import{At as e,Cn as t,Ct as n,Dt as r,Et as i,Jt as a,Kt as o,M as s,Mt as c,N as ee,Nt as l,O as u,On as d,Ot as f,P as p,Tn as m,ct as te,dt as ne,hn as h,in as g,j as _,jt as v,k as re,kt as y,lt as ie,ut as ae}from"./game-logic-CfBcTF_c.js";import"./vendor-pinia-DP9x75p8.js";import"./vendor-crypto-DGvz1MHk.js";import"./game-i18n-DEf7ySVe.js";import"./vendor-others-CUjrprN5.js";import"./vendor-reka-ui-CZQh7FLl.js";import"./vendor-utils-Dg-HLkEU.js";import"./vendor-vueuse-C7EbLx--.js";import{M as b,z as oe}from"./vendor-icons-W6Ny__75.js";import{t as se}from"./CardDescription-BjAei3DC.js";import{h as ce,u as x}from"./game-config-D-D7cMgJ.js";import{A as le,I as ue,M as S,P as C,_ as w,c as T,i as E,l as D,o as O,r as k,s as A,u as j,w as M}from"./index-DRmrr36X.js";import{t as N}from"./useGameConfig-CVlwnWOp.js";import{t as P}from"./AlertDialog-Bf_xgpJz.js";import{t as F}from"./CardUnlockOverlay-CVKjkS94.js";var I={key:0,class:`container mx-auto p-4 sm:p-6`},L={class:`flex justify-between items-center mb-4 sm:mb-6 gap-2`},R={class:`text-2xl sm:text-3xl font-bold`},z={class:`text-xs sm:text-sm`},B={class:`flex items-center gap-1.5 text-muted-foreground`},V={class:`grid grid-cols-2 lg:grid-cols-3 gap-3 sm:gap-4`},H={class:`flex justify-between items-start gap-2`},U={class:`min-w-0 flex-1`},de={class:`space-y-3`},fe={class:`text-xs sm:text-sm space-y-1.5 sm:space-y-2`},pe={class:`text-muted-foreground mb-1 sm:mb-2`},me={class:`space-y-1 sm:space-y-1.5`},he={class:`flex items-center gap-1.5 sm:gap-2`},ge={class:`text-xs`},_e={class:`flex items-center gap-1.5 sm:gap-2`},ve={class:`text-xs`},ye={class:`flex items-center gap-1.5 sm:gap-2`},be={class:`text-xs`},xe={class:`text-xs sm:text-sm space-y-0.5 sm:space-y-1`},Se={class:`flex items-center gap-1.5 text-muted-foreground`},Ce={class:`flex items-center gap-1.5 text-muted-foreground`},we={key:1,class:`text-xs text-muted-foreground`},Te={class:`flex gap-2 flex-wrap`},W=l({__name:`BuildingsView`,setup(l){let W=ue(),Ee=w(),{t:G}=C(),{BUILDINGS:K,TECHNOLOGIES:De}=N(),q=i(()=>W.currentPlanet),J=h(null),Oe=i(()=>q.value?Object.values(x).filter(e=>{let t=K.value[e];return q.value.isMoon?t.moonOnly===!0:t.moonOnly!==!0}):[]),ke=e=>{if(!W.currentPlanet||!s(W.currentPlanet,e,W.player.technologies,W.player.officers).valid)return!1;let t=re(W.currentPlanet,e,W.player.officers);return W.currentPlanet.buildQueue.push(t),!0},Ae=e=>ne(e),je=e=>{if(!X(e)){J.value?.show({title:G(`common.requirementsNotMet`),message:Z(e)});return}ke(e)||J.value?.show({title:G(`buildingsView.upgradeFailed`),message:G(`buildingsView.upgradeFailedMessage`)})},Y=e=>q.value?.buildings[e]||0,X=e=>{if(!q.value)return!1;let t=K.value[e],n=p(t,Y(e)+1);return!n||Object.keys(n).length===0?!0:ee(q.value,W.player.technologies,n)},Me=e=>{if(!q.value)return G(`buildingsView.upgrade`);let t=K.value[e],n=Y(e);return t.maxLevel!==void 0&&n>=t.maxLevel?G(`buildingsView.maxLevelReached`):q.value.buildQueue.length>0||X(e)?G(`buildingsView.upgrade`):G(`buildingsView.requirementsNotMet`)},Z=e=>{let t=K.value[e],n=p(t,Y(e)+1);if(!n||!q.value)return``;let r=[];for(let[e,t]of Object.entries(n))if(Object.values(x).includes(e)){let n=e,i=q.value.buildings[n]||0,a=K.value[n]?.name||n,o=i>=t?`✓`:`✗`;r.push(`${o} ${a}: Lv ${t} (${G(`common.current`)}: Lv ${i})`)}else if(Object.values(ce).includes(e)){let n=e,i=W.player.technologies[n]||0,a=De.value[n]?.name||n,o=i>=t?`✓`:`✗`;r.push(`${o} ${a}: Lv ${t} (${G(`common.current`)}: Lv ${i})`)}return r.join(`
`)},Ne=e=>{if(!q.value)return!1;let t=K.value[e],n=Y(e);if(t.maxLevel!==void 0&&n>=t.maxLevel||q.value.buildQueue.length>0||!s(q.value,e,W.player.technologies,W.player.officers).valid)return!1;let r=Q(e,n+1);return q.value.resources.metal>=r.metal&&q.value.resources.crystal>=r.crystal&&q.value.resources.deuterium>=r.deuterium},Q=(e,t)=>te(e,t),Pe=(e,t)=>ie(e,t),Fe=e=>{if(!W.currentPlanet||!_(W.currentPlanet,e,W.player.officers).valid)return!1;let t=u(W.currentPlanet,e,W.player.officers);return W.currentPlanet.buildQueue.push(t),!0},Ie=e=>{Fe(e)||J.value?.show({title:G(`buildingsView.demolishFailed`),message:G(`buildingsView.demolishFailedMessage`)})},Le=e=>!q.value||q.value.buildQueue.length>0?!1:Y(e)>0,$=e=>ae(e,Y(e));return(i,s)=>q.value?(o(),e(`div`,I,[r(`div`,L,[r(`h1`,R,d(t(G)(`buildingsView.title`)),1),r(`div`,z,[r(`span`,B,[c(t(b),{size:14}),v(` `+d(Ae(q.value))+` / `+d(q.value.maxSpace),1)])])]),r(`div`,V,[(o(!0),e(n,null,a(Oe.value,n=>(o(),f(t(j),{key:n,class:`relative`},{default:g(()=>[c(F,{requirements:t(K)[n].requirements,currentLevel:Y(n)},null,8,[`requirements`,`currentLevel`]),c(t(T),null,{default:g(()=>[r(`div`,H,[r(`div`,U,[c(t(A),{class:`text-base sm:text-lg cursor-pointer hover:text-primary transition-colors`,onClick:e=>t(Ee).openBuilding(n,Y(n))},{default:g(()=>[v(d(t(K)[n].name),1)]),_:2},1032,[`onClick`]),c(t(se),{class:`text-xs sm:text-sm`},{default:g(()=>[v(d(t(K)[n].description),1)]),_:2},1024)]),c(t(le),{variant:`secondary`,class:`text-xs whitespace-nowrap flex-shrink-0`},{default:g(()=>[v(`Lv `+d(Y(n)),1)]),_:2},1024)])]),_:2},1024),c(t(D),null,{default:g(()=>[r(`div`,de,[r(`div`,fe,[r(`p`,pe,d(t(G)(`buildingsView.upgradeCost`))+`:`,1),r(`div`,me,[r(`div`,he,[c(M,{type:`metal`,size:`sm`}),r(`span`,ge,d(t(G)(`resources.metal`))+`:`,1),r(`span`,{class:m([`font-medium text-xs sm:text-sm`,t(O)(q.value.resources.metal,Q(n,Y(n)+1).metal)])},d(t(k)(Q(n,Y(n)+1).metal)),3)]),r(`div`,_e,[c(M,{type:`crystal`,size:`sm`}),r(`span`,ve,d(t(G)(`resources.crystal`))+`:`,1),r(`span`,{class:m([`font-medium text-xs sm:text-sm`,t(O)(q.value.resources.crystal,Q(n,Y(n)+1).crystal)])},d(t(k)(Q(n,Y(n)+1).crystal)),3)]),r(`div`,ye,[c(M,{type:`deuterium`,size:`sm`}),r(`span`,be,d(t(G)(`resources.deuterium`))+`:`,1),r(`span`,{class:m([`font-medium text-xs sm:text-sm`,t(O)(q.value.resources.deuterium,Q(n,Y(n)+1).deuterium)])},d(t(k)(Q(n,Y(n)+1).deuterium)),3)])])]),r(`div`,xe,[r(`div`,Se,[c(t(oe),{size:14,class:`flex-shrink-0`}),r(`span`,null,d(t(E)(Pe(n,Y(n)+1))),1)]),r(`div`,Ce,[c(t(b),{size:14,class:`flex-shrink-0`}),r(`span`,null,d(t(K)[n].spaceUsage),1)])]),c(t(S),{onClick:e=>je(n),disabled:!Ne(n),class:`w-full`},{default:g(()=>[v(d(Me(n)),1)]),_:2},1032,[`onClick`,`disabled`]),Y(n)>0?(o(),f(t(S),{key:0,onClick:e=>Ie(n),disabled:!Le(n),variant:`destructive`,class:`w-full`},{default:g(()=>[v(d(t(G)(`buildingsView.demolish`)),1)]),_:1},8,[`onClick`,`disabled`])):y(``,!0),Y(n)>0?(o(),e(`div`,we,[r(`p`,null,d(t(G)(`buildingsView.demolishRefund`))+`:`,1),r(`div`,Te,[r(`span`,null,d(t(k)($(n).metal))+` `+d(t(G)(`resources.metal`)),1),r(`span`,null,d(t(k)($(n).crystal))+` `+d(t(G)(`resources.crystal`)),1),r(`span`,null,d(t(k)($(n).deuterium))+` `+d(t(G)(`resources.deuterium`)),1)])])):y(``,!0)])]),_:2},1024)]),_:2},1024))),128))]),c(P,{ref_key:`alertDialog`,ref:J},null,512)])):y(``,!0)}});export{W as default};