collabmd 0.1.46 → 0.1.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -5
- package/dist/client/assets/{CodeMirrorEditor-UCMRAMCV-CYM5nxUi.js → CodeMirrorEditor-UCMRAMCV-BPH4FJkv.js} +1 -1
- package/dist/client/assets/JetBrainsMono-Regular-BQaDgvhP.woff2 +0 -0
- package/dist/client/assets/{abnfDiagram-N423BO3Z-CUMTFJhI.js → abnfDiagram-VCTEODGH-BNDLzJ7L.js} +1 -1
- package/dist/client/assets/architecture-7GRP2DOG-BMOPAkUC.js +1 -0
- package/dist/client/assets/{architectureDiagram-T3A2C74G-w25m71oV.js → architectureDiagram-5GKGNRK7-I39sYjHI.js} +1 -1
- package/dist/client/assets/babel-CY5KOv-I.js +16 -0
- package/dist/client/assets/base-BYODPHdS.js +1 -0
- package/dist/client/assets/blockDiagram-NRAW4CY4-C6DtJy5Y.js +129 -0
- package/dist/client/assets/browser-BKLM0ThC-IxjwuOIz-BBqQnUEb.js +1 -0
- package/dist/client/assets/c4Diagram-UCG6FXSJ-CtWtxS9_.js +38 -0
- package/dist/client/assets/channel-CaoKA_We.js +1 -0
- package/dist/client/assets/{chunk-U6XO7XAA-BFxjP5U3.js → chunk-2ZTRR5NV-C2qZJila.js} +1 -1
- package/dist/client/assets/{chunk-YOTPTUD7-D0vRKqYp.js → chunk-3Z5EZCMW-DMniOlPd.js} +1 -1
- package/dist/client/assets/{chunk-BIQX33UG-DZEsGuSn.js → chunk-5V3GS4D5-i-ZDOEnP.js} +1 -1
- package/dist/client/assets/{chunk-MOZMSUNE-XVucA-n6.js → chunk-6AZGARVD-BB6FqMl-.js} +1 -1
- package/dist/client/assets/{chunk-5JV3BV7I-Cy5pj3QY.js → chunk-6EIED4P4-DdUJkP0f.js} +1 -1
- package/dist/client/assets/{chunk-R7FJI6CG-Cnn3gE-Y.js → chunk-6K3QC6MW-CqVsVn-y.js} +1 -1
- package/dist/client/assets/{chunk-OSBZ3O6U-CrKZOUOr.js → chunk-6TQVIW2G-DKlLbNIP.js} +1 -1
- package/dist/client/assets/{chunk-JG7HCLWE-BYfiSaVt.js → chunk-747NJXEK-BFkZPlab.js} +1 -1
- package/dist/client/assets/{chunk-NSK5VX7P-TLH37VXI.js → chunk-75Z2AOVW-CdFSaPjz.js} +1 -1
- package/dist/client/assets/chunk-CKBBP62Z-DG26UiBv.js +2 -0
- package/dist/client/assets/{chunk-3NCLNEKW-Y2Jf_LI-.js → chunk-CLGD4ZFX-DQLgbQrv.js} +1 -1
- package/dist/client/assets/chunk-DSNCTWBM-8xkug7fQ.js +2 -0
- package/dist/client/assets/chunk-DU6HZSFF-COXDzJK1.js +127 -0
- package/dist/client/assets/{chunk-2GRJ4B5K-DhnlUv3F.js → chunk-F27PBJKO-CNHIFhjo.js} +1 -1
- package/dist/client/assets/{chunk-YGJVY4SA-CjSe7Bx7.js → chunk-FLYJHZSQ-Be7lKF17.js} +1 -1
- package/dist/client/assets/{chunk-KEIR6QF5-BICK3FdT.js → chunk-FOHPRMQF-DHwB1DNv.js} +2 -2
- package/dist/client/assets/{chunk-5RXB4S5H-BWrwFqMI.js → chunk-G27WJ6UU-D9-eg537.js} +2 -2
- package/dist/client/assets/chunk-GMAD6QVW-CbcBqPM5.js +72 -0
- package/dist/client/assets/{chunk-QBLGF6JB-CxAyS2mW.js → chunk-I5DQTOEV-Hm2LfiYI.js} +1 -1
- package/dist/client/assets/{chunk-5FCAYU7R-Dh5nylU8.js → chunk-ICYGCRZG-749o-pGJ.js} +1 -1
- package/dist/client/assets/{chunk-CQNSW5MT-B8S09OIh.js → chunk-IH6LHLGP-CC6I9F3i.js} +1 -1
- package/dist/client/assets/chunk-JQ64N6SF-DSFNH4bh.js +1 -0
- package/dist/client/assets/{chunk-CYSBUYHQ-C1Rf4art.js → chunk-KI3K4JFJ-Rma-0k_M.js} +1 -1
- package/dist/client/assets/{chunk-GF5L2VYU-DkJpO7ff.js → chunk-LCL6LL3I-DmDkVukh.js} +1 -1
- package/dist/client/assets/chunk-LNGE3PJU-DWpGwHrW.js +34 -0
- package/dist/client/assets/chunk-OBVCFTLP-BJR7u1jh.js +1 -0
- package/dist/client/assets/{chunk-5TONJI2A-DQOY3q1H.js → chunk-OUJLGHUK-D0j2JRSg.js} +1 -1
- package/dist/client/assets/chunk-P2QGCYS3-BRpqY32H.js +1 -0
- package/dist/client/assets/{chunk-KBJHAD2P-CB_3zWUf.js → chunk-POPQ4Y6H-Cb4SlVZF.js} +1 -1
- package/dist/client/assets/{chunk-4I5QYGJK-CCB2YcIH.js → chunk-PWAF6VOD-Cz8IwBB5.js} +1 -1
- package/dist/client/assets/chunk-R7TYR2AO-CTd0Yj98.js +10 -0
- package/dist/client/assets/chunk-RHFEMEQ7-CWY8cf4H.js +168 -0
- package/dist/client/assets/chunk-RM4UPSZO-CWRwxNWJ.js +41 -0
- package/dist/client/assets/{chunk-6Q2QTUOP-CPlWzBtc.js → chunk-SVP7TREG-CyHOmcac.js} +1 -1
- package/dist/client/assets/chunk-TEH6E4GO-DVayPj-q.js +62 -0
- package/dist/client/assets/{chunk-EMLP6XTP-RLD4nXpI.js → chunk-UY3FDG6J-CnmaAkG5.js} +1 -1
- package/dist/client/assets/{chunk-5HE753X5-Bw-yg4kO.js → chunk-XHIXRSVI-BFQ6B8BE.js} +1 -1
- package/dist/client/assets/classDiagram-DTDB5LWJ-7fEmn0zV.js +1 -0
- package/dist/client/assets/classDiagram-v2-JRS7N3AN-7fEmn0zV.js +1 -0
- package/dist/client/assets/comment-ui-shared-DuoyznXW.js +7 -0
- package/dist/client/assets/cynefin-OW5HDTMX-7tP7QfM3.js +1 -0
- package/dist/client/assets/{cynefinDiagram-MW4NZA55-CJxXfJek.js → cynefinDiagram-5FMLGOSQ-CdTPi2yO.js} +1 -1
- package/dist/client/assets/dagre-3AP2YEHR-5gtJtd0O.js +4 -0
- package/dist/client/assets/dagre-PrKaheQc.js +1 -0
- package/dist/client/assets/{diagram-7IWD3JNH-B2d2Bm15.js → diagram-S7CK7UJ4-BudWz9WU.js} +4 -4
- package/dist/client/assets/{diagram-UB23O5K3-DJcKCwv9.js → diagram-UQ7AKVKN-3v4rbH-s.js} +1 -1
- package/dist/client/assets/{diagram-B4RE2ZJO-NP4UAwjR.js → diagram-VSXAHHWV-CQRVEZR7.js} +1 -1
- package/dist/client/assets/{diagram-Q27KOJAE-DylDuwor.js → diagram-VX7I27RA-C_-rj0sw.js} +1 -1
- package/dist/client/assets/{diagram-LBJQPF4R-D1FJQV8t.js → diagram-Z3DM3KII-B4yxavgj.js} +1 -1
- package/dist/client/assets/direct-engine-DdrQKpgq-CtKfQzCt.js +5 -0
- package/dist/client/assets/dist-73RPdcyU.js +1 -0
- package/dist/client/assets/{dist-Bm6pf9Bl.js → dist-BJ1bJs33.js} +1 -1
- package/dist/client/assets/{dist-BalScOwZ.js → dist-BK9QvQrc.js} +1 -1
- package/dist/client/assets/{dist-DLMiIsNC.js → dist-BPHLJ09L.js} +1 -1
- package/dist/client/assets/{dist-Bf8f4HmM.js → dist-B_yQaEv_.js} +1 -1
- package/dist/client/assets/{dist-CC5IrQMG.js → dist-BeajGMhO.js} +1 -1
- package/dist/client/assets/{dist-PDZ3bSqm.js → dist-Bw3VIE_v.js} +1 -1
- package/dist/client/assets/{dist-xElaxbia.js → dist-ByrG2qBA.js} +1 -1
- package/dist/client/assets/{dist-ule2n6ak.js → dist-C5NgpdG5.js} +1 -1
- package/dist/client/assets/dist-CH-sQu3r.js +1 -0
- package/dist/client/assets/dist-CKS_-are.js +1 -0
- package/dist/client/assets/{dist-D-Z6FLem.js → dist-CdmKGRGr.js} +1 -1
- package/dist/client/assets/dist-ChRoo3IB.js +9 -0
- package/dist/client/assets/{dist-dtAdgL39.js → dist-CietwTVS.js} +1 -1
- package/dist/client/assets/{dist-jv4WdPnK.js → dist-D37Hyu3h.js} +1 -1
- package/dist/client/assets/dist-D3fehAZ2.js +2 -0
- package/dist/client/assets/{dist-BEwK4csK.js → dist-D5wCC32z.js} +1 -1
- package/dist/client/assets/{dist-shrl6K_0.js → dist-DDUn5zTz.js} +1 -1
- package/dist/client/assets/{dist-CZgOmxK6.js → dist-DGEbEfw4.js} +1 -1
- package/dist/client/assets/{dist-B5HTH2BO.js → dist-DVy5woUy.js} +1 -1
- package/dist/client/assets/{dist-DZKu9Cs8.js → dist-DZAAWTG-.js} +1 -1
- package/dist/client/assets/{dist-TjMh8n1u.js → dist-Dir5dDKZ.js} +1 -1
- package/dist/client/assets/dist-Dl_tpDSr.js +1 -0
- package/dist/client/assets/{dist-FWJsgGYI.js → dist-DuH3ZrHo.js} +1 -1
- package/dist/client/assets/{dist-BjHJDtyU.js → dist-DutPuFmC.js} +1 -1
- package/dist/client/assets/{dist-Cqhv5LAk.js → dist-LQ4kDCKz.js} +1 -1
- package/dist/client/assets/{dist-CCP_AKPG.js → dist-RKBTaQMb.js} +1 -1
- package/dist/client/assets/{dist-BoVBdSjk.js → dist-Tw-Fxpeb.js} +1 -1
- package/dist/client/assets/dist-eBx8q6Sy.js +1 -0
- package/dist/client/assets/{dist-rGBmqxC7.js → dist-mj2Ht75J.js} +1 -1
- package/dist/client/assets/{dist-BDt3rz7l.js → dist-netZOQtD.js} +1 -1
- package/dist/client/assets/document-formatter-Dxl_a8XO.js +2 -0
- package/dist/client/assets/{drawio-editor-FzY1cVw8.js → drawio-editor-BVaNNtYp.js} +2 -2
- package/dist/client/assets/{drawioEditor-BjiKJqlc.js → drawioEditor-BkIBlXx0.js} +2 -2
- package/dist/client/assets/{ebnfDiagram-BXEA7PRR-nw0wmA6y.js → ebnfDiagram-PWID7BFC-OXa8VEp1.js} +1 -1
- package/dist/client/assets/editor-session-DMyVdHLj.js +54 -0
- package/dist/client/assets/embedded-editor-base-B3l6Xy65.css +1 -0
- package/dist/client/assets/embedpdf-BmE13ZZ0.js +1 -0
- package/dist/client/assets/embedpdf-DA4bA119-BPqZxwjc.js +2363 -0
- package/dist/client/assets/{en-7NFCYGKX-BrgYZAEe.js → en-SJ2YIMFF-CJBL3nkq.js} +1 -1
- package/dist/client/assets/erDiagram-SSCWMZ5O-C-iy6VkX.js +99 -0
- package/dist/client/assets/estree-CuT_pB8K.js +44 -0
- package/dist/client/assets/eventmodeling-NTZA5JFV-BR2FzK4R.js +1 -0
- package/dist/client/assets/excalidraw-editor-BbSbI80a.css +1 -0
- package/dist/client/assets/excalidraw-editor-BjYaNEMY.js +9 -0
- package/dist/client/assets/excalidrawEditor-ChqF_d82.js +2 -0
- package/dist/client/assets/export-page-Dyu0XCbu.js +57 -0
- package/dist/client/assets/exportDocument-CJBx4Xjx.css +1 -0
- package/dist/client/assets/exportDocument-Dgvfa2Sd.js +2 -0
- package/dist/client/assets/{file-icon-svg-CQAjlWjK.js → file-icon-svg-Y_kpF957.js} +1 -1
- package/dist/client/assets/file-kind-BwMIcZbi.js +1 -0
- package/dist/client/assets/file-search-DDLyyLDU.js +1 -0
- package/dist/client/assets/flowDiagram-A5DVABFB-CiW1eN8C.js +1 -0
- package/dist/client/assets/{ganttDiagram-PKOTCBZU-BnM97BCT.js → ganttDiagram-EL5Y4UJY-DtKHAbez.js} +1 -1
- package/dist/client/assets/gitGraph-4MIJSDKK-DYlXv_yJ.js +1 -0
- package/dist/client/assets/{gitGraphDiagram-DS77QQ5N-BQpQhjuN.js → gitGraphDiagram-WWUBYQGX-oue8fQ5o.js} +1 -1
- package/dist/client/assets/github-dark.min-BV82VuKq.css +1 -0
- package/dist/client/assets/github.min-v3dd8CNH.css +1 -0
- package/dist/client/assets/html-Cdnr2qzU.js +25 -0
- package/dist/client/assets/image-ZVKINSPA-0zXSnE7M.js +1 -0
- package/dist/client/assets/index-CSNIMyOP.css +1 -0
- package/dist/client/assets/index-DG3N2Ps-.js +2 -0
- package/dist/client/assets/info-A6RAGUB7-BlU-8_xu.js +1 -0
- package/dist/client/assets/{infoDiagram-6WML65LV-DYB8HCDQ.js → infoDiagram-RXCK75RN-BMzo6KIn.js} +1 -1
- package/dist/client/assets/{ishikawaDiagram-WSZJBQD7-Coz_P3t6.js → ishikawaDiagram-5VMMS53U-BIM3h287.js} +1 -1
- package/dist/client/assets/{journeyDiagram-NVQOT4AX-B6edChce.js → journeyDiagram-EYS64GPL-mF6Lh8O-.js} +1 -1
- package/dist/client/assets/{kanban-definition-27J2QSJJ-BFd9-cLc.js → kanban-definition-3QL26DDD-DLN2NyoR.js} +2 -2
- package/dist/client/assets/{line-B_S_S8kV.js → line-BfTWJmgf.js} +1 -1
- package/dist/client/assets/main-D0wCxpVn.js +903 -0
- package/dist/client/assets/markdown-CByV-4CU.js +70 -0
- package/dist/client/assets/{mermaid-parser.core-CUVdebAV.js → mermaid-parser.core-Bl0efOMt.js} +2 -2
- package/dist/client/assets/mermaid.core-BJRLUQZE.js +11 -0
- package/dist/client/assets/{mindmap-definition-FAOFIHXS-C9PQ38Al.js → mindmap-definition-FBJOCRG2-CRyHaHTk.js} +1 -1
- package/dist/client/assets/packet-AYTQ26CC-BSJEH9Lb.js +1 -0
- package/dist/client/assets/pdfium-RAgkpwfK.wasm +0 -0
- package/dist/client/assets/{pegDiagram-VL7TDLO6-BMZUrSaU.js → pegDiagram-XKGWAZYB-B31fKPR2.js} +1 -1
- package/dist/client/assets/pie-WAS4IAKB-qxv01Y8W.js +1 -0
- package/dist/client/assets/{pieDiagram-7S7Q4E2Y-h8kbCL9o.js → pieDiagram-E7YTZNPT-B5OZPb88.js} +1 -1
- package/dist/client/assets/preview-render-compiler-CrJIooVD.js +35 -0
- package/dist/client/assets/preview-render-compiler-O0JxBVNF.js +1 -0
- package/dist/client/assets/{preview-render-profile-CE-5rVTC.js → preview-render-profile-B4RWYWHt.js} +1 -1
- package/dist/client/assets/preview-render-worker-_QTxqKvP.js +60 -0
- package/dist/client/assets/prod-BiYPMR1i.js +177 -0
- package/dist/client/assets/prod-VxdGZ5Ly.js +1 -0
- package/dist/client/assets/{quadrantDiagram-CIZ2JOQS-CkElyfMi.js → quadrantDiagram-AXDQQJYC-Drrw14YH.js} +1 -1
- package/dist/client/assets/quick-switcher-controller-CaEjEtq_.js +1 -0
- package/dist/client/assets/radar-RG4KPBEZ-B6h6pWOs.js +1 -0
- package/dist/client/assets/railroad-74A4TZTK-CGtTWdGc.js +1 -0
- package/dist/client/assets/railroad-abnf-HS5TGJTU-Cq7y22IA.js +1 -0
- package/dist/client/assets/railroad-ebnf-LZEXJU2U-V0aQVv9m.js +1 -0
- package/dist/client/assets/railroad-peg-WCYAUIDC-BQiIsX_p.js +1 -0
- package/dist/client/assets/{railroadDiagram-AXF67PYL-c75gnikD.js → railroadDiagram-O6MQD6OU-BPifP0MB.js} +1 -1
- package/dist/client/assets/{requirementDiagram-LRYGKXZP-mNxKLuHS.js → requirementDiagram-EFPCY7ZU-CRZG6mRB.js} +2 -2
- package/dist/client/assets/{sankeyDiagram-W5VNT64P-0OhplksI.js → sankeyDiagram-P5KCCOFB-DvarEJpo.js} +1 -1
- package/dist/client/assets/{sequenceDiagram-SI44F4Z6-BJ_yAocC.js → sequenceDiagram-WJ2MYXX4-B4oWlb-w.js} +1 -1
- package/dist/client/assets/standalone-6z5x8CWe.js +29 -0
- package/dist/client/assets/{stateDiagram-OKZ733FA-Cc83O86s.js → stateDiagram-HBIQ2CUA-qbHIIqRZ.js} +1 -1
- package/dist/client/assets/stateDiagram-v2-4QOOHH4V-B--gjrit.js +1 -0
- package/dist/client/assets/swimlanes-XN3QIQJK-xB6CtUGj.js +1 -0
- package/dist/client/assets/swimlanesDiagram-VK2B7HYN-DO8XNXEg.js +8 -0
- package/dist/client/assets/{timeline-definition-Z64GVDOM-BWDAGTHz.js → timeline-definition-24CTP7MA-Lj_yTNlY.js} +1 -1
- package/dist/client/assets/treeView-Q6P3EWNA-BTTYcvrF.js +1 -0
- package/dist/client/assets/treemap-WGGIJYW6-Cg7tyfH8.js +1 -0
- package/dist/client/assets/{vault-api-client-_LpV1aIn.js → vault-api-client-BkwdFjx0.js} +2 -2
- package/dist/client/assets/vault-utils-DvoSftJT.js +22 -0
- package/dist/client/assets/{vennDiagram-T6HMQDX7-LOSsnlMB.js → vennDiagram-4TSXK5OY-BekRp5Y0.js} +1 -1
- package/dist/client/assets/wardley-WFR3VGLG-C6N1rULY.js +1 -0
- package/dist/client/assets/{wardleyDiagram-T6FBY63Y-BxII3foY.js → wardleyDiagram-VM6X3IG4-kdnV_Hdm.js} +1 -1
- package/dist/client/assets/worker-engine-m0rlHn8R-S8mpn_O0.js +17369 -0
- package/dist/client/assets/{xychartDiagram-ELKLHX3M-B-pTEjju.js → xychartDiagram-S5SC5T6Z-DufGwNSB.js} +3 -3
- package/dist/client/assets/yaml-9ltHPDNO.js +154 -0
- package/dist/client/drawio-editor.html +1 -1
- package/dist/client/excalidraw-editor.html +1 -1
- package/dist/client/export-document.html +3 -3
- package/dist/client/index.html +56 -24
- package/package.json +22 -18
- package/src/client/app/index.html +53 -21
- package/src/client/application/app-shell/comments-feature.js +2 -3
- package/src/client/application/app-shell/export-feature.js +17 -1
- package/src/client/application/app-shell/git-feature.js +30 -11
- package/src/client/application/app-shell/presence-feature.js +2 -2
- package/src/client/application/app-shell/ui-feature-identity.js +13 -0
- package/src/client/application/app-shell/ui-feature-shell.js +228 -9
- package/src/client/application/app-shell-elements.js +5 -0
- package/src/client/application/pdf-preview-controller.js +53 -970
- package/src/client/application/preview-render-compiler.js +3 -0
- package/src/client/application/quick-switcher-loader.js +1 -1
- package/src/client/application/workspace-coordinator.js +21 -4
- package/src/client/application/workspace-preview-controller.js +120 -5
- package/src/client/application/workspace-route-controller.js +4 -1
- package/src/client/assets/vendor/highlight/github-dark.min.css +2 -10
- package/src/client/assets/vendor/highlight/github.min.css +2 -10
- package/src/client/assets/vendor/jetbrains-mono/JetBrainsMono-Regular.woff2 +0 -0
- package/src/client/assets/vendor/jetbrains-mono/OFL.txt +93 -0
- package/src/client/bootstrap/collabmd-app-shell.js +31 -8
- package/src/client/domain/document-formatter.js +193 -0
- package/src/client/domain/file-search.js +73 -0
- package/src/client/domain/git-labels.js +5 -0
- package/src/client/domain/vault-paths.js +6 -4
- package/src/client/domain/wiki-link-completions.js +20 -20
- package/src/client/drawio-editor.js +8 -3
- package/src/client/excalidraw-editor.js +163 -6
- package/src/client/export/export-host.js +57 -36
- package/src/client/export/export-page.js +20 -6
- package/src/client/export/export-pipeline.js +322 -22
- package/src/client/infrastructure/editor-session.js +4 -0
- package/src/client/infrastructure/editor-view-adapter.js +60 -14
- package/src/client/presentation/bases-preview-controller.js +35 -11
- package/src/client/presentation/comment-ui/comment-ui-render.js +4 -0
- package/src/client/presentation/comment-ui-controller.js +2 -0
- package/src/client/presentation/excalidraw-embed-controller.js +7 -0
- package/src/client/presentation/file-action-controller.js +15 -2
- package/src/client/presentation/file-explorer-controller.js +3 -5
- package/src/client/presentation/file-explorer-view.js +43 -45
- package/src/client/presentation/file-history-view-controller.js +6 -1
- package/src/client/presentation/file-tree-state.js +5 -14
- package/src/client/presentation/git-diff-view-controller.js +36 -11
- package/src/client/presentation/git-panel-controller.js +12 -8
- package/src/client/presentation/quick-switcher-controller.js +92 -153
- package/src/client/styles/components/scrollbars.css +10 -0
- package/src/client/styles/export-document.css +44 -29
- package/src/client/styles/features/collaboration-presence.css +13 -1
- package/src/client/styles/features/preview-markdown.css +79 -0
- package/src/client/styles/features/quick-switcher.css +8 -0
- package/src/client/styles/foundation/themes.css +1 -0
- package/src/client/styles/foundation/tokens.css +8 -0
- package/src/client/styles/layout/shell.css +73 -339
- package/src/client/styles/layout/sidebar.css +42 -4
- package/src/client/styles/layout/view-modes.css +2 -0
- package/src/client/styles/overrides/codemirror.css +31 -19
- package/src/client/styles/overrides/highlightjs.css +20 -4
- package/src/client/styles/surfaces/excalidraw-editor.css +42 -0
- package/src/domain/file-kind.js +12 -1
- package/src/server/domain/ripgrep-search-service.js +110 -37
- package/src/server/infrastructure/git/git-service.js +23 -11
- package/src/server/infrastructure/http/create-git-api-command-handler.js +3 -1
- package/src/server/infrastructure/http/create-structurizr-api-handler.js +4 -2
- package/src/server/infrastructure/persistence/path-utils.js +10 -4
- package/src/server/infrastructure/persistence/vault-file-store.js +2 -0
- package/src/server/infrastructure/structurizr/structurizr-workspace-service.js +33 -7
- package/dist/client/assets/architecture-TIHT7OUA-CsHfPErM.js +0 -1
- package/dist/client/assets/base-CxPEiHuy.js +0 -1
- package/dist/client/assets/blockDiagram-VBNYF7ZC-CipJt9Jl.js +0 -132
- package/dist/client/assets/c4Diagram-5PPSVZJV-B5ktVx6g.js +0 -10
- package/dist/client/assets/channel-4Jkmq93I.js +0 -1
- package/dist/client/assets/chunk-7BUUIJ7U-Bb538aSH.js +0 -1
- package/dist/client/assets/chunk-7Z6QIM7H-BP9Pdsm9.js +0 -10
- package/dist/client/assets/chunk-ERSWUTIN-hHdvnhaY.js +0 -41
- package/dist/client/assets/chunk-I66GZJ75-CVFiiffQ.js +0 -127
- package/dist/client/assets/chunk-J7OUQ5F2-4CEb7pvH.js +0 -2
- package/dist/client/assets/chunk-JQJVKLGR-cx8X_24v.js +0 -156
- package/dist/client/assets/chunk-QR6OTTB3-CDAA_5Ib.js +0 -62
- package/dist/client/assets/chunk-RYQCIY6F-D-a0zH8K.js +0 -1
- package/dist/client/assets/chunk-UBXNYLIW-Bhk-PbFK.js +0 -1
- package/dist/client/assets/chunk-W5SLKNZC-BdNSCxZ9.js +0 -1
- package/dist/client/assets/chunk-WRU74C26-h6_XkD3_.js +0 -70
- package/dist/client/assets/chunk-ZIRB5QZD-O39ZBUk3.js +0 -32
- package/dist/client/assets/classDiagram-JCYQIIEL-L7lsyW_w.js +0 -1
- package/dist/client/assets/classDiagram-v2-OCEON4UE-L7lsyW_w.js +0 -1
- package/dist/client/assets/comment-ui-shared-BC4pt4w8.js +0 -7
- package/dist/client/assets/cynefin-VYW2F7L2-Ds2Fw2Y0.js +0 -1
- package/dist/client/assets/dagre-Buvkdvvj.js +0 -1
- package/dist/client/assets/dagre-VZM6K2ZE-L1xArOGs.js +0 -4
- package/dist/client/assets/dist-B5Jf1SLZ.js +0 -2
- package/dist/client/assets/dist-BKW4PALF.js +0 -1
- package/dist/client/assets/dist-BWcHHOx-.js +0 -1
- package/dist/client/assets/dist-DaYdhcVs.js +0 -1
- package/dist/client/assets/dist-Kh2COra_.js +0 -1
- package/dist/client/assets/dist-tOaegDYS2.js +0 -1
- package/dist/client/assets/editor-session-Cm9ekeNo.js +0 -54
- package/dist/client/assets/embedded-editor-base-CwTkk911.css +0 -1
- package/dist/client/assets/erDiagram-JOGREHBK-cYUpEKpf.js +0 -85
- package/dist/client/assets/es-DXGV3RHd.js +0 -22
- package/dist/client/assets/eventmodeling-45OFAUF4-CLEiVx5s.js +0 -1
- package/dist/client/assets/excalidraw-editor-B46zsTFI.js +0 -9
- package/dist/client/assets/excalidraw-editor-Bt7gMSoh.css +0 -1
- package/dist/client/assets/excalidrawEditor-CT2pHq7e.js +0 -2
- package/dist/client/assets/export-page-A7NHawJY.js +0 -39
- package/dist/client/assets/exportDocument-B2L8fe34.css +0 -1
- package/dist/client/assets/exportDocument-BaqcOAAW.js +0 -2
- package/dist/client/assets/file-kind-BbqgGzpc.js +0 -1
- package/dist/client/assets/flowDiagram-UKHOOZJN-D0ypP0Ez.js +0 -1
- package/dist/client/assets/gitGraph-TEB2WS4Q-CZFBqwW-.js +0 -1
- package/dist/client/assets/github-dark.min-Z5exjX_n.css +0 -1
- package/dist/client/assets/github.min-D2BCvnWf.css +0 -1
- package/dist/client/assets/image-QXRYHUNP-SWEV8H0J.js +0 -1
- package/dist/client/assets/index-ClbjMBVt.js +0 -2
- package/dist/client/assets/index-Pum8ET-5.css +0 -1
- package/dist/client/assets/info-DKCQHKI2--1InqQeT.js +0 -1
- package/dist/client/assets/main-B3uPyqic.js +0 -893
- package/dist/client/assets/map-BaFkSB1l.js +0 -1
- package/dist/client/assets/mermaid.core-DN-lF51U.js +0 -11
- package/dist/client/assets/packet-7NZHBO7P-BGMXB0XL.js +0 -1
- package/dist/client/assets/pdf-BL9Pr2D5.js +0 -54
- package/dist/client/assets/pdf.worker-CLesOks4.mjs +0 -64857
- package/dist/client/assets/pdf_viewer-FVkkThnz.js +0 -551
- package/dist/client/assets/pie-RZYD4A2V-DgYg3tCt.js +0 -1
- package/dist/client/assets/preview-render-compiler-BD-XhkS2.js +0 -35
- package/dist/client/assets/preview-render-compiler-BKedaMxx.js +0 -1
- package/dist/client/assets/preview-render-worker-CiPqc9n6.js +0 -60
- package/dist/client/assets/prod-Dy20X7eT.js +0 -1
- package/dist/client/assets/prod-hnwh7wRM.js +0 -177
- package/dist/client/assets/quick-switcher-controller-fqOYR7qR.js +0 -12
- package/dist/client/assets/radar-I7S5WNFK-Ag-zp_Rq.js +0 -1
- package/dist/client/assets/railroad-3IZDKUUU-aibJDIDV.js +0 -1
- package/dist/client/assets/railroad-abnf-AHOZXSZD-BBMEuvIl.js +0 -1
- package/dist/client/assets/railroad-ebnf-EBAXGLYW-Be1nseej.js +0 -1
- package/dist/client/assets/railroad-peg-LSFZ7HO6-DIvD-Eyb.js +0 -1
- package/dist/client/assets/stateDiagram-v2-UEYNNEHI-B1-BufUk.js +0 -1
- package/dist/client/assets/swimlanes-SLNWSIFB-oVTWEJIj.js +0 -2
- package/dist/client/assets/swimlanesDiagram-ULZ7WXOC-C5OTVwEu.js +0 -8
- package/dist/client/assets/treeView-QDETBFTQ-uHZ-3Fz8.js +0 -1
- package/dist/client/assets/treemap-6X3UGDF4-BnUKyy3l.js +0 -1
- package/dist/client/assets/vault-utils-wdQ0RNR9.js +0 -1
- package/dist/client/assets/wardley-OPB4EBWU-Da7TLC2F.js +0 -1
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ar-SA-PQUY64WN-xjXgbW6d.js","./chunk-SRAX5OIU-KFQikY-4.js","./rolldown-runtime-Dd_uD5pT.js","./az-AZ-OXJXL76K-4JkO4Pca.js","./bg-BG-W2GKIJDF-DnkH_o81.js","./bn-BD-TGL7M4PJ-CG4JkmtP.js","./bn-IN-BKETKYEH-CG4JkmtP.js","./ca-ES-LD5SCRVV-U6_TVMX9.js","./cs-CZ-OFPU5DBV-BmFAIhqX.js","./da-DK-FRDJFYWF-H387Jw8B.js","./de-CH-ZG7H3QK3-C_groygo.js","./de-DE-SIJYH4IH-C_groygo.js","./el-GR-IEE2CGI2-BkT6YT54.js","./en-7NFCYGKX-BrgYZAEe.js","./chunk-YGJVY4SA-CjSe7Bx7.js","./es-ES-TVVPWKV5-CpPKJXTM.js","./eu-ES-CGBMFQDT-Bu3N2493.js","./fa-IR-IE6XAPR4-BEvLCORD.js","./fi-FI-P7TKNHRM-DI0q8iSX.js","./fr-FR-QI2XZNT7-y8kXd8LA.js","./gl-ES-TLYCNOZZ-Br-Fhff-.js","./he-IL-ZX43XLGP-qKQq6V9X.js","./hi-IN-UTYRMTUF-DOUcwrDO.js","./hu-HU-AJOSEBW6-FqTyvHlD.js","./id-ID-ETLTVG6C-CQqh3CLS.js","./it-IT-B4B6TP6L-V-yK3SZz.js","./ja-JP-IYKVURR5-BQKBXRpX.js","./kaa-SE2BUIKX-CZ5kfwPg.js","./kab-KAB-Y3GLKXLR-Do7GWfuN.js","./kk-KZ-ABWUFVOH-BpqVciQz.js","./km-KH-PCWDKPHP-DSmy5shj.js","./ko-KR-7JQDXKGM-N42lep78.js","./ku-TR-NAH2Q5B7-K8LLl9fk.js","./lt-LT-VQFYRSNQ-BmOd0ALn.js","./lv-LV-T62VSYUM-B22WdPhp.js","./mr-IN-V4FHLCJE-XX069tpm.js","./my-MM-E3SQ6E54-cst_-5SB.js","./nb-NO-MLNOFN5H-Bu2URWko.js","./nl-NL-D5L3ZV4M-BqrV0btt.js","./nn-NO-NNHDGPKB-DK-xZaWM.js","./oc-FR-DWCRF55G-BZ5Po5R6.js","./pa-IN-3JSAY44M-BZQSjKrS.js","./percentages-ETZPVQEE-DFxFqXgH.js","./chunk-7XWMRXBY-CfMzEq80.js","./pl-PL-ACURYKP3-qcEOSfCk.js","./pt-BR-LOX7MLGD-DLueHSyZ.js","./pt-PT-CZ2U2RFQ-BJ-GAEm6.js","./ro-RO-2HECL2X6-CJUvKAf0.js","./ru-RU-HAYNXO46-BWSlvTrt.js","./si-LK-W5KNS4H6-DGGCsn7k.js","./sk-SK-7K2CFGDV-CY4uTYgQ.js","./sl-SI-OXV2QZWW-2-weqaBY.js","./sv-SE-JTOBZRGL-9-IUtVkO.js","./ta-IN-KFAVKXGT-gHO6Q_DH.js","./th-TH-VDMSCPDL-BvJuw6PJ.js","./tr-TR-CEZ6GX45-CG6UU3Su.js","./uk-UA-Q3H3OXQC-CSuIg_DY.js","./uz-UZ-NGCSWWPX-mom7rxSP.js","./vi-VN-P3NDEVPS-BB0Fu9ck.js","./zh-CN-SS3O57GA-Bj8wsiMe.js","./zh-HK-LWJT3VCF-DOTquTCh.js","./zh-TW-VJXC72RT-B48PRo-l.js","./image-QXRYHUNP-SWEV8H0J.js","./chunk-ERSWUTIN-hHdvnhaY.js","./preload-helper-HclGiUj8.js","./CodeMirrorEditor-UCMRAMCV-CYM5nxUi.js","./dist-CCP_AKPG.js","./jsx-runtime-BpzPEenQ.js","./dist-xElaxbia.js","./excalidraw-mermaid-stub-DE5FTiZB.js","./excalidraw-mermaid-stub-BNckbX2n.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{i as e,t}from"./rolldown-runtime-Dd_uD5pT.js";import{t as n}from"./preload-helper-HclGiUj8.js";import{$a as r,$c as i,$i as a,$n as o,$o as s,$r as c,$s as l,$t as u,A as d,Aa as f,Ac as p,Ai as m,An as h,Ao as g,Ar as _,As as v,At as y,B as b,Ba as x,Bc as S,Bi as C,Bn as w,Bo as T,Br as E,Bs as D,Bt as O,Ca as ee,Cc as k,Ci as te,Cl as ne,Cn as re,Co as ie,Cr as ae,Ct as oe,Da as se,Dc as ce,Di as le,Dn as ue,Do as de,Dr as fe,Ds as pe,Dt as me,E as he,Ea as ge,Ec as _e,Ei as ve,En as ye,Eo as be,Er as xe,Es as Se,Et as Ce,F as we,Fa as Te,Fc as Ee,Fi as De,Fn as Oe,Fo as ke,Fr as Ae,Fs as je,Ft as Me,G as Ne,Ga as Pe,Gc as Fe,Gi as Ie,Gn as Le,Go as Re,Gr as ze,Gs as Be,Gt as Ve,H as He,Ha as Ue,Hc as We,Hi as Ge,Hn as Ke,Ho as qe,Hr as Je,Hs as Ye,Ht as Xe,I as Ze,Ia as Qe,Ic as $e,Ii as et,In as tt,Io as nt,Ir as rt,Is as it,It as at,J as ot,Ja as st,Jc as ct,Ji as lt,Jn as ut,Jo as dt,Jr as ft,Js as pt,Jt as mt,K as ht,Ka as gt,Kc as _t,Ki as vt,Kn as yt,Ko as bt,Kr as xt,Ks as St,Kt as Ct,L as wt,La as Tt,Lc as Et,Li as Dt,Ln as Ot,Lo as kt,Lr as At,Lt as jt,M as Mt,Ma as Nt,Mc as Pt,Mi as Ft,Mn as It,Mo as Lt,Mr as Rt,Ms as zt,Mt as Bt,N as Vt,Na as Ht,Nc as Ut,Ni as Wt,Nn as Gt,No as Kt,Nr as qt,Ns as Jt,Nt as Yt,O as Xt,Oa as Zt,Oc as A,Oi as Qt,On as $t,Oo as en,Or as tn,Os as nn,Ot as rn,P as an,Pa as on,Pc as sn,Pi as cn,Pn as ln,Po as un,Pr as dn,Ps as fn,Pt as pn,Q as mn,Qa as hn,Qc as gn,Qi as _n,Qn as vn,Qo as yn,Qr as bn,Qs as xn,Qt as Sn,R as Cn,Ra as wn,Rc as Tn,Ri as En,Rn as Dn,Ro as On,Rr as kn,Rs as An,Rt as jn,S as Mn,Sa as Nn,Sc as Pn,Si as Fn,Sl as In,Sn as Ln,So as Rn,Sr as zn,Ss as Bn,St as Vn,T as Hn,Ta as Un,Ti as Wn,Tn as Gn,To as Kn,Tr as qn,Ts as Jn,Tt as Yn,U as Xn,Ua as Zn,Uc as Qn,Ui as $n,Un as er,Uo as tr,Ur as nr,Us as rr,Ut as ir,V as ar,Va as or,Vc as sr,Vi as cr,Vn as lr,Vo as j,Vr as ur,Vs as dr,Vt as fr,W as pr,Wa as mr,Wc as hr,Wi as gr,Wn as _r,Wo as vr,Wr as yr,Ws as M,Wt as br,X as xr,Xa as Sr,Xc as Cr,Xi as wr,Xn as Tr,Xo as Er,Xr as Dr,Xs as Or,Xt as kr,Y as Ar,Ya as jr,Yc as Mr,Yi as Nr,Yn as N,Yo as Pr,Yr as Fr,Ys as Ir,Yt as Lr,Z as Rr,Za as zr,Zi as Br,Zn as Vr,Zo as Hr,Zr as Ur,Zs as Wr,Zt as Gr,_ as Kr,_a as qr,_c as Jr,_i as Yr,_l as Xr,_n as Zr,_o as Qr,_r as $r,_s as ei,_t as ti,a as ni,aa as ri,ac as ii,ai,al as oi,an as si,ao as ci,ar as li,as as ui,at as di,b as fi,ba as pi,bc as mi,bi as hi,bl as gi,bn as _i,bo as vi,br as yi,bs as bi,bt as xi,c as Si,ca as Ci,cc as wi,ci as Ti,cl as Ei,cn as P,co as Di,cr as Oi,cs as ki,ct as Ai,d as ji,da as Mi,dc as Ni,di as Pi,dl as Fi,dn as Ii,do as Li,dr as Ri,ds as zi,dt as Bi,ea as Vi,ec as Hi,ei as Ui,el as Wi,en as Gi,eo as Ki,es as qi,et as Ji,f as Yi,fa as Xi,fc as Zi,fi as Qi,fl as $i,fn as ea,fo as ta,fr as na,fs as ra,ft as ia,g as aa,ga as oa,gc as sa,gi as ca,gl as la,gn as ua,go as da,gr as fa,gs as pa,gt as ma,h as ha,ha as ga,hc as _a,hi as va,hl as ya,hn as ba,ho as xa,hr as Sa,hs as Ca,ht as wa,i as Ta,ia as Ea,ic as Da,ii as Oa,il as ka,in as Aa,io as ja,ir as Ma,is as Na,it as Pa,j as Fa,ja as F,jc as Ia,ji as La,jn as Ra,jo as za,jr as Ba,js as Va,jt as Ha,ka as Ua,kc as Wa,ki as Ga,kn as Ka,ko as qa,kr as Ja,ks as Ya,kt as Xa,l as Za,la as Qa,lc as $a,li as eo,ll as to,ln as no,lo as ro,lr as io,ls as ao,lt as oo,m as so,ma as co,mc as lo,mi as uo,ml as fo,mn as po,mo,mr as ho,ms as go,mt as _o,n as vo,na as yo,nc as bo,ni as xo,nl as So,nn as Co,no as wo,nr as To,ns as Eo,nt as Do,o as Oo,oa as ko,oc as Ao,oi as jo,ol as Mo,on as No,oo as Po,or as Fo,os as Io,ot as Lo,p as Ro,pa as zo,pc as Bo,pi as Vo,pl as Ho,pn as Uo,po as Wo,pr as Go,ps as Ko,pt as qo,q as Jo,qa as Yo,qc as Xo,qi as Zo,qn as Qo,qo as $o,qr as es,qs as ts,qt as ns,r as rs,ra as is,rc as as,ri as os,rl as ss,rn as cs,ro as ls,rr as us,rs as ds,rt as fs,s as ps,sa as ms,sc as hs,si as gs,sl as _s,sn as vs,so as ys,sr as bs,ss as xs,st as Ss,t as Cs,ta as ws,tc as Ts,ti as Es,tl as Ds,tn as Os,to as ks,tr as As,ts as I,tt as js,ua as Ms,uc as Ns,ui as Ps,ul as Fs,un as Is,uo as Ls,ur as Rs,us as zs,ut as Bs,v as Vs,va as Hs,vc as Us,vi as Ws,vl as Gs,vo as Ks,vr as qs,vs as Js,vt as Ys,w as Xs,wa as Zs,wc as Qs,wi as $s,wn as ec,wo as tc,wr as nc,ws as rc,wt as ic,x as ac,xa as oc,xc as sc,xi as cc,xl as L,xn as lc,xo as uc,xr as dc,xs as fc,xt as pc,y as mc,ya as hc,yc as gc,yi as _c,yl as vc,yn as R,yo as yc,yr as bc,ys as xc,yt as Sc,z as Cc,za as wc,zc as Tc,zi as Ec,zn as Dc,zo as Oc,zr as kc,zs as Ac}from"./chunk-ERSWUTIN-hHdvnhaY.js";import{i as z,n as jc,r as Mc}from"./chunk-SRAX5OIU-KFQikY-4.js";import{n as Nc,t as Pc}from"./jsx-runtime-BpzPEenQ.js";import{_ as Fc}from"./chunk-YGJVY4SA-CjSe7Bx7.js";import{r as Ic}from"./chunk-7XWMRXBY-CfMzEq80.js";import{n as Lc}from"./excalidraw-mermaid-stub-BNckbX2n.js";var B=e(Nc(),1),V=Pc();function Rc(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`){if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(n=Rc(e[t]))&&(r&&(r+=` `),r+=n);else for(t in e)e[t]&&(r&&(r+=` `),r+=t)}return r}function H(){for(var e=0,t,n,r=``;e<arguments.length;)(t=arguments[e++])&&(n=Rc(t))&&(r&&(r+=` `),r+=n);return r}var zc=t(((e,t)=>{var n=`Expected a function`,r=NaN,i=/^\s+|\s+$/g,a=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,s=/^0o[0-7]+$/i,c=parseInt,l=typeof global==`object`&&global&&global.Object===Object&&global,u=typeof self==`object`&&self&&self.Object===Object&&self,d=l||u||Function(`return this`)(),f=Object.prototype.toString,p=Math.max,m=Math.min,h=function(){return d.Date.now()};function g(e,t,r){var i,a,o,s,c,l,u=0,d=!1,f=!1,g=!0;if(typeof e!=`function`)throw TypeError(n);t=x(t)||0,v(r)&&(d=!!r.leading,f=`maxWait`in r,o=f?p(x(r.maxWait)||0,t):o,g=`trailing`in r?!!r.trailing:g);function _(t){var n=i,r=a;return i=a=void 0,u=t,s=e.apply(r,n),s}function y(e){return u=e,c=setTimeout(C,t),d?_(e):s}function b(e){var n=e-l,r=e-u,i=t-n;return f?m(i,o-r):i}function S(e){var n=e-l,r=e-u;return l===void 0||n>=t||n<0||f&&r>=o}function C(){var e=h();if(S(e))return w(e);c=setTimeout(C,b(e))}function w(e){return c=void 0,g&&i?_(e):(i=a=void 0,s)}function T(){c!==void 0&&clearTimeout(c),u=0,i=l=a=c=void 0}function E(){return c===void 0?s:w(h())}function D(){var e=h(),n=S(e);if(i=arguments,a=this,l=e,n){if(c===void 0)return y(l);if(f)return c=setTimeout(C,t),_(l)}return c===void 0&&(c=setTimeout(C,t)),s}return D.cancel=T,D.flush=E,D}function _(e,t,r){var i=!0,a=!0;if(typeof e!=`function`)throw TypeError(n);return v(r)&&(i=`leading`in r?!!r.leading:i,a=`trailing`in r?!!r.trailing:a),g(e,t,{leading:i,maxWait:t,trailing:a})}function v(e){var t=typeof e;return!!e&&(t==`object`||t==`function`)}function y(e){return!!e&&typeof e==`object`}function b(e){return typeof e==`symbol`||y(e)&&f.call(e)==`[object Symbol]`}function x(e){if(typeof e==`number`)return e;if(b(e))return r;if(v(e)){var t=typeof e.valueOf==`function`?e.valueOf():e;e=v(t)?t+``:t}if(typeof e!=`string`)return e===0?e:+e;e=e.replace(i,``);var n=o.test(e);return n||s.test(e)?c(e.slice(2),n?2:8):a.test(e)?r:+e}t.exports=_})),Bc=t((e=>{var t=Nc();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`);function o(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return o(e,t,null,r)},e.flushSync=function(e){var t=s.T,n=i.p;try{if(s.T=null,i.p=2,e)return e()}finally{s.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=c(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??i.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=c(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else i.d.m(e)}},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return s.H.useFormState(e,t,n)},e.useFormStatus=function(){return s.H.useHostTransitionStatus()},e.version=`19.2.8`})),Vc=t(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=Bc()})),Hc=e(zc(),1),Uc=e(Vc(),1),Wc=0;function Gc(e,t){let n=`atom${++Wc}`,r={toString(){return n}};return typeof e==`function`?r.read=e:(r.init=e,r.read=Kc,r.write=qc),t&&(r.write=t),r}function Kc(e){return e(this)}function qc(e,t,n){return t(this,typeof n==`function`?n(e(this)):n)}var Jc=(e,t)=>e.unstable_is?e.unstable_is(t):t===e,Yc=e=>`init`in e,Xc=e=>!!e.write,Zc=new WeakMap,Qc=e=>tl(e)&&!Zc.get(e)?.[1],$c=(e,t)=>{let n=Zc.get(e);n&&(n[1]=!0,n[0].forEach(e=>e(t)))},el=e=>{if(Zc.has(e))return;let t=[new Set,!1];Zc.set(e,t);let n=()=>{t[1]=!0};e.then(n,n),e.onCancel=e=>{t[0].add(e)}},tl=e=>typeof e?.then==`function`,nl=e=>`v`in e||`e`in e,rl=e=>{if(`e`in e)throw e.e;return e.v},il=(e,t,n)=>{n.p.has(e)||(n.p.add(e),t.then(()=>{n.p.delete(e)},()=>{n.p.delete(e)}))},al=(e,t,n,r,i)=>{var a;n.d.set(r,i.n),Qc(n.v)&&il(t,n.v,i),(a=i.m)==null||a.t.add(t),e&&ll(e,r,t)},ol=()=>({D:new Map,H:new Set,M:new Set,L:new Set}),sl=(e,t,n)=>{e[t].add(n)},cl=(e,t,n)=>{e.D.has(t)||(e.D.set(t,new Set),sl(e,`M`,()=>{var t;(t=n.m)==null||t.l.forEach(t=>sl(e,`M`,t))}))},ll=(e,t,n)=>{let r=e.D.get(t);r&&r.add(n)},ul=(e,t)=>e.D.get(t),dl=e=>{let t,n=!1,r=e=>{try{e()}catch(e){n||=(t=e,!0)}};for(;e.H.size||e.M.size||e.L.size;)e.D.clear(),e.H.forEach(r),e.H.clear(),e.M.forEach(r),e.M.clear(),e.L.forEach(r),e.L.clear();if(n)throw t},fl=(...[e,t,n,r])=>{let i=(t,n,r)=>{let i=`v`in n,a=n.v,o=Qc(n.v)?n.v:null;if(tl(r)){el(r);for(let i of n.d.keys())il(t,r,e(i));n.v=r}else n.v=r;delete n.e,delete n.x,(!i||!Object.is(a,n.v))&&(++n.n,o&&$c(o,r))},a=(n,r)=>{var o;let s=e(r);if(nl(s)&&(s.m&&!s.x||Array.from(s.d).every(([e,t])=>a(n,e).n===t)))return s;s.d.clear();let c=!0,l=t=>{if(Jc(r,t)){let n=e(t);if(!nl(n)){if(Yc(t))i(t,n,t.init);else throw Error(`no atom init`)}return rl(n)}let o=a(n,t);try{return rl(o)}finally{if(c)al(n,r,s,t,o);else{let e=ol();al(e,r,s,t,o),d(e,r,s),dl(e)}}},f,p,m={get signal(){return f||=new AbortController,f.signal},get setSelf(){return!p&&Xc(r)&&(p=(...e)=>{if(!c)return u(r,...e)}),p}};try{let e=t(r,l,m);if(i(r,s,e),tl(e)){(o=e.onCancel)==null||o.call(e,()=>f?.abort());let t=()=>{if(s.m){let e=ol();d(e,r,s),dl(e)}};e.then(t,t)}return s}catch(e){return delete s.v,s.e=e,delete s.x,++s.n,s}finally{c=!1}},o=e=>rl(a(void 0,e)),s=(t,n,r)=>{var i;let a=new Map;for(let t of r.m?.t||[]){let n=e(t);n.m&&a.set(t,n)}for(let t of r.p)a.set(t,e(t));return(i=ul(t,n))==null||i.forEach(t=>{a.set(t,e(t))}),a},c=(e,t,n)=>{let r=[],i=new Set,o=new Set,c=[[t,n]];for(;c.length>0;){let[t,n]=c[c.length-1];if(o.has(t)){c.pop();continue}if(i.has(t)){r.push([t,n,n.n]),o.add(t),n.x=!0,c.pop();continue}i.add(t);for(let[r,a]of s(e,t,n))t!==r&&!i.has(r)&&c.push([r,a])}sl(e,`H`,()=>{let n=new Set([t]);for(let t=r.length-1;t>=0;--t){let[i,o,s]=r[t],c=!1;for(let e of o.d.keys())if(e!==i&&n.has(e)){c=!0;break}c&&(a(e,i),d(e,i,o),s!==o.n&&(cl(e,i,o),n.add(i))),delete o.x}})},l=(t,r,...o)=>{let s=!0,u=e=>rl(a(t,e)),f=(n,...a)=>{let o=e(n);try{if(Jc(r,n)){if(!Yc(n))throw Error(`atom not writable`);let e=o.n,r=a[0];i(n,o,r),d(t,n,o),e!==o.n&&(cl(t,n,o),c(t,n,o));return}return l(t,n,...a)}finally{s||dl(t)}};try{return n(r,u,f,...o)}finally{s=!1}},u=(e,...t)=>{let n=ol();try{return l(n,e,...t)}finally{dl(n)}},d=(t,n,r)=>{if(r.m&&!Qc(r.v)){for(let i of r.d.keys())r.m.d.has(i)||(f(t,i,e(i)).t.add(n),r.m.d.add(i));for(let i of r.m.d||[])r.d.has(i)||(r.m.d.delete(i),p(t,i,e(i))?.t.delete(n))}},f=(t,n,i)=>{if(!i.m){a(t,n);for(let r of i.d.keys())f(t,r,e(r)).t.add(n);if(i.m={l:new Set,d:new Set(i.d.keys()),t:new Set},Xc(n)){let e=i.m,a,o=(e,t)=>{let r=!0;a=(...t)=>{try{return l(e,n,...t)}finally{r||dl(e)}};try{return t()}finally{r=!1}};sl(t,`L`,()=>{let i=o(t,()=>r(n,(...e)=>a(...e)));i&&(e.u=e=>o(e,i))})}}return i.m},p=(t,n,r)=>{if(r.m&&!r.m.l.size&&!Array.from(r.m.t).some(t=>e(t).m?.d.has(n))){let i=r.m.u;i&&sl(t,`L`,()=>i(t)),delete r.m;for(let i of r.d.keys())p(t,i,e(i))?.t.delete(n);return}return r.m};return{get:o,set:u,sub:(t,n)=>{let r=ol(),i=e(t),a=f(r,t,i).l;return a.add(n),dl(r),()=>{a.delete(n);let e=ol();p(e,t,i),dl(e)}},unstable_derive:i=>fl(...i(e,t,n,r))}},pl=()=>{let e=new WeakMap;return fl(t=>{let n=e.get(t);return n||(n={d:new Map,p:new Set,n:0},e.set(t,n)),n},(e,...t)=>e.read(...t),(e,...t)=>e.write(...t),(e,...t)=>e.onMount?.call(e,...t))},ml,hl=()=>(ml||=pl(),ml),gl=(0,B.createContext)(void 0),_l=e=>{let t=(0,B.useContext)(gl);return e?.store||t||hl()},vl=e=>typeof e?.then==`function`,yl=e=>{e.status=`pending`,e.then(t=>{e.status=`fulfilled`,e.value=t},t=>{e.status=`rejected`,e.reason=t})},bl=B.use||(e=>{if(e.status===`pending`)throw e;if(e.status===`fulfilled`)return e.value;throw e.status===`rejected`?e.reason:(yl(e),e)}),xl=new WeakMap,Sl=e=>{let t=xl.get(e);return t||(t=new Promise((n,r)=>{let i=e,a=e=>t=>{i===e&&n(t)},o=e=>t=>{i===e&&r(t)},s=e=>{`onCancel`in e&&typeof e.onCancel==`function`&&e.onCancel(e=>{vl(e)?(xl.set(e,t),i=e,e.then(a(e),o(e)),s(e)):n(e)})};e.then(a(e),o(e)),s(e)}),xl.set(e,t)),t};function Cl(e,t){let n=_l(t),[[r,i,a],o]=(0,B.useReducer)(t=>{let r=n.get(e);return Object.is(t[0],r)&&t[1]===n&&t[2]===e?t:[r,n,e]},void 0,()=>[n.get(e),n,e]),s=r;(i!==n||a!==e)&&(o(),s=n.get(e));let c=t?.delay;return(0,B.useEffect)(()=>{let t=n.sub(e,()=>{if(typeof c==`number`){let t=n.get(e);vl(t)&&yl(Sl(t)),setTimeout(o,c);return}o()});return o(),t},[n,e,c]),(0,B.useDebugValue)(s),vl(s)?bl(Sl(s)):s}function wl(e,t){let n=_l(t);return(0,B.useCallback)((...t)=>n.set(e,...t),[n,e])}function Tl(e,t){return[Cl(e,t),wl(e,t)]}var El=new WeakMap;function Dl(e,t){let n=_l(t),r=Ol(n);for(let[i,a]of e)(!r.has(i)||t?.dangerouslyForceHydrate)&&(r.add(i),n.set(i,a))}var Ol=e=>{let t=El.get(e);return t||(t=new WeakSet,El.set(e,t)),t};function kl(){return kl=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},kl.apply(this,arguments)}function Al(){let e=(0,B.createContext)(null);function t({store:t,initialValues:n=[],children:r}){let i=(0,B.useRef)(t);return i.current||=pl(),Dl(n,{store:i.current}),(0,V.jsx)(e.Provider,{value:i.current,children:r})}let n=t=>{let n=(0,B.useContext)(e);if(!n)throw Error(`Missing Provider from createIsolation`);return _l(kl({store:n},t))};return{Provider:t,useStore:n,useAtom:(e,t)=>{let r=n();return Tl(e,kl({store:r},t))},useAtomValue:(e,t)=>{let r=n();return Cl(e,kl({store:r},t))},useSetAtom:(e,t)=>{let r=n();return wl(e,kl({store:r},t))}}}var{read:jl,write:Ml}=Gc(null);(0,B.createContext)({scope:void 0,baseStore:void 0});function Nl(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function Pl(...e){return t=>{let n=!1,r=e.map(e=>{let r=Nl(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():Nl(e[t],null)}}}}function Fl(...e){return B.useCallback(Pl(...e),e)}function Il(e){let t=Ll(e),n=B.forwardRef((e,n)=>{let{children:r,...i}=e,a=B.Children.toArray(r),o=a.find(zl);if(o){let e=o.props.children,r=a.map(t=>t===o?B.Children.count(e)>1?B.Children.only(null):B.isValidElement(e)?e.props.children:null:t);return(0,V.jsx)(t,{...i,ref:n,children:B.isValidElement(e)?B.cloneElement(e,void 0,r):null})}return(0,V.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function Ll(e){let t=B.forwardRef((e,t)=>{let{children:n,...r}=e;if(B.isValidElement(n)){let e=Vl(n),i=Bl(r,n.props);return n.type!==B.Fragment&&(i.ref=t?Pl(t,e):e),B.cloneElement(n,i)}return B.Children.count(n)>1?B.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Rl=Symbol(`radix.slottable`);function zl(e){return B.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===Rl}function Bl(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function Vl(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Hl=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=Il(`Primitive.${t}`),r=B.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,V.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Ul(e,t){e&&Uc.flushSync(()=>e.dispatchEvent(t))}function Wl(e,t=[]){let n=[];function r(t,r){let i=B.createContext(r),a=n.length;n=[...n,r];let o=t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=B.useMemo(()=>o,Object.values(o));return(0,V.jsx)(s.Provider,{value:c,children:r})};o.displayName=t+`Provider`;function s(n,o){let s=o?.[e]?.[a]||i,c=B.useContext(s);if(c)return c;if(r!==void 0)return r;throw Error(`\`${n}\` must be used within \`${t}\``)}return[o,s]}let i=()=>{let t=n.map(e=>B.createContext(e));return function(n){let r=n?.[e]||t;return B.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,Gl(i,...t)]}function Gl(...e){let t=e[0];if(e.length===1)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return B.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}function Kl(e){let t=e+`CollectionProvider`,[n,r]=Wl(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=e=>{let{scope:t,children:n}=e,r=B.useRef(null),a=B.useRef(new Map).current;return(0,V.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})};o.displayName=t;let s=e+`CollectionSlot`,c=Il(s),l=B.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=Fl(t,a(s,n).collectionRef);return(0,V.jsx)(c,{ref:i,children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=Il(u),p=B.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=B.useRef(null),s=Fl(t,o),c=a(u,n);return B.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,V.jsx)(f,{[d]:``,ref:s,children:r})});p.displayName=u;function m(t){let n=a(e+`CollectionConsumer`,t);return B.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${d}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:o,Slot:l,ItemSlot:p},m,r]}typeof window<`u`&&window.document&&window.document.createElement;function U(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}var ql=globalThis?.document?B.useLayoutEffect:()=>{},Jl=B.useInsertionEffect||ql;function Yl({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){let[i,a,o]=Xl({defaultProp:t,onChange:n}),s=e!==void 0,c=s?e:i;{let t=B.useRef(e!==void 0);B.useEffect(()=>{let e=t.current;e!==s&&console.warn(`${r} is changing from ${e?`controlled`:`uncontrolled`} to ${s?`controlled`:`uncontrolled`}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),t.current=s},[s,r])}return[c,B.useCallback(t=>{if(s){let n=Zl(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}function Xl({defaultProp:e,onChange:t}){let[n,r]=B.useState(e),i=B.useRef(n),a=B.useRef(t);return Jl(()=>{a.current=t},[t]),B.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}function Zl(e){return typeof e==`function`}function Ql(e,t){return B.useReducer((e,n)=>t[e][n]??e,e)}var $l=e=>{let{present:t,children:n}=e,r=eu(t),i=typeof n==`function`?n({present:r.isPresent}):B.Children.only(n),a=Fl(r.ref,nu(i));return typeof n==`function`||r.isPresent?B.cloneElement(i,{ref:a}):null};$l.displayName=`Presence`;function eu(e){let[t,n]=B.useState(),r=B.useRef(null),i=B.useRef(e),a=B.useRef(`none`),[o,s]=Ql(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return B.useEffect(()=>{let e=tu(r.current);a.current=o===`mounted`?e:`none`},[o]),ql(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,o=tu(t);e?s(`MOUNT`):o===`none`||t?.display===`none`?s(`UNMOUNT`):s(n&&r!==o?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,s]),ql(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=tu(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(s(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},c=e=>{e.target===t&&(a.current=tu(r.current))};return t.addEventListener(`animationstart`,c),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,c),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}s(`ANIMATION_END`)},[t,s]),{isPresent:[`mounted`,`unmountSuspended`].includes(o),ref:B.useCallback(e=>{r.current=e?getComputedStyle(e):null,n(e)},[])}}function tu(e){return e?.animationName||`none`}function nu(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var ru=B.useId||(()=>void 0),iu=0;function au(e){let[t,n]=B.useState(ru());return ql(()=>{e||n(e=>e??String(iu++))},[e]),e||(t?`radix-${t}`:``)}var ou=B.createContext(void 0);function su(e){let t=B.useContext(ou);return e||t||`ltr`}function cu(e){let t=B.useRef(e);return B.useEffect(()=>{t.current=e}),B.useMemo(()=>(...e)=>t.current?.(...e),[])}function lu(e,t=globalThis?.document){let n=cu(e);B.useEffect(()=>{let e=e=>{e.key===`Escape`&&n(e)};return t.addEventListener(`keydown`,e,{capture:!0}),()=>t.removeEventListener(`keydown`,e,{capture:!0})},[n,t])}var uu=`DismissableLayer`,du=`dismissableLayer.update`,fu=`dismissableLayer.pointerDownOutside`,pu=`dismissableLayer.focusOutside`,mu,hu=B.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),gu=B.forwardRef((e,t)=>{let{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:a,onInteractOutside:o,onDismiss:s,...c}=e,l=B.useContext(hu),[u,d]=B.useState(null),f=u?.ownerDocument??globalThis?.document,[,p]=B.useState({}),m=Fl(t,e=>d(e)),h=Array.from(l.layers),[g]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),_=h.indexOf(g),v=u?h.indexOf(u):-1,y=l.layersWithOutsidePointerEventsDisabled.size>0,b=v>=_,x=yu(e=>{let t=e.target,n=[...l.branches].some(e=>e.contains(t));!b||n||(i?.(e),o?.(e),e.defaultPrevented||s?.())},f),S=bu(e=>{let t=e.target;[...l.branches].some(e=>e.contains(t))||(a?.(e),o?.(e),e.defaultPrevented||s?.())},f);return lu(e=>{v===l.layers.size-1&&(r?.(e),!e.defaultPrevented&&s&&(e.preventDefault(),s()))},f),B.useEffect(()=>{if(u)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(mu=f.body.style.pointerEvents,f.body.style.pointerEvents=`none`),l.layersWithOutsidePointerEventsDisabled.add(u)),l.layers.add(u),xu(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=mu)}},[u,f,n,l]),B.useEffect(()=>()=>{u&&(l.layers.delete(u),l.layersWithOutsidePointerEventsDisabled.delete(u),xu())},[u,l]),B.useEffect(()=>{let e=()=>p({});return document.addEventListener(du,e),()=>document.removeEventListener(du,e)},[]),(0,V.jsx)(Hl.div,{...c,ref:m,style:{pointerEvents:y?b?`auto`:`none`:void 0,...e.style},onFocusCapture:U(e.onFocusCapture,S.onFocusCapture),onBlurCapture:U(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:U(e.onPointerDownCapture,x.onPointerDownCapture)})});gu.displayName=uu;var _u=`DismissableLayerBranch`,vu=B.forwardRef((e,t)=>{let n=B.useContext(hu),r=B.useRef(null),i=Fl(t,r);return B.useEffect(()=>{let e=r.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),(0,V.jsx)(Hl.div,{...e,ref:i})});vu.displayName=_u;function yu(e,t=globalThis?.document){let n=cu(e),r=B.useRef(!1),i=B.useRef(()=>{});return B.useEffect(()=>{let e=e=>{if(e.target&&!r.current){let r=function(){Su(fu,n,a,{discrete:!0})},a={originalEvent:e};e.pointerType===`touch`?(t.removeEventListener(`click`,i.current),i.current=r,t.addEventListener(`click`,i.current,{once:!0})):r()}else t.removeEventListener(`click`,i.current);r.current=!1},a=window.setTimeout(()=>{t.addEventListener(`pointerdown`,e)},0);return()=>{window.clearTimeout(a),t.removeEventListener(`pointerdown`,e),t.removeEventListener(`click`,i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function bu(e,t=globalThis?.document){let n=cu(e),r=B.useRef(!1);return B.useEffect(()=>{let e=e=>{e.target&&!r.current&&Su(pu,n,{originalEvent:e},{discrete:!1})};return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function xu(){let e=new CustomEvent(du);document.dispatchEvent(e)}function Su(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?Ul(i,a):i.dispatchEvent(a)}var Cu=`focusScope.autoFocusOnMount`,wu=`focusScope.autoFocusOnUnmount`,Tu={bubbles:!1,cancelable:!0},Eu=`FocusScope`,Du=B.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=B.useState(null),l=cu(i),u=cu(a),d=B.useRef(null),f=Fl(t,e=>c(e)),p=B.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;B.useEffect(()=>{if(r){let e=function(e){if(p.paused||!s)return;let t=e.target;s.contains(t)?d.current=t:Pu(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||Pu(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&Pu(s)};document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return s&&r.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,s,p.paused]),B.useEffect(()=>{if(s){Fu.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(Cu,Tu);s.addEventListener(Cu,l),s.dispatchEvent(t),t.defaultPrevented||(Ou(Ru(Au(s)),{select:!0}),document.activeElement===e&&Pu(s))}return()=>{s.removeEventListener(Cu,l),setTimeout(()=>{let t=new CustomEvent(wu,Tu);s.addEventListener(wu,u),s.dispatchEvent(t),t.defaultPrevented||Pu(e??document.body,{select:!0}),s.removeEventListener(wu,u),Fu.remove(p)},0)}}},[s,l,u,p]);let m=B.useCallback(e=>{if(!n&&!r||p.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=ku(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&Pu(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&Pu(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,V.jsx)(Hl.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});Du.displayName=Eu;function Ou(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(Pu(r,{select:t}),document.activeElement!==n)return}function ku(e){let t=Au(e);return[ju(t,e),ju(t.reverse(),e)]}function Au(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function ju(e,t){for(let n of e)if(!Mu(n,{upTo:t}))return n}function Mu(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}function Nu(e){return e instanceof HTMLInputElement&&`select`in e}function Pu(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Nu(e)&&t&&e.select()}}var Fu=Iu();function Iu(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=Lu(e,t),e.unshift(t)},remove(t){e=Lu(e,t),e[0]?.resume()}}}function Lu(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Ru(e){return e.filter(e=>e.tagName!==`A`)}var zu=`Portal`,Bu=B.forwardRef((e,t)=>{let{container:n,...r}=e,[i,a]=B.useState(!1);ql(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?Uc.createPortal((0,V.jsx)(Hl.div,{...r,ref:t}),o):null});Bu.displayName=zu;var Vu=0;function Hu(){B.useEffect(()=>{let e=document.querySelectorAll(`[data-radix-focus-guard]`);return document.body.insertAdjacentElement(`afterbegin`,e[0]??Uu()),document.body.insertAdjacentElement(`beforeend`,e[1]??Uu()),Vu++,()=>{Vu===1&&document.querySelectorAll(`[data-radix-focus-guard]`).forEach(e=>e.remove()),Vu--}},[])}function Uu(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}var Wu=function(){return Wu=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Wu.apply(this,arguments)};function Gu(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function Ku(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var qu=`right-scroll-bar-position`,Ju=`width-before-scroll-bar`,Yu=`with-scroll-bars-hidden`,Xu=`--removed-body-scroll-bar-size`;function Zu(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function Qu(e,t){var n=(0,B.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var $u=typeof window<`u`?B.useLayoutEffect:B.useEffect,ed=new WeakMap;function td(e,t){var n=Qu(t||null,function(t){return e.forEach(function(e){return Zu(e,t)})});return $u(function(){var t=ed.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||Zu(e,null)}),i.forEach(function(e){r.has(e)||Zu(e,a)})}ed.set(n,e)},[e]),n}function nd(e){return e}function rd(e,t){t===void 0&&(t=nd);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function id(e){e===void 0&&(e={});var t=rd(null);return t.options=Wu({async:!0,ssr:!1},e),t}var ad=function(e){var t=e.sideCar,n=Gu(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return B.createElement(r,Wu({},n))};ad.isSideCarExport=!0;function od(e,t){return e.useMedium(t),ad}var sd=id(),cd=function(){},ld=B.forwardRef(function(e,t){var n=B.useRef(null),r=B.useState({onScrollCapture:cd,onWheelCapture:cd,onTouchMoveCapture:cd}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,m=e.noIsolation,h=e.inert,g=e.allowPinchZoom,_=e.as,v=_===void 0?`div`:_,y=e.gapMode,b=Gu(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),x=f,S=td([n,t]),C=Wu(Wu({},b),i);return B.createElement(B.Fragment,null,u&&B.createElement(x,{sideCar:sd,removeScrollBar:l,shards:d,noRelative:p,noIsolation:m,inert:h,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:y}),o?B.cloneElement(B.Children.only(s),Wu(Wu({},C),{ref:S})):B.createElement(v,Wu({},C,{className:c,ref:S}),s))});ld.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},ld.classNames={fullWidth:Ju,zeroRight:qu};var ud,dd=function(){if(ud)return ud;if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function fd(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=dd();return t&&e.setAttribute(`nonce`,t),e}function pd(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function md(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var hd=function(){var e=0,t=null;return{add:function(n){e==0&&(t=fd())&&(pd(t,n),md(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},gd=function(){var e=hd();return function(t,n){B.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},_d=function(){var e=gd();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},vd={left:0,top:0,right:0,gap:0},yd=function(e){return parseInt(e||``,10)||0},bd=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[yd(n),yd(r),yd(i)]},xd=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return vd;var t=bd(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},Sd=_d(),Cd=`data-scroll-locked`,wd=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
|
|
3
|
-
.${Yu} {
|
|
4
|
-
overflow: hidden ${r};
|
|
5
|
-
padding-right: ${s}px ${r};
|
|
6
|
-
}
|
|
7
|
-
body[${Cd}] {
|
|
8
|
-
overflow: hidden ${r};
|
|
9
|
-
overscroll-behavior: contain;
|
|
10
|
-
${[t&&`position: relative ${r};`,n===`margin`&&`
|
|
11
|
-
padding-left: ${i}px;
|
|
12
|
-
padding-top: ${a}px;
|
|
13
|
-
padding-right: ${o}px;
|
|
14
|
-
margin-left:0;
|
|
15
|
-
margin-top:0;
|
|
16
|
-
margin-right: ${s}px ${r};
|
|
17
|
-
`,n===`padding`&&`padding-right: ${s}px ${r};`].filter(Boolean).join(``)}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.${qu} {
|
|
21
|
-
right: ${s}px ${r};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.${Ju} {
|
|
25
|
-
margin-right: ${s}px ${r};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.${qu} .${qu} {
|
|
29
|
-
right: 0 ${r};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
.${Ju} .${Ju} {
|
|
33
|
-
margin-right: 0 ${r};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
body[${Cd}] {
|
|
37
|
-
${Xu}: ${s}px;
|
|
38
|
-
}
|
|
39
|
-
`},Td=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},Ed=function(){B.useEffect(function(){return document.body.setAttribute(Cd,(Td()+1).toString()),function(){var e=Td()-1;e<=0?document.body.removeAttribute(Cd):document.body.setAttribute(Cd,e.toString())}},[])},Dd=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;Ed();var a=B.useMemo(function(){return xd(i)},[i]);return B.createElement(Sd,{styles:wd(a,!t,i,n?``:`!important`)})},Od=!1;if(typeof window<`u`)try{var kd=Object.defineProperty({},"passive",{get:function(){return Od=!0,!0}});window.addEventListener(`test`,kd,kd),window.removeEventListener(`test`,kd,kd)}catch{Od=!1}var Ad=Od?{passive:!1}:!1,jd=function(e){return e.tagName===`TEXTAREA`},Md=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!jd(e)&&n[t]===`visible`)},Nd=function(e){return Md(e,`overflowY`)},Pd=function(e){return Md(e,`overflowX`)},Fd=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),Rd(e,r)){var i=zd(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Id=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},Ld=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},Rd=function(e,t){return e===`v`?Nd(t):Pd(t)},zd=function(e,t){return e===`v`?Id(t):Ld(t)},Bd=function(e,t){return e===`h`&&t===`rtl`?-1:1},Vd=function(e,t,n,r,i){var a=Bd(e,window.getComputedStyle(t).direction),o=a*r,s=n.target,c=t.contains(s),l=!1,u=o>0,d=0,f=0;do{if(!s)break;var p=zd(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&Rd(e,s)&&(d+=h,f+=m);var g=s.parentNode;s=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!c&&s!==document.body||c&&(t.contains(s)||t===s));return(u&&(i&&Math.abs(d)<1||!i&&o>d)||!u&&(i&&Math.abs(f)<1||!i&&-o>f))&&(l=!0),l},Hd=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Ud=function(e){return[e.deltaX,e.deltaY]},Wd=function(e){return e&&`current`in e?e.current:e},Gd=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Kd=function(e){return`
|
|
40
|
-
.block-interactivity-${e} {pointer-events: none;}
|
|
41
|
-
.allow-interactivity-${e} {pointer-events: all;}
|
|
42
|
-
`},qd=0,Jd=[];function Yd(e){var t=B.useRef([]),n=B.useRef([0,0]),r=B.useRef(),i=B.useState(qd++)[0],a=B.useState(_d)[0],o=B.useRef(e);B.useEffect(function(){o.current=e},[e]),B.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=Ku([e.lockRef.current],(e.shards||[]).map(Wd),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=B.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=Hd(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=Fd(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=Fd(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return Vd(h,t,e,h===`h`?s:c,!0)},[]),c=B.useCallback(function(e){var n=e;if(!(!Jd.length||Jd[Jd.length-1]!==a)){var r=`deltaY`in n?Ud(n):Hd(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&Gd(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(Wd).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=B.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:Xd(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=B.useCallback(function(e){n.current=Hd(e),r.current=void 0},[]),d=B.useCallback(function(t){l(t.type,Ud(t),t.target,s(t,e.lockRef.current))},[]),f=B.useCallback(function(t){l(t.type,Hd(t),t.target,s(t,e.lockRef.current))},[]);B.useEffect(function(){return Jd.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,Ad),document.addEventListener(`touchmove`,c,Ad),document.addEventListener(`touchstart`,u,Ad),function(){Jd=Jd.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,Ad),document.removeEventListener(`touchmove`,c,Ad),document.removeEventListener(`touchstart`,u,Ad)}},[]);var p=e.removeScrollBar,m=e.inert;return B.createElement(B.Fragment,null,m?B.createElement(a,{styles:Kd(i)}):null,p?B.createElement(Dd,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Xd(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var Zd=od(sd,Yd),Qd=B.forwardRef(function(e,t){return B.createElement(ld,Wu({},e,{ref:t,sideCar:Zd}))});Qd.classNames=ld.classNames;var $d=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},ef=new WeakMap,tf=new WeakMap,nf={},rf=0,af=function(e){return e&&(e.host||af(e.parentNode))},of=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=af(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},sf=function(e,t,n,r){var i=of(t,Array.isArray(e)?e:[e]);nf[n]||(nf[n]=new WeakMap);var a=nf[n],o=[],s=new Set,c=new Set(i),l=function(e){!e||s.has(e)||(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){!e||c.has(e)||Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(ef.get(e)||0)+1,l=(a.get(e)||0)+1;ef.set(e,c),a.set(e,l),o.push(e),c===1&&i&&tf.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),rf++,function(){o.forEach(function(e){var t=ef.get(e)-1,i=a.get(e)-1;ef.set(e,t),a.set(e,i),t||(tf.has(e)||e.removeAttribute(r),tf.delete(e)),i||e.removeAttribute(n)}),rf--,rf||(ef=new WeakMap,ef=new WeakMap,tf=new WeakMap,nf={})}},cf=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||$d(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),sf(r,i,n,`aria-hidden`)):function(){return null}},lf=t((e=>{var t=Nc();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,a=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue;function c(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),c=r[0].inst,u=r[1];return o(function(){c.value=n,c.getSnapshot=t,l(c)&&u({inst:c})},[e,n,t]),a(function(){return l(c)&&u({inst:c}),e(function(){l(c)&&u({inst:c})})},[e]),s(n),n}function l(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function u(e,t){return t()}var d=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?u:c;e.useSyncExternalStore=t.useSyncExternalStore===void 0?d:t.useSyncExternalStore})),uf=t(((e,t)=>{t.exports=lf()}));function df(e){let[t,n]=B.useState(void 0);return ql(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}n(void 0)},[e]),t}var ff=[`top`,`right`,`bottom`,`left`],pf=Math.min,mf=Math.max,hf=Math.round,gf=Math.floor,_f=e=>({x:e,y:e}),vf={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function yf(e,t,n){return mf(e,pf(t,n))}function bf(e,t){return typeof e==`function`?e(t):e}function xf(e){return e.split(`-`)[0]}function Sf(e){return e.split(`-`)[1]}function Cf(e){return e===`x`?`y`:`x`}function wf(e){return e===`y`?`height`:`width`}function Tf(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function Ef(e){return Cf(Tf(e))}function Df(e,t,n){n===void 0&&(n=!1);let r=Sf(e),i=Ef(e),a=wf(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=If(o)),[o,If(o)]}function Of(e){let t=If(e);return[kf(e),t,kf(t)]}function kf(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var Af=[`left`,`right`],jf=[`right`,`left`],Mf=[`top`,`bottom`],Nf=[`bottom`,`top`];function Pf(e,t,n){switch(e){case`top`:case`bottom`:return n?t?jf:Af:t?Af:jf;case`left`:case`right`:return t?Mf:Nf;default:return[]}}function Ff(e,t,n,r){let i=Sf(e),a=Pf(xf(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(kf)))),a}function If(e){let t=xf(e);return vf[t]+e.slice(t.length)}function Lf(e){return{top:0,right:0,bottom:0,left:0,...e}}function Rf(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:Lf(e)}function zf(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function Bf(e,t,n){let{reference:r,floating:i}=e,a=Tf(t),o=Ef(t),s=wf(o),c=xf(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}switch(Sf(t)){case`start`:p[o]-=f*(n&&l?-1:1);break;case`end`:p[o]+=f*(n&&l?-1:1)}return p}async function Vf(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=bf(t,e),p=Rf(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=zf(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=zf(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var Hf=50,Uf=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:Vf},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=Bf(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<Hf&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=Bf(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},Wf=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=bf(e,t)||{};if(l==null)return{};let d=Rf(u),f={x:n,y:r},p=Ef(i),m=wf(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(o.isElement==null?void 0:o.isElement(S)))&&(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=pf(d[_],T),D=pf(d[v],T),O=E,ee=C-h[m]-D,k=C/2-h[m]/2+w,te=yf(O,k,ee),ne=!c.arrow&&Sf(i)!=null&&k!==te&&a.reference[m]/2-(k<O?E:D)-h[m]/2<0,re=ne?k<O?k-O:k-ee:0;return{[p]:f[p]+re,data:{[p]:te,centerOffset:k-te-re,...ne&&{alignmentOffset:re}},reset:ne}}}),Gf=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=bf(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=xf(r),_=Tf(o),v=xf(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[If(o)]:Of(o)),x=p!==`none`;!d&&x&&b.push(...Ff(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=Df(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===Tf(t)||T.every(e=>Tf(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=Tf(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}};function Kf(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function qf(e){return ff.some(t=>e[t]>=0)}var Jf=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=bf(e,t);switch(i){case`referenceHidden`:{let e=Kf(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:qf(e)}}}case`escaped`:{let e=Kf(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:qf(e)}}}default:return{}}}}},Yf=new Set([`left`,`top`]);async function Xf(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=xf(n),s=Sf(n),c=Tf(n)===`y`,l=Yf.has(o)?-1:1,u=a&&c?-1:1,d=bf(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var Zf=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await Xf(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},Qf=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=bf(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=Tf(xf(i)),p=Cf(f),m=u[p],h=u[f];if(o){let e=p===`y`?`top`:`left`,t=p===`y`?`bottom`:`right`,n=m+d[e],r=m-d[t];m=yf(n,m,r)}if(s){let e=f===`y`?`top`:`left`,t=f===`y`?`bottom`:`right`,n=h+d[e],r=h-d[t];h=yf(n,h,r)}let g=c.fn({...t,[p]:m,[f]:h});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[p]:o,[f]:s}}}}}},$f=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=bf(e,t),u={x:n,y:r},d=Tf(i),f=Cf(d),p=u[f],m=u[d],h=bf(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=Yf.has(xf(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},ep=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){var n,r;let{placement:i,rects:a,platform:o,elements:s}=t,{apply:c=()=>{},...l}=bf(e,t),u=await o.detectOverflow(t,l),d=xf(i),f=Sf(i),p=Tf(i)===`y`,{width:m,height:h}=a.floating,g,_;d===`top`||d===`bottom`?(g=d,_=f===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?`start`:`end`)?`left`:`right`):(_=d,g=f===`end`?`top`:`bottom`);let v=h-u.top-u.bottom,y=m-u.left-u.right,b=pf(h-u[g],v),x=pf(m-u[_],y),S=!t.middlewareData.shift,C=b,w=x;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(w=y),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(C=v),S&&!f){let e=mf(u.left,0),t=mf(u.right,0),n=mf(u.top,0),r=mf(u.bottom,0);p?w=m-2*(e!==0||t!==0?e+t:mf(u.left,u.right)):C=h-2*(n!==0||r!==0?n+r:mf(u.top,u.bottom))}await c({...t,availableWidth:w,availableHeight:C});let T=await o.getDimensions(s.floating);return m!==T.width||h!==T.height?{reset:{rects:!0}}:{}}}};function tp(){return typeof window<`u`}function np(e){return ap(e)?(e.nodeName||``).toLowerCase():`#document`}function rp(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function ip(e){return((ap(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function ap(e){return tp()?e instanceof Node||e instanceof rp(e).Node:!1}function op(e){return tp()?e instanceof Element||e instanceof rp(e).Element:!1}function sp(e){return tp()?e instanceof HTMLElement||e instanceof rp(e).HTMLElement:!1}function cp(e){return!tp()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof rp(e).ShadowRoot}function lp(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=bp(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function up(e){return/^(table|td|th)$/.test(np(e))}function dp(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var fp=/transform|translate|scale|rotate|perspective|filter/,pp=/paint|layout|strict|content/,mp=e=>!!e&&e!==`none`,hp;function gp(e){let t=op(e)?bp(e):e;return mp(t.transform)||mp(t.translate)||mp(t.scale)||mp(t.rotate)||mp(t.perspective)||!vp()&&(mp(t.backdropFilter)||mp(t.filter))||fp.test(t.willChange||``)||pp.test(t.contain||``)}function _p(e){let t=Sp(e);for(;sp(t)&&!yp(t);){if(gp(t))return t;if(dp(t))return null;t=Sp(t)}return null}function vp(){return hp??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),hp}function yp(e){return/^(html|body|#document)$/.test(np(e))}function bp(e){return rp(e).getComputedStyle(e)}function xp(e){return op(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Sp(e){if(np(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||cp(e)&&e.host||ip(e);return cp(t)?t.host:t}function Cp(e){let t=Sp(e);return yp(t)?e.ownerDocument?e.ownerDocument.body:e.body:sp(t)&&lp(t)?t:Cp(t)}function wp(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Cp(e),i=r===e.ownerDocument?.body,a=rp(r);if(i){let e=Tp(a);return t.concat(a,a.visualViewport||[],lp(r)?r:[],e&&n?wp(e):[])}return t.concat(r,wp(r,[],n))}function Tp(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Ep(e){let t=bp(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=sp(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=hf(n)!==a||hf(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Dp(e){return op(e)?e:e.contextElement}function Op(e){let t=Dp(e);if(!sp(t))return _f(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=Ep(t),o=(a?hf(n.width):n.width)/r,s=(a?hf(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var kp=_f(0);function Ap(e){let t=rp(e);return!vp()||!t.visualViewport?kp:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function jp(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==rp(e)?!1:t}function Mp(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Dp(e),o=_f(1);t&&(r?op(r)&&(o=Op(r)):o=Op(e));let s=jp(a,n,r)?Ap(a):_f(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a){let e=rp(a),t=r&&op(r)?rp(r):r,n=e,i=Tp(n);for(;i&&r&&t!==n;){let e=Op(i),t=i.getBoundingClientRect(),r=bp(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=rp(i),i=Tp(n)}}return zf({width:u,height:d,x:c,y:l})}function Np(e,t){let n=xp(e).scrollLeft;return t?t.left+n:Mp(ip(e)).left+n}function Pp(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-Np(e,n),y:n.top+t.scrollTop}}function Fp(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=ip(r),s=t?dp(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=_f(1),u=_f(0),d=sp(r);if((d||!d&&!a)&&((np(r)!==`body`||lp(o))&&(c=xp(r)),d)){let e=Mp(r);l=Op(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?Pp(o,c):_f(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function Ip(e){return Array.from(e.getClientRects())}function Lp(e){let t=ip(e),n=xp(e),r=e.ownerDocument.body,i=mf(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=mf(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+Np(e),s=-n.scrollTop;return bp(r).direction===`rtl`&&(o+=mf(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}var Rp=25;function zp(e,t){let n=rp(e),r=ip(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=vp();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=Np(r);if(l<=0){let e=r.ownerDocument,t=e.body,n=getComputedStyle(t),i=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,o=Math.abs(r.clientWidth-t.clientWidth-i);o<=Rp&&(a-=o)}else l<=Rp&&(a+=l);return{width:a,height:o,x:s,y:c}}function Bp(e,t){let n=Mp(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=sp(e)?Op(e):_f(1);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function Vp(e,t,n){let r;if(t===`viewport`)r=zp(e,n);else if(t===`document`)r=Lp(ip(e));else if(op(t))r=Bp(t,n);else{let n=Ap(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return zf(r)}function Hp(e,t){let n=Sp(e);return n===t||!op(n)||yp(n)?!1:bp(n).position===`fixed`||Hp(n,t)}function Up(e,t){let n=t.get(e);if(n)return n;let r=wp(e,[],!1).filter(e=>op(e)&&np(e)!==`body`),i=null,a=bp(e).position===`fixed`,o=a?Sp(e):e;for(;op(o)&&!yp(o);){let t=bp(o),n=gp(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&(i.position===`absolute`||i.position===`fixed`)||lp(o)&&!n&&Hp(e,o))?r=r.filter(e=>e!==o):i=t,o=Sp(o)}return t.set(e,r),r}function Wp(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?dp(t)?[]:Up(t,this._c):[].concat(n),r],o=Vp(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=Vp(t,a[e],i);s=mf(n.top,s),c=pf(n.right,c),l=pf(n.bottom,l),u=mf(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function Gp(e){let{width:t,height:n}=Ep(e);return{width:t,height:n}}function Kp(e,t,n){let r=sp(t),i=ip(t),a=n===`fixed`,o=Mp(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=_f(0);function l(){c.x=Np(i)}if(r||!r&&!a){if((np(t)!==`body`||lp(i))&&(s=xp(t)),r){let e=Mp(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}else i&&l()}a&&!r&&i&&l();let u=i&&!r&&!a?Pp(i,s):_f(0);return{x:o.left+s.scrollLeft-c.x-u.x,y:o.top+s.scrollTop-c.y-u.y,width:o.width,height:o.height}}function qp(e){return bp(e).position===`static`}function Jp(e,t){if(!sp(e)||bp(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return ip(e)===n&&(n=n.ownerDocument.body),n}function Yp(e,t){let n=rp(e);if(dp(e))return n;if(!sp(e)){let t=Sp(e);for(;t&&!yp(t);){if(op(t)&&!qp(t))return t;t=Sp(t)}return n}let r=Jp(e,t);for(;r&&up(r)&&qp(r);)r=Jp(r,t);return r&&yp(r)&&qp(r)&&!gp(r)?n:r||_p(e)||n}var Xp=async function(e){let t=this.getOffsetParent||Yp,n=this.getDimensions,r=await n(e.floating);return{reference:Kp(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Zp(e){return bp(e).direction===`rtl`}var Qp={convertOffsetParentRelativeRectToViewportRelativeRect:Fp,getDocumentElement:ip,getClippingRect:Wp,getOffsetParent:Yp,getElementRects:Xp,getClientRects:Ip,getDimensions:Gp,getScale:Op,isElement:op,isRTL:Zp};function $p(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function em(e,t){let n=null,r,i=ip(e);function a(){var e;clearTimeout(r),(e=n)==null||e.disconnect(),n=null}function o(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),a();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(s||t(),!f||!p)return;let m=gf(d),h=gf(i.clientWidth-(u+f)),g=gf(i.clientHeight-(d+p)),_=gf(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:mf(0,pf(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(n!==c){if(!y)return o();n?o(!1,n):r=setTimeout(()=>{o(!1,1e-7)},1e3)}n===1&&!$p(l,e.getBoundingClientRect())&&o(),y=!1}try{n=new IntersectionObserver(b,{...v,root:i.ownerDocument})}catch{n=new IntersectionObserver(b,v)}n.observe(e)}return o(!0),a}function tm(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=Dp(e),u=i||a?[...l?wp(l):[],...t?wp(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?em(l,n):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?Mp(e):null;c&&g();function g(){let t=Mp(e);h&&!$p(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var nm=Zf,rm=Qf,im=Gf,am=ep,om=Jf,sm=Wf,cm=$f,lm=(e,t,n)=>{let r=new Map,i={platform:Qp,...n},a={...i.platform,_c:r};return Uf(e,t,{...i,platform:a})},um=typeof document<`u`?B.useLayoutEffect:function(){};function dm(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!dm(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!dm(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function fm(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function pm(e,t){let n=fm(e);return Math.round(t*n)/n}function mm(e){let t=B.useRef(e);return um(()=>{t.current=e}),t}function hm(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=B.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=B.useState(r);dm(f,r)||p(r);let[m,h]=B.useState(null),[g,_]=B.useState(null),v=B.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=B.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=B.useRef(null),C=B.useRef(null),w=B.useRef(u),T=c!=null,E=mm(c),D=mm(i),O=mm(l),ee=B.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),lm(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};k.current&&!dm(w.current,t)&&(w.current=t,Uc.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);um(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let k=B.useRef(!1);um(()=>(k.current=!0,()=>{k.current=!1}),[]),um(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,ee);ee()}},[b,x,ee,E,T]);let te=B.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),ne=B.useMemo(()=>({reference:b,floating:x}),[b,x]),re=B.useMemo(()=>{let e={position:n,left:0,top:0};if(!ne.floating)return e;let t=pm(ne.floating,u.x),r=pm(ne.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...fm(ne.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,ne.floating,u.x,u.y]);return B.useMemo(()=>({...u,update:ee,refs:te,elements:ne,floatingStyles:re}),[u,ee,te,ne,re])}var gm=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:sm({element:r.current,padding:i}).fn(n):r?sm({element:r,padding:i}).fn(n):{}}}},_m=(e,t)=>{let n=nm(e);return{name:n.name,fn:n.fn,options:[e,t]}},vm=(e,t)=>{let n=rm(e);return{name:n.name,fn:n.fn,options:[e,t]}},ym=(e,t)=>({fn:cm(e).fn,options:[e,t]}),bm=(e,t)=>{let n=im(e);return{name:n.name,fn:n.fn,options:[e,t]}},xm=(e,t)=>{let n=am(e);return{name:n.name,fn:n.fn,options:[e,t]}},Sm=(e,t)=>{let n=om(e);return{name:n.name,fn:n.fn,options:[e,t]}},Cm=(e,t)=>{let n=gm(e);return{name:n.name,fn:n.fn,options:[e,t]}},wm=`Arrow`,Tm=B.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,V.jsx)(Hl.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,V.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});Tm.displayName=wm;var Em=Tm,Dm=`Popper`,[Om,km]=Wl(Dm),[Am,jm]=Om(Dm),Mm=e=>{let{__scopePopper:t,children:n}=e,[r,i]=B.useState(null);return(0,V.jsx)(Am,{scope:t,anchor:r,onAnchorChange:i,children:n})};Mm.displayName=Dm;var Nm=`PopperAnchor`,Pm=B.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=jm(Nm,n),o=B.useRef(null),s=Fl(t,o),c=B.useRef(null);return B.useEffect(()=>{let e=c.current;c.current=r?.current||o.current,e!==c.current&&a.onAnchorChange(c.current)}),r?null:(0,V.jsx)(Hl.div,{...i,ref:s})});Pm.displayName=Nm;var Fm=`PopperContent`,[Im,Lm]=Om(Fm),Rm=B.forwardRef((e,t)=>{let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:d=`partial`,hideWhenDetached:f=!1,updatePositionStrategy:p=`optimized`,onPlaced:m,...h}=e,g=jm(Fm,n),[_,v]=B.useState(null),y=Fl(t,e=>v(e)),[b,x]=B.useState(null),S=df(b),C=S?.width??0,w=S?.height??0,T=r+(a===`center`?``:`-`+a),E=typeof u==`number`?u:{top:0,right:0,bottom:0,left:0,...u},D=Array.isArray(l)?l:[l],O=D.length>0,ee={padding:E,boundary:D.filter(Hm),altBoundary:O},{refs:k,floatingStyles:te,placement:ne,isPositioned:re,middlewareData:ie}=hm({strategy:`fixed`,placement:T,whileElementsMounted:(...e)=>tm(...e,{animationFrame:p===`always`}),elements:{reference:g.anchor},middleware:[_m({mainAxis:i+w,alignmentAxis:o}),c&&vm({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?ym():void 0,...ee}),c&&bm({...ee}),xm({...ee,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),b&&Cm({element:b,padding:s}),Um({arrowWidth:C,arrowHeight:w}),f&&Sm({strategy:`referenceHidden`,...ee})]}),[ae,oe]=Wm(ne),se=cu(m);ql(()=>{re&&se?.()},[re,se]);let ce=ie.arrow?.x,le=ie.arrow?.y,ue=ie.arrow?.centerOffset!==0,[de,fe]=B.useState();return ql(()=>{_&&fe(window.getComputedStyle(_).zIndex)},[_]),(0,V.jsx)(`div`,{ref:k.setFloating,"data-radix-popper-content-wrapper":``,style:{...te,transform:re?te.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:de,"--radix-popper-transform-origin":[ie.transformOrigin?.x,ie.transformOrigin?.y].join(` `),...ie.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,V.jsx)(Im,{scope:n,placedSide:ae,onArrowChange:x,arrowX:ce,arrowY:le,shouldHideArrow:ue,children:(0,V.jsx)(Hl.div,{"data-side":ae,"data-align":oe,...h,ref:y,style:{...h.style,animation:re?void 0:`none`}})})})});Rm.displayName=Fm;var zm=`PopperArrow`,Bm={top:`bottom`,right:`left`,bottom:`top`,left:`right`},Vm=B.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=Lm(zm,n),a=Bm[i.placedSide];return(0,V.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,V.jsx)(Em,{...r,ref:t,style:{...r.style,display:`block`}})})});Vm.displayName=zm;function Hm(e){return e!==null}var Um=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=Wm(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function Wm(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var Gm=Mm,Km=Pm,qm=Rm,Jm=Vm,Ym=`rovingFocusGroup.onEntryFocus`,Xm={bubbles:!1,cancelable:!0},Zm=`RovingFocusGroup`,[Qm,$m,eh]=Kl(Zm),[th,nh]=Wl(Zm,[eh]),[rh,ih]=th(Zm),ah=B.forwardRef((e,t)=>(0,V.jsx)(Qm.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,V.jsx)(Qm.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,V.jsx)(oh,{...e,ref:t})})}));ah.displayName=Zm;var oh=B.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=B.useRef(null),p=Fl(t,f),m=su(a),[h,g]=Yl({prop:o,defaultProp:s??null,onChange:c,caller:Zm}),[_,v]=B.useState(!1),y=cu(l),b=$m(n),x=B.useRef(!1),[S,C]=B.useState(0);return B.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(Ym,y),()=>e.removeEventListener(Ym,y)},[y]),(0,V.jsx)(rh,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:B.useCallback(e=>g(e),[g]),onItemShiftTab:B.useCallback(()=>v(!0),[]),onFocusableItemAdd:B.useCallback(()=>C(e=>e+1),[]),onFocusableItemRemove:B.useCallback(()=>C(e=>e-1),[]),children:(0,V.jsx)(Hl.div,{tabIndex:_||S===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:U(e.onMouseDown,()=>{x.current=!0}),onFocus:U(e.onFocus,e=>{let t=!x.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(Ym,Xm);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=b().filter(e=>e.focusable);fh([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}x.current=!1}),onBlur:U(e.onBlur,()=>v(!1))})})}),sh=`RovingFocusGroupItem`,ch=B.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=au(),l=a||c,u=ih(sh,n),d=u.currentTabStopId===l,f=$m(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u;return B.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),(0,V.jsx)(Qm.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,V.jsx)(Hl.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:U(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:U(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:U(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=dh(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?ph(n,r+1):n.slice(r+1)}setTimeout(()=>fh(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})});ch.displayName=sh;var lh={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function uh(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function dh(e,t,n){let r=uh(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return lh[r]}function fh(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function ph(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var mh=ah,hh=ch,gh=[`Enter`,` `],_h=[`ArrowDown`,`PageUp`,`Home`],vh=[`ArrowUp`,`PageDown`,`End`],yh=[..._h,...vh],bh={ltr:[...gh,`ArrowRight`],rtl:[...gh,`ArrowLeft`]},xh={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},Sh=`Menu`,[Ch,wh,Th]=Kl(Sh),[Eh,Dh]=Wl(Sh,[Th,km,nh]),Oh=km(),kh=nh(),[Ah,jh]=Eh(Sh),[Mh,Nh]=Eh(Sh),Ph=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=Oh(t),[c,l]=B.useState(null),u=B.useRef(!1),d=cu(a),f=su(i);return B.useEffect(()=>{let e=()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},t=()=>u.current=!1;return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),(0,V.jsx)(Gm,{...s,children:(0,V.jsx)(Ah,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,V.jsx)(Mh,{scope:t,onClose:B.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};Ph.displayName=Sh;var Fh=`MenuAnchor`,Ih=B.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=Oh(n);return(0,V.jsx)(Km,{...i,...r,ref:t})});Ih.displayName=Fh;var[Lh,Rh]=Eh(`MenuPortal`,{forceMount:void 0}),zh=`MenuContent`,[Bh,Vh]=Eh(zh),Hh=B.forwardRef((e,t)=>{let n=Rh(zh,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=jh(zh,e.__scopeMenu),o=Nh(zh,e.__scopeMenu);return(0,V.jsx)(Ch.Provider,{scope:e.__scopeMenu,children:(0,V.jsx)($l,{present:r||a.open,children:(0,V.jsx)(Ch.Slot,{scope:e.__scopeMenu,children:o.modal?(0,V.jsx)(Uh,{...i,ref:t}):(0,V.jsx)(Wh,{...i,ref:t})})})})}),Uh=B.forwardRef((e,t)=>{let n=jh(zh,e.__scopeMenu),r=B.useRef(null),i=Fl(t,r);return B.useEffect(()=>{let e=r.current;if(e)return cf(e)},[]),(0,V.jsx)(Kh,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:U(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Wh=B.forwardRef((e,t)=>{let n=jh(zh,e.__scopeMenu);return(0,V.jsx)(Kh,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Gh=Il(`MenuContent.ScrollLock`),Kh=B.forwardRef((e,t)=>{let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...h}=e,g=jh(zh,n),_=Nh(zh,n),v=Oh(n),y=kh(n),b=wh(n),[x,S]=B.useState(null),C=B.useRef(null),w=Fl(t,C,g.onContentChange),T=B.useRef(0),E=B.useRef(``),D=B.useRef(0),O=B.useRef(null),ee=B.useRef(`right`),k=B.useRef(0),te=m?Qd:B.Fragment,ne=m?{as:Gh,allowPinchZoom:!0}:void 0,re=e=>{let t=E.current+e,n=b().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=Ag(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;(function e(t){E.current=t,window.clearTimeout(T.current),t!==``&&(T.current=window.setTimeout(()=>e(``),1e3))})(t),o&&setTimeout(()=>o.focus())};B.useEffect(()=>()=>window.clearTimeout(T.current),[]),Hu();let ie=B.useCallback(e=>ee.current===O.current?.side&&Mg(e,O.current?.area),[]);return(0,V.jsx)(Bh,{scope:n,searchRef:E,onItemEnter:B.useCallback(e=>{ie(e)&&e.preventDefault()},[ie]),onItemLeave:B.useCallback(e=>{ie(e)||(C.current?.focus(),S(null))},[ie]),onTriggerLeave:B.useCallback(e=>{ie(e)&&e.preventDefault()},[ie]),pointerGraceTimerRef:D,onPointerGraceIntentChange:B.useCallback(e=>{O.current=e},[]),children:(0,V.jsx)(te,{...ne,children:(0,V.jsx)(Du,{asChild:!0,trapped:i,onMountAutoFocus:U(a,e=>{e.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,V.jsx)(gu,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,V.jsx)(mh,{asChild:!0,...y,dir:_.dir,orientation:`vertical`,loop:r,currentTabStopId:x,onCurrentTabStopIdChange:S,onEntryFocus:U(c,e=>{_.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,V.jsx)(qm,{role:`menu`,"aria-orientation":`vertical`,"data-state":Tg(g.open),"data-radix-menu-content":``,dir:_.dir,...v,...h,ref:w,style:{outline:`none`,...h.style},onKeyDown:U(h.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&re(e.key));let i=C.current;if(e.target!==i||!yh.includes(e.key))return;e.preventDefault();let a=b().filter(e=>!e.disabled).map(e=>e.ref.current);vh.includes(e.key)&&a.reverse(),Og(a)}),onBlur:U(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(T.current),E.current=``)}),onPointerMove:U(e.onPointerMove,Ng(e=>{let t=e.target,n=k.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>k.current?`right`:`left`;ee.current=t,k.current=e.clientX}}))})})})})})})});Hh.displayName=zh;var qh=`MenuGroup`,Jh=B.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,V.jsx)(Hl.div,{role:`group`,...r,ref:t})});Jh.displayName=qh;var Yh=`MenuLabel`,Xh=B.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,V.jsx)(Hl.div,{...r,ref:t})});Xh.displayName=Yh;var Zh=`MenuItem`,Qh=`menu.itemSelect`,$h=B.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,a=B.useRef(null),o=Nh(Zh,e.__scopeMenu),s=Vh(Zh,e.__scopeMenu),c=Fl(t,a),l=B.useRef(!1),u=()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(Qh,{bubbles:!0,cancelable:!0});e.addEventListener(Qh,e=>r?.(e),{once:!0}),Ul(e,t),t.defaultPrevented?l.current=!1:o.onClose()}};return(0,V.jsx)(eg,{...i,ref:c,disabled:n,onClick:U(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:U(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:U(e.onKeyDown,e=>{let t=s.searchRef.current!==``;n||t&&e.key===` `||gh.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});$h.displayName=Zh;var eg=B.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=Vh(Zh,n),s=kh(n),c=B.useRef(null),l=Fl(t,c),[u,d]=B.useState(!1),[f,p]=B.useState(``);return B.useEffect(()=>{let e=c.current;e&&p((e.textContent??``).trim())},[a.children]),(0,V.jsx)(Ch.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,V.jsx)(hh,{asChild:!0,...s,focusable:!r,children:(0,V.jsx)(Hl.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:U(e.onPointerMove,Ng(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:U(e.onPointerLeave,Ng(e=>o.onItemLeave(e))),onFocus:U(e.onFocus,()=>d(!0)),onBlur:U(e.onBlur,()=>d(!1))})})})}),tg=`MenuCheckboxItem`,ng=B.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,V.jsx)(ug,{scope:e.__scopeMenu,checked:n,children:(0,V.jsx)($h,{role:`menuitemcheckbox`,"aria-checked":Eg(n)?`mixed`:n,...i,ref:t,"data-state":Dg(n),onSelect:U(i.onSelect,()=>r?.(Eg(n)?!0:!n),{checkForDefaultPrevented:!1})})})});ng.displayName=tg;var rg=`MenuRadioGroup`,[ig,ag]=Eh(rg,{value:void 0,onValueChange:()=>{}}),og=B.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,a=cu(r);return(0,V.jsx)(ig,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,V.jsx)(Jh,{...i,ref:t})})});og.displayName=rg;var sg=`MenuRadioItem`,cg=B.forwardRef((e,t)=>{let{value:n,...r}=e,i=ag(sg,e.__scopeMenu),a=n===i.value;return(0,V.jsx)(ug,{scope:e.__scopeMenu,checked:a,children:(0,V.jsx)($h,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":Dg(a),onSelect:U(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});cg.displayName=sg;var lg=`MenuItemIndicator`,[ug,dg]=Eh(lg,{checked:!1}),fg=B.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,a=dg(lg,n);return(0,V.jsx)($l,{present:r||Eg(a.checked)||a.checked===!0,children:(0,V.jsx)(Hl.span,{...i,ref:t,"data-state":Dg(a.checked)})})});fg.displayName=lg;var pg=`MenuSeparator`,mg=B.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,V.jsx)(Hl.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})});mg.displayName=pg;var hg=`MenuArrow`,gg=B.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=Oh(n);return(0,V.jsx)(Jm,{...i,...r,ref:t})});gg.displayName=hg;var _g=`MenuSub`,[vg,yg]=Eh(_g),bg=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=jh(_g,t),o=Oh(t),[s,c]=B.useState(null),[l,u]=B.useState(null),d=cu(i);return B.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),(0,V.jsx)(Gm,{...o,children:(0,V.jsx)(Ah,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u,children:(0,V.jsx)(vg,{scope:t,contentId:au(),triggerId:au(),trigger:s,onTriggerChange:c,children:n})})})};bg.displayName=_g;var xg=`MenuSubTrigger`,Sg=B.forwardRef((e,t)=>{let n=jh(xg,e.__scopeMenu),r=Nh(xg,e.__scopeMenu),i=yg(xg,e.__scopeMenu),a=Vh(xg,e.__scopeMenu),o=B.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:c}=a,l={__scopeMenu:e.__scopeMenu},u=B.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return B.useEffect(()=>u,[u]),B.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),c(null)}},[s,c]),(0,V.jsx)(Ih,{asChild:!0,...l,children:(0,V.jsx)(eg,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":i.contentId,"data-state":Tg(n.open),...e,ref:Pl(t,i.onTriggerChange),onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:U(e.onPointerMove,Ng(t=>{a.onItemEnter(t),!t.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:U(e.onPointerLeave,Ng(e=>{u();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i=r===`right`,o=i?-5:5,c=t[i?`left`:`right`],l=t[i?`right`:`left`];a.onPointerGraceIntentChange({area:[{x:e.clientX+o,y:e.clientY},{x:c,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:c,y:t.bottom}],side:r}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:U(e.onKeyDown,t=>{let i=a.searchRef.current!==``;e.disabled||i&&t.key===` `||bh[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});Sg.displayName=xg;var Cg=`MenuSubContent`,wg=B.forwardRef((e,t)=>{let n=Rh(zh,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=jh(zh,e.__scopeMenu),o=Nh(zh,e.__scopeMenu),s=yg(Cg,e.__scopeMenu),c=B.useRef(null),l=Fl(t,c);return(0,V.jsx)(Ch.Provider,{scope:e.__scopeMenu,children:(0,V.jsx)($l,{present:r||a.open,children:(0,V.jsx)(Ch.Slot,{scope:e.__scopeMenu,children:(0,V.jsx)(Kh,{id:s.contentId,"aria-labelledby":s.triggerId,...i,ref:l,align:`start`,side:o.dir===`rtl`?`left`:`right`,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{o.isUsingKeyboardRef.current&&c.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:U(e.onFocusOutside,e=>{e.target!==s.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:U(e.onEscapeKeyDown,e=>{o.onClose(),e.preventDefault()}),onKeyDown:U(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=xh[o.dir].includes(e.key);t&&n&&(a.onOpenChange(!1),s.trigger?.focus(),e.preventDefault())})})})})})});wg.displayName=Cg;function Tg(e){return e?`open`:`closed`}function Eg(e){return e===`indeterminate`}function Dg(e){return Eg(e)?`indeterminate`:e?`checked`:`unchecked`}function Og(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function kg(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function Ag(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=kg(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function jg(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function Mg(e,t){return t?jg({x:e.clientX,y:e.clientY},t):!1}function Ng(e){return t=>t.pointerType===`mouse`?e(t):void 0}var Pg=Ph,Fg=Ih,Ig=Hh,Lg=Jh,Rg=Xh,zg=$h,Bg=ng,Vg=og,Hg=cg,Ug=fg,Wg=mg,Gg=gg,Kg=bg,qg=Sg,Jg=wg,Yg=`DropdownMenu`,[Xg,Zg]=Wl(Yg,[Dh]),Qg=Dh(),[$g,e_]=Xg(Yg),t_=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=Qg(t),l=B.useRef(null),[u,d]=Yl({prop:i,defaultProp:a??!1,onChange:o,caller:Yg});return(0,V.jsx)($g,{scope:t,triggerId:au(),triggerRef:l,contentId:au(),open:u,onOpenChange:d,onOpenToggle:B.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,V.jsx)(Pg,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};t_.displayName=Yg;var n_=`DropdownMenuTrigger`,r_=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=e_(n_,n),o=Qg(n);return(0,V.jsx)(Fg,{asChild:!0,...o,children:(0,V.jsx)(Hl.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:Pl(t,a.triggerRef),onPointerDown:U(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:U(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})});r_.displayName=n_;var i_=`DropdownMenuContent`,a_=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=e_(i_,n),a=Qg(n),o=B.useRef(!1);return(0,V.jsx)(Ig,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:U(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:U(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});a_.displayName=i_;var o_=`DropdownMenuGroup`,s_=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Qg(n);return(0,V.jsx)(Lg,{...i,...r,ref:t})});s_.displayName=o_;var c_=`DropdownMenuLabel`,l_=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Qg(n);return(0,V.jsx)(Rg,{...i,...r,ref:t})});l_.displayName=c_;var u_=`DropdownMenuItem`,d_=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Qg(n);return(0,V.jsx)(zg,{...i,...r,ref:t})});d_.displayName=u_;var f_=`DropdownMenuCheckboxItem`,p_=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Qg(n);return(0,V.jsx)(Bg,{...i,...r,ref:t})});p_.displayName=f_;var m_=`DropdownMenuRadioGroup`,h_=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Qg(n);return(0,V.jsx)(Vg,{...i,...r,ref:t})});h_.displayName=m_;var g_=`DropdownMenuRadioItem`,__=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Qg(n);return(0,V.jsx)(Hg,{...i,...r,ref:t})});__.displayName=g_;var v_=`DropdownMenuItemIndicator`,y_=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Qg(n);return(0,V.jsx)(Ug,{...i,...r,ref:t})});y_.displayName=v_;var b_=`DropdownMenuSeparator`,x_=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Qg(n);return(0,V.jsx)(Wg,{...i,...r,ref:t})});x_.displayName=b_;var S_=`DropdownMenuArrow`,C_=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Qg(n);return(0,V.jsx)(Gg,{...i,...r,ref:t})});C_.displayName=S_;var w_=e=>{let{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:a}=e,o=Qg(t),[s,c]=Yl({prop:r,defaultProp:a??!1,onChange:i,caller:`DropdownMenuSub`});return(0,V.jsx)(Kg,{...o,open:s,onOpenChange:c,children:n})},T_=`DropdownMenuSubTrigger`,E_=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Qg(n);return(0,V.jsx)(qg,{...i,...r,ref:t})});E_.displayName=T_;var D_=`DropdownMenuSubContent`,O_=B.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Qg(n);return(0,V.jsx)(Jg,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});O_.displayName=D_;var k_=t_,A_=r_,j_=a_,M_=d_,N_=w_,P_=E_,F_=O_,I_=`Popover`,[L_,R_]=Wl(I_,[km]),z_=km(),[B_,V_]=L_(I_),H_=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=z_(t),c=B.useRef(null),[l,u]=B.useState(!1),[d,f]=Yl({prop:r,defaultProp:i??!1,onChange:a,caller:I_});return(0,V.jsx)(Gm,{...s,children:(0,V.jsx)(B_,{scope:t,contentId:au(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:B.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:B.useCallback(()=>u(!0),[]),onCustomAnchorRemove:B.useCallback(()=>u(!1),[]),modal:o,children:n})})};H_.displayName=I_;var U_=`PopoverAnchor`,W_=B.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=V_(U_,n),a=z_(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return B.useEffect(()=>(o(),()=>s()),[o,s]),(0,V.jsx)(Km,{...a,...r,ref:t})});W_.displayName=U_;var G_=`PopoverTrigger`,K_=B.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=V_(G_,n),a=z_(n),o=Fl(t,i.triggerRef),s=(0,V.jsx)(Hl.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":sv(i.open),...r,ref:o,onClick:U(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,V.jsx)(Km,{asChild:!0,...a,children:s})});K_.displayName=G_;var q_=`PopoverPortal`,[J_,Y_]=L_(q_,{forceMount:void 0}),X_=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=V_(q_,t);return(0,V.jsx)(J_,{scope:t,forceMount:n,children:(0,V.jsx)($l,{present:n||a.open,children:(0,V.jsx)(Bu,{asChild:!0,container:i,children:r})})})};X_.displayName=q_;var Z_=`PopoverContent`,Q_=B.forwardRef((e,t)=>{let n=Y_(Z_,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=V_(Z_,e.__scopePopover);return(0,V.jsx)($l,{present:r||a.open,children:a.modal?(0,V.jsx)(ev,{...i,ref:t}):(0,V.jsx)(tv,{...i,ref:t})})});Q_.displayName=Z_;var $_=Il(`PopoverContent.RemoveScroll`),ev=B.forwardRef((e,t)=>{let n=V_(Z_,e.__scopePopover),r=B.useRef(null),i=Fl(t,r),a=B.useRef(!1);return B.useEffect(()=>{let e=r.current;if(e)return cf(e)},[]),(0,V.jsx)(Qd,{as:$_,allowPinchZoom:!0,children:(0,V.jsx)(nv,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:U(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:U(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;a.current=r},{checkForDefaultPrevented:!1}),onFocusOutside:U(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),tv=B.forwardRef((e,t)=>{let n=V_(Z_,e.__scopePopover),r=B.useRef(!1),i=B.useRef(!1);return(0,V.jsx)(nv,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),nv=B.forwardRef((e,t)=>{let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=V_(Z_,n),p=z_(n);return Hu(),(0,V.jsx)(Du,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,V.jsx)(gu,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),children:(0,V.jsx)(qm,{"data-state":sv(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})}),rv=`PopoverClose`,iv=B.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=V_(rv,n);return(0,V.jsx)(Hl.button,{type:`button`,...r,ref:t,onClick:U(e.onClick,()=>i.onOpenChange(!1))})});iv.displayName=rv;var av=`PopoverArrow`,ov=B.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=z_(n);return(0,V.jsx)(Jm,{...i,...r,ref:t})});ov.displayName=av;function sv(e){return e?`open`:`closed`}var cv=H_,lv=K_,uv=X_,dv=Q_,fv=iv,pv=ov,mv=`Tabs`,[hv,gv]=Wl(mv,[nh]),_v=nh(),[vv,yv]=hv(mv),bv=B.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o=`horizontal`,dir:s,activationMode:c=`automatic`,...l}=e,u=su(s),[d,f]=Yl({prop:r,onChange:i,defaultProp:a??``,caller:mv});return(0,V.jsx)(vv,{scope:n,baseId:au(),value:d,onValueChange:f,orientation:o,dir:u,activationMode:c,children:(0,V.jsx)(Hl.div,{dir:u,"data-orientation":o,...l,ref:t})})});bv.displayName=mv;var xv=`TabsList`,Sv=B.forwardRef((e,t)=>{let{__scopeTabs:n,loop:r=!0,...i}=e,a=yv(xv,n),o=_v(n);return(0,V.jsx)(mh,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:r,children:(0,V.jsx)(Hl.div,{role:`tablist`,"aria-orientation":a.orientation,...i,ref:t})})});Sv.displayName=xv;var Cv=`TabsTrigger`,wv=B.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,disabled:i=!1,...a}=e,o=yv(Cv,n),s=_v(n),c=Dv(o.baseId,r),l=Ov(o.baseId,r),u=r===o.value;return(0,V.jsx)(hh,{asChild:!0,...s,focusable:!i,active:u,children:(0,V.jsx)(Hl.button,{type:`button`,role:`tab`,"aria-selected":u,"aria-controls":l,"data-state":u?`active`:`inactive`,"data-disabled":i?``:void 0,disabled:i,id:c,...a,ref:t,onMouseDown:U(e.onMouseDown,e=>{!i&&e.button===0&&e.ctrlKey===!1?o.onValueChange(r):e.preventDefault()}),onKeyDown:U(e.onKeyDown,e=>{[` `,`Enter`].includes(e.key)&&o.onValueChange(r)}),onFocus:U(e.onFocus,()=>{let e=o.activationMode!==`manual`;!u&&!i&&e&&o.onValueChange(r)})})})});wv.displayName=Cv;var Tv=`TabsContent`,Ev=B.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,forceMount:i,children:a,...o}=e,s=yv(Tv,n),c=Dv(s.baseId,r),l=Ov(s.baseId,r),u=r===s.value,d=B.useRef(u);return B.useEffect(()=>{let e=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,V.jsx)($l,{present:i||u,children:({present:n})=>(0,V.jsx)(Hl.div,{"data-state":u?`active`:`inactive`,"data-orientation":s.orientation,role:`tabpanel`,"aria-labelledby":c,hidden:!n,id:l,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:d.current?`0s`:void 0},children:n&&a})})});Ev.displayName=Tv;function Dv(e,t){return`${e}-trigger-${t}`}function Ov(e,t){return`${e}-content-${t}`}var kv=bv,Av=Sv,jv=wv,Mv=Ev,Nv=e(t(((e,t)=>{(function(){var n=this,r={};e===void 0?n.fuzzy=r:t.exports=r,r.simpleFilter=function(e,t){return t.filter(function(t){return r.test(e,t)})},r.test=function(e,t){return r.match(e,t)!==null},r.match=function(e,t,n){n||={};var r=0,i=[],a=t.length,o=0,s=0,c=n.pre||``,l=n.post||``,u=n.caseSensitive&&t||t.toLowerCase(),d;e=n.caseSensitive&&e||e.toLowerCase();for(var f=0;f<a;f++)d=t[f],u[f]===e[r]?(d=c+d+l,r+=1,s+=1+s):s=0,o+=s,i[i.length]=d;return r===e.length?(o=u===e?1/0:o,{rendered:i.join(``),score:o}):null},r.filter=function(e,t,n){return!t||t.length===0?[]:typeof e==`string`?(n||={},t.reduce(function(t,i,a,o){var s=i;n.extract&&(s=n.extract(i));var c=r.match(e,s,n);return c!=null&&(t[t.length]={string:c.rendered,score:c.score,index:a,original:i}),t},[]).sort(function(e,t){return t.score-e.score||e.index-t.index})):t}})()}))(),1);function Pv(e,t){return(e[0]-t[0])**2+(e[1]-t[1])**2}function Fv(e,t,n){let r=Pv(t,n);if(r===0)return Pv(e,t);let i=((e[0]-t[0])*(n[0]-t[0])+(e[1]-t[1])*(n[1]-t[1]))/r;return i=Math.max(0,Math.min(1,i)),Pv(e,Iv(t,n,i))}function Iv(e,t,n){return[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n]}function Lv(e,t){return Rv(e,0,e.length,t)}function Rv(e,t,n,r,i){let a=i||[],o=e[t],s=e[n-1],c=0,l=1;for(let r=t+1;r<n-1;++r){let t=Fv(e[r],o,s);t>c&&(c=t,l=r)}return Math.sqrt(c)>r?(Rv(e,t,l+1,r,a),Rv(e,l,n,r,a)):(a.length||a.push(o),a.push(s)),a}function zv(e,t,n,r=e=>e){return e*r(.5-t*(.5-n))}function Bv(e){return[-e[0],-e[1]]}function Vv(e,t){return[e[0]+t[0],e[1]+t[1]]}function Hv(e,t){return[e[0]-t[0],e[1]-t[1]]}function Uv(e,t){return[e[0]*t,e[1]*t]}function Wv(e,t){return[e[0]/t,e[1]/t]}function Gv(e){return[e[1],-e[0]]}function Kv(e,t){return e[0]*t[0]+e[1]*t[1]}function qv(e,t){return e[0]===t[0]&&e[1]===t[1]}function Jv(e){return Math.hypot(e[0],e[1])}function Yv(e){return e[0]*e[0]+e[1]*e[1]}function Xv(e,t){return Yv(Hv(e,t))}function Zv(e){return Wv(e,Jv(e))}function Qv(e,t){return Math.hypot(e[1]-t[1],e[0]-t[0])}function $v(e,t,n){let r=Math.sin(n),i=Math.cos(n),a=e[0]-t[0],o=e[1]-t[1],s=a*i-o*r,c=a*r+o*i;return[s+t[0],c+t[1]]}function ey(e,t,n){return Vv(e,Uv(Hv(t,e),n))}function ty(e,t,n){return Vv(e,Uv(t,n))}var{min:ny,PI:ry}=Math,iy=.275,ay=ry+1e-4;function oy(e,t={}){let{size:n=16,smoothing:r=.5,thinning:i=.5,simulatePressure:a=!0,easing:o=e=>e,start:s={},end:c={},last:l=!1}=t,{cap:u=!0,easing:d=e=>e*(2-e)}=s,{cap:f=!0,easing:p=e=>--e*e*e+1}=c;if(e.length===0||n<=0)return[];let m=e[e.length-1].runningLength,h=s.taper===!1?0:s.taper===!0?Math.max(n,m):s.taper,g=c.taper===!1?0:c.taper===!0?Math.max(n,m):c.taper,_=(n*r)**2,v=[],y=[],b=e.slice(0,10).reduce((e,t)=>{let r=t.pressure;if(a){let i=ny(1,t.distance/n);r=ny(1,e+(ny(1,1-i)-e)*(i*iy))}return(e+r)/2},e[0].pressure),x=zv(n,i,e[e.length-1].pressure,o),S,C=e[0].vector,w=e[0].point,T=w,E=w,D=T,O=!1;for(let t=0;t<e.length;t++){let{pressure:r}=e[t],{point:s,vector:c,distance:l,runningLength:u}=e[t];if(t<e.length-1&&m-u<3)continue;if(i){if(a){let e=ny(1,l/n),t=ny(1,1-e);r=ny(1,b+(t-b)*(e*iy))}x=zv(n,i,r,o)}else x=n/2;S===void 0&&(S=x);let f=u<h?d(u/h):1,ee=m-u<g?p((m-u)/g):1;x=Math.max(.01,x*Math.min(f,ee));let k=(t<e.length-1?e[t+1]:e[t]).vector,te=t<e.length-1?Kv(c,k):1,ne=Kv(c,C)<0&&!O,re=te!==null&&te<0;if(ne||re){let e=Uv(Gv(C),x);for(let t=0;t<=1;t+=.07692307692307693)E=$v(Hv(s,e),s,ay*t),v.push(E),D=$v(Vv(s,e),s,ay*-t),y.push(D);w=E,T=D,re&&(O=!0);continue}if(O=!1,t===e.length-1){let e=Uv(Gv(c),x);v.push(Hv(s,e)),y.push(Vv(s,e));continue}let ie=Uv(Gv(ey(k,c,te)),x);E=Hv(s,ie),(t<=1||Xv(w,E)>_)&&(v.push(E),w=E),D=Vv(s,ie),(t<=1||Xv(T,D)>_)&&(y.push(D),T=D),b=r,C=c}let ee=e[0].point.slice(0,2),k=e.length>1?e[e.length-1].point.slice(0,2):Vv(e[0].point,[1,1]),te=[],ne=[];if(e.length===1){if(!(h||g)||l){let e=ty(ee,Zv(Gv(Hv(ee,k))),-(S||x)),t=[];for(let n=1/13,r=n;r<=1;r+=n)t.push($v(e,ee,ay*2*r));return t}}else{if(!(h||g&&e.length===1)){if(u)for(let e=1/13,t=e;t<=1;t+=e){let e=$v(y[0],ee,ay*t);te.push(e)}else{let e=Hv(v[0],y[0]),t=Uv(e,.5),n=Uv(e,.51);te.push(Hv(ee,t),Hv(ee,n),Vv(ee,n),Vv(ee,t))}}let t=Gv(Bv(e[e.length-1].vector));if(g||h&&e.length===1)ne.push(k);else if(f){let e=ty(k,t,x);for(let t=1/29,n=t;n<1;n+=t)ne.push($v(e,k,ay*3*n))}else ne.push(Vv(k,Uv(t,x)),Vv(k,Uv(t,x*.99)),Hv(k,Uv(t,x*.99)),Hv(k,Uv(t,x)))}return v.concat(ne,y.reverse(),te)}function sy(e,t={}){let{streamline:n=.5,size:r=16,last:i=!1}=t;if(e.length===0)return[];let a=.15+(1-n)*.85,o=Array.isArray(e[0])?e:e.map(({x:e,y:t,pressure:n=.5})=>[e,t,n]);if(o.length===2){let e=o[1];o=o.slice(0,-1);for(let t=1;t<5;t++)o.push(ey(o[0],e,t/4))}o.length===1&&(o=[...o,[...Vv(o[0],[1,1]),...o[0].slice(2)]]);let s=[{point:[o[0][0],o[0][1]],pressure:o[0][2]>=0?o[0][2]:.25,vector:[1,1],distance:0,runningLength:0}],c=!1,l=0,u=s[0],d=o.length-1;for(let e=1;e<o.length;e++){let t=i&&e===d?o[e].slice(0,2):ey(u.point,o[e],a);if(qv(u.point,t))continue;let n=Qv(t,u.point);if(l+=n,e<d&&!c){if(l<r)continue;c=!0}u={point:t,pressure:o[e][2]>=0?o[e][2]:.5,vector:Zv(Hv(u.point,t)),distance:n,runningLength:l},s.push(u)}return s[0].vector=s[1]?.vector||[0,0],s}function cy(e,t={}){return oy(sy(e,t),t)}var ly=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{n.clear()}},o=t=e(r,i,a);return a},uy=e=>e?ly(e):ly,dy=t((e=>{var t=Nc(),n=uf();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p}})),fy=e(t(((e,t)=>{t.exports=dy()}))(),1),{useDebugValue:py}=B.default,{useSyncExternalStoreWithSelector:my}=fy.default,hy=e=>e;function gy(e,t=hy,n){let r=my(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return py(r),r}var _y=e=>{let t=typeof e==`function`?uy(e):e,n=(e,n)=>gy(t,e,n);return Object.assign(n,t),n},vy=e=>e?_y(e):_y,yy,by=typeof window<`u`&&((yy=window.document)!=null&&yy.createElement||window.navigator?.product===`ReactNative`)?B.useLayoutEffect:B.useEffect;function xy(){let e=vy(e=>({current:[],version:0,set:e}));return{In:({children:t})=>{let n=e(e=>e.set),r=e(e=>e.version);return by(()=>{n(e=>({version:e.version+1}))},[]),by(()=>(n(({current:e})=>({current:[...e,t]})),()=>n(({current:e})=>({current:e.filter(e=>e!==t)}))),[t,r]),null},Out:()=>{let t=e(e=>e.current);return B.createElement(B.Fragment,null,t)}}}var Sy=e(t(((e,t)=>{var n=NaN,r=/^\s+|\s+$/g,i=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,o=/^0o[0-7]+$/i,s=parseInt,c=typeof global==`object`&&global&&global.Object===Object&&global,l=typeof self==`object`&&self&&self.Object===Object&&self,u=c||l||Function(`return this`)(),d=Object.prototype.toString,f=Math.max,p=Math.min,m=function(){return u.Date.now()};function h(e,t,n){var r,i,a,o,s,c,l=0,u=!1,d=!1,h=!0;if(typeof e!=`function`)throw TypeError(`Expected a function`);t=y(t)||0,g(n)&&(u=!!n.leading,d=`maxWait`in n,a=d?f(y(n.maxWait)||0,t):a,h=`trailing`in n?!!n.trailing:h);function _(t){var n=r,a=i;return r=i=void 0,l=t,o=e.apply(a,n),o}function v(e){return l=e,s=setTimeout(S,t),u?_(e):o}function b(e){var n=e-c,r=e-l,i=t-n;return d?p(i,a-r):i}function x(e){var n=e-c,r=e-l;return c===void 0||n>=t||n<0||d&&r>=a}function S(){var e=m();if(x(e))return C(e);s=setTimeout(S,b(e))}function C(e){return s=void 0,h&&r?_(e):(r=i=void 0,o)}function w(){s!==void 0&&clearTimeout(s),l=0,r=c=i=s=void 0}function T(){return s===void 0?o:C(m())}function E(){var e=m(),n=x(e);if(r=arguments,i=this,c=e,n){if(s===void 0)return v(c);if(d)return s=setTimeout(S,t),_(c)}return s===void 0&&(s=setTimeout(S,t)),o}return E.cancel=w,E.flush=T,E}function g(e){var t=typeof e;return!!e&&(t==`object`||t==`function`)}function _(e){return!!e&&typeof e==`object`}function v(e){return typeof e==`symbol`||_(e)&&d.call(e)==`[object Symbol]`}function y(e){if(typeof e==`number`)return e;if(v(e))return n;if(g(e)){var t=typeof e.valueOf==`function`?e.valueOf():e;e=g(t)?t+``:t}if(typeof e!=`string`)return e===0?e:+e;e=e.replace(r,``);var c=a.test(e);return c||o.test(e)?s(e.slice(2),c?2:8):i.test(e)?n:+e}t.exports=h}))(),1),Cy=Al(),{useAtom:wy,useSetAtom:Ty,useAtomValue:Ey,useStore:Dy}=Cy,Oy=Cy.Provider,ky=pl(),Ay=jc({"./locales/ar-SA.json":()=>n(()=>import(`./ar-SA-PQUY64WN-xjXgbW6d.js`),__vite__mapDeps([0,1,2]),import.meta.url),"./locales/az-AZ.json":()=>n(()=>import(`./az-AZ-OXJXL76K-4JkO4Pca.js`),__vite__mapDeps([3,1,2]),import.meta.url),"./locales/bg-BG.json":()=>n(()=>import(`./bg-BG-W2GKIJDF-DnkH_o81.js`),__vite__mapDeps([4,1,2]),import.meta.url),"./locales/bn-BD.json":()=>n(()=>import(`./bn-BD-TGL7M4PJ-CG4JkmtP.js`),__vite__mapDeps([5,1,2]),import.meta.url),"./locales/bn-IN.json":()=>n(()=>import(`./bn-IN-BKETKYEH-CG4JkmtP.js`),__vite__mapDeps([6,1,2]),import.meta.url),"./locales/ca-ES.json":()=>n(()=>import(`./ca-ES-LD5SCRVV-U6_TVMX9.js`),__vite__mapDeps([7,1,2]),import.meta.url),"./locales/cs-CZ.json":()=>n(()=>import(`./cs-CZ-OFPU5DBV-BmFAIhqX.js`),__vite__mapDeps([8,1,2]),import.meta.url),"./locales/da-DK.json":()=>n(()=>import(`./da-DK-FRDJFYWF-H387Jw8B.js`),__vite__mapDeps([9,1,2]),import.meta.url),"./locales/de-CH.json":()=>n(()=>import(`./de-CH-ZG7H3QK3-C_groygo.js`),__vite__mapDeps([10,1,2]),import.meta.url),"./locales/de-DE.json":()=>n(()=>import(`./de-DE-SIJYH4IH-C_groygo.js`),__vite__mapDeps([11,1,2]),import.meta.url),"./locales/el-GR.json":()=>n(()=>import(`./el-GR-IEE2CGI2-BkT6YT54.js`),__vite__mapDeps([12,1,2]),import.meta.url),"./locales/en.json":()=>n(()=>import(`./en-7NFCYGKX-BrgYZAEe.js`),__vite__mapDeps([13,1,2,14]),import.meta.url),"./locales/es-ES.json":()=>n(()=>import(`./es-ES-TVVPWKV5-CpPKJXTM.js`),__vite__mapDeps([15,1,2]),import.meta.url),"./locales/eu-ES.json":()=>n(()=>import(`./eu-ES-CGBMFQDT-Bu3N2493.js`),__vite__mapDeps([16,1,2]),import.meta.url),"./locales/fa-IR.json":()=>n(()=>import(`./fa-IR-IE6XAPR4-BEvLCORD.js`),__vite__mapDeps([17,1,2]),import.meta.url),"./locales/fi-FI.json":()=>n(()=>import(`./fi-FI-P7TKNHRM-DI0q8iSX.js`),__vite__mapDeps([18,1,2]),import.meta.url),"./locales/fr-FR.json":()=>n(()=>import(`./fr-FR-QI2XZNT7-y8kXd8LA.js`),__vite__mapDeps([19,1,2]),import.meta.url),"./locales/gl-ES.json":()=>n(()=>import(`./gl-ES-TLYCNOZZ-Br-Fhff-.js`),__vite__mapDeps([20,1,2]),import.meta.url),"./locales/he-IL.json":()=>n(()=>import(`./he-IL-ZX43XLGP-qKQq6V9X.js`),__vite__mapDeps([21,1,2]),import.meta.url),"./locales/hi-IN.json":()=>n(()=>import(`./hi-IN-UTYRMTUF-DOUcwrDO.js`),__vite__mapDeps([22,1,2]),import.meta.url),"./locales/hu-HU.json":()=>n(()=>import(`./hu-HU-AJOSEBW6-FqTyvHlD.js`),__vite__mapDeps([23,1,2]),import.meta.url),"./locales/id-ID.json":()=>n(()=>import(`./id-ID-ETLTVG6C-CQqh3CLS.js`),__vite__mapDeps([24,1,2]),import.meta.url),"./locales/it-IT.json":()=>n(()=>import(`./it-IT-B4B6TP6L-V-yK3SZz.js`),__vite__mapDeps([25,1,2]),import.meta.url),"./locales/ja-JP.json":()=>n(()=>import(`./ja-JP-IYKVURR5-BQKBXRpX.js`),__vite__mapDeps([26,1,2]),import.meta.url),"./locales/kaa.json":()=>n(()=>import(`./kaa-SE2BUIKX-CZ5kfwPg.js`),__vite__mapDeps([27,1,2]),import.meta.url),"./locales/kab-KAB.json":()=>n(()=>import(`./kab-KAB-Y3GLKXLR-Do7GWfuN.js`),__vite__mapDeps([28,1,2]),import.meta.url),"./locales/kk-KZ.json":()=>n(()=>import(`./kk-KZ-ABWUFVOH-BpqVciQz.js`),__vite__mapDeps([29,1,2]),import.meta.url),"./locales/km-KH.json":()=>n(()=>import(`./km-KH-PCWDKPHP-DSmy5shj.js`),__vite__mapDeps([30,1,2]),import.meta.url),"./locales/ko-KR.json":()=>n(()=>import(`./ko-KR-7JQDXKGM-N42lep78.js`),__vite__mapDeps([31,1,2]),import.meta.url),"./locales/ku-TR.json":()=>n(()=>import(`./ku-TR-NAH2Q5B7-K8LLl9fk.js`),__vite__mapDeps([32,1,2]),import.meta.url),"./locales/lt-LT.json":()=>n(()=>import(`./lt-LT-VQFYRSNQ-BmOd0ALn.js`),__vite__mapDeps([33,1,2]),import.meta.url),"./locales/lv-LV.json":()=>n(()=>import(`./lv-LV-T62VSYUM-B22WdPhp.js`),__vite__mapDeps([34,1,2]),import.meta.url),"./locales/mr-IN.json":()=>n(()=>import(`./mr-IN-V4FHLCJE-XX069tpm.js`),__vite__mapDeps([35,1,2]),import.meta.url),"./locales/my-MM.json":()=>n(()=>import(`./my-MM-E3SQ6E54-cst_-5SB.js`),__vite__mapDeps([36,1,2]),import.meta.url),"./locales/nb-NO.json":()=>n(()=>import(`./nb-NO-MLNOFN5H-Bu2URWko.js`),__vite__mapDeps([37,1,2]),import.meta.url),"./locales/nl-NL.json":()=>n(()=>import(`./nl-NL-D5L3ZV4M-BqrV0btt.js`),__vite__mapDeps([38,1,2]),import.meta.url),"./locales/nn-NO.json":()=>n(()=>import(`./nn-NO-NNHDGPKB-DK-xZaWM.js`),__vite__mapDeps([39,1,2]),import.meta.url),"./locales/oc-FR.json":()=>n(()=>import(`./oc-FR-DWCRF55G-BZ5Po5R6.js`),__vite__mapDeps([40,1,2]),import.meta.url),"./locales/pa-IN.json":()=>n(()=>import(`./pa-IN-3JSAY44M-BZQSjKrS.js`),__vite__mapDeps([41,1,2]),import.meta.url),"./locales/percentages.json":()=>n(()=>import(`./percentages-ETZPVQEE-DFxFqXgH.js`),__vite__mapDeps([42,1,2,43]),import.meta.url),"./locales/pl-PL.json":()=>n(()=>import(`./pl-PL-ACURYKP3-qcEOSfCk.js`),__vite__mapDeps([44,1,2]),import.meta.url),"./locales/pt-BR.json":()=>n(()=>import(`./pt-BR-LOX7MLGD-DLueHSyZ.js`),__vite__mapDeps([45,1,2]),import.meta.url),"./locales/pt-PT.json":()=>n(()=>import(`./pt-PT-CZ2U2RFQ-BJ-GAEm6.js`),__vite__mapDeps([46,1,2]),import.meta.url),"./locales/ro-RO.json":()=>n(()=>import(`./ro-RO-2HECL2X6-CJUvKAf0.js`),__vite__mapDeps([47,1,2]),import.meta.url),"./locales/ru-RU.json":()=>n(()=>import(`./ru-RU-HAYNXO46-BWSlvTrt.js`),__vite__mapDeps([48,1,2]),import.meta.url),"./locales/si-LK.json":()=>n(()=>import(`./si-LK-W5KNS4H6-DGGCsn7k.js`),__vite__mapDeps([49,1,2]),import.meta.url),"./locales/sk-SK.json":()=>n(()=>import(`./sk-SK-7K2CFGDV-CY4uTYgQ.js`),__vite__mapDeps([50,1,2]),import.meta.url),"./locales/sl-SI.json":()=>n(()=>import(`./sl-SI-OXV2QZWW-2-weqaBY.js`),__vite__mapDeps([51,1,2]),import.meta.url),"./locales/sv-SE.json":()=>n(()=>import(`./sv-SE-JTOBZRGL-9-IUtVkO.js`),__vite__mapDeps([52,1,2]),import.meta.url),"./locales/ta-IN.json":()=>n(()=>import(`./ta-IN-KFAVKXGT-gHO6Q_DH.js`),__vite__mapDeps([53,1,2]),import.meta.url),"./locales/th-TH.json":()=>n(()=>import(`./th-TH-VDMSCPDL-BvJuw6PJ.js`),__vite__mapDeps([54,1,2]),import.meta.url),"./locales/tr-TR.json":()=>n(()=>import(`./tr-TR-CEZ6GX45-CG6UU3Su.js`),__vite__mapDeps([55,1,2]),import.meta.url),"./locales/uk-UA.json":()=>n(()=>import(`./uk-UA-Q3H3OXQC-CSuIg_DY.js`),__vite__mapDeps([56,1,2]),import.meta.url),"./locales/uz-UZ.json":()=>n(()=>import(`./uz-UZ-NGCSWWPX-mom7rxSP.js`),__vite__mapDeps([57,1,2]),import.meta.url),"./locales/vi-VN.json":()=>n(()=>import(`./vi-VN-P3NDEVPS-BB0Fu9ck.js`),__vite__mapDeps([58,1,2]),import.meta.url),"./locales/zh-CN.json":()=>n(()=>import(`./zh-CN-SS3O57GA-Bj8wsiMe.js`),__vite__mapDeps([59,1,2]),import.meta.url),"./locales/zh-HK.json":()=>n(()=>import(`./zh-HK-LWJT3VCF-DOTquTCh.js`),__vite__mapDeps([60,1,2]),import.meta.url),"./locales/zh-TW.json":()=>n(()=>import(`./zh-TW-VJXC72RT-B48PRo-l.js`),__vite__mapDeps([61,1,2]),import.meta.url)}),jy=85,My={code:`en`,label:`English`},Ny=[My,...[{code:`ar-SA`,label:`العربية`,rtl:!0},{code:`bg-BG`,label:`Български`},{code:`ca-ES`,label:`Català`},{code:`cs-CZ`,label:`Česky`},{code:`de-DE`,label:`Deutsch`},{code:`el-GR`,label:`Ελληνικά`},{code:`es-ES`,label:`Español`},{code:`eu-ES`,label:`Euskara`},{code:`fa-IR`,label:`فارسی`,rtl:!0},{code:`fi-FI`,label:`Suomi`},{code:`fr-FR`,label:`Français`},{code:`gl-ES`,label:`Galego`},{code:`he-IL`,label:`עברית`,rtl:!0},{code:`hi-IN`,label:`हिन्दी`},{code:`hu-HU`,label:`Magyar`},{code:`id-ID`,label:`Bahasa Indonesia`},{code:`it-IT`,label:`Italiano`},{code:`ja-JP`,label:`日本語`},{code:`kab-KAB`,label:`Taqbaylit`},{code:`kk-KZ`,label:`Қазақ тілі`},{code:`ko-KR`,label:`한국어`},{code:`ku-TR`,label:`Kurdî`},{code:`lt-LT`,label:`Lietuvių`},{code:`lv-LV`,label:`Latviešu`},{code:`my-MM`,label:`Burmese`},{code:`nb-NO`,label:`Norsk bokmål`},{code:`nl-NL`,label:`Nederlands`},{code:`nn-NO`,label:`Norsk nynorsk`},{code:`oc-FR`,label:`Occitan`},{code:`pa-IN`,label:`ਪੰਜਾਬੀ`},{code:`pl-PL`,label:`Polski`},{code:`pt-BR`,label:`Português Brasileiro`},{code:`pt-PT`,label:`Português`},{code:`ro-RO`,label:`Română`},{code:`ru-RU`,label:`Русский`},{code:`sk-SK`,label:`Slovenčina`},{code:`sv-SE`,label:`Svenska`},{code:`sl-SI`,label:`Slovenščina`},{code:`tr-TR`,label:`Türkçe`},{code:`uk-UA`,label:`Українська`},{code:`zh-CN`,label:`简体中文`},{code:`zh-TW`,label:`繁體中文`},{code:`vi-VN`,label:`Tiếng Việt`},{code:`mr-IN`,label:`मराठी`}].filter(e=>Ic[e.code]>=jy).sort((e,t)=>e.label>t.label?1:-1)],Py=`__test__`;ci()&&Ny.unshift({code:Py,label:`test language`},{code:`${Py}.rtl`,label:`test language (rtl)`,rtl:!0});var Fy=My,Iy={},Ly=async e=>{if(Fy=e,document.documentElement.dir=Fy.rtl?`rtl`:`ltr`,document.documentElement.lang=Fy.code,e.code.startsWith(Py))Iy={};else try{Iy=await Ay(`./locales/${Fy.code}.json`)}catch(t){console.error(`Failed to load language ${e.code}:`,t.message),Iy=Fc}ky.set(By,e.code)},Ry=()=>Fy,zy=(e,t)=>{for(let n=0;n<t.length;++n){let r=t[n];if(e[r]===void 0)return;e=e[r]}if(typeof e==`string`)return e},W=(e,t,n)=>{if(Fy.code.startsWith(Py))return`\u202A[[${t?`${e}(${JSON.stringify(t).slice(1,-1)})`:e}]]\u202C`;let r=e.split(`.`),i=zy(Iy,r)||zy(Fc,r)||n;if(i===void 0){let t=`Can't find translation for ${e}`;if(ne.PROD)return console.warn(t),``;throw Error(t)}if(t)for(let e in t)i=i.replace(`{{${e}}}`,String(t[e]));return i},By=Gc(My.code),Vy=()=>({t:W,langCode:Ey(By)}),Hy=e=>`var(--icon-fill-color)`,Uy=e=>e===A.LIGHT?`#fff`:`#1e1e1e`,G=(e,t=512)=>{let{width:n=512,height:r=n,mirror:i,style:a,...o}=typeof t==`number`?{width:t}:t;return(0,V.jsx)(`svg`,{"aria-hidden":`true`,focusable:`false`,role:`img`,viewBox:`0 0 ${n} ${r}`,className:H({"rtl-mirror":i}),style:a,...o,children:typeof e==`string`?(0,V.jsx)(`path`,{fill:`currentColor`,d:e}):e})},K={width:24,height:24,fill:`none`,strokeWidth:2,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`},q={width:20,height:20,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`},Wy={width:40,height:20};G((0,V.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`rect`,{x:3,y:8,width:18,height:4,rx:1}),(0,V.jsx)(`line`,{x1:12,y1:8,x2:12,y2:21}),(0,V.jsx)(`path`,{d:`M19 12v7a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-7`}),(0,V.jsx)(`path`,{d:`M7.5 8a2.5 2.5 0 0 1 0 -5a4.8 8 0 0 1 4.5 5a4.8 8 0 0 1 4.5 -5a2.5 2.5 0 0 1 0 5`})]}),K);var Gy=G((0,V.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M3 19a9 9 0 0 1 9 0a9 9 0 0 1 9 0`}),(0,V.jsx)(`path`,{d:`M3 6a9 9 0 0 1 9 0a9 9 0 0 1 9 0`}),(0,V.jsx)(`line`,{x1:`3`,y1:`6`,x2:`3`,y2:`19`}),(0,V.jsx)(`line`,{x1:`12`,y1:`6`,x2:`12`,y2:`19`}),(0,V.jsx)(`line`,{x1:`21`,y1:`6`,x2:`21`,y2:`19`})]}),K),Ky=G((0,V.jsxs)(`svg`,{strokeWidth:`1.5`,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`line`,{x1:`12`,y1:`5`,x2:`12`,y2:`19`}),(0,V.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`})]}),K),qy=G((0,V.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1`}),(0,V.jsx)(`circle`,{cx:`12`,cy:`19`,r:`1`}),(0,V.jsx)(`circle`,{cx:`12`,cy:`5`,r:`1`})]}),K),Jy=G((0,V.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M5 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`}),(0,V.jsx)(`path`,{d:`M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`}),(0,V.jsx)(`path`,{d:`M19 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`})]}),K),Yy=G((0,V.jsxs)(`svg`,{strokeWidth:`1.5`,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M9 4v6l-2 4v2h10v-2l-2 -4v-6`}),(0,V.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12`,y2:`21`}),(0,V.jsx)(`line`,{x1:`8`,y1:`4`,x2:`16`,y2:`4`})]}),K),Xy=G((0,V.jsxs)(`g`,{strokeWidth:1.25,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M12 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,V.jsx)(`path`,{d:`M19 8m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,V.jsx)(`path`,{d:`M5 11m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,V.jsx)(`path`,{d:`M15 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,V.jsx)(`path`,{d:`M6.5 9.5l3.5 -3`}),(0,V.jsx)(`path`,{d:`M14 5.5l3 1.5`}),(0,V.jsx)(`path`,{d:`M18.5 10l-2.5 7`}),(0,V.jsx)(`path`,{d:`M13.5 17.5l-7 -5`})]}),K),Zy=G((0,V.jsxs)(`g`,{children:[(0,V.jsx)(`path`,{d:`M13.542 8.542H6.458a2.5 2.5 0 0 0-2.5 2.5v3.75a2.5 2.5 0 0 0 2.5 2.5h7.084a2.5 2.5 0 0 0 2.5-2.5v-3.75a2.5 2.5 0 0 0-2.5-2.5Z`,stroke:`currentColor`,strokeWidth:`1.25`}),(0,V.jsx)(`path`,{d:`M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z`,stroke:`currentColor`,strokeWidth:`1.25`}),(0,V.jsx)(`mask`,{id:`UnlockedIcon`,style:{maskType:`alpha`},maskUnits:`userSpaceOnUse`,x:6,y:1,width:9,height:9,children:(0,V.jsx)(`path`,{stroke:`none`,d:`M6.399 9.561V5.175c0-.93.401-1.823 1.116-2.48a3.981 3.981 0 0 1 2.693-1.028c1.01 0 1.98.37 2.694 1.027.715.658 1.116 1.55 1.116 2.481`,fill:`#fff`})}),(0,V.jsx)(`g`,{mask:`url(#UnlockedIcon)`,children:(0,V.jsx)(`path`,{stroke:`none`,d:`M5.149 9.561v1.25h2.5v-1.25h-2.5Zm5.06-7.894V.417v1.25Zm2.559 3.508v1.25h2.5v-1.25h-2.5ZM7.648 8.51V5.175h-2.5V8.51h2.5Zm0-3.334c0-.564.243-1.128.713-1.561L6.668 1.775c-.959.883-1.52 2.104-1.52 3.4h2.5Zm.713-1.561a2.732 2.732 0 0 1 1.847-.697v-2.5c-1.31 0-2.585.478-3.54 1.358L8.36 3.614Zm1.847-.697c.71 0 1.374.26 1.847.697l1.694-1.839a5.231 5.231 0 0 0-3.54-1.358v2.5Zm1.847.697c.47.433.713.997.713 1.561h2.5c0-1.296-.56-2.517-1.52-3.4l-1.693 1.839Z`,fill:`currentColor`})})]}),q),Qy=G((0,V.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,V.jsx)(`path`,{d:`M13.542 8.542H6.458a2.5 2.5 0 0 0-2.5 2.5v3.75a2.5 2.5 0 0 0 2.5 2.5h7.084a2.5 2.5 0 0 0 2.5-2.5v-3.75a2.5 2.5 0 0 0-2.5-2.5Z`}),(0,V.jsx)(`path`,{d:`M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z`}),(0,V.jsx)(`path`,{d:`M6.667 8.333V5.417C6.667 3.806 8.159 2.5 10 2.5c1.841 0 3.333 1.306 3.333 2.917v2.916`})]}),q),$y=G((0,V.jsx)(`g`,{fill:`currentColor`,children:(0,V.jsx)(`path`,{d:`M12 2a5 5 0 0 1 5 5v3a3 3 0 0 1 3 3v6a3 3 0 0 1 -3 3h-10a3 3 0 0 1 -3 -3v-6a3 3 0 0 1 3 -3v-3a5 5 0 0 1 5 -5m0 12a2 2 0 0 0 -1.995 1.85l-.005 .15a2 2 0 1 0 2 -2m0 -10a3 3 0 0 0 -3 3v3h6v-3a3 3 0 0 0 -3 -3`})}),{width:24,height:24}),eb=G((0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M38.5 83.5c-14-2-17.833-10.473-21-22.5C14.333 48.984 12 22 12 12.5`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`}),(0,V.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`m12.005 10.478 7.905 14.423L6 25.75l6.005-15.273Z`,fill:`currentColor`}),(0,V.jsx)(`path`,{d:`M12.005 10.478c1.92 3.495 3.838 7 7.905 14.423m-7.905-14.423c3.11 5.683 6.23 11.368 7.905 14.423m0 0c-3.68.226-7.35.455-13.91.85m13.91-.85c-5.279.33-10.566.647-13.91.85m0 0c1.936-4.931 3.882-9.86 6.005-15.273M6 25.75c2.069-5.257 4.135-10.505 6.005-15.272`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`})]}),{width:41,height:94,fill:`none`}),tb=G((0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M18.026 1.232c-5.268 13.125-5.548 33.555 3.285 42.311 8.823 8.75 33.31 12.304 42.422 13.523`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`}),(0,V.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`m72.181 59.247-13.058-10-2.948 13.62 16.006-3.62Z`,fill:`currentColor`}),(0,V.jsx)(`path`,{d:`M72.181 59.247c-3.163-2.429-6.337-4.856-13.058-10m13.058 10c-5.145-3.936-10.292-7.882-13.058-10m0 0c-.78 3.603-1.563 7.196-2.948 13.62m2.948-13.62c-1.126 5.168-2.24 10.346-2.948 13.62m0 0c5.168-1.166 10.334-2.343 16.006-3.62m-16.006 3.62c5.51-1.248 11.01-2.495 16.006-3.62`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`})]}),{width:85,height:71,fill:`none`}),nb=G((0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M1 77c14-2 31.833-11.973 35-24 3.167-12.016-6-35-9.5-43.5`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`}),(0,V.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`m24.165 1.093-2.132 16.309 13.27-4.258-11.138-12.05Z`,fill:`currentColor`}),(0,V.jsx)(`path`,{d:`M24.165 1.093c-.522 3.953-1.037 7.916-2.132 16.309m2.131-16.309c-.835 6.424-1.68 12.854-2.13 16.308m0 0c3.51-1.125 7.013-2.243 13.27-4.257m-13.27 4.257c5.038-1.608 10.08-3.232 13.27-4.257m0 0c-3.595-3.892-7.197-7.777-11.14-12.05m11.14 12.05c-3.837-4.148-7.667-8.287-11.14-12.05`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`})]}),{width:38,height:78,fill:`none`});G((0,V.jsx)(`g`,{fill:`currentColor`,children:(0,V.jsx)(`path`,{d:`M39.9 32.889a.326.326 0 0 0-.279-.056c-2.094-3.083-4.774-6-7.343-8.833l-.419-.472a.212.212 0 0 0-.056-.139.586.586 0 0 0-.167-.111l-.084-.083-.056-.056c-.084-.167-.28-.278-.475-.167-.782.39-1.507.973-2.206 1.528-.92.722-1.842 1.445-2.708 2.25a8.405 8.405 0 0 0-.977 1.028c-.14.194-.028.361.14.444-.615.611-1.23 1.223-1.843 1.861a.315.315 0 0 0-.084.223c0 .083.056.166.111.194l1.09.833v.028c1.535 1.528 4.244 3.611 7.12 5.861.418.334.865.667 1.284 1 .195.223.39.473.558.695.084.11.28.139.391.055.056.056.14.111.196.167a.398.398 0 0 0 .167.056.255.255 0 0 0 .224-.111.394.394 0 0 0 .055-.167c.029 0 .028.028.056.028a.318.318 0 0 0 .224-.084l5.082-5.528a.309.309 0 0 0 0-.444Zm-14.63-1.917a.485.485 0 0 0 .111.14c.586.5 1.2 1 1.843 1.555l-2.569-1.945-.251-.166c-.056-.028-.112-.084-.168-.111l-.195-.167.056-.056.055-.055.112-.111c.866-.861 2.346-2.306 3.1-3.028-.81.805-2.43 3.167-2.095 3.944Zm8.767 6.89-2.122-1.612a44.713 44.713 0 0 0-2.625-2.5c1.145.861 2.122 1.611 2.262 1.75 1.117.972 1.06.806 1.815 1.445l.921.666a1.06 1.06 0 0 1-.251.25Zm.558.416-.056-.028c.084-.055.168-.111.252-.194l-.196.222ZM1.089 5.75c.055.361.14.722.195 1.056.335 1.833.67 3.5 1.284 4.75l.252.944c.084.361.223.806.363.917 1.424 1.25 3.602 3.11 5.947 4.889a.295.295 0 0 0 .363 0s0 .027.028.027a.254.254 0 0 0 .196.084.318.318 0 0 0 .223-.084c2.988-3.305 5.221-6.027 6.813-8.305.112-.111.14-.278.14-.417.111-.111.195-.25.307-.333.111-.111.111-.306 0-.39l-.028-.027c0-.055-.028-.139-.084-.167-.698-.666-1.2-1.138-1.731-1.638-.922-.862-1.871-1.75-3.881-3.75l-.028-.028c-.028-.028-.056-.056-.112-.056-.558-.194-1.703-.389-3.127-.639C6.087 2.223 3.21 1.723.614.944c0 0-.168 0-.196.028l-.083.084c-.028.027-.056.055-.224.11h.056-.056c.028.167.028.278.084.473 0 .055.112.5.112.555l.782 3.556Zm15.496 3.278-.335-.334c.084.112.196.195.335.334Zm-3.546 4.666-.056.056c0-.028.028-.056.056-.056Zm-2.038-10c.168.167.866.834 1.033.973-.726-.334-2.54-1.167-3.379-1.445.838.167 1.983.334 2.346.472ZM1.424 2.306c.419.722.754 3.222 1.089 5.666-.196-.778-.335-1.555-.503-2.278-.251-1.277-.503-2.416-.838-3.416.056 0 .14 0 .252.028Zm-.168-.584c-.112 0-.223-.028-.307-.028 0-.027 0-.055-.028-.055.14 0 .223.028.335.083Zm-1.089.222c0-.027 0-.027 0 0ZM39.453 1.333c.028-.11-.558-.61-.363-.639.42-.027.42-.666 0-.666-.558.028-1.144.166-1.675.25-.977.194-1.982.389-2.96.61-2.205.473-4.383.973-6.561 1.557-.67.194-1.424.333-2.066.666-.224.111-.196.333-.084.472-.056.028-.084.028-.14.056-.195.028-.363.056-.558.083-.168.028-.252.167-.224.334 0 .027.028.083.028.11-1.173 1.556-2.485 3.195-3.909 4.945-1.396 1.611-2.876 3.306-4.356 5.056-4.719 5.5-10.052 11.75-15.943 17.25a.268.268 0 0 0 0 .389c.028.027.056.055.084.055-.084.084-.168.14-.252.222-.056.056-.084.111-.084.167a.605.605 0 0 0-.111.139c-.112.111-.112.305.028.389.111.11.307.11.39-.028.029-.028.029-.056.056-.056a.44.44 0 0 1 .615 0c.335.362.67.723.977 1.028l-.698-.583c-.112-.111-.307-.083-.39.028-.113.11-.085.305.027.389l7.427 6.194c.056.056.112.056.196.056s.14-.028.195-.084l.168-.166c.028.027.083.027.111.027.084 0 .14-.027.196-.083 10.052-10.055 18.15-17.639 27.42-24.417.083-.055.111-.166.111-.25.112 0 .196-.083.251-.194 1.704-5.194 2.039-9.806 2.15-12.083v-.028c0-.028.028-.056.028-.083.028-.056.028-.084.028-.084a1.626 1.626 0 0 0-.111-1.028ZM21.472 9.5c.446-.5.893-1.028 1.34-1.5-2.876 3.778-7.65 9.583-14.408 16.5 4.607-5.083 9.242-10.333 13.068-15ZM5.193 35.778h.084-.084Zm3.462 3.194c-.027-.028-.027-.028 0-.028v.028Zm4.16-3.583c.224-.25.448-.472.699-.722 0 0 0 .027.028.027-.252.223-.475.445-.726.695Zm1.146-1.111c.14-.14.279-.334.446-.5l.028-.028c1.648-1.694 3.351-3.389 5.082-5.111l.028-.028c.419-.333.921-.694 1.368-1.028a379.003 379.003 0 0 0-6.952 6.695ZM24.794 6.472c-.921 1.195-1.954 2.778-2.82 4.028-2.736 3.944-11.532 13.583-11.727 13.75a1976.983 1976.983 0 0 1-8.042 7.639l-.167.167c-.14-.167-.14-.417.028-.556C14.49 19.861 22.03 10.167 25.074 5.917c-.084.194-.14.36-.28.555Zm4.83 5.695c-1.116-.64-1.646-1.64-1.34-2.611l.084-.334c.028-.083.084-.194.14-.277.307-.5.754-.917 1.257-1.167.027 0 .055 0 .083-.028-.028-.056-.028-.139-.028-.222.028-.167.14-.278.335-.278.335 0 1.369.306 1.76.639.111.083.223.194.335.305.14.167.363.445.474.667.056.028.112.306.196.445.056.222.111.472.084.694-.028.028 0 .194-.028.194a2.668 2.668 0 0 1-.363 1.028c-.028.028-.028.056-.056.084l-.028.027c-.14.223-.335.417-.53.556-.643.444-1.369.583-2.095.389 0 0-.195-.084-.28-.111Zm8.154-.834a39.098 39.098 0 0 1-.893 3.167c0 .028-.028.083 0 .111-.056 0-.084.028-.14.056-2.206 1.61-4.356 3.305-6.506 5.028 1.843-1.64 3.686-3.306 5.613-4.945.558-.5.949-1.139 1.06-1.861l.28-1.667v-.055c.14-.334.67-.195.586.166Z`,fill:`currentColor`})}),{width:40,height:40,fill:`none`});var rb=G((0,V.jsxs)(`g`,{stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M6 6l4.153 11.793a0.365 .365 0 0 0 .331 .207a0.366 .366 0 0 0 .332 -.207l2.184 -4.793l4.787 -1.994a0.355 .355 0 0 0 .213 -.323a0.355 .355 0 0 0 -.213 -.323l-11.787 -4.36z`}),(0,V.jsx)(`path`,{d:`M13.5 13.5l4.5 4.5`})]}),{fill:`none`,width:22,height:22,strokeWidth:1.25}),ib=G((0,V.jsxs)(`g`,{stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.5,children:[(0,V.jsx)(`path`,{d:`M4.028 13.252c-.657 -.972 -1.028 -2.078 -1.028 -3.252c0 -3.866 4.03 -7 9 -7s9 3.134 9 7s-4.03 7 -9 7c-1.913 0 -3.686 -.464 -5.144 -1.255`}),(0,V.jsx)(`path`,{d:`M5 15m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,V.jsx)(`path`,{d:`M5 17c0 1.42 .316 2.805 1 4`})]}),{fill:`none`,width:22,height:22,strokeWidth:1.25}),ab=G((0,V.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`})]}),K),ob=G((0,V.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M10.5 20.4l-6.9 -6.9c-.781 -.781 -.781 -2.219 0 -3l6.9 -6.9c.781 -.781 2.219 -.781 3 0l6.9 6.9c.781 .781 .781 2.219 0 3l-6.9 6.9c-.781 .781 -2.219 .781 -3 0z`})]}),K),sb=G((0,V.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`})]}),K),cb=G((0,V.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,V.jsx)(`line`,{x1:`15`,y1:`16`,x2:`19`,y2:`12`}),(0,V.jsx)(`line`,{x1:`15`,y1:`8`,x2:`19`,y2:`12`})]}),K),lb=G((0,V.jsx)(`path`,{d:`M4.167 10h11.666`,strokeWidth:`1.5`}),q),ub=G((0,V.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M20 17v-12c0 -1.121 -.879 -2 -2 -2s-2 .879 -2 2v12l2 2l2 -2z`}),(0,V.jsx)(`path`,{d:`M16 7h4`}),(0,V.jsx)(`path`,{d:`M18 19h-13a2 2 0 1 1 0 -4h4a2 2 0 1 0 0 -4h-3`})]}),K),db=G((0,V.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,V.jsx)(`path`,{clipRule:`evenodd`,d:`m7.643 15.69 7.774-7.773a2.357 2.357 0 1 0-3.334-3.334L4.31 12.357a3.333 3.333 0 0 0-.977 2.357v1.953h1.953c.884 0 1.732-.352 2.357-.977Z`}),(0,V.jsx)(`path`,{d:`m11.25 5.417 3.333 3.333`})]}),q),fb=G((0,V.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`line`,{x1:`4`,y1:`20`,x2:`7`,y2:`20`}),(0,V.jsx)(`line`,{x1:`14`,y1:`20`,x2:`21`,y2:`20`}),(0,V.jsx)(`line`,{x1:`6.9`,y1:`15`,x2:`13.8`,y2:`15`}),(0,V.jsx)(`line`,{x1:`10.2`,y1:`6.3`,x2:`16`,y2:`20`}),(0,V.jsx)(`polyline`,{points:`5 20 11 4 13 4 20 20`})]}),K),pb=G((0,V.jsxs)(`g`,{stroke:`currentColor`,strokeWidth:`1.5`,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M3 7v-2h13v2`}),(0,V.jsx)(`path`,{d:`M10 5v14`}),(0,V.jsx)(`path`,{d:`M12 19h-4`}),(0,V.jsx)(`path`,{d:`M15 13v-1h6v1`}),(0,V.jsx)(`path`,{d:`M18 12v7`}),(0,V.jsx)(`path`,{d:`M17 19h2`})]}),K),mb=G((0,V.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,V.jsx)(`path`,{d:`M12.5 6.667h.01`}),(0,V.jsx)(`path`,{d:`M4.91 2.625h10.18a2.284 2.284 0 0 1 2.285 2.284v10.182a2.284 2.284 0 0 1-2.284 2.284H4.909a2.284 2.284 0 0 1-2.284-2.284V4.909a2.284 2.284 0 0 1 2.284-2.284Z`}),(0,V.jsx)(`path`,{d:`m3.333 12.5 3.334-3.333c.773-.745 1.726-.745 2.5 0l4.166 4.166`}),(0,V.jsx)(`path`,{d:`m11.667 11.667.833-.834c.774-.744 1.726-.744 2.5 0l1.667 1.667`})]}),q),hb=G((0,V.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M19 20h-10.5l-4.21 -4.3a1 1 0 0 1 0 -1.41l10 -10a1 1 0 0 1 1.41 0l5 5a1 1 0 0 1 0 1.41l-9.2 9.3`}),(0,V.jsx)(`path`,{d:`M18 13.3l-6.3 -6.3`})]}),K),gb=G((0,V.jsx)(`path`,{strokeWidth:`1.25`,d:`M10 4.167v11.666M4.167 10h11.666`}),q),_b=G((0,V.jsx)(`path`,{d:`M5 10h10`,strokeWidth:`1.25`}),q),vb=G((0,V.jsxs)(`g`,{strokeWidth:1.25,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M21 21l-6 -6`}),(0,V.jsx)(`path`,{d:`M3.268 12.043a7.017 7.017 0 0 0 6.634 4.957a7.012 7.012 0 0 0 7.043 -6.131a7 7 0 0 0 -5.314 -7.672a7.021 7.021 0 0 0 -8.241 4.403`}),(0,V.jsx)(`path`,{d:`M3 4v4h4`})]}),K),yb=G((0,V.jsx)(`path`,{strokeWidth:`1.25`,d:`M3.333 5.833h13.334M8.333 9.167v5M11.667 9.167v5M4.167 5.833l.833 10c0 .92.746 1.667 1.667 1.667h6.666c.92 0 1.667-.746 1.667-1.667l.833-10M7.5 5.833v-2.5c0-.46.373-.833.833-.833h3.334c.46 0 .833.373.833.833v2.5`}),q),bb=G((0,V.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,V.jsx)(`polyline`,{points:`12 16 18 10 12 4`}),(0,V.jsx)(`polyline`,{points:`8 4 2 10 8 16`})]}),q),xb=G((0,V.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,V.jsx)(`path`,{d:`M14.375 6.458H8.958a2.5 2.5 0 0 0-2.5 2.5v5.417a2.5 2.5 0 0 0 2.5 2.5h5.417a2.5 2.5 0 0 0 2.5-2.5V8.958a2.5 2.5 0 0 0-2.5-2.5Z`}),(0,V.jsx)(`path`,{clipRule:`evenodd`,d:`M11.667 3.125c.517 0 .986.21 1.325.55.34.338.55.807.55 1.325v1.458H8.333c-.485 0-.927.185-1.26.487-.343.312-.57.75-.609 1.24l-.005 5.357H5a1.87 1.87 0 0 1-1.326-.55 1.87 1.87 0 0 1-.549-1.325V5c0-.518.21-.987.55-1.326.338-.34.807-.549 1.325-.549h6.667Z`})]}),q),Sb=G((0,V.jsx)(`path`,{clipRule:`evenodd`,d:`M10 2.5h.328a6.25 6.25 0 0 0 6.6 10.372A7.5 7.5 0 1 1 10 2.493V2.5Z`,stroke:`currentColor`}),q),Cb=G((0,V.jsx)(`g`,{stroke:`currentColor`,strokeLinejoin:`round`,children:(0,V.jsx)(`path`,{d:`M10 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM10 4.167V2.5M14.167 5.833l1.166-1.166M15.833 10H17.5M14.167 14.167l1.166 1.166M10 15.833V17.5M5.833 14.167l-1.166 1.166M5 10H3.333M5.833 5.833 4.667 4.667`})}),{...q,strokeWidth:1.5}),wb=G((0,V.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`line`,{x1:`4`,y1:`6`,x2:`20`,y2:`6`}),(0,V.jsx)(`line`,{x1:`4`,y1:`12`,x2:`20`,y2:`12`}),(0,V.jsx)(`line`,{x1:`4`,y1:`18`,x2:`20`,y2:`18`})]}),K),Tb=G((0,V.jsx)(`path`,{strokeWidth:`1.25`,d:`M3.333 14.167v1.666c0 .92.747 1.667 1.667 1.667h10c.92 0 1.667-.746 1.667-1.667v-1.666M5.833 9.167 10 13.333l4.167-4.166M10 3.333v10`}),q),Eb=G((0,V.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,V.jsx)(`line`,{x1:`12`,y1:`17`,x2:`12`,y2:`17.01`}),(0,V.jsx)(`path`,{d:`M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4`})]}),K),Db=G((0,V.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,V.jsx)(`line`,{x1:`12`,y1:`17`,x2:`12`,y2:`17.01`}),(0,V.jsx)(`path`,{d:`M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4`})]}),K),Ob=G((0,V.jsx)(`path`,{strokeWidth:`1.25`,d:`M9.167 5.833H5.833c-1.254 0-2.5 1.282-2.5 2.5v5.834c0 1.283 1.252 2.5 2.5 2.5h5.834c1.251 0 2.5-1.25 2.5-2.5v-3.334M8.333 11.667l8.334-8.334M12.5 3.333h4.167V7.5`}),q),kb=G((0,V.jsx)(`path`,{d:`M7.5 15.833c-3.583 1.167-3.583-2.083-5-2.5m10 4.167v-2.917c0-.833.083-1.166-.417-1.666 2.334-.25 4.584-1.167 4.584-5a3.833 3.833 0 0 0-1.084-2.667 3.5 3.5 0 0 0-.083-2.667s-.917-.25-2.917 1.084a10.25 10.25 0 0 0-5.166 0C5.417 2.333 4.5 2.583 4.5 2.583a3.5 3.5 0 0 0-.083 2.667 3.833 3.833 0 0 0-1.084 2.667c0 3.833 2.25 4.75 4.584 5-.5.5-.5 1-.417 1.666V17.5`,strokeWidth:`1.25`}),q),Ab=G((0,V.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,V.jsx)(`path`,{d:`M7.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM12.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM6.25 6.25c2.917-.833 4.583-.833 7.5 0M5.833 13.75c2.917.833 5.417.833 8.334 0`}),(0,V.jsx)(`path`,{d:`M12.917 14.167c0 .833 1.25 2.5 1.666 2.5 1.25 0 2.361-1.39 2.917-2.5.556-1.39.417-4.861-1.25-9.584-1.214-.846-2.5-1.116-3.75-1.25l-.833 2.084M7.083 14.167c0 .833-1.13 2.5-1.526 2.5-1.191 0-2.249-1.39-2.778-2.5-.529-1.39-.397-4.861 1.19-9.584 1.157-.846 2.318-1.116 3.531-1.25l.833 2.084`})]}),q),jb=G((0,V.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M4 4l11.733 16h4.267l-11.733 -16z`}),(0,V.jsx)(`path`,{d:`M4 20l6.768 -6.768m2.46 -2.46l6.772 -6.772`})]}),K),Mb=G((0,V.jsx)(`polyline`,{fill:`none`,stroke:`currentColor`,points:`20 6 9 17 4 12`}),{width:24,height:24}),Nb=G((0,V.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,V.jsx)(`path`,{d:`M8.333 11.667a2.917 2.917 0 0 0 4.167 0l3.333-3.334a2.946 2.946 0 1 0-4.166-4.166l-.417.416`}),(0,V.jsx)(`path`,{d:`M11.667 8.333a2.917 2.917 0 0 0-4.167 0l-3.333 3.334a2.946 2.946 0 0 0 4.166 4.166l.417-.416`})]}),q),Pb=G(`M433.941 129.941l-83.882-83.882A48 48 0 0 0 316.118 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48V163.882a48 48 0 0 0-14.059-33.941zM224 416c-35.346 0-64-28.654-64-64 0-35.346 28.654-64 64-64s64 28.654 64 64c0 35.346-28.654 64-64 64zm96-304.52V212c0 6.627-5.373 12-12 12H76c-6.627 0-12-5.373-12-12V108c0-6.627 5.373-12 12-12h228.52c3.183 0 6.235 1.264 8.485 3.515l3.48 3.48A11.996 11.996 0 0 1 320 111.48z`,{width:448,height:512}),Fb=G(`M252 54L203 8a28 27 0 00-20-8H28C12 0 0 12 0 27v195c0 15 12 26 28 26h204c15 0 28-11 28-26V73a28 27 0 00-8-19zM130 213c-21 0-37-16-37-36 0-19 16-35 37-35 20 0 37 16 37 35 0 20-17 36-37 36zm56-169v56c0 4-4 6-7 6H44c-4 0-7-2-7-6V42c0-4 3-7 7-7h133l4 2 3 2a7 7 0 012 5z M296 201l87 95-188 205-78 9c-10 1-19-8-18-20l9-84zm141-14l-41-44a31 31 0 00-46 0l-38 41 87 95 38-42c13-14 13-36 0-50z`,{width:448,height:512}),Ib=G((0,V.jsx)(`path`,{d:`m9.257 6.351.183.183H15.819c.34 0 .727.182 1.051.506.323.323.505.708.505 1.05v5.819c0 .316-.183.7-.52 1.035-.337.338-.723.522-1.037.522H4.182c-.352 0-.74-.181-1.058-.5-.318-.318-.499-.705-.499-1.057V5.182c0-.351.181-.736.5-1.054.32-.321.71-.503 1.057-.503H6.53l2.726 2.726Z`,strokeWidth:`1.25`}),q);G(`M384 112v352c0 26.51-21.49 48-48 48H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h80c0-35.29 28.71-64 64-64s64 28.71 64 64h80c26.51 0 48 21.49 48 48zM192 40c-13.255 0-24 10.745-24 24s10.745 24 24 24 24-10.745 24-24-10.745-24-24-24m96 114v-20a6 6 0 0 0-6-6H102a6 6 0 0 0-6 6v20a6 6 0 0 0 6 6h180a6 6 0 0 0 6-6z`,{width:384,height:512}),G(`M204.3 5C104.9 24.4 24.8 104.3 5.2 203.4c-37 187 131.7 326.4 258.8 306.7 41.2-6.4 61.4-54.6 42.5-91.7-23.1-45.4 9.9-98.4 60.9-98.4h79.7c35.8 0 64.8-29.6 64.9-65.3C511.5 97.1 368.1-26.9 204.3 5zM96 320c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm32-128c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128-64c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128 64c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32z`);var Lb=[`M5 16l1.465 1.638a2 2 0 1 1 -3.015 .099l1.55 -1.737z`,`M13.737 9.737c2.299 -2.3 3.23 -5.095 2.081 -6.245c-1.15 -1.15 -3.945 -.217 -6.244 2.082c-2.3 2.299 -3.231 5.095 -2.082 6.244c1.15 1.15 3.946 .218 6.245 -2.081z`,`M7.492 11.818c.362 .362 .768 .676 1.208 .934l6.895 4.047c1.078 .557 2.255 -.075 3.692 -1.512c1.437 -1.437 2.07 -2.614 1.512 -3.692c-.372 -.718 -1.72 -3.017 -4.047 -6.895a6.015 6.015 0 0 0 -.934 -1.208`],Rb=G((0,V.jsxs)(`g`,{strokeWidth:1.25,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),Lb.map(e=>(0,V.jsx)(`path`,{d:e},e))]}),K),zb=G((0,V.jsx)(`g`,{strokeWidth:1.5,children:(0,V.jsx)(`path`,{d:`M6 18l12 -12`})}),K),Bb=G((0,V.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M15 8h.01`}),(0,V.jsx)(`path`,{d:`M12 20h-5a3 3 0 0 1 -3 -3v-10a3 3 0 0 1 3 -3h10a3 3 0 0 1 3 3v5`}),(0,V.jsx)(`path`,{d:`M4 15l4 -4c.928 -.893 2.072 -.893 3 0l4 4`}),(0,V.jsx)(`path`,{d:`M14 14l1 -1c.617 -.593 1.328 -.793 2.009 -.598`}),(0,V.jsx)(`path`,{d:`M19 16v6`}),(0,V.jsx)(`path`,{d:`M22 19l-3 3l-3 -3`})]}),K),Vb=G(`M216 0h80c13.3 0 24 10.7 24 24v168h87.7c17.8 0 26.7 21.5 14.1 34.1L269.7 378.3c-7.5 7.5-19.8 7.5-27.3 0L90.1 226.1c-12.6-12.6-3.7-34.1 14.1-34.1H192V24c0-13.3 10.7-24 24-24zm296 376v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h146.7l49 49c20.1 20.1 52.5 20.1 72.6 0l49-49H488c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z`,{width:512,height:512});G(`M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z`,{width:448,height:512}),G(`M416 208H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h384c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z`,{width:448,height:512});var Hb=G(`M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z`);G(`M16 132h416c8.837 0 16-7.163 16-16V76c0-8.837-7.163-16-16-16H16C7.163 60 0 67.163 0 76v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16z`);var Ub=G((0,V.jsx)(`path`,{d:`M7.5 10.833 4.167 7.5 7.5 4.167M4.167 7.5h9.166a3.333 3.333 0 0 1 0 6.667H12.5`,strokeWidth:`1.25`}),q),Wb=G((0,V.jsx)(`path`,{d:`M12.5 10.833 15.833 7.5 12.5 4.167M15.833 7.5H6.667a3.333 3.333 0 1 0 0 6.667H7.5`,strokeWidth:`1.25`}),q),Gb=G(`M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zM262.655 90c-54.497 0-89.255 22.957-116.549 63.758-3.536 5.286-2.353 12.415 2.715 16.258l34.699 26.31c5.205 3.947 12.621 3.008 16.665-2.122 17.864-22.658 30.113-35.797 57.303-35.797 20.429 0 45.698 13.148 45.698 32.958 0 14.976-12.363 22.667-32.534 33.976C247.128 238.528 216 254.941 216 296v4c0 6.627 5.373 12 12 12h56c6.627 0 12-5.373 12-12v-1.333c0-28.462 83.186-29.647 83.186-106.667 0-58.002-60.165-102-116.531-102zM256 338c-25.365 0-46 20.635-46 46 0 25.364 20.635 46 46 46s46-20.636 46-46c0-25.365-20.635-46-46-46z`,{mirror:!0}),Kb=G((0,V.jsx)(`path`,{d:`M5 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 7.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 17.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM7.25 8.917l5.5-2.834M7.25 11.083l5.5 2.834`,strokeWidth:`1.5`}),q);G(`M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z`),G(`M16 5l-1.42 1.42-1.59-1.59V16h-1.98V4.83L9.42 6.42 8 5l4-4 4 4zm4 5v11c0 1.1-.9 2-2 2H6c-1.11 0-2-.9-2-2V10c0-1.11.89-2 2-2h3v2H6v11h12V10h-3V8h3c1.1 0 2 .89 2 2z`,{width:24,height:24}),G((0,V.jsxs)(`g`,{strokeWidth:1.25,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M8 9h-1a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-8a2 2 0 0 0 -2 -2h-1`}),(0,V.jsx)(`path`,{d:`M12 14v-11`}),(0,V.jsx)(`path`,{d:`M9 6l3 -3l3 3`})]}),K),G((0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{fill:`currentColor`,d:`M40 5.6v6.1l-4.1.7c-8.9 1.4-16.5 6.9-20.6 15C13 32 10.9 43 12.4 43c.4 0 2.4-1.3 4.4-3 5-3.9 12.1-7 18.2-7.7l5-.6v12.8l11.2-11.3L62.5 22 51.2 10.8 40-.5v6.1zm10.2 22.6L44 34.5v-6.8l-6.9.6c-3.9.3-9.8 1.7-13.2 3.1-3.5 1.4-6.5 2.4-6.7 2.2-.9-1 3-7.5 6.4-10.8C28 18.6 34.4 16 40.1 16c3.7 0 3.9-.1 3.9-3.2V9.5l6.2 6.3 6.3 6.2-6.3 6.2z`}),(0,V.jsx)(`path`,{stroke:`currentColor`,fill:`currentColor`,d:`M0 36v20h48v-6.2c0-6 0-6.1-2-4.3-1.1 1-2 2.9-2 4.2V52H4V34c0-17.3-.1-18-2-18s-2 .7-2 20z`})]}),{width:64,height:64}),G((0,V.jsx)(`path`,{stroke:`currentColor`,strokeWidth:`40`,fill:`currentColor`,d:`M148 560a318 318 0 0 0 522 110 316 316 0 0 0 0-450 316 316 0 0 0-450 0c-11 11-21 22-30 34v4h47c25 0 46 21 46 46s-21 45-46 45H90c-13 0-25-6-33-14-9-9-14-20-14-33V156c0-25 20-45 45-45s45 20 45 45v32l1 1a401 401 0 0 1 623 509l212 212a42 42 0 0 1-59 59L698 757A401 401 0 0 1 65 570a42 42 0 0 1 83-10z`}),{width:1024});var qb=(0,V.jsxs)(`g`,{strokeWidth:1.5,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M12 10l0 10`}),(0,V.jsx)(`path`,{d:`M12 10l4 4`}),(0,V.jsx)(`path`,{d:`M12 10l-4 4`}),(0,V.jsx)(`path`,{d:`M4 4l16 0`})]}),Jb=(0,V.jsxs)(`g`,{strokeWidth:1.5,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M12 5l0 14`}),(0,V.jsx)(`path`,{d:`M16 9l-4 -4`}),(0,V.jsx)(`path`,{d:`M8 9l4 -4`})]}),Yb=G(Jb,K),Xb=G(Jb,{...K,style:{transform:`rotate(180deg)`}}),Zb=G(qb,K),Qb=G(qb,{...K,style:{transform:`rotate(180deg)`}}),$b=G((0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`g`,{clipPath:`url(#a)`,stroke:`currentColor`,strokeWidth:`1.25`,children:[(0,V.jsx)(`path`,{d:`M3.333 3.333h13.334`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,V.jsx)(`path`,{d:`M13.542 6.458h-.417c-.92 0-1.667.747-1.667 1.667v7.083c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667V8.125c0-.92-.746-1.667-1.666-1.667ZM6.875 6.458h-.417c-.92 0-1.666.747-1.666 1.667v3.75c0 .92.746 1.667 1.666 1.667h.417c.92 0 1.667-.746 1.667-1.667v-3.75c0-.92-.747-1.667-1.667-1.667Z`})]}),(0,V.jsx)(`defs`,{children:(0,V.jsx)(`clipPath`,{id:`a`,children:(0,V.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),q),ex=G((0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`g`,{clipPath:`url(#a)`,stroke:`currentColor`,strokeWidth:`1.25`,children:[(0,V.jsx)(`path`,{d:`M3.333 16.667h13.334`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,V.jsx)(`path`,{d:`M6.875 3.125h-.417c-.92 0-1.666.746-1.666 1.667v7.083c0 .92.746 1.667 1.666 1.667h.417c.92 0 1.667-.746 1.667-1.667V4.792c0-.92-.747-1.667-1.667-1.667ZM13.542 5.817h-.417c-.92 0-1.667.747-1.667 1.667v4.391c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667V7.484c0-.92-.746-1.667-1.666-1.667Z`})]}),(0,V.jsx)(`defs`,{children:(0,V.jsx)(`clipPath`,{id:`a`,children:(0,V.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),q),tx=G((0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`g`,{clipPath:`url(#a)`,stroke:`currentColor`,strokeWidth:`1.25`,children:[(0,V.jsx)(`path`,{d:`M3.333 3.333v13.334`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,V.jsx)(`path`,{d:`M15.208 4.792H8.125c-.92 0-1.667.746-1.667 1.666v.417c0 .92.747 1.667 1.667 1.667h7.083c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666ZM12.516 11.458H8.125c-.92 0-1.667.746-1.667 1.667v.417c0 .92.747 1.666 1.667 1.666h4.391c.92 0 1.667-.746 1.667-1.666v-.417c0-.92-.746-1.667-1.667-1.667Z`})]}),(0,V.jsx)(`defs`,{children:(0,V.jsx)(`clipPath`,{id:`a`,children:(0,V.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),q),nx=G((0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`g`,{clipPath:`url(#a)`,stroke:`currentColor`,strokeWidth:`1.25`,children:[(0,V.jsx)(`path`,{d:`M16.667 3.333v13.334`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,V.jsx)(`path`,{d:`M11.875 4.792H4.792c-.92 0-1.667.746-1.667 1.666v.417c0 .92.746 1.667 1.667 1.667h7.083c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666ZM11.683 11.458H7.292c-.92 0-1.667.746-1.667 1.667v.417c0 .92.746 1.666 1.667 1.666h4.39c.921 0 1.667-.746 1.667-1.666v-.417c0-.92-.746-1.667-1.666-1.667Z`})]}),(0,V.jsx)(`defs`,{children:(0,V.jsx)(`clipPath`,{id:`a`,children:(0,V.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),q),rx=G((0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`g`,{clipPath:`url(#a)`,stroke:`currentColor`,strokeWidth:`1.25`,children:[(0,V.jsx)(`path`,{d:`M16.667 3.333v13.334M3.333 3.333v13.334`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,V.jsx)(`path`,{d:`M14.375 10.208v-.416c0-.92-.746-1.667-1.667-1.667H7.292c-.92 0-1.667.746-1.667 1.667v.416c0 .92.746 1.667 1.667 1.667h5.416c.92 0 1.667-.746 1.667-1.667Z`})]}),(0,V.jsx)(`defs`,{children:(0,V.jsx)(`clipPath`,{id:`a`,children:(0,V.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),q),ix=G((0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`g`,{clipPath:`url(#a)`,stroke:`currentColor`,strokeWidth:`1.25`,children:[(0,V.jsx)(`path`,{d:`M3.333 3.333h13.334M3.333 16.667h13.334`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,V.jsx)(`path`,{d:`M10.208 5.625h-.416c-.92 0-1.667.746-1.667 1.667v5.416c0 .92.746 1.667 1.667 1.667h.416c.92 0 1.667-.746 1.667-1.667V7.292c0-.92-.746-1.667-1.667-1.667Z`})]}),(0,V.jsx)(`defs`,{children:(0,V.jsx)(`clipPath`,{id:`a`,children:(0,V.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),q),ax=G((0,V.jsxs)(`g`,{stroke:`currentColor`,strokeWidth:`1.25`,children:[(0,V.jsx)(`path`,{d:`M1.667 10h2.916`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,V.jsx)(`path`,{d:`M8.333 10h3.334`,strokeLinejoin:`round`}),(0,V.jsx)(`path`,{d:`M15.417 10h2.916`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,V.jsx)(`path`,{d:`M6.875 4.792h-.417c-.92 0-1.666.746-1.666 1.666v7.084c0 .92.746 1.666 1.666 1.666h.417c.92 0 1.667-.746 1.667-1.666V6.458c0-.92-.747-1.666-1.667-1.666ZM13.542 6.458h-.417c-.92 0-1.667.747-1.667 1.667v3.75c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667v-3.75c0-.92-.746-1.667-1.666-1.667Z`})]}),q),ox=G((0,V.jsxs)(`g`,{stroke:`currentColor`,strokeWidth:`1.25`,children:[(0,V.jsx)(`path`,{d:`M10 18.333v-2.916`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,V.jsx)(`path`,{d:`M10 11.667V8.333`,strokeLinejoin:`round`}),(0,V.jsx)(`path`,{d:`M10 4.583V1.667`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,V.jsx)(`path`,{d:`M4.792 13.125v.417c0 .92.746 1.666 1.666 1.666h7.084c.92 0 1.666-.746 1.666-1.666v-.417c0-.92-.746-1.667-1.666-1.667H6.458c-.92 0-1.666.746-1.666 1.667ZM6.458 6.458v.417c0 .92.747 1.667 1.667 1.667h3.75c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666h-3.75c-.92 0-1.667.746-1.667 1.666Z`})]}),q),sx=G((0,V.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`circle`,{cx:`9`,cy:`7`,r:`4`}),(0,V.jsx)(`path`,{d:`M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2`}),(0,V.jsx)(`path`,{d:`M16 3.13a4 4 0 0 1 0 7.75`}),(0,V.jsx)(`path`,{d:`M21 21v-2a4 4 0 0 0 -3 -3.85`})]}),K);G(`M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm115.7 272l-176 101c-15.8 8.8-35.7-2.5-35.7-21V152c0-18.4 19.8-29.8 35.7-21l176 107c16.4 9.2 16.4 32.9 0 42z`);var cx=G(`M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm96 328c0 8.8-7.2 16-16 16H176c-8.8 0-16-7.2-16-16V176c0-8.8 7.2-16 16-16h160c8.8 0 16 7.2 16 16v160z`),lx=G((0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`g`,{clipPath:`url(#a)`,stroke:`currentColor`,strokeWidth:`1.25`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,V.jsx)(`path`,{d:`M15 5 5 15M5 5l10 10`})}),(0,V.jsx)(`defs`,{children:(0,V.jsx)(`clipPath`,{id:`a`,children:(0,V.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),q);G(`M464 0c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48H176c-26.51 0-48-21.49-48-48V48c0-26.51 21.49-48 48-48h288M176 416c-44.112 0-80-35.888-80-80V128H48c-26.51 0-48 21.49-48 48v288c0 26.51 21.49 48 48 48h288c26.51 0 48-21.49 48-48v-48H176z`,{mirror:!0}),G(`M11.553 22.894a.998.998 0 00.894 0s3.037-1.516 5.465-4.097C19.616 16.987 21 14.663 21 12V5a1 1 0 00-.649-.936l-8-3a.998.998 0 00-.702 0l-8 3A1 1 0 003 5v7c0 2.663 1.384 4.987 3.088 6.797 2.428 2.581 5.465 4.097 5.465 4.097zm-1.303-8.481l6.644-6.644a.856.856 0 111.212 1.212l-7.25 7.25a.856.856 0 01-1.212 0l-3.75-3.75a.856.856 0 111.212-1.212l3.144 3.144z`,{width:24}),G(`M369.9 97.9L286 14C277 5 264.8-.1 252.1-.1H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V131.9c0-12.7-5.1-25-14.1-34zM332.1 128H256V51.9l76.1 76.1zM48 464V48h160v104c0 13.3 10.7 24 24 24h104v288H48zm32-48h224V288l-23.5-23.5c-4.7-4.7-12.3-4.7-17 0L176 352l-39.5-39.5c-4.7-4.7-12.3-4.7-17 0L80 352v64zm48-240c-26.5 0-48 21.5-48 48s21.5 48 48 48 48-21.5 48-48-21.5-48-48-48z`,{width:384,height:512});var ux=B.memo(({theme:e})=>G((0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M25 26H111V111H25`,fill:Hy(e)}),(0,V.jsx)(`path`,{d:`M25 111C25 80.2068 25 49.4135 25 26M25 26C48.6174 26 72.2348 26 111 26H25ZM25 26C53.3671 26 81.7343 26 111 26H25ZM111 26C111 52.303 111 78.606 111 111V26ZM111 26C111 51.2947 111 76.5893 111 111V26ZM111 111C87.0792 111 63.1585 111 25 111H111ZM111 111C87.4646 111 63.9293 111 25 111H111ZM25 111C25 81.1514 25 51.3028 25 26V111Z`,stroke:Hy(e),strokeWidth:`2`}),(0,V.jsx)(`path`,{d:`M100 100H160V160H100`,fill:Hy(e)}),(0,V.jsx)(`path`,{d:`M100 160C100 144.106 100 128.211 100 100M100 100C117.706 100 135.412 100 160 100H100ZM100 100C114.214 100 128.428 100 160 100H100ZM160 100C160 120.184 160 140.369 160 160V100ZM160 100C160 113.219 160 126.437 160 160V100ZM160 160C145.534 160 131.068 160 100 160H160ZM160 160C143.467 160 126.934 160 100 160H160ZM100 160C100 143.661 100 127.321 100 100V160Z`,stroke:Hy(e),strokeWidth:`2`}),(0,V.jsxs)(`g`,{fill:Uy(e),stroke:Hy(e),strokeWidth:`6`,children:[(0,V.jsx)(`rect`,{x:`2.5`,y:`2.5`,width:`30`,height:`30`}),(0,V.jsx)(`rect`,{x:`2.5`,y:`149.5`,width:`30`,height:`30`}),(0,V.jsx)(`rect`,{x:`147.5`,y:`149.5`,width:`30`,height:`30`}),(0,V.jsx)(`rect`,{x:`147.5`,y:`2.5`,width:`30`,height:`30`})]})]}),{width:182,height:182,mirror:!0})),dx=B.memo(({theme:e})=>G((0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M25 26H111V111H25`,fill:Hy(e)}),(0,V.jsx)(`path`,{d:`M25 111C25 80.2068 25 49.4135 25 26M25 26C48.6174 26 72.2348 26 111 26H25ZM25 26C53.3671 26 81.7343 26 111 26H25ZM111 26C111 52.303 111 78.606 111 111V26ZM111 26C111 51.2947 111 76.5893 111 111V26ZM111 111C87.0792 111 63.1585 111 25 111H111ZM111 111C87.4646 111 63.9293 111 25 111H111ZM25 111C25 81.1514 25 51.3028 25 26V111Z`,stroke:Hy(e),strokeWidth:`2`}),(0,V.jsx)(`path`,{d:`M100 100H160V160H100`,fill:Hy(e)}),(0,V.jsx)(`path`,{d:`M100 160C100 144.106 100 128.211 100 100M100 100C117.706 100 135.412 100 160 100H100ZM100 100C114.214 100 128.428 100 160 100H100ZM160 100C160 120.184 160 140.369 160 160V100ZM160 100C160 113.219 160 126.437 160 160V100ZM160 160C145.534 160 131.068 160 100 160H160ZM160 160C143.467 160 126.934 160 100 160H160ZM100 160C100 143.661 100 127.321 100 100V160Z`,stroke:Hy(e),strokeWidth:`2`}),(0,V.jsxs)(`g`,{fill:Uy(e),stroke:Hy(e),strokeWidth:`6`,children:[(0,V.jsx)(`rect`,{x:`2.5`,y:`2.5`,width:`30`,height:`30`}),(0,V.jsx)(`rect`,{x:`78.5`,y:`149.5`,width:`30`,height:`30`}),(0,V.jsx)(`rect`,{x:`147.5`,y:`149.5`,width:`30`,height:`30`}),(0,V.jsx)(`rect`,{x:`147.5`,y:`78.5`,width:`30`,height:`30`}),(0,V.jsx)(`rect`,{x:`105.5`,y:`2.5`,width:`30`,height:`30`}),(0,V.jsx)(`rect`,{x:`2.5`,y:`102.5`,width:`30`,height:`30`})]})]}),{width:182,height:182,mirror:!0})),fx=G((0,V.jsx)(`g`,{strokeWidth:1.25,children:(0,V.jsx)(`path`,{d:`M5.879 2.625h8.242a3.27 3.27 0 0 1 3.254 3.254v8.242a3.27 3.27 0 0 1-3.254 3.254H5.88a3.27 3.27 0 0 1-3.254-3.254V5.88A3.27 3.27 0 0 1 5.88 2.626l-.001-.001ZM4.518 16.118l7.608-12.83m.198 13.934 5.051-9.897M2.778 9.675l9.348-6.387m-7.608 12.83 12.857-8.793`})}),q),px=G((0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{d:`M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z`,stroke:`currentColor`,strokeWidth:`1.25`}),(0,V.jsx)(`mask`,{id:`FillHachureIcon`,style:{maskType:`alpha`},maskUnits:`userSpaceOnUse`,x:2,y:2,width:16,height:16,children:(0,V.jsx)(`path`,{d:`M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z`,fill:`currentColor`,stroke:`currentColor`,strokeWidth:`1.25`})}),(0,V.jsx)(`g`,{mask:`url(#FillHachureIcon)`,children:(0,V.jsx)(`path`,{d:`M2.258 15.156 15.156 2.258M7.324 20.222 20.222 7.325m-20.444 5.35L12.675-.222m-8.157 18.34L17.416 5.22`,stroke:`currentColor`,strokeWidth:`1.25`,strokeLinecap:`round`,strokeLinejoin:`round`})})]}),q),mx=G((0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`g`,{clipPath:`url(#a)`,children:[(0,V.jsx)(`path`,{d:`M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z`,stroke:`currentColor`,strokeWidth:`1.25`}),(0,V.jsx)(`mask`,{id:`FillCrossHatchIcon`,style:{maskType:`alpha`},maskUnits:`userSpaceOnUse`,x:-1,y:-1,width:22,height:22,children:(0,V.jsx)(`path`,{d:`M2.426 15.044 15.044 2.426M7.383 20 20 7.383M0 12.617 12.617 0m-7.98 17.941L17.256 5.324m-2.211 12.25L2.426 4.956M20 12.617 7.383 0m5.234 20L0 7.383m17.941 7.98L5.324 2.745`,stroke:`currentColor`,strokeWidth:`1.25`,strokeLinecap:`round`,strokeLinejoin:`round`})}),(0,V.jsx)(`g`,{mask:`url(#FillCrossHatchIcon)`,children:(0,V.jsx)(`path`,{d:`M14.121 2H5.88A3.879 3.879 0 0 0 2 5.879v8.242A3.879 3.879 0 0 0 5.879 18h8.242A3.879 3.879 0 0 0 18 14.121V5.88A3.879 3.879 0 0 0 14.121 2Z`,fill:`currentColor`})})]}),(0,V.jsx)(`defs`,{children:(0,V.jsx)(`clipPath`,{id:`a`,children:(0,V.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),q),hx=G((0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`g`,{clipPath:`url(#a)`,children:(0,V.jsx)(`path`,{d:`M4.91 2.625h10.18a2.284 2.284 0 0 1 2.285 2.284v10.182a2.284 2.284 0 0 1-2.284 2.284H4.909a2.284 2.284 0 0 1-2.284-2.284V4.909a2.284 2.284 0 0 1 2.284-2.284Z`,stroke:`currentColor`,strokeWidth:`1.25`})}),(0,V.jsx)(`defs`,{children:(0,V.jsx)(`clipPath`,{id:`a`,children:(0,V.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),{...q,fill:`currentColor`}),gx=G((0,V.jsx)(V.Fragment,{children:(0,V.jsx)(`path`,{d:`M4.167 10h11.666`,stroke:`currentColor`,strokeWidth:`1.25`,strokeLinecap:`round`,strokeLinejoin:`round`})}),q),_x=G((0,V.jsx)(`path`,{d:`M5 10h10`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),q),vx=G((0,V.jsx)(`path`,{d:`M5 10h10`,stroke:`currentColor`,strokeWidth:`3.75`,strokeLinecap:`round`,strokeLinejoin:`round`}),q);B.memo(({theme:e})=>G((0,V.jsx)(`path`,{d:`M6 10H34`,stroke:Hy(e),strokeWidth:2,fill:`none`,strokeLinecap:`round`}),{width:40,height:20}));var yx=G((0,V.jsxs)(`g`,{strokeWidth:`2`,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M5 12h2`}),(0,V.jsx)(`path`,{d:`M17 12h2`}),(0,V.jsx)(`path`,{d:`M11 12h2`})]}),K),bx=G((0,V.jsxs)(`g`,{strokeWidth:`2`,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M4 12v.01`}),(0,V.jsx)(`path`,{d:`M8 12v.01`}),(0,V.jsx)(`path`,{d:`M12 12v.01`}),(0,V.jsx)(`path`,{d:`M16 12v.01`}),(0,V.jsx)(`path`,{d:`M20 12v.01`})]}),K),xx=G((0,V.jsx)(`path`,{d:`M2.5 12.038c1.655-.885 5.9-3.292 8.568-4.354 2.668-1.063.101 2.821 1.32 3.104 1.218.283 5.112-1.814 5.112-1.814`,strokeWidth:`1.25`}),q),Sx=G((0,V.jsx)(`path`,{d:`M2.5 12.563c1.655-.886 5.9-3.293 8.568-4.355 2.668-1.062.101 2.822 1.32 3.105 1.218.283 5.112-1.814 5.112-1.814m-13.469 2.23c2.963-1.586 6.13-5.62 7.468-4.998 1.338.623-1.153 4.11-.132 5.595 1.02 1.487 6.133-1.43 6.133-1.43`,strokeWidth:`1.25`}),q),Cx=G((0,V.jsx)(`path`,{d:`M2.5 11.936c1.737-.879 8.627-5.346 10.42-5.268 1.795.078-.418 5.138.345 5.736.763.598 3.53-1.789 4.235-2.147M2.929 9.788c1.164-.519 5.47-3.28 6.987-3.114 1.519.165 1 3.827 2.121 4.109 1.122.281 3.839-2.016 4.606-2.42`,strokeWidth:`1.25`}),q),wx=G((0,V.jsxs)(`g`,{children:[(0,V.jsx)(`path`,{d:`M4 12 C 5 8, 6 8, 8 12`,fill:`none`,strokeWidth:`1`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,V.jsx)(`path`,{d:`M8 12 C 9 16, 10 16, 12 12`,fill:`none`,strokeWidth:`1`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,V.jsx)(`path`,{d:`M12 12 C 14 8, 15 8, 16 12`,fill:`none`,strokeWidth:`1`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,V.jsx)(`path`,{d:`M16 12 C 17 16, 18 16, 19 12`,fill:`none`,strokeWidth:`1`,strokeLinecap:`round`,strokeLinejoin:`round`})]}),K),Tx=G((0,V.jsxs)(`g`,{children:[(0,V.jsx)(`path`,{d:`M4 12 C 5 8, 6 8, 8 12`,fill:`none`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,V.jsx)(`path`,{d:`M8 12 C 9 16, 10 16, 12 12`,fill:`none`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,V.jsx)(`path`,{d:`M12 12 C 14 8, 15 8, 16 12`,fill:`none`,strokeWidth:`2.75`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,V.jsx)(`path`,{d:`M16 12 C 17 16, 18 16, 19 12`,fill:`none`,strokeWidth:`3.25`,strokeLinecap:`round`,strokeLinejoin:`round`})]}),K),Ex=G((0,V.jsxs)(`svg`,{strokeWidth:`1.5`,children:[(0,V.jsx)(`path`,{d:`M3.33334 9.99998V6.66665C3.33334 6.04326 3.33403 4.9332 3.33539 3.33646C4.95233 3.33436 6.06276 3.33331 6.66668 3.33331H10`}),(0,V.jsx)(`path`,{d:`M13.3333 3.33331V3.34331`}),(0,V.jsx)(`path`,{d:`M16.6667 3.33331V3.34331`}),(0,V.jsx)(`path`,{d:`M16.6667 6.66669V6.67669`}),(0,V.jsx)(`path`,{d:`M16.6667 10V10.01`}),(0,V.jsx)(`path`,{d:`M3.33334 13.3333V13.3433`}),(0,V.jsx)(`path`,{d:`M16.6667 13.3333V13.3433`}),(0,V.jsx)(`path`,{d:`M3.33334 16.6667V16.6767`}),(0,V.jsx)(`path`,{d:`M6.66666 16.6667V16.6767`}),(0,V.jsx)(`path`,{d:`M10 16.6667V16.6767`}),(0,V.jsx)(`path`,{d:`M13.3333 16.6667V16.6767`}),(0,V.jsx)(`path`,{d:`M16.6667 16.6667V16.6767`})]}),q),Dx=G((0,V.jsxs)(`g`,{strokeWidth:`1.5`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M4 12v-4a4 4 0 0 1 4 -4h4`}),(0,V.jsx)(`line`,{x1:`16`,y1:`4`,x2:`16`,y2:`4.01`}),(0,V.jsx)(`line`,{x1:`20`,y1:`4`,x2:`20`,y2:`4.01`}),(0,V.jsx)(`line`,{x1:`20`,y1:`8`,x2:`20`,y2:`8.01`}),(0,V.jsx)(`line`,{x1:`20`,y1:`12`,x2:`20`,y2:`12.01`}),(0,V.jsx)(`line`,{x1:`4`,y1:`16`,x2:`4`,y2:`16.01`}),(0,V.jsx)(`line`,{x1:`20`,y1:`16`,x2:`20`,y2:`16.01`}),(0,V.jsx)(`line`,{x1:`4`,y1:`20`,x2:`4`,y2:`20.01`}),(0,V.jsx)(`line`,{x1:`8`,y1:`20`,x2:`8`,y2:`20.01`}),(0,V.jsx)(`line`,{x1:`12`,y1:`20`,x2:`12`,y2:`20.01`}),(0,V.jsx)(`line`,{x1:`16`,y1:`20`,x2:`16`,y2:`20.01`}),(0,V.jsx)(`line`,{x1:`20`,y1:`20`,x2:`20`,y2:`20.01`})]}),K),Ox=B.memo(({flip:e=!1})=>G((0,V.jsxs)(`g`,{transform:e?`translate(40, 0) scale(-1, 1)`:``,stroke:`currentColor`,opacity:.3,strokeWidth:2,fill:`none`,strokeLinecap:`round`,children:[(0,V.jsx)(`path`,{d:`M7,11 H19`}),(0,V.jsx)(`path`,{d:`M25,6 L33,16 M33,6 L25,16`})]}),Wy)),kx=B.memo(({flip:e=!1})=>G((0,V.jsx)(`g`,{transform:e?`translate(40, 0) scale(-1, 1)`:``,stroke:`currentColor`,strokeWidth:2,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,V.jsx)(`path`,{d:`M7,11 H33 M23,5 L33,11 L23,17`})}),Wy)),Ax=B.memo(({flip:e=!1})=>G((0,V.jsxs)(`g`,{stroke:`currentColor`,fill:`currentColor`,transform:e?`translate(40, 0) scale(-1, 1)`:``,strokeLinejoin:`round`,children:[(0,V.jsx)(`path`,{d:`M7,11 H23`,strokeWidth:2,strokeLinecap:`round`}),(0,V.jsx)(`path`,{d:`M23,5 L35,11 L23,17 Z`})]}),Wy)),jx=B.memo(({flip:e=!1})=>G((0,V.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,transform:e?`translate(40, 0) scale(-1, 1)`:``,strokeWidth:2,strokeLinejoin:`round`,strokeLinecap:`round`,children:[(0,V.jsx)(`path`,{d:`M7,11 H23`}),(0,V.jsx)(`path`,{d:`M23,5 L35,11 L23,17 Z`})]}),Wy)),Mx=B.memo(({flip:e=!1})=>G((0,V.jsxs)(`g`,{stroke:`currentColor`,fill:`currentColor`,transform:e?`translate(40, 0) scale(-1, 1)`:``,children:[(0,V.jsx)(`path`,{d:`M7,11 H25`,strokeWidth:2,strokeLinecap:`round`}),(0,V.jsx)(`circle`,{cx:`29`,cy:`11`,r:`4`})]}),Wy)),Nx=B.memo(({flip:e=!1})=>G((0,V.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,transform:e?`translate(40, 0) scale(-1, 1)`:``,strokeWidth:2,children:[(0,V.jsx)(`path`,{d:`M7,11 H25`,strokeLinecap:`round`}),(0,V.jsx)(`circle`,{cx:`29`,cy:`11`,r:`4`})]}),Wy)),Px=B.memo(({flip:e=!1})=>G((0,V.jsxs)(`g`,{stroke:`currentColor`,fill:`currentColor`,transform:e?`translate(40, 0) scale(-1, 1)`:``,strokeLinejoin:`round`,children:[(0,V.jsx)(`path`,{d:`M7,11 H21`,strokeWidth:2,strokeLinecap:`round`}),(0,V.jsx)(`path`,{d:`M21,11 L28,5 L35,11 L28,17 Z`})]}),Wy)),Fx=B.memo(({flip:e=!1})=>G((0,V.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,transform:e?`translate(40, 0) scale(-1, 1)`:``,strokeLinejoin:`round`,strokeWidth:2,strokeLinecap:`round`,children:[(0,V.jsx)(`path`,{d:`M7,11 H21`}),(0,V.jsx)(`path`,{d:`M21,11 L28,5 L35,11 L28,17 Z`})]}),Wy)),Ix=B.memo(({flip:e=!1})=>G((0,V.jsx)(`g`,{transform:e?`translate(40, 0) scale(-1, 1)`:``,stroke:`currentColor`,strokeWidth:2,fill:`none`,strokeLinecap:`round`,children:(0,V.jsx)(`path`,{d:`M11,11 H31 M31,5 V17`})}),Wy)),Lx=B.memo(({flip:e=!1})=>G((0,V.jsx)(`g`,{stroke:`currentColor`,fill:`none`,transform:e?``:`translate(40, 0) scale(-1, 1)`,strokeLinejoin:`round`,strokeWidth:2,children:(0,V.jsx)(`path`,{d:`M35,11 H7 M15,5 V17`})}),Wy)),Rx=B.memo(({flip:e=!1})=>G((0,V.jsx)(`g`,{stroke:`currentColor`,fill:`none`,transform:e?``:`translate(40, 0) scale(-1, 1)`,strokeLinejoin:`round`,strokeWidth:2,children:(0,V.jsx)(`path`,{d:`M35,11 H7 M15,11 L7,5 M15,11 L7,17`})}),Wy)),zx=B.memo(({flip:e=!1})=>G((0,V.jsx)(`g`,{stroke:`currentColor`,fill:`none`,transform:e?``:`translate(40, 0) scale(-1, 1)`,strokeLinejoin:`round`,strokeWidth:2,children:(0,V.jsx)(`path`,{d:`M35,11 H7 M23,5 V17 M15,11 L7,5 M15,11 L7,17`})}),Wy)),Bx=B.memo(({flip:e=!1})=>G((0,V.jsx)(`g`,{stroke:`currentColor`,fill:`none`,transform:e?``:`translate(40, 0) scale(-1, 1)`,strokeLinejoin:`round`,strokeWidth:2,children:(0,V.jsx)(`path`,{d:`M35,11 H7 M15,5 V17 M7,5 V17`})}),Wy)),Vx=B.memo(({flip:e=!1})=>G((0,V.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,transform:e?``:`translate(40, 0) scale(-1, 1)`,strokeLinejoin:`round`,strokeWidth:2,children:[(0,V.jsx)(`path`,{d:`M35,11 H19 M11,11 H7 M7,5 V17`}),(0,V.jsx)(`circle`,{cx:`15`,cy:`11`,r:`4`})]}),Wy)),Hx=B.memo(({flip:e=!1})=>G((0,V.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,transform:e?``:`translate(40, 0) scale(-1, 1)`,strokeLinejoin:`round`,strokeWidth:2,children:[(0,V.jsx)(`path`,{d:`M35,11 H27 M19,11 H7 M15,11 L7,5 M15,11 L7,17`}),(0,V.jsx)(`circle`,{cx:`23`,cy:`11`,r:`4`})]}),Wy)),Ux=G((0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`g`,{clipPath:`url(#a)`,children:(0,V.jsx)(`path`,{d:`M14.167 6.667a3.333 3.333 0 0 0-3.334-3.334H9.167a3.333 3.333 0 0 0 0 6.667h1.666a3.333 3.333 0 0 1 0 6.667H9.167a3.333 3.333 0 0 1-3.334-3.334`,stroke:`currentColor`,strokeWidth:`1.25`,strokeLinecap:`round`,strokeLinejoin:`round`})}),(0,V.jsx)(`defs`,{children:(0,V.jsx)(`clipPath`,{id:`a`,children:(0,V.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),q),Wx=G((0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`g`,{clipPath:`url(#a)`,children:(0,V.jsx)(`path`,{d:`M5 16.667V3.333L10 15l5-11.667v13.334`,stroke:`currentColor`,strokeWidth:`1.25`,strokeLinecap:`round`,strokeLinejoin:`round`})}),(0,V.jsx)(`defs`,{children:(0,V.jsx)(`clipPath`,{id:`a`,children:(0,V.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),q),Gx=G((0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`g`,{clipPath:`url(#a)`,children:(0,V.jsx)(`path`,{d:`M5.833 3.333v13.334h8.334`,stroke:`currentColor`,strokeWidth:`1.25`,strokeLinecap:`round`,strokeLinejoin:`round`})}),(0,V.jsx)(`defs`,{children:(0,V.jsx)(`clipPath`,{id:`a`,children:(0,V.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),q),Kx=G((0,V.jsx)(V.Fragment,{children:(0,V.jsx)(`path`,{d:`m1.667 3.333 6.666 13.334M8.333 3.333 1.667 16.667M11.667 3.333v13.334h6.666`,stroke:`currentColor`,strokeWidth:`1.25`,strokeLinecap:`round`,strokeLinejoin:`round`})}),q),qx=G((0,V.jsxs)(`g`,{strokeWidth:1.25,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M3 7v-2h13v2`}),(0,V.jsx)(`path`,{d:`M10 5v14`}),(0,V.jsx)(`path`,{d:`M12 19h-4`}),(0,V.jsx)(`path`,{d:`M15 13v-1h6v1`}),(0,V.jsx)(`path`,{d:`M18 12v7`}),(0,V.jsx)(`path`,{d:`M17 19h2`})]}),K),Jx=G((0,V.jsx)(V.Fragment,{children:(0,V.jsxs)(`g`,{stroke:`currentColor`,strokeWidth:`1.25`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M7 12h10`}),(0,V.jsx)(`path`,{d:`M7 5v14`}),(0,V.jsx)(`path`,{d:`M17 5v14`}),(0,V.jsx)(`path`,{d:`M15 19h4`}),(0,V.jsx)(`path`,{d:`M15 5h4`}),(0,V.jsx)(`path`,{d:`M5 19h4`}),(0,V.jsx)(`path`,{d:`M5 5h4`})]})}),K),Yx=G((0,V.jsx)(V.Fragment,{children:(0,V.jsx)(`g`,{stroke:`currentColor`,strokeWidth:`1.25`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,V.jsx)(`path`,{d:`M5.833 16.667v-10a3.333 3.333 0 0 1 3.334-3.334h1.666a3.333 3.333 0 0 1 3.334 3.334v10M5.833 10.833h8.334`})})}),q),Xx=G((0,V.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M7 8l-4 4l4 4`}),(0,V.jsx)(`path`,{d:`M17 8l4 4l-4 4`}),(0,V.jsx)(`path`,{d:`M14 4l-4 16`})]}),K),Zx=Xx,Qx=G((0,V.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`line`,{x1:`4`,y1:`8`,x2:`20`,y2:`8`}),(0,V.jsx)(`line`,{x1:`4`,y1:`12`,x2:`12`,y2:`12`}),(0,V.jsx)(`line`,{x1:`4`,y1:`16`,x2:`16`,y2:`16`})]}),K),$x=G((0,V.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`line`,{x1:`4`,y1:`8`,x2:`20`,y2:`8`}),(0,V.jsx)(`line`,{x1:`8`,y1:`12`,x2:`16`,y2:`12`}),(0,V.jsx)(`line`,{x1:`6`,y1:`16`,x2:`18`,y2:`16`})]}),K),eS=G((0,V.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`line`,{x1:`4`,y1:`8`,x2:`20`,y2:`8`}),(0,V.jsx)(`line`,{x1:`10`,y1:`12`,x2:`20`,y2:`12`}),(0,V.jsx)(`line`,{x1:`8`,y1:`16`,x2:`20`,y2:`16`})]}),K),tS=B.memo(({theme:e})=>G((0,V.jsxs)(`g`,{strokeWidth:`1.5`,stroke:`currentColor`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`line`,{x1:`4`,y1:`4`,x2:`20`,y2:`4`}),(0,V.jsx)(`rect`,{x:`9`,y:`8`,width:`6`,height:`12`,rx:`2`})]}),K)),nS=B.memo(({theme:e})=>G((0,V.jsxs)(`g`,{strokeWidth:`2`,stroke:`currentColor`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`line`,{x1:`4`,y1:`20`,x2:`20`,y2:`20`}),(0,V.jsx)(`rect`,{x:`9`,y:`4`,width:`6`,height:`12`,rx:`2`})]}),K)),rS=B.memo(({theme:e})=>G((0,V.jsxs)(`g`,{strokeWidth:`1.5`,stroke:`currentColor`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`line`,{x1:`4`,y1:`12`,x2:`9`,y2:`12`}),(0,V.jsx)(`line`,{x1:`15`,y1:`12`,x2:`20`,y2:`12`}),(0,V.jsx)(`rect`,{x:`9`,y:`6`,width:`6`,height:`12`,rx:`2`})]}),K)),iS=G((0,V.jsxs)(`g`,{children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M21 19h-18l9 -15`}),(0,V.jsx)(`path`,{d:`M20.615 15.171h.015`}),(0,V.jsx)(`path`,{d:`M19.515 11.771h.015`}),(0,V.jsx)(`path`,{d:`M17.715 8.671h.015`}),(0,V.jsx)(`path`,{d:`M15.415 5.971h.015`})]}),K),aS=G((0,V.jsx)(`path`,{d:`M537.6 226.6c4.1-10.7 6.4-22.4 6.4-34.6 0-53-43-96-96-96-19.7 0-38.1 6-53.3 16.2C367 64.2 315.3 32 256 32c-88.4 0-160 71.6-160 160 0 2.7.1 5.4.2 8.1C40.2 219.8 0 273.2 0 336c0 79.5 64.5 144 144 144h368c70.7 0 128-57.3 128-128 0-61.9-44-113.6-102.4-125.4zM393.4 288H328v112c0 8.8-7.2 16-16 16h-48c-8.8 0-16-7.2-16-16V288h-65.4c-14.3 0-21.4-17.2-11.3-27.3l105.4-105.4c6.2-6.2 16.4-6.2 22.6 0l105.4 105.4c10.1 10.1 2.9 27.3-11.3 27.3z`,fill:`currentColor`}),{width:640,height:512});G((0,V.jsx)(`path`,{d:`M480 416C497.7 416 512 430.3 512 448C512 465.7 497.7 480 480 480H150.6C133.7 480 117.4 473.3 105.4 461.3L25.37 381.3C.3786 356.3 .3786 315.7 25.37 290.7L258.7 57.37C283.7 32.38 324.3 32.38 349.3 57.37L486.6 194.7C511.6 219.7 511.6 260.3 486.6 285.3L355.9 416H480zM265.4 416L332.7 348.7L195.3 211.3L70.63 336L150.6 416L265.4 416z`}));var oS=G((0,V.jsxs)(`g`,{strokeWidth:1.25,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M8 13v-7.5a1.5 1.5 0 0 1 3 0v6.5`}),(0,V.jsx)(`path`,{d:`M11 5.5v-2a1.5 1.5 0 1 1 3 0v8.5`}),(0,V.jsx)(`path`,{d:`M14 5.5a1.5 1.5 0 0 1 3 0v6.5`}),(0,V.jsx)(`path`,{d:`M17 7.5a1.5 1.5 0 0 1 3 0v8.5a6 6 0 0 1 -6 6h-2h.208a6 6 0 0 1 -5.012 -2.7a69.74 69.74 0 0 1 -.196 -.3c-.312 -.479 -1.407 -2.388 -3.286 -5.728a1.5 1.5 0 0 1 .536 -2.022a1.867 1.867 0 0 1 2.28 .28l1.47 1.47`})]}),K),sS=G((0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2`}),(0,V.jsx)(`path`,{d:`M7 11l5 5l5 -5`}),(0,V.jsx)(`path`,{d:`M12 4l0 12`})]}),K),cS=G((0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M8 8m0 2a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2z`}),(0,V.jsx)(`path`,{d:`M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2`})]}),K),lS=G((0,V.jsxs)(`g`,{strokeWidth:1.25,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M7 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0`}),(0,V.jsx)(`path`,{d:`M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0`}),(0,V.jsx)(`path`,{d:`M9.15 14.85l8.85 -10.85`}),(0,V.jsx)(`path`,{d:`M6 4l8.85 10.85`})]}),K),uS=G((0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0`}),(0,V.jsx)(`path`,{d:`M12 17l0 .01`}),(0,V.jsx)(`path`,{d:`M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4`})]}),K);G((0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M7 4v16l13 -8z`})]}),K),G((0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M17 4h-10a3 3 0 0 0 -3 3v10a3 3 0 0 0 3 3h10a3 3 0 0 0 3 -3v-10a3 3 0 0 0 -3 -3z`,strokeWidth:`0`,fill:`currentColor`})]}),K);var dS=G((0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M5 12l5 5l10 -10`})]}),K),fS=G((0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M10.24 3.957l-8.422 14.06a1.989 1.989 0 0 0 1.7 2.983h16.845a1.989 1.989 0 0 0 1.7 -2.983l-8.423 -14.06a1.989 1.989 0 0 0 -3.4 0z`}),(0,V.jsx)(`path`,{d:`M12 9v4`}),(0,V.jsx)(`path`,{d:`M12 17h.01`})]}),K),pS=G((0,V.jsxs)(`g`,{strokeWidth:1.25,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M11 7l6 6`}),(0,V.jsx)(`path`,{d:`M4 16l11.7 -11.7a1 1 0 0 1 1.4 0l2.6 2.6a1 1 0 0 1 0 1.4l-11.7 11.7h-4v-4z`})]}),K),mS=G((0,V.jsxs)(`g`,{strokeWidth:1.5,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M4 7l16 0`}),(0,V.jsx)(`path`,{d:`M4 17l16 0`}),(0,V.jsx)(`path`,{d:`M7 4l0 16`}),(0,V.jsx)(`path`,{d:`M17 4l0 16`})]}),K),hS=G((0,V.jsx)(`path`,{fill:`currentColor`,d:`M407.48,111.18C335.587,108.103 269.573,152.338 245.08,220C220.587,152.338 154.573,108.103 82.68,111.18C80.285,168.229 107.577,222.632 154.74,254.82C178.908,271.419 193.35,298.951 193.27,328.27L193.27,379.13L296.9,379.13L296.9,328.27C296.816,298.953 311.255,271.42 335.42,254.82C382.596,222.644 409.892,168.233 407.48,111.18Z`})),gS=G((0,V.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4`}),(0,V.jsx)(`path`,{d:`M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4`})]}),K),_S=G((0,V.jsxs)(`g`,{children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M6 10l-2 1l8 4l8 -4l-2 -1`}),(0,V.jsx)(`path`,{d:`M4 15l8 4l8 -4`}),(0,V.jsx)(`path`,{d:`M12 4v7`}),(0,V.jsx)(`path`,{d:`M15 8l-3 3l-3 -3`})]}),K),vS=G((0,V.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,V.jsx)(`path`,{d:`M4.16602 10H15.8327`}),(0,V.jsx)(`path`,{d:`M12.5 13.3333L15.8333 10`}),(0,V.jsx)(`path`,{d:`M12.5 6.66666L15.8333 9.99999`})]}),q),yS=G((0,V.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M3 9.5a6.5 6.5 0 1 0 13 0a6.5 6.5 0 1 0 -13 0`}),(0,V.jsx)(`path`,{d:`M10 12a2 2 0 0 1 2 -2h7a2 2 0 0 1 2 2v7a2 2 0 0 1 -2 2h-7a2 2 0 0 1 -2 -2l0 -7`})]}),K),bS=G((0,V.jsxs)(`g`,{fill:`none`,stroke:`currentColor`,strokeWidth:`1.25`,strokeLinecap:`round`,strokeLinejoin:`round`,transform:`rotate(90 10 10)`,children:[(0,V.jsx)(`path`,{clipRule:`evenodd`,d:`m9.644 13.69 7.774-7.773a2.357 2.357 0 0 0-3.334-3.334l-7.773 7.774L8 12l1.643 1.69Z`}),(0,V.jsx)(`path`,{d:`m13.25 3.417 3.333 3.333M10 10l2-2M5 15l3-3M2.156 17.894l1-1M5.453 19.029l-.144-1.407M2.377 11.887l.866 1.118M8.354 17.273l-1.194-.758M.953 14.652l1.408.13`})]}),20),xS=G((0,V.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`}),(0,V.jsx)(`path`,{d:`M6 21l15 -15l-3 -3l-15 15l3 3`}),(0,V.jsx)(`path`,{d:`M15 6l3 3`}),(0,V.jsx)(`path`,{d:`M9 3a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2`}),(0,V.jsx)(`path`,{d:`M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2`})]}),K);G((0,V.jsxs)(`g`,{strokeWidth:1.25,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`}),(0,V.jsx)(`path`,{d:`M6 21l15 -15l-3 -3l-15 15l3 3`}),(0,V.jsx)(`path`,{d:`M15 6l3 3`}),(0,V.jsx)(`path`,{d:`M9 3a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2`}),(0,V.jsx)(`path`,{d:`M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2`})]}),K),G((0,V.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M11.217 19.384a3.501 3.501 0 0 0 6.783 -1.217v-5.167l-6 -3.35`}),(0,V.jsx)(`path`,{d:`M5.214 15.014a3.501 3.501 0 0 0 4.446 5.266l4.34 -2.534v-6.946`}),(0,V.jsx)(`path`,{d:`M6 7.63c-1.391 -.236 -2.787 .395 -3.534 1.689a3.474 3.474 0 0 0 1.271 4.745l4.263 2.514l6 -3.348`}),(0,V.jsx)(`path`,{d:`M12.783 4.616a3.501 3.501 0 0 0 -6.783 1.217v5.067l6 3.45`}),(0,V.jsx)(`path`,{d:`M18.786 8.986a3.501 3.501 0 0 0 -4.446 -5.266l-4.34 2.534v6.946`}),(0,V.jsx)(`path`,{d:`M18 16.302c1.391 .236 2.787 -.395 3.534 -1.689a3.474 3.474 0 0 0 -1.271 -4.745l-4.308 -2.514l-5.955 3.42`})]}),K);var SS=G((0,V.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M4 8v-2a2 2 0 0 1 2 -2h2`}),(0,V.jsx)(`path`,{d:`M4 16v2a2 2 0 0 0 2 2h2`}),(0,V.jsx)(`path`,{d:`M16 4h2a2 2 0 0 1 2 2v2`}),(0,V.jsx)(`path`,{d:`M16 20h2a2 2 0 0 0 2 -2v-2`})]}),K),CS=G((0,V.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,strokeWidth:1.5,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0`}),(0,V.jsx)(`path`,{d:`M21 12c-2.4 4 -5.4 6 -9 6c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6`})]}),K),wS=G((0,V.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M10.585 10.587a2 2 0 0 0 2.829 2.828`}),(0,V.jsx)(`path`,{d:`M16.681 16.673a8.717 8.717 0 0 1 -4.681 1.327c-3.6 0 -6.6 -2 -9 -6c1.272 -2.12 2.712 -3.678 4.32 -4.674m2.86 -1.146a9.055 9.055 0 0 1 1.82 -.18c3.6 0 6.6 2 9 6c-.666 1.11 -1.379 2.067 -2.138 2.87`}),(0,V.jsx)(`path`,{d:`M3 3l18 18`})]}),K),TS=G((0,V.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M15.5 13a3.5 3.5 0 0 0 -3.5 3.5v1a3.5 3.5 0 0 0 7 0v-1.8`}),(0,V.jsx)(`path`,{d:`M8.5 13a3.5 3.5 0 0 1 3.5 3.5v1a3.5 3.5 0 0 1 -7 0v-1.8`}),(0,V.jsx)(`path`,{d:`M17.5 16a3.5 3.5 0 0 0 0 -7h-.5`}),(0,V.jsx)(`path`,{d:`M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0`}),(0,V.jsx)(`path`,{d:`M6.5 16a3.5 3.5 0 0 1 0 -7h.5`}),(0,V.jsx)(`path`,{d:`M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10`})]}),K),ES=G((0,V.jsxs)(`g`,{strokeWidth:1.25,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M15.5 13a3.5 3.5 0 0 0 -3.5 3.5v1a3.5 3.5 0 0 0 7 0v-1.8`}),(0,V.jsx)(`path`,{d:`M8.5 13a3.5 3.5 0 0 1 3.5 3.5v1a3.5 3.5 0 0 1 -7 0v-1.8`}),(0,V.jsx)(`path`,{d:`M17.5 16a3.5 3.5 0 0 0 0 -7h-.5`}),(0,V.jsx)(`path`,{d:`M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0`}),(0,V.jsx)(`path`,{d:`M6.5 16a3.5 3.5 0 0 1 0 -7h.5`}),(0,V.jsx)(`path`,{d:`M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10`})]}),K),DS=G((0,V.jsxs)(`g`,{strokeWidth:1.5,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0`}),(0,V.jsx)(`path`,{d:`M21 21l-6 -6`})]}),K),OS=G((0,V.jsxs)(`g`,{strokeWidth:1.5,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M20.984 12.53a9 9 0 1 0 -7.552 8.355`}),(0,V.jsx)(`path`,{d:`M12 7v5l3 3`}),(0,V.jsx)(`path`,{d:`M19 16l-2 3h4l-2 3`})]}),K),kS=G((0,V.jsxs)(`g`,{strokeWidth:1.5,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M12 8l0 4l2 2`}),(0,V.jsx)(`path`,{d:`M3.05 11a9 9 0 1 1 .5 4m-.5 5v-5h5`})]}),K),AS=G((0,V.jsxs)(`g`,{strokeWidth:1.5,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M9 2m0 3a3 3 0 0 1 3 -3h0a3 3 0 0 1 3 3v5a3 3 0 0 1 -3 3h0a3 3 0 0 1 -3 -3z`}),(0,V.jsx)(`path`,{d:`M5 10a7 7 0 0 0 14 0`}),(0,V.jsx)(`path`,{d:`M8 21l8 0`}),(0,V.jsx)(`path`,{d:`M12 17l0 4`})]}),K),jS=G((0,V.jsxs)(`g`,{strokeWidth:1.5,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M3 3l18 18`}),(0,V.jsx)(`path`,{d:`M9 5a3 3 0 0 1 6 0v5a3 3 0 0 1 -.13 .874m-2 2a3 3 0 0 1 -3.87 -2.872v-1`}),(0,V.jsx)(`path`,{d:`M5 10a7 7 0 0 0 10.846 5.85m2 -2a6.967 6.967 0 0 0 1.152 -3.85`}),(0,V.jsx)(`path`,{d:`M8 21l8 0`}),(0,V.jsx)(`path`,{d:`M12 17l0 4`})]}),K),MS=G((0,V.jsxs)(`g`,{strokeWidth:1.25,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M13 3l0 7l6 0l-8 11l0 -7l-6 0l8 -11`})]}),K),NS=G((0,V.jsxs)(`g`,{children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M8 8m0 1a1 1 0 0 1 1 -1h6a1 1 0 0 1 1 1v6a1 1 0 0 1 -1 1h-6a1 1 0 0 1 -1 -1z`}),(0,V.jsx)(`path`,{d:`M12 20v.01`}),(0,V.jsx)(`path`,{d:`M16 20v.01`}),(0,V.jsx)(`path`,{d:`M8 20v.01`}),(0,V.jsx)(`path`,{d:`M4 20v.01`}),(0,V.jsx)(`path`,{d:`M4 16v.01`}),(0,V.jsx)(`path`,{d:`M4 12v.01`}),(0,V.jsx)(`path`,{d:`M4 8v.01`}),(0,V.jsx)(`path`,{d:`M4 4v.01`}),(0,V.jsx)(`path`,{d:`M8 4v.01`}),(0,V.jsx)(`path`,{d:`M12 4v.01`}),(0,V.jsx)(`path`,{d:`M16 4v.01`}),(0,V.jsx)(`path`,{d:`M20 4v.01`}),(0,V.jsx)(`path`,{d:`M20 8v.01`}),(0,V.jsx)(`path`,{d:`M20 12v.01`}),(0,V.jsx)(`path`,{d:`M20 16v.01`}),(0,V.jsx)(`path`,{d:`M20 20v.01`})]}),K),PS=G((0,V.jsxs)(`g`,{strokeWidth:1.25,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M5 3v18`}),(0,V.jsx)(`path`,{d:`M19 21v-18`}),(0,V.jsx)(`path`,{d:`M5 7h14`}),(0,V.jsx)(`path`,{d:`M5 15h14`}),(0,V.jsx)(`path`,{d:`M8 13v4`}),(0,V.jsx)(`path`,{d:`M11 13v4`}),(0,V.jsx)(`path`,{d:`M16 13v4`}),(0,V.jsx)(`path`,{d:`M14 5v4`}),(0,V.jsx)(`path`,{d:`M11 5v4`}),(0,V.jsx)(`path`,{d:`M8 5v4`}),(0,V.jsx)(`path`,{d:`M3 21h18`})]}),K),FS=G((0,V.jsxs)(`g`,{strokeWidth:1.25,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M3 12l18 0`}),(0,V.jsx)(`path`,{d:`M7 16l10 0l-10 5l0 -5`}),(0,V.jsx)(`path`,{d:`M7 8l10 0l-10 -5l0 5`})]}),K),IS=G((0,V.jsxs)(`g`,{strokeWidth:1.25,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M12 3l0 18`}),(0,V.jsx)(`path`,{d:`M16 7l0 10l5 0l-5 -10`}),(0,V.jsx)(`path`,{d:`M8 7l0 10l-5 0l5 -10`})]}),K),LS=G((0,V.jsxs)(`g`,{strokeWidth:1.25,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M5 3m0 2a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v2a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2z`}),(0,V.jsx)(`path`,{d:`M19 6h1a2 2 0 0 1 2 2a5 5 0 0 1 -5 5l-5 0v2`}),(0,V.jsx)(`path`,{d:`M10 15m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z`})]}),K),RS=G((0,V.jsxs)(`g`,{strokeWidth:1.25,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M15 15m-5 0a5 5 0 1 0 10 0a5 5 0 1 0 -10 0`}),(0,V.jsx)(`path`,{d:`M22 22l-3 -3`}),(0,V.jsx)(`path`,{d:`M6 18h-1a2 2 0 0 1 -2 -2v-1`}),(0,V.jsx)(`path`,{d:`M3 11v-1`}),(0,V.jsx)(`path`,{d:`M3 6v-1a2 2 0 0 1 2 -2h1`}),(0,V.jsx)(`path`,{d:`M10 3h1`}),(0,V.jsx)(`path`,{d:`M15 3h1a2 2 0 0 1 2 2v1`})]}),K),zS=G((0,V.jsxs)(`g`,{strokeWidth:1.25,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M14 3v4a1 1 0 0 0 1 1h4`}),(0,V.jsx)(`path`,{d:`M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4`}),(0,V.jsx)(`path`,{d:`M4 20.25c0 .414 .336 .75 .75 .75h1.25a1 1 0 0 0 1 -1v-1a1 1 0 0 0 -1 -1h-1a1 1 0 0 1 -1 -1v-1a1 1 0 0 1 1 -1h1.25a.75 .75 0 0 1 .75 .75`}),(0,V.jsx)(`path`,{d:`M10 15l2 6l2 -6`}),(0,V.jsx)(`path`,{d:`M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3`})]}),K),BS=G((0,V.jsxs)(`g`,{strokeWidth:1.25,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M14 3v4a1 1 0 0 0 1 1h4`}),(0,V.jsx)(`path`,{d:`M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4`}),(0,V.jsx)(`path`,{d:`M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3`}),(0,V.jsx)(`path`,{d:`M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6`}),(0,V.jsx)(`path`,{d:`M11 21v-6l3 6v-6`})]}),K),VS=G((0,V.jsxs)(`g`,{strokeWidth:1.25,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M4 13v-8a2 2 0 0 1 2 -2h1a2 2 0 0 1 2 2v8a2 2 0 0 0 6 0v-8a2 2 0 0 1 2 -2h1a2 2 0 0 1 2 2v8a8 8 0 0 1 -16 0`}),(0,V.jsx)(`path`,{d:`M4 8l5 0`}),(0,V.jsx)(`path`,{d:`M15 8l4 0`})]}),K),HS=G((0,V.jsxs)(`g`,{strokeWidth:1.25,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M3 14c.83 .642 2.077 1.017 3.5 1c1.423 .017 2.67 -.358 3.5 -1c.83 -.642 2.077 -1.017 3.5 -1c1.423 -.017 2.67 .358 3.5 1`}),(0,V.jsx)(`path`,{d:`M8 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2`}),(0,V.jsx)(`path`,{d:`M12 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2`}),(0,V.jsx)(`path`,{d:`M3 10h14v5a6 6 0 0 1 -6 6h-2a6 6 0 0 1 -6 -6v-5z`}),(0,V.jsx)(`path`,{d:`M16.746 16.726a3 3 0 1 0 .252 -5.555`})]}),K),US=G((0,V.jsxs)(`g`,{stroke:`currentColor`,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M3 5a1 1 0 0 1 1-1h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1h-16a1 1 0 0 1-1-1v-10zM7 20h10M9 16v4M15 16v4`})]}),{...K,strokeWidth:1.5});G((0,V.jsxs)(`g`,{strokeWidth:1.5,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M15 8v-2a2 2 0 0 0 -2 -2h-7a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h7a2 2 0 0 0 2 -2v-2`}),(0,V.jsx)(`path`,{d:`M21 12h-13l3 -3`}),(0,V.jsx)(`path`,{d:`M11 15l-3 -3`})]}),K);var WS=G((0,V.jsxs)(`g`,{children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M2 8a4 4 0 0 1 4 -4h12a4 4 0 0 1 4 4v8a4 4 0 0 1 -4 4h-12a4 4 0 0 1 -4 -4v-8z`}),(0,V.jsx)(`path`,{d:`M10 9l5 3l-5 3z`})]}),K),GS=G((0,V.jsxs)(`g`,{strokeWidth:1.5,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M3 6h18`}),(0,V.jsx)(`path`,{d:`M3 12h18`}),(0,V.jsx)(`path`,{d:`M3 18h18`}),(0,V.jsx)(`path`,{d:`M6 3v18`}),(0,V.jsx)(`path`,{d:`M12 3v18`}),(0,V.jsx)(`path`,{d:`M18 3v18`})]}),K),KS=G((0,V.jsxs)(`g`,{strokeWidth:1.5,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M17 3m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z`}),(0,V.jsx)(`path`,{d:`M3 17m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z`}),(0,V.jsx)(`path`,{d:`M17 5c-6.627 0 -12 5.373 -12 12`})]}),K),qS=G((0,V.jsxs)(`g`,{children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M6 18l12 -12`}),(0,V.jsx)(`path`,{d:`M18 10v-4h-4`})]}),K),JS=G((0,V.jsxs)(`g`,{children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M4,19L10,19C11.097,19 12,18.097 12,17L12,9C12,7.903 12.903,7 14,7L21,7`}),(0,V.jsx)(`path`,{d:`M18 4l3 3l-3 3`})]}),K),YS=G((0,V.jsxs)(`g`,{children:[(0,V.jsx)(`path`,{d:`M16,12L20,9L16,6`}),(0,V.jsx)(`path`,{d:`M6 20c0 -6.075 4.925 -11 11 -11h3`})]}),K),XS=G((0,V.jsxs)(`g`,{children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M6 9l6 6l6 -6`})]}),K),ZS=G((0,V.jsxs)(`g`,{children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M6 15l6 -6l6 6`})]}),K),QS=G((0,V.jsxs)(`g`,{children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M6 15l6 -6l6 6`})]}),K),$S=G((0,V.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M8 5v10a1 1 0 0 0 1 1h10`}),(0,V.jsx)(`path`,{d:`M5 8h10a1 1 0 0 1 1 1v10`})]}),K),eC=G((0,V.jsxs)(`g`,{children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M5 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,V.jsx)(`path`,{d:`M19 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,V.jsx)(`path`,{d:`M5 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,V.jsx)(`path`,{d:`M19 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,V.jsx)(`path`,{d:`M5 7l0 10`}),(0,V.jsx)(`path`,{d:`M7 5l10 0`}),(0,V.jsx)(`path`,{d:`M7 19l10 0`}),(0,V.jsx)(`path`,{d:`M19 7l0 10`})]}),K);G((0,V.jsxs)(`g`,{strokeWidth:1.5,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M4 11v8a1 1 0 0 0 1 1h8m-9 -14v-1a1 1 0 0 1 1 -1h1m5 0h2m5 0h1a1 1 0 0 1 1 1v1m0 5v2m0 5v1a1 1 0 0 1 -1 1h-1`}),(0,V.jsx)(`path`,{d:`M4 12h7a1 1 0 0 1 1 1v7`})]}),K);var tC=G((0,V.jsxs)(`g`,{strokeWidth:1.5,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M14 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,V.jsx)(`path`,{d:`M4 6l8 0`}),(0,V.jsx)(`path`,{d:`M16 6l4 0`}),(0,V.jsx)(`path`,{d:`M8 12m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,V.jsx)(`path`,{d:`M4 12l2 0`}),(0,V.jsx)(`path`,{d:`M10 12l10 0`}),(0,V.jsx)(`path`,{d:`M17 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,V.jsx)(`path`,{d:`M4 18l11 0`}),(0,V.jsx)(`path`,{d:`M19 18l1 0`})]}),K),nC=G((0,V.jsxs)(`g`,{strokeWidth:1,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M6 10l4 -4 L6 14l8 -8 L6 18l12 -12 L10 18l8 -8 L14 18l4 -4`})]}),K),rC=G((0,V.jsxs)(`g`,{strokeWidth:1.25,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4`}),(0,V.jsx)(`path`,{d:`M13.5 6.5l4 4`})]}),K);G((0,V.jsxs)(`g`,{strokeWidth:1,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M11 7l-5 5l5 5`}),(0,V.jsx)(`path`,{d:`M17 7l-5 5l5 5`})]}),K);var iC=G((0,V.jsxs)(`g`,{strokeWidth:`1.75`,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M4 4m0 2a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2z`}),(0,V.jsx)(`path`,{d:`M15 4l0 16`})]}),K);G((0,V.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M3 20l1.3 -3.9c-2.324 -3.437 -1.426 -7.872 2.1 -10.374c3.526 -2.501 8.59 -2.296 11.845 .48c3.255 2.777 3.695 7.266 1.029 10.501c-2.666 3.235 -7.615 4.215 -11.574 2.293l-4.7 1`})]}),K),G((0,V.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M3 4l18 0`}),(0,V.jsx)(`path`,{d:`M4 4v10a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-10`}),(0,V.jsx)(`path`,{d:`M12 16l0 4`}),(0,V.jsx)(`path`,{d:`M9 20l6 0`}),(0,V.jsx)(`path`,{d:`M8 12l3 -3l2 2l3 -3`})]}),K);var aC=(0,V.jsx)(`div`,{style:{width:`1rem`,height:`1rem`}}),oC=G((0,V.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`polyline`,{points:`6 9 12 15 18 9`})]}),K),sC=G((0,V.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`polyline`,{points:`9 6 15 12 9 18`})]}),K),cC=G((0,V.jsxs)(`g`,{strokeWidth:1.25,children:[(0,V.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,V.jsx)(`path`,{d:`M14 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,V.jsx)(`path`,{d:`M4 6l8 0`}),(0,V.jsx)(`path`,{d:`M16 6l4 0`}),(0,V.jsx)(`path`,{d:`M8 12m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,V.jsx)(`path`,{d:`M4 12l2 0`}),(0,V.jsx)(`path`,{d:`M10 12l10 0`}),(0,V.jsx)(`path`,{d:`M17 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,V.jsx)(`path`,{d:`M4 18l11 0`}),(0,V.jsx)(`path`,{d:`M19 18l1 0`})]}),K),lC=({size:e=`1em`,circleWidth:t=8,synchronized:n=!1,className:r=``})=>{let i=-(B.useRef(Date.now()).current%1600);return(0,V.jsx)(`div`,{className:`Spinner ${r}`,children:(0,V.jsx)(`svg`,{viewBox:`0 0 100 100`,style:{width:e,height:e,"--spinner-delay":n?`${i}ms`:0},children:(0,V.jsx)(`circle`,{cx:`50`,cy:`50`,r:50-t/2,strokeWidth:t,fill:`none`,strokeMiterlimit:`10`})})})},J=B.forwardRef(({size:e=`medium`,visible:t=!0,className:n=``,...r},i)=>{let a=B.useRef(null);B.useImperativeHandle(i,()=>a.current);let o=`ToolIcon_size_${e}`,[s,c]=(0,B.useState)(!1),l=(0,B.useRef)(!0),u=async e=>{let t=`onClick`in r&&r.onClick?.(e);if(nt(t))try{c(!0),await t}catch(e){if(e instanceof Cn)console.warn(e);else throw e}finally{l.current&&c(!1)}};(0,B.useEffect)(()=>(l.current=!0,()=>{l.current=!1}),[]);let d=(0,B.useRef)(null);return r.type===`button`||r.type===`icon`?(0,V.jsxs)(`button`,{className:H(`ToolIcon_type_button`,o,n,t&&!r.hidden?`ToolIcon_type_button--show`:`ToolIcon_type_button--hide`,{ToolIcon:!r.hidden,"ToolIcon--plain":r.type===`icon`}),style:r.style,"data-testid":r[`data-testid`],hidden:r.hidden,title:r.title,"aria-label":r[`aria-label`],type:`button`,onClick:u,ref:a,disabled:s||r.isLoading||!!r.disabled,children:[(r.icon||r.label)&&(0,V.jsxs)(`div`,{className:`ToolIcon__icon`,"aria-hidden":`true`,"aria-disabled":!!r.disabled,children:[r.icon||r.label,r.keyBindingLabel&&(0,V.jsx)(`span`,{className:`ToolIcon__keybinding`,children:r.keyBindingLabel}),r.isLoading&&(0,V.jsx)(lC,{})]}),r.showAriaLabel&&(0,V.jsxs)(`div`,{className:`ToolIcon__label`,children:[r[`aria-label`],` `,s&&(0,V.jsx)(lC,{})]}),r.children]}):(0,V.jsx)(`button`,{className:H(`ToolIcon`,`ToolIcon_type_toggle`,o,n,{"ToolIcon--checked":r.checked}),type:`button`,style:r.style,title:r.title,"aria-label":r[`aria-label`],"aria-keyshortcuts":r[`aria-keyshortcuts`],"aria-pressed":r.checked,"data-testid":r[`data-testid`],disabled:!!r.disabled,"aria-disabled":!!r.disabled,onPointerDown:e=>{d.current=e.pointerType||null},onPointerUp:()=>{requestAnimationFrame(()=>{d.current=null})},onClick:()=>{r.onSelect?.({pointerType:d.current})},ref:a,children:(0,V.jsxs)(`div`,{className:`ToolIcon__icon`,children:[r.icon,r.keyBindingLabel&&(0,V.jsx)(`span`,{className:`ToolIcon__keybinding`,children:r.keyBindingLabel})]})})});J.displayName=`IconButton`;var uC=[],Y=e=>(uC=uC.concat(e),e),dC=(e,t,n)=>{let r=new Set(xt(e.filter(e=>P(e)),t).map(e=>e.id)),i={},a=n.scene.getNonDeletedElementsMap(),o=new Set;for(let t of r){let n=Yn(e,t);for(let e of n)if(!o.has(e.id)){if(cs(e)){let t=Go(e,a);t&&(i[t.id]=!0)}else i[e.id]=!0;o.add(e.id)}}let s=!0,c=e.map(e=>{if(t.selectedElementIds[e.id]){let t=cs(e)?Go(e,a):null;return e.frameId&&r.has(e.frameId)?(s=!1,i[e.id]=!0,e):t?.frameId&&r.has(t?.frameId)?e:(e.boundElements&&e.boundElements.forEach(t=>{let r=n.scene.getNonDeletedElementsMap().get(t.id);r&&ve(r)&&n.scene.mutateElement(r,{startBinding:e.id===r.startBinding?.elementId?null:r.startBinding,endBinding:e.id===r.endBinding?.elementId?null:r.endBinding})}),R(e,{isDeleted:!0}))}return e.frameId&&r.has(e.frameId)?(s=!1,cs(e)||(i[e.id]=!0),R(e,{frameId:null})):cs(e)&&t.selectedElementIds[e.containerId]?R(e,{isDeleted:!0}):e}),l=t.editingGroupId;if(s&&t.editingGroupId){let e=yt(c,t.editingGroupId).filter(e=>!e.isDeleted);if(e.length>1)e[0]&&(i[e[0].id]=!0);else{l=null,e[0]&&(i[e[0].id]=!0);let n=e[0];if(n){let e=n.groupIds.findIndex(e=>e===t.editingGroupId),r=n.groupIds[e+1];if(r){let e=yt(c,r).filter(e=>!e.isDeleted);e.length>1&&(l=r,e.forEach(e=>{i[e.id]=!0}))}}}}return{elements:c,appState:{...t,...na({selectedElementIds:i,editingGroupId:l},et(c),t,null)}}},fC=(e,t)=>{if(e.editingGroupId){let n=yt(et(t),e.editingGroupId);if(n.length)return{...e,selectedElementIds:{[n[0].id]:!0}}}return e},pC=Y({name:`deleteSelectedElements`,label:`labels.delete`,icon:yb,trackEvent:{category:`element`,action:`delete`},perform:(e,t,n,r)=>{if(t.selectedLinearElement?.isEditing){let{elementId:n,selectedPointsIndices:i}=t.selectedLinearElement,a=r.scene.getNonDeletedElementsMap(),o=N.getElement(n,a);if(!o||i==null)return!1;if(i.length>=o.points.length){let n=e.map(e=>e.id===o.id?R(e,{isDeleted:!0}):e);return{elements:n,appState:{...fC(t,n),selectedLinearElement:null},captureUpdate:F.IMMEDIATELY}}return N.deletePoints(o,r,i),{elements:e,appState:{...t,selectedLinearElement:{...t.selectedLinearElement,selectedPointsIndices:i?.[0]>0?[i[0]-1]:[0]}},captureUpdate:F.IMMEDIATELY}}let{elements:i,appState:a}=dC(e,t,r);return jo(i,i.filter(e=>e.isDeleted)),a=fC(a,i),{elements:i,appState:{...a,activeTool:Pt(t,{type:r.state.preferredSelectionTool.type}),multiElement:null,newElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:Bi(et(e),t)?F.IMMEDIATELY:F.EVENTUALLY}},keyTest:(e,t,n)=>(e.key===j.BACKSPACE||e.key===j.DELETE)&&!e[j.CTRL_OR_CMD],PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>{let i=sV()===`mobile`;return(0,V.jsx)(J,{type:`button`,icon:yb,title:W(`labels.delete`),"aria-label":W(`labels.delete`),onClick:()=>n(null),disabled:!Bi(et(e),t),style:{...i&&t.openPopup!==`compactOtherProperties`?On:{}}})}}),X=e=>e.replace(/\b(Opt(?:ion)?|Alt)\b/i,W(_t?`keys.option`:`keys.alt`)).replace(/\bShift\b/i,W(`keys.shift`)).replace(/\b(Enter|Return)\b/i,W(`keys.enter`)).replace(/\b(Ctrl|Cmd|Command|CtrlOrCmd)\b/gi,W(_t?`keys.cmd`:`keys.ctrl`)).replace(/\b(Esc(?:ape)?)\b/i,W(`keys.escape`)).replace(/\b(Space(?:bar)?)\b/i,W(`keys.spacebar`)).replace(/\b(Del(?:ete)?)\b/i,W(`keys.delete`)),mC=Y({name:`sendBackward`,label:`labels.sendBackward`,keywords:[`move down`,`zindex`,`layer`],icon:Xb,trackEvent:{category:`element`},perform:(e,t,n,r)=>({elements:Wt(e,t,r.scene),appState:t,captureUpdate:F.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[j.CTRL_OR_CMD]&&!e.shiftKey&&e.code===I.BRACKET_LEFT,PanelComponent:({updateData:e,appState:t})=>(0,V.jsx)(`button`,{type:`button`,className:`zIndexButton`,onClick:()=>e(null),title:`${W(`labels.sendBackward`)} \u2014 ${X(`CtrlOrCmd+[`)}`,children:Xb})}),hC=Y({name:`bringForward`,label:`labels.bringForward`,keywords:[`move up`,`zindex`,`layer`],icon:Yb,trackEvent:{category:`element`},perform:(e,t,n,r)=>({elements:Gt(e,t,r.scene),appState:t,captureUpdate:F.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[j.CTRL_OR_CMD]&&!e.shiftKey&&e.code===I.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:t})=>(0,V.jsx)(`button`,{type:`button`,className:`zIndexButton`,onClick:()=>e(null),title:`${W(`labels.bringForward`)} \u2014 ${X(`CtrlOrCmd+]`)}`,children:Yb})}),gC=Y({name:`sendToBack`,label:`labels.sendToBack`,keywords:[`move down`,`zindex`,`layer`],icon:Qb,trackEvent:{category:`element`},perform:(e,t)=>({elements:Ka(e,t),appState:t,captureUpdate:F.IMMEDIATELY}),keyTest:e=>_t?e[j.CTRL_OR_CMD]&&e.altKey&&e.code===I.BRACKET_LEFT:e[j.CTRL_OR_CMD]&&e.shiftKey&&e.code===I.BRACKET_LEFT,PanelComponent:({updateData:e,appState:t})=>(0,V.jsx)(`button`,{type:`button`,className:`zIndexButton`,onClick:()=>e(null),title:`${W(`labels.sendToBack`)} \u2014 ${X(_t?`CtrlOrCmd+Alt+[`:`CtrlOrCmd+Shift+[`)}`,children:Qb})}),_C=Y({name:`bringToFront`,label:`labels.bringToFront`,keywords:[`move up`,`zindex`,`layer`],icon:Zb,trackEvent:{category:`element`},perform:(e,t)=>({elements:Xe(e,t),appState:t,captureUpdate:F.IMMEDIATELY}),keyTest:e=>_t?e[j.CTRL_OR_CMD]&&e.altKey&&e.code===I.BRACKET_RIGHT:e[j.CTRL_OR_CMD]&&e.shiftKey&&e.code===I.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:t})=>(0,V.jsx)(`button`,{type:`button`,className:`zIndexButton`,onClick:t=>e(null),title:`${W(`labels.bringToFront`)} \u2014 ${X(_t?`CtrlOrCmd+Alt+]`:`CtrlOrCmd+Shift+]`)}`,children:Zb})}),vC=Y({name:`selectAll`,label:`labels.selectAll`,icon:NS,trackEvent:{category:`canvas`},viewMode:!1,perform:(e,t,n,r)=>{if(t.selectedLinearElement?.isEditing)return!1;let i=e.filter(e=>!e.isDeleted&&!(a(e)&&e.containerId)&&!e.locked).reduce((e,t)=>(e[t.id]=!0,e),{});return{appState:{...t,...na({editingGroupId:null,selectedElementIds:i},et(e),t,r),selectedLinearElement:Object.keys(i).length===1&&po(e[0])?new N(e[0],ui(e)):null},captureUpdate:F.IMMEDIATELY}},keyTest:e=>e[j.CTRL_OR_CMD]&&e.key===j.A}),yC=Y({name:`duplicateSelection`,label:`labels.duplicateSelection`,icon:xb,trackEvent:{category:`element`},perform:(e,t,n,r)=>{if(t.selectedElementsAreBeingDragged)return!1;if(t.selectedLinearElement?.isEditing)try{return{elements:e,appState:N.duplicateSelectedPoints(t,r.scene),captureUpdate:F.IMMEDIATELY}}catch{return!1}let{duplicatedElements:i,elementsWithDuplicates:a}=bc({type:`in-place`,elements:e,idsOfElementsToDuplicate:ui(xt(e,t,{includeBoundTextElement:!0,includeElementsInFrames:!0})),appState:t,randomizeSeed:!0,overrides:({origElement:e,origIdToDuplicateId:t})=>{let n=e.frameId&&t.get(e.frameId);return{x:e.x+10,y:e.y+10,frameId:n??e.frameId}}});if(r.props.onDuplicate&&a){let t=r.props.onDuplicate(a,e);t&&(a=t)}return{elements:Ie(a,ui(i)),appState:{...t,...E(i,et(a),t)},captureUpdate:F.IMMEDIATELY}},keyTest:e=>e[j.CTRL_OR_CMD]&&e.key===j.D,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>{let i=sV()===`mobile`;return(0,V.jsx)(J,{type:`button`,icon:xb,title:`${W(`labels.duplicateSelection`)} \u2014 ${X(`CtrlOrCmd+D`)}`,"aria-label":W(`labels.duplicateSelection`),onClick:()=>n(null),disabled:!Bi(et(e),t),style:{...i&&t.openPopup!==`compactOtherProperties`?On:{}}})}}),bC=new Set([`command_palette`,`export`]),xC=(e,t,n,r)=>{try{if(typeof window>`u`||ne.VITE_WORKER_ID||ne.VITE_APP_ENABLE_TRACKING!==`true`||!bC.has(e)||ci())return;ne.PROD||console.info(`trackEvent`,{category:e,action:t,label:n,value:r}),window.sa_event&&window.sa_event(t,{category:e,label:n,value:r})}catch(e){console.error(`error during analytics`,e)}},SC=(0,B.forwardRef)((e,t)=>{let{title:n,className:r,testId:i,active:a,icon:o,onClick:s}=e;return(0,V.jsx)(`button`,{type:`button`,ref:t,title:n,"data-testid":i,className:H(r,{active:a}),onClick:s,style:e.style,children:o},n)}),CC=e=>(0,V.jsx)(V.Fragment,{children:e.options.map(t=>e.type===`button`?(0,V.jsx)(SC,{icon:t.icon,title:t.text,testId:t.testId,active:t.active??e.value===t.value,onClick:n=>e.onClick(t.value,n)},t.text):(0,V.jsxs)(`label`,{className:H({active:e.value===t.value}),title:t.text,children:[(0,V.jsx)(`input`,{type:`radio`,name:e.group,onChange:()=>e.onChange(t.value),checked:e.value===t.value,"data-testid":t.testId}),t.icon]},t.text))}),wC=()=>(0,V.jsx)(`div`,{style:{width:1,height:`1rem`,backgroundColor:`var(--default-border-color)`,margin:`0 auto`}}),TC=B.createContext(null),EC=()=>B.useContext(TC),DC=e=>{let[t,n]=(0,B.useState)(null),r=oV(),{theme:i}=EC(),{container:a}=cV();return(0,B.useLayoutEffect)(()=>{t&&(t.className=``,t.classList.add(`excalidraw`,...e?.className?.split(/\s+/)||[]),t.classList.toggle(`excalidraw--mobile`,r.formFactor===`phone`),t.classList.toggle(`theme--dark`,i===A.DARK))},[t,i,r.formFactor,e?.className]),(0,B.useLayoutEffect)(()=>{let t=e?.parentSelector?a?.querySelector(e.parentSelector):document.body;if(!t)return;let r=document.createElement(`div`);return t.appendChild(r),n(r),()=>{t.removeChild(r)}},[a,e?.parentSelector]),t};function OC(e,t,n){(0,B.useEffect)(()=>{function r(r){let i=r;if(!e.current)return;let a=n?.(i,e.current);if(a!==!0){if(a===!1)return t(i);e.current.contains(i.target)||!document.documentElement.contains(i.target)||i.target.closest(`[data-radix-portal]`)||i.target===document.documentElement&&document.body.style.pointerEvents===`none`||i.target.closest(`[data-prevent-outside-click]`)||t(i)}}return document.addEventListener(T.POINTER_DOWN,r),document.addEventListener(T.TOUCH_START,r),()=>{document.removeEventListener(T.POINTER_DOWN,r),document.removeEventListener(T.TOUCH_START,r)}},[e,t,n])}var kC=e=>{let t=(0,B.useRef)(e);return Object.assign(t.current,e),t.current},AC=({cursorPosition:e,elementSize:t,containerSize:n,gap:r})=>{let i=e+r+t>n?e-r-t:e+r;return ss(i,0,Math.max(0,n-t))},jC=({cursor:e,element:t,container:n,gap:r})=>({left:AC({cursorPosition:e.x-n.left,elementSize:t.width,containerSize:n.width,gap:r}),top:AC({cursorPosition:e.y-n.top,elementSize:t.height,containerSize:n.height,gap:r})}),MC=Gc(null),NC=({onCancel:e,onChange:t,onSelect:n,colorPickerType:r})=>{let i=DC({className:`excalidraw-eye-dropper-backdrop`,parentSelector:`.excalidraw-eye-dropper-container`}),a=EC(),o=lV(),s=iV(),c=kC({app:s,onCancel:e,onChange:t,onSelect:n,selectedElements:xt(o,a)}),{container:l}=cV();(0,B.useEffect)(()=>{let e=u.current;if(!e||!s.canvas||!i)return;let t=!1,n=s.canvas.getContext(`2d`),o=({clientX:e,clientY:t})=>{let r=n.getImageData((e-a.offsetLeft)*window.devicePixelRatio,(t-a.offsetTop)*window.devicePixelRatio,1,1).data;return ce(r[0],r[1],r[2])},d=({clientX:n,clientY:a,altKey:s})=>{let{top:l,left:u}=jC({cursor:{x:n,y:a},element:{width:e.offsetWidth,height:e.offsetHeight},container:i.getBoundingClientRect(),gap:20});e.style.top=`${l}px`,e.style.left=`${u}px`;let d=o({clientX:n,clientY:a});t&&c.onChange(r,d,c.selectedElements,{altKey:s}),e.style.background=d},f=()=>{c.onCancel()},p=(e,t)=>{c.onSelect(e,t)},m=e=>{t=!0,e.stopImmediatePropagation()},h=e=>{t=!1,l?.focus(),e.stopImmediatePropagation(),e.preventDefault(),p(o(e),e)},g=e=>{e.key===j.ESCAPE&&(e.preventDefault(),e.stopImmediatePropagation(),f())};return i.tabIndex=-1,i.focus(),d({clientX:c.app.viewport.lastPosition.x,clientY:c.app.viewport.lastPosition.y,altKey:!1}),i.addEventListener(T.KEYDOWN,g),i.addEventListener(T.POINTER_DOWN,m),i.addEventListener(T.POINTER_UP,h),window.addEventListener(`pointermove`,d,{passive:!0}),window.addEventListener(T.BLUR,f),()=>{t=!1,i.removeEventListener(T.KEYDOWN,g),i.removeEventListener(T.POINTER_DOWN,m),i.removeEventListener(T.POINTER_UP,h),window.removeEventListener(`pointermove`,d),window.removeEventListener(T.BLUR,f)}},[c,s.canvas,i,r,l,a.offsetLeft,a.offsetTop]);let u=(0,B.useRef)(null);return OC(u,()=>{e()},e=>!!e.target.closest(`.excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop`)),i?(0,Uc.createPortal)((0,V.jsx)(`div`,{ref:u,className:`excalidraw-eye-dropper-preview`}),i):null},PC=B.forwardRef(({children:e,padding:t,className:n,style:r,"data-viewport-ui":i,"data-viewport-ui-name":a},o)=>(0,V.jsx)(`div`,{className:H(`Island`,n),style:{"--padding":t,...r},"data-viewport-ui":i,"data-viewport-ui-name":a,ref:o,children:e})),FC=B.forwardRef(({className:e,container:t,children:n,style:r,onClose:i,onKeyDown:a,onFocusOutside:o,onPointerLeave:s,onPointerDownOutside:c,preventAutoFocusOnTouch:l=!1},u)=>{let d=oV(),f=d.formFactor===`phone`&&!d.isLandscape;return(0,V.jsx)(uv,{container:t,children:(0,V.jsxs)(dv,{ref:u,className:H(`focus-visible-none`,e),"data-prevent-outside-click":!0,side:f?`bottom`:`right`,align:f?`center`:`start`,alignOffset:-16,sideOffset:20,collisionBoundary:t??void 0,style:{zIndex:`var(--zIndex-ui-styles-popup)`,marginLeft:d.formFactor===`phone`?`0.5rem`:void 0},onPointerLeave:s,onKeyDown:a,onFocusOutside:o,onPointerDownOutside:c,onOpenAutoFocus:e=>{l&&d.isTouchScreen&&e.preventDefault()},onCloseAutoFocus:e=>{e.stopPropagation(),e.preventDefault(),t&&!bt(document.activeElement)&&t.focus(),i()},children:[(0,V.jsx)(PC,{padding:3,style:r,children:n}),(0,V.jsx)(pv,{width:20,height:10,style:{fill:`var(--popup-bg-color)`,filter:`drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)`}})]})})}),IC=()=>document.querySelector(`.excalidraw-wysiwyg`),LC=()=>{let e=IC();return e?{start:e.selectionStart,end:e.selectionEnd}:null},RC=e=>{setTimeout(()=>{let t=IC();t&&(t.focus(),e&&(t.selectionStart=e.start,t.selectionEnd=e.end))},0)},zC=(e,t,n,r)=>{t&&r&&r();let i=t&&n?LC():null;e(),t&&n&&RC(i)},BC=()=>{let[e,t]=(0,B.useState)(null);return{saveCaretPosition:(0,B.useCallback)(()=>{let e=LC();t(e)},[]),restoreCaretPosition:(0,B.useCallback)(()=>{setTimeout(()=>{let n=IC();n&&(n.focus(),e&&(n.selectionStart=e.start,n.selectionEnd=e.end,t(null)))},0)},[e]),clearSavedPosition:(0,B.useCallback)(()=>{t(null)},[]),hasSavedPosition:!!e}},VC=(e=100)=>{let t=IC();if(t){let n=t.onblur;t.onblur=null,setTimeout(()=>{t.onblur=n},e)}},HC=({palette:e,color:t})=>{if(!t)return null;for(let[n,r]of Object.entries(e))if(Array.isArray(r)){let e=r.indexOf(t);if(e>-1)return{colorName:n,shade:e}}else if(r===t)return{colorName:n,shade:null};return null},UC=[[`q`,`w`,`e`,`r`,`t`],[`a`,`s`,`d`,`f`,`g`],[`z`,`x`,`c`,`v`,`b`]].flat(),WC=({color:e,palette:t})=>!Object.values(t).flat().includes(e),GC=(e,t,n)=>{let r={elementBackground:`backgroundColor`,elementStroke:`strokeColor`},i=e.filter(e=>{if(e.isDeleted)return!1;let i=e[r[t]];return!ei(i)&&WC({color:i,palette:n})}),a=new Map;return i.forEach(e=>{let n=e[r[t]];a.has(n)?a.set(n,a.get(n)+1):a.set(n,1)}),[...a.entries()].sort((e,t)=>t[1]-e[1]).map(e=>e[0]).slice(0,5)},KC=Gc(null),qC=({color:e,onChange:t,label:n,colorPickerType:r,placeholder:i})=>{let a=oV(),[o,s]=(0,B.useState)(e),[c,l]=(0,B.useState)(null),[u,d]=wy(KC);(0,B.useEffect)(()=>{s(e)},[e]);let f=(0,B.useCallback)(e=>{let n=e.toLowerCase().trim(),r=go(n);r?(t(r),l(null)):n.length===0?l(null):/^#?[0-9a-f]+$/.test(n)?l(W(`colorPicker.invalidHexLength`)):l(W(`colorPicker.invalidColor`)),s(n)},[t]),p=(0,B.useRef)(null),m=(0,B.useRef)(null);(0,B.useEffect)(()=>{p.current&&p.current.focus()},[u]);let[h,g]=wy(MC);return(0,B.useEffect)(()=>()=>{g(null)},[g]),(0,V.jsxs)(`div`,{className:`color-picker__input-label-container`,children:[(0,V.jsxs)(`div`,{className:H(`color-picker__input-label`,{"has-error":c}),children:[(0,V.jsx)(`div`,{className:`color-picker__input-hash`,children:`#`}),(0,V.jsx)(`input`,{ref:u===`hex`?p:void 0,style:{border:0,padding:0},spellCheck:!1,className:`color-picker-input`,"aria-label":n,"aria-invalid":!!c,onChange:e=>{f(e.target.value)},value:(o||``).replace(/^#/,``),onBlur:()=>{s(e),l(null)},tabIndex:-1,onFocus:()=>d(`hex`),onKeyDown:e=>{e.key!==j.TAB&&(e.key===j.ESCAPE&&m.current?.focus(),e.stopPropagation())},placeholder:i}),a.formFactor!==`phone`&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{style:{width:`1px`,height:`1.25rem`,backgroundColor:`var(--default-border-color)`}}),(0,V.jsx)(`div`,{ref:m,className:H(`excalidraw-eye-dropper-trigger`,{selected:h}),onClick:()=>g(e=>e?null:{keepOpenOnAlt:!1,onSelect:e=>t(e),colorPickerType:r}),title:`${W(`labels.eyeDropper`)} \u2014 ${j.I.toLocaleUpperCase()} or ${X(`Alt`)} `,children:pS})]})]}),c&&(0,V.jsx)(`div`,{className:`color-picker__error-message`,role:`alert`,children:c})]})},JC=({color:e,keyLabel:t,isShade:n=!1})=>(0,V.jsxs)(`div`,{className:`color-picker__button__hotkey-label`,style:{color:Js(e)?`#fff`:`#000`},children:[n&&`⇧`,t]}),YC=({colors:e,color:t,onChange:n,label:r})=>{let[i,a]=wy(KC),o=(0,B.useRef)(null);return(0,B.useEffect)(()=>{o.current&&o.current.focus()},[t,i]),(0,V.jsx)(`div`,{className:`color-picker-content--default`,children:e.map((e,i)=>(0,V.jsxs)(`button`,{ref:t===e?o:void 0,tabIndex:-1,type:`button`,className:H(`color-picker__button color-picker__button--large has-outline`,{active:t===e,"is-transparent":e===`transparent`||!e}),onClick:()=>{n(e),a(`custom`)},title:e,"aria-label":r,style:{"--swatch-color":e},children:[(0,V.jsx)(`div`,{className:`color-picker__button-outline`}),(0,V.jsx)(JC,{color:e,keyLabel:i+1})]},i))})},XC=({palette:e,color:t,onChange:n,activeShade:r,showHotKey:i=!0,excludedColors:a})=>{let o=HC({color:t,palette:e}),[s,c]=wy(KC),l=(0,B.useRef)(null);return(0,B.useEffect)(()=>{l.current&&s===`baseColors`&&l.current.focus()},[o?.colorName,s]),(0,V.jsx)(`div`,{className:`color-picker-content--default`,children:Object.entries(e).map(([e,t],s)=>{let u=(Array.isArray(t)?t[r]:t)||`transparent`;if(a?.includes(u))return(0,V.jsx)(`div`,{className:`color-picker__button color-picker__button--large`,style:{visibility:`hidden`},"aria-hidden":`true`},e);let d=UC[s],f=W(`colors.${e.replace(/\d+/,``)}`,null,``);return(0,V.jsxs)(`button`,{ref:o?.colorName===e?l:void 0,tabIndex:-1,type:`button`,className:H(`color-picker__button color-picker__button--large has-outline`,{active:o?.colorName===e,"is-transparent":u===`transparent`||!u}),onClick:()=>{n(u),c(`baseColors`)},title:`${f}${u.startsWith(`#`)?` ${u}`:``} \u2014 ${d}`,"aria-label":`${f} \u2014 ${d}`,style:u?{"--swatch-color":u}:void 0,"data-testid":`color-${e}`,children:[(0,V.jsx)(`div`,{className:`color-picker__button-outline`}),i&&(0,V.jsx)(JC,{color:u,keyLabel:d})]},e)})})},ZC=({children:e})=>(0,V.jsx)(`div`,{className:`color-picker__heading`,children:e}),QC=({color:e,onChange:t,palette:n,showHotKey:r})=>{let i=HC({color:e||`transparent`,palette:n}),[a,o]=wy(KC),s=(0,B.useRef)(null);if((0,B.useEffect)(()=>{s.current&&a===`shades`&&s.current.focus()},[i,a]),i){let{colorName:e,shade:c}=i,l=n[e];if(Array.isArray(l))return(0,V.jsx)(`div`,{className:`color-picker-content--default shades`,children:l.map((n,i)=>(0,V.jsxs)(`button`,{ref:i===c&&a===`shades`?s:void 0,tabIndex:-1,type:`button`,className:H(`color-picker__button color-picker__button--large has-outline`,{active:i===c}),"aria-label":`Shade`,title:`${e} - ${i+1}`,style:n?{"--swatch-color":n}:void 0,onClick:()=>{t(n),o(`shades`)},children:[(0,V.jsx)(`div`,{className:`color-picker__button-outline`}),r&&(0,V.jsx)(JC,{color:n,keyLabel:i+1,isShade:!0})]},i))})}return(0,V.jsxs)(`div`,{className:`color-picker-content--default`,style:{position:`relative`},tabIndex:-1,children:[(0,V.jsx)(`button`,{type:`button`,tabIndex:-1,className:`color-picker__button color-picker__button--large color-picker__button--no-focus-visible`}),(0,V.jsx)(`div`,{tabIndex:-1,style:{position:`absolute`,top:0,left:0,right:0,bottom:0,display:`flex`,alignItems:`center`,justifyContent:`center`,textAlign:`center`,fontSize:`0.75rem`},children:W(`colorPicker.noShades`)})]})},$C=(e,t,n)=>{let r=Math.ceil(n/5);switch(t??=-1,e){case`ArrowLeft`:{let e=t-1;return e<0?n-1:e}case`ArrowRight`:return(t+1)%n;case`ArrowDown`:{let e=t+5;return e>=n?t%5:e}case`ArrowUp`:{let e=t-5,i=e<0?5*r+e:e;return i>=n?void 0:i}}},ew=({e,colorObj:t,onChange:n,palette:r,customColors:i,setActiveColorPickerSection:a,activeShade:o,excludedColors:s})=>{if(t?.shade!=null&&[`Digit1`,`Digit2`,`Digit3`,`Digit4`,`Digit5`].includes(e.code)&&e.shiftKey){let i=Number(e.code.slice(-1))-1;return n(r[t.colorName][i]),a(`shades`),!0}if([`1`,`2`,`3`,`4`,`5`].includes(e.key)&&i[Number(e.key)-1])return n(i[Number(e.key)-1]),a(`custom`),!0;if(UC.includes(e.key)){let t=UC.indexOf(e.key),i=r[Object.keys(r)[t]],c=Array.isArray(i)?i[o]:i;return c==null||s?.includes(c)||(n(c),a(`baseColors`)),!0}return!1},tw=({event:e,activeColorPickerSection:t,palette:n,color:r,onChange:i,customColors:a,setActiveColorPickerSection:o,updateData:s,activeShade:c,onEyeDropperToggle:l,onEscape:u,excludedColors:d})=>{if(e[j.CTRL_OR_CMD])return!1;if(e.key===j.ESCAPE)return u(e),!0;if(e.key===j.ALT)return l(!0),!0;if(e.key===j.I)return l(),!0;let f=HC({color:r,palette:n});if(e.key===j.TAB){let s={custom:!!a.length,baseColors:!0,shades:f?.shade!=null,hex:!0},c=Object.entries(s).reduce((e,[t,n])=>(n&&e.push(t),e),[]),l=c.indexOf(t),u=e.shiftKey?-1:1,d=c[l+u>c.length-1?0:l+u<0?c.length-1:l+u];return d&&o(d),d===`custom`?i(a[0]):d===`baseColors`&&(Object.entries(n).find(([e,t])=>Array.isArray(t)?t.includes(r):t===r?e:null)||i(Ye.black)),e.preventDefault(),e.stopPropagation(),!0}if(ew({e,colorObj:f,onChange:i,palette:n,customColors:a,setActiveColorPickerSection:o,activeShade:c,excludedColors:d}))return!0;if(t===`shades`&&f){let{shade:t}=f,r=$C(e.key,t,5);if(r!==void 0)return i(n[f.colorName][r]),!0}if(t===`baseColors`&&f){let{colorName:t}=f,r=Object.keys(n),a=r.indexOf(t),o=$C(e.key,a,r.length),s=0;for(;o!==void 0&&s++<r.length;){let t=n[r[o]],i=Array.isArray(t)?t[c]:t;if(!d?.includes(i))break;o=$C(e.key,o,r.length)}if(o!==void 0){let e=n[r[o]];return i(Array.isArray(e)?e[c]:e),!0}}if(t===`custom`){let t=r==null?0:a.indexOf(r),n=$C(e.key,t,a.length);if(n!==void 0){let e=a[n];return i(e),!0}}return!1},nw=B.forwardRef(({color:e,onChange:t,type:n,elements:r,palette:i,updateData:a,children:o,showTitle:s,onEyeDropperToggle:c,onEscape:l,showHotKey:u=!0,excludedColors:d},f)=>{let p=s?n===`elementStroke`?W(`labels.stroke`):n===`elementBackground`?W(`labels.background`):null:null,[m]=B.useState(()=>n===`canvasBackground`?[]:GC(r,n,i)),[h,g]=wy(KC),_=HC({color:e,palette:i});(0,B.useEffect)(()=>{if(!h){let t=!!e&&WC({color:e,palette:i}),n=t&&!m.includes(e);g(n?null:t?`custom`:_?.shade==null?`baseColors`:`shades`)}},[h,e,i,g,_,m]);let[v,y]=(0,B.useState)(_?.shade??(n===`elementBackground`?1:4));(0,B.useEffect)(()=>{_?.shade!=null&&y(_.shade);let e=e=>{e.key===j.ALT&&c(!1)};return document.addEventListener(T.KEYUP,e,{capture:!0}),()=>{document.removeEventListener(T.KEYUP,e,{capture:!0})}},[_,c]);let b=B.useRef(null);return(0,B.useImperativeHandle)(f,()=>b.current),(0,B.useEffect)(()=>{b?.current?.focus()},[]),(0,V.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":W(`labels.colorPicker`),children:(0,V.jsxs)(`div`,{ref:b,onKeyDown:n=>{tw({event:n,activeColorPickerSection:h,palette:i,color:e,onChange:t,onEyeDropperToggle:c,customColors:m,setActiveColorPickerSection:g,updateData:a,activeShade:v,onEscape:l,excludedColors:d})&&(n.preventDefault(),n.stopPropagation())},className:`color-picker-content properties-content`,tabIndex:-1,children:[p&&(0,V.jsx)(`div`,{className:`color-picker__title`,children:p}),!!m.length&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(ZC,{children:W(`colorPicker.mostUsedCustomColors`)}),(0,V.jsx)(YC,{colors:m,color:e,label:W(`colorPicker.mostUsedCustomColors`),onChange:t})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(ZC,{children:W(`colorPicker.colors`)}),(0,V.jsx)(XC,{color:e,palette:i,onChange:t,activeShade:v,showHotKey:u,excludedColors:d})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(ZC,{children:W(`colorPicker.shades`)}),(0,V.jsx)(QC,{color:e,onChange:t,palette:i,showHotKey:u})]}),o]})})}),rw=({onChange:e,type:t,activeColor:n,topPicks:r})=>{let i;return t===`elementStroke`&&(i=g),t===`elementBackground`&&(i=Li),t===`canvasBackground`&&(i=mo),r&&(i=r),i?(0,V.jsx)(`div`,{className:`color-picker__top-picks`,children:i.map(t=>(0,V.jsx)(`button`,{className:H(`color-picker__button`,{active:t===n,"is-transparent":t===`transparent`||!t,"has-outline":!Js(t,240)}),style:{"--swatch-color":t},type:`button`,title:t,onClick:()=>e(t),"data-testid":`color-top-pick-${t}`,children:(0,V.jsx)(`div`,{className:`color-picker__button-outline`})},t))}):(console.error(`Invalid type for TopPicks`),null)},iw=({type:e,color:t,onChange:n,label:r,elements:i,palette:a=Ye,updateData:o,getOpenPopup:s,appState:c,excludedColors:l})=>{let{container:u}=cV(),d=sV(),f=d!==`full`,p=d===`mobile`,[,m]=wy(KC),[h,g]=wy(MC),_=(0,V.jsxs)(`div`,{children:[(0,V.jsx)(ZC,{children:W(`colorPicker.hexCode`)}),(0,V.jsx)(qC,{color:t||``,label:r,onChange:e=>{n(e)},colorPickerType:e,placeholder:W(`colorPicker.color`)})]}),v=(0,B.useRef)(null),y=()=>{v.current?.focus()};return(0,V.jsx)(FC,{container:u,style:{maxWidth:`13rem`},preventAutoFocusOnTouch:!!c.editingTextElement,onFocusOutside:e=>{de(e.target)||y(),e.preventDefault()},onPointerDownOutside:e=>{h&&e.preventDefault()},onClose:()=>{s()===e&&o({openPopup:null}),m(null),c.editingTextElement&&setTimeout(()=>{let e=document.querySelector(`.excalidraw-wysiwyg`);e&&e.focus()},0)},children:a?(0,V.jsx)(nw,{ref:v,palette:a,excludedColors:l,color:t,onChange:e=>{let t=c.editingTextElement?LC():null;n(e),c.editingTextElement&&t&&RC(t)},onEyeDropperToggle:t=>{g(r=>t?(r||={keepOpenOnAlt:!0,onSelect:n,colorPickerType:e},r.keepOpenOnAlt=!0,r):t===!1||r?null:{keepOpenOnAlt:!1,onSelect:n,colorPickerType:e})},onEscape:e=>{h?g(null):o({openPopup:null})},type:e,elements:i,updateData:o,showTitle:f,showHotKey:!p,children:_}):_})},aw=({label:e,color:t,type:n,mode:r=`background`,onToggle:i,editingTextElement:a})=>{let o=sV(),s=o!==`full`,c=o===`mobile`;return(0,V.jsxs)(lv,{type:`button`,className:H(`color-picker__button active-color properties-trigger`,{"is-transparent":!t||t===`transparent`,"has-outline":!t||!Js(t,240),"compact-sizing":s,"mobile-border":c}),"aria-label":e,style:t?{"--swatch-color":t}:void 0,title:W(n===`elementStroke`?`labels.showStroke`:`labels.showBackground`),"data-openpopup":n,onClick:e=>{e.preventDefault(),e.stopPropagation(),a&&VC(),i()},children:[(0,V.jsx)(`div`,{className:`color-picker__button-outline`,children:!t&&zb}),s&&t&&r===`stroke`&&(0,V.jsx)(`div`,{className:`color-picker__button-background`,children:(0,V.jsx)(`span`,{style:{color:t&&Js(t,240)?`#fff`:`#111`},children:nC})})]})},ow=({type:e,color:t,onChange:n,label:r,elements:i,palette:a=Ye,topPicks:o,updateData:s,appState:c,excludedColors:l})=>{let u=(0,B.useRef)(c.openPopup);(0,B.useEffect)(()=>{u.current=c.openPopup},[c.openPopup]);let d=sV()!==`full`;return(0,V.jsx)(`div`,{children:(0,V.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,className:H(`color-picker-container`,{"color-picker-container--no-top-picks":d}),children:[!d&&(0,V.jsx)(rw,{activeColor:t,onChange:n,type:e,topPicks:o}),!d&&(0,V.jsx)(wC,{}),(0,V.jsxs)(cv,{open:c.openPopup===e,onOpenChange:t=>{t&&s({openPopup:e})},children:[(0,V.jsx)(aw,{color:t,label:r,type:e,mode:e===`elementStroke`?`stroke`:`background`,editingTextElement:!!c.editingTextElement,onToggle:()=>{c.openPopup===e?s({openPopup:null}):(c.openPopup,s({openPopup:e}))}}),c.openPopup===e&&(0,V.jsx)(iw,{type:e,color:t,onChange:n,label:r,elements:i,palette:a,excludedColors:l,updateData:s,getOpenPopup:()=>u.current,appState:c})]})]})})},sw=B.forwardRef(({className:e,placeholder:t,onChange:n},r)=>(0,V.jsxs)(`div`,{className:H(`QuickSearch__wrapper`,e),children:[DS,(0,V.jsx)(`input`,{ref:r,className:`QuickSearch__input`,type:`text`,placeholder:t,onChange:e=>n(e.target.value.trim().toLowerCase())})]})),cw=({className:e,placeholder:t,children:n})=>{let r=!B.Children.count(n);return(0,V.jsx)(`div`,{className:H(`ScrollableList__wrapper`,e),role:`menu`,children:r?(0,V.jsx)(`div`,{className:`empty`,children:t}):n})},lw=({children:e,className:t=``,style:n,title:r})=>(0,V.jsxs)(`div`,{className:`dropdown-menu-group ${t}`,style:n,children:[r&&(0,V.jsx)(`p`,{className:`dropdown-menu-group-title`,children:r}),e]}),uw=lw;lw.displayName=`DropdownMenuGroup`;var dw=B.createContext({}),fw=(e=``,t=!1,n=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e} ${t?`dropdown-menu-item--selected`:``} ${n?`dropdown-menu-item--hovered`:``}`.trim(),pw=e=>{let t=(0,B.useContext)(dw);return Xo(e,e=>{t.onSelect?.(e)})},mw=({children:e,...t})=>(0,V.jsx)(`span`,{...t,style:{textOverflow:`ellipsis`,overflow:`hidden`,whiteSpace:`nowrap`,...t.style},children:e}),hw=({textStyle:e,icon:t,shortcut:n,children:r,badge:i})=>{let a=oV();return(0,V.jsxs)(V.Fragment,{children:[t&&(0,V.jsx)(`div`,{className:`dropdown-menu-item__icon`,children:t}),(0,V.jsx)(`div`,{style:e,className:`dropdown-menu-item__text`,children:(0,V.jsx)(mw,{children:r})}),i&&(0,V.jsx)(`div`,{className:`dropdown-menu-item__badge`,children:i}),n&&a.formFactor!==`phone`&&(0,V.jsx)(`div`,{className:`dropdown-menu-item__shortcut`,children:n})]})},gw=({icon:e,badge:t,value:n,children:r,shortcut:i,className:a,selected:o,onSelect:s,...c})=>{let l=pw(s);return(0,V.jsx)(M_,{className:`radix-menu-item`,onSelect:l,asChild:!0,children:(0,V.jsx)(`button`,{...c,value:n,className:fw(a,o),title:c.title??c[`aria-label`],children:(0,V.jsx)(hw,{icon:e,shortcut:i,badge:t,children:r})})})};gw.displayName=`DropdownMenuItem`;var _w={GREEN:`green`,RED:`red`,BLUE:`blue`},vw=({type:e=_w.BLUE,children:t})=>{let{theme:n}=uV(),r={display:`inline-flex`,marginLeft:`auto`,padding:`2px 4px`,borderRadius:6,fontSize:9,fontFamily:`Cascadia, monospace`,border:n===A.LIGHT?`1.5px solid white`:`none`};switch(e){case _w.GREEN:Object.assign(r,{backgroundColor:`var(--background-color-badge)`,color:`var(--color-badge)`});break;case _w.RED:Object.assign(r,{backgroundColor:`pink`,color:`darkred`});break;case _w.BLUE:default:Object.assign(r,{background:`var(--color-promo)`,color:`var(--color-surface-lowest)`})}return(0,V.jsx)(`div`,{className:`DropDownMenuItemBadge`,style:r,children:t})};vw.displayName=`DropdownMenuItemBadge`,gw.Badge=vw;var yw=gw,bw=({event:e,inputRef:t,hoveredFont:n,filteredFonts:r,onClose:i,onSelect:a,onHover:o})=>{if(!e[j.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===j.F)return t.current?.focus(),!0;if(e.key===j.ESCAPE)return i(),!0;if(e.key===j.ENTER)return n?.value&&a(n.value),!0;if(e.key===j.ARROW_DOWN)return n?.next?o(n.next.value):r[0]?.value&&o(r[0].value),!0;if(e.key===j.ARROW_UP)return n?.prev?o(n.prev.value):r[r.length-1]?.value&&o(r[r.length-1].value),!0},xw=e=>{switch(e){case Na.Excalifont:case Na.Virgil:return db;case Na.Nunito:case Na.Helvetica:return Yx;case Na[`Lilita One`]:return Jx;case Na[`Comic Shanns`]:case Na.Cascadia:return Zx;default:return Yx}},Sw=(e,t)=>Object.entries(Na).find(([,t])=>t===e)?.[0]??t[0]?.fontFace?.family??`Unknown`,Cw=B.memo(({selectedFontFamily:e,hoveredFontFamily:t,onSelect:n,onHover:r,onLeave:i,onOpen:a,onClose:o})=>{let{container:s}=cV(),c=iV(),{fonts:l}=c,{showDeprecatedFonts:u}=aV(),d=sV(),[f,p]=(0,B.useState)(``),m=(0,B.useRef)(null),h=(0,B.useMemo)(()=>Array.from(Ar.registered.entries()).filter(([e,{metadata:t}])=>!t.private&&!t.fallback).map(([e,{metadata:t,fontFaces:n}])=>{let r={value:e,icon:xw(e),text:Sw(e,n)};return t.deprecated&&Object.assign(r,{deprecated:t.deprecated,badge:{type:_w.RED,placeholder:W(`fontList.badge.old`)}}),r}).sort((e,t)=>e.text.toLowerCase()>t.text.toLowerCase()?1:-1),[]),g=(0,B.useMemo)(()=>new Set(l.getSceneFamilies()),[e]),_=(0,B.useMemo)(()=>h.filter(e=>g.has(e.value)),[h,g]),y=(0,B.useMemo)(()=>h.filter(e=>!g.has(e.value)&&(u||!e.deprecated)),[h,g,u]),b=(0,B.useMemo)(()=>v([..._,...y].filter(e=>e.text?.toLowerCase().includes(f))),[_,y,f]),x=(0,B.useMemo)(()=>{let n;return t?n=b.find(e=>e.value===t):e&&(n=b.find(t=>t.value===e)),!n&&f&&(b[0]?.value?r(b[0].value):i()),n},[t,e,f,b,r,i]),S=(0,B.useCallback)(e=>{let t=null;if(c.state.editingTextElement){let e=document.querySelector(`.excalidraw-wysiwyg`);e&&(t={start:e.selectionStart,end:e.selectionEnd})}n(e),c.state.editingTextElement&&t&&setTimeout(()=>{let e=document.querySelector(`.excalidraw-wysiwyg`);e&&t&&(e.focus(),e.selectionStart=t.start,e.selectionEnd=t.end)},0)},[n,c.state.editingTextElement]),C=(0,B.useCallback)(e=>{bw({event:e,inputRef:m,hoveredFont:x,filteredFonts:b,onSelect:S,onHover:r,onClose:o})&&(e.preventDefault(),e.stopPropagation())},[x,b,S,r,o]);(0,B.useEffect)(()=>(a(),()=>{o()}),[]);let w=(0,B.useMemo)(()=>b.filter(e=>g.has(e.value)),[b,g]),T=(0,B.useMemo)(()=>b.filter(e=>!g.has(e.value)),[b,g]),E=({font:t,order:n})=>{let i=(0,B.useRef)(null),a=t.value===x?.value,o=t.value===e;return(0,B.useEffect)(()=>{a&&(n===0?i.current?.scrollIntoView?.({block:`end`}):i.current?.scrollIntoView?.({block:`nearest`}))},[a,n]),(0,V.jsx)(`button`,{ref:i,type:`button`,value:t.value,className:fw(``,o,a),title:t.text,tabIndex:o?0:-1,onClick:e=>{S(Number(e.currentTarget.value))},onMouseMove:()=>{x?.value!==t.value&&r(t.value)},children:(0,V.jsx)(hw,{icon:t.icon,badge:t.badge&&(0,V.jsx)(vw,{type:t.badge.type,children:t.badge.placeholder}),textStyle:{fontFamily:Ns({fontFamily:t.value})},children:t.text})})},D=[];return w.length&&D.push((0,V.jsx)(uw,{title:W(`fontList.sceneFonts`),children:w.map((e,t)=>(0,V.jsx)(E,{font:e,order:t},e.value))},`group_1`)),T.length&&D.push((0,V.jsx)(uw,{title:W(`fontList.availableFonts`),children:T.map((e,t)=>(0,V.jsx)(E,{font:e,order:t+w.length},e.value))},`group_2`)),(0,V.jsxs)(FC,{className:`properties-content`,container:s,style:{width:`15rem`},onClose:()=>{o(),c.state.editingTextElement&&setTimeout(()=>{let e=document.querySelector(`.excalidraw-wysiwyg`);e&&e.focus()},0)},onPointerLeave:i,onKeyDown:C,preventAutoFocusOnTouch:!!c.state.editingTextElement,children:[d===`full`&&(0,V.jsx)(sw,{ref:m,placeholder:W(`quickSearch.placeholder`),onChange:ke(p,20)}),(0,V.jsx)(cw,{className:`dropdown-menu fonts manual-hover`,placeholder:W(`fontList.empty`),children:D.length?D:null})]})},(e,t)=>e.selectedFontFamily===t.selectedFontFamily&&e.hoveredFontFamily===t.hoveredFontFamily),ww=({selectedFontFamily:e,isOpened:t=!1,compactMode:n=!1})=>{let r=dV(),i=n?{...On,width:`2rem`,height:`2rem`}:{};return(0,V.jsx)(lv,{asChild:!0,children:(0,V.jsx)(`div`,{"data-openpopup":`fontFamily`,className:`properties-trigger`,children:(0,V.jsx)(J,{type:`toggle`,icon:fb,title:W(`labels.showFonts`),"aria-label":W(`labels.showFonts`),className:`standalone properties-trigger`,"data-testid":`font-family-show-fonts`,checked:t,onSelect:()=>{r(e=>({openPopup:e.openPopup===`fontFamily`?null:e.openPopup}))},style:{border:`none`,...i}})})})},Tw=[{value:Na.Excalifont,icon:db,text:W(`labels.handDrawn`),testId:`font-family-hand-drawn`},{value:Na.Nunito,icon:Yx,text:W(`labels.normal`),testId:`font-family-normal`},{value:Na[`Comic Shanns`],icon:Zx,text:W(`labels.code`),testId:`font-family-code`}];new Set(Tw.map(e=>e.value));var Ew=B.memo(({isOpened:e,selectedFontFamily:t,hoveredFontFamily:n,onSelect:r,onHover:i,onLeave:a,onPopupChange:o,compactMode:s=!1})=>{let c=(0,B.useMemo)(()=>Tw,[]),l=(0,B.useCallback)(e=>{e&&r(e)},[r]);return(0,V.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,className:H(`FontPicker__container`,{"FontPicker__container--compact":s}),children:[!s&&(0,V.jsx)(`div`,{className:`buttonList`,children:(0,V.jsx)(CC,{type:`button`,options:c,value:t,onClick:l})}),!s&&(0,V.jsx)(wC,{}),(0,V.jsxs)(cv,{open:e,onOpenChange:o,children:[(0,V.jsx)(ww,{selectedFontFamily:t,isOpened:e,compactMode:s}),e&&(0,V.jsx)(Cw,{selectedFontFamily:t,hoveredFontFamily:n,onSelect:l,onHover:i,onLeave:a,onOpen:()=>o(!0),onClose:()=>o(!1)})]})]})},(e,t)=>e.isOpened===t.isOpened&&e.selectedFontFamily===t.selectedFontFamily&&e.hoveredFontFamily===t.hoveredFontFamily),Dw=({className:e,icon:t,size:n=`1em`})=>(0,V.jsx)(`span`,{className:e,style:{width:n,height:`100%`,margin:`0 0.5ex 0 0.5ex`,display:`inline-flex`,lineHeight:0,verticalAlign:`middle`,flex:`0 0 auto`},children:t}),Ow=({label:e,open:t,openTrigger:n,children:r,className:i,showCollapsedIcon:a=!0})=>(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{style:{cursor:`pointer`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},className:i,onClick:n,children:[e,a&&(0,V.jsx)(Dw,{icon:t?ZS:XS})]}),t&&(0,V.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`},children:r})]}),kw=Gc(!1),Aw=4,jw=`default`,Mw=e=>e.flatMap(e=>e.options),Nw=(e,t)=>{for(let n of e){let e=n.options.find(t);if(e)return e}return null},Pw=(e,t)=>e.some(e=>e.options.some(t)),Fw=e=>e.flatMap(e=>Array.from({length:Math.ceil(e.options.length/Aw)},(t,n)=>e.options.slice(n*Aw,n*Aw+Aw)));function Iw({visibleSections:e,hiddenSections:t=[],value:n,label:r,onChange:i,onClose:a}){let{container:o}=cV(),[s,c]=wy(kw),l=Mw([...e,...t]),u=Fw([...e,...s?t:[]]),d=e=>{let t=l.find(t=>t.keyBinding===e.key.toLowerCase());if(!(e.metaKey||e.altKey||e.ctrlKey)&&t)i(t.value),e.preventDefault();else if(e.key===j.TAB){let t=l.findIndex(e=>e.value===n),r=e.shiftKey?(l.length+t-1)%l.length:(t+1)%l.length;i(l[r].value)}else if(dr(e.key)){let t=Ry().rtl,r=l.findIndex(e=>e.value===n);if(r!==-1){let a=l.length,o=r;switch(e.key){case t?j.ARROW_LEFT:j.ARROW_RIGHT:o=(r+1)%a;break;case t?j.ARROW_RIGHT:j.ARROW_LEFT:o=(a+r-1)%a;break;case j.ARROW_DOWN:{let t=u.findIndex(e=>e.some(e=>e.value===n)),a=u[t];if(t!==-1&&a){let o=a.findIndex(e=>e.value===n),s=u[(t+1)%u.length];i((s[Math.min(o,s.length-1)]??l[r]).value),e.preventDefault(),e.nativeEvent.stopImmediatePropagation(),e.stopPropagation();return}break}case j.ARROW_UP:{let t=u.findIndex(e=>e.some(e=>e.value===n)),a=u[t];if(t!==-1&&a){let o=a.findIndex(e=>e.value===n),s=u[(u.length+t-1)%u.length];i((s[Math.min(o,s.length-1)]??l[r]).value),e.preventDefault(),e.nativeEvent.stopImmediatePropagation(),e.stopPropagation();return}break}}i(l[o].value)}e.preventDefault()}else(e.key===j.ESCAPE||e.key===j.ENTER)&&(e.preventDefault(),a());e.nativeEvent.stopImmediatePropagation(),e.stopPropagation()};(0,B.useEffect)(()=>{Pw(t,e=>e.value===n)&&c(!0)},[n,t,c]);let f=e=>(0,V.jsx)(`div`,{className:`picker-content`,children:e.map(e=>(0,V.jsxs)(`button`,{type:`button`,className:H(`picker-option`,{active:n===e.value}),onClick:()=>{i(e.value)},title:e.keyBinding?`${e.text} \u2014 ${e.keyBinding.toUpperCase()}`:e.text,"aria-label":e.text||`none`,"aria-keyshortcuts":e.keyBinding||void 0,ref:t=>{n===e.value&&setTimeout(()=>{t?.focus()},0)},children:[e.icon,e.keyBinding&&(0,V.jsx)(`span`,{className:`picker-keybinding`,children:e.keyBinding})]},e.text))}),p=e=>e.map((e,t)=>e.name===jw?(0,V.jsx)(B.Fragment,{children:f(e.options)},`${e.name}-${t}`):(0,V.jsxs)(`div`,{className:`picker-section`,children:[(0,V.jsx)(`div`,{className:`picker-section-label`,children:e.name}),f(e.options)]},`${e.name}-${t}`));return(0,V.jsx)(dv,{className:`picker`,role:`dialog`,"aria-modal":`true`,"aria-label":r,side:`bottom`,align:`start`,sideOffset:12,alignOffset:12,style:{zIndex:`var(--zIndex-ui-styles-popup)`},onKeyDown:d,collisionBoundary:o??void 0,children:(0,V.jsxs)(`div`,{className:`picker-sections`,children:[p(e),t.length>0&&(0,V.jsx)(Ow,{label:W(`labels.more_options`),open:s,openTrigger:()=>{c(e=>!e)},className:`picker-collapsible`,children:(0,V.jsx)(`div`,{className:`picker-sections`,children:p(t)})})]})})}function Lw({value:e,label:t,visibleSections:n,hiddenSections:r,onChange:i}){let[a,o]=B.useState(!1),s=(0,B.useMemo)(()=>Nw(n,t=>t.value===e)??Nw(r??[],t=>t.value===e),[n,r,e]);return(0,V.jsx)(`div`,{children:(0,V.jsxs)(cv,{open:a,onOpenChange:e=>o(e),children:[(0,V.jsx)(lv,{type:`button`,"aria-label":t,onClick:()=>o(!a),className:a?`active`:``,children:s?.icon}),a&&(0,V.jsx)(Iw,{visibleSections:n,hiddenSections:r,value:e,label:t,onChange:i,onClose:()=>{o(!1)}})]})})}var Rw=({label:e,value:t,onChange:n,min:r=0,max:i=100,step:a=10,minLabel:o=r,hasCommonValue:s=!0,testId:c})=>{let l=B.useRef(null),u=B.useRef(null);return(0,B.useEffect)(()=>{if(l.current&&u.current){let e=l.current,n=u.current,a=e.offsetWidth,o=parseFloat(getComputedStyle(e).getPropertyValue(`--slider-thumb-size`))||16,s=(t-r)/(i-r||1)*100,c=s/100*(a-o)+o/2;n.style.left=`${c}px`,e.style.background=`linear-gradient(to right, var(--color-slider-track) 0%, var(--color-slider-track) ${s}%, var(--button-bg) ${s}%, var(--button-bg) 100%)`}},[i,r,t]),(0,V.jsxs)(`label`,{className:`control-label`,children:[e,(0,V.jsxs)(`div`,{className:`range-wrapper`,children:[(0,V.jsx)(`input`,{style:{"--color-slider-track":s?void 0:`var(--button-bg)`},ref:l,type:`range`,min:r,max:i,step:a,onChange:e=>{n(+e.target.value)},value:t,className:`range-input`,"data-testid":c}),(0,V.jsx)(`div`,{className:`value-bubble`,ref:u,children:t===r?null:t}),(0,V.jsx)(`div`,{className:`zero-label`,children:o})]})]})},zw=.1,Bw=e=>{let t=sr(e.editorInterface);return{stylesPanelMode:t,isCompact:t!==`full`,isMobile:t===`mobile`}},Vw=(e,t,n,r=!1)=>{let i=ui(xt(e,t,{includeBoundTextElement:r}));return e.map(e=>i.get(e.id)||e.id===t.editingTextElement?.id?(dc(e)||console.error(`[NONDELETED][INVARIANT] changeProperty(): skipping deleted selected/editing element`),n(e)):e)},Hw=function(e,t,n,r,i){let a=t.state.editingTextElement,o=et(e),s=null;if(a&&(s=n(a)),!s){if(Bi(o,t.state)){let e=t.scene.getSelectedElements(t.state),a=r===!0?e:e.filter(e=>r(e));s=Ko(a,n)??(typeof i==`function`?i(!0):i)}else s=typeof i==`function`?i(!1):i}return s},Uw=(e,t,n)=>cs(t)||!t.autoResize?t:n.mutateElement(t,{x:e.textAlign===`left`?e.x:e.x+(e.width-t.width)/(e.textAlign===`center`?2:1),y:e.y+(e.height-t.height)/2}),Ww=(e,t,n,r,i)=>{let o=new Set,s=Vw(e,t,e=>{if(a(e)){let t=r(e);o.add(t);let i=R(e,{fontSize:t});return Sa(i,n.scene.getContainerElement(e),n.scene),i=Uw(e,i,n.scene),i}return e},!0);return xt(e,t,{includeBoundTextElement:!0}).forEach(e=>{a(e)&&La(e,n.scene)}),{elements:s,appState:{...t,currentItemFontSize:o.size===1?[...o][0]:i??t.currentItemFontSize},captureUpdate:F.IMMEDIATELY}};Y({name:`changeStrokeColor`,label:`labels.stroke`,trackEvent:!1,perform:(e,t,n)=>({...n?.currentItemStrokeColor&&{elements:Vw(e,t,e=>$n(e.type)?R(e,{strokeColor:n.currentItemStrokeColor}):e,!0)},appState:{...t,...n},captureUpdate:n?.currentItemStrokeColor?F.IMMEDIATELY:F.EVENTUALLY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r,data:i})=>{let{stylesPanelMode:a}=Bw(r);return(0,V.jsxs)(V.Fragment,{children:[a===`full`&&(0,V.jsx)(`h3`,{"aria-hidden":`true`,children:W(`labels.stroke`)}),(0,V.jsx)(ow,{topPicks:g,palette:Zi,type:`elementStroke`,label:W(`labels.stroke`),color:Hw(e,r,e=>e.strokeColor,!0,e=>e?null:t.currentItemStrokeColor),onChange:e=>n({currentItemStrokeColor:e}),elements:e,appState:t,updateData:n})]})}}),Y({name:`changeBackgroundColor`,label:`labels.changeBackground`,trackEvent:!1,perform:(e,t,n,r)=>{if(!n?.currentItemBackgroundColor)return{appState:{...t,...n},captureUpdate:F.EVENTUALLY};let i,a=r.scene.getSelectedElements(t);if(!ei(n.currentItemBackgroundColor)&&a.every(e=>Oe(e)&&ic(e.points))){let t=ui(a);i=e.map(e=>t.has(e.id)&&Oe(e)?R(e,{backgroundColor:n.currentItemBackgroundColor,...kr(e,!0)}):e)}else i=Vw(e,t,e=>R(e,{backgroundColor:n.currentItemBackgroundColor}));return{elements:i,appState:{...t,...n},captureUpdate:F.IMMEDIATELY}},PanelComponent:({elements:e,appState:t,updateData:n,app:r,data:i})=>{let{stylesPanelMode:a}=Bw(r);return(0,V.jsxs)(V.Fragment,{children:[a===`full`&&(0,V.jsx)(`h3`,{"aria-hidden":`true`,children:W(`labels.background`)}),(0,V.jsx)(ow,{topPicks:Li,palette:ao,type:`elementBackground`,label:W(`labels.background`),color:Hw(e,r,e=>e.backgroundColor,!0,e=>e?null:t.currentItemBackgroundColor),onChange:e=>n({currentItemBackgroundColor:e}),elements:e,appState:t,updateData:n})]})}});var Gw=Y({name:`changeBucketFillBackgroundColor`,label:`labels.changeBackground`,trackEvent:!1,perform:(e,t,n)=>({appState:{...t,...n},captureUpdate:F.EVENTUALLY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>{let{stylesPanelMode:i}=Bw(r);return(0,V.jsxs)(V.Fragment,{children:[i===`full`&&(0,V.jsx)(`h3`,{"aria-hidden":`true`,children:W(`labels.background`)}),(0,V.jsx)(ow,{topPicks:yn,palette:ao,excludedColors:[Ye.transparent],type:`elementBackground`,label:W(`labels.background`),color:Re(t.currentItemBackgroundColor),onChange:e=>n({currentItemBackgroundColor:e}),elements:e,appState:t,updateData:n})]})}});Y({name:`changeFillStyle`,label:`labels.fill`,trackEvent:!1,perform:(e,t,n,r)=>(xC(`element`,`changeFillStyle`,`${n} (${r.editorInterface.formFactor===`phone`?`mobile`:`desktop`})`),{elements:Vw(e,t,e=>R(e,{fillStyle:n})),appState:{...t,currentItemFillStyle:n},captureUpdate:F.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>{let i=xt(e,t),a=i.length>0&&i.every(e=>e.fillStyle===`zigzag`);return(0,V.jsxs)(`fieldset`,{children:[(0,V.jsx)(`legend`,{children:W(`labels.fill`)}),(0,V.jsx)(`div`,{className:`buttonList`,children:(0,V.jsx)(CC,{type:`button`,options:[{value:`hachure`,text:`${W(a?`labels.zigzag`:`labels.hachure`)} (${X(`Alt-Click`)})`,icon:a?fx:px,active:a?!0:void 0,testId:`fill-hachure`},{value:`cross-hatch`,text:W(`labels.crossHatch`),icon:mx,testId:`fill-cross-hatch`},{value:`solid`,text:W(`labels.solid`),icon:hx,testId:`fill-solid`}],value:Hw(e,r,e=>e.fillStyle,e=>e.hasOwnProperty(`fillStyle`),e=>e?null:t.currentItemFillStyle),onClick:(e,t)=>{n(t.altKey&&e===`hachure`&&i.every(e=>e.fillStyle===`hachure`)?`zigzag`:e)}})})]})}});var Kw=e=>Ac.find(t=>We(e.type,t)===e.strokeWidth)??null,qw=(e,t)=>We(e.type,t);Y({name:`changeStrokeWidth`,label:`labels.strokeWidth`,trackEvent:!1,perform:(e,t,n)=>(qa(n,`actionChangeStrokeWidth: value must be defined`),{elements:Vw(e,t,e=>R(e,{strokeWidth:qw(e,n)})),appState:{...t,currentItemStrokeWidthKey:n},captureUpdate:F.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r,data:i})=>(0,V.jsxs)(`fieldset`,{children:[(0,V.jsx)(`legend`,{children:W(`labels.strokeWidth`)}),(0,V.jsx)(`div`,{className:`buttonList`,children:(0,V.jsx)(CC,{group:`stroke-width`,options:[{value:`thin`,text:W(`labels.thin`),icon:gx,testId:`strokeWidth-thin`},{value:`medium`,text:W(`labels.medium`),icon:_x,testId:`strokeWidth-medium`},{value:`bold`,text:W(`labels.bold`),icon:vx,testId:`strokeWidth-bold`}],value:Hw(e,r,Kw,e=>e.hasOwnProperty(`strokeWidth`),e=>e?null:t.currentItemStrokeWidthKey),onChange:e=>n(e)})})]})}),Y({name:`changeSloppiness`,label:`labels.sloppiness`,trackEvent:!1,perform:(e,t,n)=>({elements:Vw(e,t,e=>R(e,{seed:za(),roughness:n})),appState:{...t,currentItemRoughness:n},captureUpdate:F.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r,data:i})=>(0,V.jsxs)(`fieldset`,{children:[(0,V.jsx)(`legend`,{children:W(`labels.sloppiness`)}),(0,V.jsx)(`div`,{className:`buttonList`,children:(0,V.jsx)(CC,{group:`sloppiness`,options:[{value:0,text:W(`labels.architect`),icon:xx},{value:1,text:W(`labels.artist`),icon:Sx},{value:2,text:W(`labels.cartoonist`),icon:Cx}],value:Hw(e,r,e=>e.roughness,e=>e.hasOwnProperty(`roughness`),e=>e?null:t.currentItemRoughness),onChange:e=>n(e)})})]})}),Y({name:`changeFreedrawMode`,label:`labels.pressure`,trackEvent:!1,perform:(e,t,n)=>{let r=n||`constant`;return{elements:Vw(e,t,e=>e.type===`freedraw`?R(e,{strokeOptions:{...e.strokeOptions,variability:r}}):e),appState:{...t,currentItemStrokeVariability:r},captureUpdate:F.IMMEDIATELY}},PanelComponent:({elements:e,appState:t,updateData:n,app:r,data:i})=>{let a=Hw(e,r,e=>e.strokeOptions?.variability,e=>e.type===`freedraw`,e=>e?null:t.currentItemStrokeVariability)??t.currentItemStrokeVariability;if(i?.cycle){let e=a===`variable`;return(0,V.jsx)(J,{type:`button`,icon:e?Tx:wx,title:W(`labels.pressure`),"aria-label":W(`labels.pressure`),onClick:()=>n(e?`constant`:`variable`)})}return(0,V.jsxs)(`fieldset`,{children:[(0,V.jsx)(`legend`,{children:W(`labels.pressure`)}),(0,V.jsx)(`div`,{className:`buttonList`,children:(0,V.jsx)(CC,{group:`strokeOptions.variability`,options:[{value:`constant`,text:W(`labels.pressure_constant`),icon:wx},{value:`variable`,text:W(`labels.pressure_variable`),icon:Tx}],value:a,onChange:e=>n(e)})})]})}}),Y({name:`changeStrokeStyle`,label:`labels.strokeStyle`,trackEvent:!1,perform:(e,t,n)=>({elements:Vw(e,t,e=>R(e,{strokeStyle:n})),appState:{...t,currentItemStrokeStyle:n},captureUpdate:F.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r,data:i})=>(0,V.jsxs)(`fieldset`,{children:[(0,V.jsx)(`legend`,{children:W(`labels.strokeStyle`)}),(0,V.jsx)(`div`,{className:`buttonList`,children:(0,V.jsx)(CC,{group:`strokeStyle`,options:[{value:`solid`,text:W(`labels.strokeStyle_solid`),icon:gx},{value:`dashed`,text:W(`labels.strokeStyle_dashed`),icon:yx},{value:`dotted`,text:W(`labels.strokeStyle_dotted`),icon:bx}],value:Hw(e,r,e=>e.strokeStyle,e=>e.hasOwnProperty(`strokeStyle`),e=>e?null:t.currentItemStrokeStyle),onChange:e=>n(e)})})]})}),Y({name:`changeOpacity`,label:`labels.opacity`,trackEvent:!1,perform:(e,t,n)=>({elements:Vw(e,t,e=>R(e,{opacity:n}),!0),appState:{...t,currentItemOpacity:n},captureUpdate:F.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,app:n,updateData:r})=>{let i=Hw(e,n,e=>e.opacity,!0,e=>e?null:t.currentItemOpacity);return(0,V.jsx)(Rw,{label:W(`labels.opacity`),value:i??t.currentItemOpacity,hasCommonValue:i!==null,onChange:r,min:0,max:100,step:10,testId:`opacity`})}}),Y({name:`changeFontSize`,label:`labels.fontSize`,trackEvent:!1,perform:(e,t,n,r)=>Ww(e,t,r,()=>(qa(n,`actionChangeFontSize: Expected a font size value`),n),n),PanelComponent:({elements:e,appState:t,updateData:n,app:r,data:i})=>{let{isCompact:o}=Bw(r);return(0,V.jsxs)(`fieldset`,{children:[(0,V.jsx)(`legend`,{children:W(`labels.fontSize`)}),(0,V.jsx)(`div`,{className:`buttonList`,children:(0,V.jsx)(CC,{group:`font-size`,options:[{value:Qn.sm,text:W(`labels.small`),icon:Ux,testId:`fontSize-small`},{value:Qn.md,text:W(`labels.medium`),icon:Wx,testId:`fontSize-medium`},{value:Qn.lg,text:W(`labels.large`),icon:Gx,testId:`fontSize-large`},{value:Qn.xl,text:W(`labels.veryLarge`),icon:Kx,testId:`fontSize-veryLarge`}],value:Hw(e,r,e=>{if(a(e))return e.fontSize;let t=Ti(e,r.scene.getNonDeletedElementsMap());return t?t.fontSize:null},e=>a(e)||Ti(e,r.scene.getNonDeletedElementsMap())!==null,e=>e?null:t.currentItemFontSize||20),onChange:e=>{zC(()=>n(e),o,!!t.editingTextElement,i?.onPreventClose)}})})]})}});var Jw=Y({name:`decreaseFontSize`,label:`labels.decreaseFontSize`,icon:qx,trackEvent:!1,perform:(e,t,n,r)=>Ww(e,t,r,e=>Math.round(1/(1+zw)*e.fontSize)),keyTest:e=>e[j.CTRL_OR_CMD]&&e.shiftKey&&(e.key===j.CHEVRON_LEFT||e.key===j.COMMA)}),Yw=Y({name:`increaseFontSize`,label:`labels.increaseFontSize`,icon:qx,trackEvent:!1,perform:(e,t,n,r)=>Ww(e,t,r,e=>Math.round(e.fontSize*(1+zw))),keyTest:e=>e[j.CTRL_OR_CMD]&&e.shiftKey&&(e.key===j.CHEVRON_RIGHT||e.key===j.PERIOD)});Y({name:`changeFontFamily`,label:`labels.fontFamily`,trackEvent:!1,perform:(e,t,n,r)=>{let{cachedElements:i,resetAll:o,resetContainers:s,...c}=n;if(o)return{elements:Vw(e,t,e=>{let t=i?.get(e.id);return t?R(e,{...t}):e},!0),appState:{...t,...c},captureUpdate:F.NEVER};qa(n,`actionChangeFontFamily: value must be defined`);let{currentItemFontFamily:l,currentHoveredFontFamily:u}=n,d=F.EVENTUALLY,f,p=!1;if(l)f=l,d=F.IMMEDIATELY;else if(u){f=u,d=F.EVENTUALLY;let n=xt(e,t,{includeBoundTextElement:!0}).filter(e=>a(e));if(n.length>200)p=!0;else{let e=0,t=0;for(;e<n.length&&t<5e3;){let r=n[e];t+=r?.originalText.length||0,e++}t>5e3&&(p=!0)}}let m={appState:{...t,...c},captureUpdate:d};if(f&&!p){let n=new Map,o=new Set,c=!1,d=Array.from(Ar.loadedFontsCache.values()),p=Object.entries(Na).find(([e,t])=>t===f)?.[0];u&&p&&d.some(e=>e.startsWith(p))&&(c=!0),Object.assign(m,{elements:Vw(e,t,e=>{if(a(e)&&(e.fontFamily!==f||l)){let t=R(e,{fontFamily:f,lineHeight:zs(f)}),a=i?.get(e.containerId||``)||{},l=r.scene.getContainerElement(e);return s&&l&&a&&r.scene.mutateElement(l,{...a}),c||(o=new Set([...o,...Array.from(t.originalText)])),n.set(t,l),t}return e},!0)});let h=`10px ${Ns({fontFamily:f})}`,g=Array.from(o.values()).join();if(c||window.document.fonts.check(h,g))for(let[e,t]of n)Sa(e,t,r.scene);else window.document.fonts.load(h,g).then(e=>{for(let[e,t]of n){let n=r.scene.getElement(e.id),i=t?r.scene.getElement(t.id):null;n&&Sa(n,i,r.scene)}r.fonts.onLoaded(e)})}return m},PanelComponent:({elements:e,appState:t,app:n,updateData:r})=>{let i=(0,B.useRef)(new Map),o=(0,B.useRef)(null),[s,c]=(0,B.useState)({}),l=(0,B.useRef)(!0),{stylesPanelMode:u,isCompact:d}=Bw(n),f=(0,B.useMemo)(()=>{let r=(e,r)=>Hw(e,n,e=>{if(a(e))return e.fontFamily;let t=Ti(e,r);return t?t.fontFamily:null},e=>a(e)||Ti(e,r)!==null,e=>e?null:t.currentItemFontFamily||yc);return s.openPopup===`fontFamily`&&t.openPopup===`fontFamily`?r(Array.from(i.current?.values()??[]),i.current):!s.openPopup&&t.openPopup!==`fontFamily`?r(e,n.scene.getNonDeletedElementsMap()):o.current},[s.openPopup,t,e,n]);return(0,B.useEffect)(()=>{o.current=f},[f]),(0,B.useEffect)(()=>{Object.keys(s).length&&(r(s),c({}))},[s]),(0,B.useEffect)(()=>(l.current=!1,()=>{l.current=!0}),[]),(0,V.jsxs)(V.Fragment,{children:[u===`full`&&(0,V.jsx)(`legend`,{children:W(`labels.fontFamily`)}),(0,V.jsx)(Ew,{isOpened:t.openPopup===`fontFamily`,selectedFontFamily:f,hoveredFontFamily:t.currentHoveredFontFamily,compactMode:u!==`full`,onSelect:e=>{zC(()=>{c({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:e}),i.current.clear()},d,!!t.editingTextElement)},onHover:e=>{c({currentHoveredFontFamily:e,cachedElements:new Map(i.current),resetContainers:!0})},onLeave:()=>{c({currentHoveredFontFamily:null,cachedElements:new Map(i.current),resetAll:!0})},onPopupChange:r=>{if(r){i.current.clear();let{editingTextElement:r}=t;if(r?.type===`text`){let e=n.scene.getElement(r.id);i.current.set(r.id,R(e||r,{},!0))}else{let n=xt(e,t,{includeBoundTextElement:!0});for(let e of n)i.current.set(e.id,R(e,{},!0))}c({...s,openPopup:`fontFamily`})}else{let e={currentHoveredFontFamily:null,cachedElements:new Map(i.current),resetAll:!0};c({...e}),i.current.clear(),d&&t.editingTextElement&&RC(null)}}})]})}}),Y({name:`changeTextAlign`,label:`Change text alignment`,trackEvent:!1,perform:(e,t,n,r)=>({elements:Vw(e,t,e=>{if(a(e)){let t=R(e,{textAlign:n});return Sa(t,r.scene.getContainerElement(e),r.scene),t}return e},!0),appState:{...t,currentItemTextAlign:n},captureUpdate:F.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r,data:i})=>{let o=r.scene.getNonDeletedElementsMap(),{isCompact:s}=Bw(r);return(0,V.jsxs)(`fieldset`,{children:[(0,V.jsx)(`legend`,{children:W(`labels.textAlign`)}),(0,V.jsx)(`div`,{className:`buttonList`,children:(0,V.jsx)(CC,{group:`text-align`,options:[{value:`left`,text:W(`labels.left`),icon:Qx,testId:`align-left`},{value:`center`,text:W(`labels.center`),icon:$x,testId:`align-horizontal-center`},{value:`right`,text:W(`labels.right`),icon:eS,testId:`align-right`}],value:Hw(e,r,e=>{if(a(e))return e.textAlign;let t=Ti(e,o);return t?t.textAlign:null},e=>a(e)||Ti(e,o)!==null,e=>e?null:t.currentItemTextAlign),onChange:e=>{zC(()=>n(e),s,!!t.editingTextElement,i?.onPreventClose)}})})]})}}),Y({name:`changeVerticalAlign`,label:`Change vertical alignment`,trackEvent:{category:`element`},perform:(e,t,n,r)=>({elements:Vw(e,t,e=>{if(a(e)){let t=R(e,{verticalAlign:n});return Sa(t,r.scene.getContainerElement(e),r.scene),t}return e},!0),appState:{...t},captureUpdate:F.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r,data:i})=>{let{isCompact:o}=Bw(r);return(0,V.jsx)(`fieldset`,{children:(0,V.jsx)(`div`,{className:`buttonList`,children:(0,V.jsx)(CC,{group:`text-align`,options:[{value:Pn.TOP,text:W(`labels.alignTop`),icon:(0,V.jsx)(tS,{theme:t.theme}),testId:`align-top`},{value:Pn.MIDDLE,text:W(`labels.centerVertically`),icon:(0,V.jsx)(rS,{theme:t.theme}),testId:`align-middle`},{value:Pn.BOTTOM,text:W(`labels.alignBottom`),icon:(0,V.jsx)(nS,{theme:t.theme}),testId:`align-bottom`}],value:Hw(e,r,e=>{if(a(e)&&e.containerId)return e.verticalAlign;let t=Ti(e,r.scene.getNonDeletedElementsMap());return t?t.verticalAlign:null},e=>a(e)||Ti(e,r.scene.getNonDeletedElementsMap())!==null,e=>e?null:Pn.MIDDLE),onChange:e=>{zC(()=>n(e),o,!!t.editingTextElement,i?.onPreventClose)}})})})}}),Y({name:`changeRoundness`,label:`Change edge roundness`,trackEvent:!1,perform:(e,t,n)=>({elements:Vw(e,t,e=>ve(e)?e:R(e,{roundness:n===`round`?{type:tt(e.type)?Jr.ADAPTIVE_RADIUS:Jr.PROPORTIONAL_RADIUS}:null})),appState:{...t,currentItemRoundness:n},captureUpdate:F.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r,renderAction:i})=>{let a=$r(et(e),t).some(e=>e.roundness?.type===Jr.LEGACY);return(0,V.jsxs)(`fieldset`,{children:[(0,V.jsx)(`legend`,{children:W(`labels.edges`)}),(0,V.jsxs)(`div`,{className:`buttonList`,children:[(0,V.jsx)(CC,{group:`edges`,options:[{value:`sharp`,text:W(`labels.sharp`),icon:Ex},{value:`round`,text:W(`labels.round`),icon:Dx}],value:Hw(e,r,e=>a?null:e.roundness?`round`:`sharp`,e=>!_(e)&&e.hasOwnProperty(`roundness`),e=>e?null:t.currentItemRoundness),onChange:e=>n(e)}),i(`togglePolygon`)]})]})}});var Xw=e=>({visibleSections:[{name:`default`,options:[{value:null,text:W(`labels.arrowhead_none`),keyBinding:`q`,icon:(0,V.jsx)(Ox,{flip:e})},{value:`arrow`,text:W(`labels.arrowhead_arrow`),keyBinding:`w`,icon:(0,V.jsx)(kx,{flip:e})},{value:`triangle`,text:W(`labels.arrowhead_triangle`),icon:(0,V.jsx)(Ax,{flip:e}),keyBinding:`e`},{value:`triangle_outline`,text:W(`labels.arrowhead_triangle_outline`),icon:(0,V.jsx)(jx,{flip:e}),keyBinding:`r`}]}],hiddenSections:[{name:`default`,options:[{value:`circle`,text:W(`labels.arrowhead_circle`),keyBinding:`a`,icon:(0,V.jsx)(Mx,{flip:e})},{value:`circle_outline`,text:W(`labels.arrowhead_circle_outline`),keyBinding:`s`,icon:(0,V.jsx)(Nx,{flip:e})},{value:`diamond`,text:W(`labels.arrowhead_diamond`),icon:(0,V.jsx)(Px,{flip:e}),keyBinding:`d`},{value:`diamond_outline`,text:W(`labels.arrowhead_diamond_outline`),icon:(0,V.jsx)(Fx,{flip:e}),keyBinding:`f`},{value:`bar`,text:W(`labels.arrowhead_bar`),keyBinding:`z`,icon:(0,V.jsx)(Ix,{flip:e})}]},{name:W(`labels.cardinality`),options:[{value:`cardinality_one`,text:W(`labels.arrowhead_cardinality_one`),icon:(0,V.jsx)(Lx,{flip:e}),keyBinding:`x`},{value:`cardinality_many`,text:W(`labels.arrowhead_cardinality_many`),icon:(0,V.jsx)(Rx,{flip:e}),keyBinding:`c`},{value:`cardinality_one_or_many`,text:W(`labels.arrowhead_cardinality_one_or_many`),icon:(0,V.jsx)(zx,{flip:e}),keyBinding:`v`},{value:`cardinality_exactly_one`,text:W(`labels.arrowhead_cardinality_exactly_one`),icon:(0,V.jsx)(Bx,{flip:e}),keyBinding:null},{value:`cardinality_zero_or_one`,text:W(`labels.arrowhead_cardinality_zero_or_one`),icon:(0,V.jsx)(Vx,{flip:e}),keyBinding:null},{value:`cardinality_zero_or_many`,text:W(`labels.arrowhead_cardinality_zero_or_many`),icon:(0,V.jsx)(Hx,{flip:e}),keyBinding:null}]}]});Y({name:`changeArrowhead`,label:`Change arrowheads`,trackEvent:!1,perform:(e,t,n)=>(qa(n,`actionChangeArrowhead: value must be defined`),{elements:Vw(e,t,e=>{if(po(e)){let{position:t,type:r}=n;if(t===`start`)return R(e,{startArrowhead:r});if(t===`end`)return R(e,{endArrowhead:r})}return e}),appState:{...t,[n.position===`start`?`currentItemStartArrowhead`:`currentItemEndArrowhead`]:n.type},captureUpdate:F.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>{let i=Ry().rtl,a=(0,B.useMemo)(()=>Xw(!i),[i]),o=(0,B.useMemo)(()=>Xw(!!i),[i]);return(0,V.jsxs)(`fieldset`,{children:[(0,V.jsx)(`legend`,{children:W(`labels.arrowheads`)}),(0,V.jsxs)(`div`,{className:`iconSelectList buttonList`,children:[(0,V.jsx)(Lw,{visibleSections:a.visibleSections,hiddenSections:a.hiddenSections,label:`arrowhead_start`,value:Hw(e,r,e=>po(e)&&c(e.type)?is(e.startArrowhead):t.currentItemStartArrowhead,!0,e=>e?null:t.currentItemStartArrowhead),onChange:e=>n({position:`start`,type:e})}),(0,V.jsx)(Lw,{visibleSections:o.visibleSections,hiddenSections:o.hiddenSections,label:`arrowhead_end`,value:Hw(e,r,e=>po(e)&&c(e.type)?is(e.endArrowhead):t.currentItemEndArrowhead,!0,e=>e?null:t.currentItemEndArrowhead),onChange:e=>n({position:`end`,type:e})})]})]})}}),Y({name:`changeArrowProperties`,label:`Change arrow properties`,trackEvent:!1,perform:(e,t,n,r)=>!1,PanelComponent:({elements:e,appState:t,updateData:n,app:r,renderAction:i})=>(0,V.jsxs)(`div`,{className:`selected-shape-actions`,children:[i(`changeArrowhead`),i(`changeArrowType`)]})}),Y({name:`changeArrowType`,label:`Change arrow types`,trackEvent:!1,perform:(e,t,n,r)=>{let i=Vw(e,t,e=>{if(!_(e))return e;let i=r.scene.getNonDeletedElementsMap(),a=N.getPointAtIndexGlobalCoordinates(e,0,i),o=N.getPointAtIndexGlobalCoordinates(e,-1,i),s=R(e,{x:n===Cr.elbow?a[0]:e.x,y:n===Cr.elbow?a[1]:e.y,roundness:n===Cr.round?{type:Jr.PROPORTIONAL_RADIUS}:null,elbowed:n===Cr.elbow,angle:n===Cr.elbow?0:e.angle,points:n===Cr.elbow||e.elbowed?[N.pointFromAbsoluteCoords({...e,x:a[0],y:a[1],angle:0},a,i),N.pointFromAbsoluteCoords({...e,x:a[0],y:a[1],angle:0},o,i)]:e.points});if(ve(s)){s.fixedSegments=null;let e=r.scene.getNonDeletedElementsMap();r.dismissLinearEditor();let n=N.getPointAtIndexGlobalCoordinates(s,0,e),i=N.getPointAtIndexGlobalCoordinates(s,-1,e),a=s.startBinding&&e.get(s.startBinding.elementId),o=s.endBinding&&e.get(s.endBinding.elementId),c=a&&s.startBinding?{...s.startBinding,...tn(s,a,`start`,e,t.isBindingEnabled)}:null,l=o&&s.endBinding?{...s.endBinding,...tn(s,o,`end`,e,t.isBindingEnabled)}:null;s={...s,startBinding:c,endBinding:l,...Zn(s,e,{points:[n,i].map(e=>L(e[0]-s.x,e[1]-s.y)),startBinding:c,endBinding:l,fixedSegments:null})}}else{let e=r.scene.getNonDeletedElementsMap();if(s.startBinding){let n=e.get(s.startBinding.elementId);n&&nc(s,n,t.bindMode===`inside`?`inside`:`orbit`,`start`,r.scene)}if(s.endBinding){let n=e.get(s.endBinding.elementId);n&&nc(s,n,t.bindMode===`inside`?`inside`:`orbit`,`end`,r.scene)}}return s}),a={...t,currentItemArrowType:n},o=t.selectedLinearElement?.elementId;if(o){let t=i.find(e=>e.id===o);t&&(a.selectedLinearElement=new N(t,ui(e)))}return{elements:i,appState:a,captureUpdate:F.IMMEDIATELY}},PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,V.jsxs)(`fieldset`,{children:[(0,V.jsx)(`legend`,{children:W(`labels.arrowtypes`)}),(0,V.jsx)(`div`,{className:`buttonList`,children:(0,V.jsx)(CC,{group:`arrowtypes`,options:[{value:Cr.sharp,text:W(`labels.arrowtype_sharp`),icon:qS,testId:`sharp-arrow`},{value:Cr.round,text:W(`labels.arrowtype_round`),icon:YS,testId:`round-arrow`},{value:Cr.elbow,text:W(`labels.arrowtype_elbowed`),icon:JS,testId:`elbow-arrow`}],value:Hw(e,r,e=>_(e)?e.elbowed?Cr.elbow:e.roundness?Cr.round:Cr.sharp:null,e=>_(e),e=>e?null:t.currentItemArrowType),onChange:e=>n(e)})})]})});var Zw=()=>{let e=document.querySelector(`.excalidraw-tooltip`);if(e)return e;let t=document.createElement(`div`);return document.body.appendChild(t),t.classList.add(`excalidraw-tooltip`),t},Qw=(e,t,n=`bottom`)=>{let r=e.getBoundingClientRect(),i=window.innerWidth,a=window.innerHeight,o=t.left+t.width/2-r.width/2;o<0?o=5:o+r.width>=i&&(o=i-r.width-5);let s;n===`bottom`?(s=t.top+t.height+5,s+r.height>=a&&(s=t.top-r.height-5)):(s=t.top-r.height-5,s<0&&(s=t.top+t.height+5)),Object.assign(e.style,{top:`${s}px`,left:`${o}px`})},$w=(e,t,n,r)=>{t.classList.add(`excalidraw-tooltip--visible`),t.style.minWidth=r?`50ch`:`10ch`,t.style.maxWidth=r?`50ch`:`15ch`,t.textContent=n,Qw(t,e.getBoundingClientRect())},eT=({children:e,label:t,long:n=!1,style:r,disabled:i})=>((0,B.useEffect)(()=>()=>Zw().classList.remove(`excalidraw-tooltip--visible`),[]),i?null:(0,V.jsx)(`div`,{className:`excalidraw-tooltip-wrapper`,onPointerEnter:e=>$w(e.currentTarget,Zw(),t,n),onPointerLeave:()=>Zw().classList.remove(`excalidraw-tooltip--visible`),style:r,children:e})),tT=(e,t)=>typeof t==`function`?t(e):Array.isArray(t)?e:e[t],nT=(e,t,n)=>{if(e?.isDestroyed)return;let r=e?.getAppState();if(!r){if(!n)return;console.warn(`useAppStateValue: excalidrawAPI not defined yet for internal component while it should always be defined. Are you sure you're rendering inside of <Excalidraw/> component tree?`),r=Object.assign({width:0,height:0,offsetLeft:0,offsetTop:0},ht())}return tT(r,t)};function rT(e,t=!0){let n=pV(),[,r]=(0,B.useState)(0),i=(0,B.useRef)(null);return i.current||={selector:e,isInitialized:!!n,latestValue:nT(n,e,t)},i.current.selector=e,!i.current.isInitialized&&n&&!n.isDestroyed&&(i.current.isInitialized=!0,i.current.latestValue=nT(n,e,t)),(0,B.useEffect)(()=>{let e=i.current;if(!(!n||n.isDestroyed||!e))return n.onStateChange(e.selector,t=>{e.latestValue=t,r(e=>e+1)})},[n]),i.current.latestValue}function iT(e,t){let n=pV(),r=(0,B.useRef)({selector:e,callback:t});r.current.selector=e,r.current.callback=t,(0,B.useEffect)(()=>{if(!(!n||n.isDestroyed))return r.current.callback(nT(n,r.current.selector,!0),n.getAppState()),n.onStateChange(r.current.selector,(e,t)=>{r.current.callback(e,t)})},[n])}Y({name:`changeViewBackgroundColor`,label:`labels.canvasBackground`,trackEvent:!1,predicate:(e,t,n,r)=>!!r.props.UIOptions.canvasActions.changeViewBackgroundColor&&!t.viewModeEnabled,perform:(e,t,n)=>({appState:{...t,...n},captureUpdate:n?.viewBackgroundColor?F.IMMEDIATELY:F.EVENTUALLY}),PanelComponent:({elements:e,appState:t,updateData:n,appProps:r,data:i})=>(0,V.jsx)(ow,{palette:null,topPicks:mo,label:W(`labels.canvasBackground`),type:`canvasBackground`,color:t.viewBackgroundColor,onChange:e=>n({viewBackgroundColor:e}),"data-testid":`canvas-background-picker`,elements:e,appState:t,updateData:n})});var aT=Y({name:`clearCanvas`,label:`labels.clearCanvas`,icon:yb,trackEvent:{category:`canvas`},predicate:(e,t,n,r)=>!!r.props.UIOptions.canvasActions.clearCanvas&&!t.viewModeEnabled&&t.openDialog?.name!==`elementLinkSelector`,perform:(e,t,n,r)=>(r.imageCache.clear(),{elements:e.map(e=>R(e,{isDeleted:!0})),appState:{...ht(),files:{},theme:t.theme,penMode:t.penMode,penDetected:t.penDetected,exportBackground:t.exportBackground,exportEmbedScene:t.exportEmbedScene,gridSize:t.gridSize,gridStep:t.gridStep,gridModeEnabled:t.gridModeEnabled,stats:t.stats,activeTool:t.activeTool.type===`image`?{...t.activeTool,type:r.state.preferredSelectionTool.type}:t.activeTool},captureUpdate:F.IMMEDIATELY})}),oT=Y({name:`zoomIn`,label:`buttons.zoomIn`,viewMode:!0,navigation:!0,icon:gb,trackEvent:{category:`canvas`},predicate:(e,t,n,r)=>r.isNavigationEnabled(),perform:(e,t,n,r)=>(r.requestUnfollow(),{appState:{...t,...Vs({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:mc(t.zoom.value+Bo)},t)},captureUpdate:F.EVENTUALLY}),PanelComponent:({updateData:e})=>{let t=rT(e=>e.zoom.value);return(0,V.jsx)(J,{type:`button`,className:`zoom-in-button zoom-button`,icon:gb,title:`${W(`buttons.zoomIn`)} \u2014 ${X(`CtrlOrCmd++`)}`,"aria-label":W(`buttons.zoomIn`),disabled:t>=30,onClick:()=>{e(null)}})},keyTest:e=>(e.code===I.EQUAL||e.code===I.NUM_ADD)&&(e[j.CTRL_OR_CMD]||e.shiftKey)}),sT=Y({name:`zoomOut`,label:`buttons.zoomOut`,icon:_b,viewMode:!0,navigation:!0,trackEvent:{category:`canvas`},predicate:(e,t,n,r)=>r.isNavigationEnabled(),perform:(e,t,n,r)=>(r.requestUnfollow(),{appState:{...t,...Vs({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:mc(t.zoom.value-Bo)},t)},captureUpdate:F.EVENTUALLY}),PanelComponent:({updateData:e})=>{let t=rT(e=>e.zoom.value);return(0,V.jsx)(J,{type:`button`,className:`zoom-out-button zoom-button`,icon:_b,title:`${W(`buttons.zoomOut`)} \u2014 ${X(`CtrlOrCmd+-`)}`,"aria-label":W(`buttons.zoomOut`),disabled:t<=zi,onClick:()=>{e(null)}})},keyTest:e=>(e.code===I.MINUS||e.code===I.NUM_SUBTRACT)&&(e[j.CTRL_OR_CMD]||e.shiftKey)}),cT=Y({name:`resetZoom`,label:`buttons.resetZoom`,icon:vb,viewMode:!0,navigation:!0,trackEvent:{category:`canvas`},predicate:(e,t,n,r)=>r.isNavigationEnabled(),perform:(e,t,n,r)=>{r.requestUnfollow();let i=t.scrollConstraints?.lockZoom?t.scrollConstraints.zoom:1;return{appState:{...t,...Vs({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:mc(i)},t)},captureUpdate:F.EVENTUALLY}},PanelComponent:({updateData:e})=>{let t=rT(e=>e.zoom.value);return(0,V.jsx)(eT,{label:W(`buttons.resetZoom`),style:{height:`100%`},children:(0,V.jsxs)(J,{type:`button`,className:`reset-zoom-button zoom-button`,title:W(`buttons.resetZoom`),"aria-label":W(`buttons.resetZoom`),onClick:()=>{e(null)},children:[(t*100).toFixed(0),`%`]})})},keyTest:e=>(e.code===I.ZERO||e.code===I.NUM_ZERO)&&(e[j.CTRL_OR_CMD]||e.shiftKey)}),lT=e=>[e.x,e.y,e.x+e.width,e.y+e.height];Y({name:`zoomToFitSelectionInViewport`,label:`labels.zoomToFitViewport`,icon:RS,viewMode:!0,navigation:!0,trackEvent:{category:`canvas`},predicate:(e,t,n,r)=>r.isNavigationEnabled(),perform:(e,t,n,r)=>{r.requestUnfollow();let i=r.scene.getSelectedElements(t),a=i.length?Is(et(i)):t.scrollConstraints?lT(t.scrollConstraints):Is(et(e)),o=an({bounds:a,appState:t,fit:`scale-down`,canvasOffsets:r.viewport.getOffsets()});return{...o,appState:{...o.appState,...Kr(o.appState)}}},keyTest:e=>e.code===I.TWO&&e.shiftKey&&!e.altKey&&!e[j.CTRL_OR_CMD]}),Y({name:`zoomToFitSelection`,label:`helpDialog.zoomToSelection`,icon:RS,viewMode:!0,navigation:!0,trackEvent:{category:`canvas`},predicate:(e,t,n,r)=>r.isNavigationEnabled(),perform:(e,t,n,r)=>{r.requestUnfollow();let i=r.scene.getSelectedElements(t),a=i.length?Is(et(i)):t.scrollConstraints?lT(t.scrollConstraints):Is(et(e)),o=an({bounds:a,appState:t,fit:`contain`,canvasOffsets:r.viewport.getOffsets()});return{...o,appState:{...o.appState,...Kr(o.appState)}}},keyTest:e=>e.code===I.THREE&&e.shiftKey&&!e.altKey&&!e[j.CTRL_OR_CMD]}),Y({name:`zoomToFit`,label:`helpDialog.zoomToFit`,icon:RS,viewMode:!0,navigation:!0,trackEvent:{category:`canvas`},predicate:(e,t,n,r)=>r.isNavigationEnabled(),perform:(e,t,n,r)=>{r.requestUnfollow();let i=t.scrollConstraints?lT(t.scrollConstraints):Is(et(e)),a=an({bounds:i,appState:t,fit:`scale-down`,canvasOffsets:r.viewport.getOffsets()});return{...a,appState:{...a.appState,...Kr(a.appState)}}},keyTest:e=>e.code===I.ONE&&e.shiftKey&&!e.altKey&&!e[j.CTRL_OR_CMD]});var uT=Y({name:`toggleTheme`,label:(e,t)=>t.theme===A.DARK?`buttons.lightMode`:`buttons.darkMode`,keywords:[`toggle`,`dark`,`light`,`mode`,`theme`],icon:(e,t)=>e.theme===A.LIGHT?Sb:Cb,viewMode:!0,trackEvent:{category:`canvas`},perform:(e,t,n,r)=>{let i=n||(t.theme===A.LIGHT?A.DARK:A.LIGHT);return r.props.onThemeChange?(r.props.onThemeChange(i),!1):{appState:{...t,theme:i},captureUpdate:F.EVENTUALLY}},keyTest:e=>!e[j.CTRL_OR_CMD]&&e.altKey&&e.shiftKey&&e.code===I.D,predicate:(e,t,n,r)=>!!r.props.UIOptions.canvasActions.toggleTheme}),dT=({app:e,options:t,activeTool:n,defaultOption:r,"data-testid":i,onToolChange:a,displayedOption:o})=>{let[s,c]=(0,B.useState)(!1),l=n.type,u=o.type===l,{container:d}=cV();return!t.some(e=>e.type===l)&&s&&c(!1),(0,B.useEffect)(()=>{let t=e.onPointerDownEmitter.on(()=>{c(!1)});return()=>t?.()},[e]),(0,V.jsxs)(cv,{open:s,children:[(0,V.jsx)(lv,{asChild:!0,children:(0,V.jsx)(J,{className:H({fillable:o.fillable}),type:`toggle`,icon:o.icon,checked:u,disabled:t.every(t=>_T(e,t.type)),title:lo(o.title),"aria-label":lo(o.title),"data-testid":i,onSelect:()=>{c(e=>!e),a(r)}})}),(0,V.jsx)(dv,{className:`tool-popover-content`,sideOffset:16,collisionBoundary:d??void 0,children:t.map(({type:t,icon:n,title:r,fillable:i})=>(0,V.jsx)(J,{className:H({fillable:i}),type:`toggle`,icon:n,checked:l===t,disabled:_T(e,t),title:lo(t),"aria-label":lo(t),"data-testid":`toolbar-${t}`,onSelect:()=>{e.state.activeTool.type!==t&&(xC(`toolbar`,t,`ui`),e.setActiveTool({type:t}),a?.(t))}},t))})]})},fT=(e=>e)({hand:{icon:oS,letterKey:j.H,toggle:!0},selection:{icon:rb,letterKey:j.V,numericKey:j[1],fillable:!0},rectangle:{icon:ab,letterKey:j.R,numericKey:j[2],fillable:!0},diamond:{icon:ob,letterKey:j.D,numericKey:j[3],fillable:!0},ellipse:{icon:sb,letterKey:j.O,numericKey:j[4],fillable:!0},arrow:{icon:cb,letterKey:j.A,numericKey:j[5],fillable:!0},line:{icon:lb,letterKey:j.L,numericKey:j[6],fillable:!0},freedraw:{icon:db,letterKey:[j.P,j.X],numericKey:j[7]},text:{icon:fb,letterKey:j.T,numericKey:j[8]},image:{icon:mb,numericKey:j[9]},eraser:{icon:hb,letterKey:j.E,numericKey:j[0],toggle:!0},frame:{icon:mS,letterKey:j.F},autoshape:{icon:yS,letterKey:j.X,shiftKey:!0,fillable:!1},embeddable:{icon:bb},laser:{icon:bS,letterKey:j.K},bucketfill:{icon:Rb,letterKey:j.B},lasso:{icon:ib,fillable:!1}}),pT=Object.keys(fT).filter(e=>fT[e].toggle),mT=e=>{let{letterKey:t,shiftKey:n}=fT[e];if(!t)return t;let r=lo(typeof t==`string`?t:t[0]);return n?X(`Shift+${r}`):r},hT=e=>{let t=mT(e),{numericKey:n}=fT[e];return t&&n!=null?`${t} ${W(`helpDialog.or`)} ${n}`:`${t||n}`},gT=(e,t,n=!1)=>{let r=e.toLowerCase();for(let i of Object.keys(fT)){let{letterKey:a,numericKey:o,shiftKey:s}=fT[i];if(n===!!s&&(o!=null&&e===o||a&&(typeof a==`string`?a===r:a.includes(r))))return i===`selection`?t.state.preferredSelectionTool.type:i}return null},_T=(e,t)=>e.props.activeTool!=null&&e.props.activeTool.type!==t,vT=(e,t)=>{let n=fT[e],r=t?.shortcutType??e,i=({app:i,activeTool:a,hideKeyBinding:o,hideShortcut:s})=>{let c=lo(W(`toolBar.${e}`)),l=s?null:hT(r);return(0,V.jsx)(J,{className:H({fillable:n.fillable}),type:`toggle`,icon:n.icon,checked:a.type===e,disabled:_T(i,e),title:l?`${c} \u2014 ${l}`:c,keyBindingLabel:o||s?void 0:fT[r].numericKey||mT(r),"aria-label":c,"aria-keyshortcuts":l??void 0,"data-testid":`toolbar-${e}`,onSelect:({pointerType:n})=>{if(!i.state.penDetected&&n===`pen`&&i.togglePenMode(!0),t?.onSelect){t.onSelect(i,{pointerType:n});return}i.state.activeTool.type!==e&&(xC(`toolbar`,e,`ui`),i.setActiveTool({type:e}))}})};return i.displayName=`${lo(e)}IconButton`,i},yT=vT(`hand`),bT=vT(`rectangle`),xT=vT(`diamond`),ST=vT(`ellipse`),CT=vT(`arrow`),wT=vT(`line`),TT=vT(`freedraw`),ET=vT(`text`),DT=vT(`image`),OT=vT(`eraser`),kT=vT(`frame`),AT=vT(`selection`,{onSelect:(e,{pointerType:t})=>{if(e.state.activeTool.type===`selection`&&t!==null){e.setActiveTool({type:`lasso`});return}e.state.activeTool.type!==`selection`&&(xC(`toolbar`,`selection`,`ui`),e.setActiveTool({type:`selection`}))}}),jT=vT(`lasso`,{shortcutType:`selection`}),MT=({app:e,activeTool:t,setAppState:n})=>{let r=[{type:`selection`,icon:fT.selection.icon,fillable:fT.selection.fillable,title:lo(W(`toolBar.selection`))},{type:`lasso`,icon:fT.lasso.icon,fillable:fT.lasso.fillable,title:lo(W(`toolBar.lasso`))}],i=r.find(t=>t.type===e.state.preferredSelectionTool.type)||r[0];return(0,V.jsx)(dT,{app:e,options:r,activeTool:t,defaultOption:e.state.preferredSelectionTool.type,"data-testid":`toolbar-selection`,onToolChange:t=>{(t===`selection`||t===`lasso`)&&(e.setActiveTool({type:t}),n({preferredSelectionTool:{type:t,initialized:!0}}))},displayedOption:i})},NT=({app:e,activeTool:t})=>{let n=[{type:`freedraw`,icon:fT.freedraw.icon,fillable:fT.freedraw.fillable,title:lo(W(`toolBar.freedraw`))},{type:`autoshape`,icon:fT.autoshape.icon,fillable:fT.autoshape.fillable,title:lo(W(`toolBar.autoshape`))}],[r,i]=(0,B.useState)(t.type===`autoshape`?`autoshape`:`freedraw`);(0,B.useEffect)(()=>{(t.type===`freedraw`||t.type===`autoshape`)&&i(t.type)},[t.type]);let a=n.find(e=>e.type===r)||n[0];return(0,V.jsx)(dT,{app:e,options:n,activeTool:t,defaultOption:r,"data-testid":`toolbar-freedraw`,onToolChange:t=>{(t===`freedraw`||t===`autoshape`)&&(i(t),e.setActiveTool({type:t}))},displayedOption:a})},PT=Y({name:`finalize`,label:``,trackEvent:!1,perform:(e,t,n,r)=>{let i=!0,a=e,{focusContainer:o,scene:s}=r,c=s.getNonDeletedElementsMap(),l=t.activeTool.type===`autoshape`;if(n&&t.selectedLinearElement){let{event:i,sceneCoords:o}=n,u=N.getElement(t.selectedLinearElement.elementId,c);qa(u,`Arrow element should exist if selectedLinearElement is set`),qa(o,`sceneCoords should be defined if actionFinalize is called with event`);let d=N.handlePointerUp(i,t.selectedLinearElement,t,r.scene);if(ft(u)&&!t.selectedLinearElement.segmentMidPointHoveredCoords){let e=!!t.newElement,n=e||!t.selectedLinearElement.selectedPointsIndices?[u.points.length-1]:t.selectedLinearElement.selectedPointsIndices,a=Be(i),l=i[j.CTRL_OR_CMD]?null:r.getEffectiveGridSize(),f=n.reduce((e,t)=>(e.set(t,{point:a?u.points[t]:N.createPointAt(u,c,o.x-d.pointerOffset.x,o.y-d.pointerOffset.y,l)}),e),new Map)??new Map;Ct(u,f,o.x,o.y,s,t,{newArrow:e,altKey:i.altKey,angleLocked:a,gridSize:r.getEffectiveGridSize()})}else Oe(u)&&t.selectedLinearElement?.isEditing&&!t.newElement&&!Un(u.points)&&s.mutateElement(u,{polygon:!1});if(d!==t.selectedLinearElement){u&&li(u)&&(a=a.map(e=>e.id===u.id?R(e,{isDeleted:!0}):e));let n=t.activeTool?.locked;return{elements:u.points.length<2||li(u)?e.map(e=>e.id===u.id?R(e,{isDeleted:!0}):e):a,appState:{...t,cursorButton:`up`,selectedElementIds:l?{}:t.selectedElementIds,selectedLinearElement:n||l?null:{...d,selectedPointsIndices:null,isEditing:!1,initialState:{...d.initialState,lastClickedPoint:-1},pointerOffset:{x:0,y:0}},selectionElement:null,suggestedBinding:null,hoveredArrowTextAnchor:null,newElement:null,multiElement:null},captureUpdate:F.IMMEDIATELY}}}window.document.activeElement instanceof HTMLElement&&o();let u=r.drawShape.hasPendingGesture();(u||l)&&(r.drawShape.finalize(),u&&(a=r.scene.getElementsIncludingDeleted()));let d=null;if(t.multiElement)d=t.multiElement;else if(!l&&!u&&(t.newElement?.type===`freedraw`||ft(t.newElement)))d=t.newElement;else if(Object.keys(t.selectedElementIds).length===1){let e=c.get(Object.keys(t.selectedElementIds)[0]);e&&(d=e)}if(d){if(t.selectedLinearElement&&t.multiElement&&d.type!==`freedraw`&&t.lastPointerDownWith!==`touch`){let{points:e}=d,{lastCommittedPoint:n}=t.selectedLinearElement;if((!n||e[e.length-1]!==n)&&(i=!1,s.mutateElement(d,{points:d.points.slice(0,-1)}),ft(d)&&d.endBinding&&d.points.length>1)){let e=!!t.newElement,n=new Map([[d.points.length-1,{point:d.points[d.points.length-1],isDragging:!1}]]),r=N.getPointAtIndexGlobalCoordinates(d,-1,c);Ct(d,n,r[0],r[1],s,t,{newArrow:e})}}if(d&&li(d)&&(a=a.map(e=>e.id===d?.id?R(e,{isDeleted:!0}):e)),po(d)||os(d)){if(io(d.points,t.zoom.value)&&(Oe(d)||os(d))){let e=d.points,t=e[0],n=e.map((n,r)=>r===e.length-1?L(t[0],t[1]):n);Oe(d)?s.mutateElement(d,{points:n,polygon:!0}):s.mutateElement(d,{points:n})}Oe(d)&&!Un(d.points)&&s.mutateElement(d,{polygon:!1})}}let f;f=pT.includes(t.activeTool.type)?Pt(t,{...t.activeTool.lastActiveTool||{type:r.state.preferredSelectionTool.type},lastActiveTool:null}):Pt(t,{type:r.state.preferredSelectionTool.type});let p=r.isToolLocked(),m=t.activeTool.type===`autoshape`||(p||t.activeTool.type===`freedraw`)&&!!d;m||r.cursor.applyForTool(f);let h=d&&po(d)?new N(d,ui(a)):t.selectedLinearElement;return h&&={...h,isEditing:!t.newElement&&h.isEditing,initialState:{...h.initialState,lastClickedPoint:-1,origin:null}},{elements:a,appState:{...t,cursorButton:`up`,activeTool:m?t.activeTool:f,activeEmbeddable:null,newElement:null,selectionElement:null,multiElement:null,editingTextElement:null,suggestedBinding:null,hoveredArrowTextAnchor:null,frameToHighlight:null,selectedElementIds:l?{}:d&&!p&&t.activeTool.type!==`freedraw`?{...t.selectedElementIds,[d.id]:!0}:t.selectedElementIds,selectedLinearElement:l?null:h},captureUpdate:i?F.IMMEDIATELY:F.NEVER}},keyTest:(e,t)=>e.key===j.ESCAPE&&t.selectedLinearElement?.isEditing||(e.key===j.ESCAPE||e.key===j.ENTER)&&t.multiElement!==null,PanelComponent:({appState:e,updateData:t,data:n})=>(0,V.jsx)(J,{type:`button`,icon:Hb,title:W(`buttons.done`),"aria-label":W(`buttons.done`),onClick:t,visible:e.multiElement!=null,size:n?.size||`medium`,style:{pointerEvents:`all`}})}),FT=(e,t)=>pT.includes(e.activeTool.type)?Pt(e,{...e.activeTool.lastActiveTool||{type:t.state.preferredSelectionTool.type},lastActiveTool:null}):Pt(e,{type:t.state.preferredSelectionTool.type}),IT=(e,t,n)=>{if(!e.editingGroupId)return null;let r=t.scene.getNonDeletedElements(),i=t.scene.getSelectedElements({selectedElementIds:n,elements:r}),a=i.length?i:yt(r,e.editingGroupId);for(let t of a){let n=t.groupIds.indexOf(e.editingGroupId);if(n!==-1&&t.groupIds[n+1])return t.groupIds[n+1]}return null};Y({name:`deselect`,label:``,trackEvent:!1,perform:(e,t,n,r)=>{let i=FT(t,r);if(r.cursor.applyForTool(i),t.editingGroupId){let e=r.scene.getNonDeletedElements(),n=Object.keys(t.selectedElementIds).length>0?t.selectedElementIds:yt(e,t.editingGroupId).reduce((e,t)=>(e[t.id]=!0,e),{});return{appState:{...t,...na({editingGroupId:IT(t,r,n),selectedElementIds:n},e,t,r),activeEmbeddable:null,activeTool:i,selectedLinearElement:null,selectionElement:null,showHyperlinkPopup:!1,suggestedBinding:null,hoveredArrowTextAnchor:null,frameToHighlight:null},captureUpdate:F.IMMEDIATELY}}return{appState:{...t,activeEmbeddable:null,activeTool:i,editingGroupId:null,selectedElementIds:fa({},t),selectedGroupIds:{},selectedLinearElement:null,selectionElement:null,showHyperlinkPopup:!1,suggestedBinding:null,hoveredArrowTextAnchor:null,frameToHighlight:null},captureUpdate:F.IMMEDIATELY}},keyTest:(e,t,n,r)=>e.key!==j.ESCAPE||de(e.target)?!1:!t.newElement&&t.multiElement===null&&!t.selectedLinearElement?.isEditing&&(t.activeEmbeddable!==null||t.activeTool.type!==r.state.preferredSelectionTool.type||!!t.editingGroupId||!!t.selectedLinearElement||Bi(r.scene.getNonDeletedElements(),t))});var LT=({children:e,checked:t,onChange:n,className:r})=>(0,V.jsxs)(`div`,{className:H(`Checkbox`,r,{"is-checked":t}),onClick:e=>{n(!t,e),e.currentTarget.querySelector(`.Checkbox-box`).focus()},children:[(0,V.jsx)(`button`,{type:`button`,className:`Checkbox-box`,role:`checkbox`,"aria-checked":t,children:Mb}),(0,V.jsx)(`div`,{className:`Checkbox-label`,children:e})]}),RT=e=>{let t=e.title||(e.value===A.DARK?W(`buttons.lightMode`):W(`buttons.darkMode`));return(0,V.jsx)(J,{type:`icon`,icon:e.value===A.LIGHT?zT.MOON:zT.SUN,title:t,"aria-label":t,onClick:()=>e.onChange(e.value===A.DARK?A.LIGHT:A.DARK),"data-testid":`toggle-dark-mode`})},zT={SUN:(0,V.jsx)(`svg`,{width:`512`,height:`512`,className:`rtl-mirror`,viewBox:`0 0 512 512`,children:(0,V.jsx)(`path`,{fill:`currentColor`,d:`M256 160c-52.9 0-96 43.1-96 96s43.1 96 96 96 96-43.1 96-96-43.1-96-96-96zm246.4 80.5l-94.7-47.3 33.5-100.4c4.5-13.6-8.4-26.5-21.9-21.9l-100.4 33.5-47.4-94.8c-6.4-12.8-24.6-12.8-31 0l-47.3 94.7L92.7 70.8c-13.6-4.5-26.5 8.4-21.9 21.9l33.5 100.4-94.7 47.4c-12.8 6.4-12.8 24.6 0 31l94.7 47.3-33.5 100.5c-4.5 13.6 8.4 26.5 21.9 21.9l100.4-33.5 47.3 94.7c6.4 12.8 24.6 12.8 31 0l47.3-94.7 100.4 33.5c13.6 4.5 26.5-8.4 21.9-21.9l-33.5-100.4 94.7-47.3c13-6.5 13-24.7.2-31.1zm-155.9 106c-49.9 49.9-131.1 49.9-181 0-49.9-49.9-49.9-131.1 0-181 49.9-49.9 131.1-49.9 181 0 49.9 49.9 49.9 131.1 0 181z`})}),MOON:(0,V.jsx)(`svg`,{width:`512`,height:`512`,className:`rtl-mirror`,viewBox:`0 0 512 512`,children:(0,V.jsx)(`path`,{fill:`currentColor`,d:`M283.211 512c78.962 0 151.079-35.925 198.857-94.792 7.068-8.708-.639-21.43-11.562-19.35-124.203 23.654-238.262-71.576-238.262-196.954 0-72.222 38.662-138.635 101.498-174.394 9.686-5.512 7.25-20.197-3.756-22.23A258.156 258.156 0 0 0 283.211 0c-141.309 0-256 114.511-256 256 0 141.309 114.511 256 256 256z`})})},BT=e=>{let{id:t}=cV(),[n,r]=(0,B.useState)(e.value);return(0,V.jsxs)(`div`,{className:`ProjectName`,children:[(0,V.jsx)(`label`,{className:`ProjectName-label`,htmlFor:`filename`,children:`${e.label}:`}),(0,V.jsx)(`input`,{type:`text`,className:`TextInput`,onBlur:t=>{e.ignoreFocus||Ir(t.target);let n=t.target.value;n!==e.value&&e.onChange(n)},onKeyDown:e=>{if(e.key===j.ENTER){if(e.preventDefault(),e.nativeEvent.isComposing||e.keyCode===229)return;e.currentTarget.blur()}},id:`${t}-filename`,value:n,onChange:e=>r(e.target.value)})]})},VT=5e3,HT=Object.assign(({message:e,onClose:t,closable:n=!1,duration:r=VT,style:i})=>{let a=(0,B.useRef)(0),o=r!==1/0,s=(0,B.useCallback)(()=>{o&&(a.current=window.setTimeout(()=>t(),r))},[t,r,o]);return(0,B.useEffect)(()=>{if(o)return s(),()=>clearTimeout(a.current)},[s,e,r,o]),(0,V.jsxs)(`div`,{className:`Toast`,role:`status`,onMouseEnter:o?()=>clearTimeout(a?.current):void 0,onMouseLeave:o?s:void 0,style:i,children:[(0,V.jsx)(`div`,{className:`Toast__message`,children:e}),n&&(0,V.jsx)(J,{icon:lx,"aria-label":`close`,type:`icon`,onClick:t,className:`close`})]})},{ProgressBar:({progress:e})=>(0,V.jsx)(`div`,{className:`Toast__progress-bar`,children:(0,V.jsx)(`div`,{className:`Toast__progress-bar-fill`,style:{width:`${Math.min(5,Math.round(e*100))}%`}})})});`clipboard`in navigator&&`readText`in navigator.clipboard;var UT=`clipboard`in navigator&&`writeText`in navigator.clipboard,WT=`clipboard`in navigator&&`write`in navigator.clipboard&&`ClipboardItem`in window&&`toBlob`in HTMLCanvasElement.prototype,GT=e=>!!([Oc.excalidraw,Oc.excalidrawClipboard,Oc.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),KT=({types:e,files:t})=>{!e&&!t&&console.warn(`createPasteEvent: no types or files provided`);let n=new ClipboardEvent(T.PASTE,{clipboardData:new DataTransfer});if(e)for(let[r,i]of Object.entries(e)){if(typeof i!=`string`){t||=[],t.push(i);continue}try{if(n.clipboardData?.items.add(i,r),n.clipboardData?.getData(r)!==i)throw Error(`Failed to set "${r}" as clipboardData item`)}catch(e){throw Error(e.message)}}if(t){let e=-1;for(let r of t){e++;try{if(n.clipboardData?.items.add(r),n.clipboardData?.files[e]!==r)throw Error(`Failed to set file "${r.name}" as clipboardData item`)}catch(e){throw Error(e.message)}}}return n},qT=({elements:e,files:t})=>{let n=ui(e),r=new Set(e.filter(e=>P(e))),i=!1,a=e.reduce((e,n)=>(ae(n)&&(i=!0,t&&t[n.fileId]&&(e[n.fileId]=t[n.fileId])),e),{});i&&!t&&console.warn("copyToClipboard: attempting to file element(s) without providing associated `files` object.");let o={type:Oc.excalidrawClipboard,elements:e.map(e=>{if(Bt(e,n)&&!r.has(Bt(e,n))){let t=ca(e);return ir(t,n,{frameId:null}),t}return e}),files:t?a:void 0};return JSON.stringify(o)},JT=async(e,t,n)=>{let r=qT({elements:e,files:t});await oE({[M.excalidrawClipboard]:r,[M.text]:r},n)};function YT(e){let t=[];for(let n of e.childNodes)if(n.nodeType===3){let e=n.textContent?.trim();e&&t.push({type:`text`,value:e})}else if(n instanceof HTMLImageElement){let e=n.getAttribute(`src`);e&&e.startsWith(`http`)&&t.push({type:`imageUrl`,value:e})}else t=t.concat(YT(n));return t}var XT=e=>{let t=e.value;try{let e=YT(new DOMParser().parseFromString(t,M.html).body);if(e.length)return{type:`mixedContent`,value:e}}catch(e){console.error(`error in parseHTMLFromPaste: ${e.message}`)}return null},ZT=async()=>{let e={},t;try{t=await navigator.clipboard?.read()}catch(t){try{if(navigator.clipboard?.readText){console.warn(`navigator.clipboard.readText() failed (${t.message}). Failling back to navigator.clipboard.read()`);let e=await navigator.clipboard?.readText();if(e)return{[M.text]:e}}}catch(t){if(navigator.clipboard?.read)console.warn(`navigator.clipboard.readText() failed (${t.message}). Failling back to navigator.clipboard.read()`);else{if(t.name===`DataError`)return console.warn(`navigator.clipboard.read() error, clipboard is probably empty: ${t.message}`),e;throw t}}throw t}for(let n of t)for(let t of n.types)if(Hr(tr,t))try{if(t===M.text||t===M.html)e[t]=await(await n.getType(t)).text();else if(Do(t)){let r=await n.getType(t);e[t]=Xn(r,t,void 0)}else throw new ni(`Unsupported clipboard type: ${t}`)}catch(e){console.warn(e instanceof ni?e.message:`Cannot retrieve ${t} from clipboardItem: ${e.message}`)}return Object.keys(e).length===0&&console.warn(`No clipboard data found from clipboard.read().`),e},QT=async(e,t=!1)=>{try{let n=e.findByType(M.html),r=!t&&n&&XT(n);return r?r.value.every(e=>e.type===`text`)?{type:`text`,value:e.getData(M.text)??r.value.map(e=>e.value).join(`
|
|
43
|
-
`).trim()}:r:{type:`text`,value:(e.getData(M.text)||``).trim()}}catch{return{type:`text`,value:``}}},$T=function(e){return this.find(t=>t.type===e)||null},eE=function(e){return this.find(t=>t.type===e)?.value??null},tE=function(){return this.filter(e=>e.kind===`file`)},nE=e=>{let t;t=cE(e)?e.clipboardData?.items:e.dataTransfer?.items;let n=new Set;for(let e of Array.from(t||[]))n.has(e.type)||n.add(e.type);return n},rE=async e=>{let t;t=cE(e)?e.clipboardData?.items:e.dataTransfer?.items;let n=(await Promise.all(Array.from(t||[]).map(async t=>{if(t.kind===`file`){let e=t.getAsFile();if(e){let n=await Jo(t);return e=await Cs(e),{type:e.type,kind:`file`,file:e,fileHandle:n}}}else if(t.kind===`string`){let{type:n}=t,r;return r=`clipboardData`in e&&e.clipboardData?e.clipboardData?.getData(n):await new Promise(e=>{t.getAsString(t=>e(t))}),{type:n,kind:`string`,value:r}}return null}))).filter(e=>e!=null);return Object.assign(n,{findByType:$T,getData:eE,getFiles:tE})},iE=async(e,t=!1)=>{let n=await QT(e,t);if(n.type===`mixedContent`)return{mixedContent:n.value};try{let e=JSON.parse(n.value),r=e.type===Oc.excalidrawClipboardWithAPI;if(GT(e))return{elements:e.elements,files:e.files,text:t?JSON.stringify(e.elements,null,2):void 0,programmaticAPI:r}}catch{}return{text:n.value}},aE=async e=>{try{await navigator.clipboard.write([new ClipboardItem({[M.png]:e})])}catch(t){if(nt(e))await navigator.clipboard.write([new ClipboardItem({[M.png]:await e})]);else throw t}},oE=async(e,t)=>{e||=``;let n=Object.entries(typeof e==`string`?{[M.text]:e}:e);try{if(t){for(let[e,r]of n)if(t.clipboardData?.setData(e,r),t.clipboardData?.getData(e)!==r)throw Error(`Failed to setData on clipboardEvent`);return}}catch(e){console.error(e)}let r=n.find(([e])=>e===M.text);if(UT&&r)try{await navigator.clipboard.writeText(r[1]);return}catch(e){console.error(e)}if(r&&!sE(r[1]))throw Error(`Error copying to clipboard.`)},sE=e=>{e||=` `;let t=document.documentElement.getAttribute(`dir`)===`rtl`,n=document.createElement(`textarea`);n.style.border=`0`,n.style.padding=`0`,n.style.margin=`0`,n.style.position=`absolute`,n.style[t?`right`:`left`]=`-9999px`;let r=window.pageYOffset||document.documentElement.scrollTop;n.style.top=`${r}px`,n.style.fontSize=`12pt`,n.setAttribute(`readonly`,``),n.value=e,document.body.appendChild(n);let i=!1;try{n.select(),n.setSelectionRange(0,n.value.length),i=document.execCommand(`copy`)}catch(e){console.error(e)}return n.remove(),i},cE=e=>e.type===T.PASTE||e.type===T.COPY||e.type===T.CUT,lE=(e,{selectedElementIds:t},n)=>{let r=et(e),i=ui(r),a=n&&Bi(r,{selectedElementIds:t}),o=null,s=a?xt(r,{selectedElementIds:t},{includeBoundTextElement:!0}):r;if(a){let e=s[0];s.length===1&&P(e)?(o=e,s=Vn(r,e,i)):s.length>1&&(s=xt(r,{selectedElementIds:t},{includeBoundTextElement:!0,includeElementsInFrames:!0}))}return{exportingFrame:o,exportedElements:ta(s)}},uE=async(e,t,r,i,{exportBackground:a,exportPadding:o=10,viewBackgroundColor:s,name:c=r.name||`Untitled`,fileHandle:l=null,exportingFrame:u=null})=>{if(t.length===0)throw Error(W(`alerts.cannotExportEmptyCanvas`));if(e===`svg`||e===`clipboard-svg`){let n=Ne(t,{exportBackground:a,exportWithDarkMode:r.exportWithDarkMode,viewBackgroundColor:s,exportPadding:o,exportScale:r.exportScale,exportEmbedScene:r.exportEmbedScene&&e===`svg`},i,{exportingFrame:u});if(e===`svg`)return mn(n.then(e=>new Blob([Ia+e.outerHTML],{type:M.svg})),{description:`Export to SVG`,name:c,extension:r.exportEmbedScene?`excalidraw.svg`:`svg`,mimeTypes:[it.svg],fileHandle:l});if(e===`clipboard-svg`){let e=await n.then(e=>e.outerHTML);try{await oE(e)}catch{throw Error(W(`errors.copyToSystemClipboardFailed`))}return}}let d=fs(t,r,i,{exportBackground:a,viewBackgroundColor:s,exportPadding:o,exportingFrame:u});if(e===`png`){let e=vo(d);return r.exportEmbedScene&&(e=e.then(e=>n(async()=>{let{encodePngMetadata:e}=await import(`./image-QXRYHUNP-SWEV8H0J.js`);return{encodePngMetadata:e}},__vite__mapDeps([62,63,2,64,1]),import.meta.url).then(({encodePngMetadata:n})=>n({blob:e,metadata:Xs(t,r,i,`local`)})))),mn(e,{description:`Export to PNG`,name:c,extension:r.exportEmbedScene?`excalidraw.png`:`png`,mimeTypes:[it.png],fileHandle:l})}if(e===`clipboard`)try{await aE(vo(d))}catch(e){throw console.warn(e),e.name===`CANVAS_POSSIBLY_TOO_BIG`?Error(W(`canvasError.canvasTooBig`)):Ya&&e.name===`TypeError`?Error(`${W(`alerts.couldNotCopyToClipboard`)}
|
|
44
|
-
|
|
45
|
-
${W(`hints.firefox_clipboard_write`)}`):Error(W(`alerts.couldNotCopyToClipboard`))}else throw Error(`Unsupported export type`)},dE=async(e,t,n)=>{let r=Oo(t);if(!ac(r))throw Error(`fileHandle should exist and should be of type svg or png when resaving`);let{elements:i,appState:a,files:o}=await e,{exportBackground:s,viewBackgroundColor:c}=a;a={...a,exportEmbedScene:!0};let{exportedElements:l,exportingFrame:u}=lE(i,a,!1);return await uE(r,l,a,o,{exportBackground:s,viewBackgroundColor:c,name:n,fileHandle:t,exportingFrame:u}),{fileHandle:t}},fE=Y({name:`changeProjectName`,label:`labels.fileTitle`,trackEvent:!1,perform:(e,t,n)=>({appState:{...t,name:n},captureUpdate:F.EVENTUALLY}),PanelComponent:({appState:e,updateData:t,appProps:n,data:r,app:i})=>(0,V.jsx)(BT,{label:W(`labels.fileTitle`),value:i.getName(),onChange:e=>t(e),ignoreFocus:r?.ignoreFocus??!1})}),pE=Y({name:`changeExportScale`,label:`imageExportDialog.scale`,trackEvent:{category:`export`,action:`scale`},perform:(e,t,n)=>({appState:{...t,exportScale:n},captureUpdate:F.EVENTUALLY})}),mE=Y({name:`changeExportBackground`,label:`imageExportDialog.label.withBackground`,trackEvent:{category:`export`,action:`toggleBackground`},perform:(e,t,n)=>({appState:{...t,exportBackground:n},captureUpdate:F.EVENTUALLY}),PanelComponent:({appState:e,updateData:t})=>(0,V.jsx)(LT,{checked:e.exportBackground,onChange:e=>t(e),children:W(`imageExportDialog.label.withBackground`)})}),hE=Y({name:`changeExportEmbedScene`,label:`imageExportDialog.tooltip.embedScene`,trackEvent:{category:`export`,action:`embedScene`},perform:(e,t,n)=>({appState:{...t,exportEmbedScene:n},captureUpdate:F.EVENTUALLY}),PanelComponent:({appState:e,updateData:t})=>(0,V.jsxs)(LT,{checked:e.exportEmbedScene,onChange:e=>t(e),children:[W(`imageExportDialog.label.embedScene`),(0,V.jsx)(eT,{label:W(`imageExportDialog.tooltip.embedScene`),long:!0,children:(0,V.jsx)(`div`,{className:`excalidraw-tooltip-icon`,children:Gb})})]})}),gE=!1,_E=(e,t)=>{let n=t.message??W(`progressDialog.defaultMessage`);e.setAppState({toast:{message:t.progress==null?n:(0,V.jsxs)(V.Fragment,{children:[n,(0,V.jsx)(HT.ProgressBar,{progress:t.progress})]}),duration:1/0}})};async function vE(e,t){if(t.app.state.isLoading&&(_E(t.app,{progress:null}),await t.app.onStateChange({predicate:e=>!e.isLoading})),typeof e==`object`&&e&&Symbol.asyncIterator in e){for await(let n of e){if(t.signal.aborted){e.return();return}if(n.type===`progress`)_E(t.app,{message:n.message,progress:n.progress??null});else if(n.type===`done`)return}return}e instanceof Promise&&(_E(t.app,{progress:null}),await e)}function yE(e,t,n,r){let i=new AbortController,a=i.signal;return{abortController:i,data:new Promise(async i=>{try{r.props.onExport&&await vE(r.props.onExport(`json`,{elements:e,appState:t,files:n},{signal:a}),{app:r,signal:a})}catch(e){e?.name===`AbortError`?console.warn(`onExport() aborted by host app (signal aborted: ${a.aborted})`):console.error(`Error during props.onExport() handling`,e)}i({elements:e,appState:t,files:r.files})})}}var bE=Y({name:`saveToActiveFile`,label:`buttons.save`,icon:Tb,trackEvent:{category:`export`},predicate:(e,t,n,r)=>!!r.props.UIOptions.canvasActions.saveToActiveFile&&!!t.fileHandle&&!t.viewModeEnabled,perform:async(e,t,n,r)=>{if(gE)return!1;gE=!0;let i=t.fileHandle,a=r.getName(),{abortController:o,data:s}=yE(e,t,r.files,r);try{let{fileHandle:e}=Ta(i)?await dE(s,i,a):await Hn({data:s,filename:a,fileHandle:i});return{captureUpdate:F.NEVER,appState:{fileHandle:e,toast:{message:i&&e?.name?W(`toast.fileSavedToFilename`).replace(`{filename}`,`"${e.name}"`):W(`toast.fileSaved`),duration:1500}}}}catch(e){return o.abort(),e?.name===`AbortError`?console.warn(e):console.error(e),{captureUpdate:F.NEVER,appState:{toast:null}}}finally{gE=!1}},keyTest:e=>e.key===j.S&&e[j.CTRL_OR_CMD]&&!e.shiftKey}),xE=Y({name:`saveFileToDisk`,label:`exportDialog.disk_title`,icon:Tb,viewMode:!0,trackEvent:{category:`export`},perform:async(e,t,n,r)=>{if(gE)return!1;gE=!0;let{abortController:i,data:a}=yE(e,t,r.files,r);try{let{fileHandle:e}=await Hn({data:a,filename:r.getName(),fileHandle:null});return{captureUpdate:F.NEVER,appState:{openDialog:null,fileHandle:e,toast:{message:W(`toast.fileSaved`),duration:3e3}}}}catch(e){return i.abort(),e?.name===`AbortError`?console.warn(e):console.error(e),{captureUpdate:F.NEVER,appState:{toast:null}}}finally{gE=!1}},keyTest:e=>e.key.toLowerCase()===j.S&&e.shiftKey&&e[j.CTRL_OR_CMD],PanelComponent:({updateData:e})=>(0,V.jsx)(J,{type:`button`,icon:Fb,title:W(`buttons.saveAs`),"aria-label":W(`buttons.saveAs`),showAriaLabel:oV().formFactor===`phone`,hidden:!Ss,onClick:()=>e(null),"data-testid":`save-as-button`})}),SE=Y({name:`loadScene`,label:`buttons.load`,trackEvent:{category:`export`},predicate:(e,t,n,r)=>!!r.props.UIOptions.canvasActions.loadScene&&!t.viewModeEnabled,perform:async(e,t,n,r)=>{try{let{elements:n,appState:r,files:i}=await aa(t,e);return{elements:n,appState:r,files:i,captureUpdate:F.IMMEDIATELY}}catch(n){return n?.name===`AbortError`?(console.warn(n),!1):{elements:e,appState:{...t,errorMessage:n.message},files:r.files,captureUpdate:F.EVENTUALLY}}},keyTest:e=>e[j.CTRL_OR_CMD]&&e.key===j.O}),CE=Y({name:`exportWithDarkMode`,label:`imageExportDialog.label.darkMode`,trackEvent:{category:`export`,action:`toggleTheme`},perform:(e,t,n,r)=>(r.sessionExportThemeOverride=n?A.DARK:A.LIGHT,{appState:{...t,exportWithDarkMode:n},captureUpdate:F.EVENTUALLY}),PanelComponent:({appState:e,updateData:t})=>(0,V.jsx)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,marginTop:`-45px`,marginBottom:`10px`},children:(0,V.jsx)(RT,{value:e.exportWithDarkMode?A.DARK:A.LIGHT,onChange:e=>{t(e===A.DARK)},title:W(`imageExportDialog.label.darkMode`)})})}),wE=`{}`,TE=Y({name:`copyStyles`,label:`labels.copyStyles`,icon:LS,trackEvent:{category:`element`},perform:(e,t,n,r)=>{let i=[],a=e.find(e=>t.selectedElementIds[e.id]);if(i.push(a),a&&Dr(a)){let e=Ti(a,r.scene.getNonDeletedElementsMap());i.push(e)}return a&&(wE=JSON.stringify(i)),{appState:{...t,toast:{message:W(`toast.copyStyles`)}},captureUpdate:F.EVENTUALLY}},keyTest:e=>e[j.CTRL_OR_CMD]&&e.altKey&&e.code===I.C}),EE=Y({name:`pasteStyles`,label:`labels.pasteStyles`,icon:LS,trackEvent:{category:`element`},perform:(e,t,n,r)=>{let i=JSON.parse(wE),o=i[0],s=i[1];if(!bs(o))return{elements:e,captureUpdate:F.EVENTUALLY};let c=xt(e,t,{includeBoundTextElement:!0}),l=c.map(e=>e.id);return{elements:e.map(e=>{if(l.includes(e.id)){let t=o;if(a(e)&&e.containerId&&(t=s),!t)return e;let n=R(e,{backgroundColor:t?.backgroundColor,strokeWidth:t?.strokeWidth,strokeColor:t?.strokeColor,strokeStyle:t?.strokeStyle,fillStyle:t?.fillStyle,opacity:t?.opacity,roughness:t?.roughness,roundness:t.roundness?ee(t.roundness.type,e)?t.roundness:C(e):null});if(a(n)){let e=t.fontSize||20,i=t.fontFamily||yc,a=R(n,{fontSize:e,fontFamily:i,textAlign:t.textAlign||`left`,lineHeight:t.lineHeight||zs(i)});n=a;let o=null;a.containerId&&(o=c.find(e=>e.id===a.containerId)||null),Sa(a,o,r.scene)}return n.type===`arrow`&&_(t)&&(n=R(n,{startArrowhead:t.startArrowhead,endArrowhead:t.endArrowhead})),P(e)&&(n=R(n,{roundness:null,backgroundColor:`transparent`})),n}return e}),captureUpdate:F.IMMEDIATELY}},keyTest:e=>e[j.CTRL_OR_CMD]&&e.altKey&&e.code===I.V}),DE=Y({name:`toggleShortcuts`,label:`welcomeScreen.defaults.helpHint`,icon:Db,viewMode:!0,trackEvent:{category:`menu`,action:`toggleHelpDialog`},perform:(e,t,n,{focusContainer:r})=>(t.openDialog?.name===`help`&&r(),{appState:{...t,openDialog:t.openDialog?.name===`help`?null:{name:`help`},openMenu:null,openPopup:null},captureUpdate:F.EVENTUALLY}),keyTest:e=>e.key===j.QUESTION_MARK}),OE=(e,t)=>{if(e.length>=2){let n=t?e[0].groupIds.indexOf(t):-1,r=n>-1?e[0].groupIds.slice(0,n):e[0].groupIds;for(let t of r)if(e.every(e=>oa(e,t)))return!0}return!1},kE=(e,t)=>{let n=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds,includeBoundTextElement:!1});return n.length>=2&&!OE(n,e.editingGroupId)&&!Ln(n)},AE=Y({name:`group`,label:`labels.group`,icon:e=>(0,V.jsx)(ux,{theme:e.theme}),trackEvent:{category:`element`},perform:(e,t,n,r)=>{if(!kE(t,r))return!1;let i=Dc(r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0}));if(i.length<2)return{appState:t,elements:e,captureUpdate:F.EVENTUALLY};let a=Vi(t);if(a.length===1){let n=a[0],r=new Set(yt(e,n).map(e=>e.id)),o=new Set(i.map(e=>e.id));if(new Set([...Array.from(r),...Array.from(o)]).size===r.size)return{appState:t,elements:e,captureUpdate:F.EVENTUALLY}}let o=[...e];new Set(i.map(e=>e.frameId)).size>1&&Pe(i).forEach((e,t)=>{_n(e,r.scene.getNonDeletedElementsMap())});let s=Tc(),c=ui(i);o=o.map(e=>c.get(e.id)?R(e,{groupIds:br(e.groupIds,s,t.editingGroupId)}):e);let l=yt(o,s),u=l[l.length-1],d=o.lastIndexOf(u),f=o.slice(d+1),p=o.slice(0,d).filter(e=>!oa(e,s)),m=Ie([...p,...l,...f],ui(l));return{appState:{...t,...gr(s,{...t,selectedGroupIds:{}},et(o))},elements:m,captureUpdate:F.IMMEDIATELY}},predicate:(e,t,n,r)=>kE(t,r),keyTest:e=>!e.shiftKey&&e[j.CTRL_OR_CMD]&&e.key===j.G,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,V.jsx)(J,{hidden:!kE(t,r),type:`button`,icon:(0,V.jsx)(ux,{theme:t.theme}),onClick:()=>n(null),title:`${W(`labels.group`)} \u2014 ${X(`CtrlOrCmd+G`)}`,"aria-label":W(`labels.group`),visible:Bi(et(e),t)})}),jE=Y({name:`ungroup`,label:`labels.ungroup`,icon:e=>(0,V.jsx)(dx,{theme:e.theme}),trackEvent:{category:`element`},perform:(e,t,n,r)=>{let i=Vi(t),a=ui(e);if(i.length===0)return{appState:t,elements:e,captureUpdate:F.EVENTUALLY};let o=[...e],s=[];o=o.map(e=>{cs(e)&&s.push(e.id);let n=Ft(e.groupIds,t.selectedGroupIds);return n.length===e.groupIds.length?e:R(e,{groupIds:n})});let c=na(t,et(o),t,null),l=r.scene.getSelectedElements(t),u=new Set(l.filter(e=>e.frameId).map(e=>e.frameId));return Ms(e).filter(e=>u.has(e.id)).forEach(e=>{e&&(o=xi(o,Os(o,e,t,a),e))}),c.selectedElementIds=Object.entries(c.selectedElementIds).reduce((e,[t,n])=>(n&&!s.includes(t)&&(e[t]=!0),e),{}),{appState:{...t,...c},elements:o,captureUpdate:F.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[j.CTRL_OR_CMD]&&e.key===j.G.toUpperCase(),predicate:(e,t)=>Vi(t).length>0,PanelComponent:({elements:e,appState:t,updateData:n})=>(0,V.jsx)(J,{type:`button`,hidden:Vi(t).length===0,icon:(0,V.jsx)(dx,{theme:t.theme}),onClick:()=>n(null),title:`${W(`labels.ungroup`)} \u2014 ${X(`CtrlOrCmd+Shift+G`)}`,"aria-label":W(`labels.ungroup`),visible:Bi(et(e),t)})}),ME=(e,t,n,r,i,a,o)=>{e.beginPath(),e.moveTo(t+a,n),e.lineTo(t+r-a,n),e.quadraticCurveTo(t+r,n,t+r,n+a),e.lineTo(t+r,n+i-a),e.quadraticCurveTo(t+r,n+i,t+r-a,n+i),e.lineTo(t+a,n+i),e.quadraticCurveTo(t,n+i,t,n+i-a),e.lineTo(t,n+a),e.quadraticCurveTo(t,n,t+a,n),e.closePath(),e.fill(),o&&(e.strokeStyle=o),e.stroke()};function NE(e){let t=0;if(e.length===0)return t;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t=(t<<5)-t+r}return t}var PE=(e,t)=>`hsl(${Math.abs(NE(t?.id||e))%37*10}, 100%, 83%)`,FE=e=>{let t=e?.trim()?.codePointAt(0);return(t?String.fromCodePoint(t):`?`).toUpperCase()},IE=({context:e,renderConfig:t,appState:n,normalizedWidth:r,normalizedHeight:i})=>{for(let[a,o]of t.remotePointerViewportCoords){let{x:s,y:c}=o,l=n.collaborators.get(a);s-=n.offsetLeft,c-=n.offsetTop;let u=s<0||s>r-11||c<0||c>i-14;s=Math.max(s,0),s=Math.min(s,r-11),c=Math.max(c,0),c=Math.min(c,i-14);let d=PE(a,l);e.save(),e.strokeStyle=d,e.fillStyle=d;let f=t.remotePointerUserStates.get(a),p=u||f===en.IDLE||f===en.AWAY;p&&(e.globalAlpha=.3),t.remotePointerButton.get(a)===`down`&&(e.beginPath(),e.arc(s,c,15,0,2*Math.PI,!1),e.lineWidth=3,e.strokeStyle=`#ffffff88`,e.stroke(),e.closePath(),e.beginPath(),e.arc(s,c,15,0,2*Math.PI,!1),e.lineWidth=1,e.strokeStyle=d,e.stroke(),e.closePath());let m=n.theme===A.DARK?`#2f6330`:Di,h=l?.isSpeaking;h&&(e.fillStyle=m,e.strokeStyle=m,e.lineWidth=10,e.lineJoin=`round`,e.beginPath(),e.moveTo(s,c),e.lineTo(s+0,c+14),e.lineTo(s+4,c+9),e.lineTo(s+11,c+8),e.closePath(),e.stroke(),e.fill()),e.fillStyle=Jt,e.strokeStyle=Jt,e.lineWidth=6,e.lineJoin=`round`,e.beginPath(),e.moveTo(s,c),e.lineTo(s+0,c+14),e.lineTo(s+4,c+9),e.lineTo(s+11,c+8),e.closePath(),e.stroke(),e.fill(),e.fillStyle=d,e.strokeStyle=d,e.lineWidth=2,e.lineJoin=`round`,e.beginPath(),p?(e.moveTo(s-1,c-1),e.lineTo(s-1,c+15),e.lineTo(s+5,c+10),e.lineTo(s+12,c+9),e.closePath(),e.fill()):(e.moveTo(s,c),e.lineTo(s+0,c+14),e.lineTo(s+4,c+9),e.lineTo(s+11,c+8),e.closePath(),e.fill(),e.stroke());let g=t.remotePointerUsernames.get(a)||``;if(!u&&g){e.font=`600 12px sans-serif`;let t=(h?s+0:s)+11/2,n=(h?c+0:c)+14+2,r=e.measureText(g),i=r.actualBoundingBoxDescent+r.actualBoundingBoxAscent,a=Math.max(i,12),o=t-1,l=n-1,u=r.width+2+10+2,f=a+2+6+2;e.roundRect?(e.beginPath(),e.roundRect(o,l,u,f,8),e.fillStyle=d,e.fill(),e.strokeStyle=`#ffffff`,e.stroke(),h&&(e.beginPath(),e.roundRect(o-2,l-2,u+4,f+4,8),e.strokeStyle=m,e.stroke())):ME(e,o,l,u,f,8,`#ffffff`),e.fillStyle=`#1e1e1e`,e.fillText(g,t+5+1,n+3+r.actualBoundingBoxAscent+Math.floor((a-i)/2)+2),h&&(e.fillStyle=m,e.fillRect(o+u+8,l+(f/2-4),2,8),e.fillRect(o+u+8+5,l+(f/2-8),2,16),e.fillRect(o+u+8+10,l+(f/2-4),2,8))}e.restore(),e.closePath()}},LE=({color:e,onClick:t,name:n,src:r,className:i})=>{let a=FE(n),[o,s]=(0,B.useState)(!1),c=!o&&r,l=c?void 0:{background:e};return(0,V.jsx)(`div`,{className:H(`Avatar`,i),style:l,onClick:t,children:c?(0,V.jsx)(`img`,{className:`Avatar-img`,src:r,alt:a,referrerPolicy:`no-referrer`,onError:()=>s(!0)}):a})};Y({name:`goToCollaborator`,label:`Go to a collaborator`,viewMode:!0,trackEvent:{category:`collab`},perform:(e,t,n,r)=>(qa(n,`actionGoToCollaborator: collaborator should be defined when actionGoToCollaborator is called`),!n.socketId||r.props.userToFollow?.socketId===n.socketId||n.isCurrentUser?(r.requestUnfollow(),{appState:t,captureUpdate:F.EVENTUALLY}):(r.emitUserFollowIntent({userToFollow:{socketId:n.socketId,username:n.username||``},action:`FOLLOW`}),{appState:{...t,openMenu:t.openMenu===`canvas`?null:t.openMenu},captureUpdate:F.EVENTUALLY})),PanelComponent:({updateData:e,data:t,appState:n})=>{let{socketId:r,collaborator:i,withName:a,isBeingFollowed:o}=t,s=PE(r,i),c=H({"is-followed":o,"is-current-user":i.isCurrentUser===!0,"is-speaking":i.isSpeaking,"is-in-call":i.isInCall,"is-muted":i.isMuted}),l=i.isInCall?i.isSpeaking?(0,V.jsxs)(`div`,{className:`UserList__collaborator-status-icon-speaking-indicator`,title:W(`userList.hint.isSpeaking`),children:[(0,V.jsx)(`div`,{}),(0,V.jsx)(`div`,{}),(0,V.jsx)(`div`,{})]}):i.isMuted?(0,V.jsx)(`div`,{className:`UserList__collaborator-status-icon-microphone-muted`,title:W(`userList.hint.micMuted`),children:jS}):(0,V.jsx)(`div`,{title:W(`userList.hint.inCall`),children:AS}):null;return a?(0,V.jsxs)(`div`,{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${c}`,style:{"--avatar-size":`1.5rem`},onClick:i.isCurrentUser?void 0:()=>e(i),children:[(0,V.jsx)(LE,{color:s,onClick:()=>{},name:i.username||``,src:i.avatarUrl,className:c}),(0,V.jsx)(`div`,{className:`UserList__collaborator-name`,children:i.username}),(0,V.jsxs)(`div`,{className:`UserList__collaborator-status-icons`,"aria-hidden":!0,children:[o&&(0,V.jsx)(`div`,{className:`UserList__collaborator-status-icon-is-followed`,title:W(`userList.hint.followStatus`),children:CS}),i.isCurrentUser&&` (${W(`labels.you`)})`,l]})]}):(0,V.jsxs)(`div`,{className:`UserList__collaborator UserList__collaborator--avatar-only ${c}`,children:[(0,V.jsx)(LE,{color:s,onClick:()=>{e(i)},name:i.username||``,src:i.avatarUrl,className:c}),l&&(0,V.jsx)(`div`,{className:`UserList__collaborator-status-icon`,children:l})]})}});var RE=Y({name:`addToLibrary`,trackEvent:{category:`element`},perform:(e,t,n,r)=>{let i=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});for(let e of mi)if(i.some(t=>t.type===e))return{captureUpdate:F.EVENTUALLY,appState:{...t,errorMessage:W(`errors.libraryElementTypeError.${e}`)}};return r.library.getLatestLibrary().then(e=>r.library.setLibrary([{id:Tc(),status:`unpublished`,elements:i.map(ca),created:Date.now()},...e])).then(()=>({captureUpdate:F.EVENTUALLY,appState:{...t,toast:{message:W(`toast.addedToLibrary`)}}})).catch(e=>({captureUpdate:F.EVENTUALLY,appState:{...t,errorMessage:e.message}}))},label:`labels.addToLibrary`}),zE=(e,t)=>{let n=t.scene.getSelectedElements(e);return Es(n,t.scene.getNonDeletedElementsMap(),e).length>1&&!n.some(e=>P(e))},BE=(e,t,n,r)=>{let i=n.scene.getSelectedElements(t),a=Ga(i,r,n.scene,t),o=ui(a);return Ma(e.map(e=>o.get(e.id)||e),t,n)};Y({name:`alignTop`,label:`labels.alignTop`,icon:$b,trackEvent:{category:`element`},predicate:(e,t,n,r)=>zE(t,r),perform:(e,t,n,r)=>({appState:t,elements:BE(e,t,r,{position:`start`,axis:`y`}),captureUpdate:F.IMMEDIATELY}),keyTest:e=>e[j.CTRL_OR_CMD]&&e.shiftKey&&e.key===j.ARROW_UP,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,V.jsx)(J,{hidden:!zE(t,r),type:`button`,icon:$b,onClick:()=>n(null),title:`${W(`labels.alignTop`)} \u2014 ${X(`CtrlOrCmd+Shift+Up`)}`,"aria-label":W(`labels.alignTop`),visible:Bi(et(e),t)})}),Y({name:`alignBottom`,label:`labels.alignBottom`,icon:ex,trackEvent:{category:`element`},predicate:(e,t,n,r)=>zE(t,r),perform:(e,t,n,r)=>({appState:t,elements:BE(e,t,r,{position:`end`,axis:`y`}),captureUpdate:F.IMMEDIATELY}),keyTest:e=>e[j.CTRL_OR_CMD]&&e.shiftKey&&e.key===j.ARROW_DOWN,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,V.jsx)(J,{hidden:!zE(t,r),type:`button`,icon:ex,onClick:()=>n(null),title:`${W(`labels.alignBottom`)} \u2014 ${X(`CtrlOrCmd+Shift+Down`)}`,"aria-label":W(`labels.alignBottom`),visible:Bi(et(e),t)})}),Y({name:`alignLeft`,label:`labels.alignLeft`,icon:tx,trackEvent:{category:`element`},predicate:(e,t,n,r)=>zE(t,r),perform:(e,t,n,r)=>({appState:t,elements:BE(e,t,r,{position:`start`,axis:`x`}),captureUpdate:F.IMMEDIATELY}),keyTest:e=>e[j.CTRL_OR_CMD]&&e.shiftKey&&e.key===j.ARROW_LEFT,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,V.jsx)(J,{hidden:!zE(t,r),type:`button`,icon:tx,onClick:()=>n(null),title:`${W(`labels.alignLeft`)} \u2014 ${X(`CtrlOrCmd+Shift+Left`)}`,"aria-label":W(`labels.alignLeft`),visible:Bi(et(e),t)})}),Y({name:`alignRight`,label:`labels.alignRight`,icon:nx,trackEvent:{category:`element`},predicate:(e,t,n,r)=>zE(t,r),perform:(e,t,n,r)=>({appState:t,elements:BE(e,t,r,{position:`end`,axis:`x`}),captureUpdate:F.IMMEDIATELY}),keyTest:e=>e[j.CTRL_OR_CMD]&&e.shiftKey&&e.key===j.ARROW_RIGHT,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,V.jsx)(J,{hidden:!zE(t,r),type:`button`,icon:nx,onClick:()=>n(null),title:`${W(`labels.alignRight`)} \u2014 ${X(`CtrlOrCmd+Shift+Right`)}`,"aria-label":W(`labels.alignRight`),visible:Bi(et(e),t)})}),Y({name:`alignVerticallyCentered`,label:`labels.centerVertically`,icon:ax,trackEvent:{category:`element`},predicate:(e,t,n,r)=>zE(t,r),perform:(e,t,n,r)=>({appState:t,elements:BE(e,t,r,{position:`center`,axis:`y`}),captureUpdate:F.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,V.jsx)(J,{hidden:!zE(t,r),type:`button`,icon:ax,onClick:()=>n(null),title:W(`labels.centerVertically`),"aria-label":W(`labels.centerVertically`),visible:Bi(et(e),t)})}),Y({name:`alignHorizontallyCentered`,label:`labels.centerHorizontally`,icon:ox,trackEvent:{category:`element`},predicate:(e,t,n,r)=>zE(t,r),perform:(e,t,n,r)=>({appState:t,elements:BE(e,t,r,{position:`center`,axis:`x`}),captureUpdate:F.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,V.jsx)(J,{hidden:!zE(t,r),type:`button`,icon:ox,onClick:()=>n(null),title:W(`labels.centerHorizontally`),"aria-label":W(`labels.centerHorizontally`),visible:Bi(et(e),t)})});var VE=(e,t)=>{let n=t.scene.getSelectedElements(e);return Es(n,t.scene.getNonDeletedElementsMap(),e).length>2&&!n.some(e=>P(e))},HE=(e,t,n,r)=>{let i=n.scene.getSelectedElements(t),a=rn(i,n.scene.getNonDeletedElementsMap(),r,t,n.scene),o=ui(a);return Ma(e.map(e=>o.get(e.id)||e),t,n)};Y({name:`distributeHorizontally`,label:`labels.distributeHorizontally`,trackEvent:{category:`element`},perform:(e,t,n,r)=>({appState:t,elements:HE(e,t,r,{space:`between`,axis:`x`}),captureUpdate:F.IMMEDIATELY}),keyTest:e=>!e[j.CTRL_OR_CMD]&&e.altKey&&e.code===I.H,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,V.jsx)(J,{hidden:!VE(t,r),type:`button`,icon:rx,onClick:()=>n(null),title:`${W(`labels.distributeHorizontally`)} \u2014 ${X(`Alt+H`)}`,"aria-label":W(`labels.distributeHorizontally`),visible:Bi(et(e),t)})}),Y({name:`distributeVertically`,label:`labels.distributeVertically`,trackEvent:{category:`element`},perform:(e,t,n,r)=>({appState:t,elements:HE(e,t,r,{space:`between`,axis:`y`}),captureUpdate:F.IMMEDIATELY}),keyTest:e=>!e[j.CTRL_OR_CMD]&&e.altKey&&e.code===I.V,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,V.jsx)(J,{hidden:!VE(t,r),type:`button`,icon:ix,onClick:()=>n(null),title:`${W(`labels.distributeVertically`)} \u2014 ${X(`Alt+V`)}`,"aria-label":W(`labels.distributeVertically`),visible:Bi(et(e),t)})});var UE=Y({name:`flipHorizontal`,label:`labels.flipHorizontal`,icon:IS,trackEvent:{category:`element`},perform:(e,t,n,r)=>({elements:Ma(GE(e,r.scene.getNonDeletedElementsMap(),t,`horizontal`,r),t,r),appState:t,captureUpdate:F.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===I.H}),WE=Y({name:`flipVertical`,label:`labels.flipVertical`,icon:FS,trackEvent:{category:`element`},perform:(e,t,n,r)=>({elements:Ma(GE(e,r.scene.getNonDeletedElementsMap(),t,`vertical`,r),t,r),appState:t,captureUpdate:F.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===I.V&&!e[j.CTRL_OR_CMD]}),GE=(e,t,n,r,i)=>{let a=KE(xt(et(e),n,{includeBoundTextElement:!0,includeElementsInFrames:!0}),t,r,i),o=ui(a);return e.map(e=>o.get(e.id)||e)},KE=(e,t,n,r)=>{if(e.every(e=>_(e)&&(e.startBinding||e.endBinding)))return e.map(e=>{let t=e;return R(t,{startArrowhead:t.endArrowhead,endArrowhead:t.startArrowhead})});let{midX:i,midY:a}=f(e);Gi(e,t,`nw`,r.scene,new Map(Array.from(t.values()).map(e=>[e.id,ca(e)])),{flipByX:n===`horizontal`,flipByY:n===`vertical`,shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),Ur(e.filter(_),r.scene,r.state);let{elbowArrows:o,otherElements:s}=e.reduce((e,t)=>ve(t)?{...e,elbowArrows:e.elbowArrows.concat(t)}:{...e,otherElements:e.otherElements.concat(t)},{elbowArrows:[],otherElements:[]}),{midX:c,midY:l}=f(e),[u,d]=[i-c,a-l];return s.forEach(e=>r.scene.mutateElement(e,{x:e.x+u,y:e.y+d})),o.forEach(e=>r.scene.mutateElement(e,{x:e.x+u,y:e.y+d})),e},qE=Y({name:`copy`,label:`labels.copy`,icon:xb,trackEvent:{category:`element`},perform:async(e,t,n,r)=>{let i=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await JT(i,r.files,n)}catch(e){return{captureUpdate:F.EVENTUALLY,appState:{...t,errorMessage:e.message}}}return{captureUpdate:F.EVENTUALLY}},keyTest:void 0}),JE=Y({name:`paste`,label:`labels.paste`,trackEvent:{category:`element`},perform:async(e,t,n,r)=>{let i;try{i=await ZT()}catch(e){return e.name===`AbortError`||e.name===`NotAllowedError`?!1:(console.error(`actionPaste ${e.name}: ${e.message}`),Ya?{captureUpdate:F.EVENTUALLY,appState:{...t,errorMessage:W(`hints.firefox_clipboard_write`)}}:{captureUpdate:F.EVENTUALLY,appState:{...t,errorMessage:W(`errors.asyncPasteFailedOnRead`)}})}try{r.pasteFromClipboard(KT({types:i}))}catch(e){return console.error(e),{captureUpdate:F.EVENTUALLY,appState:{...t,errorMessage:W(`errors.asyncPasteFailedOnParse`)}}}return{captureUpdate:F.EVENTUALLY}},keyTest:void 0}),YE=Y({name:`cut`,label:`labels.cut`,icon:lS,trackEvent:{category:`element`},perform:(e,t,n,r)=>(qE.perform(e,t,n,r),pC.perform(e,t,null,r)),keyTest:e=>e[j.CTRL_OR_CMD]&&e.key===j.X}),XE=Y({name:`copyAsSvg`,label:`labels.copyAsSvg`,icon:zS,trackEvent:{category:`element`},perform:async(e,t,n,r)=>{if(!r.canvas)return{captureUpdate:F.EVENTUALLY};let{exportedElements:i,exportingFrame:a}=lE(e,t,!0);try{return await uE(`clipboard-svg`,i,t,r.files,{...t,exportingFrame:a,name:r.getName()}),{appState:{toast:{message:W(`toast.copyToClipboardAsSvg`,{exportSelection:r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}).length?W(`toast.selection`):W(`toast.canvas`),exportColorScheme:t.exportWithDarkMode?W(`buttons.darkMode`):W(`buttons.lightMode`)})}},captureUpdate:F.EVENTUALLY}}catch(e){return console.error(e),{appState:{errorMessage:e.message},captureUpdate:F.EVENTUALLY}}},predicate:e=>UT&&e.length>0,keywords:[`svg`,`clipboard`,`copy`]}),ZE=Y({name:`copyAsPng`,label:`labels.copyAsPng`,icon:BS,trackEvent:{category:`element`},perform:async(e,t,n,r)=>{if(!r.canvas)return{captureUpdate:F.EVENTUALLY};let i=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:a,exportingFrame:o}=lE(e,t,!0);try{return await uE(`clipboard`,a,t,r.files,{...t,exportingFrame:o,name:r.getName()}),{appState:{...t,toast:{message:W(`toast.copyToClipboardAsPng`,{exportSelection:i.length?W(`toast.selection`):W(`toast.canvas`),exportColorScheme:t.exportWithDarkMode?W(`buttons.darkMode`):W(`buttons.lightMode`)})}},captureUpdate:F.EVENTUALLY}}catch(e){return console.error(e),{appState:{...t,errorMessage:e.message},captureUpdate:F.EVENTUALLY}}},predicate:e=>WT&&e.length>0,keyTest:e=>e.code===I.C&&e.altKey&&e.shiftKey,keywords:[`png`,`clipboard`,`copy`]}),QE=Y({name:`copyText`,label:`labels.copyText`,trackEvent:{category:`element`},perform:(e,t,n,r)=>{let i=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0});try{oE(Bs(i))}catch{throw Error(W(`errors.copyToSystemClipboardFailed`))}return{captureUpdate:F.EVENTUALLY}},predicate:(e,t,n,r)=>UT&&r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0}).some(a),keywords:[`text`,`clipboard`,`copy`]}),$E=Y({name:`gridMode`,icon:GS,keywords:[`snap`],label:`labels.toggleGrid`,viewMode:!0,trackEvent:{category:`canvas`,predicate:e=>e.gridModeEnabled},perform(e,t){return{appState:{...t,gridModeEnabled:!this.checked(t),objectsSnapModeEnabled:!1},captureUpdate:F.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,t,n)=>n.gridModeEnabled===void 0,keyTest:e=>e[j.CTRL_OR_CMD]&&e.code===I.QUOTE}),eD=Y({name:`zenMode`,label:`buttons.zenMode`,icon:HS,viewMode:!0,trackEvent:{category:`canvas`,predicate:e=>!e.zenModeEnabled},perform(e,t){return{appState:{...t,zenModeEnabled:!this.checked(t)},captureUpdate:F.EVENTUALLY}},checked:e=>e.zenModeEnabled,predicate:(e,t,n,r)=>r.editorInterface.formFactor!==`phone`&&typeof n.zenModeEnabled>`u`,keyTest:e=>!e[j.CTRL_OR_CMD]&&e.altKey&&e.code===I.Z}),tD=Y({name:`objectsSnapMode`,label:`buttons.objectsSnapMode`,icon:VS,viewMode:!1,trackEvent:{category:`canvas`,predicate:e=>!e.objectsSnapModeEnabled},perform(e,t){return{appState:{...t,objectsSnapModeEnabled:!this.checked(t),gridModeEnabled:!1},captureUpdate:F.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,t,n)=>typeof n.objectsSnapModeEnabled>`u`,keyTest:e=>!e[j.CTRL_OR_CMD]&&e.altKey&&e.code===I.S}),nD=Y({name:`arrowBinding`,label:`labels.arrowBinding`,viewMode:!1,trackEvent:{category:`canvas`,predicate:e=>e.bindingPreference===`disabled`},perform(e,t){let n=t.bindingPreference===`enabled`?`disabled`:`enabled`;return{appState:{...t,bindingPreference:n,isBindingEnabled:n===`enabled`},captureUpdate:F.NEVER}},checked:e=>e.bindingPreference===`enabled`}),rD=Y({name:`midpointSnapping`,label:`labels.midpointSnapping`,viewMode:!1,trackEvent:{category:`canvas`,predicate:e=>!e.isMidpointSnappingEnabled},perform(e,t){return{appState:{...t,isMidpointSnappingEnabled:!this.checked(t)},captureUpdate:F.NEVER}},checked:e=>e.isMidpointSnappingEnabled}),iD=Y({name:`stats`,label:`stats.fullTitle`,icon:PS,viewMode:!0,trackEvent:{category:`menu`},keywords:[`edit`,`attributes`,`customize`],perform(e,t){return{appState:{...t,stats:{...t.stats,open:!this.checked(t)}},captureUpdate:F.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[j.CTRL_OR_CMD]&&e.altKey&&e.code===I.SLASH}),aD=Y({name:`unbindText`,label:`labels.unbindText`,trackEvent:{category:`element`},predicate:(e,t,n,r)=>r.scene.getSelectedElements(t).some(e=>Dr(e)),perform:(e,t,n,i)=>{let a=i.scene.getSelectedElements(t),o=i.scene.getNonDeletedElementsMap();return a.forEach(e=>{let t=Ti(e,o);if(t){let{width:n,height:a}=uo(t.originalText,tc(t),t.lineHeight),s=wc(e.id);r(e.id);let{x:c,y:l}=_i(e,t,o);i.scene.mutateElement(t,{containerId:null,width:n,height:a,text:t.originalText,x:c,y:l}),i.scene.mutateElement(e,{boundElements:e.boundElements?.filter(e=>e.id!==t.id),height:s||e.height})}}),{elements:e,appState:t,captureUpdate:F.IMMEDIATELY}}}),oD=Y({name:`bindText`,label:`labels.bindText`,trackEvent:{category:`element`},predicate:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t);if(i.length===2){let e=a(i[0])||a(i[1]),t;if(Ii(i[0])?t=i[0]:Ii(i[1])&&(t=i[1]),e&&t&&Ti(t,r.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t),o,s;a(i[0])&&Ii(i[1])?(o=i[0],s=i[1]):(o=i[1],s=i[0]),r.scene.mutateElement(o,{containerId:s.id,verticalAlign:Pn.MIDDLE,textAlign:sn.CENTER,autoResize:!0,angle:_(s)?0:s?.angle??0}),r.scene.mutateElement(s,{boundElements:(s.boundElements||[]).concat({type:`text`,id:o.id})});let c=s.height;return Sa(o,s,r.scene),vn(s.id,c),{elements:sD(e,s,o),appState:{...t,selectedElementIds:{[s.id]:!0}},captureUpdate:F.IMMEDIATELY}}}),sD=(e,t,n)=>{let r=e.slice(),i=r.findIndex(e=>e.id===n.id);r.splice(i,1);let a=r.findIndex(e=>e.id===t.id);return r.splice(a+1,0,n),Ie(r,ui([t,n])),r},cD=(e,t,n)=>{let r=e.slice(),i=r.findIndex(e=>e.id===t.id);r.splice(i,1);let a=r.findIndex(e=>e.id===n.id);return r.splice(a,0,t),Ie(r,ui([t,n])),r},lD=Y({name:`wrapTextInContainer`,label:`labels.createContainerFromText`,trackEvent:{category:`element`},predicate:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t),o=i.some(e=>a(e)&&!cs(e));return i.length>0&&o},perform:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t),o=e.slice(),s={};for(let e of i)if(a(e)&&!cs(e)){let n=pc({type:`rectangle`,backgroundColor:t.currentItemBackgroundColor,boundElements:[...e.boundElements||[],{id:e.id,type:`text`}],angle:e.angle,fillStyle:t.currentItemFillStyle,strokeColor:t.currentItemStrokeColor,roughness:t.currentItemRoughness,strokeWidth:We(`rectangle`,t.currentItemStrokeWidthKey),strokeStyle:t.currentItemStrokeStyle,roundness:t.currentItemRoundness===`round`?{type:tt(`rectangle`)?Jr.ADAPTIVE_RADIUS:Jr.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:e.x-5,y:e.y-5,width:yo(e.width,`rectangle`),height:yo(e.height,`rectangle`),groupIds:e.groupIds,frameId:e.frameId});if(e.boundElements?.length){let t=e.boundElements.filter(e=>e.type===`arrow`).map(e=>e.id);o.filter(e=>t.includes(e.id)).forEach(t=>{let i=t.startBinding,a=t.endBinding;i?.elementId===e.id&&(i={...i,elementId:n.id}),a?.elementId===e.id&&(a={...a,elementId:n.id}),(i||a)&&r.scene.mutateElement(t,{startBinding:i,endBinding:a})})}r.scene.mutateElement(e,{containerId:n.id,verticalAlign:Pn.MIDDLE,boundElements:null,textAlign:sn.CENTER,autoResize:!0}),Sa(e,n,r.scene),o=cD([...o,n],n,e),s[n.id]=!0}return{elements:o,appState:{...t,selectedElementIds:s},captureUpdate:F.IMMEDIATELY}}}),uD=380,dD=42,fD=5,pD=85,mD=500,hD=!1,gD=new Map,_D=({element:e,scene:t,setAppState:n,onLinkOpen:r,setToast:i,updateEmbedValidationStatus:a})=>{let o=t.getNonDeletedElementsMap(),s=uV(),c=aV(),l=oV(),u=e.link||``,[d,f]=(0,B.useState)(u),p=(0,B.useRef)(null),m=s.showHyperlinkPopup===`editor`,h=(0,B.useCallback)(()=>{if(!p.current)return;let r=Ts(p.current.value)||null;if(!e.link&&r&&xC(`hyperlink`,`create`),us(e)){if(s.activeEmbeddable?.element===e&&n({activeEmbeddable:null}),!r){t.mutateElement(e,{link:null}),a(e,!1);return}if(!En(r,c.validateEmbeddable))r&&i({message:W(`toast.unableToEmbed`),closable:!0}),e.link&&gD.set(e.id,e.link),t.mutateElement(e,{link:r}),a(e,!1);else{let{width:n,height:o}=e,s=zo(r);s?.error instanceof URIError&&i({message:W(`toast.unrecognizedLinkFormat`),closable:!0});let c=s?s.intrinsicSize.w/s.intrinsicSize.h:1,l=gD.get(e.id)!==e.link;t.mutateElement(e,{...l?{width:s?.type===`video`?n>o?n:o*c:n,height:s?.type===`video`&&n>o?n/c:o}:{},link:r}),a(e,!0),gD.has(e.id)&&gD.delete(e.id)}}else t.mutateElement(e,{link:r})},[e,t,i,c.validateEmbeddable,s.activeEmbeddable,n,a]);(0,B.useLayoutEffect)(()=>()=>{h()},[h]),(0,B.useEffect)(()=>{m&&p?.current&&!(l.formFactor===`phone`||l.isTouchScreen)&&p.current.select()},[m,l.formFactor,l.isTouchScreen]),(0,B.useEffect)(()=>{let t=null,r=r=>{m||(t&&clearTimeout(t),wD(e,o,s,L(r.clientX,r.clientY))&&(t=window.setTimeout(()=>{n({showHyperlinkPopup:!1})},mD)))};return window.addEventListener(T.POINTER_MOVE,r,!1),()=>{window.removeEventListener(T.POINTER_MOVE,r,!1),t&&clearTimeout(t)}},[s,e,m,n,o]);let g=(0,B.useCallback)(()=>{xC(`hyperlink`,`delete`),t.mutateElement(e,{link:null}),n({showHyperlinkPopup:!1})},[n,e,t]),_=()=>{xC(`hyperlink`,`edit`,`popup-ui`),n({showHyperlinkPopup:`editor`})},{x:v,y}=vD(e,s,o);return s.contextMenu||s.selectedElementsAreBeingDragged||s.resizingElement||s.isRotating||s.openMenu||s.viewModeEnabled?null:(0,V.jsxs)(`div`,{className:`excalidraw-hyperlinkContainer`,style:{top:`${y}px`,left:`${v}px`,width:uD,padding:fD},children:[m?(0,V.jsx)(`input`,{className:H(`excalidraw-hyperlinkContainer-input`),placeholder:W(`labels.link.hint`),ref:p,value:d,onChange:e=>f(e.target.value),autoFocus:!0,onKeyDown:e=>{e.stopPropagation(),e[j.CTRL_OR_CMD]&&e.key===j.K&&e.preventDefault(),(e.key===j.ENTER||e.key===j.ESCAPE)&&(h(),n({showHyperlinkPopup:`info`}))}}):e.link?(0,V.jsx)(`a`,{href:Ts(e.link||``),className:`excalidraw-hyperlinkContainer-link`,target:Da(e.link)?`_self`:`_blank`,onClick:t=>{if(e.link&&r){let n=Fe(T.EXCALIDRAW_LINK,t.nativeEvent);r({...e,link:Ts(e.link)},n),n.defaultPrevented&&t.preventDefault()}},rel:`noopener noreferrer`,children:e.link}):(0,V.jsx)(`div`,{className:`excalidraw-hyperlinkContainer-link`,children:W(`labels.link.empty`)}),(0,V.jsxs)(`div`,{className:`excalidraw-hyperlinkContainer__buttons`,children:[!m&&(0,V.jsx)(J,{type:`button`,title:W(`buttons.edit`),"aria-label":W(`buttons.edit`),label:W(`buttons.edit`),onClick:_,className:`excalidraw-hyperlinkContainer--edit`,icon:db}),(0,V.jsx)(J,{type:`button`,title:W(`labels.linkToElement`),"aria-label":W(`labels.linkToElement`),label:W(`labels.linkToElement`),onClick:()=>{n({openDialog:{name:`elementLinkSelector`,sourceElementId:e.id}})},icon:eC}),u&&!us(e)&&(0,V.jsx)(J,{type:`button`,title:W(`buttons.remove`),"aria-label":W(`buttons.remove`),label:W(`buttons.remove`),onClick:g,className:`excalidraw-hyperlinkContainer--remove`,icon:yb})]})]})},vD=(e,t,n)=>{let[r,i]=kc(e,n),{x:a,y:o}=Tn({sceneX:r+e.width/2,sceneY:i},t);return{x:a-t.offsetLeft-uD/2,y:o-t.offsetTop-pD}},yD=(e,t)=>{let n=xt(e,t);return us(n[0])?`labels.link.editEmbed`:n[0]?.link?`labels.link.edit`:`labels.link.create`},bD=null,xD=(e,t,n)=>{bD&&clearTimeout(bD),bD=window.setTimeout(()=>SD(e,t,n),300)},SD=(e,t,n)=>{if(!e.link)return;let r=Zw();r.classList.add(`excalidraw-tooltip--visible`),r.style.maxWidth=`20rem`,r.textContent=Ea(e.link)?W(`labels.link.goToElement`):e.link;let[i,a,o,s]=kc(e,n),[c,l,u,d]=di([i,a,o,s],e.angle,t),f=Tn({sceneX:c,sceneY:l},t);Qw(r,{left:f.x,top:f.y,width:u,height:d},`top`),xC(`hyperlink`,`tooltip`,`link-icon`),hD=!0},CD=()=>{bD&&clearTimeout(bD),hD&&(hD=!1,Zw().classList.remove(`excalidraw-tooltip--visible`))},wD=(e,t,n,[r,i])=>{let{x:a,y:o}=St({clientX:r,clientY:i},n),s=15/n.zoom.value;if(ut(L(a,o),e,t))return!1;let[c,l,u]=kc(e,t);if(a>=c&&a<=u&&o>=l-pD&&o<=l)return!1;let{x:d,y:f}=vD(e,n,t);return!(r>=d-s&&r<=d+uD+fD*2+s&&i>=f-s&&i<=f+s+fD*2+dD)},TD=Y({name:`hyperlink`,label:(e,t)=>yD(et(e),t),icon:Nb,perform:(e,t)=>t.showHyperlinkPopup!==`editor`&&{elements:e,appState:{...t,showHyperlinkPopup:`editor`,openMenu:null},captureUpdate:F.IMMEDIATELY},trackEvent:{category:`hyperlink`,action:`click`},keyTest:e=>e[j.CTRL_OR_CMD]&&e.key===j.K,predicate:(e,t)=>xt(e,t).length===1,PanelComponent:({elements:e,appState:t,updateData:n})=>{let r=xt(e,t);return(0,V.jsx)(J,{type:`toggle`,icon:Nb,"aria-label":W(yD(et(e),t)),title:`${us(e[0])?W(`labels.link.labelEmbed`):W(`labels.link.label`)} - ${X(`CtrlOrCmd+K`)}`,onSelect:()=>n(null),checked:r.length===1&&!!r[0].link})}}),ED=e=>e.every(e=>!e.locked),DD=Y({name:`toggleElementLock`,label:(e,t,n)=>ED(n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1}))?`labels.elementLock.lock`:`labels.elementLock.unlock`,icon:(e,t)=>ED(xt(t,e))?Qy:Zy,trackEvent:{category:`element`},predicate:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t);return i.length>0&&!i.some(e=>e.locked&&e.frameId)},perform:(e,t,n,r)=>{let i=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});if(!i.length)return!1;let a=ED(i),o=ui(i),s=i.length>1&&m(i),c=i.length===1||s?null:Tc(),l={...t.lockedMultiSelections};if(a)l={...t.lockedMultiSelections,...c?{[c]:!0}:{}};else if(s){let e=i[0].groupIds.at(-1);delete l[e]}let u=e.map(e=>{if(!o.has(e.id))return e;let n=e.groupIds;return a?c&&(n=[...n,c]):n=n.filter(e=>!t.lockedMultiSelections[e]),R(e,{locked:a,groupIds:n.length===e.groupIds.length?e.groupIds:n})}),d=ui(u),f=a?{}:Object.fromEntries(i.map(e=>[e.id,!0])),p=i.map(e=>d.get(e.id)||e),h=a?{}:rt(et(p),t),g=a?c||(s?i[0].groupIds.at(-1):i[0].id):null;return{elements:u,appState:{...t,selectedElementIds:f,selectedGroupIds:h,selectedLinearElement:a?null:t.selectedLinearElement,lockedMultiSelections:l,activeLockedId:g},captureUpdate:F.IMMEDIATELY}},keyTest:(e,t,n,r)=>e.key.toLocaleLowerCase()===j.L&&e[j.CTRL_OR_CMD]&&e.shiftKey&&r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1}).length>0}),OD=Y({name:`unlockAllElements`,trackEvent:{category:`canvas`},viewMode:!1,icon:Zy,predicate:(e,t)=>xt(e,t).length===0&&e.some(e=>e.locked),perform:(e,t)=>{let n=e.filter(e=>e.locked),r=e.map(e=>{if(e.locked){let n=e.groupIds.filter(e=>!t.lockedMultiSelections[e]);return R(e,{locked:!1,groupIds:e.groupIds.length===n.length?e.groupIds:n})}return e}),i=ui(r),a=n.map(e=>i.get(e.id)||e),o=et(a);return{elements:r,appState:{...t,selectedElementIds:Object.fromEntries(o.map(e=>[e.id,!0])),selectedGroupIds:rt(o,t),lockedMultiSelections:{},activeLockedId:null},captureUpdate:F.IMMEDIATELY}},label:`labels.elementLock.unlockAll`}),kD=8,AD=10,jD=[`rectangle`,`diamond`,`ellipse`],MD=[`line`,`sharpArrow`,`curvedArrow`,`elbowArrow`],ND=new Set(jD),PD=new Set(MD),FD=e=>ND.has(e),ID=e=>e===`arrow`||PD.has(e),LD=Gc(null),RD=new Map,zD=new Map,BD=({app:e})=>{let t=e.scene.getSelectedElements(e.state),n=(0,B.useRef)(null);return(0,B.useEffect)(()=>{if(t.length===0){e.updateEditorAtom(LD,null);return}let r=WD(t);r&&!n.current?n.current=r:(n.current&&!r||n.current&&r!==n.current)&&(e.updateEditorAtom(LD,null),n.current=null)},[t,e]),(0,B.useEffect)(()=>()=>{RD.clear(),zD.clear()},[]),(0,V.jsx)(VD,{app:e,elements:t})},VD=({app:e,elements:t})=>{let n=WD(t),r=(0,B.useMemo)(()=>n===`generic`?qD(t):[],[n,t]),i=(0,B.useMemo)(()=>n===`linear`?JD(t):[],[n,t]),a=n===`generic`?r.every(e=>e.type===r[0].type):n===`linear`&&i.every(e=>cc(e)===cc(i[0])),[o,s]=(0,B.useState)({x:0,y:0}),c=(0,B.useRef)(``),l=(0,B.useRef)(null);(0,B.useEffect)(()=>{let t=[...r,...i].sort((e,t)=>e.id.localeCompare(t.id)),n=`
|
|
46
|
-
${e.state.scrollX}${e.state.scrollY}${e.state.offsetTop}${e.state.offsetLeft}${e.state.zoom.value}${t.map(e=>e.id).join(`,`)}`;if(n===c.current)return;c.current=n;let a;if(t.length===1){let[n,,,r,i,o]=kc(t[0],e.scene.getNonDeletedElementsMap());a=Fs(L(n,r),L(i,o),t[0].angle)}else{let{minX:e,maxY:n}=f(t);a=L(e,n)}let{x:o,y:l}=Tn({sceneX:a[0],sceneY:a[1]},e.state);s({x:o,y:l})},[r,i,e.scene,e.state]),(0,B.useEffect)(()=>{for(let e of i){let t=KD(e.id,rO(e));zD.has(t)||zD.set(t,e)}},[i]),(0,B.useEffect)(()=>{for(let t of r)if(!RD.has(t.id)){let n=Ti(t,e.scene.getNonDeletedElementsMap());n&&RD.set(t.id,{fontSize:n.fontSize})}},[r,e.scene]);let u=n===`linear`?[[`line`,lb],[`sharpArrow`,qS],[`curvedArrow`,YS],[`elbowArrow`,JS]]:n===`generic`?[[`rectangle`,ab],[`diamond`,ob],[`ellipse`,sb]]:[];return(0,V.jsx)(`div`,{ref:l,tabIndex:-1,style:{position:`absolute`,top:`${o.y+(AD+8)*e.state.zoom.value-e.state.offsetTop}px`,left:`${o.x-e.state.offsetLeft-kD}px`,zIndex:2},className:D.CONVERT_ELEMENT_TYPE_POPUP,children:u.map(([o,s])=>{let c=a&&(n===`generic`&&r[0].type===o||n===`linear`&&cc(i[0])===o);return(0,V.jsx)(J,{type:`toggle`,icon:s,checked:c,title:o,"aria-label":o,"data-testid":`toolbar-${o}`,onSelect:()=>{c||(e.state.activeTool.type!==o&&xC(`convertElementType`,o,`ui`),UD(e,{conversionType:n,nextType:o}),l.current?.focus())}},`${t[0].id}${t[0].version}_${o}`)})})},HD=(e,t,n)=>{let r=Te(e,t),i=ms(e,t),a=qr(t.text,tc(t),r),o=uo(a,tc(t),t.lineHeight),s=t.fontSize;for(;(o.width>r||o.height>i)&&s>0;){--s;let e={...t,fontSize:s};o=uo(t.text,tc(e),t.lineHeight)}ir(t,n.getNonDeletedElementsMap(),{fontSize:s,width:o.width,height:o.height}),Sa(t,e,n)},UD=(e,{conversionType:t,nextType:n,direction:r=`right`})=>{if(!t)return!1;let i=e.scene.getSelectedElements(e.state),a=i.reduce((e,t)=>({...e,[t.id]:!0}),{}),o=r===`right`?1:-1;if(t===`generic`){let t=qD(i),r=t.every(e=>e.type===t[0].type)?jD.indexOf(t[0].type):-1;if(n??=jD[(r+jD.length+o)%jD.length],n&&FD(n)){let r={};for(let i of t){let t=tO(i,n,e);r[t.id]=t}let i=[];for(let t of e.scene.getElementsIncludingDeleted())r[t.id]?i.push(r[t.id]):i.push(t);e.scene.replaceAllElements(i);for(let t of Object.values(r)){let n=Ti(t,e.scene.getNonDeletedElementsMap());n&&(RD.get(t.id)&&ir(n,e.scene.getNonDeletedElementsMap(),{fontSize:RD.get(t.id)?.fontSize??n.fontSize}),HD(t,n,e.scene))}e.setState(e=>({selectedElementIds:a,activeTool:Pt(e,{type:`selection`})}))}}if(t===`linear`){let t=JD(i);if(!n){let e=Ko(t,cc);n=MD[((e?MD.indexOf(e):-1)+MD.length+o)%MD.length]}if(ID(n)){let r=[],i=e.scene.getElementsMapIncludingDeleted();for(let a of t){let t=zD.get(KD(a.id,n));if(t&&cc(t)===n)i.set(t.id,t),r.push(t);else{let t=tO(a,n,e);i.set(t.id,t),r.push(t)}}e.scene.replaceAllElements(i);for(let t of r)if(po(t)){if(ve(t)){let n=$D(t);if(n.length<2)continue;let r=[];for(let e=1;e<n.length-2;e++)r.push({start:n[e],end:n[e+1],index:e+1});let i=Zn(t,e.scene.getNonDeletedElementsMap(),{points:n,fixedSegments:r});ir(t,e.scene.getNonDeletedElementsMap(),{...i,endArrowhead:`arrow`})}else{let n=_a([`line`,`sharpArrow`,`curvedArrow`],e=>zD.get(KD(t.id,e)));if(n){let r=n.points;e.scene.mutateElement(t,{points:r})}}}}let r=JD(e.scene.getSelectedElements(e.state));e.setState(t=>({selectedElementIds:a,selectedLinearElement:r.length===1?new N(r[0],e.scene.getNonDeletedElementsMap()):null,activeTool:Pt(t,{type:`selection`})}))}return!0},WD=e=>{if(e.length===0)return null;let t=!1;for(let n of e){if(FD(n.type))return`generic`;GD(n)&&(t=!0)}return t?`linear`:null},GD=e=>po(e)&&(!_(e)||!Ps(e)&&!Dr(e)),KD=(e,t)=>`${e}:${t}`,qD=e=>e.filter(e=>FD(e.type)),JD=e=>e.filter(e=>GD(e)),YD=20,XD=(e,t)=>e[0]===t[0],ZD=(e,t)=>e[1]===t[1],QD=(e,t)=>XD(e,t)?Math.abs(e[1]-t[1]):Math.abs(e[0]-t[0]),$D=e=>{let t=[e.points[0]],n=eO(e.points);for(let e=1;e<n.length;++e){let r=t[t.length-1],i=[...n[e]];Math.abs(i[0]-r[0])<YD?i[0]=r[0]:Math.abs(i[1]-r[1])<YD&&(i[1]=r[1]),XD(r,i)||ZD(r,i)||t.push(L(r[0],i[1])),t.push(i)}let r=[t[0]];for(let e=1;e<t.length-1;++e)XD(t[e-1],t[e])&&XD(t[e],t[e+1])||ZD(t[e-1],t[e])&&ZD(t[e],t[e+1])||r.push(t[e]);r.push(t[t.length-1]);let i=[r[0]];for(let e=1;e<r.length-1;++e){let t=i[i.length-1],n=r[e],a=r[e+1],o=XD(t,n),s=XD(n,a);if(o!==s){let e=QD(t,n),r=QD(n,a);if(e<YD||r<YD){if(r<e)o?a[0]=t[0]:a[1]=t[1];else if(s)for(let e=i.length-1;e>=0&&i[e][0]===t[0];--e)i[e][0]=n[0];else for(let e=i.length-1;e>=0&&i[e][1]===t[1];--e)i[e][1]=n[1];continue}}i.push(n)}return i.push(r[r.length-1]),i},eO=e=>{if(e.length===0)return[];let t=[e[0]];for(let n=1;n<e.length;n++){let[r,i]=t[t.length-1],[a,o]=e[n];(r!==a||i!==o)&&t.push(e[n])}return t},tO=(e,t,n)=>{if(!nO(e.type,t)){if(!Wo())throw Error(`Invalid conversion from ${e.type} to ${t}.`);return e}if(e.type===t)return e;if(fr.delete(e),FD(t)){let r=Ue(pc({...e,type:t,roundness:e.roundness?{type:tt(t)?Jr.ADAPTIVE_RADIUS:Jr.PROPORTIONAL_RADIUS}:e.roundness}));return Dt(r,n.scene,n.state),r}if(ID(t))switch(t){case`line`:return Ue(re({...e,type:`line`}));case`sharpArrow`:return Ue(Oa({...e,type:`arrow`,elbowed:!1,roundness:null,startArrowhead:n.state.currentItemStartArrowhead,endArrowhead:n.state.currentItemEndArrowhead}));case`curvedArrow`:return Ue(Oa({...e,type:`arrow`,elbowed:!1,roundness:{type:Jr.PROPORTIONAL_RADIUS},startArrowhead:n.state.currentItemStartArrowhead,endArrowhead:n.state.currentItemEndArrowhead}));case`elbowArrow`:return Ue(Oa({...e,type:`arrow`,elbowed:!0,fixedSegments:null,roundness:null}))}return uc(t,`unhandled conversion type: ${t}`),e},nO=(e,t)=>!!(FD(e)&&FD(t)||ID(e)&&ID(t)),rO=e=>po(e)?cc(e):e.type,iO=BD,aO=Y({name:`toggleShapeSwitch`,label:`labels.shapeSwitch`,icon:()=>null,viewMode:!0,trackEvent:{category:`shape_switch`,action:`toggle`},keywords:[`change`,`switch`,`swap`],perform(e,t,n,r){return ky.set(LD,{type:`panel`}),{captureUpdate:F.NEVER}},checked:e=>e.gridModeEnabled,predicate:(e,t,n)=>WD(e)!==null}),oO=Y({name:`copyElementLink`,label:`labels.copyElementLink`,icon:cS,trackEvent:{category:`element`},perform:async(e,t,n,r)=>{let i=xt(e,t);try{if(window.location){let n=ua(i,t);return n?(await oE(r.props.generateLinkForSelection?r.props.generateLinkForSelection(n.id,n.type):ur(n.id,n.type)),{appState:{toast:{message:W(`toast.elementLinkCopied`),closable:!0}},captureUpdate:F.EVENTUALLY}):{appState:t,elements:e,app:r,captureUpdate:F.EVENTUALLY}}}catch(e){console.error(e)}return{appState:t,elements:e,app:r,captureUpdate:F.EVENTUALLY}},predicate:(e,t)=>lt(xt(e,t))}),sO=Y({name:`linkToElement`,label:`labels.linkToElement`,icon:eC,perform:(e,t,n,r)=>{let i=xt(e,t);return i.length!==1||!lt(i)?{elements:e,appState:t,app:r,captureUpdate:F.EVENTUALLY}:{appState:{...t,openDialog:{name:`elementLinkSelector`,sourceElementId:xt(e,t)[0].id}},captureUpdate:F.IMMEDIATELY}},predicate:(e,t,n,r)=>{let i=xt(e,t);return t.openDialog?.name!==`elementLinkSelector`&&i.length===1&<(i)},trackEvent:!1}),cO={toggleTheme:[X(`Shift+Alt+D`)],saveScene:[X(`CtrlOrCmd+S`)],loadScene:[X(`CtrlOrCmd+O`)],clearCanvas:[X(`CtrlOrCmd+Delete`)],imageExport:[X(`CtrlOrCmd+Shift+E`)],commandPalette:[X(`CtrlOrCmd+/`),X(`CtrlOrCmd+Shift+P`)],cut:[X(`CtrlOrCmd+X`)],copy:[X(`CtrlOrCmd+C`)],paste:[X(`CtrlOrCmd+V`)],copyStyles:[X(`CtrlOrCmd+Alt+C`)],pasteStyles:[X(`CtrlOrCmd+Alt+V`)],selectAll:[X(`CtrlOrCmd+A`)],deleteSelectedElements:[X(`Delete`)],duplicateSelection:[X(`CtrlOrCmd+D`),X(`Alt+${W(`helpDialog.drag`)}`)],sendBackward:[X(`CtrlOrCmd+[`)],bringForward:[X(`CtrlOrCmd+]`)],sendToBack:[X(_t?`CtrlOrCmd+Alt+[`:`CtrlOrCmd+Shift+[`)],bringToFront:[X(_t?`CtrlOrCmd+Alt+]`:`CtrlOrCmd+Shift+]`)],copyAsPng:[X(`Shift+Alt+C`)],group:[X(`CtrlOrCmd+G`)],ungroup:[X(`CtrlOrCmd+Shift+G`)],gridMode:[X(`CtrlOrCmd+'`)],zenMode:[X(`Alt+Z`)],objectsSnapMode:[X(`Alt+S`)],stats:[X(`Alt+/`)],addToLibrary:[],flipHorizontal:[X(`Shift+H`)],flipVertical:[X(`Shift+V`)],viewMode:[X(`Alt+R`)],hyperlink:[X(`CtrlOrCmd+K`)],toggleElementLock:[X(`CtrlOrCmd+Shift+L`)],resetZoom:[X(`CtrlOrCmd+0`)],zoomOut:[X(`CtrlOrCmd+-`)],zoomIn:[X(`CtrlOrCmd++`)],zoomToFitSelection:[X(`Shift+3`)],zoomToFit:[X(`Shift+1`)],zoomToFitSelectionInViewport:[X(`Shift+2`)],saveFileToDisk:[X(`CtrlOrCmd+S`)],saveToActiveFile:[X(`CtrlOrCmd+S`)],toggleShortcuts:[X(`?`)],searchMenu:[X(`CtrlOrCmd+F`)],wrapSelectionInFrame:[],toolLock:[X(`Q`)]},lO=(e,t=0)=>{let n=cO[e];return n&&n.length>0?n[t]||n[0]:``},uO=RegExp(`[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]`,`g`),dO=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,fO={À:`A`,Á:`A`,Â:`A`,Ã:`A`,Ä:`A`,Å:`A`,à:`a`,á:`a`,â:`a`,ã:`a`,ä:`a`,å:`a`,Ç:`C`,ç:`c`,Ð:`D`,ð:`d`,È:`E`,É:`E`,Ê:`E`,Ë:`E`,è:`e`,é:`e`,ê:`e`,ë:`e`,Ì:`I`,Í:`I`,Î:`I`,Ï:`I`,ì:`i`,í:`i`,î:`i`,ï:`i`,Ñ:`N`,ñ:`n`,Ò:`O`,Ó:`O`,Ô:`O`,Õ:`O`,Ö:`O`,Ø:`O`,ò:`o`,ó:`o`,ô:`o`,õ:`o`,ö:`o`,ø:`o`,Ù:`U`,Ú:`U`,Û:`U`,Ü:`U`,ù:`u`,ú:`u`,û:`u`,ü:`u`,Ý:`Y`,ý:`y`,ÿ:`y`,Æ:`E`,æ:`e`,Þ:`T`,þ:`t`,ß:`s`,Ā:`A`,Ă:`A`,Ą:`A`,ā:`a`,ă:`a`,ą:`a`,Ć:`C`,Ĉ:`C`,Ċ:`C`,Č:`C`,ć:`c`,ĉ:`c`,ċ:`c`,č:`c`,Ď:`D`,Đ:`D`,ď:`d`,đ:`d`,Ē:`E`,Ĕ:`E`,Ė:`E`,Ę:`E`,Ě:`E`,ē:`e`,ĕ:`e`,ė:`e`,ę:`e`,ě:`e`,Ĝ:`G`,Ğ:`G`,Ġ:`G`,Ģ:`G`,ĝ:`g`,ğ:`g`,ġ:`g`,ģ:`g`,Ĥ:`H`,Ħ:`H`,ĥ:`h`,ħ:`h`,Ĩ:`I`,Ī:`I`,Ĭ:`I`,Į:`I`,İ:`I`,ĩ:`i`,ī:`i`,ĭ:`i`,į:`i`,ı:`i`,Ĵ:`J`,ĵ:`j`,Ķ:`K`,ķ:`k`,ĸ:`k`,Ĺ:`L`,Ļ:`L`,Ľ:`L`,Ŀ:`L`,Ł:`L`,ĺ:`l`,ļ:`l`,ľ:`l`,ŀ:`l`,ł:`l`,Ń:`N`,Ņ:`N`,Ň:`N`,Ŋ:`N`,ń:`n`,ņ:`n`,ň:`n`,ŋ:`n`,Ō:`O`,Ŏ:`O`,Ő:`O`,ō:`o`,ŏ:`o`,ő:`o`,Ŕ:`R`,Ŗ:`R`,Ř:`R`,ŕ:`r`,ŗ:`r`,ř:`r`,Ś:`S`,Ŝ:`S`,Ş:`S`,Š:`S`,ś:`s`,ŝ:`s`,ş:`s`,š:`s`,Ţ:`T`,Ť:`T`,Ŧ:`T`,ţ:`t`,ť:`t`,ŧ:`t`,Ũ:`U`,Ū:`U`,Ŭ:`U`,Ů:`U`,Ű:`U`,Ų:`U`,ũ:`u`,ū:`u`,ŭ:`u`,ů:`u`,ű:`u`,ų:`u`,Ŵ:`W`,ŵ:`w`,Ŷ:`Y`,ŷ:`y`,Ÿ:`Y`,Ź:`Z`,Ż:`Z`,Ž:`Z`,ź:`z`,ż:`z`,ž:`z`,IJ:`I`,ij:`i`,Œ:`E`,œ:`e`,ʼn:`n`,ſ:`s`},pO=e=>e.replace(dO,e=>fO[e]||e).replace(uO,``),mO=()=>{let[e,t]=(0,B.useState)(null);return[e,(0,B.useCallback)(e=>t(e),[])]},hO=({elements:e,appState:t,files:n,maxWidthOrHeight:r,getDimensions:i,exportPadding:a,exportingFrame:o})=>{let s=et(Xt(e,null,{deleteInvisibleElements:!0})),c=we(t,null),{exportBackground:l,viewBackgroundColor:u}=c;return fs(s,{...c,offsetTop:0,offsetLeft:0,width:0,height:0},n||{},{exportBackground:l,exportPadding:a,viewBackgroundColor:u,exportingFrame:o},(e,n)=>{let a=document.createElement(`canvas`);if(r){typeof i==`function`&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");let o=Math.max(e,n),s=r<o?r/o:t?.exportScale??1;return a.width=e*s,a.height=n*s,{canvas:a,scale:s}}let o=i?.(e,n)||{width:e,height:n};return a.width=o.width,a.height=o.height,{canvas:a,scale:o.scale??1}})},gO=async e=>{let{mimeType:t=M.png,quality:n}=e;t===M.png&&typeof n==`number`&&console.warn(`"quality" will be ignored for "${M.png}" mimeType`),t===`image/jpg`&&(t=M.jpg),t===M.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${M.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let r=await hO(e);return n||=/image\/jpe?g/.test(t)?.92:.8,new Promise((i,a)=>{r.toBlob(async n=>{if(!n)return a(Error(`couldn't export to blob`));n&&t===M.png&&e.appState?.exportEmbedScene&&(n=await He({blob:n,metadata:Xs(e.elements,e.appState,e.files||{},`local`)})),i(n)},t,n)})},_O=async({elements:e,appState:t=ht(),files:n={},exportPadding:r,renderEmbeddables:i,exportingFrame:a,skipInliningFonts:o,reuseImages:s})=>{let c=et(Xt(e,null,{deleteInvisibleElements:!0})),l={...we(t,null),exportPadding:r};return Ne(c,l,n,{exportingFrame:a,renderEmbeddables:i,skipInliningFonts:o,reuseImages:s})},vO=async e=>{if(e.type===`svg`)await oE((await _O(e)).outerHTML);else if(e.type===`png`)await aE(gO(e));else if(e.type===`json`)await JT(e.elements,e.files);else throw Error(`Invalid export type`)},yO=Gc(new Map),bO=async e=>await _O({elements:e,appState:{exportBackground:!1,viewBackgroundColor:Ye.white},files:null,renderEmbeddables:!1,skipInliningFonts:!0}),xO=(e,t,n,r)=>{let[i,a]=(0,B.useState)();return(0,B.useEffect)(()=>{if(t){if(e){let r=n.get(e);r?a(r):(async()=>{let r=await bO(t);r.querySelector(`.style-fonts`)?.remove(),r&&(n.set(e,r),a(r))})()}else(async()=>{let e=await bO(t);a(e)})()}},[e,t,n,a]),(0,B.useEffect)(()=>{let e=r.current;if(e)return i&&(e.innerHTML=i.outerHTML),()=>{e.innerHTML=``}},[i,r]),i},SO=()=>{let[e]=wy(yO);return{clearLibraryCache:()=>e.clear(),deleteItemsFromLibraryCache:t=>{t.forEach(t=>e.delete(t))},svgCache:e}},CO=[`excalidraw.com`,`raw.githubusercontent.com/excalidraw/excalidraw-libraries`],wO=new Rn,TO=Gc({status:`loaded`,isInitialized:!1,libraryItems:[]}),EO=e=>ta(e),DO=(e,t)=>!e.find(e=>e.elements.length===t.elements.length&&e.elements.every((e,n)=>e.id===t.elements[n].id&&e.versionNonce===t.elements[n].versionNonce)),OO=(e,t)=>{let n=[];for(let r of t)DO(e,r)&&n.push(r);return[...n,...e]},kO=(e,t)=>{let n=ui(t),r={deletedItems:new Map,addedItems:new Map,updatedItems:new Map};for(let t of e)n.has(t.id)||r.deletedItems.set(t.id,t);let i=ui(e);for(let e of t){let t=i.get(e.id);t?RO(t)!==RO(e)&&r.updatedItems.set(e.id,e):r.addedItems.set(e.id,e)}return r},AO=class{constructor(e){z(this,`currLibraryItems`,[]),z(this,`prevLibraryItems`,EO(this.currLibraryItems)),z(this,`app`),z(this,`updateQueue`,[]),z(this,`getLastUpdateTask`,()=>this.updateQueue[this.updateQueue.length-1]),z(this,`notifyListeners`,()=>{if(this.updateQueue.length>0)ky.set(TO,e=>({status:`loading`,libraryItems:this.currLibraryItems,isInitialized:e.isInitialized}));else{ky.set(TO,{status:`loaded`,libraryItems:this.currLibraryItems,isInitialized:!0});try{let e=this.prevLibraryItems;this.prevLibraryItems=EO(this.currLibraryItems);let t=EO(this.currLibraryItems);this.app.props.onLibraryChange?.(t),wO.trigger(kO(e,t),t)}catch(e){console.error(e)}}}),z(this,`destroy`,()=>{this.updateQueue=[],this.currLibraryItems=[],ky.set(yO,new Map)}),z(this,`resetLibrary`,()=>this.setLibrary([])),z(this,`getLatestLibrary`,()=>new Promise(async e=>{try{let t=await(this.getLastUpdateTask()||this.currLibraryItems);this.updateQueue.length>0?e(this.getLatestLibrary()):e(EO(t))}catch{return e(this.currLibraryItems)}})),z(this,`updateLibrary`,async({libraryItems:e,prompt:t=!1,merge:n=!1,openLibraryMenu:r=!1,defaultStatus:i=`unpublished`})=>(r&&this.app.setState({openSidebar:{name:bo.name,tab:`library`}}),this.setLibrary(()=>new Promise(async(r,a)=>{try{let o=await(typeof e==`function`&&!(e instanceof Blob)?e(this.currLibraryItems):e),s;s=o instanceof Blob?await Si(o,i):Pa(o,i),!t||window.confirm(W(`alerts.confirmAddLibrary`,{numShapes:s.length}))?(t&&this.app.focusContainer(),r(n?OO(this.currLibraryItems,s):s)):a(new Cn)}catch(e){a(e)}})))),z(this,`setLibrary`,e=>{let t=new Promise(async(t,n)=>{try{await this.getLastUpdateTask(),typeof e==`function`&&(e=e(this.currLibraryItems)),this.currLibraryItems=EO(await e),t(this.currLibraryItems)}catch(e){n(e)}}).catch(e=>{if(e.name===`AbortError`)return console.warn(`Library update aborted by user`),this.currLibraryItems;throw e}).finally(()=>{this.updateQueue=this.updateQueue.filter(e=>e!==t),this.notifyListeners()});return this.updateQueue.push(t),this.notifyListeners(),t}),this.app=e}},jO=e=>{let t=Math.ceil(Math.sqrt(e.length)),n=[],r=n=>e.slice(n*t,n*t+t).reduce((e,t)=>{let{height:n}=f(t.elements);return Math.max(e,n)},0),i=n=>{let r=0,i=0,a=0;for(let o of e){if(r%t===0&&(i=0),i===n){let{width:e}=f(o.elements);a=Math.max(a,e)}r++,i++}return a},a=0,o=0,s=0,c=0,l=0,u=0,d=0;for(let p of e){l&&l%t===0&&(o+=s+50,a=0,u=0,d++),u===0&&(s=r(d)),c=i(u);let{minX:e,minY:m,width:h,height:g}=f(p.elements),_=(c-h)/2,v=(s-g)/2;n.push(...p.elements.map(t=>({...t,x:t.x+a+_-e,y:t.y+o+v-m}))),a+=c+50,l++,u++}return n},MO=(e,t=CO)=>{if(typeof t==`function`?t(e):t.some(t=>{let n=new URL(`https://${t.replace(/^https?:\/\//,``)}`),{hostname:r,pathname:i}=new URL(e);return RegExp(`(^|\\.)${n.hostname}$`).test(r)&&RegExp(`^${n.pathname.replace(/\/+$/,``)}(/+|$)`).test(i)}))return!0;throw Error(`Invalid or disallowed library URL: "${e}"`)},NO=()=>{let e=new URLSearchParams(window.location.hash.slice(1)).get(xc.addLibrary)||new URLSearchParams(window.location.search).get(un.addLibrary),t=e?new URLSearchParams(window.location.hash.slice(1)).get(`token`):null;return e?{libraryUrl:e,idToken:t}:null},PO=class e{constructor(e){z(this,`adapter`),this.adapter=e}static async getLibraryItems(t,n,r=!0){let i=()=>new Promise(async(e,r)=>{try{let r=await t.load({source:n});e(Pa(r?.libraryItems||[],`published`))}catch(e){r(e)}});return r?e.queue.push(i):i()}getLibraryItems(t){return e.getLibraryItems(this.adapter,t,!1)}};z(PO,`queue`,new Va),z(PO,`run`,async(e,t)=>{let n=new PO(e);return PO.queue.push(()=>t(n))});var FO=PO,IO=0,LO=0,RO=e=>`${e.id}:${e.name||``}:${Zr(e.elements)}`,zO=e=>ri(e.map(e=>RO(e)).sort().join()),BO=async(e,t)=>{try{return LO++,await FO.run(e,async n=>{let r=ui(await n.getLibraryItems(`save`));for(let[e]of t.deletedItems)r.delete(e);let i=[];for(let[e,n]of t.addedItems)r.has(e)?r.set(e,n):i.push(n);if(t.updatedItems)for(let[e,n]of t.updatedItems)r.set(e,n);let a=i.concat(Array.from(r.values())),o=zO(a);return o!==IO&&await e.save({libraryItems:a}),IO=o,a})}finally{LO--}},VO=e=>{let{excalidrawAPI:t}=e,n=(0,B.useRef)(e);n.current=e;let r=(0,B.useRef)(!1);(0,B.useEffect)(()=>{if(!t)return;r.current=!1;let e=async({libraryUrl:e,idToken:r})=>{let i=new Promise(async(t,r)=>{try{e=decodeURIComponent(e),e=sa(e),MO(e,n.current.validateLibraryUrl),t(await(await fetch(e)).blob())}catch(e){r(e)}}),a=r!==t.id;await(a&&document.hidden?new Promise(e=>{window.addEventListener(`focus`,()=>e(),{once:!0})}):null);try{await t.updateLibrary({libraryItems:i,prompt:a,merge:!0,defaultStatus:`published`,openLibraryMenu:!0})}catch(e){throw t.updateScene({appState:{errorMessage:e.message}}),e}finally{if(window.location.hash.includes(xc.addLibrary)){let e=new URLSearchParams(window.location.hash.slice(1));e.delete(xc.addLibrary),window.history.replaceState({},Ao,`#${e.toString()}`)}else if(window.location.search.includes(un.addLibrary)){let e=new URLSearchParams(window.location.search);e.delete(un.addLibrary),window.history.replaceState({},Ao,`?${e.toString()}`)}}},i=t=>{t.preventDefault();let n=NO();n&&(t.stopImmediatePropagation(),window.history.replaceState({},``,t.oldURL),e(n))},a=NO();if(a&&e(a),`getInitialLibraryItems`in n.current&&n.current.getInitialLibraryItems&&(console.warn("useHandleLibrar `opts.getInitialLibraryItems` is deprecated. Use `opts.adapter` instead."),Promise.resolve(n.current.getInitialLibraryItems()).then(e=>{t.updateLibrary({libraryItems:e,merge:!0})}).catch(e=>{console.error(`UseHandeLibrary getInitialLibraryItems failed: ${e?.message}`)})),`adapter`in n.current&&n.current.adapter){let e=n.current.adapter,i=n.current.migrationAdapter,a=Mr();i?a.resolve(Po(i.load).then(async t=>{let n=null;try{if(!t)return FO.getLibraryItems(e,`load`);n=Pa(t.libraryItems||[],`published`);let r=await BO(e,kO([],n));try{await i.clear()}catch(e){console.error(`couldn't delete legacy library data: ${e.message}`)}return r}catch(e){return console.error(`couldn't migrate legacy library data: ${e.message}`),n}}).catch(t=>(console.error(`error during library migration: ${t.message}`),FO.getLibraryItems(e,`load`)))):a.resolve(Po(FO.getLibraryItems,e,`load`)),t.updateLibrary({libraryItems:a.then(e=>{let t=e||[];return IO=zO(t),t}),merge:!0}).finally(()=>{r.current=!0})}return window.addEventListener(T.HASHCHANGE,i),()=>{window.removeEventListener(T.HASHCHANGE,i)}},[t]),(0,B.useEffect)(()=>{let e=wO.on(async(e,t)=>{let i=r.current,a=`adapter`in n.current&&n.current.adapter||null;try{a&&IO!==zO(t)&&await BO(a,e)}catch(t){console.error(`couldn't persist library update: ${t.message}`,e),i&&n.current.excalidrawAPI&&n.current.excalidrawAPI.updateScene({appState:{errorMessage:W(`errors.saveLibraryError`)}})}}),t=e=>{LO&&Hi(e)};return window.addEventListener(T.BEFORE_UNLOAD,t),()=>{window.removeEventListener(T.BEFORE_UNLOAD,t),e(),IO=0,LO=0}},[])},HO=({theme:e,id:t,libraryReturnUrl:n})=>{let r=n||window.location.origin+window.location.pathname;return(0,V.jsx)(`a`,{className:`library-menu-browse-button`,href:`${ne.VITE_APP_LIBRARY_URL}?target=${window.name||`_blank`}&referrer=${r}&useHash=true&token=${t}&theme=${e}&version=${qi.excalidrawLibrary}`,target:`_excalidraw_libraries`,children:W(`labels.libraries`)})},UO=({libraryReturnUrl:e,theme:t,id:n,style:r,children:i,className:a})=>(0,V.jsxs)(`div`,{className:H(`library-menu-control-buttons`,a),style:r,children:[(0,V.jsx)(HO,{id:n,libraryReturnUrl:e,theme:t}),i]}),WO=Gc(0),GO=e=>{let[t,n]=wy(WO);return(0,B.useEffect)(()=>{let{current:t}=e;if(!t)return;let r=(0,Hc.default)(()=>{let{scrollTop:e}=t;n(e)},200);return t.addEventListener(`scroll`,r),()=>{r.cancel(),t.removeEventListener(`scroll`,r)}},[e,n]),t},KO=({label:e,onClick:t,className:n,children:r,actionType:i,type:a=`button`,isLoading:o,...s})=>{let c=i?`Dialog__action-button--${i}`:``;return(0,V.jsxs)(`button`,{className:H(`Dialog__action-button`,c,n),type:a,"aria-label":e,onClick:t,...s,children:[r&&(0,V.jsx)(`div`,{style:o?{visibility:`hidden`}:{},children:r}),(0,V.jsx)(`div`,{style:o?{visibility:`hidden`}:{},children:e}),o&&(0,V.jsx)(`div`,{style:{position:`absolute`,inset:0},children:(0,V.jsx)(lC,{})})]})},qO=e=>{let{onConfirm:t,onCancel:n,children:r,confirmText:i=W(`buttons.confirm`),cancelText:a=W(`buttons.cancel`),className:o=``,...s}=e,c=dV(),l=Ty(Uk),{container:u}=cV();return(0,V.jsxs)(Zk,{onCloseRequest:n,size:`small`,...s,className:`confirm-dialog ${o}`,children:[r,(0,V.jsxs)(`div`,{className:`confirm-dialog-buttons`,children:[(0,V.jsx)(KO,{label:a,onClick:()=>{c({openMenu:null}),l(!1),(0,Uc.flushSync)(()=>{n()}),u?.focus()}}),(0,V.jsx)(KO,{label:i,onClick:()=>{c({openMenu:null}),l(!1),(0,Uc.flushSync)(()=>{t()}),u?.focus()},actionType:`danger`})]})]})},JO=class{static has(e){try{return!!window.localStorage.getItem(e)}catch(e){return console.warn(`localStorage.getItem error: ${e.message}`),!1}}static get(e){try{let t=window.localStorage.getItem(e);return t?JSON.parse(t):null}catch(e){return console.warn(`localStorage.getItem error: ${e.message}`),null}}};z(JO,`set`,(e,t)=>{try{return window.localStorage.setItem(e,JSON.stringify(t)),!0}catch(e){return console.warn(`localStorage.setItem error: ${e.message}`),!1}}),z(JO,`delete`,e=>{try{window.localStorage.removeItem(e)}catch(e){console.warn(`localStorage.removeItem error: ${e.message}`)}});var YO=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,XO=/{{([\w-]+)}}/,ZO=/<([\w-]+)>/,QO=/<\/([\w-]+)>/,$O=(e,t)=>{let n=[{name:``,children:[]}];return e.split(YO).filter(Boolean).forEach(r=>{let i=r.match(ZO),a=r.match(QO),o=r.match(XO);if(i!==null){let r=i[1];t.hasOwnProperty(r)?n.push({name:r,children:[]}):console.warn(`Trans: missed to pass in prop ${r} for interpolating ${e}`)}else if(a!==null){if(a[1]===n[n.length-1].name){let e=n.pop(),r=B.createElement(B.Fragment,{},...e.children),i=t[e.name];typeof i==`function`&&n[n.length-1].children.push(i(r))}else console.warn(`Trans: unexpected end tag ${r} for interpolating ${e}`)}else if(o!==null){let r=o[1];t.hasOwnProperty(r)?n[n.length-1].children.push(t[r]):console.warn(`Trans: key ${r} not in props for interpolating ${e}`)}else n[n.length-1].children.push(r)}),n.length!==1&&console.warn(`Trans: stack not empty for interpolating ${e}`),n[0].children},ek=({i18nKey:e,children:t,...n})=>{let{t:r}=Vy();return B.createElement(B.Fragment,{},...$O(r(e),n))},tk=async e=>{let t=nn(e,6),n=document.createElement(`canvas`);n.width=t[0].length*128+(t[0].length+1)*16-16,n.height=t.length*128+(t.length+1)*16-16;let r=n.getContext(`2d`);r.fillStyle=`#fff`,r.fillRect(0,0,n.width,n.height);for(let[t,n]of e.entries()){let e=await hO({elements:n.elements,files:null,maxWidthOrHeight:128}),{width:i,height:a}=e,o=Math.floor(t/6)*144,s=t%6*144;r.drawImage(e,s+(128-i)/2+8,o+(128-a)/2+8),r.lineWidth=2,r.strokeStyle=`#ced4da`,r.strokeRect(s+4,o+4,136,136)}return await Lo(new File([await vo(n)],`preview`,{type:M.png}),{outputType:M.jpg,maxWidthOrHeight:5e3})},nk=({libItem:e,appState:t,index:n,onChange:r,onRemove:i})=>{let a=(0,B.useRef)(null),o=(0,B.useRef)(null);return(0,B.useEffect)(()=>{let n=a.current;n&&(async()=>{let r=await _O({elements:e.elements,appState:{...t,viewBackgroundColor:`#fff`,exportBackground:!0},files:null,skipInliningFonts:!0});n.innerHTML=r.outerHTML})()},[e.elements,t]),(0,V.jsxs)(`div`,{className:`single-library-item`,children:[e.status===`published`&&(0,V.jsx)(`span`,{className:`single-library-item-status`,children:W(`labels.statusPublished`)}),(0,V.jsx)(`div`,{ref:a,className:`single-library-item__svg`}),(0,V.jsx)(J,{"aria-label":W(`buttons.remove`),type:`button`,icon:lx,className:`single-library-item--remove`,onClick:i.bind(null,e.id),title:W(`buttons.remove`)}),(0,V.jsxs)(`div`,{style:{display:`flex`,margin:`0.8rem 0`,width:`100%`,fontSize:`14px`,fontWeight:500,flexDirection:`column`},children:[(0,V.jsxs)(`label`,{style:{display:`flex`,justifyContent:`space-between`,flexDirection:`column`},children:[(0,V.jsxs)(`div`,{style:{padding:`0.5em 0`},children:[(0,V.jsx)(`span`,{style:{fontWeight:500,color:`#868e96`},children:W(`publishDialog.itemName`)}),(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`required`,children:`*`})]}),(0,V.jsx)(`input`,{type:`text`,ref:o,style:{width:`80%`,padding:`0.2rem`},defaultValue:e.name,placeholder:`Item name`,onChange:e=>{r(e.target.value,n)}})]}),(0,V.jsx)(`span`,{className:`error`,children:e.error})]})]})},rk=({onClose:e,libraryItems:t,appState:n,onSuccess:r,onError:i,updateItemsInStorage:a,onRemove:o})=>{let[s,c]=(0,B.useState)({authorName:``,githubHandle:``,name:``,description:``,twitterHandle:``,website:``}),[l,u]=(0,B.useState)(!1);(0,B.useEffect)(()=>{let e=JO.get(Io.PUBLISH_LIBRARY);e&&c(e)},[]);let[d,f]=(0,B.useState)(t.slice());(0,B.useEffect)(()=>{f(t.slice())},[t]);let p=e=>{c({...s,[e.target.name]:e.target.value})},m=async e=>{e.preventDefault(),u(!0);let t=[],n=!1;if(d.forEach(e=>{let r=``;e.name||(r=W(`publishDialog.errors.required`),n=!0),t.push({...e,error:r})}),n){f(t),u(!1);return}let a=await tk(d),o={type:Oc.excalidrawLibrary,version:qi.excalidrawLibrary,source:Er(),libraryItems:d},c=JSON.stringify(o,null,2),l=new Blob([c],{type:`application/json`}),p=new FormData;p.append(`excalidrawLib`,l),p.append(`previewImage`,a),p.append(`previewImageType`,a.type),p.append(`title`,s.name),p.append(`authorName`,s.authorName),p.append(`githubHandle`,s.githubHandle),p.append(`name`,s.name),p.append(`description`,s.description),p.append(`twitterHandle`,s.twitterHandle),p.append(`website`,s.website),fetch(`${ne.VITE_APP_LIBRARY_BACKEND}/submit`,{method:`post`,body:p}).then(e=>e.ok?e.json().then(({url:e})=>{JO.delete(Io.PUBLISH_LIBRARY),r({url:e,authorName:s.authorName,items:d})}):e.json().catch(()=>{throw Error(e.statusText||`something went wrong`)}).then(t=>{throw Error(t.message||e.statusText||`something went wrong`)}),e=>{console.error(e),i(e),u(!1)}).catch(e=>{console.error(e),i(e),u(!1)})},h=()=>{let e=[];return d.forEach((t,r)=>{e.push((0,V.jsx)(`div`,{className:`single-library-item-wrapper`,children:(0,V.jsx)(nk,{libItem:t,appState:n,index:r,onChange:(e,t)=>{let n=d.slice();n[t].name=e,f(n)},onRemove:o})},r))}),(0,V.jsx)(`div`,{className:`selected-library-items`,children:e})},g=(0,B.useCallback)(()=>{a(d),JO.set(Io.PUBLISH_LIBRARY,s),e()},[d,e,a,s]),_=!!t.length,v=t.some(e=>e.status===`published`);return(0,V.jsx)(Zk,{onCloseRequest:g,title:W(`publishDialog.title`),className:`publish-library`,children:_?(0,V.jsxs)(`form`,{onSubmit:m,children:[(0,V.jsx)(`div`,{className:`publish-library-note`,children:(0,V.jsx)(ek,{i18nKey:`publishDialog.noteDescription`,link:e=>(0,V.jsx)(`a`,{href:`https://libraries.excalidraw.com`,target:`_blank`,rel:`noopener`,children:e})})}),(0,V.jsx)(`span`,{className:`publish-library-note`,children:(0,V.jsx)(ek,{i18nKey:`publishDialog.noteGuidelines`,link:e=>(0,V.jsx)(`a`,{href:`https://github.com/excalidraw/excalidraw-libraries#guidelines`,target:`_blank`,rel:`noopener noreferrer`,children:e})})}),(0,V.jsx)(`div`,{className:`publish-library-note`,children:W(`publishDialog.noteItems`)}),v&&(0,V.jsx)(`span`,{className:`publish-library-note publish-library-warning`,children:W(`publishDialog.republishWarning`)}),h(),(0,V.jsxs)(`div`,{className:`publish-library__fields`,children:[(0,V.jsxs)(`label`,{children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{children:W(`publishDialog.libraryName`)}),(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`required`,children:`*`})]}),(0,V.jsx)(`input`,{type:`text`,name:`name`,required:!0,value:s.name,onChange:p,placeholder:W(`publishDialog.placeholder.libraryName`)})]}),(0,V.jsxs)(`label`,{style:{alignItems:`flex-start`},children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{children:W(`publishDialog.libraryDesc`)}),(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`required`,children:`*`})]}),(0,V.jsx)(`textarea`,{name:`description`,rows:4,required:!0,value:s.description,onChange:p,placeholder:W(`publishDialog.placeholder.libraryDesc`)})]}),(0,V.jsxs)(`label`,{children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{children:W(`publishDialog.authorName`)}),(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`required`,children:`*`})]}),(0,V.jsx)(`input`,{type:`text`,name:`authorName`,required:!0,value:s.authorName,onChange:p,placeholder:W(`publishDialog.placeholder.authorName`)})]}),(0,V.jsxs)(`label`,{children:[(0,V.jsx)(`span`,{children:W(`publishDialog.githubUsername`)}),(0,V.jsx)(`input`,{type:`text`,name:`githubHandle`,value:s.githubHandle,onChange:p,placeholder:W(`publishDialog.placeholder.githubHandle`)})]}),(0,V.jsxs)(`label`,{children:[(0,V.jsx)(`span`,{children:W(`publishDialog.twitterUsername`)}),(0,V.jsx)(`input`,{type:`text`,name:`twitterHandle`,value:s.twitterHandle,onChange:p,placeholder:W(`publishDialog.placeholder.twitterHandle`)})]}),(0,V.jsxs)(`label`,{children:[(0,V.jsx)(`span`,{children:W(`publishDialog.website`)}),(0,V.jsx)(`input`,{type:`text`,name:`website`,pattern:`https?://.+`,title:W(`publishDialog.errors.website`),value:s.website,onChange:p,placeholder:W(`publishDialog.placeholder.website`)})]}),(0,V.jsx)(`span`,{className:`publish-library-note`,children:(0,V.jsx)(ek,{i18nKey:`publishDialog.noteLicense`,link:e=>(0,V.jsx)(`a`,{href:`https://github.com/excalidraw/excalidraw-libraries/blob/main/LICENSE`,target:`_blank`,rel:`noopener noreferrer`,children:e})})})]}),(0,V.jsxs)(`div`,{className:`publish-library__buttons`,children:[(0,V.jsx)(KO,{label:W(`buttons.saveLibNames`),onClick:g,"data-testid":`cancel-clear-canvas-button`}),(0,V.jsx)(KO,{type:`submit`,label:W(`buttons.submit`),actionType:`primary`,isLoading:l})]})]}):(0,V.jsx)(`p`,{style:{padding:`1em`,textAlign:`center`,fontWeight:500},children:W(`publishDialog.atleastOneLibItem`)})})},ik={Row:(0,B.forwardRef)(({children:e,gap:t,align:n,justifyContent:r,className:i,style:a},o)=>(0,V.jsx)(`div`,{className:H(`Stack Stack_horizontal`,i),style:{"--gap":t,alignItems:n,justifyContent:r,...a},ref:o,children:e})),Col:(0,B.forwardRef)(({children:e,gap:t,align:n,justifyContent:r,className:i,style:a},o)=>(0,V.jsx)(`div`,{className:H(`Stack Stack_vertical`,i),style:{"--gap":t,justifyItems:n,justifyContent:r,...a},ref:o,children:e}))},ak=({children:e,onClickOutside:t,className:n=``,onSelect:r,open:i=!0,align:a=`end`,style:o})=>{let s=oV(),c=(0,B.useRef)(null),l=kC({onClickOutside:t});OC(c,(0,B.useCallback)(e=>{c.current?.closest(`.${D.DROPDOWN_MENU_EVENT_WRAPPER}`)?.contains(e.target)||l.onClickOutside?.()},[l])),(0,B.useEffect)(()=>{if(!i)return;let e=e=>{e.key===j.ESCAPE&&(e.preventDefault(),e.stopImmediatePropagation(),l.onClickOutside?.())},t={capture:!0};return document.addEventListener(T.KEYDOWN,e,t),()=>{document.removeEventListener(T.KEYDOWN,e,t)}},[l,i]);let u=H(`dropdown-menu ${n}`,{"dropdown-menu--mobile":s.formFactor===`phone`}).trim();return(0,V.jsx)(dw.Provider,{value:{onSelect:r},children:(0,V.jsx)(j_,{ref:c,className:u,style:o,"data-testid":`dropdown-menu`,align:a,sideOffset:8,onCloseAutoFocus:e=>e.preventDefault(),children:s.formFactor===`phone`?(0,V.jsx)(ik.Col,{className:`dropdown-menu-container`,children:e}):(0,V.jsx)(PC,{className:`dropdown-menu-container`,padding:2,children:e})})})};ak.displayName=`DropdownMenuContent`;var ok=ak,sk=({children:e,className:t=``,selected:n,...r})=>(0,V.jsx)(`div`,{...r,className:`dropdown-menu-item-base dropdown-menu-item-custom ${t} ${n?`dropdown-menu-item--selected`:``}`.trim(),children:e}),ck=({icon:e,shortcut:t,href:n,children:r,onSelect:i,className:a=``,selected:o,rel:s=`noopener`,...c})=>{let l=pw(i);return(0,V.jsx)(M_,{className:`radix-menu-item`,onSelect:l,asChild:!0,children:(0,V.jsx)(`a`,{...c,href:n,target:`_blank`,rel:`noopener ${s}`,className:fw(a,o),title:c.title??c[`aria-label`],children:(0,V.jsx)(hw,{icon:e,shortcut:t,children:r})})})},lk=ck;ck.displayName=`DropdownMenuItemLink`;var uk=()=>(0,V.jsx)(`div`,{style:{height:`1px`,backgroundColor:`var(--default-border-color)`,margin:`6px 0`,flex:`0 0 auto`}}),dk=uk;uk.displayName=`DropdownMenuSeparator`;var fk=-4,pk=4,mk=({children:e,className:t})=>{let n=oV(),r=H(`dropdown-menu dropdown-submenu ${t}`,{"dropdown-menu--mobile":n.formFactor===`phone`}).trim(),i=(0,B.useCallback)(e=>{if(e){let t=e.closest(`.dropdown-menu-container`)?.getBoundingClientRect();if(t){let n=e.getBoundingClientRect().width,r=window.innerWidth-t.right;r<n+20&&(o(r-n+fk),c(fk+8))}}},[]),[a,o]=(0,B.useState)(pk),[s,c]=(0,B.useState)(fk);return(0,V.jsx)(F_,{className:r,sideOffset:a,alignOffset:s,collisionPadding:8,ref:i,children:n.formFactor===`phone`?(0,V.jsx)(ik.Col,{className:`dropdown-menu-container`,children:e}):(0,V.jsx)(PC,{className:`dropdown-menu-container`,padding:2,style:{zIndex:1},children:e})})},hk=mk;mk.displayName=`DropdownMenuSubContent`;var gk=({children:e,icon:t,shortcut:n,className:r})=>(0,V.jsxs)(P_,{className:`${fw(r)} dropdown-menu__submenu-trigger`,children:[(0,V.jsx)(hw,{icon:t,shortcut:n,children:e}),(0,V.jsx)(`div`,{className:`dropdown-menu__submenu-trigger-icon`,children:sC})]}),_k=gk;gk.displayName=`DropdownMenuSubTrigger`;var vk=e=>t=>B.Children.toArray(t).find(t=>B.isValidElement(t)&&typeof t.type!=`string`&&t?.type.displayName&&t.type.displayName===e)||null,yk=vk(`DropdownMenuTrigger`),bk=vk(`DropdownMenuContent`),xk=vk(`DropdownMenuSubTrigger`),Sk=vk(`DropdownMenuSubContent`),Ck=({children:e})=>{let t=xk(e),n=Sk(e);return(0,V.jsxs)(N_,{children:[t,n]})};Ck.Trigger=_k,Ck.Content=hk,Ck.displayName=`DropdownMenuSub`;var wk=Ck,Tk=({className:e=``,children:t,onToggle:n,title:r,...i})=>{let a=oV(),o=H(`dropdown-menu-button ${e}`,`zen-mode-transition`,{"dropdown-menu-button--mobile":a.formFactor===`phone`}).trim();return(0,V.jsx)(A_,{className:o,onClick:n,type:`button`,"data-testid":`dropdown-menu-button`,title:r,...i,children:t})},Ek=Tk;Tk.displayName=`DropdownMenuTrigger`;var Dk=e=>(0,V.jsx)(yw,{...e,icon:e.checked?Mb:aC}),Ok=({children:e,open:t})=>{let n=yk(e),r=bk(e),i=r&&B.isValidElement(r)?B.cloneElement(r,{open:t}):r;return(0,V.jsx)(k_,{open:t,modal:!1,children:(0,V.jsxs)(`div`,{className:D.DROPDOWN_MENU_EVENT_WRAPPER,style:{display:`contents`},children:[n,i]})})};Ok.Trigger=Ek,Ok.Content=ok,Ok.Item=yw,Ok.ItemCheckbox=Dk,Ok.ItemLink=lk,Ok.ItemCustom=sk,Ok.Group=uw,Ok.Separator=dk,Ok.Sub=wk;var Z=Ok;Ok.displayName=`DropdownMenu`;var kk=(e,t)=>e.filter(e=>t.includes(e.id)),Ak=({setAppState:e,selectedItems:t,library:n,onRemoveFromLibrary:r,resetLibrary:i,onSelectItems:a,appState:o,className:s})=>{let[c]=wy(TO),[l,u]=wy(Uk),d=()=>{let e=t.length?W(`alerts.removeItemsFromsLibrary`,{count:t.length}):W(`alerts.resetLibrary`),n=t.length?W(`confirmDialog.removeItemsFromLib`):W(`confirmDialog.resetLibrary`);return(0,V.jsx)(qO,{onConfirm:()=>{t.length?r():i(),p(!1)},onCancel:()=>{p(!1)},title:n,children:(0,V.jsx)(`p`,{children:e})})},[f,p]=(0,B.useState)(!1),m=!!t.length,h=m?c.libraryItems.filter(e=>t.includes(e.id)):c.libraryItems,g=W(m?`buttons.remove`:`buttons.resetLibrary`),[_,v]=(0,B.useState)(!1),[y,b]=(0,B.useState)(null),x=(0,B.useCallback)(()=>(0,V.jsxs)(Zk,{onCloseRequest:()=>b(null),title:W(`publishSuccessDialog.title`),className:`publish-library-success`,size:`small`,children:[(0,V.jsx)(`p`,{children:(0,V.jsx)(ek,{i18nKey:`publishSuccessDialog.content`,authorName:y.authorName,link:e=>(0,V.jsx)(`a`,{href:y?.url,target:`_blank`,rel:`noopener noreferrer`,children:e})})}),(0,V.jsx)(J,{type:`button`,title:W(`buttons.close`),"aria-label":W(`buttons.close`),label:W(`buttons.close`),onClick:()=>b(null),"data-testid":`publish-library-success-close`,className:`publish-library-success-close`})]}),[b,y]),S=(e,r)=>{v(!1),b({url:e.url,authorName:e.authorName});let i=r.slice();i.forEach(e=>{t.includes(e.id)&&(e.status=`published`)}),n.setLibrary(i)};return(0,V.jsxs)(`div`,{className:H(`library-menu-dropdown-container`,s),children:[(0,V.jsxs)(Z,{open:l,children:[(0,V.jsx)(Z.Trigger,{onToggle:()=>u(!l),children:qy}),(0,V.jsxs)(Z.Content,{onClickOutside:()=>u(!1),onSelect:()=>u(!1),className:`library-menu`,children:[!m&&(0,V.jsx)(Z.Item,{onSelect:async()=>{try{await n.updateLibrary({libraryItems:Cc({description:`Excalidraw library files`}),merge:!0,openLibraryMenu:!0})}catch(t){if(t?.name===`AbortError`){console.warn(t);return}e({errorMessage:W(`errors.importLibraryError`)})}},icon:Ib,"data-testid":`lib-dropdown--load`,children:W(`buttons.load`)}),!!h.length&&(0,V.jsx)(Z.Item,{onSelect:async()=>{let t=m?h:await n.getLatestLibrary();rs(t).catch($e).catch(t=>{e({errorMessage:t.message})})},icon:Tb,"data-testid":`lib-dropdown--export`,children:W(`buttons.export`)}),m&&(0,V.jsx)(Z.Item,{icon:aS,onSelect:()=>v(!0),"data-testid":`lib-dropdown--remove`,children:W(`buttons.publishLibrary`)}),!!h.length&&(0,V.jsx)(Z.Item,{onSelect:()=>p(!0),icon:yb,children:g})]})]}),t.length>0&&(0,V.jsx)(`div`,{className:`library-actions-counter`,children:t.length}),f&&d(),_&&(0,V.jsx)(rk,{onClose:()=>v(!1),libraryItems:kk(c.libraryItems,t),appState:o,onSuccess:e=>S(e,c.libraryItems),onError:e=>window.alert(e),updateItemsInStorage:()=>n.setLibrary(c.libraryItems),onRemove:e=>a(t.filter(t=>t!==e))}),y&&x()]})},jk=({selectedItems:e,onSelectItems:t,className:n})=>{let{library:r}=iV(),{clearLibraryCache:i,deleteItemsFromLibraryCache:a}=SO(),o=EC(),s=dV(),[c]=wy(TO),l=async n=>{let i=n.filter(t=>!e.includes(t.id));r.setLibrary(i).catch(()=>{s({errorMessage:W(`alerts.errorRemovingFromLibrary`)})}),a(e),t([])};return(0,V.jsx)(Ak,{appState:o,setAppState:s,selectedItems:e,onSelectItems:t,library:r,onRemoveFromLibrary:()=>l(c.libraryItems),resetLibrary:()=>{r.resetLibrary(),i()},className:n})};function Mk(){return[!1,(0,B.useCallback)(e=>e(),[])]}var Nk=B.useTransition||Mk,Pk=(0,B.memo)(({id:e,elements:t,isPending:n,onClick:r,selected:i,onToggle:a,onDrag:o,svgCache:s})=>{let c=(0,B.useRef)(null),l=xO(e,t,s,c),[u,d]=(0,B.useState)(!1),f=oV().formFactor===`phone`,p=n&&(0,V.jsx)(`div`,{className:`library-unit__adder`,children:Ky});return(0,V.jsxs)(`div`,{className:H(`library-unit`,{"library-unit__active":t,"library-unit--hover":t&&u,"library-unit--selected":i,"library-unit--skeleton":!l}),onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),children:[(0,V.jsx)(`div`,{className:H(`library-unit__dragger`,{"library-unit__pulse":!!n}),ref:c,draggable:!!t,onClick:t||n?t=>{e&&t.shiftKey?a(e,t):r(e)}:void 0,onDragStart:t=>{if(!e){t.preventDefault();return}d(!1),o(e,t)}}),p,e&&t&&(u||f||i)&&(0,V.jsx)(LT,{checked:i,onChange:(t,n)=>a(e,n),className:`library-unit__checkbox`})]})}),Fk=()=>(0,V.jsx)(`div`,{className:`library-unit library-unit--skeleton`}),Ik=({children:e})=>(0,V.jsx)(`div`,{className:`library-menu-items-container__grid`,children:e}),Lk=(0,B.memo)(({items:e,onItemSelectToggle:t,onItemDrag:n,isItemSelected:r,onClick:i,svgCache:a,itemsRenderedPerBatch:o})=>{let[,s]=Nk(),[c,l]=(0,B.useState)(0);return(0,B.useEffect)(()=>{c<e.length&&s(()=>{l(c+o)})},[c,e.length,s,o]),(0,V.jsx)(V.Fragment,{children:e.map((e,o)=>o<c?(0,V.jsx)(Pk,{elements:e?.elements,isPending:!e?.id&&!!e?.elements,onClick:i,svgCache:a,id:e?.id,selected:r(e.id),onToggle:t,onDrag:n},e?.id??o):(0,V.jsx)(Fk,{},o))})}),Rk=({type:e=`button`,onSelect:t,selected:n,children:r,className:i=``,...a})=>(0,V.jsx)(`button`,{onClick:Xo(a.onClick,e=>{t()}),type:e,className:H(`excalidraw-button`,i,{selected:n}),...a,children:r}),zk=(0,B.forwardRef)(({onChange:e,label:t,fullWidth:n,placeholder:r,readonly:i,selectOnRender:a,onKeyDown:o,isRedacted:s=!1,icon:c,className:l,type:u,...d},f)=>{let p=(0,B.useRef)(null);(0,B.useImperativeHandle)(f,()=>p.current),(0,B.useLayoutEffect)(()=>{a&&(p.current?.focus(),p.current?.select())},[a]);let[m,h]=(0,B.useState)(!1);return(0,V.jsxs)(`div`,{className:H(`ExcTextField`,l,{"ExcTextField--fullWidth":n,"ExcTextField--hasIcon":!!c}),onClick:()=>{p.current?.focus()},children:[c,t&&(0,V.jsx)(`div`,{className:`ExcTextField__label`,children:t}),(0,V.jsxs)(`div`,{className:H(`ExcTextField__input`,{"ExcTextField__input--readonly":i}),children:[(0,V.jsx)(`input`,{className:H({"is-redacted":`value`in d&&d.value&&s&&!m}),readOnly:i,value:`value`in d?d.value:void 0,defaultValue:`defaultValue`in d?d.defaultValue:void 0,placeholder:r,ref:p,onChange:t=>e?.(t.target.value),onKeyDown:o,type:u}),s&&(0,V.jsx)(Rk,{onSelect:()=>h(!m),style:{border:0,userSelect:`none`},children:m?wS:CS})]})]})}),Bk=17,Vk=64;function Hk({isLoading:e,libraryItems:t,onAddToLibrary:n,onInsertLibraryItems:r,pendingElements:i,theme:a,id:o,libraryReturnUrl:s,onSelectItems:c,selectedItems:l}){let u=oV(),d=(0,B.useRef)(null),f=GO(d);(0,B.useEffect)(()=>{f>0&&d.current?.scrollTo(0,f)},[]);let{svgCache:p}=SO(),[m,h]=(0,B.useState)(null),[g,_]=(0,B.useState)(``),v=!t.length&&!i.length,y=!v&&!!g.trim(),b=(0,B.useMemo)(()=>{let e=pO(g.trim().toLowerCase());return e?t.filter(t=>{let n=t.name||``;return n.trim()&&pO(n.toLowerCase()).includes(e)}):[]},[t,g]),x=(0,B.useMemo)(()=>t.filter(e=>e.status!==`published`),[t]),S=(0,B.useMemo)(()=>t.filter(e=>e.status===`published`),[t]),C=(0,B.useCallback)((e,t)=>{let n=!l.includes(e),r=[...x,...S];if(n){if(t.shiftKey&&m){let t=r.findIndex(e=>e.id===m),n=r.findIndex(t=>t.id===e);if(t===-1||n===-1){c([...l,e]);return}let i=ui(l),a=Math.min(t,n),o=Math.max(t,n);c(r.reduce((e,t,n)=>((n>=a&&n<=o||i.has(t.id))&&e.push(t.id),e),[]))}else c([...l,e]);h(e)}else h(null),c(l.filter(t=>t!==e))},[m,c,S,l,x]);(0,B.useEffect)(()=>{l.length||h(null)},[l]);let w=(0,B.useCallback)(e=>{let n;return n=l.includes(e)?t.filter(e=>l.includes(e.id)):t.filter(t=>t.id===e),n.map(e=>({...e,elements:bc({type:`everything`,elements:e.elements,randomizeSeed:!0,preserveFrameChildrenOrder:!0}).duplicatedElements}))},[t,l]),T=(0,B.useCallback)((e,t)=>{let n={itemIds:l.includes(e)?l:[e]};t.dataTransfer.setData(M.excalidrawlibIds,JSON.stringify(n))},[l]),E=(0,B.useCallback)(e=>e?l.includes(e):!1,[l]),D=(0,B.useCallback)(()=>{n(i)},[i,n]),O=(0,B.useCallback)(e=>{e&&r(w(e))},[w,r]),ee=p.size>=(b.length?b:t).length?Vk:Bk,k=(0,B.useRef)(null);(0,B.useEffect)(()=>{ro(()=>{k.current?.focus()})},[]);let te=!y&&(0,V.jsxs)(V.Fragment,{children:[!v&&(0,V.jsx)(`div`,{className:`library-menu-items-container__header`,children:W(`labels.personalLib`)}),!i.length&&!x.length?(0,V.jsxs)(`div`,{className:`library-menu-items__no-items`,children:[!S.length&&(0,V.jsx)(`div`,{className:`library-menu-items__no-items__label`,children:W(`library.noItems`)}),(0,V.jsx)(`div`,{className:`library-menu-items__no-items__hint`,children:S.length>0?W(`library.hint_emptyPrivateLibrary`):W(`library.hint_emptyLibrary`)})]}):(0,V.jsxs)(Ik,{children:[i.length>0&&(0,V.jsx)(Lk,{itemsRenderedPerBatch:ee,items:[{id:null,elements:i}],onItemSelectToggle:C,onItemDrag:T,onClick:D,isItemSelected:E,svgCache:p}),(0,V.jsx)(Lk,{itemsRenderedPerBatch:ee,items:x,onItemSelectToggle:C,onItemDrag:T,onClick:O,isItemSelected:E,svgCache:p})]}),S.length>0&&(0,V.jsx)(`div`,{className:`library-menu-items-container__header`,style:{marginTop:`0.75rem`},children:W(`labels.excalidrawLib`)}),S.length>0&&(0,V.jsx)(Ik,{children:(0,V.jsx)(Lk,{itemsRenderedPerBatch:ee,items:S,onItemSelectToggle:C,onItemDrag:T,onClick:O,isItemSelected:E,svgCache:p})})]}),ne=y&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`library-menu-items-container__header`,children:[W(`library.search.heading`),!e&&(0,V.jsxs)(`div`,{className:`library-menu-items-container__header__hint`,style:{cursor:`pointer`},onPointerDown:e=>e.preventDefault(),onClick:e=>{_(``)},children:[(0,V.jsx)(`kbd`,{children:`esc`}),` to clear`]})]}),b.length>0?(0,V.jsx)(Ik,{children:(0,V.jsx)(Lk,{itemsRenderedPerBatch:ee,items:b,onItemSelectToggle:C,onItemDrag:T,onClick:O,isItemSelected:E,svgCache:p})}):(0,V.jsxs)(`div`,{className:`library-menu-items__no-items`,children:[(0,V.jsx)(`div`,{className:`library-menu-items__no-items__hint`,children:W(`library.search.noResults`)}),(0,V.jsx)(Rk,{onPointerDown:e=>e.preventDefault(),onSelect:()=>{_(``)},style:{width:`auto`,marginTop:`1rem`},children:W(`library.search.clearSearch`)})]})]});return(0,V.jsxs)(`div`,{className:`library-menu-items-container`,style:i.length||x.length||S.length?{justifyContent:`flex-start`}:{borderBottom:0},children:[(0,V.jsxs)(`div`,{className:`library-menu-items-header`,children:[!v&&(0,V.jsx)(zk,{ref:k,type:`search`,className:H(`library-menu-items-container__search`,{hideCancelButton:u.formFactor!==`phone`}),placeholder:W(`library.search.inputPlaceholder`),value:g,onChange:e=>_(e)}),(0,V.jsx)(jk,{selectedItems:l,onSelectItems:c,className:`library-menu-dropdown-container--in-heading`})]}),(0,V.jsxs)(ik.Col,{className:`library-menu-items-container__items`,align:`start`,gap:1,style:{flex:S.length>0?1:`0 1 auto`,margin:v?`auto`:0},ref:d,children:[e&&(0,V.jsx)(`div`,{style:{position:`absolute`,top:`var(--container-padding-y)`,right:`var(--container-padding-x)`,transform:`translateY(50%)`},children:(0,V.jsx)(lC,{})}),te,ne,v&&(0,V.jsx)(UO,{style:{padding:`16px 0`,width:`100%`},id:o,libraryReturnUrl:s,theme:a})]})]})}var Uk=Gc(!1),Wk=({children:e})=>(0,V.jsx)(`div`,{className:`layer-ui__library`,children:e}),Gk=(0,B.memo)(({onInsertLibraryItems:e,pendingElements:t,onAddToLibrary:n,setAppState:r,libraryReturnUrl:i,library:a,id:o,theme:s,selectedItems:c,onSelectItems:l})=>{let[u]=wy(TO),d=(0,B.useCallback)(e=>{(async(e,t)=>{xC(`element`,`addToLibrary`,`ui`);for(let t of mi)if(e.some(e=>e.type===t))return r({errorMessage:W(`errors.libraryElementTypeError.${t}`)});let i=[{status:`unpublished`,elements:e,id:Tc(),created:Date.now()},...t];n(),a.setLibrary(i).catch(()=>{r({errorMessage:W(`alerts.errorAddingToLibrary`)})})})(e,u.libraryItems)},[n,a,r,u.libraryItems]),f=(0,B.useMemo)(()=>u.libraryItems,[u]);if(u.status===`loading`&&!u.isInitialized)return(0,V.jsx)(Wk,{children:(0,V.jsx)(`div`,{className:`layer-ui__library-message`,children:(0,V.jsxs)(`div`,{children:[(0,V.jsx)(lC,{size:`2em`}),(0,V.jsx)(`span`,{children:W(`labels.libraryLoadingMessage`)})]})})});let p=u.libraryItems.length>0||t.length>0;return(0,V.jsxs)(Wk,{children:[(0,V.jsx)(Hk,{isLoading:u.status===`loading`,libraryItems:f,onAddToLibrary:d,onInsertLibraryItems:e,pendingElements:t,id:o,libraryReturnUrl:i,theme:s,onSelectItems:l,selectedItems:c}),p&&(0,V.jsx)(UO,{className:`library-menu-control-buttons--at-bottom`,style:{padding:`16px 12px 0 12px`},id:o,libraryReturnUrl:i,theme:s})]})}),Kk=(e,t)=>({elements:e,pending:xt(e,{selectedElementIds:t},{includeBoundTextElement:!0,includeElementsInFrames:!0}),selectedElementIds:t}),qk=(e,t)=>{let n=lV(),[r,i]=(0,B.useState)(()=>Kk(n,e.selectedElementIds)),a=(0,B.useRef)(new Map);return(0,B.useEffect)(()=>{for(let e of r.pending)a.current.set(e.id,e.version)},[r.pending]),(0,B.useEffect)(()=>{t.state.cursorButton===`up`&&t.state.activeTool.type===`selection`&&i(r=>{if(!S(r.selectedElementIds,e.selectedElementIds))return a.current.clear(),Kk(n,e.selectedElementIds);let i=t.scene.getNonDeletedElementsMap();for(let t of Object.keys(e.selectedElementIds)){let r=i.get(t)?.version;if(r&&r!==a.current.get(t))return Kk(n,e.selectedElementIds)}return r})},[t,t.state.cursorButton,t.state.activeTool.type,e.selectedElementIds,n]),r.pending},Jk=(0,B.memo)(()=>{let e=iV(),{onInsertElements:t}=e,n=aV(),r=EC(),i=dV(),[a,o]=(0,B.useState)([]),s=(0,B.useMemo)(()=>e.library,[e.library]),c=qk(r,e);(0,B.useEffect)(()=>ki(document,T.KEYDOWN,t=>{if(t.key===j.ESCAPE&&t.target instanceof HTMLElement){let n=t.target;if(n.closest(`.${D.SIDEBAR}`))a.length>0?(t.stopPropagation(),o([])):de(n)&&n instanceof HTMLInputElement&&!n.value&&(t.stopPropagation(),i({openSidebar:null}),e.focusContainer());else if(a.length>0){let{x:n,y:r}=e.viewport.lastPosition;document.elementFromPoint(n,r)?.closest(`.${D.SIDEBAR}`)&&(t.stopPropagation(),o([]))}}},{capture:!0}),[a,i,e]);let l=(0,B.useCallback)(n=>{t(jO(n)),e.focusContainer()},[t,e]),u=(0,B.useCallback)(()=>{i({selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null})},[i]);return(0,V.jsx)(Gk,{pendingElements:c,onInsertLibraryItems:l,onAddToLibrary:u,setAppState:i,libraryReturnUrl:n.libraryReturnUrl,library:s,id:e.id,theme:r.theme,selectedItems:a,onSelectItems:o})}),Yk=e=>{let{closeOnClickOutside:t=!0}=e,n=DC({className:`excalidraw-modal-container`}),r=(0,B.useRef)(document.body.classList.contains(`excalidraw-animations-disabled`));return n?(0,Uc.createPortal)((0,V.jsxs)(`div`,{className:H(`Modal`,e.className,{"animations-disabled":r.current}),role:`dialog`,"aria-modal":`true`,onKeyDown:t=>{t.key===j.ESCAPE&&(t.preventDefault(),t.nativeEvent.stopImmediatePropagation(),t.stopPropagation(),e.onCloseRequest())},"aria-labelledby":e.labelledBy,children:[(0,V.jsx)(`div`,{className:`Modal__background`,onClick:t?e.onCloseRequest:void 0}),(0,V.jsx)(`div`,{className:`Modal__content`,style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),n):null};function Xk(e){if(e&&typeof e==`number`)return e;switch(e){case`small`:return 550;case`wide`:return 1024;default:return 800}}var Zk=e=>{let[t,n]=mO(),[r]=(0,B.useState)(document.activeElement),{id:i}=cV(),a=oV().formFactor===`phone`;(0,B.useEffect)(()=>{if(!t)return;let n=dt(t);setTimeout(()=>{n.length>0&&e.autofocus!==!1&&(n[1]||n[0]).focus()});let r=e=>{if(e.key===j.TAB){let n=dt(t),{activeElement:r}=document,i=n.findIndex(e=>e===r);i===0&&e.shiftKey?(n[n.length-1].focus(),e.preventDefault()):i===n.length-1&&!e.shiftKey&&(n[0].focus(),e.preventDefault())}};return t.addEventListener(`keydown`,r),()=>t.removeEventListener(`keydown`,r)},[t,e.autofocus]);let o=dV(),s=Ty(Uk),c=()=>{o({openMenu:null}),s(!1),r.focus(),e.onCloseRequest()};return(0,V.jsx)(Yk,{className:H(`Dialog`,e.className,{"Dialog--fullscreen":a}),labelledBy:`dialog-title`,maxWidth:Xk(e.size),onCloseRequest:c,closeOnClickOutside:e.closeOnClickOutside,children:(0,V.jsxs)(PC,{ref:n,children:[e.title&&(0,V.jsx)(`h2`,{id:`${i}-dialog-title`,className:`Dialog__title`,children:(0,V.jsx)(`span`,{className:`Dialog__titleContent`,children:e.title})}),a&&(0,V.jsx)(`button`,{className:`Dialog__close`,onClick:c,title:W(`buttons.close`),"aria-label":W(`buttons.close`),type:`button`,children:lx}),(0,V.jsx)(`div`,{className:`Dialog__content`,children:e.children})]})})},Qk=Y({name:`viewMode`,label:`labels.viewMode`,icon:CS,viewMode:!0,trackEvent:{category:`canvas`,predicate:e=>!e.viewModeEnabled},perform(e,t){return{appState:{...t,viewModeEnabled:!this.checked(t)},captureUpdate:F.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,t,n,r)=>typeof n.viewModeEnabled>`u`&&r.isInteractionEnabled(),keyTest:e=>!e[j.CTRL_OR_CMD]&&e.altKey&&e.code===I.R}),$k=(e,t)=>{let n=t[0]?.type||null;for(let e of t)if(e.type!==n){n=null;break}return $n(e.activeTool.type)&&n!==`image`&&n!==`frame`&&n!==`magicframe`||t.some(e=>$n(e.type))},eA=(e,t)=>hi(e.activeTool.type)||t.some(e=>hi(e.type)),tA=(e,t,n,r)=>{let i=e.activeTool.type,o=e=>e(i)||t.some(t=>e(t.type)),s=t.length===1,l=t.length===2&&(Dr(t[0])||Dr(t[1])),u=!!(e.editingTextElement||e.newElement),d=t.length>0;return{hasSelection:d,showExtraActions:d&&!u,strokeColor:$k(e,t),backgroundColor:eA(e,t),fill:i===`bucketfill`||hi(i)&&!ei(e.currentItemBackgroundColor)||t.some(e=>hi(e.type)&&!ei(e.backgroundColor)),strokeWidth:o(te),freedrawMode:o(Xi),strokeStyle:o(Br),sloppiness:o(Br),roundness:o(ma),arrowType:o(hc),arrowheads:o(c),text:i===`text`||t.some(a),textAlign:i===`text`||Ba(t,n),verticalAlign:dn(t,n),opacity:i!==`autoshape`||d,layers:i!==`freedraw`&&i!==`autoshape`&&!t.some(e=>e.type===`freedraw`)||xt(n,e).some(e=>e.type===`freedraw`),align:!l&&zE(e,r),distribute:t.length>2,link:s||l,linkSingleOnly:s,cropEditor:!e.croppingElementId&&s&&De(t[0]),lineEditor:!e.selectedLinearElement?.isEditing&&s&&po(t[0])&&!ve(t[0])}},nA=H([D.SHAPE_ACTIONS_THEME_SCOPE,`properties-content`]),rA=({renderAction:e})=>(0,V.jsxs)(`fieldset`,{children:[(0,V.jsx)(`legend`,{children:W(`labels.layers`)}),(0,V.jsxs)(`div`,{className:`buttonList`,children:[e(`sendToBack`),e(`sendBackward`),e(`bringForward`),e(`bringToFront`)]})]}),iA=({renderAction:e,showDistribute:t})=>{let n=document.documentElement.getAttribute(`dir`)===`rtl`;return(0,V.jsxs)(`fieldset`,{children:[(0,V.jsx)(`legend`,{children:W(`labels.align`)}),(0,V.jsxs)(`div`,{className:`buttonList`,children:[n?(0,V.jsxs)(V.Fragment,{children:[e(`alignRight`),e(`alignHorizontallyCentered`),e(`alignLeft`)]}):(0,V.jsxs)(V.Fragment,{children:[e(`alignLeft`),e(`alignHorizontallyCentered`),e(`alignRight`)]}),t&&e(`distributeHorizontally`),(0,V.jsx)(`div`,{style:{flexBasis:`100%`,height:0}}),(0,V.jsxs)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:`.5rem`,marginTop:`-0.5rem`},children:[e(`alignTop`),e(`alignVerticallyCentered`),e(`alignBottom`),t&&e(`distributeVertically`)]})]})]})},aA=({appState:e,elementsMap:t,renderAction:n,app:r})=>{let i=tA(e,$r(t,e),t,r);return e.activeTool.type===`bucketfill`?(0,V.jsxs)(`div`,{className:`selected-shape-actions`,children:[(0,V.jsx)(`div`,{children:n(`changeBucketFillBackgroundColor`)}),n(`changeFillStyle`),n(`changeOpacity`)]}):(0,V.jsxs)(`div`,{className:`selected-shape-actions`,children:[(0,V.jsx)(`div`,{children:i.strokeColor&&n(`changeStrokeColor`)}),i.backgroundColor&&(0,V.jsx)(`div`,{children:n(`changeBackgroundColor`)}),i.fill&&n(`changeFillStyle`),i.strokeWidth&&n(`changeStrokeWidth`),i.strokeStyle&&(0,V.jsx)(V.Fragment,{children:n(`changeStrokeStyle`)}),i.freedrawMode&&n(`changeFreedrawMode`),i.sloppiness&&(0,V.jsx)(V.Fragment,{children:n(`changeSloppiness`)}),i.roundness&&(0,V.jsx)(V.Fragment,{children:n(`changeRoundness`)}),i.arrowType&&(0,V.jsx)(V.Fragment,{children:n(`changeArrowType`)}),i.text&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`fieldset`,{children:n(`changeFontFamily`)}),n(`changeFontSize`),i.textAlign&&n(`changeTextAlign`)]}),i.verticalAlign&&n(`changeVerticalAlign`),i.arrowheads&&(0,V.jsx)(V.Fragment,{children:n(`changeArrowhead`)}),i.opacity&&n(`changeOpacity`),i.layers&&(0,V.jsx)(rA,{renderAction:n}),i.align&&(0,V.jsx)(iA,{renderAction:n,showDistribute:i.distribute}),i.showExtraActions&&(0,V.jsxs)(`fieldset`,{children:[(0,V.jsx)(`legend`,{children:W(`labels.actions`)}),(0,V.jsxs)(`div`,{className:`buttonList`,children:[n(`duplicateSelection`),n(`deleteSelectedElements`),n(`group`),n(`ungroup`),i.link&&n(`hyperlink`),i.cropEditor&&n(`cropEditor`),i.lineEditor&&n(`toggleLinearEditor`)]})]})]})},oA=({appState:e,renderAction:t,setAppState:n,predicates:r,container:i})=>{let a=r.hasSelection||e.activeTool.type!==`selection`&&e.activeTool.type!==`eraser`&&e.activeTool.type!==`hand`&&e.activeTool.type!==`laser`&&e.activeTool.type!==`lasso`,o=e.openPopup===`compactStrokeStyles`;return a?(0,V.jsx)(`div`,{className:`compact-action-item`,children:(0,V.jsxs)(cv,{open:o,onOpenChange:e=>{n(e?{openPopup:`compactStrokeStyles`}:{openPopup:null})},children:[(0,V.jsx)(lv,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,className:H(`compact-action-button properties-trigger`,{active:o}),title:W(`labels.stroke`),onClick:e=>{e.preventDefault(),e.stopPropagation(),n({openPopup:o?null:`compactStrokeStyles`})},children:tC})}),o&&(0,V.jsx)(FC,{className:nA,container:i,style:{maxWidth:`13rem`},onClose:()=>{},children:(0,V.jsxs)(`div`,{className:`selected-shape-actions`,children:[r.fill&&t(`changeFillStyle`),r.strokeWidth&&t(`changeStrokeWidth`),r.freedrawMode&&t(`changeFreedrawMode`),r.strokeStyle&&(0,V.jsx)(V.Fragment,{children:t(`changeStrokeStyle`)}),r.sloppiness&&(0,V.jsx)(V.Fragment,{children:t(`changeSloppiness`)}),r.roundness&&t(`changeRoundness`),r.opacity&&t(`changeOpacity`)]})})]})}):null},sA=({appState:e,renderAction:t,setAppState:n,targetElements:r,predicates:i,container:a,app:o})=>{if(!i.arrowType)return null;let s=e.openPopup===`compactArrowProperties`;return(0,V.jsx)(`div`,{className:`compact-action-item`,children:(0,V.jsxs)(cv,{open:s,onOpenChange:e=>{n(e?{openPopup:`compactArrowProperties`}:{openPopup:null})},children:[(0,V.jsx)(lv,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,className:H(`compact-action-button properties-trigger`,{active:s}),title:W(`labels.arrowtypes`),onClick:e=>{e.preventDefault(),e.stopPropagation(),n({openPopup:s?null:`compactArrowProperties`})},children:(()=>{let t=Hw(r,o,e=>_(e)?e.elbowed?`elbow`:e.roundness?`round`:`sharp`:null,e=>_(e),t=>t?null:e.currentItemArrowType);return t===`elbow`?JS:t===`round`?YS:qS})()})}),s&&(0,V.jsx)(FC,{container:a,className:`properties-content`,style:{maxWidth:`13rem`},onClose:()=>{},children:t(`changeArrowProperties`)})]})})},cA=({appState:e,renderAction:t,setAppState:n,predicates:r,container:i})=>{let{saveCaretPosition:a,restoreCaretPosition:o}=BC(),s=e.openPopup===`compactTextProperties`;return(0,V.jsx)(`div`,{className:`compact-action-item`,children:(0,V.jsxs)(cv,{open:s,onOpenChange:t=>{t?(e.editingTextElement&&a(),n({openPopup:`compactTextProperties`})):(n({openPopup:null}),e.editingTextElement&&o())},children:[(0,V.jsx)(lv,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,className:H(`compact-action-button properties-trigger`,{active:s}),title:W(`labels.textAlign`),onClick:t=>{t.preventDefault(),t.stopPropagation(),s?n({openPopup:null}):(e.editingTextElement&&a(),n({openPopup:`compactTextProperties`}))},children:pb})}),e.openPopup===`compactTextProperties`&&(0,V.jsx)(FC,{className:nA,container:i,style:{maxWidth:`13rem`},preventAutoFocusOnTouch:!!e.editingTextElement,onClose:()=>{e.editingTextElement&&o()},children:(0,V.jsxs)(`div`,{className:`selected-shape-actions`,children:[r.text&&t(`changeFontSize`),r.textAlign&&t(`changeTextAlign`),r.verticalAlign&&t(`changeVerticalAlign`)]})})]})})},lA=({appState:e,renderAction:t,predicates:n,setAppState:r,container:i,showDuplicate:a,showDelete:o})=>{let s=e.openPopup===`compactOtherProperties`;return n.showExtraActions?(0,V.jsx)(`div`,{className:`compact-action-item`,children:(0,V.jsxs)(cv,{open:s,onOpenChange:e=>{r(e?{openPopup:`compactOtherProperties`}:{openPopup:null})},children:[(0,V.jsx)(lv,{asChild:!0,children:(0,V.jsx)(`button`,{type:`button`,className:H(`compact-action-button properties-trigger`,{active:s}),title:W(`labels.actions`),onClick:e=>{e.preventDefault(),e.stopPropagation(),r({openPopup:s?null:`compactOtherProperties`})},children:Jy})}),s&&(0,V.jsx)(FC,{className:nA,container:i,style:{maxWidth:`12rem`,justifyContent:`center`,alignItems:`center`},onClose:()=>{},children:(0,V.jsxs)(`div`,{className:`selected-shape-actions`,children:[n.layers&&(0,V.jsx)(rA,{renderAction:t}),n.align&&(0,V.jsx)(iA,{renderAction:t,showDistribute:n.distribute}),(0,V.jsxs)(`fieldset`,{children:[(0,V.jsx)(`legend`,{children:W(`labels.actions`)}),(0,V.jsxs)(`div`,{className:`buttonList`,children:[t(`group`),t(`ungroup`),n.linkSingleOnly&&t(`hyperlink`),n.cropEditor&&t(`cropEditor`),a&&t(`duplicateSelection`),o&&t(`deleteSelectedElements`)]})]})]})})]})}):null},uA=({renderAction:e,predicates:t})=>t.lineEditor?(0,V.jsx)(`div`,{className:`compact-action-item`,children:e(`toggleLinearEditor`)}):null,dA=({appState:e,elementsMap:t,renderAction:n,app:r,setAppState:i})=>{let a=$r(t,e),o=tA(e,a,t,r),{container:s}=cV();return(0,V.jsxs)(`div`,{className:`compact-shape-actions`,children:[o.strokeColor&&(0,V.jsx)(`div`,{className:H(`compact-action-item`),children:n(`changeStrokeColor`)}),o.backgroundColor&&(0,V.jsx)(`div`,{className:`compact-action-item`,children:n(e.activeTool.type===`bucketfill`?`changeBucketFillBackgroundColor`:`changeBackgroundColor`)}),o.freedrawMode&&(0,V.jsx)(`div`,{className:`compact-action-item`,children:n(`changeFreedrawMode`,{cycle:!0})}),(0,V.jsx)(oA,{appState:e,renderAction:n,setAppState:i,predicates:o,container:s}),(0,V.jsx)(sA,{appState:e,renderAction:n,setAppState:i,targetElements:a,predicates:o,container:s,app:r}),o.lineEditor&&(0,V.jsx)(`div`,{className:`compact-action-item`,children:n(`toggleLinearEditor`)}),o.text&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{className:`compact-action-item`,children:n(`changeFontFamily`)}),(0,V.jsx)(cA,{appState:e,renderAction:n,setAppState:i,predicates:o,container:s})]}),o.showExtraActions&&(0,V.jsx)(`div`,{className:`compact-action-item`,children:n(`duplicateSelection`)}),o.showExtraActions&&(0,V.jsx)(`div`,{className:`compact-action-item`,children:n(`deleteSelectedElements`)}),(0,V.jsx)(lA,{appState:e,renderAction:n,predicates:o,setAppState:i,container:s})]})},fA=({appState:e,elementsMap:t,renderAction:n,app:r,setAppState:i})=>{let a=$r(t,e),o=tA(e,a,t,r),{container:s}=cV(),c=(0,B.useRef)(null),l=c.current?.getBoundingClientRect()?.width??0,u=l>=374,d=l>=412;return(0,V.jsxs)(PC,{className:`compact-shape-actions mobile-shape-actions`,style:{flexDirection:`row`,boxShadow:`none`,padding:0,zIndex:2,backgroundColor:`transparent`,height:43.2,marginBottom:4,alignItems:`center`,gap:6,pointerEvents:`none`},ref:c,children:[(0,V.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,gap:6,flex:1},children:[o.strokeColor&&(0,V.jsx)(`div`,{className:H(`compact-action-item`),children:n(`changeStrokeColor`)}),o.backgroundColor&&(0,V.jsx)(`div`,{className:`compact-action-item`,children:n(e.activeTool.type===`bucketfill`?`changeBucketFillBackgroundColor`:`changeBackgroundColor`)}),(0,V.jsx)(oA,{appState:e,renderAction:n,setAppState:i,predicates:o,container:s}),(0,V.jsx)(sA,{appState:e,renderAction:n,setAppState:i,targetElements:a,predicates:o,container:s,app:r}),(0,V.jsx)(uA,{renderAction:n,predicates:o}),o.text&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{className:`compact-action-item`,children:n(`changeFontFamily`)}),(0,V.jsx)(cA,{appState:e,renderAction:n,setAppState:i,predicates:o,container:s})]}),(0,V.jsx)(lA,{appState:e,renderAction:n,predicates:o,setAppState:i,container:s,showDuplicate:!d,showDelete:!u})]}),(0,V.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,gap:6},children:[(0,V.jsx)(`div`,{className:`compact-action-item`,children:n(`undo`)}),(0,V.jsx)(`div`,{className:`compact-action-item`,children:n(`redo`)}),d&&(0,V.jsx)(`div`,{className:`compact-action-item`,children:n(`duplicateSelection`)}),u&&(0,V.jsx)(`div`,{className:`compact-action-item`,children:n(`deleteSelectedElements`)})]})]})},pA=({renderAction:e})=>(0,V.jsx)(ik.Col,{gap:1,className:D.ZOOM_ACTIONS,children:(0,V.jsxs)(ik.Row,{align:`center`,children:[e(`zoomOut`),e(`resetZoom`),e(`zoomIn`)]})}),mA=({renderAction:e,className:t})=>(0,V.jsxs)(`div`,{className:`undo-redo-buttons ${t}`,children:[(0,V.jsx)(`div`,{className:`undo-button-container`,children:(0,V.jsx)(eT,{label:W(`buttons.undo`),children:e(`undo`)})}),(0,V.jsx)(`div`,{className:`redo-button-container`,children:(0,V.jsxs)(eT,{label:W(`buttons.redo`),children:[` `,e(`redo`)]})})]}),hA=({actionManager:e,showExitZenModeBtn:t})=>(0,V.jsx)(`button`,{type:`button`,className:H(`disable-zen-mode`,{"disable-zen-mode--visible":t}),onClick:()=>e.executeAction(eD),children:W(`buttons.exitZenMode`)}),gA=({actionManager:e})=>(0,V.jsx)(`button`,{type:`button`,className:`disable-view-mode`,onClick:()=>e.executeAction(Qk),children:rC}),_A=e=>{let t=(0,B.useRef)({userFn:e});return t.current.userFn=e,t.current.stableFn||(t.current.stableFn=(...e)=>t.current.userFn(...e)),t.current.stableFn},vA=Gc(null),yA=()=>{let[e,t]=wy(vA),n=fV();return e&&e===`clearCanvas`?(0,V.jsx)(qO,{onConfirm:()=>{n.executeAction(aT),t(null)},onCancel:()=>t(null),title:W(`clearCanvasDialog.title`),children:(0,V.jsxs)(`p`,{className:`clear-canvas__content`,children:[` `,W(`alerts.clearReset`)]})}):null},bA={},xA=Gc(null),SA={app:`App`,export:`Export`,tools:`Tools`,editor:`Editor`,elements:`Elements`,links:`Links`,library:`Library`},CA=e=>{switch(e){case SA.app:return 1;case SA.export:return 2;case SA.editor:return 3;case SA.tools:return 4;case SA.elements:return 5;case SA.links:return 6;default:return 10}},wA=({shortcut:e,className:t,children:n})=>{let r=e.replace(`++`,`+$`).split(`+`);return(0,V.jsxs)(`div`,{className:H(`shortcut`,t),children:[r.map((e,t)=>(0,V.jsx)(`div`,{className:`shortcut-wrapper`,children:(0,V.jsx)(`div`,{className:`shortcut-key`,children:e===`$`?`+`:e})},e)),(0,V.jsx)(`div`,{className:`shortcut-desc`,children:n})]})},TA=e=>!e.altKey&&e[j.CTRL_OR_CMD]&&(e.shiftKey&&e.key.toLowerCase()===j.P||e.key===j.SLASH),EA=Object.assign(e=>{let t=EC(),n=dV();return(0,B.useEffect)(()=>{let e=e=>{TA(e)&&(e.preventDefault(),e.stopPropagation(),n(e=>{let t=e.openDialog?.name===`commandPalette`?null:{name:`commandPalette`};return t&&xC(`command_palette`,`open`,`shortcut`),{openDialog:t}}))};return window.addEventListener(T.KEYDOWN,e,{capture:!0}),()=>window.removeEventListener(T.KEYDOWN,e,{capture:!0})},[n]),t.openDialog?.name===`commandPalette`?(0,V.jsx)(DA,{...e}):null},{defaultItems:bA});function DA({customCommandPaletteItems:e}){let t=iV(),n=EC(),r=dV(),i=aV(),a=fV(),[o,s]=wy(xA),[c,l]=(0,B.useState)(null),u=(0,B.useRef)(null),d=kC({uiAppState:n,customCommandPaletteItems:e,appProps:i}),[f]=wy(TO),p=(0,B.useMemo)(()=>f.libraryItems?.filter(e=>!!e.name).map(e=>({label:e.name,icon:(0,V.jsx)(OA,{id:e.id,elements:e.elements}),category:`Library`,order:CA(`Library`),haystack:pO(e.name),perform:()=>{t.onInsertElements(jO([e]))}}))||[],[t,f.libraryItems]);(0,B.useEffect)(()=>{let{uiAppState:e,customCommandPaletteItems:n,appProps:i}=d,c=n=>{let r=``;return n.label&&(r=typeof n.label==`function`?W(n.label(t.scene.getNonDeletedElements(),e,t)):W(n.label)),r},u=n=>typeof n.icon==`function`?n.icon(e,t.scene.getNonDeletedElements()):n.icon,f=[],m=(e,t,n)=>{let r={label:c(e),icon:u(e),category:t,shortcut:lO(e.name),keywords:e.keywords,predicate:e.predicate,viewMode:e.viewMode,perform:()=>{a.executeAction(e,`commandPalette`)}};return n?n(r,e):r};if(e&&t.scene&&a){let d=[a.actions.group,a.actions.ungroup,a.actions.cut,a.actions.copy,a.actions.deleteSelectedElements,a.actions.wrapSelectionInFrame,a.actions.copyStyles,a.actions.pasteStyles,a.actions.bringToFront,a.actions.bringForward,a.actions.sendBackward,a.actions.sendToBack,a.actions.alignTop,a.actions.alignBottom,a.actions.alignLeft,a.actions.alignRight,a.actions.alignVerticallyCentered,a.actions.alignHorizontallyCentered,a.actions.duplicateSelection,a.actions.flipHorizontal,a.actions.flipVertical,a.actions.zoomToFitSelection,a.actions.zoomToFitSelectionInViewport,a.actions.increaseFontSize,a.actions.decreaseFontSize,a.actions.toggleLinearEditor,a.actions.cropEditor,a.actions.togglePolygon,TD,oO,sO].map(e=>m(e,SA.elements,(e,t)=>({...e,predicate:t.predicate?t.predicate:(e,t,n,r)=>xt(e,t).length>0}))),h=[a.actions.undo,a.actions.redo,a.actions.zoomIn,a.actions.zoomOut,a.actions.resetZoom,a.actions.zoomToFit,a.actions.zenMode,a.actions.viewMode,a.actions.gridMode,a.actions.objectsSnapMode,a.actions.toggleShortcuts,a.actions.selectAll,a.actions.toggleElementLock,a.actions.unlockAllElements,a.actions.stats].map(e=>m(e,SA.editor)),g=[a.actions.saveToActiveFile,a.actions.saveFileToDisk,a.actions.copyAsPng,a.actions.copyAsSvg].map(e=>m(e,SA.export));f=[...d,...h,{label:c(aT),icon:u(aT),shortcut:lO(aT.name),category:SA.editor,keywords:[`delete`,`destroy`],viewMode:!1,perform:()=>{ky.set(vA,`clearCanvas`)}},{label:W(`buttons.exportImage`),category:SA.export,icon:Bb,shortcut:lO(`imageExport`),keywords:[`export`,`image`,`png`,`jpeg`,`svg`,`clipboard`,`picture`],perform:()=>{r({openDialog:{name:`imageExport`}})}},...g];let _=[m(uT,SA.app),{label:W(`toolBar.library`),category:SA.app,icon:Gy,viewMode:!1,perform:()=>{e.openSidebar?r({openSidebar:null}):r({openSidebar:{name:bo.name,tab:bo.defaultTab}})}},{label:W(`search.title`),category:SA.app,icon:DS,viewMode:!0,perform:()=>{a.executeAction(eM)}},{label:W(`labels.shapeSwitch`),category:SA.elements,icon:MS,perform:()=>{a.executeAction(aO)}},{label:W(`labels.changeStroke`),keywords:[`color`,`outline`],category:SA.elements,icon:Rb,viewMode:!1,predicate:(e,t)=>{let n=xt(e,t);return n.length>0&&$k(t,n)},perform:()=>{r(e=>({openPopup:`elementStroke`}))}},{label:W(`labels.changeBackground`),keywords:[`color`,`fill`],icon:Rb,category:SA.elements,viewMode:!1,predicate:(e,t)=>{let n=xt(e,t);return n.length>0&&eA(t,n)},perform:()=>{r(e=>({openPopup:`elementBackground`}))}},{label:W(`labels.canvasBackground`),keywords:[`color`],icon:Rb,category:SA.editor,viewMode:!1,perform:()=>{r(e=>({openMenu:e.openMenu===`canvas`?null:`canvas`,openPopup:`canvasBackground`}))}},...Object.keys(fT).reduce((e,n)=>{let r=fT[n];if(i.UIOptions.tools?.[n]===!1)return e;let a=mT(n)||r.numericKey,o={label:W(`toolBar.${n}`),category:SA.tools,shortcut:a,icon:r.icon,keywords:[`toolbar`],viewMode:!1,perform:()=>{t.setActiveTool({type:n},{toggle:!1})}};return e.push(o),e},[]),{label:W(`toolBar.lock`),category:SA.tools,icon:e.activeTool.locked?Qy:Zy,shortcut:j.Q.toLocaleUpperCase(),viewMode:!1,perform:()=>{t.toggleLock()}},{label:`${W(`labels.textToDiagram`)}...`,category:SA.tools,icon:ES,viewMode:!1,predicate:i.aiEnabled,perform:()=>{r(e=>({...e,openDialog:{name:`ttd`,tab:`text-to-diagram`}}))}},{label:`${W(`toolBar.mermaidToExcalidraw`)}...`,category:SA.tools,icon:hS,viewMode:!1,predicate:i.aiEnabled,perform:()=>{r(e=>({...e,openDialog:{name:`ttd`,tab:`mermaid`}}))}}],v=[...f,..._,...n||[]].map(e=>({...e,icon:e.icon||MS,order:e.order??CA(e.category),haystack:`${pO(e.label.toLocaleLowerCase())} ${e.keywords?.join(` `)||``}`}));l(v),s([...v,...p].find(e=>e.label===o?.label)??null)}},[d,t,a,l,o?.label,s,r,p]);let[m,h]=(0,B.useState)(``),[g,_]=(0,B.useState)(null),[v,y]=(0,B.useState)({}),b=e=>{r({openDialog:null},e),h(``)},x=(e,t)=>{n.openDialog?.name===`commandPalette`&&(t.stopPropagation(),t.preventDefault(),document.body.classList.add(`excalidraw-animations-disabled`),b(()=>{e.perform({actionManager:a,event:t}),s(e),requestAnimationFrame(()=>{document.body.classList.remove(`excalidraw-animations-disabled`)})}))},S=_A(e=>e.viewMode===!1&&n.viewModeEnabled?!1:typeof e.predicate==`function`?e.predicate(t.scene.getNonDeletedElements(),n,i,t):e.predicate===void 0||e.predicate),C=_A(e=>{let t=de(e.target)||TA(e)||e.key===j.ESCAPE;if(t&&e.key!==j.ARROW_UP&&e.key!==j.ARROW_DOWN&&e.key!==j.ENTER)return;let n=Object.values(v).flat(),r=o&&!m&&S(o);if(e.key===j.ARROW_UP){e.preventDefault();let t=n.findIndex(e=>e.label===g?.label);if(r){if(t===0){_(o);return}if(g===o){let e=n[n.length-1];e&&_(e);return}}let i;i=t===-1||t===0?n.length-1:(t-1)%n.length;let a=n[i];a&&_(a);return}if(e.key===j.ARROW_DOWN){e.preventDefault();let t=n.findIndex(e=>e.label===g?.label);if(r){if(!g||t===n.length-1){_(o);return}if(g===o){let e=n[0];e&&_(e);return}}let i=n[(t+1)%n.length];i&&_(i);return}if(e.key===j.ENTER&&g&&setTimeout(()=>{x(g,e)}),!t){if(e.stopPropagation(),/^[a-zA-Z0-9]$/.test(e.key)){u?.current?.focus();return}e.preventDefault()}});return(0,B.useEffect)(()=>(window.addEventListener(T.KEYDOWN,C,{capture:!0}),()=>window.removeEventListener(T.KEYDOWN,C,{capture:!0})),[C]),(0,B.useEffect)(()=>{if(!c)return;let e=e=>{let t={};for(let n of e)t[n.category]?t[n.category].push(n):t[n.category]=[n];return t},t=m?.length>1?[...c.filter(S).sort((e,t)=>e.order-t.order),...p]:c.filter(S).sort((e,t)=>e.order-t.order),n=!m&&o&&S(o);if(!m){y(e(n?t.filter(e=>e.label!==o?.label):t)),_(n?o:t[0]||null);return}let r=pO(m.toLocaleLowerCase().replace(/[<>_| -]/g,``));t=Nv.default.filter(r,t,{extract:e=>e.haystack??``}).sort((e,t)=>t.score-e.score).map(e=>e.original),y(e(t)),_(t[0]??null)},[m,c,S,o,p]),(0,V.jsxs)(Zk,{onCloseRequest:()=>b(),closeOnClickOutside:!0,title:!1,size:720,autofocus:!0,className:`command-palette-dialog`,children:[(0,V.jsx)(zk,{value:m,placeholder:W(`commandPalette.search.placeholder`),onChange:e=>{h(e)},selectOnRender:!0,ref:u}),t.editorInterface.formFactor!==`phone`&&(0,V.jsxs)(`div`,{className:`shortcuts-wrapper`,children:[(0,V.jsx)(wA,{shortcut:`↑↓`,children:W(`commandPalette.shortcuts.select`)}),(0,V.jsx)(wA,{shortcut:`↵`,children:W(`commandPalette.shortcuts.confirm`)}),(0,V.jsx)(wA,{shortcut:X(`Esc`),children:W(`commandPalette.shortcuts.close`)})]}),(0,V.jsxs)(`div`,{className:`commands`,children:[o&&!m&&(0,V.jsxs)(`div`,{className:`command-category`,children:[(0,V.jsxs)(`div`,{className:`command-category-title`,children:[W(`commandPalette.recents`),(0,V.jsx)(`div`,{className:`icon`,style:{marginLeft:`6px`},children:OS})]}),(0,V.jsx)(kA,{command:o,isSelected:o.label===g?.label,onClick:e=>x(o,e),disabled:!S(o),onMouseMove:()=>_(o),showShortcut:t.editorInterface.formFactor!==`phone`,appState:n})]}),Object.keys(v).length>0?Object.keys(v).map((e,r)=>(0,V.jsxs)(`div`,{className:`command-category`,children:[(0,V.jsx)(`div`,{className:`command-category-title`,children:e}),v[e].map(r=>(0,V.jsx)(kA,{command:r,isSelected:r.label===g?.label,onClick:e=>x(r,e),onMouseMove:()=>_(r),showShortcut:t.editorInterface.formFactor!==`phone`,appState:n,size:e===`Library`?`large`:`small`},r.label))]},e)):c?(0,V.jsxs)(`div`,{className:`no-match`,children:[(0,V.jsx)(`div`,{className:`icon`,children:DS}),` `,W(`commandPalette.search.noMatch`)]}):null]})]})}var OA=({id:e,elements:t})=>{let n=(0,B.useRef)(null),{svgCache:r}=SO();return xO(e,t,r,n),(0,V.jsx)(`div`,{className:`library-item-icon`,ref:n})},kA=({command:e,isSelected:t,disabled:n,onMouseMove:r,onClick:i,showShortcut:a,appState:o,size:s=`small`})=>{let c=()=>{};return(0,V.jsxs)(`div`,{className:H(`command-item`,{"item-selected":t,"item-disabled":n,"command-item-large":s===`large`}),ref:e=>{t&&!n&&e?.scrollIntoView?.({block:`nearest`})},onClick:n?c:i,onMouseMove:n?c:r,title:n?W(`commandPalette.itemNotAvailable`):``,children:[(0,V.jsxs)(`div`,{className:`name`,children:[e.icon&&(0,V.jsx)(Dw,{className:`icon`,size:`var(--icon-size, 1rem)`,icon:typeof e.icon==`function`?e.icon(o,[]):e.icon}),(0,V.jsx)(mw,{children:e.label})]}),a&&e.shortcut&&(0,V.jsx)(wA,{shortcut:e.shortcut})]})};function AA([e,t,n],[r,i,a]){return[e+r,t+i,n+a]}function jA([e,t,n],[r,i,a]){return[e-r,t-i,n-a]}function MA([e,t,n],r){return[e*r,t*r,n*r]}function NA([e,t,n]){return[e/Math.sqrt(e**2+t**2),t/Math.sqrt(e**2+t**2),n]}function PA([e,t,n],r){return[Math.cos(r)*e-Math.sin(r)*t,Math.sin(r)*e+Math.cos(r)*t,n]}function FA(e,t,n){return AA(e,MA(jA(t,e),n))}function IA(e,t,n){return Math.atan2(n[1]-e[1],n[0]-e[0])-Math.atan2(t[1]-e[1],t[0]-e[0])}function LA(e){return Math.atan2(Math.sin(e),Math.cos(e))}function RA([e,t]){return Math.sqrt(e**2+t**2)}function zA([e,t],[n,r]){return Math.sqrt((n-e)**2+(r-t)**2)}function BA(e){if(e.length<2)return 0;let t=0;for(let n=1;n<=e.length-1;n++)t+=zA(e[n-1],e[n]);return t+=zA(e[e.length-2],e[e.length-1]),t}var VA=(e,t,n)=>Math.max(t,Math.min(n,e));function HA(e,t,n){let r=zA(t,n);if(r===0)return zA(e,t);let i=VA(((e[0]-t[0])*(n[0]-t[0])+(e[1]-t[1])*(n[1]-t[1]))/r**2,0,1);return zA([t[0]+i*(n[0]-t[0]),t[1]+i*(n[1]-t[1]),e[2]],e)}function UA(e,t){if(t===0||e.length<=2)return e;let n=e[0],r=e[e.length-1],[i,a]=e.reduce(([e,t],i,a)=>{let o=HA(i,n,r);return o>e?[o,a]:[e,t]},[0,-1]);if(i>=t){let i=e[a];return[...UA([n,...e.slice(1,a),i],t).slice(0,-1),i,...UA([i,...e.slice(a,-1),r],t).slice(1)]}return[n,r]}var WA=class e{constructor(t){z(this,`options`),z(this,`originalPoints`,[]),z(this,`stablePoints`,[]),z(this,`tailPoints`,[]),z(this,`isFresh`,!0),this.options=Object.assign({},e.defaults,t)}get lastPoint(){return this.tailPoints[this.tailPoints.length-1]??this.stablePoints[this.stablePoints.length-1]}addPoint(t){let n=this.originalPoints[this.originalPoints.length-1];if(!(n&&n[0]===t[0]&&n[1]===t[1])){if(this.originalPoints.push(t),this.isFresh){this.isFresh=!1,this.stablePoints.push(t);return}this.options.streamline>0&&(t=FA(this.lastPoint,t,1-this.options.streamline)),this.tailPoints.push(t),BA(this.tailPoints)>e.constants.maxTailLength&&this.stabilizeTail()}}close(){this.stabilizeTail()}stabilizeTail(){if(this.options.simplify>0&&this.options.simplifyPhase===`tail`)throw Error(`Not implemented yet`);this.stablePoints.push(...this.tailPoints),this.tailPoints=[]}getSize(e,t,n,r,i){return(e??this.options.size)*this.options.sizeMapping({pressure:t,runningLength:i,currentIndex:n,totalLength:r})}getStrokeOutline(t){if(this.isFresh)return[];let n=[...this.stablePoints,...this.tailPoints];this.options.simplify>0&&this.options.simplifyPhase===`input`&&(n=UA(n,this.options.simplify));let r=n.length;if(r===0)return[];if(r===1){let e=n[0],i=this.getSize(t,e[2],0,r,0);if(i<.5)return[];let a=[];for(let t=0;t<=Math.PI*2;t+=Math.PI/16)a.push(AA(e,MA(PA([1,0,0],t),i)));return a.push(AA(e,MA([1,0,0],this.getSize(t,e[2],0,r,0)))),a}if(r===2){let e=n[0],i=n[1],a=this.getSize(t,e[2],0,r,0),o=this.getSize(t,i[2],0,r,0);if(a<.5||o<.5)return[];let s=[],c=IA(e,[e[0],e[1]-100,e[2]],i);for(let t=c;t<=Math.PI+c;t+=Math.PI/16)s.push(AA(e,MA(PA([1,0,0],t),a)));for(let e=Math.PI+c;e<=Math.PI*2+c;e+=Math.PI/16)s.push(AA(i,MA(PA([1,0,0],e),o)));return s.push(s[0]),s}let i=[],a=[],o=0,s=0,c=0,l=0;for(let u=1;u<r-1;u++){let d=n[u-1],f=n[u],p=n[u+1],m=f[2],h=zA(d,f);l+=h,o=s+(h-s)*.2;let g=this.getSize(t,m,u,r,l);if(g===0){c=u+1;continue}let _=NA(jA(d,f)),v=NA(jA(p,f)),y=PA(_,Math.PI/2),b=PA(_,-Math.PI/2),x=PA(v,Math.PI/2),S=PA(v,-Math.PI/2),C=AA(f,MA(y,g)),w=AA(f,MA(b,g)),T=AA(f,MA(x,g)),E=AA(f,MA(S,g)),D=AA(y,S),O=AA(b,x),ee=AA(f,MA(RA(D)===0?_:NA(D),g)),k=AA(f,MA(RA(O)===0?v:NA(O),g)),te=LA(IA(f,d,p)),ne=e.constants.cornerDetectionMaxAngle/180*Math.PI*e.constants.cornerDetectionVariance(o);if(Math.abs(te)<ne){let e=Math.abs(LA(Math.PI-te));if(e===0)continue;if(te<0){a.push(w,k);for(let t=0;t<=e;t+=e/4)i.push(AA(f,PA(MA(y,g),t)));for(let t=e;t>=0;t-=e/4)a.push(AA(f,PA(MA(y,g),t)));a.push(k,T)}else{i.push(C,ee);for(let t=0;t<=e;t+=e/4)a.push(AA(f,PA(MA(y,-g),-t)));for(let t=e;t>=0;t-=e/4)i.push(AA(f,PA(MA(y,-g),-t)));i.push(ee,E)}}else i.push(ee),a.push(k);s=o}if(c>=r-2){if(this.options.keepHead){let e=n[r-1],t=[];for(let n=0;n<=Math.PI*2;n+=Math.PI/16)t.push(AA(e,MA(PA([1,0,0],n),this.options.size)));return t.push(AA(e,MA([1,0,0],this.options.size))),t}return[]}let u=n[c],d=n[c+1],f=n[r-2],p=n[r-1],m=NA(jA(d,u)),h=NA(jA(f,p)),g=PA(m,-Math.PI/2),_=PA(h,Math.PI/2),v=this.getSize(t,u[2],0,r,0),y=[],b=this.options.keepHead?this.options.size:this.getSize(t,f[2],r-2,r,l),x=[];if(v>.1){for(let e=0;e<=Math.PI;e+=Math.PI/16)y.unshift(AA(u,PA(MA(g,v),-e)));y.unshift(AA(u,MA(g,-v)))}else y.push(u);for(let e=0;e<=Math.PI*3;e+=Math.PI/16)x.push(AA(p,PA(MA(_,-b),-e)));let S=[...y,...i,...x.reverse(),...a.reverse()];return y.length>0&&S.push(y[0]),this.options.simplify>0&&this.options.simplifyPhase===`output`?UA(S,this.options.simplify):S}};z(WA,`defaults`,{size:2,streamline:.45,simplify:.1,simplifyPhase:`output`,keepHead:!1,sizeMapping:()=>1}),z(WA,`constants`,{cornerDetectionMaxAngle:75,cornerDetectionVariance:e=>e>35?.5:1,maxTailLength:50});var GA=WA,KA=e=>{if(!e)return[];for(let t of e.sets)if(t.type===`path`)return t.ops;return e.sets[0].ops},qA=e=>!!e&&e.type===`embeddable`,JA=e=>!!e&&e.type===`iframe`,YA=e=>!!e&&(e.type===`iframe`||e.type===`embeddable`),XA=e=>e!=null&&e.type===`text`,ZA=e=>e!=null&&(e.type===`frame`||e.type===`magicframe`),QA=e=>e!=null&&tj(e.type),$A=e=>e!=null&&e.type===`arrow`,ej=e=>$A(e)&&e.elbowed,tj=e=>e===`arrow`||e===`line`,nj=e=>e!==null&&`containerId`in e&&e.containerId!==null&&XA(e),rj=(e,t=1)=>{if(e.length>=3){let[n,r]=[e[0],e[e.length-1]];return ya(n,r)<=8/t}return!1},ij=(e,t)=>{if(t.roundness?.type===Jr.PROPORTIONAL_RADIUS||t.roundness?.type===Jr.LEGACY)return e*fn;if(t.roundness?.type===Jr.ADAPTIVE_RADIUS){let n=t.roundness?.value??32;return e<=n/.25?e*fn:n}return 0};`ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789`.toLocaleUpperCase();var aj=(e,t)=>{let n=[];for(let r of e.values())r.frameId===t&&n.push(r);return n};(function(){let e=null,t=null,n=null,r=(r,i)=>(n!=null&&r===e&&i.selectedElementIds===t||(n=r.some(e=>i.selectedElementIds[e.id]),e=r,t=i.selectedElementIds),n);return r.clearCache=()=>{e=null,t=null,n=null},r})();var oj=(e,t,n)=>{let r=new Set,i=[];for(let a of e.values()){if(t.selectedElementIds[a.id]){vj(a)?(i.push(a),r.add(a.id)):console.error(`[NONDELETED][INVARIANT] getSelectedElements skipping deleted selected element which should not be in the selection`);continue}if(n?.includeBoundTextElement&&nj(a)&&vj(a)&&t.selectedElementIds[a?.containerId]){i.push(a),r.add(a.id);continue}}if(n?.includeElementsInFrames){let t=[];return i.forEach(n=>{ZA(n)&&aj(e,n.id).forEach(e=>!r.has(e.id)&&t.push(e)),t.push(n)}),t}return i},sj=(e,t)=>S(t.selectedElementIds,e)?t.selectedElementIds:e;(function(){let e=null,t=null,n=null,r=(r,i,a,o)=>{if(n!==void 0&&i===t&&r===e&&a.editingGroupId===n?.editingGroupId)return n;let s={};for(let e of r){let t=e.groupIds;if(a.editingGroupId){let e=t.indexOf(a.editingGroupId);e>-1&&(t=t.slice(0,e))}if(t.length>0){let e=t[t.length-1];s[e]=!0}}let c={},l=i.reduce((e,t)=>{if(t.isDeleted)return e;let n=t.groupIds.find(e=>s[e]);return n&&(e[t.id]=!0,Array.isArray(c[n])?c[n].push(t.id):c[n]=[t.id]),e},{});for(let e of Object.keys(c))c[e].length<2&&s[e]&&(s[e]=!1);return t=i,e=r,n={editingGroupId:a.editingGroupId,selectedGroupIds:s,selectedElementIds:sj({...a.selectedElementIds,...l},o)},n},i=(e,t,n,i)=>{let a=i?i.scene.getSelectedElements({selectedElementIds:e.selectedElementIds,elements:t}):oj(t,e);return a.length?r(a,t,e,n):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:sj(e.selectedElementIds,n)}};return i.clearCache=()=>{t=null,e=null,n=null},i})();var cj=[1,0],lj=[0,1],uj=[-1,0],dj=[0,-1],fj=e=>{let[t,n]=e,r=Math.abs(t),i=Math.abs(n);return t>i?cj:t<=-i?uj:n>r?lj:dj},pj=(e,t)=>fj(In(e,t)),mj=(e,t)=>gj(pj(e,t)),hj=(e,t)=>e[0]===t[0]&&e[1]===t[1],gj=e=>hj(e,cj)||hj(e,uj),_j=e=>e===`rectangle`||e===`iframe`||e===`embeddable`||e===`line`||e===`diamond`||e===`image`;(0,Hc.default)(e=>{(ci()||fc()||window?.DEBUG_FRACTIONAL_INDICES)&&_c(e,{shouldThrow:ci()||fc(),includeBoundTextValidation:!0})},6e4,{leading:!0,trailing:!1}),Math.PI/4;var vj=e=>!e.isDeleted,yj=e=>{let t=Math.floor(e.width/2)+1,n=e.width,r=Math.floor(e.height/2)+1;return[t,0,n,r,t,e.height,0,r]},bj=20,xj=15,Sj=e=>{switch(e){case`arrow`:return 25;case`diamond`:case`diamond_outline`:return 12;case`cardinality_many`:case`cardinality_one_or_many`:case`cardinality_zero_or_many`:return xj;case`cardinality_one`:case`cardinality_exactly_one`:case`cardinality_zero_or_one`:return bj;default:return 15}},Cj=e=>{switch(e){case`bar`:return 90;case`arrow`:return 20;default:return 25}},wj=(e,t,n,r,i=0)=>{if(r===null||t.length<1)return null;let a=KA(t[0]);if(a.length<1)return null;let o=n===`start`?1:a.length-1,s=a[o].data;qa(s.length===6,`Op data length is not 6`);let c=L(s[4],s[5]),l=L(s[2],s[3]),u=L(s[0],s[1]),d=a[o-1],f=L(0,0);if(d.op===`move`){let e=Fi(d.data);qa(e!=null,`Op data is not a point`),f=e}else d.op===`bcurveTo`&&(f=L(d.data[4],d.data[5]));let p=(e,t)=>(1-e)**3*c[t]+3*e*(1-e)**2*l[t]+3*e**2*(1-e)*u[t]+f[t]*e**3,[m,h]=n===`start`?f:c,[g,_]=[p(.3,0),p(.3,1)],v=Math.hypot(m-g,h-_),y=(m-g)/v,b=(h-_)/v,x=Sj(r),S=0;{let[t,r]=n===`end`?e.points[e.points.length-1]:e.points[0],[i,a]=e.points.length>1?n===`end`?e.points[e.points.length-2]:e.points[1]:[0,0];S=Math.hypot(t-i,r-a)}let C=Math.min(x,S*(r===`diamond`||r===`diamond_outline`?.25:.5)),w=m-y*C*i,T=h-b*C*i,E=w-y*C,D=T-b*C;if(r===`circle`||r===`circle_outline`)return[w,T,Math.hypot(D-T,E-w)+e.strokeWidth-2];let O=Cj(r);if(r===`cardinality_many`||r===`cardinality_one_or_many`){let[e,t]=Fs(L(w,T),L(E,D),la(-O)),[n,r]=Fs(L(w,T),L(E,D),la(O));return[E,D,e,t,n,r]}let[ee,k]=Fs(L(E,D),L(w,T),-O*Math.PI/180),[te,ne]=Fs(L(E,D),L(w,T),la(O));if(r===`diamond`||r===`diamond_outline`){let t,r;if(n===`start`){let[n,i]=e.points.length>1?e.points[1]:[0,0];[t,r]=Fs(L(w+C*2,T),L(w,T),Math.atan2(i-T,n-w))}else{let[n,i]=e.points.length>1?e.points[e.points.length-2]:[0,0];[t,r]=Fs(L(w-C*2,T),L(w,T),Math.atan2(T-i,w-n))}return[w,T,ee,k,t,r,te,ne]}return[w,T,ee,k,te,ne]},Tj=typeof document<`u`?document.createElement(`img`):{src:``};Tj.src=`data:${M.svg},%3Csvg%20aria-hidden%3D%22true%22%20focusable%3D%22false%22%20data-prefix%3D%22fas%22%20data-icon%3D%22image%22%20class%3D%22svg-inline--fa%20fa-image%20fa-w-16%22%20role%3D%22img%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20512%20512%22%3E%3Cpath%20fill%3D%22%23888%22%20d%3D%22M464%20448H48c-26.51%200-48-21.49-48-48V112c0-26.51%2021.49-48%2048-48h416c26.51%200%2048%2021.49%2048%2048v288c0%2026.51-21.49%2048-48%2048zM112%20120c-30.928%200-56%2025.072-56%2056s25.072%2056%2056%2056%2056-25.072%2056-56-25.072-56-56-56zM64%20384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971%200L208%20320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971%200L64%20336v48z%22%3E%3C%2Fpath%3E%3C%2Fsvg%3E`;var Ej=typeof document<`u`?document.createElement(`img`):{src:``};Ej.src=`data:${M.svg},%3Csvg%20viewBox%3D%220%200%20668%20668%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20xml%3Aspace%3D%22preserve%22%20style%3D%22fill-rule%3Aevenodd%3Bclip-rule%3Aevenodd%3Bstroke-linejoin%3Around%3Bstroke-miterlimit%3A2%22%3E%3Cpath%20d%3D%22M464%20448H48c-26.51%200-48-21.49-48-48V112c0-26.51%2021.49-48%2048-48h416c26.51%200%2048%2021.49%2048%2048v288c0%2026.51-21.49%2048-48%2048ZM112%20120c-30.928%200-56%2025.072-56%2056s25.072%2056%2056%2056%2056-25.072%2056-56-25.072-56-56-56ZM64%20384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971%200L208%20320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971%200L64%20336v48Z%22%20style%3D%22fill%3A%23888%3Bfill-rule%3Anonzero%22%20transform%3D%22matrix(.81709%200%200%20.81709%20124.825%20145.825)%22%2F%3E%3Cpath%20d%3D%22M256%208C119.034%208%208%20119.033%208%20256c0%20136.967%20111.034%20248%20248%20248s248-111.034%20248-248S392.967%208%20256%208Zm130.108%20117.892c65.448%2065.448%2070%20165.481%2020.677%20235.637L150.47%20105.216c70.204-49.356%20170.226-44.735%20235.638%2020.676ZM125.892%20386.108c-65.448-65.448-70-165.481-20.677-235.637L361.53%20406.784c-70.203%2049.356-170.226%2044.736-235.638-20.676Z%22%20style%3D%22fill%3A%23888%3Bfill-rule%3Anonzero%22%20transform%3D%22matrix(.30366%200%200%20.30366%20506.822%2060.065)%22%2F%3E%3C%2Fsvg%3E`;var Dj=new WeakMap,Oj=class{};z(Oj,`rg`,new oo),z(Oj,`cache`,new WeakMap),z(Oj,`get`,(e,t)=>{let n=Oj.cache.get(e);if(n&&(t===null||n.theme===t))return n.shape}),z(Oj,`delete`,e=>{Oj.cache.delete(e),Dj.delete(e)}),z(Oj,`destroy`,()=>{Oj.cache=new WeakMap}),z(Oj,`generateElementShape`,(e,t)=>{let n=t?.isExporting?void 0:Oj.get(e,t?t.theme:null);if(n!==void 0)return n;Dj.delete(e);let r=zj(e,Oj.rg,t||{isExporting:!1,canvasBackgroundColor:Ye.white,embedsValidationStatus:null,theme:A.LIGHT});return t?.isExporting||Oj.cache.set(e,{shape:r,theme:t?.theme||A.LIGHT}),r});var kj=e=>[8,8+e],Aj=e=>[1.5,6+e];function jj(e){let t=e.roughness,n=Math.max(e.width,e.height),r=Math.min(e.width,e.height);return r>=20&&n>=50||r>=15&&e.roundness&&_j(e.type)||QA(e)&&n>=50?t:Math.min(t/(n<10?3:2),2.5)}var Mj=(e,t=!1,n=!1)=>{let r={seed:e.seed,strokeLineDash:e.strokeStyle===`dashed`?kj(e.strokeWidth):e.strokeStyle===`dotted`?Aj(e.strokeWidth):void 0,disableMultiStroke:e.strokeStyle!==`solid`,strokeWidth:e.strokeStyle===`solid`?e.strokeWidth:e.strokeWidth+.5,fillWeight:e.strokeWidth/2,hachureGap:e.strokeWidth*4,roughness:jj(e),stroke:kt(e.strokeColor,n),preserveVertices:t||e.roughness<da.cartoonist};switch(e.type){case`rectangle`:case`iframe`:case`embeddable`:case`diamond`:case`ellipse`:return r.fillStyle=e.fillStyle,r.fill=ei(e.backgroundColor)?void 0:kt(e.backgroundColor,n),e.type===`ellipse`&&(r.curveFitting=1),r;case`line`:case`freedraw`:return rj(e.points)&&(r.fillStyle=e.fillStyle,r.fill=e.backgroundColor===`transparent`?void 0:kt(e.backgroundColor,n)),r;case`arrow`:return r;default:throw Error(`Unimplemented type ${e.type}`)}},Nj=(e,t,n)=>YA(e)&&(t||qA(e)&&n?.get(e.id)!==!0)&&ei(e.backgroundColor)&&ei(e.strokeColor)?{...e,roughness:0,backgroundColor:`#d3d3d3`,fillStyle:`solid`}:JA(e)?{...e,strokeColor:ei(e.strokeColor)?`#000000`:e.strokeColor,backgroundColor:ei(e.backgroundColor)?`#f4f4f6`:e.backgroundColor}:e,Pj=(e,t,n)=>{if(t===null)return[];let[,,r,i,a,o]=t;return[e.line(r,i,a,o,n)]},Fj=(e,t,n)=>{if(t===null)return[];let[r,i,a,o,s,c]=t;return[e.line(a,o,r,i,n),e.line(s,c,r,i,n)]},Ij=(e,t)=>{let n={...t};if(e.strokeStyle===`dotted`){let t=Aj(e.strokeWidth-1);n.strokeLineDash=[t[0],t[1]-1]}else delete n.strokeLineDash;return n.roughness=Math.min(1,n.roughness||0),n},Lj=(e,t,n,r,i,a=1)=>{if(r===null)return[];let[o,s,c]=r,l={...t,fill:i,fillStyle:`solid`,stroke:n,roughness:Math.min(.5,t.roughness||0)};return delete l.strokeLineDash,[e.circle(o,s,c*a,l)]},Rj=(e,t,n,r,i,a,o,s)=>{if(r===null)return[];let c=kt(e.strokeColor,s),l=kt(o,s),u=.8;switch(r){case`circle`:case`circle_outline`:return Lj(i,a,c,wj(e,t,n,r),r===`circle_outline`?l:c);case`triangle`:case`triangle_outline`:{let o=wj(e,t,n,r);if(o===null)return[];let[s,u,d,f,p,m]=o,h={...a,fill:r===`triangle_outline`?l:c,fillStyle:`solid`,roughness:Math.min(1,a.roughness||0)};return delete h.strokeLineDash,[i.polygon([[s,u],[d,f],[p,m],[s,u]],h)]}case`diamond`:case`diamond_outline`:{let o=wj(e,t,n,r);if(o===null)return[];let[s,u,d,f,p,m,h,g]=o,_={...a,fill:r===`diamond_outline`?l:c,fillStyle:`solid`,roughness:Math.min(1,a.roughness||0)};return delete _.strokeLineDash,[i.polygon([[s,u],[d,f],[p,m],[h,g],[s,u]],_)]}case`cardinality_one`:return Pj(i,wj(e,t,n,r),Ij(e,a));case`cardinality_many`:return Fj(i,wj(e,t,n,r),Ij(e,a));case`cardinality_one_or_many`:{let r=Ij(e,a);return[...Fj(i,wj(e,t,n,`cardinality_many`),r),...Pj(i,wj(e,t,n,`cardinality_one`,-.25),r)]}case`cardinality_exactly_one`:{let r=Ij(e,a);return[...Pj(i,wj(e,t,n,`cardinality_one`,-.5),r),...Pj(i,wj(e,t,n,`cardinality_one`),r)]}case`cardinality_zero_or_one`:{let r=Ij(e,a);return[...Lj(i,a,c,wj(e,t,n,`circle_outline`,1.5),l,u),...Pj(i,wj(e,t,n,`cardinality_one`,-.5),r)]}case`cardinality_zero_or_many`:{let r=Ij(e,a);return[...Fj(i,wj(e,t,n,`cardinality_many`),r),...Lj(i,a,c,wj(e,t,n,`circle_outline`,1.5),l,u)]}default:return Fj(i,wj(e,t,n,r),Ij(e,a))}},zj=(e,t,{isExporting:n,canvasBackgroundColor:r,embedsValidationStatus:i,theme:a})=>{let o=a===A.DARK;switch(e.type){case`rectangle`:case`iframe`:case`embeddable`:{let r;if(e.roundness){let a=e.width,s=e.height,c=ij(Math.min(a,s),e);r=t.path(`M ${c} 0 L ${a-c} 0 Q ${a} 0, ${a} ${c} L ${a} ${s-c} Q ${a} ${s}, ${a-c} ${s} L ${c} ${s} Q 0 ${s}, 0 ${s-c} L 0 ${c} Q 0 0, ${c} 0`,Mj(Nj(e,n,i),!0,o))}else r=t.rectangle(0,0,e.width,e.height,Mj(Nj(e,n,i),!1,o));return r}case`diamond`:{let n,[r,i,a,s,c,l,u,d]=yj(e);if(e.roundness){let f=ij(Math.abs(r-u),e),p=ij(Math.abs(s-i),e);n=t.path(`M ${r+f} ${i+p} L ${a-f} ${s-p}
|
|
47
|
-
C ${a} ${s}, ${a} ${s}, ${a-f} ${s+p}
|
|
48
|
-
L ${c+f} ${l-p}
|
|
49
|
-
C ${c} ${l}, ${c} ${l}, ${c-f} ${l-p}
|
|
50
|
-
L ${u+f} ${d+p}
|
|
51
|
-
C ${u} ${d}, ${u} ${d}, ${u+f} ${d-p}
|
|
52
|
-
L ${r-f} ${i+p}
|
|
53
|
-
C ${r} ${i}, ${r} ${i}, ${r+f} ${i+p}`,Mj(e,!0,o))}else n=t.polygon([[r,i],[a,s],[c,l],[u,d]],Mj(e,!1,o));return n}case`ellipse`:return t.ellipse(e.width/2,e.height/2,e.width,e.height,Mj(e,!1,o));case`line`:case`arrow`:{let n,i=Mj(e,!1,o),a=e.points.length?e.points:[L(0,0)];if(ej(e)?a.every(e=>Math.abs(e[0])<=1e6&&Math.abs(e[1])<=1e6)?n=[t.path(Bj(a,16),Mj(e,!0,o))]:(console.error(`Elbow arrow with extreme point positions detected. Arrow not rendered.`,e.id,JSON.stringify(a)),n=[]):n=e.roundness?[t.curve(a,i)]:i.fill?[t.polygon(a,i)]:[t.linearPath(a,i)],e.type===`arrow`){let{startArrowhead:a=null,endArrowhead:s=`arrow`}=e;if(a!==null){let s=Rj(e,n,`start`,a,t,i,r,o);n.push(...s)}if(s!==null){let a=Rj(e,n,`end`,s,t,i,r,o);n.push(...a)}}return n}case`freedraw`:{let n=[];if(rj(e.points)){let r=Lv(e.points,.75);n.push(t.curve(r,{...Mj(e,!1,o),stroke:`none`}))}return n.push(Vj(e)),n}case`frame`:case`magicframe`:case`text`:case`image`:return null;default:return uc(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}},Bj=(e,t)=>{let n=[];for(let r=1;r<e.length-1;r+=1){let i=e[r-1],a=e[r+1],o=e[r],s=mj(o,i),c=mj(a,o),l=Math.min(t,ya(e[r],a)/2,ya(e[r],i)/2);s?i[0]<o[0]?n.push([e[r][0]-l,e[r][1]]):n.push([e[r][0]+l,e[r][1]]):i[1]<o[1]?n.push([e[r][0],e[r][1]-l]):n.push([e[r][0],e[r][1]+l]),n.push(e[r]),c?a[0]<o[0]?n.push([e[r][0]-l,e[r][1]]):n.push([e[r][0]+l,e[r][1]]):a[1]<o[1]?n.push([e[r][0],e[r][1]-l]):n.push([e[r][0],e[r][1]+l])}let r=[`M ${e[0][0]} ${e[0][1]}`];for(let e=0;e<n.length;e+=3)r.push(`L ${n[e][0]} ${n[e][1]}`),r.push(`Q ${n[e+1][0]} ${n[e+1][1]}, ${n[e+2][0]} ${n[e+2][1]}`);return r.push(`L ${e[e.length-1][0]} ${e[e.length-1][1]}`),r.join(` `)},Vj=e=>Zj(Jj(e)),Hj={SIZE_FACTOR:4.25,THINNING:.6,SMOOTHING:.5},Uj={SIZE_FACTOR:1.4},Wj=e=>e.strokeOptions?.streamline??.5,Gj=e=>cy(e.simulatePressure?e.points:e.points.length?e.points.map(([t,n],r)=>[t,n,e.pressures[r]]):[[0,0,.5]],{simulatePressure:e.simulatePressure,size:e.strokeWidth*Hj.SIZE_FACTOR,thinning:Hj.THINNING,smoothing:Hj.SMOOTHING,streamline:Wj(e),easing:e=>Math.sin(e*Math.PI/2),last:!0}),Kj=e=>new GA({size:e.strokeWidth*Uj.SIZE_FACTOR,streamline:Wj(e),simplify:0,sizeMapping:e=>Math.max(.1,e.pressure)}),qj=e=>{let t=Kj(e);return e.points.map(([e,n])=>t.addPoint([e,n,1])),t.getStrokeOutline().map(([e,t])=>[e,t])},Jj=e=>e.strokeOptions?.variability===`constant`?qj(e):Gj(e),Yj=(e,t)=>[(e[0]+t[0])/2,(e[1]+t[1])/2],Xj=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g,Zj=e=>{if(!e.length)return``;let t=e.length-1;return e.reduce((e,n,r,i)=>(r===t?e.push(n,Yj(n,i[0]),`L`,i[0],`Z`):e.push(n,Yj(n,i[r+1])),e),[`M`,e[0],`Q`]).join(` `).replace(Xj,`$1`)},Qj=(e,t,n=!1)=>{let r=!1;for(let n in t){let i=t[n];if(typeof i<`u`){if(e[n]===i&&(typeof i!=`object`||!i))continue;r=!0}}return!r&&!n?e:{...e,...t,version:t.version??e.version+1,versionNonce:t.versionNonce??za(),updated:Qr()}},$j=Y({name:`toggleLinearEditor`,category:SA.elements,label:(e,t,n)=>n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds})[0]?.type===`arrow`?`labels.lineEditor.editArrow`:`labels.lineEditor.edit`,keywords:[`line`],trackEvent:{category:`element`},predicate:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t);return!!(!t.selectedLinearElement?.isEditing&&i.length===1&&po(i[0])&&!ve(i[0]))},perform(e,t,n,r){qa(t.selectedLinearElement,`No selected linear element found`);let i=r.scene.getElement(t.selectedLinearElement.elementId);qa(i,`No selected element found`);let a={...t.selectedLinearElement,isEditing:!t.selectedLinearElement.isEditing};return{appState:{...t,selectedLinearElement:a},captureUpdate:F.IMMEDIATELY}},PanelComponent:({appState:e,updateData:t,app:n})=>{let r=n.scene.getSelectedElements({selectedElementIds:e.selectedElementIds})[0];if(!r)return null;let i=W(r.type===`arrow`?`labels.lineEditor.editArrow`:`labels.lineEditor.edit`);return(0,V.jsx)(J,{type:`button`,icon:KS,title:i,"aria-label":i,onClick:()=>t(null)})}});Y({name:`togglePolygon`,category:SA.elements,icon:Xy,keywords:[`loop`],label:(e,t,n)=>n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds}).some(e=>!Oe(e)||!e.polygon)?`labels.polygon.convertToPolygon`:`labels.polygon.breakPolygon`,trackEvent:{category:`element`},predicate:(e,t,n,r)=>{let i=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds});return i.length>0&&i.every(e=>Oe(e)&&e.points.length>=4)},perform(e,t,n,r){let i=r.scene.getSelectedElements(t);if(i.some(e=>!Oe(e)))return!1;let a=i,o=a.some(e=>!e.polygon),s=ui(a);return{elements:e.map(e=>!s.has(e.id)||!Oe(e)?e:Qj(e,{backgroundColor:o?e.backgroundColor:`transparent`,...kr(e,o)})),appState:t,captureUpdate:F.IMMEDIATELY}},PanelComponent:({appState:e,updateData:t,app:n})=>{let r=n.scene.getSelectedElements({selectedElementIds:e.selectedElementIds});if(r.length===0||r.some(e=>!Oe(e)||!e.polygon||e.points.length<3))return null;let i=r.every(e=>Oe(e)&&e.polygon),a=W(i?`labels.polygon.breakPolygon`:`labels.polygon.convertToPolygon`);return(0,V.jsx)(J,{type:`toggle`,icon:Xy,title:a,"aria-label":a,checked:i,onSelect:()=>t(null),style:{marginLeft:`auto`}})}});var eM=Y({name:`searchMenu`,icon:DS,keywords:[`search`,`find`],label:`search.title`,viewMode:!0,trackEvent:{category:`search_menu`,action:`toggle`,predicate:e=>e.gridModeEnabled},perform(e,t,n,r){if(t.openDialog)return!1;if(t.openSidebar?.name===bo.name&&t.openSidebar.tab===`search`){let e=r.excalidrawContainerValue.container?.querySelector(`.${D.SEARCH_MENU_INPUT_WRAPPER} input`);return e?.focus(),e?.select(),!1}return{appState:{...t,openSidebar:{name:bo.name,tab:Or},openDialog:null},captureUpdate:F.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,t,n)=>n.gridModeEnabled===void 0,keyTest:e=>e[j.CTRL_OR_CMD]&&e.key===j.F}),tM=Y({name:`cropEditor`,label:`helpDialog.cropStart`,icon:$S,viewMode:!0,trackEvent:{category:`menu`},keywords:[`image`,`crop`],perform(e,t,n,r){let i=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0})[0];return{appState:{...t,isCropping:!1,croppingElementId:i.id},captureUpdate:F.IMMEDIATELY}},predicate:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t);return!!(!t.croppingElementId&&i.length===1&&De(i[0]))},PanelComponent:({appState:e,updateData:t,app:n})=>{let r=W(`helpDialog.cropStart`);return(0,V.jsx)(J,{type:`button`,icon:$S,title:r,"aria-label":r,onClick:()=>t(null)})}}),nM=(e,t)=>{let n=t.scene.getSelectedElements(e);return n.length===1&&P(n[0])},rM=Y({name:`selectAllElementsInFrame`,label:`labels.selectAllElementsInFrame`,trackEvent:{category:`canvas`},perform:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t).at(0)||null;if(P(i)){let n=Yn(et(e),i.id).filter(e=>!(e.type===`text`&&e.containerId));return{elements:e,appState:{...t,selectedElementIds:n.reduce((e,t)=>(e[t.id]=!0,e),{})},captureUpdate:F.IMMEDIATELY}}return{elements:e,appState:t,captureUpdate:F.EVENTUALLY}},predicate:(e,t,n,r)=>nM(t,r)}),iM=Y({name:`removeAllElementsFromFrame`,label:`labels.removeAllElementsFromFrame`,trackEvent:{category:`history`},perform:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t).at(0)||null;return P(i)?{elements:Aa(e,i),appState:{...t,selectedElementIds:{[i.id]:!0}},captureUpdate:F.IMMEDIATELY}:{elements:e,appState:t,captureUpdate:F.EVENTUALLY}},predicate:(e,t,n,r)=>nM(t,r)});Y({name:`updateFrameRendering`,label:`labels.updateFrameRendering`,viewMode:!0,trackEvent:{category:`canvas`},perform:(e,t)=>({elements:e,appState:{...t,frameRendering:{...t.frameRendering,enabled:!t.frameRendering.enabled}},captureUpdate:F.EVENTUALLY}),checked:e=>e.frameRendering.enabled});var aM=Y({name:`wrapSelectionInFrame`,label:`labels.wrapSelectionInFrame`,trackEvent:{category:`element`},predicate:(e,t,n,r)=>{let i=xt(e,t);return i.length>0&&!i.some(e=>P(e))},perform:(e,t,n,r)=>{let i=xt(e,t),a=r.scene.getNonDeletedElementsMap(),[o,s,c,l]=Is(i,a),u=at({x:o-16,y:s-16,width:c-o+32,height:l-s+32});if(t.editingGroupId){let e=yt(i,t.editingGroupId);for(let n of e){let e=n.groupIds.indexOf(t.editingGroupId);ir(n,a,{groupIds:n.groupIds.slice(0,e)})}}return{elements:Ke([...r.scene.getElementsIncludingDeleted(),u],i,u),appState:{selectedElementIds:{[u.id]:!0}},captureUpdate:F.IMMEDIATELY}}}),oM=class extends xo{applyTo(e,t,n){let[r,i]=this.elements.applyTo(e,n.elements,{excludedProperties:new Set([`version`,`versionNonce`])}),[a,o]=this.appState.applyTo(t,r);return[r,a,i||o]}static calculate(e,t){return super.calculate(e,t)}static inverse(e){return super.inverse(e)}static applyLatestChanges(e,t,n,r){return super.applyLatestChanges(e,t,n,r)}},sM=class{constructor(e=!0,t=!0){this.isUndoStackEmpty=e,this.isRedoStackEmpty=t}},cM=class e{constructor(e){this.store=e,z(this,`onHistoryChangedEmitter`,new Rn),z(this,`undoStack`,[]),z(this,`redoStack`,[])}get isUndoStackEmpty(){return this.undoStack.length===0}get isRedoStackEmpty(){return this.redoStack.length===0}clear(){this.undoStack.length=0,this.redoStack.length=0}record(e){if(e.isEmpty()||e instanceof oM)return;let t=oM.inverse(e);this.undoStack.push(t),t.elements.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new sM(this.isUndoStackEmpty,this.isRedoStackEmpty))}undo(t,n){return this.perform(t,n,()=>e.pop(this.undoStack),t=>e.push(this.redoStack,t))}redo(t,n){return this.perform(t,n,()=>e.pop(this.redoStack),t=>e.push(this.undoStack,t))}perform(e,t,n,r){try{let i=n();if(i===null)return;let a=F.IMMEDIATELY,o=this.store.snapshot,s=e,c=t,l=!1;for(;i;){try{[s,c,l]=i.applyTo(s,c,o);let e=o.elements,t=o.maybeClone(a,s,c),n=Ec.create(o,t),r=oM.applyLatestChanges(i,e,s);r.isEmpty()||(this.store.scheduleMicroAction({action:a,change:n,delta:r}),i=r),o=t}finally{r(i)}if(l)break;i=n()}return[s,c]}finally{this.onHistoryChangedEmitter.trigger(new sM(this.isUndoStackEmpty,this.isRedoStackEmpty))}}static pop(e){if(!e.length)return null;let t=e.pop();return t===void 0?null:t}static push(e,t){let n=oM.inverse(t);return e.push(n)}},lM=(e,t)=>{let[n,r]=(0,B.useState)(t);return(0,B.useEffect)(()=>{let t=e.on(e=>{r(e)});return()=>{t()}},[e]),n},uM=(e,t,n)=>{if(!t.multiElement&&!t.resizingElement&&!t.editingTextElement&&!t.newElement&&!t.selectedElementsAreBeingDragged&&!t.selectionElement&&!e.flowchart.isCreatingChart&&!e.drawShape.hasPendingGesture()){let e=n();if(!e)return{captureUpdate:F.EVENTUALLY};let[t,r]=e;return{appState:r,elements:no(Array.from(t.values())),captureUpdate:F.NEVER}}return{captureUpdate:F.EVENTUALLY}},dM=e=>({name:`undo`,label:`buttons.undo`,icon:Ub,trackEvent:{category:`history`},viewMode:!1,perform:(t,n,r,i)=>uM(i,n,()=>e.undo(ui(t),n)),keyTest:e=>e[j.CTRL_OR_CMD]&&gc(e,j.Z)&&!e.shiftKey,PanelComponent:({appState:t,updateData:n,data:r,app:i})=>{let{isUndoStackEmpty:a}=lM(e.onHistoryChangedEmitter,new sM(e.isUndoStackEmpty,e.isRedoStackEmpty)),o=sV()===`mobile`;return(0,V.jsx)(J,{type:`button`,icon:Ub,"aria-label":W(`buttons.undo`),onClick:n,size:r?.size||`medium`,disabled:a,"data-testid":`button-undo`,style:{...o?On:{}}})}}),fM=e=>({name:`redo`,label:`buttons.redo`,icon:Wb,trackEvent:{category:`history`},viewMode:!1,perform:(t,n,r,i)=>uM(i,n,()=>e.redo(ui(t),n)),keyTest:e=>e[j.CTRL_OR_CMD]&&e.shiftKey&&gc(e,j.Z)||e[j.CTRL_OR_CMD]&&!e.shiftKey&&gc(e,j.Y),PanelComponent:({appState:t,updateData:n,data:r,app:i})=>{let{isRedoStackEmpty:a}=lM(e.onHistoryChangedEmitter,new sM(e.isUndoStackEmpty,e.isRedoStackEmpty)),o=sV()===`mobile`;return(0,V.jsx)(J,{type:`button`,icon:Wb,"aria-label":W(`buttons.redo`),onClick:n,size:r?.size||`medium`,disabled:a,"data-testid":`button-redo`,style:{...o?On:{}}})}}),pM=Y({name:`autoResize`,label:`labels.autoResize`,icon:null,trackEvent:{category:`element`},predicate:(e,t,n)=>{let r=xt(e,t);return r.length===1&&a(r[0])&&!r[0].autoResize},perform:(e,t,n,r)=>{let i=xt(e,t),o=bs(n)&&a(n)?n:i[0],s=e.find(e=>e.id===o?.id);if(!s||!a(s))return!1;let c=uo(s.originalText,tc(s),s.lineHeight),l=gs(s),u=R(s,{autoResize:!0,width:c.width,height:c.height,x:s.x+(s.width-c.width)*l.x,y:s.y+(s.height-c.height)*l.y,text:s.originalText});return dc(u)&&La(u,r.scene,{changedElements:new Map([[u.id,u]])}),{appState:t,elements:e.map(e=>e.id===u.id?u:e),captureUpdate:F.IMMEDIATELY}}}),mM=(e,t,n,r,i,a)=>{if(e.trackEvent)try{typeof e.trackEvent==`object`&&(!e.trackEvent.predicate||e.trackEvent.predicate(n,r,a))&&xC(e.trackEvent.category,e.trackEvent.action||e.name,`${t} (${i.editorInterface.formFactor===`phone`?`mobile`:`desktop`})`)}catch(e){console.error(`error while logging action:`,e)}},hM=class{constructor(e,t,n,r){z(this,`actions`,{}),z(this,`updater`),z(this,`getAppState`),z(this,`getElementsIncludingDeleted`),z(this,`app`),z(this,`isActionBlockedByViewportTransition`,e=>e.navigation===!0&&this.app.viewport.isLockedTransitionPending),z(this,`renderAction`,(e,t)=>{let n=this.app.props.UIOptions.canvasActions;if(this.actions[e]&&`PanelComponent`in this.actions[e]&&(!(e in n)||n[e])){let n=this.actions[e],r=n.PanelComponent;r.displayName=`PanelComponent`;let i=this.getElementsIncludingDeleted(),a=this.getAppState();return(0,V.jsx)(r,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:e=>{this.isActionBlockedByViewportTransition(n)||(mM(n,`ui`,a,i,this.app,e),this.updater(n.perform(this.getElementsIncludingDeleted(),this.getAppState(),e,this.app)))},appProps:this.app.props,app:this.app,data:t,renderAction:this.renderAction})}return null}),z(this,`isActionEnabled`,e=>{let t=this.getElementsIncludingDeleted(),n=this.getAppState();return!e.predicate||e.predicate(t,n,this.app.props,this.app)}),this.updater=t=>{if(nt(t))t.then(t=>e(t));else return e(t)},this.getAppState=t,this.getElementsIncludingDeleted=n,this.app=r}registerAction(e){this.actions[e.name]=e}registerAll(e){e.forEach(e=>this.registerAction(e))}handleKeyDown(e){if(!this.app.isInteractionEnabled()&&!this.app.isNavigationEnabled())return!1;let t=this.app.props.UIOptions.canvasActions,n=Object.values(this.actions).sort((e,t)=>(t.keyPriority||0)-(e.keyPriority||0)).filter(n=>(n.name in t?t[n.name]:!0)&&n.keyTest&&n.keyTest(e,this.getAppState(),this.getElementsIncludingDeleted(),this.app));if(n.length!==1)return n.length>1&&console.warn(`Canceling as multiple actions match this shortcut`,n),!1;let r=n[0];if(!this.app.isInteractionEnabled()&&r.navigation!==!0||this.getAppState().viewModeEnabled&&r.viewMode!==!0)return!1;if(this.isActionBlockedByViewportTransition(r))return e.preventDefault(),e.stopPropagation(),!0;let i=this.getElementsIncludingDeleted(),a=this.getAppState();return mM(r,`keyboard`,a,i,this.app,null),e.preventDefault(),e.stopPropagation(),this.updater(n[0].perform(i,a,null,this.app)),!0}executeAction(e,t=`api`,n=null){if(t!==`api`&&!this.app.isInteractionEnabled()&&!(this.app.isNavigationEnabled()&&e.navigation===!0)||this.isActionBlockedByViewportTransition(e))return;let r=this.getElementsIncludingDeleted(),i=this.getAppState();mM(e,t,i,r,this.app,n),this.updater(e.perform(r,i,n,this.app))}},gM=e=>{let t=Array.from(e.values());return{x:vM(t,e=>e.x)/t.length,y:vM(t,e=>e.y)/t.length}},_M=([e,t])=>Math.hypot(e.x-t.x,e.y-t.y),vM=(e,t)=>e.reduce((e,n)=>e+t(n),0),yM=8,bM=99999,xM=e=>yM/e,SM=class{};z(SM,`referenceSnapPoints`,null),z(SM,`visibleGaps`,null),z(SM,`setReferenceSnapPoints`,e=>{SM.referenceSnapPoints=e}),z(SM,`getReferenceSnapPoints`,()=>SM.referenceSnapPoints),z(SM,`setVisibleGaps`,e=>{SM.visibleGaps=e}),z(SM,`getVisibleGaps`,()=>SM.visibleGaps),z(SM,`destroy`,()=>{SM.referenceSnapPoints=null,SM.visibleGaps=null});var CM=SM,wM=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,TM=({event:e,app:t,selectedElements:n})=>{if(e){let n=t.state.activeTool.type===`lasso`&&t.state.selectedElementsAreBeingDragged;return(t.state.activeTool.type!==`lasso`||n)&&(t.state.objectsSnapModeEnabled&&!e[j.CTRL_OR_CMD]||!t.state.objectsSnapModeEnabled&&e[j.CTRL_OR_CMD]&&!wM(t))}return n.length===1&&n[0].type===`arrow`?!1:t.state.objectsSnapModeEnabled},EM=(e,t,n=.01)=>Math.abs(e-t)<=n,DM=(e,t,{omitCenter:n,boundingBoxCorners:r,dragOffset:i}={omitCenter:!1,boundingBoxCorners:!1})=>{let a=[];if(e.length===1){let o=e[0],[s,c,l,u,d,f]=kc(o,t);i&&(s+=i.x,l+=i.x,d+=i.x,c+=i.y,u+=i.y,f+=i.y);let p=(l-s)/2,m=(u-c)/2;if((o.type===`diamond`||o.type===`ellipse`)&&!r){let e=Fs(L(s,c+m),L(d,f),o.angle),t=Fs(L(s+p,c),L(d,f),o.angle),r=Fs(L(l,c+m),L(d,f),o.angle),i=Fs(L(s+p,u),L(d,f),o.angle),h=L(d,f);a=n?[e,t,r,i]:[e,t,r,i,h]}else{let e=Fs(L(s,c),L(d,f),o.angle),t=Fs(L(l,c),L(d,f),o.angle),r=Fs(L(s,u),L(d,f),o.angle),i=Fs(L(l,u),L(d,f),o.angle),p=L(d,f);a=n?[e,t,r,i]:[e,t,r,i,p]}}else if(e.length>1){let[t,r,o,s]=Ht(e,i??{x:0,y:0}),c=o-t,l=s-r,u=L(t,r),d=L(o,r),f=L(t,s),p=L(o,s),m=L(t+c/2,r+l/2);a=n?[u,d,f,p]:[u,d,f,p,m]}return a.map(e=>L(PM(e[0]),PM(e[1])))},OM=(e,t,n,r)=>Qt(e,t,n,r),kM=(e,t,n,r)=>{let a=OM(e,t,n,r),o=It(a,r).filter(e=>!(e.length===1&&cs(e[0]))).map(e=>Is(e).map(e=>PM(e))),s=o.sort((e,t)=>e[0]-t[0]),c=[],l=0;e:for(let e=0;e<s.length;e++){let t=s[e];for(let n=e+1;n<s.length;n++){if(++l>bM)break e;let e=s[n],[,r,a,o]=t,[u,d,,f]=e;a<u&&to(fo(r,o),fo(d,f))&&c.push({startBounds:t,endBounds:e,startSide:[L(a,r),L(a,o)],endSide:[L(u,d),L(u,f)],length:u-a,overlap:i(fo(r,o),fo(d,f))})}}let u=o.sort((e,t)=>e[1]-t[1]),d=[];l=0;e:for(let e=0;e<u.length;e++){let t=u[e];for(let n=e+1;n<u.length;n++){if(++l>bM)break e;let e=u[n],[r,,a,o]=t,[s,c,f]=e;o<c&&to(fo(r,a),fo(s,f))&&d.push({startBounds:t,endBounds:e,startSide:[L(r,o),L(a,o)],endSide:[L(s,c),L(f,c)],length:c-o,overlap:i(fo(r,a),fo(s,f))})}}return{horizontalGaps:c,verticalGaps:d}},AM=(e,t,n,r,i,a,o)=>{if(!TM({app:n,event:r,selectedElements:e})||e.length===0)return[];let s=CM.getVisibleGaps();if(s){let{horizontalGaps:n,verticalGaps:r}=s,[c,l,u,d]=Ht(e,t).map(e=>PM(e)),f=(c+u)/2,p=(l+d)/2;for(let e of n){if(!to(fo(l,d),e.overlap))continue;let t=PM(e.startSide[0][0]+e.length/2-f);if(e.length>u-c&&Math.abs(t)<=o.x){Math.abs(t)<o.x&&(i.length=0),o.x=Math.abs(t);let n={type:`gap`,direction:`center_horizontal`,gap:e,offset:t};i.push(n);continue}let[,,n]=e.endBounds,r=c-n,a=PM(e.length-r);if(Math.abs(a)<=o.x){Math.abs(a)<o.x&&(i.length=0),o.x=Math.abs(a);let t={type:`gap`,direction:`side_right`,gap:e,offset:a};i.push(t);continue}let[s,,,]=e.startBounds,p=PM(s-u-e.length);if(Math.abs(p)<=o.x){Math.abs(p)<o.x&&(i.length=0),o.x=Math.abs(p);let t={type:`gap`,direction:`side_left`,gap:e,offset:p};i.push(t);continue}}for(let e of r){if(!to(fo(c,u),e.overlap))continue;let t=PM(e.startSide[0][1]+e.length/2-p);if(e.length>d-l&&Math.abs(t)<=o.y){Math.abs(t)<o.y&&(a.length=0),o.y=Math.abs(t);let n={type:`gap`,direction:`center_vertical`,gap:e,offset:t};a.push(n);continue}let[,n,,]=e.startBounds,r=PM(n-d-e.length);if(Math.abs(r)<=o.y){Math.abs(r)<o.y&&(a.length=0),o.y=Math.abs(r);let t={type:`gap`,direction:`side_top`,gap:e,offset:r};a.push(t);continue}let[,,,i]=e.endBounds,s=PM(l-i),f=e.length-s;if(Math.abs(f)<=o.y){Math.abs(f)<o.y&&(a.length=0),o.y=Math.abs(f);let t={type:`gap`,direction:`side_bottom`,gap:e,offset:f};a.push(t);continue}}}},jM=(e,t,n,r)=>{let i=OM(e,t,n,r);return It(i,r).filter(e=>!(e.length===1&&cs(e[0]))).flatMap(e=>DM(e,r))},MM=(e,t,n,r,i,a,o)=>{if(!TM({app:n,event:r,selectedElements:e})||e.length===0&&t.length===0)return[];let s=CM.getReferenceSnapPoints();if(s)for(let e of t)for(let t of s){let n=t[0]-e[0],r=t[1]-e[1];Math.abs(n)<=o.x&&(Math.abs(n)<o.x&&(i.length=0),i.push({type:`point`,points:[e,t],offset:n}),o.x=Math.abs(n)),Math.abs(r)<=o.y&&(Math.abs(r)<o.y&&(a.length=0),a.push({type:`point`,points:[e,t],offset:r}),o.y=Math.abs(r))}},NM=(e,t,n,r,i)=>{let a=n.state,o=xt(e,a);if(!TM({app:n,event:r,selectedElements:o})||o.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};t.x=PM(t.x),t.y=PM(t.y);let s=[],c=[],l=xM(a.zoom.value),u={x:l,y:l};MM(o,DM(o,i,{dragOffset:t}),n,r,s,c,u),AM(o,t,n,r,s,c,u);let d={x:s[0]?.offset??0,y:c[0]?.offset??0};u.x=0,u.y=0,s.length=0,c.length=0;let f={x:PM(t.x+d.x),y:PM(t.y+d.y)};MM(o,DM(o,i,{dragOffset:f}),n,r,s,c,u),AM(o,f,n,r,s,c,u);let p=IM(s,c),m=RM(o,f,[...s,...c].filter(e=>e.type===`gap`));return{snapOffset:d,snapLines:[...p,...m]}},PM=e=>Math.round(e*10**6)/10**6,FM=e=>{let t=new Map;for(let n of e){let e=n.join(`,`);t.has(e)||t.set(e,n)}return Array.from(t.values())},IM=(e,t)=>{let n={},r={};if(e.length>0){for(let t of e)if(t.type===`point`){let e=PM(t.points[0][0]);n[e]||(n[e]=[]),n[e].push(...t.points.map(e=>L(PM(e[0]),PM(e[1]))))}}if(t.length>0){for(let e of t)if(e.type===`point`){let t=PM(e.points[0][1]);r[t]||(r[t]=[]),r[t].push(...e.points.map(e=>L(PM(e[0]),PM(e[1]))))}}return Object.entries(n).map(([e,t])=>({type:`points`,points:FM(t.map(t=>L(Number(e),t[1])).sort((e,t)=>e[1]-t[1]))})).concat(Object.entries(r).map(([e,t])=>({type:`points`,points:FM(t.map(t=>L(t[0],Number(e))).sort((e,t)=>e[0]-t[0]))})))},LM=e=>{let t=new Map;for(let n of e){let e=n.points.flat().map(e=>[PM(e)]).join(`,`);t.has(e)||t.set(e,n)}return Array.from(t.values())},RM=(e,t,n)=>{let[r,a,o,s]=Ht(e,t),c=[];for(let e of n){let[t,n,l,u]=e.gap.startBounds,[d,f,p,m]=e.gap.endBounds,h=i(fo(a,s),e.gap.overlap),g=i(fo(r,o),e.gap.overlap);switch(e.direction){case`center_horizontal`:if(h){let t=(h[0]+h[1])/2;c.push({type:`gap`,direction:`horizontal`,points:[L(e.gap.startSide[0][0],t),L(r,t)]},{type:`gap`,direction:`horizontal`,points:[L(o,t),L(e.gap.endSide[0][0],t)]})}break;case`center_vertical`:if(g){let t=(g[0]+g[1])/2;c.push({type:`gap`,direction:`vertical`,points:[L(t,e.gap.startSide[0][1]),L(t,a)]},{type:`gap`,direction:`vertical`,points:[L(t,s),L(t,e.gap.endSide[0][1])]})}break;case`side_right`:if(h){let e=(h[0]+h[1])/2;c.push({type:`gap`,direction:`horizontal`,points:[L(l,e),L(d,e)]},{type:`gap`,direction:`horizontal`,points:[L(p,e),L(r,e)]})}break;case`side_left`:if(h){let e=(h[0]+h[1])/2;c.push({type:`gap`,direction:`horizontal`,points:[L(o,e),L(t,e)]},{type:`gap`,direction:`horizontal`,points:[L(l,e),L(d,e)]})}break;case`side_top`:if(g){let e=(g[0]+g[1])/2;c.push({type:`gap`,direction:`vertical`,points:[L(e,s),L(e,n)]},{type:`gap`,direction:`vertical`,points:[L(e,u),L(e,f)]})}break;case`side_bottom`:if(g){let e=(g[0]+g[1])/2;c.push({type:`gap`,direction:`vertical`,points:[L(e,u),L(e,f)]},{type:`gap`,direction:`vertical`,points:[L(e,m),L(e,a)]})}}}return LM(c.map(e=>({...e,points:e.points.map(e=>L(PM(e[0]),PM(e[1])))})))},zM=(e,t,n,r,i,a)=>{if(!TM({event:r,selectedElements:e,app:n})||e.length===0||e.length===1&&!EM(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[o,s,c,l]=Is(t);a&&(a.includes(`e`)?c+=i.x:a.includes(`w`)&&(o+=i.x),a.includes(`n`)?s+=i.y:a.includes(`s`)&&(l+=i.y));let u=[];if(a)switch(a){case`e`:u.push(L(c,s),L(c,l));break;case`w`:u.push(L(o,s),L(o,l));break;case`n`:u.push(L(o,s),L(c,s));break;case`s`:u.push(L(o,l),L(c,l));break;case`ne`:u.push(L(c,s));break;case`nw`:u.push(L(o,s));break;case`se`:u.push(L(c,l));break;case`sw`:u.push(L(o,l));break}let d=xM(n.state.zoom.value),f={x:d,y:d},p=[],m=[];MM(t,u,n,r,p,m,f);let h={x:p[0]?.offset??0,y:m[0]?.offset??0};f.x=0,f.y=0,p.length=0,m.length=0;let[g,_,v,y]=Is(e).map(e=>PM(e));return MM(e,[L(g,_),L(g,y),L(v,_),L(v,y)],n,r,p,m,f),{snapOffset:h,snapLines:IM(p,m)}},BM=(e,t,n,r,i,a)=>{if(!TM({event:n,selectedElements:[e],app:t}))return{snapOffset:{x:0,y:0},snapLines:[]};let o=[L(r.x+i.x,r.y+i.y)],s=xM(t.state.zoom.value),c={x:s,y:s},l=[],u=[];MM([e],o,t,n,l,u,c);let d={x:l[0]?.offset??0,y:u[0]?.offset??0};c.x=0,c.y=0,l.length=0,u.length=0;let f=DM([e],a,{boundingBoxCorners:!0,omitCenter:!0});return MM([e],f,t,n,l,u,c),{snapOffset:d,snapLines:IM(l,u)}},VM=(e,t,n,r,i)=>{if(!TM({event:r,selectedElements:[],app:t}))return{originOffset:{x:0,y:0},snapLines:[]};let a=Qt(e,[],t.state,i),o=xM(t.state.zoom.value),s={x:o,y:o},c=[],l=[];for(let e of a){let t=DM([e],i);for(let e of t){let t=e[0]-n.x;Math.abs(t)<=Math.abs(s.x)&&(Math.abs(t)<Math.abs(s.x)&&(l.length=0),l.push({type:`pointer`,points:[e,L(e[0],n.y)],direction:`vertical`}),s.x=t);let r=e[1]-n.y;Math.abs(r)<=Math.abs(s.y)&&(Math.abs(r)<Math.abs(s.y)&&(c.length=0),c.push({type:`pointer`,points:[e,L(n.x,e[1])],direction:`horizontal`}),s.y=r)}}return{originOffset:{x:l.length>0?l[0].points[0][0]-n.x:0,y:c.length>0?c[0].points[0][1]-n.y:0},snapLines:[...l,...c]}},HM=e=>e===Ks.rectangle||e===Ks.ellipse||e===Ks.diamond||e===Ks.frame||e===Ks.magicframe||e===Ks.image||e===Ks.text,UM=class{constructor(e){z(this,`scene`),z(this,`_getRenderableElements`,Ls(({canvasNonce:e,zoom:t,offsetLeft:n,offsetTop:r,scrollX:i,scrollY:a,height:o,width:s,editingTextElement:c,newElement:l})=>{let u=this.scene.getNonDeletedElements(),{elementsMap:d,newElementCanvasElement:f}=this.getRenderableElementsMap({elements:u,editingTextElement:c,newElement:l});return{elementsMap:d,visibleElements:this.getVisibleCanvasElements({elementsMap:d,zoom:t,offsetLeft:n,offsetTop:r,scrollX:i,scrollY:a,height:o,width:s}),newElementCanvasElement:f,canvasNonce:e}})),z(this,`getRenderableElements`,e=>{let{newElement:t}=e,n=`${this.scene.getSceneNonce()}${t?.frameId?`:${t.versionNonce}`:``}`,r=this._getRenderableElements({canvasNonce:n,zoom:e.zoom,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,scrollX:e.scrollX,scrollY:e.scrollY,height:e.height,width:e.width,editingTextElement:e.editingTextElement,newElement:e.newElement});if(e.frameToHighlight&&e.selectedElementsAreBeingDragged&&wn(e.selectedElements)!==e.frameToHighlight.id){let t=this.sortSelectedElementsIntoHighlightedFrame({visibleElements:r.visibleElements,selectedElements:e.selectedElements,frameToHighlight:e.frameToHighlight});return{...r,visibleElements:t}}return r}),this.scene=e}getVisibleCanvasElements({elementsMap:e,zoom:t,offsetLeft:n,offsetTop:r,scrollX:i,scrollY:a,height:o,width:s}){let c=[];for(let l of e.values())ko(l,s,o,{zoom:t,offsetLeft:n,offsetTop:r,scrollX:i,scrollY:a},e)&&c.push(l);return c}getRenderableElementsMap({elements:e,editingTextElement:t,newElement:n}){let r=ie(new Map),i=n?.frameId?null:n;for(let n of e)i?.id!==n.id&&(!t||t.type!==`text`||n.id!==t.id)&&r.set(n.id,n);return{elementsMap:r,newElementCanvasElement:i}}sortSelectedElementsIntoHighlightedFrame({visibleElements:e,selectedElements:t,frameToHighlight:n}){if(!t.length)return e;let r=ui(t),i=e.filter(e=>!r.has(e.id)),a=gt(i,n.id);return a===null?e:[...i.slice(0,a),...t,...i.slice(a)]}destroy(){Za.cancel(),this._getRenderableElements.clear()}},WM=5,GM=(e,t,n)=>{let[r,i]=kc(e,n),{x:a,y:o}=Tn({sceneX:r+e.width,sceneY:i},t);return{x:a-t.offsetLeft+10,y:o-t.offsetTop}},KM=({children:e,element:t,elementsMap:n})=>{let r=uV();if(r.contextMenu||r.newElement||r.resizingElement||r.isRotating||r.openMenu||r.viewModeEnabled)return null;let{x:i,y:a}=GM(t,r,n);return(0,V.jsx)(`div`,{className:`excalidraw-canvas-buttons`,style:{top:`${a}px`,left:`${i}px`,padding:WM},children:e})},qM=e=>t=>{(0,Uc.unstable_batchedUpdates)(e,t)},JM=e=>bi(t=>{(0,Uc.unstable_batchedUpdates)(e,t)}),YM=(()=>{let e;try{let t=B.version.split(`.`);e=Number(t[0])>17}catch{e=!1}let t=!1;return()=>window.EXCALIDRAW_THROTTLE_RENDER===!0?e?!0:(t||(t=!0,console.warn(`Excalidraw: render throttling is disabled on React versions < 18.`)),!1):!1})(),XM=class e{static start(t,n){if(e.animations.has(t))return;let r={animation:n,lastTime:0,state:void 0};e.animations.set(t,r);let i;try{i=n({deltaTime:0,state:void 0})}catch(n){throw e.animations.get(t)===r&&(e.animations.delete(t),e.cancelScheduledFrameIfIdle()),n}if(e.animations.get(t)===r){if(!i){e.animations.delete(t),e.cancelScheduledFrameIfIdle();return}r.state=i,e.scheduleNextFrame()}}static scheduleNextFrame(){e.scheduledFrame||(YM()?e.scheduledFrame={id:requestAnimationFrame(e.tick),type:`raf`}:e.scheduledFrame={id:setTimeout(e.tick,0),type:`timeout`})}static cancelScheduledFrame(){e.scheduledFrame&&=(e.scheduledFrame.type===`raf`?cancelAnimationFrame(e.scheduledFrame.id):clearTimeout(e.scheduledFrame.id),null)}static cancelScheduledFrameIfIdle(){return e.animations.size>0?!1:(e.cancelScheduledFrame(),!0)}static tick(){if(e.scheduledFrame=null,e.animations.size>0){let t=[...e.animations];for(let[n,r]of t){if(e.animations.get(n)!==r)continue;let t=performance.now(),i=r.lastTime===0?0:t-r.lastTime,a=r.animation({deltaTime:i,state:r.state});if(e.animations.get(n)===r){if(a)r.lastTime=t,r.state=a;else if(e.animations.delete(n),e.cancelScheduledFrameIfIdle())return}}if(e.cancelScheduledFrameIfIdle())return;e.scheduleNextFrame()}}static running(t){return e.animations.has(t)}static cancel(t){e.animations.delete(t),e.cancelScheduledFrameIfIdle()}static reset(){e.animations.clear(),e.cancelScheduledFrame()}};z(XM,`scheduledFrame`,null),z(XM,`animations`,new Map);var ZM=XM,QM=class e{constructor(t,n){this.app=t,this.options=n,z(this,`currentTrail`),z(this,`pastTrails`,[]),z(this,`container`),z(this,`trailElement`),z(this,`trailAnimation`),z(this,`key`),this.key=`animated-trail-${e.counter++}`,this.trailElement=document.createElementNS(wi,`path`),this.options.animateTrail&&(this.trailAnimation=document.createElementNS(`http://www.w3.org/2000/svg`,`animate`),this.trailAnimation.setAttribute(`attributeName`,`stroke-dashoffset`),this.trailElement.setAttribute(`stroke-dasharray`,`7 7`),this.trailElement.setAttribute(`stroke-dashoffset`,`10`),this.trailAnimation.setAttribute(`from`,`0`),this.trailAnimation.setAttribute(`to`,`-14`),this.trailAnimation.setAttribute(`dur`,`0.3s`),this.trailElement.appendChild(this.trailAnimation))}get hasCurrentTrail(){return!!this.currentTrail}hasLastPoint(e,t){if(this.currentTrail){let n=this.currentTrail.originalPoints.length;return this.currentTrail.originalPoints[n-1][0]===e&&this.currentTrail.originalPoints[n-1][1]===t}return!1}cleanup(){this.pastTrails=[],this.currentTrail=void 0,this.trailElement.parentNode===this.container&&this.container?.removeChild(this.trailElement)}start(e){e&&(this.container=e),this.trailElement.parentNode!==this.container&&this.container&&this.container.appendChild(this.trailElement),ZM.running(this.key)||ZM.start(this.key,()=>this.onFrame()?{keep:!0}:(this.cleanup(),null))}stop(){ZM.cancel(this.key),this.cleanup()}startPath(e,t){this.currentTrail=new GA(this.options),this.currentTrail.addPoint([e,t,performance.now()]),this.update()}addPointToPath(e,t){this.currentTrail&&(this.currentTrail.addPoint([e,t,performance.now()]),this.update())}endPath(){this.currentTrail&&(this.currentTrail.close(),this.currentTrail.options.keepHead=!1,this.pastTrails.push(this.currentTrail),this.currentTrail=void 0,this.update())}getCurrentTrail(){return this.currentTrail}clearTrails(){this.pastTrails=[],this.currentTrail=void 0,this.update()}update(){this.start(),this.trailAnimation&&(this.trailAnimation.setAttribute(`begin`,`indefinite`),this.trailAnimation.setAttribute(`repeatCount`,`indefinite`))}onFrame(){let e=[];for(let t of this.pastTrails)e.push(this.drawTrail(t,this.app.state));if(this.currentTrail){let t=this.drawTrail(this.currentTrail,this.app.state);e.push(t)}if(this.pastTrails=this.pastTrails.filter(e=>e.getStrokeOutline(e.options.size/this.app.state.zoom.value).length!==0),e.length===0)return this.trailElement.setAttribute(`d`,``),!1;let t=e.join(` `).trim();return this.trailElement.setAttribute(`d`,t),this.trailAnimation?(this.trailElement.setAttribute(`fill`,(this.options.fill??(()=>`black`))(this)),this.trailElement.setAttribute(`stroke`,(this.options.stroke??(()=>`black`))(this))):this.trailElement.setAttribute(`fill`,(this.options.fill??(()=>`black`))(this)),!0}drawTrail(e,t){let n=e.getStrokeOutline(e.options.size/t.zoom.value).map(([e,n])=>{let r=Tn({sceneX:e,sceneY:n},t);return[r.x,r.y]}),r=this.trailAnimation?n.slice(0,n.length/2):n;return vr(r,!0)}};z(QM,`counter`,0);var $M=QM,eN=class{constructor(e){this.app=e,z(this,`localTrail`),z(this,`collabTrails`,new Map),z(this,`container`),this.localTrail=new $M(e,{...this.getTrailOptions(),fill:()=>`red`})}getTrailOptions(){return{simplify:0,streamline:.4,sizeMapping:e=>{let t=Math.max(0,1-(performance.now()-e.pressure)/1e3),n=(50-Math.min(50,e.totalLength-e.currentIndex))/50;return Math.min(pa(n),pa(t))}}}startPath(e,t){this.localTrail.startPath(e,t)}addPointToPath(e,t){this.localTrail.addPointToPath(e,t)}endPath(){this.localTrail.endPath()}start(e){this.container=e,this.localTrail.start(e)}stop(){this.localTrail.stop(),this.stopCollabTrails(),this.container=void 0}stopCollabTrails(e){for(let[t,n]of this.collabTrails)e?.get(t)||(n.stop(),this.collabTrails.delete(t))}updateCollabTrails(e){if(this.stopCollabTrails(e),!(!this.container||e.size===0))for(let[t,n]of e.entries()){if(n.isCurrentUser)continue;let e=this.collabTrails.get(t);if(e||(e=new $M(this.app,{...this.getTrailOptions(),fill:()=>n.pointer?.laserColor||PE(t,n)}),e.start(this.container),this.collabTrails.set(t,e)),n.pointer&&n.pointer.tool===`laser`){let t=n.button===`down`,r=n.button===`up`,i=e.hasCurrentTrail;t&&!i&&e.startPath(n.pointer.x,n.pointer.y);let a=!e.hasLastPoint(n.pointer.x,n.pointer.y);t&&a&&e.addPointToPath(n.pointer.x,n.pointer.y),r&&i&&(e.addPointToPath(n.pointer.x,n.pointer.y),e.endPath())}}}},tN=12,nN=16,rN=10,iN=nN+2,aN=.8,oN=e=>4/e,sN=(e,t,n)=>{let r=oN(t);if(n!==`desktop`||nN>(e.height+r*2)*t*aN)return null;let i=tN/t,a=nN/t,o=L(e.x+e.width/2,e.y+e.height/2),s=Fs(L(o[0]+e.width/2+r+i,o[1]),o,e.angle);return{center:s,start:Fs(L(s[0],s[1]-a/2),s,e.angle),end:Fs(L(s[0],s[1]+a/2),s,e.angle),hitboxWidth:rN/t,hitboxHeight:iN/t}},cN=(e,t,n,r)=>{let i=sN(t,n,r);if(!i)return!1;let a=Fs(L(e.x,e.y),i.center,-t.angle);return Math.abs(a[0]-i.center[0])<=i.hitboxWidth/2&&Math.abs(a[1]-i.center[1])<=i.hitboxHeight/2},lN=(e,t,n,r,i,a)=>{let{zoom:o}=r,s=180*n/Math.PI,c=e*(o.value-1)/2,l=t*(o.value-1)/2;return e>i&&o.value!==1&&(c=i*(o.value-1)/2),t>a&&o.value!==1&&(l=a*(o.value-1)/2),`translate(${c}px, ${l}px) scale(${o.value}) rotate(${s}deg)`},uN=(e,t)=>{let n=e.lastIndexOf(`
|
|
54
|
-
`,Math.max(0,t-1))+1,r=e.indexOf(`
|
|
55
|
-
`,t),i=e.slice(n,r===-1?e.length:r);return Ut(i)?`rtl`:`ltr`},dN=e=>{let t=[0],n=0;for(let r of Array.from(e))n+=r.length,t.push(n);return t},fN=({text:e,font:t,lineHeightPx:n,direction:r,targetX:i})=>{if(!e||!document.body||typeof document.createRange!=`function`)return null;let a=dN(e),o=document.createElement(`div`),s=document.createTextNode(e),c=document.createRange(),l=[];o.dir=r,Object.assign(o.style,{position:`fixed`,top:`0`,left:`0`,margin:0,padding:0,border:0,opacity:`0`,pointerEvents:`none`,whiteSpace:`pre`,font:t,lineHeight:`${n}px`}),o.append(s),document.body.append(o);try{for(let e of a){c.setStart(s,e),c.setEnd(s,e);let t=c.getBoundingClientRect();if(!Number.isFinite(t.left))return null;l.push(t.left)}}catch{return null}finally{o.remove()}let u=Math.min(...l),d=a[0],f=1/0;for(let e=0;e<a.length;e++){let t=Math.abs(l[e]-u-i);t<f&&(f=t,d=a[e])}return d},pN=({onChange:e,onSubmit:t,getViewportCoords:n,element:r,canvas:i,excalidrawContainer:o,app:s,autoSelect:c=!0,initialCaretSceneCoords:l=null})=>{let u=null,d=(e,t)=>{if(!t.style.fontFamily||!t.style.fontSize)return!1;let n=t.style.fontFamily.replace(/"/g,``);return Ns({fontFamily:e.fontFamily})!==n||`${e.fontSize}px`!==t.style.fontSize},f=s.state.theme,p=()=>{f=s.state.theme;let e=s.state,t=s.scene.getElement(r.id);if(!t)return;let{textAlign:i,verticalAlign:o}=t,c=s.scene.getNonDeletedElementsMap();if(t&&a(t)){let r=t.x,a=t.y,l=Go(t,s.scene.getNonDeletedElementsMap()),f=t.width,p=t.height,h=t.width,g=t.height;if(l&&t.containerId){if(_(l)){let e=N.getBoundTextElementPosition(l,t,c);r=e.x,a=e.y}let e=d(t,m),n;if(e?n=vn(l.id,l.height):(n=zn[l.id],n||=vn(l.id,l.height)),h=Te(l,t),g=ms(l,t),!_(l)&&p>g){let e=yo(p,l.type);s.scene.mutateElement(l,{height:e}),La(l,s.scene);return}if(!_(l)&&l.height>n.height&&p<g){let e=yo(p,l.type);s.scene.mutateElement(l,{height:e}),La(l,s.scene)}else{let{x:e,y:n}=_i(l,t,c);r=e,a=n}}let[v,y]=n(r,a);l?f+=.5:(h=(e.width-8-v)/e.zoom.value,f=Math.min(f,h)),p*=1.05;let b=tc(t),x=xe(t,l),S=(e.height-y)/e.zoom.value;Object.assign(m.style,{font:b,lineHeight:t.lineHeight,width:`${f}px`,height:`${p}px`,left:`${v}px`,top:`${y}px`,transform:lN(f,p,x,e,h,S),textAlign:i,verticalAlign:o,color:kt(t.strokeColor,e.theme===A.DARK),opacity:t.opacity/100,maxHeight:`${S}px`}),u={angle:x,font:b,height:t.height,lineHeightPx:Fr(t.fontSize,t.lineHeight),textAlign:i,width:t.width,x:r,y:a},m.scrollTop=0,fc()&&(m.style.fontFamily=Ns(t)),s.scene.mutateElement(t,{x:r,y:a})}},m=document.createElement(`textarea`);m.dir=`auto`,m.tabIndex=0,m.dataset.type=`wysiwyg`,m.wrap=`off`,m.classList.add(`excalidraw-wysiwyg`);let h=`pre`,g=`normal`;(cs(r)||!r.autoResize)&&(h=`pre-wrap`,g=`break-word`),Object.assign(m.style,{position:`absolute`,display:`inline-block`,minHeight:`1em`,backfaceVisibility:`hidden`,margin:0,padding:0,border:0,outline:0,resize:`none`,background:`transparent`,overflow:`hidden`,zIndex:`var(--zIndex-wysiwyg)`,wordBreak:g,whiteSpace:h,overflowWrap:`break-word`,boxSizing:`content-box`}),m.value=r.originalText,p();let v=()=>{if(!l||!u)return null;let e=u,t=L(e.x+e.width/2,e.y+e.height/2),[n,r]=Fs(L(l.x,l.y),t,-e.angle),i=n-e.x,a=r-e.y,o=$t(m.value,e.font,h===`pre-wrap`?e.width:1/0),s=o[Math.max(0,Math.min(o.length-1,Math.floor(a/e.lineHeightPx)))],c=uN(m.value,s.start),d=No(s.text,e.font),f=i-(e.textAlign===`center`?(e.width-d)/2:e.textAlign===`right`?e.width-d:0);if(!s.text)return s.start;let p=fN({text:s.text,font:e.font,lineHeightPx:e.lineHeightPx,direction:c,targetX:f});return s.start+(p||0)},y=(()=>{let e=v();return e===null?null:{start:e,end:e}})();e&&(m.onpaste=async e=>{let t=nE(e),n=null;if(t.has(M.excalidrawClipboard)||t.has(M.excalidraw)){e.preventDefault(),n=await rE(e);try{let e=await iE(n);if(e.elements){let t=Bs(e.elements);if(t){let{selectionStart:e,selectionEnd:n,value:r}=m;m.value=r.slice(0,e)+t+r.slice(n);let i=e+t.length;m.selectionStart=m.selectionEnd=i,m.dispatchEvent(new Event(`input`))}}return}catch{console.warn(`failed to parse excalidraw clipboard data`)}}n||=await rE(e);let i=n.findByType(M.text);if(!i)return;let a=ze(i.value);if(!a)return;let o=Go(r,s.scene.getNonDeletedElementsMap()),c=tc({fontSize:s.state.currentItemFontSize,fontFamily:s.state.currentItemFontFamily});if(o){let e=Ti(o,s.scene.getNonDeletedElementsMap()),t=qr(`${m.value}${a}`,c,Te(o,e)),n=ho(t,c);m.style.width=`${n}px`}},m.oninput=()=>{let t=ze(m.value);if(m.value!==t){let e=m.selectionStart;m.value=t,m.selectionStart=e,m.selectionEnd=e}e(m.value)}),m.onkeydown=e=>{if(!e.shiftKey&&oT.keyTest(e))e.preventDefault(),s.actionManager.executeAction(oT),p();else if(!e.shiftKey&&sT.keyTest(e))e.preventDefault(),s.actionManager.executeAction(sT),p();else if(!e.shiftKey&&cT.keyTest(e))e.preventDefault(),s.actionManager.executeAction(cT),p();else if(Jw.keyTest(e))s.actionManager.executeAction(Jw);else if(Yw.keyTest(e))s.actionManager.executeAction(Yw);else if(e.key===j.ESCAPE)e.preventDefault(),E=!0,O();else if(bE.keyTest(e))e.preventDefault(),O(),s.actionManager.executeAction(bE);else if(e.key===j.ENTER&&e[j.CTRL_OR_CMD]){if(e.preventDefault(),e.isComposing||e.keyCode===229)return;E=!0,O()}else if(e.key===j.TAB||e[j.CTRL_OR_CMD]&&(e.code===I.BRACKET_LEFT||e.code===I.BRACKET_RIGHT)){if(e.preventDefault(),e.isComposing)return;e.shiftKey||e.code===I.BRACKET_LEFT?C():S(),m.dispatchEvent(new Event(`input`))}};let b=` `.repeat(4),x=RegExp(`^ {1,4}`),S=()=>{let{selectionStart:e,selectionEnd:t}=m,n=w(),r=m.value;n.forEach(e=>{let t=r.slice(0,e),n=r.slice(e);r=`${t}${b}${n}`}),m.value=r,m.selectionStart=e+4,m.selectionEnd=t+4*n.length},C=()=>{let{selectionStart:e,selectionEnd:t}=m,n=w(),r=[],i=m.value;n.forEach(e=>{let t=i.slice(e,e+4).match(x);t&&(i=`${i.slice(0,e)}${i.slice(e+t[0].length)}`,r.push(e))}),m.value=i,r.length&&(e>r[r.length-1]?m.selectionStart=Math.max(e-4,r[r.length-1]):m.selectionStart=e,m.selectionEnd=Math.max(m.selectionStart,t-4*r.length))},w=()=>{let{selectionStart:e,selectionEnd:t,value:n}=m,r=n.slice(0,e).match(/[^\n]*$/)[0].length;return e-=r,n.slice(e,t).split(`
|
|
56
|
-
`).reduce((t,n,r,i)=>t.concat(r?t[r-1]+i[r-1].length+1:e),[]).reverse()},T=e=>{e.target instanceof HTMLCanvasElement&&(e.preventDefault(),e.stopPropagation())},E=!1,O=()=>{if(oe)return;oe=!0,ee();let e=s.scene.getElement(r.id);if(!e)return;let n=Go(e,s.scene.getNonDeletedElementsMap());if(n){if(m.value.trim()){let e=Ce(n);!e||e!==r.id?s.scene.mutateElement(n,{boundElements:(n.boundElements||[]).concat({type:`text`,id:r.id})}):_(n)&&Ue(n)}else s.scene.mutateElement(n,{boundElements:n.boundElements?.filter(e=>!a(e))});Sa(e,n,s.scene)}t({viaKeyboard:E,nextOriginalText:m.value})},ee=()=>{m.onblur=null,m.oninput=null,m.onkeydown=null,se&&se.disconnect(),window.removeEventListener(`resize`,p),window.removeEventListener(`wheel`,T,!0),window.removeEventListener(`pointerdown`,ne),window.removeEventListener(`pointerup`,k),window.removeEventListener(`blur`,O),window.removeEventListener(`beforeunload`,O),ie(),re(),ae(),m.remove()},k=e=>{window.removeEventListener(`pointerup`,k);let t=e?.target,n=t instanceof HTMLElement&&t.classList.contains(`properties-trigger`),r=(t instanceof HTMLElement||t instanceof SVGElement)&&!!t.closest(`.properties-content`),i=(t instanceof HTMLElement||t instanceof SVGElement)&&(!!t.closest(`.${D.SHAPE_ACTIONS_MENU}`)||!!t.closest(`.compact-shape-actions-island`));setTimeout(()=>{i||n||r||(m.onblur=O,m.focus(),y&&=(m.setSelectionRange(y.start,y.end),null))})},te=()=>{m.onblur=null,window.addEventListener(`pointerup`,k),window.addEventListener(`blur`,O)},ne=e=>{let t=e?.target;if(e.button===je.WHEEL){t instanceof HTMLTextAreaElement&&(e.preventDefault(),s.handleCanvasPanUsingWheelOrSpaceDrag(e)),te();return}let n=t instanceof HTMLElement&&t.classList.contains(`properties-trigger`),r=(t instanceof HTMLElement||t instanceof SVGElement)&&!!t.closest(`.properties-content`);(e.target instanceof HTMLElement||e.target instanceof SVGElement)&&(e.target.closest(`.${D.SHAPE_ACTIONS_MENU}, .${D.ZOOM_ACTIONS}`)||e.target.closest(`.compact-shape-actions-island`))&&!de(e.target)||n||r?te():e.target instanceof HTMLCanvasElement&&!fc()&&requestAnimationFrame(()=>{O()})},re=s.onChangeEmitter.on(e=>{s.state.theme!==f&&p()}),ie=s.scene.onUpdate(()=>{p(),document.activeElement?.closest(`.properties-content`)||m.focus()}),ae=s.onScrollChangeEmitter.on(()=>{p()}),oe=!1;c&&!y&&m.select(),k();let se=null;return i&&`ResizeObserver`in window?(se=new window.ResizeObserver(()=>{p()}),se.observe(i)):window.addEventListener(`resize`,p),m.onpointerdown=e=>e.stopPropagation(),requestAnimationFrame(()=>{window.addEventListener(`pointerdown`,ne,{capture:!0})}),window.addEventListener(`beforeunload`,O),o?.querySelector(`.excalidraw-textEditorContainer`).appendChild(m),O},mN=4,hN=6,gN=`rgba(0,0,0,0.3)`,_N=(e,t,n,r)=>{if(!e.size)return{horizontal:null,vertical:null};let[i,a,o,s]=Is(e),c=t/r.zoom.value,l=n/r.zoom.value,u={top:parseInt(sc(`sat`))||0,bottom:parseInt(sc(`sab`))||0,left:parseInt(sc(`sal`))||0,right:parseInt(sc(`sar`))||0},d=Ry().rtl,f=-r.scrollX+u.left,p=-r.scrollY+u.top,m=f+c-u.right,h=p+l-u.bottom,g=Math.min(i,f),_=Math.min(a,p),v=Math.max(o,m),y=Math.max(s,h),b=o-i,x=s-a,S=v-g,C=y-_,w=Math.max(mN*2,u.left+u.right)+hN*2,T=c/S*t-w,E=Math.max(mN*2,u.top+u.bottom)+hN*2,D=l/C*n-E,O=S>b?S*r.zoom.value/(T+w):t/(T+w),ee=C>x?C*r.zoom.value/(D+E):n/(D+E);return{horizontal:f===g&&m===v?null:{x:Math.max(u.left,mN)+hN+(f-g)/S*t,y:n-hN-Math.max(mN,u.bottom),width:T,height:hN,deltaMultiplier:O},vertical:p===_&&h===y?null:{x:d?Math.max(u.left,mN):t-hN-Math.max(u.right,mN),y:Math.max(u.top,mN)+hN+(p-_)/C*n,width:hN,height:D,deltaMultiplier:ee}}},vN=(e,t,n)=>{let[r,i]=[e.horizontal,e.vertical].map(e=>e!=null&&e.x<=t&&t<=e.x+e.width&&e.y<=n&&n<=e.y+e.height);return{isOverEither:r||i,isOverHorizontal:r,isOverVertical:i}},yN=e=>RegExp(`^(?:%%{.*?}%%[\\s\\n]*)?\\b(?:${[`flowchart`,`graph`,`sequenceDiagram`,`classDiagram`,`stateDiagram`,`stateDiagram-v2`,`erDiagram`,`journey`,`gantt`,`pie`,`quadrantChart`,`requirementDiagram`,`gitGraph`,`C4Context`,`mindmap`,`timeline`,`zenuml`,`sankey`,`xychart`,`block`].map(e=>`\\s*${e}(-beta)?`).join(`|`)})\\b`).test(e.trim()),bN=e=>{let{lassoPath:t,elements:n,elementsMap:r,elementsSegments:i,intersectedElements:a,enclosedElements:o,simplifyDistance:s}=e,c=t;s&&(c=Lv(t,s));let l=n.filter(e=>!e.locked);o.clear(),a.clear();let u=t.reduce((e,t)=>[Math.min(e[0],t[0]),Math.min(e[1],t[1]),Math.max(e[2],t[0]),Math.max(e[3],t[1])],[1/0,1/0,-1/0,-1/0]);for(let e of l){let t=Zt(e,r);Yr(u,t)&&!a.has(e.id)&&!o.has(e.id)&&(xN(c,e,i)?o.add(e.id):SN(c,e,r)&&a.add(e.id))}return{selectedElementIds:[...a,...o]}},xN=(e,t,n)=>{let r=vc(e),i=n.get(t.id);return i?i.some(e=>e.some(e=>$i(e,r))):!1},SN=(e,t,n)=>{let r=e.slice(1).map((t,n)=>ka(e[n],t)).concat([ka(e[e.length-1],e[0])]),i=Ti(t,n);return r.some(e=>ws(t,n,e,0,!0).length>0||!!i&&ws({...i,..._i(t,i,n)},n,e,0,!0).length>0)},CN=class extends $M{constructor(e){super(e,{animateTrail:!0,streamline:.4,sizeMapping:e=>{let t=Math.max(0,1-(performance.now()-e.pressure)/(1/0)),n=(5e3-Math.min(5e3,e.totalLength-e.currentIndex))/5e3;return Math.min(pa(n),pa(t))},fill:()=>`rgba(105,101,219,0.05)`,stroke:()=>`rgba(105,101,219)`}),z(this,`intersectedElements`,new Set),z(this,`enclosedElements`,new Set),z(this,`elementsSegments`,null),z(this,`canvasTranslate`,null),z(this,`keepPreviousSelection`,!1),z(this,`selectElementsFromIds`,e=>{this.app.setState(t=>{let n=e.reduce((e,t)=>(e[t]=!0,e),{});if(this.keepPreviousSelection)for(let e of Object.keys(t.selectedElementIds))n[e]=!0;for(let[e]of Object.entries(n)){let t=this.app.scene.getNonDeletedElement(e);if(t&&a(t)){let e=Go(t,this.app.scene.getNonDeletedElementsMap());e&&(n[e.id]=!0,delete n[t.id])}}for(let[e]of Object.entries(n)){let t=this.app.scene.getNonDeletedElement(e);if(t&&P(t)){let e=Yn(this.app.scene.getNonDeletedElementsMap(),t.id);for(let t of e)delete n[t.id]}}let r=na({editingGroupId:t.editingGroupId,selectedElementIds:n},this.app.scene.getNonDeletedElements(),t,this.app),i=[...Object.keys(r.selectedElementIds)],o=[...Object.keys(r.selectedGroupIds)];return{selectedElementIds:r.selectedElementIds,selectedGroupIds:r.selectedGroupIds,selectedLinearElement:i.length===1&&!o.length&&po(this.app.scene.getNonDeletedElement(i[0]))?new N(this.app.scene.getNonDeletedElement(i[0]),this.app.scene.getNonDeletedElementsMap()):null}})}),z(this,`addPointToPath`,(e,t,n=!1)=>{super.addPointToPath(e,t),this.keepPreviousSelection=n,this.updateSelection()}),z(this,`updateSelection`,()=>{let e=super.getCurrentTrail()?.originalPoints?.map(e=>L(e[0],e[1])),t={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom.value};if(!this.elementsSegments||!S(t,this.canvasTranslate??{})){this.canvasTranslate=t,this.elementsSegments=new Map;let e=ui(this.app.visibleElements);for(let t of this.app.visibleElements){let n=si(t,e);this.elementsSegments.set(t.id,n)}}if(e){let{selectedElementIds:t}=bN({lassoPath:e,elements:this.app.visibleElements,elementsMap:this.app.scene.getNonDeletedElementsMap(),elementsSegments:this.elementsSegments,intersectedElements:this.intersectedElements,enclosedElements:this.enclosedElements,simplifyDistance:5/this.app.state.zoom.value});this.selectElementsFromIds(t)}})}startPath(e,t,n=!1){this.endPath(),super.startPath(e,t),this.intersectedElements.clear(),this.enclosedElements.clear(),this.keepPreviousSelection=n,this.keepPreviousSelection||this.app.setState({selectedElementIds:{},selectedGroupIds:{},selectedLinearElement:null})}endPath(){super.endPath(),super.clearTrails(),this.intersectedElements.clear(),this.enclosedElements.clear(),this.elementsSegments=null}},wN=class extends $M{constructor(e){super(e,{streamline:.2,size:5,keepHead:!0,sizeMapping:e=>{let t=Math.max(0,1-(performance.now()-e.pressure)/200),n=(10-Math.min(10,e.totalLength-e.currentIndex))/10;return Math.min(pa(n),pa(t))},fill:()=>e.state.theme===A.LIGHT?`rgba(0, 0, 0, 0.2)`:`rgba(255, 255, 255, 0.2)`}),z(this,`elementsToErase`,new Set),z(this,`groupsToErase`,new Set)}startPath(e,t){this.endPath(),super.startPath(e,t),this.elementsToErase.clear()}addPointToPath(e,t,n=!1){return super.addPointToPath(e,t),this.updateElementsToBeErased(n)}updateElementsToBeErased(e){let t=super.getCurrentTrail()?.originalPoints?.map(e=>L(e[0],e[1]))||[];if(t.length<2)return[];let n=ka(t[t.length-1],t[t.length-2]),r=this.app.visibleElements.filter(e=>!e.locked),i=ui(r);for(let t of r)if(e&&this.elementsToErase.has(t.id)){if(TN(n,t,i,this.app.state.zoom.value)){let e=t.groupIds.at(-1);if(this.groupsToErase.has(e)){let t=yt(this.app.scene.getNonDeletedElementsMap(),e);for(let e of t)this.elementsToErase.delete(e.id);this.groupsToErase.delete(e)}if(cs(t)&&this.elementsToErase.delete(t.containerId),Dr(t)){let e=Ce(t);e&&this.elementsToErase.delete(e)}this.elementsToErase.delete(t.id)}}else if(!e&&!this.elementsToErase.has(t.id)&&TN(n,t,i,this.app.state.zoom.value)){let e=t.groupIds.at(-1);if(!this.groupsToErase.has(e)){let t=yt(this.app.scene.getNonDeletedElementsMap(),e);for(let e of t)this.elementsToErase.add(e.id);this.groupsToErase.add(e)}if(Dr(t)){let e=Ce(t);e&&this.elementsToErase.add(e)}cs(t)&&this.elementsToErase.add(t.containerId),this.elementsToErase.add(t.id)}return Array.from(this.elementsToErase)}endPath(){super.endPath(),super.clearTrails(),this.elementsToErase.clear(),this.groupsToErase.clear()}},TN=(e,t,n,r)=>{let i=e[1],a=os(t)?15:t.strokeWidth/2,o=[Math.min(e[0][0],e[1][0])-a,Math.min(e[0][1],e[1][1])-a,Math.max(e[0][0],e[1][0])+a,Math.max(e[0][1],e[1][1])+a],s=Zt(t,n),c=[s[0]-a,s[1]-a,s[2]+a,s[3]+a];if(!Yr(o,c))return!1;if(At(t)&&Wn(i,t,n))return!0;if(os(t)){let i=Qi(t),a=Je(t,i,n),o=Math.max(2.25,5/r);for(let t of a)if(Mo(t,e)<=o)return!0;let s=Gs(...i.map(([e,n])=>L(t.x+e,t.y+n)));return!!$i(e[0],s)}let l=Ti(t,n);if(_(t)||Oe(t)&&!t.polygon){let i=Math.max(t.strokeWidth,t.strokeWidth*2/r),a=si(t,n);for(let t of a)if(Mo(t,e)<=i)return!0;return!1}return ws(t,n,e,0,!0).length>0||!!l&&ws({...l,..._i(t,l,n)},n,e,0,!0).length>0},EN=44,DN=22,ON=66,kN=48,AN=14,jN=304,MN=320,NN=5.87,PN=28,FN=4,IN=2,LN=10,RN=10,zN=8,BN=12,VN=256,HN=10,UN=4,WN=BN*2,GN=BN*2,KN=100,qN=140,JN=.35,YN=BN/2,XN=20,ZN=BN*2,QN=BN,$N={fillStyle:`hachure`,fontFamily:yc,fontSize:20,opacity:100,roughness:1,strokeColor:Ye.black,roundness:null,strokeStyle:`solid`,strokeWidth:1,verticalAlign:Pn.MIDDLE,locked:!1},eP=be(4),tP=e=>e.labels?.length??e.series[0]?.values.length??0,nP=(e,t)=>{if(!e)return!1;let n=tP(e);return n<2?!1:t!==`radar`||n>=3},rP=(e,t)=>e+(t<=1?0:Math.min(ON,(t-1)*DN)),iP=(e,t)=>{if(e===`line`){let e=rP(kN,t);return{slotWidth:e,gap:AN,chartHeight:MN,xLabelMaxWidth:e+AN*3+LN}}let n=rP(EN,t);return{slotWidth:n,gap:AN,chartHeight:jN,xLabelMaxWidth:n+AN*3+LN}},aP=(e,t)=>({chartWidth:(t.slotWidth+t.gap)*e.series[0].values.length+t.gap,chartHeight:t.chartHeight+t.gap*2}),oP=()=>({chartWidth:VN+GN*2,chartHeight:VN+GN*2}),sP=(e,t,n)=>{let r=Math.abs(e-t);return Math.min(r,n-r)},cP=(e,t)=>{if(e<=0||eP.length===0)return[];let n=eP.length,r=(t%n+n)%n,i=[r],a=Math.min(e,n),o=new Set(Array.from({length:n},(e,t)=>t).filter(e=>e!==r));for(;i.length<a;){let e=-1,t=-1,r=-1;for(let a of o){let o=i.map(e=>sP(a,e,n)),s=Math.min(...o),c=o.reduce((e,t)=>e+t,0)/o.length;(s>t||s===t&&c>r)&&(e=a,t=s,r=c)}i.push(e),o.delete(e)}return Array.from({length:e},(e,t)=>eP[i[t%i.length]])},lP=e=>{if(eP.length===0)return 0;if(typeof e!=`number`||!Number.isFinite(e))return Math.floor(Math.random()*eP.length);let t=e.toString(),n=0;for(let e=0;e<t.length;e++)n=n*31+t.charCodeAt(e)|0;return Math.abs(n)%eP.length},uP=e=>eP[e],dP=(e,t)=>{let n=e.flatMap(e=>e.values.map(e=>Math.max(0,e))),r=n.filter(e=>e>0),i=Math.max(1,...n),a=r.length>0?Math.min(...r):1,o=e.length===1&&a>0&&i/a>=KN;return{renderSteps:!1,normalize:(e,t)=>{let n=Math.max(0,e);return o?Math.log10(n+1)/Math.log10(i+1):n/i}}},fP=e=>/\s/.test(e.trim()),pP=(e,t,n)=>fP(e)?qr(e,t,n):e,mP=(e,t,n,r,i,a)=>{let o=Na.Excalifont,s=Qn.sm,c=zs(o),l=tc({fontFamily:o,fontSize:s}),u=Math.min(qN,i*(e.length>8?.56:.72)),d=Sn(l,c),f=e.map((e,f)=>{let p=t[f],m=Math.max(0,...e.trim().split(/\s+/).filter(Boolean).map(e=>uo(e,l,c).width)),h=pP(e,l,Math.max(d,u,m)),g=uo(h,l,c),_=Math.cos(p),v=Math.sin(p),y=_>JN?`left`:_<-JN?`right`:`center`,b=y===`center`?g.width/2:0,x=WN+(Math.abs(_)*b+Math.abs(v)*(g.height/2))+YN,S=n+_*(i+x),C=r+v*(i+x),w=v>JN?BN/3:v<-JN?-BN/3:0;return oc({backgroundColor:a,...$N,text:h,originalText:e,x:S,y:C+w,fontFamily:o,fontSize:s,lineHeight:c,textAlign:y,verticalAlign:`middle`})});return{axisLabels:f,axisLabelTopY:Math.min(...f.map(e=>e.y)),axisLabelBottomY:Math.max(...f.map(e=>e.y+e.height))}},hP=(e,t,n,r,i,a)=>{if(e.length<=1)return[];let o=Na[`Lilita One`],s=Qn.lg,c=zs(o),l=tc({fontFamily:o,fontSize:s}),u=e.map((e,n)=>{let r=e.title?.trim()||`Series ${n+1}`,i=pP(r,l,VN),a=uo(i,l,c),o=XN+QN+a.width;return{label:r,displayLabel:i,color:t[n],width:o,height:a.height}}),d=Math.max(XN/2,...u.map(e=>e.height/2)),f=Math.max(i,r+d+WN),p=ZN,m=XN*.6,h=u.reduce((e,t)=>e+t.width,0)+ZN*Math.max(0,u.length-1),g=h+p*2,_=d*2+m*2,v=[];v.push(pc({...$N,backgroundColor:`transparent`,type:`rectangle`,fillStyle:`solid`,strokeColor:Ye.black,x:n-g/2,y:f-_/2,width:g,height:_,roughness:da.architect,roundness:{type:Jr.PROPORTIONAL_RADIUS}}));let y=n-h/2;return u.forEach(e=>{v.push(pc({...$N,backgroundColor:e.color,type:`rectangle`,x:y,y:f-XN/2,width:XN,height:XN,fillStyle:`solid`,strokeColor:e.color,roughness:da.architect,roundness:{type:Jr.PROPORTIONAL_RADIUS}})),v.push(oc({...$N,text:e.displayLabel,originalText:e.label,autoResize:!1,x:y+XN+QN,y:f,fontFamily:o,fontSize:s,lineHeight:c,textAlign:`left`,verticalAlign:`middle`})),y+=e.width+ZN}),v},gP=(e,t,n,r)=>{if(uo(e,n,r).width<=t)return e;let i=e.length;for(;i>1;){let a=`${e.slice(0,i)}...`;if(uo(a,n,r).width<=t)return a;i--}return e[0]?`${e[0]}...`:e},_P=(e,t,n,r)=>{if(uo(e,n,r).width<=t)return{wrapped:!1,text:e};let i=e.trim().split(/\s+/).filter(Boolean);return i.length>1&&!i.some(e=>uo(e,n,r).width>t)&&t>=Sn(n,r)?{wrapped:!0,text:qr(e,n,t)}:{wrapped:!1,text:gP(e,t,n,r)}},vP=(e,t,n)=>{let r=Math.abs(Math.cos(n)),i=Math.abs(Math.sin(n));return{width:e*r+t*i,height:e*i+t*r}},yP=e=>e.includes(`...`),bP=(e,t,n,r,i)=>{let a=Math.max(PN,Math.ceil(Sn(r,i))),o=Math.max(a,Math.floor(t)),s=[];for(let e=o;e>=a;e-=4)s.push(e);s[s.length-1]!==a&&s.push(a);let c=e=>({ellipsified:yP(e.text),visibleChars:e.text.replace(/\.\.\./g,``).replace(/\n/g,``).length,lineCount:e.text.split(`
|
|
57
|
-
`).length}),l=(e,t)=>{let n=c(e),r=c(t);return n.ellipsified===r.ellipsified?n.visibleChars===r.visibleChars?n.lineCount===r.lineCount?e.rotatedHeight<t.rotatedHeight:n.lineCount<r.lineCount:n.visibleChars>r.visibleChars:!n.ellipsified},u=null,d=null,f=null;for(let t of s){let{wrapped:a,text:o}=_P(e,t,r,i),s=uo(o,r,i),c=vP(s.width,s.height,NN),p={originalText:e,text:o,metrics:s,rotatedWidth:c.width,rotatedHeight:c.height,wrapped:a},m=c.width-n;if(m<=0){(!u||l(p,u))&&(u=p);continue}(!d||m<d.overflow||m===d.overflow&&l(p,d.spec))&&(d={overflow:m,spec:p}),!yP(p.text)&&(!f||m<f.overflow||m===f.overflow&&l(p,f.spec))&&(f={overflow:m,spec:p})}return u||(f&&d&&f.overflow<=d.overflow+zN?f.spec:d.spec)},xP=e=>{if(e.type!==`text`)return e.y+e.height;let t=vP(e.width,e.height,e.angle);return e.y+e.height/2+t.height/2},SP=(e,t,n,r,i)=>{let a=$N.fontFamily,o=Qn.sm,s=zs(a),c=tc({fontFamily:a,fontSize:o}),l=Math.max(1,i.slotWidth+i.gap-FN*2+RN),u=n;return e.labels?.map((e,n)=>{let a=bP(e,i.xLabelMaxWidth,l,c,s),d=t+n*(i.slotWidth+i.gap)+i.gap+i.slotWidth/2,f=u+IN+(a.rotatedHeight-a.metrics.height)/2;return oc({backgroundColor:r,...$N,text:a.text,originalText:a.wrapped?e:a.text,autoResize:!a.wrapped,x:d,y:f,angle:NN,fontSize:o,lineHeight:s,textAlign:`center`,verticalAlign:`top`})})||[]},CP=(e,t,n,r,i,a=Math.max(...e.series[0].values))=>{let o=oc({backgroundColor:r,...$N,x:t-i.gap,y:n-i.gap,text:`0`,textAlign:`right`});return[o,oc({backgroundColor:r,...$N,x:t-i.gap,y:n-i.chartHeight-o.height/2,text:a.toLocaleString(),textAlign:`right`})]},wP=(e,t,n,r,i)=>{let{chartWidth:a,chartHeight:o}=aP(e,i);return[re({backgroundColor:r,...$N,type:`line`,x:t,y:n,width:a,points:[L(0,0),L(a,0)]}),re({backgroundColor:r,...$N,type:`line`,x:t,y:n,height:o,points:[L(0,0),L(0,-o)]}),re({backgroundColor:r,...$N,type:`line`,x:t,y:n-i.chartHeight-i.gap,strokeStyle:`dotted`,width:a,opacity:HN,points:[L(0,0),L(a,0)]})]},TP=(e,t,n,r,i,a=Math.max(...e.series[0].values),o)=>{let{chartWidth:s,chartHeight:c}=aP(e,i),l=e.title?oc({backgroundColor:r,...$N,text:e.title,x:t+s/2,y:n-i.chartHeight-i.gap*2-20,roundness:null,textAlign:`center`,fontSize:Qn.xl,fontFamily:Na[`Lilita One`]}):null,u=o?pc({backgroundColor:r,...$N,type:`rectangle`,x:t,y:n-c,width:s,height:c,strokeColor:Ye.black,fillStyle:`solid`,opacity:6}):null;return[...u?[u]:[],...l?[l]:[],...SP(e,t,n,r,i),...CP(e,t,n,r,i,a),...wP(e,t,n,r,i)]},EP=(e,t,n,r)=>{let i=e.series,a=iP(`bar`,i.length),o=Math.max(1,...i.flatMap(e=>e.values.map(e=>Math.max(0,e)))),s=lP(r),c=uP(s),l=cP(i.length,s),u=i.length>1?Math.max(1,Math.floor(a.gap/(i.length+1))):0,d=i.length>1?Math.max(2,(a.slotWidth-u*(i.length-1))/i.length):a.slotWidth,f=i.length*d+u*(i.length-1),p=(a.slotWidth-f)/2,m=i[0].values.flatMap((e,r)=>i.map((e,s)=>{let f=Math.max(0,e.values[r]??0)/o*a.chartHeight,m=i.length>1?l[s]:c;return pc({backgroundColor:m,...$N,type:`rectangle`,fillStyle:i.length>1?`solid`:$N.fillStyle,strokeColor:i.length>1?m:$N.strokeColor,x:t+r*(a.slotWidth+a.gap)+a.gap+p+s*(d+u),y:n-f-a.gap,width:d,height:f})})),h=TP(e,t,n,c,a,o,ci()),g=SP(e,t,n,c,a),_=Math.max(n+a.gap/2,...g.map(e=>xP(e))),{chartWidth:v}=aP(e,a),y=hP(i,l,t+v/2,_,n+a.gap*5,c);return[...h,...m,...y]},DP=(e,t,n,r)=>{let i=e.series,a=iP(`line`,i.length),o=Math.max(1,...i.flatMap(e=>e.values)),s=lP(r),c=uP(s),l=cP(i.length,s),u=i.map((e,r)=>{let i=e.values.map((e,t)=>L(t*(a.slotWidth+a.gap),-(e/o)*a.chartHeight)),s=Math.max(...i.map(e=>e[0])),c=Math.max(...i.map(e=>e[1])),u=Math.min(...i.map(e=>e[0])),d=Math.min(...i.map(e=>e[1]));return re({backgroundColor:`transparent`,...$N,type:`line`,x:t+a.gap+a.slotWidth/2,y:n-a.gap,height:c-d,width:s-u,strokeColor:l[r],strokeWidth:2,points:i})}),d=i.flatMap((e,r)=>e.values.map((e,i)=>{let s=i*(a.slotWidth+a.gap)+a.gap/2,c=-(e/o)*a.chartHeight+a.gap/2;return pc({backgroundColor:l[r],...$N,fillStyle:`solid`,strokeColor:l[r],strokeWidth:2,type:`ellipse`,x:t+s+a.slotWidth/2,y:n+c-a.gap*2,width:a.gap,height:a.gap})})),f=i[0].values.map((e,t)=>Math.max(0,...i.map(e=>e.values[t]??0))).map((e,r)=>{let i=r*(a.slotWidth+a.gap)+a.gap/2,s=e/o*a.chartHeight+a.gap/2+a.gap;return re({backgroundColor:c,...$N,type:`line`,x:t+i+a.slotWidth/2+a.gap/2,y:n-s,height:s,strokeStyle:`dotted`,opacity:HN,points:[L(0,0),L(0,s)]})}),p=TP(e,t,n,c,a,o,ci()),m=SP(e,t,n,c,a),h=Math.max(n+a.gap/2,...m.map(e=>xP(e))),{chartWidth:g}=aP(e,a),_=hP(i,l,t+g/2,h,n+a.gap*5,c);return[...p,...u,...f,...d,..._]},OP=e=>{let t=/^([-+]?)[$\u20AC\u00A3\u00A5\u20A9]?([-+]?)([\d.,]+)[%]?$/.exec(e);return t?parseFloat(`${(t[1]||t[2])+t[3]}`.replace(/,/g,``)):null},kP=(e,t)=>e.slice(1).every(e=>OP(e[t])!==null),AP=e=>{let t=e[0].length;if(t>2){let n=e[0].every(e=>OP(e)===null),r=n?e.slice(1):e;if(r.length<1)return{ok:!1,reason:`No data rows`};if(r.some(e=>e.slice(1).some(e=>OP(e)===null)))return{ok:!1,reason:`Value is not numeric`};if(t-1>r.length){let t=n?e[0].slice(1).map(e=>e.trim()):null,i=r.map(e=>({title:e[0]?.trim()||null,values:e.slice(1).map(e=>OP(e))}));return{ok:!0,data:{title:i.length===1?i[0].title:n&&e[0][0].trim()||null,labels:t,series:i}}}let i=e[0].slice(1).map((e,t)=>{let i=t+1,a=`Series ${i}`;return{title:n&&e.trim()||a,values:r.map(e=>OP(e[i]))}});return{ok:!0,data:{title:n&&e[0][0].trim()||null,labels:r.map(e=>e[0]),series:i}}}if(t===1){if(!kP(e,0))return{ok:!1,reason:`Value is not numeric`};let t=OP(e[0][0])===null,n=t?e[0][0]:null,r=(t?e.slice(1):e).map(e=>OP(e[0]));return r.length<2?{ok:!1,reason:`Less than two rows`}:{ok:!0,data:{title:n,labels:null,series:[{title:n,values:r}]}}}let n=OP(e[0][1])===null,r=n?e.slice(1):e;if(r.length<2)return{ok:!1,reason:`Less than 2 rows`};if(r.some(e=>OP(e[1])===null))return{ok:!1,reason:`Value is not numeric`};let i=n?e[0][1]:null;return{ok:!0,data:{title:i,labels:r.map(e=>e[0]),series:[{title:i,values:r.map(e=>OP(e[1]))}]}}},jP=e=>{let t=t=>e.replace(/\r\n?/g,`
|
|
58
|
-
`).split(`
|
|
59
|
-
`).filter(e=>e.trim().length>0).map(e=>e.split(t).map(e=>e.trim())),n=[` `,`,`,`;`].map(e=>{let n=t(e),r=n[0]?.length??0;return{delimiter:e,parsed:n,numCols:r,isConsistent:n.length>0&&n.every(e=>e.length===r)}}),r=(n.find(e=>e.isConsistent&&e.numCols>1)??n.find(e=>e.isConsistent)??n[0]).parsed;if(r.length===0)return{ok:!1,reason:`No values`};let i=r[0].length;return r.every(e=>e.length===i)?AP(r):{ok:!1,reason:`All rows don't have same number of columns`}},MP=(e,t,n,r)=>{if(!nP(e,`radar`))return null;let i=e.labels??e.series[0].values.map((e,t)=>`Value ${t+1}`),a=e.series,{normalize:o,renderSteps:s}=dP(a,i.length),c=lP(r),l=uP(c),u=cP(a.length,c),{chartWidth:d,chartHeight:f}=oP(),p=t+d/2,m=n-f/2,h=VN/2,g=i.map((e,t)=>-Math.PI/2+Math.PI*2*t/i.length),{axisLabels:_,axisLabelTopY:v,axisLabelBottomY:y}=mP(i,g,p,m,h,l),b=Na[`Lilita One`],x=Qn.xl,S=zs(b),C=tc({fontFamily:b,fontSize:x}),w=e.title?pP(e.title,C,d+WN*2):null,T=w?uo(w,C,S):null,E=w?oc({backgroundColor:l,...$N,text:w,originalText:e.title??w,x:t+d/2,y:v-WN-T.height/2,fontFamily:b,fontSize:x,lineHeight:S,textAlign:`center`}):null,D=s?Array.from({length:UN},(e,t)=>{let n=(t+1)/UN,r=h*n,i=g.map(e=>L(Math.cos(e)*r,Math.sin(e)*r));return i.push(L(i[0][0],i[0][1])),re({backgroundColor:`transparent`,...$N,type:`line`,x:p,y:m,width:r*2,height:r*2,strokeStyle:`solid`,roughness:da.architect,opacity:HN,polygon:!0,points:i})}):[],O=g.map(e=>{let t=Math.cos(e)*h,n=Math.sin(e)*h;return re({backgroundColor:`transparent`,...$N,type:`line`,x:p,y:m,width:Math.abs(t),height:Math.abs(n),strokeStyle:`solid`,roughness:da.architect,opacity:HN,points:[L(0,0),L(t,n)]})}),ee=a.map((e,t)=>{let n=g.map((t,n)=>{let r=e.values[n]??0,i=o(r,n)*h;return L(Math.cos(t)*i,Math.sin(t)*i)});return n.push(L(n[0][0],n[0][1])),re({backgroundColor:`transparent`,...$N,type:`line`,x:p,y:m,width:h*2,height:h*2,strokeColor:u[t],strokeWidth:2,polygon:!0,points:n})}),k=hP(a,u,p,y,n+BN*5,l);return[...E?[E]:[],..._,...D,...O,...ee,...k]},NP=(e,t,n,r,i)=>e===`line`?DP(t,n,r,i):e===`radar`?MP(t,n,r,i):EP(t,n,r,i),PP=class{constructor(e){this.app=e,z(this,`updateHoveredAnchor`,e=>{let t=this.app.state.activeTool.type===`text`&&!this.app.state.editingTextElement&&!this.app.state.newElement?this.getAnchorAtPosition(e.x,e.y):null,n=this.app.state.hoveredArrowTextAnchor;return(n?.elementId!==t?.elementId||n?.anchor!==t?.anchor)&&this.app.setState({hoveredArrowTextAnchor:t}),t}),z(this,`refresh`,()=>{this.app.lastPointerMoveCoords&&this.updateHoveredAnchor(this.app.lastPointerMoveCoords)})}getBindableEndpointAtPosition(e,t){if(!Ys(this.app.state))return null;let n=Ws(L(e,t),this.app.scene.getNonDeletedElements(),this.app.scene.getNonDeletedElementsMap(),this.app.state.zoom);if(!n||this.app.getTextElementAtPosition(e,t))return null;let r=this.app.getElementAtPosition(e,t,{includeLockedElements:!0});return r&&r.id!==n.arrow.id&&this.app.scene.getElementIndex(r.id)>this.app.scene.getElementIndex(n.arrow.id)?null:n}getAnchorAtPosition(e,t){let n=this.getBindableEndpointAtPosition(e,t);if(n)return{elementId:n.arrow.id,anchor:n.startOrEnd};let r=this.app.getTextBindableContainerAtPosition(e,t);return!_(r)||Ti(r,this.app.scene.getNonDeletedElementsMap())?null:this.app.getTextWysiwygSnappedToCenterPosition(e,t,this.app.state,r)?{elementId:r.id,anchor:`label`}:null}getTextBinding({arrow:e,startOrEnd:t},n){return va(e,t,this.app.scene.getNonDeletedElementsMap(),n)}bindText({arrow:e,startOrEnd:t},n,r){se(e,n,t,r,this.app.scene)}maybeDragNewText(e,t){return!a(e)||!O(e,this.app.scene.getNonDeletedElementsMap())?!1:(ge({newElement:e,...or(e),pointerX:t.x,zoom:this.app.state.zoom.value,scene:this.app.scene}),!0)}},FP=yn.filter(e=>e!==Ye.white),IP=class{constructor(e){this.app=e,z(this,`temporaryEyeDropper`,null),z(this,`pending`,null),z(this,`handlePointerDown`,e=>{this.pending=e}),z(this,`handlePointerUp`,()=>{let e=this.pending;this.pending=null,e&&this.fill(e)}),z(this,`cancel`,()=>{this.pending=null}),z(this,`cycleBackgroundColor`,()=>{let e=Re(this.app.state.currentItemBackgroundColor),t=FP[(FP.indexOf(e)+1)%FP.length];this.app.actionManager.executeAction(Gw,`keyboard`,{currentItemBackgroundColor:t})}),z(this,`openTemporaryEyeDropper`,()=>{if(ky.get(MC))return;let e={colorPickerType:`elementBackground`,keepOpenOnAlt:!0,onSelect:e=>{this.app.actionManager.executeAction(Gw,`ui`,{currentItemBackgroundColor:e})}};this.temporaryEyeDropper=e,this.app.updateEditorAtom(MC,e)}),z(this,`closeTemporaryEyeDropper`,()=>{let e=this.temporaryEyeDropper;this.temporaryEyeDropper=null,e&&ky.get(MC)===e&&this.app.updateEditorAtom(MC,null)}),z(this,`restyle`,e=>{let t=Re(this.app.state.currentItemBackgroundColor);e.backgroundColor===t&&e.fillStyle===this.app.state.currentItemFillStyle&&e.opacity===this.app.state.currentItemOpacity||(this.app.scene.mutateElement(e,{backgroundColor:t,fillStyle:this.app.state.currentItemFillStyle,opacity:this.app.state.currentItemOpacity}),fr.delete(e),this.app.scheduleCapture())}),z(this,`fill`,e=>{let t=Re(this.app.state.currentItemBackgroundColor),n=this.app.scene.getNonDeletedElements(),r=this.app.scene.getNonDeletedElementsMap(),i=L(e.x,e.y),a=this.app.getElementAtPosition(i[0],i[1]),o=Xa({point:i,elements:n,elementsMap:r});if(!o.ok){if(a&&Ri(a)){this.restyle(a);return}o.reason===`too_complex`?this.app.setToast({message:W(`bucketfill.tooComplex`),duration:3e3}):(o.reason===`open_region`||o.reason===`too_small`||o.reason===`invalid_polygon`)&&this.app.setToast({message:W(`bucketfill.noRegion`),duration:3e3});return}if(a&&Ve({hitElement:a,scenePoints:o.scenePoints,elementsMap:r})){this.restyle(a);return}let{width:s,height:c}=vi(o.scenePoints),[l,u]=o.scenePoints[0],d=o.scenePoints.map(e=>L(e[0]-l,e[1]-u)),f=o.ownerId?r.get(o.ownerId):null,p=f?P(f)?f.id:f.frameId:this.app.getTopLayerFrameAtSceneCoords(e)?.id??null,m=f?f.groupIds:o.boundaryElementIds.map(e=>r.get(e)?.groupIds).filter(e=>!!e).reduce((e,t)=>e===null?t:e.filter(e=>t.includes(e)),null)??[],h=re({type:`line`,x:l,y:u,width:s,height:c,points:d,polygon:!0,strokeColor:`transparent`,backgroundColor:t,fillStyle:this.app.state.currentItemFillStyle,strokeWidth:1,strokeStyle:`solid`,roughness:0,roundness:null,opacity:this.app.state.currentItemOpacity,frameId:p,groupIds:m}),g=this.app.scene.getElementsIncludingDeleted().findIndex(e=>e.id===o.insertion.elementId);this.app.scene.insertElementsAtIndex([h],g<0?null:o.insertion.placement===`above`?g+1:g),this.app.scheduleCapture()})}},LP=`<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">`,RP=`<path d="M6.164 11.755a5.314 5.314 0 0 1-4.932-5.298 5.314 5.314 0 0 1 5.311-5.311 5.314 5.314 0 0 1 5.307 5.113l8.773 8.773a3.322 3.322 0 0 1 0 4.696l-.895.895a3.322 3.322 0 0 1-4.696 0l-8.868-8.868Z" style="fill:#fff"/>`,zP=`<path stroke="#1b1b1f" fill="#fff" d="m7.868 11.113 7.773 7.774a2.359 2.359 0 0 0 1.667.691 2.368 2.368 0 0 0 2.357-2.358c0-.625-.248-1.225-.69-1.667L11.201 7.78 9.558 9.469l-1.69 1.643v.001Zm10.273 3.606-3.333 3.333m-3.25-6.583 2 2m-7-7 3 3M3.664 3.625l1 1M2.529 6.922l1.407-.144m5.735-2.932-1.118.866M4.285 9.823l.758-1.194m1.863-6.207-.13 1.408"/>`,BP=`data:${M.svg},${encodeURIComponent(`${LP}${zP}</svg>`)}`,VP=`data:${M.svg},${encodeURIComponent(`${LP}${RP}${zP}</svg>`)}`,HP=e=>{let t=Lb.map((t,n)=>`<path d="${t}" ${n<2?`fill="${e}"`:``} />`).join(``);return`data:${M.svg},${encodeURIComponent(`<svg viewBox="0 0 24 24" width="24" height="24" fill="none" xmlns="http://www.w3.org/2000/svg" stroke-linecap="round" stroke-linejoin="round"><g stroke="#fff" fill="#fff" stroke-width="5">${t}</g><g stroke="#1b1b1f" stroke-width="1.25">${t}</g></svg>`)}`},UP=class{constructor(e){this.app=e,z(this,`toolCursorMemo`,null),z(this,`eraserCanvasCache`,null),z(this,`eraserPreviewDataURL`,null),z(this,`set`,e=>{this.toolCursorMemo=null,this.canvas&&(this.canvas.style.cursor=e)}),z(this,`reset`,()=>{this.app.state.viewModeEnabled&&!this.app.isActiveToolPointerCapturing()?this.app.isNavigationEnabled()?this.set(Et.GRAB):this.clear():this.applyForTool()}),z(this,`applyForTool`,(e=this.app.state.activeTool)=>{let t=this.canvas;if(!t)return;let n=e.type===`bucketfill`?Re(this.app.state.currentItemBackgroundColor):void 0,r=e.type===`eraser`||e.type===`laser`?this.app.state.theme:void 0,i=this.toolCursorMemo;if(i?.canvas!==t||i.type!==e.type||i.bucketFillColor!==n||i.theme!==r){if(e.type===`selection`)this.clear();else if(Ro({activeTool:e}))this.set(Et.GRAB);else if(ji({activeTool:e}))this.applyEraser();else if(e.type===`autoshape`)this.set(Et.CROSSHAIR);else if(e.type===`bucketfill`)this.set(`url(${HP(n)}) 5 18, auto`);else if(e.type===`laser`){let e=this.app.state.theme===A.LIGHT?BP:VP;this.set(`url(${e}), auto`)}else[`image`,`custom`].includes(e.type)?e.type!==`image`&&this.set(Et.AUTO):this.set(Et.CROSSHAIR);this.toolCursorMemo={canvas:t,type:e.type,bucketFillColor:n,theme:r}}}),z(this,`clear`,()=>{this.set(``)}),z(this,`applyEraser`,()=>{let e=this.app.state.theme;if(!this.eraserCanvasCache||this.eraserCanvasCache.theme!==e){let t=e===A.DARK;this.eraserCanvasCache=document.createElement(`canvas`),this.eraserCanvasCache.theme=e,this.eraserCanvasCache.height=20,this.eraserCanvasCache.width=20;let n=this.eraserCanvasCache.getContext(`2d`);n.lineWidth=1,n.beginPath(),n.arc(this.eraserCanvasCache.width/2,this.eraserCanvasCache.height/2,5,0,2*Math.PI),n.fillStyle=t?`#000`:`#fff`,n.fill(),n.strokeStyle=t?`#fff`:`#000`,n.stroke(),this.eraserPreviewDataURL=this.eraserCanvasCache.toDataURL(M.svg)}this.set(`url(${this.eraserPreviewDataURL}) 10 10, auto`)})}get canvas(){return this.app.interactiveCanvas}},WP=class{constructor(e){this.app=e,z(this,`trail`),this.trail=new $M(this.app,{...this.getTrailOptions(),fill:()=>e.state.theme===A.LIGHT?`rgba(0, 0, 0, 0.2)`:`rgba(255, 255, 255, 0.2)`})}getTrailOptions(){return{simplify:0,streamline:.4,size:1,sizeMapping:()=>ss(We(`line`,this.app.state.currentItemStrokeWidthKey)*.65*this.app.state.zoom.value,1.25,4)}}startPath(e,t){this.trail.startPath(e,t)}addPointToPath(e,t){this.trail.addPointToPath(e,t)}endPath(){this.trail.endPath()}clearTrails(){this.trail.clearTrails()}getCurrentPoints(){let e=this.trail.getCurrentTrail();return e?e.originalPoints.map(([e,t])=>L(e,t)):[]}start(e){this.trail.start(e)}stop(){this.trail.stop()}},GP=class{constructor(e){this.app=e,z(this,`trail`),z(this,`gestureInProgress`,!1),z(this,`stop`,()=>{this.trail.stop()}),z(this,`hasPendingGesture`,()=>this.gestureInProgress),z(this,`handlePointerDown`,e=>{this.gestureInProgress&&this.app.actionManager.executeAction(PT),this.gestureInProgress=!0,this.trail.startPath(e.lastCoords.x,e.lastCoords.y)}),z(this,`handlePointerMove`,e=>vs(this.app,e)),z(this,`bindRecognizedArrow`,e=>{let{app:t}=this,n=t.scene.getNonDeletedElementsMap(),r=t.scene.getNonDeletedElements(),i=jn(t.state.zoom),a=[`start`,`end`].map(t=>{let a=N.getPointAtIndexGlobalCoordinates(e,t===`start`?0:-1,n);return{startOrEnd:t,globalPoint:a,target:Nn(a,r,n,i)}}),o=!!a[0].target&&a[0].target===a[1].target,s=t.state.isMidpointSnappingEnabled&&!t.state.gridModeEnabled;for(let{startOrEnd:n,globalPoint:r,target:i}of a)i&&nc(e,i,o?`inside`:`orbit`,n,t.scene,r,t.state.isBindingEnabled,s);if(o)return;let c=new Map;for(let{startOrEnd:t,target:r}of a){if(!r)continue;let i=pn(e,t===`start`?`startBinding`:`endBinding`,t===`start`?e.startBinding:e.endBinding,r,n);i&&c.set(t===`start`?0:e.points.length-1,{point:i})}c.size&&N.movePoints(e,t.scene,c)}),z(this,`maybeUpgradeLineToArrow`,e=>{let{app:t}=this,n=t.scene.getNonDeletedElementsMap(),r=t.scene.getNonDeletedElements(),i=jn(t.state.zoom),[a,o]=[0,-1].map(t=>Nn(N.getPointAtIndexGlobalCoordinates(e,t,n),r,n,i));return!a&&!o||a===o?null:Oa({type:`arrow`,x:e.x,y:e.y,width:e.width,height:e.height,startArrowhead:null,endArrowhead:t.state.currentItemEndArrowhead,points:e.points,groupIds:e.groupIds,frameId:e.frameId,locked:!1,angle:e.angle,strokeColor:e.strokeColor,backgroundColor:e.backgroundColor,fillStyle:e.fillStyle,roughness:e.roughness,opacity:e.opacity,strokeStyle:e.strokeStyle,strokeWidth:e.strokeWidth})}),z(this,`finalize`,()=>{let{app:e}=this,t=this.gestureInProgress?this.trail.getCurrentPoints():[];if(this.gestureInProgress=!1,this.trail.endPath(),t.length>=3){let n=e.state.newElement||hn(t,e.state,e.scene.getNonDeletedElementsMap(),e.state.newElement,e.scene.getNonDeletedFramesLikes());if(n){let t={...n,seed:za(),opacity:e.state.currentItemOpacity};e.state.isBindingEnabled&&Oe(t)&&(t=this.maybeUpgradeLineToArrow(t)??t),e.insertNewElement(t),e.state.isBindingEnabled&&ft(t)&&this.bindRecognizedArrow(t)}}this.trail.clearTrails()}),this.trail=new WP(e)}},KP=class e{constructor(e){this.app=e,z(this,`creator`,new _r),z(this,`navigator`,new jr),z(this,`clear`,()=>{this.creator.clear(),this.navigator.clear()}),z(this,`handleKeyEvent`,e=>{let t=this.resolveKeyboardEventToOperation(e);switch(t.type){case`none`:return!1;case`canceled`:return this.app.triggerRender(!0),!0;case`creating`:return e.preventDefault(),t.pending.length&&this.app.revealIfHidden(t.pending),!0;case`navigating`:{e.preventDefault();let n=t.nodeId&&this.app.scene.getNonDeletedElementsMap().get(t.nodeId);return n&&this.selectAndReveal(n),!0}case`committed`:{t.nodes.length&&this.app.insertNewElements(t.nodes);let e=t.nodes[0];return e&&this.selectAndReveal(e),this.captureUpdate(),!0}case`navigationEnded`:return this.captureUpdate(),!0}})}get pendingNodes(){return this.creator.pendingNodes}get isCreatingChart(){return this.creator.isCreatingChart}resolveKeyboardEventToOperation(t){let{creator:n,navigator:r,app:i}=this;if(t.type===`keydown`){if(t.key===j.ESCAPE&&n.isCreatingChart)return n.clear(),{type:`canceled`};if(!dr(t.key))return{type:`none`};if(t[j.CTRL_OR_CMD]&&!t.shiftKey){let r=xt(i.scene.getNonDeletedElementsMap(),i.state);return r.length===1&&jt(r[0])&&n.createNodes(r[0],i.state,e.getLinkDirectionFromKey(t.key),i.scene),{type:`creating`,pending:n.pendingNodes??[]}}if(t.altKey){let n=i.scene.getNonDeletedElementsMap(),a=xt(n,i.state);if(a.length===1)return{type:`navigating`,nodeId:r.exploreByDirection(a[0],n,e.getLinkDirectionFromKey(t.key))}}return{type:`none`}}let a=!t.altKey&&r.isExploring;if(a&&r.clear(),!t[j.CTRL_OR_CMD]&&n.isCreatingChart){let e=n.pendingNodes??[];return n.clear(),{type:`committed`,nodes:e}}return a?{type:`navigationEnded`}:{type:`none`}}selectAndReveal(e){this.app.setState(t=>({selectedElementIds:fa({[e.id]:!0},t)})),this.app.revealIfHidden([e])}captureUpdate(){this.app.syncActionResult({captureUpdate:F.IMMEDIATELY})}static getLinkDirectionFromKey(e){switch(e){case j.ARROW_UP:return`up`;case j.ARROW_DOWN:return`down`;case j.ARROW_RIGHT:return`right`;case j.ARROW_LEFT:return`left`;default:return`right`}}},qP=`animateScrollToContent`,JP=`animateScrollConstraintsSnapBack`,YP=500,XP=250,ZP=200,QP=302,$P={full:216,compact:64},eF=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return typeof t.x==`number`&&typeof t.y==`number`&&(t.width==null||typeof t.width==`number`)&&(t.height==null||typeof t.height==`number`)},tF=(e,t)=>{let n=t.get(e);return n?[n]:yt(t,e)},nF=(e,t,n)=>{if(typeof e==`string`){let n=Ea(e),r=n?`link`:`element`,i=n?Le(e):e,a=i?tF(i,t):[];return a.length?{bounds:Is(a,t),type:r}:{bounds:null,type:r}}if(zt(e))return{bounds:e,type:`area`};if(eF(e)&&!bs(e)){let t=e.width??n.width,r=e.height??n.height;return{bounds:[e.x,e.y,e.x+t,e.y+r],type:`area`}}let r=Array.isArray(e)?e:[e],i=r.reduce((e,n)=>{if(n&&!n.isDeleted){let r=t.get(n.id);r&&e.push(r)}return e},[]),a=!i.length;return(i.length!==r.length||a)&&console.warn(`supplied element target(s) for setViewport contain deleted or non-existent elements which have been filtered out`),a?{bounds:null,type:`element`}:{bounds:Is(i,t),type:`element`}},rF=e=>e===!1?0:e===!0||e==null?150:Math.max(e,0),iF=(e,t,n=`scale-down`,r)=>{let{appState:i}=an({bounds:t,appState:e,fit:n,canvasOffsets:r,steppedZoom:!1});return{scrollX:i.scrollX,scrollY:i.scrollY,zoom:i.zoom}},aF=(e,t,{fit:n,offsets:r,lock:i})=>{let a=iF(e,t,n,r);if(!i?.scroll&&!i?.zoom)return{...a,scrollConstraints:null};let[o,s,c,l]=t,u={x:o,y:s,width:c-o,height:l-s,lockScroll:!!i.scroll,lockZoom:!!i.zoom,zoom:a.zoom.value,overscroll:rF(i.overscroll),offsets:r};return{...Kr({...e,...a,scrollConstraints:u}),scrollConstraints:u}},oF=({from:e,target:t,factor:n})=>{if(n>=1)return{...t};let r=e.zoom.value*(t.zoom.value/e.zoom.value)**+n,i=t.zoom.value===e.zoom.value?n:(r-e.zoom.value)/(t.zoom.value-e.zoom.value);return{scrollX:((1-i)*e.scrollX*e.zoom.value+i*t.scrollX*t.zoom.value)/r,scrollY:((1-i)*e.scrollY*e.zoom.value+i*t.scrollY*t.zoom.value)/r,zoom:{value:r}}},sF=e=>e===!1?null:e===!0||e==null?YP:e.duration??YP,cF=(e,t,n,r,i)=>{ZM.start(qP,({deltaTime:a,state:o})=>{let s=(o?.elapsed??0)+a,c=Math.min(s/n,1),l=pa(ss(c,0,1));return c<1?(r({...oF({from:e,target:t,factor:l}),shouldCacheIgnoreZoom:!0}),{elapsed:s}):(i(),null)})},lF=(e,t,n=XP)=>{let r=Kr(e);if(r.scrollX===e.scrollX&&r.scrollY===e.scrollY&&r.zoom.value===e.zoom.value||ZM.running(qP))return;let i=(e.scrollX-r.scrollX)*e.zoom.value,a=(e.scrollY-r.scrollY)*e.zoom.value;ZM.start(JP,({deltaTime:e,state:r})=>{let o=(r?.elapsed??0)+e,s=Math.min(o/n,1),c=1-pa(ss(s,0,1));return t(e=>{if(!e.scrollConstraints)return null;let t=Kr(e),n=t.zoom.value;return{scrollX:t.scrollX+i*c/n,scrollY:t.scrollY+a*c/n,zoom:t.zoom}}),s<1?{elapsed:o}:null})},uF=class{constructor(e,t){this.app=e,this.dependencies=t,z(this,`lastPosition`,{x:0,y:0}),z(this,`activeTransition`,null),z(this,`uiLastMeasured`,new Map),z(this,`invalidateUIOffset`,e=>{this.uiLastMeasured.delete(e)}),z(this,`resolveOffsets`,e=>{if(!e)return e;let{ui:t,...n}=e;if(!t)return n;let r=this.getOffsets(t===!0?void 0:t);return{top:n.top??r.top,right:n.right??r.right,bottom:n.bottom??r.bottom,left:n.left??r.left}}),z(this,`getOffsets`,e=>{let t=this.dependencies.getContainer(),n=t?.getBoundingClientRect(),r=Ry().rtl,i={top:0,right:0,bottom:0,left:0},a=new Set;if(t&&n)for(let e of t.querySelectorAll(`[data-viewport-ui]`)){let t=e.getBoundingClientRect(),r={top:t.top-n.top,right:t.right-n.left,bottom:t.bottom-n.top,left:t.left-n.left,width:t.width};switch(e.dataset.viewportUi){case`top`:i.top=Math.max(i.top,r.bottom);break;case`bottom`:i.bottom=Math.max(i.bottom,this.app.state.height-r.top);break;case`side`:{let[t,n]=r.left+r.width/2<this.app.state.width/2?[`left`,r.right]:[`right`,this.app.state.width-r.left];i[t]=Math.max(i[t],n);let o=e.dataset.viewportUiName;o&&(a.add(o),n>0&&this.uiLastMeasured.set(o,{side:t,offset:n}));break}}}if(e?.reserve&&this.app.editorInterface.formFactor!==`phone`){let t=(e,t)=>{if(a.has(e))return;let{side:n,offset:r}=this.uiLastMeasured.get(e)??t;i[n]=Math.max(i[n],r)};e.reserve.stylesPanel&&t(`stylesPanel`,{side:r?`right`:`left`,offset:this.dependencies.getStylesPanelMode()===`compact`?$P.compact:$P.full}),e.reserve.sidebar&&t(`sidebar`,{side:r?`left`:`right`,offset:QP})}let o=e?.padding??24,s=e?.paddingTop??o,c=(r?e?.paddingLeft:e?.paddingRight)??o,l=e?.paddingBottom??o,u=(r?e?.paddingRight:e?.paddingLeft)??o,d={top:i.top+s,right:i.right+c,bottom:i.bottom+l,left:i.left+u};return{top:e?.top??d.top,right:(r?e?.left:e?.right)??d.right,bottom:e?.bottom??d.bottom,left:(r?e?.right:e?.left)??d.left}}),z(this,`resolveInitialViewport`,(e,t,n)=>{let{bounds:r}=nF(e.target,t,n);return r?aF(n,r,{...e,offsets:this.resolveOffsets(e.offsets)}):null}),z(this,`setViewport`,e=>{if(e===null){this.cancelTransition(),ZM.cancel(JP),this.snapBackDebounced.cancel(),this.app.setState({scrollConstraints:null,shouldCacheIgnoreZoom:!1});return}let{target:t,fit:n,lock:r,animation:i}=e,a=this.resolveOffsets(e.offsets),{bounds:o,type:s}=nF(t,this.app.scene.getNonDeletedElementsMap(),this.app.state);if(!o){s===`link`&&this.app.setState({toast:{message:W(`elementLink.notFound`),duration:3e3,closable:!0}});return}let c=aF(this.app.state,o,{fit:n,offsets:a,lock:r}),l=sF(i),u={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom};if(this.cancelTransition(),ZM.cancel(JP),this.snapBackDebounced.cancel(),l===null){this.app.setState({...c,shouldCacheIgnoreZoom:!1});return}let d={target:c};this.activeTransition=d,this.app.state.scrollConstraints&&this.app.setState({scrollConstraints:null}),cF(u,c,l,e=>{this.activeTransition===d&&this.app.setState(e)},()=>{this.activeTransition===d&&(this.activeTransition=null,this.app.setState({...d.target,shouldCacheIgnoreZoom:!1}))})}),z(this,`translate`,(e,t)=>{if(this.isLockedTransitionPending)return!1;this.cancelTransition(),t?.preserveScrollConstraintsSnapBack||ZM.cancel(JP),this.app.setState({shouldCacheIgnoreZoom:!1}),this.app.requestUnfollow();let n=this.app.state.zoom.value;return this.app.setState(e),this.app.setState(e=>{if(!e.scrollConstraints)return null;let r=!t?.zoomPreConstrained&&e.zoom.value!==n?0:e.scrollConstraints.overscroll;return r>0&&this.snapBackDebounced(),Kr(e,r)}),!0}),z(this,`constrain`,(e=0)=>{this.app.setState(t=>t.scrollConstraints?Kr(t,e):null)}),z(this,`releaseOverscroll`,()=>{this.app.state.scrollConstraints&&(this.snapBackDebounced.cancel(),this.snapBack())}),z(this,`snapBack`,()=>{this.app.unmounted||this.dependencies.isGestureActive()||lF(this.app.state,e=>this.app.setState(t=>e(t)))}),z(this,`snapBackDebounced`,ke(this.snapBack,ZP)),z(this,`cancelTransition`,()=>{this.activeTransition=null,ZM.cancel(qP)}),z(this,`destroy`,()=>{this.cancelTransition(),ZM.cancel(JP),this.snapBackDebounced.cancel()})}get isAnimating(){return ZM.running(qP)||ZM.running(JP)}get isLockedTransitionPending(){return!!this.activeTransition?.target.scrollConstraints}},dF=()=>(0,V.jsxs)(`div`,{"data-testid":`brave-measure-text-error`,children:[(0,V.jsx)(`p`,{children:(0,V.jsx)(ek,{i18nKey:`errors.brave_measure_text_error.line1`,bold:e=>(0,V.jsx)(`span`,{style:{fontWeight:600},children:e})})}),(0,V.jsx)(`p`,{children:(0,V.jsx)(ek,{i18nKey:`errors.brave_measure_text_error.line2`,bold:e=>(0,V.jsx)(`span`,{style:{fontWeight:600},children:e})})}),(0,V.jsx)(`p`,{children:(0,V.jsx)(ek,{i18nKey:`errors.brave_measure_text_error.line3`,link:e=>(0,V.jsx)(`a`,{href:`http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser`,children:e})})}),(0,V.jsx)(`p`,{children:(0,V.jsx)(ek,{i18nKey:`errors.brave_measure_text_error.line4`,issueLink:e=>(0,V.jsx)(`a`,{href:`https://github.com/excalidraw/excalidraw/issues/new`,children:e}),discordLink:e=>(0,V.jsxs)(`a`,{href:`https://discord.gg/UexuTaE`,children:[e,`.`]})})})]}),fF=10,pF=({children:e,left:t,top:n,onCloseRequest:r,fitInViewport:i=!1,viewportWidth:a=window.innerWidth,viewportHeight:o=window.innerHeight,className:s})=>{let c=(0,B.useRef)(null);(0,B.useEffect)(()=>{let e=c.current;if(!e)return;e.contains(document.activeElement)||e.focus();let t=t=>{if(t.key===j.TAB){let n=dt(e),{activeElement:r}=document,i=n.findIndex(e=>e===r);r===e?(t.shiftKey?n[n.length-1]?.focus():n[0].focus(),t.preventDefault(),t.stopImmediatePropagation()):i===0&&t.shiftKey?(n[n.length-1]?.focus(),t.preventDefault(),t.stopImmediatePropagation()):i===n.length-1&&!t.shiftKey&&(n[0]?.focus(),t.preventDefault(),t.stopImmediatePropagation())}};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[]);let l=(0,B.useRef)(null);return(0,B.useLayoutEffect)(()=>{if(i&&c.current&&n!=null&&t!=null){let e=c.current,{width:r,height:i}=e.getBoundingClientRect();if(l.current?.top===n&&l.current?.left===t)return;l.current={top:n,left:t};let s=Math.max(0,a-fF*2);r>=s?(e.style.width=`${s}px`,e.style.left=`${fF}px`,e.style.overflowX=`scroll`):e.style.left=`${ss(t,fF,a-fF-r)}px`;let u=Math.max(0,o-fF*2);i>=u?(e.style.height=`${u}px`,e.style.top=`${fF}px`,e.style.overflowY=`scroll`):e.style.top=`${ss(n,fF,o-fF-i)}px`}},[n,t,i,a,o]),(0,B.useEffect)(()=>{if(r){let e=e=>{c.current?.contains(e.target)||(0,Uc.unstable_batchedUpdates)(()=>r(e))};return document.addEventListener(`pointerdown`,e,!1),()=>document.removeEventListener(`pointerdown`,e,!1)}},[r]),(0,V.jsx)(`div`,{className:H(`popover`,s),ref:c,tabIndex:-1,children:e})},mF=`separator`,hF=B.memo(({actionManager:e,items:t,top:n,left:r,onClose:i})=>{let a=uV(),o=lV(),s=t.reduce((t,n)=>(n&&(n===mF||!n.predicate||n.predicate(o,a,e.app.props,e.app))&&t.push(n),t),[]);return(0,V.jsx)(pF,{onCloseRequest:()=>{i()},top:n,left:r,fitInViewport:!0,viewportWidth:a.width,viewportHeight:a.height,className:`context-menu-popover`,children:(0,V.jsx)(`ul`,{className:`context-menu`,onContextMenu:e=>e.preventDefault(),children:s.map((t,n)=>{if(t===mF)return!s[n-1]||s[n-1]===mF?null:(0,V.jsx)(`hr`,{className:`context-menu-item-separator`},n);let r=t.name,c=``;return t.label&&(c=typeof t.label==`function`?W(t.label(o,a,e.app)):W(t.label)),(0,V.jsx)(`li`,{"data-testid":r,onClick:()=>{i(()=>{e.executeAction(t,`contextMenu`)})},children:(0,V.jsxs)(`button`,{type:`button`,className:H(`context-menu-item`,{dangerous:r===`deleteSelectedElements`,checkmark:t.checked?.(a)}),children:[(0,V.jsx)(`div`,{className:`context-menu-item__label`,children:c}),(0,V.jsx)(`kbd`,{className:`context-menu-item__shortcut`,children:r?lO(r):``})]})},n)})})})}),gF=({border:e,style:t})=>(0,V.jsx)(`div`,{className:`viewport-status-frame__border`,style:{borderColor:e,...t}}),_F=({label:e,border:t})=>{let n=(0,B.useId)(),r=(0,V.jsxs)(V.Fragment,{children:[e.icon&&(0,V.jsx)(`span`,{className:`viewport-status-frame__badge-icon`,children:e.icon}),e.label]});return(0,V.jsxs)(`div`,{className:H(`viewport-status-frame__badge`,{"viewport-status-frame__badge--clickable":e.onClick}),role:`status`,style:{"--viewport-status-frame-badge-background":e.background||t||`var(--color-primary)`,color:e.color},children:[e.onClick&&(0,V.jsx)(`button`,{type:`button`,className:`viewport-status-frame__badge-action`,"aria-labelledby":n,onClick:e.onClick}),(0,V.jsx)(`div`,{className:`viewport-status-frame__badge-label`,id:e.onClick?n:void 0,children:r}),e.onClose&&(0,V.jsx)(`button`,{type:`button`,className:`viewport-status-frame__badge-close`,"aria-label":W(`buttons.close`),onClick:e.onClose,children:lx})]})},vF=B.createContext(null),yF=()=>B.useContext(vF),bF=Al(),xF=()=>B.useMemo(()=>({MainMenuTunnel:xy(),WelcomeScreenMenuHintTunnel:xy(),WelcomeScreenToolbarHintTunnel:xy(),WelcomeScreenHelpHintTunnel:xy(),WelcomeScreenCenterTunnel:xy(),FooterCenterTunnel:xy(),DefaultSidebarTriggerTunnel:xy(),DefaultSidebarTabTriggersTunnel:xy(),OverwriteConfirmDialogTunnel:xy(),TTDDialogTriggerTunnel:xy(),tunnelsJotai:bF}),[]),SF=({delay:e,theme:t})=>{let[n,r]=(0,B.useState)(!!e);return(0,B.useEffect)(()=>{if(!e)return;let t=setTimeout(()=>{r(!1)},e);return()=>clearTimeout(t)},[e]),n?null:(0,V.jsxs)(`div`,{className:H(`LoadingMessage`,{"LoadingMessage--dark":t===A.DARK}),children:[(0,V.jsx)(`div`,{children:(0,V.jsx)(lC,{})}),(0,V.jsx)(`div`,{className:`LoadingMessage-text`,children:W(`labels.loadingScene`)})]})},CF=({app:e,setAppState:t})=>{let n=e.state.activeTool,[r,i]=(0,B.useState)(!1),[a,o]=(0,B.useState)(`rectangle`),[s,c]=(0,B.useState)(`arrow`);(0,B.useEffect)(()=>{(n.type===`rectangle`||n.type===`diamond`||n.type===`ellipse`)&&o(n.type)},[n.type]),(0,B.useEffect)(()=>{(n.type===`arrow`||n.type===`line`)&&c(n.type)},[n.type]);let l=n.type===`frame`,u=n.type===`autoshape`,d=n.type===`laser`,f=n.type===`embeddable`,p=n.type===`bucketfill`,{TTDDialogTriggerTunnel:m}=yF(),h=[`rectangle`,`diamond`,`ellipse`].map(e=>({type:e,icon:fT[e].icon,title:lo(W(`toolBar.${e}`)),fillable:fT[e].fillable})),g=[`arrow`,`line`].map(e=>({type:e,icon:fT[e].icon,title:lo(W(`toolBar.${e}`)),fillable:fT[e].fillable})),[_,v]=(0,B.useState)(0),y=_>=316,b=_>=356,x=_>=396,S=[`text`,`frame`,`embeddable`,`laser`,`bucketfill`,`magicframe`].filter(e=>!(y&&e===`text`||x&&e===`frame`)).includes(n.type),C=S?n.type===`text`?fb:n.type===`image`?mb:n.type===`frame`?mS:n.type===`embeddable`?bb:n.type===`laser`?bS:n.type===`bucketfill`?Rb:n.type===`magicframe`?xS:qy:qy,w={app:e,activeTool:n};return(0,V.jsxs)(`div`,{className:`mobile-toolbar`,ref:e=>{e&&v(e.getBoundingClientRect().width)},children:[(0,V.jsx)(yT,{...w,hideKeyBinding:!0}),(0,V.jsx)(MT,{...w,setAppState:t}),(0,V.jsx)(NT,{...w}),(0,V.jsx)(OT,{...w,hideShortcut:!0}),(0,V.jsx)(dT,{app:e,options:h,activeTool:n,defaultOption:a,"data-testid":`toolbar-rectangle`,onToolChange:t=>{(t===`rectangle`||t===`diamond`||t===`ellipse`)&&(o(t),e.setActiveTool({type:t}))},displayedOption:h.find(e=>e.type===a)||h[0]}),(0,V.jsx)(dT,{app:e,options:g,activeTool:n,defaultOption:s,"data-testid":`toolbar-arrow`,onToolChange:t=>{(t===`arrow`||t===`line`)&&(c(t),e.setActiveTool({type:t}))},displayedOption:g.find(e=>e.type===s)||g[0]}),y&&(0,V.jsx)(ET,{...w,hideShortcut:!0}),b&&(0,V.jsx)(DT,{...w,hideShortcut:!0}),x&&(0,V.jsx)(kT,{...w,hideShortcut:!0}),(0,V.jsxs)(Z,{open:r,children:[(0,V.jsx)(Z.Trigger,{className:H(`App-toolbar__extra-tools-trigger App-toolbar__extra-tools-trigger--mobile`,{"App-toolbar__extra-tools-trigger--selected":S||r}),onToggle:()=>{i(!r),t({openMenu:null,openPopup:null})},title:W(`toolBar.extraTools`),style:{width:36,height:36,display:`flex`,alignItems:`center`,justifyContent:`center`},children:C}),(0,V.jsxs)(Z.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:`App-toolbar__extra-tools-dropdown`,align:`start`,children:[!y&&(0,V.jsx)(Z.Item,{onSelect:()=>e.setActiveTool({type:`text`}),icon:fb,shortcut:j.T.toLocaleUpperCase(),"data-testid":`toolbar-text`,selected:n.type===`text`,disabled:_T(e,`text`),children:W(`toolBar.text`)}),!b&&(0,V.jsx)(Z.Item,{onSelect:()=>e.setActiveTool({type:`image`}),icon:mb,"data-testid":`toolbar-image`,selected:n.type===`image`,disabled:_T(e,`image`),children:W(`toolBar.image`)}),!x&&(0,V.jsx)(Z.Item,{onSelect:()=>e.setActiveTool({type:`frame`}),icon:mS,shortcut:j.F.toLocaleUpperCase(),"data-testid":`toolbar-frame`,selected:l,disabled:_T(e,`frame`),children:W(`toolBar.frame`)}),(0,V.jsx)(Z.Item,{onSelect:()=>e.setActiveTool({type:`embeddable`}),icon:bb,"data-testid":`toolbar-embeddable`,selected:f,disabled:_T(e,`embeddable`),children:W(`toolBar.embeddable`)}),(0,V.jsx)(Z.Item,{onSelect:()=>e.setActiveTool({type:`autoshape`}),icon:yS,shortcut:hT(`autoshape`),"data-testid":`toolbar-autoshape`,selected:u,disabled:_T(e,`autoshape`),children:W(`toolBar.autoshape`)}),(0,V.jsx)(Z.Item,{onSelect:()=>e.setActiveTool({type:`laser`}),icon:bS,"data-testid":`toolbar-laser`,selected:d,shortcut:j.K.toLocaleUpperCase(),disabled:_T(e,`laser`),children:W(`toolBar.laser`)}),(0,V.jsx)(Z.Item,{onSelect:()=>e.setActiveTool({type:`bucketfill`}),icon:Rb,"data-testid":`toolbar-bucketfill`,selected:p,shortcut:j.B.toLocaleUpperCase(),disabled:_T(e,`bucketfill`),children:W(`toolBar.bucketfill`)}),(0,V.jsx)(`div`,{style:{margin:`6px 0`,fontSize:14,fontWeight:600},children:`Generate`}),e.props.aiEnabled!==!1&&(0,V.jsx)(m.Out,{}),(0,V.jsx)(Z.Item,{onSelect:()=>e.setOpenDialog({name:`ttd`,tab:`mermaid`}),icon:hS,"data-testid":`toolbar-embeddable`,children:W(`toolBar.mermaidToExcalidraw`)}),e.props.aiEnabled!==!1&&e.plugins.diagramToCode&&(0,V.jsx)(V.Fragment,{children:(0,V.jsx)(Z.Item,{onSelect:()=>e.onMagicframeToolSelect(),icon:xS,"data-testid":`toolbar-magicframe`,badge:(0,V.jsx)(Z.Item.Badge,{children:`AI`}),disabled:_T(e,`magicframe`),children:W(`toolBar.magicframe`)})})]})]})]})},wF=({children:e,side:t,className:n})=>(0,V.jsx)(`div`,{className:H(`FixedSideContainer`,`FixedSideContainer_side_${t}`,n),children:e}),TF=e=>e.penDetected?(0,V.jsx)(J,{className:H(`ToolIcon__penMode`,{"is-mobile":e.isMobile}),type:`toggle`,icon:ub,checked:e.checked,title:`${e.title}`,"aria-label":`${e.title}`,onSelect:()=>e.onChange?.()}):null,EF=({appState:e,elements:t,actionManager:n,setAppState:r,renderTopLeftUI:i,renderTopRightUI:a,renderSidebars:o,renderWelcomeScreen:s,defaultUIEnabled:c,scrollBackToContentUIEnabled:l,app:u,onPenModeToggle:d})=>{let{WelcomeScreenCenterTunnel:f,MainMenuTunnel:p,DefaultSidebarTriggerTunnel:m}=yF(),h=()=>{if(e.openDialog?.name===`elementLinkSelector`)return null;let t=(0,V.jsxs)(`div`,{className:`excalidraw-ui-top-right`,children:[a?.(!0,e)??(!e.viewModeEnabled&&(0,V.jsxs)(V.Fragment,{children:[c&&(0,V.jsx)(TF,{checked:e.penMode,onChange:()=>d(null),title:W(`toolBar.penMode`),isMobile:!0,penDetected:e.penDetected}),(0,V.jsx)(m.Out,{})]})),c&&e.viewModeEnabled&&u.isInteractionEnabled()&&(0,V.jsx)(gA,{actionManager:n})]}),r=(0,V.jsxs)(`div`,{className:`excalidraw-ui-top-left`,children:[i?.(!0,e),(0,V.jsx)(p.Out,{})]});return(0,V.jsxs)(`div`,{className:`App-toolbar-content`,style:{display:`flex`,flexDirection:`row`,justifyContent:`space-between`},children:[r,t]})},g=()=>(0,V.jsx)(CF,{app:u,setAppState:r}),_=l&&e.scrolledOutside,v=c&&!e.viewModeEnabled,y=_&&!e.openMenu&&!e.openSidebar?(0,V.jsx)(`button`,{type:`button`,className:`scroll-back-to-content`,onClick:()=>{r(e=>({...Vt(t,e)}))},children:W(`buttons.scrollBackToContent`)}):null,b=u.props.viewportStatusFrame?.label,x=b?(0,V.jsx)(_F,{label:b,border:u.props.viewportStatusFrame?.border}):null;return(0,V.jsxs)(V.Fragment,{children:[o(),(0,V.jsx)(`div`,{className:`App-welcome-screen`,children:s&&(0,V.jsx)(f.Out,{})}),v&&(0,V.jsxs)(`div`,{className:`App-bottom-bar`,style:{marginBottom:hN+mN},"data-viewport-ui":`bottom`,children:[y&&(0,V.jsx)(`div`,{className:`floating-status-stack`,children:y}),(0,V.jsx)(fA,{appState:e,elementsMap:u.scene.getNonDeletedElementsMap(),renderAction:n.renderAction,app:u,setAppState:r}),(0,V.jsx)(PC,{className:`App-toolbar`,children:e.openDialog?.name!==`elementLinkSelector`&&g()})]}),!v&&y&&(0,V.jsx)(`div`,{className:`floating-status-stack`,children:y}),x&&(0,V.jsx)(`div`,{className:`viewport-status-frame__badge-row`,children:x}),(0,V.jsx)(wF,{side:`top`,className:`App-top-bar`,children:h()})]})},DF=e=>{switch(e){case`bar`:return W(`labels.chartType_bar`);case`line`:return W(`labels.chartType_line`);case`radar`:return W(`labels.chartType_radar`);default:return e}},OF=e=>{let t=(0,B.useRef)(null),[n,r]=(0,B.useState)(null),{theme:i}=EC();(0,B.useLayoutEffect)(()=>{if(!e.spreadsheet){r(null);return}let n=NP(e.chartType,e.spreadsheet,0,0,e.colorSeed);if(!n){r(null),t.current?.replaceChildren();return}r(n);let a,o=t.current;return(async()=>(a=await Ne(n,{exportBackground:!1,viewBackgroundColor:`#fff`,exportWithDarkMode:i===`dark`},null,{skipInliningFonts:!0}),a.querySelector(`.style-fonts`)?.remove(),o.replaceChildren(),o.appendChild(a)))(),()=>{o.replaceChildren()}},[e.spreadsheet,e.chartType,e.colorSeed,i]);let a=DF(e.chartType);return(0,V.jsxs)(`button`,{type:`button`,className:`ChartPreview`,"aria-label":a,onClick:()=>{n&&e.onClick(e.chartType,n)},children:[(0,V.jsx)(`div`,{className:`ChartPreview__canvas`,ref:t}),(0,V.jsx)(`div`,{className:`ChartPreview__label`,children:a})]})},kF=e=>{let t=(0,B.useRef)(null),{theme:n}=EC();return(0,B.useLayoutEffect)(()=>{if(!e.rawText)return;let r=oc({text:e.rawText,x:0,y:0}),i=t.current;return(async()=>{let e=await Ne([r],{exportBackground:!1,viewBackgroundColor:`#fff`,exportWithDarkMode:n===`dark`},null,{skipInliningFonts:!0});e.querySelector(`.style-fonts`)?.remove(),i.replaceChildren(),i.appendChild(e)})(),()=>{i.replaceChildren()}},[e.rawText,n]),(0,V.jsxs)(`button`,{type:`button`,className:`ChartPreview`,"aria-label":W(`labels.chartType_plaintext`),onClick:()=>{e.onClick(e.rawText)},children:[(0,V.jsx)(`div`,{className:`ChartPreview__canvas`,ref:t}),(0,V.jsx)(`div`,{className:`ChartPreview__label`,children:W(`labels.chartType_plaintext`)})]})},AF=({data:e,rawText:t,onClose:n})=>{let{onInsertElements:r,focusContainer:i}=iV(),[a,o]=(0,B.useState)(Math.random()),s=B.useCallback(()=>{o(Math.random())},[]),c=B.useCallback(()=>{n&&n()},[n]),l=(e,t)=>{r(t),xC(`paste`,`chart`,e),n(),i()};return(0,V.jsx)(Zk,{size:`regular`,onCloseRequest:c,title:(0,V.jsxs)(`div`,{className:`PasteChartDialog__title`,children:[(0,V.jsx)(`div`,{className:`PasteChartDialog__titleText`,children:W(`labels.pasteCharts`)}),(0,V.jsx)(`div`,{className:`PasteChartDialog__reshuffleBtn`,onClick:s,role:`button`,tabIndex:0,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),s())},children:Rb})]}),className:`PasteChartDialog`,autofocus:!1,children:(0,V.jsxs)(`div`,{className:`container`,children:[[`bar`,`line`,`radar`].map(t=>nP(e,t)?(0,V.jsx)(OF,{chartType:t,spreadsheet:e,colorSeed:a,onClick:l},t):null),t&&(0,V.jsx)(kF,{rawText:t,onClick:e=>{let t=oc({text:e,x:0,y:0});r([t]),xC(`paste`,`chart`,`plaintext`),n(),i()}})]})})},jF=({heading:e,children:t,...n})=>{let{id:r}=cV(),i=(0,V.jsx)(`h2`,{className:`visually-hidden`,id:`${r}-${e}-title`,children:W(`headings.${e}`)});return(0,V.jsx)(`section`,{...n,"aria-labelledby":`${r}-${e}-title`,children:typeof t==`function`?t(i):(0,V.jsxs)(V.Fragment,{children:[i,t]})})},MF=4,NF=8,PF=38,FF=21,IF=({shouldWrap:e,children:t,username:n})=>e?(0,V.jsx)(eT,{label:n||`Unknown user`,children:t}):(0,V.jsx)(V.Fragment,{children:t}),LF=({actionManager:e,collaborator:t,socketId:n,withName:r=!1,shouldWrapWithTooltip:i=!1,isBeingFollowed:a})=>{let o={socketId:n,collaborator:t,withName:r,isBeingFollowed:a},s=e.renderAction(`goToCollaborator`,o);return(0,V.jsx)(IF,{username:t.username,shouldWrap:i,children:s},n)},RF=[`avatarUrl`,`id`,`socketId`,`username`,`isInCall`,`isSpeaking`,`isMuted`,`isCurrentUser`],zF=B.memo(({className:e,mobile:t,collaborators:n,userToFollow:r,currentUserControls:i})=>{let a=fV(),o=typeof i==`function`?i(!!t):i,s=Array.from(n,([e,t])=>({...t,socketId:e})).filter(e=>e.username?.trim()),c=s.find(e=>e.isCurrentUser),l=s.filter(e=>!e.isCurrentUser),[u,d]=B.useState(``),f=s.filter(e=>e.username?.toLowerCase().includes(u)),p=B.useRef(null);(0,B.useLayoutEffect)(()=>{if(p.current){let e=e=>{h(e)};if(e(p.current.clientWidth),!Bn)return;let t=new ResizeObserver(t=>{for(let n of t){let{width:t}=n.contentRect;e(t)}});return t.observe(p.current),()=>{t.disconnect()}}},[]);let[m,h]=B.useState(MF*PF),g=c?m-FF:m,_=Math.max(1,Math.min(8,Math.floor(g/PF))),v=c?Math.max(0,_-1):_,y=l.slice(0,v),b=c?[...y,c]:y,x=b.map(e=>{let t=LF({actionManager:a,collaborator:e,socketId:e.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:e.socketId===r});return e.isCurrentUser?(0,V.jsxs)(cv,{children:[(0,V.jsx)(lv,{asChild:!0,children:(0,V.jsxs)(`div`,{className:`UserList__pill`,children:[t,(0,V.jsx)(`div`,{className:`UserList__pill-chevron`,children:oC})]})}),(0,V.jsx)(dv,{className:`focus-visible-none`,style:{zIndex:2,width:`15rem`,textAlign:`left`},align:`end`,sideOffset:10,children:(0,V.jsxs)(PC,{padding:2,children:[s.length>=NF&&(0,V.jsx)(sw,{placeholder:W(`quickSearch.placeholder`),onChange:d}),(0,V.jsx)(cw,{className:`dropdown-menu UserList__collaborators`,placeholder:W(`userList.empty`),children:f.length>0?[(0,V.jsx)(`div`,{className:`hint`,children:W(`userList.hint.text`)},`hint`),f.map(e=>LF({actionManager:a,collaborator:e,socketId:e.socketId,withName:!0,isBeingFollowed:e.socketId===r}))]:[]}),o&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{className:`UserList__menu-divider`}),(0,V.jsx)(fv,{asChild:!0,children:(0,V.jsx)(`div`,{className:`dropdown-menu`,children:o})})]}),(0,V.jsx)(pv,{width:20,height:10,style:{fill:`var(--popup-bg-color)`,filter:`drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)`}})]})})]},e.socketId):t});return t?(0,V.jsxs)(`div`,{className:H(`UserList UserList_mobile`,e),children:[(0,V.jsx)(`div`,{className:`UserList_mobile__avatars`,children:s.map(e=>LF({actionManager:a,collaborator:e,socketId:e.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:e.socketId===r}))}),o&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{className:`UserList__menu-divider`}),o]})]}):(0,V.jsx)(`div`,{className:`UserList__wrapper`,ref:p,children:(0,V.jsx)(`div`,{className:H(`UserList`,e),style:{"--max-avatars":b.length+(c?FF/PF:0)},children:x})})},(e,t)=>{if(e.collaborators.size!==t.collaborators.size||e.mobile!==t.mobile||e.className!==t.className||e.userToFollow!==t.userToFollow||e.currentUserControls!==t.currentUserControls)return!1;let n=t.collaborators.keys();for(let[r,i]of e.collaborators){let e=t.collaborators.get(r);if(!e||r!==n.next().value||!S(i,e,RF))return!1}return!0}),BF=e=>(0,V.jsx)(eT,{label:`${W(`helpDialog.title`)} \u2014 ?`,children:(0,V.jsx)(`button`,{className:`help-icon`,onClick:e.onClick,type:`button`,"aria-label":W(`helpDialog.title`),children:Eb})}),VF=({appState:e,actionManager:t,showExitZenModeBtn:n,renderWelcomeScreen:r,defaultUIEnabled:i,zoomUIEnabled:a})=>{let{FooterCenterTunnel:o,WelcomeScreenHelpHintTunnel:s}=yF(),c=iV();return(0,V.jsxs)(`footer`,{role:`contentinfo`,className:`layer-ui__wrapper__footer App-menu App-menu_bottom`,children:[(i||a&&c.isNavigationEnabled())&&(0,V.jsx)(`div`,{className:H(`layer-ui__wrapper__footer-left zen-mode-transition`,{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:(0,V.jsx)(ik.Col,{gap:2,children:(0,V.jsxs)(jF,{heading:`canvasActions`,children:[a&&c.isNavigationEnabled()&&(0,V.jsx)(pA,{renderAction:t.renderAction}),i&&!e.viewModeEnabled&&(0,V.jsx)(mA,{renderAction:t.renderAction,className:H(`zen-mode-transition`,{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})})]})})}),(0,V.jsx)(o.Out,{}),(i||r)&&(0,V.jsx)(`div`,{className:H(`layer-ui__wrapper__footer-right zen-mode-transition`,{"transition-right":e.zenModeEnabled}),children:(0,V.jsxs)(`div`,{style:{position:`relative`},children:[r&&(0,V.jsx)(s.Out,{}),i&&(0,V.jsx)(BF,{onClick:()=>t.executeAction(DE)})]})}),i&&(0,V.jsx)(hA,{actionManager:t,showExitZenModeBtn:n})]})},HF=VF;VF.displayName=`Footer`;var UF=B.createContext({}),WF=({children:e,className:t})=>{let n=oV(),r=(0,B.useContext)(UF),i=!!(n.canFitSidebar&&r.shouldRenderDockButton);return(0,V.jsxs)(`div`,{className:H(`sidebar__header`,t),"data-testid":`sidebar-header`,children:[e,(0,V.jsxs)(`div`,{className:`sidebar__header__buttons`,children:[i&&(0,V.jsx)(eT,{label:W(`labels.sidebarLock`),children:(0,V.jsx)(Rk,{onSelect:()=>r.onDock?.(!r.docked),selected:!!r.docked,className:`sidebar__dock`,"data-testid":`sidebar-dock`,"aria-label":W(`labels.sidebarLock`),children:Yy})}),(0,V.jsx)(Rk,{"data-testid":`sidebar-close`,className:`sidebar__close`,onSelect:r.onCloseRequest,"aria-label":W(`buttons.close`),children:lx})]})]})};WF.displayName=`SidebarHeader`;var GF=({children:e,tab:t,onSelect:n,...r})=>(0,V.jsx)(jv,{value:t,asChild:!0,onSelect:n,children:(0,V.jsx)(`button`,{type:`button`,className:`excalidraw-button sidebar-tab-trigger`,...r,children:e})});GF.displayName=`SidebarTabTrigger`;var KF=({children:e,...t})=>(0,V.jsx)(Av,{className:`sidebar-triggers`,...t,children:e});KF.displayName=`SidebarTabTriggers`;var qF=({name:e,tab:t,icon:n,title:r,children:i,onToggle:a,className:o,style:s})=>{let c=dV(),l=EC().openSidebar?.name===e;return(0,V.jsx)(`button`,{type:`button`,title:r,className:`sidebar-trigger__label-element`,"aria-label":r,"aria-keyshortcuts":`0`,"aria-pressed":l,onClick:()=>{document.querySelector(`.layer-ui__wrapper`)?.classList.remove(`animate`);let n=!l;c({openSidebar:n?{name:e,tab:t}:null,openMenu:null,openPopup:null}),a?.(n)},children:(0,V.jsxs)(`div`,{className:H(`sidebar-trigger`,o),style:s,children:[n&&(0,V.jsx)(`div`,{children:n}),i&&(0,V.jsx)(`div`,{className:`sidebar-trigger__label`,children:i})]})})};qF.displayName=`SidebarTrigger`;var JF=({children:e,...t})=>{let n=EC(),r=dV();if(!n.openSidebar)return null;let{name:i}=n.openSidebar;return(0,V.jsx)(kv,{className:`sidebar-tabs-root`,value:n.openSidebar.tab,onValueChange:e=>r(t=>({...t,openSidebar:{...t.openSidebar,name:i,tab:e}})),...t,children:e})};JF.displayName=`SidebarTabs`;var YF=({tab:e,children:t,...n})=>(0,V.jsx)(Mv,{...n,value:e,"data-testid":e,children:t});YF.displayName=`SidebarTab`;var XF=Gc(!1),ZF=(0,B.forwardRef)(({name:e,children:t,onDock:n,docked:r,className:i,...a},o)=>{ci()&&n&&r==null&&console.warn("Sidebar: `docked` must be set when `onDock` is supplied for the sidebar to be user-dockable. To hide this message, either pass `docked` or remove `onDock`");let s=dV(),c=Ty(XF);(0,B.useLayoutEffect)(()=>(c(!!r),()=>{c(!1)}),[c,r]);let l=(0,B.useRef)({});l.current.onCloseRequest=()=>{s({openSidebar:null})},l.current.onDock=e=>n?.(e),l.current=ds(l.current,{docked:r,shouldRenderDockButton:!!n&&r!=null});let u=(0,B.useRef)(null);(0,B.useImperativeHandle)(o,()=>u.current);let d=oV(),f=(0,B.useCallback)(()=>{document.querySelector(`.Dialog`)||s({openSidebar:null})},[s]);return OC(u,(0,B.useCallback)(e=>{e.target.closest(`.sidebar-trigger`)||(!r||!d.canFitSidebar)&&f()},[f,r,d.canFitSidebar])),(0,B.useEffect)(()=>{let e=e=>{e.key===j.ESCAPE&&(!r||!d.canFitSidebar)&&f()};return document.addEventListener(T.KEYDOWN,e),()=>{document.removeEventListener(T.KEYDOWN,e)}},[f,r,d.canFitSidebar]),(0,V.jsx)(PC,{...a,className:H(D.SIDEBAR,{"sidebar--docked":r},i),"data-viewport-ui":d.formFactor===`phone`?void 0:`side`,"data-viewport-ui-name":d.formFactor===`phone`?void 0:`sidebar`,ref:u,children:(0,V.jsx)(UF.Provider,{value:l.current,children:t})})});ZF.displayName=`SidebarInner`;var QF=Object.assign((0,B.forwardRef)((e,t)=>{let n=EC(),{onStateChange:r}=e,i=(0,B.useRef)(n.openSidebar);(0,B.useEffect)(()=>{(!n.openSidebar&&i?.current?.name===e.name||n.openSidebar?.name===e.name&&i?.current?.name!==e.name||i.current?.name===e.name)&&n.openSidebar!==i.current&&r?.(n.openSidebar?.name===e.name?n.openSidebar:null),i.current=n.openSidebar},[n.openSidebar,r,e.name]);let[a,o]=(0,B.useState)(!1);return(0,B.useLayoutEffect)(()=>(o(!0),()=>o(!1)),[]),a&&n.openSidebar?.name===e.name?(0,B.createElement)(ZF,{...e,ref:t,key:e.name}):null}),{Header:WF,TabTriggers:KF,TabTrigger:GF,Tabs:JF,Tab:YF,Trigger:qF});QF.displayName=`Sidebar`;var $F=(e,t)=>{let n=Gc(0),r=e=>{let{tunnelsJotai:{useAtom:r}}=yF(),[,i]=r(n),a=(0,B.useRef)({preferHost:!1,counter:0});return(0,B.useLayoutEffect)(()=>{let e=a.current;return i(t=>{let n=t+1;return e.counter=n,n}),()=>{i(t=>{let n=t-1;return e.counter=n,n||(e.preferHost=!1),n})}},[i]),e.__fallback||(a.current.preferHost=!0),!a.current.counter&&e.__fallback&&a.current.preferHost||a.current.counter>1&&e.__fallback?null:(0,V.jsx)(t,{...e})};return r.displayName=e,r},eI={};Mc(eI,{ChangeCanvasBackground:()=>mI,ClearCanvas:()=>fI,CommandPalette:()=>lI,Export:()=>hI,Help:()=>dI,LiveCollaborationTrigger:()=>_I,LoadScene:()=>oI,Preferences:()=>DI,PreferencesToggleGridModeItem:()=>CI,PreferencesToggleZenModeItem:()=>wI,SaveAsImage:()=>cI,SaveToActiveFile:()=>sI,SearchMenu:()=>uI,Socials:()=>gI,ToggleTheme:()=>pI});var tI=Gc({active:!1});async function nI({title:e,description:t,actionLabel:n,color:r}){return new Promise(i=>{ky.set(tI,{active:!0,onConfirm:()=>i(!0),onClose:()=>i(!1),onReject:()=>i(!1),title:e,description:t,actionLabel:n,color:r})})}var rI=function({onChange:e,value:t,choices:n,name:r}){return(0,V.jsx)(`div`,{className:`RadioGroup`,children:n.map(n=>(0,V.jsxs)(`div`,{className:H(`RadioGroup__choice`,{active:n.value===t}),title:n.ariaLabel,children:[(0,V.jsx)(`input`,{name:r,type:`radio`,checked:n.value===t,onChange:()=>e(n.value),"aria-label":n.ariaLabel}),n.label]},String(n.value)))})},iI=({value:e,shortcut:t,onChange:n,choices:r,children:i,name:a,icon:o})=>{let s=oV();return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`dropdown-menu-item-base dropdown-menu-item-bare`,children:[o&&(0,V.jsx)(`div`,{className:`dropdown-menu-item__icon`,children:o}),(0,V.jsx)(`label`,{className:`dropdown-menu-item__text`,children:(0,V.jsx)(mw,{children:i})}),(0,V.jsx)(rI,{name:a,value:e,onChange:n,choices:r})]}),t&&s.formFactor!==`phone`&&(0,V.jsx)(`div`,{className:`dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned`,children:t})]})};iI.displayName=`DropdownMenuItemContentRadio`;var aI=iI,oI=()=>{let{t:e}=Vy(),t=fV(),n=lV();return t.isActionEnabled(SE)?(0,V.jsx)(yw,{icon:Ib,onSelect:async()=>{(!n.length||await nI({title:e(`overwriteConfirm.modal.loadFromFile.title`),actionLabel:e(`overwriteConfirm.modal.loadFromFile.button`),color:`warning`,description:(0,V.jsx)(ek,{i18nKey:`overwriteConfirm.modal.loadFromFile.description`,bold:e=>(0,V.jsx)(`strong`,{children:e}),br:()=>(0,V.jsx)(`br`,{})})}))&&t.executeAction(SE)},"data-testid":`load-button`,shortcut:lO(`loadScene`),"aria-label":e(`buttons.load`),children:e(`buttons.load`)}):null};oI.displayName=`LoadScene`;var sI=()=>{let{t:e}=Vy(),t=fV();return t.isActionEnabled(bE)?(0,V.jsx)(yw,{shortcut:lO(`saveScene`),"data-testid":`save-button`,onSelect:()=>t.executeAction(bE),icon:Pb,"aria-label":`${e(`buttons.save`)}`,children:`${e(`buttons.save`)}`}):null};sI.displayName=`SaveToActiveFile`;var cI=()=>{let e=dV(),{t}=Vy();return(0,V.jsx)(yw,{icon:Bb,"data-testid":`image-export-button`,onSelect:()=>e({openDialog:{name:`imageExport`}}),shortcut:lO(`imageExport`),"aria-label":t(`buttons.exportImage`),children:t(`buttons.exportImage`)})};cI.displayName=`SaveAsImage`;var lI=e=>{let t=dV(),{t:n}=Vy();return(0,V.jsx)(yw,{icon:MS,"data-testid":`command-palette-button`,onSelect:()=>{xC(`command_palette`,`open`,`menu`),t({openDialog:{name:`commandPalette`}})},shortcut:lO(`commandPalette`),"aria-label":n(`commandPalette.title`),className:e?.className,children:n(`commandPalette.title`)})};lI.displayName=`CommandPalette`;var uI=e=>{let{t}=Vy(),n=fV();return(0,V.jsx)(yw,{icon:DS,"data-testid":`search-menu-button`,onSelect:()=>{n.executeAction(eM)},shortcut:lO(`searchMenu`),"aria-label":t(`search.title`),className:e?.className,children:t(`search.title`)})};uI.displayName=`SearchMenu`;var dI=()=>{let{t:e}=Vy(),t=fV();return(0,V.jsx)(yw,{"data-testid":`help-menu-item`,icon:Eb,onSelect:()=>t.executeAction(DE),shortcut:`?`,"aria-label":e(`helpDialog.title`),children:e(`helpDialog.title`)})};dI.displayName=`Help`;var fI=()=>{let{t:e}=Vy(),t=Ty(vA);return fV().isActionEnabled(aT)?(0,V.jsx)(yw,{icon:yb,onSelect:()=>t(`clearCanvas`),"data-testid":`clear-canvas-button`,"aria-label":e(`buttons.clearReset`),children:e(`buttons.clearReset`)}):null};fI.displayName=`ClearCanvas`;var pI=e=>{let{t}=Vy(),n=EC(),r=fV(),i=lO(`toggleTheme`),a=aV();return r.isActionEnabled(uT)?e?.allowSystemTheme?(0,V.jsx)(aI,{name:`theme`,value:e.theme,onChange:e=>{if(a.onThemeChange){a.onThemeChange(e);return}console.warn("MainMenu.DefaultItems.ToggleTheme: `<Excalidraw/> props.onThemeChange` must be defined to use system theme selection.")},choices:[{value:A.LIGHT,label:Cb,ariaLabel:`${t(`buttons.lightMode`)} - ${i}`},{value:A.DARK,label:Sb,ariaLabel:`${t(`buttons.darkMode`)} - ${i}`},{value:`system`,label:US,ariaLabel:t(`buttons.systemMode`)}],children:t(`labels.theme`)}):(0,V.jsx)(yw,{onSelect:e=>{e.preventDefault(),r.executeAction(uT)},icon:n.theme===A.DARK?Cb:Sb,"data-testid":`toggle-dark-mode`,shortcut:i,"aria-label":n.theme===A.DARK?t(`buttons.lightMode`):t(`buttons.darkMode`),children:n.theme===A.DARK?t(`buttons.lightMode`):t(`buttons.darkMode`)}):null};pI.displayName=`ToggleTheme`;var mI=()=>{let{t:e}=Vy(),t=EC(),n=fV(),r=aV();return t.viewModeEnabled||!r.UIOptions.canvasActions.changeViewBackgroundColor?null:(0,V.jsxs)(`div`,{style:{marginTop:`0.75rem`},children:[(0,V.jsx)(`div`,{"data-testid":`canvas-background-label`,style:{fontSize:`0.875rem`,marginBottom:`0.25rem`,marginLeft:`0.5rem`},children:e(`labels.canvasBackground`)}),(0,V.jsx)(`div`,{style:{padding:`0 0.625rem`},children:n.renderAction(`changeViewBackgroundColor`)})]})};mI.displayName=`ChangeCanvasBackground`;var hI=()=>{let{t:e}=Vy(),t=dV();return(0,V.jsx)(yw,{icon:Tb,onSelect:()=>{t({openDialog:{name:`jsonExport`}})},"data-testid":`json-export-button`,"aria-label":e(`buttons.export`),children:e(`buttons.export`)})};hI.displayName=`Export`;var gI=()=>{let{t:e}=Vy();return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(lk,{icon:kb,href:`https://github.com/excalidraw/excalidraw`,"aria-label":`GitHub`,children:`GitHub`}),(0,V.jsx)(lk,{icon:jb,href:`https://x.com/excalidraw`,"aria-label":`X`,children:e(`labels.followUs`)}),(0,V.jsx)(lk,{icon:Ab,href:`https://discord.gg/UexuTaE`,"aria-label":`Discord`,children:e(`labels.discordChat`)})]})};gI.displayName=`Socials`;var _I=({onSelect:e,isCollaborating:t})=>{let{t:n}=Vy();return(0,V.jsx)(yw,{"data-testid":`collab-button`,icon:sx,className:H({"active-collab":t}),onSelect:e,children:n(`labels.liveCollaboration`)})};_I.displayName=`LiveCollaborationTrigger`;var vI=()=>{let{t:e}=Vy(),t=iV(),n=EC();return(0,V.jsx)(Dk,{checked:n.activeTool.locked,shortcut:lO(`toolLock`),onSelect:e=>{t.toggleLock(),e.preventDefault()},children:e(`labels.preferences_toolLock`)})},yI=()=>{let{t:e}=Vy(),t=EC(),n=dV();return(0,V.jsx)(aI,{name:`boxSelectionMode`,icon:aC,value:t.boxSelectionMode,onChange:e=>{n({boxSelectionMode:e})},choices:[{value:`contain`,label:e(`labels.boxSelectionContain`),ariaLabel:e(`labels.boxSelectionContain`)},{value:`overlap`,label:e(`labels.boxSelectionOverlap`),ariaLabel:e(`labels.boxSelectionOverlap`)}],children:e(`labels.boxSelectionMode`)})},bI=()=>{let{t:e}=Vy(),t=fV(),n=EC();return(0,V.jsx)(Dk,{checked:n.objectsSnapModeEnabled,shortcut:lO(`objectsSnapMode`),onSelect:e=>{t.executeAction(tD),e.preventDefault()},children:e(`buttons.objectsSnapMode`)})},xI=()=>{let{t:e}=Vy(),t=fV(),n=EC();return(0,V.jsx)(Dk,{checked:n.bindingPreference===`enabled`,onSelect:e=>{t.executeAction(nD),e.preventDefault()},children:e(`labels.arrowBinding`)})},SI=()=>{let{t:e}=Vy(),t=fV(),n=EC();return(0,V.jsx)(Dk,{checked:n.isMidpointSnappingEnabled,onSelect:e=>{t.executeAction(rD),e.preventDefault()},children:e(`labels.midpointSnapping`)})},CI=()=>{let{t:e}=Vy(),t=fV(),n=EC();return(0,V.jsx)(Dk,{checked:n.gridModeEnabled,shortcut:lO(`gridMode`),onSelect:e=>{t.executeAction($E),e.preventDefault()},children:e(`labels.toggleGrid`)})},wI=()=>{let{t:e}=Vy(),t=fV(),n=EC();return(0,V.jsx)(Dk,{checked:n.zenModeEnabled,shortcut:lO(`zenMode`),onSelect:e=>{t.executeAction(eD),e.preventDefault()},children:e(`buttons.zenMode`)})},TI=()=>{let{t:e}=Vy(),t=fV(),n=EC();return t.isActionEnabled(Qk)?(0,V.jsx)(Dk,{checked:n.viewModeEnabled,shortcut:lO(`viewMode`),onSelect:e=>{t.executeAction(Qk),e.preventDefault()},children:e(`labels.viewMode`)}):null},EI=()=>{let{t:e}=Vy(),t=fV(),n=EC();return(0,V.jsx)(Dk,{checked:n.stats.open,shortcut:lO(`stats`),onSelect:e=>{t.executeAction(iD),e.preventDefault()},children:e(`stats.fullTitle`)})},DI=({children:e,additionalItems:t})=>{let{t:n}=Vy();return(0,V.jsxs)(wk,{children:[(0,V.jsx)(wk.Trigger,{icon:cC,children:n(`labels.preferences`)}),(0,V.jsxs)(wk.Content,{className:`excalidraw-main-menu-preferences-submenu`,children:[e||(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(yI,{}),(0,V.jsx)(vI,{}),(0,V.jsx)(bI,{}),(0,V.jsx)(CI,{}),(0,V.jsx)(wI,{}),(0,V.jsx)(TI,{}),(0,V.jsx)(EI,{}),(0,V.jsx)(xI,{}),(0,V.jsx)(SI,{})]}),t]})]})};DI.ToggleToolLock=vI,DI.BoxSelectionMode=yI,DI.ToggleSnapMode=bI,DI.ToggleArrowBinding=xI,DI.ToggleMidpointSnapping=SI,DI.ToggleGridMode=CI,DI.ToggleZenMode=wI,DI.ToggleViewMode=TI,DI.ToggleElementProperties=EI,DI.displayName=`Preferences`;var OI=Object.assign($F(`MainMenu`,({children:e,onSelect:t})=>{let{MainMenuTunnel:n}=yF(),r=oV(),i=EC(),a=aV(),o=dV();return(0,V.jsx)(n.In,{children:(0,V.jsxs)(Z,{open:i.openMenu===`canvas`,children:[(0,V.jsx)(Z.Trigger,{onToggle:()=>{o({openMenu:i.openMenu===`canvas`?null:`canvas`,openPopup:null,openDialog:null})},"data-testid":`main-menu-trigger`,className:`main-menu-trigger`,children:wb}),(0,V.jsxs)(Z.Content,{onClickOutside:()=>o({openMenu:null}),onSelect:Xo(t,()=>{o({openMenu:null})}),className:`main-menu`,align:`start`,children:[e,r.formFactor===`phone`&&i.collaborators.size>0&&(0,V.jsxs)(`fieldset`,{className:`UserList-Wrapper`,children:[(0,V.jsx)(`legend`,{children:W(`labels.collaborators`)}),(0,V.jsx)(zF,{mobile:!0,collaborators:i.collaborators,userToFollow:a.userToFollow?.socketId||null,currentUserControls:a.currentUserControls})]})]})]})})}),{Trigger:Z.Trigger,Item:Z.Item,ItemLink:Z.ItemLink,ItemCustom:Z.ItemCustom,Group:Z.Group,Separator:Z.Separator,Sub:wk,DefaultItems:eI}),kI=(0,B.forwardRef)(({children:e,icon:t,onClick:n,label:r,variant:i=`filled`,color:a=`primary`,size:o=`medium`,fullWidth:s,className:c,status:l,disabled:u},d)=>{let[f,p]=(0,B.useState)(!1),m=async e=>{let t=n?.(e);if(nt(t)){let e=window.setTimeout(()=>{p(!0)},50);try{await t}catch(e){if(e instanceof Cn)console.warn(e);else throw e}finally{clearTimeout(e),p(!1)}}},h=f?`loading`:l;return a=h===`success`?`success`:a,(0,V.jsx)(`button`,{className:H(`ExcButton`,`ExcButton--color-${a}`,`ExcButton--variant-${i}`,`ExcButton--size-${o}`,`ExcButton--status-${h}`,{"ExcButton--fullWidth":s},c),onClick:m,type:`button`,"aria-label":r,ref:d,disabled:u||h===`loading`||h===`success`,children:(0,V.jsxs)(`div`,{className:`ExcButton__contents`,children:[h===`loading`?(0,V.jsx)(lC,{className:`ExcButton__statusIcon`}):h===`success`&&(0,V.jsx)(`div`,{className:`ExcButton__statusIcon`,children:dS}),t&&(0,V.jsx)(`div`,{className:`ExcButton__icon`,"aria-hidden":!0,children:t}),i!==`icon`&&(e??r)]})})}),AI=({title:e,children:t,actionLabel:n,onClick:r})=>(0,V.jsxs)(`div`,{className:`OverwriteConfirm__Actions__Action`,children:[(0,V.jsx)(`h4`,{children:e}),(0,V.jsx)(`div`,{className:`OverwriteConfirm__Actions__Action__content`,children:t}),(0,V.jsx)(kI,{variant:`outlined`,color:`muted`,label:n,size:`large`,fullWidth:!0,onClick:r})]}),jI=Object.assign(({children:e})=>(0,V.jsx)(`div`,{className:`OverwriteConfirm__Actions`,children:e}),{ExportToImage:()=>{let{t:e}=Vy(),t=fV(),n=dV();return(0,V.jsx)(AI,{title:e(`overwriteConfirm.action.exportToImage.title`),actionLabel:e(`overwriteConfirm.action.exportToImage.button`),onClick:()=>{t.executeAction(hE,`ui`,!0),n({openDialog:{name:`imageExport`}})},children:e(`overwriteConfirm.action.exportToImage.description`)})},SaveToDisk:()=>{let{t:e}=Vy(),t=fV();return(0,V.jsx)(AI,{title:e(`overwriteConfirm.action.saveToDisk.title`),actionLabel:e(`overwriteConfirm.action.saveToDisk.button`),onClick:()=>{t.executeAction(xE,`ui`)},children:e(`overwriteConfirm.action.saveToDisk.description`)})}}),MI=Object.assign($F(`OverwriteConfirmDialog`,({children:e})=>{let{OverwriteConfirmDialogTunnel:t}=yF(),[n,r]=wy(tI);return n.active?(0,V.jsx)(t.In,{children:(0,V.jsx)(Zk,{onCloseRequest:()=>{n.onClose(),r(e=>({...e,active:!1}))},title:!1,size:916,children:(0,V.jsxs)(`div`,{className:`OverwriteConfirm`,children:[(0,V.jsx)(`h3`,{children:n.title}),(0,V.jsxs)(`div`,{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${n.color}`,children:[(0,V.jsx)(`div`,{className:`OverwriteConfirm__Description__icon`,children:fS}),(0,V.jsx)(`div`,{children:n.description}),(0,V.jsx)(`div`,{className:`OverwriteConfirm__Description__spacer`}),(0,V.jsx)(kI,{color:n.color,size:`large`,label:n.actionLabel,onClick:()=>{n.onConfirm(),r(e=>({...e,active:!1}))}})]}),(0,V.jsx)(jI,{children:e})]})})}):null}),{Actions:jI,Action:AI}),NI=Gc(``),PI=Gc(null),FI=350,II=()=>{let e=iV(),t=dV(),n=(0,B.useRef)(null),[r,i]=wy(NI),a=r.trim(),[o,s]=(0,B.useState)(!1),[c,l]=(0,B.useState)({nonce:null,items:[]}),u=(0,B.useRef)(null),d=(0,B.useRef)(void 0),[f,p]=wy(PI),m=e.scene.getNonDeletedElementsMap();(0,B.useEffect)(()=>{o||(a!==u.current||e.scene.getSceneNonce()!==d.current)&&(u.current=null,WI(a,e,(n,r)=>{l({nonce:za(),items:n}),u.current=a,d.current=e.scene.getSceneNonce(),t({searchMatches:n.length?{focusedId:null,matches:n.map(e=>({id:e.element.id,focus:!1,matchedLines:e.matchedLines}))}:null})}))},[o,a,m,e,t,p,d]);let h=()=>{c.items.length>0&&p(e=>e===null?0:(e+1)%c.items.length)},g=()=>{c.items.length>0&&p(e=>e===null?0:e-1<0?c.items.length-1:e-1)};(0,B.useEffect)(()=>{t(e=>e.searchMatches?{searchMatches:{focusedId:f!==null&&e.searchMatches?.matches[f]?.id||null,matches:e.searchMatches.matches.map((e,t)=>t===f?{...e,focus:!0}:{...e,focus:!1})}}:null)},[f,t]),(0,B.useEffect)(()=>{if(c.items.length>0&&f!==null){let t=c.items[f];if(t){let n=e.state.zoom.value,r=oc({text:t.searchQuery,x:t.element.x+(t.matchedLines[0]?.offsetX??0),y:t.element.y+(t.matchedLines[0]?.offsetY??0),width:t.matchedLines[0]?.width,height:t.matchedLines[0]?.height,fontSize:P(t.element)?Wr.nameFontSize:t.element.fontSize,fontFamily:P(t.element)?Na.Assistant:t.element.fontFamily}),i=r.fontSize,a=i*n<14;if(!Tr([r],e.canvas.width/window.devicePixelRatio,e.canvas.height/window.devicePixelRatio,{offsetLeft:e.state.offsetLeft,offsetTop:e.state.offsetTop,scrollX:e.state.scrollX,scrollY:e.state.scrollY,zoom:e.state.zoom},e.scene.getNonDeletedElementsMap(),e.viewport.getOffsets())||a){let t=a&&i<14?`contain`:`scale-down`;e.viewport.setViewport({target:Is([r]),fit:t,animation:{duration:300},offsets:{ui:!0}})}}}},[f,c,e]),(0,B.useEffect)(()=>()=>{p(null),u.current=null,d.current=void 0,t({searchMatches:null}),s(!1)},[t,p]);let _=kC({goToNextItem:h,goToPreviousItem:g,searchMatches:c});(0,B.useEffect)(()=>ki(window,T.KEYDOWN,r=>{if(r.key===j.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){r.preventDefault(),r.stopPropagation(),t({openSidebar:null});return}if(r[j.CTRL_OR_CMD]&&r.key===j.F){if(r.preventDefault(),r.stopPropagation(),e.state.openDialog)return;n.current?.matches(`:focus`)||(e.state.openDialog&&t({openDialog:null}),n.current?.focus(),n.current?.select())}r.target instanceof HTMLElement&&r.target.closest(`.layer-ui__search`)&&_.searchMatches.items.length&&(r.key===j.ENTER&&(r.stopPropagation(),_.goToNextItem()),r.key===j.ARROW_UP?(r.stopPropagation(),_.goToPreviousItem()):r.key===j.ARROW_DOWN&&(r.stopPropagation(),_.goToNextItem()))},{capture:!0,passive:!1}),[t,_,e]);let v=`${c.items.length} ${c.items.length===1?W(`search.singleResult`):W(`search.multipleResults`)}`;return(0,V.jsxs)(`div`,{className:`layer-ui__search`,children:[(0,V.jsx)(`div`,{className:`layer-ui__search-header`,children:(0,V.jsx)(zk,{className:D.SEARCH_MENU_INPUT_WRAPPER,value:r,ref:n,placeholder:W(`search.placeholder`),icon:DS,onChange:n=>{i(n),s(!0);let r=n.trim();WI(r,e,(n,i)=>{l({nonce:za(),items:n}),p(i),u.current=r,d.current=e.scene.getSceneNonce(),t({searchMatches:n.length?{focusedId:null,matches:n.map(e=>({id:e.element.id,focus:!1,matchedLines:e.matchedLines}))}:null}),s(!1)})},selectOnRender:!0})}),(0,V.jsxs)(`div`,{className:`layer-ui__search-count`,children:[c.items.length>0&&(0,V.jsxs)(V.Fragment,{children:[f!==null&&f>-1?(0,V.jsxs)(`div`,{children:[f+1,` / `,v]}):(0,V.jsx)(`div`,{children:v}),(0,V.jsxs)(`div`,{className:`result-nav`,children:[(0,V.jsx)(Rk,{onSelect:()=>{h()},className:`result-nav-btn`,children:XS}),(0,V.jsx)(Rk,{onSelect:()=>{g()},className:`result-nav-btn`,children:QS})]})]}),c.items.length===0&&a&&u.current&&(0,V.jsx)(`div`,{style:{margin:`1rem auto`},children:W(`search.noMatch`)})]}),(0,V.jsx)(RI,{matches:c,onItemClick:p,focusIndex:f,searchQuery:a})]})},LI=e=>{let t=[e.preview.moreBefore?`...`:``,e.preview.previewText.slice(0,e.preview.indexInSearchQuery),e.preview.previewText.slice(e.preview.indexInSearchQuery,e.preview.indexInSearchQuery+e.searchQuery.length),e.preview.previewText.slice(e.preview.indexInSearchQuery+e.searchQuery.length),e.preview.moreAfter?`...`:``];return(0,V.jsx)(`div`,{tabIndex:-1,className:H(`layer-ui__result-item`,{active:e.highlighted}),onClick:e.onClick,ref:t=>{e.highlighted&&t?.scrollIntoView({behavior:`auto`,block:`nearest`})},children:(0,V.jsx)(`div`,{className:`preview-text`,children:t.flatMap((e,t)=>(0,V.jsx)(B.Fragment,{children:t===2?(0,V.jsx)(`b`,{children:e}):e},t))})})},RI=(0,B.memo)(e=>{let t=(0,B.useMemo)(()=>e.matches.items.filter(e=>P(e.element)),[e.matches]),n=(0,B.useMemo)(()=>e.matches.items.filter(e=>a(e.element)),[e.matches]);return(0,V.jsxs)(`div`,{children:[t.length>0&&(0,V.jsxs)(`div`,{className:`layer-ui__search-result-container`,children:[(0,V.jsxs)(`div`,{className:`layer-ui__search-result-title`,children:[(0,V.jsx)(`div`,{className:`title-icon`,children:mS}),(0,V.jsx)(`div`,{children:W(`search.frames`)})]}),t.map((t,n)=>(0,V.jsx)(LI,{searchQuery:e.searchQuery,preview:t.preview,highlighted:n===e.focusIndex,onClick:()=>e.onItemClick(n)},t.element.id+t.index)),n.length>0&&(0,V.jsx)(`div`,{className:`layer-ui__divider`})]}),n.length>0&&(0,V.jsxs)(`div`,{className:`layer-ui__search-result-container`,children:[(0,V.jsxs)(`div`,{className:`layer-ui__search-result-title`,children:[(0,V.jsx)(`div`,{className:`title-icon`,children:fb}),(0,V.jsx)(`div`,{children:W(`search.texts`)})]}),n.map((n,r)=>(0,V.jsx)(LI,{searchQuery:e.searchQuery,preview:n.preview,highlighted:r+t.length===e.focusIndex,onClick:()=>e.onItemClick(r+t.length)},n.element.id+n.index))]})]})},(e,t)=>e.matches.nonce===t.matches.nonce&&e.focusIndex===t.focusIndex),zI=(e,t,n)=>{let r=e.slice(0,t),i=r.split(/\s+/),a=r.endsWith(` `),o=i.length-2-1-!a,s=i.slice(o<=0?0:o).join(` `)+(a?` `:``);s=s.length>20?s.slice(-20):s;let c=e.slice(t+n.length),l=c.split(/\s+/),u=!c.startsWith(` `),d=u?6:5,f=(u?``:` `)+l.slice(0,d).join(` `);return{indexInSearchQuery:s.length,previewText:s+n+f,moreBefore:o>0,moreAfter:l.length>d}},BI=(e,t)=>{let n=e.split(`
|
|
60
|
-
`),r=[],i=0;for(let e=0;e<n.length;e++){let a=n[e],o=n[e+1];if(o){let e=t.indexOf(o,i);if(e>a.length+i){let t=e-(a.length+i);for(;t>0;)a+=` `,t--}}r.push(a),i+=a.length}return r.join(`
|
|
61
|
-
`)},VI=(e,t,n)=>{let r=BI(e.text,e.originalText).split(`
|
|
62
|
-
`),i=[],a=0,o=0;for(let e of r){let t=a,n=t+e.length-1;i.push({line:e,startIndex:t,endIndex:n,lineNumber:o}),a=n+1,o++}let s=n,c=e.originalText.slice(n,n+t.length),l=[];for(let t of i){if(c===``)break;if(s>=t.startIndex&&s<=t.endIndex){let n=t.endIndex+1-s,r=t.line.slice(0,s-t.startIndex),i=c.slice(0,n);c=c.slice(n);let a=uo(r,tc(e),e.lineHeight);if(r===``&&(a.width=0),e.textAlign!==`left`&&t.line.length>0){let n=uo(t.line,tc(e),e.lineHeight),r=e.textAlign===`center`?(e.width-n.width)/2:e.width-n.width;a.width+=r}let{width:o,height:u}=uo(i,tc(e),e.lineHeight),d=a.width,f=t.lineNumber*a.height;l.push({offsetX:d,offsetY:f,width:o,height:u,showOnCanvas:!0}),s+=n}}return l},HI=(e,t,n,r)=>{let i=e.name??Fo(e),a=i.slice(n,n+t.length),o=i.slice(0,n),s=tc({fontSize:Wr.nameFontSize,fontFamily:Na.Assistant}),c=zs(Na.Assistant),l=uo(o,s,c);o===``&&(l.width=0);let u=uo(a,s,c),d=l.width,f=-l.height-Wr.strokeWidth,p=u.width;return[{offsetX:d,offsetY:f,width:p,height:u.height,showOnCanvas:d+p<=e.width*r}]},UI=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,`\\$&`),WI=(0,Sy.default)((e,t,n)=>{if(!e||e===``){n([],null);return}let r=t.scene.getNonDeletedElements(),i=r.filter(e=>a(e)),o=r.filter(e=>P(e));i.sort((e,t)=>e.y-t.y),o.sort((e,t)=>e.y-t.y);let s=[],c=new RegExp(UI(e),`gi`);for(let t of i){let n=null,r=t.originalText;for(;(n=c.exec(r))!==null;){let i=zI(r,n.index,e),a=VI(t,e,n.index);a.length>0&&s.push({element:t,searchQuery:e,preview:i,index:n.index,matchedLines:a})}}let l=[];for(let n of o){let r=null,i=n.name??Fo(n);for(;(r=c.exec(i))!==null;){let a=zI(i,r.index,e),o=HI(n,e,r.index,t.state.zoom.value);o.length>0&&l.push({element:n,searchQuery:e,preview:a,index:r.index,matchedLines:o})}}let u=new Set(t.visibleElements.map(e=>e.id)),d=[...l,...s];n(d,d.findIndex(e=>u.has(e.element.id))??null)},FI),GI=$F(`DefaultSidebarTrigger`,e=>{let{DefaultSidebarTriggerTunnel:t}=yF();return(0,V.jsx)(t.In,{children:(0,V.jsx)(QF.Trigger,{...e,className:`default-sidebar-trigger`,name:bo.name})})});GI.displayName=`DefaultSidebarTrigger`;var KI=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:t}=yF();return(0,V.jsx)(t.In,{children:e})};KI.displayName=`DefaultTabTriggers`;var qI=Object.assign($F(`DefaultSidebar`,({children:e,className:t,onDock:n,docked:r,...i})=>{let a=EC(),o=dV(),{DefaultSidebarTabTriggersTunnel:s}=yF(),c=a.openSidebar?.tab===Or;return(0,B.createElement)(QF,{...i,name:`default`,key:`default`,className:H(`default-sidebar`,t),docked:c||(r??a.defaultSidebarDockedPreference),onDock:c||n===!1||!n&&r!=null?void 0:Xo(n,e=>{o({defaultSidebarDockedPreference:e})})},(0,V.jsxs)(QF.Tabs,{children:[(0,V.jsx)(QF.Header,{children:(0,V.jsxs)(QF.TabTriggers,{children:[(0,V.jsx)(QF.TabTrigger,{tab:Or,children:DS}),(0,V.jsx)(QF.TabTrigger,{tab:$o,children:Gy}),(0,V.jsx)(s.Out,{})]})}),(0,V.jsx)(QF.Tab,{tab:$o,children:(0,V.jsx)(Jk,{})}),(0,V.jsx)(QF.Tab,{tab:Or,children:(0,V.jsx)(II,{})}),e]}))}),{Trigger:GI,TabTriggers:KI}),JI=300,YI=({input:e,placeholder:t,onChange:r,onKeyboardSubmit:i,errorLine:a})=>{let o=(0,B.useRef)(null),s=(0,B.useRef)(i);s.current=i;let[c,l]=(0,B.useState)({type:`loading`}),[u,d]=(0,B.useState)(!1),{theme:f}=EC();if((0,B.useEffect)(()=>{let e=!1,t=setTimeout(()=>{e||d(!0)},JI);return n(()=>import(`./CodeMirrorEditor-UCMRAMCV-CYM5nxUi.js`).then(t=>{e||l({type:`ready`,component:t.default})}),__vite__mapDeps([65,2,66,1,67,68]),import.meta.url).catch(()=>{e||l({type:`fallback`})}).finally(()=>{clearTimeout(t)}),()=>{e=!0,clearTimeout(t)}},[]),(0,B.useEffect)(()=>{if(c.type!==`fallback`||!s.current)return;let e=o.current;if(e){let t=e=>{e[j.CTRL_OR_CMD]&&e.key===j.ENTER&&(e.preventDefault(),s.current?.())};return e.focus(),e.addEventListener(T.KEYDOWN,t),()=>{e.removeEventListener(T.KEYDOWN,t)}}},[c.type]),c.type===`ready`){let n=c.component;return(0,V.jsx)(n,{value:e,onChange:r,onKeyboardSubmit:i,placeholder:t,theme:f,errorLine:a})}return c.type===`fallback`?(0,V.jsx)(`textarea`,{className:`ttd-dialog-input`,onChange:e=>r(e.target.value),value:e,placeholder:t,ref:o}):u?(0,V.jsx)(`div`,{className:`ttd-dialog-input ttd-dialog-input--loading`,children:(0,V.jsx)(lC,{})}):null},XI=/(?:Parse|Lexical) error on line (\d+)[.:]/i,ZI=/Trying to inactivate an inactive participant \((.+)\)/i,QI=/^\s*-+\^\s*$/,$I=e=>XI.test(e),eL=e=>$I(e)||ZI.test(e),tL=e=>QI.test(e),nL=e=>{let t=e.match(ZI);return t?.[1]?t[1].trim():null},rL=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),iL=(e,t)=>{let n=nL(e);if(!n)return null;let r=RegExp(`^\\s*deactivate\\s+${rL(n)}(?:\\s+%%.*)?\\s*$`),i=t.split(/\r?\n/);for(let e=i.length-1;e>=0;e--)if(r.test(i[e]))return e+1;return null},aL=(e,t)=>{let n=e.match(XI);return n?Number.parseInt(n[1],10):t?iL(e,t):null},oL=(e,t)=>(e.match(t)||[]).length,sL=(e,t)=>{if(!$I(e))return null;let n=aL(e,t),r=n?`Syntax error near line ${n}.`:`Syntax error in Mermaid diagram.`,i=[];return t&&(oL(t,/\[/g)!==oL(t,/\]/g)&&i.push(`Unbalanced square brackets in a node label.`),oL(t,/\(/g)!==oL(t,/\)/g)&&i.push(`Unbalanced parentheses in a node shape.`),oL(t,/\{/g)!==oL(t,/\}/g)&&i.push(`Unbalanced braces in a decision node.`),oL(t,/^\s*subgraph\b/gm)>oL(t,/^\s*end\s*$/gm)&&i.push("A block is missing an `end` statement.")),(/got 'NODE_STRING'/.test(e)||/got 'PS'/.test(e))&&i.push(`An extra character/token may appear after a node or label definition.`),i.length===0&&(i.push(`A node or edge line is malformed (missing/extra delimiters).`),i.push("A block (`subgraph`, `class`, etc.) may be incomplete.")),{summary:r,likelyCauses:[...new Set(i)]}},cL=e=>$I(e)?e.replace(/\n\s*Expecting[\s\S]*$/,``).trimEnd():e,lL=({error:e,canvasRef:t,loaded:n,hideErrorDetails:r,sourceText:i,autoFixAvailable:a,onApplyAutoFix:o})=>{let s=e?r?W(`chat.errors.mermaidParseError`):cL(e.message):null,c=e&&!r?sL(e.message,i):null,l=!!a&&!!o&&!r,u=s?.split(/\r?\n/)??[];return(0,V.jsxs)(`div`,{className:`ttd-dialog-output-wrapper ${e?`ttd-dialog-output-wrapper--error`:``}`,children:[e&&(0,V.jsx)(`div`,{"data-testid":`ttd-dialog-output-error`,className:`ttd-dialog-output-error`,children:(0,V.jsxs)(`div`,{className:`ttd-dialog-output-error-content`,children:[(0,V.jsx)(`div`,{className:`ttd-dialog-output-error-icon`,children:fS}),c&&(0,V.jsxs)(`div`,{className:`ttd-dialog-output-error-summary`,children:[(0,V.jsx)(`div`,{className:`ttd-dialog-output-error-summary__headline`,children:c.summary}),(0,V.jsx)(`div`,{className:`ttd-dialog-output-error-summary__label`,children:`Likely causes:`}),(0,V.jsx)(`ul`,{className:`ttd-dialog-output-error-summary__causes`,children:c.likelyCauses.map(e=>(0,V.jsx)(`li`,{children:e},e))})]}),(0,V.jsx)(`div`,{className:`ttd-dialog-output-error-message`,children:u.map((e,t)=>(0,V.jsxs)(`span`,{className:tL(e)?`ttd-dialog-output-error-message__caret`:void 0,children:[e,t<u.length-1?`
|
|
63
|
-
`:``]},`error-line-${t}`))}),!r&&(0,V.jsx)(`div`,{className:`ttd-dialog-output-error-autofix-slot`,children:l?(0,V.jsx)(Rk,{className:`ttd-dialog-panel-button ttd-dialog-output-error-autofix`,onSelect:o,children:W(`mermaid.autoFixAvailable`)}):null})]})},`error`),n?(0,V.jsx)(`div`,{className:H(`ttd-dialog-output-canvas-container`,{invisible:!!e}),children:(0,V.jsx)(`div`,{ref:t,className:`ttd-dialog-output-canvas-content`})},`canvas`):(0,V.jsx)(lC,{size:`2rem`})]})},uL=({label:e,children:t,panelActions:n=[],onTextSubmitInProgess:r,renderTopRight:i,renderSubmitShortcut:a,className:o,panelActionJustifyContent:s=`flex-start`})=>{let c=e=>{if(e?.variant===`link`)return(0,V.jsxs)(`button`,{className:H(`ttd-dialog-panel-action-link`,e.className),onClick:e.action,disabled:e?.disabled||r,type:`button`,children:[e.label,e.icon&&(0,V.jsx)(`span`,{className:`ttd-dialog-panel-action-link__icon`,children:e.icon})]});if(e?.variant===`button`)return(0,V.jsxs)(Rk,{className:H(`ttd-dialog-panel-button`,e.className),onSelect:e.action?e.action:()=>{},disabled:e?.disabled||r,children:[(0,V.jsxs)(`div`,{className:H({invisible:r}),children:[e?.label,e?.icon&&(0,V.jsx)(`span`,{children:e.icon})]}),r&&(0,V.jsx)(lC,{})]});if(e?.variant===`rateLimit`)return(0,V.jsx)(`div`,{className:H(`ttd-dialog-panel__rate-limit`,e.className),children:e.label})};return(0,V.jsxs)(`div`,{className:H(`ttd-dialog-panel`,o),children:[(e||i)&&(0,V.jsxs)(`div`,{className:`ttd-dialog-panel__header`,children:[typeof e==`string`?(0,V.jsx)(`label`,{children:e}):e,i?.()]}),t,(0,V.jsxs)(`div`,{className:H(`ttd-dialog-panel-button-container`,{invisible:!n.length}),style:{justifyContent:s},children:[n.filter(Boolean).map(e=>(0,V.jsx)(B.Fragment,{children:c(e)},e.label)),!r&&a?.()]})]})},dL=({children:e})=>(0,V.jsx)(`div`,{className:`ttd-dialog-panels`,children:e}),fL=()=>(0,V.jsxs)(`div`,{className:`ttd-dialog-submit-shortcut`,children:[(0,V.jsx)(`div`,{className:`ttd-dialog-submit-shortcut__key`,children:X(`CtrlOrCmd`)}),(0,V.jsx)(`div`,{className:`ttd-dialog-submit-shortcut__key`,children:X(`Enter`)})]}),pL=(e,t)=>{let n=aL(e,t);return n==null?null:n-1},mL=(e,t,n)=>{if(t<0||t>=e.length)return null;let r=n(e[t]);if(r===e[t])return null;let i=[...e];return i[t]=r,i.join(`
|
|
64
|
-
`)},hL=e=>{let t=e.match(/^(.*(?:\[[^\]]*]|\([^)]*\)|\{[^}]*}|"(?:[^"]*)"|'(?:[^']*)'))([A-Za-z]+)\s*$/);if(t)return t[1];let n=e.match(/^(.*(?:\[[^\]]*]|\([^)]*\)|\{[^}]*}|"(?:[^"]*)"|'(?:[^']*)'))([,;:])\s*$/);return n?n[1]:e},gL=e=>e.replace(/(\|[^|\n]+\|)\s*>\s*(?=[A-Za-z0-9_("[{'`])/g,`$1 `),_L=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),vL=(e,t)=>{let n=RegExp(`^\\s*deactivate\\s+${_L(t)}(?:\\s+%%.*)?\\s*$`),r=e.split(/\r?\n/);for(let e=r.length-1;e>=0;e--)if(n.test(r[e]))return r.filter((t,n)=>n!==e).join(`
|
|
65
|
-
`);return null},yL=(e,t)=>{let n=RegExp(`^\\s*deactivate\\s+${_L(t)}(?:\\s+%%.*)?\\s*$`),r=e.split(/\r?\n/),i=!1,a=r.filter(e=>!n.test(e)||(i=!0,!1));return i?a.join(`
|
|
66
|
-
`):null},bL=e=>{let t=(e.match(/^\s*subgraph\b/gm)||[]).length-(e.match(/^\s*end\s*$/gm)||[]).length;if(t<=0)return null;let n=Array.from({length:t},()=>`end`).join(`
|
|
67
|
-
`);return`${e.trimEnd()}
|
|
68
|
-
${n}`},xL=e=>e.replace(/[“”]/g,`"`).replace(/[‘’]/g,`'`),SL=(e,t)=>{if(!eL(t)||!e.trim())return[];let n=[],r=new Set,i=t=>{!t||t===e||r.has(t)||(r.add(t),n.push(t))},a=nL(t);if(a&&(i(vL(e,a)),i(yL(e,a))),$I(t)){let n=e.split(/\r?\n/),r=pL(t,e),a=r==null?[]:[r,r-1,r+1];for(let e of a)i(mL(n,e,e=>hL(e))),i(mL(n,e,e=>gL(e)));i(gL(e)),i(bL(e));let o=xL(e);i(o===e?null:o)}return n},CL=({canvasRef:e,setError:t})=>{let n=e.current;if(!n)return;let r=n.parentElement;r&&(r.style.background=``,t(null),n.replaceChildren())},wL=async({canvasRef:e,mermaidToExcalidrawLib:t,mermaidDefinition:n,setError:r,data:i,theme:a})=>{let o=e.current,s=o?.parentElement;if(!o||!s)return{success:!1};if(!n)return CL({canvasRef:e,setError:r}),{success:!1};let c;try{let e=await t.api;try{c=await e.parseMermaidToExcalidraw(n)}catch(t){let r=t;if(!n.includes(`"`))return{success:!1,error:r};try{c=await e.parseMermaidToExcalidraw(n.replace(/"/g,`'`))}catch{return{success:!1,error:r}}}let{elements:l,files:u={}}=c;r(null),i.current={elements:Hs(l,{regenerateIds:!0}),files:u};let d=await hO({elements:i.current.elements,files:i.current.files,exportPadding:10,maxWidthOrHeight:Math.max(s.offsetWidth,s.offsetHeight)*window.devicePixelRatio,appState:{exportWithDarkMode:a===A.DARK}});return s.style.background=`var(--default-bg-color)`,o.replaceChildren(d),{success:!0}}catch(e){return s.style.background=`var(--default-bg-color)`,n&&r(e),{success:!1,error:e}}},TL=e=>{JO.set(Io.MERMAID_TO_EXCALIDRAW,e)},EL=({app:e,data:t,text:n,shouldSaveMermaidDataToStorage:r})=>{let{elements:i,files:a}=t.current;i.length&&(e.addElementsFromPasteOrLibrary({elements:i,files:a,position:`center`,fit:`scale-down`}),e.setOpenDialog(null),r&&n&&TL(n))},DL=`flowchart TD
|
|
69
|
-
A[Christmas] -->|Get money| B(Go shopping)
|
|
70
|
-
B --> C{Let me think}
|
|
71
|
-
C -->|One| D[Laptop]
|
|
72
|
-
C -->|Two| E[iPhone]
|
|
73
|
-
C -->|Three| F[Car]`,OL=ke(TL,300),kL=500,AL=4,jL=30,ML=e=>e instanceof Error?e.message:typeof e==`string`?e:e&&typeof e==`object`&&`message`in e&&typeof e.message==`string`?e.message:``,NL=({mermaidToExcalidrawLib:e,isActive:t})=>{let[n,r]=(0,B.useState)(()=>JO.get(Io.MERMAID_TO_EXCALIDRAW)||DL),i=(0,B.useDeferredValue)(n),[a,o]=(0,B.useState)(null),[s,c]=(0,B.useState)(null),l=a?.message?aL(a.message,i):null,u=(0,B.useRef)(null),d=(0,B.useRef)({elements:[],files:null}),f=iV(),{theme:p}=EC();(0,B.useEffect)(()=>{t&&((async()=>{try{if(!i.trim()){CL({canvasRef:u,setError:o});return}let t=await wL({canvasRef:u,data:d,mermaidToExcalidrawLib:e,setError:o,mermaidDefinition:i,theme:p});if(!t.success){let e=t.error??Error(`Invalid mermaid definition`);o(e)}}catch(e){ci()&&console.error(`Failed to parse mermaid definition`,e)}})(),OL(i))},[i,e,t,p]),(0,B.useEffect)(()=>()=>{OL.flush()},[]),(0,B.useEffect)(()=>{let n=a?.message??``,r=i;if(!(t&&eL(n)&&r.trim()&&e.loaded)){c(null);return}let o=SL(r,n);if(!o.length){c(null);return}let s=!1,l=setTimeout(async()=>{try{let t=await e.api,n=new Set([r]),i=o.map(e=>({text:e,depth:1})),a=0;for(;i.length>0&&a<jL;){let e=i.shift();if(!(!e||n.has(e.text))){n.add(e.text),a+=1;try{await t.parseMermaidToExcalidraw(e.text),s||c(e.text);return}catch(t){if(e.depth>=AL)continue;let r=ML(t);if(!r)continue;let a=SL(e.text,r);for(let t of a)n.has(t)||i.push({text:t,depth:e.depth+1})}}}}catch{}s||c(null)},kL);return()=>{s=!0,clearTimeout(l)}},[i,a?.message,t,e]);let m=()=>{EL({app:f,data:d,text:n,shouldSaveMermaidDataToStorage:!0})};return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{className:`ttd-dialog-desc`,children:(0,V.jsx)(ek,{i18nKey:`mermaid.description`,flowchartLink:e=>(0,V.jsx)(`a`,{href:`https://mermaid.js.org/syntax/flowchart.html`,target:`_blank`,rel:`noreferrer`,children:e}),sequenceLink:e=>(0,V.jsx)(`a`,{href:`https://mermaid.js.org/syntax/sequenceDiagram.html`,target:`_blank`,rel:`noreferrer`,children:e}),classLink:e=>(0,V.jsx)(`a`,{href:`https://mermaid.js.org/syntax/classDiagram.html`,target:`_blank`,rel:`noreferrer`,children:e}),erdLink:e=>(0,V.jsx)(`a`,{href:`https://mermaid.js.org/syntax/entityRelationshipDiagram.html`,target:`_blank`,rel:`noreferrer`,children:e})})}),(0,V.jsxs)(dL,{children:[(0,V.jsx)(uL,{children:(0,V.jsx)(YI,{input:n,placeholder:W(`mermaid.inputPlaceholder`),onChange:e=>r(e),errorLine:l,onKeyboardSubmit:()=>{m()}})}),(0,V.jsx)(uL,{panelActions:[{action:()=>{m()},label:W(`mermaid.button`),icon:vS,variant:`button`}],renderSubmitShortcut:()=>(0,V.jsx)(fL,{}),children:(0,V.jsx)(lL,{canvasRef:u,loaded:e.loaded,error:a,sourceText:n,autoFixAvailable:!!s,onApplyAutoFix:()=>{s&&r(s)}})})]})]})},PL=()=>(0,V.jsxs)(`div`,{className:`chat-interface__welcome-screen__welcome-message`,children:[(0,V.jsx)(`h3`,{children:W(`chat.placeholder.title`)}),(0,V.jsx)(`p`,{children:W(`chat.placeholder.description`)}),(0,V.jsx)(`p`,{children:W(`chat.placeholder.hint`)})]}),FL=({message:e,onMermaidTabClick:t,onAiRepairClick:n,onDeleteMessage:r,onInsertMessage:i,onRetry:a,rateLimitRemaining:o,isLastMessage:s,renderWarning:c,allowFixingParseError:l})=>{let[u,d]=(0,B.useState)(!1);(0,B.useEffect)(()=>{if(!e.error||!s)return;if(e.error&&!e.lastAttemptAt){d(!0);return}let t=Date.now()-e.lastAttemptAt,n=Math.max(0,5e3-t);if(n===0){d(!0);return}d(!1);let r=setTimeout(()=>{d(!0)},n);return()=>clearTimeout(r)},[e.error,e.lastAttemptAt,s]);let f=e=>e.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`});if(e.type===`warning`){let t=c?.(e);return(0,V.jsx)(`div`,{className:`chat-message chat-message--system`,children:(0,V.jsxs)(`div`,{className:`chat-message__content`,children:[(0,V.jsxs)(`div`,{className:`chat-message__header`,children:[(0,V.jsx)(`span`,{className:`chat-message__role`,children:W(`chat.role.system`)}),(0,V.jsx)(`span`,{className:`chat-message__timestamp`,children:f(e.timestamp)})]}),(0,V.jsx)(`div`,{className:`chat-message__body`,children:(0,V.jsx)(`div`,{className:`chat-message__text`,children:t||(e.warningType===`messageLimitExceeded`?(0,V.jsxs)(V.Fragment,{children:[W(`chat.rateLimit.messageLimit`),(0,V.jsx)(`div`,{style:{marginTop:`10px`},children:(0,V.jsx)(kI,{onClick:()=>{window.open(`${ne.VITE_APP_PLUS_LP}/plus?utm_source=excalidraw&utm_medium=app&utm_content=ttdChatBanner#excalidraw-redirect`,`_blank`,`noopener`)},children:W(`chat.upsellBtnLabel`)})})]}):W(`chat.rateLimit.generalRateLimit`))})})]})})}return(0,V.jsxs)(`div`,{className:`chat-message chat-message--${e.type}`,children:[(0,V.jsxs)(`div`,{className:`chat-message__content`,children:[(0,V.jsxs)(`div`,{className:`chat-message__header`,children:[(0,V.jsx)(`span`,{className:`chat-message__role`,children:e.type===`user`?W(`chat.role.user`):W(`chat.role.assistant`)}),(0,V.jsx)(`span`,{className:`chat-message__timestamp`,children:f(e.timestamp)})]}),(0,V.jsx)(`div`,{className:`chat-message__body`,children:e.error?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{className:`chat-message__error`,children:e.content}),e.errorType!==`parse`&&(0,V.jsxs)(`div`,{className:`chat-message__error_message`,children:[`Error: `,e.error||W(`chat.errors.generationFailed`)]}),e.errorType===`parse`&&l&&(0,V.jsxs)(`div`,{className:`chat-message__error_message`,children:[(0,V.jsx)(`p`,{children:W(`chat.errors.invalidDiagram`)}),(0,V.jsxs)(`div`,{className:`chat-message__error-actions`,children:[t&&(0,V.jsx)(`button`,{className:`chat-message__error-link`,onClick:()=>t(e),type:`button`,children:W(`chat.errors.fixInMermaid`)}),n&&(0,V.jsx)(`button`,{className:`chat-message__error-link`,onClick:()=>n(e),disabled:o===0,type:`button`,children:W(`chat.errors.aiRepair`)})]})]})]}):(0,V.jsxs)(`div`,{className:`chat-message__text`,children:[e.content,e.isGenerating&&(0,V.jsx)(`span`,{className:`chat-message__cursor`,children:`▋`})]})})]}),e.type===`assistant`&&!e.isGenerating&&(0,V.jsxs)(`div`,{className:`chat-message__actions`,children:[!e.error&&i&&(0,V.jsx)(`button`,{className:`chat-message__action`,onClick:()=>i(e),type:`button`,"aria-label":W(`chat.insert`),title:W(`chat.insert`),children:_S}),t&&e.content&&(0,V.jsx)(`button`,{className:`chat-message__action`,onClick:()=>t(e),type:`button`,"aria-label":W(`chat.viewAsMermaid`),title:W(`chat.viewAsMermaid`),children:Xx}),r&&e.errorType!==`network`&&(0,V.jsx)(`button`,{className:`chat-message__action chat-message__action--danger`,onClick:()=>r(e.id),type:`button`,"aria-label":W(`chat.deleteMessage`),title:W(`chat.deleteMessage`),children:yb}),e.errorType===`network`&&a&&s&&(0,V.jsx)(`button`,{className:H(`chat-message__action`,{invisible:!u}),onClick:()=>a(e),type:`button`,"aria-label":W(`chat.retry`),title:W(`chat.retry`),children:gS})]})]})},IL=({chatId:e,messages:t,currentPrompt:n,onPromptChange:r,onGenerate:i,isGenerating:a,rateLimits:o,onAbort:s,onMermaidTabClick:c,onAiRepairClick:l,onDeleteMessage:u,onInsertMessage:d,onRetry:f,renderWelcomeScreen:p,renderWarning:m})=>{let h=(0,B.useRef)(null),g=(0,B.useRef)(null);(0,B.useLayoutEffect)(()=>{h.current?.scrollIntoView()},[t]),(0,B.useEffect)(()=>{g.current&&g.current.focus()},[e]);let _=e=>{let t=e.target.value;r(t)},v=()=>{if(a&&s){s();return}let e=n.trim();e&&(i({prompt:e}),r(``))},y=e=>{e.key===j.ENTER&&!e.shiftKey&&(e.preventDefault(),a||v())},b=n.trim().length>3&&!a&&(o?.rateLimitRemaining??1)>0,x=a&&!!s;return(0,V.jsxs)(`div`,{className:`chat-interface`,children:[(0,V.jsxs)(`div`,{className:`chat-interface__messages`,children:[t.length===0?(0,V.jsx)(`div`,{className:`chat-interface__welcome-screen`,children:p?p({rateLimits:o??null}):(0,V.jsx)(PL,{})}):t.map((e,n)=>(0,V.jsx)(FL,{message:e,onMermaidTabClick:c,onAiRepairClick:l,onDeleteMessage:u,onInsertMessage:d,onRetry:f,rateLimitRemaining:o?.rateLimitRemaining,isLastMessage:n===t.length-1,renderWarning:m,allowFixingParseError:e.errorType===`parse`&&n===t.length-1},e.id)),(0,V.jsx)(`div`,{ref:h,id:`messages-end`})]}),(0,V.jsx)(`div`,{className:`chat-interface__input-container`,children:(0,V.jsx)(`div`,{className:`chat-interface__input-outer`,children:(0,V.jsxs)(`div`,{className:`chat-interface__input-wrapper`,style:{borderColor:a?`var(--dialog-border-color)`:void 0},children:[(0,V.jsx)(`textarea`,{ref:g,autoFocus:!0,className:`chat-interface__input`,value:n,onChange:_,onKeyDown:y,placeholder:a?W(`chat.generating`):o?.rateLimitRemaining===0?W(`chat.rateLimit.messageLimitInputPlaceholder`):t.length>0?W(`chat.inputPlaceholderWithMessages`):W(`chat.inputPlaceholder`,{shortcut:`Shift + Enter`}),disabled:o?.rateLimitRemaining===0,rows:1,cols:30,onInput:e=>{let t=e.target;t.style.height=`auto`,t.style.height=`${Math.min(t.scrollHeight,120)}px`}}),(0,V.jsx)(`button`,{className:`chat-interface__send-button`,onClick:v,disabled:!b&&!x,type:`button`,children:(0,V.jsx)(Dw,{size:`1.5em`,icon:a?cx:vS})})]})})})]})},LL=Gc(null),RL=Gc(!1),zL=Gc(null),BL=Gc({id:Tc(),messages:[],currentPrompt:``}),VL=(e,t)=>{let{messages:n}=e,r=as(n,e=>e.type===`assistant`);if(r===-1)return e;let i=n[r],a=n.slice();return a[r]={...i,...t},{...e,messages:a}},HL=e=>{let{messages:t}=e;return t[as(t,e=>e.type===`assistant`)]},UL=(e,t)=>{let n=t.map(e=>({...e,id:Tc(),timestamp:new Date}));return{...e,messages:[...e.messages,...n]}},WL=e=>{let t=as(e.messages??[],e=>e.type===`assistant`);return t===-1?e:{...e,messages:e.messages.filter((e,n)=>n!==t)}},GL=e=>{let t=[];for(let n of e.messages)n.content&&(n.type===`user`||n.type===`assistant`)&&t.push({role:n.type,content:n.content});return t},KL=()=>{let[e,t]=wy(BL);return{addUserMessage:e=>{t(t=>UL(t,[{type:`user`,content:e}]))},addAssistantMessage:()=>{t(e=>UL(e,[{type:`assistant`,content:``,isGenerating:!0}]))},setAssistantError:(e,n=`other`,r)=>{let i=r?JSON.stringify({name:r instanceof Error?r.name:`Error`,message:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:void 0}):void 0;t(t=>VL(t,{isGenerating:!1,error:e,errorType:n,errorDetails:i}))},chatHistory:e,setChatHistory:t,setLastRetryAttempt:()=>{t(e=>VL(e,{lastAttemptAt:Date.now()}))}}},qL=e=>{let t=e.trim();return t.length<=50?t:`${t.substring(0,47)}...`},JL=Gc([]),YL=Gc(!1),XL=Gc(!1),ZL=({persistenceAdapter:e})=>{let[t]=wy(BL),[n,r]=wy(JL),[i,a]=wy(YL),[o,s]=wy(XL),c=(0,B.useRef)(n);c.current=n;let l=t?.messages[t?.messages.length-1],u=(0,B.useCallback)(async()=>{if(!(o||i)){a(!0);try{let t=await e.loadChats();r(t),s(!0)}catch(e){console.warn(`Failed to load chats:`,e),r([]),s(!0)}finally{a(!1)}}},[o,i,r,a,s,e]);(0,B.useEffect)(()=>{u()},[]);let d=(0,B.useCallback)(async()=>{if(t.messages.length===0)return;let n=t.messages.find(e=>e.type===`user`);if(!n||typeof n.content!=`string`)return;let i=qL(n.content),a=c.current,o=a.find(e=>e.id===t.id),s=!o||o.messages.length!==t.messages.length||o.messages.some((e,n)=>e.id!==t.messages[n]?.id||e.content!==t.messages[n]?.content),l={id:t.id,title:i,messages:t.messages.filter(e=>e.type===`user`||e.type===`assistant`).map(e=>({...e,timestamp:e.timestamp instanceof Date?e.timestamp:new Date(e.timestamp)})),currentPrompt:t.currentPrompt,timestamp:s?Date.now():o?.timestamp??Date.now()},u=[...a.filter(e=>e.id!==t.id),l].sort((e,t)=>t.timestamp-e.timestamp).slice(0,10);r(u);try{await e.saveChats(u)}catch(e){console.warn(`Failed to save chats:`,e)}},[t,r,e]);return(0,B.useEffect)(()=>{l?.isGenerating||d()},[t.messages?.length,l?.id,l?.isGenerating]),{savedChats:n,saveCurrentChat:d,deleteChat:(0,B.useCallback)(async t=>{let n=c.current.filter(e=>e.id!==t);r(n);try{await e.saveChats(n)}catch(e){console.warn(`Failed to save after delete:`,e)}return n},[r,e]),restoreChat:(0,B.useCallback)(e=>e,[]),createNewChatId:(0,B.useCallback)(async()=>(await d(),Tc()),[d])}},QL=e=>{let t=e.trim();if(!t)return!1;let n=(t.match(/\[/g)||[]).length,r=(t.match(/\]/g)||[]).length,i=(t.match(/\{/g)||[]).length,a=(t.match(/\}/g)||[]).length,o=(t.match(/\(/g)||[]).length,s=(t.match(/\)/g)||[]).length;if(n!==r||i!==a||o!==s)return!1;let c=t.split(`
|
|
74
|
-
`).pop()?.trim()||``;return![/-->$/,/--$/,/-\.$/,/==>$/,/==$/,/~~$/,/::$/,/:$/,/\|$/,/&$/].some(e=>e.test(c))},$L=300,eR=3e3,tR=100,nR=100,rR=({mermaidToExcalidrawLib:e,canvasRef:t})=>{let[n]=wy(BL),[,r]=wy(zL),[i,a]=wy(RL),o=(0,B.useRef)(!1),s=(0,B.useMemo)(()=>HL(n),[n]),c=(0,B.useRef)(s);(0,B.useEffect)(()=>{c.current=s},[s]);let l=(0,B.useRef)({elements:[],files:null}),u=(0,B.useRef)(0),d=(0,B.useRef)(null),f=(0,B.useRef)(!1),p=(0,B.useRef)($L),{theme:m}=EC(),h=(0,B.useCallback)(async n=>{if(!n.trim()||!e.loaded||o.current)return!1;o.current=!0;let i=performance.now(),a=await wL({canvasRef:t,data:l,mermaidToExcalidrawLib:e,setError:r,mermaidDefinition:n,theme:m});return performance.now()-i<tR?p.current=$L:p.current=eR,o.current=!1,a.success},[t,e,r,m]),g=(0,B.useMemo)(()=>{let e=async e=>{let t=Date.now(),n=t-u.current,r=p.current;if(!QL(e)){f.current||=(u.current=Math.max(u.current,t-r+nR),!0),d.current=e;return}if(f.current=!1,n<r){d.current=e;return}d.current=null;let i=await h(e);u.current=Date.now(),i||(u.current=u.current-r+nR,f.current=!0)};return e.flush=async()=>{if(d.current){let e=d.current;d.current=null,await h(e),u.current=Date.now()}},e.cancel=()=>{d.current=null},e},[h]),_=(0,B.useCallback)(()=>{u.current=0,d.current=null,f.current=!1,p.current=$L},[]);return(0,B.useEffect)(()=>{s?.content&&s?.isGenerating?g(s.content):s?.isGenerating||(g.flush(),_(),s?.content&&g(s.content))},[_,g,s?.isGenerating,s?.content]),(0,B.useEffect)(()=>{let e=c.current;!e?.content||e.error||i&&h(e.content)},[n?.id,h,i]),(0,B.useEffect)(()=>{if(n.messages?.filter(e=>e.type===`assistant`).length)i||a(!0);else{let e=t.current;if(e){let t=e.parentElement;t&&(t.style.background=``,e.replaceChildren())}a(!1)}},[n.messages,a,t,i]),{data:l}},iR=3,aR=1e4,oR=({onTextSubmit:e})=>{let[,t]=wy(zL),[n,r]=wy(LL),[i,a]=wy(BL),{addUserMessage:o,addAssistantMessage:s,setAssistantError:c}=KL(),l=(0,B.useRef)(null),u=e=>e.length>aR||e.length<iR||n?.rateLimitRemaining===0?(e.length<iR&&t(Error(W(`chat.errors.promptTooShort`,{min:iR}))),e.length>aR&&t(Error(W(`chat.errors.promptTooLong`,{max:aR}))),!1):!0;return{onGenerate:async({prompt:n,isRepairFlow:d=!1})=>{if(!u(n))return;l.current&&l.current.abort(),t(null);let f=new AbortController;l.current=f,d?a(e=>VL(e,{isGenerating:!0,content:``,error:void 0,errorType:void 0,errorDetails:void 0})):(o(n),s());try{xC(`ai`,`generate`,`ttd`);let{generatedResponse:o,error:s,rateLimit:l,rateLimitRemaining:u}=await e({messages:[...GL(i).slice(-3),{role:`user`,content:n}],onStreamCreated:()=>{d&&a(e=>VL(e,{content:``,error:``,isGenerating:!0}))},onChunk:e=>{a(t=>VL(t,{content:HL(t).content+e}))},signal:f.signal});if(a(e=>VL(e,{isGenerating:!1})),So(l)&&So(u)&&r({rateLimit:l,rateLimitRemaining:u}),(s?.status===429||u===0)&&a(e=>(s?.status===429&&(e=WL(e)),e={...e,messages:e.messages.filter(e=>e.type!==`warning`||e.warningType===`rateLimitExceeded`||e.warningType===`messageLimitExceeded`)},UL(e,[{type:`warning`,warningType:u===0?`messageLimitExceeded`:`rateLimitExceeded`}]))),s){if(s.name===`AbortError`||s.message===`Aborted`||f.signal.aborted)return;let e=Error(s.message||W(`chat.errors.requestFailed`));s.status!==429&&c(e.message,`network`),t(e);return}try{await Lc(o??``),xC(`ai`,`mermaid parse success`,`ttd`)}catch(e){xC(`ai`,`mermaid parse failed`,`ttd`);let n=Error(e.message||W(`chat.errors.mermaidParseError`));c(n.message,`parse`),t(n)}}catch(e){let n=Error(e.message||W(`chat.errors.generationFailed`));c(n.message,`other`),t(n)}finally{l.current=null}},handleAbort:()=>{l.current&&l.current.abort()}}},sR=({persistenceAdapter:e})=>{let t=Ty(zL),[n,r]=wy(BL),[i,a]=(0,B.useState)(!1),{restoreChat:o,deleteChat:s,createNewChatId:c}=ZL({persistenceAdapter:e}),l=(0,B.useCallback)(e=>{let n=e.messages.map(e=>({...e,timestamp:e.timestamp instanceof Date?e.timestamp:new Date(e.timestamp)})),i={id:e.id,messages:n,currentPrompt:``},a=HL(i);t(a?.error?Error(a?.error):null),r(i)},[t,r]),u=(0,B.useCallback)(async()=>{let e=await c();r({id:e,messages:[],currentPrompt:``}),t(null)},[c,r,t]);return{isMenuOpen:i,onRestoreChat:(0,B.useCallback)(e=>{let t=o(e);l(t),a(!1)},[o,l]),handleDeleteChat:(0,B.useCallback)(async(e,t)=>{t.stopPropagation();let r=e===n.id,i=await s(e);if(r){if(i.length>0){let e=i[0];l(e)}else await u()}},[n.id,s,l,u]),handleNewChat:(0,B.useCallback)(async()=>{await u(),a(!1)},[u]),handleMenuToggle:(0,B.useCallback)(()=>{a(e=>!e)},[]),handleMenuClose:(0,B.useCallback)(()=>{a(!1)},[])}},cR=({isOpen:e,onToggle:t,onClose:n,onNewChat:r,onRestoreChat:i,onDeleteChat:a,isNewChatBtnVisible:o,savedChats:s,activeSessionId:c,disabled:l})=>(0,V.jsxs)(`div`,{className:`ttd-chat-history-menu`,children:[o&&(0,V.jsx)(kI,{onClick:r,disabled:l,children:W(`chat.newChat`)}),s.length>0&&(0,V.jsx)(`div`,{className:`ttd-dialog-panel__menu-wrapper`,children:(0,V.jsxs)(Z,{open:e,children:[(0,V.jsx)(Z.Trigger,{onToggle:t,className:`ttd-dialog-menu-trigger`,disabled:l,title:W(`chat.menu`),"aria-label":W(`chat.menu`),children:kS}),(0,V.jsx)(Z.Content,{onClickOutside:n,onSelect:n,children:(0,V.jsx)(V.Fragment,{children:s.map(e=>(0,V.jsxs)(Z.ItemCustom,{className:H(`ttd-chat-menu-item`,{"ttd-chat-menu-item--active":e.id===c}),onClick:()=>{i(e)},children:[(0,V.jsx)(`span`,{className:`ttd-chat-menu-item__title`,children:e.title}),(0,V.jsx)(`button`,{className:`ttd-chat-menu-item__delete`,onClick:t=>a(e.id,t),title:W(`chat.deleteChat`),"aria-label":W(`chat.deleteChat`),type:`button`,children:yb})]},e.id))})})]})})]}),lR=({chatId:e,messages:t,currentPrompt:n,onPromptChange:r,onGenerate:i,isGenerating:a,generatedResponse:o,isMenuOpen:s,onMenuToggle:c,onMenuClose:l,onNewChat:u,onRestoreChat:d,onDeleteChat:f,savedChats:p,activeSessionId:m,onAbort:h,onMermaidTabClick:g,onAiRepairClick:_,onDeleteMessage:v,onInsertMessage:y,onRetry:b,onViewAsMermaid:x,renderWelcomeScreen:S,renderWarning:C})=>{let[w]=wy(LL),T=(()=>{let e=[];return w&&e.push({label:W(`chat.rateLimitRemaining`,{count:w.rateLimitRemaining}),variant:`rateLimit`,className:w.rateLimitRemaining<5?`ttd-dialog-panel__rate-limit--danger`:``}),o&&e.push({action:x,label:W(`chat.viewAsMermaid`),icon:(0,V.jsx)(Dw,{icon:vS}),variant:`link`}),e})();return(0,V.jsx)(uL,{label:(0,V.jsxs)(`div`,{className:`ttd-dialog-panel__label-wrapper`,children:[(0,V.jsx)(`div`,{className:`ttd-dialog-panel__label-group`}),(0,V.jsx)(`div`,{className:`ttd-dialog-panel__header-right`,children:(0,V.jsx)(cR,{isNewChatBtnVisible:!!t.length,isOpen:s,onToggle:c,onClose:l,onNewChat:u,onRestoreChat:d,onDeleteChat:f,savedChats:p,activeSessionId:m,disabled:a})})]}),className:`ttd-dialog-chat-panel`,panelActionJustifyContent:T.length===2?`space-between`:T.length===1&&T[0].variant===`rateLimit`?`flex-start`:`flex-end`,panelActions:T,children:(0,V.jsx)(IL,{chatId:e,messages:t,currentPrompt:n,onPromptChange:r,onGenerate:i,isGenerating:a,generatedResponse:o,onAbort:h,onMermaidTabClick:g,onAiRepairClick:_,onDeleteMessage:v,onInsertMessage:y,onRetry:b,rateLimits:w,renderWelcomeScreen:S,renderWarning:C})})},uR=({canvasRef:e,error:t,loaded:n,onInsert:r,hideErrorDetails:i})=>{let a=[{action:r,label:W(`chat.insert`),icon:vS,variant:`button`}];return(0,V.jsx)(uL,{panelActionJustifyContent:`flex-end`,panelActions:a,className:`ttd-dialog-preview-panel`,children:(0,V.jsx)(lL,{canvasRef:e,error:t,loaded:n,hideErrorDetails:i})})},dR=({mermaidToExcalidrawLib:e,onTextSubmit:t,renderWelcomeScreen:n,renderWarning:r,persistenceAdapter:i})=>{let a=iV(),o=dV(),s=(0,B.useRef)(null),[c,l]=wy(zL),[u,d]=wy(BL),f=Ey(RL),{savedChats:p}=ZL({persistenceAdapter:i}),m=HL(u),{setLastRetryAttempt:h}=KL(),{data:g}=rR({canvasRef:s,mermaidToExcalidrawLib:e}),{onGenerate:_,handleAbort:v}=oR({onTextSubmit:t}),{isMenuOpen:y,onRestoreChat:b,handleDeleteChat:x,handleNewChat:S,handleMenuToggle:C,handleMenuClose:w}=sR({persistenceAdapter:i});return(0,V.jsxs)(`div`,{className:`ttd-dialog-layout ${f?`ttd-dialog-layout--split`:`ttd-dialog-layout--chat-only`}`,children:[(0,V.jsx)(lR,{chatId:u.id,messages:u.messages,currentPrompt:u.currentPrompt,onPromptChange:e=>{d(t=>({...t,currentPrompt:e}))},onGenerate:_,isGenerating:m?.isGenerating??!1,generatedResponse:m?.content,isMenuOpen:y,onMenuToggle:C,onMenuClose:w,onNewChat:S,onRestoreChat:b,onDeleteChat:x,savedChats:p,activeSessionId:u.id,onAbort:v,onMermaidTabClick:e=>{let t=e.content||``;t&&(TL(t),o({openDialog:{name:`ttd`,tab:`mermaid`}}))},onAiRepairClick:async e=>{let t=e.content||``,n=e.error||``;if(!t)return;let r=`Fix the error in this Mermaid diagram. The diagram is:
|
|
75
|
-
|
|
76
|
-
\`\`\`mermaid
|
|
77
|
-
${t}
|
|
78
|
-
\`\`\`
|
|
79
|
-
|
|
80
|
-
The exception/error is: ${n}
|
|
81
|
-
|
|
82
|
-
Please fix the Mermaid syntax and regenerate a valid diagram.`;await _({prompt:r,isRepairFlow:!0})},onDeleteMessage:e=>{let t=u.messages.findIndex(t=>t.id===e&&t.type===`assistant`),n=u.messages.slice(0,t-1);d({...u,messages:n})},onInsertMessage:async t=>{let n=t.content||``;if(!n.trim()||!e.loaded)return;let r={current:{elements:[],files:null}};(await wL({canvasRef:s,data:r,mermaidToExcalidrawLib:e,setError:l,mermaidDefinition:n,theme:a.state.theme})).success&&EL({app:a,data:r,text:n,shouldSaveMermaidDataToStorage:!0})},onRetry:async e=>{let t=u.messages.findIndex(t=>t.id===e.id);if(t>0){let e=u.messages[t-1];e.type===`user`&&typeof e.content==`string`&&(h(),await _({prompt:e.content,isRepairFlow:!0}))}},onViewAsMermaid:()=>{typeof m?.content==`string`&&(TL(m.content),o({openDialog:{name:`ttd`,tab:`mermaid`}}))},renderWarning:r,renderWelcomeScreen:n}),f&&(0,V.jsx)(uR,{canvasRef:s,hideErrorDetails:m?.errorType===`parse`,error:c,loaded:e.loaded,onInsert:()=>{EL({app:a,data:g})}})]})},fR=({mermaidToExcalidrawLib:e,onTextSubmit:t,renderWelcomeScreen:n,renderWarning:r,persistenceAdapter:i})=>(0,V.jsx)(dR,{mermaidToExcalidrawLib:e,onTextSubmit:t,renderWelcomeScreen:n,renderWarning:r,persistenceAdapter:i}),pR=e=>{let t=dV(),n=(0,B.useRef)(null),r=(0,B.useRef)(0);return(0,V.jsx)(kv,{ref:n,className:`ttd-dialog-tabs-root`,value:e.tab,onValueChange:i=>{if(!i)return;let a=n.current?.closest(`.Modal__content`);if(a){let e=a.offsetHeight||0;e>r.current&&(r.current=e,a.style.minHeight=`min(${r.current}px, 100%)`)}e.dialog===`ttd`&&Hr([`text-to-diagram`,`mermaid`],i)&&t({openDialog:{name:e.dialog,tab:i}})},children:e.children})};pR.displayName=`TTDDialogTabs`;var mR=pR,hR=({children:e,...t})=>(0,V.jsx)(Av,{className:`ttd-dialog-triggers`,...t,children:e});hR.displayName=`TTDDialogTabTriggers`;var gR=({children:e,tab:t,onSelect:n,...r})=>(0,V.jsx)(jv,{value:t,asChild:!0,onSelect:n,children:(0,V.jsx)(`button`,{type:`button`,className:`ttd-dialog-tab-trigger`,...r,children:e})});gR.displayName=`TTDDialogTabTrigger`;var _R=({tab:e,children:t,...n})=>(0,V.jsx)(Mv,{...n,value:e,children:t});_R.displayName=`TTDDialogTab`;var vR=e=>{let t=EC();return t.openDialog?.name===`ttd`?(0,V.jsx)(yR,{...e,tab:t.openDialog.tab}):null};vR.WelcomeMessage=PL;var yR=$F(`TTDDialogBase`,({tab:e,...t})=>{let r=iV(),[i,a]=(0,B.useState)({loaded:!1,api:n(()=>import(`./excalidraw-mermaid-stub-DE5FTiZB.js`),__vite__mapDeps([69,70]),import.meta.url)});return(0,B.useEffect)(()=>{(async()=>{await i.api,a(e=>({...e,loaded:!0}))})()},[i.api]),(0,V.jsx)(Zk,{className:`ttd-dialog`,onCloseRequest:()=>{r.setOpenDialog(null)},size:1520,title:!1,...t,autofocus:!1,children:(0,V.jsxs)(mR,{dialog:`ttd`,tab:e,children:[`__fallback`in t&&t.__fallback?(0,V.jsx)(`p`,{className:`dialog-mermaid-title`,children:W(`mermaid.title`)}):(0,V.jsxs)(hR,{children:[(0,V.jsx)(gR,{tab:`text-to-diagram`,children:(0,V.jsxs)(`div`,{className:`ttd-dialog-tab-trigger__content`,children:[W(`labels.textToDiagram`),(0,V.jsx)(`div`,{className:`ttd-dialog-tab-trigger__badge`,children:W(`chat.aiBeta`)})]})}),(0,V.jsx)(gR,{tab:`mermaid`,children:W(`mermaid.label`)})]}),!(`__fallback`in t)&&(0,V.jsx)(_R,{className:`ttd-dialog-content`,tab:`text-to-diagram`,children:(0,V.jsx)(fR,{mermaidToExcalidrawLib:i,onTextSubmit:t.onTextSubmit,renderWelcomeScreen:t.renderWelcomeScreen,renderWarning:t.renderWarning,persistenceAdapter:t.persistenceAdapter})}),(0,V.jsx)(_R,{className:`ttd-dialog-content`,tab:`mermaid`,children:(0,V.jsx)(NL,{mermaidToExcalidrawLib:i,isActive:e===`mermaid`})})]})})}),bR=.01,xR=10,SR=(e,t)=>!(t===`angle`&&P(e)),CR=(e,t)=>{let n=e+t/2;return n-n%t},wR=(e,t,n)=>Object.keys(e).map(e=>({original:(n??t).get(e),latest:t.get(e)})).filter(e=>e.original!==void 0&&e.latest!==void 0),TR=(e,t,n,r,i,a,o=!0)=>{if(ft(n)&&(n.startBinding||n.endBinding)){if(Math.abs(e-n.x)<10&&Math.abs(t-n.y)<10)return;qt(n,`start`,r),qt(n,`end`,r)}let s=r.getNonDeletedElementsMap(),c=s.get(n.id);if(!c)return;let[l,u]=[n.x+n.width/2,n.y+n.height/2],[d,f]=Fs(L(n.x,n.y),L(l,u),n.angle),p=e-d,m=t-f,[h,g]=Fs(L(e,t),L(l+p,u+m),-n.angle);r.mutateElement(c,{x:h,y:g},{informMutation:o,isDragging:!1}),Dt(c,r,i);let _=Ti(n,a);if(_){let e=s.get(_.id);e&&r.mutateElement(e,{x:_.x+p,y:_.y+m},{informMutation:o,isDragging:!1})}if(P(n)){let e=Yn(a,n.id);e.forEach(t=>{let n=s.get(t.id);if(!n)return;let[a,c]=[t.x+t.width/2,t.y+t.height/2],[l,u]=Fs(L(t.x,t.y),L(a,c),t.angle),d=Math.round(l+p),f=Math.round(u+m),[h,g]=Fs(L(d,f),L(a+p,c+m),-t.angle);r.mutateElement(n,{x:h,y:g},{informMutation:o,isDragging:!1}),Dt(n,r,i,{simultaneouslyUpdated:et(e)})})}},ER=(e,t)=>{let n=Vi(t).map(t=>yt(e,t).reduce((e,t)=>(e[t.id]=!0,e),{}));return e.filter(e=>!wa(e)).forEach(e=>{n.push({[e.id]:!0})}),n},DR=({label:e,icon:t,dragInputCallback:n,value:r,elements:i,editable:a=!0,shouldKeepAspectRatio:o,property:s,scene:c,appState:l,sensitivity:u=1,dragFinishedCallback:d})=>{let f=iV(),p=dV(),m=(0,B.useRef)(null),h=(0,B.useRef)(null),[g,_]=(0,B.useState)(r.toString()),v=(0,B.useRef)(null);v.current||={originalAppState:ta(l),originalElements:i,lastUpdatedValue:g,updatePending:!1},(0,B.useEffect)(()=>{let e=r.toString();_(e),v.current.lastUpdatedValue=e},[r]);let y=(e,t,i)=>{if(!v.current.updatePending)return!1;v.current.updatePending=!1;let a=Number(e);if(isNaN(a)){_(r.toString());return}let l=Number(a.toFixed(2)),u=Number(r);(isNaN(u)||Math.abs(l-u)>=bR)&&(v.current.lastUpdatedValue=e,n({accumulatedChange:0,instantChange:0,originalElements:t,originalElementsMap:f.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:o,shouldChangeByStepSize:!1,scene:c,nextValue:l,property:s,originalAppState:i,setInputValue:e=>_(String(e)),app:f,setAppState:p}),f.syncActionResult({captureUpdate:F.IMMEDIATELY}))},b=(0,B.useRef)({});return b.current.handleInputValue=y,(0,B.useEffect)(()=>{let e=m.current,t=b.current;return()=>{let n=e?.value;n&&t.handleInputValue?.(n,v.current.originalElements,v.current.originalAppState),window.removeEventListener(T.POINTER_MOVE,t.onPointerMove,!1),window.removeEventListener(T.POINTER_UP,t.onPointerUp,!1)}},[a]),a?(0,V.jsxs)(`div`,{className:H(`drag-input-container`,!a&&`disabled`),"data-testid":e,children:[(0,V.jsx)(`div`,{className:`drag-input-label`,ref:h,onPointerDown:e=>{if(m.current&&a){document.body.classList.add(`excalidraw-cursor-resize`);let e=Number(m.current.value);isNaN(e)&&(e=0);let t=null,r=f.scene.getNonDeletedElements().reduce((e,t)=>(e.set(t.id,ca(t)),e),new Map),a=i.map(e=>r.get(e.id)),h=ta(l),g=0,v=0,y=e=>{if(t&&r!==null&&a!==null){let i=e.clientX-t.x;i!==0&&(v+=i,Math.abs(v)>=u&&(v=Math.sign(v)*Math.floor(Math.abs(v)/u),g+=v,n({accumulatedChange:g,instantChange:v,originalElements:a,originalElementsMap:r,shouldKeepAspectRatio:o,shouldChangeByStepSize:e.shiftKey,property:s,scene:c,originalAppState:h,setInputValue:e=>_(String(e)),app:f,setAppState:p}),v=0))}t={x:e.clientX,y:e.clientY}},x=()=>{window.removeEventListener(T.POINTER_MOVE,y,!1),f.syncActionResult({captureUpdate:F.IMMEDIATELY}),d?.({app:f,setAppState:p,originalElements:a,originalAppState:h}),t=null,g=0,v=0,a=null,r=null,document.body.classList.remove(`excalidraw-cursor-resize`),window.removeEventListener(T.POINTER_UP,x,!1)};b.current.onPointerMove=y,b.current.onPointerUp=x,window.addEventListener(T.POINTER_MOVE,y,!1),window.addEventListener(T.POINTER_UP,x,!1)}},onPointerEnter:()=>{h.current&&(h.current.style.cursor=`ew-resize`)},children:t?(0,V.jsx)(Dw,{icon:t}):e}),(0,V.jsx)(`input`,{className:`drag-input`,autoComplete:`off`,spellCheck:`false`,onKeyDown:e=>{if(a){let t=e.target;t instanceof HTMLInputElement&&e.key===j.ENTER&&(y(t.value,i,l),f.focusContainer())}},ref:m,value:g,onChange:e=>{v.current.updatePending=!0,_(e.target.value)},onFocus:e=>{e.target.select(),v.current.originalElements=i,v.current.originalAppState=ta(l)},onBlur:e=>{g?a&&y(e.target.value,v.current.originalElements,v.current.originalAppState):_(r.toString())},disabled:!a})]}):null},OR=15,kR=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:n,nextValue:r,scene:i,app:a})=>{let o=i.getNonDeletedElementsMap(),s=t[0];if(s&&!ve(s)){let t=o.get(s.id);if(!t)return;if(r!==void 0){let e=la(r);i.mutateElement(t,{angle:e}),Dt(t,i,a.state);let n=Ti(t,o);n&&!_(t)&&i.mutateElement(n,{angle:e});return}let c=(Math.round(gi(s.angle)*100)/100+Math.round(e))%360;n&&(c=CR(c,OR)),c=c<0?c+360:c;let l=la(c);i.mutateElement(t,{angle:l}),Dt(t,i,a.state);let u=Ti(t,o);u&&!_(t)&&i.mutateElement(u,{angle:l})}},AR=({element:e,scene:t,appState:n,property:r})=>(0,V.jsx)(DR,{label:`A`,icon:iS,value:Math.round(gi(e.angle)%360*100)/100,elements:[e],dragInputCallback:kR,editable:SR(e,`angle`),scene:t,appState:n,property:r}),jR=5,MR=({property:e,scene:t,appState:n,setAppState:r})=>(0,V.jsx)(DR,{label:`Grid step`,sensitivity:8,elements:[],dragInputCallback:({nextValue:e,instantChange:t,shouldChangeByStepSize:n,setInputValue:i})=>{r(r=>{let a;return e?a=e:t&&(a=n?CR(r.gridStep+jR*Math.sign(t),jR):r.gridStep+t),a?(a=ha(a),i(a),{gridStep:a}):(i(r.gridStep),null)})},scene:t,value:n.gridStep,property:e,appState:n}),NR=10,PR=e=>e.type===`image`,FR=({accumulatedChange:e,originalElements:t,originalElementsMap:n,shouldKeepAspectRatio:r,shouldChangeByStepSize:i,nextValue:a,property:s,originalAppState:c,instantChange:l,scene:u,app:d,setAppState:f})=>{let p=u.getNonDeletedElementsMap(),m=t[0],h=p.get(m.id);if(m&&h){let t=r||PR(m),d=m.width/m.height;if(c.croppingElementId===m.id){let e=p.get(m.id);if(!e||!De(e)||!e.crop)return;let t=e.crop,n={...t},r=e.scale[0]===-1,i=e.scale[1]===-1,{width:o,height:c}=Vo(e),d=t.naturalWidth/o,f=t.naturalHeight/c,h=r?t.width+t.x:t.naturalWidth-t.x,g=i?t.height+t.y:t.naturalHeight-t.y,_=10*d,v=10*f;if(a!==void 0){if(s===`width`){let e=a*d,i=ss(e,_,h);n={...n,width:i,x:r?t.x+t.width-i:t.x}}else if(s===`height`){let e=a*f,r=ss(e,v,g);n={...n,height:r,y:i?t.y+t.height-r:t.y}}u.mutateElement(e,{crop:n,width:n.width/(t.naturalWidth/o),height:n.height/(t.naturalHeight/c)});return}let y=s===`width`?l:0,b=s===`height`?l:0,x=ss(t.width+y,_,h),S=ss(t.height+b,_,g);n={...t,x:r?t.x+t.width-x:t.x,y:i?t.y+t.height-S:t.y,width:x,height:S},u.mutateElement(e,{crop:n,width:n.width/(t.naturalWidth/o),height:n.height/(t.naturalHeight/c)});return}if(a!==void 0){let e=Math.max(s===`width`?a:t?a*d:m.width,1),r=Math.max(s===`height`?a:t?a/d:m.height,1);if(o(e,r,h,m,n,u,s===`width`?`e`:`s`,{shouldMaintainAspectRatio:t}),P(h)){let e=Os(u.getElementsIncludingDeleted(),h,c,u.getNonDeletedElementsMap()),t=xi(u.getElementsIncludingDeleted(),e,h);u.replaceAllElements(t)}return}{let r=s===`width`?e:0,a=s===`height`?e:0,l=Math.max(0,m.width+r);s===`width`&&(l=i?CR(l,NR):Math.round(l));let p=Math.max(0,m.height+a);s===`height`&&(p=i?CR(p,NR):Math.round(p)),t&&(s===`width`?p=Math.round(l/d*100)/100:l=Math.round(p*d*100)/100),p=Math.max(1,p),l=Math.max(1,l),o(l,p,h,m,n,u,s===`width`?`e`:`s`,{shouldMaintainAspectRatio:t}),P(h)&&f({elementsToHighlight:et(Os(u.getElementsIncludingDeleted(),h,c,u.getNonDeletedElementsMap()))})}}},IR=({setAppState:e,app:t,originalElements:n,originalAppState:r})=>{let i=t.scene.getNonDeletedElementsMap(),a=n?.[0],o=a&&i.get(a.id);if(o&&P(o)){let n=Os(t.scene.getElementsIncludingDeleted(),o,r,t.scene.getNonDeletedElementsMap()),i=xi(t.scene.getElementsIncludingDeleted(),n,o);t.scene.replaceAllElements(i),e({elementsToHighlight:null})}},LR=({property:e,element:t,scene:n,appState:r})=>{let i=Ei(e===`width`?t.width:t.height,2);if(r.croppingElementId&&r.croppingElementId===t.id&&De(t)&&t.crop){let{width:n,height:r}=Vo(t);if(e===`width`){let e=n/t.crop.naturalWidth;i=Ei(t.crop.width*e,2)}if(e===`height`){let e=r/t.crop.naturalHeight;i=Ei(t.crop.height*e,2)}}return(0,V.jsx)(DR,{label:e===`width`?`W`:`H`,elements:[t],dragInputCallback:FR,value:i,editable:SR(t,e),scene:n,appState:r,property:e,dragFinishedCallback:IR})},RR=4,zR=4,BR=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:n,nextValue:r,scene:i})=>{let o=i.getNonDeletedElementsMap(),s=t[0];if(s){let t=o.get(s.id);if(!t||!a(t))return;let c;if(r!==void 0)c=Math.max(Math.round(r),RR);else if(s.type===`text`){let t=Math.round(s.fontSize);c=Math.max(t+Math.round(e),RR),n&&(c=CR(c,zR))}c&&(i.mutateElement(t,{fontSize:c}),Sa(t,i.getContainerElement(t),i))}},VR=({element:e,scene:t,appState:n,property:r})=>{let i=a(e)?e:Dr(e)?Ti(e,t.getNonDeletedElementsMap()):null;return i?(0,V.jsx)(DR,{label:`F`,value:Math.round(i.fontSize*10)/10,elements:[i],dragInputCallback:BR,icon:qx,appState:n,scene:t,property:r}):null},HR=15,UR=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:n,nextValue:r,property:i,scene:a})=>{let o=a.getNonDeletedElementsMap(),s=t.map(e=>o.get(e.id)).filter(e=>e&&!wa(e)&&SR(e,i)),c=t.filter(e=>!wa(e)&&SR(e,i));if(r!==void 0){let e=la(r);for(let t of s){if(!t)continue;a.mutateElement(t,{angle:e});let n=Ti(t,o);n&&!_(t)&&a.mutateElement(n,{angle:e})}a.triggerUpdate();return}for(let t=0;t<s.length;t++){let r=s[t];if(!r)continue;let i=c[t],l=(Math.round(gi(i.angle)*100)/100+Math.round(e))%360;n&&(l=CR(l,HR)),l=l<0?l+360:l;let u=la(l);a.mutateElement(r,{angle:u});let d=Ti(r,o);d&&!_(r)&&a.mutateElement(d,{angle:u})}a.triggerUpdate()},WR=({elements:e,scene:t,appState:n,property:r})=>{let i=e.filter(e=>!wa(e)&&SR(e,`angle`)),a=i.map(e=>Math.round(gi(e.angle)%360*100)/100),o=new Set(a).size===1?a[0]:`Mixed`,s=i.some(e=>SR(e,`angle`));return(0,V.jsx)(DR,{label:`A`,icon:iS,value:o,elements:e,dragInputCallback:UR,editable:s,appState:n,scene:t,property:r})},GR=10,KR=(e,t,n,r)=>{let i=r.x-e,o=r.y-t,s=r.width*n,c=r.height*n;return{width:s,height:c,x:e+i*n,y:t+o*n,...wo(r,s,c,!1),...a(r)?{fontSize:r.fontSize*n}:{}}},qR=(e,t,n,r,i,o,s,c)=>{let l=c.getNonDeletedElementsMap(),u=KR(e,t,r,o);c.mutateElement(i,u);let d=Ti(o,s);if(d){let e=d.fontSize*r;La(i,c);let t=l.get(d.id);t&&a(t)&&(c.mutateElement(t,{fontSize:e}),Qa(i,c,n===`width`?`e`:`s`,!0))}},JR=(e,t,n,r,i,a,o,s,c,l)=>{a===`width`?t=Math.round(e/r*100)/100:e=Math.round(t*r*100)/100;let u=t/n;for(let e=0;e<s.length;e++){let t=s[e],n=o[e];qR(i[0],i[1],a,u,n,t,c,l)}},YR=({accumulatedChange:e,originalElements:t,originalElementsMap:n,originalAppState:r,shouldChangeByStepSize:i,nextValue:a,scene:s,property:c,setAppState:l,app:u})=>{let d=s.getNonDeletedElementsMap(),f=ER(t,r);if(a!==void 0){for(let e of f){let t=wR(e,d,n);if(t.length>1){let e=t.map(e=>e.latest),r=t.map(e=>e.original),[i,o,l,u]=Is(r),d=l-i,f=u-o,p=d/f;JR(Math.max(1,c===`width`?Math.max(0,a):d),Math.max(1,c===`height`?Math.max(0,a):f),f,p,L(i,o),c,e,r,n,s)}else{let[e]=t,l=e?.latest,u=e?.original;if(l&&u&&SR(l,c)){let e=c===`width`?Math.max(0,a):l.width;c===`width`&&(e=i?CR(e,GR):Math.round(e));let t=c===`height`?Math.max(0,a):l.height;if(c===`height`&&(t=i?CR(t,GR):Math.round(t)),e=Math.max(1,e),t=Math.max(1,t),o(e,t,l,u,n,s,c===`width`?`e`:`s`,{shouldInformMutation:!1}),P(l)){let e=Os(s.getElementsIncludingDeleted(),l,r,s.getNonDeletedElementsMap()),t=xi(s.getElementsIncludingDeleted(),e,l);s.replaceAllElements(t)}}}}s.triggerUpdate();return}let p=c===`width`?e:0,m=c===`height`?e:0,h=[];for(let e of f){let t=wR(e,d,n);if(t.length>1){let e=t.map(e=>e.latest),r=t.map(e=>e.original),[a,o,l,u]=Is(r),d=l-a,f=u-o,h=d/f,g=Math.max(0,d+p);c===`width`&&(g=i?CR(g,GR):Math.round(g));let _=Math.max(0,f+m);c===`height`&&(_=i?CR(_,GR):Math.round(_)),g=Math.max(1,g),_=Math.max(1,_),JR(g,_,f,h,L(a,o),c,e,r,n,s)}else{let[e]=t,a=e?.latest,l=e?.original;if(a&&l&&SR(a,c)){let e=Math.max(0,l.width+p);c===`width`&&(e=i?CR(e,GR):Math.round(e));let t=Math.max(0,l.height+m);if(c===`height`&&(t=i?CR(t,GR):Math.round(t)),e=Math.max(1,e),t=Math.max(1,t),o(e,t,a,l,n,s,c===`width`?`e`:`s`,{shouldInformMutation:!1}),P(a)){let e=et(Os(s.getElementsIncludingDeleted(),a,r,s.getNonDeletedElementsMap()));h.push(...e)}}}}l({elementsToHighlight:h}),s.triggerUpdate()},XR=({setAppState:e,app:t,originalElements:n,originalAppState:r})=>{let i=t.scene.getNonDeletedElementsMap(),a=n?.[0],o=a&&i.get(a.id);if(o&&P(o)){let n=Os(t.scene.getElementsIncludingDeleted(),o,r,t.scene.getNonDeletedElementsMap()),i=xi(t.scene.getElementsIncludingDeleted(),n,o);t.scene.replaceAllElements(i),e({elementsToHighlight:null})}},ZR=({property:e,elements:t,elementsMap:n,atomicUnits:r,scene:i,appState:a})=>{let o=(0,B.useMemo)(()=>r.map(t=>{let r=wR(t,n);if(r.length>1){let[t,n,i,a]=Is(r.map(e=>e.latest));return Math.round((e===`width`?i-t:a-n)*100)/100}let[i]=r;return Math.round((e===`width`?i.latest.width:i.latest.height)*100)/100}),[n,r,e]),s=new Set(o).size===1?Math.round(o[0]*100)/100:`Mixed`,c=o.length>0;return(0,V.jsx)(DR,{label:e===`width`?`W`:`H`,elements:t,dragInputCallback:YR,value:s,editable:c,appState:a,property:e,scene:i,dragFinishedCallback:XR})},QR=4,$R=4,ez=(e,t)=>e.reduce((e,n)=>{if(!n||wa(n))return e;if(a(n))return e.push(n),e;if(Dr(n)){let r=Ti(n,t);if(r)return e.push(r),e}return e},[]),tz=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:n,nextValue:r,scene:i})=>{let a=i.getNonDeletedElementsMap(),o=t.map(e=>a.get(e.id)),s;if(r){s=Math.max(Math.round(r),QR);for(let e of o)i.mutateElement(e,{fontSize:s}),Sa(e,i.getContainerElement(e),i);i.triggerUpdate()}else{let r=t;for(let t=0;t<o.length;t++){let a=o[t],s=r[t],c=Math.round(s.fontSize),l=Math.max(c+Math.round(e),QR);n&&(l=CR(l,$R)),i.mutateElement(a,{fontSize:l}),Sa(a,i.getContainerElement(a),i)}i.triggerUpdate()}},nz=({elements:e,scene:t,appState:n,property:r,elementsMap:i})=>{let a=ez(e,i);if(!a.length)return null;let o=a.map(e=>Math.round(e.fontSize*10)/10),s=new Set(o).size===1?o[0]:`Mixed`,c=o.length>0;return(0,V.jsx)(DR,{label:`F`,icon:qx,elements:a,dragInputCallback:tz,value:s,editable:c,scene:t,property:r,appState:n})},rz=(e,t,n,r,i,a,o)=>{for(let s=0;s<r.length;s++){let c=r[s],[l,u]=[c.x+c.width/2,c.y+c.height/2],[d,f]=Fs(L(c.x,c.y),L(l,u),c.angle);TR(e===`x`?Math.round(d+t):d,e===`y`?Math.round(f+n):f,c,a,o,i,!1)}},iz=(e,t,n,r,i,o)=>{let s=i.getNonDeletedElementsMap(),[c,l,,]=Is(n),u=e-c,d=t-l;for(let e=0;e<n.length;e++){let t=n[e],c=s.get(t.id);if(c&&(!a(c)||!c.containerId)){let[e,n]=[c.x+c.width/2,c.y+c.height/2],[a,s]=Fs(L(c.x,c.y),L(e,n),c.angle);TR(a+u,s+d,t,i,o,r,!1)}}},az=({accumulatedChange:e,originalElements:t,originalElementsMap:n,shouldChangeByStepSize:r,nextValue:i,property:a,scene:o,originalAppState:s,app:c})=>{let l=o.getNonDeletedElementsMap();if(i!==void 0){for(let e of ER(t,s)){let t=wR(e,l,n);if(t.length>1){let[e,r,,]=Is(t.map(e=>e.latest));iz(a===`x`?i:e,a===`y`?i:r,t.map(e=>e.original),n,o,c.state)}else{let e=t[0]?.original,r=t[0]?.latest;if(e&&r&&SR(r,a)){let[t,r]=[e.x+e.width/2,e.y+e.height/2],[s,l]=Fs(L(e.x,e.y),L(t,r),e.angle);TR(a===`x`?i:s,a===`y`?i:l,e,o,c.state,n,!1)}}}o.triggerUpdate();return}let u=r?CR(e,xR):e;rz(a,a===`x`?u:0,a===`y`?u:0,t,n,o,c.state),o.triggerUpdate()},oz=({property:e,elements:t,elementsMap:n,atomicUnits:r,scene:i,appState:a})=>{let o=(0,B.useMemo)(()=>r.map(t=>{let r=Object.keys(t).map(e=>n.get(e)).filter(e=>e!==void 0);if(r.length>1){let[t,n]=Is(r);return Math.round((e===`x`?t:n)*100)/100}let[i]=r,[a,o]=[i.x+i.width/2,i.y+i.height/2],[s,c]=Fs(L(i.x,i.y),L(a,o),i.angle);return Math.round((e===`x`?s:c)*100)/100}),[r,n,e]),s=new Set(o).size===1?o[0]:`Mixed`;return(0,V.jsx)(DR,{label:e===`x`?`X`:`Y`,elements:t,dragInputCallback:az,value:s,property:e,scene:i,appState:a})},sz=({accumulatedChange:e,instantChange:t,originalElements:n,originalElementsMap:r,shouldChangeByStepSize:i,nextValue:a,property:o,scene:s,originalAppState:c,app:l})=>{let u=s.getNonDeletedElementsMap(),d=n[0],[f,p]=[d.x+d.width/2,d.y+d.height/2],[m,h]=Fs(L(d.x,d.y),L(f,p),d.angle);if(c.croppingElementId===d.id){let e=u.get(d.id);if(!e||!De(e)||!e.crop)return;let n=e.crop,r=n,i=e.scale[0]===-1,c=e.scale[1]===-1,{width:l,height:f}=Vo(e);if(a!==void 0){if(o===`x`){let e=a*(n.naturalWidth/l);r=i?{...n,x:ss(n.naturalWidth-e-n.width,0,n.naturalWidth-n.width)}:{...n,x:ss(a*(n.naturalWidth/l),0,n.naturalWidth-n.width)}}o===`y`&&(r={...n,y:ss(a*(n.naturalHeight/f),0,n.naturalHeight-n.height)}),s.mutateElement(e,{crop:r});return}let p=(o===`x`?t:0)*(i?-1:1),m=(o===`y`?t:0)*(c?-1:1);r={...n,x:ss(n.x+p,0,n.naturalWidth-n.width),y:ss(n.y+m,0,n.naturalHeight-n.height)},s.mutateElement(e,{crop:r});return}if(a!==void 0){TR(o===`x`?a:m,o===`y`?a:h,d,s,l.state,r);return}let g=o===`x`?e:0,_=o===`y`?e:0;TR(o===`x`?Math.round(i?CR(d.x+g,xR):m+g):m,o===`y`?Math.round(i?CR(d.y+_,xR):h+_):h,d,s,l.state,r)},cz=({property:e,element:t,scene:n,appState:r})=>{let[i,a]=Fs(L(t.x,t.y),L(t.x+t.width/2,t.y+t.height/2),t.angle),o=Ei(e===`x`?i:a,2);if(r.croppingElementId===t.id&&De(t)&&t.crop){let n=qn(t);n&&(o=Ei(e===`x`?n.x:n.y,2))}return(0,V.jsx)(DR,{label:e===`x`?`X`:`Y`,elements:[t],dragInputCallback:sz,scene:n,value:o,property:e,appState:r})},lz=50,uz=e=>{let t=uV(),n=e.app.scene.getSceneNonce()||1,r=e.app.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1}),i=wM(e.app);return(0,V.jsx)(pz,{...e,appState:t,sceneNonce:n,selectedElements:r,gridModeEnabled:i})},dz=({children:e,columns:t=1,heading:n,style:r,...i})=>(0,V.jsx)(`div`,{className:H(`exc-stats__row`,{"exc-stats__row--heading":n}),style:{gridTemplateColumns:`repeat(${t}, 1fr)`,...r},...i,children:e});dz.displayName=`StatsRow`;var fz=({children:e,order:t,style:n,...r})=>(0,V.jsx)(`div`,{className:`exc-stats__rows`,style:{order:t,...n},...r,children:e});fz.displayName=`StatsRows`,uz.StatsRow=dz,uz.StatsRows=fz;var pz=(0,B.memo)(({app:e,onClose:t,renderCustomStats:n,selectedElements:r,appState:i,sceneNonce:a,gridModeEnabled:o})=>{let s=e.scene,c=s.getNonDeletedElements(),l=s.getNonDeletedElementsMap(),u=dV(),d=r.length===1?r[0]:null,f=r.length>1?r:null,p=i.croppingElementId&&De(d),h=p?Vo(d):null,[g,_]=(0,B.useState)({width:0,height:0}),v=(0,B.useMemo)(()=>(0,Hc.default)(e=>{let t=Is(e);_({width:Math.round(t[2])-Math.round(t[0]),height:Math.round(t[3])-Math.round(t[1])})},lz),[]);(0,B.useEffect)(()=>{v(c)},[a,c,v]),(0,B.useEffect)(()=>()=>v.cancel(),[v]);let y=(0,B.useMemo)(()=>ER(r,i),[r,i]),b=(0,B.useMemo)(()=>Ln(r),[r]);return(0,V.jsx)(`div`,{className:`exc-stats`,children:(0,V.jsxs)(PC,{padding:3,children:[(0,V.jsxs)(`div`,{className:`title`,children:[(0,V.jsx)(`h2`,{children:W(`stats.title`)}),(0,V.jsx)(`div`,{className:`close`,onClick:t,children:lx})]}),(0,V.jsxs)(Ow,{label:(0,V.jsx)(`h3`,{children:W(`stats.generalStats`)}),open:!!(i.stats.panels&xn.generalStats),openTrigger:()=>u(e=>({stats:{open:!0,panels:e.stats.panels^xn.generalStats}})),children:[(0,V.jsxs)(fz,{children:[(0,V.jsx)(dz,{heading:!0,children:W(`stats.scene`)}),(0,V.jsxs)(dz,{columns:2,children:[(0,V.jsx)(`div`,{children:W(`stats.shapes`)}),(0,V.jsx)(`div`,{children:c.length})]}),(0,V.jsxs)(dz,{columns:2,children:[(0,V.jsx)(`div`,{children:W(`stats.width`)}),(0,V.jsx)(`div`,{children:g.width})]}),(0,V.jsxs)(dz,{columns:2,children:[(0,V.jsx)(`div`,{children:W(`stats.height`)}),(0,V.jsx)(`div`,{children:g.height})]}),o&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(dz,{heading:!0,children:`Canvas`}),(0,V.jsx)(dz,{children:(0,V.jsx)(MR,{property:`gridStep`,scene:s,appState:i,setAppState:u})})]})]}),n?.(c,i)]}),!b&&r.length>0&&(0,V.jsx)(`div`,{id:`elementStats`,style:{marginTop:12},children:(0,V.jsx)(Ow,{label:(0,V.jsx)(`h3`,{children:W(`stats.elementProperties`)}),open:!!(i.stats.panels&xn.elementProperties),openTrigger:()=>u(e=>({stats:{open:!0,panels:e.stats.panels^xn.elementProperties}})),children:(0,V.jsxs)(fz,{children:[d&&(0,V.jsxs)(V.Fragment,{children:[p&&(0,V.jsx)(dz,{heading:!0,children:W(`labels.unCroppedDimension`)}),i.croppingElementId&&De(d)&&h&&(0,V.jsxs)(dz,{columns:2,children:[(0,V.jsx)(`div`,{children:W(`stats.width`)}),(0,V.jsx)(`div`,{children:Ei(h.width,2)})]}),i.croppingElementId&&De(d)&&h&&(0,V.jsxs)(dz,{columns:2,children:[(0,V.jsx)(`div`,{children:W(`stats.height`)}),(0,V.jsx)(`div`,{children:Ei(h.height,2)})]}),(0,V.jsx)(dz,{heading:!0,"data-testid":`stats-element-type`,style:{margin:`0.3125rem 0`},children:i.croppingElementId?W(`labels.imageCropping`):W(`element.${d.type}`)}),(0,V.jsx)(dz,{children:(0,V.jsx)(cz,{element:d,property:`x`,elementsMap:l,scene:s,appState:i})}),(0,V.jsx)(dz,{children:(0,V.jsx)(cz,{element:d,property:`y`,elementsMap:l,scene:s,appState:i})}),(0,V.jsx)(dz,{children:(0,V.jsx)(LR,{property:`width`,element:d,scene:s,appState:i})}),(0,V.jsx)(dz,{children:(0,V.jsx)(LR,{property:`height`,element:d,scene:s,appState:i})}),(0,V.jsx)(dz,{children:(0,V.jsx)(AR,{property:`angle`,element:d,scene:s,appState:i})}),(0,V.jsx)(dz,{children:(0,V.jsx)(VR,{property:`fontSize`,element:d,scene:s,appState:i})})]}),f&&(0,V.jsxs)(V.Fragment,{children:[m(f)&&(0,V.jsx)(dz,{heading:!0,children:W(`element.group`)}),(0,V.jsxs)(dz,{columns:2,style:{margin:`0.3125rem 0`},children:[(0,V.jsx)(`div`,{children:W(`stats.shapes`)}),(0,V.jsx)(`div`,{children:r.length})]}),(0,V.jsx)(dz,{children:(0,V.jsx)(oz,{property:`x`,elements:f,elementsMap:l,atomicUnits:y,scene:s,appState:i})}),(0,V.jsx)(dz,{children:(0,V.jsx)(oz,{property:`y`,elements:f,elementsMap:l,atomicUnits:y,scene:s,appState:i})}),(0,V.jsx)(dz,{children:(0,V.jsx)(ZR,{property:`width`,elements:f,elementsMap:l,atomicUnits:y,scene:s,appState:i})}),(0,V.jsx)(dz,{children:(0,V.jsx)(ZR,{property:`height`,elements:f,elementsMap:l,atomicUnits:y,scene:s,appState:i})}),(0,V.jsx)(dz,{children:(0,V.jsx)(WR,{property:`angle`,elements:f,scene:s,appState:i})}),(0,V.jsx)(dz,{children:(0,V.jsx)(nz,{property:`fontSize`,elements:f,scene:s,appState:i,elementsMap:l})})]})]})})})]})})},(e,t)=>e.sceneNonce===t.sceneNonce&&e.selectedElements===t.selectedElements&&e.appState.stats.panels===t.appState.stats.panels&&e.gridModeEnabled===t.gridModeEnabled&&e.appState.gridStep===t.appState.gridStep&&e.appState.croppingElementId===t.appState.croppingElementId),mz=({sourceElementId:e,onClose:t,appState:n,scene:r,generateLinkForSelection:i=ur})=>{let a=r.getNonDeletedElementsMap(),o=a.get(e)?.link??null,[s,c]=(0,B.useState)(o),[l,u]=(0,B.useState)(!1);(0,B.useEffect)(()=>{let e=xt(a,n),t=o;if(e.length>0&&i){let r=ua(e,n);r&&(t=Ts(i(r.id,r.type)))}c(t)},[a,n,n.selectedElementIds,o,i]);let d=(0,B.useCallback)(()=>{if(s&&s!==a.get(e)?.link){let t=a.get(e);t&&r.mutateElement(t,{link:s})}if(!s&&l&&e){let t=a.get(e);t&&r.mutateElement(t,{link:null})}t?.()},[e,s,a,l,r,t]);return(0,B.useEffect)(()=>{let e=e=>{n.openDialog?.name===`elementLinkSelector`&&e.key===j.ENTER&&d(),n.openDialog?.name===`elementLinkSelector`&&e.key===j.ESCAPE&&t?.()};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[n,t,d]),(0,V.jsxs)(`div`,{className:`ElementLinkDialog`,children:[(0,V.jsxs)(`div`,{className:`ElementLinkDialog__header`,children:[(0,V.jsx)(`h2`,{children:W(`elementLink.title`)}),(0,V.jsx)(`p`,{children:W(`elementLink.desc`)})]}),(0,V.jsxs)(`div`,{className:`ElementLinkDialog__input`,children:[(0,V.jsx)(zk,{value:s??``,onChange:e=>{l||u(!0),c(e)},onKeyDown:e=>{e.key===j.ENTER&&d()},className:`ElementLinkDialog__input-field`,selectOnRender:!0}),o&&s&&(0,V.jsx)(J,{type:`button`,title:W(`buttons.remove`),"aria-label":W(`buttons.remove`),label:W(`buttons.remove`),onClick:()=>{c(null),u(!0)},className:`ElementLinkDialog__remove`,icon:yb})]}),(0,V.jsxs)(`div`,{className:`ElementLinkDialog__actions`,children:[(0,V.jsx)(KO,{label:W(`buttons.cancel`),onClick:()=>{t?.()},style:{marginRight:10}}),(0,V.jsx)(KO,{label:W(`buttons.confirm`),onClick:d,actionType:`primary`})]})]})},hz=({children:e,onClose:t})=>{let[n,r]=(0,B.useState)(!!e),{container:i}=cV(),a=B.useCallback(()=>{r(!1),t&&t(),i?.focus()},[t,i]);return(0,V.jsx)(V.Fragment,{children:n&&(0,V.jsx)(Zk,{size:`small`,onCloseRequest:a,title:W(`errorDialog.title`),children:(0,V.jsx)(`div`,{style:{whiteSpace:`pre-wrap`},children:e})})})},gz=()=>(0,V.jsxs)(`div`,{className:`HelpDialog__header`,children:[(0,V.jsxs)(`a`,{className:`HelpDialog__btn`,href:`https://docs.excalidraw.com`,target:`_blank`,rel:`noopener`,children:[(0,V.jsx)(`div`,{className:`HelpDialog__link-icon`,children:Ob}),W(`helpDialog.documentation`)]}),(0,V.jsxs)(`a`,{className:`HelpDialog__btn`,href:`https://plus.excalidraw.com/blog`,target:`_blank`,rel:`noopener`,children:[(0,V.jsx)(`div`,{className:`HelpDialog__link-icon`,children:Ob}),W(`helpDialog.blog`)]}),(0,V.jsxs)(`a`,{className:`HelpDialog__btn`,href:`https://github.com/excalidraw/excalidraw/issues`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,V.jsx)(`div`,{className:`HelpDialog__link-icon`,children:kb}),W(`helpDialog.github`)]}),(0,V.jsxs)(`a`,{className:`HelpDialog__btn`,href:`https://youtube.com/@excalidraw`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,V.jsx)(`div`,{className:`HelpDialog__link-icon`,children:WS}),`YouTube`]})]}),_z=e=>(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`h3`,{children:e.title}),(0,V.jsx)(`div`,{className:`HelpDialog__islands-container`,children:e.children})]}),vz=e=>(0,V.jsxs)(`div`,{className:`HelpDialog__island ${e.className}`,children:[(0,V.jsx)(`h4`,{className:`HelpDialog__island-title`,children:e.caption}),(0,V.jsx)(`div`,{className:`HelpDialog__island-content`,children:e.children})]});function*yz(e,t){let n=!0;for(let r of e)n||(yield t),n=!1,yield r}var bz=e=>e.replace(/\b[a-z]\b/,e=>e.toUpperCase()),Q=({label:e,shortcuts:t,isOr:n=!0})=>{let r=t.map(e=>(e.endsWith(`++`)?[...e.slice(0,-2).split(`+`),`+`]:e.split(`+`)).map(e=>(0,V.jsx)(xz,{children:bz(e)},e)));return(0,V.jsxs)(`div`,{className:`HelpDialog__shortcut`,children:[(0,V.jsx)(`div`,{children:e}),(0,V.jsx)(`div`,{className:`HelpDialog__key-container`,children:[...yz(r,n?W(`helpDialog.or`):``)]})]})},xz=e=>(0,V.jsx)(`kbd`,{className:`HelpDialog__key`,...e}),Sz=({onClose:e})=>{let t=fV(),n=B.useCallback(()=>{e&&e()},[e]);return(0,V.jsx)(V.Fragment,{children:(0,V.jsxs)(Zk,{onCloseRequest:n,title:W(`helpDialog.title`),className:`HelpDialog`,children:[(0,V.jsx)(gz,{}),(0,V.jsxs)(_z,{title:W(`helpDialog.shortcuts`),children:[(0,V.jsxs)(vz,{className:`HelpDialog__island--tools`,caption:W(`helpDialog.tools`),children:[(0,V.jsx)(Q,{label:W(`toolBar.hand`),shortcuts:[j.H]}),(0,V.jsx)(Q,{label:W(`toolBar.selection`),shortcuts:[j.V,j[1]]}),(0,V.jsx)(Q,{label:W(`toolBar.rectangle`),shortcuts:[j.R,j[2]]}),(0,V.jsx)(Q,{label:W(`toolBar.diamond`),shortcuts:[j.D,j[3]]}),(0,V.jsx)(Q,{label:W(`toolBar.ellipse`),shortcuts:[j.O,j[4]]}),(0,V.jsx)(Q,{label:W(`toolBar.arrow`),shortcuts:[j.A,j[5]]}),(0,V.jsx)(Q,{label:W(`toolBar.line`),shortcuts:[j.L,j[6]]}),(0,V.jsx)(Q,{label:W(`toolBar.freedraw`),shortcuts:[j.P,j[7]]}),(0,V.jsx)(Q,{label:W(`toolBar.text`),shortcuts:[j.T,j[8]]}),(0,V.jsx)(Q,{label:W(`toolBar.image`),shortcuts:[j[9]]}),(0,V.jsx)(Q,{label:W(`toolBar.eraser`),shortcuts:[j.E,j[0]]}),(0,V.jsx)(Q,{label:W(`toolBar.frame`),shortcuts:[j.F]}),(0,V.jsx)(Q,{label:W(`toolBar.laser`),shortcuts:[j.K]}),(0,V.jsx)(Q,{label:W(`toolBar.bucketfill`),shortcuts:[j.B]}),(0,V.jsx)(Q,{label:W(`labels.eyeDropper`),shortcuts:[j.I,`Shift+S`,`Shift+G`]}),(0,V.jsx)(Q,{label:W(`helpDialog.editLineArrowPoints`),shortcuts:[X(`CtrlOrCmd+Enter`)]}),(0,V.jsx)(Q,{label:W(`helpDialog.editText`),shortcuts:[X(`Enter`)]}),(0,V.jsx)(Q,{label:W(`helpDialog.textNewLine`),shortcuts:[X(`Enter`),X(`Shift+Enter`)]}),(0,V.jsx)(Q,{label:W(`helpDialog.textFinish`),shortcuts:[X(`Esc`),X(`CtrlOrCmd+Enter`)]}),(0,V.jsx)(Q,{label:W(`helpDialog.curvedArrow`),shortcuts:[`A`,W(`helpDialog.click`),W(`helpDialog.click`),W(`helpDialog.click`)],isOr:!1}),(0,V.jsx)(Q,{label:W(`helpDialog.curvedLine`),shortcuts:[`L`,W(`helpDialog.click`),W(`helpDialog.click`),W(`helpDialog.click`)],isOr:!1}),(0,V.jsx)(Q,{label:W(`helpDialog.cropStart`),shortcuts:[W(`helpDialog.doubleClick`),X(`Enter`)],isOr:!0}),(0,V.jsx)(Q,{label:W(`helpDialog.cropFinish`),shortcuts:[X(`Enter`),X(`Escape`)],isOr:!0}),(0,V.jsx)(Q,{label:W(`toolBar.lock`),shortcuts:[j.Q]}),(0,V.jsx)(Q,{label:W(`helpDialog.preventBinding`),shortcuts:[X(`CtrlOrCmd`)]}),(0,V.jsx)(Q,{label:W(`toolBar.link`),shortcuts:[X(`CtrlOrCmd+K`)]}),(0,V.jsx)(Q,{label:W(`toolBar.convertElementType`),shortcuts:[`Tab`,`Shift+Tab`],isOr:!0})]}),(0,V.jsxs)(vz,{className:`HelpDialog__island--view`,caption:W(`helpDialog.view`),children:[(0,V.jsx)(Q,{label:W(`buttons.zoomIn`),shortcuts:[X(`CtrlOrCmd++`)]}),(0,V.jsx)(Q,{label:W(`buttons.zoomOut`),shortcuts:[X(`CtrlOrCmd+-`)]}),(0,V.jsx)(Q,{label:W(`buttons.resetZoom`),shortcuts:[X(`CtrlOrCmd+0`)]}),(0,V.jsx)(Q,{label:W(`helpDialog.zoomToFit`),shortcuts:[`Shift+1`]}),(0,V.jsx)(Q,{label:W(`helpDialog.zoomToSelection`),shortcuts:[`Shift+2`]}),(0,V.jsx)(Q,{label:W(`helpDialog.movePageUpDown`),shortcuts:[`PgUp/PgDn`]}),(0,V.jsx)(Q,{label:W(`helpDialog.movePageLeftRight`),shortcuts:[`Shift+PgUp/PgDn`]}),(0,V.jsx)(Q,{label:W(`buttons.zenMode`),shortcuts:[X(`Alt+Z`)]}),(0,V.jsx)(Q,{label:W(`buttons.objectsSnapMode`),shortcuts:[X(`Alt+S`)]}),(0,V.jsx)(Q,{label:W(`labels.toggleGrid`),shortcuts:[X(`CtrlOrCmd+'`)]}),(0,V.jsx)(Q,{label:W(`labels.viewMode`),shortcuts:[X(`Alt+R`)]}),t.isActionEnabled(uT)&&(0,V.jsx)(Q,{label:W(`labels.toggleTheme`),shortcuts:[X(`Alt+Shift+D`)]}),(0,V.jsx)(Q,{label:W(`stats.fullTitle`),shortcuts:[X(`Alt+/`)]}),(0,V.jsx)(Q,{label:W(`search.title`),shortcuts:[lO(`searchMenu`)]}),(0,V.jsx)(Q,{label:W(`commandPalette.title`),shortcuts:Ya?[lO(`commandPalette`)]:[lO(`commandPalette`),lO(`commandPalette`,1)]})]}),(0,V.jsxs)(vz,{className:`HelpDialog__island--editor`,caption:W(`helpDialog.editor`),children:[(0,V.jsx)(Q,{label:W(`helpDialog.createFlowchart`),shortcuts:[X(`CtrlOrCmd+Arrow Key`)],isOr:!0}),(0,V.jsx)(Q,{label:W(`helpDialog.navigateFlowchart`),shortcuts:[X(`Alt+Arrow Key`)],isOr:!0}),(0,V.jsx)(Q,{label:W(`labels.moveCanvas`),shortcuts:[X(`Space+${W(`helpDialog.drag`)}`),X(`Wheel+${W(`helpDialog.drag`)}`)],isOr:!0}),(0,V.jsx)(Q,{label:W(`buttons.clearReset`),shortcuts:[X(`CtrlOrCmd+Delete`)]}),(0,V.jsx)(Q,{label:W(`labels.delete`),shortcuts:[X(`Delete`)]}),(0,V.jsx)(Q,{label:W(`labels.cut`),shortcuts:[X(`CtrlOrCmd+X`)]}),(0,V.jsx)(Q,{label:W(`labels.copy`),shortcuts:[X(`CtrlOrCmd+C`)]}),(0,V.jsx)(Q,{label:W(`labels.paste`),shortcuts:[X(`CtrlOrCmd+V`)]}),(0,V.jsx)(Q,{label:W(`labels.pasteAsPlaintext`),shortcuts:[X(`CtrlOrCmd+Shift+V`)]}),(0,V.jsx)(Q,{label:W(`labels.selectAll`),shortcuts:[X(`CtrlOrCmd+A`)]}),(0,V.jsx)(Q,{label:W(`labels.multiSelect`),shortcuts:[X(`Shift+${W(`helpDialog.click`)}`)]}),(0,V.jsx)(Q,{label:W(`helpDialog.deepSelect`),shortcuts:[X(`CtrlOrCmd+${W(`helpDialog.click`)}`)]}),(0,V.jsx)(Q,{label:W(`helpDialog.deepBoxSelect`),shortcuts:[X(`CtrlOrCmd+${W(`helpDialog.drag`)}`)]}),(WT||Ya)&&(0,V.jsx)(Q,{label:W(`labels.copyAsPng`),shortcuts:[X(`Shift+Alt+C`)]}),(0,V.jsx)(Q,{label:W(`labels.copyStyles`),shortcuts:[X(`CtrlOrCmd+Alt+C`)]}),(0,V.jsx)(Q,{label:W(`labels.pasteStyles`),shortcuts:[X(`CtrlOrCmd+Alt+V`)]}),(0,V.jsx)(Q,{label:W(`labels.sendToBack`),shortcuts:[X(_t?`CtrlOrCmd+Alt+[`:`CtrlOrCmd+Shift+[`)]}),(0,V.jsx)(Q,{label:W(`labels.bringToFront`),shortcuts:[X(_t?`CtrlOrCmd+Alt+]`:`CtrlOrCmd+Shift+]`)]}),(0,V.jsx)(Q,{label:W(`labels.sendBackward`),shortcuts:[X(`CtrlOrCmd+[`)]}),(0,V.jsx)(Q,{label:W(`labels.bringForward`),shortcuts:[X(`CtrlOrCmd+]`)]}),(0,V.jsx)(Q,{label:W(`labels.alignTop`),shortcuts:[X(`CtrlOrCmd+Shift+Up`)]}),(0,V.jsx)(Q,{label:W(`labels.alignBottom`),shortcuts:[X(`CtrlOrCmd+Shift+Down`)]}),(0,V.jsx)(Q,{label:W(`labels.alignLeft`),shortcuts:[X(`CtrlOrCmd+Shift+Left`)]}),(0,V.jsx)(Q,{label:W(`labels.alignRight`),shortcuts:[X(`CtrlOrCmd+Shift+Right`)]}),(0,V.jsx)(Q,{label:W(`labels.duplicateSelection`),shortcuts:[X(`CtrlOrCmd+D`),X(`Alt+${W(`helpDialog.drag`)}`)]}),(0,V.jsx)(Q,{label:W(`helpDialog.toggleElementLock`),shortcuts:[X(`CtrlOrCmd+Shift+L`)]}),(0,V.jsx)(Q,{label:W(`buttons.undo`),shortcuts:[X(`CtrlOrCmd+Z`)]}),(0,V.jsx)(Q,{label:W(`buttons.redo`),shortcuts:p?[X(`CtrlOrCmd+Y`),X(`CtrlOrCmd+Shift+Z`)]:[X(`CtrlOrCmd+Shift+Z`)]}),(0,V.jsx)(Q,{label:W(`labels.group`),shortcuts:[X(`CtrlOrCmd+G`)]}),(0,V.jsx)(Q,{label:W(`labels.ungroup`),shortcuts:[X(`CtrlOrCmd+Shift+G`)]}),(0,V.jsx)(Q,{label:W(`labels.flipHorizontal`),shortcuts:[X(`Shift+H`)]}),(0,V.jsx)(Q,{label:W(`labels.flipVertical`),shortcuts:[X(`Shift+V`)]}),(0,V.jsx)(Q,{label:W(`labels.showStroke`),shortcuts:[X(`S`)]}),(0,V.jsx)(Q,{label:W(`labels.showBackground`),shortcuts:[X(`G`)]}),(0,V.jsx)(Q,{label:W(`labels.showFonts`),shortcuts:[X(`Shift+F`)]}),(0,V.jsx)(Q,{label:W(`labels.decreaseFontSize`),shortcuts:[X(`CtrlOrCmd+Shift+<`)]}),(0,V.jsx)(Q,{label:W(`labels.increaseFontSize`),shortcuts:[X(`CtrlOrCmd+Shift+>`)]})]})]})]})})},Cz=2e3,wz=()=>{let[e,t]=(0,B.useState)(null),n=(0,B.useRef)(0);return{copyStatus:e,resetCopyStatus:(0,B.useCallback)(()=>{t(null)},[]),onCopy:()=>{clearTimeout(n.current),t(`success`),n.current=window.setTimeout(()=>{t(null)},Cz)}}},Tz=({title:e,name:t,checked:n,onChange:r,disabled:i=!1})=>(0,V.jsx)(`div`,{className:H(`Switch`,{toggled:n,disabled:i}),children:(0,V.jsx)(`input`,{name:t,id:t,title:e,type:`checkbox`,checked:n,disabled:i,onChange:()=>r(!n),onKeyDown:e=>{e.key===` `&&r(!n)}})}),Ez=()=>(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h3`,{children:W(`canvasError.cannotShowPreview`)}),(0,V.jsx)(`p`,{children:(0,V.jsx)(`span`,{children:W(`canvasError.canvasTooBig`)})}),(0,V.jsxs)(`em`,{children:[`(`,W(`canvasError.canvasTooBigTip`),`)`]})]}),Dz=({appStateSnapshot:e,elementsSnapshot:t,files:n,actionManager:r,onExportImage:i,name:a,exportWithDarkMode:o})=>{let s=Bi(t,e),[c,l]=(0,B.useState)(a),[u,d]=(0,B.useState)(s),[f,p]=(0,B.useState)(e.exportBackground),[m,h]=(0,B.useState)(e.exportEmbedScene),[g,_]=(0,B.useState)(e.exportScale),v=(0,B.useRef)(null),y=(0,B.useRef)(0),[b,x]=(0,B.useState)(null),{onCopy:S,copyStatus:C,resetCopyStatus:w}=wz();(0,B.useEffect)(()=>{w()},[c,f,o,g,m,w]);let{exportedElements:T,exportingFrame:E}=lE(t,e,u);return(0,B.useEffect)(()=>{let t=v.current;if(!t)return;let r=t.offsetWidth,i=t.offsetHeight;if(!r)return;let a=++y.current,s=()=>a!==y.current;return hO({elements:T,appState:{...e,name:c,exportBackground:f,exportWithDarkMode:o,exportScale:g,exportEmbedScene:m},files:n,exportPadding:10,maxWidthOrHeight:Math.max(r,i),exportingFrame:E}).then(async e=>{if(!s()){try{await vo(e)}catch(e){throw e.name===`CANVAS_POSSIBLY_TOO_BIG`?Error(W(`canvasError.canvasTooBig`)):e}s()||(x(null),t.replaceChildren(e))}}).catch(e=>{s()||(console.error(e),x(e))}),()=>{y.current+=1}},[e,n,T,E,c,f,o,g,m]),(0,V.jsxs)(`div`,{className:`ImageExportModal`,children:[(0,V.jsx)(`h3`,{children:W(`imageExportDialog.header`)}),(0,V.jsxs)(`div`,{className:`ImageExportModal__preview`,children:[(0,V.jsx)(`div`,{className:`ImageExportModal__preview__canvas`,ref:v,children:b&&(0,V.jsx)(Ez,{})}),(0,V.jsx)(`div`,{className:`ImageExportModal__preview__filename`,children:!Ss&&(0,V.jsx)(`input`,{type:`text`,className:`TextInput`,value:c,style:{width:`30ch`},onChange:e=>{l(e.target.value),r.executeAction(fE,`ui`,e.target.value)}})})]}),(0,V.jsxs)(`div`,{className:`ImageExportModal__settings`,children:[(0,V.jsx)(`h3`,{children:W(`imageExportDialog.header`)}),s&&(0,V.jsx)(Oz,{label:W(`imageExportDialog.label.onlySelected`),name:`exportOnlySelected`,children:(0,V.jsx)(Tz,{name:`exportOnlySelected`,checked:u,onChange:e=>{d(e)}})}),(0,V.jsx)(Oz,{label:W(`imageExportDialog.label.withBackground`),name:`exportBackgroundSwitch`,children:(0,V.jsx)(Tz,{name:`exportBackgroundSwitch`,checked:f,onChange:e=>{p(e),r.executeAction(mE,`ui`,e)}})}),(0,V.jsx)(Oz,{label:W(`imageExportDialog.label.darkMode`),name:`exportDarkModeSwitch`,children:(0,V.jsx)(Tz,{name:`exportDarkModeSwitch`,checked:o,onChange:e=>{r.executeAction(CE,`ui`,e)}})}),(0,V.jsx)(Oz,{label:W(`imageExportDialog.label.embedScene`),tooltip:W(`imageExportDialog.tooltip.embedScene`),name:`exportEmbedSwitch`,children:(0,V.jsx)(Tz,{name:`exportEmbedSwitch`,checked:m,onChange:e=>{h(e),r.executeAction(hE,`ui`,e)}})}),(0,V.jsx)(Oz,{label:W(`imageExportDialog.label.scale`),name:`exportScale`,children:(0,V.jsx)(rI,{name:`exportScale`,value:g,onChange:e=>{_(e),r.executeAction(pE,`ui`,e)},choices:ja.map(e=>({value:e,label:`${e}\xD7`}))})}),(0,V.jsxs)(`div`,{className:`ImageExportModal__settings__buttons`,children:[(0,V.jsx)(kI,{className:`ImageExportModal__settings__buttons__button`,label:W(`imageExportDialog.title.exportToPng`),onClick:()=>i(Eo.png,T,{exportingFrame:E}),icon:sS,children:W(`imageExportDialog.button.exportToPng`)}),(0,V.jsx)(kI,{className:`ImageExportModal__settings__buttons__button`,label:W(`imageExportDialog.title.exportToSvg`),onClick:()=>i(Eo.svg,T,{exportingFrame:E}),icon:sS,children:W(`imageExportDialog.button.exportToSvg`)}),(WT||Ya)&&(0,V.jsx)(kI,{className:`ImageExportModal__settings__buttons__button`,label:W(`imageExportDialog.title.copyPngToClipboard`),status:C,onClick:async()=>{await i(Eo.clipboard,T,{exportingFrame:E}),S()},icon:cS,children:W(`imageExportDialog.button.copyPngToClipboard`)})]})]})]})},Oz=({label:e,children:t,tooltip:n,name:r})=>(0,V.jsxs)(`div`,{className:`ImageExportModal__settings__setting`,title:e,children:[(0,V.jsxs)(`label`,{htmlFor:r,className:`ImageExportModal__settings__setting__label`,children:[e,n&&(0,V.jsx)(eT,{label:n,long:!0,children:uS})]}),(0,V.jsx)(`div`,{className:`ImageExportModal__settings__setting__content`,children:t})]}),kz=({elements:e,appState:t,files:n,actionManager:r,onExportImage:i,onCloseRequest:a,name:o})=>{let[{appStateSnapshot:s,elementsSnapshot:c}]=(0,B.useState)(()=>({appStateSnapshot:ta(t),elementsSnapshot:ta(e)}));return(0,V.jsx)(Zk,{onCloseRequest:a,size:`wide`,title:!1,children:(0,V.jsx)(Dz,{elementsSnapshot:c,appStateSnapshot:s,files:n,actionManager:r,onExportImage:i,name:o,exportWithDarkMode:t.exportWithDarkMode})})},Az={primary:{base:`var(--color-primary)`,darker:`var(--color-primary-darker)`,darkest:`var(--color-primary-darkest)`},lime:{base:`#74b816`,darker:`#66a80f`,darkest:`#5c940d`},pink:{base:`#d6336c`,darker:`#c2255c`,darkest:`#a61e4d`}},jz=({children:e,color:t})=>(0,V.jsx)(`div`,{className:`Card`,style:{"--card-color":Az[t].base,"--card-color-darker":Az[t].darker,"--card-color-darkest":Az[t].darkest},children:e}),Mz=({elements:e,appState:t,setAppState:n,files:r,actionManager:i,exportOpts:a,canvas:o,onCloseRequest:s})=>{let{onExportToBackend:c}=a;return(0,V.jsx)(`div`,{className:`ExportDialog ExportDialog--json`,children:(0,V.jsxs)(`div`,{className:`ExportDialog-cards`,children:[a.saveFileToDisk&&(0,V.jsxs)(jz,{color:`lime`,children:[(0,V.jsx)(`div`,{className:`Card-icon`,children:Vb}),(0,V.jsx)(`h2`,{children:W(`exportDialog.disk_title`)}),(0,V.jsxs)(`div`,{className:`Card-details`,children:[W(`exportDialog.disk_details`),!Ss&&i.renderAction(`changeProjectName`)]}),(0,V.jsx)(J,{className:`Card-button`,type:`button`,title:W(`exportDialog.disk_button`),"aria-label":W(`exportDialog.disk_button`),showAriaLabel:!0,onClick:()=>{i.executeAction(xE,`ui`)}})]}),c&&(0,V.jsxs)(jz,{color:`pink`,children:[(0,V.jsx)(`div`,{className:`Card-icon`,children:Nb}),(0,V.jsx)(`h2`,{children:W(`exportDialog.link_title`)}),(0,V.jsx)(`div`,{className:`Card-details`,children:W(`exportDialog.link_details`)}),(0,V.jsx)(J,{className:`Card-button`,type:`button`,title:W(`exportDialog.link_button`),"aria-label":W(`exportDialog.link_button`),showAriaLabel:!0,onClick:async()=>{try{xC(`export`,`link`,`ui (${ts()})`),await c(e,t,r),s()}catch(e){n({errorMessage:e.message})}}})]}),a.renderCustomUI&&a.renderCustomUI(e,t,r,o)]})})},Nz=({elements:e,appState:t,files:n,actionManager:r,exportOpts:i,canvas:a,setAppState:o})=>{let s=B.useCallback(()=>{o({openDialog:null})},[o]);return(0,V.jsx)(V.Fragment,{children:t.openDialog?.name===`jsonExport`&&(0,V.jsx)(Zk,{onCloseRequest:s,title:W(`buttons.export`),children:(0,V.jsx)(Mz,{elements:e,appState:t,setAppState:o,files:n,actionManager:r,onCloseRequest:s,exportOpts:i,canvas:a})})})},Pz=e=>(0,V.jsx)(J,{className:H(`ToolIcon__LaserPointer`,{"is-mobile":e.isMobile}),type:`toggle`,size:`small`,icon:bS,checked:e.checked,title:`${e.title}`,"aria-label":`${e.title}`,"data-testid":`toolbar-LaserPointer`,onSelect:()=>e.onChange?.()}),Fz=e=>Array.isArray(e)?`<kbd>${e.map(X).join(` + `)}</kbd>`:`<kbd>${X(e)}</kbd>`,Iz=({appState:e,isMobile:t,editorInterface:n,app:r})=>{let{activeTool:i,isResizing:o,isRotating:s,lastPointerDownWith:c}=e,l=e.multiElement!==null;if(e.openSidebar?.name===bo.name&&e.openSidebar.tab===`search`&&e.searchMatches?.matches.length)return W(`hints.dismissSearch`,{shortcut:Fz(`Escape`)});if(e.openSidebar&&!n.canFitSidebar)return null;if(ji(e))return W(`hints.eraserRevert`,{shortcut:Fz(`Alt`)});let u=r.scene.getSelectedElements(e);if(e.selectedLinearElement?.isDragging&&u[0]?.type===`arrow`)return W(`hints.arrowBindModifiers`,{shortcut_1:Fz(`Ctrl`),shortcut_2:Fz(`Alt`)});if(i.type===`arrow`||i.type===`line`)return l?W(`hints.linearElementMulti`,{shortcut_1:Fz(`Escape`),shortcut_2:Fz(`Enter`)}):i.type===`arrow`?W(`hints.arrowTool`,{shortcut:Fz(`A`)}):W(`hints.linearElement`);if(i.type===`freedraw`)return W(`hints.freeDraw`);if(i.type===`text`)return W(`hints.text`);if(i.type===`embeddable`)return W(`hints.embeddable`);if(i.type===`autoshape`)return W(`hints.autoshape`);if(o&&c===`mouse`&&u.length===1){let e=u[0];return po(e)&&e.points.length===2?W(`hints.lockAngle`,{shortcut:Fz(`Shift`)}):De(e)?W(`hints.resizeImage`,{shortcut_1:Fz(`Shift`),shortcut_2:Fz(`Alt`)}):W(`hints.resize`,{shortcut_1:Fz(`Shift`),shortcut_2:Fz(`Alt`)})}if(s&&c===`mouse`)return W(`hints.rotate`,{shortcut:Fz(`Shift`)});if(u.length===1&&a(u[0]))return W(`hints.text_selected`,{shortcut:Fz(`Enter`)});if(e.editingTextElement)return W(`hints.text_editing`,{shortcut_1:Fz(`Escape`),shortcut_2:Fz([`CtrlOrCmd`,`Enter`])});if(e.croppingElementId)return W(`hints.leaveCropEditor`,{shortcut_1:Fz(`Enter`),shortcut_2:Fz(`Escape`)});if(u.length===1&&De(u[0]))return W(`hints.enterCropEditor`,{shortcut:Fz(`Enter`)});if(i.type===`selection`){if(e.selectionElement&&!u.length&&!e.editingTextElement&&!e.selectedLinearElement?.isEditing)return W(`hints.deepBoxSelect`,{shortcut:Fz(`CtrlOrCmd`)});if(wM(r)&&e.selectedElementsAreBeingDragged)return W(`hints.disableSnapping`,{shortcut:Fz(`CtrlOrCmd`)});if(!u.length&&!t)return W(`hints.canvasPanning`,{shortcut_1:Fz(W(`keys.mmb`)),shortcut_2:Fz(`Space`)});if(u.length===1){if(po(u[0]))return _(u[0])&&e.selectedLinearElement?.elementId===u[0].id&&(e.selectedLinearElement.hoverPointIndex===0||e.selectedLinearElement.hoverPointIndex===u[0].points.length-1)?W(`hints.toggleArrowhead`):e.selectedLinearElement?.isEditing?e.selectedLinearElement.selectedPointsIndices?W(`hints.lineEditor_pointSelected`,{shortcut_1:Fz(`Delete`),shortcut_2:Fz([`CtrlOrCmd`,`D`])}):W(`hints.lineEditor_nothingSelected`,{shortcut_1:Fz(`Shift`),shortcut_2:Fz(`Alt`)}):Oe(u[0])?W(`hints.lineEditor_line_info`,{shortcut:Fz(`Enter`)}):W(`hints.lineEditor_info`,{shortcut_1:Fz(`CtrlOrCmd`),shortcut_2:Fz([`CtrlOrCmd`,`Enter`])});if(!e.newElement&&!e.selectedElementsAreBeingDragged&&Ii(u[0])){let e=W(`hints.bindTextToElement`,{shortcut:Fz(`Enter`)}),t=W(`hints.createFlowchart`,{shortcut:Fz([`CtrlOrCmd`,`↑↓`])});return jt(u[0])?(lr(u[0],r.scene.getNonDeletedElementsMap()),[e,t]):e}}}return null},Lz=({appState:e,isMobile:t,editorInterface:n,app:r})=>{let i=Iz({appState:e,isMobile:t,editorInterface:n,app:r});if(!i)return null;let a=(Array.isArray(i)?i.map(e=>e.replace(/\. ?$/,``)).join(`, `):i).split(/(<kbd>[^<]+<\/kbd>)/g).map((e,t)=>{if(t%2==1){let n=e[0]===`<`&&e.match(/^<kbd>([^<]+)<\/kbd>$/);return(0,V.jsx)(`kbd`,{children:n?n[1]:e},t)}return e});return(0,V.jsx)(`div`,{className:`HintViewer`,children:(0,V.jsx)(`span`,{children:a})})},Rz=e=>(0,V.jsx)(J,{className:H(`ToolIcon__lock`,{"is-mobile":e.isMobile}),type:`toggle`,icon:e.checked?Qy:Zy,checked:e.checked,disabled:e.disabled,title:`${e.title} \u2014 Q`,"aria-label":`${e.title}`,"data-testid":`toolbar-lock`,onSelect:()=>e.onChange?.()}),zz=({app:e,activeTool:t,setAppState:n})=>{let[r,i]=(0,B.useState)(!1),a=sV()===`full`,{TTDDialogTriggerTunnel:o}=yF(),s=t.type===`frame`,c=t.type===`autoshape`,l=t.type===`laser`,u=t.type===`bucketfill`,d=a&&t.type===`lasso`&&e.state.preferredSelectionTool.type!==`lasso`,f=t.type===`embeddable`;return(0,V.jsxs)(Z,{open:r,children:[(0,V.jsx)(Z.Trigger,{className:H(`App-toolbar__extra-tools-trigger`,{"App-toolbar__extra-tools-trigger--selected":s||f||a&&c||d||u||l&&!e.props.isCollaborating}),onToggle:()=>{i(!r),n({openMenu:null,openPopup:null})},title:W(`toolBar.extraTools`),children:s?mS:f?bb:a&&c?yS:l&&!e.props.isCollaborating?bS:d?ib:u?Rb:qy}),(0,V.jsxs)(Z.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:`App-toolbar__extra-tools-dropdown`,children:[(0,V.jsx)(Z.Item,{onSelect:()=>e.setActiveTool({type:`frame`}),icon:mS,shortcut:j.F.toLocaleUpperCase(),"data-testid":`toolbar-frame`,selected:s,disabled:_T(e,`frame`),children:W(`toolBar.frame`)}),(0,V.jsx)(Z.Item,{onSelect:()=>e.setActiveTool({type:`embeddable`}),icon:bb,"data-testid":`toolbar-embeddable`,selected:f,disabled:_T(e,`embeddable`),children:W(`toolBar.embeddable`)}),(0,V.jsx)(Z.Item,{onSelect:()=>e.setActiveTool({type:`autoshape`}),icon:yS,shortcut:hT(`autoshape`),"data-testid":`toolbar-autoshape`,selected:c,disabled:_T(e,`autoshape`),children:W(`toolBar.autoshape`)}),(0,V.jsx)(Z.Item,{onSelect:()=>e.setActiveTool({type:`laser`}),icon:bS,"data-testid":`toolbar-laser`,selected:l,shortcut:j.K.toLocaleUpperCase(),disabled:_T(e,`laser`),children:W(`toolBar.laser`)}),(0,V.jsx)(Z.Item,{onSelect:()=>e.setActiveTool({type:`bucketfill`}),icon:Rb,"data-testid":`toolbar-bucketfill`,selected:u,shortcut:j.B.toLocaleUpperCase(),disabled:_T(e,`bucketfill`),children:W(`toolBar.bucketfill`)}),a&&(0,V.jsx)(Z.Item,{onSelect:()=>e.setActiveTool({type:`lasso`}),icon:ib,"data-testid":`toolbar-lasso`,selected:d,disabled:_T(e,`lasso`),children:W(`toolBar.lasso`)}),(0,V.jsx)(`div`,{style:{margin:`6px 0`,fontSize:14,fontWeight:600},children:`Generate`}),e.props.aiEnabled!==!1&&(0,V.jsx)(o.Out,{}),(0,V.jsx)(Z.Item,{onSelect:()=>e.setOpenDialog({name:`ttd`,tab:`mermaid`}),icon:hS,"data-testid":`toolbar-embeddable`,children:W(`toolBar.mermaidToExcalidraw`)}),e.props.aiEnabled!==!1&&e.plugins.diagramToCode&&(0,V.jsx)(Z.Item,{onSelect:()=>e.onMagicframeToolSelect(),icon:xS,"data-testid":`toolbar-magicframe`,badge:(0,V.jsx)(Z.Item.Badge,{children:`AI`}),disabled:_T(e,`magicframe`),children:W(`toolBar.magicframe`)})]})]})},Bz=({app:e,appState:t,setAppState:n,UIOptions:r,onPenModeToggle:i,onLockToggle:a,heading:o})=>{let s=oV(),c=sV()===`compact`,l=t.activeTool,u={app:e,activeTool:l};return(0,V.jsxs)(PC,{padding:1,className:H(`App-toolbar`,{"zen-mode":t.zenModeEnabled,"App-toolbar--compact":c}),"data-viewport-ui":`top`,children:[(0,V.jsx)(Lz,{appState:t,isMobile:s.formFactor===`phone`,editorInterface:s,app:e}),o,(0,V.jsxs)(ik.Row,{gap:c?.5:1,children:[!c&&(0,V.jsx)(TF,{checked:t.penMode,onChange:()=>i(null),title:W(`toolBar.penMode`),penDetected:t.penDetected}),e.props.activeTool==null&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(Rz,{checked:t.activeTool.locked,onChange:a,title:W(`toolBar.lock`),disabled:e.props.activeTool!=null}),(0,V.jsx)(`div`,{className:`App-toolbar__divider`,style:{marginRight:`0.25rem`}})]}),(0,V.jsx)(yT,{...u,hideKeyBinding:!0}),c?(0,V.jsx)(MT,{...u,setAppState:n}):t.preferredSelectionTool.type===`lasso`?(0,V.jsx)(jT,{...u}):(0,V.jsx)(AT,{...u}),(0,V.jsx)(bT,{...u}),(0,V.jsx)(xT,{...u}),(0,V.jsx)(ST,{...u}),(0,V.jsx)(CT,{...u}),(0,V.jsx)(wT,{...u}),c?(0,V.jsx)(NT,{...u}):(0,V.jsx)(TT,{...u}),(0,V.jsx)(ET,{...u}),r.tools?.image!==!1&&(0,V.jsx)(DT,{...u}),(0,V.jsx)(OT,{...u}),(0,V.jsx)(`div`,{className:`App-toolbar__divider`,style:{marginLeft:`0.25rem`}}),(0,V.jsx)(zz,{app:e,activeTool:l,setAppState:n})]})]})},Vz=({UIOptions:e})=>(0,V.jsxs)(OI,{__fallback:!0,children:[(0,V.jsx)(OI.DefaultItems.LoadScene,{}),(0,V.jsx)(OI.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&(0,V.jsx)(OI.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&(0,V.jsx)(OI.DefaultItems.SaveAsImage,{}),(0,V.jsx)(OI.DefaultItems.SearchMenu,{}),(0,V.jsx)(OI.DefaultItems.Help,{}),(0,V.jsx)(OI.DefaultItems.ClearCanvas,{}),(0,V.jsx)(OI.Separator,{}),(0,V.jsx)(OI.Group,{title:`Excalidraw links`,children:(0,V.jsx)(OI.DefaultItems.Socials,{})}),(0,V.jsx)(OI.Separator,{}),(0,V.jsx)(OI.DefaultItems.ToggleTheme,{allowSystemTheme:!1}),(0,V.jsx)(OI.DefaultItems.ChangeCanvasBackground,{})]}),Hz=()=>(0,V.jsxs)(MI,{__fallback:!0,children:[(0,V.jsx)(MI.Actions.SaveToDisk,{}),(0,V.jsx)(MI.Actions.ExportToImage,{})]}),Uz=({actionManager:e,appState:t,files:n,setAppState:r,elements:i,canvas:a,onLockToggle:o,onPenModeToggle:s,showExitZenModeBtn:c,renderTopLeftUI:l,renderTopRightUI:u,renderCustomStats:d,UIOptions:f,onExportImage:p,renderWelcomeScreen:m,children:h,app:g,defaultUIEnabled:_,zoomUIEnabled:v,scrollBackToContentUIEnabled:y,isCollaborating:b,generateLinkForSelection:x,currentUserControls:S})=>{let C=oV(),w=aV(),T=sV()===`compact`,E=xF(),O=T?{menuTopGap:4,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:.5,islandPadding:1,collabMarginLeft:8}:{menuTopGap:6,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:1,islandPadding:1,collabMarginLeft:8},ee=E.tunnelsJotai.Provider,[k,te]=wy(MC),ne=()=>f.canvasActions.export?(0,V.jsx)(Nz,{elements:i,appState:t,files:n,actionManager:e,exportOpts:f.canvasActions.export,canvas:a,setAppState:r}):null,re=()=>!f.canvasActions.saveAsImage||t.openDialog?.name!==`imageExport`?null:(0,V.jsx)(kz,{elements:i,appState:t,files:n,actionManager:e,onExportImage:p,onCloseRequest:()=>r({openDialog:null}),name:g.getName()}),ie=()=>(0,V.jsxs)(`div`,{style:{position:`relative`},children:[(0,V.jsxs)(`div`,{className:`excalidraw-ui-top-left`,children:[l?.(!1,t),(0,V.jsx)(E.MainMenuTunnel.Out,{})]}),m&&(0,V.jsx)(E.WelcomeScreenMenuHintTunnel.Out,{})]}),ae=()=>(0,V.jsx)(jF,{heading:`selectedShapeActions`,className:H(`selected-shape-actions zen-mode-transition`,{"transition-left":t.zenModeEnabled}),children:T?(0,V.jsx)(PC,{className:H(`compact-shape-actions-island`),padding:0,"data-viewport-ui":`side`,"data-viewport-ui-name":`stylesPanel`,style:{maxHeight:`${t.height-166}px`},children:(0,V.jsx)(dA,{appState:t,elementsMap:g.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:g,setAppState:r})}):(0,V.jsx)(PC,{className:D.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${t.height-166}px`},"data-viewport-ui":`side`,"data-viewport-ui-name":`stylesPanel`,children:(0,V.jsx)(aA,{appState:t,elementsMap:g.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:g})})}),oe=()=>{let n=_&&Rt(t,i),a=_&&t.stats.open&&!t.zenModeEnabled&&!t.viewModeEnabled&&t.openDialog?.name!==`elementLinkSelector`;return(0,V.jsx)(wF,{side:`top`,children:(0,V.jsxs)(`div`,{className:`App-menu App-menu_top`,children:[(0,V.jsxs)(ik.Col,{gap:O.menuTopGap,className:H(`App-menu_top__left`),children:[ie(),_&&(0,V.jsx)(`div`,{className:H(`selected-shape-actions-container`,{"selected-shape-actions-container--compact":T}),children:n&&ae()}),_&&T&&!t.viewModeEnabled&&n&&(0,V.jsx)(TF,{checked:t.penMode,onChange:()=>s(null),title:W(`toolBar.penMode`),isMobile:!0,penDetected:t.penDetected})]}),_&&!t.viewModeEnabled&&t.openDialog?.name!==`elementLinkSelector`&&(0,V.jsx)(jF,{heading:`shapes`,className:`shapes-section`,children:e=>(0,V.jsxs)(`div`,{style:{position:`relative`},children:[m&&(0,V.jsx)(E.WelcomeScreenToolbarHintTunnel.Out,{}),(0,V.jsx)(ik.Col,{gap:O.toolbarColGap,align:`start`,children:(0,V.jsxs)(ik.Row,{gap:O.toolbarRowGap,className:H(`App-toolbar-container`,{"zen-mode":t.zenModeEnabled}),children:[(0,V.jsx)(Bz,{app:g,appState:t,setAppState:r,UIOptions:f,onPenModeToggle:s,onLockToggle:o,heading:e}),b&&(0,V.jsx)(PC,{style:{marginLeft:O.collabMarginLeft,alignSelf:`center`,height:`fit-content`},children:(0,V.jsx)(Pz,{title:W(`toolBar.laser`),checked:t.activeTool.type===Ks.laser,onChange:()=>g.setActiveTool({type:Ks.laser}),isMobile:!0})})]})})]})}),(0,V.jsxs)(`div`,{className:H(`layer-ui__wrapper__top-right zen-mode-transition`,{"transition-right":t.zenModeEnabled,"layer-ui__wrapper__top-right--compact":T}),children:[_&&t.collaborators.size>0&&(0,V.jsx)(zF,{collaborators:t.collaborators,userToFollow:w.userToFollow?.socketId||null,currentUserControls:S}),u?.(C.formFactor===`phone`,t),!t.viewModeEnabled&&t.openDialog?.name!==`elementLinkSelector`&&(!ce||t.openSidebar?.name!==bo.name)&&(0,V.jsx)(E.DefaultSidebarTriggerTunnel.Out,{}),a&&(0,V.jsx)(uz,{app:g,onClose:()=>{e.executeAction(iD)},renderCustomStats:d})]})]})})},se=()=>_?(0,V.jsx)(qI,{__fallback:!0,onDock:e=>{xC(`sidebar`,`toggleDock (${e?`dock`:`undock`})`,`(${C.formFactor===`phone`?`mobile`:`desktop`})`)}}):null,ce=Ey(XF),le=!!(t.openSidebar&&ce&&C.canFitSidebar),ue=(0,V.jsxs)(V.Fragment,{children:[h,_&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(Vz,{UIOptions:f}),(0,V.jsx)(qI.Trigger,{__fallback:!0,icon:iC,title:lo(W(`toolBar.library`)),onToggle:e=>{e&&xC(`sidebar`,`${bo.name} (open)`,`button (${C.formFactor===`phone`?`mobile`:`desktop`})`)},tab:bo.defaultTab})]}),(0,V.jsx)(Hz,{}),t.openDialog?.name===`ttd`&&(0,V.jsx)(vR,{__fallback:!0}),_&&t.isLoading&&(0,V.jsx)(SF,{delay:250}),_&&t.errorMessage&&(0,V.jsx)(hz,{onClose:()=>r({errorMessage:null}),children:t.errorMessage}),_&&k&&C.formFactor!==`phone`&&(0,V.jsx)(NC,{colorPickerType:k.colorPickerType,onCancel:()=>{te(null)},onChange:(e,t,n,{altKey:a})=>{if(e===`elementBackground`||e===`elementStroke`){if(n.length){for(let r of n)ir(r,ui(i),{[a&&k.swapPreviewOnAlt?e===`elementBackground`?`strokeColor`:`backgroundColor`:e===`elementBackground`?`backgroundColor`:`strokeColor`]:t}),fr.delete(r);g.scene.triggerUpdate()}else r(e===`elementBackground`?{currentItemBackgroundColor:t}:{currentItemStrokeColor:t})}},onSelect:(e,t)=>{te(e=>e?.keepOpenOnAlt&&t.altKey?e:null),k?.onSelect?.(e,t)}}),t.openDialog?.name===`help`&&(0,V.jsx)(Sz,{onClose:()=>{r({openDialog:null})}}),(0,V.jsx)(yA,{}),_&&t.openDialog?.name===`elementLinkSelector`&&(0,V.jsx)(mz,{sourceElementId:t.openDialog.sourceElementId,onClose:()=>{r({openDialog:null})},scene:g.scene,appState:t,generateLinkForSelection:x}),(0,V.jsx)(E.OverwriteConfirmDialogTunnel.Out,{}),re(),ne(),_&&t.openDialog?.name===`charts`&&(0,V.jsx)(AF,{data:t.openDialog.data,rawText:t.openDialog.rawText,onClose:()=>r({openDialog:null})}),C.formFactor===`phone`&&(0,V.jsx)(EF,{app:g,appState:t,elements:i,actionManager:e,renderJSONExportDialog:ne,renderImageExportDialog:re,setAppState:r,onPenModeToggle:s,renderTopLeftUI:l,renderTopRightUI:u,renderSidebars:se,renderWelcomeScreen:m,defaultUIEnabled:_,scrollBackToContentUIEnabled:y}),C.formFactor!==`phone`&&(0,V.jsxs)(V.Fragment,{children:[w.viewportStatusFrame?.border&&(0,V.jsx)(gF,{border:w.viewportStatusFrame.border,style:le?{right:`calc(var(--right-sidebar-width) - var(--space-factor) * 2)`}:void 0}),(0,V.jsxs)(`div`,{className:`layer-ui__wrapper`,style:le?{width:`calc(100% - var(--right-sidebar-width))`}:{},children:[m&&(0,V.jsx)(E.WelcomeScreenCenterTunnel.Out,{}),oe(),(0,V.jsx)(HF,{appState:t,actionManager:e,showExitZenModeBtn:c,renderWelcomeScreen:m,defaultUIEnabled:_,zoomUIEnabled:v}),(t.toast||y&&t.scrolledOutside||w.viewportStatusFrame?.label)&&(0,V.jsxs)(`div`,{className:`floating-status-stack`,children:[t.toast&&(0,V.jsx)(HT,{message:t.toast.message,onClose:()=>r({toast:null}),duration:t.toast.duration,closable:t.toast.closable}),!t.toast&&y&&t.scrolledOutside&&(0,V.jsx)(`button`,{type:`button`,className:`scroll-back-to-content`,onClick:()=>{r(e=>({...Vt(i,e)}))},children:W(`buttons.scrollBackToContent`)}),w.viewportStatusFrame?.label&&(0,V.jsx)(_F,{label:w.viewportStatusFrame.label,border:w.viewportStatusFrame.border})]})]}),se()]})]});return(0,V.jsx)(TC.Provider,{value:t,children:(0,V.jsx)(ee,{children:(0,V.jsx)(vF.Provider,{value:E,children:ue})})})},Wz=e=>{let{cursorButton:t,scrollX:n,scrollY:r,zoom:i,shouldCacheIgnoreZoom:a,snapLines:o,originSnapOffset:s,suggestedBinding:c,frameToHighlight:l,elementsToHighlight:u,...d}=e;return d},Gz=B.memo(Uz,(e,t)=>{if(e.children!==t.children)return!1;let{canvas:n,appState:r,...i}=e,{canvas:a,appState:o,...s}=t;return S(Wz(r),Wz(o),{selectedElementIds:S,selectedGroupIds:S})&&S(i,s)}),Kz=e=>(0,V.jsx)(J,{className:H(`ToolIcon__MagicButton`,{"is-mobile":e.isMobile}),type:`toggle`,size:`small`,icon:e.icon,checked:e.checked,title:`${e.title}`,"aria-label":`${e.title}`,onSelect:()=>e.onChange?.()}),qz=({trails:e})=>{let t=(0,B.useRef)(null);return(0,B.useEffect)(()=>{if(t.current)for(let n of e)n.start(t.current);return()=>{for(let t of e)t.stop()}},e),(0,V.jsx)(`div`,{className:`SVGLayer`,children:(0,V.jsx)(`svg`,{ref:t})})},Jz=`#ff6b6b`,Yz=`#ff0000`,Xz=1,Zz=2,Qz=(e,t)=>{if(!t.snapLines.length)return;let n=t.theme===A.LIGHT||t.zenModeEnabled?Jz:Yz,r=(t.zenModeEnabled?Xz*1.5:Xz)/t.zoom.value;e.save(),e.translate(t.scrollX,t.scrollY);for(let i of t.snapLines)i.type===`pointer`?(e.lineWidth=r,e.strokeStyle=n,eB(i,e,t)):i.type===`gap`?(e.lineWidth=r,e.strokeStyle=n,rB(i.points[0],i.points[1],i.direction,t,e)):i.type===`points`&&(e.lineWidth=r,e.strokeStyle=n,$z(i,e,t));e.restore()},$z=(e,t,n)=>{if(!n.zenModeEnabled){let n=e.points[0],r=e.points[e.points.length-1];nB(n,r,t)}for(let r of e.points)tB(r,n,t)},eB=(e,t,n)=>{tB(e.points[0],n,t),n.zenModeEnabled||nB(e.points[0],e.points[1],t)},tB=([e,t],n,r)=>{r.save();let i=(n.zenModeEnabled?Zz*1.5:Zz)/n.zoom.value;r.beginPath(),r.moveTo(e-i,t-i),r.lineTo(e+i,t+i),r.moveTo(e+i,t-i),r.lineTo(e-i,t+i),r.stroke(),r.restore()},nB=(e,t,n)=>{n.beginPath(),n.lineTo(e[0],e[1]),n.lineTo(t[0],t[1]),n.stroke()},rB=(e,t,n,r,i)=>{let a=8/r.zoom.value,o=a/2,s=a/4;if(n===`horizontal`){let n=[(e[0]+t[0])/2,e[1]];r.zenModeEnabled||nB(L(e[0],e[1]-a),L(e[0],e[1]+a),i),nB(L(n[0]-s,n[1]-o),L(n[0]-s,n[1]+o),i),nB(L(n[0]+s,n[1]-o),L(n[0]+s,n[1]+o),i),r.zenModeEnabled||(nB(L(t[0],t[1]-a),L(t[0],t[1]+a),i),nB(e,t,i))}else{let n=[e[0],(e[1]+t[1])/2];r.zenModeEnabled||nB(L(e[0]-a,e[1]),L(e[0]+a,e[1]),i),nB(L(n[0]-o,n[1]-s),L(n[0]+o,n[1]-s),i),nB(L(n[0]-o,n[1]+s),L(n[0]+o,n[1]+s),i),r.zenModeEnabled||(nB(L(t[0]-a,t[1]),L(t[0]+a,t[1]),i),nB(e,t,i))}},iB=(e,t)=>{qa(t.selectedLinearElement,`selectedLinearElement is null`);let{segmentMidPointHoveredCoords:n}=t.selectedLinearElement;qa(n,`midPointCoords is null`),oB(n,e,t)},aB=(e,t,n)=>{let{elementId:r,hoverPointIndex:i}=t.selectedLinearElement;if(t.selectedLinearElement?.isEditing&&t.selectedLinearElement?.selectedPointsIndices?.includes(i)||t.selectedLinearElement?.isDragging)return;let a=N.getElement(r,n);a&&oB(N.getPointAtIndexGlobalCoordinates(a,i,n),e,t)},oB=(e,t,n)=>{t.save(),t.translate(n.scrollX,n.scrollY),t.fillStyle=`rgba(105, 101, 219, 0.4)`,b(t,e[0],e[1],N.POINT_HANDLE_SIZE/n.zoom.value,!1),t.restore()},sB=(e,t,n)=>{let{elementId:r,anchor:i}=t.hoveredArrowTextAnchor,a=n.get(r);!a||!_(a)||a.isDeleted||oB(i===`label`?N.getBoundTextElementCenter(a,n):N.getPointAtIndexGlobalCoordinates(a,i===`start`?0:-1,n),e,t)},cB=(e,t,n,r,i,a,o)=>{e.strokeStyle=`#5e5ad8`,e.setLineDash([]),e.fillStyle=`rgba(255, 255, 255, 0.9)`,i?e.fillStyle=`rgba(134, 131, 226, 0.9)`:a&&(e.fillStyle=`rgba(177, 151, 252, 0.7)`),b(e,n[0],n[1],(o?r*(t.selectedLinearElement?.isEditing?1.5:2):r)/t.zoom.value,!a,!o||i)},lB=(e,t,n,r,i,a=!1)=>{let o=t.element.frameId&&n.get(t.element.frameId);switch(o&&P(o)&&(e.translate(o.x,o.y),e.beginPath(),Wr.radius&&e.roundRect?e.roundRect(-1,-1,o.width+1,o.height+1,Wr.radius/r.zoom.value):e.rect(-1,-1,o.width+1,o.height+1),e.clip(),e.translate(-o.x,-o.y)),t.element.type){case`magicframe`:case`frame`:e.save(),e.translate(t.element.x,t.element.y),e.lineWidth=Wr.strokeWidth/r.zoom.value,e.strokeStyle=r.theme===A.DARK?`rgba(3, 93, 161, 1)`:`rgba(106, 189, 252, 1)`,Wr.radius&&e.roundRect?(e.beginPath(),e.roundRect(0,0,t.element.width,t.element.height,Wr.radius/r.zoom.value),e.stroke(),e.closePath()):e.strokeRect(0,0,t.element.width,t.element.height),e.restore();break;default:e.save();let i=ga(t.element,n);switch(e.translate(i[0],i[1]),e.rotate(t.element.angle),e.translate(-i[0],-i[1]),e.translate(t.element.x,t.element.y),e.lineWidth=ss(1.75,t.element.strokeWidth,4)/Math.max(.25,r.zoom.value),e.strokeStyle=r.theme===A.DARK?`rgba(3, 93, 161, 1)`:`rgba(106, 189, 252, 1)`,t.element.type){case`ellipse`:e.beginPath(),e.ellipse(t.element.width/2,t.element.height/2,t.element.width/2,t.element.height/2,0,0,2*Math.PI),e.closePath(),e.stroke();break;case`diamond`:{let[n,r]=er(t.element);n.forEach(n=>{e.beginPath(),e.moveTo(n[0][0]-t.element.x,n[0][1]-t.element.y),e.lineTo(n[1][0]-t.element.x,n[1][1]-t.element.y),e.stroke()}),r.forEach(n=>{let[r,i,a,o]=n;e.beginPath(),e.moveTo(r[0]-t.element.x,r[1]-t.element.y),e.bezierCurveTo(i[0]-t.element.x,i[1]-t.element.y,a[0]-t.element.x,a[1]-t.element.y,o[0]-t.element.x,o[1]-t.element.y),e.stroke()})}break;default:{let[n,r]=st(t.element);n.forEach(n=>{e.beginPath(),e.moveTo(n[0][0]-t.element.x,n[0][1]-t.element.y),e.lineTo(n[1][0]-t.element.x,n[1][1]-t.element.y),e.stroke()}),r.forEach(n=>{let[r,i,a,o]=n;e.beginPath(),e.moveTo(r[0]-t.element.x,r[1]-t.element.y),e.bezierCurveTo(i[0]-t.element.x,i[1]-t.element.y,a[0]-t.element.x,a[1]-t.element.y,o[0]-t.element.x,o[1]-t.element.y),e.stroke()})}}e.restore()}if(r.isMidpointSnappingEnabled&&!r.gridModeEnabled&&!a&&(P(t.element)||Tt(t.element))){let a=r.selectedLinearElement,o=a?.elementId&&N.getElement(a?.elementId,n),s=i&&u({point:i,element:t.element,elementsMap:n,threshold:0,overrideShouldTestInside:!0}),c=o&&ve(o)||r.activeTool.type===`arrow`&&r.currentItemArrowType===`elbow`;if(!s||c){e.save();let a=ga(t.element,n),o;if(t.element.type===`diamond`){let e=ga(t.element,n);o=h(t.element).map(n=>{let r=_s(n,.5),i=Fs(r,e,t.element.angle);return L(i[0],i[1])})}else o=[{x:t.element.width,y:t.element.height/2},{x:t.element.width/2,y:t.element.height},{x:0,y:t.element.height/2},{x:t.element.width/2,y:0}].map(e=>{let n=L(e.x+t.element.x,e.y+t.element.y),r=Fs(n,a,t.element.angle);return L(r[0],r[1])});let l=i&&o.reduce((e,t,n)=>{let r=ya(t,i);return n===-1||r<e.distance?{idx:n,distance:r}:e},{idx:-1,distance:1/0}),u=4/r.zoom.value,d=jn(r.zoom)+t.element.strokeWidth/2;o.forEach((t,n)=>{let i=(!s||c)&&l?.idx===n&&l.distance<=d,a=!i&&(c||n===l?.idx&&l.distance<=d*2);i?(e.fillStyle=r.theme===A.DARK?`rgba(3, 93, 161, 1)`:`rgba(106, 189, 252, 1)`,e.beginPath(),e.arc(t[0],t[1],u,0,2*Math.PI),e.fill()):a&&(e.fillStyle=r.theme===A.DARK?`rgba(0, 0, 0, 0.8)`:`rgba(65, 65, 65, 0.5)`,e.beginPath(),e.arc(t[0],t[1],u,0,2*Math.PI),e.fill())}),e.restore()}}},uB=(e,t,n,r,i,a,o)=>{let s=e.state.bindMode===`orbit`&&e.bindModeHandler!==null,c=700-(o?.runtime??(s?0:700)),l=ss(1/700*c,1e-4,1),u=n.strokeWidth/2,d=n.frameId&&r.get(n.frameId);switch(d&&P(d)&&(t.translate(d.x,d.y),t.beginPath(),Wr.radius&&t.roundRect?t.roundRect(-1,-1,d.width+1,d.height+1,Wr.radius/i.zoom.value):t.rect(-1,-1,d.width+1,d.height+1),t.clip(),t.translate(-d.x,-d.y)),n.type){case`magicframe`:case`frame`:t.save(),t.translate(n.x,n.y),t.lineWidth=Wr.strokeWidth/i.zoom.value,t.strokeStyle=i.theme===A.DARK?`rgba(3, 93, 161, ${l})`:`rgba(106, 189, 252, ${l})`,Wr.radius&&t.roundRect?(t.beginPath(),t.roundRect(0,0,n.width,n.height,Wr.radius/i.zoom.value),t.stroke(),t.closePath()):t.strokeRect(0,0,n.width,n.height),t.restore();break;default:t.save();let e=ga(n,r),a=e[0]+i.scrollX,o=e[1]+i.scrollY;switch(t.translate(a,o),t.rotate(n.angle),t.translate(-a,-o),t.translate(n.x+i.scrollX-u,n.y+i.scrollY-u),t.lineWidth=ss(2.5,n.strokeWidth*1.75,4)/Math.max(.25,i.zoom.value),t.strokeStyle=i.theme===A.DARK?`rgba(3, 93, 161, ${l/2})`:`rgba(106, 189, 252, ${l/2})`,n.type){case`ellipse`:t.beginPath(),t.ellipse((n.width+u*2)/2,(n.height+u*2)/2,(n.width+u*2)/2,(n.height+u*2)/2,0,0,2*Math.PI),t.closePath(),t.stroke();break;case`diamond`:{let[e,r]=er(n,u);e.forEach(e=>{t.beginPath(),t.moveTo(e[0][0]-n.x+u,e[0][1]-n.y+u),t.lineTo(e[1][0]-n.x+u,e[1][1]-n.y+u),t.stroke()}),r.forEach(e=>{let[r,i,a,o]=e;t.beginPath(),t.moveTo(r[0]-n.x+u,r[1]-n.y+u),t.bezierCurveTo(i[0]-n.x+u,i[1]-n.y+u,a[0]-n.x+u,a[1]-n.y+u,o[0]-n.x+u,o[1]-n.y+u),t.stroke()})}break;default:{let[e,r]=st(n,u);e.forEach(e=>{t.beginPath(),t.moveTo(e[0][0]-n.x+u,e[0][1]-n.y+u),t.lineTo(e[1][0]-n.x+u,e[1][1]-n.y+u),t.stroke()}),r.forEach(e=>{let[r,i,a,o]=e;t.beginPath(),t.moveTo(r[0]-n.x+u,r[1]-n.y+u),t.bezierCurveTo(i[0]-n.x+u,i[1]-n.y+u,a[0]-n.x+u,a[1]-n.y+u,o[0]-n.x+u,o[1]-n.y+u),t.stroke()})}}t.restore()}if(!s||(o?.runtime??0)>700)return;let f=.5*(Math.min(n.width,n.height)/2);if(!P(n)){t.save(),t.translate(n.x+i.scrollX,n.y+i.scrollY);let a=1/700*c;if(t.strokeStyle=`rgba(0, 0, 0, 0.2)`,t.lineWidth=1/i.zoom.value,t.setLineDash([4/i.zoom.value,4/i.zoom.value]),t.lineDashOffset=-a*10/i.zoom.value,t.beginPath(),t.ellipse(n.width/2,n.height/2,f,f,0,0,2*Math.PI),t.stroke(),t.fillStyle=`rgba(0, 0, 0, 0.04)`,t.beginPath(),t.ellipse(n.width/2,n.height/2,f*(1-l),f*(1-l),0,0,2*Math.PI),t.fill(),t.restore(),i.isMidpointSnappingEnabled&&!i.gridModeEnabled&&(!e.lastPointerMoveEvent||!Be(e.lastPointerMoveEvent))){t.save(),t.translate(n.x+i.scrollX,n.y+i.scrollY);let e=5/i.zoom.value,a=e+5/i.zoom.value,o;if(n.type===`diamond`){let[,e]=er(n),t=ga(n,r);o=e.map(e=>{let r=_s(e,.5),i=Fs(r,t,n.angle);return{x:i[0]-n.x,y:i[1]-n.y}})}else{let e=ga(n,r);o=[{x:n.width/2,y:0},{x:n.width,y:n.height/2},{x:n.width/2,y:n.height},{x:0,y:n.height/2}].map(t=>{let r=L(t.x+n.x,t.y+n.y),i=Fs(r,e,n.angle);return{x:i[0]-n.x,y:i[1]-n.y}})}o.forEach(e=>{t.clearRect(e.x-a,e.y-a,a*2,a*2)}),t.fillStyle=i.theme===A.DARK?`rgba(3, 93, 161, ${l})`:`rgba(106, 189, 252, ${l})`,o.forEach(n=>{t.beginPath(),t.arc(n.x,n.y,e,0,2*Math.PI),t.fill()}),t.restore()}}return{runtime:(o?.runtime??0)+a}},dB=(e,t,n,r,i,a,o)=>{if(n!==null){if(pe(`COMPLEX_BINDINGS`))return uB(e,t,n.element,r,i,a,o);t.save(),t.translate(i.scrollX,i.scrollY),lB(t,n,r,i,e.lastPointerMoveCoords?L(e.lastPointerMoveCoords.x,e.lastPointerMoveCoords.y):null,!!e.lastPointerMoveEvent&&Be(e.lastPointerMoveEvent)),t.restore()}},fB=(e,t,n)=>{let{angle:r,x1:i,y1:a,x2:o,y2:s,selectionColors:c,cx:l,cy:u,dashed:d,activeEmbeddable:f}=n,p=o-i,m=s-a,h=(n.padding??4)/t.zoom.value,g=8/t.zoom.value,_=4/t.zoom.value;e.save(),e.translate(t.scrollX,t.scrollY),e.lineWidth=(f?4:1)/t.zoom.value;let v=c.length;for(let t=0;t<v;++t)e.strokeStyle=c[t],d&&e.setLineDash([g,_+(g+_)*(v-1)]),e.lineDashOffset=(g+_)*t,Yi(e,i-h,a-h,p+h*2,m+h*2,l,u,r);e.restore()},pB=(e,t,n,r)=>{let[i,a,o,s]=kc(n,r),c=o-i,l=s-a;e.strokeStyle=`rgb(0,118,255)`,e.lineWidth=Wr.strokeWidth/t.zoom.value,e.save(),e.translate(t.scrollX,t.scrollY),Yi(e,i,a,c,l,i+c/2,a+l/2,n.angle,!1,Wr.radius/t.zoom.value),e.restore()},mB=(e,t,n,r)=>{let{colors:i=[`rgb(0,118,255)`],dashed:a=!1}=r||{},o=n.filter(e=>e.groupIds.length===0),s=n.filter(e=>e.groupIds.length>0),c=e=>{let[t,n,r,o]=Is(e);return{angle:0,x1:t,x2:r,y1:n,y2:o,selectionColors:i,dashed:a,cx:t+(r-t)/2,cy:n+(o-n)/2,activeEmbeddable:!1}},l=e=>{let t=yt(n,e);return c(t)};Object.entries(rt(s,t)).filter(([e,t])=>t).map(([e,t])=>e).map(e=>l(e)).concat(o.map(e=>c([e]))).forEach(n=>fB(e,t,n))},hB=(e,t,n,r)=>{if(!t.selectedLinearElement)return;e.save(),e.translate(t.scrollX,t.scrollY),e.lineWidth=1/t.zoom.value;let i=N.getPointsGlobalCoordinates(n,r),{POINT_HANDLE_SIZE:a}=N,o=t.selectedLinearElement?.isEditing?a:a/2,s=ve(n),c=Oe(n);if(i.forEach((r,a)=>{if(s&&a!==0&&a!==i.length-1)return;let l=a>0&&(a!==i.length-1||!c||!n.polygon)&&Wi(r,a===i.length-1?i[0]:i[a-1],2/t.zoom.value),u=!!t.selectedLinearElement?.isEditing&&!!t.selectedLinearElement?.selectedPointsIndices?.includes(a);c&&n.polygon&&!u&&a===n.points.length-1&&t.selectedLinearElement?.isEditing&&t.selectedLinearElement?.selectedPointsIndices?.includes(0)&&(u=!0),cB(e,t,r,o,u,!1,l)}),ve(n)){let o=n.fixedSegments?.map(e=>e.index)||[];i.slice(0,-1).forEach((s,c)=>{N.isSegmentTooShort(n,i[c+1],i[c],c,t.zoom,r)||cB(e,t,L((s[0]+i[c+1][0])/2,(s[1]+i[c+1][1])/2),a/2,!1,!o.includes(c+1),!1)})}else N.getEditorMidPoints(n,r,t).filter((e,t,r)=>e!==null&&!(ve(n)&&(t===0||t===r.length-1))).forEach(n=>{(t.selectedLinearElement?.isEditing||i.length===2)&&cB(e,t,n,a/2,!1,!0,!1)});e.restore()},gB=(e,t,n,r)=>{e.save(),e.translate(t.scrollX,t.scrollY),e.strokeStyle=`rgba(134, 131, 226, 0.6)`,e.lineWidth=1/t.zoom.value,e.setLineDash([4/t.zoom.value,4/t.zoom.value]),e.beginPath(),e.moveTo(n[0],n[1]),e.lineTo(r[0],r[1]),e.stroke(),e.restore()},_B=(e,t,n,r,i)=>{e.save(),e.translate(t.scrollX,t.scrollY),e.strokeStyle=`rgba(134, 131, 226, 0.6)`,e.lineWidth=1/t.zoom.value,e.setLineDash([]),e.fillStyle=i?`rgba(134, 131, 226, 0.9)`:`rgba(255, 255, 255, 0.9)`,b(e,n[0],n[1],r/t.zoom.value,!0,!0),e.restore()},vB=({arrow:e,appState:t,type:n,context:r,elementsMap:i})=>{let a=n===`start`?e.startBinding:e.endBinding,o=a?.elementId&&i.get(a.elementId);if(!o||!Tt(o)||o.isDeleted)return;let s=Gr(a.fixedPoint,o,i);if(!Oi(s,e,o,i,t,n))return;let c=t.selectedLinearElement,l=!!c?.isDragging,u=n===`start`?0:e.points.length-1,d=!!c?.selectedPointsIndices?.includes(u);if(c?.hoveredFocusPointBinding===n&&!c.draggedFocusPointBinding&&oB(s,r,t),!(d&&l)){let s=Gr(a.fixedPoint,o,i),l=c?.hoveredFocusPointBinding===n;gB(r,t,N.getPointAtIndexGlobalCoordinates(e,u,i),s),_B(r,t,s,Zo/1.5,l)}},yB=(e,t,n,r,i)=>{Object.keys(r).forEach(a=>{let o=r[a];if(o!==void 0){let[r,s,c,l]=o;e.save(),e.lineWidth=1/n.zoom.value,t.selectionColor&&(e.strokeStyle=t.selectionColor),a===`rotation`?b(e,r+c/2,s+l/2,c/2,!0):e.roundRect?(e.beginPath(),e.roundRect(r,s,c,l,2/n.zoom.value),e.fill(),e.stroke()):Yi(e,r,s,c,l,r+c/2,s+l/2,i,!0),e.restore()}})},bB=(e,t,n,r,i)=>{let[a,o,,,s,c]=kc(r,i),l=3/n.zoom.value,u=l/2,d=s-a+l,f=c-o+l,p=Math.min(20/n.zoom.value,d),m=Math.min(20/n.zoom.value,f);e.save(),e.fillStyle=t.selectionColor,e.strokeStyle=t.selectionColor,e.lineWidth=l,[[[-d,-f],[0,u],[p,u],[u,0],[u,m]],[[d-u,-f],[u,u],[-p+u,u],[0,0],[0,m]],[[-d,f],[0,-u],[p,-u],[u,0],[u,-m]],[[d-u,f],[u,-u],[-p+u,-u],[0,0],[0,-m]]].forEach(t=>{let[[n,i],[a,o],[l,u],[d,f],[p,m]]=t;e.save(),e.translate(s,c),e.rotate(r.angle),e.beginPath(),e.moveTo(n+a,i+o),e.lineTo(n+l,i+u),e.stroke(),e.beginPath(),e.moveTo(n+d,i+f),e.lineTo(n+p,i+m),e.stroke(),e.restore()}),e.restore()},xB=(e,t,n,r)=>{t.save();let i=oN(n.zoom.value),a=e.width+i*2,o=e.height+i*2,s=e.x+e.width/2,c=e.y+e.height/2,l=-(e.width/2+i),u=-(e.height/2+i);t.translate(s+n.scrollX,c+n.scrollY),t.rotate(e.angle),t.lineWidth=1/n.zoom.value,t.strokeStyle=r,t.globalAlpha=.5,t.setLineDash([6/n.zoom.value,4/n.zoom.value]),t.strokeRect(l,u,a,o),t.restore()},SB=(e,t,n,r,i)=>{let a=sN(e,n.zoom.value,i);a&&(t.save(),t.globalAlpha=.5,t.lineWidth=1.5/n.zoom.value,t.lineCap=`round`,t.strokeStyle=r,t.beginPath(),t.moveTo(a.start[0]+n.scrollX,a.start[1]+n.scrollY),t.lineTo(a.end[0]+n.scrollX,a.end[1]+n.scrollY),t.stroke(),t.restore())},CB=({app:e,canvas:t,elementsMap:n,visibleElements:r,selectedElements:i,allElementsMap:o,scale:s,appState:c,renderConfig:l,editorInterface:u,animationState:d,deltaTime:f})=>{if(t===null)return{};let[p,m]=ot(t,s),h=d,g=ar({canvas:t,scale:s,normalizedWidth:p,normalizedHeight:m});g.save(),g.scale(c.zoom.value,c.zoom.value);let v;if(r.forEach(e=>{c.selectedLinearElement?.isEditing&&c.selectedLinearElement.elementId===e.id&&e&&(v=e)}),v&&hB(g,c,v,n),c.selectionElement&&!c.isCropping)try{ia(c.selectionElement,g,c,l.selectionColor)}catch(e){console.error(e)}let y=ba(i,c);if(y&&!y.autoResize&&SB(y,g,c,l.selectionColor,u.formFactor),c.editingTextElement){let e=o.get(c.editingTextElement.id);e&&!e.autoResize&&xB(e,g,c,l.selectionColor)}if(h=c.isBindingEnabled&&c.suggestedBinding?{...d,bindingHighlight:dB(e,g,c.suggestedBinding,o,c,f,d?.bindingHighlight)}:{...d,bindingHighlight:void 0},c.hoveredArrowTextAnchor&&sB(g,c,o),c.frameToHighlight&&pB(g,c,c.frameToHighlight,n),c.elementsToHighlight&&mB(g,c,c.elementsToHighlight),c.activeLockedId){let e=o.get(c.activeLockedId);mB(g,c,e?[e]:yt(o,c.activeLockedId),{colors:[`#ced4da`],dashed:!0})}let b=i.some(e=>P(e));i.length===1&&c.selectedLinearElement?.isEditing&&c.selectedLinearElement.elementId===i[0].id&&hB(g,c,i[0],n);let x=c.selectedLinearElement,S=x&&N.getElement(x.elementId,o);if(S&&(c.selectedLinearElement.isDragging||(x.segmentMidPointHoveredCoords?iB(g,c):(ve(S)?x.hoverPointIndex===0||x.hoverPointIndex===S.points.length-1:x.hoverPointIndex>=0)&&aB(g,c,n)),_(S)&&(vB({arrow:S,elementsMap:o,appState:c,context:g,type:`start`}),vB({arrow:S,elementsMap:o,appState:c,context:g,type:`end`}))),!c.multiElement&&!c.newElement&&!c.selectedLinearElement?.isEditing){let e=lc(i,c,u),t=i.length===1&&po(i[0]);t&&c.selectedLinearElement?.elementId===i[0].id&&!i[0].locked&&hB(g,c,i[0],n);let r=l.selectionColor||`#000`;if(e){let e=ui(i),a=[];for(let i of n.values()){let o=[],s=l.remoteSelectedElementIds.get(i.id);if(t&&ve(i)&&(i.startBinding||i.endBinding)||(e.has(i.id)&&!$s(c,i)&&o.push(r),s&&o.push(...s.map(e=>PE(e,c.collaborators.get(e))))),o.length){let[e,t,r,l,u,d]=kc(i,n,!0);a.push({angle:i.angle,x1:e,y1:t,x2:r,y2:l,selectionColors:i.locked?[`#ced4da`]:o,dashed:!!s||i.locked,cx:u,cy:d,activeEmbeddable:c.activeEmbeddable?.element===i&&c.activeEmbeddable.state===`active`,padding:i.id===c.croppingElementId||De(i)?0:void 0})}}let o=e=>{let t=yt(n,e),[r,i,o,s]=Is(t);a.push({angle:0,x1:r,x2:o,y1:i,y2:s,selectionColors:t.some(e=>e.locked)?[`#ced4da`]:[`#000`],dashed:!0,cx:r+(o-r)/2,cy:i+(s-i)/2,activeEmbeddable:!1})};for(let e of Vi(c))o(e);c.editingGroupId&&o(c.editingGroupId),a.forEach(e=>fB(g,c,e))}if(g.save(),g.translate(c.scrollX,c.scrollY),i.length===1){g.fillStyle=`#fff`;let t=kn(i[0],c.zoom,n,`mouse`,cn(u));if(!c.viewModeEnabled&&e&&!a(c.editingTextElement)&&!c.croppingElementId&&yB(g,l,c,t,i[0].angle),c.croppingElementId&&!c.isCropping){let e=n.get(c.croppingElementId);e&&De(e)&&bB(g,l,c,e,n)}}else if(i.length>1&&!c.isRotating&&!i.some(e=>e.locked)){let e=4/c.zoom.value;g.fillStyle=`#fff`;let[t,a,o,s]=Is(i,n),d=g.getLineDash();g.setLineDash([2/c.zoom.value]);let f=g.lineWidth;g.lineWidth=1/c.zoom.value,g.strokeStyle=r,Yi(g,t-e,a-e,o-t+e*2,s-a+e*2,(t+o)/2,(a+s)/2,0),g.lineWidth=f,g.setLineDash(d);let p=ln([t,a,o,s,(t+o)/2,(a+s)/2],0,c.zoom,`mouse`,b?{...cn(u),rotation:!0}:cn(u));i.some(e=>!e.locked)&&yB(g,l,c,p,0)}g.restore()}c.searchMatches?.matches.forEach(({id:e,focus:t,matchedLines:r})=>{let i=n.get(e);if(i){let[e,a,,,o,s]=kc(i,n,!0);g.save(),c.theme===A.LIGHT?t?g.fillStyle=`rgba(255, 124, 0, 0.4)`:g.fillStyle=`rgba(255, 226, 0, 0.4)`:t?g.fillStyle=`rgba(229, 82, 0, 0.4)`:g.fillStyle=`rgba(99, 52, 0, 0.4)`;let l=P(i)?c.zoom.value:1;g.translate(c.scrollX,c.scrollY),g.translate(o,s),g.rotate(i.angle),r.forEach(n=>{(n.showOnCanvas||t)&&g.fillRect(e+n.offsetX/l-o,a+n.offsetY/l-s,n.width/l,n.height/l)}),g.restore()}}),Qz(g,c),g.restore(),IE({context:g,renderConfig:l,appState:c,normalizedWidth:p,normalizedHeight:m});let C;return l.renderScrollbars&&(C=_N(n,p,m,c),g.save(),g.fillStyle=gN,g.strokeStyle=`rgba(255,255,255,0.8)`,[C.horizontal,C.vertical].forEach(e=>{e&&ME(g,e.x,e.y,e.width,e.height,hN/2)}),g.restore()),{scrollBars:C,animationState:h}},wB=e=>{let t=CB(e);return e.callback(t),t},TB=`animateInteractiveScene`,EB=e=>{let t=(0,B.useRef)(!1),n=(0,B.useRef)(null);return(0,B.useEffect)(()=>{if(!t.current){t.current=!0;return}let r=new Map,i=new Map,a=new Map,o=new Map,s=new Map;e.appState.collaborators.forEach((t,n)=>{if(t.selectedElementIds)for(let e of Object.keys(t.selectedElementIds))a.has(e)||a.set(e,[]),a.get(e).push(n);!t.pointer||t.pointer.renderCursor===!1||(t.username&&o.set(n,t.username),t.userState&&s.set(n,t.userState),i.set(n,Tn({sceneX:t.pointer.x,sceneY:t.pointer.y},e.appState)),r.set(n,t.button))});let c=e.containerRef?.current&&getComputedStyle(e.containerRef.current).getPropertyValue(`--color-selection`)||`#6965db`;n.current={app:e.app,canvas:e.canvas,elementsMap:e.elementsMap,visibleElements:e.visibleElements,selectedElements:e.selectedElements,allElementsMap:e.allElementsMap,scale:window.devicePixelRatio,appState:e.appState,renderConfig:{remotePointerViewportCoords:i,remotePointerButton:r,remoteSelectedElementIds:a,remotePointerUsernames:o,remotePointerUserStates:s,selectionColor:c,renderScrollbars:e.renderScrollbars,lastViewportPosition:e.app.viewport.lastPosition},editorInterface:e.editorInterface,callback:e.renderInteractiveSceneCallback,animationState:{bindingHighlight:void 0},deltaTime:0},ZM.running(TB)||ZM.start(TB,({deltaTime:e,state:t})=>{let r=wB({...n.current,deltaTime:e,animationState:t}).animationState;if(r){for(let e in r)if(r[e]!==void 0)return r}})}),(0,V.jsx)(`canvas`,{className:`excalidraw__canvas interactive`,style:{width:e.appState.width,height:e.appState.height},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:e.handleCanvasRef,onContextMenu:e.onContextMenu,onClick:e.onClick,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onPointerCancel:e.onPointerCancel,onTouchMove:e.onTouchMove,onPointerDown:e.onPointerDown,onDoubleClick:e.appState.viewModeEnabled?void 0:e.onDoubleClick,children:W(`labels.drawingCanvas`)})},DB=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,activeTool:e.activeTool,openDialog:e.openDialog,editingGroupId:e.editingGroupId,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,selectionElement:e.selectionElement,selectedGroupIds:e.selectedGroupIds,selectedLinearElement:e.selectedLinearElement,multiElement:e.multiElement,newElement:e.newElement,isBindingEnabled:e.isBindingEnabled,isMidpointSnappingEnabled:e.isMidpointSnappingEnabled,gridModeEnabled:e.gridModeEnabled,suggestedBinding:e.suggestedBinding,hoveredArrowTextAnchor:e.hoveredArrowTextAnchor,isRotating:e.isRotating,elementsToHighlight:e.elementsToHighlight,collaborators:e.collaborators,activeEmbeddable:e.activeEmbeddable,snapLines:e.snapLines,zenModeEnabled:e.zenModeEnabled,editingTextElement:e.editingTextElement,isCropping:e.isCropping,croppingElementId:e.croppingElementId,searchMatches:e.searchMatches,activeLockedId:e.activeLockedId,hoveredElementIds:e.hoveredElementIds,frameRendering:e.frameRendering,shouldCacheIgnoreZoom:e.shouldCacheIgnoreZoom,exportScale:e.exportScale,currentItemArrowType:e.currentItemArrowType}),OB=B.memo(EB,(e,t)=>e.selectionNonce!==t.selectionNonce||e.canvasNonce!==t.canvasNonce||e.scale!==t.scale||e.elementsMap!==t.elementsMap||e.visibleElements!==t.visibleElements||e.selectedElements!==t.selectedElements||e.renderScrollbars!==t.renderScrollbars||e.interactionEnabled!==t.interactionEnabled||e.navigationEnabled!==t.navigationEnabled?!1:S(DB(e.appState),DB(t.appState))),kB=e=>{let t=(0,B.useRef)(null),n=(0,B.useRef)(!1);return(0,B.useEffect)(()=>{e.canvas.style.width=`${e.appState.width}px`,e.canvas.style.height=`${e.appState.height}px`,e.canvas.width=e.appState.width*e.scale,e.canvas.height=e.appState.height*e.scale},[e.appState.height,e.appState.width,e.canvas,e.scale]),(0,B.useEffect)(()=>{let r=t.current;if(!r)return;let i=e.canvas;n.current||(n.current=!0,r.replaceChildren(i),i.classList.add(`excalidraw__canvas`,`static`)),Ji({canvas:i,rc:e.rc,scale:e.scale,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,visibleElements:e.visibleElements,appState:e.appState,renderConfig:e.renderConfig},YM())}),(0,V.jsx)(`div`,{className:`excalidraw__canvas-wrapper`,ref:t})},AB=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,openDialog:e.openDialog,hoveredElementIds:e.hoveredElementIds,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,shouldCacheIgnoreZoom:e.shouldCacheIgnoreZoom,viewBackgroundColor:e.viewBackgroundColor,exportScale:e.exportScale,selectedElementsAreBeingDragged:e.selectedElementsAreBeingDragged,gridSize:e.gridSize,gridStep:e.gridStep,frameRendering:e.frameRendering,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,editingGroupId:e.editingGroupId,currentHoveredFontFamily:e.currentHoveredFontFamily,croppingElementId:e.croppingElementId,suggestedBinding:e.suggestedBinding}),jB=B.memo(kB,(e,t)=>e.canvasNonce!==t.canvasNonce||e.scale!==t.scale||e.elementsMap!==t.elementsMap||e.visibleElements!==t.visibleElements?!1:S(AB(e.appState),AB(t.appState))&&S(e.renderConfig,t.renderConfig)),MB=({canvas:e,rc:t,newElement:n,elementsMap:r,allElementsMap:i,scale:a,appState:o,renderConfig:s})=>{if(e){let[c,l]=ot(e,a),u=ar({canvas:e,scale:a,normalizedWidth:c,normalizedHeight:l});if(u.save(),u.scale(o.zoom.value,o.zoom.value),n&&n.type!==`selection`){if(li(n))return;if((n.frameId||o.frameToHighlight?.id)&&o.frameRendering.enabled&&o.frameRendering.clip){let e=To(n,r,o);e&&Me(n,e,o,r)&&xr(e,u,s,o)}qs(n,r,i,t,u,s,o)}else u.clearRect(0,0,c,l);u.restore()}},NB=bi(e=>{MB(e)}),PB=(e,t)=>{if(t){NB(e);return}MB(e)},FB=e=>{let t=(0,B.useRef)(null);return(0,B.useEffect)(()=>{t.current&&PB({canvas:t.current,scale:e.scale,newElement:e.newElement,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,rc:e.rc,renderConfig:e.renderConfig,appState:e.appState},YM())}),(0,V.jsx)(`canvas`,{className:`excalidraw__canvas`,style:{width:e.appState.width,height:e.appState.height},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:t})},IB=700,LB=100,RB=16,zB=3e5,BB=Gc(null),VB=e=>e===Cr.elbow?JS:e===Cr.round?YS:qS,HB=class{constructor(e){z(this,`app`),z(this,`lastShownAt`,0),z(this,`show`,e=>{let{x:t,y:n}=this.app.viewport.lastPosition;t===0&&n===0||(this.lastShownAt=Date.now(),this.app.updateEditorAtom(BB,{content:e,nonce:Math.random()}))}),z(this,`isOnCooldown`,()=>Date.now()-this.lastShownAt<zB),z(this,`onArrowTypeCycled`,e=>{this.show(VB(e))}),z(this,`onToolShortcut`,(e,t)=>{(t===`digit`||!this.isOnCooldown())&&this.show(e===`line`?lb:VB(this.app.state.currentItemArrowType))}),this.app=e}},UB=()=>{let[e,t]=wy(BB),n=iV(),{container:r}=cV(),i=(0,B.useRef)(null),[a,o]=(0,B.useState)(!1),s=e?.nonce;return(0,B.useLayoutEffect)(()=>{if(s==null||!r)return;let e=(e,t)=>{let n=i.current;if(!n)return;let{left:a,top:o}=jC({cursor:{x:e,y:t},element:{width:n.offsetWidth,height:n.offsetHeight},container:r.getBoundingClientRect(),gap:RB});n.style.transform=`translate(${a}px, ${o}px)`};e(n.viewport.lastPosition.x,n.viewport.lastPosition.y);let t=t=>{e(t.clientX,t.clientY)};return window.addEventListener(T.POINTER_MOVE,t),()=>{window.removeEventListener(T.POINTER_MOVE,t)}},[s,r,n]),(0,B.useEffect)(()=>()=>{t(null)},[t]),(0,B.useEffect)(()=>{if(s==null)return;o(!1);let e=window.setTimeout(()=>{o(!0)},IB),n=window.setTimeout(()=>{t(null)},IB+LB),r=()=>{t(null)};return window.addEventListener(T.POINTER_DOWN,r,{capture:!0}),()=>{window.clearTimeout(e),window.clearTimeout(n),window.removeEventListener(T.POINTER_DOWN,r,{capture:!0})}},[s,t]),e?(0,V.jsx)(`div`,{ref:i,className:H(`CursorHint`,{"CursorHint--fade-out":a}),"data-testid":`cursor-hint`,children:e.content}):null},WB=class{constructor(e){this.getState=e,z(this,`listeners`,[]),z(this,`onStateChange`,(e,t,n)=>{let{predicate:r,getValue:i,callback:a,once:o,matchesImmediately:s}=this.normalize(e,t,n);return a?s&&(queueMicrotask(()=>{let e=this.getState();a(i(e),e)}),o)?()=>{}:this.subscribe({predicate:r,getValue:i,callback:a,once:o}):s?Promise.resolve(i(this.getState())):new Promise(e=>{this.subscribe({predicate:r,getValue:i,callback:t=>e(t),once:!0})})})}isStateChangePredicateOptions(e){return typeof e==`object`&&!Array.isArray(e)&&`predicate`in e}subscribe(e){return this.listeners.push(e),()=>{this.listeners=this.listeners.filter(t=>t!==e)}}normalize(e,t,n){let r,i,a=t,o=n?.once??!1,s=!1;if(this.isStateChangePredicateOptions(e)){let{predicate:t,callback:n,once:c}=e;r=t,i=e=>e,a=n?(e,t)=>n(t):void 0,o=c??!1,s=t(this.getState())}else if(typeof e==`function`){let t=e;r=(e,n)=>t(e)!==t(n),i=e=>t(e)}else if(Array.isArray(e)){let t=e;r=(e,n)=>t.some(t=>e[t]!==n[t]),i=e=>e}else{let t=e;r=(e,n)=>e[t]!==n[t],i=e=>e[t]}return{predicate:r,getValue:i,callback:a,once:o,matchesImmediately:s}}flush(e){if(!this.listeners.length)return;let t=this.getState(),n=[];for(let r of this.listeners)r.predicate(t,e)?(r.callback(r.getValue(t),t),r.once||n.push(r)):n.push(r);this.listeners=n}clear(){this.listeners=[]}},GB=({app:e,activeLockedId:t})=>{let n=e.scene.getElement(t);n&&!dc(n)&&console.error(`[NONDELETED][INVARIANT] UnlockPopup: activeLockedId points to a deleted element`);let r=n&&dc(n)?n:null,i=r?[r]:yt(e.scene.getNonDeletedElementsMap(),t);if(i.length===0)return null;let[a,o]=Is(i),{x:s,y:c}=Tn({sceneX:a,sceneY:o},e.state);return(0,V.jsx)(`div`,{className:`UnlockPopup`,style:{bottom:`${e.state.height+12-c+e.state.offsetTop}px`,left:`${s-e.state.offsetLeft}px`},onClick:()=>{(0,Uc.flushSync)(()=>{let t=rt(i,e.state);e.setState({selectedElementIds:i.reduce((e,t)=>({...e,[t.id]:!0}),{}),selectedGroupIds:t,activeLockedId:null})}),e.actionManager.executeAction(DD)},title:W(`labels.elementLock.unlock`),children:$y})},KB=B.createContext(null),qB=B.createContext(null),JB={formFactor:`desktop`,desktopUIMode:`full`,userAgent:k(typeof navigator<`u`?navigator.userAgent:``),isTouchScreen:!1,canFitSidebar:!1,isLandscape:!0},YB=B.createContext(JB);YB.displayName=`EditorInterfaceContext`;var XB={"editor:mount":{cardinality:`once`,replay:`last`},"editor:initialize":{cardinality:`once`,replay:`last`},"editor:unmount":{cardinality:`once`,replay:`last`}},ZB=B.createContext({container:null,id:null});ZB.displayName=`ExcalidrawContainerContext`;var QB=B.createContext([]);QB.displayName=`ExcalidrawElementsContext`;var $B=B.createContext({...ht(),width:0,height:0,offsetLeft:0,offsetTop:0});$B.displayName=`ExcalidrawAppStateContext`;var eV=B.createContext(()=>{console.warn(`Uninitialized ExcalidrawSetAppStateContext context!`)});eV.displayName=`ExcalidrawSetAppStateContext`;var tV=B.createContext(null);tV.displayName=`ExcalidrawActionManagerContext`;var nV=B.createContext(null);nV.displayName=`ExcalidrawAPIContext`;var rV=B.createContext(null);rV.displayName=`ExcalidrawAPISetContext`;var iV=()=>(0,B.useContext)(KB),aV=()=>(0,B.useContext)(qB),oV=()=>(0,B.useContext)(YB),sV=()=>sr(oV()),cV=()=>(0,B.useContext)(ZB),lV=()=>(0,B.useContext)(QB),uV=()=>(0,B.useContext)($B),dV=()=>(0,B.useContext)(eV),fV=()=>(0,B.useContext)(tV),pV=()=>(0,B.useContext)(nV),mV=!1,hV=0,gV=null,_V=!1,vV=!1,yV=!1,bV={horizontal:null,vertical:null},xV=0,SV=!1,CV=new Map,wV=4,TV=!1,EV=0,DV=!1,OV=null,$={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},kV=class e extends B.Component{constructor(t){super(t),z(this,`canvas`),z(this,`interactiveCanvas`,null),z(this,`sessionExportThemeOverride`),z(this,`rc`),z(this,`unmounted`,!1),z(this,`actionManager`),z(this,`editorInterface`,JB),z(this,`stylesPanelMode`,sr(JB)),z(this,`excalidrawContainerRef`,B.createRef()),z(this,`scene`),z(this,`fonts`),z(this,`renderer`),z(this,`visibleElements`),z(this,`hasRenderableElements`,!1),z(this,`resizeObserver`),z(this,`library`),z(this,`libraryItemsFromStorage`),z(this,`id`),z(this,`store`),z(this,`history`),z(this,`excalidrawContainerValue`),z(this,`files`,{}),z(this,`imageCache`,new Map),z(this,`iFrameRefs`,new Map),z(this,`embedsValidationStatus`,new Map),z(this,`initializedEmbeds`,new Set),z(this,`elementsPendingErasure`,new Set),z(this,`_initialized`,!1),z(this,`editorLifecycleEvents`,new Kt(XB)),z(this,`onEvent`,this.editorLifecycleEvents.on.bind(this.editorLifecycleEvents)),z(this,`appStateObserver`,new WB(()=>this.state)),z(this,`onStateChange`,this.appStateObserver.onStateChange),z(this,`bucketFill`,new IP(this)),z(this,`flowchart`,new KP(this)),z(this,`cursor`,new UP(this)),z(this,`arrowText`,new PP(this)),z(this,`viewport`,new uF(this,{getContainer:()=>this.excalidrawContainerRef.current,getStylesPanelMode:()=>this.stylesPanelMode,isGestureActive:()=>$.pointers.size>=2||vV})),z(this,`bindModeHandler`,null),z(this,`textWysiwygSubmitHandler`,null),z(this,`hitLinkElement`),z(this,`lastPointerDownEvent`,null),z(this,`lastPointerUpEvent`,null),z(this,`lastPointerUpIsDoubleClick`,!1),z(this,`lastPointerMoveEvent`,null),z(this,`lastPointerMoveCoords`,null),z(this,`lastCompletedCanvasClicks`,[]),z(this,`previousPointerMoveCoords`,null),z(this,`drawShape`,new GP(this)),z(this,`laserTrails`,new eN(this)),z(this,`eraserTrail`,new wN(this)),z(this,`lassoTrail`,new CN(this)),z(this,`cursorHints`,new HB(this)),z(this,`onChangeEmitter`,new Rn),z(this,`onPointerDownEmitter`,new Rn),z(this,`onPointerUpEmitter`,new Rn),z(this,`onUserFollowEmitter`,new Rn),z(this,`onScrollChangeEmitter`,new Rn),z(this,`missingPointerEventCleanupEmitter`,new Rn),z(this,`onRemoveEventListenersEmitter`,new Rn),z(this,`api`),z(this,`isToolSupported`,(e,t=this.props)=>{if(t.UIOptions.tools?.[e]===!1)return!1;if(this.isInteractionEnabled(t))return!0;let n=typeof t.interaction==`object`&&t.interaction!==null?t.interaction.enabled?.tools:void 0;return e===`laser`?n?.laser===!0:e===`custom`&&n?.custom===!0}),z(this,`updateEditorAtom`,(e,...t)=>{let n=ky.set(e,...t);return this.triggerRender(),n}),z(this,`previousHoveredBindableElement`,null),z(this,`getEffectiveGridSize`,()=>wM(this)?this.state.gridSize:null),z(this,`getTextCreationGridPoint`,(e,t)=>{let n=this.getEffectiveGridSize();if(n===null)return null;let r=e=>Math.floor(e/n)*n;return{x:r(e),y:r(t)}}),z(this,`handleIframeLikeElementHover`,({hitElement:e,scenePointer:t,moveEvent:n})=>e&&ns(e)&&(this.state.viewModeEnabled||this.state.activeTool.type===`laser`||this.isIframeLikeElementCenter(e,n,t.x,t.y))?(this.cursor.set(Et.POINTER),this.setState({activeEmbeddable:{element:e,state:`hover`}}),!0):(this.state.activeEmbeddable?.state===`hover`&&this.setState({activeEmbeddable:null}),!1)),z(this,`isDoubleClick`,(e,t)=>e!=null&&t.timeStamp-e.timeStamp<=300),z(this,`updateEmbedValidationStatus`,(e,t)=>{this.embedsValidationStatus.set(e.id,t),fr.delete(e)}),z(this,`updateEmbeddables`,()=>{let e=new Set,t=!1;this.scene.getNonDeletedElements().filter(n=>{if(us(n)){if(e.add(n.id),!this.embedsValidationStatus.has(n.id)){t=!0;let e=En(n.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(n,e)}}else Yt(n)&&e.add(n.id);return!1}),t&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((t,n)=>{e.has(n)||this.iFrameRefs.delete(n)})}),z(this,`getFrameNameDOMId`,e=>`${this.id}-frame-name-${e.id}`),z(this,`frameNameBoundsCache`,{get:e=>{let t=this.frameNameBoundsCache._cache.get(e.id);if(!t||t.zoom!==this.state.zoom.value||t.versionNonce!==e.versionNonce){let n=document.getElementById(this.getFrameNameDOMId(e));if(n){let r=n.getBoundingClientRect(),i=St({clientX:r.x,clientY:r.y},this.state),a=St({clientX:r.right,clientY:r.bottom},this.state);return t={x:i.x,y:i.y,width:a.x-i.x,height:a.y-i.y,zoom:this.state.zoom.value,versionNonce:e.versionNonce},this.frameNameBoundsCache._cache.set(e.id,t),t}return null}return t},_cache:new Map}),z(this,`resetEditingFrame`,e=>{e&&this.scene.mutateElement(e,{name:e.name?.trim()||null}),this.setState({editingFrame:null})}),z(this,`renderFrameNames`,()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return this.state.editingFrame&&this.resetEditingFrame(null),null;let e=this.state.theme===A.DARK,t=this.scene.getNonDeletedFramesLikes(),n=t.length>0&&this.state.searchMatches?.focusedId&&P(this.scene.getElement(this.state.searchMatches.focusedId))?this.state.searchMatches.matches.find(e=>e.focus):null;return t.map(t=>{if(!ko(t,this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap()))return this.state.editingFrame===t.id&&this.resetEditingFrame(t),null;let{x:r,y:i}=Tn({sceneX:t.x,sceneY:t.y},this.state),a,o=Nt(t);if(t.id===this.state.editingFrame){let n=o;a=(0,V.jsx)(`input`,{autoFocus:!0,value:n,onChange:e=>{this.scene.mutateElement(t,{name:e.target.value})},onFocus:e=>e.target.select(),onBlur:()=>this.resetEditingFrame(t),onKeyDown:e=>{(e.key===j.ESCAPE||e.key===j.ENTER)&&this.resetEditingFrame(t)},style:{background:kt(this.state.viewBackgroundColor,e),zIndex:2,border:`none`,display:`block`,padding:`6px`,borderRadius:4,boxShadow:`inset 0 0 0 1px var(--color-primary)`,fontFamily:`Assistant`,fontSize:`${Wr.nameFontSize}px`,transform:`translate(-6px, 6px)`,color:e?Wr.nameColorDarkTheme:Wr.nameColorLightTheme,overflow:`hidden`,maxWidth:`${document.body.clientWidth-r-6}px`},size:n.length+1||1,dir:`auto`,autoComplete:`off`,autoCapitalize:`off`,autoCorrect:`off`})}else a=o;return(0,V.jsx)(`div`,{id:this.getFrameNameDOMId(t),className:D.FRAME_NAME,style:{position:`absolute`,bottom:`${this.state.height+Wr.nameOffsetY-i+this.state.offsetTop}px`,left:`${r-this.state.offsetLeft}px`,zIndex:2,fontSize:Wr.nameFontSize,color:e?Wr.nameColorDarkTheme:Wr.nameColorLightTheme,lineHeight:Wr.nameLineHeight,width:`max-content`,maxWidth:n?.id===t.id&&n?.focus?`none`:`${t.width*this.state.zoom.value}px`,overflow:t.id===this.state.editingFrame?`visible`:`hidden`,whiteSpace:`nowrap`,textOverflow:`ellipsis`,cursor:Et.MOVE,pointerEvents:this.state.viewModeEnabled?ii.disabled:ii.enabled},onPointerDown:e=>this.handleCanvasPointerDown(e),onWheel:e=>this.handleWheel(e),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:t.id})},children:a},t.id)})}),z(this,`focusContainer`,()=>{this.excalidrawContainerRef.current?.focus()}),z(this,`getSceneElementsIncludingDeleted`,()=>this.scene.getElementsIncludingDeleted()),z(this,`getSceneElementsMapIncludingDeleted`,()=>this.scene.getElementsMapIncludingDeleted()),z(this,`getSceneElements`,()=>this.scene.getNonDeletedElements()),z(this,`onInsertElements`,e=>{this.addElementsFromPasteOrLibrary({elements:e,position:`center`,files:null})}),z(this,`onExportImage`,async(e,t,n)=>{xC(`export`,e,`ui`);let r=await uE(e,t,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:n.exportingFrame}).catch($e).catch(e=>{console.error(e),this.setState({errorMessage:e.message})});this.state.exportEmbedScene&&r&&Ta(r)&&this.setState({fileHandle:r})}),z(this,`magicGenerations`,new Map),z(this,`updateMagicGeneration`,({frameElement:e,data:t})=>{t.status===`pending`?this.scene.mutateElement(e,{customData:{generationData:void 0}},{informMutation:!1,isDragging:!1}):this.scene.mutateElement(e,{customData:{generationData:t}},{informMutation:!1,isDragging:!1}),this.magicGenerations.set(e.id,t),this.triggerRender()}),z(this,`plugins`,{}),z(this,`onMagicframeToolSelect`,()=>{let e=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});if(e.length===0)this.setActiveTool({type:Ks.magicframe}),xC(`ai`,`tool-select (empty-selection)`,`d2c`);else{let t=e.length===1&&ue(e[0])&&e[0];if(!t&&e.some(e=>P(e)||e.frameId)){this.setActiveTool({type:Ks.magicframe});return}xC(`ai`,`tool-select (existing selection)`,`d2c`);let n;if(t)n=t;else{let[t,r,i,a]=Is(e);n=on({...Wr,x:t-50,y:r-50,width:i-t+100,height:a-r+100,opacity:100,locked:!1}),this.insertNewElement(n);for(let t of e)this.scene.mutateElement(t,{frameId:n.id});this.setState({selectedElementIds:{[n.id]:!0}})}this.onMagicFrameGenerate(n,`upstream`)}}),z(this,`openEyeDropper`,({type:e})=>{this.updateEditorAtom(MC,{swapPreviewOnAlt:!0,colorPickerType:e===`stroke`?`elementStroke`:`elementBackground`,onSelect:(t,n)=>{let r=e===`background`&&n.altKey||e===`stroke`&&!n.altKey;!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!==`selection`?r?this.syncActionResult({appState:{...this.state,currentItemStrokeColor:t},captureUpdate:F.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:t},captureUpdate:F.IMMEDIATELY}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(e=>this.state.selectedElementIds[e.id]?R(e,{[r?`strokeColor`:`backgroundColor`]:t}):e),captureUpdate:F.IMMEDIATELY})},keepOpenOnAlt:!1})}),z(this,`dismissLinearEditor`,()=>{setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isEditing:!1}})})}),z(this,`syncActionResult`,qM(e=>{if(this.unmounted||e===!1)return;this.store.scheduleAction(e.captureUpdate);let t=!1,n=null;if(e.elements&&(this.scene.replaceAllElements(e.elements),t=!0),e.files&&(this.addMissingFiles(e.files,e.replaceFiles),this.addNewImagesToImageCache()),e.appState||n||this.state.contextMenu){let r=e?.appState?.viewModeEnabled||!1,i=e?.appState?.zenModeEnabled||!1,o=e?.appState?.theme||this.props.theme||A.LIGHT,s=e?.appState?.name??this.state.name,c=e?.appState?.errorMessage??this.state.errorMessage;if(typeof this.props.viewModeEnabled<`u`&&(r=this.props.viewModeEnabled),this.isInteractionEnabled()||(r=!0),typeof this.props.zenModeEnabled<`u`&&(i=this.props.zenModeEnabled),n=e.appState?.editingTextElement||null,e.elements&&n){let t=n.id,r=e.elements.find(e=>e.id===t);n=r&&dc(r)&&a(r)?r:null}this.setState(t=>{let a=e.appState||{};return{...t,...a,contextMenu:null,editingTextElement:n,viewModeEnabled:r,zenModeEnabled:i,theme:o,name:s,errorMessage:c}}),t=!0}t||this.scene.triggerUpdate()})),z(this,`scheduleCapture`,()=>this.store.scheduleCapture()),z(this,`onBlur`,qM(()=>{_V=!1,this.setState({isBindingEnabled:this.state.bindingPreference===`enabled`})})),z(this,`onUnload`,()=>{this.onBlur()}),z(this,`disableEvent`,e=>{e.preventDefault()}),z(this,`preventBrowserZoomWheel`,e=>{e[j.CTRL_OR_CMD]&&e.preventDefault()}),z(this,`handleNavigationModeKeyDown`,e=>{if(this.maybeHandlePageScrollKeyDown(e)){e.preventDefault();return}this.actionManager.handleKeyDown(e)}),z(this,`maybeHandlePageScrollKeyDown`,e=>{if(e.key!==j.PAGE_UP&&e.key!==j.PAGE_DOWN)return!1;let t=(e.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;return e.key===j.PAGE_DOWN&&(t=-t),e.shiftKey?this.viewport.translate(e=>({scrollX:e.scrollX+t})):this.viewport.translate(e=>({scrollY:e.scrollY+t})),!0}),z(this,`preventBrowserZoomKeyDown`,e=>{e[j.CTRL_OR_CMD]&&(e.code===I.EQUAL||e.code===I.MINUS||e.code===I.ZERO||e.code===I.NUM_ADD||e.code===I.NUM_SUBTRACT||e.code===I.NUM_ZERO)&&e.preventDefault()}),z(this,`terminateActiveInteraction`,()=>{if(this.maybeCleanupAfterMissingPointerUp(null),_V=!1,vV=!1,yV=!1,OV=null,$.pointers.clear(),$.lastCenter=null,$.initialDistance=null,$.initialScale=null,clearTimeout(hV),hV=0,e.resetTapTwice(),this.resetContextMenuTimer(),clearTimeout(EV),EV=0,TV=!1,this.bindModeHandler&&=(clearTimeout(this.bindModeHandler),null),this.flowchart.clear(),ky.set(MC,null),ky.set(LD,null),this.state.editingFrame){let e=this.scene.getNonDeletedElement(this.state.editingFrame);this.resetEditingFrame(e&&P(e)?e:null)}queueMicrotask(()=>{(!this.isInteractionEnabled()||this.state.viewModeEnabled)&&this.textWysiwygSubmitHandler?.()}),this.setState({contextMenu:null,openMenu:null,openPopup:null,cursorButton:`up`,bindMode:`orbit`,activeEmbeddable:null,activeLockedId:null,selectedElementsAreBeingDragged:!1,selectionElement:null,resizingElement:null,isResizing:!1,isRotating:!1,isCropping:!1,croppingElementId:null,suggestedBinding:null,frameToHighlight:null,elementsToHighlight:null,snapLines:[],showHyperlinkPopup:!1}),this.deselectElements(),this.isInteractionEnabled()||(this.setState({originSnapOffset:null}),this.cursor.reset())}),z(this,`handleInteractionStateChange`,(e,t)=>{let n=this.isInteractionEnabled(e),r=n!==this.isInteractionEnabled(),i=e.viewModeEnabled!==this.props.viewModeEnabled,a=this.state.viewModeEnabled;this.isInteractionEnabled()?(i||r)&&(a=!!this.props.viewModeEnabled):a=!0,a!==this.state.viewModeEnabled&&this.setState({viewModeEnabled:a});let o=n&&!t.viewModeEnabled,s=this.isInteractionEnabled()&&!this.state.viewModeEnabled;(r&&!this.isInteractionEnabled()||o&&!s)&&this.terminateActiveInteraction(),r&&this.addEventListeners(),this.isLinksEnabled(e)!==this.isLinksEnabled()&&(this.isLinksEnabled()||(this.hitLinkElement=void 0,CD(),this.cursor.reset())),this.isEmbedsEnabled(e)!==this.isEmbedsEnabled()&&(this.isEmbedsEnabled()||this.setState({activeEmbeddable:null})),this.isToolSupported(t.activeTool.type,e)!==this.isToolSupported(this.state.activeTool.type)&&(this.isToolSupported(this.state.activeTool.type)||this.laserTrails.endPath(),this.cursor.reset()),!this.isInteractionEnabled()&&!this.isToolSupported(this.state.activeTool.type)&&this.state.activeTool.type!==`selection`&&this.setState({activeTool:Pt(this.state,{type:`selection`})}),(this.isBrowserZoomEnabled(e)!==this.isBrowserZoomEnabled()||this.isNavigationEnabled(e)!==this.isNavigationEnabled())&&(this.addEventListeners(),this.cursor.reset()),t.viewModeEnabled!==this.state.viewModeEnabled&&(this.isInteractionEnabled()&&this.addEventListeners(),this.state.viewModeEnabled||this.deselectElements(),this.cursor.reset())}),z(this,`isSameForcedTool`,(e,t)=>e?.type===t?.type&&(e?.type===`custom`?e.customType??null:null)===(t?.type===`custom`?t.customType??null:null)),z(this,`handleForcedToolChange`,(e,t)=>{let n=this.props.activeTool;if(!n)return;let r=!this.isSameForcedTool(e.activeTool,n);if(n.type===`image`){r&&console.warn(`"image" tool cannot be forced via "props.activeTool"`);return}this.isSameForcedTool(n,this.state.activeTool)||(r||t.activeTool!==this.state.activeTool||this.isToolSupported(n.type,e)!==this.isToolSupported(n.type,this.props))&&this.setActiveTool(n)}),z(this,`resetHistory`,()=>{this.history.clear()}),z(this,`resetStore`,()=>{this.store.clear()}),z(this,`resetScene`,qM(e=>{this.scene.replaceAllElements([]),this.setState(t=>({...ht(),isLoading:!e?.resetLoadingState&&t.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()})),z(this,`initializeScene`,async()=>{`launchQueue`in window&&`LaunchParams`in window&&window.launchQueue.setConsumer(async e=>{if(!e.files.length)return;let t=e.files[0],n=await t.getFile();this.loadFileToCanvas(new File([n],n.name||``,{type:n.type}),t)}),this.props.theme&&this.setState({theme:this.props.theme}),this.state.isLoading||this.setState({isLoading:!0});let e=null;try{e=typeof this.props.initialData==`function`?await this.props.initialData()||null:await this.props.initialData||null,e?.libraryItems&&this.library.updateLibrary({libraryItems:e.libraryItems,merge:!0}).catch(e=>{console.error(e)})}catch(t){console.error(t),e={appState:{errorMessage:t.message||`Encountered an error during importing or restoring scene data`}}}let t=Xt(e?.elements,null,{repairBindings:!0,deleteInvisibleElements:!0}),n=we(e?.appState,null),r=n.activeTool;n.preferredSelectionTool.initialized||(n.preferredSelectionTool={type:this.editorInterface.formFactor===`phone`?`lasso`:`selection`,initialized:!0}),n={...n,theme:this.props.theme||n.theme,openSidebar:n?.openSidebar||this.state.openSidebar,activeTool:r.type===`image`||r.type===`lasso`||r.type===`selection`?{...r,type:n.preferredSelectionTool.type}:n.activeTool,isLoading:!1,toast:this.state.toast};let i={...n,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft},a=this.props.initialState?.viewport;if(a){let e=t.filter(e=>!e.isDeleted),r=ui(e),o=this.viewport.resolveInitialViewport(a,r,i);o&&(n={...n,...o})}else e?.scrollToContent&&(n={...n,...Vt(t,i)});this.resetStore(),this.resetHistory(),this.syncActionResult({elements:t,appState:n,files:e?.files,captureUpdate:F.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(e=>{this.fonts.onLoaded(e)}),Ea(window.location.href)&&this.viewport.setViewport({target:window.location.href,fit:`scale-down`,animation:!1})}),z(this,`getFormFactor`,(e,t)=>this.props.UIOptions.getFormFactor?.(e,t)??pt(e,t)),z(this,`refreshEditorInterface`,()=>{let e=this.excalidrawContainerRef.current;if(!e)return;let{width:t,height:n}=e.getBoundingClientRect(),r=Ee(),i=k(typeof navigator<`u`?navigator.userAgent:``),a=this.props.UIOptions.dockedSidebarBreakpoint==null?hs:this.props.UIOptions.dockedSidebarBreakpoint,o=ds(this.editorInterface,{desktopUIMode:r??this.editorInterface.desktopUIMode,formFactor:this.getFormFactor(t,n),userAgent:i,canFitSidebar:t>a,isLandscape:t>n});this.editorInterface=o,this.reconcileStylesPanelMode(o)}),z(this,`reconcileStylesPanelMode`,e=>{let t=sr(e);if(t===this.stylesPanelMode)return;let n=this.stylesPanelMode;this.stylesPanelMode=t,this.viewport.invalidateUIOffset(`stylesPanel`),n!==`full`&&t===`full`&&this.setState(e=>({preferredSelectionTool:{type:`selection`,initialized:!0}}))}),z(this,`setDesktopUIMode`,e=>{let t=_e(e);this.editorInterface=ds(this.editorInterface,{desktopUIMode:t}),this.reconcileStylesPanelMode(this.editorInterface)}),z(this,`onResize`,qM(()=>{this.scene.getElementsIncludingDeleted().forEach(e=>fr.delete(e)),this.refreshEditorInterface(),this.updateDOMRect(),this.setState({})})),z(this,`onFullscreenChange`,()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state===`active`&&this.setState({activeEmbeddable:null})}),z(this,`renderInteractiveSceneCallback`,({scrollBars:e})=>{e&&(bV=e),this.scheduleImageRefresh()}),z(this,`onScroll`,ke(()=>{let{offsetTop:e,offsetLeft:t}=this.getCanvasOffsets();this.setState(n=>n.offsetLeft===t&&n.offsetTop===e?null:{offsetTop:e,offsetLeft:t})},100)),z(this,`onCut`,qM(e=>{!this.isInteractionEnabled()||!this.excalidrawContainerRef.current?.contains(document.activeElement)||de(e.target)||(this.actionManager.executeAction(YE,`keyboard`,e),e.preventDefault(),e.stopPropagation())})),z(this,`onCopy`,qM(e=>{!this.isInteractionEnabled()||!this.excalidrawContainerRef.current?.contains(document.activeElement)||de(e.target)||(this.actionManager.executeAction(qE,`keyboard`,e),e.preventDefault(),e.stopPropagation())})),z(this,`onTouchStart`,t=>{if(this.isInteractionEnabled()){if(qe&&t.preventDefault(),!mV){mV=!0,t.touches.length===1&&(gV={x:t.touches[0].clientX,y:t.touches[0].clientY}),clearTimeout(hV),hV=window.setTimeout(e.resetTapTwice,300);return}if(mV&&t.touches.length===1&&gV){let e=t.touches[0];ya(L(e.clientX,e.clientY),L(gV.x,gV.y))<=35&&(this.lassoTrail.endPath(),this.deselectElements(),this.handleCanvasDoubleClick({clientX:e.clientX,clientY:e.clientY,type:`touch`,altKey:!1,ctrlKey:!1,metaKey:!1,shiftKey:!1})),mV=!1,clearTimeout(hV)}t.touches.length===2&&this.setState({selectedElementIds:fa({},this.state),activeEmbeddable:null})}}),z(this,`onTouchEnd`,e=>{this.isInteractionEnabled()&&(this.resetContextMenuTimer(),e.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:fa(this.state.previousSelectedElementIds,this.state)}):$.pointers.clear())}),z(this,`pasteFromClipboard`,qM(async e=>{if(!this.isInteractionEnabled())return;let t=!!TV,n=document.activeElement,r=this.excalidrawContainerRef.current?.contains(n);if(e&&!r)return;let i=document.elementFromPoint(this.viewport.lastPosition.x,this.viewport.lastPosition.y);if(e&&(!(i instanceof HTMLCanvasElement)||de(n)))return;let a=await rE(e),o=a.getFiles(),s=await iE(a,t);if(this.props.onPaste)try{if(await this.props.onPaste(s,e)===!1)return}catch(e){console.error(e)}await this.insertClipboardContent(s,o,t),this.setActiveTool({type:this.state.preferredSelectionTool.type},{keepSelection:!0}),e?.preventDefault()})),z(this,`addElementsFromPasteOrLibrary`,e=>{let t=Xt(e.elements,null,{deleteInvisibleElements:!0}),[n,r,i,o]=Is(t),c=Jn(n,i)/2,l=Jn(r,o)/2,u=typeof e.position==`object`?e.position.clientX:e.position===`cursor`?this.viewport.lastPosition.x:this.state.width/2+this.state.offsetLeft,d=typeof e.position==`object`?e.position.clientY:e.position===`cursor`?this.viewport.lastPosition.y:this.state.height/2+this.state.offsetTop,{x:f,y:p}=St({clientX:u,clientY:d},this.state),m=f-c,h=p-l,[g,_]=An(m,h,this.getEffectiveGridSize()),{duplicatedElements:v}=bc({type:`everything`,elements:t.map(e=>R(e,{x:e.x+g-n,y:e.y+_-r})),randomizeSeed:!e.retainSeed,preserveFrameChildrenOrder:e.preserveFrameChildrenOrder}),y=this.scene.getElementsIncludingDeleted(),b=[...y,...v];b=this.props.onDuplicate?.(b,y)||b,Ie(b,ui(v));let x=this.getTopLayerFrameAtSceneCoords({x:f,y:p});if(x){let e=ye(v,x);b=Ke(b,e,x)}this.scene.replaceAllElements(b),v.forEach(e=>{if(a(e)&&cs(e)){let t=Go(e,this.scene.getElementsMapIncludingDeleted());Sa(e,t,this.scene)}}),s&&Ar.loadElementsFonts(v).then(e=>{this.fonts.onLoaded(e)}),e.files&&this.addMissingFiles(e.files);let S=Ua(v);this.store.scheduleCapture(),this.setState({...this.state,openSidebar:this.state.openSidebar&&this.editorInterface.canFitSidebar&&ky.get(XF)?this.state.openSidebar:null,...E(S,this.scene.getNonDeletedElements(),this.state)},()=>{e.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:this.state.preferredSelectionTool.type},{keepSelection:!0}),e.fit&&this.viewport.setViewport({target:v,fit:e.fit,animation:!1,offsets:{ui:!0}})}),z(this,`setAppState`,(e,t)=>{this.setState(e,t)}),z(this,`removePointer`,e=>{xV&&this.resetContextMenuTimer(),e.type===`pointercancel`&&this.bucketFill.cancel();let t=$.pointers.size>=2;$.pointers.delete(e.pointerId),t&&$.pointers.size<2&&this.state.scrollConstraints&&this.viewport.releaseOverscroll()}),z(this,`toggleLock`,(e=`ui`)=>{this.props.activeTool||(this.state.activeTool.locked||xC(`toolbar`,`toggleLock`,`${e} (${this.editorInterface.formFactor===`phone`?`mobile`:`desktop`})`),this.setState(e=>({activeTool:{...e.activeTool,...Pt(this.state,e.activeTool.locked?{type:this.state.preferredSelectionTool.type}:e.activeTool),locked:!e.activeTool.locked}})))}),z(this,`updateFrameRendering`,e=>{this.setState(t=>{let n=typeof e==`function`?e(t.frameRendering):e;return{frameRendering:{enabled:n?.enabled??t.frameRendering.enabled,clip:n?.clip??t.frameRendering.clip,name:n?.name??t.frameRendering.name,outline:n?.outline??t.frameRendering.outline}}})}),z(this,`togglePenMode`,e=>{this.setState(t=>({penMode:e??!t.penMode,penDetected:!0,currentItemStrokeVariability:t.penDetected?t.currentItemStrokeVariability:`variable`}))}),z(this,`revealIfHidden`,e=>{!e.length||Tr(e,this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.viewport.getOffsets())||this.viewport.setViewport({target:Is(e),fit:`scale-down`,animation:{duration:300},offsets:{ui:!0}})}),z(this,`emitUserFollowIntent`,e=>{this.onUserFollowEmitter.trigger(e),this.props.onUserFollow?.(e)}),z(this,`requestUnfollow`,()=>{this.props.userToFollow&&this.emitUserFollowIntent({userToFollow:this.props.userToFollow,action:`UNFOLLOW`})}),z(this,`setToast`,e=>{this.setState({toast:e})}),z(this,`restoreFileFromShare`,async()=>{try{let e=await caches.open(`web-share-target`),t=await e.match(`shared-file`);if(t){let n=await t.blob(),r=new File([n],n.name||``,{type:n.type});this.loadFileToCanvas(r,null),await e.delete(`shared-file`),window.history.replaceState(null,Ao,window.location.pathname)}}catch(e){this.setState({errorMessage:e.message})}}),z(this,`addFiles`,qM(e=>{let{addedFiles:t}=this.addMissingFiles(e);this.clearImageShapeCache(t),this.scene.triggerUpdate(),this.addNewImagesToImageCache()})),z(this,`addMissingFiles`,(e,t=!1)=>{let n=t?{}:{...this.files},r={},i=Array.isArray(e)?e:Object.values(e);for(let e of i)if(!n[e.id]&&(r[e.id]=e,n[e.id]=e,e.mimeType===M.svg))try{let t=fi(cr(Ze(e.dataURL)),M.svg);e.dataURL!==t&&(e.version=(e.version??1)+1,e.dataURL=t)}catch(e){console.error(e)}return this.files=n,{addedFiles:r}}),z(this,`updateScene`,qM(e=>{let{elements:t,appState:n,collaborators:r,captureUpdate:i}=e;if(i){let e=t||void 0,r=n?ec({...this.store.snapshot.appState,...n}):void 0;this.store.scheduleMicroAction({action:i,elements:e,appState:r})}n&&this.setState(n),t&&this.scene.replaceAllElements(t),r&&(this.laserTrails.updateCollabTrails(r),this.setState({collaborators:r}))})),z(this,`applyDeltas`,(e,t)=>{let n=xo.squash(...e),r={...this.state},i=new Map(this.scene.getElementsMapIncludingDeleted());return xo.applyTo(n,i,r,t)}),z(this,`mutateElement`,(e,t,n=!0)=>this.scene.mutateElement(e,t,{informMutation:n,isDragging:!1})),z(this,`triggerRender`,e=>{e===!0?this.scene.triggerUpdate():this.setState({})}),z(this,`toggleSidebar`,({name:e,tab:t,force:n})=>{let r;r=n===void 0?this.state.openSidebar?.name===e&&this.state.openSidebar?.tab===t?null:e:n?e:null;let i=r?{name:r}:null;return i&&t&&(i.tab=t),this.setState({openSidebar:i}),!!r}),z(this,`updateCurrentCursorPosition`,qM(e=>{this.viewport.lastPosition.x=e.clientX,this.viewport.lastPosition.y=e.clientY})),z(this,`onKeyDown`,qM(e=>{if(!this.isInteractionEnabled())return;if(`Proxy`in window&&(!e.shiftKey&&/^[A-Z]$/.test(e.key)||e.shiftKey&&/^[a-z]$/.test(e.key))&&(e=new Proxy(e,{get(t,n){let r=t[n];return typeof r==`function`?r.bind(t):n===`key`?e.shiftKey?t.key.toUpperCase():t.key.toLowerCase():r}})),!Se(e.target)){if((e.key===j.ESCAPE||e.key===j.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let t=xt(this.scene.getNonDeletedElementsMap(),this.state);if(t.length===1&&De(t[0])&&e.key===j.ENTER){this.startImageCropping(t[0]);return}if(e.key===j.ESCAPE)this.updateEditorAtom(LD,null);else if(e.key===j.TAB&&(document.activeElement===this.excalidrawContainerRef?.current||document.activeElement?.classList.contains(D.CONVERT_ELEMENT_TYPE_POPUP))){e.preventDefault();let n=WD(t);ky.get(LD)?.type===`panel`&&UD(this,{conversionType:n,direction:e.shiftKey?`left`:`right`})&&this.store.scheduleCapture(),n&&this.updateEditorAtom(LD,{type:`panel`})}if(this.flowchart.handleKeyEvent(e))return}if(e[j.CTRL_OR_CMD]&&e.key===j.P&&!e.shiftKey&&!e.altKey){this.setToast({message:W(`commandPalette.shortcutHint`,{shortcut:lO(`commandPalette`)})}),e.preventDefault();return}if(e[j.CTRL_OR_CMD]&&e.key.toLowerCase()===j.V&&(TV=e.shiftKey,clearTimeout(EV),EV=window.setTimeout(()=>{TV=!1},100)),e[j.CTRL_OR_CMD]&&de(e.target)&&(e.code===I.MINUS||e.code===I.EQUAL)){e.preventDefault();return}if(de(e.target)&&e.key!==j.ESCAPE||dr(e.key)&&Se(e.target))return;if(e.key===j.QUESTION_MARK){this.setState({openDialog:{name:`help`}});return}if(e.key.toLowerCase()===j.E&&e.shiftKey&&e[j.CTRL_OR_CMD]){e.preventDefault(),this.setState({openDialog:{name:`imageExport`}});return}if(this.maybeHandlePageScrollKeyDown(e)){e.preventDefault();return}if(this.state.openDialog?.name===`elementLinkSelector`)return;if(e.key===j.ALT){if(this.state.activeTool.type===`bucketfill`){this.bucketFill.openTemporaryEyeDropper(),e.preventDefault();return}pe(`COMPLEX_BINDINGS`)?this.handleSkipBindMode():ai({app:this,event:e})}if(this.actionManager.handleKeyDown(e))return;let t=this.props.viewModeEnabled===!0;if(!t&&this.state.viewModeEnabled&&e.key===j.ESCAPE){this.setActiveTool({type:`selection`});return}if(!t&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged){let t=gT(e.key,this,e.shiftKey);if(this.state.viewModeEnabled&&!gn(t,[`laser`,`hand`]))return;if(t){if(this.state.activeTool.type!==t&&xC(`toolbar`,t,`keyboard (${this.editorInterface.formFactor===`phone`?`mobile`:`desktop`})`),t===`arrow`&&this.state.activeTool.type===`arrow`){let e=this.state.currentItemArrowType===Cr.sharp?Cr.round:this.state.currentItemArrowType===Cr.round?Cr.elbow:Cr.sharp;this.setState({currentItemArrowType:e}),this.cursorHints.onArrowTypeCycled(e)}else(t===`arrow`||t===`line`)&&this.cursorHints.onToolShortcut(t,/^\d$/.test(e.key)?`digit`:`letter`);t===`bucketfill`&&this.state.activeTool.type===`bucketfill`?this.bucketFill.cycleBackgroundColor():t===`lasso`&&this.state.activeTool.type===`laser`?this.setActiveTool({type:this.state.preferredSelectionTool.type}):this.setActiveTool({type:t},{toggle:!0}),e.stopPropagation();return}if(e.key===j.Q){this.toggleLock(`keyboard`),e.stopPropagation();return}}if(this.state.viewModeEnabled)return;if(e[j.CTRL_OR_CMD]&&!e.repeat&&(pe(`COMPLEX_BINDINGS`)&&this.resetDelayedBindMode(),(0,Uc.flushSync)(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!==`enabled`})}),this.arrowText.refresh(),ai({app:this,event:e})),dr(e.key)){let t=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),n=new Set;t.filter(e=>ft(e)).filter(e=>{let n=e.startBinding&&!t.some(t=>t.id===e.startBinding?.elementId),r=e.endBinding&&!t.some(t=>t.id===e.endBinding?.elementId);return n||r}).forEach(e=>n.add(e.id)),t=t.filter(e=>!n.has(e.id));let r=this.getEffectiveGridSize()&&(e.shiftKey?1:this.getEffectiveGridSize())||(e.shiftKey?5:1),i=0,a=0;e.key===j.ARROW_LEFT?i=-r:e.key===j.ARROW_RIGHT?i=r:e.key===j.ARROW_UP?a=-r:e.key===j.ARROW_DOWN&&(a=r),t.forEach(e=>{this.scene.mutateElement(e,{x:e.x+i,y:e.y+a},{informMutation:!1,isDragging:!1}),La(e,this.scene,{simultaneouslyUpdated:t})}),this.scene.triggerUpdate(),e.preventDefault()}else if(e.key===j.ENTER){let t=this.scene.getSelectedElements(this.state);if(t.length===1){let n=t[0];if(e[j.CTRL_OR_CMD]||Oe(n))po(n)&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==n.id)&&(this.store.scheduleCapture(),ve(n)||this.actionManager.executeAction($j));else if(a(n)||le(n)){let t;a(n)||(t=n);let r=mt(n,this.scene.getNonDeletedElementsMap()),i=r.x,o=r.y;this.startTextEditing({sceneX:i,sceneY:o,container:t}),e.preventDefault();return}else P(n)&&this.setState({editingFrame:n.id})}}if(e.key===j.SPACE&&$.pointers.size===0&&(_V=!0,this.cursor.set(Et.GRAB),e.preventDefault()),(e.key===j.G||e.key===j.S)&&!e.altKey&&!e[j.CTRL_OR_CMD]){let t=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type===`selection`&&!t.length)return;e.key===j.G&&(hi(this.state.activeTool.type)||t.some(e=>hi(e.type)))&&(this.setState({openPopup:`elementBackground`}),e.stopPropagation()),e.key===j.S&&(this.setState({openPopup:`elementStroke`}),e.stopPropagation())}if(!e[j.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===j.F){let t=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type===`selection`&&!t.length)return;(this.state.activeTool.type===`text`||t.find(e=>a(e)||Ti(e,this.scene.getNonDeletedElementsMap())))&&(e.preventDefault(),this.setState({openPopup:`fontFamily`}))}e[j.CTRL_OR_CMD]&&(e.key===j.BACKSPACE||e.key===j.DELETE)&&this.updateEditorAtom(vA,`clearCanvas`);let n=e.key.toLocaleLowerCase(),r=n===j.S&&e.shiftKey&&!e[j.CTRL_OR_CMD],i=e.key===j.I||n===j.G&&e.shiftKey;(r||i)&&this.openEyeDropper({type:r?`stroke`:`background`})})),z(this,`onKeyUp`,qM(e=>{if(this.isInteractionEnabled()){if(e.key===j.SPACE&&(this.state.viewModeEnabled&&this.state.activeTool.type!==`laser`||this.state.openDialog?.name===`elementLinkSelector`?this.cursor.set(Et.GRAB):$a(this.state.activeTool.type)?this.cursor.reset():(this.cursor.applyForTool(),this.setState({selectedElementIds:fa({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),_V=!1),e.key===j.ALT&&(this.bucketFill.closeTemporaryEyeDropper(),ai({app:this,event:e})),(e.key===j.ALT&&this.state.bindMode===`skip`||!e[j.CTRL_OR_CMD]&&!Ys(this.state))&&(this.setState({bindMode:`orbit`}),this.lastPointerMoveEvent&&pe(`COMPLEX_BINDINGS`))){let e=St({clientX:this.lastPointerMoveEvent.clientX,clientY:this.lastPointerMoveEvent.clientY},this.state),t=Nn(L(e.x,e.y),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(this.state.selectedLinearElement){let e=N.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());ft(e)&&this.handleDelayedBindModeChange(e,t)}}if(!e[j.CTRL_OR_CMD]){let t=this.state.bindingPreference===`enabled`;this.state.isBindingEnabled!==t&&((0,Uc.flushSync)(()=>{this.setState({isBindingEnabled:t})}),this.arrowText.refresh()),ai({app:this,event:e})}if(dr(e.key)){Ur(this.scene.getSelectedElements(this.state).filter(_),this.scene,this.state);let e=this.scene.getNonDeletedElementsMap();this.scene.getSelectedElements(this.state).filter(Uo).forEach(t=>{t.startBinding&&this.scene.mutateElement(t,{startBinding:{...t.startBinding,...Yo(t,e.get(t.startBinding.elementId),`start`,e)}}),t.endBinding&&this.scene.mutateElement(t,{endBinding:{...t.endBinding,...Yo(t,e.get(t.endBinding.elementId),`end`,e)}})}),this.setState({suggestedBinding:null})}this.flowchart.handleKeyEvent(e)}})),z(this,`setActiveTool`,(e,t={})=>{let{keepSelection:n=!1}=t;if(!this.isToolSupported(e.type)){console.warn(this.isInteractionEnabled()?`"${e.type}" tool is disabled via "UIOptions.canvasActions.tools.${e.type}"`:`"${e.type}" tool cannot be activated while the editor is non-interactive (see "interaction.enabled.tools")`);return}if(this.props.activeTool&&!this.isSameForcedTool(this.props.activeTool,e)){console.warn(`"${e.type}" tool activation ignored \u2014 the active tool is controlled by the host via "props.activeTool"`);return}this.drawShape.hasPendingGesture()&&this.actionManager.executeAction(PT);let r=pT.includes(e.type),i=t.toggle===!0&&r&&this.state.activeTool.type===e.type?Pt(this.state,{...this.state.activeTool.lastActiveTool||{type:this.state.preferredSelectionTool.type},lastActiveTool:null}):r&&this.state.activeTool.type!==e.type?Pt(this.state,{...e,lastActiveTool:this.state.activeTool}):Pt(this.state,e);i.type===`hand`?this.cursor.set(Et.GRAB):_V||this.cursor.applyForTool(i),ra(document.activeElement)&&this.focusContainer(),Ci(i.type)||this.setState({suggestedBinding:null}),i.type===`image`&&this.onImageToolbarButtonClick(),this.setState(e=>{let t={snapLines:e.snapLines.length?[]:e.snapLines,originSnapOffset:null,activeEmbeddable:null,selectedLinearElement:$a(i.type)?e.selectedLinearElement:null,frameToHighlight:null,hoveredArrowTextAnchor:null};return i.type===`freedraw`&&this.store.scheduleCapture(),i.type===`lasso`?{...e,...t,activeTool:i,...n?{}:{selectedElementIds:fa({},e),selectedGroupIds:fa({},e),editingGroupId:null,multiElement:null}}:i.type===`selection`?{...e,...t,activeTool:i}:{...e,...t,activeTool:i,selectedElementIds:fa({},e),selectedGroupIds:fa({},e),editingGroupId:null,multiElement:null}})}),z(this,`setOpenDialog`,e=>{this.setState({openDialog:e})}),z(this,`isTouchScreenMultiTouchGesture`,()=>$.pointers.size>=2),z(this,`getName`,()=>this.state.name||this.props.name||`${W(`labels.untitled`)}-${xa()}`),z(this,`onGestureStart`,qM(e=>{this.isNavigationEnabled()&&(e.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:fa({},this.state),activeEmbeddable:null}),$.initialScale=this.state.zoom.value)})),z(this,`onGestureChange`,qM(e=>{if(!this.isNavigationEnabled()||(e.preventDefault(),this.isTouchScreenMultiTouchGesture()))return;let t=$.initialScale;t&&this.viewport.translate(n=>({...Vs({viewportX:this.viewport.lastPosition.x,viewportY:this.viewport.lastPosition.y,nextZoom:mc(t*e.scale)},n)}),{zoomPreConstrained:!0,preserveScrollConstraintsSnapBack:!0})})),z(this,`onGestureEnd`,qM(e=>{this.isNavigationEnabled()&&(e.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:fa(this.state.previousSelectedElementIds,this.state)}),$.initialScale=null)})),z(this,`isHittingTextAutoResizeHandle`,(e,t)=>{let n=ba(e,this.state);return!!(n&&!n.isDeleted&&!n.autoResize&&cN(t,n,this.state.zoom.value,this.editorInterface.formFactor))}),z(this,`handleTextAutoResizeHandlePointerDown`,(e,t)=>{let n=ba(e,this.state);return!n||!this.isHittingTextAutoResizeHandle(e,t)?!1:(this.actionManager.executeAction(pM,`ui`,n),this.cursor.reset(),!0)}),z(this,`startTextEditing`,({sceneX:e,sceneY:t,insertAtParentCenter:n=!0,container:r,autoEdit:i=!0,initialCaretSceneCoords:a,arrowEndpoint:o})=>{let s=!1,c=o&&this.arrowText.getTextBinding(o,this.getCurrentItemStrokeWidth(`text`));c&&(r=null,n=!1,e=c.anchor[0],t=c.anchor[1]);let l=n&&this.getTextWysiwygSnappedToCenterPosition(e,t,this.state,r);r&&l&&(Ti(r,this.scene.getNonDeletedElementsMap())||(s=!0));let u=c?null:this.getSelectedTextElement(r)||this.getTextElementAtPosition(e,t),d=u?.fontFamily||this.state.currentItemFontFamily,f=u?.lineHeight||zs(d),p=this.state.currentItemFontSize;if(!u&&s&&r&&!_(r)){let n=Sn(tc({fontSize:p,fontFamily:d}),f),i=Ja(p,f),a=Math.max(r.height,i),o=Math.max(r.width,n);this.scene.mutateElement(r,{height:a,width:o}),e=r.x+o/2,t=r.y+a/2,l&&=this.getTextWysiwygSnappedToCenterPosition(e,t,this.state,r)}let m=this.getTextCreationGridPoint(e,t),h=c?{x:e,y:t}:l?{x:l.elementCenterX,y:l.elementCenterY}:u?{x:e,y:t}:{x:m?.x??e,y:m===null?t-Fr(p,f)/2:m.y},g=this.getTopLayerFrameAtSceneCoords({x:h.x,y:h.y}),v=g&&(!s||!r||r.frameId===g.id)?g.id:null,y=u||oc({x:h.x,y:h.y,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(`text`),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:``,fontSize:p,fontFamily:d,textAlign:c?.textAlign??(l?`center`:this.state.currentItemTextAlign),verticalAlign:c?.verticalAlign??(l?Pn.MIDDLE:`top`),containerId:s?r?.id:void 0,groupIds:r?.groupIds??[],lineHeight:f,angle:r?_(r)?0:r.angle:0,frameId:v});if(!u&&s&&r&&this.scene.mutateElement(r,{boundElements:(r.boundElements||[]).concat({type:`text`,id:y.id})}),this.setState({editingTextElement:y}),!u){if(r&&s){let e=this.scene.getElementIndex(r.id);this.scene.insertElementsAtIndex([y],e+1)}else this.insertNewElement(y)}o&&c&&this.arrowText.bindText(o,y,c.fixedPoint),i||u||r?this.handleTextWysiwyg(y,{isExistingElement:!!u,initialCaretSceneCoords:u?a:null}):this.setState({newElement:y,multiElement:null})}),z(this,`startImageCropping`,e=>{this.store.scheduleCapture(),this.setState({croppingElementId:e.id})}),z(this,`finishImageCropping`,()=>{this.state.croppingElementId&&(this.store.scheduleCapture(),this.setState({croppingElementId:null}))}),z(this,`shouldHandleBrowserCanvasDoubleClick`,e=>{if(e===`touch`||this.lastCompletedCanvasClicks.length===0)return!0;if(this.lastCompletedCanvasClicks.length<2)return!1;let[t,n]=this.lastCompletedCanvasClicks;return ya(L(t.x,t.y),L(n.x,n.y))<=35}),z(this,`handleCanvasDoubleClick`,e=>{if(!this.isInteractionEnabled()||this.state.editingTextElement||!this.shouldHandleBrowserCanvasDoubleClick(e.type)||this.state.multiElement||this.state.activeTool.type!==this.state.preferredSelectionTool.type&&this.state.activeTool.type!==`autoshape`)return;let t=this.scene.getSelectedElements(this.state),{x:n,y:r}=St(e,this.state);if(t.length===1&&po(t[0])){let i=t[0];if((e[j.CTRL_OR_CMD]&&Uo(i)||Oe(i))&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==i.id)){this.actionManager.executeAction($j);return}if(this.state.selectedLinearElement&&ve(t[0])){let e=N.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:n,y:r},this.state,this.scene.getNonDeletedElementsMap()),i=e?N.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,e,this.scene.getNonDeletedElementsMap()):-1;if(i&&i>-1){this.store.scheduleCapture(),N.deleteFixedSegment(t[0],this.scene,i);let a=N.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:n,y:r},this.state,this.scene.getNonDeletedElementsMap()),o=a?N.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,a,this.scene.getNonDeletedElementsMap()):null;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,segmentMidpoint:{index:o,value:e,added:!1}},segmentMidPointHoveredCoords:a}});return}}else if(this.state.selectedLinearElement?.isEditing&&this.state.selectedLinearElement.elementId===i.id&&Oe(i))return}if(t.length===1&&De(t[0])){this.startImageCropping(t[0]);return}if(this.cursor.reset(),Vi(this.state).length>0){let e=this.getElementAtPosition(n,r),t=e&&pi(e,this.state.selectedGroupIds);if(t){this.store.scheduleCapture(),this.setState(n=>({...n,...na({editingGroupId:t,selectedElementIds:{[e.id]:!0}},this.scene.getNonDeletedElements(),n,this)}));return}}if(this.cursor.reset(),!this.state.viewModeEnabled){let t=this.getElementAtPosition(n,r);if(ns(t)){this.setState({activeEmbeddable:{element:t,state:`active`}});return}if(!this.state.selectedLinearElement?.isEditing){let t=!e[j.CTRL_OR_CMD]&&this.getTextBindableContainerAtPosition(n,r);if(t&&(this.state.activeTool.type===`autoshape`||Dr(t)||!ei(t.backgroundColor)||u({point:L(n,r),element:t,elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(t)}))){let e=mt(t,this.scene.getNonDeletedElementsMap());n=e.x,r=e.y}this.startTextEditing({sceneX:n,sceneY:r,insertAtParentCenter:!e.altKey,container:t||null})}}}),z(this,`handleCanvasClick`,e=>{if(this.isInteractionEnabled()){if(e.button!==je.MAIN){this.lastCompletedCanvasClicks=[];return}this.lastCompletedCanvasClicks=[...this.lastCompletedCanvasClicks.slice(-1),{x:e.clientX,y:e.clientY}]}}),z(this,`getElementLinkAtPosition`,(e,t)=>{if(t&&t.locked)return;let n=this.scene.getNonDeletedElements(),r=-1;for(let i=n.length-1;i>=0;i--){let a=n[i];if(t&&a.id===t.id&&(r=i),a.link&&i>=r&&Mn(a,this.scene.getNonDeletedElementsMap(),this.state,L(e.x,e.y),this.editorInterface.formFactor===`phone`))return a}}),z(this,`handleElementLinkClick`,e=>{let t=ya(L(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),L(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||t>10)return;let n=St(this.lastPointerDownEvent,this.state),r=this.scene.getNonDeletedElementsMap(),i=Mn(this.hitLinkElement,r,this.state,L(n.x,n.y),this.editorInterface.formFactor===`phone`),a=St(this.lastPointerUpEvent,this.state),o=Mn(this.hitLinkElement,r,this.state,L(a.x,a.y),this.editorInterface.formFactor===`phone`);if(i&&o){CD();let t=this.hitLinkElement.link;if(t){t=Ts(t);let n;if(this.props.onLinkOpen&&(n=Fe(T.EXCALIDRAW_LINK,e.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:t},n)),!n?.defaultPrevented){let e=Da(t)?`_self`:`_blank`,n=window.open(void 0,e);n&&(n.opener=null,n.location=t)}}}}),z(this,`applyElementLinkHoverAffordance`,()=>this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(this.cursor.set(Et.POINTER),xD(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap()),!0):(CD(),!1)),z(this,`maybeHandleElementLinkClick`,(e,t)=>{if(this.editorInterface.isTouchScreen){let e=this.getElementAtPosition(t.x,t.y,{includeLockedElements:!0});this.hitLinkElement=this.getElementLinkAtPosition(t,e)}return this.hitLinkElement&&this.lastPointerDownEvent&&!this.state.selectedElementIds[this.hitLinkElement.id]?(this.handleElementLinkClick(e),!0):!1}),z(this,`handleInteractiveContentPointerMove`,e=>{let t=St(e,this.state),n=this.getElementAtPosition(t.x,t.y,{includeLockedElements:!0});if(this.isEmbedsEnabled()){let r=n?.locked?null:n;if(this.handleIframeLikeElementHover({hitElement:r,scenePointer:t,moveEvent:e}))return}this.hitLinkElement=this.isLinksEnabled()?this.getElementLinkAtPosition(t,n):void 0,this.applyElementLinkHoverAffordance()||this.cursor.reset()}),z(this,`handleInteractiveContentPointerUp`,e=>{if(this.lastPointerUpEvent=e,this.isEmbedsEnabled()&&this.handleIframeLikeCenterClick())return;let t=St(e,this.state);this.isLinksEnabled()&&this.maybeHandleElementLinkClick(e,t)||this.state.activeEmbeddable?.state===`active`&&this.setState({activeEmbeddable:null})}),z(this,`getTopLayerFrameAtSceneCoords`,(e,t)=>{let n=this.scene.getNonDeletedElementsMap(),r=this.scene.getNonDeletedFramesLikes().filter(t=>!t.locked&&x(e,t,n));if(!r.length)return null;let i=r.at(-1),a=this.getElementsAtPosition(e.x,e.y,{includeLockedElements:!0}).findLast(e=>!t?.excludeElementIds?.[e.id]);if(a){if(P(a)&&!a.locked)return i;let e=this.scene.getElementIndex(a.id),n=this.scene.getElementIndex(i.id);return e!==-1&&n!==-1&&e<=n?i:(t?.currentFrameId?r.find(e=>e.id===t.currentFrameId)??null:null)||(a.frameId?r.find(e=>e.id===a.frameId)??null:null)}return i}),z(this,`updateFrameToHighlight`,e=>{this.state.frameToHighlight!==e&&this.setState({frameToHighlight:e})}),z(this,`maybeUpdateFrameToHighlightOnPointerMove`,(e,t)=>{this.state.newElement||this.state.multiElement||this.state.selectionElement||this.state.selectedElementsAreBeingDragged||this.updateFrameToHighlight(!t&&Nr(this.state.activeTool.type)?this.getTopLayerFrameAtSceneCoords(e):null)}),z(this,`insertNewElements`,e=>{if(!e.length)return;let t=[];for(let n of e){let e=t[t.length-1];e?.[0].frameId===n.frameId?e.push(n):t.push([n])}for(let e of t){let t=e[0].frameId,n=t?gt(this.scene.getElementsIncludingDeleted(),t):null;this.scene.insertElementsAtIndex(e,n)}}),z(this,`insertNewElement`,e=>{this.insertNewElements([e]);let t=e.frameId?this.scene.getNonDeletedElement(e.frameId):null;this.updateFrameToHighlight(t&&P(t)?t:null)}),z(this,`handleCanvasPointerMove`,e=>{if(!this.isInteractionEnabled()){this.isToolSupported(this.state.activeTool.type)&&this.savePointer(e.clientX,e.clientY,this.state.cursorButton),this.isNavigationEnabled()&&this.updateMultiTouchGesture(e),(this.isLinksEnabled()||this.isEmbedsEnabled())&&!vV&&this.handleInteractiveContentPointerMove(e);return}this.savePointer(e.clientX,e.clientY,this.state.cursorButton),this.lastPointerMoveEvent=e.nativeEvent;let t=St(e,this.state),{x:n,y:r}=t;if(this.lastPointerMoveCoords={x:n,y:r},this.updateMultiTouchGesture(e),_V||vV||yV||Ro(this.state))return;let i=vN(bV,e.clientX-this.state.offsetLeft,e.clientY-this.state.offsetTop).isOverEither;if(!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.multiElement&&(i?this.cursor.set(Et.AUTO):this.cursor.applyForTool()),this.maybeUpdateFrameToHighlightOnPointerMove({x:n,y:r},i),!this.state.newElement&&HM(this.state.activeTool.type)){let{originOffset:t,snapLines:i}=VM(this.scene.getNonDeletedElements(),this,{x:n,y:r},e,this.scene.getNonDeletedElementsMap());this.setState(e=>{let n=Ni(e.snapLines,i),r=e.originSnapOffset?Ni(e.originSnapOffset,t):t;return e.snapLines===n&&e.originSnapOffset===r?null:{snapLines:n,originSnapOffset:r}})}else!this.state.newElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.selectionElement&&this.setState(e=>e.snapLines.length?{snapLines:[]}:null);if(this.state.selectedLinearElement?.isEditing&&!this.state.selectedLinearElement.isDragging){let t=this.state.newElement?null:N.handlePointerMoveInEditMode(e,n,r,this);t&&t!==this.state.selectedLinearElement&&(0,Uc.flushSync)(()=>{this.setState({selectedLinearElement:t})})}if(Qo(this.state.activeTool.type)){let{newElement:e}=this.state;if(!e&&Ys(this.state)){let e=L(n,r),t=this.scene.getNonDeletedElementsMap(),i=Nn(e,this.scene.getNonDeletedElements(),t,jn(this.state.zoom));i?this.setState({suggestedBinding:{element:i,midPoint:eo(e,i,t,this.state.zoom)}}):this.state.suggestedBinding&&this.setState({suggestedBinding:null})}}if(this.state.multiElement&&this.state.selectedLinearElement){let{multiElement:t,selectedLinearElement:i}=this.state,{x:a,y:o,points:s}=t,c=s[s.length-1],{lastCommittedPoint:l}=i;if(this.cursor.applyForTool(),c===l)ya(L(n-a,r-o),c)>=8?(this.store.scheduleCapture(),(0,Uc.flushSync)(()=>{qa(this.state.selectedLinearElement?.initialState,`initialState must be set`),this.setState({selectedLinearElement:{...this.state.selectedLinearElement,lastCommittedPoint:s[s.length-1],selectedPointsIndices:[t.points.length],initialState:{...this.state.selectedLinearElement.initialState,lastClickedPoint:t.points.length}}})}),this.scene.mutateElement(t,{points:[...s,L(n-a,r-o)]},{informMutation:!1,isDragging:!1})):this.cursor.set(Et.POINTER);else if(s.length>2&&l&&ya(L(n-a,r-o),l)<8){this.cursor.set(Et.POINTER),this.scene.mutateElement(t,{points:s.slice(0,-1)},{informMutation:!1,isDragging:!1});let e=t.points.length-1;this.setState({selectedLinearElement:{...i,selectedPointsIndices:i.selectedPointsIndices?[...new Set(i.selectedPointsIndices.map(t=>Math.min(t,e)))]:i.selectedPointsIndices,lastCommittedPoint:t.points[e],initialState:{...i.initialState,lastClickedPoint:e}}})}else{io(s,this.state.zoom.value)&&this.cursor.set(Et.POINTER);let i=this.scene.getNonDeletedElementsMap();if(Uo(t)){let e=Nn(L(n,r),this.scene.getNonDeletedElements(),i);pe(`COMPLEX_BINDINGS`)&&this.handleDelayedBindModeChange(t,e)}qa(this.state.selectedLinearElement,`Expected selectedLinearElement to be set to operate on a linear element`);let a=N.handlePointerMove(e.nativeEvent,this,n,r,this.state.selectedLinearElement);a&&this.setState(a)}return}if(this.state.activeTool.type===`arrow`&&!this.state.newElement){let e=L(n,r),t=Nn(e,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),jn(this.state.zoom)),i=this.scene.getNonDeletedElementsMap();t&&!Wn(e,t,i)&&this.setState({suggestedBinding:{element:t,midPoint:eo(e,t,i,this.state.zoom)}})}let o=!!e.buttons,s=this.state.activeTool.type===`laser`;if(o||!s&&this.state.activeTool.type!==`selection`&&this.state.activeTool.type!==`lasso`&&this.state.activeTool.type!==`text`&&this.state.activeTool.type!==`eraser`)return;let c=this.scene.getNonDeletedElements(),l=this.scene.getSelectedElements(this.state);if(this.isHittingTextAutoResizeHandle(l,t)){this.cursor.set(Et.POINTER);return}if(l.length===1&&!i&&!this.state.selectedLinearElement?.isEditing){if(this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,n,r),(!this.state.selectedLinearElement||this.state.selectedLinearElement.hoverPointIndex===-1)&&this.state.openDialog?.name!==`elementLinkSelector`&&!(l.length===1&&ve(l[0]))&&!(po(l[0])&&(this.editorInterface.userAgent.isMobileDevice||l[0].points.length===2))){let t=Sr(c,this.state,n,r,this.state.zoom,e.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);if(t&&t.transformHandleType){this.cursor.set(Lr(t));return}}}else if(l.length>1&&!i&&this.state.openDialog?.name!==`elementLinkSelector`){let t=es(Is(l),n,r,this.state.zoom,e.pointerType,this.editorInterface);if(t){this.cursor.set(Lr({transformHandleType:t}));return}}if(ji(this.state))return;let u=this.getElementAtPosition(n,r,{preferSelected:!0,includeLockedElements:!0}),d=null;d=u&&u.locked?null:u;let f=this.arrowText.updateHoveredAnchor(t);if(this.handleIframeLikeElementHover({hitElement:d,scenePointer:t,moveEvent:e})||(this.hitLinkElement=this.getElementLinkAtPosition(t,u)),!this.applyElementLinkHoverAffordance()){if(s)return;d&&(d.link||us(d))&&this.state.selectedElementIds[d.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:`info`}):this.state.activeTool.type===`text`?this.cursor.set(f?Et.POINTER:a(d)?Et.TEXT:Et.CROSSHAIR):!e[j.CTRL_OR_CMD]&&this.isHittingCommonBoundingBoxOfSelectedElements(t,l)?this.cursor.set(Et.MOVE):this.state.viewModeEnabled?this.cursor.set(Et.GRAB):this.state.openDialog?.name===`elementLinkSelector`||i?this.cursor.set(Et.AUTO):!e[j.CTRL_OR_CMD]&&d?.id!==this.state.editingTextElement?.id?(d||this.isHittingCommonBoundingBoxOfSelectedElements(t,l))&&!d?.locked&&(!d||!ve(d)||!(d.startBinding||d.endBinding))&&(this.state.activeTool.type!==`lasso`||l.length>0)&&this.cursor.set(Et.MOVE):this.cursor.set(Et.AUTO),this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,n,r)}this.state.openDialog?.name===`elementLinkSelector`&&d?this.setState(e=>({hoveredElementIds:Ni(e.hoveredElementIds,na({editingGroupId:e.editingGroupId,selectedElementIds:{[d.id]:!0}},this.scene.getNonDeletedElements(),e,this).selectedElementIds)})):this.state.openDialog?.name===`elementLinkSelector`&&!d&&this.setState(e=>({hoveredElementIds:Ni(e.hoveredElementIds,{})}))}),z(this,`handleEraser`,(e,t)=>{let n=this.eraserTrail.addPointToPath(t.x,t.y,e.altKey);this.elementsPendingErasure=new Set(n),this.triggerRender()}),z(this,`handleTouchMove`,e=>{this.isInteractionEnabled()&&(SV=!0)}),z(this,`handleCanvasPointerDown`,e=>{if(!this.isInteractionEnabled()&&!this.isToolSupported(this.state.activeTool.type)){(this.isLinksEnabled()||this.isEmbedsEnabled())&&(this.lastPointerDownEvent=e),this.isNavigationEnabled()&&(this.updateGestureOnPointerDown(e),vV||this.handleCanvasPanUsingWheelOrSpaceDrag(e));return}let t=this.scene.getSelectedElements(this.state);if(!e.ctrlKey){let e=this.state.bindingPreference===`enabled`;this.state.isBindingEnabled!==e&&this.setState({isBindingEnabled:e})}let n=St(e,this.state),{x:r,y:i}=n;this.lastPointerMoveCoords={x:r,y:i};let a=e.target;if(a.setPointerCapture&&a.setPointerCapture(e.pointerId),this.maybeCleanupAfterMissingPointerUp(e.nativeEvent),this.state.activeTool.type!==`laser`&&this.requestUnfollow(),this.state.searchMatches&&(this.setState(e=>({searchMatches:e.searchMatches&&{focusedId:null,matches:e.searchMatches.matches.map(e=>({...e,focus:!1}))}})),this.updateEditorAtom(PI,null)),ky.get(LD)&&this.updateEditorAtom(LD,null),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.state.openPopup&&this.setState({openPopup:null}),this.updateGestureOnPointerDown(e),e.pointerType===`touch`&&this.state.newElement&&this.state.newElement.type===`freedraw`){let e=this.state.newElement;this.updateScene({...e.points.length<10?{elements:this.scene.getElementsIncludingDeleted().filter(t=>t.id!==e.id)}:{},appState:{newElement:null,editingTextElement:null,suggestedBinding:null,selectedElementIds:fa(Object.keys(this.state.selectedElementIds).filter(t=>t!==e.id).reduce((e,t)=>(e[t]=this.state.selectedElementIds[t],e),{}),this.state)},captureUpdate:this.state.openDialog?.name===`elementLinkSelector`?F.EVENTUALLY:F.NEVER});return}let o=document.getSelection();if(o?.anchorNode&&o.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(e),!this.state.penDetected&&e.pointerType===`pen`&&this.setState(e=>({penMode:!0,penDetected:!0,currentItemStrokeVariability:`variable`})),!this.editorInterface.isTouchScreen&&[`pen`,`touch`].includes(e.pointerType)&&(this.editorInterface=ds(this.editorInterface,{isTouchScreen:!0})),vV||(this.lastPointerDownEvent=e,this.handleCanvasPanUsingWheelOrSpaceDrag(e)))return;if(this.setState({lastPointerDownWith:e.pointerType,cursorButton:`down`}),this.savePointer(e.clientX,e.clientY,`down`),e.button===je.ERASER&&this.isInteractionEnabled()&&!this.props.activeTool&&this.state.activeTool.type!==Ks.eraser){this.setState({activeTool:Pt(this.state,{type:Ks.eraser,lastActiveTool:this.state.activeTool})},()=>{this.handleCanvasPointerDown(e);let t=()=>{n(),r?.(),ji(this.state)&&this.setState({activeTool:Pt(this.state,{...this.state.activeTool.lastActiveTool||{type:Ks.selection},lastActiveTool:null})})},n=ki(window,T.POINTER_UP,t,{once:!0}),r;requestAnimationFrame(()=>{r=this.missingPointerEventCleanupEmitter.once(t)})});return}if(e.button!==je.MAIN&&e.button!==je.TOUCH&&e.button!==je.ERASER||$.pointers.size>1)return;let s=this.initialPointerDownState(e);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleTextAutoResizeHandlePointerDown(t,s.origin)||this.handleDraggingScrollBar(e,s)||(this.clearSelectionIfNotUsingSelection(),this.handleSelectionOnPointerDown(e,s))||!(!this.state.penMode||e.pointerType!==`touch`||this.state.activeTool.type===`selection`||this.state.activeTool.type===`lasso`||this.state.activeTool.type===`text`||this.state.activeTool.type===`image`))return;if(this.state.activeTool.type===`lasso`){let t=s.hit.element&&this.isASelectedElement(s.hit.element);(e.altKey&&e[j.CTRL_OR_CMD]&&!s.resize.handleType||!s.hit.hasHitCommonBoundingBoxOfSelectedElements&&!s.resize.handleType&&!t)&&(this.lassoTrail.hasCurrentTrail||this.lassoTrail.startPath(s.origin.x,s.origin.y,e.shiftKey),s.drag.blockDragging=this.editorInterface.formFactor===`desktop`),this.editorInterface.formFactor!==`desktop`&&s.hit.element&&!t&&(this.setState(e=>{let t={...e.selectedElementIds,[s.hit.element.id]:!0},n=[];Object.keys(e.selectedElementIds).forEach(e=>{let t=this.scene.getElement(e);t&&n.push(t)});let r=s.hit.element;if(P(r))Yn(n,r.id).forEach(e=>{delete t[e.id]});else if(r.frameId)t[r.frameId]&&delete t[r.id];else{let e=r.groupIds,i=new Set(e.flatMap(e=>yt(this.scene.getNonDeletedElements(),e)).filter(e=>P(e)).map(e=>e.id));i.size>0&&n.forEach(e=>{e.frameId&&i.has(e.frameId)&&(delete t[e.id],e.groupIds.flatMap(e=>yt(this.scene.getNonDeletedElements(),e)).forEach(e=>{delete t[e.id]}))})}return{...na({editingGroupId:e.editingGroupId,selectedElementIds:t},this.scene.getNonDeletedElements(),e,this),showHyperlinkPopup:r.link||us(r)?`info`:!1}}),s.hit.wasAddedToSelection=!0)}else this.state.activeTool.type===`text`?this.handleTextOnPointerDown(e,s):this.state.activeTool.type===`arrow`||this.state.activeTool.type===`line`?this.handleLinearElementOnPointerDown(e,this.state.activeTool.type,s):this.state.activeTool.type===`freedraw`?this.handleFreeDrawElementOnPointerDown(e,this.state.activeTool.type,s):this.state.activeTool.type===`custom`?this.cursor.applyForTool():this.state.activeTool.type===Ks.frame||this.state.activeTool.type===Ks.magicframe?this.createFrameElementOnPointerDown(s,this.state.activeTool.type):this.state.activeTool.type===`laser`?this.laserTrails.startPath(s.lastCoords.x,s.lastCoords.y):this.state.activeTool.type===`autoshape`?this.drawShape.handlePointerDown(s):this.state.activeTool.type===Ks.bucketfill?this.bucketFill.handlePointerDown(n):this.state.activeTool.type!==`eraser`&&this.state.activeTool.type!==`hand`&&this.state.activeTool.type!==`image`&&this.createGenericElementOnPointerDown(this.state.activeTool.type,s);this.props?.onPointerDown?.(this.state.activeTool,s),this.onPointerDownEmitter.trigger(this.state.activeTool,s,e),this.state.activeTool.type===`eraser`&&this.eraserTrail.startPath(s.lastCoords.x,s.lastCoords.y);let c=this.onPointerMoveFromPointerDownHandler(s),l=this.onPointerUpFromPointerDownHandler(s),u=this.onKeyDownFromPointerDownHandler(s),d=this.onKeyUpFromPointerDownHandler(s);this.missingPointerEventCleanupEmitter.once(t=>l(t||e.nativeEvent)),(!this.state.viewModeEnabled||this.isActiveToolPointerCapturing())&&(window.addEventListener(T.POINTER_MOVE,c),window.addEventListener(T.POINTER_UP,l),window.addEventListener(T.KEYDOWN,u),window.addEventListener(T.KEYUP,d),s.eventListeners.onMove=c,s.eventListeners.onUp=l,s.eventListeners.onKeyUp=d,s.eventListeners.onKeyDown=u)}),z(this,`handleCanvasPointerUp`,e=>{if(!this.isInteractionEnabled()){(this.isLinksEnabled()||this.isEmbedsEnabled())&&this.handleInteractiveContentPointerUp(e);return}if(pe(`COMPLEX_BINDINGS`)&&this.resetDelayedBindMode(),this.removePointer(e),this.lastPointerUpIsDoubleClick=this.isDoubleClick(this.lastPointerUpEvent,e),this.lastPointerUpEvent=e,!e.ctrlKey){let e=this.state.bindingPreference===`enabled`;this.state.isBindingEnabled!==e&&this.setState({isBindingEnabled:e})}let t=St({clientX:e.clientX,clientY:e.clientY},this.state),{x:n,y:r}=t;this.lastPointerMoveCoords={x:n,y:r},!this.handleIframeLikeCenterClick()&&!this.maybeHandleElementLinkClick(e,t)&&this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})}),z(this,`maybeOpenContextMenuAfterPointerDownOnTouchDevices`,e=>{e.pointerType===`touch`&&(SV=!1,xV?SV=!0:xV=window.setTimeout(()=>{xV=0,SV||this.handleCanvasContextMenu(e)},500))}),z(this,`resetContextMenuTimer`,()=>{clearTimeout(xV),xV=0,SV=!1}),z(this,`maybeCleanupAfterMissingPointerUp`,e=>{OV?.(),this.missingPointerEventCleanupEmitter.trigger(e).clear()}),z(this,`handleCanvasPanUsingWheelOrSpaceDrag`,e=>{if(!($.pointers.size<=1&&((e.button===je.WHEEL||e.button===je.MAIN&&_V||Ro(this.state))&&(this.isInteractionEnabled()||this.isNavigationEnabled())||this.state.viewModeEnabled&&!this.isActiveToolPointerCapturing())))return!1;vV=!0,this.focusContainer(),this.state.editingTextElement||e.preventDefault();let t=!1,n=/Linux/.test(window.navigator.platform);this.cursor.set(Et.GRABBING);let{clientX:r,clientY:i}=e,a=JM(e=>{let a=r-e.clientX,o=i-e.clientY;if(r=e.clientX,i=e.clientY,n&&!t&&(Math.abs(a)>1||Math.abs(o)>1)){t=!0;let e=t=>{document.body.removeEventListener(T.PASTE,e),t.stopPropagation()},n=()=>{setTimeout(()=>{document.body.removeEventListener(T.PASTE,e),window.removeEventListener(T.POINTER_UP,n)},100)};document.body.addEventListener(T.PASTE,e),window.addEventListener(T.POINTER_UP,n)}this.viewport.translate({scrollX:this.state.scrollX-a/this.state.zoom.value,scrollY:this.state.scrollY-o/this.state.zoom.value})}),o=qM(OV=()=>{OV=null,vV=!1,_V||this.cursor.reset(),this.setState({cursorButton:`up`},this.viewport.releaseOverscroll),this.savePointer(e.clientX,e.clientY,`up`),window.removeEventListener(T.POINTER_MOVE,a),window.removeEventListener(T.POINTER_UP,o),window.removeEventListener(T.BLUR,o),a.flush()});return window.addEventListener(T.BLUR,o),window.addEventListener(T.POINTER_MOVE,a,{passive:!0}),window.addEventListener(T.POINTER_UP,o),!0}),z(this,`updateMultiTouchGesture`,e=>{$.pointers.has(e.pointerId)&&$.pointers.set(e.pointerId,{x:e.clientX,y:e.clientY});let t=$.initialScale;if($.pointers.size===2&&$.lastCenter&&t&&$.initialDistance){let e=gM($.pointers),n=e.x-$.lastCenter.x,r=e.y-$.lastCenter.y;$.lastCenter=e;let i=_M(Array.from($.pointers.values())),a=this.state.activeTool.type===`freedraw`&&this.state.penMode?1:i/$.initialDistance,o=a?mc(t*a):this.state.zoom.value;this.setState(t=>{let i=Vs({viewportX:e.x,viewportY:e.y,nextZoom:o},t),a=i.zoom.value;return this.viewport.translate({zoom:i.zoom,scrollX:i.scrollX+2*n/a,scrollY:i.scrollY+2*r/a,shouldCacheIgnoreZoom:!0},{zoomPreConstrained:!0}),null}),this.viewport.isLockedTransitionPending||this.resetShouldCacheIgnoreZoomDebounced()}else $.lastCenter=$.initialDistance=$.initialScale=null}),z(this,`clearSelectionIfNotUsingSelection`,()=>{$a(this.state.activeTool.type)||this.setState({selectedElementIds:fa({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}),z(this,`handleSelectionOnPointerDown`,(e,t)=>{if($a(this.state.activeTool.type)){let n=this.scene.getNonDeletedElements(),r=this.scene.getNonDeletedElementsMap(),i=this.scene.getSelectedElements(this.state);if(i.length===1&&!this.state.selectedLinearElement?.isEditing&&!ve(i[0])&&!(po(i[0])&&(this.editorInterface.userAgent.isMobileDevice||i[0].points.length===2))&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let r=Sr(n,this.state,t.origin.x,t.origin.y,this.state.zoom,e.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);r!=null&&(r.transformHandleType===`rotation`?(this.setState({resizingElement:r.element}),t.resize.handleType=r.transformHandleType):(this.state.croppingElementId||this.setState({resizingElement:r.element}),t.resize.handleType=r.transformHandleType))}else i.length>1&&(t.resize.handleType=es(Is(i),t.origin.x,t.origin.y,this.state.zoom,e.pointerType,this.editorInterface));if(t.resize.handleType)t.resize.isResizing=!0,t.resize.offset=Qs(mr(t.resize.handleType,i,r,t.origin.x,t.origin.y)),i.length===1&&po(i[0])&&i[0].points.length===2&&(t.resize.arrowDirection=Dn(t.resize.handleType,i[0]));else{if(this.state.selectedLinearElement){let n=this.state.selectedLinearElement,r=N.handlePointerDown(e,this,this.store,t.origin,n,this.scene);if(r.hitElement&&(t.hit.element=r.hitElement),r.linearElementEditor&&this.setState({selectedLinearElement:r.linearElementEditor}),r.didAddPoint)return!0;let i=this.scene.getNonDeletedElementsMap(),a=N.getElement(n.elementId,i);if(a&&ft(a)){let{hitFocusPoint:e,pointerOffset:r,arrowOtherEndpointInitialBinding:o}=qo(a,t,i,this.state);if(e)return this.setState({selectedLinearElement:{...n,hoveredFocusPointBinding:e,draggedFocusPointBinding:e,pointerOffset:r,initialState:{...n.initialState,arrowOtherEndpointInitialBinding:o}}}),!1}}let n=this.getElementsAtPosition(t.origin.x,t.origin.y,{includeLockedElements:!0}),r=n.filter(e=>!e.locked),i=this.getElementAtPosition(t.origin.x,t.origin.y,{allHitElements:n});if((!i||i.id!==this.state.activeLockedId)&&this.setState({activeLockedId:null}),i&&i.locked&&!r.some(e=>this.state.selectedElementIds[e.id])?t.hit.element=null:t.hit.element=t.hit.element??this.getElementAtPosition(t.origin.x,t.origin.y),this.hitLinkElement=this.getElementLinkAtPosition(t.origin,i),this.hitLinkElement)return!0;if(this.state.croppingElementId&&t.hit.element?.id!==this.state.croppingElementId&&this.finishImageCropping(),t.hit.element&&this.getElementLinkAtPosition({x:t.origin.x,y:t.origin.y},t.hit.element))return!1;t.hit.allHitElements=r;let a=t.hit.element,o=t.hit.allHitElements.some(e=>this.isASelectedElement(e));if((a===null||!o)&&!e.shiftKey&&!t.hit.hasHitCommonBoundingBoxOfSelectedElements&&(!this.state.selectedLinearElement?.isEditing||a&&a?.id!==this.state.selectedLinearElement?.elementId)&&this.clearSelection(a),this.state.selectedLinearElement?.isEditing)this.setState(e=>({selectedLinearElement:e.selectedLinearElement?{...e.selectedLinearElement,isEditing:!!a&&a.id===this.state.selectedLinearElement?.elementId}:null,selectedElementIds:e.selectedLinearElement?fa({[e.selectedLinearElement.elementId]:!0},this.state):fa({},e)}));else if(a!=null){if(e[j.CTRL_OR_CMD])return e.altKey?(this.state.openDialog?.name===`elementLinkSelector`&&this.setOpenDialog(null),this.lassoTrail.startPath(t.origin.x,t.origin.y,e.shiftKey),this.setActiveTool({type:`lasso`,fromSelection:!0}),!1):(this.state.selectedElementIds[a.id]||(t.hit.wasAddedToSelection=!0),this.setState(e=>({...me(e,a),previousSelectedElementIds:this.state.selectedElementIds})),!1);this.state.selectedElementIds[a.id]||(this.state.editingGroupId&&!oa(a,this.state.editingGroupId)&&this.setState({selectedElementIds:fa({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!o&&!t.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(e=>{let t={...e.selectedElementIds,[a.id]:!0},n=[];if(Object.keys(e.selectedElementIds).forEach(e=>{let t=this.scene.getElement(e);t&&n.push(t)}),P(a))Yn(n,a.id).forEach(e=>{delete t[e.id]});else if(a.frameId)t[a.frameId]&&delete t[a.id];else{let e=a.groupIds,r=new Set(e.flatMap(e=>yt(this.scene.getNonDeletedElements(),e)).filter(e=>P(e)).map(e=>e.id));r.size>0&&n.forEach(e=>{e.frameId&&r.has(e.frameId)&&(delete t[e.id],e.groupIds.flatMap(e=>yt(this.scene.getNonDeletedElements(),e)).forEach(e=>{delete t[e.id]}))})}return e.openDialog?.name===`elementLinkSelector`&&(a.groupIds.some(t=>e.selectedGroupIds[t])||(t={[a.id]:!0})),{...na({editingGroupId:e.editingGroupId,selectedElementIds:t},this.scene.getNonDeletedElements(),e,this),showHyperlinkPopup:a.link||us(a)?`info`:!1}}),t.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1}),z(this,`handleTextOnPointerDown`,(e,t)=>{if(this.state.editingTextElement)return;let n=t.origin.x,r=t.origin.y;this.setState({hoveredArrowTextAnchor:null});let i=this.arrowText.getBindableEndpointAtPosition(n,r);if(i)this.startTextEditing({sceneX:n,sceneY:r,autoEdit:!1,arrowEndpoint:i});else{let t=this.getElementAtPosition(n,r,{includeBoundTextElement:!0}),i=this.getTextBindableContainerAtPosition(n,r);Dr(t)&&(i=t,n=t.x+t.width/2,r=t.y+t.height/2),this.startTextEditing({sceneX:n,sceneY:r,insertAtParentCenter:!e.altKey,container:i,autoEdit:!1,initialCaretSceneCoords:{x:n,y:r}})}this.isToolLocked()?this.cursor.reset():this.setState({activeTool:Pt(this.state,{type:this.state.preferredSelectionTool.type})},()=>this.cursor.reset())}),z(this,`handleFreeDrawElementOnPointerDown`,(e,t,n)=>{let[r,i]=An(n.origin.x,n.origin.y,null),a=this.getTopLayerFrameAtSceneCoords({x:r,y:i}),o=e.pressure===.5,s=this.state.currentItemStrokeVariability,c=Mi({type:t,x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(`freedraw`),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:null,simulatePressure:o,strokeOptions:{variability:s,streamline:e.pointerType===`mouse`?Pr:ct},locked:!1,frameId:a?a.id:null,points:[L(0,0)],pressures:o?[]:[e.pressure]});this.insertNewElement(c),this.setState(e=>{let t={...e.selectedElementIds};return delete t[c.id],{selectedElementIds:fa(t,e)}}),this.setState({newElement:c,suggestedBinding:null})}),z(this,`insertIframeElement`,({sceneX:e,sceneY:t,width:n,height:r})=>{let[i,a]=An(e,t,this.lastPointerDownEvent?.[j.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),o=Fn({type:`iframe`,x:i,y:a,strokeColor:`transparent`,backgroundColor:`transparent`,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(`iframe`),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness(`iframe`),opacity:this.state.currentItemOpacity,locked:!1,width:n,height:r});return this.insertNewElement(o),o}),z(this,`insertEmbeddableElement`,({sceneX:e,sceneY:t,link:n})=>{let[r,i]=An(e,t,this.lastPointerDownEvent?.[j.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=zo(n);if(!a)return;a.error instanceof URIError&&this.setToast({message:W(`toast.unrecognizedLinkFormat`),closable:!0});let o=Ge({type:`embeddable`,x:r,y:i,strokeColor:`transparent`,backgroundColor:`transparent`,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(`embeddable`),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness(`embeddable`),opacity:this.state.currentItemOpacity,locked:!1,width:a.intrinsicSize.w,height:a.intrinsicSize.h,link:n});return this.insertNewElement(o),o}),z(this,`newImagePlaceholder`,({sceneX:e,sceneY:t,addToFrameUnderCursor:n=!0})=>{let[r,i]=An(e,t,this.lastPointerDownEvent?.[j.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=n?this.getTopLayerFrameAtSceneCoords({x:r,y:i}):null,o=100/this.state.zoom.value;return y({type:`image`,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(`image`),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:null,opacity:this.state.currentItemOpacity,locked:!1,frameId:a?a.id:null,x:r-o/2,y:i-o/2,width:o,height:o})}),z(this,`handleLinearElementOnPointerDown`,(e,t,n)=>{if(e.ctrlKey&&(0,Uc.flushSync)(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!==`enabled`})}),this.state.multiElement){let{multiElement:t,selectedLinearElement:r}=this.state;if(qa(r,`selectedLinearElement is expected to be set`),t.type===`line`&&io(t.points,this.state.zoom.value)){(0,Uc.flushSync)(()=>{this.setState({selectedLinearElement:{...r,lastCommittedPoint:t.points[t.points.length-1],initialState:{...r.initialState,lastClickedPoint:-1}}})}),this.actionManager.executeAction(PT);return}if(ve(t)&&t.points.length>1){this.actionManager.executeAction(PT,`ui`,{event:e.nativeEvent,sceneCoords:{x:n.origin.x,y:n.origin.y}});return}let{x:i,y:a}=t,{lastCommittedPoint:o}=r,s=St(e,this.state),{start:c,end:l}=ft(t)&&Ys(this.state)?ks(t,new Map([[t.points.length-1,{point:t.points[t.points.length-1],isDragging:!1}]]),s.x,s.y,this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements(),this.state,{newArrow:!!this.state.newElement,zoom:this.state.zoom}):{end:{mode:void 0}},u=this.scene.getNonDeletedElementsMap(),d=c?.mode!=null&&l.mode!=null&&c.element.id===l.element.id&&!Wn(l.focusPoint,l.element,u),f=l.mode===`orbit`&&t.startBinding?.elementId!==l.element?.id,p=o&&ya(L(n.origin.x-i,n.origin.y-a),o)<8;if(f||d||t.points.length>1&&p){this.actionManager.executeAction(PT,`ui`,{event:e.nativeEvent,sceneCoords:{x:n.origin.x,y:n.origin.y}});return}this.setState(e=>({selectedElementIds:fa({...e.selectedElementIds,[t.id]:!0},e)})),this.cursor.set(Et.POINTER)}else{let[r,i]=An(n.origin.x,n.origin.y,e[j.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=this.getTopLayerFrameAtSceneCoords({x:r,y:i}),{currentItemStartArrowhead:o,currentItemEndArrowhead:s}=this.state,[c,l]=t===`arrow`?[o,s]:[null,null],u=t===`arrow`?Oa({type:t,x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(t),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemArrowType===Cr.round?{type:Jr.PROPORTIONAL_RADIUS}:null,startArrowhead:c,endArrowhead:l,locked:!1,frameId:a?a.id:null,elbowed:this.state.currentItemArrowType===Cr.elbow,fixedSegments:this.state.currentItemArrowType===Cr.elbow?[]:null}):re({type:t,x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(t),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemRoundness===`round`?{type:Jr.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:a?a.id:null}),d=L(n.origin.x,n.origin.y),f=this.scene.getNonDeletedElementsMap(),p=Ys(this.state)?Nn(d,this.scene.getNonDeletedElements(),f):null;this.scene.mutateElement(u,{points:[L(0,0),L(0,0)]}),this.insertNewElement(u),ft(u)&&Ct(u,new Map([[0,{point:L(0,0),isDragging:!1}]]),d[0],d[1],this.scene,this.state,{newArrow:!0,altKey:e.altKey,initialBinding:!0,angleLocked:Be(e.nativeEvent)}),(0,Uc.flushSync)(()=>{this.setState(t=>{let r=null,i=t.selectedElementIds;if(po(u)){r=new N(u,this.scene.getNonDeletedElementsMap());let t=u.points.length-1;r={...r,selectedPointsIndices:[t],initialState:{...r.initialState,arrowStartIsInside:e.altKey,lastClickedPoint:t,origin:L(n.origin.x,n.origin.y)}}}return i=this.isToolLocked()?t.selectedElementIds:fa({[u.id]:!0},t),{...t,bindMode:`orbit`,newElement:u,suggestedBinding:p&&ft(u)?{element:p,midPoint:eo(d,p,f,this.state.zoom)}:null,selectedElementIds:i,selectedLinearElement:r}})}),ft(u)&&pe(`COMPLEX_BINDINGS`)&&this.handleDelayedBindModeChange(u,p)}}),z(this,`createGenericElementOnPointerDown`,(e,t)=>{let[n,r]=An(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[j.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),i=this.getTopLayerFrameAtSceneCoords({x:n,y:r}),a={x:n,y:r,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(e),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.getCurrentItemRoundness(e),locked:!1,frameId:i?i.id:null},o;o=e===`embeddable`?Ge({type:`embeddable`,...a}):pc({type:e,...a}),o.type===`selection`?this.setState({selectionElement:o}):(this.insertNewElement(o),this.setState({multiElement:null,newElement:o}))}),z(this,`createFrameElementOnPointerDown`,(e,t)=>{let[n,r]=An(e.origin.x,e.origin.y,this.lastPointerDownEvent?.[j.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),i={x:n,y:r,opacity:this.state.currentItemOpacity,locked:!1,...Wr},a=t===Ks.magicframe?on(i):at(i);this.insertNewElement(a),this.setState({multiElement:null,newElement:a})}),z(this,`restoreReadyToEraseElements`,()=>{this.elementsPendingErasure=new Set,this.triggerRender()}),z(this,`eraseElements`,()=>{let e=!1;this.elementsPendingErasure.forEach(e=>{let t=this.scene.getElement(e);if(ft(t)){if(t.startBinding){let e=this.scene.getElement(t.startBinding.elementId);ir(e,this.scene.getElementsMapIncludingDeleted(),{boundElements:e.boundElements.filter(e=>e.id!==t.id)})}if(t.endBinding){let e=this.scene.getElement(t.endBinding.elementId);ir(e,this.scene.getElementsMapIncludingDeleted(),{boundElements:e.boundElements.filter(e=>e.id!==t.id)})}}else Tt(t)&&t.boundElements?.forEach(e=>{if(e.type===`arrow`){let n=this.scene.getElement(e.id);n?.startBinding?.elementId===t.id&&ir(n,this.scene.getElementsMapIncludingDeleted(),{startBinding:null}),n?.endBinding?.elementId===t.id&&ir(n,this.scene.getElementsMapIncludingDeleted(),{endBinding:null})}})});let t=this.scene.getElementsIncludingDeleted().map(t=>this.elementsPendingErasure.has(t.id)||t.frameId&&this.elementsPendingErasure.has(t.frameId)||cs(t)&&this.elementsPendingErasure.has(t.containerId)?(e=!0,R(t,{isDeleted:!0})):t);this.elementsPendingErasure=new Set,e&&(this.store.scheduleCapture(),this.scene.replaceAllElements(t))}),z(this,`initializeImage`,async(e,t)=>{if(!Mt(t))throw Error(W(`errors.unsupportedFileType`));let n=t.type;if(this.cursor.set(`wait`),n===M.svg)try{t=Fa(cr(await t.text()),t.name)}catch(e){throw console.warn(e),Error(W(`errors.svgImageInsertError`))}let r=await(this.props.generateIdForFile?.(t)||wt(t));if(!r)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),Error(W(`errors.imageInsertError`));if(!this.files[r]?.dataURL){let{maxWidthOrHeight:e,maxFileSizeBytes:n}=this.props.imageOptions;try{t=await Lo(t,{maxWidthOrHeight:e})}catch(e){console.error(`Error trying to resizing image file on insertion`,e)}if(t.size>n)throw Error(W(`errors.fileTooBig`,{maxSize:`${Math.trunc(n/1024/1024)}MB`}))}let i=this.files[r]?.dataURL||await d(t);return new Promise(async(t,a)=>{try{let a=this.getLatestInitializedImageElement(e,r);if(this.addMissingFiles([{mimeType:n,id:r,dataURL:i,created:Date.now(),lastRetrieved:Date.now()}]),!this.imageCache.get(r)){this.addNewImagesToImageCache();let{erroredFiles:e}=await this.updateImageCache([a]);if(e.size)throw Error(`Image cache update resulted with an error.`)}let o=await this.imageCache.get(r)?.image;if(o&&this.state.newElement?.id!==a.id){a=this.getLatestInitializedImageElement(e,r);let t=this.getImageNaturalDimensions(a,o);Object.assign(a,t)}t(a)}catch(e){console.error(e),a(Error(W(`errors.imageInsertError`)))}})}),z(this,`getLatestInitializedImageElement`,(e,t)=>{let n=this.scene.getElement(e.id)??e;return R(n,{fileId:t})}),z(this,`onImageToolbarButtonClick`,async()=>{try{let e=this.state.width/2+this.state.offsetLeft,t=this.state.height/2+this.state.offsetTop,{x:n,y:r}=St({clientX:e,clientY:t},this.state),i=await Cc({description:`Image`,extensions:Object.keys(it),multiple:!0});this.insertImages(i,n,r)}catch(e){e.name===`AbortError`?console.warn(e):console.error(e),this.setState({newElement:null,activeTool:Pt(this.state,{type:this.state.preferredSelectionTool.type})},()=>{this.actionManager.executeAction(PT)})}}),z(this,`getImageNaturalDimensions`,(e,t)=>{let n=Math.max(this.state.height-120,160),r=Math.min(n,Math.floor(this.state.height*.5)/this.state.zoom.value),i=Math.min(t.naturalHeight,r),a=i*(t.naturalWidth/t.naturalHeight);return{x:e.x+e.width/2-a/2,y:e.y+e.height/2-i/2,width:a,height:i,crop:null}}),z(this,`updateImageCache`,async(e,t=this.files)=>{let{updatedFiles:n,erroredFiles:r}=await Pi({imageCache:this.imageCache,fileIds:e.map(e=>e.fileId),files:t});return r.size&&(this.store.scheduleAction(F.NEVER),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(e=>ae(e)&&r.has(e.fileId)?R(e,{status:`error`}):e))),{updatedFiles:n,erroredFiles:r}}),z(this,`addNewImagesToImageCache`,async(e=Zs(this.scene.getNonDeletedElements()),t=this.files)=>{let n=e.filter(e=>!e.isDeleted&&!this.imageCache.has(e.fileId));if(n.length){let{updatedFiles:e}=await this.updateImageCache(n,t);if(e.size)for(let t of n)e.has(t.fileId)&&fr.delete(t);e.size&&this.scene.triggerUpdate()}}),z(this,`scheduleImageRefresh`,(0,Hc.default)(()=>{this.addNewImagesToImageCache()},500)),z(this,`handleInteractiveCanvasRef`,e=>{e===null?(this.interactiveCanvas?.removeEventListener(T.TOUCH_START,this.onTouchStart),this.interactiveCanvas?.removeEventListener(T.TOUCH_END,this.onTouchEnd)):(this.interactiveCanvas=e,this.cursor.reset(),this.interactiveCanvas.addEventListener(T.TOUCH_START,this.onTouchStart,{passive:!1}),this.interactiveCanvas.addEventListener(T.TOUCH_END,this.onTouchEnd))}),z(this,`insertImages`,async(e,t,n)=>{let r=50/this.state.zoom.value,i=bn(e.map(()=>this.newImagePlaceholder({sceneX:t,sceneY:n})),t,n,r);this.insertNewElements(i);let a=await Promise.all(i.map(async(t,n)=>{try{return await this.initializeImage(t,await Cs(e[n]))}catch(e){return this.setState({errorMessage:e.message||W(`errors.imageInsertError`)}),R(t,{isDeleted:!0})}})),o=ui(a),s=bn(a.filter(e=>!e.isDeleted),t,n,r),c=ui(s),l=this.scene.getElementsIncludingDeleted().map(e=>c.get(e.id)??o.get(e.id)??e);this.updateScene({appState:{selectedElementIds:fa(Object.fromEntries(s.map(e=>[e.id,!0])),this.state)},elements:l,captureUpdate:F.IMMEDIATELY}),this.setState({},()=>{this.actionManager.executeAction(PT)})}),z(this,`handleAppOnDrop`,async e=>{if(!this.isInteractionEnabled())return;let{x:t,y:n}=St(e,this.state),r=await rE(e),i=r.getFiles();if(i.length===1){let{file:e,fileHandle:t}=i[0];if(e&&(e.type===M.png||e.type===M.svg))try{let n=await ps(e,this.state,this.scene.getElementsIncludingDeleted(),t);this.syncActionResult({...n,appState:{...n.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:F.IMMEDIATELY});return}catch(e){if(e.name!==`EncodingError`)throw Error(W(`alerts.couldNotLoadInvalidFile`))}}let a=i.map(e=>e.file).filter(e=>Mt(e));if(a.length>0&&this.isToolSupported(`image`))return this.insertImages(a,t,n);let o=r.getData(M.excalidrawlibIds),s=r.getData(M.excalidrawlib);if(o||s){try{let t=null;if(o){let{itemIds:e}=JSON.parse(o);t=(await this.library.getLatestLibrary()).filter(t=>e.includes(t.id))}else s&&(t=Rr(s));t?.length&&(t=t.map(e=>({...e,elements:bc({type:`everything`,elements:e.elements,randomizeSeed:!0,preserveFrameChildrenOrder:!0}).duplicatedElements})),this.addElementsFromPasteOrLibrary({elements:jO(t),position:e,files:null}))}catch(e){this.setState({errorMessage:e.message})}return}if(i.length>0){let{file:e,fileHandle:t}=i[0];e&&await this.loadFileToCanvas(e,t)}let c=r.findByType(M.text);if(c){let e=c.value;if(e&&En(e,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(e)||zo(e)?.type===`video`)){let r=this.insertEmbeddableElement({sceneX:t,sceneY:n,link:Ts(e)});r&&(this.store.scheduleCapture(),this.setState({selectedElementIds:{[r.id]:!0}}))}}}),z(this,`loadFileToCanvas`,async(e,t)=>{e=await Cs(e);try{let n=this.scene.getElementsIncludingDeleted(),r;try{r=await pr(e,this.state,n,t)}catch(e){let t=e instanceof so;if(t&&e.code===`IMAGE_NOT_CONTAINS_SCENE_DATA`&&!this.isToolSupported(`image`)){this.setState({isLoading:!1,errorMessage:W(`errors.imageToolNotSupported`)});return}let n=W(t?`alerts.cannotRestoreFromImage`:`alerts.couldNotLoadInvalidFile`);this.setState({isLoading:!1,errorMessage:n})}if(!r)return;r.type===M.excalidraw?(ti(n.concat(r.data.elements)),this.store.scheduleMicroAction({action:F.NEVER,elements:n,appState:void 0}),this.setState({isLoading:!0}),this.syncActionResult({...r.data,appState:{...r.data.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:F.IMMEDIATELY})):r.type===M.excalidrawlib&&await this.library.updateLibrary({libraryItems:e,merge:!0,openLibraryMenu:!0}).catch(e=>{console.error(e),this.setState({errorMessage:W(`errors.importLibraryError`)})})}catch(e){this.setState({isLoading:!1,errorMessage:e.message})}}),z(this,`handleCanvasContextMenu`,e=>{if(e.preventDefault(),!this.isInteractionEnabled()||(this.bucketFill.cancel(),(`pointerType`in e.nativeEvent&&e.nativeEvent.pointerType===`touch`||`pointerType`in e.nativeEvent&&e.nativeEvent.pointerType===`pen`&&e.button!==je.SECONDARY)&&this.state.activeTool.type!==this.state.preferredSelectionTool.type))return;let{x:t,y:n}=St(e,this.state),r=this.getElementAtPosition(t,n,{preferSelected:!0,includeLockedElements:!0}),i=this.scene.getSelectedElements(this.state),a=this.isHittingCommonBoundingBoxOfSelectedElements({x:t,y:n},i),o=r||a?`element`:`canvas`,{top:s,left:c}=this.excalidrawContainerRef.current.getBoundingClientRect(),l=e.clientX-c,u=e.clientY-s;xC(`contextMenu`,`openContextMenu`,o),this.setState({...r&&!this.state.selectedElementIds[r.id]?{...this.state,...na({editingGroupId:this.state.editingGroupId,selectedElementIds:{[r.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:po(r)?new N(r,this.scene.getNonDeletedElementsMap()):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:u,left:l,items:this.getContextMenuItems(o)}})})}),z(this,`maybeDragNewGenericElement`,(e,t,n=!0)=>{let r=this.state.selectionElement,i=e.lastCoords;if(r&&e.boxSelection.hasOccurred&&this.state.activeTool.type!==`eraser`){Ae({newElement:r,elementType:this.state.activeTool.type,originX:e.origin.x,originY:e.origin.y,x:i.x,y:i.y,width:Jn(e.origin.x,i.x),height:Jn(e.origin.y,i.y),shouldMaintainAspectRatio:Wa(t),shouldResizeFromCenter:!1,scene:this.scene,zoom:this.state.zoom.value,informMutation:!1});return}let a=this.state.newElement;if(!a||this.arrowText.maybeDragNewText(a,i))return;let[o,s]=An(i.x,i.y,t[j.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),c=ae(a)&&this.imageCache.get(a.fileId)?.image,l=c&&!(c instanceof Promise)?c.width/c.height:null;this.maybeCacheReferenceSnapPoints(t,[a]);let{snapOffset:u,snapLines:d}=BM(a,this,t,{x:e.originInGrid.x+(this.state.originSnapOffset?.x??0),y:e.originInGrid.y+(this.state.originSnapOffset?.y??0)},{x:o-e.originInGrid.x,y:s-e.originInGrid.y},this.scene.getNonDeletedElementsMap());o+=u.x,s+=u.y,this.setState({snapLines:d}),ft(a)||Ae({newElement:a,elementType:this.state.activeTool.type,originX:e.originInGrid.x,originY:e.originInGrid.y,x:o,y:s,width:Jn(e.originInGrid.x,o),height:Jn(e.originInGrid.y,s),shouldMaintainAspectRatio:De(a)?!Wa(t):Wa(t),shouldResizeFromCenter:hr(t),zoom:this.state.zoom.value,scene:this.scene,widthAspectRatio:l,originOffset:this.state.originSnapOffset,informMutation:n}),this.setState({newElement:a}),(this.state.activeTool.type===Ks.frame||this.state.activeTool.type===Ks.magicframe)&&this.setState({elementsToHighlight:Os(this.scene.getNonDeletedElements(),a,this.state,this.scene.getNonDeletedElementsMap())})}),z(this,`maybeHandleCrop`,(e,t)=>{if(!this.state.croppingElementId)return!1;let n=e.resize.handleType,r=e.lastCoords,[i,a]=An(r.x-e.resize.offset.x,r.y-e.resize.offset.y,t[j.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),o=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(n&&o&&De(o)){let s=e.originalElements.get(o.id),c=ae(o)&&this.imageCache.get(o.fileId)?.image;if(s&&De(s)&&c&&!(c instanceof Promise)){let[l,u]=An(r.x,r.y,t[j.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),d={x:l-e.originInGrid.x,y:u-e.originInGrid.y};this.maybeCacheReferenceSnapPoints(t,[o]);let{snapOffset:f,snapLines:p}=zM([o],[s],this,t,d,n);this.scene.mutateElement(o,Sc(o,this.scene.getNonDeletedElementsMap(),n,c.naturalWidth,c.naturalHeight,i+f.x,a+f.y,t.shiftKey?s.width/s.height:void 0)),La(o,this.scene),this.setState({isCropping:n&&n!==`rotation`,snapLines:p})}return!0}return!1}),z(this,`maybeHandleResize`,(e,t)=>{let n=this.scene.getSelectedElements(this.state),r=n.filter(P),i=e.resize.handleType;if(r.length>0&&i===`rotation`||n.length===1&&ve(n[0])||this.state.croppingElementId)return!1;this.setState({isResizing:i&&i!==`rotation`,isRotating:i===`rotation`,activeEmbeddable:null});let a=e.lastCoords,[o,s]=An(a.x-e.resize.offset.x,a.y-e.resize.offset.y,t[j.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),c=new Map;if(r.forEach(e=>{Yn(this.scene.getNonDeletedElements(),e.id).forEach(t=>{c.set(e.id+t.id,{x:t.x-e.x,y:t.y-e.y})})}),!this.state.selectedElementsAreBeingDragged){let[r,c]=An(a.x,a.y,t[j.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l={x:r-e.originInGrid.x,y:c-e.originInGrid.y},u=[...e.originalElements.values()];this.maybeCacheReferenceSnapPoints(t,n);let{snapOffset:d,snapLines:f}=zM(n,xt(u,this.state),this,t,l,i);o+=d.x,s+=d.y,this.setState({snapLines:f})}if(Qe(e.originalElements,i,n,this.scene,Be(t),hr(t),n.some(e=>De(e))?!Wa(t):Wa(t),o,s,e.resize.center.x,e.resize.center.y)){let e=new Set;return r.forEach(t=>{Os(this.scene.getNonDeletedElements(),t,this.state,this.scene.getNonDeletedElementsMap()).forEach(t=>{dc(t)?e.add(t):console.error(`[NONDELETED][INVARIANT] Skipped highlighting deleted element in resizing frame`)})}),this.setState({elementsToHighlight:[...e]}),!0}return!1}),z(this,`getContextMenuItems`,e=>{let t=[];if(t.push(ZE,XE),e===`canvas`)return this.state.viewModeEnabled?[...t,$E,eD,Qk,iD]:[JE,mF,ZE,XE,QE,mF,vC,OD,mF,$E,tD,nD,rD,eD,Qk,iD];if(t.push(QE),this.state.viewModeEnabled)return[qE,...t];let n=this.editorInterface.formFactor===`desktop`?[mF,mC,hC,gC,_C]:[];return[mF,YE,qE,JE,mF,rM,iM,aM,mF,tM,mF,...t,mF,TE,EE,mF,AE,pM,aD,oD,lD,jE,mF,RE,...n,mF,UE,WE,mF,$j,mF,TD,oO,mF,yC,DD,mF,pC]}),z(this,`handleWheel`,qM(e=>{if(!this.isNavigationEnabled())return;if(!(e.target instanceof HTMLCanvasElement||e.target instanceof HTMLTextAreaElement||e.target instanceof HTMLIFrameElement||e.target instanceof HTMLElement&&e.target.classList.contains(D.FRAME_NAME))){e[j.CTRL_OR_CMD]&&e.preventDefault();return}if(e.preventDefault(),vV)return;let{deltaX:t,deltaY:n}=e;if(e.metaKey||e.ctrlKey){let e=Math.sign(n),t=Bo*100,r=Math.abs(n),i=n;r>t&&(i=t*e);let a=this.state.zoom.value-i/100;a+=Math.log10(Math.max(1,this.state.zoom.value))*-e*Math.min(1,r/20);let o=this.state.scrollConstraints?.lockZoom?this.state.scrollConstraints.zoom:zi;a=Math.max(a,o),this.viewport.translate(e=>({...Vs({viewportX:this.viewport.lastPosition.x,viewportY:this.viewport.lastPosition.y,nextZoom:mc(a)},e),shouldCacheIgnoreZoom:!0}),{zoomPreConstrained:!0,preserveScrollConstraintsSnapBack:!0})&&this.resetShouldCacheIgnoreZoomDebounced();return}if(e.shiftKey){this.viewport.translate(({zoom:e,scrollX:r})=>({scrollX:r-(n||t)/e.value}));return}this.viewport.translate(({zoom:e,scrollX:r,scrollY:i})=>({scrollX:r-t/e.value,scrollY:i-n/e.value}))})),z(this,`savePointer`,(e,t,n)=>{if(!this.isInteractionEnabled()&&!this.isToolSupported(this.state.activeTool.type)||!e||!t)return;let{x:r,y:i}=St({clientX:e,clientY:t},this.state),a={x:r,y:i,tool:this.state.activeTool.type===`laser`?`laser`:`pointer`};this.props.onPointerUpdate?.({pointer:a,button:n,pointersMap:$.pointers})}),z(this,`resetShouldCacheIgnoreZoomDebounced`,ke(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300)),z(this,`updateDOMRect`,e=>{if(this.excalidrawContainerRef?.current){let{width:t,height:n,left:r,top:i}=this.excalidrawContainerRef.current.getBoundingClientRect(),{width:a,height:o,offsetTop:s,offsetLeft:c}=this.state;if(t===a&&n===o&&r===c&&i===s){e&&e();return}this.setState({width:t,height:n,offsetLeft:r,offsetTop:i},()=>{e&&e()}),this.viewport.constrain()}}),z(this,`refresh`,()=>{this.setState({...this.getCanvasOffsets()})}),z(this,`watchState`,()=>{});let n=ht(),{viewModeEnabled:r=!1,zenModeEnabled:i=!1,gridModeEnabled:o=!1,objectsSnapModeEnabled:c=!1,theme:l=n.theme,name:f=`${W(`labels.untitled`)}-${xa()}`}=t,p=null;t.activeTool&&(t.activeTool.type===`image`?console.warn(`"image" tool cannot be forced via "props.activeTool"`):this.isToolSupported(t.activeTool.type,t)?p=Pt(n,t.activeTool):console.warn(`"${t.activeTool.type}" tool ("props.activeTool") cannot be activated \u2014 disabled via "UIOptions.tools", or not enabled while non-interactive (see "interaction.enabled.tools")`)),this.state={...n,theme:l,exportWithDarkMode:l===A.DARK,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:!this.isInteractionEnabled(t)||r,activeTool:p??n.activeTool,zenModeEnabled:i,objectsSnapModeEnabled:c,gridModeEnabled:o??n.gridModeEnabled,name:f,width:window.innerWidth,height:window.innerHeight},this.refreshEditorInterface(),this.stylesPanelMode=sr(this.editorInterface),this.id=ls(),this.library=new AO(this),this.actionManager=new hM(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new Ha,this.canvas=document.createElement(`canvas`),this.rc=Ai.canvas(this.canvas),this.renderer=new UM(this.scene),this.visibleElements=[],this.store=new _o(this),this.history=new cM(this.store),this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new Ar(this.scene),this.history=new cM(this.store),this.actionManager.registerAll(uC),this.actionManager.registerAction(dM(this.history)),this.actionManager.registerAction(fM(this.history)),this.api=this.createExcalidrawAPI()}createExcalidrawAPI(){return{isDestroyed:!1,updateScene:this.updateScene,applyDeltas:this.applyDeltas,mutateElement:this.mutateElement,updateLibrary:this.library.updateLibrary,addFiles:this.addFiles,resetScene:this.resetScene,getSceneElementsIncludingDeleted:this.getSceneElementsIncludingDeleted,getSceneElementsMapIncludingDeleted:this.getSceneElementsMapIncludingDeleted,history:{clear:this.resetHistory},setViewport:this.viewport.setViewport,getViewportOffsets:this.viewport.getOffsets,getSceneElements:this.getSceneElements,getAppState:()=>this.state,getFiles:()=>this.files,getName:this.getName,registerAction:e=>{this.actionManager.registerAction(e)},refresh:this.refresh,setToast:this.setToast,id:this.id,setActiveTool:this.setActiveTool,setCursor:this.cursor.set,resetCursor:this.cursor.reset,getEditorInterface:()=>this.editorInterface,updateFrameRendering:this.updateFrameRendering,toggleSidebar:this.toggleSidebar,onChange:e=>this.onChangeEmitter.on(e),onIncrement:e=>this.store.onStoreIncrementEmitter.on(e),onPointerDown:e=>this.onPointerDownEmitter.on(e),onPointerUp:e=>this.onPointerUpEmitter.on(e),onScrollChange:e=>this.onScrollChangeEmitter.on(e),onUserFollow:e=>this.onUserFollowEmitter.on(e),onStateChange:this.onStateChange,onEvent:this.onEvent}}isInteractionEnabled(e=this.props){return e.interaction!==!1&&typeof e.interaction!=`object`}isLinksEnabled(e=this.props){return typeof e.interaction==`object`&&e.interaction!==null?e.interaction.enabled?.links===!0||e.interaction.enabled?.interactiveContent===!0:e.interaction!==!1}isNavigationEnabled(e=this.props){return typeof e.interaction==`object`&&e.interaction!==null?e.interaction.enabled?.navigation===!0:e.interaction!==!1}isEmbedsEnabled(e=this.props){return typeof e.interaction==`object`&&e.interaction!==null?e.interaction.enabled?.embeds===!0||e.interaction.enabled?.interactiveContent===!0:e.interaction!==!1}isBrowserZoomEnabled(e=this.props){return typeof e.interaction==`object`&&e.interaction!==null&&e.interaction.enabled?.browserZoom===!0}isToolLocked(){return this.state.activeTool.locked||this.props.activeTool!=null}isActiveToolPointerCapturing(){return this.isInteractionEnabled()?this.state.activeTool.type===`laser`||this.state.activeTool.type===`custom`:this.isToolSupported(this.state.activeTool.type)}isDefaultUIEnabled(e=this.props){return e.ui!==!1&&(typeof e.ui!=`object`||e.ui===null)}isUIControlEnabled(e,t=this.props){return typeof t.ui==`object`&&t.ui!==null?t.ui.enabled?.[e]===!0:t.ui!==!1}onWindowMessage(e){if(e.origin!==`https://player.vimeo.com`&&e.origin!==`https://www.youtube.com`)return;let t=null;try{t=JSON.parse(e.data)}catch{}if(t)switch(e.origin){case`https://player.vimeo.com`:if(t.method===`paused`){let n=null,r=document.body.querySelectorAll(`iframe.excalidraw__embeddable`);if(!r)break;for(let t of r)t.contentWindow===e.source&&(n=t.contentWindow);n?.postMessage(JSON.stringify({method:t.value?`play`:`pause`,value:!0}),`*`)}break;case`https://www.youtube.com`:if(t.event===`infoDelivery`&&t.info&&t.id&&typeof t.info.playerState==`number`){let e=t.id,n=t.info.playerState;Object.values(Us).includes(n)&&CV.set(e,n)}break}}handleSkipBindMode(){if(this.state.selectedLinearElement?.initialState&&!this.state.selectedLinearElement.initialState.arrowStartIsInside){qa(this.lastPointerMoveCoords,`Missing last pointer move coords when changing bind skip mode for arrow start`);let e=this.scene.getNonDeletedElementsMap(),t=Nn(L(this.lastPointerMoveCoords.x,this.lastPointerMoveCoords.y),this.scene.getNonDeletedElements(),e),n=N.getElement(this.state.selectedLinearElement.elementId,e);n?.startBinding&&t?.id===n.startBinding.elementId&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,arrowStartIsInside:!0}}})}if(this.state.bindMode===`orbit`&&(this.bindModeHandler&&=(clearTimeout(this.bindModeHandler),null),(0,Uc.flushSync)(()=>{this.setState({bindMode:`skip`})}),this.lastPointerMoveCoords&&this.state.selectedLinearElement?.selectedPointsIndices&&this.state.selectedLinearElement?.selectedPointsIndices.length)){let{x:e,y:t}=this.lastPointerMoveCoords,n=this.lastPointerMoveEvent??this.lastPointerDownEvent?.nativeEvent;qa(n,`Last event must exist`);let r=e-this.state.selectedLinearElement.pointerOffset.x,i=t-this.state.selectedLinearElement.pointerOffset.y,a=this.state.multiElement?N.handlePointerMove(n,this,r,i,this.state.selectedLinearElement):N.handlePointDragging(n,this,r,i,this.state.selectedLinearElement);a&&this.setState(a)}}resetDelayedBindMode(){this.bindModeHandler&&=(clearTimeout(this.bindModeHandler),null),this.state.bindMode!==`orbit`&&setTimeout(()=>this.setState({bindMode:`orbit`}))}handleDelayedBindModeChange(e,t){if(e.isDeleted||ve(e))return;let n=()=>{if(this.bindModeHandler=null,qa(this.lastPointerMoveCoords,`Expected lastPointerMoveCoords to be set`),!this.state.multiElement){if(!this.state.selectedLinearElement||!this.state.selectedLinearElement.selectedPointsIndices||!this.state.selectedLinearElement.selectedPointsIndices.length)return;let t=this.state.selectedLinearElement.selectedPointsIndices.includes(0),n=this.state.selectedLinearElement.selectedPointsIndices.includes(e.points.length-1);if(!t&&!n||t&&n)return}let{x:t,y:n}=this.lastPointerMoveCoords,r=Nn(L(t,n),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(r&&this.state.bindMode!==`skip`){qa(this.state.selectedLinearElement?.elementId===e.id,`The selectedLinearElement is expected to not change while a bind mode timeout is ticking`);let i=this.state.selectedLinearElement.initialState.arrowStartIsInside||e.startBinding?.elementId===r.id;(0,Uc.flushSync)(()=>{qa(this.state.selectedLinearElement,`this.state.selectedLinearElement must exist`),this.setState({bindMode:`inside`,selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,arrowStartIsInside:i}}})});let a=this.lastPointerMoveEvent??this.lastPointerDownEvent?.nativeEvent;qa(a,`Last event must exist`);let o=t-this.state.selectedLinearElement.pointerOffset.x,s=n-this.state.selectedLinearElement.pointerOffset.y,c=this.state.multiElement?N.handlePointerMove(a,this,o,s,this.state.selectedLinearElement):N.handlePointDragging(a,this,o,s,this.state.selectedLinearElement);c&&this.setState(c)}},r=!1;if(this.state.selectedLinearElement?.selectedPointsIndices){let n=this.scene.getNonDeletedElementsMap(),i=this.state.selectedLinearElement.selectedPointsIndices.includes(0),a=this.state.selectedLinearElement.selectedPointsIndices.includes(e.points.length-1),o=i?t:e.startBinding&&n.get(e.startBinding.elementId),s=a?t:e.endBinding&&n.get(e.endBinding.elementId),c=o&&Zt(o,n),l=s&&Zt(s,n);r=!!(c&&l&&o.id!==s.id&&Yr(c,l))}let i=this.state.selectedLinearElement?.selectedPointsIndices?.includes(0),a=this.state.selectedLinearElement?.selectedPointsIndices?.includes(e.points.length-1),o=i?`startBinding`:a?`endBinding`:null,s=i?`endBinding`:a?`startBinding`:null,c=s&&e[s]?.mode===`inside`&&e[s]?.elementId===t?.id||o&&e[o]?.mode===`inside`&&t?.id===e[o]?.elementId;o&&s&&e[o]?.mode===`inside`&&t?.id!==e[o]?.elementId&&e[s]?.elementId!==e[o]?.elementId&&this.scene.mutateElement(e,{[o]:{...e[o],mode:`orbit`}},{informMutation:!1,isDragging:!0}),!t||this.previousHoveredBindableElement&&t.id!==this.previousHoveredBindableElement.id?(this.bindModeHandler&&=(clearTimeout(this.bindModeHandler),null),this.state.bindMode===`inside`&&(0,Uc.flushSync)(()=>{this.setState({bindMode:`orbit`})}),this.previousHoveredBindableElement=null):!this.bindModeHandler&&(!this.state.newElement||!e.startBinding||r)&&!c&&(this.bindModeHandler=setTimeout(n,700)),this.previousHoveredBindableElement=t}cacheEmbeddableRef(e,t){t&&this.iFrameRefs.set(e.id,t)}getHTMLIFrameElement(e){return this.iFrameRefs.get(e.id)}handleIframeLikeCenterClick(){if(!this.lastPointerDownEvent||!this.lastPointerUpEvent||this.lastPointerDownEvent.button!==je.MAIN||_V||!gn(this.state.activeTool.type,[`laser`,`selection`,`lasso`]))return!1;let e=L(St({clientX:this.lastPointerDownEvent.clientX,clientY:this.lastPointerDownEvent.clientY},this.state)),t=L(St({clientX:this.lastPointerUpEvent.clientX,clientY:this.lastPointerUpEvent.clientY},this.state));if(ya(e,t)>10)return!1;let n=this.getElementAtPosition(e[0],e[1]);if(!(n&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<=300&&$.pointers.size<2&&ns(n)&&(this.state.viewModeEnabled||this.state.activeTool.type===`laser`||this.isIframeLikeElementCenter(n,this.lastPointerUpEvent,t[0],t[1]))))return!1;let r=n;if(this.state.activeEmbeddable?.element===r&&this.state.activeEmbeddable?.state===`active`||(setTimeout(()=>{this.setState({activeEmbeddable:{element:r,state:`active`},selectedElementIds:{[r.id]:!0},newElement:null,selectionElement:null})},100),Yt(r)))return!0;let i=this.getHTMLIFrameElement(r);if(!i?.contentWindow)return!0;if(i.src.includes(`youtube`)){let e=CV.get(r.id);switch(e||(CV.set(r.id,Us.UNSTARTED),i.contentWindow.postMessage(JSON.stringify({event:`listening`,id:r.id}),`*`)),e){case Us.PLAYING:case Us.BUFFERING:i.contentWindow?.postMessage(JSON.stringify({event:`command`,func:`pauseVideo`,args:``}),`*`);break;default:i.contentWindow?.postMessage(JSON.stringify({event:`command`,func:`playVideo`,args:``}),`*`)}}return i.src.includes(`player.vimeo.com`)&&i.contentWindow.postMessage(JSON.stringify({method:`paused`}),`*`),!0}isIframeLikeElementCenter(e,t,n,r){return e&&!t.altKey&&!t.shiftKey&&!t.metaKey&&!t.ctrlKey&&(this.state.activeEmbeddable?.element!==e||this.state.activeEmbeddable?.state===`hover`||!this.state.activeEmbeddable)&&n>=e.x+e.width/3&&n<=e.x+2*e.width/3&&r>=e.y+e.height/3&&r<=e.y+2*e.height/3}renderEmbeddables(){let e=this.state.zoom.value,t=this.state.width,n=this.state.height,r=this.scene.getNonDeletedElements().filter(e=>us(e)&&this.embedsValidationStatus.get(e.id)===!0||Yt(e));return(0,V.jsx)(V.Fragment,{children:r.map(r=>{let{x:i,y:a}=Tn({sceneX:r.x,sceneY:r.y},this.state),o=ko(r,t,n,this.state,this.scene.getNonDeletedElementsMap()),s=this.initializedEmbeds.has(r.id);if(o&&!s&&this.initializedEmbeds.add(r.id),!(o||s))return null;let c;if(Yt(r)){c=null;let e=(r.customData?.generationData??this.magicGenerations.get(r.id))||{status:`error`,message:`No generation data`,code:`ERR_NO_GENERATION_DATA`};if(e.status===`done`){let t=e.html;c={intrinsicSize:{w:r.width,h:r.height},type:`document`,srcdoc:()=>t}}else if(e.status===`pending`)c={intrinsicSize:{w:r.width,h:r.height},type:`document`,srcdoc:()=>Co(`
|
|
83
|
-
<style>
|
|
84
|
-
html, body {
|
|
85
|
-
width: 100%;
|
|
86
|
-
height: 100%;
|
|
87
|
-
color: ${this.state.theme===A.DARK?`white`:`black`};
|
|
88
|
-
}
|
|
89
|
-
body {
|
|
90
|
-
display: flex;
|
|
91
|
-
align-items: center;
|
|
92
|
-
justify-content: center;
|
|
93
|
-
flex-direction: column;
|
|
94
|
-
gap: 1rem;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
.Spinner {
|
|
98
|
-
display: flex;
|
|
99
|
-
align-items: center;
|
|
100
|
-
justify-content: center;
|
|
101
|
-
margin-left: auto;
|
|
102
|
-
margin-right: auto;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
.Spinner svg {
|
|
106
|
-
animation: rotate 1.6s linear infinite;
|
|
107
|
-
transform-origin: center center;
|
|
108
|
-
width: 40px;
|
|
109
|
-
height: 40px;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
.Spinner circle {
|
|
113
|
-
stroke: currentColor;
|
|
114
|
-
animation: dash 1.6s linear 0s infinite;
|
|
115
|
-
stroke-linecap: round;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
@keyframes rotate {
|
|
119
|
-
100% {
|
|
120
|
-
transform: rotate(360deg);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
@keyframes dash {
|
|
125
|
-
0% {
|
|
126
|
-
stroke-dasharray: 1, 300;
|
|
127
|
-
stroke-dashoffset: 0;
|
|
128
|
-
}
|
|
129
|
-
50% {
|
|
130
|
-
stroke-dasharray: 150, 300;
|
|
131
|
-
stroke-dashoffset: -200;
|
|
132
|
-
}
|
|
133
|
-
100% {
|
|
134
|
-
stroke-dasharray: 1, 300;
|
|
135
|
-
stroke-dashoffset: -280;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
</style>
|
|
139
|
-
<div class="Spinner">
|
|
140
|
-
<svg
|
|
141
|
-
viewBox="0 0 100 100"
|
|
142
|
-
>
|
|
143
|
-
<circle
|
|
144
|
-
cx="50"
|
|
145
|
-
cy="50"
|
|
146
|
-
r="46"
|
|
147
|
-
stroke-width="8"
|
|
148
|
-
fill="none"
|
|
149
|
-
stroke-miter-limit="10"
|
|
150
|
-
/>
|
|
151
|
-
</svg>
|
|
152
|
-
</div>
|
|
153
|
-
<div>Generating...</div>
|
|
154
|
-
`)};else{let t;t=e.code===`ERR_GENERATION_INTERRUPTED`?`Generation was interrupted...`:e.message||`Generation failed`,c={intrinsicSize:{w:r.width,h:r.height},type:`document`,srcdoc:()=>Co(`
|
|
155
|
-
<style>
|
|
156
|
-
html, body {
|
|
157
|
-
height: 100%;
|
|
158
|
-
}
|
|
159
|
-
body {
|
|
160
|
-
display: flex;
|
|
161
|
-
flex-direction: column;
|
|
162
|
-
align-items: center;
|
|
163
|
-
justify-content: center;
|
|
164
|
-
color: ${Ye.red[3]};
|
|
165
|
-
}
|
|
166
|
-
h1, h3 {
|
|
167
|
-
margin-top: 0;
|
|
168
|
-
margin-bottom: 0.5rem;
|
|
169
|
-
}
|
|
170
|
-
</style>
|
|
171
|
-
<h1>Error!</h1>
|
|
172
|
-
<h3>${t}</h3>
|
|
173
|
-
`)}}}else c=zo(sa(r.link||``));let l=this.state.activeEmbeddable?.element===r&&this.state.activeEmbeddable?.state===`active`,u=this.state.activeEmbeddable?.element===r&&this.state.activeEmbeddable?.state===`hover`,d=c?.type===`video`,f=ss(d?e:1,.75,wV);return(0,V.jsx)(`div`,{className:H(`excalidraw__embeddable-container`,{"is-hovered":u}),style:{transform:o?`translate(${i-this.state.offsetLeft}px, ${a-this.state.offsetTop}px) scale(${e})`:`none`,display:o?`block`:`none`,opacity:Vr(r,Bt(r,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name===`elementLinkSelector`?ys:1),"--embeddable-radius":`${vt(Math.min(r.width,r.height),r)}px`},children:(0,V.jsxs)(`div`,{className:`excalidraw__embeddable-container__inner`,style:{width:o?`${r.width}px`:0,height:o?`${r.height}px`:0,transform:o?`rotate(${r.angle}rad)`:`none`,pointerEvents:l?ii.enabled:ii.disabled},children:[u&&(0,V.jsx)(`div`,{className:`excalidraw__embeddable-hint`,children:W(`buttons.embeddableInteractionButton`)}),(0,V.jsx)(`div`,{className:`excalidraw__embeddable__outer`,style:{padding:`${r.strokeWidth}px`},children:(0,V.jsx)(`div`,{className:`excalidraw__embeddable__content`,style:{width:`${f*100}%`,height:`${f*100}%`,transform:`scale(${1/f})`},children:(us(r)?this.props.renderEmbeddable?.(r,this.state):null)??(0,V.jsx)(`iframe`,{ref:e=>this.cacheEmbeddableRef(r,e),className:`excalidraw__embeddable`,srcDoc:c?.type===`document`?c.srcdoc(this.state.theme):void 0,src:c?.type===`document`?void 0:c?.link??``,scrolling:`no`,referrerPolicy:`no-referrer-when-downgrade`,title:`Excalidraw Embedded Content`,allow:`accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture`,allowFullScreen:!0,sandbox:`${c?.sandbox?.allowSameOrigin?`allow-same-origin`:``} allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation allow-downloads`})})})]})},r.id)})})}toggleOverscrollBehavior(e){document.documentElement.style.overscrollBehaviorX=e.type===`pointerenter`?`none`:`auto`}render(){let e=this.scene.getSelectedElements(this.state),{renderTopRightUI:t,renderTopLeftUI:n,renderCustomStats:r}=this.props,{elementsMap:i,visibleElements:a,canvasNonce:o,newElementCanvasElement:s}=this.renderer.getRenderableElements({zoom:this.state.zoom,offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,height:this.state.height,width:this.state.width,editingTextElement:this.state.editingTextElement,newElement:this.state.newElement,selectedElements:e,selectedElementsAreBeingDragged:this.state.selectedElementsAreBeingDragged,frameToHighlight:this.state.frameToHighlight});this.visibleElements=a,this.hasRenderableElements=i.size>0;let c=this.scene.getNonDeletedElementsMap(),l=`setPointerCapture`in HTMLElement.prototype?!1:this.state.selectionElement||this.state.newElement||this.state.selectedElementsAreBeingDragged||this.state.resizingElement||this.state.activeTool.type===`laser`&&this.state.cursorButton===`down`,u=e[0],d=ky.get(LD)?.type===`panel`;return(0,V.jsx)(`div`,{translate:`no`,className:H(`excalidraw excalidraw-container notranslate`,this.props.className,{"excalidraw--view-mode":this.state.viewModeEnabled||this.state.openDialog?.name===`elementLinkSelector`,"excalidraw--mobile":this.editorInterface.formFactor===`phone`,"excalidraw--non-interactive":!this.isInteractionEnabled(),"excalidraw--navigation":!this.isInteractionEnabled()&&this.isNavigationEnabled(),"excalidraw--tools":!this.isInteractionEnabled()&&this.isToolSupported(this.state.activeTool.type),"excalidraw--embeds":!this.isInteractionEnabled()&&this.isEmbedsEnabled(),"excalidraw--allow-browser-zoom":!this.isInteractionEnabled()&&this.isBrowserZoomEnabled(),"excalidraw--ui-hidden":!this.isDefaultUIEnabled(),"excalidraw--mobile-toolbar":this.editorInterface.formFactor===`phone`&&this.isDefaultUIEnabled()&&!this.state.viewModeEnabled,"excalidraw--viewport-status-border":!!this.props.viewportStatusFrame?.border,"excalidraw--viewport-status-label":!!this.props.viewportStatusFrame?.label,"excalidraw--zen-mode":this.state.zenModeEnabled}),style:{"--ui-pointerEvents":l?ii.disabled:ii.enabled,"--right-sidebar-width":`${QP}px`},ref:this.excalidrawContainerRef,onDrop:this.isInteractionEnabled()?this.handleAppOnDrop:void 0,tabIndex:0,onKeyDown:this.props.handleKeyboardGlobally||!this.isInteractionEnabled()?void 0:this.onKeyDown,onPointerEnter:this.isInteractionEnabled()?this.toggleOverscrollBehavior:void 0,onPointerLeave:this.isInteractionEnabled()?this.toggleOverscrollBehavior:void 0,children:(0,V.jsx)(nV.Provider,{value:this.api,children:(0,V.jsx)(KB.Provider,{value:this,children:(0,V.jsx)(qB.Provider,{value:this.props,children:(0,V.jsx)(ZB.Provider,{value:this.excalidrawContainerValue,children:(0,V.jsx)(YB.Provider,{value:this.editorInterface,children:(0,V.jsx)(eV.Provider,{value:this.setAppState,children:(0,V.jsx)($B.Provider,{value:this.state,children:(0,V.jsxs)(QB.Provider,{value:this.scene.getNonDeletedElements(),children:[(0,V.jsxs)(tV.Provider,{value:this.actionManager,children:[(0,V.jsx)(Gz,{canvas:this.canvas,appState:this.state,defaultUIEnabled:this.isDefaultUIEnabled(),zoomUIEnabled:this.isUIControlEnabled(`zoom`),scrollBackToContentUIEnabled:this.isUIControlEnabled(`scrollBackToContent`),files:this.files,setAppState:this.setAppState,actionManager:this.actionManager,elements:this.scene.getNonDeletedElements(),onLockToggle:this.toggleLock,onPenModeToggle:this.togglePenMode,langCode:Ry().code,renderTopLeftUI:n,renderTopRightUI:t,renderCustomStats:r,showExitZenModeBtn:typeof this.props?.zenModeEnabled>`u`&&this.state.zenModeEnabled,UIOptions:this.props.UIOptions,onExportImage:this.onExportImage,renderWelcomeScreen:!this.state.isLoading&&this.state.showWelcomeScreen&&this.state.activeTool.type===this.state.preferredSelectionTool.type&&!this.state.zenModeEnabled&&!this.scene.getElementsIncludingDeleted().length,app:this,isCollaborating:this.props.isCollaborating,generateLinkForSelection:this.props.generateLinkForSelection,currentUserControls:this.props.currentUserControls,children:this.props.children}),(0,V.jsx)(`div`,{className:`excalidraw-textEditorContainer`}),(0,V.jsx)(`div`,{className:`excalidraw-contextMenuContainer`}),(0,V.jsx)(`div`,{className:`excalidraw-eye-dropper-container`}),(0,V.jsx)(qz,{trails:[this.laserTrails,this.lassoTrail,this.eraserTrail,this.drawShape.trail]}),this.isDefaultUIEnabled()&&(0,V.jsx)(UB,{}),this.isDefaultUIEnabled()&&e.length===1&&this.state.openDialog?.name!==`elementLinkSelector`&&this.state.showHyperlinkPopup&&(0,V.jsx)(_D,{element:u,scene:this.scene,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},u.id),this.isDefaultUIEnabled()&&this.props.aiEnabled!==!1&&e.length===1&&ue(u)&&(0,V.jsx)(KM,{element:u,elementsMap:i,children:(0,V.jsx)(Kz,{title:W(`labels.convertToCode`),icon:xS,checked:!1,onChange:()=>this.onMagicFrameGenerate(u,`button`)})}),this.isDefaultUIEnabled()&&e.length===1&&Yt(u)&&u.customData?.generationData?.status===`done`&&(0,V.jsxs)(KM,{element:u,elementsMap:i,children:[(0,V.jsx)(Kz,{title:W(`labels.copySource`),icon:cS,checked:!1,onChange:()=>this.onIframeSrcCopy(u)}),(0,V.jsx)(Kz,{title:`Enter fullscreen`,icon:SS,checked:!1,onChange:()=>{let e=this.getHTMLIFrameElement(u);if(e)try{e.requestFullscreen(),this.setState({activeEmbeddable:{element:u,state:`active`},selectedElementIds:{[u.id]:!0},newElement:null,selectionElement:null})}catch(e){console.warn(e),this.setState({errorMessage:`Couldn't enter fullscreen`})}}})]}),this.isDefaultUIEnabled()&&this.state.contextMenu&&(0,V.jsx)(hF,{items:this.state.contextMenu.items,top:this.state.contextMenu.top,left:this.state.contextMenu.left,actionManager:this.actionManager,onClose:e=>{this.setState({contextMenu:null},()=>{this.focusContainer(),e?.()})}}),(0,V.jsx)(jB,{canvas:this.canvas,rc:this.rc,elementsMap:i,allElementsMap:c,visibleElements:a,canvasNonce:o,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:wM(this),renderLinks:this.isLinksEnabled(),canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:this.flowchart.pendingNodes,theme:this.state.theme}}),s&&(0,V.jsx)(FB,{appState:this.state,newElement:s,scale:window.devicePixelRatio,rc:this.rc,elementsMap:i,allElementsMap:c,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:!1,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:null,theme:this.state.theme}}),(0,V.jsx)(OB,{app:this,containerRef:this.excalidrawContainerRef,canvas:this.interactiveCanvas,elementsMap:i,visibleElements:a,allElementsMap:c,selectedElements:e,canvasNonce:o,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderScrollbars:this.props.renderScrollbars===!0,editorInterface:this.editorInterface,interactionEnabled:this.isInteractionEnabled(),navigationEnabled:this.isNavigationEnabled(),renderInteractiveSceneCallback:this.renderInteractiveSceneCallback,handleCanvasRef:this.handleInteractiveCanvasRef,onContextMenu:this.handleCanvasContextMenu,onClick:this.handleCanvasClick,onPointerMove:this.handleCanvasPointerMove,onPointerUp:this.handleCanvasPointerUp,onPointerCancel:this.removePointer,onTouchMove:this.handleTouchMove,onPointerDown:this.handleCanvasPointerDown,onDoubleClick:this.handleCanvasDoubleClick}),this.props.viewportStatusFrame?.border&&this.editorInterface.formFactor===`phone`&&(0,V.jsx)(gF,{border:this.props.viewportStatusFrame.border}),this.renderFrameNames(),this.isDefaultUIEnabled()&&this.state.activeLockedId&&(0,V.jsx)(GB,{app:this,activeLockedId:this.state.activeLockedId}),this.isDefaultUIEnabled()&&d&&(0,V.jsx)(iO,{app:this})]}),this.renderEmbeddables()]})})})})})})})})})}setPlugins(e){Object.assign(this.plugins,e)}async onMagicFrameGenerate(e,t){let n=this.plugins.diagramToCode?.generate;if(!n){this.setState({errorMessage:`No diagram to code plugin found`});return}let r=Vn(this.scene.getNonDeletedElements(),e,this.scene.getNonDeletedElementsMap()).filter(e=>!ue(e));if(!r.length){t===`button`?(this.setState({errorMessage:`Cannot generate from an empty frame`}),xC(`ai`,`generate (no-children)`,`d2c`)):this.setActiveTool({type:`magicframe`});return}let i=this.insertIframeElement({sceneX:e.x+e.width+30,sceneY:e.y,width:e.width,height:e.height});if(i){this.updateMagicGeneration({frameElement:i,data:{status:`pending`}}),this.setState({selectedElementIds:{[i.id]:!0}}),xC(`ai`,`generate (start)`,`d2c`);try{let{html:t}=await n({frame:e,children:r});if(xC(`ai`,`generate (success)`,`d2c`),!t.trim()){this.updateMagicGeneration({frameElement:i,data:{status:`error`,code:`ERR_OAI`,message:`Nothing genereated :(`}});return}let a=t.includes(`<!DOCTYPE html>`)&&t.includes(`</html>`)?t.slice(t.indexOf(`<!DOCTYPE html>`),t.indexOf(`</html>`)+7):t;this.updateMagicGeneration({frameElement:i,data:{status:`done`,html:a}})}catch(e){xC(`ai`,`generate (failed)`,`d2c`),this.updateMagicGeneration({frameElement:i,data:{status:`error`,code:`ERR_OAI`,message:e.message||`Unknown error during generation`}})}}}onIframeSrcCopy(e){e.customData?.generationData?.status===`done`&&(oE(e.customData.generationData.html),this.setToast({message:`copied to clipboard`,closable:!1,duration:1500}))}clearImageShapeCache(e){let t=e??this.files;this.scene.getNonDeletedElements().forEach(e=>{ae(e)&&t[e.fileId]&&(this.imageCache.delete(e.fileId),fr.delete(e))})}async componentDidMount(){this.unmounted=!1,this.api=this.createExcalidrawAPI(),this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,(fc()||ci())&&(this.setState.bind(this),Object.defineProperties(window.h,{state:{configurable:!0,get:()=>this.state},setState:{configurable:!0,value:(...e)=>this.setState(...e)},app:{configurable:!0,value:this},history:{configurable:!0,value:this.history},store:{configurable:!0,value:this.store},fonts:{configurable:!0,value:this.fonts}})),this.store.onDurableIncrementEmitter.on(e=>{this.history.record(e.delta)}),this.props.onIncrement&&this.store.onStoreIncrementEmitter.on(e=>{this.props.onIncrement?.(e)}),this.scene.onUpdate(this.triggerRender),this.addEventListeners(),this.props.autoFocus&&this.excalidrawContainerRef.current&&this.focusContainer(),Bn&&this.excalidrawContainerRef.current&&(this.resizeObserver=new ResizeObserver(()=>{this.refreshEditorInterface(),this.updateDOMRect()}),this.resizeObserver?.observe(this.excalidrawContainerRef.current)),new URLSearchParams(window.location.search.slice(1)).has(`web-share-target`)?this.restoreFileFromShare():this.updateDOMRect(this.initializeScene),Lt()&&!Ot()&&this.setState({errorMessage:(0,V.jsx)(dF,{})});let e={excalidrawAPI:this.api,container:this.excalidrawContainerRef.current};this.editorLifecycleEvents.emit(`editor:mount`,e),this.props.onMount?.(e),this.props.onExcalidrawAPI?.(this.api)}componentWillUnmount(){this.api={...this.api,isDestroyed:!0};for(let e of Object.keys(this.api))(e.startsWith(`get`)||e===`onStateChange`||e===`onEvent`)&&typeof this.api[e]==`function`&&(this.api[e]=()=>{throw Error("ExcalidrawAPI is no longer usable after the editor has been unmounted and will return invalid/empty data. You should check for `ExcalidrawAPI.isDestroyed` before calling get* methods on subscribing to state/event changes.")});this.editorLifecycleEvents.emit(`editor:unmount`),this.props.onUnmount?.(),this.props.onExcalidrawAPI?.(null),window.launchQueue?.setConsumer(()=>{}),this.renderer.destroy(),this.scene.destroy(),this.scene=new Ha,this.fonts=new Ar(this.scene),this.renderer=new UM(this.scene),this.files={},this.imageCache.clear(),this.resizeObserver?.disconnect(),this.unmounted=!0,this.viewport.destroy(),this.removeEventListeners(),this.library.destroy(),this.laserTrails.stop(),this.drawShape.stop(),this.eraserTrail.stop(),this.onChangeEmitter.clear(),this.store.onStoreIncrementEmitter.clear(),this.store.onDurableIncrementEmitter.clear(),this.appStateObserver.clear(),this.editorLifecycleEvents.clear(),fr.destroy(),CM.destroy(),clearTimeout(xV),Bi.clearCache(),na.clearCache(),xV=0,document.documentElement.style.overscrollBehaviorX=``}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){if(this.removeEventListeners(),this.onRemoveEventListenersEmitter.once(ki(window,T.MESSAGE,this.onWindowMessage,!1),ki(document,T.POINTER_UP,this.removePointer,{passive:!1}),ki(document.fonts,`loadingdone`,e=>{let t=e.fontfaces;this.fonts.onLoaded(t)},{passive:!1}),ki(window,T.FOCUS,()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.isInteractionEnabled()){this.isNavigationEnabled()&&this.onRemoveEventListenersEmitter.once(ki(this.excalidrawContainerRef.current,T.WHEEL,this.handleWheel,{passive:!1}),ki(this.props.handleKeyboardGlobally?document:this.excalidrawContainerRef.current,T.KEYDOWN,this.handleNavigationModeKeyDown,!1),ki(document,T.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),ki(document,T.GESTURE_START,this.onGestureStart,!1),ki(document,T.GESTURE_CHANGE,this.onGestureChange,!1),ki(document,T.GESTURE_END,this.onGestureEnd,!1)),this.isBrowserZoomEnabled()||(this.isNavigationEnabled()||this.onRemoveEventListenersEmitter.once(ki(this.excalidrawContainerRef.current,T.WHEEL,this.preventBrowserZoomWheel,{passive:!1}),ki(this.excalidrawContainerRef.current,T.GESTURE_START,this.disableEvent,!1),ki(this.excalidrawContainerRef.current,T.GESTURE_CHANGE,this.disableEvent,!1),ki(this.excalidrawContainerRef.current,T.GESTURE_END,this.disableEvent,!1)),this.onRemoveEventListenersEmitter.once(ki(this.props.handleKeyboardGlobally?document:this.excalidrawContainerRef.current,T.KEYDOWN,this.preventBrowserZoomKeyDown,!1)));return}this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(ki(document,T.KEYDOWN,this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(ki(this.excalidrawContainerRef.current,T.WHEEL,this.handleWheel,{passive:!1}),ki(document,T.COPY,this.onCopy,{passive:!1}),ki(document,T.KEYUP,this.onKeyUp,{passive:!0}),ki(document,T.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),ki(document,T.GESTURE_START,this.onGestureStart,!1),ki(document,T.GESTURE_CHANGE,this.onGestureChange,!1),ki(document,T.GESTURE_END,this.onGestureEnd,!1)),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(ki(document,T.FULLSCREENCHANGE,this.onFullscreenChange,{passive:!1}),ki(document,T.PASTE,this.pasteFromClipboard,{passive:!1}),ki(document,T.CUT,this.onCut,{passive:!1}),ki(window,T.RESIZE,this.onResize,!1),ki(window,T.UNLOAD,this.onUnload,!1),ki(window,T.BLUR,this.onBlur,!1),ki(this.excalidrawContainerRef.current,T.WHEEL,this.handleWheel,{passive:!1}),ki(this.excalidrawContainerRef.current,T.DRAG_OVER,this.disableEvent,!1),ki(this.excalidrawContainerRef.current,T.DROP,this.disableEvent,!1)),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(ki(rr(this.excalidrawContainerRef.current),T.SCROLL,this.onScroll,{passive:!1})))}componentDidUpdate(e,t){!this._initialized&&!this.state.isLoading&&(this._initialized=!0,this.editorLifecycleEvents.emit(`editor:initialize`,this.api),this.props.onInitialize?.(this.api)),this.handleInteractionStateChange(e,t),this.handleForcedToolChange(e,t),this.appStateObserver.flush(t),this.updateEmbeddables();let n=this.scene.getElementsIncludingDeleted(),r=this.scene.getElementsMapIncludingDeleted(),i=(this.sessionExportThemeOverride??this.state.theme)===A.DARK;this.state.exportWithDarkMode!==i&&this.setState({exportWithDarkMode:i}),!this.state.showWelcomeScreen&&!n.length&&this.setState({showWelcomeScreen:!0}),(t.zoom.value!==this.state.zoom.value||t.scrollX!==this.state.scrollX||t.scrollY!==this.state.scrollY)&&(this.props?.onScrollChange?.(this.state.scrollX,this.state.scrollY,this.state.zoom),this.onScrollChangeEmitter.trigger(this.state.scrollX,this.state.scrollY,this.state.zoom)),Object.keys(this.state.selectedElementIds).length&&ji(this.state)&&this.setState({activeTool:Pt(this.state,{type:`selection`})}),this.state.activeTool.type===`eraser`&&t.theme!==this.state.theme&&this.cursor.applyForTool(),this.state.activeTool.type===`bucketfill`&&t.currentItemBackgroundColor!==this.state.currentItemBackgroundColor&&this.cursor.applyForTool(),t.activeTool.type===`selection`&&this.state.activeTool.type!==`selection`&&this.state.showHyperlinkPopup&&this.setState({showHyperlinkPopup:!1}),e.langCode!==this.props.langCode&&this.updateLanguage(),ji(t)&&!ji(this.state)&&this.eraserTrail.endPath(),(t.openDialog?.name===`elementLinkSelector`||this.state.openDialog?.name===`elementLinkSelector`)&&t.openDialog?.name!==this.state.openDialog?.name&&(this.deselectElements(),this.setState({hoveredElementIds:{}})),e.zenModeEnabled!==this.props.zenModeEnabled&&this.setState({zenModeEnabled:!!this.props.zenModeEnabled}),e.theme!==this.props.theme&&this.props.theme&&this.setState({theme:this.props.theme}),this.excalidrawContainerRef.current?.classList.toggle(`theme--dark`,this.state.theme===A.DARK),this.state.selectedLinearElement?.isEditing&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.actionManager.executeAction(PT)});let a=Object.keys(this.state.selectedElementIds);if(a.length){let e=a.filter(e=>{let t=this.scene.getElement(e);return!t||t.isDeleted});e.length&&this.setState(t=>{let n={...t.selectedElementIds};for(let t of e)delete n[t];return{selectedElementIds:fa(n,t)}})}if(this.state.editingTextElement){let e=this.scene.getElement(this.state.editingTextElement.id);(!e||e.isDeleted)&&this.setState({editingTextElement:null})}let o=this.state.editingTextElement||this.viewport.isAnimating?!1:!this.visibleElements.length&&this.hasRenderableElements;this.state.scrolledOutside!==o&&this.setState({scrolledOutside:o}),this.store.commit(r,this.state),this.state.isLoading||(this.props.onChange?.(n,this.state,this.files),this.onChangeEmitter.trigger(n,this.state,this.files))}static resetTapTwice(){mV=!1,gV=null}async insertClipboardContent(e,t,r){let{x:i,y:a}=St({clientX:this.viewport.lastPosition.x,clientY:this.viewport.lastPosition.y},this.state);if(e.errorMessage){this.setState({errorMessage:e.errorMessage});return}if(t.length===0&&!r&&e.mixedContent){await this.addElementsFromMixedContentPaste(e.mixedContent,{isPlainPaste:r,sceneX:i,sceneY:a});return}if(!r&&e.text){let t=jP(e.text);if(t.ok){this.setState({openDialog:{name:`charts`,data:t.data,rawText:e.text}});return}}let o=t.map(e=>e.file);if(o.length===0&&e.text&&!r){let t=e.text.trim();t.startsWith(`<svg`)&&t.endsWith(`</svg>`)&&o.push(Fa(t))}if(o.length>0){this.isToolSupported(`image`)?await this.insertImages(o,i,a):this.setState({errorMessage:W(`errors.imageToolNotSupported`)});return}if(e.elements){let t=e.programmaticAPI?Hs(e.elements):e.elements;this.addElementsFromPasteOrLibrary({elements:t,files:e.files||null,position:this.editorInterface.formFactor===`desktop`?`cursor`:`center`,retainSeed:r,preserveFrameChildrenOrder:!0});return}if(!e.text)return;if(!r&&yN(e.text)){let t=await n(()=>import(`./excalidraw-mermaid-stub-DE5FTiZB.js`),__vite__mapDeps([69,70]),import.meta.url);try{let{elements:n,files:r={}}=await t.parseMermaidToExcalidraw(e.text),i=Hs(n,{regenerateIds:!0});this.addElementsFromPasteOrLibrary({elements:i,files:r,position:this.editorInterface.formFactor===`desktop`?`cursor`:`center`});return}catch(e){console.warn(`parsing pasted text as mermaid definition failed: ${e.message}`)}}let s=Kn(e.text).split(/\n+/).map(e=>e.trim()).filter(Boolean),c=s.map(e=>Ui(e)).filter(e=>En(e,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(e)||zo(e)?.type===`video`));if(!r&&c.length>0&&c.length===s.length){let e=[];for(let t of c){let n=e[e.length-1],r=this.insertEmbeddableElement({sceneX:n?n.x+n.width+20:i,sceneY:a,link:Ts(t)});r&&e.push(r)}e.length&&(this.store.scheduleCapture(),this.setState({selectedElementIds:Object.fromEntries(e.map(e=>[e.id,!0]))}));return}this.addTextFromPaste(e.text,r)}async addElementsFromMixedContentPaste(e,{isPlainPaste:t,sceneX:n,sceneY:r}){if(!t&&e.some(e=>e.type===`imageUrl`)&&this.isToolSupported(`image`)){let t=e.filter(e=>e.type===`imageUrl`).map(e=>e.value),i=await Promise.all(t.map(async e=>{try{return{file:await he(e)}}catch(e){let t=e.message;return e.cause===`FETCH_ERROR`?t=W(`errors.failedToFetchImage`):e.cause===`UNSUPPORTED`&&(t=W(`errors.unsupportedFileType`)),{errorMessage:t}}})),a=i.filter(e=>!!e.file).map(e=>e.file);await this.insertImages(a,n,r);let o=i.find(e=>!!e.errorMessage);o&&o.errorMessage&&this.setState({errorMessage:o.errorMessage})}else{let n=e.filter(e=>e.type===`text`);n.length&&this.addTextFromPaste(n.map(e=>e.value).join(`
|
|
174
|
-
|
|
175
|
-
`),t)}}addTextFromPaste(e,t=!1){let{x:n,y:r}=St({clientX:this.viewport.lastPosition.x,clientY:this.viewport.lastPosition.y},this.state),i={x:n,y:r,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(`text`),strokeStyle:this.state.currentItemStrokeStyle,roundness:null,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:e,fontSize:this.state.currentItemFontSize,fontFamily:this.state.currentItemFontFamily,textAlign:xs,verticalAlign:`top`,locked:!1},a=tc({fontSize:i.fontSize,fontFamily:i.fontFamily}),o=zs(i.fontFamily),[s,,c]=oe(this.state),l=Math.max(Math.min((c-s)*.5,800),200),u=r,d=t?[e]:e.split(`
|
|
176
|
-
`),f=d.reduce((e,t,r)=>{let s=ze(t).trim();if(s.length){let t=this.getTopLayerFrameAtSceneCoords({x:n,y:u}),r=uo(s,a,o),c=r.width>l,d=c?qr(s,a,l):s;r=c?uo(d,a,o):r;let f=n-r.width/2,p=u-r.height/2,m=oc({...i,x:f,y:p,text:d,originalText:s,lineHeight:o,autoResize:!c,frameId:t?t.id:null});e.push(m),u+=m.height+10}else d[r-1]?.trim()&&(u+=Fr(i.fontSize,o)+10);return e},[]);f.length!==0&&(this.insertNewElements(f),this.store.scheduleCapture(),this.setState({selectedElementIds:fa(Object.fromEntries(f.map(e=>[e.id,!0])),this.state)}),!t&&f.length>1&&DV===!1&&this.editorInterface.formFactor!==`phone`&&(this.setToast({message:W(`toast.pasteAsSingleElement`,{shortcut:X(`CtrlOrCmd+Shift+V`)}),duration:5e3}),DV=!0))}handleTextWysiwyg(e,{isExistingElement:t=!1,initialCaretSceneCoords:n=null}){let r=this.scene.getElementsMapIncludingDeleted(),i=(t,n)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(i=>i.id===e.id&&a(i)?R(i,{originalText:t,isDeleted:n??i.isDeleted,...wr(i,Go(i,r),r,t)}):i)])};this.textWysiwygSubmitHandler=pN({canvas:this.canvas,getViewportCoords:(e,t)=>{let{x:n,y:r}=Tn({sceneX:e,sceneY:t},this.state);return[n-this.state.offsetLeft,r-this.state.offsetTop]},onChange:qM(t=>{i(t,!1),dc(e)&&La(e,this.scene)}),onSubmit:qM(({viaKeyboard:n,nextOriginalText:r})=>{this.textWysiwygSubmitHandler=null;let a=!r.trim();i(r,a);let o=n&&!this.isToolLocked()&&this.state.activeTool.type!==`autoshape`?e.containerId||(a?null:e.id):null;o&&(0,Uc.flushSync)(()=>{this.setState(e=>({selectedElementIds:fa({...e.selectedElementIds,[o]:!0},e)}))}),a&&jo(this.scene.getNonDeletedElements(),[e]),(!a||t)&&this.store.scheduleCapture(),(0,Uc.flushSync)(()=>{this.setState({newElement:null,editingTextElement:null})}),(this.isToolLocked()||this.state.activeTool.type===`autoshape`)&&this.cursor.applyForTool(),this.focusContainer()}),element:e,excalidrawContainer:this.excalidrawContainerRef.current,app:this,initialCaretSceneCoords:n,autoSelect:!this.editorInterface.isTouchScreen}),this.deselectElements(),i(e.originalText,!1)}deselectElements(){this.setState({selectedElementIds:fa({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getSelectedTextElement(e){let t=this.scene.getSelectedElements(this.state);if(t.length!==1)return null;let n=t[0];return a(n)?n:e?Ti(n,this.scene.getNonDeletedElementsMap()):null}getSelectedTextEditingContainerAtPosition(e,t){let n=this.scene.getSelectedElements(this.state);if(n.length!==1||!e||e.id!==n[0].id)return null;let r=n[0];if(a(r))return null;if(!le(r))return;let i=this.getSelectedTextElement(r),o=this.getTextElementAtPosition(t.x,t.y);if(!(!i||o?.id!==i.id))return r}getTextElementAtPosition(e,t){let n=this.getElementAtPosition(e,t,{includeBoundTextElement:!0});return n&&a(n)&&!n.isDeleted?n:null}getElementAtPosition(e,t,n){let r=[];if(r=n&&`allHitElements`in n?n?.allHitElements||[]:this.getElementsAtPosition(e,t,{includeBoundTextElement:n?.includeBoundTextElement,includeLockedElements:n?.includeLockedElements}),r.length>1){if(n?.preferSelected){for(let e=r.length-1;e>-1;e--)if(this.state.selectedElementIds[r[e].id])return r[e]}let i=r[r.length-1];return u({point:L(e,t),element:i,threshold:this.getElementHitThreshold(i)/2,elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:P(i)?this.frameNameBoundsCache.get(i):null})?i:r[r.length-2]}return r.length===1?r[0]:null}getElementsAtPosition(e,t,n){let r=[],i=this.scene.getNonDeletedElementsMap();return(n?.includeBoundTextElement&&n?.includeLockedElements?this.scene.getNonDeletedElements():this.scene.getNonDeletedElements().filter(e=>(n?.includeLockedElements||!e.locked)&&(n?.includeBoundTextElement||!(a(e)&&e.containerId)))).filter(n=>this.hitElement(e,t,n)).filter(n=>{let r=Bt(n,i);return r&&!dc(r)&&console.error(`[NONDELETED][INVARIANT] Containing frame is deleted`),r&&this.state.frameRendering.enabled&&this.state.frameRendering.clip&&!ns(n)?x({x:e,y:t},r,i):!0}).filter(e=>!ns(e)||(r.push(e),!1)).concat(r)}getElementHitThreshold(e){return Math.max(e.strokeWidth/2+.1,.85*(l/this.state.zoom.value))}hitElement(e,t,n,r=!0){return r&&this.state.selectedElementIds[n.id]&&lc([n],this.state,this.editorInterface)&&ut(L(e,t),n,this.scene.getNonDeletedElementsMap(),this.getElementHitThreshold(n))||ea(L(e,t),n,this.scene.getNonDeletedElementsMap())?!0:u({point:L(e,t),element:n,threshold:this.getElementHitThreshold(n),elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:P(n)?this.frameNameBoundsCache.get(n):null})}getTextBindableContainerAtPosition(e,t){let n=this.scene.getNonDeletedElements(),r=this.scene.getSelectedElements(this.state);if(r.length===1)return Ii(r[0],!1)?r[0]:null;let i=null;for(let r=n.length-1;r>=0;--r){if(n[r].isDeleted)continue;let[a,o,s,c]=kc(n[r],this.scene.getNonDeletedElementsMap());if(_(n[r])&&u({point:L(e,t),element:n[r],elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(n[r])})){i=n[r];break}if(a<e&&e<s&&o<t&&t<c){if(P(n[r]))continue;i=n[r];break}}return Ii(i,!1)?i:null}isEditingTextContent(){return!!this.state.editingTextElement||a(this.state.newElement)}handleHoverSelectedLinearElement(e,t,n){let r=this.scene.getNonDeletedElementsMap(),i=N.getElement(e.elementId,r);if(i){if(this.state.selectedLinearElement){let a=-1,o=null;u({point:L(t,n),element:i,elementsMap:r,threshold:this.getElementHitThreshold(i)})?(a=N.getPointIndexUnderCursor(i,r,this.state.zoom,t,n),o=N.getSegmentMidpointHitCoords(e,{x:t,y:n},this.state,this.scene.getNonDeletedElementsMap()),(ve(i)?a===0||a===i.points.length-1:a>=0)||o?this.cursor.set(Et.POINTER):this.hitElement(t,n,i)&&(!ve(i)||!(i.startBinding||i.endBinding))&&(this.state.activeTool.type!==`lasso`||Object.keys(this.state.selectedElementIds).length>0)&&this.cursor.set(Et.MOVE)):this.hitElement(t,n,i)&&(!ve(i)||!(i.startBinding||i.endBinding))&&(this.state.activeTool.type!==`lasso`||Object.keys(this.state.selectedElementIds).length>0)&&this.cursor.set(Et.MOVE),this.state.selectedLinearElement.hoverPointIndex!==a&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:a}}),N.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,o)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:o}});let s=null,c=i;(c.startBinding||c.endBinding)&&(s=nr(i,t,n,this.scene,this.state)),this.state.selectedLinearElement.hoveredFocusPointBinding!==s&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!1,hoveredFocusPointBinding:s}}),s&&this.cursor.set(Et.POINTER)}else this.cursor.set(Et.AUTO)}}updateGestureOnPointerDown(e){$.pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),$.pointers.size===2&&($.lastCenter=gM($.pointers),$.initialScale=this.state.zoom.value,$.initialDistance=_M(Array.from($.pointers.values())))}initialPointerDownState(e){let t=St(e,this.state),n=this.scene.getSelectedElements(this.state),[r,i,a,o]=Is(n),s=n.findIndex(ve)===0;return{origin:t,withCmdOrCtrl:e[j.CTRL_OR_CMD],originInGrid:Qs(An(t.x,t.y,e[j.CTRL_OR_CMD]||s?null:this.getEffectiveGridSize())),scrollbars:vN(bV,e.clientX-this.state.offsetLeft,e.clientY-this.state.offsetTop),lastCoords:{...t},originalElements:this.scene.getNonDeletedElements().reduce((e,t)=>(e.set(t.id,ca(t)),e),new Map),resize:{handleType:!1,isResizing:!1,offset:{x:0,y:0},arrowDirection:`origin`,center:{x:(a+r)/2,y:(o+i)/2}},hit:{element:null,allHitElements:[],wasAddedToSelection:!1,hasBeenDuplicated:!1,hasHitCommonBoundingBoxOfSelectedElements:this.isHittingCommonBoundingBoxOfSelectedElements(t,n)},drag:{hasOccurred:!1,offset:null,origin:{...t},blockDragging:!1},eventListeners:{onMove:null,onUp:null,onKeyUp:null,onKeyDown:null},boxSelection:{hasOccurred:!1}}}handleDraggingScrollBar(e,t){if(!(t.scrollbars.isOverEither&&!this.state.multiElement))return!1;yV=!0,t.lastCoords.x=e.clientX,t.lastCoords.y=e.clientY;let n=JM(e=>{e.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(e,t)}),r=qM(()=>{OV=null,yV=!1,this.cursor.applyForTool(),this.setState({cursorButton:`up`}),this.savePointer(e.clientX,e.clientY,`up`),window.removeEventListener(T.POINTER_MOVE,n),window.removeEventListener(T.POINTER_UP,r),n.flush()});return OV=r,window.addEventListener(T.POINTER_MOVE,n),window.addEventListener(T.POINTER_UP,r),!0}isASelectedElement(e){return e!=null&&this.state.selectedElementIds[e.id]}isHittingCommonBoundingBoxOfSelectedElements(e,t){if(t.length<2)return!1;let n=Math.max(l/this.state.zoom.value,1),r=4/this.state.zoom.value,[i,a,o,s]=Is(t);return e.x>i-r-n&&e.x<o+r+n&&e.y>a-r-n&&e.y<s+r+n}getCurrentItemRoundness(e){return this.state.currentItemRoundness===`round`?{type:tt(e)?Jr.ADAPTIVE_RADIUS:Jr.PROPORTIONAL_RADIUS}:null}getCurrentItemStrokeWidth(e){return We(e,this.state.currentItemStrokeWidthKey)}maybeCacheReferenceSnapPoints(e,t,n=!1){TM({event:e,app:this,selectedElements:t})&&(n||!CM.getReferenceSnapPoints())&&CM.setReferenceSnapPoints(jM(this.scene.getNonDeletedElements(),t,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(e,t,n=!1){TM({event:e,app:this,selectedElements:t})&&(n||!CM.getVisibleGaps())&&CM.setVisibleGaps(kM(this.scene.getNonDeletedElements(),t,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(e){return qM(t=>{this.maybeHandleResize(e,t)||this.maybeDragNewGenericElement(e,t)})}onKeyUpFromPointerDownHandler(e){return qM(t=>{t.key===j.ALT&&t.preventDefault(),!this.maybeHandleResize(e,t)&&this.maybeDragNewGenericElement(e,t)})}onPointerMoveFromPointerDownHandler(e){return JM(t=>{if(this.state.openDialog?.name===`elementLinkSelector`)return;let n=St(t,this.state);if(this.state.activeLockedId&&this.setState({activeLockedId:null}),this.state.selectedLinearElement&&this.state.selectedLinearElement.elbowed&&this.state.selectedLinearElement.initialState.segmentMidpoint.index){let[e,r]=An(n.x,n.y,t[j.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),i=this.state.selectedLinearElement.initialState.segmentMidpoint.index;if(i<0){let t=N.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:e,y:r},this.state,this.scene.getNonDeletedElementsMap());i=t?N.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,t,this.scene.getNonDeletedElementsMap()):-1}let a=N.moveFixedSegment(this.state.selectedLinearElement,i,e,r,this.scene);this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!0,segmentMidPointHoveredCoords:a.segmentMidPointHoveredCoords,initialState:a.initialState}});return}let r=this.previousPointerMoveCoords??e.origin;if(this.previousPointerMoveCoords=n,e.drag.offset===null&&(e.drag.offset=Qs(Rs(this.scene.getSelectedElements(this.state),e.origin.x,e.origin.y))),!(t.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(t,e))return;if(ji(this.state)){this.handleEraser(t,n);return}if(this.state.activeTool.type===`laser`&&this.laserTrails.addPointToPath(n.x,n.y),this.drawShape.handlePointerMove(n))return;let[i,a]=An(n.x,n.y,t[j.CTRL_OR_CMD]?null:this.getEffectiveGridSize());if(e.resize.isResizing&&(e.lastCoords.x=n.x,e.lastCoords.y=n.y,this.maybeHandleCrop(e,t)||this.maybeHandleResize(e,t)))return!0;let o=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let r=this.state.selectedLinearElement;if(r.draggedFocusPointBinding){Ra(r,o,n,this.scene,this.state,this.getEffectiveGridSize(),t.altKey),this.setState({selectedLinearElement:{...r,isDragging:!1,selectedPointsIndices:[],initialState:{...r.initialState,lastClickedPoint:-1}}});return}if(N.shouldAddMidpoint(this.state.selectedLinearElement,n,this.state,o)){let e=N.addMidpoint(this.state.selectedLinearElement,n,this,!t[j.CTRL_OR_CMD],this.scene);if(!e)return;(0,Uc.flushSync)(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:e.pointerDownState,selectedPointsIndices:e.selectedPointsIndices,segmentMidPointHoveredCoords:null,isDragging:!0}})});return}if(r.initialState.segmentMidpoint.value!==null&&!r.initialState.segmentMidpoint.added)return;if(r.initialState.lastClickedPoint>-1){let i=N.getElement(r.elementId,o);if(i?.isDeleted)return;if(ft(i)){let e=Nn(L(n.x,n.y),this.scene.getNonDeletedElements(),o);pe(`COMPLEX_BINDINGS`)&&this.handleDelayedBindModeChange(i,e)}if(t.altKey&&!this.state.selectedLinearElement?.initialState?.arrowStartIsInside&&pe(`COMPLEX_BINDINGS`)&&this.handleSkipBindMode(),r.initialState.lastClickedPoint===-1)return;let a=N.handlePointDragging(t,this,n.x,n.y,r);if(a){e.lastCoords.x=n.x,e.lastCoords.y=n.y,e.drag.hasOccurred=!0,(a.suggestedBinding!==this.state.suggestedBinding||!S(a.selectedLinearElement?.selectedPointsIndices??[],this.state.selectedLinearElement?.selectedPointsIndices??[])||a.selectedLinearElement?.hoverPointIndex!==this.state.selectedLinearElement?.hoverPointIndex||a.selectedLinearElement?.customLineAngle!==this.state.selectedLinearElement?.customLineAngle||this.state.selectedLinearElement.isDragging!==a.selectedLinearElement?.isDragging||this.state.selectedLinearElement?.initialState?.altFocusPoint!==a.selectedLinearElement?.initialState?.altFocusPoint)&&this.setState(a);return}}}let s=e.hit.allHitElements.some(e=>this.isASelectedElement(e)),c=this.state.selectedLinearElement?.isEditing&&t.shiftKey&&this.state.selectedLinearElement.elementId===e.hit.element?.id;if((s||e.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!c&&!e.drag.blockDragging){let i=this.scene.getSelectedElements(this.state);if(i.length>0&&i.every(e=>e.locked))return;let a=i.some(e=>P(e))?null:this.getTopLayerFrameAtSceneCoords(n,{currentFrameId:wn(i),excludeElementIds:this.state.selectedElementIds});if(this.updateFrameToHighlight(a),e.drag.hasOccurred=!0,this.state.activeTool.type===`lasso`&&this.lassoTrail.hasCurrentTrail&&!(this.editorInterface.formFactor!==`desktop`&&e.hit.element)&&!this.state.activeTool.fromSelection)return;if(this.state.activeTool.type===`lasso`&&i.length>0&&e.drag.hasOccurred&&!this.state.activeTool.fromSelection&&this.lassoTrail.endPath(),i.length>0&&!e.withCmdOrCtrl&&!this.state.editingTextElement&&this.state.activeEmbeddable?.state!==`active`){let a={x:n.x-e.drag.origin.x,y:n.y-e.drag.origin.y},s=[...e.originalElements.values()],c=t.shiftKey;if(c){let e=Math.abs(a.x),t=Math.abs(a.y),n=c&&e<t,r=c&&e>t;n&&(a.x=0),r&&(a.y=0)}if(this.state.croppingElementId){let t=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(t&&De(t)&&t.crop!==null&&e.hit.element===t){let e=t.crop,i=ae(t)&&this.imageCache.get(t.fileId)?.image;if(i&&!(i instanceof Promise)){let a=Vo(t),s=Xr(n.x-r.x,n.y-r.y);s[0]*=i.naturalWidth/a.width,s[1]*=i.naturalHeight/a.height;let[c,l,u,d,f,p]=kc(t,o),m=In(Fs(L(c,l),L(f,p),t.angle)),h=In(Fs(L(u,l),L(f,p),t.angle)),g=In(Fs(L(c,d),L(f,p),t.angle)),_=Ds(Ho(h,m)),v=Ds(Ho(g,m)),y=Xr(oi(s,_),oi(s,v)),b={...e,x:ss(e.x-y[0]*Math.sign(t.scale[0]),0,i.naturalWidth-e.width),y:ss(e.y-y[1]*Math.sign(t.scale[1]),0,i.naturalHeight-e.height)};this.scene.mutateElement(t,{crop:b});return}}}this.maybeCacheVisibleGaps(t,i),this.maybeCacheReferenceSnapPoints(t,i);let{snapOffset:l,snapLines:u}=NM(s,a,this,t,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:u}),this.state.editingFrame||fe(e,i,a,this.scene,l,t[j.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),this.setState({selectedElementsAreBeingDragged:!0,selectionElement:null}),t.altKey&&!e.hit.hasBeenDuplicated){e.hit.hasBeenDuplicated=!0;let n=this.scene.getElementsIncludingDeleted(),r=e.hit.element,i=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});r&&e.hit.wasAddedToSelection&&!i.find(e=>e.id===r.id)&&i.push(r);let a=new Map(i.map(e=>[e.id,e])),{duplicatedElements:o,duplicateElementsMap:s,elementsWithDuplicates:c,origIdToDuplicateId:l}=bc({type:`in-place`,elements:n,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:a,overrides:({duplicateElement:e,origElement:t})=>({frameId:e.frameId??t.frameId,seed:za()})});o.forEach(t=>{e.originalElements.set(t.id,ca(t))});let u=c.map(t=>{if(a.has(t.id)){let n=e.originalElements.get(t.id);if(n)return R(t,{x:n.x,y:n.y})}return t}),d=this.props.onDuplicate?.(u,n),f=Ie(d||u,ui(o));(0,Uc.flushSync)(()=>{if(e.hit.element){let t=l.get(e.hit.element.id),n=t&&s.get(t);e.hit.element=n||null}e.hit.allHitElements=e.hit.allHitElements.reduce((e,t)=>{let n=l.get(t.id),r=n&&s.get(n);return r&&e.push(r),e},[]),e.drag.origin=St(t,this.state),this.setState(e=>({...E(o,this.scene.getNonDeletedElements(),e)})),this.scene.replaceAllElements(f),i.forEach(e=>{Tt(e)&&e.boundElements?.some(e=>e.type===`arrow`)&&La(e,this.scene)}),this.maybeCacheVisibleGaps(t,i,!0),this.maybeCacheReferenceSnapPoints(t,i,!0)})}return}}if(this.state.selectionElement){if(e.lastCoords.x=n.x,e.lastCoords.y=n.y,t.altKey){this.setActiveTool({type:`lasso`,fromSelection:!0},{keepSelection:t.shiftKey}),this.lassoTrail.startPath(e.origin.x,e.origin.y,t.shiftKey),this.setAppState({selectionElement:null});return}this.maybeDragNewGenericElement(e,t)}else if(this.state.activeTool.type===`lasso`)!t.altKey&&this.state.activeTool.fromSelection?(this.setActiveTool({type:`selection`}),this.createGenericElementOnPointerDown(`selection`,e),e.lastCoords.x=n.x,e.lastCoords.y=n.y,this.maybeDragNewGenericElement(e,t),this.lassoTrail.endPath()):this.lassoTrail.addPointToPath(n.x,n.y,t.shiftKey);else{let r=this.state.newElement;if(!r)return;if(r.type===`freedraw`){let e=r.points,i=n.x-r.x,a=n.y-r.y,o=e.length>0&&e[e.length-1];if(!(o&&o[0]===i&&o[1]===a)){let n=r.simulatePressure?r.pressures:[...r.pressures,t.pressure];this.scene.mutateElement(r,{points:[...e,L(i,a)],pressures:n},{informMutation:!1,isDragging:!1}),this.setState({newElement:r})}}else if(po(r)&&!r.isDeleted){e.drag.hasOccurred=!0;let n=r.points;qa(n.length>1,`Do not create linear elements with less than 2 points`);let o=this.state.selectedLinearElement;(!o||o.elementId!==r.id)&&(o=new N(r,this.scene.getNonDeletedElementsMap())),o&&(o.initialState.lastClickedPoint<0||o.initialState.lastClickedPoint>=n.length)&&(console.warn(`Last clicked point is out of bounds. Attempting to fix it.`),o={...o,selectedPointsIndices:[n.length-1],initialState:{...o.initialState,prevSelectedPointsIndices:null,lastClickedPoint:n.length-1},hoverPointIndex:n.length-1}),this.setState({newElement:r,...N.handlePointDragging(t,this,i,a,o)})}else e.lastCoords.x=n.x,e.lastCoords.y=n.y,this.maybeDragNewGenericElement(e,t,!1)}if(this.state.activeTool.type===`selection`){e.boxSelection.hasOccurred=!0;let n=this.scene.getNonDeletedElements();if(this.state.selectedLinearElement?.isEditing)N.handleBoxSelection(t,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let r=!0;!t.shiftKey&&Bi(n,this.state)&&(e.withCmdOrCtrl&&e.hit.element?this.setState(t=>na({...t,selectedElementIds:{[e.hit.element.id]:!0}},this.scene.getNonDeletedElements(),t,this)):r=!1);let i=this.state.selectionElement?yr(n,this.state.selectionElement,this.scene.getNonDeletedElementsMap(),!1,this.state.boxSelectionMode):[];this.setState(t=>{let n={...r&&t.selectedElementIds,...i.reduce((e,t)=>(e[t.id]=!0,e),{})};return e.hit.element&&(i.length?delete n[e.hit.element.id]:n[e.hit.element.id]=!0),t=r?t:{...t,selectedGroupIds:{},editingGroupId:null},{...na({editingGroupId:t.editingGroupId,selectedElementIds:n},this.scene.getNonDeletedElements(),t,this),selectedLinearElement:i.length===1&&po(i[0])?new N(i[0],this.scene.getNonDeletedElementsMap()):null,showHyperlinkPopup:i.length===1&&(i[0].link||us(i[0]))?`info`:!1}})}}})}handlePointerMoveOverScrollbars(e,t){if(t.scrollbars.isOverHorizontal){let n=e.clientX,r=n-t.lastCoords.x;return this.viewport.translate({scrollX:this.state.scrollX-r*(bV.horizontal?.deltaMultiplier||1)/this.state.zoom.value}),t.lastCoords.x=n,!0}if(t.scrollbars.isOverVertical){let n=e.clientY,r=n-t.lastCoords.y;return this.viewport.translate({scrollY:this.state.scrollY-r*(bV.vertical?.deltaMultiplier||1)/this.state.zoom.value}),t.lastCoords.y=n,!0}return!1}onPointerUpFromPointerDownHandler(e){return qM(t=>{let n=this.scene.getNonDeletedElementsMap();this.removePointer(t),e.drag.blockDragging=!1,e.eventListeners.onMove&&e.eventListeners.onMove.flush(),t.type===`pointerup`&&this.state.activeTool.type===Ks.bucketfill?this.bucketFill.handlePointerUp():this.bucketFill.cancel();let{newElement:r,resizingElement:i,croppingElementId:o,multiElement:s,activeTool:c,isResizing:l,isRotating:u,isCropping:d}=this.state;this.setState(e=>({isResizing:!1,isRotating:!1,isCropping:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:`up`,snapLines:Ni(e.snapLines,[]),originSnapOffset:null})),this.lassoTrail.endPath(),this.previousPointerMoveCoords=null,CM.setReferenceSnapPoints(null),CM.setVisibleGaps(null),this.savePointer(t.clientX,t.clientY,`up`);let f=e.hit.allHitElements,p=St({clientX:t.clientX,clientY:t.clientY},this.state);if(this.state.activeTool.type===`selection`&&!e.boxSelection.hasOccurred&&!e.resize.isResizing&&!f.some(e=>this.state.selectedElementIds[e.id])){let e=this.getElementAtPosition(p.x,p.y,{includeLockedElements:!0});this.isEditingTextContent()||this.store.scheduleCapture(),e?.locked?this.setState({activeLockedId:e.groupIds.length>0?e.groupIds.at(-1)||``:e.id}):this.setState({activeLockedId:null})}else this.setState({activeLockedId:null});if(pe(`COMPLEX_BINDINGS`)&&this.resetDelayedBindMode(),this.setState({selectedElementsAreBeingDragged:!1,bindMode:`orbit`}),e.drag.hasOccurred&&e.hit?.element?.id){let t=n.get(e.hit.element.id);Tt(t)&&t.boundElements?.filter(e=>e.type===`arrow`).map(e=>n.get(e.id)).filter(e=>ve(e)).forEach(e=>{e&&this.scene.mutateElement(e,{})})}if(this.state.selectedLinearElement?.isEditing&&!this.state.newElement&&this.state.selectedLinearElement.draggedFocusPointBinding===null){if(!e.boxSelection.hasOccurred&&e.hit?.element?.id!==this.state.selectedLinearElement.elementId&&this.state.selectedLinearElement.draggedFocusPointBinding===null)this.actionManager.executeAction(PT);else{let e=N.handlePointerUp(t,this.state.selectedLinearElement,this.state,this.scene);this.actionManager.executeAction(PT,`ui`,{event:t,sceneCoords:p}),e!==this.state.selectedLinearElement&&this.setState({selectedLinearElement:e,suggestedBinding:null})}}else if(this.state.selectedLinearElement){if(this.state.selectedLinearElement.elbowed){let e=N.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());e&&this.scene.mutateElement(e,{})}if(this.state.selectedLinearElement.draggedFocusPointBinding?(yi(this.state.selectedLinearElement,this.scene),this.setState({selectedLinearElement:{...this.state.selectedLinearElement,draggedFocusPointBinding:null,initialState:{...this.state.selectedLinearElement.initialState,arrowOtherEndpointInitialBinding:null}}})):e.hit?.element?.id===this.state.selectedLinearElement.elementId?this.state.selectedLinearElement.isDragging&&(this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!1}}),this.actionManager.executeAction(PT,`ui`,{event:t,sceneCoords:p})):this.scene.getSelectedElements(this.state).length>1&&this.setState({selectedLinearElement:null}),this.state.newElement&&this.state.multiElement&&po(this.state.newElement)&&this.state.selectedLinearElement){let{multiElement:e}=this.state;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,lastCommittedPoint:e.points[e.points.length-1]}})}}if(this.missingPointerEventCleanupEmitter.clear(),window.removeEventListener(T.POINTER_MOVE,e.eventListeners.onMove),window.removeEventListener(T.POINTER_UP,e.eventListeners.onUp),window.removeEventListener(T.KEYDOWN,e.eventListeners.onKeyDown),window.removeEventListener(T.KEYUP,e.eventListeners.onKeyUp),this.props?.onPointerUp?.(c,e),this.onPointerUpEmitter.trigger(this.state.activeTool,e,t),r?.type===`freedraw`){let e=St(t,this.state),n=r.points,i=e.x-r.x,a=e.y-r.y;i===n[0][0]&&a===n[0][1]&&(a+=1e-4,i+=1e-4);let o=r.simulatePressure?[]:[...r.pressures,t.pressure];this.scene.mutateElement(r,{points:[...n,L(i,a)],pressures:o}),this.actionManager.executeAction(PT);return}if(po(r)&&this.state.activeTool.type!==`autoshape`){let n=St(t,this.state),i=ya(L(n.x,n.y),L(e.origin.x,e.origin.y))*this.state.zoom.value;if((!e.drag.hasOccurred||i<20)&&r&&!s){if(this.editorInterface.isTouchScreen){let e=Math.min(this.state.width*.7/this.state.zoom.value,100);this.scene.mutateElement(r,{x:r.x-e/2,points:[L(0,0),L(e,0)]},{informMutation:!1,isDragging:!1}),this.actionManager.executeAction(PT)}else this.setState({multiElement:r,newElement:r})}else e.drag.hasOccurred&&!s&&(this.store.scheduleCapture(),po(r)&&this.actionManager.executeAction(PT,`ui`,{event:t,sceneCoords:p}),this.setState({suggestedBinding:null}),this.isToolLocked()?this.setState({newElement:null}):this.setState(e=>({newElement:null,activeTool:Pt(this.state,{type:this.state.preferredSelectionTool.type}),selectedElementIds:fa({...e.selectedElementIds,[r.id]:!0},e),selectedLinearElement:new N(r,this.scene.getNonDeletedElementsMap())}),()=>this.cursor.reset()),this.scene.triggerUpdate());return}if(a(r)){let e=Ki(tc({fontSize:r.fontSize,fontFamily:r.fontFamily}),r.lineHeight);r.width<e&&this.scene.mutateElement(r,{autoResize:!0}),this.cursor.reset(),this.handleTextWysiwyg(r,{isExistingElement:!0})}if(c.type!==`selection`&&r&&li(r)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(e=>e.id!==r.id),appState:{newElement:null},captureUpdate:F.NEVER});return}if(P(r)){let e=As(this.scene.getElementsIncludingDeleted(),r,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(Ke(this.scene.getElementsMapIncludingDeleted(),e,r))}if(r&&(this.scene.mutateElement(r,zr(r),{informMutation:!1,isDragging:!1}),this.scene.triggerUpdate()),e.drag.hasOccurred){let e=St(t,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let e=this.scene.getElement(this.state.selectedLinearElement.elementId);if(e?.frameId){let t=Bt(e,n);t&&e&&(Gn(e,t,this.scene.getNonDeletedElementsMap())||(this.scene.mutateElement(e,{groupIds:[]}),_n([e],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let t=this.scene.getSelectedElements(this.state),n=this.getTopLayerFrameAtSceneCoords(e,{currentFrameId:wn(t),excludeElementIds:this.state.selectedElementIds}),r=this.scene.getElementsMapIncludingDeleted(),i=e=>{if(e.length>0){for(let t of e){let e=t.groupIds.indexOf(this.state.editingGroupId);this.scene.mutateElement(t,{groupIds:t.groupIds.slice(0,e)},{informMutation:!1,isDragging:!1})}r.forEach(e=>{e.groupIds.length&&yt(r,e.groupIds[e.groupIds.length-1]).length<2&&this.scene.mutateElement(e,{groupIds:[]},{informMutation:!1,isDragging:!1})}),this.setState({editingGroupId:null})}};if(n&&!this.state.selectedElementIds[n.id]){let e=t.filter(e=>co(e,r,this.state));this.state.editingGroupId&&i(e),r=Ke(r,e,n)}else!n&&this.state.editingGroupId&&i(t.filter(e=>e.frameId&&!co(e,r,this.state)));r=Ma(r,this.state,this),this.scene.replaceAllElements(r)}}if(i&&this.store.scheduleCapture(),i&&li(i)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(e=>e.id!==i.id),captureUpdate:F.NEVER}),e.resize.isResizing){let e=Ma(this.scene.getElementsIncludingDeleted(),this.state,this),t=this.scene.getSelectedElements(this.state).filter(P);for(let r of t)e=xi(e,Os(this.scene.getElementsIncludingDeleted(),r,this.state,n),r);this.scene.replaceAllElements(e)}let m=e.hit.element;this.state.selectedLinearElement?.elementId!==m?.id&&po(m)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new N(m,this.scene.getNonDeletedElementsMap())}),(!o||o&&(!m&&!d||m&&m.id!==o))&&this.finishImageCropping();let h=this.lastPointerDownEvent,g=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(ji(this.state)&&h&&g){if(this.eraserTrail.endPath(),ya(L(h.clientX,h.clientY),L(g.clientX,g.clientY))===0){let e=St({clientX:g.clientX,clientY:g.clientY},this.state);this.getElementsAtPosition(e.x,e.y).forEach(e=>this.elementsPendingErasure.add(e.id))}this.eraseElements();return}if(this.elementsPendingErasure.size&&this.restoreReadyToEraseElements(),m&&!e.drag.hasOccurred&&!e.hit.wasAddedToSelection&&(!this.state.selectedLinearElement?.isEditing||!e.boxSelection.hasOccurred)&&this.state.activeTool.type!==`lasso`&&(t.shiftKey&&!this.state.selectedLinearElement?.isEditing?this.state.selectedElementIds[m.id]?$s(this.state,m)?this.setState(e=>{let t={...e.selectedElementIds};for(let e of m.groupIds.flatMap(e=>yt(this.scene.getNonDeletedElements(),e)))delete t[e.id];return{selectedGroupIds:{...e.selectedElementIds,...m.groupIds.map(e=>({[e]:!1})).reduce((e,t)=>({...e,...t}),{})},selectedElementIds:fa(t,e)}}):this.state.selectedLinearElement?.isDragging||this.setState(e=>{let t={...e.selectedElementIds};delete t[m.id];let n=xt(this.scene.getNonDeletedElements(),{selectedElementIds:t});return{...na({editingGroupId:e.editingGroupId,selectedElementIds:t},this.scene.getNonDeletedElements(),e,this),selectedLinearElement:n.length===1&&po(n[0])?new N(n[0],this.scene.getNonDeletedElementsMap()):e.selectedLinearElement}}):m.frameId&&this.state.selectedElementIds[m.frameId]?this.setState(e=>{let t={...e.selectedElementIds,[m.id]:!0};return delete t[m.frameId],(this.scene.getElement(m.frameId)?.groupIds??[]).flatMap(e=>yt(this.scene.getNonDeletedElements(),e)).forEach(e=>{delete t[e.id]}),{...na({editingGroupId:e.editingGroupId,selectedElementIds:t},this.scene.getNonDeletedElements(),e,this),showHyperlinkPopup:m.link||us(m)?`info`:!1}}):this.setState(e=>({selectedElementIds:fa({...e.selectedElementIds,[m.id]:!0},e)})):this.setState(e=>({...na({editingGroupId:e.editingGroupId,selectedElementIds:{[m.id]:!0}},this.scene.getNonDeletedElements(),e,this),selectedLinearElement:po(m)&&e.selectedLinearElement?.elementId!==m.id?new N(m,this.scene.getNonDeletedElementsMap()):e.selectedLinearElement}))),this.state.activeTool.type!==`lasso`&&!(m&&ve(m))&&!e.drag.hasOccurred&&!this.state.isResizing&&(m&&w({point:L(e.origin.x,e.origin.y),element:m,elementsMap:n,threshold:this.getElementHitThreshold(m),frameNameBound:P(m)?this.frameNameBoundsCache.get(m):null},n)||!m&&e.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.selectedLinearElement?.isEditing?this.actionManager.executeAction($j):this.setState({selectedElementIds:fa({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),this.cursor.set(Et.AUTO);return}let v=this.getSelectedTextEditingContainerAtPosition(m,p);if(c.type===this.state.preferredSelectionTool.type&&!this.state.editingTextElement&&!e.drag.hasOccurred&&!e.hit.wasAddedToSelection&&!t.shiftKey&&!t[j.CTRL_OR_CMD]&&!t.altKey&&t.pointerType!==`touch`&&m&&(a(m)&&this.state.selectedElementIds[m.id]&&this.scene.getSelectedElements(this.state).length===1||v)){this.startTextEditing({sceneX:p.x,sceneY:p.y,container:v,initialCaretSceneCoords:this.lastPointerUpIsDoubleClick?void 0:p});return}if(!this.isToolLocked()&&c.type!==`freedraw`&&r&&this.setState(e=>({selectedElementIds:fa({...e.selectedElementIds,[r.id]:!0},e),showHyperlinkPopup:us(r)&&!r.link?`editor`:e.showHyperlinkPopup})),!this.isEditingTextContent()&&(c.type!==`selection`||Bi(this.scene.getNonDeletedElements(),this.state)||!S(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.scheduleCapture(),e.drag.hasOccurred&&!this.state.selectedLinearElement||l||u||d){let e=this.scene.getSelectedElements(this.state).filter(_);Ur(e,this.scene,this.state)}if(c.type===`laser`){this.laserTrails.endPath();return}if(c.type===`autoshape`){this.actionManager.executeAction(PT);return}!this.isToolLocked()&&c.type!==`freedraw`&&c.type!==Ks.bucketfill&&(c.type!==`lasso`||c.type===`lasso`&&c.fromSelection)?this.setState({newElement:null,suggestedBinding:null,activeTool:Pt(this.state,{type:this.state.preferredSelectionTool.type})},()=>this.cursor.reset()):this.setState({newElement:null,suggestedBinding:null})})}clearSelection(e){this.setState(t=>({selectedElementIds:fa({},t),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:t.editingGroupId&&e!=null&&oa(e,t.editingGroupId)?t.editingGroupId:null})),this.setState({selectedElementIds:fa({},this.state),activeEmbeddable:null,previousSelectedElementIds:this.state.selectedElementIds,selectedLinearElement:null})}getTextWysiwygSnappedToCenterPosition(e,t,n,r){if(r){let i=r.x+r.width/2,a=r.y+r.height/2,o=mt(r,this.scene.getNonDeletedElementsMap());if(o&&(i=o.x,a=o.y),Math.hypot(e-i,t-a)<30){let{x:e,y:t}=Tn({sceneX:i,sceneY:a},n);return{viewportX:e,viewportY:t,elementCenterX:i,elementCenterY:a}}}}getCanvasOffsets(){if(this.excalidrawContainerRef?.current){let{left:e,top:t}=this.excalidrawContainerRef.current.getBoundingClientRect();return{offsetLeft:e,offsetTop:t}}return{offsetLeft:0,offsetTop:0}}async updateLanguage(){await Ly(Ny.find(e=>e.code===this.props.langCode)||My),this.setAppState({})}};(fc()||ci())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(ti(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}));var AV=kV,jV=e=>{let[t,n]=(0,B.useState)(!0);return(0,B.useEffect)(()=>{let t=async()=>{await Ly(r),n(!1)},r=Ny.find(t=>t.code===e.langCode)||My;t()},[e.langCode]),t?(0,V.jsx)(SF,{theme:e.theme}):e.children},MV=({children:e})=>{let{FooterCenterTunnel:t}=yF(),n=EC();return(0,V.jsx)(t.In,{children:(0,V.jsx)(`div`,{className:H(`footer-center zen-mode-transition`,{"layer-ui__wrapper__footer-left--transition-bottom":n.zenModeEnabled}),children:e})})},NV=MV;MV.displayName=`FooterCenter`;var PV=({isCollaborating:e,onSelect:t,editorInterface:n,...r})=>{let i=EC(),a=n?.formFactor!==`desktop`||i.width<1440;return(0,V.jsxs)(Rk,{...r,className:H(`collab-button`,{active:e}),type:`button`,onSelect:t,style:{position:`relative`,width:a?void 0:`auto`},title:W(`labels.liveCollaboration`),children:[a?Kb:W(`labels.share`),i.collaborators.size>0&&(0,V.jsx)(`div`,{className:`CollabButton-collaborators`,children:i.collaborators.size})]})},FV=PV;PV.displayName=`LiveCollaborationTrigger`;var IV=()=>(0,V.jsx)(`svg`,{viewBox:`0 0 40 40`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,className:`ExcalidrawLogo-icon`,children:(0,V.jsx)(`path`,{d:`M39.9 32.889a.326.326 0 0 0-.279-.056c-2.094-3.083-4.774-6-7.343-8.833l-.419-.472a.212.212 0 0 0-.056-.139.586.586 0 0 0-.167-.111l-.084-.083-.056-.056c-.084-.167-.28-.278-.475-.167-.782.39-1.507.973-2.206 1.528-.92.722-1.842 1.445-2.708 2.25a8.405 8.405 0 0 0-.977 1.028c-.14.194-.028.361.14.444-.615.611-1.23 1.223-1.843 1.861a.315.315 0 0 0-.084.223c0 .083.056.166.111.194l1.09.833v.028c1.535 1.528 4.244 3.611 7.12 5.861.418.334.865.667 1.284 1 .195.223.39.473.558.695.084.11.28.139.391.055.056.056.14.111.196.167a.398.398 0 0 0 .167.056.255.255 0 0 0 .224-.111.394.394 0 0 0 .055-.167c.029 0 .028.028.056.028a.318.318 0 0 0 .224-.084l5.082-5.528a.309.309 0 0 0 0-.444Zm-14.63-1.917a.485.485 0 0 0 .111.14c.586.5 1.2 1 1.843 1.555l-2.569-1.945-.251-.166c-.056-.028-.112-.084-.168-.111l-.195-.167.056-.056.055-.055.112-.111c.866-.861 2.346-2.306 3.1-3.028-.81.805-2.43 3.167-2.095 3.944Zm8.767 6.89-2.122-1.612a44.713 44.713 0 0 0-2.625-2.5c1.145.861 2.122 1.611 2.262 1.75 1.117.972 1.06.806 1.815 1.445l.921.666a1.06 1.06 0 0 1-.251.25Zm.558.416-.056-.028c.084-.055.168-.111.252-.194l-.196.222ZM1.089 5.75c.055.361.14.722.195 1.056.335 1.833.67 3.5 1.284 4.75l.252.944c.084.361.223.806.363.917 1.424 1.25 3.602 3.11 5.947 4.889a.295.295 0 0 0 .363 0s0 .027.028.027a.254.254 0 0 0 .196.084.318.318 0 0 0 .223-.084c2.988-3.305 5.221-6.027 6.813-8.305.112-.111.14-.278.14-.417.111-.111.195-.25.307-.333.111-.111.111-.306 0-.39l-.028-.027c0-.055-.028-.139-.084-.167-.698-.666-1.2-1.138-1.731-1.638-.922-.862-1.871-1.75-3.881-3.75l-.028-.028c-.028-.028-.056-.056-.112-.056-.558-.194-1.703-.389-3.127-.639C6.087 2.223 3.21 1.723.614.944c0 0-.168 0-.196.028l-.083.084c-.028.027-.056.055-.224.11h.056-.056c.028.167.028.278.084.473 0 .055.112.5.112.555l.782 3.556Zm15.496 3.278-.335-.334c.084.112.196.195.335.334Zm-3.546 4.666-.056.056c0-.028.028-.056.056-.056Zm-2.038-10c.168.167.866.834 1.033.973-.726-.334-2.54-1.167-3.379-1.445.838.167 1.983.334 2.346.472ZM1.424 2.306c.419.722.754 3.222 1.089 5.666-.196-.778-.335-1.555-.503-2.278-.251-1.277-.503-2.416-.838-3.416.056 0 .14 0 .252.028Zm-.168-.584c-.112 0-.223-.028-.307-.028 0-.027 0-.055-.028-.055.14 0 .223.028.335.083Zm-1.089.222c0-.027 0-.027 0 0ZM39.453 1.333c.028-.11-.558-.61-.363-.639.42-.027.42-.666 0-.666-.558.028-1.144.166-1.675.25-.977.194-1.982.389-2.96.61-2.205.473-4.383.973-6.561 1.557-.67.194-1.424.333-2.066.666-.224.111-.196.333-.084.472-.056.028-.084.028-.14.056-.195.028-.363.056-.558.083-.168.028-.252.167-.224.334 0 .027.028.083.028.11-1.173 1.556-2.485 3.195-3.909 4.945-1.396 1.611-2.876 3.306-4.356 5.056-4.719 5.5-10.052 11.75-15.943 17.25a.268.268 0 0 0 0 .389c.028.027.056.055.084.055-.084.084-.168.14-.252.222-.056.056-.084.111-.084.167a.605.605 0 0 0-.111.139c-.112.111-.112.305.028.389.111.11.307.11.39-.028.029-.028.029-.056.056-.056a.44.44 0 0 1 .615 0c.335.362.67.723.977 1.028l-.698-.583c-.112-.111-.307-.083-.39.028-.113.11-.085.305.027.389l7.427 6.194c.056.056.112.056.196.056s.14-.028.195-.084l.168-.166c.028.027.083.027.111.027.084 0 .14-.027.196-.083 10.052-10.055 18.15-17.639 27.42-24.417.083-.055.111-.166.111-.25.112 0 .196-.083.251-.194 1.704-5.194 2.039-9.806 2.15-12.083v-.028c0-.028.028-.056.028-.083.028-.056.028-.084.028-.084a1.626 1.626 0 0 0-.111-1.028ZM21.472 9.5c.446-.5.893-1.028 1.34-1.5-2.876 3.778-7.65 9.583-14.408 16.5 4.607-5.083 9.242-10.333 13.068-15ZM5.193 35.778h.084-.084Zm3.462 3.194c-.027-.028-.027-.028 0-.028v.028Zm4.16-3.583c.224-.25.448-.472.699-.722 0 0 0 .027.028.027-.252.223-.475.445-.726.695Zm1.146-1.111c.14-.14.279-.334.446-.5l.028-.028c1.648-1.694 3.351-3.389 5.082-5.111l.028-.028c.419-.333.921-.694 1.368-1.028a379.003 379.003 0 0 0-6.952 6.695ZM24.794 6.472c-.921 1.195-1.954 2.778-2.82 4.028-2.736 3.944-11.532 13.583-11.727 13.75a1976.983 1976.983 0 0 1-8.042 7.639l-.167.167c-.14-.167-.14-.417.028-.556C14.49 19.861 22.03 10.167 25.074 5.917c-.084.194-.14.36-.28.555Zm4.83 5.695c-1.116-.64-1.646-1.64-1.34-2.611l.084-.334c.028-.083.084-.194.14-.277.307-.5.754-.917 1.257-1.167.027 0 .055 0 .083-.028-.028-.056-.028-.139-.028-.222.028-.167.14-.278.335-.278.335 0 1.369.306 1.76.639.111.083.223.194.335.305.14.167.363.445.474.667.056.028.112.306.196.445.056.222.111.472.084.694-.028.028 0 .194-.028.194a2.668 2.668 0 0 1-.363 1.028c-.028.028-.028.056-.056.084l-.028.027c-.14.223-.335.417-.53.556-.643.444-1.369.583-2.095.389 0 0-.195-.084-.28-.111Zm8.154-.834a39.098 39.098 0 0 1-.893 3.167c0 .028-.028.083 0 .111-.056 0-.084.028-.14.056-2.206 1.61-4.356 3.305-6.506 5.028 1.843-1.64 3.686-3.306 5.613-4.945.558-.5.949-1.139 1.06-1.861l.28-1.667v-.055c.14-.334.67-.195.586.166Z`,fill:`currentColor`})}),LV=()=>(0,V.jsxs)(`svg`,{viewBox:`0 0 450 55`,xmlns:`http://www.w3.org/2000/svg`,fill:`none`,className:`ExcalidrawLogo-text`,children:[(0,V.jsx)(`path`,{d:`M429.27 96.74c2.47-1.39 4.78-3.02 6.83-4.95 1.43-1.35 2.73-2.86 3.81-4.51-.66.9-1.4 1.77-2.23 2.59-2.91 2.84-5.72 5.09-8.42 6.87h.01ZM343.6 69.36c.33 3.13.58 6.27.79 9.4.09 1.37.18 2.75.25 4.12-.12-4.46-.27-8.93-.5-13.39-.11-2.08-.24-4.16-.4-6.24-.06 1.79-.11 3.85-.13 6.11h-.01ZM378.47 98.34c.01-.37.07-1.13.01-6.51-.11 1.9-.22 3.81-.31 5.71-.07 1.42-.22 2.91-.16 4.35.39.03.78.07 1.17.1-.92-.85-.76-2.01-.72-3.66l.01.01ZM344.09 86.12c-.09-2.41-.22-4.83-.39-7.24v12.21c.15-.05.32-.09.47-.14.05-1.61-.03-3.23-.09-4.83h.01ZM440.69 66.79c-.22-.34-.45-.67-.69-.99-3.71-4.87-9.91-7.14-15.65-8.55-1.05-.26-2.12-.49-3.18-.71 2.29.59 4.48 1.26 6.64 2.02 7.19 2.54 10.57 5.41 12.88 8.23ZM305.09 72.46l1.2 3.6c.84 2.53 1.67 5.06 2.46 7.61.24.78.5 1.57.73 2.36.22-.04.44-.08.67-.12a776.9 776.9 0 0 1-5.01-13.57c-.02.04-.03.09-.05.13v-.01ZM345.49 90.25v.31c1.48-.42 3.05-.83 4.66-1.2-1.56.25-3.12.52-4.66.89ZM371.02 90.22c0-.57-.04-1.14-.11-1.71-.06-.02-.12-.04-.19-.05-.21-.05-.43-.08-.65-.11.42.16.74.88.95 1.87ZM398.93 54.23c-.13 0-.27-.01-.4-.02l.03.4c.11-.15.23-.27.37-.38ZM401.57 62.28v-.15c-1.22-.24-2.86-.61-3.23-1.25-.09-.15-.18-.51-.27-.98-.09.37-.2.73-.33 1.09 1.24.56 2.52.98 3.83 1.29ZM421.73 88.68c-2.97 1.65-6.28 3.12-9.69 3.68v.18c4.72-.14 11.63-3.85 16.33-8.38-2.04 1.75-4.33 3.24-6.63 4.53l-.01-.01ZM411.28 80.92c-.05-1.2-.09-2.4-.15-3.6-.21 5.66-.46 11.38-.47 14.51.24-.02.48-.04.71-.07.15-3.61.05-7.23-.09-10.83v-.01Z`,transform:`translate(-144.023 -51.76)`}),(0,V.jsx)(`path`,{d:`M425.38 67.41c-3.5-1.45-7.19-2.57-14.06-3.62.09 1.97.06 4.88-.03 8.12.03.04.06.09.06.15.19 1.36.28 2.73.37 4.1.25 3.77.39 7.55.41 11.33 0 1.38-.01 2.76-.07 4.13 1.4-.25 2.78-.65 4.12-1.15 4.07-1.5 7.94-3.78 11.28-6.54 2.33-1.92 5.13-4.49 5.88-7.58.63-3.53-2.45-6.68-7.97-8.96l.01.02ZM411.35 92.53v-.06l-.34.03c.11.01.22.03.34.03ZM314.26 64.06c-.23-.59-.47-1.17-.7-1.75.57 1.62 1.11 3.25 1.6 4.9l.15.54 2.35 6.05c.32.82.66 1.64.98 2.46-1.38-4.1-2.83-8.17-4.39-12.2h.01ZM156.82 103.07c-.18.13-.38.23-.58.33 1.32-.03 2.66-.2 3.93-.34.86-.09 1.72-.22 2.58-.33-2.12.1-4.12.17-5.94.34h.01ZM210.14 68.88s.03.04.05.07c.18-.31.39-.64.58-.96-.21.3-.42.6-.64.89h.01ZM201.65 82.8c-.5.77-1.02 1.56-1.49 2.37 1.11-1.55 2.21-3.1 3.2-4.59-.23.23-.49.51-.75.79-.32.47-.65.95-.96 1.43ZM194.03 98.66c-.33-.4-.65-.84-1.05-1.17-.24-.2-.07-.49.17-.56-.23-.26-.42-.5-.63-.75 1.51-2.55 3.93-5.87 6.4-9.28-.17-.08-.29-.28-.2-.49.04-.09.09-.17.13-.26-1.21 1.78-2.42 3.55-3.61 5.33-.87 1.31-1.74 2.64-2.54 4-.29.5-.63 1.04-.87 1.61.81.65 1.63 1.27 2.47 1.88-.09-.11-.18-.21-.27-.32v.01ZM307.79 82.93c-1-3.17-2.05-6.32-3.1-9.48-1.62 4.08-3.69 9.17-6.16 15.19 3.32-1.04 6.77-1.87 10.27-2.5-.32-1.08-.67-2.15-1.01-3.21ZM149.5 80.7c.05-1.71.04-3.43 0-5.14-.1 2.26-.16 4.51-.22 6.77-.02.73-.03 1.46-.04 2.19.14-1.27.2-2.55.24-3.82h.02ZM228.98 98.3c.39 1.25.91 3.03.94 3.91.06-.03.12-.07.17-.1.08-1.29-.55-2.65-1.11-3.81ZM307.72 53.36c.81.5 1.53 1.04 2.07 1.49-.38-.8-.78-1.58-1.21-2.35-.17.03-.34.06-.51.11-.43.12-.86.26-1.29.41.35-.01.53.1.94.34ZM283.69 96.14c3.91-7.25 6.89-13.35 8.88-18.15l1.1-2.66c-1.27 2.64-2.56 5.27-3.83 7.9-1.53 3.15-3.06 6.31-4.58 9.47-.87 1.81-1.76 3.62-2.54 5.47.04.02.07.04.11.07.05.05.1.09.15.14.05-.73.27-1.48.71-2.24ZM289.92 103.23s-.04.01-.05.03c0-.02.04-.03.05-.04.05-.05.11-.1.16-.15l.21-.21c-.55 0-1.5-.27-2.55-.72.4.26.8.51 1.22.74.24.13.48.26.73.37.05.02.1.03.14.05a.27.27 0 0 1 .08-.07h.01ZM269.23 68.49c-.39-.19-.82-.48-1.33-.87-3.06-1.56-6.31-2.78-9.36-2.35-3.5.49-5.7 1.11-7.74 2.44 5.71-2.6 12.82-2.07 18.44.79l-.01-.01ZM177.87 53.69l1.06.03c-.96-.22-2-.25-2.89-.3-4.95-.26-9.99.33-14.86 1.19-2.44.43-4.88.95-7.28 1.59 9.09-1.76 15.69-2.77 23.97-2.51ZM219.85 55.51c-.18.12-.36.27-.56.45-.45.53-.86 1.11-1.26 1.66-1.91 2.61-3.71 5.31-5.57 7.95l-.12.18 8.05-10.11c-.18-.05-.36-.1-.55-.13h.01ZM510.71 54.1c.12-.15.29-.3.53-.45.69-.4 3.72-.63 5.87-.74-.36-.02-.73-.04-1.09-.05-1.84-.03-3.67.09-5.49.35.05.3.12.59.18.88v.01ZM510.76 86.02c1.37-3.07 2.49-6.27 3.57-9.46.55-1.64 1.12-3.3 1.6-4.97-1.59 4.01-3.67 9.14-6.2 15.3.24-.08.5-.14.74-.22.1-.22.19-.44.29-.65ZM566.95 75.76c.11-.02.23.03.31.11-.05-.13-.09-.26-.14-.39-.05.09-.11.18-.17.28ZM511.33 86.41c3.08-.89 6.24-1.62 9.46-2.14-1.51-3.98-2.98-7.96-4.39-11.87-.05.15-.09.31-.14.46-1.02 3.32-2.15 6.61-3.39 9.85-.48 1.25-.98 2.49-1.53 3.7h-.01ZM578.24 74.45c.11-.44.23-.87.35-1.31-.31.7-.64 1.39-.97 2.08.09.21.19.4.28.61.12-.46.23-.92.35-1.38h-.01ZM520.62 53.11c-.09 0-.18-.01-.28-.02.38.34.29 1.08.93 2.53l6.65 17.15c2.2 5.68 4.69 11.36 7.41 16.87l1.06 2.17c-2.95-7.05-5.92-14.08-8.87-21.13-1.58-3.79-3.16-7.59-4.7-11.4-.78-1.92-1.73-3.89-2.25-5.91-.03-.1 0-.19.04-.26h.01ZM578.78 77.87c1.45-5.77 3.07-10.43 3.58-13.36.05-.34.16-.88.31-1.55-.67 1.79-1.37 3.56-2.08 5.33-.12.43-.23.86-.35 1.29-.65 2.43-1.29 4.86-1.9 7.3.14.33.29.65.43 1l.01-.01ZM545.3 94.66c.02-.44.03-.83.05-1.12.02-1.01.05-2.02.11-3.02.03-6.66-.46-14.33-1.46-22.8-.13-.42-.27-1.24-.56-2.89 0-.02 0-.04-.01-.06.62 6.61.95 13.25 1.32 19.87.17 3.08.33 6.16.52 9.23.02.25.03.52.04.78l-.01.01ZM580.77 102.81c.13.2.27.38.37.49.27-.11.53-.22.8-.32-.43.09-.82.05-1.17-.16v-.01ZM530.48 104.07h.33c-.36-.13-.71-.32-1.04-.56.14.24.3.47.45.7.06-.08.14-.13.26-.13v-.01ZM542.63 58.82c.06.23.11.47.15.71.14-.33.36-.62.7-.86-.28.05-.57.11-.85.15ZM583.81 57.87c.15-.7.29-1.41.42-2.11-.14.45-.28.9-.42 1.34-.46 1.44-.89 2.89-1.31 4.34.44-1.19.88-2.37 1.31-3.57ZM523.62 91.48c-4.66 1.17-9.05 2.89-14.02 5.27 4.65-1.84 9.48-3.29 14.28-4.63-.09-.22-.17-.41-.26-.64ZM460.64 78.3c-.04-2.9-.11-5.81-.28-8.71-.1-1.68-.17-3.43-.5-5.09-.07.02-.14.03-.2.05.3 6.54.45 12.17.51 17.12.17-.07.34-.14.51-.2 0-1.06-.01-2.11-.03-3.17h-.01ZM470.63 63.24c-3.38-.26-6.81.32-10.1 1.1.41 2.01.47 4.14.57 6.18.18 3.55.25 7.11.27 10.67 3.31-1.38 6.5-3.12 9.3-5.35 1.96-1.56 3.86-3.41 5.02-5.66.73-1.41 1.19-3.22.26-4.65-1.09-1.7-3.46-2.14-5.32-2.29ZM460.29 63.68c1-.24 2.01-.46 3.04-.65-1.15.16-2.37.38-3.71.69v.13c.07-.02.15-.04.22-.05.11-.13.3-.18.45-.11v-.01ZM457.24 100.96c.43-.03.86-.07 1.29-.11.14-.49.27-.99.38-1.49-.44.7-1 1.23-1.67 1.6ZM482.88 104.98c-.18.23-.36.38-.55.47.14.09.27.19.4.28a70.76 70.76 0 0 0 4.37-4.63c.76-.89 1.52-1.81 2.19-2.77-.3-.27-.61-.53-.92-.79-.07 1.94-4.62 6.32-5.49 7.45v-.01Z`,transform:`translate(-144.023 -51.76)`}),(0,V.jsx)(`path`,{d:`M474.36 63.31c-.4-.16-.84-.27-1.29-.37 1.56.42 3.08 1.22 3.76 2.74.62 1.4.32 2.95-.28 4.32.7-1.22.94-2.34.74-3.47-.24-1.33-1.19-2.54-2.93-3.21v-.01ZM477.34 89.18c-1.2-.81-2.4-1.62-3.6-2.42-.14.1-.26.19-.4.29 1.4.67 2.73 1.39 4 2.13ZM465.88 93.85c.37.25.74.5 1.1.75.46.32.92.65 1.38.97-1.57-1.2-2.01-1.61-2.49-1.72h.01ZM574.92 90.06c-2.28-5.21-4.93-11.13-5.67-12.26-.1-.15-1.57-3.01-1.63-3.08 0 0-.01.02-.02.02.4 1.37 1.09 2.69 1.65 3.99 2.14 4.95 4.36 9.86 6.67 14.73.6 1.26 1.21 2.52 1.83 3.78-.75-2.01-1.64-4.45-2.83-7.18ZM448.73 65.29c.1.2.22.38.34.57.22-.02.43-.06.65-.08v-.08c-.14-.05-.25 0-.99-.41ZM460.16 94.81c-.02.31-.06.59-.1.89-.03 1.71-.33 3.43-.79 5.07.15-.02.3-.03.45-.05.01-.04.02-.08.03-.11.09-.34.15-.69.2-1.03.17-1.07.25-2.16.33-3.24.05-.69.08-1.39.12-2.08-.27.1-.27.26-.24.57v-.02Z`,transform:`translate(-144.023 -51.76)`}),(0,V.jsx)(`path`,{d:`m328.67 98.12-3.22-6.58c-1.29-2.63-2.53-5.29-3.72-7.97-.25-.85-.52-1.69-.79-2.53-.81-2.57-1.67-5.12-2.55-7.67-1.92-5.53-3.9-11.08-6.32-16.41-.72-1.58-1.46-3.44-2.63-4.79-.03-.17-.16-.29-.34-.36a.282.282 0 0 0-.23-.04c-.06-.01-.12 0-.18.01-.74.06-1.5.38-2.19.61-2.22.77-4.4 1.64-6.63 2.38-.03-.08-.06-.16-.09-.25-.15-.42-.82-.24-.67.19.03.09.07.19.1.28l-.18.06c-.36.11-.28.6 0 .68.18 1.18.63 2.36.98 3.49.03.09.06.17.08.26-.08.23-.17.46-.24.64-.37.98-.79 1.94-1.21 2.9-1.27 2.89-2.62 5.75-3.98 8.6-3.18 6.67-6.44 13.31-9.64 19.97-1.08 2.25-2.2 4.5-3.15 6.81-.13.32.24.5.5.37 1.34 1.33 2.84 2.5 4.4 3.57.65.44 1.31.87 2.01 1.24.4.22.86.48 1.33.5.24.01.35-.19.33-.37.11-.1.21-.21.28-.28.41-.41.81-.84 1.2-1.26.85-.92 1.69-1.87 2.5-2.84 6.31-2.34 12.6-4.31 18.71-5.84 2.14 5.3 3.43 8.43 3.97 9.58.55 1.05 1.15 1.88 1.82 2.52 1.32.56 6.96-.03 9.23-1.96.87-1.28 1.19-2.67.93-4.15-.09-.5-.22-.95-.4-1.33l-.01-.03Zm-20.09-45.61c.43.77.83 1.56 1.21 2.35-.54-.45-1.27-.99-2.07-1.49-.42-.24-.6-.35-.94-.34.43-.15.85-.29 1.29-.41.17-.05.34-.08.51-.11Zm-25.86 45.66c.78-1.85 1.67-3.66 2.54-5.47 1.51-3.16 3.05-6.31 4.58-9.47 1.28-2.63 2.56-5.26 3.83-7.9l-1.1 2.66c-1.99 4.79-4.97 10.9-8.88 18.15-.43.76-.66 1.51-.71 2.24-.05-.05-.1-.09-.15-.14a.259.259 0 0 0-.11-.07Zm6.24 4.71c-.42-.23-.82-.48-1.22-.74 1.05.45 2 .72 2.55.72l-.21.21c-.05.05-.11.1-.16.15-.01.01-.04.03-.05.04 0-.02.03-.02.05-.03a.27.27 0 0 0-.08.07c-.05-.02-.1-.03-.14-.05-.25-.1-.49-.24-.73-.37h-.01Zm15.73-29.43c1.05 3.15 2.1 6.31 3.1 9.48.34 1.06.69 2.13 1.01 3.21-3.5.63-6.95 1.46-10.27 2.5 2.48-6.03 4.54-11.11 6.16-15.19Zm4.79 12.57c-.23-.79-.49-1.58-.73-2.36-.79-2.54-1.63-5.08-2.46-7.61l-1.2-3.6c.02-.04.04-.09.05-.13 1.6 4.45 3.28 9 5.01 13.57l-.67.12v.01Zm5.83-18.27-.15-.54c-.49-1.64-1.03-3.28-1.6-4.9.23.58.47 1.17.7 1.75 1.56 4.03 3.01 8.1 4.39 12.2-.33-.82-.67-1.64-.98-2.46l-2.35-6.05h-.01ZM390.43 79.37c-.13-10.43-.22-17.5-.24-19.97-.24-1.6.21-2.88-.65-3.65-.14-.13-.32-.23-.52-.32h.03c.45 0 .45-.69 0-.7-1.75-.03-3.5-.04-5.25-.14-1.38-.08-2.76-.21-4.15-.31-.07 0-.12.01-.17.04-.21-.07-.47.03-.45.31l.03.45c-.11.14-.19.3-.22.5-.21 1.26-.32 13.67-.36 23.59-.32 5.79-.67 11.57-.97 17.36-.09 1.73-.29 3.54-.21 5.3-.39.02-.38.64.04.69v.12c.05.44.74.45.7 0v-.06c1.1.09 2.2.21 3.3.3 1.14.19 2.44.2 3.29.17 1.73-.05 2.92-.05 3.8-.37.45-.05.9-.11 1.35-.17.44-.06.25-.73-.19-.67h-.01c.24-.32.45-.72.62-1.25.66-1.84.41-6.36.34-11.33l-.13-9.9.02.01Zm-12.26 18.17c.09-1.91.2-3.81.31-5.71.06 5.38 0 6.14-.01 6.51-.05 1.65-.21 2.81.72 3.66-.39-.04-.78-.07-1.17-.1-.06-1.44.09-2.93.16-4.35l-.01-.01ZM588.97 53.85c-2.06-.25-3.17-.51-3.76-.6a.3.3 0 0 1 .04-.08c.22-.39-.39-.75-.6-.35-.56 1.02-.9 2.19-1.26 3.29-.61 1.88-1.17 3.78-1.72 5.68-.63 2.19-1.24 4.39-1.83 6.59-.81 2.03-1.67 4.05-2.61 6.03-1.7-3.64-3.11-6.04-4.03-7.57-2.26-3.74-2.85-5.48-3.57-6.08l.31-.09c.43-.12.25-.8-.19-.67-1.06.3-2.12.6-3.17.95-.93.32-1.85.69-2.76 1.07-.13.05-.19.16-.22.27-.04.02-.08.05-.11.07-.04-.06-.07-.12-.11-.18a.354.354 0 0 0-.48-.12c-.16.09-.22.32-.13.48l.33.54c0 .09.02.18.06.28.51 1.16.78 1.38.72 1.47-2.42 3.44-5.41 7.86-6.2 9.1-1.27 1.97-2.01 3.14-2.45 3.84l-.91-6.56-.43-4.1c-.19-1.85-.37-3.23-.53-4.13-.19-1.1-.3-2.15-.45-3.16-.2-1.36-.29-2.06-.47-2.42h.04c.45.02.45-.68 0-.7-3.43-.16-6.81.94-10.17 1.48-.24-.22-.73-.04-.58.32.24.59.33 1.25.43 1.87.17 1.06.29 2.13.4 3.2.32 3.09.53 6.2.74 9.3.44 6.75.77 13.51 1.17 20.26.11 1.95.13 3.96.46 5.89.05.3.37.31.55.14.74 1.71 2.87 1.27 6.13 1.27 1.34 0 2.39.04 2.99-.11.02.32.48.53.63.18 3.61-8.26 7.41-16.46 12.05-24.2.03-.05.04-.1.05-.15.3.73.64 1.45.94 2.16.97 2.26 1.97 4.52 2.98 6.76 2.26 5.03 4.54 10.07 7.09 14.96.47.9.94 1.79 1.47 2.65.2.32.4.67.66.96-.18.25 0 .68.34.54.91-.38 1.82-.75 2.76-1.07 1.04-.35 2.11-.65 3.17-.95.39-.11.28-.66-.07-.68.62-.4.95-.96.87-1.91-.3-3.34.72-7.47.86-8.52l2.14-11.43c1.75-10.74 3.13-17.51 3.23-20.86.02-.49.08-2.84.13-3.24.17-1.25.48-1-4.96-1.65l.03-.02Zm-46.19 5.67c-.04-.24-.09-.48-.15-.71l.85-.15c-.34.24-.56.53-.7.86Zm1.95 25.12c-.36-6.63-.7-13.26-1.32-19.87 0 .02 0 .04.01.06.29 1.65.44 2.47.56 2.89 1 8.46 1.5 16.14 1.46 22.8-.06.99-.1 2-.11 3.02-.01.29-.03.68-.05 1.12-.01-.26-.03-.53-.04-.78-.19-3.08-.35-6.16-.52-9.23l.01-.01Zm36.4 18.66c-.11-.11-.24-.29-.37-.49.35.21.74.26 1.17.16-.27.11-.53.22-.8.32v.01Zm-.89-33.72c.12-.43.23-.86.35-1.29.71-1.77 1.41-3.55 2.08-5.33-.15.68-.26 1.22-.31 1.55-.5 2.94-2.13 7.59-3.58 13.36-.15-.35-.29-.66-.43-1 .61-2.44 1.25-4.87 1.9-7.3l-.01.01Zm3.56-12.48c.14-.44.28-.89.42-1.34-.13.7-.27 1.41-.42 2.11-.43 1.19-.86 2.38-1.31 3.57.42-1.45.85-2.9 1.31-4.34Zm-5.22 16.05c-.11.44-.23.87-.35 1.31-.12.46-.23.92-.35 1.38-.1-.22-.19-.4-.28-.61.34-.69.66-1.38.97-2.08h.01Zm-11.64 2.62c.06-.1.12-.19.17-.28.05.13.09.26.14.39a.398.398 0 0 0-.31-.11Zm2.3 2.98c-.56-1.3-1.25-2.63-1.65-3.99 0 0 .01-.02.02-.02.06.08 1.52 2.93 1.63 3.08.73 1.13 3.38 7.04 5.67 12.26 1.2 2.73 2.08 5.17 2.83 7.18-.62-1.25-1.23-2.51-1.83-3.78-2.31-4.87-4.53-9.78-6.67-14.73ZM275.92 87.03c-1.06-2.18-1.13-3.45-2.44-2.93-1.52.57-2.94 1.3-4.5 2.1-1.4.72-2.68 1.44-3.92 2.12.01-.25-.24-.5-.51-.34-4.8 2.93-12.41 4.7-17.28 1.31-1.98-1.77-3.32-4.15-3.97-5.78-.29-.95-.49-1.94-.63-2.93-.14-3.34 1.58-6.53 3.9-9.12.8-.79 1.68-1.51 2.66-2.12 3.7-2.3 8.22-3.07 12.51-2.51 2.71.35 5.32 1.24 7.71 2.55.39.22.75-.39.35-.6-.18-.1-.37-.18-.55-.27.56.27 1.03.33 1.51.19l-.48.39c-.15.11-.23.3-.13.48.09.15.33.24.48.13 1.3-.97 2.46-2.09 3.45-3.37.37-.29.64-.6.65-.97v-.02c.08-.33-.03-.7-.21-1.08-.31-.87-.98-2.01-2.19-3.26-2.43-2.52-3.79-3.45-5.68-4.26-1.14-.49-3.12-1.06-4.42-1.23-3.28-.42-10.64-1.21-18.18 4.11-7.74 5.46-11.94 12.3-12.23 20.61-.08 2.06.04 3.98.34 5.71.74 4.18 2.57 8 5.44 11.34 4.26 4.99 9.76 7.52 16.34 7.52 4.85 0 9.69-1.77 14.89-4.62.23-.12.45-.23.68-.35 2.19-1.1 4.37-2.23 6.46-3.5.49-.3 1.03-.61 1.5-.98 1.47-.87 1.11-1.12.49-2.95-.39-1.14-.76-2.7-2.06-5.36l.02-.01Zm-17.38-21.76c3.05-.42 6.31.79 9.36 2.35.51.39.94.68 1.33.87-5.61-2.86-12.72-3.39-18.44-.79 2.05-1.33 4.24-1.95 7.74-2.44l.01.01ZM443.67 72.67c-.4-2.2-1.15-4.33-2.37-6.22-1.49-2.32-3.58-4.19-5.91-5.64-6.17-3.81-13.75-5.11-20.83-6.01-3.23-.41-6.47-.69-9.72-.92l-1.39-.12c-.85-.07-1.52-.1-2.05-.1-1.08-.06-2.17-.12-3.25-.17-.08 0-.14.02-.19.05-.1.05-.18.14-.16.3.27 2.55-.01 5.12-.92 7.52-.15.38.4.56.62.28 1.32.59 2.68 1.05 4.08 1.37 0 2.78-.14 7.58-.33 12.91 0 0 0 .02-.01.03-.61 3.66-.79 7.42-1 11.12-.23 4.01-.43 8.03-.44 12.05 0 .64 0 1.28.03 1.93.02.31 0 .68.15.96.06.11.14.16.24.17-.2.17-.21.54.11.59 3.83.67 7.78.71 11.68.25 2.3-.19 4.87-.65 7.65-1.56 1.85-.54 3.67-1.18 5.43-1.91 7.2-3.02 14.31-8.07 17.35-15.53.76-1.86 1.17-3.8 1.31-5.75.3-1.93.28-3.82-.09-5.58l.01-.02Zm-19.32-15.42c5.74 1.41 11.94 3.68 15.65 8.55.25.32.47.65.69.99-2.3-2.82-5.68-5.69-12.88-8.23-2.16-.76-4.35-1.43-6.64-2.02 1.06.21 2.13.45 3.18.71Zm-25.82-3.04c.13 0 .27.01.4.02-.14.1-.26.23-.37.38 0-.13-.02-.26-.03-.4Zm34.82 22.17c-.75 3.09-3.55 5.66-5.88 7.58-3.35 2.76-7.21 5.03-11.28 6.54-1.33.49-2.71.9-4.12 1.15.06-1.38.08-2.76.07-4.13-.02-3.78-.16-7.56-.41-11.33-.09-1.37-.18-2.74-.37-4.1 0-.06-.03-.11-.06-.15.09-3.25.12-6.16.03-8.12 6.86 1.05 10.56 2.17 14.06 3.62 5.52 2.28 8.59 5.44 7.97 8.96l-.01-.02Zm-22 16.15c-.12 0-.23-.02-.34-.03l.34-.03v.06Zm-.69-.7c0-3.13.26-8.84.47-14.51.06 1.2.11 2.41.15 3.6.15 3.6.25 7.23.09 10.83-.24.03-.48.05-.71.07v.01Zm-12.33-30.94c.37.63 2.01 1.01 3.23 1.25v.15c-1.31-.31-2.59-.73-3.83-1.29.12-.36.23-.72.33-1.09.08.48.18.84.27.98Zm13.7 31.65v-.18c3.41-.56 6.71-2.02 9.69-3.68 2.31-1.28 4.59-2.78 6.63-4.53-4.69 4.53-11.61 8.24-16.33 8.38l.01.01Zm24.07-.75c-2.05 1.93-4.37 3.56-6.83 4.95 2.7-1.78 5.52-4.03 8.42-6.87.82-.82 1.56-1.69 2.23-2.59-1.08 1.65-2.38 3.16-3.81 4.51h-.01ZM187.16 92.14c-.79-2.47-2.1-7.12-3.1-6.87-.19-.01-2.09.77-4.08 1.54-3.06 1.18-5.91 2.13-10.09 2.82-2.74.42-5.87 1.01-10.61 1.06.04-3.34.05-6.01.05-7.99 7.97-.65 12.33-2.11 16.37-3.55 1.11-.39 2.69-1.01 2.63-1.8-.08-.35-.55-1.39-1.17-2.61-.47-1.16-.98-2.31-1.61-3.38-.42-.71-1.04-1.69-1.86-2.06-.11-.08-.22-.13-.29-.12-.02 0-.04 0-.07.01-.19-.04-.39-.05-.6-.01-.17.03-.24.15-.25.28-.04.02-.09.04-.14.05-4.33 1.48-8.85 2.33-13.24 3.61a499.1 499.1 0 0 0-.31-8.19c4.51-.99 8.88-1.38 13.11-1.82 3.68-.38 6.28.12 7.47.34.59.11.9.16 1.16.18h.1c-.1.37.44.66.62.28.02-.04.03-.08.05-.13.15.2.53.22.62-.1.17-.58.19-1.21.21-1.81v-.36c.03-.15.05-.3.07-.45.52-2.47.33-5.09-.64-7.44-.11-.27-.44-.28-.6-.14-.08-.21-.15-.42-.24-.62-.19-.41-.79-.05-.6.35.03.07.05.15.09.22-.98-.42-2.15-.54-3.17-.63-2.17-.19-4.37-.14-6.54 0-5.7.35-11.4 1.3-16.91 2.79-2.08.56-4.13 1.22-6.14 2-4.54 1.05-3.79 1.51-2.17 6.07.18.51.46 1.68.54 1.94.82 2.47 1.08 2.13 3.1 2.13s0 .05 0 .08h.52c-.48 2.66-.51 5.45-.62 8.13-.15 3.48-.22 6.96-.28 10.45 0 .41-.01.82-.02 1.23-.16.29-.33.57-.51.85-.05.38-.09.77-.14 1.18-.42 3.52-.59 6.48-.52 8.8v.34c.02.47.05.76.06.87.16 1.57-.26 3.47 1.35 3.79 1.61.32 3.5.55 4.85.55.11 0 .22-.02.33-.02 1.79.24 3.67.05 5.45-.12 2.85-.28 5.69-.7 8.51-1.19 3.03-.53 6.05-1.14 9.04-1.86 2.4-.58 4.82-1.19 7.13-2.06.51-.19 1.73-.57 2.46-1.14 1.81-.68 2.18-1 1.57-2.67-.23-.62-.48-1.49-.91-2.78l-.03-.02Zm-11.12-38.71c.89.05 1.93.08 2.89.3-.33 0-.68-.02-1.06-.03-8.28-.26-14.88.75-23.97 2.51 2.41-.64 4.85-1.16 7.28-1.59 4.87-.86 9.91-1.45 14.86-1.19Zm-26.53 22.13c.03 1.71.04 3.43 0 5.14-.04 1.27-.11 2.55-.24 3.82 0-.73.02-1.46.04-2.19.05-2.26.12-4.51.22-6.77h-.02Zm6.73 27.85c.2-.1.4-.21.58-.33 1.82-.17 3.82-.24 5.94-.34-.86.11-1.72.24-2.58.33-1.27.14-2.61.31-3.93.34h-.01ZM534.48 85.44c-3.52-8.38-7.07-16.75-10.5-25.17-.63-1.54-1.25-3.09-1.86-4.65-.31-.8-.65-1.6-.87-2.43-.04-.17-.17-.24-.31-.25.1-.2 0-.51-.29-.53-1.59-.08-3.18-.22-4.78-.25-1.96-.03-3.91.13-5.84.42-.31.05-.31.38-.13.56-.03.06-.05.14-.04.22.23 1.54.63 3.06 1.16 4.53.13.35.27.7.41 1.06l-2.68 6.18c-.11.03-.2.09-.25.22-.67 1.9-1.52 3.73-2.34 5.56a536.85 536.85 0 0 1-3.9 8.45c-2.64 5.64-5.34 11.25-7.91 16.93-.44.97-.88 1.94-1.29 2.93-.2.48-.47 1-.55 1.52v.05c-.02.12.02.26.16.34 1.19.73 2.41 1.41 3.66 2.05 1.2.62 2.45 1.25 3.76 1.61.43.12.62-.55.19-.67-1.13-.31-2.2-.83-3.24-1.36 1.09.36 2.1.69 2.75.93 2.82 1.01 2.38 1.1 4.3-3.75 2.1-1.09 4.34-1.96 6.53-2.79 4.35-1.64 8.8-3.03 13.27-4.29.82 2.01 1.77 3.97 2.72 5.92.35.83.62 1.45.79 1.82.22.42.45.8.69 1.15.17.33.33.67.5 1 .42.8.84 1.63 1.4 2.35.23.29.6 0 .55-.31 1.53-.02 3.06-.07 4.58-.27.92-.12 1.82-.32 2.71-.54 1.39-.27 3.85-1.11 3.74-1.42-.67-1.96-1.55-3.87-2.34-5.78-1.57-3.78-3.16-7.56-4.75-11.33v-.01Zm-11.65-26.16c1.54 3.81 3.12 7.6 4.7 11.4 2.94 7.05 5.91 14.09 8.87 21.13l-1.06-2.17c-2.71-5.51-5.2-11.19-7.41-16.87l-6.65-17.15c-.65-1.45-.55-2.19-.93-2.53.09 0 .18.01.28.02a.29.29 0 0 0-.04.26c.52 2.02 1.47 3.98 2.25 5.91h-.01Zm-6.58 13.58c.05-.15.09-.31.14-.46 1.41 3.92 2.88 7.9 4.39 11.87-3.22.52-6.38 1.25-9.46 2.14.55-1.22 1.05-2.46 1.53-3.7 1.24-3.24 2.37-6.53 3.39-9.85h.01Zm-.23-20c.36 0 .73.03 1.09.05-2.15.1-5.18.33-5.87.74-.24.15-.41.3-.53.45-.06-.29-.13-.58-.18-.88 1.82-.26 3.65-.39 5.49-.35v-.01Zm-.09 18.72c-.49 1.67-1.05 3.33-1.6 4.97-1.07 3.19-2.19 6.38-3.57 9.46-.09.21-.19.43-.29.65-.25.07-.5.14-.74.22 2.53-6.16 4.61-11.29 6.2-15.3Zm-6.34 25.16c4.97-2.38 9.37-4.1 14.02-5.27l.26.64c-4.8 1.35-9.63 2.8-14.28 4.63Zm20.17 6.76c.33.23.68.42 1.04.56h-.33c-.12 0-.21.06-.26.13-.15-.23-.31-.45-.45-.7v.01ZM226.57 91.75c-3.55-4.74-6.68-9.11-9.31-12.99 9.2-15.25 10.05-17.81 10.35-18.38.17-.34 1.09-2.27.64-2.53-1.13-.65-1.03-.65-2.97-1.71-1.19-.65-3.04-1.61-4.53-2.12-1.71-.59-1.24-.36-3 2.77-.06.1-.11.2-.17.3-.75 1.02-1.48 2.05-2.2 3.09-1.88 2.71-3.73 5.45-5.69 8.1-3.68-4.91-6.88-8.76-9.51-11.43-.15-.15-.3-.29-.46-.42-1.27-1.28-7.24 3.53-7.93 5.58-.09.09-.19.16-.28.25-.27.26.03.64.33.58.19.65.5 1.29.94 1.91 3.85 5.06 7.19 9.76 9.94 14-1.23 2.61-3.06 5-4.67 7.38l-2.28 3.33c-.5.66-.93 1.23-1.29 1.69-.67.93-2.09 2.61-2.3 3.87-.51.85-1.16 1.84-1.29 2.83-.06.44.61.63.67.19.01-.08.04-.15.06-.22 1.36 1.08 2.76 2.11 4.19 3.11 1.3.91 2.62 1.85 4.04 2.56.21.1.4 0 .48-.17.24.07.48.14.72.2.44.1.62-.57.19-.67-2.02-.48-3.77-1.57-5.23-3.02-.47-.46-.9-.96-1.32-1.46 1.74 1.35 4.2 2.89 5.89 4.14 1.39 1.03 2.85-2.27 4.22-4.2 1.86-2.64 3.96-5.86 5.52-8.29l10.39 14.51c.67.81 1.14 1.21 1.57 1.36-.05.24.12.51.41.4 1.53-.58 3.05-1.19 4.54-1.87 1.52-.69 3.06-1.45 4.36-2.5a.28.28 0 0 0 .12-.23c1.66-1.1.81-1.74-1.41-4.91-1.13-1.58-1.71-2.36-3.7-5.01l-.03-.02Zm2.41 6.54c.56 1.15 1.19 2.52 1.11 3.81-.06.04-.12.07-.17.1-.03-.88-.55-2.66-.94-3.91Zm-16.51-32.73c1.86-2.65 3.65-5.35 5.57-7.95.4-.55.81-1.13 1.26-1.66.19-.18.38-.33.56-.45.18.03.36.08.55.13l-8.05 10.11.12-.18h-.01ZM192.7 95.48c.79-1.37 1.66-2.69 2.54-4 1.19-1.79 2.4-3.56 3.61-5.33-.04.09-.09.17-.13.26-.1.22.03.41.2.49-2.47 3.42-4.89 6.73-6.4 9.28.21.24.4.48.63.75-.24.07-.4.36-.17.56.4.33.72.77 1.05 1.17.09.11.18.21.27.32-.84-.61-1.66-1.24-2.47-1.88.24-.57.58-1.11.87-1.61v-.01Zm7.46-10.32c.47-.81.98-1.59 1.49-2.37.31-.48.64-.95.96-1.43.26-.29.52-.56.75-.79-.99 1.48-2.09 3.03-3.2 4.59Zm10.03-16.22s-.03-.05-.05-.07c.22-.29.43-.59.64-.89-.2.32-.4.65-.58.96h-.01ZM371.54 87.96c-.01-.08-.01-.16-.03-.23-.06-.38-.58-.29-.66.03-.3-.05-.6-.08-.81-.11-1.14-.15-2.29-.19-3.44-.2 1.04-.09 2.09-.18 3.14-.23.45-.02.45-.72 0-.7-6.57.35-13.14 1.23-19.65 2.11-1.53.21-3.05.42-4.57.68-.01 0-.02.01-.04.01-.04-3.33-.13-6.66-.24-9.99-.19-5.7-.4-11.41-.88-17.1-.13-1.51-.23-3.07-.49-4.58 0-.25 0-.48-.02-.68-.06-1.19-.04-2.61-.68-2.78-.16-.07-.72-.16-1.5-.24.22-.17.16-.62-.2-.63-1.19-.04-2.39.09-3.57.23-1.2.14-2.41.32-3.59.6-.16-.1-.41-.06-.5.12-.06.02-.13.03-.19.05-.35.1-.29.55-.03.66-.26.6-.19 2.27-.21 3-.02.66-.66 33.73-.9 40.3-.03.65.06 1.12.04 1.45-.16 3.05.87 4.96 6.34 3.93 1.09-.08 2.75-.77 5.36-1.43 4.13-1.04 5.78-1.52 6.2-1.65 6.43-1.69 6.78-1.97 11.72-2.43.55-.05 4.8-.38 6.03-.3.64.04 1.19.07 1.65.1.09 0 .16-.03.24-.05.1.27.56.33.66-.02.39-1.32.61-2.71.78-4.08.2-1.61.29-3.24.15-4.86.24.03.52-.23.38-.53-.09-.2-.27-.33-.49-.43v-.02Zm-.63.56c.07.57.11 1.14.11 1.71-.21-.99-.53-1.71-.95-1.87.22.03.44.06.65.11.06.01.12.04.19.05Zm-25.41 1.73c1.54-.36 3.1-.64 4.66-.89-1.61.37-3.18.77-4.66 1.2v-.31Zm-.86-7.37c-.07-1.37-.16-2.75-.25-4.12-.21-3.13-.45-6.27-.79-9.4.02-2.25.08-4.31.13-6.11.16 2.08.29 4.16.4 6.24.23 4.46.38 8.93.5 13.39h.01Zm-.94-4c.16 2.41.29 4.83.39 7.24.06 1.6.14 3.22.09 4.83-.15.05-.32.09-.47.14V78.88h-.01ZM483.72 92.83c-3.05-2.28-6.22-4.4-9.38-6.51 8.86-6.49 13.49-12.95 13.73-19.23.04-.76 0-1.5-.13-2.2-.67-3.82-3.5-6.68-8.39-8.48.13.04.27.08.4.13 3.92 1.39 7.74 4.23 8.5 8.56.34 1.95-.05 3.96-.98 5.69-.21.4.39.75.6.35 1.86-3.46 1.46-7.55-.97-10.63-3.53-4.47-9.76-5.88-15.16-6.16-2.32-.12-4.64-.04-6.95.19-6 .32-12.71 1.68-17.63 3.21-.37.11-.67.23-.92.35-.2-.17-.62.02-.57.37v.03c-.64.68-.18 1.64.48 3.21.38.91.67 1.89 1.15 2.58.32.76.68 1.51 1.13 2.19.14.21.38.19.53.07.19-.02.38-.05.57-.08v1.57c-.06.06-.1.13-.11.23-.27 4.18-.34 8.38-.48 12.57l-.3 9.03c-.24 3.91-.44 6.77-.46 7.26-.05.88-.11 1.95.07 2.81-.01.22-.02.43-.04.65 0 .11-.02.23-.03.35 0 .05-.03.27-.01.16-.05.4.5.59.64.28.05.04.12.08.2.08 1.75.13 3.5.28 5.25.3 1.69.02 3.38-.12 5.06-.32.08.23.36.39.55.15.06-.08.11-.17.16-.26.18-.09.24-.32.18-.48.05-.2.1-.4.13-.6.16-.86.25-1.74.33-2.62.11-1.17.17-2.34.23-3.51.15-.01.32-.03.52-.04.36-.03 1.73-.15 2.06-.15.39 0 .7-.02.95-.04 1.76 1.11 3.45 2.35 5.14 3.55 2.83 2.01 5.64 4.04 8.47 6.04 1.42 1 2.85 2 4.29 2.97.1.06.19.07.27.04.08 0 .17-.02.25-.1 1.61-1.56 3.15-3.18 4.6-4.88.75-.88 1.49-1.78 2.15-2.73.01.01.03.02.04.03.34.3.83-.2.49-.49-2.16-1.9-4.34-3.76-6.64-5.48l.03-.01Zm-6.38-3.65a55.72 55.72 0 0 0-4-2.13c.14-.1.26-.19.4-.29 1.2.81 2.4 1.61 3.6 2.42Zm-20.1 11.78c.67-.37 1.23-.91 1.67-1.6-.11.5-.24 1-.38 1.49-.43.04-.86.08-1.29.11Zm2.38-37.24c1.34-.31 2.56-.52 3.71-.69-1.03.19-2.04.41-3.04.65-.14-.07-.34-.02-.45.11-.07.02-.15.04-.22.05v-.13.01Zm.04.84c.07-.02.14-.03.2-.05.34 1.66.41 3.41.5 5.09.17 2.9.24 5.81.28 8.71l.03 3.17c-.17.07-.34.14-.51.2-.06-4.96-.21-10.58-.51-17.12h.01Zm16.04 5.62c-1.16 2.25-3.06 4.1-5.02 5.66-2.8 2.23-5.99 3.97-9.3 5.35-.01-3.56-.09-7.12-.27-10.67-.1-2.04-.16-4.16-.57-6.18 3.3-.78 6.72-1.36 10.1-1.1 1.85.14 4.23.59 5.32 2.29.92 1.43.46 3.24-.26 4.65Zm.85-.18c.6-1.37.9-2.92.28-4.32-.67-1.52-2.2-2.32-3.76-2.74.46.1.89.21 1.29.37 1.74.67 2.69 1.88 2.93 3.21.2 1.13-.05 2.25-.74 3.47V70Zm-27.47-4.14c-.12-.19-.23-.38-.34-.57.74.42.85.36.99.41v.08c-.22.03-.43.06-.65.08Zm11.21 30.46c-.08 1.08-.16 2.17-.33 3.24-.05.35-.11.69-.2 1.03 0 .04-.02.07-.03.11-.15.02-.3.04-.45.05.45-1.64.76-3.36.79-5.07.03-.29.08-.57.1-.89-.03-.31-.03-.47.24-.57-.04.69-.07 1.39-.12 2.08v.02Zm5.6-2.47c.48.11.92.52 2.49 1.72-.46-.32-.92-.65-1.38-.97-.37-.25-.73-.5-1.1-.75h-.01Zm21.23 7.24a70.76 70.76 0 0 1-4.37 4.63c-.14-.09-.27-.19-.4-.28.19-.09.37-.24.55-.47.87-1.14 5.43-5.51 5.49-7.45.31.26.62.53.92.79-.67.97-1.42 1.88-2.19 2.77v.01Z`,fill:`currentColor`,transform:`translate(-144.023 -51.76)`})]}),RV=({style:e,size:t=`small`,withText:n})=>(0,V.jsxs)(`div`,{className:`ExcalidrawLogo is-${t}`,style:e,children:[(0,V.jsx)(IV,{}),n&&(0,V.jsx)(LV,{})]}),zV=({icon:e,shortcut:t,children:n})=>{let r=oV();return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{className:`welcome-screen-menu-item__icon`,children:e}),(0,V.jsx)(`div`,{className:`welcome-screen-menu-item__text`,children:n}),t&&r.formFactor!==`phone`&&(0,V.jsx)(`div`,{className:`welcome-screen-menu-item__shortcut`,children:t})]})};zV.displayName=`WelcomeScreenMenuItemContent`;var BV=({onSelect:e,children:t,icon:n,shortcut:r,className:i=``,...a})=>(0,V.jsx)(`button`,{...a,type:`button`,className:`welcome-screen-menu-item ${i}`,onClick:e,children:(0,V.jsx)(zV,{icon:n,shortcut:r,children:t})});BV.displayName=`WelcomeScreenMenuItem`;var VV=({children:e,href:t,icon:n,shortcut:r,className:i=``,...a})=>(0,V.jsx)(`a`,{...a,className:`welcome-screen-menu-item ${i}`,href:t,target:`_blank`,rel:`noopener`,children:(0,V.jsx)(zV,{icon:n,shortcut:r,children:e})});VV.displayName=`WelcomeScreenMenuItemLink`;var HV=({children:e})=>{let{WelcomeScreenCenterTunnel:t}=yF();return(0,V.jsx)(t.In,{children:(0,V.jsx)(`div`,{className:`welcome-screen-center`,children:e||(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(UV,{}),(0,V.jsx)(WV,{children:W(`welcomeScreen.defaults.center_heading`)}),(0,V.jsxs)(GV,{children:[(0,V.jsx)(qV,{}),(0,V.jsx)(KV,{})]})]})})})};HV.displayName=`Center`;var UV=({children:e})=>(0,V.jsx)(`div`,{className:`welcome-screen-center__logo excalifont welcome-screen-decor`,children:e||(0,V.jsx)(RV,{withText:!0})});UV.displayName=`Logo`;var WV=({children:e})=>(0,V.jsx)(`div`,{className:`welcome-screen-center__heading welcome-screen-decor excalifont`,children:e});WV.displayName=`Heading`;var GV=({children:e})=>(0,V.jsx)(`div`,{className:`welcome-screen-menu`,children:e});GV.displayName=`Menu`;var KV=()=>{let e=fV();return(0,V.jsx)(BV,{onSelect:()=>e.executeAction(DE),shortcut:`?`,icon:Eb,children:W(`helpDialog.title`)})};KV.displayName=`MenuItemHelp`;var qV=()=>{let e=EC(),t=fV();return e.viewModeEnabled?null:(0,V.jsx)(BV,{onSelect:()=>t.executeAction(SE),shortcut:lO(`loadScene`),icon:Ib,children:W(`buttons.load`)})};qV.displayName=`MenuItemLoadScene`;var JV=({onSelect:e})=>{let{t}=Vy();return(0,V.jsx)(BV,{shortcut:null,onSelect:e,icon:sx,children:t(`labels.liveCollaboration`)})};JV.displayName=`MenuItemLiveCollaborationTrigger`,HV.Logo=UV,HV.Heading=WV,HV.Menu=GV,HV.MenuItem=BV,HV.MenuItemLink=VV,HV.MenuItemHelp=KV,HV.MenuItemLoadScene=qV,HV.MenuItemLiveCollaborationTrigger=JV;var YV=({children:e})=>{let{WelcomeScreenMenuHintTunnel:t}=yF();return(0,V.jsx)(t.In,{children:(0,V.jsxs)(`div`,{className:`excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu`,children:[eb,(0,V.jsx)(`div`,{className:`welcome-screen-decor-hint__label`,children:e||W(`welcomeScreen.defaults.menuHint`)})]})})};YV.displayName=`MenuHint`;var XV=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:t}=yF();return(0,V.jsx)(t.In,{children:(0,V.jsxs)(`div`,{className:`excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar`,children:[(0,V.jsx)(`div`,{className:`welcome-screen-decor-hint__label`,children:e||W(`welcomeScreen.defaults.toolbarHint`)}),nb]})})};XV.displayName=`ToolbarHint`;var ZV=({children:e})=>{let{WelcomeScreenHelpHintTunnel:t}=yF();return(0,V.jsx)(t.In,{children:(0,V.jsxs)(`div`,{className:`excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help`,children:[(0,V.jsx)(`div`,{children:e||W(`welcomeScreen.defaults.helpHint`)}),tb]})})};ZV.displayName=`HelpHint`;var QV=e=>(0,V.jsx)(V.Fragment,{children:e.children||(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(HV,{}),(0,V.jsx)(YV,{}),(0,V.jsx)(XV,{}),(0,V.jsx)(ZV,{})]})});QV.displayName=`WelcomeScreen`,QV.Center=HV,QV.Hints={MenuHint:YV,ToolbarHint:XV,HelpHint:ZV};var $V=QV,eH=()=>{Array.prototype.at||Object.defineProperty(Array.prototype,"at",{value:function(e){if(e=Math.trunc(e)||0,e<0&&(e+=this.length),!(e<0||e>=this.length))return this[e]},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.findLast||Object.defineProperty(Array.prototype,"findLast",{value:function(e,t){return this.slice().reverse().find((n,r)=>e.call(t,n,this.length-r-1,this))},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.findIndex||Object.defineProperty(Array.prototype,"findIndex",{value:function(e,t){for(let n=0;n<this.length;n++)if(e.call(t,this[n],n,this))return n;return-1},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.findLastIndex||Object.defineProperty(Array.prototype,"findLastIndex",{value:function(e,t){let n=this.slice().reverse().findIndex((n,r)=>e.call(t,n,this.length-r-1,this));return n===-1?-1:this.length-n-1},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.toReversed||Object.defineProperty(Array.prototype,"toReversed",{value:function(){return this.slice().reverse()},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.toSorted||Object.defineProperty(Array.prototype,"toSorted",{value:function(e){return this.slice().sort(e)},writable:!0,enumerable:!1,configurable:!0}),Element.prototype.replaceChildren||(Element.prototype.replaceChildren=function(...e){this.innerHTML=``,this.append(...e)})},tH=(e,t,n)=>!!(t&&(t.id===e.editingTextElement?.id||t.id===e.resizingElement?.id||t.id===e.newElement?.id||t.version>n.version||t.version===n.version&&t.versionNonce<=n.versionNonce)),nH=(0,Hc.default)((e,t,n)=>{if(ci()||fc()||window?.DEBUG_FRACTIONAL_INDICES){let r=ti(e.map(e=>({...e})));_c(r,{shouldThrow:fc()||ci(),includeBoundTextValidation:!0,reconciliationContext:{localElements:t,remoteElements:n}})}},6e4,{leading:!0,trailing:!1}),rH=(e,t,n)=>{let r=ui(e),i=[],a=new Set;for(let e of t)if(!a.has(e.id)){let t=r.get(e.id),o=tH(n,t,e);t&&o?(i.push(t),a.add(t.id)):(i.push(e),a.add(e.id))}for(let t of e)a.has(t.id)||(i.push(t),a.add(t.id));let o=no(i);return nH(o,e,t),ti(o),o},iH=({children:e,icon:t})=>{let{t:n}=Vy(),{TTDDialogTriggerTunnel:r}=yF(),i=dV();return(0,V.jsx)(r.In,{children:(0,V.jsx)(Z.Item,{onSelect:()=>{xC(`ai`,`dialog open`,`ttd`),i({openDialog:{name:`ttd`,tab:`text-to-diagram`}})},icon:t??TS,badge:(0,V.jsx)(Z.Item.Badge,{children:`AI`}),children:e??n(`labels.textToDiagram`)})})};iH.displayName=`TTDDialogTrigger`;function aH(e){let t=e.get(`X-Ratelimit-Limit`),n=e.get(`X-Ratelimit-Remaining`);return{rateLimit:t?parseInt(t,10):void 0,rateLimitRemaining:n?parseInt(n,10):void 0}}async function*oH(e){let t=new TextDecoder,n=``;try{for(;;){let{done:r,value:i}=await e.read();if(r)break;n+=t.decode(i,{stream:!0});let a=n.split(`
|
|
177
|
-
`);n=a.pop()||``;for(let e of a){let t=e.trim();t&&t.startsWith(`data: `)&&(yield t.slice(6))}}}finally{e.releaseLock()}}async function sH(e){let{url:t,messages:n,onChunk:r,onStreamCreated:i,extractRateLimits:a=!0,signal:o}=e;try{let e=``,s={},c=null,l=await fetch(t,{method:`POST`,headers:{Accept:`text/event-stream`,"Content-Type":`application/json`},body:JSON.stringify({messages:n}),signal:o});if(a&&(s=aH(l.headers)),!l.ok){if(l.status===429)return{...s,error:new js({message:`Rate limit exceeded`,status:429})};let e=await l.text();throw new js({message:e||`Generation failed...`,status:l.status})}let u=l.body?.getReader();if(!u)throw new js({message:`Couldn't get reader from response body`,status:500});i?.();try{for await(let t of oH(u)){if(t===`[DONE]`)break;try{let n=JSON.parse(t);if(n===null)break;switch(n.type){case`content`:{let t=n.delta;t&&(e+=t,r?.(t));break}case`error`:c=new js({message:n.error.message,status:500})}}catch(e){console.warn(`Failed to parse SSE data:`,t,e)}}}catch(e){c=e.name===`AbortError`?new js({message:`Request aborted`,status:499}):new js({message:e.message||`Streaming error`,status:500})}return c?{...s,error:c}:e?{generatedResponse:e,error:null,...s}:{...s,error:new js({message:`Generation failed...`,status:l.status})}}catch(e){return e.name===`AbortError`?{error:new js({message:`Request aborted`,status:499})}:{error:new js({message:e.message||`Request failed`,status:500})}}}var cH=e=>{let t=iV();return(0,B.useLayoutEffect)(()=>{t.setPlugins({diagramToCode:{generate:e.generate}})},[t,e.generate]),null};eH();var lH=({children:e})=>{let[t,n]=(0,B.useState)(null);return(0,V.jsx)(nV.Provider,{value:t,children:(0,V.jsx)(rV.Provider,{value:n,children:e})})},uH=B.memo(e=>{let{onExport:t,className:r,onChange:i,onThemeChange:a,onIncrement:o,initialData:s,initialState:c,onExcalidrawAPI:l,onMount:u,onUnmount:d,onInitialize:f,isCollaborating:p=!1,onPointerUpdate:m,renderTopLeftUI:h,renderTopRightUI:g,langCode:_=My.code,viewModeEnabled:v,interaction:y,ui:b,activeTool:x,zenModeEnabled:S,gridModeEnabled:C,libraryReturnUrl:w,theme:T,name:E,renderCustomStats:D,onPaste:O,detectScroll:ee=!0,handleKeyboardGlobally:k=!1,onLibraryChange:te,autoFocus:ne=!1,generateIdForFile:re,onLinkOpen:ie,generateLinkForSelection:ae,onPointerDown:oe,onPointerUp:se,onScrollChange:ce,onUserFollow:le,userToFollow:ue,onDuplicate:de,children:fe,validateEmbeddable:pe,renderEmbeddable:me,aiEnabled:he,showDeprecatedFonts:ge,renderScrollbars:_e,viewportStatusFrame:ve,currentUserControls:ye,imageOptions:be}=e,xe=e.UIOptions?.canvasActions,Se={...e.UIOptions,canvasActions:{...Ca.canvasActions,...xe},tools:{image:e.UIOptions?.tools?.image??!0}};xe?.export&&(Se.canvasActions.export.saveFileToDisk=xe.export?.saveFileToDisk??Ca.canvasActions.export.saveFileToDisk),Se.canvasActions.toggleTheme===null&&(T==null||a)&&(Se.canvasActions.toggleTheme=!0);let Ce={maxFileSizeBytes:be?.maxFileSizeBytes??rc.maxFileSizeBytes,maxWidthOrHeight:be?.maxWidthOrHeight??rc.maxWidthOrHeight},we=(0,B.useContext)(rV),Te=(0,B.useRef)(l);Te.current=l;let Ee=(0,B.useCallback)(e=>{we?.(e),Te.current?.(e)},[we]),De=typeof y==`object`&&!!y&&y.enabled?.browserZoom===!0&&y.enabled?.navigation!==!0;return(0,B.useEffect)(()=>{if((async()=>{await n(()=>import(`./roundRect-D01gJrlt.js`),[],import.meta.url)})(),De)return;let e=e=>{typeof e.scale==`number`&&e.scale!==1&&e.preventDefault()};return document.addEventListener(`touchmove`,e,{passive:!1}),()=>{document.removeEventListener(`touchmove`,e)}},[De]),(0,V.jsx)(Oy,{store:ky,children:(0,V.jsx)(jV,{langCode:_,theme:T,children:(0,V.jsx)(AV,{onExport:t,className:r,onChange:i,onThemeChange:a,onIncrement:o,initialData:s,initialState:c,onExcalidrawAPI:Ee,onMount:u,onUnmount:d,onInitialize:f,isCollaborating:p,onPointerUpdate:m,renderTopLeftUI:h,renderTopRightUI:g,langCode:_,viewModeEnabled:v,interaction:y,ui:b,activeTool:x,zenModeEnabled:S,gridModeEnabled:C,libraryReturnUrl:w,theme:T,name:E,renderCustomStats:D,UIOptions:Se,onPaste:O,detectScroll:ee,handleKeyboardGlobally:k,onLibraryChange:te,autoFocus:ne,generateIdForFile:re,onLinkOpen:ie,generateLinkForSelection:ae,onPointerDown:oe,onPointerUp:se,onScrollChange:ce,onUserFollow:le,userToFollow:ue,onDuplicate:de,validateEmbeddable:pe,renderEmbeddable:me,aiEnabled:he!==!1,showDeprecatedFonts:ge,renderScrollbars:_e,viewportStatusFrame:ve,currentUserControls:ye,imageOptions:Ce,children:fe})})})},(e,t)=>{if(e.children!==t.children)return!1;let{initialData:n,UIOptions:r={},imageOptions:i,interaction:a,ui:o,activeTool:s,...c}=e,{initialData:l,UIOptions:u={},imageOptions:d,interaction:f,ui:p,activeTool:m,...h}=t;if(!(s===m||s?.type===m?.type&&(s?.type===`custom`?s.customType:null)===(m?.type===`custom`?m.customType:null))||!(a===f||typeof a==`object`&&a&&typeof f==`object`&&f&&!!a.enabled?.links==!!f.enabled?.links&&!!a.enabled?.embeds==!!f.enabled?.embeds&&!!a.enabled?.interactiveContent==!!f.enabled?.interactiveContent&&!!a.enabled?.navigation==!!f.enabled?.navigation&&!!a.enabled?.browserZoom==!!f.enabled?.browserZoom&&!!a.enabled?.tools?.laser==!!f.enabled?.tools?.laser&&!!a.enabled?.tools?.custom==!!f.enabled?.tools?.custom)||!(o===p||typeof o==`object`&&o&&typeof p==`object`&&p&&!!o.enabled?.zoom==!!p.enabled?.zoom&&!!o.enabled?.scrollBackToContent==!!p.enabled?.scrollBackToContent))return!1;let g=Object.keys(r),_=Object.keys(u);if(g.length!==_.length)return!1;let v=g.every(e=>e===`getFormFactor`?!0:e===`canvasActions`?Object.keys(r.canvasActions).every(e=>e===`export`&&r?.canvasActions?.export&&u?.canvasActions?.export?r.canvasActions.export.saveFileToDisk===u.canvasActions.export.saveFileToDisk:r?.canvasActions?.[e]===u?.canvasActions?.[e]):r[e]===u[e]),y=(i?.maxWidthOrHeight??rc.maxWidthOrHeight)===(d?.maxWidthOrHeight??rc.maxWidthOrHeight)&&(i?.maxFileSizeBytes??rc.maxFileSizeBytes)===(d?.maxFileSizeBytes??rc.maxFileSizeBytes);return v&&y&&S(c,h)});uH.displayName=`Excalidraw`;function dH(e){return rT(e,!1)}export{My as A,mw as C,iT as D,sV as E,hO as F,NP as I,vR as L,Ny as M,lH as N,zO as O,uH as P,Vc as R,nP as S,pV as T,NV as _,Rk as a,cH as b,iH as c,gO as d,dH as f,jP as g,vO as h,FV as i,NO as j,EA as k,rH as l,QF as m,uz as n,qI as o,$V as p,Vy as r,OI as s,_O as t,nV as u,VO as v,oV as w,OO as x,sH as y};
|