aitu-app 0.9.0 → 0.9.2
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-cp00LGgR.js → CanvasAudioPlayer-C_USx5uz.js} +1 -1
- package/assets/{ComicCreator-CAmJF3JX.js → ComicCreator-qGQaXp7h.js} +2 -2
- package/assets/DeferredAIInputBar-CPykEFYX.css +1 -0
- package/assets/DeferredAIInputBar-LmZGQCLT.js +107 -0
- package/assets/{DrawnixDeferredFeatures-DIznfzB7.js → DrawnixDeferredFeatures-Hy_-quZ1.js} +1 -1
- package/assets/{KnowledgeBaseContent-CxilHI-j.js → KnowledgeBaseContent-DSKNA70H.js} +8 -8
- package/assets/{MVCreator-ZrinzYPm.js → MVCreator-C3iClDLU.js} +12 -10
- package/assets/{ModelBenchmarkWorkbench-DbesnX6E.js → ModelBenchmarkWorkbench-BxwdcZ0q.js} +2 -2
- package/assets/{MusicAnalyzer-BzXD1qYH.js → MusicAnalyzer-f_T6_YPJ.js} +2 -2
- package/assets/{ParametersDropdown-DBQCDv3g.js → ParametersDropdown-CTSN3ClD.js} +1 -1
- package/assets/{PromptHistoryTool-CUCIE0Ld.js → PromptHistoryTool-DV-8RSdz.js} +2 -2
- package/assets/{ResizableDivider-CdfJF8GW.js → ResizableDivider-CUQBmPpx.js} +1 -1
- package/assets/TaskQueuePanel-CtjY1W4t.js +1 -0
- package/assets/{VideoAnalyzer-wtxorxD3.js → VideoAnalyzer-BBVBSONO.js} +3 -3
- package/assets/{VideoAnalyzer-C90c84gt.js → VideoAnalyzer-BmAjGvN8.js} +1 -1
- package/assets/{ai-chat-B5qFht2H.js → ai-chat-BO5vbKZW.js} +5 -5
- package/assets/{ai-generation-preferences-service-CvWbMxv3.js → ai-generation-preferences-service-ZmPTR-wz.js} +1 -1
- package/assets/{batch-image-generation-Bo3h_Eop.js → batch-image-generation-BLBSv-t6.js} +6 -6
- package/assets/{diagram-engines-C9ewAq_o.js → diagram-engines-CSzW_-6N.js} +2 -2
- package/assets/{editor-engines-CvxZrFyB.js → editor-engines-C573k8UM.js} +1 -1
- package/assets/{index-Dw6PsLbq.js → index-BT-rxxI3.js} +2 -2
- package/assets/{index-BCqdmg38.js → index-Dw_8lcIi.js} +1 -1
- package/assets/{index-BSlnQdcy.js → index-IHNaVKGH.js} +1 -1
- package/assets/{index-CjBeKr1R.js → index-N8asYyaz.js} +1 -1
- package/assets/{index-CylhK_f5.js → index-jxwTv7c1.js} +1 -1
- package/assets/{index.es-BKVY-J2g.js → index.es-BLXvmueB.js} +1 -1
- package/assets/{jspdf.es.min-BM9ML7Zw.js → jspdf.es.min-DxWvbkh4.js} +2 -2
- package/assets/{markdown-to-drawnix-COS1iVyq.js → markdown-to-drawnix-BVFYnimo.js} +2 -2
- package/assets/{mermaid-to-drawnix-oplawQO0.js → mermaid-to-drawnix-nGs2aeZ7.js} +2 -2
- package/assets/{model-benchmark-launcher-DD4vN0Ca.js → model-benchmark-launcher-DAWoSySc.js} +1 -1
- package/assets/{photo-wall-splitter-CbKqFOIV.js → photo-wall-splitter-CCUURzGk.js} +1 -1
- package/assets/{prompt-utils-7t-jk6n6.js → prompt-utils-MF_LILNU.js} +1 -1
- package/assets/{settings-dialog-D2yEWl8J.js → settings-dialog-Ac7R-_CG.js} +1 -1
- package/assets/{skill-dsl-parser-C-utRXFg.js → skill-dsl-parser-Do9iAYbB.js} +1 -1
- package/assets/{startup-app-DxX-P1pm.js → startup-app-eD_rQhSh.js} +531 -527
- package/assets/{task-sync-Dr7Nza2v.js → task-sync-BJVOunRa.js} +1 -1
- package/assets/{tool-windows-BIjc1zsU.js → tool-windows-CmgL3thd.js} +17 -17
- package/assets/ttd-dialog-B12v0SVY.js +6 -0
- package/assets/{ttd-dialog-submit-shortcut-yUk15rsg.js → ttd-dialog-submit-shortcut-C2lJygXA.js} +1 -1
- package/assets/useCharacters-BAKE4TeJ.js +2 -0
- package/assets/{useMediaViewer-CEvHYype.js → useMediaViewer-BGw5RkSR.js} +1 -1
- package/assets/{useWorkflowSubmission-Cxhdsl2b.js → useWorkflowSubmission-iAPmKke9.js} +6 -6
- package/assets/{video-recovery-service-CB8hyRf5.js → video-recovery-service-CW7bErP2.js} +1 -1
- package/assets/{workflow-generation-utils-JoRODaP7.js → workflow-generation-utils-DhIVnOHO.js} +2 -2
- package/assets/workflow-submission-service-Ce0cpj8E.js +4 -0
- package/changelog.json +18 -13
- package/idle-prefetch-manifest.json +306 -306
- package/manifest.json +3 -3
- package/package.json +1 -1
- package/precache-manifest.json +6 -6
- package/sw.js +1 -1
- package/version.json +6 -3
- package/assets/DeferredAIInputBar-CzMATNng.js +0 -107
- package/assets/DeferredAIInputBar-D_e6qG1y.css +0 -1
- package/assets/TaskQueuePanel-oLG4DAzJ.js +0 -1
- package/assets/ttd-dialog-CNSSc4wk.js +0 -6
- package/assets/useCharacters-DzXMuknh.js +0 -2
- package/assets/workflow-submission-service-BIGFW4s4.js +0 -4
package/version.json
CHANGED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./startup-app-CKHrOmQ0.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{au as So,ee as br,r as o,iy as nn,am as Ne,iz as ns,f0 as cn,j as c,E as Qe,iA as vr,bz as Mo,dB as Nt,bg as kr,iB as Sr,iC as Mr,b3 as Cr,n as Tr,e0 as $s,f_ as Pr,aR as Er,iD as Je,iE as Xn,aX as Nn,bo as ss,bb as Rt,bn as zt,bp as xt,aF as Dn,iF as os,iG as is,iH as Ze,iI as cs,_ as ls,iJ as Vs,aK as ds,a0 as us,cl as Rn,de as Co,b9 as To,he as Ar,dd as Dr,v as fs,l as jr,iK as Nr,M as qe,iL as Rr,X as zr,a4 as Or,c2 as Wr,hC as Lr,iM as Br,iN as rs,fB as ps,az as Fr,p as Hr,iO as Gr,iP as Ur,iQ as $r,bq as jn,iR as as,y as Po,iS as Vr,iT as Kr,ec as Yr,f$ as pt,ge as Zn,al as wt,av as Dt,iU as Ks,iV as Ys,iW as Xr,g9 as He,fZ as qn,bP as Zr,iX as vn,aD as hs,ef as Xs,eg as qr,iY as Jr,iZ as Qr,i_ as ea,i$ as ta,j0 as Zs,hk as Eo,bw as Jn,e1 as qs,j1 as na,bQ as Ao,j2 as Js,b as Qs,j3 as eo,j4 as to,aI as sn,eu as sa,dk as oa,aA as kn,eK as ra,j5 as aa,j6 as no,j7 as ia,j8 as ca}from"./startup-app-DxX-P1pm.js";import{u as la,a as da,c as Sn,b as jt,W as ua}from"./useWorkflowSubmission-Cxhdsl2b.js";import{_ as so}from"./startup-runtime-DTmhLESk.js";import{P as fa,c as Mn,G as Cn,b as pa,o as ha,i as Tn,l as ht,p as ma,q as oo,K as ga,S as xa,r as wa,s as ya,t as ro,v as ao,x as io}from"./ai-chat-B5qFht2H.js";import{c as Ia,q as _a,A as co,M as ba}from"./tool-windows-BIjc1zsU.js";import{P as va}from"./ParametersDropdown-DBQCDv3g.js";import{u as ka,r as Sa,g as Ma,a as Ca}from"./prompt-utils-7t-jk6n6.js";import{s as lo}from"./workflow-submission-service-BIGFW4s4.js";import{b as Ta}from"./mj-params-M-7csAp7.js";import{l as Pa,a as Qn,s as Ea,b as Aa}from"./ai-generation-preferences-service-CvWbMxv3.js";import"./skill-dsl-parser-C-utRXFg.js";const Da=({generationType:e,onSelectPrompt:n,language:t,extraActions:d,onBeforeOpenMyPrompts:r})=>{const{history:l,removeHistory:a,refreshHistory:m}=So({deduplicateWithPresets:!1,modelTypeFilter:e==="image"||e==="video"?void 0:e}),{imageHistory:u,videoHistory:h}=ka(),{confirm:p,confirmDialog:_}=br(),[I,w]=o.useState(!1),[,g]=o.useState(0),A=o.useRef(null),T=o.useRef(null),C=o.useRef(null),R=t==="zh"?"我的提示词":"My Prompts",N=e==="image"||e==="video"?Sa({generationType:e,language:t,promptContents:Ma(e,t,e==="image"?u:h),imageHistory:u,videoHistory:h}):Ca({generationType:e,language:t,aiInputHistory:l,imageHistory:u,videoHistory:h});o.useEffect(()=>nn.subscribeChanges(()=>{m(),g(Z=>Z+1)}),[m]),o.useEffect(()=>()=>{T.current&&clearTimeout(T.current),C.current&&clearTimeout(C.current)},[]);const b=o.useCallback(()=>{C.current&&(clearTimeout(C.current),C.current=null),T.current=setTimeout(()=>{m(),g(Z=>Z+1),I||Ne.trackPromptAction({action:"open_panel",surface:"ai_input_prompt_popover",promptType:e,itemCount:N.length}),w(!0)},150)},[e,I,N.length,m]),z=o.useCallback(()=>{T.current&&(clearTimeout(T.current),T.current=null),C.current=setTimeout(()=>{w(!1)},200)},[]),P=o.useCallback(Z=>{n({content:Z.content,modelType:Z.modelType,scene:Z.scene}),w(!1)},[n]),X=o.useCallback(async Z=>{const S=N.find($=>$.id===Z);!S||!await p({title:t==="zh"?"确认删除提示词":"Delete Prompt",description:t==="zh"?"确定要删除这条提示词吗?此操作不可撤销。":"Are you sure you want to delete this prompt? This action cannot be undone.",confirmText:t==="zh"?"删除":"Delete",cancelText:t==="zh"?"取消":"Cancel",danger:!0})||(nn.deletePrompt(e,S.content),S.historyId&&e!=="image"&&e!=="video"?a(S.historyId):g($=>$+1))},[p,e,t,N,a]),M=o.useCallback(Z=>{const S=N.find(D=>D.id===Z);S&&(nn.isPinned(e,S.content)?nn.unpinPrompt(e,S.content):nn.pinPrompt(e,S.content),g(D=>D+1))},[e,N]),K=o.useCallback(()=>{const Z=ns.find($=>$.id==="prompt-history");if(!Z){Ne.trackPromptAction({action:"open_tool",surface:"ai_input_prompt_popover",promptType:e,status:"failed",metadata:{tool_id:"prompt-history",reason:"tool_not_found"}});return}r==null||r();const S=cn.getToolState("prompt-history");console.info("[PromptHistoryPopover] open my prompts",{generationType:e,beforeStatus:S==null?void 0:S.status,beforeInstanceId:S==null?void 0:S.instanceId,beforeIsLauncher:S==null?void 0:S.isLauncher,beforeIsPinned:S==null?void 0:S.isPinned}),Ne.trackPromptAction({action:"open_tool",surface:"ai_input_prompt_popover",promptType:e,status:"success",metadata:{tool_id:Z.id}}),w(!1),cn.openTool(Z,{componentProps:{initialCategory:e}});const D=cn.getToolState("prompt-history");console.info("[PromptHistoryPopover] requested my prompts open",{generationType:e,afterStatus:D==null?void 0:D.status,afterInstanceId:D==null?void 0:D.instanceId,afterIsLauncher:D==null?void 0:D.isLauncher,afterIsPinned:D==null?void 0:D.isPinned})},[e,r]);return c.jsxs("div",{ref:A,className:"prompt-history-popover",children:[c.jsxs("div",{className:"prompt-history-popover__actions",children:[c.jsx(Qe,{content:R,showArrow:!1,children:c.jsx("button",{className:"prompt-history-popover__trigger","data-track":"ai_input_click_history",onMouseEnter:b,onMouseLeave:z,children:c.jsx(vr,{size:18})})}),d]}),I&&c.jsx("div",{className:"prompt-history-popover__panel-wrapper",onMouseEnter:b,onMouseLeave:z,children:c.jsx(fa,{title:R,items:N,onSelect:P,onTogglePin:M,onDelete:X,onTitleClick:K,language:t,showCount:!0,analyticsSurface:"ai_input_prompt_popover",analyticsPromptType:e})}),_]})};function ja(e){var n;return!!((n=e.params)!=null&&n.longVideoMeta)}function Na(e){var n;return((n=e.params)==null?void 0:n.longVideoMeta)||null}class Ot{constructor(){this.isInitialized=!1,this.batches=new Map,this.initTimestamp=0}static getInstance(){return Ot.instance||(Ot.instance=new Ot),Ot.instance}initialize(){this.isInitialized||(this.isInitialized=!0,this.initTimestamp=Date.now(),Mo.observeTaskUpdates().subscribe(n=>{if(n.type==="taskUpdated"&&n.task.status===Nt.COMPLETED&&n.task.type===kr.VIDEO&&ja(n.task)){if((n.task.completedAt||0)<this.initTimestamp)return;this.handleSegmentCompleted(n.task).catch(d=>{console.error("[LongVideoChain] Error handling completed segment:",d)})}}))}async handleSegmentCompleted(n){var h;const t=Na(n);if(!t)return;const{segmentIndex:d,totalSegments:r,scripts:l,batchId:a}=t,m=(h=n.result)==null?void 0:h.url;let u=this.batches.get(a);if(u||(u={batchId:a,totalSegments:r,completedSegments:new Map,processedSegments:new Set,creatingNextFor:null,isMerging:!1,mergeCompleted:!1,scripts:l||[],characterReferenceUrls:t.characterReferenceUrls,characterDescription:t.characterDescription},this.batches.set(a,u)),!u.processedSegments.has(d)){if(u.processedSegments.add(d),m&&u.completedSegments.set(d,m),u.completedSegments.size===r){await this.mergeAndInsert(u);return}if(u.creatingNextFor!==d&&d<r){u.creatingNextFor=d;try{await this.createNextSegment(n,t,l,m,u.characterReferenceUrls,u.characterDescription)}finally{u.creatingNextFor=null}}}}async createNextSegment(n,t,d,r,l,a){const m=t.segmentIndex+1,u=d.find(_=>_.index===m);if(!u){console.error(`[LongVideoChain] Script not found for segment ${m}`);return}let h;if(r)try{h=(await Sr(r)).dataUrl}catch(_){console.error("[LongVideoChain] Failed to extract last frame:",_)}const p={...t,segmentIndex:m,needsLastFrame:m<t.totalSegments,characterReferenceUrls:l??t.characterReferenceUrls,characterDescription:a??t.characterDescription};Ia(u,p,h)}async mergeAndInsert(n){if(!(n.isMerging||n.mergeCompleted)){n.isMerging=!0;try{const t=[];for(let a=1;a<=n.totalSegments;a++){const m=n.completedSegments.get(a);m&&t.push(m)}if(t.length===0){console.error("[LongVideoChain] No video URLs to merge");return}const d=this.extractTransitions(n),l=await Mr(t,(a,m,u)=>{const h=u||`${m} ${a.toFixed(1)}%`},{transitions:d,transitionDuration:.5});await this.insertMergedVideo(l.url),n.mergeCompleted=!0,this.cleanupBatch(n.batchId)}catch(t){console.error("[LongVideoChain] Merge failed:",t),this.cleanupBatch(n.batchId)}finally{n.isMerging=!1}}}async insertMergedVideo(n){try{await _a("video",n)}catch(t){console.error("[LongVideoChain] Failed to insert video to canvas:",t)}}extractTransitions(n){return!n.scripts||n.scripts.length===0?[]:n.scripts.sort((t,d)=>t.index-d.index).slice(0,-1).map(t=>t.transition_hint||"cut")}cleanupBatch(n){const t=this.batches.get(n);t&&(t.completedSegments.clear(),t.processedSegments.clear(),this.batches.delete(n))}getBatchStatus(n){const t=this.batches.get(n);return t?{completed:t.completedSegments.size,total:t.totalSegments,isMerging:t.isMerging,mergeCompleted:t.mergeCompleted}:null}}const Ra=Ot.getInstance();function za(){Ra.initialize()}function uo(){return`img-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}async function fo(e){return new Promise((n,t)=>{const d=new Image,r=e.startsWith("http")&&!e.startsWith(location.origin);d.crossOrigin="anonymous",d.onload=()=>n(d),d.onerror=()=>{t(r?new Error("无法加载外部图片,可能是跨域 (CORS) 限制。请先下载图片到本地后再操作。"):new Error("图片加载失败,请检查图片是否有效"))},d.src=e})}function Oa(e,n=.92){return e.toDataURL("image/jpeg",n)}class Wa{async split(n,t){const{rows:d,cols:r}=t;if(d<1||r<1)throw new Error("Grid rows and cols must be at least 1");const l=await fo(n),a=l.naturalWidth,m=l.naturalHeight,u=Math.floor(a/r),h=Math.floor(m/d),p=[];for(let _=0;_<d;_++)for(let I=0;I<r;I++){const w=_*r+I,g=I*u,A=_*h,T=document.createElement("canvas");T.width=u,T.height=h;const C=T.getContext("2d");if(!C)throw new Error("Failed to get canvas 2d context");C.drawImage(l,g,A,u,h,0,0,u,h);const R=Oa(T);p.push({id:uo(),imageData:R,originalIndex:w,width:u,height:h})}return p}async splitToBlob(n,t){const{rows:d,cols:r}=t;if(d<1||r<1)throw new Error("Grid rows and cols must be at least 1");const l=await fo(n),a=l.naturalWidth,m=l.naturalHeight,u=Math.floor(a/r),h=Math.floor(m/d),p=[];for(let _=0;_<d;_++)for(let I=0;I<r;I++){const w=_*r+I,g=I*u,A=_*h,T=document.createElement("canvas");T.width=u,T.height=h;const C=T.getContext("2d");if(!C)throw new Error("Failed to get canvas 2d context");C.drawImage(l,g,A,u,h,0,0,u,h);const R=await new Promise((b,z)=>{T.toBlob(P=>{P?b(P):z(new Error("Failed to create blob"))},"image/png",.92)}),N=URL.createObjectURL(R);p.push({id:uo(),imageData:N,originalIndex:w,width:u,height:h})}return p}revokeBlobUrls(n){for(const t of n)t.imageData.startsWith("blob:")&&URL.revokeObjectURL(t.imageData)}}const po=new Wa;function je(e,n){return Math.random()*(n-e)+e}function Pn(e){const n=[...e];for(let t=n.length-1;t>0;t--){const d=Math.floor(Math.random()*(t+1));[n[t],n[d]]=[n[d],n[t]]}return n}class La{calculate(n,t,d,r){switch(t){case"scattered":return this.scatteredLayout(n,d,r);case"grid":return this.gridLayout(n,d);case"circular":return this.circularLayout(n,d,r);case"inspiration-board":return this.inspirationBoardLayout(n,d,r);default:return console.warn(`[LayoutEngine] Unknown layout style: ${t}, falling back to grid`),this.gridLayout(n,d)}}scatteredLayout(n,t,d){const{maxRotation:r=15,minScale:l=.85,maxScale:a=1.15,positionJitter:m=40}=d||{},{canvasWidth:u,canvasHeight:h,startX:p,startY:_,gap:I=20}=t,w=n.length,g=Math.ceil(Math.sqrt(w)),A=Math.ceil(w/g),T=Math.max(...n.map(M=>M.width)),C=Math.max(...n.map(M=>M.height)),R=u-I*2,N=h-I*2,b=R/g,z=N/A,P=Math.min((b-I)/T,(z-I)/C,1),X=Pn(n.map((M,K)=>K));return n.map((M,K)=>{const Z=Math.floor(K/g),S=K%g,D=p+I+S*b+b/2,$=_+I+Z*z+z/2,le=je(-m,m),O=je(-m,m),oe=je(-r,r),be=je(l,a),Me=P*be,It=M.width*Me,_t=M.height*Me;return{...M,x:D+le-It/2,y:$+O-_t/2,rotation:oe,scale:Me,zIndex:X[K]}})}gridLayout(n,t){const{canvasWidth:d,canvasHeight:r,startX:l,startY:a,gap:m=20}=t,u=n.length,h=Math.ceil(Math.sqrt(u)),p=Math.ceil(u/h),_=Math.max(...n.map(R=>R.width)),I=Math.max(...n.map(R=>R.height)),w=d-m*(h+1),g=r-m*(p+1),A=w/h,T=g/p,C=Math.min(A/_,T/I,1);return n.map((R,N)=>{const b=Math.floor(N/h),z=N%h,P=R.width*C,X=R.height*C,M=l+m+z*(A+m),K=a+m+b*(T+m),Z=M+(A-P)/2,S=K+(T-X)/2;return{...R,x:Z,y:S,rotation:0,scale:C,zIndex:N}})}circularLayout(n,t,d){const{centerIndex:r=-1,radius:l,startAngle:a=-90}=d||{},{canvasWidth:m,canvasHeight:u,startX:h,startY:p}=t,_=h+m/2,I=p+u/2,w=r>=0&&r<n.length?n.filter((S,D)=>D!==r):n,g=r>=0&&r<n.length?n[r]:null,A=Math.max(...n.map(S=>S.width)),T=Math.max(...n.map(S=>S.height)),C=Math.max(A,T),R=w.length,N=C*.8,b=R*C*1.2,z=Math.max(N,b/(2*Math.PI)),P=l||Math.min(z,Math.min(m,u)/2-C/2),X=Math.min(m,u),M=Math.min(X*.25/C,1),K=[];if(g){const S=g.width*M*1.2,D=g.height*M*1.2;K.push({...g,x:_-S/2,y:I-D/2,rotation:0,scale:M*1.2,zIndex:R})}const Z=360/R;return w.forEach((S,D)=>{const le=(a+D*Z)*Math.PI/180,O=S.width*M,oe=S.height*M,be=_+P*Math.cos(le)-O/2,Me=I+P*Math.sin(le)-oe/2;K.push({...S,x:be,y:Me,rotation:0,scale:M,zIndex:D})}),K}inspirationBoardLayout(n,t,d){const{minWidthRatio:r=Mn.minWidthRatio,maxWidthRatio:l=Mn.maxWidthRatio,maxRotation:a=Mn.maxRotation,gap:m=Mn.gap}=d||{},{canvasWidth:u,canvasHeight:h,startX:p,startY:_}=t,I=n.length,w=this.assignSizeCategories(I),g=n.reduce((z,P)=>z+P.width,0)/I,A=n.reduce((z,P)=>z+P.height,0)/I,T=u||1200,C=h||600,R=Math.min(T*.25/g,C*.4/A,1),N=this.calculateInspirationBoardPositions(I,T,C,m),b=Pn(n.map((z,P)=>P));return n.map((z,P)=>{const X=N[P],M=w[P];let K;switch(M){case"large":K=je(1.2,l);break;case"medium":K=je(.9,1.1);break;case"small":K=je(r,.85);break;default:K=1}const Z=R*K,S=je(-a,a),D=je(-20,20),$=je(-15,15),le=z.width*Z,O=z.height*Z;return{...z,x:p+X.x+D-le/2,y:_+X.y+$-O/2,rotation:S,scale:Z,zIndex:b[P]}})}assignSizeCategories(n){const t=[],d=Math.max(2,Math.floor(n*.25)),r=Math.max(2,Math.floor(n*.25)),l=n-d-r;for(let a=0;a<d;a++)t.push("large");for(let a=0;a<l;a++)t.push("medium");for(let a=0;a<r;a++)t.push("small");return Pn(t)}calculateInspirationBoardPositions(n,t,d,r){const l=[],a=Math.ceil(n/4),m=Math.ceil(n/a),u=(t-r*2)/m,h=(d-r*2)/a;for(let p=0;p<n;p++){const _=Math.floor(p/m),I=p%m,w=r+I*u+u/2,g=r+_*h+h/2,A=je(-u*.3,u*.3),T=je(-h*.2,h*.2);l.push({x:w+A,y:g+T})}return Pn(l)}calculateRequiredSize(n,t,d=.5){const r=n.length,l=Math.ceil(Math.sqrt(r)),a=Math.ceil(r/l),m=Math.max(...n.map(w=>w.width)),u=Math.max(...n.map(w=>w.height)),h=20,p=t==="scattered"?60:40,_=l*m*d+(l+1)*h+p*2,I=a*u*d+(a+1)*h+p*2;return{width:_,height:I}}}const ho=new La;class Ba{constructor(){this.board=null}setBoard(n){this.board=n}getBoard(){return this.board}async generate(n){const{theme:t,gridConfig:d=Cn.gridConfig,layoutStyle:r=Cn.layoutStyle,imageSize:l=Cn.imageSize,imageQuality:a=Cn.imageQuality}=n;try{const m=this.buildPrompt(t,d),u=await Cr.generateImage(m,{size:l,quality:a,response_format:"url"});if(!u.data||u.data.length===0)throw new Error("AI 生成图片失败:未返回图片数据");const h=u.data[0].url||u.data[0].b64_json,p=h&&Tr(String(h));if(!p)throw new Error("AI 生成图片失败:未返回图片 URL");const _=await $s.getImageForAI(p),I=_.type==="base64"?_.value:p,w=await po.split(I,d),g=this.calculateLayoutParams(w),A=ho.calculate(w,r,g);return{success:!0,originalImageUrl:p,elements:A}}catch(m){return console.error("[GridImageService] Generation failed:",m),{success:!1,error:m.message||"宫格图生成失败"}}}async processExistingImage(n,t,d="scattered"){try{const r=await $s.getImageForAI(n),l=r.type==="base64"?r.value:n,a=await po.split(l,t),m=this.calculateLayoutParams(a),u=ho.calculate(a,d,m);return{success:!0,originalImageUrl:n,elements:u}}catch(r){return console.error("[GridImageService] Processing failed:",r),{success:!1,error:r.message||"宫格图处理失败"}}}async insertToBoard(n,t){if(!this.board)throw new Error("画板未初始化,请先调用 setBoard");let d=(t==null?void 0:t[0])??100,r=t==null?void 0:t[1];if(r===void 0){const a=Pr(this.board);r=(a==null?void 0:a[1])??100,d=(a==null?void 0:a[0])??d}const l=[...n].sort((a,m)=>a.zIndex-m.zIndex);for(const a of l){const m=d+a.x,u=r+a.y,h={url:a.imageData,width:a.width*a.scale,height:a.height*a.scale};Er.insertImage(this.board,h,[m,u])}}async generateAndInsert(n,t){const d=await this.generate(n);return d.success&&d.elements&&await this.insertToBoard(d.elements,t),d}buildPrompt(n,t){const d=pa.zh;return d(n,t.rows,t.cols)}calculateLayoutParams(n){const t=n.reduce((w,g)=>w+g.width,0),d=n.reduce((w,g)=>w+g.height,0),r=n.length,l=Math.ceil(Math.sqrt(r)),a=Math.ceil(r/l),m=t/r,u=d/r,h=30,p=50,_=l*m+(l+1)*h+p*2,I=a*u+(a+1)*h+p*2;return{canvasWidth:_,canvasHeight:I,startX:0,startY:0,gap:h}}}const mo=new Ba;function Fa(e){return{cleanText:e,selectedAudioModel:null,selectedImageModel:null,selectedVideoModel:null,selectedParams:[],selectedCount:null}}function Ha(){const e=Nn.get();return(e==null?void 0:e.imageModelName)||xt()}function Ga(){const e=Nn.get();return(e==null?void 0:e.videoModelName)||Rt()}function Ua(){const e=Nn.get();return(e==null?void 0:e.audioModelName)||zt()}function go(){const e=Nn.get();return(e==null?void 0:e.textModelName)||ss()}function $a(e,n,t){if(n.length>0)return n.join(`
|
|
3
|
-
`);if(e){if(t===1)return"请仔细分析这张图片的内容、风格、构图、色调和艺术特点,推测生成这张图片可能使用的原始提示词,然后基于你推测的提示词重新生成一张全新的、风格相似但内容不完全相同的图片。不要直接复制原图。";if(t>1)return"请分析这些图片的主题、风格和视觉元素,找出它们之间的共同点或关联性,然后创造性地将它们融合成一张全新的、和谐统一的图片。融合时请保持各图片的精华元素,确保最终作品在构图、色调和风格上协调一致。"}return""}function on(e){return e.replace(":","x").toLowerCase()}function Va(e,n,t){const d=n.texts.length>0||n.images.length>0||n.videos.length>0||n.graphics.length>0,r=n.texts,l=n.images.length+n.graphics.length,a=Fa(e),m=a.cleanText.trim().length>0;let u=(t==null?void 0:t.generationType)||"image",h,p=!1;if(t!=null&&t.modelId){const b=Je(t.modelId);t.generationType||((b==null?void 0:b.type)==="video"?u="video":(b==null?void 0:b.type)==="audio"?u="audio":(b==null?void 0:b.type)==="text"?u="text":u="image"),h=t.modelId,p=!0}else a.selectedAudioModel?(u="audio",h=a.selectedAudioModel,p=!0):a.selectedVideoModel?(u="video",h=a.selectedVideoModel,p=!0):a.selectedImageModel?(u="image",h=a.selectedImageModel,p=!0):!d&&m&&!(t!=null&&t.generationType)?(u="agent",h=go()):u==="video"?h=Ga():u==="audio"?h=Ua():u==="text"||u==="agent"?h=go():h=Ha();let _;(t==null?void 0:t.generationType)==="image"||(t==null?void 0:t.generationType)==="video"||(t==null?void 0:t.generationType)==="audio"||(t==null?void 0:t.generationType)==="text"?_="direct_generation":(t==null?void 0:t.generationType)==="agent"?_="agent_flow":_=m?"agent_flow":"direct_generation";const I=a.cleanText.trim(),w=r.join(`
|
|
4
|
-
`).trim();let g;if(w&&I?g=`${w}
|
|
5
|
-
|
|
6
|
-
${I}`:I?g=I:w?g=w:d&&l>0?g=u==="text"?"":$a(d,[],l):g="",h.startsWith("mj")&&(t!=null&&t.params)){const b=Ta(t.params);b&&(g=[g,b].filter(Boolean).join(" "))}const A=(t==null?void 0:t.count)||a.selectedCount||1;let T,C,R;if(t!=null&&t.params){u!=="audio"&&u!=="text"&&u!=="agent"&&!h.startsWith("mj")&&t.params.size&&(T=on(t.params.size)),t.params.duration&&(C=t.params.duration);const b={};for(const[z,P]of Object.entries(t.params))z!=="size"&&z!=="duration"&&P&&(b[z]=P);Object.keys(b).length>0&&(R=b)}if(!T&&(t!=null&&t.size)&&t.size!=="auto"&&(T=on(t.size)),!T&&(t==null?void 0:t.size)!=="auto"){for(const b of a.selectedParams)if(b.id==="size"){T=on(b.value);break}}if(!C){for(const b of a.selectedParams)if(b.id==="duration"){C=b.value;break}}if(!T&&(t==null?void 0:t.size)!=="auto"&&u!=="text"&&u!=="agent"&&u!=="audio"){const b=Je(h);if((b==null?void 0:b.type)==="image"&&b.imageDefaults)T="1x1";else if((b==null?void 0:b.type)==="video"&&b.videoDefaults){const z=Xn(h,(t==null?void 0:t.modelRef)||h,t==null?void 0:t.params);T=on(z.size||b.videoDefaults.size),C||(C=z.duration||b.videoDefaults.duration)}else if(u==="image")T="1x1";else if(u==="video"){const z=Xn(h,(t==null?void 0:t.modelRef)||h,t==null?void 0:t.params);T=on(z.size),C||(C=z.duration)}}!C&&u==="video"&&(C=Xn(h,(t==null?void 0:t.modelRef)||h,t==null?void 0:t.params).duration);const N=a.cleanText.trim();return{scenario:_,generationType:u,modelId:h,modelRef:(t==null?void 0:t.modelRef)||null,defaultModels:t==null?void 0:t.defaultModels,defaultModelRefs:t==null?void 0:t.defaultModelRefs,isModelExplicit:p,prompt:g,userInstruction:N,rawInput:e,count:A,size:T,duration:C,extraParams:R,parseResult:a,hasExtraContent:m,selection:n,knowledgeContextRefs:t==null?void 0:t.knowledgeContextRefs}}const es={id:Ze,name:"自动"},xo=os.map(e=>({id:e.id,name:e.name,isSystem:!0,mcpTool:e.mcpTool,outputType:e.outputType})),Ka=({value:e,onSelect:n,onSelectSkill:t,onAddSkill:d,disabled:r=!1})=>{const[l,a]=o.useState(!1),[m,u]=o.useState([]),[h,p]=o.useState([]),[_,I]=o.useState(""),[w,g]=o.useState(0),A=o.useRef(null),T=o.useRef(null),C=o.useCallback(async()=>{try{const D=(await Dn.getAllDirectories()).find(oe=>oe.name==="Skill");if(!D)return;const $=await Dn.getNoteMetasByDirectory(D.id),le=new Set(os.map(oe=>oe.id)),O=$.filter(oe=>!le.has(oe.id)).map(oe=>{var be;return{id:oe.id,name:oe.title,outputType:((be=oe.metadata)==null?void 0:be.outputType)||void 0}});u(O)}catch{}},[]),R=o.useCallback(async()=>{try{const S=await is.getAllExternalSkillsMeta(),D=new Set(os.map(le=>le.id)),$=S.filter(le=>!D.has(le.id)).map(le=>({id:le.id,name:le.name,isExternal:!0,source:le.source,outputType:le.outputType}));p($)}catch{}},[]);o.useEffect(()=>{if(l){C(),R(),I("");const D=[es,...xo,...h,...m].findIndex($=>$.id===e);g(D>=0?D:0),setTimeout(()=>{var $;return($=T.current)==null?void 0:$.focus()},50)}},[l,e]),o.useEffect(()=>{if(l&&A.current){const S=A.current.children[w];S&&S.scrollIntoView({block:"nearest"})}},[w,l]);const N=o.useCallback(S=>{S.preventDefault(),!r&&a(D=>!D)},[r]),b=o.useCallback(S=>{n(S.id),t==null||t(S),a(!1)},[n,t]),z=o.useCallback(S=>{S.stopPropagation(),a(!1),d()},[d]),P=[es,...xo,...h,...m],X=_.trim()?P.filter(S=>S.name.toLowerCase().includes(_.toLowerCase())||S.id.toLowerCase().includes(_.toLowerCase())):P,M=P.length>15,K=o.useCallback(S=>S==="Escape"?(a(!1),!0):S==="ArrowDown"?(g(D=>D<X.length-1?D+1:0),!0):S==="ArrowUp"?(g(D=>D>0?D-1:X.length-1),!0):S==="Enter"||S===" "||S==="Tab"?(w<X.length&&b(X[w]),!0):!1,[w,X,b]),Z=X.find(S=>S.id===e)||es;return c.jsx(cs,{isOpen:l,setIsOpen:a,disabled:r,openKeys:["Enter"," ","ArrowDown","ArrowUp"],onOpenKey:K,children:({containerRef:S,menuRef:D,menuStyle:$,handleTriggerKeyDown:le})=>c.jsxs("div",{className:"skill-dropdown",ref:S,children:[c.jsx(Qe,{content:`Skill: ${Z.name}`,showArrow:!1,children:c.jsxs("button",{className:`skill-dropdown__trigger ${l?"skill-dropdown__trigger--open":""}`,onMouseDown:N,onKeyDown:le,disabled:r,type:"button",children:[c.jsx("span",{className:"skill-dropdown__icon-prefix",children:c.jsx(Vs,{size:14})}),c.jsx("span",{className:"skill-dropdown__label",children:Z.name}),c.jsx(ds,{size:14,className:`skill-dropdown__chevron ${l?"skill-dropdown__chevron--open":""}`})]})}),l&&ls.createPortal(c.jsxs("div",{ref:D,className:`skill-dropdown__menu ${Rn}`,style:{...$,zIndex:us.DROPDOWN_PORTAL},onMouseDown:O=>O.stopPropagation(),onClick:O=>O.stopPropagation(),children:[c.jsxs("div",{className:"skill-dropdown__header",children:[c.jsx(Vs,{size:14}),c.jsx("span",{children:"Skill"})]}),M&&c.jsx("div",{className:"skill-dropdown__search",children:c.jsx("input",{ref:T,type:"text",className:"skill-dropdown__search-input",placeholder:"搜索 Skill...",value:_,onChange:O=>{I(O.target.value),g(0)},onMouseDown:O=>O.stopPropagation(),onKeyDown:O=>O.stopPropagation()})}),c.jsx("div",{ref:A,className:"skill-dropdown__list",children:X.map((O,oe)=>{const be=O.id===e,Me=oe===w;return c.jsxs("div",{className:`skill-dropdown__item ${be?"skill-dropdown__item--selected":""} ${Me?"skill-dropdown__item--highlighted":""}`,onClick:()=>b(O),onMouseEnter:()=>g(oe),children:[c.jsx("span",{className:"skill-dropdown__item-label",children:O.name}),O.outputType==="image"&&c.jsx(Co,{size:12,className:"skill-dropdown__item-image-icon"}),O.outputType==="video"&&c.jsx(To,{size:12,className:"skill-dropdown__item-image-icon"}),O.outputType==="ppt"&&c.jsx(Ar,{size:12,className:"skill-dropdown__item-image-icon"}),O.outputType==="audio"&&c.jsx(Dr,{size:12,className:"skill-dropdown__item-image-icon"}),O.isSystem&&c.jsx("span",{className:"skill-dropdown__item-badge",children:"系统"}),O.isExternal&&c.jsx("span",{className:"skill-dropdown__item-badge",children:"系统"}),be&&c.jsx(fs,{size:14,className:"skill-dropdown__item-check"})]},O.id)})}),c.jsx("div",{className:"skill-dropdown__divider"}),c.jsxs("div",{className:"skill-dropdown__add-btn",onClick:z,onMouseDown:O=>O.preventDefault(),children:[c.jsx(jr,{size:14}),c.jsx("span",{children:"添加 Skill"})]})]}),document.body)]})})},wo=["image","video","audio"];function Ya(e){if(e==="image"||e==="video"||e==="audio")return e}function mt(e){if(!e)return[];const n=Ya(e.outputType);if(n)return[n];if(e.outputType==="text")return[];const t=new Set,d=ha(e.mcpTool);d&&t.add(d);const r=[e.id,e.name,e.description,e.content].filter(Boolean).join(`
|
|
7
|
-
`);if(r)for(const l of wo)Xa(l).some(m=>r.includes(m))&&t.add(l);return wo.filter(l=>t.has(l))}function Xa(e){switch(e){case"image":return["generate_image","generate_grid_image","generate_photo_wall","generate_inspiration_board"];case"video":return["generate_video","generate_long_video"];case"audio":return["generate_audio"]}}var Ue=(e=>(e.VIDEO="视频创作",e.IMAGE="图片生成",e.MINDMAP="思维导图",e.FLOWCHART="流程图",e.PPT="PPT大纲",e.GRID="宫格图",e.SVG="SVG矢量图",e))(Ue||{});const rn=3,Za="data:image/svg+xml;utf8,"+encodeURIComponent(`
|
|
8
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 420 420">
|
|
9
|
-
<defs>
|
|
10
|
-
<linearGradient id="bg" x1="0" y1="0" x2="1" y2="1">
|
|
11
|
-
<stop offset="0" stop-color="#f8f4ff"/>
|
|
12
|
-
<stop offset="1" stop-color="#fff7ed"/>
|
|
13
|
-
</linearGradient>
|
|
14
|
-
<linearGradient id="accent" x1="0" y1="0" x2="1" y2="1">
|
|
15
|
-
<stop offset="0" stop-color="#a855f7"/>
|
|
16
|
-
<stop offset="1" stop-color="#f97316"/>
|
|
17
|
-
</linearGradient>
|
|
18
|
-
</defs>
|
|
19
|
-
<rect width="420" height="420" rx="34" fill="url(#bg)"/>
|
|
20
|
-
<rect x="38" y="46" width="344" height="316" rx="22" fill="#ffffff" opacity="0.95"/>
|
|
21
|
-
<g transform="translate(58 116)" stroke="#d8b4fe" stroke-width="3">
|
|
22
|
-
<rect width="86" height="72" rx="14" fill="#fff7ed"/>
|
|
23
|
-
<rect x="108" width="86" height="72" rx="14" fill="#f5f3ff"/>
|
|
24
|
-
<rect x="216" width="86" height="72" rx="14" fill="#fffbeb"/>
|
|
25
|
-
<rect y="92" width="86" height="72" rx="14" fill="#fef2f2"/>
|
|
26
|
-
<rect x="108" y="92" width="86" height="72" rx="14" fill="#eef2ff"/>
|
|
27
|
-
<rect x="216" y="92" width="86" height="72" rx="14" fill="#fff7ed"/>
|
|
28
|
-
<rect y="184" width="86" height="72" rx="14" fill="#f5f3ff"/>
|
|
29
|
-
<rect x="108" y="184" width="86" height="72" rx="14" fill="#fffbeb"/>
|
|
30
|
-
<rect x="216" y="184" width="86" height="72" rx="14" fill="#fef2f2"/>
|
|
31
|
-
</g>
|
|
32
|
-
<circle cx="101" cy="152" r="18" fill="#f97316"/>
|
|
33
|
-
<circle cx="209" cy="152" r="18" fill="#a855f7"/>
|
|
34
|
-
<circle cx="317" cy="152" r="18" fill="#f59e0b"/>
|
|
35
|
-
<circle cx="101" cy="244" r="18" fill="#ef4444"/>
|
|
36
|
-
<circle cx="209" cy="244" r="18" fill="#6366f1"/>
|
|
37
|
-
<circle cx="317" cy="244" r="18" fill="#fb923c"/>
|
|
38
|
-
<circle cx="101" cy="336" r="18" fill="#8b5cf6"/>
|
|
39
|
-
<circle cx="209" cy="336" r="18" fill="#eab308"/>
|
|
40
|
-
<circle cx="317" cy="336" r="18" fill="#f43f5e"/>
|
|
41
|
-
<path d="M356 78l8 10 12-20" fill="none" stroke="url(#accent)" stroke-width="7" stroke-linecap="round" stroke-linejoin="round"/>
|
|
42
|
-
</svg>`),qa="data:image/svg+xml;utf8,"+encodeURIComponent(`
|
|
43
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 420 420">
|
|
44
|
-
<defs>
|
|
45
|
-
<linearGradient id="bg" x1="0" y1="0" x2="1" y2="1">
|
|
46
|
-
<stop offset="0" stop-color="#eef5ff"/>
|
|
47
|
-
<stop offset="1" stop-color="#e7e2ff"/>
|
|
48
|
-
</linearGradient>
|
|
49
|
-
<linearGradient id="accent" x1="0" y1="0" x2="1" y2="1">
|
|
50
|
-
<stop offset="0" stop-color="#3b82f6"/>
|
|
51
|
-
<stop offset="1" stop-color="#8b5cf6"/>
|
|
52
|
-
</linearGradient>
|
|
53
|
-
</defs>
|
|
54
|
-
<rect width="420" height="420" rx="34" fill="url(#bg)"/>
|
|
55
|
-
<rect x="34" y="44" width="352" height="318" rx="22" fill="#ffffff" opacity="0.94"/>
|
|
56
|
-
<rect x="34" y="44" width="352" height="52" rx="22" fill="#e8edff"/>
|
|
57
|
-
<rect x="56" y="126" width="160" height="14" rx="7" fill="url(#accent)"/>
|
|
58
|
-
<rect x="56" y="164" width="274" height="12" rx="6" fill="#c7d2fe"/>
|
|
59
|
-
<rect x="56" y="192" width="220" height="12" rx="6" fill="#dbeafe"/>
|
|
60
|
-
<rect x="56" y="244" width="100" height="70" rx="12" fill="#eff6ff" stroke="#93c5fd"/>
|
|
61
|
-
<rect x="186" y="244" width="100" height="70" rx="12" fill="#f5f3ff" stroke="#a78bfa"/>
|
|
62
|
-
<rect x="316" y="244" width="52" height="70" rx="12" fill="#ecfeff" stroke="#67e8f9"/>
|
|
63
|
-
<circle cx="82" cy="279" r="14" fill="#3b82f6"/>
|
|
64
|
-
<circle cx="236" cy="279" r="14" fill="#8b5cf6"/>
|
|
65
|
-
<circle cx="342" cy="279" r="14" fill="#06b6d4"/>
|
|
66
|
-
<path d="M158 279h24M288 279h24" stroke="#94a3b8" stroke-width="8" stroke-linecap="round"/>
|
|
67
|
-
<rect x="56" y="334" width="312" height="10" rx="5" fill="#dbeafe"/>
|
|
68
|
-
</svg>`),Ja="data:image/svg+xml;utf8,"+encodeURIComponent(`
|
|
69
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 420 420">
|
|
70
|
-
<defs>
|
|
71
|
-
<linearGradient id="bg" x1="0" y1="0" x2="1" y2="1">
|
|
72
|
-
<stop offset="0" stop-color="#f0fdf4"/>
|
|
73
|
-
<stop offset="1" stop-color="#ecfeff"/>
|
|
74
|
-
</linearGradient>
|
|
75
|
-
<linearGradient id="lineA" x1="0" y1="0" x2="1" y2="1">
|
|
76
|
-
<stop offset="0" stop-color="#22c55e"/>
|
|
77
|
-
<stop offset="1" stop-color="#06b6d4"/>
|
|
78
|
-
</linearGradient>
|
|
79
|
-
</defs>
|
|
80
|
-
<rect width="420" height="420" rx="34" fill="url(#bg)"/>
|
|
81
|
-
<rect x="34" y="48" width="352" height="312" rx="22" fill="#ffffff" opacity="0.94"/>
|
|
82
|
-
<g fill="none" stroke="url(#lineA)" stroke-width="3" stroke-linecap="round">
|
|
83
|
-
<path d="M210 210C170 190 150 156 126 128"/>
|
|
84
|
-
<path d="M210 210C170 220 144 252 116 286"/>
|
|
85
|
-
<path d="M210 210C250 184 278 150 312 128"/>
|
|
86
|
-
<path d="M210 210C252 224 280 254 322 292"/>
|
|
87
|
-
<path d="M126 128C108 116 94 110 78 104"/>
|
|
88
|
-
<path d="M312 128C332 116 346 110 362 104"/>
|
|
89
|
-
<path d="M116 286C98 300 82 310 66 324"/>
|
|
90
|
-
<path d="M322 292C342 302 356 312 372 326"/>
|
|
91
|
-
</g>
|
|
92
|
-
<rect x="168" y="178" width="84" height="64" rx="18" fill="#ecfdf5" stroke="#22c55e" stroke-width="3"/>
|
|
93
|
-
<circle cx="210" cy="210" r="16" fill="#22c55e"/>
|
|
94
|
-
<rect x="76" y="98" width="98" height="36" rx="13" fill="#f0fdf4" stroke="#86efac"/>
|
|
95
|
-
<rect x="72" y="270" width="102" height="36" rx="13" fill="#eff6ff" stroke="#93c5fd"/>
|
|
96
|
-
<rect x="262" y="98" width="102" height="36" rx="13" fill="#ecfeff" stroke="#67e8f9"/>
|
|
97
|
-
<rect x="266" y="276" width="108" height="36" rx="13" fill="#f0fdfa" stroke="#5eead4"/>
|
|
98
|
-
<circle cx="96" cy="116" r="7" fill="#22c55e"/>
|
|
99
|
-
<circle cx="96" cy="288" r="7" fill="#3b82f6"/>
|
|
100
|
-
<circle cx="286" cy="116" r="7" fill="#06b6d4"/>
|
|
101
|
-
<circle cx="290" cy="294" r="7" fill="#14b8a6"/>
|
|
102
|
-
<rect x="116" y="112" width="42" height="7" rx="3.5" fill="#bbf7d0"/>
|
|
103
|
-
<rect x="116" y="284" width="44" height="7" rx="3.5" fill="#bfdbfe"/>
|
|
104
|
-
<rect x="306" y="112" width="42" height="7" rx="3.5" fill="#a5f3fc"/>
|
|
105
|
-
<rect x="310" y="290" width="46" height="7" rx="3.5" fill="#99f6e4"/>
|
|
106
|
-
</svg>`),yo=[{id:"grid-emoji",title:"智能拆分宫格图",description:"宫格图,风格统一",prompt:"生成16宫格猫咪表情包",category:Ue.GRID,imageUrl:Za,badgeColor:"badge--grid",skillId:"generate_grid_image"},{id:"ppt-outline",title:"生成PPT大纲",description:"用参考图片规划配图与页面提示词",prompt:"生成一份关于「AI 创作工作流」的 PPT 大纲;如果已上传参考图片,请将参考图片作为配图和视觉风格参考。",category:Ue.PPT,imageUrl:qa,badgeColor:"badge--ppt",skillId:"generate_ppt"},{id:"mindmap-project",title:"项目规划脑图",description:"快速生成结构化的思维导图,梳理项目计划",prompt:"创建一个关于「移动应用开发」的思维导图,包含需求分析、UI设计、前端开发、后端开发、测试上线等主要分支",category:Ue.MINDMAP,imageUrl:Ja,badgeColor:"badge--mindmap",skillId:"generate_mindmap"}],Do={[Ue.VIDEO]:{bg:"#fce7f3",text:"#be185d"},[Ue.IMAGE]:{bg:"#dbeafe",text:"#1d4ed8"},[Ue.MINDMAP]:{bg:"#dcfce7",text:"#15803d"},[Ue.FLOWCHART]:{bg:"#fef3c7",text:"#b45309"},[Ue.PPT]:{bg:"#dbeafe",text:"#1d4ed8"},[Ue.GRID]:{bg:"#f3e8ff",text:"#7c3aed"},[Ue.SVG]:{bg:"#e0e7ff",text:"#4338ca"}},Qa=({template:e,onClick:n})=>{const t=Do[e.category],d=r=>{r.preventDefault()};return c.jsxs("div",{className:"inspiration-card",onMouseDown:d,onClick:n,"data-track":`inspiration_click_${e.id}`,children:[c.jsxs("div",{className:"inspiration-card__image-wrapper",children:[c.jsx("img",{src:e.imageUrl,alt:e.title,className:"inspiration-card__image",loading:"lazy"}),c.jsx("span",{className:"inspiration-card__badge",style:{backgroundColor:t.bg,color:t.text},children:e.category}),c.jsx("div",{className:"inspiration-card__hover-overlay",children:c.jsx("div",{className:"inspiration-card__arrow",children:c.jsx(Nr,{size:16})})})]}),c.jsxs("div",{className:"inspiration-card__content",children:[c.jsx("h3",{className:"inspiration-card__title",children:e.title}),c.jsx("p",{className:"inspiration-card__description",children:e.description})]})]})},Io="aitu_hide_inspiration_board",ei=({isCanvasEmpty:e,onSelectPrompt:n,onOpenPromptTool:t,visible:d=!0,className:r=""})=>{const[l,a]=o.useState(0),[m,u]=o.useState(!1),[h,p]=o.useState("board"),[_,I]=o.useState(null);o.useEffect(()=>{localStorage.getItem(Io)==="true"&&u(!0)},[]);const w=Math.ceil(yo.length/rn),g=w>1,A=yo.slice(l*rn,(l+1)*rn),T=o.useCallback(M=>{M.preventDefault(),M.stopPropagation(),a(K=>(K-1+w)%w)},[w]),C=o.useCallback(M=>{M.preventDefault(),M.stopPropagation(),a(K=>(K+1)%w)},[w]),R=o.useCallback(M=>{I(M),p("guide"),n({prompt:M.prompt,modelType:"agent",skillId:M.skillId,templateId:M.id,title:M.title,category:M.category})},[n]),N=o.useCallback(M=>{M.preventDefault(),M.stopPropagation(),p("board")},[]),b=o.useCallback(M=>{M.preventDefault(),M.stopPropagation(),p("board"),I(null),u(!0),localStorage.setItem(Io,"true")},[]),z=o.useCallback(M=>{M.preventDefault(),M.stopPropagation(),qe.info("请点击右下角真正的发送按钮开始生成")},[]);if(!e||!d||m)return null;const P=h==="guide"&&_,X=_?Do[_.category]:null;return c.jsxs("div",{className:`inspiration-board ${P?"inspiration-board--guide":""} ${r}`,"data-testid":"inspiration-board",children:[c.jsxs("div",{className:"inspiration-board__header",children:[P?c.jsxs("div",{className:"inspiration-board__guide-title-group",children:[c.jsxs("button",{className:"inspiration-board__back-btn",onMouseDown:M=>M.preventDefault(),onClick:N,"aria-label":"返回灵感创意","data-testid":"inspiration-guide-back","data-track":"inspiration_click_guide_back",children:[c.jsx(Rr,{size:15}),c.jsx("span",{children:"返回"})]}),c.jsx("h3",{className:"inspiration-board__title",children:"确认后发送"})]}):c.jsx("h3",{className:"inspiration-board__title",children:"灵感创意"}),c.jsx(Qe,{content:"不再提示",showArrow:!1,children:c.jsxs("button",{className:"inspiration-board__hide-btn",onClick:b,onMouseDown:M=>M.preventDefault(),"data-track":"inspiration_click_hide",children:[c.jsx(zr,{size:14}),c.jsx("span",{children:"不再提示"})]})}),!P&&t&&c.jsx(Qe,{content:"提示词工具",showArrow:!1,children:c.jsxs("button",{className:"inspiration-board__prompt-btn",onClick:t,onMouseDown:M=>M.preventDefault(),"data-track":"inspiration_click_prompt_tool",children:[c.jsx(Or,{size:14}),c.jsx("span",{children:"提示词"})]})}),!P&&g&&c.jsxs("div",{className:"inspiration-board__pagination",children:[c.jsxs("span",{className:"inspiration-board__page-indicator",children:[l+1," / ",w]}),c.jsxs("div",{className:"inspiration-board__nav-buttons",children:[c.jsx("button",{className:"inspiration-board__nav-btn",onMouseDown:M=>M.preventDefault(),onClick:T,"aria-label":"上一页","data-track":"inspiration_click_prev",children:c.jsx(Wr,{size:16})}),c.jsx("button",{className:"inspiration-board__nav-btn",onMouseDown:M=>M.preventDefault(),onClick:C,"aria-label":"下一页","data-track":"inspiration_click_next",children:c.jsx(Lr,{size:16})})]})]})]}),P?c.jsx("div",{className:"inspiration-board__guide","data-testid":"inspiration-send-guide",children:c.jsxs("div",{className:"inspiration-board__guide-main",children:[c.jsxs("div",{className:"inspiration-board__guide-summary",children:[c.jsx("img",{src:_.imageUrl,alt:_.title,className:"inspiration-board__guide-image",loading:"lazy"}),c.jsxs("div",{className:"inspiration-board__guide-content",children:[X&&c.jsx("span",{className:"inspiration-board__guide-badge",style:{backgroundColor:X.bg,color:X.text},children:_.category}),c.jsx("h4",{className:"inspiration-board__guide-name",children:_.title}),c.jsx("p",{className:"inspiration-board__guide-description",children:_.description})]})]}),c.jsxs("div",{className:"inspiration-board__guide-action",children:[c.jsxs("div",{className:"inspiration-board__guide-cue",children:[c.jsx(Br,{className:"inspiration-board__guide-pointer",size:26,"aria-hidden":"true"}),c.jsx(Qe,{content:"请点击右下角真正的发送按钮",showArrow:!1,children:c.jsx("button",{type:"button",className:"inspiration-board__guide-send-preview",onClick:z,onMouseDown:M=>M.preventDefault(),"aria-label":"示意发送按钮",children:c.jsx(rs,{size:17})})})]}),c.jsxs("div",{className:"inspiration-board__guide-tip",children:[c.jsx(rs,{size:16}),c.jsx("span",{children:"下一步:点击发送按钮开始生成"})]})]})]})}):c.jsxs("div",{className:"inspiration-board__grid",children:[A.map(M=>c.jsx(Qa,{template:M,onClick:()=>R(M)},M.id)),A.length<rn&&Array.from({length:rn-A.length}).map((M,K)=>c.jsx("div",{className:"inspiration-card inspiration-card--placeholder"},`placeholder-${K}`))]})]})},gt=[{value:"image",label:"图片",icon:c.jsx(Co,{size:14}),zh:"图片",en:"Image"},{value:"video",label:"视频",icon:c.jsx(To,{size:14}),zh:"视频",en:"Video"},{value:"audio",label:"音频",icon:c.jsx(Hr,{size:14}),zh:"音频",en:"Audio"},{value:"text",label:"文本",icon:c.jsx(Gr,{size:14}),zh:"文本",en:"Text"},{value:"agent",label:"Agent",icon:c.jsx(Ur,{size:14}),zh:"Agent",en:"Agent"}],ti=({value:e,onSelect:n,disabled:t=!1})=>{const[d,r]=o.useState(!1),{language:l}=ps(),[a,m]=o.useState(0),u=o.useRef(null);o.useEffect(()=>{if(d){const w=gt.findIndex(g=>g.value===e);m(w>=0?w:0)}},[d,e]),o.useEffect(()=>{if(d&&u.current){const w=u.current.children[a];w&&w.scrollIntoView({block:"nearest"})}},[a,d]);const h=o.useCallback(w=>{w.preventDefault(),!t&&r(g=>!g)},[t]),p=o.useCallback(w=>{n(w),r(!1)},[n]),_=o.useCallback(w=>w==="Escape"?(r(!1),!0):w==="ArrowDown"?(m(g=>g<gt.length-1?g+1:0),!0):w==="ArrowUp"?(m(g=>g>0?g-1:gt.length-1),!0):w==="Enter"||w===" "||w==="Tab"?(p(gt[a].value),!0):!1,[a,p]),I=gt.find(w=>w.value===e)||gt[0];return c.jsx(cs,{isOpen:d,setIsOpen:r,disabled:t,openKeys:["Enter"," ","ArrowDown","ArrowUp"],onOpenKey:_,children:({containerRef:w,menuRef:g,menuStyle:A,handleTriggerKeyDown:T})=>c.jsxs("div",{className:"generation-type-dropdown",ref:w,children:[c.jsx(Qe,{content:`${l==="zh"?"生成类型":"Type"}: ${l==="zh"?I.zh:I.en} (↑↓ Tab)`,showArrow:!1,children:c.jsxs("button",{className:`generation-type-dropdown__trigger ${d?"generation-type-dropdown__trigger--open":""}`,onMouseDown:h,onKeyDown:T,disabled:t,type:"button",children:[c.jsx("span",{className:"generation-type-dropdown__icon-prefix",children:I.icon}),c.jsx("span",{className:"generation-type-dropdown__label",children:l==="zh"?I.zh:I.en}),c.jsx(ds,{size:14,className:`generation-type-dropdown__chevron ${d?"generation-type-dropdown__chevron--open":""}`})]})}),d&&ls.createPortal(c.jsxs("div",{ref:g,className:`generation-type-dropdown__menu ${Rn}`,style:{...A,zIndex:us.DROPDOWN_PORTAL},onMouseDown:C=>C.stopPropagation(),onClick:C=>C.stopPropagation(),children:[c.jsxs("div",{className:"generation-type-dropdown__header",children:[c.jsx(Fr,{size:14}),c.jsx("span",{children:l==="zh"?"生成类型 (↑↓ Tab)":"Generation type (↑↓ Tab)"})]}),c.jsx("div",{ref:u,className:"generation-type-dropdown__list",children:gt.map((C,R)=>{const N=C.value===e,b=R===a;return c.jsxs("div",{className:`generation-type-dropdown__item ${N?"generation-type-dropdown__item--selected":""} ${b?"generation-type-dropdown__item--highlighted":""}`,onClick:()=>p(C.value),onMouseEnter:()=>m(R),children:[c.jsx("span",{className:"generation-type-dropdown__item-icon",children:C.icon}),c.jsx("span",{className:"generation-type-dropdown__item-label",children:l==="zh"?C.zh:C.en}),N&&c.jsx(fs,{size:14,className:"generation-type-dropdown__item-check"})]},C.value)})})]}),document.body)]})})},an=[1,2,3,4,5,10,20],ni=({value:e,onSelect:n,disabled:t=!1,isOpen:d,onOpenChange:r})=>{const{value:l,setValue:a}=$r({controlledValue:d,defaultValue:!1,onChange:r}),{language:m}=ps(),[u,h]=o.useState(0),p=o.useRef(null);o.useEffect(()=>{if(l){const g=an.indexOf(e);h(g>=0?g:0)}},[l,e]),o.useEffect(()=>{if(l&&p.current){const g=p.current.children[u];g&&g.scrollIntoView({block:"nearest"})}},[u,l]);const _=o.useCallback(g=>{g.preventDefault(),!t&&a(!l)},[t,l,a]),I=o.useCallback(g=>{n(g),a(!1)},[n]),w=o.useCallback(g=>g==="Escape"?(a(!1),!0):g==="ArrowDown"?(h(A=>A<an.length-1?A+1:0),!0):g==="ArrowUp"?(h(A=>A>0?A-1:an.length-1),!0):g==="Enter"||g===" "||g==="Tab"?(I(an[u]),!0):!1,[u,I]);return c.jsx(cs,{isOpen:l,setIsOpen:a,disabled:t,openKeys:["Enter"," ","ArrowDown","ArrowUp"],onOpenKey:w,children:({containerRef:g,menuRef:A,menuStyle:T,handleTriggerKeyDown:C})=>c.jsxs("div",{className:"count-dropdown",ref:g,children:[c.jsx(Qe,{content:`${m==="zh"?"生成数量":"Count"}: ${e} (↑↓ Tab)`,showArrow:!1,children:c.jsxs("button",{className:`count-dropdown__trigger ${l?"count-dropdown__trigger--open":""}`,onMouseDown:_,onKeyDown:C,disabled:t,type:"button",children:[c.jsxs("span",{className:"count-dropdown__label",children:[e,m==="zh"?"个":""]}),c.jsx(ds,{size:14,className:`count-dropdown__chevron ${l?"count-dropdown__chevron--open":""}`})]})}),l&&ls.createPortal(c.jsxs("div",{ref:A,className:`count-dropdown__menu ${Rn}`,style:{...T,zIndex:us.DROPDOWN_PORTAL},onMouseDown:R=>R.stopPropagation(),onClick:R=>R.stopPropagation(),children:[c.jsx("div",{className:"count-dropdown__header",children:c.jsx("span",{children:m==="zh"?"生成数量 (↑↓ Tab)":"Count (↑↓ Tab)"})}),c.jsx("div",{ref:p,className:"count-dropdown__list",children:an.map((R,N)=>{const b=R===e,z=N===u;return c.jsxs("div",{className:`count-dropdown__item ${b?"count-dropdown__item--selected":""} ${z?"count-dropdown__item--highlighted":""}`,onClick:()=>I(R),onMouseEnter:()=>h(N),children:[c.jsxs("span",{className:"count-dropdown__item-label",children:[R,m==="zh"?"个":R>1?" items":" item"]}),b&&c.jsx(fs,{size:14,className:"count-dropdown__item-check"})]},R)})})]}),document.body)]})})},jo=["right","bottom","left","top"],En=4;function si(e,n,t,d,r=32){const l=d<=2?d:d<=4?2:3,a=Math.floor(t/l),m=t%l;return[e[0]+m*(n.width+r),e[1]+a*(n.height+r)]}function No(e,n){const{ignoreElementIds:t=[],ignoreTypes:d=["workzone"],extraOccupiedRects:r=[]}=n;return[...e.children.filter(oi).filter(l=>!d.includes(l.type??"")&&!t.includes(l.id??"")).map(l=>({...jn.getRectangleByPoints(l.points),id:l.id,type:l.type})),...r]}function oi(e){return typeof e=="object"&&e!==null&&Array.isArray(e.points)&&e.points.length===2}function Ro(e,n,t){return e.x<n.x+n.width+t&&e.x+e.width+t>n.x&&e.y<n.y+n.height+t&&e.y+e.height+t>n.y}function ri(e,n,t,d){const r=[e];for(let l=1;l<=d;l+=1)r.push([e[0]+n*l,e[1]],[e[0],e[1]+t*l],[e[0]+n*l,e[1]+t*l],[e[0]-n*l,e[1]],[e[0]-n*l,e[1]+t*l],[e[0],e[1]-t*l],[e[0]+n*l,e[1]-t*l],[e[0]-n*l,e[1]-t*l]);return r}function ai(e,n,t,d,r){const l=Math.max(r,32),a=Math.max(Math.round(Math.min(n.width,n.height)*.16),28),m=Math.max(Math.round(Math.min(n.width,n.height)*.12),18),u=n.width+a,h=n.height+a,p=[];for(let _=0;_<t;_+=1){const I=Math.floor(_/En),w=_%En,g=Math.min(En,t-I*En),A=w-(g-1)/2,T=e.x+e.width/2-n.width/2,C=e.y+e.height/2-n.height/2,R=Math.abs(A)*m;let N=T,b=C;switch(d){case"right":N=e.x+e.width+l+I*u+R,b=C+A*(n.height+a);break;case"left":N=e.x-l-n.width-I*u-R,b=C+A*(n.height+a);break;case"top":N=T+A*(n.width+a),b=e.y-l-n.height-I*h-R;break;case"bottom":default:N=T+A*(n.width+a),b=e.y+e.height+l+I*h+R;break}p.push([Math.round(N),Math.round(b)])}return p}function _o(e,n,t,d,r){return e.reduce((a,m)=>{const u={x:m[0],y:m[1],width:n.width,height:n.height};return a+t.filter(h=>Ro(u,h,d)).length},0)*1e3+jo.indexOf(r)*10}function ii(e,n,t,d,r){var h;const{gap:l=40,padding:a=16}=r,m=No(e,r),u=jo.map(p=>({side:p,positions:ai(n,t,d,p,l)}));return u.sort((p,_)=>_o(p.positions,t,m,a,p.side)-_o(_.positions,t,m,a,_.side)),((h=u[0])==null?void 0:h.positions)??[]}function ci(e,n,t,d,r={}){const{frameRect:l,extraOccupiedRects:a=[],...m}=r,u={...m,extraOccupiedRects:a},h=l?ii(e,l,t,d,u):Array.from({length:d},(_,I)=>si(n,t,I,d,u.gap)),p=[...a];return h.map(_=>{const I=li(e,_,t,{...u,extraOccupiedRects:p});return p.push({x:I[0],y:I[1],width:t.width,height:t.height}),I})}function li(e,n,t,d={}){const{gap:r=40,padding:l=16,maxSearchRadius:a=6}=d,m=No(e,d),u=t.width+r,h=t.height+r,p=ri(n,u,h,a);for(const _ of p){const I={x:_[0],y:_[1],width:t.width,height:t.height};if(!m.some(g=>Ro(I,g,l)))return _}return[n[0],n[1]+h*(a+1)]}function yt(e){return typeof e=="string"&&e.trim()?e.trim():null}function di(e){return e==="image"||e==="video"||e==="audio"||e==="text"||e==="agent"}function ui(e){if(!e||typeof e!="object")return!1;const n=e;return typeof n.modelId=="string"&&n.modelId.trim().length>0&&(n.profileId===null||typeof n.profileId=="string")&&(n.providerIdHint===null||typeof n.providerIdHint=="string")&&(n.vendorHint===null||typeof n.vendorHint=="string")&&typeof n.updatedAt=="number"&&Number.isFinite(n.updatedAt)}function ms(){try{const e=window.localStorage.getItem(as);if(!e)return{};const n=JSON.parse(e);if(!n||typeof n!="object")return{};const t={};return Object.entries(n).forEach(([d,r])=>{di(d)&&ui(r)&&(t[d]={modelId:r.modelId.trim(),profileId:yt(r.profileId),providerIdHint:yt(r.providerIdHint),vendorHint:yt(r.vendorHint),updatedAt:r.updatedAt})}),t}catch{return{}}}function zo(e){try{if(!Object.values(e).some(Boolean)){window.localStorage.removeItem(as);return}window.localStorage.setItem(as,JSON.stringify(e))}catch{}}function fi(e){const n=ms();return n[e]?n[e]||null:e==="agent"&&n.text||null}function bo(e,n){var r;const t=yt(n.modelId);if(!t){Oo(e);return}const d=ms();d[e]={modelId:t,profileId:yt((r=n.modelRef)==null?void 0:r.profileId),providerIdHint:yt(n.providerIdHint),vendorHint:yt(n.vendorHint),updatedAt:Date.now()},zo(d)}function Oo(e){const n=ms();n[e]&&(delete n[e],zo(n))}function nt(e,n,t,d){var l;const r=e.metadata||{};return{id:e.id,name:e.name,generationType:e.generationType,prompt:r.prompt||((l=n==null?void 0:n.aiContext)==null?void 0:l.finalPrompt)||"",aiAnalysis:e.aiAnalysis,count:r.count,createdAt:e.createdAt,status:e.status,steps:e.steps.map(a=>({id:a.id,description:a.description,status:a.status,mcp:a.mcp,args:a.args,result:a.result,error:a.error,duration:a.duration,options:a.options})),retryContext:n,postProcessingStatus:t,insertedCount:d}}const pi=new Set(["generate_image","generate_video","generate_long_video","generate_audio","generate_text"]);function hi(e,n){return e==="generate_image"?"image":e==="generate_video"||e==="generate_long_video"?"video":e==="generate_audio"?"audio":e==="generate_text"?"text":n.scenarioType==="skill_flow"||n.generationType==="agent"?"agent":n.generationType==="image"||n.generationType==="video"||n.generationType==="audio"||n.generationType==="text"?n.generationType:"agent"}function mi(e,n){const t=typeof n.args.prompt=="string"?n.args.prompt.trim():e.metadata.prompt.trim(),d=(e.metadata.rawInput||e.metadata.userInstruction||e.metadata.prompt||t).trim().slice(0,2e3),r=e.scenarioType==="skill_flow"?e.name.trim():void 0,l=hi(n.mcp,e),a=hs(e.metadata.knowledgeContextRefs);return{initialPrompt:d,sentPrompt:t.slice(0,2e3),category:l,skillId:e.skillId,skillName:r,tags:[l,r].filter(Boolean),knowledgeContextRefs:a.length>0?a:void 0}}function An(e,n){const t=hs(e.metadata.knowledgeContextRefs),d=t.length>0&&pi.has(n.mcp)&&!n.args.knowledgeContextRefs?{...n.args,knowledgeContextRefs:t}:n.args;return d.promptMeta||!["generate_image","generate_video","generate_long_video","generate_audio","generate_text"].includes(n.mcp)?{...n,args:d}:{...n,args:{...d,promptMeta:mi(e,n)}}}let vo=!1;vo||(ya(),za(),is.initialize().catch(e=>{console.warn("[AIInputBar] 外部 Skill 服务初始化失败(非致命):",e)}),vo=!0);function Wo(e){return e.selectionKey||(e.sourceProfileId?`${e.sourceProfileId}::${e.id}`:e.id)}function Ge(e,n){return n!=null&&n.profileId?`${n.profileId}::${e}`:e}function $e(e){return e?wt(e.sourceProfileId||null,e.id):null}function ts(e){return e<=0?"0":e<=20?"1-20":e<=100?"21-100":e<=300?"101-300":e<=800?"301-800":"800+"}const gi=1,Lo=4,xi=6,wi=1.5;function ko(e,n){const t=window.getComputedStyle(e),d=Number.parseFloat(t.fontSize)||15,r=Number.parseFloat(t.lineHeight)||d*wi,l=Number.parseFloat(t.paddingTop)+Number.parseFloat(t.paddingBottom),a=Number.parseFloat(t.borderTopWidth)+Number.parseFloat(t.borderBottomWidth);return Math.ceil(r*n+l+a)}function yi(e,n){if(!e)return;if(!n){e.style.height="",e.style.overflowY="";return}const t=ko(e,Lo),d=ko(e,xi);e.style.height="auto";const r=e.scrollHeight,l=Math.min(Math.max(r,t),d);e.style.height=`${l}px`,e.style.overflowY=r>d?"auto":"hidden"}function Ie(e,n,t){if(!n)return;const d=Ge(n,t),r=(t==null?void 0:t.profileId)||null;return e.find(l=>Wo(l)===d)||e.find(l=>l.id===n&&(l.sourceProfileId||null)===r)||(r===null?e.find(l=>l.id===n&&!l.sourceProfileId):void 0)||e.find(l=>l.id===n)}function Ii(e,n){return e==="agent"&&n==="text"?"agent":n}function _i(e){if(!e)return!1;const n=e.toLowerCase();return n.includes("#video")?!0:[".mp4",".webm",".mov",".avi",".mkv",".m4v",".flv",".wmv"].some(d=>n.includes(d))}const Bo=Po.memo(({language:e,onSelectionChange:n,externalBoardRef:t,onCanvasEmptyChange:d,isDataReady:r,onFrameSelected:l})=>{const a=aa(),m=o.useRef(a);m.current=a,o.useEffect(()=>(ro(a),ao(a),io(a),lo(a),mo.setBoard(a),t&&(t.current=a),()=>{ro(null),ao(null),io(null),lo(null),mo.setBoard(null),t&&(t.current=null)}),[a,t]);const u=o.useRef(d);u.current=d,o.useEffect(()=>{if(!a||!u.current||!r)return;const I=setInterval(()=>{var g;const w=a.children||[];(g=u.current)==null||g.call(u,w.length===0)},500);return()=>{clearInterval(I)}},[a,r]);const h=o.useRef(n);h.current=n;const p=o.useRef(l);return p.current=l,o.useEffect(()=>{const _=async()=>{var A,T,C,R;const w=m.current;if(!w)return;const g=Eo(w);if(g.length===1&&Ao(g[0])){const N=g[0],b=jn.getRectangleByPoints(N.points);(A=p.current)==null||A.call(p,{id:N.id,width:b.width,height:b.height})}else(T=p.current)==null||T.call(p,null);if(g.length===0){h.current([]);return}try{const N=await ia(w),b=[];N.graphicsImage&&b.push({url:N.graphicsImage,name:e==="zh"?"图形元素":"Graphics",type:"graphics",width:(C=N.graphicsImageDimensions)==null?void 0:C.width,height:(R=N.graphicsImageDimensions)==null?void 0:R.height});for(const z of N.remainingImages){const P=z.url||"",X=_i(P);b.push({url:P,name:z.name||(X?`video-${Date.now()}`:`image-${Date.now()}`),type:X?"video":"image",width:z.width,height:z.height})}N.remainingText&&N.remainingText.trim()&&b.push({type:"text",text:N.remainingText.trim(),name:e==="zh"?"文字内容":"Text Content"}),h.current(b)}catch(N){console.error("Failed to process selected content:",N),h.current([])}};_();const I=()=>{setTimeout(_,50)};return document.addEventListener("mouseup",I),document.addEventListener(no,_),()=>{document.removeEventListener("mouseup",I),document.removeEventListener(no,_)}},[e]),null});Bo.displayName="SelectionWatcher";const Fo=Po.memo(({className:e,isDataReady:n,onEnableToolWindows:t,onEnableRuntime:d})=>{const{language:r}=ps(),l=Tn("image"),a=Tn("video"),m=Tn("audio"),u=Tn("text"),h=Vr(),p=la(),{setActiveSelections:_}=Kr(),{addHistory:I}=So(),{addAsset:w}=Yr(),g=o.useRef(h.sendWorkflowMessage);g.current=h.sendWorkflowMessage;const A=o.useRef(h.updateWorkflowMessage);A.current=h.updateWorkflowMessage;const T=o.useRef(h.appendAgentLog);T.current=h.appendAgentLog;const C=o.useRef(h.updateThinkingContent);C.current=h.updateThinkingContent;const R=o.useRef(h.setSelectedContent);R.current=h.setSelectedContent;const N=o.useRef(h.registerRetryHandler);N.current=h.registerRetryHandler;const b=o.useRef(null),z=o.useRef([]),P=o.useRef(null),X=Pa(),M=o.useCallback((s,i,f)=>{if(!s)return;const x=z.current,v=(f!=null&&f.workflowId&&(f!=null&&f.batchId)&&typeof f.batchIndex=="number"?pt.getAnchorByBatchSlot(s,{workflowId:f.workflowId,batchId:f.batchId,batchIndex:f.batchIndex}):null)||(f!=null&&f.workflowId?pt.getAnchorByWorkflowId(s,f.workflowId):null)||(x[0]?pt.getAnchorById(s,x[0]):null);if(!v)return;const E=v.taskIds.includes(i)?v.taskIds:[...v.taskIds,i];pt.updateAnchor(s,v.id,{taskIds:E,primaryTaskId:v.primaryTaskId||i})},[]),K=o.useCallback((s,i,f)=>{const x=z.current;x.length===0||!s||x.forEach(v=>{pt.updateAnchor(s,v,Zn(i,f))})},[]),Z=o.useCallback(s=>{const i=z.current;i.length===0||!s||(i.forEach(f=>{pt.removeAnchor(s,f)}),z.current=[])},[]),S=o.useCallback((s,i)=>{const f=fi(s);if(!f)return;const x=Ie(i,f.modelId,wt(f.profileId,f.modelId));if(x)return x;Oo(s)},[]),D=o.useCallback((s,i)=>{const f=S(s,i);if(f)return f;const v=Dt(s==="video"?"video":s==="audio"?"audio":s==="text"||s==="agent"?"text":"image"),E=Ie(i,v.modelId,wt(v.profileId,v.modelId));if(E)return E;const G=s==="video"?Rt():s==="audio"?zt():s==="text"||s==="agent"?ss():xt();return Ie(i,G,null)||i[0]},[S]),$=X.generationType,O=D($,$==="video"?a:$==="audio"?m:$==="text"||$==="agent"?u:l)||Je(X.selectedModel)||Je($==="video"?Rt():$==="audio"?zt():$==="text"||$==="agent"?ss():xt()),oe=D("image",l)||Je(xt()),be=D("video",a)||Je(Rt()),Me=D("audio",m)||Je(zt()),It=Dt("image"),_t=(oe==null?void 0:oe.id)||It.modelId||xt(),gs=$e(oe)||wt(It.profileId,It.modelId),xs=Ge((O==null?void 0:O.id)||_t,$e(O)||gs),ws=$==="agent"?{}:Qn($,(O==null?void 0:O.id)||_t,xs,X.selectedParams),[ge,st]=o.useState(""),[Ho,ln]=o.useState(!1),[Go,Uo]=o.useState(!1),[zn,On]=o.useState([]),[Wt,bt]=o.useState([]),[ot,Wn]=o.useState([]),[Re,rt]=o.useState(!1),Ve=o.useRef(!1),we=o.useRef(null),[Lt,at]=o.useState(!1),[$o,Vo]=o.useState(null),[y,Ke]=o.useState($),[fe,dn]=o.useState(X.selectedSkillId||Ze),[W,ys]=o.useState((O==null?void 0:O.id)||_t),[L,Is]=o.useState($e(O)||gs),[ze,_s]=o.useState((oe==null?void 0:oe.id)||xt()),[Ce,bs]=o.useState($e(oe)),[Oe,vs]=o.useState((be==null?void 0:be.id)||Rt()),[Te,ks]=o.useState($e(be)),[We,Ss]=o.useState((Me==null?void 0:Me.id)||zt()),[Pe,Ms]=o.useState($e(Me)),[it,Ye]=o.useState([]),un=o.useMemo(()=>{if(y!=="image"||Ie(l,W,L))return l;const i=ht("image",W,L);return i?[i,...l]:l},[y,l,W,L]),fn=o.useMemo(()=>{if(y!=="video"||Ie(a,W,L))return a;const i=ht("video",W,L);return i?[i,...a]:a},[y,W,L,a]),pn=o.useMemo(()=>{if(y!=="audio"||Ie(m,W,L))return m;const i=ht("audio",W,L);return i?[i,...m]:m},[m,y,W,L]),hn=o.useMemo(()=>{if(y!=="text"&&y!=="agent"||Ie(u,W,L))return u;const i=ht("text",W,L);return i?[i,...u]:u},[y,W,L,u]),Bt=o.useMemo(()=>{if(Ie(l,ze,Ce))return l;const i=ht("image",ze,Ce);return i?[i,...l]:l},[l,ze,Ce]),Ft=o.useMemo(()=>{if(Ie(a,Oe,Te))return a;const i=ht("video",Oe,Te);return i?[i,...a]:a},[Oe,Te,a]),Ht=o.useMemo(()=>{if(Ie(m,We,Pe))return m;const i=ht("audio",We,Pe);return i?[i,...m]:m},[m,We,Pe]),[Ee,mn]=o.useState(()=>{if($==="agent")return{};const s=(O==null?void 0:O.id)||_t,i=Ks(s).find(f=>f.id==="size");return{...ws,...s.startsWith("mj")||!i?{}:{size:ws.size||Ys(s)}}}),Gt=o.useRef(Ee),Cs=o.useRef($==="agent"?"agent":`${$}:${xs}`);o.useEffect(()=>{Gt.current=Ee},[Ee]);const[Ut,Ts]=o.useState(X.selectedCount),[Ps,Ln]=o.useState(!1),[Es,Bn]=o.useState(!1),[As,Fn]=o.useState(!1),ct=o.useRef(null),Ko=o.useCallback(s=>{Ln(s),s||(ct.current=null)},[]),Yo=o.useCallback(s=>{Bn(s),s||(ct.current=null)},[]),Xo=o.useCallback(s=>{Fn(s),s||(ct.current=null)},[]),[Ds,$t]=o.useState(!1),ie=o.useMemo(()=>[...Wt,...zn],[Wt,zn]),lt=o.useMemo(()=>({invalidFile:r==="zh"?"请上传图片文件":"Please upload image files",fileTooLarge:r==="zh"?"图片大小不能超过 25MB":"Image size cannot exceed 25MB",loadFailed:r==="zh"?"加载图片失败":"Failed to load image",compressionFailed:r==="zh"?"图片压缩失败":"Image compression failed",compressing:s=>r==="zh"?`正在压缩图片 (${s.toFixed(1)}MB)...`:`Compressing image (${s.toFixed(1)}MB)...`,compressed:(s,i)=>r==="zh"?`压缩完成: ${s.toFixed(1)}MB → ${i.toFixed(1)}MB`:`Compressed: ${s.toFixed(1)}MB → ${i.toFixed(1)}MB`}),[r]);o.useEffect(()=>{const s=y==="video"?fn:y==="audio"?pn:y==="text"||y==="agent"?hn:un,f=Ie(s,W,L)||D(y,s);if(f){const x=Ge(W,L),v=Wo(f);x!==v&&(ys(f.id),Is($e(f)))}y!=="agent"&&dn(Ze),(y==="agent"||y==="text"||y==="audio")&&Ts(1)},[pn,y,un,D,W,L,hn,fn]),o.useEffect(()=>{const s=(i,f,x,v,E,G)=>{if(Ie(f,x,v))return;const F=D(i,f);F&&(E(F.id),G($e(F)))};s("image",Bt,ze,Ce,_s,bs),s("video",Ft,Oe,Te,vs,ks),s("audio",Ht,We,Pe,Ss,Ms)},[D,We,Pe,ze,Ce,Oe,Te,Ht,Bt,Ft]);const gn=o.useMemo(()=>y==="video"?fn:y==="audio"?pn:y==="text"||y==="agent"?hn:un,[pn,y,un,hn,fn]);o.useEffect(()=>{let s=!1;return(async()=>{var G;if(y!=="agent"||fe===Ze){Ye([]);return}const f=vn(fe);if(f){Ye(mt(f));return}const x=Zs(fe);if(x){Ye(mt(x));return}const v=await is.getSkillById(fe);if(s)return;if(v){Ye(mt(v));return}const E=await Dn.getNoteById(fe);s||Ye(E?mt({id:E.id,name:E.title,content:E.content,outputType:(G=E.metadata)==null?void 0:G.outputType}):[])})().catch(()=>{s||Ye([])}),()=>{s=!0}},[y,fe]);const Vt=o.useMemo(()=>{var f;if(y==="agent")return[];if(y==="video")return Xr(W,L||W,Ee);const s=Ks(W);return y!=="audio"?s:(Ee.sunoAction||((f=s.find(x=>x.id==="sunoAction"))==null?void 0:f.defaultValue)||"music")==="lyrics"?s.filter(x=>x.id==="sunoAction"||x.id==="mv"||x.id==="title"||x.id==="tags"):s},[y,W,L,Ee]);o.useEffect(()=>{if(!Lt)return;const s=i=>{const f=i.target;wn.current&&!wn.current.contains(f)&&at(!1)};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[Lt]),o.useEffect(()=>()=>{we.current&&clearTimeout(we.current),Ve.current=!1},[]),o.useEffect(()=>{const s=i=>{var f;((f=i.detail)==null?void 0:f.type)!=="image"&&(we.current&&(clearTimeout(we.current),we.current=null),Ve.current=!1,rt(!1))};return window.addEventListener("ai-generation-complete",s),()=>{window.removeEventListener("ai-generation-complete",s)}},[]),o.useEffect(()=>{const s=Mo.observeTaskUpdates().subscribe(i=>{var F,q;const f=i.task,x=p.getWorkflow();if(!x)return;const v=x.steps.find(U=>{const ee=U.result;return(ee==null?void 0:ee.taskId)===f.id});if(!v)return;let E=v.status,G=v.result,Q=v.error;switch(f.status){case Nt.PENDING:case Nt.PROCESSING:E="running";break;case Nt.COMPLETED:E="completed",G={...typeof G=="object"?G:{},taskId:f.id,result:f.result};break;case Nt.FAILED:E="failed",Q=((F=f.error)==null?void 0:F.message)||"任务执行失败";break;case Nt.CANCELLED:E="skipped";break}if(E!==v.status){if(p.updateStep(v.id,E,G,Q),E==="failed"){const ee=(q=v.options)==null?void 0:q.batchId;ee&&x.steps.forEach(se=>{var ye;se.id!==v.id&&((ye=se.options)==null?void 0:ye.batchId)===ee&&se.status==="running"&&p.updateStep(se.id,"skipped",void 0,"前置任务失败")})}const U=p.getWorkflow();if(U){const ee=nt(U,b.current||void 0);A.current(ee);const se=P.current,ye=Le.current;se&&ye&&He.updateWorkflow(ye,se,ee)}}});return()=>s.unsubscribe()},[p]);const js=o.useRef(void 0),xn=o.useRef(void 0);o.useEffect(()=>{const s=qn.observeCompletionEvents().subscribe(i=>{const f=p.getWorkflow(),x=f==null?void 0:f.steps.find(G=>{const Q=G.result;return(Q==null?void 0:Q.taskId)===i.taskId});let v,E;switch(i.type){case"postProcessingStarted":v="processing";break;case"postProcessingCompleted":v="completed",E=i.result.insertedCount;break;case"postProcessingFailed":v="failed";break}if(js.current=v,E!==void 0&&(xn.current=(xn.current||0)+E),f&&x){const G=p.getWorkflow();if(G){const Q=nt(G,b.current||void 0,v,xn.current);A.current(Q);const F=P.current,q=Le.current;F&&q&&He.updateWorkflow(q,F,Q)}}if(i.type==="postProcessingCompleted"){const G=i.result.firstElementPosition;we.current&&(clearTimeout(we.current),we.current=null),Ve.current=!1,rt(!1),setTimeout(async()=>{var q;h.closeChatDrawer();const Q=P.current,F=Le.current;if(Q&&F){const U=p.getWorkflow();if(U==null?void 0:U.steps.every(se=>se.status==="completed"||se.status==="failed"||se.status==="skipped")){const{workflowCompletionService:se}=await so(async()=>{const{workflowCompletionService:ne}=await import("./startup-app-DxX-P1pm.js").then(Se=>Se.nW);return{workflowCompletionService:ne}},__vite__mapDeps([0]),import.meta.url);(U==null?void 0:U.steps.every(ne=>{const Se=ne.result;return Se!=null&&Se.taskId?se.isPostProcessingCompleted(Se.taskId):!0}))&&(He.removeWorkZone(F,Q),P.current=null)}}if(G&&F){const U=(q=F.host)==null?void 0:q.getBoundingClientRect();if(U){const ee=F.viewport.zoom,se=G[0]-U.width/(2*ee),ye=G[1]-U.height/(2*ee);Zr.updateViewport(F,[se,ye],ee)}}},500),js.current=void 0,xn.current=void 0}});return()=>s.unsubscribe()},[p,h]);const Le=o.useRef(null),{submitWorkflow:Ns}=da({boardRef:Le,workZoneIdRef:P}),Ae=o.useRef(null),wn=o.useRef(null),Rs=o.useRef(null);ma(Ae,{enableCopy:!0,stopPropagation:!0}),o.useEffect(()=>{const s=i=>{const f=i.detail;if(f!=null&&f.generationType&&Ke(f.generationType),f!=null&&f.skillId){dn(f.skillId);const x=vn(f.skillId);x&&Ye(mt(x))}at(!0),requestAnimationFrame(()=>{var x;(x=Ae.current)==null||x.focus()})};return window.addEventListener(co,s),()=>{window.removeEventListener(co,s)}},[]);const Zo=o.useCallback(s=>{var i;if(st(s.prompt),ln(!0),Ke("agent"),s.skillId){dn(s.skillId);const f=vn(s.skillId);f&&Ye(mt(f))}(i=Ae.current)==null||i.focus(),Ne.track("inspiration_selected",{promptLength:s.prompt.length,modelType:s.modelType,skillId:s.skillId,templateId:s.templateId,title:s.title,category:s.category})},[]),qo=o.useCallback(s=>{var i;st(s.content),ln(!1),s.modelType&&(s.modelType==="image"?Ke("image"):s.modelType==="video"?Ke("video"):s.modelType==="audio"?Ke("audio"):s.modelType==="text"?Ke("text"):s.modelType==="agent"&&Ke("agent")),(i=Ae.current)==null||i.focus()},[]),Jo=o.useCallback(()=>{const s=ns.find(i=>i.id==="knowledge-base");s&&(window.__kbPendingNavigation={directoryName:"Skill",autoCreateNote:!0},cn.openTool(s),setTimeout(()=>{window.dispatchEvent(new CustomEvent("kb:navigate",{detail:{directoryName:"Skill",autoCreateNote:!0}}))},300))},[]),zs=o.useCallback((s="ai_input_bar")=>{const i=ns.find(f=>f.id==="banana-prompt");if(!i){console.warn("[AIInputBar] Banana prompt tool not found"),Ne.trackPromptAction({action:"open_tool",surface:s,promptType:y,prompt:ge,source:s,status:"failed",metadata:{tool_id:"banana-prompt",reason:"tool_not_found"}});return}Ne.trackPromptAction({action:"open_tool",surface:s,promptType:y,prompt:ge,source:s,status:"success",metadata:{tool_id:i.id,tool_type:"external_prompt_library"}}),cn.openTool(i)},[y,ge]),Qo=o.useCallback(()=>{zs("inspiration_board")},[zs]),er=o.useCallback(async s=>{try{const i=new Image;i.onload=()=>{const f={type:"image",url:s.url,name:s.name||`素材-${Date.now()}`,width:i.naturalWidth||void 0,height:i.naturalHeight||void 0};bt(x=>[...x,f]),$t(!1)},i.onerror=()=>{const f={type:"image",url:s.url,name:s.name||`素材-${Date.now()}`};bt(x=>[...x,f]),$t(!1)},i.src=s.url}catch(i){console.error("Failed to select asset from library:",i),$t(!1)}},[]),tr=o.useCallback(s=>{Wn(hs(s))},[]),nr=o.useCallback(()=>{var s;(s=Rs.current)==null||s.click()},[]),Os=o.useCallback(s=>new Promise((i,f)=>{const x=new FileReader;x.onload=()=>{const v=x.result,E=new Image;E.onload=()=>{i({url:v,width:E.naturalWidth,height:E.naturalHeight})},E.onerror=()=>{i({url:v,width:0,height:0})},E.src=v},x.onerror=f,x.readAsDataURL(s)}),[]),yn=o.useCallback(async s=>{const i=Array.from(s);if(i.length===0)return;const f=[];for(const[x,v]of i.entries()){if(!v.type.startsWith("image/")){qe.error(lt.invalidFile);continue}if(v.size>25*1024*1024){qe.error(lt.fileTooLarge);continue}try{let E=v;if(v.size>10*1024*1024){const{compressImageBlob:U,getCompressionStrategy:ee}=await so(async()=>{const{compressImageBlob:ne,getCompressionStrategy:Se}=await import("./startup-app-DxX-P1pm.js").then(Xe=>Xe.nG);return{compressImageBlob:ne,getCompressionStrategy:Se}},__vite__mapDeps([0]),import.meta.url),se=ee(v.size/(1024*1024)),ye=qe.loading({content:lt.compressing(v.size/(1024*1024)),duration:0,placement:"top"});try{E=await U(v,se.targetSizeMB),qe.close(ye),qe.success({content:lt.compressed(v.size/(1024*1024),E.size/(1024*1024)),duration:2})}catch(ne){qe.close(ye),console.error("[AIInputBar] Failed to compress image:",ne),qe.error(lt.compressionFailed);continue}}const G=E instanceof File?E:new File([E],v.name||`pasted-image-${Date.now()}.png`,{type:E.type||v.type||"image/png"});w(G,Xs.IMAGE,qr.LOCAL,G.name).catch(U=>{console.warn("[AIInputBar] Failed to add asset to library:",U)});const{url:Q,width:F,height:q}=await Os(G);f.push({type:"image",url:Q,name:G.name||`上传图片 ${x+1}`,width:F||void 0,height:q||void 0})}catch(E){console.error("[AIInputBar] Failed to import local image:",E),qe.error(lt.loadFailed)}}f.length>0&&bt(x=>[...x,...f])},[w,Os,lt]),sr=o.useCallback(async s=>{const i=s.target.files;!i||i.length===0||(await yn(i),s.target.value="")},[yn]),or=o.useCallback(s=>{On(s)},[]),Ws=o.useRef(null),rr=o.useCallback(s=>{if(Ws.current=s,!s)return;const i=Jr(s.width,s.height,W);i&&mn(f=>({...f,size:i}))},[W]),ar=o.useCallback(s=>{s<Wt.length&&bt(i=>i.filter((f,x)=>x!==s))},[Wt.length]);o.useEffect(()=>{R.current(ie.map(s=>({type:s.type,url:s.url,text:s.text,name:s.name})))},[ie]),o.useEffect(()=>{const s=i=>{var F,q;const f=(F=i.clipboardData)==null?void 0:F.items;if(!f||f.length===0||!Array.from(f).some(U=>U.type.startsWith("image/")))return;const v=document.activeElement,E=wn.current;if(!(!!E&&(E.contains(v)||Lt&&(v===document.body||(v==null?void 0:v.tagName)==="BODY"))))return;const Q=[];for(const U of Array.from(f)){if(!U.type.startsWith("image/"))continue;const ee=U.getAsFile();ee&&Q.push(ee)}Q.length!==0&&(i.preventDefault(),yn(Q),(q=Ae.current)==null||q.focus())};return document.addEventListener("paste",s),()=>{document.removeEventListener("paste",s)}},[yn,Lt]);const vt=o.useCallback(()=>{if(ct.current!==null){const s=ct.current;st(i=>i.substring(0,s)+i.substring(s+1)),ct.current=null}},[]),In=o.useCallback(s=>{const i=Ii(y,s.type);Ne.track("ai_input_change_model",{model:s.id,type:s.type,profileId:s.sourceProfileId||null}),vt(),Ke(i),ys(s.id);const f=$e(s);Is(f),bo(i,{modelId:s.id,modelRef:f,providerIdHint:s.sourceProfileId||(f==null?void 0:f.profileId),vendorHint:s.vendor}),mn(i==="agent"?{}:Qn(i,s.id,Ge(s.id,f))),Ln(!1),setTimeout(()=>{var x;return(x=Ae.current)==null?void 0:x.focus()},0)},[vt,y]),ir=o.useCallback(s=>{const i=Ie(gn,s,L)||Ie(gn,s,null)||Je(s);i&&In(i)},[In,gn,L]),cr=o.useCallback(s=>{In(s)},[In]),_n=o.useCallback((s,i)=>{const f=$e(i);s==="image"?(_s(i.id),bs(f)):s==="video"?(vs(i.id),ks(f)):(Ss(i.id),Ms(f)),bo(s,{modelId:i.id,modelRef:f,providerIdHint:i.sourceProfileId||(f==null?void 0:f.profileId),vendorHint:i.vendor}),Ne.track("ai_input_change_agent_media_model",{model:i.id,type:s,profileId:i.sourceProfileId||null})},[]),Hn=o.useCallback((s,i,f)=>{const x=s==="image"?Bt:s==="video"?Ft:Ht,v=Ie(x,i,f||null)||Ie(x,i,null)||Je(i);v&&_n(s,v)},[_n,Ht,Bt,Ft]),Gn=o.useCallback((s,i)=>{_n(s,i)},[_n]),lr=o.useCallback(s=>{Ye(mt(s))},[]),Ls=o.useMemo(()=>({image:ze,video:Oe,audio:We}),[We,ze,Oe]),Bs=o.useMemo(()=>({image:Ce,video:Te,audio:Pe}),[Pe,Ce,Te]);o.useEffect(()=>{const s=[{modelId:W,profileId:(L==null?void 0:L.profileId)||null}];y==="agent"&&fe!==Ze&&(it.includes("image")&&s.push({modelId:ze,profileId:(Ce==null?void 0:Ce.profileId)||null}),it.includes("video")&&s.push({modelId:Oe,profileId:(Te==null?void 0:Te.profileId)||null}),it.includes("audio")&&s.push({modelId:We,profileId:(Pe==null?void 0:Pe.profileId)||null})),_(s)},[y,We,Pe,ze,Ce,Oe,Te,W,L,fe,it,_]),o.useEffect(()=>{const s=(F,q)=>{const U=Object.keys(F),ee=Object.keys(q);return U.length!==ee.length?!1:U.every(se=>F[se]===q[se])},i=y==="agent"?"agent":`${y}:${Ge(W,L)}`,f=y==="agent"?{}:Cs.current===i?Gt.current||{}:Qn(y,W,Ge(W,L),Gt.current),x={},v=Vt.find(F=>F.id==="size"),E=f.size,G=!E||!(v!=null&&v.options)||v.options.some(F=>F.value===E);!W.startsWith("mj")&&v&&(x.size=E&&G?E:v.defaultValue||Ys(W)),Vt.forEach(F=>{if(F.id==="size")return;const q=f[F.id],U=!q||F.valueType!=="enum"||!F.options||F.options.some(ee=>ee.value===q);q&&U?x[F.id]=q:F.defaultValue&&(x[F.id]=F.defaultValue)});const Q=Qr(W,x);s(Gt.current||{},Q)||(mn(Q),Gt.current=Q),Cs.current=i},[y,W,L,Vt]),o.useEffect(()=>{Ea({generationType:y,selectedModel:W,selectedParams:Ee,selectedCount:Ut,selectedSkillId:fe}),y!=="agent"&&Aa(y,W,Ee,Ge(W,L))},[y,W,L,Ee,Ut,fe]);const dr=o.useCallback((s,i,f)=>{vt(),mn(x=>{const v={...x};return i===void 0||i===""?delete v[s]:v[s]=i,v}),f!=null&&f.keepOpen||(Bn(!1),setTimeout(()=>{var x;return(x=Ae.current)==null?void 0:x.focus()},0))},[vt]),ur=o.useCallback(s=>{vt(),Ts(s),Fn(!1),setTimeout(()=>{var i;return(i=Ae.current)==null?void 0:i.focus()},0)},[vt]),Un=o.useCallback(async s=>{var G,Q,F,q,U,ee,se,ye;const i=ge.trim();if(!i&&ie.length===0||Ve.current||Re)return;Ve.current=!0,ln(!1),d==null||d();const f=Date.now(),x=i.length,v={trigger:s,source:"ai_input_bar",generationType:y,generation_type:y,model:W,profileId:(L==null?void 0:L.profileId)||null,profile_id:(L==null?void 0:L.profileId)||null,hasAttachedContent:ie.length>0,has_attached_content:ie.length>0,attachedCount:ie.length,attached_count:ie.length,knowledgeContextCount:ot.length,knowledge_context_count:ot.length,promptLength:x,prompt_length:x,promptLengthBucket:ts(x),prompt_length_bucket:ts(x)},E=(ne,Se={})=>{const Xe=Date.now()-f;Ne.track("ai_input_submit",{...v,status:ne,durationMs:Xe,duration_ms:Xe,...Se})};E("start"),rt(!0);try{if(!ea(y==="video"?"video":y==="audio"?"audio":y==="text"||y==="agent"?"text":"image",L||W)&&!await ta()){E("cancelled",{reason:"missing_api_key",submitMode:"preflight",submit_mode:"preflight"}),Ve.current=!1,rt(!1);return}const Xe=ie.filter(k=>k.type==="image"&&k.url),Kt=ie.filter(k=>k.type==="graphics"&&k.url),j=[...Xe,...Kt].map(k=>{if(k.width&&k.height)return{width:k.width,height:k.height}}).filter(k=>k!==void 0),te={texts:ie.filter(k=>k.type==="text"&&k.text).map(k=>k.text),images:Xe.map(k=>k.url),videos:ie.filter(k=>k.type==="video"&&k.url).map(k=>k.url),graphics:Kt.map(k=>k.url),imageDimensions:j},H=Va(ge,te,{modelId:W,modelRef:L,params:Ee,generationType:y,count:Ut,knowledgeContextRefs:ot,defaultModels:y==="agent"?Ls:void 0,defaultModelRefs:y==="agent"?Bs:void 0}),re=[...te.images,...te.graphics];let B;if(y==="agent"&&fe!==Ze){const k=vn(fe);if(k)try{B=await Sn(H,k,re)}catch(J){console.warn("[AIInputBar] 系统 Skill 工作流转换失败,降级到通用工作流:",J),B=jt(H,re)}else{const J=Zs(fe);if(J)try{B=await Sn(H,{id:J.id,name:J.name,type:"external",content:J.content,outputType:J.outputType},re)}catch(Y){console.warn("[AIInputBar] 外部 Skill 工作流转换失败,降级到角色扮演:",Y),B=await Sn(H,{id:J.id,name:J.name,type:"external",content:J.content,outputType:J.outputType},re).catch(()=>jt(H,re))}else try{const Y=await Dn.getNoteById(fe);if(Y){const ce=((G=Y.metadata)==null?void 0:G.outputType)||void 0;B=await Sn(H,{id:Y.id,name:Y.title,type:"user",content:Y.content,outputType:ce},re)}else B=jt(H,re)}catch{B=jt(H,re)}}B||(console.warn("[AIInputBar] Skill 工作流未能生成,降级到通用工作流"),B=jt(H,re))}else B=jt(H,re);const V=Le.current;if(V){const ce=(Q=V.host)==null?void 0:Q.getBoundingClientRect(),he=((F=V.viewport)==null?void 0:F.zoom)||1,me=((U=(q=V.viewport)==null?void 0:q.origination)==null?void 0:U[0])||0,Be=((se=(ee=V.viewport)==null?void 0:ee.origination)==null?void 0:se[1])||0,qt=V.children.filter(xe=>xe.type!=="workzone"),bn=me+((ce==null?void 0:ce.width)||0)/2/he,Tt=Be+((ce==null?void 0:ce.height)||0)/2/he;let ve=bn-200,ae=Tt,Pt=ve,tt=Tt-240/2;if(qt.length>0){const xe=Eo(V);let de=!1;if(xe.length>0)try{const ue=Jn(V,xe,!1);xe.every(ke=>qs.isDrawElement(ke)&&qs.isImage(ke)||na(ke))&&ue.width>ue.height?(ve=ue.x+ue.width+50,ae=ue.y):(ve=ue.x,ae=ue.y+ue.height+50),Pt=ve,tt=ae,de=!0}catch(ue){console.warn("[AIInputBar] Failed to calculate position for selected elements:",ue)}if(!de){let ue=null,Qt=-1/0;for(const ke of qt)try{const At=Jn(V,[ke],!1),en=At.y+At.height;en>Qt&&(Qt=en,ue=ke)}catch(At){console.warn("[AIInputBar] Failed to get rectangle for element:",At)}if(ue){const ke=Jn(V,[ue],!1);ve=ke.x,ae=ke.y+ke.height+50,Pt=ve,tt=ae}}}const ut=nt(B),Et=Ws.current;let Jt,ft,Hs;if(Et){const xe=V.children.find(de=>de.id===Et.id);if(xe&&Ao(xe)){Jt=Et.id,ft={width:Et.width,height:Et.height};const de=jn.getRectangleByPoints(xe.points);Hs=de,ve=de.x,ae=de.y}}if(H.generationType==="image"){const xe=Math.max(H.count??1,1),de=xe>1,ue=de?void 0:Jt,Qt=de?void 0:ft,ke=[],At=`wf_batch_${B.id}`,en=ue?null:ci(V,[ve,ae],Js({workflowId:B.id,expectedInsertPosition:[ve,ae],requestedSize:H.size,requestedCount:1,zoom:he,title:ut.name||"图片生成",...Zn("submitted")}).size??{width:320,height:180},xe,{frameRect:de?Hs:void 0});for(let Fe=0;Fe<xe;Fe+=1){let tn=Js({workflowId:B.id,expectedInsertPosition:[ve,ae],targetFrameId:ue,targetFrameDimensions:Qt,frameAffinityId:de?Jt:void 0,frameAffinityDimensions:de?ft:void 0,requestedSize:H.size,requestedCount:de?1:xe,batchId:de?At:void 0,batchIndex:de?Fe+1:void 0,batchTotal:de?xe:void 0,zoom:he,title:ut.name||"图片生成",...Zn("submitted")});if(!ue){const Us=en?en[Fe]??tn.position:tn.position;tn={...tn,position:Us,expectedInsertPosition:Us}}const _r=pt.insertAnchor(V,tn);ke.push(_r)}z.current=ke.map(Fe=>Fe.id),P.current=null;const[Gs]=ke;Gs&&setTimeout(()=>{const Fe=jn.getRectangleByPoints(Gs.points);Qs(V,[Fe.x+Fe.width/2,Fe.y+Fe.height/2],100)},100)}else{const xe=He.insertWorkZone(V,{workflow:ut,position:[Pt,tt],size:{width:360,height:240},expectedInsertPosition:[ve,ae],targetFrameId:Jt,targetFrameDimensions:ft,zoom:he});P.current=xe.id,z.current=[],setTimeout(()=>{const de=Pt+180,ue=tt+240/2;Qs(V,[de,ue],100)},100)}}const kt=Dt("image"),St=Dt("video"),Mt=Dt("audio"),Ct={rawInput:ge,userInstruction:H.userInstruction,model:{id:H.modelId,type:H.generationType,isExplicit:H.isModelExplicit},modelRef:H.modelRef,defaultModels:H.defaultModels||{audio:Mt.modelId||zt(),image:kt.modelId||xt(),video:St.modelId||Rt()},defaultModelRefs:H.defaultModelRefs||{audio:wt(Mt.profileId,Mt.modelId),image:wt(kt.profileId,kt.modelId),video:wt(St.profileId,St.modelId)},params:{count:H.count,size:H.size,duration:H.duration},selection:te,finalPrompt:H.prompt,knowledgeContextRefs:H.knowledgeContextRefs},Kn=Dt("text").modelId,Yt={aiContext:Ct,referenceImages:re,textModel:Kn};b.current=Yt;try{const k=Date.now(),{usedSW:J}=await Ns(H,re,Yt,B);if(J){if(E("success",{submitMode:"service_worker",submit_mode:"service_worker",workflowId:B.id,workflow_id:B.id,stepCount:B.steps.length,step_count:B.steps.length}),y==="image"&&K(V,"accepted"),ge.trim()){const Y=ge.trim(),ce=ie.length>0;I(Y,ce,y),y==="image"?eo(Y):y==="video"&&to(Y)}st(""),On([]),bt([]),Wn([]),we.current&&clearTimeout(we.current),we.current=setTimeout(()=>{Ve.current=!1,rt(!1),we.current=null},1e3);return}}catch(k){console.warn("[AIInputBar] SW execution failed, falling back to main thread:",k)}if(y==="image"&&K(V,"handoff"),ge.trim()){const k=ge.trim(),J=ie.length>0;I(k,J,y),y==="image"?eo(k):y==="video"&&to(k)}st(""),On([]),bt([]),Wn([]),we.current&&clearTimeout(we.current),we.current=setTimeout(()=>{Ve.current=!1,rt(!1),we.current=null},1e3);const pe=[],et=[],Xt=(k,J)=>({onChunk:Y=>{C.current(Y)},onAddSteps:Y=>{p.updateStep(k.id,"completed",{analysis:"completed"},void 0,Date.now()-J);const ce=Y.map((me,Be)=>An(B,{...me,status:me.status==="completed"?"completed":"pending",options:{mode:"queue",batchId:`agent_${Date.now()}`,batchIndex:Be+1,batchTotal:Y.length,globalIndex:Be+1}}));p.addSteps(ce),et.push(...ce),Y.forEach(me=>{T.current({type:"tool_call",timestamp:Date.now(),toolName:me.mcp,args:me.args})});const he=nt(p.getWorkflow(),b.current||void 0);A.current(he),P.current&&V&&He.updateWorkflow(V,P.current,he)},onUpdateStep:(Y,ce,he,me)=>{p.updateStep(Y,ce,he,me),T.current({type:"tool_result",timestamp:Date.now(),toolName:Y,success:ce==="completed",data:he,error:me});const Be=nt(p.getWorkflow(),b.current||void 0);A.current(Be),P.current&&V&&He.updateWorkflow(V,P.current,Be)}});let De=!1;const Zt=()=>{const k=nt(p.getWorkflow(),b.current||void 0);A.current(k),P.current&&V&&He.updateWorkflow(V,P.current,k)},Yn=async k=>{var ce,he,me,Be,qt,bn;const J=Date.now(),Y=et.length;p.updateStep(k.id,"running"),Zt();try{const Tt={...k.options,...Xt(k,J)},ve=An(B,k),ae=await oo.executeTool({name:ve.mcp,arguments:ve.args},Tt),Pt=(he=(ce=p.getWorkflow())==null?void 0:ce.steps.find(tt=>tt.id===k.id))==null?void 0:he.status;if(ae.success){if(ae.taskId)pe.push(ae.taskId),p.updateStep(k.id,"running",{taskId:ae.taskId}),M(V,ae.taskId,{workflowId:B.id,batchId:(me=k.options)==null?void 0:me.batchId,batchIndex:(Be=k.options)==null?void 0:Be.batchIndex});else if(Pt==="running"){const tt=ae.type==="text"&&ae.data&&typeof ae.data=="object"&&"content"in ae.data?{content:ae.data.content}:ae.data;p.updateStep(k.id,"completed",tt,void 0,Date.now()-J);const ut=k.mcp==="generate_text"?(qt=ae.data)==null?void 0:qt.content:k.mcp==="ai_analyze"?(bn=ae.data)==null?void 0:bn.response:void 0;if((k.mcp==="generate_text"||k.mcp==="ai_analyze")&&ut&&ut.trim()&&et.length===Y){const ft={id:`${k.id}-insert-text`,mcp:"insert_to_canvas",args:{items:[{type:"text",content:ut}]},description:k.mcp==="generate_text"?"将生成文本插入画布":"将 AI 回复插入画布",status:"pending"};p.addSteps([ft]),et.push(ft)}}}else return p.updateStep(k.id,"failed",void 0,ae.error||"执行失败",Date.now()-J),!1;return!0}catch(Tt){return p.updateStep(k.id,"failed",void 0,String(Tt)),!1}finally{Zt()}};for(const k of B.steps){if(De){p.updateStep(k.id,"skipped"),Zt();continue}await Yn(k)||(De=!0)}if(!De&&et.length>0){const k=p.getWorkflow();for(const J of et){if(De){p.updateStep(J.id,"skipped"),Zt();continue}const Y=(ye=p.getWorkflow())==null?void 0:ye.steps.find(he=>he.id===J.id);if(!Y){console.warn(`[AIInputBar] Step ${J.id} not found in workflow!`);continue}if(Y.status==="completed")continue;await Yn(Y)||(De=!0)}}const _e=p.getWorkflow(),yr=_e==null?void 0:_e.steps.every(k=>k.status==="completed"||k.status==="failed"||k.status==="skipped"),Ir=pe.length>0;if(yr&&!Ir){const k=P.current,J=z.current,Y=Le.current;(k||J.length>0)&&Y&&(_e!=null&&_e.steps.every(he=>{const me=he.result;return me!=null&&me.taskId?qn.isPostProcessingCompleted(me.taskId):!0}))&&setTimeout(()=>{k&&(He.removeWorkZone(Y,k),P.current=null),J.length>0&&(K(Y,"completed"),Z(Y))},1500)}E(De?"failed":"success",{submitMode:"main_thread",submit_mode:"main_thread",workflowId:B.id,workflow_id:B.id,stepCount:(_e==null?void 0:_e.steps.length)||B.steps.length,step_count:(_e==null?void 0:_e.steps.length)||B.steps.length,createdTaskCount:pe.length,created_task_count:pe.length,failureReason:De?"workflow_step_failed":void 0,failure_reason:De?"workflow_step_failed":void 0})}catch(ne){console.error("Failed to create generation task:",ne),E("failed",{submitMode:"setup",submit_mode:"setup",error:ne instanceof Error?ne.message:String(ne)}),y==="image"&&K(Le.current,"failed",{error:ne instanceof Error?ne.message:"创建图片任务失败"}),p.abortWorkflow(),Ve.current=!1,rt(!1)}},[ge,ie,Re,W,L,p,Ns,I,Ee,ot,Ls,Bs,y,Ut,M,K,Z,d]),$n=o.useCallback(async(s,i,f)=>{var Kt;const x=s.retryContext;if(!x){console.error("[AIInputBar] No retry context available for workflow");return}f&&(P.current=f);const v={id:s.id,name:s.name,description:`重试: ${s.name}`,scenarioType:s.steps.some(j=>j.mcp==="ai_analyze")?"agent_flow":"direct_generation",generationType:s.generationType,steps:s.steps.map((j,te)=>({id:j.id,mcp:j.mcp,args:j.args,description:j.description,status:te<i?j.status:"pending",result:te<i?j.result:void 0,error:te<i?j.error:void 0,duration:te<i?j.duration:void 0,options:j.options})),metadata:{prompt:s.prompt,userInstruction:x.aiContext.userInstruction,rawInput:x.aiContext.rawInput,modelId:x.aiContext.model.id,modelRef:x.aiContext.modelRef,defaultModels:x.aiContext.defaultModels,defaultModelRefs:x.aiContext.defaultModelRefs,isModelExplicit:x.aiContext.model.isExplicit,count:s.count,size:x.aiContext.params.size,duration:x.aiContext.params.duration,referenceImages:x.referenceImages,selection:x.aiContext.selection,knowledgeContextRefs:x.aiContext.knowledgeContextRefs},createdAt:Date.now()};p.startWorkflow(v),T.current({type:"retry",timestamp:Date.now(),reason:`从步骤 ${i+1} 开始重试`,attempt:1});const E=Le.current,G=()=>{const j=nt(p.getWorkflow(),x);A.current(j),P.current&&E&&He.updateWorkflow(E,P.current,j)},Q=nt(v,x);A.current(Q),P.current&&E&&He.updateWorkflow(E,P.current,Q);const F=(j,te)=>({onChunk:H=>{C.current(H)},onAddSteps:H=>{p.updateStep(j.id,"completed",{analysis:"completed"},void 0,Date.now()-te);const re=H.map((B,V)=>An(v,{...B,status:B.status==="completed"?"completed":"pending",options:{mode:"queue",batchId:`agent_${Date.now()}`,batchIndex:V+1,batchTotal:H.length,globalIndex:V+1}}));p.addSteps(re),q.push(...re),H.forEach(B=>{T.current({type:"tool_call",timestamp:Date.now(),toolName:B.mcp,args:B.args})}),G()},onUpdateStep:(H,re,B,V)=>{p.updateStep(H,re,B,V),T.current({type:"tool_result",timestamp:Date.now(),toolName:H,success:re==="completed",data:B,error:V}),G()}}),q=[];let U=!1;const ee=new Map;s.steps.forEach(j=>{var H;const te=(H=j.result)==null?void 0:H.taskId;te&&ee.set(j.id,te)});const se=async j=>{var re,B,V,kt,St,Mt;const te=Date.now(),H=q.length;p.updateStep(j.id,"running"),G();try{const Ct=ee.get(j.id),Kn={...j.options,...F(j,te),...Ct?{retryTaskId:Ct}:{}},Yt=An(v,j),pe=await oo.executeTool({name:Yt.mcp,arguments:Yt.args},Kn),et=(B=(re=p.getWorkflow())==null?void 0:re.steps.find(Xt=>Xt.id===j.id))==null?void 0:B.status;if(pe.success){if(pe.taskId)p.updateStep(j.id,"running",{taskId:pe.taskId}),M(E,pe.taskId,{workflowId:s.id,batchId:(V=j.options)==null?void 0:V.batchId,batchIndex:(kt=j.options)==null?void 0:kt.batchIndex});else if(et==="running"){const Xt=pe.type==="text"&&pe.data&&typeof pe.data=="object"&&"content"in pe.data?{content:pe.data.content}:pe.data;p.updateStep(j.id,"completed",Xt,void 0,Date.now()-te);const De=j.mcp==="generate_text"?(St=pe.data)==null?void 0:St.content:j.mcp==="ai_analyze"?(Mt=pe.data)==null?void 0:Mt.response:void 0;if((j.mcp==="generate_text"||j.mcp==="ai_analyze")&&De&&De.trim()&&q.length===H){const _e={id:`${j.id}-insert-text`,mcp:"insert_to_canvas",args:{items:[{type:"text",content:De}]},description:j.mcp==="generate_text"?"将生成文本插入画布":"将 AI 回复插入画布",status:"pending"};p.addSteps([_e]),q.push(_e)}}}else return p.updateStep(j.id,"failed",void 0,pe.error||"执行失败",Date.now()-te),!1;return!0}catch(Ct){return p.updateStep(j.id,"failed",void 0,String(Ct)),!1}finally{G()}},ye=v.steps.slice(i);for(const j of ye){if(U){p.updateStep(j.id,"skipped"),G();continue}await se(j)||(U=!0)}if(!U&&q.length>0)for(const j of q){if(U){p.updateStep(j.id,"skipped"),G();continue}const te=(Kt=p.getWorkflow())==null?void 0:Kt.steps.find(re=>re.id===j.id);if(!te||te.status==="completed")continue;await se(te)||(U=!0)}const ne=p.getWorkflow(),Se=ne==null?void 0:ne.steps.every(j=>j.status==="completed"||j.status==="failed"||j.status==="skipped"),Xe=ne==null?void 0:ne.steps.some(j=>{var te;return(te=j.result)==null?void 0:te.taskId});if(Se&&!Xe){const j=P.current,te=Le.current;j&&te&&(ne!=null&&ne.steps.every(re=>{const B=re.result;return B!=null&&B.taskId?qn.isPostProcessingCompleted(B.taskId):!0}))&&setTimeout(()=>{He.removeWorkZone(te,j),P.current=null},1500)}},[p,M]);o.useEffect(()=>{N.current($n);const s=Le.current;s&&(s.__executeWorkflowRetry=$n)},[$n]);const fr=o.useCallback(s=>{var i;if(!s.nativeEvent.isComposing&&!(s.key==="Enter"&&(s.shiftKey||s.altKey))){if((Ps||Es||As)&&(s.key==="Enter"||s.key==="Tab")){s.preventDefault();return}if(s.key==="Enter"){s.preventDefault(),Ne.track("ai_input_submit_keyboard"),Un("keyboard");return}if(s.key==="Escape"){at(!1),(i=Ae.current)==null||i.blur();return}}},[Un]),pr=o.useCallback(()=>{Ne.track("ai_input_focus_textarea"),at(!0)},[]),hr=o.useCallback(()=>{Ne.track("ai_input_blur_textarea"),at(!1)},[]),mr=o.useCallback(s=>{const i=s.target.value,f=s.target.selectionStart||i.length;if(st(i),ln(!1),f>0){const x=i[f-1],v=f>1?i[f-2]:" ";x==="#"&&(v===" "||v===`
|
|
107
|
-
`||f===1)&&(ct.current=f-1,Ln(!0),Bn(!1),Fn(!1))}},[]),gr=o.useMemo(()=>JSON.stringify({generationType:y,model:W,profileId:(L==null?void 0:L.profileId)||null,hasAttachedContent:ie.length>0,attachedCount:ie.length,knowledgeContextCount:ot.length,promptLengthBucket:ts(ge.trim().length)}),[ie.length,y,ot.length,ge,W,L==null?void 0:L.profileId]),Vn=ge.trim().length>0||ie.length>0,xr=Ho&&Vn&&!Re,Fs=$o===!0,wr=zn.some(s=>{var i;return s.type==="text"&&((i=s.text)==null?void 0:i.trim())}),dt=Lt||ie.length>0||Go;return o.useLayoutEffect(()=>{yi(Ae.current,dt)},[dt,ge]),c.jsxs("div",{ref:wn,className:sn("ai-input-bar",Rn,e,{"ai-input-bar--with-inspiration":Fs}),"data-testid":"ai-input-bar",children:[c.jsx(Bo,{language:r,onSelectionChange:or,externalBoardRef:Le,onCanvasEmptyChange:Vo,isDataReady:n,onFrameSelected:rr}),c.jsx(ei,{isCanvasEmpty:Fs,onSelectPrompt:Zo,onOpenPromptTool:Qo}),c.jsxs("div",{className:sn("ai-input-bar__container",{"ai-input-bar__container--expanded":dt}),children:[c.jsxs("div",{className:"ai-input-bar__bottom-bar",children:[c.jsx("input",{ref:Rs,type:"file",accept:"image/*",multiple:!0,onChange:sr,style:{display:"none"}}),c.jsx(Qe,{content:r==="zh"?"上传图片":"Upload images",showArrow:!1,children:c.jsx("button",{className:"ai-input-bar__upload-btn",onMouseDown:s=>{s.preventDefault(),s.stopPropagation()},onClick:nr,"data-track":"ai_input_click_upload",children:c.jsx(sa,{size:18})})}),c.jsx(Qe,{content:r==="zh"?"从素材库选择":"Select from library",showArrow:!1,children:c.jsx("button",{className:"ai-input-bar__library-btn",onMouseDown:s=>{s.preventDefault(),s.stopPropagation()},onClick:()=>$t(!0),"data-track":"ai_input_click_library",children:c.jsx(oa,{size:18})})}),c.jsx(ga,{value:ot,onChange:tr,disabled:Re,language:r,variant:"compact",className:"ai-input-bar__knowledge-selector"}),c.jsx(ti,{value:y,onSelect:Ke,disabled:Re}),y==="agent"&&c.jsx(Ka,{value:fe,onSelect:dn,onSelectSkill:lr,onAddSkill:Jo,disabled:Re}),c.jsx(kn,{selectedModel:W,selectedSelectionKey:Ge(W,L),onSelect:ir,onSelectModel:cr,language:r,models:gn,header:r==="zh"?y==="agent"?"选择文本模型 (↑↓ Tab)":"选择模型 (↑↓ Tab)":y==="agent"?"Select text model (↑↓ Tab)":"Select model (↑↓ Tab)",isOpen:Ps,onOpenChange:Ko}),y==="agent"&&fe!==Ze&&it.includes("image")&&c.jsx(kn,{selectedModel:ze,selectedSelectionKey:Ge(ze,Ce),onSelect:(s,i)=>Hn("image",s,i),onSelectModel:s=>Gn("image",s),language:r,models:Bt,header:r==="zh"?"选择图片模型 (↑↓ Tab)":"Select image model (↑↓ Tab)"}),y==="agent"&&fe!==Ze&&it.includes("video")&&c.jsx(kn,{selectedModel:Oe,selectedSelectionKey:Ge(Oe,Te),onSelect:(s,i)=>Hn("video",s,i),onSelectModel:s=>Gn("video",s),language:r,models:Ft,header:r==="zh"?"选择视频模型 (↑↓ Tab)":"Select video model (↑↓ Tab)"}),y==="agent"&&fe!==Ze&&it.includes("audio")&&c.jsx(kn,{selectedModel:We,selectedSelectionKey:Ge(We,Pe),onSelect:(s,i)=>Hn("audio",s,i),onSelectModel:s=>Gn("audio",s),language:r,models:Ht,header:r==="zh"?"选择音频模型 (↑↓ Tab)":"Select audio model (↑↓ Tab)"}),y!=="agent"&&Vt.length>0&&c.jsx(va,{selectedParams:Ee,onParamChange:dr,compatibleParams:Vt,modelId:W,language:r,isOpen:Es,onOpenChange:Yo},W),y!=="agent"&&y!=="text"&&y!=="audio"&&c.jsx(ni,{value:Ut,onSelect:ur,disabled:Re,isOpen:As,onOpenChange:Xo}),c.jsx("div",{className:"ai-input-bar__bottom-spacer"}),c.jsx("button",{className:sn("ai-input-bar__send-btn",{active:Vn,loading:Re,"ai-input-bar__send-btn--guide":xr}),onMouseDown:s=>{s.preventDefault(),s.stopPropagation()},onClick:()=>Un("button"),disabled:!Vn||Re,"data-track":"ai_input_click_send","data-track-params":gr,"data-testid":"ai-send-btn",children:c.jsx(rs,{size:18})})]}),c.jsxs("div",{className:sn("ai-input-bar__input-area",{"ai-input-bar__input-area--expanded":dt}),children:[ie.length>0&&c.jsx("div",{className:"ai-input-bar__content-preview",children:c.jsx(xa,{items:ie,language:r,enableHoverPreview:!0,onRemove:ar,removableStartIndex:Wt.length})}),c.jsxs("div",{className:"ai-input-bar__prompt-row",children:[c.jsx("div",{className:"ai-input-bar__rich-input",children:c.jsx("textarea",{ref:Ae,className:sn("ai-input-bar__input",{"ai-input-bar__input--focused":dt}),value:ge,onChange:mr,onKeyDown:fr,onFocus:pr,onBlur:hr,placeholder:y==="agent"?r==="zh"?"输入指令,让 Agent 为你工作...":"Type instructions for Agent...":y==="text"?r==="zh"?"输入你想生成的文本内容、文章、摘要或 Markdown":"Describe the text, article, summary, or markdown you want":y==="audio"?wr?r==="zh"?"已有文本,无需额外提示词,直接发送":"Text already selected. No extra prompt needed, just send":r==="zh"?"描述你想要生成的音乐、风格、歌词或情绪":"Describe the music, style, lyrics, or mood you want":r==="zh"?`描述你想要创建的${y==="image"?"图片":"视频"}`:`Describe the ${y==="image"?"image":"video"} you want to create`,rows:dt?Lo:gi,disabled:Re,"data-testid":"ai-input-textarea"})}),c.jsx(Da,{generationType:y,onSelectPrompt:qo,language:r,onBeforeOpenMyPrompts:t,extraActions:dt?c.jsx(wa,{className:"prompt-history-popover__action-btn",originalPrompt:ge,language:r,scenarioId:`ai-input.${y}`,disabled:Re,allowStructuredMode:!0,onOpenChange:Uo,onMouseDown:s=>{s.preventDefault(),s.stopPropagation(),at(!0)},onApply:s=>{st(s),at(!0),requestAnimationFrame(()=>{var i;(i=Ae.current)==null||i.focus()})}}):null})]})]})]}),Ds&&c.jsx(ba,{isOpen:Ds,onClose:()=>$t(!1),mode:ra.SELECT,filterType:Xs.IMAGE,onSelect:er})]})});Fo.displayName="AIInputBar";function Ni({isDataReady:e,activationKey:n,onEnableToolWindows:t,onEnableRuntime:d}){const r=o.useRef(null);return o.useEffect(()=>{if(n<=0)return;const l=window.setTimeout(()=>{var m;const a=(m=r.current)==null?void 0:m.querySelector('[data-testid="ai-input-textarea"]');a==null||a.focus()},0);return()=>{window.clearTimeout(l)}},[n]),c.jsx(ua,{children:c.jsx(ca,{children:c.jsx("div",{ref:r,children:c.jsx(Fo,{isDataReady:e,onEnableToolWindows:t,onEnableRuntime:d})})})})}export{Ni as DeferredAIInputBar,Ni as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
@charset "UTF-8";.prompt-history-popover{position:relative;align-self:flex-start;z-index:10;display:flex;align-items:center;flex-shrink:0}.prompt-history-popover__actions{display:flex;flex-direction:column;align-items:center;gap:4px}.prompt-history-popover__trigger{display:flex;align-items:center;justify-content:center;width:32px;height:32px;padding:0;border:none;border-radius:6px;background:transparent;color:var(--td-text-color-secondary, #666);cursor:pointer;transition:all .2s ease}.prompt-history-popover__trigger:hover{background:var(--td-bg-color-container-hover, rgba(0, 0, 0, .04));color:var(--td-text-color-primary, #333)}.prompt-history-popover__action-btn{display:flex;align-items:center;justify-content:center;width:32px;height:32px;padding:0;border:none;border-radius:6px;background:transparent;color:var(--td-text-color-secondary, #666);cursor:pointer;transition:all .2s ease}.prompt-history-popover__action-btn:hover:not(:disabled){background:var(--td-bg-color-container-hover, rgba(0, 0, 0, .04));color:var(--td-text-color-primary, #333)}.prompt-history-popover__action-btn:disabled{opacity:.55;cursor:not-allowed}.prompt-history-popover__panel-wrapper{position:absolute;bottom:calc(100% + 8px);right:0;z-index:1000}.inspiration-board{padding:12px;background:var(--island-bg-color, #fff);border:none;border-radius:24px 24px 0 0;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);box-shadow:none;animation:slideUp .3s ease-out;pointer-events:auto;width:100%;box-sizing:border-box}.inspiration-board--guide .inspiration-board__header{align-items:flex-start}.inspiration-board--guide .inspiration-board__hide-btn{margin-left:auto;margin-right:0}.inspiration-board__header{display:flex;align-items:center;justify-content:space-between;margin-bottom:8px;gap:8px}.inspiration-board__title{margin:0;font-size:14px;font-weight:600;color:var(--td-text-color-primary);flex:1}.inspiration-board__guide-title-group{display:flex;align-items:center;gap:8px;flex:1;min-width:0}.inspiration-board__back-btn{display:flex;align-items:center;gap:4px;padding:4px 8px;border:none;border-radius:6px;cursor:pointer;font-size:12px;font-weight:500;background:var(--td-bg-color-container-hover);color:var(--td-text-color-secondary);transition:all .2s ease;flex-shrink:0}.inspiration-board__back-btn:hover{color:var(--td-text-color-primary);background:var(--td-bg-color-container-active)}.inspiration-board__back-btn:active{transform:scale(.97)}.inspiration-board__back-btn svg{flex-shrink:0}.inspiration-board__hide-btn{display:flex;align-items:center;gap:4px;padding:4px 10px;border:none;border-radius:6px;cursor:pointer;font-size:12px;font-weight:500;background:transparent;color:var(--td-text-color-placeholder);transition:all .2s ease;margin-right:8px}.inspiration-board__hide-btn:hover{background:var(--td-bg-color-container-hover);color:var(--td-text-color-secondary)}.inspiration-board__hide-btn:active{transform:scale(.97)}.inspiration-board__hide-btn svg{flex-shrink:0}.inspiration-board__prompt-btn{display:flex;align-items:center;gap:4px;padding:4px 10px;border:none;border-radius:6px;cursor:pointer;font-size:12px;font-weight:500;transition:all .2s ease;margin-right:8px}.inspiration-board__prompt-btn:active{transform:scale(.97)}.inspiration-board__prompt-btn svg{flex-shrink:0}.inspiration-board__pagination{display:flex;align-items:center;gap:4px}.inspiration-board__page-indicator{font-size:11px;color:var(--td-text-color-placeholder);font-variant-numeric:tabular-nums}.inspiration-board__nav-buttons{display:flex;gap:2px}.inspiration-board__nav-btn{display:flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;background:#fff;border:1px solid var(--td-component-border);border-radius:6px;cursor:pointer;color:var(--td-text-color-secondary);transition:all .2s ease}.inspiration-board__nav-btn:hover{background:var(--td-bg-color-container-hover);color:var(--td-text-color-primary);border-color:var(--td-brand-color-light)}.inspiration-board__nav-btn:active{transform:scale(.95)}.inspiration-board__grid{display:grid;grid-template-columns:repeat(3,1fr);gap:12px}.inspiration-board__guide{display:grid;gap:10px;width:100%;animation:fadeIn .3s ease-out;justify-items:stretch}.inspiration-board__guide-main{display:grid;grid-template-columns:minmax(0,1fr) minmax(220px,.78fr);gap:18px;align-items:center;width:100%;min-width:0}.inspiration-board__guide-summary{display:grid;grid-template-columns:84px minmax(0,1fr);gap:12px;align-items:center;width:100%;box-sizing:border-box;min-width:0}.inspiration-board__guide-image{width:84px;height:84px;-o-object-fit:cover;object-fit:cover;border-radius:10px;border:1px solid var(--td-component-border);background:var(--td-bg-color-container);flex-shrink:0}.inspiration-board__guide-content{display:flex;flex-direction:column;justify-content:center;min-width:0}.inspiration-board__guide-badge{width:-moz-fit-content;width:fit-content;margin-bottom:6px;padding:2px 8px;font-size:10px;font-weight:600;border-radius:4px}.inspiration-board__guide-name{margin:0 0 4px;font-size:14px;line-height:1.35;font-weight:600;color:var(--td-text-color-primary)}.inspiration-board__guide-description{margin:0;font-size:12px;line-height:1.5;color:var(--td-text-color-secondary)}.inspiration-board__guide-action{display:grid;gap:8px;min-width:0}.inspiration-board__guide-cue{position:relative;min-height:92px;overflow:hidden;border-radius:12px;background:linear-gradient(135deg,#f59e0b1a,#fff0),repeating-linear-gradient(135deg,rgba(245,158,11,.08) 0,rgba(245,158,11,.08) 1px,transparent 1px,transparent 12px)}.inspiration-board__guide-pointer{position:absolute;left:28px;top:18px;z-index:3;color:#b45309;pointer-events:none;filter:drop-shadow(0 4px 8px rgba(245,158,11,.18));transform-origin:70% 70%;animation:pointerTap 1.8s ease-in-out infinite}.inspiration-board__guide-send-preview{position:absolute;right:32px;bottom:24px;display:flex;align-items:center;justify-content:center;width:34px;height:34px;padding:0;border:0;border-radius:50%;background:#f59e0be0;color:#fff;cursor:pointer;z-index:2;box-shadow:inset 0 0 0 2px #ffffff94,0 8px 18px #f59e0b33}.inspiration-board__guide-send-preview:hover{background:#f59e0bf2}.inspiration-board__guide-tip{display:flex;align-items:center;gap:8px;width:100%;box-sizing:border-box;padding:8px 10px;border-radius:10px;background:#f59e0b1a;color:#b45309;font-size:12px;line-height:1.45;font-weight:500}.inspiration-board__guide-tip svg{flex-shrink:0}.inspiration-card{position:relative;display:flex;flex-direction:column;background:#fff;border:1px solid var(--td-component-border);border-radius:12px;overflow:hidden;cursor:pointer;transition:all .2s ease}.inspiration-card:hover{border-color:var(--td-brand-color-light);box-shadow:0 4px 12px #00000014;transform:translateY(-2px)}.inspiration-card:hover .inspiration-card__image{transform:scale(1.05)}.inspiration-card:hover .inspiration-card__hover-overlay{opacity:1}.inspiration-card:hover .inspiration-card__arrow{transform:translateY(0)}.inspiration-card:hover .inspiration-card__title{color:var(--td-brand-color)}.inspiration-card--placeholder{visibility:hidden}.inspiration-card__image-wrapper{position:relative;aspect-ratio:1/1;overflow:hidden;background:var(--td-bg-color-container)}.inspiration-card__image{width:100%;height:100%;-o-object-fit:cover;object-fit:cover;transition:transform .5s ease}.inspiration-card__badge{position:absolute;top:8px;left:8px;padding:2px 8px;font-size:10px;font-weight:600;border-radius:4px;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px);background-color:#fffffff2}.inspiration-card__hover-overlay{position:absolute;top:0;right:0;bottom:0;left:0;display:flex;align-items:center;justify-content:center;background:#0000001a;opacity:0;transition:opacity .2s ease}.inspiration-card__arrow{display:flex;align-items:center;justify-content:center;width:28px;height:28px;background:#fffffff2;border-radius:50%;box-shadow:0 2px 8px #00000026;color:var(--td-text-color-primary);transform:translateY(8px);transition:transform .2s ease}.inspiration-card__content{padding:8px}.inspiration-card__title{margin:0 0 4px;font-size:13px;font-weight:600;color:var(--td-text-color-primary);line-height:1.3;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;transition:color .2s ease}.inspiration-card__description{margin:0;font-size:11px;color:var(--td-text-color-secondary);line-height:1.4;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;height:32px}@keyframes slideUp{0%{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}@keyframes pointerTap{0%,18%,to{left:28px;top:18px;transform:rotate(-10deg) scale(1)}58%,70%{left:calc(100% - 62px);top:30px;transform:rotate(-10deg) scale(1)}78%{left:calc(100% - 62px);top:30px;transform:rotate(-10deg) scale(.82)}88%{left:calc(100% - 62px);top:30px;transform:rotate(-10deg) scale(1)}}@media(max-width:640px){.inspiration-board__guide-main{grid-template-columns:1fr;gap:10px}.inspiration-board__guide-summary{gap:10px}.inspiration-board__guide-image{width:68px;height:68px}.inspiration-board__guide-summary{grid-template-columns:68px minmax(0,1fr)}.inspiration-board__guide-cue{min-height:70px}.inspiration-board__hide-btn,.inspiration-board__prompt-btn,.inspiration-board__back-btn{padding-left:8px;padding-right:8px}}.ai-input-bar{position:fixed;bottom:12px;left:50%;transform:translate(-50%);z-index:100;width:100%;max-width:720px;padding:0 16px;box-sizing:border-box;pointer-events:none;display:flex;flex-direction:column;align-items:center;gap:8px}.ai-input-bar--with-inspiration{gap:0}.ai-input-bar--with-inspiration:before{content:"";position:absolute;top:0;left:16px;right:16px;bottom:0;background:var(--island-bg-color, #fff);border-radius:24px;box-shadow:0 2px 16px #0000001a;z-index:-1;pointer-events:none}.ai-input-bar__content-preview,.ai-input-bar__images-preview{pointer-events:auto;display:flex;flex-wrap:wrap;gap:8px;padding:0 0 0 12px;background:transparent;border-radius:0;box-shadow:none;width:100%;flex-shrink:0;box-sizing:border-box}.ai-input-bar__processing{display:flex;align-items:center;justify-content:center;padding:8px 16px;color:#9ca3af;font-size:13px}.ai-input-bar__content-item,.ai-input-bar__image-item{position:relative;width:36px;height:36px;border-radius:4px;overflow:hidden;background:#f3f4f6;flex-shrink:0;cursor:pointer;transition:transform .15s ease;display:flex;align-items:center;justify-content:center}.ai-input-bar__content-item:hover,.ai-input-bar__image-item:hover{transform:scale(1.05)}.ai-input-bar__content-item img,.ai-input-bar__image-item img{width:100%;height:100%;-o-object-fit:contain;object-fit:contain;background:#f3f4f6}.ai-input-bar__content-item--graphics{border:1px solid #f59e0b}.ai-input-bar__content-item--video{border:2px solid #3b82f6}.ai-input-bar__content-item--text{width:auto;height:auto;min-width:64px;max-width:180px;padding:8px 12px;background:#eff6ff;border:1px solid #bfdbfe;display:flex;align-items:center;justify-content:flex-start}.ai-input-bar__hover-preview{position:fixed;z-index:99999;pointer-events:none;border-radius:8px;box-shadow:0 8px 32px #00000040;overflow:hidden;background:var(--island-bg-color, #fff);padding:4px;animation:fadeIn .15s ease}.ai-input-bar__hover-preview img{max-width:300px;max-height:300px;width:auto;height:auto;-o-object-fit:contain;object-fit:contain;display:block}.ai-input-bar__hover-preview--text{padding:12px;max-width:400px;max-height:300px;overflow-y:auto}.ai-input-bar__hover-preview--video{padding:4px;max-width:400px;max-height:300px}.ai-input-bar__hover-video{width:100%;height:100%;display:flex;align-items:center;justify-content:center;background:#000;border-radius:4px;overflow:hidden}.ai-input-bar__hover-video video{max-width:400px;max-height:300px;width:100%;height:auto;display:block}.ai-input-bar__hover-text{display:flex;flex-direction:column;gap:8px}.ai-input-bar__hover-text-header{display:flex;align-items:center;gap:6px;padding-bottom:8px;border-bottom:1px solid #f3f4f6;color:#3b82f6;font-size:14px;font-weight:500}.ai-input-bar__hover-text-content{font-size:13px;line-height:1.6;color:#1f2937;white-space:pre-wrap;word-break:break-word;max-height:240px;overflow-y:auto}.ai-input-bar__video-overlay{position:absolute;top:0;left:0;right:0;bottom:0;display:flex;align-items:center;justify-content:center;background:#0000004d;pointer-events:none}.ai-input-bar__video-overlay svg{color:#fff;filter:drop-shadow(0 1px 2px rgba(0,0,0,.3))}.ai-input-bar__video-placeholder{width:100%;height:100%;display:flex;align-items:center;justify-content:center;background:linear-gradient(135deg,#667eea,#764ba2);color:#fff}.ai-input-bar__text-preview{display:flex;align-items:center;gap:6px;width:100%}.ai-input-bar__text-icon{color:#3b82f6;flex-shrink:0}.ai-input-bar__text-content{font-size:12px;color:#1f2937;line-height:1.3;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ai-input-bar__content-remove,.ai-input-bar__image-remove{position:absolute;top:2px;right:2px;width:16px;height:16px;display:flex;align-items:center;justify-content:center;background:#0009;border:none;border-radius:50%;color:#fff;cursor:pointer;opacity:0;transition:opacity .15s ease}.ai-input-bar__content-item:hover .ai-input-bar__content-remove,.ai-input-bar__content-item:hover .ai-input-bar__image-remove,.ai-input-bar__image-item:hover .ai-input-bar__content-remove,.ai-input-bar__image-item:hover .ai-input-bar__image-remove{opacity:1}.ai-input-bar__content-remove:hover,.ai-input-bar__image-remove:hover{background:#000c}.ai-input-bar__content-label{position:absolute;bottom:0;left:0;right:0;background:#f59e0be6;color:#fff;font-size:10px;text-align:center}.ai-input-bar__content-label--video{background:#3b82f6e6}.ai-input-bar__container{position:relative;pointer-events:auto;display:flex;flex-direction:column-reverse;width:100%;background:var(--island-bg-color, #fff);border-radius:24px;padding:6px 10px;box-shadow:0 2px 12px #00000014;transition:all .2s ease}.ai-input-bar__container--expanded{border-radius:16px;padding:12px}.ai-input-bar--with-inspiration .ai-input-bar__container{border-radius:0 0 24px 24px;box-shadow:none}.ai-input-bar--with-inspiration .ai-input-bar__container--expanded{border-radius:0 0 16px 16px}.ai-input-bar__bottom-bar{display:flex;align-items:center;gap:4px;width:100%;flex-shrink:0;flex-wrap:nowrap;overflow-x:auto;scrollbar-width:none}.ai-input-bar__bottom-bar::-webkit-scrollbar{display:none}.ai-input-bar__bottom-spacer{flex:1;min-width:8px}.ai-input-bar__input-area{position:relative;display:flex;flex-direction:column;gap:6px;margin-bottom:4px;width:100%;transition:max-height .2s ease}.ai-input-bar__input-area--expanded{max-height:200px;gap:8px;margin-bottom:8px}.ai-input-bar__tools{display:flex;align-items:center;gap:4px;flex-shrink:0}.ai-input-bar__prompt-row{display:flex;align-items:flex-start;gap:4px;width:100%;min-width:0}.ai-input-bar__type-toggle{display:flex;align-items:center;gap:2px}.ai-input-bar__type-btn{display:flex;align-items:center;justify-content:center;width:36px;height:36px;border:1px solid #f3f4f6;background:transparent;border-radius:8px;color:#6b7280;cursor:pointer;transition:all .15s ease}.ai-input-bar__type-btn:hover{color:#1f2937;background:#f3f4f6}.ai-input-bar__type-btn.active{background:#f59e0b;border-color:#f59e0b;color:#fff}.ai-input-bar__type-btn.active:hover{background:#d97706;border-color:#d97706}.ai-input-bar__model-selector{position:relative}.ai-input-bar__model-btn{display:flex;align-items:center;gap:4px;padding:8px 12px;border:none;background:transparent;font-size:14px;font-weight:500;color:#1f2937;cursor:pointer;transition:all .15s ease;white-space:nowrap}.ai-input-bar__model-btn:hover{color:#f59e0b}.ai-input-bar__model-btn svg{transition:transform .2s ease;color:#9ca3af}.ai-input-bar__model-btn svg.rotated{transform:rotate(180deg)}.ai-input-bar__model-menu{position:absolute;bottom:calc(100% + 8px);left:0;min-width:220px;background:var(--island-bg-color, #fff);border:1px solid #f3f4f6;border-radius:12px;box-shadow:0 4px 20px #0000001f;padding:6px;z-index:10;animation:menuSlideUp .15s ease}.ai-input-bar__model-option{display:flex;flex-direction:column;align-items:flex-start;width:100%;padding:10px 12px;border:none;background:transparent;border-radius:8px;cursor:pointer;text-align:left;transition:background .15s ease}.ai-input-bar__model-option:hover{background:#f3f4f6}.ai-input-bar__model-option.active{background:#f59e0b1a}.ai-input-bar__model-option.active .model-name{color:#f59e0b}.ai-input-bar__model-option .model-name{font-size:14px;font-weight:500;color:#1f2937}.ai-input-bar__model-option .model-desc{font-size:12px;color:#9ca3af;margin-top:2px}.ai-input-bar__upload-btn,.ai-input-bar__library-btn{display:flex;align-items:center;justify-content:center;width:36px;height:36px;border:1px solid #f3f4f6;background:transparent;border-radius:8px;color:#6b7280;cursor:pointer;transition:all .15s ease}.ai-input-bar__upload-btn:hover,.ai-input-bar__library-btn:hover{color:#1f2937;background:#f3f4f6;border-color:#9ca3af}.ai-input-bar__rich-input{position:relative;flex:1;min-width:0;width:100%}.ai-input-bar__highlight-layer{position:absolute;top:0;left:0;right:0;bottom:0;padding:6px 20px 6px 12px;font-size:15px;line-height:1.5;letter-spacing:normal;word-spacing:normal;white-space:pre-wrap;word-wrap:break-word;word-break:break-word;overflow-wrap:break-word;pointer-events:none;font-family:PingFang SC,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif;overflow:hidden;z-index:1;box-sizing:border-box;border:1px solid transparent;margin:0}.ai-input-bar__highlight-text{color:transparent}.ai-input-bar__highlight-tag{color:transparent;border-radius:3px;box-decoration-break:clone;-webkit-box-decoration-break:clone;padding:0 2px;margin:0 -2px}.ai-input-bar__highlight-tag--image{background:#e5393526}.ai-input-bar__highlight-tag--video{background:#ff980026}.ai-input-bar__highlight-tag--param{background:#9c27b026}.ai-input-bar__highlight-tag--count{background:#2196f326}.ai-input-bar__input{width:100%;border:none;background:transparent;font-size:15px;line-height:1.5;letter-spacing:normal;word-spacing:normal;text-rendering:auto;-webkit-font-smoothing:auto;color:#1f2937;resize:none;outline:none;min-height:28.5px;max-height:147px;overflow-y:hidden;padding:3px 20px 3px 12px;margin:0;font-family:PingFang SC,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif;transition:height .2s ease,min-height .2s ease,max-height .2s ease,padding .2s ease;position:relative;z-index:2;box-sizing:border-box;white-space:pre-wrap;word-wrap:break-word;word-break:break-word;overflow-wrap:break-word}.ai-input-bar__input::-webkit-scrollbar{width:8px}.ai-input-bar__input::-webkit-scrollbar-track{background:transparent}.ai-input-bar__input::-webkit-scrollbar-thumb{background:#0003;border-radius:4px}.ai-input-bar__input::-webkit-scrollbar-thumb:hover{background:#00000059}.ai-input-bar__input::-moz-placeholder{color:#9ca3af}.ai-input-bar__input::placeholder{color:#9ca3af}.ai-input-bar__input:focus{outline:none;border:none!important;box-shadow:none}.ai-input-bar__input:hover{outline:none;border:none!important;box-shadow:none}.ai-input-bar__input:disabled{opacity:.6}.ai-input-bar__input--focused{padding-top:6px;padding-bottom:6px;min-height:102px;max-height:147px}.ai-input-bar__upload-btn,.ai-input-bar__library-btn{display:flex;align-items:center;justify-content:center;width:32px;height:32px;border:none;background:transparent;border-radius:8px;color:#6b7280;cursor:pointer;transition:all .2s ease;flex-shrink:0}.ai-input-bar__upload-btn:hover,.ai-input-bar__library-btn:hover{background:#f3f4f6;color:#f59e0b}.ai-input-bar__upload-btn:active,.ai-input-bar__library-btn:active{transform:scale(.95)}.ai-input-bar__knowledge-selector{flex:0 0 auto}.ai-input-bar__knowledge-selector .knowledge-note-context-selector__trigger{width:32px;min-width:32px;height:32px;min-height:32px;border-radius:8px}.ai-input-bar__knowledge-selector .knowledge-note-context-selector__dropdown{top:auto;bottom:calc(100% + 8px);left:0;width:min(360px,100vw - 32px);max-width:calc(100vw - 32px)}.ai-input-bar__knowledge-selector .knowledge-note-context-selector__hover-summary{left:0}.ai-input-bar .generation-type-dropdown{position:relative;display:inline-flex;flex-shrink:0}.ai-input-bar .generation-type-dropdown__trigger{display:flex;align-items:center;gap:2px;padding:4px 8px;background:transparent;border:none;border-radius:4px;cursor:pointer;transition:all .15s ease;color:#1f2937;font-size:13px;font-weight:500;white-space:nowrap}.ai-input-bar .generation-type-dropdown__trigger:hover:not(:disabled){background:#f59e0b1a}.ai-input-bar .generation-type-dropdown__trigger--open{background:#f59e0b26}.ai-input-bar .generation-type-dropdown__icon-prefix{color:#f59e0b;display:flex;align-items:center;font-weight:600;margin-right:1px}.ai-input-bar .generation-type-dropdown__label{color:#6b7280}.ai-input-bar .generation-type-dropdown__chevron{color:#9ca3af;transition:transform .2s ease;margin-left:1px}.ai-input-bar .generation-type-dropdown__chevron--open{transform:rotate(180deg)}.ai-input-bar .generation-type-dropdown__menu{position:absolute;bottom:calc(100% + 8px);left:0;background:var(--island-bg-color, #fff);border:1px solid #f3f4f6;border-radius:8px;box-shadow:0 4px 16px #0000001f;padding:4px;z-index:100;min-width:100px}.ai-input-bar .generation-type-dropdown__item{display:flex;align-items:center;gap:8px;padding:8px 12px;border-radius:6px;cursor:pointer;transition:background .1s ease;font-size:13px;white-space:nowrap;color:#1f2937}.ai-input-bar .generation-type-dropdown__item:hover{background:#f3f4f6}.ai-input-bar .generation-type-dropdown__item--selected{background:#f59e0b14;color:#f59e0b;font-weight:500}.ai-input-bar .generation-type-dropdown__item-icon{display:flex;align-items:center;color:#9ca3af}.generation-type-dropdown__item--selected .ai-input-bar .generation-type-dropdown__item-icon{color:#f59e0b}.ai-input-bar .generation-type-dropdown__item-check{margin-left:auto;color:#f59e0b}.ai-input-bar .skill-dropdown{position:relative;display:inline-flex;flex-shrink:0}.ai-input-bar .skill-dropdown__trigger{display:flex;align-items:center;gap:2px;padding:4px 8px;background:transparent;border:none;border-radius:4px;cursor:pointer;transition:all .15s ease;color:#1f2937;font-size:13px;font-weight:500;white-space:nowrap}.ai-input-bar .skill-dropdown__trigger:hover:not(:disabled){background:#f59e0b1a}.ai-input-bar .skill-dropdown__trigger--open{background:#f59e0b26}.ai-input-bar .skill-dropdown__icon-prefix{color:#f59e0b;display:flex;align-items:center;font-weight:600;margin-right:1px}.ai-input-bar .skill-dropdown__label{color:#6b7280}.ai-input-bar .skill-dropdown__chevron{color:#9ca3af;transition:transform .2s ease;margin-left:1px}.ai-input-bar .skill-dropdown__chevron--open{transform:rotate(180deg)}.ai-input-bar .count-dropdown{position:relative;display:inline-flex;flex-shrink:0}.ai-input-bar .count-dropdown__trigger{display:flex;align-items:center;gap:1px;padding:4px 8px;background:transparent;border:none;border-radius:4px;cursor:pointer;transition:all .15s ease;color:#1f2937;font-size:13px;font-weight:500;white-space:nowrap}.ai-input-bar .count-dropdown__trigger:hover:not(:disabled){background:#f59e0b1a}.ai-input-bar .count-dropdown__trigger--open{background:#f59e0b26}.ai-input-bar .count-dropdown__plus-icon{color:#f59e0b;flex-shrink:0}.ai-input-bar .count-dropdown__label{color:#6b7280}.ai-input-bar .count-dropdown__chevron{color:#9ca3af;transition:transform .2s ease;margin-left:1px}.ai-input-bar .count-dropdown__chevron--open{transform:rotate(180deg)}.ai-input-bar .count-dropdown__menu{position:absolute;bottom:calc(100% + 8px);left:0;background:var(--island-bg-color, #fff);border:1px solid #f3f4f6;border-radius:8px;box-shadow:0 4px 16px #0000001f;padding:4px;z-index:100;min-width:80px}.ai-input-bar .count-dropdown__item{display:flex;align-items:center;justify-content:space-between;padding:8px 12px;border-radius:6px;cursor:pointer;transition:background .1s ease;font-size:13px;color:#1f2937}.ai-input-bar .count-dropdown__item:hover{background:#f3f4f6}.ai-input-bar .count-dropdown__item--selected{background:#f59e0b14;color:#f59e0b;font-weight:500}.ai-input-bar .count-dropdown__item-check{color:#f59e0b}.ai-input-bar__send-btn{display:flex;align-items:center;justify-content:center;width:40px;height:40px;border:none;background:#f3f4f6;border-radius:50%;color:#9ca3af;cursor:not-allowed;transition:all .2s ease;flex-shrink:0}.ai-input-bar__send-btn.active{background:#f59e0b;color:#fff;cursor:pointer;box-shadow:0 2px 8px #f59e0b66}.ai-input-bar__send-btn.active:hover{background:#d97706;transform:scale(1.05)}.ai-input-bar__send-btn.loading{background:#f59e0b99;cursor:wait;animation:pulse 1.5s infinite}.ai-input-bar__send-btn--guide{box-shadow:inset 0 0 0 3px #ffffff8c,0 2px 8px #f59e0b66;animation:sendGuidePulse 1.4s ease-in-out infinite}.ai-input-bar__send-btn--guide.active:hover{transform:none}.ai-input-bar__send-btn:disabled{pointer-events:none}@keyframes menuSlideUp{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}@keyframes sendGuidePulse{0%,to{box-shadow:inset 0 0 0 3px #ffffff8c,0 2px 8px #f59e0b66}50%{box-shadow:inset 0 0 0 3px #ffffffd1,0 6px 16px #f59e0b73}}@keyframes pulse{0%,to{opacity:1}50%{opacity:.7}}:root[data-theme=dark] .ai-input-bar__content-preview,:root[data-theme=dark] .ai-input-bar__images-preview{background:var(--color-surface-high, #2a2a2a)}:root[data-theme=dark] .ai-input-bar__content-item,:root[data-theme=dark] .ai-input-bar__image-item{background:var(--color-surface-mid, #333)}:root[data-theme=dark] .ai-input-bar__content-item--text{background:#3b82f626;border-color:#3b82f64d}:root[data-theme=dark] .ai-input-bar__text-content{color:var(--color-gray-20, #ccc)}:root[data-theme=dark] .ai-input-bar__hover-preview{background:var(--color-surface-high, #2a2a2a);box-shadow:0 8px 32px #00000080}:root[data-theme=dark] .ai-input-bar__hover-text-header{border-bottom-color:var(--color-border, #444);color:#60a5fa}:root[data-theme=dark] .ai-input-bar__hover-text-content{color:var(--color-gray-20, #ccc)}:root[data-theme=dark] .ai-input-bar__processing{color:var(--color-gray-50, #999)}:root[data-theme=dark] .ai-input-bar__container{background:var(--color-surface-high, #2a2a2a);border-color:var(--color-border, #444);box-shadow:0 2px 12px #0003}:root[data-theme=dark] .ai-input-bar__type-btn{border-color:var(--color-border, #444);color:var(--color-gray-50, #999)}:root[data-theme=dark] .ai-input-bar__type-btn:hover{color:var(--color-gray-20, #ccc);background:var(--color-surface-mid, #333)}:root[data-theme=dark] .ai-input-bar__type-btn.active{background:#f59e0b;border-color:#f59e0b;color:#fff}:root[data-theme=dark] .ai-input-bar__model-btn{color:var(--color-gray-20, #ccc)}:root[data-theme=dark] .ai-input-bar__model-btn:hover{color:#f59e0b}:root[data-theme=dark] .ai-input-bar__model-btn svg{color:var(--color-gray-50, #999)}:root[data-theme=dark] .ai-input-bar__model-menu{background:var(--color-surface-high, #2a2a2a);border-color:var(--color-border, #444)}:root[data-theme=dark] .ai-input-bar__model-option:hover{background:var(--color-surface-mid, #333)}:root[data-theme=dark] .ai-input-bar__model-option.active{background:#f59e0b26}:root[data-theme=dark] .ai-input-bar__model-option .model-name{color:var(--color-gray-20, #ccc)}:root[data-theme=dark] .ai-input-bar__model-option .model-desc{color:var(--color-gray-50, #999)}:root[data-theme=dark] .ai-input-bar__upload-btn,:root[data-theme=dark] .ai-input-bar__library-btn{border-color:var(--color-border, #444);color:var(--color-gray-50, #999)}:root[data-theme=dark] .ai-input-bar__upload-btn:hover,:root[data-theme=dark] .ai-input-bar__library-btn:hover{color:var(--color-gray-20, #ccc);background:var(--color-surface-mid, #333)}:root[data-theme=dark] .ai-input-bar__knowledge-selector .knowledge-note-context-selector__trigger{color:var(--color-gray-50, #999)}:root[data-theme=dark] .ai-input-bar__knowledge-selector .knowledge-note-context-selector__trigger:hover,:root[data-theme=dark] .ai-input-bar__knowledge-selector .knowledge-note-context-selector__trigger:focus-visible{color:#f59e0b;background:#f59e0b26}:root[data-theme=dark] .ai-input-bar__knowledge-selector.knowledge-note-context-selector--selected .knowledge-note-context-selector__trigger{color:#f59e0b;background:#f59e0b2e}:root[data-theme=dark] .ai-input-bar .generation-type-dropdown__trigger,:root[data-theme=dark] .ai-input-bar .count-dropdown__trigger,:root[data-theme=dark] .ai-input-bar .skill-dropdown__trigger{color:var(--color-gray-20, #ccc)}:root[data-theme=dark] .ai-input-bar .generation-type-dropdown__trigger:hover,:root[data-theme=dark] .ai-input-bar .count-dropdown__trigger:hover,:root[data-theme=dark] .ai-input-bar .skill-dropdown__trigger:hover{background:#f59e0b26}:root[data-theme=dark] .ai-input-bar .generation-type-dropdown__trigger--open,:root[data-theme=dark] .ai-input-bar .count-dropdown__trigger--open,:root[data-theme=dark] .ai-input-bar .skill-dropdown__trigger--open{background:#f59e0b33}:root[data-theme=dark] .ai-input-bar .generation-type-dropdown__icon-prefix,:root[data-theme=dark] .ai-input-bar .generation-type-dropdown__plus-icon,:root[data-theme=dark] .ai-input-bar .count-dropdown__icon-prefix,:root[data-theme=dark] .ai-input-bar .count-dropdown__plus-icon,:root[data-theme=dark] .ai-input-bar .skill-dropdown__icon-prefix,:root[data-theme=dark] .ai-input-bar .skill-dropdown__plus-icon{color:#f59e0b}:root[data-theme=dark] .ai-input-bar .generation-type-dropdown__label,:root[data-theme=dark] .ai-input-bar .count-dropdown__label,:root[data-theme=dark] .ai-input-bar .skill-dropdown__label{color:var(--color-gray-30, #bbb)}:root[data-theme=dark] .ai-input-bar .generation-type-dropdown__chevron,:root[data-theme=dark] .ai-input-bar .count-dropdown__chevron,:root[data-theme=dark] .ai-input-bar .skill-dropdown__chevron{color:var(--color-gray-50, #999)}:root[data-theme=dark] .ai-input-bar .generation-type-dropdown__menu,:root[data-theme=dark] .ai-input-bar .count-dropdown__menu,:root[data-theme=dark] .ai-input-bar .skill-dropdown__menu{background:var(--color-surface-high, #2a2a2a);border-color:var(--color-border, #444);box-shadow:0 4px 20px #0006}:root[data-theme=dark] .ai-input-bar .generation-type-dropdown__item,:root[data-theme=dark] .ai-input-bar .count-dropdown__item,:root[data-theme=dark] .ai-input-bar .skill-dropdown__item{color:var(--color-gray-20, #ccc)}:root[data-theme=dark] .ai-input-bar .generation-type-dropdown__item:hover,:root[data-theme=dark] .ai-input-bar .count-dropdown__item:hover,:root[data-theme=dark] .ai-input-bar .skill-dropdown__item:hover{background:var(--color-surface-mid, #333)}:root[data-theme=dark] .ai-input-bar .generation-type-dropdown__item--selected,:root[data-theme=dark] .ai-input-bar .count-dropdown__item--selected,:root[data-theme=dark] .ai-input-bar .skill-dropdown__item--selected{background:#f59e0b26;color:#f59e0b}:root[data-theme=dark] .ai-input-bar__highlight-tag--image{background:#e5393533}:root[data-theme=dark] .ai-input-bar__highlight-tag--video{background:#ff980033}:root[data-theme=dark] .ai-input-bar__highlight-tag--param{background:#9c27b033}:root[data-theme=dark] .ai-input-bar__highlight-tag--count{background:#2196f333}:root[data-theme=dark] .ai-input-bar__input{color:var(--color-gray-20, #ccc)}:root[data-theme=dark] .ai-input-bar__input::-webkit-scrollbar-thumb{background:#fff3}:root[data-theme=dark] .ai-input-bar__input::-webkit-scrollbar-thumb:hover{background:#ffffff4d}:root[data-theme=dark] .ai-input-bar__input::-moz-placeholder{color:var(--color-gray-60, #666)}:root[data-theme=dark] .ai-input-bar__input::placeholder{color:var(--color-gray-60, #666)}:root[data-theme=dark] .ai-input-bar__send-btn{background:var(--color-surface-mid, #333);color:var(--color-gray-60, #666)}:root[data-theme=dark] .ai-input-bar__send-btn.active{background:#f59e0b;color:#fff}.prompt-suggestion-panel{position:absolute;bottom:calc(100% + 8px);left:0;right:0;background:var(--island-bg-color, #fff);border-radius:16px;box-shadow:0 4px 24px #0000001f;overflow:hidden;animation:panelSlideUp .2s ease;max-height:320px;display:flex;flex-direction:column;pointer-events:auto}.prompt-suggestion-panel--empty{max-height:auto}.prompt-suggestion-panel__content{overflow-y:auto;padding:8px}.prompt-suggestion-panel__content::-webkit-scrollbar{width:6px}.prompt-suggestion-panel__content::-webkit-scrollbar-track{background:transparent}.prompt-suggestion-panel__content::-webkit-scrollbar-thumb{background:#00000026;border-radius:3px}.prompt-suggestion-panel__content::-webkit-scrollbar-thumb:hover{background:#00000040}.prompt-suggestion-panel__empty{padding:24px 16px;text-align:center;color:#9ca3af;font-size:14px}.prompt-suggestion-panel__section:not(:last-child){margin-bottom:12px;padding-bottom:12px;border-bottom:1px solid #f3f4f6}.prompt-suggestion-panel__section-header{display:flex;align-items:center;gap:6px;padding:4px 8px 8px;font-size:12px;font-weight:500;color:#9ca3af;text-transform:uppercase;letter-spacing:.5px}.prompt-suggestion-panel__section-header svg{opacity:.7}.prompt-suggestion-panel__list{display:flex;flex-direction:column;gap:2px}.prompt-suggestion-panel__item{display:flex;align-items:center;justify-content:space-between;padding:10px 12px;border-radius:10px;cursor:pointer;transition:all .15s ease;background:transparent}.prompt-suggestion-panel__item:hover,.prompt-suggestion-panel__item--highlighted{background:#f3f4f6}.prompt-suggestion-panel__item--history:hover .prompt-suggestion-panel__item-delete,.prompt-suggestion-panel__item--history.prompt-suggestion-panel__item--highlighted .prompt-suggestion-panel__item-delete{opacity:1}.prompt-suggestion-panel__item-text{flex:1;font-size:14px;line-height:1.4;color:#1f2937;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding-right:8px}.prompt-suggestion-panel__item-delete{display:flex;align-items:center;justify-content:center;width:20px;height:20px;border:none;background:transparent;border-radius:4px;color:#9ca3af;cursor:pointer;opacity:0;transition:all .15s ease;flex-shrink:0}.prompt-suggestion-panel__item-delete:hover{background:#ef44441a;color:#ef4444}@keyframes panelSlideUp{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}:root[data-theme=dark] .prompt-suggestion-panel{background:var(--color-surface-high, #2a2a2a);box-shadow:0 4px 24px #0000004d}:root[data-theme=dark] .prompt-suggestion-panel__content::-webkit-scrollbar-thumb{background:#ffffff26}:root[data-theme=dark] .prompt-suggestion-panel__content::-webkit-scrollbar-thumb:hover{background:#ffffff40}:root[data-theme=dark] .prompt-suggestion-panel__empty{color:var(--color-gray-50, #999)}:root[data-theme=dark] .prompt-suggestion-panel__section:not(:last-child){border-bottom-color:var(--color-border, #444)}:root[data-theme=dark] .prompt-suggestion-panel__section-header{color:var(--color-gray-50, #999)}:root[data-theme=dark] .prompt-suggestion-panel__item:hover{background:var(--color-surface-mid, #333)}:root[data-theme=dark] .prompt-suggestion-panel__item-text{color:var(--color-gray-20, #ccc)}:root[data-theme=dark] .prompt-suggestion-panel__item-delete{color:var(--color-gray-50, #999)}:root[data-theme=dark] .prompt-suggestion-panel__item-delete:hover{background:#ef444426;color:#f87171}@media(max-width:1024px){.ai-input-bar{max-width:600px}}@media(max-width:768px){.ai-input-bar{bottom:calc(env(safe-area-inset-bottom,0px) + 12px);padding:0 12px;max-width:calc(100% - 80px);left:calc(50% + 30px)}.ai-input-bar__container{padding:6px 8px;border-radius:20px}.ai-input-bar__content-preview,.ai-input-bar__images-preview{gap:6px}.ai-input-bar__bottom-bar{gap:2px}.ai-input-bar__hover-preview{display:none}}@media(max-width:640px){.ai-input-bar{bottom:calc(env(safe-area-inset-bottom,0px) + 8px);padding:0 8px;padding-left:calc(env(safe-area-inset-left,0px) + 8px);padding-right:calc(env(safe-area-inset-right,0px) + 8px);left:50%;transform:translate(-50%);max-width:calc(100% - 16px);width:100%}.ai-input-bar__content-preview,.ai-input-bar__images-preview{gap:4px;padding-left:8px}.ai-input-bar__content-item,.ai-input-bar__image-item{width:32px;height:32px}.ai-input-bar__content-item--text{height:auto;min-width:48px;max-width:120px;padding:6px 8px}.ai-input-bar__container{padding:4px 6px;border-radius:16px;gap:4px}.ai-input-bar__bottom-bar{gap:2px}.ai-input-bar__bottom-spacer{min-width:4px}.ai-input-bar__type-btn{width:36px;height:36px;min-width:36px}.ai-input-bar__model-btn{padding:6px 8px;font-size:13px}.ai-input-bar__upload-btn,.ai-input-bar__library-btn,.ai-input-bar__knowledge-selector .knowledge-note-context-selector__trigger{width:36px;height:36px;min-width:36px}.ai-input-bar__highlight-layer{font-size:14px;padding:4px 8px}.ai-input-bar__input{font-size:14px;padding:2px 8px;min-height:25px}.ai-input-bar__input--focused{padding-top:4px;padding-bottom:4px;min-height:92px;max-height:134px}.ai-input-bar__send-btn{width:36px;height:36px;min-width:36px}.ai-input-bar .generation-type-dropdown__trigger,.ai-input-bar .count-dropdown__trigger,.ai-input-bar .skill-dropdown__trigger{padding:4px 6px;font-size:12px}.ai-input-bar .generation-type-dropdown__menu,.ai-input-bar .count-dropdown__menu,.ai-input-bar .skill-dropdown__menu{max-width:calc(100vw - 32px)}.prompt-suggestion-panel{max-height:240px;border-radius:12px}.prompt-suggestion-panel__item{padding:8px 10px}.prompt-suggestion-panel__item-text{font-size:13px}}@media(max-width:480px){.ai-input-bar{bottom:calc(env(safe-area-inset-bottom,0px) + 6px);padding:0 6px;padding-left:calc(env(safe-area-inset-left,0px) + 6px);padding-right:calc(env(safe-area-inset-right,0px) + 6px)}.ai-input-bar__container{padding:4px}.ai-input-bar__type-btn,.ai-input-bar__upload-btn,.ai-input-bar__library-btn,.ai-input-bar__send-btn,.ai-input-bar__knowledge-selector .knowledge-note-context-selector__trigger{width:34px;height:34px;min-width:34px}.ai-input-bar__model-btn{padding:4px 6px;font-size:12px}.ai-input-bar__input{font-size:13px;min-height:23.5px}.ai-input-bar__input--focused{min-height:86px;max-height:125px}.ai-input-bar .generation-type-dropdown__label,.ai-input-bar .count-dropdown__label,.ai-input-bar .skill-dropdown__label{display:none}}.ai-input-bar__at-suggestion{position:absolute;bottom:calc(100% + 8px);left:0;min-width:280px;max-width:400px;max-height:320px;background:var(--island-bg-color, #fff);border:1px solid #e5e7eb;border-radius:12px;box-shadow:0 4px 20px #00000026;overflow:hidden;z-index:1000;animation:atSuggestionFadeIn .15s ease}.ai-input-bar__at-suggestion-header{padding:10px 12px;font-size:12px;font-weight:500;color:#6b7280;border-bottom:1px solid #f3f4f6;background:#fafafa}.ai-input-bar__at-suggestion-list{max-height:260px;overflow-y:auto;padding:4px;position:relative}.ai-input-bar__at-suggestion-list::-webkit-scrollbar{width:4px}.ai-input-bar__at-suggestion-list::-webkit-scrollbar-track{background:transparent}.ai-input-bar__at-suggestion-list::-webkit-scrollbar-thumb{background:#e5e7eb;border-radius:2px}.ai-input-bar__at-suggestion-item{display:flex;align-items:center;justify-content:space-between;padding:8px 10px;border-radius:8px;cursor:pointer;transition:background .1s ease}.ai-input-bar__at-suggestion-item:hover,.ai-input-bar__at-suggestion-item--highlighted{background:#f3f4f6}.ai-input-bar__at-suggestion-item--selected{background:#f59e0b14}.ai-input-bar__at-suggestion-item--selected:hover,.ai-input-bar__at-suggestion-item--selected.ai-input-bar__at-suggestion-item--highlighted{background:#f59e0b1f}.ai-input-bar__at-suggestion-item--selected .ai-input-bar__at-suggestion-item-label{color:#d97706;font-weight:500}.ai-input-bar__at-suggestion-item--selected .ai-input-bar__at-suggestion-item-code{color:#f59e0b}.ai-input-bar__at-suggestion-item-content{flex:1;min-width:0}.ai-input-bar__at-suggestion-item-name{display:flex;align-items:center;gap:8px}.ai-input-bar__at-suggestion-item-code{font-size:12px;font-family:SF Mono,Monaco,Menlo,monospace;color:#9ca3af;flex-shrink:0}.ai-input-bar__at-suggestion-item-label{font-size:13px;color:#1f2937;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ai-input-bar__at-suggestion-item-vip{font-size:10px;font-weight:600;color:#e91e63;background:#e91e631a;border:1px solid rgba(233,30,99,.2);padding:0 4px;border-radius:3px;flex-shrink:0}.ai-input-bar__at-suggestion-item-desc{font-size:11px;color:#9ca3af;margin-top:2px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ai-input-bar__at-suggestion-item-check{flex-shrink:0;color:#f59e0b;margin-left:8px}@keyframes atSuggestionFadeIn{0%{opacity:0;transform:translateY(4px)}to{opacity:1;transform:translateY(0)}}:root[data-theme=dark] .ai-input-bar__at-suggestion{background:var(--color-surface-high, #2a2a2a);border-color:var(--color-border, #444)}:root[data-theme=dark] .ai-input-bar__at-suggestion-header{background:var(--color-surface-mid, #333);border-bottom-color:var(--color-border, #444);color:var(--color-gray-50, #999)}:root[data-theme=dark] .ai-input-bar__at-suggestion-list::-webkit-scrollbar-thumb{background:var(--color-border, #444)}:root[data-theme=dark] .ai-input-bar__at-suggestion-item:hover,:root[data-theme=dark] .ai-input-bar__at-suggestion-item--highlighted{background:var(--color-surface-mid, #333)}:root[data-theme=dark] .ai-input-bar__at-suggestion-item--selected{background:#f59e0b1f}:root[data-theme=dark] .ai-input-bar__at-suggestion-item--selected:hover,:root[data-theme=dark] .ai-input-bar__at-suggestion-item--selected.ai-input-bar__at-suggestion-item--highlighted{background:#f59e0b2e}:root[data-theme=dark] .ai-input-bar__at-suggestion-item-code{color:var(--color-gray-50, #999)}:root[data-theme=dark] .ai-input-bar__at-suggestion-item-label{color:var(--color-gray-20, #ccc)}:root[data-theme=dark] .ai-input-bar__at-suggestion-item-desc{color:var(--color-gray-50, #999)}:root[data-theme=dark] .ai-input-bar__at-suggestion-item-vip{background:#e91e6326;border-color:#e91e634d}.generation-type-dropdown__menu{background:var(--island-bg-color, #fff);border:1px solid #f3f4f6;border-radius:8px;box-shadow:0 4px 16px #0000001f;padding:0;min-width:100px;overflow:hidden}.generation-type-dropdown__header{display:flex;align-items:center;gap:8px;padding:8px 12px;font-size:12px;font-weight:500;color:#6b7280;border-bottom:1px solid #f3f4f6;background:#fafafa}.generation-type-dropdown__list{padding:4px}.generation-type-dropdown__item{display:flex;align-items:center;gap:8px;padding:8px 12px;border-radius:6px;cursor:pointer;transition:background .1s ease;font-size:13px;white-space:nowrap;color:#1f2937}.generation-type-dropdown__item:hover,.generation-type-dropdown__item--highlighted{background:#f3f4f6}.generation-type-dropdown__item--selected{background:#f59e0b14;color:#f59e0b;font-weight:500}.generation-type-dropdown__item--selected:hover,.generation-type-dropdown__item--selected.generation-type-dropdown__item--highlighted{background:#f59e0b1f}.generation-type-dropdown__item-icon{display:flex;align-items:center;color:#9ca3af}.generation-type-dropdown__item--selected .generation-type-dropdown__item-icon{color:#f59e0b}.generation-type-dropdown__item-label{flex:1}.generation-type-dropdown__item-check{margin-left:auto;color:#f59e0b}.skill-dropdown__menu{background:var(--island-bg-color, #fff);border:1px solid #f3f4f6;border-radius:8px;box-shadow:0 4px 16px #0000001f;padding:0;min-width:120px;overflow:hidden}.skill-dropdown__header{display:flex;align-items:center;gap:8px;padding:8px 12px;font-size:12px;font-weight:500;color:#6b7280;border-bottom:1px solid #f3f4f6;background:#fafafa}.skill-dropdown__list{padding:4px}.skill-dropdown__item{display:flex;align-items:center;gap:8px;padding:8px 12px;border-radius:6px;cursor:pointer;transition:background .1s ease;font-size:13px;white-space:nowrap;color:#1f2937}.skill-dropdown__item:hover,.skill-dropdown__item--highlighted{background:#f3f4f6}.skill-dropdown__item--selected{background:#f59e0b14;color:#f59e0b;font-weight:500}.skill-dropdown__item--selected:hover,.skill-dropdown__item--selected.skill-dropdown__item--highlighted{background:#f59e0b1f}.skill-dropdown__item-label{flex:1}.skill-dropdown__item-badge{font-size:10px;padding:1px 5px;border-radius:3px;background:#f59e0b1a;color:#f59e0b;font-weight:500;margin-left:auto;margin-right:4px}.skill-dropdown__item-badge--external{background:#3b82f61a;color:#3b82f6}.skill-dropdown__search{padding:4px 8px;border-bottom:1px solid #f3f4f6}.skill-dropdown__search-input{width:100%;padding:6px 8px;font-size:12px;border:1px solid #f3f4f6;border-radius:4px;outline:none;background:var(--island-bg-color, #fff);color:inherit}.skill-dropdown__search-input:focus{border-color:#f59e0b}.skill-dropdown__search-input::-moz-placeholder{color:#999}.skill-dropdown__search-input::placeholder{color:#999}.skill-dropdown__item-check{color:#f59e0b;flex-shrink:0}.skill-dropdown__divider{height:1px;background:#f3f4f6;margin:4px 0}.skill-dropdown__add-btn{display:flex;align-items:center;gap:8px;padding:8px 12px;cursor:pointer;font-size:13px;color:#f59e0b;transition:background .1s ease}.skill-dropdown__add-btn:hover{background:#f59e0b14}.count-dropdown__menu{background:var(--island-bg-color, #fff);border:1px solid #f3f4f6;border-radius:8px;box-shadow:0 4px 16px #0000001f;padding:0;min-width:80px;overflow:hidden}.count-dropdown__header{display:flex;align-items:center;gap:8px;padding:8px 12px;font-size:12px;font-weight:500;color:#6b7280;border-bottom:1px solid #f3f4f6;background:#fafafa}.count-dropdown__list{padding:4px}.count-dropdown__item{display:flex;align-items:center;justify-content:space-between;padding:8px 12px;border-radius:6px;cursor:pointer;transition:background .1s ease;font-size:13px;white-space:nowrap;color:#1f2937}.count-dropdown__item:hover,.count-dropdown__item--highlighted{background:#f3f4f6}.count-dropdown__item--selected{background:#f59e0b14;color:#f59e0b;font-weight:500}.count-dropdown__item--selected:hover,.count-dropdown__item--selected.count-dropdown__item--highlighted{background:#f59e0b1f}.count-dropdown__item-check{margin-left:8px;color:#f59e0b}:root[data-theme=dark] .generation-type-dropdown__menu,:root[data-theme=dark] .count-dropdown__menu,:root[data-theme=dark] .skill-dropdown__menu{background:var(--color-surface-high, #2a2a2a);border-color:var(--color-border, #444);box-shadow:0 4px 20px #0006}:root[data-theme=dark] .generation-type-dropdown__header,:root[data-theme=dark] .count-dropdown__header,:root[data-theme=dark] .skill-dropdown__header{background:var(--color-surface-mid, #333);border-bottom-color:var(--color-border, #444);color:var(--color-gray-50, #999)}:root[data-theme=dark] .generation-type-dropdown__item,:root[data-theme=dark] .count-dropdown__item,:root[data-theme=dark] .skill-dropdown__item{color:var(--color-gray-20, #ccc)}:root[data-theme=dark] .generation-type-dropdown__item:hover,:root[data-theme=dark] .generation-type-dropdown__item--highlighted,:root[data-theme=dark] .count-dropdown__item:hover,:root[data-theme=dark] .count-dropdown__item--highlighted,:root[data-theme=dark] .skill-dropdown__item:hover,:root[data-theme=dark] .skill-dropdown__item--highlighted{background:var(--color-surface-mid, #333)}:root[data-theme=dark] .generation-type-dropdown__item--selected,:root[data-theme=dark] .count-dropdown__item--selected,:root[data-theme=dark] .skill-dropdown__item--selected{background:#f59e0b26;color:#f59e0b}:root[data-theme=dark] .generation-type-dropdown__item--selected:hover,:root[data-theme=dark] .generation-type-dropdown__item--selected.generation-type-dropdown__item--highlighted,:root[data-theme=dark] .generation-type-dropdown__item--selected.count-dropdown__item--highlighted,:root[data-theme=dark] .generation-type-dropdown__item--selected.skill-dropdown__item--highlighted,:root[data-theme=dark] .count-dropdown__item--selected:hover,:root[data-theme=dark] .count-dropdown__item--selected.generation-type-dropdown__item--highlighted,:root[data-theme=dark] .count-dropdown__item--selected.count-dropdown__item--highlighted,:root[data-theme=dark] .count-dropdown__item--selected.skill-dropdown__item--highlighted,:root[data-theme=dark] .skill-dropdown__item--selected:hover,:root[data-theme=dark] .skill-dropdown__item--selected.generation-type-dropdown__item--highlighted,:root[data-theme=dark] .skill-dropdown__item--selected.count-dropdown__item--highlighted,:root[data-theme=dark] .skill-dropdown__item--selected.skill-dropdown__item--highlighted{background:#f59e0b33}:root[data-theme=dark] .skill-dropdown__header{background:var(--color-surface-mid, #333);border-bottom-color:var(--color-border, #444);color:var(--color-gray-50, #999)}:root[data-theme=dark] .skill-dropdown__divider{background:var(--color-border, #444)}:root[data-theme=dark] .skill-dropdown__add-btn{color:#f59e0b}:root[data-theme=dark] .skill-dropdown__add-btn:hover{background:#f59e0b26}:root[data-theme=dark] .skill-dropdown__item-badge{background:#f59e0b33}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r,dA as ct,j as t,d8 as ce,er as _,ba as ot,M as u,E as b,ke as ts,b$ as ye,kf as dt,y as tt,gr as _e,kg as ss,c1 as ne,i3 as as,ck as rs,e0 as st,bg as p,dB as q,n as at,d as rt,kh as ut,ki as ls,cq as is,kj as ns,p as cs,c7 as os,c8 as ds,kk as us,dc as ms,kl as ps,id as hs,hx as fs,g6 as se,jd as gs,ei as xs,am as vs,h9 as lt,gb as it,bz as Ce,c as Cs,gd as nt,km as ys,aT as _s,aN as js,aO as ws}from"./startup-app-DxX-P1pm.js";import{T as Is,C as bs,u as mt,V as ks,a as Ss}from"./useCharacters-DzXMuknh.js";import{M as Ds,U as Ns}from"./ai-chat-B5qFht2H.js";import{f as Es,B as Us,I as Ms,m as $s,g as ie,r as Ts}from"./tool-windows-BIjc1zsU.js";/* empty css */import"./startup-runtime-DTmhLESk.js";const Ls=30,zs=({onPreviewOpen:l,onDownload:f,className:o})=>{const[d,L]=r.useState([]),[z,j]=r.useState(!0),[k,S]=r.useState(!1),[P,R]=r.useState(!1),x=r.useRef(0),O=r.useRef(null),E=r.useCallback(async m=>{try{return await ct.getArchivedTasks(m,Ls)}catch{return{tasks:[],hasMore:!1}}},[]);r.useEffect(()=>{let m=!1;return j(!0),x.current=0,E(0).then(C=>{m||(L(C.tasks),R(C.hasMore),x.current=C.tasks.length,j(!1))}),()=>{m=!0}},[E]);const V=r.useCallback(async()=>{if(k||!P)return;S(!0);const m=await E(x.current);L(C=>[...C,...m.tasks]),R(m.hasMore),x.current+=m.tasks.length,S(!1)},[k,P,E]);return r.useEffect(()=>{const m=O.current;if(!m)return;const C=()=>{m.scrollHeight-m.scrollTop-m.clientHeight<200&&V()};return m.addEventListener("scroll",C,{passive:!0}),()=>m.removeEventListener("scroll",C)},[V]),z?t.jsxs("div",{className:"task-queue-panel__empty",children:[t.jsx(ce,{size:"small"}),t.jsx("div",{className:"task-queue-panel__empty-text",children:"加载历史任务..."})]}):d.length===0?t.jsxs("div",{className:"task-queue-panel__empty",children:[t.jsx("div",{className:"task-queue-panel__empty-icon",children:"📦"}),t.jsx("div",{className:"task-queue-panel__empty-text",children:"暂无历史任务"})]}):t.jsxs("div",{ref:O,className:o,style:{overflow:"auto",height:"100%"},children:[d.map(m=>t.jsx(Is,{task:m,onPreviewOpen:l?()=>l(m.id):void 0,onDownload:f},m.id)),P&&t.jsx("div",{style:{padding:"12px",textAlign:"center"},children:k?t.jsx(ce,{size:"small"}):t.jsx(_,{size:"small",variant:"text",theme:"default",onClick:V,children:"加载更多"})})]})},qs=({character:l,onDelete:f,onSelect:o,compact:d=!1})=>{const[L,z]=r.useState(!1),j=l.status==="processing"||l.status==="pending",k=l.status==="failed",S=l.status==="completed",P=r.useCallback(async m=>{if(m.stopPropagation(),!l.username)return;const C=`@${l.username}`;try{await ot(C),u.success(`已复制: ${C}`)}catch(v){console.error("Failed to copy:",v),u.error("复制失败")}},[l.username]),R=r.useCallback(()=>{S&&o&&o(l)},[S,o,l]),x=r.useCallback(m=>{m.stopPropagation(),f==null||f(l.id)},[f,l.id]),O=r.useCallback(m=>{m.stopPropagation(),S&&l.profilePictureUrl&&z(!0)},[S,l.profilePictureUrl]),E=()=>l.profilePictureUrl||S?t.jsx(b,{content:"点击查看大图",children:t.jsx(bs,{characterId:l.id,profilePictureUrl:l.profilePictureUrl,alt:l.username||"Character",className:"character-card__avatar-img",onClick:O})}):t.jsx("div",{className:"character-card__avatar-placeholder",children:t.jsx(dt,{})}),V=()=>j?t.jsxs("div",{className:"character-card__status character-card__status--processing",children:[t.jsx(ce,{size:"small"}),t.jsx("span",{children:"创建中..."})]}):k?t.jsxs("div",{className:"character-card__status character-card__status--failed",children:["创建失败: ",l.error||"未知错误"]}):null;return d?t.jsxs("div",{className:`character-card character-card--compact ${j?"character-card--loading":""} ${k?"character-card--failed":""}`,onClick:R,children:[t.jsx("div",{className:"character-card__avatar",children:E()}),t.jsx("span",{className:"character-card__username-text",children:l.username||"创建中..."})]}):t.jsxs("div",{className:`character-card ${j?"character-card--loading":""} ${k?"character-card--failed":""}`,onClick:R,children:[t.jsx("div",{className:"character-card__avatar",children:E()}),t.jsxs("div",{className:"character-card__info",children:[S&&l.username?t.jsx(b,{content:"点击复制",children:t.jsxs("div",{className:"character-card__username",onClick:P,children:["@",l.username,t.jsx(ts,{className:"character-card__username-copy"})]})}):t.jsx("div",{className:"character-card__username",style:{cursor:"default"},children:j?"创建中...":"角色"}),l.id&&t.jsx(b,{content:l.id,placement:"bottom",children:t.jsx("div",{className:"character-card__source",children:l.id})}),V()]}),t.jsx("div",{className:"character-card__actions",children:t.jsx(b,{content:"删除角色",children:t.jsx(_,{size:"small",variant:"text",theme:"danger",icon:t.jsx(ye,{}),"data-track":"character_click_delete",onClick:x})})}),l.profilePictureUrl&&t.jsx(Ds,{visible:L,onClose:()=>z(!1),items:[{url:l.profilePictureUrl,type:"image",title:`@${l.username||"Character"}`}]})]})},Ps=({onSelect:l,completedOnly:f=!1,maxItems:o,showHeader:d=!0,title:L="角色列表"})=>{const{characters:z,completedCharacters:j,pendingCharacters:k,isLoading:S,deleteCharacter:P,refreshCharacters:R}=mt(),[x,O]=tt.useState(null),E=tt.useMemo(()=>{let v=f?j:z;return v=[...v].sort((oe,de)=>de.createdAt-oe.createdAt),o&&v.length>o&&(v=v.slice(0,o)),v},[f,z,j,o]),V=r.useCallback(v=>{O(v)},[]),m=r.useCallback(async()=>{if(!x)return;await P(x)?u.success("角色已删除"):u.error("删除失败"),O(null)},[x,P]),C=r.useCallback(async()=>{await R(),u.success("已刷新")},[R]);return S?t.jsxs("div",{className:"character-list__loading",children:[t.jsx(ce,{size:"small"}),t.jsx("span",{children:"加载中..."})]}):E.length===0?t.jsxs("div",{className:"character-list",children:[d&&t.jsxs("div",{className:"character-list__header",children:[t.jsx("h4",{children:L}),t.jsx(_,{size:"small",variant:"text",icon:t.jsx(_e,{}),"data-track":"character_click_refresh",onClick:C})]}),t.jsxs("div",{className:"character-list__empty",children:[t.jsx("div",{className:"character-list__empty-icon",children:t.jsx(ss,{})}),t.jsx("div",{children:"暂无角色"}),t.jsx("div",{style:{fontSize:"12px",marginTop:"4px",color:"#999"},children:"从已完成的 Sora-2 视频中提取角色"})]})]}):t.jsxs("div",{className:"character-list",children:[d&&t.jsxs("div",{className:"character-list__header",children:[t.jsxs("h4",{children:[L,k.length>0&&t.jsxs("span",{style:{fontWeight:"normal",fontSize:"12px",color:"#666",marginLeft:"8px"},children:["(",k.length," 创建中)"]})]}),t.jsx(_,{size:"small",variant:"text",icon:t.jsx(_e,{}),"data-track":"character_click_refresh",onClick:C})]}),t.jsx("div",{className:"character-list__items",children:E.map(v=>t.jsx(qs,{character:v,onDelete:V,onSelect:l},v.id))}),t.jsx(ne,{open:!!x,title:"确认删除",description:"确定要删除此角色吗?删除后将无法在提示词中使用该角色。",confirmText:"删除",cancelText:"取消",danger:!0,onOpenChange:v=>{v||O(null)},onConfirm:m})]})},{TabPanel:te}=ut,Rs="task-queue-drawer-width";function Os(l){var f,o,d;return Array.isArray((f=l.result)==null?void 0:f.urls)&&l.result.urls.length>0?l.result.urls.length:(o=l.result)!=null&&o.url||(d=l.result)!=null&&d.chatResponse||se(l)?1:0}function As(l){const f=Os(l);return{taskId:l.id,taskType:l.type,taskStatus:l.status,model:typeof l.params.model=="string"&&l.params.model.trim()?l.params.model:void 0,resultCount:f||void 0,hasMultipleResults:f>1}}const Qs=({expanded:l,onClose:f,onTaskAction:o})=>{const{tasks:d,activeTasks:L,completedTasks:z,failedTasks:j,cancelledTasks:k,isLoading:S,isLoadingMore:P,hasMore:R,totalCount:x,loadedCount:O,loadMore:E,retryTask:V,deleteTask:m,clearCompleted:C,clearFailed:v,batchDeleteTasks:oe,batchRetryTasks:de,batchCancelTasks:pt}=as(),{board:B,openDialog:je}=rs(),{characters:we}=mt(),[A,ht]=r.useState("all"),[ft,ue]=r.useState(!1),[Ie,gt]=r.useState("completed"),[ae,xt]=r.useState(""),[D,Y]=r.useState("all"),[Vs,be]=r.useState(null),[vt,me]=r.useState(!1),[Ct,yt]=r.useState(0),[_t,jt]=r.useState("single"),[ke,pe]=r.useState(!1),[Se,he]=r.useState(""),[wt,fe]=r.useState(!1),[ge,De]=r.useState(null),[Ne,xe]=r.useState(null),[H,ee]=r.useState(!1),[g,Q]=r.useState(new Set),[It,ve]=r.useState(!1),[Ee,Ue]=r.useState(null),{isConfigured:bt}=Es(),[re,Me]=r.useState(!1),[kt,le]=r.useState(0),$e=D==="character";r.useEffect(()=>{st.initCacheStatus()},[]),r.useEffect(()=>{if(!l)return;let s=!1;return ct.getArchivedTaskCount().then(e=>{s||Ue(e)}).catch(()=>{s||Ue(0)}),()=>{s=!0}},[l,A]);const W=r.useMemo(()=>{let s;switch(A){case"all":s=d;break;case"active":s=L;break;case"completed":s=z;break;case"failed":s=j;break;case"cancelled":s=k;break;case"archived":return[];default:s=d}if(D!=="all"&&D!=="character"&&(s=s.filter(e=>e.type===(D==="image"?p.IMAGE:D==="audio"?p.AUDIO:D==="text"?p.CHAT:p.VIDEO))),ae.trim()){const e=ae.toLowerCase().trim();s=s.filter(a=>{var c,y,w,I,K;return a.params.prompt.toLowerCase().includes(e)||String(((c=a.result)==null?void 0:c.title)||"").toLowerCase().includes(e)||String(((y=a.result)==null?void 0:y.lyricsTitle)||"").toLowerCase().includes(e)||String(((w=a.result)==null?void 0:w.lyricsText)||"").toLowerCase().includes(e)||String(((I=a.result)==null?void 0:I.chatResponse)||"").toLowerCase().includes(e)||(((K=a.result)==null?void 0:K.lyricsTags)||[]).some(n=>String(n).toLowerCase().includes(e))})}return[...s].sort((e,a)=>a.createdAt-e.createdAt)},[A,d,L,z,j,k,D,ae]),St=s=>{gt(s),ue(!0)},Dt=()=>{Ie==="completed"?C():v(),ue(!1)},Nt=s=>{V(s),o==null||o("retry",s)},Et=s=>{De(s),fe(!0)},Ut=()=>{ge&&(m(ge),o==null||o("delete",ge)),fe(!1),De(null)},Mt=()=>{H?(ee(!1),Q(new Set)):ee(!0)},$t=(s,e)=>{Q(a=>{const c=new Set(a);return e?c.add(s):c.delete(s),c})},Tt=()=>{const s=W.map(e=>e.id);Q(new Set(s))},Lt=()=>{Q(new Set)},zt=()=>{g.size!==0&&ve(!0)},qt=()=>{oe(Array.from(g)),Q(new Set),ee(!1),ve(!1),u.success(`已删除 ${g.size} 个任务`)},Pt=()=>{const s=Array.from(g).filter(e=>{const a=d.find(c=>c.id===e);return(a==null?void 0:a.status)===q.FAILED||(a==null?void 0:a.status)===q.CANCELLED});if(s.length===0){u.warning("没有可重试的任务");return}de(s),Q(new Set),ee(!1),u.success(`已重试 ${s.length} 个任务`)},Te=r.useMemo(()=>Array.from(g).filter(s=>{const e=d.find(a=>a.id===s);return(e==null?void 0:e.status)===q.FAILED||(e==null?void 0:e.status)===q.CANCELLED}).length,[g,d]),Le=r.useMemo(()=>Array.from(g).filter(s=>{const e=d.find(a=>a.id===s);return(e==null?void 0:e.status)===q.PENDING||(e==null?void 0:e.status)===q.PROCESSING}).length,[g,d]),ze=r.useMemo(()=>Array.from(g).filter(s=>{const e=d.find(a=>a.id===s);return(e==null?void 0:e.status)===q.COMPLETED&&((e==null?void 0:e.type)===p.IMAGE||(e==null?void 0:e.type)===p.VIDEO)}).length,[g,d]),Z=r.useMemo(()=>({all:d.length,image:d.filter(s=>s.type===p.IMAGE).length,video:d.filter(s=>s.type===p.VIDEO).length,audio:d.filter(s=>s.type===p.AUDIO).length,text:d.filter(s=>s.type===p.CHAT).length,character:we.length}),[d,we]),Rt=()=>{const s=Array.from(g).filter(e=>{const a=d.find(c=>c.id===e);return(a==null?void 0:a.status)===q.PENDING||(a==null?void 0:a.status)===q.PROCESSING});if(s.length===0){u.warning("没有可取消的进行中任务");return}pt(s),Q(new Set),ee(!1),u.success(`已取消 ${s.length} 个任务`)},Ot=async()=>{const s=Array.from(g).filter(e=>{const a=d.find(c=>c.id===e);return(a==null?void 0:a.status)===q.COMPLETED&&((a==null?void 0:a.type)===p.IMAGE||(a==null?void 0:a.type)===p.VIDEO)});if(!(s.length===0||re)){Me(!0),le(0);try{const e=await $s.syncMultipleTasks(s,(a,c)=>{le(Math.round(a/c*100))});le(100),e.succeeded>0&&u.success(`已同步 ${e.succeeded} 个任务`),e.failed>0&&u.warning(`${e.failed} 个任务同步失败`)}catch(e){console.error("[TaskQueuePanel] Batch sync failed:",e),u.error("同步失败,请稍后重试")}finally{Me(!1),le(0)}}},qe=async s=>{const e=d.find(c=>c.id===s);if(e&&se(e)){u.info("歌词任务支持复制或插入画布");return}if(!e)return;const a=gs(e);if(a.length!==0)try{const c=await xs(a);c.openedCount>0&&c.downloadedCount===0?u.success(c.openedCount>1?`已打开 ${c.openedCount} 个链接,请在新标签页下载`:"资源不支持直接下载,已打开链接"):u.success(e.type===p.AUDIO?a.length>1?"多条音频已开始下载":"音频下载成功":a.length>1?"多图已开始下载":"下载成功"),vs.track("generation_result_download",{...As(e),downloadedCount:c.downloadedCount,openedCount:c.openedCount}),o==null||o("download",s)}catch(c){console.error("Download failed:",c),u.error("下载失败,请稍后重试")}},At=async s=>{const e=d.find(c=>c.id===s);if(!e||!se(e)){u.warning("暂无可复制的歌词");return}const a=it(e);if(!a.trim()){u.warning("暂无可复制的歌词");return}try{await ot(a),u.success("歌词已复制"),o==null||o("copy",s)}catch(c){console.error("Failed to copy lyrics:",c),u.error("复制失败,请稍后重试")}},Vt=async s=>{var a,c,y,w,I,K,n,J,F,X,N,U;const e=d.find(i=>i.id===s);if(!e||!B){console.warn("Cannot insert: task result or board not available"),u.warning("无法插入:白板未就绪");return}if(!((a=e.result)!=null&&a.url)&&!((y=(c=e.result)==null?void 0:c.urls)!=null&&y.length)&&!se(e)){const i=e.type===p.CHAT?(w=e.result)==null?void 0:w.chatResponse:void 0;if(i!=null&&i.trim()){const h=(e.params.prompt||"").slice(0,20)||void 0;await ie({items:[{type:"text",content:i,label:h}]}),u.success("文本已插入到白板"),Ce.markAsInserted(s,"manual"),o==null||o("insert",s);return}console.warn("Cannot insert: task result is empty"),u.warning("无法插入:任务结果为空");return}try{const i=e.result;if(e.type===p.IMAGE){const h=(I=i.urls)!=null&&I.length?i.urls:[i.url];for(const M of h)await rt(B,at(M));u.success(h.length>1?"多图已插入到白板":"图片已插入到白板")}else if(e.type===p.VIDEO)await Cs(B,i.url),u.success("视频已插入到白板");else if(e.type===p.AUDIO){if(se(e)){const G=nt(i,e.params.title||e.params.prompt)||(e.params.prompt||"").slice(0,20)||void 0;await ie({items:[{type:"text",content:it(e),label:G,metadata:{title:nt(i,e.params.title||e.params.prompt),tags:ys(i)}}]}),u.success("歌词已插入到白板"),Ce.markAsInserted(s,"manual"),o==null||o("insert",s);return}const h=Ts(i),M=(n=(K=i.clips)==null?void 0:K[0])==null?void 0:n.duration,$={title:i.title||e.params.title||e.params.prompt,duration:typeof M=="number"?M:i.duration,previewImageUrl:i.previewImageUrl,tags:typeof e.params.tags=="string"?e.params.tags:void 0,mv:typeof e.params.mv=="string"?e.params.mv:void 0,prompt:e.params.prompt,providerTaskId:i.providerTaskId||e.remoteId,clipId:i.primaryClipId||((F=(J=i.clips)==null?void 0:J[0])==null?void 0:F.clipId)||((N=(X=i.clips)==null?void 0:X[0])==null?void 0:N.id)||((U=i.clipIds)==null?void 0:U[0]),clipIds:i.clipIds};h.length===1?await _s(B,h[0],$):await ie({items:h.map((G,T)=>{var Ve,Fe,Ge,Be,He,We,Ke,Qe,Ye,Ze,Je,Xe,et;return{type:"audio",content:G,groupId:`task-audio-${e.id}`,dimensions:{width:ws,height:js},metadata:{...$,title:((Fe=(Ve=i.clips)==null?void 0:Ve[T])==null?void 0:Fe.title)||`${$.title||"Audio"} ${T+1}`,previewImageUrl:((Be=(Ge=i.clips)==null?void 0:Ge[T])==null?void 0:Be.imageLargeUrl)||((We=(He=i.clips)==null?void 0:He[T])==null?void 0:We.imageUrl)||$.previewImageUrl,duration:typeof((Qe=(Ke=i.clips)==null?void 0:Ke[T])==null?void 0:Qe.duration)=="number"?i.clips[T].duration||void 0:$.duration,clipId:((Ze=(Ye=i.clips)==null?void 0:Ye[T])==null?void 0:Ze.clipId)||((Xe=(Je=i.clips)==null?void 0:Je[T])==null?void 0:Xe.id)||((et=i.clipIds)==null?void 0:et[T])||$.clipId}}})}),u.success(h.length>1?"多条音频卡片已插入到白板":"音频卡片已插入到白板")}else if(e.type===p.CHAT){const h=i.chatResponse||"",M=(e.params.prompt||"").slice(0,20)||void 0;await ie({items:[{type:"text",content:h,label:M}]}),u.success("文本已插入到白板")}Ce.markAsInserted(s,"manual"),o==null||o("insert",s)}catch(i){console.error("Failed to insert to board:",i),u.error(`插入失败: ${i instanceof Error?i.message:"未知错误"}`)}},Ft=s=>{var a,c,y,w;const e=d.find(I=>I.id===s);if(!e){console.warn("Cannot edit: task not found");return}if(e.type===p.IMAGE){const I={initialPrompt:e.params.prompt,initialWidth:e.params.width,initialHeight:e.params.height,initialImages:e.params.uploadedImages,initialResultUrl:(a=e.result)==null?void 0:a.url,initialResultUrls:(c=e.result)==null?void 0:c.urls};je(lt.aiImageGeneration,I)}else if(e.type===p.VIDEO){const I={initialPrompt:e.params.prompt,initialDuration:typeof e.params.seconds=="string"?parseInt(e.params.seconds,10):e.params.seconds,initialModel:e.params.model,initialSize:e.params.size,initialImages:e.params.uploadedImages,initialResultUrl:(y=e.result)==null?void 0:y.url,initialResultUrls:(w=e.result)==null?void 0:w.urls};je(lt.aiVideoGeneration,I)}else if(e.type===p.AUDIO){u.info("音频任务暂不支持从任务面板直接编辑");return}o==null||o("edit",s)},Gt=s=>{const e=d.find(a=>a.id===s);e&&(xe(e),o==null||o("extractCharacter",s))},Pe=r.useMemo(()=>{const s=new Set;return W.filter(e=>{var a,c,y,w;return e.status!==q.COMPLETED||!((a=e.result)!=null&&a.url)&&!((y=(c=e.result)==null?void 0:c.urls)!=null&&y.length)||e.type!==p.IMAGE&&e.type!==p.VIDEO&&!(e.type===p.AUDIO&&((w=e.result)==null?void 0:w.resultKind)!=="lyrics")||s.has(e.id)?!1:(s.add(e.id),!0)})},[W]),{previewMediaItems:Bt,taskIdToPreviewConfig:Re}=r.useMemo(()=>{var a,c,y,w,I,K;const s=[],e=new Map;for(const n of Pe){const J=s.length,F=((a=n.result)==null?void 0:a.title)||n.params.title||((c=n.params.prompt)==null?void 0:c.substring(0,50))||"媒体预览";if(n.type===p.AUDIO){const N=((w=(y=n.result)==null?void 0:y.clips)==null?void 0:w.filter(h=>!!h.audioUrl).map((h,M)=>{var $,G,T;return{id:h.clipId||h.id||`${n.id}-${M}`,url:h.audioUrl,type:"audio",title:h.title||(($=n.result)!=null&&$.clips&&n.result.clips.length>1?`${F} (${M+1}/${n.result.clips.length})`:F),posterUrl:h.imageLargeUrl||h.imageUrl||((G=n.result)==null?void 0:G.previewImageUrl),duration:typeof h.duration=="number"?h.duration:(T=n.result)==null?void 0:T.duration,prompt:n.params.prompt,tags:typeof n.params.tags=="string"?n.params.tags:void 0,artist:n.params.model||n.params.mv||"Aitu",album:"Aitu Generated"}}))??[],U=(I=n.result.urls)!=null&&I.length?n.result.urls:n.result.url?[n.result.url]:[],i=N.length>0?N:U.map((h,M)=>{var $,G;return{id:U.length>1?`${n.id}-${M}`:n.id,url:h,type:"audio",title:U.length>1?`${F} (${M+1}/${U.length})`:F,posterUrl:($=n.result)==null?void 0:$.previewImageUrl,duration:(G=n.result)==null?void 0:G.duration,prompt:n.params.prompt,tags:typeof n.params.tags=="string"?n.params.tags:void 0,artist:n.params.model||n.params.mv||"Aitu",album:"Aitu Generated"}});s.push(...i)}else{const N=(K=n.result.urls)!=null&&K.length?n.result.urls:[n.result.url],U=n.type===p.VIDEO?"video":"image";for(let i=0;i<N.length;i++){const h=U==="image"?at(N[i]):N[i];s.push({id:N.length>1?`${n.id}-${i}`:n.id,url:h,type:U,title:N.length>1?`${F} (${i+1}/${N.length})`:F})}}const X=s.length-J;e.set(n.id,{mode:n.type===p.AUDIO&&X>1?"compare":"single",index:n.type===p.AUDIO&&X>1?Array.from({length:Math.min(X,4)},(N,U)=>J+U):J})}return{previewMediaItems:s,taskIdToPreviewConfig:e}},[Pe]),Oe=r.useCallback(s=>{be(s);const e=Re.get(s);e!==void 0&&(jt(e.mode),yt(e.index),me(!0))},[Re]),Ht=r.useCallback(()=>{be(null),me(!1)},[]),Wt=r.useCallback(s=>{s.type==="image"&&(he(s.url),pe(!0),me(!1))},[]),Kt=r.useCallback(async s=>{if(B)try{const e=`edited-image-${Date.now()}`,a=`/__aitu_cache__/image/${e}.png`,y=await(await fetch(s)).blob();await st.cacheMediaFromBlob(a,y,"image",{taskId:e}),await rt(B,a),pe(!1),he("")}catch(e){console.error("Failed to insert edited image:",e)}},[B]),Qt=r.useCallback(()=>{f==null||f()},[f]),Yt=x>0?x:d.length,Ae="这里只显示最近 100 个任务,更早的任务会自动移到“历史”中继续保留。",Zt=t.jsx(b,{content:Ae,children:t.jsxs("span",{children:["全部 (",Yt,")"]})}),Jt=Ee===null?"历史":`历史 (${Ee})`,Xt=x>=100?`已加载最近 ${x} 个任务,较早任务已移至“历史”`:`已加载全部 ${x} 个任务`,es=t.jsxs("div",{className:"task-queue-panel__filters-container",children:[t.jsxs(ut,{value:A,onChange:s=>ht(s),children:[t.jsx(te,{value:"all",label:Zt}),t.jsx(te,{value:"active",label:`生成中 (${L.length})`}),t.jsx(te,{value:"failed",label:`失败 (${j.length})`}),t.jsx(te,{value:"completed",label:`已完成 (${z.length})`}),t.jsx(te,{value:"archived",label:Jt})]}),A!=="archived"&&t.jsxs("div",{className:"task-queue-panel__filters",children:[t.jsxs("div",{className:"task-queue-panel__type-filters",children:[t.jsx(b,{content:`全部 (${Z.all})`,children:t.jsx(_,{size:"small",variant:"text",shape:"square",onClick:()=>Y("all"),className:D==="all"?"task-queue-panel__filter-btn--active":"",children:t.jsx(ls,{size:"16px"})})}),t.jsx(b,{content:`图片 (${Z.image})`,children:t.jsx(_,{size:"small",variant:"text",shape:"square",onClick:()=>Y("image"),className:D==="image"?"task-queue-panel__filter-btn--active":"",children:t.jsx(is,{size:"16px"})})}),t.jsx(b,{content:`视频 (${Z.video})`,children:t.jsx(_,{size:"small",variant:"text",shape:"square",onClick:()=>Y("video"),className:D==="video"?"task-queue-panel__filter-btn--active":"",children:t.jsx(ns,{size:"16px"})})}),t.jsx(b,{content:`音频 (${Z.audio})`,children:t.jsx(_,{size:"small",variant:"text",shape:"square",onClick:()=>Y("audio"),className:D==="audio"?"task-queue-panel__filter-btn--active":"",children:t.jsx(cs,{size:16,strokeWidth:1.9})})}),t.jsx(b,{content:`文本 (${Z.text})`,children:t.jsx(_,{size:"small",variant:"text",shape:"square",onClick:()=>Y("text"),className:D==="text"?"task-queue-panel__filter-btn--active":"",children:"文"})}),t.jsx(b,{content:`角色 (${Z.character})`,children:t.jsx(_,{size:"small",variant:"text",shape:"square",onClick:()=>Y("character"),className:D==="character"?"task-queue-panel__filter-btn--active":"",children:t.jsx(dt,{size:"16px"})})})]}),t.jsxs("div",{className:"task-queue-panel__search-row",children:[t.jsx(os,{value:ae,onChange:s=>xt(s),placeholder:"搜索...",clearable:!0,prefixIcon:t.jsx(ds,{}),size:"small",className:"task-queue-panel__search-input"}),t.jsxs("div",{className:"task-queue-panel__filter-actions",children:[t.jsx(b,{content:H?"退出多选":"批量操作",children:t.jsx(_,{size:"small",variant:H?"base":"outline",theme:H?"primary":"default",icon:t.jsx(us,{}),"data-track":"task_click_toggle_selection",onClick:Mt,children:H?"退出":"多选"})}),j.length>0&&!H&&t.jsx(b,{content:"清除失败",children:t.jsx(_,{size:"small",variant:"text",theme:"default",icon:t.jsx(ye,{style:{color:"var(--td-text-color-placeholder)"}}),"data-track":"task_click_clear_failed",onClick:()=>St("failed"),className:"task-queue-panel__clear-btn"})})]})]})]}),H&&!$e&&t.jsxs("div",{className:"task-queue-panel__batch-actions",children:[t.jsxs("div",{className:"task-queue-panel__batch-select",children:[t.jsx(ms,{checked:g.size===W.length&&W.length>0,indeterminate:g.size>0&&g.size<W.length,onChange:s=>s?Tt():Lt()}),t.jsxs("span",{className:"task-queue-panel__batch-count",children:["已选 ",g.size," / ",W.length]})]}),t.jsxs("div",{className:"task-queue-panel__batch-buttons",children:[Le>0&&t.jsxs(_,{size:"small",variant:"outline",theme:"warning",icon:t.jsx(ps,{}),"data-track":"task_click_batch_cancel",onClick:Rt,children:["取消 (",Le,")"]}),Te>0&&t.jsxs(_,{size:"small",theme:"primary",icon:t.jsx(_e,{}),"data-track":"task_click_batch_retry",onClick:Pt,children:["重试 (",Te,")"]}),bt&&ze>0&&t.jsx(b,{content:"同步选中的任务到云端",placement:"bottom",children:t.jsx(_,{size:"small",variant:"outline",icon:t.jsx(hs,{}),"data-track":"task_click_batch_sync",onClick:Ot,disabled:re,loading:re,children:re?`${kt}%`:`同步 (${ze})`})}),t.jsxs(_,{size:"small",variant:"text",theme:"default",icon:t.jsx(ye,{}),"data-track":"task_click_batch_delete",onClick:zt,disabled:g.size===0,children:["删除 (",g.size,")"]})]})]})]});return t.jsxs(t.Fragment,{children:[t.jsx(Us,{isOpen:l,onClose:Qt,title:"任务队列",filterSection:es,position:"toolbar-right",width:"responsive",storageKey:Rs,pinStorageKey:fs.task,showBackdrop:!1,closeOnEsc:!1,showCloseButton:!0,className:"task-queue-panel",contentClassName:"task-queue-panel__content",resizable:!0,minWidth:320,maxWidth:1024,"data-testid":"task-queue-panel",children:$e?t.jsx(Ps,{showHeader:!1,title:""}):A==="archived"?t.jsx(zs,{onPreviewOpen:Oe,onDownload:qe,className:"task-queue-panel__list"}):t.jsx(ks,{tasks:W,selectionMode:H,selectedTaskIds:g,onSelectionChange:$t,onRetry:Nt,onDelete:Et,onDownload:qe,onInsert:Vt,onCopy:At,onEdit:Ft,onPreviewOpen:Oe,onExtractCharacter:Gt,hasMore:R,isLoadingMore:P,onLoadMore:E,totalCount:x,loadedCount:O,allLoadedText:Xt,allLoadedHint:x>=100?Ae:void 0,className:"task-queue-panel__list",emptyContent:S?t.jsxs("div",{className:"task-queue-panel__empty",children:[t.jsx("div",{className:"task-queue-panel__empty-icon",children:"⏳"}),t.jsx("div",{className:"task-queue-panel__empty-text",children:"加载中..."})]}):t.jsxs("div",{className:"task-queue-panel__empty",children:[t.jsx("div",{className:"task-queue-panel__empty-icon",children:"📋"}),t.jsx("div",{className:"task-queue-panel__empty-text",children:A==="all"?"暂无任务":`暂无${A==="active"?"生成中":A==="completed"?"已完成":A==="failed"?"失败":"已取消"}任务`})]})})}),t.jsx(ne,{open:ft,title:"确认清除",description:`确定要清除所有${Ie==="completed"?"已完成":"失败"}的任务吗?此操作无法撤销。`,confirmText:"清除",cancelText:"取消",danger:!0,onOpenChange:ue,onConfirm:Dt}),t.jsx(ne,{open:wt,title:"确认删除",description:"确定要删除此任务吗?此操作无法撤销。",confirmText:"删除",cancelText:"取消",danger:!0,onOpenChange:fe,onConfirm:Ut}),t.jsx(ne,{open:It,title:"确认批量删除",description:`确定要删除选中的 ${g.size} 个任务吗?此操作无法撤销。`,confirmText:"删除",cancelText:"取消",danger:!0,onOpenChange:ve,onConfirm:qt}),t.jsx(Ns,{visible:vt,items:Bt,initialMode:_t,initialIndex:Ct,onClose:Ht,showThumbnails:!0,onEdit:Wt}),ke&&Se&&t.jsx(Ms,{visible:ke,imageUrl:Se,showOverwrite:!1,onClose:()=>{pe(!1),he("")},onInsert:B?Kt:void 0}),t.jsx(Ss,{visible:!!Ne,task:Ne,onClose:()=>xe(null),onCreateStart:()=>{},onCreateComplete:s=>{xe(null)}})]})};export{Rs as TASK_DRAWER_WIDTH_KEY,Qs as TaskQueuePanel};
|