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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a$ as Pe,r as a,s as Y,aQ as e,aR as de,aS as Ae,bg as ne,en as Re,eo as De,cR as Ee,ep as Te,eq as Fe,er as ce,es as $e,et as ze,e7 as Be,eu as Oe,ev as He,ew as Ue,ex as We,ey as Ge,ez as Ve,eA as qe,eB as Xe,cC as Qe,bc as U,eC as Ye,eD as Ke,bj as ye,bn as Ze,eE as Je,bp as et,cP as tt,bi as Ce,bh as _e,bV as st,cs as nt,eF as at,cL as rt,eG as ot,eH as it,eI as lt,cY as Ie,t as ct,c1 as dt,cG as ee,ct as ut,e8 as mt,e9 as pt,eJ as ft,cO as Se,eK as ht,eL as gt,dq as Me,eM as vt,eN as xt,eO as wt,u as bt,eP as yt,eQ as Ct}from"./index-CvvgEQLL.js";function At(){const{completedTasks:t}=Pe(),o=a.useMemo(()=>t.filter(n=>{var m;return n.type===Y.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===Y.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 je=(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}))},Rt=(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])},Et=t=>{const[o,l]=a.useState(!1),[i,n]=a.useState(!1),m=a.useCallback(f=>{l(f),je(f,i,t)},[i,t]),b=a.useCallback(f=>{n(f),je(o,f,t)},[o,t]);return{isGenerating:o,isLoading:i,updateIsGenerating:m,updateIsLoading:b}},_t=(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",It=[1,2,3,4,5,10,20,50,100],St="aitu_image_generation_quantity",Mt="aitu_video_generation_quantity",me=100,Ft=({language:t,type:o,isGenerating:l,hasGenerated:i,canGenerate:n,onGenerate:m,onReset:b,leftContent:f})=>{const h=o==="video"?Mt:St,[g,C]=a.useState(()=>{try{const u=localStorage.getItem(h);if(u){const L=parseInt(u,10);if(!isNaN(L)&&L>=1&&L<=me)return L}}catch{}return 1}),[D,N]=a.useState(!1),[c,x]=a.useState(()=>g.toString()),y=a.useRef(null);a.useEffect(()=>{x(g.toString());try{localStorage.setItem(h,g.toString())}catch{}},[g,h]),a.useEffect(()=>{const u=L=>{y.current&&!y.current.contains(L.target)&&(N(!1),w())};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[c]);const w=()=>{let u=parseInt(c,10);(isNaN(u)||u<1)&&(u=1),u>me&&(u=me),x(u.toString()),C(u)},T=u=>{const L=u.target.value;(L===""||/^\d*$/.test(L))&&x(L)},$=u=>{C(u),x(u.toString()),N(!1)},k=()=>{l||N(!D)},B=()=>{m(g)};return e.jsxs("div",{className:"section-actions unified-action-bar",children:[f&&e.jsx("div",{className:"action-bar-left",children:f}),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 ${D?"is-open":""} ${l?"is-disabled":""}`,children:[e.jsx("input",{type:"text",inputMode:"numeric",value:c,onChange:T,onBlur:w,"data-track":"ai_click_quantity_input",onClick:()=>!l&&N(!0),disabled:l,className:"quantity-input"}),e.jsx("button",{type:"button","data-track":"ai_click_quantity_toggle",onClick:u=>{u.stopPropagation(),k()},disabled:l,className:"quantity-toggle",children:e.jsx(Ae,{className:`quantity-icon ${D?"is-open":""}`})})]})}),D&&e.jsxs("div",{className:"quantity-dropdown",children:[e.jsx("div",{className:"quantity-dropdown-header",children:t==="zh"?"选择数量":"Select Quantity"}),It.map(u=>e.jsxs("button",{type:"button","data-track":"ai_click_quantity_select",onClick:()=>$(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(Re,{}),className:"action-button--reset-subtle"})})]})},$t=({error:t})=>t?e.jsx("div",{className:"form-error",children:t}):null,jt=({visible:t,query:o,position:l,showBelow:i=!1,selectedIndex:n,onSelect:m,onClose:b})=>{const{completedCharacters:f,isLoading:h}=De(),g=a.useRef(null),C=a.useMemo(()=>{if(!o)return f;const c=o.toLowerCase();return f.filter(x=>x.username.toLowerCase().includes(c))},[f,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=x=>{g.current&&!g.current.contains(x.target)&&b()};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[t,b]);const D=a.useCallback(c=>{Ee.track("character_used_in_prompt",{characterId:c.id,username:c.username}),m(c)},[m]);if(!t)return null;const N={position:"fixed",top:l.top,left:l.left,transform:i?"none":"translateY(-100%)",zIndex:Te.DROPDOWN_PORTAL,maxHeight:"200px",overflowY:"auto"};return h?e.jsx("div",{ref:g,className:"character-mention-popup",style:N,children:e.jsx("div",{className:"character-mention-popup__empty",children:"加载中..."})}):C.length===0?e.jsx("div",{ref:g,className:"character-mention-popup",style:N,children:e.jsx("div",{className:"character-mention-popup__empty",children:o?`未找到 "${o}" 相关角色`:"暂无可用角色"})}):e.jsx("div",{ref:g,className:"character-mention-popup",style:N,children:C.map((c,x)=>e.jsxs("div",{className:`character-mention-popup__item ${x===n?"character-mention-popup__item--selected":""}`,onClick:()=>D(c),"data-track":"character_click_mention",children:[e.jsx("div",{className:"character-mention-popup__item-avatar",children:e.jsx(Fe,{characterId:c.id,profilePictureUrl:c.profilePictureUrl,alt:c.username})}),e.jsxs("span",{className:"character-mention-popup__item-name",children:["@",c.username]})]},c.id))})},kt={visible:!1,query:"",position:{top:0,left:0},showBelow:!1,startIndex:-1,selectedIndex:0};function Dt({enabled:t=!0,onPromptChange:o,prompt:l}){const[i,n]=a.useState(kt),m=a.useRef(null),{completedCharacters:b}=De(),f=a.useCallback(c=>{if(!m.current)return{top:0,left:0,showBelow:!1};const x=m.current,y=x.getBoundingClientRect(),w=document.createElement("div"),T=window.getComputedStyle(x),$=["fontFamily","fontSize","fontWeight","fontStyle","letterSpacing","lineHeight","textTransform","wordSpacing","whiteSpace","paddingTop","paddingRight","paddingBottom","paddingLeft","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","boxSizing"];w.style.position="absolute",w.style.top="0",w.style.left="-9999px",w.style.visibility="hidden",w.style.whiteSpace="pre-wrap",w.style.overflowWrap="break-word",w.style.overflow="hidden",w.style.width=`${x.clientWidth}px`,$.forEach(V=>{w.style[V]=T.getPropertyValue(V.replace(/([A-Z])/g,"-$1").toLowerCase())}),document.body.appendChild(w);let k=0,B=0;try{const V=x.value.substring(0,c),Z=document.createTextNode(V),I=document.createElement("span");I.textContent="",w.appendChild(Z),w.appendChild(I);const _=I.getBoundingClientRect(),P=w.getBoundingClientRect();k=_.top-P.top,B=_.left-P.left}finally{document.body.removeChild(w)}const u=x.scrollTop,L=parseInt(T.lineHeight)||20;let W=y.top+k-u,z=y.left+B;const H=240,K=window.innerWidth;z+H>K-16&&(z=K-H-16),z<16&&(z=16);const G=W<220+16;return G?W=W+L+4:W=W-48,{top:W,left:z,showBelow:G}},[]),h=a.useCallback((c,x)=>{if(!t)return;const y=c.substring(0,x),w=y.lastIndexOf("@");if(w===-1){n(B=>({...B,visible:!1}));return}const T=w>0?c[w-1]:" ";if(!/\s/.test(T)&&w!==0){n(B=>({...B,visible:!1}));return}const $=y.substring(w+1);if($.includes(" ")){n(B=>({...B,visible:!1}));return}const k=f(x);n({visible:!0,query:$,position:{top:k.top,left:k.left},showBelow:k.showBelow,startIndex:w,selectedIndex:0})},[t,f]),g=a.useCallback(c=>{var $;if(i.startIndex===-1)return;const x=l.substring(0,i.startIndex),y=(($=m.current)==null?void 0:$.selectionStart)||l.length,w=l.substring(y),T=`${x}@${c.username} ${w}`;o(T),n(k=>({...k,visible:!1})),setTimeout(()=>{if(m.current){const k=x.length+c.username.length+2;m.current.focus(),m.current.setSelectionRange(k,k)}},0)},[i.startIndex,l,o]),C=a.useCallback(c=>{if(!i.visible)return;const x=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,x.length-1)}));break;case"ArrowUp":c.preventDefault(),n(y=>({...y,selectedIndex:Math.max(y.selectedIndex-1,0)}));break;case"Enter":case"Tab":x.length>0&&(c.preventDefault(),g(x[i.selectedIndex]));break;case"Escape":c.preventDefault(),n(y=>({...y,visible:!1}));break}},[i,b,g]),D=a.useCallback((c,x)=>{o(c),h(c,x)},[o,h]),N=a.useCallback(()=>{n(c=>({...c,visible:!1}))},[]);return{mentionState:i,setMentionState:n,textareaRef:m,completedCharacters:b,handleTextChange:D,handleKeyDown:C,handleCharacterSelect:g,closeMentionPopup:N,calculateMentionPosition:f}}const zt=({prompt:t,onPromptChange:o,presetPrompts:l,language:i,type:n,disabled:m=!1,onError:b,enableMention:f=!0,videoProvider:h})=>{const[g,C]=a.useState(!1),D=a.useRef(null),N=a.useRef(null),[c,x]=a.useState(null),[y,w]=a.useState(0),T=a.useMemo(()=>ce.sortPrompts(n,l).map((_,P)=>({id:`preset-${P}-${_.slice(0,20)}`,content:_,pinned:ce.isPinned(n,_)})),[n,l,y]),$=f&&n==="video"&&h==="sora",{mentionState:k,textareaRef:B,handleTextChange:u,handleKeyDown:L,handleCharacterSelect:W,closeMentionPopup:z}=Dt({enabled:$,onPromptChange:o,prompt:t}),H=a.useCallback(()=>{if(N.current&&g){const I=N.current.getBoundingClientRect(),_=8,P=320,Q=400,ae=window.innerHeight-I.top+4,J=Math.min(P,window.innerWidth-_*2),te=window.innerWidth-I.right,re=window.innerWidth-J-_,se=Math.max(Math.min(te,re),_),oe=Math.min(Q,I.top-_,window.innerHeight*.45);x({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(D.current&&!D.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 K=a.useCallback(I=>{const _=typeof I=="string"?I:I.content;o(_),b==null||b(null),C(!1)},[o,b]),X=a.useCallback(I=>{const _=T.find(P=>P.id===I);_&&(_.pinned?ce.unpinPrompt(n,_.content):ce.pinPrompt(n,_.content),w(P=>P+1))},[n,T]),G=a.useCallback(I=>{const _=T.find(P=>P.id===I);_&&(ce.deletePrompt(n,_.content),w(P=>P+1))},[n,T]),V=a.useCallback(I=>{const _=I.target.value,P=I.target.selectionStart||0;u(_,P),b==null||b(null)},[u,b]);a.useEffect(()=>{n!=="video"&&z()},[n,z]);const Z=()=>{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:Te.DIALOG_POPOVER,"--panel-max-width":"calc(100vw - 16px)","--panel-max-height":`${c.maxHeight}px`},children:e.jsx(ze,{title:I,items:T,onSelect:K,onTogglePin:X,onDelete:G,language:i,disabled:m,showCount:!0})});return Be.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:D,children:[e.jsx("button",{ref:N,type:"button",className:"preset-icon-button",disabled:m,onClick:()=>C(!g),children:e.jsx($e,{size:16})}),Z()]})})]}),e.jsx("textarea",{ref:B,className:"form-textarea",value:t,onChange:V,onKeyDown:L,placeholder:_t(i,n,h),rows:4,disabled:m}),$&&e.jsx(jt,{visible:k.visible,query:k.query,position:k.position,showBelow:k.showBelow,selectedIndex:k.selectedIndex,onSelect:W,onClose:z})]})};function Tt(t){return t.map(o=>o.prompt.trim()).filter(o=>o.length>0).filter((o,l,i)=>i.indexOf(o)===l)}const Bt=(t,o,l)=>{const i=t==="image"?We(o):Ge(o),n=Tt(l);return[...[...t==="video"?Oe():He(),...n].filter((h,g,C)=>C.indexOf(h)===g).slice(0,Ue),...i].filter((h,g,C)=>C.indexOf(h)===g).slice(0,Ve)},Ot=(t,o,l)=>{!o||!o.trim()||(t==="video"?qe(o.trim()):Xe(o.trim()))},Ht=({images:t,onImagesChange:o,language:l="zh",disabled:i=!1,multiple:n=!0,maxCount:m=10,label:b,slotLabels:f,onError:h})=>{const[g,C]=a.useState(!1),[D,N]=a.useState(!1),[c,x]=a.useState(0),[y,w]=a.useState(null),T=a.useRef(null),$=a.useRef(null),{addAsset:k}=Qe(),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],L=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,A)=>{const E=new FileReader;E.onload=()=>{S({url:E.result,name:p,file:(d instanceof File,d)})},E.onerror=A,E.readAsDataURL(d)}),[]),z=a.useCallback(async(d,p)=>{const A=Array.from(d).filter(L);if(A.length===0)return;n&&t.length+A.length>m&&(U.warning(u.maxCountReached.replace("{count}",String(m))),A.splice(m-t.length));const E=[];for(const r of A)try{let s=r;if(r.size>10*1024*1024){const M=Ye(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 Ke(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(v){U.close(R),console.error("[ReferenceImageUpload] Compression failed:",v),h==null||h(l==="zh"?"图片压缩失败":"Image compression failed");continue}}E.push({blob:s,name:r.name})}catch(s){console.error("[ReferenceImageUpload] Error processing file:",s),h==null||h(u.loadFailed);continue}if(E.length!==0){E.forEach(({blob:r,name:s})=>{k(r,ye.IMAGE,Ze.LOCAL,s).catch(M=>{console.warn("[ReferenceImageUpload] Failed to add asset to library:",M)})});try{const r=await Promise.all(E.map(({blob:s,name:M})=>W(s,M)));if(f&&p!==void 0){const s=[...t];s[p]=r[0],o(s.filter(Boolean))}else o(n?[...t,...r]:r.slice(0,1));h==null||h(null)}catch(r){console.error("[ReferenceImageUpload] Failed to process files:",r),h==null||h(u.loadFailed)}}},[t,n,m,f,l,L,W,k,o,h,u]),H=a.useCallback(d=>{const p=d.target.files;p&&p.length>0&&z(p,f?c:void 0),d.target.value=""},[z,f,c]),K=a.useCallback(async d=>{try{const S=await(await fetch(d.url)).blob(),A=new FileReader;A.onload=()=>{const E={url:A.result,name:d.name};if(f){const r=[...t];r[c]=E,o(r.filter(Boolean))}else if(n){if(t.length>=m){U.warning(u.maxCountReached.replace("{count}",String(m)));return}o([...t,E])}else o([E]);C(!1),h==null||h(null)},A.readAsDataURL(S)}catch(p){console.error("[ReferenceImageUpload] Failed to convert asset to base64:",p),h==null||h(u.loadFailed),C(!1)}},[t,n,m,f,c,o,h,u]),X=a.useCallback(d=>{d.preventDefault(),d.stopPropagation(),i||N(!0)},[i]),G=a.useCallback(d=>{var S;d.preventDefault(),d.stopPropagation();const p=(S=T.current)==null?void 0:S.getBoundingClientRect();if(p){const{clientX:A,clientY:E}=d;(A<p.left||A>p.right||E<p.top||E>p.bottom)&&N(!1)}},[]),V=a.useCallback(d=>{d.preventDefault(),d.stopPropagation()},[]),Z=a.useCallback((d,p)=>{if(d.preventDefault(),d.stopPropagation(),N(!1),i)return;const S=d.dataTransfer.files;S&&S.length>0&&z(S,p)},[i,z]);a.useEffect(()=>{const d=async p=>{var M;if(i)return;const S=document.activeElement,A=T.current;if(!A||!(A.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 v=r[R];if(v.type.startsWith("image/")){const j=v.getAsFile();j&&s.push(j)}}s.length>0&&(p.preventDefault(),z(s))};return document.addEventListener("paste",d),()=>{document.removeEventListener("paste",d)}},[i,z]);const I=a.useCallback(d=>{const p=t.filter((S,A)=>A!==d);w(null),o(p)},[t,o]),_=a.useCallback(d=>{var p;d!==void 0&&x(d),(p=$.current)==null||p.click()},[]),P=a.useCallback(d=>{d!==void 0&&x(d),C(!0)},[]),Q=a.useCallback((d,p)=>{const S=p.currentTarget.getBoundingClientRect(),A=S.left+S.width/2,E=S.top-10;w({url:d,x:A,y:E})},[]),ae=a.useCallback(()=>{w(null)},[]),J=d=>e.jsx("div",{className:`reference-image-upload__placeholder ${D?"reference-image-upload__placeholder--dragging":""}`,onDragEnter:X,onDragLeave:G,onDragOver:V,onDrop:p=>Z(p,d),children:e.jsxs("div",{className:"reference-image-upload__buttons",children:[e.jsx(ne,{variant:"outline",icon:e.jsx(Ce,{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(_e,{size:16}),onClick:()=>P(d),disabled:i,"data-track":"reference_image_upload_library",className:"reference-image-upload__btn",children:u.library})]})}),te=(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(st,{size:14})}),f&&f[p]&&e.jsx("div",{className:"reference-image-upload__slot-label",children:f[p]})]},p),re=()=>f?e.jsx("div",{className:"reference-image-upload__slots",children:f.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?te(S,p):e.jsx("div",{className:`reference-image-upload__slot-placeholder ${D?"reference-image-upload__slot-placeholder--dragging":""}`,onDragEnter:X,onDragLeave:G,onDragOver:V,onDrop:A=>Z(A,p),children:e.jsxs("div",{className:"reference-image-upload__slot-buttons",children:[e.jsx(ne,{variant:"outline",icon:e.jsx(Ce,{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(_e,{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)=>te(p,S)),d&&J(),t.length===0&&!d&&J()]})},oe=()=>t.length>0?e.jsxs("div",{className:"reference-image-upload__single",children:[te(t[0],0),e.jsx("div",{className:"reference-image-upload__replace",children:J()})]}):J();return e.jsxs(e.Fragment,{children:[y&&Je.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:T,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:$,type:"file",accept:"image/*",multiple:n&&!f,onChange:H,className:"reference-image-upload__input",disabled:i}),f?re():n?se():oe(),e.jsx(et,{isOpen:g,onClose:()=>C(!1),mode:tt.SELECT,filterType:ye.IMAGE,onSelect:K})]})]})},Ne="aitu-dialog-task-list-width-",pe=240,fe=800,Nt=()=>{const t=Math.round(660);return Math.max(pe,Math.min(fe,t))},Ut=t=>{try{const o=localStorage.getItem(Ne+t);if(o){const l=parseInt(o,10);if(!isNaN(l)&&l>=pe&&l<=fe)return l}}catch{}return Nt()},ke=(t,o)=>{try{localStorage.setItem(Ne+t,o.toString())}catch{}},Wt=({isRightPanelVisible:t,onToggleRightPanel:o,onWidthChange:l,rightPanelWidth:i,minWidth:n=pe,maxWidth:m=fe,onResizeStart:b,onResizeEnd:f,language:h="zh",disabled:g=!1,storageKey:C="image"})=>{const[D,N]=a.useState(!1),c=a.useRef(0),x=a.useRef(0);a.useEffect(()=>(D?(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=""}),[D]);const y=a.useCallback(T=>{if(g||!t)return;T.preventDefault(),T.stopPropagation(),N(!0),c.current=T.clientX,x.current=i,b==null||b();const $=B=>{const u=c.current-B.clientX,L=Math.max(n,Math.min(m,x.current+u));l(L)},k=()=>{N(!1),f==null||f(),x.current+(c.current-document.body.getBoundingClientRect().left),ke(C,i),document.removeEventListener("mousemove",$),document.removeEventListener("mouseup",k)};document.addEventListener("mousemove",$),document.addEventListener("mouseup",k)},[g,t,i,n,m,l,b,f,C]);a.useEffect(()=>{!D&&t&&ke(C,i)},[i,D,t,C]);const w=t?h==="zh"?"隐藏任务列表":"Hide Task List":h==="zh"?"显示任务列表":"Show Task List";return e.jsxs("div",{className:`resizable-divider ${D?"is-dragging":""} ${t?"":"is-collapsed"} ${g?"is-disabled":""}`,onMouseDown:y,children:[e.jsx("div",{className:"resizable-divider__bar"}),e.jsx(de,{content:w,theme:"light",placement:"left",children:e.jsx("button",{type:"button",className:"resizable-divider__toggle",onClick:T=>{T.stopPropagation(),o()},"aria-label":w,children:t?e.jsx(nt,{size:"14px"}):e.jsx(at,{size:"14px"})})})]})},Gt=({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(rt,{checked:l,onChange:n,className:"auto-insert-checkbox"})})};function Vt(t){try{return localStorage.getItem(t)!=="false"}catch{return!0}}function Lt(t={}){const{taskType:o}=t,{tasks:l,isLoading:i}=ot(),{retryTask:n,deleteTask:m}=it(),b=a.useMemo(()=>[...o?l.filter(C=>C.type===o):l].sort((C,D)=>D.createdAt-C.createdAt),[l,o]),f=a.useCallback(async()=>{},[]),h=a.useCallback(async()=>{if(lt(),!await Ie.isAvailable())return;const C=await Ie.getAllTasks();C.length>0&&ct.restoreTasks(C)},[]);return{tasks:b,isLoading:i,isLoadingMore:!1,hasMore:!1,totalCount:b.length,loadedCount:b.length,loadMore:f,refresh:h,retryTask:n,deleteTask:m}}const qt=({taskIds:t,taskType:o,onEditTask:l})=>{const{tasks:i,isLoading:n,isLoadingMore:m,hasMore:b,totalCount:f,loadedCount:h,loadMore:g,retryTask:C,deleteTask:D}=Lt({taskType:o}),{board:N,openDialog:c}=dt(),[x,y]=a.useState(!1),[w,T]=a.useState(null),[$,k]=a.useState(!1),[B,u]=a.useState(0),[L,W]=a.useState(""),[z,H]=a.useState(null),[K,X]=a.useState(!1),G=a.useMemo(()=>i.filter(r=>r.status===ee.FAILED).length,[i]),V=a.useCallback(()=>{const r=i.filter(s=>s.status===ee.FAILED);r.forEach(s=>D(s.id)),X(!1),U.success(`已清除 ${r.length} 个失败任务`)},[i,D]),Z=(r,s)=>{var O,q,ue,ie,le,he,ge,ve,xe,we,be;if(!s.trim())return!0;const M=s.toLowerCase().split(/\s+/).filter(Boolean),R={[ee.PENDING]:"处理中",[ee.PROCESSING]:"处理中",[ee.COMPLETED]:"已完成",[ee.FAILED]:"失败",[ee.CANCELLED]:"已取消"},v=[],j=(O=r.params)!=null&&O.params&&typeof r.params.params=="object"?r.params.params:null;v.push(((q=r.params)==null?void 0:q.prompt)??""),v.push(((ue=r.params)==null?void 0:ue.model)??""),v.push(r.id??""),v.push(R[r.status]??String(r.status)),(ie=r.params)!=null&&ie.batchId&&v.push(String(r.params.batchId)),(le=r.params)!=null&&le.batchIndex&&v.push(String(r.params.batchIndex)),(he=r.params)!=null&&he.batchTotal&&v.push(String(r.params.batchTotal)),typeof(j==null?void 0:j.model_name)=="string"&&v.push(j.model_name),typeof(j==null?void 0:j.mode)=="string"&&v.push(j.mode),typeof(j==null?void 0:j.klingAction2)=="string"&&v.push(j.klingAction2),(ge=r.result)!=null&&ge.format&&v.push(String(r.result.format)),(ve=r.result)!=null&&ve.width&&((xe=r.result)!=null&&xe.height)?v.push(`${r.result.width}x${r.result.height}`):(we=r.params)!=null&&we.width&&((be=r.params)!=null&&be.height)&&v.push(`${r.params.width}x${r.params.height}`);const F=v.join(" ").toLowerCase();return M.every(Le=>F.includes(Le))},I=a.useMemo(()=>{let r=i;return t&&t.length>0&&(r=r.filter(s=>t.includes(s.id))),L.trim()&&(r=r.filter(s=>Z(s,L))),r.sort((s,M)=>M.createdAt-s.createdAt)},[i,t,L]),_=r=>{C(r)},P=r=>{T(r),y(!0)},Q=()=>{w&&D(w),y(!1),T(null)},ae=async r=>{var R,v,j,F;const s=i.find(O=>O.id===r);if(!((R=s==null?void 0:s.result)!=null&&R.url)&&!((j=(v=s==null?void 0:s.result)==null?void 0:v.urls)!=null&&j.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 q=M[O],ue=`${wt(s.params.prompt)||s.type}${M.length>1?`-${O+1}`:""}.${s.result.format}`,ie=await bt.getCachedBlob(q);if(ie){yt(ie,ue);continue}const le=await Ct(q,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("下载失败,请稍后重试")}},J=async r=>{var M,R,v,j;const s=i.find(F=>F.id===r);if(!((M=s==null?void 0:s.result)!=null&&M.url)&&!((v=(R=s==null?void 0:s.result)==null?void 0:R.urls)!=null&&v.length)||!N){console.warn("Cannot insert: task result or board not available"),U.warning("无法插入:白板未就绪");return}try{if(s.type===Y.IMAGE){const F=(j=s.result.urls)!=null&&j.length?s.result.urls:[s.result.url];for(const O of F)await vt(N,O);U.success(F.length>1?"多图已插入到白板":"图片已插入到白板")}else s.type===Y.VIDEO&&(await xt(N,s.result.url),U.success("视频已插入到白板"))}catch(F){console.error("Failed to insert to board:",F),U.error(`插入失败: ${F instanceof Error?F.message:"未知错误"}`)}},te=r=>{var M,R,v,j;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===Y.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(Me.aiImageGeneration,F)}else if(s.type===Y.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:(v=s.result)==null?void 0:v.url,initialResultUrls:(j=s.result)==null?void 0:j.urls};c(Me.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,v;return s.status!==ee.COMPLETED||!((M=s.result)!=null&&M.url)&&!((v=(R=s.result)==null?void 0:R.urls)!=null&&v.length)||s.type!==Y.IMAGE&&s.type!==Y.VIDEO||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 v of se){const j=(M=v.result.urls)!=null&&M.length?v.result.urls:[v.result.url],F=v.type===Y.VIDEO?"video":"image",O=(R=v.params.prompt)==null?void 0:R.substring(0,50);s.set(v.id,r.length);for(let q=0;q<j.length;q++)r.push({id:j.length>1?`${v.id}-${q}`:v.id,url:j[q],type:F,title:j.length>1?`${O} (${q+1}/${j.length})`:O})}return{previewMediaItems:r,taskIdToPreviewIndex:s}},[se]),p=a.useCallback(r=>{const s=d.get(r);s!==void 0&&(u(s),k(!0))},[d]),S=a.useCallback(()=>{k(!1)},[]),A=L.trim()&&I.length===0&&i.length>0,E=f>0?f: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:["生成任务 (",E,")"]}),e.jsx("div",{className:"dialog-task-list__header-actions",children:G>0&&e.jsx(de,{content:`清除全部失败任务 (${G})`,theme:"light",children:e.jsx(ne,{size:"small",variant:"text",icon:e.jsx(ut,{}),onClick:()=>X(!0)})})})]}),e.jsx("div",{className:"dialog-task-list__search",children:e.jsx(mt,{value:L,onChange:r=>W(r),placeholder:"搜索任务(提示词/模型/...)",clearable:!0,prefixIcon:e.jsx(pt,{}),size:"small"})})]}),e.jsx(ft,{tasks:I,onRetry:_,onDelete:P,onDownload:ae,onInsert:J,onEdit:te,onPreviewOpen:p,onExtractCharacter:re,hasMore:b,isLoadingMore:m,onLoadMore:g,totalCount:E,loadedCount:h,className:"dialog-task-list__content",emptyContent:e.jsx("div",{className:"dialog-task-list__empty",children:n?e.jsx("p",{children:"加载中..."}):A?e.jsx("p",{children:"未找到匹配的任务"}):e.jsx("p",{children:"暂无生成任务"})})})]}),e.jsx(Se,{visible:x,header:"确认删除",onClose:()=>y(!1),onConfirm:Q,onCancel:()=>y(!1),children:"确定要删除此任务吗?此操作无法撤销。"}),e.jsxs(Se,{visible:K,header:"清除失败任务",onClose:()=>X(!1),onConfirm:V,onCancel:()=>X(!1),children:["确定要清除全部 ",G," 个失败任务吗?此操作无法撤销。"]}),e.jsx(ht,{visible:$,items:oe,initialIndex:B,onClose:S,showThumbnails:!0}),e.jsx(gt,{visible:!!z,task:z,onClose:()=>H(null),onCreateComplete:r=>{H(null)}})]})};export{Ft as A,jt as C,qt as D,$t as E,zt as P,Ht as R,Et as a,Rt as b,Gt as c,Wt as d,Vt as e,Dt as f,Bt as g,Ut as l,Ot as s,At as u};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-CvvgEQLL.js","./index-Bf4QGnyR.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{bS as H,r as t,aQ as e,e7 as Ft,b$ as ae,bV as de,ep as Bt,fN as Me,fO as it,fP as ue,b_ as xe,cd as ke,fQ as _e,fR as ze,fS as Kt,fT as se,bl as ct,fU as Ze,cT as C,fV as Ot,fW as Vt,fX as $e,bm as Ee,fY as Ht,fZ as Le,e8 as be,bW as lt,bg as he,eY as Xt,cO as Yt,f_ as qt,bc as A,f$ as dt,g0 as ut,d1 as Zt,aW as Qe,bo as Re,g1 as Qt,g2 as Gt,b0 as Jt,em as ht,cI as Ge,g3 as es,cF as Ce,g4 as ts,be as ss}from"./index-CvvgEQLL.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 ns=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Je=H("arrow-down",ns);/**
|
|
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 as=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],et=H("arrow-up",as);/**
|
|
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 os=[["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"}]],rs=H("book-open",os);/**
|
|
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 is=[["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"}]],cs=H("bot",is);/**
|
|
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 ls=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],ds=H("circle-stop",ls);/**
|
|
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 us=[["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=H("external-link",us);/**
|
|
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 hs=[["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=H("file-text",hs);/**
|
|
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 ms=[["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"}]],ps=H("folder-open",ms);/**
|
|
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 fs=[["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"}]],xs=H("folder-plus",fs);/**
|
|
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 ks=[["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"}]],_s=H("folder",ks);/**
|
|
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 bs=[["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"}]],gs=H("funnel",bs);/**
|
|
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 ws=[["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=H("link-2",ws);/**
|
|
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 js=[["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=H("lock",js);/**
|
|
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 ys=[["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"}]],vs=H("notebook-pen",ys);/**
|
|
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 Ns=[["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"}]],Ss=H("panel-right-close",Ns);/**
|
|
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 Cs=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]],Ms=H("panel-right",Cs);/**
|
|
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 zs=[["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"}]],Es=H("tags",zs);/**
|
|
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 Rs=[["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=H("upload",Rs),ne="__system_skill__";function Ds(s){const n=new Date(s),i=new Date;return n.getFullYear()===i.getFullYear()&&n.getMonth()===i.getMonth()&&n.getDate()===i.getDate()?n.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"}):n.getFullYear()===i.getFullYear()?n.toLocaleDateString("zh-CN",{month:"2-digit",day:"2-digit"}):n.toLocaleDateString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit"})}const Ts=({directories:s,notesByDir:n,noteTagsMap:i,noteCounts:l,selectedDirId:x,selectedNoteId:m,expandedDirIds:h,isCreatingDir:d,skillDirName:w="Skill",onSelectDir:M,onToggleExpand:N,onCreateDir:g,onCancelCreateDir:v,onRenameDir:j,onDeleteDir:b,onSelectNote:z,onCreateNote:p,onDeleteNote:k,onDuplicateDir:D,onDuplicateNote:U,onInsertNoteToCanvas:E})=>{const[L,S]=t.useState(""),[W,K]=t.useState(null),[X,q]=t.useState(""),[V,r]=t.useState(null);t.useEffect(()=>{const f=()=>r(null),R=()=>r(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,Y,oe=!1)=>{f.preventDefault(),f.stopPropagation(),r({x:f.clientX,y:f.clientY,type:R,id:Y,isDefault:oe})},[]),I=t.useCallback(async()=>{const f=L.trim();if(f)try{await g(f),S(""),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=>S(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($s,{dir:f,isSelected:x===f.id,isExpanded:h.has(f.id),notes:n[f.id]||[],noteCount:l[f.id]||0,noteTagsMap:i,selectedNoteId:m,isRenaming:W===f.id,renameValue:X,onSelectDir:()=>{M(f.id),h.has(f.id)||N(f.id)},onToggleExpand:()=>{N(f.id),r(null)},onStartRename:()=>{K(f.id),q(f.name),r(null)},onRenameChange:q,onRenameConfirm:()=>B(f.id),onRenameCancel:()=>K(null),onDeleteDir:()=>{b(f.id),r(null)},onCreateNote:()=>{p(f.id),r(null)},onSelectNote:z,onDeleteNote:R=>{k(R),r(null)},onContextMenu:R=>F(R,"directory",f.id,f.isDefault),onNoteContextMenu:(R,Y)=>F(R,"note",Y),isSkillDir:f.name===w},f.id))}),V&&Ft.createPortal(e.jsx("div",{className:"kb-context-menu",style:{top:V.y,left:V.x,zIndex:Bt.DROPDOWN_PORTAL},onClick:f=>f.stopPropagation(),children:V.type==="directory"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"kb-context-menu__item",onClick:()=>{D(V.id),r(null)},children:[e.jsx(Me,{size:14}),e.jsx("span",{children:"复制目录"})]}),e.jsxs("div",{className:"kb-context-menu__item",onClick:()=>{var f;K(V.id),q(((f=s.find(R=>R.id===V.id))==null?void 0:f.name)||""),r(null)},children:[e.jsx(it,{size:14}),e.jsx("span",{children:"重命名"})]}),e.jsxs("div",{className:"kb-context-menu__item kb-context-menu__item--danger",onClick:()=>{b(V.id),r(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(V.id),r(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(Y=>Y.id===V.id);R&&E(R),r(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:()=>{k(V.id),r(null)},children:[e.jsx(ue,{size:14}),e.jsx("span",{children:"删除"})]})]})}),document.body)]})},$s=({dir:s,isSelected:n,isExpanded:i,notes:l,noteCount:x,noteTagsMap:m,selectedNoteId:h,isRenaming:d,renameValue:w,isSkillDir:M=!1,onSelectDir:N,onToggleExpand:g,onStartRename:v,onRenameChange:j,onRenameConfirm:b,onRenameCancel:z,onDeleteDir:p,onCreateNote:k,onSelectNote:D,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:S=>{S.stopPropagation(),g()},children:i?e.jsx(xe,{size:14}):e.jsx(ke,{size:14})}),i?e.jsx(ps,{size:16}):e.jsx(_s,{size:16}),d?e.jsx("input",{className:"kb-tree__input kb-tree__input--inline",value:w,onChange:S=>j(S.target.value),onKeyDown:S=>{S.key==="Enter"&&b(),S.key==="Escape"&&z()},onClick:S=>S.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:S=>{S.stopPropagation(),k()},title:"新建笔记",children:e.jsx(_e,{size:12})}),e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"kb-tree__icon-btn",onClick:S=>{S.stopPropagation(),v()},title:"重命名",children:e.jsx(it,{size:12})}),e.jsx("button",{className:"kb-tree__icon-btn kb-tree__icon-btn--danger",onClick:S=>{S.stopPropagation(),p()},title:"删除",children:e.jsx(ue,{size:12})})]})]})]}),i&&e.jsxs("div",{className:"kb-tree__notes",children:[M&&ze.map(S=>{const W=`${ne}${S.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:()=>D(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:[S.name,e.jsx("span",{className:"kb-tree__system-badge",children:"系统"})]})})]},W)}),M&&Kt().map(S=>{const W=`${se}${S.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:()=>D(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:[S.name,e.jsx("span",{className:"kb-tree__system-badge",children:"系统"})]})})]},W)}),l.length===0&&!M&&e.jsx("div",{className:"kb-tree__notes-empty",children:"暂无笔记"}),l.length===0&&M&&ze.length===0&&e.jsx("div",{className:"kb-tree__notes-empty",children:"暂无笔记"}),Array.from(new Map(l.map(S=>[S.id,S])).values()).map(S=>{const W=h===S.id,K=m[S.id]||[],X=S.metadata;return e.jsx(Ls,{note:S,isSelected:W,tags:K,metadata:X,onSelect:()=>D(S.id),onDelete:()=>U(S.id),onContextMenu:q=>L(q,S.id)},S.id)})]})]}),Ls=({note:s,isSelected:n,tags:i,metadata:l,onSelect:x,onDelete:m,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:[i.length>0&&e.jsxs("div",{className:"kb-tree__note-tags",children:[i.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)),i.length>2&&e.jsxs("span",{className:"kb-tree__tag-more",children:["+",i.length-2]})]}),i.length===0&&!(l!=null&&l.domain)&&e.jsx("span",{className:"kb-tree__note-time",children:Ds(s.updatedAt)})]})]}),e.jsx("button",{className:"kb-tree__note-delete",onClick:d=>{d.stopPropagation(),m()},title:"删除笔记",children:e.jsx(ue,{size:12})})]}),st=({allTags:s,selectedTagIds:n,onSelectedChange:i,onCreateTag:l,showCount:x=!1})=>{const[m,h]=t.useState(!1),[d,w]=t.useState(""),[M,N]=t.useState(!1),g=t.useRef(null);t.useEffect(()=>{if(!m)return;const p=k=>{g.current&&!g.current.contains(k.target)&&(h(!1),N(!1),w(""))};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[m]);const v=t.useCallback(p=>{const k=n.includes(p)?n.filter(D=>D!==p):[...n,p];i(k)},[n,i]),j=t.useCallback((p,k)=>{k.stopPropagation(),i(n.filter(D=>D!==p))},[n,i]),b=t.useCallback(async()=>{const p=d.trim();if(p)try{const k=await l(p);i([...n,k.id]),w(""),N(!1)}catch{}},[d,l,n,i]),z=s.filter(p=>n.includes(p.id));return e.jsxs("div",{className:"kb-tag-selector",ref:g,children:[e.jsxs("div",{className:"kb-tag-selector__selected",children:[z.map(p=>e.jsxs("span",{className:"kb-tag-selector__tag kb-tag-selector__tag--selected",style:{"--tag-color":p.color,borderColor:p.color,backgroundColor:`${p.color}15`},children:[e.jsx("span",{className:"kb-tag-selector__dot",style:{backgroundColor:p.color}}),e.jsx("span",{children:p.name}),e.jsx("button",{className:"kb-tag-selector__remove",onClick:k=>j(p.id,k),title:"移除标签",children:e.jsx(de,{size:11})})]},p.id)),e.jsxs("button",{className:"kb-tag-selector__add-btn",onClick:()=>h(p=>!p),children:[e.jsx(_e,{size:13}),e.jsx("span",{children:"标签"})]})]}),m&&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(p=>{const k=n.includes(p.id);return e.jsxs("button",{className:`kb-tag-selector__tag ${k?"kb-tag-selector__tag--selected":""}`,style:{"--tag-color":p.color,borderColor:k?p.color:void 0,backgroundColor:k?`${p.color}15`:void 0},onClick:()=>v(p.id),children:[e.jsx("span",{className:"kb-tag-selector__dot",style:{backgroundColor:p.color}}),e.jsx("span",{children:p.name}),x&&e.jsxs("span",{className:"kb-tag-selector__count",children:["(",p.count,")"]}),k&&e.jsx(de,{size:12})]},p.id)})]}),M?e.jsxs("div",{className:"kb-tag-selector__create",children:[e.jsx("input",{className:"kb-tag-selector__input",value:d,onChange:p=>w(p.target.value),onKeyDown:p=>{p.key==="Enter"&&b(),p.key==="Escape"&&(N(!1),w(""))},placeholder:"标签名称",autoFocus:!0}),e.jsx("button",{className:"kb-tag-selector__create-btn",onClick:b,children:"确定"})]}):e.jsxs("button",{className:"kb-tag-selector__new-btn",onClick:()=>N(!0),children:[e.jsx(_e,{size:13}),e.jsx("span",{children:"新建标签"})]})]})]})},Ps=({outputType:s,onOutputTypeChange:n,readOnly:i=!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:i?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 As(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,`
|
|
93
|
+
|
|
94
|
+
`).trim()}function Is(){const[s,n]=t.useState({isSpeaking:!1,isPaused:!1,isSupported:typeof window<"u"&&"speechSynthesis"in window}),i=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=As(d);if(!w)return;const M=new SpeechSynthesisUtterance(w);M.lang="zh-CN",M.rate=1,M.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&&(M.voice=g),M.onend=()=>{n(v=>({...v,isSpeaking:!1,isPaused:!1})),i.current=null},M.onerror=()=>{n(v=>({...v,isSpeaking:!1,isPaused:!1})),i.current=null},i.current=M,window.speechSynthesis.speak(M),n(v=>({...v,isSpeaking:!0,isPaused:!1}))},[s.isSupported]),x=t.useCallback(()=>{s.isSupported&&(window.speechSynthesis.pause(),n(d=>({...d,isPaused:!0})))},[s.isSupported]),m=t.useCallback(()=>{s.isSupported&&(window.speechSynthesis.resume(),n(d=>({...d,isPaused:!1})))},[s.isSupported]),h=t.useCallback(()=>{s.isSupported&&(window.speechSynthesis.cancel(),i.current=null,n(d=>({...d,isSpeaking:!1,isPaused:!1})))},[s.isSupported]);return{...s,speak:l,pause:x,resume:m,stop:h}}const Us=({note:s,allTags:n,noteTags:i,readOnly:l=!1,isSkillDirectory:x=!1,onUpdateNote:m,onSetNoteTags:h,onCreateTag:d})=>{const[w,M]=t.useState(""),[N,g]=t.useState(!1),[v,j]=t.useState(null),b=t.useRef(null),z=t.useRef(null),p=t.useRef(null),k=t.useRef(null),{isSpeaking:D,isPaused:U,isSupported:E,speak:L,pause:S,resume:W,stop:K}=Is(),X=t.useMemo(()=>i.map($=>$.id),[i]),[q,V]=t.useState(void 0);t.useEffect(()=>{var $;V(s&&x&&(($=s.metadata)==null?void 0:$.outputType)||void 0)},[s==null?void 0:s.id,x]);const r=s==null?void 0:s.metadata,F=r&&(r.sourceUrl||r.author||r.domain);t.useEffect(()=>{if(s)if(M(s.title),k.current=s.id,x&&!l){const $=s.content||"";j($.trim()?Ze.isDSLContent($):null)}else j(null);else M(""),k.current=null,j(null);K()},[s==null?void 0:s.id,K,x,l]);const I=t.useCallback($=>{M($),s&&(z.current&&clearTimeout(z.current),z.current=setTimeout(()=>{m(s.id,{title:$})},500))},[s,m]),B=t.useCallback($=>{s&&(z.current&&clearTimeout(z.current),z.current=setTimeout(()=>{m(s.id,{content:$})},500),x&&!l&&(b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{$.trim()?j(Ze.isDSLContent($)):j(null)},500)))},[s,m,x,l]),f=t.useCallback($=>{if(!s)return;V($);const J={...s.metadata,outputType:$};$||delete J.outputType,C.updateNote(s.id,{metadata:J})},[s]),R=t.useCallback($=>{s&&h(s.id,$)},[s,h]),Y=t.useCallback(()=>{s&&(D?U?W():S():L(s.content))},[s,D,U,L,S,W]),oe=t.useCallback(async()=>{if(!s)return;const $=await C.exportNoteAsMarkdown(s.id);if(!$)return;const J=new Blob([$.content],{type:"text/markdown;charset=utf-8"}),re=URL.createObjectURL(J),Q=document.createElement("a");Q.href=re,Q.download=$.filename,document.body.appendChild(Q),Q.click(),document.body.removeChild(Q),URL.revokeObjectURL(re)},[s]);return t.useEffect(()=>()=>{z.current&&clearTimeout(z.current),b.current&&clearTimeout(b.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 ${D?"kb-note-editor__action-btn--active":""}`,onClick:Y,title:D?U?"继续朗读":"暂停朗读":"语音朗读",children:D&&!U?e.jsx(Ot,{size:14}):e.jsx(Vt,{size:14})}),D&&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:[r.author&&e.jsxs("span",{className:"kb-note-editor__metadata-collapsed-item",children:[e.jsx(Ee,{size:10}),e.jsx("span",{children:r.author})]}),r.sourceUrl&&e.jsxs("a",{href:r.sourceUrl,target:"_blank",rel:"noopener noreferrer",className:"kb-note-editor__metadata-collapsed-link",onClick:$=>$.stopPropagation(),title:r.sourceUrl,children:[e.jsx(De,{size:10}),e.jsx("span",{children:r.domain||r.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:[r.domain&&e.jsxs("span",{className:"kb-note-editor__metadata-item",children:[r.faviconUrl?e.jsx("img",{src:r.faviconUrl,alt:"",className:"kb-note-editor__favicon",onError:$=>{$.currentTarget.style.display="none"}}):e.jsx(ct,{size:12}),e.jsx("span",{children:r.domain})]}),r.author&&e.jsxs("span",{className:"kb-note-editor__metadata-item",children:[e.jsx(Ee,{size:12}),e.jsx("span",{children:r.author})]}),r.publishedAt&&e.jsxs("span",{className:"kb-note-editor__metadata-item",children:[e.jsx(Ht,{size:12}),e.jsx("span",{children:r.publishedAt})]})]}),r.sourceUrl&&e.jsx("a",{href:r.sourceUrl,target:"_blank",rel:"noopener noreferrer",className:"kb-note-editor__source-link",children:r.sourceUrl}),r.description&&e.jsx("p",{className:"kb-note-editor__metadata-desc",children:r.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(Ps,{outputType:q,onOutputTypeChange:f,readOnly:l})}),e.jsx("div",{className:"kb-note-editor__content",children:e.jsx(Le,{ref:p,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(rs,{size:64,strokeWidth:1})}),e.jsx("h3",{className:"kb-note-editor__placeholder-title",children:"无笔记选中"}),e.jsx("p",{className:"kb-note-editor__placeholder-text",children:"选择左侧的一篇笔记开始编辑,或者创建一个新笔记"})]})})},Ws=({allTags:s,selectedTagIds:n,onSelectedChange:i})=>{const[l,x]=t.useState(""),[m,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];i(v)},M=()=>{i([]),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:M,className:"kb-filter-dropdown__clear-btn",children:[e.jsx(de,{size:14,style:{marginRight:4}}),"清除标签过滤"]})})]});return e.jsx(Xt,{content:N,visible:m,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(gs,{size:14,style:{marginRight:4}}),"标签",n.length>0&&` (${n.length})`]})})},Fs=({visible:s,onClose:n,allTags:i,onCreateTag:l,onUpdateTag:x,onDeleteTag:m,onSelectTag:h})=>{const[d,w]=t.useState(!1),[M,N]=t.useState(""),[g,v]=t.useState(null),[j,b]=t.useState(""),z=t.useRef(null);t.useEffect(()=>{d&&z.current&&setTimeout(()=>{var E;(E=z.current)==null||E.focus()},100)},[d]);const p=async()=>{if(!M.trim()){w(!1);return}try{await l(M.trim()),N(""),w(!1),A.success("标签创建成功")}catch{A.error("标签创建失败")}},k=async E=>{if(!j.trim()){v(null);return}try{await x(E,j.trim()),v(null),A.success("标签更新成功")}catch{A.error("标签更新失败")}},D=async(E,L)=>{E.stopPropagation();try{await m(L),A.success("标签删除成功")}catch{A.error("标签删除失败")}},U=(E,L)=>{E.stopPropagation(),v(L.id),b(L.name)};return e.jsx(Yt,{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:z,value:M,onChange:E=>N(E),onEnter:p,onBlur:p,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:"新建标签"})]}),i.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=>b(L),onEnter:()=>k(E.id),size:"small",autofocus:!0}),e.jsx(he,{shape:"circle",variant:"text",size:"small",onClick:()=>k(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(qt,{size:12})}),e.jsx("button",{className:"kb-tag-item__action-btn kb-tag-item__action-btn--delete",onClick:L=>D(L,E.id),title:"删除",children:e.jsx(ue,{size:12})})]})]})},E.id))]})})},nt=10,Bs=({currentNoteId:s,allNotes:n,noteTagsMap:i,onSelectNote:l})=>{const[x,m]=t.useState([]),[h,d]=t.useState(!1),[w,M]=t.useState(!1);t.useEffect(()=>{let b=!1;return(async()=>{try{const p=await dt().getRelatedNotes(s,nt);b||m(p)}catch{b||m([])}})(),()=>{b=!0}},[s]);const N=t.useMemo(()=>n.find(b=>b.id===s),[n,s]),g=t.useMemo(()=>{var z;const b=(z=N==null?void 0:N.metadata)==null?void 0:z.sourceUrl;return b?n.filter(p=>{var k;return p.id!==s&&((k=p==null?void 0:p.metadata)==null?void 0:k.sourceUrl)===b}):[]},[n,s,N]),v=t.useMemo(()=>new Set(g.map(b=>b.id)),[g]),j=t.useMemo(()=>{if(x.length>0){const k=new Set;return x.filter(D=>v.has(D.id)||k.has(D.id)?!1:(k.add(D.id),!0))}const b=i[s]||[],z=new Set(b.map(k=>k.id));if(!N)return[];const p=[];for(const k of n){if(k.id===s||v.has(k.id))continue;const U=(i[k.id]||[]).map(X=>X.id),E=U.filter(X=>z.has(X)).length,L=new Set([...z,...U]).size,S=L>0?E/L:0,W=Ks(N.title,k.title),K=S*.7+W*.3;K>.05&&p.push({id:k.id,title:k.title||"无标题",score:K})}return p.sort((k,D)=>D.score-k.score).slice(0,nt)},[x,v,n,s,i,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(b=>e.jsxs("div",{className:"kb-related-notes__item",onClick:()=>l(b.id),children:[e.jsx(fe,{size:12,className:"kb-related-notes__icon"}),e.jsx("span",{className:"kb-related-notes__name",children:b.title||"无标题"}),e.jsx("button",{className:"kb-related-notes__goto-btn",onClick:z=>{z.stopPropagation(),l(b.id)},title:"跳转",children:e.jsx(De,{size:10})})]},`related-${b.id}`))})]}),j.length>0&&e.jsxs("div",{className:"kb-related-notes__section",children:[e.jsxs("button",{className:"kb-related-notes__section-header",onClick:()=>M(!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(b=>{const z="score"in b?b.score:void 0;return e.jsxs("div",{className:"kb-related-notes__item",onClick:()=>l(b.id),children:[e.jsx(fe,{size:12,className:"kb-related-notes__icon"}),e.jsx("span",{className:"kb-related-notes__name",children:b.title}),z!==void 0&&e.jsxs("span",{className:"kb-related-notes__similarity",children:[Math.round(z*100),"%"]}),e.jsx("button",{className:"kb-related-notes__goto-btn",onClick:p=>{p.stopPropagation(),l(b.id)},title:"跳转",children:e.jsx(De,{size:10})})]},`similar-${b.id}`)})})]})]})};function Ks(s,n){if(!s||!n)return 0;const i=s.toLowerCase(),l=n.toLowerCase(),x=new Set;for(let w=0;w<i.length-1;w++)x.add(i.substring(w,w+2));const m=new Set;for(let w=0;w<l.length-1;w++)m.add(l.substring(w,w+2));let h=0;for(const w of x)m.has(w)&&h++;const d=x.size+m.size;return d===0?0:2*h/d}const Os=`你是一个专业的知识提取助手,擅长从文本中识别和提取关键知识点。你的任务是分析给定的文本内容,提取出有价值的知识点,并以结构化的 Markdown 格式返回。
|
|
95
|
+
|
|
96
|
+
提取规则:
|
|
97
|
+
1. **核心概念**: 文中出现的重要概念、术语及其解释
|
|
98
|
+
2. **重要定义**: 明确的定义性内容,如"XX是指..."、"XX定义为..."
|
|
99
|
+
3. **关键步骤**: 操作流程、方法步骤、实施要点
|
|
100
|
+
4. **要点总结**: 核心观点、结论、重要发现
|
|
101
|
+
|
|
102
|
+
提取要求:
|
|
103
|
+
- 每个知识点必须有清晰的标题和详细的内容描述
|
|
104
|
+
- 确保提取的知识点具有独立性和完整性
|
|
105
|
+
- 避免重复提取相同的知识点
|
|
106
|
+
- 知识点数量控制在 3-10 个之间
|
|
107
|
+
- 内容要精炼、易于理解
|
|
108
|
+
|
|
109
|
+
输出格式要求:
|
|
110
|
+
- 必须返回 Markdown 格式
|
|
111
|
+
- 每个知识点使用二级标题(##)
|
|
112
|
+
- 内容使用正常段落或列表`;function Vs(s,n){return`请分析以下文本内容,提取关键知识点并以 Markdown 格式返回:
|
|
113
|
+
${n?`
|
|
114
|
+
文章标题:${n}`:""}
|
|
115
|
+
---
|
|
116
|
+
${s}
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
请按以下 Markdown 格式返回提取结果:
|
|
120
|
+
|
|
121
|
+
## 知识点标题1
|
|
122
|
+
|
|
123
|
+
知识点的详细内容描述,完整解释该知识点。可以使用列表、加粗等 Markdown 语法。
|
|
124
|
+
|
|
125
|
+
## 知识点标题2
|
|
126
|
+
|
|
127
|
+
另一个知识点的内容...
|
|
128
|
+
|
|
129
|
+
注意:
|
|
130
|
+
1. 每个知识点使用二级标题(##)
|
|
131
|
+
2. 标题要简洁明了,概括知识点核心
|
|
132
|
+
3. 内容要详细完整,可使用列表、加粗等格式
|
|
133
|
+
4. 不要添加"知识点1"、"知识点2"这样的序号前缀
|
|
134
|
+
5. 直接返回 Markdown 内容,不要使用代码块包裹`}function Hs(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 i=n.split(/^##\s+/gm).filter(x=>x.trim());if(i.length===0)return null;const l=i.map(x=>{const m=x.split(`
|
|
135
|
+
`);return{title:m[0].trim(),content:m.slice(1).join(`
|
|
136
|
+
`).trim(),sourceContext:"",type:"summary",tags:[]}}).filter(x=>x.title&&x.content);return l.length>0?{knowledgePoints:l}:null}catch{return null}}function Xs(){return`kp_${Date.now()}_${Math.random().toString(36).slice(2,9)}`}async function Ys(s,n){var h,d,w;const{model:i,onProgress:l,signal:x}=n;return((w=(d=(h=(await ut(s,M=>l==null?void 0:l(M),x,i)).choices)==null?void 0:h[0])==null?void 0:d.message)==null?void 0:w.content)||""}async function qs(s,n){var v,j,b;const{title:i,sourceUrl:l,model:x,onProgress:m,signal:h}=n,d=[{role:"system",content:[{type:"text",text:Os}]},{role:"user",content:[{type:"text",text:Vs(s,i)}]}],M=((b=(j=(v=(await ut(d,z=>m==null?void 0:m(z),h,x)).choices)==null?void 0:v[0])==null?void 0:j.message)==null?void 0:b.content)||"",N=Hs(M);if(!N||N.knowledgePoints.length===0)throw new Error("无法从内容中提取知识点,请确保内容包含有价值的信息");return{knowledgePoints:N.knowledgePoints.map(z=>({id:Xs(),title:z.title,content:z.content,sourceContext:z.sourceContext,tags:z.tags,type:z.type,selected:!0})),rawResponse:M,sourceUrl:l,sourceTitle:i,extractedAt:Date.now()}}const Zs="kb-chat-storage",Qs="sessions",pt=Zt.createInstance({name:Zs,storeName:Qs});async function Gs(s){return pt.getItem(s)}async function Js(s,n){const i={noteId:s,messages:n,updatedAt:Date.now()};await pt.setItem(s,i)}const ft={concept:"核心概念",definition:"重要定义",step:"关键步骤",summary:"要点总结"};function en(s,n){const i=[];i.push(`# ${n.title||"知识提炼"}`),i.push(""),n.sourceUrl&&(i.push(`> 来源: ${n.sourceUrl}`),i.push("")),i.push(`> 导出时间: ${new Date().toLocaleString("zh-CN")}`),i.push(""),i.push("---"),i.push("");const l=["concept","definition","step","summary"];for(const x of l){const m=s.filter(h=>h.type===x);if(m.length!==0){i.push(`## ${ft[x]}`),i.push("");for(const h of m)i.push(`### ${h.title}`),i.push(""),i.push(h.content),h.sourceContext&&(i.push(""),i.push(`> ${h.sourceContext}`)),h.tags.length>0&&(i.push(""),i.push(`**标签**: ${h.tags.map(d=>`\`${d}\``).join(" ")}`)),i.push("")}}return i.join(`
|
|
137
|
+
`)}function tn(s,n){const i=s.knowledgePoints.filter(h=>h.selected!==!1);if(i.length===0)throw new Error("没有选中的知识点");const l={title:s.sourceTitle||"知识提炼",sourceUrl:s.sourceUrl},x=new Date().toISOString().slice(0,10),m=s.sourceTitle?`${s.sourceTitle.slice(0,30).replace(/[/\\?%*:|"<>]/g,"-")}_知识提炼_${x}`:`知识提炼_${x}`;return{content:en(i,l),filename:`${m}.md`,mimeType:"text/markdown"}}function sn(s,n,i){const l=new Blob([s],{type:i}),x=URL.createObjectURL(l),m=document.createElement("a");m.href=x,m.download=n,document.body.appendChild(m),m.click(),document.body.removeChild(m),URL.revokeObjectURL(x)}const at="gemini-2.5-flash";function xt(s){const n=[],i=["concept","definition","step","summary"];for(const l of i){const x=s.knowledgePoints.filter(m=>m.type===l);if(x.length!==0){n.push(`## ${ft[l]}`),n.push("");for(const m of x)n.push(`### ${m.title}`),n.push(""),n.push(m.content),m.sourceContext&&(n.push(""),n.push(`> ${m.sourceContext}`)),m.tags&&m.tags.length>0&&(n.push(""),n.push(`**标签**: ${m.tags.map(h=>`\`${h}\``).join(" ")}`)),n.push("")}}return n.join(`
|
|
138
|
+
`).trim()}const nn=({noteId:s,noteContent:n,noteTitle:i,onInsertToNote:l,onSaved:x})=>{const[m,h]=t.useState([]),[d,w]=t.useState(""),[M,N]=t.useState(at),[g,v]=t.useState(()=>Qe(null,at)),[j,b]=t.useState(!1),[z,p]=t.useState(null),[k,D]=t.useState(null),U=t.useRef(null),E=t.useRef(null);t.useEffect(()=>{let r=!0;return(async()=>{h([]);try{const I=await Gs(s);r&&(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)}})(),()=>{r=!1}},[s]),t.useEffect(()=>{m.length>0&&Js(s,m).catch(console.error)},[m,s]),t.useEffect(()=>{U.current&&(U.current.scrollTop=U.current.scrollHeight)},[m]),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(()=>{k&&(k.abort(),D(null),b(!1),h(r=>[...r,{id:Date.now().toString(),role:"model",content:"🚫 已停止生成",type:"text",timestamp:Date.now()}]))},[k]),S=t.useCallback(async()=>{if(!d.trim()||j)return;const r={id:Date.now().toString(),role:"user",content:d,type:"text",timestamp:Date.now()};h(I=>[...I,r]),w(""),b(!0),E.current&&(E.current.style.height="auto");const F=new AbortController;D(F);try{const I=m.concat(r).map(f=>({role:f.role==="model"?"assistant":"user",content:[{type:"text",text:f.content}]}));if(I.length<=2){const f=`Context:
|
|
139
|
+
${n}
|
|
140
|
+
|
|
141
|
+
Task: ${r.content}`,R=I.length-1;I[R].content=[{type:"text",text:f}]}const B=(Date.now()+1).toString();p(B),h(f=>[...f,{id:B,role:"model",content:"正在思考...",type:"text",timestamp:Date.now()}]),await Ys(I,{model:g||M,onProgress:f=>{h(R=>R.map(Y=>Y.id===B?{...Y,content:f}:Y))},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{b(!1),D(null),p(null)}},[d,j,m,n,M,g]),W=t.useCallback(async()=>{if(j)return;b(!0);const r={id:Date.now().toString(),role:"user",content:"提取知识点",type:"text",timestamp:Date.now()};h(B=>[...B,r]);const F=new AbortController;D(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:i,model:g||M,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{b(!1),D(null)}},[j,n,i,M,g]),K=r=>{r.key==="Enter"&&!r.shiftKey&&(r.preventDefault(),S())},X=t.useCallback(r=>{if(!r){A.warning("没有可复制的内容");return}navigator.clipboard.writeText(r).then(()=>{A.success("复制成功")}).catch(()=>{A.error("复制失败")})},[]),q=t.useCallback(r=>r.type==="text"?r.content:r.type==="extraction-result"&&r.data?xt(r.data):"",[]),V=t.useCallback(r=>{if(r.type==="extraction-result"&&r.data)try{const F=tn(r.data,{format:"markdown",includeSource:!0,includeTags:!0});sn(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:m.map(r=>e.jsxs("div",{className:`kb-message kb-message--${r.role}`,children:[e.jsx("div",{className:"kb-message__avatar",children:r.role==="user"?e.jsx(Ee,{}):e.jsx(cs,{})}),e.jsxs("div",{className:"kb-message__body",children:[e.jsx("div",{className:"kb-message__content",children:r.role==="model"?e.jsx("div",{className:"kb-message__content-scroll",children:r.type==="text"?r.id===z&&(r.content==="正在思考..."||r.content==="正在分析笔记内容并提取知识点...")?e.jsxs("div",{className:"kb-message__thinking","aria-label":"思考中",children:[e.jsx("span",{className:"kb-message__thinking-text",children:r.content.replace(/\.+$/,"")}),e.jsxs("span",{className:"kb-message__thinking-dots",children:[e.jsx("span",{children:"."}),e.jsx("span",{children:"."}),e.jsx("span",{children:"."})]})]}):r.content?e.jsx("div",{className:"kb-message__markdown-wrap",children:e.jsx(Le,{markdown:r.content,readOnly:!0,showModeSwitch:!1,initialMode:"wysiwyg",className:"kb-extraction-markdown"})}):null:e.jsx(ot,{result:r.data})}):r.type==="text"?e.jsx("div",{className:"kb-message__text",children:r.content}):e.jsx(ot,{result:r.data})}),r.role==="model"&&e.jsxs("div",{className:"kb-message__actions",children:[e.jsx("button",{className:"kb-message__action-btn",onClick:()=>X(q(r)),title:"复制",children:e.jsx(Me,{size:14})}),e.jsx("button",{className:"kb-message__action-btn",onClick:()=>{const F=q(r);F&&(l==null||l(F))},title:"插入到笔记",children:e.jsx(vs,{size:14})}),r.type==="extraction-result"&&e.jsx("button",{className:"kb-message__action-btn",onClick:()=>V(r),title:"导出 Markdown",children:e.jsx($e,{size:14})})]})]})]},r.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:r=>w(r.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(Qt,{value:M,valueRef:g,onChange:(r,F)=>{N(r),v(F||Qe(null,r))},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:S,disabled:!d.trim()&&!j,title:j?"停止生成":"发送",children:j?e.jsx(ds,{size:18}):e.jsx(Gt,{size:18})})]})]})]})]})},ot=({result:s})=>{const n=Jt.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"})})},rt=[{label:"更新时间",value:"updatedAt"},{label:"创建时间",value:"createdAt"},{label:"标题",value:"title"}],an=({value:s,onChange:n})=>{var m;const i=((m=rt.find(h=>h.value===s.field))==null?void 0:m.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"},...rt.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}}),i]})})},cn=({initialNoteId:s})=>{var He;const[n,i]=t.useState([]),[l,x]=t.useState([]),[m,h]=t.useState([]),[d,w]=t.useState(null),[M,N]=t.useState([]),[g,v]=t.useState({}),[j,b]=t.useState(null),[z,p]=t.useState(new Set),[k,D]=t.useState(null),[U,E]=t.useState(""),[L,S]=t.useState(C.loadSortPreference?C.loadSortPreference():{field:"updatedAt",order:"desc"}),[W,K]=t.useState([]),[X,q]=t.useState(!1),[V,r]=t.useState(!1),[F,I]=t.useState(!1),[B,f]=t.useState(null),R=t.useRef(null),Y=t.useRef(null),[oe,$]=t.useState(!1),[J,re]=t.useState("related"),[Q,Pe]=t.useState(280),[ge,Ae]=t.useState(300),ie=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(ie.current){o.preventDefault();const _=Math.max(200,Math.min(600,o.clientX-u.left));Pe(_)}else if(ce.current){o.preventDefault();const _=Math.max(200,Math.min(600,u.right-o.clientX));Ae(_)}},c=()=>{ie.current&&(ie.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 ie.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(),ie.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 C.initialize(),await O();try{const o=await C.getStorageUsage();bt(o)}catch{}if(s){G(s);return}const c=window.__kbPendingNavigation;if(c){window.__kbPendingNavigation=null;const{directoryName:o,autoCreateNote:u}=c;if(o){const y=(await C.getAllDirectories()).find(T=>T.name===o);if(y&&(b(y.id),p(T=>{const P=new Set(T);return P.add(y.id),P}),u)){const T=o==="Skill"?"新Skill":"新笔记",P=await C.createNote(T,y.id);await O(),p(Ne=>{const le=new Set(Ne);return le.add(y.id),le}),D(P.id);const Z=await C.getNoteById(P.id);w(Z),N([])}}}})()},[]);const O=t.useCallback(async()=>{const[a,c,o]=await Promise.all([C.getAllDirectories(),C.getAllNoteMetas(),C.getAllTags()]),u=Array.from(new Map(a.map(T=>[T.id,T])).values());i(u);const _=Array.from(new Map(c.map(T=>[T.id,T])).values());x(_);const y=Array.from(new Map(o.map(T=>[T.id,T])).values());h(y),!j&&!k&&u.length>0&&(b(u[0].id),p(new Set([u[0].id]))),await gt(_)},[j,k]),gt=t.useCallback(async a=>{try{const[c,o]=await Promise.all([C.getAllTags(),C.getAllNoteTags()]),u=new Map(c.map(y=>[y.id,y])),_={};for(const y of a)_[y.id]=[];for(const y of o)if(_[y.noteId]&&u.has(y.tagId)){const T=u.get(y.tagId);T&&(_[y.noteId].some(P=>P.id===T.id)||_[y.noteId].push(T))}for(const y in _)_[y].sort((T,P)=>T.name.localeCompare(P.name));v(_)}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(_=>_.id)),o=new Map(B.map((_,y)=>[_.id,y]));let u=l.filter(_=>c.has(_.id));if(W.length>0){const _=new Set(W);u=u.filter(y=>(g[y.id]||[]).some(P=>_.has(P.id)))}return u.sort((_,y)=>(o.get(_.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(_=>c.has(_.id)))}return C.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(_=>_.id===o.id)||u.push(o)}return a},[ee]),je=t.useCallback(async a=>{await C.createDirectory(a),await O()},[O]),yt=t.useCallback(async(a,c)=>{await C.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=Ge.confirm({header:"确认删除目录",body:`确定要删除目录 "${c.name}" 及其下的所有笔记吗?此操作不可撤销。`,onConfirm:async()=>{var u;try{await C.deleteDirectory(a),j===a&&(b(((u=n[0])==null?void 0:u.id)||null),D(null),w(null)),await O(),A.success("目录已删除")}catch(_){A.error(`删除失败: ${_.message}`)}o.destroy()},onClose:()=>{o.destroy()}})},[O,j,n]),Nt=t.useCallback(async a=>{try{await C.duplicateDirectory(a),await O(),A.success("目录复制成功")}catch(c){A.error(`复制目录失败: ${c.message}`)}},[O]),St=t.useCallback(a=>{p(c=>{const o=new Set(c);return o.has(a)?o.delete(a):o.add(a),o})},[]),G=t.useCallback(async a=>{if(D(a),b(null),N(g[a]||[]),a.startsWith(ne)){const o=a.slice(ne.length),u=ze.find(_=>_.id===o);if(u){const _=["image","inspiration","grid_image"],y=["ppt"],T=u.mcpTool&&_.some(Z=>u.mcpTool.includes(Z))?"image":u.mcpTool&&y.some(Z=>u.mcpTool.includes(Z))?"ppt":void 0,P={id:a,title:u.name,content:u.description||"",directoryId:"",createdAt:0,updatedAt:0,metadata:{...T?{outputType:T}:{}}};w(P),N([])}return}if(a.startsWith(se)){const o=a.slice(se.length),u=es(o);if(u){const _={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(_),N([])}return}const c=await C.getNoteById(a);if(w(c),c){const o=await C.getTagsForNote(c.id);N(o),p(u=>{const _=new Set(u);return _.add(c.directoryId),_})}},[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 _=u,y=1;for(;c.has(_);)_=`${u} ${y}`,y++;const T=await C.createNote(_,a);await O(),p(P=>{const Z=new Set(P);return Z.add(a),Z}),G(T.id)},[O,G,l,n]),ve=t.useCallback(async(a,c)=>{await C.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 Ce(async()=>{const{Transforms:_}=await import("./index-CvvgEQLL.js").then(y=>y.hU);return{Transforms:_}},__vite__mapDeps([0,1]),import.meta.url);o.children.forEach((_,y)=>{if(_.noteId===a){const T={};c.title!==void 0&&(T.title=c.title),c.content!==void 0&&(T.body=c.content),Object.keys(T).length>0&&u.setNode(o,T,[y])}})}}catch(o){console.warn("[KB] Failed to sync note update to canvas card:",o)}},[d]),Ct=t.useCallback(async a=>{if(!d)return;const c=d.content?`
|
|
142
|
+
|
|
143
|
+
`:"",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 C.getNoteById(a.id);if(!y){A.error("获取笔记内容失败");return}const{getViewportOrigination:T}=await Ce(async()=>{const{getViewportOrigination:te}=await import("./index-CvvgEQLL.js").then(Se=>Se.hU);return{getViewportOrigination:te}},__vite__mapDeps([0,1]),import.meta.url),P=T(c),Z=((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,Ye=((P==null?void 0:P[0])??0)+Z/2-le/2,qe=((P==null?void 0:P[1])??0)+Ne/2-Xe/2,{Transforms:Ut}=await Ce(async()=>{const{Transforms:te}=await import("./index-CvvgEQLL.js").then(Se=>Se.hU);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:[[Ye,qe],[Ye+le,qe+Xe]]};Ut.insertNode(c,Wt,[c.children.length]),A.success("已插入到画布")}catch(_){console.error("[KB] Failed to insert note to canvas:",_),A.error(`插入失败: ${_.message}`)}},[]),zt=t.useCallback(async a=>{try{await C.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=Ge.confirm({header:"确认删除笔记",body:`确定要删除笔记 "${c.title||"无标题"}" 吗?此操作不可撤销。`,onConfirm:async()=>{try{await C.deleteNote(a),k===a&&(D(null),w(null),N([])),await O(),A.success("笔记已删除")}catch(u){A.error(`删除失败: ${u.message}`)}o.destroy()},onClose:()=>{o.destroy()}})},[k,O,l]);t.useEffect(()=>{!We.current&&ee.length>0&&(G(ee[0].id),We.current=!0)},[ee,G]),t.useEffect(()=>{const a=c=>{const{noteId:o}=c.detail;o&&G(o)};return window.addEventListener("kb:open-note",a),()=>window.removeEventListener("kb:open-note",a)},[G]),t.useEffect(()=>{const a=async c=>{const{directoryName:o,autoCreateNote:u}=c.detail;if(!o)return;window.__kbPendingNavigation&&(window.__kbPendingNavigation=null);const y=(await C.getAllDirectories()).find(T=>T.name===o);y&&(b(y.id),p(T=>{const P=new Set(T);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 C.setNoteTags(a,c);const o=await C.getTagsForNote(a);N(o),v(_=>({..._,[a]:o}));const u=await C.getAllTags();h(u)},[]),Fe=t.useCallback(async a=>{const c=await C.createTag(a),o=await C.getAllTags();return h(o),c},[]),Dt=t.useCallback(async(a,c)=>{await C.updateTag(a,{name:c});const o=await C.getAllTags();h(o)},[]),Tt=t.useCallback(async a=>{await C.deleteTag(a);const c=await C.getAllTags();if(h(c),d){const o=await C.getTagsForNote(d.id);N(o),v(u=>({...u,[d.id]:o}))}},[d]),$t=t.useCallback(a=>{S(a),C.saveSortPreference&&C.saveSortPreference(a)},[]);t.useEffect(()=>{if(!V)return;const a=c=>{Y.current&&!Y.current.contains(c.target)&&r(!1)};return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},[V]);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 C.importNoteFromMarkdown(u,j,o.name)}await O(),me.current&&(me.current.value="")}},[j,O]),Ke=t.useCallback(async()=>{try{const a=await C.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 C.importFromZip(c);u.noteCount===0&&u.dirCount===0?A.warning("导入完成:没有新增内容(可能已存在重复内容)"):A.success(`导入完成:${u.dirCount} 个新目录、${u.noteCount} 篇笔记`)}else{const u=await c.text(),_=JSON.parse(u);if(_.version!==1&&_.version!==2){A.error("不支持的导入格式");return}const y=await C.importAllData(_);A.success(`导入完成:${y.dirCount} 个目录、${y.noteCount} 篇笔记、${y.tagCount} 个标签`)}await O()}catch(u){console.error(u),A.error("导入失败,请确认文件格式正确")}pe.current&&(pe.current.value="")}},[O]),Ve=t.useCallback(()=>{const a=window.prompt("请输入目录名称","新建目录");a&&je(a)},[je]),At=t.useCallback(a=>{switch(a.value){case"create-dir":Ve();break;case"manage-tags":q(!0);break;case"import-md":Be();break;case"import-zip":Oe();break;case"export-zip":Ke();break}},[Ve,Be,Oe,Ke]),It=t.useMemo(()=>[{content:"新建目录",value:"create-dir",prefixIcon:e.jsx(xs,{size:14})},{content:"管理标签",value:"manage-tags",prefixIcon:e.jsx(Es,{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(ts,{size:18})})})]}),e.jsxs("div",{className:"kb-drawer__filters",style:{display:"flex",gap:"8px",alignItems:"center"},children:[e.jsx(Ws,{allTags:m,selectedTagIds:W,onSelectedChange:K}),e.jsx("div",{style:{flex:1}}),e.jsx(an,{value:L,onChange:$t})]})]}),e.jsx(Ts,{directories:n,notesByDir:jt,noteTagsMap:g,noteCounts:wt,selectedDirId:j,selectedNoteId:k,expandedDirIds:z,onSelectDir:a=>{b(a),D(null),w(null)},onToggleExpand:St,onCreateDir:je,onRenameDir:yt,onDeleteDir:vt,onDuplicateDir:Nt,onSelectNote:G,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(ss,{size:12}),e.jsxs("span",{className:"kb-drawer__storage-text",children:["已用 ",on(Ie.used)]})]})]}),e.jsx("div",{className:"kb-resizer",onMouseDown:kt}),e.jsx("div",{className:"kb-drawer__editor",children:e.jsx(Us,{note:d,allTags:m,noteTags:M,readOnly:!!(k&&(k.startsWith(ne)||k.startsWith(se))),isSkillDirectory:!!(d&&(((He=n.find(a=>a.id===d.directoryId))==null?void 0:He.name)==="Skill"||k&&k.startsWith(ne)||k&&k.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(Ms,{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:()=>re("related"),title:"相似笔记",children:e.jsx(mt,{size:14})}),e.jsx("button",{className:`kb-drawer__right-tab ${J==="extraction"?"kb-drawer__right-tab--active":""}`,onClick:()=>re("extraction"),title:"知识提取",children:e.jsx(Re,{size:14})})]}),e.jsx("button",{className:"kb-drawer__right-collapse-btn",onClick:()=>$(!0),title:"收起侧边栏",children:e.jsx(Ss,{size:14})})]}),e.jsx("div",{className:"kb-drawer__right-content",children:J==="related"?e.jsx(Bs,{currentNoteId:d.id,allNotes:l,noteTagsMap:g,onSelectNote:G}):e.jsx(nn,{noteId:d.id,noteContent:d.content,noteTitle:d.title,onSaved:()=>O(),onInsertToNote:Ct},d.id)})]})]})})]}),e.jsx(Fs,{visible:X,onClose:()=>q(!1),allTags:m,onCreateTag:Fe,onUpdateTag:Dt,onDeleteTag:Tt})]})};function on(s){if(s===0)return"0 B";const n=["B","KB","MB","GB"],i=Math.floor(Math.log(s)/Math.log(1024));return`${(s/Math.pow(1024,i)).toFixed(1)} ${n[i]}`}export{cn as default};
|