import{u as a,a as s,m as e}from"./index.751353e8.js";import{b as l,c as t,d as n,f as r,g as o,h as u,t as c,n as i}from"./vendor.38cc6e40.js";const d={class:"zip-import-view"},v={class:"panel-card task-card"},p={class:"panel-card__body task-card__body"},m={class:"path-box"},g={class:"task-actions"},b=["disabled"],h=["disabled"],k={class:"task-status-box__badge"},f={class:"task-status-box__content"},y={__name:"ZipImportView",setup(y){const P=l({path:null,unlocker:"none"}),I=l(null),_=l(""),Z=l(!1),w=l("idle"),x=l("等待导入"),z=l("请选择本地 ZIP 文件。"),{setEnvironment:L,setLastAction:C,showToast:A}=a(),{addLog:$,addLogs:j}=s(),D=t((()=>({idle:"待命",running:"进行中",success:"已完成",error:"失败"}[w.value]||"待命"))),S=(a,s,e)=>{w.value=a,x.value=s,z.value=e},T=a=>{(null==a?void 0:a.message)&&($(a.message,a.type||"info"),S("running","任务执行中",a.message))},E=()=>{var a,s;null==(s=null==(a=I.value)?void 0:a.click)||s.call(a)},K=a=>{var s;const e=(a=>{const s=Array.from(a||[]).find((a=>String((null==a?void 0:a.name)||"").toLowerCase().endsWith(".zip")));return String((null==s?void 0:s.path)||"").trim()})((null==(s=null==a?void 0:a.target)?void 0:s.files)||[]);e?(_.value=e,$(`已选择本地 ZIP：${e}`,"success"),S("idle","等待开始",e)):A("未读取到有效 ZIP 文件。","warning")},R=async()=>{if(_.value.trim()){Z.value=!0,S("running","任务已启动","正在准备导入本地 ZIP...");try{const a=await e.startLocalZipImportTask({zipPath:_.value.trim(),steamPath:P.value.path,unlocker:P.value.unlocker,addAllDlc:!0,patchDepotKey:!1,onProgress:T});S(a.success?"success":"error",a.success?"任务执行成功":"任务执行失败",a.summary),C(a.summary),A(a.success?"ZIP 导入成功。":a.summary||"ZIP 导入失败。",a.success?"success":"error")}catch(a){const s=`ZIP 导入异常：${a.message}`;$(s,"error"),S("error","任务执行失败",s),C(s),A(s,"error")}finally{Z.value=!1}}else A("请先选择 ZIP 文件。","info")};return n((async()=>{const a=await e.initialize();P.value.path=a.steamPath,P.value.unlocker=a.unlocker,a.logs&&j(a.logs),L({steamPath:a.steamPath,unlocker:a.unlocker})})),(a,s)=>(r(),o("div",d,[u("section",v,[s[1]||(s[1]=u("header",{class:"panel-card__header"},[u("h2",null,"ZIP 本地入库")],-1)),u("div",p,[u("input",{ref_key:"fileInputRef",ref:I,class:"file-input",type:"file",accept:".zip",onChange:K},null,544),u("div",m,[s[0]||(s[0]=u("strong",null,"当前 ZIP",-1)),u("p",null,c(_.value||"还没有选择 ZIP 文件"),1)]),u("div",g,[u("button",{class:"secondary-btn",type:"button",disabled:Z.value,onClick:E}," 选择 ",8,b),u("button",{class:"primary-btn",type:"button",disabled:Z.value,onClick:R},c(Z.value?"开始中...":"开始"),9,h)]),u("section",{class:i(["task-status-box",`task-status-box--${w.value}`])},[u("div",k,c(D.value),1),u("div",f,[u("strong",null,c(x.value),1),u("p",null,c(z.value),1)])],2)])])]))},__scopeId:"data-v-4299cfc6"};export{y as default};
