aitu-app 0.6.13 → 0.6.14
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/{ChatMessagesArea-Btxhq7Z2.js → ChatMessagesArea-BQ33OSbv.js} +4 -4
- package/assets/DialogTaskList-D8vkITTk.js +1 -0
- package/assets/KnowledgeBaseContent-iIzzEUb9.js +143 -0
- package/assets/{ToolboxDrawer-CFAgOmIa.js → ToolboxDrawer-BUixzCAh.js} +14 -14
- package/assets/{ai-analyze-CXbDwr-F.js → ai-analyze-BSLl2uAK.js} +1 -1
- package/assets/ai-image-generation-DvTfL5Pf.js +1 -0
- package/assets/ai-video-generation-mgvQmDxU.js +5 -0
- package/assets/{arc-BVpYfX8u.js → arc-7VZa8sld.js} +1 -1
- package/assets/{arc-Vb6QIvRI.js → arc-CPYfXPW2.js} +1 -1
- package/assets/{batch-image-generation-rvn9zCP-.js → batch-image-generation-C7g9dTtb.js} +5 -5
- package/assets/{blockDiagram-38ab4fdb-CbbmIvT5.js → blockDiagram-38ab4fdb-9wKjan3w.js} +1 -1
- package/assets/{blockDiagram-38ab4fdb-CbUExfWH.js → blockDiagram-38ab4fdb-BfYiey8T.js} +1 -1
- package/assets/{c4Diagram-3d4e48cf-Db1GHdmL.js → c4Diagram-3d4e48cf-Cl1CeBZ9.js} +1 -1
- package/assets/{c4Diagram-3d4e48cf-Dw_8bcgE.js → c4Diagram-3d4e48cf-CvDzfWGg.js} +1 -1
- package/assets/channel-Dq0dBTpp.js +1 -0
- package/assets/channel-QRfYJ0c8.js +1 -0
- package/assets/{classDiagram-70f12bd4-CXXAHxeU.js → classDiagram-70f12bd4-7hx7i_r9.js} +1 -1
- package/assets/{classDiagram-70f12bd4-_p3Dnvx6.js → classDiagram-70f12bd4-C4dqbFYb.js} +1 -1
- package/assets/{classDiagram-v2-f2320105-B-9myg44.js → classDiagram-v2-f2320105-BE6EhyIR.js} +1 -1
- package/assets/{classDiagram-v2-f2320105-ChK1LfBX.js → classDiagram-v2-f2320105-BKvCao98.js} +1 -1
- package/assets/{clipper-CJLNPhZM.js → clipper-DMBYubGg.js} +1 -1
- package/assets/clone-8iorvsVH.js +1 -0
- package/assets/clone-CcaoZaCt.js +1 -0
- package/assets/{createText-2e5e7dd3-BCbwgqBS.js → createText-2e5e7dd3-B5bm44t-.js} +1 -1
- package/assets/{createText-2e5e7dd3-BGRSuPih.js → createText-2e5e7dd3-ClED10Yd.js} +1 -1
- package/assets/{edges-e0da2a9e-BoQQRKl3.js → edges-e0da2a9e-CxYbDWHf.js} +1 -1
- package/assets/{edges-e0da2a9e-1EAOsAGW.js → edges-e0da2a9e-D83AKoY_.js} +1 -1
- package/assets/{erDiagram-9861fffd-DrPXJadW.js → erDiagram-9861fffd-By6KGQIp.js} +1 -1
- package/assets/{erDiagram-9861fffd-DIqIVsjO.js → erDiagram-9861fffd-DklWxrea.js} +1 -1
- package/assets/{flowDb-956e92f1-DKdojl1Z.js → flowDb-956e92f1-B5waKznT.js} +1 -1
- package/assets/{flowDb-956e92f1-_yAXk9b2.js → flowDb-956e92f1-zlQFiVfE.js} +1 -1
- package/assets/{flowDiagram-66a62f08-Cn3BWcxJ.js → flowDiagram-66a62f08-Be1TW-l_.js} +1 -1
- package/assets/{flowDiagram-66a62f08-BSNSE1vH.js → flowDiagram-66a62f08-DN-7_2yD.js} +1 -1
- package/assets/flowDiagram-v2-96b9c2cf-Brfi4xIj.js +1 -0
- package/assets/flowDiagram-v2-96b9c2cf-CPIzTRuX.js +1 -0
- package/assets/{flowchart-elk-definition-4a651766-CkhkUOMa.js → flowchart-elk-definition-4a651766-N0AfQRnQ.js} +1 -1
- package/assets/{flowchart-elk-definition-4a651766-CtRYHypS.js → flowchart-elk-definition-4a651766-r-PtKbtF.js} +1 -1
- package/assets/{ganttDiagram-c361ad54-C-olbHti.js → ganttDiagram-c361ad54-Bht9glx_.js} +1 -1
- package/assets/{ganttDiagram-c361ad54-DWZxEumf.js → ganttDiagram-c361ad54-C2_MLBXD.js} +1 -1
- package/assets/{gitGraphDiagram-72cf32ee-DFI0WJ7k.js → gitGraphDiagram-72cf32ee-2be20W2P.js} +1 -1
- package/assets/{gitGraphDiagram-72cf32ee-Dz3X9B4S.js → gitGraphDiagram-72cf32ee-DbRkmH2_.js} +1 -1
- package/assets/{graph-BbAdRpyG.js → graph-B8wbK8JG.js} +1 -1
- package/assets/{graph-CG3zmXkL.js → graph-Cz6eZWdE.js} +1 -1
- package/assets/{grid-image-CahEQ7p7.js → grid-image-BjBUsyzw.js} +1 -1
- package/assets/{has-Cq7YuzG9.js → has-xmSj69Ai.js} +1 -1
- package/assets/{hasIn-4hPyOh4r.js → hasIn-BEuiXUL_.js} +1 -1
- package/assets/{index-3862675e-D_PJ0qZE.js → index-3862675e-B-TzDFUV.js} +1 -1
- package/assets/{index-3862675e-Cy2LJr-t.js → index-3862675e-DUv0NNEX.js} +1 -1
- package/assets/{index-pt9oZHeu.js → index-BFKE1SDS.js} +1 -1
- package/assets/{index-WyqXHNHN.js → index-BGhQ9HiC.js} +10 -10
- package/assets/{index-C1tgh8XV.js → index-BJPn-Z4H.js} +1 -1
- package/assets/{index-CqEazMaK.js → index-BJt4za3u.js} +1 -1
- package/assets/{index-D9rMZcAy.js → index-BYIrI0Fv.js} +52 -49
- package/assets/index-Bf4QGnyR.css +9 -0
- package/assets/{index-DHrV9sCt.js → index-Bi-3shgC.js} +1 -1
- package/assets/{index-BiCrE7Ci.js → index-Biha89Ph.js} +1 -1
- package/assets/{index-BDnSt0a8.js → index-C7Vp0sfc.js} +1 -1
- package/assets/{index-DtNyBFxZ.js → index-CM5A34wJ.js} +1 -1
- package/assets/{index-XoOCAjmC.js → index-CMqABmj9.js} +1 -1
- package/assets/{index-BOZ3fCzl.js → index-CURBM_KW.js} +1 -1
- package/assets/{index-B4IEsL3l.js → index-CZI4rQ66.js} +1 -1
- package/assets/{index-CYf1zrx4.js → index-Cg0P1L1n.js} +1 -1
- package/assets/{index-B9uNbnfa.js → index-Cg4DzaGJ.js} +1 -1
- package/assets/{index-BZIcMnMw.js → index-Cr7eFaRi.js} +1 -1
- package/assets/{index-7WzIC7_D.js → index-CvvgEQLL.js} +557 -519
- package/assets/index-Cz1tSwF3.css +1 -0
- package/assets/{index-Cx19IgV-.js → index-D35EPyAQ.js} +5 -5
- package/assets/{index-Dv8yvI8G.js → index-D55hpwi0.js} +1 -1
- package/assets/{index-CciPE8zM.js → index-D8hBvwzc.js} +1 -1
- package/assets/{index-BkRTZMZM.js → index-DCPnuU9X.js} +1 -1
- package/assets/{index-Bad6y32x.js → index-DFKy--AY.js} +1 -1
- package/assets/{index-Bco0OAak.js → index-DGrNJ_p2.js} +1 -1
- package/assets/{index-DUgUd4bR.js → index-DZUnWUAx.js} +1 -1
- package/assets/{index-BU3nDlFy.js → index-DergpCoU.js} +1 -1
- package/assets/{index-DBCwQvu4.js → index-Dgpls_LJ.js} +1 -1
- package/assets/{index-jHCkpoWQ.js → index-Dh9OAfqP.js} +1 -1
- package/assets/{index-Dqi7TZna.js → index-DoC8-4hw.js} +2 -2
- package/assets/{index-BQS_8NU3.js → index-DoNZZrMr.js} +1 -1
- package/assets/{index-Bfs6Q-lQ.js → index-Dwd3fQIs.js} +1 -1
- package/assets/{index-BE7n-LiY.js → index-H9okbyq7.js} +1 -1
- package/assets/{index-BOHFUhjZ.js → index-iNzLrLfW.js} +1 -1
- package/assets/index-pQpy2-r1.js +1 -0
- package/assets/{index-ICFaM7Tx.js → index-ukQeGfpm.js} +1 -1
- package/assets/{infoDiagram-f8f76790-D8T-erO4.js → infoDiagram-f8f76790-Ds4mXkkB.js} +1 -1
- package/assets/{infoDiagram-f8f76790-C0TYyx3w.js → infoDiagram-f8f76790-Xs3wpNj_.js} +1 -1
- package/assets/{inspiration-board-CiL8hKbX.js → inspiration-board-aPQmVaUX.js} +1 -1
- package/assets/{isEmpty-BoFRUVaJ.js → isEmpty-BQn8FtDD.js} +1 -1
- package/assets/{journeyDiagram-49397b02-CkmFUv6i.js → journeyDiagram-49397b02-CMj7sdKi.js} +1 -1
- package/assets/{journeyDiagram-49397b02-BHw2LUDu.js → journeyDiagram-49397b02-DAcDgbqb.js} +1 -1
- package/assets/{layers-CaY2-pH6.js → layers-D6Y5pCwe.js} +1 -1
- package/assets/{layout-CSua1dGC.js → layout-DFY48Wfc.js} +1 -1
- package/assets/{layout-D_agYVJ_.js → layout-xjQVmyNt.js} +1 -1
- package/assets/{line-CN9rNlXr.js → line-CS-j1kBY.js} +1 -1
- package/assets/{line-CxGDlzoc.js → line-CnJU8oQA.js} +1 -1
- package/assets/{linear-DKP7SWoM.js → linear-8yUIDV7f.js} +1 -1
- package/assets/{linear-CvStv2Ny.js → linear-BNtDceQW.js} +1 -1
- package/assets/{mermaid.core-DawxQi4y.js → mermaid.core-Bse-qmGl.js} +5 -5
- package/assets/{mindmap-definition-fc14e90a-BWrsnm3I.js → mindmap-definition-fc14e90a-B5pHBBH0.js} +1 -1
- package/assets/{mindmap-definition-fc14e90a-Dmo2lz3K.js → mindmap-definition-fc14e90a-BZEj0_V2.js} +1 -1
- package/assets/{photo-wall-splitter-B_WR4Rl2.js → photo-wall-splitter-DNhSfZ1J.js} +1 -1
- package/assets/pick-Bz9u-Vgl.js +1 -0
- package/assets/{pieDiagram-8a3498a8-DhrponMk.js → pieDiagram-8a3498a8-BX6EY38S.js} +1 -1
- package/assets/{pieDiagram-8a3498a8-CmbWJAb7.js → pieDiagram-8a3498a8-C2SKAWPu.js} +1 -1
- package/assets/{quadrantDiagram-120e2f19-CgIF-y-_.js → quadrantDiagram-120e2f19-C_pOTOg2.js} +1 -1
- package/assets/{quadrantDiagram-120e2f19-DOKwrvFF.js → quadrantDiagram-120e2f19-_4F-o39n.js} +1 -1
- package/assets/{requirementDiagram-deff3bca-BqbqHjdU.js → requirementDiagram-deff3bca-CZBh345Y.js} +1 -1
- package/assets/{requirementDiagram-deff3bca-CIXltTSE.js → requirementDiagram-deff3bca-DUvc5b49.js} +1 -1
- package/assets/{sankeyDiagram-04a897e0-DcPermhl.js → sankeyDiagram-04a897e0-DgwQWZaB.js} +1 -1
- package/assets/{sankeyDiagram-04a897e0-DGiABLdx.js → sankeyDiagram-04a897e0-HlGDp0fm.js} +1 -1
- package/assets/{sequenceDiagram-704730f1-piXYTUjh.js → sequenceDiagram-704730f1-CZleNxPQ.js} +1 -1
- package/assets/{sequenceDiagram-704730f1-BUXJ6XVH.js → sequenceDiagram-704730f1-HXnccUr4.js} +1 -1
- package/assets/{settings-dialog-A3AH7O45.css → settings-dialog-Bf8ExAlc.css} +1 -1
- package/assets/settings-dialog-FIIbAUlz.js +11 -0
- package/assets/{shard-sync-service-BCo2qKEA.js → shard-sync-service-BmLCs0-9.js} +1 -1
- package/assets/{stateDiagram-587899a1-Dnd2X4K4.js → stateDiagram-587899a1-BgbU_RYJ.js} +1 -1
- package/assets/{stateDiagram-587899a1-Cdfs3rRO.js → stateDiagram-587899a1-wcO67Z9P.js} +1 -1
- package/assets/{stateDiagram-v2-d93cdb3a-DtC5XSWV.js → stateDiagram-v2-d93cdb3a-CyibEwON.js} +1 -1
- package/assets/{stateDiagram-v2-d93cdb3a-lOfkWHnS.js → stateDiagram-v2-d93cdb3a-D6v0mGya.js} +1 -1
- package/assets/{styles-6aaf32cf-B_EWv7Bz.js → styles-6aaf32cf-CuwtY8aD.js} +1 -1
- package/assets/{styles-6aaf32cf-BTv8Dnxa.js → styles-6aaf32cf-DPVcUAPG.js} +1 -1
- package/assets/{styles-9a916d00-C4vTAlbK.js → styles-9a916d00-5sadXKIs.js} +1 -1
- package/assets/{styles-9a916d00-BNkP2BU4.js → styles-9a916d00-BlcdlroT.js} +1 -1
- package/assets/{styles-c10674c1-BcxLBYaC.js → styles-c10674c1-DMY3sr0M.js} +1 -1
- package/assets/{styles-c10674c1-Dp5J5JrP.js → styles-c10674c1-fyvfh0rz.js} +2 -2
- package/assets/{svgDrawCommon-08f97a94-CalbTy9V.js → svgDrawCommon-08f97a94-D99zFeK3.js} +1 -1
- package/assets/{svgDrawCommon-08f97a94-5_vuhhyn.js → svgDrawCommon-08f97a94-DCKNxHs0.js} +1 -1
- package/assets/{timeline-definition-85554ec2-DBiJ4h6g.js → timeline-definition-85554ec2-B-Hua8_V.js} +1 -1
- package/assets/{timeline-definition-85554ec2-ByBsrbAq.js → timeline-definition-85554ec2-BJFySUyi.js} +1 -1
- package/assets/{ttd-dialog-C9noZsTQ.js → ttd-dialog-D_LEovv1.js} +4 -4
- package/assets/{upload-DP5n1PVz.js → upload-DPuHWdr4.js} +1 -1
- package/assets/{video-recovery-service-DY01FcHI.js → video-recovery-service-BUo0pCsG.js} +1 -1
- package/assets/{xychartDiagram-e933f94c-CJ1NxG0K.js → xychartDiagram-e933f94c-Cf5Uc503.js} +1 -1
- package/assets/{xychartDiagram-e933f94c-CEXcS3Lw.js → xychartDiagram-e933f94c-Cu1l8Kcq.js} +1 -1
- package/changelog.json +42 -0
- package/package.json +1 -1
- package/precache-manifest.json +279 -279
- package/sw.js +4 -4
- package/version.json +29 -3
- package/assets/DialogTaskList-0I91BD1p.js +0 -1
- package/assets/KnowledgeBaseContent-CSEr1paK.js +0 -153
- package/assets/ai-image-generation-CvUX_vnh.js +0 -1
- package/assets/ai-video-generation-BgDcotXE.js +0 -5
- package/assets/channel-ChluHQU5.js +0 -1
- package/assets/channel-DQ0ggWsj.js +0 -1
- package/assets/clone-BscGHP5K.js +0 -1
- package/assets/clone-CTdvgy2F.js +0 -1
- package/assets/flowDiagram-v2-96b9c2cf-BmoA7Lrr.js +0 -1
- package/assets/flowDiagram-v2-96b9c2cf-Du5Aycbt.js +0 -1
- package/assets/index-C_Ed2LrM.js +0 -1
- package/assets/index-V8UiJyjb.css +0 -1
- package/assets/index-qP_w2VHW.css +0 -9
- package/assets/pick-C1hcXSqm.js +0 -1
- package/assets/settings-dialog-D1OnKj0y.js +0 -11
package/version.json
CHANGED
|
@@ -1,6 +1,32 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.6.
|
|
3
|
-
"buildTime": "2026-
|
|
2
|
+
"version": "0.6.14",
|
|
3
|
+
"buildTime": "2026-04-08T10:25:20.176Z",
|
|
4
4
|
"gitCommit": "unknown",
|
|
5
|
-
"changelog": [
|
|
5
|
+
"changelog": [
|
|
6
|
+
"persist dropdown selections and correct type fallback",
|
|
7
|
+
"完善多供应商模型协议路由与 Sora 视频适配",
|
|
8
|
+
"增加 Stitch 设计工作流资产与规范",
|
|
9
|
+
"支持 Suno 歌词任务与厂商识别能力",
|
|
10
|
+
"增强文本多模态识图与供应商模型路由体验",
|
|
11
|
+
"修复 web 端音频任务类型检查失败",
|
|
12
|
+
"优化移动端音频播放器并恢复桌面端展示",
|
|
13
|
+
"实现多供应商模型配置与按模型来源路由",
|
|
14
|
+
"增加音频模态与 Suno 路由基础",
|
|
15
|
+
"优化模型选择器供应商与厂商分层展示",
|
|
16
|
+
"优化移动端设置与供应商配置体验",
|
|
17
|
+
"优化音频节点内容布局与信息层级",
|
|
18
|
+
"接入音频生成任务与工作流链路",
|
|
19
|
+
"优化设置页模型发现与配置体验",
|
|
20
|
+
"增加画布音频节点与播放能力",
|
|
21
|
+
"增加 Kling 参数适配",
|
|
22
|
+
"增加 Kling 能力路由",
|
|
23
|
+
"重构设置页并修复配置持久化",
|
|
24
|
+
"补充媒体任务兼容与路由回归",
|
|
25
|
+
"完善音频入口与任务展示体验",
|
|
26
|
+
"优化 Kling 参数展示",
|
|
27
|
+
"实现模型获取与按需添加流程",
|
|
28
|
+
"恢复被误删掉代码",
|
|
29
|
+
"优化至形状可导出",
|
|
30
|
+
"优化至适配画笔"
|
|
31
|
+
]
|
|
6
32
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b0 as Ne,r as a,s as te,aQ as e,aR as de,aS as Pe,bh as ne,eg as Le,eh as je,cS as Re,ei as ke,ej as Ae,ek as ce,el as Fe,em as Ee,d_ as $e,en as ze,eo as Be,ep as Oe,eq as He,er as Ue,es as We,et as qe,eu as Ge,cD as Ve,bd as U,ev as Xe,ew as Qe,bk as we,bo as Ye,ex as Ke,bq as Ze,cQ as Je,bj as be,bi as ye,bW as et,cr as tt,ey as st,cM as nt,ez as at,eA as rt,eB as ot,cZ as Ce,t as it,c2 as lt,cH as J,cs as ct,d$ as dt,e0 as ut,eC as mt,cP as _e,eD as pt,eE as ht,dp as Ie,eF as ft,eG as gt,eH as vt,u as xt,eI as wt,eJ as bt}from"./index-7WzIC7_D.js";function Pt(){const{completedTasks:t}=Ne(),o=a.useMemo(()=>t.filter(n=>{var m;return n.type===te.IMAGE&&((m=n.result)==null?void 0:m.url)}).map(n=>({id:n.id,type:"image",prompt:n.params.prompt,timestamp:n.completedAt||n.createdAt,imageUrl:n.result.url,width:n.result.width||1024,height:n.result.height||1024,uploadedImages:n.params.uploadedImages})).sort((n,m)=>m.timestamp-n.timestamp),[t]),l=a.useMemo(()=>t.filter(n=>{var m;return n.type===te.VIDEO&&((m=n.result)==null?void 0:m.url)}).map(n=>({id:n.id,type:"video",prompt:n.params.prompt,timestamp:n.completedAt||n.createdAt,imageUrl:n.result.thumbnailUrl||n.result.url,width:n.result.width||400,height:n.result.height||225,previewUrl:n.result.url,downloadUrl:n.result.url,uploadedImage:n.params.uploadedImage})).sort((n,m)=>m.timestamp-n.timestamp),[t]),i=a.useMemo(()=>[...o,...l].sort((n,m)=>m.timestamp-n.timestamp),[o,l]);return{imageHistory:o,videoHistory:l,allHistory:i}}const Se=(t,o,l)=>{const i=l==="image"?{isGenerating:t,imageLoading:o}:{isGenerating:t,videoLoading:o};window.dispatchEvent(new CustomEvent("ai-generation-state-change",{detail:i}))},Lt=(t,o,l)=>{a.useEffect(()=>{const i=n=>{(n.metaKey||n.ctrlKey)&&n.key==="Enter"&&(n.preventDefault(),!t&&o.trim()&&l())};return document.addEventListener("keydown",i),()=>{document.removeEventListener("keydown",i)}},[t,o,l])},Rt=t=>{const[o,l]=a.useState(!1),[i,n]=a.useState(!1),m=a.useCallback(h=>{l(h),Se(h,i,t)},[i,t]),b=a.useCallback(h=>{n(h),Se(o,h,t)},[o,t]);return{isGenerating:o,isLoading:i,updateIsGenerating:m,updateIsLoading:b}},yt=(t,o,l)=>o==="image"?t==="zh"?"一只可爱的小猫坐在窗台上,阳光透过窗户洒在它的毛发上,背景是温馨的家居环境":"A cute kitten sitting on a windowsill, with sunlight streaming through the window onto its fur, with a cozy home environment in the background":l==="sora"?t==="zh"?"描述视频内容,输入 @ 可引用已创建的角色,如 @username 在海边漫步...":"Describe video content, type @ to reference created characters, e.g. @username walking on the beach...":t==="zh"?"生成一个美丽的日出场景,阳光从山峰后缓缓升起,云朵轻柔地飘动":"Generate a beautiful sunrise scene where the sun slowly rises from behind mountains with clouds gently floating",Ct=[1,2,3,4,5,10,20,50,100],_t="aitu_image_generation_quantity",It="aitu_video_generation_quantity",me=100,At=({language:t,type:o,isGenerating:l,hasGenerated:i,canGenerate:n,onGenerate:m,onReset:b,leftContent:h})=>{const f=o==="video"?It:_t,[g,C]=a.useState(()=>{try{const u=localStorage.getItem(f);if(u){const N=parseInt(u,10);if(!isNaN(N)&&N>=1&&N<=me)return N}}catch{}return 1}),[k,T]=a.useState(!1),[c,v]=a.useState(()=>g.toString()),y=a.useRef(null);a.useEffect(()=>{v(g.toString());try{localStorage.setItem(f,g.toString())}catch{}},[g,f]),a.useEffect(()=>{const u=N=>{y.current&&!y.current.contains(N.target)&&(T(!1),x())};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[c]);const x=()=>{let u=parseInt(c,10);(isNaN(u)||u<1)&&(u=1),u>me&&(u=me),v(u.toString()),C(u)},D=u=>{const N=u.target.value;(N===""||/^\d*$/.test(N))&&v(N)},E=u=>{C(u),v(u.toString()),T(!1)},j=()=>{l||T(!k)},B=()=>{m(g)};return e.jsxs("div",{className:"section-actions unified-action-bar",children:[h&&e.jsx("div",{className:"action-bar-left",children:h}),e.jsxs("div",{className:`unified-action-box ${l?"is-generating":""} ${n?"can-generate":""}`,children:[e.jsxs("div",{className:"quantity-section",ref:y,children:[e.jsx(de,{content:t==="zh"?"生成数量":"Quantity",theme:"light",children:e.jsxs("div",{className:`quantity-control ${k?"is-open":""} ${l?"is-disabled":""}`,children:[e.jsx("input",{type:"text",inputMode:"numeric",value:c,onChange:D,onBlur:x,"data-track":"ai_click_quantity_input",onClick:()=>!l&&T(!0),disabled:l,className:"quantity-input"}),e.jsx("button",{type:"button","data-track":"ai_click_quantity_toggle",onClick:u=>{u.stopPropagation(),j()},disabled:l,className:"quantity-toggle",children:e.jsx(Pe,{className:`quantity-icon ${k?"is-open":""}`})})]})}),k&&e.jsxs("div",{className:"quantity-dropdown",children:[e.jsx("div",{className:"quantity-dropdown-header",children:t==="zh"?"选择数量":"Select Quantity"}),Ct.map(u=>e.jsxs("button",{type:"button","data-track":"ai_click_quantity_select",onClick:()=>E(u),className:`quantity-option ${g===u?"is-selected":""}`,children:[e.jsxs("span",{children:[u," ",o==="video"?t==="zh"?"个":u>1?"videos":"video":t==="zh"?"张":u>1?"images":"image"]}),g===u&&e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})})]},u))]})]}),e.jsx("div",{className:"action-divider"}),e.jsx("button",{"data-track":"ai_click_generate",onClick:B,disabled:l||!n,className:`generate-button ${l?"loading":""}`,children:l?t==="zh"?"生成中...":"Generating...":i?t==="zh"?"重新生成":"Regenerate":o==="video"?t==="zh"?"生成视频":"Generate Video":t==="zh"?"生成":"Generate"})]}),e.jsx(de,{content:t==="zh"?"重置表单":"Reset form",theme:"light",children:e.jsx(ne,{"data-track":"ai_click_reset",onClick:b,disabled:l,variant:"text",shape:"circle",icon:e.jsx(Le,{}),className:"action-button--reset-subtle"})})]})},Ft=({error:t})=>t?e.jsx("div",{className:"form-error",children:t}):null,St=({visible:t,query:o,position:l,showBelow:i=!1,selectedIndex:n,onSelect:m,onClose:b})=>{const{completedCharacters:h,isLoading:f}=je(),g=a.useRef(null),C=a.useMemo(()=>{if(!o)return h;const c=o.toLowerCase();return h.filter(v=>v.username.toLowerCase().includes(c))},[h,o]);a.useEffect(()=>{if(!t||!g.current)return;const c=g.current.querySelector(".character-mention-popup__item--selected");c&&c.scrollIntoView({block:"nearest"})},[t,n]),a.useEffect(()=>{if(!t)return;const c=v=>{g.current&&!g.current.contains(v.target)&&b()};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[t,b]);const k=a.useCallback(c=>{Re.track("character_used_in_prompt",{characterId:c.id,username:c.username}),m(c)},[m]);if(!t)return null;const T={position:"fixed",top:l.top,left:l.left,transform:i?"none":"translateY(-100%)",zIndex:ke.DROPDOWN_PORTAL,maxHeight:"200px",overflowY:"auto"};return f?e.jsx("div",{ref:g,className:"character-mention-popup",style:T,children:e.jsx("div",{className:"character-mention-popup__empty",children:"加载中..."})}):C.length===0?e.jsx("div",{ref:g,className:"character-mention-popup",style:T,children:e.jsx("div",{className:"character-mention-popup__empty",children:o?`未找到 "${o}" 相关角色`:"暂无可用角色"})}):e.jsx("div",{ref:g,className:"character-mention-popup",style:T,children:C.map((c,v)=>e.jsxs("div",{className:`character-mention-popup__item ${v===n?"character-mention-popup__item--selected":""}`,onClick:()=>k(c),"data-track":"character_click_mention",children:[e.jsx("div",{className:"character-mention-popup__item-avatar",children:e.jsx(Ae,{characterId:c.id,profilePictureUrl:c.profilePictureUrl,alt:c.username})}),e.jsxs("span",{className:"character-mention-popup__item-name",children:["@",c.username]})]},c.id))})},Mt={visible:!1,query:"",position:{top:0,left:0},showBelow:!1,startIndex:-1,selectedIndex:0};function jt({enabled:t=!0,onPromptChange:o,prompt:l}){const[i,n]=a.useState(Mt),m=a.useRef(null),{completedCharacters:b}=je(),h=a.useCallback(c=>{if(!m.current)return{top:0,left:0,showBelow:!1};const v=m.current,y=v.getBoundingClientRect(),x=document.createElement("div"),D=window.getComputedStyle(v),E=["fontFamily","fontSize","fontWeight","fontStyle","letterSpacing","lineHeight","textTransform","wordSpacing","whiteSpace","paddingTop","paddingRight","paddingBottom","paddingLeft","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","boxSizing"];x.style.position="absolute",x.style.top="0",x.style.left="-9999px",x.style.visibility="hidden",x.style.whiteSpace="pre-wrap",x.style.overflowWrap="break-word",x.style.overflow="hidden",x.style.width=`${v.clientWidth}px`,E.forEach(G=>{x.style[G]=D.getPropertyValue(G.replace(/([A-Z])/g,"-$1").toLowerCase())}),document.body.appendChild(x);let j=0,B=0;try{const G=v.value.substring(0,c),K=document.createTextNode(G),I=document.createElement("span");I.textContent="",x.appendChild(K),x.appendChild(I);const _=I.getBoundingClientRect(),P=x.getBoundingClientRect();j=_.top-P.top,B=_.left-P.left}finally{document.body.removeChild(x)}const u=v.scrollTop,N=parseInt(D.lineHeight)||20;let W=y.top+j-u,$=y.left+B;const H=240,Y=window.innerWidth;$+H>Y-16&&($=Y-H-16),$<16&&($=16);const q=W<220+16;return q?W=W+N+4:W=W-48,{top:W,left:$,showBelow:q}},[]),f=a.useCallback((c,v)=>{if(!t)return;const y=c.substring(0,v),x=y.lastIndexOf("@");if(x===-1){n(B=>({...B,visible:!1}));return}const D=x>0?c[x-1]:" ";if(!/\s/.test(D)&&x!==0){n(B=>({...B,visible:!1}));return}const E=y.substring(x+1);if(E.includes(" ")){n(B=>({...B,visible:!1}));return}const j=h(v);n({visible:!0,query:E,position:{top:j.top,left:j.left},showBelow:j.showBelow,startIndex:x,selectedIndex:0})},[t,h]),g=a.useCallback(c=>{var E;if(i.startIndex===-1)return;const v=l.substring(0,i.startIndex),y=((E=m.current)==null?void 0:E.selectionStart)||l.length,x=l.substring(y),D=`${v}@${c.username} ${x}`;o(D),n(j=>({...j,visible:!1})),setTimeout(()=>{if(m.current){const j=v.length+c.username.length+2;m.current.focus(),m.current.setSelectionRange(j,j)}},0)},[i.startIndex,l,o]),C=a.useCallback(c=>{if(!i.visible)return;const v=i.query?b.filter(y=>y.username.toLowerCase().includes(i.query.toLowerCase())):b;switch(c.key){case"ArrowDown":c.preventDefault(),n(y=>({...y,selectedIndex:Math.min(y.selectedIndex+1,v.length-1)}));break;case"ArrowUp":c.preventDefault(),n(y=>({...y,selectedIndex:Math.max(y.selectedIndex-1,0)}));break;case"Enter":case"Tab":v.length>0&&(c.preventDefault(),g(v[i.selectedIndex]));break;case"Escape":c.preventDefault(),n(y=>({...y,visible:!1}));break}},[i,b,g]),k=a.useCallback((c,v)=>{o(c),f(c,v)},[o,f]),T=a.useCallback(()=>{n(c=>({...c,visible:!1}))},[]);return{mentionState:i,setMentionState:n,textareaRef:m,completedCharacters:b,handleTextChange:k,handleKeyDown:C,handleCharacterSelect:g,closeMentionPopup:T,calculateMentionPosition:h}}const Et=({prompt:t,onPromptChange:o,presetPrompts:l,language:i,type:n,disabled:m=!1,onError:b,enableMention:h=!0,videoProvider:f})=>{const[g,C]=a.useState(!1),k=a.useRef(null),T=a.useRef(null),[c,v]=a.useState(null),[y,x]=a.useState(0),D=a.useMemo(()=>ce.sortPrompts(n,l).map((_,P)=>({id:`preset-${P}-${_.slice(0,20)}`,content:_,pinned:ce.isPinned(n,_)})),[n,l,y]),E=h&&n==="video"&&f==="sora",{mentionState:j,textareaRef:B,handleTextChange:u,handleKeyDown:N,handleCharacterSelect:W,closeMentionPopup:$}=jt({enabled:E,onPromptChange:o,prompt:t}),H=a.useCallback(()=>{if(T.current&&g){const I=T.current.getBoundingClientRect(),_=8,P=320,Q=400,ae=window.innerHeight-I.top+4,Z=Math.min(P,window.innerWidth-_*2),ee=window.innerWidth-I.right,re=window.innerWidth-Z-_,se=Math.max(Math.min(ee,re),_),oe=Math.min(Q,I.top-_,window.innerHeight*.45);v({bottom:ae,right:se,maxHeight:oe})}},[g]);a.useEffect(()=>{if(g)return H(),window.addEventListener("scroll",H,!0),window.addEventListener("resize",H),()=>{window.removeEventListener("scroll",H,!0),window.removeEventListener("resize",H)}},[g,H]),a.useEffect(()=>{const I=_=>{const P=_.target;if(k.current&&!k.current.contains(P)){const Q=document.querySelector(".preset-prompt-panel-portal");Q!=null&&Q.contains(P)||C(!1)}};if(g)return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[g]);const Y=a.useCallback(I=>{const _=typeof I=="string"?I:I.content;o(_),b==null||b(null),C(!1)},[o,b]),X=a.useCallback(I=>{const _=D.find(P=>P.id===I);_&&(_.pinned?ce.unpinPrompt(n,_.content):ce.pinPrompt(n,_.content),x(P=>P+1))},[n,D]),q=a.useCallback(I=>{const _=D.find(P=>P.id===I);_&&(ce.deletePrompt(n,_.content),x(P=>P+1))},[n,D]),G=a.useCallback(I=>{const _=I.target.value,P=I.target.selectionStart||0;u(_,P),b==null||b(null)},[u,b]);a.useEffect(()=>{n!=="video"&&$()},[n,$]);const K=()=>{if(!g||!c)return null;const I=i==="zh"?`${n==="image"?"图片":"视频"}描述预设`:`${n==="image"?"Image":"Video"} Description Presets`,_=e.jsx("div",{className:"preset-prompt-panel-portal",style:{position:"fixed",bottom:c.bottom,right:c.right,zIndex:ke.DIALOG_POPOVER,"--panel-max-width":"calc(100vw - 16px)","--panel-max-height":`${c.maxHeight}px`},children:e.jsx(Ee,{title:I,items:D,onSelect:Y,onTogglePin:X,onDelete:q,language:i,disabled:m,showCount:!0})});return $e.createPortal(_,document.body)};return e.jsxs("div",{className:"form-field form-field--prompt",children:[e.jsxs("div",{className:"form-label-with-icon",children:[e.jsx("label",{className:"form-label",children:i==="zh"?`${n==="image"?"图片":"视频"}描述`:`${n==="image"?"Image":"Video"} Description`}),e.jsx("div",{className:"textarea-with-preset",children:e.jsxs("div",{className:"preset-tooltip-container",ref:k,children:[e.jsx("button",{ref:T,type:"button",className:"preset-icon-button",disabled:m,onClick:()=>C(!g),children:e.jsx(Fe,{size:16})}),K()]})})]}),e.jsx("textarea",{ref:B,className:"form-textarea",value:t,onChange:G,onKeyDown:N,placeholder:yt(i,n,f),rows:4,disabled:m}),E&&e.jsx(St,{visible:j.visible,query:j.query,position:j.position,showBelow:j.showBelow,selectedIndex:j.selectedIndex,onSelect:W,onClose:$})]})};function kt(t){return t.map(o=>o.prompt.trim()).filter(o=>o.length>0).filter((o,l,i)=>i.indexOf(o)===l)}const $t=(t,o,l)=>{const i=t==="image"?He(o):Ue(o),n=kt(l);return[...[...t==="video"?ze():Be(),...n].filter((f,g,C)=>C.indexOf(f)===g).slice(0,Oe),...i].filter((f,g,C)=>C.indexOf(f)===g).slice(0,We)},zt=(t,o,l)=>{!o||!o.trim()||(t==="video"?qe(o.trim()):Ge(o.trim()))},Bt=({images:t,onImagesChange:o,language:l="zh",disabled:i=!1,multiple:n=!0,maxCount:m=10,label:b,slotLabels:h,onError:f})=>{const[g,C]=a.useState(!1),[k,T]=a.useState(!1),[c,v]=a.useState(0),[y,x]=a.useState(null),D=a.useRef(null),E=a.useRef(null),{addAsset:j}=Ve(),u={zh:{local:"本地",library:"素材库",dragHint:"拖拽图片到此处",pasteHint:"或 Ctrl+V 粘贴",invalidFile:"请上传图片文件",fileTooLarge:"图片大小不能超过 25MB",someFilesInvalid:"部分文件格式不支持或超过25MB限制",loadFailed:"加载图片失败",maxCountReached:"最多上传 {count} 张图片"},en:{local:"Local",library:"Library",dragHint:"Drop images here",pasteHint:"or Ctrl+V to paste",invalidFile:"Please upload image files",fileTooLarge:"Image size cannot exceed 25MB",someFilesInvalid:"Some files are not supported or exceed 25MB limit",loadFailed:"Failed to load image",maxCountReached:"Maximum {count} images allowed"}}[l],N=a.useCallback(d=>d.type.startsWith("image/")?d.size>25*1024*1024?(U.error(u.fileTooLarge),!1):!0:(U.error(u.invalidFile),!1),[u]),W=a.useCallback((d,p)=>new Promise((S,L)=>{const A=new FileReader;A.onload=()=>{S({url:A.result,name:p,file:(d instanceof File,d)})},A.onerror=L,A.readAsDataURL(d)}),[]),$=a.useCallback(async(d,p)=>{const L=Array.from(d).filter(N);if(L.length===0)return;n&&t.length+L.length>m&&(U.warning(u.maxCountReached.replace("{count}",String(m))),L.splice(m-t.length));const A=[];for(const r of L)try{let s=r;if(r.size>10*1024*1024){const M=Xe(r.size/1048576),R=U.loading({content:l==="zh"?`正在压缩图片 (${(r.size/1024/1024).toFixed(1)}MB)...`:`Compressing image (${(r.size/1024/1024).toFixed(1)}MB)...`,duration:0,placement:"top"});try{s=await Qe(r,M.targetSizeMB),U.close(R),U.success({content:l==="zh"?`压缩完成: ${(r.size/1024/1024).toFixed(1)}MB → ${(s.size/1024/1024).toFixed(1)}MB`:`Compressed: ${(r.size/1024/1024).toFixed(1)}MB → ${(s.size/1024/1024).toFixed(1)}MB`,duration:2})}catch(w){U.close(R),console.error("[ReferenceImageUpload] Compression failed:",w),f==null||f(l==="zh"?"图片压缩失败":"Image compression failed");continue}}A.push({blob:s,name:r.name})}catch(s){console.error("[ReferenceImageUpload] Error processing file:",s),f==null||f(u.loadFailed);continue}if(A.length!==0){A.forEach(({blob:r,name:s})=>{j(r,we.IMAGE,Ye.LOCAL,s).catch(M=>{console.warn("[ReferenceImageUpload] Failed to add asset to library:",M)})});try{const r=await Promise.all(A.map(({blob:s,name:M})=>W(s,M)));if(h&&p!==void 0){const s=[...t];s[p]=r[0],o(s.filter(Boolean))}else o(n?[...t,...r]:r.slice(0,1));f==null||f(null)}catch(r){console.error("[ReferenceImageUpload] Failed to process files:",r),f==null||f(u.loadFailed)}}},[t,n,m,h,l,N,W,j,o,f,u]),H=a.useCallback(d=>{const p=d.target.files;p&&p.length>0&&$(p,h?c:void 0),d.target.value=""},[$,h,c]),Y=a.useCallback(async d=>{try{const S=await(await fetch(d.url)).blob(),L=new FileReader;L.onload=()=>{const A={url:L.result,name:d.name};if(h){const r=[...t];r[c]=A,o(r.filter(Boolean))}else if(n){if(t.length>=m){U.warning(u.maxCountReached.replace("{count}",String(m)));return}o([...t,A])}else o([A]);C(!1),f==null||f(null)},L.readAsDataURL(S)}catch(p){console.error("[ReferenceImageUpload] Failed to convert asset to base64:",p),f==null||f(u.loadFailed),C(!1)}},[t,n,m,h,c,o,f,u]),X=a.useCallback(d=>{d.preventDefault(),d.stopPropagation(),i||T(!0)},[i]),q=a.useCallback(d=>{var S;d.preventDefault(),d.stopPropagation();const p=(S=D.current)==null?void 0:S.getBoundingClientRect();if(p){const{clientX:L,clientY:A}=d;(L<p.left||L>p.right||A<p.top||A>p.bottom)&&T(!1)}},[]),G=a.useCallback(d=>{d.preventDefault(),d.stopPropagation()},[]),K=a.useCallback((d,p)=>{if(d.preventDefault(),d.stopPropagation(),T(!1),i)return;const S=d.dataTransfer.files;S&&S.length>0&&$(S,p)},[i,$]);a.useEffect(()=>{const d=async p=>{var M;if(i)return;const S=document.activeElement,L=D.current;if(!L||!(L.contains(S)||S===document.body||(S==null?void 0:S.tagName)==="BODY"))return;const r=(M=p.clipboardData)==null?void 0:M.items;if(!r)return;const s=[];for(let R=0;R<r.length;R++){const w=r[R];if(w.type.startsWith("image/")){const z=w.getAsFile();z&&s.push(z)}}s.length>0&&(p.preventDefault(),$(s))};return document.addEventListener("paste",d),()=>{document.removeEventListener("paste",d)}},[i,$]);const I=a.useCallback(d=>{const p=t.filter((S,L)=>L!==d);x(null),o(p)},[t,o]),_=a.useCallback(d=>{var p;d!==void 0&&v(d),(p=E.current)==null||p.click()},[]),P=a.useCallback(d=>{d!==void 0&&v(d),C(!0)},[]),Q=a.useCallback((d,p)=>{const S=p.currentTarget.getBoundingClientRect(),L=S.left+S.width/2,A=S.top-10;x({url:d,x:L,y:A})},[]),ae=a.useCallback(()=>{x(null)},[]),Z=d=>e.jsx("div",{className:`reference-image-upload__placeholder ${k?"reference-image-upload__placeholder--dragging":""}`,onDragEnter:X,onDragLeave:q,onDragOver:G,onDrop:p=>K(p,d),children:e.jsxs("div",{className:"reference-image-upload__buttons",children:[e.jsx(ne,{variant:"outline",icon:e.jsx(be,{size:16}),onClick:()=>_(d),disabled:i,"data-track":"reference_image_upload_local",className:"reference-image-upload__btn",children:u.local}),e.jsx(ne,{variant:"outline",icon:e.jsx(ye,{size:16}),onClick:()=>P(d),disabled:i,"data-track":"reference_image_upload_library",className:"reference-image-upload__btn",children:u.library})]})}),ee=(d,p)=>e.jsxs("div",{className:"reference-image-upload__preview",onMouseEnter:S=>Q(d.url,S),onMouseLeave:ae,children:[e.jsx("img",{src:d.url,alt:d.name,className:"reference-image-upload__image"}),e.jsx("button",{type:"button",className:"reference-image-upload__remove",onClick:()=>I(p),disabled:i,"data-track":"reference_image_upload_remove",children:e.jsx(et,{size:14})}),h&&h[p]&&e.jsx("div",{className:"reference-image-upload__slot-label",children:h[p]})]},p),re=()=>h?e.jsx("div",{className:"reference-image-upload__slots",children:h.map((d,p)=>{const S=t[p];return e.jsxs("div",{className:"reference-image-upload__slot",children:[e.jsx("div",{className:"reference-image-upload__slot-title",children:d}),S?ee(S,p):e.jsx("div",{className:`reference-image-upload__slot-placeholder ${k?"reference-image-upload__slot-placeholder--dragging":""}`,onDragEnter:X,onDragLeave:q,onDragOver:G,onDrop:L=>K(L,p),children:e.jsxs("div",{className:"reference-image-upload__slot-buttons",children:[e.jsx(ne,{variant:"outline",icon:e.jsx(be,{size:16}),onClick:()=>_(p),disabled:i,"data-track":"reference_image_upload_slot_local",className:"reference-image-upload__slot-btn",children:u.local}),e.jsx(ne,{variant:"outline",icon:e.jsx(ye,{size:16}),onClick:()=>P(p),disabled:i,"data-track":"reference_image_upload_slot_library",className:"reference-image-upload__slot-btn",children:u.library})]})})]},p)})}):null,se=()=>{const d=n&&t.length<m;return e.jsxs("div",{className:"reference-image-upload__grid",children:[t.map((p,S)=>ee(p,S)),d&&Z(),t.length===0&&!d&&Z()]})},oe=()=>t.length>0?e.jsxs("div",{className:"reference-image-upload__single",children:[ee(t[0],0),e.jsx("div",{className:"reference-image-upload__replace",children:Z()})]}):Z();return e.jsxs(e.Fragment,{children:[y&&Ke.createPortal(e.jsx("div",{className:"reference-image-upload__hover-preview",style:{left:`${y.x}px`,top:`${y.y}px`,transform:"translate(-50%, -100%)"},children:e.jsx("img",{src:y.url,alt:"Preview"})}),document.body),e.jsxs("div",{ref:D,className:`reference-image-upload ${i?"reference-image-upload--disabled":""}`,tabIndex:0,children:[b&&e.jsx("div",{className:"reference-image-upload__label",children:b}),e.jsx("input",{ref:E,type:"file",accept:"image/*",multiple:n&&!h,onChange:H,className:"reference-image-upload__input",disabled:i}),h?re():n?se():oe(),e.jsx(Ze,{isOpen:g,onClose:()=>C(!1),mode:Je.SELECT,filterType:we.IMAGE,onSelect:Y})]})]})},De="aitu-dialog-task-list-width-",pe=240,he=800,Dt=()=>{const t=Math.round(660);return Math.max(pe,Math.min(he,t))},Ot=t=>{try{const o=localStorage.getItem(De+t);if(o){const l=parseInt(o,10);if(!isNaN(l)&&l>=pe&&l<=he)return l}}catch{}return Dt()},Me=(t,o)=>{try{localStorage.setItem(De+t,o.toString())}catch{}},Ht=({isRightPanelVisible:t,onToggleRightPanel:o,onWidthChange:l,rightPanelWidth:i,minWidth:n=pe,maxWidth:m=he,onResizeStart:b,onResizeEnd:h,language:f="zh",disabled:g=!1,storageKey:C="image"})=>{const[k,T]=a.useState(!1),c=a.useRef(0),v=a.useRef(0);a.useEffect(()=>(k?(document.body.style.userSelect="none",document.body.style.cursor="col-resize"):(document.body.style.userSelect="",document.body.style.cursor=""),()=>{document.body.style.userSelect="",document.body.style.cursor=""}),[k]);const y=a.useCallback(D=>{if(g||!t)return;D.preventDefault(),D.stopPropagation(),T(!0),c.current=D.clientX,v.current=i,b==null||b();const E=B=>{const u=c.current-B.clientX,N=Math.max(n,Math.min(m,v.current+u));l(N)},j=()=>{T(!1),h==null||h(),v.current+(c.current-document.body.getBoundingClientRect().left),Me(C,i),document.removeEventListener("mousemove",E),document.removeEventListener("mouseup",j)};document.addEventListener("mousemove",E),document.addEventListener("mouseup",j)},[g,t,i,n,m,l,b,h,C]);a.useEffect(()=>{!k&&t&&Me(C,i)},[i,k,t,C]);const x=t?f==="zh"?"隐藏任务列表":"Hide Task List":f==="zh"?"显示任务列表":"Show Task List";return e.jsxs("div",{className:`resizable-divider ${k?"is-dragging":""} ${t?"":"is-collapsed"} ${g?"is-disabled":""}`,onMouseDown:y,children:[e.jsx("div",{className:"resizable-divider__bar"}),e.jsx(de,{content:x,theme:"light",placement:"left",children:e.jsx("button",{type:"button",className:"resizable-divider__toggle",onClick:D=>{D.stopPropagation(),o()},"aria-label":x,children:t?e.jsx(tt,{size:"14px"}):e.jsx(st,{size:"14px"})})})]})},Ut=({storageKey:t,language:o})=>{const[l,i]=a.useState(()=>{try{return localStorage.getItem(t)!=="false"}catch{return!0}}),n=a.useCallback(m=>{i(m);try{localStorage.setItem(t,String(m))}catch{}},[t]);return e.jsx(de,{content:o==="zh"?"生成后自动插入画布":"Auto insert to canvas after generation",theme:"light",children:e.jsx(nt,{checked:l,onChange:n,className:"auto-insert-checkbox"})})};function Wt(t){try{return localStorage.getItem(t)!=="false"}catch{return!0}}function Tt(t={}){const{taskType:o}=t,{tasks:l,isLoading:i}=at(),{retryTask:n,deleteTask:m}=rt(),b=a.useMemo(()=>[...o?l.filter(C=>C.type===o):l].sort((C,k)=>k.createdAt-C.createdAt),[l,o]),h=a.useCallback(async()=>{},[]),f=a.useCallback(async()=>{if(ot(),!await Ce.isAvailable())return;const C=await Ce.getAllTasks();C.length>0&&it.restoreTasks(C)},[]);return{tasks:b,isLoading:i,isLoadingMore:!1,hasMore:!1,totalCount:b.length,loadedCount:b.length,loadMore:h,refresh:f,retryTask:n,deleteTask:m}}const qt=({taskIds:t,taskType:o,onEditTask:l})=>{const{tasks:i,isLoading:n,isLoadingMore:m,hasMore:b,totalCount:h,loadedCount:f,loadMore:g,retryTask:C,deleteTask:k}=Tt({taskType:o}),{board:T,openDialog:c}=lt(),[v,y]=a.useState(!1),[x,D]=a.useState(null),[E,j]=a.useState(!1),[B,u]=a.useState(0),[N,W]=a.useState(""),[$,H]=a.useState(null),[Y,X]=a.useState(!1),q=a.useMemo(()=>i.filter(r=>r.status===J.FAILED).length,[i]),G=a.useCallback(()=>{const r=i.filter(s=>s.status===J.FAILED);r.forEach(s=>k(s.id)),X(!1),U.success(`已清除 ${r.length} 个失败任务`)},[i,k]),K=(r,s)=>{var F,O,V,ue,ie,le,fe,ge,ve,xe;if(!s.trim())return!0;const M=s.toLowerCase().split(/\s+/).filter(Boolean),R={[J.PENDING]:"处理中",[J.PROCESSING]:"处理中",[J.COMPLETED]:"已完成",[J.FAILED]:"失败",[J.CANCELLED]:"已取消"},w=[];w.push(((F=r.params)==null?void 0:F.prompt)??""),w.push(((O=r.params)==null?void 0:O.model)??""),w.push(r.id??""),w.push(R[r.status]??String(r.status)),(V=r.params)!=null&&V.batchId&&w.push(String(r.params.batchId)),(ue=r.params)!=null&&ue.batchIndex&&w.push(String(r.params.batchIndex)),(ie=r.params)!=null&&ie.batchTotal&&w.push(String(r.params.batchTotal)),(le=r.result)!=null&&le.format&&w.push(String(r.result.format)),(fe=r.result)!=null&&fe.width&&((ge=r.result)!=null&&ge.height)?w.push(`${r.result.width}x${r.result.height}`):(ve=r.params)!=null&&ve.width&&((xe=r.params)!=null&&xe.height)&&w.push(`${r.params.width}x${r.params.height}`);const z=w.join(" ").toLowerCase();return M.every(Te=>z.includes(Te))},I=a.useMemo(()=>{let r=i;return t&&t.length>0&&(r=r.filter(s=>t.includes(s.id))),N.trim()&&(r=r.filter(s=>K(s,N))),r.sort((s,M)=>M.createdAt-s.createdAt)},[i,t,N]),_=r=>{C(r)},P=r=>{D(r),y(!0)},Q=()=>{x&&k(x),y(!1),D(null)},ae=async r=>{var R,w,z,F;const s=i.find(O=>O.id===r);if(!((R=s==null?void 0:s.result)!=null&&R.url)&&!((z=(w=s==null?void 0:s.result)==null?void 0:w.urls)!=null&&z.length))return;const M=(F=s.result.urls)!=null&&F.length?s.result.urls:[s.result.url];try{for(let O=0;O<M.length;O++){const V=M[O],ue=`${vt(s.params.prompt)||s.type}${M.length>1?`-${O+1}`:""}.${s.result.format}`,ie=await xt.getCachedBlob(V);if(ie){wt(ie,ue);continue}const le=await bt(V,s.params.prompt,s.result.format,s.type);le&&"opened"in le}U.success(M.length>1?"多图已开始下载":"下载成功")}catch(O){console.error("Download failed:",O),U.error("下载失败,请稍后重试")}},Z=async r=>{var M,R,w,z;const s=i.find(F=>F.id===r);if(!((M=s==null?void 0:s.result)!=null&&M.url)&&!((w=(R=s==null?void 0:s.result)==null?void 0:R.urls)!=null&&w.length)||!T){console.warn("Cannot insert: task result or board not available"),U.warning("无法插入:白板未就绪");return}try{if(s.type===te.IMAGE){const F=(z=s.result.urls)!=null&&z.length?s.result.urls:[s.result.url];for(const O of F)await ft(T,O);U.success(F.length>1?"多图已插入到白板":"图片已插入到白板")}else s.type===te.VIDEO&&(await gt(T,s.result.url),U.success("视频已插入到白板"))}catch(F){console.error("Failed to insert to board:",F),U.error(`插入失败: ${F instanceof Error?F.message:"未知错误"}`)}},ee=r=>{var M,R,w,z;const s=i.find(F=>F.id===r);if(!s){console.warn("Cannot edit: task not found");return}if(l){l(s);return}if(s.type===te.IMAGE){const F={initialPrompt:s.params.prompt,initialWidth:s.params.width,initialHeight:s.params.height,initialImages:s.params.uploadedImages,initialResultUrl:(M=s.result)==null?void 0:M.url,initialResultUrls:(R=s.result)==null?void 0:R.urls};c(Ie.aiImageGeneration,F)}else if(s.type===te.VIDEO){const F={initialPrompt:s.params.prompt,initialDuration:typeof s.params.seconds=="string"?parseInt(s.params.seconds,10):s.params.seconds,initialModel:s.params.model,initialSize:s.params.size,initialImages:s.params.uploadedImages,initialResultUrl:(w=s.result)==null?void 0:w.url,initialResultUrls:(z=s.result)==null?void 0:z.urls};c(Ie.aiVideoGeneration,F)}},re=r=>{const s=i.find(M=>M.id===r);s&&H(s)},se=a.useMemo(()=>{const r=new Set;return I.filter(s=>{var M,R,w;return s.status!==J.COMPLETED||!((M=s.result)!=null&&M.url)&&!((w=(R=s.result)==null?void 0:R.urls)!=null&&w.length)||r.has(s.id)?!1:(r.add(s.id),!0)})},[I]),{previewMediaItems:oe,taskIdToPreviewIndex:d}=a.useMemo(()=>{var M,R;const r=[],s=new Map;for(const w of se){const z=(M=w.result.urls)!=null&&M.length?w.result.urls:[w.result.url],F=w.type===te.VIDEO?"video":"image",O=(R=w.params.prompt)==null?void 0:R.substring(0,50);s.set(w.id,r.length);for(let V=0;V<z.length;V++)r.push({id:z.length>1?`${w.id}-${V}`:w.id,url:z[V],type:F,title:z.length>1?`${O} (${V+1}/${z.length})`:O})}return{previewMediaItems:r,taskIdToPreviewIndex:s}},[se]),p=a.useCallback(r=>{const s=d.get(r);s!==void 0&&(u(s),j(!0))},[d]),S=a.useCallback(()=>{j(!1)},[]),L=N.trim()&&I.length===0&&i.length>0,A=h>0?h:i.length;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"dialog-task-list",children:[e.jsxs("div",{className:"dialog-task-list__header",children:[e.jsxs("div",{className:"dialog-task-list__header-main",children:[e.jsxs("h4",{children:["生成任务 (",A,")"]}),e.jsx("div",{className:"dialog-task-list__header-actions",children:q>0&&e.jsx(de,{content:`清除全部失败任务 (${q})`,theme:"light",children:e.jsx(ne,{size:"small",variant:"text",icon:e.jsx(ct,{}),onClick:()=>X(!0)})})})]}),e.jsx("div",{className:"dialog-task-list__search",children:e.jsx(dt,{value:N,onChange:r=>W(r),placeholder:"搜索任务(提示词/模型/...)",clearable:!0,prefixIcon:e.jsx(ut,{}),size:"small"})})]}),e.jsx(mt,{tasks:I,onRetry:_,onDelete:P,onDownload:ae,onInsert:Z,onEdit:ee,onPreviewOpen:p,onExtractCharacter:re,hasMore:b,isLoadingMore:m,onLoadMore:g,totalCount:A,loadedCount:f,className:"dialog-task-list__content",emptyContent:e.jsx("div",{className:"dialog-task-list__empty",children:n?e.jsx("p",{children:"加载中..."}):L?e.jsx("p",{children:"未找到匹配的任务"}):e.jsx("p",{children:"暂无生成任务"})})})]}),e.jsx(_e,{visible:v,header:"确认删除",onClose:()=>y(!1),onConfirm:Q,onCancel:()=>y(!1),children:"确定要删除此任务吗?此操作无法撤销。"}),e.jsxs(_e,{visible:Y,header:"清除失败任务",onClose:()=>X(!1),onConfirm:G,onCancel:()=>X(!1),children:["确定要清除全部 ",q," 个失败任务吗?此操作无法撤销。"]}),e.jsx(pt,{visible:E,items:oe,initialIndex:B,onClose:S,showThumbnails:!0}),e.jsx(ht,{visible:!!$,task:$,onClose:()=>H(null),onCreateComplete:r=>{H(null)}})]})};export{At as A,St as C,qt as D,Ft as E,Et as P,Bt as R,Rt as a,Lt as b,Ut as c,Ht as d,Wt as e,jt as f,$t as g,Ot as l,zt as s,Pt as u};
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-7WzIC7_D.js","./index-qP_w2VHW.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{bT as V,r as t,aQ as e,d_ as Ft,c0 as ae,bW as de,ei as Bt,fG as Me,fH as rt,fI as ue,b$ as xe,cd as ke,fJ as _e,fK as ze,fL as Kt,fM as se,bm as ct,fN as Ge,cU as M,fO as $e,bn as Ee,fP as Ot,fQ as Le,d$ as be,bX as lt,bh as he,eR as Ht,cP as Vt,fR as Xt,bd as A,fS as dt,fT as ut,d1 as qt,aW as Qe,bp as Re,fU as Yt,fV as Gt,b1 as Qt,ef as ht,cJ as Ze,fW as Zt,cG as Se,fX as Jt,bf as es}from"./index-7WzIC7_D.js";/**
|
|
3
|
-
* @license lucide-react v0.562.0 - ISC
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the ISC license.
|
|
6
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/const ts=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Je=V("arrow-down",ts);/**
|
|
8
|
-
* @license lucide-react v0.562.0 - ISC
|
|
9
|
-
*
|
|
10
|
-
* This source code is licensed under the ISC license.
|
|
11
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
12
|
-
*/const ss=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],et=V("arrow-up",ss);/**
|
|
13
|
-
* @license lucide-react v0.562.0 - ISC
|
|
14
|
-
*
|
|
15
|
-
* This source code is licensed under the ISC license.
|
|
16
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/const ns=[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]],as=V("book-open",ns);/**
|
|
18
|
-
* @license lucide-react v0.562.0 - ISC
|
|
19
|
-
*
|
|
20
|
-
* This source code is licensed under the ISC license.
|
|
21
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
22
|
-
*/const os=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],is=V("bot",os);/**
|
|
23
|
-
* @license lucide-react v0.562.0 - ISC
|
|
24
|
-
*
|
|
25
|
-
* This source code is licensed under the ISC license.
|
|
26
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
27
|
-
*/const rs=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],cs=V("circle-stop",rs);/**
|
|
28
|
-
* @license lucide-react v0.562.0 - ISC
|
|
29
|
-
*
|
|
30
|
-
* This source code is licensed under the ISC license.
|
|
31
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
32
|
-
*/const ls=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],De=V("external-link",ls);/**
|
|
33
|
-
* @license lucide-react v0.562.0 - ISC
|
|
34
|
-
*
|
|
35
|
-
* This source code is licensed under the ISC license.
|
|
36
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
37
|
-
*/const ds=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],fe=V("file-text",ds);/**
|
|
38
|
-
* @license lucide-react v0.562.0 - ISC
|
|
39
|
-
*
|
|
40
|
-
* This source code is licensed under the ISC license.
|
|
41
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
42
|
-
*/const us=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],hs=V("folder-open",us);/**
|
|
43
|
-
* @license lucide-react v0.562.0 - ISC
|
|
44
|
-
*
|
|
45
|
-
* This source code is licensed under the ISC license.
|
|
46
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
47
|
-
*/const ms=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],ps=V("folder-plus",ms);/**
|
|
48
|
-
* @license lucide-react v0.562.0 - ISC
|
|
49
|
-
*
|
|
50
|
-
* This source code is licensed under the ISC license.
|
|
51
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
52
|
-
*/const fs=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],xs=V("folder",fs);/**
|
|
53
|
-
* @license lucide-react v0.562.0 - ISC
|
|
54
|
-
*
|
|
55
|
-
* This source code is licensed under the ISC license.
|
|
56
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
57
|
-
*/const ks=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],_s=V("funnel",ks);/**
|
|
58
|
-
* @license lucide-react v0.562.0 - ISC
|
|
59
|
-
*
|
|
60
|
-
* This source code is licensed under the ISC license.
|
|
61
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
62
|
-
*/const bs=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],mt=V("link-2",bs);/**
|
|
63
|
-
* @license lucide-react v0.562.0 - ISC
|
|
64
|
-
*
|
|
65
|
-
* This source code is licensed under the ISC license.
|
|
66
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
67
|
-
*/const gs=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],Te=V("lock",gs);/**
|
|
68
|
-
* @license lucide-react v0.562.0 - ISC
|
|
69
|
-
*
|
|
70
|
-
* This source code is licensed under the ISC license.
|
|
71
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
72
|
-
*/const ws=[["path",{d:"M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4",key:"re6nr2"}],["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["path",{d:"M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"pqwjuv"}]],js=V("notebook-pen",ws);/**
|
|
73
|
-
* @license lucide-react v0.562.0 - ISC
|
|
74
|
-
*
|
|
75
|
-
* This source code is licensed under the ISC license.
|
|
76
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
77
|
-
*/const ys=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]],vs=V("panel-right-close",ys);/**
|
|
78
|
-
* @license lucide-react v0.562.0 - ISC
|
|
79
|
-
*
|
|
80
|
-
* This source code is licensed under the ISC license.
|
|
81
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
82
|
-
*/const Ns=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]],Cs=V("panel-right",Ns);/**
|
|
83
|
-
* @license lucide-react v0.562.0 - ISC
|
|
84
|
-
*
|
|
85
|
-
* This source code is licensed under the ISC license.
|
|
86
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
87
|
-
*/const Ss=[["path",{d:"M13.172 2a2 2 0 0 1 1.414.586l6.71 6.71a2.4 2.4 0 0 1 0 3.408l-4.592 4.592a2.4 2.4 0 0 1-3.408 0l-6.71-6.71A2 2 0 0 1 6 9.172V3a1 1 0 0 1 1-1z",key:"16rjxf"}],["path",{d:"M2 7v6.172a2 2 0 0 0 .586 1.414l6.71 6.71a2.4 2.4 0 0 0 3.191.193",key:"178nd4"}],["circle",{cx:"10.5",cy:"6.5",r:".5",fill:"currentColor",key:"12ikhr"}]],Ms=V("tags",Ss);/**
|
|
88
|
-
* @license lucide-react v0.562.0 - ISC
|
|
89
|
-
*
|
|
90
|
-
* This source code is licensed under the ISC license.
|
|
91
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
92
|
-
*/const zs=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],tt=V("upload",zs);/**
|
|
93
|
-
* @license lucide-react v0.562.0 - ISC
|
|
94
|
-
*
|
|
95
|
-
* This source code is licensed under the ISC license.
|
|
96
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
97
|
-
*/const Es=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]],Rs=V("volume-2",Es);/**
|
|
98
|
-
* @license lucide-react v0.562.0 - ISC
|
|
99
|
-
*
|
|
100
|
-
* This source code is licensed under the ISC license.
|
|
101
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
102
|
-
*/const Ds=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]],Ts=V("volume-x",Ds),ne="__system_skill__";function $s(s){const n=new Date(s),r=new Date;return n.getFullYear()===r.getFullYear()&&n.getMonth()===r.getMonth()&&n.getDate()===r.getDate()?n.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"}):n.getFullYear()===r.getFullYear()?n.toLocaleDateString("zh-CN",{month:"2-digit",day:"2-digit"}):n.toLocaleDateString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit"})}const Ls=({directories:s,notesByDir:n,noteTagsMap:r,noteCounts:l,selectedDirId:x,selectedNoteId:p,expandedDirIds:h,isCreatingDir:d,skillDirName:w="Skill",onSelectDir:z,onToggleExpand:N,onCreateDir:g,onCancelCreateDir:v,onRenameDir:j,onDeleteDir:_,onSelectNote:S,onCreateNote:m,onDeleteNote:b,onDuplicateDir:T,onDuplicateNote:U,onInsertNoteToCanvas:E})=>{const[L,C]=t.useState(""),[W,K]=t.useState(null),[X,Y]=t.useState(""),[H,i]=t.useState(null);t.useEffect(()=>{const f=()=>i(null),R=()=>i(null);return document.addEventListener("click",f),document.addEventListener("scroll",R,!0),()=>{document.removeEventListener("click",f),document.removeEventListener("scroll",R,!0)}},[]);const F=t.useCallback((f,R,q,oe=!1)=>{f.preventDefault(),f.stopPropagation(),i({x:f.clientX,y:f.clientY,type:R,id:q,isDefault:oe})},[]),I=t.useCallback(async()=>{const f=L.trim();if(f)try{await g(f),C(""),v()}catch{}},[L,g,v]),B=t.useCallback(async f=>{const R=X.trim();if(R)try{await j(f,R),K(null)}catch{}},[X,j]);return e.jsxs("div",{className:"kb-tree",children:[d&&e.jsxs("div",{className:"kb-tree__create-row",children:[e.jsx("input",{className:"kb-tree__input",value:L,onChange:f=>C(f.target.value),onKeyDown:f=>{f.key==="Enter"&&I(),f.key==="Escape"&&v()},placeholder:"目录名称",autoFocus:!0}),e.jsx("button",{className:"kb-tree__icon-btn",onClick:I,children:e.jsx(ae,{size:14})}),e.jsx("button",{className:"kb-tree__icon-btn",onClick:v,children:e.jsx(de,{size:14})})]}),e.jsx("div",{className:"kb-tree__list",children:s.map(f=>e.jsx(Ps,{dir:f,isSelected:x===f.id,isExpanded:h.has(f.id),notes:n[f.id]||[],noteCount:l[f.id]||0,noteTagsMap:r,selectedNoteId:p,isRenaming:W===f.id,renameValue:X,onSelectDir:()=>{z(f.id),h.has(f.id)||N(f.id)},onToggleExpand:()=>{N(f.id),i(null)},onStartRename:()=>{K(f.id),Y(f.name),i(null)},onRenameChange:Y,onRenameConfirm:()=>B(f.id),onRenameCancel:()=>K(null),onDeleteDir:()=>{_(f.id),i(null)},onCreateNote:()=>{m(f.id),i(null)},onSelectNote:S,onDeleteNote:R=>{b(R),i(null)},onContextMenu:R=>F(R,"directory",f.id,f.isDefault),onNoteContextMenu:(R,q)=>F(R,"note",q),isSkillDir:f.name===w},f.id))}),H&&Ft.createPortal(e.jsx("div",{className:"kb-context-menu",style:{top:H.y,left:H.x,zIndex:Bt.DROPDOWN_PORTAL},onClick:f=>f.stopPropagation(),children:H.type==="directory"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"kb-context-menu__item",onClick:()=>{T(H.id),i(null)},children:[e.jsx(Me,{size:14}),e.jsx("span",{children:"复制目录"})]}),e.jsxs("div",{className:"kb-context-menu__item",onClick:()=>{var f;K(H.id),Y(((f=s.find(R=>R.id===H.id))==null?void 0:f.name)||""),i(null)},children:[e.jsx(rt,{size:14}),e.jsx("span",{children:"重命名"})]}),e.jsxs("div",{className:"kb-context-menu__item kb-context-menu__item--danger",onClick:()=>{_(H.id),i(null)},children:[e.jsx(ue,{size:14}),e.jsx("span",{children:"删除"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"kb-context-menu__item",onClick:()=>{U(H.id),i(null)},children:[e.jsx(Me,{size:14}),e.jsx("span",{children:"创建副本"})]}),E&&e.jsxs("div",{className:"kb-context-menu__item",onClick:()=>{const R=Object.values(n).flat().find(q=>q.id===H.id);R&&E(R),i(null)},children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),e.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"16"}),e.jsx("line",{x1:"8",y1:"12",x2:"16",y2:"12"})]}),e.jsx("span",{children:"插入到画布"})]}),e.jsxs("div",{className:"kb-context-menu__item kb-context-menu__item--danger",onClick:()=>{b(H.id),i(null)},children:[e.jsx(ue,{size:14}),e.jsx("span",{children:"删除"})]})]})}),document.body)]})},Ps=({dir:s,isSelected:n,isExpanded:r,notes:l,noteCount:x,noteTagsMap:p,selectedNoteId:h,isRenaming:d,renameValue:w,isSkillDir:z=!1,onSelectDir:N,onToggleExpand:g,onStartRename:v,onRenameChange:j,onRenameConfirm:_,onRenameCancel:S,onDeleteDir:m,onCreateNote:b,onSelectNote:T,onDeleteNote:U,onContextMenu:E,onNoteContextMenu:L})=>e.jsxs("div",{className:`kb-tree__dir ${n?"kb-tree__dir--selected":""}`,children:[e.jsxs("div",{className:"kb-tree__dir-row",onClick:N,onContextMenu:E,children:[e.jsx("button",{className:"kb-tree__expand-btn",onClick:C=>{C.stopPropagation(),g()},children:r?e.jsx(xe,{size:14}):e.jsx(ke,{size:14})}),r?e.jsx(hs,{size:16}):e.jsx(xs,{size:16}),d?e.jsx("input",{className:"kb-tree__input kb-tree__input--inline",value:w,onChange:C=>j(C.target.value),onKeyDown:C=>{C.key==="Enter"&&_(),C.key==="Escape"&&S()},onClick:C=>C.stopPropagation(),autoFocus:!0}):e.jsx("span",{className:"kb-tree__dir-name",children:s.name}),e.jsx("span",{className:"kb-tree__dir-count",children:x}),e.jsxs("div",{className:"kb-tree__dir-actions",children:[e.jsx("button",{className:"kb-tree__icon-btn",onClick:C=>{C.stopPropagation(),b()},title:"新建笔记",children:e.jsx(_e,{size:12})}),e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"kb-tree__icon-btn",onClick:C=>{C.stopPropagation(),v()},title:"重命名",children:e.jsx(rt,{size:12})}),e.jsx("button",{className:"kb-tree__icon-btn kb-tree__icon-btn--danger",onClick:C=>{C.stopPropagation(),m()},title:"删除",children:e.jsx(ue,{size:12})})]})]})]}),r&&e.jsxs("div",{className:"kb-tree__notes",children:[z&&ze.map(C=>{const W=`${ne}${C.id}`,K=h===W;return e.jsxs("div",{className:`kb-tree__note-row kb-tree__note-row--system ${K?"kb-tree__note-row--selected":""}`,onClick:()=>T(W),children:[e.jsx("div",{className:"kb-tree__note-icon",children:e.jsx(Te,{size:14})}),e.jsx("div",{className:"kb-tree__note-content",children:e.jsxs("div",{className:"kb-tree__note-title",children:[C.name,e.jsx("span",{className:"kb-tree__system-badge",children:"系统"})]})})]},W)}),z&&Kt().map(C=>{const W=`${se}${C.id}`,K=h===W;return e.jsxs("div",{className:`kb-tree__note-row kb-tree__note-row--system ${K?"kb-tree__note-row--selected":""}`,onClick:()=>T(W),children:[e.jsx("div",{className:"kb-tree__note-icon",children:e.jsx(Te,{size:14})}),e.jsx("div",{className:"kb-tree__note-content",children:e.jsxs("div",{className:"kb-tree__note-title",children:[C.name,e.jsx("span",{className:"kb-tree__system-badge",children:"系统"})]})})]},W)}),l.length===0&&!z&&e.jsx("div",{className:"kb-tree__notes-empty",children:"暂无笔记"}),l.length===0&&z&&ze.length===0&&e.jsx("div",{className:"kb-tree__notes-empty",children:"暂无笔记"}),Array.from(new Map(l.map(C=>[C.id,C])).values()).map(C=>{const W=h===C.id,K=p[C.id]||[],X=C.metadata;return e.jsx(As,{note:C,isSelected:W,tags:K,metadata:X,onSelect:()=>T(C.id),onDelete:()=>U(C.id),onContextMenu:Y=>L(Y,C.id)},C.id)})]})]}),As=({note:s,isSelected:n,tags:r,metadata:l,onSelect:x,onDelete:p,onContextMenu:h})=>e.jsxs("div",{className:`kb-tree__note-row ${n?"kb-tree__note-row--selected":""}`,onClick:x,onContextMenu:h,children:[e.jsx("div",{className:"kb-tree__note-icon",children:e.jsx(fe,{size:14})}),e.jsxs("div",{className:"kb-tree__note-content",children:[e.jsx("div",{className:"kb-tree__note-title",children:s.title||"无标题"}),(l==null?void 0:l.domain)&&e.jsxs("div",{className:"kb-tree__note-domain",children:[l.faviconUrl?e.jsx("img",{src:l.faviconUrl,alt:"",className:"kb-tree__favicon",onError:d=>{d.target.style.display="none"}}):e.jsx(ct,{size:10}),e.jsx("span",{children:l.domain})]}),e.jsxs("div",{className:"kb-tree__note-meta",children:[r.length>0&&e.jsxs("div",{className:"kb-tree__note-tags",children:[r.slice(0,2).map(d=>e.jsx("span",{className:"kb-tree__tag-badge",style:{backgroundColor:`${d.color}20`,color:d.color},children:d.name},d.id)),r.length>2&&e.jsxs("span",{className:"kb-tree__tag-more",children:["+",r.length-2]})]}),r.length===0&&!(l!=null&&l.domain)&&e.jsx("span",{className:"kb-tree__note-time",children:$s(s.updatedAt)})]})]}),e.jsx("button",{className:"kb-tree__note-delete",onClick:d=>{d.stopPropagation(),p()},title:"删除笔记",children:e.jsx(ue,{size:12})})]}),st=({allTags:s,selectedTagIds:n,onSelectedChange:r,onCreateTag:l,showCount:x=!1})=>{const[p,h]=t.useState(!1),[d,w]=t.useState(""),[z,N]=t.useState(!1),g=t.useRef(null);t.useEffect(()=>{if(!p)return;const m=b=>{g.current&&!g.current.contains(b.target)&&(h(!1),N(!1),w(""))};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[p]);const v=t.useCallback(m=>{const b=n.includes(m)?n.filter(T=>T!==m):[...n,m];r(b)},[n,r]),j=t.useCallback((m,b)=>{b.stopPropagation(),r(n.filter(T=>T!==m))},[n,r]),_=t.useCallback(async()=>{const m=d.trim();if(m)try{const b=await l(m);r([...n,b.id]),w(""),N(!1)}catch{}},[d,l,n,r]),S=s.filter(m=>n.includes(m.id));return e.jsxs("div",{className:"kb-tag-selector",ref:g,children:[e.jsxs("div",{className:"kb-tag-selector__selected",children:[S.map(m=>e.jsxs("span",{className:"kb-tag-selector__tag kb-tag-selector__tag--selected",style:{"--tag-color":m.color,borderColor:m.color,backgroundColor:`${m.color}15`},children:[e.jsx("span",{className:"kb-tag-selector__dot",style:{backgroundColor:m.color}}),e.jsx("span",{children:m.name}),e.jsx("button",{className:"kb-tag-selector__remove",onClick:b=>j(m.id,b),title:"移除标签",children:e.jsx(de,{size:11})})]},m.id)),e.jsxs("button",{className:"kb-tag-selector__add-btn",onClick:()=>h(m=>!m),children:[e.jsx(_e,{size:13}),e.jsx("span",{children:"标签"})]})]}),p&&e.jsxs("div",{className:"kb-tag-selector__dropdown",children:[e.jsxs("div",{className:"kb-tag-selector__tags",children:[s.length===0&&e.jsx("span",{className:"kb-tag-selector__empty",children:"暂无标签"}),s.map(m=>{const b=n.includes(m.id);return e.jsxs("button",{className:`kb-tag-selector__tag ${b?"kb-tag-selector__tag--selected":""}`,style:{"--tag-color":m.color,borderColor:b?m.color:void 0,backgroundColor:b?`${m.color}15`:void 0},onClick:()=>v(m.id),children:[e.jsx("span",{className:"kb-tag-selector__dot",style:{backgroundColor:m.color}}),e.jsx("span",{children:m.name}),x&&e.jsxs("span",{className:"kb-tag-selector__count",children:["(",m.count,")"]}),b&&e.jsx(de,{size:12})]},m.id)})]}),z?e.jsxs("div",{className:"kb-tag-selector__create",children:[e.jsx("input",{className:"kb-tag-selector__input",value:d,onChange:m=>w(m.target.value),onKeyDown:m=>{m.key==="Enter"&&_(),m.key==="Escape"&&(N(!1),w(""))},placeholder:"标签名称",autoFocus:!0}),e.jsx("button",{className:"kb-tag-selector__create-btn",onClick:_,children:"确定"})]}):e.jsxs("button",{className:"kb-tag-selector__new-btn",onClick:()=>N(!0),children:[e.jsx(_e,{size:13}),e.jsx("span",{children:"新建标签"})]})]})]})},Is=({outputType:s,onOutputTypeChange:n,readOnly:r=!1})=>e.jsx("div",{className:"mcp-tool-selector",children:e.jsxs("div",{className:"mcp-tool-selector__output-type",children:[e.jsx("span",{className:"mcp-tool-selector__output-type-label",children:"输出类型"}),e.jsx("div",{className:"mcp-tool-selector__output-type-options",children:r?e.jsx("span",{className:"mcp-tool-selector__output-type-value",children:s==="image"?"图片":s==="video"?"视频":s==="ppt"?"PPT":"文本"}):e.jsxs(e.Fragment,{children:[e.jsx("button",{className:`mcp-tool-selector__output-type-btn ${!s||s==="text"?"mcp-tool-selector__output-type-btn--active":""}`,onClick:()=>n==null?void 0:n(void 0),children:"文本"}),e.jsx("button",{className:`mcp-tool-selector__output-type-btn ${s==="image"?"mcp-tool-selector__output-type-btn--active":""}`,onClick:()=>n==null?void 0:n("image"),children:"图片"}),e.jsx("button",{className:`mcp-tool-selector__output-type-btn ${s==="video"?"mcp-tool-selector__output-type-btn--active":""}`,onClick:()=>n==null?void 0:n("video"),children:"视频"}),e.jsx("button",{className:`mcp-tool-selector__output-type-btn ${s==="ppt"?"mcp-tool-selector__output-type-btn--active":""}`,onClick:()=>n==null?void 0:n("ppt"),children:"PPT"})]})})]})});function Us(s){return s.replace(/```[\s\S]*?```/g,"").replace(/`([^`]+)`/g,"$1").replace(/!\[([^\]]*)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/^#{1,6}\s+/gm,"").replace(/\*\*(.+?)\*\*/g,"$1").replace(/\*(.+?)\*/g,"$1").replace(/__(.+?)__/g,"$1").replace(/_(.+?)_/g,"$1").replace(/~~(.+?)~~/g,"$1").replace(/^[\s]*[-*+]\s+/gm,"").replace(/^[\s]*\d+\.\s+/gm,"").replace(/^>\s+/gm,"").replace(/^[-*_]{3,}$/gm,"").replace(/<[^>]+>/g,"").replace(/\n{3,}/g,`
|
|
103
|
-
|
|
104
|
-
`).trim()}function Ws(){const[s,n]=t.useState({isSpeaking:!1,isPaused:!1,isSupported:typeof window<"u"&&"speechSynthesis"in window}),r=t.useRef(null);t.useEffect(()=>()=>{s.isSupported&&window.speechSynthesis.cancel()},[s.isSupported]);const l=t.useCallback(d=>{if(!s.isSupported)return;window.speechSynthesis.cancel();const w=Us(d);if(!w)return;const z=new SpeechSynthesisUtterance(w);z.lang="zh-CN",z.rate=1,z.pitch=1;const N=window.speechSynthesis.getVoices(),g=N.find(v=>v.lang.startsWith("zh")&&v.localService)||N.find(v=>v.lang.startsWith("zh"));g&&(z.voice=g),z.onend=()=>{n(v=>({...v,isSpeaking:!1,isPaused:!1})),r.current=null},z.onerror=()=>{n(v=>({...v,isSpeaking:!1,isPaused:!1})),r.current=null},r.current=z,window.speechSynthesis.speak(z),n(v=>({...v,isSpeaking:!0,isPaused:!1}))},[s.isSupported]),x=t.useCallback(()=>{s.isSupported&&(window.speechSynthesis.pause(),n(d=>({...d,isPaused:!0})))},[s.isSupported]),p=t.useCallback(()=>{s.isSupported&&(window.speechSynthesis.resume(),n(d=>({...d,isPaused:!1})))},[s.isSupported]),h=t.useCallback(()=>{s.isSupported&&(window.speechSynthesis.cancel(),r.current=null,n(d=>({...d,isSpeaking:!1,isPaused:!1})))},[s.isSupported]);return{...s,speak:l,pause:x,resume:p,stop:h}}const Fs=({note:s,allTags:n,noteTags:r,readOnly:l=!1,isSkillDirectory:x=!1,onUpdateNote:p,onSetNoteTags:h,onCreateTag:d})=>{const[w,z]=t.useState(""),[N,g]=t.useState(!1),[v,j]=t.useState(null),_=t.useRef(null),S=t.useRef(null),m=t.useRef(null),b=t.useRef(null),{isSpeaking:T,isPaused:U,isSupported:E,speak:L,pause:C,resume:W,stop:K}=Ws(),X=t.useMemo(()=>r.map($=>$.id),[r]),[Y,H]=t.useState(void 0);t.useEffect(()=>{var $;H(s&&x&&(($=s.metadata)==null?void 0:$.outputType)||void 0)},[s==null?void 0:s.id,x]);const i=s==null?void 0:s.metadata,F=i&&(i.sourceUrl||i.author||i.domain);t.useEffect(()=>{if(s)if(z(s.title),b.current=s.id,x&&!l){const $=s.content||"";j($.trim()?Ge.isDSLContent($):null)}else j(null);else z(""),b.current=null,j(null);K()},[s==null?void 0:s.id,K,x,l]);const I=t.useCallback($=>{z($),s&&(S.current&&clearTimeout(S.current),S.current=setTimeout(()=>{p(s.id,{title:$})},500))},[s,p]),B=t.useCallback($=>{s&&(S.current&&clearTimeout(S.current),S.current=setTimeout(()=>{p(s.id,{content:$})},500),x&&!l&&(_.current&&clearTimeout(_.current),_.current=setTimeout(()=>{$.trim()?j(Ge.isDSLContent($)):j(null)},500)))},[s,p,x,l]),f=t.useCallback($=>{if(!s)return;H($);const J={...s.metadata,outputType:$};$||delete J.outputType,M.updateNote(s.id,{metadata:J})},[s]),R=t.useCallback($=>{s&&h(s.id,$)},[s,h]),q=t.useCallback(()=>{s&&(T?U?W():C():L(s.content))},[s,T,U,L,C,W]),oe=t.useCallback(async()=>{if(!s)return;const $=await M.exportNoteAsMarkdown(s.id);if(!$)return;const J=new Blob([$.content],{type:"text/markdown;charset=utf-8"}),ie=URL.createObjectURL(J),Q=document.createElement("a");Q.href=ie,Q.download=$.filename,document.body.appendChild(Q),Q.click(),document.body.removeChild(Q),URL.revokeObjectURL(ie)},[s]);return t.useEffect(()=>()=>{S.current&&clearTimeout(S.current),_.current&&clearTimeout(_.current)},[]),s?e.jsxs("div",{className:`kb-note-editor ${l?"kb-note-editor--readonly":""}`,children:[l&&e.jsxs("div",{className:"kb-note-editor__readonly-banner",children:[e.jsx(Te,{size:14}),e.jsx("span",{children:"系统内置 Skill,不可修改"})]}),e.jsxs("div",{className:"kb-note-editor__title-row",children:[e.jsx("input",{className:"kb-note-editor__title",value:w,onChange:$=>!l&&I($.target.value),placeholder:"笔记标题",readOnly:l}),e.jsxs("div",{className:"kb-note-editor__actions",children:[E&&e.jsx("button",{className:`kb-note-editor__action-btn ${T?"kb-note-editor__action-btn--active":""}`,onClick:q,title:T?U?"继续朗读":"暂停朗读":"语音朗读",children:T&&!U?e.jsx(Ts,{size:14}):e.jsx(Rs,{size:14})}),T&&e.jsx("button",{className:"kb-note-editor__action-btn kb-note-editor__action-btn--danger",onClick:K,title:"停止朗读",children:"■"}),e.jsx("button",{className:"kb-note-editor__action-btn",onClick:oe,title:"导出 Markdown",children:e.jsx($e,{size:14})})]})]}),F&&e.jsxs("div",{className:`kb-note-editor__metadata-section ${N?"kb-note-editor__metadata-section--collapsed":""}`,children:[e.jsxs("button",{className:"kb-note-editor__metadata-toggle",onClick:()=>g(!N),title:N?"展开来源信息":"收起来源信息",children:[N?e.jsx(ke,{size:14}):e.jsx(xe,{size:14}),e.jsx("span",{children:"来源信息"})]}),N&&e.jsxs("div",{className:"kb-note-editor__metadata-collapsed",children:[i.author&&e.jsxs("span",{className:"kb-note-editor__metadata-collapsed-item",children:[e.jsx(Ee,{size:10}),e.jsx("span",{children:i.author})]}),i.sourceUrl&&e.jsxs("a",{href:i.sourceUrl,target:"_blank",rel:"noopener noreferrer",className:"kb-note-editor__metadata-collapsed-link",onClick:$=>$.stopPropagation(),title:i.sourceUrl,children:[e.jsx(De,{size:10}),e.jsx("span",{children:i.domain||i.sourceUrl})]})]}),!N&&e.jsxs("div",{className:"kb-note-editor__metadata-body",children:[e.jsx("div",{className:"kb-note-editor__tags",children:e.jsx(st,{allTags:n,selectedTagIds:X,onSelectedChange:R,onCreateTag:d})}),e.jsxs("div",{className:"kb-note-editor__metadata-info",children:[i.domain&&e.jsxs("span",{className:"kb-note-editor__metadata-item",children:[i.faviconUrl?e.jsx("img",{src:i.faviconUrl,alt:"",className:"kb-note-editor__favicon",onError:$=>{$.currentTarget.style.display="none"}}):e.jsx(ct,{size:12}),e.jsx("span",{children:i.domain})]}),i.author&&e.jsxs("span",{className:"kb-note-editor__metadata-item",children:[e.jsx(Ee,{size:12}),e.jsx("span",{children:i.author})]}),i.publishedAt&&e.jsxs("span",{className:"kb-note-editor__metadata-item",children:[e.jsx(Ot,{size:12}),e.jsx("span",{children:i.publishedAt})]})]}),i.sourceUrl&&e.jsx("a",{href:i.sourceUrl,target:"_blank",rel:"noopener noreferrer",className:"kb-note-editor__source-link",children:i.sourceUrl}),i.description&&e.jsx("p",{className:"kb-note-editor__metadata-desc",children:i.description})]})]}),!F&&e.jsx("div",{className:"kb-note-editor__tags",children:e.jsx(st,{allTags:n,selectedTagIds:X,onSelectedChange:R,onCreateTag:d})}),x&&e.jsx("div",{className:"kb-note-editor__mcp-tools",children:e.jsx(Is,{outputType:Y,onOutputTypeChange:f,readOnly:l})}),e.jsx("div",{className:"kb-note-editor__content",children:e.jsx(Le,{ref:m,markdown:s.content,onChange:l?void 0:B,placeholder:"开始写点什么...",showModeSwitch:!l,readOnly:l})}),x&&!l&&v!==null&&e.jsx("div",{className:`kb-note-editor__dsl-status ${v?"kb-note-editor__dsl-status--valid":"kb-note-editor__dsl-status--fallback"}`,children:v?"✓ 已识别为工作流 DSL(正则解析),将直接执行":"⚡ 将由 AI 解析为工作流(大模型解析)"})]}):e.jsx("div",{className:"kb-note-editor kb-note-editor--empty",children:e.jsxs("div",{className:"kb-note-editor__placeholder",children:[e.jsx("div",{className:"kb-note-editor__placeholder-icon",children:e.jsx(as,{size:64,strokeWidth:1})}),e.jsx("h3",{className:"kb-note-editor__placeholder-title",children:"无笔记选中"}),e.jsx("p",{className:"kb-note-editor__placeholder-text",children:"选择左侧的一篇笔记开始编辑,或者创建一个新笔记"})]})})},Bs=({allTags:s,selectedTagIds:n,onSelectedChange:r})=>{const[l,x]=t.useState(""),[p,h]=t.useState(!1),d=t.useMemo(()=>{if(!l)return s;const g=l.toLowerCase();return s.filter(v=>v.name.toLowerCase().includes(g))},[s,l]),w=g=>{const v=n.includes(g)?n.filter(j=>j!==g):[...n,g];r(v)},z=()=>{r([]),h(!1)},N=e.jsxs("div",{className:"kb-filter-dropdown__content",children:[e.jsx("div",{className:"kb-filter-dropdown__search",children:e.jsx(be,{value:l,onChange:g=>x(g),placeholder:"搜索标签...",prefixIcon:e.jsx(lt,{size:14}),size:"small",clearable:!0})}),e.jsx("div",{className:"kb-filter-dropdown__list",children:d.length>0?d.map(g=>{const v=n.includes(g.id);return e.jsxs("div",{className:`kb-filter-dropdown__item ${v?"is-selected":""}`,onClick:()=>w(g.id),children:[e.jsx("span",{className:"kb-filter-dropdown__item-dot",style:{backgroundColor:g.color}}),e.jsx("span",{className:"kb-filter-dropdown__item-name",children:g.name}),e.jsxs("span",{className:"kb-filter-dropdown__item-count",children:["(",g.count||0,")"]}),v&&e.jsx(ae,{size:14,className:"kb-filter-dropdown__item-check"})]},g.id)}):e.jsx("div",{className:"kb-filter-dropdown__empty",children:"无匹配标签"})}),n.length>0&&e.jsx("div",{className:"kb-filter-dropdown__footer",children:e.jsxs(he,{theme:"default",variant:"text",size:"small",onClick:z,className:"kb-filter-dropdown__clear-btn",children:[e.jsx(de,{size:14,style:{marginRight:4}}),"清除标签过滤"]})})]});return e.jsx(Ht,{content:N,visible:p,onVisibleChange:g=>h(g),trigger:"click",placement:"bottom-left",overlayClassName:"kb-filter-dropdown__popup",children:e.jsxs(he,{variant:n.length>0?"base":"outline",theme:n.length>0?"primary":"default",size:"small",className:`kb-filter-trigger ${n.length>0?"is-active":""}`,children:[e.jsx(_s,{size:14,style:{marginRight:4}}),"标签",n.length>0&&` (${n.length})`]})})},Ks=({visible:s,onClose:n,allTags:r,onCreateTag:l,onUpdateTag:x,onDeleteTag:p,onSelectTag:h})=>{const[d,w]=t.useState(!1),[z,N]=t.useState(""),[g,v]=t.useState(null),[j,_]=t.useState(""),S=t.useRef(null);t.useEffect(()=>{d&&S.current&&setTimeout(()=>{var E;(E=S.current)==null||E.focus()},100)},[d]);const m=async()=>{if(!z.trim()){w(!1);return}try{await l(z.trim()),N(""),w(!1),A.success("标签创建成功")}catch{A.error("标签创建失败")}},b=async E=>{if(!j.trim()){v(null);return}try{await x(E,j.trim()),v(null),A.success("标签更新成功")}catch{A.error("标签更新失败")}},T=async(E,L)=>{E.stopPropagation();try{await p(L),A.success("标签删除成功")}catch{A.error("标签删除失败")}},U=(E,L)=>{E.stopPropagation(),v(L.id),_(L.name)};return e.jsx(Vt,{header:"管理标签",visible:s,onClose:n,footer:null,width:400,className:"kb-tag-management-dialog",children:e.jsxs("div",{className:"kb-tag-list",children:[d?e.jsx("div",{className:"kb-tag-item kb-tag-item--creating",children:e.jsx(be,{ref:S,value:z,onChange:E=>N(E),onEnter:m,onBlur:m,placeholder:"输入标签名称...",size:"small"})}):e.jsxs("div",{className:"kb-tag-item kb-tag-item--create-btn",onClick:()=>w(!0),children:[e.jsx(_e,{size:16}),e.jsx("span",{children:"新建标签"})]}),r.map(E=>e.jsx("div",{className:"kb-tag-item",onClick:()=>{h&&!g&&(h(E.id),n())},children:g===E.id?e.jsxs("div",{className:"kb-tag-item__editing",onClick:L=>L.stopPropagation(),children:[e.jsx(be,{value:j,onChange:L=>_(L),onEnter:()=>b(E.id),size:"small",autofocus:!0}),e.jsx(he,{shape:"circle",variant:"text",size:"small",onClick:()=>b(E.id),children:e.jsx(ae,{size:14})}),e.jsx(he,{shape:"circle",variant:"text",size:"small",onClick:()=>v(null),children:e.jsx(de,{size:14})})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"kb-tag-item__dot",style:{backgroundColor:E.color}}),e.jsx("span",{className:"kb-tag-item__name",children:E.name}),e.jsx("span",{className:"kb-tag-item__count",children:E.count?`(${E.count} 个笔记)`:"(0 个笔记)"}),e.jsxs("div",{className:"kb-tag-item__actions",children:[e.jsx("button",{className:"kb-tag-item__action-btn",onClick:L=>U(L,E),title:"重命名",children:e.jsx(Xt,{size:12})}),e.jsx("button",{className:"kb-tag-item__action-btn kb-tag-item__action-btn--delete",onClick:L=>T(L,E.id),title:"删除",children:e.jsx(ue,{size:12})})]})]})},E.id))]})})},nt=10,Os=({currentNoteId:s,allNotes:n,noteTagsMap:r,onSelectNote:l})=>{const[x,p]=t.useState([]),[h,d]=t.useState(!1),[w,z]=t.useState(!1);t.useEffect(()=>{let _=!1;return(async()=>{try{const m=await dt().getRelatedNotes(s,nt);_||p(m)}catch{_||p([])}})(),()=>{_=!0}},[s]);const N=t.useMemo(()=>n.find(_=>_.id===s),[n,s]),g=t.useMemo(()=>{var S;const _=(S=N==null?void 0:N.metadata)==null?void 0:S.sourceUrl;return _?n.filter(m=>{var b;return m.id!==s&&((b=m==null?void 0:m.metadata)==null?void 0:b.sourceUrl)===_}):[]},[n,s,N]),v=t.useMemo(()=>new Set(g.map(_=>_.id)),[g]),j=t.useMemo(()=>{if(x.length>0){const b=new Set;return x.filter(T=>v.has(T.id)||b.has(T.id)?!1:(b.add(T.id),!0))}const _=r[s]||[],S=new Set(_.map(b=>b.id));if(!N)return[];const m=[];for(const b of n){if(b.id===s||v.has(b.id))continue;const U=(r[b.id]||[]).map(X=>X.id),E=U.filter(X=>S.has(X)).length,L=new Set([...S,...U]).size,C=L>0?E/L:0,W=Hs(N.title,b.title),K=C*.7+W*.3;K>.05&&m.push({id:b.id,title:b.title||"无标题",score:K})}return m.sort((b,T)=>T.score-b.score).slice(0,nt)},[x,v,n,s,r,N]);return g.length===0&&j.length===0?null:e.jsxs("div",{className:"kb-related-notes",children:[g.length>0&&e.jsxs("div",{className:"kb-related-notes__section",children:[e.jsxs("button",{className:"kb-related-notes__section-header",onClick:()=>d(!h),children:[h?e.jsx(ke,{size:12}):e.jsx(xe,{size:12}),e.jsx(mt,{size:12}),e.jsx("span",{children:"相关笔记"}),e.jsx("span",{className:"kb-related-notes__count",children:g.length})]}),!h&&e.jsx("div",{className:"kb-related-notes__list",children:g.map(_=>e.jsxs("div",{className:"kb-related-notes__item",onClick:()=>l(_.id),children:[e.jsx(fe,{size:12,className:"kb-related-notes__icon"}),e.jsx("span",{className:"kb-related-notes__name",children:_.title||"无标题"}),e.jsx("button",{className:"kb-related-notes__goto-btn",onClick:S=>{S.stopPropagation(),l(_.id)},title:"跳转",children:e.jsx(De,{size:10})})]},`related-${_.id}`))})]}),j.length>0&&e.jsxs("div",{className:"kb-related-notes__section",children:[e.jsxs("button",{className:"kb-related-notes__section-header",onClick:()=>z(!w),children:[w?e.jsx(ke,{size:12}):e.jsx(xe,{size:12}),e.jsx(fe,{size:12}),e.jsx("span",{children:"相似笔记"}),e.jsx("span",{className:"kb-related-notes__count",children:j.length})]}),!w&&e.jsx("div",{className:"kb-related-notes__list",children:j.map(_=>{const S="score"in _?_.score:void 0;return e.jsxs("div",{className:"kb-related-notes__item",onClick:()=>l(_.id),children:[e.jsx(fe,{size:12,className:"kb-related-notes__icon"}),e.jsx("span",{className:"kb-related-notes__name",children:_.title}),S!==void 0&&e.jsxs("span",{className:"kb-related-notes__similarity",children:[Math.round(S*100),"%"]}),e.jsx("button",{className:"kb-related-notes__goto-btn",onClick:m=>{m.stopPropagation(),l(_.id)},title:"跳转",children:e.jsx(De,{size:10})})]},`similar-${_.id}`)})})]})]})};function Hs(s,n){if(!s||!n)return 0;const r=s.toLowerCase(),l=n.toLowerCase(),x=new Set;for(let w=0;w<r.length-1;w++)x.add(r.substring(w,w+2));const p=new Set;for(let w=0;w<l.length-1;w++)p.add(l.substring(w,w+2));let h=0;for(const w of x)p.has(w)&&h++;const d=x.size+p.size;return d===0?0:2*h/d}const Vs=`你是一个专业的知识提取助手,擅长从文本中识别和提取关键知识点。你的任务是分析给定的文本内容,提取出有价值的知识点,并以结构化的 Markdown 格式返回。
|
|
105
|
-
|
|
106
|
-
提取规则:
|
|
107
|
-
1. **核心概念**: 文中出现的重要概念、术语及其解释
|
|
108
|
-
2. **重要定义**: 明确的定义性内容,如"XX是指..."、"XX定义为..."
|
|
109
|
-
3. **关键步骤**: 操作流程、方法步骤、实施要点
|
|
110
|
-
4. **要点总结**: 核心观点、结论、重要发现
|
|
111
|
-
|
|
112
|
-
提取要求:
|
|
113
|
-
- 每个知识点必须有清晰的标题和详细的内容描述
|
|
114
|
-
- 确保提取的知识点具有独立性和完整性
|
|
115
|
-
- 避免重复提取相同的知识点
|
|
116
|
-
- 知识点数量控制在 3-10 个之间
|
|
117
|
-
- 内容要精炼、易于理解
|
|
118
|
-
|
|
119
|
-
输出格式要求:
|
|
120
|
-
- 必须返回 Markdown 格式
|
|
121
|
-
- 每个知识点使用二级标题(##)
|
|
122
|
-
- 内容使用正常段落或列表`;function Xs(s,n){return`请分析以下文本内容,提取关键知识点并以 Markdown 格式返回:
|
|
123
|
-
${n?`
|
|
124
|
-
文章标题:${n}`:""}
|
|
125
|
-
---
|
|
126
|
-
${s}
|
|
127
|
-
---
|
|
128
|
-
|
|
129
|
-
请按以下 Markdown 格式返回提取结果:
|
|
130
|
-
|
|
131
|
-
## 知识点标题1
|
|
132
|
-
|
|
133
|
-
知识点的详细内容描述,完整解释该知识点。可以使用列表、加粗等 Markdown 语法。
|
|
134
|
-
|
|
135
|
-
## 知识点标题2
|
|
136
|
-
|
|
137
|
-
另一个知识点的内容...
|
|
138
|
-
|
|
139
|
-
注意:
|
|
140
|
-
1. 每个知识点使用二级标题(##)
|
|
141
|
-
2. 标题要简洁明了,概括知识点核心
|
|
142
|
-
3. 内容要详细完整,可使用列表、加粗等格式
|
|
143
|
-
4. 不要添加"知识点1"、"知识点2"这样的序号前缀
|
|
144
|
-
5. 直接返回 Markdown 内容,不要使用代码块包裹`}function qs(s){try{let n=s.trim();n.startsWith("```markdown")?n=n.slice(11):n.startsWith("```md")?n=n.slice(5):n.startsWith("```")&&(n=n.slice(3)),n.endsWith("```")&&(n=n.slice(0,-3)),n=n.trim();const r=n.split(/^##\s+/gm).filter(x=>x.trim());if(r.length===0)return null;const l=r.map(x=>{const p=x.split(`
|
|
145
|
-
`);return{title:p[0].trim(),content:p.slice(1).join(`
|
|
146
|
-
`).trim(),sourceContext:"",type:"summary",tags:[]}}).filter(x=>x.title&&x.content);return l.length>0?{knowledgePoints:l}:null}catch{return null}}function Ys(){return`kp_${Date.now()}_${Math.random().toString(36).slice(2,9)}`}async function Gs(s,n){var h,d,w;const{model:r,onProgress:l,signal:x}=n;return((w=(d=(h=(await ut(s,z=>l==null?void 0:l(z),x,r)).choices)==null?void 0:h[0])==null?void 0:d.message)==null?void 0:w.content)||""}async function Qs(s,n){var v,j,_;const{title:r,sourceUrl:l,model:x,onProgress:p,signal:h}=n,d=[{role:"system",content:[{type:"text",text:Vs}]},{role:"user",content:[{type:"text",text:Xs(s,r)}]}],z=((_=(j=(v=(await ut(d,S=>p==null?void 0:p(S),h,x)).choices)==null?void 0:v[0])==null?void 0:j.message)==null?void 0:_.content)||"",N=qs(z);if(!N||N.knowledgePoints.length===0)throw new Error("无法从内容中提取知识点,请确保内容包含有价值的信息");return{knowledgePoints:N.knowledgePoints.map(S=>({id:Ys(),title:S.title,content:S.content,sourceContext:S.sourceContext,tags:S.tags,type:S.type,selected:!0})),rawResponse:z,sourceUrl:l,sourceTitle:r,extractedAt:Date.now()}}const Zs="kb-chat-storage",Js="sessions",pt=qt.createInstance({name:Zs,storeName:Js});async function en(s){return pt.getItem(s)}async function tn(s,n){const r={noteId:s,messages:n,updatedAt:Date.now()};await pt.setItem(s,r)}const ft={concept:"核心概念",definition:"重要定义",step:"关键步骤",summary:"要点总结"};function sn(s,n){const r=[];r.push(`# ${n.title||"知识提炼"}`),r.push(""),n.sourceUrl&&(r.push(`> 来源: ${n.sourceUrl}`),r.push("")),r.push(`> 导出时间: ${new Date().toLocaleString("zh-CN")}`),r.push(""),r.push("---"),r.push("");const l=["concept","definition","step","summary"];for(const x of l){const p=s.filter(h=>h.type===x);if(p.length!==0){r.push(`## ${ft[x]}`),r.push("");for(const h of p)r.push(`### ${h.title}`),r.push(""),r.push(h.content),h.sourceContext&&(r.push(""),r.push(`> ${h.sourceContext}`)),h.tags.length>0&&(r.push(""),r.push(`**标签**: ${h.tags.map(d=>`\`${d}\``).join(" ")}`)),r.push("")}}return r.join(`
|
|
147
|
-
`)}function nn(s,n){const r=s.knowledgePoints.filter(h=>h.selected!==!1);if(r.length===0)throw new Error("没有选中的知识点");const l={title:s.sourceTitle||"知识提炼",sourceUrl:s.sourceUrl},x=new Date().toISOString().slice(0,10),p=s.sourceTitle?`${s.sourceTitle.slice(0,30).replace(/[/\\?%*:|"<>]/g,"-")}_知识提炼_${x}`:`知识提炼_${x}`;return{content:sn(r,l),filename:`${p}.md`,mimeType:"text/markdown"}}function an(s,n,r){const l=new Blob([s],{type:r}),x=URL.createObjectURL(l),p=document.createElement("a");p.href=x,p.download=n,document.body.appendChild(p),p.click(),document.body.removeChild(p),URL.revokeObjectURL(x)}const at="gemini-2.5-flash";function xt(s){const n=[],r=["concept","definition","step","summary"];for(const l of r){const x=s.knowledgePoints.filter(p=>p.type===l);if(x.length!==0){n.push(`## ${ft[l]}`),n.push("");for(const p of x)n.push(`### ${p.title}`),n.push(""),n.push(p.content),p.sourceContext&&(n.push(""),n.push(`> ${p.sourceContext}`)),p.tags&&p.tags.length>0&&(n.push(""),n.push(`**标签**: ${p.tags.map(h=>`\`${h}\``).join(" ")}`)),n.push("")}}return n.join(`
|
|
148
|
-
`).trim()}const on=({noteId:s,noteContent:n,noteTitle:r,onInsertToNote:l,onSaved:x})=>{const[p,h]=t.useState([]),[d,w]=t.useState(""),[z,N]=t.useState(at),[g,v]=t.useState(()=>Qe(null,at)),[j,_]=t.useState(!1),[S,m]=t.useState(null),[b,T]=t.useState(null),U=t.useRef(null),E=t.useRef(null);t.useEffect(()=>{let i=!0;return(async()=>{h([]);try{const I=await en(s);i&&(I&&I.messages.length>0?h(I.messages):h([{id:"init",role:"model",content:"我已经阅读了这篇笔记。你可以让我提取摘要、关键点,或者直接与我讨论笔记内容。",type:"text",timestamp:Date.now()}]))}catch(I){console.error("Failed to load chat history",I)}})(),()=>{i=!1}},[s]),t.useEffect(()=>{p.length>0&&tn(s,p).catch(console.error)},[p,s]),t.useEffect(()=>{U.current&&(U.current.scrollTop=U.current.scrollHeight)},[p]),t.useEffect(()=>{E.current&&(E.current.style.height="auto",E.current.style.height=`${Math.min(E.current.scrollHeight,120)}px`)},[d]);const L=t.useCallback(()=>{S&&(S.abort(),m(null),_(!1),h(i=>[...i,{id:Date.now().toString(),role:"model",content:"🚫 已停止生成",type:"text",timestamp:Date.now()}]))},[S]),C=t.useCallback(async()=>{if(!d.trim()||j)return;const i={id:Date.now().toString(),role:"user",content:d,type:"text",timestamp:Date.now()};h(I=>[...I,i]),w(""),_(!0),E.current&&(E.current.style.height="auto");const F=new AbortController;m(F);try{const I=p.concat(i).map(f=>({role:f.role==="model"?"assistant":"user",content:[{type:"text",text:f.content}]}));if(I.length<=2){const f=`Context:
|
|
149
|
-
${n}
|
|
150
|
-
|
|
151
|
-
Task: ${i.content}`,R=I.length-1;I[R].content=[{type:"text",text:f}]}const B=(Date.now()+1).toString();T(B),h(f=>[...f,{id:B,role:"model",content:"正在思考...",type:"text",timestamp:Date.now()}]),await Gs(I,{model:g||z,onProgress:f=>{h(R=>R.map(q=>q.id===B?{...q,content:f}:q))},signal:F.signal})}catch(I){I.name!=="AbortError"&&h(B=>[...B,{id:Date.now().toString(),role:"model",content:`Error: ${I.message||"Something went wrong"}`,type:"text",timestamp:Date.now()}])}finally{_(!1),m(null),T(null)}},[d,j,p,n,z,g]),W=t.useCallback(async()=>{if(j)return;_(!0);const i={id:Date.now().toString(),role:"user",content:"提取知识点",type:"text",timestamp:Date.now()};h(B=>[...B,i]);const F=new AbortController;m(F);const I=(Date.now()+1).toString();h(B=>[...B,{id:I,role:"model",content:"正在分析笔记内容并提取知识点...",type:"text",timestamp:Date.now()}]);try{const B=await Qs(n,{title:r,model:g||z,signal:F.signal});h(f=>f.map(R=>R.id===I?{...R,content:"知识点提取完成:",type:"extraction-result",data:B}:R))}catch(B){B.name!=="AbortError"&&h(f=>f.map(R=>R.id===I?{...R,content:`提取失败: ${B.message}`}:R))}finally{_(!1),m(null)}},[j,n,r,z,g]),K=i=>{i.key==="Enter"&&!i.shiftKey&&(i.preventDefault(),C())},X=t.useCallback(i=>{if(!i){A.warning("没有可复制的内容");return}navigator.clipboard.writeText(i).then(()=>{A.success("复制成功")}).catch(()=>{A.error("复制失败")})},[]),Y=t.useCallback(i=>i.type==="text"?i.content:i.type==="extraction-result"&&i.data?xt(i.data):"",[]),H=t.useCallback(i=>{if(i.type==="extraction-result"&&i.data)try{const F=nn(i.data,{format:"markdown",includeSource:!0,includeTags:!0});an(F.content,F.filename,F.mimeType)}catch(F){console.error("Failed to export",F),A.error("导出失败")}},[]);return e.jsxs("div",{className:"kb-extraction-chat",children:[e.jsx("div",{className:"kb-extraction-chat__header",children:e.jsxs("div",{className:"kb-extraction-chat__title",children:[e.jsx(Re,{size:18}),e.jsx("span",{children:"知识提取 & 对话"})]})}),e.jsx("div",{className:"kb-extraction-chat__messages",ref:U,children:p.map(i=>e.jsxs("div",{className:`kb-message kb-message--${i.role}`,children:[e.jsx("div",{className:"kb-message__avatar",children:i.role==="user"?e.jsx(Ee,{}):e.jsx(is,{})}),e.jsxs("div",{className:"kb-message__body",children:[e.jsx("div",{className:"kb-message__content",children:i.role==="model"?e.jsx("div",{className:"kb-message__content-scroll",children:i.type==="text"?i.id===b&&(i.content==="正在思考..."||i.content==="正在分析笔记内容并提取知识点...")?e.jsxs("div",{className:"kb-message__thinking","aria-label":"思考中",children:[e.jsx("span",{className:"kb-message__thinking-text",children:i.content.replace(/\.+$/,"")}),e.jsxs("span",{className:"kb-message__thinking-dots",children:[e.jsx("span",{children:"."}),e.jsx("span",{children:"."}),e.jsx("span",{children:"."})]})]}):i.content?e.jsx("div",{className:"kb-message__markdown-wrap",children:e.jsx(Le,{markdown:i.content,readOnly:!0,showModeSwitch:!1,initialMode:"wysiwyg",className:"kb-extraction-markdown"})}):null:e.jsx(ot,{result:i.data})}):i.type==="text"?e.jsx("div",{className:"kb-message__text",children:i.content}):e.jsx(ot,{result:i.data})}),i.role==="model"&&e.jsxs("div",{className:"kb-message__actions",children:[e.jsx("button",{className:"kb-message__action-btn",onClick:()=>X(Y(i)),title:"复制",children:e.jsx(Me,{size:14})}),e.jsx("button",{className:"kb-message__action-btn",onClick:()=>{const F=Y(i);F&&(l==null||l(F))},title:"插入到笔记",children:e.jsx(js,{size:14})}),i.type==="extraction-result"&&e.jsx("button",{className:"kb-message__action-btn",onClick:()=>H(i),title:"导出 Markdown",children:e.jsx($e,{size:14})})]})]})]},i.id))}),e.jsxs("div",{className:"kb-extraction-chat__input-area",children:[e.jsx("div",{className:"kb-extraction-chat__input-wrapper",children:e.jsx("textarea",{ref:E,className:"kb-extraction-chat__textarea",value:d,onChange:i=>w(i.target.value),onKeyDown:K,placeholder:"输入问题,与 AI 讨论笔记内容...",disabled:j,rows:1})}),e.jsxs("div",{className:"kb-extraction-chat__input-actions",children:[e.jsx("div",{className:"kb-extraction-chat__model-selector",children:e.jsx(Yt,{value:z,valueRef:g,onChange:(i,F)=>{N(i),v(F||Qe(null,i))},variant:"capsule"})}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("button",{className:"kb-extraction-chat__icon-btn",onClick:W,title:"一键提取知识点",disabled:j,children:e.jsx(Re,{size:16})}),e.jsx("button",{className:`kb-extraction-chat__send-btn ${d.trim()||j?"kb-extraction-chat__send-btn--active":""}`,onClick:j?L:C,disabled:!d.trim()&&!j,title:j?"停止生成":"发送",children:j?e.jsx(cs,{size:18}):e.jsx(Gt,{size:18})})]})]})]})]})},ot=({result:s})=>{const n=Qt.useMemo(()=>xt(s),[s]);return e.jsx("div",{className:"kb-extraction-result-view",children:e.jsx(Le,{markdown:n,readOnly:!0,showModeSwitch:!1,initialMode:"wysiwyg",className:"kb-extraction-markdown"})})},it=[{label:"更新时间",value:"updatedAt"},{label:"创建时间",value:"createdAt"},{label:"标题",value:"title"}],rn=({value:s,onChange:n})=>{var p;const r=((p=it.find(h=>h.value===s.field))==null?void 0:p.label)||"排序",l=h=>{const d=h.value;["asc","desc"].includes(d)?n({...s,order:d}):d===s.field?n({...s,order:s.order==="asc"?"desc":"asc"}):n({...s,field:d,order:d==="title"?"asc":"desc"})},x=[{content:"排序字段",disabled:!0,className:"kb-sort-dropdown__header"},...it.map(h=>({content:h.label,value:h.value,prefixIcon:s.field===h.value?e.jsx(ae,{size:14}):e.jsx("div",{style:{width:14}})})),{divider:!0},{content:"排序方式",disabled:!0,className:"kb-sort-dropdown__header"},{content:"升序",value:"asc",prefixIcon:s.order==="asc"?e.jsx(ae,{size:14}):e.jsx("div",{style:{width:14}}),suffixIcon:e.jsx(et,{size:14})},{content:"降序",value:"desc",prefixIcon:s.order==="desc"?e.jsx(ae,{size:14}):e.jsx("div",{style:{width:14}}),suffixIcon:e.jsx(Je,{size:14})}];return e.jsx(ht,{options:x,onClick:l,trigger:"click",minColumnWidth:120,children:e.jsxs(he,{variant:"outline",size:"small",className:"kb-sort-trigger",children:[s.order==="asc"?e.jsx(et,{size:14,style:{marginRight:4}}):e.jsx(Je,{size:14,style:{marginRight:4}}),r]})})},dn=({initialNoteId:s})=>{var Ve;const[n,r]=t.useState([]),[l,x]=t.useState([]),[p,h]=t.useState([]),[d,w]=t.useState(null),[z,N]=t.useState([]),[g,v]=t.useState({}),[j,_]=t.useState(null),[S,m]=t.useState(new Set),[b,T]=t.useState(null),[U,E]=t.useState(""),[L,C]=t.useState(M.loadSortPreference?M.loadSortPreference():{field:"updatedAt",order:"desc"}),[W,K]=t.useState([]),[X,Y]=t.useState(!1),[H,i]=t.useState(!1),[F,I]=t.useState(!1),[B,f]=t.useState(null),R=t.useRef(null),q=t.useRef(null),[oe,$]=t.useState(!1),[J,ie]=t.useState("related"),[Q,Pe]=t.useState(280),[ge,Ae]=t.useState(300),re=t.useRef(!1),ce=t.useRef(!1),we=t.useRef(null);t.useEffect(()=>{const a=localStorage.getItem("kb-sidebar-width");if(a){const o=parseInt(a,10);!isNaN(o)&&o>100&&o<800&&Pe(o)}const c=localStorage.getItem("kb-right-sidebar-width");if(c){const o=parseInt(c,10);!isNaN(o)&&o>100&&o<800&&Ae(o)}},[]),t.useEffect(()=>{const a=o=>{if(!we.current)return;const u=we.current.getBoundingClientRect();if(re.current){o.preventDefault();const k=Math.max(200,Math.min(600,o.clientX-u.left));Pe(k)}else if(ce.current){o.preventDefault();const k=Math.max(200,Math.min(600,u.right-o.clientX));Ae(k)}},c=()=>{re.current&&(re.current=!1,localStorage.setItem("kb-sidebar-width",Q.toString()),document.body.style.cursor=""),ce.current&&(ce.current=!1,localStorage.setItem("kb-right-sidebar-width",ge.toString()),document.body.style.cursor="")};return re.current||ce.current?(document.addEventListener("mousemove",a),document.addEventListener("mouseup",c)):document.addEventListener("mousemove",a),document.addEventListener("mousemove",a),document.addEventListener("mouseup",c),()=>{document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",c)}},[Q,ge]);const kt=a=>{a.preventDefault(),re.current=!0,document.body.style.cursor="col-resize"},_t=a=>{a.preventDefault(),ce.current=!0,document.body.style.cursor="col-resize"},[Ie,bt]=t.useState(null),Ue=t.useRef(!1),We=t.useRef(!1);t.useEffect(()=>{if(Ue.current)return;Ue.current=!0,(async()=>{await M.initialize(),await O();try{const o=await M.getStorageUsage();bt(o)}catch{}if(s){Z(s);return}const c=window.__kbPendingNavigation;if(c){window.__kbPendingNavigation=null;const{directoryName:o,autoCreateNote:u}=c;if(o){const y=(await M.getAllDirectories()).find(D=>D.name===o);if(y&&(_(y.id),m(D=>{const P=new Set(D);return P.add(y.id),P}),u)){const D=o==="Skill"?"新Skill":"新笔记",P=await M.createNote(D,y.id);await O(),m(Ne=>{const le=new Set(Ne);return le.add(y.id),le}),T(P.id);const G=await M.getNoteById(P.id);w(G),N([])}}}})()},[]);const O=t.useCallback(async()=>{const[a,c,o]=await Promise.all([M.getAllDirectories(),M.getAllNoteMetas(),M.getAllTags()]),u=Array.from(new Map(a.map(D=>[D.id,D])).values());r(u);const k=Array.from(new Map(c.map(D=>[D.id,D])).values());x(k);const y=Array.from(new Map(o.map(D=>[D.id,D])).values());h(y),!j&&!b&&u.length>0&&(_(u[0].id),m(new Set([u[0].id]))),await gt(k)},[j,b]),gt=t.useCallback(async a=>{try{const[c,o]=await Promise.all([M.getAllTags(),M.getAllNoteTags()]),u=new Map(c.map(y=>[y.id,y])),k={};for(const y of a)k[y.id]=[];for(const y of o)if(k[y.noteId]&&u.has(y.tagId)){const D=u.get(y.tagId);D&&(k[y.noteId].some(P=>P.id===D.id)||k[y.noteId].push(D))}for(const y in k)k[y].sort((D,P)=>D.name.localeCompare(P.name));v(k)}catch(c){console.error("Failed to refresh note tags map:",c)}},[]);t.useEffect(()=>{if(!U.trim()){f(null);return}return R.current&&clearTimeout(R.current),R.current=setTimeout(async()=>{try{const c=await dt().search(U,{limit:50,filter:j?{directoryId:j}:{}});f(c)}catch{f(null)}},300),()=>{R.current&&clearTimeout(R.current)}},[U,j]);const ee=t.useMemo(()=>{if(B&&U.trim()){const c=new Set(B.map(k=>k.id)),o=new Map(B.map((k,y)=>[k.id,y]));let u=l.filter(k=>c.has(k.id));if(W.length>0){const k=new Set(W);u=u.filter(y=>(g[y.id]||[]).some(P=>k.has(P.id)))}return u.sort((k,y)=>(o.get(k.id)??0)-(o.get(y.id)??0))}let a=l;if(W.length>0){const c=new Set(W);a=a.filter(o=>(g[o.id]||[]).some(k=>c.has(k.id)))}return M.sortNoteMetas(a,L)},[l,j,U,W,L,g,B]),wt=t.useMemo(()=>{const a={},c=new Set;for(const o of ee)c.has(o.id)||(c.add(o.id),a[o.directoryId]=(a[o.directoryId]||0)+1);return a},[ee]),jt=t.useMemo(()=>{var c;const a={};for(const o of ee){const u=a[c=o.directoryId]??(a[c]=[]);u.some(k=>k.id===o.id)||u.push(o)}return a},[ee]),je=t.useCallback(async a=>{await M.createDirectory(a),await O()},[O]),yt=t.useCallback(async(a,c)=>{await M.updateDirectory(a,{name:c}),await O()},[O]),vt=t.useCallback(async a=>{const c=n.find(u=>u.id===a);if(!c)return;const o=Ze.confirm({header:"确认删除目录",body:`确定要删除目录 "${c.name}" 及其下的所有笔记吗?此操作不可撤销。`,onConfirm:async()=>{var u;try{await M.deleteDirectory(a),j===a&&(_(((u=n[0])==null?void 0:u.id)||null),T(null),w(null)),await O(),A.success("目录已删除")}catch(k){A.error(`删除失败: ${k.message}`)}o.destroy()},onClose:()=>{o.destroy()}})},[O,j,n]),Nt=t.useCallback(async a=>{try{await M.duplicateDirectory(a),await O(),A.success("目录复制成功")}catch(c){A.error(`复制目录失败: ${c.message}`)}},[O]),Ct=t.useCallback(a=>{m(c=>{const o=new Set(c);return o.has(a)?o.delete(a):o.add(a),o})},[]),Z=t.useCallback(async a=>{if(T(a),_(null),N(g[a]||[]),a.startsWith(ne)){const o=a.slice(ne.length),u=ze.find(k=>k.id===o);if(u){const k=["image","inspiration","grid_image"],y=["ppt"],D=u.mcpTool&&k.some(G=>u.mcpTool.includes(G))?"image":u.mcpTool&&y.some(G=>u.mcpTool.includes(G))?"ppt":void 0,P={id:a,title:u.name,content:u.description||"",directoryId:"",createdAt:0,updatedAt:0,metadata:{...D?{outputType:D}:{}}};w(P),N([])}return}if(a.startsWith(se)){const o=a.slice(se.length),u=Zt(o);if(u){const k={id:a,title:u.name,content:u.content||u.description||"",directoryId:"",createdAt:0,updatedAt:0,metadata:{...u.outputType?{outputType:u.outputType}:{},...u.category?{category:u.category}:{}}};w(k),N([])}return}const c=await M.getNoteById(a);if(w(c),c){const o=await M.getTagsForNote(c.id);N(o),m(u=>{const k=new Set(u);return k.add(c.directoryId),k})}},[n,g]),ye=t.useCallback(async a=>{const c=new Set(l.filter(P=>P.directoryId===a).map(P=>P.title)),o=n.find(P=>P.id===a),u=(o==null?void 0:o.name)==="Skill"?"新Skill":"新笔记";let k=u,y=1;for(;c.has(k);)k=`${u} ${y}`,y++;const D=await M.createNote(k,a);await O(),m(P=>{const G=new Set(P);return G.add(a),G}),Z(D.id)},[O,Z,l,n]),ve=t.useCallback(async(a,c)=>{await M.updateNote(a,c),x(o=>o.map(u=>u.id===a?{...u,...c,updatedAt:Date.now()}:u)),(d==null?void 0:d.id)===a&&w(o=>o&&{...o,...c,updatedAt:Date.now()});try{const o=window.__drawnixBoard;if(o&&o.children){const{Transforms:u}=await Se(async()=>{const{Transforms:k}=await import("./index-7WzIC7_D.js").then(y=>y.hL);return{Transforms:k}},__vite__mapDeps([0,1]),import.meta.url);o.children.forEach((k,y)=>{if(k.noteId===a){const D={};c.title!==void 0&&(D.title=c.title),c.content!==void 0&&(D.body=c.content),Object.keys(D).length>0&&u.setNode(o,D,[y])}})}}catch(o){console.warn("[KB] Failed to sync note update to canvas card:",o)}},[d]),St=t.useCallback(async a=>{if(!d)return;const c=d.content?`
|
|
152
|
-
|
|
153
|
-
`:"",o=(d.content||"")+c+a;await ve(d.id,{content:o}),A.success("已插入到笔记末尾")},[d,ve]),Mt=t.useCallback(async a=>{var o,u;const c=window.__drawnixBoard;if(!c){A.warning("请先打开画布");return}try{if(c.children.find(te=>te.noteId===a.id)&&!window.confirm("画布中已存在关联该笔记的卡片,是否再次插入?"))return;const y=await M.getNoteById(a.id);if(!y){A.error("获取笔记内容失败");return}const{getViewportOrigination:D}=await Se(async()=>{const{getViewportOrigination:te}=await import("./index-7WzIC7_D.js").then(Ce=>Ce.hL);return{getViewportOrigination:te}},__vite__mapDeps([0,1]),import.meta.url),P=D(c),G=((o=c.host)==null?void 0:o.clientWidth)||800,Ne=((u=c.host)==null?void 0:u.clientHeight)||600,le=Math.round(window.innerWidth*.5),Xe=180,qe=((P==null?void 0:P[0])??0)+G/2-le/2,Ye=((P==null?void 0:P[1])??0)+Ne/2-Xe/2,{Transforms:Ut}=await Se(async()=>{const{Transforms:te}=await import("./index-7WzIC7_D.js").then(Ce=>Ce.hL);return{Transforms:te}},__vite__mapDeps([0,1]),import.meta.url),Wt={type:"card",id:`card-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,title:y.title||"无标题",body:y.content||"",noteId:y.id,fillColor:"#FA8C16",points:[[qe,Ye],[qe+le,Ye+Xe]]};Ut.insertNode(c,Wt,[c.children.length]),A.success("已插入到画布")}catch(k){console.error("[KB] Failed to insert note to canvas:",k),A.error(`插入失败: ${k.message}`)}},[]),zt=t.useCallback(async a=>{try{await M.duplicateNote(a),await O(),A.success("笔记复制成功")}catch(c){A.error(`复制笔记失败: ${c.message}`)}},[O]),Et=t.useCallback(async a=>{if(a.startsWith(ne)){A.warning("系统内置 Skill,不可删除");return}if(a.startsWith(se)){A.warning("外部 Skill,不可在此删除(请在设置中管理外部 Skill 包)");return}const c=l.find(u=>u.id===a);if(!c)return;const o=Ze.confirm({header:"确认删除笔记",body:`确定要删除笔记 "${c.title||"无标题"}" 吗?此操作不可撤销。`,onConfirm:async()=>{try{await M.deleteNote(a),b===a&&(T(null),w(null),N([])),await O(),A.success("笔记已删除")}catch(u){A.error(`删除失败: ${u.message}`)}o.destroy()},onClose:()=>{o.destroy()}})},[b,O,l]);t.useEffect(()=>{!We.current&&ee.length>0&&(Z(ee[0].id),We.current=!0)},[ee,Z]),t.useEffect(()=>{const a=c=>{const{noteId:o}=c.detail;o&&Z(o)};return window.addEventListener("kb:open-note",a),()=>window.removeEventListener("kb:open-note",a)},[Z]),t.useEffect(()=>{const a=async c=>{const{directoryName:o,autoCreateNote:u}=c.detail;if(!o)return;window.__kbPendingNavigation&&(window.__kbPendingNavigation=null);const y=(await M.getAllDirectories()).find(D=>D.name===o);y&&(_(y.id),m(D=>{const P=new Set(D);return P.add(y.id),P}),u&&await ye(y.id))};return window.addEventListener("kb:navigate",a),()=>window.removeEventListener("kb:navigate",a)},[ye]);const Rt=t.useCallback(async(a,c)=>{await M.setNoteTags(a,c);const o=await M.getTagsForNote(a);N(o),v(k=>({...k,[a]:o}));const u=await M.getAllTags();h(u)},[]),Fe=t.useCallback(async a=>{const c=await M.createTag(a),o=await M.getAllTags();return h(o),c},[]),Dt=t.useCallback(async(a,c)=>{await M.updateTag(a,{name:c});const o=await M.getAllTags();h(o)},[]),Tt=t.useCallback(async a=>{await M.deleteTag(a);const c=await M.getAllTags();if(h(c),d){const o=await M.getTagsForNote(d.id);N(o),v(u=>({...u,[d.id]:o}))}},[d]),$t=t.useCallback(a=>{C(a),M.saveSortPreference&&M.saveSortPreference(a)},[]);t.useEffect(()=>{if(!H)return;const a=c=>{q.current&&!q.current.contains(c.target)&&i(!1)};return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},[H]);const me=t.useRef(null),Be=t.useCallback(()=>{var a;(a=me.current)==null||a.click()},[]),Lt=t.useCallback(async a=>{const c=a.target.files;if(!(!c||!j)){for(const o of Array.from(c)){if(!o.name.endsWith(".md")&&!o.name.endsWith(".markdown"))continue;const u=await o.text();await M.importNoteFromMarkdown(u,j,o.name)}await O(),me.current&&(me.current.value="")}},[j,O]),Ke=t.useCallback(async()=>{try{const a=await M.exportAsZip(),c=URL.createObjectURL(a),o=document.createElement("a");o.href=c,o.download=`knowledge-base-${new Date().toISOString().slice(0,10)}.zip`,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(c)}catch(a){console.error("Export failed:",a),A.error("导出失败")}},[]),pe=t.useRef(null),Oe=t.useCallback(()=>{var a;(a=pe.current)==null||a.click()},[]),Pt=t.useCallback(async a=>{var o;const c=(o=a.target.files)==null?void 0:o[0];if(c){try{if(c.name.toLowerCase().endsWith(".zip")){const u=await M.importFromZip(c);u.noteCount===0&&u.dirCount===0?A.warning("导入完成:没有新增内容(可能已存在重复内容)"):A.success(`导入完成:${u.dirCount} 个新目录、${u.noteCount} 篇笔记`)}else{const u=await c.text(),k=JSON.parse(u);if(k.version!==1&&k.version!==2){A.error("不支持的导入格式");return}const y=await M.importAllData(k);A.success(`导入完成:${y.dirCount} 个目录、${y.noteCount} 篇笔记、${y.tagCount} 个标签`)}await O()}catch(u){console.error(u),A.error("导入失败,请确认文件格式正确")}pe.current&&(pe.current.value="")}},[O]),He=t.useCallback(()=>{const a=window.prompt("请输入目录名称","新建目录");a&&je(a)},[je]),At=t.useCallback(a=>{switch(a.value){case"create-dir":He();break;case"manage-tags":Y(!0);break;case"import-md":Be();break;case"import-zip":Oe();break;case"export-zip":Ke();break}},[He,Be,Oe,Ke]),It=t.useMemo(()=>[{content:"新建目录",value:"create-dir",prefixIcon:e.jsx(ps,{size:14})},{content:"管理标签",value:"manage-tags",prefixIcon:e.jsx(Ms,{size:14})},{content:"导入 Markdown",value:"import-md",prefixIcon:e.jsx(tt,{size:14})},{content:"导入 ZIP",value:"import-zip",prefixIcon:e.jsx(tt,{size:14})},{content:"导出 ZIP",value:"export-zip",prefixIcon:e.jsx($e,{size:14})}],[]);return e.jsxs("div",{className:"kb-drawer",children:[e.jsx("input",{ref:me,type:"file",accept:".md,.markdown",multiple:!0,style:{display:"none"},onChange:Lt}),e.jsx("input",{ref:pe,type:"file",accept:".json,.zip",style:{display:"none"},onChange:Pt}),e.jsxs("div",{className:"kb-drawer__body",ref:we,children:[e.jsxs("div",{className:"kb-drawer__sidebar",style:{width:Q},children:[e.jsxs("div",{className:"kb-drawer__toolbar",children:[e.jsxs("div",{className:"kb-drawer__search",style:{display:"flex",gap:"8px",alignItems:"center",marginBottom:"8px"},children:[e.jsx(be,{size:"small",prefixIcon:e.jsx(lt,{size:14}),placeholder:"搜索笔记...",value:U,onChange:a=>E(a),clearable:!0,style:{flex:1}}),e.jsx(ht,{trigger:"click",options:It,onClick:At,minColumnWidth:120,maxColumnWidth:200,popupProps:{overlayStyle:{width:200}},children:e.jsx("button",{style:{background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:"4px",color:"var(--td-text-color-secondary)",borderRadius:"4px"},onMouseEnter:a=>a.currentTarget.style.backgroundColor="var(--td-bg-color-container-hover)",onMouseLeave:a=>a.currentTarget.style.backgroundColor="transparent",title:"更多操作",children:e.jsx(Jt,{size:18})})})]}),e.jsxs("div",{className:"kb-drawer__filters",style:{display:"flex",gap:"8px",alignItems:"center"},children:[e.jsx(Bs,{allTags:p,selectedTagIds:W,onSelectedChange:K}),e.jsx("div",{style:{flex:1}}),e.jsx(rn,{value:L,onChange:$t})]})]}),e.jsx(Ls,{directories:n,notesByDir:jt,noteTagsMap:g,noteCounts:wt,selectedDirId:j,selectedNoteId:b,expandedDirIds:S,onSelectDir:a=>{_(a),T(null),w(null)},onToggleExpand:Ct,onCreateDir:je,onRenameDir:yt,onDeleteDir:vt,onDuplicateDir:Nt,onSelectNote:Z,onCreateNote:ye,onDeleteNote:Et,onDuplicateNote:zt,isCreatingDir:F,onCancelCreateDir:()=>I(!1),onInsertNoteToCanvas:Mt}),Ie&&e.jsxs("div",{className:"kb-drawer__storage-bar",children:[e.jsx(es,{size:12}),e.jsxs("span",{className:"kb-drawer__storage-text",children:["已用 ",cn(Ie.used)]})]})]}),e.jsx("div",{className:"kb-resizer",onMouseDown:kt}),e.jsx("div",{className:"kb-drawer__editor",children:e.jsx(Fs,{note:d,allTags:p,noteTags:z,readOnly:!!(b&&(b.startsWith(ne)||b.startsWith(se))),isSkillDirectory:!!(d&&(((Ve=n.find(a=>a.id===d.directoryId))==null?void 0:Ve.name)==="Skill"||b&&b.startsWith(ne)||b&&b.startsWith(se))),onUpdateNote:ve,onSetNoteTags:Rt,onCreateTag:Fe})}),d&&e.jsx(e.Fragment,{children:oe?e.jsx("button",{className:"kb-drawer__right-toggle",onClick:()=>$(!1),title:"展开侧边栏",children:e.jsx(Cs,{size:14})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"kb-resizer",onMouseDown:_t}),e.jsxs("div",{className:"kb-drawer__right-sidebar",style:{width:ge},children:[e.jsxs("div",{className:"kb-drawer__right-header",children:[e.jsxs("div",{className:"kb-drawer__right-tabs",children:[e.jsx("button",{className:`kb-drawer__right-tab ${J==="related"?"kb-drawer__right-tab--active":""}`,onClick:()=>ie("related"),title:"相似笔记",children:e.jsx(mt,{size:14})}),e.jsx("button",{className:`kb-drawer__right-tab ${J==="extraction"?"kb-drawer__right-tab--active":""}`,onClick:()=>ie("extraction"),title:"知识提取",children:e.jsx(Re,{size:14})})]}),e.jsx("button",{className:"kb-drawer__right-collapse-btn",onClick:()=>$(!0),title:"收起侧边栏",children:e.jsx(vs,{size:14})})]}),e.jsx("div",{className:"kb-drawer__right-content",children:J==="related"?e.jsx(Os,{currentNoteId:d.id,allNotes:l,noteTagsMap:g,onSelectNote:Z}):e.jsx(on,{noteId:d.id,noteContent:d.content,noteTitle:d.title,onSaved:()=>O(),onInsertToNote:St},d.id)})]})]})})]}),e.jsx(Ks,{visible:X,onClose:()=>Y(!1),allTags:p,onCreateTag:Fe,onUpdateTag:Dt,onDeleteTag:Tt})]})};function cn(s){if(s===0)return"0 B";const n=["B","KB","MB","GB"],r=Math.floor(Math.log(s)/Math.log(1024));return`${(s/Math.pow(1024,r)).toFixed(1)} ${n[r]}`}export{dn as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{aM as Ne,r as a,aN as Z,aO as Ye,aP as Xe,aQ as t,aR as ce,aS as Ze,aT as le,aU as es,aV as ss,aW as ts,aX as F,aY as ye,aZ as U,a_ as de,a$ as as,b0 as rs,b1 as Y,b2 as ns,b3 as os,v as X,b4 as me,b5 as is,b6 as cs,b7 as ls,b8 as ue,s as pe,b9 as ds,ba as ms,bb as Ee,bc as Ae,bd as Me}from"./index-7WzIC7_D.js";import{l as us,u as ps,a as hs,g as gs,b as fs,R as bs,P as _s,E as vs,A as Is,c as xs,d as Ss,D as js,e as Re,s as ws}from"./DialogTaskList-0I91BD1p.js";const Ps=({value:u,onChange:f,compact:V=!0,options:b})=>{const{language:S}=Ne(),[_,v]=a.useState(!1),E=a.useRef(null),G=b&&b.length>0?b:Z,l=a.useMemo(()=>u==="auto"?Ye:Xe(u),[u]);a.useEffect(()=>{const o=j=>{E.current&&!E.current.contains(j.target)&&v(!1)};return _&&document.addEventListener("mousedown",o),()=>{document.removeEventListener("mousedown",o)}},[_]);const k=o=>{f(o.value),v(!1)};return V?t.jsxs("div",{className:"aspect-ratio-selector aspect-ratio-selector--compact",ref:E,children:[t.jsx(ce,{content:S==="zh"?"选择图片比例":"Select aspect ratio",theme:"light",children:t.jsxs("div",{className:`aspect-ratio-selector__trigger ${_?"aspect-ratio-selector__trigger--open":""}`,"data-track":"ai_click_ratio_toggle",onClick:()=>v(!_),children:[t.jsx("span",{className:"aspect-ratio-selector__trigger-value",children:(l==null?void 0:l.label)||u}),t.jsx(Ze,{className:`aspect-ratio-selector__trigger-icon ${_?"aspect-ratio-selector__trigger-icon--open":""}`})]})}),_&&t.jsx("div",{className:"aspect-ratio-selector__dropdown",children:t.jsx("div",{className:"aspect-ratio-selector__dropdown-grid",children:G.map(o=>t.jsx(ce,{content:o.description,theme:"light",placement:"top",showArrow:!1,children:t.jsx("div",{className:`aspect-ratio-selector__dropdown-item ${u===o.value?"aspect-ratio-selector__dropdown-item--selected":""}`,"data-track":"ai_click_ratio_select",onClick:()=>k(o),children:o.label})},o.value))})})]}):t.jsxs("div",{className:"aspect-ratio-selector",children:[t.jsx("div",{className:"aspect-ratio-selector__label",children:S==="zh"?"图片比例":"Aspect Ratio"}),t.jsx("div",{className:"aspect-ratio-selector__options",children:G.map(o=>t.jsx(ce,{content:o.description,theme:"light",placement:"top",showArrow:!1,children:t.jsx("div",{className:`aspect-ratio-selector__option ${u===o.value?"aspect-ratio-selector__option--selected":""}`,"data-track":"ai_click_ratio_select",onClick:()=>f(o.value),children:t.jsx("span",{className:"aspect-ratio-selector__option-ratio",children:o.label})})},o.value))})]})},Es=({initialPrompt:u="",initialImages:f=[],selectedElementIds:V=[],initialWidth:b,initialHeight:S,initialResultUrl:_,initialAspectRatio:v,targetFrameId:E,targetFrameDimensions:G,selectedModel:l,selectedModelRef:k,onModelChange:o,onModelRefChange:j}={})=>{var Pe;const A=le("image"),ee=a.useRef(null);if(!ee.current){const e=l||A.modelId||"gemini-2.5-flash-image-vip";ee.current=es(e)}const K=ee.current,T=ss("image"),[g,J]=a.useState(u),[p,M]=a.useState(K.extraParams),se=l||K.currentModel||A.modelId,te=l&&l!==A.modelId?k||null:K.currentModel&&K.currentModel!==A.modelId?null:ts(A.profileId,A.modelId),q=F(T,se,te)||ye("image",se,te),[n,R]=a.useState((q==null?void 0:q.id)||se||((Pe=T[0])==null?void 0:Pe.id)||"gemini-2.5-flash-image-vip"),[m,N]=a.useState(U(q)||te),h=a.useMemo(()=>{if(F(T,n,m)||!n)return T;const s=ye("image",n,m);return s?[s,...T]:T},[n,m,T]),[ae,he]=a.useState(b||1024),[re,ge]=a.useState(S||1024),[I,L]=a.useState(v||K.aspectRatio||de),[ze,d]=a.useState(null),[fe,D]=a.useState(f),[be,Ce]=a.useState(!0),[_e,Oe]=a.useState(()=>us("image")),[B,z]=a.useState("config"),$e=a.useRef(null),{viewportWidth:Ge}=as(),w=Ge<=768,{imageHistory:ve}=ps(),{isGenerating:C}=hs("image"),{language:i}=Ne(),{createTask:Ie}=rs(),x=n.startsWith("mj"),W=Y.useMemo(()=>{if(x)return[];const e=ns(n);if(e.length===0)return Z;const s=new Map(Z.map(c=>[c.value,c])),r=[];return e.forEach(c=>{const y=c.value==="auto"?"auto":c.value.replace("x",":"),O=s.get(y);O&&!r.some(P=>P.value===O.value)&&r.push(O)}),r.length>0?r:Z},[n,x]),ne=Y.useMemo(()=>{const e=os(n);return x?e.length>0:e.some(s=>s.id!=="size")},[n,x]);a.useEffect(()=>{M({})},[n]);const Ke=a.useCallback((e,s)=>{if(!s||s==="default"){M(r=>{const c={...r};return delete c[e],c});return}M(r=>({...r,[e]:s}))},[]),[xe,H]=a.useState(!1),Le=a.useCallback(e=>{Oe(e)},[]),De=a.useCallback(()=>{Ce(e=>!e)},[]),Se=Y.useRef("");a.useEffect(()=>{if(xe)return;const e=JSON.stringify({prompt:u,images:f==null?void 0:f.map(s=>s.url),elementIds:V,width:b,height:S,result:_,aspectRatio:v});Se.current!==e&&(Se.current=e,J(u),D(f||[]),b&&he(b),S&&ge(S),v&&L(v))},[u,f,V,b,S,_,v,xe]),a.useEffect(()=>{const e=s=>{var c;const r=s.imageModelName||((c=h[0])==null?void 0:c.id)||"gemini-2.5-flash-image-vip";if(r!==n){R(r);const y=F(h,r,m);N(U(y)||null)}};return X.addListener(e),()=>X.removeListener(e)},[n,m,h]),a.useEffect(()=>{if(h.length===0)return;F(h,n,m)||(R(h[0].id),N(U(h[0])))},[n,m,h]),a.useEffect(()=>{if(!l)return;const e=me(n,m),s=me(l,k);if(e!==s){R(l);const r=F(h,l,k);N(U(r)||k||null)}},[n,m,l,k,h]),a.useEffect(()=>{!ne&&Object.keys(p).length>0&&M({})},[ne,p]),a.useEffect(()=>{var s;if(x||W.length===0)return;const e=new Set(W.map(r=>r.value));if(!e.has(I)){const r=e.has("auto")?"auto":((s=W[0])==null?void 0:s.value)||de;L(r)}},[I,x,W]),a.useEffect(()=>{is({currentModel:n,extraParams:p,aspectRatio:I})},[n,p,I]),a.useEffect(()=>(d(null),()=>{d(null)}),[]);const We=()=>{J(""),M({}),D([]),d(null),L(de),z("config"),H(!1),window.dispatchEvent(new CustomEvent("ai-image-clear"))},Fe=Y.useMemo(()=>gs("image",i,ve),[ve,i]),je=e=>{ws("image",e)},Ue=e=>{if(H(!0),z("config"),J(e.params.prompt||""),M({}),he(e.params.width||1024),ge(e.params.height||1024),e.params.uploadedImages&&e.params.uploadedImages.length>0?D(e.params.uploadedImages):D([]),e.params.model){R(e.params.model),N(e.params.modelRef||null);const s=X.get();X.update({...s,imageModelName:e.params.model})}e.params.aspectRatio&&L(e.params.aspectRatio),d(null)},Ve=async()=>Promise.all(fe.map(async e=>{if(e.file)return new Promise((s,r)=>{const c=new FileReader;c.onload=()=>{s({type:"url",url:c.result,name:e.name})},c.onerror=r,c.readAsDataURL(e.file)});if(e.url)return{type:"url",url:e.url,name:e.name};throw new Error("Invalid image data")})),we=async(e=1)=>{if(!g||!g.trim()){d(i==="zh"?"请输入图像描述":"Please enter image description");return}if(!ds("image",m||n)&&!await ms()){d(i==="zh"?"需要 API Key 才能生成图片":"API Key is required to generate images");return}x&&d(null);try{const s=typeof ae=="string"?parseInt(ae)||1024:ae,r=typeof re=="string"?parseInt(re)||1024:re,c=await Ve();if(e>1){const Q=[],Be=`batch_${Date.now()}`,oe=n||le("image").modelId,ke=oe.startsWith("mj")?[g.trim(),Ee(p)].filter(Boolean).join(" "):(g||"").trim(),$=!oe.startsWith("mj")&&Object.keys(p).length>0?p:void 0,He=$!=null&&$.size?$.size:Ae(I);for(let ie=0;ie<e;ie++){const Qe={prompt:ke,width:s,height:r,aspectRatio:I,size:He,model:oe,modelRef:m||null,uploadedImages:c,batchId:Be,batchIndex:ie+1,batchTotal:e,autoInsertToCanvas:Re(ue.AI_IMAGE_AUTO_INSERT),targetFrameId:E,targetFrameDimensions:G,...$?{params:$}:{}},Te=Ie(Qe,pe.IMAGE);Te&&Q.push(Te.id)}Q.length>0?(Me.success(i==="zh"?`已添加 ${Q.length} 个任务到队列`:`Added ${Q.length} tasks to queue`),je(ke),d(null),z("tasks"),H(!1)):d(i==="zh"?"批量任务创建失败,请稍后重试":"Failed to create batch tasks, please try again later");return}const y=n||le("image").modelId,O=y.startsWith("mj")?[g.trim(),Ee(p)].filter(Boolean).join(" "):(g||"").trim(),P=!y.startsWith("mj")&&Object.keys(p).length>0?p:void 0,Je=P!=null&&P.size?P.size:Ae(I),qe={prompt:O,width:s,height:r,aspectRatio:I,size:Je,model:y,modelRef:m||null,uploadedImages:c,autoInsertToCanvas:Re(ue.AI_IMAGE_AUTO_INSERT),batchId:`image_single_${Date.now()}`,batchIndex:1,batchTotal:1,targetFrameId:E,targetFrameDimensions:G,...P?{params:P}:{}};Ie(qe,pe.IMAGE)?(Me.success(i==="zh"?"任务已添加到队列,将在后台生成":"Task added to queue, will be generated in background"),je(O),d(null),z("tasks"),H(!1)):d(i==="zh"?"任务创建失败,请检查参数或稍后重试":"Failed to create task, please check parameters or try again later")}catch(s){console.error("Failed to create task:",s);let r=i==="zh"?"任务创建失败,请检查参数或稍后重试":"Failed to create task, please check parameters or try again later";s.message&&(s.message.includes("exceed 5000 characters")?r=i==="zh"?"提示词不能超过 5000 字符":"Prompt must not exceed 5000 characters":s.message.includes("Duplicate submission")?r=i==="zh"?"请勿重复提交,请等待 5 秒后再试":"Duplicate submission. Please wait 5 seconds.":s.message.includes("Invalid parameters")&&(r=i==="zh"?`参数错误: ${s.message.replace("Invalid parameters: ","")}`:s.message)),d(r)}};return fs(C,g,()=>we(1)),t.jsxs("div",{className:"ai-image-generation-container",children:[w?t.jsxs("div",{className:"ai-generation-mobile-switcher",role:"tablist",children:[t.jsx("button",{type:"button",className:`ai-generation-mobile-switcher__tab ${B==="config"?"ai-generation-mobile-switcher__tab--active":""}`,onClick:()=>z("config"),children:"生成设置"}),t.jsx("button",{type:"button",className:`ai-generation-mobile-switcher__tab ${B==="tasks"?"ai-generation-mobile-switcher__tab--active":""}`,onClick:()=>z("tasks"),children:"生成任务"})]}):null,t.jsxs("div",{className:`main-content ${w?"main-content--mobile-panels":""}`,ref:$e,children:[t.jsxs("div",{className:`ai-image-generation-section ${w&&B!=="config"?"ai-generation-mobile-panel--hidden":""}`,children:[t.jsxs("div",{className:"ai-image-generation-form",children:[l!==void 0&&o&&t.jsx("div",{className:"form-header-row",children:t.jsx("div",{className:"model-selector-wrapper",children:t.jsx(cs,{selectedModel:n,selectedSelectionKey:me(n,m),onSelect:e=>{R(e),N(null),o(e),j==null||j(null)},onSelectModel:e=>{R(e.id);const s=U(e);N(s),o(e.id),j==null||j(s)},language:i,models:h,placement:"down",variant:"form",disabled:C})})}),ne&&t.jsx("div",{className:"model-params-row",children:t.jsx(ls,{selectedParams:p,onParamChange:Ke,modelId:n,language:i,disabled:C,excludeParamIds:x?void 0:["size"]})}),t.jsx(bs,{images:fe,onImagesChange:D,language:i,disabled:C,multiple:!0,label:i==="zh"?"参考图片 (可选)":"Reference Images (Optional)",onError:d}),t.jsx(_s,{prompt:g,onPromptChange:J,presetPrompts:Fe,language:i,type:"image",disabled:C,onError:d}),t.jsx(vs,{error:ze})]}),t.jsx(Is,{language:i,type:"image",isGenerating:C,hasGenerated:!1,canGenerate:!!(g&&g.trim()),onGenerate:we,onReset:We,leftContent:t.jsxs(t.Fragment,{children:[t.jsx(xs,{storageKey:ue.AI_IMAGE_AUTO_INSERT,language:i}),!x&&t.jsx(Ps,{value:I,onChange:L,compact:!0,options:W})]})})]}),w?null:t.jsx(Ss,{isRightPanelVisible:be,onToggleRightPanel:De,onWidthChange:Le,rightPanelWidth:_e,language:i,storageKey:"image"}),(w||be)&&t.jsx("div",{className:`task-sidebar ${w?"task-sidebar--mobile-panel":""} ${w&&B!=="tasks"?"ai-generation-mobile-panel--hidden":""}`,style:w?void 0:{width:_e,flexShrink:0},children:t.jsx(js,{taskType:pe.IMAGE,onEditTask:Ue})})]})]})};export{Es as default};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{r,I as as,_ as rs,co as ns,aQ as e,cp as Oe,cq as ls,cb as ds,cr as is,bh as ke,cs,ct as us,aT as ms,cu as Te,cv as ps,aV as fs,a$ as bs,aW as hs,aX as re,aY as ze,aZ as ee,b1 as V,cw as ne,cx as vs,cy as $e,cz as gs,cA as xs,cB as Ve,aM as _s,b0 as ys,v as ce,b4 as ge,cC as js,b6 as Ss,b7 as Ps,b8 as Re,s as Le,bd as Ns}from"./index-7WzIC7_D.js";import{f as Cs,C as ws,l as Es,u as Ms,a as Is,g as Os,b as ks,R as Ts,P as zs,E as $s,A as Vs,c as Rs,d as Ls,D as Fs,e as Us,s as As}from"./DialogTaskList-0I91BD1p.js";import{S as De}from"./index-WyqXHNHN.js";import"./pick-C1hcXSqm.js";import"./hasIn-4hPyOh4r.js";function Fe(d,a){var o=Object.keys(d);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(d);a&&(c=c.filter(function(u){return Object.getOwnPropertyDescriptor(d,u).enumerable})),o.push.apply(o,c)}return o}function Ue(d){for(var a=1;a<arguments.length;a++){var o=arguments[a]!=null?arguments[a]:{};a%2?Fe(Object(o),!0).forEach(function(c){rs(d,c,o[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(d,Object.getOwnPropertyDescriptors(o)):Fe(Object(o)).forEach(function(c){Object.defineProperty(d,c,Object.getOwnPropertyDescriptor(o,c))})}return d}var Ds={tag:"svg",attrs:{fill:"none",viewBox:"0 0 24 24",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12 21C16.9706 21 21 16.9706 21 12C21 7.02944 16.9706 3 12 3C7.02944 3 3 7.02944 3 12C3 16.9706 7.02944 21 12 21ZM23 12C23 18.0751 18.0751 23 12 23C5.92487 23 0.999999 18.0751 1 12C1 5.92487 5.92487 0.999999 12 1C18.0751 1 23 5.92487 23 12ZM15 16.4142L11 12.4142L11 5.5H13L13 11.5858L16.4142 15L15 16.4142Z"}}]},xe=r.forwardRef(function(d,a){return r.createElement(as,Ue(Ue({},d),{},{id:"time",ref:a,icon:Ds}))});xe.displayName="TimeIcon";const Ks=({model:d,configOverride:a,duration:o,size:c,onDurationChange:u,onSizeChange:n,disabled:x=!1})=>{const p=a||ns(d);r.useEffect(()=>{const f={duration:p.defaultDuration,size:p.defaultSize};p.durationOptions.find(N=>N.value===o)||u(f.duration),p.sizeOptions.find(N=>N.value===c)||n(f.size)},[p,o,d,u,n,c]);const w=p.durationOptions.map(f=>({label:f.label,value:f.value})),M=p.sizeOptions.map(f=>({label:`${f.label} (${f.value})`,value:f.value}));return e.jsxs("div",{className:"video-model-options",children:[e.jsxs("div",{className:"video-model-options__row",children:[e.jsx("label",{className:"video-model-options__label",children:"时长"}),e.jsx("div",{className:"video-model-options__control",children:p.durationOptions.length===1?e.jsx("span",{className:"video-model-options__fixed-value",children:p.durationOptions[0].label}):e.jsx(Oe.Group,{value:o,onChange:f=>u(f),disabled:x,variant:"default-filled",size:"small",children:w.map(f=>e.jsx(Oe.Button,{value:f.value,children:f.label},f.value))})})]}),e.jsxs("div",{className:"video-model-options__row",children:[e.jsx("label",{className:"video-model-options__label",children:"尺寸"}),e.jsx("div",{className:"video-model-options__control",children:e.jsx(De,{value:c,onChange:f=>n(f),disabled:x,size:"small",options:M,style:{width:"200px"}})})]})]})};function Ke(){return ls("scene")}function Ae(d,a){return{id:Ke(),order:d,duration:a,prompt:""}}function Gs(d,a,o=1){if(d.length===0)return{valid:!1,error:"至少需要一个场景"};for(const u of d){if(u.duration<o)return{valid:!1,error:`场景 ${u.order} 时长不能少于 ${o} 秒`};if(u.duration>a)return{valid:!1,error:`场景 ${u.order} 时长不能超过 ${a} 秒`}}const c=d.find(u=>!u.prompt.trim());return c?{valid:!1,error:`场景 ${c.order} 需要填写提示词`}:{valid:!0}}function Ws(d){return d.sort((a,o)=>a.order-o.order).map((a,o)=>`Shot ${o+1}:
|
|
2
|
-
duration: ${a.duration}sec
|
|
3
|
-
Scene: ${a.prompt.trim()}`).join(`
|
|
4
|
-
|
|
5
|
-
`)}function Bs(d){const a=/Shot\s+(\d+):\s*\n\s*duration:\s*([\d.]+)\s*sec\s*\n\s*Scene:\s*([^\n]+(?:\n(?!Shot\s+\d+:)[^\n]*)*)/gi,o=[];let c;for(;(c=a.exec(d))!==null;){const u=parseInt(c[1],10),n=parseFloat(c[2]),x=c[3].trim();o.push({id:Ke(),order:u,duration:n,prompt:x})}return o.length===0?null:o.sort((u,n)=>u.order-n.order)}const Hs=({value:d,onChange:a,placeholder:o,disabled:c=!1,autoFocus:u=!1,enableMention:n=!0})=>{const{mentionState:x,textareaRef:p,handleTextChange:w,handleKeyDown:M,handleCharacterSelect:f,closeMentionPopup:k}=Cs({enabled:n,onPromptChange:a,prompt:d}),U=r.useCallback(N=>{const T=N.target.value,z=N.target.selectionStart||0;w(T,z)},[w]);return r.useEffect(()=>{u&&p.current&&p.current.focus()},[u,p]),e.jsxs("div",{className:"scene-prompt-input",children:[e.jsx("textarea",{ref:p,className:"scene-prompt-input__textarea",value:d,onChange:U,onKeyDown:M,placeholder:o,disabled:c,rows:3}),n&&e.jsx(ws,{visible:x.visible,query:x.query,position:x.position,showBelow:x.showBelow,selectedIndex:x.selectedIndex,onSelect:f,onClose:k})]})},qs=({enabled:d,onEnabledChange:a,totalDuration:o,maxScenes:c,minSceneDuration:u,scenes:n,onScenesChange:x,disabled:p=!1})=>{const[w,M]=r.useState(null),f=r.useRef(null);r.useEffect(()=>{d&&n.length>0&&!w&&M(n[0].id)},[d,n,w]);const k=r.useCallback(()=>{if(n.length>=c)return;const m=n.reduce((v,O)=>v+O.duration,0),h=o-m;let b=Math.max(u,h/2);b=parseFloat(b.toFixed(1)),b<u&&(b=u);const y=Ae(n.length+1,b);x([...n,y]),M(y.id),setTimeout(()=>{var v;(v=f.current)==null||v.scrollIntoView({behavior:"smooth"})},100)},[n,c,o,u,x]),U=r.useCallback(m=>{var y;if(n.length<=1)return;const b=n.filter(v=>v.id!==m).map((v,O)=>({...v,order:O+1}));x(b),w===m&&M(((y=b[0])==null?void 0:y.id)||null)},[n,x,w]),N=r.useCallback(m=>{const h=n.filter(b=>b.id!==m).reduce((b,y)=>b+y.duration,0);return Math.max(u,o-h)},[n,o,u]),T=r.useCallback(m=>{const h=N(m),b=[],y=.1;for(let v=u;v<=h+.001;v+=y){const O=parseFloat(v.toFixed(1));O<=h&&b.push({label:`${O}`,value:O})}return b},[u,N]),z=r.useCallback((m,h)=>{const b=typeof h=="string"?parseFloat(h):h;if(isNaN(b))return;const y=N(m),v=n.map(O=>{if(O.id===m){const me=Math.max(u,Math.min(b,y)),R=parseFloat(me.toFixed(1));return{...O,duration:R}}return O});x(v)},[n,u,N,x]),F=r.useCallback((m,h)=>{const b=n.map(y=>y.id===m?{...y,prompt:h}:y);x(b)},[n,x]),ue=r.useCallback(m=>{if(a(m),m&&n.length===0){const h=Ae(1,o);x([h]),M(h.id)}},[n,o,a,x]),I=r.useCallback(m=>{M(m)},[]),le=n.length<c;return e.jsxs("div",{className:"storyboard-editor",children:[e.jsxs("div",{className:"storyboard-editor__header",children:[e.jsxs("div",{className:"storyboard-editor__toggle",children:[e.jsx(ds,{value:d,onChange:ue,disabled:p,size:"small"}),e.jsxs("div",{className:"storyboard-editor__title",children:[e.jsx("span",{className:"storyboard-editor__title-text",children:"故事场景模式"}),e.jsx("span",{className:"storyboard-editor__title-desc",children:"定义多个场景及其时长"})]})]}),d&&e.jsx("span",{className:"storyboard-editor__new-badge",children:"NEW"})]}),d&&e.jsxs("div",{className:"storyboard-editor__content",children:[e.jsxs("div",{className:"storyboard-editor__section-header",children:[e.jsx("span",{className:"storyboard-editor__section-title",children:"场景列表"}),e.jsxs("span",{className:"storyboard-editor__section-hint",children:["共 ",n.length," 个场景,已用 ",n.reduce((m,h)=>m+h.duration,0).toFixed(1)," 秒 / 总时长 ",o," 秒"]})]}),e.jsxs("div",{className:"storyboard-editor__scenes",children:[n.map((m,h)=>{const b=w===m.id,y=h===n.length-1;return e.jsxs("div",{className:`storyboard-editor__scene-wrapper ${b?"is-selected":""}`,children:[e.jsx("div",{className:`storyboard-editor__timeline-line ${y?"is-last":""}`}),e.jsx("div",{className:`storyboard-editor__timeline-node ${b?"is-selected":""}`,children:b?h+1:""}),!b&&e.jsxs("div",{className:"storyboard-editor__scene storyboard-editor__scene--compact",onClick:()=>I(m.id),children:[e.jsx("span",{className:"storyboard-editor__scene-index",children:h+1}),e.jsx("div",{className:"storyboard-editor__scene-preview",children:e.jsx("p",{className:"storyboard-editor__scene-preview-text",children:m.prompt||"暂无场景描述..."})}),e.jsxs("div",{className:"storyboard-editor__scene-duration-badge",children:[e.jsx(xe,{size:"12px"}),e.jsxs("span",{children:[m.duration,"s"]})]}),e.jsx(is,{className:"storyboard-editor__scene-arrow",size:"14px"})]}),b&&e.jsxs("div",{className:"storyboard-editor__scene storyboard-editor__scene--expanded",children:[e.jsxs("div",{className:"storyboard-editor__scene-header",children:[e.jsx("div",{className:"storyboard-editor__scene-info",children:e.jsxs("span",{className:"storyboard-editor__scene-label",children:[e.jsx("span",{className:"storyboard-editor__active-indicator"}),"场景 ",h+1]})}),e.jsxs("div",{className:"storyboard-editor__scene-controls",children:[e.jsx(xe,{className:"storyboard-editor__time-icon"}),e.jsx(De,{value:parseFloat(m.duration.toFixed(1)),onChange:v=>z(m.id,v),disabled:p,className:"storyboard-editor__duration-select",size:"small",options:T(m.id),filterable:!0,creatable:!0,popupProps:{overlayClassName:"storyboard-editor__duration-popup"}}),n.length>1&&e.jsx(ke,{theme:"default",variant:"text",size:"small",icon:e.jsx(cs,{}),onClick:v=>{v.stopPropagation(),U(m.id)},disabled:p,className:"storyboard-editor__scene-delete"})]})]}),e.jsx("div",{className:"storyboard-editor__scene-prompt",children:e.jsx(Hs,{value:m.prompt,onChange:v=>F(m.id,v),placeholder:`描述场景 ${h+1} 的内容,输入 @ 可引用角色`,disabled:p,autoFocus:!0,enableMention:!0})})]})]},m.id)}),e.jsx("div",{ref:f})]}),le&&e.jsx(ke,{theme:"default",variant:"dashed",size:"medium",icon:e.jsx(us,{}),onClick:k,disabled:p,className:"storyboard-editor__add-btn",block:!0,children:"添加场景"})]})]})},et=({initialPrompt:d="",initialImage:a,initialImages:o,initialDuration:c,initialModel:u,initialSize:n,initialResultUrl:x,selectedModel:p,selectedModelRef:w,onModelChange:M,onModelRefChange:f}={})=>{var Ie;const k=ms("video"),U=r.useRef(null);if(!U.current){const s=Te(u||p||k.modelId||"veo3");U.current=ps(s)}const N=U.current,T=fs("video"),[z,F]=r.useState(d),[ue,I]=r.useState(null),[le,m]=r.useState(!0),[h,b]=r.useState(()=>Es("video")),[y,v]=r.useState("config"),O=r.useRef(null),{viewportWidth:me}=bs(),R=me<=768,_e=u||p||N.currentModel||k.modelId,pe=p&&p!==k.modelId?w||null:N.currentModel&&N.currentModel!==k.modelId?null:hs(k.profileId,k.modelId),de=re(T,_e,pe)||ze("video",_e,pe),[i,q]=r.useState((de==null?void 0:de.id)||((Ie=T[0])==null?void 0:Ie.id)||Te("veo3")),[S,Z]=r.useState(ee(de)||pe),L=V.useMemo(()=>{if(re(T,i,S)||!i)return T;const t=ze("video",i,S);return t?[t,...T]:T},[i,S,T]),[$,K]=r.useState(()=>N.extraParams||ne(i,S||i)),fe=V.useMemo(()=>vs(i,S||i,$),[i,S,$]),C=V.useMemo(()=>$e(i,S||i,$),[i,S,$]),G=V.useMemo(()=>gs(i,S||i,$),[i,S,$]),[W,se]=r.useState((c==null?void 0:c.toString())||N.duration||G.duration),[ie,te]=r.useState(n||N.size||G.size),Ge=V.useMemo(()=>fe.some(s=>s.id!=="size"&&s.id!=="duration"),[fe]),We=r.useCallback((s,t)=>{if(!t||t==="default"){K(l=>{const g={...l};return delete g[s],g});return}K(l=>({...l,[s]:t}))},[]),[ye,Q]=r.useState(()=>o&&o.length>0?o:a?[{slot:0,slotLabel:"参考图",url:a.url||"",name:a.name,file:a.file}]:[]),[je,A]=r.useState(()=>{const s=C.imageUpload.maxCount,t=C.imageUpload.labels||[];let l=[];return o&&o.length>0?l=o:a&&(l=[{slot:0,slotLabel:t[0]||"参考图",url:a.url||"",name:a.name,file:a.file}]),l.slice(0,s).map((g,_)=>({...g,slot:_,slotLabel:t[_]||`参考图${_+1}`}))}),[Y,B]=r.useState(!1),[oe,H]=r.useState([]),be=V.useMemo(()=>xs(i),[i]),Be=Ve(i),{videoHistory:Se}=Ms(),[He,qe]=r.useState(0),{isGenerating:D}=Is("video"),Ze=r.useCallback(s=>{b(s)},[]),Qe=r.useCallback(()=>{m(s=>!s)},[]),{language:P}=_s(),{createTask:Ye}=ys();r.useEffect(()=>{const s=t=>{const l=t.videoModelName||"veo3";if(l!==i){q(l);const g=re(L,l,S);Z(ee(g)||null),K(ne(l,ee(g)||l))}};return ce.addListener(s),()=>ce.removeListener(s)},[i,S,L]),r.useEffect(()=>{if(L.length===0)return;re(L,i,S)||(q(L[0].id),Z(ee(L[0])))},[i,S,L]),r.useEffect(()=>{if(!p)return;const s=ge(i,S),t=ge(p,w);if(s!==t){q(p);const l=re(L,p,w);Z(ee(l)||w||null)}},[i,S,p,w,L]);const[Pe,he]=r.useState(!1),[Ne,Ce]=r.useState(!1);r.useEffect(()=>{if(Ne){Ce(!1);return}const s=C.imageUpload.maxCount,t=C.imageUpload.labels||[];if(se(G.duration),te(G.size),ye.length>0){const l=ye.slice(0,s).map((g,_)=>({...g,slot:_,slotLabel:t[_]||`参考图${_+1}`}));A(l)}else A([]);Ve(i)||(B(!1),H([]))},[i,G,Ne,C.imageUpload]);const we=V.useRef("");r.useEffect(()=>{if(Pe)return;const s=JSON.stringify({prompt:d,image:a==null?void 0:a.url,images:o==null?void 0:o.map(j=>j.url),duration:c,model:u,size:n,result:x});if(we.current===s)return;we.current=s,F(d);const t=C.imageUpload.maxCount,l=C.imageUpload.labels||[];let g=[];o&&o.length>0?g=o:a&&(g=[{slot:0,slotLabel:"参考图",url:a.url||"",name:a.name,file:a.file}]),Q(g);const _=g.slice(0,t).map((j,E)=>({...j,slot:E,slotLabel:l[E]||`参考图${E+1}`}));A(_),c!==void 0&&se(c.toString()),n&&te(n),I(null)},[d,a,o,c,n,x,C.imageUpload,Pe]),r.useEffect(()=>(I(null),()=>{I(null)}),[]),r.useEffect(()=>{js({currentModel:i,extraParams:$,duration:W,size:ie})},[i,$,W,ie]);const Je=()=>{F(""),Q([]),A([]),I(null),v("config"),se(G.duration),te(G.size),he(!1),B(!1),H([]),K(ne(i,S||i)),window.dispatchEvent(new CustomEvent("ai-video-clear"))},Ee=V.useCallback((s,t)=>s.map((l,g)=>({slot:g,slotLabel:t[g]||`参考图${g+1}`,url:l.url,name:l.name,file:l.file})),[]),Xe=V.useCallback(s=>s.map(t=>({url:t.url,name:t.name,file:t.file})),[]),es=V.useCallback(s=>{const t=C.imageUpload.labels||[],l=Ee(s,t);A(l),Q(l)},[C.imageUpload.labels,Ee]),ss=V.useMemo(()=>Os("video",P,Se),[Se,P,He]),ts=s=>{As("video",s),qe(t=>t+1)},os=s=>{var l,g;if(he(!0),v("config"),Ce(!0),s.params.model){q(s.params.model),Z(s.params.modelRef||null);const _=ce.get();ce.update({..._,videoModelName:s.params.model})}if((l=s.params.storyboard)!=null&&l.enabled&&((g=s.params.storyboard)!=null&&g.scenes))B(!0),H(s.params.storyboard.scenes),F("");else{const _=s.params.prompt||"",j=Bs(_);j&&j.length>0?(B(!0),H(j),F("")):(B(!1),H([]),F(_))}if(s.params.seconds!==void 0){const _=typeof s.params.seconds=="string"?s.params.seconds:s.params.seconds.toString();se(_)}const t=s.params.params&&typeof s.params.params=="object"?Object.entries(s.params.params).reduce((_,[j,E])=>(E!=null&&String(E).trim()&&(_[j]=String(E)),_),{}):{};if(K(t),s.params.size&&te(s.params.size),s.params.uploadedImages&&s.params.uploadedImages.length>0){Q(s.params.uploadedImages);const _=s.params.model||i,j=$e(_,s.params.modelRef||_,t),E=j.imageUpload.maxCount,ae=j.imageUpload.labels||[],J=s.params.uploadedImages.slice(0,E).map((X,ve)=>({...X,slot:ve,slotLabel:ae[ve]||`参考图${ve+1}`}));A(J)}else Q([]),A([]);I(null)},Me=async(s=1)=>{if(Y){const t=Gs(oe,parseFloat(W),be.minSceneDuration);if(!t.valid){I(t.error||"场景配置无效");return}}else if(!z||!z.trim()){I(P==="zh"?"请输入视频描述":"Please enter video description");return}try{const t=[];for(const j of je)if(j.file){const E=await new Promise((ae,J)=>{const X=new FileReader;X.onload=()=>ae(X.result),X.onerror=J,X.readAsDataURL(j.file)});t.push({...j,url:E,file:void 0})}else t.push({...j,file:void 0});const l=Y?Ws(oe):(z||"").trim(),g=[],_=`video_batch_${Date.now()}`;for(let j=0;j<s;j++){const E=Object.keys($).length>0?$:void 0,ae={prompt:l,model:i,modelRef:S||null,seconds:W,size:ie,uploadedImages:t,...Y&&{storyboard:{enabled:!0,scenes:oe,totalDuration:parseFloat(W)}},batchId:_,batchIndex:j+1,batchTotal:s,autoInsertToCanvas:Us(Re.AI_VIDEO_AUTO_INSERT),...E?{params:E}:{}},J=Ye(ae,Le.VIDEO);J&&g.push(J.id)}g.length>0?(Ns.success(P==="zh"?s>1?`${g.length} 个视频任务已添加到队列,将在后台生成`:"视频任务已添加到队列,将在后台生成":s>1?`${g.length} video tasks added to queue, will be generated in background`:"Video task added to queue, will be generated in background"),ts(l),F(""),Q([]),A([]),B(!1),H([]),I(null),v("tasks"),he(!1)):I(P==="zh"?"任务创建失败,请检查参数或稍后重试":"Failed to create task, please check parameters or try again later")}catch(t){console.error("Failed to create task:",t);let l=P==="zh"?"任务创建失败,请检查参数或稍后重试":"Failed to create task, please check parameters or try again later";t.message&&(t.message.includes("exceed 5000 characters")?l=P==="zh"?"提示词不能超过 5000 字符":"Prompt must not exceed 5000 characters":t.message.includes("Duplicate submission")?l=P==="zh"?"请勿重复提交,请等待 5 秒后再试":"Duplicate submission. Please wait 5 seconds.":t.message.includes("Invalid parameters")&&(l=P==="zh"?`参数错误: ${t.message.replace("Invalid parameters: ","")}`:t.message)),I(l)}};return ks(D,z,Me),e.jsxs("div",{className:"ai-video-generation-container",children:[R?e.jsxs("div",{className:"ai-generation-mobile-switcher",role:"tablist",children:[e.jsx("button",{type:"button",className:`ai-generation-mobile-switcher__tab ${y==="config"?"ai-generation-mobile-switcher__tab--active":""}`,onClick:()=>v("config"),children:"生成设置"}),e.jsx("button",{type:"button",className:`ai-generation-mobile-switcher__tab ${y==="tasks"?"ai-generation-mobile-switcher__tab--active":""}`,onClick:()=>v("tasks"),children:"生成任务"})]}):null,e.jsxs("div",{className:`main-content ${R?"main-content--mobile-panels":""}`,ref:O,children:[e.jsxs("div",{className:`ai-image-generation-section ${R&&y!=="config"?"ai-generation-mobile-panel--hidden":""}`,children:[e.jsxs("div",{className:"ai-image-generation-form",children:[p!==void 0&&M&&e.jsx("div",{className:"form-header-row",children:e.jsx("div",{className:"model-selector-wrapper",children:e.jsx(Ss,{selectedModel:i,selectedSelectionKey:ge(i,S),onSelect:s=>{const t=s;q(t),Z(null),K(ne(t,t)),M(s),f==null||f(null)},onSelectModel:s=>{const t=s.id;q(t);const l=ee(s);Z(l),K(ne(t,l||t)),M(s.id),f==null||f(l)},language:P,models:L,placement:"down",variant:"form",placeholder:P==="zh"?"选择视频模型":"Select Video Model",disabled:D})})}),Ge&&e.jsx("div",{className:"model-params-row",children:e.jsx(Ps,{selectedParams:$,onParamChange:We,compatibleParams:fe,modelId:i,language:P,disabled:D,excludeParamIds:["size","duration"]})}),e.jsx(Ks,{model:i,configOverride:C,duration:W,size:ie,onDurationChange:se,onSizeChange:te,disabled:D}),e.jsx(Ts,{images:Xe(je),onImagesChange:es,language:P,disabled:D,multiple:C.imageUpload.maxCount>1,maxCount:C.imageUpload.maxCount,slotLabels:C.imageUpload.mode==="frames"?C.imageUpload.labels:void 0,label:C.imageUpload.mode==="frames"?P==="zh"?"首尾帧图片 (可选)":"Start/End Frames (Optional)":P==="zh"?"参考图片 (可选)":"Reference Images (Optional)"}),Be&&e.jsx(qs,{enabled:Y,onEnabledChange:B,totalDuration:parseFloat(W),maxScenes:be.maxScenes,minSceneDuration:be.minSceneDuration,scenes:oe,onScenesChange:H,disabled:D}),!Y&&e.jsx(zs,{prompt:z,onPromptChange:F,presetPrompts:ss,language:P,type:"video",disabled:D,onError:I,videoProvider:C.provider}),e.jsx($s,{error:ue})]}),e.jsx(Vs,{language:P,type:"video",isGenerating:D,hasGenerated:!1,canGenerate:Y?oe.length>0:!!(z&&z.trim()),onGenerate:Me,onReset:Je,leftContent:e.jsx(Rs,{storageKey:Re.AI_VIDEO_AUTO_INSERT,language:P})})]}),R?null:e.jsx(Ls,{isRightPanelVisible:le,onToggleRightPanel:Qe,onWidthChange:Ze,rightPanelWidth:h,language:P,storageKey:"video"}),(R||le)&&e.jsx("div",{className:`task-sidebar ${R?"task-sidebar--mobile-panel":""} ${R&&y!=="tasks"?"ai-generation-mobile-panel--hidden":""}`,style:R?void 0:{width:h,flexShrink:0},children:e.jsx(Fs,{taskType:Le.VIDEO,onEditTask:os})})]})]})};export{et as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{U as a,C as n}from"./mermaid.core-DawxQi4y.js";const t=(r,o)=>a.lang.round(n.parse(r)[o]);export{t as c};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{U as a,C as n}from"./index-Cx19IgV-.js";const t=(r,o)=>a.lang.round(n.parse(r)[o]);export{t as c};
|
package/assets/clone-BscGHP5K.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as r}from"./graph-BbAdRpyG.js";var e=4;function a(o){return r(o,e)}export{a as c};
|
package/assets/clone-CTdvgy2F.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a5 as r}from"./index-7WzIC7_D.js";var a=4;function n(o){return r(o,a)}export{n as c};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{f as o,p as e}from"./flowDb-956e92f1-DKdojl1Z.js";import{f as a,a as t}from"./styles-c10674c1-BcxLBYaC.js";import{y as i}from"./mermaid.core-DawxQi4y.js";import"./graph-BbAdRpyG.js";import"./layout-CSua1dGC.js";import"./index-3862675e-Cy2LJr-t.js";import"./clone-BscGHP5K.js";import"./edges-e0da2a9e-BoQQRKl3.js";import"./createText-2e5e7dd3-BCbwgqBS.js";import"./line-CN9rNlXr.js";import"./array-B5oSNiGi.js";import"./path-CY0bYimO.js";import"./channel-ChluHQU5.js";import"./index-7WzIC7_D.js";const n={parser:e,db:o,renderer:t,styles:a,init:r=>{r.flowchart||(r.flowchart={}),r.flowchart.arrowMarkerAbsolute=r.arrowMarkerAbsolute,i({flowchart:{arrowMarkerAbsolute:r.arrowMarkerAbsolute}}),t.setConf(r.flowchart),o.clear(),o.setGen("gen-2")}};export{n as diagram};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{f as o,p as e}from"./flowDb-956e92f1-_yAXk9b2.js";import{f as a,a as t}from"./styles-c10674c1-Dp5J5JrP.js";import{z as i}from"./index-Cx19IgV-.js";import"./graph-CG3zmXkL.js";import"./layout-D_agYVJ_.js";import"./index-3862675e-D_PJ0qZE.js";import"./index-7WzIC7_D.js";import"./clone-CTdvgy2F.js";import"./edges-e0da2a9e-1EAOsAGW.js";import"./createText-2e5e7dd3-BGRSuPih.js";import"./index-BOZ3fCzl.js";import"./line-CxGDlzoc.js";import"./array-BKyUJesY.js";import"./path-CbwjOpE9.js";import"./channel-DQ0ggWsj.js";import"./isEmpty-BoFRUVaJ.js";import"./has-Cq7YuzG9.js";import"./hasIn-4hPyOh4r.js";import"./pick-C1hcXSqm.js";const z={parser:e,db:o,renderer:t,styles:a,init:r=>{r.flowchart||(r.flowchart={}),r.flowchart.arrowMarkerAbsolute=r.arrowMarkerAbsolute,i({flowchart:{arrowMarkerAbsolute:r.arrowMarkerAbsolute}}),t.setConf(r.flowchart),o.clear(),o.setGen("gen-2")}};export{z as diagram};
|