import{$t as e,En as t,J as n,On as r,Rn as i,Yn as a,ar as o,at as s,cn as ee,cr as c,dn as l,fn as u,ln as te,nt as d,on as f,pn as ne,q as re,qt as ie,rn as p,rr as m,sn as h,tt as g,un as _,zn as ae}from"./game-logic-BBFCPVtv.js";import"./vendor-pinia-L_8CmDWM.js";import"./vendor-vue-router-0mfLVB6Y.js";import"./vendor-crypto-CQM8pryk.js";import"./game-i18n-BC9uiVvf.js";import"./vendor-others-Bce0hM6h.js";import"./vendor-reka-ui-DR3m_AkV.js";import"./vendor-utils-BlvnUqQX.js";import"./vendor-vueuse-Djj-oRw9.js";import"./vendor-icons-Ccm2_GPI.js";import{t as oe}from"./CardDescription-DduF5EVY.js";import{d as v,v as y}from"./game-config-DRP-gbpS.js";import{$ as se,A as ce,F as le,I as ue,J as de,K as b,L as x,M as S,N as C,X as w,d as T,f as E,j as D,k as O,l as k,m as A,o as j,p as M,x as N}from"./index-B4KMqZ_y.js";import{t as P}from"./useGameConfig-DLqfPHtW.js";import{t as F}from"./CardUnlockOverlay-CspXlcWR.js";import{t as I}from"./UnlockRequirement-DJ9dN5JL.js";var L={key:0,class:`container mx-auto p-4 sm:p-6`},R={class:`text-2xl sm:text-3xl font-bold mb-4 sm:mb-6`},z={class:`grid grid-cols-2 lg:grid-cols-3 gap-3 sm:gap-4`},fe={class:`mb-2`},B={class:`flex flex-col sm:flex-row sm:justify-between sm:items-start gap-2`},V={class:`space-y-2.5 sm:space-y-3`},pe={class:`text-xs sm:text-sm space-y-1.5 sm:space-y-2`},me={class:`text-muted-foreground mb-1 sm:mb-2`},he={class:`space-y-1 sm:space-y-1.5`},ge={class:`text-xs`},H=ne({__name:`ResearchView`,setup(ne){let H=se(),_e=N(),{t:U}=w(),{TECHNOLOGIES:W,BUILDINGS:ve}=P(),G=f(()=>H.currentPlanet),K=f(()=>H.player),q=a(!1),J=a(``),Y=a(``),ye=[{key:`metal`},{key:`crystal`},{key:`deuterium`},{key:`darkMatter`}],X=e=>{if(!H.currentPlanet||!n(H.currentPlanet,e,H.player.technologies,H.player.researchQueue).valid)return!1;let t=H.player.technologies[e]||0,{queueItem:r}=re(H.currentPlanet,e,t,H.player.officers,H.player.technologies);return H.player.researchQueue.push(r),!0},Z=e=>{if(!G.value)return!1;let t=W.value[e],n=d(t,Q(e)+1);return!n||Object.keys(n).length===0?!0:g(G.value,H.player.technologies,n)},be=e=>{if(!G.value)return U(`researchView.research`);let t=W.value[e],n=Q(e);if(t.maxLevel!==void 0&&n>=t.maxLevel)return U(`researchView.maxLevelReached`);let r=s(H.player.technologies);return K.value.researchQueue.length>=r||Z(e)?U(`researchView.research`):U(`buildingsView.requirementsNotMet`)},xe=e=>{let t=W.value[e],n=d(t,Q(e)+1);if(!n||!G.value)return``;let r=[];for(let[e,t]of Object.entries(n))if(Object.values(v).includes(e)){let n=e,i=G.value.buildings[n]||0,a=ve.value[n]?.name||n,o=i>=t?`✓`:`✗`;r.push(`${o} ${a}: Lv ${t} (${U(`common.current`)}: Lv ${i})`)}else if(Object.values(y).includes(e)){let n=e,i=H.player.technologies[n]||0,a=W.value[n]?.name||n,o=i>=t?`✓`:`✗`;r.push(`${o} ${a}: Lv ${t} (${U(`common.current`)}: Lv ${i})`)}return r.join(`
`)},Se=e=>{if(!Z(e)){J.value=U(`common.requirementsNotMet`),Y.value=xe(e),q.value=!0;return}X(e)||(J.value=U(`researchView.researchFailed`),Y.value=U(`researchView.researchFailedMessage`),q.value=!0)},Q=e=>K.value.technologies[e]||0,Ce=e=>{if(!G.value)return!1;let t=W.value[e],n=Q(e);if(t.maxLevel!==void 0&&n>=t.maxLevel)return!1;let r=s(H.player.technologies);if(K.value.researchQueue.length>=r)return!1;let i=$(e,n+1);return g(G.value,H.player.technologies,t.requirements)&&G.value.resources.metal>=i.metal&&G.value.resources.crystal>=i.crystal&&G.value.resources.deuterium>=i.deuterium&&G.value.resources.darkMatter>=i.darkMatter},$=(e,t)=>ie(e,t);return(n,a)=>G.value?(t(),_(`div`,L,[u(I,{"required-building":m(v).ResearchLab,"required-level":1},null,8,[`required-building`]),h(`h1`,R,c(m(U)(`researchView.title`)),1),h(`div`,z,[(t(!0),_(p,null,r(Object.values(m(y)),n=>(t(),ee(m(A),{key:n,class:`relative`},{default:i(()=>[u(F,{requirements:m(W)[n].requirements,currentLevel:Q(n)},null,8,[`requirements`,`currentLevel`]),u(m(E),null,{default:i(()=>[h(`div`,fe,[h(`div`,B,[u(m(T),{class:`text-sm sm:text-base lg:text-lg cursor-pointer hover:text-primary transition-colors underline decoration-dotted underline-offset-4 order-2 sm:order-1`,onClick:e=>m(_e).openTechnology(n,Q(n))},{default:i(()=>[l(c(m(W)[n].name),1)]),_:2},1032,[`onClick`]),u(m(b),{variant:`secondary`,class:`text-xs whitespace-nowrap self-start order-1 sm:order-2`},{default:i(()=>[l(` Lv `+c(Q(n)),1)]),_:2},1024)])]),u(m(oe),{class:`text-xs sm:text-sm`},{default:i(()=>[l(c(m(W)[n].description),1)]),_:2},1024)]),_:2},1024),u(m(M),null,{default:i(()=>[h(`div`,V,[h(`div`,pe,[h(`p`,me,c(m(U)(`researchView.researchCost`))+`:`,1),h(`div`,he,[(t(),_(p,null,r(ye,t=>ae(h(`div`,{key:t.key,class:`flex items-center gap-1.5 sm:gap-2`},[u(x,{type:t.key,size:`sm`},null,8,[`type`]),h(`span`,ge,c(m(U)(`resources.${t.key}`))+`:`,1),h(`span`,{class:o([`font-medium text-xs sm:text-sm`,m(k)(G.value.resources[t.key],$(n,Q(n)+1)[t.key])])},c(m(j)($(n,Q(n)+1)[t.key])),3)]),[[e,t.key!==`darkMatter`||$(n,Q(n)+1).darkMatter>0]])),64))])]),u(m(de),{onClick:e=>Se(n),disabled:!Ce(n),class:`w-full`},{default:i(()=>[l(c(be(n)),1)]),_:2},1032,[`onClick`,`disabled`])])]),_:2},1024)]),_:2},1024))),128))]),u(m(ue),{open:q.value,"onUpdate:open":a[0]||=e=>q.value=e},{default:i(()=>[u(m(C),null,{default:i(()=>[u(m(ce),null,{default:i(()=>[u(m(O),null,{default:i(()=>[l(c(J.value),1)]),_:1}),u(m(S),{class:`whitespace-pre-line`},{default:i(()=>[l(c(Y.value),1)]),_:1})]),_:1}),u(m(D),null,{default:i(()=>[u(m(le),null,{default:i(()=>[l(c(m(U)(`common.confirm`)),1)]),_:1})]),_:1})]),_:1})]),_:1},8,[`open`])])):te(``,!0)}});export{H as default};