erdbpro 3.4.7-rc.13 → 3.4.7-rc.15
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/dist/assets/{AdminRoute-gDOEk8yy.js → AdminRoute-DR7WLv8e.js} +2 -2
- package/dist/assets/{Combination-1O3P4ajp.js → Combination-CxniEXn1.js} +1 -1
- package/dist/assets/{DataViewerModeToolbar-BERwUykX.js → DataViewerModeToolbar-CYSCGewc.js} +6 -6
- package/dist/assets/{DbClientEditorRoute-i_z2s1dZ.js → DbClientEditorRoute-BVm8MU5x.js} +1 -1
- package/dist/assets/{DiagramEditorRoute-Bfw-7ea4.js → DiagramEditorRoute-DNJKPoqI.js} +1 -1
- package/dist/assets/{DrawingEditorRoute-CCZVGvjN.js → DrawingEditorRoute-BNoD_8Ve.js} +2 -2
- package/dist/assets/{DrawingsView-BvAZw1vT.js → DrawingsView-g6wT2o_x.js} +1 -1
- package/dist/assets/{ExcalidrawEditor-BlXcT7Ae.js → ExcalidrawEditor-D6g8tcWL.js} +8 -8
- package/dist/assets/{FileCommentMarkers-Do8KNBq5.js → FileCommentMarkers-Bb7wFZxL.js} +1 -1
- package/dist/assets/{FlowchartEditorRoute-P1Jzy5w7.js → FlowchartEditorRoute-BdXa9Oyr.js} +1 -1
- package/dist/assets/{FlowchartView-KKIj1Hq-.js → FlowchartView-ei1BqVgz.js} +2 -2
- package/dist/assets/{JumpToNode-YENX0D1W.js → JumpToNode-M6Utg2ut.js} +1 -1
- package/dist/assets/{NoteEditorRoute-BDfs3QN9.js → NoteEditorRoute-DxamsV4C.js} +2 -2
- package/dist/assets/{NotesCompanionPane-fnnh-pKK.js → NotesCompanionPane-DYjj7a6e.js} +2 -2
- package/dist/assets/{NotesView-ByjZpc8a.js → NotesView-BGbxQglx.js} +5 -5
- package/dist/assets/{ProjectFileTabs-DZWlg8g5.js → ProjectFileTabs-j0OMam2z.js} +1 -1
- package/dist/assets/{TeamInventoryRoute-Kfj2OfHo.js → TeamInventoryRoute-DPBxOK5q.js} +1 -1
- package/dist/assets/{TeamManagementRoute-Ce6VjmAT.js → TeamManagementRoute-DD3yiac2.js} +1 -1
- package/dist/assets/{TrashView-Dqa_2hcy.js → TrashView-jomRM79l.js} +1 -1
- package/dist/assets/{UserManagementRoute-C48VZ_KR.js → UserManagementRoute-BqAGOrWQ.js} +1 -1
- package/dist/assets/{WorkspaceProvider-EYbBHADd.js → WorkspaceProvider-C28olTit.js} +3 -3
- package/dist/assets/{abnfDiagram-N423BO3Z-QQB1rA1l.js → abnfDiagram-N423BO3Z-C3d9xfDN.js} +1 -1
- package/dist/assets/{ar-SA-G6X2FPQ2-DaSx7KIG.js → ar-SA-G6X2FPQ2-CwoHu-qE.js} +1 -1
- package/dist/assets/{architectureDiagram-T3A2C74G-BlFel6lV.js → architectureDiagram-T3A2C74G-D59utP2G.js} +1 -1
- package/dist/assets/{az-AZ-76LH7QW2-DO9uvjni.js → az-AZ-76LH7QW2-De29UAAn.js} +1 -1
- package/dist/assets/{bg-BG-XCXSNQG7-DDoAY2iD.js → bg-BG-XCXSNQG7-CsS1K_o9.js} +1 -1
- package/dist/assets/{blockDiagram-VBNYF7ZC-DJhN2lry.js → blockDiagram-VBNYF7ZC-B71Bc6cP.js} +1 -1
- package/dist/assets/{bn-BD-2XOGV67Q-CclZf_c4.js → bn-BD-2XOGV67Q-DLc_zkyf.js} +1 -1
- package/dist/assets/{c4Diagram-5PPSVZJV-DZ1eakb6.js → c4Diagram-5PPSVZJV-D7B9GGtH.js} +1 -1
- package/dist/assets/{ca-ES-6MX7JW3Y-BUCZd9Xn.js → ca-ES-6MX7JW3Y-CXvB0AzC.js} +1 -1
- package/dist/assets/{calendar-CSJ0kfzv.js → calendar-DTAvub78.js} +2 -2
- package/dist/assets/channel-CW5mt8xd.js +1 -0
- package/dist/assets/{chunk-2GRJ4B5K-BY-ZzQVT.js → chunk-2GRJ4B5K-BT6T9Mle.js} +1 -1
- package/dist/assets/{chunk-4I5QYGJK-DM5_T8-j.js → chunk-4I5QYGJK-IvHBiHQG.js} +1 -1
- package/dist/assets/{chunk-5RXB4S5H-BtY6Azfu.js → chunk-5RXB4S5H-CsNECxJm.js} +1 -1
- package/dist/assets/{chunk-6Q2QTUOP-B379eNzG.js → chunk-6Q2QTUOP-DLmKKZSq.js} +1 -1
- package/dist/assets/{chunk-7Z6QIM7H-kSLYYRVb.js → chunk-7Z6QIM7H-CHtefOeu.js} +1 -1
- package/dist/assets/{chunk-EIO257PC-a766giU7.js → chunk-EIO257PC-BSS4TFrV.js} +1 -1
- package/dist/assets/{chunk-GF5L2VYU-DLdS-mKH.js → chunk-GF5L2VYU-Bar_Wn0g.js} +1 -1
- package/dist/assets/{chunk-I66GZJ75-CgT_fz4y.js → chunk-I66GZJ75-C5kpRYr2.js} +1 -1
- package/dist/assets/{chunk-JQJVKLGR-CwEYJVm6.js → chunk-JQJVKLGR-BESTHlIW.js} +1 -1
- package/dist/assets/{chunk-KBJHAD2P-BLX0BdA-.js → chunk-KBJHAD2P-CcKEoX3_.js} +1 -1
- package/dist/assets/{chunk-NSK5VX7P-DKODrRGZ.js → chunk-NSK5VX7P-B5CsPI_M.js} +1 -1
- package/dist/assets/{chunk-QR6OTTB3-CAhn2ZdJ.js → chunk-QR6OTTB3-BXN9mlVj.js} +1 -1
- package/dist/assets/{chunk-UBXNYLIW-D6QbmKvf.js → chunk-UBXNYLIW-B0DsMHjj.js} +1 -1
- package/dist/assets/{chunk-W5SLKNZC-BQwPOO_u.js → chunk-W5SLKNZC-B4y5MC3B.js} +1 -1
- package/dist/assets/{chunk-WRU74C26-CTGb-Pv5.js → chunk-WRU74C26-BN2S-au0.js} +1 -1
- package/dist/assets/classDiagram-JCYQIIEL-CfyzV054.js +1 -0
- package/dist/assets/classDiagram-v2-OCEON4UE-CfyzV054.js +1 -0
- package/dist/assets/{cs-CZ-2BRQDIVT-CogtCaXP.js → cs-CZ-2BRQDIVT-DyWuUnnU.js} +1 -1
- package/dist/assets/{cynefinDiagram-MW4NZA55-DVtyFCKO.js → cynefinDiagram-MW4NZA55-B5Qq7W8X.js} +1 -1
- package/dist/assets/{da-DK-5WZEPLOC-DQLs-46W.js → da-DK-5WZEPLOC-BvmG_hEU.js} +1 -1
- package/dist/assets/{dagre-VZM6K2ZE-BIFOnVcL.js → dagre-VZM6K2ZE-DtdWCZ1H.js} +1 -1
- package/dist/assets/{de-DE-XR44H4JA-pHRpsJi6.js → de-DE-XR44H4JA-zzpo_pmv.js} +1 -1
- package/dist/assets/{diagram-7IWD3JNH-BR9dRm3U.js → diagram-7IWD3JNH-RU30M1zA.js} +1 -1
- package/dist/assets/{diagram-B4RE2ZJO-CjxPSOmE.js → diagram-B4RE2ZJO-D2GiHo28.js} +1 -1
- package/dist/assets/{diagram-LBJQPF4R-Dmh0qJ7J.js → diagram-LBJQPF4R-C9bOPpNl.js} +1 -1
- package/dist/assets/{diagram-Q27KOJAE-D3et1RGZ.js → diagram-Q27KOJAE-6N4GjFGx.js} +1 -1
- package/dist/assets/{diagram-UB23O5K3-B15C06jN.js → diagram-UB23O5K3-DgekKBVn.js} +1 -1
- package/dist/assets/{dist-BREvphdv.js → dist-DfV1p8lz.js} +4 -4
- package/dist/assets/{ebnfDiagram-BXEA7PRR-Dv99LKgV.js → ebnfDiagram-BXEA7PRR-DsLR5O2x.js} +1 -1
- package/dist/assets/{el-GR-BZB4AONW-DZNMVxxk.js → el-GR-BZB4AONW-D2oAWn1N.js} +1 -1
- package/dist/assets/{en-B4ZKOASM-CMd7rWnx.js → en-B4ZKOASM-BxPrmNU7.js} +1 -1
- package/dist/assets/{erDiagram-JOGREHBK-CuaEMlaV.js → erDiagram-JOGREHBK-C1ryV-QO.js} +1 -1
- package/dist/assets/{erd-edge-style-C_Ktt10j.js → erd-edge-style-CLMspt9p.js} +1 -1
- package/dist/assets/{es-ES-U4NZUMDT-BAmZUry5.js → es-ES-U4NZUMDT-KSQ8qnNz.js} +1 -1
- package/dist/assets/{eu-ES-A7QVB2H4-D_495kzy.js → eu-ES-A7QVB2H4-B9FEp75x.js} +1 -1
- package/dist/assets/{fa-IR-HGAKTJCU-DF7L_VWO.js → fa-IR-HGAKTJCU-DlFSdUIm.js} +1 -1
- package/dist/assets/{fi-FI-Z5N7JZ37-C49uNvWC.js → fi-FI-Z5N7JZ37-ClzWBAuq.js} +1 -1
- package/dist/assets/flowDiagram-UKHOOZJN-D08SxeWD.js +1 -0
- package/dist/assets/{fr-FR-RHASNOE6-Dfiy45Ws.js → fr-FR-RHASNOE6-BbtD7h1Z.js} +1 -1
- package/dist/assets/{ganttDiagram-PKOTCBZU-BR6JrukT.js → ganttDiagram-PKOTCBZU-CPKjInLV.js} +1 -1
- package/dist/assets/{gitGraphDiagram-DS77QQ5N-BRfyukT9.js → gitGraphDiagram-DS77QQ5N-AP5u0YCd.js} +1 -1
- package/dist/assets/{gl-ES-HMX3MZ6V-Ojkg_PHq.js → gl-ES-HMX3MZ6V-B0G3CzvU.js} +1 -1
- package/dist/assets/{he-IL-6SHJWFNN-aVXHmgSA.js → he-IL-6SHJWFNN-Cl96O526.js} +1 -1
- package/dist/assets/{hi-IN-IWLTKZ5I-C6I-dcrt.js → hi-IN-IWLTKZ5I-Bs41dp3M.js} +1 -1
- package/dist/assets/{hu-HU-A5ZG7DT2-V2Ijxsye.js → hu-HU-A5ZG7DT2-BHP_uqfs.js} +1 -1
- package/dist/assets/{id-ID-SAP4L64H-aI57QXA0.js → id-ID-SAP4L64H-I2Bup_j4.js} +1 -1
- package/dist/assets/image-GAAHSSAO-EQiZEaT2.js +1 -0
- package/dist/assets/{index-DCMwd7x8.js → index-BmedLVwn.js} +130 -130
- package/dist/assets/index-CEGb4t81.css +1 -0
- package/dist/assets/{infoDiagram-6WML65LV-CQx05-h3.js → infoDiagram-6WML65LV-CE2gZIDY.js} +1 -1
- package/dist/assets/{ishikawaDiagram-WSZJBQD7-Bi71C7u2.js → ishikawaDiagram-WSZJBQD7-BJ4ZMdW8.js} +1 -1
- package/dist/assets/{it-IT-JPQ66NNP-BwcMVI2s.js → it-IT-JPQ66NNP-Cdkfsf2Z.js} +1 -1
- package/dist/assets/{ja-JP-DBVTYXUO-DcCo1QuT.js → ja-JP-DBVTYXUO-BDLkNj9p.js} +1 -1
- package/dist/assets/{journeyDiagram-NVQOT4AX-Dj_wQbo_.js → journeyDiagram-NVQOT4AX-C0DVEhI-.js} +1 -1
- package/dist/assets/{kaa-6HZHGXH3-CgG3AqRg.js → kaa-6HZHGXH3-B5yHGXrL.js} +1 -1
- package/dist/assets/{kab-KAB-ZGHBKWFO-IIJYLJDT.js → kab-KAB-ZGHBKWFO-Bzs8PNws.js} +1 -1
- package/dist/assets/{kanban-definition-27J2QSJJ-CvEHsfKv.js → kanban-definition-27J2QSJJ-D86feQCj.js} +1 -1
- package/dist/assets/{kk-KZ-P5N5QNE5-14XbGfBK.js → kk-KZ-P5N5QNE5-wA_34IY3.js} +1 -1
- package/dist/assets/{km-KH-HSX4SM5Z-DvtktkbQ.js → km-KH-HSX4SM5Z-sFXNTcL0.js} +1 -1
- package/dist/assets/{ko-KR-MTYHY66A-E0g_sU-b.js → ko-KR-MTYHY66A-DU_hfWCQ.js} +1 -1
- package/dist/assets/{ku-TR-6OUDTVRD-DRdCmygu.js → ku-TR-6OUDTVRD-C5UvWxpJ.js} +1 -1
- package/dist/assets/{line-C4Nqd6-4.js → line-BBjcGHhW.js} +1 -1
- package/dist/assets/{lt-LT-XHIRWOB4-CvEuKPj1.js → lt-LT-XHIRWOB4-Ctdjer6c.js} +1 -1
- package/dist/assets/{lv-LV-5QDEKY6T-B_UNkmzH.js → lv-LV-5QDEKY6T-CEaFcw9i.js} +1 -1
- package/dist/assets/{mindmap-definition-FAOFIHXS-DqaqBE7a.js → mindmap-definition-FAOFIHXS-njKSCKEy.js} +1 -1
- package/dist/assets/{mr-IN-CRQNXWMA-B5g-WyR8.js → mr-IN-CRQNXWMA-BA3Isf4f.js} +1 -1
- package/dist/assets/{my-MM-5M5IBNSE-DTBX3Slo.js → my-MM-5M5IBNSE-BKqlyD1o.js} +1 -1
- package/dist/assets/{nb-NO-T6EIAALU-B1I8zsJL.js → nb-NO-T6EIAALU-DGmdF13c.js} +1 -1
- package/dist/assets/{nl-NL-IS3SIHDZ-AtjUEgA1.js → nl-NL-IS3SIHDZ-BJzlXfgy.js} +1 -1
- package/dist/assets/{nn-NO-6E72VCQL-DY0bgWam.js → nn-NO-6E72VCQL-DN7N2974.js} +1 -1
- package/dist/assets/{note-importer-D-BIiDQE.js → note-importer-DrKk7Mjj.js} +2 -2
- package/dist/assets/{oc-FR-POXYY2M6-Cp3hSw7Y.js → oc-FR-POXYY2M6-BXPK-dYI.js} +1 -1
- package/dist/assets/{pa-IN-N4M65BXN-BQDzCIRl.js → pa-IN-N4M65BXN-DpTJY82v.js} +1 -1
- package/dist/assets/{pegDiagram-VL7TDLO6-PH0kaWC9.js → pegDiagram-VL7TDLO6-Do6Evcko.js} +1 -1
- package/dist/assets/percentages-BXMCSKIN-CzvmIjz5.js +1 -0
- package/dist/assets/{pieDiagram-7S7Q4E2Y-CM8dxNWJ.js → pieDiagram-7S7Q4E2Y-DHgNmj39.js} +1 -1
- package/dist/assets/{pl-PL-T2D74RX3-DZPM8Kqk.js → pl-PL-T2D74RX3-BEQm-cE-.js} +1 -1
- package/dist/assets/{pt-BR-5N22H2LF-BkVzBjsT.js → pt-BR-5N22H2LF-DnRQyqyV.js} +1 -1
- package/dist/assets/{pt-PT-UZXXM6DQ-Kzh9i5gU.js → pt-PT-UZXXM6DQ-BAZgfSxU.js} +1 -1
- package/dist/assets/{quadrantDiagram-CIZ2JOQS-DeqLWBSS.js → quadrantDiagram-CIZ2JOQS-zfgBzeh_.js} +1 -1
- package/dist/assets/{railroadDiagram-AXF67PYL-DR96F6O_.js → railroadDiagram-AXF67PYL-rO7zY2yP.js} +1 -1
- package/dist/assets/{requirementDiagram-LRYGKXZP-D0p5haDz.js → requirementDiagram-LRYGKXZP-DmAwo0fp.js} +1 -1
- package/dist/assets/{ro-RO-JPDTUUEW-RRCMID5j.js → ro-RO-JPDTUUEW-DzqvLxwQ.js} +1 -1
- package/dist/assets/{ru-RU-B4JR7IUQ-C5VwX7PA.js → ru-RU-B4JR7IUQ-ClAd821S.js} +1 -1
- package/dist/assets/{sankeyDiagram-W5VNT64P-JgRMoeDt.js → sankeyDiagram-W5VNT64P-CVEmNZWw.js} +1 -1
- package/dist/assets/{sequenceDiagram-SI44F4Z6-DYfkHfM2.js → sequenceDiagram-SI44F4Z6-x6gKQE1Z.js} +1 -1
- package/dist/assets/{si-LK-N5RQ5JYF-DxhEXPHN.js → si-LK-N5RQ5JYF-BCEdbZmN.js} +1 -1
- package/dist/assets/{sk-SK-C5VTKIMK-BXyhcjsY.js → sk-SK-C5VTKIMK-B2Sfn6oz.js} +1 -1
- package/dist/assets/{sl-SI-NN7IZMDC-BOzcBsgH.js → sl-SI-NN7IZMDC-BjucWPJS.js} +1 -1
- package/dist/assets/{stateDiagram-OKZ733FA-M4omEZLi.js → stateDiagram-OKZ733FA-CA3JLKaG.js} +1 -1
- package/dist/assets/stateDiagram-v2-UEYNNEHI-Bqv1PspM.js +1 -0
- package/dist/assets/subset-shared.chunk-WgyLTEbr.js +1 -0
- package/dist/assets/{subset-worker.chunk-BgvN4hBu.js → subset-worker.chunk-B7lDvIj9.js} +1 -1
- package/dist/assets/{sv-SE-XGPEYMSR-sZ5rly11.js → sv-SE-XGPEYMSR-C4nI_AFQ.js} +1 -1
- package/dist/assets/{swimlanes-SLNWSIFB-CmAnHrUm.js → swimlanes-SLNWSIFB-CCipBkDe.js} +1 -1
- package/dist/assets/swimlanesDiagram-ULZ7WXOC-CNdDNDA7.js +8 -0
- package/dist/assets/{ta-IN-2NMHFXQM-DCQux1_U.js → ta-IN-2NMHFXQM-C6z-jcGe.js} +1 -1
- package/dist/assets/{th-TH-HPSO5L25-DdyNi14O.js → th-TH-HPSO5L25-vEQN57ge.js} +1 -1
- package/dist/assets/{timeline-definition-Z64GVDOM-K_v5mAZD.js → timeline-definition-Z64GVDOM-CjQrtqdy.js} +1 -1
- package/dist/assets/{tr-TR-DEFEU3FU-DXbjzYFH.js → tr-TR-DEFEU3FU-DRfblwMc.js} +1 -1
- package/dist/assets/{uk-UA-QMV73CPH-VUycwkKm.js → uk-UA-QMV73CPH-DPhmwzrJ.js} +1 -1
- package/dist/assets/{vennDiagram-T6HMQDX7-B9WlEbd3.js → vennDiagram-T6HMQDX7-BiHgV8GY.js} +1 -1
- package/dist/assets/{vi-VN-M7AON7JQ-CraKtmCg.js → vi-VN-M7AON7JQ-Cdpe5Km3.js} +1 -1
- package/dist/assets/{wardleyDiagram-T6FBY63Y-CEYOgfru.js → wardleyDiagram-T6FBY63Y-DKWJTdnq.js} +1 -1
- package/dist/assets/{xychartDiagram-ELKLHX3M-7uPk_GZE.js → xychartDiagram-ELKLHX3M-DhY-9ms-.js} +1 -1
- package/dist/assets/{zh-CN-LNUGB5OW-lQR0deYl.js → zh-CN-LNUGB5OW-CPMakOyF.js} +1 -1
- package/dist/assets/{zh-HK-E62DVLB3-Buzj7oBV.js → zh-HK-E62DVLB3-DUH04CWK.js} +1 -1
- package/dist/assets/{zh-TW-RAJ6MFWO-DHN5QaMl.js → zh-TW-RAJ6MFWO-Cm2TzPH6.js} +1 -1
- package/dist/index.html +4 -4
- package/dist-server/index.js +160 -160
- package/dist-server/mcp.js +74 -74
- package/package.json +1 -1
- package/dist/assets/channel-DDoiY3Qy.js +0 -1
- package/dist/assets/classDiagram-JCYQIIEL-o650ZObW.js +0 -1
- package/dist/assets/classDiagram-v2-OCEON4UE-o650ZObW.js +0 -1
- package/dist/assets/flowDiagram-UKHOOZJN-YPjGSXvd.js +0 -1
- package/dist/assets/image-GAAHSSAO-DDigG9x4.js +0 -1
- package/dist/assets/index-BRZOISFr.css +0 -1
- package/dist/assets/percentages-BXMCSKIN-Bvmf7A2F.js +0 -1
- package/dist/assets/stateDiagram-v2-UEYNNEHI-DJeq0yBK.js +0 -1
- package/dist/assets/subset-shared.chunk-YUlvemG7.js +0 -1
- package/dist/assets/swimlanesDiagram-ULZ7WXOC-DSStaDFa.js +0 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t,t as n}from"./jsx-runtime-DSr1VPkp.js";import{t as r}from"./check-Uq0GkTkz.js";import{n as i}from"./api-D87lw-98.js";import{Ut as a}from"./index-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t,t as n}from"./jsx-runtime-DSr1VPkp.js";import{t as r}from"./check-Uq0GkTkz.js";import{n as i}from"./api-D87lw-98.js";import{Ut as a}from"./index-BmedLVwn.js";var o=e(t(),1),s=n(),c=(0,o.createContext)(null),l=e=>`${e.type}:${e.id}`;function u({config:e,children:t}){let[n,r]=(0,o.useState)(new Map),a=(0,o.useRef)(0),u=`/api/projects/`+encodeURIComponent(e.projectId)+`/comments`,d=`feature_type=`+e.featureType+`&file_id=`+encodeURIComponent(e.fileId),f=(0,o.useCallback)(async()=>{let e=++a.current;try{let t=await i(u+`/markers?`+d),n=await t.json().catch(()=>({}));if(!t.ok)throw Error(n.error||`Could not load comment markers.`);let o=new Map;for(let e of n.markers||[]){let t={anchorType:e.anchorType??e.anchor_type,anchorId:String(e.anchorId??e.anchor_id),status:e.status===`resolved`?`resolved`:`open`,unreadCount:Number(e.unreadCount??e.unread_count??0)};o.set(l({type:t.anchorType,id:t.anchorId}),t)}e===a.current&&r(o)}catch{}},[u,d]);(0,o.useEffect)(()=>{r(new Map),f();let t=t=>{t.teamId&&t.teamId!==e.teamId||t.projectId&&String(t.projectId)!==e.projectId||f()},n=e=>t(e.detail||{}),i=e=>{let n=e.detail;n?.eventType===`cloud.workspace.sync`&&t(n)},o=e=>t(e.detail||{}),s=window.setInterval(()=>{document.visibilityState===`visible`&&f()},15e3);return window.addEventListener(`collaboration-updated`,n),window.addEventListener(`cloud-workspace-sync`,i),window.addEventListener(`cloud-live-sync-reconnected`,o),()=>{a.current++,window.clearInterval(s),window.removeEventListener(`collaboration-updated`,n),window.removeEventListener(`cloud-workspace-sync`,i),window.removeEventListener(`cloud-live-sync-reconnected`,o)}},[e,f]);let p=(0,o.useMemo)(()=>({config:e,markers:n}),[e,n]);return(0,s.jsx)(c.Provider,{value:p,children:t})}function d(){return(0,o.useContext)(c)}function f({anchor:e}){let t=d(),n=t?.markers.get(l(e));if(!t||!n)return null;let i=e.type===`shape`?`Flowchart shape`:`Drawing element`,o=n.status===`resolved`?`, resolved`:n.unreadCount?`, `+n.unreadCount+` unread`:``,c=n.status===`resolved`?`bg-foreground text-background`:`bg-sky-500 text-white dark:bg-sky-400 dark:text-slate-950`;return(0,s.jsx)(`button`,{type:`button`,className:`flex size-11 shrink-0 items-center justify-center rounded-full border-0 bg-transparent p-0 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-sky-500`,"aria-label":i+` comments`+o,title:i+` comments`+o,onPointerDown:e=>e.stopPropagation(),onClick:n=>{n.stopPropagation(),window.dispatchEvent(new CustomEvent(`project-comment-open-request`,{detail:{featureType:t.config.featureType,fileId:t.config.fileId,type:e.type,id:e.id}}))},children:(0,s.jsx)(`span`,{className:`flex size-5 items-center justify-center rounded-full px-1 text-[9px] font-bold leading-none shadow-sm `+c,children:n.status===`resolved`?(0,s.jsx)(r,{"aria-hidden":`true`,className:`size-2.5 stroke-[3]`}):n.unreadCount>0?n.unreadCount>3?`3+`:n.unreadCount:(0,s.jsx)(a,{"aria-hidden":`true`,className:`size-3`})})})}export{u as n,d as r,f as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t,t as n}from"./jsx-runtime-DSr1VPkp.js";import{l as r,u as i}from"./chunk-BV7QT456-CCzugQp2.js";import"./WorkspaceProvider-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t,t as n}from"./jsx-runtime-DSr1VPkp.js";import{l as r,u as i}from"./chunk-BV7QT456-CCzugQp2.js";import"./WorkspaceProvider-C28olTit.js";import{n as a}from"./WorkspaceContext-O7njKDwj.js";import{pn as o}from"./index-BmedLVwn.js";import{n as s}from"./FileCommentMarkers-Bb7wFZxL.js";import{FlowchartView as c}from"./FlowchartView-ei1BqVgz.js";import{t as l}from"./ProjectFileTabs-j0OMam2z.js";var u=e(t(),1),d=n();function f(){let e=a(),t=r(),{id:n}=i(),{activeFlowchart:f,activeFlowchartId:p,handleFlowchartChange:m,isPublicView:h,isLoading:g,isFlowchartItemLoading:_,handleFlowchartSelect:v,saveFlowchart:y,triggerDebouncedSync:b}=e,x=f?.project_id??f?.projectId,S=f?.uid??p,C=e.projects.find(e=>String(e.id)===String(x)),w=C?.team_id??C?.teamId,T=!!(!h&&!e.isGuest&&w&&t.activeTeamId&&String(w)===String(t.activeTeamId)),E=(0,u.useMemo)(()=>T&&x!=null&&w&&e.user?.id&&S!=null?{projectId:String(x),teamId:String(w),fileId:String(S),featureType:`flowchart`}:null,[T,e.user?.id,S,x,w]),D=(0,u.useRef)(!1);if((0,u.useEffect)(()=>{if(!(h||!n)&&!D.current){if(String(p)===n){D.current=!0;return}p||(D.current=!0,v(n))}},[n,p,h,v]),!h&&!p)return n&&!D.current?(0,d.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center border rounded-xl bg-muted/10`,children:[(0,d.jsx)(`div`,{className:`w-6 h-6 border-2 border-primary/30 border-t-primary rounded-full animate-spin`}),(0,d.jsx)(`p`,{className:`mt-4 text-sm font-medium text-muted-foreground animate-pulse`,children:`Loading flowchart...`})]}):(0,d.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center border rounded-xl bg-muted/10`,children:(0,d.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:`Select a flowchart to view`})});if(!f&&!_)return(0,d.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center border rounded-xl bg-muted/10`,children:[(0,d.jsx)(o,{className:`w-12 h-12 text-muted-foreground/40 mb-4`}),(0,d.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:`Flowchart not found`}),(0,d.jsx)(`p`,{className:`text-xs text-muted-foreground/60 mt-1`,children:`This flowchart may have been deleted or is no longer available.`})]});if(!f)return(0,d.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center border rounded-xl bg-muted/10`,children:[(0,d.jsx)(`div`,{className:`w-6 h-6 border-2 border-primary/30 border-t-primary rounded-full animate-spin`}),(0,d.jsx)(`p`,{className:`mt-4 text-sm font-medium text-muted-foreground animate-pulse`,children:`Loading flowchart...`})]});let O=(0,d.jsx)(c,{isLoading:_,activeFlowchartId:p,activeFlowchart:f,handleFlowchartChange:m,isReadOnly:h,commentsEnabled:T,saveFlowchart:y,triggerDebouncedSync:b});return(0,d.jsxs)(`div`,{className:`flex flex-col flex-1 overflow-hidden`,children:[(0,d.jsx)(l,{currentView:`flowchart`}),E?(0,d.jsx)(s,{config:E,children:O},[E.projectId,E.teamId,E.featureType,E.fileId].join(`:`)):O]})}export{f as FlowchartEditorRoute};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t,t as n}from"./jsx-runtime-DSr1VPkp.js";import{a as r,c as i,h as a,i as o,l as s,m as c,n as l,p as u,r as d,s as f,t as p}from"./downloadSVG-DnlyCOTN.js";import{a as m,h as ee,r as te}from"./esm-B1WURL1q.js";import{n as h}from"./dist-Di9gTGEC.js";import{a as g,c as ne,d as _,i as v,l as y,n as b,o as x,s as S,t as C}from"./dialog-DdtHj1_i.js";import{t as w}from"./button-BGyQguBL.js";import{i as T,n as E,o as D,s as O,t as k}from"./select-iuD-eAM0.js";import{t as A}from"./check-Uq0GkTkz.js";import{S as j,a as M,b as re,n as N,r as ie,u as ae}from"./scroll-area-DJulbnDp.js";import{n as oe,t as se}from"./move-BzTcfKj2.js";import{n as ce,r as le,t as ue}from"./undo-2-BrIFXDrK.js";import{t as de}from"./plus-DfXp3YpY.js";import{t as fe}from"./trash-2-BmZK7fDJ.js";import{t as pe}from"./card-XtyXpgaS.js";import{t as P}from"./input-QHOTkdNi.js";import{n as me}from"./WorkspaceContext-O7njKDwj.js";import{t as F}from"./label-B06IPhlq.js";import{A as he,C as ge,D as _e,E as ve,M as I,N as ye,P as be,Qt as xe,T as Se,Ut as Ce,j as L,k as we,mn as Te,w as Ee}from"./index-DCMwd7x8.js";import{t as De}from"./FileCommentMarkers-Do8KNBq5.js";/* empty css */import{t as Oe}from"./JumpToNode-YENX0D1W.js";var R=e(t(),1),z=n(),ke=(0,R.memo)(({data:e,id:t,selected:n})=>{let[r,a]=(0,R.useState)(!1),o=`!w-1.5 !h-1.5 !bg-white !border-none opacity-0 group-hover:opacity-100 transition-opacity z-20 cursor-crosshair`,s=(0,R.useMemo)(()=>{switch(e.shape){case`diamond`:return`min-w-[130px] min-h-[130px] p-8`;case`circle`:return`min-w-[110px] min-h-[110px] p-4`;case`cloud`:return`min-w-[160px] max-w-[240px] min-h-[90px] px-10 py-6`;case`database`:return`min-w-[140px] max-w-[220px] min-h-[100px] px-6 pt-10 pb-6`;case`parallelogram`:return`min-w-[160px] max-w-[240px] min-h-[80px] px-12 py-4`;case`oval`:return`min-w-[140px] max-w-[240px] min-h-[80px] px-10 py-4`;case`document`:return`min-w-[140px] max-w-[220px] min-h-[90px] px-8 pt-4 pb-10`;default:return`min-w-[140px] max-w-[240px] min-h-[80px] px-8 py-4`}},[e.shape]),c=(0,R.useMemo)(()=>{switch(e.shape){case`diamond`:return{width:100,height:100};case`circle`:return{width:80,height:80};default:return{width:100,height:60}}},[e.shape]),l=(0,R.useMemo)(()=>{let t={background:`linear-gradient(135deg, ${e.color}40 0%, ${e.color}10 100%)`,borderColor:e.color,borderWidth:`2px`,borderStyle:`solid`,boxShadow:`none`,transition:`all 0.3s cubic-bezier(0.4, 0, 0.2, 1)`},n=`${e.color}20`,r=e.color,i={filter:`none`,transition:`all 0.3s`};switch(e.shape){case`diamond`:return(0,z.jsx)(`svg`,{className:`absolute inset-0 w-full h-full pointer-events-none overflow-visible`,viewBox:`0 0 100 100`,preserveAspectRatio:`none`,children:(0,z.jsx)(`path`,{d:`M50,2 L98,50 L50,98 L2,50 Z`,fill:n,stroke:r,strokeWidth:`2`,vectorEffect:`non-scaling-stroke`,strokeLinejoin:`round`,style:i})});case`parallelogram`:return(0,z.jsx)(`svg`,{className:`absolute inset-0 w-full h-full pointer-events-none overflow-visible`,viewBox:`0 0 100 100`,preserveAspectRatio:`none`,children:(0,z.jsx)(`path`,{d:`M20,2 L98,2 L80,98 L2,98 Z`,fill:n,stroke:r,strokeWidth:`2`,vectorEffect:`non-scaling-stroke`,strokeLinejoin:`round`,style:i})});case`oval`:return(0,z.jsx)(`div`,{className:`absolute inset-0 rounded-[50px] pointer-events-none`,style:t});case`circle`:return(0,z.jsx)(`div`,{className:`absolute inset-0 rounded-full pointer-events-none flex items-center justify-center`,style:{...t,background:`radial-gradient(circle at 30% 30%, ${e.color}40 0%, ${e.color}10 100%)`}});case`database`:return(0,z.jsxs)(`svg`,{className:`absolute inset-0 w-full h-full pointer-events-none overflow-visible`,viewBox:`0 0 100 100`,preserveAspectRatio:`none`,children:[(0,z.jsx)(`path`,{d:`M2,15 L2,85 C2,95 98,95 98,85 L98,15`,fill:n,stroke:r,strokeWidth:`2`,vectorEffect:`non-scaling-stroke`,strokeLinejoin:`round`,style:i}),(0,z.jsx)(`path`,{d:`M2,15 C2,5 98,5 98,15 C98,25 2,25 2,15 Z`,fill:`${e.color}35`,stroke:r,strokeWidth:`2`,vectorEffect:`non-scaling-stroke`}),(0,z.jsx)(`path`,{d:`M2,50 C2,60 98,60 98,50`,fill:`none`,stroke:r,strokeWidth:`2`,vectorEffect:`non-scaling-stroke`,opacity:`0.3`})]});case`document`:return(0,z.jsxs)(`svg`,{className:`absolute inset-0 w-full h-full pointer-events-none overflow-visible`,viewBox:`0 0 100 100`,preserveAspectRatio:`none`,children:[(0,z.jsx)(`path`,{d:`M2,2 L70,2 L98,30 L98,85 C98,93 90,98 85,98 L15,98 C7,98 2,93 2,85 Z`,fill:n,stroke:r,strokeWidth:`2`,vectorEffect:`non-scaling-stroke`,strokeLinejoin:`round`,style:i}),(0,z.jsx)(`path`,{d:`M70,2 V30 H98`,fill:`none`,stroke:r,strokeWidth:`2`,vectorEffect:`non-scaling-stroke`,strokeLinejoin:`round`})]});case`cloud`:return(0,z.jsx)(`svg`,{className:`absolute inset-0 w-full h-full pointer-events-none overflow-visible`,viewBox:`0 0 100 100`,preserveAspectRatio:`none`,children:(0,z.jsx)(`path`,{d:`M20,80 C5,80 5,60 15,50 C10,20 40,15 55,25 C65,5 95,10 95,40 C105,50 105,80 80,80 Z`,fill:n,stroke:r,strokeWidth:`2`,vectorEffect:`non-scaling-stroke`,strokeLinecap:`round`,strokeLinejoin:`round`,style:i})});default:return(0,z.jsx)(`div`,{className:`absolute inset-0 rounded-md pointer-events-none`,style:t})}},[e.color,e.shape,n]),u=(0,z.jsxs)(`div`,{className:`relative group flex items-center justify-center cursor-pointer transition-all duration-300 hover:scale-[1.02] ${s}`,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),style:{aspectRatio:e.shape===`circle`?`1 / 1`:`auto`},children:[(0,z.jsx)(i,{isVisible:n||r,keepAspectRatio:e.shape===`circle`,minWidth:c.width,minHeight:c.height,handleStyle:{width:8,height:8,borderRadius:0,backgroundColor:`#0f0f14`,border:`1.5px solid ${e.color}`,zIndex:50},lineStyle:{border:`1px dashed ${e.color}80`}}),l,e._commentsEnabled&&(0,z.jsx)(`div`,{className:`absolute -right-2 -top-2 z-30`,children:(0,z.jsx)(De,{anchor:{type:`shape`,id:t}})}),(0,z.jsx)(f,{id:`top`,type:`target`,position:m.Top,className:o}),(0,z.jsx)(f,{id:`top`,type:`source`,position:m.Top,className:o}),(0,z.jsx)(f,{id:`bottom`,type:`target`,position:m.Bottom,className:o}),(0,z.jsx)(f,{id:`bottom`,type:`source`,position:m.Bottom,className:o}),(0,z.jsx)(f,{id:`right`,type:`target`,position:m.Right,className:o}),(0,z.jsx)(f,{id:`right`,type:`source`,position:m.Right,className:o}),(0,z.jsx)(f,{id:`left`,type:`target`,position:m.Left,className:o}),(0,z.jsx)(f,{id:`left`,type:`source`,position:m.Left,className:o}),(0,z.jsx)(`div`,{className:`relative z-10 text-center text-sm font-semibold text-foreground wrap-break-word whitespace-pre-wrap max-w-full flex-1`,children:e.label}),e.section&&(0,z.jsx)(`div`,{className:`absolute -top-7 left-1/2 -translate-x-1/2 z-20 whitespace-nowrap text-[9px] font-medium text-muted-foreground/60 tracking-wider uppercase px-2 py-0.5 rounded-full bg-background/50 backdrop-blur-sm border border-border/30`,children:e.section})]});return e._commentsEnabled?(0,z.jsxs)(N,{children:[(0,z.jsx)(ae,{className:`contents`,children:u}),(0,z.jsx)(ie,{className:`min-w-36`,positionerClassName:`z-[210]`,children:(0,z.jsxs)(M,{onClick:()=>window.dispatchEvent(new CustomEvent(`project-comment-open-request`,{detail:{featureType:`flowchart`,type:`shape`,id:t}})),children:[(0,z.jsx)(Ce,{"aria-hidden":`true`}),`Comment`]})})]}):u}),Ae=e=>e.trim().toLowerCase().includes(`start`);function je({isOpen:e,onOpenChange:t,nodeData:n,onNodeDataChange:r,onConfirm:i}){let a=Ae(n.label);return(0,z.jsx)(C,{open:e,onOpenChange:t,children:(0,z.jsxs)(v,{className:`sm:max-w-sm`,children:[(0,z.jsxs)(S,{children:[(0,z.jsx)(y,{children:`Create New Symbol`}),(0,z.jsx)(g,{children:`Configure the symbol before placing it on the canvas.`})]}),(0,z.jsxs)(b,{className:`space-y-6`,children:[(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(F,{children:`Label`}),(0,z.jsx)(P,{value:n.label,onChange:e=>r({...n,label:e.target.value}),placeholder:`Enter symbol label`,className:`bg-muted border-border text-foreground`})]}),a&&(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(F,{children:`Group Title`}),(0,z.jsx)(P,{value:n.section||``,onChange:e=>r({...n,section:e.target.value||void 0}),placeholder:`e.g. Pengajuan Cuti`,className:`bg-muted border-border text-foreground`}),(0,z.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50`,children:`Nama grup untuk alur yang dimulai dari sini.`})]}),(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(F,{children:`Shape Type`}),(0,z.jsxs)(k,{value:n.shape,onValueChange:e=>r({...n,shape:e||n.shape}),children:[(0,z.jsx)(D,{className:`w-full bg-muted border-border text-foreground`,children:(0,z.jsx)(O,{placeholder:`Select a shape`,children:n.shape?I[n.shape]:`Select a shape`})}),(0,z.jsxs)(E,{className:`bg-popover border-border text-popover-foreground`,children:[(0,z.jsx)(T,{value:`rectangle`,children:`Rectangle (Process)`}),(0,z.jsx)(T,{value:`oval`,children:`Oval (Start/End)`}),(0,z.jsx)(T,{value:`diamond`,children:`Diamond (Decision)`}),(0,z.jsx)(T,{value:`parallelogram`,children:`Parallelogram (Input/Output)`}),(0,z.jsx)(T,{value:`database`,children:`Cylinder (Database)`}),(0,z.jsx)(T,{value:`document`,children:`Document`}),(0,z.jsx)(T,{value:`cloud`,children:`Cloud (External System)`}),(0,z.jsx)(T,{value:`circle`,children:`Circle (Connector)`})]})]})]}),(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(F,{children:`Color`}),(0,z.jsx)(`div`,{className:`flex gap-2 flex-wrap`,children:he.map(e=>(0,z.jsx)(`button`,{className:`w-8 h-8 rounded-full border-2 transition-transform hover:scale-110 ${n.color===e?`border-white scale-110`:`border-transparent`}`,style:{backgroundColor:e},onClick:()=>r({...n,color:e})},e))})]})]}),(0,z.jsxs)(x,{children:[(0,z.jsx)(w,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,z.jsx)(w,{onClick:i,className:`bg-primary text-primary-foreground`,children:`Add to Flowchart`})]})]})})}function B(e){return e.data.label.trim().toLowerCase().includes(`start`)}function Me({selectedNodeId:e,onClose:t,selectedNode:n,onUpdateNodeData:r,onDeleteNode:i,onDeleteGroup:a,onValidateSection:o}){let s=n?B(n):!1,[c,l]=(0,R.useState)(()=>n?n.data.code?n.data.code:n.data.shape===`diamond`?`return context.amount > 100 ? 'Yes' : 'No';`:`context.status = 'Approved';`:``),u=e=>{l(e),r({code:e})};return(0,z.jsx)(C,{open:!!e,onOpenChange:e=>{e||t()},children:(0,z.jsxs)(v,{className:`sm:max-w-sm`,children:[(0,z.jsxs)(S,{children:[(0,z.jsx)(y,{children:`Symbol Properties`}),(0,z.jsx)(g,{children:`Customize the name, shape, and color of this symbol.`})]}),n&&(0,z.jsxs)(b,{className:`space-y-6`,children:[(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(F,{children:`Label`}),(0,z.jsx)(P,{value:n.data.label,onChange:e=>r({label:e.target.value}),placeholder:`Enter symbol label`,className:`bg-muted/50 border-border text-foreground`})]}),(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(F,{className:`text-xs font-bold text-zinc-300`,children:`Code Logic (JavaScript)`}),(0,z.jsx)(`textarea`,{value:c,onChange:e=>u(e.target.value),placeholder:n.data.shape===`diamond`?`e.g. return context.amount > 100 ? 'Yes' : 'No';`:`e.g. context.status = 'Approved'; context.tries += 1;`,className:`w-full h-24 bg-muted border border-border rounded-md p-2 text-xs font-mono text-foreground placeholder:text-muted-foreground/50 resize-none focus:outline-none focus:border-ring`}),(0,z.jsxs)(`p`,{className:`text-[9px] text-muted-foreground/50 leading-normal`,children:[`Attached sandbox logic. For Decision diamonds, return the matching branch label (case-sensitive). Process symbols can mutate variables in the `,(0,z.jsx)(`code`,{children:`context`}),` object.`]})]}),s&&(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(F,{children:`Group Title`}),(0,z.jsx)(P,{value:n.data.section||``,onChange:e=>r({section:e.target.value||void 0}),onBlur:e=>{let t=e.target.value;t&&o&&!o(t)&&r({section:void 0})},placeholder:`e.g. Pengajuan Cuti`,className:`bg-muted/50 border-border text-foreground`}),(0,z.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50`,children:`Nama grup untuk alur yang dimulai dari sini.`})]}),(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(F,{children:`Shape Type`}),(0,z.jsxs)(k,{value:n.data.shape,onValueChange:e=>e&&r({shape:e}),children:[(0,z.jsx)(D,{className:`w-full bg-muted border-border text-foreground`,children:(0,z.jsx)(O,{placeholder:`Select a shape`,children:n.data.shape?I[n.data.shape]:`Select a shape`})}),(0,z.jsxs)(E,{className:`bg-popover border-border text-popover-foreground`,children:[(0,z.jsx)(T,{value:`rectangle`,children:`Rectangle (Process)`}),(0,z.jsx)(T,{value:`oval`,children:`Oval (Start/End)`}),(0,z.jsx)(T,{value:`diamond`,children:`Diamond (Decision)`}),(0,z.jsx)(T,{value:`parallelogram`,children:`Parallelogram (Input/Output)`}),(0,z.jsx)(T,{value:`database`,children:`Cylinder (Database)`}),(0,z.jsx)(T,{value:`document`,children:`Document`}),(0,z.jsx)(T,{value:`cloud`,children:`Cloud (External System)`}),(0,z.jsx)(T,{value:`circle`,children:`Circle (Connector)`})]})]})]}),(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(F,{children:`Color`}),(0,z.jsx)(`div`,{className:`flex gap-2 flex-wrap`,children:he.map(e=>(0,z.jsx)(`button`,{className:`w-8 h-8 rounded-full border-2 transition-transform hover:scale-110 ${n.data.color===e?`border-white scale-110`:`border-transparent`}`,style:{backgroundColor:e},onClick:()=>r({color:e})},e))})]}),(0,z.jsxs)(`div`,{className:`pt-2 border-t border-border space-y-2`,children:[(0,z.jsxs)(w,{variant:`destructive`,size:`sm`,className:`w-full gap-2`,onClick:()=>{i(),t()},children:[(0,z.jsx)(fe,{className:`size-4`}),`Delete Symbol`]}),s&&n.data.section&&a&&(0,z.jsxs)(w,{variant:`outline`,size:`sm`,className:`w-full gap-2 text-destructive border-destructive/30 hover:bg-destructive/10`,onClick:()=>{a(),t()},children:[(0,z.jsx)(fe,{className:`size-4`}),`Delete Group "`,n.data.section,`"`]})]})]},e)]})})}function Ne({selectedEdgeId:e,onClose:t,selectedEdge:n,isDashed:r,arrowType:i,onEdgeTypeChange:a,onArrowChange:o,onLabelChange:s,onDeleteEdge:c}){return(0,z.jsx)(C,{open:!!e,onOpenChange:e=>{e||t()},children:(0,z.jsxs)(v,{className:`sm:max-w-sm`,children:[(0,z.jsx)(S,{children:(0,z.jsxs)(`div`,{className:`flex items-center justify-between pr-8`,children:[(0,z.jsxs)(`div`,{className:`space-y-1 text-left`,children:[(0,z.jsx)(y,{children:`Connector Properties`}),(0,z.jsx)(g,{children:`Format the line style and arrows.`})]}),(0,z.jsx)(w,{variant:`ghost`,size:`icon`,onClick:c,className:`text-destructive hover:bg-destructive/10 -mr-2 shadow-none`,title:`Delete Connector`,children:(0,z.jsx)(fe,{className:`w-4 h-4`})})]})}),n&&(0,z.jsxs)(b,{className:`space-y-6`,children:[(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(F,{children:`Text Label`}),(0,z.jsx)(P,{value:typeof n.label==`string`?n.label:``,onChange:e=>s(e.target.value),placeholder:`e.g. Yes, No, 1, 2...`,className:`bg-muted border-border text-foreground`})]}),(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(F,{children:`Line Style`}),(0,z.jsxs)(k,{value:r?`dashed`:`solid`,onValueChange:e=>a(e||``),children:[(0,z.jsx)(D,{className:`w-full bg-muted border-border text-foreground`,children:(0,z.jsx)(O,{placeholder:`Select line style`,children:L[r?`dashed`:`solid`]})}),(0,z.jsxs)(E,{className:`bg-popover border-border text-popover-foreground`,children:[(0,z.jsx)(T,{value:`solid`,children:`Solid Line`}),(0,z.jsx)(T,{value:`dashed`,children:`Dashed Line`})]})]})]}),(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(F,{children:`Arrow Style`}),(0,z.jsxs)(k,{value:i,onValueChange:e=>o(e||``),children:[(0,z.jsx)(D,{className:`w-full bg-muted border-border text-foreground`,children:(0,z.jsx)(O,{placeholder:`Select arrow style`,children:we[i]})}),(0,z.jsxs)(E,{className:`bg-popover border-border text-popover-foreground`,children:[(0,z.jsx)(T,{value:`end`,children:`Arrow at End`}),(0,z.jsx)(T,{value:`start`,children:`Arrow at Start (Reverse)`}),(0,z.jsx)(T,{value:`both`,children:`Arrows Both Ends`}),(0,z.jsx)(T,{value:`none`,children:`No Arrows (Line only)`})]})]})]})]})]})})}function Pe({nodes:e,edges:t,onConfirm:n,onCancel:r,confirmLabel:i=`Confirm Append`,canvasGroups:a=[],existingNodes:o=[],existingEdges:s=[]}){let[c,l]=(0,R.useState)(null),u=(0,R.useMemo)(()=>{if(!o.length||!e.length)return null;let n=new Map;for(let e of o)n.set((e.data.label||``).toLowerCase(),e);let r=new Map;for(let t of e)r.set((t.data.label||``).toLowerCase(),t);let i=[];for(let t of e){let e=t.data.label||`Untitled`,r=n.get(e.toLowerCase());if(!r)i.push({type:`header`,label:e,isNew:!0}),i.push({type:`add`,prefix:`+`,field:`shape`,newVal:t.data.shape}),i.push({type:`add`,prefix:`+`,field:`label`,newVal:e}),t.data.color&&i.push({type:`add`,prefix:`+`,field:`color`,newVal:t.data.color});else{let n=r.data.shape!==t.data.shape,a=r.data.color!==t.data.color,o=(r.data.label||``)!==e;(n||a||o)&&(i.push({type:`header`,label:e}),o&&i.push({type:`change`,prefix:`~`,field:`label`,oldVal:r.data.label,newVal:e}),n&&i.push({type:`change`,prefix:`~`,field:`shape`,oldVal:r.data.shape,newVal:t.data.shape}),a&&i.push({type:`change`,prefix:`~`,field:`color`,oldVal:r.data.color,newVal:t.data.color}))}}for(let e of o){let t=e.data.label||``;r.has(t.toLowerCase())||(i.push({type:`header`,label:t,isNew:!1}),i.push({type:`remove`,prefix:`-`,field:`shape`,oldVal:e.data.shape}),i.push({type:`remove`,prefix:`-`,field:`removed`,oldVal:`entire node`}))}let a=new Set(s.map(e=>{let t=o.find(t=>t.id===e.source)?.data.label||e.source,n=o.find(t=>t.id===e.target)?.data.label||e.target;return`${t.toLowerCase()}→${n.toLowerCase()}`})),c=new Set(t.map(t=>{let n=e.find(e=>e.id===t.source)?.data.label||t.source,r=e.find(e=>e.id===t.target)?.data.label||t.target;return`${n.toLowerCase()}→${r.toLowerCase()}`})),l=[...c].filter(e=>!a.has(e)),u=[...a].filter(e=>!c.has(e));if(l.length>0||u.length>0){i.push({type:`header`,label:`Connections`});for(let e of l)i.push({type:`add`,prefix:`+`,field:`connection`,newVal:e});for(let e of u)i.push({type:`remove`,prefix:`-`,field:`connection`,oldVal:e})}return i.length>0?i:null},[o,s,e,t]);return(0,z.jsxs)(C,{open:!0,onOpenChange:e=>{e||r()},children:[(0,z.jsx)(ne,{}),(0,z.jsxs)(v,{size:`2xl`,showCloseButton:!0,children:[(0,z.jsx)(S,{children:(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsx)(`div`,{className:`size-8 rounded-lg bg-indigo-500/10 flex items-center justify-center`,children:(0,z.jsx)(Te,{className:`size-4 text-indigo-400`})}),(0,z.jsx)(`div`,{children:(0,z.jsx)(y,{children:`Preview Changes`})})]})}),(0,z.jsx)(b,{children:(0,z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[e.length>0&&(0,z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,z.jsxs)(`label`,{className:`text-[11px] font-medium text-muted-foreground`,children:[`New Symbols (`,e.length,`)`]}),(0,z.jsx)(`div`,{className:`max-h-75 overflow-y-auto custom-scrollbar space-y-2`,children:e.map(e=>(0,z.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-muted overflow-hidden`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5 px-3 py-2 border-b border-border/20 bg-muted/50`,children:[(0,z.jsx)(Te,{className:`size-3 text-indigo-400 shrink-0`}),(0,z.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground`,children:e.data.label}),(0,z.jsx)(`span`,{className:`text-[9px] text-muted-foreground ml-auto`,children:e.data.shape})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 text-[10px] font-mono`,children:[(0,z.jsx)(`span`,{className:`text-gray-500`,children:`Shape:`}),(0,z.jsx)(`span`,{className:`text-gray-300`,children:e.data.shape}),e.data.color&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`text-gray-500 ml-2`,children:`Color:`}),(0,z.jsx)(`span`,{className:`text-gray-300`,children:e.data.color})]})]})]},e.id))})]}),u&&(0,z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,z.jsx)(`label`,{className:`text-[11px] font-medium text-muted-foreground`,children:`Changes`}),(0,z.jsx)(`div`,{className:`rounded-lg border border-border/40 overflow-hidden max-h-75 overflow-y-auto custom-scrollbar text-[10px] font-mono leading-relaxed`,children:(0,z.jsx)(`div`,{className:`divide-y divide-border/10`,children:u.map((e,t)=>{if(e.type===`header`)return(0,z.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 bg-muted border-b border-border/30`,children:[e.isNew&&(0,z.jsx)(`span`,{className:`text-[8px] font-semibold px-1 py-0.5 rounded bg-emerald-500/15 text-emerald-400 border border-emerald-500/30 shrink-0`,children:`NEW`}),(0,z.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground`,children:e.label})]},t);let n=e.type===`add`,r=e.type===`remove`,i=e.type===`change`,a=n?`bg-emerald-900/20`:r?`bg-red-900/20`:i?`bg-amber-900/20`:``,o=n?`text-emerald-400`:r?`text-red-400`:`text-amber-400`,s=n?`text-emerald-300`:r?`text-red-400`:`text-amber-300`,c=n?`text-emerald-400/60`:r?`text-red-400/60`:`text-amber-400/60`;return(0,z.jsxs)(`div`,{className:`flex items-center gap-1 px-3 py-0.5 ${a}`,children:[(0,z.jsx)(`span`,{className:`w-4 shrink-0 select-none ${o}`,children:e.prefix}),(0,z.jsx)(`span`,{className:`w-20 shrink-0 ${c}`,children:e.field}),e.oldVal&&(0,z.jsx)(`span`,{className:`text-red-400/70 line-through`,children:e.oldVal}),e.oldVal&&e.newVal&&(0,z.jsx)(`span`,{className:`text-gray-600`,children:`→`}),e.newVal&&(0,z.jsx)(`span`,{className:s,children:e.newVal})]},t)})})})]}),!u&&!e.length&&(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No changes detected.`})]})}),(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-6 pt-4 pb-6`,children:[(0,z.jsx)(`div`,{className:`flex items-center gap-3`,children:a.length>0&&(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(oe,{className:`size-3.5 text-muted-foreground shrink-0`}),(0,z.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Replace:`}),(0,z.jsxs)(k,{value:c??``,onValueChange:e=>l(e||null),children:[(0,z.jsx)(D,{className:`h-7 text-[12px]`,children:(0,z.jsx)(O,{placeholder:`All Symbols`})}),(0,z.jsxs)(E,{children:[(0,z.jsx)(T,{value:``,children:`All Symbols`}),a.map(e=>(0,z.jsx)(T,{value:e,children:e},e))]})]})]})}),(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsxs)(w,{variant:`outline`,size:`sm`,onClick:r,className:`gap-2`,children:[(0,z.jsx)(_,{className:`size-4`}),`Cancel`]}),(0,z.jsxs)(w,{size:`sm`,onClick:()=>n(c||void 0),className:`gap-2`,children:[(0,z.jsx)(A,{className:`size-4`}),i]})]})]})]})]})}function V(e){return[{x:e.x+80,y:e.y},{x:e.x+80,y:e.y+70},{x:e.x,y:e.y+35},{x:e.x+160,y:e.y+35}]}function H(e,t){return V(e)[[`top`,`bottom`,`left`,`right`].indexOf(t)]}function Fe(e,t){let n=[`top`,`bottom`,`left`,`right`],r=V(e.position),i=V(t.position),a=1/0,o=0,s=0;for(let e=0;e<4;e++)for(let t=0;t<4;t++){let n=r[e].x-i[t].x,c=r[e].y-i[t].y,l=n*n+c*c;l<a&&(a=l,o=e,s=t)}return{sourceHandle:n[o],targetHandle:n[s]}}function Ie(e,t,n,r){if(t===`bottom`||t===`top`||r===`bottom`||r===`top`){let t=(e.y+n.y)/2;return`M${e.x},${e.y} L${e.x},${t} L${n.x},${t} L${n.x},${n.y}`}let i=(e.x+n.x)/2;return`M${e.x},${e.y} L${i},${e.y} L${i},${n.y} L${n.x},${n.y}`}function Le(e,t,n){switch(e){case`diamond`:return`<polygon points="80,2 158,35 80,68 2,35" fill="url(#grad-${n})" stroke="${t}" stroke-width="2" stroke-linejoin="round" filter="url(#shadow)" />`;case`parallelogram`:return`<polygon points="32,2 158,2 128,68 2,68" fill="url(#grad-${n})" stroke="${t}" stroke-width="2" stroke-linejoin="round" filter="url(#shadow)" />`;case`oval`:return`<ellipse cx="80" cy="35" rx="78" ry="33" fill="url(#grad-${n})" stroke="${t}" stroke-width="2" filter="url(#shadow)" />`;case`circle`:return`<circle cx="80" cy="35" r="33" fill="url(#grad-${n})" stroke="${t}" stroke-width="2" filter="url(#shadow)" />`;case`database`:return`<g>
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t,t as n}from"./jsx-runtime-DSr1VPkp.js";import{a as r,c as i,h as a,i as o,l as s,m as c,n as l,p as u,r as d,s as f,t as p}from"./downloadSVG-DnlyCOTN.js";import{a as m,h as ee,r as te}from"./esm-B1WURL1q.js";import{n as h}from"./dist-Di9gTGEC.js";import{a as g,c as ne,d as _,i as v,l as y,n as b,o as x,s as S,t as C}from"./dialog-DdtHj1_i.js";import{t as w}from"./button-BGyQguBL.js";import{i as T,n as E,o as D,s as O,t as k}from"./select-iuD-eAM0.js";import{t as A}from"./check-Uq0GkTkz.js";import{S as j,a as M,b as re,n as N,r as ie,u as ae}from"./scroll-area-DJulbnDp.js";import{n as oe,t as se}from"./move-BzTcfKj2.js";import{n as ce,r as le,t as ue}from"./undo-2-BrIFXDrK.js";import{t as de}from"./plus-DfXp3YpY.js";import{t as fe}from"./trash-2-BmZK7fDJ.js";import{t as pe}from"./card-XtyXpgaS.js";import{t as P}from"./input-QHOTkdNi.js";import{n as me}from"./WorkspaceContext-O7njKDwj.js";import{t as F}from"./label-B06IPhlq.js";import{A as he,C as ge,D as _e,E as ve,M as I,N as ye,P as be,T as xe,Ut as Se,Zt as Ce,j as L,k as we,pn as Te,w as Ee}from"./index-BmedLVwn.js";import{t as De}from"./FileCommentMarkers-Bb7wFZxL.js";/* empty css */import{t as Oe}from"./JumpToNode-M6Utg2ut.js";var R=e(t(),1),z=n(),ke=(0,R.memo)(({data:e,id:t,selected:n})=>{let[r,a]=(0,R.useState)(!1),o=`!w-1.5 !h-1.5 !bg-white !border-none opacity-0 group-hover:opacity-100 transition-opacity z-20 cursor-crosshair`,s=(0,R.useMemo)(()=>{switch(e.shape){case`diamond`:return`min-w-[130px] min-h-[130px] p-8`;case`circle`:return`min-w-[110px] min-h-[110px] p-4`;case`cloud`:return`min-w-[160px] max-w-[240px] min-h-[90px] px-10 py-6`;case`database`:return`min-w-[140px] max-w-[220px] min-h-[100px] px-6 pt-10 pb-6`;case`parallelogram`:return`min-w-[160px] max-w-[240px] min-h-[80px] px-12 py-4`;case`oval`:return`min-w-[140px] max-w-[240px] min-h-[80px] px-10 py-4`;case`document`:return`min-w-[140px] max-w-[220px] min-h-[90px] px-8 pt-4 pb-10`;default:return`min-w-[140px] max-w-[240px] min-h-[80px] px-8 py-4`}},[e.shape]),c=(0,R.useMemo)(()=>{switch(e.shape){case`diamond`:return{width:100,height:100};case`circle`:return{width:80,height:80};default:return{width:100,height:60}}},[e.shape]),l=(0,R.useMemo)(()=>{let t={background:`linear-gradient(135deg, ${e.color}40 0%, ${e.color}10 100%)`,borderColor:e.color,borderWidth:`2px`,borderStyle:`solid`,boxShadow:`none`,transition:`all 0.3s cubic-bezier(0.4, 0, 0.2, 1)`},n=`${e.color}20`,r=e.color,i={filter:`none`,transition:`all 0.3s`};switch(e.shape){case`diamond`:return(0,z.jsx)(`svg`,{className:`absolute inset-0 w-full h-full pointer-events-none overflow-visible`,viewBox:`0 0 100 100`,preserveAspectRatio:`none`,children:(0,z.jsx)(`path`,{d:`M50,2 L98,50 L50,98 L2,50 Z`,fill:n,stroke:r,strokeWidth:`2`,vectorEffect:`non-scaling-stroke`,strokeLinejoin:`round`,style:i})});case`parallelogram`:return(0,z.jsx)(`svg`,{className:`absolute inset-0 w-full h-full pointer-events-none overflow-visible`,viewBox:`0 0 100 100`,preserveAspectRatio:`none`,children:(0,z.jsx)(`path`,{d:`M20,2 L98,2 L80,98 L2,98 Z`,fill:n,stroke:r,strokeWidth:`2`,vectorEffect:`non-scaling-stroke`,strokeLinejoin:`round`,style:i})});case`oval`:return(0,z.jsx)(`div`,{className:`absolute inset-0 rounded-[50px] pointer-events-none`,style:t});case`circle`:return(0,z.jsx)(`div`,{className:`absolute inset-0 rounded-full pointer-events-none flex items-center justify-center`,style:{...t,background:`radial-gradient(circle at 30% 30%, ${e.color}40 0%, ${e.color}10 100%)`}});case`database`:return(0,z.jsxs)(`svg`,{className:`absolute inset-0 w-full h-full pointer-events-none overflow-visible`,viewBox:`0 0 100 100`,preserveAspectRatio:`none`,children:[(0,z.jsx)(`path`,{d:`M2,15 L2,85 C2,95 98,95 98,85 L98,15`,fill:n,stroke:r,strokeWidth:`2`,vectorEffect:`non-scaling-stroke`,strokeLinejoin:`round`,style:i}),(0,z.jsx)(`path`,{d:`M2,15 C2,5 98,5 98,15 C98,25 2,25 2,15 Z`,fill:`${e.color}35`,stroke:r,strokeWidth:`2`,vectorEffect:`non-scaling-stroke`}),(0,z.jsx)(`path`,{d:`M2,50 C2,60 98,60 98,50`,fill:`none`,stroke:r,strokeWidth:`2`,vectorEffect:`non-scaling-stroke`,opacity:`0.3`})]});case`document`:return(0,z.jsxs)(`svg`,{className:`absolute inset-0 w-full h-full pointer-events-none overflow-visible`,viewBox:`0 0 100 100`,preserveAspectRatio:`none`,children:[(0,z.jsx)(`path`,{d:`M2,2 L70,2 L98,30 L98,85 C98,93 90,98 85,98 L15,98 C7,98 2,93 2,85 Z`,fill:n,stroke:r,strokeWidth:`2`,vectorEffect:`non-scaling-stroke`,strokeLinejoin:`round`,style:i}),(0,z.jsx)(`path`,{d:`M70,2 V30 H98`,fill:`none`,stroke:r,strokeWidth:`2`,vectorEffect:`non-scaling-stroke`,strokeLinejoin:`round`})]});case`cloud`:return(0,z.jsx)(`svg`,{className:`absolute inset-0 w-full h-full pointer-events-none overflow-visible`,viewBox:`0 0 100 100`,preserveAspectRatio:`none`,children:(0,z.jsx)(`path`,{d:`M20,80 C5,80 5,60 15,50 C10,20 40,15 55,25 C65,5 95,10 95,40 C105,50 105,80 80,80 Z`,fill:n,stroke:r,strokeWidth:`2`,vectorEffect:`non-scaling-stroke`,strokeLinecap:`round`,strokeLinejoin:`round`,style:i})});default:return(0,z.jsx)(`div`,{className:`absolute inset-0 rounded-md pointer-events-none`,style:t})}},[e.color,e.shape,n]),u=(0,z.jsxs)(`div`,{className:`relative group flex items-center justify-center cursor-pointer transition-all duration-300 hover:scale-[1.02] ${s}`,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),style:{aspectRatio:e.shape===`circle`?`1 / 1`:`auto`},children:[(0,z.jsx)(i,{isVisible:n||r,keepAspectRatio:e.shape===`circle`,minWidth:c.width,minHeight:c.height,handleStyle:{width:8,height:8,borderRadius:0,backgroundColor:`#0f0f14`,border:`1.5px solid ${e.color}`,zIndex:50},lineStyle:{border:`1px dashed ${e.color}80`}}),l,e._commentsEnabled&&(0,z.jsx)(`div`,{className:`absolute -right-2 -top-2 z-30`,children:(0,z.jsx)(De,{anchor:{type:`shape`,id:t}})}),(0,z.jsx)(f,{id:`top`,type:`target`,position:m.Top,className:o}),(0,z.jsx)(f,{id:`top`,type:`source`,position:m.Top,className:o}),(0,z.jsx)(f,{id:`bottom`,type:`target`,position:m.Bottom,className:o}),(0,z.jsx)(f,{id:`bottom`,type:`source`,position:m.Bottom,className:o}),(0,z.jsx)(f,{id:`right`,type:`target`,position:m.Right,className:o}),(0,z.jsx)(f,{id:`right`,type:`source`,position:m.Right,className:o}),(0,z.jsx)(f,{id:`left`,type:`target`,position:m.Left,className:o}),(0,z.jsx)(f,{id:`left`,type:`source`,position:m.Left,className:o}),(0,z.jsx)(`div`,{className:`relative z-10 text-center text-sm font-semibold text-foreground wrap-break-word whitespace-pre-wrap max-w-full flex-1`,children:e.label}),e.section&&(0,z.jsx)(`div`,{className:`absolute -top-7 left-1/2 -translate-x-1/2 z-20 whitespace-nowrap text-[9px] font-medium text-muted-foreground/60 tracking-wider uppercase px-2 py-0.5 rounded-full bg-background/50 backdrop-blur-sm border border-border/30`,children:e.section})]});return e._commentsEnabled?(0,z.jsxs)(N,{children:[(0,z.jsx)(ae,{className:`contents`,children:u}),(0,z.jsx)(ie,{className:`min-w-36`,positionerClassName:`z-[210]`,children:(0,z.jsxs)(M,{onClick:()=>window.dispatchEvent(new CustomEvent(`project-comment-open-request`,{detail:{featureType:`flowchart`,type:`shape`,id:t}})),children:[(0,z.jsx)(Se,{"aria-hidden":`true`}),`Comment`]})})]}):u}),Ae=e=>e.trim().toLowerCase().includes(`start`);function je({isOpen:e,onOpenChange:t,nodeData:n,onNodeDataChange:r,onConfirm:i}){let a=Ae(n.label);return(0,z.jsx)(C,{open:e,onOpenChange:t,children:(0,z.jsxs)(v,{className:`sm:max-w-sm`,children:[(0,z.jsxs)(S,{children:[(0,z.jsx)(y,{children:`Create New Symbol`}),(0,z.jsx)(g,{children:`Configure the symbol before placing it on the canvas.`})]}),(0,z.jsxs)(b,{className:`space-y-6`,children:[(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(F,{children:`Label`}),(0,z.jsx)(P,{value:n.label,onChange:e=>r({...n,label:e.target.value}),placeholder:`Enter symbol label`,className:`bg-muted border-border text-foreground`})]}),a&&(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(F,{children:`Group Title`}),(0,z.jsx)(P,{value:n.section||``,onChange:e=>r({...n,section:e.target.value||void 0}),placeholder:`e.g. Pengajuan Cuti`,className:`bg-muted border-border text-foreground`}),(0,z.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50`,children:`Nama grup untuk alur yang dimulai dari sini.`})]}),(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(F,{children:`Shape Type`}),(0,z.jsxs)(k,{value:n.shape,onValueChange:e=>r({...n,shape:e||n.shape}),children:[(0,z.jsx)(D,{className:`w-full bg-muted border-border text-foreground`,children:(0,z.jsx)(O,{placeholder:`Select a shape`,children:n.shape?I[n.shape]:`Select a shape`})}),(0,z.jsxs)(E,{className:`bg-popover border-border text-popover-foreground`,children:[(0,z.jsx)(T,{value:`rectangle`,children:`Rectangle (Process)`}),(0,z.jsx)(T,{value:`oval`,children:`Oval (Start/End)`}),(0,z.jsx)(T,{value:`diamond`,children:`Diamond (Decision)`}),(0,z.jsx)(T,{value:`parallelogram`,children:`Parallelogram (Input/Output)`}),(0,z.jsx)(T,{value:`database`,children:`Cylinder (Database)`}),(0,z.jsx)(T,{value:`document`,children:`Document`}),(0,z.jsx)(T,{value:`cloud`,children:`Cloud (External System)`}),(0,z.jsx)(T,{value:`circle`,children:`Circle (Connector)`})]})]})]}),(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(F,{children:`Color`}),(0,z.jsx)(`div`,{className:`flex gap-2 flex-wrap`,children:he.map(e=>(0,z.jsx)(`button`,{className:`w-8 h-8 rounded-full border-2 transition-transform hover:scale-110 ${n.color===e?`border-white scale-110`:`border-transparent`}`,style:{backgroundColor:e},onClick:()=>r({...n,color:e})},e))})]})]}),(0,z.jsxs)(x,{children:[(0,z.jsx)(w,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,z.jsx)(w,{onClick:i,className:`bg-primary text-primary-foreground`,children:`Add to Flowchart`})]})]})})}function B(e){return e.data.label.trim().toLowerCase().includes(`start`)}function Me({selectedNodeId:e,onClose:t,selectedNode:n,onUpdateNodeData:r,onDeleteNode:i,onDeleteGroup:a,onValidateSection:o}){let s=n?B(n):!1,[c,l]=(0,R.useState)(()=>n?n.data.code?n.data.code:n.data.shape===`diamond`?`return context.amount > 100 ? 'Yes' : 'No';`:`context.status = 'Approved';`:``),u=e=>{l(e),r({code:e})};return(0,z.jsx)(C,{open:!!e,onOpenChange:e=>{e||t()},children:(0,z.jsxs)(v,{className:`sm:max-w-sm`,children:[(0,z.jsxs)(S,{children:[(0,z.jsx)(y,{children:`Symbol Properties`}),(0,z.jsx)(g,{children:`Customize the name, shape, and color of this symbol.`})]}),n&&(0,z.jsxs)(b,{className:`space-y-6`,children:[(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(F,{children:`Label`}),(0,z.jsx)(P,{value:n.data.label,onChange:e=>r({label:e.target.value}),placeholder:`Enter symbol label`,className:`bg-muted/50 border-border text-foreground`})]}),(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(F,{className:`text-xs font-bold text-zinc-300`,children:`Code Logic (JavaScript)`}),(0,z.jsx)(`textarea`,{value:c,onChange:e=>u(e.target.value),placeholder:n.data.shape===`diamond`?`e.g. return context.amount > 100 ? 'Yes' : 'No';`:`e.g. context.status = 'Approved'; context.tries += 1;`,className:`w-full h-24 bg-muted border border-border rounded-md p-2 text-xs font-mono text-foreground placeholder:text-muted-foreground/50 resize-none focus:outline-none focus:border-ring`}),(0,z.jsxs)(`p`,{className:`text-[9px] text-muted-foreground/50 leading-normal`,children:[`Attached sandbox logic. For Decision diamonds, return the matching branch label (case-sensitive). Process symbols can mutate variables in the `,(0,z.jsx)(`code`,{children:`context`}),` object.`]})]}),s&&(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(F,{children:`Group Title`}),(0,z.jsx)(P,{value:n.data.section||``,onChange:e=>r({section:e.target.value||void 0}),onBlur:e=>{let t=e.target.value;t&&o&&!o(t)&&r({section:void 0})},placeholder:`e.g. Pengajuan Cuti`,className:`bg-muted/50 border-border text-foreground`}),(0,z.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50`,children:`Nama grup untuk alur yang dimulai dari sini.`})]}),(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(F,{children:`Shape Type`}),(0,z.jsxs)(k,{value:n.data.shape,onValueChange:e=>e&&r({shape:e}),children:[(0,z.jsx)(D,{className:`w-full bg-muted border-border text-foreground`,children:(0,z.jsx)(O,{placeholder:`Select a shape`,children:n.data.shape?I[n.data.shape]:`Select a shape`})}),(0,z.jsxs)(E,{className:`bg-popover border-border text-popover-foreground`,children:[(0,z.jsx)(T,{value:`rectangle`,children:`Rectangle (Process)`}),(0,z.jsx)(T,{value:`oval`,children:`Oval (Start/End)`}),(0,z.jsx)(T,{value:`diamond`,children:`Diamond (Decision)`}),(0,z.jsx)(T,{value:`parallelogram`,children:`Parallelogram (Input/Output)`}),(0,z.jsx)(T,{value:`database`,children:`Cylinder (Database)`}),(0,z.jsx)(T,{value:`document`,children:`Document`}),(0,z.jsx)(T,{value:`cloud`,children:`Cloud (External System)`}),(0,z.jsx)(T,{value:`circle`,children:`Circle (Connector)`})]})]})]}),(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(F,{children:`Color`}),(0,z.jsx)(`div`,{className:`flex gap-2 flex-wrap`,children:he.map(e=>(0,z.jsx)(`button`,{className:`w-8 h-8 rounded-full border-2 transition-transform hover:scale-110 ${n.data.color===e?`border-white scale-110`:`border-transparent`}`,style:{backgroundColor:e},onClick:()=>r({color:e})},e))})]}),(0,z.jsxs)(`div`,{className:`pt-2 border-t border-border space-y-2`,children:[(0,z.jsxs)(w,{variant:`destructive`,size:`sm`,className:`w-full gap-2`,onClick:()=>{i(),t()},children:[(0,z.jsx)(fe,{className:`size-4`}),`Delete Symbol`]}),s&&n.data.section&&a&&(0,z.jsxs)(w,{variant:`outline`,size:`sm`,className:`w-full gap-2 text-destructive border-destructive/30 hover:bg-destructive/10`,onClick:()=>{a(),t()},children:[(0,z.jsx)(fe,{className:`size-4`}),`Delete Group "`,n.data.section,`"`]})]})]},e)]})})}function Ne({selectedEdgeId:e,onClose:t,selectedEdge:n,isDashed:r,arrowType:i,onEdgeTypeChange:a,onArrowChange:o,onLabelChange:s,onDeleteEdge:c}){return(0,z.jsx)(C,{open:!!e,onOpenChange:e=>{e||t()},children:(0,z.jsxs)(v,{className:`sm:max-w-sm`,children:[(0,z.jsx)(S,{children:(0,z.jsxs)(`div`,{className:`flex items-center justify-between pr-8`,children:[(0,z.jsxs)(`div`,{className:`space-y-1 text-left`,children:[(0,z.jsx)(y,{children:`Connector Properties`}),(0,z.jsx)(g,{children:`Format the line style and arrows.`})]}),(0,z.jsx)(w,{variant:`ghost`,size:`icon`,onClick:c,className:`text-destructive hover:bg-destructive/10 -mr-2 shadow-none`,title:`Delete Connector`,children:(0,z.jsx)(fe,{className:`w-4 h-4`})})]})}),n&&(0,z.jsxs)(b,{className:`space-y-6`,children:[(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(F,{children:`Text Label`}),(0,z.jsx)(P,{value:typeof n.label==`string`?n.label:``,onChange:e=>s(e.target.value),placeholder:`e.g. Yes, No, 1, 2...`,className:`bg-muted border-border text-foreground`})]}),(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(F,{children:`Line Style`}),(0,z.jsxs)(k,{value:r?`dashed`:`solid`,onValueChange:e=>a(e||``),children:[(0,z.jsx)(D,{className:`w-full bg-muted border-border text-foreground`,children:(0,z.jsx)(O,{placeholder:`Select line style`,children:L[r?`dashed`:`solid`]})}),(0,z.jsxs)(E,{className:`bg-popover border-border text-popover-foreground`,children:[(0,z.jsx)(T,{value:`solid`,children:`Solid Line`}),(0,z.jsx)(T,{value:`dashed`,children:`Dashed Line`})]})]})]}),(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsx)(F,{children:`Arrow Style`}),(0,z.jsxs)(k,{value:i,onValueChange:e=>o(e||``),children:[(0,z.jsx)(D,{className:`w-full bg-muted border-border text-foreground`,children:(0,z.jsx)(O,{placeholder:`Select arrow style`,children:we[i]})}),(0,z.jsxs)(E,{className:`bg-popover border-border text-popover-foreground`,children:[(0,z.jsx)(T,{value:`end`,children:`Arrow at End`}),(0,z.jsx)(T,{value:`start`,children:`Arrow at Start (Reverse)`}),(0,z.jsx)(T,{value:`both`,children:`Arrows Both Ends`}),(0,z.jsx)(T,{value:`none`,children:`No Arrows (Line only)`})]})]})]})]})]})})}function Pe({nodes:e,edges:t,onConfirm:n,onCancel:r,confirmLabel:i=`Confirm Append`,canvasGroups:a=[],existingNodes:o=[],existingEdges:s=[]}){let[c,l]=(0,R.useState)(null),u=(0,R.useMemo)(()=>{if(!o.length||!e.length)return null;let n=new Map;for(let e of o)n.set((e.data.label||``).toLowerCase(),e);let r=new Map;for(let t of e)r.set((t.data.label||``).toLowerCase(),t);let i=[];for(let t of e){let e=t.data.label||`Untitled`,r=n.get(e.toLowerCase());if(!r)i.push({type:`header`,label:e,isNew:!0}),i.push({type:`add`,prefix:`+`,field:`shape`,newVal:t.data.shape}),i.push({type:`add`,prefix:`+`,field:`label`,newVal:e}),t.data.color&&i.push({type:`add`,prefix:`+`,field:`color`,newVal:t.data.color});else{let n=r.data.shape!==t.data.shape,a=r.data.color!==t.data.color,o=(r.data.label||``)!==e;(n||a||o)&&(i.push({type:`header`,label:e}),o&&i.push({type:`change`,prefix:`~`,field:`label`,oldVal:r.data.label,newVal:e}),n&&i.push({type:`change`,prefix:`~`,field:`shape`,oldVal:r.data.shape,newVal:t.data.shape}),a&&i.push({type:`change`,prefix:`~`,field:`color`,oldVal:r.data.color,newVal:t.data.color}))}}for(let e of o){let t=e.data.label||``;r.has(t.toLowerCase())||(i.push({type:`header`,label:t,isNew:!1}),i.push({type:`remove`,prefix:`-`,field:`shape`,oldVal:e.data.shape}),i.push({type:`remove`,prefix:`-`,field:`removed`,oldVal:`entire node`}))}let a=new Set(s.map(e=>{let t=o.find(t=>t.id===e.source)?.data.label||e.source,n=o.find(t=>t.id===e.target)?.data.label||e.target;return`${t.toLowerCase()}→${n.toLowerCase()}`})),c=new Set(t.map(t=>{let n=e.find(e=>e.id===t.source)?.data.label||t.source,r=e.find(e=>e.id===t.target)?.data.label||t.target;return`${n.toLowerCase()}→${r.toLowerCase()}`})),l=[...c].filter(e=>!a.has(e)),u=[...a].filter(e=>!c.has(e));if(l.length>0||u.length>0){i.push({type:`header`,label:`Connections`});for(let e of l)i.push({type:`add`,prefix:`+`,field:`connection`,newVal:e});for(let e of u)i.push({type:`remove`,prefix:`-`,field:`connection`,oldVal:e})}return i.length>0?i:null},[o,s,e,t]);return(0,z.jsxs)(C,{open:!0,onOpenChange:e=>{e||r()},children:[(0,z.jsx)(ne,{}),(0,z.jsxs)(v,{size:`2xl`,showCloseButton:!0,children:[(0,z.jsx)(S,{children:(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsx)(`div`,{className:`size-8 rounded-lg bg-indigo-500/10 flex items-center justify-center`,children:(0,z.jsx)(Te,{className:`size-4 text-indigo-400`})}),(0,z.jsx)(`div`,{children:(0,z.jsx)(y,{children:`Preview Changes`})})]})}),(0,z.jsx)(b,{children:(0,z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[e.length>0&&(0,z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,z.jsxs)(`label`,{className:`text-[11px] font-medium text-muted-foreground`,children:[`New Symbols (`,e.length,`)`]}),(0,z.jsx)(`div`,{className:`max-h-75 overflow-y-auto custom-scrollbar space-y-2`,children:e.map(e=>(0,z.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-muted overflow-hidden`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5 px-3 py-2 border-b border-border/20 bg-muted/50`,children:[(0,z.jsx)(Te,{className:`size-3 text-indigo-400 shrink-0`}),(0,z.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground`,children:e.data.label}),(0,z.jsx)(`span`,{className:`text-[9px] text-muted-foreground ml-auto`,children:e.data.shape})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 text-[10px] font-mono`,children:[(0,z.jsx)(`span`,{className:`text-gray-500`,children:`Shape:`}),(0,z.jsx)(`span`,{className:`text-gray-300`,children:e.data.shape}),e.data.color&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`text-gray-500 ml-2`,children:`Color:`}),(0,z.jsx)(`span`,{className:`text-gray-300`,children:e.data.color})]})]})]},e.id))})]}),u&&(0,z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,z.jsx)(`label`,{className:`text-[11px] font-medium text-muted-foreground`,children:`Changes`}),(0,z.jsx)(`div`,{className:`rounded-lg border border-border/40 overflow-hidden max-h-75 overflow-y-auto custom-scrollbar text-[10px] font-mono leading-relaxed`,children:(0,z.jsx)(`div`,{className:`divide-y divide-border/10`,children:u.map((e,t)=>{if(e.type===`header`)return(0,z.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 bg-muted border-b border-border/30`,children:[e.isNew&&(0,z.jsx)(`span`,{className:`text-[8px] font-semibold px-1 py-0.5 rounded bg-emerald-500/15 text-emerald-400 border border-emerald-500/30 shrink-0`,children:`NEW`}),(0,z.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground`,children:e.label})]},t);let n=e.type===`add`,r=e.type===`remove`,i=e.type===`change`,a=n?`bg-emerald-900/20`:r?`bg-red-900/20`:i?`bg-amber-900/20`:``,o=n?`text-emerald-400`:r?`text-red-400`:`text-amber-400`,s=n?`text-emerald-300`:r?`text-red-400`:`text-amber-300`,c=n?`text-emerald-400/60`:r?`text-red-400/60`:`text-amber-400/60`;return(0,z.jsxs)(`div`,{className:`flex items-center gap-1 px-3 py-0.5 ${a}`,children:[(0,z.jsx)(`span`,{className:`w-4 shrink-0 select-none ${o}`,children:e.prefix}),(0,z.jsx)(`span`,{className:`w-20 shrink-0 ${c}`,children:e.field}),e.oldVal&&(0,z.jsx)(`span`,{className:`text-red-400/70 line-through`,children:e.oldVal}),e.oldVal&&e.newVal&&(0,z.jsx)(`span`,{className:`text-gray-600`,children:`→`}),e.newVal&&(0,z.jsx)(`span`,{className:s,children:e.newVal})]},t)})})})]}),!u&&!e.length&&(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No changes detected.`})]})}),(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-6 pt-4 pb-6`,children:[(0,z.jsx)(`div`,{className:`flex items-center gap-3`,children:a.length>0&&(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(oe,{className:`size-3.5 text-muted-foreground shrink-0`}),(0,z.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Replace:`}),(0,z.jsxs)(k,{value:c??``,onValueChange:e=>l(e||null),children:[(0,z.jsx)(D,{className:`h-7 text-[12px]`,children:(0,z.jsx)(O,{placeholder:`All Symbols`})}),(0,z.jsxs)(E,{children:[(0,z.jsx)(T,{value:``,children:`All Symbols`}),a.map(e=>(0,z.jsx)(T,{value:e,children:e},e))]})]})]})}),(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsxs)(w,{variant:`outline`,size:`sm`,onClick:r,className:`gap-2`,children:[(0,z.jsx)(_,{className:`size-4`}),`Cancel`]}),(0,z.jsxs)(w,{size:`sm`,onClick:()=>n(c||void 0),className:`gap-2`,children:[(0,z.jsx)(A,{className:`size-4`}),i]})]})]})]})]})}function V(e){return[{x:e.x+80,y:e.y},{x:e.x+80,y:e.y+70},{x:e.x,y:e.y+35},{x:e.x+160,y:e.y+35}]}function H(e,t){return V(e)[[`top`,`bottom`,`left`,`right`].indexOf(t)]}function Fe(e,t){let n=[`top`,`bottom`,`left`,`right`],r=V(e.position),i=V(t.position),a=1/0,o=0,s=0;for(let e=0;e<4;e++)for(let t=0;t<4;t++){let n=r[e].x-i[t].x,c=r[e].y-i[t].y,l=n*n+c*c;l<a&&(a=l,o=e,s=t)}return{sourceHandle:n[o],targetHandle:n[s]}}function Ie(e,t,n,r){if(t===`bottom`||t===`top`||r===`bottom`||r===`top`){let t=(e.y+n.y)/2;return`M${e.x},${e.y} L${e.x},${t} L${n.x},${t} L${n.x},${n.y}`}let i=(e.x+n.x)/2;return`M${e.x},${e.y} L${i},${e.y} L${i},${n.y} L${n.x},${n.y}`}function Le(e,t,n){switch(e){case`diamond`:return`<polygon points="80,2 158,35 80,68 2,35" fill="url(#grad-${n})" stroke="${t}" stroke-width="2" stroke-linejoin="round" filter="url(#shadow)" />`;case`parallelogram`:return`<polygon points="32,2 158,2 128,68 2,68" fill="url(#grad-${n})" stroke="${t}" stroke-width="2" stroke-linejoin="round" filter="url(#shadow)" />`;case`oval`:return`<ellipse cx="80" cy="35" rx="78" ry="33" fill="url(#grad-${n})" stroke="${t}" stroke-width="2" filter="url(#shadow)" />`;case`circle`:return`<circle cx="80" cy="35" r="33" fill="url(#grad-${n})" stroke="${t}" stroke-width="2" filter="url(#shadow)" />`;case`database`:return`<g>
|
|
2
2
|
<path d="M2,14 L2,56 C2,68 158,68 158,56 L158,14" fill="url(#grad-${n})" stroke="${t}" stroke-width="2" stroke-linejoin="round" filter="url(#shadow)" />
|
|
3
3
|
<ellipse cx="80" cy="14" rx="78" ry="10.5" fill="${t}30" stroke="${t}" stroke-width="2" filter="url(#shadow)" />
|
|
4
4
|
<path d="M2,35 C2,45.5 158,45.5 158,35" fill="none" stroke="${t}" stroke-width="2" opacity="0.3" />
|
|
@@ -34,4 +34,4 @@ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t,t as n}from"./j
|
|
|
34
34
|
${s}
|
|
35
35
|
</g>`}).join(`
|
|
36
36
|
`)}
|
|
37
|
-
</svg>`}function W(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}var Re={custom:ke},G={type:`smoothstep`,style:{stroke:`#b1b1b7`},markerEnd:{type:te.ArrowClosed,color:`#b1b1b7`}};function ze({nodes:e,edges:t,filename:n,onCancel:r}){let{resolvedTheme:i}=me(),a=i===`dark`?`#222`:`#ccc`,[c]=(0,R.useState)(e),[l]=(0,R.useState)(t),f=(0,R.useCallback)(()=>{},[]),m=(0,R.useCallback)(()=>{},[]),ee=(0,R.useCallback)(()=>{let e=U(c,l);if(!e){h.error(`No nodes to export`);return}p(e,n),h.success(`Flowchart exported as SVG`),r()},[c,l,n,r]);return(0,z.jsx)(C,{open:!0,onOpenChange:e=>{e||r()},children:(0,z.jsxs)(v,{className:`sm:max-w-3xl h-[600px]`,children:[(0,z.jsx)(S,{children:(0,z.jsx)(y,{children:`Export Flowchart`})}),(0,z.jsxs)(b,{className:`flex-1 flex flex-col min-h-0`,children:[(0,z.jsx)(`div`,{className:`flex-1 rounded-lg border border-border overflow-hidden bg-muted/10 mb-4 relative`,children:(0,z.jsx)(s,{children:(0,z.jsx)(u,{nodes:c,edges:l,onNodesChange:f,onEdgesChange:m,nodeTypes:Re,defaultEdgeOptions:G,fitView:!0,colorMode:i,onlyRenderVisibleElements:!0,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,minZoom:.1,maxZoom:2.5,panOnDrag:!1,zoomOnScroll:!1,zoomOnPinch:!1,zoomOnDoubleClick:!1,children:(0,z.jsx)(d,{variant:o.Lines,gap:50,size:1,color:a})})})}),(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,z.jsx)(`div`,{className:`flex items-center gap-1.5`,children:(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:`Preview`})}),(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsxs)(w,{variant:`outline`,onClick:r,className:`gap-2`,children:[(0,z.jsx)(_,{className:`size-4`}),`Cancel`]}),(0,z.jsxs)(w,{onClick:ee,className:`gap-2`,children:[(0,z.jsx)(j,{className:`size-4`}),`Download SVG`]})]})]})]})]})})}var Be=80,Ve=80,He=240,Ue=150,K=64,We=72;function q(e){return(e||``).trim().toLowerCase()}function J(e){let t=q(e.data.label);return t.includes(`start`)||t.includes(`begin`)}function Y(e){let t=q(e.data.label);return t.includes(`end`)||t.includes(`finish`)||t.includes(`done`)||t.includes(`stop`)}function Ge(e){return e.data.shape===`diamond`}function Ke(e){let t=(e.data.label||``).trim().length,n=e.data.shape,r=(()=>{switch(n){case`diamond`:return{width:130,height:130,wrap:12};case`circle`:return{width:110,height:110,wrap:10};case`cloud`:return{width:170,height:96,wrap:16};case`database`:return{width:150,height:104,wrap:16};case`parallelogram`:return{width:170,height:86,wrap:16};case`document`:return{width:150,height:96,wrap:16};case`oval`:return{width:150,height:84,wrap:15};default:return{width:150,height:84,wrap:16}}})(),i=Math.max(0,Math.ceil(t/r.wrap)-1)*18,a=n===`diamond`?Math.min(48,Math.max(0,t-r.wrap)*3):Math.min(64,Math.max(0,t-r.wrap*1.5)*2.5);return{width:r.width+a,height:r.height+i}}function qe(e){let t=Ke(e);return{x:e.position.x+t.width/2,y:e.position.y+t.height/2}}function Je(e){switch(e){case`top`:return`bottom`;case`bottom`:return`top`;case`left`:return`right`;case`right`:return`left`}}function Ye(e,t,n){let r=q(n);if(Ge(e)){if(r===`yes`)return`right`;if(r===`no`)return`left`}let i=qe(e),a=qe(t),o=a.x-i.x,s=a.y-i.y;return Math.abs(o)>Math.abs(s)*1.05?o>=0?`right`:`left`:s>=0?`bottom`:`top`}function Xe(e,t,n){let r=Ye(e,t,n);return{sourceHandle:r,targetHandle:Je(r)}}function Ze(e,t,n,r){let i=[...t];return Ge(e)?(i.sort((t,i)=>{let a=q(n.get(`${e.id}->${t}`)),o=q(n.get(`${e.id}->${i}`)),s=a===`yes`?0:a===`no`?1:2,c=o===`yes`?0:o===`no`?1:2;if(s!==c)return s-c;let l=r.get(t),u=r.get(i),d=J(l)?-1:+!!Y(l),f=J(u)?-1:+!!Y(u);return d===f?(l?.data.label||``).localeCompare(u?.data.label||``):d-f}),i):(i.sort((e,t)=>{let n=r.get(e),i=r.get(t),a=J(n)?-1:+!!Y(n),o=J(i)?-1:+!!Y(i);return a===o?(n?.data.label||``).localeCompare(i?.data.label||``):a-o}),i)}function Qe(e,t,n,r){let i=Math.round(n),a=n=>{let r=e.get(t);return!r||!r.has(n)?n:null},o=r===0?1:r,s=[0];for(let e=1;e<=40;e++)r===0?s.push(e,-e):s.push(e*o,-e*o);for(let e of s){let t=a(i+e);if(t!=null)return t}return i}function X(e){let t=[];for(let n=0;n<e;n++)if(n===0)t.push(1);else if(n===1)t.push(-1);else{let e=Math.ceil(n/2);t.push(n%2==0?e+1:-(e+1))}return t}function $e(e,t){if(e.length===0)return{nodes:[],edges:[]};let n=new Map(e.map(e=>[e.id,e])),r=new Map,i=new Map,a=new Map;for(let t of e)r.set(t.id,[]),i.set(t.id,[]);for(let e of t){let t=e.source,n=e.target;!r.has(t)||!i.has(n)||(r.get(t).push(n),i.get(n).push(t),a.set(`${t}->${n}`,e.label?String(e.label):``))}let o=e.filter(e=>i.get(e.id)?.length===0&&J(e)).map(e=>e.id);if(o.length===0){let t=e.filter(e=>i.get(e.id)?.length===0).map(e=>e.id);t.length>0&&o.push(...t)}o.length===0&&e.length>0&&o.push(e[0].id);let s=new Set,c=new Set,l=new Set;function u(e){s.add(e),c.add(e);for(let t of r.get(e)||[])c.has(t)?l.add(`${e}->${t}`):s.has(t)||u(t);c.delete(e)}for(let e of o)s.has(e)||u(e);for(let t of e)s.has(t.id)||u(t.id);let d=new Map;function f(e){if(d.has(e))return d.get(e);let t=(i.get(e)||[]).filter(t=>!l.has(`${t}->${e}`));if(t.length===0)return d.set(e,0),0;let n=Math.max(...t.map(f))+1;return d.set(e,n),n}let p=new Map;for(let t of e){let e=f(t.id);p.has(e)||p.set(e,[]),p.get(e).push(t.id)}let m=new Map,ee=0;for(let t of e){let e=Ke(t);ee=Math.max(ee,e.width);let n=f(t.id),r=m.get(n)||0;m.set(n,Math.max(r,e.height))}let h=Math.max(ee+K,He),g=new Map,ne=[...p.keys()].sort((e,t)=>e-t);for(let e of ne){let t=m.get(e)||0;g.set(e,Math.max(t+We,Ue))}let _=new Map,v=new Map,y=new Map;function b(e,t){v.has(e)||v.set(e,new Set),v.get(e).add(t)}function x(e,t,n=0){let r=f(e),i=Qe(v,r,t,n);return _.set(e,i),b(r,i),i}function S(e,t,i=0){if(_.has(e))return;let o=x(e,t,y.get(e)??i),s=n.get(e);if(!s)return;let c=(r.get(e)||[]).filter(t=>!l.has(`${e}->${t}`));if(c.length===0)return;let u=Ze(s,c,a,n);if(Ge(s)){let t=u.find(t=>q(a.get(`${e}->${t}`))===`yes`),n=u.find(t=>q(a.get(`${e}->${t}`))===`no`),r=u.filter(e=>e!==t&&e!==n);t&&(y.set(t,1),S(t,o+1,1)),n&&(y.set(n,-1),S(n,o-1,-1));let i=r,s=X(i.length);i.forEach((e,t)=>{let n=s[t],r=n>0?1:n<0?-1:0;y.set(e,r),S(e,o+n,r)});return}if(u.length===1){let e=u[0];y.has(e)||y.set(e,0),S(e,o,y.get(e)??0);return}let d=X(u.length);u.forEach((e,t)=>{let n=d[t],r=n>0?1:n<0?-1:0;y.has(e)||y.set(e,r),S(e,o+n,r)})}let C=[...o].sort((e,t)=>{let r=n.get(e)?.data.label||``,i=n.get(t)?.data.label||``,a=J(n.get(e))?-1:0,o=J(n.get(t))?-1:0;return a===o?r.localeCompare(i):a-o}),w=C.length===1?[0]:[0,1,-1,2,-2,3,-3];C.forEach((e,t)=>{let n=w[t]??0;y.has(e)||y.set(e,0),S(e,n*2,0)});for(let t of e)if(!_.has(t.id)){let e=(i.get(t.id)||[]).filter(e=>_.has(e)),n=e.length>0?e.reduce((e,t)=>e+(_.get(t)||0),0)/e.length:0,r=e.length>0?Math.sign(e.reduce((e,t)=>e+(y.get(t)||0),0)):0;S(t.id,n,r)}for(let t of e){let e=(i.get(t.id)||[]).filter(e=>_.has(e));if(e.length>=2){let n=e.map(e=>_.get(e)||0),r=n.reduce((e,t)=>e+t,0)/n.length,i=Math.round(r),a=f(t.id),o=_.get(t.id);o!=null&&o!==i&&!v.get(a)?.has(i)&&(v.get(a)?.delete(o),b(a,i),_.set(t.id,i))}}let T=Math.min(..._.values(),0),E=new Map;for(let[e,t]of _)E.set(e,t-T);let D=Ve,O=new Map;for(let e of ne)O.set(e,D),D+=(g.get(e)||Ue)+18;let k=e.map(e=>{let t=f(e.id),n=Ke(e),r=E.get(e.id)??0;return{...e,position:{x:Be+r*h,y:O.get(t)??Ve},style:{...e.style,width:n.width,height:n.height}}}),A=new Map(k.map(e=>[e.id,e]));return{nodes:k,edges:t.map((e,t)=>{let n=A.get(e.source),r=A.get(e.target);if(!n||!r)return e;let i=Xe(n,r,e.label?String(e.label):``);return{...e,id:e.id||`flowchart_edge_${t}`,sourceHandle:i.sourceHandle,targetHandle:i.targetHandle,type:e.type||`smoothstep`,markerEnd:e.markerEnd||{type:te.ArrowClosed,color:`#b1b1b7`}}})}}var et={custom:ke},tt=R.memo(({activeFlowchartId:e,activeFlowchart:t,handleFlowchartChange:n,isReadOnly:i=!1,isLoading:s=!1,saveFlowchart:f,triggerDebouncedSync:p,companionMode:m=!1,commentsEnabled:g=!1})=>{let{registerContentHandler:ne,setActionContextData:_}=re(),[v,y,b]=a([]),[x,S,C]=c([]),[A,j]=(0,R.useState)(null),[M,N]=(0,R.useState)(null),[ie,ae]=(0,R.useState)(null),[oe,fe]=(0,R.useState)(null),[P,F]=(0,R.useState)({x:0,y:0,zoom:1}),[he,I]=(0,R.useState)(!1),[Ce,L]=(0,R.useState)(null),[we,Te]=(0,R.useState)(null),[De,ke]=(0,R.useState)({label:`New Symbol`,shape:`rectangle`,color:`#8b5cf6`}),Ae=R.useRef(!0),B=R.useRef(!1),V=R.useRef(!1),H=R.useRef(!1),Fe=R.useRef(e),Ie=R.useRef(!1),Le=R.useRef(!1),U=R.useRef(v),W=R.useRef(x),Re=R.useRef(new Set),{takeSnapshot:G,undo:Be,redo:Ve,canUndo:He,canRedo:Ue}=l(),K=R.useRef(`append`),We=(0,R.useCallback)(()=>{if(v.length===0)return;let e=$e(v,x);G(U.current,W.current),y(e.nodes),S(e.edges)},[v,x,y,S,G]);U.current=v,W.current=x;let q=e=>{if(!e)return null;if(typeof e==`object`)return e;if(typeof e!=`string`)return null;try{return JSON.parse(e)}catch{return null}},J=s&&(!t||!t.data);(0,R.useEffect)(()=>{B.current=!0,Ae.current=!0;try{let n=q(t.data)||{nodes:[],edges:[]},r=localStorage.getItem(`pending_create_flowchart_json`)||localStorage.getItem(`pending_update_flowchart_json`),i=n.nodes&&n.nodes.length>0?n.nodes:r||H.current?[]:be,a=n.edges&&n.edges.length>0?n.edges:r||H.current?[]:ye;H.current||(y(i),S(a)),Fe.current!==e&&(Fe.current=e,H.current=!1,j(null),N(null))}catch{let e=localStorage.getItem(`pending_create_flowchart_json`)||localStorage.getItem(`pending_update_flowchart_json`);H.current||(y(e?[]:be),S(e?[]:ye))}let n=setTimeout(()=>{B.current=!1,Ae.current=!1},2e3);return()=>{clearTimeout(n),B.current=!1}},[e,t.data]);let Y=R.useRef(n);(0,R.useEffect)(()=>{Y.current=n},[n]),(0,R.useEffect)(()=>{Ae.current||B.current||V.current||Ie.current||Le.current||(v.length>0||x.length>0)&&Y.current(v,x)},[v,x]);let Ge=(0,R.useCallback)(()=>{V.current=!0},[]),Ke=(0,R.useCallback)(()=>{V.current=!1,(U.current.length>0||W.current.length>0)&&Y.current(U.current,W.current)},[]),qe=(0,R.useMemo)(()=>({type:`smoothstep`,reconnectable:!0,style:{stroke:`#b1b1b7`},markerEnd:{type:te.ArrowClosed,color:`#b1b1b7`}}),[]),Je=(0,R.useCallback)(e=>{G(U.current,W.current),S(t=>ee({...e,type:`smoothstep`,style:{stroke:`#b1b1b7`},markerEnd:{type:te.ArrowClosed,color:`#b1b1b7`},animated:!1},t))},[S,G]),Ye=(0,R.useCallback)((e,t)=>{S(n=>n.map(n=>n.id===e.id?{...n,source:t.source,target:t.target,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle}:n)),G(U.current,W.current)},[S,G]),Xe=()=>{G(U.current,W.current);let e=Math.random().toString(36).substring(2,11),t={...De};t.label.trim().toLowerCase()===`start`&&!t.groupId&&(t.groupId=`grp_${Math.random().toString(36).substring(2,8)}`);let n={id:e,type:`custom`,position:{x:window.innerWidth/2-200,y:window.innerHeight/2-100},data:t};y(e=>e.concat(n)),I(!1)},Ze=e=>{A&&(G(U.current,W.current),y(t=>t.map(t=>t.id===A?{...t,data:{...t.data,...e}}:t)))},Qe=(0,R.useCallback)(e=>{let t=e.trim();return!t||!v.some(e=>e.id!==A&&e.data.section?.toLowerCase()===t.toLowerCase())||(h.error(`Group title already exists`,{description:`Another group is already named "${t}". Each group must have a unique title.`}),!1)},[v,A]),X=e=>{M&&(G(U.current,W.current),S(t=>t.map(t=>t.id===M?{...t,...e}:t)))},tt=()=>{if(!A)return;G(U.current,W.current);let e=[A];y(t=>t.filter(t=>!e.includes(t.id))),S(t=>t.filter(t=>!e.includes(t.source)&&!e.includes(t.target))),j(null)},nt=()=>{let e=v.find(e=>e.id===A);if(!e||!e.data.section)return;G(U.current,W.current);let t=e.data.section,n=v.filter(e=>e.data.section===t).map(e=>e.id);if(n.length===0)return;let r=new Set(n),i=[...n];for(;i.length>0;){let e=i.shift();for(let t of x)t.source===e&&!r.has(t.target)&&(r.add(t.target),i.push(t.target))}let a=[...r];y(e=>e.filter(e=>!a.includes(e.id))),S(e=>e.filter(e=>!a.includes(e.source)&&!a.includes(e.target))),j(null)},rt=()=>{M&&(G(U.current,W.current),S(e=>e.filter(e=>e.id!==M)),N(null))},it=R.useRef(M),at=R.useRef(A);(0,R.useEffect)(()=>{Ie.current=M!==null,Le.current=A!==null;let e=it.current!==null&&M===null,t=at.current!==null&&A===null;it.current=M,at.current=A,(e||t)&&!Ae.current&&!B.current&&(v.length>0||x.length>0)&&Y.current(v,x)},[M,A]),(0,R.useEffect)(()=>{let e=e=>{if(i)return;let t=e.target;if(!(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.isContentEditable)&&!t.hasAttribute?.(`data-keyboard-trap`)&&(e.key===`Delete`||e.key===`Backspace`)){if(A){tt();return}if(M){rt();return}}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[A,M,i]);let ot=v.find(e=>e.id===A),Z=x.find(e=>e.id===M),st=Z?.animated===!0||Z?.style?.strokeDasharray===`5,5`,ct=`end`;Z?.markerStart&&Z?.markerEnd?ct=`both`:Z?.markerStart&&!Z?.markerEnd?ct=`start`:!Z?.markerStart&&!Z?.markerEnd&&(ct=`none`);let lt=e=>{X(e===`dashed`?{animated:!1,style:{...Z?.style,strokeDasharray:`5,5`}}:{animated:!1,style:{...Z?.style,strokeDasharray:void 0}})},ut=e=>{let t=Z?.style?.stroke||`#b1b1b7`,n={type:te.ArrowClosed,color:t};e===`none`?X({markerStart:void 0,markerEnd:void 0}):e===`start`?X({markerStart:n,markerEnd:void 0}):e===`end`?X({markerStart:void 0,markerEnd:n}):e===`both`&&X({markerStart:n,markerEnd:n})},dt=e=>{e.trim()===``?X({label:void 0}):X({label:e,labelBgStyle:{fill:`var(--popover)`},labelStyle:{fill:`var(--popover-foreground)`}})},{setFlowchartExportHandler:ft,resolvedTheme:pt}=me(),mt=pt===`dark`?`#222`:`#ccc`,ht=e=>{let n=t?.title?.replace(/[^a-zA-Z0-9_-]/g,`_`)||`flowchart`;return e?`${n}-${e}`:n},gt=(0,R.useCallback)(()=>{let e=U.current,t=W.current;if(e.length===0){h.error(`No nodes to export`);return}Te({nodes:e,edges:t,filename:ht()})},[]),_t=(0,R.useCallback)(e=>{let t=new Set(U.current.filter(t=>t.data.section===e).map(e=>e.id));if(t.size===0){h.error(`No nodes found in group "${e}"`);return}let n=[...t],r=new Set(n),i=[...n];for(;i.length>0;){let e=i.shift();for(let t of W.current)t.source===e&&!r.has(t.target)&&(r.add(t.target),i.push(t.target))}let a=U.current.filter(e=>r.has(e.id)),o=W.current.filter(e=>r.has(e.source)&&r.has(e.target));if(a.length===0){h.error(`No nodes to export`);return}Te({nodes:a,edges:o,filename:ht(e)})},[]),vt=(0,R.useMemo)(()=>v.map(e=>e.data.section).filter(e=>!!e).filter((e,t,n)=>n.indexOf(e)===t),[v]);(0,R.useEffect)(()=>{if(!m)return ft({exportAll:gt,exportGroup:_t,groups:vt}),()=>ft(null)},[m,gt,_t,vt,ft]);let yt=(0,R.useMemo)(()=>{if(!oe)return Re.current;let e=v.filter(e=>e.data.section===oe).map(e=>e.id);if(e.length===0)return Re.current;let t=new Set(e),n=[...e],r=0;for(;r<n.length;){let e=n[r++];for(let r of x)r.source===e&&!t.has(r.target)&&(t.add(r.target),n.push(r.target))}return t},[oe,v,x]),Q=(0,R.useMemo)(()=>{if(yt.size===0)return null;let e=1/0,t=1/0,n=-1/0,r=-1/0;for(let i of v)if(yt.has(i.id)){let a=i.position.x,o=i.position.y;e=Math.min(e,a),t=Math.min(t,o),n=Math.max(n,a+160),r=Math.max(r,o+70)}return e===1/0?null:{x:e-14,y:t-14,width:n-e+28,height:r-t+28}},[yt,v]),bt=(0,R.useMemo)(()=>v.map(e=>{let t=e.id===A,n=yt.has(e.id),r=t||n,a=g&&!i&&!m;return!!e.selected===r&&e.data._commentsEnabled===a?e:{...e,selected:r,data:{...e.data,_commentsEnabled:a}}}),[m,g,i,v,A,yt]),xt=(0,R.useCallback)(e=>{let t=e.filter(e=>e.type!==`select`);t.length!==0&&b(t)},[b]),St=(0,R.useCallback)(e=>{let t=e.filter(e=>e.type!==`select`);t.length!==0&&C(t)},[C]);(0,R.useEffect)(()=>{if(m||V.current)return;let e=setTimeout(()=>{_({nodes:U.current,edges:W.current})},500);return()=>clearTimeout(e)},[m,v,x,_]);let $=R.useRef(null),Ct=R.useRef(null);(0,R.useEffect)(()=>{if(!m)return ne((e,t,n)=>{try{if(Ct.current=n||null,n===`flowchart-insert`){let t=ge(U.current,W.current,e);if(t&&t.nodes.length>0){$.current=e,K.current=`insert`,L(t);return}}if(n===`flowchart-import`){let t=_e(e);if(t&&t.nodes.length>0){$.current=e,K.current=`replace`,L(t);return}}if(t===`append`){let t=_e(e);if(t&&t.nodes.length>0){$.current=e,K.current=`append`,L(t);return}}if(t===`replace`){let t=_e(e);if(t&&t.nodes.length>0){$.current=e,K.current=`replace`,L(t);return}}$.current||h.error(`Could not parse flowchart data. The response may be too large or in an unsupported format.`)}catch(e){console.error(`Flowchart content handler error:`,e),h.error(`Failed to apply AI content to flowchart`)}},[`append`,`replace`])},[m,ne,y,S,G]),(0,R.useEffect)(()=>{if(m)return;let e=localStorage.getItem(`pending_create_flowchart_json`);if(e){localStorage.removeItem(`pending_create_flowchart_json`);let r=_e(e);if(r&&r.nodes.length>0){H.current=!0,G(U.current,W.current),y(r.nodes),S(r.edges);let e=JSON.stringify({nodes:r.nodes,edges:r.edges});f&&t?f({...t,data:e}).then(()=>{p?.()}).catch(e=>{console.error(`Error saving generated flowchart:`,e)}):n(r.nodes,r.edges),h.success(`Applied generated architecture Flowchart to new canvas`)}}let r=localStorage.getItem(`pending_update_flowchart_json`);if(r){localStorage.removeItem(`pending_update_flowchart_json`);let e=_e(r);if(e&&e.nodes.length>0){H.current=!0,G(U.current,W.current),y(e.nodes),S(e.edges);let r=JSON.stringify({nodes:e.nodes,edges:e.edges});f&&t?f({...t,data:r}).then(()=>{p?.()}).catch(e=>{console.error(`Error updating flowchart:`,e)}):n(e.nodes,e.edges),h.success(`Updated Flowchart with AI-generated content`)}}},[m,y,S,G,n,f,t,p]);let wt=(0,R.useCallback)(e=>{let t=$.current;if(t){if(G(U.current,W.current),e){let n=U.current.filter(t=>t.data.section===e).map(e=>e.id),r=new Set(n),i=[...n];for(;i.length>0;){let e=i.shift();for(let t of W.current)t.source===e&&!r.has(t.target)&&(r.add(t.target),i.push(t.target))}let a=[...r];y(e=>{let n=e.filter(e=>!a.includes(e.id)),r=Ee(t);return r?[...n,...r.nodes]:e}),S(e=>{let n=e.filter(e=>!a.includes(e.source)&&!a.includes(e.target)),r=Ee(t);return r?[...n,...r.edges]:e})}else if(K.current===`replace`){let e=Ee(t);e&&(y(e.nodes),S(e.edges))}else if(K.current===`insert`){let e=ge(U.current,W.current,t);e&&(y(e.nodes),S(e.edges))}else{let e=Se(U.current,W.current,t);e&&(y(e.nodes),S(e.edges))}L(null),$.current=null,ve()}},[y,S,G]),Tt=(0,R.useMemo)(()=>x.map(e=>{let t=e.id===ie,n=e.id===M,r=e;if(!t&&!n)return r;let i=e=>{if(e)return typeof e==`string`?e:{...e,color:`#ffffff`,width:14,height:14}},a=n?{...r.style||{},stroke:`#ffffff`,strokeWidth:2.5}:r.style;return{...r,style:a,markerEnd:n?i(r.markerEnd):r.markerEnd,markerStart:n?i(r.markerStart):r.markerStart}}),[x,ie,M]);return J?(0,z.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center border rounded-xl bg-muted/10`,children:[(0,z.jsx)(xe,{className:`w-6 h-6 text-primary animate-spin`}),(0,z.jsx)(`p`,{className:`mt-4 text-sm font-medium text-muted-foreground animate-pulse`,children:`Loading flowchart...`})]}):(0,z.jsxs)(pe,{className:`w-full h-full border rounded-xl bg-muted/20 flex flex-col overflow-hidden relative py-0`,children:[!i&&(0,z.jsx)(`div`,{className:`absolute top-6 inset-x-0 z-10 flex justify-center pointer-events-none`,children:(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5 p-1.5 bg-background/95 backdrop-blur-md border border-border/50 rounded-2xl shadow-2xl pointer-events-auto max-w-[95vw] overflow-x-auto no-scrollbar`,children:[(0,z.jsx)(Oe,{nodes:v,label:`Symbol`}),vt.length>0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`w-px h-6 bg-border mx-0.5`}),(0,z.jsxs)(k,{value:oe??``,onValueChange:e=>{fe(e||null),j(null)},children:[(0,z.jsxs)(D,{className:`h-9 min-w-[130px] border-none bg-transparent hover:bg-muted px-2 text-xs font-medium cursor-pointer [&>svg]:text-muted-foreground`,title:`Select a group to move`,children:[(0,z.jsx)(se,{className:`w-3.5 h-3.5 mr-1 text-muted-foreground shrink-0`}),(0,z.jsx)(O,{placeholder:`Move Group`})]}),(0,z.jsx)(E,{className:`bg-popover border-border text-popover-foreground min-w-[150px]`,children:vt.map(e=>(0,z.jsx)(T,{value:e,className:`focus:bg-muted text-xs`,children:e},e))})]})]}),(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`w-px h-6 bg-border mx-0.5`}),(0,z.jsxs)(w,{onClick:We,variant:`outline`,size:`sm`,className:`h-9 px-3 border-border hover:bg-muted bg-muted/50 text-xs font-semibold cursor-pointer`,children:[(0,z.jsx)(le,{className:`w-3.5 h-3.5 sm:mr-1.5`}),(0,z.jsx)(`span`,{className:`hidden sm:inline`,children:`Auto Layout`})]}),(0,z.jsx)(`div`,{className:`w-px h-6 bg-border mx-0.5`}),(0,z.jsxs)(w,{onClick:()=>I(!0),size:`sm`,className:`h-9 px-3 sm:px-4 font-bold shadow-lg shadow-primary/20 cursor-pointer`,children:[(0,z.jsx)(de,{className:`w-4 h-4 sm:mr-2`}),(0,z.jsx)(`span`,{className:`hidden sm:inline`,children:`Add Symbol`})]})]}),(0,z.jsx)(`div`,{className:`w-px h-6 bg-border mx-0.5`}),(0,z.jsx)(w,{onClick:()=>Be(U.current,W.current),disabled:!He,size:`sm`,variant:`ghost`,className:`h-9 w-9 p-0 cursor-pointer`,title:`Undo`,children:(0,z.jsx)(ue,{className:`w-4 h-4`})}),(0,z.jsx)(w,{onClick:()=>Ve(U.current,W.current),disabled:!Ue,size:`sm`,variant:`ghost`,className:`h-9 w-9 p-0 cursor-pointer`,title:`Redo`,children:(0,z.jsx)(ce,{className:`w-4 h-4`})})]})}),(0,z.jsxs)(`div`,{className:`flex-1 w-full h-full relative`,children:[(0,z.jsxs)(u,{nodes:bt,edges:Tt,onNodesChange:xt,onEdgesChange:St,onConnect:Je,onReconnect:Ye,defaultEdgeOptions:qe,onNodeDragStart:Ge,onNodeDragStop:Ke,nodeTypes:et,onNodeClick:(e,t)=>j(t.id),onEdgeClick:(e,t)=>N(t.id),onEdgeMouseEnter:(e,t)=>ae(t.id),onEdgeMouseLeave:()=>ae(null),onPaneClick:()=>{j(null),N(null),fe(null)},fitView:!0,colorMode:pt,onlyRenderVisibleElements:!0,nodesDraggable:!i,nodesConnectable:!i,elementsSelectable:!i,minZoom:.1,maxZoom:2.5,onMove:(e,t)=>F(t),children:[(0,z.jsx)(r,{className:`bg-background/95 border-border shadow-md`,showInteractive:!i}),(0,z.jsx)(d,{variant:o.Lines,gap:50,size:1,color:mt})]}),Q&&(0,z.jsx)(`svg`,{className:`absolute inset-0 pointer-events-none`,style:{overflow:`visible`},children:(0,z.jsx)(`g`,{transform:`translate(${P.x}, ${P.y}) scale(${P.zoom})`,children:(0,z.jsx)(`rect`,{x:Q.x,y:Q.y,width:Q.width,height:Q.height,fill:`rgba(99, 102, 241, 0.04)`,stroke:`#6366f1`,strokeWidth:1.5/P.zoom,strokeDasharray:`${6/P.zoom} ${3/P.zoom}`,rx:8/P.zoom,ry:8/P.zoom})})})]}),!i&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(je,{isOpen:he,onOpenChange:I,nodeData:De,onNodeDataChange:ke,onConfirm:Xe}),(0,z.jsx)(Me,{selectedNodeId:A,onClose:()=>j(null),selectedNode:ot,onUpdateNodeData:Ze,onDeleteNode:tt,onDeleteGroup:nt,onValidateSection:Qe}),(0,z.jsx)(Ne,{selectedEdgeId:M,onClose:()=>N(null),selectedEdge:Z,isDashed:st,arrowType:ct,onEdgeTypeChange:lt,onArrowChange:ut,onLabelChange:dt,onDeleteEdge:rt})]}),Ce&&(0,z.jsx)(Pe,{nodes:Ce.nodes,edges:Ce.edges,existingNodes:v,existingEdges:x,onConfirm:wt,onCancel:()=>{L(null),$.current=null},confirmLabel:K.current===`insert`?`Confirm Insert`:K.current===`replace`?`Confirm Replace`:`Confirm Append`,canvasGroups:K.current===`replace`?v.map(e=>e.data.section).filter(e=>!!e).filter((e,t,n)=>n.indexOf(e)===t):[]}),we&&(0,z.jsx)(ze,{nodes:we.nodes,edges:we.edges,filename:we.filename,onCancel:()=>Te(null)})]})});export{tt as FlowchartView};
|
|
37
|
+
</svg>`}function W(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}var Re={custom:ke},G={type:`smoothstep`,style:{stroke:`#b1b1b7`},markerEnd:{type:te.ArrowClosed,color:`#b1b1b7`}};function ze({nodes:e,edges:t,filename:n,onCancel:r}){let{resolvedTheme:i}=me(),a=i===`dark`?`#222`:`#ccc`,[c]=(0,R.useState)(e),[l]=(0,R.useState)(t),f=(0,R.useCallback)(()=>{},[]),m=(0,R.useCallback)(()=>{},[]),ee=(0,R.useCallback)(()=>{let e=U(c,l);if(!e){h.error(`No nodes to export`);return}p(e,n),h.success(`Flowchart exported as SVG`),r()},[c,l,n,r]);return(0,z.jsx)(C,{open:!0,onOpenChange:e=>{e||r()},children:(0,z.jsxs)(v,{className:`sm:max-w-3xl h-[600px]`,children:[(0,z.jsx)(S,{children:(0,z.jsx)(y,{children:`Export Flowchart`})}),(0,z.jsxs)(b,{className:`flex-1 flex flex-col min-h-0`,children:[(0,z.jsx)(`div`,{className:`flex-1 rounded-lg border border-border overflow-hidden bg-muted/10 mb-4 relative`,children:(0,z.jsx)(s,{children:(0,z.jsx)(u,{nodes:c,edges:l,onNodesChange:f,onEdgesChange:m,nodeTypes:Re,defaultEdgeOptions:G,fitView:!0,colorMode:i,onlyRenderVisibleElements:!0,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,minZoom:.1,maxZoom:2.5,panOnDrag:!1,zoomOnScroll:!1,zoomOnPinch:!1,zoomOnDoubleClick:!1,children:(0,z.jsx)(d,{variant:o.Lines,gap:50,size:1,color:a})})})}),(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,z.jsx)(`div`,{className:`flex items-center gap-1.5`,children:(0,z.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:`Preview`})}),(0,z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,z.jsxs)(w,{variant:`outline`,onClick:r,className:`gap-2`,children:[(0,z.jsx)(_,{className:`size-4`}),`Cancel`]}),(0,z.jsxs)(w,{onClick:ee,className:`gap-2`,children:[(0,z.jsx)(j,{className:`size-4`}),`Download SVG`]})]})]})]})]})})}var Be=80,Ve=80,He=240,Ue=150,K=64,We=72;function q(e){return(e||``).trim().toLowerCase()}function J(e){let t=q(e.data.label);return t.includes(`start`)||t.includes(`begin`)}function Y(e){let t=q(e.data.label);return t.includes(`end`)||t.includes(`finish`)||t.includes(`done`)||t.includes(`stop`)}function Ge(e){return e.data.shape===`diamond`}function Ke(e){let t=(e.data.label||``).trim().length,n=e.data.shape,r=(()=>{switch(n){case`diamond`:return{width:130,height:130,wrap:12};case`circle`:return{width:110,height:110,wrap:10};case`cloud`:return{width:170,height:96,wrap:16};case`database`:return{width:150,height:104,wrap:16};case`parallelogram`:return{width:170,height:86,wrap:16};case`document`:return{width:150,height:96,wrap:16};case`oval`:return{width:150,height:84,wrap:15};default:return{width:150,height:84,wrap:16}}})(),i=Math.max(0,Math.ceil(t/r.wrap)-1)*18,a=n===`diamond`?Math.min(48,Math.max(0,t-r.wrap)*3):Math.min(64,Math.max(0,t-r.wrap*1.5)*2.5);return{width:r.width+a,height:r.height+i}}function qe(e){let t=Ke(e);return{x:e.position.x+t.width/2,y:e.position.y+t.height/2}}function Je(e){switch(e){case`top`:return`bottom`;case`bottom`:return`top`;case`left`:return`right`;case`right`:return`left`}}function Ye(e,t,n){let r=q(n);if(Ge(e)){if(r===`yes`)return`right`;if(r===`no`)return`left`}let i=qe(e),a=qe(t),o=a.x-i.x,s=a.y-i.y;return Math.abs(o)>Math.abs(s)*1.05?o>=0?`right`:`left`:s>=0?`bottom`:`top`}function Xe(e,t,n){let r=Ye(e,t,n);return{sourceHandle:r,targetHandle:Je(r)}}function Ze(e,t,n,r){let i=[...t];return Ge(e)?(i.sort((t,i)=>{let a=q(n.get(`${e.id}->${t}`)),o=q(n.get(`${e.id}->${i}`)),s=a===`yes`?0:a===`no`?1:2,c=o===`yes`?0:o===`no`?1:2;if(s!==c)return s-c;let l=r.get(t),u=r.get(i),d=J(l)?-1:+!!Y(l),f=J(u)?-1:+!!Y(u);return d===f?(l?.data.label||``).localeCompare(u?.data.label||``):d-f}),i):(i.sort((e,t)=>{let n=r.get(e),i=r.get(t),a=J(n)?-1:+!!Y(n),o=J(i)?-1:+!!Y(i);return a===o?(n?.data.label||``).localeCompare(i?.data.label||``):a-o}),i)}function Qe(e,t,n,r){let i=Math.round(n),a=n=>{let r=e.get(t);return!r||!r.has(n)?n:null},o=r===0?1:r,s=[0];for(let e=1;e<=40;e++)r===0?s.push(e,-e):s.push(e*o,-e*o);for(let e of s){let t=a(i+e);if(t!=null)return t}return i}function X(e){let t=[];for(let n=0;n<e;n++)if(n===0)t.push(1);else if(n===1)t.push(-1);else{let e=Math.ceil(n/2);t.push(n%2==0?e+1:-(e+1))}return t}function $e(e,t){if(e.length===0)return{nodes:[],edges:[]};let n=new Map(e.map(e=>[e.id,e])),r=new Map,i=new Map,a=new Map;for(let t of e)r.set(t.id,[]),i.set(t.id,[]);for(let e of t){let t=e.source,n=e.target;!r.has(t)||!i.has(n)||(r.get(t).push(n),i.get(n).push(t),a.set(`${t}->${n}`,e.label?String(e.label):``))}let o=e.filter(e=>i.get(e.id)?.length===0&&J(e)).map(e=>e.id);if(o.length===0){let t=e.filter(e=>i.get(e.id)?.length===0).map(e=>e.id);t.length>0&&o.push(...t)}o.length===0&&e.length>0&&o.push(e[0].id);let s=new Set,c=new Set,l=new Set;function u(e){s.add(e),c.add(e);for(let t of r.get(e)||[])c.has(t)?l.add(`${e}->${t}`):s.has(t)||u(t);c.delete(e)}for(let e of o)s.has(e)||u(e);for(let t of e)s.has(t.id)||u(t.id);let d=new Map;function f(e){if(d.has(e))return d.get(e);let t=(i.get(e)||[]).filter(t=>!l.has(`${t}->${e}`));if(t.length===0)return d.set(e,0),0;let n=Math.max(...t.map(f))+1;return d.set(e,n),n}let p=new Map;for(let t of e){let e=f(t.id);p.has(e)||p.set(e,[]),p.get(e).push(t.id)}let m=new Map,ee=0;for(let t of e){let e=Ke(t);ee=Math.max(ee,e.width);let n=f(t.id),r=m.get(n)||0;m.set(n,Math.max(r,e.height))}let h=Math.max(ee+K,He),g=new Map,ne=[...p.keys()].sort((e,t)=>e-t);for(let e of ne){let t=m.get(e)||0;g.set(e,Math.max(t+We,Ue))}let _=new Map,v=new Map,y=new Map;function b(e,t){v.has(e)||v.set(e,new Set),v.get(e).add(t)}function x(e,t,n=0){let r=f(e),i=Qe(v,r,t,n);return _.set(e,i),b(r,i),i}function S(e,t,i=0){if(_.has(e))return;let o=x(e,t,y.get(e)??i),s=n.get(e);if(!s)return;let c=(r.get(e)||[]).filter(t=>!l.has(`${e}->${t}`));if(c.length===0)return;let u=Ze(s,c,a,n);if(Ge(s)){let t=u.find(t=>q(a.get(`${e}->${t}`))===`yes`),n=u.find(t=>q(a.get(`${e}->${t}`))===`no`),r=u.filter(e=>e!==t&&e!==n);t&&(y.set(t,1),S(t,o+1,1)),n&&(y.set(n,-1),S(n,o-1,-1));let i=r,s=X(i.length);i.forEach((e,t)=>{let n=s[t],r=n>0?1:n<0?-1:0;y.set(e,r),S(e,o+n,r)});return}if(u.length===1){let e=u[0];y.has(e)||y.set(e,0),S(e,o,y.get(e)??0);return}let d=X(u.length);u.forEach((e,t)=>{let n=d[t],r=n>0?1:n<0?-1:0;y.has(e)||y.set(e,r),S(e,o+n,r)})}let C=[...o].sort((e,t)=>{let r=n.get(e)?.data.label||``,i=n.get(t)?.data.label||``,a=J(n.get(e))?-1:0,o=J(n.get(t))?-1:0;return a===o?r.localeCompare(i):a-o}),w=C.length===1?[0]:[0,1,-1,2,-2,3,-3];C.forEach((e,t)=>{let n=w[t]??0;y.has(e)||y.set(e,0),S(e,n*2,0)});for(let t of e)if(!_.has(t.id)){let e=(i.get(t.id)||[]).filter(e=>_.has(e)),n=e.length>0?e.reduce((e,t)=>e+(_.get(t)||0),0)/e.length:0,r=e.length>0?Math.sign(e.reduce((e,t)=>e+(y.get(t)||0),0)):0;S(t.id,n,r)}for(let t of e){let e=(i.get(t.id)||[]).filter(e=>_.has(e));if(e.length>=2){let n=e.map(e=>_.get(e)||0),r=n.reduce((e,t)=>e+t,0)/n.length,i=Math.round(r),a=f(t.id),o=_.get(t.id);o!=null&&o!==i&&!v.get(a)?.has(i)&&(v.get(a)?.delete(o),b(a,i),_.set(t.id,i))}}let T=Math.min(..._.values(),0),E=new Map;for(let[e,t]of _)E.set(e,t-T);let D=Ve,O=new Map;for(let e of ne)O.set(e,D),D+=(g.get(e)||Ue)+18;let k=e.map(e=>{let t=f(e.id),n=Ke(e),r=E.get(e.id)??0;return{...e,position:{x:Be+r*h,y:O.get(t)??Ve},style:{...e.style,width:n.width,height:n.height}}}),A=new Map(k.map(e=>[e.id,e]));return{nodes:k,edges:t.map((e,t)=>{let n=A.get(e.source),r=A.get(e.target);if(!n||!r)return e;let i=Xe(n,r,e.label?String(e.label):``);return{...e,id:e.id||`flowchart_edge_${t}`,sourceHandle:i.sourceHandle,targetHandle:i.targetHandle,type:e.type||`smoothstep`,markerEnd:e.markerEnd||{type:te.ArrowClosed,color:`#b1b1b7`}}})}}var et={custom:ke},tt=R.memo(({activeFlowchartId:e,activeFlowchart:t,handleFlowchartChange:n,isReadOnly:i=!1,isLoading:s=!1,saveFlowchart:f,triggerDebouncedSync:p,companionMode:m=!1,commentsEnabled:g=!1})=>{let{registerContentHandler:ne,setActionContextData:_}=re(),[v,y,b]=a([]),[x,S,C]=c([]),[A,j]=(0,R.useState)(null),[M,N]=(0,R.useState)(null),[ie,ae]=(0,R.useState)(null),[oe,fe]=(0,R.useState)(null),[P,F]=(0,R.useState)({x:0,y:0,zoom:1}),[he,I]=(0,R.useState)(!1),[Se,L]=(0,R.useState)(null),[we,Te]=(0,R.useState)(null),[De,ke]=(0,R.useState)({label:`New Symbol`,shape:`rectangle`,color:`#8b5cf6`}),Ae=R.useRef(!0),B=R.useRef(!1),V=R.useRef(!1),H=R.useRef(!1),Fe=R.useRef(e),Ie=R.useRef(!1),Le=R.useRef(!1),U=R.useRef(v),W=R.useRef(x),Re=R.useRef(new Set),{takeSnapshot:G,undo:Be,redo:Ve,canUndo:He,canRedo:Ue}=l(),K=R.useRef(`append`),We=(0,R.useCallback)(()=>{if(v.length===0)return;let e=$e(v,x);G(U.current,W.current),y(e.nodes),S(e.edges)},[v,x,y,S,G]);U.current=v,W.current=x;let q=e=>{if(!e)return null;if(typeof e==`object`)return e;if(typeof e!=`string`)return null;try{return JSON.parse(e)}catch{return null}},J=s&&(!t||!t.data);(0,R.useEffect)(()=>{B.current=!0,Ae.current=!0;try{let n=q(t.data)||{nodes:[],edges:[]},r=localStorage.getItem(`pending_create_flowchart_json`)||localStorage.getItem(`pending_update_flowchart_json`),i=n.nodes&&n.nodes.length>0?n.nodes:r||H.current?[]:be,a=n.edges&&n.edges.length>0?n.edges:r||H.current?[]:ye;H.current||(y(i),S(a)),Fe.current!==e&&(Fe.current=e,H.current=!1,j(null),N(null))}catch{let e=localStorage.getItem(`pending_create_flowchart_json`)||localStorage.getItem(`pending_update_flowchart_json`);H.current||(y(e?[]:be),S(e?[]:ye))}let n=setTimeout(()=>{B.current=!1,Ae.current=!1},2e3);return()=>{clearTimeout(n),B.current=!1}},[e,t.data]);let Y=R.useRef(n);(0,R.useEffect)(()=>{Y.current=n},[n]),(0,R.useEffect)(()=>{Ae.current||B.current||V.current||Ie.current||Le.current||(v.length>0||x.length>0)&&Y.current(v,x)},[v,x]);let Ge=(0,R.useCallback)(()=>{V.current=!0},[]),Ke=(0,R.useCallback)(()=>{V.current=!1,(U.current.length>0||W.current.length>0)&&Y.current(U.current,W.current)},[]),qe=(0,R.useMemo)(()=>({type:`smoothstep`,reconnectable:!0,style:{stroke:`#b1b1b7`},markerEnd:{type:te.ArrowClosed,color:`#b1b1b7`}}),[]),Je=(0,R.useCallback)(e=>{G(U.current,W.current),S(t=>ee({...e,type:`smoothstep`,style:{stroke:`#b1b1b7`},markerEnd:{type:te.ArrowClosed,color:`#b1b1b7`},animated:!1},t))},[S,G]),Ye=(0,R.useCallback)((e,t)=>{S(n=>n.map(n=>n.id===e.id?{...n,source:t.source,target:t.target,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle}:n)),G(U.current,W.current)},[S,G]),Xe=()=>{G(U.current,W.current);let e=Math.random().toString(36).substring(2,11),t={...De};t.label.trim().toLowerCase()===`start`&&!t.groupId&&(t.groupId=`grp_${Math.random().toString(36).substring(2,8)}`);let n={id:e,type:`custom`,position:{x:window.innerWidth/2-200,y:window.innerHeight/2-100},data:t};y(e=>e.concat(n)),I(!1)},Ze=e=>{A&&(G(U.current,W.current),y(t=>t.map(t=>t.id===A?{...t,data:{...t.data,...e}}:t)))},Qe=(0,R.useCallback)(e=>{let t=e.trim();return!t||!v.some(e=>e.id!==A&&e.data.section?.toLowerCase()===t.toLowerCase())||(h.error(`Group title already exists`,{description:`Another group is already named "${t}". Each group must have a unique title.`}),!1)},[v,A]),X=e=>{M&&(G(U.current,W.current),S(t=>t.map(t=>t.id===M?{...t,...e}:t)))},tt=()=>{if(!A)return;G(U.current,W.current);let e=[A];y(t=>t.filter(t=>!e.includes(t.id))),S(t=>t.filter(t=>!e.includes(t.source)&&!e.includes(t.target))),j(null)},nt=()=>{let e=v.find(e=>e.id===A);if(!e||!e.data.section)return;G(U.current,W.current);let t=e.data.section,n=v.filter(e=>e.data.section===t).map(e=>e.id);if(n.length===0)return;let r=new Set(n),i=[...n];for(;i.length>0;){let e=i.shift();for(let t of x)t.source===e&&!r.has(t.target)&&(r.add(t.target),i.push(t.target))}let a=[...r];y(e=>e.filter(e=>!a.includes(e.id))),S(e=>e.filter(e=>!a.includes(e.source)&&!a.includes(e.target))),j(null)},rt=()=>{M&&(G(U.current,W.current),S(e=>e.filter(e=>e.id!==M)),N(null))},it=R.useRef(M),at=R.useRef(A);(0,R.useEffect)(()=>{Ie.current=M!==null,Le.current=A!==null;let e=it.current!==null&&M===null,t=at.current!==null&&A===null;it.current=M,at.current=A,(e||t)&&!Ae.current&&!B.current&&(v.length>0||x.length>0)&&Y.current(v,x)},[M,A]),(0,R.useEffect)(()=>{let e=e=>{if(i)return;let t=e.target;if(!(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.isContentEditable)&&!t.hasAttribute?.(`data-keyboard-trap`)&&(e.key===`Delete`||e.key===`Backspace`)){if(A){tt();return}if(M){rt();return}}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[A,M,i]);let ot=v.find(e=>e.id===A),Z=x.find(e=>e.id===M),st=Z?.animated===!0||Z?.style?.strokeDasharray===`5,5`,ct=`end`;Z?.markerStart&&Z?.markerEnd?ct=`both`:Z?.markerStart&&!Z?.markerEnd?ct=`start`:!Z?.markerStart&&!Z?.markerEnd&&(ct=`none`);let lt=e=>{X(e===`dashed`?{animated:!1,style:{...Z?.style,strokeDasharray:`5,5`}}:{animated:!1,style:{...Z?.style,strokeDasharray:void 0}})},ut=e=>{let t=Z?.style?.stroke||`#b1b1b7`,n={type:te.ArrowClosed,color:t};e===`none`?X({markerStart:void 0,markerEnd:void 0}):e===`start`?X({markerStart:n,markerEnd:void 0}):e===`end`?X({markerStart:void 0,markerEnd:n}):e===`both`&&X({markerStart:n,markerEnd:n})},dt=e=>{e.trim()===``?X({label:void 0}):X({label:e,labelBgStyle:{fill:`var(--popover)`},labelStyle:{fill:`var(--popover-foreground)`}})},{setFlowchartExportHandler:ft,resolvedTheme:pt}=me(),mt=pt===`dark`?`#222`:`#ccc`,ht=e=>{let n=t?.title?.replace(/[^a-zA-Z0-9_-]/g,`_`)||`flowchart`;return e?`${n}-${e}`:n},gt=(0,R.useCallback)(()=>{let e=U.current,t=W.current;if(e.length===0){h.error(`No nodes to export`);return}Te({nodes:e,edges:t,filename:ht()})},[]),_t=(0,R.useCallback)(e=>{let t=new Set(U.current.filter(t=>t.data.section===e).map(e=>e.id));if(t.size===0){h.error(`No nodes found in group "${e}"`);return}let n=[...t],r=new Set(n),i=[...n];for(;i.length>0;){let e=i.shift();for(let t of W.current)t.source===e&&!r.has(t.target)&&(r.add(t.target),i.push(t.target))}let a=U.current.filter(e=>r.has(e.id)),o=W.current.filter(e=>r.has(e.source)&&r.has(e.target));if(a.length===0){h.error(`No nodes to export`);return}Te({nodes:a,edges:o,filename:ht(e)})},[]),vt=(0,R.useMemo)(()=>v.map(e=>e.data.section).filter(e=>!!e).filter((e,t,n)=>n.indexOf(e)===t),[v]);(0,R.useEffect)(()=>{if(!m)return ft({exportAll:gt,exportGroup:_t,groups:vt}),()=>ft(null)},[m,gt,_t,vt,ft]);let yt=(0,R.useMemo)(()=>{if(!oe)return Re.current;let e=v.filter(e=>e.data.section===oe).map(e=>e.id);if(e.length===0)return Re.current;let t=new Set(e),n=[...e],r=0;for(;r<n.length;){let e=n[r++];for(let r of x)r.source===e&&!t.has(r.target)&&(t.add(r.target),n.push(r.target))}return t},[oe,v,x]),Q=(0,R.useMemo)(()=>{if(yt.size===0)return null;let e=1/0,t=1/0,n=-1/0,r=-1/0;for(let i of v)if(yt.has(i.id)){let a=i.position.x,o=i.position.y;e=Math.min(e,a),t=Math.min(t,o),n=Math.max(n,a+160),r=Math.max(r,o+70)}return e===1/0?null:{x:e-14,y:t-14,width:n-e+28,height:r-t+28}},[yt,v]),bt=(0,R.useMemo)(()=>v.map(e=>{let t=e.id===A,n=yt.has(e.id),r=t||n,a=g&&!i&&!m;return!!e.selected===r&&e.data._commentsEnabled===a?e:{...e,selected:r,data:{...e.data,_commentsEnabled:a}}}),[m,g,i,v,A,yt]),xt=(0,R.useCallback)(e=>{let t=e.filter(e=>e.type!==`select`);t.length!==0&&b(t)},[b]),St=(0,R.useCallback)(e=>{let t=e.filter(e=>e.type!==`select`);t.length!==0&&C(t)},[C]);(0,R.useEffect)(()=>{if(m||V.current)return;let e=setTimeout(()=>{_({nodes:U.current,edges:W.current})},500);return()=>clearTimeout(e)},[m,v,x,_]);let $=R.useRef(null),Ct=R.useRef(null);(0,R.useEffect)(()=>{if(!m)return ne((e,t,n)=>{try{if(Ct.current=n||null,n===`flowchart-insert`){let t=ge(U.current,W.current,e);if(t&&t.nodes.length>0){$.current=e,K.current=`insert`,L(t);return}}if(n===`flowchart-import`){let t=_e(e);if(t&&t.nodes.length>0){$.current=e,K.current=`replace`,L(t);return}}if(t===`append`){let t=_e(e);if(t&&t.nodes.length>0){$.current=e,K.current=`append`,L(t);return}}if(t===`replace`){let t=_e(e);if(t&&t.nodes.length>0){$.current=e,K.current=`replace`,L(t);return}}$.current||h.error(`Could not parse flowchart data. The response may be too large or in an unsupported format.`)}catch(e){console.error(`Flowchart content handler error:`,e),h.error(`Failed to apply AI content to flowchart`)}},[`append`,`replace`])},[m,ne,y,S,G]),(0,R.useEffect)(()=>{if(m)return;let e=localStorage.getItem(`pending_create_flowchart_json`);if(e){localStorage.removeItem(`pending_create_flowchart_json`);let r=_e(e);if(r&&r.nodes.length>0){H.current=!0,G(U.current,W.current),y(r.nodes),S(r.edges);let e=JSON.stringify({nodes:r.nodes,edges:r.edges});f&&t?f({...t,data:e}).then(()=>{p?.()}).catch(e=>{console.error(`Error saving generated flowchart:`,e)}):n(r.nodes,r.edges),h.success(`Applied generated architecture Flowchart to new canvas`)}}let r=localStorage.getItem(`pending_update_flowchart_json`);if(r){localStorage.removeItem(`pending_update_flowchart_json`);let e=_e(r);if(e&&e.nodes.length>0){H.current=!0,G(U.current,W.current),y(e.nodes),S(e.edges);let r=JSON.stringify({nodes:e.nodes,edges:e.edges});f&&t?f({...t,data:r}).then(()=>{p?.()}).catch(e=>{console.error(`Error updating flowchart:`,e)}):n(e.nodes,e.edges),h.success(`Updated Flowchart with AI-generated content`)}}},[m,y,S,G,n,f,t,p]);let wt=(0,R.useCallback)(e=>{let t=$.current;if(t){if(G(U.current,W.current),e){let n=U.current.filter(t=>t.data.section===e).map(e=>e.id),r=new Set(n),i=[...n];for(;i.length>0;){let e=i.shift();for(let t of W.current)t.source===e&&!r.has(t.target)&&(r.add(t.target),i.push(t.target))}let a=[...r];y(e=>{let n=e.filter(e=>!a.includes(e.id)),r=Ee(t);return r?[...n,...r.nodes]:e}),S(e=>{let n=e.filter(e=>!a.includes(e.source)&&!a.includes(e.target)),r=Ee(t);return r?[...n,...r.edges]:e})}else if(K.current===`replace`){let e=Ee(t);e&&(y(e.nodes),S(e.edges))}else if(K.current===`insert`){let e=ge(U.current,W.current,t);e&&(y(e.nodes),S(e.edges))}else{let e=xe(U.current,W.current,t);e&&(y(e.nodes),S(e.edges))}L(null),$.current=null,ve()}},[y,S,G]),Tt=(0,R.useMemo)(()=>x.map(e=>{let t=e.id===ie,n=e.id===M,r=e;if(!t&&!n)return r;let i=e=>{if(e)return typeof e==`string`?e:{...e,color:`#ffffff`,width:14,height:14}},a=n?{...r.style||{},stroke:`#ffffff`,strokeWidth:2.5}:r.style;return{...r,style:a,markerEnd:n?i(r.markerEnd):r.markerEnd,markerStart:n?i(r.markerStart):r.markerStart}}),[x,ie,M]);return J?(0,z.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center border rounded-xl bg-muted/10`,children:[(0,z.jsx)(Ce,{className:`w-6 h-6 text-primary animate-spin`}),(0,z.jsx)(`p`,{className:`mt-4 text-sm font-medium text-muted-foreground animate-pulse`,children:`Loading flowchart...`})]}):(0,z.jsxs)(pe,{className:`w-full h-full border rounded-xl bg-muted/20 flex flex-col overflow-hidden relative py-0`,children:[!i&&(0,z.jsx)(`div`,{className:`absolute top-6 inset-x-0 z-10 flex justify-center pointer-events-none`,children:(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5 p-1.5 bg-background/95 backdrop-blur-md border border-border/50 rounded-2xl shadow-2xl pointer-events-auto max-w-[95vw] overflow-x-auto no-scrollbar`,children:[(0,z.jsx)(Oe,{nodes:v,label:`Symbol`}),vt.length>0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`w-px h-6 bg-border mx-0.5`}),(0,z.jsxs)(k,{value:oe??``,onValueChange:e=>{fe(e||null),j(null)},children:[(0,z.jsxs)(D,{className:`h-9 min-w-[130px] border-none bg-transparent hover:bg-muted px-2 text-xs font-medium cursor-pointer [&>svg]:text-muted-foreground`,title:`Select a group to move`,children:[(0,z.jsx)(se,{className:`w-3.5 h-3.5 mr-1 text-muted-foreground shrink-0`}),(0,z.jsx)(O,{placeholder:`Move Group`})]}),(0,z.jsx)(E,{className:`bg-popover border-border text-popover-foreground min-w-[150px]`,children:vt.map(e=>(0,z.jsx)(T,{value:e,className:`focus:bg-muted text-xs`,children:e},e))})]})]}),(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`w-px h-6 bg-border mx-0.5`}),(0,z.jsxs)(w,{onClick:We,variant:`outline`,size:`sm`,className:`h-9 px-3 border-border hover:bg-muted bg-muted/50 text-xs font-semibold cursor-pointer`,children:[(0,z.jsx)(le,{className:`w-3.5 h-3.5 sm:mr-1.5`}),(0,z.jsx)(`span`,{className:`hidden sm:inline`,children:`Auto Layout`})]}),(0,z.jsx)(`div`,{className:`w-px h-6 bg-border mx-0.5`}),(0,z.jsxs)(w,{onClick:()=>I(!0),size:`sm`,className:`h-9 px-3 sm:px-4 font-bold shadow-lg shadow-primary/20 cursor-pointer`,children:[(0,z.jsx)(de,{className:`w-4 h-4 sm:mr-2`}),(0,z.jsx)(`span`,{className:`hidden sm:inline`,children:`Add Symbol`})]})]}),(0,z.jsx)(`div`,{className:`w-px h-6 bg-border mx-0.5`}),(0,z.jsx)(w,{onClick:()=>Be(U.current,W.current),disabled:!He,size:`sm`,variant:`ghost`,className:`h-9 w-9 p-0 cursor-pointer`,title:`Undo`,children:(0,z.jsx)(ue,{className:`w-4 h-4`})}),(0,z.jsx)(w,{onClick:()=>Ve(U.current,W.current),disabled:!Ue,size:`sm`,variant:`ghost`,className:`h-9 w-9 p-0 cursor-pointer`,title:`Redo`,children:(0,z.jsx)(ce,{className:`w-4 h-4`})})]})}),(0,z.jsxs)(`div`,{className:`flex-1 w-full h-full relative`,children:[(0,z.jsxs)(u,{nodes:bt,edges:Tt,onNodesChange:xt,onEdgesChange:St,onConnect:Je,onReconnect:Ye,defaultEdgeOptions:qe,onNodeDragStart:Ge,onNodeDragStop:Ke,nodeTypes:et,onNodeClick:(e,t)=>j(t.id),onEdgeClick:(e,t)=>N(t.id),onEdgeMouseEnter:(e,t)=>ae(t.id),onEdgeMouseLeave:()=>ae(null),onPaneClick:()=>{j(null),N(null),fe(null)},fitView:!0,colorMode:pt,onlyRenderVisibleElements:!0,nodesDraggable:!i,nodesConnectable:!i,elementsSelectable:!i,minZoom:.1,maxZoom:2.5,onMove:(e,t)=>F(t),children:[(0,z.jsx)(r,{className:`bg-background/95 border-border shadow-md`,showInteractive:!i}),(0,z.jsx)(d,{variant:o.Lines,gap:50,size:1,color:mt})]}),Q&&(0,z.jsx)(`svg`,{className:`absolute inset-0 pointer-events-none`,style:{overflow:`visible`},children:(0,z.jsx)(`g`,{transform:`translate(${P.x}, ${P.y}) scale(${P.zoom})`,children:(0,z.jsx)(`rect`,{x:Q.x,y:Q.y,width:Q.width,height:Q.height,fill:`rgba(99, 102, 241, 0.04)`,stroke:`#6366f1`,strokeWidth:1.5/P.zoom,strokeDasharray:`${6/P.zoom} ${3/P.zoom}`,rx:8/P.zoom,ry:8/P.zoom})})})]}),!i&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(je,{isOpen:he,onOpenChange:I,nodeData:De,onNodeDataChange:ke,onConfirm:Xe}),(0,z.jsx)(Me,{selectedNodeId:A,onClose:()=>j(null),selectedNode:ot,onUpdateNodeData:Ze,onDeleteNode:tt,onDeleteGroup:nt,onValidateSection:Qe}),(0,z.jsx)(Ne,{selectedEdgeId:M,onClose:()=>N(null),selectedEdge:Z,isDashed:st,arrowType:ct,onEdgeTypeChange:lt,onArrowChange:ut,onLabelChange:dt,onDeleteEdge:rt})]}),Se&&(0,z.jsx)(Pe,{nodes:Se.nodes,edges:Se.edges,existingNodes:v,existingEdges:x,onConfirm:wt,onCancel:()=>{L(null),$.current=null},confirmLabel:K.current===`insert`?`Confirm Insert`:K.current===`replace`?`Confirm Replace`:`Confirm Append`,canvasGroups:K.current===`replace`?v.map(e=>e.data.section).filter(e=>!!e).filter((e,t,n)=>n.indexOf(e)===t):[]}),we&&(0,z.jsx)(ze,{nodes:we.nodes,edges:we.edges,filename:we.filename,onCancel:()=>Te(null)})]})});export{tt as FlowchartView};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t,t as n}from"./jsx-runtime-DSr1VPkp.js";import{r}from"./utils-SlpklRSt.js";import{g as i}from"./downloadSVG-DnlyCOTN.js";import{f as a}from"./dialog-DdtHj1_i.js";import{t as o}from"./button-BGyQguBL.js";import{B as s,S as c,_ as l,f as u,g as d,h as f,m as p,v as m}from"./select-iuD-eAM0.js";import{t as h}from"./scroll-area-DJulbnDp.js";import{t as g}from"./input-QHOTkdNi.js";import{qt as _}from"./index-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t,t as n}from"./jsx-runtime-DSr1VPkp.js";import{r}from"./utils-SlpklRSt.js";import{g as i}from"./downloadSVG-DnlyCOTN.js";import{f as a}from"./dialog-DdtHj1_i.js";import{t as o}from"./button-BGyQguBL.js";import{B as s,S as c,_ as l,f as u,g as d,h as f,m as p,v as m}from"./select-iuD-eAM0.js";import{t as h}from"./scroll-area-DJulbnDp.js";import{t as g}from"./input-QHOTkdNi.js";import{qt as _}from"./index-BmedLVwn.js";var v=e(t(),1),y=n();function b({nodes:e,className:t,label:n=`Symbol`}){let{fitView:b}=i(),[x,S]=(0,v.useState)(!1),[C,w]=(0,v.useState)(``),T=v.useRef(null);v.useEffect(()=>{x&&setTimeout(()=>T.current?.focus(),100)},[x]);let E=e=>{e.stopPropagation(),e.key===`Escape`&&S(!1)},D=(0,v.useMemo)(()=>{let t=C.trim().toLowerCase();return t?e.filter(e=>{let n=e.data;return(n.name||n.label||``).toLowerCase().includes(t)}):e},[e,C]),O=e=>{S(!1),w(``),e.position.x+(e.measured?.width??200)/2,e.position.y+(e.measured?.height??100)/2,setTimeout(()=>{b({nodes:[{id:e.id}],duration:0,padding:1.5,minZoom:1.2,maxZoom:1.2})},100)};return(0,y.jsxs)(u,{open:x,onOpenChange:S,children:[(0,y.jsx)(c,{render:(0,y.jsxs)(o,{variant:`outline`,size:`sm`,className:r(`h-9 px-3 text-xs font-bold border-border/50 bg-muted/20 hover:bg-muted text-muted-foreground transition-all`,t),children:[(0,y.jsx)(_,{className:`w-3.5 h-3.5 mr-2`}),(0,y.jsxs)(`span`,{className:`hidden sm:inline`,children:[`Jump to `,n]}),(0,y.jsx)(`span`,{className:`sm:hidden`,children:`Jump`}),(0,y.jsx)(s,{className:`w-3 h-3 ml-2 opacity-50`})]})}),(0,y.jsxs)(p,{align:`start`,className:`w-[280px] p-0 shadow-2xl border-border/50 bg-background/95 backdrop-blur-xl`,children:[(0,y.jsx)(`div`,{className:`p-3 pb-2`,onPointerDown:e=>e.stopPropagation(),children:(0,y.jsxs)(`div`,{className:`relative`,children:[(0,y.jsx)(a,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground`}),(0,y.jsx)(g,{ref:T,placeholder:`Search ${n.toLowerCase()}s...`,className:`h-8 pl-8 text-xs bg-muted/50 border-none focus-visible:ring-1 focus-visible:ring-primary/50`,value:C,onChange:e=>w(e.target.value),onKeyDown:E,autoComplete:`off`})]})}),(0,y.jsx)(m,{className:`bg-border/50`}),(0,y.jsxs)(f,{children:[(0,y.jsxs)(l,{className:`px-3 pt-1 text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70`,children:[`Showing `,D.length,` of `,e.length,` `,n.toLowerCase(),`s`]}),(0,y.jsx)(h,{className:`h-[250px] px-1 pb-1`,children:D.length===0?(0,y.jsx)(`div`,{className:`px-3 py-6 text-center text-[11px] text-muted-foreground italic`,children:`No matching items found`}):D.map(e=>{let t=e.data,n=t.name||t.label||`Unnamed component`;return(0,y.jsxs)(d,{onClick:()=>O(e),className:`flex items-center gap-2.5 px-3 py-2 cursor-pointer transition-colors focus:bg-accent focus:text-accent-foreground rounded-lg mx-1`,children:[(0,y.jsx)(`div`,{className:`w-2 h-2 rounded-full`,style:{backgroundColor:e.data.color||`#8b5cf6`}}),(0,y.jsx)(`span`,{className:`text-[13px] font-medium truncate tracking-tight`,children:n})]},e.id)})})]})]})]})}export{b as t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/NotesView-
|
|
2
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t,t as n}from"./jsx-runtime-DSr1VPkp.js";import{t as r}from"./preload-helper-Czpn1I53.js";import{u as i}from"./chunk-BV7QT456-CCzugQp2.js";import{t as a}from"./createLucideIcon-CyOWwA0s.js";import"./WorkspaceProvider-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/NotesView-BGbxQglx.js","assets/rolldown-runtime-C0FnF6B9.js","assets/jsx-runtime-DSr1VPkp.js","assets/utils-SlpklRSt.js","assets/preload-helper-Czpn1I53.js","assets/chunk-BV7QT456-CCzugQp2.js","assets/dist-Di9gTGEC.js","assets/createLucideIcon-CyOWwA0s.js","assets/dialog-DdtHj1_i.js","assets/DialogTrigger-CMZ2bBUb.js","assets/composite-BPr5hlSp.js","assets/useBaseUiId-r-qiwcia.js","assets/button-BGyQguBL.js","assets/select-iuD-eAM0.js","assets/floating-ui.react-dom-R40qjF1b.js","assets/useCompositeItem-Bd6is6jf.js","assets/check-Uq0GkTkz.js","assets/input-QHOTkdNi.js","assets/useControlled-CwUHqyRq.js","assets/popover-CfQq7zeH.js","assets/link-2-C71ROdND.js","assets/arrow-left-Cfq6LFs7.js","assets/calendar-DTAvub78.js","assets/scroll-area-DJulbnDp.js","assets/note-importer-DrKk7Mjj.js","assets/api-D87lw-98.js","assets/image-compression-COYPhRs3.js","assets/index-BmedLVwn.js","assets/downloadSVG-DnlyCOTN.js","assets/esm-B1WURL1q.js","assets/src-B-DeWB10.js","assets/value-Cwm0ChEK.js","assets/vanilla--C5Lp_AM.js","assets/triangle-alert-8iwJw8fK.js","assets/wand-sparkles-DfkrzvIR.js","assets/copy-CIp5gOrB.js","assets/minus-gDNtJ5kA.js","assets/plus-DfXp3YpY.js","assets/trash-2-BmZK7fDJ.js","assets/card-XtyXpgaS.js","assets/checkbox-CdFXC_rx.js","assets/table-BX0J8-d-.js","assets/WorkspaceProvider-C28olTit.js","assets/useAuth-B8-lFzUV.js","assets/dist-js-DXG5pDMi.js","assets/core-DNaw6KYU.js","assets/WorkspaceContext-O7njKDwj.js","assets/ConfirmModal-Cha1K-QX.js","assets/message-scroller-_TSj18yr.js","assets/extends-CvVTau-c.js","assets/label-B06IPhlq.js","assets/index-CEGb4t81.css","assets/image-rU2A9CMJ.js","assets/move-BzTcfKj2.js","assets/undo-2-BrIFXDrK.js","assets/refresh-ccw-otI6Z4JU.js","assets/users-BWMwdWqZ.js","assets/user-cog-DrTVVVeT.js","assets/Combination-CxniEXn1.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t,t as n}from"./jsx-runtime-DSr1VPkp.js";import{t as r}from"./preload-helper-Czpn1I53.js";import{u as i}from"./chunk-BV7QT456-CCzugQp2.js";import{t as a}from"./createLucideIcon-CyOWwA0s.js";import"./WorkspaceProvider-C28olTit.js";import{n as o}from"./WorkspaceContext-O7njKDwj.js";import{t as s}from"./ProjectFileTabs-j0OMam2z.js";var c=a(`file-question-mark`,[[`path`,{d:`M12 17h.01`,key:`p32p05`}],[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z`,key:`1mlx9k`}],[`path`,{d:`M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3`,key:`mhlwft`}]]),l=e(t(),1),u=n(),d=l.lazy(()=>r(()=>import(`./NotesView-BGbxQglx.js`).then(e=>({default:e.NotesView})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58])));function f(){let e=o(),{id:t}=i(),{activeNote:n,activeNoteUid:r,saveNote:a,handleNoteChange:f,deleteNote:p,isPublicView:m,isLoading:h,isNoteItemLoading:g,handleNoteSelect:_}=e,v=(0,l.useRef)(!1);return(0,l.useEffect)(()=>{if(!(m||!t)&&!v.current){if(r===t){v.current=!0;return}r||(v.current=!0,_(t))}},[t,r,m,_]),!m&&!r?t&&!v.current?(0,u.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center border rounded-xl bg-muted/10`,children:[(0,u.jsx)(`div`,{className:`w-6 h-6 border-2 border-primary/30 border-t-primary rounded-full animate-spin`}),(0,u.jsx)(`p`,{className:`mt-4 text-sm font-medium text-muted-foreground animate-pulse`,children:`Loading note...`})]}):(0,u.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center border rounded-xl bg-muted/10`,children:(0,u.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:`Select a note to view`})}):!n&&!g?(0,u.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center border rounded-xl bg-muted/10`,children:[(0,u.jsx)(c,{className:`w-12 h-12 text-muted-foreground/40 mb-4`}),(0,u.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:`Note not found`}),(0,u.jsx)(`p`,{className:`text-xs text-muted-foreground/60 mt-1`,children:`This note may have been deleted or is no longer available.`})]}):n?(0,u.jsxs)(`div`,{className:`flex flex-col flex-1 overflow-hidden`,children:[(0,u.jsx)(s,{currentView:`notes`}),(0,u.jsx)(l.Suspense,{fallback:(0,u.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,u.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[(0,u.jsx)(`div`,{className:`w-6 h-6 border-2 border-primary/30 border-t-primary rounded-full animate-spin`}),(0,u.jsx)(`span`,{className:`text-xs text-muted-foreground/60 animate-pulse`,children:`Loading note...`})]})}),children:(0,u.jsx)(d,{isLoading:g,activeNoteUid:m?null:r,activeNote:n,saveNote:a,handleNoteChange:f,deleteNote:p,isReadOnly:m})})]}):(0,u.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center border rounded-xl bg-muted/10`,children:[(0,u.jsx)(`div`,{className:`w-6 h-6 border-2 border-primary/30 border-t-primary rounded-full animate-spin`}),(0,u.jsx)(`p`,{className:`mt-4 text-sm font-medium text-muted-foreground animate-pulse`,children:`Loading note...`})]})}export{f as NoteEditorRoute,c as t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FlowchartView-
|
|
2
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t,t as n}from"./jsx-runtime-DSr1VPkp.js";import{t as r}from"./preload-helper-Czpn1I53.js";import{a as i,d as a,f as o,i as s,l as c,p as l,r as u}from"./downloadSVG-DnlyCOTN.js";import{ct as d,h as ee,r as te,t as ne}from"./esm-B1WURL1q.js";import{n as f}from"./dist-Di9gTGEC.js";import{t as p}from"./button-BGyQguBL.js";import{n as re}from"./calendar-CSJ0kfzv.js";import{t as m}from"./triangle-alert-8iwJw8fK.js";import{r as h}from"./undo-2-BrIFXDrK.js";import{t as g}from"./plus-DfXp3YpY.js";import{n as _}from"./api-D87lw-98.js";import{E as v,a as y,k as b}from"./note-importer-D-BIiDQE.js";import{v as x}from"./WorkspaceProvider-EYbBHADd.js";import{n as S}from"./WorkspaceContext-O7njKDwj.js";import{Qt as C,R as ie,v as ae}from"./index-DCMwd7x8.js";/* empty css */import{a as oe,i as w,n as T,o as E,r as D,s as O,t as k}from"./erd-edge-style-C_Ktt10j.js";var A=e(t(),1);function j(e){if(!e)return null;try{return typeof e==`string`?JSON.parse(e):e}catch{return null}}function M(e){return{...e,id:String(e.id),is_pk:e.is_pk??e.isPk??!1,is_nullable:e.is_nullable??e.isNullable??!0,is_unique:e.is_unique??e.isUnique??!1,default_value:e.default_value??e.defaultValue??null,enum_values:e.enum_values??e.enumValues??``,max_length:e.max_length??e.maxLength??null,numeric_precision:e.numeric_precision??e.numericPrecision??null,numeric_scale:e.numeric_scale??e.numericScale??null,sort_order:e.sort_order??e.sortOrder??0}}function N(e){let t=e.data??e,n=String(e.id??t.id),r=e.position?.x??e.x??t.x??0,i=e.position?.y??e.y??t.y??0;return{id:n,type:`entity`,position:{x:r,y:i},data:{...t,_notesCompanion:!0,id:n,name:t.name??e.name??`Untitled`,x:r,y:i,color:t.color??e.color??`#6366f1`,columns:(t.columns??e.columns??[]).map(M)}}}function se(e){let t=j(e.data),n=Array.isArray(e.entities)&&e.entities.length?e.entities:Array.isArray(t?.nodes)?t.nodes:[],r=Array.isArray(e.relationships)&&e.relationships.length?e.relationships:Array.isArray(t?.edges)?t.edges:[],i=n.map(N),a=new Map(i.map(e=>[e.id,e]));return{nodes:i,edges:r.map(e=>{let t=String(e.source??e.source_entity_id??e.sourceEntityId??``),n=String(e.target??e.target_entity_id??e.targetEntityId??``),r=e.sourceHandle??e.source_handle??e.sourceColumnId??e.source_column_id,i=e.targetHandle??e.target_handle??e.targetColumnId??e.target_column_id,o=a.get(t),s=a.get(n),c=(o?.position.x??0)<(s?.position.x??0),l=String(r||``).startsWith(`col-`)?r:r?`col-${r}-${c?`source`:`source-l`}`:void 0,u=String(i||``).startsWith(`col-`)?i:i?`col-${i}-${c?`target`:`target-r`}`:void 0;return{...e,id:String(e.id),source:t,target:n,sourceHandle:l,targetHandle:u,label:e.label,type:e.type??`smoothstep`,data:{...e.data||{},on_delete:e.on_delete??e.onDelete,on_update:e.on_update??e.onUpdate,constraint_name:e.constraint_name??e.constraintName}}})}}function P(e,t){return k(e,t?[t]:[])}var F=n(),ce={entity:E},I=(0,A.lazy)(()=>r(()=>import(`./FlowchartView-KKIj1Hq-.js`).then(e=>({default:e.FlowchartView})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55]))),L=(0,A.lazy)(()=>r(()=>import(`./ExcalidrawEditor-BlXcT7Ae.js`),__vite__mapDeps([56,1,2,4,31,8,9,15,11,17,40,44,28,51,30,32,3,5,6,7,12,13,14,10,16,18,19,20,21,33,34,35,36,37,38,22,39,25,26,27,41,42,43,45,46,47,48,49,50,29,52,57,53])));async function R(e,t,n){if(n){let n=e===`erd`?`erd`:e===`flowchart`?`flowchart`:`drawings`;return await b.getResource(t)||((await b.getAllResources(n)).find(e=>String(e.uid??e.id)===t)??null)}let r=await _(`/api/${e===`erd`?`diagrams`:e===`flowchart`?`flowcharts`:`drawings`}/${t}`);return r.ok?r.json():null}function z({document:e,previewSchema:t,previewKey:n}){let r=(0,A.useMemo)(()=>se(e),[e]),{isGuest:c,resolvedTheme:m}=S(),[C,E]=(0,A.useState)(r.nodes),[k,j]=(0,A.useState)(r.edges),[M,N]=(0,A.useState)(null),[I,L]=(0,A.useState)(null),[R,z]=(0,A.useState)(null),[B,V]=(0,A.useState)([]),[H,U]=(0,A.useState)(!1),W=(0,A.useRef)(C),G=(0,A.useRef)(k),K=(0,A.useRef)(null),q=(0,A.useMemo)(()=>x(e),[e]),J=q??{x:0,y:0,zoom:1},Y=(0,A.useRef)(J);W.current=C,G.current=k;let X=(0,A.useCallback)((t,n)=>{K.current&&clearTimeout(K.current),K.current=setTimeout(async()=>{let r=t.map(e=>({...e.data,x:e.position.x,y:e.position.y})),i=n.map(v),a=y(t,n);try{if(c){let t=await b.getResource(e.uid??e.id);t&&await b.saveResource({...t,entities:r,relationships:i,data:null,dbml_source:a,viewport_x:Y.current.x,viewport_y:Y.current.y,viewport_zoom:Y.current.zoom,updated_at:new Date().toISOString()})}else if(!(await _(`/api/diagrams/save/${e.uid??e.id}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({entities:r,relationships:i,viewport:Y.current,data:null,dbmlSource:a})})).ok)throw Error()}catch{f.error(`Could not save ERD changes`)}},350)},[e.id,e.uid,c]);(0,A.useEffect)(()=>{if(!(!t||!n))try{let e=re(W.current,G.current,`erd-generate-sql`,t);if(!e)throw Error();let n=w(W.current,G.current,e.nodes,e.edges);if(n.changes.length===0){z(null),f.success(`No schema changes found`);return}N(null),L(null),V(n.changes.map(e=>e.id)),U(!1),z({originalNodes:W.current,originalEdges:G.current,proposedNodes:e.nodes,proposedEdges:e.edges,result:n})}catch{f.error(`Could not parse the schema for diff`)}},[n,t]);let le=(0,A.useCallback)(()=>{if(!R)return;let e=D(R.originalNodes,R.originalEdges,R.proposedNodes,R.proposedEdges,R.result,B);E(e.nodes),j(e.edges),z(null),X(e.nodes,e.edges),f.success(`Schema changes merged successfully`)},[B,R,X]),ue=(0,A.useCallback)(e=>{let t=o(e,W.current);E(t),e.some(e=>e.type!==`select`&&e.type!==`dimensions`)&&X(t,G.current)},[X]),de=(0,A.useCallback)(e=>{let t=a(e,G.current);j(t),e.some(e=>e.type!==`select`)&&X(W.current,t)},[X]),fe=(0,A.useCallback)(e=>{let t=ee({...e,id:crypto.randomUUID(),type:`smoothstep`,label:`1:N`},G.current);j(t),X(W.current,t)},[X]),pe=(0,A.useCallback)((e,t)=>{let n=typeof t==`string`?{label:t}:t,r=G.current.map(t=>t.id===e?{...t,...n,data:{...t.data||{},...n.data||{}}}:t);j(r),X(W.current,r)},[X]),me=(0,A.useCallback)(e=>{let t=e=>e&&(e.endsWith(`-source`)?e.replace(/-source$/,`-source-l`):e.endsWith(`-source-l`)?e.replace(/-source-l$/,`-source`):e.endsWith(`-target`)?e.replace(/-target$/,`-target-r`):e.endsWith(`-target-r`)?e.replace(/-target-r$/,`-target`):e),n=G.current.map(n=>n.id===e?{...n,sourceHandle:t(n.sourceHandle),targetHandle:t(n.targetHandle)}:n);j(n),X(W.current,n)},[X]),he=(0,A.useCallback)(e=>{let t=G.current.filter(t=>t.id!==e);j(t),L(null),X(W.current,t)},[X]),ge=(0,A.useCallback)((e,t)=>{let n=e=>e?.replace(/^col-/,``).replace(/-(source|target)(-(l|r))?$/,``);if(!t.sourceHandle||!t.targetHandle)return;if(String(t.source)!==String(e.source)||String(t.target)!==String(e.target)||n(t.sourceHandle)!==n(e.sourceHandle)||n(t.targetHandle)!==n(e.targetHandle)){f.info(`Only the connector position can be changed`);return}let r=(e,t)=>{let r=n(t);return W.current.find(t=>String(t.id)===String(e))?.data.columns.find(e=>String(e.id)===String(r))},i=r(t.source,t.sourceHandle),a=r(t.target,t.targetHandle);if(i&&a&&i.type!==a.type){f.error(`Type Mismatch`,{description:`Cannot reconnect ${i.type} to ${a.type}`});return}let o=d(e,t,G.current);j(o),X(W.current,o)},[X]),_e=(0,A.useCallback)(e=>{let t=W.current.map(t=>t.id===e.id?{...t,data:e}:t);E(t),X(t,G.current)},[X]),ve=(0,A.useCallback)(e=>{let t=W.current.filter(t=>t.id!==e),n=G.current.filter(t=>t.source!==e&&t.target!==e);E(t),j(n),N(null),X(t,n)},[X]),ye=(0,A.useCallback)(()=>{let e=crypto.randomUUID(),t={id:e,name:`new_table`,x:80,y:80,color:`#6366f1`,columns:[]},n=[...W.current,{id:e,type:`entity`,position:{x:80,y:80},data:t}];E(n),N(e),X(n,G.current)},[X]),be=(0,A.useCallback)(()=>{if(W.current.length===0)return;let e=oe(W.current,G.current);E(e),X(e,G.current)},[X]),xe=(0,A.useCallback)((e,t)=>{Y.current=t},[]),Z=(0,A.useCallback)((e,t)=>{Y.current=t,e&&X(W.current,G.current)},[X]);(0,A.useEffect)(()=>{let e=e=>N(e.detail?.id??null);return window.addEventListener(O,e),()=>window.removeEventListener(O,e)},[]);let Q=C.find(e=>e.id===M)?.data??null,Se=k.find(e=>e.id===I)??null,Ce=m===`dark`?`#222`:`#ccc`,$=(0,A.useMemo)(()=>({type:`smoothstep`,animated:!1,reconnectable:!0,style:{stroke:`var(--edge-color)`,strokeWidth:2},markerEnd:{type:te.Arrow,color:`var(--edge-color)`,width:10,height:10}}),[]),we=(0,A.useMemo)(()=>C.map(e=>{let t=e.id===M;return!!e.selected===t?e:{...e,selected:t}}),[C,M]),Te=(0,A.useMemo)(()=>P(k,M),[k,M]),Ee=(0,A.useMemo)(()=>R?P(R.result.edges,null):[],[R]),De=(0,A.useMemo)(()=>R?.result.nodes.map(e=>({...e,data:{...e.data,isDiffMode:!0}}))??[],[R]);return(0,F.jsxs)(`div`,{className:`relative h-full min-h-0 overflow-hidden bg-background`,children:[(0,F.jsxs)(l,{nodes:R?De:we,edges:R?Ee:Te,nodeTypes:ce,onNodesChange:ue,onEdgesChange:de,onConnect:fe,onReconnect:ge,nodesDraggable:!R,nodesConnectable:!R,elementsSelectable:!R,edgesReconnectable:!R,defaultEdgeOptions:$,onNodeClick:(e,t)=>{L(null),N(t.id)},onNodeDoubleClick:(e,t)=>{L(null),N(t.id)},onEdgeClick:(e,t)=>{N(null),L(t.id)},onPaneClick:()=>{N(null),L(null)},onMove:xe,onMoveEnd:Z,colorMode:m,connectionLineType:ne.SmoothStep,connectionLineStyle:$.style,onlyRenderVisibleElements:!0,defaultViewport:J,fitView:!q,children:[(0,F.jsx)(u,{variant:s.Lines,gap:50,size:1,color:Ce}),(0,F.jsx)(i,{position:`bottom-left`,showInteractive:!1})]}),!R&&(0,F.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 top-3 z-10 flex justify-center`,children:(0,F.jsxs)(`div`,{className:`pointer-events-auto flex items-center gap-1 rounded-lg border bg-background/95 p-1 shadow-sm backdrop-blur`,children:[(0,F.jsxs)(p,{size:`sm`,onClick:ye,children:[(0,F.jsx)(g,{}),` Table`]}),(0,F.jsxs)(p,{variant:`outline`,size:`sm`,onClick:be,disabled:C.length===0,title:`Automatically arrange tables`,children:[(0,F.jsx)(h,{}),` Auto Layout`]})]})}),!R&&Q&&(0,F.jsx)(`aside`,{className:`absolute inset-y-0 right-0 z-20 w-[min(22rem,82%)] border-l bg-background shadow-xl`,children:(0,F.jsx)(ae,{selectedEntity:Q,onUpdateEntity:_e,onDeleteEntity:ve,onBackToTables:()=>N(null),propertiesOnly:!0})}),(0,F.jsx)(ie,{isOpen:!R&&!!I,onOpenChange:e=>{e||L(null)},selectedEdge:Se,nodes:C,handleEdgeUpdate:pe,handleEdgeFlip:me,deleteEdge:he}),R&&(0,F.jsx)(T,{diff:R.result,approvedIds:B,showChecklist:H,onApprovedIdsChange:V,onShowChecklistChange:U,onReject:()=>{z(null),f.info(`Schema update rejected`)},onMerge:le})]})}function B({pane:e,document:t}){let{saveFlowchart:n,saveDrawing:r,triggerDebouncedSync:i}=S();return e.type===`erd`?(0,F.jsx)(c,{children:(0,F.jsx)(z,{document:t,previewSchema:e.previewSchema,previewKey:e.previewKey},t.uid??t.id)}):e.type===`flowchart`?(0,F.jsx)(I,{companionMode:!0,activeFlowchartId:t.uid??t.id,activeFlowchart:t,handleFlowchartChange:(e,r)=>void n({...t,data:JSON.stringify({nodes:e,edges:r})}).then(()=>i()),saveFlowchart:n,triggerDebouncedSync:i}):(0,F.jsx)(L,{compact:!0,drawing:t,onSave:r,onChange:e=>void r({...t,data:e}).then(()=>i()),onDelete:()=>{}})}function V({pane:e}){let{isGuest:t}=S(),[n,r]=(0,A.useState)(),[i,a]=(0,A.useState)(`loading`);return(0,A.useEffect)(()=>{let n=!0;return a(`loading`),r(void 0),R(e.type,e.uid,t).then(e=>{n&&(r(e),a(e?`ready`:`missing`))}).catch(()=>{n&&a(`missing`)}),()=>{n=!1}},[t,e.type,e.uid]),i===`loading`?(0,F.jsx)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:(0,F.jsx)(C,{className:`size-4 animate-spin`})}):i===`missing`?(0,F.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 text-xs text-muted-foreground`,children:[(0,F.jsx)(m,{className:`size-5`}),`File unavailable`]}):(0,F.jsx)(B,{pane:e,document:n})}export{V as NotesCompanionPane};
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FlowchartView-ei1BqVgz.js","assets/rolldown-runtime-C0FnF6B9.js","assets/jsx-runtime-DSr1VPkp.js","assets/downloadSVG-DnlyCOTN.js","assets/utils-SlpklRSt.js","assets/esm-B1WURL1q.js","assets/src-B-DeWB10.js","assets/value-Cwm0ChEK.js","assets/dist-Di9gTGEC.js","assets/vanilla--C5Lp_AM.js","assets/dialog-DdtHj1_i.js","assets/createLucideIcon-CyOWwA0s.js","assets/DialogTrigger-CMZ2bBUb.js","assets/composite-BPr5hlSp.js","assets/useBaseUiId-r-qiwcia.js","assets/button-BGyQguBL.js","assets/select-iuD-eAM0.js","assets/floating-ui.react-dom-R40qjF1b.js","assets/useCompositeItem-Bd6is6jf.js","assets/check-Uq0GkTkz.js","assets/input-QHOTkdNi.js","assets/useControlled-CwUHqyRq.js","assets/scroll-area-DJulbnDp.js","assets/move-BzTcfKj2.js","assets/undo-2-BrIFXDrK.js","assets/plus-DfXp3YpY.js","assets/trash-2-BmZK7fDJ.js","assets/card-XtyXpgaS.js","assets/WorkspaceContext-O7njKDwj.js","assets/label-B06IPhlq.js","assets/index-BmedLVwn.js","assets/preload-helper-Czpn1I53.js","assets/chunk-BV7QT456-CCzugQp2.js","assets/popover-CfQq7zeH.js","assets/link-2-C71ROdND.js","assets/arrow-left-Cfq6LFs7.js","assets/triangle-alert-8iwJw8fK.js","assets/wand-sparkles-DfkrzvIR.js","assets/copy-CIp5gOrB.js","assets/minus-gDNtJ5kA.js","assets/api-D87lw-98.js","assets/checkbox-CdFXC_rx.js","assets/table-BX0J8-d-.js","assets/note-importer-DrKk7Mjj.js","assets/image-compression-COYPhRs3.js","assets/WorkspaceProvider-C28olTit.js","assets/useAuth-B8-lFzUV.js","assets/dist-js-DXG5pDMi.js","assets/core-DNaw6KYU.js","assets/ConfirmModal-Cha1K-QX.js","assets/message-scroller-_TSj18yr.js","assets/extends-CvVTau-c.js","assets/index-CEGb4t81.css","assets/FileCommentMarkers-Bb7wFZxL.js","assets/JumpToNode-M6Utg2ut.js","assets/style-CHpVij2M.css","assets/ExcalidrawEditor-D6g8tcWL.js","assets/Combination-CxniEXn1.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t,t as n}from"./jsx-runtime-DSr1VPkp.js";import{t as r}from"./preload-helper-Czpn1I53.js";import{a as i,d as a,f as o,i as s,l as c,p as l,r as u}from"./downloadSVG-DnlyCOTN.js";import{ct as d,h as ee,r as te,t as ne}from"./esm-B1WURL1q.js";import{n as f}from"./dist-Di9gTGEC.js";import{t as p}from"./button-BGyQguBL.js";import{n as re}from"./calendar-DTAvub78.js";import{t as m}from"./triangle-alert-8iwJw8fK.js";import{r as h}from"./undo-2-BrIFXDrK.js";import{t as g}from"./plus-DfXp3YpY.js";import{n as _}from"./api-D87lw-98.js";import{E as v,a as y,k as b}from"./note-importer-DrKk7Mjj.js";import{v as x}from"./WorkspaceProvider-C28olTit.js";import{n as S}from"./WorkspaceContext-O7njKDwj.js";import{R as ie,Zt as C,v as ae}from"./index-BmedLVwn.js";/* empty css */import{a as oe,i as w,n as T,o as E,r as D,s as O,t as k}from"./erd-edge-style-CLMspt9p.js";var A=e(t(),1);function j(e){if(!e)return null;try{return typeof e==`string`?JSON.parse(e):e}catch{return null}}function M(e){return{...e,id:String(e.id),is_pk:e.is_pk??e.isPk??!1,is_nullable:e.is_nullable??e.isNullable??!0,is_unique:e.is_unique??e.isUnique??!1,default_value:e.default_value??e.defaultValue??null,enum_values:e.enum_values??e.enumValues??``,max_length:e.max_length??e.maxLength??null,numeric_precision:e.numeric_precision??e.numericPrecision??null,numeric_scale:e.numeric_scale??e.numericScale??null,sort_order:e.sort_order??e.sortOrder??0}}function N(e){let t=e.data??e,n=String(e.id??t.id),r=e.position?.x??e.x??t.x??0,i=e.position?.y??e.y??t.y??0;return{id:n,type:`entity`,position:{x:r,y:i},data:{...t,_notesCompanion:!0,id:n,name:t.name??e.name??`Untitled`,x:r,y:i,color:t.color??e.color??`#6366f1`,columns:(t.columns??e.columns??[]).map(M)}}}function se(e){let t=j(e.data),n=Array.isArray(e.entities)&&e.entities.length?e.entities:Array.isArray(t?.nodes)?t.nodes:[],r=Array.isArray(e.relationships)&&e.relationships.length?e.relationships:Array.isArray(t?.edges)?t.edges:[],i=n.map(N),a=new Map(i.map(e=>[e.id,e]));return{nodes:i,edges:r.map(e=>{let t=String(e.source??e.source_entity_id??e.sourceEntityId??``),n=String(e.target??e.target_entity_id??e.targetEntityId??``),r=e.sourceHandle??e.source_handle??e.sourceColumnId??e.source_column_id,i=e.targetHandle??e.target_handle??e.targetColumnId??e.target_column_id,o=a.get(t),s=a.get(n),c=(o?.position.x??0)<(s?.position.x??0),l=String(r||``).startsWith(`col-`)?r:r?`col-${r}-${c?`source`:`source-l`}`:void 0,u=String(i||``).startsWith(`col-`)?i:i?`col-${i}-${c?`target`:`target-r`}`:void 0;return{...e,id:String(e.id),source:t,target:n,sourceHandle:l,targetHandle:u,label:e.label,type:e.type??`smoothstep`,data:{...e.data||{},on_delete:e.on_delete??e.onDelete,on_update:e.on_update??e.onUpdate,constraint_name:e.constraint_name??e.constraintName}}})}}function P(e,t){return k(e,t?[t]:[])}var F=n(),ce={entity:E},I=(0,A.lazy)(()=>r(()=>import(`./FlowchartView-ei1BqVgz.js`).then(e=>({default:e.FlowchartView})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55]))),L=(0,A.lazy)(()=>r(()=>import(`./ExcalidrawEditor-D6g8tcWL.js`),__vite__mapDeps([56,1,2,4,31,8,9,15,11,17,40,44,28,51,30,32,3,5,6,7,12,13,14,10,16,18,19,20,21,33,34,35,36,37,38,22,39,25,26,27,41,42,43,45,46,47,48,49,50,29,52,57,53])));async function R(e,t,n){if(n){let n=e===`erd`?`erd`:e===`flowchart`?`flowchart`:`drawings`;return await b.getResource(t)||((await b.getAllResources(n)).find(e=>String(e.uid??e.id)===t)??null)}let r=await _(`/api/${e===`erd`?`diagrams`:e===`flowchart`?`flowcharts`:`drawings`}/${t}`);return r.ok?r.json():null}function z({document:e,previewSchema:t,previewKey:n}){let r=(0,A.useMemo)(()=>se(e),[e]),{isGuest:c,resolvedTheme:m}=S(),[C,E]=(0,A.useState)(r.nodes),[k,j]=(0,A.useState)(r.edges),[M,N]=(0,A.useState)(null),[I,L]=(0,A.useState)(null),[R,z]=(0,A.useState)(null),[B,V]=(0,A.useState)([]),[H,U]=(0,A.useState)(!1),W=(0,A.useRef)(C),G=(0,A.useRef)(k),K=(0,A.useRef)(null),q=(0,A.useMemo)(()=>x(e),[e]),J=q??{x:0,y:0,zoom:1},Y=(0,A.useRef)(J);W.current=C,G.current=k;let X=(0,A.useCallback)((t,n)=>{K.current&&clearTimeout(K.current),K.current=setTimeout(async()=>{let r=t.map(e=>({...e.data,x:e.position.x,y:e.position.y})),i=n.map(v),a=y(t,n);try{if(c){let t=await b.getResource(e.uid??e.id);t&&await b.saveResource({...t,entities:r,relationships:i,data:null,dbml_source:a,viewport_x:Y.current.x,viewport_y:Y.current.y,viewport_zoom:Y.current.zoom,updated_at:new Date().toISOString()})}else if(!(await _(`/api/diagrams/save/${e.uid??e.id}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({entities:r,relationships:i,viewport:Y.current,data:null,dbmlSource:a})})).ok)throw Error()}catch{f.error(`Could not save ERD changes`)}},350)},[e.id,e.uid,c]);(0,A.useEffect)(()=>{if(!(!t||!n))try{let e=re(W.current,G.current,`erd-generate-sql`,t);if(!e)throw Error();let n=w(W.current,G.current,e.nodes,e.edges);if(n.changes.length===0){z(null),f.success(`No schema changes found`);return}N(null),L(null),V(n.changes.map(e=>e.id)),U(!1),z({originalNodes:W.current,originalEdges:G.current,proposedNodes:e.nodes,proposedEdges:e.edges,result:n})}catch{f.error(`Could not parse the schema for diff`)}},[n,t]);let le=(0,A.useCallback)(()=>{if(!R)return;let e=D(R.originalNodes,R.originalEdges,R.proposedNodes,R.proposedEdges,R.result,B);E(e.nodes),j(e.edges),z(null),X(e.nodes,e.edges),f.success(`Schema changes merged successfully`)},[B,R,X]),ue=(0,A.useCallback)(e=>{let t=o(e,W.current);E(t),e.some(e=>e.type!==`select`&&e.type!==`dimensions`)&&X(t,G.current)},[X]),de=(0,A.useCallback)(e=>{let t=a(e,G.current);j(t),e.some(e=>e.type!==`select`)&&X(W.current,t)},[X]),fe=(0,A.useCallback)(e=>{let t=ee({...e,id:crypto.randomUUID(),type:`smoothstep`,label:`1:N`},G.current);j(t),X(W.current,t)},[X]),pe=(0,A.useCallback)((e,t)=>{let n=typeof t==`string`?{label:t}:t,r=G.current.map(t=>t.id===e?{...t,...n,data:{...t.data||{},...n.data||{}}}:t);j(r),X(W.current,r)},[X]),me=(0,A.useCallback)(e=>{let t=e=>e&&(e.endsWith(`-source`)?e.replace(/-source$/,`-source-l`):e.endsWith(`-source-l`)?e.replace(/-source-l$/,`-source`):e.endsWith(`-target`)?e.replace(/-target$/,`-target-r`):e.endsWith(`-target-r`)?e.replace(/-target-r$/,`-target`):e),n=G.current.map(n=>n.id===e?{...n,sourceHandle:t(n.sourceHandle),targetHandle:t(n.targetHandle)}:n);j(n),X(W.current,n)},[X]),he=(0,A.useCallback)(e=>{let t=G.current.filter(t=>t.id!==e);j(t),L(null),X(W.current,t)},[X]),ge=(0,A.useCallback)((e,t)=>{let n=e=>e?.replace(/^col-/,``).replace(/-(source|target)(-(l|r))?$/,``);if(!t.sourceHandle||!t.targetHandle)return;if(String(t.source)!==String(e.source)||String(t.target)!==String(e.target)||n(t.sourceHandle)!==n(e.sourceHandle)||n(t.targetHandle)!==n(e.targetHandle)){f.info(`Only the connector position can be changed`);return}let r=(e,t)=>{let r=n(t);return W.current.find(t=>String(t.id)===String(e))?.data.columns.find(e=>String(e.id)===String(r))},i=r(t.source,t.sourceHandle),a=r(t.target,t.targetHandle);if(i&&a&&i.type!==a.type){f.error(`Type Mismatch`,{description:`Cannot reconnect ${i.type} to ${a.type}`});return}let o=d(e,t,G.current);j(o),X(W.current,o)},[X]),_e=(0,A.useCallback)(e=>{let t=W.current.map(t=>t.id===e.id?{...t,data:e}:t);E(t),X(t,G.current)},[X]),ve=(0,A.useCallback)(e=>{let t=W.current.filter(t=>t.id!==e),n=G.current.filter(t=>t.source!==e&&t.target!==e);E(t),j(n),N(null),X(t,n)},[X]),ye=(0,A.useCallback)(()=>{let e=crypto.randomUUID(),t={id:e,name:`new_table`,x:80,y:80,color:`#6366f1`,columns:[]},n=[...W.current,{id:e,type:`entity`,position:{x:80,y:80},data:t}];E(n),N(e),X(n,G.current)},[X]),be=(0,A.useCallback)(()=>{if(W.current.length===0)return;let e=oe(W.current,G.current);E(e),X(e,G.current)},[X]),xe=(0,A.useCallback)((e,t)=>{Y.current=t},[]),Z=(0,A.useCallback)((e,t)=>{Y.current=t,e&&X(W.current,G.current)},[X]);(0,A.useEffect)(()=>{let e=e=>N(e.detail?.id??null);return window.addEventListener(O,e),()=>window.removeEventListener(O,e)},[]);let Q=C.find(e=>e.id===M)?.data??null,Se=k.find(e=>e.id===I)??null,Ce=m===`dark`?`#222`:`#ccc`,$=(0,A.useMemo)(()=>({type:`smoothstep`,animated:!1,reconnectable:!0,style:{stroke:`var(--edge-color)`,strokeWidth:2},markerEnd:{type:te.Arrow,color:`var(--edge-color)`,width:10,height:10}}),[]),we=(0,A.useMemo)(()=>C.map(e=>{let t=e.id===M;return!!e.selected===t?e:{...e,selected:t}}),[C,M]),Te=(0,A.useMemo)(()=>P(k,M),[k,M]),Ee=(0,A.useMemo)(()=>R?P(R.result.edges,null):[],[R]),De=(0,A.useMemo)(()=>R?.result.nodes.map(e=>({...e,data:{...e.data,isDiffMode:!0}}))??[],[R]);return(0,F.jsxs)(`div`,{className:`relative h-full min-h-0 overflow-hidden bg-background`,children:[(0,F.jsxs)(l,{nodes:R?De:we,edges:R?Ee:Te,nodeTypes:ce,onNodesChange:ue,onEdgesChange:de,onConnect:fe,onReconnect:ge,nodesDraggable:!R,nodesConnectable:!R,elementsSelectable:!R,edgesReconnectable:!R,defaultEdgeOptions:$,onNodeClick:(e,t)=>{L(null),N(t.id)},onNodeDoubleClick:(e,t)=>{L(null),N(t.id)},onEdgeClick:(e,t)=>{N(null),L(t.id)},onPaneClick:()=>{N(null),L(null)},onMove:xe,onMoveEnd:Z,colorMode:m,connectionLineType:ne.SmoothStep,connectionLineStyle:$.style,onlyRenderVisibleElements:!0,defaultViewport:J,fitView:!q,children:[(0,F.jsx)(u,{variant:s.Lines,gap:50,size:1,color:Ce}),(0,F.jsx)(i,{position:`bottom-left`,showInteractive:!1})]}),!R&&(0,F.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 top-3 z-10 flex justify-center`,children:(0,F.jsxs)(`div`,{className:`pointer-events-auto flex items-center gap-1 rounded-lg border bg-background/95 p-1 shadow-sm backdrop-blur`,children:[(0,F.jsxs)(p,{size:`sm`,onClick:ye,children:[(0,F.jsx)(g,{}),` Table`]}),(0,F.jsxs)(p,{variant:`outline`,size:`sm`,onClick:be,disabled:C.length===0,title:`Automatically arrange tables`,children:[(0,F.jsx)(h,{}),` Auto Layout`]})]})}),!R&&Q&&(0,F.jsx)(`aside`,{className:`absolute inset-y-0 right-0 z-20 w-[min(22rem,82%)] border-l bg-background shadow-xl`,children:(0,F.jsx)(ae,{selectedEntity:Q,onUpdateEntity:_e,onDeleteEntity:ve,onBackToTables:()=>N(null),propertiesOnly:!0})}),(0,F.jsx)(ie,{isOpen:!R&&!!I,onOpenChange:e=>{e||L(null)},selectedEdge:Se,nodes:C,handleEdgeUpdate:pe,handleEdgeFlip:me,deleteEdge:he}),R&&(0,F.jsx)(T,{diff:R.result,approvedIds:B,showChecklist:H,onApprovedIdsChange:V,onShowChecklistChange:U,onReject:()=>{z(null),f.info(`Schema update rejected`)},onMerge:le})]})}function B({pane:e,document:t}){let{saveFlowchart:n,saveDrawing:r,triggerDebouncedSync:i}=S();return e.type===`erd`?(0,F.jsx)(c,{children:(0,F.jsx)(z,{document:t,previewSchema:e.previewSchema,previewKey:e.previewKey},t.uid??t.id)}):e.type===`flowchart`?(0,F.jsx)(I,{companionMode:!0,activeFlowchartId:t.uid??t.id,activeFlowchart:t,handleFlowchartChange:(e,r)=>void n({...t,data:JSON.stringify({nodes:e,edges:r})}).then(()=>i()),saveFlowchart:n,triggerDebouncedSync:i}):(0,F.jsx)(L,{compact:!0,drawing:t,onSave:r,onChange:e=>void r({...t,data:e}).then(()=>i()),onDelete:()=>{}})}function V({pane:e}){let{isGuest:t}=S(),[n,r]=(0,A.useState)(),[i,a]=(0,A.useState)(`loading`);return(0,A.useEffect)(()=>{let n=!0;return a(`loading`),r(void 0),R(e.type,e.uid,t).then(e=>{n&&(r(e),a(e?`ready`:`missing`))}).catch(()=>{n&&a(`missing`)}),()=>{n=!1}},[t,e.type,e.uid]),i===`loading`?(0,F.jsx)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:(0,F.jsx)(C,{className:`size-4 animate-spin`})}):i===`missing`?(0,F.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 text-xs text-muted-foreground`,children:[(0,F.jsx)(m,{className:`size-5`}),`File unavailable`]}):(0,F.jsx)(B,{pane:e,document:n})}export{V as NotesCompanionPane};
|