aitu-app 0.9.2 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/assets/{CanvasAudioPlayer-C_USx5uz.js → CanvasAudioPlayer-BKMfe-GO.js} +2 -2
- package/assets/{ComicCreator-qGQaXp7h.js → ComicCreator-D5HnnPYu.js} +3 -3
- package/assets/DeferredAIInputBar-CVXfAbVO.css +1 -0
- package/assets/DeferredAIInputBar-Ce250DxA.js +107 -0
- package/assets/{DrawnixDeferredFeatures-Hy_-quZ1.js → DrawnixDeferredFeatures-ue9KjDJ6.js} +2 -2
- package/assets/{KnowledgeBaseContent-DSKNA70H.js → KnowledgeBaseContent-YCNU2vP8.js} +5 -5
- package/assets/{MVCreator-C3iClDLU.js → MVCreator-uWWF5q7x.js} +4 -4
- package/assets/{ModelBenchmarkWorkbench-BxwdcZ0q.js → ModelBenchmarkWorkbench-Bm75hOT0.js} +2 -2
- package/assets/{MusicAnalyzer-f_T6_YPJ.js → MusicAnalyzer-BXe6y3_p.js} +1 -1
- package/assets/ParametersDropdown-BE58BbHs.css +1 -0
- package/assets/{ParametersDropdown-CTSN3ClD.js → ParametersDropdown-wKdOCk_p.js} +1 -1
- package/assets/{PromptHistoryTool-DV-8RSdz.js → PromptHistoryTool-BRMlnlE1.js} +2 -2
- package/assets/{ResizableDivider-CUQBmPpx.js → ResizableDivider-tAq9KErj.js} +1 -1
- package/assets/{TaskQueuePanel-CtjY1W4t.js → TaskQueuePanel-D4PA4azU.js} +1 -1
- package/assets/{VideoAnalyzer-BBVBSONO.js → VideoAnalyzer-CVqV3zd3.js} +3 -3
- package/assets/{VideoAnalyzer-BmAjGvN8.js → VideoAnalyzer-gVfFvd5A.js} +1 -1
- package/assets/{ai-chat-BO5vbKZW.js → ai-chat-D_s8vs6j.js} +45 -45
- package/assets/{ai-chat-DyV67c_f.css → ai-chat-_KImIteT.css} +1 -1
- package/assets/{ai-generation-preferences-service-ZmPTR-wz.js → ai-generation-preferences-service-rBqGBu1Z.js} +1 -1
- package/assets/{batch-image-generation-BLBSv-t6.js → batch-image-generation-BHunNwyR.js} +6 -6
- package/assets/{diagram-engines-CSzW_-6N.js → diagram-engines-y0JSIEUO.js} +3 -3
- package/assets/{editor-engines-C573k8UM.js → editor-engines-Cc9_gvTn.js} +1 -1
- package/assets/{index-BT-rxxI3.js → index-BECJnoIM.js} +1 -1
- package/assets/{index-jxwTv7c1.js → index-BOOKwIS8.js} +1 -1
- package/assets/{index-N8asYyaz.js → index-Co0sFz6V.js} +2 -2
- package/assets/{index-IHNaVKGH.js → index-CrsvRs42.js} +1 -1
- package/assets/{index-Dw_8lcIi.js → index-Dthb4yKS.js} +1 -1
- package/assets/{index.es-BLXvmueB.js → index.es-l6CUS7uC.js} +1 -1
- package/assets/{jspdf.es.min-DxWvbkh4.js → jspdf.es.min-vSonSXg8.js} +3 -3
- package/assets/{markdown-to-drawnix-BVFYnimo.js → markdown-to-drawnix-CkXxETO6.js} +3 -3
- package/assets/{mermaid-to-drawnix-nGs2aeZ7.js → mermaid-to-drawnix-CiiYHL53.js} +3 -3
- package/assets/{model-benchmark-launcher-DAWoSySc.js → model-benchmark-launcher-EfxZ9z3O.js} +1 -1
- package/assets/{photo-wall-splitter-CCUURzGk.js → photo-wall-splitter-BJ5RLX6n.js} +1 -1
- package/assets/{prompt-utils-MF_LILNU.js → prompt-utils-7NlWAivq.js} +1 -1
- package/assets/{settings-dialog-Ac7R-_CG.js → settings-dialog-CBNPo-wJ.js} +1 -1
- package/assets/{skill-dsl-parser-Do9iAYbB.js → skill-dsl-parser-9CW3IgX7.js} +1 -1
- package/assets/{startup-app-CKHrOmQ0.css → startup-app-BJH8E5sr.css} +1 -1
- package/assets/{startup-app-eD_rQhSh.js → startup-app-M6vjXkRC.js} +509 -504
- package/assets/{task-sync-BJVOunRa.js → task-sync-B01Tbv7m.js} +1 -1
- package/assets/{tool-windows-CmgL3thd.js → tool-windows-Cf62DjP-.js} +21 -21
- package/assets/ttd-dialog-O1oaoYry.js +6 -0
- package/assets/{ttd-dialog-submit-shortcut-C2lJygXA.js → ttd-dialog-submit-shortcut-rkvbdHF7.js} +1 -1
- package/assets/{useCharacters-BAKE4TeJ.js → useCharacters-BVPiqeuF.js} +1 -1
- package/assets/{useMediaViewer-BGw5RkSR.js → useMediaViewer-Be0fy5RZ.js} +1 -1
- package/assets/{useWorkflowSubmission-iAPmKke9.js → useWorkflowSubmission-BwYRubj-.js} +9 -9
- package/assets/{video-recovery-service-CW7bErP2.js → video-recovery-service-CUmfssNZ.js} +1 -1
- package/assets/{workflow-generation-utils-DhIVnOHO.js → workflow-generation-utils-362XEGgT.js} +3 -3
- package/assets/{workflow-submission-service-Ce0cpj8E.js → workflow-submission-service-Dk47OkGu.js} +2 -2
- package/changelog.json +18 -13
- package/idle-prefetch-manifest.json +286 -286
- package/manifest.json +3 -3
- package/package.json +1 -1
- package/precache-manifest.json +6 -6
- package/sw.js +1 -1
- package/version.json +3 -4
- package/assets/DeferredAIInputBar-CPykEFYX.css +0 -1
- package/assets/DeferredAIInputBar-LmZGQCLT.js +0 -107
- package/assets/ParametersDropdown-b2oWAycj.css +0 -1
- package/assets/ttd-dialog-B12v0SVY.js +0 -6
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{_ as yt}from"./startup-runtime-DTmhLESk.js";import{fB as Gs,ee as
|
|
2
|
-
`)}function Ca(b){const k={...b};return k.size==="auto"&&delete k.size,Object.keys(k).length>0?k:void 0}function ls(b){return b instanceof Element&&!!b.closest('input, textarea, [contenteditable="true"]')}function Sa(){const b=[];for(let k=0;k<5;k++)b.push({id:k+1,prompt:"",params:{size:"auto"},images:[],count:1,taskIds:[]});return b}const Aa=({onSwitchToSingle:b,selectedModel:k,selectedModelRef:z,onModelChange:R,onModelRefChange:M})=>{var Jt;const{language:r}=Gs(),{confirm:F,confirmDialog:se}=Vs(),_=ma("image"),{createTask:X,tasks:ae}=Js(),{addAsset:U,assets:is,loadAssets:Nt}=Hs(),{isMobile:os,isTablet:cs}=qs(),Rt=os||cs,_t=is.filter(t=>t.type===be.IMAGE);o.useEffect(()=>{Nt()},[Nt]);const[w,A]=o.useState(Sa),[ne,Ne]=o.useState(6),[et,Et]=o.useState(!1),[re,me]=o.useState(!1),he=o.useRef(!1),[tt,us]=o.useState([]);o.useEffect(()=>{let t=!0;return qt.get(ss).then(e=>{t&&(e&&e.tasks&&Array.isArray(e.tasks)&&e.tasks.length>0&&(A(e.tasks),e.taskIdCounter&&Ne(e.taskIdCounter)),Et(!0))}).catch(e=>{console.warn("Failed to load batch image cache:",e),t&&Et(!0)}),()=>{t=!1}},[]);const[j,le]=o.useState(null),[I,Y]=o.useState([]),[Q,O]=o.useState(null),[ie,xe]=o.useState(null),[C,Z]=o.useState(new Set),{validSelectedRows:za,selectedTaskCount:Na,selectedInfoText:ds}=o.useMemo(()=>{const t=[...C].filter(n=>{const l=w[n];return l&&l.prompt&&l.prompt.trim()!==""}).sort((n,l)=>n-l),e=t.reduce((n,l)=>{const u=w[l];return n+((u==null?void 0:u.count)||1)},0),s=t.length>0?r==="zh"?`已选 ${t.length} 行 / ${e} 任务`:`${t.length} rows / ${e} tasks`:"";return{validSelectedRows:t,selectedTaskCount:e,selectedInfoText:s}},[C,w,r]),G=o.useRef([]),V=o.useRef(-1),ye=o.useRef(!1),[Tt,st]=o.useState(!0),[ms,at]=o.useState(!1),[J,Dt]=o.useState(!1),[K,Mt]=o.useState(null),[$t,Pt]=o.useState([]),[Re,nt]=o.useState(null),[we,rt]=o.useState(!1),[_e,lt]=o.useState(null),[hs,it]=o.useState(null),[ee,fs]=o.useState(1),[ps,ot]=o.useState(!1),[L,ct]=o.useState([]),[oe,At]=o.useState(1),ut=o.useMemo(()=>L.slice(0,12).map(t=>URL.createObjectURL(t)),[L]);o.useEffect(()=>()=>{ut.forEach(t=>URL.revokeObjectURL(t))},[ut]);const ce=Wt("image"),Ee=Ye(_,ce.modelId,vt(ce.profileId,ce.modelId))||ts("image",ce.modelId,vt(ce.profileId,ce.modelId)),[x,Te]=o.useState((Ee==null?void 0:Ee.id)||((Jt=_[0])==null?void 0:Jt.id)||"gemini-2.5-flash-image-vip"),[B,De]=o.useState(Qe(Ee)||vt(ce.profileId,ce.modelId)),ue=o.useMemo(()=>{if(Ye(_,x,B)||!x)return _;const e=ts("image",x,B);return e?[e,..._]:_},[_,x,B]),dt=o.useMemo(()=>Ct(x,B),[x,B]),Lt=o.useMemo(()=>zt(x),[x]),S=o.useMemo(()=>ka(x,dt).extraParams,[x,dt]);o.useEffect(()=>{A(t=>{let e=!1;const s=t.map(n=>{const l=pe(n,x,S),u=typeof n.size=="string",c=ke(n.params)?n.params:{};if(!u&&ya(c,l))return n;e=!0;const{size:d,...f}=n;return{...f,params:l}});return e?s:t})},[et,S,x]),o.useEffect(()=>{if(ue.length===0)return;Ye(ue,x,B)||(Te(ue[0].id),De(Qe(ue[0])))},[x,B,ue]),o.useEffect(()=>{if(!k)return;const t=Ct(x,B),e=Ct(k,z);if(t!==e){Te(k);const s=Ye(ue,k,z);De(Qe(s)||z||null)}},[k,z,x,B,ue]);const{openViewer:It,viewerProps:gs}=pa(),[ve,mt]=o.useState(null),[ws,Me]=o.useState(!1),[$e,bs]=o.useState(5),[Ot,ht]=o.useState(!1),[ft,pt]=o.useState(null),Pe=o.useRef(null),Ae=o.useRef(null),Le=o.useRef(null),Ie=o.useRef(null),Kt=o.useRef(null),Oe=o.useRef(null),gt=o.useRef(null),Ke=o.useRef(null),Fe=o.useCallback(()=>{var t;(t=Ke.current)==null||t.focus({preventScroll:!0})},[]),Be=o.useCallback(t=>{const e=Ke.current;if(!e)return!1;const s=t.target instanceof Element?t.target:null;if(s&&e.contains(s))return!0;const n=document.activeElement;return n instanceof Element&&e.contains(n)},[]);o.useEffect(()=>{if(!et)return;const t={tasks:w,taskIdCounter:ne,timestamp:Date.now()};qt.set(ss,t).catch(e=>{console.warn("Failed to save batch image cache:",e)})},[w,ne,et]);const Ft=o.useCallback((t,e,s,n)=>{if(ye.current){ye.current=!1;return}G.current=G.current.slice(0,V.current+1);const l={tasks:JSON.parse(JSON.stringify(t)),selectedCells:[...e],activeCell:s?{...s}:null,selectedRows:Array.from(n)};G.current.push(l),V.current=G.current.length-1,G.current.length>50&&(G.current.shift(),V.current--)},[]);o.useEffect(()=>{w.length>0&&Ft(w,I,j,C)},[w,Ft]),o.useEffect(()=>{if(G.current.length>0&&V.current>=0&&!ye.current){const t=G.current[V.current];t&&(t.selectedCells=[...I],t.activeCell=j?{...j}:null,t.selectedRows=Array.from(C))}},[I,j,C]);const Bt=o.useCallback(()=>{if(V.current>0){V.current--,ye.current=!0;const t=G.current[V.current];A(JSON.parse(JSON.stringify(t.tasks))),Y([...t.selectedCells]),le(t.activeCell?{...t.activeCell}:null),Z(new Set(t.selectedRows)),y.info(r==="zh"?"已撤销":"Undone")}else y.warning(r==="zh"?"没有可撤销的操作":"Nothing to undo")},[r]),Ut=o.useCallback(()=>{if(V.current<G.current.length-1){V.current++,ye.current=!0;const t=G.current[V.current];A(JSON.parse(JSON.stringify(t.tasks))),Y([...t.selectedCells]),le(t.activeCell?{...t.activeCell}:null),Z(new Set(t.selectedRows)),y.info(r==="zh"?"已重做":"Redone")}else y.warning(r==="zh"?"没有可重做的操作":"Nothing to redo")},[r]),ks=o.useCallback(t=>{A(e=>{const s=[...e];for(let n=0;n<t;n++)s.push({id:ne+n,prompt:"",params:{...S},images:[],count:1,taskIds:[]});return s}),Ne(e=>e+t)},[S,ne]),xs=o.useCallback(()=>{if(C.size===0){y.warning(r==="zh"?"请先勾选要删除的行":"Please check rows to delete");return}A(t=>t.filter((e,s)=>!C.has(s))),Z(new Set),Y([]),le(null)},[C,r]),N=o.useCallback((t,e)=>{Fe(),le({row:t,col:e}),Y([{row:t,col:e}]),O(null),xe(null)},[Fe]),Ue=o.useCallback((t,e)=>{if(N(t,e),e==="params"){xe({row:t,col:e});return}$.includes(e)&&e!=="images"&&O({row:t,col:e})},[N]),E=o.useCallback((t,e,s)=>{A(n=>{if(!n[t])return n;const l=[...n];return e==="params"?(l[t]={...l[t],params:pe({...l[t],params:ke(s)?s:{}},x,S)},l):e==="size"?(l[t]={...l[t],params:pe({...l[t],size:String(s||"")},x,S)},l):(l[t]={...l[t],[e]:s},l)})},[S,x]),Gt=o.useCallback((t,e,s)=>{const n=t.split(/\r?\n/).filter(u=>u.trim());if(n.length===0)return;const l=(u,c,d)=>{if(!(u<0||u>=w.length))if(c==="prompt")E(u,c,d);else if(c==="count"){const f=parseInt(d,10);!isNaN(f)&&f>=1&&E(u,c,f)}else(c==="params"||c==="size")&&E(u,"params",rs(d,x,S))};if(n.length===1||s.length>1){const u=n[0];s.forEach(c=>l(c.row,c.col,u));return}n.forEach((u,c)=>{l(e.row+c,e.col,u)})},[S,x,w.length,E]),Vt=o.useCallback((t,e)=>{const s=window.__copiedCells;if(!s||s.length===0)return!1;if(s.length===1){const n=s[0];return e.forEach(l=>{l.col===n.col&&E(l.row,l.col,n.value)}),!0}return s.forEach((n,l)=>{const u=t.row+l;u<w.length&&E(u,t.col,n.value)}),!0},[w.length,E]),je=o.useCallback((t,e,s)=>{if(t.shiftKey&&j){const n=Math.min(j.row,e),l=Math.max(j.row,e);Z(c=>{const d=new Set(c);for(let f=n;f<=l;f++)d.add(f);return d});const u=[];for(let c=n;c<=l;c++)u.push({row:c,col:j.col});Y(u),Kt.current=e}else t.ctrlKey||t.metaKey?Y(n=>n.some(u=>u.row===e&&u.col===s)?n.filter(u=>!(u.row===e&&u.col===s)):[...n,{row:e,col:s}]):(N(e,s),Kt.current=e)},[j,N]),Ge=o.useCallback(t=>{var s;if(!j){y.warning(r==="zh"?"请先选中一个单元格作为填充源":"Please select a cell as fill source");return}const e=(s=w[j.row])==null?void 0:s[t];if(e==null||typeof e=="string"&&e.trim()===""||Array.isArray(e)&&e.length===0){y.warning(r==="zh"?"选中的单元格没有数据":"Selected cell has no data");return}A(n=>n.map(l=>({...l,[t]:as(e)}))),y.success(r==="zh"?"已填充整列":"Column filled")},[j,w,r]),Ve=o.useCallback((t,e)=>{rt(!1),lt(null),Dt(!0),Mt({row:t,col:e}),nt(t)},[]),wt=o.useCallback((t,e)=>{J||(Fe(),rt(!0),lt({row:t,col:e}),le({row:t,col:e}),Y([{row:t,col:e}]))},[Fe,J]),ys=o.useCallback(t=>{if(!J&&!we)return;const s=t.target.closest("tr[data-row-index]");if(!s)return;const n=parseInt(s.dataset.rowIndex||"-1");if(!(n<0)){if(J&&K){nt(n);const l=K.row,u=n,c=Math.min(l,u),d=Math.max(l,u),f=[];for(let m=c;m<=d;m++)m!==l&&f.push(m);Pt(f)}if(we&&_e){const l=_e.col,u=_e.row,c=n,d=Math.min(u,c),f=Math.max(u,c),m=[];for(let i=d;i<=f;i++)m.push({row:i,col:l});Y(m)}}},[J,K,we,_e]),Je=o.useCallback(()=>{var t;if(J&&K&&Re!==null&&Re!==K.row){const e=(t=w[K.row])==null?void 0:t[K.col],s=K.row,n=Re,l=Math.min(s,n),u=Math.max(s,n);A(d=>{const f=[...d];for(let m=l;m<=u;m++)m!==s&&f[m]&&(f[m]={...f[m],[K.col]:as(e)});return f});const c=[];for(let d=l;d<=u;d++)c.push({row:d,col:K.col});Y(c),y.success(r==="zh"?`已填充 ${Math.abs(n-s)} 行`:`Filled ${Math.abs(n-s)} rows`)}Dt(!1),Mt(null),nt(null),Pt([]),rt(!1),lt(null)},[J,K,Re,w,r]),vs=o.useCallback(t=>{const e=t.target.files;e&&(Array.from(e).forEach(s=>{s.type.startsWith("image/")&&U(s,be.IMAGE,We.LOCAL,s.name).catch(n=>{console.warn("[BatchImageGeneration] Failed to add asset to library:",n)})}),Pe.current&&(Pe.current.value=""))},[U]),js=o.useCallback(t=>{let e=[];if(C.size>0?e=[...C]:I.length>0?e=[...new Set(I.map(s=>s.row))]:j&&(e=[j.row]),e.length===0){y.warning(r==="zh"?"请先选中要添加图片的行":"Please select a row first");return}A(s=>{const n=[...s];return e.forEach(l=>{n[l]&&!n[l].images.includes(t)&&(n[l]={...n[l],images:[...n[l].images,t]})}),n})},[C,I,j,r]),fe=o.useCallback((t,e)=>{A(s=>{const n=[...s];return n[t]&&!n[t].images.includes(e)&&(n[t]={...n[t],images:[...n[t].images,e]}),n})},[]),Cs=o.useCallback((t,e)=>{A(s=>{const n=[...s];return n[t]&&(n[t]={...n[t],images:n[t].images.filter(l=>l!==e)}),n})},[]),Ss=o.useCallback(t=>{const e=t.target.files,s=gt.current;!e||e.length===0||s===null||(Array.from(e).forEach(n=>{if(!n.type.startsWith("image/"))return;U(n,be.IMAGE,We.LOCAL,n.name).catch(u=>{console.warn("[BatchImageGeneration] Failed to add asset to library:",u)});const l=new FileReader;l.onload=u=>{var d;const c=(d=u.target)==null?void 0:d.result;fe(s,c)},l.readAsDataURL(n)}),Ie.current&&(Ie.current.value=""),gt.current=null)},[fe,U]),zs=o.useCallback(t=>{var e;gt.current=t,st(!0),(e=Ie.current)==null||e.click()},[]),Ns=o.useCallback(t=>{pt(t),ht(!0)},[]),Rs=o.useCallback(t=>{ft!==null&&(t.url&&fe(ft,t.url),ht(!1),pt(null))},[ft,fe]),_s=o.useCallback((t,e)=>{t.preventDefault(),t.dataTransfer.dropEffect="copy",it(e)},[]),Es=o.useCallback(t=>{const e=t.relatedTarget;(!e||!t.currentTarget.contains(e))&&it(null)},[]),Ts=o.useCallback((t,e)=>{t.preventDefault(),it(null);const s=t.dataTransfer.getData("text/library-image");if(s){fe(e,s),y.success(r==="zh"?`已添加图片到第 ${e+1} 行`:`Added image to row ${e+1}`);return}const n=t.dataTransfer.files;if(!n||n.length===0)return;let l=0;Array.from(n).forEach(u=>{if(!u.type.startsWith("image/"))return;U(u,be.IMAGE,We.LOCAL,u.name).catch(d=>{console.warn("[BatchImageGeneration] Failed to add asset to library:",d)});const c=new FileReader;c.onload=d=>{var m;const f=(m=d.target)==null?void 0:m.result;fe(e,f)},c.readAsDataURL(u),l++}),l>0&&y.success(r==="zh"?`已添加 ${l} 张图片到第 ${e+1} 行`:`Added ${l} images to row ${e+1}`)},[fe,r,U]),Ds=o.useCallback((t,e)=>{t.dataTransfer.setData("text/library-image",e),t.dataTransfer.effectAllowed="copy"},[]),Ms=o.useCallback(t=>{const e=t.target.files;if(!e||e.length===0)return;const s=Array.from(e).filter(l=>l.type.startsWith("image/"));if(s.length===0){y.warning(r==="zh"?"请选择图片文件":"Please select image files");return}ct(s);const n=j?j.row+1:1;At(Math.min(n,w.length)),ot(!0),Ae.current&&(Ae.current.value="")},[r,j,w.length]),$s=o.useCallback(async()=>{if(L.length===0)return;const t=Xs(`批量导入(${L.length}张)`),e=ee,s=L.length,n=Math.ceil(s/e),l=oe-1,u=[];for(const m of L){U(m,be.IMAGE,We.LOCAL,m.name).catch(p=>{console.warn("[BatchImageGeneration] Failed to add asset to library:",p)});const i=await new Promise((p,h)=>{const g=new FileReader;g.onload=v=>{var T;return p((T=v.target)==null?void 0:T.result)},g.onerror=h,g.readAsDataURL(m)});u.push(i)}A(m=>{const i=[...m];let p=0,h=0;for(let g=0;g<n;g++){const v=l+g,T=[];for(let H=0;H<e&&p<s;H++)T.push(u[p]),p++;v<i.length?i[v]={...i[v],images:[...i[v].images,...T]}:(i.push({id:ne+h,prompt:"",params:{...S},images:T,count:1,taskIds:[]}),h++)}return i});const c=Math.min(n,w.length-l),d=Math.max(0,n-c);d>0&&Ne(m=>m+d),ct([]),ot(!1),t();const f=r==="zh"?`已导入 ${s} 张图片,从第 ${oe} 行开始`:`Imported ${s} images starting from row ${oe}`;y.success(f)},[L,ee,oe,ne,w.length,r,U,S]),bt=o.useCallback(()=>{ct([]),ot(!1)},[]),Ps=o.useCallback(async()=>{try{const t=await yt(()=>import("./office-data-ByisqnCq.js").then(l=>l.x),[],import.meta.url),e=[{提示词:"一只可爱的橘猫在阳光下睡觉",参数:ge({...S,size:"1x1"}),数量:1},{提示词:"未来城市的夜景,霓虹灯闪烁",参数:ge({...S,size:"16x9"}),数量:2},{提示词:"古风美女,水墨画风格",参数:ge({...S,size:"3x4"}),数量:1},{提示词:"",参数:ge(S),数量:1},{提示词:"",参数:ge(S),数量:1}],s=t.utils.book_new(),n=t.utils.json_to_sheet(e);n["!cols"]=[{wch:60},{wch:24},{wch:8}],t.utils.book_append_sheet(s,n,"批量出图模板"),t.writeFile(s,"batch-image-template.xlsx"),y.success(r==="zh"?"模板下载成功,填写后可导入使用":"Template downloaded, fill and import to use")}catch(t){console.error("Excel template download error:",t),y.error(r==="zh"?"下载失败,请稍后重试":"Download failed, please try again")}},[S,r]),As=o.useCallback(async t=>{var s;const e=(s=t.target.files)==null?void 0:s[0];if(e){try{const n=await yt(()=>import("./office-data-ByisqnCq.js").then(u=>u.x),[],import.meta.url),l=new FileReader;l.onload=u=>{var c;try{const d=new Uint8Array((c=u.target)==null?void 0:c.result),f=n.read(d,{type:"array"}),m=f.SheetNames[0],i=f.Sheets[m],p=n.utils.sheet_to_json(i);if(p.length===0){y.warning(r==="zh"?"Excel 文件为空":"Excel file is empty");return}const h=p.map((g,v)=>{const T=g.提示词||g.prompt||g.Prompt||"",H=g.参数||g.params||g.Params||"",te=g.尺寸||g.size||g.Size||"",q=H?rs(String(H),x,S):pe({params:S,size:String(te)},x,S),qe=parseInt(String(g.数量||g.count||g.Count||"1"))||1,Ht=g.参考图||g.images||g.Images||"",Us=Ht?Ht.split(`
|
|
3
|
-
`).map(Se=>Se.trim()).filter(Se=>Se.length>0&&!Se.startsWith("[")&&!Se.endsWith("]")):[];return{id:ne+v,prompt:String(T).trim(),params:q,images:
|
|
1
|
+
import{_ as yt}from"./startup-runtime-DTmhLESk.js";import{fB as Gs,ee as Js,i5 as Vs,ec as Ws,at as qs,ef as be,r as o,e4 as qt,hW as Hs,av as Ht,al as vt,iW as zt,M as y,eg as He,lm as Xs,dB as H,ei as Ys,j2 as Qs,j3 as Zs,bg as ea,j as a,E as P,er as D,hC as Xt,ln as ta,cq as sa,lo as aa,lp as na,b$ as ra,aA as la,dk as Yt,dc as Qt,lq as Xe,c0 as ia,cn as oa,hE as ca,eu as Zt,cu as es,R as jt,eK as ua,ba as da}from"./startup-app-M6vjXkRC.js";import{i as ma,j as Ye,l as ts,k as Qe,m as Ct,K as ha,M as fa}from"./ai-chat-D_s8vs6j.js";import{u as pa,a as ga}from"./useMediaViewer-Be0fy5RZ.js";import{P as wa}from"./ParametersDropdown-wKdOCk_p.js";import{M as ba}from"./tool-windows-Cf62DjP-.js";import{c as ka,e as Ze}from"./ai-generation-preferences-service-rBqGBu1Z.js";import{b as xa}from"./mj-params-M-7csAp7.js";const ss=Hs.BATCH_IMAGE_CACHE,$=["prompt","params","images","count","preview"];function ke(b){return!!b&&typeof b=="object"&&!Array.isArray(b)&&Object.values(b).every(k=>typeof k=="string")}function as(b){return Array.isArray(b)?[...b]:ke(b)?{...b}:b}function ya(b,k){const z=Object.keys(b),R=Object.keys(k);return z.length===R.length&&z.every(M=>b[M]===k[M])}function ze(b){return b.trim().toLowerCase().replace(/[::]/g,"x").replace(/×/g,"x").replace(/\s+/g,"")}function ns(b){return ze(b).replace(/[=_-]/g,"")}function va(b,k){var M,r;if(typeof k!="string")return;const z=k.trim();if(!z)return;const R=ze(z);return(r=(M=b.options)==null?void 0:M.find(F=>{const se=ze(F.value),E=ze(F.label),X=ze(F.label.split("(")[0]);return R===se||R===E||R===X}))==null?void 0:r.value}function ja(b,k){const z=ns(k),R={参数:"params",尺寸:"size",图片尺寸:"size",宽高比:"size",分辨率:"resolution",图片分辨率:"resolution",画质:"quality",图片质量:"quality",质量:"quality"},M=R[k.trim()]||R[z];return b.find(r=>r.id===k||r.id===M?!0:[r.id,r.label,r.shortLabel||"",r.description||""].map(ns).includes(z))}function St(b,k){if(typeof k!="string")return;const z=k.trim();if(z)return b.valueType==="enum"?va(b,z):z}function pe(b,k,z){const M=zt(k).find(X=>X.id==="size"),r=ke(b.params)?b.params:{},F={...z,...r},se=r.size||b.size,E=M?St(M,se):void 0;return E&&(F.size=E),Ze(k,F)}function rs(b,k,z){const R=b.trim();if(!R)return{...z};const M=zt(k),r={};try{const E=JSON.parse(R);if(ke(E))return Ze(k,{...z,...E})}catch{}const F=M.find(E=>E.id==="size"),se=F?St(F,R):void 0;return se?Ze(k,{...z,size:se}):(R.split(/[;\n]+/).map(E=>E.trim()).filter(Boolean).forEach(E=>{const X=E.match(/^([^:=:=]+)[:=:]\s*(.+)$/);if(!X)return;const ae=ja(M,X[1]);if(!ae)return;const B=St(ae,X[2]);B&&(r[ae.id]=B)}),Ze(k,{...z,...r}))}function ge(b){return Object.entries(b).filter(([,k])=>k).map(([k,z])=>`${k}=${z}`).join(`
|
|
2
|
+
`)}function Ca(b){const k={...b};return k.size==="auto"&&delete k.size,Object.keys(k).length>0?k:void 0}function ls(b){return b instanceof Element&&!!b.closest('input, textarea, [contenteditable="true"]')}function Sa(){const b=[];for(let k=0;k<5;k++)b.push({id:k+1,prompt:"",params:{size:"auto"},images:[],count:1,taskIds:[]});return b}const Aa=({onSwitchToSingle:b,selectedModel:k,selectedModelRef:z,onModelChange:R,onModelRefChange:M})=>{var Vt;const{language:r}=Gs(),{confirm:F,confirmDialog:se}=Js(),E=ma("image"),{createTask:X,tasks:ae}=Vs(),{addAsset:B,assets:is,loadAssets:Nt}=Ws(),{isMobile:os,isTablet:cs}=qs(),Rt=os||cs,Et=is.filter(t=>t.type===be.IMAGE);o.useEffect(()=>{Nt()},[Nt]);const[w,A]=o.useState(Sa),[ne,Ne]=o.useState(6),[et,_t]=o.useState(!1),[re,me]=o.useState(!1),he=o.useRef(!1),[tt,us]=o.useState([]);o.useEffect(()=>{let t=!0;return qt.get(ss).then(e=>{t&&(e&&e.tasks&&Array.isArray(e.tasks)&&e.tasks.length>0&&(A(e.tasks),e.taskIdCounter&&Ne(e.taskIdCounter)),_t(!0))}).catch(e=>{console.warn("Failed to load batch image cache:",e),t&&_t(!0)}),()=>{t=!1}},[]);const[j,le]=o.useState(null),[I,Y]=o.useState([]),[Q,O]=o.useState(null),[ie,xe]=o.useState(null),[C,Z]=o.useState(new Set),{validSelectedRows:za,selectedTaskCount:Na,selectedInfoText:ds}=o.useMemo(()=>{const t=[...C].filter(n=>{const l=w[n];return l&&l.prompt&&l.prompt.trim()!==""}).sort((n,l)=>n-l),e=t.reduce((n,l)=>{const u=w[l];return n+((u==null?void 0:u.count)||1)},0),s=t.length>0?r==="zh"?`已选 ${t.length} 行 / ${e} 任务`:`${t.length} rows / ${e} tasks`:"";return{validSelectedRows:t,selectedTaskCount:e,selectedInfoText:s}},[C,w,r]),G=o.useRef([]),J=o.useRef(-1),ye=o.useRef(!1),[Tt,st]=o.useState(!0),[ms,at]=o.useState(!1),[V,Dt]=o.useState(!1),[K,Mt]=o.useState(null),[$t,Pt]=o.useState([]),[Re,nt]=o.useState(null),[we,rt]=o.useState(!1),[Ee,lt]=o.useState(null),[hs,it]=o.useState(null),[ee,fs]=o.useState(1),[ps,ot]=o.useState(!1),[L,ct]=o.useState([]),[oe,At]=o.useState(1),ut=o.useMemo(()=>L.slice(0,12).map(t=>URL.createObjectURL(t)),[L]);o.useEffect(()=>()=>{ut.forEach(t=>URL.revokeObjectURL(t))},[ut]);const ce=Ht("image"),_e=Ye(E,ce.modelId,vt(ce.profileId,ce.modelId))||ts("image",ce.modelId,vt(ce.profileId,ce.modelId)),[x,Te]=o.useState((_e==null?void 0:_e.id)||((Vt=E[0])==null?void 0:Vt.id)||"gemini-2.5-flash-image-vip"),[U,De]=o.useState(Qe(_e)||vt(ce.profileId,ce.modelId)),ue=o.useMemo(()=>{if(Ye(E,x,U)||!x)return E;const e=ts("image",x,U);return e?[e,...E]:E},[E,x,U]),dt=o.useMemo(()=>Ct(x,U),[x,U]),Lt=o.useMemo(()=>zt(x),[x]),S=o.useMemo(()=>ka(x,dt).extraParams,[x,dt]);o.useEffect(()=>{A(t=>{let e=!1;const s=t.map(n=>{const l=pe(n,x,S),u=typeof n.size=="string",c=ke(n.params)?n.params:{};if(!u&&ya(c,l))return n;e=!0;const{size:d,...f}=n;return{...f,params:l}});return e?s:t})},[et,S,x]),o.useEffect(()=>{if(ue.length===0)return;Ye(ue,x,U)||(Te(ue[0].id),De(Qe(ue[0])))},[x,U,ue]),o.useEffect(()=>{if(!k)return;const t=Ct(x,U),e=Ct(k,z);if(t!==e){Te(k);const s=Ye(ue,k,z);De(Qe(s)||z||null)}},[k,z,x,U,ue]);const{openViewer:It,viewerProps:gs}=pa(),[ve,mt]=o.useState(null),[ws,Me]=o.useState(!1),[$e,bs]=o.useState(5),[Ot,ht]=o.useState(!1),[ft,pt]=o.useState(null),Pe=o.useRef(null),Ae=o.useRef(null),Le=o.useRef(null),Ie=o.useRef(null),Kt=o.useRef(null),Oe=o.useRef(null),gt=o.useRef(null),Ke=o.useRef(null),Fe=o.useCallback(()=>{var t;(t=Ke.current)==null||t.focus({preventScroll:!0})},[]),Ue=o.useCallback(t=>{const e=Ke.current;if(!e)return!1;const s=t.target instanceof Element?t.target:null;if(s&&e.contains(s))return!0;const n=document.activeElement;return n instanceof Element&&e.contains(n)},[]);o.useEffect(()=>{if(!et)return;const t={tasks:w,taskIdCounter:ne,timestamp:Date.now()};qt.set(ss,t).catch(e=>{console.warn("Failed to save batch image cache:",e)})},[w,ne,et]);const Ft=o.useCallback((t,e,s,n)=>{if(ye.current){ye.current=!1;return}G.current=G.current.slice(0,J.current+1);const l={tasks:JSON.parse(JSON.stringify(t)),selectedCells:[...e],activeCell:s?{...s}:null,selectedRows:Array.from(n)};G.current.push(l),J.current=G.current.length-1,G.current.length>50&&(G.current.shift(),J.current--)},[]);o.useEffect(()=>{w.length>0&&Ft(w,I,j,C)},[w,Ft]),o.useEffect(()=>{if(G.current.length>0&&J.current>=0&&!ye.current){const t=G.current[J.current];t&&(t.selectedCells=[...I],t.activeCell=j?{...j}:null,t.selectedRows=Array.from(C))}},[I,j,C]);const Ut=o.useCallback(()=>{if(J.current>0){J.current--,ye.current=!0;const t=G.current[J.current];A(JSON.parse(JSON.stringify(t.tasks))),Y([...t.selectedCells]),le(t.activeCell?{...t.activeCell}:null),Z(new Set(t.selectedRows)),y.info(r==="zh"?"已撤销":"Undone")}else y.warning(r==="zh"?"没有可撤销的操作":"Nothing to undo")},[r]),Bt=o.useCallback(()=>{if(J.current<G.current.length-1){J.current++,ye.current=!0;const t=G.current[J.current];A(JSON.parse(JSON.stringify(t.tasks))),Y([...t.selectedCells]),le(t.activeCell?{...t.activeCell}:null),Z(new Set(t.selectedRows)),y.info(r==="zh"?"已重做":"Redone")}else y.warning(r==="zh"?"没有可重做的操作":"Nothing to redo")},[r]),ks=o.useCallback(t=>{A(e=>{const s=[...e];for(let n=0;n<t;n++)s.push({id:ne+n,prompt:"",params:{...S},images:[],count:1,taskIds:[]});return s}),Ne(e=>e+t)},[S,ne]),xs=o.useCallback(()=>{if(C.size===0){y.warning(r==="zh"?"请先勾选要删除的行":"Please check rows to delete");return}A(t=>t.filter((e,s)=>!C.has(s))),Z(new Set),Y([]),le(null)},[C,r]),N=o.useCallback((t,e)=>{Fe(),le({row:t,col:e}),Y([{row:t,col:e}]),O(null),xe(null)},[Fe]),Be=o.useCallback((t,e)=>{if(N(t,e),e==="params"){xe({row:t,col:e});return}$.includes(e)&&e!=="images"&&O({row:t,col:e})},[N]),_=o.useCallback((t,e,s)=>{A(n=>{if(!n[t])return n;const l=[...n];return e==="params"?(l[t]={...l[t],params:pe({...l[t],params:ke(s)?s:{}},x,S)},l):e==="size"?(l[t]={...l[t],params:pe({...l[t],size:String(s||"")},x,S)},l):(l[t]={...l[t],[e]:s},l)})},[S,x]),Gt=o.useCallback((t,e,s)=>{const n=t.split(/\r?\n/).filter(u=>u.trim());if(n.length===0)return;const l=(u,c,d)=>{if(!(u<0||u>=w.length))if(c==="prompt")_(u,c,d);else if(c==="count"){const f=parseInt(d,10);!isNaN(f)&&f>=1&&_(u,c,f)}else(c==="params"||c==="size")&&_(u,"params",rs(d,x,S))};if(n.length===1||s.length>1){const u=n[0];s.forEach(c=>l(c.row,c.col,u));return}n.forEach((u,c)=>{l(e.row+c,e.col,u)})},[S,x,w.length,_]),Jt=o.useCallback((t,e)=>{const s=window.__copiedCells;if(!s||s.length===0)return!1;if(s.length===1){const n=s[0];return e.forEach(l=>{l.col===n.col&&_(l.row,l.col,n.value)}),!0}return s.forEach((n,l)=>{const u=t.row+l;u<w.length&&_(u,t.col,n.value)}),!0},[w.length,_]),je=o.useCallback((t,e,s)=>{if(t.shiftKey&&j){const n=Math.min(j.row,e),l=Math.max(j.row,e);Z(c=>{const d=new Set(c);for(let f=n;f<=l;f++)d.add(f);return d});const u=[];for(let c=n;c<=l;c++)u.push({row:c,col:j.col});Y(u),Kt.current=e}else t.ctrlKey||t.metaKey?Y(n=>n.some(u=>u.row===e&&u.col===s)?n.filter(u=>!(u.row===e&&u.col===s)):[...n,{row:e,col:s}]):(N(e,s),Kt.current=e)},[j,N]),Ge=o.useCallback(t=>{var s;if(!j){y.warning(r==="zh"?"请先选中一个单元格作为填充源":"Please select a cell as fill source");return}const e=(s=w[j.row])==null?void 0:s[t];if(e==null||typeof e=="string"&&e.trim()===""||Array.isArray(e)&&e.length===0){y.warning(r==="zh"?"选中的单元格没有数据":"Selected cell has no data");return}A(n=>n.map(l=>({...l,[t]:as(e)}))),y.success(r==="zh"?"已填充整列":"Column filled")},[j,w,r]),Je=o.useCallback((t,e)=>{rt(!1),lt(null),Dt(!0),Mt({row:t,col:e}),nt(t)},[]),wt=o.useCallback((t,e)=>{V||(Fe(),rt(!0),lt({row:t,col:e}),le({row:t,col:e}),Y([{row:t,col:e}]))},[Fe,V]),ys=o.useCallback(t=>{if(!V&&!we)return;const s=t.target.closest("tr[data-row-index]");if(!s)return;const n=parseInt(s.dataset.rowIndex||"-1");if(!(n<0)){if(V&&K){nt(n);const l=K.row,u=n,c=Math.min(l,u),d=Math.max(l,u),f=[];for(let m=c;m<=d;m++)m!==l&&f.push(m);Pt(f)}if(we&&Ee){const l=Ee.col,u=Ee.row,c=n,d=Math.min(u,c),f=Math.max(u,c),m=[];for(let i=d;i<=f;i++)m.push({row:i,col:l});Y(m)}}},[V,K,we,Ee]),Ve=o.useCallback(()=>{var t;if(V&&K&&Re!==null&&Re!==K.row){const e=(t=w[K.row])==null?void 0:t[K.col],s=K.row,n=Re,l=Math.min(s,n),u=Math.max(s,n);A(d=>{const f=[...d];for(let m=l;m<=u;m++)m!==s&&f[m]&&(f[m]={...f[m],[K.col]:as(e)});return f});const c=[];for(let d=l;d<=u;d++)c.push({row:d,col:K.col});Y(c),y.success(r==="zh"?`已填充 ${Math.abs(n-s)} 行`:`Filled ${Math.abs(n-s)} rows`)}Dt(!1),Mt(null),nt(null),Pt([]),rt(!1),lt(null)},[V,K,Re,w,r]),vs=o.useCallback(t=>{const e=t.target.files;e&&(Array.from(e).forEach(s=>{s.type.startsWith("image/")&&B(s,be.IMAGE,He.LOCAL,s.name).catch(n=>{console.warn("[BatchImageGeneration] Failed to add asset to library:",n)})}),Pe.current&&(Pe.current.value=""))},[B]),js=o.useCallback(t=>{let e=[];if(C.size>0?e=[...C]:I.length>0?e=[...new Set(I.map(s=>s.row))]:j&&(e=[j.row]),e.length===0){y.warning(r==="zh"?"请先选中要添加图片的行":"Please select a row first");return}A(s=>{const n=[...s];return e.forEach(l=>{n[l]&&!n[l].images.includes(t)&&(n[l]={...n[l],images:[...n[l].images,t]})}),n})},[C,I,j,r]),fe=o.useCallback((t,e)=>{A(s=>{const n=[...s];return n[t]&&!n[t].images.includes(e)&&(n[t]={...n[t],images:[...n[t].images,e]}),n})},[]),Cs=o.useCallback((t,e)=>{A(s=>{const n=[...s];return n[t]&&(n[t]={...n[t],images:n[t].images.filter(l=>l!==e)}),n})},[]),Ss=o.useCallback(t=>{const e=t.target.files,s=gt.current;!e||e.length===0||s===null||(Array.from(e).forEach(n=>{if(!n.type.startsWith("image/"))return;B(n,be.IMAGE,He.LOCAL,n.name).catch(u=>{console.warn("[BatchImageGeneration] Failed to add asset to library:",u)});const l=new FileReader;l.onload=u=>{var d;const c=(d=u.target)==null?void 0:d.result;fe(s,c)},l.readAsDataURL(n)}),Ie.current&&(Ie.current.value=""),gt.current=null)},[fe,B]),zs=o.useCallback(t=>{var e;gt.current=t,st(!0),(e=Ie.current)==null||e.click()},[]),Ns=o.useCallback(t=>{pt(t),ht(!0)},[]),Rs=o.useCallback(t=>{ft!==null&&(t.url&&fe(ft,t.url),ht(!1),pt(null))},[ft,fe]),Es=o.useCallback((t,e)=>{t.preventDefault(),t.dataTransfer.dropEffect="copy",it(e)},[]),_s=o.useCallback(t=>{const e=t.relatedTarget;(!e||!t.currentTarget.contains(e))&&it(null)},[]),Ts=o.useCallback((t,e)=>{t.preventDefault(),it(null);const s=t.dataTransfer.getData("text/library-image");if(s){fe(e,s),y.success(r==="zh"?`已添加图片到第 ${e+1} 行`:`Added image to row ${e+1}`);return}const n=t.dataTransfer.files;if(!n||n.length===0)return;let l=0;Array.from(n).forEach(u=>{if(!u.type.startsWith("image/"))return;B(u,be.IMAGE,He.LOCAL,u.name).catch(d=>{console.warn("[BatchImageGeneration] Failed to add asset to library:",d)});const c=new FileReader;c.onload=d=>{var m;const f=(m=d.target)==null?void 0:m.result;fe(e,f)},c.readAsDataURL(u),l++}),l>0&&y.success(r==="zh"?`已添加 ${l} 张图片到第 ${e+1} 行`:`Added ${l} images to row ${e+1}`)},[fe,r,B]),Ds=o.useCallback((t,e)=>{t.dataTransfer.setData("text/library-image",e),t.dataTransfer.effectAllowed="copy"},[]),Ms=o.useCallback(t=>{const e=t.target.files;if(!e||e.length===0)return;const s=Array.from(e).filter(l=>l.type.startsWith("image/"));if(s.length===0){y.warning(r==="zh"?"请选择图片文件":"Please select image files");return}ct(s);const n=j?j.row+1:1;At(Math.min(n,w.length)),ot(!0),Ae.current&&(Ae.current.value="")},[r,j,w.length]),$s=o.useCallback(async()=>{if(L.length===0)return;const t=Xs(`批量导入(${L.length}张)`),e=ee,s=L.length,n=Math.ceil(s/e),l=oe-1,u=[];for(const m of L){B(m,be.IMAGE,He.LOCAL,m.name).catch(p=>{console.warn("[BatchImageGeneration] Failed to add asset to library:",p)});const i=await new Promise((p,h)=>{const g=new FileReader;g.onload=v=>{var T;return p((T=v.target)==null?void 0:T.result)},g.onerror=h,g.readAsDataURL(m)});u.push(i)}A(m=>{const i=[...m];let p=0,h=0;for(let g=0;g<n;g++){const v=l+g,T=[];for(let W=0;W<e&&p<s;W++)T.push(u[p]),p++;v<i.length?i[v]={...i[v],images:[...i[v].images,...T]}:(i.push({id:ne+h,prompt:"",params:{...S},images:T,count:1,taskIds:[]}),h++)}return i});const c=Math.min(n,w.length-l),d=Math.max(0,n-c);d>0&&Ne(m=>m+d),ct([]),ot(!1),t();const f=r==="zh"?`已导入 ${s} 张图片,从第 ${oe} 行开始`:`Imported ${s} images starting from row ${oe}`;y.success(f)},[L,ee,oe,ne,w.length,r,B,S]),bt=o.useCallback(()=>{ct([]),ot(!1)},[]),Ps=o.useCallback(async()=>{try{const t=await yt(()=>import("./office-data-ByisqnCq.js").then(l=>l.x),[],import.meta.url),e=[{提示词:"一只可爱的橘猫在阳光下睡觉",参数:ge({...S,size:"1x1"}),数量:1},{提示词:"未来城市的夜景,霓虹灯闪烁",参数:ge({...S,size:"16x9"}),数量:2},{提示词:"古风美女,水墨画风格",参数:ge({...S,size:"3x4"}),数量:1},{提示词:"",参数:ge(S),数量:1},{提示词:"",参数:ge(S),数量:1}],s=t.utils.book_new(),n=t.utils.json_to_sheet(e);n["!cols"]=[{wch:60},{wch:24},{wch:8}],t.utils.book_append_sheet(s,n,"批量出图模板"),t.writeFile(s,"batch-image-template.xlsx"),y.success(r==="zh"?"模板下载成功,填写后可导入使用":"Template downloaded, fill and import to use")}catch(t){console.error("Excel template download error:",t),y.error(r==="zh"?"下载失败,请稍后重试":"Download failed, please try again")}},[S,r]),As=o.useCallback(async t=>{var s;const e=(s=t.target.files)==null?void 0:s[0];if(e){try{const n=await yt(()=>import("./office-data-ByisqnCq.js").then(u=>u.x),[],import.meta.url),l=new FileReader;l.onload=u=>{var c;try{const d=new Uint8Array((c=u.target)==null?void 0:c.result),f=n.read(d,{type:"array"}),m=f.SheetNames[0],i=f.Sheets[m],p=n.utils.sheet_to_json(i);if(p.length===0){y.warning(r==="zh"?"Excel 文件为空":"Excel file is empty");return}const h=p.map((g,v)=>{const T=g.提示词||g.prompt||g.Prompt||"",W=g.参数||g.params||g.Params||"",te=g.尺寸||g.size||g.Size||"",q=W?rs(String(W),x,S):pe({params:S,size:String(te)},x,S),qe=parseInt(String(g.数量||g.count||g.Count||"1"))||1,Wt=g.参考图||g.images||g.Images||"",Bs=Wt?Wt.split(`
|
|
3
|
+
`).map(Se=>Se.trim()).filter(Se=>Se.length>0&&!Se.startsWith("[")&&!Se.endsWith("]")):[];return{id:ne+v,prompt:String(T).trim(),params:q,images:Bs,count:Math.max(1,qe),taskIds:[]}});A(g=>[...g,...h]),Ne(g=>g+h.length),y.success(r==="zh"?`已导入 ${h.length} 行数据`:`Imported ${h.length} rows`)}catch(d){console.error("Excel import error:",d),y.error(r==="zh"?"导入失败,请检查文件格式":"Import failed, please check file format")}},l.readAsArrayBuffer(e)}catch(n){console.error("Excel library load error:",n),y.error(r==="zh"?"加载 Excel 处理库失败":"Failed to load Excel library")}Le.current&&(Le.current.value="")}},[S,r,x,ne]),de=o.useCallback(t=>{if(t.taskIds.length===0)return{status:"idle",tasks:[],completedCount:0,failedCount:0};const e=ae.filter(c=>t.taskIds.includes(c.id)),s=e.filter(c=>c.status===H.COMPLETED).length,n=e.filter(c=>c.status===H.FAILED).length,l=e.filter(c=>c.status===H.PENDING||c.status===H.PROCESSING).length;let u="idle";return l>0?u="generating":n>0&&s>0?u="partial":n>0?u="failed":s>0&&(u="completed"),{status:u,tasks:e,completedCount:s,failedCount:n}},[ae]),Ls=o.useCallback(async()=>{try{const t=await yt(()=>import("./office-data-ByisqnCq.js").then(i=>i.x),[],import.meta.url),e=32e3,s=i=>{const h=i.map((g,v)=>g.startsWith("data:")?`[本地图片${v+1}]`:g).join(`
|
|
4
4
|
`);return h.length>e?h.substring(0,e-20)+`
|
|
5
|
-
...[已截断]`:h},n=w.map(i=>{const p=de(i),h=p.tasks.filter(g=>{var v;return g.status===
|
|
6
|
-
`);da(f).then(()=>{window.__copiedCells=d,window.__copiedCellsText=f})}return}switch(e.key){case"ArrowUp":e.preventDefault(),s>0&&N(s-1,n);break;case"ArrowDown":e.preventDefault(),s<w.length-1&&N(s+1,n);break;case"ArrowLeft":e.preventDefault(),l>0&&N(s,$[l-1]);break;case"ArrowRight":e.preventDefault(),l<$.length-1&&N(s,$[l+1]);break;case"Tab":e.preventDefault(),e.shiftKey?l>0?N(s,$[l-1]):s>0&&N(s-1,$[$.length-1]):l<$.length-1?N(s,$[l+1]):s<w.length-1&&N(s+1,$[0]);break;case"Enter":e.preventDefault(),n!=="images"&&
|
|
5
|
+
...[已截断]`:h},n=w.map(i=>{const p=de(i),h=p.tasks.filter(g=>{var v;return g.status===H.COMPLETED&&((v=g.result)==null?void 0:v.url)}).map(g=>g.result.url);return{提示词:i.prompt,参数:ge(pe(i,x,S)),参考图:s(i.images),数量:i.count,预览图:s(h),状态:p.status==="idle"?"未生成":p.status==="generating"?"生成中":p.status==="completed"?"已完成":p.status==="failed"?"失败":p.status==="partial"?"部分完成":""}}),l=t.utils.book_new(),u=t.utils.json_to_sheet(n);u["!cols"]=[{wch:60},{wch:24},{wch:80},{wch:8},{wch:80},{wch:12}],t.utils.book_append_sheet(l,u,"批量出图数据");const c=new Date,d=`${c.getFullYear()}${String(c.getMonth()+1).padStart(2,"0")}${String(c.getDate()).padStart(2,"0")}`,f=`${String(c.getHours()).padStart(2,"0")}${String(c.getMinutes()).padStart(2,"0")}`,m=`batch-image-export_${d}_${f}.xlsx`;t.writeFile(l,m),y.success(r==="zh"?`已导出 ${w.length} 行数据`:`Exported ${w.length} rows`)}catch(t){console.error("Excel export error:",t),y.error(r==="zh"?"导出失败,请稍后重试":"Export failed, please try again")}},[S,de,r,x,w]),Is=o.useCallback(()=>{const t=[];if(w.forEach((e,s)=>{const{status:n}=de(e);(n==="failed"||n==="partial")&&t.push(s)}),t.length===0){y.info(r==="zh"?"没有失败的行":"No failed rows");return}Z(new Set(t)),y.success(r==="zh"?`已选中 ${t.length} 个失败行`:`Selected ${t.length} failed rows`)},[w,de,r]),Os=o.useCallback(()=>{const t=new Set;w.forEach((e,s)=>{C.has(s)||t.add(s)}),Z(t)},[w,C]),kt=o.useCallback((t,e=0)=>{It(ga(t,"image"),e)},[It]),We=o.useCallback((t,e=!1)=>{Z(s=>{const n=new Set(s);if(e&&Oe.current!==null){const l=Math.min(Oe.current,t),u=Math.max(Oe.current,t);for(let c=l;c<=u;c++)n.add(c)}else n.has(t)?n.delete(t):n.add(t);return n}),Oe.current=t},[]),Ks=o.useCallback(()=>{C.size===w.length&&w.length>0?Z(new Set):Z(new Set(w.map((t,e)=>e)))},[w,C.size]),Fs=o.useCallback(async()=>{const t=[...C].sort((s,n)=>s-n);if(t.length===0){y.warning(r==="zh"?"请先勾选要下载的行":"Please check rows to download");return}const e=[];if(t.forEach(s=>{const n=w[s];n&&n.taskIds.forEach((l,u)=>{var d;const c=ae.find(f=>f.id===l);(c==null?void 0:c.status)===H.COMPLETED&&((d=c.result)!=null&&d.url)&&e.push({url:c.result.url,filename:`row${s+1}_${u+1}_${n.prompt.slice(0,20).replace(/[^\w\u4e00-\u9fa5]/g,"_")}.png`})})}),e.length===0){y.warning(r==="zh"?"选中的行没有已生成的图片":"No generated images in selected rows");return}try{y.info(r==="zh"?"正在准备下载...":"Preparing download...");const s=new Date,n=`${s.getFullYear()}${String(s.getMonth()+1).padStart(2,"0")}${String(s.getDate()).padStart(2,"0")}`,l=`${String(s.getHours()).padStart(2,"0")}${String(s.getMinutes()).padStart(2,"0")}`,u=`aitu_images_${e.length}pics_${n}_${l}.zip`,c=e.map(f=>({url:f.url,type:"image",filename:f.filename})),d=await Ys(c,u);d.openedCount>0&&d.downloadedCount===0?y.success(r==="zh"?d.openedCount>1?`已打开 ${d.openedCount} 个链接,请在新标签页下载`:"资源不支持直接下载,已打开链接":d.openedCount>1?`Opened ${d.openedCount} links for download`:"Opened link for download"):y.success(r==="zh"?"下载成功":"Download complete")}catch(s){console.error("Download failed:",s),y.error(r==="zh"?"下载失败":"Download failed")}},[C,w,ae,r]),xt=o.useCallback(async t=>{me(!0);try{if(!Qs("image",U||x)&&(O(null),le(null),!await Zs())){y.warning(r==="zh"?"需要 API Key 才能生成图片":"API Key is required to generate images");return}const e=Date.now();let s=0,n=0;for(const{task:l,rowIndex:u}of t){const c=l.count||1,d=`batch_${l.id}_${e}`,f=pe(l,x,S),m=f.size||S.size||"auto",i=m==="auto"?void 0:m,p=x||Ht("image").modelId||"gemini-2.5-flash-image-vip",h=p.startsWith("mj"),g=h?[l.prompt.trim(),xa(f)].filter(Boolean).join(" "):l.prompt.trim(),v=h?void 0:Ca(f),T=l.images.map((te,q)=>({type:"url",url:te,name:`reference_${q+1}`})),W=[];for(let te=0;te<c;te++){s++;const q={prompt:g,knowledgeContextRefs:tt,aspectRatio:m,size:i,model:p,modelRef:U||null,uploadedImages:T,batchId:d,batchIndex:te+1,batchTotal:c,globalIndex:s,autoInsertToCanvas:!0,...v?{params:v}:{}},qe=X(q,ea.IMAGE);qe&&(n++,W.push(qe.id))}W.length>0&&A(te=>{const q=[...te];return q[u]&&(q[u]={...q[u],taskIds:[...q[u].taskIds,...W]}),q})}n>0&&y.success(r==="zh"?`已提交 ${n} 个任务到队列`:`Submitted ${n} tasks to queue`)}finally{he.current=!1,me(!1)}},[X,S,tt,r,x,U,A,O,le]),Us=o.useCallback(async()=>{if(he.current||re)return;he.current=!0,me(!0);const t=[...C].sort((c,d)=>c-d);if(t.length===0){y.warning(r==="zh"?"请先勾选要生成的行":"Please check rows to generate"),he.current=!1,me(!1);return}const e=t.map(c=>({task:w[c],rowIndex:c})).filter(({task:c})=>c&&c.prompt&&c.prompt.trim()!=="");if(e.length===0){y.warning(r==="zh"?"选中的行没有填写提示词":"Selected rows have no prompts"),he.current=!1,me(!1);return}const s=e.filter(({task:c})=>de(c).status==="generating"),n=e.filter(({task:c})=>(c.count||1)>=100),l=e.reduce((c,{task:d})=>c+(d.count||1),0),u=l>=100;if(s.length>0||n.length>0||u){const c=[];if(s.length>0){const m=s.map(({rowIndex:i})=>i+1).join("、");c.push(r==="zh"?`第 ${m} 行正在生成中`:`Row ${m} is generating`)}if(n.length>0){const m=n.map(({task:i,rowIndex:p})=>r==="zh"?`第 ${p+1} 行数量为 ${i.count}`:`Row ${p+1} count is ${i.count}`).join("、");c.push(m)}u&&c.push(r==="zh"?`总任务数为 ${l}`:`Total task count is ${l}`);const d=c.join(r==="zh"?";":"; "),f=r==="zh"?`${d},是否继续?`:`${d}. Continue?`;F({title:r==="zh"?"生成提醒":"Generation Warning",description:f,confirmText:r==="zh"?"继续生成":"Continue",cancelText:r==="zh"?"取消":"Cancel",confirmTheme:"warning"}).then(m=>{m?xt(e):(he.current=!1,me(!1))}).catch(()=>{he.current=!1,me(!1)});return}xt(e)},[F,w,C,r,xt,de,re]);o.useEffect(()=>{const t=e=>{if(ls(e.target)||!Ue(e)||!j||Q||ie)return;const{row:s,col:n}=j,l=$.indexOf(n);if(e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&$.includes(n)&&n!=="images"&&n!=="params"){if(e.preventDefault(),n==="count"){const c=parseInt(e.key);isNaN(c)?_(s,n,0):_(s,n,c)}else n==="prompt"&&_(s,n,e.key);O({row:s,col:n}),window.__cellEditSelectAll=!1;return}if((e.ctrlKey||e.metaKey)&&e.key==="z"&&!e.shiftKey){e.preventDefault(),Ut();return}if((e.ctrlKey||e.metaKey)&&(e.key==="y"||e.key==="z"&&e.shiftKey)){e.preventDefault(),Bt();return}if((e.ctrlKey||e.metaKey)&&e.key==="c"){e.preventDefault();const d=[...I].sort((f,m)=>f.row-m.row).map(f=>{var i;const m=(i=w[f.row])==null?void 0:i[f.col];return{row:f.row,col:f.col,value:m}});if(d.length>0){const f=d.map(m=>m.col==="images"?JSON.stringify(m.value):m.col==="params"&&ke(m.value)?ge(m.value):String(m.value??"")).join(`
|
|
6
|
+
`);da(f).then(()=>{window.__copiedCells=d,window.__copiedCellsText=f})}return}switch(e.key){case"ArrowUp":e.preventDefault(),s>0&&N(s-1,n);break;case"ArrowDown":e.preventDefault(),s<w.length-1&&N(s+1,n);break;case"ArrowLeft":e.preventDefault(),l>0&&N(s,$[l-1]);break;case"ArrowRight":e.preventDefault(),l<$.length-1&&N(s,$[l+1]);break;case"Tab":e.preventDefault(),e.shiftKey?l>0?N(s,$[l-1]):s>0&&N(s-1,$[$.length-1]):l<$.length-1?N(s,$[l+1]):s<w.length-1&&N(s+1,$[0]);break;case"Enter":e.preventDefault(),n!=="images"&&Be(s,n);break;case"Escape":e.preventDefault(),O(null);break;case"Delete":case"Backspace":{e.preventDefault(),(I.length>0?I:[{row:s,col:n}]).forEach(d=>{d.col==="prompt"?_(d.row,d.col,""):d.col==="count"?_(d.row,d.col,0):d.col==="images"?_(d.row,d.col,[]):d.col==="params"&&_(d.row,d.col,S)});break}}};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[j,S,Q,ie,w,I,N,Be,_,Ut,Bt,Ue]),o.useEffect(()=>{const t=e=>{var u,c;if(!j||Q||ls(e.target)||!Ue(e))return;const s=((u=e.clipboardData)==null?void 0:u.getData("text/plain"))||((c=e.clipboardData)==null?void 0:c.getData("text"))||"";if(!s)return;e.preventDefault();const n=I.length>0?I:[j],l=window.__copiedCellsText;typeof l=="string"&&l.replace(/\r\n/g,`
|
|
7
7
|
`)===s.replace(/\r\n/g,`
|
|
8
|
-
`)&&Vt(j,n)||Gt(s,j,n)};return document.addEventListener("paste",t),()=>document.removeEventListener("paste",t)},[j,Gt,Q,Be,Vt,I]),o.useEffect(()=>{const t=e=>{const s=Ke.current,n=e.target instanceof Node?e.target:null;!s||!n||s.contains(n)||document.activeElement===s&&s.blur()};return document.addEventListener("pointerdown",t),()=>document.removeEventListener("pointerdown",t)},[]),o.useEffect(()=>{const t=()=>{(J||we)&&Je()};return document.addEventListener("mouseup",t),()=>document.removeEventListener("mouseup",t)},[J,we,Je]);const Ce=(t,e,s)=>{var f,m;const n=(Q==null?void 0:Q.row)===e&&(Q==null?void 0:Q.col)===s,l=(j==null?void 0:j.row)===e&&(j==null?void 0:j.col)===s,u=I.some(i=>i.row===e&&i.col===s),c=J&&(K==null?void 0:K.col)===s&&$t.includes(e),d=`excel-cell cell-${s} ${l?"active":""} ${u?"selected":""} ${c?"filling":""}`;switch(s){case"prompt":return a.jsxs("div",{className:d,onMouseDown:i=>{i.target.classList.contains("fill-handle")||n||i.button===0&&!i.shiftKey&&wt(e,s)},onClick:i=>{n||je(i,e,s)},onDoubleClick:()=>Ue(e,s),children:[n?a.jsx("textarea",{className:"cell-textarea",autoFocus:!0,value:t.prompt,placeholder:r==="zh"?"输入提示词...":"Enter prompt...",onChange:i=>{E(e,s,i.target.value)},onFocus:i=>{const p=i.target.value.length;i.target.setSelectionRange(p,p),i.target.style.height="auto",i.target.style.height=i.target.scrollHeight+"px"},onInput:i=>{const p=i.target;p.style.height="auto",p.style.height=p.scrollHeight+"px"},onBlur:()=>O(null),onKeyDown:i=>{if(i.key==="Escape")O(null);else if(i.key==="Enter"&&!i.shiftKey)i.preventDefault(),O(null),e<w.length-1&&N(e+1,s);else if(i.key==="Tab"){i.preventDefault(),O(null);const p=$.indexOf(s);i.shiftKey?p>0?N(e,$[p-1]):e>0&&N(e-1,$[$.length-1]):p<$.length-1?N(e,$[p+1]):e<w.length-1&&N(e+1,$[0])}}}):a.jsx("span",{className:"cell-text",children:t.prompt||""}),l&&a.jsx("div",{className:"fill-handle",onMouseDown:i=>{i.stopPropagation(),Ve(e,s)}})]});case"params":{const i=pe(t,x,S),p=(ie==null?void 0:ie.row)===e&&(ie==null?void 0:ie.col)===s;return a.jsxs("div",{className:d,onMouseDown:h=>{h.target.classList.contains("fill-handle")||h.target.closest(".batch-params-cell-control")||h.button===0&&!h.shiftKey&&wt(e,s)},onClick:h=>je(h,e,s),onDoubleClick:()=>{N(e,s),xe({row:e,col:s})},children:[a.jsx("div",{className:"batch-params-cell-control",onMouseDown:h=>{le({row:e,col:s}),Y([{row:e,col:s}]),O(null),h.stopPropagation()},onClick:h=>h.stopPropagation(),children:Lt.length>0?a.jsx(wa,{selectedParams:i,onParamChange:(h,g,v)=>{const T={...i};!g||g==="default"?delete T[h]:T[h]=g,E(e,s,T),v!=null&&v.keepOpen||xe(null)},compatibleParams:Lt,modelId:x,language:r,disabled:re,isOpen:p,onOpenChange:h=>{xe(h?{row:e,col:s}:null)},placement:"auto"},`${x}-${t.id}`):a.jsx("span",{className:"cell-text",children:"-"})}),l&&a.jsx("div",{className:"fill-handle",onMouseDown:h=>{h.stopPropagation(),Ve(e,s)}})]})}case"images":return a.jsxs("div",{className:d,onClick:i=>je(i,e,s),children:[a.jsxs("div",{className:"image-cell-content",children:[t.images.map((i,p)=>a.jsxs("div",{className:"cell-image-thumb",children:[a.jsx("img",{src:i,alt:""}),a.jsx("button",{className:"remove-btn",onClick:h=>{h.stopPropagation(),Cs(e,i)},children:"×"})]},p)),a.jsxs("div",{className:"add-image-buttons",children:[a.jsx(D,{variant:"text",shape:"square",size:"small",onClick:i=>{i.stopPropagation(),N(e,s),zs(e)},title:r==="zh"?"上传图片":"Upload image",icon:a.jsx(Zt,{size:16}),className:"add-image-btn","data-track":"batch_row_upload_image_click"}),a.jsx(D,{variant:"text",shape:"square",size:"small",onClick:i=>{i.stopPropagation(),N(e,s),Ns(e)},title:r==="zh"?"从素材库选择":"Select from library",icon:a.jsx(Yt,{size:16}),className:"add-image-btn","data-track":"batch_row_select_from_library_click"})]})]}),l&&a.jsx("div",{className:"fill-handle",onMouseDown:i=>{i.stopPropagation(),Ve(e,s)}})]});case"count":return a.jsxs("div",{className:d,onMouseDown:i=>{i.target.classList.contains("fill-handle")||n||i.button===0&&!i.shiftKey&&wt(e,s)},onClick:i=>{n||je(i,e,s)},onDoubleClick:()=>Ue(e,s),children:[n?a.jsx("input",{type:"number",autoFocus:!0,min:1,max:10,value:t.count===0?"":t.count,className:"cell-count-input",onChange:i=>{const p=i.target.value;if(p===""){E(e,s,0);return}const h=parseInt(p);isNaN(h)||E(e,s,h)},onBlur:()=>{!t.count||t.count<1?E(e,s,1):t.count>10&&E(e,s,10),O(null)},onKeyDown:i=>{i.key==="Escape"?O(null):i.key==="Enter"&&(O(null),e<w.length-1&&N(e+1,s))}}):a.jsx("span",{className:"cell-text",children:t.count}),l&&a.jsx("div",{className:"fill-handle",onMouseDown:i=>{i.stopPropagation(),Ve(e,s)}})]});case"preview":{const i=de(t);return a.jsxs("div",{className:`${d} preview-cell preview-${i.status}`,onClick:p=>{i.status==="completed"||i.status==="partial"?mt(e):i.status==="failed"?C.has(e)||He(e):je(p,e,s)},children:[i.status==="idle"&&a.jsx("span",{className:"preview-idle",children:"-"}),(i.status==="generating"||i.status==="completed")&&(()=>{const p=i.tasks.filter(v=>{var T;return v.status===W.COMPLETED&&((T=v.result)==null?void 0:T.url)}).map(v=>v.result.url),h=i.status==="generating",g=i.tasks.filter(v=>v.status===W.PENDING||v.status===W.PROCESSING).length;return p.length===0&&h?a.jsxs("span",{className:"preview-generating",children:[a.jsx("span",{className:"loading-spinner"}),r==="zh"?"生成中...":"Generating..."]}):a.jsxs("div",{className:"preview-images",children:[p.slice(0,h?2:3).map((v,T)=>a.jsx(P,{content:r==="zh"?"点击放大,左右切换":"Click to enlarge, swipe to navigate",showArrow:!1,children:a.jsx("div",{className:"preview-thumb clickable",onClick:H=>{H.stopPropagation(),kt(p,T)},children:a.jsx(jt,{src:v,alt:`Result ${T+1}`,showSkeleton:!1,eager:!0})})},T)),h&&a.jsx(P,{content:r==="zh"?`还有 ${g} 张生成中`:`${g} more generating`,showArrow:!1,children:a.jsxs("span",{className:"preview-generating-inline",children:[a.jsx("span",{className:"loading-spinner"}),"+",g]})}),!h&&i.completedCount>3&&a.jsx(P,{content:r==="zh"?"查看全部图片":"View all images",showArrow:!1,children:a.jsxs("span",{className:"preview-more clickable",onClick:v=>{v.stopPropagation(),mt(e)},children:["+",i.completedCount-3]})})]})})(),i.status==="failed"&&((f=i.tasks[0])==null?void 0:f.error)&&a.jsxs("div",{className:"preview-error",children:[a.jsx("span",{className:"preview-error-message",children:i.tasks[0].error.message}),((m=i.tasks[0].error.details)==null?void 0:m.originalError)&&a.jsx(P,{content:a.jsxs("div",{className:"error-details-tooltip",children:[a.jsx("div",{className:"error-details-title",children:"原始错误信息:"}),a.jsx("div",{className:"error-details-content",children:i.tasks[0].error.details.originalError})]}),theme:"light",placement:"bottom",showArrow:!1,children:a.jsx("span",{className:"preview-error-details-link",children:"[详情]"})})]}),i.status==="partial"&&(()=>{const p=i.tasks.filter(h=>{var g;return h.status===W.COMPLETED&&((g=h.result)==null?void 0:g.url)}).map(h=>h.result.url);return a.jsxs("div",{className:"preview-partial",children:[a.jsx("div",{className:"preview-images",children:p.slice(0,2).map((h,g)=>a.jsx(P,{content:r==="zh"?"点击放大,左右切换":"Click to enlarge, swipe to navigate",showArrow:!1,children:a.jsx("div",{className:"preview-thumb clickable",onClick:v=>{v.stopPropagation(),kt(p,g)},children:a.jsx(jt,{src:h,alt:`Result ${g+1}`,showSkeleton:!1,eager:!0})})},g))}),a.jsxs("span",{className:"preview-partial-info",children:["⚠️ ",i.completedCount,"/",i.tasks.length]})]})})()]})}default:return null}};return a.jsxs("div",{ref:Ke,className:"batch-image-generation",tabIndex:-1,children:[a.jsxs("div",{className:"batch-main-content",children:[a.jsxs("div",{className:"batch-toolbar",children:[a.jsx("input",{ref:Ae,type:"file",accept:"image/*",multiple:!0,onChange:Ms,style:{display:"none"}}),a.jsx("input",{ref:Ie,type:"file",accept:"image/*",multiple:!0,onChange:Ss,style:{display:"none"}}),a.jsx("input",{ref:Le,type:"file",accept:".xlsx,.xls,.csv",onChange:As,style:{display:"none"}}),a.jsxs("div",{className:"toolbar-left",children:[a.jsx(P,{content:r==="zh"?"下载模板":"Download Template",theme:"light",children:a.jsx(D,{variant:"outline",theme:"default",icon:a.jsx(Xt,{}),onClick:Ps,"data-track":"batch_download_template_click"})}),a.jsx(P,{content:r==="zh"?"导入 Excel":"Import Excel",theme:"light",children:a.jsx(D,{variant:"outline",theme:"default",icon:a.jsx(ta,{}),onClick:()=>{var t;return(t=Le.current)==null?void 0:t.click()},"data-track":"batch_import_excel_click"})}),a.jsx(P,{content:r==="zh"?"批量导入图片":"Batch Import Images",theme:"light",children:a.jsx(D,{variant:"outline",theme:"default",icon:a.jsx(sa,{}),onClick:()=>{var t;return(t=Ae.current)==null?void 0:t.click()},"data-track":"batch_import_images_click","data-track-params":JSON.stringify({source:"toolbar"})})}),a.jsx("span",{className:"toolbar-divider"}),a.jsx(P,{content:r==="zh"?"选择失败行":"Select Failed Rows",theme:"light",children:a.jsx(D,{variant:"text",theme:"default",icon:a.jsx(aa,{}),onClick:Is,"data-track":"batch_select_failed_click"})}),a.jsx(P,{content:r==="zh"?"反选":"Invert Selection",theme:"light",children:a.jsx(D,{variant:"text",theme:"default",icon:a.jsx(na,{}),onClick:Os,"data-track":"batch_invert_selection_click"})}),a.jsx("span",{className:"toolbar-divider"}),a.jsx(D,{variant:"text",theme:"default",icon:a.jsx(ra,{}),onClick:xs,className:"batch-delete-btn","data-track":"batch_delete_selected_click","data-track-params":JSON.stringify({count:C.size}),children:r==="zh"?"删除选中":"Delete Selected"}),a.jsx("span",{className:"toolbar-divider"}),a.jsx(D,{variant:"outline",theme:"default",icon:a.jsx(Xt,{}),onClick:Fs,className:"batch-download-btn","data-track":"batch_download_images_click","data-track-params":JSON.stringify({count:C.size}),children:r==="zh"?"下载选中图片":"Download"})]}),a.jsxs("div",{className:"toolbar-right",children:[a.jsx("div",{className:"batch-knowledge-context-wrapper",children:a.jsx(ha,{value:tt,onChange:us,disabled:re,language:r,label:r==="zh"?"上下文":"Context"})}),a.jsx("div",{className:"model-selector-wrapper","data-track":"batch_model_select",children:a.jsx(la,{selectedModel:x,selectedSelectionKey:dt,onSelect:t=>{Te(t),De(null),R==null||R(t),M==null||M(null)},onSelectModel:t=>{Te(t.id);const e=Qe(t);De(e),R==null||R(t.id),M==null||M(e)},language:r,models:ue,placement:"down",variant:"form",disabled:re})}),a.jsx(D,{theme:"primary",onClick:Bs,loading:re,disabled:re,className:"batch-generate-btn","data-track":"batch_generate_click","data-track-params":JSON.stringify({selectedRows:C.size,model:x}),children:re?r==="zh"?"提交中...":"Submitting...":r==="zh"?"生成选中行":"Generate Selected"}),a.jsx("span",{className:"toolbar-divider"}),!Rt&&!Tt&&a.jsx(P,{content:r==="zh"?"显示素材库":"Show Library",theme:"light",children:a.jsx(D,{variant:"outline",theme:"default",icon:a.jsx(Yt,{size:16}),onClick:()=>st(!0),"data-track":"batch_library_show_click"})})]})]}),a.jsxs("div",{className:`excel-table-container ${J?"is-filling":""} ${we?"is-selecting":""}`,onMouseMove:ys,onMouseUp:Je,onMouseLeave:Je,children:[a.jsxs("table",{className:"excel-table",children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{className:"col-checkbox",children:a.jsx(P,{content:ds||(r==="zh"?"全选/取消全选":"Select All / Deselect All"),theme:"light",showArrow:!1,visible:ms,onVisibleChange:t=>at(t),children:a.jsx("div",{className:"checkbox-wrapper",children:a.jsx(Qt,{checked:w.length>0&&C.size===w.length,indeterminate:C.size>0&&C.size<w.length,onChange:Ks})})})}),a.jsx("th",{className:"row-number",children:"#"}),a.jsx("th",{className:"col-prompt",children:a.jsxs("div",{className:"th-content",children:[r==="zh"?"提示词":"Prompt",a.jsx(P,{content:r==="zh"?"向下填充":"Fill down",theme:"light",children:a.jsx(D,{variant:"text",shape:"circle",size:"small",icon:a.jsx(Xe,{}),className:"column-fill-btn",onClick:()=>Ge("prompt"),"data-track":"batch_fill_column_click","data-track-params":JSON.stringify({column:"prompt"})})})]})}),a.jsx("th",{className:"col-params",children:a.jsxs("div",{className:"th-content",children:[r==="zh"?"参数":"Params",a.jsx(P,{content:r==="zh"?"向下填充":"Fill down",theme:"light",children:a.jsx(D,{variant:"text",shape:"circle",size:"small",icon:a.jsx(Xe,{}),className:"column-fill-btn",onClick:()=>Ge("params"),"data-track":"batch_fill_column_click","data-track-params":JSON.stringify({column:"params"})})})]})}),a.jsx("th",{className:"col-images",children:a.jsxs("div",{className:"th-content",children:[r==="zh"?"参考图片":"Ref Images",a.jsx(P,{content:r==="zh"?"向下填充":"Fill down",theme:"light",children:a.jsx(D,{variant:"text",shape:"circle",size:"small",icon:a.jsx(Xe,{}),className:"column-fill-btn",onClick:()=>Ge("images"),"data-track":"batch_fill_column_click","data-track-params":JSON.stringify({column:"images"})})})]})}),a.jsx("th",{className:"col-count",children:a.jsxs("div",{className:"th-content",children:[r==="zh"?"数量":"Count",a.jsx(P,{content:r==="zh"?"向下填充":"Fill down",theme:"light",children:a.jsx(D,{variant:"text",shape:"circle",size:"small",icon:a.jsx(Xe,{}),className:"column-fill-btn",onClick:()=>Ge("count"),"data-track":"batch_fill_column_click","data-track-params":JSON.stringify({column:"count"})})})]})}),a.jsx("th",{className:"col-preview",children:a.jsx("div",{className:"th-content",children:r==="zh"?"预览":"Preview"})})]})}),a.jsx("tbody",{children:w.map((t,e)=>a.jsxs("tr",{"data-row-index":e,className:`${C.has(e)?"row-selected":""} ${hs===e?"row-drag-over":""} ${$t.includes(e)?"fill-preview":""}`,onDragOver:s=>_s(s,e),onDragLeave:Es,onDrop:s=>Ts(s,e),children:[a.jsx("td",{className:"col-checkbox",onClick:s=>{He(e,s.shiftKey)},children:a.jsx("div",{className:"checkbox-wrapper",onClick:s=>{s.stopPropagation(),He(e,s.shiftKey)},onMouseEnter:()=>C.size>0&&at(!0),onMouseLeave:()=>at(!1),children:a.jsx(Qt,{checked:C.has(e)})})}),a.jsx("td",{className:"row-number",onClick:s=>He(e,s.shiftKey),style:{cursor:"pointer"},children:e+1}),a.jsx("td",{children:Ce(t,e,"prompt")}),a.jsx("td",{children:Ce(t,e,"params")}),a.jsx("td",{children:Ce(t,e,"images")}),a.jsx("td",{children:Ce(t,e,"count")}),a.jsx("td",{children:Ce(t,e,"preview")})]},t.id))})]}),a.jsxs("div",{className:"add-rows-section",children:[a.jsx(D,{variant:"dashed",shape:"circle",onClick:()=>Me(!0),title:r==="zh"?"添加行":"Add Rows",icon:a.jsx(ia,{}),className:"add-rows-btn","data-track":"batch_add_rows_click"}),a.jsx(D,{variant:"outline",theme:"default",icon:a.jsx(oa,{}),onClick:Ls,className:"export-excel-btn","data-track":"batch_export_excel_click","data-track-params":JSON.stringify({rowCount:w.length}),children:r==="zh"?"导出Excel":"Export Excel"})]})]}),a.jsx("p",{className:"hint-text",children:r==="zh"?"提示:Enter 编辑/确认 | Tab 移动 | Ctrl+Z 撤销 | Ctrl+Y 重做 | 拖拽图片到行":"Tip: Enter to edit/confirm | Tab to move | Ctrl+Z undo | Ctrl+Y redo | Drag images to rows"})]}),!Rt&&a.jsxs("div",{className:`image-library-sidebar ${Tt?"":"hidden"}`,children:[a.jsxs("div",{className:"library-header",children:[a.jsx("h3",{children:r==="zh"?"素材库":"Library"}),a.jsx(D,{variant:"text",shape:"square",size:"small",className:"close-btn",onClick:()=>st(!1),icon:a.jsx(ca,{}),"data-track":"batch_library_close_click"})]}),a.jsxs("div",{className:"library-content",children:[a.jsxs("div",{className:"upload-section",children:[a.jsx("input",{ref:Pe,type:"file",accept:"image/*",multiple:!0,onChange:vs,style:{display:"none"}}),a.jsx(D,{block:!0,theme:"default",variant:"outline",icon:a.jsx(Zt,{size:16}),onClick:()=>{var t;return(t=Pe.current)==null?void 0:t.click()},"data-track":"batch_library_upload_click",children:r==="zh"?"上传图片":"Upload"})]}),a.jsx("div",{className:"library-grid",children:_t.length===0?a.jsx("div",{className:"empty-library",children:r==="zh"?"暂无图片,请上传":"No images, please upload"}):_t.map(t=>a.jsx(P,{content:r==="zh"?"点击添加到选中行,或拖拽到指定行":"Click to add to selected rows, or drag to a specific row",showArrow:!1,children:a.jsx("div",{className:"library-image",onClick:()=>js(t.url),draggable:!0,onDragStart:e=>Ds(e,t.url),"data-track":"batch_library_image_click",children:a.jsx("img",{src:t.url,alt:t.name,draggable:!1})})},t.id))})]})]}),ps&&a.jsx("div",{className:"batch-import-modal-overlay",onClick:bt,children:a.jsxs("div",{className:"batch-import-modal",onClick:t=>t.stopPropagation(),children:[a.jsxs("div",{className:"modal-header",children:[a.jsx("h3",{children:r==="zh"?"批量导入图片":"Batch Import Images"}),a.jsx("button",{className:"close-btn",onClick:bt,children:"×"})]}),a.jsxs("div",{className:"modal-body",children:[a.jsx("p",{className:"import-info",children:r==="zh"?`已选择 ${L.length} 张图片`:`${L.length} images selected`}),a.jsxs("div",{className:"import-settings-row",children:[a.jsxs("div",{className:"import-setting-item",children:[a.jsx("label",{children:r==="zh"?"从第几行开始:":"Start from row:"}),a.jsx("input",{type:"number",min:1,max:w.length+Math.ceil(L.length/ee),value:oe,onChange:t=>{const e=Math.max(1,parseInt(t.target.value)||1);At(e)},className:"start-row-input"})]}),a.jsxs("div",{className:"import-setting-item",children:[a.jsx("label",{children:r==="zh"?"每行图片数:":"Images per row:"}),a.jsx("div",{className:"per-row-options",children:[1,2,3,4,5].map(t=>a.jsx("button",{className:`per-row-btn ${ee===t?"active":""}`,onClick:()=>fs(t),children:t},t))})]})]}),a.jsx("p",{className:"import-preview",children:r==="zh"?`从第 ${oe} 行开始,填充 ${Math.ceil(L.length/ee)} 行,每行 ${ee} 张图片`:`Starting from row ${oe}, filling ${Math.ceil(L.length/ee)} rows with ${ee} image(s) each`}),a.jsxs("div",{className:"import-preview-grid",children:[ut.map((t,e)=>a.jsx("div",{className:"preview-item",children:a.jsx("img",{src:t,alt:""})},e)),L.length>12&&a.jsxs("div",{className:"preview-more",children:["+",L.length-12]})]})]}),a.jsxs("div",{className:"modal-footer",children:[a.jsx(D,{variant:"outline",theme:"default",onClick:bt,"data-track":"batch_import_modal_cancel_click",children:r==="zh"?"取消":"Cancel"}),a.jsx(D,{theme:"default",variant:"outline",onClick:$s,"data-track":"batch_import_modal_confirm_click","data-track-params":JSON.stringify({imageCount:L.length,imagesPerRow:ee,startRow:oe}),children:r==="zh"?"确认导入":"Import"})]})]})}),a.jsx(fa,{...gs}),a.jsx(es,{visible:ws,onClose:()=>Me(!1),header:r==="zh"?"添加行":"Add Rows",confirmBtn:{content:r==="zh"?"添加":"Add",theme:"default",variant:"outline",onClick:()=>{ks($e),Me(!1),y.success(r==="zh"?`已添加 ${$e} 行`:`Added ${$e} rows`)}},cancelBtn:{content:r==="zh"?"取消":"Cancel",onClick:()=>Me(!1)},width:360,className:"add-rows-dialog",destroyOnClose:!0,children:a.jsxs("div",{className:"add-rows-content",children:[a.jsx("label",{children:r==="zh"?"添加行数:":"Number of rows:"}),a.jsx("input",{type:"number",min:1,max:100,value:$e,onChange:t=>bs(Math.max(1,Math.min(100,parseInt(t.target.value)||1))),className:"add-rows-input",autoFocus:!0})]})}),a.jsx(es,{visible:ve!==null,onClose:()=>mt(null),header:r==="zh"?`第 ${(ve??0)+1} 行生成结果`:`Row ${(ve??0)+1} Results`,footer:null,width:"70vw",className:"row-gallery-dialog",destroyOnClose:!0,children:ve!==null&&(()=>{const t=w[ve];if(!t)return null;const s=de(t).tasks.filter(l=>{var u;return l.status===W.COMPLETED&&((u=l.result)==null?void 0:u.url)}),n=s.map(l=>l.result.url);return a.jsxs("div",{className:"row-gallery-content",children:[a.jsx("div",{className:"gallery-grid",children:s.map((l,u)=>a.jsxs("div",{className:"gallery-item",onClick:()=>kt(n,u),children:[a.jsx(jt,{src:l.result.url,alt:`Result ${u+1}`,showSkeleton:!1,eager:!0}),a.jsx("span",{className:"gallery-item-index",children:u+1})]},l.id))}),s.length===0&&a.jsx("div",{className:"gallery-empty",children:r==="zh"?"暂无生成结果":"No results yet"})]})})()}),Ot&&a.jsx(ba,{isOpen:Ot,onClose:()=>{ht(!1),pt(null)},mode:ua.SELECT,filterType:be.IMAGE,onSelect:Rs}),se]})};export{Aa as default};
|
|
8
|
+
`)&&Jt(j,n)||Gt(s,j,n)};return document.addEventListener("paste",t),()=>document.removeEventListener("paste",t)},[j,Gt,Q,Ue,Jt,I]),o.useEffect(()=>{const t=e=>{const s=Ke.current,n=e.target instanceof Node?e.target:null;!s||!n||s.contains(n)||document.activeElement===s&&s.blur()};return document.addEventListener("pointerdown",t),()=>document.removeEventListener("pointerdown",t)},[]),o.useEffect(()=>{const t=()=>{(V||we)&&Ve()};return document.addEventListener("mouseup",t),()=>document.removeEventListener("mouseup",t)},[V,we,Ve]);const Ce=(t,e,s)=>{var f,m;const n=(Q==null?void 0:Q.row)===e&&(Q==null?void 0:Q.col)===s,l=(j==null?void 0:j.row)===e&&(j==null?void 0:j.col)===s,u=I.some(i=>i.row===e&&i.col===s),c=V&&(K==null?void 0:K.col)===s&&$t.includes(e),d=`excel-cell cell-${s} ${l?"active":""} ${u?"selected":""} ${c?"filling":""}`;switch(s){case"prompt":return a.jsxs("div",{className:d,onMouseDown:i=>{i.target.classList.contains("fill-handle")||n||i.button===0&&!i.shiftKey&&wt(e,s)},onClick:i=>{n||je(i,e,s)},onDoubleClick:()=>Be(e,s),children:[n?a.jsx("textarea",{className:"cell-textarea",autoFocus:!0,value:t.prompt,placeholder:r==="zh"?"输入提示词...":"Enter prompt...",onChange:i=>{_(e,s,i.target.value)},onFocus:i=>{const p=i.target.value.length;i.target.setSelectionRange(p,p),i.target.style.height="auto",i.target.style.height=i.target.scrollHeight+"px"},onInput:i=>{const p=i.target;p.style.height="auto",p.style.height=p.scrollHeight+"px"},onBlur:()=>O(null),onKeyDown:i=>{if(i.key==="Escape")O(null);else if(i.key==="Enter"&&!i.shiftKey)i.preventDefault(),O(null),e<w.length-1&&N(e+1,s);else if(i.key==="Tab"){i.preventDefault(),O(null);const p=$.indexOf(s);i.shiftKey?p>0?N(e,$[p-1]):e>0&&N(e-1,$[$.length-1]):p<$.length-1?N(e,$[p+1]):e<w.length-1&&N(e+1,$[0])}}}):a.jsx("span",{className:"cell-text",children:t.prompt||""}),l&&a.jsx("div",{className:"fill-handle",onMouseDown:i=>{i.stopPropagation(),Je(e,s)}})]});case"params":{const i=pe(t,x,S),p=(ie==null?void 0:ie.row)===e&&(ie==null?void 0:ie.col)===s;return a.jsxs("div",{className:d,onMouseDown:h=>{h.target.classList.contains("fill-handle")||h.target.closest(".batch-params-cell-control")||h.button===0&&!h.shiftKey&&wt(e,s)},onClick:h=>je(h,e,s),onDoubleClick:()=>{N(e,s),xe({row:e,col:s})},children:[a.jsx("div",{className:"batch-params-cell-control",onMouseDown:h=>{le({row:e,col:s}),Y([{row:e,col:s}]),O(null),h.stopPropagation()},onClick:h=>h.stopPropagation(),children:Lt.length>0?a.jsx(wa,{selectedParams:i,onParamChange:(h,g,v)=>{const T={...i};!g||g==="default"?delete T[h]:T[h]=g,_(e,s,T),v!=null&&v.keepOpen||xe(null)},compatibleParams:Lt,modelId:x,language:r,disabled:re,isOpen:p,onOpenChange:h=>{xe(h?{row:e,col:s}:null)},placement:"auto"},`${x}-${t.id}`):a.jsx("span",{className:"cell-text",children:"-"})}),l&&a.jsx("div",{className:"fill-handle",onMouseDown:h=>{h.stopPropagation(),Je(e,s)}})]})}case"images":return a.jsxs("div",{className:d,onClick:i=>je(i,e,s),children:[a.jsxs("div",{className:"image-cell-content",children:[t.images.map((i,p)=>a.jsxs("div",{className:"cell-image-thumb",children:[a.jsx("img",{src:i,alt:""}),a.jsx("button",{className:"remove-btn",onClick:h=>{h.stopPropagation(),Cs(e,i)},children:"×"})]},p)),a.jsxs("div",{className:"add-image-buttons",children:[a.jsx(D,{variant:"text",shape:"square",size:"small",onClick:i=>{i.stopPropagation(),N(e,s),zs(e)},title:r==="zh"?"上传图片":"Upload image",icon:a.jsx(Zt,{size:16}),className:"add-image-btn","data-track":"batch_row_upload_image_click"}),a.jsx(D,{variant:"text",shape:"square",size:"small",onClick:i=>{i.stopPropagation(),N(e,s),Ns(e)},title:r==="zh"?"从素材库选择":"Select from library",icon:a.jsx(Yt,{size:16}),className:"add-image-btn","data-track":"batch_row_select_from_library_click"})]})]}),l&&a.jsx("div",{className:"fill-handle",onMouseDown:i=>{i.stopPropagation(),Je(e,s)}})]});case"count":return a.jsxs("div",{className:d,onMouseDown:i=>{i.target.classList.contains("fill-handle")||n||i.button===0&&!i.shiftKey&&wt(e,s)},onClick:i=>{n||je(i,e,s)},onDoubleClick:()=>Be(e,s),children:[n?a.jsx("input",{type:"number",autoFocus:!0,min:1,max:10,value:t.count===0?"":t.count,className:"cell-count-input",onChange:i=>{const p=i.target.value;if(p===""){_(e,s,0);return}const h=parseInt(p);isNaN(h)||_(e,s,h)},onBlur:()=>{!t.count||t.count<1?_(e,s,1):t.count>10&&_(e,s,10),O(null)},onKeyDown:i=>{i.key==="Escape"?O(null):i.key==="Enter"&&(O(null),e<w.length-1&&N(e+1,s))}}):a.jsx("span",{className:"cell-text",children:t.count}),l&&a.jsx("div",{className:"fill-handle",onMouseDown:i=>{i.stopPropagation(),Je(e,s)}})]});case"preview":{const i=de(t);return a.jsxs("div",{className:`${d} preview-cell preview-${i.status}`,onClick:p=>{i.status==="completed"||i.status==="partial"?mt(e):i.status==="failed"?C.has(e)||We(e):je(p,e,s)},children:[i.status==="idle"&&a.jsx("span",{className:"preview-idle",children:"-"}),(i.status==="generating"||i.status==="completed")&&(()=>{const p=i.tasks.filter(v=>{var T;return v.status===H.COMPLETED&&((T=v.result)==null?void 0:T.url)}).map(v=>v.result.url),h=i.status==="generating",g=i.tasks.filter(v=>v.status===H.PENDING||v.status===H.PROCESSING).length;return p.length===0&&h?a.jsxs("span",{className:"preview-generating",children:[a.jsx("span",{className:"loading-spinner"}),r==="zh"?"生成中...":"Generating..."]}):a.jsxs("div",{className:"preview-images",children:[p.slice(0,h?2:3).map((v,T)=>a.jsx(P,{content:r==="zh"?"点击放大,左右切换":"Click to enlarge, swipe to navigate",showArrow:!1,children:a.jsx("div",{className:"preview-thumb clickable",onClick:W=>{W.stopPropagation(),kt(p,T)},children:a.jsx(jt,{src:v,alt:`Result ${T+1}`,showSkeleton:!1,eager:!0})})},T)),h&&a.jsx(P,{content:r==="zh"?`还有 ${g} 张生成中`:`${g} more generating`,showArrow:!1,children:a.jsxs("span",{className:"preview-generating-inline",children:[a.jsx("span",{className:"loading-spinner"}),"+",g]})}),!h&&i.completedCount>3&&a.jsx(P,{content:r==="zh"?"查看全部图片":"View all images",showArrow:!1,children:a.jsxs("span",{className:"preview-more clickable",onClick:v=>{v.stopPropagation(),mt(e)},children:["+",i.completedCount-3]})})]})})(),i.status==="failed"&&((f=i.tasks[0])==null?void 0:f.error)&&a.jsxs("div",{className:"preview-error",children:[a.jsx("span",{className:"preview-error-message",children:i.tasks[0].error.message}),((m=i.tasks[0].error.details)==null?void 0:m.originalError)&&a.jsx(P,{content:a.jsxs("div",{className:"error-details-tooltip",children:[a.jsx("div",{className:"error-details-title",children:"原始错误信息:"}),a.jsx("div",{className:"error-details-content",children:i.tasks[0].error.details.originalError})]}),theme:"light",placement:"bottom",showArrow:!1,children:a.jsx("span",{className:"preview-error-details-link",children:"[详情]"})})]}),i.status==="partial"&&(()=>{const p=i.tasks.filter(h=>{var g;return h.status===H.COMPLETED&&((g=h.result)==null?void 0:g.url)}).map(h=>h.result.url);return a.jsxs("div",{className:"preview-partial",children:[a.jsx("div",{className:"preview-images",children:p.slice(0,2).map((h,g)=>a.jsx(P,{content:r==="zh"?"点击放大,左右切换":"Click to enlarge, swipe to navigate",showArrow:!1,children:a.jsx("div",{className:"preview-thumb clickable",onClick:v=>{v.stopPropagation(),kt(p,g)},children:a.jsx(jt,{src:h,alt:`Result ${g+1}`,showSkeleton:!1,eager:!0})})},g))}),a.jsxs("span",{className:"preview-partial-info",children:["⚠️ ",i.completedCount,"/",i.tasks.length]})]})})()]})}default:return null}};return a.jsxs("div",{ref:Ke,className:"batch-image-generation",tabIndex:-1,children:[a.jsxs("div",{className:"batch-main-content",children:[a.jsxs("div",{className:"batch-toolbar",children:[a.jsx("input",{ref:Ae,type:"file",accept:"image/*",multiple:!0,onChange:Ms,style:{display:"none"}}),a.jsx("input",{ref:Ie,type:"file",accept:"image/*",multiple:!0,onChange:Ss,style:{display:"none"}}),a.jsx("input",{ref:Le,type:"file",accept:".xlsx,.xls,.csv",onChange:As,style:{display:"none"}}),a.jsxs("div",{className:"toolbar-left",children:[a.jsx(P,{content:r==="zh"?"下载模板":"Download Template",theme:"light",children:a.jsx(D,{variant:"outline",theme:"default",icon:a.jsx(Xt,{}),onClick:Ps,"data-track":"batch_download_template_click"})}),a.jsx(P,{content:r==="zh"?"导入 Excel":"Import Excel",theme:"light",children:a.jsx(D,{variant:"outline",theme:"default",icon:a.jsx(ta,{}),onClick:()=>{var t;return(t=Le.current)==null?void 0:t.click()},"data-track":"batch_import_excel_click"})}),a.jsx(P,{content:r==="zh"?"批量导入图片":"Batch Import Images",theme:"light",children:a.jsx(D,{variant:"outline",theme:"default",icon:a.jsx(sa,{}),onClick:()=>{var t;return(t=Ae.current)==null?void 0:t.click()},"data-track":"batch_import_images_click","data-track-params":JSON.stringify({source:"toolbar"})})}),a.jsx("span",{className:"toolbar-divider"}),a.jsx(P,{content:r==="zh"?"选择失败行":"Select Failed Rows",theme:"light",children:a.jsx(D,{variant:"text",theme:"default",icon:a.jsx(aa,{}),onClick:Is,"data-track":"batch_select_failed_click"})}),a.jsx(P,{content:r==="zh"?"反选":"Invert Selection",theme:"light",children:a.jsx(D,{variant:"text",theme:"default",icon:a.jsx(na,{}),onClick:Os,"data-track":"batch_invert_selection_click"})}),a.jsx("span",{className:"toolbar-divider"}),a.jsx(D,{variant:"text",theme:"default",icon:a.jsx(ra,{}),onClick:xs,className:"batch-delete-btn","data-track":"batch_delete_selected_click","data-track-params":JSON.stringify({count:C.size}),children:r==="zh"?"删除选中":"Delete Selected"}),a.jsx("span",{className:"toolbar-divider"}),a.jsx(D,{variant:"outline",theme:"default",icon:a.jsx(Xt,{}),onClick:Fs,className:"batch-download-btn","data-track":"batch_download_images_click","data-track-params":JSON.stringify({count:C.size}),children:r==="zh"?"下载选中图片":"Download"})]}),a.jsxs("div",{className:"toolbar-right",children:[a.jsx("div",{className:"batch-knowledge-context-wrapper",children:a.jsx(ha,{value:tt,onChange:us,disabled:re,language:r,label:r==="zh"?"上下文":"Context"})}),a.jsx("div",{className:"model-selector-wrapper","data-track":"batch_model_select",children:a.jsx(la,{selectedModel:x,selectedSelectionKey:dt,onSelect:t=>{Te(t),De(null),R==null||R(t),M==null||M(null)},onSelectModel:t=>{Te(t.id);const e=Qe(t);De(e),R==null||R(t.id),M==null||M(e)},language:r,models:ue,placement:"down",variant:"form",disabled:re})}),a.jsx(D,{theme:"primary",onClick:Us,loading:re,disabled:re,className:"batch-generate-btn","data-track":"batch_generate_click","data-track-params":JSON.stringify({selectedRows:C.size,model:x}),children:re?r==="zh"?"提交中...":"Submitting...":r==="zh"?"生成选中行":"Generate Selected"}),a.jsx("span",{className:"toolbar-divider"}),!Rt&&!Tt&&a.jsx(P,{content:r==="zh"?"显示素材库":"Show Library",theme:"light",children:a.jsx(D,{variant:"outline",theme:"default",icon:a.jsx(Yt,{size:16}),onClick:()=>st(!0),"data-track":"batch_library_show_click"})})]})]}),a.jsxs("div",{className:`excel-table-container ${V?"is-filling":""} ${we?"is-selecting":""}`,onMouseMove:ys,onMouseUp:Ve,onMouseLeave:Ve,children:[a.jsxs("table",{className:"excel-table",children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{className:"col-checkbox",children:a.jsx(P,{content:ds||(r==="zh"?"全选/取消全选":"Select All / Deselect All"),theme:"light",showArrow:!1,visible:ms,onVisibleChange:t=>at(t),children:a.jsx("div",{className:"checkbox-wrapper",children:a.jsx(Qt,{checked:w.length>0&&C.size===w.length,indeterminate:C.size>0&&C.size<w.length,onChange:Ks})})})}),a.jsx("th",{className:"row-number",children:"#"}),a.jsx("th",{className:"col-prompt",children:a.jsxs("div",{className:"th-content",children:[r==="zh"?"提示词":"Prompt",a.jsx(P,{content:r==="zh"?"向下填充":"Fill down",theme:"light",children:a.jsx(D,{variant:"text",shape:"circle",size:"small",icon:a.jsx(Xe,{}),className:"column-fill-btn",onClick:()=>Ge("prompt"),"data-track":"batch_fill_column_click","data-track-params":JSON.stringify({column:"prompt"})})})]})}),a.jsx("th",{className:"col-params",children:a.jsxs("div",{className:"th-content",children:[r==="zh"?"参数":"Params",a.jsx(P,{content:r==="zh"?"向下填充":"Fill down",theme:"light",children:a.jsx(D,{variant:"text",shape:"circle",size:"small",icon:a.jsx(Xe,{}),className:"column-fill-btn",onClick:()=>Ge("params"),"data-track":"batch_fill_column_click","data-track-params":JSON.stringify({column:"params"})})})]})}),a.jsx("th",{className:"col-images",children:a.jsxs("div",{className:"th-content",children:[r==="zh"?"参考图片":"Ref Images",a.jsx(P,{content:r==="zh"?"向下填充":"Fill down",theme:"light",children:a.jsx(D,{variant:"text",shape:"circle",size:"small",icon:a.jsx(Xe,{}),className:"column-fill-btn",onClick:()=>Ge("images"),"data-track":"batch_fill_column_click","data-track-params":JSON.stringify({column:"images"})})})]})}),a.jsx("th",{className:"col-count",children:a.jsxs("div",{className:"th-content",children:[r==="zh"?"数量":"Count",a.jsx(P,{content:r==="zh"?"向下填充":"Fill down",theme:"light",children:a.jsx(D,{variant:"text",shape:"circle",size:"small",icon:a.jsx(Xe,{}),className:"column-fill-btn",onClick:()=>Ge("count"),"data-track":"batch_fill_column_click","data-track-params":JSON.stringify({column:"count"})})})]})}),a.jsx("th",{className:"col-preview",children:a.jsx("div",{className:"th-content",children:r==="zh"?"预览":"Preview"})})]})}),a.jsx("tbody",{children:w.map((t,e)=>a.jsxs("tr",{"data-row-index":e,className:`${C.has(e)?"row-selected":""} ${hs===e?"row-drag-over":""} ${$t.includes(e)?"fill-preview":""}`,onDragOver:s=>Es(s,e),onDragLeave:_s,onDrop:s=>Ts(s,e),children:[a.jsx("td",{className:"col-checkbox",onClick:s=>{We(e,s.shiftKey)},children:a.jsx("div",{className:"checkbox-wrapper",onClick:s=>{s.stopPropagation(),We(e,s.shiftKey)},onMouseEnter:()=>C.size>0&&at(!0),onMouseLeave:()=>at(!1),children:a.jsx(Qt,{checked:C.has(e)})})}),a.jsx("td",{className:"row-number",onClick:s=>We(e,s.shiftKey),style:{cursor:"pointer"},children:e+1}),a.jsx("td",{children:Ce(t,e,"prompt")}),a.jsx("td",{children:Ce(t,e,"params")}),a.jsx("td",{children:Ce(t,e,"images")}),a.jsx("td",{children:Ce(t,e,"count")}),a.jsx("td",{children:Ce(t,e,"preview")})]},t.id))})]}),a.jsxs("div",{className:"add-rows-section",children:[a.jsx(D,{variant:"dashed",shape:"circle",onClick:()=>Me(!0),title:r==="zh"?"添加行":"Add Rows",icon:a.jsx(ia,{}),className:"add-rows-btn","data-track":"batch_add_rows_click"}),a.jsx(D,{variant:"outline",theme:"default",icon:a.jsx(oa,{}),onClick:Ls,className:"export-excel-btn","data-track":"batch_export_excel_click","data-track-params":JSON.stringify({rowCount:w.length}),children:r==="zh"?"导出Excel":"Export Excel"})]})]}),a.jsx("p",{className:"hint-text",children:r==="zh"?"提示:Enter 编辑/确认 | Tab 移动 | Ctrl+Z 撤销 | Ctrl+Y 重做 | 拖拽图片到行":"Tip: Enter to edit/confirm | Tab to move | Ctrl+Z undo | Ctrl+Y redo | Drag images to rows"})]}),!Rt&&a.jsxs("div",{className:`image-library-sidebar ${Tt?"":"hidden"}`,children:[a.jsxs("div",{className:"library-header",children:[a.jsx("h3",{children:r==="zh"?"素材库":"Library"}),a.jsx(D,{variant:"text",shape:"square",size:"small",className:"close-btn",onClick:()=>st(!1),icon:a.jsx(ca,{}),"data-track":"batch_library_close_click"})]}),a.jsxs("div",{className:"library-content",children:[a.jsxs("div",{className:"upload-section",children:[a.jsx("input",{ref:Pe,type:"file",accept:"image/*",multiple:!0,onChange:vs,style:{display:"none"}}),a.jsx(D,{block:!0,theme:"default",variant:"outline",icon:a.jsx(Zt,{size:16}),onClick:()=>{var t;return(t=Pe.current)==null?void 0:t.click()},"data-track":"batch_library_upload_click",children:r==="zh"?"上传图片":"Upload"})]}),a.jsx("div",{className:"library-grid",children:Et.length===0?a.jsx("div",{className:"empty-library",children:r==="zh"?"暂无图片,请上传":"No images, please upload"}):Et.map(t=>a.jsx(P,{content:r==="zh"?"点击添加到选中行,或拖拽到指定行":"Click to add to selected rows, or drag to a specific row",showArrow:!1,children:a.jsx("div",{className:"library-image",onClick:()=>js(t.url),draggable:!0,onDragStart:e=>Ds(e,t.url),"data-track":"batch_library_image_click",children:a.jsx("img",{src:t.url,alt:t.name,draggable:!1})})},t.id))})]})]}),ps&&a.jsx("div",{className:"batch-import-modal-overlay",onClick:bt,children:a.jsxs("div",{className:"batch-import-modal",onClick:t=>t.stopPropagation(),children:[a.jsxs("div",{className:"modal-header",children:[a.jsx("h3",{children:r==="zh"?"批量导入图片":"Batch Import Images"}),a.jsx("button",{className:"close-btn",onClick:bt,children:"×"})]}),a.jsxs("div",{className:"modal-body",children:[a.jsx("p",{className:"import-info",children:r==="zh"?`已选择 ${L.length} 张图片`:`${L.length} images selected`}),a.jsxs("div",{className:"import-settings-row",children:[a.jsxs("div",{className:"import-setting-item",children:[a.jsx("label",{children:r==="zh"?"从第几行开始:":"Start from row:"}),a.jsx("input",{type:"number",min:1,max:w.length+Math.ceil(L.length/ee),value:oe,onChange:t=>{const e=Math.max(1,parseInt(t.target.value)||1);At(e)},className:"start-row-input"})]}),a.jsxs("div",{className:"import-setting-item",children:[a.jsx("label",{children:r==="zh"?"每行图片数:":"Images per row:"}),a.jsx("div",{className:"per-row-options",children:[1,2,3,4,5].map(t=>a.jsx("button",{className:`per-row-btn ${ee===t?"active":""}`,onClick:()=>fs(t),children:t},t))})]})]}),a.jsx("p",{className:"import-preview",children:r==="zh"?`从第 ${oe} 行开始,填充 ${Math.ceil(L.length/ee)} 行,每行 ${ee} 张图片`:`Starting from row ${oe}, filling ${Math.ceil(L.length/ee)} rows with ${ee} image(s) each`}),a.jsxs("div",{className:"import-preview-grid",children:[ut.map((t,e)=>a.jsx("div",{className:"preview-item",children:a.jsx("img",{src:t,alt:""})},e)),L.length>12&&a.jsxs("div",{className:"preview-more",children:["+",L.length-12]})]})]}),a.jsxs("div",{className:"modal-footer",children:[a.jsx(D,{variant:"outline",theme:"default",onClick:bt,"data-track":"batch_import_modal_cancel_click",children:r==="zh"?"取消":"Cancel"}),a.jsx(D,{theme:"default",variant:"outline",onClick:$s,"data-track":"batch_import_modal_confirm_click","data-track-params":JSON.stringify({imageCount:L.length,imagesPerRow:ee,startRow:oe}),children:r==="zh"?"确认导入":"Import"})]})]})}),a.jsx(fa,{...gs}),a.jsx(es,{visible:ws,onClose:()=>Me(!1),header:r==="zh"?"添加行":"Add Rows",confirmBtn:{content:r==="zh"?"添加":"Add",theme:"default",variant:"outline",onClick:()=>{ks($e),Me(!1),y.success(r==="zh"?`已添加 ${$e} 行`:`Added ${$e} rows`)}},cancelBtn:{content:r==="zh"?"取消":"Cancel",onClick:()=>Me(!1)},width:360,className:"add-rows-dialog",destroyOnClose:!0,children:a.jsxs("div",{className:"add-rows-content",children:[a.jsx("label",{children:r==="zh"?"添加行数:":"Number of rows:"}),a.jsx("input",{type:"number",min:1,max:100,value:$e,onChange:t=>bs(Math.max(1,Math.min(100,parseInt(t.target.value)||1))),className:"add-rows-input",autoFocus:!0})]})}),a.jsx(es,{visible:ve!==null,onClose:()=>mt(null),header:r==="zh"?`第 ${(ve??0)+1} 行生成结果`:`Row ${(ve??0)+1} Results`,footer:null,width:"70vw",className:"row-gallery-dialog",destroyOnClose:!0,children:ve!==null&&(()=>{const t=w[ve];if(!t)return null;const s=de(t).tasks.filter(l=>{var u;return l.status===H.COMPLETED&&((u=l.result)==null?void 0:u.url)}),n=s.map(l=>l.result.url);return a.jsxs("div",{className:"row-gallery-content",children:[a.jsx("div",{className:"gallery-grid",children:s.map((l,u)=>a.jsxs("div",{className:"gallery-item",onClick:()=>kt(n,u),children:[a.jsx(jt,{src:l.result.url,alt:`Result ${u+1}`,showSkeleton:!1,eager:!0}),a.jsx("span",{className:"gallery-item-index",children:u+1})]},l.id))}),s.length===0&&a.jsx("div",{className:"gallery-empty",children:r==="zh"?"暂无生成结果":"No results yet"})]})})()}),Ot&&a.jsx(ba,{isOpen:Ot,onClose:()=>{ht(!1),pt(null)},mode:ua.SELECT,filterType:be.IMAGE,onSelect:Rs}),se]})};export{Aa as default};
|