uigraph 1.0.0 → 1.0.1
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/bin.mjs +134 -56911
- package/dist/viewer/assets/abnfDiagram-VCTEODGH-D7zWJuPJ.js +1 -0
- package/dist/viewer/assets/actor-avatar-Bu-mKKXB.js +1 -0
- package/dist/viewer/assets/{api-adapters-CnQpLiWI.js → api-adapters-tfr51BsS.js} +1 -1
- package/dist/viewer/assets/{api-endpoints-DCA5GNpC.js → api-endpoints-D-Whnnwd.js} +9 -9
- package/dist/viewer/assets/{api-group-endpoints-page-Di42W69y.js → api-group-endpoints-page-B9R1EI4i.js} +9 -9
- package/dist/viewer/assets/{arc-Cn8owoDw.js → arc-DauzQXFu.js} +1 -1
- package/dist/viewer/assets/architectureDiagram-5GKGNRK7-CXzgHd-c.js +36 -0
- package/dist/viewer/assets/{arrow-left-DWcMgM2U.js → arrow-left-DpQqmf17.js} +1 -1
- package/dist/viewer/assets/avatar-DAFUyk1i.js +43 -0
- package/dist/viewer/assets/badge-hR3QvPWv.js +1 -0
- package/dist/viewer/assets/better-delete-confirmation-modal-CGEQ5O4X.js +1 -0
- package/dist/viewer/assets/better-dialog-DcIxFWwk.js +1 -0
- package/dist/viewer/assets/{blockDiagram-I7D4REHJ-CbYzOsL_.js → blockDiagram-I7D4REHJ-CFHWUw4z.js} +2 -2
- package/dist/viewer/assets/{brands-Bd4RklRx.js → brands-DtmA1AhP.js} +1 -1
- package/dist/viewer/assets/button-DZj74qS7.js +1 -0
- package/dist/viewer/assets/{c4Diagram-7LVT6UL2-CLkVbphC.js → c4Diagram-7LVT6UL2-BHSggPKI.js} +6 -6
- package/dist/viewer/assets/{calendar-C0xdI_ag.js → calendar-Bolgc8E5.js} +1 -1
- package/dist/viewer/assets/channel-CNRSofFP.js +1 -0
- package/dist/viewer/assets/{check-XjanpAFg.js → check-BpmCQNbj.js} +1 -1
- package/dist/viewer/assets/checkbox-CFJfXL6R.js +1 -0
- package/dist/viewer/assets/{chevron-down-R7pQzyLD.js → chevron-down-DDsUE_xz.js} +1 -1
- package/dist/viewer/assets/{chevron-up-CRPypfOs.js → chevron-up-DVznKMGv.js} +1 -1
- package/dist/viewer/assets/{chunk-2Q5K7J3B-CcvtugCu.js → chunk-2Q5K7J3B-CNfz5YDQ.js} +1 -1
- package/dist/viewer/assets/{chunk-5VM5RSS4-CpZHHr12.js → chunk-5VM5RSS4-CwIhjvMe.js} +1 -1
- package/dist/viewer/assets/{chunk-F27PBJKO-DeAl4iOc.js → chunk-F27PBJKO-YFexFJof.js} +1 -1
- package/dist/viewer/assets/{chunk-IMKFNOWR-BfrPe7pS.js → chunk-IMKFNOWR-GY2yrvuo.js} +1 -1
- package/dist/viewer/assets/{chunk-JWPE2WC7-DDjyvUmZ.js → chunk-JWPE2WC7-xd0JGvne.js} +1 -1
- package/dist/viewer/assets/chunk-OB3PAWPO-DJIP1M4r.js +12 -0
- package/dist/viewer/assets/{chunk-POPQ4Y6H-DkDb0mzz.js → chunk-POPQ4Y6H-Bh6rizEy.js} +1 -1
- package/dist/viewer/assets/{chunk-SVP7TREG-D-K2XIGs.js → chunk-SVP7TREG-DtNrjvpq.js} +1 -1
- package/dist/viewer/assets/{chunk-TICWLB2K-DWMQQx6z.js → chunk-TICWLB2K-DrERwtw8.js} +1 -1
- package/dist/viewer/assets/{chunk-XXDRQBXY-DfkljAyM.js → chunk-XXDRQBXY-fYo04iwY.js} +1 -1
- package/dist/viewer/assets/{circle-alert-pm13M-Ef.js → circle-alert-Bl7DXYD_.js} +1 -1
- package/dist/viewer/assets/classDiagram-ZZMXUADV-D7PO-ME9.js +1 -0
- package/dist/viewer/assets/classDiagram-v2-VYDZK3BY-D7PO-ME9.js +1 -0
- package/dist/viewer/assets/color-input-ClkkG_kZ.js +11 -0
- package/dist/viewer/assets/{common-Y7ySZBdh.js → common-DLCsGQ-t.js} +1 -1
- package/dist/viewer/assets/{component-icons-D1BDAuEt.js → component-icons-MJ61E9nt.js} +2 -2
- package/dist/viewer/assets/{copy-CN4K2f_R.js → copy-DMJJonQF.js} +1 -1
- package/dist/viewer/assets/cose-bilkent-JH36ORCC-Dplz8nVT.js +1 -0
- package/dist/viewer/assets/cross-button-D5qst1tj.js +1 -0
- package/dist/viewer/assets/{cynefin-OW5HDTMX-yz-uw9Kz.js → cynefin-OW5HDTMX-DiBs4CI8.js} +1 -1
- package/dist/viewer/assets/cynefinDiagram-5FMLGOSQ-COXS8-dI.js +62 -0
- package/dist/viewer/assets/{dagre-GXQ25YYZ-zjZDwXOe.js → dagre-GXQ25YYZ-K8qvfG8D.js} +2 -2
- package/dist/viewer/assets/dashboard-diagrams-page-Cb0xNr4W.js +2 -0
- package/dist/viewer/assets/dashboard-diagrams-page-inner-CD--zr5q.js +1 -0
- package/dist/viewer/assets/dashboard-docs-page-BfWR9Ai9.js +2 -0
- package/dist/viewer/assets/dashboard-docs-page-inner-BLbX-YwF.js +67 -0
- package/dist/viewer/assets/dashboard-layout-sTeeHNsZ.js +1 -0
- package/dist/viewer/assets/dashboard-lens-layout-D-tu_4kn.js +1 -0
- package/dist/viewer/assets/dashboard-map-frame-page-7pDmbTSe.js +1 -0
- package/dist/viewer/assets/dashboard-plans-page-CfwOZ34A.js +1 -0
- package/dist/viewer/assets/dashboard-service-apis-k93fjW51.js +1 -0
- package/dist/viewer/assets/{dashboard-service-diagrams-CIjk95Jk.js → dashboard-service-diagrams-BIWUxX-Y.js} +3 -3
- package/dist/viewer/assets/dashboard-service-docs-CnniTD6Q.js +1 -0
- package/dist/viewer/assets/{dashboard-service-overview-CzePVPjl.js → dashboard-service-overview-CGBu4omY.js} +5 -5
- package/dist/viewer/assets/dashboard-services-DEscIO2O.js +1 -0
- package/dist/viewer/assets/{db-type-badge-DOgu1Pyc.js → db-type-badge-UbPgpwQf.js} +2 -2
- package/dist/viewer/assets/debounce-Cp8eREM4-D7o-Pzb-.js +2 -0
- package/dist/viewer/assets/{dependencies-CYdEztHw.js → dependencies-DK2GDlhQ.js} +1 -1
- package/dist/viewer/assets/{dependency-graph-DbyfN-rC.js → dependency-graph-xBEnCS0J.js} +3 -3
- package/dist/viewer/assets/{diagram-S7CK7UJ4-q-NHkUCx.js → diagram-S7CK7UJ4-D-liadVe.js} +2 -2
- package/dist/viewer/assets/diagram-UQ7AKVKN-CnA8mgXp.js +41 -0
- package/dist/viewer/assets/{diagram-VSXAHHWV-DZc1kHGx.js → diagram-VSXAHHWV-Ck7dgRFR.js} +2 -2
- package/dist/viewer/assets/diagram-VX7I27RA-Cm1LHbu3.js +24 -0
- package/dist/viewer/assets/diagram-Z3DM3KII-DV3yBUCB.js +24 -0
- package/dist/viewer/assets/diagram-live-preview-DzJ7Nxp1.js +2 -0
- package/dist/viewer/assets/{diagram-portal-page-CWxuok9E.js → diagram-portal-page-gguGLULH.js} +24 -24
- package/dist/viewer/assets/{diagrams-C1xkRPqT.js → diagrams-BqBSv2eb.js} +4 -4
- package/dist/viewer/assets/dialog-D7wzTt0L.js +6 -0
- package/dist/viewer/assets/{doc-file-content-B06roi8L.js → doc-file-content-Be0au9Vo.js} +4 -4
- package/dist/viewer/assets/{download-CLdCXVsO.js → download-DhyZ3g4F.js} +1 -1
- package/dist/viewer/assets/ebnfDiagram-PWID7BFC-BXbHVQvG.js +1 -0
- package/dist/viewer/assets/{editor-vqK4qAnB.js → editor-F9o4zoeB.js} +2 -2
- package/dist/viewer/assets/{erDiagram-RLTQ6QDP-BWuA-aqV.js → erDiagram-RLTQ6QDP-DMfiWput.js} +2 -2
- package/dist/viewer/assets/{file-text-BvszilVL.js → file-text-BFqJQ67P.js} +1 -1
- package/dist/viewer/assets/flow-diagram-preview-B83UU1n_.js +1 -0
- package/dist/viewer/assets/{flowDiagram-HODETNUW-Db0QtNj4.js → flowDiagram-HODETNUW-BNFS2Mkr.js} +1 -1
- package/dist/viewer/assets/ganttDiagram-EL5Y4UJY-DFDsYJNp.js +292 -0
- package/dist/viewer/assets/gitGraphDiagram-WWUBYQGX-BVHabPDp.js +106 -0
- package/dist/viewer/assets/global-loader-XJO9_e0l.js +1 -0
- package/dist/viewer/assets/{globe-Jl6eIZmG.js → globe-CJ35KsQW.js} +1 -1
- package/dist/viewer/assets/gql-FFIj8zdp.js +1 -0
- package/dist/viewer/assets/{grid-scroll-body-CPqSxU6-.js → grid-scroll-body-DC5pYDPJ.js} +2 -2
- package/dist/viewer/assets/iconBase-DtqdW2XR.js +1 -0
- package/dist/viewer/assets/index-B6MxYIzs.js +1 -0
- package/dist/viewer/assets/index-BC5xdBQU.js +48 -0
- package/dist/viewer/assets/index-BIrx3oY4.js +1 -0
- package/dist/viewer/assets/{index-jm22RWpY.js → index-BZGsDmUx.js} +5 -5
- package/dist/viewer/assets/{index-Poftp9f1.js → index-BZXhpoWr.js} +4 -4
- package/dist/viewer/assets/index-Bn2bqqMd.js +1 -0
- package/dist/viewer/assets/{index-HU5pz3kj.js → index-BpCVYTvP.js} +36 -36
- package/dist/viewer/assets/{index-Bt2YHgxl.js → index-CBOYhBKJ.js} +1 -1
- package/dist/viewer/assets/index-CH7cEAxj.js +17 -0
- package/dist/viewer/assets/index-CIf0GId3.js +74 -0
- package/dist/viewer/assets/{index-D7MEHpJf.js → index-Ck66Ic_p.js} +4 -4
- package/dist/viewer/assets/index-Cp9mIQ8F.js +1 -0
- package/dist/viewer/assets/{index-c6Bxcoqm.js → index-DDmBuMKI.js} +1 -1
- package/dist/viewer/assets/{index-BSyJbFDG.js → index-DY3BFyb6.js} +1 -1
- package/dist/viewer/assets/{index-BS94XVnd.js → index-DkzZ-ZvR.js} +1 -1
- package/dist/viewer/assets/{index-C_43VC19.js → index-PglMbhys.js} +1 -1
- package/dist/viewer/assets/infoDiagram-27XIBGKW-CG-wwxBf.js +2 -0
- package/dist/viewer/assets/input--C59pq6j.js +1 -0
- package/dist/viewer/assets/{ishikawaDiagram-5VMMS53U-C4PzFnZ4.js → ishikawaDiagram-5VMMS53U-BlgV7ceJ.js} +2 -2
- package/dist/viewer/assets/{journeyDiagram-3NMN7TZE-Dpn3bBNo.js → journeyDiagram-3NMN7TZE-Cn03_Xl6.js} +2 -2
- package/dist/viewer/assets/{kanban-definition-UXKFOSKX-CJ99H4G6.js → kanban-definition-UXKFOSKX-CJogvDPY.js} +6 -6
- package/dist/viewer/assets/{layout-Bfvxt_D5.js → layout-B26eC4yQ.js} +1 -1
- package/dist/viewer/assets/{lens-run-page-DZneics-.js → lens-run-page-Ba1ppzJt.js} +3 -3
- package/dist/viewer/assets/lens-runs-page-BnUS57LM.js +1 -0
- package/dist/viewer/assets/{link-2-C75goIOt.js → link-2-D1e0xznG.js} +1 -1
- package/dist/viewer/assets/linked-project-dot-BY1gEES9.js +543 -0
- package/dist/viewer/assets/{loader-circle-C5jZoM7X.js → loader-circle-CiqyoJF7.js} +1 -1
- package/dist/viewer/assets/{merge-Cy7YkrN7.js → merge-BhOMvhW1.js} +1 -1
- package/dist/viewer/assets/mermaid.core-BDgZg3kW.js +312 -0
- package/dist/viewer/assets/method-badge-DErZP7y5.js +1 -0
- package/dist/viewer/assets/{mindmap-definition-YA3MSWOX-yQCKA-K4.js → mindmap-definition-YA3MSWOX-DFkLu0ac.js} +2 -2
- package/dist/viewer/assets/nav-links-DZWMpwMR.js +61 -0
- package/dist/viewer/assets/{network-COWNXGMM.js → network-B1apzT1s.js} +1 -1
- package/dist/viewer/assets/{nosql-editor-modal-DTiWkc_r.js → nosql-editor-modal-CvH0SWAi.js} +5 -5
- package/dist/viewer/assets/not-found-page-C-fn8QeM.js +1 -0
- package/dist/viewer/assets/organization-dependency-graph-page-BryP-iJL.js +1 -0
- package/dist/viewer/assets/pegDiagram-XKGWAZYB-g1cM14-L.js +1 -0
- package/dist/viewer/assets/{pieDiagram-E7YTZNPT-DqnkpCX4.js → pieDiagram-E7YTZNPT-WEnDsMY3.js} +2 -2
- package/dist/viewer/assets/{plus-DQakmTjA.js → plus-DbyuOgKB.js} +1 -1
- package/dist/viewer/assets/popover-476u3TN0.js +1 -0
- package/dist/viewer/assets/preload-helper-BlTxHScW.js +1 -0
- package/dist/viewer/assets/{quadrantDiagram-AXDQQJYC-iQjJfars.js → quadrantDiagram-AXDQQJYC-NdfQCpzF.js} +2 -2
- package/dist/viewer/assets/query-D9oj6LGx.js +50 -0
- package/dist/viewer/assets/{quill-rCHj4fCw.js → quill-Cde5JMRD.js} +1 -1
- package/dist/viewer/assets/railroadDiagram-O6MQD6OU-BYhlXlMY.js +1 -0
- package/dist/viewer/assets/{react-BNzYaZuG.js → react-Bx48XWN4.js} +1 -1
- package/dist/viewer/assets/react-flow-wrapper-BcbvHgxz.js +277 -0
- package/dist/viewer/assets/{requirementDiagram-BXWQKSXE-Bv-Vh1dW.js → requirementDiagram-BXWQKSXE-C25Bcm2L.js} +2 -2
- package/dist/viewer/assets/{sankeyDiagram-P5KCCOFB-C__uD07f.js → sankeyDiagram-P5KCCOFB-h8LiCsgk.js} +2 -2
- package/dist/viewer/assets/scroll-area-RagrStGj.js +6 -0
- package/dist/viewer/assets/{search-DW-qhXLk.js → search-vw7ucoOs.js} +1 -1
- package/dist/viewer/assets/section-loader-C4hOfhQS.js +1 -0
- package/dist/viewer/assets/section-not-found-BnrXiPog.js +1 -0
- package/dist/viewer/assets/select-D9fbrr7O.js +1 -0
- package/dist/viewer/assets/{sequenceDiagram-WJ2MYXX4-1RbvcHwO.js → sequenceDiagram-WJ2MYXX4-CDRVvD30.js} +2 -2
- package/dist/viewer/assets/{service-context-C17u_Fw9.js → service-context-D5nBtU18.js} +1 -1
- package/dist/viewer/assets/{service-database-list-page-cYuDHIls.js → service-database-list-page-DBjaDLVy.js} +2 -2
- package/dist/viewer/assets/service-database-page-CenNCgwf.js +2 -0
- package/dist/viewer/assets/service-database-page-inner-gS51TQTZ.js +85 -0
- package/dist/viewer/assets/{service-doc-Dir8g83J.js → service-doc-C-jHqT1U.js} +4 -4
- package/dist/viewer/assets/{service-doc-preview-modal-bJ6tJ5YR.js → service-doc-preview-modal-5sX6FOu1.js} +2 -2
- package/dist/viewer/assets/service-layout-Bf0vZBCH.js +1 -0
- package/dist/viewer/assets/service-pages-CFikvX4t.js +1 -0
- package/dist/viewer/assets/{services-Crqkffr5.js → services-Ivav34WC.js} +4 -4
- package/dist/viewer/assets/{share-2-BmYmqN4k.js → share-2-CQEaWbfH.js} +1 -1
- package/dist/viewer/assets/sizeCapture-INFHLROL-BJ6ndnPM.js +1 -0
- package/dist/viewer/assets/stateDiagram-D77RDMKH-B_tNCX3o.js +1 -0
- package/dist/viewer/assets/stateDiagram-v2-MP3YSRHH-Dl9wqdli.js +1 -0
- package/dist/viewer/assets/{style-DgSU0bQl.js → style-BPesJvJr.js} +8 -8
- package/dist/viewer/assets/super-circle-loader-DSkos6uP.js +1 -0
- package/dist/viewer/assets/super-logo-loader-Cxlbn6MB.js +1 -0
- package/dist/viewer/assets/swimlanes-42K2YHIH-CzURzYwf.js +1 -0
- package/dist/viewer/assets/swimlanesDiagram-VR7AAH4N-DrIlwFtk.js +8 -0
- package/dist/viewer/assets/table-B4pFND-o.js +1 -0
- package/dist/viewer/assets/textarea-Clgdv3Oi.js +1 -0
- package/dist/viewer/assets/{timeline-definition-24CTP7MA-C4yuLwUH.js → timeline-definition-24CTP7MA-D0YXQE1U.js} +2 -2
- package/dist/viewer/assets/ui-graph-logo-gHowu5gP.js +1 -0
- package/dist/viewer/assets/{upload-CRsS43j9.js → upload-CYb3nN_5.js} +1 -1
- package/dist/viewer/assets/{uploads-BOQHX9l4.js → uploads-CX2kdXbM.js} +8 -8
- package/dist/viewer/assets/{use-debounced-value-Ba-kkCUY.js → use-debounced-value-BpNFJd3C.js} +1 -1
- package/dist/viewer/assets/{use-localstorage-DIisTx-J.js → use-localstorage-D233xVb0.js} +1 -1
- package/dist/viewer/assets/use-permissions-BvmxJJ5r.js +1 -0
- package/dist/viewer/assets/{use-scoped-storage-C4RzED-E.js → use-scoped-storage-DL1XVp1j.js} +1 -1
- package/dist/viewer/assets/useMutation-D5ZHwHsx.js +1 -0
- package/dist/viewer/assets/useQuery-Dhe6uxrL.js +1 -0
- package/dist/viewer/assets/{vennDiagram-4TSXK5OY-BCtqXZqe.js → vennDiagram-4TSXK5OY-SSjHlqCQ.js} +2 -2
- package/dist/viewer/assets/{wardleyDiagram-VM6X3IG4-D3OtZJoT.js → wardleyDiagram-VM6X3IG4-CZWNdQxH.js} +2 -2
- package/dist/viewer/assets/{xychartDiagram-S5SC5T6Z-DxLL2CHH.js → xychartDiagram-S5SC5T6Z-B2qAGeb0.js} +2 -2
- package/dist/viewer/assets/zod-BMU4UTQt.js +1 -0
- package/dist/viewer/index.html +10 -1
- package/package.json +56 -56
- package/dist/abort-signals-B4fc3ahg.mjs +0 -34
- package/dist/anthropic-messages-KPxCHqBN.mjs +0 -14327
- package/dist/auth-storage-BvNH97p9.mjs +0 -2180
- package/dist/azure-openai-config-BbeCSg4y.mjs +0 -55
- package/dist/azure-openai-responses-BRzy8RfL.mjs +0 -182
- package/dist/classifier-shared-DBUHiTGw.mjs +0 -105
- package/dist/cli-2R6QQFp1.mjs +0 -451
- package/dist/cloudflare-workers-ai-system-one-BfqwmRQf.mjs +0 -44
- package/dist/config-D8DMGzIq.mjs +0 -647
- package/dist/cross-spawn-B2jIQPlu.mjs +0 -404
- package/dist/diagnostics-xdSgQR8t.mjs +0 -131
- package/dist/dist-BRyghrKX.mjs +0 -404
- package/dist/dist-D0EzrblG.mjs +0 -12161
- package/dist/dist-EKhnHWHG.mjs +0 -140221
- package/dist/dist-pQtuusFv.mjs +0 -1243
- package/dist/easter-egg-3d-C9_btlWn.mjs +0 -1225
- package/dist/env-api-keys-uytNub6O.mjs +0 -122
- package/dist/error-body-FhmCtR7m.mjs +0 -101
- package/dist/esm-D5isprgl.mjs +0 -1533
- package/dist/esm-DnqE4pfM.mjs +0 -104876
- package/dist/execute-BoTKl80U.mjs +0 -1715
- package/dist/github-copilot-headers-DWcTgoXr.mjs +0 -22
- package/dist/google-generative-ai-Brs5YpJo.mjs +0 -332
- package/dist/google-shared-2CyYa4VE.mjs +0 -33438
- package/dist/google-vertex-DZDUQPKa.mjs +0 -378
- package/dist/hash-DN7ukSfd.mjs +0 -16
- package/dist/headers-GhQHLk-3.mjs +0 -17
- package/dist/jiti-9kWALm4Y.mjs +0 -5439
- package/dist/jiti-loader-f21DrY1K.mjs +0 -27
- package/dist/jiti-static-loader-BI_w28l7.mjs +0 -41704
- package/dist/json-parse-B2mHg7o7.mjs +0 -381
- package/dist/keybinding-hints-D0nLU3ZH.mjs +0 -17899
- package/dist/lib-Dj1gKQJc.mjs +0 -24379
- package/dist/llama-cpp-classify-C73BoMYd.mjs +0 -344
- package/dist/mistral-conversations-DXVR7znL.mjs +0 -698
- package/dist/models-DBdii9gQ.mjs +0 -1255
- package/dist/multipart-parser-DLw9Z0uJ.mjs +0 -298
- package/dist/node-B0NU8X55.mjs +0 -2479
- package/dist/node-B8gaKm9g.mjs +0 -23
- package/dist/openai-I3_AqKDX.mjs +0 -17357
- package/dist/openai-codex-responses-PcZHDuBD.mjs +0 -1198
- package/dist/openai-completions-a_mH01ii.mjs +0 -994
- package/dist/openai-decisions-Du8y4mQG.mjs +0 -142
- package/dist/openai-prompt-cache-Bc6qNWt0.mjs +0 -8
- package/dist/openai-responses-a9lV_U7O.mjs +0 -270
- package/dist/openai-responses-shared-CDs_PBiH.mjs +0 -598
- package/dist/openrouter-images-D0Zc8Cjs.mjs +0 -125
- package/dist/photon_rs-DCvMOMu0.mjs +0 -4252
- package/dist/pi-messages-B5ietIBq.mjs +0 -306
- package/dist/provider-env-BJhgA66g.mjs +0 -37
- package/dist/provider-retry-DXYM7rVE.mjs +0 -79
- package/dist/runtime-DTkBxiaM.mjs +0 -2822
- package/dist/sanitize-unicode-CqChtoM6.mjs +0 -26
- package/dist/shell-836_JFnI.mjs +0 -162
- package/dist/source-CKPndhKl.mjs +0 -478
- package/dist/src-DNm2QRm3.mjs +0 -5028
- package/dist/system-one-shared-DUAFtNa8.mjs +0 -75
- package/dist/token-DEUkymby.mjs +0 -56
- package/dist/token-util-Cx5S4eKt.mjs +0 -3
- package/dist/tool-DHDYqsyG.mjs +0 -6673
- package/dist/transform-messages-BClk99Vn.mjs +0 -477
- package/dist/typesafe-system-one-D2d8j8hZ.mjs +0 -24
- package/dist/typescript-Br-vsRJV.mjs +0 -6737
- package/dist/uuid-CNCZqNBb.mjs +0 -49
- package/dist/v2-1z8ijsD3.mjs +0 -6120
- package/dist/viewer/assets/abnfDiagram-VCTEODGH-j5YaKnl9.js +0 -1
- package/dist/viewer/assets/actor-avatar-DqmoY8Xc.js +0 -1
- package/dist/viewer/assets/architectureDiagram-5GKGNRK7-D80cJKz_.js +0 -36
- package/dist/viewer/assets/avatar-BI7D-Aia.js +0 -43
- package/dist/viewer/assets/badge-870-A4Y6.js +0 -1
- package/dist/viewer/assets/better-delete-confirmation-modal-Dib31LVb.js +0 -1
- package/dist/viewer/assets/better-dialog-D3AAiahr.js +0 -1
- package/dist/viewer/assets/button-DadqadpO.js +0 -1
- package/dist/viewer/assets/channel-DRkt3LIn.js +0 -1
- package/dist/viewer/assets/checkbox-BXpR079x.js +0 -1
- package/dist/viewer/assets/classDiagram-ZZMXUADV-G5CebNaC.js +0 -1
- package/dist/viewer/assets/classDiagram-v2-VYDZK3BY-G5CebNaC.js +0 -1
- package/dist/viewer/assets/color-input-Efm-lxDy.js +0 -11
- package/dist/viewer/assets/cose-bilkent-JH36ORCC-CrSHFmnp.js +0 -1
- package/dist/viewer/assets/cross-button-5Sr5rWVP.js +0 -1
- package/dist/viewer/assets/cynefinDiagram-5FMLGOSQ-Bdl_eBdu.js +0 -62
- package/dist/viewer/assets/dashboard-diagrams-page-DMupOe1m.js +0 -2
- package/dist/viewer/assets/dashboard-diagrams-page-inner-Dh0yKh2A.js +0 -1
- package/dist/viewer/assets/dashboard-docs-page-DWJ1qOQz.js +0 -2
- package/dist/viewer/assets/dashboard-docs-page-inner-Fs6G3oGo.js +0 -67
- package/dist/viewer/assets/dashboard-layout-D36InAaB.js +0 -1
- package/dist/viewer/assets/dashboard-lens-layout-Cv1Xx3hY.js +0 -1
- package/dist/viewer/assets/dashboard-map-frame-page-CTn61NUO.js +0 -1
- package/dist/viewer/assets/dashboard-plans-page-DxFJkrgK.js +0 -1
- package/dist/viewer/assets/dashboard-service-apis-BHtD9s5z.js +0 -1
- package/dist/viewer/assets/dashboard-service-docs-Uv_1uxxO.js +0 -1
- package/dist/viewer/assets/dashboard-services-CUP-L4Jg.js +0 -1
- package/dist/viewer/assets/diagram-UQ7AKVKN-DhFcurW6.js +0 -41
- package/dist/viewer/assets/diagram-VX7I27RA-DE1nREE8.js +0 -24
- package/dist/viewer/assets/diagram-Z3DM3KII-CSrYcCbc.js +0 -24
- package/dist/viewer/assets/diagram-live-preview-i5doxXLH.js +0 -2
- package/dist/viewer/assets/dialog-D_HtNS17.js +0 -6
- package/dist/viewer/assets/ebnfDiagram-PWID7BFC-BfL8m_sf.js +0 -1
- package/dist/viewer/assets/flow-diagram-preview-T0Z4iMVU.js +0 -1
- package/dist/viewer/assets/ganttDiagram-EL5Y4UJY-CsITpniw.js +0 -292
- package/dist/viewer/assets/gitGraphDiagram-WWUBYQGX-B4eCBGoe.js +0 -106
- package/dist/viewer/assets/iconBase-BoDZfJgC.js +0 -1
- package/dist/viewer/assets/index-5E1tJ7yK.js +0 -125
- package/dist/viewer/assets/index-7XpV2DRw.js +0 -1
- package/dist/viewer/assets/index-C0Rs3s9Z.js +0 -1
- package/dist/viewer/assets/index-CzHjJWeV.js +0 -1
- package/dist/viewer/assets/index-DcEA6SIV.js +0 -74
- package/dist/viewer/assets/infoDiagram-27XIBGKW-lTebN5Ix.js +0 -2
- package/dist/viewer/assets/input-YvHTVS0E.js +0 -1
- package/dist/viewer/assets/lens-runs-page-DoAOObxx.js +0 -1
- package/dist/viewer/assets/linked-project-dot-Ds2uEmJ9.js +0 -543
- package/dist/viewer/assets/mermaid.core-BCRBv8Us.js +0 -312
- package/dist/viewer/assets/method-badge-DMYDKdDZ.js +0 -1
- package/dist/viewer/assets/nav-links-8vT2ixiI.js +0 -61
- package/dist/viewer/assets/not-found-page-CnfLlhS4.js +0 -1
- package/dist/viewer/assets/organization-dependency-graph-page-3xqIxjNx.js +0 -1
- package/dist/viewer/assets/pegDiagram-XKGWAZYB-CMXqeAum.js +0 -1
- package/dist/viewer/assets/popover-CN9ni1N3.js +0 -1
- package/dist/viewer/assets/railroadDiagram-O6MQD6OU-CfqToX3W.js +0 -1
- package/dist/viewer/assets/react-flow-wrapper-BPlRstyO.js +0 -276
- package/dist/viewer/assets/scroll-area-BodE-n7W.js +0 -6
- package/dist/viewer/assets/section-loader-BzpYM_Nx.js +0 -1
- package/dist/viewer/assets/select-DDtnmSET.js +0 -1
- package/dist/viewer/assets/service-database-page-CMi1wF4h.js +0 -2
- package/dist/viewer/assets/service-database-page-inner-CoqAj93L.js +0 -85
- package/dist/viewer/assets/service-layout-0NMm_bKG.js +0 -1
- package/dist/viewer/assets/service-pages-dfnc91SU.js +0 -1
- package/dist/viewer/assets/sizeCapture-INFHLROL-BRJi3gCg.js +0 -1
- package/dist/viewer/assets/stateDiagram-D77RDMKH-DdLsfxgy.js +0 -1
- package/dist/viewer/assets/stateDiagram-v2-MP3YSRHH-DFwg8Qki.js +0 -1
- package/dist/viewer/assets/super-circle-loader-D8MElOMh.js +0 -1
- package/dist/viewer/assets/super-logo-loader-DJYiRbCS.js +0 -1
- package/dist/viewer/assets/swimlanes-42K2YHIH-AuYjrPqh.js +0 -1
- package/dist/viewer/assets/swimlanesDiagram-VR7AAH4N-0nIGA8_4.js +0 -8
- package/dist/viewer/assets/table-Bi4Auk9Z.js +0 -1
- package/dist/viewer/assets/textarea-MgxZ5x6-.js +0 -1
- package/dist/viewer/assets/ui-graph-logo-D4jRhd4z.js +0 -1
- package/dist/viewer/assets/use-permissions-6JVET753.js +0 -1
- package/dist/viewer/assets/useMutation-CmVaR9zz.js +0 -1
- package/dist/viewer/assets/useQuery-B8yYhO0c.js +0 -1
- package/dist/viewer/assets/zod-Dc4H6VVJ.js +0 -1
- package/dist/virtual-modules-DnCx0Gdx.mjs +0 -340
package/dist/viewer/assets/{diagram-portal-page-CWxuok9E.js → diagram-portal-page-gguGLULH.js}
RENAMED
|
@@ -1,79 +1,79 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{r as y,j as s}from"./index-CH7cEAxj.js";import{l as ri,m as ai,n as we,o as oi,p as Ms,q as li,r as mr,s as Ye,t as is,v as Ue,w as hr,x as gr,z as hn,Z as gn,y as Nt,g as W,B as pr,E as fr,G as Os,f as X,H as pn,I as Qs,A as it,N as xr,K as br,L as yr,O as Ke,P as vr,U as jr,Q as wr,S as Nr,T as fn,V as Cr,W as Sr,X as kr,Y as Ir,_ as Tr,$ as ci,a0 as Er,h as Zs,a as qe,M as Oe,J as Bs,a1 as di,a2 as ui,a3 as mi,a4 as Lr,a5 as hi,a6 as _s,a7 as xn,a8 as Ar,a9 as Fr,aa as Dr,i as gi,u as pi,ab as Rr,ac as zr,ad as Mr,ae as Or,C as Br,af as fi,ag as _r,ah as Pr,e as Hr,j as $r,ai as Wr,aj as Gr,F as qr,D as Ur,R as Vr}from"./react-flow-wrapper-BcbvHgxz.js";import{G as Kr}from"./global-loader-XJO9_e0l.js";import{S as Xr,E as Ps,a0 as Yr,aa as Qr,a8 as Zr,G as Jr,u as Js,a as xi}from"./query-D9oj6LGx.js";import{e as ea,u as bi,f as ta,S as sa,s as na,D as Qe,R as ia}from"./style-BPesJvJr.js";import{d as yi,A as ra,a as aa,b as oa,D as la,c as ca}from"./avatar-DAFUyk1i.js";import{C as gs}from"./cross-button-D5qst1tj.js";import{U as Hs}from"./ui-graph-logo-gHowu5gP.js";import{B as Q}from"./button-DZj74qS7.js";import{I as Fe}from"./input--C59pq6j.js";import{g as vi,h as da,i as ji,j as wi,X as ua,k as ma,l as ha,m as Ni,n as Ci,D as en,d as Si,e as tn,f as sn,a as nn,c as ga}from"./dialog-D7wzTt0L.js";import{c as H,L as ss,a as pa}from"./chunk-OB3PAWPO-DJIP1M4r.js";import{Z as ki,_ as fa,$ as xa,a0 as ba,a1 as ya,a2 as va,a3 as bn,a4 as ja,a5 as wa,c as We,j as Ct,d as at,a6 as Na,a7 as ct,a8 as Ii,a9 as Ca,aa as Sa,ab as ka,G as rn,ac as yn,T as et,v as tt,w as st,ad as Ia,ae as Ta,af as Ea,ag as La,K as vn,ah as Aa,ai as Ti,aj as jn,ak as Fa,al as Da,am as wn,an as Ra,ao as za,ap as Ma,aq as Oa,ar as Ba,as as _a,at as qt,x as Mt,au as Ut,av as Nn,aw as Cn,ax as Pa,ay as Sn,O as kn,az as Ha,aA as $a,L as Wa,aB as Ga,aC as qa,aD as Ua,Y as Va,aE as Ka,aF as Xa,aG as Ya,aH as Qa,X as Za,aI as Ja,y as eo}from"./nav-links-DZWMpwMR.js";import{D as Ot,a as Bt,b as _t,c as Me,S as Ei,C as $s,U as to}from"./scroll-area-RagrStGj.js";import{b as Pt,G as Li}from"./iconBase-DtqdW2XR.js";import{S as so}from"./search-vw7ucoOs.js";import{n as no,S as io,o as ro,b as ao,c as oo,u as ne,p as lo,q as co,r as uo,s as mo,m as Ai,t as rs,N as ho,a as Fi,T as Di,U as go,F as po,L as fo,D as In,K as xo,d as bo,e as yo,f as vo,g as jo,h as wo,i as No,j as Re,k as Co,v as So,w as ko}from"./color-input-ClkkG_kZ.js";import{B as an,a as on}from"./better-dialog-DcIxFWwk.js";import{L as le,T as Ws}from"./textarea-Clgdv3Oi.js";import{t as U}from"./index-B6MxYIzs.js";import{c as Io,i as To,a as Eo,d as Ri,e as Lo,g as Ao,h as Fo,j as Do,A as Ge,S as Vt,k as Ro,l as de,b as ln,f as zi}from"./index-BpCVYTvP.js";import{o as as,a as zo}from"./index-CBOYhBKJ.js";import{b as Mo,u as ut}from"./useQuery-Dhe6uxrL.js";import{S as os}from"./super-circle-loader-DSkos6uP.js";import{a as Oo,b as Bo}from"./index-DkzZ-ZvR.js";import{d as _o,e as Po}from"./index-DY3BFyb6.js";import{d as ls,q as Ho,M as Gs,_ as $o}from"./index-BIrx3oY4.js";import{t as Wo,T as It,u as Mi}from"./uploads-CX2kdXbM.js";import{m as ze}from"./index-PglMbhys.js";import{C as Go}from"./copy-DMJJonQF.js";import qo from"./__animated-nodes.DI0XYTuw-C-Pp0d4E.js";import{B as Uo}from"./better-delete-confirmation-modal-CGEQ5O4X.js";import{a as Be}from"./index-Dj_05fqk.js";import{P as mt}from"./plus-DbyuOgKB.js";import{T as Vo}from"./component-icons-MJ61E9nt.js";import{u as zt}from"./useMutation-D5ZHwHsx.js";import{D as Ko}from"./brands-DtmA1AhP.js";import{N as Tn,c as ys,a as vs,b as En,T as Xo,d as js}from"./nosql-editor-modal-CvH0SWAi.js";import{S as Yo}from"./services-Ivav34WC.js";import{C as nt}from"./chevron-down-DDsUE_xz.js";import{U as qs}from"./upload-CYb3nN_5.js";import{F as ws}from"./file-text-BFqJQ67P.js";import{C as Qo}from"./check-BpmCQNbj.js";import{c as Oi}from"./index-DDmBuMKI.js";import{g as cn}from"./gql-FFIj8zdp.js";import{S as _e,a as Pe,b as He,c as $e,d as Le}from"./select-D9fbrr7O.js";import{C as Zo,D as Jo}from"./diagrams-BqBSv2eb.js";import{L as el}from"./loader-circle-CiqyoJF7.js";import{u as tl}from"./use-debounced-value-BpNFJd3C.js";import{a as Ve}from"./react-Bx48XWN4.js";import{S as sl}from"./super-logo-loader-Cxlbn6MB.js";import"./index-CIf0GId3.js";import"./preload-helper-BlTxHScW.js";import"./use-localstorage-D233xVb0.js";import"./badge-hR3QvPWv.js";import"./table-B4pFND-o.js";import"./common-DLCsGQ-t.js";import"./index-Ck66Ic_p.js";import"./checkbox-CFJfXL6R.js";import"./en-US-B1Lg1a1H.js";import"./format-BquKoU4D.js";import"./endOfMonth-CMPv5yN4.js";import"./popover-476u3TN0.js";import"./mermaid.core-BDgZg3kW.js";import"./transform-BqqRT-Iy.js";import"./last-DXTTfs9a.js";import"./value-wA6veExk.js";import"./arrow-left-DpQqmf17.js";import"./chevron-up-DVznKMGv.js";function Ln(t,e){const n=new Set(e);return t.filter(i=>!n.has(i))}var nl=class extends Xr{#i;#e;#r;#s;#t;#n;#a;#o;#l;#c=[];constructor(t,e,n){super(),this.#i=t,this.#s=n,this.#r=[],this.#t=[],this.#e=[],this.setQueries(e)}onSubscribe(){this.listeners.size===1&&this.#t.forEach(t=>{t.subscribe(e=>{this.#h(t,e)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#t.forEach(t=>{t.destroy()})}setQueries(t,e){this.#r=t,this.#s=e,Ps.batch(()=>{const n=this.#t,i=this.#m(this.#r);i.forEach(m=>m.observer.setOptions(m.defaultedQueryOptions));const r=i.map(m=>m.observer),a=r.map(m=>m.getCurrentResult()),o=n.length!==r.length,c=r.some((m,d)=>m!==n[d]),l=o||c,u=l?!0:a.some((m,d)=>{const h=this.#e[d];return!h||!Yr(m,h)});!l&&!u||(l&&(this.#c=i,this.#t=r),this.#e=a,this.hasListeners()&&(l&&(Ln(n,r).forEach(m=>{m.destroy()}),Ln(r,n).forEach(m=>{m.subscribe(d=>{this.#h(m,d)})})),this.#g()))})}getCurrentResult(){return this.#e}getQueries(){return this.#t.map(t=>t.getCurrentQuery())}getObservers(){return this.#t}getOptimisticResult(t,e){const n=this.#m(t),i=n.map(a=>a.observer.getOptimisticResult(a.defaultedQueryOptions)),r=n.map(a=>a.defaultedQueryOptions.queryHash);return[i,a=>this.#u(a??i,e,r),()=>this.#d(i,n)]}#d(t,e){const n=new Set;return e.map((i,r)=>{const a=t[r];return i.defaultedQueryOptions.notifyOnChangeProps?a:i.observer.trackResult(a,o=>{n.has(o)||(n.add(o),e.forEach(c=>{c.observer.trackProp(o)}))})})}#u(t,e,n){if(e){const i=this.#l,r=n!==void 0&&i!==void 0&&(i.length!==n.length||n.some((a,o)=>a!==i[o]));return(this.#e!==this.#o||r||e!==this.#a)&&(this.#a=e,this.#o=this.#e,n!==void 0&&(this.#l=n),this.#n=Qr(this.#n,e(t))),this.#n}return t}#p(){return!this.#s?.combine||this.#t.some((t,e)=>t.options.suspense&&this.#e[e]?.data===void 0)}#m(t){const e=new Map;this.#t.forEach(i=>{const r=i.options.queryHash;if(!r)return;const a=e.get(r);a?a.push(i):e.set(r,[i])});const n=[];return t.forEach(i=>{const r=this.#i.defaultQueryOptions(i),a=e.get(r.queryHash)?.shift()??new ki(this.#i,r);n.push({defaultedQueryOptions:r,observer:a})}),n}#h(t,e){const n=this.#t.indexOf(t);n!==-1&&(this.#e=this.#e.slice(),this.#e[n]=e,this.#g())}#g(){if(this.hasListeners()){const t=this.#p(),e=this.#n,n=t?e:this.#u(this.#d(this.#e,this.#c),this.#s?.combine);(t||e!==n)&&Ps.batch(()=>{this.listeners.forEach(i=>{i(this.#e)})})}}};function il({queries:t,...e},n){const i=Zr(),r=fa(),a=xa(),o=e.subscribed!==!1,c=y.useMemo(()=>t.map(f=>{const g=i.defaultQueryOptions(f);return g._optimisticResults=r?"isRestoring":o?"optimistic":void 0,g}),[t,i,r,o]);c.forEach(f=>{ba(f);const g=i.getQueryCache().get(f.queryHash);ya(f,a,g)}),va(a);const[l]=y.useState(()=>new nl(i,c,e)),[u,m,d]=l.getOptimisticResult(c,e.combine),h=!r&&o;y.useSyncExternalStore(y.useCallback(f=>h?l.subscribe(Ps.batchCalls(f)):Jr,[l,h]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),y.useEffect(()=>{l.setQueries(c,e)},[c,e,l]);const x=u.some((f,g)=>bn(c[g],f))?u.flatMap((f,g)=>{const v=c[g];if(v&&bn(v,f)){const b=new ki(i,v);return ja(v,b,a)}return[]}):[];if(x.length>0)throw Promise.all(x);const N=u.find((f,g)=>{const v=c[g];return v&&wa({result:f,errorResetBoundary:a,throwOnError:v.throwOnError,query:i.getQueryCache().get(v.queryHash),suspense:v.suspense})});if(N)throw N.error;return m(d())}/**
|
|
2
2
|
* @license lucide-react v0.514.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const
|
|
6
|
+
*/const rl=[["path",{d:"M11 14h10",key:"1w8e9d"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v1.344",key:"1e62lh"}],["path",{d:"m17 18 4-4-4-4",key:"z2g111"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113",key:"bjbb7m"}],["rect",{x:"8",y:"2",width:"8",height:"4",rx:"1",key:"ublpy"}]],al=We("clipboard-paste",rl);/**
|
|
7
7
|
* @license lucide-react v0.514.0 - ISC
|
|
8
8
|
*
|
|
9
9
|
* This source code is licensed under the ISC license.
|
|
10
10
|
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const
|
|
11
|
+
*/const ol=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],Ht=We("code-xml",ol);/**
|
|
12
12
|
* @license lucide-react v0.514.0 - ISC
|
|
13
13
|
*
|
|
14
14
|
* This source code is licensed under the ISC license.
|
|
15
15
|
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const
|
|
16
|
+
*/const ll=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]],cl=We("crosshair",ll);/**
|
|
17
17
|
* @license lucide-react v0.514.0 - ISC
|
|
18
18
|
*
|
|
19
19
|
* This source code is licensed under the ISC license.
|
|
20
20
|
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const
|
|
21
|
+
*/const dl=[["path",{d:"M20 7h-3a2 2 0 0 1-2-2V2",key:"x099mo"}],["path",{d:"M9 18a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h7l4 4v10a2 2 0 0 1-2 2Z",key:"18t6ie"}],["path",{d:"M3 7.6v12.8A1.6 1.6 0 0 0 4.6 22h9.8",key:"1nja0z"}]],ul=We("files",dl);/**
|
|
22
22
|
* @license lucide-react v0.514.0 - ISC
|
|
23
23
|
*
|
|
24
24
|
* This source code is licensed under the ISC license.
|
|
25
25
|
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/const
|
|
26
|
+
*/const ml=[["line",{x1:"22",x2:"2",y1:"6",y2:"6",key:"15w7dq"}],["line",{x1:"22",x2:"2",y1:"18",y2:"18",key:"1ip48p"}],["line",{x1:"6",x2:"6",y1:"2",y2:"22",key:"a2lnyx"}],["line",{x1:"18",x2:"18",y1:"2",y2:"22",key:"8vb6jd"}]],hl=We("frame",ml);/**
|
|
27
27
|
* @license lucide-react v0.514.0 - ISC
|
|
28
28
|
*
|
|
29
29
|
* This source code is licensed under the ISC license.
|
|
30
30
|
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
-
*/const
|
|
31
|
+
*/const gl=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],pl=We("image",gl);/**
|
|
32
32
|
* @license lucide-react v0.514.0 - ISC
|
|
33
33
|
*
|
|
34
34
|
* This source code is licensed under the ISC license.
|
|
35
35
|
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
-
*/const
|
|
36
|
+
*/const fl=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],xl=We("maximize-2",fl);/**
|
|
37
37
|
* @license lucide-react v0.514.0 - ISC
|
|
38
38
|
*
|
|
39
39
|
* This source code is licensed under the ISC license.
|
|
40
40
|
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
-
*/const
|
|
41
|
+
*/const bl=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],yl=We("refresh-cw",bl);/**
|
|
42
42
|
* @license lucide-react v0.514.0 - ISC
|
|
43
43
|
*
|
|
44
44
|
* This source code is licensed under the ISC license.
|
|
45
45
|
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
-
*/const
|
|
46
|
+
*/const vl=[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]],jl=We("scan",vl);/**
|
|
47
47
|
* @license lucide-react v0.514.0 - ISC
|
|
48
48
|
*
|
|
49
49
|
* This source code is licensed under the ISC license.
|
|
50
50
|
* See the LICENSE file in the root directory of this source tree.
|
|
51
|
-
*/const
|
|
51
|
+
*/const wl=[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]],Nl=We("scissors",wl);/**
|
|
52
52
|
* @license lucide-react v0.514.0 - ISC
|
|
53
53
|
*
|
|
54
54
|
* This source code is licensed under the ISC license.
|
|
55
55
|
* See the LICENSE file in the root directory of this source tree.
|
|
56
|
-
*/const
|
|
56
|
+
*/const Cl=[["path",{d:"M16 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V8Z",key:"qazsjp"}],["path",{d:"M15 3v4a2 2 0 0 0 2 2h4",key:"40519r"}]],Sl=We("sticky-note",Cl);/**
|
|
57
57
|
* @license lucide-react v0.514.0 - ISC
|
|
58
58
|
*
|
|
59
59
|
* This source code is licensed under the ISC license.
|
|
60
60
|
* See the LICENSE file in the root directory of this source tree.
|
|
61
|
-
*/const Sl=[["path",{d:"M12 4v16",key:"1654pz"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2",key:"e0r10z"}],["path",{d:"M9 20h6",key:"s66wpe"}]],kl=We("type",Sl);function Il({...t}){return s.jsx(yi,{"data-slot":"sheet",...t})}function Tl({...t}){return s.jsx(da,{"data-slot":"sheet-trigger",...t})}function El({...t}){return s.jsx(ji,{"data-slot":"sheet-close",...t})}function Ll({...t}){return s.jsx(wi,{"data-slot":"sheet-portal",...t})}function Al({className:t,...e}){return s.jsx(Ni,{"data-slot":"sheet-overlay",className:H("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",t),...e})}function Fl({className:t,children:e,side:n="right",showCloseButton:i=!0,...r}){return s.jsxs(Ll,{children:[s.jsx(Al,{}),s.jsxs(vi,{"data-slot":"sheet-content",className:H("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-50 flex flex-col gap-4 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500",n==="right"&&"data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm",n==="left"&&"data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm",n==="top"&&"data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b",n==="bottom"&&"data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t",t),...r,children:[e,i&&s.jsxs(ji,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none",children:[s.jsx(ua,{className:"size-4"}),s.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function Dl({className:t,...e}){return s.jsx("div",{"data-slot":"sheet-header",className:H("flex flex-col gap-1.5 p-4",t),...e})}function Rl({className:t,...e}){return s.jsx(ma,{"data-slot":"sheet-title",className:H("text-foreground font-semibold",t),...e})}function zl({className:t,...e}){return s.jsx(ha,{"data-slot":"sheet-description",className:H("text-muted-foreground text-sm",t),...e})}var Ln=1,Ml=.9,Ol=.8,Bl=.17,Ns=.1,Cs=.999,_l=.9999,Pl=.99,Hl=/[\\\/_+.#"@\[\(\{&]/,$l=/[\\\/_+.#"@\[\(\{&]/g,Wl=/[\s-]/,Oi=/[\s-]/g;function Us(t,e,n,i,r,a,o){if(a===e.length)return r===t.length?Ln:Pl;var c=`${r},${a}`;if(o[c]!==void 0)return o[c];for(var l=i.charAt(a),u=n.indexOf(l,r),m=0,d,h,x,N;u>=0;)d=Us(t,e,n,i,u+1,a+1,o),d>m&&(u===r?d*=Ln:Hl.test(t.charAt(u-1))?(d*=Ol,x=t.slice(r,u-1).match($l),x&&r>0&&(d*=Math.pow(Cs,x.length))):Wl.test(t.charAt(u-1))?(d*=Ml,N=t.slice(r,u-1).match(Oi),N&&r>0&&(d*=Math.pow(Cs,N.length))):(d*=Bl,r>0&&(d*=Math.pow(Cs,u-r))),t.charAt(u)!==e.charAt(a)&&(d*=_l)),(d<Ns&&n.charAt(u-1)===i.charAt(a+1)||i.charAt(a+1)===i.charAt(a)&&n.charAt(u-1)!==i.charAt(a))&&(h=Us(t,e,n,i,u+1,a+2,o),h*Ns>d&&(d=h*Ns)),d>m&&(m=d),u=n.indexOf(l,u+1);return o[c]=m,m}function An(t){return t.toLowerCase().replace(Oi," ")}function Gl(t,e,n){return t=n&&n.length>0?`${t+" "+n.join(" ")}`:t,Us(t,e,An(t),An(e),0,0,{})}var Et='[cmdk-group=""]',Ss='[cmdk-group-items=""]',ql='[cmdk-group-heading=""]',Bi='[cmdk-item=""]',Fn=`${Bi}:not([aria-disabled="true"])`,Vs="cmdk-item-select",vt="data-value",Ul=(t,e,n)=>Gl(t,e,n),_i=y.createContext(void 0),Wt=()=>y.useContext(_i),Pi=y.createContext(void 0),dn=()=>y.useContext(Pi),Hi=y.createContext(void 0),$i=y.forwardRef((t,e)=>{let n=jt(()=>{var L,$;return{search:"",value:($=(L=t.value)!=null?L:t.defaultValue)!=null?$:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),i=jt(()=>new Set),r=jt(()=>new Map),a=jt(()=>new Map),o=jt(()=>new Set),c=Wi(t),{label:l,children:u,value:m,onValueChange:d,filter:h,shouldFilter:x,loop:N,disablePointerSelection:f=!1,vimBindings:g=!0,...v}=t,b=Ct(),p=Ct(),w=Ct(),S=y.useRef(null),I=nc();ft(()=>{if(m!==void 0){let L=m.trim();n.current.value=L,C.emit()}},[m]),ft(()=>{I(6,O)},[]);let C=y.useMemo(()=>({subscribe:L=>(o.current.add(L),()=>o.current.delete(L)),snapshot:()=>n.current,setState:(L,$,te)=>{var P,D,q,j;if(!Object.is(n.current[L],$)){if(n.current[L]=$,L==="search")k(),T(),I(1,R);else if(L==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let z=document.getElementById(w);z?z.focus():(P=document.getElementById(b))==null||P.focus()}if(I(7,()=>{var z;n.current.selectedItemId=(z=F())==null?void 0:z.id,C.emit()}),te||I(5,O),((D=c.current)==null?void 0:D.value)!==void 0){let z=$??"";(j=(q=c.current).onValueChange)==null||j.call(q,z);return}}C.emit()}},emit:()=>{o.current.forEach(L=>L())}}),[]),A=y.useMemo(()=>({value:(L,$,te)=>{var P;$!==((P=a.current.get(L))==null?void 0:P.value)&&(a.current.set(L,{value:$,keywords:te}),n.current.filtered.items.set(L,M($,te)),I(2,()=>{T(),C.emit()}))},item:(L,$)=>(i.current.add(L),$&&(r.current.has($)?r.current.get($).add(L):r.current.set($,new Set([L]))),I(3,()=>{k(),T(),n.current.value||R(),C.emit()}),()=>{a.current.delete(L),i.current.delete(L),n.current.filtered.items.delete(L);let te=F();I(4,()=>{k(),te?.getAttribute("id")===L&&R(),C.emit()})}),group:L=>(r.current.has(L)||r.current.set(L,new Set),()=>{a.current.delete(L),r.current.delete(L)}),filter:()=>c.current.shouldFilter,label:l||t["aria-label"],getDisablePointerSelection:()=>c.current.disablePointerSelection,listId:b,inputId:w,labelId:p,listInnerRef:S}),[]);function M(L,$){var te,P;let D=(P=(te=c.current)==null?void 0:te.filter)!=null?P:Ul;return L?D(L,n.current.search,$):0}function T(){if(!n.current.search||c.current.shouldFilter===!1)return;let L=n.current.filtered.items,$=[];n.current.filtered.groups.forEach(P=>{let D=r.current.get(P),q=0;D.forEach(j=>{let z=L.get(j);q=Math.max(z,q)}),$.push([P,q])});let te=S.current;G().sort((P,D)=>{var q,j;let z=P.getAttribute("id"),_=D.getAttribute("id");return((q=L.get(_))!=null?q:0)-((j=L.get(z))!=null?j:0)}).forEach(P=>{let D=P.closest(Ss);D?D.appendChild(P.parentElement===D?P:P.closest(`${Ss} > *`)):te.appendChild(P.parentElement===te?P:P.closest(`${Ss} > *`))}),$.sort((P,D)=>D[1]-P[1]).forEach(P=>{var D;let q=(D=S.current)==null?void 0:D.querySelector(`${Et}[${vt}="${encodeURIComponent(P[0])}"]`);q?.parentElement.appendChild(q)})}function R(){let L=G().find(te=>te.getAttribute("aria-disabled")!=="true"),$=L?.getAttribute(vt);C.setState("value",$||void 0)}function k(){var L,$,te,P;if(!n.current.search||c.current.shouldFilter===!1){n.current.filtered.count=i.current.size;return}n.current.filtered.groups=new Set;let D=0;for(let q of i.current){let j=($=(L=a.current.get(q))==null?void 0:L.value)!=null?$:"",z=(P=(te=a.current.get(q))==null?void 0:te.keywords)!=null?P:[],_=M(j,z);n.current.filtered.items.set(q,_),_>0&&D++}for(let[q,j]of r.current)for(let z of j)if(n.current.filtered.items.get(z)>0){n.current.filtered.groups.add(q);break}n.current.filtered.count=D}function O(){var L,$,te;let P=F();P&&(((L=P.parentElement)==null?void 0:L.firstChild)===P&&((te=($=P.closest(Et))==null?void 0:$.querySelector(ql))==null||te.scrollIntoView({block:"nearest"})),P.scrollIntoView({block:"nearest"}))}function F(){var L;return(L=S.current)==null?void 0:L.querySelector(`${Bi}[aria-selected="true"]`)}function G(){var L;return Array.from(((L=S.current)==null?void 0:L.querySelectorAll(Fn))||[])}function ae(L){let $=G()[L];$&&C.setState("value",$.getAttribute(vt))}function me(L){var $;let te=F(),P=G(),D=P.findIndex(j=>j===te),q=P[D+L];($=c.current)!=null&&$.loop&&(q=D+L<0?P[P.length-1]:D+L===P.length?P[0]:P[D+L]),q&&C.setState("value",q.getAttribute(vt))}function Y(L){let $=F(),te=$?.closest(Et),P;for(;te&&!P;)te=L>0?tc(te,Et):sc(te,Et),P=te?.querySelector(Fn);P?C.setState("value",P.getAttribute(vt)):me(L)}let Ne=()=>ae(G().length-1),ke=L=>{L.preventDefault(),L.metaKey?Ne():L.altKey?Y(1):me(1)},ye=L=>{L.preventDefault(),L.metaKey?ae(0):L.altKey?Y(-1):me(-1)};return y.createElement(at.div,{ref:e,tabIndex:-1,...v,"cmdk-root":"",onKeyDown:L=>{var $;($=v.onKeyDown)==null||$.call(v,L);let te=L.nativeEvent.isComposing||L.keyCode===229;if(!(L.defaultPrevented||te))switch(L.key){case"n":case"j":{g&&L.ctrlKey&&ke(L);break}case"ArrowDown":{ke(L);break}case"p":case"k":{g&&L.ctrlKey&&ye(L);break}case"ArrowUp":{ye(L);break}case"Home":{L.preventDefault(),ae(0);break}case"End":{L.preventDefault(),Ne();break}case"Enter":{L.preventDefault();let P=F();if(P){let D=new Event(Vs);P.dispatchEvent(D)}}}}},y.createElement("label",{"cmdk-label":"",htmlFor:A.inputId,id:A.labelId,style:rc},l),ps(t,L=>y.createElement(Pi.Provider,{value:C},y.createElement(_i.Provider,{value:A},L))))}),Vl=y.forwardRef((t,e)=>{var n,i;let r=Ct(),a=y.useRef(null),o=y.useContext(Hi),c=Wt(),l=Wi(t),u=(i=(n=l.current)==null?void 0:n.forceMount)!=null?i:o?.forceMount;ft(()=>{if(!u)return c.item(r,o?.id)},[u]);let m=Gi(r,a,[t.value,t.children,a],t.keywords),d=dn(),h=ht(I=>I.value&&I.value===m.current),x=ht(I=>u||c.filter()===!1?!0:I.search?I.filtered.items.get(r)>0:!0);y.useEffect(()=>{let I=a.current;if(!(!I||t.disabled))return I.addEventListener(Vs,N),()=>I.removeEventListener(Vs,N)},[x,t.onSelect,t.disabled]);function N(){var I,C;f(),(C=(I=l.current).onSelect)==null||C.call(I,m.current)}function f(){d.setState("value",m.current,!0)}if(!x)return null;let{disabled:g,value:v,onSelect:b,forceMount:p,keywords:w,...S}=t;return y.createElement(at.div,{ref:Pt(a,e),...S,id:r,"cmdk-item":"",role:"option","aria-disabled":!!g,"aria-selected":!!h,"data-disabled":!!g,"data-selected":!!h,onPointerMove:g||c.getDisablePointerSelection()?void 0:f,onClick:g?void 0:N},t.children)}),Kl=y.forwardRef((t,e)=>{let{heading:n,children:i,forceMount:r,...a}=t,o=Ct(),c=y.useRef(null),l=y.useRef(null),u=Ct(),m=Wt(),d=ht(x=>r||m.filter()===!1?!0:x.search?x.filtered.groups.has(o):!0);ft(()=>m.group(o),[]),Gi(o,c,[t.value,t.heading,l]);let h=y.useMemo(()=>({id:o,forceMount:r}),[r]);return y.createElement(at.div,{ref:Pt(c,e),...a,"cmdk-group":"",role:"presentation",hidden:d?void 0:!0},n&&y.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:u},n),ps(t,x=>y.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?u:void 0},y.createElement(Hi.Provider,{value:h},x))))}),Xl=y.forwardRef((t,e)=>{let{alwaysRender:n,...i}=t,r=y.useRef(null),a=ht(o=>!o.search);return!n&&!a?null:y.createElement(at.div,{ref:Pt(r,e),...i,"cmdk-separator":"",role:"separator"})}),Yl=y.forwardRef((t,e)=>{let{onValueChange:n,...i}=t,r=t.value!=null,a=dn(),o=ht(u=>u.search),c=ht(u=>u.selectedItemId),l=Wt();return y.useEffect(()=>{t.value!=null&&a.setState("search",t.value)},[t.value]),y.createElement(at.input,{ref:e,...i,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":c,id:l.inputId,type:"text",value:r?t.value:o,onChange:u=>{r||a.setState("search",u.target.value),n?.(u.target.value)}})}),Ql=y.forwardRef((t,e)=>{let{children:n,label:i="Suggestions",...r}=t,a=y.useRef(null),o=y.useRef(null),c=ht(u=>u.selectedItemId),l=Wt();return y.useEffect(()=>{if(o.current&&a.current){let u=o.current,m=a.current,d,h=new ResizeObserver(()=>{d=requestAnimationFrame(()=>{let x=u.offsetHeight;m.style.setProperty("--cmdk-list-height",x.toFixed(1)+"px")})});return h.observe(u),()=>{cancelAnimationFrame(d),h.unobserve(u)}}},[]),y.createElement(at.div,{ref:Pt(a,e),...r,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":c,"aria-label":i,id:l.listId},ps(t,u=>y.createElement("div",{ref:Pt(o,l.listInnerRef),"cmdk-list-sizer":""},u)))}),Zl=y.forwardRef((t,e)=>{let{open:n,onOpenChange:i,overlayClassName:r,contentClassName:a,container:o,...c}=t;return y.createElement(yi,{open:n,onOpenChange:i},y.createElement(wi,{container:o},y.createElement(Ni,{"cmdk-overlay":"",className:r}),y.createElement(vi,{"aria-label":t.label,"cmdk-dialog":"",className:a},y.createElement($i,{ref:e,...c}))))}),Jl=y.forwardRef((t,e)=>ht(n=>n.filtered.count===0)?y.createElement(at.div,{ref:e,...t,"cmdk-empty":"",role:"presentation"}):null),ec=y.forwardRef((t,e)=>{let{progress:n,children:i,label:r="Loading...",...a}=t;return y.createElement(at.div,{ref:e,...a,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":r},ps(t,o=>y.createElement("div",{"aria-hidden":!0},o)))}),Tt=Object.assign($i,{List:Ql,Item:Vl,Input:Yl,Group:Kl,Separator:Xl,Dialog:Zl,Empty:Jl,Loading:ec});function tc(t,e){let n=t.nextElementSibling;for(;n;){if(n.matches(e))return n;n=n.nextElementSibling}}function sc(t,e){let n=t.previousElementSibling;for(;n;){if(n.matches(e))return n;n=n.previousElementSibling}}function Wi(t){let e=y.useRef(t);return ft(()=>{e.current=t}),e}var ft=typeof window>"u"?y.useEffect:y.useLayoutEffect;function jt(t){let e=y.useRef();return e.current===void 0&&(e.current=t()),e}function ht(t){let e=dn(),n=()=>t(e.snapshot());return y.useSyncExternalStore(e.subscribe,n,n)}function Gi(t,e,n,i=[]){let r=y.useRef(),a=Wt();return ft(()=>{var o;let c=(()=>{var u;for(let m of n){if(typeof m=="string")return m.trim();if(typeof m=="object"&&"current"in m)return m.current?(u=m.current.textContent)==null?void 0:u.trim():r.current}})(),l=i.map(u=>u.trim());a.value(t,c,l),(o=e.current)==null||o.setAttribute(vt,c),r.current=c}),r}var nc=()=>{let[t,e]=y.useState(),n=jt(()=>new Map);return ft(()=>{n.current.forEach(i=>i()),n.current=new Map},[t]),(i,r)=>{n.current.set(i,r),e({})}};function ic(t){let e=t.type;return typeof e=="function"?e(t.props):"render"in e?e.render(t.props):t}function ps({asChild:t,children:e},n){return t&&y.isValidElement(e)?y.cloneElement(ic(e),{ref:e.ref},n(e.props.children)):n(e)}var rc={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function ac({className:t,...e}){return s.jsx(Tt,{"data-slot":"command",className:H("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",t),...e})}function oc({title:t="Command Palette",description:e="Search for a command to run...",children:n,className:i,showCloseButton:r=!0,shouldFilter:a,...o}){return s.jsxs(tn,{...o,children:[s.jsxs(Ci,{className:"sr-only",children:[s.jsx(sn,{children:t}),s.jsx(nn,{children:e})]}),s.jsx(rn,{className:H("overflow-hidden p-0",i),showCloseButton:r,children:s.jsx(ac,{shouldFilter:a,className:"[&_[cmdk-group-heading]]:text-muted-foreground **:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:n})})]})}function lc({className:t,...e}){return s.jsxs("div",{"data-slot":"command-input-wrapper",className:"flex h-9 items-center gap-2 border-b px-3",children:[s.jsx(to,{className:"size-4 shrink-0 opacity-50"}),s.jsx(Tt.Input,{"data-slot":"command-input",className:H("placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",t),...e})]})}function cc({className:t,...e}){return s.jsx(Tt.List,{"data-slot":"command-list",className:H("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",t),...e})}function dc({...t}){return s.jsx(Tt.Empty,{"data-slot":"command-empty",className:"py-6 text-center text-sm",...t})}function uc({className:t,...e}){return s.jsx(Tt.Group,{"data-slot":"command-group",className:H("text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",t),...e})}function mc({className:t,...e}){return s.jsx(Tt.Item,{"data-slot":"command-item",className:H("data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...e})}const Dn=400,hc=32,gc={enterprise:"Enterprise",system:"System",container:"Container",generic:"Boundary",node:"Node"},pc={c4:"C4 Element",c4Boundary:"C4 Boundary",group:"Frame",shape:"Shape",default:"Shape",cloud:"Cloud",text:"Text",code:"Code",table:"Table",databaseTableSQL:"Database Table",dataTableInterface:"Data Table",sequenceParticipant:"Participant",subDiagram:"Sub Diagram",builder:"Node"};function un(t){return pc[t]??"Node"}function ks(t){return t.length<=Dn?t:`${t.slice(0,Dn)}…`}function Rn(t){return t.split(`
|
|
62
|
-
`).find(n=>n.trim().length>0)?.trim()??""}function lt(t,e){const n=t.data.componentFields;return ai(n,{componentFieldId:e})??""}function
|
|
61
|
+
*/const kl=[["path",{d:"M12 4v16",key:"1654pz"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2",key:"e0r10z"}],["path",{d:"M9 20h6",key:"s66wpe"}]],Il=We("type",kl);function Tl({...t}){return s.jsx(vi,{"data-slot":"sheet",...t})}function El({...t}){return s.jsx(da,{"data-slot":"sheet-trigger",...t})}function Ll({...t}){return s.jsx(wi,{"data-slot":"sheet-close",...t})}function Al({...t}){return s.jsx(Ni,{"data-slot":"sheet-portal",...t})}function Fl({className:t,...e}){return s.jsx(Ci,{"data-slot":"sheet-overlay",className:H("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",t),...e})}function Dl({className:t,children:e,side:n="right",showCloseButton:i=!0,...r}){return s.jsxs(Al,{children:[s.jsx(Fl,{}),s.jsxs(ji,{"data-slot":"sheet-content",className:H("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-50 flex flex-col gap-4 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500",n==="right"&&"data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm",n==="left"&&"data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm",n==="top"&&"data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b",n==="bottom"&&"data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t",t),...r,children:[e,i&&s.jsxs(wi,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none",children:[s.jsx(ua,{className:"size-4"}),s.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function Rl({className:t,...e}){return s.jsx("div",{"data-slot":"sheet-header",className:H("flex flex-col gap-1.5 p-4",t),...e})}function zl({className:t,...e}){return s.jsx(ma,{"data-slot":"sheet-title",className:H("text-foreground font-semibold",t),...e})}function Ml({className:t,...e}){return s.jsx(ha,{"data-slot":"sheet-description",className:H("text-muted-foreground text-sm",t),...e})}var An=1,Ol=.9,Bl=.8,_l=.17,Ns=.1,Cs=.999,Pl=.9999,Hl=.99,$l=/[\\\/_+.#"@\[\(\{&]/,Wl=/[\\\/_+.#"@\[\(\{&]/g,Gl=/[\s-]/,Bi=/[\s-]/g;function Us(t,e,n,i,r,a,o){if(a===e.length)return r===t.length?An:Hl;var c=`${r},${a}`;if(o[c]!==void 0)return o[c];for(var l=i.charAt(a),u=n.indexOf(l,r),m=0,d,h,x,N;u>=0;)d=Us(t,e,n,i,u+1,a+1,o),d>m&&(u===r?d*=An:$l.test(t.charAt(u-1))?(d*=Bl,x=t.slice(r,u-1).match(Wl),x&&r>0&&(d*=Math.pow(Cs,x.length))):Gl.test(t.charAt(u-1))?(d*=Ol,N=t.slice(r,u-1).match(Bi),N&&r>0&&(d*=Math.pow(Cs,N.length))):(d*=_l,r>0&&(d*=Math.pow(Cs,u-r))),t.charAt(u)!==e.charAt(a)&&(d*=Pl)),(d<Ns&&n.charAt(u-1)===i.charAt(a+1)||i.charAt(a+1)===i.charAt(a)&&n.charAt(u-1)!==i.charAt(a))&&(h=Us(t,e,n,i,u+1,a+2,o),h*Ns>d&&(d=h*Ns)),d>m&&(m=d),u=n.indexOf(l,u+1);return o[c]=m,m}function Fn(t){return t.toLowerCase().replace(Bi," ")}function ql(t,e,n){return t=n&&n.length>0?`${t+" "+n.join(" ")}`:t,Us(t,e,Fn(t),Fn(e),0,0,{})}var Et='[cmdk-group=""]',Ss='[cmdk-group-items=""]',Ul='[cmdk-group-heading=""]',_i='[cmdk-item=""]',Dn=`${_i}:not([aria-disabled="true"])`,Vs="cmdk-item-select",vt="data-value",Vl=(t,e,n)=>ql(t,e,n),Pi=y.createContext(void 0),Wt=()=>y.useContext(Pi),Hi=y.createContext(void 0),dn=()=>y.useContext(Hi),$i=y.createContext(void 0),Wi=y.forwardRef((t,e)=>{let n=jt(()=>{var L,$;return{search:"",value:($=(L=t.value)!=null?L:t.defaultValue)!=null?$:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),i=jt(()=>new Set),r=jt(()=>new Map),a=jt(()=>new Map),o=jt(()=>new Set),c=Gi(t),{label:l,children:u,value:m,onValueChange:d,filter:h,shouldFilter:x,loop:N,disablePointerSelection:f=!1,vimBindings:g=!0,...v}=t,b=Ct(),p=Ct(),w=Ct(),S=y.useRef(null),I=ic();ft(()=>{if(m!==void 0){let L=m.trim();n.current.value=L,C.emit()}},[m]),ft(()=>{I(6,O)},[]);let C=y.useMemo(()=>({subscribe:L=>(o.current.add(L),()=>o.current.delete(L)),snapshot:()=>n.current,setState:(L,$,te)=>{var P,D,q,j;if(!Object.is(n.current[L],$)){if(n.current[L]=$,L==="search")k(),T(),I(1,R);else if(L==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let z=document.getElementById(w);z?z.focus():(P=document.getElementById(b))==null||P.focus()}if(I(7,()=>{var z;n.current.selectedItemId=(z=F())==null?void 0:z.id,C.emit()}),te||I(5,O),((D=c.current)==null?void 0:D.value)!==void 0){let z=$??"";(j=(q=c.current).onValueChange)==null||j.call(q,z);return}}C.emit()}},emit:()=>{o.current.forEach(L=>L())}}),[]),A=y.useMemo(()=>({value:(L,$,te)=>{var P;$!==((P=a.current.get(L))==null?void 0:P.value)&&(a.current.set(L,{value:$,keywords:te}),n.current.filtered.items.set(L,M($,te)),I(2,()=>{T(),C.emit()}))},item:(L,$)=>(i.current.add(L),$&&(r.current.has($)?r.current.get($).add(L):r.current.set($,new Set([L]))),I(3,()=>{k(),T(),n.current.value||R(),C.emit()}),()=>{a.current.delete(L),i.current.delete(L),n.current.filtered.items.delete(L);let te=F();I(4,()=>{k(),te?.getAttribute("id")===L&&R(),C.emit()})}),group:L=>(r.current.has(L)||r.current.set(L,new Set),()=>{a.current.delete(L),r.current.delete(L)}),filter:()=>c.current.shouldFilter,label:l||t["aria-label"],getDisablePointerSelection:()=>c.current.disablePointerSelection,listId:b,inputId:w,labelId:p,listInnerRef:S}),[]);function M(L,$){var te,P;let D=(P=(te=c.current)==null?void 0:te.filter)!=null?P:Vl;return L?D(L,n.current.search,$):0}function T(){if(!n.current.search||c.current.shouldFilter===!1)return;let L=n.current.filtered.items,$=[];n.current.filtered.groups.forEach(P=>{let D=r.current.get(P),q=0;D.forEach(j=>{let z=L.get(j);q=Math.max(z,q)}),$.push([P,q])});let te=S.current;G().sort((P,D)=>{var q,j;let z=P.getAttribute("id"),_=D.getAttribute("id");return((q=L.get(_))!=null?q:0)-((j=L.get(z))!=null?j:0)}).forEach(P=>{let D=P.closest(Ss);D?D.appendChild(P.parentElement===D?P:P.closest(`${Ss} > *`)):te.appendChild(P.parentElement===te?P:P.closest(`${Ss} > *`))}),$.sort((P,D)=>D[1]-P[1]).forEach(P=>{var D;let q=(D=S.current)==null?void 0:D.querySelector(`${Et}[${vt}="${encodeURIComponent(P[0])}"]`);q?.parentElement.appendChild(q)})}function R(){let L=G().find(te=>te.getAttribute("aria-disabled")!=="true"),$=L?.getAttribute(vt);C.setState("value",$||void 0)}function k(){var L,$,te,P;if(!n.current.search||c.current.shouldFilter===!1){n.current.filtered.count=i.current.size;return}n.current.filtered.groups=new Set;let D=0;for(let q of i.current){let j=($=(L=a.current.get(q))==null?void 0:L.value)!=null?$:"",z=(P=(te=a.current.get(q))==null?void 0:te.keywords)!=null?P:[],_=M(j,z);n.current.filtered.items.set(q,_),_>0&&D++}for(let[q,j]of r.current)for(let z of j)if(n.current.filtered.items.get(z)>0){n.current.filtered.groups.add(q);break}n.current.filtered.count=D}function O(){var L,$,te;let P=F();P&&(((L=P.parentElement)==null?void 0:L.firstChild)===P&&((te=($=P.closest(Et))==null?void 0:$.querySelector(Ul))==null||te.scrollIntoView({block:"nearest"})),P.scrollIntoView({block:"nearest"}))}function F(){var L;return(L=S.current)==null?void 0:L.querySelector(`${_i}[aria-selected="true"]`)}function G(){var L;return Array.from(((L=S.current)==null?void 0:L.querySelectorAll(Dn))||[])}function ae(L){let $=G()[L];$&&C.setState("value",$.getAttribute(vt))}function me(L){var $;let te=F(),P=G(),D=P.findIndex(j=>j===te),q=P[D+L];($=c.current)!=null&&$.loop&&(q=D+L<0?P[P.length-1]:D+L===P.length?P[0]:P[D+L]),q&&C.setState("value",q.getAttribute(vt))}function Y(L){let $=F(),te=$?.closest(Et),P;for(;te&&!P;)te=L>0?sc(te,Et):nc(te,Et),P=te?.querySelector(Dn);P?C.setState("value",P.getAttribute(vt)):me(L)}let Ne=()=>ae(G().length-1),ke=L=>{L.preventDefault(),L.metaKey?Ne():L.altKey?Y(1):me(1)},ye=L=>{L.preventDefault(),L.metaKey?ae(0):L.altKey?Y(-1):me(-1)};return y.createElement(at.div,{ref:e,tabIndex:-1,...v,"cmdk-root":"",onKeyDown:L=>{var $;($=v.onKeyDown)==null||$.call(v,L);let te=L.nativeEvent.isComposing||L.keyCode===229;if(!(L.defaultPrevented||te))switch(L.key){case"n":case"j":{g&&L.ctrlKey&&ke(L);break}case"ArrowDown":{ke(L);break}case"p":case"k":{g&&L.ctrlKey&&ye(L);break}case"ArrowUp":{ye(L);break}case"Home":{L.preventDefault(),ae(0);break}case"End":{L.preventDefault(),Ne();break}case"Enter":{L.preventDefault();let P=F();if(P){let D=new Event(Vs);P.dispatchEvent(D)}}}}},y.createElement("label",{"cmdk-label":"",htmlFor:A.inputId,id:A.labelId,style:ac},l),ps(t,L=>y.createElement(Hi.Provider,{value:C},y.createElement(Pi.Provider,{value:A},L))))}),Kl=y.forwardRef((t,e)=>{var n,i;let r=Ct(),a=y.useRef(null),o=y.useContext($i),c=Wt(),l=Gi(t),u=(i=(n=l.current)==null?void 0:n.forceMount)!=null?i:o?.forceMount;ft(()=>{if(!u)return c.item(r,o?.id)},[u]);let m=qi(r,a,[t.value,t.children,a],t.keywords),d=dn(),h=ht(I=>I.value&&I.value===m.current),x=ht(I=>u||c.filter()===!1?!0:I.search?I.filtered.items.get(r)>0:!0);y.useEffect(()=>{let I=a.current;if(!(!I||t.disabled))return I.addEventListener(Vs,N),()=>I.removeEventListener(Vs,N)},[x,t.onSelect,t.disabled]);function N(){var I,C;f(),(C=(I=l.current).onSelect)==null||C.call(I,m.current)}function f(){d.setState("value",m.current,!0)}if(!x)return null;let{disabled:g,value:v,onSelect:b,forceMount:p,keywords:w,...S}=t;return y.createElement(at.div,{ref:Pt(a,e),...S,id:r,"cmdk-item":"",role:"option","aria-disabled":!!g,"aria-selected":!!h,"data-disabled":!!g,"data-selected":!!h,onPointerMove:g||c.getDisablePointerSelection()?void 0:f,onClick:g?void 0:N},t.children)}),Xl=y.forwardRef((t,e)=>{let{heading:n,children:i,forceMount:r,...a}=t,o=Ct(),c=y.useRef(null),l=y.useRef(null),u=Ct(),m=Wt(),d=ht(x=>r||m.filter()===!1?!0:x.search?x.filtered.groups.has(o):!0);ft(()=>m.group(o),[]),qi(o,c,[t.value,t.heading,l]);let h=y.useMemo(()=>({id:o,forceMount:r}),[r]);return y.createElement(at.div,{ref:Pt(c,e),...a,"cmdk-group":"",role:"presentation",hidden:d?void 0:!0},n&&y.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:u},n),ps(t,x=>y.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?u:void 0},y.createElement($i.Provider,{value:h},x))))}),Yl=y.forwardRef((t,e)=>{let{alwaysRender:n,...i}=t,r=y.useRef(null),a=ht(o=>!o.search);return!n&&!a?null:y.createElement(at.div,{ref:Pt(r,e),...i,"cmdk-separator":"",role:"separator"})}),Ql=y.forwardRef((t,e)=>{let{onValueChange:n,...i}=t,r=t.value!=null,a=dn(),o=ht(u=>u.search),c=ht(u=>u.selectedItemId),l=Wt();return y.useEffect(()=>{t.value!=null&&a.setState("search",t.value)},[t.value]),y.createElement(at.input,{ref:e,...i,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":c,id:l.inputId,type:"text",value:r?t.value:o,onChange:u=>{r||a.setState("search",u.target.value),n?.(u.target.value)}})}),Zl=y.forwardRef((t,e)=>{let{children:n,label:i="Suggestions",...r}=t,a=y.useRef(null),o=y.useRef(null),c=ht(u=>u.selectedItemId),l=Wt();return y.useEffect(()=>{if(o.current&&a.current){let u=o.current,m=a.current,d,h=new ResizeObserver(()=>{d=requestAnimationFrame(()=>{let x=u.offsetHeight;m.style.setProperty("--cmdk-list-height",x.toFixed(1)+"px")})});return h.observe(u),()=>{cancelAnimationFrame(d),h.unobserve(u)}}},[]),y.createElement(at.div,{ref:Pt(a,e),...r,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":c,"aria-label":i,id:l.listId},ps(t,u=>y.createElement("div",{ref:Pt(o,l.listInnerRef),"cmdk-list-sizer":""},u)))}),Jl=y.forwardRef((t,e)=>{let{open:n,onOpenChange:i,overlayClassName:r,contentClassName:a,container:o,...c}=t;return y.createElement(vi,{open:n,onOpenChange:i},y.createElement(Ni,{container:o},y.createElement(Ci,{"cmdk-overlay":"",className:r}),y.createElement(ji,{"aria-label":t.label,"cmdk-dialog":"",className:a},y.createElement(Wi,{ref:e,...c}))))}),ec=y.forwardRef((t,e)=>ht(n=>n.filtered.count===0)?y.createElement(at.div,{ref:e,...t,"cmdk-empty":"",role:"presentation"}):null),tc=y.forwardRef((t,e)=>{let{progress:n,children:i,label:r="Loading...",...a}=t;return y.createElement(at.div,{ref:e,...a,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":r},ps(t,o=>y.createElement("div",{"aria-hidden":!0},o)))}),Tt=Object.assign(Wi,{List:Zl,Item:Kl,Input:Ql,Group:Xl,Separator:Yl,Dialog:Jl,Empty:ec,Loading:tc});function sc(t,e){let n=t.nextElementSibling;for(;n;){if(n.matches(e))return n;n=n.nextElementSibling}}function nc(t,e){let n=t.previousElementSibling;for(;n;){if(n.matches(e))return n;n=n.previousElementSibling}}function Gi(t){let e=y.useRef(t);return ft(()=>{e.current=t}),e}var ft=typeof window>"u"?y.useEffect:y.useLayoutEffect;function jt(t){let e=y.useRef();return e.current===void 0&&(e.current=t()),e}function ht(t){let e=dn(),n=()=>t(e.snapshot());return y.useSyncExternalStore(e.subscribe,n,n)}function qi(t,e,n,i=[]){let r=y.useRef(),a=Wt();return ft(()=>{var o;let c=(()=>{var u;for(let m of n){if(typeof m=="string")return m.trim();if(typeof m=="object"&&"current"in m)return m.current?(u=m.current.textContent)==null?void 0:u.trim():r.current}})(),l=i.map(u=>u.trim());a.value(t,c,l),(o=e.current)==null||o.setAttribute(vt,c),r.current=c}),r}var ic=()=>{let[t,e]=y.useState(),n=jt(()=>new Map);return ft(()=>{n.current.forEach(i=>i()),n.current=new Map},[t]),(i,r)=>{n.current.set(i,r),e({})}};function rc(t){let e=t.type;return typeof e=="function"?e(t.props):"render"in e?e.render(t.props):t}function ps({asChild:t,children:e},n){return t&&y.isValidElement(e)?y.cloneElement(rc(e),{ref:e.ref},n(e.props.children)):n(e)}var ac={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function oc({className:t,...e}){return s.jsx(Tt,{"data-slot":"command",className:H("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",t),...e})}function lc({title:t="Command Palette",description:e="Search for a command to run...",children:n,className:i,showCloseButton:r=!0,shouldFilter:a,...o}){return s.jsxs(en,{...o,children:[s.jsxs(Si,{className:"sr-only",children:[s.jsx(tn,{children:t}),s.jsx(sn,{children:e})]}),s.jsx(nn,{className:H("overflow-hidden p-0",i),showCloseButton:r,children:s.jsx(oc,{shouldFilter:a,className:"[&_[cmdk-group-heading]]:text-muted-foreground **:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:n})})]})}function cc({className:t,...e}){return s.jsxs("div",{"data-slot":"command-input-wrapper",className:"flex h-9 items-center gap-2 border-b px-3",children:[s.jsx(so,{className:"size-4 shrink-0 opacity-50"}),s.jsx(Tt.Input,{"data-slot":"command-input",className:H("placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",t),...e})]})}function dc({className:t,...e}){return s.jsx(Tt.List,{"data-slot":"command-list",className:H("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",t),...e})}function uc({...t}){return s.jsx(Tt.Empty,{"data-slot":"command-empty",className:"py-6 text-center text-sm",...t})}function mc({className:t,...e}){return s.jsx(Tt.Group,{"data-slot":"command-group",className:H("text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",t),...e})}function hc({className:t,...e}){return s.jsx(Tt.Item,{"data-slot":"command-item",className:H("data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...e})}const Rn=400,gc=32,pc={enterprise:"Enterprise",system:"System",container:"Container",generic:"Boundary",node:"Node"},fc={c4:"C4 Element",c4Boundary:"C4 Boundary",group:"Frame",shape:"Shape",default:"Shape",cloud:"Cloud",text:"Text",code:"Code",table:"Table",databaseTableSQL:"Database Table",dataTableInterface:"Data Table",sequenceParticipant:"Participant",subDiagram:"Sub Diagram",builder:"Node"};function un(t){return fc[t]??"Node"}function ks(t){return t.length<=Rn?t:`${t.slice(0,Rn)}…`}function zn(t){return t.split(`
|
|
62
|
+
`).find(n=>n.trim().length>0)?.trim()??""}function lt(t,e){const n=t.data.componentFields;return ai(n,{componentFieldId:e})??""}function xc(t,e){const n=[];let i=t,r=0;for(;i.parentId&&r<gc;){const a=e.get(i.parentId);if(!a)break;const o=lt(a,"name");o&&n.unshift(o),i=a,r++}return n.join(" / ")}function bc(t){const e={id:t.id,nodeType:t.type??"default",title:"",subtitle:un(t.type??"default"),technology:"",description:"",content:""};if(t.type==="c4"){const i=t.data.c4Kind,r=t.data.isExternal===!0;return{...e,title:lt(t,"name"),subtitle:`${r?"External ":""}${i?ri[i]:"C4 Element"}`,technology:t.data.technology??"",description:t.data.description??""}}if(t.type==="c4Boundary"){const i=t.data.c4BoundaryKind;return{...e,title:lt(t,"name"),subtitle:t.data.boundaryType??(i?pc[i]:"Boundary"),description:t.data.description??""}}if(t.type==="text"){const i=lt(t,"text");return i.trim()?{...e,title:zn(i),content:ks(i)}:null}if(t.type==="code"){const i=lt(t,"code");return i.trim()?{...e,title:zn(i),content:ks(i)}:null}if(t.type==="table"){const i=t.data.columns??[],r=t.data.rows??[];return{...e,title:lt(t,"name")||"Table",content:ks([...i,...r.flat()].join(" "))}}if(t.type==="databaseTableSQL"){const i=t.data.localTable,r=t.data.serviceTable,a=i??r;return{...e,title:a?.tableName??"Table",subtitle:a?.databaseName??e.subtitle}}if(t.type==="sequenceParticipant")return{...e,title:t.data.label??lt(t,"name")};if(t.type==="subDiagram")return{...e,title:t.data.diagramName??"Sub Diagram"};if(t.type==="image"||t.type==="gif"||t.type==="comment")return null;const n=lt(t,"name");return n.trim()?{...e,title:n}:null}function yc(t){const e=new Map(t.map(i=>[i.id,i])),n=[];for(const i of t){const r=bc(i);r&&(!r.title.trim()&&!r.content.trim()||n.push({...r,title:r.title.trim()||un(r.nodeType),parentPath:xc(i,e)}))}return n}const vc=50;function jc(){const{reactFlowInstance:t,isCommandPaletteOpen:e,setIsCommandPaletteOpen:n,setSelectedNodeIds:i}=we(),[r,a]=y.useState(""),[o,c]=y.useState([]);y.useEffect(()=>{!e||!t||(a(""),c(yc(t.getNodes())))},[e,t]);const l=no(o,r,{threshold:.4,ignoreLocation:!0,keys:[{name:"title",weight:.55},{name:"description",weight:.2},{name:"content",weight:.15},{name:"technology",weight:.1}]}),u=y.useMemo(()=>{const d=new Map;for(const h of l.slice(0,vc)){const x=d.get(h.nodeType);x&&x.push(h),x||d.set(h.nodeType,[h])}return[...d.entries()]},[l]);function m(d){t&&(i([d]),oi(t,[d]),n(!1))}return s.jsxs(lc,{open:e,onOpenChange:n,title:"Search diagram",description:"Search and jump to a node, frame, or boundary",shouldFilter:!1,className:"border-[#2A3242] bg-[#141925] text-[#F4F7FC]",children:[s.jsx(cc,{value:r,onValueChange:a,placeholder:"Search nodes, frames, text…"}),s.jsxs(dc,{className:"max-h-[24rem]",children:[s.jsx(uc,{children:"No matching nodes."}),u.map(([d,h])=>s.jsx(mc,{heading:un(d),children:h.map(x=>s.jsxs(hc,{value:x.id,onSelect:()=>m(x.id),className:"flex-col items-start gap-0.5 data-[selected=true]:bg-[#1E2533]",children:[s.jsx("span",{className:"w-full truncate text-sm",children:x.title}),s.jsx("span",{className:"w-full truncate text-xs text-[#828DA3]",children:[x.subtitle,x.technology,x.parentPath&&`in ${x.parentPath}`,x.description].filter(Boolean).join(" · ")})]},x.id))},d))]})]})}function wc(t,e=!1){const n=t.length;let i=0,r="",a=0,o=16,c=0,l=0,u=0,m=0,d=0;function h(p,w){let S=0,I=0;for(;S<p;){let C=t.charCodeAt(i);if(C>=48&&C<=57)I=I*16+C-48;else if(C>=65&&C<=70)I=I*16+C-65+10;else if(C>=97&&C<=102)I=I*16+C-97+10;else break;i++,S++}return S<p&&(I=-1),I}function x(p){i=p,r="",a=0,o=16,d=0}function N(){let p=i;if(t.charCodeAt(i)===48)i++;else for(i++;i<t.length&&bt(t.charCodeAt(i));)i++;if(i<t.length&&t.charCodeAt(i)===46)if(i++,i<t.length&&bt(t.charCodeAt(i)))for(i++;i<t.length&&bt(t.charCodeAt(i));)i++;else return d=3,t.substring(p,i);let w=i;if(i<t.length&&(t.charCodeAt(i)===69||t.charCodeAt(i)===101))if(i++,(i<t.length&&t.charCodeAt(i)===43||t.charCodeAt(i)===45)&&i++,i<t.length&&bt(t.charCodeAt(i))){for(i++;i<t.length&&bt(t.charCodeAt(i));)i++;w=i}else d=3;return t.substring(p,w)}function f(){let p="",w=i;for(;;){if(i>=n){p+=t.substring(w,i),d=2;break}const S=t.charCodeAt(i);if(S===34){p+=t.substring(w,i),i++;break}if(S===92){if(p+=t.substring(w,i),i++,i>=n){d=2;break}switch(t.charCodeAt(i++)){case 34:p+='"';break;case 92:p+="\\";break;case 47:p+="/";break;case 98:p+="\b";break;case 102:p+="\f";break;case 110:p+=`
|
|
63
63
|
`;break;case 114:p+="\r";break;case 116:p+=" ";break;case 117:const C=h(4);C>=0?p+=String.fromCharCode(C):d=4;break;default:d=5}w=i;continue}if(S>=0&&S<=31)if(Lt(S)){p+=t.substring(w,i),d=2;break}else d=6;i++}return p}function g(){if(r="",d=0,a=i,l=c,m=u,i>=n)return a=n,o=17;let p=t.charCodeAt(i);if(Is(p)){do i++,r+=String.fromCharCode(p),p=t.charCodeAt(i);while(Is(p));return o=15}if(Lt(p))return i++,r+=String.fromCharCode(p),p===13&&t.charCodeAt(i)===10&&(i++,r+=`
|
|
64
|
-
`),c++,u=i,o=14;switch(p){case 123:return i++,o=1;case 125:return i++,o=2;case 91:return i++,o=3;case 93:return i++,o=4;case 58:return i++,o=6;case 44:return i++,o=5;case 34:return i++,r=f(),o=10;case 47:const w=i-1;if(t.charCodeAt(i+1)===47){for(i+=2;i<n&&!Lt(t.charCodeAt(i));)i++;return r=t.substring(w,i),o=12}if(t.charCodeAt(i+1)===42){i+=2;const S=n-1;let I=!1;for(;i<S;){const C=t.charCodeAt(i);if(C===42&&t.charCodeAt(i+1)===47){i+=2,I=!0;break}i++,Lt(C)&&(C===13&&t.charCodeAt(i)===10&&i++,c++,u=i)}return I||(i++,d=1),r=t.substring(w,i),o=13}return r+=String.fromCharCode(p),i++,o=16;case 45:if(r+=String.fromCharCode(p),i++,i===n||!bt(t.charCodeAt(i)))return o=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return r+=N(),o=11;default:for(;i<n&&v(p);)i++,p=t.charCodeAt(i);if(a!==i){switch(r=t.substring(a,i),r){case"true":return o=8;case"false":return o=9;case"null":return o=7}return o=16}return r+=String.fromCharCode(p),i++,o=16}}function v(p){if(Is(p)||Lt(p))return!1;switch(p){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}function b(){let p;do p=g();while(p>=12&&p<=15);return p}return{setPosition:x,getPosition:()=>i,scan:e?b:g,getToken:()=>o,getTokenValue:()=>r,getTokenOffset:()=>a,getTokenLength:()=>i-a,getTokenStartLine:()=>l,getTokenStartCharacter:()=>a-m,getTokenError:()=>d}}function Is(t){return t===32||t===9}function Lt(t){return t===10||t===13}function bt(t){return t>=48&&t<=57}var
|
|
64
|
+
`),c++,u=i,o=14;switch(p){case 123:return i++,o=1;case 125:return i++,o=2;case 91:return i++,o=3;case 93:return i++,o=4;case 58:return i++,o=6;case 44:return i++,o=5;case 34:return i++,r=f(),o=10;case 47:const w=i-1;if(t.charCodeAt(i+1)===47){for(i+=2;i<n&&!Lt(t.charCodeAt(i));)i++;return r=t.substring(w,i),o=12}if(t.charCodeAt(i+1)===42){i+=2;const S=n-1;let I=!1;for(;i<S;){const C=t.charCodeAt(i);if(C===42&&t.charCodeAt(i+1)===47){i+=2,I=!0;break}i++,Lt(C)&&(C===13&&t.charCodeAt(i)===10&&i++,c++,u=i)}return I||(i++,d=1),r=t.substring(w,i),o=13}return r+=String.fromCharCode(p),i++,o=16;case 45:if(r+=String.fromCharCode(p),i++,i===n||!bt(t.charCodeAt(i)))return o=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return r+=N(),o=11;default:for(;i<n&&v(p);)i++,p=t.charCodeAt(i);if(a!==i){switch(r=t.substring(a,i),r){case"true":return o=8;case"false":return o=9;case"null":return o=7}return o=16}return r+=String.fromCharCode(p),i++,o=16}}function v(p){if(Is(p)||Lt(p))return!1;switch(p){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}function b(){let p;do p=g();while(p>=12&&p<=15);return p}return{setPosition:x,getPosition:()=>i,scan:e?b:g,getToken:()=>o,getTokenValue:()=>r,getTokenOffset:()=>a,getTokenLength:()=>i-a,getTokenStartLine:()=>l,getTokenStartCharacter:()=>a-m,getTokenError:()=>d}}function Is(t){return t===32||t===9}function Lt(t){return t===10||t===13}function bt(t){return t>=48&&t<=57}var Mn;(function(t){t[t.lineFeed=10]="lineFeed",t[t.carriageReturn=13]="carriageReturn",t[t.space=32]="space",t[t._0=48]="_0",t[t._1=49]="_1",t[t._2=50]="_2",t[t._3=51]="_3",t[t._4=52]="_4",t[t._5=53]="_5",t[t._6=54]="_6",t[t._7=55]="_7",t[t._8=56]="_8",t[t._9=57]="_9",t[t.a=97]="a",t[t.b=98]="b",t[t.c=99]="c",t[t.d=100]="d",t[t.e=101]="e",t[t.f=102]="f",t[t.g=103]="g",t[t.h=104]="h",t[t.i=105]="i",t[t.j=106]="j",t[t.k=107]="k",t[t.l=108]="l",t[t.m=109]="m",t[t.n=110]="n",t[t.o=111]="o",t[t.p=112]="p",t[t.q=113]="q",t[t.r=114]="r",t[t.s=115]="s",t[t.t=116]="t",t[t.u=117]="u",t[t.v=118]="v",t[t.w=119]="w",t[t.x=120]="x",t[t.y=121]="y",t[t.z=122]="z",t[t.A=65]="A",t[t.B=66]="B",t[t.C=67]="C",t[t.D=68]="D",t[t.E=69]="E",t[t.F=70]="F",t[t.G=71]="G",t[t.H=72]="H",t[t.I=73]="I",t[t.J=74]="J",t[t.K=75]="K",t[t.L=76]="L",t[t.M=77]="M",t[t.N=78]="N",t[t.O=79]="O",t[t.P=80]="P",t[t.Q=81]="Q",t[t.R=82]="R",t[t.S=83]="S",t[t.T=84]="T",t[t.U=85]="U",t[t.V=86]="V",t[t.W=87]="W",t[t.X=88]="X",t[t.Y=89]="Y",t[t.Z=90]="Z",t[t.asterisk=42]="asterisk",t[t.backslash=92]="backslash",t[t.closeBrace=125]="closeBrace",t[t.closeBracket=93]="closeBracket",t[t.colon=58]="colon",t[t.comma=44]="comma",t[t.dot=46]="dot",t[t.doubleQuote=34]="doubleQuote",t[t.minus=45]="minus",t[t.openBrace=123]="openBrace",t[t.openBracket=91]="openBracket",t[t.plus=43]="plus",t[t.slash=47]="slash",t[t.formFeed=12]="formFeed",t[t.tab=9]="tab"})(Mn||(Mn={}));new Array(20).fill(0).map((t,e)=>" ".repeat(e));const yt=200;new Array(yt).fill(0).map((t,e)=>`
|
|
65
65
|
`+" ".repeat(e)),new Array(yt).fill(0).map((t,e)=>"\r"+" ".repeat(e)),new Array(yt).fill(0).map((t,e)=>`\r
|
|
66
66
|
`+" ".repeat(e)),new Array(yt).fill(0).map((t,e)=>`
|
|
67
67
|
`+" ".repeat(e)),new Array(yt).fill(0).map((t,e)=>"\r"+" ".repeat(e)),new Array(yt).fill(0).map((t,e)=>`\r
|
|
68
|
-
`+" ".repeat(e));var cs;(function(t){t.DEFAULT={allowTrailingComma:!1}})(cs||(cs={}));function wc(t,e=[],n=cs.DEFAULT){let i=null,r=[];const a=[];function o(l){Array.isArray(r)?r.push(l):i!==null&&(r[i]=l)}return Nc(t,{onObjectBegin:()=>{const l={};o(l),a.push(r),r=l,i=null},onObjectProperty:l=>{i=l},onObjectEnd:()=>{r=a.pop()},onArrayBegin:()=>{const l=[];o(l),a.push(r),r=l,i=null},onArrayEnd:()=>{r=a.pop()},onLiteralValue:o,onError:(l,u,m)=>{e.push({error:l,offset:u,length:m})}},n),r[0]}function Nc(t,e,n=cs.DEFAULT){const i=jc(t,!1),r=[];let a=0;function o(F){return F?()=>a===0&&F(i.getTokenOffset(),i.getTokenLength(),i.getTokenStartLine(),i.getTokenStartCharacter()):()=>!0}function c(F){return F?G=>a===0&&F(G,i.getTokenOffset(),i.getTokenLength(),i.getTokenStartLine(),i.getTokenStartCharacter()):()=>!0}function l(F){return F?G=>a===0&&F(G,i.getTokenOffset(),i.getTokenLength(),i.getTokenStartLine(),i.getTokenStartCharacter(),()=>r.slice()):()=>!0}function u(F){return F?()=>{a>0?a++:F(i.getTokenOffset(),i.getTokenLength(),i.getTokenStartLine(),i.getTokenStartCharacter(),()=>r.slice())===!1&&(a=1)}:()=>!0}function m(F){return F?()=>{a>0&&a--,a===0&&F(i.getTokenOffset(),i.getTokenLength(),i.getTokenStartLine(),i.getTokenStartCharacter())}:()=>!0}const d=u(e.onObjectBegin),h=l(e.onObjectProperty),x=m(e.onObjectEnd),N=u(e.onArrayBegin),f=m(e.onArrayEnd),g=l(e.onLiteralValue),v=c(e.onSeparator),b=o(e.onComment),p=c(e.onError),w=n&&n.disallowComments,S=n&&n.allowTrailingComma;function I(){for(;;){const F=i.scan();switch(i.getTokenError()){case 4:C(14);break;case 5:C(15);break;case 3:C(13);break;case 1:w||C(11);break;case 2:C(12);break;case 6:C(16);break}switch(F){case 12:case 13:w?C(10):b();break;case 16:C(1);break;case 15:case 14:break;default:return F}}}function C(F,G=[],ae=[]){if(p(F),G.length+ae.length>0){let me=i.getToken();for(;me!==17;){if(G.indexOf(me)!==-1){I();break}else if(ae.indexOf(me)!==-1)break;me=I()}}}function A(F){const G=i.getTokenValue();return F?g(G):(h(G),r.push(G)),I(),!0}function M(){switch(i.getToken()){case 11:const F=i.getTokenValue();let G=Number(F);isNaN(G)&&(C(2),G=0),g(G);break;case 7:g(null);break;case 8:g(!0);break;case 9:g(!1);break;default:return!1}return I(),!0}function T(){return i.getToken()!==10?(C(3,[],[2,5]),!1):(A(!1),i.getToken()===6?(v(":"),I(),O()||C(4,[],[2,5])):C(5,[],[2,5]),r.pop(),!0)}function R(){d(),I();let F=!1;for(;i.getToken()!==2&&i.getToken()!==17;){if(i.getToken()===5){if(F||C(4,[],[]),v(","),I(),i.getToken()===2&&S)break}else F&&C(6,[],[]);T()||C(4,[],[2,5]),F=!0}return x(),i.getToken()!==2?C(7,[2],[]):I(),!0}function k(){N(),I();let F=!0,G=!1;for(;i.getToken()!==4&&i.getToken()!==17;){if(i.getToken()===5){if(G||C(4,[],[]),v(","),I(),i.getToken()===4&&S)break}else G&&C(6,[],[]);F?(r.push(0),F=!1):r[r.length-1]++,O()||C(4,[],[4,5]),G=!0}return f(),F||r.pop(),i.getToken()!==4?C(8,[4],[]):I(),!0}function O(){switch(i.getToken()){case 3:return k();case 1:return R();case 10:return A(!0);default:return M()}}return I(),i.getToken()===17?n.allowEmptyContent?!0:(C(4,[],[]),!1):O()?(i.getToken()!==17&&C(9,[],[]),!0):(C(4,[],[]),!1)}var Mn;(function(t){t[t.None=0]="None",t[t.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",t[t.UnexpectedEndOfString=2]="UnexpectedEndOfString",t[t.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",t[t.InvalidUnicode=4]="InvalidUnicode",t[t.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",t[t.InvalidCharacter=6]="InvalidCharacter"})(Mn||(Mn={}));var On;(function(t){t[t.OpenBraceToken=1]="OpenBraceToken",t[t.CloseBraceToken=2]="CloseBraceToken",t[t.OpenBracketToken=3]="OpenBracketToken",t[t.CloseBracketToken=4]="CloseBracketToken",t[t.CommaToken=5]="CommaToken",t[t.ColonToken=6]="ColonToken",t[t.NullKeyword=7]="NullKeyword",t[t.TrueKeyword=8]="TrueKeyword",t[t.FalseKeyword=9]="FalseKeyword",t[t.StringLiteral=10]="StringLiteral",t[t.NumericLiteral=11]="NumericLiteral",t[t.LineCommentTrivia=12]="LineCommentTrivia",t[t.BlockCommentTrivia=13]="BlockCommentTrivia",t[t.LineBreakTrivia=14]="LineBreakTrivia",t[t.Trivia=15]="Trivia",t[t.Unknown=16]="Unknown",t[t.EOF=17]="EOF"})(On||(On={}));const Cc=wc;var Bn;(function(t){t[t.InvalidSymbol=1]="InvalidSymbol",t[t.InvalidNumberFormat=2]="InvalidNumberFormat",t[t.PropertyNameExpected=3]="PropertyNameExpected",t[t.ValueExpected=4]="ValueExpected",t[t.ColonExpected=5]="ColonExpected",t[t.CommaExpected=6]="CommaExpected",t[t.CloseBraceExpected=7]="CloseBraceExpected",t[t.CloseBracketExpected=8]="CloseBracketExpected",t[t.EndOfFileExpected=9]="EndOfFileExpected",t[t.InvalidCommentToken=10]="InvalidCommentToken",t[t.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",t[t.UnexpectedEndOfString=12]="UnexpectedEndOfString",t[t.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",t[t.InvalidUnicode=14]="InvalidUnicode",t[t.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",t[t.InvalidCharacter=16]="InvalidCharacter"})(Bn||(Bn={}));async function Ks(t,e){if(e===void 0)try{return await ko(t)}catch{throw new Error("Failed to import Mermaid diagram")}const n=Cc(e);if(n===null||typeof n!="object"||Array.isArray(n))throw new Error("Invalid Mermaid context file");try{return await Ao(t,n,{repositionNodes:!0})}catch{throw new Error("Failed to import Mermaid diagram")}}async function Sc(){const[...t]=await as({multiple:!0,accept:".mmd,.txt,.json,.jsonc"}),e=t.find(r=>r.name.toLowerCase().endsWith(".mmd"))??t.find(r=>r.name.toLowerCase().endsWith(".txt"));if(!e)throw new Error("No Mermaid file found");const n=t.find(r=>r.name.toLowerCase().endsWith(".json"))??t.find(r=>r.name.toLowerCase().endsWith(".jsonc")),i=await e.text();return n?Ks(i,await n.text()):Ks(i)}function kc(t,e){return Io(t)?To(t,e):Di(t)?Eo(t,e):Lo({nodes:t,edges:e})}function Ic(t,e,n){const i=n.trim().replace(/[\\/:*?"<>|]+/g,"-").replace(/\s+/g," ")||"uigraph-diagram",r=kc(t,e),a=new Blob([r.mermaid],{type:"text/plain;charset=utf-8"}),o=URL.createObjectURL(a),c=document.createElement("a");c.href=o,c.download=`${i}.mmd`,c.click();const l=new Blob([JSON.stringify(r.context,null,2)],{type:"application/json;charset=utf-8"}),u=URL.createObjectURL(l),m=document.createElement("a");m.href=u,m.download=`${i}-context.json`,m.click(),URL.revokeObjectURL(u),URL.revokeObjectURL(o)}function Tc(){const{setNodes:t,setEdges:e}=we(),[n,i]=y.useState(!1),[r,a]=y.useState(""),[o,c]=y.useState(""),[l,u]=y.useState(!1);return s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Q,{preset:"outline",onClick:()=>i(!0),children:[s.jsx(wa,{}),"Insert Code"]}),s.jsx(on,{open:n,onOpenChange:i,children:s.jsx(ln,{title:"Insert code",description:"Paste your Mermaid diagram and optionally its context JSON.",footerCancel:!0,footerSubmit:"Import",footerSubmitLoading:l,onFooterSubmitClick:async()=>{if(!r.trim())return U.error("Mermaid code is required");u(!0);try{const m=await Ks(r,o.trim()||void 0);t(m.nodes),e(m.edges),i(!1),a(""),c(""),U.success("Diagram imported successfully")}catch{U.error("Failed to import the pasted code")}finally{u(!1)}},children:s.jsxs("div",{className:"flex flex-col gap-5",children:[s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(le,{children:"Mermaid"}),s.jsx(Ws,{value:r,onChange:m=>a(m.target.value),placeholder:"flowchart TD ...",className:"min-h-[220px] font-mono"})]}),s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(le,{children:"Context JSON (optional)"}),s.jsx(Ws,{value:o,onChange:m=>c(m.target.value),placeholder:"{ ... }",className:"min-h-[140px] font-mono"})]})]})})})]})}const Ec=br("5s");function Lc(){const{diagramId:t,diagramName:e,organizationId:n,isEmbedded:i,childDiagramIds:r,setChildDiagramIds:a}=we(),o=zo(),c=y.useRef(null),[l,u]=y.useState(!1),[m,d]=y.useState(!1),[h,x]=y.useState(!1),N=r[r.length-1];y.useEffect(()=>{u(!1),d(!1)},[N]);const f=y.useCallback(async g=>{if(!N||!n||m)return;d(!0);const v=c.current?.contentWindow?.__uigraphEmbedSave?.();v&&await Promise.race([v,new Promise(b=>setTimeout(b,Ec))]),d(!1),a(g);try{await o.query({query:bi,errorPolicy:"ignore",fetchPolicy:"network-only",variables:{orgId:n,id:N}})}catch{U.error("Failed to refresh the sub diagram preview")}},[o,m,N,n,a]);return y.useEffect(()=>{if(!N)return;window.__uigraphEmbedClose=()=>void f(r.slice(0,-1)),window.__uigraphOpenChild=v=>{if(t&&v===t){x(!0);return}f([...r,v])};function g(v){if(v.key==="Escape"){if(h){x(!1),v.stopPropagation(),v.stopImmediatePropagation();return}f(r.slice(0,-1))}}return window.addEventListener("keydown",g,{capture:!0}),()=>{delete window.__uigraphEmbedClose,delete window.__uigraphOpenChild,window.removeEventListener("keydown",g,{capture:!0})}},[N,r,t,h,f]),i||!N?null:s.jsxs(s.Fragment,{children:[s.jsx(tn,{open:!0,onOpenChange:g=>{g||f([])},children:s.jsxs(rn,{showCloseButton:!1,className:"bg-shading border-stock flex h-[94vh] w-[96vw] max-w-none flex-col gap-0 overflow-hidden rounded-[0.75rem] p-0 sm:max-w-none",children:[s.jsx(nn,{className:"hidden",children:"Edit the linked sub diagram without leaving this diagram"}),s.jsxs("div",{className:"border-stock flex h-12 shrink-0 items-center gap-2 border-b px-3",children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1 text-sm",children:[s.jsx("button",{type:"button",onClick:()=>void f([]),className:"text-paragraph max-w-[16rem] min-w-0 truncate transition-colors hover:text-[#F4F7FC]",children:e}),r.map((g,v)=>s.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[s.jsx(ct,{className:"text-paragraph size-3.5 shrink-0"}),v===r.length-1?s.jsx(sn,{className:"min-w-0 truncate text-sm font-medium text-[#F4F7FC]",children:s.jsx(Kt,{diagramId:g,organizationId:n})}):s.jsx("button",{type:"button",onClick:()=>void f(r.slice(0,v+1)),className:"text-paragraph max-w-[16rem] min-w-0 truncate transition-colors hover:text-[#F4F7FC]",children:s.jsx(Kt,{diagramId:g,organizationId:n})})]},`${g}-${v}`))]}),m&&s.jsxs("span",{className:"text-paragraph flex shrink-0 items-center gap-1.5 text-xs",children:[s.jsx(Os,{className:"size-3 animate-spin"}),"Saving…"]}),s.jsx("button",{type:"button",title:"Open in new tab",onClick:()=>li(N),className:"text-paragraph flex size-8 shrink-0 items-center justify-center rounded-[0.5rem] transition-colors hover:text-[#F4F7FC]",children:s.jsx(ki,{className:"size-4"})}),s.jsx(gs,{title:"Close",onClick:()=>void f([]),className:"size-8 shrink-0 rounded-[0.5rem]"})]}),s.jsxs("div",{className:"relative min-h-0 flex-1",children:[s.jsx("iframe",{ref:c,src:`/diagram/${N}/embed`,title:`Sub diagram of ${t}`,onLoad:()=>u(!0),className:"size-full border-0"},N),!l&&s.jsxs("div",{className:"bg-shading text-paragraph absolute inset-0 flex flex-col items-center justify-center gap-2",children:[s.jsx(Os,{className:"size-5 animate-spin"}),s.jsx("span",{className:"text-xs",children:"Opening diagram…"})]})]})]})}),s.jsx(on,{open:h,onOpenChange:g=>!g&&x(!1),className:"sm:max-w-[min(40rem,90%)]",children:s.jsx(ln,{title:"This is the main diagram",description:"Opening it here nests it inside itself.",children:s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("button",{type:"button",onClick:()=>{x(!1),t&&f([...r,t])},className:"border-stock hover:border-primary/60 flex flex-col rounded-xl border p-5 text-left transition-colors outline-none",children:[s.jsxs("span",{className:"grid flex-1 grid-cols-[auto_1fr] items-start gap-x-3 gap-y-0.5",children:[s.jsx("span",{className:"bg-primary/10 text-primary row-span-2 flex size-11 items-center justify-center rounded-xl",children:s.jsx(Na,{className:"size-5"})}),s.jsx("span",{className:"min-w-0 truncate text-sm font-medium text-[#F4F7FC]",children:"Open as child"}),s.jsx("span",{className:"text-paragraph line-clamp-2 min-w-0 text-xs leading-snug",children:"Nest the main diagram one level deeper"})]}),s.jsxs("span",{className:"mt-5 flex items-center gap-1 whitespace-nowrap",children:[s.jsx("span",{className:"border-stock/70 text-paragraph/80 shrink-0 rounded-md border px-1.5 py-0.5 text-[10px]",children:"Main diagram"}),s.jsx(ct,{className:"text-paragraph/50 size-3 shrink-0"}),r.length>1&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-paragraph/60 text-[10px]",children:"…"}),s.jsx(ct,{className:"text-paragraph/50 size-3 shrink-0"})]}),s.jsx("span",{className:"border-stock/70 text-paragraph/80 max-w-[5rem] truncate rounded-md border px-1.5 py-0.5 text-[10px]",children:s.jsx(Kt,{diagramId:N,organizationId:n})}),s.jsx(ct,{className:"text-primary/60 size-3 shrink-0"}),s.jsxs("span",{className:"border-primary/40 text-primary/90 flex shrink-0 items-center gap-1 rounded-md border px-1.5 py-0.5 text-[10px]",children:[s.jsx(Ca,{className:"size-3 shrink-0"}),"Main diagram"]})]})]}),s.jsxs("button",{type:"button",onClick:()=>{x(!1),f([])},className:"border-stock hover:border-paragraph/60 flex flex-col rounded-xl border p-5 text-left transition-colors outline-none",children:[s.jsxs("span",{className:"grid flex-1 grid-cols-[auto_1fr] items-start gap-x-3 gap-y-0.5",children:[s.jsx("span",{className:"bg-paragraph/10 text-paragraph row-span-2 flex size-11 items-center justify-center rounded-xl",children:s.jsx(Sa,{className:"size-5"})}),s.jsx("span",{className:"min-w-0 truncate text-sm font-medium text-[#F4F7FC]",children:"Close sub diagrams"}),s.jsx("span",{className:"text-paragraph line-clamp-2 min-w-0 text-xs leading-snug",children:"Close the sub diagrams and go back"})]}),s.jsxs("span",{className:"mt-5 flex items-center gap-1 whitespace-nowrap",children:[s.jsx("span",{className:"border-primary/40 text-primary/90 shrink-0 rounded-md border px-1.5 py-0.5 text-[10px]",children:"Main diagram"}),s.jsx(ct,{className:"text-paragraph/40 size-3 shrink-0"}),r.length>1&&s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"border-stock/40 text-paragraph/40 rounded-md border border-dashed px-1.5 py-0.5 text-[10px]",children:["+",r.length-1]}),s.jsx(ct,{className:"text-paragraph/40 size-3 shrink-0"})]}),s.jsx("span",{className:"border-stock/40 text-paragraph/40 max-w-[5rem] truncate rounded-md border border-dashed px-1.5 py-0.5 text-[10px] line-through",children:s.jsx(Kt,{diagramId:N,organizationId:n})})]})]})]})})})]})}function Kt({diagramId:t,organizationId:e}){const{data:n}=ut(bi,{errorPolicy:"ignore",fetchPolicy:"cache-first",skip:!e,variables:{orgId:e,id:t}});return s.jsx(s.Fragment,{children:n?.diagram?.name??"Untitled diagram"})}function Ac({className:t,...e}){return s.jsx("svg",{viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:H(Ye.icon,t),...e,children:s.jsx("path",{d:"M10.8006 2.94556L3.10059 10.6456M3.10059 2.94556L10.8006 10.6456",stroke:"currentColor",strokeWidth:"0.825",strokeLinecap:"round",strokeLinejoin:"round"})})}function Fc({className:t,...e}){return s.jsx("svg",{fill:"none",viewBox:"0 0 18 17",xmlns:"http://www.w3.org/2000/svg",className:H(Ye.icon,t),...e,children:s.jsx("path",{d:"M6.25055 6.4129L4.63222 8.1547C4.41645 8.37684 4.03136 8.95658 3.98489 9.4876C3.93602 10.046 4.43914 10.8471 4.63222 11.1538C5.13549 11.953 5.33814 12.3966 5.92688 13.1531C6.24661 13.5639 7.11028 14.3828 8.51622 14.486C9.56574 14.5629 10.6104 14.5558 11.1055 14.486C11.4455 14.438 12.2707 14.286 13.0475 13.4863C13.8243 12.6866 14.0185 11.3759 14.0185 10.8205V5.48894C14.0185 5.15571 13.8243 4.48927 13.0475 4.48927C12.2707 4.48927 12.0765 5.15571 12.0765 5.48894V7.82152M6.25055 9.4876V4.15605C6.25055 3.82282 6.44474 3.15638 7.22154 3.15638C7.99832 3.15638 8.19255 3.82282 8.19255 4.15605M8.19255 4.15605V7.15504M8.19255 4.15605V2.82315C8.19255 2.48993 8.38671 1.82349 9.16356 1.82349C9.94035 1.82349 10.1345 2.48993 10.1345 2.82315V4.15605M10.1345 4.15605V7.15504M10.1345 4.15605C10.1345 3.82282 10.3287 3.15638 11.1055 3.15638C11.8823 3.15638 12.0765 3.82282 12.0765 4.15605V5.82216",stroke:"currentColor",strokeWidth:"1.00395",strokeLinecap:"round",strokeLinejoin:"round"})})}function Dc({className:t,...e}){return s.jsx("svg",{fill:"none",viewBox:"0 0 18 17",xmlns:"http://www.w3.org/2000/svg",className:H(Ye.icon,t),...e,children:s.jsx("path",{d:"M7.52938 3.24873L11.5676 4.82891C13.8968 5.74032 15.0614 6.19602 15.0227 6.91887C14.9841 7.64177 13.7688 7.97321 11.338 8.63615C10.6143 8.83352 10.2524 8.93225 10.0015 9.1831C9.75056 9.43402 9.65191 9.79591 9.45447 10.5197C8.7916 12.9504 8.46009 14.1657 7.73725 14.2044C7.01438 14.243 6.55868 13.0784 5.64727 10.7493L4.06709 6.71102C3.11289 4.27249 2.63579 3.05324 3.25369 2.43533C3.8716 1.81743 5.09086 2.29453 7.52938 3.24873Z",stroke:"currentColor",strokeWidth:"1.00395",strokeLinejoin:"round"})})}function Rc({className:t,...e}){return s.jsxs("svg",{fill:"none",viewBox:"0 0 18 17",xmlns:"http://www.w3.org/2000/svg",className:H(Ye.icon,t),...e,children:[s.jsx("path",{d:"M12.3464 11.5281L15.0236 14.2053",stroke:"currentColor",strokeWidth:"1.00395",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M13.6851 7.51233C13.6851 4.55519 11.2878 2.15796 8.33069 2.15796C5.37355 2.15796 2.97632 4.55519 2.97632 7.51233C2.97632 10.4695 5.37355 12.8667 8.33069 12.8667C11.2878 12.8667 13.6851 10.4695 13.6851 7.51233Z",stroke:"currentColor",strokeWidth:"1.00395",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M5.98816 7.51246H10.6732M8.3307 5.16992V9.855",stroke:"currentColor",strokeWidth:"1.00395",strokeLinecap:"round",strokeLinejoin:"round"})]})}function zc({className:t,...e}){return s.jsxs("svg",{fill:"none",viewBox:"0 0 18 17",xmlns:"http://www.w3.org/2000/svg",className:H(Ye.icon,t),...e,children:[s.jsx("path",{d:"M12.3464 11.5281L15.0236 14.2053",stroke:"currentColor",strokeWidth:"1.00395",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M13.6851 7.51233C13.6851 4.55519 11.2878 2.15796 8.33069 2.15796C5.37355 2.15796 2.97632 4.55519 2.97632 7.51233C2.97632 10.4695 5.37355 12.8667 8.33069 12.8667C11.2878 12.8667 13.6851 10.4695 13.6851 7.51233Z",stroke:"currentColor",strokeWidth:"1.00395",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M5.98816 7.51246H10.6732",stroke:"currentColor",strokeWidth:"1.00395",strokeLinecap:"round",strokeLinejoin:"round"})]})}function Mc({className:t,...e}){return s.jsx("svg",{fill:"none",viewBox:"0 0 18 17",xmlns:"http://www.w3.org/2000/svg",className:H(Ye.icon,t),...e,children:s.jsx("path",{d:"M11.3425 14.2053C12.2766 14.2053 12.7436 14.2053 13.1236 14.09C13.9792 13.8305 14.6489 13.1609 14.9084 12.3052C15.0237 11.9252 15.0237 11.4582 15.0237 10.5242M15.0237 5.83909C15.0237 4.90505 15.0237 4.43803 14.9084 4.058C14.6489 3.20237 13.9792 2.53279 13.1236 2.27324C12.7436 2.15796 12.2766 2.15796 11.3425 2.15796M6.65745 14.2053C5.72341 14.2053 5.25639 14.2053 4.87636 14.09C4.02073 13.8305 3.35115 13.1609 3.0916 12.3052C2.97632 11.9252 2.97632 11.4582 2.97632 10.5242M2.97632 5.83909C2.97632 4.90505 2.97632 4.43803 3.0916 4.058C3.35115 3.20237 4.02073 2.53279 4.87636 2.27324C5.25639 2.15796 5.72341 2.15796 6.65745 2.15796",stroke:"currentColor",strokeWidth:"1.00395",strokeLinecap:"round",strokeLinejoin:"round"})})}function Oc({className:t,...e}){return s.jsxs("svg",{fill:"none",viewBox:"0 0 18 17",xmlns:"http://www.w3.org/2000/svg",className:H(Ye.icon,t),...e,children:[s.jsx("path",{d:"M8.99993 7.84697C9.33156 7.84697 9.63991 7.71412 10.2565 7.44841L10.7015 7.25665C11.7981 6.78414 12.3464 6.54788 12.3464 6.17373C12.3464 5.79958 11.7981 5.56332 10.7015 5.09079L10.2565 4.89905C9.63991 4.63334 9.33156 4.50049 8.99993 4.50049C8.66829 4.50049 8.35995 4.63334 7.74332 4.89905L7.29836 5.09079C6.20175 5.56332 5.65344 5.79958 5.65344 6.17373C5.65344 6.54788 6.20175 6.78414 7.29836 7.25665L7.74332 7.44841C8.35995 7.71412 8.66829 7.84697 8.99993 7.84697ZM8.99993 7.84697V11.8628",stroke:"currentColor",strokeWidth:"1.00395",strokeLinejoin:"round"}),s.jsx("path",{d:"M12.3464 6.17383V10.1896C12.3464 10.5637 11.7981 10.8 10.7015 11.2725L10.2565 11.4643C9.63991 11.73 9.33156 11.8629 8.99993 11.8629C8.66829 11.8629 8.35995 11.73 7.74332 11.4643L7.29836 11.2725C6.20175 10.8 5.65344 10.5637 5.65344 10.1896V6.17383",stroke:"currentColor",strokeWidth:"1.00395",strokeLinejoin:"round"}),s.jsx("path",{d:"M7.08858 1.82349C5.31025 1.86415 4.27153 2.03402 3.56184 2.74372C2.85214 3.45342 2.68226 4.49213 2.6416 6.27047M10.9112 1.82349C12.6896 1.86415 13.7283 2.03402 14.438 2.74372C15.1477 3.45342 15.3175 4.49213 15.3582 6.27047M10.9112 14.5401C12.6896 14.4994 13.7283 14.3296 14.438 13.6199C15.1477 12.9102 15.3175 11.8715 15.3582 10.0931M7.08858 14.5401C5.31025 14.4994 4.27153 14.3296 3.56184 13.6199C2.85214 12.9102 2.68226 11.8715 2.6416 10.0931",stroke:"currentColor",strokeWidth:"1.00395",strokeLinecap:"round",strokeLinejoin:"round"})]})}function Bc({className:t,...e}){return s.jsxs("svg",{fill:"none",viewBox:"0 0 18 17",xmlns:"http://www.w3.org/2000/svg",className:H(Ye.icon,t),...e,children:[s.jsx("path",{d:"M9.66929 2.15796H8.33069C5.80661 2.15796 4.54458 2.15796 3.76045 2.94209C2.97632 3.72622 2.97632 4.98825 2.97632 7.51233V8.85093C2.97632 11.375 2.97632 12.6371 3.76045 13.4212C4.54458 14.2053 5.80661 14.2053 8.33069 14.2053H9.66929C12.1933 14.2053 13.4554 14.2053 14.2395 13.4212C15.0237 12.6371 15.0237 11.375 15.0237 8.85093V7.51233C15.0237 4.98825 15.0237 3.72622 14.2395 2.94209C13.4554 2.15796 12.1933 2.15796 9.66929 2.15796Z",stroke:"currentColor",strokeWidth:"1.00395",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M6.99207 2.15796V14.2053",stroke:"currentColor",strokeWidth:"1.00395",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M11.0078 2.15796V14.2053",stroke:"currentColor",strokeWidth:"1.00395",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M15.0236 6.17383H2.97632",stroke:"currentColor",strokeWidth:"1.00395",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M15.0236 10.1897H2.97632",stroke:"currentColor",strokeWidth:"1.00395",strokeLinecap:"round",strokeLinejoin:"round"})]})}function _c({className:t,...e}){return s.jsxs("svg",{fill:"none",viewBox:"0 0 18 17",xmlns:"http://www.w3.org/2000/svg",className:H(Ye.icon,t),...e,children:[s.jsx("rect",{x:"1.5",y:"6.5",width:"4",height:"4",rx:"0.75",stroke:"currentColor",strokeWidth:"1.00395"}),s.jsx("rect",{x:"12.5",y:"2.5",width:"4",height:"3",rx:"0.75",stroke:"currentColor",strokeWidth:"1.00395"}),s.jsx("rect",{x:"12.5",y:"11.5",width:"4",height:"3",rx:"0.75",stroke:"currentColor",strokeWidth:"1.00395"}),s.jsx("path",{d:"M5.5 8.5H9.5",stroke:"currentColor",strokeWidth:"1.00395",strokeLinecap:"round"}),s.jsx("path",{d:"M9.5 4H9.5V13",stroke:"currentColor",strokeWidth:"1.00395",strokeLinecap:"round"}),s.jsx("path",{d:"M9.5 4H12.5",stroke:"currentColor",strokeWidth:"1.00395",strokeLinecap:"round"}),s.jsx("path",{d:"M9.5 13H12.5",stroke:"currentColor",strokeWidth:"1.00395",strokeLinecap:"round"})]})}function Pc({className:t,...e}){return s.jsxs("svg",{fill:"none",viewBox:"0 0 18 17",xmlns:"http://www.w3.org/2000/svg",className:H(Ye.icon,t),...e,children:[s.jsx("rect",{x:"7",y:"1",width:"4",height:"3.5",rx:"0.75",stroke:"currentColor",strokeWidth:"1.00395"}),s.jsx("rect",{x:"2",y:"12.5",width:"4",height:"3",rx:"0.75",stroke:"currentColor",strokeWidth:"1.00395"}),s.jsx("rect",{x:"12",y:"12.5",width:"4",height:"3",rx:"0.75",stroke:"currentColor",strokeWidth:"1.00395"}),s.jsx("path",{d:"M9 4.5V8.5",stroke:"currentColor",strokeWidth:"1.00395",strokeLinecap:"round"}),s.jsx("path",{d:"M4 8.5H14",stroke:"currentColor",strokeWidth:"1.00395",strokeLinecap:"round"}),s.jsx("path",{d:"M4 8.5V12.5",stroke:"currentColor",strokeWidth:"1.00395",strokeLinecap:"round"}),s.jsx("path",{d:"M14 8.5V12.5",stroke:"currentColor",strokeWidth:"1.00395",strokeLinecap:"round"})]})}function Hc({className:t,...e}){return s.jsxs("svg",{fill:"none",viewBox:"1.5 1.5 21 21",xmlns:"http://www.w3.org/2000/svg",className:H(Ye.icon,t),...e,children:[s.jsx("circle",{cx:"7",cy:"5",r:"2",stroke:"currentColor",strokeWidth:"1.17"}),s.jsx("circle",{cx:"17",cy:"5",r:"2",stroke:"currentColor",strokeWidth:"1.17"}),s.jsx("circle",{cx:"7",cy:"19",r:"2",stroke:"currentColor",strokeWidth:"1.17"}),s.jsx("circle",{cx:"17",cy:"19",r:"2",stroke:"currentColor",strokeWidth:"1.17"}),s.jsx("path",{d:"M7 7C7 12 17 12 17 17",stroke:"currentColor",strokeWidth:"1.17",strokeLinecap:"round"}),s.jsx("path",{d:"M17 7C17 12 7 12 7 17",pathLength:"100",strokeDasharray:"30 40 30",stroke:"currentColor",strokeWidth:"1.17",strokeLinecap:"round"})]})}const $c=160,Wc=60,Xt=40,Yt=60,_n=40,Gc=200,qc=120,Uc=150,Vc=90,Pn=80,Kc={cloud:{width:150,height:150},image:{width:150,height:150},gif:{width:150,height:150},databaseTableSQL:{width:500,height:400},table:{width:600,height:400},code:{width:300,height:400},builder:{width:300,height:200}};function pt(t){const e=t.type?Kc[t.type]:void 0,n=Math.max((typeof t.width=="number"&&isFinite(t.width)?t.width:void 0)??(typeof t.style?.width=="number"?t.style.width:void 0)??t.measured?.width??e?.width??$c,40),i=Math.max((typeof t.height=="number"&&isFinite(t.height)?t.height:void 0)??(typeof t.style?.height=="number"?t.style.height:void 0)??t.measured?.height??e?.height??Wc,20);return{width:n,height:i}}function Hn(t){const{width:e,height:n}=pt(t);return{left:t.position.x,top:t.position.y,right:t.position.x+e,bottom:t.position.y+n}}function Xc(t){const e=t.filter(i=>is(i)&&!i.parentId);if(e.length===0)return t;const n=[...t];for(let i=0;i<n.length;i++){const r=n[i];if(is(r)||r.parentId)continue;const a=Hn(r),o=e.filter(l=>{const u=Hn(l);return a.left>=u.left&&a.right<=u.right&&a.top>=u.top&&a.bottom<=u.bottom}).sort((l,u)=>{const m=pt(l),d=pt(u);return m.width*m.height-d.width*d.height})[0];if(!o)continue;n[i]={...r,parentId:o.id,position:{x:r.position.x-o.position.x,y:r.position.y-o.position.y}};const c=n.findIndex(l=>l.id===o.id);if(c>=0){const l=Array.isArray(n[c].data?.childNodes)?n[c].data.childNodes:[];l.includes(r.id)||(n[c]={...n[c],data:{...n[c].data,childNodes:[...l,r.id]}})}}return n}function Yc(t,e,n,i){if(e.length===0){const{width:g,height:v}=pt(t);return{children:[],groupWidth:g,groupHeight:v}}if(e.length===1){const{width:g,height:v}=pt(e[0]);return{children:[{...e[0],position:{x:Xt,y:Yt}}],groupWidth:g+Xt*2,groupHeight:v+Yt+_n}}const r=new ls.graphlib.Graph;r.setDefaultEdgeLabel(()=>({})),r.setGraph({rankdir:i,ranksep:Uc,nodesep:Vc});for(const g of e){const{width:v,height:b}=pt(g);r.setNode(g.id,{width:v,height:b})}const a=new Set(e.map(g=>g.id));for(const g of n)a.has(g.source)&&a.has(g.target)&&r.setEdge(g.source,g.target);ls.layout(r);let o=1/0,c=1/0,l=-1/0,u=-1/0;const m={};for(const g of e){const{x:v,y:b,width:p,height:w}=r.node(g.id),S=v-p/2,I=b-w/2;m[g.id]={x:S,y:I},o=Math.min(o,S),c=Math.min(c,I),l=Math.max(l,S+p),u=Math.max(u,I+w)}const d=Xt-o,h=Yt-c,x=e.map(g=>({...g,position:{x:m[g.id].x+d,y:m[g.id].y+h}})),N=l-o+Xt*2,f=u-c+Yt+_n;return{children:x,groupWidth:N,groupHeight:f}}function Qc(t,e){const n=new Map;for(const a of t)n.set(a.id,new Set);for(const a of e)n.has(a.source)&&n.has(a.target)&&(n.get(a.source).add(a.target),n.get(a.target).add(a.source));const i=new Set,r=[];for(const a of t){if(i.has(a.id))continue;const o=[],c=[a.id];for(;c.length>0;){const l=c.shift();if(i.has(l))continue;i.add(l);const u=t.find(m=>m.id===l);u&&o.push(u);for(const m of n.get(l)??[])i.has(m)||c.push(m)}r.push(o)}return r}function Zc(t,e,n){const i=new ls.graphlib.Graph;i.setDefaultEdgeLabel(()=>({})),i.setGraph({rankdir:n,ranksep:Gc,nodesep:qc});for(const u of t){const{width:m,height:d}=pt(u);i.setNode(u.id,{width:m,height:d})}for(const u of e)i.setEdge(u.source,u.target);ls.layout(i);let r=1/0,a=1/0,o=-1/0,c=-1/0;return{nodes:t.map(u=>{const{x:m,y:d,width:h,height:x}=i.node(u.id),N=m-h/2,f=d-x/2;return r=Math.min(r,N),a=Math.min(a,f),o=Math.max(o,N+h),c=Math.max(c,f+x),{...u,position:{x:N,y:f}}}),left:r,top:a,width:o-r,height:c-a}}function Jc(t){if(t.length===0)return[];if(t.length===1){const{nodes:l,left:u,top:m}=t[0];return l.map(d=>({...d,position:{x:d.position.x-u,y:d.position.y-m}}))}const e=t.reduce((l,u)=>l+u.width*u.height,0),n=Math.sqrt(e)*1.5,i=[...t].sort((l,u)=>u.height-l.height),r=[];let a=0,o=0,c=0;for(const l of i){a>0&&a+l.width>n&&(a=0,o+=c+Pn,c=0);const u=a-l.left,m=o-l.top;for(const d of l.nodes)r.push({...d,position:{x:d.position.x+u,y:d.position.y+m}});a+=l.width+Pn,c=Math.max(c,l.height)}return r}function Xs(t,e,n="LR"){const i=Xc(t),r=i.filter(g=>!g.parentId),a=i.filter(g=>!!g.parentId),o=new Map;for(const g of a){const v=g.parentId;o.has(v)||o.set(v,[]),o.get(v).push(g)}const c=new Map,l=r.map(g=>{if(!is(g))return g;const v=o.get(g.id)??[];if(v.length===0)return g;const b=new Set(v.map(C=>C.id)),p=e.filter(C=>b.has(C.source)&&b.has(C.target)),{children:w,groupWidth:S,groupHeight:I}=Yc(g,v,p,n);return c.set(g.id,w),{...g,style:{...g.style,width:S,height:I}}}),u=a.map(g=>c.get(g.parentId)?.find(b=>b.id===g.id)??g),m=new Map;for(const g of u)g.parentId&&m.set(g.id,g.parentId);const d=new Set(l.map(g=>g.id)),h=[];for(const g of e){const v=d.has(g.source)?g.source:m.get(g.source),b=d.has(g.target)?g.target:m.get(g.target);v&&b&&v!==b&&h.push({source:v,target:b})}const N=Qc(l,h).map(g=>{const v=new Set(g.map(p=>p.id)),b=h.filter(p=>v.has(p.source)&&v.has(p.target));return Zc(g,b,n)});return[...Jc(N),...u]}function ed(t,e,n){const r=Xs(t,e,n).map(o=>is(o)&&o.data?.autoLayout?{...o,data:{...o.data,autoLayout:!1}}:o),a=yr(r,e);return{nodes:r,edges:a}}function td(t,e,n="LR"){return t.some(r=>r.type==="sequenceParticipant")?Ue(t,e):ed(t,e,n)}const Ts=60,sd="#0b0e16";function nd(t){const e=vr(t),n=e.width+Ts,i=e.height+Ts,r=Po(e,n,i,1,1,Ts);return{x:r.x,y:r.y,zoom:r.zoom,width:n,height:i}}async function id(t){const e=nd(t),n=document.documentElement.querySelector(".react-flow__viewport");if(!n)throw new Error("Failed to download diagram");n.classList.add("downloading");const i=await $o(n,{width:e.width,height:e.height,backgroundColor:sd,style:{transform:`translate(${e.x}px, ${e.y}px) scale(${e.zoom})`},filter(r){return!r?.classList?.contains?.("react-flow__handle")}});return n.classList.remove("downloading"),i}function rd(t){return t.replace(/[<>:"/\\|?*]/g,"").trim().substring(0,200)||"diagram"}async function ad(t,e){const i=(await id(t)).toDataURL("image/webp"),r=e?`${rd(e)}.webp`:"diagram.webp",a=document.createElement("a");a.setAttribute("download",r),a.setAttribute("href",i),a.target="_blank",a.click(),URL.revokeObjectURL(i)}const qi="pointer-events-auto flex items-center gap-2 rounded-[0.75rem] border border-[#2A3242] bg-[#141925] p-1 shadow-sm";function od(){const[t,e]=y.useState(!1),[n,i]=y.useState(!1),r=ea(),{nodes:a,edges:o,setNodes:c,setEdges:l,selectedFrame:u,reactFlowInstance:m,cursorMode:d,setCursorMode:h,showGrid:x,setShowGrid:N,drawingMode:f,setDrawingMode:g,isPreviewing:v,isFullscreen:b,setIsFullscreen:p,isEmbedded:w,diagramName:S}=we(),I=Di(a),C=!w&&b;async function A(){e(!0);try{await ad(a,S),U.success("Diagram exported successfully")}catch{U.error("Failed to export diagram image")}finally{e(!1)}}async function M(){try{const R=await Sc();c(R.nodes),l(R.edges)}catch(R){U.error(R instanceof Error?R.message:"Failed to import Mermaid diagram")}}function T(){try{Ic(a,o,S),U.success("Diagram exported successfully")}catch{U.error("Failed to export the diagram")}}return s.jsxs("div",{className:"group/top-controls pointer-events-none absolute inset-0",children:[C&&s.jsx("div",{className:"pointer-events-auto absolute inset-x-0 top-0 h-10",children:s.jsx("div",{className:"pointer-events-none absolute top-0 left-1/2 flex h-5 w-14 -translate-x-1/2 items-center justify-center rounded-b-[0.375rem] border border-t-0 border-[#2A3242] bg-[#141925] transition-opacity duration-200 group-hover/top-controls:opacity-0",children:s.jsx(an,{className:"size-3.5 text-[#828DA3]"})})}),s.jsx("div",{className:H("absolute inset-x-0 top-3 flex items-center justify-center",C&&"-translate-y-[calc(100%_+_0.75rem)] transition-transform duration-200 group-hover/top-controls:translate-y-0",C&&n&&"translate-y-0"),children:s.jsxs("div",{className:qi,children:[s.jsxs(Ie,{delayDuration:100,tooltipPosition:"top",tooltip:d==="pan"?"Hand tool (switch to select)":"Select tool (switch to pan)",isActive:d==="pan",onClick:()=>h(d==="pan"?"select":"pan"),children:[d==="pan"&&s.jsx(Fc,{}),d==="select"&&s.jsx(Dc,{})]}),s.jsx(gt,{}),s.jsx(Ie,{onClick:()=>m&&mn(m,1/hn),delayDuration:100,tooltipPosition:"top",tooltip:"Zoom out",children:s.jsx(zc,{})}),s.jsx(Ie,{onClick:()=>m&&mn(m,hn),delayDuration:100,tooltipPosition:"top",tooltip:"Zoom in",children:s.jsx(Rc,{})}),s.jsx(gt,{}),s.jsx(Ie,{delayDuration:100,tooltipPosition:"top",tooltip:u?"Ungroup nodes":"Group nodes",disabled:v,isActive:f||!!u,onClick:()=>{if(u){const R=new Set(u.data?.childNodes??[]),k=u.parentId;c(O=>O.filter(F=>F.id!==u.id).map(F=>{if(R.has(F.id))return{...F,selected:!1,parentId:k,position:{x:F.position.x+u.position.x,y:F.position.y+u.position.y}};if(k&&F.id===k){const G=F.data?.childNodes??[];return{...F,data:{...F.data,childNodes:[...G.filter(ae=>ae!==u.id&&!R.has(ae)),...R]}}}return F}))}else g(R=>!R)},children:s.jsx(Oc,{})}),s.jsx(Ie,{delayDuration:100,tooltipPosition:"top",tooltip:x?"Hide grid":"Show grid",isActive:x,onClick:()=>N(R=>!R),children:s.jsx(Bc,{})}),!w&&s.jsx(Ie,{delayDuration:100,tooltipPosition:"top",tooltip:b?"Exit fullscreen":"Fullscreen",isActive:b,onClick:()=>p(R=>!R),children:s.jsx(Mc,{})}),s.jsx(gt,{}),s.jsx(Ie,{delayDuration:100,tooltipPosition:"top",tooltip:I?"Auto layout is unavailable for sequence diagrams":"Auto layout left-to-right",disabled:v||I,onClick:()=>{if(I)return;const R=Xs(a,o,"LR");c(R),setTimeout(()=>m?.fitView({padding:.2}),50)},children:s.jsx(_c,{})}),s.jsx(Ie,{delayDuration:100,tooltipPosition:"top",tooltip:I?"Auto layout is unavailable for sequence diagrams":"Auto layout top-to-bottom",disabled:v||I,onClick:()=>{if(I)return;const R=Xs(a,o,"TB");c(R),setTimeout(()=>m?.fitView({padding:.2}),50)},children:s.jsx(Pc,{})}),s.jsx(Ie,{delayDuration:100,tooltipPosition:"top",tooltip:"Auto Layout",disabled:v||!r||a.length===0,onClick:()=>{if(!r){U.info("Diagram is still rendering — try again in a moment");return}const{nodes:R,edges:k}=td(a,o,"LR");c(R),l(k),setTimeout(()=>m?.fitView({padding:.2}),50)},children:s.jsx(Hc,{})}),s.jsx(gt,{}),s.jsxs(Ot,{open:n,onOpenChange:i,children:[s.jsx(Bt,{asChild:!0,children:s.jsx(Ie,{delayDuration:100,tooltipPosition:"top",tooltip:"Mermaid Diagram",children:s.jsx(Bo,{className:"text-base"})})}),s.jsxs(_t,{align:"center",className:"border border-[#2A3242] bg-[#141925] text-[#F4F7FC]",children:[s.jsxs(Me,{onClick:()=>void M(),disabled:v,children:[s.jsx(bn,{className:"size-4"}),"Import Mermaid"]}),s.jsxs(Me,{onClick:T,children:[s.jsx(bn,{className:"size-4 rotate-180"}),"Export To Mermaid"]})]})]}),s.jsx(Ie,{delayDuration:100,tooltipPosition:"top",tooltip:"Export Image",onClick:A,disabled:t,children:t?s.jsx(os,{className:"text-sm"}):s.jsx(Mo,{className:"mb-0.5 text-[1.2rem]"})})]})})]})}function Ie({tooltipPosition:t,className:e,isActive:n,disabled:i,tooltip:r,delayDuration:a,...o}){return s.jsxs(et,{delayDuration:a??500,disableHoverableContent:!0,open:r?void 0:!1,children:[s.jsx(tt,{asChild:!0,children:s.jsx("button",{className:H("flex size-10 items-center justify-center rounded-[0.5rem] border border-[#2A3242] bg-transparent text-[1.0625rem] text-[#F4F7FC] transition-all",!i&&[n&&"border-primary/30 bg-primary/10 text-primary",!n&&"hover:bg-[#1E2533]"],i&&"cursor-not-allowed opacity-50",e),...o})}),s.jsx(st,{side:t,children:r})]})}function gt(){return s.jsx("div",{className:"h-[1.625rem] w-[1px] bg-[#2A3242]"})}function Ui(t){return{componentFieldId:"name",type:X.TextInput,label:"Name",data:[{value:t}]}}function Vi(t){const e=[...t].filter(r=>r.type==="sequenceParticipant").sort((r,a)=>r.position.x-a.position.x),n=e.length>=2?Math.abs(e[1].position.x-e[0].position.x)||Nt.columnWidth:Nt.columnWidth;return{x:e.length>0?Math.max(...e.map(r=>r.position.x))+n:0,columnWidth:n}}function Es(t,e){const{x:n}=Vi(t);return{id:`participant-${W()}`,type:"sequenceParticipant",position:{x:n,y:0},data:{componentFields:[Ui(e)]}}}function ld(t,e,n,i,r){const a=new Map(t.filter(b=>b.type==="sequenceParticipant").map(b=>[b.id,b])),o=a.get(n),c=a.get(i);if(!o||!c)return{nodes:t,edges:e};const l=n===i,u=jr(t,e),m=o.position.x<c.position.x,d=m||l?"right":"left",h=l?"right":m?"left":"right",x=`message-${W()}`,N=!t.some(b=>b.id.startsWith("message-")),f={id:x,type:"shape",position:{x:0,y:wr(u,Nt)-Nt.messageNodeHeight/2},data:{shape:"rectangle",fill:"#f8fafc",stroke:"#CCCCCC",strokeWidth:1,componentFields:[Ui(r)],...N?{sequenceNumber:1}:{}},style:{width:Nt.messageNodeWidth,height:Nt.messageNodeHeight}},g={id:W(),source:n,target:x,sourceHandle:gn(u,d,"source"),targetHandle:l?"target-top":d==="right"?"target-left":"target-right",type:"smoothstep"},v={id:W(),source:x,target:i,sourceHandle:l?"source-bottom":m?"source-right":"source-left",targetHandle:gn(u+(l?1:0),h,"target"),type:"smoothstep",markerEnd:Bs({type:Gs.ArrowClosed})};return Ue([...t,f],[...e,g,v])}function cd(t,e,n,i,r){const a=new Set(t.filter(u=>u.type==="sequenceParticipant").map(u=>u.id));if(!t.some(u=>u.id===n)||!a.has(i)||!a.has(r))return{nodes:t,edges:e};let o=!1,c=!1;const l=e.map(u=>u.target===n&&a.has(u.source)?(o=!0,{...u,source:i}):u.source===n&&a.has(u.target)?(c=!0,{...u,target:r}):u);return!o||!c?{nodes:t,edges:e}:Ue(t,Ki(t,l))}function Ki(t,e){const n=new Map(t.filter(r=>r.type==="sequenceParticipant").map(r=>[r.id,r])),i=new Map;for(const r of e)n.has(r.source)&&r.target.startsWith("message-")&&i.set(r.target,{...i.get(r.target),from:r.source}),r.source.startsWith("message-")&&n.has(r.target)&&i.set(r.source,{...i.get(r.source),to:r.target});return e.map(r=>{const a=i.get(r.source),o=i.get(r.target),c=a??o;if(!c?.from||!c.to)return r;const l=n.get(c.from),u=n.get(c.to);if(!l||!u)return r;const m=c.from===c.to,d=l.position.x<u.position.x,h=d||m?"right":"left",x=m?"right":d?"left":"right";return a?{...r,sourceHandle:m?"source-bottom":d?"source-right":"source-left",targetHandle:r.targetHandle?.replace(/^row-(\d+)-(left|right)-/,`row-$1-${x}-`)}:{...r,sourceHandle:r.sourceHandle?.replace(/^row-(\d+)-(left|right)-/,`row-$1-${h}-`),targetHandle:m?"target-top":h==="right"?"target-left":"target-right"}})}const Qt=60;function $n(t,e){if(!e.some(a=>a.type==="sequenceParticipant"||a.id.startsWith("message-")))return;const{nodes:i,edges:r}=Ue(t.getNodes(),t.getEdges());t.setNodes(i),t.setEdges(r)}function dd(){const[t,e]=y.useState(null),{selectedEdgeIds:n,selectedNodeIds:i,setSelectedEdgeIds:r,setSelectedNodeIds:a,reactFlowInstance:o}=we();async function c(){const f=o;if(!f)return;const g=i.map(v=>f.getNode(v)).filter(Boolean);await f.deleteElements({edges:n.map(v=>f.getEdge(v)).filter(Boolean),nodes:g}),$n(f,g)}function l(f){const g=i.map(w=>f.getNode(w)).filter(Boolean),v=n.map(w=>f.getEdge(w)).filter(Boolean);return f.getNodes().forEach(w=>{w.parentId&&!g.some(S=>S.id===w.id)&&g.some(S=>S.id===w.parentId)&&(console.log("adding node",w),g.push(w))}),f.getEdges().forEach(w=>{!v.some(S=>S.id===w.id)&&g.some(S=>S.id===w.source)&&g.some(S=>S.id===w.target)&&(console.log("adding edge",w),v.push(w))}),{targetNodes:g,targetEdges:v}}function u(f){const g=o;g&&(e({mode:f,...l(g)}),a([]),r([]))}async function m(f=t){const g=o;if(!g||!f)return;const{targetNodes:v,targetEdges:b}=f;if(!v.length)return;const p=new Map,w=new Set(v.map(k=>k.id));v.forEach(k=>{const O=k.type==="sequenceParticipant"?"participant-":k.id.startsWith("message-")?"message-":"";p.set(k.id,`${O}${W()}`)});const{x:S,columnWidth:I}=Vi(g.getNodes());let C=S;const A=v.map(k=>{const O=p.get(k.id),F=Array.isArray(k.data?.childNodes)?k.data.childNodes.map(ae=>p.get(ae)??ae):k.data?.childNodes;let G=k.parentId&&w.has(k.parentId)?k.position:{x:k.position.x+Qt,y:k.position.y+Qt};return k.type==="sequenceParticipant"&&(G={x:C,y:0},C+=I),{...k,id:O,childNodes:void 0,data:{...k.data,childNodes:F},position:G}}),M=b.map(k=>{const O=p.get(k.source)||k.source,F=p.get(k.target)||k.target;return{...k,source:O,target:F,data:{...k.data},id:W()}});A.forEach(k=>{if(k.parentId){const O=p.get(k.parentId)||k.parentId;k.parentId=O}});const T=g.getViewport();if(await g.setViewport({...T,x:T.x-Qt*T.zoom,y:T.y-Qt*T.zoom},{duration:100}),A.some(k=>k.type==="sequenceParticipant"||k.id.startsWith("message-"))){const k=new Set(A.map(Y=>Y.id)),O=new Set(M.map(Y=>Y.id)),F=g.getNodes().map(Y=>({...Y,selected:!1})),G=g.getEdges().map(Y=>({...Y,selected:!1})),{nodes:ae,edges:me}=Ue([...F,...A],[...G,...M]);g.setNodes(ae.map(Y=>k.has(Y.id)?{...Y,selected:!0}:Y)),g.setEdges(me.map(Y=>O.has(Y.id)?{...Y,selected:!0}:Y))}else g.setNodes(k=>[...k.map(O=>({...O,selected:!1})),...A.map(O=>({...O,selected:!0}))]),g.setEdges(k=>[...k.map(O=>({...O,selected:!1})),...M.map(O=>({...O,selected:!0}))]);f.mode==="copy"&&e({mode:"copy",targetNodes:A,targetEdges:M}),f.mode==="cut"&&(await g.deleteElements({edges:b,nodes:v}),$n(g,v),e(null))}async function d(){const f=o;f&&await m({mode:"copy",...l(f)})}const h=i.length>0||n.length>0,x=!!t,N=Js({handleDelete:c,handleDuplicate:d,handleCopy:u,handlePaste:m});return y.useEffect(()=>{if(!h&&!x)return;async function f(g){const{handleDelete:v,handleDuplicate:b,handleCopy:p,handlePaste:w}=N.current,S=g.target;S.tagName==="INPUT"||S.tagName==="TEXTAREA"||S.isContentEditable||((g.key==="Delete"||g.key==="Backspace"&&h)&&await v(),(g.ctrlKey||g.metaKey)&&(g.key==="d"&&h?(g.preventDefault(),b().catch(console.error)):g.key==="c"&&h?(g.preventDefault(),p("copy")):g.key==="v"&&x&&(g.preventDefault(),w().catch(console.error))))}return window.addEventListener("keydown",f),()=>{window.removeEventListener("keydown",f)}},[h,x,N]),s.jsx(it,{children:(h||t)&&s.jsx(ze.div,{initial:{opacity:0,y:16,scale:.75},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:16,scale:.75},transition:{duration:.1,ease:"easeOut"},className:"pointer-events-none absolute inset-x-0 bottom-3 flex items-center justify-center",children:s.jsxs("div",{className:qi,children:[h&&s.jsxs(s.Fragment,{children:[s.jsx(Ie,{tooltip:"Zoom to Selection",tooltipPosition:"bottom",onClick:()=>o&&oi(o,i),children:s.jsx(vl,{size:18})}),s.jsx(gt,{}),s.jsx(Ie,{tooltip:"Cut Selection",tooltipPosition:"bottom",onClick:()=>u("cut"),children:s.jsx(wl,{size:18})}),s.jsx(Ie,{tooltip:"Copy Selection",tooltipPosition:"bottom",onClick:()=>u("copy"),children:s.jsx(Wo,{size:18})})]}),!!t&&s.jsxs(s.Fragment,{children:[h&&s.jsx(gt,{}),s.jsx(Ie,{tooltip:"Paste",tooltipPosition:"bottom",onClick:()=>m(),children:s.jsx(rl,{size:18})})]}),h&&s.jsxs(s.Fragment,{children:[s.jsx(gt,{}),s.jsx(Ie,{tooltip:"Duplicate Selection",tooltipPosition:"bottom",onClick:()=>d(),children:s.jsx(dl,{size:18})}),s.jsx(Ie,{tooltip:"Delete Selection",tooltipPosition:"bottom",className:"hover:text-destructive",onClick:c,children:s.jsx(It,{size:18})})]})]})})})}function ud(){const{nodes:t,viewport:e,reactFlowInstance:n}=we(),i=e?.zoom??Nr;return t.length===0||i>Cr?null:s.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-3 flex items-center justify-center",children:s.jsxs(Ie,{className:"pointer-events-auto w-auto gap-2 rounded-[0.75rem] bg-[#141925] px-3 text-sm shadow-sm",onClick:()=>n&&Sr(n),children:[s.jsx(ka,{className:"size-4"}),"Focus on content"]})})}function md(){const[t,e]=y.useState(!1),[n,i]=y.useState(!1),{isEmbedded:r,isFullscreen:a,sidebarActiveTool:o,diagramName:c,setDiagramName:l}=we();return r||!a?null:s.jsxs("div",{className:H("pointer-events-auto absolute top-4 left-[1.1875rem] flex items-center","-translate-x-[calc(100%_+_1.1875rem)] transition-transform duration-200 group-hover/left-controls:translate-x-0",(n||o)&&"translate-x-0"),onMouseEnter:()=>e(!0),onMouseLeave:()=>e(!1),children:[s.jsx(ss,{to:"/dashboard",className:"rounded-full",children:s.jsx(Hs,{className:"size-11 max-w-none"})}),s.jsx(it,{initial:!1,children:(t||n)&&s.jsx(ze.div,{initial:{width:0,opacity:0},animate:{width:"auto",opacity:1},exit:{width:0,opacity:0},transition:{duration:.2,ease:"easeOut"},className:"-m-1 overflow-hidden p-1",children:s.jsx("div",{className:"ml-4",children:s.jsx(Fe,{value:c,placeholder:"Enter diagram name",onChange:u=>l(u.target.value),onFocus:()=>i(!0),onBlur:()=>i(!1),className:"placeholder:text-foreground/20 h-auto rounded-[0.5rem] px-2.5 py-1.5 !text-[1.1rem] font-medium shadow-none placeholder:text-lg placeholder:font-medium"})})})})]})}function hd(t){return Ei({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M15 2c-2.71 0-5.05 1.54-6.22 3.78a7.06 7.06 0 0 0-3 3A7.01 7.01 0 0 0 2 15c0 3.87 3.13 7 7 7 2.71 0 5.05-1.54 6.22-3.78a7.06 7.06 0 0 0 3-3A7.01 7.01 0 0 0 22 9c0-3.87-3.13-7-7-7M9 20a5.002 5.002 0 0 1-4-8c0 3.87 3.13 7 7 7-.84.63-1.88 1-3 1m3-3a5.002 5.002 0 0 1-4-8c0 3.86 3.13 6.99 7 7-.84.63-1.88 1-3 1m4.7-3.3c-.53.19-1.1.3-1.7.3-2.76 0-5-2.24-5-5 0-.6.11-1.17.3-1.7.53-.19 1.1-.3 1.7-.3 2.76 0 5 2.24 5 5 0 .6-.11 1.17-.3 1.7M19 12c0-3.86-3.13-6.99-7-7a5.002 5.002 0 0 1 7 7"},child:[]},{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0zm0 0h24v24H0z"},child:[]}]})(t)}const gd=[...Go];function Xe({children:t,className:e,...n}){const i=y.useRef(null),r=y.useRef(null),[a,o]=y.useState(),[c,l]=y.useState();return y.useEffect(()=>{const u=i.current;if(!u)return;const m=r.current;if(!m)return;const d=new ResizeObserver(()=>{l(m.clientHeight),o(u.clientHeight)});return l(m.clientHeight),o(u.clientHeight),d.observe(m),d.observe(u),()=>d.disconnect()},[i,r]),s.jsx("div",{ref:r,className:H("pointer-events-none absolute inset-4 right-auto select-none",e),...n,children:s.jsx(Ti,{className:"rounded-[0.75rem] border border-[#2A3242] bg-[#141925]",style:{height:Math.min(a??0,c??0)+2},children:s.jsx("div",{ref:i,className:"pointer-events-auto",children:t})})})}const Ys="flex aspect-square w-full cursor-grab items-center justify-center rounded-[0.5rem] border border-[#2A3242] bg-[#1E2533] p-2 text-[#F4F7FC] transition-all select-none hover:bg-[#232b3a] active:cursor-grabbing [&>svg]:h-full [&>svg]:w-full [&>svg]:object-contain [&_path]:!stroke-[#CBD5E1] [&_rect]:!stroke-[#CBD5E1] [&_circle]:!stroke-[#CBD5E1] [&_polygon]:!stroke-[#CBD5E1] [&_line]:!stroke-[#CBD5E1] [&_ellipse]:!stroke-[#CBD5E1]",$t="group flex h-8 w-full items-center justify-between rounded-md px-2 text-xs font-medium text-[#F4F7FC] transition-colors hover:bg-[#1E2533]",pd="group flex h-8 w-full items-center justify-between rounded-md px-3 text-xs font-medium text-[#F4F7FC] transition-colors hover:bg-[#1E2533]",Xi="flex cursor-grab items-center gap-2 rounded-[0.5rem] bg-transparent p-2 text-[#F4F7FC] transition-all select-none hover:bg-[#1E2533] active:cursor-grabbing",fd="ml-2 flex flex-col gap-1.5 border-l border-[#2A3242] pl-1",xd="group flex h-11 w-full cursor-grab items-center gap-3 rounded-lg border border-[#2A3242] bg-[#1E2533] px-3 py-2 transition-all hover:border-primary/30 hover:bg-[#232b3a] active:scale-[0.98] active:cursor-grabbing",bd="h-10 border-[#2A3242] bg-transparent pl-10 text-sm text-[#F4F7FC] placeholder:text-[#828DA3] focus:border-primary focus:ring-primary";function yd(){return s.jsx(Xe,{className:"left-18",children:s.jsx("div",{className:"flex w-[10.5rem] flex-col gap-1.5 p-1 py-2",children:gd.map((t,e)=>{const n=`/${t.relativePath}`;return s.jsxs("div",{draggable:!0,className:Xi,onDragStart:i=>{Ke(i,"gif",{src:n,componentFields:[{componentFieldId:"name",type:X.TextInput,label:"Name",isReadonly:!0,data:[{value:t.name}]},{componentFieldId:"description",type:X.TextInput,label:"Description",data:[{value:t.category}]}]},{width:100})},children:[s.jsx("img",{src:n,alt:t.name,className:"h-8 w-8 flex-shrink-0 rounded-md"}),s.jsx("span",{className:"truncate text-sm",children:t.name})]},e)})})})}function vd(){const{sidebarActiveTool:t,setSidebarActiveTool:e}=we(),{getNode:n,setCenter:i,setNodes:r}=xi(),a=t==="add-comment";function o(D){const q=n(D);if(!q)return;const j=q.measured?.width??q.width??0,z=q.measured?.height??q.height??0;i(q.position.x+j/2,q.position.y+z/2,{zoom:1.5,duration:600}),r(_=>_.map(Z=>({...Z,selected:Z.id===D})))}const c=Qs()?.id,l=ii(D=>D.user),u=l?{userId:l.userId,name:l.name,avatarUrl:l.avatarUrl??void 0}:null,d=ta().filter(D=>D.type==="comment").map(D=>D.id),h=d.join(","),[x,N]=y.useState({}),f=y.useCallback((D,q)=>{N(j=>({...j,[D]:q}))},[]),g=y.useMemo(()=>h.split(",").filter(Boolean).flatMap(D=>x[D]??[]).sort((D,q)=>new Date(D.createdAt).getTime()-new Date(q.createdAt).getTime()),[h,x]),v=y.useMemo(()=>{const D={};return h.split(",").filter(Boolean).forEach(q=>{(x[q]??[]).forEach(j=>{D[j.commentId]=q})}),D},[h,x]),[b]=zt(kr),[p]=zt(Ir),[w]=zt(Tr);function S(D){return{awaitRefetchQueries:!0,refetchQueries:[{query:ci,variables:{orgId:c,resourceId:D}}]}}const[I,C]=y.useState(""),[A,M]=y.useState(null),[T,R]=y.useState(!1),[k,O]=y.useState(null),[F,G]=y.useState(""),[ae,me]=y.useState(null),[Y,Ne]=y.useState(null),[ke,ye]=y.useState(null),L=d[d.length-1];async function $(){const D=I.trim();if(!D||T||!u?.userId||!c)return;const q=A?v[A.commentId]:L;if(q){R(!0);try{await b({variables:{orgId:c,input:{resourceId:q,text:D,...A?{parentCommentId:A.commentId}:{}}},...S(q)}),C(""),M(null)}finally{R(!1)}}}async function te(){const D=F.trim();if(!k||!D||ae||!c)return;const q=v[k];if(q){me(k);try{await p({variables:{orgId:c,id:k,input:{text:D}},...S(q)}),O(null),G("")}finally{me(null)}}}async function P(D){if(Y||!c)return;const q=v[D];if(q){Ne(D);try{await w({variables:{orgId:c,id:D},...S(q)})}finally{Ne(null)}}}return s.jsxs(Xe,{className:"left-18",children:[d.map(D=>s.jsx(jd,{orgId:c,resourceId:D,onLoaded:f},D)),s.jsxs("div",{className:"flex w-80 flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between border-b border-[#2A3242] px-3 py-2.5",children:[s.jsx("h3",{className:"text-sm font-semibold text-[#F4F7FC]",children:"Comments"}),s.jsxs("button",{type:"button",onClick:()=>e(a?"comments":"add-comment"),className:H("flex h-7 items-center gap-1.5 rounded-md border px-2.5 text-xs font-medium transition-all",a?"border-primary bg-primary/15 text-primary":"hover:border-primary/40 border-[#2A3242] bg-[#1E2533] text-[#F4F7FC] hover:bg-[#232b3a]"),children:[s.jsx(mt,{className:H("size-3.5 transition-transform",a&&"rotate-45")}),a?"Click canvas":"Add comment"]})]}),s.jsx("div",{className:"max-h-96 overflow-x-hidden overflow-y-auto",children:s.jsx("div",{className:"divide-y divide-[#2A3242]",children:g.length===0?s.jsx("div",{className:"py-8 text-center text-sm text-[#828DA3]",children:"No comments yet. Start the conversation!"}):g.map(D=>{const q=k===D.commentId,j=u?.userId===D.createdBy,z=D.authorName||"User",_=D.parentCommentId?g.find(oe=>oe.commentId===D.parentCommentId)?.authorName:null,Z=ae===D.commentId,ge=Y===D.commentId;return s.jsx("div",{className:"p-3",children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsxs(ra,{className:"size-5 flex-shrink-0",children:[s.jsx(aa,{src:D.authorAvatarUrl||""}),s.jsx(oa,{className:"text-[10px]",children:(z.charAt(0)||"U").toUpperCase()})]}),s.jsxs("div",{className:"min-w-0 flex-1 space-y-1.5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-[13px] font-medium text-[#F4F7FC]",children:z}),s.jsx("span",{className:"text-[11px] text-[#828DA3]",children:D.createdAt?Er(D.createdAt):""})]}),q?s.jsxs("div",{className:"space-y-2",children:[s.jsx(pn,{forceFocus:!0,theme:"dark",value:F,setValue:G}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Q,{preset:"primary",className:"h-8 px-3 text-xs",onClick:te,disabled:Z,children:Z?s.jsx(os,{className:"size-4!"}):"Save"}),s.jsx(Q,{preset:"outline",className:"h-8 px-3 text-xs",onClick:()=>{O(null),G("")},disabled:Z,children:"Cancel"})]})]}):s.jsxs(s.Fragment,{children:[!!D.parentCommentId&&s.jsxs("div",{className:"text-[11px] text-[#828DA3]",children:["Replying to"," ",s.jsx("span",{className:"font-medium text-[#F4F7FC]",children:_||"a comment"})]}),s.jsx("div",{className:"text-sm leading-snug text-[#F4F7FC]",children:s.jsx(Lr,{theme:"dark",value:D.text??""})}),s.jsxs("div",{className:"flex items-center gap-1 text-[#828DA3]",children:[s.jsxs(Q,{preset:"ghost",className:"-ml-3 h-7 px-2! text-[11px] font-medium text-[#828DA3] hover:text-[#F4F7FC]",onClick:()=>M({commentId:D.commentId,name:z}),children:[s.jsx(Ar,{className:"mr-1 size-3"}),"Reply"]}),s.jsxs(Ot,{children:[s.jsx(Bt,{asChild:!0,children:s.jsx(Q,{preset:"ghost",className:"h-7 px-2! text-[11px] font-medium text-[#828DA3] hover:text-[#F4F7FC]",children:s.jsx(Fr,{className:"size-3"})})}),s.jsxs(_t,{align:"start",className:"min-w-40 rounded-lg border-[#2A3242] bg-[#141925] p-1 text-[#F4F7FC] shadow-xl",children:[s.jsxs(Me,{onClick:()=>o(v[D.commentId]),className:"cursor-pointer gap-2 rounded-md px-2.5 py-2 text-sm text-[#F4F7FC] focus:bg-[#1E2533] focus:text-[#F4F7FC]",children:[s.jsx(ll,{className:"size-4"}),"Focus Comment"]}),j&&s.jsxs(s.Fragment,{children:[s.jsxs(Me,{onClick:()=>{O(D.commentId),G(D.text??"")},className:"cursor-pointer gap-2 rounded-md px-2.5 py-2 text-sm text-[#F4F7FC] focus:bg-[#1E2533] focus:text-[#F4F7FC]",children:[s.jsx(Dr,{className:"size-4"}),"Edit"]}),s.jsxs(Me,{onClick:()=>ye(D.commentId),className:"text-destructive focus:text-destructive cursor-pointer gap-2 rounded-md px-2.5 py-2 text-sm focus:bg-[#1E2533]",disabled:ge,children:[s.jsx(Uo,{className:"size-4"}),"Delete"]})]})]})]})]})]})]})]})},D.commentId)})})}),s.jsx("div",{className:"border-t border-[#2A3242] px-3 py-2.5",children:s.jsxs("div",{className:"space-y-2",children:[!!A&&s.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-[#2A3242] bg-[#1E2533] px-2.5 py-2 text-xs text-[#828DA3]",children:[s.jsxs("div",{className:"min-w-0 flex-1 truncate",children:["Replying to"," ",s.jsx("span",{className:"font-medium text-[#F4F7FC]",children:A.name})]}),s.jsx(Q,{preset:"outline",disabled:T,onClick:()=>M(null),className:"h-7 px-2 text-xs",children:"Cancel"})]}),s.jsxs("div",{className:"relative flex min-w-0 flex-1 items-end gap-2",children:[s.jsx("div",{className:"flex-1",children:s.jsx(pn,{theme:"dark",value:I,setValue:C,className:"break-all"})}),s.jsx(Q,{onClick:$,disabled:!I.trim()||T||!L,preset:"primary",className:"size-9! p-0",children:T?s.jsx(os,{className:"size-4"}):s.jsx(Rr,{className:"size-4!"})})]})]})})]}),s.jsx(qo,{open:!!ke,onOpenChange:D=>{D||ye(null)},title:"Delete comment?",description:"This action cannot be undone.",onConfirm:async()=>{ke&&(await P(ke),ye(null))}})]})}function jd({orgId:t,resourceId:e,onLoaded:n}){const{data:i}=ut(ci,{fetchPolicy:"cache-first",variables:{orgId:t,resourceId:e},skip:!t}),r=y.useMemo(()=>Be(i?.comments).map(a=>({commentId:a.id,resourceId:a.resourceId,parentCommentId:a.parentCommentId,text:a.text,createdBy:a.createdBy,createdAt:a.createdAt,authorName:a.createdByActor?.name,authorAvatarUrl:a.createdByActor?.avatarUrl})),[i]);return y.useEffect(()=>{n(e,r)},[e,r,n]),null}var wd=Object.defineProperty,Yi=(t,e)=>wd(t,"name",{value:e,configurable:!0}),Wn="horizontal",Nd=["horizontal","vertical"],Cd=y.forwardRef(Yi(function(e,n){const{decorative:i,orientation:r=Wn,...a}=e,o=Qi(r)?r:Wn,l=i?{role:"none"}:{"aria-orientation":o==="vertical"?o:void 0,role:"separator"};return s.jsx(at.div,{"data-orientation":o,...l,...a,ref:n})},"Separator"));function Qi(t){return Nd.includes(t)}Yi(Qi,"isValidOrientation");var Sd=Cd;function St({className:t,orientation:e="horizontal",decorative:n=!0,...i}){return s.jsx(Sd,{"data-slot":"separator",decorative:n,orientation:e,className:H("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",t),...i})}function kd(){const t=Qs().id,[e,n]=y.useState(null),i=ut(Xo,{fetchPolicy:"cache-first",variables:{orgId:t},skip:!t}),r=ut(sa,{fetchPolicy:"cache-first",skip:!t||!e,variables:{orgId:t,serviceId:e}});return{selectedServiceId:e,setSelectedServiceId:n,isServicesLoading:i.loading&&!i.data,isServicesDbLoading:r.loading&&!r.data,services:y.useMemo(()=>Be(i.data?.services.items).map(a=>({...a,serviceId:a.id})),[i.data]),servicesDb:y.useMemo(()=>Be(r.data?.serviceDBs).map(na),[r.data])}}function Id(){const{setNodes:t,setEdges:e,dataSources:n,setDataSources:i,reactFlowInstance:r}=we(),{removeDataSource:a,regenerateSql:o}=zr(),[c,l]=y.useState(null),{selectedServiceId:u,setSelectedServiceId:m,isServicesLoading:d,isServicesDbLoading:h,services:x,servicesDb:N}=kd(),f=x.find(j=>j.serviceId===u),[g,v]=y.useState(null),[b,p]=y.useState(new Set),[w,S]=y.useState(""),I=y.useRef(null),[C,A]=y.useState(!1),[M,T]=y.useState(!1),[R,k]=y.useState(!1),[O,F]=y.useState(null);async function G(){try{const[j]=await as({accept:".sql,.json"});if(!j)return;const z=await j.text(),_=Vt.detectDialect(z),ge=new Vt(_).parse(z);if(!ge.tables||ge.tables.length===0){U.error("No tables found in SQL file");return}const oe=W(),K={id:oe,name:j.name,sourceType:"file",dialect:_,schemaAst:ge,createdAt:Date.now(),modifiedAt:null},fe=Ge.toReactFlow(ge,K.name);t(he=>[...he,...fe.nodes]),e(he=>[...he,...fe.edges]),i(he=>[...he,K]),v(oe),p(he=>new Set([...he,oe])),U.success(`Imported ${ge.tables.length} tables from ${j.name} (${_.toUpperCase()})`)}catch(j){console.error("Error uploading SQL file:",j),U.error("Failed to parse SQL file. Please check the file format.")}}async function ae(){try{const[j]=await as({accept:".json"});if(!j)return;const z=await j.text(),_=JSON.parse(z),Z=qe.safeParse(_),ge=W();let oe,K=null;if(Z.success){oe=Z.data;const xe=ys(Z.data);K={...xe,metadata:{...xe.metadata??{},sourceFile:j.name}}}else{const xe=Oe.safeParse(_);if(xe.success){oe=xe.data;const E=vs(xe.data);K={...E,metadata:{...E.metadata??{},sourceFile:j.name}}}else{const E=_s.safeParse(_);if(E.success){oe=E.data;const B=Tn(E.data);K={...B,metadata:{...B.metadata??{},sourceFile:j.name}}}}}if(!K||!oe){U.error("Invalid NoSQL schema file");return}const fe={id:ge,name:j.name,sourceType:"file",dialect:K.dialect,sourceContent:oe,schemaAst:K,createdAt:Date.now(),modifiedAt:null},he=Ge.toReactFlow(K,fe.name);t(xe=>[...xe,...he.nodes]),e(xe=>[...xe,...he.edges]),i(xe=>[...xe,fe]),v(ge),p(xe=>new Set([...xe,ge]));const re=K.dialect==="dynamodb"?"table":"collection";U.success(`Imported ${K.tables.length} ${K.tables.length===1?re:`${re}s`} from ${j.name}`)}catch(j){console.error("Error uploading NoSQL file:",j),U.error("Failed to parse NoSQL schema file.")}}function me(j="mysql",z="Manual Table",_="new_table"){const Z=W(),oe={id:W(),type:"table",name:_,columns:[{type:"column",name:"id",dataType:{name:"INT"},nullable:!1,autoIncrement:!0},{type:"column",name:"name",dataType:{name:"VARCHAR",parameters:[255]},nullable:!1}],constraints:[{type:"primary_key",columns:["id"]}],indexes:[]},K={dialect:j,tables:[oe],metadata:{createdAt:new Date}},fe={id:Z,name:z,sourceType:"manual",dialect:j,schemaAst:K,createdAt:Date.now(),modifiedAt:Date.now()},he=Ge.toReactFlow(K,fe.name);t(re=>[...re,...he.nodes]),e(re=>[...re,...he.edges]),v(Z),i(re=>[...re,fe]),p(re=>new Set([...re,Z])),U.success(`${z} created`)}function Y(){const j=W(),_={dialect:"mongodb",name:"MongoDB Collection",description:"MongoDB Collection",collections:[{id:W(),name:"users",tags:"auth,profiles",description:"Application users",fields:[{id:W(),name:"_id",type:"string",required:!0,refCollectionId:null},{id:W(),name:"email",type:"string",required:!0,refCollectionId:null},{id:W(),name:"username",type:"string",required:!0,refCollectionId:null},{id:W(),name:"name",type:"object",required:!0,refCollectionId:null,fields:[{id:W(),name:"first",type:"string",required:!0,refCollectionId:null},{id:W(),name:"last",type:"string",required:!0,refCollectionId:null}]},{id:W(),name:"roles",type:"array",required:!1,refCollectionId:null,itemType:"string",itemFields:void 0,fields:void 0},{id:W(),name:"address",type:"object",required:!1,refCollectionId:null,fields:[{id:W(),name:"line1",type:"string",required:!0,refCollectionId:null},{id:W(),name:"line2",type:"string",required:!1,refCollectionId:null},{id:W(),name:"city",type:"string",required:!0,refCollectionId:null},{id:W(),name:"state",type:"string",required:!1,refCollectionId:null},{id:W(),name:"country",type:"string",required:!0,refCollectionId:null},{id:W(),name:"postalCode",type:"string",required:!1,refCollectionId:null}]},{id:W(),name:"preferences",type:"object",required:!1,refCollectionId:null,fields:[{id:W(),name:"marketingOptIn",type:"boolean",required:!1,refCollectionId:null},{id:W(),name:"language",type:"string",required:!1,refCollectionId:null},{id:W(),name:"theme",type:"string",required:!1,refCollectionId:null}]},{id:W(),name:"sessions",type:"array",required:!1,refCollectionId:null,itemType:"object",itemFields:[{id:W(),name:"sessionId",type:"string",required:!0,refCollectionId:null},{id:W(),name:"createdAt",type:"date",required:!0,refCollectionId:null},{id:W(),name:"ip",type:"string",required:!1,refCollectionId:null},{id:W(),name:"userAgent",type:"string",required:!1,refCollectionId:null}]},{id:W(),name:"createdAt",type:"date",required:!0,refCollectionId:null},{id:W(),name:"updatedAt",type:"date",required:!1,refCollectionId:null}],indexes:[{id:W(),name:"uniq_email",unique:!0,fields:[{id:W(),fieldName:"email",order:1}]},{id:W(),name:"uniq_username",unique:!0,fields:[{id:W(),fieldName:"username",order:1}]},{id:W(),name:"idx_createdAt",unique:!1,fields:[{id:W(),fieldName:"createdAt",order:-1}]}]}]},Z=vs(_),ge={id:j,name:"MongoDB Collection",sourceType:"manual",dialect:"mongodb",sourceContent:_,schemaAst:Z,createdAt:Date.now(),modifiedAt:Date.now()},oe=Ge.toReactFlow(Z,ge.name);t(K=>[...K,...oe.nodes]),e(K=>[...K,...oe.edges]),v(j),i(K=>[...K,ge]),p(K=>new Set([...K,j])),U.success("MongoDB Collection created")}function Ne(){const j=W(),z={dialect:"dynamodb",name:"DynamoDB Table",description:"DynamoDB Table",primaryKey:{partitionKey:"pk",partitionKeyType:"S",sortKey:"sk",sortKeyType:"S"},globalSecondaryIndexes:[{id:W(),name:"gsi1",partitionKey:"gsi1pk",partitionKeyType:"S",sortKey:"gsi1sk",sortKeyType:"S"},{id:W(),name:"gsi2",partitionKey:"gsi2pk",partitionKeyType:"S",sortKey:"gsi2sk",sortKeyType:"S"}],attributes:[{id:W(),name:"entityType",type:"string",required:!0},{id:W(),name:"orgId",type:"string",required:!0},{id:W(),name:"userId",type:"string",required:!0},{id:W(),name:"email",type:"string",required:!0},{id:W(),name:"status",type:"string",required:!1},{id:W(),name:"roles",type:"array",required:!1,itemType:"string"},{id:W(),name:"profile",type:"object",required:!1,fields:[{id:W(),name:"firstName",type:"string",required:!0},{id:W(),name:"lastName",type:"string",required:!0},{id:W(),name:"phone",type:"string",required:!1}]},{id:W(),name:"createdAt",type:"string",required:!0},{id:W(),name:"updatedAt",type:"string",required:!1}]},_=ys(z),Z={id:j,name:"Manual DynamoDB",sourceType:"manual",dialect:"dynamodb",sourceContent:z,schemaAst:_,createdAt:Date.now(),modifiedAt:Date.now()},ge=Ge.toReactFlow(_,Z.name);t(oe=>[...oe,...ge.nodes]),e(oe=>[...oe,...ge.edges]),v(j),i(oe=>[...oe,Z]),p(oe=>new Set([...oe,j])),U.success("Manual DynamoDB schema created")}function ke(j){a(j),t(z=>z.filter(_=>!_.id.startsWith(`${j}-table-`))),e(z=>z.filter(_=>!_.id.startsWith(`${j}-table-`))),g===j&&v(null),c===j&&l(null),U.success("Data source removed")}function ye(j){if(j.dialect==="mongodb"||j.dialect==="dynamodb"||j.dialect==="json")S(JSON.stringify(j.sourceContent??{},null,2));else{const _=new Do(j.dialect,2).generate(j.schemaAst);S(_)}l(j.id)}function L(j,z){S(z),I.current&&clearTimeout(I.current);const _=n.find(Z=>Z.id===j);!_||_.dialect==="mongodb"||_.dialect==="dynamodb"||_.dialect==="json"||(I.current=setTimeout(()=>{try{const Z=n.find(re=>re.id===j);if(!Z)return;const oe=new Vt(Z.dialect).parse(z);if(!oe.tables||oe.tables.length===0)return;i(re=>re.map(E=>E.id===j?{...E,schemaAst:oe,modifiedAt:Date.now()}:E));const K=r?.getNodes(),fe=r?.getEdges(),he=Ge.updateReactFlow({schema:oe,sourceName:_.name,nodes:K??[],edges:fe??[],oldDataSources:n});t(he.nodes),e(he.edges)}catch(Z){console.error("Error parsing SQL:",Z)}},500))}function $(j){try{const z=n.find(fe=>fe.id===j);if(!z)return;if(z.dialect==="mongodb"||z.dialect==="dynamodb"||z.dialect==="json"){const fe=JSON.parse(w);if(z.dialect==="mongodb"){const he=Oe.parse(fe),re=vs(he);if(!re.tables||re.tables.length===0){U.error("No valid tables found in schema");return}l(null),i(ee=>ee.map(ie=>ie.id===j?{...ie,sourceContent:he,schemaAst:re,modifiedAt:Date.now()}:ie));const xe=r?.getNodes(),E=r?.getEdges(),B=Ge.updateReactFlow({schema:re,sourceName:z.name,nodes:xe??[],edges:E??[],oldDataSources:n});t(B.nodes),e(B.edges),U.success("Schema updated successfully");return}if(z.dialect==="dynamodb"){const he=qe.parse(fe),re=ys(he);if(!re.tables||re.tables.length===0){U.error("No valid tables found in schema");return}l(null),i(ee=>ee.map(ie=>ie.id===j?{...ie,sourceContent:he,schemaAst:re,modifiedAt:Date.now()}:ie));const xe=r?.getNodes(),E=r?.getEdges(),B=Ge.updateReactFlow({schema:re,sourceName:z.name,nodes:xe??[],edges:E??[],oldDataSources:n});t(B.nodes),e(B.edges),U.success("Schema updated successfully");return}if(z.dialect==="json"){const he=_s.parse(fe),re=Tn(he);if(!re.tables||re.tables.length===0){U.error("No valid tables found in schema");return}l(null),i(ee=>ee.map(ie=>ie.id===j?{...ie,sourceContent:he,schemaAst:re,modifiedAt:Date.now()}:ie));const xe=r?.getNodes(),E=r?.getEdges(),B=Ge.updateReactFlow({schema:re,sourceName:z.name,nodes:xe??[],edges:E??[],oldDataSources:n});t(B.nodes),e(B.edges),U.success("Schema updated successfully");return}return}const Z=new Vt(z.dialect).parse(w);if(!Z.tables||Z.tables.length===0){U.error("No valid tables found in SQL");return}l(null),i(fe=>fe.map(re=>re.id===j?{...re,schemaAst:Z,modifiedAt:Date.now()}:re));const ge=r?.getNodes(),oe=r?.getEdges(),K=Ge.updateReactFlow({schema:Z,sourceName:z.name,nodes:ge??[],edges:oe??[],oldDataSources:n});t(K.nodes),e(K.edges),U.success("SQL updated successfully")}catch(z){console.error("Error parsing edited content:",z),U.error("Invalid content. Please check your changes.")}}function te(){l(null),S("")}function P(j){const z=o(j);console.log("Regenerated SQL:",z),U.success("SQL regenerated from internal structure")}function D(j){p(z=>{const _=new Set(z);return _.has(j)?_.delete(j):_.add(j),_})}function q(j){return b.has(j)}return s.jsx(Xe,{className:"left-18",children:s.jsxs("div",{className:"flex h-full w-[500px] flex-col",children:[s.jsxs("div",{className:"from-primary/10 to-primary/5 border-stock border-b bg-gradient-to-r px-4 py-3",children:[s.jsxs("h3",{className:"text-foreground flex items-center gap-2 text-base font-semibold",children:[s.jsx(Qe,{className:"text-primary h-5 w-5"}),"Data Sources"]}),s.jsx("p",{className:"text-paragraph mt-1 text-xs",children:"Connect services, upload SQL or NoSQL files, or create tables manually"})]}),s.jsxs("div",{className:"space-y-4 p-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs(Ot,{open:M,onOpenChange:j=>{T(j),k(!1)},children:[s.jsx(Bt,{asChild:!0,children:s.jsxs(Q,{preset:"primary",className:"flex w-full items-center justify-between gap-2 pr-3! focus:z-10",children:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(mt,{className:"h-4 w-4"}),"Add SQL Source"]}),s.jsx(nt,{className:"h-4 w-4"})]})}),s.jsxs(_t,{side:"bottom",align:"start",children:[s.jsxs(Me,{onClick:G,children:[s.jsx(qs,{className:"h-4 w-4"}),"Upload SQL Schema"]}),s.jsxs(Me,{onClick:()=>me("mysql","MySQL Source"),children:[s.jsx(Qe,{className:"h-4 w-4"}),"New MySQL Source"]}),s.jsxs(Me,{onClick:()=>me("postgresql","PostgreSQL Source"),children:[s.jsx(Qe,{className:"h-4 w-4"}),"New PostgreSQL Source"]})]})]}),s.jsxs(Ot,{open:R,onOpenChange:j=>{k(j),T(!1)},children:[s.jsx(Bt,{asChild:!0,children:s.jsxs(Q,{preset:"outline",className:"flex w-full items-center justify-between gap-2 pr-3! focus:z-10",children:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(mt,{className:"h-4 w-4"}),"Add NoSQL Source"]}),s.jsx(nt,{className:"h-4 w-4"})]})}),s.jsxs(_t,{side:"bottom",align:"start",children:[s.jsxs(Me,{onClick:ae,children:[s.jsx(qs,{className:"h-4 w-4"}),"Upload NoSQL Schema"]}),s.jsxs(Me,{onClick:()=>A(!0),children:[s.jsx(ws,{className:"h-4 w-4"}),"Open NoSQL Editor"]}),s.jsxs(Me,{onClick:Ne,children:[s.jsx(Vo,{className:"h-4 w-4"}),"New DynamoDB Table"]}),s.jsxs(Me,{onClick:Y,children:[s.jsx(ws,{className:"h-4 w-4"}),"New MongoDB Collection"]})]})]})]}),s.jsxs("div",{children:[n.length>0&&s.jsxs(s.Fragment,{children:[s.jsx(St,{className:"my-4"}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("h4",{className:"text-secondary-foreground text-sm font-medium",children:["Sources (",n.length,")"]}),n.map(j=>s.jsx("div",{className:H("group border-stock bg-popover rounded-lg border py-2 transition-all",g===j.id&&"border-blue-500 ring-1 ring-blue-500",c===j.id&&"ring-2 ring-green-500"),children:c===j.id?s.jsxs("div",{children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between px-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ht,{className:"h-4 w-4 text-green-600"}),s.jsxs("span",{className:"text-foreground text-sm font-medium",children:["Editing: ",j.name]})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(Q,{size:"sm",variant:"ghost",onClick:te,children:"Cancel"}),s.jsxs(Q,{size:"sm",variant:"ghost",className:"text-green-600 hover:text-green-700",onClick:()=>$(j.id),children:["Done",s.jsx(Yo,{className:"h-3.5 w-3.5"})]})]})]}),s.jsx(en,{height:"400px",value:w,setValue:z=>L(j.id,z)}),s.jsx("div",{className:"text-muted-foreground mt-2 px-2 text-xs",children:"Changes sync automatically to flow diagram and right panel"})]}):s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-start justify-between gap-2 p-3",children:[s.jsxs("button",{className:"flex min-w-0 flex-1 cursor-pointer flex-col items-start text-left",onClick:()=>D(j.id),children:[s.jsxs("div",{className:"flex w-full items-center gap-2",children:[q(j.id)?s.jsx(nt,{className:"text-muted-foreground h-4 w-4 flex-shrink-0"}):s.jsx($s,{className:"text-muted-foreground h-4 w-4 flex-shrink-0"}),s.jsx(ws,{className:"h-4 w-4 flex-shrink-0 text-blue-600"}),s.jsx("span",{className:"text-foreground truncate text-sm font-medium",children:j.name}),j.modifiedAt&&s.jsx("span",{className:"rounded bg-yellow-100 px-1.5 py-0.5 text-xs text-yellow-700",children:"Modified"})]}),s.jsxs("div",{className:"text-muted-foreground mt-1 ml-10 flex items-center gap-3 text-xs",children:[s.jsx("span",{className:"uppercase",children:j.dialect}),s.jsx("span",{children:"•"}),s.jsxs("span",{children:[j.schemaAst?.tables?.length||0," tables"]}),s.jsx("span",{children:"•"}),s.jsxs("span",{children:[j.schemaAst?.tables?.reduce((z,_)=>z+_.constraints?.filter(Z=>Z.type==="foreign_key").length,0)," ","relations"]})]})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(Q,{variant:"ghost",size:"sm",className:"text-muted-foreground h-7 w-7 p-0 hover:text-blue-600",onClick:()=>ye(j),title:"View/Edit SQL",children:s.jsx(Ht,{className:"h-3.5 w-3.5"})}),(j.dialect==="dynamodb"||j.dialect==="mongodb"||j.dialect==="json")&&s.jsx(Q,{variant:"ghost",size:"sm",className:"text-muted-foreground h-7 w-7 p-0 hover:text-blue-600",onClick:()=>F(j),title:"Edit NoSQL Schema",children:s.jsx(Ia,{className:"h-3.5 w-3.5"})}),s.jsx(Q,{variant:"ghost",size:"sm",className:"text-muted-foreground h-7 w-7 p-0 hover:text-green-600",onClick:()=>P(j.id),title:"Regenerate SQL from AST",children:s.jsx(bl,{className:"h-3.5 w-3.5"})}),s.jsx(Q,{variant:"ghost",size:"sm",className:"text-muted-foreground h-7 w-7 p-0 hover:text-red-600",onClick:()=>ke(j.id),children:s.jsx(It,{className:"h-3.5 w-3.5"})})]})]}),q(j.id)&&s.jsx("div",{className:"ml-7 space-y-1 rounded px-2 pb-2",children:j.schemaAst?.tables.map(z=>s.jsxs("div",{draggable:!0,className:"bg-card hover:bg-accent flex cursor-grab items-center justify-between rounded px-3 py-2 text-sm transition-all active:cursor-grabbing",onDragStart:_=>{Ke(_,"databaseTableSQL",{localTable:{databaseName:j.name,tableName:z.name}},{width:400,id:Fo(j.name,z.name)},z.name??"Table")},children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Qe,{className:"h-4 w-4 text-green-600"}),s.jsx("span",{className:"text-secondary-foreground font-mono font-medium",children:z?.name})]}),s.jsxs("span",{className:"text-muted-foreground text-xs",children:[z?.columns?.length||0," cols"]})]},`${j.id}-${z?.name}`))})]})},j.id))]})]}),n.length===0&&s.jsxs("div",{className:"mt-8 text-center",children:[s.jsx("div",{className:"bg-accent mx-auto mb-3 flex h-16 w-16 items-center justify-center rounded-full",children:s.jsx(Qe,{className:"text-muted-foreground h-8 w-8"})}),s.jsx("p",{className:"text-muted-foreground text-sm",children:"No data sources yet"}),s.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:"Upload a SQL file or create a table manually"})]})]}),s.jsxs("div",{className:"space-y-2",children:[x.length>0&&s.jsxs("div",{className:"mb-4",children:[s.jsx("label",{className:"text-secondary-foreground mb-2 block text-sm font-medium",children:"Select Service"}),s.jsx(no,{disabled:d,value:u||"",onChange:m,options:x.map(j=>({value:j.serviceId,label:j.name}))})]}),u&&N.length>0&&s.jsx("div",{children:N.map(j=>{const z=j.noSQLSchema?.dynamo?.table,_=j.noSQLSchema?.mongo?.collections;let Z=[];z?.name?Z=[{name:z.name,colCount:z.attributes?.length??0}]:_&&(Z=_.map(K=>({name:K.name,colCount:K.fields?.length??0})));const ge=Z.length>0,oe=ge?Z.length:j.tables?.length||0;return s.jsxs("div",{className:"mb-4",children:[s.jsxs("h4",{className:"text-secondary-foreground mb-2 text-sm font-medium",children:[j.dbName," (",oe," tables)"]}),s.jsx("div",{className:"space-y-2",children:h?s.jsx("div",{className:"text-muted-foreground text-sm",children:"Loading tables..."}):ge?Z.map(K=>s.jsxs("div",{draggable:!0,className:"bg-card hover:bg-accent flex cursor-grab items-center justify-between rounded px-3 py-2 text-sm transition-all active:cursor-grabbing",onDragStart:fe=>{Ke(fe,"databaseTableSQL",{serviceTable:{serviceName:f.name,databaseName:j.dbName,tableName:K.name}},{width:400},K.name)},children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Qe,{className:"h-4 w-4 text-green-600"}),s.jsx("span",{className:"text-secondary-foreground font-mono font-medium",children:K.name})]}),s.jsxs("span",{className:"text-muted-foreground text-xs",children:[K.colCount," attrs"]})]},`${j.serviceDBId}-${K.name}`)):j.tables?.filter(K=>K?.name!=null).map(K=>s.jsxs("div",{draggable:!0,className:"bg-card hover:bg-accent flex cursor-grab items-center justify-between rounded px-3 py-2 text-sm transition-all active:cursor-grabbing",onDragStart:fe=>{Ke(fe,"databaseTableSQL",{serviceTable:{serviceName:f.name,databaseName:j.dbName,tableName:K.name}},{width:400},K.name??"Table")},children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Qe,{className:"h-4 w-4 text-green-600"}),s.jsx("span",{className:"text-secondary-foreground font-mono font-medium",children:K?.name})]}),s.jsxs("span",{className:"text-muted-foreground text-xs",children:[K?.columns?.length||0," cols"]})]},`${j.serviceDBId}-${K?.name}`))})]},j.serviceDBId)})})]})]}),s.jsx(In,{open:C,onOpenChange:j=>A(j),onSchemaSubmit:async j=>{const z=Ge.toReactFlow(j.schemaAst,j.name);t(_=>[..._,...z.nodes]),e(_=>[..._,...z.edges]),i(_=>[..._,j]),v(j.id),p(_=>new Set([..._,j.id])),U.success("NoSQL schema saved"),A(!1)}}),s.jsx(In,{open:O!==null,initialDataSource:O??void 0,onOpenChange:()=>F(null),onSchemaSubmit:async j=>{O&&(i(z=>z.map(_=>_.id===O.id?j:_)),U.success("NoSQL schema saved"),F(null))}})]})})}const Gn=[{cloud:"AWS",title:"AWS",manifestUrl:"/aws-icons.json"},{cloud:"Azure",title:"Azure",manifestUrl:"/azure-icons.json"},{cloud:"GCP",title:"Google Cloud",manifestUrl:"/gcp-icons.json"},{cloud:"Kubernetes",title:"Kubernetes",manifestUrl:"/kubernetes-icons.json"}];async function Td(t){const e=await fetch(t);if(!e.ok)throw new Error(`Failed to load icons from ${t}`);return e.json()}function Ed(){return nl({queries:Gn.map(t=>({queryKey:["icon-manifest",t.cloud],queryFn:()=>Td(t.manifestUrl),staleTime:1/0,gcTime:1/0})),combine:t=>{const e=[];return Gn.forEach((n,i)=>{const r=t[i].data;if(!r?.length)return;const a={};for(const o of r)(a[o.category]??=[]).push(o);e.push({title:n.title,cloud:n.cloud,categories:a})}),{sections:e,isLoading:t.some(n=>n.isPending),error:t.every(n=>n.isError)?t[0].error?.message??"Failed to load icons":null}}})}function Zi({cloud:t,icon:e}){const n=`/${t.toLowerCase()}-icons/${e.relativePath}`,i=`${t.toLowerCase()}:${e.name.toLowerCase().replace(/\s+/g,"-")}`;return s.jsxs("div",{draggable:!0,className:xd,onDragStart:r=>{Ke(r,"cloud",{cloud:t,iconSrc:n,category:e.category,componentFields:[{componentFieldId:"name",type:X.TextInput,label:"Name",isReadonly:!0,data:[{value:e.name}]}]},{width:150,height:160})},children:[s.jsx("div",{className:"flex size-8 items-center justify-center rounded-md bg-[#141925] transition-colors group-hover:bg-[#232b3a]",children:s.jsx("img",{src:n,alt:e.name,className:"size-5",onError:r=>{const a=r.target;a.src="/placeholder.svg"}})}),s.jsx("div",{className:"min-w-0 flex-1",children:s.jsx("span",{className:"group-hover:text-primary block truncate text-sm font-medium text-[#F4F7FC]",children:e.name})})]},i)}function Ld(t){return s.jsxs("svg",{fill:"none",width:"1em",height:"1em",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",...t,children:[s.jsx("g",{id:"SVGRepo_bgCarrier",strokeWidth:"0"}),s.jsx("g",{id:"SVGRepo_tracerCarrier",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsxs("g",{id:"SVGRepo_iconCarrier",children:[s.jsx("path",{fill:"#252F3E",d:"M4.51 7.687c0 .197.02.357.058.475.042.117.096.245.17.384a.233.233 0 01.037.123c0 .053-.032.107-.1.16l-.336.224a.255.255 0 01-.138.048c-.054 0-.107-.026-.16-.074a1.652 1.652 0 01-.192-.251 4.137 4.137 0 01-.165-.315c-.415.491-.936.737-1.564.737-.447 0-.804-.129-1.064-.385-.261-.256-.394-.598-.394-1.025 0-.454.16-.822.484-1.1.325-.278.756-.416 1.304-.416.18 0 .367.016.564.042.197.027.4.07.612.118v-.39c0-.406-.085-.689-.25-.854-.17-.166-.458-.246-.868-.246-.186 0-.377.022-.574.07a4.23 4.23 0 00-.575.181 1.525 1.525 0 01-.186.07.326.326 0 01-.085.016c-.075 0-.112-.054-.112-.166v-.262c0-.085.01-.15.037-.186a.399.399 0 01.15-.113c.185-.096.409-.176.67-.24.26-.07.537-.101.83-.101.633 0 1.096.144 1.394.432.293.288.442.726.442 1.314v1.73h.01zm-2.161.811c.175 0 .356-.032.548-.096.191-.064.362-.182.505-.342a.848.848 0 00.181-.341c.032-.129.054-.283.054-.465V7.03a4.43 4.43 0 00-.49-.09 3.996 3.996 0 00-.5-.033c-.357 0-.618.07-.793.214-.176.144-.26.347-.26.614 0 .25.063.437.196.566.128.133.314.197.559.197zm4.273.577c-.096 0-.16-.016-.202-.054-.043-.032-.08-.106-.112-.208l-1.25-4.127a.938.938 0 01-.049-.214c0-.085.043-.133.128-.133h.522c.1 0 .17.016.207.053.043.032.075.107.107.208l.894 3.535.83-3.535c.026-.106.058-.176.1-.208a.365.365 0 01.214-.053h.425c.102 0 .17.016.213.053.043.032.08.107.101.208l.841 3.578.92-3.578a.458.458 0 01.107-.208.346.346 0 01.208-.053h.495c.085 0 .133.043.133.133 0 .027-.006.054-.01.086a.76.76 0 01-.038.133l-1.283 4.127c-.032.107-.069.177-.111.209a.34.34 0 01-.203.053h-.457c-.101 0-.17-.016-.213-.053-.043-.038-.08-.107-.101-.214L8.213 5.37l-.82 3.439c-.026.107-.058.176-.1.213-.043.038-.118.054-.213.054h-.458zm6.838.144a3.51 3.51 0 01-.82-.096c-.266-.064-.473-.134-.612-.214-.085-.048-.143-.101-.165-.15a.378.378 0 01-.031-.149v-.272c0-.112.042-.166.122-.166a.3.3 0 01.096.016c.032.011.08.032.133.054.18.08.378.144.585.187.213.042.42.064.633.064.336 0 .596-.059.777-.176a.575.575 0 00.277-.508.52.52 0 00-.144-.373c-.095-.102-.276-.193-.537-.278l-.772-.24c-.388-.123-.676-.305-.851-.545a1.275 1.275 0 01-.266-.774c0-.224.048-.422.143-.593.096-.17.224-.32.384-.438.16-.122.34-.213.553-.277.213-.064.436-.091.67-.091.118 0 .24.005.357.021.122.016.234.038.346.06.106.026.208.052.303.085.096.032.17.064.224.096a.46.46 0 01.16.133.289.289 0 01.047.176v.251c0 .112-.042.171-.122.171a.552.552 0 01-.202-.064 2.427 2.427 0 00-1.022-.208c-.303 0-.543.048-.708.15-.165.1-.25.256-.25.475 0 .149.053.277.16.379.106.101.303.202.585.293l.756.24c.383.123.66.294.825.513.165.219.244.47.244.748 0 .23-.047.437-.138.619a1.436 1.436 0 01-.388.47c-.165.133-.362.23-.591.299-.24.075-.49.112-.761.112z"}),s.jsxs("g",{fill:"#F90",fillRule:"evenodd",clipRule:"evenodd",children:[s.jsx("path",{d:"M14.465 11.813c-1.75 1.297-4.294 1.986-6.481 1.986-3.065 0-5.827-1.137-7.913-3.027-.165-.15-.016-.353.18-.235 2.257 1.313 5.04 2.109 7.92 2.109 1.941 0 4.075-.406 6.039-1.239.293-.133.543.192.255.406z"}),s.jsx("path",{d:"M15.194 10.98c-.223-.287-1.479-.138-2.048-.069-.17.022-.197-.128-.043-.24 1-.705 2.645-.502 2.836-.267.192.24-.053 1.89-.99 2.68-.143.123-.281.06-.218-.1.213-.53.687-1.72.463-2.003z"})]})]})]})}function Ad(t){return s.jsxs("svg",{width:"1em",height:"1em",fill:"none",viewBox:"0 -28.5 256 256",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",...t,children:[s.jsx("g",{id:"SVGRepo_bgCarrier",strokeWidth:"0"}),s.jsx("g",{id:"SVGRepo_tracerCarrier",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsxs("g",{id:"SVGRepo_iconCarrier",children:[s.jsx("title",{children:"path21"}),s.jsx("g",{stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:s.jsx("path",{d:"M118.431947,187.698037 C151.322003,181.887937 178.48731,177.08008 178.799309,177.013916 L179.366585,176.893612 L148.31513,139.958881 C131.236843,119.644776 117.26369,102.945381 117.26369,102.849118 C117.26369,102.666861 149.32694,14.3716012 149.507189,14.057257 C149.567455,13.952452 171.38747,51.62411 202.400338,105.376064 C231.435152,155.699606 255.372949,197.191547 255.595444,197.580359 L255.999996,198.287301 L157.315912,198.274572 L58.6318456,198.261895 L118.431947,187.698073 L118.431947,187.698037 Z M-4.03864498e-06,176.434723 C-4.03864498e-06,176.382721 14.631291,150.983941 32.5139844,119.992969 L65.0279676,63.6457518 L102.919257,31.8473052 C123.759465,14.3581634 140.866667,0.0274832751 140.935253,0.00062917799 C141.003839,-0.0247829554 140.729691,0.665213042 140.326034,1.53468179 C139.922377,2.40415053 121.407304,42.1170321 99.1814268,89.7855264 L58.7707514,176.455514 L29.3853737,176.492355 C13.2234196,176.512639 -4.03864498e-06,176.486664 -4.03864498e-06,176.434703 L-4.03864498e-06,176.434723 Z",fill:"#0089D6",fillRule:"nonzero"})})]})]})}function Fd(t){return s.jsxs("svg",{fill:"none",width:"1em",height:"1em",version:"1.1",viewBox:"0 -25 256 256",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",preserveAspectRatio:"xMidYMid",...t,children:[s.jsx("g",{id:"SVGRepo_bgCarrier",strokeWidth:"0"}),s.jsx("g",{id:"SVGRepo_tracerCarrier",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("g",{id:"SVGRepo_iconCarrier",children:s.jsxs("g",{children:[s.jsx("path",{d:"M170.2517,56.8186 L192.5047,34.5656 L193.9877,25.1956 C153.4367,-11.6774 88.9757,-7.4964 52.4207,33.9196 C42.2667,45.4226 34.7337,59.7636 30.7167,74.5726 L38.6867,73.4496 L83.1917,66.1106 L86.6277,62.5966 C106.4247,40.8546 139.8977,37.9296 162.7557,56.4286 L170.2517,56.8186 Z",fill:"#EA4335"}),s.jsx("path",{d:"M224.2048,73.9182 C219.0898,55.0822 208.5888,38.1492 193.9878,25.1962 L162.7558,56.4282 C175.9438,67.2042 183.4568,83.4382 183.1348,100.4652 L183.1348,106.0092 C198.4858,106.0092 210.9318,118.4542 210.9318,133.8052 C210.9318,149.1572 198.4858,161.2902 183.1348,161.2902 L127.4638,161.2902 L121.9978,167.2242 L121.9978,200.5642 L127.4638,205.7952 L183.1348,205.7952 C223.0648,206.1062 255.6868,174.3012 255.9978,134.3712 C256.1858,110.1682 244.2528,87.4782 224.2048,73.9182",fill:"#4285F4"}),s.jsx("path",{d:"M71.8704,205.7957 L127.4634,205.7957 L127.4634,161.2897 L71.8704,161.2897 C67.9094,161.2887 64.0734,160.4377 60.4714,158.7917 L52.5844,161.2117 L30.1754,183.4647 L28.2234,191.0387 C40.7904,200.5277 56.1234,205.8637 71.8704,205.7957",fill:"#34A853"}),s.jsx("path",{d:"M71.8704,61.4255 C31.9394,61.6635 -0.2366,94.2275 0.0014,134.1575 C0.1344,156.4555 10.5484,177.4455 28.2234,191.0385 L60.4714,158.7915 C46.4804,152.4705 40.2634,136.0055 46.5844,122.0155 C52.9044,108.0255 69.3704,101.8085 83.3594,108.1285 C89.5244,110.9135 94.4614,115.8515 97.2464,122.0155 L129.4944,89.7685 C115.7734,71.8315 94.4534,61.3445 71.8704,61.4255",fill:"#FBBC05"})]})})]})}const Dd={aws:s.jsx(Ld,{}),azure:s.jsx(Ad,{}),gcp:s.jsx(Fd,{}),kubernetes:s.jsx(_o,{color:"#326CE5"})};function Ji(t){return Dd[t.toLowerCase()]||"☁️"}function qn(t,e){return`${t}::${e}`}function Rd({cloud:t,category:e,icons:n,isExpanded:i,onToggle:r}){const[a,o]=y.useState(!1),c=a?n:n.slice(0,8),l=n.length-c.length;return s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsxs("button",{onClick:r,className:pd,children:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(Ea,{className:"text-muted-foreground size-3"}),s.jsx("span",{className:"truncate capitalize",children:e.replace(/-/g," ")}),s.jsx("span",{className:"rounded-full bg-[#232b3a] px-1.5 py-0.5 text-[10px] text-[#828DA3]",children:n.length})]}),s.jsx("div",{className:"transition-transform group-hover:scale-110",children:i?s.jsx(an,{className:"size-4"}):s.jsx(ct,{className:"size-4"})})]}),i&&s.jsxs("div",{className:fd,children:[c.map(u=>s.jsx(Zi,{cloud:t,icon:u},`${t}:${e}:${u.name}:${u.relativePath}`)),l>0&&s.jsxs(Q,{preset:"outline",onClick:()=>o(!0),children:["+",l," more"]})]})]})}function zd({sections:t}){const[e,n]=y.useState(new Set),[i,r]=y.useState(new Set);return s.jsx("div",{className:"space-y-3",children:t.map(a=>s.jsxs("div",{className:"flex flex-col gap-4",children:[s.jsx("button",{onClick:()=>{const o=new Set(e);o.has(a.cloud)?o.delete(a.cloud):o.add(a.cloud),n(o)},className:"w-full rounded-lg border border-[#2A3242] bg-[#1E2533] p-3 transition-all hover:bg-[#232b3a] focus:outline-none",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-3xl",children:Ji(a.cloud)}),s.jsxs("div",{className:"text-left",children:[s.jsx("h3",{className:"text-sm font-semibold text-[#F4F7FC]",children:a.title}),s.jsxs("p",{className:"text-muted-foreground text-xs",children:[Object.values(a.categories).flat().length," icons available"]})]})]}),s.jsx("div",{className:"transition-transform duration-200",children:e.has(a.cloud)?s.jsx(Ta,{className:"text-muted-foreground size-4"}):s.jsx(an,{className:"text-muted-foreground size-4"})})]})}),e.has(a.cloud)&&s.jsx("div",{className:"animate-in slide-in-from-top-2 flex flex-col gap-2 duration-200",children:Object.entries(a.categories).map(([o,c])=>s.jsx(Rd,{cloud:a.cloud,category:o,icons:c,isExpanded:i.has(qn(a.cloud,o)),onToggle:()=>{const l=new Set(i),u=qn(a.cloud,o);l.has(u)?l.delete(u):l.add(u),r(l)}},`${a.cloud}:${o}`))})]},a.cloud))})}function Md({sections:t,searchQuery:e}){const n=e.trim(),[i,r]=y.useState([]),[a,o]=y.useState(!1),c=y.useMemo(()=>t.flatMap(m=>Object.entries(m.categories).flatMap(([d,h])=>h.map(x=>({cloud:m.cloud,title:m.title,category:d,icon:x,searchText:`${m.cloud} ${m.title} ${d} ${x.name}`})))),[t]),l=y.useMemo(()=>new io(c,{includeScore:!0,threshold:.3,ignoreLocation:!0,keys:[{name:"icon.name",weight:.7},{name:"category",weight:.2},{name:"searchText",weight:.1}]}),[c]);y.useEffect(()=>{if(!n){r([]),o(!1);return}o(!0);const m=setTimeout(()=>{r(l.search(n).map(d=>({score:d.score??1,...d.item}))),o(!1)},180);return()=>clearTimeout(m)},[l,n]);const u=y.useMemo(()=>{const m=new Map;for(const d of i){m.has(d.cloud)||m.set(d.cloud,{cloud:d.cloud,title:d.title,score:d.score,categories:new Map});const h=m.get(d.cloud);h.score=Math.min(h.score,d.score),h.categories.has(d.category)||h.categories.set(d.category,{category:d.category,score:d.score,icons:[]});const x=h.categories.get(d.category);x.score=Math.min(x.score,d.score),x.icons.push({icon:d.icon,score:d.score})}return Array.from(m.values()).map(d=>({...d,categories:Array.from(d.categories.values()).map(h=>({...h,icons:h.icons.sort((x,N)=>x.score-N.score||x.icon.name.localeCompare(N.icon.name))})).sort((h,x)=>h.score-x.score||h.category.localeCompare(x.category))})).sort((d,h)=>d.score-h.score||d.title.localeCompare(h.title))},[i]);return a?s.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-center",children:[s.jsx(Os,{className:"text-muted-foreground size-5 animate-spin"}),s.jsx("p",{className:"text-muted-foreground text-sm",children:"Searching icons..."})]}):u.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[s.jsx(Mi,{className:"text-muted-foreground mb-2 size-8"}),s.jsxs("p",{className:"text-muted-foreground text-sm",children:['No icons found for "',e,'"']}),s.jsx("p",{className:"text-muted-foreground text-xs",children:"Try a different search term"})]}):s.jsxs("div",{className:"flex flex-col gap-3",children:[s.jsxs("p",{className:"text-muted-foreground text-xs",children:[i.length," result",i.length!==1?"s":""," in"," ",u.length," provider",u.length!==1?"s":""]}),s.jsx(ze.div,{className:"space-y-3",initial:"hidden",animate:"visible",variants:{hidden:{},visible:{transition:{staggerChildren:.05}}},children:u.map(m=>s.jsxs(ze.div,{className:"flex flex-col gap-3",variants:{hidden:{opacity:0,y:6},visible:{opacity:1,y:0,transition:{duration:.18,ease:"easeOut"}}},children:[s.jsx("div",{className:"border-primary/20 from-primary/10 to-primary/5 w-full rounded-lg border bg-gradient-to-r p-3",children:s.jsx("div",{className:"flex items-center justify-between",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-3xl",children:Ji(m.cloud)}),s.jsxs("div",{className:"text-left",children:[s.jsx("h3",{className:"text-foreground text-sm font-semibold",children:m.title}),s.jsxs("p",{className:"text-paragraph text-xs",children:[m.categories.reduce((d,h)=>d+h.icons.length,0)," ","matched icon",m.categories.reduce((d,h)=>d+h.icons.length,0)!==1?"s":""]})]})]})})}),s.jsx("div",{className:"animate-in slide-in-from-top-2 flex flex-col gap-2 duration-200",children:m.categories.map(d=>s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsxs("div",{className:"group text-secondary-foreground flex h-8 w-full items-center justify-between rounded-md px-3 text-xs font-medium",children:[s.jsx("span",{className:"truncate capitalize",children:d.category.replace(/-/g," ")}),s.jsx("span",{className:"bg-accent text-paragraph rounded-full px-1.5 py-0.5 text-[10px]",children:d.icons.length})]}),s.jsx("div",{className:"border-stock ml-2 flex flex-col gap-1.5 border-l pl-3",children:d.icons.map(h=>s.jsx(Zi,{cloud:m.cloud,icon:h.icon},`${m.cloud}:${d.category}:${h.icon.name}:${h.icon.relativePath}`))})]},`${m.cloud}:${d.category}`))})]},m.cloud))})]})}function Od(){const{sections:t,isLoading:e,error:n}=Ed(),[i,r]=y.useState(""),a=i.trim().length>0;return e?s.jsx(Xe,{className:"left-18",children:s.jsx("div",{className:"flex flex-col gap-2 p-1",children:s.jsx("div",{className:"flex items-center justify-center p-4",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-blue-500 border-t-transparent"}),s.jsx("span",{className:"text-muted-foreground text-sm",children:"Loading icons..."})]})})})}):n?s.jsx(Xe,{className:"left-18",children:s.jsx("div",{className:"flex flex-col gap-2 p-1",children:s.jsx("div",{className:"flex items-center justify-center p-4",children:s.jsxs("div",{className:"text-sm text-red-500",children:["Error loading icons: ",n]})})})}):s.jsx(Xe,{className:"left-18",children:s.jsxs("div",{className:"flex w-96 flex-col gap-3 p-3",children:[s.jsx("div",{className:"sticky top-0 z-10 bg-[#141925] pb-1",children:s.jsxs("div",{className:"relative",children:[s.jsx(Mi,{className:"text-muted-foreground absolute top-1/2 left-3 size-4 -translate-y-1/2"}),s.jsx(Fe,{placeholder:"Search icons...",value:i,onChange:o=>r(o.target.value),className:bd})]})}),s.jsx(it,{mode:"wait",initial:!1,children:a?s.jsx(ze.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},transition:{duration:.18,ease:"easeOut"},children:s.jsx(Md,{sections:t,searchQuery:i})},"search"):s.jsx(ze.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},transition:{duration:.18,ease:"easeOut"},children:s.jsx(zd,{sections:t})},"list")})]})})}/*!
|
|
68
|
+
`+" ".repeat(e));var cs;(function(t){t.DEFAULT={allowTrailingComma:!1}})(cs||(cs={}));function Nc(t,e=[],n=cs.DEFAULT){let i=null,r=[];const a=[];function o(l){Array.isArray(r)?r.push(l):i!==null&&(r[i]=l)}return Cc(t,{onObjectBegin:()=>{const l={};o(l),a.push(r),r=l,i=null},onObjectProperty:l=>{i=l},onObjectEnd:()=>{r=a.pop()},onArrayBegin:()=>{const l=[];o(l),a.push(r),r=l,i=null},onArrayEnd:()=>{r=a.pop()},onLiteralValue:o,onError:(l,u,m)=>{e.push({error:l,offset:u,length:m})}},n),r[0]}function Cc(t,e,n=cs.DEFAULT){const i=wc(t,!1),r=[];let a=0;function o(F){return F?()=>a===0&&F(i.getTokenOffset(),i.getTokenLength(),i.getTokenStartLine(),i.getTokenStartCharacter()):()=>!0}function c(F){return F?G=>a===0&&F(G,i.getTokenOffset(),i.getTokenLength(),i.getTokenStartLine(),i.getTokenStartCharacter()):()=>!0}function l(F){return F?G=>a===0&&F(G,i.getTokenOffset(),i.getTokenLength(),i.getTokenStartLine(),i.getTokenStartCharacter(),()=>r.slice()):()=>!0}function u(F){return F?()=>{a>0?a++:F(i.getTokenOffset(),i.getTokenLength(),i.getTokenStartLine(),i.getTokenStartCharacter(),()=>r.slice())===!1&&(a=1)}:()=>!0}function m(F){return F?()=>{a>0&&a--,a===0&&F(i.getTokenOffset(),i.getTokenLength(),i.getTokenStartLine(),i.getTokenStartCharacter())}:()=>!0}const d=u(e.onObjectBegin),h=l(e.onObjectProperty),x=m(e.onObjectEnd),N=u(e.onArrayBegin),f=m(e.onArrayEnd),g=l(e.onLiteralValue),v=c(e.onSeparator),b=o(e.onComment),p=c(e.onError),w=n&&n.disallowComments,S=n&&n.allowTrailingComma;function I(){for(;;){const F=i.scan();switch(i.getTokenError()){case 4:C(14);break;case 5:C(15);break;case 3:C(13);break;case 1:w||C(11);break;case 2:C(12);break;case 6:C(16);break}switch(F){case 12:case 13:w?C(10):b();break;case 16:C(1);break;case 15:case 14:break;default:return F}}}function C(F,G=[],ae=[]){if(p(F),G.length+ae.length>0){let me=i.getToken();for(;me!==17;){if(G.indexOf(me)!==-1){I();break}else if(ae.indexOf(me)!==-1)break;me=I()}}}function A(F){const G=i.getTokenValue();return F?g(G):(h(G),r.push(G)),I(),!0}function M(){switch(i.getToken()){case 11:const F=i.getTokenValue();let G=Number(F);isNaN(G)&&(C(2),G=0),g(G);break;case 7:g(null);break;case 8:g(!0);break;case 9:g(!1);break;default:return!1}return I(),!0}function T(){return i.getToken()!==10?(C(3,[],[2,5]),!1):(A(!1),i.getToken()===6?(v(":"),I(),O()||C(4,[],[2,5])):C(5,[],[2,5]),r.pop(),!0)}function R(){d(),I();let F=!1;for(;i.getToken()!==2&&i.getToken()!==17;){if(i.getToken()===5){if(F||C(4,[],[]),v(","),I(),i.getToken()===2&&S)break}else F&&C(6,[],[]);T()||C(4,[],[2,5]),F=!0}return x(),i.getToken()!==2?C(7,[2],[]):I(),!0}function k(){N(),I();let F=!0,G=!1;for(;i.getToken()!==4&&i.getToken()!==17;){if(i.getToken()===5){if(G||C(4,[],[]),v(","),I(),i.getToken()===4&&S)break}else G&&C(6,[],[]);F?(r.push(0),F=!1):r[r.length-1]++,O()||C(4,[],[4,5]),G=!0}return f(),F||r.pop(),i.getToken()!==4?C(8,[4],[]):I(),!0}function O(){switch(i.getToken()){case 3:return k();case 1:return R();case 10:return A(!0);default:return M()}}return I(),i.getToken()===17?n.allowEmptyContent?!0:(C(4,[],[]),!1):O()?(i.getToken()!==17&&C(9,[],[]),!0):(C(4,[],[]),!1)}var On;(function(t){t[t.None=0]="None",t[t.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",t[t.UnexpectedEndOfString=2]="UnexpectedEndOfString",t[t.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",t[t.InvalidUnicode=4]="InvalidUnicode",t[t.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",t[t.InvalidCharacter=6]="InvalidCharacter"})(On||(On={}));var Bn;(function(t){t[t.OpenBraceToken=1]="OpenBraceToken",t[t.CloseBraceToken=2]="CloseBraceToken",t[t.OpenBracketToken=3]="OpenBracketToken",t[t.CloseBracketToken=4]="CloseBracketToken",t[t.CommaToken=5]="CommaToken",t[t.ColonToken=6]="ColonToken",t[t.NullKeyword=7]="NullKeyword",t[t.TrueKeyword=8]="TrueKeyword",t[t.FalseKeyword=9]="FalseKeyword",t[t.StringLiteral=10]="StringLiteral",t[t.NumericLiteral=11]="NumericLiteral",t[t.LineCommentTrivia=12]="LineCommentTrivia",t[t.BlockCommentTrivia=13]="BlockCommentTrivia",t[t.LineBreakTrivia=14]="LineBreakTrivia",t[t.Trivia=15]="Trivia",t[t.Unknown=16]="Unknown",t[t.EOF=17]="EOF"})(Bn||(Bn={}));const Sc=Nc;var _n;(function(t){t[t.InvalidSymbol=1]="InvalidSymbol",t[t.InvalidNumberFormat=2]="InvalidNumberFormat",t[t.PropertyNameExpected=3]="PropertyNameExpected",t[t.ValueExpected=4]="ValueExpected",t[t.ColonExpected=5]="ColonExpected",t[t.CommaExpected=6]="CommaExpected",t[t.CloseBraceExpected=7]="CloseBraceExpected",t[t.CloseBracketExpected=8]="CloseBracketExpected",t[t.EndOfFileExpected=9]="EndOfFileExpected",t[t.InvalidCommentToken=10]="InvalidCommentToken",t[t.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",t[t.UnexpectedEndOfString=12]="UnexpectedEndOfString",t[t.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",t[t.InvalidUnicode=14]="InvalidUnicode",t[t.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",t[t.InvalidCharacter=16]="InvalidCharacter"})(_n||(_n={}));async function Ks(t,e){if(e===void 0)try{return await Io(t)}catch{throw new Error("Failed to import Mermaid diagram")}const n=Sc(e);if(n===null||typeof n!="object"||Array.isArray(n))throw new Error("Invalid Mermaid context file");try{return await Fo(t,n,{repositionNodes:!0})}catch{throw new Error("Failed to import Mermaid diagram")}}async function kc(){const[...t]=await as({multiple:!0,accept:".mmd,.txt,.json,.jsonc"}),e=t.find(r=>r.name.toLowerCase().endsWith(".mmd"))??t.find(r=>r.name.toLowerCase().endsWith(".txt"));if(!e)throw new Error("No Mermaid file found");const n=t.find(r=>r.name.toLowerCase().endsWith(".json"))??t.find(r=>r.name.toLowerCase().endsWith(".jsonc")),i=await e.text();return n?Ks(i,await n.text()):Ks(i)}function Ic(t,e){return To(t)?Eo(t,e):Ri(t)?Lo(t,e):Ao({nodes:t,edges:e})}function Tc(t,e,n){const i=n.trim().replace(/[\\/:*?"<>|]+/g,"-").replace(/\s+/g," ")||"uigraph-diagram",r=Ic(t,e),a=new Blob([r.mermaid],{type:"text/plain;charset=utf-8"}),o=URL.createObjectURL(a),c=document.createElement("a");c.href=o,c.download=`${i}.mmd`,c.click();const l=new Blob([JSON.stringify(r.context,null,2)],{type:"application/json;charset=utf-8"}),u=URL.createObjectURL(l),m=document.createElement("a");m.href=u,m.download=`${i}-context.json`,m.click(),URL.revokeObjectURL(u),URL.revokeObjectURL(o)}function Ec(){const{setNodes:t,setEdges:e}=we(),[n,i]=y.useState(!1),[r,a]=y.useState(""),[o,c]=y.useState(""),[l,u]=y.useState(!1);return s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Q,{preset:"outline",onClick:()=>i(!0),children:[s.jsx(Na,{}),"Insert Code"]}),s.jsx(an,{open:n,onOpenChange:i,children:s.jsx(on,{title:"Insert code",description:"Paste your Mermaid diagram and optionally its context JSON.",footerCancel:!0,footerSubmit:"Import",footerSubmitLoading:l,onFooterSubmitClick:async()=>{if(!r.trim())return U.error("Mermaid code is required");u(!0);try{const m=await Ks(r,o.trim()||void 0);t(m.nodes),e(m.edges),i(!1),a(""),c(""),U.success("Diagram imported successfully")}catch{U.error("Failed to import the pasted code")}finally{u(!1)}},children:s.jsxs("div",{className:"flex flex-col gap-5",children:[s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(le,{children:"Mermaid"}),s.jsx(Ws,{value:r,onChange:m=>a(m.target.value),placeholder:"flowchart TD ...",className:"min-h-[220px] font-mono"})]}),s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(le,{children:"Context JSON (optional)"}),s.jsx(Ws,{value:o,onChange:m=>c(m.target.value),placeholder:"{ ... }",className:"min-h-[140px] font-mono"})]})]})})})]})}const Lc=mr("5s");function Ac(){const{diagramId:t,diagramName:e,organizationId:n,isEmbedded:i,childDiagramIds:r,setChildDiagramIds:a}=we(),o=Mo(),c=y.useRef(null),[l,u]=y.useState(!1),[m,d]=y.useState(!1),[h,x]=y.useState(!1),N=r[r.length-1];y.useEffect(()=>{u(!1),d(!1)},[N]);const f=y.useCallback(async g=>{if(!N||!n||m)return;d(!0);const v=c.current?.contentWindow?.__uigraphEmbedSave?.();v&&await Promise.race([v,new Promise(b=>setTimeout(b,Lc))]),d(!1),a(g);try{await o.query({query:yi,errorPolicy:"ignore",fetchPolicy:"network-only",variables:{orgId:n,id:N}})}catch{U.error("Failed to refresh the sub diagram preview")}},[o,m,N,n,a]);return y.useEffect(()=>{if(!N)return;window.__uigraphEmbedClose=()=>void f(r.slice(0,-1)),window.__uigraphOpenChild=v=>{if(t&&v===t){x(!0);return}f([...r,v])};function g(v){if(v.key==="Escape"){if(h){x(!1),v.stopPropagation(),v.stopImmediatePropagation();return}f(r.slice(0,-1))}}return window.addEventListener("keydown",g,{capture:!0}),()=>{delete window.__uigraphEmbedClose,delete window.__uigraphOpenChild,window.removeEventListener("keydown",g,{capture:!0})}},[N,r,t,h,f]),i||!N?null:s.jsxs(s.Fragment,{children:[s.jsx(en,{open:!0,onOpenChange:g=>{g||f([])},children:s.jsxs(nn,{showCloseButton:!1,className:"bg-shading border-stock flex h-[94vh] w-[96vw] max-w-none flex-col gap-0 overflow-hidden rounded-[0.75rem] p-0 sm:max-w-none",children:[s.jsx(sn,{className:"hidden",children:"Edit the linked sub diagram without leaving this diagram"}),s.jsxs("div",{className:"border-stock flex h-12 shrink-0 items-center gap-2 border-b px-3",children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1 text-sm",children:[s.jsx("button",{type:"button",onClick:()=>void f([]),className:"text-paragraph max-w-[16rem] min-w-0 truncate transition-colors hover:text-[#F4F7FC]",children:e}),r.map((g,v)=>s.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[s.jsx(ct,{className:"text-paragraph size-3.5 shrink-0"}),v===r.length-1?s.jsx(tn,{className:"min-w-0 truncate text-sm font-medium text-[#F4F7FC]",children:s.jsx(Kt,{diagramId:g,organizationId:n})}):s.jsx("button",{type:"button",onClick:()=>void f(r.slice(0,v+1)),className:"text-paragraph max-w-[16rem] min-w-0 truncate transition-colors hover:text-[#F4F7FC]",children:s.jsx(Kt,{diagramId:g,organizationId:n})})]},`${g}-${v}`))]}),m&&s.jsxs("span",{className:"text-paragraph flex shrink-0 items-center gap-1.5 text-xs",children:[s.jsx(Ms,{className:"size-3 animate-spin"}),"Saving…"]}),s.jsx("button",{type:"button",title:"Open in new tab",onClick:()=>li(N),className:"text-paragraph flex size-8 shrink-0 items-center justify-center rounded-[0.5rem] transition-colors hover:text-[#F4F7FC]",children:s.jsx(Ii,{className:"size-4"})}),s.jsx(gs,{title:"Close",onClick:()=>void f([]),className:"size-8 shrink-0 rounded-[0.5rem]"})]}),s.jsxs("div",{className:"relative min-h-0 flex-1",children:[s.jsx("iframe",{ref:c,src:`/diagram/${N}/embed`,title:`Sub diagram of ${t}`,onLoad:()=>u(!0),className:"size-full border-0"},N),!l&&s.jsxs("div",{className:"bg-shading text-paragraph absolute inset-0 flex flex-col items-center justify-center gap-2",children:[s.jsx(Ms,{className:"size-5 animate-spin"}),s.jsx("span",{className:"text-xs",children:"Opening diagram…"})]})]})]})}),s.jsx(an,{open:h,onOpenChange:g=>!g&&x(!1),className:"sm:max-w-[min(40rem,90%)]",children:s.jsx(on,{title:"This is the main diagram",description:"Opening it here nests it inside itself.",children:s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("button",{type:"button",onClick:()=>{x(!1),t&&f([...r,t])},className:"border-stock hover:border-primary/60 flex flex-col rounded-xl border p-5 text-left transition-colors outline-none",children:[s.jsxs("span",{className:"grid flex-1 grid-cols-[auto_1fr] items-start gap-x-3 gap-y-0.5",children:[s.jsx("span",{className:"bg-primary/10 text-primary row-span-2 flex size-11 items-center justify-center rounded-xl",children:s.jsx(Ca,{className:"size-5"})}),s.jsx("span",{className:"min-w-0 truncate text-sm font-medium text-[#F4F7FC]",children:"Open as child"}),s.jsx("span",{className:"text-paragraph line-clamp-2 min-w-0 text-xs leading-snug",children:"Nest the main diagram one level deeper"})]}),s.jsxs("span",{className:"mt-5 flex items-center gap-1 whitespace-nowrap",children:[s.jsx("span",{className:"border-stock/70 text-paragraph/80 shrink-0 rounded-md border px-1.5 py-0.5 text-[10px]",children:"Main diagram"}),s.jsx(ct,{className:"text-paragraph/50 size-3 shrink-0"}),r.length>1&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-paragraph/60 text-[10px]",children:"…"}),s.jsx(ct,{className:"text-paragraph/50 size-3 shrink-0"})]}),s.jsx("span",{className:"border-stock/70 text-paragraph/80 max-w-[5rem] truncate rounded-md border px-1.5 py-0.5 text-[10px]",children:s.jsx(Kt,{diagramId:N,organizationId:n})}),s.jsx(ct,{className:"text-primary/60 size-3 shrink-0"}),s.jsxs("span",{className:"border-primary/40 text-primary/90 flex shrink-0 items-center gap-1 rounded-md border px-1.5 py-0.5 text-[10px]",children:[s.jsx(Sa,{className:"size-3 shrink-0"}),"Main diagram"]})]})]}),s.jsxs("button",{type:"button",onClick:()=>{x(!1),f([])},className:"border-stock hover:border-paragraph/60 flex flex-col rounded-xl border p-5 text-left transition-colors outline-none",children:[s.jsxs("span",{className:"grid flex-1 grid-cols-[auto_1fr] items-start gap-x-3 gap-y-0.5",children:[s.jsx("span",{className:"bg-paragraph/10 text-paragraph row-span-2 flex size-11 items-center justify-center rounded-xl",children:s.jsx(ka,{className:"size-5"})}),s.jsx("span",{className:"min-w-0 truncate text-sm font-medium text-[#F4F7FC]",children:"Close sub diagrams"}),s.jsx("span",{className:"text-paragraph line-clamp-2 min-w-0 text-xs leading-snug",children:"Close the sub diagrams and go back"})]}),s.jsxs("span",{className:"mt-5 flex items-center gap-1 whitespace-nowrap",children:[s.jsx("span",{className:"border-primary/40 text-primary/90 shrink-0 rounded-md border px-1.5 py-0.5 text-[10px]",children:"Main diagram"}),s.jsx(ct,{className:"text-paragraph/40 size-3 shrink-0"}),r.length>1&&s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"border-stock/40 text-paragraph/40 rounded-md border border-dashed px-1.5 py-0.5 text-[10px]",children:["+",r.length-1]}),s.jsx(ct,{className:"text-paragraph/40 size-3 shrink-0"})]}),s.jsx("span",{className:"border-stock/40 text-paragraph/40 max-w-[5rem] truncate rounded-md border border-dashed px-1.5 py-0.5 text-[10px] line-through",children:s.jsx(Kt,{diagramId:N,organizationId:n})})]})]})]})})})]})}function Kt({diagramId:t,organizationId:e}){const{data:n}=ut(yi,{errorPolicy:"ignore",fetchPolicy:"cache-first",skip:!e,variables:{orgId:e,id:t}});return s.jsx(s.Fragment,{children:n?.diagram?.name??"Untitled diagram"})}function Fc({className:t,...e}){return s.jsx("svg",{viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:H(Ye.icon,t),...e,children:s.jsx("path",{d:"M10.8006 2.94556L3.10059 10.6456M3.10059 2.94556L10.8006 10.6456",stroke:"currentColor",strokeWidth:"0.825",strokeLinecap:"round",strokeLinejoin:"round"})})}function Dc({className:t,...e}){return s.jsx("svg",{fill:"none",viewBox:"0 0 18 17",xmlns:"http://www.w3.org/2000/svg",className:H(Ye.icon,t),...e,children:s.jsx("path",{d:"M6.25055 6.4129L4.63222 8.1547C4.41645 8.37684 4.03136 8.95658 3.98489 9.4876C3.93602 10.046 4.43914 10.8471 4.63222 11.1538C5.13549 11.953 5.33814 12.3966 5.92688 13.1531C6.24661 13.5639 7.11028 14.3828 8.51622 14.486C9.56574 14.5629 10.6104 14.5558 11.1055 14.486C11.4455 14.438 12.2707 14.286 13.0475 13.4863C13.8243 12.6866 14.0185 11.3759 14.0185 10.8205V5.48894C14.0185 5.15571 13.8243 4.48927 13.0475 4.48927C12.2707 4.48927 12.0765 5.15571 12.0765 5.48894V7.82152M6.25055 9.4876V4.15605C6.25055 3.82282 6.44474 3.15638 7.22154 3.15638C7.99832 3.15638 8.19255 3.82282 8.19255 4.15605M8.19255 4.15605V7.15504M8.19255 4.15605V2.82315C8.19255 2.48993 8.38671 1.82349 9.16356 1.82349C9.94035 1.82349 10.1345 2.48993 10.1345 2.82315V4.15605M10.1345 4.15605V7.15504M10.1345 4.15605C10.1345 3.82282 10.3287 3.15638 11.1055 3.15638C11.8823 3.15638 12.0765 3.82282 12.0765 4.15605V5.82216",stroke:"currentColor",strokeWidth:"1.00395",strokeLinecap:"round",strokeLinejoin:"round"})})}function Rc({className:t,...e}){return s.jsx("svg",{fill:"none",viewBox:"0 0 18 17",xmlns:"http://www.w3.org/2000/svg",className:H(Ye.icon,t),...e,children:s.jsx("path",{d:"M7.52938 3.24873L11.5676 4.82891C13.8968 5.74032 15.0614 6.19602 15.0227 6.91887C14.9841 7.64177 13.7688 7.97321 11.338 8.63615C10.6143 8.83352 10.2524 8.93225 10.0015 9.1831C9.75056 9.43402 9.65191 9.79591 9.45447 10.5197C8.7916 12.9504 8.46009 14.1657 7.73725 14.2044C7.01438 14.243 6.55868 13.0784 5.64727 10.7493L4.06709 6.71102C3.11289 4.27249 2.63579 3.05324 3.25369 2.43533C3.8716 1.81743 5.09086 2.29453 7.52938 3.24873Z",stroke:"currentColor",strokeWidth:"1.00395",strokeLinejoin:"round"})})}function zc({className:t,...e}){return s.jsxs("svg",{fill:"none",viewBox:"0 0 18 17",xmlns:"http://www.w3.org/2000/svg",className:H(Ye.icon,t),...e,children:[s.jsx("path",{d:"M12.3464 11.5281L15.0236 14.2053",stroke:"currentColor",strokeWidth:"1.00395",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M13.6851 7.51233C13.6851 4.55519 11.2878 2.15796 8.33069 2.15796C5.37355 2.15796 2.97632 4.55519 2.97632 7.51233C2.97632 10.4695 5.37355 12.8667 8.33069 12.8667C11.2878 12.8667 13.6851 10.4695 13.6851 7.51233Z",stroke:"currentColor",strokeWidth:"1.00395",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M5.98816 7.51246H10.6732M8.3307 5.16992V9.855",stroke:"currentColor",strokeWidth:"1.00395",strokeLinecap:"round",strokeLinejoin:"round"})]})}function Mc({className:t,...e}){return s.jsxs("svg",{fill:"none",viewBox:"0 0 18 17",xmlns:"http://www.w3.org/2000/svg",className:H(Ye.icon,t),...e,children:[s.jsx("path",{d:"M12.3464 11.5281L15.0236 14.2053",stroke:"currentColor",strokeWidth:"1.00395",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M13.6851 7.51233C13.6851 4.55519 11.2878 2.15796 8.33069 2.15796C5.37355 2.15796 2.97632 4.55519 2.97632 7.51233C2.97632 10.4695 5.37355 12.8667 8.33069 12.8667C11.2878 12.8667 13.6851 10.4695 13.6851 7.51233Z",stroke:"currentColor",strokeWidth:"1.00395",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M5.98816 7.51246H10.6732",stroke:"currentColor",strokeWidth:"1.00395",strokeLinecap:"round",strokeLinejoin:"round"})]})}function Oc({className:t,...e}){return s.jsx("svg",{fill:"none",viewBox:"0 0 18 17",xmlns:"http://www.w3.org/2000/svg",className:H(Ye.icon,t),...e,children:s.jsx("path",{d:"M11.3425 14.2053C12.2766 14.2053 12.7436 14.2053 13.1236 14.09C13.9792 13.8305 14.6489 13.1609 14.9084 12.3052C15.0237 11.9252 15.0237 11.4582 15.0237 10.5242M15.0237 5.83909C15.0237 4.90505 15.0237 4.43803 14.9084 4.058C14.6489 3.20237 13.9792 2.53279 13.1236 2.27324C12.7436 2.15796 12.2766 2.15796 11.3425 2.15796M6.65745 14.2053C5.72341 14.2053 5.25639 14.2053 4.87636 14.09C4.02073 13.8305 3.35115 13.1609 3.0916 12.3052C2.97632 11.9252 2.97632 11.4582 2.97632 10.5242M2.97632 5.83909C2.97632 4.90505 2.97632 4.43803 3.0916 4.058C3.35115 3.20237 4.02073 2.53279 4.87636 2.27324C5.25639 2.15796 5.72341 2.15796 6.65745 2.15796",stroke:"currentColor",strokeWidth:"1.00395",strokeLinecap:"round",strokeLinejoin:"round"})})}function Bc({className:t,...e}){return s.jsxs("svg",{fill:"none",viewBox:"0 0 18 17",xmlns:"http://www.w3.org/2000/svg",className:H(Ye.icon,t),...e,children:[s.jsx("path",{d:"M8.99993 7.84697C9.33156 7.84697 9.63991 7.71412 10.2565 7.44841L10.7015 7.25665C11.7981 6.78414 12.3464 6.54788 12.3464 6.17373C12.3464 5.79958 11.7981 5.56332 10.7015 5.09079L10.2565 4.89905C9.63991 4.63334 9.33156 4.50049 8.99993 4.50049C8.66829 4.50049 8.35995 4.63334 7.74332 4.89905L7.29836 5.09079C6.20175 5.56332 5.65344 5.79958 5.65344 6.17373C5.65344 6.54788 6.20175 6.78414 7.29836 7.25665L7.74332 7.44841C8.35995 7.71412 8.66829 7.84697 8.99993 7.84697ZM8.99993 7.84697V11.8628",stroke:"currentColor",strokeWidth:"1.00395",strokeLinejoin:"round"}),s.jsx("path",{d:"M12.3464 6.17383V10.1896C12.3464 10.5637 11.7981 10.8 10.7015 11.2725L10.2565 11.4643C9.63991 11.73 9.33156 11.8629 8.99993 11.8629C8.66829 11.8629 8.35995 11.73 7.74332 11.4643L7.29836 11.2725C6.20175 10.8 5.65344 10.5637 5.65344 10.1896V6.17383",stroke:"currentColor",strokeWidth:"1.00395",strokeLinejoin:"round"}),s.jsx("path",{d:"M7.08858 1.82349C5.31025 1.86415 4.27153 2.03402 3.56184 2.74372C2.85214 3.45342 2.68226 4.49213 2.6416 6.27047M10.9112 1.82349C12.6896 1.86415 13.7283 2.03402 14.438 2.74372C15.1477 3.45342 15.3175 4.49213 15.3582 6.27047M10.9112 14.5401C12.6896 14.4994 13.7283 14.3296 14.438 13.6199C15.1477 12.9102 15.3175 11.8715 15.3582 10.0931M7.08858 14.5401C5.31025 14.4994 4.27153 14.3296 3.56184 13.6199C2.85214 12.9102 2.68226 11.8715 2.6416 10.0931",stroke:"currentColor",strokeWidth:"1.00395",strokeLinecap:"round",strokeLinejoin:"round"})]})}function _c({className:t,...e}){return s.jsxs("svg",{fill:"none",viewBox:"0 0 18 17",xmlns:"http://www.w3.org/2000/svg",className:H(Ye.icon,t),...e,children:[s.jsx("path",{d:"M9.66929 2.15796H8.33069C5.80661 2.15796 4.54458 2.15796 3.76045 2.94209C2.97632 3.72622 2.97632 4.98825 2.97632 7.51233V8.85093C2.97632 11.375 2.97632 12.6371 3.76045 13.4212C4.54458 14.2053 5.80661 14.2053 8.33069 14.2053H9.66929C12.1933 14.2053 13.4554 14.2053 14.2395 13.4212C15.0237 12.6371 15.0237 11.375 15.0237 8.85093V7.51233C15.0237 4.98825 15.0237 3.72622 14.2395 2.94209C13.4554 2.15796 12.1933 2.15796 9.66929 2.15796Z",stroke:"currentColor",strokeWidth:"1.00395",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M6.99207 2.15796V14.2053",stroke:"currentColor",strokeWidth:"1.00395",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M11.0078 2.15796V14.2053",stroke:"currentColor",strokeWidth:"1.00395",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M15.0236 6.17383H2.97632",stroke:"currentColor",strokeWidth:"1.00395",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M15.0236 10.1897H2.97632",stroke:"currentColor",strokeWidth:"1.00395",strokeLinecap:"round",strokeLinejoin:"round"})]})}function Pc({className:t,...e}){return s.jsxs("svg",{fill:"none",viewBox:"0 0 18 17",xmlns:"http://www.w3.org/2000/svg",className:H(Ye.icon,t),...e,children:[s.jsx("rect",{x:"1.5",y:"6.5",width:"4",height:"4",rx:"0.75",stroke:"currentColor",strokeWidth:"1.00395"}),s.jsx("rect",{x:"12.5",y:"2.5",width:"4",height:"3",rx:"0.75",stroke:"currentColor",strokeWidth:"1.00395"}),s.jsx("rect",{x:"12.5",y:"11.5",width:"4",height:"3",rx:"0.75",stroke:"currentColor",strokeWidth:"1.00395"}),s.jsx("path",{d:"M5.5 8.5H9.5",stroke:"currentColor",strokeWidth:"1.00395",strokeLinecap:"round"}),s.jsx("path",{d:"M9.5 4H9.5V13",stroke:"currentColor",strokeWidth:"1.00395",strokeLinecap:"round"}),s.jsx("path",{d:"M9.5 4H12.5",stroke:"currentColor",strokeWidth:"1.00395",strokeLinecap:"round"}),s.jsx("path",{d:"M9.5 13H12.5",stroke:"currentColor",strokeWidth:"1.00395",strokeLinecap:"round"})]})}function Hc({className:t,...e}){return s.jsxs("svg",{fill:"none",viewBox:"0 0 18 17",xmlns:"http://www.w3.org/2000/svg",className:H(Ye.icon,t),...e,children:[s.jsx("rect",{x:"7",y:"1",width:"4",height:"3.5",rx:"0.75",stroke:"currentColor",strokeWidth:"1.00395"}),s.jsx("rect",{x:"2",y:"12.5",width:"4",height:"3",rx:"0.75",stroke:"currentColor",strokeWidth:"1.00395"}),s.jsx("rect",{x:"12",y:"12.5",width:"4",height:"3",rx:"0.75",stroke:"currentColor",strokeWidth:"1.00395"}),s.jsx("path",{d:"M9 4.5V8.5",stroke:"currentColor",strokeWidth:"1.00395",strokeLinecap:"round"}),s.jsx("path",{d:"M4 8.5H14",stroke:"currentColor",strokeWidth:"1.00395",strokeLinecap:"round"}),s.jsx("path",{d:"M4 8.5V12.5",stroke:"currentColor",strokeWidth:"1.00395",strokeLinecap:"round"}),s.jsx("path",{d:"M14 8.5V12.5",stroke:"currentColor",strokeWidth:"1.00395",strokeLinecap:"round"})]})}function $c({className:t,...e}){return s.jsxs("svg",{fill:"none",viewBox:"1.5 1.5 21 21",xmlns:"http://www.w3.org/2000/svg",className:H(Ye.icon,t),...e,children:[s.jsx("circle",{cx:"7",cy:"5",r:"2",stroke:"currentColor",strokeWidth:"1.17"}),s.jsx("circle",{cx:"17",cy:"5",r:"2",stroke:"currentColor",strokeWidth:"1.17"}),s.jsx("circle",{cx:"7",cy:"19",r:"2",stroke:"currentColor",strokeWidth:"1.17"}),s.jsx("circle",{cx:"17",cy:"19",r:"2",stroke:"currentColor",strokeWidth:"1.17"}),s.jsx("path",{d:"M7 7C7 12 17 12 17 17",stroke:"currentColor",strokeWidth:"1.17",strokeLinecap:"round"}),s.jsx("path",{d:"M17 7C17 12 7 12 7 17",pathLength:"100",strokeDasharray:"30 40 30",stroke:"currentColor",strokeWidth:"1.17",strokeLinecap:"round"})]})}const Wc=160,Gc=60,Xt=40,Yt=60,Pn=40,qc=200,Uc=120,Vc=150,Kc=90,Hn=80,Xc={cloud:{width:150,height:150},image:{width:150,height:150},gif:{width:150,height:150},databaseTableSQL:{width:500,height:400},table:{width:600,height:400},code:{width:300,height:400},builder:{width:300,height:200}};function pt(t){const e=t.type?Xc[t.type]:void 0,n=Math.max((typeof t.width=="number"&&isFinite(t.width)?t.width:void 0)??(typeof t.style?.width=="number"?t.style.width:void 0)??t.measured?.width??e?.width??Wc,40),i=Math.max((typeof t.height=="number"&&isFinite(t.height)?t.height:void 0)??(typeof t.style?.height=="number"?t.style.height:void 0)??t.measured?.height??e?.height??Gc,20);return{width:n,height:i}}function $n(t){const{width:e,height:n}=pt(t);return{left:t.position.x,top:t.position.y,right:t.position.x+e,bottom:t.position.y+n}}function Yc(t){const e=t.filter(i=>is(i)&&!i.parentId);if(e.length===0)return t;const n=[...t];for(let i=0;i<n.length;i++){const r=n[i];if(is(r)||r.parentId)continue;const a=$n(r),o=e.filter(l=>{const u=$n(l);return a.left>=u.left&&a.right<=u.right&&a.top>=u.top&&a.bottom<=u.bottom}).sort((l,u)=>{const m=pt(l),d=pt(u);return m.width*m.height-d.width*d.height})[0];if(!o)continue;n[i]={...r,parentId:o.id,position:{x:r.position.x-o.position.x,y:r.position.y-o.position.y}};const c=n.findIndex(l=>l.id===o.id);if(c>=0){const l=Array.isArray(n[c].data?.childNodes)?n[c].data.childNodes:[];l.includes(r.id)||(n[c]={...n[c],data:{...n[c].data,childNodes:[...l,r.id]}})}}return n}function Qc(t,e,n,i){if(e.length===0){const{width:g,height:v}=pt(t);return{children:[],groupWidth:g,groupHeight:v}}if(e.length===1){const{width:g,height:v}=pt(e[0]);return{children:[{...e[0],position:{x:Xt,y:Yt}}],groupWidth:g+Xt*2,groupHeight:v+Yt+Pn}}const r=new ls.graphlib.Graph;r.setDefaultEdgeLabel(()=>({})),r.setGraph({rankdir:i,ranksep:Vc,nodesep:Kc});for(const g of e){const{width:v,height:b}=pt(g);r.setNode(g.id,{width:v,height:b})}const a=new Set(e.map(g=>g.id));for(const g of n)a.has(g.source)&&a.has(g.target)&&r.setEdge(g.source,g.target);ls.layout(r);let o=1/0,c=1/0,l=-1/0,u=-1/0;const m={};for(const g of e){const{x:v,y:b,width:p,height:w}=r.node(g.id),S=v-p/2,I=b-w/2;m[g.id]={x:S,y:I},o=Math.min(o,S),c=Math.min(c,I),l=Math.max(l,S+p),u=Math.max(u,I+w)}const d=Xt-o,h=Yt-c,x=e.map(g=>({...g,position:{x:m[g.id].x+d,y:m[g.id].y+h}})),N=l-o+Xt*2,f=u-c+Yt+Pn;return{children:x,groupWidth:N,groupHeight:f}}function Zc(t,e){const n=new Map;for(const a of t)n.set(a.id,new Set);for(const a of e)n.has(a.source)&&n.has(a.target)&&(n.get(a.source).add(a.target),n.get(a.target).add(a.source));const i=new Set,r=[];for(const a of t){if(i.has(a.id))continue;const o=[],c=[a.id];for(;c.length>0;){const l=c.shift();if(i.has(l))continue;i.add(l);const u=t.find(m=>m.id===l);u&&o.push(u);for(const m of n.get(l)??[])i.has(m)||c.push(m)}r.push(o)}return r}function Jc(t,e,n){const i=new ls.graphlib.Graph;i.setDefaultEdgeLabel(()=>({})),i.setGraph({rankdir:n,ranksep:qc,nodesep:Uc});for(const u of t){const{width:m,height:d}=pt(u);i.setNode(u.id,{width:m,height:d})}for(const u of e)i.setEdge(u.source,u.target);ls.layout(i);let r=1/0,a=1/0,o=-1/0,c=-1/0;return{nodes:t.map(u=>{const{x:m,y:d,width:h,height:x}=i.node(u.id),N=m-h/2,f=d-x/2;return r=Math.min(r,N),a=Math.min(a,f),o=Math.max(o,N+h),c=Math.max(c,f+x),{...u,position:{x:N,y:f}}}),left:r,top:a,width:o-r,height:c-a}}function ed(t){if(t.length===0)return[];if(t.length===1){const{nodes:l,left:u,top:m}=t[0];return l.map(d=>({...d,position:{x:d.position.x-u,y:d.position.y-m}}))}const e=t.reduce((l,u)=>l+u.width*u.height,0),n=Math.sqrt(e)*1.5,i=[...t].sort((l,u)=>u.height-l.height),r=[];let a=0,o=0,c=0;for(const l of i){a>0&&a+l.width>n&&(a=0,o+=c+Hn,c=0);const u=a-l.left,m=o-l.top;for(const d of l.nodes)r.push({...d,position:{x:d.position.x+u,y:d.position.y+m}});a+=l.width+Hn,c=Math.max(c,l.height)}return r}function Xs(t,e,n="LR"){const i=Yc(t),r=i.filter(g=>!g.parentId),a=i.filter(g=>!!g.parentId),o=new Map;for(const g of a){const v=g.parentId;o.has(v)||o.set(v,[]),o.get(v).push(g)}const c=new Map,l=r.map(g=>{if(!is(g))return g;const v=o.get(g.id)??[];if(v.length===0)return g;const b=new Set(v.map(C=>C.id)),p=e.filter(C=>b.has(C.source)&&b.has(C.target)),{children:w,groupWidth:S,groupHeight:I}=Qc(g,v,p,n);return c.set(g.id,w),{...g,style:{...g.style,width:S,height:I}}}),u=a.map(g=>c.get(g.parentId)?.find(b=>b.id===g.id)??g),m=new Map;for(const g of u)g.parentId&&m.set(g.id,g.parentId);const d=new Set(l.map(g=>g.id)),h=[];for(const g of e){const v=d.has(g.source)?g.source:m.get(g.source),b=d.has(g.target)?g.target:m.get(g.target);v&&b&&v!==b&&h.push({source:v,target:b})}const N=Zc(l,h).map(g=>{const v=new Set(g.map(p=>p.id)),b=h.filter(p=>v.has(p.source)&&v.has(p.target));return Jc(g,b,n)});return[...ed(N),...u]}function td(t,e,n){const r=Xs(t,e,n).map(o=>is(o)&&o.data?.autoLayout?{...o,data:{...o.data,autoLayout:!1}}:o),a=hr(r,e);return{nodes:r,edges:a}}function sd(t,e,n="LR"){return t.some(r=>r.type==="sequenceParticipant")?Ue(t,e):td(t,e,n)}const Ts=60,nd="#0b0e16";function id(t){const e=gr(t),n=e.width+Ts,i=e.height+Ts,r=Ho(e,n,i,1,1,Ts);return{x:r.x,y:r.y,zoom:r.zoom,width:n,height:i}}async function rd(t){const e=id(t),n=document.documentElement.querySelector(".react-flow__viewport");if(!n)throw new Error("Failed to download diagram");n.classList.add("downloading");const i=await Wo(n,{width:e.width,height:e.height,backgroundColor:nd,style:{transform:`translate(${e.x}px, ${e.y}px) scale(${e.zoom})`},filter(r){return!r?.classList?.contains?.("react-flow__handle")}});return n.classList.remove("downloading"),i}function ad(t){return t.replace(/[<>:"/\\|?*]/g,"").trim().substring(0,200)||"diagram"}async function od(t,e){const i=(await rd(t)).toDataURL("image/webp"),r=e?`${ad(e)}.webp`:"diagram.webp",a=document.createElement("a");a.setAttribute("download",r),a.setAttribute("href",i),a.target="_blank",a.click(),URL.revokeObjectURL(i)}const Ui="pointer-events-auto flex items-center gap-2 rounded-[0.75rem] border border-[#2A3242] bg-[#141925] p-1 shadow-sm";function ld(){const[t,e]=y.useState(!1),[n,i]=y.useState(!1),r=ea(),{nodes:a,edges:o,setNodes:c,setEdges:l,selectedFrame:u,reactFlowInstance:m,cursorMode:d,setCursorMode:h,showGrid:x,setShowGrid:N,drawingMode:f,setDrawingMode:g,isPreviewing:v,isFullscreen:b,setIsFullscreen:p,isEmbedded:w,diagramName:S}=we(),I=Ri(a),C=!w&&b;async function A(){e(!0);try{await od(a,S),U.success("Diagram exported successfully")}catch{U.error("Failed to export diagram image")}finally{e(!1)}}async function M(){try{const R=await kc();c(R.nodes),l(R.edges)}catch(R){U.error(R instanceof Error?R.message:"Failed to import Mermaid diagram")}}function T(){try{Tc(a,o,S),U.success("Diagram exported successfully")}catch{U.error("Failed to export the diagram")}}return s.jsxs("div",{className:"group/top-controls pointer-events-none absolute inset-0",children:[C&&s.jsx("div",{className:"pointer-events-auto absolute inset-x-0 top-0 h-10",children:s.jsx("div",{className:"pointer-events-none absolute top-0 left-1/2 flex h-5 w-14 -translate-x-1/2 items-center justify-center rounded-b-[0.375rem] border border-t-0 border-[#2A3242] bg-[#141925] transition-opacity duration-200 group-hover/top-controls:opacity-0",children:s.jsx(rn,{className:"size-3.5 text-[#828DA3]"})})}),s.jsx("div",{className:H("absolute inset-x-0 top-3 flex items-center justify-center",C&&"-translate-y-[calc(100%_+_0.75rem)] transition-transform duration-200 group-hover/top-controls:translate-y-0",C&&n&&"translate-y-0"),children:s.jsxs("div",{className:Ui,children:[s.jsxs(Ie,{delayDuration:100,tooltipPosition:"top",tooltip:d==="pan"?"Hand tool (switch to select)":"Select tool (switch to pan)",isActive:d==="pan",onClick:()=>h(d==="pan"?"select":"pan"),children:[d==="pan"&&s.jsx(Dc,{}),d==="select"&&s.jsx(Rc,{})]}),s.jsx(gt,{}),s.jsx(Ie,{onClick:()=>m&&hn(m,1/gn),delayDuration:100,tooltipPosition:"top",tooltip:"Zoom out",children:s.jsx(Mc,{})}),s.jsx(Ie,{onClick:()=>m&&hn(m,gn),delayDuration:100,tooltipPosition:"top",tooltip:"Zoom in",children:s.jsx(zc,{})}),s.jsx(gt,{}),s.jsx(Ie,{delayDuration:100,tooltipPosition:"top",tooltip:u?"Ungroup nodes":"Group nodes",disabled:v,isActive:f||!!u,onClick:()=>{if(u){const R=new Set(u.data?.childNodes??[]),k=u.parentId;c(O=>O.filter(F=>F.id!==u.id).map(F=>{if(R.has(F.id))return{...F,selected:!1,parentId:k,position:{x:F.position.x+u.position.x,y:F.position.y+u.position.y}};if(k&&F.id===k){const G=F.data?.childNodes??[];return{...F,data:{...F.data,childNodes:[...G.filter(ae=>ae!==u.id&&!R.has(ae)),...R]}}}return F}))}else g(R=>!R)},children:s.jsx(Bc,{})}),s.jsx(Ie,{delayDuration:100,tooltipPosition:"top",tooltip:x?"Hide grid":"Show grid",isActive:x,onClick:()=>N(R=>!R),children:s.jsx(_c,{})}),!w&&s.jsx(Ie,{delayDuration:100,tooltipPosition:"top",tooltip:b?"Exit fullscreen":"Fullscreen",isActive:b,onClick:()=>p(R=>!R),children:s.jsx(Oc,{})}),s.jsx(gt,{}),s.jsx(Ie,{delayDuration:100,tooltipPosition:"top",tooltip:I?"Auto layout is unavailable for sequence diagrams":"Auto layout left-to-right",disabled:v||I,onClick:()=>{if(I)return;const R=Xs(a,o,"LR");c(R),setTimeout(()=>m?.fitView({padding:.2}),50)},children:s.jsx(Pc,{})}),s.jsx(Ie,{delayDuration:100,tooltipPosition:"top",tooltip:I?"Auto layout is unavailable for sequence diagrams":"Auto layout top-to-bottom",disabled:v||I,onClick:()=>{if(I)return;const R=Xs(a,o,"TB");c(R),setTimeout(()=>m?.fitView({padding:.2}),50)},children:s.jsx(Hc,{})}),s.jsx(Ie,{delayDuration:100,tooltipPosition:"top",tooltip:"Auto Layout",disabled:v||!r||a.length===0,onClick:()=>{if(!r){U.info("Diagram is still rendering — try again in a moment");return}const{nodes:R,edges:k}=sd(a,o,"LR");c(R),l(k),setTimeout(()=>m?.fitView({padding:.2}),50)},children:s.jsx($c,{})}),s.jsx(gt,{}),s.jsxs(Ot,{open:n,onOpenChange:i,children:[s.jsx(Bt,{asChild:!0,children:s.jsx(Ie,{delayDuration:100,tooltipPosition:"top",tooltip:"Mermaid Diagram",children:s.jsx(_o,{className:"text-base"})})}),s.jsxs(_t,{align:"center",className:"border border-[#2A3242] bg-[#141925] text-[#F4F7FC]",children:[s.jsxs(Me,{onClick:()=>void M(),disabled:v,children:[s.jsx(yn,{className:"size-4"}),"Import Mermaid"]}),s.jsxs(Me,{onClick:T,children:[s.jsx(yn,{className:"size-4 rotate-180"}),"Export To Mermaid"]})]})]}),s.jsx(Ie,{delayDuration:100,tooltipPosition:"top",tooltip:"Export Image",onClick:A,disabled:t,children:t?s.jsx(os,{className:"text-sm"}):s.jsx(Oo,{className:"mb-0.5 text-[1.2rem]"})})]})})]})}function Ie({tooltipPosition:t,className:e,isActive:n,disabled:i,tooltip:r,delayDuration:a,...o}){return s.jsxs(et,{delayDuration:a??500,disableHoverableContent:!0,open:r?void 0:!1,children:[s.jsx(tt,{asChild:!0,children:s.jsx("button",{className:H("flex size-10 items-center justify-center rounded-[0.5rem] border border-[#2A3242] bg-transparent text-[1.0625rem] text-[#F4F7FC] transition-all",!i&&[n&&"border-primary/30 bg-primary/10 text-primary",!n&&"hover:bg-[#1E2533]"],i&&"cursor-not-allowed opacity-50",e),...o})}),s.jsx(st,{side:t,children:r})]})}function gt(){return s.jsx("div",{className:"h-[1.625rem] w-[1px] bg-[#2A3242]"})}function Vi(t){return{componentFieldId:"name",type:X.TextInput,label:"Name",data:[{value:t}]}}function Ki(t){const e=[...t].filter(r=>r.type==="sequenceParticipant").sort((r,a)=>r.position.x-a.position.x),n=e.length>=2?Math.abs(e[1].position.x-e[0].position.x)||Nt.columnWidth:Nt.columnWidth;return{x:e.length>0?Math.max(...e.map(r=>r.position.x))+n:0,columnWidth:n}}function Es(t,e){const{x:n}=Ki(t);return{id:`participant-${W()}`,type:"sequenceParticipant",position:{x:n,y:0},data:{componentFields:[Vi(e)]}}}function cd(t,e,n,i,r){const a=new Map(t.filter(b=>b.type==="sequenceParticipant").map(b=>[b.id,b])),o=a.get(n),c=a.get(i);if(!o||!c)return{nodes:t,edges:e};const l=n===i,u=pr(t,e),m=o.position.x<c.position.x,d=m||l?"right":"left",h=l?"right":m?"left":"right",x=`message-${W()}`,N=!t.some(b=>b.id.startsWith("message-")),f={id:x,type:"shape",position:{x:0,y:fr(u,Nt)-Nt.messageNodeHeight/2},data:{shape:"rectangle",fill:"#f8fafc",stroke:"#CCCCCC",strokeWidth:1,componentFields:[Vi(r)],...N?{sequenceNumber:1}:{}},style:{width:Nt.messageNodeWidth,height:Nt.messageNodeHeight}},g={id:W(),source:n,target:x,sourceHandle:pn(u,d,"source"),targetHandle:l?"target-top":d==="right"?"target-left":"target-right",type:"smoothstep"},v={id:W(),source:x,target:i,sourceHandle:l?"source-bottom":m?"source-right":"source-left",targetHandle:pn(u+(l?1:0),h,"target"),type:"smoothstep",markerEnd:Os({type:Gs.ArrowClosed})};return Ue([...t,f],[...e,g,v])}function dd(t,e,n,i,r){const a=new Set(t.filter(u=>u.type==="sequenceParticipant").map(u=>u.id));if(!t.some(u=>u.id===n)||!a.has(i)||!a.has(r))return{nodes:t,edges:e};let o=!1,c=!1;const l=e.map(u=>u.target===n&&a.has(u.source)?(o=!0,{...u,source:i}):u.source===n&&a.has(u.target)?(c=!0,{...u,target:r}):u);return!o||!c?{nodes:t,edges:e}:Ue(t,Xi(t,l))}function Xi(t,e){const n=new Map(t.filter(r=>r.type==="sequenceParticipant").map(r=>[r.id,r])),i=new Map;for(const r of e)n.has(r.source)&&r.target.startsWith("message-")&&i.set(r.target,{...i.get(r.target),from:r.source}),r.source.startsWith("message-")&&n.has(r.target)&&i.set(r.source,{...i.get(r.source),to:r.target});return e.map(r=>{const a=i.get(r.source),o=i.get(r.target),c=a??o;if(!c?.from||!c.to)return r;const l=n.get(c.from),u=n.get(c.to);if(!l||!u)return r;const m=c.from===c.to,d=l.position.x<u.position.x,h=d||m?"right":"left",x=m?"right":d?"left":"right";return a?{...r,sourceHandle:m?"source-bottom":d?"source-right":"source-left",targetHandle:r.targetHandle?.replace(/^row-(\d+)-(left|right)-/,`row-$1-${x}-`)}:{...r,sourceHandle:r.sourceHandle?.replace(/^row-(\d+)-(left|right)-/,`row-$1-${h}-`),targetHandle:m?"target-top":h==="right"?"target-left":"target-right"}})}const Qt=60;function Wn(t,e){if(!e.some(a=>a.type==="sequenceParticipant"||a.id.startsWith("message-")))return;const{nodes:i,edges:r}=Ue(t.getNodes(),t.getEdges());t.setNodes(i),t.setEdges(r)}function ud(){const[t,e]=y.useState(null),{selectedEdgeIds:n,selectedNodeIds:i,setSelectedEdgeIds:r,setSelectedNodeIds:a,reactFlowInstance:o}=we();async function c(){const f=o;if(!f)return;const g=i.map(v=>f.getNode(v)).filter(Boolean);await f.deleteElements({edges:n.map(v=>f.getEdge(v)).filter(Boolean),nodes:g}),Wn(f,g)}function l(f){const g=i.map(w=>f.getNode(w)).filter(Boolean),v=n.map(w=>f.getEdge(w)).filter(Boolean);return f.getNodes().forEach(w=>{w.parentId&&!g.some(S=>S.id===w.id)&&g.some(S=>S.id===w.parentId)&&(console.log("adding node",w),g.push(w))}),f.getEdges().forEach(w=>{!v.some(S=>S.id===w.id)&&g.some(S=>S.id===w.source)&&g.some(S=>S.id===w.target)&&(console.log("adding edge",w),v.push(w))}),{targetNodes:g,targetEdges:v}}function u(f){const g=o;g&&(e({mode:f,...l(g)}),a([]),r([]))}async function m(f=t){const g=o;if(!g||!f)return;const{targetNodes:v,targetEdges:b}=f;if(!v.length)return;const p=new Map,w=new Set(v.map(k=>k.id));v.forEach(k=>{const O=k.type==="sequenceParticipant"?"participant-":k.id.startsWith("message-")?"message-":"";p.set(k.id,`${O}${W()}`)});const{x:S,columnWidth:I}=Ki(g.getNodes());let C=S;const A=v.map(k=>{const O=p.get(k.id),F=Array.isArray(k.data?.childNodes)?k.data.childNodes.map(ae=>p.get(ae)??ae):k.data?.childNodes;let G=k.parentId&&w.has(k.parentId)?k.position:{x:k.position.x+Qt,y:k.position.y+Qt};return k.type==="sequenceParticipant"&&(G={x:C,y:0},C+=I),{...k,id:O,childNodes:void 0,data:{...k.data,childNodes:F},position:G}}),M=b.map(k=>{const O=p.get(k.source)||k.source,F=p.get(k.target)||k.target;return{...k,source:O,target:F,data:{...k.data},id:W()}});A.forEach(k=>{if(k.parentId){const O=p.get(k.parentId)||k.parentId;k.parentId=O}});const T=g.getViewport();if(await g.setViewport({...T,x:T.x-Qt*T.zoom,y:T.y-Qt*T.zoom},{duration:100}),A.some(k=>k.type==="sequenceParticipant"||k.id.startsWith("message-"))){const k=new Set(A.map(Y=>Y.id)),O=new Set(M.map(Y=>Y.id)),F=g.getNodes().map(Y=>({...Y,selected:!1})),G=g.getEdges().map(Y=>({...Y,selected:!1})),{nodes:ae,edges:me}=Ue([...F,...A],[...G,...M]);g.setNodes(ae.map(Y=>k.has(Y.id)?{...Y,selected:!0}:Y)),g.setEdges(me.map(Y=>O.has(Y.id)?{...Y,selected:!0}:Y))}else g.setNodes(k=>[...k.map(O=>({...O,selected:!1})),...A.map(O=>({...O,selected:!0}))]),g.setEdges(k=>[...k.map(O=>({...O,selected:!1})),...M.map(O=>({...O,selected:!0}))]);f.mode==="copy"&&e({mode:"copy",targetNodes:A,targetEdges:M}),f.mode==="cut"&&(await g.deleteElements({edges:b,nodes:v}),Wn(g,v),e(null))}async function d(){const f=o;f&&await m({mode:"copy",...l(f)})}const h=i.length>0||n.length>0,x=!!t,N=Qs({handleDelete:c,handleDuplicate:d,handleCopy:u,handlePaste:m});return y.useEffect(()=>{if(!h&&!x)return;async function f(g){const{handleDelete:v,handleDuplicate:b,handleCopy:p,handlePaste:w}=N.current,S=g.target;S.tagName==="INPUT"||S.tagName==="TEXTAREA"||S.isContentEditable||((g.key==="Delete"||g.key==="Backspace"&&h)&&await v(),(g.ctrlKey||g.metaKey)&&(g.key==="d"&&h?(g.preventDefault(),b().catch(console.error)):g.key==="c"&&h?(g.preventDefault(),p("copy")):g.key==="v"&&x&&(g.preventDefault(),w().catch(console.error))))}return window.addEventListener("keydown",f),()=>{window.removeEventListener("keydown",f)}},[h,x,N]),s.jsx(it,{children:(h||t)&&s.jsx(ze.div,{initial:{opacity:0,y:16,scale:.75},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:16,scale:.75},transition:{duration:.1,ease:"easeOut"},className:"pointer-events-none absolute inset-x-0 bottom-3 flex items-center justify-center",children:s.jsxs("div",{className:Ui,children:[h&&s.jsxs(s.Fragment,{children:[s.jsx(Ie,{tooltip:"Zoom to Selection",tooltipPosition:"bottom",onClick:()=>o&&oi(o,i),children:s.jsx(jl,{size:18})}),s.jsx(gt,{}),s.jsx(Ie,{tooltip:"Cut Selection",tooltipPosition:"bottom",onClick:()=>u("cut"),children:s.jsx(Nl,{size:18})}),s.jsx(Ie,{tooltip:"Copy Selection",tooltipPosition:"bottom",onClick:()=>u("copy"),children:s.jsx(Go,{size:18})})]}),!!t&&s.jsxs(s.Fragment,{children:[h&&s.jsx(gt,{}),s.jsx(Ie,{tooltip:"Paste",tooltipPosition:"bottom",onClick:()=>m(),children:s.jsx(al,{size:18})})]}),h&&s.jsxs(s.Fragment,{children:[s.jsx(gt,{}),s.jsx(Ie,{tooltip:"Duplicate Selection",tooltipPosition:"bottom",onClick:()=>d(),children:s.jsx(ul,{size:18})}),s.jsx(Ie,{tooltip:"Delete Selection",tooltipPosition:"bottom",className:"hover:text-destructive",onClick:c,children:s.jsx(It,{size:18})})]})]})})})}function md(){const{nodes:t,viewport:e,reactFlowInstance:n}=we(),i=e?.zoom??xr;return t.length===0||i>br?null:s.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-3 flex items-center justify-center",children:s.jsxs(Ie,{className:"pointer-events-auto w-auto gap-2 rounded-[0.75rem] bg-[#141925] px-3 text-sm shadow-sm",onClick:()=>n&&yr(n),children:[s.jsx(Ia,{className:"size-4"}),"Focus on content"]})})}function hd(){const[t,e]=y.useState(!1),[n,i]=y.useState(!1),{isEmbedded:r,isFullscreen:a,sidebarActiveTool:o,diagramName:c,setDiagramName:l}=we();return r||!a?null:s.jsxs("div",{className:H("pointer-events-auto absolute top-4 left-[1.1875rem] flex items-center","-translate-x-[calc(100%_+_1.1875rem)] transition-transform duration-200 group-hover/left-controls:translate-x-0",(n||o)&&"translate-x-0"),onMouseEnter:()=>e(!0),onMouseLeave:()=>e(!1),children:[s.jsx(ss,{to:"/dashboard",className:"rounded-full",children:s.jsx(Hs,{className:"size-11 max-w-none"})}),s.jsx(it,{initial:!1,children:(t||n)&&s.jsx(ze.div,{initial:{width:0,opacity:0},animate:{width:"auto",opacity:1},exit:{width:0,opacity:0},transition:{duration:.2,ease:"easeOut"},className:"-m-1 overflow-hidden p-1",children:s.jsx("div",{className:"ml-4",children:s.jsx(Fe,{value:c,placeholder:"Enter diagram name",onChange:u=>l(u.target.value),onFocus:()=>i(!0),onBlur:()=>i(!1),className:"placeholder:text-foreground/20 h-auto rounded-[0.5rem] px-2.5 py-1.5 !text-[1.1rem] font-medium shadow-none placeholder:text-lg placeholder:font-medium"})})})})]})}function gd(t){return Li({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M15 2c-2.71 0-5.05 1.54-6.22 3.78a7.06 7.06 0 0 0-3 3A7.01 7.01 0 0 0 2 15c0 3.87 3.13 7 7 7 2.71 0 5.05-1.54 6.22-3.78a7.06 7.06 0 0 0 3-3A7.01 7.01 0 0 0 22 9c0-3.87-3.13-7-7-7M9 20a5.002 5.002 0 0 1-4-8c0 3.87 3.13 7 7 7-.84.63-1.88 1-3 1m3-3a5.002 5.002 0 0 1-4-8c0 3.86 3.13 6.99 7 7-.84.63-1.88 1-3 1m4.7-3.3c-.53.19-1.1.3-1.7.3-2.76 0-5-2.24-5-5 0-.6.11-1.17.3-1.7.53-.19 1.1-.3 1.7-.3 2.76 0 5 2.24 5 5 0 .6-.11 1.17-.3 1.7M19 12c0-3.86-3.13-6.99-7-7a5.002 5.002 0 0 1 7 7"},child:[]},{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0zm0 0h24v24H0z"},child:[]}]})(t)}const pd=[...qo];function Xe({children:t,className:e,...n}){const i=y.useRef(null),r=y.useRef(null),[a,o]=y.useState(),[c,l]=y.useState();return y.useEffect(()=>{const u=i.current;if(!u)return;const m=r.current;if(!m)return;const d=new ResizeObserver(()=>{l(m.clientHeight),o(u.clientHeight)});return l(m.clientHeight),o(u.clientHeight),d.observe(m),d.observe(u),()=>d.disconnect()},[i,r]),s.jsx("div",{ref:r,className:H("pointer-events-none absolute inset-4 right-auto select-none",e),...n,children:s.jsx(Ei,{className:"rounded-[0.75rem] border border-[#2A3242] bg-[#141925]",style:{height:Math.min(a??0,c??0)+2},children:s.jsx("div",{ref:i,className:"pointer-events-auto",children:t})})})}const Ys="flex aspect-square w-full cursor-grab items-center justify-center rounded-[0.5rem] border border-[#2A3242] bg-[#1E2533] p-2 text-[#F4F7FC] transition-all select-none hover:bg-[#232b3a] active:cursor-grabbing [&>svg]:h-full [&>svg]:w-full [&>svg]:object-contain [&_path]:!stroke-[#CBD5E1] [&_rect]:!stroke-[#CBD5E1] [&_circle]:!stroke-[#CBD5E1] [&_polygon]:!stroke-[#CBD5E1] [&_line]:!stroke-[#CBD5E1] [&_ellipse]:!stroke-[#CBD5E1]",$t="group flex h-8 w-full items-center justify-between rounded-md px-2 text-xs font-medium text-[#F4F7FC] transition-colors hover:bg-[#1E2533]",fd="group flex h-8 w-full items-center justify-between rounded-md px-3 text-xs font-medium text-[#F4F7FC] transition-colors hover:bg-[#1E2533]",Yi="flex cursor-grab items-center gap-2 rounded-[0.5rem] bg-transparent p-2 text-[#F4F7FC] transition-all select-none hover:bg-[#1E2533] active:cursor-grabbing",xd="ml-2 flex flex-col gap-1.5 border-l border-[#2A3242] pl-1",bd="group flex h-11 w-full cursor-grab items-center gap-3 rounded-lg border border-[#2A3242] bg-[#1E2533] px-3 py-2 transition-all hover:border-primary/30 hover:bg-[#232b3a] active:scale-[0.98] active:cursor-grabbing",yd="h-10 border-[#2A3242] bg-transparent pl-10 text-sm text-[#F4F7FC] placeholder:text-[#828DA3] focus:border-primary focus:ring-primary";function vd(){return s.jsx(Xe,{className:"left-18",children:s.jsx("div",{className:"flex w-[10.5rem] flex-col gap-1.5 p-1 py-2",children:pd.map((t,e)=>{const n=`/${t.relativePath}`;return s.jsxs("div",{draggable:!0,className:Yi,onDragStart:i=>{Ke(i,"gif",{src:n,componentFields:[{componentFieldId:"name",type:X.TextInput,label:"Name",isReadonly:!0,data:[{value:t.name}]},{componentFieldId:"description",type:X.TextInput,label:"Description",data:[{value:t.category}]}]},{width:100})},children:[s.jsx("img",{src:n,alt:t.name,className:"h-8 w-8 flex-shrink-0 rounded-md"}),s.jsx("span",{className:"truncate text-sm",children:t.name})]},e)})})})}function jd(){const{sidebarActiveTool:t,setSidebarActiveTool:e}=we(),{getNode:n,setCenter:i,setNodes:r}=bi(),a=t==="add-comment";function o(D){const q=n(D);if(!q)return;const j=q.measured?.width??q.width??0,z=q.measured?.height??q.height??0;i(q.position.x+j/2,q.position.y+z/2,{zoom:1.5,duration:600}),r(_=>_.map(Z=>({...Z,selected:Z.id===D})))}const c=Js()?.id,l=xi(D=>D.user),u=l?{userId:l.userId,name:l.name,avatarUrl:l.avatarUrl??void 0}:null,d=ta().filter(D=>D.type==="comment").map(D=>D.id),h=d.join(","),[x,N]=y.useState({}),f=y.useCallback((D,q)=>{N(j=>({...j,[D]:q}))},[]),g=y.useMemo(()=>h.split(",").filter(Boolean).flatMap(D=>x[D]??[]).sort((D,q)=>new Date(D.createdAt).getTime()-new Date(q.createdAt).getTime()),[h,x]),v=y.useMemo(()=>{const D={};return h.split(",").filter(Boolean).forEach(q=>{(x[q]??[]).forEach(j=>{D[j.commentId]=q})}),D},[h,x]),[b]=zt(vr),[p]=zt(jr),[w]=zt(wr);function S(D){return{awaitRefetchQueries:!0,refetchQueries:[{query:ci,variables:{orgId:c,resourceId:D}}]}}const[I,C]=y.useState(""),[A,M]=y.useState(null),[T,R]=y.useState(!1),[k,O]=y.useState(null),[F,G]=y.useState(""),[ae,me]=y.useState(null),[Y,Ne]=y.useState(null),[ke,ye]=y.useState(null),L=d[d.length-1];async function $(){const D=I.trim();if(!D||T||!u?.userId||!c)return;const q=A?v[A.commentId]:L;if(q){R(!0);try{await b({variables:{orgId:c,input:{resourceId:q,text:D,...A?{parentCommentId:A.commentId}:{}}},...S(q)}),C(""),M(null)}finally{R(!1)}}}async function te(){const D=F.trim();if(!k||!D||ae||!c)return;const q=v[k];if(q){me(k);try{await p({variables:{orgId:c,id:k,input:{text:D}},...S(q)}),O(null),G("")}finally{me(null)}}}async function P(D){if(Y||!c)return;const q=v[D];if(q){Ne(D);try{await w({variables:{orgId:c,id:D},...S(q)})}finally{Ne(null)}}}return s.jsxs(Xe,{className:"left-18",children:[d.map(D=>s.jsx(wd,{orgId:c,resourceId:D,onLoaded:f},D)),s.jsxs("div",{className:"flex w-80 flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between border-b border-[#2A3242] px-3 py-2.5",children:[s.jsx("h3",{className:"text-sm font-semibold text-[#F4F7FC]",children:"Comments"}),s.jsxs("button",{type:"button",onClick:()=>e(a?"comments":"add-comment"),className:H("flex h-7 items-center gap-1.5 rounded-md border px-2.5 text-xs font-medium transition-all",a?"border-primary bg-primary/15 text-primary":"hover:border-primary/40 border-[#2A3242] bg-[#1E2533] text-[#F4F7FC] hover:bg-[#232b3a]"),children:[s.jsx(mt,{className:H("size-3.5 transition-transform",a&&"rotate-45")}),a?"Click canvas":"Add comment"]})]}),s.jsx("div",{className:"max-h-96 overflow-x-hidden overflow-y-auto",children:s.jsx("div",{className:"divide-y divide-[#2A3242]",children:g.length===0?s.jsx("div",{className:"py-8 text-center text-sm text-[#828DA3]",children:"No comments yet. Start the conversation!"}):g.map(D=>{const q=k===D.commentId,j=u?.userId===D.createdBy,z=D.authorName||"User",_=D.parentCommentId?g.find(oe=>oe.commentId===D.parentCommentId)?.authorName:null,Z=ae===D.commentId,ge=Y===D.commentId;return s.jsx("div",{className:"p-3",children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsxs(ra,{className:"size-5 flex-shrink-0",children:[s.jsx(aa,{src:D.authorAvatarUrl||""}),s.jsx(oa,{className:"text-[10px]",children:(z.charAt(0)||"U").toUpperCase()})]}),s.jsxs("div",{className:"min-w-0 flex-1 space-y-1.5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-[13px] font-medium text-[#F4F7FC]",children:z}),s.jsx("span",{className:"text-[11px] text-[#828DA3]",children:D.createdAt?Nr(D.createdAt):""})]}),q?s.jsxs("div",{className:"space-y-2",children:[s.jsx(fn,{forceFocus:!0,theme:"dark",value:F,setValue:G}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Q,{preset:"primary",className:"h-8 px-3 text-xs",onClick:te,disabled:Z,children:Z?s.jsx(os,{className:"size-4!"}):"Save"}),s.jsx(Q,{preset:"outline",className:"h-8 px-3 text-xs",onClick:()=>{O(null),G("")},disabled:Z,children:"Cancel"})]})]}):s.jsxs(s.Fragment,{children:[!!D.parentCommentId&&s.jsxs("div",{className:"text-[11px] text-[#828DA3]",children:["Replying to"," ",s.jsx("span",{className:"font-medium text-[#F4F7FC]",children:_||"a comment"})]}),s.jsx("div",{className:"text-sm leading-snug text-[#F4F7FC]",children:s.jsx(Cr,{theme:"dark",value:D.text??""})}),s.jsxs("div",{className:"flex items-center gap-1 text-[#828DA3]",children:[s.jsxs(Q,{preset:"ghost",className:"-ml-3 h-7 px-2! text-[11px] font-medium text-[#828DA3] hover:text-[#F4F7FC]",onClick:()=>M({commentId:D.commentId,name:z}),children:[s.jsx(Sr,{className:"mr-1 size-3"}),"Reply"]}),s.jsxs(Ot,{children:[s.jsx(Bt,{asChild:!0,children:s.jsx(Q,{preset:"ghost",className:"h-7 px-2! text-[11px] font-medium text-[#828DA3] hover:text-[#F4F7FC]",children:s.jsx(kr,{className:"size-3"})})}),s.jsxs(_t,{align:"start",className:"min-w-40 rounded-lg border-[#2A3242] bg-[#141925] p-1 text-[#F4F7FC] shadow-xl",children:[s.jsxs(Me,{onClick:()=>o(v[D.commentId]),className:"cursor-pointer gap-2 rounded-md px-2.5 py-2 text-sm text-[#F4F7FC] focus:bg-[#1E2533] focus:text-[#F4F7FC]",children:[s.jsx(cl,{className:"size-4"}),"Focus Comment"]}),j&&s.jsxs(s.Fragment,{children:[s.jsxs(Me,{onClick:()=>{O(D.commentId),G(D.text??"")},className:"cursor-pointer gap-2 rounded-md px-2.5 py-2 text-sm text-[#F4F7FC] focus:bg-[#1E2533] focus:text-[#F4F7FC]",children:[s.jsx(Ir,{className:"size-4"}),"Edit"]}),s.jsxs(Me,{onClick:()=>ye(D.commentId),className:"text-destructive focus:text-destructive cursor-pointer gap-2 rounded-md px-2.5 py-2 text-sm focus:bg-[#1E2533]",disabled:ge,children:[s.jsx(Vo,{className:"size-4"}),"Delete"]})]})]})]})]})]})]})]})},D.commentId)})})}),s.jsx("div",{className:"border-t border-[#2A3242] px-3 py-2.5",children:s.jsxs("div",{className:"space-y-2",children:[!!A&&s.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-[#2A3242] bg-[#1E2533] px-2.5 py-2 text-xs text-[#828DA3]",children:[s.jsxs("div",{className:"min-w-0 flex-1 truncate",children:["Replying to"," ",s.jsx("span",{className:"font-medium text-[#F4F7FC]",children:A.name})]}),s.jsx(Q,{preset:"outline",disabled:T,onClick:()=>M(null),className:"h-7 px-2 text-xs",children:"Cancel"})]}),s.jsxs("div",{className:"relative flex min-w-0 flex-1 items-end gap-2",children:[s.jsx("div",{className:"flex-1",children:s.jsx(fn,{theme:"dark",value:I,setValue:C,className:"break-all"})}),s.jsx(Q,{onClick:$,disabled:!I.trim()||T||!L,preset:"primary",className:"size-9! p-0",children:T?s.jsx(os,{className:"size-4"}):s.jsx(Tr,{className:"size-4!"})})]})]})})]}),s.jsx(Uo,{open:!!ke,onOpenChange:D=>{D||ye(null)},title:"Delete comment?",description:"This action cannot be undone.",onConfirm:async()=>{ke&&(await P(ke),ye(null))}})]})}function wd({orgId:t,resourceId:e,onLoaded:n}){const{data:i}=ut(ci,{fetchPolicy:"cache-first",variables:{orgId:t,resourceId:e},skip:!t}),r=y.useMemo(()=>Be(i?.comments).map(a=>({commentId:a.id,resourceId:a.resourceId,parentCommentId:a.parentCommentId,text:a.text,createdBy:a.createdBy,createdAt:a.createdAt,authorName:a.createdByActor?.name,authorAvatarUrl:a.createdByActor?.avatarUrl})),[i]);return y.useEffect(()=>{n(e,r)},[e,r,n]),null}var Nd=Object.defineProperty,Qi=(t,e)=>Nd(t,"name",{value:e,configurable:!0}),mn={Horizontal:"horizontal",Vertical:"vertical"},Gn=mn.Horizontal,Cd=Object.values(mn),Sd=y.forwardRef(Qi(function(e,n){const{decorative:i,orientation:r=Gn,...a}=e,o=Zi(r)?r:Gn,c=o===mn.Vertical?o:void 0,l=i?{role:"none"}:{"aria-orientation":c,role:"separator"};return s.jsx(at.div,{"data-orientation":o,...l,...a,ref:n})},"Separator"));function Zi(t){return Cd.includes(t)}Qi(Zi,"isValidOrientation");function St({className:t,orientation:e="horizontal",decorative:n=!0,...i}){return s.jsx(Sd,{"data-slot":"separator",decorative:n,orientation:e,className:H("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",t),...i})}function kd(){const t=Js().id,[e,n]=y.useState(null),i=ut(Yo,{fetchPolicy:"cache-first",variables:{orgId:t},skip:!t}),r=ut(sa,{fetchPolicy:"cache-first",skip:!t||!e,variables:{orgId:t,serviceId:e}});return{selectedServiceId:e,setSelectedServiceId:n,isServicesLoading:i.loading&&!i.data,isServicesDbLoading:r.loading&&!r.data,services:y.useMemo(()=>Be(i.data?.services.items).map(a=>({...a,serviceId:a.id})),[i.data]),servicesDb:y.useMemo(()=>Be(r.data?.serviceDBs).map(na),[r.data])}}function Id(){const{setNodes:t,setEdges:e,dataSources:n,setDataSources:i,reactFlowInstance:r}=we(),{removeDataSource:a,regenerateSql:o}=Er(),[c,l]=y.useState(null),{selectedServiceId:u,setSelectedServiceId:m,isServicesLoading:d,isServicesDbLoading:h,services:x,servicesDb:N}=kd(),f=x.find(j=>j.serviceId===u),[g,v]=y.useState(null),[b,p]=y.useState(new Set),[w,S]=y.useState(""),I=y.useRef(null),[C,A]=y.useState(!1),[M,T]=y.useState(!1),[R,k]=y.useState(!1),[O,F]=y.useState(null);async function G(){try{const[j]=await as({accept:".sql,.json"});if(!j)return;const z=await j.text(),_=Vt.detectDialect(z),ge=new Vt(_).parse(z);if(!ge.tables||ge.tables.length===0){U.error("No tables found in SQL file");return}const oe=W(),K={id:oe,name:j.name,sourceType:"file",dialect:_,schemaAst:ge,createdAt:Date.now(),modifiedAt:null},fe=Ge.toReactFlow(ge,K.name);t(he=>[...he,...fe.nodes]),e(he=>[...he,...fe.edges]),i(he=>[...he,K]),v(oe),p(he=>new Set([...he,oe])),U.success(`Imported ${ge.tables.length} tables from ${j.name} (${_.toUpperCase()})`)}catch(j){console.error("Error uploading SQL file:",j),U.error("Failed to parse SQL file. Please check the file format.")}}async function ae(){try{const[j]=await as({accept:".json"});if(!j)return;const z=await j.text(),_=JSON.parse(z),Z=qe.safeParse(_),ge=W();let oe,K=null;if(Z.success){oe=Z.data;const xe=ys(Z.data);K={...xe,metadata:{...xe.metadata??{},sourceFile:j.name}}}else{const xe=Oe.safeParse(_);if(xe.success){oe=xe.data;const E=vs(xe.data);K={...E,metadata:{...E.metadata??{},sourceFile:j.name}}}else{const E=Bs.safeParse(_);if(E.success){oe=E.data;const B=En(E.data);K={...B,metadata:{...B.metadata??{},sourceFile:j.name}}}}}if(!K||!oe){U.error("Invalid NoSQL schema file");return}const fe={id:ge,name:j.name,sourceType:"file",dialect:K.dialect,sourceContent:oe,schemaAst:K,createdAt:Date.now(),modifiedAt:null},he=Ge.toReactFlow(K,fe.name);t(xe=>[...xe,...he.nodes]),e(xe=>[...xe,...he.edges]),i(xe=>[...xe,fe]),v(ge),p(xe=>new Set([...xe,ge]));const re=K.dialect==="dynamodb"?"table":"collection";U.success(`Imported ${K.tables.length} ${K.tables.length===1?re:`${re}s`} from ${j.name}`)}catch(j){console.error("Error uploading NoSQL file:",j),U.error("Failed to parse NoSQL schema file.")}}function me(j="mysql",z="Manual Table",_="new_table"){const Z=W(),oe={id:W(),type:"table",name:_,columns:[{type:"column",name:"id",dataType:{name:"INT"},nullable:!1,autoIncrement:!0},{type:"column",name:"name",dataType:{name:"VARCHAR",parameters:[255]},nullable:!1}],constraints:[{type:"primary_key",columns:["id"]}],indexes:[]},K={dialect:j,tables:[oe],metadata:{createdAt:new Date}},fe={id:Z,name:z,sourceType:"manual",dialect:j,schemaAst:K,createdAt:Date.now(),modifiedAt:Date.now()},he=Ge.toReactFlow(K,fe.name);t(re=>[...re,...he.nodes]),e(re=>[...re,...he.edges]),v(Z),i(re=>[...re,fe]),p(re=>new Set([...re,Z])),U.success(`${z} created`)}function Y(){const j=W(),_={dialect:"mongodb",name:"MongoDB Collection",description:"MongoDB Collection",collections:[{id:W(),name:"users",tags:"auth,profiles",description:"Application users",fields:[{id:W(),name:"_id",type:"string",required:!0,refCollectionId:null},{id:W(),name:"email",type:"string",required:!0,refCollectionId:null},{id:W(),name:"username",type:"string",required:!0,refCollectionId:null},{id:W(),name:"name",type:"object",required:!0,refCollectionId:null,fields:[{id:W(),name:"first",type:"string",required:!0,refCollectionId:null},{id:W(),name:"last",type:"string",required:!0,refCollectionId:null}]},{id:W(),name:"roles",type:"array",required:!1,refCollectionId:null,itemType:"string",itemFields:void 0,fields:void 0},{id:W(),name:"address",type:"object",required:!1,refCollectionId:null,fields:[{id:W(),name:"line1",type:"string",required:!0,refCollectionId:null},{id:W(),name:"line2",type:"string",required:!1,refCollectionId:null},{id:W(),name:"city",type:"string",required:!0,refCollectionId:null},{id:W(),name:"state",type:"string",required:!1,refCollectionId:null},{id:W(),name:"country",type:"string",required:!0,refCollectionId:null},{id:W(),name:"postalCode",type:"string",required:!1,refCollectionId:null}]},{id:W(),name:"preferences",type:"object",required:!1,refCollectionId:null,fields:[{id:W(),name:"marketingOptIn",type:"boolean",required:!1,refCollectionId:null},{id:W(),name:"language",type:"string",required:!1,refCollectionId:null},{id:W(),name:"theme",type:"string",required:!1,refCollectionId:null}]},{id:W(),name:"sessions",type:"array",required:!1,refCollectionId:null,itemType:"object",itemFields:[{id:W(),name:"sessionId",type:"string",required:!0,refCollectionId:null},{id:W(),name:"createdAt",type:"date",required:!0,refCollectionId:null},{id:W(),name:"ip",type:"string",required:!1,refCollectionId:null},{id:W(),name:"userAgent",type:"string",required:!1,refCollectionId:null}]},{id:W(),name:"createdAt",type:"date",required:!0,refCollectionId:null},{id:W(),name:"updatedAt",type:"date",required:!1,refCollectionId:null}],indexes:[{id:W(),name:"uniq_email",unique:!0,fields:[{id:W(),fieldName:"email",order:1}]},{id:W(),name:"uniq_username",unique:!0,fields:[{id:W(),fieldName:"username",order:1}]},{id:W(),name:"idx_createdAt",unique:!1,fields:[{id:W(),fieldName:"createdAt",order:-1}]}]}]},Z=vs(_),ge={id:j,name:"MongoDB Collection",sourceType:"manual",dialect:"mongodb",sourceContent:_,schemaAst:Z,createdAt:Date.now(),modifiedAt:Date.now()},oe=Ge.toReactFlow(Z,ge.name);t(K=>[...K,...oe.nodes]),e(K=>[...K,...oe.edges]),v(j),i(K=>[...K,ge]),p(K=>new Set([...K,j])),U.success("MongoDB Collection created")}function Ne(){const j=W(),z={dialect:"dynamodb",name:"DynamoDB Table",description:"DynamoDB Table",primaryKey:{partitionKey:"pk",partitionKeyType:"S",sortKey:"sk",sortKeyType:"S"},globalSecondaryIndexes:[{id:W(),name:"gsi1",partitionKey:"gsi1pk",partitionKeyType:"S",sortKey:"gsi1sk",sortKeyType:"S"},{id:W(),name:"gsi2",partitionKey:"gsi2pk",partitionKeyType:"S",sortKey:"gsi2sk",sortKeyType:"S"}],attributes:[{id:W(),name:"entityType",type:"string",required:!0},{id:W(),name:"orgId",type:"string",required:!0},{id:W(),name:"userId",type:"string",required:!0},{id:W(),name:"email",type:"string",required:!0},{id:W(),name:"status",type:"string",required:!1},{id:W(),name:"roles",type:"array",required:!1,itemType:"string"},{id:W(),name:"profile",type:"object",required:!1,fields:[{id:W(),name:"firstName",type:"string",required:!0},{id:W(),name:"lastName",type:"string",required:!0},{id:W(),name:"phone",type:"string",required:!1}]},{id:W(),name:"createdAt",type:"string",required:!0},{id:W(),name:"updatedAt",type:"string",required:!1}]},_=ys(z),Z={id:j,name:"Manual DynamoDB",sourceType:"manual",dialect:"dynamodb",sourceContent:z,schemaAst:_,createdAt:Date.now(),modifiedAt:Date.now()},ge=Ge.toReactFlow(_,Z.name);t(oe=>[...oe,...ge.nodes]),e(oe=>[...oe,...ge.edges]),v(j),i(oe=>[...oe,Z]),p(oe=>new Set([...oe,j])),U.success("Manual DynamoDB schema created")}function ke(j){a(j),t(z=>z.filter(_=>!_.id.startsWith(`${j}-table-`))),e(z=>z.filter(_=>!_.id.startsWith(`${j}-table-`))),g===j&&v(null),c===j&&l(null),U.success("Data source removed")}function ye(j){if(j.dialect==="mongodb"||j.dialect==="dynamodb"||j.dialect==="json")S(JSON.stringify(j.sourceContent??{},null,2));else{const _=new Ro(j.dialect,2).generate(j.schemaAst);S(_)}l(j.id)}function L(j,z){S(z),I.current&&clearTimeout(I.current);const _=n.find(Z=>Z.id===j);!_||_.dialect==="mongodb"||_.dialect==="dynamodb"||_.dialect==="json"||(I.current=setTimeout(()=>{try{const Z=n.find(re=>re.id===j);if(!Z)return;const oe=new Vt(Z.dialect).parse(z);if(!oe.tables||oe.tables.length===0)return;i(re=>re.map(E=>E.id===j?{...E,schemaAst:oe,modifiedAt:Date.now()}:E));const K=r?.getNodes(),fe=r?.getEdges(),he=Ge.updateReactFlow({schema:oe,sourceName:_.name,nodes:K??[],edges:fe??[],oldDataSources:n});t(he.nodes),e(he.edges)}catch(Z){console.error("Error parsing SQL:",Z)}},500))}function $(j){try{const z=n.find(fe=>fe.id===j);if(!z)return;if(z.dialect==="mongodb"||z.dialect==="dynamodb"||z.dialect==="json"){const fe=JSON.parse(w);if(z.dialect==="mongodb"){const he=Oe.parse(fe),re=vs(he);if(!re.tables||re.tables.length===0){U.error("No valid tables found in schema");return}l(null),i(ee=>ee.map(ie=>ie.id===j?{...ie,sourceContent:he,schemaAst:re,modifiedAt:Date.now()}:ie));const xe=r?.getNodes(),E=r?.getEdges(),B=Ge.updateReactFlow({schema:re,sourceName:z.name,nodes:xe??[],edges:E??[],oldDataSources:n});t(B.nodes),e(B.edges),U.success("Schema updated successfully");return}if(z.dialect==="dynamodb"){const he=qe.parse(fe),re=ys(he);if(!re.tables||re.tables.length===0){U.error("No valid tables found in schema");return}l(null),i(ee=>ee.map(ie=>ie.id===j?{...ie,sourceContent:he,schemaAst:re,modifiedAt:Date.now()}:ie));const xe=r?.getNodes(),E=r?.getEdges(),B=Ge.updateReactFlow({schema:re,sourceName:z.name,nodes:xe??[],edges:E??[],oldDataSources:n});t(B.nodes),e(B.edges),U.success("Schema updated successfully");return}if(z.dialect==="json"){const he=Bs.parse(fe),re=En(he);if(!re.tables||re.tables.length===0){U.error("No valid tables found in schema");return}l(null),i(ee=>ee.map(ie=>ie.id===j?{...ie,sourceContent:he,schemaAst:re,modifiedAt:Date.now()}:ie));const xe=r?.getNodes(),E=r?.getEdges(),B=Ge.updateReactFlow({schema:re,sourceName:z.name,nodes:xe??[],edges:E??[],oldDataSources:n});t(B.nodes),e(B.edges),U.success("Schema updated successfully");return}return}const Z=new Vt(z.dialect).parse(w);if(!Z.tables||Z.tables.length===0){U.error("No valid tables found in SQL");return}l(null),i(fe=>fe.map(re=>re.id===j?{...re,schemaAst:Z,modifiedAt:Date.now()}:re));const ge=r?.getNodes(),oe=r?.getEdges(),K=Ge.updateReactFlow({schema:Z,sourceName:z.name,nodes:ge??[],edges:oe??[],oldDataSources:n});t(K.nodes),e(K.edges),U.success("SQL updated successfully")}catch(z){console.error("Error parsing edited content:",z),U.error("Invalid content. Please check your changes.")}}function te(){l(null),S("")}function P(j){const z=o(j);console.log("Regenerated SQL:",z),U.success("SQL regenerated from internal structure")}function D(j){p(z=>{const _=new Set(z);return _.has(j)?_.delete(j):_.add(j),_})}function q(j){return b.has(j)}return s.jsx(Xe,{className:"left-18",children:s.jsxs("div",{className:"flex h-full w-[500px] flex-col",children:[s.jsxs("div",{className:"from-primary/10 to-primary/5 border-stock border-b bg-gradient-to-r px-4 py-3",children:[s.jsxs("h3",{className:"text-foreground flex items-center gap-2 text-base font-semibold",children:[s.jsx(Qe,{className:"text-primary h-5 w-5"}),"Data Sources"]}),s.jsx("p",{className:"text-paragraph mt-1 text-xs",children:"Connect services, upload SQL or NoSQL files, or create tables manually"})]}),s.jsxs("div",{className:"space-y-4 p-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs(Ot,{open:M,onOpenChange:j=>{T(j),k(!1)},children:[s.jsx(Bt,{asChild:!0,children:s.jsxs(Q,{preset:"primary",className:"flex w-full items-center justify-between gap-2 pr-3! focus:z-10",children:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(mt,{className:"h-4 w-4"}),"Add SQL Source"]}),s.jsx(nt,{className:"h-4 w-4"})]})}),s.jsxs(_t,{side:"bottom",align:"start",children:[s.jsxs(Me,{onClick:G,children:[s.jsx(qs,{className:"h-4 w-4"}),"Upload SQL Schema"]}),s.jsxs(Me,{onClick:()=>me("mysql","MySQL Source"),children:[s.jsx(Qe,{className:"h-4 w-4"}),"New MySQL Source"]}),s.jsxs(Me,{onClick:()=>me("postgresql","PostgreSQL Source"),children:[s.jsx(Qe,{className:"h-4 w-4"}),"New PostgreSQL Source"]})]})]}),s.jsxs(Ot,{open:R,onOpenChange:j=>{k(j),T(!1)},children:[s.jsx(Bt,{asChild:!0,children:s.jsxs(Q,{preset:"outline",className:"flex w-full items-center justify-between gap-2 pr-3! focus:z-10",children:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(mt,{className:"h-4 w-4"}),"Add NoSQL Source"]}),s.jsx(nt,{className:"h-4 w-4"})]})}),s.jsxs(_t,{side:"bottom",align:"start",children:[s.jsxs(Me,{onClick:ae,children:[s.jsx(qs,{className:"h-4 w-4"}),"Upload NoSQL Schema"]}),s.jsxs(Me,{onClick:()=>A(!0),children:[s.jsx(ws,{className:"h-4 w-4"}),"Open NoSQL Editor"]}),s.jsxs(Me,{onClick:Ne,children:[s.jsx(Ko,{className:"h-4 w-4"}),"New DynamoDB Table"]}),s.jsxs(Me,{onClick:Y,children:[s.jsx(ws,{className:"h-4 w-4"}),"New MongoDB Collection"]})]})]})]}),s.jsxs("div",{children:[n.length>0&&s.jsxs(s.Fragment,{children:[s.jsx(St,{className:"my-4"}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("h4",{className:"text-secondary-foreground text-sm font-medium",children:["Sources (",n.length,")"]}),n.map(j=>s.jsx("div",{className:H("group border-stock bg-popover rounded-lg border py-2 transition-all",g===j.id&&"border-blue-500 ring-1 ring-blue-500",c===j.id&&"ring-2 ring-green-500"),children:c===j.id?s.jsxs("div",{children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between px-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ht,{className:"h-4 w-4 text-green-600"}),s.jsxs("span",{className:"text-foreground text-sm font-medium",children:["Editing: ",j.name]})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(Q,{size:"sm",variant:"ghost",onClick:te,children:"Cancel"}),s.jsxs(Q,{size:"sm",variant:"ghost",className:"text-green-600 hover:text-green-700",onClick:()=>$(j.id),children:["Done",s.jsx(Qo,{className:"h-3.5 w-3.5"})]})]})]}),s.jsx(Zs,{height:"400px",value:w,setValue:z=>L(j.id,z)}),s.jsx("div",{className:"text-muted-foreground mt-2 px-2 text-xs",children:"Changes sync automatically to flow diagram and right panel"})]}):s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-start justify-between gap-2 p-3",children:[s.jsxs("button",{className:"flex min-w-0 flex-1 cursor-pointer flex-col items-start text-left",onClick:()=>D(j.id),children:[s.jsxs("div",{className:"flex w-full items-center gap-2",children:[q(j.id)?s.jsx(nt,{className:"text-muted-foreground h-4 w-4 flex-shrink-0"}):s.jsx($s,{className:"text-muted-foreground h-4 w-4 flex-shrink-0"}),s.jsx(ws,{className:"h-4 w-4 flex-shrink-0 text-blue-600"}),s.jsx("span",{className:"text-foreground truncate text-sm font-medium",children:j.name}),j.modifiedAt&&s.jsx("span",{className:"rounded bg-yellow-100 px-1.5 py-0.5 text-xs text-yellow-700",children:"Modified"})]}),s.jsxs("div",{className:"text-muted-foreground mt-1 ml-10 flex items-center gap-3 text-xs",children:[s.jsx("span",{className:"uppercase",children:j.dialect}),s.jsx("span",{children:"•"}),s.jsxs("span",{children:[j.schemaAst?.tables?.length||0," tables"]}),s.jsx("span",{children:"•"}),s.jsxs("span",{children:[j.schemaAst?.tables?.reduce((z,_)=>z+_.constraints?.filter(Z=>Z.type==="foreign_key").length,0)," ","relations"]})]})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(Q,{variant:"ghost",size:"sm",className:"text-muted-foreground h-7 w-7 p-0 hover:text-blue-600",onClick:()=>ye(j),title:"View/Edit SQL",children:s.jsx(Ht,{className:"h-3.5 w-3.5"})}),(j.dialect==="dynamodb"||j.dialect==="mongodb"||j.dialect==="json")&&s.jsx(Q,{variant:"ghost",size:"sm",className:"text-muted-foreground h-7 w-7 p-0 hover:text-blue-600",onClick:()=>F(j),title:"Edit NoSQL Schema",children:s.jsx(Ta,{className:"h-3.5 w-3.5"})}),s.jsx(Q,{variant:"ghost",size:"sm",className:"text-muted-foreground h-7 w-7 p-0 hover:text-green-600",onClick:()=>P(j.id),title:"Regenerate SQL from AST",children:s.jsx(yl,{className:"h-3.5 w-3.5"})}),s.jsx(Q,{variant:"ghost",size:"sm",className:"text-muted-foreground h-7 w-7 p-0 hover:text-red-600",onClick:()=>ke(j.id),children:s.jsx(It,{className:"h-3.5 w-3.5"})})]})]}),q(j.id)&&s.jsx("div",{className:"ml-7 space-y-1 rounded px-2 pb-2",children:j.schemaAst?.tables.map(z=>s.jsxs("div",{draggable:!0,className:"bg-card hover:bg-accent flex cursor-grab items-center justify-between rounded px-3 py-2 text-sm transition-all active:cursor-grabbing",onDragStart:_=>{Ke(_,"databaseTableSQL",{localTable:{databaseName:j.name,tableName:z.name}},{width:400,id:Do(j.name,z.name)},z.name??"Table")},children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Qe,{className:"h-4 w-4 text-green-600"}),s.jsx("span",{className:"text-secondary-foreground font-mono font-medium",children:z?.name})]}),s.jsxs("span",{className:"text-muted-foreground text-xs",children:[z?.columns?.length||0," cols"]})]},`${j.id}-${z?.name}`))})]})},j.id))]})]}),n.length===0&&s.jsxs("div",{className:"mt-8 text-center",children:[s.jsx("div",{className:"bg-accent mx-auto mb-3 flex h-16 w-16 items-center justify-center rounded-full",children:s.jsx(Qe,{className:"text-muted-foreground h-8 w-8"})}),s.jsx("p",{className:"text-muted-foreground text-sm",children:"No data sources yet"}),s.jsx("p",{className:"text-muted-foreground mt-1 text-xs",children:"Upload a SQL file or create a table manually"})]})]}),s.jsxs("div",{className:"space-y-2",children:[x.length>0&&s.jsxs("div",{className:"mb-4",children:[s.jsx("label",{className:"text-secondary-foreground mb-2 block text-sm font-medium",children:"Select Service"}),s.jsx(io,{disabled:d,value:u||"",onChange:m,options:x.map(j=>({value:j.serviceId,label:j.name}))})]}),u&&N.length>0&&s.jsx("div",{children:N.map(j=>{const z=j.noSQLSchema?.dynamo?.table,_=j.noSQLSchema?.mongo?.collections;let Z=[];z?.name?Z=[{name:z.name,colCount:z.attributes?.length??0}]:_&&(Z=_.map(K=>({name:K.name,colCount:K.fields?.length??0})));const ge=Z.length>0,oe=ge?Z.length:j.tables?.length||0;return s.jsxs("div",{className:"mb-4",children:[s.jsxs("h4",{className:"text-secondary-foreground mb-2 text-sm font-medium",children:[j.dbName," (",oe," tables)"]}),s.jsx("div",{className:"space-y-2",children:h?s.jsx("div",{className:"text-muted-foreground text-sm",children:"Loading tables..."}):ge?Z.map(K=>s.jsxs("div",{draggable:!0,className:"bg-card hover:bg-accent flex cursor-grab items-center justify-between rounded px-3 py-2 text-sm transition-all active:cursor-grabbing",onDragStart:fe=>{Ke(fe,"databaseTableSQL",{serviceTable:{serviceName:f.name,databaseName:j.dbName,tableName:K.name}},{width:400},K.name)},children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Qe,{className:"h-4 w-4 text-green-600"}),s.jsx("span",{className:"text-secondary-foreground font-mono font-medium",children:K.name})]}),s.jsxs("span",{className:"text-muted-foreground text-xs",children:[K.colCount," attrs"]})]},`${j.serviceDBId}-${K.name}`)):j.tables?.filter(K=>K?.name!=null).map(K=>s.jsxs("div",{draggable:!0,className:"bg-card hover:bg-accent flex cursor-grab items-center justify-between rounded px-3 py-2 text-sm transition-all active:cursor-grabbing",onDragStart:fe=>{Ke(fe,"databaseTableSQL",{serviceTable:{serviceName:f.name,databaseName:j.dbName,tableName:K.name}},{width:400},K.name??"Table")},children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Qe,{className:"h-4 w-4 text-green-600"}),s.jsx("span",{className:"text-secondary-foreground font-mono font-medium",children:K?.name})]}),s.jsxs("span",{className:"text-muted-foreground text-xs",children:[K?.columns?.length||0," cols"]})]},`${j.serviceDBId}-${K?.name}`))})]},j.serviceDBId)})})]})]}),s.jsx(Tn,{open:C,onOpenChange:j=>A(j),onSchemaSubmit:async j=>{const z=Ge.toReactFlow(j.schemaAst,j.name);t(_=>[..._,...z.nodes]),e(_=>[..._,...z.edges]),i(_=>[..._,j]),v(j.id),p(_=>new Set([..._,j.id])),U.success("NoSQL schema saved"),A(!1)}}),s.jsx(Tn,{open:O!==null,initialDataSource:O??void 0,onOpenChange:()=>F(null),onSchemaSubmit:async j=>{O&&(i(z=>z.map(_=>_.id===O.id?j:_)),U.success("NoSQL schema saved"),F(null))}})]})})}const qn=[{cloud:"AWS",title:"AWS",manifestUrl:"/aws-icons.json"},{cloud:"Azure",title:"Azure",manifestUrl:"/azure-icons.json"},{cloud:"GCP",title:"Google Cloud",manifestUrl:"/gcp-icons.json"},{cloud:"Kubernetes",title:"Kubernetes",manifestUrl:"/kubernetes-icons.json"}];async function Td(t){const e=await fetch(t);if(!e.ok)throw new Error(`Failed to load icons from ${t}`);return e.json()}function Ed(){return il({queries:qn.map(t=>({queryKey:["icon-manifest",t.cloud],queryFn:()=>Td(t.manifestUrl),staleTime:1/0,gcTime:1/0})),combine:t=>{const e=[];return qn.forEach((n,i)=>{const r=t[i].data;if(!r?.length)return;const a={};for(const o of r)(a[o.category]??=[]).push(o);e.push({title:n.title,cloud:n.cloud,categories:a})}),{sections:e,isLoading:t.some(n=>n.isPending),error:t.every(n=>n.isError)?t[0].error?.message??"Failed to load icons":null}}})}function Ji({cloud:t,icon:e}){const n=`/${t.toLowerCase()}-icons/${e.relativePath}`,i=`${t.toLowerCase()}:${e.name.toLowerCase().replace(/\s+/g,"-")}`;return s.jsxs("div",{draggable:!0,className:bd,onDragStart:r=>{Ke(r,"cloud",{cloud:t,iconSrc:n,category:e.category,componentFields:[{componentFieldId:"name",type:X.TextInput,label:"Name",isReadonly:!0,data:[{value:e.name}]}]},{width:150,height:160})},children:[s.jsx("div",{className:"flex size-8 items-center justify-center rounded-md bg-[#141925] transition-colors group-hover:bg-[#232b3a]",children:s.jsx("img",{src:n,alt:e.name,className:"size-5",onError:r=>{const a=r.target;a.src="/placeholder.svg"}})}),s.jsx("div",{className:"min-w-0 flex-1",children:s.jsx("span",{className:"group-hover:text-primary block truncate text-sm font-medium text-[#F4F7FC]",children:e.name})})]},i)}function Ld(t){return s.jsxs("svg",{fill:"none",width:"1em",height:"1em",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",...t,children:[s.jsx("g",{id:"SVGRepo_bgCarrier",strokeWidth:"0"}),s.jsx("g",{id:"SVGRepo_tracerCarrier",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsxs("g",{id:"SVGRepo_iconCarrier",children:[s.jsx("path",{fill:"#252F3E",d:"M4.51 7.687c0 .197.02.357.058.475.042.117.096.245.17.384a.233.233 0 01.037.123c0 .053-.032.107-.1.16l-.336.224a.255.255 0 01-.138.048c-.054 0-.107-.026-.16-.074a1.652 1.652 0 01-.192-.251 4.137 4.137 0 01-.165-.315c-.415.491-.936.737-1.564.737-.447 0-.804-.129-1.064-.385-.261-.256-.394-.598-.394-1.025 0-.454.16-.822.484-1.1.325-.278.756-.416 1.304-.416.18 0 .367.016.564.042.197.027.4.07.612.118v-.39c0-.406-.085-.689-.25-.854-.17-.166-.458-.246-.868-.246-.186 0-.377.022-.574.07a4.23 4.23 0 00-.575.181 1.525 1.525 0 01-.186.07.326.326 0 01-.085.016c-.075 0-.112-.054-.112-.166v-.262c0-.085.01-.15.037-.186a.399.399 0 01.15-.113c.185-.096.409-.176.67-.24.26-.07.537-.101.83-.101.633 0 1.096.144 1.394.432.293.288.442.726.442 1.314v1.73h.01zm-2.161.811c.175 0 .356-.032.548-.096.191-.064.362-.182.505-.342a.848.848 0 00.181-.341c.032-.129.054-.283.054-.465V7.03a4.43 4.43 0 00-.49-.09 3.996 3.996 0 00-.5-.033c-.357 0-.618.07-.793.214-.176.144-.26.347-.26.614 0 .25.063.437.196.566.128.133.314.197.559.197zm4.273.577c-.096 0-.16-.016-.202-.054-.043-.032-.08-.106-.112-.208l-1.25-4.127a.938.938 0 01-.049-.214c0-.085.043-.133.128-.133h.522c.1 0 .17.016.207.053.043.032.075.107.107.208l.894 3.535.83-3.535c.026-.106.058-.176.1-.208a.365.365 0 01.214-.053h.425c.102 0 .17.016.213.053.043.032.08.107.101.208l.841 3.578.92-3.578a.458.458 0 01.107-.208.346.346 0 01.208-.053h.495c.085 0 .133.043.133.133 0 .027-.006.054-.01.086a.76.76 0 01-.038.133l-1.283 4.127c-.032.107-.069.177-.111.209a.34.34 0 01-.203.053h-.457c-.101 0-.17-.016-.213-.053-.043-.038-.08-.107-.101-.214L8.213 5.37l-.82 3.439c-.026.107-.058.176-.1.213-.043.038-.118.054-.213.054h-.458zm6.838.144a3.51 3.51 0 01-.82-.096c-.266-.064-.473-.134-.612-.214-.085-.048-.143-.101-.165-.15a.378.378 0 01-.031-.149v-.272c0-.112.042-.166.122-.166a.3.3 0 01.096.016c.032.011.08.032.133.054.18.08.378.144.585.187.213.042.42.064.633.064.336 0 .596-.059.777-.176a.575.575 0 00.277-.508.52.52 0 00-.144-.373c-.095-.102-.276-.193-.537-.278l-.772-.24c-.388-.123-.676-.305-.851-.545a1.275 1.275 0 01-.266-.774c0-.224.048-.422.143-.593.096-.17.224-.32.384-.438.16-.122.34-.213.553-.277.213-.064.436-.091.67-.091.118 0 .24.005.357.021.122.016.234.038.346.06.106.026.208.052.303.085.096.032.17.064.224.096a.46.46 0 01.16.133.289.289 0 01.047.176v.251c0 .112-.042.171-.122.171a.552.552 0 01-.202-.064 2.427 2.427 0 00-1.022-.208c-.303 0-.543.048-.708.15-.165.1-.25.256-.25.475 0 .149.053.277.16.379.106.101.303.202.585.293l.756.24c.383.123.66.294.825.513.165.219.244.47.244.748 0 .23-.047.437-.138.619a1.436 1.436 0 01-.388.47c-.165.133-.362.23-.591.299-.24.075-.49.112-.761.112z"}),s.jsxs("g",{fill:"#F90",fillRule:"evenodd",clipRule:"evenodd",children:[s.jsx("path",{d:"M14.465 11.813c-1.75 1.297-4.294 1.986-6.481 1.986-3.065 0-5.827-1.137-7.913-3.027-.165-.15-.016-.353.18-.235 2.257 1.313 5.04 2.109 7.92 2.109 1.941 0 4.075-.406 6.039-1.239.293-.133.543.192.255.406z"}),s.jsx("path",{d:"M15.194 10.98c-.223-.287-1.479-.138-2.048-.069-.17.022-.197-.128-.043-.24 1-.705 2.645-.502 2.836-.267.192.24-.053 1.89-.99 2.68-.143.123-.281.06-.218-.1.213-.53.687-1.72.463-2.003z"})]})]})]})}function Ad(t){return s.jsxs("svg",{width:"1em",height:"1em",fill:"none",viewBox:"0 -28.5 256 256",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",...t,children:[s.jsx("g",{id:"SVGRepo_bgCarrier",strokeWidth:"0"}),s.jsx("g",{id:"SVGRepo_tracerCarrier",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsxs("g",{id:"SVGRepo_iconCarrier",children:[s.jsx("title",{children:"path21"}),s.jsx("g",{stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:s.jsx("path",{d:"M118.431947,187.698037 C151.322003,181.887937 178.48731,177.08008 178.799309,177.013916 L179.366585,176.893612 L148.31513,139.958881 C131.236843,119.644776 117.26369,102.945381 117.26369,102.849118 C117.26369,102.666861 149.32694,14.3716012 149.507189,14.057257 C149.567455,13.952452 171.38747,51.62411 202.400338,105.376064 C231.435152,155.699606 255.372949,197.191547 255.595444,197.580359 L255.999996,198.287301 L157.315912,198.274572 L58.6318456,198.261895 L118.431947,187.698073 L118.431947,187.698037 Z M-4.03864498e-06,176.434723 C-4.03864498e-06,176.382721 14.631291,150.983941 32.5139844,119.992969 L65.0279676,63.6457518 L102.919257,31.8473052 C123.759465,14.3581634 140.866667,0.0274832751 140.935253,0.00062917799 C141.003839,-0.0247829554 140.729691,0.665213042 140.326034,1.53468179 C139.922377,2.40415053 121.407304,42.1170321 99.1814268,89.7855264 L58.7707514,176.455514 L29.3853737,176.492355 C13.2234196,176.512639 -4.03864498e-06,176.486664 -4.03864498e-06,176.434703 L-4.03864498e-06,176.434723 Z",fill:"#0089D6",fillRule:"nonzero"})})]})]})}function Fd(t){return s.jsxs("svg",{fill:"none",width:"1em",height:"1em",version:"1.1",viewBox:"0 -25 256 256",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",preserveAspectRatio:"xMidYMid",...t,children:[s.jsx("g",{id:"SVGRepo_bgCarrier",strokeWidth:"0"}),s.jsx("g",{id:"SVGRepo_tracerCarrier",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("g",{id:"SVGRepo_iconCarrier",children:s.jsxs("g",{children:[s.jsx("path",{d:"M170.2517,56.8186 L192.5047,34.5656 L193.9877,25.1956 C153.4367,-11.6774 88.9757,-7.4964 52.4207,33.9196 C42.2667,45.4226 34.7337,59.7636 30.7167,74.5726 L38.6867,73.4496 L83.1917,66.1106 L86.6277,62.5966 C106.4247,40.8546 139.8977,37.9296 162.7557,56.4286 L170.2517,56.8186 Z",fill:"#EA4335"}),s.jsx("path",{d:"M224.2048,73.9182 C219.0898,55.0822 208.5888,38.1492 193.9878,25.1962 L162.7558,56.4282 C175.9438,67.2042 183.4568,83.4382 183.1348,100.4652 L183.1348,106.0092 C198.4858,106.0092 210.9318,118.4542 210.9318,133.8052 C210.9318,149.1572 198.4858,161.2902 183.1348,161.2902 L127.4638,161.2902 L121.9978,167.2242 L121.9978,200.5642 L127.4638,205.7952 L183.1348,205.7952 C223.0648,206.1062 255.6868,174.3012 255.9978,134.3712 C256.1858,110.1682 244.2528,87.4782 224.2048,73.9182",fill:"#4285F4"}),s.jsx("path",{d:"M71.8704,205.7957 L127.4634,205.7957 L127.4634,161.2897 L71.8704,161.2897 C67.9094,161.2887 64.0734,160.4377 60.4714,158.7917 L52.5844,161.2117 L30.1754,183.4647 L28.2234,191.0387 C40.7904,200.5277 56.1234,205.8637 71.8704,205.7957",fill:"#34A853"}),s.jsx("path",{d:"M71.8704,61.4255 C31.9394,61.6635 -0.2366,94.2275 0.0014,134.1575 C0.1344,156.4555 10.5484,177.4455 28.2234,191.0385 L60.4714,158.7915 C46.4804,152.4705 40.2634,136.0055 46.5844,122.0155 C52.9044,108.0255 69.3704,101.8085 83.3594,108.1285 C89.5244,110.9135 94.4614,115.8515 97.2464,122.0155 L129.4944,89.7685 C115.7734,71.8315 94.4534,61.3445 71.8704,61.4255",fill:"#FBBC05"})]})})]})}const Dd={aws:s.jsx(Ld,{}),azure:s.jsx(Ad,{}),gcp:s.jsx(Fd,{}),kubernetes:s.jsx(Po,{color:"#326CE5"})};function er(t){return Dd[t.toLowerCase()]||"☁️"}function Un(t,e){return`${t}::${e}`}function Rd({cloud:t,category:e,icons:n,isExpanded:i,onToggle:r}){const[a,o]=y.useState(!1),c=a?n:n.slice(0,8),l=n.length-c.length;return s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsxs("button",{onClick:r,className:fd,children:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(La,{className:"text-muted-foreground size-3"}),s.jsx("span",{className:"truncate capitalize",children:e.replace(/-/g," ")}),s.jsx("span",{className:"rounded-full bg-[#232b3a] px-1.5 py-0.5 text-[10px] text-[#828DA3]",children:n.length})]}),s.jsx("div",{className:"transition-transform group-hover:scale-110",children:i?s.jsx(rn,{className:"size-4"}):s.jsx(ct,{className:"size-4"})})]}),i&&s.jsxs("div",{className:xd,children:[c.map(u=>s.jsx(Ji,{cloud:t,icon:u},`${t}:${e}:${u.name}:${u.relativePath}`)),l>0&&s.jsxs(Q,{preset:"outline",onClick:()=>o(!0),children:["+",l," more"]})]})]})}function zd({sections:t}){const[e,n]=y.useState(new Set),[i,r]=y.useState(new Set);return s.jsx("div",{className:"space-y-3",children:t.map(a=>s.jsxs("div",{className:"flex flex-col gap-4",children:[s.jsx("button",{onClick:()=>{const o=new Set(e);o.has(a.cloud)?o.delete(a.cloud):o.add(a.cloud),n(o)},className:"w-full rounded-lg border border-[#2A3242] bg-[#1E2533] p-3 transition-all hover:bg-[#232b3a] focus:outline-none",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-3xl",children:er(a.cloud)}),s.jsxs("div",{className:"text-left",children:[s.jsx("h3",{className:"text-sm font-semibold text-[#F4F7FC]",children:a.title}),s.jsxs("p",{className:"text-muted-foreground text-xs",children:[Object.values(a.categories).flat().length," icons available"]})]})]}),s.jsx("div",{className:"transition-transform duration-200",children:e.has(a.cloud)?s.jsx(Ea,{className:"text-muted-foreground size-4"}):s.jsx(rn,{className:"text-muted-foreground size-4"})})]})}),e.has(a.cloud)&&s.jsx("div",{className:"animate-in slide-in-from-top-2 flex flex-col gap-2 duration-200",children:Object.entries(a.categories).map(([o,c])=>s.jsx(Rd,{cloud:a.cloud,category:o,icons:c,isExpanded:i.has(Un(a.cloud,o)),onToggle:()=>{const l=new Set(i),u=Un(a.cloud,o);l.has(u)?l.delete(u):l.add(u),r(l)}},`${a.cloud}:${o}`))})]},a.cloud))})}function Md({sections:t,searchQuery:e}){const n=e.trim(),[i,r]=y.useState([]),[a,o]=y.useState(!1),c=y.useMemo(()=>t.flatMap(m=>Object.entries(m.categories).flatMap(([d,h])=>h.map(x=>({cloud:m.cloud,title:m.title,category:d,icon:x,searchText:`${m.cloud} ${m.title} ${d} ${x.name}`})))),[t]),l=y.useMemo(()=>new ro(c,{includeScore:!0,threshold:.3,ignoreLocation:!0,keys:[{name:"icon.name",weight:.7},{name:"category",weight:.2},{name:"searchText",weight:.1}]}),[c]);y.useEffect(()=>{if(!n){r([]),o(!1);return}o(!0);const m=setTimeout(()=>{r(l.search(n).map(d=>({score:d.score??1,...d.item}))),o(!1)},180);return()=>clearTimeout(m)},[l,n]);const u=y.useMemo(()=>{const m=new Map;for(const d of i){m.has(d.cloud)||m.set(d.cloud,{cloud:d.cloud,title:d.title,score:d.score,categories:new Map});const h=m.get(d.cloud);h.score=Math.min(h.score,d.score),h.categories.has(d.category)||h.categories.set(d.category,{category:d.category,score:d.score,icons:[]});const x=h.categories.get(d.category);x.score=Math.min(x.score,d.score),x.icons.push({icon:d.icon,score:d.score})}return Array.from(m.values()).map(d=>({...d,categories:Array.from(d.categories.values()).map(h=>({...h,icons:h.icons.sort((x,N)=>x.score-N.score||x.icon.name.localeCompare(N.icon.name))})).sort((h,x)=>h.score-x.score||h.category.localeCompare(x.category))})).sort((d,h)=>d.score-h.score||d.title.localeCompare(h.title))},[i]);return a?s.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-center",children:[s.jsx(Ms,{className:"text-muted-foreground size-5 animate-spin"}),s.jsx("p",{className:"text-muted-foreground text-sm",children:"Searching icons..."})]}):u.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[s.jsx(Oi,{className:"text-muted-foreground mb-2 size-8"}),s.jsxs("p",{className:"text-muted-foreground text-sm",children:['No icons found for "',e,'"']}),s.jsx("p",{className:"text-muted-foreground text-xs",children:"Try a different search term"})]}):s.jsxs("div",{className:"flex flex-col gap-3",children:[s.jsxs("p",{className:"text-muted-foreground text-xs",children:[i.length," result",i.length!==1?"s":""," in"," ",u.length," provider",u.length!==1?"s":""]}),s.jsx(ze.div,{className:"space-y-3",initial:"hidden",animate:"visible",variants:{hidden:{},visible:{transition:{staggerChildren:.05}}},children:u.map(m=>s.jsxs(ze.div,{className:"flex flex-col gap-3",variants:{hidden:{opacity:0,y:6},visible:{opacity:1,y:0,transition:{duration:.18,ease:"easeOut"}}},children:[s.jsx("div",{className:"border-primary/20 from-primary/10 to-primary/5 w-full rounded-lg border bg-gradient-to-r p-3",children:s.jsx("div",{className:"flex items-center justify-between",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-3xl",children:er(m.cloud)}),s.jsxs("div",{className:"text-left",children:[s.jsx("h3",{className:"text-foreground text-sm font-semibold",children:m.title}),s.jsxs("p",{className:"text-paragraph text-xs",children:[m.categories.reduce((d,h)=>d+h.icons.length,0)," ","matched icon",m.categories.reduce((d,h)=>d+h.icons.length,0)!==1?"s":""]})]})]})})}),s.jsx("div",{className:"animate-in slide-in-from-top-2 flex flex-col gap-2 duration-200",children:m.categories.map(d=>s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsxs("div",{className:"group text-secondary-foreground flex h-8 w-full items-center justify-between rounded-md px-3 text-xs font-medium",children:[s.jsx("span",{className:"truncate capitalize",children:d.category.replace(/-/g," ")}),s.jsx("span",{className:"bg-accent text-paragraph rounded-full px-1.5 py-0.5 text-[10px]",children:d.icons.length})]}),s.jsx("div",{className:"border-stock ml-2 flex flex-col gap-1.5 border-l pl-3",children:d.icons.map(h=>s.jsx(Ji,{cloud:m.cloud,icon:h.icon},`${m.cloud}:${d.category}:${h.icon.name}:${h.icon.relativePath}`))})]},`${m.cloud}:${d.category}`))})]},m.cloud))})]})}function Od(){const{sections:t,isLoading:e,error:n}=Ed(),[i,r]=y.useState(""),a=i.trim().length>0;return e?s.jsx(Xe,{className:"left-18",children:s.jsx("div",{className:"flex flex-col gap-2 p-1",children:s.jsx("div",{className:"flex items-center justify-center p-4",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-blue-500 border-t-transparent"}),s.jsx("span",{className:"text-muted-foreground text-sm",children:"Loading icons..."})]})})})}):n?s.jsx(Xe,{className:"left-18",children:s.jsx("div",{className:"flex flex-col gap-2 p-1",children:s.jsx("div",{className:"flex items-center justify-center p-4",children:s.jsxs("div",{className:"text-sm text-red-500",children:["Error loading icons: ",n]})})})}):s.jsx(Xe,{className:"left-18",children:s.jsxs("div",{className:"flex w-96 flex-col gap-3 p-3",children:[s.jsx("div",{className:"sticky top-0 z-10 bg-[#141925] pb-1",children:s.jsxs("div",{className:"relative",children:[s.jsx(Oi,{className:"text-muted-foreground absolute top-1/2 left-3 size-4 -translate-y-1/2"}),s.jsx(Fe,{placeholder:"Search icons...",value:i,onChange:o=>r(o.target.value),className:yd})]})}),s.jsx(it,{mode:"wait",initial:!1,children:a?s.jsx(ze.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},transition:{duration:.18,ease:"easeOut"},children:s.jsx(Md,{sections:t,searchQuery:i})},"search"):s.jsx(ze.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},transition:{duration:.18,ease:"easeOut"},children:s.jsx(zd,{sections:t})},"list")})]})})}/*!
|
|
69
69
|
* Flickr's Justified Gallery [fjGallery] v2.2.0 (https://flickr-justified-gallery.nkdev.info)
|
|
70
70
|
* Copyright 2024 nK <https://nkdev.info>
|
|
71
71
|
* Licensed under MIT (https://github.com/nk-o/flickr-justified-gallery/blob/master/LICENSE)
|
|
72
|
-
*/function Bd(t,e,n){var i=n||{},r=i.noTrailing,a=r===void 0?!1:r,o=i.noLeading,c=o===void 0?!1:o,l=i.debounceMode,u=l===void 0?void 0:l,m,d=!1,h=0;function x(){m&&clearTimeout(m)}function N(g){var v=g||{},b=v.upcomingOnly,p=b===void 0?!1:b;x(),d=!p}function f(){for(var g=arguments.length,v=new Array(g),b=0;b<g;b++)v[b]=arguments[b];var p=this,w=Date.now()-h;if(d)return;function S(){h=Date.now(),e.apply(p,v)}function I(){m=void 0}!c&&u&&!m&&S(),x(),u===void 0&&w>t?c?(h=Date.now(),a||(m=setTimeout(u?I:S,t))):S():a!==!0&&(m=setTimeout(u?I:S,u===void 0?t-w:t))}return f.cancel=N,f}function _d(t,e,n){var i={},r=i.atBegin,a=r===void 0?!1:r;return Bd(t,e,{debounceMode:a!==!1})}var
|
|
72
|
+
*/function Bd(t,e,n){var i=n||{},r=i.noTrailing,a=r===void 0?!1:r,o=i.noLeading,c=o===void 0?!1:o,l=i.debounceMode,u=l===void 0?void 0:l,m,d=!1,h=0;function x(){m&&clearTimeout(m)}function N(g){var v=g||{},b=v.upcomingOnly,p=b===void 0?!1:b;x(),d=!p}function f(){for(var g=arguments.length,v=new Array(g),b=0;b<g;b++)v[b]=arguments[b];var p=this,w=Date.now()-h;if(d)return;function S(){h=Date.now(),e.apply(p,v)}function I(){m=void 0}!c&&u&&!m&&S(),x(),u===void 0&&w>t?c?(h=Date.now(),a||(m=setTimeout(u?I:S,t))):S():a!==!0&&(m=setTimeout(u?I:S,u===void 0?t-w:t))}return f.cancel=N,f}function _d(t,e,n){var i={},r=i.atBegin,a=r===void 0?!1:r;return Bd(t,e,{debounceMode:a!==!1})}var tr=function(e){var n=[],i=null,r=function(){for(var o=arguments.length,c=new Array(o),l=0;l<o;l++)c[l]=arguments[l];n=c,!i&&(i=requestAnimationFrame(function(){i=null,e.apply(void 0,n)}))};return r.cancel=function(){i&&(cancelAnimationFrame(i),i=null)},r};function Pd(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}const sr=function(t){this.index=t.index,this.top=t.top,this.left=t.left,this.width=t.width,this.spacing=t.spacing,this.targetRowHeight=t.targetRowHeight,this.targetRowHeightTolerance=t.targetRowHeightTolerance,this.minAspectRatio=this.width/t.targetRowHeight*(1-t.targetRowHeightTolerance),this.maxAspectRatio=this.width/t.targetRowHeight*(1+t.targetRowHeightTolerance),this.edgeCaseMinRowHeight=t.edgeCaseMinRowHeight,this.edgeCaseMaxRowHeight=t.edgeCaseMaxRowHeight,this.widowLayoutStyle=t.widowLayoutStyle,this.isBreakoutRow=t.isBreakoutRow,this.items=[],this.height=0};sr.prototype={addItem:function(t){const e=this.items.concat(t),n=this.width-(e.length-1)*this.spacing,i=e.reduce(function(l,u){return l+u.aspectRatio},0),r=n/this.targetRowHeight;let a,o,c;return this.isBreakoutRow&&this.items.length===0&&t.aspectRatio>=1?(this.items.push(t),this.completeLayout(n/t.aspectRatio,"justify"),!0):i<this.minAspectRatio?(this.items.push(Object.assign({},t)),!0):i>this.maxAspectRatio?this.items.length===0?(this.items.push(Object.assign({},t)),this.completeLayout(n/i,"justify"),!0):(a=this.width-(this.items.length-1)*this.spacing,o=this.items.reduce(function(l,u){return l+u.aspectRatio},0),c=a/this.targetRowHeight,Math.abs(i-r)>Math.abs(o-c)?(this.completeLayout(a/o,"justify"),!1):(this.items.push(Object.assign({},t)),this.completeLayout(n/i,"justify"),!0)):(this.items.push(Object.assign({},t)),this.completeLayout(n/i,"justify"),!0)},isLayoutComplete:function(){return this.height>0},completeLayout:function(t,e){let n=this.left;const i=this.width-(this.items.length-1)*this.spacing;let r,a,o,c,l,u;(typeof e>"u"||["justify","center","left"].indexOf(e)<0)&&(e="left"),a=Math.max(this.edgeCaseMinRowHeight,Math.min(t,this.edgeCaseMaxRowHeight)),t!==a?(this.height=a,r=i/a/(i/t)):(this.height=t,r=1),this.items.forEach(function(m){m.row=this.index,m.top=this.top,m.width=m.aspectRatio*this.height*r,m.height=this.height,m.left=n,n+=m.width+this.spacing},this),e==="justify"?(n-=this.spacing+this.left,o=(n-this.width)/this.items.length,c=this.items.map(function(m,d){return Math.round((d+1)*o)}),this.items.length===1?(l=this.items[0],l.width-=Math.round(o)):this.items.forEach(function(m,d){d>0?(m.left-=c[d-1],m.width-=c[d]-c[d-1]):m.width-=c[d]})):e==="center"&&(u=(this.width-n)/2,this.items.forEach(function(m){m.left+=u+this.spacing},this))},forceComplete:function(t,e){typeof e=="number"?this.completeLayout(e,this.widowLayoutStyle):this.completeLayout(this.targetRowHeight,this.widowLayoutStyle)},getItems:function(){return this.items}};/*!
|
|
73
73
|
* Copyright 2019 SmugMug, Inc. | Copyright 2024 nK
|
|
74
74
|
* Licensed under the terms of the MIT license. Please see LICENSE file in the project root for terms.
|
|
75
75
|
* @license
|
|
76
|
-
*/function Ls(t,e){let n;return t.fullWidthBreakoutRowCadence!==!1&&(e._rows.length+1)%t.fullWidthBreakoutRowCadence===0&&(n=!0),new
|
|
76
|
+
*/function Ls(t,e){let n;return t.fullWidthBreakoutRowCadence!==!1&&(e._rows.length+1)%t.fullWidthBreakoutRowCadence===0&&(n=!0),new sr({index:e._rows.length,top:e._containerHeight,left:t.containerPadding.left,width:t.containerWidth-t.containerPadding.left-t.containerPadding.right,spacing:t.boxSpacing.horizontal,targetRowHeight:t.targetRowHeight,targetRowHeightTolerance:t.targetRowHeightTolerance,edgeCaseMinRowHeight:t.edgeCaseMinRowHeight*t.targetRowHeight,edgeCaseMaxRowHeight:t.edgeCaseMaxRowHeight*t.targetRowHeight,isBreakoutRow:n,widowLayoutStyle:t.widowLayoutStyle})}function As(t,e,n){return e._rows.push(n),e._layoutItems=e._layoutItems.concat(n.getItems()),e._containerHeight+=n.height+t.boxSpacing.vertical,n.items}function Hd(t,e,n){let i=[],r,a,o;return t.forceAspectRatio&&n.forEach(function(c){c.forcedAspectRatio=!0,c.aspectRatio=t.forceAspectRatio}),n.some(function(c,l){if(isNaN(c.aspectRatio))throw new Error("Item "+l+" has an invalid aspect ratio");if(a||(a=Ls(t,e)),r=a.addItem(c),a.isLayoutComplete()){if(i=i.concat(As(t,e,a)),e._rows.length>=t.maxNumRows)return a=null,!0;if(a=Ls(t,e),!r&&(r=a.addItem(c),a.isLayoutComplete())){if(i=i.concat(As(t,e,a)),e._rows.length>=t.maxNumRows)return a=null,!0;a=Ls(t,e)}}}),a&&a.getItems().length&&t.showWidows&&(e._rows.length?(e._rows[e._rows.length-1].isBreakoutRow?o=e._rows[e._rows.length-1].targetRowHeight:o=e._rows[e._rows.length-1].height,a.forceComplete(!1,o)):a.forceComplete(!1),i=i.concat(As(t,e,a)),t._widowCount=a.getItems().length),e._containerHeight=e._containerHeight-t.boxSpacing.vertical,e._containerHeight=e._containerHeight+t.containerPadding.bottom,{containerHeight:e._containerHeight,widowCount:t._widowCount,boxes:e._layoutItems}}function $d(t,e){let n={};const i={},r={containerWidth:1060,containerPadding:10,boxSpacing:10,targetRowHeight:320,targetRowHeightTolerance:.25,edgeCaseMinRowHeight:.5,edgeCaseMaxRowHeight:2.5,maxNumRows:Number.POSITIVE_INFINITY,forceAspectRatio:!1,showWidows:!0,fullWidthBreakoutRowCadence:!1,widowLayoutStyle:"left"},a={},o={};return e=e||{},n=Object.assign(r,e),a.top=isNaN(parseFloat(n.containerPadding.top))?n.containerPadding:n.containerPadding.top,a.right=isNaN(parseFloat(n.containerPadding.right))?n.containerPadding:n.containerPadding.right,a.bottom=isNaN(parseFloat(n.containerPadding.bottom))?n.containerPadding:n.containerPadding.bottom,a.left=isNaN(parseFloat(n.containerPadding.left))?n.containerPadding:n.containerPadding.left,o.horizontal=isNaN(parseFloat(n.boxSpacing.horizontal))?n.boxSpacing:n.boxSpacing.horizontal,o.vertical=isNaN(parseFloat(n.boxSpacing.vertical))?n.boxSpacing:n.boxSpacing.vertical,n.containerPadding=a,n.boxSpacing=o,i._layoutItems=[],i._awakeItems=[],i._inViewportItems=[],i._leadingOrphans=[],i._trailingOrphans=[],i._containerHeight=n.containerPadding.top,i._rows=[],i._orphans=[],n._widowCount=0,Hd(n,i,t.map(function(c){return c.width&&c.height?{aspectRatio:c.width/c.height}:{aspectRatio:c}}))}var Wd=$d,Gd=Pd(Wd);function qd(t){document.readyState==="complete"||document.readyState==="interactive"?t():document.addEventListener("DOMContentLoaded",t,{capture:!0,once:!0,passive:!0})}let Rt;typeof window<"u"?Rt=window:typeof global<"u"?Rt=global:typeof self<"u"?Rt=self:Rt={};var kt=Rt;function Ud(t,e){let n,i=!1,r=!1;const a=()=>{if(i){e(i);return}t.naturalWidth&&(i={width:t.naturalWidth,height:t.naturalHeight},e(i),clearInterval(n),r&&m())},o=()=>{a()},c=()=>{a()},l=()=>{t.naturalWidth>0&&a()},u=()=>{r=!0,t.addEventListener("load",o),t.addEventListener("error",c)},m=()=>{r=!1,t.removeEventListener("load",o),t.removeEventListener("error",c)};l(),i||(u(),n=setInterval(l,100))}const ns=[],Gt=tr(()=>{ns.forEach(t=>{t.resize()})});kt.addEventListener("resize",Gt);kt.addEventListener("orientationchange",Gt);kt.addEventListener("load",Gt);qd(()=>{Gt()});let Vn=0;class nr{constructor(e,n){const i=this;i.instanceID=Vn,Vn+=1,i.$container=e,i.images=[],i.defaults={itemSelector:".fj-gallery-item",imageSelector:"img",gutter:10,rowHeight:320,rowHeightTolerance:.25,maxRowsCount:Number.POSITIVE_INFINITY,edgeCaseMinRowHeight:.5,edgeCaseMaxRowHeight:2.5,lastRow:"left",transitionDuration:"0.3s",calculateItemsHeight:!1,resizeDebounce:100,isRtl:i.css(i.$container,"direction")==="rtl",onInit:null,onDestroy:null,onAppendImages:null,onBeforeJustify:null,onJustify:null};const r=i.$container.dataset||{},a={};Object.keys(r).forEach(o=>{const c=o.substr(0,1).toLowerCase()+o.substr(1);c&&typeof i.defaults[c]<"u"&&(a[c]=r[o])}),i.options={...i.defaults,...a,...n},i.pureOptions={...i.options},i.resize=_d(i.options.resizeDebounce,i.resize),i.justify=tr(i.justify.bind(i)),i.init()}css(e,n){return typeof n=="string"?kt.getComputedStyle(e).getPropertyValue(n):(Object.keys(n).forEach(i=>{e.style[i]=n[i]}),e)}applyTransition(e,n){const i=this;i.onTransitionEnd(e)(),i.css(e,{"transition-property":n.join(", "),"transition-duration":i.options.transitionDuration}),e.addEventListener("transitionend",i.onTransitionEnd(e,n),!1)}onTransitionEnd(e){const n=this;return()=>{n.css(e,{"transition-property":"","transition-duration":""}),e.removeEventListener("transitionend",n.onTransitionEnd(e))}}addToFjGalleryList(){ns.push(this),Gt()}removeFromFjGalleryList(){const e=this;ns.forEach((n,i)=>{n.instanceID===e.instanceID&&ns.splice(i,1)})}init(){const e=this;e.appendImages(e.$container.querySelectorAll(e.options.itemSelector)),e.addToFjGalleryList(),e.options.onInit&&e.options.onInit.call(e)}appendImages(e){const n=this;kt.jQuery&&e instanceof kt.jQuery&&(e=e.get()),!(!e||!e.length)&&(e.forEach(i=>{if(i&&!i.fjGalleryImage&&i.querySelector){const r=i.querySelector(n.options.imageSelector);if(r){i.fjGalleryImage=n;const a={$item:i,$image:r,width:parseFloat(r.getAttribute("width"))||!1,height:parseFloat(r.getAttribute("height"))||!1,loadSizes(){const o=this;Ud(r,c=>{(o.width!==c.width||o.height!==c.height)&&(o.width=c.width,o.height=c.height,n.resize())})}};a.loadSizes(),n.images.push(a)}}}),n.options.onAppendImages&&n.options.onAppendImages.call(n,[e]),n.justify())}justify(){const e=this,n=[];e.justifyCount=(e.justifyCount||0)+1,e.options.onBeforeJustify&&e.options.onBeforeJustify.call(e),e.images.forEach(l=>{l.width&&l.height&&n.push(l.width/l.height)});const i={containerWidth:e.$container.getBoundingClientRect().width,containerPadding:{top:parseFloat(e.css(e.$container,"padding-top"))||0,right:parseFloat(e.css(e.$container,"padding-right"))||0,bottom:parseFloat(e.css(e.$container,"padding-bottom"))||0,left:parseFloat(e.css(e.$container,"padding-left"))||0},boxSpacing:e.options.gutter,targetRowHeight:e.options.rowHeight,targetRowHeightTolerance:e.options.rowHeightTolerance,maxNumRows:e.options.maxRowsCount,edgeCaseMinRowHeight:e.options.edgeCaseMinRowHeight,edgeCaseMaxRowHeight:e.options.edgeCaseMaxRowHeight,showWidows:e.options.lastRow!=="hide"},r=Gd(n,i);if(r.widowCount&&(e.options.lastRow==="center"||e.options.lastRow==="right")){const l=r.boxes[r.boxes.length-1];let u=i.containerWidth-l.width-l.left;e.options.lastRow==="center"&&(u/=2),e.options.lastRow==="right"&&(u-=i.containerPadding.right);for(let m=1;m<=r.widowCount;m+=1)r.boxes[r.boxes.length-m].left=r.boxes[r.boxes.length-m].left+u}e.options.isRtl&&r.boxes.forEach((l,u)=>{r.boxes[u].left=i.containerWidth-r.boxes[u].left-r.boxes[u].width-i.containerPadding.right+i.containerPadding.left});let a=0,o=0;const c={};e.images.forEach((l,u)=>{if(r.boxes[a]&&l.width&&l.height){if(e.options.calculateItemsHeight&&typeof c[r.boxes[a].row]>"u"&&Object.keys(c).length&&(o+=c[Object.keys(c).pop()]-r.boxes[u-1].height),e.options.transitionDuration&&e.justifyCount>1&&e.applyTransition(l.$item,["transform"]),e.css(l.$item,{display:"",position:"absolute",transform:`translateX(${r.boxes[a].left}px) translateY(${r.boxes[a].top+o}px) translateZ(0)`,width:`${r.boxes[a].width}px`}),e.options.calculateItemsHeight){const m=l.$item.getBoundingClientRect();(typeof c[r.boxes[a].row]>"u"||c[r.boxes[a].row]<m.height)&&(c[r.boxes[a].row]=m.height)}a+=1}else e.css(l.$item,{display:"none"})}),e.options.calculateItemsHeight&&Object.keys(c).length&&(o+=c[Object.keys(c).pop()]-r.boxes[r.boxes.length-1].height),e.options.transitionDuration&&e.applyTransition(e.$container,["height"]),e.css(e.$container,{height:`${r.containerHeight+o}px`}),e.options.onJustify&&e.options.onJustify.call(e)}updateOptions(e){const n=this;n.options={...n.options,...e},n.justify()}destroy(){const e=this;e.removeFromFjGalleryList(),e.justifyCount=0,e.options.onDestroy&&e.options.onDestroy.call(e),e.css(e.$container,{height:"",transition:""}),e.images.forEach(n=>{e.css(n.$item,{position:"",transform:"",transition:"",width:"",height:""})}),e.images.forEach(n=>{delete n.$item.fjGalleryImage}),delete e.$container.fjGallery}resize(){this.justify()}}const ir=function(t,e,...n){(typeof HTMLElement=="object"?t instanceof HTMLElement:t&&typeof t=="object"&&t!==null&&t.nodeType===1&&typeof t.nodeName=="string")&&(t=[t]);const i=t.length;let r=0,a;for(r;r<i;r+=1)if(typeof e=="object"||typeof e>"u"?t[r].fjGallery||(t[r].fjGallery=new nr(t[r],e)):t[r].fjGallery&&(a=t[r].fjGallery[e].apply(t[r].fjGallery,n)),typeof a<"u")return a;return t};ir.constructor=nr;/*! *****************************************************************************
|
|
77
77
|
Copyright (c) Microsoft Corporation.
|
|
78
78
|
|
|
79
79
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -104,7 +104,7 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
|
104
104
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
105
105
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
106
106
|
PERFORMANCE OF THIS SOFTWARE.
|
|
107
|
-
***************************************************************************** */var dt=function(){return dt=Object.assign||function(e){for(var n,i=1,r=arguments.length;i<r;i++){n=arguments[i];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},dt.apply(this,arguments)};function Kd(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;for(var i=Array(t),r=0,e=0;e<n;e++)for(var a=arguments[e],o=0,c=a.length;o<c;o++,r++)i[r]=a[o];return i}var pe={afterAppendSlide:"lgAfterAppendSlide",init:"lgInit",hasVideo:"lgHasVideo",containerResize:"lgContainerResize",updateSlides:"lgUpdateSlides",afterAppendSubHtml:"lgAfterAppendSubHtml",beforeOpen:"lgBeforeOpen",afterOpen:"lgAfterOpen",slideItemLoad:"lgSlideItemLoad",beforeSlide:"lgBeforeSlide",afterSlide:"lgAfterSlide",posterClick:"lgPosterClick",dragStart:"lgDragStart",dragMove:"lgDragMove",dragEnd:"lgDragEnd",beforeNextSlide:"lgBeforeNextSlide",beforePrevSlide:"lgBeforePrevSlide",beforeClose:"lgBeforeClose",afterClose:"lgAfterClose"},Xd={mode:"lg-slide",easing:"ease",speed:400,licenseKey:"0000-0000-000-0000",height:"100%",width:"100%",addClass:"",startClass:"lg-start-zoom",backdropDuration:300,container:"",startAnimationDuration:400,zoomFromOrigin:!0,hideBarsDelay:0,showBarsAfter:1e4,slideDelay:0,supportLegacyBrowser:!0,allowMediaOverlap:!1,videoMaxSize:"1280-720",loadYouTubePoster:!0,defaultCaptionHeight:0,ariaLabelledby:"",ariaDescribedby:"",resetScrollPosition:!0,hideScrollbar:!1,closable:!0,swipeToClose:!0,closeOnTap:!0,showCloseIcon:!0,showMaximizeIcon:!1,loop:!0,escKey:!0,keyPress:!0,trapFocus:!0,controls:!0,slideEndAnimation:!0,hideControlOnEnd:!1,mousewheel:!1,getCaptionFromTitleOrAlt:!0,appendSubHtmlTo:".lg-sub-html",subHtmlSelectorRelative:!1,preload:2,numberOfSlideItemsInDom:10,selector:"",selectWithin:"",nextHtml:"",prevHtml:"",index:0,iframeWidth:"100%",iframeHeight:"100%",iframeMaxWidth:"100%",iframeMaxHeight:"100%",download:!0,counter:!0,appendCounterTo:".lg-toolbar",swipeThreshold:50,enableSwipe:!0,enableDrag:!0,dynamic:!1,dynamicEl:[],extraProps:[],exThumbImage:"",isMobile:void 0,mobileSettings:{controls:!1,showCloseIcon:!1,download:!1},plugins:[],strings:{closeGallery:"Close gallery",toggleMaximize:"Toggle maximize",previousSlide:"Previous slide",nextSlide:"Next slide",download:"Download",playVideo:"Play video",mediaLoadingFailed:"Oops... Failed to load content..."}};function Yd(){(function(){if(typeof window.CustomEvent=="function")return!1;function t(e,n){n=n||{bubbles:!1,cancelable:!1,detail:null};var i=document.createEvent("CustomEvent");return i.initCustomEvent(e,n.bubbles,n.cancelable,n.detail),i}window.CustomEvent=t})(),(function(){Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector)})()}var ir=(function(){function t(e){return this.cssVenderPrefixes=["TransitionDuration","TransitionTimingFunction","Transform","Transition"],this.selector=this._getSelector(e),this.firstElement=this._getFirstEl(),this}return t.generateUUID=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var n=Math.random()*16|0,i=e=="x"?n:n&3|8;return i.toString(16)})},t.prototype._getSelector=function(e,n){if(n===void 0&&(n=document),typeof e!="string")return e;n=n||document;var i=e.substring(0,1);return i==="#"?n.querySelector(e):n.querySelectorAll(e)},t.prototype._each=function(e){return this.selector?(this.selector.length!==void 0?[].forEach.call(this.selector,e):e(this.selector,0),this):this},t.prototype._setCssVendorPrefix=function(e,n,i){var r=n.replace(/-([a-z])/gi,function(a,o){return o.toUpperCase()});this.cssVenderPrefixes.indexOf(r)!==-1?(e.style[r.charAt(0).toLowerCase()+r.slice(1)]=i,e.style["webkit"+r]=i,e.style["moz"+r]=i,e.style["ms"+r]=i,e.style["o"+r]=i):e.style[r]=i},t.prototype._getFirstEl=function(){return this.selector&&this.selector.length!==void 0?this.selector[0]:this.selector},t.prototype.isEventMatched=function(e,n){var i=n.split(".");return e.split(".").filter(function(r){return r}).every(function(r){return i.indexOf(r)!==-1})},t.prototype.attr=function(e,n){return n===void 0?this.firstElement?this.firstElement.getAttribute(e):"":(this._each(function(i){i.setAttribute(e,n)}),this)},t.prototype.find=function(e){return V(this._getSelector(e,this.selector))},t.prototype.first=function(){return this.selector&&this.selector.length!==void 0?V(this.selector[0]):V(this.selector)},t.prototype.eq=function(e){return V(this.selector[e])},t.prototype.parent=function(){return V(this.selector.parentElement)},t.prototype.get=function(){return this._getFirstEl()},t.prototype.removeAttr=function(e){var n=e.split(" ");return this._each(function(i){n.forEach(function(r){return i.removeAttribute(r)})}),this},t.prototype.wrap=function(e){if(!this.firstElement)return this;var n=document.createElement("div");return n.className=e,this.firstElement.parentNode.insertBefore(n,this.firstElement),this.firstElement.parentNode.removeChild(this.firstElement),n.appendChild(this.firstElement),this},t.prototype.addClass=function(e){return e===void 0&&(e=""),this._each(function(n){e.split(" ").forEach(function(i){i&&n.classList.add(i)})}),this},t.prototype.removeClass=function(e){return this._each(function(n){e.split(" ").forEach(function(i){i&&n.classList.remove(i)})}),this},t.prototype.hasClass=function(e){return this.firstElement?this.firstElement.classList.contains(e):!1},t.prototype.hasAttribute=function(e){return this.firstElement?this.firstElement.hasAttribute(e):!1},t.prototype.toggleClass=function(e){return this.firstElement?(this.hasClass(e)?this.removeClass(e):this.addClass(e),this):this},t.prototype.css=function(e,n){var i=this;return this._each(function(r){i._setCssVendorPrefix(r,e,n)}),this},t.prototype.on=function(e,n){var i=this;return this.selector?(e.split(" ").forEach(function(r){Array.isArray(t.eventListeners[r])||(t.eventListeners[r]=[]),t.eventListeners[r].push(n),i.selector.addEventListener(r.split(".")[0],n)}),this):this},t.prototype.once=function(e,n){var i=this;return this.on(e,function(){i.off(e),n(e)}),this},t.prototype.off=function(e){var n=this;return this.selector?(Object.keys(t.eventListeners).forEach(function(i){n.isEventMatched(e,i)&&(t.eventListeners[i].forEach(function(r){n.selector.removeEventListener(i.split(".")[0],r)}),t.eventListeners[i]=[])}),this):this},t.prototype.trigger=function(e,n){if(!this.firstElement)return this;var i=new CustomEvent(e.split(".")[0],{detail:n||null});return this.firstElement.dispatchEvent(i),this},t.prototype.load=function(e){var n=this;return fetch(e).then(function(i){return i.text()}).then(function(i){n.selector.innerHTML=i}),this},t.prototype.html=function(e){return e===void 0?this.firstElement?this.firstElement.innerHTML:"":(this._each(function(n){n.innerHTML=e}),this)},t.prototype.append=function(e){return this._each(function(n){typeof e=="string"?n.insertAdjacentHTML("beforeend",e):n.appendChild(e)}),this},t.prototype.prepend=function(e){return this._each(function(n){typeof e=="string"?n.insertAdjacentHTML("afterbegin",e):e instanceof HTMLElement&&n.insertBefore(e.cloneNode(!0),n.firstChild)}),this},t.prototype.remove=function(){return this._each(function(e){e.parentNode.removeChild(e)}),this},t.prototype.empty=function(){return this._each(function(e){e.innerHTML=""}),this},t.prototype.scrollTop=function(e){return e!==void 0?(document.body.scrollTop=e,document.documentElement.scrollTop=e,this):window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0},t.prototype.scrollLeft=function(e){return e!==void 0?(document.body.scrollLeft=e,document.documentElement.scrollLeft=e,this):window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0},t.prototype.offset=function(){if(!this.firstElement)return{left:0,top:0};var e=this.firstElement.getBoundingClientRect(),n=V("body").style().marginLeft;return{left:e.left-parseFloat(n)+this.scrollLeft(),top:e.top+this.scrollTop()}},t.prototype.style=function(){return this.firstElement?this.firstElement.currentStyle||window.getComputedStyle(this.firstElement):{}},t.prototype.width=function(){var e=this.style();return this.firstElement.clientWidth-parseFloat(e.paddingLeft)-parseFloat(e.paddingRight)},t.prototype.height=function(){var e=this.style();return this.firstElement.clientHeight-parseFloat(e.paddingTop)-parseFloat(e.paddingBottom)},t.eventListeners={},t})();function V(t){return Yd(),new ir(t)}var Qd=["src","sources","subHtml","subHtmlUrl","html","video","poster","slideName","responsive","srcset","sizes","iframe","downloadUrl","download","width","facebookShareUrl","tweetText","iframeTitle","twitterShareUrl","pinterestShareUrl","pinterestText","fbHtml","disqusIdentifier","disqusUrl"];function Zd(t){return t==="href"?"src":(t=t.replace("data-",""),t=t.charAt(0).toLowerCase()+t.slice(1),t=t.replace(/-([a-z])/g,function(e){return e[1].toUpperCase()}),t)}var Se={fetchCaptionFromUrl:function(t,e,n){fetch(t).then(function(i){return i.text()}).then(function(i){if(n==="append"){var r='<div class="lg-sub-html">'+i+"</div>";e.append(r)}else e.html(i)})},getSize:function(t,e,n,i){n===void 0&&(n=0);var r=V(t),a=r.attr("data-lg-size")||i;if(a){var o=a.split(",");if(o[1])for(var c=window.innerWidth,l=0;l<o.length;l++){var u=o[l],m=parseInt(u.split("-")[2],10);if(m>c){a=u;break}l===o.length-1&&(a=u)}var d=a.split("-"),h=parseInt(d[0],10),x=parseInt(d[1],10),N=e.width(),f=e.height()-n,g=Math.min(N,h),v=Math.min(f,x),b=Math.min(g/h,v/x);return{width:h*b,height:x*b}}},getTransform:function(t,e,n,i,r){if(r){var a=V(t).find("img").first();if(a.get()){var o=e.get().getBoundingClientRect(),c=o.width,l=e.height()-(n+i),u=a.width(),m=a.height(),d=a.style(),h=(c-u)/2-a.offset().left+(parseFloat(d.paddingLeft)||0)+(parseFloat(d.borderLeft)||0)+V(window).scrollLeft()+o.left,x=(l-m)/2-a.offset().top+(parseFloat(d.paddingTop)||0)+(parseFloat(d.borderTop)||0)+V(window).scrollTop()+n,N=u/r.width,f=m/r.height,g="translate3d("+(h*=-1)+"px, "+(x*=-1)+"px, 0) scale3d("+N+", "+f+", 1)";return g}}},getIframeMarkup:function(t,e,n,i,r,a){var o=a?'title="'+a+'"':"";return'<div class="lg-media-cont lg-has-iframe" style="width:'+t+"; max-width:"+n+"; height: "+e+"; max-height:"+i+`">
|
|
107
|
+
***************************************************************************** */var dt=function(){return dt=Object.assign||function(e){for(var n,i=1,r=arguments.length;i<r;i++){n=arguments[i];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},dt.apply(this,arguments)};function Kd(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;for(var i=Array(t),r=0,e=0;e<n;e++)for(var a=arguments[e],o=0,c=a.length;o<c;o++,r++)i[r]=a[o];return i}var pe={afterAppendSlide:"lgAfterAppendSlide",init:"lgInit",hasVideo:"lgHasVideo",containerResize:"lgContainerResize",updateSlides:"lgUpdateSlides",afterAppendSubHtml:"lgAfterAppendSubHtml",beforeOpen:"lgBeforeOpen",afterOpen:"lgAfterOpen",slideItemLoad:"lgSlideItemLoad",beforeSlide:"lgBeforeSlide",afterSlide:"lgAfterSlide",posterClick:"lgPosterClick",dragStart:"lgDragStart",dragMove:"lgDragMove",dragEnd:"lgDragEnd",beforeNextSlide:"lgBeforeNextSlide",beforePrevSlide:"lgBeforePrevSlide",beforeClose:"lgBeforeClose",afterClose:"lgAfterClose"},Xd={mode:"lg-slide",easing:"ease",speed:400,licenseKey:"0000-0000-000-0000",height:"100%",width:"100%",addClass:"",startClass:"lg-start-zoom",backdropDuration:300,container:"",startAnimationDuration:400,zoomFromOrigin:!0,hideBarsDelay:0,showBarsAfter:1e4,slideDelay:0,supportLegacyBrowser:!0,allowMediaOverlap:!1,videoMaxSize:"1280-720",loadYouTubePoster:!0,defaultCaptionHeight:0,ariaLabelledby:"",ariaDescribedby:"",resetScrollPosition:!0,hideScrollbar:!1,closable:!0,swipeToClose:!0,closeOnTap:!0,showCloseIcon:!0,showMaximizeIcon:!1,loop:!0,escKey:!0,keyPress:!0,trapFocus:!0,controls:!0,slideEndAnimation:!0,hideControlOnEnd:!1,mousewheel:!1,getCaptionFromTitleOrAlt:!0,appendSubHtmlTo:".lg-sub-html",subHtmlSelectorRelative:!1,preload:2,numberOfSlideItemsInDom:10,selector:"",selectWithin:"",nextHtml:"",prevHtml:"",index:0,iframeWidth:"100%",iframeHeight:"100%",iframeMaxWidth:"100%",iframeMaxHeight:"100%",download:!0,counter:!0,appendCounterTo:".lg-toolbar",swipeThreshold:50,enableSwipe:!0,enableDrag:!0,dynamic:!1,dynamicEl:[],extraProps:[],exThumbImage:"",isMobile:void 0,mobileSettings:{controls:!1,showCloseIcon:!1,download:!1},plugins:[],strings:{closeGallery:"Close gallery",toggleMaximize:"Toggle maximize",previousSlide:"Previous slide",nextSlide:"Next slide",download:"Download",playVideo:"Play video",mediaLoadingFailed:"Oops... Failed to load content..."}};function Yd(){(function(){if(typeof window.CustomEvent=="function")return!1;function t(e,n){n=n||{bubbles:!1,cancelable:!1,detail:null};var i=document.createEvent("CustomEvent");return i.initCustomEvent(e,n.bubbles,n.cancelable,n.detail),i}window.CustomEvent=t})(),(function(){Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector)})()}var rr=(function(){function t(e){return this.cssVenderPrefixes=["TransitionDuration","TransitionTimingFunction","Transform","Transition"],this.selector=this._getSelector(e),this.firstElement=this._getFirstEl(),this}return t.generateUUID=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var n=Math.random()*16|0,i=e=="x"?n:n&3|8;return i.toString(16)})},t.prototype._getSelector=function(e,n){if(n===void 0&&(n=document),typeof e!="string")return e;n=n||document;var i=e.substring(0,1);return i==="#"?n.querySelector(e):n.querySelectorAll(e)},t.prototype._each=function(e){return this.selector?(this.selector.length!==void 0?[].forEach.call(this.selector,e):e(this.selector,0),this):this},t.prototype._setCssVendorPrefix=function(e,n,i){var r=n.replace(/-([a-z])/gi,function(a,o){return o.toUpperCase()});this.cssVenderPrefixes.indexOf(r)!==-1?(e.style[r.charAt(0).toLowerCase()+r.slice(1)]=i,e.style["webkit"+r]=i,e.style["moz"+r]=i,e.style["ms"+r]=i,e.style["o"+r]=i):e.style[r]=i},t.prototype._getFirstEl=function(){return this.selector&&this.selector.length!==void 0?this.selector[0]:this.selector},t.prototype.isEventMatched=function(e,n){var i=n.split(".");return e.split(".").filter(function(r){return r}).every(function(r){return i.indexOf(r)!==-1})},t.prototype.attr=function(e,n){return n===void 0?this.firstElement?this.firstElement.getAttribute(e):"":(this._each(function(i){i.setAttribute(e,n)}),this)},t.prototype.find=function(e){return V(this._getSelector(e,this.selector))},t.prototype.first=function(){return this.selector&&this.selector.length!==void 0?V(this.selector[0]):V(this.selector)},t.prototype.eq=function(e){return V(this.selector[e])},t.prototype.parent=function(){return V(this.selector.parentElement)},t.prototype.get=function(){return this._getFirstEl()},t.prototype.removeAttr=function(e){var n=e.split(" ");return this._each(function(i){n.forEach(function(r){return i.removeAttribute(r)})}),this},t.prototype.wrap=function(e){if(!this.firstElement)return this;var n=document.createElement("div");return n.className=e,this.firstElement.parentNode.insertBefore(n,this.firstElement),this.firstElement.parentNode.removeChild(this.firstElement),n.appendChild(this.firstElement),this},t.prototype.addClass=function(e){return e===void 0&&(e=""),this._each(function(n){e.split(" ").forEach(function(i){i&&n.classList.add(i)})}),this},t.prototype.removeClass=function(e){return this._each(function(n){e.split(" ").forEach(function(i){i&&n.classList.remove(i)})}),this},t.prototype.hasClass=function(e){return this.firstElement?this.firstElement.classList.contains(e):!1},t.prototype.hasAttribute=function(e){return this.firstElement?this.firstElement.hasAttribute(e):!1},t.prototype.toggleClass=function(e){return this.firstElement?(this.hasClass(e)?this.removeClass(e):this.addClass(e),this):this},t.prototype.css=function(e,n){var i=this;return this._each(function(r){i._setCssVendorPrefix(r,e,n)}),this},t.prototype.on=function(e,n){var i=this;return this.selector?(e.split(" ").forEach(function(r){Array.isArray(t.eventListeners[r])||(t.eventListeners[r]=[]),t.eventListeners[r].push(n),i.selector.addEventListener(r.split(".")[0],n)}),this):this},t.prototype.once=function(e,n){var i=this;return this.on(e,function(){i.off(e),n(e)}),this},t.prototype.off=function(e){var n=this;return this.selector?(Object.keys(t.eventListeners).forEach(function(i){n.isEventMatched(e,i)&&(t.eventListeners[i].forEach(function(r){n.selector.removeEventListener(i.split(".")[0],r)}),t.eventListeners[i]=[])}),this):this},t.prototype.trigger=function(e,n){if(!this.firstElement)return this;var i=new CustomEvent(e.split(".")[0],{detail:n||null});return this.firstElement.dispatchEvent(i),this},t.prototype.load=function(e){var n=this;return fetch(e).then(function(i){return i.text()}).then(function(i){n.selector.innerHTML=i}),this},t.prototype.html=function(e){return e===void 0?this.firstElement?this.firstElement.innerHTML:"":(this._each(function(n){n.innerHTML=e}),this)},t.prototype.append=function(e){return this._each(function(n){typeof e=="string"?n.insertAdjacentHTML("beforeend",e):n.appendChild(e)}),this},t.prototype.prepend=function(e){return this._each(function(n){typeof e=="string"?n.insertAdjacentHTML("afterbegin",e):e instanceof HTMLElement&&n.insertBefore(e.cloneNode(!0),n.firstChild)}),this},t.prototype.remove=function(){return this._each(function(e){e.parentNode.removeChild(e)}),this},t.prototype.empty=function(){return this._each(function(e){e.innerHTML=""}),this},t.prototype.scrollTop=function(e){return e!==void 0?(document.body.scrollTop=e,document.documentElement.scrollTop=e,this):window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0},t.prototype.scrollLeft=function(e){return e!==void 0?(document.body.scrollLeft=e,document.documentElement.scrollLeft=e,this):window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0},t.prototype.offset=function(){if(!this.firstElement)return{left:0,top:0};var e=this.firstElement.getBoundingClientRect(),n=V("body").style().marginLeft;return{left:e.left-parseFloat(n)+this.scrollLeft(),top:e.top+this.scrollTop()}},t.prototype.style=function(){return this.firstElement?this.firstElement.currentStyle||window.getComputedStyle(this.firstElement):{}},t.prototype.width=function(){var e=this.style();return this.firstElement.clientWidth-parseFloat(e.paddingLeft)-parseFloat(e.paddingRight)},t.prototype.height=function(){var e=this.style();return this.firstElement.clientHeight-parseFloat(e.paddingTop)-parseFloat(e.paddingBottom)},t.eventListeners={},t})();function V(t){return Yd(),new rr(t)}var Qd=["src","sources","subHtml","subHtmlUrl","html","video","poster","slideName","responsive","srcset","sizes","iframe","downloadUrl","download","width","facebookShareUrl","tweetText","iframeTitle","twitterShareUrl","pinterestShareUrl","pinterestText","fbHtml","disqusIdentifier","disqusUrl"];function Zd(t){return t==="href"?"src":(t=t.replace("data-",""),t=t.charAt(0).toLowerCase()+t.slice(1),t=t.replace(/-([a-z])/g,function(e){return e[1].toUpperCase()}),t)}var Se={fetchCaptionFromUrl:function(t,e,n){fetch(t).then(function(i){return i.text()}).then(function(i){if(n==="append"){var r='<div class="lg-sub-html">'+i+"</div>";e.append(r)}else e.html(i)})},getSize:function(t,e,n,i){n===void 0&&(n=0);var r=V(t),a=r.attr("data-lg-size")||i;if(a){var o=a.split(",");if(o[1])for(var c=window.innerWidth,l=0;l<o.length;l++){var u=o[l],m=parseInt(u.split("-")[2],10);if(m>c){a=u;break}l===o.length-1&&(a=u)}var d=a.split("-"),h=parseInt(d[0],10),x=parseInt(d[1],10),N=e.width(),f=e.height()-n,g=Math.min(N,h),v=Math.min(f,x),b=Math.min(g/h,v/x);return{width:h*b,height:x*b}}},getTransform:function(t,e,n,i,r){if(r){var a=V(t).find("img").first();if(a.get()){var o=e.get().getBoundingClientRect(),c=o.width,l=e.height()-(n+i),u=a.width(),m=a.height(),d=a.style(),h=(c-u)/2-a.offset().left+(parseFloat(d.paddingLeft)||0)+(parseFloat(d.borderLeft)||0)+V(window).scrollLeft()+o.left,x=(l-m)/2-a.offset().top+(parseFloat(d.paddingTop)||0)+(parseFloat(d.borderTop)||0)+V(window).scrollTop()+n,N=u/r.width,f=m/r.height,g="translate3d("+(h*=-1)+"px, "+(x*=-1)+"px, 0) scale3d("+N+", "+f+", 1)";return g}}},getIframeMarkup:function(t,e,n,i,r,a){var o=a?'title="'+a+'"':"";return'<div class="lg-media-cont lg-has-iframe" style="width:'+t+"; max-width:"+n+"; height: "+e+"; max-height:"+i+`">
|
|
108
108
|
<iframe class="lg-object" frameborder="0" `+o+' src="'+r+`" allowfullscreen="true"></iframe>
|
|
109
109
|
</div>`},getImgMarkup:function(t,e,n,i,r,a){var o=i?'srcset="'+i+'"':"",c=r?'sizes="'+r+'"':"",l="<img "+n+" "+o+" "+c+' class="lg-object lg-image" data-index="'+t+'" src="'+e+'" />',u="";if(a){var m=typeof a=="string"?JSON.parse(a):a;u=m.map(function(d){var h="";return Object.keys(d).forEach(function(x){h+=" "+x+'="'+d[x]+'"'}),"<source "+h+"></source>"})}return""+u+l},getResponsiveSrc:function(t){for(var e=[],n=[],i="",r=0;r<t.length;r++){var a=t[r].split(" ");a[0]===""&&a.splice(0,1),n.push(a[0]),e.push(a[1])}for(var o=window.innerWidth,c=0;c<e.length;c++)if(parseInt(e[c],10)>o){i=n[c];break}return i},isImageLoaded:function(t){return!(!t||!t.complete||t.naturalWidth===0)},getVideoPosterMarkup:function(t,e,n,i,r){var a="";r&&r.youtube?a="lg-has-youtube":r&&r.vimeo?a="lg-has-vimeo":a="lg-has-html5";var o=e;return typeof e!="string"&&(o=e.outerHTML),'<div class="lg-video-cont '+a+'" style="'+n+`">
|
|
110
110
|
<div class="lg-video-play-button">
|
|
@@ -127,7 +127,7 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
127
127
|
</div>
|
|
128
128
|
`+o+`
|
|
129
129
|
<img class="lg-object lg-video-poster" src="`+t+`" />
|
|
130
|
-
</div>`},getFocusableElements:function(t){var e=t.querySelectorAll('a[href]:not([disabled]), button:not([disabled]), textarea:not([disabled]), input[type="text"]:not([disabled]), input[type="radio"]:not([disabled]), input[type="checkbox"]:not([disabled]), select:not([disabled])'),n=[].filter.call(e,function(i){var r=window.getComputedStyle(i);return r.display!=="none"&&r.visibility!=="hidden"});return n},getDynamicOptions:function(t,e,n,i){var r=[],a=Kd(Qd,e);return[].forEach.call(t,function(o){for(var c={},l=0;l<o.attributes.length;l++){var u=o.attributes[l];if(u.specified){var m=Zd(u.name),d="";a.indexOf(m)>-1&&(d=m),d&&(c[d]=u.value)}}var h=V(o),x=h.find("img").first().attr("alt"),N=h.attr("title"),f=i?h.attr(i):h.find("img").first().attr("src");c.thumb=f,n&&!c.subHtml&&(c.subHtml=N||x||""),c.alt=x||N||"",r.push(c)}),r},isMobile:function(){return/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)},isVideo:function(t,e,n){if(!t){if(e)return{html5:!0};console.error("lightGallery :- data-src is not provided on slide item "+(n+1)+". Please make sure the selector property is properly configured. More info - https://www.lightgalleryjs.com/demos/html-markup/");return}var i=t.match(/\/\/(?:www\.)?youtu(?:\.be|be\.com|be-nocookie\.com)\/(?:watch\?v=|embed\/)?([a-z0-9\-\_\%]+)([\&|?][\S]*)*/i),r=t.match(/\/\/(?:www\.)?(?:player\.)?vimeo.com\/(?:video\/)?([0-9a-z\-_]+)(.*)?/i),a=t.match(/https?:\/\/(.+)?(wistia\.com|wi\.st)\/(medias|embed)\/([0-9a-z\-_]+)(.*)/);if(i)return{youtube:i};if(r)return{vimeo:r};if(a)return{wistia:a}}},
|
|
130
|
+
</div>`},getFocusableElements:function(t){var e=t.querySelectorAll('a[href]:not([disabled]), button:not([disabled]), textarea:not([disabled]), input[type="text"]:not([disabled]), input[type="radio"]:not([disabled]), input[type="checkbox"]:not([disabled]), select:not([disabled])'),n=[].filter.call(e,function(i){var r=window.getComputedStyle(i);return r.display!=="none"&&r.visibility!=="hidden"});return n},getDynamicOptions:function(t,e,n,i){var r=[],a=Kd(Qd,e);return[].forEach.call(t,function(o){for(var c={},l=0;l<o.attributes.length;l++){var u=o.attributes[l];if(u.specified){var m=Zd(u.name),d="";a.indexOf(m)>-1&&(d=m),d&&(c[d]=u.value)}}var h=V(o),x=h.find("img").first().attr("alt"),N=h.attr("title"),f=i?h.attr(i):h.find("img").first().attr("src");c.thumb=f,n&&!c.subHtml&&(c.subHtml=N||x||""),c.alt=x||N||"",r.push(c)}),r},isMobile:function(){return/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)},isVideo:function(t,e,n){if(!t){if(e)return{html5:!0};console.error("lightGallery :- data-src is not provided on slide item "+(n+1)+". Please make sure the selector property is properly configured. More info - https://www.lightgalleryjs.com/demos/html-markup/");return}var i=t.match(/\/\/(?:www\.)?youtu(?:\.be|be\.com|be-nocookie\.com)\/(?:watch\?v=|embed\/)?([a-z0-9\-\_\%]+)([\&|?][\S]*)*/i),r=t.match(/\/\/(?:www\.)?(?:player\.)?vimeo.com\/(?:video\/)?([0-9a-z\-_]+)(.*)?/i),a=t.match(/https?:\/\/(.+)?(wistia\.com|wi\.st)\/(medias|embed)\/([0-9a-z\-_]+)(.*)/);if(i)return{youtube:i};if(r)return{vimeo:r};if(a)return{wistia:a}}},Kn=0,Jd=(function(){function t(e,n){if(this.lgOpened=!1,this.index=0,this.plugins=[],this.lGalleryOn=!1,this.lgBusy=!1,this.currentItemsInDom=[],this.prevScrollTop=0,this.bodyPaddingRight=0,this.isDummyImageRemoved=!1,this.dragOrSwipeEnabled=!1,this.mediaContainerPosition={top:0,bottom:0},!e)return this;if(Kn++,this.lgId=Kn,this.el=e,this.LGel=V(e),this.generateSettings(n),this.buildModules(),this.settings.dynamic&&this.settings.dynamicEl!==void 0&&!Array.isArray(this.settings.dynamicEl))throw"When using dynamic mode, you must also define dynamicEl as an Array.";return this.galleryItems=this.getItems(),this.normalizeSettings(),this.init(),this.validateLicense(),this}return t.prototype.generateSettings=function(e){if(this.settings=dt(dt({},Xd),e),this.settings.isMobile&&typeof this.settings.isMobile=="function"?this.settings.isMobile():Se.isMobile()){var n=dt(dt({},this.settings.mobileSettings),this.settings.mobileSettings);this.settings=dt(dt({},this.settings),n)}},t.prototype.normalizeSettings=function(){if(this.settings.slideEndAnimation&&(this.settings.hideControlOnEnd=!1),this.settings.closable||(this.settings.swipeToClose=!1),this.zoomFromOrigin=this.settings.zoomFromOrigin,this.settings.dynamic&&(this.zoomFromOrigin=!1),this.settings.container){var e=this.settings.container;if(typeof e=="function")this.settings.container=e();else if(typeof e=="string"){var n=document.querySelector(e);this.settings.container=n??document.body}}else this.settings.container=document.body;this.settings.preload=Math.min(this.settings.preload,this.galleryItems.length)},t.prototype.init=function(){var e=this;this.addSlideVideoInfo(this.galleryItems),this.buildStructure(),this.LGel.trigger(pe.init,{instance:this}),this.settings.keyPress&&this.keyPress(),setTimeout(function(){e.enableDrag(),e.enableSwipe(),e.triggerPosterClick()},50),this.arrow(),this.settings.mousewheel&&this.mousewheel(),this.settings.dynamic||this.openGalleryOnItemClick()},t.prototype.openGalleryOnItemClick=function(){for(var e=this,n=function(a){var o=i.items[a],c=V(o),l=rr.generateUUID();c.attr("data-lg-id",l).on("click.lgcustom-item-"+l,function(u){u.preventDefault();var m=e.settings.index||a;e.openGallery(m,o)})},i=this,r=0;r<this.items.length;r++)n(r)},t.prototype.buildModules=function(){var e=this;this.settings.plugins.forEach(function(n){e.plugins.push(new n(e,V))})},t.prototype.validateLicense=function(){this.settings.licenseKey?this.settings.licenseKey==="0000-0000-000-0000"&&console.warn("lightGallery: "+this.settings.licenseKey+" license key is not valid for production use"):console.error("Please provide a valid license key")},t.prototype.getSlideItem=function(e){return V(this.getSlideItemId(e))},t.prototype.getSlideItemId=function(e){return"#lg-item-"+this.lgId+"-"+e},t.prototype.getIdName=function(e){return e+"-"+this.lgId},t.prototype.getElementById=function(e){return V("#"+this.getIdName(e))},t.prototype.manageSingleSlideClassName=function(){this.galleryItems.length<2?this.outer.addClass("lg-single-item"):this.outer.removeClass("lg-single-item")},t.prototype.buildStructure=function(){var e=this,n=this.$container&&this.$container.get();if(!n){var i="",r="";this.settings.controls&&(i='<button type="button" id="'+this.getIdName("lg-prev")+'" aria-label="'+this.settings.strings.previousSlide+'" class="lg-prev lg-icon"> '+this.settings.prevHtml+` </button>
|
|
131
131
|
<button type="button" id="`+this.getIdName("lg-next")+'" aria-label="'+this.settings.strings.nextSlide+'" class="lg-next lg-icon"> '+this.settings.nextHtml+" </button>"),this.settings.appendSubHtmlTo!==".lg-item"&&(r='<div class="lg-sub-html" role="status" aria-live="polite"></div>');var a="";this.settings.allowMediaOverlap&&(a+="lg-media-overlap ");var o=this.settings.ariaLabelledby?'aria-labelledby="'+this.settings.ariaLabelledby+'"':"",c=this.settings.ariaDescribedby?'aria-describedby="'+this.settings.ariaDescribedby+'"':"",l="lg-container "+this.settings.addClass+" "+(document.body!==this.settings.container?"lg-inline":""),u=this.settings.closable&&this.settings.showCloseIcon?'<button type="button" aria-label="'+this.settings.strings.closeGallery+'" id="'+this.getIdName("lg-close")+'" class="lg-close lg-icon"></button>':"",m=this.settings.showMaximizeIcon?'<button type="button" aria-label="'+this.settings.strings.toggleMaximize+'" id="'+this.getIdName("lg-maximize")+'" class="lg-maximize lg-icon"></button>':"",d=`
|
|
132
132
|
<div class="`+l+'" id="'+this.getIdName("lg-container")+'" tabindex="-1" aria-modal="true" '+o+" "+c+` role="dialog"
|
|
133
133
|
>
|
|
@@ -195,7 +195,7 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
|
195
195
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
196
196
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
197
197
|
PERFORMANCE OF THIS SOFTWARE.
|
|
198
|
-
***************************************************************************** */var us=function(){return us=Object.assign||function(e){for(var n,i=1,r=arguments.length;i<r;i++){n=arguments[i];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},us.apply(this,arguments)},iu={scale:1,zoom:!0,infiniteZoom:!0,actualSize:!0,showZoomInOutIcons:!1,actualSizeIcons:{zoomIn:"lg-zoom-in",zoomOut:"lg-zoom-out"},enableZoomAfter:300,zoomPluginStrings:{zoomIn:"Zoom in",zoomOut:"Zoom out",viewActualSize:"View actual size"}},Je={containerResize:"lgContainerResize",beforeOpen:"lgBeforeOpen",afterOpen:"lgAfterOpen",slideItemLoad:"lgSlideItemLoad",afterSlide:"lgAfterSlide",rotateLeft:"lgRotateLeft",rotateRight:"lgRotateRight",flipHorizontal:"lgFlipHorizontal",flipVertical:"lgFlipVertical"},Fs=500,ru=(function(){function t(e,n){return this.core=e,this.$LG=n,this.settings=us(us({},iu),this.core.settings),this}return t.prototype.buildTemplates=function(){var e=this.settings.showZoomInOutIcons?'<button id="'+this.core.getIdName("lg-zoom-in")+'" type="button" aria-label="'+this.settings.zoomPluginStrings.zoomIn+'" class="lg-zoom-in lg-icon"></button><button id="'+this.core.getIdName("lg-zoom-out")+'" type="button" aria-label="'+this.settings.zoomPluginStrings.zoomOut+'" class="lg-zoom-out lg-icon"></button>':"";this.settings.actualSize&&(e+='<button id="'+this.core.getIdName("lg-actual-size")+'" type="button" aria-label="'+this.settings.zoomPluginStrings.viewActualSize+'" class="'+this.settings.actualSizeIcons.zoomIn+' lg-icon"></button>'),this.core.outer.addClass("lg-use-transition-for-zoom"),this.core.$toolbar.first().append(e)},t.prototype.enableZoom=function(e){var n=this,i=this.settings.enableZoomAfter+e.detail.delay;this.$LG("body").first().hasClass("lg-from-hash")&&e.detail.delay?i=0:this.$LG("body").first().removeClass("lg-from-hash"),this.zoomableTimeout=setTimeout(function(){n.isImageSlide(n.core.index)&&(n.core.getSlideItem(e.detail.index).addClass("lg-zoomable"),e.detail.index===n.core.index&&n.setZoomEssentials())},i+30)},t.prototype.enableZoomOnSlideItemLoad=function(){this.core.LGel.on(Je.slideItemLoad+".zoom",this.enableZoom.bind(this))},t.prototype.getDragCords=function(e){return{x:e.pageX,y:e.pageY}},t.prototype.getSwipeCords=function(e){var n=e.touches[0].pageX,i=e.touches[0].pageY;return{x:n,y:i}},t.prototype.getDragAllowedAxises=function(e,n){if(!this.containerRect)return{allowX:!1,allowY:!1};var i=this.core.getSlideItem(this.core.index).find(".lg-image").first().get(),r=0,a=0,o=i.getBoundingClientRect();e?(r=i.offsetHeight*e,a=i.offsetWidth*e):n?(r=o.height+n*o.height,a=o.width+n*o.width):(r=o.height,a=o.width);var c=r>this.containerRect.height,l=a>this.containerRect.width;return{allowX:l,allowY:c}},t.prototype.setZoomEssentials=function(){this.containerRect=this.core.$content.get().getBoundingClientRect()},t.prototype.zoomImage=function(e,n,i,r){if(!(!this.containerRect||Math.abs(n)<=0)){var a=this.containerRect.width/2+this.containerRect.left,o=this.containerRect.height/2+this.containerRect.top+this.scrollTop,c,l;e===1&&(this.positionChanged=!1);var u=this.getDragAllowedAxises(0,n),m=u.allowY,d=u.allowX;this.positionChanged&&(c=this.left/(this.scale-n),l=this.top/(this.scale-n),this.pageX=a-c,this.pageY=o-l,this.positionChanged=!1);var h=this.getPossibleSwipeDragCords(n),x,N,f=a-this.pageX,g=o-this.pageY;if(e-n>1){var v=(e-n)/Math.abs(n);f=(n<0?-f:f)+this.left*(v+(n<0?-1:1)),g=(n<0?-g:g)+this.top*(v+(n<0?-1:1)),x=f/v,N=g/v}else{var v=(e-n)*n;x=f*v,N=g*v}i&&(d?this.isBeyondPossibleLeft(x,h.minX)?x=h.minX:this.isBeyondPossibleRight(x,h.maxX)&&(x=h.maxX):e>1&&(x<h.minX?x=h.minX:x>h.maxX&&(x=h.maxX)),m?this.isBeyondPossibleTop(N,h.minY)?N=h.minY:this.isBeyondPossibleBottom(N,h.maxY)&&(N=h.maxY):e>1&&(N<h.minY?N=h.minY:N>h.maxY&&(N=h.maxY))),this.setZoomStyles({x,y:N,scale:e}),this.left=x,this.top=N,r&&this.setZoomImageSize()}},t.prototype.resetImageTranslate=function(e){if(this.isImageSlide(e)){var n=this.core.getSlideItem(e).find(".lg-image").first();this.imageReset=!1,n.removeClass("reset-transition reset-transition-y reset-transition-x"),this.core.outer.removeClass("lg-actual-size"),n.css("width","auto").css("height","auto"),setTimeout(function(){n.removeClass("no-transition")},10)}},t.prototype.setZoomImageSize=function(){var e=this,n=this.core.getSlideItem(this.core.index).find(".lg-image").first();setTimeout(function(){var i=e.getCurrentImageActualSizeScale();e.scale>=i&&(n.addClass("no-transition"),e.imageReset=!0)},Fs),setTimeout(function(){var i=e.getCurrentImageActualSizeScale();if(e.scale>=i){var r=e.getDragAllowedAxises(e.scale);n.css("width",n.get().naturalWidth+"px").css("height",n.get().naturalHeight+"px"),e.core.outer.addClass("lg-actual-size"),r.allowX&&r.allowY?n.addClass("reset-transition"):r.allowX&&!r.allowY?n.addClass("reset-transition-x"):!r.allowX&&r.allowY&&n.addClass("reset-transition-y")}},Fs+50)},t.prototype.setZoomStyles=function(e){var n=this.core.getSlideItem(this.core.index).find(".lg-img-wrap").first(),i=this.core.getSlideItem(this.core.index).find(".lg-image").first(),r=this.core.outer.find(".lg-current .lg-dummy-img").first();this.scale=e.scale,i.css("transform","scale3d("+e.scale+", "+e.scale+", 1)"),r.css("transform","scale3d("+e.scale+", "+e.scale+", 1)");var a="translate3d("+e.x+"px, "+e.y+"px, 0)";n.css("transform",a)},t.prototype.setActualSize=function(e,n){var i=this;if(!this.zoomInProgress){this.zoomInProgress=!0;var r=this.core.galleryItems[this.core.index];this.resetImageTranslate(e),setTimeout(function(){if(!(!r.src||i.core.outer.hasClass("lg-first-slide-loading"))){var a=i.getCurrentImageActualSizeScale(),o=i.scale;i.core.outer.hasClass("lg-zoomed")?i.scale=1:i.scale=i.getScale(a),i.setPageCords(n),i.beginZoom(i.scale),i.zoomImage(i.scale,i.scale-o,!0,!0)}},50),setTimeout(function(){i.core.outer.removeClass("lg-grabbing").addClass("lg-grab")},60),setTimeout(function(){i.zoomInProgress=!1},Fs+110)}},t.prototype.getNaturalWidth=function(e){var n=this.core.getSlideItem(e).find(".lg-image").first(),i=this.core.galleryItems[e].width;return i?parseFloat(i):n.get().naturalWidth},t.prototype.getActualSizeScale=function(e,n){var i,r;return e>=n?(i=e/n,r=i||2):r=1,r},t.prototype.getCurrentImageActualSizeScale=function(){var e=this.core.getSlideItem(this.core.index).find(".lg-image").first(),n=e.get().offsetWidth,i=this.getNaturalWidth(this.core.index)||n;return this.getActualSizeScale(i,n)},t.prototype.getPageCords=function(e){var n={};if(e)n.x=e.pageX||e.touches[0].pageX,n.y=e.pageY||e.touches[0].pageY;else{var i=this.core.$content.get().getBoundingClientRect();n.x=i.width/2+i.left,n.y=i.height/2+this.scrollTop+i.top}return n},t.prototype.setPageCords=function(e){var n=this.getPageCords(e);this.pageX=n.x,this.pageY=n.y},t.prototype.manageActualPixelClassNames=function(){var e=this.core.getElementById("lg-actual-size");e.removeClass(this.settings.actualSizeIcons.zoomIn).addClass(this.settings.actualSizeIcons.zoomOut)},t.prototype.beginZoom=function(e){return this.core.outer.removeClass("lg-zoom-drag-transition lg-zoom-dragging"),e>1?(this.core.outer.addClass("lg-zoomed"),this.manageActualPixelClassNames()):this.resetZoom(),e>1},t.prototype.getScale=function(e){var n=this.getCurrentImageActualSizeScale();return e<1?e=1:e>n&&(e=n),e},t.prototype.init=function(){var e=this;if(this.settings.zoom){this.buildTemplates(),this.enableZoomOnSlideItemLoad();var n=null;this.core.outer.on("dblclick.lg",function(i){e.$LG(i.target).hasClass("lg-image")&&e.setActualSize(e.core.index,i)}),this.core.outer.on("touchstart.lg",function(i){var r=e.$LG(i.target);i.touches.length===1&&r.hasClass("lg-image")&&(n?(clearTimeout(n),n=null,i.preventDefault(),e.setActualSize(e.core.index,i)):n=setTimeout(function(){n=null},300))}),this.core.LGel.on(Je.containerResize+".zoom "+Je.rotateRight+".zoom "+Je.rotateLeft+".zoom "+Je.flipHorizontal+".zoom "+Je.flipVertical+".zoom",function(){if(!(!e.core.lgOpened||!e.isImageSlide(e.core.index)||e.core.touchAction)){var i=e.core.getSlideItem(e.core.index).find(".lg-img-wrap").first();e.top=0,e.left=0,e.setZoomEssentials(),e.setZoomSwipeStyles(i,{x:0,y:0}),e.positionChanged=!0}}),this.$LG(window).on("scroll.lg.zoom.global"+this.core.lgId,function(){e.core.lgOpened&&(e.scrollTop=e.$LG(window).scrollTop())}),this.core.getElementById("lg-zoom-out").on("click.lg",function(){if(e.isImageSlide(e.core.index)){var i=0;e.imageReset&&(e.resetImageTranslate(e.core.index),i=50),setTimeout(function(){var r=e.scale-e.settings.scale;r<1&&(r=1),e.beginZoom(r),e.zoomImage(r,-e.settings.scale,!0,!e.settings.infiniteZoom)},i)}}),this.core.getElementById("lg-zoom-in").on("click.lg",function(){e.zoomIn()}),this.core.getElementById("lg-actual-size").on("click.lg",function(){e.setActualSize(e.core.index)}),this.core.LGel.on(Je.beforeOpen+".zoom",function(){e.core.outer.find(".lg-item").removeClass("lg-zoomable")}),this.core.LGel.on(Je.afterOpen+".zoom",function(){e.scrollTop=e.$LG(window).scrollTop(),e.pageX=e.core.outer.width()/2,e.pageY=e.core.outer.height()/2+e.scrollTop,e.scale=1}),this.core.LGel.on(Je.afterSlide+".zoom",function(i){var r=i.detail.prevIndex;e.scale=1,e.positionChanged=!1,e.zoomInProgress=!1,e.resetZoom(r),e.resetImageTranslate(r),e.isImageSlide(e.core.index)&&e.setZoomEssentials()}),this.zoomDrag(),this.pinchZoom(),this.zoomSwipe(),this.zoomableTimeout=!1,this.positionChanged=!1,this.zoomInProgress=!1}},t.prototype.zoomIn=function(){if(this.isImageSlide(this.core.index)){var e=this.scale+this.settings.scale;this.settings.infiniteZoom||(e=this.getScale(e)),this.beginZoom(e),this.zoomImage(e,Math.min(this.settings.scale,e-this.scale),!0,!this.settings.infiniteZoom)}},t.prototype.resetZoom=function(e){this.core.outer.removeClass("lg-zoomed lg-zoom-drag-transition");var n=this.core.getElementById("lg-actual-size"),i=this.core.getSlideItem(e!==void 0?e:this.core.index);n.removeClass(this.settings.actualSizeIcons.zoomOut).addClass(this.settings.actualSizeIcons.zoomIn),i.find(".lg-img-wrap").first().removeAttr("style"),i.find(".lg-image").first().removeAttr("style"),this.scale=1,this.left=0,this.top=0,this.setPageCords()},t.prototype.getTouchDistance=function(e){return Math.sqrt((e.touches[0].pageX-e.touches[1].pageX)*(e.touches[0].pageX-e.touches[1].pageX)+(e.touches[0].pageY-e.touches[1].pageY)*(e.touches[0].pageY-e.touches[1].pageY))},t.prototype.pinchZoom=function(){var e=this,n=0,i=!1,r=1,a=0,o=this.core.getSlideItem(this.core.index);this.core.outer.on("touchstart.lg",function(c){if(o=e.core.getSlideItem(e.core.index),!!e.isImageSlide(e.core.index)&&c.touches.length===2){if(c.preventDefault(),e.core.outer.hasClass("lg-first-slide-loading"))return;r=e.scale||1,e.core.outer.removeClass("lg-zoom-drag-transition lg-zoom-dragging"),e.setPageCords(c),e.resetImageTranslate(e.core.index),e.core.touchAction="pinch",n=e.getTouchDistance(c)}}),this.core.$inner.on("touchmove.lg",function(c){if(c.touches.length===2&&e.core.touchAction==="pinch"&&(e.$LG(c.target).hasClass("lg-item")||o.get().contains(c.target))){c.preventDefault();var l=e.getTouchDistance(c),u=n-l;if(!i&&Math.abs(u)>5&&(i=!0),i){a=e.scale;var m=Math.max(1,r+-u*.02);e.scale=Math.round((m+Number.EPSILON)*100)/100;var d=e.scale-a;e.zoomImage(e.scale,Math.round((d+Number.EPSILON)*100)/100,!1,!1)}}}),this.core.$inner.on("touchend.lg",function(c){if(e.core.touchAction==="pinch"&&(e.$LG(c.target).hasClass("lg-item")||o.get().contains(c.target))){if(i=!1,n=0,e.scale<=1)e.resetZoom();else{var l=e.getCurrentImageActualSizeScale();if(e.scale>=l){var u=l-e.scale;u===0&&(u=.01),e.zoomImage(l,u,!1,!0)}e.manageActualPixelClassNames(),e.core.outer.addClass("lg-zoomed")}e.core.touchAction=void 0}})},t.prototype.touchendZoom=function(e,n,i,r,a){var o=n.x-e.x,c=n.y-e.y,l=Math.abs(o)/a+1,u=Math.abs(c)/a+1;l>2&&(l+=1),u>2&&(u+=1),o=o*l,c=c*u;var m=this.core.getSlideItem(this.core.index).find(".lg-img-wrap").first(),d={};d.x=this.left+o,d.y=this.top+c;var h=this.getPossibleSwipeDragCords();(Math.abs(o)>15||Math.abs(c)>15)&&(r&&(this.isBeyondPossibleTop(d.y,h.minY)?d.y=h.minY:this.isBeyondPossibleBottom(d.y,h.maxY)&&(d.y=h.maxY)),i&&(this.isBeyondPossibleLeft(d.x,h.minX)?d.x=h.minX:this.isBeyondPossibleRight(d.x,h.maxX)&&(d.x=h.maxX)),r?this.top=d.y:d.y=this.top,i?this.left=d.x:d.x=this.left,this.setZoomSwipeStyles(m,d),this.positionChanged=!0)},t.prototype.getZoomSwipeCords=function(e,n,i,r,a){var o={};if(r){if(o.y=this.top+(n.y-e.y),this.isBeyondPossibleTop(o.y,a.minY)){var c=a.minY-o.y;o.y=a.minY-c/6}else if(this.isBeyondPossibleBottom(o.y,a.maxY)){var l=o.y-a.maxY;o.y=a.maxY+l/6}}else o.y=this.top;if(i){if(o.x=this.left+(n.x-e.x),this.isBeyondPossibleLeft(o.x,a.minX)){var u=a.minX-o.x;o.x=a.minX-u/6}else if(this.isBeyondPossibleRight(o.x,a.maxX)){var m=o.x-a.maxX;o.x=a.maxX+m/6}}else o.x=this.left;return o},t.prototype.isBeyondPossibleLeft=function(e,n){return e>=n},t.prototype.isBeyondPossibleRight=function(e,n){return e<=n},t.prototype.isBeyondPossibleTop=function(e,n){return e>=n},t.prototype.isBeyondPossibleBottom=function(e,n){return e<=n},t.prototype.isImageSlide=function(e){var n=this.core.galleryItems[e];return this.core.getSlideType(n)==="image"},t.prototype.getPossibleSwipeDragCords=function(e){var n=this.core.getSlideItem(this.core.index).find(".lg-image").first(),i=this.core.mediaContainerPosition.bottom,r=n.get().getBoundingClientRect(),a=r.height,o=r.width;e&&(a=a+e*a,o=o+e*o);var c=(a-this.containerRect.height)/2,l=(this.containerRect.height-a)/2+i,u=(o-this.containerRect.width)/2,m=(this.containerRect.width-o)/2,d={minY:c,maxY:l,minX:u,maxX:m};return d},t.prototype.setZoomSwipeStyles=function(e,n){e.css("transform","translate3d("+n.x+"px, "+n.y+"px, 0)")},t.prototype.zoomSwipe=function(){var e=this,n={},i={},r=!1,a=!1,o=!1,c=new Date,l=new Date,u,m,d=this.core.getSlideItem(this.core.index);this.core.$inner.on("touchstart.lg",function(h){if(e.isImageSlide(e.core.index)&&(d=e.core.getSlideItem(e.core.index),(e.$LG(h.target).hasClass("lg-item")||d.get().contains(h.target))&&h.touches.length===1&&e.core.outer.hasClass("lg-zoomed"))){h.preventDefault(),c=new Date,e.core.touchAction="zoomSwipe",m=e.core.getSlideItem(e.core.index).find(".lg-img-wrap").first();var x=e.getDragAllowedAxises(0);o=x.allowY,a=x.allowX,(a||o)&&(n=e.getSwipeCords(h)),u=e.getPossibleSwipeDragCords(),e.core.outer.addClass("lg-zoom-dragging lg-zoom-drag-transition")}}),this.core.$inner.on("touchmove.lg",function(h){if(h.touches.length===1&&e.core.touchAction==="zoomSwipe"&&(e.$LG(h.target).hasClass("lg-item")||d.get().contains(h.target))){h.preventDefault(),e.core.touchAction="zoomSwipe",i=e.getSwipeCords(h);var x=e.getZoomSwipeCords(n,i,a,o,u);(Math.abs(i.x-n.x)>15||Math.abs(i.y-n.y)>15)&&(r=!0,e.setZoomSwipeStyles(m,x))}}),this.core.$inner.on("touchend.lg",function(h){if(e.core.touchAction==="zoomSwipe"&&(e.$LG(h.target).hasClass("lg-item")||d.get().contains(h.target))){if(h.preventDefault(),e.core.touchAction=void 0,e.core.outer.removeClass("lg-zoom-dragging"),!r)return;r=!1,l=new Date;var x=l.valueOf()-c.valueOf();e.touchendZoom(n,i,a,o,x)}})},t.prototype.zoomDrag=function(){var e=this,n={},i={},r=!1,a=!1,o=!1,c=!1,l,u,m,d;this.core.outer.on("mousedown.lg.zoom",function(h){if(e.isImageSlide(e.core.index)){var x=e.core.getSlideItem(e.core.index);if(e.$LG(h.target).hasClass("lg-item")||x.get().contains(h.target)){l=new Date,d=e.core.getSlideItem(e.core.index).find(".lg-img-wrap").first();var N=e.getDragAllowedAxises(0);c=N.allowY,o=N.allowX,e.core.outer.hasClass("lg-zoomed")&&e.$LG(h.target).hasClass("lg-object")&&(o||c)&&(h.preventDefault(),n=e.getDragCords(h),m=e.getPossibleSwipeDragCords(),r=!0,e.core.outer.removeClass("lg-grab").addClass("lg-grabbing lg-zoom-drag-transition lg-zoom-dragging"))}}}),this.$LG(window).on("mousemove.lg.zoom.global"+this.core.lgId,function(h){if(r){a=!0,i=e.getDragCords(h);var x=e.getZoomSwipeCords(n,i,o,c,m);e.setZoomSwipeStyles(d,x)}}),this.$LG(window).on("mouseup.lg.zoom.global"+this.core.lgId,function(h){if(r){if(u=new Date,r=!1,e.core.outer.removeClass("lg-zoom-dragging"),a&&(n.x!==i.x||n.y!==i.y)){i=e.getDragCords(h);var x=u.valueOf()-l.valueOf();e.touchendZoom(n,i,o,c,x)}a=!1}e.core.outer.removeClass("lg-grabbing").addClass("lg-grab")})},t.prototype.closeGallery=function(){this.resetZoom(),this.zoomInProgress=!1},t.prototype.destroy=function(){this.$LG(window).off(".lg.zoom.global"+this.core.lgId),this.core.LGel.off(".lg.zoom"),this.core.LGel.off(".zoom"),clearTimeout(this.zoomableTimeout),this.zoomableTimeout=!1},t})();function au({images:t,imageHeight:e,galleryId:n,renderImage:i}){const r=y.useRef(null),a=[t.length,t.join("#")].join("@");return y.useEffect(()=>{if(!t.length)return;const o=r.current;if(!o)return;const c=o.querySelector(".gallery");c&&nr(c,{itemSelector:".gallery__item",rowHeight:e??80,lastRow:"justify",gutter:5,rowHeightTolerance:.2,calculateItemsHeight:!1})},[a,e,t.length]),t.length?s.jsx("div",{ref:r,children:s.jsx(tu,{plugins:[ru,nu],mode:"lg-fade",thumbnail:!0,galleryId:n??"media-gallery",elementClassNames:"gallery gallery-wrapper",mobileSettings:{controls:!1,showCloseIcon:!1,download:!1,rotate:!1},children:t.map((o,c)=>s.jsx("div",{"data-src":o,className:"gallery__item block",children:i?i(o):s.jsx("img",{src:o,alt:`Gallery item ${c+1}`,className:"h-full w-full object-cover"})},o))},a)}):null}const ou=Zs(`
|
|
198
|
+
***************************************************************************** */var us=function(){return us=Object.assign||function(e){for(var n,i=1,r=arguments.length;i<r;i++){n=arguments[i];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},us.apply(this,arguments)},iu={scale:1,zoom:!0,infiniteZoom:!0,actualSize:!0,showZoomInOutIcons:!1,actualSizeIcons:{zoomIn:"lg-zoom-in",zoomOut:"lg-zoom-out"},enableZoomAfter:300,zoomPluginStrings:{zoomIn:"Zoom in",zoomOut:"Zoom out",viewActualSize:"View actual size"}},Je={containerResize:"lgContainerResize",beforeOpen:"lgBeforeOpen",afterOpen:"lgAfterOpen",slideItemLoad:"lgSlideItemLoad",afterSlide:"lgAfterSlide",rotateLeft:"lgRotateLeft",rotateRight:"lgRotateRight",flipHorizontal:"lgFlipHorizontal",flipVertical:"lgFlipVertical"},Fs=500,ru=(function(){function t(e,n){return this.core=e,this.$LG=n,this.settings=us(us({},iu),this.core.settings),this}return t.prototype.buildTemplates=function(){var e=this.settings.showZoomInOutIcons?'<button id="'+this.core.getIdName("lg-zoom-in")+'" type="button" aria-label="'+this.settings.zoomPluginStrings.zoomIn+'" class="lg-zoom-in lg-icon"></button><button id="'+this.core.getIdName("lg-zoom-out")+'" type="button" aria-label="'+this.settings.zoomPluginStrings.zoomOut+'" class="lg-zoom-out lg-icon"></button>':"";this.settings.actualSize&&(e+='<button id="'+this.core.getIdName("lg-actual-size")+'" type="button" aria-label="'+this.settings.zoomPluginStrings.viewActualSize+'" class="'+this.settings.actualSizeIcons.zoomIn+' lg-icon"></button>'),this.core.outer.addClass("lg-use-transition-for-zoom"),this.core.$toolbar.first().append(e)},t.prototype.enableZoom=function(e){var n=this,i=this.settings.enableZoomAfter+e.detail.delay;this.$LG("body").first().hasClass("lg-from-hash")&&e.detail.delay?i=0:this.$LG("body").first().removeClass("lg-from-hash"),this.zoomableTimeout=setTimeout(function(){n.isImageSlide(n.core.index)&&(n.core.getSlideItem(e.detail.index).addClass("lg-zoomable"),e.detail.index===n.core.index&&n.setZoomEssentials())},i+30)},t.prototype.enableZoomOnSlideItemLoad=function(){this.core.LGel.on(Je.slideItemLoad+".zoom",this.enableZoom.bind(this))},t.prototype.getDragCords=function(e){return{x:e.pageX,y:e.pageY}},t.prototype.getSwipeCords=function(e){var n=e.touches[0].pageX,i=e.touches[0].pageY;return{x:n,y:i}},t.prototype.getDragAllowedAxises=function(e,n){if(!this.containerRect)return{allowX:!1,allowY:!1};var i=this.core.getSlideItem(this.core.index).find(".lg-image").first().get(),r=0,a=0,o=i.getBoundingClientRect();e?(r=i.offsetHeight*e,a=i.offsetWidth*e):n?(r=o.height+n*o.height,a=o.width+n*o.width):(r=o.height,a=o.width);var c=r>this.containerRect.height,l=a>this.containerRect.width;return{allowX:l,allowY:c}},t.prototype.setZoomEssentials=function(){this.containerRect=this.core.$content.get().getBoundingClientRect()},t.prototype.zoomImage=function(e,n,i,r){if(!(!this.containerRect||Math.abs(n)<=0)){var a=this.containerRect.width/2+this.containerRect.left,o=this.containerRect.height/2+this.containerRect.top+this.scrollTop,c,l;e===1&&(this.positionChanged=!1);var u=this.getDragAllowedAxises(0,n),m=u.allowY,d=u.allowX;this.positionChanged&&(c=this.left/(this.scale-n),l=this.top/(this.scale-n),this.pageX=a-c,this.pageY=o-l,this.positionChanged=!1);var h=this.getPossibleSwipeDragCords(n),x,N,f=a-this.pageX,g=o-this.pageY;if(e-n>1){var v=(e-n)/Math.abs(n);f=(n<0?-f:f)+this.left*(v+(n<0?-1:1)),g=(n<0?-g:g)+this.top*(v+(n<0?-1:1)),x=f/v,N=g/v}else{var v=(e-n)*n;x=f*v,N=g*v}i&&(d?this.isBeyondPossibleLeft(x,h.minX)?x=h.minX:this.isBeyondPossibleRight(x,h.maxX)&&(x=h.maxX):e>1&&(x<h.minX?x=h.minX:x>h.maxX&&(x=h.maxX)),m?this.isBeyondPossibleTop(N,h.minY)?N=h.minY:this.isBeyondPossibleBottom(N,h.maxY)&&(N=h.maxY):e>1&&(N<h.minY?N=h.minY:N>h.maxY&&(N=h.maxY))),this.setZoomStyles({x,y:N,scale:e}),this.left=x,this.top=N,r&&this.setZoomImageSize()}},t.prototype.resetImageTranslate=function(e){if(this.isImageSlide(e)){var n=this.core.getSlideItem(e).find(".lg-image").first();this.imageReset=!1,n.removeClass("reset-transition reset-transition-y reset-transition-x"),this.core.outer.removeClass("lg-actual-size"),n.css("width","auto").css("height","auto"),setTimeout(function(){n.removeClass("no-transition")},10)}},t.prototype.setZoomImageSize=function(){var e=this,n=this.core.getSlideItem(this.core.index).find(".lg-image").first();setTimeout(function(){var i=e.getCurrentImageActualSizeScale();e.scale>=i&&(n.addClass("no-transition"),e.imageReset=!0)},Fs),setTimeout(function(){var i=e.getCurrentImageActualSizeScale();if(e.scale>=i){var r=e.getDragAllowedAxises(e.scale);n.css("width",n.get().naturalWidth+"px").css("height",n.get().naturalHeight+"px"),e.core.outer.addClass("lg-actual-size"),r.allowX&&r.allowY?n.addClass("reset-transition"):r.allowX&&!r.allowY?n.addClass("reset-transition-x"):!r.allowX&&r.allowY&&n.addClass("reset-transition-y")}},Fs+50)},t.prototype.setZoomStyles=function(e){var n=this.core.getSlideItem(this.core.index).find(".lg-img-wrap").first(),i=this.core.getSlideItem(this.core.index).find(".lg-image").first(),r=this.core.outer.find(".lg-current .lg-dummy-img").first();this.scale=e.scale,i.css("transform","scale3d("+e.scale+", "+e.scale+", 1)"),r.css("transform","scale3d("+e.scale+", "+e.scale+", 1)");var a="translate3d("+e.x+"px, "+e.y+"px, 0)";n.css("transform",a)},t.prototype.setActualSize=function(e,n){var i=this;if(!this.zoomInProgress){this.zoomInProgress=!0;var r=this.core.galleryItems[this.core.index];this.resetImageTranslate(e),setTimeout(function(){if(!(!r.src||i.core.outer.hasClass("lg-first-slide-loading"))){var a=i.getCurrentImageActualSizeScale(),o=i.scale;i.core.outer.hasClass("lg-zoomed")?i.scale=1:i.scale=i.getScale(a),i.setPageCords(n),i.beginZoom(i.scale),i.zoomImage(i.scale,i.scale-o,!0,!0)}},50),setTimeout(function(){i.core.outer.removeClass("lg-grabbing").addClass("lg-grab")},60),setTimeout(function(){i.zoomInProgress=!1},Fs+110)}},t.prototype.getNaturalWidth=function(e){var n=this.core.getSlideItem(e).find(".lg-image").first(),i=this.core.galleryItems[e].width;return i?parseFloat(i):n.get().naturalWidth},t.prototype.getActualSizeScale=function(e,n){var i,r;return e>=n?(i=e/n,r=i||2):r=1,r},t.prototype.getCurrentImageActualSizeScale=function(){var e=this.core.getSlideItem(this.core.index).find(".lg-image").first(),n=e.get().offsetWidth,i=this.getNaturalWidth(this.core.index)||n;return this.getActualSizeScale(i,n)},t.prototype.getPageCords=function(e){var n={};if(e)n.x=e.pageX||e.touches[0].pageX,n.y=e.pageY||e.touches[0].pageY;else{var i=this.core.$content.get().getBoundingClientRect();n.x=i.width/2+i.left,n.y=i.height/2+this.scrollTop+i.top}return n},t.prototype.setPageCords=function(e){var n=this.getPageCords(e);this.pageX=n.x,this.pageY=n.y},t.prototype.manageActualPixelClassNames=function(){var e=this.core.getElementById("lg-actual-size");e.removeClass(this.settings.actualSizeIcons.zoomIn).addClass(this.settings.actualSizeIcons.zoomOut)},t.prototype.beginZoom=function(e){return this.core.outer.removeClass("lg-zoom-drag-transition lg-zoom-dragging"),e>1?(this.core.outer.addClass("lg-zoomed"),this.manageActualPixelClassNames()):this.resetZoom(),e>1},t.prototype.getScale=function(e){var n=this.getCurrentImageActualSizeScale();return e<1?e=1:e>n&&(e=n),e},t.prototype.init=function(){var e=this;if(this.settings.zoom){this.buildTemplates(),this.enableZoomOnSlideItemLoad();var n=null;this.core.outer.on("dblclick.lg",function(i){e.$LG(i.target).hasClass("lg-image")&&e.setActualSize(e.core.index,i)}),this.core.outer.on("touchstart.lg",function(i){var r=e.$LG(i.target);i.touches.length===1&&r.hasClass("lg-image")&&(n?(clearTimeout(n),n=null,i.preventDefault(),e.setActualSize(e.core.index,i)):n=setTimeout(function(){n=null},300))}),this.core.LGel.on(Je.containerResize+".zoom "+Je.rotateRight+".zoom "+Je.rotateLeft+".zoom "+Je.flipHorizontal+".zoom "+Je.flipVertical+".zoom",function(){if(!(!e.core.lgOpened||!e.isImageSlide(e.core.index)||e.core.touchAction)){var i=e.core.getSlideItem(e.core.index).find(".lg-img-wrap").first();e.top=0,e.left=0,e.setZoomEssentials(),e.setZoomSwipeStyles(i,{x:0,y:0}),e.positionChanged=!0}}),this.$LG(window).on("scroll.lg.zoom.global"+this.core.lgId,function(){e.core.lgOpened&&(e.scrollTop=e.$LG(window).scrollTop())}),this.core.getElementById("lg-zoom-out").on("click.lg",function(){if(e.isImageSlide(e.core.index)){var i=0;e.imageReset&&(e.resetImageTranslate(e.core.index),i=50),setTimeout(function(){var r=e.scale-e.settings.scale;r<1&&(r=1),e.beginZoom(r),e.zoomImage(r,-e.settings.scale,!0,!e.settings.infiniteZoom)},i)}}),this.core.getElementById("lg-zoom-in").on("click.lg",function(){e.zoomIn()}),this.core.getElementById("lg-actual-size").on("click.lg",function(){e.setActualSize(e.core.index)}),this.core.LGel.on(Je.beforeOpen+".zoom",function(){e.core.outer.find(".lg-item").removeClass("lg-zoomable")}),this.core.LGel.on(Je.afterOpen+".zoom",function(){e.scrollTop=e.$LG(window).scrollTop(),e.pageX=e.core.outer.width()/2,e.pageY=e.core.outer.height()/2+e.scrollTop,e.scale=1}),this.core.LGel.on(Je.afterSlide+".zoom",function(i){var r=i.detail.prevIndex;e.scale=1,e.positionChanged=!1,e.zoomInProgress=!1,e.resetZoom(r),e.resetImageTranslate(r),e.isImageSlide(e.core.index)&&e.setZoomEssentials()}),this.zoomDrag(),this.pinchZoom(),this.zoomSwipe(),this.zoomableTimeout=!1,this.positionChanged=!1,this.zoomInProgress=!1}},t.prototype.zoomIn=function(){if(this.isImageSlide(this.core.index)){var e=this.scale+this.settings.scale;this.settings.infiniteZoom||(e=this.getScale(e)),this.beginZoom(e),this.zoomImage(e,Math.min(this.settings.scale,e-this.scale),!0,!this.settings.infiniteZoom)}},t.prototype.resetZoom=function(e){this.core.outer.removeClass("lg-zoomed lg-zoom-drag-transition");var n=this.core.getElementById("lg-actual-size"),i=this.core.getSlideItem(e!==void 0?e:this.core.index);n.removeClass(this.settings.actualSizeIcons.zoomOut).addClass(this.settings.actualSizeIcons.zoomIn),i.find(".lg-img-wrap").first().removeAttr("style"),i.find(".lg-image").first().removeAttr("style"),this.scale=1,this.left=0,this.top=0,this.setPageCords()},t.prototype.getTouchDistance=function(e){return Math.sqrt((e.touches[0].pageX-e.touches[1].pageX)*(e.touches[0].pageX-e.touches[1].pageX)+(e.touches[0].pageY-e.touches[1].pageY)*(e.touches[0].pageY-e.touches[1].pageY))},t.prototype.pinchZoom=function(){var e=this,n=0,i=!1,r=1,a=0,o=this.core.getSlideItem(this.core.index);this.core.outer.on("touchstart.lg",function(c){if(o=e.core.getSlideItem(e.core.index),!!e.isImageSlide(e.core.index)&&c.touches.length===2){if(c.preventDefault(),e.core.outer.hasClass("lg-first-slide-loading"))return;r=e.scale||1,e.core.outer.removeClass("lg-zoom-drag-transition lg-zoom-dragging"),e.setPageCords(c),e.resetImageTranslate(e.core.index),e.core.touchAction="pinch",n=e.getTouchDistance(c)}}),this.core.$inner.on("touchmove.lg",function(c){if(c.touches.length===2&&e.core.touchAction==="pinch"&&(e.$LG(c.target).hasClass("lg-item")||o.get().contains(c.target))){c.preventDefault();var l=e.getTouchDistance(c),u=n-l;if(!i&&Math.abs(u)>5&&(i=!0),i){a=e.scale;var m=Math.max(1,r+-u*.02);e.scale=Math.round((m+Number.EPSILON)*100)/100;var d=e.scale-a;e.zoomImage(e.scale,Math.round((d+Number.EPSILON)*100)/100,!1,!1)}}}),this.core.$inner.on("touchend.lg",function(c){if(e.core.touchAction==="pinch"&&(e.$LG(c.target).hasClass("lg-item")||o.get().contains(c.target))){if(i=!1,n=0,e.scale<=1)e.resetZoom();else{var l=e.getCurrentImageActualSizeScale();if(e.scale>=l){var u=l-e.scale;u===0&&(u=.01),e.zoomImage(l,u,!1,!0)}e.manageActualPixelClassNames(),e.core.outer.addClass("lg-zoomed")}e.core.touchAction=void 0}})},t.prototype.touchendZoom=function(e,n,i,r,a){var o=n.x-e.x,c=n.y-e.y,l=Math.abs(o)/a+1,u=Math.abs(c)/a+1;l>2&&(l+=1),u>2&&(u+=1),o=o*l,c=c*u;var m=this.core.getSlideItem(this.core.index).find(".lg-img-wrap").first(),d={};d.x=this.left+o,d.y=this.top+c;var h=this.getPossibleSwipeDragCords();(Math.abs(o)>15||Math.abs(c)>15)&&(r&&(this.isBeyondPossibleTop(d.y,h.minY)?d.y=h.minY:this.isBeyondPossibleBottom(d.y,h.maxY)&&(d.y=h.maxY)),i&&(this.isBeyondPossibleLeft(d.x,h.minX)?d.x=h.minX:this.isBeyondPossibleRight(d.x,h.maxX)&&(d.x=h.maxX)),r?this.top=d.y:d.y=this.top,i?this.left=d.x:d.x=this.left,this.setZoomSwipeStyles(m,d),this.positionChanged=!0)},t.prototype.getZoomSwipeCords=function(e,n,i,r,a){var o={};if(r){if(o.y=this.top+(n.y-e.y),this.isBeyondPossibleTop(o.y,a.minY)){var c=a.minY-o.y;o.y=a.minY-c/6}else if(this.isBeyondPossibleBottom(o.y,a.maxY)){var l=o.y-a.maxY;o.y=a.maxY+l/6}}else o.y=this.top;if(i){if(o.x=this.left+(n.x-e.x),this.isBeyondPossibleLeft(o.x,a.minX)){var u=a.minX-o.x;o.x=a.minX-u/6}else if(this.isBeyondPossibleRight(o.x,a.maxX)){var m=o.x-a.maxX;o.x=a.maxX+m/6}}else o.x=this.left;return o},t.prototype.isBeyondPossibleLeft=function(e,n){return e>=n},t.prototype.isBeyondPossibleRight=function(e,n){return e<=n},t.prototype.isBeyondPossibleTop=function(e,n){return e>=n},t.prototype.isBeyondPossibleBottom=function(e,n){return e<=n},t.prototype.isImageSlide=function(e){var n=this.core.galleryItems[e];return this.core.getSlideType(n)==="image"},t.prototype.getPossibleSwipeDragCords=function(e){var n=this.core.getSlideItem(this.core.index).find(".lg-image").first(),i=this.core.mediaContainerPosition.bottom,r=n.get().getBoundingClientRect(),a=r.height,o=r.width;e&&(a=a+e*a,o=o+e*o);var c=(a-this.containerRect.height)/2,l=(this.containerRect.height-a)/2+i,u=(o-this.containerRect.width)/2,m=(this.containerRect.width-o)/2,d={minY:c,maxY:l,minX:u,maxX:m};return d},t.prototype.setZoomSwipeStyles=function(e,n){e.css("transform","translate3d("+n.x+"px, "+n.y+"px, 0)")},t.prototype.zoomSwipe=function(){var e=this,n={},i={},r=!1,a=!1,o=!1,c=new Date,l=new Date,u,m,d=this.core.getSlideItem(this.core.index);this.core.$inner.on("touchstart.lg",function(h){if(e.isImageSlide(e.core.index)&&(d=e.core.getSlideItem(e.core.index),(e.$LG(h.target).hasClass("lg-item")||d.get().contains(h.target))&&h.touches.length===1&&e.core.outer.hasClass("lg-zoomed"))){h.preventDefault(),c=new Date,e.core.touchAction="zoomSwipe",m=e.core.getSlideItem(e.core.index).find(".lg-img-wrap").first();var x=e.getDragAllowedAxises(0);o=x.allowY,a=x.allowX,(a||o)&&(n=e.getSwipeCords(h)),u=e.getPossibleSwipeDragCords(),e.core.outer.addClass("lg-zoom-dragging lg-zoom-drag-transition")}}),this.core.$inner.on("touchmove.lg",function(h){if(h.touches.length===1&&e.core.touchAction==="zoomSwipe"&&(e.$LG(h.target).hasClass("lg-item")||d.get().contains(h.target))){h.preventDefault(),e.core.touchAction="zoomSwipe",i=e.getSwipeCords(h);var x=e.getZoomSwipeCords(n,i,a,o,u);(Math.abs(i.x-n.x)>15||Math.abs(i.y-n.y)>15)&&(r=!0,e.setZoomSwipeStyles(m,x))}}),this.core.$inner.on("touchend.lg",function(h){if(e.core.touchAction==="zoomSwipe"&&(e.$LG(h.target).hasClass("lg-item")||d.get().contains(h.target))){if(h.preventDefault(),e.core.touchAction=void 0,e.core.outer.removeClass("lg-zoom-dragging"),!r)return;r=!1,l=new Date;var x=l.valueOf()-c.valueOf();e.touchendZoom(n,i,a,o,x)}})},t.prototype.zoomDrag=function(){var e=this,n={},i={},r=!1,a=!1,o=!1,c=!1,l,u,m,d;this.core.outer.on("mousedown.lg.zoom",function(h){if(e.isImageSlide(e.core.index)){var x=e.core.getSlideItem(e.core.index);if(e.$LG(h.target).hasClass("lg-item")||x.get().contains(h.target)){l=new Date,d=e.core.getSlideItem(e.core.index).find(".lg-img-wrap").first();var N=e.getDragAllowedAxises(0);c=N.allowY,o=N.allowX,e.core.outer.hasClass("lg-zoomed")&&e.$LG(h.target).hasClass("lg-object")&&(o||c)&&(h.preventDefault(),n=e.getDragCords(h),m=e.getPossibleSwipeDragCords(),r=!0,e.core.outer.removeClass("lg-grab").addClass("lg-grabbing lg-zoom-drag-transition lg-zoom-dragging"))}}}),this.$LG(window).on("mousemove.lg.zoom.global"+this.core.lgId,function(h){if(r){a=!0,i=e.getDragCords(h);var x=e.getZoomSwipeCords(n,i,o,c,m);e.setZoomSwipeStyles(d,x)}}),this.$LG(window).on("mouseup.lg.zoom.global"+this.core.lgId,function(h){if(r){if(u=new Date,r=!1,e.core.outer.removeClass("lg-zoom-dragging"),a&&(n.x!==i.x||n.y!==i.y)){i=e.getDragCords(h);var x=u.valueOf()-l.valueOf();e.touchendZoom(n,i,o,c,x)}a=!1}e.core.outer.removeClass("lg-grabbing").addClass("lg-grab")})},t.prototype.closeGallery=function(){this.resetZoom(),this.zoomInProgress=!1},t.prototype.destroy=function(){this.$LG(window).off(".lg.zoom.global"+this.core.lgId),this.core.LGel.off(".lg.zoom"),this.core.LGel.off(".zoom"),clearTimeout(this.zoomableTimeout),this.zoomableTimeout=!1},t})();function au({images:t,imageHeight:e,galleryId:n,renderImage:i}){const r=y.useRef(null),a=[t.length,t.join("#")].join("@");return y.useEffect(()=>{if(!t.length)return;const o=r.current;if(!o)return;const c=o.querySelector(".gallery");c&&ir(c,{itemSelector:".gallery__item",rowHeight:e??80,lastRow:"justify",gutter:5,rowHeightTolerance:.2,calculateItemsHeight:!1})},[a,e,t.length]),t.length?s.jsx("div",{ref:r,children:s.jsx(tu,{plugins:[ru,nu],mode:"lg-fade",thumbnail:!0,galleryId:n??"media-gallery",elementClassNames:"gallery gallery-wrapper",mobileSettings:{controls:!1,showCloseIcon:!1,download:!1,rotate:!1},children:t.map((o,c)=>s.jsx("div",{"data-src":o,className:"gallery__item block",children:i?i(o):s.jsx("img",{src:o,alt:`Gallery item ${c+1}`,className:"h-full w-full object-cover"})},o))},a)}):null}const ou=cn(`
|
|
199
199
|
query DiagramImages($orgId: ID!, $diagramId: ID!) {
|
|
200
200
|
diagramImages(orgId: $orgId, diagramId: $diagramId) {
|
|
201
201
|
diagramImageId
|
|
@@ -207,7 +207,7 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
207
207
|
createdAt
|
|
208
208
|
}
|
|
209
209
|
}
|
|
210
|
-
`),lu=
|
|
210
|
+
`),lu=cn(`
|
|
211
211
|
mutation CreateDiagramImage(
|
|
212
212
|
$orgId: ID!
|
|
213
213
|
$diagramId: ID!
|
|
@@ -221,11 +221,11 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
221
221
|
order
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
|
-
`);function cu(){const{diagramId:t,organizationId:e}=we(),{data:n,refetch:i}=ut(ou,{variables:{orgId:e,diagramId:t},skip:!t||!e}),[r,{loading:a}]=zt(lu),o=y.useMemo(()=>Be(n?.diagramImages),[n?.diagramImages]),[c,l]=y.useState(null),u=y.useMemo(()=>o.flatMap(d=>d?.imageUrl?[d.imageUrl]:[]),[o]);async function m(){if(!(!t||!e))try{const[d]=await as({accept:"image/*"});if(!d)return;const h=await zi(e,d);await r({variables:{orgId:e,diagramId:t,input:{assetId:h,fileName:d.name,order:o.length}}}),await i()}catch(d){console.error("Error uploading image:",d),U.error("Failed to upload image")}}return s.jsx(Xe,{className:"left-18",children:s.jsxs("div",{className:"flex w-[15rem] flex-col gap-3 p-2",children:[s.jsxs(Q,{preset:"outline",onClick:m,disabled:a,className:"h-9 w-full gap-2 text-sm",children:[s.jsx(qs,{className:"size-4 shrink-0"}),a?"Uploading...":"Upload image"]}),o.length>0&&s.jsxs("div",{className:"flex items-center justify-between px-0.5",children:[s.jsx("span",{className:"text-xs font-medium text-[#828DA3]",children:"Your images"}),s.jsx("span",{className:"rounded-md bg-[#1E2533] px-1.5 py-0.5 text-[10px] font-medium text-[#828DA3]",children:o.length})]}),s.jsx("div",{className:"flex flex-col gap-2",children:o.length===0?s.jsxs("button",{type:"button",onClick:m,disabled:a,className:"hover:border-primary/30 flex flex-col items-center justify-center gap-2 rounded-lg border border-dashed border-[#2A3242] bg-[#1E2533]/50 px-3 py-8 text-center transition-colors hover:bg-[#1E2533]",children:[s.jsx("div",{className:"flex size-10 items-center justify-center rounded-full bg-[#2A3242]/70",children:s.jsx(gl,{className:"size-4 text-[#586378]"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs font-medium text-[#F4F7FC]",children:"No images yet"}),s.jsx("p",{className:"mt-1 text-[10px] leading-relaxed text-[#828DA3]",children:"Upload PNG, JPG, or SVG to drag onto the canvas"})]})]}):s.jsx(au,{imageHeight:64,galleryId:"diagram-images",images:u,renderImage:d=>{const h=o.find(x=>x?.imageUrl===d);return s.jsx("img",{draggable:!0,src:d,alt:h?.fileName||"Diagram image",title:h?.fileName??"Diagram image",className:H("w-full cursor-grab rounded-md border border-[#2A3242]","hover:border-primary/60 hover:ring-primary/30 transition-all select-none hover:ring-2 active:cursor-grabbing",c===d&&"border-primary ring-primary/40 opacity-40 ring-2"),onDragEnd:()=>l(null),onDragStart:x=>{l(d),Ke(x,"image",{src:d,componentFields:[{componentFieldId:"name",type:X.TextInput,label:"Name",isReadonly:!0,data:[{value:h?.fileName??"Image"}]},{componentFieldId:"description",type:X.TextInput,label:"Description"}]},{width:100},h?.fileName??"Image",d)}})}})})]})})}function je(t){return{componentFieldId:"name",type:X.TextInput,label:"Name",isReadonly:!0,data:[{value:t}]}}const Ae={width:240,height:120},xt="#828DA3",Ft="rgba(130, 141, 163, 0.06)",Ds=xt,Dt={width:420,height:300},du=[{id:"c4-person",label:"Person",icon:s.jsx(yn,{className:"h-4 w-4"}),nodeType:"c4",dragData:{c4Kind:"person",c4Shape:"default",isExternal:!1,fill:de.person.fill,stroke:de.person.stroke,componentFields:[je("Person")]},recommendedSize:Ae},{id:"c4-system",label:"System",icon:s.jsx(La,{className:"h-4 w-4"}),nodeType:"c4",dragData:{c4Kind:"system",c4Shape:"default",isExternal:!1,fill:de.system.fill,stroke:de.system.stroke,componentFields:[je("Software System")]},recommendedSize:Ae},{id:"c4-system-ext",label:"External System",icon:s.jsx(Ii,{className:"h-4 w-4"}),nodeType:"c4",dragData:{c4Kind:"system",c4Shape:"default",isExternal:!0,fill:de.systemExternal.fill,stroke:de.systemExternal.stroke,componentFields:[je("External System")]},recommendedSize:Ae},{id:"c4-person-ext",label:"External Person",icon:s.jsx(yn,{className:"h-4 w-4"}),nodeType:"c4",dragData:{c4Kind:"person",c4Shape:"default",isExternal:!0,fill:de.personExternal.fill,stroke:de.personExternal.stroke,componentFields:[je("External Person")]},recommendedSize:Ae},{id:"c4-container",label:"Container",icon:s.jsx(vn,{className:"h-4 w-4"}),nodeType:"c4",dragData:{c4Kind:"container",c4Shape:"default",isExternal:!1,technology:"",fill:de.container.fill,stroke:de.container.stroke,componentFields:[je("Container")]},recommendedSize:Ae},{id:"c4-container-ext",label:"External Container",icon:s.jsx(vn,{className:"h-4 w-4"}),nodeType:"c4",dragData:{c4Kind:"container",c4Shape:"default",isExternal:!0,technology:"",fill:de.containerExternal.fill,stroke:de.containerExternal.stroke,componentFields:[je("External Container")]},recommendedSize:Ae},{id:"c4-container-db",label:"Database",icon:s.jsx(Aa,{className:"h-4 w-4"}),nodeType:"c4",dragData:{c4Kind:"container",c4Shape:"db",isExternal:!1,fill:de.container.fill,stroke:de.container.stroke,componentFields:[je("Database")]},recommendedSize:Ae},{id:"c4-container-queue",label:"Queue",icon:s.jsx(Fa,{className:"h-4 w-4"}),nodeType:"c4",dragData:{c4Kind:"container",c4Shape:"queue",isExternal:!1,fill:de.container.fill,stroke:de.container.stroke,componentFields:[je("Queue")]},recommendedSize:Ae},{id:"c4-component",label:"Component",icon:s.jsx(jn,{className:"h-4 w-4"}),nodeType:"c4",dragData:{c4Kind:"component",c4Shape:"default",isExternal:!1,fill:de.component.fill,stroke:de.component.stroke,componentFields:[je("Component")]},recommendedSize:Ae},{id:"c4-component-ext",label:"External Component",icon:s.jsx(jn,{className:"h-4 w-4"}),nodeType:"c4",dragData:{c4Kind:"component",c4Shape:"default",isExternal:!0,fill:de.componentExternal.fill,stroke:de.componentExternal.stroke,componentFields:[je("External Component")]},recommendedSize:Ae},{id:"c4-container-bucket",label:"Bucket",icon:s.jsx(Da,{className:"h-4 w-4"}),nodeType:"c4",dragData:{c4Kind:"container",c4Shape:"bucket",isExternal:!1,fill:de.container.fill,stroke:de.container.stroke,componentFields:[je("Bucket")]},recommendedSize:Ae},{id:"c4-container-folder",label:"Directory",icon:s.jsx(Ra,{className:"h-4 w-4"}),nodeType:"c4",dragData:{c4Kind:"container",c4Shape:"folder",isExternal:!1,fill:de.container.fill,stroke:de.container.stroke,componentFields:[je("Directory")]},recommendedSize:Ae},{id:"c4-container-browser",label:"Web Browser",icon:s.jsx(za,{className:"h-4 w-4"}),nodeType:"c4",dragData:{c4Kind:"container",c4Shape:"browser",isExternal:!1,fill:de.container.fill,stroke:de.container.stroke,componentFields:[je("Single-Page Application")]},recommendedSize:Ae},{id:"c4-container-terminal",label:"Terminal",icon:s.jsx(Ma,{className:"h-4 w-4"}),nodeType:"c4",dragData:{c4Kind:"container",c4Shape:"terminal",isExternal:!1,fill:de.container.fill,stroke:de.container.stroke,componentFields:[je("Server-side Application")]},recommendedSize:Ae},{id:"c4-component-uml",label:"Component (UML)",icon:s.jsx(Oa,{className:"h-4 w-4"}),nodeType:"c4",dragData:{c4Kind:"component",c4Shape:"component",isExternal:!1,fill:de.component.fill,stroke:de.component.stroke,componentFields:[je("Component")]},recommendedSize:Ae},{id:"c4-infrastructure-node",label:"Infrastructure Node",icon:s.jsx(Ba,{className:"h-4 w-4"}),nodeType:"c4",dragData:{c4Kind:"node",c4Shape:"ellipse",isExternal:!1,fill:xt,stroke:xt,componentFields:[je("Infrastructure Node")]},recommendedSize:Ae}],uu=[{id:"c4-enterprise-boundary",label:"Enterprise Boundary",icon:s.jsx(qt,{className:"h-4 w-4"}),nodeType:"c4Boundary",dragData:{c4BoundaryKind:"enterprise",backgroundColor:Ft,borderColor:Ds,componentFields:[je("Enterprise")]},recommendedSize:Dt},{id:"c4-system-boundary",label:"System Boundary",icon:s.jsx(qt,{className:"h-4 w-4"}),nodeType:"c4Boundary",dragData:{c4BoundaryKind:"system",backgroundColor:Ft,borderColor:Ds,componentFields:[je("System Boundary")]},recommendedSize:Dt},{id:"c4-container-boundary",label:"Container Boundary",icon:s.jsx(qt,{className:"h-4 w-4"}),nodeType:"c4Boundary",dragData:{c4BoundaryKind:"container",backgroundColor:Ft,borderColor:Ds,componentFields:[je("Container Boundary")]},recommendedSize:Dt},{id:"c4-deployment-node",label:"Deployment Node",icon:s.jsx(Ii,{className:"h-4 w-4"}),nodeType:"c4Boundary",dragData:{c4BoundaryKind:"node",backgroundColor:Ft,borderColor:xt,componentFields:[je("Deployment Node")]},recommendedSize:Dt},{id:"c4-group-boundary",label:"Group",icon:s.jsx(qt,{className:"h-4 w-4"}),nodeType:"c4Boundary",dragData:{c4BoundaryKind:"generic",backgroundColor:Ft,borderColor:xt,componentFields:[je("Group")]},recommendedSize:Dt}],Zt={nodeType:"subDiagram",dragData:{componentFields:[je("Sub Diagram")]},recommendedSize:{width:260,height:200}},mu=[{id:"elements",label:"Elements",tools:du},{id:"boundaries",label:"Boundaries",tools:uu}];function hu(){const[t,e]=y.useState(!0);return s.jsxs(s.Fragment,{children:[s.jsxs("button",{onClick:()=>e(!t),className:H($t,"mt-0.5"),children:[s.jsx("span",{className:"truncate",children:"C4 Model"}),s.jsx(nt,{className:H("size-3 transition-transform duration-200 ease-out",!t&&"-rotate-90")})]}),s.jsx(it,{initial:!1,children:t&&s.jsx(ze.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:"easeOut"},className:"overflow-hidden",children:s.jsx("div",{className:"flex flex-col gap-2 px-2 pt-2 pb-2",children:mu.map(n=>s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx("span",{className:"text-xs font-medium text-[#828DA3]",children:n.label}),s.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:n.tools.map(i=>s.jsx(Mt,{children:s.jsxs(et,{children:[s.jsx(tt,{children:s.jsx("div",{draggable:!0,className:Ys,onDragStart:r=>{Ke(r,i.nodeType,i.dragData,i.recommendedSize,i.label)},children:s.jsx("div",{className:"flex items-center justify-center",children:i.icon})})}),s.jsx(st,{children:i.label})]})},i.id))})]},n.id))})},"category-c4")})]})}function Kn(t,e){const n=t.data?.componentFields;return ai(n,{componentFieldId:e})}function gu(){const{nodes:t,edges:e,setNodes:n,setEdges:i,reactFlowInstance:r,tempDiagramState:a,organizationId:o}=we(),[c,{loading:l}]=zt(Qo),[u,m]=y.useState(!1),[d,h]=y.useState(""),[x,N]=y.useState(""),[f,g]=y.useState(""),[v,b]=y.useState(null),[p,w]=y.useState(null),[S,I]=y.useState(""),[C,A]=y.useState(null),[M,T]=y.useState(null),[R,k]=y.useState(null),O=a!==null,F=t.filter(E=>E.type==="sequenceParticipant").sort((E,B)=>E.position.x-B.position.x),G=new Map;for(const E of e)E.source.startsWith("participant-")&&E.target.startsWith("message-")&&G.set(E.target,{...G.get(E.target),from:E.source}),E.source.startsWith("message-")&&E.target.startsWith("participant-")&&G.set(E.source,{...G.get(E.source),to:E.target});const ae=t.filter(E=>E.id.startsWith("message-")).sort((E,B)=>E.position.y-B.position.y),me=ae.some(E=>E.data?.sequenceNumber!==void 0),Y=F.length>0,Ne=t.length===0,ke=!O&&(Y||Ne),ye=R??ke;function L(E){const B=Kn(E,"name");return B||`Participant ${F.findIndex(ie=>ie.id===E.id)+1}`}function $(E){n(B=>B.map(ee=>({...ee,selected:ee.id===E}))),r?.fitView({nodes:[{id:E}],padding:3,maxZoom:1.2,duration:300})}function te(E,B){w(E),I(B)}function P(){if(!p)return;const E=p,B=S.trim();w(null),n(ee=>ee.map(ie=>{if(ie.id!==E)return ie;const be=ie.data?.componentFields??[];return{...ie,data:{...ie.data,componentFields:cn(be,{...Ri(be,be),name:B})}}}))}function D(){const E=[];if(t.length===0){const ie=Es(t,"Participant A");E.push(ie,Es([ie],"Participant B"))}else E.push(Es(t,"New Participant"));const{nodes:B,edges:ee}=Ue([...t,...E],e);n(B),i(ee),setTimeout(()=>r?.fitView({padding:.2}),50)}async function q(){if(o)try{const{data:E}=await c({variables:{orgId:o,input:{name:"Sequence Diagram",content:"{}"}}}),B=E?.createDiagram?.id;if(!B)throw new Error("Failed to create canvas");window.open(`/diagram/${B}`,"_blank","noopener,noreferrer")}catch{U.error("Failed to create canvas")}}function j(E,B){const ee=[...F],[ie]=ee.splice(E,1);ee.splice(B>E?B-1:B,0,ie);const be=F.map(Ee=>Ee.position.x),Ce=new Map(ee.map((Ee,Ze)=>[Ee.id,be[Ze]])),ce=t.map(Ee=>{const Ze=Ce.get(Ee.id);return Ze===void 0?Ee:{...Ee,position:{...Ee.position,x:Ze}}}),{nodes:xs,edges:bs}=Ue(ce,Ki(ce,e));n(xs),i(bs)}function z(E){const B=new Set([...G].filter(([,ce])=>ce.from===E||ce.to===E).map(([ce])=>ce)),ee=t.filter(ce=>ce.id!==E&&!B.has(ce.id)),ie=e.filter(ce=>ce.source!==E&&ce.target!==E&&!B.has(ce.source)&&!B.has(ce.target)),{nodes:be,edges:Ce}=Ue(ee,ie);n(be),i(Ce),b(null)}function _(){if(u){m(!1),b(null);return}h(F[0]?.id??""),N(F[1]?.id??F[0]?.id??""),g(""),b(null),m(!0)}function Z(){if(!d||!x)return;const{nodes:E,edges:B}=ld(t,e,d,x,f);n(E),i(B),g(""),setTimeout(()=>r?.fitView({padding:.2}),50)}function ge(){const E=new Map(ae.map((be,Ce)=>[be.id,Ce+1])),B=t.map(be=>{const Ce=E.get(be.id);if(Ce===void 0)return be;const ce={...be.data};return me?delete ce.sequenceNumber:ce.sequenceNumber=Ce,{...be,data:ce}}),{nodes:ee,edges:ie}=Ue(B,e);n(ee),i(ie)}function oe(E){if(v===E){m(!1),b(null);return}const B=G.get(E);!B?.from||!B.to||(h(B.from),N(B.to),b(E),m(!0))}function K(){if(!v||!d||!x)return;const{nodes:E,edges:B}=cd(t,e,v,d,x);n(E),i(B),m(!1),b(null)}function fe(E,B){const ee=[...ae],[ie]=ee.splice(E,1);ee.splice(B>E?B-1:B,0,ie);const be=ae.map(Ee=>Ee.position.y),Ce=new Map(ee.map((Ee,Ze)=>[Ee.id,be[Ze]])),ce=t.map(Ee=>{const Ze=Ce.get(Ee.id);return Ze===void 0?Ee:{...Ee,position:{...Ee.position,y:Ze}}}),{nodes:xs,edges:bs}=Ue(ce,e);n(xs),i(bs)}function he(E){const B=t.filter(Ce=>Ce.id!==E),ee=e.filter(Ce=>Ce.source!==E&&Ce.target!==E),{nodes:ie,edges:be}=Ue(B,ee);n(ie),i(be),v===E&&b(null)}function re(E,B,ee){if(C===null||C.list!==B)return;E.preventDefault(),E.dataTransfer.dropEffect="move";const ie=E.currentTarget.getBoundingClientRect(),be=E.clientY>ie.top+ie.height/2;T(be?ee+1:ee)}function xe(E){C!==null&&C.list===E&&M!==null&&(M!==C.index&&M!==C.index+1&&(E==="participants"&&j(C.index,M),E==="messages"&&fe(C.index,M)),A(null),T(null))}return s.jsxs(s.Fragment,{children:[s.jsxs("button",{onClick:()=>k(!ye),className:$t,children:[s.jsx("span",{className:"truncate",children:"Sequence Diagram"}),s.jsx(nt,{className:H("size-3 transition-transform duration-200 ease-out",!ye&&"-rotate-90")})]}),s.jsx(it,{initial:!1,children:ye&&s.jsx(ze.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:"easeOut"},className:"overflow-hidden",children:s.jsxs("div",{className:"flex flex-col",children:[(Y||ke)&&s.jsxs("div",{className:"flex h-8 items-center justify-between gap-2 pr-1 pl-2",children:[s.jsxs("span",{className:"text-[0.8125rem] font-medium text-[#828DA3]",children:["Participants",Y&&s.jsx("span",{className:"ml-1.5 text-[#5A6478]",children:F.length})]}),Y&&ke&&s.jsxs(et,{delayDuration:300,children:[s.jsx(tt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:D,className:"flex size-6 shrink-0 items-center justify-center rounded-[0.375rem] text-[#828DA3] transition-colors hover:bg-[#2A3242] hover:text-[#F4F7FC]",children:s.jsx(Ut,{className:"size-3.5"})})}),s.jsx(st,{side:"right",children:"Add participant"})]})]}),ke&&!Y&&s.jsxs("button",{type:"button",onClick:D,className:"hover:border-primary/40 flex h-9 w-full items-center gap-2 rounded-[0.5rem] border border-dashed border-[#2A3242] px-2 text-sm text-[#F4F7FC] transition-colors hover:bg-[#1E2533]",children:[s.jsx(Ut,{className:"size-4 text-[#828DA3]"}),"New sequence diagram"]}),!ke&&!Y&&s.jsxs("div",{className:"flex flex-col gap-2 px-2 py-1",children:[s.jsx("p",{className:"text-[0.6875rem] leading-relaxed text-[#828DA3]",children:O?"Sequence editing is unavailable while a preview is active.":"Sequence tools are available only in sequence diagrams or empty diagrams."}),!O&&s.jsxs(Q,{preset:"outline",className:"h-8 w-full rounded-[0.5rem] text-xs",disabled:l||!o,onClick:q,children:[l?s.jsx(Jo,{className:"size-4 animate-spin"}):s.jsx(Ut,{className:"size-4"}),"Create New Diagram"]})]}),F.map((E,B)=>s.jsxs("div",{draggable:!O&&p!==E.id,onDragStart:ee=>{ee.dataTransfer.effectAllowed="move",A({list:"participants",index:B})},onDragOver:ee=>re(ee,"participants",B),onDrop:()=>xe("participants"),onDragEnd:()=>{A(null),T(null)},className:H("group relative flex h-8 items-center gap-2 rounded-[0.5rem] pr-1 pl-2 transition-colors hover:bg-[#1E2533]",E.selected&&"bg-[#1E2533]",C?.list==="participants"&&C.index===B&&"opacity-40"),children:[C?.list==="participants"&&M===B&&s.jsx("span",{className:"bg-primary pointer-events-none absolute inset-x-0 -top-px h-0.5"}),C?.list==="participants"&&M===B+1&&s.jsx("span",{className:"bg-primary pointer-events-none absolute inset-x-0 -bottom-px h-0.5"}),s.jsxs("span",{className:"relative flex size-3.5 shrink-0 items-center justify-center",children:[s.jsx("span",{className:"size-2 rounded-full transition-opacity group-hover:opacity-0",style:{background:E.data?.color??di}}),s.jsx(wn,{className:"absolute size-3.5 cursor-grab text-[#828DA3] opacity-0 transition-opacity group-hover:opacity-100"})]}),p===E.id?s.jsx(Fe,{autoFocus:!0,value:S,onChange:ee=>I(ee.target.value),onBlur:P,onKeyDown:ee=>{ee.key==="Enter"&&P(),ee.key==="Escape"&&w(null)},className:"h-6 border-[#2A3242] bg-transparent px-1.5 text-[0.8125rem] text-[#F4F7FC] shadow-none"}):s.jsx("button",{type:"button",onClick:()=>$(E.id),onDoubleClick:()=>te(E.id,L(E)),className:"flex-1 truncate text-left text-[0.8125rem] text-[#F4F7FC]",children:L(E)}),s.jsx("div",{className:"flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100",children:s.jsx("button",{type:"button",disabled:O,onClick:()=>z(E.id),className:H("flex size-6 shrink-0 items-center justify-center rounded-[0.375rem] text-[#828DA3] transition-colors hover:bg-[#2A3242] hover:text-[#F4F7FC] disabled:pointer-events-none disabled:opacity-30","hover:text-red-400"),children:s.jsx(Nn,{className:"size-3.5"})})})]},E.id)),Y&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"mt-2 flex h-8 items-center justify-between gap-2 pr-1 pl-2",children:[s.jsxs("span",{className:"text-[0.8125rem] font-medium text-[#828DA3]",children:["Messages",s.jsx("span",{className:"ml-1.5 text-[#5A6478]",children:ae.length})]}),s.jsxs("div",{className:"flex items-center gap-0.5",children:[s.jsxs(et,{delayDuration:300,children:[s.jsx(tt,{asChild:!0,children:s.jsx("button",{type:"button",disabled:O||ae.length===0,onClick:ge,className:H("flex size-6 shrink-0 items-center justify-center rounded-[0.375rem] border border-transparent transition-colors disabled:pointer-events-none disabled:opacity-30",me?"border-primary/30 bg-primary/10 text-primary":"text-[#828DA3] hover:bg-[#2A3242] hover:text-[#F4F7FC]"),children:s.jsx(_a,{className:"size-3.5"})})}),s.jsx(st,{side:"right",children:me?"Hide message numbers":"Number messages"})]}),s.jsxs(et,{delayDuration:300,children:[s.jsx(tt,{asChild:!0,children:s.jsx("button",{type:"button",disabled:O,onClick:_,className:H("flex size-6 shrink-0 items-center justify-center rounded-[0.375rem] text-[#828DA3] transition-colors hover:bg-[#2A3242] hover:text-[#F4F7FC] disabled:pointer-events-none disabled:opacity-30",u&&"bg-[#2A3242] text-[#F4F7FC]"),children:u?s.jsx(Cn,{className:"size-3.5"}):s.jsx(Ut,{className:"size-3.5"})})}),s.jsx(st,{side:"right",children:u?"Cancel":"Add message"})]})]})]}),u&&s.jsxs("div",{className:"mb-1 flex flex-col gap-2 rounded-[0.5rem] border border-[#2A3242] p-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsxs(_e,{value:d,onValueChange:h,children:[s.jsx(Pe,{className:"h-8 w-full min-w-0 border-[#2A3242] bg-transparent text-xs text-[#F4F7FC] shadow-none placeholder:text-[#828DA3]",children:s.jsx(He,{placeholder:"From"})}),s.jsx($e,{children:F.map(E=>s.jsx(Le,{value:E.id,children:L(E)},E.id))})]}),s.jsx(Sn,{className:"size-3.5 shrink-0 text-[#828DA3]"}),s.jsxs(_e,{value:x,onValueChange:N,children:[s.jsx(Pe,{className:"h-8 w-full min-w-0 border-[#2A3242] bg-transparent text-xs text-[#F4F7FC] shadow-none placeholder:text-[#828DA3]",children:s.jsx(He,{placeholder:"To"})}),s.jsx($e,{children:F.map(E=>s.jsx(Le,{value:E.id,children:L(E)},E.id))})]})]}),!v&&s.jsx(Fe,{autoFocus:!0,value:f,onChange:E=>g(E.target.value),placeholder:"Message label",className:"h-8 w-full min-w-0 border-[#2A3242] bg-transparent text-xs text-[#F4F7FC] shadow-none placeholder:text-[#828DA3]",onKeyDown:E=>{E.key==="Enter"&&Z()}}),s.jsx(Q,{className:"h-8 w-full text-xs",disabled:!d||!x,onClick:v?K:Z,children:v?"Update message":"Add message"})]}),ae.length===0&&!u&&s.jsx("p",{className:"px-2 pb-1 text-[0.6875rem] text-[#828DA3]",children:"No messages yet."}),ae.map((E,B)=>{const ee=G.get(E.id),ie=F.find(ce=>ce.id===ee?.from),be=F.find(ce=>ce.id===ee?.to),Ce=Kn(E,"name");return s.jsxs("div",{draggable:!O&&p!==E.id&&v!==E.id,onDragStart:ce=>{ce.dataTransfer.effectAllowed="move",A({list:"messages",index:B})},onDragOver:ce=>re(ce,"messages",B),onDrop:()=>xe("messages"),onDragEnd:()=>{A(null),T(null)},className:H("group relative flex min-h-8 items-center gap-2 rounded-[0.5rem] py-1 pr-1 pl-2 transition-colors hover:bg-[#1E2533]",E.selected&&"bg-[#1E2533]",C?.list==="messages"&&C.index===B&&"opacity-40"),children:[C?.list==="messages"&&M===B&&s.jsx("span",{className:"bg-primary pointer-events-none absolute inset-x-0 -top-px h-0.5"}),C?.list==="messages"&&M===B+1&&s.jsx("span",{className:"bg-primary pointer-events-none absolute inset-x-0 -bottom-px h-0.5"}),s.jsxs("span",{className:"relative flex w-3 shrink-0 items-center justify-center",children:[s.jsx("span",{className:"text-[0.6875rem] text-[#5A6478] transition-opacity group-hover:opacity-0",children:B+1}),s.jsx(wn,{className:"absolute size-3.5 cursor-grab text-[#828DA3] opacity-0 transition-opacity group-hover:opacity-100"})]}),s.jsx("button",{type:"button",onClick:()=>$(E.id),onDoubleClick:()=>te(E.id,Ce??""),className:"flex min-w-0 flex-1 flex-col items-start gap-0.5 text-left",children:p===E.id?null:s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"flex w-full min-w-0 items-center gap-1 text-[0.8125rem] text-[#F4F7FC]",children:[s.jsx("span",{className:"truncate",children:ie?L(ie):"Unknown"}),s.jsx(Sn,{className:"size-3 shrink-0 text-[#828DA3]"}),s.jsx("span",{className:"truncate",children:be?L(be):"Unknown"})]}),Ce&&s.jsx("span",{className:"w-full truncate text-[0.6875rem] text-[#828DA3]",children:Ce})]})}),p===E.id&&s.jsx(Fe,{autoFocus:!0,value:S,onChange:ce=>I(ce.target.value),onBlur:P,onKeyDown:ce=>{ce.key==="Enter"&&P(),ce.key==="Escape"&&w(null)},className:"h-6 border-[#2A3242] bg-transparent px-1.5 text-[0.8125rem] text-[#F4F7FC] shadow-none"}),s.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100",children:[s.jsx("button",{type:"button",disabled:O,onClick:()=>oe(E.id),title:v===E.id?"Cancel editing participants":"Edit participants",className:H("flex size-6 shrink-0 items-center justify-center rounded-[0.375rem] text-[#828DA3] transition-colors hover:bg-[#2A3242] hover:text-[#F4F7FC] disabled:pointer-events-none disabled:opacity-30",v===E.id&&"bg-[#2A3242] text-[#F4F7FC]"),children:v===E.id?s.jsx(Cn,{className:"size-3.5"}):s.jsx(Pa,{className:"size-3.5"})}),s.jsx("button",{type:"button",disabled:O,onClick:()=>he(E.id),className:H("flex size-6 shrink-0 items-center justify-center rounded-[0.375rem] text-[#828DA3] transition-colors hover:bg-[#2A3242] hover:text-[#F4F7FC] disabled:pointer-events-none disabled:opacity-30","hover:text-red-400"),children:s.jsx(Nn,{className:"size-3.5"})})]})]},E.id)})]})]})},"category-sequence")})]})}const pu=Zs(`
|
|
224
|
+
`);function cu(){const{diagramId:t,organizationId:e}=we(),{data:n,refetch:i}=ut(ou,{variables:{orgId:e,diagramId:t},skip:!t||!e}),[r,{loading:a}]=zt(lu),o=y.useMemo(()=>Be(n?.diagramImages),[n?.diagramImages]),[c,l]=y.useState(null),u=y.useMemo(()=>o.flatMap(d=>d?.imageUrl?[d.imageUrl]:[]),[o]);async function m(){if(!(!t||!e))try{const[d]=await as({accept:"image/*"});if(!d)return;const h=await Mi(e,d);await r({variables:{orgId:e,diagramId:t,input:{assetId:h,fileName:d.name,order:o.length}}}),await i()}catch(d){console.error("Error uploading image:",d),U.error("Failed to upload image")}}return s.jsx(Xe,{className:"left-18",children:s.jsxs("div",{className:"flex w-[15rem] flex-col gap-3 p-2",children:[s.jsxs(Q,{preset:"outline",onClick:m,disabled:a,className:"h-9 w-full gap-2 text-sm",children:[s.jsx(qs,{className:"size-4 shrink-0"}),a?"Uploading...":"Upload image"]}),o.length>0&&s.jsxs("div",{className:"flex items-center justify-between px-0.5",children:[s.jsx("span",{className:"text-xs font-medium text-[#828DA3]",children:"Your images"}),s.jsx("span",{className:"rounded-md bg-[#1E2533] px-1.5 py-0.5 text-[10px] font-medium text-[#828DA3]",children:o.length})]}),s.jsx("div",{className:"flex flex-col gap-2",children:o.length===0?s.jsxs("button",{type:"button",onClick:m,disabled:a,className:"hover:border-primary/30 flex flex-col items-center justify-center gap-2 rounded-lg border border-dashed border-[#2A3242] bg-[#1E2533]/50 px-3 py-8 text-center transition-colors hover:bg-[#1E2533]",children:[s.jsx("div",{className:"flex size-10 items-center justify-center rounded-full bg-[#2A3242]/70",children:s.jsx(pl,{className:"size-4 text-[#586378]"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs font-medium text-[#F4F7FC]",children:"No images yet"}),s.jsx("p",{className:"mt-1 text-[10px] leading-relaxed text-[#828DA3]",children:"Upload PNG, JPG, or SVG to drag onto the canvas"})]})]}):s.jsx(au,{imageHeight:64,galleryId:"diagram-images",images:u,renderImage:d=>{const h=o.find(x=>x?.imageUrl===d);return s.jsx("img",{draggable:!0,src:d,alt:h?.fileName||"Diagram image",title:h?.fileName??"Diagram image",className:H("w-full cursor-grab rounded-md border border-[#2A3242]","hover:border-primary/60 hover:ring-primary/30 transition-all select-none hover:ring-2 active:cursor-grabbing",c===d&&"border-primary ring-primary/40 opacity-40 ring-2"),onDragEnd:()=>l(null),onDragStart:x=>{l(d),Ke(x,"image",{src:d,componentFields:[{componentFieldId:"name",type:X.TextInput,label:"Name",isReadonly:!0,data:[{value:h?.fileName??"Image"}]},{componentFieldId:"description",type:X.TextInput,label:"Description"}]},{width:100},h?.fileName??"Image",d)}})}})})]})})}function je(t){return{componentFieldId:"name",type:X.TextInput,label:"Name",isReadonly:!0,data:[{value:t}]}}const Ae={width:240,height:120},xt="#828DA3",Ft="rgba(130, 141, 163, 0.06)",Ds=xt,Dt={width:420,height:300},du=[{id:"c4-person",label:"Person",icon:s.jsx(vn,{className:"h-4 w-4"}),nodeType:"c4",dragData:{c4Kind:"person",c4Shape:"default",isExternal:!1,fill:de.person.fill,stroke:de.person.stroke,componentFields:[je("Person")]},recommendedSize:Ae},{id:"c4-system",label:"System",icon:s.jsx(Aa,{className:"h-4 w-4"}),nodeType:"c4",dragData:{c4Kind:"system",c4Shape:"default",isExternal:!1,fill:de.system.fill,stroke:de.system.stroke,componentFields:[je("Software System")]},recommendedSize:Ae},{id:"c4-system-ext",label:"External System",icon:s.jsx(Ti,{className:"h-4 w-4"}),nodeType:"c4",dragData:{c4Kind:"system",c4Shape:"default",isExternal:!0,fill:de.systemExternal.fill,stroke:de.systemExternal.stroke,componentFields:[je("External System")]},recommendedSize:Ae},{id:"c4-person-ext",label:"External Person",icon:s.jsx(vn,{className:"h-4 w-4"}),nodeType:"c4",dragData:{c4Kind:"person",c4Shape:"default",isExternal:!0,fill:de.personExternal.fill,stroke:de.personExternal.stroke,componentFields:[je("External Person")]},recommendedSize:Ae},{id:"c4-container",label:"Container",icon:s.jsx(jn,{className:"h-4 w-4"}),nodeType:"c4",dragData:{c4Kind:"container",c4Shape:"default",isExternal:!1,technology:"",fill:de.container.fill,stroke:de.container.stroke,componentFields:[je("Container")]},recommendedSize:Ae},{id:"c4-container-ext",label:"External Container",icon:s.jsx(jn,{className:"h-4 w-4"}),nodeType:"c4",dragData:{c4Kind:"container",c4Shape:"default",isExternal:!0,technology:"",fill:de.containerExternal.fill,stroke:de.containerExternal.stroke,componentFields:[je("External Container")]},recommendedSize:Ae},{id:"c4-container-db",label:"Database",icon:s.jsx(Fa,{className:"h-4 w-4"}),nodeType:"c4",dragData:{c4Kind:"container",c4Shape:"db",isExternal:!1,fill:de.container.fill,stroke:de.container.stroke,componentFields:[je("Database")]},recommendedSize:Ae},{id:"c4-container-queue",label:"Queue",icon:s.jsx(Da,{className:"h-4 w-4"}),nodeType:"c4",dragData:{c4Kind:"container",c4Shape:"queue",isExternal:!1,fill:de.container.fill,stroke:de.container.stroke,componentFields:[je("Queue")]},recommendedSize:Ae},{id:"c4-component",label:"Component",icon:s.jsx(wn,{className:"h-4 w-4"}),nodeType:"c4",dragData:{c4Kind:"component",c4Shape:"default",isExternal:!1,fill:de.component.fill,stroke:de.component.stroke,componentFields:[je("Component")]},recommendedSize:Ae},{id:"c4-component-ext",label:"External Component",icon:s.jsx(wn,{className:"h-4 w-4"}),nodeType:"c4",dragData:{c4Kind:"component",c4Shape:"default",isExternal:!0,fill:de.componentExternal.fill,stroke:de.componentExternal.stroke,componentFields:[je("External Component")]},recommendedSize:Ae},{id:"c4-container-bucket",label:"Bucket",icon:s.jsx(Ra,{className:"h-4 w-4"}),nodeType:"c4",dragData:{c4Kind:"container",c4Shape:"bucket",isExternal:!1,fill:de.container.fill,stroke:de.container.stroke,componentFields:[je("Bucket")]},recommendedSize:Ae},{id:"c4-container-folder",label:"Directory",icon:s.jsx(za,{className:"h-4 w-4"}),nodeType:"c4",dragData:{c4Kind:"container",c4Shape:"folder",isExternal:!1,fill:de.container.fill,stroke:de.container.stroke,componentFields:[je("Directory")]},recommendedSize:Ae},{id:"c4-container-browser",label:"Web Browser",icon:s.jsx(Ma,{className:"h-4 w-4"}),nodeType:"c4",dragData:{c4Kind:"container",c4Shape:"browser",isExternal:!1,fill:de.container.fill,stroke:de.container.stroke,componentFields:[je("Single-Page Application")]},recommendedSize:Ae},{id:"c4-container-terminal",label:"Terminal",icon:s.jsx(Oa,{className:"h-4 w-4"}),nodeType:"c4",dragData:{c4Kind:"container",c4Shape:"terminal",isExternal:!1,fill:de.container.fill,stroke:de.container.stroke,componentFields:[je("Server-side Application")]},recommendedSize:Ae},{id:"c4-component-uml",label:"Component (UML)",icon:s.jsx(Ba,{className:"h-4 w-4"}),nodeType:"c4",dragData:{c4Kind:"component",c4Shape:"component",isExternal:!1,fill:de.component.fill,stroke:de.component.stroke,componentFields:[je("Component")]},recommendedSize:Ae},{id:"c4-infrastructure-node",label:"Infrastructure Node",icon:s.jsx(_a,{className:"h-4 w-4"}),nodeType:"c4",dragData:{c4Kind:"node",c4Shape:"ellipse",isExternal:!1,fill:xt,stroke:xt,componentFields:[je("Infrastructure Node")]},recommendedSize:Ae}],uu=[{id:"c4-enterprise-boundary",label:"Enterprise Boundary",icon:s.jsx(qt,{className:"h-4 w-4"}),nodeType:"c4Boundary",dragData:{c4BoundaryKind:"enterprise",backgroundColor:Ft,borderColor:Ds,componentFields:[je("Enterprise")]},recommendedSize:Dt},{id:"c4-system-boundary",label:"System Boundary",icon:s.jsx(qt,{className:"h-4 w-4"}),nodeType:"c4Boundary",dragData:{c4BoundaryKind:"system",backgroundColor:Ft,borderColor:Ds,componentFields:[je("System Boundary")]},recommendedSize:Dt},{id:"c4-container-boundary",label:"Container Boundary",icon:s.jsx(qt,{className:"h-4 w-4"}),nodeType:"c4Boundary",dragData:{c4BoundaryKind:"container",backgroundColor:Ft,borderColor:Ds,componentFields:[je("Container Boundary")]},recommendedSize:Dt},{id:"c4-deployment-node",label:"Deployment Node",icon:s.jsx(Ti,{className:"h-4 w-4"}),nodeType:"c4Boundary",dragData:{c4BoundaryKind:"node",backgroundColor:Ft,borderColor:xt,componentFields:[je("Deployment Node")]},recommendedSize:Dt},{id:"c4-group-boundary",label:"Group",icon:s.jsx(qt,{className:"h-4 w-4"}),nodeType:"c4Boundary",dragData:{c4BoundaryKind:"generic",backgroundColor:Ft,borderColor:xt,componentFields:[je("Group")]},recommendedSize:Dt}],Zt={nodeType:"subDiagram",dragData:{componentFields:[je("Sub Diagram")]},recommendedSize:{width:260,height:200}},mu=[{id:"elements",label:"Elements",tools:du},{id:"boundaries",label:"Boundaries",tools:uu}];function hu(){const[t,e]=y.useState(!0);return s.jsxs(s.Fragment,{children:[s.jsxs("button",{onClick:()=>e(!t),className:H($t,"mt-0.5"),children:[s.jsx("span",{className:"truncate",children:"C4 Model"}),s.jsx(nt,{className:H("size-3 transition-transform duration-200 ease-out",!t&&"-rotate-90")})]}),s.jsx(it,{initial:!1,children:t&&s.jsx(ze.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:"easeOut"},className:"overflow-hidden",children:s.jsx("div",{className:"flex flex-col gap-2 px-2 pt-2 pb-2",children:mu.map(n=>s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx("span",{className:"text-xs font-medium text-[#828DA3]",children:n.label}),s.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:n.tools.map(i=>s.jsx(Mt,{children:s.jsxs(et,{children:[s.jsx(tt,{children:s.jsx("div",{draggable:!0,className:Ys,onDragStart:r=>{Ke(r,i.nodeType,i.dragData,i.recommendedSize,i.label)},children:s.jsx("div",{className:"flex items-center justify-center",children:i.icon})})}),s.jsx(st,{children:i.label})]})},i.id))})]},n.id))})},"category-c4")})]})}function Xn(t,e){const n=t.data?.componentFields;return ai(n,{componentFieldId:e})}function gu(){const{nodes:t,edges:e,setNodes:n,setEdges:i,reactFlowInstance:r,tempDiagramState:a,organizationId:o}=we(),[c,{loading:l}]=zt(Zo),[u,m]=y.useState(!1),[d,h]=y.useState(""),[x,N]=y.useState(""),[f,g]=y.useState(""),[v,b]=y.useState(null),[p,w]=y.useState(null),[S,I]=y.useState(""),[C,A]=y.useState(null),[M,T]=y.useState(null),[R,k]=y.useState(null),O=a!==null,F=t.filter(E=>E.type==="sequenceParticipant").sort((E,B)=>E.position.x-B.position.x),G=new Map;for(const E of e)E.source.startsWith("participant-")&&E.target.startsWith("message-")&&G.set(E.target,{...G.get(E.target),from:E.source}),E.source.startsWith("message-")&&E.target.startsWith("participant-")&&G.set(E.source,{...G.get(E.source),to:E.target});const ae=t.filter(E=>E.id.startsWith("message-")).sort((E,B)=>E.position.y-B.position.y),me=ae.some(E=>E.data?.sequenceNumber!==void 0),Y=F.length>0,Ne=t.length===0,ke=!O&&(Y||Ne),ye=R??ke;function L(E){const B=Xn(E,"name");return B||`Participant ${F.findIndex(ie=>ie.id===E.id)+1}`}function $(E){n(B=>B.map(ee=>({...ee,selected:ee.id===E}))),r?.fitView({nodes:[{id:E}],padding:3,maxZoom:1.2,duration:300})}function te(E,B){w(E),I(B)}function P(){if(!p)return;const E=p,B=S.trim();w(null),n(ee=>ee.map(ie=>{if(ie.id!==E)return ie;const be=ie.data?.componentFields??[];return{...ie,data:{...ie.data,componentFields:ln(be,{...zi(be,be),name:B})}}}))}function D(){const E=[];if(t.length===0){const ie=Es(t,"Participant A");E.push(ie,Es([ie],"Participant B"))}else E.push(Es(t,"New Participant"));const{nodes:B,edges:ee}=Ue([...t,...E],e);n(B),i(ee),setTimeout(()=>r?.fitView({padding:.2}),50)}async function q(){if(o)try{const{data:E}=await c({variables:{orgId:o,input:{name:"Sequence Diagram",content:"{}"}}}),B=E?.createDiagram?.id;if(!B)throw new Error("Failed to create canvas");window.open(`/diagram/${B}`,"_blank","noopener,noreferrer")}catch{U.error("Failed to create canvas")}}function j(E,B){const ee=[...F],[ie]=ee.splice(E,1);ee.splice(B>E?B-1:B,0,ie);const be=F.map(Ee=>Ee.position.x),Ce=new Map(ee.map((Ee,Ze)=>[Ee.id,be[Ze]])),ce=t.map(Ee=>{const Ze=Ce.get(Ee.id);return Ze===void 0?Ee:{...Ee,position:{...Ee.position,x:Ze}}}),{nodes:xs,edges:bs}=Ue(ce,Xi(ce,e));n(xs),i(bs)}function z(E){const B=new Set([...G].filter(([,ce])=>ce.from===E||ce.to===E).map(([ce])=>ce)),ee=t.filter(ce=>ce.id!==E&&!B.has(ce.id)),ie=e.filter(ce=>ce.source!==E&&ce.target!==E&&!B.has(ce.source)&&!B.has(ce.target)),{nodes:be,edges:Ce}=Ue(ee,ie);n(be),i(Ce),b(null)}function _(){if(u){m(!1),b(null);return}h(F[0]?.id??""),N(F[1]?.id??F[0]?.id??""),g(""),b(null),m(!0)}function Z(){if(!d||!x)return;const{nodes:E,edges:B}=cd(t,e,d,x,f);n(E),i(B),g(""),setTimeout(()=>r?.fitView({padding:.2}),50)}function ge(){const E=new Map(ae.map((be,Ce)=>[be.id,Ce+1])),B=t.map(be=>{const Ce=E.get(be.id);if(Ce===void 0)return be;const ce={...be.data};return me?delete ce.sequenceNumber:ce.sequenceNumber=Ce,{...be,data:ce}}),{nodes:ee,edges:ie}=Ue(B,e);n(ee),i(ie)}function oe(E){if(v===E){m(!1),b(null);return}const B=G.get(E);!B?.from||!B.to||(h(B.from),N(B.to),b(E),m(!0))}function K(){if(!v||!d||!x)return;const{nodes:E,edges:B}=dd(t,e,v,d,x);n(E),i(B),m(!1),b(null)}function fe(E,B){const ee=[...ae],[ie]=ee.splice(E,1);ee.splice(B>E?B-1:B,0,ie);const be=ae.map(Ee=>Ee.position.y),Ce=new Map(ee.map((Ee,Ze)=>[Ee.id,be[Ze]])),ce=t.map(Ee=>{const Ze=Ce.get(Ee.id);return Ze===void 0?Ee:{...Ee,position:{...Ee.position,y:Ze}}}),{nodes:xs,edges:bs}=Ue(ce,e);n(xs),i(bs)}function he(E){const B=t.filter(Ce=>Ce.id!==E),ee=e.filter(Ce=>Ce.source!==E&&Ce.target!==E),{nodes:ie,edges:be}=Ue(B,ee);n(ie),i(be),v===E&&b(null)}function re(E,B,ee){if(C===null||C.list!==B)return;E.preventDefault(),E.dataTransfer.dropEffect="move";const ie=E.currentTarget.getBoundingClientRect(),be=E.clientY>ie.top+ie.height/2;T(be?ee+1:ee)}function xe(E){C!==null&&C.list===E&&M!==null&&(M!==C.index&&M!==C.index+1&&(E==="participants"&&j(C.index,M),E==="messages"&&fe(C.index,M)),A(null),T(null))}return s.jsxs(s.Fragment,{children:[s.jsxs("button",{onClick:()=>k(!ye),className:$t,children:[s.jsx("span",{className:"truncate",children:"Sequence Diagram"}),s.jsx(nt,{className:H("size-3 transition-transform duration-200 ease-out",!ye&&"-rotate-90")})]}),s.jsx(it,{initial:!1,children:ye&&s.jsx(ze.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:"easeOut"},className:"overflow-hidden",children:s.jsxs("div",{className:"flex flex-col",children:[(Y||ke)&&s.jsxs("div",{className:"flex h-8 items-center justify-between gap-2 pr-1 pl-2",children:[s.jsxs("span",{className:"text-[0.8125rem] font-medium text-[#828DA3]",children:["Participants",Y&&s.jsx("span",{className:"ml-1.5 text-[#5A6478]",children:F.length})]}),Y&&ke&&s.jsxs(et,{delayDuration:300,children:[s.jsx(tt,{asChild:!0,children:s.jsx("button",{type:"button",onClick:D,className:"flex size-6 shrink-0 items-center justify-center rounded-[0.375rem] text-[#828DA3] transition-colors hover:bg-[#2A3242] hover:text-[#F4F7FC]",children:s.jsx(Ut,{className:"size-3.5"})})}),s.jsx(st,{side:"right",children:"Add participant"})]})]}),ke&&!Y&&s.jsxs("button",{type:"button",onClick:D,className:"hover:border-primary/40 flex h-9 w-full items-center gap-2 rounded-[0.5rem] border border-dashed border-[#2A3242] px-2 text-sm text-[#F4F7FC] transition-colors hover:bg-[#1E2533]",children:[s.jsx(Ut,{className:"size-4 text-[#828DA3]"}),"New sequence diagram"]}),!ke&&!Y&&s.jsxs("div",{className:"flex flex-col gap-2 px-2 py-1",children:[s.jsx("p",{className:"text-[0.6875rem] leading-relaxed text-[#828DA3]",children:O?"Sequence editing is unavailable while a preview is active.":"Sequence tools are available only in sequence diagrams or empty diagrams."}),!O&&s.jsxs(Q,{preset:"outline",className:"h-8 w-full rounded-[0.5rem] text-xs",disabled:l||!o,onClick:q,children:[l?s.jsx(el,{className:"size-4 animate-spin"}):s.jsx(Ut,{className:"size-4"}),"Create New Diagram"]})]}),F.map((E,B)=>s.jsxs("div",{draggable:!O&&p!==E.id,onDragStart:ee=>{ee.dataTransfer.effectAllowed="move",A({list:"participants",index:B})},onDragOver:ee=>re(ee,"participants",B),onDrop:()=>xe("participants"),onDragEnd:()=>{A(null),T(null)},className:H("group relative flex h-8 items-center gap-2 rounded-[0.5rem] pr-1 pl-2 transition-colors hover:bg-[#1E2533]",E.selected&&"bg-[#1E2533]",C?.list==="participants"&&C.index===B&&"opacity-40"),children:[C?.list==="participants"&&M===B&&s.jsx("span",{className:"bg-primary pointer-events-none absolute inset-x-0 -top-px h-0.5"}),C?.list==="participants"&&M===B+1&&s.jsx("span",{className:"bg-primary pointer-events-none absolute inset-x-0 -bottom-px h-0.5"}),s.jsxs("span",{className:"relative flex size-3.5 shrink-0 items-center justify-center",children:[s.jsx("span",{className:"size-2 rounded-full transition-opacity group-hover:opacity-0",style:{background:E.data?.color??di}}),s.jsx(Nn,{className:"absolute size-3.5 cursor-grab text-[#828DA3] opacity-0 transition-opacity group-hover:opacity-100"})]}),p===E.id?s.jsx(Fe,{autoFocus:!0,value:S,onChange:ee=>I(ee.target.value),onBlur:P,onKeyDown:ee=>{ee.key==="Enter"&&P(),ee.key==="Escape"&&w(null)},className:"h-6 border-[#2A3242] bg-transparent px-1.5 text-[0.8125rem] text-[#F4F7FC] shadow-none"}):s.jsx("button",{type:"button",onClick:()=>$(E.id),onDoubleClick:()=>te(E.id,L(E)),className:"flex-1 truncate text-left text-[0.8125rem] text-[#F4F7FC]",children:L(E)}),s.jsx("div",{className:"flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100",children:s.jsx("button",{type:"button",disabled:O,onClick:()=>z(E.id),className:H("flex size-6 shrink-0 items-center justify-center rounded-[0.375rem] text-[#828DA3] transition-colors hover:bg-[#2A3242] hover:text-[#F4F7FC] disabled:pointer-events-none disabled:opacity-30","hover:text-red-400"),children:s.jsx(Cn,{className:"size-3.5"})})})]},E.id)),Y&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"mt-2 flex h-8 items-center justify-between gap-2 pr-1 pl-2",children:[s.jsxs("span",{className:"text-[0.8125rem] font-medium text-[#828DA3]",children:["Messages",s.jsx("span",{className:"ml-1.5 text-[#5A6478]",children:ae.length})]}),s.jsxs("div",{className:"flex items-center gap-0.5",children:[s.jsxs(et,{delayDuration:300,children:[s.jsx(tt,{asChild:!0,children:s.jsx("button",{type:"button",disabled:O||ae.length===0,onClick:ge,className:H("flex size-6 shrink-0 items-center justify-center rounded-[0.375rem] border border-transparent transition-colors disabled:pointer-events-none disabled:opacity-30",me?"border-primary/30 bg-primary/10 text-primary":"text-[#828DA3] hover:bg-[#2A3242] hover:text-[#F4F7FC]"),children:s.jsx(Pa,{className:"size-3.5"})})}),s.jsx(st,{side:"right",children:me?"Hide message numbers":"Number messages"})]}),s.jsxs(et,{delayDuration:300,children:[s.jsx(tt,{asChild:!0,children:s.jsx("button",{type:"button",disabled:O,onClick:_,className:H("flex size-6 shrink-0 items-center justify-center rounded-[0.375rem] text-[#828DA3] transition-colors hover:bg-[#2A3242] hover:text-[#F4F7FC] disabled:pointer-events-none disabled:opacity-30",u&&"bg-[#2A3242] text-[#F4F7FC]"),children:u?s.jsx(Sn,{className:"size-3.5"}):s.jsx(Ut,{className:"size-3.5"})})}),s.jsx(st,{side:"right",children:u?"Cancel":"Add message"})]})]})]}),u&&s.jsxs("div",{className:"mb-1 flex flex-col gap-2 rounded-[0.5rem] border border-[#2A3242] p-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsxs(_e,{value:d,onValueChange:h,children:[s.jsx(Pe,{className:"h-8 w-full min-w-0 border-[#2A3242] bg-transparent text-xs text-[#F4F7FC] shadow-none placeholder:text-[#828DA3]",children:s.jsx(He,{placeholder:"From"})}),s.jsx($e,{children:F.map(E=>s.jsx(Le,{value:E.id,children:L(E)},E.id))})]}),s.jsx(kn,{className:"size-3.5 shrink-0 text-[#828DA3]"}),s.jsxs(_e,{value:x,onValueChange:N,children:[s.jsx(Pe,{className:"h-8 w-full min-w-0 border-[#2A3242] bg-transparent text-xs text-[#F4F7FC] shadow-none placeholder:text-[#828DA3]",children:s.jsx(He,{placeholder:"To"})}),s.jsx($e,{children:F.map(E=>s.jsx(Le,{value:E.id,children:L(E)},E.id))})]})]}),!v&&s.jsx(Fe,{autoFocus:!0,value:f,onChange:E=>g(E.target.value),placeholder:"Message label",className:"h-8 w-full min-w-0 border-[#2A3242] bg-transparent text-xs text-[#F4F7FC] shadow-none placeholder:text-[#828DA3]",onKeyDown:E=>{E.key==="Enter"&&Z()}}),s.jsx(Q,{className:"h-8 w-full text-xs",disabled:!d||!x,onClick:v?K:Z,children:v?"Update message":"Add message"})]}),ae.length===0&&!u&&s.jsx("p",{className:"px-2 pb-1 text-[0.6875rem] text-[#828DA3]",children:"No messages yet."}),ae.map((E,B)=>{const ee=G.get(E.id),ie=F.find(ce=>ce.id===ee?.from),be=F.find(ce=>ce.id===ee?.to),Ce=Xn(E,"name");return s.jsxs("div",{draggable:!O&&p!==E.id&&v!==E.id,onDragStart:ce=>{ce.dataTransfer.effectAllowed="move",A({list:"messages",index:B})},onDragOver:ce=>re(ce,"messages",B),onDrop:()=>xe("messages"),onDragEnd:()=>{A(null),T(null)},className:H("group relative flex min-h-8 items-center gap-2 rounded-[0.5rem] py-1 pr-1 pl-2 transition-colors hover:bg-[#1E2533]",E.selected&&"bg-[#1E2533]",C?.list==="messages"&&C.index===B&&"opacity-40"),children:[C?.list==="messages"&&M===B&&s.jsx("span",{className:"bg-primary pointer-events-none absolute inset-x-0 -top-px h-0.5"}),C?.list==="messages"&&M===B+1&&s.jsx("span",{className:"bg-primary pointer-events-none absolute inset-x-0 -bottom-px h-0.5"}),s.jsxs("span",{className:"relative flex w-3 shrink-0 items-center justify-center",children:[s.jsx("span",{className:"text-[0.6875rem] text-[#5A6478] transition-opacity group-hover:opacity-0",children:B+1}),s.jsx(Nn,{className:"absolute size-3.5 cursor-grab text-[#828DA3] opacity-0 transition-opacity group-hover:opacity-100"})]}),s.jsx("button",{type:"button",onClick:()=>$(E.id),onDoubleClick:()=>te(E.id,Ce??""),className:"flex min-w-0 flex-1 flex-col items-start gap-0.5 text-left",children:p===E.id?null:s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"flex w-full min-w-0 items-center gap-1 text-[0.8125rem] text-[#F4F7FC]",children:[s.jsx("span",{className:"truncate",children:ie?L(ie):"Unknown"}),s.jsx(kn,{className:"size-3 shrink-0 text-[#828DA3]"}),s.jsx("span",{className:"truncate",children:be?L(be):"Unknown"})]}),Ce&&s.jsx("span",{className:"w-full truncate text-[0.6875rem] text-[#828DA3]",children:Ce})]})}),p===E.id&&s.jsx(Fe,{autoFocus:!0,value:S,onChange:ce=>I(ce.target.value),onBlur:P,onKeyDown:ce=>{ce.key==="Enter"&&P(),ce.key==="Escape"&&w(null)},className:"h-6 border-[#2A3242] bg-transparent px-1.5 text-[0.8125rem] text-[#F4F7FC] shadow-none"}),s.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100",children:[s.jsx("button",{type:"button",disabled:O,onClick:()=>oe(E.id),title:v===E.id?"Cancel editing participants":"Edit participants",className:H("flex size-6 shrink-0 items-center justify-center rounded-[0.375rem] text-[#828DA3] transition-colors hover:bg-[#2A3242] hover:text-[#F4F7FC] disabled:pointer-events-none disabled:opacity-30",v===E.id&&"bg-[#2A3242] text-[#F4F7FC]"),children:v===E.id?s.jsx(Sn,{className:"size-3.5"}):s.jsx(Ha,{className:"size-3.5"})}),s.jsx("button",{type:"button",disabled:O,onClick:()=>he(E.id),className:H("flex size-6 shrink-0 items-center justify-center rounded-[0.375rem] text-[#828DA3] transition-colors hover:bg-[#2A3242] hover:text-[#F4F7FC] disabled:pointer-events-none disabled:opacity-30","hover:text-red-400"),children:s.jsx(Cn,{className:"size-3.5"})})]})]},E.id)})]})]})},"category-sequence")})]})}const pu=cn(`
|
|
225
225
|
query Teams($orgId: ID!) {
|
|
226
226
|
teams(orgId: $orgId) {
|
|
227
227
|
id
|
|
228
228
|
name
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
|
-
`),Jt=20,Rs="all";function rr({selectedDiagramId:t,onSelect:e,onDragStart:n}){const{organizationId:i,diagramId:r}=we(),[a,o]=y.useState(""),c=el(a,300),[l,u]=y.useState(Rs),[m,d]=y.useState(Jt),h=ut(pu,{variables:{orgId:i},skip:!i}),{data:x,loading:N}=ut(Zo,{variables:{orgId:i,search:c||void 0,teamId:l===Rs?void 0:l,limit:m,offset:0},skip:!i,fetchPolicy:"cache-and-network"}),f=Be(h.data?.teams??[]),g=Be(x?.diagrams?.items??[]),v=g.filter(p=>p.id!==r),b=g.length<(x?.diagrams?.totalCount??0);return s.jsxs(s.Fragment,{children:[f.length>0&&s.jsxs(_e,{value:l,onValueChange:p=>{u(p),d(Jt)},children:[s.jsx(Pe,{className:"border-stock bg-input h-9 w-full rounded-md text-sm",children:s.jsx(He,{placeholder:"All teams"})}),s.jsxs($e,{children:[s.jsx(Le,{value:Rs,children:"All teams"}),f.map(p=>s.jsx(Le,{value:p.id,children:p.name},p.id))]})]}),s.jsxs("div",{className:"relative",children:[s.jsx(Ha,{className:"text-paragraph absolute top-1/2 left-2.5 size-3.5 -translate-y-1/2"}),s.jsx(Fe,{value:a,placeholder:"Search diagrams",className:"border-stock bg-input h-9 w-full rounded-md pl-8 text-sm",onChange:p=>{o(p.currentTarget.value),d(Jt)}})]}),s.jsxs("div",{className:"flex max-h-72 min-w-0 flex-col gap-1 overflow-y-auto",children:[N&&v.length===0&&s.jsx("p",{className:"text-paragraph py-2 text-xs",children:"Loading diagrams…"}),!N&&v.length===0&&s.jsx("p",{className:"text-paragraph py-2 text-xs",children:"No diagrams found"}),v.map(p=>{const w=p.name??"Untitled diagram",S=p.id===t;return s.jsxs("div",{draggable:!!n,onDragStart:I=>n?.(I,p),onClick:()=>e?.(p),role:e?"button":void 0,tabIndex:e?0:void 0,onKeyDown:I=>{I.key!=="Enter"&&I.key!==" "||(I.preventDefault(),e?.(p))},className:H("flex w-full min-w-0 items-center gap-2 rounded-md border p-1.5 text-left transition-colors",n&&"cursor-grab active:cursor-grabbing",!S&&"border-stock hover:bg-input",S&&"border-primary bg-primary/10"),children:[s.jsx("div",{className:"bg-input h-8 w-12 shrink-0 overflow-hidden rounded-sm",children:p.previewImageUrl&&s.jsx("img",{src:p.previewImageUrl,alt:w,className:"size-full object-cover"})}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-[#F4F7FC]",children:w}),S&&s.jsx($a,{className:"text-primary size-3.5 shrink-0"})]},p.id)}),b&&s.jsx("button",{type:"button",disabled:N,onClick:()=>d(m+Jt),className:"border-stock hover:bg-input text-paragraph mt-0.5 rounded-md border py-1.5 text-xs transition-colors disabled:opacity-60",children:N?"Loading…":"Load more"})]})]})}function fu(){const[t,e]=y.useState(!0);return s.jsxs(s.Fragment,{children:[s.jsxs("button",{onClick:()=>e(!t),className:H($t,"mt-0.5"),children:[s.jsx("span",{className:"truncate",children:"Sub Diagram"}),s.jsx(nt,{className:H("size-3 transition-transform duration-200 ease-out",!t&&"-rotate-90")})]}),s.jsx(it,{initial:!1,children:t&&s.jsx(ze.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:"easeOut"},className:"overflow-hidden",children:s.jsx("div",{className:"flex flex-col gap-2 px-2 pt-2 pb-2",children:s.jsx(rr,{onDragStart:(n,i)=>{const r=i.name??"Untitled diagram";Ke(n,Zt.nodeType,{...Zt.dragData,diagramId:i.id,diagramName:r},{width:Zt.recommendedSize.width,height:Zt.recommendedSize.height},r)}})})},"category-sub-diagram")})]})}function xu(){return s.jsx(Xe,{className:"left-18",children:s.jsxs("div",{className:"flex w-[16rem] flex-col p-1.5",children:[s.jsx(gu,{}),s.jsx(hu,{}),s.jsx(fu,{})]})})}const bu=["flowchart","shapes"],ar={standard:{label:"Standard",shapeIds:["document","multiple-documents"]},flowchart:{label:"Flowchart",shapeIds:["terminator","delay","off-page-connector","display","collate","sort","or","database","subroutine","manual-input","summing-junction","internal-storage"]},shapes:{label:"Shapes",shapeIds:["rectangle","rounded-rect","ellipse","diamond","triangle","parallelogram","trapezoid","hexagon","cylinder"]}};function yu(t){for(const[e,{shapeIds:n}]of Object.entries(ar))if(n.includes(t))return e}function vu(t){const e={shapes:[],standard:[],flowchart:[]};for(const n of t){const i=yu(n.id);i&&e[i].push(n)}return e}const ju=[{id:"text",label:"Text",icon:s.jsx(kl,{className:"h-4 w-4"}),nodeType:"text",dragData:{componentFields:[{componentFieldId:"text",type:X.TextBox,label:"Text",isReadonly:!0}]},recommendedSize:{width:200,height:60}},{id:"sticky-note",label:"Sticky Note",icon:s.jsx(Cl,{className:"h-4 w-4"}),nodeType:"shape",dragData:{shape:"rounded-rect",fill:"#FEF08A",cornerRadius:0,componentFields:[{componentFieldId:"name",type:X.TextInput,label:"Name",isReadonly:!0,data:[{value:""}]}]},recommendedSize:{width:200,height:150}},{id:"code-block",label:"Code Block",icon:s.jsx(Ht,{className:"h-4 w-4"}),nodeType:"code",dragData:{fontFamily:"monospace",componentFields:[{componentFieldId:"code",type:X.CodeEditor,label:"Code",isReadonly:!0,data:[{value:"// Code here"}]}]},recommendedSize:{width:300,height:150}},{id:"table",label:"Table",nodeType:"table",icon:s.jsx(Mr,{className:"size-4"}),dragData:{rows:mi,columns:ui,componentFields:[{componentFieldId:"name",type:X.TextInput,label:"Name",isReadonly:!1,data:[{value:"My Table"}]}]}},{id:"frame",label:"Frame",icon:s.jsx(ml,{className:"h-4 w-4"}),nodeType:"group",dragData:{backgroundColor:"rgba(20, 25, 37, 0.35)",borderColor:"#828DA3",componentFields:[{componentFieldId:"name",type:X.TextInput,label:"Name",isReadonly:!1,data:[{value:"Frame"}]},{componentFieldId:"label",type:X.TextInput,label:"Label",data:[{value:""}]}],childNodes:[]},recommendedSize:{width:400,height:300}}];function wu(){const[t,e]=y.useState(new Set(["standard","flowchart","shapes"])),n=vu(hi);function i(r){const a=new Set(t);a.has(r)?a.delete(r):a.add(r),e(a)}return s.jsx(Xe,{className:"left-18",children:s.jsxs("div",{className:"w-[10.5rem] p-2",children:[s.jsx("div",{className:"text-muted-foreground mb-2 text-xs font-semibold",children:"General"}),s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsxs("button",{onClick:()=>i("standard"),className:$t,children:[s.jsx("span",{className:"truncate",children:"Standard"}),t.has("standard")?s.jsx(nt,{className:"size-3"}):s.jsx($s,{className:"size-3"})]}),s.jsx(it,{initial:!1,children:t.has("standard")&&s.jsx(ze.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:"easeOut"},className:"overflow-hidden",children:s.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:ju.map(r=>s.jsx(Mt,{children:s.jsxs(et,{children:[s.jsx(tt,{children:s.jsx("div",{draggable:!0,className:Ys,onDragStart:a=>{Ke(a,r.nodeType,r.dragData,r.recommendedSize,r.label)},children:s.jsx("div",{className:"flex items-center justify-center",children:r.icon})})}),s.jsx(st,{children:r.label})]})},r.id))})},"category-standard")})]}),bu.filter(r=>r!=="standard").map(r=>{const a=ar[r],o=n[r],c=t.has(r);return o.length===0?null:s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsxs("button",{onClick:()=>i(r),className:$t,children:[s.jsx("span",{className:"truncate",children:a.label}),c?s.jsx(nt,{className:"size-3"}):s.jsx($s,{className:"size-3"})]}),s.jsx(it,{initial:!1,children:c&&s.jsx(ze.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:"easeOut"},className:"overflow-hidden",children:s.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:o.map(l=>s.jsx(Mt,{children:s.jsxs(et,{children:[s.jsx(tt,{children:s.jsx("div",{draggable:!0,className:Ys,onDragStart:u=>{Ke(u,"shape",{shape:l.id,componentFields:[{componentFieldId:"name",type:X.TextInput,label:"Name",isReadonly:!0,data:[{value:""}]}]},{width:l.recommendedWidth,height:l.recommendedHeight},l.label)},children:s.jsx(l.Component,{})})}),s.jsx(st,{children:l.label})]})},l.id))})},`category-${r}`)})]},r)})]})]})})}function Xn(t){return Ei({attr:{viewBox:"0 0 32 32"},child:[{tag:"path",attr:{d:"M 6 5 L 6 7 L 7 7 L 7 25 L 6 25 L 6 27 L 14 27 L 14 25 L 13 25 L 13 19 L 19 19 L 19 25 L 18 25 L 18 27 L 26 27 L 26 25 L 25 25 L 25 7 L 26 7 L 26 5 L 18 5 L 18 7 L 19 7 L 19 13 L 13 13 L 13 7 L 14 7 L 14 5 Z M 9 7 L 11 7 L 11 15 L 21 15 L 21 7 L 23 7 L 23 25 L 21 25 L 21 17 L 11 17 L 11 25 L 9 25 Z"},child:[]}]})(t)}const Nu=[{name:"Heading",preview:"Heading",id:"text:h1",icon:s.jsx(Xn,{}),fontSize:24,fontWeight:700,color:"#f4f7fc"},{name:"Subheading",preview:"Subheading",id:"text:h2",icon:s.jsx(Xn,{}),fontSize:20,fontWeight:600,color:"#d2d9e6"},{name:"Body",preview:"Body text",id:"text:body",icon:s.jsx(Ps,{}),fontSize:14,fontWeight:400,color:"#d2d9e6"},{name:"Caption",preview:"Caption",id:"text:caption",icon:s.jsx(Ps,{}),fontSize:12,fontWeight:400,color:"#828da3"}];function Cu(){return s.jsx(Xe,{className:"left-18",children:s.jsx("div",{className:"flex w-[10.5rem] flex-col gap-1.5 p-1",children:Nu.map((t,e)=>s.jsx("div",{draggable:!0,className:Xi,onDragStart:n=>{Ke(n,"text",{color:t.color,fontSize:t.fontSize,fontWeight:t.fontWeight,componentFields:[{componentFieldId:"text",type:X.TextBox,label:"Text",isReadonly:!0}]},void 0,t.preview)},children:s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"flex size-5 items-center justify-center rounded-[4px] border border-[#2A3242] bg-[#1E2533] text-[12px] text-[#F4F7FC]",children:t.icon}),s.jsx("span",{className:"text-sm font-medium",children:t.preview})]})},e))})})}function Su(){const{sidebarActiveTool:t,setSidebarActiveTool:e,isEmbedded:n,isFullscreen:i}=we(),r=!n&&i&&!t;return s.jsxs(s.Fragment,{children:[s.jsx(Xe,{className:H(!n&&i&&"top-[4.25rem]",r&&"-translate-x-[calc(100%_+_1rem)] transition-transform duration-200 group-hover/left-controls:translate-x-0"),children:s.jsxs("div",{className:"flex flex-col items-center gap-1.5 p-1",children:[s.jsx(ot,{name:"General",icon:s.jsx(Wa,{}),isActive:t==="shapes",onClick:()=>e(a=>a==="shapes"?null:"shapes")}),s.jsx(ot,{name:"Modeling",icon:s.jsx(Ga,{}),isActive:t==="modeling",onClick:()=>e(a=>a==="modeling"?null:"modeling")}),s.jsx(ot,{name:"Icons",icon:s.jsx(qa,{}),isActive:t==="icons",onClick:()=>e(a=>a==="icons"?null:"icons")}),s.jsx(ot,{name:"Images",icon:s.jsx(Ua,{}),isActive:t==="images",onClick:()=>e(a=>a==="images"?null:"images")}),s.jsx(ot,{name:"Animated Nodes",icon:s.jsx(hd,{}),isActive:t==="animated",onClick:()=>e(a=>a==="animated"?null:"animated")}),s.jsx(ot,{name:"Text",icon:s.jsx(Ps,{}),isActive:t==="text",onClick:()=>e(a=>a==="text"?null:"text")}),s.jsx(ot,{name:"Comments",icon:s.jsx(Va,{}),isActive:t==="comments"||t==="add-comment",onClick:()=>e(a=>a==="comments"||a==="add-comment"?null:"comments")}),s.jsx(ot,{name:"Data Sources",icon:s.jsx(Oo,{}),isActive:t==="data-sources",onClick:()=>{e(a=>a==="data-sources"?null:"data-sources")}})]})}),t==="shapes"&&s.jsx(wu,{}),t==="modeling"&&s.jsx(xu,{}),t==="icons"&&s.jsx(Od,{}),t==="images"&&s.jsx(cu,{}),t==="animated"&&s.jsx(yd,{}),t==="text"&&s.jsx(Cu,{}),t==="data-sources"&&s.jsx(Id,{}),(t==="comments"||t==="add-comment")&&s.jsx(vd,{})]})}function ot({icon:t,name:e,isActive:n,onClick:i}){return s.jsx(Mt,{children:s.jsxs(et,{open:n?!1:void 0,children:[s.jsx(tt,{asChild:!0,children:s.jsx("button",{onClick:i,className:H("flex h-10 w-10 items-center justify-center rounded-[0.5rem] border border-[#2A3242] bg-transparent text-[#F4F7FC] transition-all hover:bg-[#1E2533] [&>svg]:!size-5",n&&"border-primary/30 bg-primary/10 text-primary"),children:t})}),s.jsx(st,{side:"right",children:e})]})})}function or(){const t=we(),e=y.useRef(null);function n(){return t.selectedEdgeIds.length!==1?null:t.reactFlowInstance?.getEdge(t.selectedEdgeIds[0])??null}const i=n();function r(a){const o=i.id;if(!o)return;const c=structuredClone(a);function l(){let u;t.setEdges(m=>m.map(d=>d.id!==o?d:(u={...d,...c},u))),u&&t.reactFlowInstance?.updateEdge(o,u)}e.current&&clearTimeout(e.current),e.current=setTimeout(l,100)}return{edge:i,updateEdge:r}}function Te(){const t=xi(),e=we(),n=y.useRef(null);function i(){return e.selectedNodeIds.length!==1?null:e.nodes.find(l=>l.id===e.selectedNodeIds[0])??null}const r=i(),a=r?.data??null;function o(l,u){const m=r.id;if(!m)return;const d=structuredClone(l);function h(){if(u)return t.updateNode(m,d);let x;e.setNodes(N=>N.map(f=>f.id!==d.id?f:(x=Yn(f,d),x))),x&&t.updateNode(m,x)}n.current&&clearTimeout(n.current),n.current=setTimeout(h,100)}function c(l,u){const m=r.id;if(!m)return;const d=structuredClone(l);function h(){if(u)return t.updateNodeData(m,l);e.setNodes(x=>x.map(N=>N.id!==m?N:Yn(N,{data:d})))}n.current&&clearTimeout(n.current),n.current=setTimeout(h,100)}return{node:r,data:a,updateNode:o,updateData:c}}function Yn(t,e){return{...t,...e,data:{...t.data,...e.data}}}function ku({componentFields:t,setComponentFields:e,nativeComponents:n,largeEmptyState:i,enableRequired:r,hideDescription:a,newItemDefaults:o}){return s.jsxs("div",{className:"leading-[1.3333]",children:[!a&&s.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"mb-2 font-semibold",children:"Component Structure"}),s.jsx("p",{className:"text-paragraph text-sm",children:"Define the fields for your component"})]}),n&&s.jsxs(Ot,{children:[s.jsx(Bt,{asChild:!0,children:s.jsxs(Q,{preset:"outline",className:"h-14 w-[12.25rem] justify-between px-6 text-base",children:["Apply Template",s.jsx(Ro,{})]})}),s.jsx(_t,{align:"end",children:n.filter(c=>c.type==="modal").map(c=>s.jsx(Me,{onClick:()=>{e(Be(c.componentFields).map((l,u)=>({...l,order:u+1})))},children:c.name},c.componentId))})]})]}),s.jsxs("div",{className:"mb-6",children:[t.length===0&&s.jsx("div",{className:H("flex items-center justify-center rounded-[16px] border border-[#2A3242] bg-transparent p-3",i&&"py-8"),children:s.jsx("p",{className:"text-paragraph text-sm",children:"No fields added"})}),s.jsx(ro,{enableRequired:r,componentFields:t,setComponentFields:e})]}),s.jsxs("div",{hidden:!0,children:[s.jsx(Q,{variant:"destructive",className:"mb-4 h-11 w-full rounded-xl",onClick:()=>{const c=Object.values(X).map(l=>[l,l]).flat();e(c.map((l,u)=>({componentFieldId:crypto.randomUUID(),order:u+1,type:l,label:l,required:u%2===0,options:Array.from({length:5},(m,d)=>`Option ${d+1}`)})))},children:"Add All Fields (Required + Optional) - For Testing"}),s.jsx(Q,{variant:"destructive",className:"mb-4 h-11 w-full rounded-xl",onClick:()=>{const c=Object.values(X);e(c.map((l,u)=>({componentFieldId:crypto.randomUUID(),type:l,order:u+1,label:l,required:!0,options:Array.from({length:5},(m,d)=>`Option ${d+1}`)})))},children:"Add All Fields (Required) - For Testing"}),s.jsx(Q,{variant:"destructive",className:"mb-4 h-11 w-full rounded-xl",onClick:()=>{const c=Object.values(X);e(c.map((l,u)=>({componentFieldId:crypto.randomUUID(),type:l,order:u+1,label:l,required:!1,options:Array.from({length:5},(m,d)=>`Option ${d+1}`)})))},children:"Add All Fields (Optional) - For Testing"})]}),s.jsx(ao,{defaults:o,setComponentFields:e})]})}function Iu({...t}){return s.jsx(tn,{open:t.open,onOpenChange:t.onOpenChange,children:s.jsx(rn,{showCloseButton:!1,className:"border-stock bg-shading h-full !w-full !max-w-full grid-rows-[auto_1fr] gap-0 overflow-hidden rounded-none border p-0 md:h-auto md:max-h-[90vh] md:!max-w-[42.9375rem] md:rounded-[2rem]",children:s.jsx(Tu,{...t})})})}function Tu({initialComponentFields:t,onOpenChange:e,onSubmit:n}){const i=y.useRef(null),[r,a]=y.useState(0),[o,c]=y.useState(!1);y.useEffect(()=>{const d=i.current;if(!d)return;const h=new ResizeObserver(()=>{a(d.clientHeight)});return a(d.clientHeight),h.observe(d),()=>h.disconnect()},[i]);const l=y.useMemo(()=>Be(t),[t]),[u,m]=ne(l);return s.jsxs(s.Fragment,{children:[s.jsxs(Ci,{className:"border-stock flex flex-row items-center justify-between border-b p-6",children:[s.jsxs("div",{className:"flex h-full flex-col justify-between",children:[s.jsx(sn,{className:"mb-2 text-base leading-tight",children:"Component Structure"}),s.jsx(nn,{children:"Configure the Structure for component."})]}),s.jsx(ga,{asChild:!0,children:s.jsx(gs,{})})]}),s.jsxs("div",{className:"custom-scrollbar relative isolate overflow-auto p-6",children:[s.jsx(ze.div,{animate:{height:r},transition:{duration:.2,ease:"easeInOut"},children:s.jsx("div",{ref:i,children:s.jsx(ku,{hideDescription:!0,largeEmptyState:!0,enableRequired:!1,componentFields:u,newItemDefaults:{hidden:!0},setComponentFields:m})})}),s.jsxs("div",{className:"relative z-10 mt-6 flex justify-end gap-3",children:[s.jsx(Q,{type:"button",variant:"outline",className:"text-paragraph border-stock bg-input h-11 w-[4.5rem] rounded-[0.8125rem]",onClick:()=>e(!1),children:"Cancel"}),s.jsxs(Q,{type:"button",className:"h-11 rounded-[0.8125rem] px-8",onClick:async function(){let d=!1;m(u.map(h=>h.label?.trim()?h:(d=!0,{...h,error:"Field name is required"}))),!d&&(c(!0),await n(u),c(!1))},children:[o&&s.jsx(os,{}),"Save"]})]})]})]})}function ms({className:t,defaultValue:e,value:n,min:i=0,max:r=100,...a}){const o=y.useMemo(()=>Array.isArray(n)?n:Array.isArray(e)?e:[i,r],[n,e,i,r]);return s.jsxs(oo,{"data-slot":"slider",defaultValue:e,value:n,min:i,max:r,className:H("relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",t),...a,children:[s.jsx(lo,{"data-slot":"slider-track",className:H("bg-muted relative grow overflow-hidden rounded-full data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5"),children:s.jsx(co,{"data-slot":"slider-range",className:H("bg-primary absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full")})}),Array.from({length:o.length},(c,l)=>s.jsx(uo,{"data-slot":"slider-thumb",className:"border-primary bg-background ring-ring/50 block size-4 shrink-0 rounded-full border shadow-sm transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"},l))]})}function hs({min:t,max:e,step:n,value:i,onChange:r}){return s.jsx("div",{className:"flex !h-12 w-full items-center rounded-[0.5rem] border px-4",children:s.jsx(ms,{min:t,max:e,step:n,value:[i],onValueChange:([a])=>r(a)})})}function Eu({edge:t,updateEdge:e}){const n=fn(t?.markerStart),i=fn(t?.markerEnd);return s.jsxs(s.Fragment,{children:[s.jsx(Qn,{label:"Start",marker:n,onChange:r=>{console.log({markerStart:r}),e({markerStart:Bs(r)})}}),s.jsx(Qn,{label:"End",marker:i,onChange:r=>{console.log({markerEnd:r}),e({markerEnd:Bs(r)})}})]})}function Qn({label:t,marker:e,onChange:n}){const[i,r]=ne(e?.type||"none"),[a,o]=ne(e?.width?.toString()||e?.height?.toString()||""),[c,l]=ne(e?.color||""),[u,m]=ne(e?.strokeWidth?.toString()||"");return s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsxs(le,{className:"mb-2 text-sm leading-[1.333]",children:[t," Marker"]}),s.jsxs(_e,{value:i,onValueChange:d=>{r(d),n({...e,type:d})},children:[s.jsx(Pe,{className:"border-stock text-paragraph !h-12 w-full rounded-[0.5rem] border px-4 text-sm",children:s.jsx(He,{placeholder:"Select Marker"})}),s.jsxs($e,{children:[s.jsx(Le,{value:"none",children:"None"}),Or.map(d=>s.jsxs(Le,{value:d.id,children:[d.icon,d.label]},d.id))]})]})]}),(i===Gs.Arrow||i===Gs.ArrowClosed)&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsxs(le,{className:"mb-2 text-sm leading-[1.333]",children:[t," Marker Color"]}),s.jsx(Li,{color:c.startsWith("#")?c:"",onColorChange:d=>{l(d),n({...e,color:d||"context-stroke"})}})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[s.jsxs(le,{className:"text-sm leading-[1.333]",children:[t," Marker Size"]}),s.jsx("span",{className:"text-muted-foreground text-center text-xs",children:a})]}),s.jsx(hs,{min:1,max:20,step:.1,value:a?Number(a):1,onChange:d=>{o(String(d)),n({...e,width:d,height:d})}})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[s.jsxs(le,{className:"text-sm leading-[1.333]",children:[t," Marker Stroke"]}),s.jsx("span",{className:"text-muted-foreground text-center text-xs",children:u})]}),s.jsx(hs,{min:1,max:5,step:.1,value:u?Number(u):1,onChange:d=>{m(String(d)),n({...e,strokeWidth:d})}})]})]})]})}function ue({label:t,labelExtra:e,labelClassName:n,labelRowClassName:i,children:r,visible:a,onChangeVisibility:o,isVisibilityDisabled:c}){const[l,u]=ne(a??!1);return s.jsxs("div",{children:[s.jsxs("div",{className:H("mb-2 flex h-7 items-center justify-between",i),children:[s.jsx(le,{className:H("text-sm font-normal text-[#F4F7FC]",n),children:t}),s.jsxs("div",{className:"flex items-center gap-2",children:[e,a!==void 0&&o!==void 0&&s.jsxs(et,{open:c?void 0:!1,children:[s.jsx(tt,{asChild:!0,children:s.jsx("div",{children:s.jsx(Q,{size:"icon",variant:"ghost",className:"size-6 text-[#828DA3] hover:text-[#F4F7FC]",disabled:c,onClick:()=>{u(m=>(o(!m),!m))},children:l?s.jsx(Ka,{}):s.jsx(Xa,{})})})}),s.jsx(st,{className:"mr-1 max-w-[200px] text-center",children:"This field can not be shown on the flow diagram"})]})]})]}),r]})}function rt({min:t,max:e,step:n,label:i,labelClassName:r,labelRowClassName:a,inputClassName:o,value:c,onChange:l}){return s.jsx(ue,{label:i,labelClassName:r,labelRowClassName:a,children:s.jsxs("div",{className:"flex w-full items-center gap-3",children:[s.jsx("div",{className:"flex-1",children:s.jsx(ms,{min:t,max:e,step:n,value:[Number.isNaN(Number(c))?0:Number(c)],onValueChange:([u])=>l(u)})}),s.jsx("input",{min:t,max:e,step:n,value:Number.isNaN(c)?"":c??"",onChange:u=>{const m=Number(u.target.value);!Number.isNaN(m)&&m>=t&&m<=e&&l(m)},type:"number",className:H("border-stock text-paragraph !h-12 w-16 rounded-[0.5rem] border px-1 pl-3 text-center text-sm",o)})]})})}function Lu({edge:t,updateEdge:e}){const[n,i]=ne(t?.style?.strokeWidth?String(t.style.strokeWidth):"2"),[r,a]=ne(t?.style?.strokeDasharray===es.dashed?"dashed":t?.style?.strokeDasharray===es.dotted?"dotted":"solid"),[o,c]=ne(t?.style?.stroke);return s.jsxs(s.Fragment,{children:[s.jsx(rt,{label:"Stroke Width",min:1,max:10,step:.1,value:n,onChange:l=>{i(String(l)),e({style:{...t?.style,strokeWidth:l}})}}),s.jsxs("div",{children:[s.jsx(le,{className:"mb-2 text-sm leading-[1.333]",children:"Stroke Style"}),s.jsxs(_e,{value:r,onValueChange:l=>{a(l),e({style:{...t?.style,strokeDasharray:l==="dashed"?es.dashed:l==="dotted"?es.dotted:void 0}})},children:[s.jsx(Pe,{className:"!h-12 w-full rounded-[0.5rem] border px-4 text-sm",children:s.jsx(He,{})}),s.jsxs($e,{children:[s.jsx(Le,{value:"solid",children:"Solid"}),s.jsx(Le,{value:"dashed",children:"Dashed"}),s.jsx(Le,{value:"dotted",children:"Dotted"})]})]})]}),s.jsxs("div",{children:[s.jsx(le,{className:"mb-2 text-sm leading-[1.333]",children:"Stroke Color"}),s.jsx(Li,{color:o,onColorChange:l=>{c(l),e({style:{...t?.style,stroke:l}})}})]})]})}const es={dashed:"4 2",dotted:"1"};function Au(){const{edge:t,updateEdge:e}=or(),[n,i]=ne(t?.animated||!1),[r,a]=ne(String(t?.type||Ho.Bezier)),[o,c]=ne(String(t?.label||"")),[l,u]=ne(Number(t?.data?.labelFontSize)||12);return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx(le,{className:"mb-2 text-sm leading-[1.333]",children:"Edge Label"}),s.jsx(Fe,{value:o,placeholder:"Edge Label",className:"!h-12 w-full rounded-[0.5rem] border px-4 text-sm",onChange:m=>{c(m.target.value),e({label:m.target.value?m.target.value:void 0})}})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[s.jsx(le,{className:"text-sm leading-[1.333]",children:"Label Size"}),s.jsx("span",{className:"text-muted-foreground block w-6 text-center text-xs",children:l})]}),s.jsx(hs,{min:8,max:40,step:1,value:l,onChange:m=>{u(m),e({data:{...t?.data,labelFontSize:m}})}})]}),s.jsxs("div",{children:[s.jsx(le,{className:"mb-2 text-sm leading-[1.333]",children:"Edge Type"}),s.jsxs(_e,{value:r,onValueChange:m=>{a(m),e({type:m})},children:[s.jsx(Pe,{className:"border-stock text-paragraph !h-12 w-full rounded-[0.5rem] border px-4 text-sm",children:s.jsx(He,{placeholder:"Select Edge Type"})}),s.jsx($e,{children:Br.map(m=>s.jsx(Le,{value:m.id,children:m.label},m.id))})]})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[s.jsx(le,{className:"text-sm leading-[1.333]",children:"Animated"}),s.jsx(rs,{checked:n,onCheckedChange:m=>{i(m),e({animated:m})}})]}),n&&s.jsxs(Q,{preset:"outline",className:"w-full",onClick:()=>{e({data:{...t?.data,reverseAnimation:!t?.data?.reverseAnimation}})},children:[s.jsx(_r,{className:"size-4"}),"Reverse Animation"]})]}),s.jsx(Lu,{edge:t,updateEdge:e}),s.jsx(Eu,{edge:t,updateEdge:e})]})}function Fu({field:t,value:e,setValue:n}){return t.type!==X.RichTextEditor&&t.type!==X.CodeEditor&&t.type!==X.TextBox?null:s.jsxs(ln,{title:t.label??"",description:t.type,footerCancel:!0,children:[t.type===X.RichTextEditor&&s.jsx("div",{className:"h-[60vh]!",children:s.jsx(gi,{className:"[&_.ql-editor]:h-[calc(60vh-2.5rem)]!",value:e??"",setValue:n})}),t.type===X.CodeEditor&&s.jsx("div",{className:"border-stock bg-card w-full overflow-hidden rounded-[0.75rem] border",children:s.jsx(en,{height:"60vh",value:typeof e=="string"?e:"",setValue:n})}),t.type===X.TextBox&&s.jsx(Ws,{value:typeof e=="string"?e:"",onChange:i=>n(i.target.value),className:"border-stock text-foreground bg-input h-[60vh] w-full resize-none rounded-[1rem] border p-4 text-sm leading-normal break-all",autoCorrect:"off",autoComplete:"off",autoCapitalize:"off"})]})}function Zn(){const{data:t,updateData:e}=Te(),n=y.useMemo(()=>Ri(t?.componentFields??[],t?.componentFields??[]),[t]),[i,r]=ne(n);return s.jsx(s.Fragment,{children:t?.componentFields?.map(a=>s.jsx(Du,{field:a,value:i[a.componentFieldId],setValue:o=>{const c={...i,[a.componentFieldId]:o};r(c),e({...t,componentFields:cn(t?.componentFields??[],c)})},isVisible:a.hidden===!1,setIsVisible:o=>{e({...t,componentFields:t?.componentFields?.map(c=>c.componentFieldId===a.componentFieldId?{...c,hidden:!o}:c)})}},a.componentFieldId))})}function Du({field:t,value:e,setValue:n,isVisible:i,setIsVisible:r}){const[a,o]=y.useState(!1),[c,l]=y.useState(!1),{codeEditorWrapper:u}=pi(),{organizationId:m}=we();async function d(N){if(N.file instanceof File&&m){l(!0);const f=await zi(m,N.file);l(!1),n({fileId:f});return}N.file instanceof File||n(N)}const h=y.useMemo(()=>!Pr.includes(t.type),[t.type]),x=t.type===X.RichTextEditor||t.type===X.CodeEditor||t.type===X.TextBox;return s.jsxs(s.Fragment,{children:[s.jsxs(ue,{label:t.label??"",visible:i,onChangeVisibility:r,isVisibilityDisabled:h,labelExtra:x?s.jsx(Q,{size:"icon",variant:"ghost",className:"size-6 text-[#828DA3] hover:text-[#F4F7FC]",onClick:()=>o(!0),children:s.jsx(fl,{className:"size-3"})}):null,children:[t.type===X.NumberInput&&s.jsx(mo,{value:e??"",onChange:n}),t.type===X.TextInput&&s.jsx(Ai,{value:e??"",onChange:n}),t.type===X.TextBox&&s.jsx(Fi,{value:e??"",onChange:n}),t.type===X.URLInput&&s.jsx(ho,{value:e??"",onChange:n}),t.type===X.FileUpload&&s.jsx(go,{file:e??null,onChange:d,isViewMode:c}),t.type===X.LinkOrFileUpload&&s.jsx(po,{value:e??null,onChange:d,isViewMode:c}),t.type===X.DropdownSelect&&s.jsx(kn,{options:Be(t.options),value:e??"",onChange:n}),t.type===X.RichTextEditor&&s.jsx(gi,{value:e??"",setValue:n}),t.type===X.CodeEditor&&s.jsx("div",{className:u,children:s.jsx(en,{value:e??"",setValue:n})}),t.type===X.KeyValueList&&s.jsx(fo,{value:e??[],onChange:n}),t.type===X.BooleanToggle&&s.jsx(kn,{options:["Yes","No"],value:e?"Yes":"No",onChange:N=>n(N==="Yes")}),t.type===X.MultiSelect&&s.jsx(xo,{options:Be(t.options),value:e??[],onChange:n}),t.type===X.SearchSelect&&s.jsx(bo,{options:Be(t.options),value:e??"",onChange:n}),t.type===X.CheckboxGroup&&s.jsx(yo,{value:e??[],onChange:n,options:Be(t.options)}),t.type===X.TagInput&&s.jsx(vo,{value:e??[],onChange:n}),t.type===X.DatePicker&&s.jsx(jo,{value:e??null,onChange:n}),t.type===X.DateRangePicker&&s.jsx(wo,{enableMinified:!0,value:e??null,onChange:n}),t.type===X.ColorPicker&&s.jsx(Re,{value:e??null,onChange:n}),t.type===X.Slider&&s.jsx(No,{value:e??null,onChange:n})]},t.componentFieldId),x&&s.jsx(on,{open:a,onOpenChange:o,className:"[--width:72rem]",children:s.jsx(Fu,{field:t,value:e??"",setValue:n})})]})}function Ru(){const{data:t,updateData:e}=Te(),[n,i]=ne(t?.contentWidth??Hr);return t?s.jsx(rt,{label:"Width",min:Wr,max:$r,step:2,value:n,onChange:r=>{i(r),e({contentWidth:r},!0)}}):null}function zu(){const{node:t,data:e,updateData:n}=Te(),[i,r]=ne(e?.technology??""),[a,o]=ne(e?.description??"");if(!e)return null;const c=e.c4Kind,l=c==="container"||c==="component";return s.jsxs(s.Fragment,{children:[t?.type==="c4"&&l&&s.jsx(ue,{label:"Technology",children:s.jsx(Ai,{value:i,placeholder:"e.g. React, Go, PostgreSQL",onChange:u=>{r(u),n({technology:u})}})}),s.jsx(ue,{label:"Description",children:s.jsx(Fi,{value:a,placeholder:"What this element does",onChange:u=>{o(u),n({description:u})}})})]})}const Mu=["person","system","container","component","node"],Ou=[{id:"default",label:"Box"},{id:"db",label:"Database"},{id:"queue",label:"Pipe / Queue"},{id:"bucket",label:"Bucket"},{id:"folder",label:"Folder"},{id:"browser",label:"Web Browser"},{id:"terminal",label:"Terminal"},{id:"component",label:"Component (UML)"},{id:"ellipse",label:"Ellipse"}];function Bu(t,e){if(t==="node")return{fill:xt,stroke:xt};const n=e?`${t}External`:t;return de[n]??de.system}function _u(){const{data:t,updateData:e}=Te(),[n,i]=ne(t?.fill??""),[,r]=ne(t?.stroke??""),[a,o]=ne(t?.fontColor??"");if(!t)return null;function c(l,u){const m=Bu(l,u);return i(m.fill),r(m.stroke),{fill:m.fill,stroke:m.stroke}}return s.jsxs(s.Fragment,{children:[s.jsx(ue,{label:"Element Type",children:s.jsxs(_e,{value:t.c4Kind,onValueChange:l=>{const u=l;e({c4Kind:u,...c(u,t.isExternal??!1)})},children:[s.jsx(Pe,{className:"border-stock bg-input h-9 w-full rounded-md text-sm",children:s.jsx(He,{})}),s.jsx($e,{children:Mu.map(l=>s.jsx(Le,{value:l,children:ri[l]},l))})]})}),s.jsx(ue,{label:"Shape",children:s.jsxs(_e,{value:t.c4Shape??"default",onValueChange:l=>e({c4Shape:l}),children:[s.jsx(Pe,{className:"border-stock bg-input h-9 w-full rounded-md text-sm",children:s.jsx(He,{})}),s.jsx($e,{children:Ou.map(l=>s.jsx(Le,{value:l.id,children:l.label},l.id))})]})}),s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx(le,{className:"text-sm font-normal text-[#F4F7FC]",children:"External"}),s.jsx(rs,{checked:t.isExternal??!1,onCheckedChange:l=>{e({isExternal:l,...c(t.c4Kind,l)})}})]}),s.jsx(ue,{label:"Color",children:s.jsx(Re,{value:n,className:"border-stock border-1 border-solid",onChange:l=>{i(l),r(l),e({fill:l,stroke:l})}})}),s.jsx(ue,{label:"Text Color",children:s.jsx(Re,{value:a,className:"border-stock border-1 border-solid",onChange:l=>{o(l),e({fontColor:l})}})})]})}function lr({className:t,...e}){return s.jsx(Co,{"data-slot":"switch",className:H("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",t),...e,children:s.jsx(So,{"data-slot":"switch-thumb",className:H("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}function fs({data:t,onChange:e}){console.log(t);const n=Js(t),[i,r]=Ve(t.borderStyle??""),[a,o]=Ve(t.borderWidth??""),[c,l]=Ve(t.borderColor??""),[u,m]=Ve(t.borderRadius??""),[d,h]=Ve(t.borderAnimationEnabled??!1);return s.jsxs(s.Fragment,{children:[s.jsx(ue,{label:"Border Style",children:s.jsxs(Ko,{type:"single",className:"border-stock w-full border",value:i,onValueChange:x=>{r(x),e({...n.current,borderStyle:x===n.current.borderStyle?"none":x,borderWidth:n.current.borderWidth??1,borderColor:n.current.borderColor??"#000000"})},children:[s.jsx(js,{value:"solid",className:"text-xs",children:"Solid"}),s.jsx(js,{value:"dashed",className:"text-xs",children:"Dashed"}),s.jsx(js,{value:"dotted",className:"text-xs",children:"Dotted"})]})}),s.jsx(ue,{label:"Border Color",children:s.jsx(Re,{value:c,className:"border-stock border-1 border-solid",onChange:x=>{l(x),e({...n.current,borderColor:x,borderWidth:n.current.borderWidth??1,borderStyle:n.current.borderStyle??"solid"})}})}),s.jsx(ue,{label:"Border Width",children:s.jsxs("div",{className:"flex w-full items-center gap-3",children:[s.jsx("div",{className:"flex-1",children:s.jsx(ms,{min:0,max:20,step:1,value:[Number.isNaN(Number(a))?0:Number(a)],onValueChange:([x])=>{o(x),e({...n.current,borderWidth:x,borderStyle:n.current.borderStyle??"solid",borderColor:n.current.borderColor??"#000000"})}})}),s.jsx("input",{type:"number",className:"border-stock text-paragraph !h-12 w-16 rounded-[0.5rem] border px-1 pl-3 text-center text-sm",value:Number.isNaN(a)?"":a??"",min:0,max:20,step:1,onChange:x=>{const N=Number(x.target.value);!Number.isNaN(N)&&N>=0&&(o(N),e({...n.current,borderWidth:N,borderStyle:n.current.borderStyle??"solid",borderColor:n.current.borderColor??"#000000"}))}})]})}),s.jsx(ue,{label:"Border Radius",children:s.jsxs("div",{className:"flex w-full items-center gap-3",children:[s.jsx("div",{className:"flex-1",children:s.jsx(ms,{min:0,max:50,step:1,value:[Number.isNaN(Number(u))?0:Number(u)],onValueChange:([x])=>{m(x),e({...n.current,borderRadius:x})}})}),s.jsx("input",{type:"number",className:"border-stock text-paragraph !h-12 w-16 rounded-[0.5rem] border px-1 pl-3 text-center text-sm",value:Number.isNaN(u)?"":u??"",min:0,max:50,step:1,onChange:x=>{const N=Number(x.target.value);!Number.isNaN(N)&&N>=0&&(m(N),e({...n.current,borderRadius:N}))}})]})}),s.jsx(ue,{label:"Border Animation",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-muted-foreground text-sm",children:d?"Enabled":"Disabled"}),s.jsx(lr,{checked:d??!1,onCheckedChange:x=>{h(x),e({...n.current,borderAnimationEnabled:x})}})]})})]})}function Pu(){const{data:t,updateData:e}=Te(),[n,i]=ne(String(t?.fill));return t?s.jsxs(s.Fragment,{children:[s.jsx(ue,{label:"Background Color",children:s.jsx(Re,{value:n=="transparent"?"":n,className:"border-stock border-1 border-solid",onChange:r=>{i(r),e({fill:r||"transparent"})}})}),s.jsx(fs,{data:{borderColor:t?.stroke??null,borderStyle:t?.strokeStyle??null,borderWidth:t?.strokeWidth??null,borderRadius:t?.borderRadius??null,borderAnimationEnabled:t?.borderAnimationEnabled??null},onChange:r=>{e({stroke:r.borderColor??void 0,strokeWidth:r.borderWidth??void 0,strokeStyle:r.borderStyle??void 0,borderRadius:r.borderRadius??void 0,borderAnimationEnabled:r.borderAnimationEnabled??void 0})}})]}):null}function Hu(){const{data:t,updateData:e}=Te(),[n,i]=ne(t?.fontSize||""),[r,a]=ne(t?.lineHeight??"");return t?s.jsxs(s.Fragment,{children:[s.jsx(rt,{min:0,max:100,step:1,label:"Font Size",value:Number(n),onChange:o=>{i(o),e({fontSize:o})}}),s.jsx(rt,{min:1,max:5,step:.1,label:"Line Height",value:Number(r),onChange:o=>{a(o),e({lineHeight:o})}}),s.jsx(fs,{data:{borderColor:t?.stroke??null,borderStyle:t?.strokeStyle??null,borderWidth:t?.strokeWidth??null,borderRadius:t?.borderRadius??null,borderAnimationEnabled:t?.borderAnimationEnabled??null},onChange:o=>{e({stroke:o.borderColor??void 0,strokeWidth:o.borderWidth??void 0,strokeStyle:o.borderStyle??void 0,borderRadius:o.borderRadius??void 0,borderAnimationEnabled:o.borderAnimationEnabled??void 0})}})]}):null}function $u(){const{data:t,updateData:e}=Te(),[n,i]=Ve(t?.style?.baseColor??"");return s.jsx(s.Fragment,{children:s.jsx(ue,{label:"Color",children:s.jsx(Re,{value:n,className:"border-stock border-1 border-solid",onChange:r=>{i(r),e({style:{...t?.style??{},baseColor:r}})}})})})}function wt({column:t,triggerRemove:e,triggerChanges:n,autoSave:i=!1,readOnly:r}){const a=Js(t),[o,c]=y.useState(!1),[l,u]=Ve(t,[t.name,t.type,t.nullable,t.isPrimaryKey]);return y.useEffect(()=>{if(!i||!o)return;const m=a.current;if(l.name===m.name&&l.type===m.type&&l.nullable===m.nullable&&l.isPrimaryKey===m.isPrimaryKey)return;const d=setTimeout(()=>{n(l)},350);return()=>{clearTimeout(d)}},[i,o,a,l,n]),s.jsxs("div",{className:"border-stock bg-card space-y-2 rounded border p-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[l.isPrimaryKey&&s.jsx("span",{className:"text-xs font-semibold text-amber-600",title:"Primary Key",children:"PK"}),l.isForeignKey&&!l.isPrimaryKey&&s.jsx("span",{className:"text-xs font-semibold text-blue-600",title:"Foreign Key",children:"FK"}),s.jsx("span",{className:"truncate font-mono text-xs font-medium",children:l.name})]}),!r&&s.jsx(Q,{size:"sm",variant:"ghost",onClick:e,className:"text-muted-foreground h-5 w-5 p-0 hover:text-red-600",children:s.jsx(It,{className:"h-3 w-3"})})]}),o?s.jsxs("div",{className:"space-y-3 border-t pt-1",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(le,{className:"text-xs",children:"Column Name"}),s.jsx(Fe,{className:"bg-input !h-11 w-full rounded-[0.8rem] shadow-none",value:l.name,onChange:m=>u(d=>({...d,name:m.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(le,{className:"text-xs",children:"Data Type"}),s.jsx(Fe,{placeholder:"VARCHAR(255), INT, etc.",className:"bg-input !h-11 rounded-[0.8rem] font-mono text-xs shadow-none",value:l.type,onChange:m=>u(d=>({...d,type:m.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(le,{className:"text-xs",children:"Nullable"}),s.jsxs(_e,{value:l.nullable?"yes":"no",onValueChange:m=>u(d=>({...d,nullable:m==="yes"})),children:[s.jsx(Pe,{className:"bg-input !h-11 w-full rounded-[0.8rem] text-xs shadow-none",children:s.jsx(He,{})}),s.jsxs($e,{children:[s.jsx(Le,{value:"yes",children:"Yes (NULL)"}),s.jsx(Le,{value:"no",children:"No (NOT NULL)"})]})]})]}),s.jsx("div",{className:"space-y-2",children:s.jsx(Q,{size:"sm",variant:"outline",onClick:()=>u(m=>({...m,isPrimaryKey:!m.isPrimaryKey})),className:H("h-11 w-full flex-1 rounded-[0.8rem] bg-transparent text-xs shadow-none transition-all",l.isPrimaryKey&&"bg-destructive/10 text-destructive hover:bg-destructive/20 hover:text-destructive border-destructive/20"),children:l.isPrimaryKey?"Remove PK":"Set as PK"})}),s.jsx(Q,{size:"sm",className:"h-11 w-full rounded-[0.8rem] text-xs shadow-none",onClick:()=>{c(!1),n(l)},children:"Done"})]}):s.jsxs("div",{className:"flex items-center justify-between border-t pt-1 text-xs",children:[s.jsx("span",{className:"text-paragraph font-mono break-all",children:l.type}),!r&&s.jsx(Q,{size:"sm",variant:"ghost",className:"h-5 px-2 text-xs text-blue-600",onClick:()=>c(!0),children:"Edit"})]})]})}function cr({value:t,setValue:e}){return s.jsx("div",{className:"bg-card overflow-hidden rounded-md border",children:s.jsx(Gr,{value:t,onChange:e,basicSetup:{lineNumbers:!0,foldGutter:!1,foldKeymap:!1,searchKeymap:!1}})})}function Wu(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function se(t){return Wu(t)?t:null}function De(t){return Array.isArray(t)?t:null}function J(t){return typeof t=="string"?t:null}function ts(t){return typeof t=="boolean"?t:null}function Jn(t){const e=t.trim();return e?e.endsWith("[]")?{type:"array",itemType:e.slice(0,-2).trim()||"string"}:{type:e,itemType:null}:{type:"",itemType:null}}function dr({table:t,tableName:e,dataSource:n,mongoCollectionSource:i,setDataSource:r,readOnly:a}){const[o,c]=y.useState(null),l=y.useMemo(()=>n?.dialect==="mongodb"?i:n?.dialect==="dynamodb"?n.sourceContent:null,[n?.dialect,n?.sourceContent,i]),u=y.useMemo(()=>{if(n?.dialect!=="dynamodb")return[];const b=se(l);return b?(De(b.attributes)??[]).map(se).filter(S=>!!S).map((S,I)=>({id:J(S.id)??`${I}`,name:J(S.name)??"",type:J(S.type)??""})):[]},[l,n?.dialect]),m=y.useMemo(()=>{if(!l)return[];if(n?.dialect==="dynamodb"){const S=se(l);if(!S)return[];const C=(De(S.attributes)??[]).map(se).filter(R=>!!R),A=se(S.primaryKey),M=A?J(A.partitionKey)??"":"",T=A?J(A.sortKey)??"":"";return C.map((R,k)=>{const O=J(R.id)??`${k}`,F=J(R.name)??"",G=J(R.type)??"",ae=ts(R.required)??!1,me=G==="array"?J(R.itemType):null;return{id:O,name:F,type:G==="array"?me?`${me}[]`:"array":G,nullable:!ae,isPrimaryKey:M!==""&&F===M||T!==""&&F===T}})}const b=se(l);return b?(De(b.fields)??[]).map(se).filter(S=>!!S).map((S,I)=>{const C=J(S.id)??`${I}`,A=J(S.name)??"",M=J(S.type)??"",T=ts(S.required)??!1,R=M==="array"?J(S.itemType):null;return{id:C,name:A,type:M==="array"?R?`${R}[]`:"array":M,nullable:!T,isPrimaryKey:!1}}):[]},[l,n?.dialect]);function d(){if(!(!n||!l)){if(n.dialect==="dynamodb"){const b=se(l);if(!b)return;const p={id:W(),name:`new_field_${m.length+1}`,type:"string",required:!1},w=De(b.attributes)??[],S={...b,attributes:[...w,p]};try{const I=qe.parse(S);r({sourceContent:I,modifiedAt:Date.now()}),U.success("Column added")}catch{U.error("Invalid schema update")}return}if(n.dialect==="mongodb"){const b=se(l);if(!b)return;const p={id:W(),name:`new_field_${m.length+1}`,type:"string",required:!1};try{const w=De(b.fields)??[],S={...b,fields:[...w,p]},I=Oe.parse(n.sourceContent),C={...I,collections:I.collections.map(M=>M.id===J(S.id)?S:M)},A=Oe.parse(C);r({sourceContent:A,modifiedAt:Date.now()}),U.success("Column added")}catch{U.error("Invalid schema update")}return}}}function h(b){if(m.length<=1){U.error("Cannot remove the last column");return}if(!(!n||!l)){if(n.dialect==="dynamodb"){const p=se(l);if(!p)return;const w=se(p.primaryKey),S=w?J(w.partitionKey)??"":"",I=w?J(w.sortKey)??"":"";let C=null;const A=De(p.attributes)??[],M=[];for(let R=0;R<A.length;R++){const k=A[R],O=se(k);if(O&&J(O.id)===b){C=J(O.name);continue}M.push(k)}const T={...p,attributes:M,primaryKey:w?{...w,partitionKey:C&&S===C?"":S,sortKey:C&&I===C?"":I}:p.primaryKey};try{const R=qe.parse(T);r({sourceContent:R,modifiedAt:Date.now()}),U.success("Column removed")}catch{U.error("Invalid schema update")}return}if(n.dialect==="mongodb"){const p=se(l);if(!p)return;try{const w=De(p.fields)??[],S=[];for(let T=0;T<w.length;T++){const R=w[T],k=se(R);k&&J(k.id)===b||S.push(R)}const I={...p,fields:S},C=Oe.parse(n.sourceContent),A={...C,collections:C.collections.map(T=>T.id===J(I.id)?I:T)},M=Oe.parse(A);r({sourceContent:M,modifiedAt:Date.now()}),U.success("Column removed")}catch{U.error("Invalid schema update")}return}}}function x(b,p){if(!n||!l)return;if(n.dialect==="dynamodb"){const A=se(l);if(!A)return;const M=se(A.primaryKey),T=M?J(M.partitionKey)??"":"",R=M?J(M.sortKey)??"":"";let k="",O="";const F=De(A.attributes)??[],G=[];let ae=!1;for(let ye=0;ye<F.length;ye++){const L=F[ye],$=se(L);if(!$||J($.id)!==b){G.push(L);continue}ae=!0,k=J($.name)??"",O=p.name??k;const te=p.nullable??!(ts($.required)??!1),P=p.type?Jn(p.type):null,D=J($.type)??"",q=D==="array"?J($.itemType):null,j=P?P.type:D,z=P&&P.type==="array"?P.itemType??q??"string":null,_={...$,name:O,required:!te,type:j};j==="array"?_.itemType=z??"string":(delete _.itemType,delete _.itemFields,delete _.fields),G.push(_)}if(!ae)return;const me=p.isPrimaryKey;let Y=T,Ne=R;me===!0&&(!Y||Y===k?Y=O:!Ne||Ne===k?Ne=O:Y=O),me===!1&&(Y===k&&(Y=""),Ne===k&&(Ne="")),p.name&&T===k&&(Y=O),p.name&&R===k&&(Ne=O);const ke={...A,attributes:G,primaryKey:M?{...M,partitionKey:Y,sortKey:Ne}:A.primaryKey};try{const ye=qe.parse(ke);r({sourceContent:ye,modifiedAt:Date.now()})}catch{U.error("Invalid schema update")}return}if(n.dialect!=="mongodb")return;const w=se(l);if(!w)return;const S=De(w.fields)??[],I=[];let C=!1;try{for(let k=0;k<S.length;k++){const O=S[k],F=se(O);if(!F||J(F.id)!==b){I.push(O);continue}C=!0;const G=J(F.name)??"",ae=p.name??G,me=p.nullable??!(ts(F.required)??!1),Y=p.type?Jn(p.type):null,Ne=J(F.type)??"",ke=Ne==="array"?J(F.itemType):null,ye=Y?Y.type:Ne,L=Y&&Y.type==="array"?Y.itemType??ke??"string":null,$={...F,name:ae,required:!me,type:ye};ye==="array"?$.itemType=L??"string":(delete $.itemType,delete $.itemFields),ye!=="object"&&delete $.fields,I.push($)}if(!C)return;const A={...w,fields:I},M=Oe.parse(n.sourceContent),T={...M,collections:M.collections.map(k=>k.id===J(A.id)?A:k)},R=Oe.parse(T);r({sourceContent:R,modifiedAt:Date.now()})}catch{U.error("Invalid schema update")}}function N(b){if(n?.dialect!=="dynamodb")return;const p=se(l);if(!p)return;const w=se(p.primaryKey);if(!w)return;const S={...p,primaryKey:{...w,...b}};try{const I=qe.parse(S);r({sourceContent:I,modifiedAt:Date.now()})}catch{U.error("Invalid schema update")}}function f(){if(n?.dialect!=="dynamodb")return;const b=se(l);if(!b)return;const p=De(b.globalSecondaryIndexes)??[],w=u.find(C=>C.name.trim()!==""),S={id:W(),name:`gsi_${p.length+1}`,partitionKey:w?.name??""},I={...b,globalSecondaryIndexes:[...p,S]};try{const C=qe.parse(I);r({sourceContent:C,modifiedAt:Date.now()}),U.success("GSI added")}catch{U.error("Invalid schema update")}}function g(b){if(n?.dialect!=="dynamodb")return;const p=se(l);if(!p)return;const w=De(p.globalSecondaryIndexes)??[],S=[];for(let C=0;C<w.length;C++){const A=w[C],M=se(A);M&&J(M.id)===b||S.push(A)}const I={...p,globalSecondaryIndexes:S};try{const C=qe.parse(I);r({sourceContent:C,modifiedAt:Date.now()}),U.success("GSI removed")}catch{U.error("Invalid schema update")}}function v(b,p){if(n?.dialect!=="dynamodb")return;const w=se(l);if(!w)return;const S=De(w.globalSecondaryIndexes)??[],I=[];let C=!1;for(let M=0;M<S.length;M++){const T=S[M],R=se(T);if(!R||J(R.id)!==b){I.push(T);continue}C=!0,I.push({...R,...p})}if(!C)return;const A={...w,globalSecondaryIndexes:I};try{const M=qe.parse(A);r({sourceContent:M,modifiedAt:Date.now()})}catch{U.error("Invalid schema update")}}return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(le,{className:"text-xs",children:n?.dialect==="dynamodb"?"Table Name":"Collection Name"}),s.jsx(Fe,{className:"!h-11 rounded-[0.8rem] shadow-none",value:t?.name??"",readOnly:a,onChange:b=>{const p=b.target.value;if(!n||!l)return;const w={...n.schemaAst,tables:n.schemaAst.tables.map(S=>S.name===e?{...S,name:p}:S)};if(n.dialect==="dynamodb"){const S=se(l);if(!S)return;const I={...S,name:p};try{const C=qe.parse(I);r({sourceContent:C,schemaAst:w,modifiedAt:Date.now()})}catch{U.error("Invalid schema update")}return}try{const S=se(l);if(!S)return;const I={...S,name:p},C=Oe.parse(n.sourceContent),A={...C,collections:C.collections.map(T=>T.id===J(I.id)?I:T)},M=Oe.parse(A);r({sourceContent:M,schemaAst:w,modifiedAt:Date.now()})}catch{U.error("Invalid schema update")}}})]}),n?.dialect==="dynamodb"&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(le,{className:"text-xs",children:"Partition Key (PK)"}),s.jsx(wt,{column:{name:J(se(se(l)?.primaryKey)?.partitionKey)??"",type:J(se(se(l)?.primaryKey)?.partitionKeyType)??"",nullable:!1,isPrimaryKey:!0,isForeignKey:!1},readOnly:a,triggerRemove:()=>N({partitionKey:""}),triggerChanges:b=>N({partitionKey:b.name,partitionKeyType:b.type})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(le,{className:"text-xs",children:"Sort Key (SK)"}),s.jsx(wt,{column:{name:J(se(se(l)?.primaryKey)?.sortKey)??"",type:J(se(se(l)?.primaryKey)?.sortKeyType)??"",nullable:!1,isPrimaryKey:!1,isForeignKey:!1},readOnly:a,triggerRemove:()=>N({sortKey:""}),triggerChanges:b=>N({sortKey:b.name,sortKeyType:b.type})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs(le,{className:"text-xs font-medium",children:["GSI (",De(se(l)?.globalSecondaryIndexes)?.length??0,")"]}),!a&&s.jsxs(Q,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs",onClick:f,children:[s.jsx(mt,{className:"mr-1 h-3 w-3"}),"Add"]})]}),s.jsx("div",{className:"space-y-2",children:(De(se(l)?.globalSecondaryIndexes)??[]).map(se).filter(b=>!!b).map((b,p)=>{const w=J(b.id)??`${p}`,S=J(b.name)??"",I=J(b.partitionKey)??"",C=J(b.sortKey)??"",A=J(b.partitionKeyType)??"",M=J(b.sortKeyType)??"",T=o===w;return s.jsxs("div",{className:"border-stock bg-card space-y-2 rounded border p-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("button",{type:"button",className:"min-w-0 flex-1 truncate text-left font-mono text-xs font-medium",onClick:()=>c(R=>R===w?null:w),children:S||`gsi_${p+1}`}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(Q,{size:"sm",variant:"ghost",className:"text-paragraph h-5 w-5 p-0",onClick:()=>c(R=>R===w?null:w),children:s.jsx(nt,{className:`h-3 w-3 transition-transform ${T?"rotate-180":""}`})}),!a&&s.jsx(Q,{size:"sm",variant:"ghost",onClick:()=>g(w),className:"text-muted-foreground h-5 w-5 p-0 hover:text-red-600",children:s.jsx(It,{className:"h-3 w-3"})})]})]}),T?s.jsxs("div",{className:"space-y-3 border-t pt-1",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(le,{className:"text-xs",children:"Index Name"}),s.jsx(Fe,{className:"bg-input !h-11 w-full rounded-[0.8rem] shadow-none",value:S,readOnly:a,onChange:R=>v(w,{name:R.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(le,{className:"text-xs",children:"GSI Partition Key (PK)"}),s.jsx(wt,{column:{name:I,type:A,nullable:!1,isPrimaryKey:!0,isForeignKey:!1},readOnly:a,triggerRemove:()=>v(w,{partitionKey:"",partitionKeyType:""}),triggerChanges:R=>v(w,{partitionKey:R.name,partitionKeyType:R.type})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(le,{className:"text-xs",children:"GSI Sort Key (SK)"}),s.jsx(wt,{column:{name:C,type:M,nullable:!1,isPrimaryKey:!1,isForeignKey:!1},readOnly:a,triggerRemove:()=>v(w,{sortKey:"",sortKeyType:""}),triggerChanges:R=>v(w,{sortKey:R.name,sortKeyType:R.type})})]})]}):null]},w)})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs(le,{className:"text-xs font-medium",children:[n?.dialect==="dynamodb"?"Attributes":"Columns"," (",m.length,")"]}),!a&&s.jsxs(Q,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs",onClick:d,children:[s.jsx(mt,{className:"mr-1 h-3 w-3"}),"Add"]})]}),s.jsx("div",{className:"space-y-2",children:m.map(b=>s.jsx(wt,{column:{name:b.name,type:b.type,nullable:b.nullable,isPrimaryKey:!1,isForeignKey:!1},readOnly:a,triggerRemove:()=>h(b.id),triggerChanges:p=>x(b.id,p)},b.id))})]})]})}function Gu(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function zs(t){return Gu(t)?t:null}function qu(t){return Array.isArray(t)?t:null}function Uu(t){return typeof t=="string"?t:null}function Vu({databaseName:t,tableName:e}){const n=fi(t,e),[i,r]=y.useState(!1);return s.jsxs("div",{className:"relative",children:[s.jsxs("div",{className:H("bg-card flex items-center justify-between gap-2 pt-2 pb-3",i&&"sticky top-0 z-50"),children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Qe,{className:"h-4 w-4 text-blue-600"}),s.jsx("h3",{className:"text-xs font-semibold",children:n.dataSource?.dialect==="dynamodb"?"DynamoDB Table":n.dataSource?.dialect==="mongodb"?"MongoDB Collection":"JSON File"})]}),s.jsx(Q,{preset:i?"primary":"outline",onClick:()=>r(a=>!a),className:H("size-9 border-none! px-3!",!i&&"bg-accent/60 hover:bg-accent"),children:s.jsx(Ht,{className:"size-5"})})]}),i?s.jsx(cr,{value:n.dataSource?.dialect==="dynamodb"?JSON.stringify(n.dataSource?.sourceContent,null,2):JSON.stringify(n.mongoCollectionSource,null,2),setValue:a=>{if(!n.dataSource)return;const o=a.trim();if(!o)return;let c;try{c=JSON.parse(o)}catch{return}if(n.dataSource.dialect==="dynamodb"){try{const l=qe.parse(c);n.setDataSource({sourceContent:l,modifiedAt:Date.now()})}catch{return}return}if(n.dataSource.dialect==="mongodb"){if(!n.mongoCollectionSource)return;const l=Oe.safeParse(n.dataSource.sourceContent);if(!l.success)return;const u={...l.data,collections:l.data.collections.map(m=>m.id===n.mongoCollectionSource?.id?c:m)};try{const m=Oe.parse(u);n.setDataSource({sourceContent:m,modifiedAt:Date.now()})}catch{return}return}if(n.dataSource.dialect==="json"){const l=zs(n.dataSource.sourceContent);if(!l)return;const u=qu(l.collections);if(!u)return;const m=u.length>0?u[0]:null;if(!(m&&zs(m)?Uu(zs(m)?.id):null))return;const h={...l,collections:[c,...u.slice(1)]};try{const x=_s.parse(h);n.setDataSource({sourceContent:x,modifiedAt:Date.now()})}catch{return}}}}):s.jsx(dr,{tableName:e,...n})]})}function Ku(){const{data:t}=Te();return t?.localTable?s.jsx(Xu,{}):t?.serviceTable?s.jsx(Yu,{}):null}function Xu(){const{data:t}=Te(),{setDataSources:e,setNodes:n}=we(),{table:i,dataSource:r,setTable:a}=fi(t?.localTable.databaseName,t?.localTable.tableName),[o,c]=ne(i??null);if(!o)return null;if(r?.dialect==="mongodb"||r?.dialect==="dynamodb"||r?.dialect==="json")return s.jsx(Vu,{databaseName:t?.localTable.databaseName,tableName:t?.localTable.tableName});const u=o.constraints.find(f=>f.type==="primary_key")?.columns??[],m=o.constraints.filter(f=>f.type==="foreign_key");function d(){const f={type:"column",name:`new_column_${(o?.columns?.length??0)+1}`,dataType:{name:"VARCHAR",parameters:[255]},nullable:!0},g={...o,columns:[...o?.columns??[],f]};a(g),c(v=>v?{...v,...g}:null),U.success("Column added")}function h(f){if(!o)return;if((o?.columns?.length??0)<=1){U.error("Cannot remove the last column");return}const g=(o?.columns??[]).filter(p=>p.name!==f),v=(o?.constraints??[]).filter(p=>!("columns"in p&&p.columns.includes(f))),b={...o,columns:g,constraints:v};c(p=>p?{...p,...b}:null),a(b),U.success("Column removed")}function x(f,g){if(!o)return;const v=o?.columns?.find(A=>A.name===f);if(!v)return;const b=g.name??v.name;let p=v.dataType;if(g.type){const A=g.type.split("("),M=A[0],T=A[1]?.replace(")","").split(",").map(R=>{const k=R.trim(),O=Number(k);return Number.isNaN(O)?k:O})??[];p={name:M,parameters:T}}const w=(o?.columns??[]).map(A=>A.name===f?{...A,name:b,dataType:p,nullable:g.nullable??A.nullable}:A),S=g.isPrimaryKey??u.includes(f),I=(o?.constraints??[]).map(A=>{if(A.type==="primary_key"){const M=A.columns.filter(T=>T!==f);return S&&!M.includes(b)&&M.push(b),M.length?{...A,columns:M}:null}return A.type==="foreign_key"?{...A,columns:A.columns.map(M=>M===f?b:M)}:A}).filter(A=>!!A),C={...o,columns:w,constraints:I};c(A=>A?{...A,...C}:null),a(C)}function N(f){if(!o||!r||f==="")return;if(r.schemaAst.tables.some(b=>b.name===f)){U.error(`A table named "${f}" already exists`);return}const g=r.name,v=o.name;c({...o,name:f}),e(b=>b.map(p=>p.name===g?{...p,schemaAst:{...p.schemaAst,tables:p.schemaAst.tables.map(w=>({...w,name:w.name===v?f:w.name,constraints:w.constraints.map(S=>S.type==="foreign_key"&&S.referencedTable===v?{...S,referencedTable:f}:S)}))}}:p)),n(b=>b.map(p=>{const w=p.data.localTable;return p.type!=="databaseTableSQL"||w?.databaseName!==g||w.tableName!==v?p:{...p,data:{...p.data,localTable:{...w,tableName:f}}}}))}return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Qe,{className:"h-4 w-4 text-blue-600"}),s.jsx("h3",{className:"text-sm font-semibold",children:"Database Table"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(le,{className:"text-xs",children:"Table Name"}),s.jsx(Fe,{className:"!h-11 rounded-[0.8rem] shadow-none",value:o.name,onChange:f=>N(f.target.value)})]})]}),s.jsx(St,{}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs(le,{className:"text-xs font-semibold",children:["Columns (",o.columns.length,")"]}),s.jsxs(Q,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs",onClick:d,children:[s.jsx(mt,{className:"mr-1 h-3 w-3"}),"Add"]})]}),s.jsx("div",{className:"space-y-2",children:o.columns.map(f=>{const g=u.includes(f.name),v=m.some(b=>b.columns.includes(f.name));return s.jsx(wt,{column:{name:f.name,type:f.dataType.name,nullable:f.nullable,isPrimaryKey:g,isForeignKey:v},triggerRemove:()=>h(f.name),triggerChanges:b=>x(f.name,b)},f.name)})})]}),u.length>0&&s.jsxs(s.Fragment,{children:[s.jsx(St,{}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(le,{className:"text-xs font-semibold",children:"Primary Keys"}),s.jsx("div",{className:"flex flex-wrap gap-1",children:u.map(f=>s.jsx("span",{className:"inline-flex items-center rounded bg-amber-500/15 px-2 py-0.5 font-mono text-xs text-amber-400",children:f},f))})]})]}),m.length>0&&s.jsxs(s.Fragment,{children:[s.jsx(St,{}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(le,{className:"text-xs font-semibold",children:"Foreign Keys"}),s.jsx("div",{className:"space-y-1",children:m.flatMap((f,g)=>f.columns.map((v,b)=>s.jsxs("div",{className:"rounded bg-blue-500/10 px-2 py-1 text-xs",children:[s.jsx("span",{className:"font-mono text-blue-400",children:v}),s.jsx("span",{className:"text-muted-foreground",children:" → "}),s.jsxs("span",{className:"font-mono text-blue-400",children:[f.referencedTable,".",f.referencedColumns[b]??f.referencedColumns[0]]})]},`${g}-${b}`)))})]})]})]})}function Yu(){const{data:t}=Te(),e=t?.serviceTable,[n,i]=y.useState(!1),{serviceDb:r,loading:a}=qr(e?.serviceName,e?.databaseName),o=y.useMemo(()=>{if(!r?.noSQLSchema)return null;try{const u=typeof r.noSQLSchema=="string"?JSON.parse(r.noSQLSchema):r.noSQLSchema;return r.dialect==="dynamodb"?u?.dynamo?.table??null:r.dialect==="mongodb"?u?.mongo?.collections??null:null}catch{return null}},[r?.noSQLSchema,r?.dialect]),c=y.useMemo(()=>r?.tables?.find(m=>m?.name===e?.tableName)?.columns?.map(m=>({name:m?.name??"",type:m?.type??"unknown"}))??[],[r,e?.tableName]),l=s.jsxs("div",{className:"rounded border border-red-500/20 bg-red-500/10 p-2 text-xs text-red-400",children:[s.jsx("strong",{className:"font-semibold",children:"Note:"})," This is a remote source and you cannot edit it directly. To edit it, use the service database data source editor in the service details panel."]});if(a)return s.jsxs("div",{className:"text-paragraph flex h-full flex-col items-center justify-center gap-4 py-12",children:[s.jsx(tl,{size:"xs"}),"Loading table..."]});if((r?.dialect==="dynamodb"||r?.dialect==="mongodb")&&o){const u=r.dialect==="mongodb"?(Array.isArray(o?.collections)?o.collections:Array.isArray(o)?o:null)?.find(x=>x.name===e?.tableName)??null:null,m=r.dialect==="dynamodb"?"DynamoDB Table":"MongoDB Collection",d=r.dialect==="dynamodb"?JSON.stringify(o,null,2):JSON.stringify(u,null,2);return s.jsxs("div",{className:"relative",children:[s.jsxs("div",{className:H("bg-card flex items-center justify-between gap-2 pt-2 pb-3",n&&"sticky top-0 z-50"),children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Qe,{className:"h-4 w-4 text-blue-600"}),s.jsx("h3",{className:"text-xs font-semibold",children:m})]}),s.jsx(Q,{preset:n?"primary":"outline",onClick:()=>i(h=>!h),className:H("size-9 border-none! px-3!",!n&&"bg-accent/60 hover:bg-accent"),children:s.jsx(Ht,{className:"size-5"})})]}),n?s.jsx(cr,{value:d??"",setValue:()=>{}}):s.jsxs("div",{className:"space-y-3",children:[s.jsx(dr,{table:{name:e?.tableName??""},tableName:e?.tableName??"",dataSource:{id:r?.serviceDBId??"",name:e?.tableName??"",sourceType:"manual",sourceContent:o,dialect:r.dialect,schemaAst:{tables:[],dialect:r.dialect},createdAt:0,modifiedAt:null},mongoCollectionSource:u,setDataSource:()=>{},setTable:()=>{},readOnly:!0}),s.jsx(St,{}),l]})]})}return s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(le,{className:"text-xs font-semibold",children:"Columns"}),c.length?s.jsx("div",{className:"space-y-1",children:c.map(u=>s.jsxs("div",{className:"bg-accent/40 text-foreground flex items-center justify-between rounded px-3 py-1 text-xs",children:[s.jsx("span",{className:"font-mono",children:u.name}),s.jsx("span",{className:"text-paragraph",children:u.type})]},u.name))}):s.jsx("p",{className:"text-muted-foreground text-center text-xs",children:"No column information is available."})]}),s.jsx(St,{}),l]})}function Qu(){const{data:t,updateData:e}=Te(),[n,i]=ne(t?.backgroundColor??""),[r,a]=ne(t?.borderColor??"");return t?s.jsxs(s.Fragment,{children:[s.jsx(ue,{label:"Background Color",children:s.jsx(Re,{value:n=="transparent"?"":n,className:"border-stock border-1 border-solid",onChange:o=>{i(o),e({backgroundColor:o||"transparent"})}})}),s.jsx(ue,{label:"Border Color",children:s.jsx(Re,{value:r,className:"border-stock border-1 border-solid",onChange:o=>{a(o),e({borderColor:o})}})}),s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx(le,{className:"text-sm font-normal text-[#F4F7FC]",children:"Hide Details"}),s.jsx(rs,{checked:t.collapsed??!1,onCheckedChange:o=>{e({collapsed:o})}})]}),s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx(le,{className:"text-sm font-normal text-[#F4F7FC]",children:"Auto Layout"}),s.jsx(rs,{disabled:t.collapsed??!1,checked:t.autoLayout??!1,onCheckedChange:o=>{e({autoLayout:o})}})]})]}):null}const Zu=8,Ju=40;function em(){const{nodes:t,setNodes:e}=we(),{data:n,updateData:i}=Te(),[r,a]=Ve(n?.color??di),[o,c]=Ve(n?.textColor??""),u=t.find(d=>d.type==="sequenceParticipant")?.data?.titleFontSize??Ur;function m(d){e(h=>h.map(x=>x.type!=="sequenceParticipant"?x:{...x,data:{...x.data,titleFontSize:d}}))}return s.jsxs(s.Fragment,{children:[s.jsx(ue,{label:"Color",children:s.jsx(Re,{value:r,className:"border-stock border-1 border-solid",onChange:d=>{a(d),i({color:d})}})}),s.jsx(ue,{label:"Text Color",children:s.jsx(Re,{value:o,className:"border-stock border-1 border-solid",onChange:d=>{c(d),i({textColor:d})}})}),s.jsxs("div",{className:"-mx-4 space-y-3 border-t border-[#2A3242] px-4 pt-4",children:[s.jsx("p",{className:"text-xs font-normal text-[#828DA3]",children:"Global Styling"}),s.jsx(rt,{min:Zu,max:Ju,step:1,label:"Participant Font Size",value:u,onChange:m})]})]})}function tm(){const{data:t,node:e,updateData:n,updateNode:i}=Te(),[r,a]=ne(String(t?.fill||"")),[o,c]=ne(String(t?.shape||"rectangle")),[l,u]=ne(String(e?.width??e?.measured?.width??"")),[m,d]=ne(String(e?.height??e?.measured?.height??"")),[h,x]=ne(t?.strokeOpacity||null),[N,f]=ne(t?.textColor||""),[g,v]=ne(t?.textFontSize||"");return t?s.jsxs(s.Fragment,{children:[s.jsx(rt,{min:0,max:100,step:1,label:"Text Font Size",value:Number(g),onChange:b=>{v(b),n({textFontSize:b})}}),s.jsx(ue,{label:"Text Color",children:s.jsx(Re,{value:N,className:"border-stock border-1 border-solid",onChange:b=>{f(b),n({textColor:b})}})}),s.jsx(ue,{label:"Shape",children:s.jsxs(_e,{value:o,onValueChange:b=>{c(b),n({shape:b})},children:[s.jsx(Pe,{className:"border-stock text-paragraph !h-12 w-full rounded-[0.5rem] border px-4 text-sm",children:s.jsx(He,{placeholder:"Select Shape"})}),s.jsx($e,{children:hi.map(({id:b,label:p})=>s.jsx(Le,{value:b,children:p},b))})]})}),s.jsx(ue,{label:"Background Color",children:s.jsx(Re,{value:r=="transparent"?"":r,className:"border-stock border-1 border-solid",onChange:b=>{a(b),n({fill:b||"transparent"})}})}),s.jsx(ue,{label:"Width (px)",children:s.jsx("input",{type:"number",className:"border-stock text-paragraph !h-12 w-full rounded-[0.5rem] border px-4 text-sm",value:l,min:20,step:2,onChange:b=>{const p=b.target.value;u(p);const w=Number(p);!Number.isNaN(w)&&w>0&&i({width:w},!0)}})}),s.jsx(ue,{label:"Height (px)",children:s.jsx("input",{type:"number",className:"border-stock text-paragraph !h-12 w-full rounded-[0.5rem] border px-4 text-sm",value:m,min:20,step:2,onChange:b=>{const p=b.target.value;d(p);const w=Number(p);!Number.isNaN(w)&&w>0&&i({height:w},!0)}})}),s.jsx(fs,{data:{borderColor:t?.stroke??null,borderStyle:t?.strokeStyle??null,borderWidth:t?.strokeWidth??null,borderRadius:t?.cornerRadius??null,borderAnimationEnabled:t?.strokeAnimation==="dash"},onChange:b=>{n({stroke:b.borderColor??void 0,strokeWidth:b.borderWidth??void 0,strokeStyle:b.borderStyle??void 0,cornerRadius:b.borderRadius??void 0,strokeAnimation:b.borderAnimationEnabled?"dash":"none"})}}),s.jsx(ue,{label:"Border Transparency",children:s.jsx(hs,{min:0,max:1,step:.1,value:Number.isNaN(Number(h))?1:Number(h),onChange:b=>{x(b),n({strokeOpacity:b})}})})]}):null}function sm(){const{data:t,updateData:e}=Te(),{openChildDiagram:n}=we();return t?s.jsxs(s.Fragment,{children:[t.diagramId&&s.jsxs(s.Fragment,{children:[s.jsxs(Q,{type:"button",className:"h-9 w-full min-w-0 rounded-md text-sm",onClick:()=>n(t.diagramId),children:[s.jsx(Ya,{className:"size-3.5 shrink-0"}),s.jsx("span",{className:"truncate",children:"Open"})]}),s.jsxs(Q,{type:"button",variant:"secondary",className:"h-9 w-full min-w-0 rounded-md text-sm",onClick:()=>li(t.diagramId),children:[s.jsx(ki,{className:"size-3.5 shrink-0"}),s.jsx("span",{className:"truncate",children:"Open in new tab"})]})]}),s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"text-paragraph text-sm",children:"Show thumbnail"}),s.jsx(lr,{checked:!t.hideThumbnail,onCheckedChange:i=>e({hideThumbnail:!i})})]}),s.jsx(rr,{selectedDiagramId:t.diagramId,onSelect:i=>e({diagramId:i.id,diagramName:i.name??"Untitled diagram"})})]}):null}const nm=[{value:"inherit",label:"Default"},{value:"Inter",label:"Inter"},{value:"Arial",label:"Arial"},{value:"Helvetica",label:"Helvetica"},{value:"Georgia",label:"Georgia"},{value:"Times New Roman",label:"Times New Roman"},{value:"Courier New",label:"Courier New"},{value:"Verdana",label:"Verdana"},{value:"Comic Sans MS",label:"Comic Sans MS"},{value:"Trebuchet MS",label:"Trebuchet MS"}],im=[{value:100,label:"Thin"},{value:200,label:"Extra Light"},{value:300,label:"Light"},{value:400,label:"Regular"},{value:500,label:"Medium"},{value:600,label:"Semi Bold"},{value:700,label:"Bold"},{value:800,label:"Extra Bold"},{value:900,label:"Black"}];function rm(){const{data:t,updateData:e}=Te(),{select:n}=pi(),[i,r]=ne(String(t?.fill)),[a,o]=ne(t?.fontSize||""),[c,l]=ne(t?.fontWeight||""),[u,m]=ne(t?.color||""),[d,h]=ne(t?.fontFamily||""),[x,N]=ne(t?.lineHeight??"");return t?s.jsxs(s.Fragment,{children:[s.jsx(ue,{label:"Text Color",children:s.jsx(Re,{value:u,className:"border-stock border-1 border-solid",onChange:f=>{m(f||""),e({color:f||void 0})}})}),s.jsx(rt,{min:0,max:100,step:1,label:"Font Size",value:Number(a),onChange:f=>{o(f),e({fontSize:f})}}),s.jsx(rt,{min:1,max:5,step:.1,label:"Line Height",value:Number(x),onChange:f=>{N(f),e({lineHeight:f})}}),s.jsx(ue,{label:"Font Weight",children:s.jsxs(_e,{value:String(c),onValueChange:f=>{const g=Number(f);l(g||""),e({fontWeight:g||void 0})},children:[s.jsx(Pe,{className:n,children:s.jsx(He,{})}),s.jsx($e,{children:im.map(f=>s.jsx(Le,{value:String(f.value),children:f.label},f.value))})]})}),s.jsx(ue,{label:"Font Family",children:s.jsxs(_e,{value:d,onValueChange:f=>{h(f||""),e({fontFamily:f||void 0})},children:[s.jsx(Pe,{className:n,children:s.jsx(He,{})}),s.jsx($e,{children:nm.map(f=>s.jsx(Le,{value:f.value,children:f.label},f.value))})]})}),s.jsx(ue,{label:"Background Color",children:s.jsx(Re,{value:i=="transparent"?"":i,className:"border-stock border-1 border-solid",onChange:f=>{r(f||""),e({fill:f||"transparent"})}})}),s.jsx(fs,{data:{borderColor:t?.stroke??null,borderStyle:t?.strokeStyle??null,borderWidth:t?.strokeWidth??null,borderRadius:t?.borderRadius??null,borderAnimationEnabled:t?.borderAnimationEnabled??null},onChange:f=>{e({stroke:f.borderColor??void 0,strokeWidth:f.borderWidth??void 0,strokeStyle:f.borderStyle??void 0,borderRadius:f.borderRadius??void 0,borderAnimationEnabled:f.borderAnimationEnabled??void 0})}})]}):null}function ei({className:t,children:e,...n}){const i=y.useRef(null),r=y.useRef(null),[a,o]=y.useState(),[c,l]=y.useState();return y.useEffect(()=>{const u=i.current;if(!u)return;const m=r.current;if(!m)return;const d=new ResizeObserver(()=>{l(m.clientHeight),o(u.clientHeight)});return l(m.clientHeight),o(u.clientHeight),d.observe(m),d.observe(u),()=>d.disconnect()},[r]),s.jsx("div",{ref:r,className:"relative isolate",children:s.jsx("div",{className:"pointer-events-auto absolute inset-0 h-fit max-h-full rounded-b-[0.75rem] border border-t-0 border-[#2A3242] bg-[#141925]",children:s.jsx(Ti,{className:"[&>div>div]:!block",style:{height:Math.min(a??0,c??0)},children:s.jsx("div",{...n,ref:i,className:H("w-[14.875rem] space-y-4 p-4 pt-2",t),children:s.jsx(Vr,{theme:"modal",children:s.jsx(Mt,{children:e})})})})})})}const ti="h-8 w-full rounded-[0.5rem] border border-[#2A3242] bg-transparent px-3 text-sm text-[#F4F7FC] placeholder:text-[#828DA3] focus:outline-none",am="h-7 w-full rounded-[0.5rem] border border-[#2A3242] bg-transparent px-2 text-xs text-[#F4F7FC] placeholder:text-[#828DA3] focus:outline-none";function om(){const{data:t,updateData:e}=Te(),[n,i]=Ve(t),r=Kr(n?.componentFields,{componentFieldId:"name"});function a(f){i(g=>{const v={...g,...f};return e(v),v})}const o=n?.columns&&n.columns.length?n.columns:ui,l=(n?.rows&&n.rows.length?n.rows:mi).map(f=>o.map((g,v)=>f?.[v]??""));function u(f,g){const v=o.map((b,p)=>p===f?g:b);a({columns:v})}function m(f,g,v){const b=l.map((p,w)=>p.map((S,I)=>w===f&&I===g?v:S));a({rows:b})}function d(){const f=[...l,o.map(()=>"")];a({rows:f})}function h(){const f=[...o,`Column ${o.length+1}`],g=l.map(v=>[...v,""]);a({columns:f,rows:g})}function x(f){if(l.length<=1)return;const g=l.filter((v,b)=>b!==f);a({rows:g})}function N(f){if(o.length<=1)return;const g=o.filter((b,p)=>p!==f),v=l.map(b=>b.filter((p,w)=>w!==f));a({columns:g,rows:v})}return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(le,{className:"text-xs text-[#828DA3]",children:"Table name"}),s.jsx(Fe,{value:r??"",onChange:f=>{const g=n?.componentFields??t?.componentFields??[],b=g.some(p=>p?.componentFieldId==="name")?g:[...g,{componentFieldId:"name",type:X.TextInput,label:"Name",isReadonly:!1,data:[{value:""}]}];a({componentFields:cn(b,{name:f.target.value})})},className:ti})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(le,{className:"text-xs font-semibold text-[#F4F7FC]",children:"Columns"}),s.jsx("span",{className:"text-[11px] text-[#828DA3]",children:o.length})]}),s.jsx("div",{className:"space-y-1.5",children:o.map((f,g)=>s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(Fe,{value:f,onChange:v=>u(g,v.target.value),className:`${ti} flex-1 text-xs`}),s.jsx(Q,{size:"icon",preset:"ghost",className:"size-7 text-[#828DA3] hover:text-[#F4F7FC]",disabled:o.length<=1,onClick:()=>N(g),children:s.jsx(It,{className:"h-3.5 w-3.5"})})]},`column-${g}`))}),s.jsxs(Q,{preset:"outline",className:"h-8 w-full",onClick:h,children:[s.jsx(mt,{className:"mr-1 h-3 w-3"}),"Add column"]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(le,{className:"text-xs font-semibold text-[#F4F7FC]",children:"Rows"}),s.jsx("span",{className:"text-[11px] text-[#828DA3]",children:l.length})]}),s.jsx("div",{className:"space-y-2",children:l.map((f,g)=>s.jsxs("div",{className:"rounded-xl border border-[#2A3242] bg-[#1E2533] p-2",children:[s.jsxs("div",{className:"mb-1 flex items-center justify-between text-[11px] text-[#828DA3]",children:[s.jsxs("span",{children:["Row ",g+1]}),s.jsx(Q,{size:"icon",preset:"ghost",className:"size-6 text-[#828DA3] hover:text-[#F4F7FC]",disabled:l.length<=1,onClick:()=>x(g),children:s.jsx(It,{className:"h-3 w-3"})})]}),s.jsx("div",{className:"space-y-1",children:o.map((v,b)=>s.jsx(Fe,{value:f[b]??"",placeholder:v||`Column ${b+1}`,onChange:p=>m(g,b,p.target.value),className:am},`cell-${g}-${b}`))})]},`row-${g}`))}),s.jsxs(Q,{preset:"outline",className:"h-8 w-full",onClick:d,children:[s.jsx(mt,{className:"mr-1 h-3 w-3"}),"Add row"]})]})]})}function lm(){const{data:t,updateData:e}=Te(),[n,i]=Ve(t);function r(a){i(o=>{const c={...o,...a};return e(c),c})}return s.jsx(s.Fragment,{children:s.jsx(rt,{label:"Border Radius",min:0,max:100,step:1,value:n?.borderRadius??8,onChange:a=>r({borderRadius:a})})})}const cm=220,dm=640,um=238,si="pointer-events-auto flex h-14 items-center justify-between rounded-t-[0.75rem] border border-[#2A3242] bg-[#141925] px-4 py-3";function ni({active:t,onClick:e,children:n}){return s.jsx("button",{type:"button",onClick:e,className:H("h-8 rounded-[0.375rem] px-3 text-sm font-normal transition-colors",t?"bg-[#141925] text-[#F4F7FC] shadow-sm":"text-[#828DA3] hover:text-[#F4F7FC]"),children:n})}function mm(){const[t,e]=y.useState(!1),[n,i]=y.useState("data"),[r,a]=y.useState(um),o=y.useRef(!1),c=y.useRef(0);y.useEffect(()=>{function g(b){o.current&&a(Math.min(dm,Math.max(cm,c.current-b.clientX)))}function v(){o.current&&(o.current=!1,document.body.style.userSelect="",document.body.style.cursor="")}return window.addEventListener("pointermove",g),window.addEventListener("pointerup",v),()=>{window.removeEventListener("pointermove",g),window.removeEventListener("pointerup",v),document.body.style.userSelect="",document.body.style.cursor=""}},[]);function l(g){g.preventDefault(),o.current=!0,c.current=g.currentTarget.parentElement?.getBoundingClientRect().right??0,document.body.style.userSelect="none",document.body.style.cursor="ew-resize"}const{setSelectedNodeIds:u,setSelectedEdgeIds:m}=we(),{node:d,updateData:h}=Te(),{edge:x}=or();function N(){u([])}function f(){m([])}return s.jsxs(s.Fragment,{children:[s.jsx(it,{children:d&&d.type!=="comment"?s.jsxs(ze.div,{initial:{opacity:0,x:16,scale:.95},animate:{opacity:1,x:0,scale:1},exit:{opacity:0,x:16,scale:.95},transition:{duration:.1,ease:"easeOut"},className:"pointer-events-none absolute inset-4 left-auto grid max-h-full w-[14.875rem] grid-rows-[auto_1fr]",style:{width:r},children:[s.jsxs("header",{className:si,children:[s.jsxs("div",{className:"flex items-center rounded-md border border-[#2A3242] bg-[#1E2533] p-0.5",children:[s.jsx(ni,{active:n==="data",onClick:()=>i("data"),children:"Data"}),s.jsx(ni,{active:n==="style",onClick:()=>i("style"),children:"Style"})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{className:"flex size-[1.375rem] items-center justify-center rounded-sm bg-transparent text-[#828DA3] transition-all hover:bg-[#1E2533] hover:text-[#F4F7FC]",onClick:()=>e(!0),children:s.jsx(Qa,{})}),s.jsx(gs,{onClick:N,className:"size-[1.375rem] rounded-sm"})]})]}),s.jsxs(ei,{className:"w-full",children:[s.jsx("button",{type:"button","aria-label":"Resize properties panel",onPointerDown:l,className:"before:bg-stock/30 hover:before:bg-paragraph/60 pointer-events-auto absolute top-0 -bottom-2 -left-1 z-20 w-2 cursor-ew-resize bg-transparent before:absolute before:inset-y-0 before:left-1/2 before:w-px before:-translate-x-1/2 before:transition-all"}),n==="data"&&s.jsx(s.Fragment,{children:d.type==="databaseTableSQL"?s.jsx(Ku,{}):d.type==="table"?s.jsx(om,{}):d.type==="subDiagram"?s.jsx(sm,{}):d.type==="c4"||d.type==="c4Boundary"?s.jsxs(s.Fragment,{children:[s.jsx(Zn,{}),s.jsx(zu,{})]}):s.jsx(Zn,{})}),n==="style"&&s.jsx(s.Fragment,{children:d.type==="cloud"?s.jsx(Pu,{}):d.type==="c4"?s.jsx(_u,{}):d.type==="group"||d.type==="c4Boundary"?s.jsx(Qu,{}):d.type==="shape"||d.type==="default"?s.jsx(tm,{}):d.type==="databaseTableSQL"?s.jsx($u,{}):d.type==="table"?s.jsx(lm,{}):d.type==="text"?s.jsx(rm,{}):d.type==="code"?s.jsx(Hu,{}):d.type==="builder"?s.jsx(Ru,{}):d.type==="sequenceParticipant"?s.jsx(em,{}):s.jsx("p",{className:"text-foreground/70 text-sm",children:"No style available"})})]})]}):x?s.jsxs(ze.div,{initial:{opacity:0,y:16,scale:.75},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:16,scale:.75},transition:{duration:.18,ease:"easeOut"},className:"pointer-events-none absolute inset-4 left-auto grid max-h-full grid-rows-[auto_1fr]",style:{width:r},children:[s.jsxs("header",{className:si,children:[s.jsx("h3",{className:"text-sm font-bold text-[#F4F7FC]",children:"Edge Properties"}),s.jsx("button",{onClick:f,className:"hover:bg-destructive flex size-[1.375rem] items-center justify-center rounded-md bg-[#1E2533] text-sm text-[#828DA3] transition-all hover:text-white",children:s.jsx(Ac,{})})]}),s.jsxs(ei,{className:"w-full",children:[s.jsx("button",{type:"button","aria-label":"Resize properties panel",onPointerDown:l,className:"before:bg-stock/30 hover:before:bg-paragraph/60 pointer-events-auto absolute top-0 -bottom-2 -left-1 z-20 w-2 cursor-ew-resize bg-transparent before:absolute before:inset-y-0 before:left-1/2 before:w-px before:-translate-x-1/2 before:transition-all"}),s.jsx(Au,{})]})]}):null}),s.jsx(Iu,{open:t,onOpenChange:e,initialComponentFields:d?.data.componentFields??[],onSubmit:async g=>{h({...d?.data,componentFields:g}),e(!1)}})]})}function hm({children:t}){const{viewport:e,diagramName:n,setDiagramName:i,isPreviewing:r,isEmbedded:a,isFullscreen:o,triggerMetaUpdate:c}=we(),l=ii(d=>d.user?.isServerAdmin);y.useEffect(()=>{if(!a)return;window.__uigraphEmbedSave=async()=>{await c(!0)};function d(h){h.key==="Escape"&&window.parent.__uigraphEmbedClose?.()}return window.addEventListener("keydown",d,{capture:!0}),()=>{delete window.__uigraphEmbedSave,window.removeEventListener("keydown",d,{capture:!0})}},[a,c]);const u=e?.zoom??1,m=y.useRef(null);return y.useEffect(()=>{if(!m.current)return;function h(x){x.key!=="Escape"||x.target?.closest('[role="dialog"],[role="menu"],[role="listbox"],[data-radix-popper-content-wrapper]')||document.querySelector('[role="dialog"][data-state="open"]')||(x.stopPropagation(),x.stopImmediatePropagation())}return document.addEventListener("keydown",h,{capture:!0}),()=>{document.removeEventListener("keydown",h,{capture:!0})}},[m]),s.jsxs("section",{ref:m,className:"bg-shading flex h-screen flex-1 flex-col select-none",children:[s.jsx("style",{children:`:root { --react-flow-scale: ${u}; --react-flow-counter-scale: ${Xr(u)} }`}),!a&&!o&&s.jsxs("header",{className:"bg-shading flex h-[5rem] items-center justify-between rounded-[1.2rem] px-6 py-4",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsxs(Il,{children:[s.jsx(Tl,{hidden:!0,asChild:!0,children:s.jsx(Q,{size:"icon",variant:"ghost",children:s.jsx(Za,{className:"text-foreground/40 size-8"})})}),s.jsxs(Fl,{side:"left",className:"!max-w-xs gap-0",showCloseButton:!1,children:[s.jsx(Rl,{className:"hidden",children:"Navigation"}),s.jsx(zl,{className:"hidden",children:"Select an action to perform"}),s.jsxs(Dl,{className:"flex flex-row items-start justify-between",children:[s.jsx(ss,{to:"/dashboard",children:s.jsx(Hs,{})}),s.jsx(El,{asChild:!0,children:s.jsx(gs,{})})]}),s.jsx("div",{className:"p-3",children:Ja.filter(d=>!d.serverAdminOnly||l).map(d=>{const h=s.jsxs(ss,{to:d.disabled?"":d.id,className:H("flex items-center justify-start gap-2 rounded-[0.75rem] p-1 px-2 transition-all",d.disabled?"text-paragraph cursor-not-allowed":"hover:bg-accent cursor-pointer"),children:[s.jsx("span",{className:H("flex size-10 items-center justify-center bg-transparent text-2xl transition-all *:transition-all"),children:d.icon}),s.jsx("span",{className:"block text-center text-sm",children:d.label})]});return s.jsxs("li",{className:"relative block select-none",children:[h,typeof d.disabled=="string"&&s.jsx("p",{className:"absolute inset-0 flex cursor-not-allowed items-center justify-center rounded-[0.75rem] bg-black/10 text-center text-sm opacity-0 backdrop-blur-xs transition-all hover:opacity-100",children:d.disabled})]},d.id)})})]})]}),s.jsx(ss,{to:"/dashboard",className:"rounded-full",children:s.jsx(Hs,{className:"size-11 max-w-none"})}),s.jsx(Fe,{value:n,placeholder:"Enter diagram name",onChange:d=>i(d.target.value),className:"placeholder:text-foreground/20 h-auto rounded-[0.5rem] px-2.5 py-1.5 !text-[1.25rem] font-medium shadow-none placeholder:text-lg placeholder:font-medium"})]}),Yr.VITE_FEATURE_DIAGRAM_IMPORT_EXPORT&&s.jsx(Tc,{}),s.jsx(eo,{})]}),s.jsx("div",{className:"relative isolate h-full flex-1",children:s.jsxs("div",{className:H("absolute isolate overflow-hidden","inset-4 top-2 rounded-[0.75rem] border border-[#2A3242]",a&&"inset-0 rounded-none border-none",o&&"inset-0 rounded-none border-none"),children:[t,s.jsx(od,{}),s.jsx(ud,{}),s.jsxs("div",{className:"group/left-controls pointer-events-none absolute inset-0",children:[!a&&o&&s.jsx("div",{className:"pointer-events-auto absolute top-4 bottom-0 left-0 w-10",children:s.jsx("div",{className:"pointer-events-none absolute top-1/2 left-0 flex h-14 w-5 -translate-y-1/2 items-center justify-center rounded-r-[0.375rem] border border-l-0 border-[#2A3242] bg-[#141925] transition-opacity duration-200 group-hover/left-controls:opacity-0",children:s.jsx(ct,{className:"size-3.5 text-[#828DA3]"})})}),s.jsx(md,{}),!r&&s.jsx(Su,{})]}),!r&&s.jsx(mm,{}),!r&&s.jsx(dd,{}),s.jsx(Lc,{}),s.jsx(vc,{})]})})]})}function Nh({embedded:t}){const e=Qs(),{diagramId:n}=fr(),{data:i,loading:r}=ut(la,{errorPolicy:"ignore",fetchPolicy:"cache-first",skip:!e.id,variables:{orgId:e.id,id:String(n)}}),a=y.useMemo(()=>ca(i?.diagram?.content??void 0),[i?.diagram?.content]),o=y.useMemo(()=>i?.diagram?.updatedAt??void 0,[i?.diagram?.updatedAt]);return r?s.jsx(xr,{}):s.jsx(Qr,{diagramId:n,isEmbedded:t,organizationId:e.id,folderId:i?.diagram?.folderId??null,teamId:i?.diagram?.teamId??null,initialData:a,initialInfo:{name:i?.diagram?.name??void 0,lastUpdatedAt:o},children:s.jsx(Zr,{children:s.jsx(ia,{children:s.jsx(hm,{children:s.jsx(Jr,{forceAutoFitView:!0})})})})})}export{Nh as DiagramPortalPage};
|
|
231
|
+
`),Jt=20,Rs="all";function ar({selectedDiagramId:t,onSelect:e,onDragStart:n}){const{organizationId:i,diagramId:r}=we(),[a,o]=y.useState(""),c=tl(a,300),[l,u]=y.useState(Rs),[m,d]=y.useState(Jt),h=ut(pu,{variables:{orgId:i},skip:!i}),{data:x,loading:N}=ut(Jo,{variables:{orgId:i,search:c||void 0,teamId:l===Rs?void 0:l,limit:m,offset:0},skip:!i,fetchPolicy:"cache-and-network"}),f=Be(h.data?.teams??[]),g=Be(x?.diagrams?.items??[]),v=g.filter(p=>p.id!==r),b=g.length<(x?.diagrams?.totalCount??0);return s.jsxs(s.Fragment,{children:[f.length>0&&s.jsxs(_e,{value:l,onValueChange:p=>{u(p),d(Jt)},children:[s.jsx(Pe,{className:"border-stock bg-input h-9 w-full rounded-md text-sm",children:s.jsx(He,{placeholder:"All teams"})}),s.jsxs($e,{children:[s.jsx(Le,{value:Rs,children:"All teams"}),f.map(p=>s.jsx(Le,{value:p.id,children:p.name},p.id))]})]}),s.jsxs("div",{className:"relative",children:[s.jsx($a,{className:"text-paragraph absolute top-1/2 left-2.5 size-3.5 -translate-y-1/2"}),s.jsx(Fe,{value:a,placeholder:"Search diagrams",className:"border-stock bg-input h-9 w-full rounded-md pl-8 text-sm",onChange:p=>{o(p.currentTarget.value),d(Jt)}})]}),s.jsxs("div",{className:"flex max-h-72 min-w-0 flex-col gap-1 overflow-y-auto",children:[N&&v.length===0&&s.jsx("p",{className:"text-paragraph py-2 text-xs",children:"Loading diagrams…"}),!N&&v.length===0&&s.jsx("p",{className:"text-paragraph py-2 text-xs",children:"No diagrams found"}),v.map(p=>{const w=p.name??"Untitled diagram",S=p.id===t;return s.jsxs("div",{draggable:!!n,onDragStart:I=>n?.(I,p),onClick:()=>e?.(p),role:e?"button":void 0,tabIndex:e?0:void 0,onKeyDown:I=>{I.key!=="Enter"&&I.key!==" "||(I.preventDefault(),e?.(p))},className:H("flex w-full min-w-0 items-center gap-2 rounded-md border p-1.5 text-left transition-colors",n&&"cursor-grab active:cursor-grabbing",!S&&"border-stock hover:bg-input",S&&"border-primary bg-primary/10"),children:[s.jsx("div",{className:"bg-input h-8 w-12 shrink-0 overflow-hidden rounded-sm",children:p.previewImageUrl&&s.jsx("img",{src:p.previewImageUrl,alt:w,className:"size-full object-cover"})}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-[#F4F7FC]",children:w}),S&&s.jsx(Wa,{className:"text-primary size-3.5 shrink-0"})]},p.id)}),b&&s.jsx("button",{type:"button",disabled:N,onClick:()=>d(m+Jt),className:"border-stock hover:bg-input text-paragraph mt-0.5 rounded-md border py-1.5 text-xs transition-colors disabled:opacity-60",children:N?"Loading…":"Load more"})]})]})}function fu(){const[t,e]=y.useState(!0);return s.jsxs(s.Fragment,{children:[s.jsxs("button",{onClick:()=>e(!t),className:H($t,"mt-0.5"),children:[s.jsx("span",{className:"truncate",children:"Sub Diagram"}),s.jsx(nt,{className:H("size-3 transition-transform duration-200 ease-out",!t&&"-rotate-90")})]}),s.jsx(it,{initial:!1,children:t&&s.jsx(ze.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:"easeOut"},className:"overflow-hidden",children:s.jsx("div",{className:"flex flex-col gap-2 px-2 pt-2 pb-2",children:s.jsx(ar,{onDragStart:(n,i)=>{const r=i.name??"Untitled diagram";Ke(n,Zt.nodeType,{...Zt.dragData,diagramId:i.id,diagramName:r},{width:Zt.recommendedSize.width,height:Zt.recommendedSize.height},r)}})})},"category-sub-diagram")})]})}function xu(){return s.jsx(Xe,{className:"left-18",children:s.jsxs("div",{className:"flex w-[16rem] flex-col p-1.5",children:[s.jsx(gu,{}),s.jsx(hu,{}),s.jsx(fu,{})]})})}const bu=["flowchart","shapes"],or={standard:{label:"Standard",shapeIds:["document","multiple-documents"]},flowchart:{label:"Flowchart",shapeIds:["terminator","delay","off-page-connector","display","collate","sort","or","database","subroutine","manual-input","summing-junction","internal-storage"]},shapes:{label:"Shapes",shapeIds:["rectangle","rounded-rect","ellipse","diamond","triangle","parallelogram","trapezoid","hexagon","cylinder"]}};function yu(t){for(const[e,{shapeIds:n}]of Object.entries(or))if(n.includes(t))return e}function vu(t){const e={shapes:[],standard:[],flowchart:[]};for(const n of t){const i=yu(n.id);i&&e[i].push(n)}return e}const ju=[{id:"text",label:"Text",icon:s.jsx(Il,{className:"h-4 w-4"}),nodeType:"text",dragData:{componentFields:[{componentFieldId:"text",type:X.TextBox,label:"Text",isReadonly:!0}]},recommendedSize:{width:200,height:60}},{id:"sticky-note",label:"Sticky Note",icon:s.jsx(Sl,{className:"h-4 w-4"}),nodeType:"shape",dragData:{shape:"rounded-rect",fill:"#FEF08A",cornerRadius:0,componentFields:[{componentFieldId:"name",type:X.TextInput,label:"Name",isReadonly:!0,data:[{value:""}]}]},recommendedSize:{width:200,height:150}},{id:"code-block",label:"Code Block",icon:s.jsx(Ht,{className:"h-4 w-4"}),nodeType:"code",dragData:{fontFamily:"monospace",componentFields:[{componentFieldId:"code",type:X.CodeEditor,label:"Code",isReadonly:!0,data:[{value:"// Code here"}]}]},recommendedSize:{width:300,height:150}},{id:"table",label:"Table",nodeType:"table",icon:s.jsx(Lr,{className:"size-4"}),dragData:{rows:mi,columns:ui,componentFields:[{componentFieldId:"name",type:X.TextInput,label:"Name",isReadonly:!1,data:[{value:"My Table"}]}]}},{id:"frame",label:"Frame",icon:s.jsx(hl,{className:"h-4 w-4"}),nodeType:"group",dragData:{backgroundColor:"rgba(20, 25, 37, 0.35)",borderColor:"#828DA3",componentFields:[{componentFieldId:"name",type:X.TextInput,label:"Name",isReadonly:!1,data:[{value:"Frame"}]},{componentFieldId:"label",type:X.TextInput,label:"Label",data:[{value:""}]}],childNodes:[]},recommendedSize:{width:400,height:300}}];function wu(){const[t,e]=y.useState(new Set(["standard","flowchart","shapes"])),n=vu(hi);function i(r){const a=new Set(t);a.has(r)?a.delete(r):a.add(r),e(a)}return s.jsx(Xe,{className:"left-18",children:s.jsxs("div",{className:"w-[10.5rem] p-2",children:[s.jsx("div",{className:"text-muted-foreground mb-2 text-xs font-semibold",children:"General"}),s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsxs("button",{onClick:()=>i("standard"),className:$t,children:[s.jsx("span",{className:"truncate",children:"Standard"}),t.has("standard")?s.jsx(nt,{className:"size-3"}):s.jsx($s,{className:"size-3"})]}),s.jsx(it,{initial:!1,children:t.has("standard")&&s.jsx(ze.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:"easeOut"},className:"overflow-hidden",children:s.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:ju.map(r=>s.jsx(Mt,{children:s.jsxs(et,{children:[s.jsx(tt,{children:s.jsx("div",{draggable:!0,className:Ys,onDragStart:a=>{Ke(a,r.nodeType,r.dragData,r.recommendedSize,r.label)},children:s.jsx("div",{className:"flex items-center justify-center",children:r.icon})})}),s.jsx(st,{children:r.label})]})},r.id))})},"category-standard")})]}),bu.filter(r=>r!=="standard").map(r=>{const a=or[r],o=n[r],c=t.has(r);return o.length===0?null:s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsxs("button",{onClick:()=>i(r),className:$t,children:[s.jsx("span",{className:"truncate",children:a.label}),c?s.jsx(nt,{className:"size-3"}):s.jsx($s,{className:"size-3"})]}),s.jsx(it,{initial:!1,children:c&&s.jsx(ze.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:"easeOut"},className:"overflow-hidden",children:s.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:o.map(l=>s.jsx(Mt,{children:s.jsxs(et,{children:[s.jsx(tt,{children:s.jsx("div",{draggable:!0,className:Ys,onDragStart:u=>{Ke(u,"shape",{shape:l.id,componentFields:[{componentFieldId:"name",type:X.TextInput,label:"Name",isReadonly:!0,data:[{value:""}]}]},{width:l.recommendedWidth,height:l.recommendedHeight},l.label)},children:s.jsx(l.Component,{})})}),s.jsx(st,{children:l.label})]})},l.id))})},`category-${r}`)})]},r)})]})]})})}function Yn(t){return Li({attr:{viewBox:"0 0 32 32"},child:[{tag:"path",attr:{d:"M 6 5 L 6 7 L 7 7 L 7 25 L 6 25 L 6 27 L 14 27 L 14 25 L 13 25 L 13 19 L 19 19 L 19 25 L 18 25 L 18 27 L 26 27 L 26 25 L 25 25 L 25 7 L 26 7 L 26 5 L 18 5 L 18 7 L 19 7 L 19 13 L 13 13 L 13 7 L 14 7 L 14 5 Z M 9 7 L 11 7 L 11 15 L 21 15 L 21 7 L 23 7 L 23 25 L 21 25 L 21 17 L 11 17 L 11 25 L 9 25 Z"},child:[]}]})(t)}const Nu=[{name:"Heading",preview:"Heading",id:"text:h1",icon:s.jsx(Yn,{}),fontSize:24,fontWeight:700,color:"#f4f7fc"},{name:"Subheading",preview:"Subheading",id:"text:h2",icon:s.jsx(Yn,{}),fontSize:20,fontWeight:600,color:"#d2d9e6"},{name:"Body",preview:"Body text",id:"text:body",icon:s.jsx(_s,{}),fontSize:14,fontWeight:400,color:"#d2d9e6"},{name:"Caption",preview:"Caption",id:"text:caption",icon:s.jsx(_s,{}),fontSize:12,fontWeight:400,color:"#828da3"}];function Cu(){return s.jsx(Xe,{className:"left-18",children:s.jsx("div",{className:"flex w-[10.5rem] flex-col gap-1.5 p-1",children:Nu.map((t,e)=>s.jsx("div",{draggable:!0,className:Yi,onDragStart:n=>{Ke(n,"text",{color:t.color,fontSize:t.fontSize,fontWeight:t.fontWeight,componentFields:[{componentFieldId:"text",type:X.TextBox,label:"Text",isReadonly:!0}]},void 0,t.preview)},children:s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"flex size-5 items-center justify-center rounded-[4px] border border-[#2A3242] bg-[#1E2533] text-[12px] text-[#F4F7FC]",children:t.icon}),s.jsx("span",{className:"text-sm font-medium",children:t.preview})]})},e))})})}function Su(){const{sidebarActiveTool:t,setSidebarActiveTool:e,isEmbedded:n,isFullscreen:i}=we(),r=!n&&i&&!t;return s.jsxs(s.Fragment,{children:[s.jsx(Xe,{className:H(!n&&i&&"top-[4.25rem]",r&&"-translate-x-[calc(100%_+_1rem)] transition-transform duration-200 group-hover/left-controls:translate-x-0"),children:s.jsxs("div",{className:"flex flex-col items-center gap-1.5 p-1",children:[s.jsx(ot,{name:"General",icon:s.jsx(Ga,{}),isActive:t==="shapes",onClick:()=>e(a=>a==="shapes"?null:"shapes")}),s.jsx(ot,{name:"Modeling",icon:s.jsx(qa,{}),isActive:t==="modeling",onClick:()=>e(a=>a==="modeling"?null:"modeling")}),s.jsx(ot,{name:"Icons",icon:s.jsx(Ua,{}),isActive:t==="icons",onClick:()=>e(a=>a==="icons"?null:"icons")}),s.jsx(ot,{name:"Images",icon:s.jsx(Va,{}),isActive:t==="images",onClick:()=>e(a=>a==="images"?null:"images")}),s.jsx(ot,{name:"Animated Nodes",icon:s.jsx(gd,{}),isActive:t==="animated",onClick:()=>e(a=>a==="animated"?null:"animated")}),s.jsx(ot,{name:"Text",icon:s.jsx(_s,{}),isActive:t==="text",onClick:()=>e(a=>a==="text"?null:"text")}),s.jsx(ot,{name:"Comments",icon:s.jsx(Ka,{}),isActive:t==="comments"||t==="add-comment",onClick:()=>e(a=>a==="comments"||a==="add-comment"?null:"comments")}),s.jsx(ot,{name:"Data Sources",icon:s.jsx(Bo,{}),isActive:t==="data-sources",onClick:()=>{e(a=>a==="data-sources"?null:"data-sources")}})]})}),t==="shapes"&&s.jsx(wu,{}),t==="modeling"&&s.jsx(xu,{}),t==="icons"&&s.jsx(Od,{}),t==="images"&&s.jsx(cu,{}),t==="animated"&&s.jsx(vd,{}),t==="text"&&s.jsx(Cu,{}),t==="data-sources"&&s.jsx(Id,{}),(t==="comments"||t==="add-comment")&&s.jsx(jd,{})]})}function ot({icon:t,name:e,isActive:n,onClick:i}){return s.jsx(Mt,{children:s.jsxs(et,{open:n?!1:void 0,children:[s.jsx(tt,{asChild:!0,children:s.jsx("button",{onClick:i,className:H("flex h-10 w-10 items-center justify-center rounded-[0.5rem] border border-[#2A3242] bg-transparent text-[#F4F7FC] transition-all hover:bg-[#1E2533] [&>svg]:!size-5",n&&"border-primary/30 bg-primary/10 text-primary"),children:t})}),s.jsx(st,{side:"right",children:e})]})})}function lr(){const t=we(),e=y.useRef(null);function n(){return t.selectedEdgeIds.length!==1?null:t.reactFlowInstance?.getEdge(t.selectedEdgeIds[0])??null}const i=n();function r(a){const o=i.id;if(!o)return;const c=structuredClone(a);function l(){let u;t.setEdges(m=>m.map(d=>d.id!==o?d:(u={...d,...c},u))),u&&t.reactFlowInstance?.updateEdge(o,u)}e.current&&clearTimeout(e.current),e.current=setTimeout(l,100)}return{edge:i,updateEdge:r}}function Te(){const t=bi(),e=we(),n=y.useRef(null);function i(){return e.selectedNodeIds.length!==1?null:e.nodes.find(l=>l.id===e.selectedNodeIds[0])??null}const r=i(),a=r?.data??null;function o(l,u){const m=r.id;if(!m)return;const d=structuredClone(l);function h(){if(u)return t.updateNode(m,d);let x;e.setNodes(N=>N.map(f=>f.id!==d.id?f:(x=Qn(f,d),x))),x&&t.updateNode(m,x)}n.current&&clearTimeout(n.current),n.current=setTimeout(h,100)}function c(l,u){const m=r.id;if(!m)return;const d=structuredClone(l);function h(){if(u)return t.updateNodeData(m,l);e.setNodes(x=>x.map(N=>N.id!==m?N:Qn(N,{data:d})))}n.current&&clearTimeout(n.current),n.current=setTimeout(h,100)}return{node:r,data:a,updateNode:o,updateData:c}}function Qn(t,e){return{...t,...e,data:{...t.data,...e.data}}}function ku({componentFields:t,setComponentFields:e,nativeComponents:n,largeEmptyState:i,enableRequired:r,hideDescription:a,newItemDefaults:o}){return s.jsxs("div",{className:"leading-[1.3333]",children:[!a&&s.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"mb-2 font-semibold",children:"Component Structure"}),s.jsx("p",{className:"text-paragraph text-sm",children:"Define the fields for your component"})]}),n&&s.jsxs(Ot,{children:[s.jsx(Bt,{asChild:!0,children:s.jsxs(Q,{preset:"outline",className:"h-14 w-[12.25rem] justify-between px-6 text-base",children:["Apply Template",s.jsx(zo,{})]})}),s.jsx(_t,{align:"end",children:n.filter(c=>c.type==="modal").map(c=>s.jsx(Me,{onClick:()=>{e(Be(c.componentFields).map((l,u)=>({...l,order:u+1})))},children:c.name},c.componentId))})]})]}),s.jsxs("div",{className:"mb-6",children:[t.length===0&&s.jsx("div",{className:H("flex items-center justify-center rounded-[16px] border border-[#2A3242] bg-transparent p-3",i&&"py-8"),children:s.jsx("p",{className:"text-paragraph text-sm",children:"No fields added"})}),s.jsx(ao,{enableRequired:r,componentFields:t,setComponentFields:e})]}),s.jsxs("div",{hidden:!0,children:[s.jsx(Q,{variant:"destructive",className:"mb-4 h-11 w-full rounded-xl",onClick:()=>{const c=Object.values(X).map(l=>[l,l]).flat();e(c.map((l,u)=>({componentFieldId:crypto.randomUUID(),order:u+1,type:l,label:l,required:u%2===0,options:Array.from({length:5},(m,d)=>`Option ${d+1}`)})))},children:"Add All Fields (Required + Optional) - For Testing"}),s.jsx(Q,{variant:"destructive",className:"mb-4 h-11 w-full rounded-xl",onClick:()=>{const c=Object.values(X);e(c.map((l,u)=>({componentFieldId:crypto.randomUUID(),type:l,order:u+1,label:l,required:!0,options:Array.from({length:5},(m,d)=>`Option ${d+1}`)})))},children:"Add All Fields (Required) - For Testing"}),s.jsx(Q,{variant:"destructive",className:"mb-4 h-11 w-full rounded-xl",onClick:()=>{const c=Object.values(X);e(c.map((l,u)=>({componentFieldId:crypto.randomUUID(),type:l,order:u+1,label:l,required:!1,options:Array.from({length:5},(m,d)=>`Option ${d+1}`)})))},children:"Add All Fields (Optional) - For Testing"})]}),s.jsx(oo,{defaults:o,setComponentFields:e})]})}function Iu({...t}){return s.jsx(en,{open:t.open,onOpenChange:t.onOpenChange,children:s.jsx(nn,{showCloseButton:!1,className:"border-stock bg-shading h-full !w-full !max-w-full grid-rows-[auto_1fr] gap-0 overflow-hidden rounded-none border p-0 md:h-auto md:max-h-[90vh] md:!max-w-[42.9375rem] md:rounded-[2rem]",children:s.jsx(Tu,{...t})})})}function Tu({initialComponentFields:t,onOpenChange:e,onSubmit:n}){const i=y.useRef(null),[r,a]=y.useState(0),[o,c]=y.useState(!1);y.useEffect(()=>{const d=i.current;if(!d)return;const h=new ResizeObserver(()=>{a(d.clientHeight)});return a(d.clientHeight),h.observe(d),()=>h.disconnect()},[i]);const l=y.useMemo(()=>Be(t),[t]),[u,m]=ne(l);return s.jsxs(s.Fragment,{children:[s.jsxs(Si,{className:"border-stock flex flex-row items-center justify-between border-b p-6",children:[s.jsxs("div",{className:"flex h-full flex-col justify-between",children:[s.jsx(tn,{className:"mb-2 text-base leading-tight",children:"Component Structure"}),s.jsx(sn,{children:"Configure the Structure for component."})]}),s.jsx(ga,{asChild:!0,children:s.jsx(gs,{})})]}),s.jsxs("div",{className:"custom-scrollbar relative isolate overflow-auto p-6",children:[s.jsx(ze.div,{animate:{height:r},transition:{duration:.2,ease:"easeInOut"},children:s.jsx("div",{ref:i,children:s.jsx(ku,{hideDescription:!0,largeEmptyState:!0,enableRequired:!1,componentFields:u,newItemDefaults:{hidden:!0},setComponentFields:m})})}),s.jsxs("div",{className:"relative z-10 mt-6 flex justify-end gap-3",children:[s.jsx(Q,{type:"button",variant:"outline",className:"text-paragraph border-stock bg-input h-11 w-[4.5rem] rounded-[0.8125rem]",onClick:()=>e(!1),children:"Cancel"}),s.jsxs(Q,{type:"button",className:"h-11 rounded-[0.8125rem] px-8",onClick:async function(){let d=!1;m(u.map(h=>h.label?.trim()?h:(d=!0,{...h,error:"Field name is required"}))),!d&&(c(!0),await n(u),c(!1))},children:[o&&s.jsx(os,{}),"Save"]})]})]})]})}function ms({className:t,defaultValue:e,value:n,min:i=0,max:r=100,...a}){const o=y.useMemo(()=>Array.isArray(n)?n:Array.isArray(e)?e:[i,r],[n,e,i,r]);return s.jsxs(lo,{"data-slot":"slider",defaultValue:e,value:n,min:i,max:r,className:H("relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",t),...a,children:[s.jsx(co,{"data-slot":"slider-track",className:H("bg-muted relative grow overflow-hidden rounded-full data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5"),children:s.jsx(uo,{"data-slot":"slider-range",className:H("bg-primary absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full")})}),Array.from({length:o.length},(c,l)=>s.jsx(mo,{"data-slot":"slider-thumb",className:"border-primary bg-background ring-ring/50 block size-4 shrink-0 rounded-full border shadow-sm transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"},l))]})}function hs({min:t,max:e,step:n,value:i,onChange:r}){return s.jsx("div",{className:"flex !h-12 w-full items-center rounded-[0.5rem] border px-4",children:s.jsx(ms,{min:t,max:e,step:n,value:[i],onValueChange:([a])=>r(a)})})}function Eu({edge:t,updateEdge:e}){const n=xn(t?.markerStart),i=xn(t?.markerEnd);return s.jsxs(s.Fragment,{children:[s.jsx(Zn,{label:"Start",marker:n,onChange:r=>{console.log({markerStart:r}),e({markerStart:Os(r)})}}),s.jsx(Zn,{label:"End",marker:i,onChange:r=>{console.log({markerEnd:r}),e({markerEnd:Os(r)})}})]})}function Zn({label:t,marker:e,onChange:n}){const[i,r]=ne(e?.type||"none"),[a,o]=ne(e?.width?.toString()||e?.height?.toString()||""),[c,l]=ne(e?.color||""),[u,m]=ne(e?.strokeWidth?.toString()||"");return s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsxs(le,{className:"mb-2 text-sm leading-[1.333]",children:[t," Marker"]}),s.jsxs(_e,{value:i,onValueChange:d=>{r(d),n({...e,type:d})},children:[s.jsx(Pe,{className:"border-stock text-paragraph !h-12 w-full rounded-[0.5rem] border px-4 text-sm",children:s.jsx(He,{placeholder:"Select Marker"})}),s.jsxs($e,{children:[s.jsx(Le,{value:"none",children:"None"}),Ar.map(d=>s.jsxs(Le,{value:d.id,children:[d.icon,d.label]},d.id))]})]})]}),(i===Gs.Arrow||i===Gs.ArrowClosed)&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsxs(le,{className:"mb-2 text-sm leading-[1.333]",children:[t," Marker Color"]}),s.jsx(Ai,{color:c.startsWith("#")?c:"",onColorChange:d=>{l(d),n({...e,color:d||"context-stroke"})}})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[s.jsxs(le,{className:"text-sm leading-[1.333]",children:[t," Marker Size"]}),s.jsx("span",{className:"text-muted-foreground text-center text-xs",children:a})]}),s.jsx(hs,{min:1,max:20,step:.1,value:a?Number(a):1,onChange:d=>{o(String(d)),n({...e,width:d,height:d})}})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[s.jsxs(le,{className:"text-sm leading-[1.333]",children:[t," Marker Stroke"]}),s.jsx("span",{className:"text-muted-foreground text-center text-xs",children:u})]}),s.jsx(hs,{min:1,max:5,step:.1,value:u?Number(u):1,onChange:d=>{m(String(d)),n({...e,strokeWidth:d})}})]})]})]})}function ue({label:t,labelExtra:e,labelClassName:n,labelRowClassName:i,children:r,visible:a,onChangeVisibility:o,isVisibilityDisabled:c}){const[l,u]=ne(a??!1);return s.jsxs("div",{children:[s.jsxs("div",{className:H("mb-2 flex h-7 items-center justify-between",i),children:[s.jsx(le,{className:H("text-sm font-normal text-[#F4F7FC]",n),children:t}),s.jsxs("div",{className:"flex items-center gap-2",children:[e,a!==void 0&&o!==void 0&&s.jsxs(et,{open:c?void 0:!1,children:[s.jsx(tt,{asChild:!0,children:s.jsx("div",{children:s.jsx(Q,{size:"icon",variant:"ghost",className:"size-6 text-[#828DA3] hover:text-[#F4F7FC]",disabled:c,onClick:()=>{u(m=>(o(!m),!m))},children:l?s.jsx(Xa,{}):s.jsx(Ya,{})})})}),s.jsx(st,{className:"mr-1 max-w-[200px] text-center",children:"This field can not be shown on the flow diagram"})]})]})]}),r]})}function rt({min:t,max:e,step:n,label:i,labelClassName:r,labelRowClassName:a,inputClassName:o,value:c,onChange:l}){return s.jsx(ue,{label:i,labelClassName:r,labelRowClassName:a,children:s.jsxs("div",{className:"flex w-full items-center gap-3",children:[s.jsx("div",{className:"flex-1",children:s.jsx(ms,{min:t,max:e,step:n,value:[Number.isNaN(Number(c))?0:Number(c)],onValueChange:([u])=>l(u)})}),s.jsx("input",{min:t,max:e,step:n,value:Number.isNaN(c)?"":c??"",onChange:u=>{const m=Number(u.target.value);!Number.isNaN(m)&&m>=t&&m<=e&&l(m)},type:"number",className:H("border-stock text-paragraph !h-12 w-16 rounded-[0.5rem] border px-1 pl-3 text-center text-sm",o)})]})})}function Lu({edge:t,updateEdge:e}){const[n,i]=ne(t?.style?.strokeWidth?String(t.style.strokeWidth):"2"),[r,a]=ne(t?.style?.strokeDasharray===es.dashed?"dashed":t?.style?.strokeDasharray===es.dotted?"dotted":"solid"),[o,c]=ne(t?.style?.stroke);return s.jsxs(s.Fragment,{children:[s.jsx(rt,{label:"Stroke Width",min:1,max:10,step:.1,value:n,onChange:l=>{i(String(l)),e({style:{...t?.style,strokeWidth:l}})}}),s.jsxs("div",{children:[s.jsx(le,{className:"mb-2 text-sm leading-[1.333]",children:"Stroke Style"}),s.jsxs(_e,{value:r,onValueChange:l=>{a(l),e({style:{...t?.style,strokeDasharray:l==="dashed"?es.dashed:l==="dotted"?es.dotted:void 0}})},children:[s.jsx(Pe,{className:"!h-12 w-full rounded-[0.5rem] border px-4 text-sm",children:s.jsx(He,{})}),s.jsxs($e,{children:[s.jsx(Le,{value:"solid",children:"Solid"}),s.jsx(Le,{value:"dashed",children:"Dashed"}),s.jsx(Le,{value:"dotted",children:"Dotted"})]})]})]}),s.jsxs("div",{children:[s.jsx(le,{className:"mb-2 text-sm leading-[1.333]",children:"Stroke Color"}),s.jsx(Ai,{color:o,onColorChange:l=>{c(l),e({style:{...t?.style,stroke:l}})}})]})]})}const es={dashed:"4 2",dotted:"1"};function Au(){const{edge:t,updateEdge:e}=lr(),[n,i]=ne(t?.animated||!1),[r,a]=ne(String(t?.type||$o.Bezier)),[o,c]=ne(String(t?.label||"")),[l,u]=ne(Number(t?.data?.labelFontSize)||12);return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx(le,{className:"mb-2 text-sm leading-[1.333]",children:"Edge Label"}),s.jsx(Fe,{value:o,placeholder:"Edge Label",className:"!h-12 w-full rounded-[0.5rem] border px-4 text-sm",onChange:m=>{c(m.target.value),e({label:m.target.value?m.target.value:void 0})}})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[s.jsx(le,{className:"text-sm leading-[1.333]",children:"Label Size"}),s.jsx("span",{className:"text-muted-foreground block w-6 text-center text-xs",children:l})]}),s.jsx(hs,{min:8,max:40,step:1,value:l,onChange:m=>{u(m),e({data:{...t?.data,labelFontSize:m}})}})]}),s.jsxs("div",{children:[s.jsx(le,{className:"mb-2 text-sm leading-[1.333]",children:"Edge Type"}),s.jsxs(_e,{value:r,onValueChange:m=>{a(m),e({type:m})},children:[s.jsx(Pe,{className:"border-stock text-paragraph !h-12 w-full rounded-[0.5rem] border px-4 text-sm",children:s.jsx(He,{placeholder:"Select Edge Type"})}),s.jsx($e,{children:Fr.map(m=>s.jsx(Le,{value:m.id,children:m.label},m.id))})]})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[s.jsx(le,{className:"text-sm leading-[1.333]",children:"Animated"}),s.jsx(rs,{checked:n,onCheckedChange:m=>{i(m),e({animated:m})}})]}),n&&s.jsxs(Q,{preset:"outline",className:"w-full",onClick:()=>{e({data:{...t?.data,reverseAnimation:!t?.data?.reverseAnimation}})},children:[s.jsx(Dr,{className:"size-4"}),"Reverse Animation"]})]}),s.jsx(Lu,{edge:t,updateEdge:e}),s.jsx(Eu,{edge:t,updateEdge:e})]})}function Fu({field:t,value:e,setValue:n}){return t.type!==X.RichTextEditor&&t.type!==X.CodeEditor&&t.type!==X.TextBox?null:s.jsxs(on,{title:t.label??"",description:t.type,footerCancel:!0,children:[t.type===X.RichTextEditor&&s.jsx("div",{className:"h-[60vh]!",children:s.jsx(gi,{className:"[&_.ql-editor]:h-[calc(60vh-2.5rem)]!",value:e??"",setValue:n})}),t.type===X.CodeEditor&&s.jsx("div",{className:"border-stock bg-card w-full overflow-hidden rounded-[0.75rem] border",children:s.jsx(Zs,{height:"60vh",value:typeof e=="string"?e:"",setValue:n})}),t.type===X.TextBox&&s.jsx(Ws,{value:typeof e=="string"?e:"",onChange:i=>n(i.target.value),className:"border-stock text-foreground bg-input h-[60vh] w-full resize-none rounded-[1rem] border p-4 text-sm leading-normal break-all",autoCorrect:"off",autoComplete:"off",autoCapitalize:"off"})]})}function Jn(){const{data:t,updateData:e}=Te(),n=y.useMemo(()=>zi(t?.componentFields??[],t?.componentFields??[]),[t]),[i,r]=ne(n);return s.jsx(s.Fragment,{children:t?.componentFields?.map(a=>s.jsx(Du,{field:a,value:i[a.componentFieldId],setValue:o=>{const c={...i,[a.componentFieldId]:o};r(c),e({...t,componentFields:ln(t?.componentFields??[],c)})},isVisible:a.hidden===!1,setIsVisible:o=>{e({...t,componentFields:t?.componentFields?.map(c=>c.componentFieldId===a.componentFieldId?{...c,hidden:!o}:c)})}},a.componentFieldId))})}function Du({field:t,value:e,setValue:n,isVisible:i,setIsVisible:r}){const[a,o]=y.useState(!1),[c,l]=y.useState(!1),{codeEditorWrapper:u}=pi(),{organizationId:m}=we();async function d(N){if(N.file instanceof File&&m){l(!0);const f=await Mi(m,N.file);l(!1),n({fileId:f});return}N.file instanceof File||n(N)}const h=y.useMemo(()=>!Rr.includes(t.type),[t.type]),x=t.type===X.RichTextEditor||t.type===X.CodeEditor||t.type===X.TextBox;return s.jsxs(s.Fragment,{children:[s.jsxs(ue,{label:t.label??"",visible:i,onChangeVisibility:r,isVisibilityDisabled:h,labelExtra:x?s.jsx(Q,{size:"icon",variant:"ghost",className:"size-6 text-[#828DA3] hover:text-[#F4F7FC]",onClick:()=>o(!0),children:s.jsx(xl,{className:"size-3"})}):null,children:[t.type===X.NumberInput&&s.jsx(ho,{value:e??"",onChange:n}),t.type===X.TextInput&&s.jsx(Fi,{value:e??"",onChange:n}),t.type===X.TextBox&&s.jsx(Di,{value:e??"",onChange:n}),t.type===X.URLInput&&s.jsx(go,{value:e??"",onChange:n}),t.type===X.FileUpload&&s.jsx(po,{file:e??null,onChange:d,isViewMode:c}),t.type===X.LinkOrFileUpload&&s.jsx(fo,{value:e??null,onChange:d,isViewMode:c}),t.type===X.DropdownSelect&&s.jsx(In,{options:Be(t.options),value:e??"",onChange:n}),t.type===X.RichTextEditor&&s.jsx(gi,{value:e??"",setValue:n}),t.type===X.CodeEditor&&s.jsx("div",{className:u,children:s.jsx(Zs,{value:e??"",setValue:n})}),t.type===X.KeyValueList&&s.jsx(xo,{value:e??[],onChange:n}),t.type===X.BooleanToggle&&s.jsx(In,{options:["Yes","No"],value:e?"Yes":"No",onChange:N=>n(N==="Yes")}),t.type===X.MultiSelect&&s.jsx(bo,{options:Be(t.options),value:e??[],onChange:n}),t.type===X.SearchSelect&&s.jsx(yo,{options:Be(t.options),value:e??"",onChange:n}),t.type===X.CheckboxGroup&&s.jsx(vo,{value:e??[],onChange:n,options:Be(t.options)}),t.type===X.TagInput&&s.jsx(jo,{value:e??[],onChange:n}),t.type===X.DatePicker&&s.jsx(wo,{value:e??null,onChange:n}),t.type===X.DateRangePicker&&s.jsx(No,{enableMinified:!0,value:e??null,onChange:n}),t.type===X.ColorPicker&&s.jsx(Re,{value:e??null,onChange:n}),t.type===X.Slider&&s.jsx(Co,{value:e??null,onChange:n})]},t.componentFieldId),x&&s.jsx(an,{open:a,onOpenChange:o,className:"[--width:72rem]",children:s.jsx(Fu,{field:t,value:e??"",setValue:n})})]})}function Ru(){const{data:t,updateData:e}=Te(),[n,i]=ne(t?.contentWidth??zr);return t?s.jsx(rt,{label:"Width",min:Or,max:Mr,step:2,value:n,onChange:r=>{i(r),e({contentWidth:r},!0)}}):null}function zu(){const{node:t,data:e,updateData:n}=Te(),[i,r]=ne(e?.technology??""),[a,o]=ne(e?.description??"");if(!e)return null;const c=e.c4Kind,l=c==="container"||c==="component";return s.jsxs(s.Fragment,{children:[t?.type==="c4"&&l&&s.jsx(ue,{label:"Technology",children:s.jsx(Fi,{value:i,placeholder:"e.g. React, Go, PostgreSQL",onChange:u=>{r(u),n({technology:u})}})}),s.jsx(ue,{label:"Description",children:s.jsx(Di,{value:a,placeholder:"What this element does",onChange:u=>{o(u),n({description:u})}})})]})}const Mu=["person","system","container","component","node"],Ou=[{id:"default",label:"Box"},{id:"db",label:"Database"},{id:"queue",label:"Pipe / Queue"},{id:"bucket",label:"Bucket"},{id:"folder",label:"Folder"},{id:"browser",label:"Web Browser"},{id:"terminal",label:"Terminal"},{id:"component",label:"Component (UML)"},{id:"ellipse",label:"Ellipse"}];function Bu(t,e){if(t==="node")return{fill:xt,stroke:xt};const n=e?`${t}External`:t;return de[n]??de.system}function _u(){const{data:t,updateData:e}=Te(),[n,i]=ne(t?.fill??""),[,r]=ne(t?.stroke??""),[a,o]=ne(t?.fontColor??"");if(!t)return null;function c(l,u){const m=Bu(l,u);return i(m.fill),r(m.stroke),{fill:m.fill,stroke:m.stroke}}return s.jsxs(s.Fragment,{children:[s.jsx(ue,{label:"Element Type",children:s.jsxs(_e,{value:t.c4Kind,onValueChange:l=>{const u=l;e({c4Kind:u,...c(u,t.isExternal??!1)})},children:[s.jsx(Pe,{className:"border-stock bg-input h-9 w-full rounded-md text-sm",children:s.jsx(He,{})}),s.jsx($e,{children:Mu.map(l=>s.jsx(Le,{value:l,children:ri[l]},l))})]})}),s.jsx(ue,{label:"Shape",children:s.jsxs(_e,{value:t.c4Shape??"default",onValueChange:l=>e({c4Shape:l}),children:[s.jsx(Pe,{className:"border-stock bg-input h-9 w-full rounded-md text-sm",children:s.jsx(He,{})}),s.jsx($e,{children:Ou.map(l=>s.jsx(Le,{value:l.id,children:l.label},l.id))})]})}),s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx(le,{className:"text-sm font-normal text-[#F4F7FC]",children:"External"}),s.jsx(rs,{checked:t.isExternal??!1,onCheckedChange:l=>{e({isExternal:l,...c(t.c4Kind,l)})}})]}),s.jsx(ue,{label:"Color",children:s.jsx(Re,{value:n,className:"border-stock border-1 border-solid",onChange:l=>{i(l),r(l),e({fill:l,stroke:l})}})}),s.jsx(ue,{label:"Text Color",children:s.jsx(Re,{value:a,className:"border-stock border-1 border-solid",onChange:l=>{o(l),e({fontColor:l})}})})]})}function cr({className:t,...e}){return s.jsx(So,{"data-slot":"switch",className:H("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",t),...e,children:s.jsx(ko,{"data-slot":"switch-thumb",className:H("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}function fs({data:t,onChange:e}){console.log(t);const n=Qs(t),[i,r]=Ve(t.borderStyle??""),[a,o]=Ve(t.borderWidth??""),[c,l]=Ve(t.borderColor??""),[u,m]=Ve(t.borderRadius??""),[d,h]=Ve(t.borderAnimationEnabled??!1);return s.jsxs(s.Fragment,{children:[s.jsx(ue,{label:"Border Style",children:s.jsxs(Xo,{type:"single",className:"border-stock w-full border",value:i,onValueChange:x=>{r(x),e({...n.current,borderStyle:x===n.current.borderStyle?"none":x,borderWidth:n.current.borderWidth??1,borderColor:n.current.borderColor??"#000000"})},children:[s.jsx(js,{value:"solid",className:"text-xs",children:"Solid"}),s.jsx(js,{value:"dashed",className:"text-xs",children:"Dashed"}),s.jsx(js,{value:"dotted",className:"text-xs",children:"Dotted"})]})}),s.jsx(ue,{label:"Border Color",children:s.jsx(Re,{value:c,className:"border-stock border-1 border-solid",onChange:x=>{l(x),e({...n.current,borderColor:x,borderWidth:n.current.borderWidth??1,borderStyle:n.current.borderStyle??"solid"})}})}),s.jsx(ue,{label:"Border Width",children:s.jsxs("div",{className:"flex w-full items-center gap-3",children:[s.jsx("div",{className:"flex-1",children:s.jsx(ms,{min:0,max:20,step:1,value:[Number.isNaN(Number(a))?0:Number(a)],onValueChange:([x])=>{o(x),e({...n.current,borderWidth:x,borderStyle:n.current.borderStyle??"solid",borderColor:n.current.borderColor??"#000000"})}})}),s.jsx("input",{type:"number",className:"border-stock text-paragraph !h-12 w-16 rounded-[0.5rem] border px-1 pl-3 text-center text-sm",value:Number.isNaN(a)?"":a??"",min:0,max:20,step:1,onChange:x=>{const N=Number(x.target.value);!Number.isNaN(N)&&N>=0&&(o(N),e({...n.current,borderWidth:N,borderStyle:n.current.borderStyle??"solid",borderColor:n.current.borderColor??"#000000"}))}})]})}),s.jsx(ue,{label:"Border Radius",children:s.jsxs("div",{className:"flex w-full items-center gap-3",children:[s.jsx("div",{className:"flex-1",children:s.jsx(ms,{min:0,max:50,step:1,value:[Number.isNaN(Number(u))?0:Number(u)],onValueChange:([x])=>{m(x),e({...n.current,borderRadius:x})}})}),s.jsx("input",{type:"number",className:"border-stock text-paragraph !h-12 w-16 rounded-[0.5rem] border px-1 pl-3 text-center text-sm",value:Number.isNaN(u)?"":u??"",min:0,max:50,step:1,onChange:x=>{const N=Number(x.target.value);!Number.isNaN(N)&&N>=0&&(m(N),e({...n.current,borderRadius:N}))}})]})}),s.jsx(ue,{label:"Border Animation",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-muted-foreground text-sm",children:d?"Enabled":"Disabled"}),s.jsx(cr,{checked:d??!1,onCheckedChange:x=>{h(x),e({...n.current,borderAnimationEnabled:x})}})]})})]})}function Pu(){const{data:t,updateData:e}=Te(),[n,i]=ne(String(t?.fill));return t?s.jsxs(s.Fragment,{children:[s.jsx(ue,{label:"Background Color",children:s.jsx(Re,{value:n=="transparent"?"":n,className:"border-stock border-1 border-solid",onChange:r=>{i(r),e({fill:r||"transparent"})}})}),s.jsx(fs,{data:{borderColor:t?.stroke??null,borderStyle:t?.strokeStyle??null,borderWidth:t?.strokeWidth??null,borderRadius:t?.borderRadius??null,borderAnimationEnabled:t?.borderAnimationEnabled??null},onChange:r=>{e({stroke:r.borderColor??void 0,strokeWidth:r.borderWidth??void 0,strokeStyle:r.borderStyle??void 0,borderRadius:r.borderRadius??void 0,borderAnimationEnabled:r.borderAnimationEnabled??void 0})}})]}):null}function Hu(){const{data:t,updateData:e}=Te(),[n,i]=ne(t?.fontSize||""),[r,a]=ne(t?.lineHeight??"");return t?s.jsxs(s.Fragment,{children:[s.jsx(rt,{min:0,max:100,step:1,label:"Font Size",value:Number(n),onChange:o=>{i(o),e({fontSize:o})}}),s.jsx(rt,{min:1,max:5,step:.1,label:"Line Height",value:Number(r),onChange:o=>{a(o),e({lineHeight:o})}}),s.jsx(fs,{data:{borderColor:t?.stroke??null,borderStyle:t?.strokeStyle??null,borderWidth:t?.strokeWidth??null,borderRadius:t?.borderRadius??null,borderAnimationEnabled:t?.borderAnimationEnabled??null},onChange:o=>{e({stroke:o.borderColor??void 0,strokeWidth:o.borderWidth??void 0,strokeStyle:o.borderStyle??void 0,borderRadius:o.borderRadius??void 0,borderAnimationEnabled:o.borderAnimationEnabled??void 0})}})]}):null}function $u(){const{data:t,updateData:e}=Te(),[n,i]=Ve(t?.style?.baseColor??"");return s.jsx(s.Fragment,{children:s.jsx(ue,{label:"Color",children:s.jsx(Re,{value:n,className:"border-stock border-1 border-solid",onChange:r=>{i(r),e({style:{...t?.style??{},baseColor:r}})}})})})}function wt({column:t,triggerRemove:e,triggerChanges:n,autoSave:i=!1,readOnly:r}){const a=Qs(t),[o,c]=y.useState(!1),[l,u]=Ve(t,[t.name,t.type,t.nullable,t.isPrimaryKey]);return y.useEffect(()=>{if(!i||!o)return;const m=a.current;if(l.name===m.name&&l.type===m.type&&l.nullable===m.nullable&&l.isPrimaryKey===m.isPrimaryKey)return;const d=setTimeout(()=>{n(l)},350);return()=>{clearTimeout(d)}},[i,o,a,l,n]),s.jsxs("div",{className:"border-stock bg-card space-y-2 rounded border p-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[l.isPrimaryKey&&s.jsx("span",{className:"text-xs font-semibold text-amber-600",title:"Primary Key",children:"PK"}),l.isForeignKey&&!l.isPrimaryKey&&s.jsx("span",{className:"text-xs font-semibold text-blue-600",title:"Foreign Key",children:"FK"}),s.jsx("span",{className:"truncate font-mono text-xs font-medium",children:l.name})]}),!r&&s.jsx(Q,{size:"sm",variant:"ghost",onClick:e,className:"text-muted-foreground h-5 w-5 p-0 hover:text-red-600",children:s.jsx(It,{className:"h-3 w-3"})})]}),o?s.jsxs("div",{className:"space-y-3 border-t pt-1",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(le,{className:"text-xs",children:"Column Name"}),s.jsx(Fe,{className:"bg-input !h-11 w-full rounded-[0.8rem] shadow-none",value:l.name,onChange:m=>u(d=>({...d,name:m.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(le,{className:"text-xs",children:"Data Type"}),s.jsx(Fe,{placeholder:"VARCHAR(255), INT, etc.",className:"bg-input !h-11 rounded-[0.8rem] font-mono text-xs shadow-none",value:l.type,onChange:m=>u(d=>({...d,type:m.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(le,{className:"text-xs",children:"Nullable"}),s.jsxs(_e,{value:l.nullable?"yes":"no",onValueChange:m=>u(d=>({...d,nullable:m==="yes"})),children:[s.jsx(Pe,{className:"bg-input !h-11 w-full rounded-[0.8rem] text-xs shadow-none",children:s.jsx(He,{})}),s.jsxs($e,{children:[s.jsx(Le,{value:"yes",children:"Yes (NULL)"}),s.jsx(Le,{value:"no",children:"No (NOT NULL)"})]})]})]}),s.jsx("div",{className:"space-y-2",children:s.jsx(Q,{size:"sm",variant:"outline",onClick:()=>u(m=>({...m,isPrimaryKey:!m.isPrimaryKey})),className:H("h-11 w-full flex-1 rounded-[0.8rem] bg-transparent text-xs shadow-none transition-all",l.isPrimaryKey&&"bg-destructive/10 text-destructive hover:bg-destructive/20 hover:text-destructive border-destructive/20"),children:l.isPrimaryKey?"Remove PK":"Set as PK"})}),s.jsx(Q,{size:"sm",className:"h-11 w-full rounded-[0.8rem] text-xs shadow-none",onClick:()=>{c(!1),n(l)},children:"Done"})]}):s.jsxs("div",{className:"flex items-center justify-between border-t pt-1 text-xs",children:[s.jsx("span",{className:"text-paragraph font-mono break-all",children:l.type}),!r&&s.jsx(Q,{size:"sm",variant:"ghost",className:"h-5 px-2 text-xs text-blue-600",onClick:()=>c(!0),children:"Edit"})]})]})}function dr({value:t,setValue:e}){return s.jsx("div",{className:"bg-card overflow-hidden rounded-md border",children:s.jsx(Br,{value:t,onChange:e,basicSetup:{lineNumbers:!0,foldGutter:!1,foldKeymap:!1,searchKeymap:!1}})})}function Wu(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function se(t){return Wu(t)?t:null}function De(t){return Array.isArray(t)?t:null}function J(t){return typeof t=="string"?t:null}function ts(t){return typeof t=="boolean"?t:null}function ei(t){const e=t.trim();return e?e.endsWith("[]")?{type:"array",itemType:e.slice(0,-2).trim()||"string"}:{type:e,itemType:null}:{type:"",itemType:null}}function ur({table:t,tableName:e,dataSource:n,mongoCollectionSource:i,setDataSource:r,readOnly:a}){const[o,c]=y.useState(null),l=y.useMemo(()=>n?.dialect==="mongodb"?i:n?.dialect==="dynamodb"?n.sourceContent:null,[n?.dialect,n?.sourceContent,i]),u=y.useMemo(()=>{if(n?.dialect!=="dynamodb")return[];const b=se(l);return b?(De(b.attributes)??[]).map(se).filter(S=>!!S).map((S,I)=>({id:J(S.id)??`${I}`,name:J(S.name)??"",type:J(S.type)??""})):[]},[l,n?.dialect]),m=y.useMemo(()=>{if(!l)return[];if(n?.dialect==="dynamodb"){const S=se(l);if(!S)return[];const C=(De(S.attributes)??[]).map(se).filter(R=>!!R),A=se(S.primaryKey),M=A?J(A.partitionKey)??"":"",T=A?J(A.sortKey)??"":"";return C.map((R,k)=>{const O=J(R.id)??`${k}`,F=J(R.name)??"",G=J(R.type)??"",ae=ts(R.required)??!1,me=G==="array"?J(R.itemType):null;return{id:O,name:F,type:G==="array"?me?`${me}[]`:"array":G,nullable:!ae,isPrimaryKey:M!==""&&F===M||T!==""&&F===T}})}const b=se(l);return b?(De(b.fields)??[]).map(se).filter(S=>!!S).map((S,I)=>{const C=J(S.id)??`${I}`,A=J(S.name)??"",M=J(S.type)??"",T=ts(S.required)??!1,R=M==="array"?J(S.itemType):null;return{id:C,name:A,type:M==="array"?R?`${R}[]`:"array":M,nullable:!T,isPrimaryKey:!1}}):[]},[l,n?.dialect]);function d(){if(!(!n||!l)){if(n.dialect==="dynamodb"){const b=se(l);if(!b)return;const p={id:W(),name:`new_field_${m.length+1}`,type:"string",required:!1},w=De(b.attributes)??[],S={...b,attributes:[...w,p]};try{const I=qe.parse(S);r({sourceContent:I,modifiedAt:Date.now()}),U.success("Column added")}catch{U.error("Invalid schema update")}return}if(n.dialect==="mongodb"){const b=se(l);if(!b)return;const p={id:W(),name:`new_field_${m.length+1}`,type:"string",required:!1};try{const w=De(b.fields)??[],S={...b,fields:[...w,p]},I=Oe.parse(n.sourceContent),C={...I,collections:I.collections.map(M=>M.id===J(S.id)?S:M)},A=Oe.parse(C);r({sourceContent:A,modifiedAt:Date.now()}),U.success("Column added")}catch{U.error("Invalid schema update")}return}}}function h(b){if(m.length<=1){U.error("Cannot remove the last column");return}if(!(!n||!l)){if(n.dialect==="dynamodb"){const p=se(l);if(!p)return;const w=se(p.primaryKey),S=w?J(w.partitionKey)??"":"",I=w?J(w.sortKey)??"":"";let C=null;const A=De(p.attributes)??[],M=[];for(let R=0;R<A.length;R++){const k=A[R],O=se(k);if(O&&J(O.id)===b){C=J(O.name);continue}M.push(k)}const T={...p,attributes:M,primaryKey:w?{...w,partitionKey:C&&S===C?"":S,sortKey:C&&I===C?"":I}:p.primaryKey};try{const R=qe.parse(T);r({sourceContent:R,modifiedAt:Date.now()}),U.success("Column removed")}catch{U.error("Invalid schema update")}return}if(n.dialect==="mongodb"){const p=se(l);if(!p)return;try{const w=De(p.fields)??[],S=[];for(let T=0;T<w.length;T++){const R=w[T],k=se(R);k&&J(k.id)===b||S.push(R)}const I={...p,fields:S},C=Oe.parse(n.sourceContent),A={...C,collections:C.collections.map(T=>T.id===J(I.id)?I:T)},M=Oe.parse(A);r({sourceContent:M,modifiedAt:Date.now()}),U.success("Column removed")}catch{U.error("Invalid schema update")}return}}}function x(b,p){if(!n||!l)return;if(n.dialect==="dynamodb"){const A=se(l);if(!A)return;const M=se(A.primaryKey),T=M?J(M.partitionKey)??"":"",R=M?J(M.sortKey)??"":"";let k="",O="";const F=De(A.attributes)??[],G=[];let ae=!1;for(let ye=0;ye<F.length;ye++){const L=F[ye],$=se(L);if(!$||J($.id)!==b){G.push(L);continue}ae=!0,k=J($.name)??"",O=p.name??k;const te=p.nullable??!(ts($.required)??!1),P=p.type?ei(p.type):null,D=J($.type)??"",q=D==="array"?J($.itemType):null,j=P?P.type:D,z=P&&P.type==="array"?P.itemType??q??"string":null,_={...$,name:O,required:!te,type:j};j==="array"?_.itemType=z??"string":(delete _.itemType,delete _.itemFields,delete _.fields),G.push(_)}if(!ae)return;const me=p.isPrimaryKey;let Y=T,Ne=R;me===!0&&(!Y||Y===k?Y=O:!Ne||Ne===k?Ne=O:Y=O),me===!1&&(Y===k&&(Y=""),Ne===k&&(Ne="")),p.name&&T===k&&(Y=O),p.name&&R===k&&(Ne=O);const ke={...A,attributes:G,primaryKey:M?{...M,partitionKey:Y,sortKey:Ne}:A.primaryKey};try{const ye=qe.parse(ke);r({sourceContent:ye,modifiedAt:Date.now()})}catch{U.error("Invalid schema update")}return}if(n.dialect!=="mongodb")return;const w=se(l);if(!w)return;const S=De(w.fields)??[],I=[];let C=!1;try{for(let k=0;k<S.length;k++){const O=S[k],F=se(O);if(!F||J(F.id)!==b){I.push(O);continue}C=!0;const G=J(F.name)??"",ae=p.name??G,me=p.nullable??!(ts(F.required)??!1),Y=p.type?ei(p.type):null,Ne=J(F.type)??"",ke=Ne==="array"?J(F.itemType):null,ye=Y?Y.type:Ne,L=Y&&Y.type==="array"?Y.itemType??ke??"string":null,$={...F,name:ae,required:!me,type:ye};ye==="array"?$.itemType=L??"string":(delete $.itemType,delete $.itemFields),ye!=="object"&&delete $.fields,I.push($)}if(!C)return;const A={...w,fields:I},M=Oe.parse(n.sourceContent),T={...M,collections:M.collections.map(k=>k.id===J(A.id)?A:k)},R=Oe.parse(T);r({sourceContent:R,modifiedAt:Date.now()})}catch{U.error("Invalid schema update")}}function N(b){if(n?.dialect!=="dynamodb")return;const p=se(l);if(!p)return;const w=se(p.primaryKey);if(!w)return;const S={...p,primaryKey:{...w,...b}};try{const I=qe.parse(S);r({sourceContent:I,modifiedAt:Date.now()})}catch{U.error("Invalid schema update")}}function f(){if(n?.dialect!=="dynamodb")return;const b=se(l);if(!b)return;const p=De(b.globalSecondaryIndexes)??[],w=u.find(C=>C.name.trim()!==""),S={id:W(),name:`gsi_${p.length+1}`,partitionKey:w?.name??""},I={...b,globalSecondaryIndexes:[...p,S]};try{const C=qe.parse(I);r({sourceContent:C,modifiedAt:Date.now()}),U.success("GSI added")}catch{U.error("Invalid schema update")}}function g(b){if(n?.dialect!=="dynamodb")return;const p=se(l);if(!p)return;const w=De(p.globalSecondaryIndexes)??[],S=[];for(let C=0;C<w.length;C++){const A=w[C],M=se(A);M&&J(M.id)===b||S.push(A)}const I={...p,globalSecondaryIndexes:S};try{const C=qe.parse(I);r({sourceContent:C,modifiedAt:Date.now()}),U.success("GSI removed")}catch{U.error("Invalid schema update")}}function v(b,p){if(n?.dialect!=="dynamodb")return;const w=se(l);if(!w)return;const S=De(w.globalSecondaryIndexes)??[],I=[];let C=!1;for(let M=0;M<S.length;M++){const T=S[M],R=se(T);if(!R||J(R.id)!==b){I.push(T);continue}C=!0,I.push({...R,...p})}if(!C)return;const A={...w,globalSecondaryIndexes:I};try{const M=qe.parse(A);r({sourceContent:M,modifiedAt:Date.now()})}catch{U.error("Invalid schema update")}}return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(le,{className:"text-xs",children:n?.dialect==="dynamodb"?"Table Name":"Collection Name"}),s.jsx(Fe,{className:"!h-11 rounded-[0.8rem] shadow-none",value:t?.name??"",readOnly:a,onChange:b=>{const p=b.target.value;if(!n||!l)return;const w={...n.schemaAst,tables:n.schemaAst.tables.map(S=>S.name===e?{...S,name:p}:S)};if(n.dialect==="dynamodb"){const S=se(l);if(!S)return;const I={...S,name:p};try{const C=qe.parse(I);r({sourceContent:C,schemaAst:w,modifiedAt:Date.now()})}catch{U.error("Invalid schema update")}return}try{const S=se(l);if(!S)return;const I={...S,name:p},C=Oe.parse(n.sourceContent),A={...C,collections:C.collections.map(T=>T.id===J(I.id)?I:T)},M=Oe.parse(A);r({sourceContent:M,schemaAst:w,modifiedAt:Date.now()})}catch{U.error("Invalid schema update")}}})]}),n?.dialect==="dynamodb"&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(le,{className:"text-xs",children:"Partition Key (PK)"}),s.jsx(wt,{column:{name:J(se(se(l)?.primaryKey)?.partitionKey)??"",type:J(se(se(l)?.primaryKey)?.partitionKeyType)??"",nullable:!1,isPrimaryKey:!0,isForeignKey:!1},readOnly:a,triggerRemove:()=>N({partitionKey:""}),triggerChanges:b=>N({partitionKey:b.name,partitionKeyType:b.type})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(le,{className:"text-xs",children:"Sort Key (SK)"}),s.jsx(wt,{column:{name:J(se(se(l)?.primaryKey)?.sortKey)??"",type:J(se(se(l)?.primaryKey)?.sortKeyType)??"",nullable:!1,isPrimaryKey:!1,isForeignKey:!1},readOnly:a,triggerRemove:()=>N({sortKey:""}),triggerChanges:b=>N({sortKey:b.name,sortKeyType:b.type})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs(le,{className:"text-xs font-medium",children:["GSI (",De(se(l)?.globalSecondaryIndexes)?.length??0,")"]}),!a&&s.jsxs(Q,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs",onClick:f,children:[s.jsx(mt,{className:"mr-1 h-3 w-3"}),"Add"]})]}),s.jsx("div",{className:"space-y-2",children:(De(se(l)?.globalSecondaryIndexes)??[]).map(se).filter(b=>!!b).map((b,p)=>{const w=J(b.id)??`${p}`,S=J(b.name)??"",I=J(b.partitionKey)??"",C=J(b.sortKey)??"",A=J(b.partitionKeyType)??"",M=J(b.sortKeyType)??"",T=o===w;return s.jsxs("div",{className:"border-stock bg-card space-y-2 rounded border p-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("button",{type:"button",className:"min-w-0 flex-1 truncate text-left font-mono text-xs font-medium",onClick:()=>c(R=>R===w?null:w),children:S||`gsi_${p+1}`}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(Q,{size:"sm",variant:"ghost",className:"text-paragraph h-5 w-5 p-0",onClick:()=>c(R=>R===w?null:w),children:s.jsx(nt,{className:`h-3 w-3 transition-transform ${T?"rotate-180":""}`})}),!a&&s.jsx(Q,{size:"sm",variant:"ghost",onClick:()=>g(w),className:"text-muted-foreground h-5 w-5 p-0 hover:text-red-600",children:s.jsx(It,{className:"h-3 w-3"})})]})]}),T?s.jsxs("div",{className:"space-y-3 border-t pt-1",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(le,{className:"text-xs",children:"Index Name"}),s.jsx(Fe,{className:"bg-input !h-11 w-full rounded-[0.8rem] shadow-none",value:S,readOnly:a,onChange:R=>v(w,{name:R.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(le,{className:"text-xs",children:"GSI Partition Key (PK)"}),s.jsx(wt,{column:{name:I,type:A,nullable:!1,isPrimaryKey:!0,isForeignKey:!1},readOnly:a,triggerRemove:()=>v(w,{partitionKey:"",partitionKeyType:""}),triggerChanges:R=>v(w,{partitionKey:R.name,partitionKeyType:R.type})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(le,{className:"text-xs",children:"GSI Sort Key (SK)"}),s.jsx(wt,{column:{name:C,type:M,nullable:!1,isPrimaryKey:!1,isForeignKey:!1},readOnly:a,triggerRemove:()=>v(w,{sortKey:"",sortKeyType:""}),triggerChanges:R=>v(w,{sortKey:R.name,sortKeyType:R.type})})]})]}):null]},w)})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs(le,{className:"text-xs font-medium",children:[n?.dialect==="dynamodb"?"Attributes":"Columns"," (",m.length,")"]}),!a&&s.jsxs(Q,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs",onClick:d,children:[s.jsx(mt,{className:"mr-1 h-3 w-3"}),"Add"]})]}),s.jsx("div",{className:"space-y-2",children:m.map(b=>s.jsx(wt,{column:{name:b.name,type:b.type,nullable:b.nullable,isPrimaryKey:!1,isForeignKey:!1},readOnly:a,triggerRemove:()=>h(b.id),triggerChanges:p=>x(b.id,p)},b.id))})]})]})}function Gu(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function zs(t){return Gu(t)?t:null}function qu(t){return Array.isArray(t)?t:null}function Uu(t){return typeof t=="string"?t:null}function Vu({databaseName:t,tableName:e}){const n=fi(t,e),[i,r]=y.useState(!1);return s.jsxs("div",{className:"relative",children:[s.jsxs("div",{className:H("bg-card flex items-center justify-between gap-2 pt-2 pb-3",i&&"sticky top-0 z-50"),children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Qe,{className:"h-4 w-4 text-blue-600"}),s.jsx("h3",{className:"text-xs font-semibold",children:n.dataSource?.dialect==="dynamodb"?"DynamoDB Table":n.dataSource?.dialect==="mongodb"?"MongoDB Collection":"JSON File"})]}),s.jsx(Q,{preset:i?"primary":"outline",onClick:()=>r(a=>!a),className:H("size-9 border-none! px-3!",!i&&"bg-accent/60 hover:bg-accent"),children:s.jsx(Ht,{className:"size-5"})})]}),i?s.jsx(dr,{value:n.dataSource?.dialect==="dynamodb"?JSON.stringify(n.dataSource?.sourceContent,null,2):JSON.stringify(n.mongoCollectionSource,null,2),setValue:a=>{if(!n.dataSource)return;const o=a.trim();if(!o)return;let c;try{c=JSON.parse(o)}catch{return}if(n.dataSource.dialect==="dynamodb"){try{const l=qe.parse(c);n.setDataSource({sourceContent:l,modifiedAt:Date.now()})}catch{return}return}if(n.dataSource.dialect==="mongodb"){if(!n.mongoCollectionSource)return;const l=Oe.safeParse(n.dataSource.sourceContent);if(!l.success)return;const u={...l.data,collections:l.data.collections.map(m=>m.id===n.mongoCollectionSource?.id?c:m)};try{const m=Oe.parse(u);n.setDataSource({sourceContent:m,modifiedAt:Date.now()})}catch{return}return}if(n.dataSource.dialect==="json"){const l=zs(n.dataSource.sourceContent);if(!l)return;const u=qu(l.collections);if(!u)return;const m=u.length>0?u[0]:null;if(!(m&&zs(m)?Uu(zs(m)?.id):null))return;const h={...l,collections:[c,...u.slice(1)]};try{const x=Bs.parse(h);n.setDataSource({sourceContent:x,modifiedAt:Date.now()})}catch{return}}}}):s.jsx(ur,{tableName:e,...n})]})}function Ku(){const{data:t}=Te();return t?.localTable?s.jsx(Xu,{}):t?.serviceTable?s.jsx(Yu,{}):null}function Xu(){const{data:t}=Te(),{setDataSources:e,setNodes:n}=we(),{table:i,dataSource:r,setTable:a}=fi(t?.localTable.databaseName,t?.localTable.tableName),[o,c]=ne(i??null);if(!o)return null;if(r?.dialect==="mongodb"||r?.dialect==="dynamodb"||r?.dialect==="json")return s.jsx(Vu,{databaseName:t?.localTable.databaseName,tableName:t?.localTable.tableName});const u=o.constraints.find(f=>f.type==="primary_key")?.columns??[],m=o.constraints.filter(f=>f.type==="foreign_key");function d(){const f={type:"column",name:`new_column_${(o?.columns?.length??0)+1}`,dataType:{name:"VARCHAR",parameters:[255]},nullable:!0},g={...o,columns:[...o?.columns??[],f]};a(g),c(v=>v?{...v,...g}:null),U.success("Column added")}function h(f){if(!o)return;if((o?.columns?.length??0)<=1){U.error("Cannot remove the last column");return}const g=(o?.columns??[]).filter(p=>p.name!==f),v=(o?.constraints??[]).filter(p=>!("columns"in p&&p.columns.includes(f))),b={...o,columns:g,constraints:v};c(p=>p?{...p,...b}:null),a(b),U.success("Column removed")}function x(f,g){if(!o)return;const v=o?.columns?.find(A=>A.name===f);if(!v)return;const b=g.name??v.name;let p=v.dataType;if(g.type){const A=g.type.split("("),M=A[0],T=A[1]?.replace(")","").split(",").map(R=>{const k=R.trim(),O=Number(k);return Number.isNaN(O)?k:O})??[];p={name:M,parameters:T}}const w=(o?.columns??[]).map(A=>A.name===f?{...A,name:b,dataType:p,nullable:g.nullable??A.nullable}:A),S=g.isPrimaryKey??u.includes(f),I=(o?.constraints??[]).map(A=>{if(A.type==="primary_key"){const M=A.columns.filter(T=>T!==f);return S&&!M.includes(b)&&M.push(b),M.length?{...A,columns:M}:null}return A.type==="foreign_key"?{...A,columns:A.columns.map(M=>M===f?b:M)}:A}).filter(A=>!!A),C={...o,columns:w,constraints:I};c(A=>A?{...A,...C}:null),a(C)}function N(f){if(!o||!r||f==="")return;if(r.schemaAst.tables.some(b=>b.name===f)){U.error(`A table named "${f}" already exists`);return}const g=r.name,v=o.name;c({...o,name:f}),e(b=>b.map(p=>p.name===g?{...p,schemaAst:{...p.schemaAst,tables:p.schemaAst.tables.map(w=>({...w,name:w.name===v?f:w.name,constraints:w.constraints.map(S=>S.type==="foreign_key"&&S.referencedTable===v?{...S,referencedTable:f}:S)}))}}:p)),n(b=>b.map(p=>{const w=p.data.localTable;return p.type!=="databaseTableSQL"||w?.databaseName!==g||w.tableName!==v?p:{...p,data:{...p.data,localTable:{...w,tableName:f}}}}))}return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Qe,{className:"h-4 w-4 text-blue-600"}),s.jsx("h3",{className:"text-sm font-semibold",children:"Database Table"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(le,{className:"text-xs",children:"Table Name"}),s.jsx(Fe,{className:"!h-11 rounded-[0.8rem] shadow-none",value:o.name,onChange:f=>N(f.target.value)})]})]}),s.jsx(St,{}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs(le,{className:"text-xs font-semibold",children:["Columns (",o.columns.length,")"]}),s.jsxs(Q,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs",onClick:d,children:[s.jsx(mt,{className:"mr-1 h-3 w-3"}),"Add"]})]}),s.jsx("div",{className:"space-y-2",children:o.columns.map(f=>{const g=u.includes(f.name),v=m.some(b=>b.columns.includes(f.name));return s.jsx(wt,{column:{name:f.name,type:f.dataType.name,nullable:f.nullable,isPrimaryKey:g,isForeignKey:v},triggerRemove:()=>h(f.name),triggerChanges:b=>x(f.name,b)},f.name)})})]}),u.length>0&&s.jsxs(s.Fragment,{children:[s.jsx(St,{}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(le,{className:"text-xs font-semibold",children:"Primary Keys"}),s.jsx("div",{className:"flex flex-wrap gap-1",children:u.map(f=>s.jsx("span",{className:"inline-flex items-center rounded bg-amber-500/15 px-2 py-0.5 font-mono text-xs text-amber-400",children:f},f))})]})]}),m.length>0&&s.jsxs(s.Fragment,{children:[s.jsx(St,{}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(le,{className:"text-xs font-semibold",children:"Foreign Keys"}),s.jsx("div",{className:"space-y-1",children:m.flatMap((f,g)=>f.columns.map((v,b)=>s.jsxs("div",{className:"rounded bg-blue-500/10 px-2 py-1 text-xs",children:[s.jsx("span",{className:"font-mono text-blue-400",children:v}),s.jsx("span",{className:"text-muted-foreground",children:" → "}),s.jsxs("span",{className:"font-mono text-blue-400",children:[f.referencedTable,".",f.referencedColumns[b]??f.referencedColumns[0]]})]},`${g}-${b}`)))})]})]})]})}function Yu(){const{data:t}=Te(),e=t?.serviceTable,[n,i]=y.useState(!1),{serviceDb:r,loading:a}=_r(e?.serviceName,e?.databaseName),o=y.useMemo(()=>{if(!r?.noSQLSchema)return null;try{const u=typeof r.noSQLSchema=="string"?JSON.parse(r.noSQLSchema):r.noSQLSchema;return r.dialect==="dynamodb"?u?.dynamo?.table??null:r.dialect==="mongodb"?u?.mongo?.collections??null:null}catch{return null}},[r?.noSQLSchema,r?.dialect]),c=y.useMemo(()=>r?.tables?.find(m=>m?.name===e?.tableName)?.columns?.map(m=>({name:m?.name??"",type:m?.type??"unknown"}))??[],[r,e?.tableName]),l=s.jsxs("div",{className:"rounded border border-red-500/20 bg-red-500/10 p-2 text-xs text-red-400",children:[s.jsx("strong",{className:"font-semibold",children:"Note:"})," This is a remote source and you cannot edit it directly. To edit it, use the service database data source editor in the service details panel."]});if(a)return s.jsxs("div",{className:"text-paragraph flex h-full flex-col items-center justify-center gap-4 py-12",children:[s.jsx(sl,{size:"xs"}),"Loading table..."]});if((r?.dialect==="dynamodb"||r?.dialect==="mongodb")&&o){const u=r.dialect==="mongodb"?(Array.isArray(o?.collections)?o.collections:Array.isArray(o)?o:null)?.find(x=>x.name===e?.tableName)??null:null,m=r.dialect==="dynamodb"?"DynamoDB Table":"MongoDB Collection",d=r.dialect==="dynamodb"?JSON.stringify(o,null,2):JSON.stringify(u,null,2);return s.jsxs("div",{className:"relative",children:[s.jsxs("div",{className:H("bg-card flex items-center justify-between gap-2 pt-2 pb-3",n&&"sticky top-0 z-50"),children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Qe,{className:"h-4 w-4 text-blue-600"}),s.jsx("h3",{className:"text-xs font-semibold",children:m})]}),s.jsx(Q,{preset:n?"primary":"outline",onClick:()=>i(h=>!h),className:H("size-9 border-none! px-3!",!n&&"bg-accent/60 hover:bg-accent"),children:s.jsx(Ht,{className:"size-5"})})]}),n?s.jsx(dr,{value:d??"",setValue:()=>{}}):s.jsxs("div",{className:"space-y-3",children:[s.jsx(ur,{table:{name:e?.tableName??""},tableName:e?.tableName??"",dataSource:{id:r?.serviceDBId??"",name:e?.tableName??"",sourceType:"manual",sourceContent:o,dialect:r.dialect,schemaAst:{tables:[],dialect:r.dialect},createdAt:0,modifiedAt:null},mongoCollectionSource:u,setDataSource:()=>{},setTable:()=>{},readOnly:!0}),s.jsx(St,{}),l]})]})}return s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(le,{className:"text-xs font-semibold",children:"Columns"}),c.length?s.jsx("div",{className:"space-y-1",children:c.map(u=>s.jsxs("div",{className:"bg-accent/40 text-foreground flex items-center justify-between rounded px-3 py-1 text-xs",children:[s.jsx("span",{className:"font-mono",children:u.name}),s.jsx("span",{className:"text-paragraph",children:u.type})]},u.name))}):s.jsx("p",{className:"text-muted-foreground text-center text-xs",children:"No column information is available."})]}),s.jsx(St,{}),l]})}function Qu(){const{data:t,updateData:e}=Te(),[n,i]=ne(t?.backgroundColor??""),[r,a]=ne(t?.borderColor??"");return t?s.jsxs(s.Fragment,{children:[s.jsx(ue,{label:"Background Color",children:s.jsx(Re,{value:n=="transparent"?"":n,className:"border-stock border-1 border-solid",onChange:o=>{i(o),e({backgroundColor:o||"transparent"})}})}),s.jsx(ue,{label:"Border Color",children:s.jsx(Re,{value:r,className:"border-stock border-1 border-solid",onChange:o=>{a(o),e({borderColor:o})}})}),s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx(le,{className:"text-sm font-normal text-[#F4F7FC]",children:"Hide Details"}),s.jsx(rs,{checked:t.collapsed??!1,onCheckedChange:o=>{e({collapsed:o})}})]}),s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx(le,{className:"text-sm font-normal text-[#F4F7FC]",children:"Auto Layout"}),s.jsx(rs,{disabled:t.collapsed??!1,checked:t.autoLayout??!1,onCheckedChange:o=>{e({autoLayout:o})}})]})]}):null}const Zu=8,Ju=40;function em(){const{nodes:t,setNodes:e}=we(),{data:n,updateData:i}=Te(),[r,a]=Ve(n?.color??di),[o,c]=Ve(n?.textColor??""),u=t.find(d=>d.type==="sequenceParticipant")?.data?.titleFontSize??Pr;function m(d){e(h=>h.map(x=>x.type!=="sequenceParticipant"?x:{...x,data:{...x.data,titleFontSize:d}}))}return s.jsxs(s.Fragment,{children:[s.jsx(ue,{label:"Color",children:s.jsx(Re,{value:r,className:"border-stock border-1 border-solid",onChange:d=>{a(d),i({color:d})}})}),s.jsx(ue,{label:"Text Color",children:s.jsx(Re,{value:o,className:"border-stock border-1 border-solid",onChange:d=>{c(d),i({textColor:d})}})}),s.jsxs("div",{className:"-mx-4 space-y-3 border-t border-[#2A3242] px-4 pt-4",children:[s.jsx("p",{className:"text-xs font-normal text-[#828DA3]",children:"Global Styling"}),s.jsx(rt,{min:Zu,max:Ju,step:1,label:"Participant Font Size",value:u,onChange:m})]})]})}function tm(){const{data:t,node:e,updateData:n,updateNode:i}=Te(),[r,a]=ne(String(t?.fill||"")),[o,c]=ne(String(t?.shape||"rectangle")),[l,u]=ne(String(e?.width??e?.measured?.width??"")),[m,d]=ne(String(e?.height??e?.measured?.height??"")),[h,x]=ne(t?.strokeOpacity||null),[N,f]=ne(t?.textColor||""),[g,v]=ne(t?.textFontSize||"");return t?s.jsxs(s.Fragment,{children:[s.jsx(rt,{min:0,max:100,step:1,label:"Text Font Size",value:Number(g),onChange:b=>{v(b),n({textFontSize:b})}}),s.jsx(ue,{label:"Text Color",children:s.jsx(Re,{value:N,className:"border-stock border-1 border-solid",onChange:b=>{f(b),n({textColor:b})}})}),s.jsx(ue,{label:"Shape",children:s.jsxs(_e,{value:o,onValueChange:b=>{c(b),n({shape:b})},children:[s.jsx(Pe,{className:"border-stock text-paragraph !h-12 w-full rounded-[0.5rem] border px-4 text-sm",children:s.jsx(He,{placeholder:"Select Shape"})}),s.jsx($e,{children:hi.map(({id:b,label:p})=>s.jsx(Le,{value:b,children:p},b))})]})}),s.jsx(ue,{label:"Background Color",children:s.jsx(Re,{value:r=="transparent"?"":r,className:"border-stock border-1 border-solid",onChange:b=>{a(b),n({fill:b||"transparent"})}})}),s.jsx(ue,{label:"Width (px)",children:s.jsx("input",{type:"number",className:"border-stock text-paragraph !h-12 w-full rounded-[0.5rem] border px-4 text-sm",value:l,min:20,step:2,onChange:b=>{const p=b.target.value;u(p);const w=Number(p);!Number.isNaN(w)&&w>0&&i({width:w},!0)}})}),s.jsx(ue,{label:"Height (px)",children:s.jsx("input",{type:"number",className:"border-stock text-paragraph !h-12 w-full rounded-[0.5rem] border px-4 text-sm",value:m,min:20,step:2,onChange:b=>{const p=b.target.value;d(p);const w=Number(p);!Number.isNaN(w)&&w>0&&i({height:w},!0)}})}),s.jsx(fs,{data:{borderColor:t?.stroke??null,borderStyle:t?.strokeStyle??null,borderWidth:t?.strokeWidth??null,borderRadius:t?.cornerRadius??null,borderAnimationEnabled:t?.strokeAnimation==="dash"},onChange:b=>{n({stroke:b.borderColor??void 0,strokeWidth:b.borderWidth??void 0,strokeStyle:b.borderStyle??void 0,cornerRadius:b.borderRadius??void 0,strokeAnimation:b.borderAnimationEnabled?"dash":"none"})}}),s.jsx(ue,{label:"Border Transparency",children:s.jsx(hs,{min:0,max:1,step:.1,value:Number.isNaN(Number(h))?1:Number(h),onChange:b=>{x(b),n({strokeOpacity:b})}})})]}):null}function sm(){const{data:t,updateData:e}=Te(),{openChildDiagram:n}=we();return t?s.jsxs(s.Fragment,{children:[t.diagramId&&s.jsxs(s.Fragment,{children:[s.jsxs(Q,{type:"button",className:"h-9 w-full min-w-0 rounded-md text-sm",onClick:()=>n(t.diagramId),children:[s.jsx(Qa,{className:"size-3.5 shrink-0"}),s.jsx("span",{className:"truncate",children:"Open"})]}),s.jsxs(Q,{type:"button",variant:"secondary",className:"h-9 w-full min-w-0 rounded-md text-sm",onClick:()=>li(t.diagramId),children:[s.jsx(Ii,{className:"size-3.5 shrink-0"}),s.jsx("span",{className:"truncate",children:"Open in new tab"})]})]}),s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"text-paragraph text-sm",children:"Show thumbnail"}),s.jsx(cr,{checked:!t.hideThumbnail,onCheckedChange:i=>e({hideThumbnail:!i})})]}),s.jsx(ar,{selectedDiagramId:t.diagramId,onSelect:i=>e({diagramId:i.id,diagramName:i.name??"Untitled diagram"})})]}):null}const nm=[{value:"inherit",label:"Default"},{value:"Inter",label:"Inter"},{value:"Arial",label:"Arial"},{value:"Helvetica",label:"Helvetica"},{value:"Georgia",label:"Georgia"},{value:"Times New Roman",label:"Times New Roman"},{value:"Courier New",label:"Courier New"},{value:"Verdana",label:"Verdana"},{value:"Comic Sans MS",label:"Comic Sans MS"},{value:"Trebuchet MS",label:"Trebuchet MS"}],im=[{value:100,label:"Thin"},{value:200,label:"Extra Light"},{value:300,label:"Light"},{value:400,label:"Regular"},{value:500,label:"Medium"},{value:600,label:"Semi Bold"},{value:700,label:"Bold"},{value:800,label:"Extra Bold"},{value:900,label:"Black"}];function rm(){const{data:t,updateData:e}=Te(),{select:n}=pi(),[i,r]=ne(String(t?.fill)),[a,o]=ne(t?.fontSize||""),[c,l]=ne(t?.fontWeight||""),[u,m]=ne(t?.color||""),[d,h]=ne(t?.fontFamily||""),[x,N]=ne(t?.lineHeight??"");return t?s.jsxs(s.Fragment,{children:[s.jsx(ue,{label:"Text Color",children:s.jsx(Re,{value:u,className:"border-stock border-1 border-solid",onChange:f=>{m(f||""),e({color:f||void 0})}})}),s.jsx(rt,{min:0,max:100,step:1,label:"Font Size",value:Number(a),onChange:f=>{o(f),e({fontSize:f})}}),s.jsx(rt,{min:1,max:5,step:.1,label:"Line Height",value:Number(x),onChange:f=>{N(f),e({lineHeight:f})}}),s.jsx(ue,{label:"Font Weight",children:s.jsxs(_e,{value:String(c),onValueChange:f=>{const g=Number(f);l(g||""),e({fontWeight:g||void 0})},children:[s.jsx(Pe,{className:n,children:s.jsx(He,{})}),s.jsx($e,{children:im.map(f=>s.jsx(Le,{value:String(f.value),children:f.label},f.value))})]})}),s.jsx(ue,{label:"Font Family",children:s.jsxs(_e,{value:d,onValueChange:f=>{h(f||""),e({fontFamily:f||void 0})},children:[s.jsx(Pe,{className:n,children:s.jsx(He,{})}),s.jsx($e,{children:nm.map(f=>s.jsx(Le,{value:f.value,children:f.label},f.value))})]})}),s.jsx(ue,{label:"Background Color",children:s.jsx(Re,{value:i=="transparent"?"":i,className:"border-stock border-1 border-solid",onChange:f=>{r(f||""),e({fill:f||"transparent"})}})}),s.jsx(fs,{data:{borderColor:t?.stroke??null,borderStyle:t?.strokeStyle??null,borderWidth:t?.strokeWidth??null,borderRadius:t?.borderRadius??null,borderAnimationEnabled:t?.borderAnimationEnabled??null},onChange:f=>{e({stroke:f.borderColor??void 0,strokeWidth:f.borderWidth??void 0,strokeStyle:f.borderStyle??void 0,borderRadius:f.borderRadius??void 0,borderAnimationEnabled:f.borderAnimationEnabled??void 0})}})]}):null}function ti({className:t,children:e,...n}){const i=y.useRef(null),r=y.useRef(null),[a,o]=y.useState(),[c,l]=y.useState();return y.useEffect(()=>{const u=i.current;if(!u)return;const m=r.current;if(!m)return;const d=new ResizeObserver(()=>{l(m.clientHeight),o(u.clientHeight)});return l(m.clientHeight),o(u.clientHeight),d.observe(m),d.observe(u),()=>d.disconnect()},[r]),s.jsx("div",{ref:r,className:"relative isolate",children:s.jsx("div",{className:"pointer-events-auto absolute inset-0 h-fit max-h-full rounded-b-[0.75rem] border border-t-0 border-[#2A3242] bg-[#141925]",children:s.jsx(Ei,{className:"[&>div>div]:!block",style:{height:Math.min(a??0,c??0)},children:s.jsx("div",{...n,ref:i,className:H("w-[14.875rem] space-y-4 p-4 pt-2",t),children:s.jsx(Hr,{theme:"modal",children:s.jsx(Mt,{children:e})})})})})})}const si="h-8 w-full rounded-[0.5rem] border border-[#2A3242] bg-transparent px-3 text-sm text-[#F4F7FC] placeholder:text-[#828DA3] focus:outline-none",am="h-7 w-full rounded-[0.5rem] border border-[#2A3242] bg-transparent px-2 text-xs text-[#F4F7FC] placeholder:text-[#828DA3] focus:outline-none";function om(){const{data:t,updateData:e}=Te(),[n,i]=Ve(t),r=$r(n?.componentFields,{componentFieldId:"name"});function a(f){i(g=>{const v={...g,...f};return e(v),v})}const o=n?.columns&&n.columns.length?n.columns:ui,l=(n?.rows&&n.rows.length?n.rows:mi).map(f=>o.map((g,v)=>f?.[v]??""));function u(f,g){const v=o.map((b,p)=>p===f?g:b);a({columns:v})}function m(f,g,v){const b=l.map((p,w)=>p.map((S,I)=>w===f&&I===g?v:S));a({rows:b})}function d(){const f=[...l,o.map(()=>"")];a({rows:f})}function h(){const f=[...o,`Column ${o.length+1}`],g=l.map(v=>[...v,""]);a({columns:f,rows:g})}function x(f){if(l.length<=1)return;const g=l.filter((v,b)=>b!==f);a({rows:g})}function N(f){if(o.length<=1)return;const g=o.filter((b,p)=>p!==f),v=l.map(b=>b.filter((p,w)=>w!==f));a({columns:g,rows:v})}return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(le,{className:"text-xs text-[#828DA3]",children:"Table name"}),s.jsx(Fe,{value:r??"",onChange:f=>{const g=n?.componentFields??t?.componentFields??[],b=g.some(p=>p?.componentFieldId==="name")?g:[...g,{componentFieldId:"name",type:X.TextInput,label:"Name",isReadonly:!1,data:[{value:""}]}];a({componentFields:ln(b,{name:f.target.value})})},className:si})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(le,{className:"text-xs font-semibold text-[#F4F7FC]",children:"Columns"}),s.jsx("span",{className:"text-[11px] text-[#828DA3]",children:o.length})]}),s.jsx("div",{className:"space-y-1.5",children:o.map((f,g)=>s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(Fe,{value:f,onChange:v=>u(g,v.target.value),className:`${si} flex-1 text-xs`}),s.jsx(Q,{size:"icon",preset:"ghost",className:"size-7 text-[#828DA3] hover:text-[#F4F7FC]",disabled:o.length<=1,onClick:()=>N(g),children:s.jsx(It,{className:"h-3.5 w-3.5"})})]},`column-${g}`))}),s.jsxs(Q,{preset:"outline",className:"h-8 w-full",onClick:h,children:[s.jsx(mt,{className:"mr-1 h-3 w-3"}),"Add column"]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(le,{className:"text-xs font-semibold text-[#F4F7FC]",children:"Rows"}),s.jsx("span",{className:"text-[11px] text-[#828DA3]",children:l.length})]}),s.jsx("div",{className:"space-y-2",children:l.map((f,g)=>s.jsxs("div",{className:"rounded-xl border border-[#2A3242] bg-[#1E2533] p-2",children:[s.jsxs("div",{className:"mb-1 flex items-center justify-between text-[11px] text-[#828DA3]",children:[s.jsxs("span",{children:["Row ",g+1]}),s.jsx(Q,{size:"icon",preset:"ghost",className:"size-6 text-[#828DA3] hover:text-[#F4F7FC]",disabled:l.length<=1,onClick:()=>x(g),children:s.jsx(It,{className:"h-3 w-3"})})]}),s.jsx("div",{className:"space-y-1",children:o.map((v,b)=>s.jsx(Fe,{value:f[b]??"",placeholder:v||`Column ${b+1}`,onChange:p=>m(g,b,p.target.value),className:am},`cell-${g}-${b}`))})]},`row-${g}`))}),s.jsxs(Q,{preset:"outline",className:"h-8 w-full",onClick:d,children:[s.jsx(mt,{className:"mr-1 h-3 w-3"}),"Add row"]})]})]})}function lm(){const{data:t,updateData:e}=Te(),[n,i]=Ve(t);function r(a){i(o=>{const c={...o,...a};return e(c),c})}return s.jsx(s.Fragment,{children:s.jsx(rt,{label:"Border Radius",min:0,max:100,step:1,value:n?.borderRadius??8,onChange:a=>r({borderRadius:a})})})}const cm=220,dm=640,um=238,ni="pointer-events-auto flex h-14 items-center justify-between rounded-t-[0.75rem] border border-[#2A3242] bg-[#141925] px-4 py-3";function ii({active:t,onClick:e,children:n}){return s.jsx("button",{type:"button",onClick:e,className:H("h-8 rounded-[0.375rem] px-3 text-sm font-normal transition-colors",t?"bg-[#141925] text-[#F4F7FC] shadow-sm":"text-[#828DA3] hover:text-[#F4F7FC]"),children:n})}function mm(){const[t,e]=y.useState(!1),[n,i]=y.useState("data"),[r,a]=y.useState(um),o=y.useRef(!1),c=y.useRef(0);y.useEffect(()=>{function g(b){o.current&&a(Math.min(dm,Math.max(cm,c.current-b.clientX)))}function v(){o.current&&(o.current=!1,document.body.style.userSelect="",document.body.style.cursor="")}return window.addEventListener("pointermove",g),window.addEventListener("pointerup",v),()=>{window.removeEventListener("pointermove",g),window.removeEventListener("pointerup",v),document.body.style.userSelect="",document.body.style.cursor=""}},[]);function l(g){g.preventDefault(),o.current=!0,c.current=g.currentTarget.parentElement?.getBoundingClientRect().right??0,document.body.style.userSelect="none",document.body.style.cursor="ew-resize"}const{setSelectedNodeIds:u,setSelectedEdgeIds:m}=we(),{node:d,updateData:h}=Te(),{edge:x}=lr();function N(){u([])}function f(){m([])}return s.jsxs(s.Fragment,{children:[s.jsx(it,{children:d&&d.type!=="comment"?s.jsxs(ze.div,{initial:{opacity:0,x:16,scale:.95},animate:{opacity:1,x:0,scale:1},exit:{opacity:0,x:16,scale:.95},transition:{duration:.1,ease:"easeOut"},className:"pointer-events-none absolute inset-4 left-auto grid max-h-full w-[14.875rem] grid-rows-[auto_1fr]",style:{width:r},children:[s.jsxs("header",{className:ni,children:[s.jsxs("div",{className:"flex items-center rounded-md border border-[#2A3242] bg-[#1E2533] p-0.5",children:[s.jsx(ii,{active:n==="data",onClick:()=>i("data"),children:"Data"}),s.jsx(ii,{active:n==="style",onClick:()=>i("style"),children:"Style"})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{className:"flex size-[1.375rem] items-center justify-center rounded-sm bg-transparent text-[#828DA3] transition-all hover:bg-[#1E2533] hover:text-[#F4F7FC]",onClick:()=>e(!0),children:s.jsx(Za,{})}),s.jsx(gs,{onClick:N,className:"size-[1.375rem] rounded-sm"})]})]}),s.jsxs(ti,{className:"w-full",children:[s.jsx("button",{type:"button","aria-label":"Resize properties panel",onPointerDown:l,className:"before:bg-stock/30 hover:before:bg-paragraph/60 pointer-events-auto absolute top-0 -bottom-2 -left-1 z-20 w-2 cursor-ew-resize bg-transparent before:absolute before:inset-y-0 before:left-1/2 before:w-px before:-translate-x-1/2 before:transition-all"}),n==="data"&&s.jsx(s.Fragment,{children:d.type==="databaseTableSQL"?s.jsx(Ku,{}):d.type==="table"?s.jsx(om,{}):d.type==="subDiagram"?s.jsx(sm,{}):d.type==="c4"||d.type==="c4Boundary"?s.jsxs(s.Fragment,{children:[s.jsx(Jn,{}),s.jsx(zu,{})]}):s.jsx(Jn,{})}),n==="style"&&s.jsx(s.Fragment,{children:d.type==="cloud"?s.jsx(Pu,{}):d.type==="c4"?s.jsx(_u,{}):d.type==="group"||d.type==="c4Boundary"?s.jsx(Qu,{}):d.type==="shape"||d.type==="default"?s.jsx(tm,{}):d.type==="databaseTableSQL"?s.jsx($u,{}):d.type==="table"?s.jsx(lm,{}):d.type==="text"?s.jsx(rm,{}):d.type==="code"?s.jsx(Hu,{}):d.type==="builder"?s.jsx(Ru,{}):d.type==="sequenceParticipant"?s.jsx(em,{}):s.jsx("p",{className:"text-foreground/70 text-sm",children:"No style available"})})]})]}):x?s.jsxs(ze.div,{initial:{opacity:0,y:16,scale:.75},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:16,scale:.75},transition:{duration:.18,ease:"easeOut"},className:"pointer-events-none absolute inset-4 left-auto grid max-h-full grid-rows-[auto_1fr]",style:{width:r},children:[s.jsxs("header",{className:ni,children:[s.jsx("h3",{className:"text-sm font-bold text-[#F4F7FC]",children:"Edge Properties"}),s.jsx("button",{onClick:f,className:"hover:bg-destructive flex size-[1.375rem] items-center justify-center rounded-md bg-[#1E2533] text-sm text-[#828DA3] transition-all hover:text-white",children:s.jsx(Fc,{})})]}),s.jsxs(ti,{className:"w-full",children:[s.jsx("button",{type:"button","aria-label":"Resize properties panel",onPointerDown:l,className:"before:bg-stock/30 hover:before:bg-paragraph/60 pointer-events-auto absolute top-0 -bottom-2 -left-1 z-20 w-2 cursor-ew-resize bg-transparent before:absolute before:inset-y-0 before:left-1/2 before:w-px before:-translate-x-1/2 before:transition-all"}),s.jsx(Au,{})]})]}):null}),s.jsx(Iu,{open:t,onOpenChange:e,initialComponentFields:d?.data.componentFields??[],onSubmit:async g=>{h({...d?.data,componentFields:g}),e(!1)}})]})}function hm({children:t}){const{viewport:e,diagramName:n,setDiagramName:i,isPreviewing:r,isEmbedded:a,isFullscreen:o,triggerMetaUpdate:c}=we(),l=xi(d=>d.user?.isServerAdmin);y.useEffect(()=>{if(!a)return;window.__uigraphEmbedSave=async()=>{await c(!0)};function d(h){h.key==="Escape"&&window.parent.__uigraphEmbedClose?.()}return window.addEventListener("keydown",d,{capture:!0}),()=>{delete window.__uigraphEmbedSave,window.removeEventListener("keydown",d,{capture:!0})}},[a,c]);const u=e?.zoom??1,m=y.useRef(null);return y.useEffect(()=>{if(!m.current)return;function h(x){x.key!=="Escape"||x.target?.closest('[role="dialog"],[role="menu"],[role="listbox"],[data-radix-popper-content-wrapper]')||document.querySelector('[role="dialog"][data-state="open"]')||(x.stopPropagation(),x.stopImmediatePropagation())}return document.addEventListener("keydown",h,{capture:!0}),()=>{document.removeEventListener("keydown",h,{capture:!0})}},[m]),s.jsxs("section",{ref:m,className:"bg-shading flex h-screen flex-1 flex-col select-none",children:[s.jsx("style",{children:`:root { --react-flow-scale: ${u}; --react-flow-counter-scale: ${Wr(u)} }`}),!a&&!o&&s.jsxs("header",{className:"bg-shading flex h-[5rem] items-center justify-between rounded-[1.2rem] px-6 py-4",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsxs(Tl,{children:[s.jsx(El,{hidden:!0,asChild:!0,children:s.jsx(Q,{size:"icon",variant:"ghost",children:s.jsx(Ja,{className:"text-foreground/40 size-8"})})}),s.jsxs(Dl,{side:"left",className:"!max-w-xs gap-0",showCloseButton:!1,children:[s.jsx(zl,{className:"hidden",children:"Navigation"}),s.jsx(Ml,{className:"hidden",children:"Select an action to perform"}),s.jsxs(Rl,{className:"flex flex-row items-start justify-between",children:[s.jsx(ss,{to:"/dashboard",children:s.jsx(Hs,{})}),s.jsx(Ll,{asChild:!0,children:s.jsx(gs,{})})]}),s.jsx("div",{className:"p-3",children:eo.filter(d=>!d.serverAdminOnly||l).map(d=>{const h=s.jsxs(ss,{to:d.disabled?"":d.id,className:H("flex items-center justify-start gap-2 rounded-[0.75rem] p-1 px-2 transition-all",d.disabled?"text-paragraph cursor-not-allowed":"hover:bg-accent cursor-pointer"),children:[s.jsx("span",{className:H("flex size-10 items-center justify-center bg-transparent text-2xl transition-all *:transition-all"),children:d.icon}),s.jsx("span",{className:"block text-center text-sm",children:d.label})]});return s.jsxs("li",{className:"relative block select-none",children:[h,typeof d.disabled=="string"&&s.jsx("p",{className:"absolute inset-0 flex cursor-not-allowed items-center justify-center rounded-[0.75rem] bg-black/10 text-center text-sm opacity-0 backdrop-blur-xs transition-all hover:opacity-100",children:d.disabled})]},d.id)})})]})]}),s.jsx(ss,{to:"/dashboard",className:"rounded-full",children:s.jsx(Hs,{className:"size-11 max-w-none"})}),s.jsx(Fe,{value:n,placeholder:"Enter diagram name",onChange:d=>i(d.target.value),className:"placeholder:text-foreground/20 h-auto rounded-[0.5rem] px-2.5 py-1.5 !text-[1.25rem] font-medium shadow-none placeholder:text-lg placeholder:font-medium"})]}),Gr.VITE_FEATURE_DIAGRAM_IMPORT_EXPORT&&s.jsx(Ec,{}),s.jsx(to,{})]}),s.jsx("div",{className:"relative isolate h-full flex-1",children:s.jsxs("div",{className:H("absolute isolate overflow-hidden","inset-4 top-2 rounded-[0.75rem] border border-[#2A3242]",a&&"inset-0 rounded-none border-none",o&&"inset-0 rounded-none border-none"),children:[t,s.jsx(ld,{}),s.jsx(md,{}),s.jsxs("div",{className:"group/left-controls pointer-events-none absolute inset-0",children:[!a&&o&&s.jsx("div",{className:"pointer-events-auto absolute top-4 bottom-0 left-0 w-10",children:s.jsx("div",{className:"pointer-events-none absolute top-1/2 left-0 flex h-14 w-5 -translate-y-1/2 items-center justify-center rounded-r-[0.375rem] border border-l-0 border-[#2A3242] bg-[#141925] transition-opacity duration-200 group-hover/left-controls:opacity-0",children:s.jsx(ct,{className:"size-3.5 text-[#828DA3]"})})}),s.jsx(hd,{}),!r&&s.jsx(Su,{})]}),!r&&s.jsx(mm,{}),!r&&s.jsx(ud,{}),s.jsx(Ac,{}),s.jsx(jc,{})]})})]})}function Eh({embedded:t}){const e=Js(),{diagramId:n}=pa(),{data:i,loading:r}=ut(la,{errorPolicy:"ignore",fetchPolicy:"cache-first",skip:!e.id,variables:{orgId:e.id,id:String(n)}}),a=y.useMemo(()=>ca(i?.diagram?.content??void 0),[i?.diagram?.content]),o=y.useMemo(()=>i?.diagram?.updatedAt??void 0,[i?.diagram?.updatedAt]);return r?s.jsx(Kr,{}):s.jsx(qr,{diagramId:n,isEmbedded:t,organizationId:e.id,folderId:i?.diagram?.folderId??null,teamId:i?.diagram?.teamId??null,initialData:a,initialInfo:{name:i?.diagram?.name??void 0,lastUpdatedAt:o},children:s.jsx(Ur,{children:s.jsx(ia,{children:s.jsx(hm,{children:s.jsx(Vr,{forceAutoFitView:!0})})})})})}export{Eh as DiagramPortalPage};
|