collabmd 0.1.48 → 0.1.49

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.
Files changed (268) hide show
  1. package/README.md +61 -5
  2. package/bin/collabmd.js +3 -0
  3. package/dist/client/assets/CodeMirrorEditor-UCMRAMCV-C-nmgL5g.js +1 -0
  4. package/dist/client/assets/abnfDiagram-VCTEODGH-CdVZqicp.js +1 -0
  5. package/dist/client/assets/{architectureDiagram-5GKGNRK7-I39sYjHI.js → architectureDiagram-5GKGNRK7-wUo0bXif.js} +3 -3
  6. package/dist/client/assets/{blockDiagram-NRAW4CY4-C6DtJy5Y.js → blockDiagram-I7D4REHJ-BRSK3m49.js} +4 -4
  7. package/dist/client/assets/browser-utils-DbXSMI-6.js +1 -0
  8. package/dist/client/assets/{c4Diagram-UCG6FXSJ-CtWtxS9_.js → c4Diagram-7LVT6UL2-yD2poxqw.js} +1 -1
  9. package/dist/client/assets/channel-Fa4GS_-F.js +1 -0
  10. package/dist/client/assets/chunk-2E4U76K2-BPnTT-J3.js +2 -0
  11. package/dist/client/assets/{chunk-TEH6E4GO-DVayPj-q.js → chunk-4HAMMTFA-DStbIfJ1.js} +20 -20
  12. package/dist/client/assets/{chunk-75Z2AOVW-CdFSaPjz.js → chunk-75Z2AOVW-C5pGd3W9.js} +1 -1
  13. package/dist/client/assets/{chunk-CLGD4ZFX-DQLgbQrv.js → chunk-CLGD4ZFX-BMeArk03.js} +1 -1
  14. package/dist/client/assets/chunk-DU6HZSFF-Zkp69c6c.js +127 -0
  15. package/dist/client/assets/{chunk-F27PBJKO-CNHIFhjo.js → chunk-F27PBJKO-D4xNct1r.js} +1 -1
  16. package/dist/client/assets/{chunk-GMAD6QVW-CbcBqPM5.js → chunk-GMAD6QVW-NZ6WpDb8.js} +1 -1
  17. package/dist/client/assets/{chunk-OBVCFTLP-BJR7u1jh.js → chunk-GVQU2GXP-D8SDprfX.js} +1 -1
  18. package/dist/client/assets/{chunk-G27WJ6UU-D9-eg537.js → chunk-IMKFNOWR-D8jEuU3Q.js} +2 -2
  19. package/dist/client/assets/{chunk-JQ64N6SF-DSFNH4bh.js → chunk-L3NEJ4N5-aijKP-eh.js} +1 -1
  20. package/dist/client/assets/chunk-OSK3NFVY-CCbLQAMa.js +10 -0
  21. package/dist/client/assets/{chunk-P2QGCYS3-BRpqY32H.js → chunk-P2QGCYS3-Oag_FdCq.js} +1 -1
  22. package/dist/client/assets/{chunk-POPQ4Y6H-Cb4SlVZF.js → chunk-POPQ4Y6H-CYnpIgXT.js} +1 -1
  23. package/dist/client/assets/{chunk-PWAF6VOD-Cz8IwBB5.js → chunk-PWAF6VOD-JSNrcBmP.js} +1 -1
  24. package/dist/client/assets/{chunk-RM4UPSZO-CWRwxNWJ.js → chunk-RM4UPSZO-DOWllDY8.js} +4 -4
  25. package/dist/client/assets/{chunk-RHFEMEQ7-CWY8cf4H.js → chunk-SHT3W25Y-BiQGljao.js} +5 -5
  26. package/dist/client/assets/{chunk-SVP7TREG-CyHOmcac.js → chunk-SVP7TREG-DB485R5x.js} +1 -1
  27. package/dist/client/assets/{chunk-LCL6LL3I-DmDkVukh.js → chunk-TICWLB2K-8rAVvoS3.js} +4 -4
  28. package/dist/client/assets/{chunk-CKBBP62Z-DG26UiBv.js → chunk-TLUHSLCS-DTY5v0aj.js} +2 -2
  29. package/dist/client/assets/classDiagram-ZZMXUADV-BsQWoR3Q.js +1 -0
  30. package/dist/client/assets/classDiagram-v2-VYDZK3BY-BsQWoR3Q.js +1 -0
  31. package/dist/client/assets/{comment-thread-store-CdcwrObc.js → comment-thread-store-CX98zR6q.js} +1 -1
  32. package/dist/client/assets/comment-threads-BnRwo5B9.js +4 -0
  33. package/dist/client/assets/{cynefinDiagram-5FMLGOSQ-CdTPi2yO.js → cynefinDiagram-5FMLGOSQ-rTz9RhFH.js} +1 -1
  34. package/dist/client/assets/{dagre-3AP2YEHR-5gtJtd0O.js → dagre-GXQ25YYZ-Cr67wLpQ.js} +2 -2
  35. package/dist/client/assets/{diagram-S7CK7UJ4-BudWz9WU.js → diagram-S7CK7UJ4-DywERe__.js} +2 -2
  36. package/dist/client/assets/{diagram-UQ7AKVKN-3v4rbH-s.js → diagram-UQ7AKVKN-CNYlXtu4.js} +1 -1
  37. package/dist/client/assets/diagram-VSXAHHWV-0H1a61Bn.js +3 -0
  38. package/dist/client/assets/{diagram-VX7I27RA-C_-rj0sw.js → diagram-VX7I27RA-CsJbsx5F.js} +1 -1
  39. package/dist/client/assets/{diagram-Z3DM3KII-B4yxavgj.js → diagram-Z3DM3KII-D0mLxEgI.js} +1 -1
  40. package/dist/client/assets/dist--hk9I5HQ.js +1 -0
  41. package/dist/client/assets/{dist-DutPuFmC.js → dist-B1XEa-Zs.js} +1 -1
  42. package/dist/client/assets/dist-Bd1JucQF.js +1 -0
  43. package/dist/client/assets/{dist-DZAAWTG-.js → dist-C0G3AaXG.js} +1 -1
  44. package/dist/client/assets/dist-Dm4w5UId.js +1 -0
  45. package/dist/client/assets/{dist-B_yQaEv_.js → dist-DpYDHR9p.js} +1 -1
  46. package/dist/client/assets/{dist-CietwTVS.js → dist-DzNmC81X.js} +1 -1
  47. package/dist/client/assets/{dist-DDUn5zTz.js → dist-GvvCNBe4.js} +1 -1
  48. package/dist/client/assets/dist-JaU3aRlD.js +19 -0
  49. package/dist/client/assets/{dist-Bw3VIE_v.js → dist-TW8iFRyW.js} +1 -1
  50. package/dist/client/assets/{dist-Dir5dDKZ.js → dist-jVU5Be5P.js} +1 -1
  51. package/dist/client/assets/document-formatter-rDDjRfZ2.js +2 -0
  52. package/dist/client/assets/drawioEditor-JubEEha7.js +9 -0
  53. package/dist/client/assets/ebnfDiagram-PWID7BFC-HeTxHpCU.js +1 -0
  54. package/dist/client/assets/editor-session-Bk6oIvSr.js +54 -0
  55. package/dist/client/assets/{embedded-editor-base-B3l6Xy65.css → embedded-editor-base-BlCgz6mw.css} +1 -1
  56. package/dist/client/assets/{erDiagram-SSCWMZ5O-C-iy6VkX.js → erDiagram-RLTQ6QDP-CbrDdd5P.js} +2 -2
  57. package/dist/client/assets/{vault-utils-DvoSftJT.js → es-Bfdp096f.js} +13 -13
  58. package/dist/client/assets/excalidraw-element-link-YLIaTnVF.js +7 -0
  59. package/dist/client/assets/{excalidraw-scene-BOben2gr.js → excalidraw-scene-6uROebca.js} +1 -1
  60. package/dist/client/assets/excalidrawEditor-dBMbRX_S.js +9 -0
  61. package/dist/client/assets/export-page-CRRQ2NEl.js +57 -0
  62. package/dist/client/assets/exportDocument-BlQRd9_m.js +2 -0
  63. package/dist/client/assets/exportDocument-CNSbjZwu.css +1 -0
  64. package/dist/client/assets/flowDiagram-HODETNUW-D5Gy0wmg.js +1 -0
  65. package/dist/client/assets/{ganttDiagram-EL5Y4UJY-DtKHAbez.js → ganttDiagram-EL5Y4UJY-BHgOYiZz.js} +1 -1
  66. package/dist/client/assets/{gitGraphDiagram-WWUBYQGX-oue8fQ5o.js → gitGraphDiagram-WWUBYQGX-Dl__X3Sk.js} +1 -1
  67. package/dist/client/assets/image-ZVKINSPA-DgzW5zAy.js +1 -0
  68. package/dist/client/assets/index-D3RER1SZ.js +1023 -0
  69. package/dist/client/assets/index-DREVKl_K.css +1 -0
  70. package/dist/client/assets/{infoDiagram-RXCK75RN-BMzo6KIn.js → infoDiagram-27XIBGKW-DBpoANC9.js} +1 -1
  71. package/dist/client/assets/{ishikawaDiagram-5VMMS53U-BIM3h287.js → ishikawaDiagram-5VMMS53U-BMPC6hfp.js} +1 -1
  72. package/dist/client/assets/{journeyDiagram-EYS64GPL-mF6Lh8O-.js → journeyDiagram-3NMN7TZE-B1sApUmM.js} +2 -2
  73. package/dist/client/assets/{kanban-definition-3QL26DDD-DLN2NyoR.js → kanban-definition-UXKFOSKX-C9yP4td1.js} +4 -4
  74. package/dist/client/assets/{line-BfTWJmgf.js → line-BFl3ujec.js} +1 -1
  75. package/dist/client/assets/mermaid.core-BrY09czX.js +11 -0
  76. package/dist/client/assets/mermaid.core-DfcNfOTv.js +1 -0
  77. package/dist/client/assets/{mindmap-definition-FBJOCRG2-CRyHaHTk.js → mindmap-definition-YA3MSWOX-BUQHcYbK.js} +8 -8
  78. package/dist/client/assets/pegDiagram-XKGWAZYB-Bi2Iml7Z.js +1 -0
  79. package/dist/client/assets/{pieDiagram-E7YTZNPT-B5OZPb88.js → pieDiagram-E7YTZNPT-_gYXnMoi.js} +1 -1
  80. package/dist/client/assets/preview-render-compiler-CfxJYldJ.js +41 -0
  81. package/dist/client/assets/preview-render-compiler-Cu8_i9iS.js +1 -0
  82. package/dist/client/assets/{preview-render-worker-_QTxqKvP.js → preview-render-worker-c4Yi93qW.js} +41 -35
  83. package/dist/client/assets/prod-BiJL30sl.js +1 -0
  84. package/dist/client/assets/prod-qAk7rHa4.js +177 -0
  85. package/dist/client/assets/{quadrantDiagram-AXDQQJYC-Drrw14YH.js → quadrantDiagram-AXDQQJYC-DwexhEhd.js} +1 -1
  86. package/dist/client/assets/quick-switcher-controller-BoIK_wuG.js +1 -0
  87. package/dist/client/assets/railroadDiagram-O6MQD6OU-BVA5UbMu.js +1 -0
  88. package/dist/client/assets/{requirementDiagram-EFPCY7ZU-CRZG6mRB.js → requirementDiagram-BXWQKSXE-C4cKwiIw.js} +2 -2
  89. package/dist/client/assets/runtime-config-DcmnGcXU.js +1 -0
  90. package/dist/client/assets/{sankeyDiagram-P5KCCOFB-DvarEJpo.js → sankeyDiagram-P5KCCOFB-B5HHkRT2.js} +1 -1
  91. package/dist/client/assets/{sequenceDiagram-WJ2MYXX4-B4oWlb-w.js → sequenceDiagram-WJ2MYXX4-BX6jqJFD.js} +6 -6
  92. package/dist/client/assets/{stateDiagram-HBIQ2CUA-qbHIIqRZ.js → stateDiagram-D77RDMKH-CmqxyRGx.js} +1 -1
  93. package/dist/client/assets/stateDiagram-v2-MP3YSRHH-zoLLQVyh.js +1 -0
  94. package/dist/client/assets/{swimlanes-XN3QIQJK-xB6CtUGj.js → swimlanes-42K2YHIH-Bmgb9Zld.js} +1 -1
  95. package/dist/client/assets/swimlanesDiagram-VR7AAH4N-DS-KQN37.js +8 -0
  96. package/dist/client/assets/{timeline-definition-24CTP7MA-Lj_yTNlY.js → timeline-definition-24CTP7MA-BA-lVH6P.js} +1 -1
  97. package/dist/client/assets/vault-api-client-iZLhMJKe.js +6 -0
  98. package/dist/client/assets/{vennDiagram-4TSXK5OY-BekRp5Y0.js → vennDiagram-4TSXK5OY-DNdUC_Xj.js} +1 -1
  99. package/dist/client/assets/{wardleyDiagram-VM6X3IG4-kdnV_Hdm.js → wardleyDiagram-VM6X3IG4-C2oY-YbF.js} +1 -1
  100. package/dist/client/assets/wiki-link-resolver-DFIwErjc.js +1 -0
  101. package/dist/client/assets/{xychartDiagram-S5SC5T6Z-DufGwNSB.js → xychartDiagram-S5SC5T6Z-CoIR8CBX.js} +1 -1
  102. package/dist/client/assets/{yjs-provider-reset-guard-DE0vINDP.js → yjs-provider-reset-guard-9ul1qF6k.js} +1 -1
  103. package/dist/client/drawio-editor.html +11 -3
  104. package/dist/client/excalidraw-editor.html +45 -2
  105. package/dist/client/export-document.html +3 -3
  106. package/dist/client/index.html +67 -35
  107. package/integrations/pi/index.ts +94 -0
  108. package/package.json +41 -32
  109. package/src/client/app/drawio-editor.html +2 -2
  110. package/src/client/app/excalidraw-editor.html +2 -2
  111. package/src/client/app/export-document.html +1 -1
  112. package/src/client/app/index.html +49 -33
  113. package/src/client/app/main-entry.js +15 -1
  114. package/src/client/application/app-shell/chat-feature.js +7 -22
  115. package/src/client/application/app-shell/git-feature.js +23 -5
  116. package/src/client/application/app-shell/presence-feature.js +8 -25
  117. package/src/client/application/app-shell/ui-feature-shell.js +36 -91
  118. package/src/client/application/app-shell/ui-feature-sidebar.js +43 -7
  119. package/src/client/application/app-shell/ui-feature-tab-activity.js +19 -6
  120. package/src/client/application/app-shell/ui-feature-toolbar.js +16 -129
  121. package/src/client/application/app-shell-elements.js +4 -0
  122. package/src/client/application/preview-render-compiler.js +1 -87
  123. package/src/client/application/preview-render-scheduler.js +8 -24
  124. package/src/client/application/preview-renderer.js +2 -2
  125. package/src/client/application/webmcp-diagram-renderer.js +47 -0
  126. package/src/client/application/workspace-coordinator.js +3 -1
  127. package/src/client/application/workspace-route-controller.js +7 -0
  128. package/src/client/bootstrap/collabmd-app-shell.js +78 -1
  129. package/src/client/domain/excalidraw-element-link.js +73 -0
  130. package/src/client/domain/excalidraw-scene.js +21 -0
  131. package/src/client/domain/hash-routes.js +8 -0
  132. package/src/client/domain/room.js +1 -5
  133. package/src/client/domain/runtime-paths.js +5 -0
  134. package/src/client/excalidraw-editor.js +135 -10
  135. package/src/client/export/export-host.js +3 -1
  136. package/src/client/export/export-pipeline.js +4 -17
  137. package/src/client/infrastructure/agent-connection-api-client.js +23 -0
  138. package/src/client/infrastructure/auth-client.js +3 -13
  139. package/src/client/infrastructure/editor-session.js +11 -0
  140. package/src/client/infrastructure/editor-view-adapter.js +13 -0
  141. package/src/client/infrastructure/excalidraw-room-client.js +80 -1
  142. package/src/client/infrastructure/git-api-client.js +39 -33
  143. package/src/client/infrastructure/lobby-presence.js +2 -5
  144. package/src/client/infrastructure/runtime-config.js +11 -1
  145. package/src/client/infrastructure/tab-activity-lock.js +2 -5
  146. package/src/client/infrastructure/vault-api-client.js +33 -26
  147. package/src/client/infrastructure/webmcp-tool-registry.js +283 -0
  148. package/src/client/infrastructure/workspace-sync-client.js +6 -4
  149. package/src/client/presentation/agent-connection-controller.js +255 -0
  150. package/src/client/presentation/backlinks-panel.js +3 -0
  151. package/src/client/presentation/bases-preview-controller.js +27 -18
  152. package/src/client/presentation/comment-ui/comment-ui-card.js +4 -2
  153. package/src/client/presentation/create-menu-presenter.js +19 -16
  154. package/src/client/presentation/excalidraw-embed-controller.js +164 -4
  155. package/src/client/presentation/file-explorer-view.js +70 -12
  156. package/src/client/presentation/file-history-view-controller.js +13 -11
  157. package/src/client/presentation/git-diff-view-controller.js +35 -43
  158. package/src/client/presentation/git-panel-controller.js +77 -27
  159. package/src/client/presentation/image-lightbox-controller.js +20 -16
  160. package/src/client/presentation/layout-controller.js +3 -1
  161. package/src/client/presentation/quick-switcher-controller.js +20 -78
  162. package/src/client/presentation/quick-switcher-text-search.js +10 -14
  163. package/src/client/styles/components/navigation.css +1 -2
  164. package/src/client/styles/features/agent-connection.css +202 -0
  165. package/src/client/styles/features/collaboration-chat.css +8 -1
  166. package/src/client/styles/features/collaboration-dialogs.css +16 -1
  167. package/src/client/styles/features/collaboration-presence.css +17 -4
  168. package/src/client/styles/features/diff-toolbar.css +1 -1
  169. package/src/client/styles/features/media-lightbox.css +12 -3
  170. package/src/client/styles/features/quick-switcher.css +20 -11
  171. package/src/client/styles/foundation/themes.css +2 -0
  172. package/src/client/styles/layout/editor-page.css +25 -11
  173. package/src/client/styles/layout/responsive.css +2 -20
  174. package/src/client/styles/layout/shell.css +1 -0
  175. package/src/client/styles/layout/sidebar.css +7 -4
  176. package/src/client/styles/primitives/controls.css +21 -54
  177. package/src/client/styles/style.css +1 -0
  178. package/src/domain/agent-tool-definitions.js +796 -0
  179. package/src/domain/collabmd-content-capabilities.js +149 -0
  180. package/src/domain/collaboration-protocol.js +2 -0
  181. package/src/domain/comment-threads.js +3 -5
  182. package/src/domain/diagram-source.js +50 -0
  183. package/src/domain/editable-content-revision.js +10 -0
  184. package/src/domain/editable-text.js +3 -0
  185. package/src/domain/exact-text-edits.js +69 -0
  186. package/src/domain/excalidraw-agent-scene.js +522 -0
  187. package/src/domain/excalidraw-agent-verification.js +460 -0
  188. package/src/domain/excalidraw-room-codec.js +1 -5
  189. package/src/domain/video-embed.js +76 -0
  190. package/src/server/application/agent-connection-service.js +178 -0
  191. package/src/server/application/agent-content-service.js +773 -0
  192. package/src/server/application/workspace-reconciliation.js +5 -7
  193. package/src/server/config/env.js +51 -1
  194. package/src/server/create-app-server.js +36 -0
  195. package/src/server/domain/bases/base-query-service.js +1 -5
  196. package/src/server/domain/collaboration/collaboration-room.js +121 -25
  197. package/src/server/domain/collaboration/protocol.js +4 -0
  198. package/src/server/domain/hosted-workspace.js +21 -0
  199. package/src/server/domain/markdown-reference-extractor.js +15 -1
  200. package/src/server/infrastructure/git/git-service.js +19 -1
  201. package/src/server/infrastructure/git/history-service.js +1 -1
  202. package/src/server/infrastructure/git/local-exclude.js +25 -0
  203. package/src/server/infrastructure/git/parsers.js +19 -17
  204. package/src/server/infrastructure/git/path-utils.js +0 -16
  205. package/src/server/infrastructure/git/status-service.js +1 -1
  206. package/src/server/infrastructure/git/untracked-files.js +12 -21
  207. package/src/server/infrastructure/http/create-agent-api-handler.js +171 -0
  208. package/src/server/infrastructure/http/create-git-api-command-handler.js +32 -0
  209. package/src/server/infrastructure/http/create-request-handler.js +28 -0
  210. package/src/server/infrastructure/http/create-static-handler.js +6 -0
  211. package/src/server/infrastructure/mcp/create-agent-mcp-handler.js +199 -0
  212. package/src/server/infrastructure/persistence/agent-connection-store.js +120 -0
  213. package/src/server/infrastructure/persistence/pull-backup-store.js +2 -27
  214. package/src/server/infrastructure/persistence/vault-file-store.js +9 -2
  215. package/src/server/shared/agent-tool-image.js +22 -0
  216. package/src/server/shared/agent-tool-rate-limiter.js +20 -0
  217. package/src/server/startup/git-remote-bootstrap.js +5 -33
  218. package/dist/client/assets/CodeMirrorEditor-UCMRAMCV-BPH4FJkv.js +0 -1
  219. package/dist/client/assets/abnfDiagram-VCTEODGH-BNDLzJ7L.js +0 -1
  220. package/dist/client/assets/browser-utils--H_DkyEF.js +0 -1
  221. package/dist/client/assets/channel-CaoKA_We.js +0 -1
  222. package/dist/client/assets/chunk-DSNCTWBM-8xkug7fQ.js +0 -2
  223. package/dist/client/assets/chunk-DU6HZSFF-COXDzJK1.js +0 -127
  224. package/dist/client/assets/chunk-R7TYR2AO-CTd0Yj98.js +0 -10
  225. package/dist/client/assets/classDiagram-DTDB5LWJ-7fEmn0zV.js +0 -1
  226. package/dist/client/assets/classDiagram-v2-JRS7N3AN-7fEmn0zV.js +0 -1
  227. package/dist/client/assets/comment-threads-9J6Em-_y.js +0 -4
  228. package/dist/client/assets/comment-ui-shared-DuoyznXW.js +0 -7
  229. package/dist/client/assets/diagram-VSXAHHWV-CQRVEZR7.js +0 -3
  230. package/dist/client/assets/dist-73RPdcyU.js +0 -1
  231. package/dist/client/assets/dist-CH-sQu3r.js +0 -1
  232. package/dist/client/assets/document-formatter-Dxl_a8XO.js +0 -2
  233. package/dist/client/assets/drawio-editor-BVaNNtYp.js +0 -9
  234. package/dist/client/assets/drawioEditor-BkIBlXx0.js +0 -2
  235. package/dist/client/assets/ebnfDiagram-PWID7BFC-OXa8VEp1.js +0 -1
  236. package/dist/client/assets/editor-session-DMyVdHLj.js +0 -54
  237. package/dist/client/assets/excalidraw-editor-BjYaNEMY.js +0 -9
  238. package/dist/client/assets/excalidraw-mermaid-stub-BNckbX2n.js +0 -1
  239. package/dist/client/assets/excalidraw-mermaid-stub-DE5FTiZB.js +0 -1
  240. package/dist/client/assets/excalidrawEditor-ChqF_d82.js +0 -2
  241. package/dist/client/assets/export-page-Dyu0XCbu.js +0 -57
  242. package/dist/client/assets/exportDocument-CJBx4Xjx.css +0 -1
  243. package/dist/client/assets/exportDocument-Dgvfa2Sd.js +0 -2
  244. package/dist/client/assets/flowDiagram-A5DVABFB-CiW1eN8C.js +0 -1
  245. package/dist/client/assets/image-ZVKINSPA-0zXSnE7M.js +0 -1
  246. package/dist/client/assets/index-CSNIMyOP.css +0 -1
  247. package/dist/client/assets/index-DG3N2Ps-.js +0 -2
  248. package/dist/client/assets/main-D0wCxpVn.js +0 -903
  249. package/dist/client/assets/mermaid.core-BJRLUQZE.js +0 -11
  250. package/dist/client/assets/pegDiagram-XKGWAZYB-B31fKPR2.js +0 -1
  251. package/dist/client/assets/preview-render-compiler-CrJIooVD.js +0 -35
  252. package/dist/client/assets/preview-render-compiler-O0JxBVNF.js +0 -1
  253. package/dist/client/assets/preview-render-profile-B4RWYWHt.js +0 -1
  254. package/dist/client/assets/prod-BiYPMR1i.js +0 -177
  255. package/dist/client/assets/prod-VxdGZ5Ly.js +0 -1
  256. package/dist/client/assets/quick-switcher-controller-CaEjEtq_.js +0 -1
  257. package/dist/client/assets/railroadDiagram-O6MQD6OU-BPifP0MB.js +0 -1
  258. package/dist/client/assets/runtime-config-BLrEKVO1.js +0 -1
  259. package/dist/client/assets/stateDiagram-v2-4QOOHH4V-B--gjrit.js +0 -1
  260. package/dist/client/assets/swimlanesDiagram-VK2B7HYN-DO8XNXEg.js +0 -8
  261. package/dist/client/assets/vault-api-client-BkwdFjx0.js +0 -6
  262. package/src/client/app/drawio-editor-entry.js +0 -1
  263. package/src/client/app/excalidraw-editor-entry.js +0 -1
  264. package/src/client/excalidraw-mermaid-stub.js +0 -7
  265. package/src/client/main.js +0 -16
  266. /package/dist/client/assets/{drawio-editor-UQQ8XHou.css → drawioEditor-UQQ8XHou.css} +0 -0
  267. /package/dist/client/assets/{excalidraw-editor-BbSbI80a.css → excalidrawEditor-BbSbI80a.css} +0 -0
  268. /package/dist/client/assets/{sizeCapture-X5ZJPWSS-B0uUizjq.js → sizeCapture-INFHLROL-B0uUizjq.js} +0 -0
@@ -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-SJ2YIMFF-CJBL3nkq.js","./chunk-FLYJHZSQ-Be7lKF17.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-ZVKINSPA-0zXSnE7M.js","./chunk-RM4UPSZO-CWRwxNWJ.js","./preload-helper-HclGiUj8.js","./CodeMirrorEditor-UCMRAMCV-BPH4FJkv.js","./dist-RKBTaQMb.js","./jsx-runtime-BpzPEenQ.js","./dist-ByrG2qBA.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{$ as r,$a as i,$c as a,$i as o,$n as s,$o as c,$r as l,$s as u,$t 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 ee,C as O,Ca as k,Cc as te,Ci as ne,Cl as re,Cn as ie,Co as ae,Cr as oe,Cs as se,Ct as ce,D as le,Da as ue,Dc as de,Di as fe,Dl as pe,Dn as me,Do as he,Dr as ge,Ds as _e,Dt as ve,E as ye,Ea as be,Ec as xe,Ei as Se,El as A,En as Ce,Eo as we,Er as Te,Es as Ee,Et as De,F as Oe,Fa as ke,Fc as Ae,Fi as je,Fn as Me,Fo as Ne,Fr as Pe,Fs as Fe,Ft as Ie,G as Le,Ga as Re,Gc as ze,Gi as Be,Gn as Ve,Go as He,Gr as Ue,Gs as We,Gt as Ge,H as Ke,Ha as qe,Hc as Je,Hi as Ye,Hn as Xe,Ho as Ze,Hr as Qe,Hs as $e,Ht as et,I as tt,Ia as nt,Ic as rt,Ii as it,In as at,Io as ot,Ir as st,Is as ct,It as lt,J as ut,Ja as dt,Jc as ft,Ji as pt,Jn as mt,Jo as ht,Jr as gt,Js as _t,Jt as vt,Ka as yt,Kc as bt,Ki as xt,Kn as St,Ko as Ct,Kr as wt,Ks as Tt,Kt as Et,L as Dt,La as Ot,Lc as kt,Li as At,Ln as jt,Lo as Mt,Lr as Nt,Ls as Pt,Lt as Ft,M as It,Ma as Lt,Mc as Rt,Mi as zt,Mn as Bt,Mo as Vt,Mr as Ht,Ms as Ut,Mt as Wt,N as Gt,Na as j,Nc as Kt,Ni as qt,Nn as Jt,No as Yt,Nr as Xt,Ns as Zt,Nt as Qt,Oa as $t,Oc as en,Oi as tn,Ol as nn,On as rn,Oo as an,Or as on,Os as sn,Ot as cn,P as ln,Pa as un,Pc as dn,Pi as fn,Pn as pn,Po as mn,Pr as hn,Ps as gn,Pt as _n,Q as vn,Qa as yn,Qc as bn,Qi as xn,Qn as Sn,Qo as Cn,Qr as wn,Qs as Tn,Qt as En,R as Dn,Ra as On,Rc as kn,Ri as An,Rn as jn,Ro as Mn,Rr as Nn,Rs as Pn,Rt as Fn,S as In,Sa as Ln,Sc as Rn,Si as zn,Sl as Bn,Sn as Vn,So as Hn,Sr as Un,Ss as Wn,St as Gn,T as Kn,Ta as qn,Tc as Jn,Ti as Yn,Tl as Xn,Tn as Zn,To as Qn,Tr as $n,Ts as er,Tt as tr,U as nr,Ua as rr,Uc as ir,Ui as ar,Un as or,Uo as sr,Ur as cr,Us as lr,Ut as ur,V as dr,Va as fr,Vc as pr,Vi as mr,Vn as hr,Vo as gr,Vr as _r,Vs as vr,Vt as yr,W as br,Wa as xr,Wc as Sr,Wi as Cr,Wn as wr,Wo as Tr,Wr as Er,Ws as Dr,Wt as Or,X as kr,Xa as Ar,Xc as jr,Xi as Mr,Xn as M,Xo as Nr,Xr as Pr,Xs as Fr,Xt as Ir,Y as Lr,Ya as Rr,Yc as zr,Yi as Br,Yn as Vr,Yo as Hr,Yr as Ur,Ys as Wr,Yt as Gr,Z as Kr,Za as qr,Zc as Jr,Zi as Yr,Zn as Xr,Zo as Zr,Zr as Qr,Zs as $r,Zt as ei,_ as ti,_a as ni,_c as ri,_i as ii,_l as ai,_n as oi,_o as si,_r as ci,_s as li,_t as ui,a as di,aa as fi,ac as pi,ai as mi,al as hi,an as gi,ao as _i,ar as vi,at as yi,b as bi,ba as xi,bc as N,bi as Si,bl as Ci,bn as wi,bo as Ti,br as Ei,bs as Di,bt as Oi,c as ki,ca as Ai,cc as ji,ci as Mi,cl as Ni,cn as P,cr as Pi,cs as Fi,ct as Ii,d as Li,da as Ri,dc as zi,di as Bi,dl as Vi,dn as Hi,do as Ui,dr as Wi,ds as Gi,dt as Ki,ea as F,ec as qi,ei as Ji,el as Yi,en as Xi,eo as Zi,er as Qi,es as $i,et as ea,f as ta,fa as na,fc as ra,fi as ia,fl as aa,fn as oa,fo as sa,fr as ca,ft as la,g as ua,ga as da,gi as fa,gl as pa,gn as ma,go as ha,gr as ga,gs as _a,gt as va,ha as ya,hc as ba,hi as xa,hl as Sa,hn as Ca,ho as wa,hr as Ta,hs as Ea,ht as Da,i as Oa,ia as ka,ic as Aa,ii as ja,il as Ma,in as Na,io as Pa,ir as Fa,is as Ia,it as La,j as Ra,ja as za,jc as Ba,ji as Va,jn as Ha,jo as Ua,jr as Wa,js as Ga,jt as Ka,k as qa,ka as Ja,kc as Ya,ki as Xa,kn as Za,ko as Qa,kr as $a,ks as eo,kt as to,l as no,la as ro,lc as io,li as ao,ll as oo,ln as so,lo as co,lr as lo,ls as uo,lt as fo,m as po,ma as mo,mc as ho,mi as go,ml as _o,mn as vo,mo as yo,mr as bo,ms as xo,mt as So,n as Co,na as wo,nc as To,ni as Eo,nl as Do,nn as Oo,no as ko,nr as Ao,ns as jo,nt as Mo,o as No,oa as Po,oc as Fo,oi as Io,ol as Lo,on as Ro,oo as zo,or as Bo,os as Vo,ot as Ho,p as Uo,pa as Wo,pc as Go,pi as Ko,pl as qo,pn as Jo,po as Yo,pr as Xo,ps as Zo,pt as Qo,q as $o,qa as es,qc as ts,qi as ns,qn as rs,qo as I,qr as is,qs as as,qt as os,r as ss,ra as cs,rc as ls,ri as us,rl as ds,rn as fs,ro as ps,rr as ms,rs as hs,s as gs,sa as _s,sc as vs,si as ys,sl as bs,sn as xs,so as Ss,sr as Cs,ss as ws,st as Ts,t as Es,ta as Ds,tc as Os,ti as ks,tl as As,tn as js,to as Ms,ts as Ns,tt as Ps,u as Fs,ua as Is,uc as Ls,ui as Rs,ul as zs,un as Bs,uo as Vs,ur as Hs,us as Us,ut as Ws,v as Gs,va as Ks,vc as L,vi as qs,vl as Js,vo as Ys,vr as Xs,vs as Zs,vt as Qs,w as $s,wa as ec,wc as tc,wi as nc,wl as rc,wn as ic,wo as R,wr as ac,ws as oc,wt as sc,x as cc,xa as lc,xc as uc,xi as dc,xl as fc,xn as pc,xo as mc,xr as hc,xs as gc,xt as _c,y as vc,ya as yc,yc as bc,yi as xc,yl as Sc,yn as z,yo as Cc,yr as wc,ys as Tc,yt as Ec,z as Dc,za as Oc,zc as kc,zi as Ac,zn as jc,zo as Mc,zr as Nc,zs as Pc}from"./chunk-RM4UPSZO-CWRwxNWJ.js";import{i as B,n as Fc,r as Ic}from"./chunk-SRAX5OIU-KFQikY-4.js";import{n as Lc,t as Rc}from"./jsx-runtime-BpzPEenQ.js";import{_ as zc}from"./chunk-FLYJHZSQ-Be7lKF17.js";import{r as Bc}from"./chunk-7XWMRXBY-CfMzEq80.js";import{n as Vc}from"./excalidraw-mermaid-stub-BNckbX2n.js";var V=e(Lc(),1),H=Rc();function Hc(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=Hc(e[t]))&&(r&&(r+=` `),r+=n);else for(t in e)e[t]&&(r&&(r+=` `),r+=t)}return r}function U(){for(var e=0,t,n,r=``;e<arguments.length;)(t=arguments[e++])&&(n=Hc(t))&&(r&&(r+=` `),r+=n);return r}var Uc=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=_})),Wc=t((e=>{var t=Lc();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`})),Gc=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=Wc()})),Kc=e(Uc(),1),qc=e(Gc(),1),Jc=0;function Yc(e,t){let n=`atom${++Jc}`,r={toString(){return n}};return typeof e==`function`?r.read=e:(r.init=e,r.read=Xc,r.write=Zc),t&&(r.write=t),r}function Xc(e){return e(this)}function Zc(e,t,n){return t(this,typeof n==`function`?n(e(this)):n)}var Qc=(e,t)=>e.unstable_is?e.unstable_is(t):t===e,$c=e=>`init`in e,el=e=>!!e.write,tl=new WeakMap,nl=e=>al(e)&&!tl.get(e)?.[1],rl=(e,t)=>{let n=tl.get(e);n&&(n[1]=!0,n[0].forEach(e=>e(t)))},il=e=>{if(tl.has(e))return;let t=[new Set,!1];tl.set(e,t);let n=()=>{t[1]=!0};e.then(n,n),e.onCancel=e=>{t[0].add(e)}},al=e=>typeof e?.then==`function`,ol=e=>`v`in e||`e`in e,sl=e=>{if(`e`in e)throw e.e;return e.v},cl=(e,t,n)=>{n.p.has(e)||(n.p.add(e),t.then(()=>{n.p.delete(e)},()=>{n.p.delete(e)}))},ll=(e,t,n,r,i)=>{var a;n.d.set(r,i.n),nl(n.v)&&cl(t,n.v,i),(a=i.m)==null||a.t.add(t),e&&pl(e,r,t)},ul=()=>({D:new Map,H:new Set,M:new Set,L:new Set}),dl=(e,t,n)=>{e[t].add(n)},fl=(e,t,n)=>{e.D.has(t)||(e.D.set(t,new Set),dl(e,`M`,()=>{var t;(t=n.m)==null||t.l.forEach(t=>dl(e,`M`,t))}))},pl=(e,t,n)=>{let r=e.D.get(t);r&&r.add(n)},ml=(e,t)=>e.D.get(t),hl=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},gl=(...[e,t,n,r])=>{let i=(t,n,r)=>{let i=`v`in n,a=n.v,o=nl(n.v)?n.v:null;if(al(r)){il(r);for(let i of n.d.keys())cl(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&&rl(o,r))},a=(n,r)=>{var o;let s=e(r);if(ol(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(Qc(r,t)){let n=e(t);if(!ol(n)){if($c(t))i(t,n,t.init);else throw Error(`no atom init`)}return sl(n)}let o=a(n,t);try{return sl(o)}finally{if(c)ll(n,r,s,t,o);else{let e=ul();ll(e,r,s,t,o),d(e,r,s),hl(e)}}},f,p,m={get signal(){return f||=new AbortController,f.signal},get setSelf(){return!p&&el(r)&&(p=(...e)=>{if(!c)return u(r,...e)}),p}};try{let e=t(r,l,m);if(i(r,s,e),al(e)){(o=e.onCancel)==null||o.call(e,()=>f?.abort());let t=()=>{if(s.m){let e=ul();d(e,r,s),hl(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=>sl(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=ml(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])}dl(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&&(fl(e,i,o),n.add(i))),delete o.x}})},l=(t,r,...o)=>{let s=!0,u=e=>sl(a(t,e)),f=(n,...a)=>{let o=e(n);try{if(Qc(r,n)){if(!$c(n))throw Error(`atom not writable`);let e=o.n,r=a[0];i(n,o,r),d(t,n,o),e!==o.n&&(fl(t,n,o),c(t,n,o));return}return l(t,n,...a)}finally{s||hl(t)}};try{return n(r,u,f,...o)}finally{s=!1}},u=(e,...t)=>{let n=ul();try{return l(n,e,...t)}finally{hl(n)}},d=(t,n,r)=>{if(r.m&&!nl(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},el(n)){let e=i.m,a,o=(e,t)=>{let r=!0;a=(...t)=>{try{return l(e,n,...t)}finally{r||hl(e)}};try{return t()}finally{r=!1}};dl(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&&dl(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=ul(),i=e(t),a=f(r,t,i).l;return a.add(n),hl(r),()=>{a.delete(n);let e=ul();p(e,t,i),hl(e)}},unstable_derive:i=>gl(...i(e,t,n,r))}},_l=()=>{let e=new WeakMap;return gl(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))},vl,yl=()=>(vl||=_l(),vl),bl=(0,V.createContext)(void 0),xl=e=>{let t=(0,V.useContext)(bl);return e?.store||t||yl()},Sl=e=>typeof e?.then==`function`,Cl=e=>{e.status=`pending`,e.then(t=>{e.status=`fulfilled`,e.value=t},t=>{e.status=`rejected`,e.reason=t})},wl=V.use||(e=>{if(e.status===`pending`)throw e;if(e.status===`fulfilled`)return e.value;throw e.status===`rejected`?e.reason:(Cl(e),e)}),Tl=new WeakMap,El=e=>{let t=Tl.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=>{Sl(e)?(Tl.set(e,t),i=e,e.then(a(e),o(e)),s(e)):n(e)})};e.then(a(e),o(e)),s(e)}),Tl.set(e,t)),t};function Dl(e,t){let n=xl(t),[[r,i,a],o]=(0,V.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,V.useEffect)(()=>{let t=n.sub(e,()=>{if(typeof c==`number`){let t=n.get(e);Sl(t)&&Cl(El(t)),setTimeout(o,c);return}o()});return o(),t},[n,e,c]),(0,V.useDebugValue)(s),Sl(s)?wl(El(s)):s}function Ol(e,t){let n=xl(t);return(0,V.useCallback)((...t)=>n.set(e,...t),[n,e])}function kl(e,t){return[Dl(e,t),Ol(e,t)]}var Al=new WeakMap;function jl(e,t){let n=xl(t),r=Ml(n);for(let[i,a]of e)(!r.has(i)||t?.dangerouslyForceHydrate)&&(r.add(i),n.set(i,a))}var Ml=e=>{let t=Al.get(e);return t||(t=new WeakSet,Al.set(e,t)),t};function Nl(){return Nl=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},Nl.apply(this,arguments)}function Pl(){let e=(0,V.createContext)(null);function t({store:t,initialValues:n=[],children:r}){let i=(0,V.useRef)(t);return i.current||=_l(),jl(n,{store:i.current}),(0,H.jsx)(e.Provider,{value:i.current,children:r})}let n=t=>{let n=(0,V.useContext)(e);if(!n)throw Error(`Missing Provider from createIsolation`);return xl(Nl({store:n},t))};return{Provider:t,useStore:n,useAtom:(e,t)=>{let r=n();return kl(e,Nl({store:r},t))},useAtomValue:(e,t)=>{let r=n();return Dl(e,Nl({store:r},t))},useSetAtom:(e,t)=>{let r=n();return Ol(e,Nl({store:r},t))}}}var{read:Fl,write:Il}=Yc(null);(0,V.createContext)({scope:void 0,baseStore:void 0});function Ll(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function Rl(...e){return t=>{let n=!1,r=e.map(e=>{let r=Ll(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():Ll(e[t],null)}}}}function zl(...e){return V.useCallback(Rl(...e),e)}function Bl(e){let t=Vl(e),n=V.forwardRef((e,n)=>{let{children:r,...i}=e,a=V.Children.toArray(r),o=a.find(Ul);if(o){let e=o.props.children,r=a.map(t=>t===o?V.Children.count(e)>1?V.Children.only(null):V.isValidElement(e)?e.props.children:null:t);return(0,H.jsx)(t,{...i,ref:n,children:V.isValidElement(e)?V.cloneElement(e,void 0,r):null})}return(0,H.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function Vl(e){let t=V.forwardRef((e,t)=>{let{children:n,...r}=e;if(V.isValidElement(n)){let e=Gl(n),i=Wl(r,n.props);return n.type!==V.Fragment&&(i.ref=t?Rl(t,e):e),V.cloneElement(n,i)}return V.Children.count(n)>1?V.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Hl=Symbol(`radix.slottable`);function Ul(e){return V.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===Hl}function Wl(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 Gl(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 Kl=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=Bl(`Primitive.${t}`),r=V.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,H.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function ql(e,t){e&&qc.flushSync(()=>e.dispatchEvent(t))}function Jl(e,t=[]){let n=[];function r(t,r){let i=V.createContext(r),a=n.length;n=[...n,r];let o=t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=V.useMemo(()=>o,Object.values(o));return(0,H.jsx)(s.Provider,{value:c,children:r})};o.displayName=t+`Provider`;function s(n,o){let s=o?.[e]?.[a]||i,c=V.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=>V.createContext(e));return function(n){let r=n?.[e]||t;return V.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,Yl(i,...t)]}function Yl(...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 V.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}function Xl(e){let t=e+`CollectionProvider`,[n,r]=Jl(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=e=>{let{scope:t,children:n}=e,r=V.useRef(null),a=V.useRef(new Map).current;return(0,H.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})};o.displayName=t;let s=e+`CollectionSlot`,c=Bl(s),l=V.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=zl(t,a(s,n).collectionRef);return(0,H.jsx)(c,{ref:i,children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=Bl(u),p=V.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=V.useRef(null),s=zl(t,o),c=a(u,n);return V.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,H.jsx)(f,{[d]:``,ref:s,children:r})});p.displayName=u;function m(t){let n=a(e+`CollectionConsumer`,t);return V.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 W(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}var Zl=globalThis?.document?V.useLayoutEffect:()=>{},Ql=V.useInsertionEffect||Zl;function $l({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){let[i,a,o]=eu({defaultProp:t,onChange:n}),s=e!==void 0,c=s?e:i;{let t=V.useRef(e!==void 0);V.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,V.useCallback(t=>{if(s){let n=tu(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}function eu({defaultProp:e,onChange:t}){let[n,r]=V.useState(e),i=V.useRef(n),a=V.useRef(t);return Ql(()=>{a.current=t},[t]),V.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}function tu(e){return typeof e==`function`}function nu(e,t){return V.useReducer((e,n)=>t[e][n]??e,e)}var ru=e=>{let{present:t,children:n}=e,r=iu(t),i=typeof n==`function`?n({present:r.isPresent}):V.Children.only(n),a=zl(r.ref,ou(i));return typeof n==`function`||r.isPresent?V.cloneElement(i,{ref:a}):null};ru.displayName=`Presence`;function iu(e){let[t,n]=V.useState(),r=V.useRef(null),i=V.useRef(e),a=V.useRef(`none`),[o,s]=nu(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return V.useEffect(()=>{let e=au(r.current);a.current=o===`mounted`?e:`none`},[o]),Zl(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,o=au(t);e?s(`MOUNT`):o===`none`||t?.display===`none`?s(`UNMOUNT`):s(n&&r!==o?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,s]),Zl(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=au(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=au(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:V.useCallback(e=>{r.current=e?getComputedStyle(e):null,n(e)},[])}}function au(e){return e?.animationName||`none`}function ou(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 su=V.useId||(()=>void 0),cu=0;function lu(e){let[t,n]=V.useState(su());return Zl(()=>{e||n(e=>e??String(cu++))},[e]),e||(t?`radix-${t}`:``)}var uu=V.createContext(void 0);function du(e){let t=V.useContext(uu);return e||t||`ltr`}function fu(e){let t=V.useRef(e);return V.useEffect(()=>{t.current=e}),V.useMemo(()=>(...e)=>t.current?.(...e),[])}function pu(e,t=globalThis?.document){let n=fu(e);V.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 mu=`DismissableLayer`,hu=`dismissableLayer.update`,gu=`dismissableLayer.pointerDownOutside`,_u=`dismissableLayer.focusOutside`,vu,yu=V.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),bu=V.forwardRef((e,t)=>{let{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:a,onInteractOutside:o,onDismiss:s,...c}=e,l=V.useContext(yu),[u,d]=V.useState(null),f=u?.ownerDocument??globalThis?.document,[,p]=V.useState({}),m=zl(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=Cu(e=>{let t=e.target,n=[...l.branches].some(e=>e.contains(t));!b||n||(i?.(e),o?.(e),e.defaultPrevented||s?.())},f),S=wu(e=>{let t=e.target;[...l.branches].some(e=>e.contains(t))||(a?.(e),o?.(e),e.defaultPrevented||s?.())},f);return pu(e=>{v===l.layers.size-1&&(r?.(e),!e.defaultPrevented&&s&&(e.preventDefault(),s()))},f),V.useEffect(()=>{if(u)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(vu=f.body.style.pointerEvents,f.body.style.pointerEvents=`none`),l.layersWithOutsidePointerEventsDisabled.add(u)),l.layers.add(u),Tu(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=vu)}},[u,f,n,l]),V.useEffect(()=>()=>{u&&(l.layers.delete(u),l.layersWithOutsidePointerEventsDisabled.delete(u),Tu())},[u,l]),V.useEffect(()=>{let e=()=>p({});return document.addEventListener(hu,e),()=>document.removeEventListener(hu,e)},[]),(0,H.jsx)(Kl.div,{...c,ref:m,style:{pointerEvents:y?b?`auto`:`none`:void 0,...e.style},onFocusCapture:W(e.onFocusCapture,S.onFocusCapture),onBlurCapture:W(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:W(e.onPointerDownCapture,x.onPointerDownCapture)})});bu.displayName=mu;var xu=`DismissableLayerBranch`,Su=V.forwardRef((e,t)=>{let n=V.useContext(yu),r=V.useRef(null),i=zl(t,r);return V.useEffect(()=>{let e=r.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),(0,H.jsx)(Kl.div,{...e,ref:i})});Su.displayName=xu;function Cu(e,t=globalThis?.document){let n=fu(e),r=V.useRef(!1),i=V.useRef(()=>{});return V.useEffect(()=>{let e=e=>{if(e.target&&!r.current){let r=function(){Eu(gu,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 wu(e,t=globalThis?.document){let n=fu(e),r=V.useRef(!1);return V.useEffect(()=>{let e=e=>{e.target&&!r.current&&Eu(_u,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 Tu(){let e=new CustomEvent(hu);document.dispatchEvent(e)}function Eu(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?ql(i,a):i.dispatchEvent(a)}var Du=`focusScope.autoFocusOnMount`,Ou=`focusScope.autoFocusOnUnmount`,ku={bubbles:!1,cancelable:!0},Au=`FocusScope`,ju=V.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=V.useState(null),l=fu(i),u=fu(a),d=V.useRef(null),f=zl(t,e=>c(e)),p=V.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;V.useEffect(()=>{if(r){let e=function(e){if(p.paused||!s)return;let t=e.target;s.contains(t)?d.current=t:Ru(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||Ru(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&Ru(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]),V.useEffect(()=>{if(s){zu.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(Du,ku);s.addEventListener(Du,l),s.dispatchEvent(t),t.defaultPrevented||(Mu(Hu(Pu(s)),{select:!0}),document.activeElement===e&&Ru(s))}return()=>{s.removeEventListener(Du,l),setTimeout(()=>{let t=new CustomEvent(Ou,ku);s.addEventListener(Ou,u),s.dispatchEvent(t),t.defaultPrevented||Ru(e??document.body,{select:!0}),s.removeEventListener(Ou,u),zu.remove(p)},0)}}},[s,l,u,p]);let m=V.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]=Nu(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&Ru(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&Ru(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,H.jsx)(Kl.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});ju.displayName=Au;function Mu(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(Ru(r,{select:t}),document.activeElement!==n)return}function Nu(e){let t=Pu(e);return[Fu(t,e),Fu(t.reverse(),e)]}function Pu(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 Fu(e,t){for(let n of e)if(!Iu(n,{upTo:t}))return n}function Iu(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 Lu(e){return e instanceof HTMLInputElement&&`select`in e}function Ru(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Lu(e)&&t&&e.select()}}var zu=Bu();function Bu(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=Vu(e,t),e.unshift(t)},remove(t){e=Vu(e,t),e[0]?.resume()}}}function Vu(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Hu(e){return e.filter(e=>e.tagName!==`A`)}var Uu=`Portal`,Wu=V.forwardRef((e,t)=>{let{container:n,...r}=e,[i,a]=V.useState(!1);Zl(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?qc.createPortal((0,H.jsx)(Kl.div,{...r,ref:t}),o):null});Wu.displayName=Uu;var Gu=0;function Ku(){V.useEffect(()=>{let e=document.querySelectorAll(`[data-radix-focus-guard]`);return document.body.insertAdjacentElement(`afterbegin`,e[0]??qu()),document.body.insertAdjacentElement(`beforeend`,e[1]??qu()),Gu++,()=>{Gu===1&&document.querySelectorAll(`[data-radix-focus-guard]`).forEach(e=>e.remove()),Gu--}},[])}function qu(){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 Ju=function(){return Ju=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},Ju.apply(this,arguments)};function Yu(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 Xu(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 Zu=`right-scroll-bar-position`,Qu=`width-before-scroll-bar`,$u=`with-scroll-bars-hidden`,ed=`--removed-body-scroll-bar-size`;function td(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function nd(e,t){var n=(0,V.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 rd=typeof window<`u`?V.useLayoutEffect:V.useEffect,id=new WeakMap;function ad(e,t){var n=nd(t||null,function(t){return e.forEach(function(e){return td(e,t)})});return rd(function(){var t=id.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||td(e,null)}),i.forEach(function(e){r.has(e)||td(e,a)})}id.set(n,e)},[e]),n}function od(e){return e}function sd(e,t){t===void 0&&(t=od);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 cd(e){e===void 0&&(e={});var t=sd(null);return t.options=Ju({async:!0,ssr:!1},e),t}var ld=function(e){var t=e.sideCar,n=Yu(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 V.createElement(r,Ju({},n))};ld.isSideCarExport=!0;function ud(e,t){return e.useMedium(t),ld}var dd=cd(),fd=function(){},pd=V.forwardRef(function(e,t){var n=V.useRef(null),r=V.useState({onScrollCapture:fd,onWheelCapture:fd,onTouchMoveCapture:fd}),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=Yu(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),x=f,S=ad([n,t]),C=Ju(Ju({},b),i);return V.createElement(V.Fragment,null,u&&V.createElement(x,{sideCar:dd,removeScrollBar:l,shards:d,noRelative:p,noIsolation:m,inert:h,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:y}),o?V.cloneElement(V.Children.only(s),Ju(Ju({},C),{ref:S})):V.createElement(v,Ju({},C,{className:c,ref:S}),s))});pd.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},pd.classNames={fullWidth:Qu,zeroRight:Zu};var md=function(){if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function hd(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=md();return t&&e.setAttribute(`nonce`,t),e}function gd(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function _d(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var vd=function(){var e=0,t=null;return{add:function(n){e==0&&(t=hd())&&(gd(t,n),_d(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},yd=function(){var e=vd();return function(t,n){V.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},bd=function(){var e=yd();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},xd={left:0,top:0,right:0,gap:0},Sd=function(e){return parseInt(e||``,10)||0},Cd=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[Sd(n),Sd(r),Sd(i)]},wd=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return xd;var t=Cd(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])}},Td=bd(),Ed=`data-scroll-locked`,Dd=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
- .${$u} {
4
- overflow: hidden ${r};
5
- padding-right: ${s}px ${r};
6
- }
7
- body[${Ed}] {
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
- .${Zu} {
21
- right: ${s}px ${r};
22
- }
23
-
24
- .${Qu} {
25
- margin-right: ${s}px ${r};
26
- }
27
-
28
- .${Zu} .${Zu} {
29
- right: 0 ${r};
30
- }
31
-
32
- .${Qu} .${Qu} {
33
- margin-right: 0 ${r};
34
- }
35
-
36
- body[${Ed}] {
37
- ${ed}: ${s}px;
38
- }
39
- `},Od=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},kd=function(){V.useEffect(function(){return document.body.setAttribute(Ed,(Od()+1).toString()),function(){var e=Od()-1;e<=0?document.body.removeAttribute(Ed):document.body.setAttribute(Ed,e.toString())}},[])},Ad=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;kd();var a=V.useMemo(function(){return wd(i)},[i]);return V.createElement(Td,{styles:Dd(a,!t,i,n?``:`!important`)})},jd=!1;if(typeof window<`u`)try{var Md=Object.defineProperty({},"passive",{get:function(){return jd=!0,!0}});window.addEventListener(`test`,Md,Md),window.removeEventListener(`test`,Md,Md)}catch{jd=!1}var Nd=jd?{passive:!1}:!1,Pd=function(e){return e.tagName===`TEXTAREA`},Fd=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!Pd(e)&&n[t]===`visible`)},Id=function(e){return Fd(e,`overflowY`)},Ld=function(e){return Fd(e,`overflowX`)},Rd=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),Vd(e,r)){var i=Hd(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},zd=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},Bd=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},Vd=function(e,t){return e===`v`?Id(t):Ld(t)},Hd=function(e,t){return e===`v`?zd(t):Bd(t)},Ud=function(e,t){return e===`h`&&t===`rtl`?-1:1},Wd=function(e,t,n,r,i){var a=Ud(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=Hd(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&Vd(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},Gd=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Kd=function(e){return[e.deltaX,e.deltaY]},qd=function(e){return e&&`current`in e?e.current:e},Jd=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Yd=function(e){return`
40
- .block-interactivity-${e} {pointer-events: none;}
41
- .allow-interactivity-${e} {pointer-events: all;}
42
- `},Xd=0,Zd=[];function Qd(e){var t=V.useRef([]),n=V.useRef([0,0]),r=V.useRef(),i=V.useState(Xd++)[0],a=V.useState(bd)[0],o=V.useRef(e);V.useEffect(function(){o.current=e},[e]),V.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=Xu([e.lockRef.current],(e.shards||[]).map(qd),!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=V.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=Gd(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=Rd(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=Rd(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 Wd(h,t,e,h===`h`?s:c,!0)},[]),c=V.useCallback(function(e){var n=e;if(!(!Zd.length||Zd[Zd.length-1]!==a)){var r=`deltaY`in n?Kd(n):Gd(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&Jd(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(qd).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=V.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:$d(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=V.useCallback(function(e){n.current=Gd(e),r.current=void 0},[]),d=V.useCallback(function(t){l(t.type,Kd(t),t.target,s(t,e.lockRef.current))},[]),f=V.useCallback(function(t){l(t.type,Gd(t),t.target,s(t,e.lockRef.current))},[]);V.useEffect(function(){return Zd.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,Nd),document.addEventListener(`touchmove`,c,Nd),document.addEventListener(`touchstart`,u,Nd),function(){Zd=Zd.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,Nd),document.removeEventListener(`touchmove`,c,Nd),document.removeEventListener(`touchstart`,u,Nd)}},[]);var p=e.removeScrollBar,m=e.inert;return V.createElement(V.Fragment,null,m?V.createElement(a,{styles:Yd(i)}):null,p?V.createElement(Ad,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function $d(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var ef=ud(dd,Qd),tf=V.forwardRef(function(e,t){return V.createElement(pd,Ju({},e,{ref:t,sideCar:ef}))});tf.classNames=pd.classNames;var nf=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},rf=new WeakMap,af=new WeakMap,of={},sf=0,cf=function(e){return e&&(e.host||cf(e.parentNode))},lf=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=cf(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})},uf=function(e,t,n,r){var i=lf(t,Array.isArray(e)?e:[e]);of[n]||(of[n]=new WeakMap);var a=of[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=(rf.get(e)||0)+1,l=(a.get(e)||0)+1;rf.set(e,c),a.set(e,l),o.push(e),c===1&&i&&af.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(),sf++,function(){o.forEach(function(e){var t=rf.get(e)-1,i=a.get(e)-1;rf.set(e,t),a.set(e,i),t||(af.has(e)||e.removeAttribute(r),af.delete(e)),i||e.removeAttribute(n)}),sf--,sf||(rf=new WeakMap,rf=new WeakMap,af=new WeakMap,of={})}},df=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||nf(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),uf(r,i,n,`aria-hidden`)):function(){return null}},ff=t((e=>{var t=Lc();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})),pf=t(((e,t)=>{t.exports=ff()}));function mf(e){let[t,n]=V.useState(void 0);return Zl(()=>{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 hf=[`top`,`right`,`bottom`,`left`],gf=Math.min,_f=Math.max,vf=Math.round,yf=Math.floor,bf=e=>({x:e,y:e}),xf={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function Sf(e,t,n){return _f(e,gf(t,n))}function Cf(e,t){return typeof e==`function`?e(t):e}function wf(e){return e.split(`-`)[0]}function Tf(e){return e.split(`-`)[1]}function Ef(e){return e===`x`?`y`:`x`}function Df(e){return e===`y`?`height`:`width`}function Of(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function kf(e){return Ef(Of(e))}function Af(e,t,n){n===void 0&&(n=!1);let r=Tf(e),i=kf(e),a=Df(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=zf(o)),[o,zf(o)]}function jf(e){let t=zf(e);return[Mf(e),t,Mf(t)]}function Mf(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var Nf=[`left`,`right`],Pf=[`right`,`left`],Ff=[`top`,`bottom`],If=[`bottom`,`top`];function Lf(e,t,n){switch(e){case`top`:case`bottom`:return n?t?Pf:Nf:t?Nf:Pf;case`left`:case`right`:return t?Ff:If;default:return[]}}function Rf(e,t,n,r){let i=Tf(e),a=Lf(wf(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(Mf)))),a}function zf(e){let t=wf(e);return xf[t]+e.slice(t.length)}function Bf(e){return{top:0,right:0,bottom:0,left:0,...e}}function Vf(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:Bf(e)}function Hf(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 Uf(e,t,n){let{reference:r,floating:i}=e,a=Of(t),o=kf(t),s=Df(o),c=wf(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(Tf(t)){case`start`:p[o]-=f*(n&&l?-1:1);break;case`end`:p[o]+=f*(n&&l?-1:1)}return p}async function Wf(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}=Cf(t,e),p=Vf(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=Hf(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=Hf(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 Gf=50,Kf=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:Wf},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=Uf(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<Gf&&(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}=Uf(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},qf=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}=Cf(e,t)||{};if(l==null)return{};let d=Vf(u),f={x:n,y:r},p=kf(i),m=Df(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=gf(d[_],T),D=gf(d[v],T),ee=E,O=C-h[m]-D,k=C/2-h[m]/2+w,te=Sf(ee,k,O),ne=!c.arrow&&Tf(i)!=null&&k!==te&&a.reference[m]/2-(k<ee?E:D)-h[m]/2<0,re=ne?k<ee?k-ee:k-O:0;return{[p]:f[p]+re,data:{[p]:te,centerOffset:k-te-re,...ne&&{alignmentOffset:re}},reset:ne}}}),Jf=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}=Cf(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=wf(r),_=Of(o),v=wf(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[zf(o)]:jf(o)),x=p!==`none`;!d&&x&&b.push(...Rf(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=Af(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`||_===Of(t)||T.every(e=>Of(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=Of(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 Yf(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Xf(e){return hf.some(t=>e[t]>=0)}var Zf=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=Cf(e,t);switch(i){case`referenceHidden`:{let e=Yf(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:Xf(e)}}}case`escaped`:{let e=Yf(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:Xf(e)}}}default:return{}}}}},Qf=new Set([`left`,`top`]);async function $f(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=wf(n),s=Tf(n),c=Of(n)===`y`,l=Qf.has(o)?-1:1,u=a&&c?-1:1,d=Cf(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 ep=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 $f(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}}}}},tp=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}=Cf(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=Of(wf(i)),p=Ef(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=Sf(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=Sf(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}}}}}},np=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}=Cf(e,t),u={x:n,y:r},d=Of(i),f=Ef(d),p=u[f],m=u[d],h=Cf(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=Qf.has(wf(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}}}},rp=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}=Cf(e,t),u=await o.detectOverflow(t,l),d=wf(i),f=Tf(i),p=Of(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=gf(h-u[g],v),x=gf(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=_f(u.left,0),t=_f(u.right,0),n=_f(u.top,0),r=_f(u.bottom,0);p?w=m-2*(e!==0||t!==0?e+t:_f(u.left,u.right)):C=h-2*(n!==0||r!==0?n+r:_f(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 ip(){return typeof window<`u`}function ap(e){return cp(e)?(e.nodeName||``).toLowerCase():`#document`}function op(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function sp(e){return((cp(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function cp(e){return ip()?e instanceof Node||e instanceof op(e).Node:!1}function lp(e){return ip()?e instanceof Element||e instanceof op(e).Element:!1}function up(e){return ip()?e instanceof HTMLElement||e instanceof op(e).HTMLElement:!1}function dp(e){return!ip()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof op(e).ShadowRoot}function fp(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=Cp(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function pp(e){return/^(table|td|th)$/.test(ap(e))}function mp(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var hp=/transform|translate|scale|rotate|perspective|filter/,gp=/paint|layout|strict|content/,_p=e=>!!e&&e!==`none`,vp;function yp(e){let t=lp(e)?Cp(e):e;return _p(t.transform)||_p(t.translate)||_p(t.scale)||_p(t.rotate)||_p(t.perspective)||!xp()&&(_p(t.backdropFilter)||_p(t.filter))||hp.test(t.willChange||``)||gp.test(t.contain||``)}function bp(e){let t=Tp(e);for(;up(t)&&!Sp(t);){if(yp(t))return t;if(mp(t))return null;t=Tp(t)}return null}function xp(){return vp??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),vp}function Sp(e){return/^(html|body|#document)$/.test(ap(e))}function Cp(e){return op(e).getComputedStyle(e)}function wp(e){return lp(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Tp(e){if(ap(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||dp(e)&&e.host||sp(e);return dp(t)?t.host:t}function Ep(e){let t=Tp(e);return Sp(t)?e.ownerDocument?e.ownerDocument.body:e.body:up(t)&&fp(t)?t:Ep(t)}function Dp(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Ep(e),i=r===e.ownerDocument?.body,a=op(r);if(i){let e=Op(a);return t.concat(a,a.visualViewport||[],fp(r)?r:[],e&&n?Dp(e):[])}return t.concat(r,Dp(r,[],n))}function Op(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function kp(e){let t=Cp(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=up(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=vf(n)!==a||vf(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Ap(e){return lp(e)?e:e.contextElement}function jp(e){let t=Ap(e);if(!up(t))return bf(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=kp(t),o=(a?vf(n.width):n.width)/r,s=(a?vf(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Mp=bf(0);function Np(e){let t=op(e);return!xp()||!t.visualViewport?Mp:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Pp(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==op(e)?!1:t}function Fp(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Ap(e),o=bf(1);t&&(r?lp(r)&&(o=jp(r)):o=jp(e));let s=Pp(a,n,r)?Np(a):bf(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=op(a),t=r&&lp(r)?op(r):r,n=e,i=Op(n);for(;i&&r&&t!==n;){let e=jp(i),t=i.getBoundingClientRect(),r=Cp(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=op(i),i=Op(n)}}return Hf({width:u,height:d,x:c,y:l})}function Ip(e,t){let n=wp(e).scrollLeft;return t?t.left+n:Fp(sp(e)).left+n}function Lp(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-Ip(e,n),y:n.top+t.scrollTop}}function Rp(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=sp(r),s=t?mp(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=bf(1),u=bf(0),d=up(r);if((d||!d&&!a)&&((ap(r)!==`body`||fp(o))&&(c=wp(r)),d)){let e=Fp(r);l=jp(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?Lp(o,c):bf(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 zp(e){return Array.from(e.getClientRects())}function Bp(e){let t=sp(e),n=wp(e),r=e.ownerDocument.body,i=_f(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=_f(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+Ip(e),s=-n.scrollTop;return Cp(r).direction===`rtl`&&(o+=_f(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}var Vp=25;function Hp(e,t){let n=op(e),r=sp(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=xp();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=Ip(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<=Vp&&(a-=o)}else l<=Vp&&(a+=l);return{width:a,height:o,x:s,y:c}}function Up(e,t){let n=Fp(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=up(e)?jp(e):bf(1);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function Wp(e,t,n){let r;if(t===`viewport`)r=Hp(e,n);else if(t===`document`)r=Bp(sp(e));else if(lp(t))r=Up(t,n);else{let n=Np(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Hf(r)}function Gp(e,t){let n=Tp(e);return n===t||!lp(n)||Sp(n)?!1:Cp(n).position===`fixed`||Gp(n,t)}function Kp(e,t){let n=t.get(e);if(n)return n;let r=Dp(e,[],!1).filter(e=>lp(e)&&ap(e)!==`body`),i=null,a=Cp(e).position===`fixed`,o=a?Tp(e):e;for(;lp(o)&&!Sp(o);){let t=Cp(o),n=yp(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&(i.position===`absolute`||i.position===`fixed`)||fp(o)&&!n&&Gp(e,o))?r=r.filter(e=>e!==o):i=t,o=Tp(o)}return t.set(e,r),r}function qp(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?mp(t)?[]:Kp(t,this._c):[].concat(n),r],o=Wp(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=Wp(t,a[e],i);s=_f(n.top,s),c=gf(n.right,c),l=gf(n.bottom,l),u=_f(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function Jp(e){let{width:t,height:n}=kp(e);return{width:t,height:n}}function Yp(e,t,n){let r=up(t),i=sp(t),a=n===`fixed`,o=Fp(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=bf(0);function l(){c.x=Ip(i)}if(r||!r&&!a){if((ap(t)!==`body`||fp(i))&&(s=wp(t)),r){let e=Fp(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?Lp(i,s):bf(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 Xp(e){return Cp(e).position===`static`}function Zp(e,t){if(!up(e)||Cp(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return sp(e)===n&&(n=n.ownerDocument.body),n}function Qp(e,t){let n=op(e);if(mp(e))return n;if(!up(e)){let t=Tp(e);for(;t&&!Sp(t);){if(lp(t)&&!Xp(t))return t;t=Tp(t)}return n}let r=Zp(e,t);for(;r&&pp(r)&&Xp(r);)r=Zp(r,t);return r&&Sp(r)&&Xp(r)&&!yp(r)?n:r||bp(e)||n}var $p=async function(e){let t=this.getOffsetParent||Qp,n=this.getDimensions,r=await n(e.floating);return{reference:Yp(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function em(e){return Cp(e).direction===`rtl`}var tm={convertOffsetParentRelativeRectToViewportRelativeRect:Rp,getDocumentElement:sp,getClippingRect:qp,getOffsetParent:Qp,getElementRects:$p,getClientRects:zp,getDimensions:Jp,getScale:jp,isElement:lp,isRTL:em};function nm(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function rm(e,t){let n=null,r,i=sp(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=yf(d),h=yf(i.clientWidth-(u+f)),g=yf(i.clientHeight-(d+p)),_=yf(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:_f(0,gf(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&&!nm(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 im(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=Ap(e),u=i||a?[...l?Dp(l):[],...t?Dp(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?rm(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?Fp(e):null;c&&g();function g(){let t=Fp(e);h&&!nm(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 am=ep,om=tp,sm=Jf,cm=rp,lm=Zf,um=qf,dm=np,fm=(e,t,n)=>{let r=new Map,i={platform:tm,...n},a={...i.platform,_c:r};return Kf(e,t,{...i,platform:a})},pm=typeof document<`u`?V.useLayoutEffect:function(){};function mm(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(!mm(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)&&!mm(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function hm(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function gm(e,t){let n=hm(e);return Math.round(t*n)/n}function _m(e){let t=V.useRef(e);return pm(()=>{t.current=e}),t}function vm(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]=V.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=V.useState(r);mm(f,r)||p(r);let[m,h]=V.useState(null),[g,_]=V.useState(null),v=V.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=V.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=V.useRef(null),C=V.useRef(null),w=V.useRef(u),T=c!=null,E=_m(c),D=_m(i),ee=_m(l),O=V.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),fm(S.current,C.current,e).then(e=>{let t={...e,isPositioned:ee.current!==!1};k.current&&!mm(w.current,t)&&(w.current=t,qc.flushSync(()=>{d(t)}))})},[f,t,n,D,ee]);pm(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let k=V.useRef(!1);pm(()=>(k.current=!0,()=>{k.current=!1}),[]),pm(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,O);O()}},[b,x,O,E,T]);let te=V.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),ne=V.useMemo(()=>({reference:b,floating:x}),[b,x]),re=V.useMemo(()=>{let e={position:n,left:0,top:0};if(!ne.floating)return e;let t=gm(ne.floating,u.x),r=gm(ne.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...hm(ne.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,ne.floating,u.x,u.y]);return V.useMemo(()=>({...u,update:O,refs:te,elements:ne,floatingStyles:re}),[u,O,te,ne,re])}var ym=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?{}:um({element:r.current,padding:i}).fn(n):r?um({element:r,padding:i}).fn(n):{}}}},bm=(e,t)=>{let n=am(e);return{name:n.name,fn:n.fn,options:[e,t]}},xm=(e,t)=>{let n=om(e);return{name:n.name,fn:n.fn,options:[e,t]}},Sm=(e,t)=>({fn:dm(e).fn,options:[e,t]}),Cm=(e,t)=>{let n=sm(e);return{name:n.name,fn:n.fn,options:[e,t]}},wm=(e,t)=>{let n=cm(e);return{name:n.name,fn:n.fn,options:[e,t]}},Tm=(e,t)=>{let n=lm(e);return{name:n.name,fn:n.fn,options:[e,t]}},Em=(e,t)=>{let n=ym(e);return{name:n.name,fn:n.fn,options:[e,t]}},Dm=`Arrow`,Om=V.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,H.jsx)(Kl.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,H.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});Om.displayName=Dm;var km=Om,Am=`Popper`,[jm,Mm]=Jl(Am),[Nm,Pm]=jm(Am),Fm=e=>{let{__scopePopper:t,children:n}=e,[r,i]=V.useState(null);return(0,H.jsx)(Nm,{scope:t,anchor:r,onAnchorChange:i,children:n})};Fm.displayName=Am;var Im=`PopperAnchor`,Lm=V.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=Pm(Im,n),o=V.useRef(null),s=zl(t,o),c=V.useRef(null);return V.useEffect(()=>{let e=c.current;c.current=r?.current||o.current,e!==c.current&&a.onAnchorChange(c.current)}),r?null:(0,H.jsx)(Kl.div,{...i,ref:s})});Lm.displayName=Im;var Rm=`PopperContent`,[zm,Bm]=jm(Rm),Vm=V.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=Pm(Rm,n),[_,v]=V.useState(null),y=zl(t,e=>v(e)),[b,x]=V.useState(null),S=mf(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],ee=D.length>0,O={padding:E,boundary:D.filter(Gm),altBoundary:ee},{refs:k,floatingStyles:te,placement:ne,isPositioned:re,middlewareData:ie}=vm({strategy:`fixed`,placement:T,whileElementsMounted:(...e)=>im(...e,{animationFrame:p===`always`}),elements:{reference:g.anchor},middleware:[bm({mainAxis:i+w,alignmentAxis:o}),c&&xm({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?Sm():void 0,...O}),c&&Cm({...O}),wm({...O,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&&Em({element:b,padding:s}),Km({arrowWidth:C,arrowHeight:w}),f&&Tm({strategy:`referenceHidden`,...O})]}),[ae,oe]=qm(ne),se=fu(m);Zl(()=>{re&&se?.()},[re,se]);let ce=ie.arrow?.x,le=ie.arrow?.y,ue=ie.arrow?.centerOffset!==0,[de,fe]=V.useState();return Zl(()=>{_&&fe(window.getComputedStyle(_).zIndex)},[_]),(0,H.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,H.jsx)(zm,{scope:n,placedSide:ae,onArrowChange:x,arrowX:ce,arrowY:le,shouldHideArrow:ue,children:(0,H.jsx)(Kl.div,{"data-side":ae,"data-align":oe,...h,ref:y,style:{...h.style,animation:re?void 0:`none`}})})})});Vm.displayName=Rm;var Hm=`PopperArrow`,Um={top:`bottom`,right:`left`,bottom:`top`,left:`right`},Wm=V.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=Bm(Hm,n),a=Um[i.placedSide];return(0,H.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,H.jsx)(km,{...r,ref:t,style:{...r.style,display:`block`}})})});Wm.displayName=Hm;function Gm(e){return e!==null}var Km=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]=qm(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 qm(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var Jm=Fm,Ym=Lm,Xm=Vm,Zm=Wm,Qm=`rovingFocusGroup.onEntryFocus`,$m={bubbles:!1,cancelable:!0},eh=`RovingFocusGroup`,[th,nh,rh]=Xl(eh),[ih,ah]=Jl(eh,[rh]),[oh,sh]=ih(eh),ch=V.forwardRef((e,t)=>(0,H.jsx)(th.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,H.jsx)(th.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,H.jsx)(lh,{...e,ref:t})})}));ch.displayName=eh;var lh=V.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=V.useRef(null),p=zl(t,f),m=du(a),[h,g]=$l({prop:o,defaultProp:s??null,onChange:c,caller:eh}),[_,v]=V.useState(!1),y=fu(l),b=nh(n),x=V.useRef(!1),[S,C]=V.useState(0);return V.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(Qm,y),()=>e.removeEventListener(Qm,y)},[y]),(0,H.jsx)(oh,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:V.useCallback(e=>g(e),[g]),onItemShiftTab:V.useCallback(()=>v(!0),[]),onFocusableItemAdd:V.useCallback(()=>C(e=>e+1),[]),onFocusableItemRemove:V.useCallback(()=>C(e=>e-1),[]),children:(0,H.jsx)(Kl.div,{tabIndex:_||S===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:W(e.onMouseDown,()=>{x.current=!0}),onFocus:W(e.onFocus,e=>{let t=!x.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(Qm,$m);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=b().filter(e=>e.focusable);hh([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}x.current=!1}),onBlur:W(e.onBlur,()=>v(!1))})})}),uh=`RovingFocusGroupItem`,dh=V.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=lu(),l=a||c,u=sh(uh,n),d=u.currentTabStopId===l,f=nh(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u;return V.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),(0,H.jsx)(th.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,H.jsx)(Kl.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:W(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:W(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:W(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=mh(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?gh(n,r+1):n.slice(r+1)}setTimeout(()=>hh(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})});dh.displayName=uh;var fh={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function ph(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function mh(e,t,n){let r=ph(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return fh[r]}function hh(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function gh(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var _h=ch,vh=dh,yh=[`Enter`,` `],bh=[`ArrowDown`,`PageUp`,`Home`],xh=[`ArrowUp`,`PageDown`,`End`],Sh=[...bh,...xh],Ch={ltr:[...yh,`ArrowRight`],rtl:[...yh,`ArrowLeft`]},wh={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},Th=`Menu`,[Eh,Dh,Oh]=Xl(Th),[kh,Ah]=Jl(Th,[Oh,Mm,ah]),jh=Mm(),Mh=ah(),[Nh,Ph]=kh(Th),[Fh,Ih]=kh(Th),Lh=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=jh(t),[c,l]=V.useState(null),u=V.useRef(!1),d=fu(a),f=du(i);return V.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,H.jsx)(Jm,{...s,children:(0,H.jsx)(Nh,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,H.jsx)(Fh,{scope:t,onClose:V.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};Lh.displayName=Th;var Rh=`MenuAnchor`,zh=V.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=jh(n);return(0,H.jsx)(Ym,{...i,...r,ref:t})});zh.displayName=Rh;var Bh=`MenuPortal`,[Vh,Hh]=kh(Bh,{forceMount:void 0}),Uh=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=Ph(Bh,t);return(0,H.jsx)(Vh,{scope:t,forceMount:n,children:(0,H.jsx)(ru,{present:n||a.open,children:(0,H.jsx)(Wu,{asChild:!0,container:i,children:r})})})};Uh.displayName=Bh;var Wh=`MenuContent`,[Gh,Kh]=kh(Wh),qh=V.forwardRef((e,t)=>{let n=Hh(Wh,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=Ph(Wh,e.__scopeMenu),o=Ih(Wh,e.__scopeMenu);return(0,H.jsx)(Eh.Provider,{scope:e.__scopeMenu,children:(0,H.jsx)(ru,{present:r||a.open,children:(0,H.jsx)(Eh.Slot,{scope:e.__scopeMenu,children:o.modal?(0,H.jsx)(Jh,{...i,ref:t}):(0,H.jsx)(Yh,{...i,ref:t})})})})}),Jh=V.forwardRef((e,t)=>{let n=Ph(Wh,e.__scopeMenu),r=V.useRef(null),i=zl(t,r);return V.useEffect(()=>{let e=r.current;if(e)return df(e)},[]),(0,H.jsx)(Zh,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:W(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Yh=V.forwardRef((e,t)=>{let n=Ph(Wh,e.__scopeMenu);return(0,H.jsx)(Zh,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Xh=Bl(`MenuContent.ScrollLock`),Zh=V.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=Ph(Wh,n),_=Ih(Wh,n),v=jh(n),y=Mh(n),b=Dh(n),[x,S]=V.useState(null),C=V.useRef(null),w=zl(t,C,g.onContentChange),T=V.useRef(0),E=V.useRef(``),D=V.useRef(0),ee=V.useRef(null),O=V.useRef(`right`),k=V.useRef(0),te=m?tf:V.Fragment,ne=m?{as:Xh,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=Fg(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())};V.useEffect(()=>()=>window.clearTimeout(T.current),[]),Ku();let ie=V.useCallback(e=>O.current===ee.current?.side&&Lg(e,ee.current?.area),[]);return(0,H.jsx)(Gh,{scope:n,searchRef:E,onItemEnter:V.useCallback(e=>{ie(e)&&e.preventDefault()},[ie]),onItemLeave:V.useCallback(e=>{ie(e)||(C.current?.focus(),S(null))},[ie]),onTriggerLeave:V.useCallback(e=>{ie(e)&&e.preventDefault()},[ie]),pointerGraceTimerRef:D,onPointerGraceIntentChange:V.useCallback(e=>{ee.current=e},[]),children:(0,H.jsx)(te,{...ne,children:(0,H.jsx)(ju,{asChild:!0,trapped:i,onMountAutoFocus:W(a,e=>{e.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,H.jsx)(bu,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,H.jsx)(_h,{asChild:!0,...y,dir:_.dir,orientation:`vertical`,loop:r,currentTabStopId:x,onCurrentTabStopIdChange:S,onEntryFocus:W(c,e=>{_.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,H.jsx)(Xm,{role:`menu`,"aria-orientation":`vertical`,"data-state":Ag(g.open),"data-radix-menu-content":``,dir:_.dir,...v,...h,ref:w,style:{outline:`none`,...h.style},onKeyDown:W(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||!Sh.includes(e.key))return;e.preventDefault();let a=b().filter(e=>!e.disabled).map(e=>e.ref.current);xh.includes(e.key)&&a.reverse(),Ng(a)}),onBlur:W(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(T.current),E.current=``)}),onPointerMove:W(e.onPointerMove,Rg(e=>{let t=e.target,n=k.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>k.current?`right`:`left`;O.current=t,k.current=e.clientX}}))})})})})})})});qh.displayName=Wh;var Qh=`MenuGroup`,$h=V.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,H.jsx)(Kl.div,{role:`group`,...r,ref:t})});$h.displayName=Qh;var eg=`MenuLabel`,tg=V.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,H.jsx)(Kl.div,{...r,ref:t})});tg.displayName=eg;var ng=`MenuItem`,rg=`menu.itemSelect`,ig=V.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,a=V.useRef(null),o=Ih(ng,e.__scopeMenu),s=Kh(ng,e.__scopeMenu),c=zl(t,a),l=V.useRef(!1),u=()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(rg,{bubbles:!0,cancelable:!0});e.addEventListener(rg,e=>r?.(e),{once:!0}),ql(e,t),t.defaultPrevented?l.current=!1:o.onClose()}};return(0,H.jsx)(ag,{...i,ref:c,disabled:n,onClick:W(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:W(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:W(e.onKeyDown,e=>{let t=s.searchRef.current!==``;n||t&&e.key===` `||yh.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});ig.displayName=ng;var ag=V.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=Kh(ng,n),s=Mh(n),c=V.useRef(null),l=zl(t,c),[u,d]=V.useState(!1),[f,p]=V.useState(``);return V.useEffect(()=>{let e=c.current;e&&p((e.textContent??``).trim())},[a.children]),(0,H.jsx)(Eh.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,H.jsx)(vh,{asChild:!0,...s,focusable:!r,children:(0,H.jsx)(Kl.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:W(e.onPointerMove,Rg(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:W(e.onPointerLeave,Rg(e=>o.onItemLeave(e))),onFocus:W(e.onFocus,()=>d(!0)),onBlur:W(e.onBlur,()=>d(!1))})})})}),og=`MenuCheckboxItem`,sg=V.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,H.jsx)(hg,{scope:e.__scopeMenu,checked:n,children:(0,H.jsx)(ig,{role:`menuitemcheckbox`,"aria-checked":jg(n)?`mixed`:n,...i,ref:t,"data-state":Mg(n),onSelect:W(i.onSelect,()=>r?.(jg(n)?!0:!n),{checkForDefaultPrevented:!1})})})});sg.displayName=og;var cg=`MenuRadioGroup`,[lg,ug]=kh(cg,{value:void 0,onValueChange:()=>{}}),dg=V.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,a=fu(r);return(0,H.jsx)(lg,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,H.jsx)($h,{...i,ref:t})})});dg.displayName=cg;var fg=`MenuRadioItem`,pg=V.forwardRef((e,t)=>{let{value:n,...r}=e,i=ug(fg,e.__scopeMenu),a=n===i.value;return(0,H.jsx)(hg,{scope:e.__scopeMenu,checked:a,children:(0,H.jsx)(ig,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":Mg(a),onSelect:W(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});pg.displayName=fg;var mg=`MenuItemIndicator`,[hg,gg]=kh(mg,{checked:!1}),_g=V.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,a=gg(mg,n);return(0,H.jsx)(ru,{present:r||jg(a.checked)||a.checked===!0,children:(0,H.jsx)(Kl.span,{...i,ref:t,"data-state":Mg(a.checked)})})});_g.displayName=mg;var vg=`MenuSeparator`,yg=V.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,H.jsx)(Kl.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})});yg.displayName=vg;var bg=`MenuArrow`,xg=V.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=jh(n);return(0,H.jsx)(Zm,{...i,...r,ref:t})});xg.displayName=bg;var Sg=`MenuSub`,[Cg,wg]=kh(Sg),Tg=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=Ph(Sg,t),o=jh(t),[s,c]=V.useState(null),[l,u]=V.useState(null),d=fu(i);return V.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),(0,H.jsx)(Jm,{...o,children:(0,H.jsx)(Nh,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u,children:(0,H.jsx)(Cg,{scope:t,contentId:lu(),triggerId:lu(),trigger:s,onTriggerChange:c,children:n})})})};Tg.displayName=Sg;var Eg=`MenuSubTrigger`,Dg=V.forwardRef((e,t)=>{let n=Ph(Eg,e.__scopeMenu),r=Ih(Eg,e.__scopeMenu),i=wg(Eg,e.__scopeMenu),a=Kh(Eg,e.__scopeMenu),o=V.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:c}=a,l={__scopeMenu:e.__scopeMenu},u=V.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return V.useEffect(()=>u,[u]),V.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),c(null)}},[s,c]),(0,H.jsx)(zh,{asChild:!0,...l,children:(0,H.jsx)(ag,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":i.contentId,"data-state":Ag(n.open),...e,ref:Rl(t,i.onTriggerChange),onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:W(e.onPointerMove,Rg(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:W(e.onPointerLeave,Rg(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:W(e.onKeyDown,t=>{let i=a.searchRef.current!==``;e.disabled||i&&t.key===` `||Ch[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});Dg.displayName=Eg;var Og=`MenuSubContent`,kg=V.forwardRef((e,t)=>{let n=Hh(Wh,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=Ph(Wh,e.__scopeMenu),o=Ih(Wh,e.__scopeMenu),s=wg(Og,e.__scopeMenu),c=V.useRef(null),l=zl(t,c);return(0,H.jsx)(Eh.Provider,{scope:e.__scopeMenu,children:(0,H.jsx)(ru,{present:r||a.open,children:(0,H.jsx)(Eh.Slot,{scope:e.__scopeMenu,children:(0,H.jsx)(Zh,{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:W(e.onFocusOutside,e=>{e.target!==s.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:W(e.onEscapeKeyDown,e=>{o.onClose(),e.preventDefault()}),onKeyDown:W(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=wh[o.dir].includes(e.key);t&&n&&(a.onOpenChange(!1),s.trigger?.focus(),e.preventDefault())})})})})})});kg.displayName=Og;function Ag(e){return e?`open`:`closed`}function jg(e){return e===`indeterminate`}function Mg(e){return jg(e)?`indeterminate`:e?`checked`:`unchecked`}function Ng(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Pg(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function Fg(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=Pg(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 Ig(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 Lg(e,t){return t?Ig({x:e.clientX,y:e.clientY},t):!1}function Rg(e){return t=>t.pointerType===`mouse`?e(t):void 0}var zg=Lh,Bg=zh,Vg=Uh,Hg=qh,Ug=$h,Wg=tg,Gg=ig,Kg=sg,qg=dg,Jg=pg,Yg=_g,Xg=yg,Zg=xg,Qg=Tg,$g=Dg,e_=kg,t_=`ContextMenu`,[n_,r_]=Jl(t_,[Ah]),i_=Ah(),[a_,o_]=n_(t_),s_=e=>{let{__scopeContextMenu:t,children:n,onOpenChange:r,dir:i,modal:a=!0}=e,[o,s]=V.useState(!1),c=i_(t),l=fu(r),u=V.useCallback(e=>{s(e),l(e)},[l]);return(0,H.jsx)(a_,{scope:t,open:o,onOpenChange:u,modal:a,children:(0,H.jsx)(zg,{...c,dir:i,open:o,onOpenChange:u,modal:a,children:n})})};s_.displayName=t_;var c_=`ContextMenuTrigger`,l_=V.forwardRef((e,t)=>{let{__scopeContextMenu:n,disabled:r=!1,...i}=e,a=o_(c_,n),o=i_(n),s=V.useRef({x:0,y:0}),c=V.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...s.current})}),l=V.useRef(0),u=V.useCallback(()=>window.clearTimeout(l.current),[]),d=e=>{s.current={x:e.clientX,y:e.clientY},a.onOpenChange(!0)};return V.useEffect(()=>u,[u]),V.useEffect(()=>void(r&&u()),[r,u]),(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Bg,{...o,virtualRef:c}),(0,H.jsx)(Kl.span,{"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,...i,ref:t,style:{WebkitTouchCallout:`none`,...e.style},onContextMenu:r?e.onContextMenu:W(e.onContextMenu,e=>{u(),d(e),e.preventDefault()}),onPointerDown:r?e.onPointerDown:W(e.onPointerDown,I_(e=>{u(),l.current=window.setTimeout(()=>d(e),700)})),onPointerMove:r?e.onPointerMove:W(e.onPointerMove,I_(u)),onPointerCancel:r?e.onPointerCancel:W(e.onPointerCancel,I_(u)),onPointerUp:r?e.onPointerUp:W(e.onPointerUp,I_(u))})]})});l_.displayName=c_;var u_=`ContextMenuPortal`,d_=e=>{let{__scopeContextMenu:t,...n}=e,r=i_(t);return(0,H.jsx)(Vg,{...r,...n})};d_.displayName=u_;var f_=`ContextMenuContent`,p_=V.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=o_(f_,n),a=i_(n),o=V.useRef(!1);return(0,H.jsx)(Hg,{...a,...r,ref:t,side:`right`,sideOffset:2,align:`start`,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),!t.defaultPrevented&&o.current&&t.preventDefault(),o.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),!t.defaultPrevented&&!i.modal&&(o.current=!0)},style:{...e.style,"--radix-context-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-context-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-context-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-context-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-context-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});p_.displayName=f_;var m_=`ContextMenuGroup`,h_=V.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=i_(n);return(0,H.jsx)(Ug,{...i,...r,ref:t})});h_.displayName=m_;var g_=`ContextMenuLabel`,__=V.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=i_(n);return(0,H.jsx)(Wg,{...i,...r,ref:t})});__.displayName=g_;var v_=`ContextMenuItem`,y_=V.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=i_(n);return(0,H.jsx)(Gg,{...i,...r,ref:t})});y_.displayName=v_;var b_=`ContextMenuCheckboxItem`,x_=V.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=i_(n);return(0,H.jsx)(Kg,{...i,...r,ref:t})});x_.displayName=b_;var S_=`ContextMenuRadioGroup`,C_=V.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=i_(n);return(0,H.jsx)(qg,{...i,...r,ref:t})});C_.displayName=S_;var w_=`ContextMenuRadioItem`,T_=V.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=i_(n);return(0,H.jsx)(Jg,{...i,...r,ref:t})});T_.displayName=w_;var E_=`ContextMenuItemIndicator`,D_=V.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=i_(n);return(0,H.jsx)(Yg,{...i,...r,ref:t})});D_.displayName=E_;var O_=`ContextMenuSeparator`,k_=V.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=i_(n);return(0,H.jsx)(Xg,{...i,...r,ref:t})});k_.displayName=O_;var A_=`ContextMenuArrow`,j_=V.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=i_(n);return(0,H.jsx)(Zg,{...i,...r,ref:t})});j_.displayName=A_;var M_=`ContextMenuSubTrigger`,N_=V.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=i_(n);return(0,H.jsx)($g,{...i,...r,ref:t})});N_.displayName=M_;var P_=`ContextMenuSubContent`,F_=V.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=i_(n);return(0,H.jsx)(e_,{...i,...r,ref:t,style:{...e.style,"--radix-context-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-context-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-context-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-context-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-context-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});F_.displayName=P_;function I_(e){return t=>t.pointerType===`mouse`?void 0:e(t)}var L_=s_,R_=l_,z_=d_,B_=p_,V_=y_,H_=`DropdownMenu`,[U_,W_]=Jl(H_,[Ah]),G_=Ah(),[K_,q_]=U_(H_),J_=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=G_(t),l=V.useRef(null),[u,d]=$l({prop:i,defaultProp:a??!1,onChange:o,caller:H_});return(0,H.jsx)(K_,{scope:t,triggerId:lu(),triggerRef:l,contentId:lu(),open:u,onOpenChange:d,onOpenToggle:V.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,H.jsx)(zg,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};J_.displayName=H_;var Y_=`DropdownMenuTrigger`,X_=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=q_(Y_,n),o=G_(n);return(0,H.jsx)(Bg,{asChild:!0,...o,children:(0,H.jsx)(Kl.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:Rl(t,a.triggerRef),onPointerDown:W(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:W(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})});X_.displayName=Y_;var Z_=`DropdownMenuContent`,Q_=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=q_(Z_,n),a=G_(n),o=V.useRef(!1);return(0,H.jsx)(Hg,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:W(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:W(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)`}})});Q_.displayName=Z_;var $_=`DropdownMenuGroup`,ev=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=G_(n);return(0,H.jsx)(Ug,{...i,...r,ref:t})});ev.displayName=$_;var tv=`DropdownMenuLabel`,nv=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=G_(n);return(0,H.jsx)(Wg,{...i,...r,ref:t})});nv.displayName=tv;var rv=`DropdownMenuItem`,iv=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=G_(n);return(0,H.jsx)(Gg,{...i,...r,ref:t})});iv.displayName=rv;var av=`DropdownMenuCheckboxItem`,ov=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=G_(n);return(0,H.jsx)(Kg,{...i,...r,ref:t})});ov.displayName=av;var sv=`DropdownMenuRadioGroup`,cv=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=G_(n);return(0,H.jsx)(qg,{...i,...r,ref:t})});cv.displayName=sv;var lv=`DropdownMenuRadioItem`,uv=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=G_(n);return(0,H.jsx)(Jg,{...i,...r,ref:t})});uv.displayName=lv;var dv=`DropdownMenuItemIndicator`,fv=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=G_(n);return(0,H.jsx)(Yg,{...i,...r,ref:t})});fv.displayName=dv;var pv=`DropdownMenuSeparator`,mv=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=G_(n);return(0,H.jsx)(Xg,{...i,...r,ref:t})});mv.displayName=pv;var hv=`DropdownMenuArrow`,gv=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=G_(n);return(0,H.jsx)(Zg,{...i,...r,ref:t})});gv.displayName=hv;var _v=e=>{let{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:a}=e,o=G_(t),[s,c]=$l({prop:r,defaultProp:a??!1,onChange:i,caller:`DropdownMenuSub`});return(0,H.jsx)(Qg,{...o,open:s,onOpenChange:c,children:n})},vv=`DropdownMenuSubTrigger`,yv=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=G_(n);return(0,H.jsx)($g,{...i,...r,ref:t})});yv.displayName=vv;var bv=`DropdownMenuSubContent`,xv=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=G_(n);return(0,H.jsx)(e_,{...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)`}})});xv.displayName=bv;var Sv=J_,Cv=X_,wv=Q_,Tv=iv,Ev=_v,Dv=yv,Ov=xv,kv=`Popover`,[Av,jv]=Jl(kv,[Mm]),Mv=Mm(),[Nv,Pv]=Av(kv),Fv=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=Mv(t),c=V.useRef(null),[l,u]=V.useState(!1),[d,f]=$l({prop:r,defaultProp:i??!1,onChange:a,caller:kv});return(0,H.jsx)(Jm,{...s,children:(0,H.jsx)(Nv,{scope:t,contentId:lu(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:V.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:V.useCallback(()=>u(!0),[]),onCustomAnchorRemove:V.useCallback(()=>u(!1),[]),modal:o,children:n})})};Fv.displayName=kv;var Iv=`PopoverAnchor`,Lv=V.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Pv(Iv,n),a=Mv(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return V.useEffect(()=>(o(),()=>s()),[o,s]),(0,H.jsx)(Ym,{...a,...r,ref:t})});Lv.displayName=Iv;var Rv=`PopoverTrigger`,zv=V.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Pv(Rv,n),a=Mv(n),o=zl(t,i.triggerRef),s=(0,H.jsx)(Kl.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":ey(i.open),...r,ref:o,onClick:W(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,H.jsx)(Ym,{asChild:!0,...a,children:s})});zv.displayName=Rv;var Bv=`PopoverPortal`,[Vv,Hv]=Av(Bv,{forceMount:void 0}),Uv=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=Pv(Bv,t);return(0,H.jsx)(Vv,{scope:t,forceMount:n,children:(0,H.jsx)(ru,{present:n||a.open,children:(0,H.jsx)(Wu,{asChild:!0,container:i,children:r})})})};Uv.displayName=Bv;var Wv=`PopoverContent`,Gv=V.forwardRef((e,t)=>{let n=Hv(Wv,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=Pv(Wv,e.__scopePopover);return(0,H.jsx)(ru,{present:r||a.open,children:a.modal?(0,H.jsx)(qv,{...i,ref:t}):(0,H.jsx)(Jv,{...i,ref:t})})});Gv.displayName=Wv;var Kv=Bl(`PopoverContent.RemoveScroll`),qv=V.forwardRef((e,t)=>{let n=Pv(Wv,e.__scopePopover),r=V.useRef(null),i=zl(t,r),a=V.useRef(!1);return V.useEffect(()=>{let e=r.current;if(e)return df(e)},[]),(0,H.jsx)(tf,{as:Kv,allowPinchZoom:!0,children:(0,H.jsx)(Yv,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:W(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:W(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:W(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),Jv=V.forwardRef((e,t)=>{let n=Pv(Wv,e.__scopePopover),r=V.useRef(!1),i=V.useRef(!1);return(0,H.jsx)(Yv,{...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()}})}),Yv=V.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=Pv(Wv,n),p=Mv(n);return Ku(),(0,H.jsx)(ju,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,H.jsx)(bu,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),children:(0,H.jsx)(Xm,{"data-state":ey(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)`}})})})}),Xv=`PopoverClose`,Zv=V.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Pv(Xv,n);return(0,H.jsx)(Kl.button,{type:`button`,...r,ref:t,onClick:W(e.onClick,()=>i.onOpenChange(!1))})});Zv.displayName=Xv;var Qv=`PopoverArrow`,$v=V.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Mv(n);return(0,H.jsx)(Zm,{...i,...r,ref:t})});$v.displayName=Qv;function ey(e){return e?`open`:`closed`}var ty=Fv,ny=zv,ry=Uv,iy=Gv,ay=Zv,oy=$v,sy=`Tabs`,[cy,ly]=Jl(sy,[ah]),uy=ah(),[dy,fy]=cy(sy),py=V.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o=`horizontal`,dir:s,activationMode:c=`automatic`,...l}=e,u=du(s),[d,f]=$l({prop:r,onChange:i,defaultProp:a??``,caller:sy});return(0,H.jsx)(dy,{scope:n,baseId:lu(),value:d,onValueChange:f,orientation:o,dir:u,activationMode:c,children:(0,H.jsx)(Kl.div,{dir:u,"data-orientation":o,...l,ref:t})})});py.displayName=sy;var my=`TabsList`,hy=V.forwardRef((e,t)=>{let{__scopeTabs:n,loop:r=!0,...i}=e,a=fy(my,n),o=uy(n);return(0,H.jsx)(_h,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:r,children:(0,H.jsx)(Kl.div,{role:`tablist`,"aria-orientation":a.orientation,...i,ref:t})})});hy.displayName=my;var gy=`TabsTrigger`,_y=V.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,disabled:i=!1,...a}=e,o=fy(gy,n),s=uy(n),c=by(o.baseId,r),l=xy(o.baseId,r),u=r===o.value;return(0,H.jsx)(vh,{asChild:!0,...s,focusable:!i,active:u,children:(0,H.jsx)(Kl.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:W(e.onMouseDown,e=>{!i&&e.button===0&&e.ctrlKey===!1?o.onValueChange(r):e.preventDefault()}),onKeyDown:W(e.onKeyDown,e=>{[` `,`Enter`].includes(e.key)&&o.onValueChange(r)}),onFocus:W(e.onFocus,()=>{let e=o.activationMode!==`manual`;!u&&!i&&e&&o.onValueChange(r)})})})});_y.displayName=gy;var vy=`TabsContent`,yy=V.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,forceMount:i,children:a,...o}=e,s=fy(vy,n),c=by(s.baseId,r),l=xy(s.baseId,r),u=r===s.value,d=V.useRef(u);return V.useEffect(()=>{let e=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,H.jsx)(ru,{present:i||u,children:({present:n})=>(0,H.jsx)(Kl.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})})});yy.displayName=vy;function by(e,t){return`${e}-trigger-${t}`}function xy(e,t){return`${e}-content-${t}`}var Sy=py,Cy=hy,wy=_y,Ty=yy,Ey=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 Dy(e,t){return(e[0]-t[0])**2+(e[1]-t[1])**2}function Oy(e,t,n){let r=Dy(t,n);if(r===0)return Dy(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)),Dy(e,ky(t,n,i))}function ky(e,t,n){return[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n]}function Ay(e,t){return jy(e,0,e.length,t)}function jy(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=Oy(e[r],o,s);t>c&&(c=t,l=r)}return Math.sqrt(c)>r?(jy(e,t,l+1,r,a),jy(e,l,n,r,a)):(a.length||a.push(o),a.push(s)),a}function My(e,t,n,r=e=>e){return e*r(.5-t*(.5-n))}function Ny(e){return[-e[0],-e[1]]}function Py(e,t){return[e[0]+t[0],e[1]+t[1]]}function Fy(e,t){return[e[0]-t[0],e[1]-t[1]]}function Iy(e,t){return[e[0]*t,e[1]*t]}function Ly(e,t){return[e[0]/t,e[1]/t]}function Ry(e){return[e[1],-e[0]]}function zy(e,t){return e[0]*t[0]+e[1]*t[1]}function By(e,t){return e[0]===t[0]&&e[1]===t[1]}function Vy(e){return Math.hypot(e[0],e[1])}function Hy(e){return e[0]*e[0]+e[1]*e[1]}function Uy(e,t){return Hy(Fy(e,t))}function Wy(e){return Ly(e,Vy(e))}function Gy(e,t){return Math.hypot(e[1]-t[1],e[0]-t[0])}function Ky(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 qy(e,t,n){return Py(e,Iy(Fy(t,e),n))}function Jy(e,t,n){return Py(e,Iy(t,n))}var{min:Yy,PI:Xy}=Math,Zy=.275,Qy=Xy+1e-4;function $y(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=Yy(1,t.distance/n);r=Yy(1,e+(Yy(1,1-i)-e)*(i*Zy))}return(e+r)/2},e[0].pressure),x=My(n,i,e[e.length-1].pressure,o),S,C=e[0].vector,w=e[0].point,T=w,E=w,D=T,ee=!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=Yy(1,l/n),t=Yy(1,1-e);r=Yy(1,b+(t-b)*(e*Zy))}x=My(n,i,r,o)}else x=n/2;S===void 0&&(S=x);let f=u<h?d(u/h):1,O=m-u<g?p((m-u)/g):1;x=Math.max(.01,x*Math.min(f,O));let k=(t<e.length-1?e[t+1]:e[t]).vector,te=t<e.length-1?zy(c,k):1,ne=zy(c,C)<0&&!ee,re=te!==null&&te<0;if(ne||re){let e=Iy(Ry(C),x);for(let t=0;t<=1;t+=.07692307692307693)E=Ky(Fy(s,e),s,Qy*t),v.push(E),D=Ky(Py(s,e),s,Qy*-t),y.push(D);w=E,T=D,re&&(ee=!0);continue}if(ee=!1,t===e.length-1){let e=Iy(Ry(c),x);v.push(Fy(s,e)),y.push(Py(s,e));continue}let ie=Iy(Ry(qy(k,c,te)),x);E=Fy(s,ie),(t<=1||Uy(w,E)>_)&&(v.push(E),w=E),D=Py(s,ie),(t<=1||Uy(T,D)>_)&&(y.push(D),T=D),b=r,C=c}let O=e[0].point.slice(0,2),k=e.length>1?e[e.length-1].point.slice(0,2):Py(e[0].point,[1,1]),te=[],ne=[];if(e.length===1){if(!(h||g)||l){let e=Jy(O,Wy(Ry(Fy(O,k))),-(S||x)),t=[];for(let n=1/13,r=n;r<=1;r+=n)t.push(Ky(e,O,Qy*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=Ky(y[0],O,Qy*t);te.push(e)}else{let e=Fy(v[0],y[0]),t=Iy(e,.5),n=Iy(e,.51);te.push(Fy(O,t),Fy(O,n),Py(O,n),Py(O,t))}}let t=Ry(Ny(e[e.length-1].vector));if(g||h&&e.length===1)ne.push(k);else if(f){let e=Jy(k,t,x);for(let t=1/29,n=t;n<1;n+=t)ne.push(Ky(e,k,Qy*3*n))}else ne.push(Py(k,Iy(t,x)),Py(k,Iy(t,x*.99)),Fy(k,Iy(t,x*.99)),Fy(k,Iy(t,x)))}return v.concat(ne,y.reverse(),te)}function eb(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(qy(o[0],e,t/4))}o.length===1&&(o=[...o,[...Py(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):qy(u.point,o[e],a);if(By(u.point,t))continue;let n=Gy(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:Wy(Fy(u.point,t)),distance:n,runningLength:l},s.push(u)}return s[0].vector=s[1]?.vector||[0,0],s}function tb(e,t={}){return $y(eb(e,t),t)}var nb=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},rb=e=>e?nb(e):nb,ib=t((e=>{var t=Lc(),n=pf();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}})),ab=e(t(((e,t)=>{t.exports=ib()}))(),1),{useDebugValue:ob}=V.default,{useSyncExternalStoreWithSelector:sb}=ab.default,cb=e=>e;function lb(e,t=cb,n){let r=sb(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return ob(r),r}var ub=e=>{let t=typeof e==`function`?rb(e):e,n=(e,n)=>lb(t,e,n);return Object.assign(n,t),n},db=e=>e?ub(e):ub,fb,pb=typeof window<`u`&&((fb=window.document)!=null&&fb.createElement||window.navigator?.product===`ReactNative`)?V.useLayoutEffect:V.useEffect;function mb(){let e=db(e=>({current:[],version:0,set:e}));return{In:({children:t})=>{let n=e(e=>e.set),r=e(e=>e.version);return pb(()=>{n(e=>({version:e.version+1}))},[]),pb(()=>(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 V.createElement(V.Fragment,null,t)}}}var hb=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),gb=Pl(),{useAtom:_b,useSetAtom:vb,useAtomValue:yb,useStore:bb}=gb,xb=gb.Provider,Sb=_l(),Cb=Fc({"./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-SJ2YIMFF-CJBL3nkq.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)}),wb=85,Tb={code:`en`,label:`English`},Eb=[Tb,...[{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=>Bc[e.code]>=wb).sort((e,t)=>e.label>t.label?1:-1)],Db=`__test__`;ht()&&Eb.unshift({code:Db,label:`test language`},{code:`${Db}.rtl`,label:`‪test language (rtl)‬`,rtl:!0});var Ob=Tb,kb={},Ab=async e=>{if(Ob=e,document.documentElement.dir=Ob.rtl?`rtl`:`ltr`,document.documentElement.lang=Ob.code,e.code.startsWith(Db))kb={};else try{kb=await Cb(`./locales/${Ob.code}.json`)}catch(t){console.error(`Failed to load language ${e.code}:`,t.message),kb=zc}Sb.set(Nb,e.code)},jb=()=>Ob,Mb=(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},G=(e,t,n)=>{if(Ob.code.startsWith(Db))return`\u202A[[${t?`${e}(${JSON.stringify(t).slice(1,-1)})`:e}]]\u202C`;let r=e.split(`.`),i=Mb(kb,r)||Mb(zc,r)||n;if(i===void 0){let t=`Can't find translation for ${e}`;if(nn.PROD)return console.warn(t),``;throw Error(t)}if(t)for(let e in t)i=i.replace(`{{${e}}}`,String(t[e]));return i},Nb=Yc(Tb.code),Pb=()=>({t:G,langCode:yb(Nb)}),Fb=e=>`var(--icon-fill-color)`,Ib=e=>e===N.LIGHT?`#fff`:`#1e1e1e`,K=(e,t=512)=>{let{width:n=512,height:r=n,mirror:i,style:a,...o}=typeof t==`number`?{width:t}:t;return(0,H.jsx)(`svg`,{"aria-hidden":`true`,focusable:`false`,role:`img`,viewBox:`0 0 ${n} ${r}`,className:U({"rtl-mirror":i}),style:a,...o,children:typeof e==`string`?(0,H.jsx)(`path`,{fill:`currentColor`,d:e}):e})},q={width:24,height:24,fill:`none`,strokeWidth:2,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`},J={width:20,height:20,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`},Lb={width:40,height:20};K((0,H.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`rect`,{x:3,y:8,width:18,height:4,rx:1}),(0,H.jsx)(`line`,{x1:12,y1:8,x2:12,y2:21}),(0,H.jsx)(`path`,{d:`M19 12v7a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-7`}),(0,H.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`})]}),q);var Rb=K((0,H.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M3 19a9 9 0 0 1 9 0a9 9 0 0 1 9 0`}),(0,H.jsx)(`path`,{d:`M3 6a9 9 0 0 1 9 0a9 9 0 0 1 9 0`}),(0,H.jsx)(`line`,{x1:`3`,y1:`6`,x2:`3`,y2:`19`}),(0,H.jsx)(`line`,{x1:`12`,y1:`6`,x2:`12`,y2:`19`}),(0,H.jsx)(`line`,{x1:`21`,y1:`6`,x2:`21`,y2:`19`})]}),q),zb=K((0,H.jsxs)(`svg`,{strokeWidth:`1.5`,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`line`,{x1:`12`,y1:`5`,x2:`12`,y2:`19`}),(0,H.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`})]}),q),Bb=K((0,H.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1`}),(0,H.jsx)(`circle`,{cx:`12`,cy:`19`,r:`1`}),(0,H.jsx)(`circle`,{cx:`12`,cy:`5`,r:`1`})]}),q),Vb=K((0,H.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M5 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`}),(0,H.jsx)(`path`,{d:`M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`}),(0,H.jsx)(`path`,{d:`M19 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`})]}),q),Hb=K((0,H.jsxs)(`svg`,{strokeWidth:`1.5`,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M9 4v6l-2 4v2h10v-2l-2 -4v-6`}),(0,H.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12`,y2:`21`}),(0,H.jsx)(`line`,{x1:`8`,y1:`4`,x2:`16`,y2:`4`})]}),q),Ub=K((0,H.jsxs)(`g`,{strokeWidth:1.25,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M12 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,H.jsx)(`path`,{d:`M19 8m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,H.jsx)(`path`,{d:`M5 11m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,H.jsx)(`path`,{d:`M15 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,H.jsx)(`path`,{d:`M6.5 9.5l3.5 -3`}),(0,H.jsx)(`path`,{d:`M14 5.5l3 1.5`}),(0,H.jsx)(`path`,{d:`M18.5 10l-2.5 7`}),(0,H.jsx)(`path`,{d:`M13.5 17.5l-7 -5`})]}),q),Wb=K((0,H.jsxs)(`g`,{children:[(0,H.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,H.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,H.jsx)(`mask`,{id:`UnlockedIcon`,style:{maskType:`alpha`},maskUnits:`userSpaceOnUse`,x:6,y:1,width:9,height:9,children:(0,H.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,H.jsx)(`g`,{mask:`url(#UnlockedIcon)`,children:(0,H.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`})})]}),J),Gb=K((0,H.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,H.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,H.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,H.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`})]}),J),Kb=K((0,H.jsx)(`g`,{fill:`currentColor`,children:(0,H.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}),qb=K((0,H.jsxs)(H.Fragment,{children:[(0,H.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,H.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`m12.005 10.478 7.905 14.423L6 25.75l6.005-15.273Z`,fill:`currentColor`}),(0,H.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`}),Jb=K((0,H.jsxs)(H.Fragment,{children:[(0,H.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,H.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,H.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`}),Yb=K((0,H.jsxs)(H.Fragment,{children:[(0,H.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,H.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,H.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`});K((0,H.jsx)(`g`,{fill:`currentColor`,children:(0,H.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 Xb=K((0,H.jsxs)(`g`,{stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.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,H.jsx)(`path`,{d:`M13.5 13.5l4.5 4.5`})]}),{fill:`none`,width:22,height:22,strokeWidth:1.25}),Zb=K((0,H.jsxs)(`g`,{stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.5,children:[(0,H.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,H.jsx)(`path`,{d:`M5 15m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,H.jsx)(`path`,{d:`M5 17c0 1.42 .316 2.805 1 4`})]}),{fill:`none`,width:22,height:22,strokeWidth:1.25}),Qb=K((0,H.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`})]}),q),$b=K((0,H.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.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`})]}),q),ex=K((0,H.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`})]}),q),tx=K((0,H.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,H.jsx)(`line`,{x1:`15`,y1:`16`,x2:`19`,y2:`12`}),(0,H.jsx)(`line`,{x1:`15`,y1:`8`,x2:`19`,y2:`12`})]}),q),nx=K((0,H.jsx)(`path`,{d:`M4.167 10h11.666`,strokeWidth:`1.5`}),J),rx=K((0,H.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M20 17v-12c0 -1.121 -.879 -2 -2 -2s-2 .879 -2 2v12l2 2l2 -2z`}),(0,H.jsx)(`path`,{d:`M16 7h4`}),(0,H.jsx)(`path`,{d:`M18 19h-13a2 2 0 1 1 0 -4h4a2 2 0 1 0 0 -4h-3`})]}),q),ix=K((0,H.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,H.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,H.jsx)(`path`,{d:`m11.25 5.417 3.333 3.333`})]}),J),ax=K((0,H.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`line`,{x1:`4`,y1:`20`,x2:`7`,y2:`20`}),(0,H.jsx)(`line`,{x1:`14`,y1:`20`,x2:`21`,y2:`20`}),(0,H.jsx)(`line`,{x1:`6.9`,y1:`15`,x2:`13.8`,y2:`15`}),(0,H.jsx)(`line`,{x1:`10.2`,y1:`6.3`,x2:`16`,y2:`20`}),(0,H.jsx)(`polyline`,{points:`5 20 11 4 13 4 20 20`})]}),q),ox=K((0,H.jsxs)(`g`,{stroke:`currentColor`,strokeWidth:`1.5`,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M3 7v-2h13v2`}),(0,H.jsx)(`path`,{d:`M10 5v14`}),(0,H.jsx)(`path`,{d:`M12 19h-4`}),(0,H.jsx)(`path`,{d:`M15 13v-1h6v1`}),(0,H.jsx)(`path`,{d:`M18 12v7`}),(0,H.jsx)(`path`,{d:`M17 19h2`})]}),q),sx=K((0,H.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,H.jsx)(`path`,{d:`M12.5 6.667h.01`}),(0,H.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,H.jsx)(`path`,{d:`m3.333 12.5 3.334-3.333c.773-.745 1.726-.745 2.5 0l4.166 4.166`}),(0,H.jsx)(`path`,{d:`m11.667 11.667.833-.834c.774-.744 1.726-.744 2.5 0l1.667 1.667`})]}),J),cx=K((0,H.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.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,H.jsx)(`path`,{d:`M18 13.3l-6.3 -6.3`})]}),q),lx=K((0,H.jsx)(`path`,{strokeWidth:`1.25`,d:`M10 4.167v11.666M4.167 10h11.666`}),J),ux=K((0,H.jsx)(`path`,{d:`M5 10h10`,strokeWidth:`1.25`}),J),dx=K((0,H.jsxs)(`g`,{strokeWidth:1.25,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M21 21l-6 -6`}),(0,H.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,H.jsx)(`path`,{d:`M3 4v4h4`})]}),q),fx=K((0,H.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`}),J),px=K((0,H.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,H.jsx)(`polyline`,{points:`12 16 18 10 12 4`}),(0,H.jsx)(`polyline`,{points:`8 4 2 10 8 16`})]}),J),mx=K((0,H.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,H.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,H.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`})]}),J),hx=K((0,H.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`}),J),gx=K((0,H.jsx)(`g`,{stroke:`currentColor`,strokeLinejoin:`round`,children:(0,H.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`})}),{...J,strokeWidth:1.5}),_x=K((0,H.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`line`,{x1:`4`,y1:`6`,x2:`20`,y2:`6`}),(0,H.jsx)(`line`,{x1:`4`,y1:`12`,x2:`20`,y2:`12`}),(0,H.jsx)(`line`,{x1:`4`,y1:`18`,x2:`20`,y2:`18`})]}),q),vx=K((0,H.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`}),J),yx=K((0,H.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,H.jsx)(`line`,{x1:`12`,y1:`17`,x2:`12`,y2:`17.01`}),(0,H.jsx)(`path`,{d:`M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4`})]}),q),bx=K((0,H.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,H.jsx)(`line`,{x1:`12`,y1:`17`,x2:`12`,y2:`17.01`}),(0,H.jsx)(`path`,{d:`M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4`})]}),q),xx=K((0,H.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`}),J),Sx=K((0,H.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`}),J),Cx=K((0,H.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,H.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,H.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`})]}),J),wx=K((0,H.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M4 4l11.733 16h4.267l-11.733 -16z`}),(0,H.jsx)(`path`,{d:`M4 20l6.768 -6.768m2.46 -2.46l6.772 -6.772`})]}),q),Tx=K((0,H.jsx)(`polyline`,{fill:`none`,stroke:`currentColor`,points:`20 6 9 17 4 12`}),{width:24,height:24}),Ex=K((0,H.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,H.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,H.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`})]}),J),Dx=K(`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}),Ox=K(`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}),kx=K((0,H.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`}),J);K(`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}),K(`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 Ax=[`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`],jx=K((0,H.jsxs)(`g`,{strokeWidth:1.25,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),Ax.map(e=>(0,H.jsx)(`path`,{d:e},e))]}),q),Mx=K((0,H.jsx)(`g`,{strokeWidth:1.5,children:(0,H.jsx)(`path`,{d:`M6 18l12 -12`})}),q),Nx=K((0,H.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M15 8h.01`}),(0,H.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,H.jsx)(`path`,{d:`M4 15l4 -4c.928 -.893 2.072 -.893 3 0l4 4`}),(0,H.jsx)(`path`,{d:`M14 14l1 -1c.617 -.593 1.328 -.793 2.009 -.598`}),(0,H.jsx)(`path`,{d:`M19 16v6`}),(0,H.jsx)(`path`,{d:`M22 19l-3 3l-3 -3`})]}),q),Px=K(`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});K(`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}),K(`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 Fx=K(`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`);K(`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 Ix=K((0,H.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`}),J),Lx=K((0,H.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`}),J),Rx=K(`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}),zx=K((0,H.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`}),J);K(`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`),K(`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}),K((0,H.jsxs)(`g`,{strokeWidth:1.25,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.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,H.jsx)(`path`,{d:`M12 14v-11`}),(0,H.jsx)(`path`,{d:`M9 6l3 -3l3 3`})]}),q),K((0,H.jsxs)(H.Fragment,{children:[(0,H.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,H.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}),K((0,H.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 Bx=(0,H.jsxs)(`g`,{strokeWidth:1.5,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M12 10l0 10`}),(0,H.jsx)(`path`,{d:`M12 10l4 4`}),(0,H.jsx)(`path`,{d:`M12 10l-4 4`}),(0,H.jsx)(`path`,{d:`M4 4l16 0`})]}),Vx=(0,H.jsxs)(`g`,{strokeWidth:1.5,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M12 5l0 14`}),(0,H.jsx)(`path`,{d:`M16 9l-4 -4`}),(0,H.jsx)(`path`,{d:`M8 9l4 -4`})]}),Hx=K(Vx,q),Ux=K(Vx,{...q,style:{transform:`rotate(180deg)`}}),Wx=K(Bx,q),Gx=K(Bx,{...q,style:{transform:`rotate(180deg)`}}),Kx=K((0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`g`,{clipPath:`url(#a)`,stroke:`currentColor`,strokeWidth:`1.25`,children:[(0,H.jsx)(`path`,{d:`M3.333 3.333h13.334`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,H.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,H.jsx)(`defs`,{children:(0,H.jsx)(`clipPath`,{id:`a`,children:(0,H.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),J),qx=K((0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`g`,{clipPath:`url(#a)`,stroke:`currentColor`,strokeWidth:`1.25`,children:[(0,H.jsx)(`path`,{d:`M3.333 16.667h13.334`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,H.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,H.jsx)(`defs`,{children:(0,H.jsx)(`clipPath`,{id:`a`,children:(0,H.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),J),Jx=K((0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`g`,{clipPath:`url(#a)`,stroke:`currentColor`,strokeWidth:`1.25`,children:[(0,H.jsx)(`path`,{d:`M3.333 3.333v13.334`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,H.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,H.jsx)(`defs`,{children:(0,H.jsx)(`clipPath`,{id:`a`,children:(0,H.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),J),Yx=K((0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`g`,{clipPath:`url(#a)`,stroke:`currentColor`,strokeWidth:`1.25`,children:[(0,H.jsx)(`path`,{d:`M16.667 3.333v13.334`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,H.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,H.jsx)(`defs`,{children:(0,H.jsx)(`clipPath`,{id:`a`,children:(0,H.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),J),Xx=K((0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`g`,{clipPath:`url(#a)`,stroke:`currentColor`,strokeWidth:`1.25`,children:[(0,H.jsx)(`path`,{d:`M16.667 3.333v13.334M3.333 3.333v13.334`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,H.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,H.jsx)(`defs`,{children:(0,H.jsx)(`clipPath`,{id:`a`,children:(0,H.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),J),Zx=K((0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`g`,{clipPath:`url(#a)`,stroke:`currentColor`,strokeWidth:`1.25`,children:[(0,H.jsx)(`path`,{d:`M3.333 3.333h13.334M3.333 16.667h13.334`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,H.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,H.jsx)(`defs`,{children:(0,H.jsx)(`clipPath`,{id:`a`,children:(0,H.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),J),Qx=K((0,H.jsxs)(`g`,{stroke:`currentColor`,strokeWidth:`1.25`,children:[(0,H.jsx)(`path`,{d:`M1.667 10h2.916`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,H.jsx)(`path`,{d:`M8.333 10h3.334`,strokeLinejoin:`round`}),(0,H.jsx)(`path`,{d:`M15.417 10h2.916`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,H.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`})]}),J),$x=K((0,H.jsxs)(`g`,{stroke:`currentColor`,strokeWidth:`1.25`,children:[(0,H.jsx)(`path`,{d:`M10 18.333v-2.916`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,H.jsx)(`path`,{d:`M10 11.667V8.333`,strokeLinejoin:`round`}),(0,H.jsx)(`path`,{d:`M10 4.583V1.667`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,H.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`})]}),J),eS=K((0,H.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`circle`,{cx:`9`,cy:`7`,r:`4`}),(0,H.jsx)(`path`,{d:`M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2`}),(0,H.jsx)(`path`,{d:`M16 3.13a4 4 0 0 1 0 7.75`}),(0,H.jsx)(`path`,{d:`M21 21v-2a4 4 0 0 0 -3 -3.85`})]}),q);K(`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 tS=K(`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`),nS=K((0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`g`,{clipPath:`url(#a)`,stroke:`currentColor`,strokeWidth:`1.25`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,H.jsx)(`path`,{d:`M15 5 5 15M5 5l10 10`})}),(0,H.jsx)(`defs`,{children:(0,H.jsx)(`clipPath`,{id:`a`,children:(0,H.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),J);K(`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}),K(`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}),K(`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 rS=V.memo(({theme:e})=>K((0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`path`,{d:`M25 26H111V111H25`,fill:Fb(e)}),(0,H.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:Fb(e),strokeWidth:`2`}),(0,H.jsx)(`path`,{d:`M100 100H160V160H100`,fill:Fb(e)}),(0,H.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:Fb(e),strokeWidth:`2`}),(0,H.jsxs)(`g`,{fill:Ib(e),stroke:Fb(e),strokeWidth:`6`,children:[(0,H.jsx)(`rect`,{x:`2.5`,y:`2.5`,width:`30`,height:`30`}),(0,H.jsx)(`rect`,{x:`2.5`,y:`149.5`,width:`30`,height:`30`}),(0,H.jsx)(`rect`,{x:`147.5`,y:`149.5`,width:`30`,height:`30`}),(0,H.jsx)(`rect`,{x:`147.5`,y:`2.5`,width:`30`,height:`30`})]})]}),{width:182,height:182,mirror:!0})),iS=V.memo(({theme:e})=>K((0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`path`,{d:`M25 26H111V111H25`,fill:Fb(e)}),(0,H.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:Fb(e),strokeWidth:`2`}),(0,H.jsx)(`path`,{d:`M100 100H160V160H100`,fill:Fb(e)}),(0,H.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:Fb(e),strokeWidth:`2`}),(0,H.jsxs)(`g`,{fill:Ib(e),stroke:Fb(e),strokeWidth:`6`,children:[(0,H.jsx)(`rect`,{x:`2.5`,y:`2.5`,width:`30`,height:`30`}),(0,H.jsx)(`rect`,{x:`78.5`,y:`149.5`,width:`30`,height:`30`}),(0,H.jsx)(`rect`,{x:`147.5`,y:`149.5`,width:`30`,height:`30`}),(0,H.jsx)(`rect`,{x:`147.5`,y:`78.5`,width:`30`,height:`30`}),(0,H.jsx)(`rect`,{x:`105.5`,y:`2.5`,width:`30`,height:`30`}),(0,H.jsx)(`rect`,{x:`2.5`,y:`102.5`,width:`30`,height:`30`})]})]}),{width:182,height:182,mirror:!0})),aS=K((0,H.jsx)(`g`,{strokeWidth:1.25,children:(0,H.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`})}),J),oS=K((0,H.jsxs)(H.Fragment,{children:[(0,H.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,H.jsx)(`mask`,{id:`FillHachureIcon`,style:{maskType:`alpha`},maskUnits:`userSpaceOnUse`,x:2,y:2,width:16,height:16,children:(0,H.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,H.jsx)(`g`,{mask:`url(#FillHachureIcon)`,children:(0,H.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`})})]}),J),sS=K((0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`g`,{clipPath:`url(#a)`,children:[(0,H.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,H.jsx)(`mask`,{id:`FillCrossHatchIcon`,style:{maskType:`alpha`},maskUnits:`userSpaceOnUse`,x:-1,y:-1,width:22,height:22,children:(0,H.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,H.jsx)(`g`,{mask:`url(#FillCrossHatchIcon)`,children:(0,H.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,H.jsx)(`defs`,{children:(0,H.jsx)(`clipPath`,{id:`a`,children:(0,H.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),J),cS=K((0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`g`,{clipPath:`url(#a)`,children:(0,H.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,H.jsx)(`defs`,{children:(0,H.jsx)(`clipPath`,{id:`a`,children:(0,H.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),{...J,fill:`currentColor`}),lS=K((0,H.jsx)(H.Fragment,{children:(0,H.jsx)(`path`,{d:`M4.167 10h11.666`,stroke:`currentColor`,strokeWidth:`1.25`,strokeLinecap:`round`,strokeLinejoin:`round`})}),J),uS=K((0,H.jsx)(`path`,{d:`M5 10h10`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),J),dS=K((0,H.jsx)(`path`,{d:`M5 10h10`,stroke:`currentColor`,strokeWidth:`3.75`,strokeLinecap:`round`,strokeLinejoin:`round`}),J);V.memo(({theme:e})=>K((0,H.jsx)(`path`,{d:`M6 10H34`,stroke:Fb(e),strokeWidth:2,fill:`none`,strokeLinecap:`round`}),{width:40,height:20}));var fS=K((0,H.jsxs)(`g`,{strokeWidth:`2`,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M5 12h2`}),(0,H.jsx)(`path`,{d:`M17 12h2`}),(0,H.jsx)(`path`,{d:`M11 12h2`})]}),q),pS=K((0,H.jsxs)(`g`,{strokeWidth:`2`,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M4 12v.01`}),(0,H.jsx)(`path`,{d:`M8 12v.01`}),(0,H.jsx)(`path`,{d:`M12 12v.01`}),(0,H.jsx)(`path`,{d:`M16 12v.01`}),(0,H.jsx)(`path`,{d:`M20 12v.01`})]}),q),mS=K((0,H.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`}),J),hS=K((0,H.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`}),J),gS=K((0,H.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`}),J),_S=K((0,H.jsxs)(`g`,{children:[(0,H.jsx)(`path`,{d:`M4 12 C 5 8, 6 8, 8 12`,fill:`none`,strokeWidth:`1`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,H.jsx)(`path`,{d:`M8 12 C 9 16, 10 16, 12 12`,fill:`none`,strokeWidth:`1`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,H.jsx)(`path`,{d:`M12 12 C 14 8, 15 8, 16 12`,fill:`none`,strokeWidth:`1`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,H.jsx)(`path`,{d:`M16 12 C 17 16, 18 16, 19 12`,fill:`none`,strokeWidth:`1`,strokeLinecap:`round`,strokeLinejoin:`round`})]}),q),vS=K((0,H.jsxs)(`g`,{children:[(0,H.jsx)(`path`,{d:`M4 12 C 5 8, 6 8, 8 12`,fill:`none`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,H.jsx)(`path`,{d:`M8 12 C 9 16, 10 16, 12 12`,fill:`none`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,H.jsx)(`path`,{d:`M12 12 C 14 8, 15 8, 16 12`,fill:`none`,strokeWidth:`2.75`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,H.jsx)(`path`,{d:`M16 12 C 17 16, 18 16, 19 12`,fill:`none`,strokeWidth:`3.25`,strokeLinecap:`round`,strokeLinejoin:`round`})]}),q),yS=K((0,H.jsxs)(`svg`,{strokeWidth:`1.5`,children:[(0,H.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,H.jsx)(`path`,{d:`M13.3333 3.33331V3.34331`}),(0,H.jsx)(`path`,{d:`M16.6667 3.33331V3.34331`}),(0,H.jsx)(`path`,{d:`M16.6667 6.66669V6.67669`}),(0,H.jsx)(`path`,{d:`M16.6667 10V10.01`}),(0,H.jsx)(`path`,{d:`M3.33334 13.3333V13.3433`}),(0,H.jsx)(`path`,{d:`M16.6667 13.3333V13.3433`}),(0,H.jsx)(`path`,{d:`M3.33334 16.6667V16.6767`}),(0,H.jsx)(`path`,{d:`M6.66666 16.6667V16.6767`}),(0,H.jsx)(`path`,{d:`M10 16.6667V16.6767`}),(0,H.jsx)(`path`,{d:`M13.3333 16.6667V16.6767`}),(0,H.jsx)(`path`,{d:`M16.6667 16.6667V16.6767`})]}),J),bS=K((0,H.jsxs)(`g`,{strokeWidth:`1.5`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M4 12v-4a4 4 0 0 1 4 -4h4`}),(0,H.jsx)(`line`,{x1:`16`,y1:`4`,x2:`16`,y2:`4.01`}),(0,H.jsx)(`line`,{x1:`20`,y1:`4`,x2:`20`,y2:`4.01`}),(0,H.jsx)(`line`,{x1:`20`,y1:`8`,x2:`20`,y2:`8.01`}),(0,H.jsx)(`line`,{x1:`20`,y1:`12`,x2:`20`,y2:`12.01`}),(0,H.jsx)(`line`,{x1:`4`,y1:`16`,x2:`4`,y2:`16.01`}),(0,H.jsx)(`line`,{x1:`20`,y1:`16`,x2:`20`,y2:`16.01`}),(0,H.jsx)(`line`,{x1:`4`,y1:`20`,x2:`4`,y2:`20.01`}),(0,H.jsx)(`line`,{x1:`8`,y1:`20`,x2:`8`,y2:`20.01`}),(0,H.jsx)(`line`,{x1:`12`,y1:`20`,x2:`12`,y2:`20.01`}),(0,H.jsx)(`line`,{x1:`16`,y1:`20`,x2:`16`,y2:`20.01`}),(0,H.jsx)(`line`,{x1:`20`,y1:`20`,x2:`20`,y2:`20.01`})]}),q),xS=V.memo(({flip:e=!1})=>K((0,H.jsxs)(`g`,{transform:e?`translate(40, 0) scale(-1, 1)`:``,stroke:`currentColor`,opacity:.3,strokeWidth:2,fill:`none`,strokeLinecap:`round`,children:[(0,H.jsx)(`path`,{d:`M7,11 H19`}),(0,H.jsx)(`path`,{d:`M25,6 L33,16 M33,6 L25,16`})]}),Lb)),SS=V.memo(({flip:e=!1})=>K((0,H.jsx)(`g`,{transform:e?`translate(40, 0) scale(-1, 1)`:``,stroke:`currentColor`,strokeWidth:2,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,H.jsx)(`path`,{d:`M7,11 H33 M23,5 L33,11 L23,17`})}),Lb)),CS=V.memo(({flip:e=!1})=>K((0,H.jsxs)(`g`,{stroke:`currentColor`,fill:`currentColor`,transform:e?`translate(40, 0) scale(-1, 1)`:``,strokeLinejoin:`round`,children:[(0,H.jsx)(`path`,{d:`M7,11 H23`,strokeWidth:2,strokeLinecap:`round`}),(0,H.jsx)(`path`,{d:`M23,5 L35,11 L23,17 Z`})]}),Lb)),wS=V.memo(({flip:e=!1})=>K((0,H.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,transform:e?`translate(40, 0) scale(-1, 1)`:``,strokeWidth:2,strokeLinejoin:`round`,strokeLinecap:`round`,children:[(0,H.jsx)(`path`,{d:`M7,11 H23`}),(0,H.jsx)(`path`,{d:`M23,5 L35,11 L23,17 Z`})]}),Lb)),TS=V.memo(({flip:e=!1})=>K((0,H.jsxs)(`g`,{stroke:`currentColor`,fill:`currentColor`,transform:e?`translate(40, 0) scale(-1, 1)`:``,children:[(0,H.jsx)(`path`,{d:`M7,11 H25`,strokeWidth:2,strokeLinecap:`round`}),(0,H.jsx)(`circle`,{cx:`29`,cy:`11`,r:`4`})]}),Lb)),ES=V.memo(({flip:e=!1})=>K((0,H.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,transform:e?`translate(40, 0) scale(-1, 1)`:``,strokeWidth:2,children:[(0,H.jsx)(`path`,{d:`M7,11 H25`,strokeLinecap:`round`}),(0,H.jsx)(`circle`,{cx:`29`,cy:`11`,r:`4`})]}),Lb)),DS=V.memo(({flip:e=!1})=>K((0,H.jsxs)(`g`,{stroke:`currentColor`,fill:`currentColor`,transform:e?`translate(40, 0) scale(-1, 1)`:``,strokeLinejoin:`round`,children:[(0,H.jsx)(`path`,{d:`M7,11 H21`,strokeWidth:2,strokeLinecap:`round`}),(0,H.jsx)(`path`,{d:`M21,11 L28,5 L35,11 L28,17 Z`})]}),Lb)),OS=V.memo(({flip:e=!1})=>K((0,H.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,transform:e?`translate(40, 0) scale(-1, 1)`:``,strokeLinejoin:`round`,strokeWidth:2,strokeLinecap:`round`,children:[(0,H.jsx)(`path`,{d:`M7,11 H21`}),(0,H.jsx)(`path`,{d:`M21,11 L28,5 L35,11 L28,17 Z`})]}),Lb)),kS=V.memo(({flip:e=!1})=>K((0,H.jsx)(`g`,{transform:e?`translate(40, 0) scale(-1, 1)`:``,stroke:`currentColor`,strokeWidth:2,fill:`none`,strokeLinecap:`round`,children:(0,H.jsx)(`path`,{d:`M11,11 H31 M31,5 V17`})}),Lb)),AS=V.memo(({flip:e=!1})=>K((0,H.jsx)(`g`,{stroke:`currentColor`,fill:`none`,transform:e?``:`translate(40, 0) scale(-1, 1)`,strokeLinejoin:`round`,strokeWidth:2,children:(0,H.jsx)(`path`,{d:`M35,11 H7 M15,5 V17`})}),Lb)),jS=V.memo(({flip:e=!1})=>K((0,H.jsx)(`g`,{stroke:`currentColor`,fill:`none`,transform:e?``:`translate(40, 0) scale(-1, 1)`,strokeLinejoin:`round`,strokeWidth:2,children:(0,H.jsx)(`path`,{d:`M35,11 H7 M15,11 L7,5 M15,11 L7,17`})}),Lb)),MS=V.memo(({flip:e=!1})=>K((0,H.jsx)(`g`,{stroke:`currentColor`,fill:`none`,transform:e?``:`translate(40, 0) scale(-1, 1)`,strokeLinejoin:`round`,strokeWidth:2,children:(0,H.jsx)(`path`,{d:`M35,11 H7 M23,5 V17 M15,11 L7,5 M15,11 L7,17`})}),Lb)),NS=V.memo(({flip:e=!1})=>K((0,H.jsx)(`g`,{stroke:`currentColor`,fill:`none`,transform:e?``:`translate(40, 0) scale(-1, 1)`,strokeLinejoin:`round`,strokeWidth:2,children:(0,H.jsx)(`path`,{d:`M35,11 H7 M15,5 V17 M7,5 V17`})}),Lb)),PS=V.memo(({flip:e=!1})=>K((0,H.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,transform:e?``:`translate(40, 0) scale(-1, 1)`,strokeLinejoin:`round`,strokeWidth:2,children:[(0,H.jsx)(`path`,{d:`M35,11 H19 M11,11 H7 M7,5 V17`}),(0,H.jsx)(`circle`,{cx:`15`,cy:`11`,r:`4`})]}),Lb)),FS=V.memo(({flip:e=!1})=>K((0,H.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,transform:e?``:`translate(40, 0) scale(-1, 1)`,strokeLinejoin:`round`,strokeWidth:2,children:[(0,H.jsx)(`path`,{d:`M35,11 H27 M19,11 H7 M15,11 L7,5 M15,11 L7,17`}),(0,H.jsx)(`circle`,{cx:`23`,cy:`11`,r:`4`})]}),Lb)),IS=K((0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`g`,{clipPath:`url(#a)`,children:(0,H.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,H.jsx)(`defs`,{children:(0,H.jsx)(`clipPath`,{id:`a`,children:(0,H.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),J),LS=K((0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`g`,{clipPath:`url(#a)`,children:(0,H.jsx)(`path`,{d:`M5 16.667V3.333L10 15l5-11.667v13.334`,stroke:`currentColor`,strokeWidth:`1.25`,strokeLinecap:`round`,strokeLinejoin:`round`})}),(0,H.jsx)(`defs`,{children:(0,H.jsx)(`clipPath`,{id:`a`,children:(0,H.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),J),RS=K((0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`g`,{clipPath:`url(#a)`,children:(0,H.jsx)(`path`,{d:`M5.833 3.333v13.334h8.334`,stroke:`currentColor`,strokeWidth:`1.25`,strokeLinecap:`round`,strokeLinejoin:`round`})}),(0,H.jsx)(`defs`,{children:(0,H.jsx)(`clipPath`,{id:`a`,children:(0,H.jsx)(`path`,{fill:`#fff`,d:`M0 0h20v20H0z`})})})]}),J),zS=K((0,H.jsx)(H.Fragment,{children:(0,H.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`})}),J),BS=K((0,H.jsxs)(`g`,{strokeWidth:1.25,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M3 7v-2h13v2`}),(0,H.jsx)(`path`,{d:`M10 5v14`}),(0,H.jsx)(`path`,{d:`M12 19h-4`}),(0,H.jsx)(`path`,{d:`M15 13v-1h6v1`}),(0,H.jsx)(`path`,{d:`M18 12v7`}),(0,H.jsx)(`path`,{d:`M17 19h2`})]}),q),VS=K((0,H.jsx)(H.Fragment,{children:(0,H.jsxs)(`g`,{stroke:`currentColor`,strokeWidth:`1.25`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M7 12h10`}),(0,H.jsx)(`path`,{d:`M7 5v14`}),(0,H.jsx)(`path`,{d:`M17 5v14`}),(0,H.jsx)(`path`,{d:`M15 19h4`}),(0,H.jsx)(`path`,{d:`M15 5h4`}),(0,H.jsx)(`path`,{d:`M5 19h4`}),(0,H.jsx)(`path`,{d:`M5 5h4`})]})}),q),HS=K((0,H.jsx)(H.Fragment,{children:(0,H.jsx)(`g`,{stroke:`currentColor`,strokeWidth:`1.25`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,H.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`})})}),J),US=K((0,H.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M7 8l-4 4l4 4`}),(0,H.jsx)(`path`,{d:`M17 8l4 4l-4 4`}),(0,H.jsx)(`path`,{d:`M14 4l-4 16`})]}),q),WS=US,GS=K((0,H.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`line`,{x1:`4`,y1:`8`,x2:`20`,y2:`8`}),(0,H.jsx)(`line`,{x1:`4`,y1:`12`,x2:`12`,y2:`12`}),(0,H.jsx)(`line`,{x1:`4`,y1:`16`,x2:`16`,y2:`16`})]}),q),KS=K((0,H.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`line`,{x1:`4`,y1:`8`,x2:`20`,y2:`8`}),(0,H.jsx)(`line`,{x1:`8`,y1:`12`,x2:`16`,y2:`12`}),(0,H.jsx)(`line`,{x1:`6`,y1:`16`,x2:`18`,y2:`16`})]}),q),qS=K((0,H.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`line`,{x1:`4`,y1:`8`,x2:`20`,y2:`8`}),(0,H.jsx)(`line`,{x1:`10`,y1:`12`,x2:`20`,y2:`12`}),(0,H.jsx)(`line`,{x1:`8`,y1:`16`,x2:`20`,y2:`16`})]}),q),JS=V.memo(({theme:e})=>K((0,H.jsxs)(`g`,{strokeWidth:`1.5`,stroke:`currentColor`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`line`,{x1:`4`,y1:`4`,x2:`20`,y2:`4`}),(0,H.jsx)(`rect`,{x:`9`,y:`8`,width:`6`,height:`12`,rx:`2`})]}),q)),YS=V.memo(({theme:e})=>K((0,H.jsxs)(`g`,{strokeWidth:`2`,stroke:`currentColor`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`line`,{x1:`4`,y1:`20`,x2:`20`,y2:`20`}),(0,H.jsx)(`rect`,{x:`9`,y:`4`,width:`6`,height:`12`,rx:`2`})]}),q)),XS=V.memo(({theme:e})=>K((0,H.jsxs)(`g`,{strokeWidth:`1.5`,stroke:`currentColor`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`line`,{x1:`4`,y1:`12`,x2:`9`,y2:`12`}),(0,H.jsx)(`line`,{x1:`15`,y1:`12`,x2:`20`,y2:`12`}),(0,H.jsx)(`rect`,{x:`9`,y:`6`,width:`6`,height:`12`,rx:`2`})]}),q)),ZS=K((0,H.jsxs)(`g`,{children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M21 19h-18l9 -15`}),(0,H.jsx)(`path`,{d:`M20.615 15.171h.015`}),(0,H.jsx)(`path`,{d:`M19.515 11.771h.015`}),(0,H.jsx)(`path`,{d:`M17.715 8.671h.015`}),(0,H.jsx)(`path`,{d:`M15.415 5.971h.015`})]}),q),QS=K((0,H.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});K((0,H.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 $S=K((0,H.jsxs)(`g`,{strokeWidth:1.25,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M8 13v-7.5a1.5 1.5 0 0 1 3 0v6.5`}),(0,H.jsx)(`path`,{d:`M11 5.5v-2a1.5 1.5 0 1 1 3 0v8.5`}),(0,H.jsx)(`path`,{d:`M14 5.5a1.5 1.5 0 0 1 3 0v6.5`}),(0,H.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`})]}),q),eC=K((0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2`}),(0,H.jsx)(`path`,{d:`M7 11l5 5l5 -5`}),(0,H.jsx)(`path`,{d:`M12 4l0 12`})]}),q),tC=K((0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.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,H.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`})]}),q),nC=K((0,H.jsxs)(`g`,{strokeWidth:1.25,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M7 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0`}),(0,H.jsx)(`path`,{d:`M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0`}),(0,H.jsx)(`path`,{d:`M9.15 14.85l8.85 -10.85`}),(0,H.jsx)(`path`,{d:`M6 4l8.85 10.85`})]}),q),rC=K((0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0`}),(0,H.jsx)(`path`,{d:`M12 17l0 .01`}),(0,H.jsx)(`path`,{d:`M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4`})]}),q);K((0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M7 4v16l13 -8z`})]}),q),K((0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.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`})]}),q);var iC=K((0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M5 12l5 5l10 -10`})]}),q),aC=K((0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.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,H.jsx)(`path`,{d:`M12 9v4`}),(0,H.jsx)(`path`,{d:`M12 17h.01`})]}),q),oC=[`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`,`M11 7l6 6`],sC=K((0,H.jsxs)(`g`,{strokeWidth:1.25,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),oC.map(e=>(0,H.jsx)(`path`,{d:e},e))]}),q),cC=K((0,H.jsxs)(`g`,{strokeWidth:1.5,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M4 7l16 0`}),(0,H.jsx)(`path`,{d:`M4 17l16 0`}),(0,H.jsx)(`path`,{d:`M7 4l0 16`}),(0,H.jsx)(`path`,{d:`M17 4l0 16`})]}),q),lC=K((0,H.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`})),uC=K((0,H.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4`}),(0,H.jsx)(`path`,{d:`M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4`})]}),q),dC=K((0,H.jsxs)(`g`,{children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M6 10l-2 1l8 4l8 -4l-2 -1`}),(0,H.jsx)(`path`,{d:`M4 15l8 4l8 -4`}),(0,H.jsx)(`path`,{d:`M12 4v7`}),(0,H.jsx)(`path`,{d:`M15 8l-3 3l-3 -3`})]}),q),fC=K((0,H.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,H.jsx)(`path`,{d:`M4.16602 10H15.8327`}),(0,H.jsx)(`path`,{d:`M12.5 13.3333L15.8333 10`}),(0,H.jsx)(`path`,{d:`M12.5 6.66666L15.8333 9.99999`})]}),J),pC=K((0,H.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M3 9.5a6.5 6.5 0 1 0 13 0a6.5 6.5 0 1 0 -13 0`}),(0,H.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`})]}),q),mC=K((0,H.jsxs)(`g`,{fill:`none`,stroke:`currentColor`,strokeWidth:`1.25`,strokeLinecap:`round`,strokeLinejoin:`round`,transform:`rotate(90 10 10)`,children:[(0,H.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,H.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),hC=K((0,H.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`}),(0,H.jsx)(`path`,{d:`M6 21l15 -15l-3 -3l-15 15l3 3`}),(0,H.jsx)(`path`,{d:`M15 6l3 3`}),(0,H.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,H.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`})]}),q);K((0,H.jsxs)(`g`,{strokeWidth:1.25,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`}),(0,H.jsx)(`path`,{d:`M6 21l15 -15l-3 -3l-15 15l3 3`}),(0,H.jsx)(`path`,{d:`M15 6l3 3`}),(0,H.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,H.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`})]}),q),K((0,H.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M11.217 19.384a3.501 3.501 0 0 0 6.783 -1.217v-5.167l-6 -3.35`}),(0,H.jsx)(`path`,{d:`M5.214 15.014a3.501 3.501 0 0 0 4.446 5.266l4.34 -2.534v-6.946`}),(0,H.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,H.jsx)(`path`,{d:`M12.783 4.616a3.501 3.501 0 0 0 -6.783 1.217v5.067l6 3.45`}),(0,H.jsx)(`path`,{d:`M18.786 8.986a3.501 3.501 0 0 0 -4.446 -5.266l-4.34 2.534v6.946`}),(0,H.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`})]}),q);var gC=K((0,H.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M4 8v-2a2 2 0 0 1 2 -2h2`}),(0,H.jsx)(`path`,{d:`M4 16v2a2 2 0 0 0 2 2h2`}),(0,H.jsx)(`path`,{d:`M16 4h2a2 2 0 0 1 2 2v2`}),(0,H.jsx)(`path`,{d:`M16 20h2a2 2 0 0 0 2 -2v-2`})]}),q),_C=K((0,H.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,strokeWidth:1.5,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0`}),(0,H.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`})]}),q),vC=K((0,H.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M10.585 10.587a2 2 0 0 0 2.829 2.828`}),(0,H.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,H.jsx)(`path`,{d:`M3 3l18 18`})]}),q),yC=K((0,H.jsxs)(`g`,{stroke:`currentColor`,fill:`none`,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.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,H.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,H.jsx)(`path`,{d:`M17.5 16a3.5 3.5 0 0 0 0 -7h-.5`}),(0,H.jsx)(`path`,{d:`M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0`}),(0,H.jsx)(`path`,{d:`M6.5 16a3.5 3.5 0 0 1 0 -7h.5`}),(0,H.jsx)(`path`,{d:`M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10`})]}),q),bC=K((0,H.jsxs)(`g`,{strokeWidth:1.25,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.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,H.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,H.jsx)(`path`,{d:`M17.5 16a3.5 3.5 0 0 0 0 -7h-.5`}),(0,H.jsx)(`path`,{d:`M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0`}),(0,H.jsx)(`path`,{d:`M6.5 16a3.5 3.5 0 0 1 0 -7h.5`}),(0,H.jsx)(`path`,{d:`M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10`})]}),q),xC=K((0,H.jsxs)(`g`,{strokeWidth:1.5,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0`}),(0,H.jsx)(`path`,{d:`M21 21l-6 -6`})]}),q),SC=K((0,H.jsxs)(`g`,{strokeWidth:1.5,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M20.984 12.53a9 9 0 1 0 -7.552 8.355`}),(0,H.jsx)(`path`,{d:`M12 7v5l3 3`}),(0,H.jsx)(`path`,{d:`M19 16l-2 3h4l-2 3`})]}),q),CC=K((0,H.jsxs)(`g`,{strokeWidth:1.5,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M12 8l0 4l2 2`}),(0,H.jsx)(`path`,{d:`M3.05 11a9 9 0 1 1 .5 4m-.5 5v-5h5`})]}),q),wC=K((0,H.jsxs)(`g`,{strokeWidth:1.5,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.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,H.jsx)(`path`,{d:`M5 10a7 7 0 0 0 14 0`}),(0,H.jsx)(`path`,{d:`M8 21l8 0`}),(0,H.jsx)(`path`,{d:`M12 17l0 4`})]}),q),TC=K((0,H.jsxs)(`g`,{strokeWidth:1.5,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M3 3l18 18`}),(0,H.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,H.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,H.jsx)(`path`,{d:`M8 21l8 0`}),(0,H.jsx)(`path`,{d:`M12 17l0 4`})]}),q),EC=K((0,H.jsxs)(`g`,{strokeWidth:1.25,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M13 3l0 7l6 0l-8 11l0 -7l-6 0l8 -11`})]}),q),DC=K((0,H.jsxs)(`g`,{children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.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,H.jsx)(`path`,{d:`M12 20v.01`}),(0,H.jsx)(`path`,{d:`M16 20v.01`}),(0,H.jsx)(`path`,{d:`M8 20v.01`}),(0,H.jsx)(`path`,{d:`M4 20v.01`}),(0,H.jsx)(`path`,{d:`M4 16v.01`}),(0,H.jsx)(`path`,{d:`M4 12v.01`}),(0,H.jsx)(`path`,{d:`M4 8v.01`}),(0,H.jsx)(`path`,{d:`M4 4v.01`}),(0,H.jsx)(`path`,{d:`M8 4v.01`}),(0,H.jsx)(`path`,{d:`M12 4v.01`}),(0,H.jsx)(`path`,{d:`M16 4v.01`}),(0,H.jsx)(`path`,{d:`M20 4v.01`}),(0,H.jsx)(`path`,{d:`M20 8v.01`}),(0,H.jsx)(`path`,{d:`M20 12v.01`}),(0,H.jsx)(`path`,{d:`M20 16v.01`}),(0,H.jsx)(`path`,{d:`M20 20v.01`})]}),q),OC=K((0,H.jsxs)(`g`,{strokeWidth:1.25,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M5 3v18`}),(0,H.jsx)(`path`,{d:`M19 21v-18`}),(0,H.jsx)(`path`,{d:`M5 7h14`}),(0,H.jsx)(`path`,{d:`M5 15h14`}),(0,H.jsx)(`path`,{d:`M8 13v4`}),(0,H.jsx)(`path`,{d:`M11 13v4`}),(0,H.jsx)(`path`,{d:`M16 13v4`}),(0,H.jsx)(`path`,{d:`M14 5v4`}),(0,H.jsx)(`path`,{d:`M11 5v4`}),(0,H.jsx)(`path`,{d:`M8 5v4`}),(0,H.jsx)(`path`,{d:`M3 21h18`})]}),q),kC=K((0,H.jsxs)(`g`,{strokeWidth:1.25,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M3 12l18 0`}),(0,H.jsx)(`path`,{d:`M7 16l10 0l-10 5l0 -5`}),(0,H.jsx)(`path`,{d:`M7 8l10 0l-10 -5l0 5`})]}),q),AC=K((0,H.jsxs)(`g`,{strokeWidth:1.25,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M12 3l0 18`}),(0,H.jsx)(`path`,{d:`M16 7l0 10l5 0l-5 -10`}),(0,H.jsx)(`path`,{d:`M8 7l0 10l-5 0l5 -10`})]}),q),jC=K((0,H.jsxs)(`g`,{strokeWidth:1.25,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.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,H.jsx)(`path`,{d:`M19 6h1a2 2 0 0 1 2 2a5 5 0 0 1 -5 5l-5 0v2`}),(0,H.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`})]}),q),MC=K((0,H.jsxs)(`g`,{strokeWidth:1.25,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M15 15m-5 0a5 5 0 1 0 10 0a5 5 0 1 0 -10 0`}),(0,H.jsx)(`path`,{d:`M22 22l-3 -3`}),(0,H.jsx)(`path`,{d:`M6 18h-1a2 2 0 0 1 -2 -2v-1`}),(0,H.jsx)(`path`,{d:`M3 11v-1`}),(0,H.jsx)(`path`,{d:`M3 6v-1a2 2 0 0 1 2 -2h1`}),(0,H.jsx)(`path`,{d:`M10 3h1`}),(0,H.jsx)(`path`,{d:`M15 3h1a2 2 0 0 1 2 2v1`})]}),q),NC=K((0,H.jsxs)(`g`,{strokeWidth:1.25,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M14 3v4a1 1 0 0 0 1 1h4`}),(0,H.jsx)(`path`,{d:`M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4`}),(0,H.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,H.jsx)(`path`,{d:`M10 15l2 6l2 -6`}),(0,H.jsx)(`path`,{d:`M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3`})]}),q),PC=K((0,H.jsxs)(`g`,{strokeWidth:1.25,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M14 3v4a1 1 0 0 0 1 1h4`}),(0,H.jsx)(`path`,{d:`M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4`}),(0,H.jsx)(`path`,{d:`M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3`}),(0,H.jsx)(`path`,{d:`M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6`}),(0,H.jsx)(`path`,{d:`M11 21v-6l3 6v-6`})]}),q),FC=K((0,H.jsxs)(`g`,{strokeWidth:1.25,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.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,H.jsx)(`path`,{d:`M4 8l5 0`}),(0,H.jsx)(`path`,{d:`M15 8l4 0`})]}),q),IC=K((0,H.jsxs)(`g`,{strokeWidth:1.25,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.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,H.jsx)(`path`,{d:`M8 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2`}),(0,H.jsx)(`path`,{d:`M12 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2`}),(0,H.jsx)(`path`,{d:`M3 10h14v5a6 6 0 0 1 -6 6h-2a6 6 0 0 1 -6 -6v-5z`}),(0,H.jsx)(`path`,{d:`M16.746 16.726a3 3 0 1 0 .252 -5.555`})]}),q),LC=K((0,H.jsxs)(`g`,{stroke:`currentColor`,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.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`})]}),{...q,strokeWidth:1.5});K((0,H.jsxs)(`g`,{strokeWidth:1.5,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.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,H.jsx)(`path`,{d:`M21 12h-13l3 -3`}),(0,H.jsx)(`path`,{d:`M11 15l-3 -3`})]}),q);var RC=K((0,H.jsxs)(`g`,{children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.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,H.jsx)(`path`,{d:`M10 9l5 3l-5 3z`})]}),q),zC=K((0,H.jsxs)(`g`,{strokeWidth:1.5,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M3 6h18`}),(0,H.jsx)(`path`,{d:`M3 12h18`}),(0,H.jsx)(`path`,{d:`M3 18h18`}),(0,H.jsx)(`path`,{d:`M6 3v18`}),(0,H.jsx)(`path`,{d:`M12 3v18`}),(0,H.jsx)(`path`,{d:`M18 3v18`})]}),q),BC=K((0,H.jsxs)(`g`,{strokeWidth:1.5,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.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,H.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,H.jsx)(`path`,{d:`M17 5c-6.627 0 -12 5.373 -12 12`})]}),q),VC=K((0,H.jsxs)(`g`,{children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M6 18l12 -12`}),(0,H.jsx)(`path`,{d:`M18 10v-4h-4`})]}),q),HC=K((0,H.jsxs)(`g`,{children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M4,19L10,19C11.097,19 12,18.097 12,17L12,9C12,7.903 12.903,7 14,7L21,7`}),(0,H.jsx)(`path`,{d:`M18 4l3 3l-3 3`})]}),q),UC=K((0,H.jsxs)(`g`,{children:[(0,H.jsx)(`path`,{d:`M16,12L20,9L16,6`}),(0,H.jsx)(`path`,{d:`M6 20c0 -6.075 4.925 -11 11 -11h3`})]}),q),WC=K((0,H.jsxs)(`g`,{children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M6 9l6 6l6 -6`})]}),q),GC=K((0,H.jsxs)(`g`,{children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M6 15l6 -6l6 6`})]}),q),KC=K((0,H.jsxs)(`g`,{children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M6 15l6 -6l6 6`})]}),q),qC=K((0,H.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M8 5v10a1 1 0 0 0 1 1h10`}),(0,H.jsx)(`path`,{d:`M5 8h10a1 1 0 0 1 1 1v10`})]}),q),JC=K((0,H.jsxs)(`g`,{children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M5 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,H.jsx)(`path`,{d:`M19 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,H.jsx)(`path`,{d:`M5 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,H.jsx)(`path`,{d:`M19 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,H.jsx)(`path`,{d:`M5 7l0 10`}),(0,H.jsx)(`path`,{d:`M7 5l10 0`}),(0,H.jsx)(`path`,{d:`M7 19l10 0`}),(0,H.jsx)(`path`,{d:`M19 7l0 10`})]}),q);K((0,H.jsxs)(`g`,{strokeWidth:1.5,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.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,H.jsx)(`path`,{d:`M4 12h7a1 1 0 0 1 1 1v7`})]}),q);var YC=K((0,H.jsxs)(`g`,{strokeWidth:1.5,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M14 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,H.jsx)(`path`,{d:`M4 6l8 0`}),(0,H.jsx)(`path`,{d:`M16 6l4 0`}),(0,H.jsx)(`path`,{d:`M8 12m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,H.jsx)(`path`,{d:`M4 12l2 0`}),(0,H.jsx)(`path`,{d:`M10 12l10 0`}),(0,H.jsx)(`path`,{d:`M17 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,H.jsx)(`path`,{d:`M4 18l11 0`}),(0,H.jsx)(`path`,{d:`M19 18l1 0`})]}),q),XC=K((0,H.jsxs)(`g`,{strokeWidth:1,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M6 10l4 -4 L6 14l8 -8 L6 18l12 -12 L10 18l8 -8 L14 18l4 -4`})]}),q),ZC=K((0,H.jsxs)(`g`,{strokeWidth:1.25,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4`}),(0,H.jsx)(`path`,{d:`M13.5 6.5l4 4`})]}),q);K((0,H.jsxs)(`g`,{strokeWidth:1,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M11 7l-5 5l5 5`}),(0,H.jsx)(`path`,{d:`M17 7l-5 5l5 5`})]}),q);var QC=K((0,H.jsxs)(`g`,{strokeWidth:`1.75`,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.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,H.jsx)(`path`,{d:`M15 4l0 16`})]}),q);K((0,H.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.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`})]}),q),K((0,H.jsxs)(`g`,{strokeWidth:`1.25`,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M3 4l18 0`}),(0,H.jsx)(`path`,{d:`M4 4v10a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-10`}),(0,H.jsx)(`path`,{d:`M12 16l0 4`}),(0,H.jsx)(`path`,{d:`M9 20l6 0`}),(0,H.jsx)(`path`,{d:`M8 12l3 -3l2 2l3 -3`})]}),q);var $C=(0,H.jsx)(`div`,{style:{width:`1rem`,height:`1rem`}}),ew=K((0,H.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`polyline`,{points:`6 9 12 15 18 9`})]}),q),tw=K((0,H.jsxs)(`g`,{strokeWidth:`1.5`,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`polyline`,{points:`9 6 15 12 9 18`})]}),q),nw=K((0,H.jsxs)(`g`,{strokeWidth:1.25,children:[(0,H.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,H.jsx)(`path`,{d:`M14 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,H.jsx)(`path`,{d:`M4 6l8 0`}),(0,H.jsx)(`path`,{d:`M16 6l4 0`}),(0,H.jsx)(`path`,{d:`M8 12m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,H.jsx)(`path`,{d:`M4 12l2 0`}),(0,H.jsx)(`path`,{d:`M10 12l10 0`}),(0,H.jsx)(`path`,{d:`M17 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`}),(0,H.jsx)(`path`,{d:`M4 18l11 0`}),(0,H.jsx)(`path`,{d:`M19 18l1 0`})]}),q),rw=({size:e=`1em`,circleWidth:t=8,synchronized:n=!1,className:r=``})=>{let i=-(V.useRef(Date.now()).current%1600);return(0,H.jsx)(`div`,{className:`Spinner ${r}`,children:(0,H.jsx)(`svg`,{viewBox:`0 0 100 100`,style:{width:e,height:e,"--spinner-delay":n?`${i}ms`:0},children:(0,H.jsx)(`circle`,{cx:`50`,cy:`50`,r:50-t/2,strokeWidth:t,fill:`none`,strokeMiterlimit:`10`})})})},Y=V.forwardRef(({size:e=`medium`,visible:t=!0,className:n=``,...r},i)=>{let a=V.useRef(null);V.useImperativeHandle(i,()=>a.current);let o=`ToolIcon_size_${e}`,[s,c]=(0,V.useState)(!1),l=(0,V.useRef)(!0),u=async e=>{let t=`onClick`in r&&r.onClick?.(e);if(Yt(t))try{c(!0),await t}catch(e){if(e instanceof gs)console.warn(e);else throw e}finally{l.current&&c(!1)}};(0,V.useEffect)(()=>(l.current=!0,()=>{l.current=!1}),[]);let d=(0,V.useRef)(null);return r.type===`button`||r.type===`icon`?(0,H.jsxs)(`button`,{className:U(`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,H.jsxs)(`div`,{className:`ToolIcon__icon`,"aria-hidden":`true`,"aria-disabled":!!r.disabled,children:[r.icon||r.label,r.keyBindingLabel&&(0,H.jsx)(`span`,{className:`ToolIcon__keybinding`,children:r.keyBindingLabel}),r.isLoading&&(0,H.jsx)(rw,{})]}),r.showAriaLabel&&(0,H.jsxs)(`div`,{className:`ToolIcon__label`,children:[r[`aria-label`],` `,s&&(0,H.jsx)(rw,{})]}),r.children]}):(0,H.jsx)(`button`,{className:U(`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,H.jsxs)(`div`,{className:`ToolIcon__icon`,children:[r.icon,r.keyBindingLabel&&(0,H.jsx)(`span`,{className:`ToolIcon__keybinding`,children:r.keyBindingLabel})]})})});Y.displayName=`IconButton`;var iw=[],X=e=>(iw=iw.concat(e),e),aw=(e,t,n)=>{let r=new Set(is(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=tr(e,t);for(let e of n)if(!o.has(e.id)){if(fs(e)){let t=bo(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=fs(e)?bo(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&&fe(r)&&n.scene.mutateElement(r,{startBinding:e.id===r.startBinding?.elementId?null:r.startBinding,endBinding:e.id===r.endBinding?.elementId?null:r.endBinding})}),z(e,{isDeleted:!0}))}return e.frameId&&r.has(e.frameId)?(s=!1,fs(e)||(i[e.id]=!0),z(e,{frameId:null})):fs(e)&&t.selectedElementIds[e.containerId]?z(e,{isDeleted:!0}):e}),l=t.editingGroupId;if(s&&t.editingGroupId){let e=St(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=St(c,r).filter(e=>!e.isDeleted);e.length>1&&(l=r,e.forEach(e=>{i[e.id]=!0}))}}}}return{elements:c,appState:{...t,...Xo({selectedElementIds:i,editingGroupId:l},At(c),t,null)}}},ow=(e,t)=>{if(e.editingGroupId){let n=St(At(t),e.editingGroupId);if(n.length)return{...e,selectedElementIds:{[n[0].id]:!0}}}return e},sw=X({name:`deleteSelectedElements`,label:`labels.delete`,icon:fx,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=M.getElement(n,a);if(!o||i==null)return!1;if(i.length>=o.points.length){let n=e.map(e=>e.id===o.id?z(e,{isDeleted:!0}):e);return{elements:n,appState:{...ow(t,n),selectedLinearElement:null},captureUpdate:j.IMMEDIATELY}}return M.deletePoints(o,r,i),{elements:e,appState:{...t,selectedLinearElement:{...t.selectedLinearElement,selectedPointsIndices:i?.[0]>0?[i[0]-1]:[0]}},captureUpdate:j.IMMEDIATELY}}let{elements:i,appState:a}=aw(e,t,r);return ys(i,i.filter(e=>e.isDeleted)),a=ow(a,i),{elements:i,appState:{...a,activeTool:$r(t,{type:r.state.preferredSelectionTool.type}),multiElement:null,newElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:Ki(At(e),t)?j.IMMEDIATELY:j.EVENTUALLY}},keyTest:(e,t,n)=>(e.key===I.BACKSPACE||e.key===I.DELETE)&&!e[I.CTRL_OR_CMD],PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>{let i=yH()===`mobile`;return(0,H.jsx)(Y,{type:`button`,icon:fx,title:G(`labels.delete`),"aria-label":G(`labels.delete`),onClick:()=>n(null),disabled:!Ki(At(e),t),style:{...i&&t.openPopup!==`compactOtherProperties`?Ne:{}}})}}),Z=e=>e.replace(/\b(Opt(?:ion)?|Alt)\b/i,G(uo?`keys.option`:`keys.alt`)).replace(/\bShift\b/i,G(`keys.shift`)).replace(/\b(Enter|Return)\b/i,G(`keys.enter`)).replace(/\b(Ctrl|Cmd|Command|CtrlOrCmd)\b/gi,G(uo?`keys.cmd`:`keys.ctrl`)).replace(/\b(Esc(?:ape)?)\b/i,G(`keys.escape`)).replace(/\b(Space(?:bar)?)\b/i,G(`keys.spacebar`)).replace(/\b(Del(?:ete)?)\b/i,G(`keys.delete`)),cw=X({name:`sendBackward`,label:`labels.sendBackward`,keywords:[`move down`,`zindex`,`layer`],icon:Ux,trackEvent:{category:`element`},perform:(e,t,n,r)=>({elements:fn(e,t,r.scene),appState:t,captureUpdate:j.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[I.CTRL_OR_CMD]&&!e.shiftKey&&e.code===ir.BRACKET_LEFT,PanelComponent:({updateData:e,appState:t})=>(0,H.jsx)(`button`,{type:`button`,className:`zIndexButton`,onClick:()=>e(null),title:`${G(`labels.sendBackward`)} \u2014 ${Z(`CtrlOrCmd+[`)}`,children:Ux})}),lw=X({name:`bringForward`,label:`labels.bringForward`,keywords:[`move up`,`zindex`,`layer`],icon:Hx,trackEvent:{category:`element`},perform:(e,t,n,r)=>({elements:Jt(e,t,r.scene),appState:t,captureUpdate:j.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[I.CTRL_OR_CMD]&&!e.shiftKey&&e.code===ir.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:t})=>(0,H.jsx)(`button`,{type:`button`,className:`zIndexButton`,onClick:()=>e(null),title:`${G(`labels.bringForward`)} \u2014 ${Z(`CtrlOrCmd+]`)}`,children:Hx})}),uw=X({name:`sendToBack`,label:`labels.sendToBack`,keywords:[`move down`,`zindex`,`layer`],icon:Gx,trackEvent:{category:`element`},perform:(e,t)=>({elements:Za(e,t),appState:t,captureUpdate:j.IMMEDIATELY}),keyTest:e=>uo?e[I.CTRL_OR_CMD]&&e.altKey&&e.code===ir.BRACKET_LEFT:e[I.CTRL_OR_CMD]&&e.shiftKey&&e.code===ir.BRACKET_LEFT,PanelComponent:({updateData:e,appState:t})=>(0,H.jsx)(`button`,{type:`button`,className:`zIndexButton`,onClick:()=>e(null),title:`${G(`labels.sendToBack`)} \u2014 ${Z(uo?`CtrlOrCmd+Alt+[`:`CtrlOrCmd+Shift+[`)}`,children:Gx})}),dw=X({name:`bringToFront`,label:`labels.bringToFront`,keywords:[`move up`,`zindex`,`layer`],icon:Wx,trackEvent:{category:`element`},perform:(e,t)=>({elements:et(e,t),appState:t,captureUpdate:j.IMMEDIATELY}),keyTest:e=>uo?e[I.CTRL_OR_CMD]&&e.altKey&&e.code===ir.BRACKET_RIGHT:e[I.CTRL_OR_CMD]&&e.shiftKey&&e.code===ir.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:t})=>(0,H.jsx)(`button`,{type:`button`,className:`zIndexButton`,onClick:t=>e(null),title:`${G(`labels.bringToFront`)} \u2014 ${Z(uo?`CtrlOrCmd+Alt+]`:`CtrlOrCmd+Shift+]`)}`,children:Wx})}),fw=X({name:`selectAll`,label:`labels.selectAll`,icon:DC,trackEvent:{category:`canvas`},viewMode:!1,perform:(e,t,n,r)=>{if(t.selectedLinearElement?.isEditing)return!1;let i=e.filter(e=>!e.isDeleted&&!(F(e)&&e.containerId)&&!e.locked).reduce((e,t)=>(e[t.id]=!0,e),{});return{appState:{...t,...Xo({editingGroupId:null,selectedElementIds:i},At(e),t,r),selectedLinearElement:Object.keys(i).length===1&&vo(e[0])?new M(e[0],ze(e)):null},captureUpdate:j.IMMEDIATELY}},keyTest:e=>e[I.CTRL_OR_CMD]&&e.key===I.A}),pw=X({name:`duplicateSelection`,label:`labels.duplicateSelection`,icon:mx,trackEvent:{category:`element`},perform:(e,t,n,r)=>{if(t.selectedElementsAreBeingDragged)return!1;if(t.selectedLinearElement?.isEditing)try{return{elements:e,appState:M.duplicateSelectedPoints(t,r.scene),captureUpdate:j.IMMEDIATELY}}catch{return!1}let{duplicatedElements:i,elementsWithDuplicates:a}=Ei({type:`in-place`,elements:e,idsOfElementsToDuplicate:ze(is(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:xt(a,ze(i)),appState:{...t,..._r(i,At(a),t)},captureUpdate:j.IMMEDIATELY}},keyTest:e=>e[I.CTRL_OR_CMD]&&e.key===I.D,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>{let i=yH()===`mobile`;return(0,H.jsx)(Y,{type:`button`,icon:mx,title:`${G(`labels.duplicateSelection`)} \u2014 ${Z(`CtrlOrCmd+D`)}`,"aria-label":G(`labels.duplicateSelection`),onClick:()=>n(null),disabled:!Ki(At(e),t),style:{...i&&t.openPopup!==`compactOtherProperties`?Ne:{}}})}}),mw=new Set([`command_palette`,`export`]),hw=(e,t,n,r)=>{try{if(typeof window>`u`||nn.VITE_WORKER_ID||nn.VITE_APP_ENABLE_TRACKING!==`true`||!mw.has(e)||ht())return;nn.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)}},gw=(0,V.forwardRef)((e,t)=>{let{title:n,className:r,testId:i,active:a,icon:o,onClick:s}=e;return(0,H.jsx)(`button`,{type:`button`,ref:t,title:n,"data-testid":i,className:U(r,{active:a}),onClick:s,style:e.style,children:o},n)}),_w=e=>(0,H.jsx)(H.Fragment,{children:e.options.map(t=>e.type===`button`?(0,H.jsx)(gw,{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,H.jsxs)(`label`,{className:U({active:e.value===t.value}),title:t.text,children:[(0,H.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))}),vw=()=>(0,H.jsx)(`div`,{style:{width:1,height:`1rem`,backgroundColor:`var(--default-border-color)`,margin:`0 auto`}}),yw=V.createContext(null),bw=()=>V.useContext(yw),xw=e=>{let[t,n]=(0,V.useState)(null),r=vH(),{theme:i}=bw(),{container:a}=bH();return(0,V.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===N.DARK))},[t,i,r.formFactor,e?.className]),(0,V.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 Sw(e,t,n){(0,V.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(R.POINTER_DOWN,r),document.addEventListener(R.TOUCH_START,r),()=>{document.removeEventListener(R.POINTER_DOWN,r),document.removeEventListener(R.TOUCH_START,r)}},[e,t,n])}var Cw=e=>{let t=(0,V.useRef)(e);return Object.assign(t.current,e),t.current},ww=({cursorPosition:e,elementSize:t,containerSize:n,gap:r})=>{let i=e+r+t>n?e-r-t:e+r;return bs(i,0,Math.max(0,n-t))},Tw=({cursor:e,element:t,container:n,gap:r})=>({left:ww({cursorPosition:e.x-n.left,elementSize:t.width,containerSize:n.width,gap:r}),top:ww({cursorPosition:e.y-n.top,elementSize:t.height,containerSize:n.height,gap:r})}),Ew=oC.map((e,t)=>`<path fill="${t===0?`#fff`:``}" d="${e}" />`).join(``),Dw=`url(data:${L.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" stroke-width="5">${Ew}</g><g stroke="#1b1b1f" stroke-width="1.25">${Ew}</g></svg>`)}) 2 21, auto`,Ow=Yc(null),kw=({onCancel:e,onChange:t,onSelect:n,colorPickerType:r})=>{let i=xw({className:`excalidraw-eye-dropper-backdrop`,parentSelector:`.excalidraw-eye-dropper-container`}),o=bw(),s=xH(),c=gH(),l=Cw({app:c,onCancel:e,onChange:t,onSelect:n,selectedElements:is(s,o)}),{container:u}=bH();(0,V.useLayoutEffect)(()=>{if(i)return i.style.cursor=Dw,()=>{i.style.cursor=``}},[i]),(0,V.useEffect)(()=>{let e=d.current;if(!e||!c.canvas||!i)return;let t=!1,n=c.canvas.getContext(`2d`),s=({clientX:e,clientY:t})=>{let r=n.getImageData((e-o.offsetLeft)*window.devicePixelRatio,(t-o.offsetTop)*window.devicePixelRatio,1,1).data;return Di(r[0],r[1],r[2])},f=e=>o.theme===N.DARK?mn(e):e,p=({clientX:n,clientY:o,altKey:c})=>{let{top:u,left:d}=Tw({cursor:{x:n,y:o},element:{width:e.offsetWidth,height:e.offsetHeight},container:i.getBoundingClientRect(),gap:7});e.style.top=`${u}px`,e.style.left=`${d}px`;let p=s({clientX:n,clientY:o});t&&l.onChange(r,f(p),l.selectedElements,{altKey:c}),e.style.background=p,e.style.setProperty(`--eye-dropper-preview-border-color`,a(p)?`#fff`:`#222`)},m=()=>{l.onCancel()},h=(e,t)=>{l.onSelect(e,t)},g=e=>{t=!0,e.stopImmediatePropagation()},_=e=>{t=!1,u?.focus(),e.stopImmediatePropagation(),e.preventDefault(),h(f(s(e)),e)},v=e=>{e.key===I.ESCAPE&&(e.preventDefault(),e.stopImmediatePropagation(),m())};return i.tabIndex=-1,i.focus(),p({clientX:l.app.viewport.lastPosition.x,clientY:l.app.viewport.lastPosition.y,altKey:!1}),i.addEventListener(R.KEYDOWN,v),i.addEventListener(R.POINTER_DOWN,g),i.addEventListener(R.POINTER_UP,_),window.addEventListener(`pointermove`,p,{passive:!0}),window.addEventListener(R.BLUR,m),()=>{t=!1,i.removeEventListener(R.KEYDOWN,v),i.removeEventListener(R.POINTER_DOWN,g),i.removeEventListener(R.POINTER_UP,_),window.removeEventListener(`pointermove`,p),window.removeEventListener(R.BLUR,m)}},[l,c.canvas,i,r,u,o.offsetLeft,o.offsetTop,o.theme]);let d=(0,V.useRef)(null);return Sw(d,()=>{e()},e=>!!e.target.closest(`.excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop`)),i?(0,qc.createPortal)((0,H.jsx)(`div`,{ref:d,className:`excalidraw-eye-dropper-preview`}),i):null},Aw=V.forwardRef(({children:e,padding:t,className:n,style:r,"data-viewport-ui":i,"data-viewport-ui-name":a},o)=>(0,H.jsx)(`div`,{className:U(`Island`,n),style:{"--padding":t,...r},"data-viewport-ui":i,"data-viewport-ui-name":a,ref:o,children:e})),jw=V.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=vH(),f=d.formFactor===`phone`&&!d.isLandscape;return(0,H.jsx)(ry,{container:t,children:(0,H.jsxs)(iy,{ref:u,className:U(`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&&!sr(document.activeElement)&&t.focus(),i()},children:[(0,H.jsx)(Aw,{padding:3,style:r,children:n}),(0,H.jsx)(oy,{width:20,height:10,style:{fill:`var(--popup-bg-color)`,filter:`drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)`}})]})})}),Mw=()=>document.querySelector(`.excalidraw-wysiwyg`),Nw=()=>{let e=Mw();return e?{start:e.selectionStart,end:e.selectionEnd}:null},Pw=e=>{setTimeout(()=>{let t=Mw();t&&(t.focus(),e&&(t.selectionStart=e.start,t.selectionEnd=e.end))},0)},Fw=(e,t,n,r)=>{t&&r&&r();let i=t&&n?Nw():null;e(),t&&n&&Pw(i)},Iw=()=>{let[e,t]=(0,V.useState)(null);return{saveCaretPosition:(0,V.useCallback)(()=>{let e=Nw();t(e)},[]),restoreCaretPosition:(0,V.useCallback)(()=>{setTimeout(()=>{let n=Mw();n&&(n.focus(),e&&(n.selectionStart=e.start,n.selectionEnd=e.end,t(null)))},0)},[e]),clearSavedPosition:(0,V.useCallback)(()=>{t(null)},[]),hasSavedPosition:!!e}},Lw=(e=100)=>{let t=Mw();if(t){let n=t.onblur;t.onblur=null,setTimeout(()=>{t.onblur=n},e)}},Rw=({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},zw=[[`q`,`w`,`e`,`r`,`t`],[`a`,`s`,`d`,`f`,`g`],[`z`,`x`,`c`,`v`,`b`]].flat(),Bw=({color:e,palette:t})=>!Object.values(t).flat().includes(e),Vw=(e,t,n)=>{let r={elementBackground:`backgroundColor`,elementStroke:`strokeColor`},i=e.filter(e=>{if(e.isDeleted)return!1;let i=e[r[t]];return!Aa(i)&&Bw({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)},Hw=Yc(null),Uw=({color:e,onChange:t,label:n,colorPickerType:r,placeholder:i})=>{let a=vH(),[o,s]=(0,V.useState)(e),[c,l]=(0,V.useState)(null),[u,d]=_b(Hw);(0,V.useEffect)(()=>{s(e)},[e]);let f=(0,V.useCallback)(e=>{let n=e.toLowerCase().trim(),r=sn(n);r?(t(r),l(null)):n.length===0?l(null):/^#?[0-9a-f]+$/.test(n)?l(G(`colorPicker.invalidHexLength`)):l(G(`colorPicker.invalidColor`)),s(n)},[t]),p=(0,V.useRef)(null),m=(0,V.useRef)(null);(0,V.useEffect)(()=>{p.current&&p.current.focus()},[u]);let[h,g]=_b(Ow);return(0,V.useEffect)(()=>()=>{g(null)},[g]),(0,H.jsxs)(`div`,{className:`color-picker__input-label-container`,children:[(0,H.jsxs)(`div`,{className:U(`color-picker__input-label`,{"has-error":c}),children:[(0,H.jsx)(`div`,{className:`color-picker__input-hash`,children:`#`}),(0,H.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!==I.TAB&&(e.key===I.ESCAPE&&m.current?.focus(),e.stopPropagation())},placeholder:i}),a.formFactor!==`phone`&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{style:{width:`1px`,height:`1.25rem`,backgroundColor:`var(--default-border-color)`}}),(0,H.jsx)(`div`,{ref:m,className:U(`excalidraw-eye-dropper-trigger`,{selected:h}),onClick:()=>g(e=>e?null:{keepOpenOnAlt:!1,onSelect:e=>t(e),colorPickerType:r}),title:`${G(`labels.eyeDropper`)} \u2014 ${I.I.toLocaleUpperCase()} or ${Z(`Alt`)} `,children:sC})]})]}),c&&(0,H.jsx)(`div`,{className:`color-picker__error-message`,role:`alert`,children:c})]})},Ww=({color:e,keyLabel:t,isShade:n=!1})=>(0,H.jsxs)(`div`,{className:`color-picker__button__hotkey-label`,style:{color:a(e)?`#fff`:`#000`},children:[n&&`⇧`,t]}),Gw=`excalidraw-color-dnd-ghost`,Kw=`excalidraw-color-dnd-active`,qw=10,Jw=100,Yw=(e,t)=>{if(e.toLowerCase()===t.toLowerCase())return!0;let n=Wn(e);return n!==null&&n===Wn(t)},Xw=(0,V.createContext)(null),Zw=()=>(0,V.useContext)(Xw),Qw=({enabled:e,picks:t,onPicksChange:n})=>{let[r,i]=(0,V.useState)(null),a=(0,V.useRef)(null),o=(0,V.useRef)({enabled:e,picks:t,onPicksChange:n});o.current={enabled:e,picks:t,onPicksChange:n};let s=(0,V.useMemo)(()=>{let e=null,t=()=>{e?.activated?i({color:e.color,origin:e.origin,overIndex:e.overIndex,duplicateIndex:e.duplicateIndex,slotSpan:e.slotSpan}):i(null)},n=()=>{let t=a.current;if(!t||!e)return!1;let n=Array.from(t.querySelectorAll(`[data-top-pick-index]`)).sort((e,t)=>Number(e.dataset.topPickIndex)-Number(t.dataset.topPickIndex));if(!n.length)return!1;e.slotRects=n.map(e=>e.getBoundingClientRect());let[r,i]=e.slotRects;e.slotSpan=i?i.left-r.left:r.width+4;let o=t.getBoundingClientRect(),s=Math.max(Math.abs(e.slotSpan)/2,10);return e.hitRect={left:o.left-s,right:o.right+s,top:o.top-14,bottom:o.bottom+14},!0},r=(t,n)=>{e?.ghost&&(e.ghost.style.transform=`translate(${t-e.ghostW/2}px, ${n-e.ghostH/2}px)`)},s=(t,n,i,a)=>{e?.ghost&&(e.ghostW!==t||e.ghostH!==n)&&(e.ghostW=t,e.ghostH=n,e.ghost.style.width=`${t}px`,e.ghost.style.height=`${n}px`,r(i,a))},c=(n,i)=>{if(!e)return;let{sourceRect:a,sourceEl:o,color:s}=e,c=document.createElement(`div`);c.className=Gw;let l=document.createElement(`div`);if(l.className=`${Gw}__swatch`,Aa(s))l.classList.add(`is-transparent`);else{let e=getComputedStyle(o).backgroundColor;l.style.backgroundColor=e&&e!==`rgba(0, 0, 0, 0)`?e:s}c.appendChild(l),document.body.appendChild(c),e.ghost=c,e.ghostW=a.width,e.ghostH=a.height,c.style.width=`${a.width}px`,c.style.height=`${a.height}px`,r(n,i),requestAnimationFrame(()=>{e?.ghost===c&&c.classList.add(`${Gw}--lifted`)}),document.body.classList.add(Kw),e.activated=!0,t()},l=(n,r)=>{if(!e?.hitRect)return;let{hitRect:i,slotRects:a}=e,c=null,l=null;if(n>=i.left&&n<=i.right&&r>=i.top&&r<=i.bottom){let t=0,r=1/0;if(a.forEach((e,i)=>{let a=Math.abs(n-(e.left+e.width/2));a<r&&(r=a,t=i)}),e.origin.kind===`swatch`){let n=o.current.picks.findIndex(t=>Yw(t,e.color));n===-1?c=t:l=n}else c=t}if(c!==e.overIndex||l!==e.duplicateIndex){e.overIndex=c,e.duplicateIndex=l;let{ghost:n}=e;n&&(n.classList.toggle(`${Gw}--over`,c!==null),n.classList.toggle(`${Gw}--blocked`,l!==null)),t()}if(c!==null){let t=e.slotRects[c];s(t.width,t.height,n,r)}else s(e.sourceRect.width,e.sourceRect.height,n,r)},u=t=>{if(!e?.ghost)return;let{ghost:n}=e;e.ghost=null,n.classList.add(`${Gw}--dropping`);let r=t.rect;r&&(n.style.width=`${r.width}px`,n.style.height=`${r.height}px`,n.style.transform=`translate(${r.left}px, ${r.top}px)`),window.setTimeout(()=>{n.classList.add(`${Gw}--fade`)},160),window.setTimeout(()=>{n.remove()},340)},d=()=>{let t=a.current;if(!t||!e?.activated)return;let n=Array.from(t.querySelectorAll(`[data-top-pick-index]`));for(let e of n)e.style.transition=`none`,e.style.transform=`none`;t.offsetWidth;for(let e of n)e.style.transition=``},f=()=>{let e=e=>{e.preventDefault(),e.stopPropagation()};window.addEventListener(`click`,e,{capture:!0,once:!0}),window.setTimeout(()=>{window.removeEventListener(`click`,e,{capture:!0})},100)},p=()=>{window.removeEventListener(`pointermove`,_,!0),window.removeEventListener(`pointerup`,v,!0),window.removeEventListener(`pointercancel`,y,!0),window.removeEventListener(`keydown`,b,!0)},m=()=>{p(),document.body.classList.remove(Kw),e?.activationTimer!=null&&window.clearTimeout(e.activationTimer),e=null,i(null)},h=t=>{e&&(d(),e.ghost&&(t?u({rect:e.sourceRect}):(e.ghost.remove(),e.ghost=null)),m())},g=(t,r)=>{if(!(!e||e.activated)){if(!n()){m();return}c(t,r),l(t,r)}},_=t=>{if(!(!e||t.pointerId!==e.pointerId)){if(e.lastX=t.clientX,e.lastY=t.clientY,!e.activated){if(Math.hypot(t.clientX-e.startX,t.clientY-e.startY)<qw){e.activationTimer!==null&&(window.clearTimeout(e.activationTimer),e.activationTimer=null);return}let n=performance.now()-e.startTime;if(n<Jw){e.activationTimer===null&&(e.activationTimer=window.setTimeout(()=>{e&&(e.activationTimer=null,Math.hypot(e.lastX-e.startX,e.lastY-e.startY)>=qw&&g(e.lastX,e.lastY))},Jw-n));return}if(g(t.clientX,t.clientY),!e?.activated)return}t.preventDefault(),r(t.clientX,t.clientY),l(t.clientX,t.clientY)}},v=t=>{if(!e||t.pointerId!==e.pointerId)return;if(!e.activated){m();return}t.preventDefault(),t.stopPropagation(),f();let{overIndex:n,origin:r,color:i,slotRects:a}=e,{picks:s,onPicksChange:c}=o.current;if(d(),n!==null){if(r.kind===`swatch`){if(!s.some(e=>Yw(e,i))){let e=[...s];e[n]=i,c(e)}}else if(r.index!==n){let e=[...s],[t]=e.splice(r.index,1);e.splice(n,0,t),c(e)}u({rect:a[n]})}else u({rect:e.sourceRect});m()},y=t=>{e&&t.pointerId===e.pointerId&&h(!0)},b=t=>{e?.activated&&t.key===`Escape`&&(t.preventDefault(),t.stopPropagation(),h(!0))};return{begin:(t,n,r)=>{!o.current.enabled||e||t.button!==0||!n||(e={pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,startTime:performance.now(),lastX:t.clientX,lastY:t.clientY,activationTimer:null,color:n,origin:r,sourceEl:t.currentTarget,sourceRect:t.currentTarget.getBoundingClientRect(),activated:!1,ghost:null,ghostW:0,ghostH:0,slotRects:[],slotSpan:0,hitRect:null,overIndex:null,duplicateIndex:null},window.addEventListener(`pointermove`,_,!0),window.addEventListener(`pointerup`,v,!0),window.addEventListener(`pointercancel`,y,!0),window.addEventListener(`keydown`,b,!0))},destroy:()=>h(!1)}},[]);return(0,V.useEffect)(()=>()=>s.destroy(),[s]),(0,V.useMemo)(()=>({dragState:r,startSwatchDrag:(e,t)=>s.begin(e,t,{kind:`swatch`}),startPickDrag:(e,t,n)=>s.begin(e,n,{kind:`pick`,index:t}),setStripEl:e=>{a.current=e}}),[r,s])},$w=({theme:e,colors:t,color:n,onChange:r,label:i})=>{let[a,o]=_b(Hw),s=Zw(),c=(0,V.useRef)(null);return(0,V.useEffect)(()=>{c.current&&c.current.focus()},[n,a]),(0,H.jsx)(`div`,{className:`color-picker-content--default`,children:t.map((t,a)=>{let l=Hn(t,e===N.DARK);return(0,H.jsxs)(`button`,{ref:n===t?c:void 0,tabIndex:-1,type:`button`,className:U(`color-picker__button color-picker__button--large has-outline`,{active:n===t,"is-transparent":t===`transparent`||!t}),onClick:()=>{r(t),o(`custom`)},onPointerDown:s?e=>s.startSwatchDrag(e,t):void 0,title:t,"aria-label":i,style:{"--swatch-color":l},children:[(0,H.jsx)(`div`,{className:`color-picker__button-outline`}),(0,H.jsx)(Ww,{color:l,keyLabel:a+1})]},a)})})},eT=({theme:e,palette:t,color:n,onChange:r,activeShade:i,showHotKey:o=!0,excludedColors:s})=>{let c=Rw({color:n,palette:t}),[l,u]=_b(Hw),d=Zw(),f=(0,V.useRef)(null);return(0,V.useEffect)(()=>{f.current&&l===`baseColors`&&f.current.focus()},[c?.colorName,l]),(0,H.jsx)(`div`,{className:`color-picker-content--default`,children:Object.entries(t).map(([t,n],l)=>{let p=(Array.isArray(n)?n[i]:n)||`transparent`;if(s?.includes(p))return(0,H.jsx)(`div`,{className:`color-picker__button color-picker__button--large`,style:{visibility:`hidden`},"aria-hidden":`true`},t);let m=zw[l],h=Hn(p,e===N.DARK),g=G(`colors.${t.replace(/\d+/,``)}`,null,``);return(0,H.jsxs)(`button`,{ref:c?.colorName===t?f:void 0,tabIndex:-1,type:`button`,className:U(`color-picker__button color-picker__button--large`,{"has-outline":!a(p,255),active:c?.colorName===t,"is-transparent":p===`transparent`||!p}),onClick:()=>{r(p),u(`baseColors`)},onPointerDown:d?e=>d.startSwatchDrag(e,p):void 0,title:`${g}${p.startsWith(`#`)?` ${p}`:``} \u2014 ${m}`,"aria-label":`${g} \u2014 ${m}`,style:p?{"--swatch-color":h}:void 0,"data-testid":`color-${t}`,children:[(0,H.jsx)(`div`,{className:`color-picker__button-outline`}),o&&(0,H.jsx)(Ww,{color:h,keyLabel:m})]},t)})})},tT=({children:e})=>(0,H.jsx)(`div`,{className:`color-picker__heading`,children:e}),nT=({theme:e,color:t,onChange:n,palette:r,showHotKey:i})=>{let a=Rw({color:t||`transparent`,palette:r}),[o,s]=_b(Hw),c=Zw(),l=(0,V.useRef)(null);if((0,V.useEffect)(()=>{l.current&&o===`shades`&&l.current.focus()},[a,o]),a){let{colorName:t,shade:u}=a,d=r[t];if(Array.isArray(d))return(0,H.jsx)(`div`,{className:`color-picker-content--default shades`,children:d.map((r,a)=>{let d=Hn(r,e===N.DARK);return(0,H.jsxs)(`button`,{ref:a===u&&o===`shades`?l:void 0,tabIndex:-1,type:`button`,className:U(`color-picker__button color-picker__button--large`,{active:a===u}),"aria-label":`Shade`,title:`${t} - ${a+1}`,style:r?{"--swatch-color":d}:void 0,onClick:()=>{n(r),s(`shades`)},onPointerDown:c?e=>c.startSwatchDrag(e,r):void 0,children:[(0,H.jsx)(`div`,{className:`color-picker__button-outline`}),i&&(0,H.jsx)(Ww,{color:d,keyLabel:a+1,isShade:!0})]},a)})})}return(0,H.jsxs)(`div`,{className:`color-picker-content--default`,style:{position:`relative`},tabIndex:-1,children:[(0,H.jsx)(`button`,{type:`button`,tabIndex:-1,className:`color-picker__button color-picker__button--large color-picker__button--no-focus-visible`}),(0,H.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:G(`colorPicker.noShades`)})]})},rT=(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}}},iT=({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(zw.includes(e.key)){let t=zw.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},aT=({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[I.CTRL_OR_CMD])return!1;if(e.key===I.ESCAPE)return u(e),!0;if(e.key===I.ALT)return l(!0),!0;if(e.key===I.I)return l(),!0;let f=Rw({color:r,palette:n});if(e.key===I.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(Tt.black)),e.preventDefault(),e.stopPropagation(),!0}if(iT({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=rT(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=rT(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=rT(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=rT(e.key,t,a.length);if(n!==void 0){let e=a[n];return i(e),!0}}return!1},oT=V.forwardRef(({theme:e,color:t,onChange:n,type:r,elements:i,palette:a,updateData:o,children:s,showTitle:c,onEyeDropperToggle:l,onEscape:u,showHotKey:d=!0,excludedColors:f},p)=>{let m=c?r===`elementStroke`?G(`labels.stroke`):r===`elementBackground`?G(`labels.background`):null:null,[h]=V.useState(()=>r===`canvasBackground`?[]:Vw(i,r,a)),[g,_]=_b(Hw),v=Zw(),y=Rw({color:t,palette:a});(0,V.useEffect)(()=>{if(!g){let e=!!t&&Bw({color:t,palette:a}),n=e&&!h.includes(t);_(n?null:e?`custom`:y?.shade==null?`baseColors`:`shades`)}},[g,t,a,_,y,h]);let[b,x]=(0,V.useState)(y?.shade??(r===`elementBackground`?1:4));(0,V.useEffect)(()=>{y?.shade!=null&&x(y.shade);let e=e=>{e.key===I.ALT&&l(!1)};return document.addEventListener(R.KEYUP,e,{capture:!0}),()=>{document.removeEventListener(R.KEYUP,e,{capture:!0})}},[y,l]);let S=V.useRef(null);return(0,V.useImperativeHandle)(p,()=>S.current),(0,V.useEffect)(()=>{S?.current?.focus()},[]),(0,H.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":G(`labels.colorPicker`),children:(0,H.jsxs)(`div`,{ref:S,onKeyDown:e=>{aT({event:e,activeColorPickerSection:g,palette:a,color:t,onChange:n,onEyeDropperToggle:l,customColors:h,setActiveColorPickerSection:_,updateData:o,activeShade:b,onEscape:u,excludedColors:f})&&(e.preventDefault(),e.stopPropagation())},className:`color-picker-content properties-content`,tabIndex:-1,children:[m&&(0,H.jsx)(`div`,{className:`color-picker__title`,children:m}),!!h.length&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(tT,{children:G(`colorPicker.mostUsedCustomColors`)}),(0,H.jsx)($w,{theme:e,colors:h,color:t,label:G(`colorPicker.mostUsedCustomColors`),onChange:n})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(tT,{children:G(`colorPicker.colors`)}),(0,H.jsx)(eT,{theme:e,color:t,palette:a,onChange:n,activeShade:b,showHotKey:d,excludedColors:f})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(tT,{children:G(`colorPicker.shades`)}),(0,H.jsx)(nT,{theme:e,color:t,onChange:n,palette:a,showHotKey:d})]}),s,v&&(0,H.jsx)(`div`,{className:`color-picker__tip`,children:G(`colorPicker.topPicksTip`)})]})})}),sT=({theme:e,onChange:t,type:n,activeColor:r,topPicks:i,onReset:o,isCustomized:s})=>{let l=Zw(),u=l?.dragState??null,{container:d}=bH(),f;if(n===`elementStroke`&&(f=Tc),n===`elementBackground`&&(f=c),n===`canvasBackground`&&(f=he),i&&(f=i),!f)return console.error(`Invalid type for TopPicks`),null;let p=e=>{if(!u||u.origin.kind!==`pick`||u.overIndex===null)return 0;let t=u.origin.index,n=u.overIndex;if(t===n)return 0;let r=e;return e===t?r=n:(e>t&&--r,r>=n&&(r+=1)),(r-e)*u.slotSpan},m=(0,H.jsxs)(`div`,{className:U(`color-picker__top-picks`,{"is-dnd-active":!!u}),ref:l?.setStripEl,children:[u&&(0,H.jsx)(`svg`,{className:`color-picker__top-picks__dnd-outline`,"aria-hidden":`true`,children:(0,H.jsx)(`rect`,{})}),f.map((n,i)=>{let o=p(i),s=Hn(n,e===N.DARK);return(0,H.jsx)(`button`,{className:U(`color-picker__button`,{active:n===r,"is-transparent":n===`transparent`||!n,"has-outline":!a(n,240),"is-dnd-source":u?.origin.kind===`pick`&&u.origin.index===i,"is-dnd-target":u?.origin.kind===`swatch`&&u.overIndex===i,"is-dnd-duplicate":u?.duplicateIndex===i}),style:{"--swatch-color":s,transform:o?`translateX(${o}px)`:void 0},type:`button`,title:n,onClick:()=>t(n),onPointerDown:l?e=>l.startPickDrag(e,i,n):void 0,"data-testid":`color-top-pick-${n}`,"data-top-pick-index":i,children:(0,H.jsx)(`div`,{className:`color-picker__button-outline`})},n)})]});return o?(0,H.jsxs)(L_,{children:[(0,H.jsx)(R_,{asChild:!0,children:m}),(0,H.jsx)(z_,{container:d,children:(0,H.jsx)(B_,{className:`color-picker__context-menu`,style:{zIndex:`var(--zIndex-ui-styles-popup)`},children:(0,H.jsx)(V_,{className:`color-picker__context-menu-item`,disabled:!s,onSelect:o,children:G(`colorPicker.resetTopPicks`)})})})]}):m},cT=({type:e,color:t,onChange:n,label:r,elements:i,palette:a=Tt,updateData:o,getOpenPopup:s,appState:c,excludedColors:l})=>{let{container:u}=bH(),d=yH(),f=d!==`full`,p=d===`mobile`,[,m]=_b(Hw),[h,g]=_b(Ow),_=(0,H.jsxs)(`div`,{children:[(0,H.jsx)(tT,{children:G(`colorPicker.hexCode`)}),(0,H.jsx)(Uw,{color:t||``,label:r,onChange:e=>{n(e)},colorPickerType:e,placeholder:G(`colorPicker.color`)})]}),v=(0,V.useRef)(null),y=()=>{v.current?.focus()};return(0,H.jsx)(jw,{container:u,style:{maxWidth:`13rem`},preventAutoFocusOnTouch:!!c.editingTextElement,onFocusOutside:e=>{if(e.target instanceof HTMLElement&&e.target.closest(`.color-picker__context-menu`)){e.preventDefault();return}Ee(e.target)||(e.target instanceof HTMLElement&&e.target.matches(`:active`)?window.addEventListener(`pointerup`,y,{once:!0}):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,H.jsx)(oT,{ref:v,palette:a,excludedColors:l,color:t,theme:c.theme,onChange:e=>{let t=c.editingTextElement?Nw():null;n(e),c.editingTextElement&&t&&Pw(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:_}):_})},lT=e=>e===`elementStroke`||e===`elementBackground`||e===`canvasBackground`,uT=({label:e,color:t,type:n,theme:r,mode:i=`background`,onToggle:o,editingTextElement:s})=>{let c=yH(),l=c!==`full`,u=c===`mobile`,d=Zw(),f=t?Hn(t,r===N.DARK):null;return(0,H.jsxs)(ny,{type:`button`,className:U(`color-picker__button active-color properties-trigger`,{"is-transparent":!t||t===`transparent`,"has-outline":!t||!a(t,240),"compact-sizing":l,"mobile-border":u}),"aria-label":e,style:f?{"--swatch-color":f}:void 0,title:G(n===`elementStroke`?`labels.showStroke`:`labels.showBackground`),"data-openpopup":n,onClick:e=>{e.preventDefault(),e.stopPropagation(),s&&Lw(),o()},onPointerDown:d?e=>d.startSwatchDrag(e,t):void 0,children:[(0,H.jsx)(`div`,{className:`color-picker__button-outline`,children:!t&&Mx}),l&&t&&i===`stroke`&&(0,H.jsx)(`div`,{className:`color-picker__button-background`,children:(0,H.jsx)(`span`,{style:{color:f&&a(f,240)?`#fff`:`#111`},children:XC})})]})},dT=(0,V.memo)(({type:e,color:t,onChange:n,label:r,elements:i,palette:a=Tt,topPicks:o,updateData:s,appState:l,excludedColors:u,customizableTopPicks:d})=>{let f=(0,V.useRef)(l.openPopup);(0,V.useEffect)(()=>{f.current=l.openPopup},[l.openPopup]);let p=yH()!==`full`,m=!!d&&!p,h=m&&d?l.colorTopPicks?.[d]:null,g=Qw({enabled:m,picks:h?.length?h:o??(e===`elementStroke`?Tc:c),onPicksChange:e=>{d&&s({colorTopPicks:{...l.colorTopPicks,[d]:e}})}});return(0,H.jsx)(Xw.Provider,{value:m?g:null,children:(0,H.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,className:U(`color-picker-container`,{"color-picker-container--no-top-picks":p}),children:[!p&&(0,H.jsx)(sT,{theme:l.theme,activeColor:t,onChange:t=>{n(t),lT(l.openPopup)&&l.openPopup!==e&&setTimeout(()=>s({openPopup:e}),0)},type:e,topPicks:h?.length?h:o,isCustomized:!!h?.length,onReset:m&&d?()=>{s({colorTopPicks:{...l.colorTopPicks,[d]:null}})}:void 0}),!p&&(0,H.jsx)(vw,{}),(0,H.jsxs)(ty,{open:l.openPopup===e,onOpenChange:t=>{t&&s({openPopup:e})},children:[(0,H.jsx)(uT,{color:t,label:r,type:e,theme:l.theme,mode:e===`elementStroke`?`stroke`:`background`,editingTextElement:!!l.editingTextElement,onToggle:()=>{l.openPopup===e?s({openPopup:null}):(l.openPopup,s({openPopup:e}))}}),l.openPopup===e&&(0,H.jsx)(cT,{type:e,color:t,onChange:n,label:r,elements:i,palette:a,excludedColors:u,updateData:s,getOpenPopup:()=>f.current,appState:l})]})]})})},(e,t)=>e.appState.openPopup===e.type||t.appState.openPopup===t.type?!1:e.type===t.type&&e.color===t.color&&e.label===t.label&&e.appState.openPopup===t.appState.openPopup&&e.palette===t.palette&&e.topPicks===t.topPicks&&e.excludedColors===t.excludedColors&&e.customizableTopPicks===t.customizableTopPicks&&e.appState.theme===t.appState.theme&&e.appState.colorTopPicks===t.appState.colorTopPicks&&!!e.appState.editingTextElement==!!t.appState.editingTextElement),fT=V.forwardRef(({className:e,placeholder:t,onChange:n},r)=>(0,H.jsxs)(`div`,{className:U(`QuickSearch__wrapper`,e),children:[xC,(0,H.jsx)(`input`,{ref:r,className:`QuickSearch__input`,type:`text`,placeholder:t,onChange:e=>n(e.target.value.trim().toLowerCase())})]})),pT=({className:e,placeholder:t,children:n})=>{let r=!V.Children.count(n);return(0,H.jsx)(`div`,{className:U(`ScrollableList__wrapper`,e),role:`menu`,children:r?(0,H.jsx)(`div`,{className:`empty`,children:t}):n})},mT=({children:e,className:t=``,style:n,title:r})=>(0,H.jsxs)(`div`,{className:`dropdown-menu-group ${t}`,style:n,children:[r&&(0,H.jsx)(`p`,{className:`dropdown-menu-group-title`,children:r}),e]}),hT=mT;mT.displayName=`DropdownMenuGroup`;var gT=V.createContext({}),_T=(e=``,t=!1,n=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e} ${t?`dropdown-menu-item--selected`:``} ${n?`dropdown-menu-item--hovered`:``}`.trim(),vT=e=>{let t=(0,V.useContext)(gT);return jo(e,e=>{t.onSelect?.(e)})},yT=({children:e,...t})=>(0,H.jsx)(`span`,{...t,style:{textOverflow:`ellipsis`,overflow:`hidden`,whiteSpace:`nowrap`,...t.style},children:e}),bT=({textStyle:e,icon:t,shortcut:n,children:r,badge:i})=>{let a=vH();return(0,H.jsxs)(H.Fragment,{children:[t&&(0,H.jsx)(`div`,{className:`dropdown-menu-item__icon`,children:t}),(0,H.jsx)(`div`,{style:e,className:`dropdown-menu-item__text`,children:(0,H.jsx)(yT,{children:r})}),i&&(0,H.jsx)(`div`,{className:`dropdown-menu-item__badge`,children:i}),n&&a.formFactor!==`phone`&&(0,H.jsx)(`div`,{className:`dropdown-menu-item__shortcut`,children:n})]})},xT=({icon:e,badge:t,value:n,children:r,shortcut:i,className:a,selected:o,onSelect:s,...c})=>{let l=vT(s);return(0,H.jsx)(Tv,{className:`radix-menu-item`,onSelect:l,asChild:!0,children:(0,H.jsx)(`button`,{...c,value:n,className:_T(a,o),title:c.title??c[`aria-label`],children:(0,H.jsx)(bT,{icon:e,shortcut:i,badge:t,children:r})})})};xT.displayName=`DropdownMenuItem`;var ST={GREEN:`green`,RED:`red`,BLUE:`blue`},CT=({type:e=ST.BLUE,children:t})=>{let{theme:n}=SH(),r={display:`inline-flex`,marginLeft:`auto`,padding:`2px 4px`,borderRadius:6,fontSize:9,fontFamily:`Cascadia, monospace`,border:n===N.LIGHT?`1.5px solid white`:`none`};switch(e){case ST.GREEN:Object.assign(r,{backgroundColor:`var(--background-color-badge)`,color:`var(--color-badge)`});break;case ST.RED:Object.assign(r,{backgroundColor:`pink`,color:`darkred`});break;case ST.BLUE:default:Object.assign(r,{background:`var(--color-promo)`,color:`var(--color-surface-lowest)`})}return(0,H.jsx)(`div`,{className:`DropDownMenuItemBadge`,style:r,children:t})};CT.displayName=`DropdownMenuItemBadge`,xT.Badge=CT;var wT=xT,TT=({event:e,inputRef:t,hoveredFont:n,filteredFonts:r,onClose:i,onSelect:a,onHover:o})=>{if(!e[I.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===I.F)return t.current?.focus(),!0;if(e.key===I.ESCAPE)return i(),!0;if(e.key===I.ENTER)return n?.value&&a(n.value),!0;if(e.key===I.ARROW_DOWN)return n?.next?o(n.next.value):r[0]?.value&&o(r[0].value),!0;if(e.key===I.ARROW_UP)return n?.prev?o(n.prev.value):r[r.length-1]?.value&&o(r[r.length-1].value),!0},ET=e=>{switch(e){case Zo.Excalifont:case Zo.Virgil:return ix;case Zo.Nunito:case Zo.Helvetica:return HS;case Zo[`Lilita One`]:return VS;case Zo[`Comic Shanns`]:case Zo.Cascadia:return WS;default:return HS}},DT=(e,t)=>Object.entries(Zo).find(([,t])=>t===e)?.[0]??t[0]?.fontFace?.family??`Unknown`,OT=V.memo(({selectedFontFamily:e,hoveredFontFamily:t,onSelect:n,onHover:r,onLeave:i,onOpen:a,onClose:o})=>{let{container:s}=bH(),c=gH(),{fonts:l}=c,{showDeprecatedFonts:u}=_H(),d=yH(),[f,p]=(0,V.useState)(``),m=(0,V.useRef)(null),h=(0,V.useMemo)(()=>Array.from(vn.registered.entries()).filter(([e,{metadata:t}])=>!t.private&&!t.fallback).map(([e,{metadata:t,fontFaces:n}])=>{let r={value:e,icon:ET(e),text:DT(e,n)};return t.deprecated&&Object.assign(r,{deprecated:t.deprecated,badge:{type:ST.RED,placeholder:G(`fontList.badge.old`)}}),r}).sort((e,t)=>e.text.toLowerCase()>t.text.toLowerCase()?1:-1),[]),g=(0,V.useMemo)(()=>new Set(l.getSceneFamilies()),[e]),_=(0,V.useMemo)(()=>h.filter(e=>g.has(e.value)),[h,g]),v=(0,V.useMemo)(()=>h.filter(e=>!g.has(e.value)&&(u||!e.deprecated)),[h,g,u]),y=(0,V.useMemo)(()=>S([..._,...v].filter(e=>e.text?.toLowerCase().includes(f))),[_,v,f]),b=(0,V.useMemo)(()=>{let n;return t?n=y.find(e=>e.value===t):e&&(n=y.find(t=>t.value===e)),!n&&f&&(y[0]?.value?r(y[0].value):i()),n},[t,e,f,y,r,i]),x=(0,V.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,V.useCallback)(e=>{TT({event:e,inputRef:m,hoveredFont:b,filteredFonts:y,onSelect:x,onHover:r,onClose:o})&&(e.preventDefault(),e.stopPropagation())},[b,y,x,r,o]);(0,V.useEffect)(()=>(a(),()=>{o()}),[]);let w=(0,V.useMemo)(()=>y.filter(e=>g.has(e.value)),[y,g]),T=(0,V.useMemo)(()=>y.filter(e=>!g.has(e.value)),[y,g]),E=({font:t,order:n})=>{let i=(0,V.useRef)(null),a=t.value===b?.value,o=t.value===e;return(0,V.useEffect)(()=>{a&&(n===0?i.current?.scrollIntoView?.({block:`end`}):i.current?.scrollIntoView?.({block:`nearest`}))},[a,n]),(0,H.jsx)(`button`,{ref:i,type:`button`,value:t.value,className:_T(``,o,a),title:t.text,tabIndex:o?0:-1,onClick:e=>{x(Number(e.currentTarget.value))},onMouseMove:()=>{b?.value!==t.value&&r(t.value)},children:(0,H.jsx)(bT,{icon:t.icon,badge:t.badge&&(0,H.jsx)(CT,{type:t.badge.type,children:t.badge.placeholder}),textStyle:{fontFamily:Fi({fontFamily:t.value})},children:t.text})})},D=[];return w.length&&D.push((0,H.jsx)(hT,{title:G(`fontList.sceneFonts`),children:w.map((e,t)=>(0,H.jsx)(E,{font:e,order:t},e.value))},`group_1`)),T.length&&D.push((0,H.jsx)(hT,{title:G(`fontList.availableFonts`),children:T.map((e,t)=>(0,H.jsx)(E,{font:e,order:t+w.length},e.value))},`group_2`)),(0,H.jsxs)(jw,{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,H.jsx)(fT,{ref:m,placeholder:G(`quickSearch.placeholder`),onChange:Ss(p,20)}),(0,H.jsx)(pT,{className:`dropdown-menu fonts manual-hover`,placeholder:G(`fontList.empty`),children:D.length?D:null})]})},(e,t)=>e.selectedFontFamily===t.selectedFontFamily&&e.hoveredFontFamily===t.hoveredFontFamily),kT=({selectedFontFamily:e,isOpened:t=!1,compactMode:n=!1})=>{let r=CH(),i=n?{...Ne,width:`2rem`,height:`2rem`}:{};return(0,H.jsx)(ny,{asChild:!0,children:(0,H.jsx)(`div`,{"data-openpopup":`fontFamily`,className:`properties-trigger`,children:(0,H.jsx)(Y,{type:`toggle`,icon:ax,title:G(`labels.showFonts`),"aria-label":G(`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}})})})},AT=[{value:Zo.Excalifont,icon:ix,text:G(`labels.handDrawn`),testId:`font-family-hand-drawn`},{value:Zo.Nunito,icon:HS,text:G(`labels.normal`),testId:`font-family-normal`},{value:Zo[`Comic Shanns`],icon:WS,text:G(`labels.code`),testId:`font-family-code`}];new Set(AT.map(e=>e.value));var jT=V.memo(({isOpened:e,selectedFontFamily:t,hoveredFontFamily:n,onSelect:r,onHover:i,onLeave:a,onPopupChange:o,compactMode:s=!1})=>{let c=(0,V.useMemo)(()=>AT,[]),l=(0,V.useCallback)(e=>{e&&r(e)},[r]);return(0,H.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,className:U(`FontPicker__container`,{"FontPicker__container--compact":s}),children:[!s&&(0,H.jsx)(`div`,{className:`buttonList`,children:(0,H.jsx)(_w,{type:`button`,options:c,value:t,onClick:l})}),!s&&(0,H.jsx)(vw,{}),(0,H.jsxs)(ty,{open:e,onOpenChange:o,children:[(0,H.jsx)(kT,{selectedFontFamily:t,isOpened:e,compactMode:s}),e&&(0,H.jsx)(OT,{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),MT=({className:e,icon:t,size:n=`1em`})=>(0,H.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}),NT=({label:e,open:t,openTrigger:n,children:r,className:i,showCollapsedIcon:a=!0})=>(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{style:{cursor:`pointer`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},className:i,onClick:n,children:[e,a&&(0,H.jsx)(MT,{icon:t?GC:WC})]}),t&&(0,H.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`},children:r})]}),PT=Yc(!1),FT=4,IT=`default`,LT=e=>e.flatMap(e=>e.options),RT=(e,t)=>{for(let n of e){let e=n.options.find(t);if(e)return e}return null},zT=(e,t)=>e.some(e=>e.options.some(t)),BT=e=>e.flatMap(e=>Array.from({length:Math.ceil(e.options.length/FT)},(t,n)=>e.options.slice(n*FT,n*FT+FT)));function VT({visibleSections:e,hiddenSections:t=[],value:n,label:r,onChange:i,onClose:a}){let{container:o}=bH(),[s,c]=_b(PT),l=LT([...e,...t]),u=BT([...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===I.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(To(e.key)){let t=jb().rtl,r=l.findIndex(e=>e.value===n);if(r!==-1){let a=l.length,o=r;switch(e.key){case t?I.ARROW_LEFT:I.ARROW_RIGHT:o=(r+1)%a;break;case t?I.ARROW_RIGHT:I.ARROW_LEFT:o=(a+r-1)%a;break;case I.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 I.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===I.ESCAPE||e.key===I.ENTER)&&(e.preventDefault(),a());e.nativeEvent.stopImmediatePropagation(),e.stopPropagation()};(0,V.useEffect)(()=>{zT(t,e=>e.value===n)&&c(!0)},[n,t,c]);let f=e=>(0,H.jsx)(`div`,{className:`picker-content`,children:e.map(e=>(0,H.jsxs)(`button`,{type:`button`,className:U(`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,H.jsx)(`span`,{className:`picker-keybinding`,children:e.keyBinding})]},e.text))}),p=e=>e.map((e,t)=>e.name===IT?(0,H.jsx)(V.Fragment,{children:f(e.options)},`${e.name}-${t}`):(0,H.jsxs)(`div`,{className:`picker-section`,children:[(0,H.jsx)(`div`,{className:`picker-section-label`,children:e.name}),f(e.options)]},`${e.name}-${t}`));return(0,H.jsx)(iy,{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,H.jsxs)(`div`,{className:`picker-sections`,children:[p(e),t.length>0&&(0,H.jsx)(NT,{label:G(`labels.more_options`),open:s,openTrigger:()=>{c(e=>!e)},className:`picker-collapsible`,children:(0,H.jsx)(`div`,{className:`picker-sections`,children:p(t)})})]})})}function HT({value:e,label:t,visibleSections:n,hiddenSections:r,onChange:i}){let[a,o]=V.useState(!1),s=(0,V.useMemo)(()=>RT(n,t=>t.value===e)??RT(r??[],t=>t.value===e),[n,r,e]);return(0,H.jsx)(`div`,{children:(0,H.jsxs)(ty,{open:a,onOpenChange:e=>o(e),children:[(0,H.jsx)(ny,{type:`button`,"aria-label":t,onClick:()=>o(!a),className:a?`active`:``,children:s?.icon}),a&&(0,H.jsx)(VT,{visibleSections:n,hiddenSections:r,value:e,label:t,onChange:i,onClose:()=>{o(!1)}})]})})}var UT=({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=V.useRef(null),u=V.useRef(null);return(0,V.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,H.jsxs)(`label`,{className:`control-label`,children:[e,(0,H.jsxs)(`div`,{className:`range-wrapper`,children:[(0,H.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,H.jsx)(`div`,{className:`value-bubble`,ref:u,children:t===r?null:t}),(0,H.jsx)(`div`,{className:`zero-label`,children:o})]})]})},WT=.1,GT=e=>{let t=rt(e.editorInterface);return{stylesPanelMode:t,isCompact:t!==`full`,isMobile:t===`mobile`}},KT=(e,t,n,r=!1)=>{let i=ze(is(e,t,{includeBoundTextElement:r}));return e.map(e=>i.get(e.id)||e.id===t.editingTextElement?.id?(Un(e)||console.error(`[NONDELETED][INVARIANT] changeProperty(): skipping deleted selected/editing element`),n(e)):e)},qT=function(e,t,n,r,i){let a=t.state.editingTextElement,o=At(e),s=null;if(a&&(s=n(a)),!s){if(Ki(o,t.state)){let e=t.scene.getSelectedElements(t.state),a=r===!0?e:e.filter(e=>r(e));s=_e(a,n)??(typeof i==`function`?i(!0):i)}else s=typeof i==`function`?i(!1):i}return s},JT=(e,t,n)=>fs(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}),YT=(e,t,n,r,i)=>{let a=new Set,o=KT(e,t,e=>{if(F(e)){let t=r(e);a.add(t);let i=z(e,{fontSize:t});return ga(i,n.scene.getContainerElement(e),n.scene),i=JT(e,i,n.scene),i}return e},!0);return is(e,t,{includeBoundTextElement:!0}).forEach(e=>{F(e)&&zt(e,n.scene)}),{elements:o,appState:{...t,currentItemFontSize:a.size===1?[...a][0]:i??t.currentItemFontSize},captureUpdate:j.IMMEDIATELY}};X({name:`changeStrokeColor`,label:`labels.stroke`,trackEvent:!1,perform:(e,t,n)=>({...n?.currentItemStrokeColor&&{elements:KT(e,t,e=>Cr(e.type)?z(e,{strokeColor:n.currentItemStrokeColor}):e,!0)},appState:{...t,...n},captureUpdate:n?.currentItemStrokeColor?j.IMMEDIATELY:j.EVENTUALLY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r,data:i})=>{let{stylesPanelMode:a}=GT(r);return(0,H.jsxs)(H.Fragment,{children:[a===`full`&&(0,H.jsx)(`h3`,{"aria-hidden":`true`,children:G(`labels.stroke`)}),(0,H.jsx)(dT,{topPicks:Tc,palette:Ui,customizableTopPicks:`elementStroke`,type:`elementStroke`,label:G(`labels.stroke`),color:qT(e,r,e=>e.strokeColor,!0,e=>e?null:t.currentItemStrokeColor),onChange:e=>n({currentItemStrokeColor:e}),elements:e,appState:t,updateData:n})]})}}),X({name:`changeBackgroundColor`,label:`labels.changeBackground`,trackEvent:!1,perform:(e,t,n,r)=>{if(!n?.currentItemBackgroundColor)return{appState:{...t,...n},captureUpdate:j.EVENTUALLY};let i,a=r.scene.getSelectedElements(t);if(!Aa(n.currentItemBackgroundColor)&&a.every(e=>Me(e)&&sc(e.points))){let t=ze(a);i=e.map(e=>t.has(e.id)&&Me(e)?z(e,{backgroundColor:n.currentItemBackgroundColor,...Ir(e,!0)}):e)}else i=KT(e,t,e=>z(e,{backgroundColor:n.currentItemBackgroundColor}));return{elements:i,appState:{...t,...n},captureUpdate:j.IMMEDIATELY}},PanelComponent:({elements:e,appState:t,updateData:n,app:r,data:i})=>{let{stylesPanelMode:a}=GT(r);return(0,H.jsxs)(H.Fragment,{children:[a===`full`&&(0,H.jsx)(`h3`,{"aria-hidden":`true`,children:G(`labels.background`)}),(0,H.jsx)(dT,{topPicks:c,palette:Ze,customizableTopPicks:`elementBackground`,type:`elementBackground`,label:G(`labels.background`),color:qT(e,r,e=>e.backgroundColor,!0,e=>e?null:t.currentItemBackgroundColor),onChange:e=>n({currentItemBackgroundColor:e}),elements:e,appState:t,updateData:n})]})}});var XT=X({name:`changeBucketFillBackgroundColor`,label:`labels.changeBackground`,trackEvent:!1,perform:(e,t,n)=>({appState:{...t,...n},captureUpdate:j.EVENTUALLY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>{let{stylesPanelMode:i}=GT(r);return(0,H.jsxs)(H.Fragment,{children:[i===`full`&&(0,H.jsx)(`h3`,{"aria-hidden":`true`,children:G(`labels.background`)}),(0,H.jsx)(dT,{topPicks:Ua,palette:Ze,excludedColors:[Tt.transparent],customizableTopPicks:`bucketFill`,type:`elementBackground`,label:G(`labels.background`),color:r.bucketFill.getBucketFillBackgroundColor(t.currentItemBackgroundColor),onChange:e=>n({currentItemBackgroundColor:e}),elements:e,appState:t,updateData:n})]})}});X({name:`changeFillStyle`,label:`labels.fill`,trackEvent:!1,perform:(e,t,n,r)=>(hw(`element`,`changeFillStyle`,`${n} (${r.editorInterface.formFactor===`phone`?`mobile`:`desktop`})`),{elements:KT(e,t,e=>z(e,{fillStyle:n})),appState:{...t,currentItemFillStyle:n},captureUpdate:j.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>{let i=is(e,t),a=i.length>0&&i.every(e=>e.fillStyle===`zigzag`);return(0,H.jsxs)(`fieldset`,{children:[(0,H.jsx)(`legend`,{children:G(`labels.fill`)}),(0,H.jsx)(`div`,{className:`buttonList`,children:(0,H.jsx)(_w,{type:`button`,options:[{value:`hachure`,text:`${G(a?`labels.zigzag`:`labels.hachure`)} (${Z(`Alt-Click`)})`,icon:a?aS:oS,active:a?!0:void 0,testId:`fill-hachure`},{value:`cross-hatch`,text:G(`labels.crossHatch`),icon:sS,testId:`fill-cross-hatch`},{value:`solid`,text:G(`labels.solid`),icon:cS,testId:`fill-solid`}],value:qT(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 ZT=e=>pi.find(t=>bc(e.type,t)===e.strokeWidth)??null,QT=(e,t)=>bc(e.type,t);X({name:`changeStrokeWidth`,label:`labels.strokeWidth`,trackEvent:!1,perform:(e,t,n)=>(ho(n,`actionChangeStrokeWidth: value must be defined`),{elements:KT(e,t,e=>z(e,{strokeWidth:QT(e,n)})),appState:{...t,currentItemStrokeWidthKey:n},captureUpdate:j.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r,data:i})=>(0,H.jsxs)(`fieldset`,{children:[(0,H.jsx)(`legend`,{children:G(`labels.strokeWidth`)}),(0,H.jsx)(`div`,{className:`buttonList`,children:(0,H.jsx)(_w,{group:`stroke-width`,options:[{value:`thin`,text:G(`labels.thin`),icon:lS,testId:`strokeWidth-thin`},{value:`medium`,text:G(`labels.medium`),icon:uS,testId:`strokeWidth-medium`},{value:`bold`,text:G(`labels.bold`),icon:dS,testId:`strokeWidth-bold`}],value:qT(e,r,ZT,e=>e.hasOwnProperty(`strokeWidth`),e=>e?null:t.currentItemStrokeWidthKey),onChange:e=>n(e)})})]})}),X({name:`changeSloppiness`,label:`labels.sloppiness`,trackEvent:!1,perform:(e,t,n)=>({elements:KT(e,t,e=>z(e,{seed:Ba(),roughness:n})),appState:{...t,currentItemRoughness:n},captureUpdate:j.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r,data:i})=>(0,H.jsxs)(`fieldset`,{children:[(0,H.jsx)(`legend`,{children:G(`labels.sloppiness`)}),(0,H.jsx)(`div`,{className:`buttonList`,children:(0,H.jsx)(_w,{group:`sloppiness`,options:[{value:0,text:G(`labels.architect`),icon:mS},{value:1,text:G(`labels.artist`),icon:hS},{value:2,text:G(`labels.cartoonist`),icon:gS}],value:qT(e,r,e=>e.roughness,e=>e.hasOwnProperty(`roughness`),e=>e?null:t.currentItemRoughness),onChange:e=>n(e)})})]})}),X({name:`changeFreedrawMode`,label:`labels.pressure`,trackEvent:!1,perform:(e,t,n)=>{let r=n||`constant`;return{elements:KT(e,t,e=>e.type===`freedraw`?z(e,{strokeOptions:{...e.strokeOptions,variability:r}}):e),appState:{...t,currentItemStrokeVariability:r},captureUpdate:j.IMMEDIATELY}},PanelComponent:({elements:e,appState:t,updateData:n,app:r,data:i})=>{let a=qT(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,H.jsx)(Y,{type:`button`,icon:e?vS:_S,title:G(`labels.pressure`),"aria-label":G(`labels.pressure`),onClick:()=>n(e?`constant`:`variable`)})}return(0,H.jsxs)(`fieldset`,{children:[(0,H.jsx)(`legend`,{children:G(`labels.pressure`)}),(0,H.jsx)(`div`,{className:`buttonList`,children:(0,H.jsx)(_w,{group:`strokeOptions.variability`,options:[{value:`constant`,text:G(`labels.pressure_constant`),icon:_S},{value:`variable`,text:G(`labels.pressure_variable`),icon:vS}],value:a,onChange:e=>n(e)})})]})}}),X({name:`changeStrokeStyle`,label:`labels.strokeStyle`,trackEvent:!1,perform:(e,t,n)=>({elements:KT(e,t,e=>z(e,{strokeStyle:n})),appState:{...t,currentItemStrokeStyle:n},captureUpdate:j.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r,data:i})=>(0,H.jsxs)(`fieldset`,{children:[(0,H.jsx)(`legend`,{children:G(`labels.strokeStyle`)}),(0,H.jsx)(`div`,{className:`buttonList`,children:(0,H.jsx)(_w,{group:`strokeStyle`,options:[{value:`solid`,text:G(`labels.strokeStyle_solid`),icon:lS},{value:`dashed`,text:G(`labels.strokeStyle_dashed`),icon:fS},{value:`dotted`,text:G(`labels.strokeStyle_dotted`),icon:pS}],value:qT(e,r,e=>e.strokeStyle,e=>e.hasOwnProperty(`strokeStyle`),e=>e?null:t.currentItemStrokeStyle),onChange:e=>n(e)})})]})}),X({name:`changeOpacity`,label:`labels.opacity`,trackEvent:!1,perform:(e,t,n)=>({elements:KT(e,t,e=>z(e,{opacity:n}),!0),appState:{...t,currentItemOpacity:n},captureUpdate:j.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,app:n,updateData:r})=>{let i=qT(e,n,e=>e.opacity,!0,e=>e?null:t.currentItemOpacity);return(0,H.jsx)(UT,{label:G(`labels.opacity`),value:i??t.currentItemOpacity,hasCommonValue:i!==null,onChange:r,min:0,max:100,step:10,testId:`opacity`})}}),X({name:`changeFontSize`,label:`labels.fontSize`,trackEvent:!1,perform:(e,t,n,r)=>YT(e,t,r,()=>(ho(n,`actionChangeFontSize: Expected a font size value`),n),n),PanelComponent:({elements:e,appState:t,updateData:n,app:r,data:i})=>{let{isCompact:a}=GT(r);return(0,H.jsxs)(`fieldset`,{children:[(0,H.jsx)(`legend`,{children:G(`labels.fontSize`)}),(0,H.jsx)(`div`,{className:`buttonList`,children:(0,H.jsx)(_w,{group:`font-size`,options:[{value:Fo.sm,text:G(`labels.small`),icon:IS,testId:`fontSize-small`},{value:Fo.md,text:G(`labels.medium`),icon:LS,testId:`fontSize-medium`},{value:Fo.lg,text:G(`labels.large`),icon:RS,testId:`fontSize-large`},{value:Fo.xl,text:G(`labels.veryLarge`),icon:zS,testId:`fontSize-veryLarge`}],value:qT(e,r,e=>{if(F(e))return e.fontSize;let t=ao(e,r.scene.getNonDeletedElementsMap());return t?t.fontSize:null},e=>F(e)||ao(e,r.scene.getNonDeletedElementsMap())!==null,e=>e?null:t.currentItemFontSize||20),onChange:e=>{Fw(()=>n(e),a,!!t.editingTextElement,i?.onPreventClose)}})})]})}});var $T=X({name:`decreaseFontSize`,label:`labels.decreaseFontSize`,icon:BS,trackEvent:!1,perform:(e,t,n,r)=>YT(e,t,r,e=>Math.round(1/(1+WT)*e.fontSize)),keyTest:e=>e[I.CTRL_OR_CMD]&&e.shiftKey&&(e.key===I.CHEVRON_LEFT||e.key===I.COMMA)}),eE=X({name:`increaseFontSize`,label:`labels.increaseFontSize`,icon:BS,trackEvent:!1,perform:(e,t,n,r)=>YT(e,t,r,e=>Math.round(e.fontSize*(1+WT))),keyTest:e=>e[I.CTRL_OR_CMD]&&e.shiftKey&&(e.key===I.CHEVRON_RIGHT||e.key===I.PERIOD)});X({name:`changeFontFamily`,label:`labels.fontFamily`,trackEvent:!1,perform:(e,t,n,r)=>{let{cachedElements:i,resetAll:a,resetContainers:o,...s}=n;if(a)return{elements:KT(e,t,e=>{let t=i?.get(e.id);return t?z(e,{...t}):e},!0),appState:{...t,...s},captureUpdate:j.NEVER};ho(n,`actionChangeFontFamily: value must be defined`);let{currentItemFontFamily:c,currentHoveredFontFamily:l}=n,u=j.EVENTUALLY,d,f=!1;if(c)d=c,u=j.IMMEDIATELY;else if(l){d=l,u=j.EVENTUALLY;let n=is(e,t,{includeBoundTextElement:!0}).filter(e=>F(e));if(n.length>200)f=!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&&(f=!0)}}let p={appState:{...t,...s},captureUpdate:u};if(d&&!f){let n=new Map,a=new Set,s=!1,u=Array.from(vn.loadedFontsCache.values()),f=Object.entries(Zo).find(([e,t])=>t===d)?.[0];l&&f&&u.some(e=>e.startsWith(f))&&(s=!0),Object.assign(p,{elements:KT(e,t,e=>{if(F(e)&&(e.fontFamily!==d||c)){let t=z(e,{fontFamily:d,lineHeight:sa(d)}),c=i?.get(e.containerId||``)||{},l=r.scene.getContainerElement(e);return o&&l&&c&&r.scene.mutateElement(l,{...c}),s||(a=new Set([...a,...Array.from(t.originalText)])),n.set(t,l),t}return e},!0)});let m=`10px ${Fi({fontFamily:d})}`,h=Array.from(a.values()).join();if(s||window.document.fonts.check(m,h))for(let[e,t]of n)ga(e,t,r.scene);else window.document.fonts.load(m,h).then(e=>{for(let[e,t]of n){let n=r.scene.getElement(e.id),i=t?r.scene.getElement(t.id):null;n&&ga(n,i,r.scene)}r.fonts.onLoaded(e)})}return p},PanelComponent:({elements:e,appState:t,app:n,updateData:r})=>{let i=(0,V.useRef)(new Map),a=(0,V.useRef)(null),[o,s]=(0,V.useState)({}),c=(0,V.useRef)(!0),{stylesPanelMode:l,isCompact:u}=GT(n),d=(0,V.useMemo)(()=>{let r=(e,r)=>qT(e,n,e=>{if(F(e))return e.fontFamily;let t=ao(e,r);return t?t.fontFamily:null},e=>F(e)||ao(e,r)!==null,e=>e?null:t.currentItemFontFamily||Pt);return o.openPopup===`fontFamily`&&t.openPopup===`fontFamily`?r(Array.from(i.current?.values()??[]),i.current):!o.openPopup&&t.openPopup!==`fontFamily`?r(e,n.scene.getNonDeletedElementsMap()):a.current},[o.openPopup,t,e,n]);return(0,V.useEffect)(()=>{a.current=d},[d]),(0,V.useEffect)(()=>{Object.keys(o).length&&(r(o),s({}))},[o]),(0,V.useEffect)(()=>(c.current=!1,()=>{c.current=!0}),[]),(0,H.jsxs)(H.Fragment,{children:[l===`full`&&(0,H.jsx)(`legend`,{children:G(`labels.fontFamily`)}),(0,H.jsx)(jT,{isOpened:t.openPopup===`fontFamily`,selectedFontFamily:d,hoveredFontFamily:t.currentHoveredFontFamily,compactMode:l!==`full`,onSelect:e=>{Fw(()=>{s({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:e}),i.current.clear()},u,!!t.editingTextElement)},onHover:e=>{s({currentHoveredFontFamily:e,cachedElements:new Map(i.current),resetContainers:!0})},onLeave:()=>{s({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,z(e||r,{},!0))}else{let n=is(e,t,{includeBoundTextElement:!0});for(let e of n)i.current.set(e.id,z(e,{},!0))}s({...o,openPopup:`fontFamily`})}else{let e={currentHoveredFontFamily:null,cachedElements:new Map(i.current),resetAll:!0};s({...e}),i.current.clear(),u&&t.editingTextElement&&Pw(null)}}})]})}}),X({name:`changeTextAlign`,label:`Change text alignment`,trackEvent:!1,perform:(e,t,n,r)=>({elements:KT(e,t,e=>{if(F(e)){let t=z(e,{textAlign:n});return ga(t,r.scene.getContainerElement(e),r.scene),t}return e},!0),appState:{...t,currentItemTextAlign:n},captureUpdate:j.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r,data:i})=>{let a=r.scene.getNonDeletedElementsMap(),{isCompact:o}=GT(r);return(0,H.jsxs)(`fieldset`,{children:[(0,H.jsx)(`legend`,{children:G(`labels.textAlign`)}),(0,H.jsx)(`div`,{className:`buttonList`,children:(0,H.jsx)(_w,{group:`text-align`,options:[{value:`left`,text:G(`labels.left`),icon:GS,testId:`align-left`},{value:`center`,text:G(`labels.center`),icon:KS,testId:`align-horizontal-center`},{value:`right`,text:G(`labels.right`),icon:qS,testId:`align-right`}],value:qT(e,r,e=>{if(F(e))return e.textAlign;let t=ao(e,a);return t?t.textAlign:null},e=>F(e)||ao(e,a)!==null,e=>e?null:t.currentItemTextAlign),onChange:e=>{Fw(()=>n(e),o,!!t.editingTextElement,i?.onPreventClose)}})})]})}}),X({name:`changeVerticalAlign`,label:`Change vertical alignment`,trackEvent:{category:`element`},perform:(e,t,n,r)=>({elements:KT(e,t,e=>{if(F(e)){let t=z(e,{verticalAlign:n});return ga(t,r.scene.getContainerElement(e),r.scene),t}return e},!0),appState:{...t},captureUpdate:j.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r,data:i})=>{let{isCompact:a}=GT(r);return(0,H.jsx)(`fieldset`,{children:(0,H.jsx)(`div`,{className:`buttonList`,children:(0,H.jsx)(_w,{group:`text-align`,options:[{value:D.TOP,text:G(`labels.alignTop`),icon:(0,H.jsx)(JS,{theme:t.theme}),testId:`align-top`},{value:D.MIDDLE,text:G(`labels.centerVertically`),icon:(0,H.jsx)(XS,{theme:t.theme}),testId:`align-middle`},{value:D.BOTTOM,text:G(`labels.alignBottom`),icon:(0,H.jsx)(YS,{theme:t.theme}),testId:`align-bottom`}],value:qT(e,r,e=>{if(F(e)&&e.containerId)return e.verticalAlign;let t=ao(e,r.scene.getNonDeletedElementsMap());return t?t.verticalAlign:null},e=>F(e)||ao(e,r.scene.getNonDeletedElementsMap())!==null,e=>e?null:D.MIDDLE),onChange:e=>{Fw(()=>n(e),a,!!t.editingTextElement,i?.onPreventClose)}})})})}}),X({name:`changeRoundness`,label:`Change edge roundness`,trackEvent:!1,perform:(e,t,n)=>({elements:KT(e,t,e=>fe(e)?e:z(e,{roundness:n===`round`?{type:at(e.type)?qi.ADAPTIVE_RADIUS:qi.PROPORTIONAL_RADIUS}:null})),appState:{...t,currentItemRoundness:n},captureUpdate:j.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r,renderAction:i})=>{let a=Xs(At(e),t).some(e=>e.roundness?.type===qi.LEGACY);return(0,H.jsxs)(`fieldset`,{children:[(0,H.jsx)(`legend`,{children:G(`labels.edges`)}),(0,H.jsxs)(`div`,{className:`buttonList`,children:[(0,H.jsx)(_w,{group:`edges`,options:[{value:`sharp`,text:G(`labels.sharp`),icon:yS},{value:`round`,text:G(`labels.round`),icon:bS}],value:qT(e,r,e=>a?null:e.roundness?`round`:`sharp`,e=>!Wa(e)&&e.hasOwnProperty(`roundness`),e=>e?null:t.currentItemRoundness),onChange:e=>n(e)}),i(`togglePolygon`)]})]})}});var tE=e=>({visibleSections:[{name:`default`,options:[{value:null,text:G(`labels.arrowhead_none`),keyBinding:`q`,icon:(0,H.jsx)(xS,{flip:e})},{value:`arrow`,text:G(`labels.arrowhead_arrow`),keyBinding:`w`,icon:(0,H.jsx)(SS,{flip:e})},{value:`triangle`,text:G(`labels.arrowhead_triangle`),icon:(0,H.jsx)(CS,{flip:e}),keyBinding:`e`},{value:`triangle_outline`,text:G(`labels.arrowhead_triangle_outline`),icon:(0,H.jsx)(wS,{flip:e}),keyBinding:`r`}]}],hiddenSections:[{name:`default`,options:[{value:`circle`,text:G(`labels.arrowhead_circle`),keyBinding:`a`,icon:(0,H.jsx)(TS,{flip:e})},{value:`circle_outline`,text:G(`labels.arrowhead_circle_outline`),keyBinding:`s`,icon:(0,H.jsx)(ES,{flip:e})},{value:`diamond`,text:G(`labels.arrowhead_diamond`),icon:(0,H.jsx)(DS,{flip:e}),keyBinding:`d`},{value:`diamond_outline`,text:G(`labels.arrowhead_diamond_outline`),icon:(0,H.jsx)(OS,{flip:e}),keyBinding:`f`},{value:`bar`,text:G(`labels.arrowhead_bar`),keyBinding:`z`,icon:(0,H.jsx)(kS,{flip:e})}]},{name:G(`labels.cardinality`),options:[{value:`cardinality_one`,text:G(`labels.arrowhead_cardinality_one`),icon:(0,H.jsx)(AS,{flip:e}),keyBinding:`x`},{value:`cardinality_many`,text:G(`labels.arrowhead_cardinality_many`),icon:(0,H.jsx)(jS,{flip:e}),keyBinding:`c`},{value:`cardinality_one_or_many`,text:G(`labels.arrowhead_cardinality_one_or_many`),icon:(0,H.jsx)(MS,{flip:e}),keyBinding:`v`},{value:`cardinality_exactly_one`,text:G(`labels.arrowhead_cardinality_exactly_one`),icon:(0,H.jsx)(NS,{flip:e}),keyBinding:null},{value:`cardinality_zero_or_one`,text:G(`labels.arrowhead_cardinality_zero_or_one`),icon:(0,H.jsx)(PS,{flip:e}),keyBinding:null},{value:`cardinality_zero_or_many`,text:G(`labels.arrowhead_cardinality_zero_or_many`),icon:(0,H.jsx)(FS,{flip:e}),keyBinding:null}]}]});X({name:`changeArrowhead`,label:`Change arrowheads`,trackEvent:!1,perform:(e,t,n)=>(ho(n,`actionChangeArrowhead: value must be defined`),{elements:KT(e,t,e=>{if(vo(e)){let{position:t,type:r}=n;if(t===`start`)return z(e,{startArrowhead:r});if(t===`end`)return z(e,{endArrowhead:r})}return e}),appState:{...t,[n.position===`start`?`currentItemStartArrowhead`:`currentItemEndArrowhead`]:n.type},captureUpdate:j.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>{let i=jb().rtl,a=(0,V.useMemo)(()=>tE(!i),[i]),o=(0,V.useMemo)(()=>tE(!!i),[i]);return(0,H.jsxs)(`fieldset`,{children:[(0,H.jsx)(`legend`,{children:G(`labels.arrowheads`)}),(0,H.jsxs)(`div`,{className:`iconSelectList buttonList`,children:[(0,H.jsx)(HT,{visibleSections:a.visibleSections,hiddenSections:a.hiddenSections,label:`arrowhead_start`,value:qT(e,r,e=>vo(e)&&Ji(e.type)?fi(e.startArrowhead):t.currentItemStartArrowhead,!0,e=>e?null:t.currentItemStartArrowhead),onChange:e=>n({position:`start`,type:e})}),(0,H.jsx)(HT,{visibleSections:o.visibleSections,hiddenSections:o.hiddenSections,label:`arrowhead_end`,value:qT(e,r,e=>vo(e)&&Ji(e.type)?fi(e.endArrowhead):t.currentItemEndArrowhead,!0,e=>e?null:t.currentItemEndArrowhead),onChange:e=>n({position:`end`,type:e})})]})]})}}),X({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,H.jsxs)(`div`,{className:`selected-shape-actions`,children:[i(`changeArrowhead`),i(`changeArrowType`)]})}),X({name:`changeArrowType`,label:`Change arrow types`,trackEvent:!1,perform:(e,t,n,r)=>{let i=KT(e,t,e=>{if(!Wa(e))return e;let i=r.scene.getNonDeletedElementsMap(),a=M.getPointAtIndexGlobalCoordinates(e,0,i),o=M.getPointAtIndexGlobalCoordinates(e,-1,i),s=z(e,{x:n===Gi.elbow?a[0]:e.x,y:n===Gi.elbow?a[1]:e.y,roundness:n===Gi.round?{type:qi.PROPORTIONAL_RADIUS}:null,elbowed:n===Gi.elbow,angle:n===Gi.elbow?0:e.angle,points:n===Gi.elbow||e.elbowed?[M.pointFromAbsoluteCoords({...e,x:a[0],y:a[1],angle:0},a,i),M.pointFromAbsoluteCoords({...e,x:a[0],y:a[1],angle:0},o,i)]:e.points});if(fe(s)){s.fixedSegments=null;let e=r.scene.getNonDeletedElementsMap();r.dismissLinearEditor();let n=M.getPointAtIndexGlobalCoordinates(s,0,e),i=M.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,...$a(s,a,`start`,e,t.isBindingEnabled)}:null,l=o&&s.endBinding?{...s.endBinding,...$a(s,o,`end`,e,t.isBindingEnabled)}:null;s={...s,startBinding:c,endBinding:l,...Re(s,e,{points:[n,i].map(e=>A(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&&$n(s,n,t.bindMode===`inside`?`inside`:`orbit`,`start`,r.scene)}if(s.endBinding){let n=e.get(s.endBinding.elementId);n&&$n(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 M(t,ze(e)))}return{elements:i,appState:a,captureUpdate:j.IMMEDIATELY}},PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,H.jsxs)(`fieldset`,{children:[(0,H.jsx)(`legend`,{children:G(`labels.arrowtypes`)}),(0,H.jsx)(`div`,{className:`buttonList`,children:(0,H.jsx)(_w,{group:`arrowtypes`,options:[{value:Gi.sharp,text:G(`labels.arrowtype_sharp`),icon:VC,testId:`sharp-arrow`},{value:Gi.round,text:G(`labels.arrowtype_round`),icon:UC,testId:`round-arrow`},{value:Gi.elbow,text:G(`labels.arrowtype_elbowed`),icon:HC,testId:`elbow-arrow`}],value:qT(e,r,e=>Wa(e)?e.elbowed?Gi.elbow:e.roundness?Gi.round:Gi.sharp:null,e=>Wa(e),e=>e?null:t.currentItemArrowType),onChange:e=>n(e)})})]})});var nE=()=>{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},rE=(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`})},iE=(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,rE(t,e.getBoundingClientRect())},aE=({children:e,label:t,long:n=!1,style:r,disabled:i})=>((0,V.useEffect)(()=>()=>nE().classList.remove(`excalidraw-tooltip--visible`),[]),i?null:(0,H.jsx)(`div`,{className:`excalidraw-tooltip-wrapper`,onPointerEnter:e=>iE(e.currentTarget,nE(),t,n),onPointerLeave:()=>nE().classList.remove(`excalidraw-tooltip--visible`),style:r,children:e})),oE=(e,t)=>typeof t==`function`?t(e):Array.isArray(t)?e:e[t],sE=(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},kr())}return oE(r,t)};function cE(e,t=!0){let n=TH(),[,r]=(0,V.useState)(0),i=(0,V.useRef)(null);return i.current||={selector:e,isInitialized:!!n,latestValue:sE(n,e,t)},i.current.selector=e,!i.current.isInitialized&&n&&!n.isDestroyed&&(i.current.isInitialized=!0,i.current.latestValue=sE(n,e,t)),(0,V.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 lE(e,t){let n=TH(),r=(0,V.useRef)({selector:e,callback:t});r.current.selector=e,r.current.callback=t,(0,V.useEffect)(()=>{if(!(!n||n.isDestroyed))return r.current.callback(sE(n,r.current.selector,!0),n.getAppState()),n.onStateChange(r.current.selector,(e,t)=>{r.current.callback(e,t)})},[n])}X({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?j.IMMEDIATELY:j.EVENTUALLY}),PanelComponent:({elements:e,appState:t,updateData:n,appProps:r,data:i})=>(0,H.jsx)(dT,{palette:null,topPicks:he,label:G(`labels.canvasBackground`),type:`canvasBackground`,color:t.viewBackgroundColor,onChange:e=>n({viewBackgroundColor:e}),"data-testid":`canvas-background-picker`,elements:e,appState:t,updateData:n})});var uE=X({name:`clearCanvas`,label:`labels.clearCanvas`,icon:fx,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=>z(e,{isDeleted:!0})),appState:{...kr(),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,colorTopPicks:t.colorTopPicks,activeTool:t.activeTool.type===`image`?{...t.activeTool,type:r.state.preferredSelectionTool.type}:t.activeTool},captureUpdate:j.IMMEDIATELY})}),dE=X({name:`zoomIn`,label:`buttons.zoomIn`,viewMode:!0,navigation:!0,icon:lx,trackEvent:{category:`canvas`},predicate:(e,t,n,r)=>r.isNavigationEnabled(),perform:(e,t,n,r)=>(r.requestUnfollow(),{appState:{...t,...Li({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:bi(t.zoom.value+an)},t)},captureUpdate:j.EVENTUALLY}),PanelComponent:({updateData:e})=>{let t=cE(e=>e.zoom.value);return(0,H.jsx)(Y,{type:`button`,className:`zoom-in-button zoom-button`,icon:lx,title:`${G(`buttons.zoomIn`)} \u2014 ${Z(`CtrlOrCmd++`)}`,"aria-label":G(`buttons.zoomIn`),disabled:t>=30,onClick:()=>{e(null)}})},keyTest:e=>(e.code===ir.EQUAL||e.code===ir.NUM_ADD)&&(e[I.CTRL_OR_CMD]||e.shiftKey)}),fE=X({name:`zoomOut`,label:`buttons.zoomOut`,icon:ux,viewMode:!0,navigation:!0,trackEvent:{category:`canvas`},predicate:(e,t,n,r)=>r.isNavigationEnabled(),perform:(e,t,n,r)=>(r.requestUnfollow(),{appState:{...t,...Li({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:bi(t.zoom.value-an)},t)},captureUpdate:j.EVENTUALLY}),PanelComponent:({updateData:e})=>{let t=cE(e=>e.zoom.value);return(0,H.jsx)(Y,{type:`button`,className:`zoom-out-button zoom-button`,icon:ux,title:`${G(`buttons.zoomOut`)} \u2014 ${Z(`CtrlOrCmd+-`)}`,"aria-label":G(`buttons.zoomOut`),disabled:t<=Yo,onClick:()=>{e(null)}})},keyTest:e=>(e.code===ir.MINUS||e.code===ir.NUM_SUBTRACT)&&(e[I.CTRL_OR_CMD]||e.shiftKey)}),pE=X({name:`resetZoom`,label:`buttons.resetZoom`,icon:dx,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,...Li({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:bi(i)},t)},captureUpdate:j.EVENTUALLY}},PanelComponent:({updateData:e})=>{let t=cE(e=>e.zoom.value);return(0,H.jsx)(aE,{label:G(`buttons.resetZoom`),style:{height:`100%`},children:(0,H.jsxs)(Y,{type:`button`,className:`reset-zoom-button zoom-button`,title:G(`buttons.resetZoom`),"aria-label":G(`buttons.resetZoom`),onClick:()=>{e(null)},children:[(t*100).toFixed(0),`%`]})})},keyTest:e=>(e.code===ir.ZERO||e.code===ir.NUM_ZERO)&&(e[I.CTRL_OR_CMD]||e.shiftKey)}),mE=e=>[e.x,e.y,e.x+e.width,e.y+e.height];X({name:`zoomToFitSelectionInViewport`,label:`labels.zoomToFitViewport`,icon:MC,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?Bs(At(i)):t.scrollConstraints?mE(t.scrollConstraints):Bs(At(e)),o=di({bounds:a,appState:t,fit:`scale-down`,canvasOffsets:r.viewport.getOffsets()});return{...o,appState:{...o.appState,...vc(o.appState)}}},keyTest:e=>e.code===ir.TWO&&e.shiftKey&&!e.altKey&&!e[I.CTRL_OR_CMD]}),X({name:`zoomToFitSelection`,label:`helpDialog.zoomToSelection`,icon:MC,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?Bs(At(i)):t.scrollConstraints?mE(t.scrollConstraints):Bs(At(e)),o=di({bounds:a,appState:t,fit:`contain`,canvasOffsets:r.viewport.getOffsets()});return{...o,appState:{...o.appState,...vc(o.appState)}}},keyTest:e=>e.code===ir.THREE&&e.shiftKey&&!e.altKey&&!e[I.CTRL_OR_CMD]}),X({name:`zoomToFit`,label:`helpDialog.zoomToFit`,icon:MC,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?mE(t.scrollConstraints):Bs(At(e)),a=di({bounds:i,appState:t,fit:`scale-down`,canvasOffsets:r.viewport.getOffsets()});return{...a,appState:{...a.appState,...vc(a.appState)}}},keyTest:e=>e.code===ir.ONE&&e.shiftKey&&!e.altKey&&!e[I.CTRL_OR_CMD]});var hE=X({name:`toggleTheme`,label:(e,t)=>t.theme===N.DARK?`buttons.lightMode`:`buttons.darkMode`,keywords:[`toggle`,`dark`,`light`,`mode`,`theme`],icon:(e,t)=>e.theme===N.LIGHT?hx:gx,viewMode:!0,trackEvent:{category:`canvas`},perform:(e,t,n,r)=>{let i=n||(t.theme===N.LIGHT?N.DARK:N.LIGHT);return r.props.onThemeChange?(r.props.onThemeChange(i),!1):{appState:{...t,theme:i},captureUpdate:j.EVENTUALLY}},keyTest:e=>!e[I.CTRL_OR_CMD]&&e.altKey&&e.shiftKey&&e.code===ir.D,predicate:(e,t,n,r)=>!!r.props.UIOptions.canvasActions.toggleTheme}),gE=({app:e,options:t,activeTool:n,defaultOption:r,"data-testid":i,onToolChange:a,displayedOption:o})=>{let[s,c]=(0,V.useState)(!1),l=n.type,u=o.type===l,{container:d}=bH();return!t.some(e=>e.type===l)&&s&&c(!1),(0,V.useEffect)(()=>{let t=e.onPointerDownEmitter.on(()=>{c(!1)});return()=>t?.()},[e]),(0,H.jsxs)(ty,{open:s,children:[(0,H.jsx)(ny,{asChild:!0,children:(0,H.jsx)(Y,{className:U({fillable:o.fillable}),type:`toggle`,icon:o.icon,checked:u,disabled:t.every(t=>SE(e,t.type)),title:Qa(o.title),"aria-label":Qa(o.title),"data-testid":i,onSelect:()=>{c(e=>!e),a(r)}})}),(0,H.jsx)(iy,{className:`tool-popover-content`,sideOffset:16,collisionBoundary:d??void 0,children:t.map(({type:t,icon:n,title:r,fillable:i})=>(0,H.jsx)(Y,{className:U({fillable:i}),type:`toggle`,icon:n,checked:l===t,disabled:SE(e,t),title:Qa(t),"aria-label":Qa(t),"data-testid":`toolbar-${t}`,onSelect:()=>{e.state.activeTool.type!==t&&(hw(`toolbar`,t,`ui`),e.setActiveTool({type:t}),a?.(t))}},t))})]})},_E=(e=>e)({hand:{icon:$S,letterKey:I.H,toggle:!0},selection:{icon:Xb,letterKey:I.V,numericKey:I[1],fillable:!0},rectangle:{icon:Qb,letterKey:I.R,numericKey:I[2],fillable:!0},diamond:{icon:$b,letterKey:I.D,numericKey:I[3],fillable:!0},ellipse:{icon:ex,letterKey:I.O,numericKey:I[4],fillable:!0},arrow:{icon:tx,letterKey:I.A,numericKey:I[5],fillable:!0},line:{icon:nx,letterKey:I.L,numericKey:I[6],fillable:!0},freedraw:{icon:ix,letterKey:[I.P,I.X],numericKey:I[7]},text:{icon:ax,letterKey:I.T,numericKey:I[8]},image:{icon:sx,numericKey:I[9]},eraser:{icon:cx,letterKey:I.E,numericKey:I[0],toggle:!0},frame:{icon:cC,letterKey:I.F},autoshape:{icon:pC,letterKey:I.X,shiftKey:!0,fillable:!1},embeddable:{icon:px},laser:{icon:mC,letterKey:I.K},bucketfill:{icon:jx,letterKey:I.B},lasso:{icon:Zb,fillable:!1}}),vE=Object.keys(_E).filter(e=>_E[e].toggle),yE=e=>{let{letterKey:t,shiftKey:n}=_E[e];if(!t)return t;let r=Qa(typeof t==`string`?t:t[0]);return n?Z(`Shift+${r}`):r},bE=e=>{let t=yE(e),{numericKey:n}=_E[e];return t&&n!=null?`${t} ${G(`helpDialog.or`)} ${n}`:`${t||n}`},xE=(e,t,n=!1)=>{let r=e.toLowerCase();for(let i of Object.keys(_E)){let{letterKey:a,numericKey:o,shiftKey:s}=_E[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},SE=(e,t)=>e.props.activeTool!=null&&e.props.activeTool.type!==t,CE=(e,t)=>{let n=_E[e],r=t?.shortcutType??e,i=({app:i,activeTool:a,hideKeyBinding:o,hideShortcut:s})=>{let c=Qa(G(`toolBar.${e}`)),l=s?null:bE(r);return(0,H.jsx)(Y,{className:U({fillable:n.fillable}),type:`toggle`,icon:n.icon,checked:a.type===e,disabled:SE(i,e),title:l?`${c} \u2014 ${l}`:c,keyBindingLabel:o||s?void 0:_E[r].numericKey||yE(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&&(hw(`toolbar`,e,`ui`),i.setActiveTool({type:e}))}})};return i.displayName=`${Qa(e)}IconButton`,i},wE=CE(`hand`),TE=CE(`rectangle`),EE=CE(`diamond`),DE=CE(`ellipse`),OE=CE(`arrow`),kE=CE(`line`),AE=CE(`freedraw`),jE=CE(`text`),ME=CE(`image`),NE=CE(`eraser`),PE=CE(`frame`),FE=CE(`selection`,{onSelect:(e,{pointerType:t})=>{if(e.state.activeTool.type===`selection`&&t!==null){e.setActiveTool({type:`lasso`});return}e.state.activeTool.type!==`selection`&&(hw(`toolbar`,`selection`,`ui`),e.setActiveTool({type:`selection`}))}}),IE=CE(`lasso`,{shortcutType:`selection`}),LE=({app:e,activeTool:t,setAppState:n})=>{let r=[{type:`selection`,icon:_E.selection.icon,fillable:_E.selection.fillable,title:Qa(G(`toolBar.selection`))},{type:`lasso`,icon:_E.lasso.icon,fillable:_E.lasso.fillable,title:Qa(G(`toolBar.lasso`))}],i=r.find(t=>t.type===e.state.preferredSelectionTool.type)||r[0];return(0,H.jsx)(gE,{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})},RE=({app:e,activeTool:t})=>{let n=[{type:`freedraw`,icon:_E.freedraw.icon,fillable:_E.freedraw.fillable,title:Qa(G(`toolBar.freedraw`))},{type:`autoshape`,icon:_E.autoshape.icon,fillable:_E.autoshape.fillable,title:Qa(G(`toolBar.autoshape`))}],[r,i]=(0,V.useState)(t.type===`autoshape`?`autoshape`:`freedraw`);(0,V.useEffect)(()=>{(t.type===`freedraw`||t.type===`autoshape`)&&i(t.type)},[t.type]);let a=n.find(e=>e.type===r)||n[0];return(0,H.jsx)(gE,{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})},zE=X({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=M.getElement(t.selectedLinearElement.elementId,c);ho(u,`Arrow element should exist if selectedLinearElement is set`),ho(o,`sceneCoords should be defined if actionFinalize is called with event`);let d=M.handlePointerUp(i,t.selectedLinearElement,t,r.scene);if(Ur(u)&&!t.selectedLinearElement.segmentMidPointHoveredCoords){let e=!!t.newElement,n=e||!t.selectedLinearElement.selectedPointsIndices?[u.points.length-1]:t.selectedLinearElement.selectedPointsIndices,a=mc(i),l=i[I.CTRL_OR_CMD]?null:r.getEffectiveGridSize(),f=n.reduce((e,t)=>(e.set(t,{point:a?u.points[t]:M.createPointAt(u,c,o.x-d.pointerOffset.x,o.y-d.pointerOffset.y,l)}),e),new Map)??new Map;Et(u,f,o.x,o.y,s,t,{newArrow:e,altKey:i.altKey,angleLocked:a,gridSize:r.getEffectiveGridSize()})}else Me(u)&&t.selectedLinearElement?.isEditing&&!t.newElement&&!ue(u.points)&&s.mutateElement(u,{polygon:!1});if(d!==t.selectedLinearElement){u&&Bo(u)&&(a=a.map(e=>e.id===u.id?z(e,{isDeleted:!0}):e));let n=t.activeTool?.locked;return{elements:u.points.length<2||Bo(u)?e.map(e=>e.id===u.id?z(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:j.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`||Ur(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)}),Ur(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=M.getPointAtIndexGlobalCoordinates(d,-1,c);Et(d,n,r[0],r[1],s,t,{newArrow:e})}}if(d&&Bo(d)&&(a=a.map(e=>e.id===d?.id?z(e,{isDeleted:!0}):e)),vo(d)||ja(d)){if(Hs(d.points,t.zoom.value)&&(Me(d)||ja(d))){let e=d.points,t=e[0],n=e.map((n,r)=>r===e.length-1?A(t[0],t[1]):n);Me(d)?s.mutateElement(d,{points:n,polygon:!0}):s.mutateElement(d,{points:n})}Me(d)&&!ue(d.points)&&s.mutateElement(d,{polygon:!1})}}let f;f=vE.includes(t.activeTool.type)?$r(t,{...t.activeTool.lastActiveTool||{type:r.state.preferredSelectionTool.type},lastActiveTool:null}):$r(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&&vo(d)?new M(d,ze(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?j.IMMEDIATELY:j.NEVER}},keyTest:(e,t)=>e.key===I.ESCAPE&&t.selectedLinearElement?.isEditing||(e.key===I.ESCAPE||e.key===I.ENTER)&&t.multiElement!==null,PanelComponent:({appState:e,updateData:t,data:n})=>(0,H.jsx)(Y,{type:`button`,icon:Fx,title:G(`buttons.done`),"aria-label":G(`buttons.done`),onClick:t,visible:e.multiElement!=null,size:n?.size||`medium`,style:{pointerEvents:`all`}})}),BE=(e,t)=>vE.includes(e.activeTool.type)?$r(e,{...e.activeTool.lastActiveTool||{type:t.state.preferredSelectionTool.type},lastActiveTool:null}):$r(e,{type:t.state.preferredSelectionTool.type}),VE=(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:St(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};X({name:`deselect`,label:``,trackEvent:!1,perform:(e,t,n,r)=>{let i=BE(t,r);if(r.cursor.applyForTool(i),t.editingGroupId){let e=r.scene.getNonDeletedElements(),n=Object.keys(t.selectedElementIds).length>0?t.selectedElementIds:St(e,t.editingGroupId).reduce((e,t)=>(e[t.id]=!0,e),{});return{appState:{...t,...Xo({editingGroupId:VE(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:j.IMMEDIATELY}}return{appState:{...t,activeEmbeddable:null,activeTool:i,editingGroupId:null,selectedElementIds:ci({},t),selectedGroupIds:{},selectedLinearElement:null,selectionElement:null,showHyperlinkPopup:!1,suggestedBinding:null,hoveredArrowTextAnchor:null,frameToHighlight:null},captureUpdate:j.IMMEDIATELY}},keyTest:(e,t,n,r)=>e.key!==I.ESCAPE||Ee(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||Ki(r.scene.getNonDeletedElements(),t))});var HE=({children:e,checked:t,onChange:n,className:r})=>(0,H.jsxs)(`div`,{className:U(`Checkbox`,r,{"is-checked":t}),onClick:e=>{n(!t,e),e.currentTarget.querySelector(`.Checkbox-box`).focus()},children:[(0,H.jsx)(`button`,{type:`button`,className:`Checkbox-box`,role:`checkbox`,"aria-checked":t,children:Tx}),(0,H.jsx)(`div`,{className:`Checkbox-label`,children:e})]}),UE=e=>{let t=e.title||(e.value===N.DARK?G(`buttons.lightMode`):G(`buttons.darkMode`));return(0,H.jsx)(Y,{type:`icon`,icon:e.value===N.LIGHT?WE.MOON:WE.SUN,title:t,"aria-label":t,onClick:()=>e.onChange(e.value===N.DARK?N.LIGHT:N.DARK),"data-testid":`toggle-dark-mode`})},WE={SUN:(0,H.jsx)(`svg`,{width:`512`,height:`512`,className:`rtl-mirror`,viewBox:`0 0 512 512`,children:(0,H.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,H.jsx)(`svg`,{width:`512`,height:`512`,className:`rtl-mirror`,viewBox:`0 0 512 512`,children:(0,H.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`})})},GE=e=>{let{id:t}=bH(),[n,r]=(0,V.useState)(e.value);return(0,H.jsxs)(`div`,{className:`ProjectName`,children:[(0,H.jsx)(`label`,{className:`ProjectName-label`,htmlFor:`filename`,children:`${e.label}:`}),(0,H.jsx)(`input`,{type:`text`,className:`TextInput`,onBlur:t=>{e.ignoreFocus||xo(t.target);let n=t.target.value;n!==e.value&&e.onChange(n)},onKeyDown:e=>{if(e.key===I.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)})]})},KE=5e3,qE=Object.assign(({message:e,onClose:t,closable:n=!1,duration:r=KE,style:i})=>{let a=(0,V.useRef)(0),o=r!==1/0,s=(0,V.useCallback)(()=>{o&&(a.current=window.setTimeout(()=>t(),r))},[t,r,o]);return(0,V.useEffect)(()=>{if(o)return s(),()=>clearTimeout(a.current)},[s,e,r,o]),(0,H.jsxs)(`div`,{className:`Toast`,role:`status`,onMouseEnter:o?()=>clearTimeout(a?.current):void 0,onMouseLeave:o?s:void 0,style:i,children:[(0,H.jsx)(`div`,{className:`Toast__message`,children:e}),n&&(0,H.jsx)(Y,{icon:nS,"aria-label":`close`,type:`icon`,onClick:t,className:`close`})]})},{ProgressBar:({progress:e})=>(0,H.jsx)(`div`,{className:`Toast__progress-bar`,children:(0,H.jsx)(`div`,{className:`Toast__progress-bar-fill`,style:{width:`${Math.min(5,Math.round(e*100))}%`}})})});`clipboard`in navigator&&`readText`in navigator.clipboard;var JE=`clipboard`in navigator&&`writeText`in navigator.clipboard,YE=`clipboard`in navigator&&`write`in navigator.clipboard&&`ClipboardItem`in window&&`toBlob`in HTMLCanvasElement.prototype,XE=e=>!!([ot.excalidraw,ot.excalidrawClipboard,ot.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),ZE=({types:e,files:t})=>{!e&&!t&&console.warn(`createPasteEvent: no types or files provided`);let n=new ClipboardEvent(R.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},QE=({elements:e,files:t})=>{let n=ze(e),r=new Set(e.filter(e=>P(e))),i=!1,a=e.reduce((e,n)=>(ac(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:ot.excalidrawClipboard,elements:e.map(e=>{if(Wt(e,n)&&!r.has(Wt(e,n))){let t=ii(e);return ur(t,n,{frameId:null}),t}return e}),files:t?a:void 0};return JSON.stringify(o)},$E=async(e,t,n)=>{let r=QE({elements:e,files:t});await dD({[L.excalidrawClipboard]:r,[L.text]:r},n)};function eD(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(eD(n));return t}var tD=e=>{let t=e.value;try{let e=eD(new DOMParser().parseFromString(t,L.html).body);if(e.length)return{type:`mixedContent`,value:e}}catch(e){console.error(`error in parseHTMLFromPaste: ${e.message}`)}return null},nD=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{[L.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(Zr(Sr,t))try{if(t===L.text||t===L.html)e[t]=await(await n.getType(t)).text();else if(Dn(t)){let r=await n.getType(t);e[t]=tt(r,t,void 0)}else throw new Mo(`Unsupported clipboard type: ${t}`)}catch(e){console.warn(e instanceof Mo?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},rD=async(e,t=!1)=>{try{let n=e.findByType(L.html),r=!t&&n&&tD(n);return r?r.value.every(e=>e.type===`text`)?{type:`text`,value:e.getData(L.text)??r.value.map(e=>e.value).join(`
43
- `).trim()}:r:{type:`text`,value:(e.getData(L.text)||``).trim()}}catch{return{type:`text`,value:``}}},iD=function(e){return this.find(t=>t.type===e)||null},aD=function(e){return this.find(t=>t.type===e)?.value??null},oD=function(){return this.filter(e=>e.kind===`file`)},sD=e=>{let t;t=pD(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},cD=async e=>{let t;t=pD(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 r(t);return e=await ua(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:iD,getData:aD,getFiles:oD})},lD=async(e,t=!1)=>{let n=await rD(e,t);if(n.type===`mixedContent`)return{mixedContent:n.value};try{let e=JSON.parse(n.value),r=e.type===ot.excalidrawClipboardWithAPI;if(XE(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}},uD=async e=>{try{await navigator.clipboard.write([new ClipboardItem({[L.png]:e})])}catch(t){if(Yt(e))await navigator.clipboard.write([new ClipboardItem({[L.png]:await e})]);else throw t}},dD=async(e,t)=>{e||=``;let n=Object.entries(typeof e==`string`?{[L.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===L.text);if(JE&&r)try{await navigator.clipboard.writeText(r[1]);return}catch(e){console.error(e)}if(r&&!fD(r[1]))throw Error(`Error copying to clipboard.`)},fD=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},pD=e=>e.type===R.PASTE||e.type===R.COPY||e.type===R.CUT,mD=(e,{selectedElementIds:t},n)=>{let r=At(e),i=ze(r),a=n&&Ki(r,{selectedElementIds:t}),o=null,s=a?is(r,{selectedElementIds:t},{includeBoundTextElement:!0}):r;if(a){let e=s[0];s.length===1&&P(e)?(o=e,s=Gn(r,e,i)):s.length>1&&(s=is(r,{selectedElementIds:t},{includeBoundTextElement:!0,includeElementsInFrames:!0}))}return{exportingFrame:o,exportedElements:g(s)}},hD=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(G(`alerts.cannotExportEmptyCanvas`));if(e===`svg`||e===`clipboard-svg`){let n=O(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 Ps(n.then(e=>new Blob([Tn+e.outerHTML],{type:L.svg})),{description:`Export to SVG`,name:c,extension:r.exportEmbedScene?`excalidraw.svg`:`svg`,mimeTypes:[bt.svg],fileHandle:l});if(e===`clipboard-svg`){let e=await n.then(e=>e.outerHTML);try{await dD(e)}catch{throw Error(G(`errors.copyToSystemClipboardFailed`))}return}}let d=Dc(t,r,i,{exportBackground:a,viewBackgroundColor:s,exportPadding:o,exportingFrame:u});if(e===`png`){let e=Ke(d);return r.exportEmbedScene&&(e=e.then(e=>n(async()=>{let{encodePngMetadata:e}=await import(`./image-ZVKINSPA-0zXSnE7M.js`);return{encodePngMetadata:e}},__vite__mapDeps([62,63,2,64,1]),import.meta.url).then(({encodePngMetadata:n})=>n({blob:e,metadata:$s(t,r,i,`local`)})))),Ps(e,{description:`Export to PNG`,name:c,extension:r.exportEmbedScene?`excalidraw.png`:`png`,mimeTypes:[bt.png],fileHandle:l})}if(e===`clipboard`)try{await uD(Ke(d))}catch(e){throw console.warn(e),e.name===`CANVAS_POSSIBLY_TOO_BIG`?Error(G(`canvasError.canvasTooBig`)):kt&&e.name===`TypeError`?Error(`${G(`alerts.couldNotCopyToClipboard`)}
44
-
45
- ${G(`hints.firefox_clipboard_write`)}`):Error(G(`alerts.couldNotCopyToClipboard`))}else throw Error(`Unsupported export type`)},gD=async(e,t,n)=>{let r=ea(t);if(!nr(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}=mD(i,a,!1);return await hD(r,l,a,o,{exportBackground:s,viewBackgroundColor:c,name:n,fileHandle:t,exportingFrame:u}),{fileHandle:t}},_D=X({name:`changeProjectName`,label:`labels.fileTitle`,trackEvent:!1,perform:(e,t,n)=>({appState:{...t,name:n},captureUpdate:j.EVENTUALLY}),PanelComponent:({appState:e,updateData:t,appProps:n,data:r,app:i})=>(0,H.jsx)(GE,{label:G(`labels.fileTitle`),value:i.getName(),onChange:e=>t(e),ignoreFocus:r?.ignoreFocus??!1})}),vD=X({name:`changeExportScale`,label:`imageExportDialog.scale`,trackEvent:{category:`export`,action:`scale`},perform:(e,t,n)=>({appState:{...t,exportScale:n},captureUpdate:j.EVENTUALLY})}),yD=X({name:`changeExportBackground`,label:`imageExportDialog.label.withBackground`,trackEvent:{category:`export`,action:`toggleBackground`},perform:(e,t,n)=>({appState:{...t,exportBackground:n},captureUpdate:j.EVENTUALLY}),PanelComponent:({appState:e,updateData:t})=>(0,H.jsx)(HE,{checked:e.exportBackground,onChange:e=>t(e),children:G(`imageExportDialog.label.withBackground`)})}),bD=X({name:`changeExportEmbedScene`,label:`imageExportDialog.tooltip.embedScene`,trackEvent:{category:`export`,action:`embedScene`},perform:(e,t,n)=>({appState:{...t,exportEmbedScene:n},captureUpdate:j.EVENTUALLY}),PanelComponent:({appState:e,updateData:t})=>(0,H.jsxs)(HE,{checked:e.exportEmbedScene,onChange:e=>t(e),children:[G(`imageExportDialog.label.embedScene`),(0,H.jsx)(aE,{label:G(`imageExportDialog.tooltip.embedScene`),long:!0,children:(0,H.jsx)(`div`,{className:`excalidraw-tooltip-icon`,children:Rx})})]})}),xD=!1,SD=(e,t)=>{let n=t.message??G(`progressDialog.defaultMessage`);e.setAppState({toast:{message:t.progress==null?n:(0,H.jsxs)(H.Fragment,{children:[n,(0,H.jsx)(qE.ProgressBar,{progress:t.progress})]}),duration:1/0}})};async function CD(e,t){if(t.app.state.isLoading&&(SD(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`)SD(t.app,{message:n.message,progress:n.progress??null});else if(n.type===`done`)return}return}e instanceof Promise&&(SD(t.app,{progress:null}),await e)}function wD(e,t,n,r){let i=new AbortController,a=i.signal;return{abortController:i,data:new Promise(async i=>{try{r.props.onExport&&await CD(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 TD=X({name:`saveToActiveFile`,label:`buttons.save`,icon:vx,trackEvent:{category:`export`},predicate:(e,t,n,r)=>!!r.props.UIOptions.canvasActions.saveToActiveFile&&!!t.fileHandle&&!t.viewModeEnabled,perform:async(e,t,n,r)=>{if(xD)return!1;xD=!0;let i=t.fileHandle,a=r.getName(),{abortController:o,data:s}=wD(e,t,r.files,r);try{let{fileHandle:e}=Fs(i)?await gD(s,i,a):await no({data:s,filename:a,fileHandle:i});return{captureUpdate:j.NEVER,appState:{fileHandle:e,toast:{message:i&&e?.name?G(`toast.fileSavedToFilename`).replace(`{filename}`,`"${e.name}"`):G(`toast.fileSaved`),duration:1500}}}}catch(e){return o.abort(),e?.name===`AbortError`?console.warn(e):console.error(e),{captureUpdate:j.NEVER,appState:{toast:null}}}finally{xD=!1}},keyTest:e=>e.key===I.S&&e[I.CTRL_OR_CMD]&&!e.shiftKey}),ED=X({name:`saveFileToDisk`,label:`exportDialog.disk_title`,icon:vx,viewMode:!0,trackEvent:{category:`export`},perform:async(e,t,n,r)=>{if(xD)return!1;xD=!0;let{abortController:i,data:a}=wD(e,t,r.files,r);try{let{fileHandle:e}=await no({data:a,filename:r.getName(),fileHandle:null});return{captureUpdate:j.NEVER,appState:{openDialog:null,fileHandle:e,toast:{message:G(`toast.fileSaved`),duration:3e3}}}}catch(e){return i.abort(),e?.name===`AbortError`?console.warn(e):console.error(e),{captureUpdate:j.NEVER,appState:{toast:null}}}finally{xD=!1}},keyTest:e=>e.key.toLowerCase()===I.S&&e.shiftKey&&e[I.CTRL_OR_CMD],PanelComponent:({updateData:e})=>(0,H.jsx)(Y,{type:`button`,icon:Ox,title:G(`buttons.saveAs`),"aria-label":G(`buttons.saveAs`),showAriaLabel:vH().formFactor===`phone`,hidden:!Ts,onClick:()=>e(null),"data-testid":`save-as-button`})}),DD=X({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 ut(t,e);return{elements:n,appState:r,files:i,captureUpdate:j.IMMEDIATELY}}catch(n){return n?.name===`AbortError`?(console.warn(n),!1):{elements:e,appState:{...t,errorMessage:n.message},files:r.files,captureUpdate:j.EVENTUALLY}}},keyTest:e=>e[I.CTRL_OR_CMD]&&e.key===I.O}),OD=X({name:`exportWithDarkMode`,label:`imageExportDialog.label.darkMode`,trackEvent:{category:`export`,action:`toggleTheme`},perform:(e,t,n,r)=>(r.sessionExportThemeOverride=n?N.DARK:N.LIGHT,{appState:{...t,exportWithDarkMode:n},captureUpdate:j.EVENTUALLY}),PanelComponent:({appState:e,updateData:t})=>(0,H.jsx)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,marginTop:`-45px`,marginBottom:`10px`},children:(0,H.jsx)(UE,{value:e.exportWithDarkMode?N.DARK:N.LIGHT,onChange:e=>{t(e===N.DARK)},title:G(`imageExportDialog.label.darkMode`)})})}),kD=`{}`,AD=X({name:`copyStyles`,label:`labels.copyStyles`,icon:jC,trackEvent:{category:`element`},perform:(e,t,n,r)=>{let i=[],a=e.find(e=>t.selectedElementIds[e.id]);if(i.push(a),a&&Qr(a)){let e=ao(a,r.scene.getNonDeletedElementsMap());i.push(e)}return a&&(kD=JSON.stringify(i)),{appState:{...t,toast:{message:G(`toast.copyStyles`)}},captureUpdate:j.EVENTUALLY}},keyTest:e=>e[I.CTRL_OR_CMD]&&e.altKey&&e.code===ir.C}),jD=X({name:`pasteStyles`,label:`labels.pasteStyles`,icon:jC,trackEvent:{category:`element`},perform:(e,t,n,r)=>{let i=JSON.parse(kD),a=i[0],o=i[1];if(!Pi(a))return{elements:e,captureUpdate:j.EVENTUALLY};let s=is(e,t,{includeBoundTextElement:!0}),c=s.map(e=>e.id);return{elements:e.map(e=>{if(c.includes(e.id)){let t=a;if(F(e)&&e.containerId&&(t=o),!t)return e;let n=z(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?qn(t.roundness.type,e)?t.roundness:mr(e):null});if(F(n)){let e=t.fontSize||20,i=t.fontFamily||Pt,a=z(n,{fontSize:e,fontFamily:i,textAlign:t.textAlign||`left`,lineHeight:t.lineHeight||sa(i)});n=a;let o=null;a.containerId&&(o=s.find(e=>e.id===a.containerId)||null),ga(a,o,r.scene)}return n.type===`arrow`&&Wa(t)&&(n=z(n,{startArrowhead:t.startArrowhead,endArrowhead:t.endArrowhead})),P(e)&&(n=z(n,{roundness:null,backgroundColor:`transparent`})),n}return e}),captureUpdate:j.IMMEDIATELY}},keyTest:e=>e[I.CTRL_OR_CMD]&&e.altKey&&e.code===ir.V}),MD=X({name:`toggleShortcuts`,label:`welcomeScreen.defaults.helpHint`,icon:bx,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:j.EVENTUALLY}),keyTest:e=>e.key===I.QUESTION_MARK}),ND=(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=>Ks(e,t)))return!0}return!1},PD=(e,t)=>{let n=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds,includeBoundTextElement:!1});return n.length>=2&&!ND(n,e.editingGroupId)&&!Vn(n)},FD=X({name:`group`,label:`labels.group`,icon:e=>(0,H.jsx)(rS,{theme:e.theme}),trackEvent:{category:`element`},perform:(e,t,n,r)=>{if(!PD(t,r))return!1;let i=jc(r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0}));if(i.length<2)return{appState:t,elements:e,captureUpdate:j.EVENTUALLY};let a=Ds(t);if(a.length===1){let n=a[0],r=new Set(St(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:j.EVENTUALLY}}let s=[...e];new Set(i.map(e=>e.frameId)).size>1&&es(i).forEach((e,t)=>{o(e,r.scene.getNonDeletedElementsMap())});let c=Ae(),l=ze(i);s=s.map(e=>l.get(e.id)?z(e,{groupIds:Or(e.groupIds,c,t.editingGroupId)}):e);let u=St(s,c),d=u[u.length-1],f=s.lastIndexOf(d),p=s.slice(f+1),m=s.slice(0,f).filter(e=>!Ks(e,c)),h=xt([...m,...u,...p],ze(u));return{appState:{...t,...Be(c,{...t,selectedGroupIds:{}},At(s))},elements:h,captureUpdate:j.IMMEDIATELY}},predicate:(e,t,n,r)=>PD(t,r),keyTest:e=>!e.shiftKey&&e[I.CTRL_OR_CMD]&&e.key===I.G,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,H.jsx)(Y,{hidden:!PD(t,r),type:`button`,icon:(0,H.jsx)(rS,{theme:t.theme}),onClick:()=>n(null),title:`${G(`labels.group`)} \u2014 ${Z(`CtrlOrCmd+G`)}`,"aria-label":G(`labels.group`),visible:Ki(At(e),t)})}),ID=X({name:`ungroup`,label:`labels.ungroup`,icon:e=>(0,H.jsx)(iS,{theme:e.theme}),trackEvent:{category:`element`},perform:(e,t,n,r)=>{let i=Ds(t),a=ze(e);if(i.length===0)return{appState:t,elements:e,captureUpdate:j.EVENTUALLY};let o=[...e],s=[];o=o.map(e=>{fs(e)&&s.push(e.id);let n=qt(e.groupIds,t.selectedGroupIds);return n.length===e.groupIds.length?e:z(e,{groupIds:n})});let c=Xo(t,At(o),t,null),l=r.scene.getSelectedElements(t),u=new Set(l.filter(e=>e.frameId).map(e=>e.frameId));return na(e).filter(e=>u.has(e.id)).forEach(e=>{e&&(o=Oi(o,js(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:j.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[I.CTRL_OR_CMD]&&e.key===I.G.toUpperCase(),predicate:(e,t)=>Ds(t).length>0,PanelComponent:({elements:e,appState:t,updateData:n})=>(0,H.jsx)(Y,{type:`button`,hidden:Ds(t).length===0,icon:(0,H.jsx)(iS,{theme:t.theme}),onClick:()=>n(null),title:`${G(`labels.ungroup`)} \u2014 ${Z(`CtrlOrCmd+Shift+G`)}`,"aria-label":G(`labels.ungroup`),visible:Ki(At(e),t)})}),LD=(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 RD(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 zD=(e,t)=>`hsl(${Math.abs(RD(t?.id||e))%37*10}, 100%, 83%)`,BD=e=>{let t=e?.trim()?.codePointAt(0);return(t?String.fromCodePoint(t):`?`).toUpperCase()},VD=({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=zD(a,l);e.save(),e.strokeStyle=d,e.fillStyle=d;let f=t.remotePointerUserStates.get(a),p=u||f===Tr.IDLE||f===Tr.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===N.DARK?`#2f6330`:Nr,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=Je,e.strokeStyle=Je,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())):LD(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()}},HD=({color:e,onClick:t,name:n,src:r,className:i})=>{let a=BD(n),[o,s]=(0,V.useState)(!1),c=!o&&r,l=c?void 0:{background:e};return(0,H.jsx)(`div`,{className:U(`Avatar`,i),style:l,onClick:t,children:c?(0,H.jsx)(`img`,{className:`Avatar-img`,src:r,alt:a,referrerPolicy:`no-referrer`,onError:()=>s(!0)}):a})};X({name:`goToCollaborator`,label:`Go to a collaborator`,viewMode:!0,trackEvent:{category:`collab`},perform:(e,t,n,r)=>(ho(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:j.EVENTUALLY}):(r.emitUserFollowIntent({userToFollow:{socketId:n.socketId,username:n.username||``},action:`FOLLOW`}),{appState:{...t,openMenu:t.openMenu===`canvas`?null:t.openMenu},captureUpdate:j.EVENTUALLY})),PanelComponent:({updateData:e,data:t,appState:n})=>{let{socketId:r,collaborator:i,withName:a,isBeingFollowed:o}=t,s=zD(r,i),c=U({"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,H.jsxs)(`div`,{className:`UserList__collaborator-status-icon-speaking-indicator`,title:G(`userList.hint.isSpeaking`),children:[(0,H.jsx)(`div`,{}),(0,H.jsx)(`div`,{}),(0,H.jsx)(`div`,{})]}):i.isMuted?(0,H.jsx)(`div`,{className:`UserList__collaborator-status-icon-microphone-muted`,title:G(`userList.hint.micMuted`),children:TC}):(0,H.jsx)(`div`,{title:G(`userList.hint.inCall`),children:wC}):null;return a?(0,H.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,H.jsx)(HD,{color:s,onClick:()=>{},name:i.username||``,src:i.avatarUrl,className:c}),(0,H.jsx)(`div`,{className:`UserList__collaborator-name`,children:i.username}),(0,H.jsxs)(`div`,{className:`UserList__collaborator-status-icons`,"aria-hidden":!0,children:[o&&(0,H.jsx)(`div`,{className:`UserList__collaborator-status-icon-is-followed`,title:G(`userList.hint.followStatus`),children:_C}),i.isCurrentUser&&` (${G(`labels.you`)})`,l]})]}):(0,H.jsxs)(`div`,{className:`UserList__collaborator UserList__collaborator--avatar-only ${c}`,children:[(0,H.jsx)(HD,{color:s,onClick:()=>{e(i)},name:i.username||``,src:i.avatarUrl,className:c}),l&&(0,H.jsx)(`div`,{className:`UserList__collaborator-status-icon`,children:l})]})}});var UD=X({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 ls)if(i.some(t=>t.type===e))return{captureUpdate:j.EVENTUALLY,appState:{...t,errorMessage:G(`errors.libraryElementTypeError.${e}`)}};return r.library.getLatestLibrary().then(e=>r.library.setLibrary([{id:Ae(),status:`unpublished`,elements:i.map(ii),created:Date.now()},...e])).then(()=>({captureUpdate:j.EVENTUALLY,appState:{...t,toast:{message:G(`toast.addedToLibrary`)}}})).catch(e=>({captureUpdate:j.EVENTUALLY,appState:{...t,errorMessage:e.message}}))},label:`labels.addToLibrary`}),WD=(e,t)=>{let n=t.scene.getSelectedElements(e);return Eo(n,t.scene.getNonDeletedElementsMap(),e).length>1&&!n.some(e=>P(e))},GD=(e,t,n,r)=>{let i=n.scene.getSelectedElements(t),a=m(i,r,n.scene,t),o=ze(a);return vi(e.map(e=>o.get(e.id)||e),t,n)};X({name:`alignTop`,label:`labels.alignTop`,icon:Kx,trackEvent:{category:`element`},predicate:(e,t,n,r)=>WD(t,r),perform:(e,t,n,r)=>({appState:t,elements:GD(e,t,r,{position:`start`,axis:`y`}),captureUpdate:j.IMMEDIATELY}),keyTest:e=>e[I.CTRL_OR_CMD]&&e.shiftKey&&e.key===I.ARROW_UP,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,H.jsx)(Y,{hidden:!WD(t,r),type:`button`,icon:Kx,onClick:()=>n(null),title:`${G(`labels.alignTop`)} \u2014 ${Z(`CtrlOrCmd+Shift+Up`)}`,"aria-label":G(`labels.alignTop`),visible:Ki(At(e),t)})}),X({name:`alignBottom`,label:`labels.alignBottom`,icon:qx,trackEvent:{category:`element`},predicate:(e,t,n,r)=>WD(t,r),perform:(e,t,n,r)=>({appState:t,elements:GD(e,t,r,{position:`end`,axis:`y`}),captureUpdate:j.IMMEDIATELY}),keyTest:e=>e[I.CTRL_OR_CMD]&&e.shiftKey&&e.key===I.ARROW_DOWN,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,H.jsx)(Y,{hidden:!WD(t,r),type:`button`,icon:qx,onClick:()=>n(null),title:`${G(`labels.alignBottom`)} \u2014 ${Z(`CtrlOrCmd+Shift+Down`)}`,"aria-label":G(`labels.alignBottom`),visible:Ki(At(e),t)})}),X({name:`alignLeft`,label:`labels.alignLeft`,icon:Jx,trackEvent:{category:`element`},predicate:(e,t,n,r)=>WD(t,r),perform:(e,t,n,r)=>({appState:t,elements:GD(e,t,r,{position:`start`,axis:`x`}),captureUpdate:j.IMMEDIATELY}),keyTest:e=>e[I.CTRL_OR_CMD]&&e.shiftKey&&e.key===I.ARROW_LEFT,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,H.jsx)(Y,{hidden:!WD(t,r),type:`button`,icon:Jx,onClick:()=>n(null),title:`${G(`labels.alignLeft`)} \u2014 ${Z(`CtrlOrCmd+Shift+Left`)}`,"aria-label":G(`labels.alignLeft`),visible:Ki(At(e),t)})}),X({name:`alignRight`,label:`labels.alignRight`,icon:Yx,trackEvent:{category:`element`},predicate:(e,t,n,r)=>WD(t,r),perform:(e,t,n,r)=>({appState:t,elements:GD(e,t,r,{position:`end`,axis:`x`}),captureUpdate:j.IMMEDIATELY}),keyTest:e=>e[I.CTRL_OR_CMD]&&e.shiftKey&&e.key===I.ARROW_RIGHT,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,H.jsx)(Y,{hidden:!WD(t,r),type:`button`,icon:Yx,onClick:()=>n(null),title:`${G(`labels.alignRight`)} \u2014 ${Z(`CtrlOrCmd+Shift+Right`)}`,"aria-label":G(`labels.alignRight`),visible:Ki(At(e),t)})}),X({name:`alignVerticallyCentered`,label:`labels.centerVertically`,icon:Qx,trackEvent:{category:`element`},predicate:(e,t,n,r)=>WD(t,r),perform:(e,t,n,r)=>({appState:t,elements:GD(e,t,r,{position:`center`,axis:`y`}),captureUpdate:j.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,H.jsx)(Y,{hidden:!WD(t,r),type:`button`,icon:Qx,onClick:()=>n(null),title:G(`labels.centerVertically`),"aria-label":G(`labels.centerVertically`),visible:Ki(At(e),t)})}),X({name:`alignHorizontallyCentered`,label:`labels.centerHorizontally`,icon:$x,trackEvent:{category:`element`},predicate:(e,t,n,r)=>WD(t,r),perform:(e,t,n,r)=>({appState:t,elements:GD(e,t,r,{position:`center`,axis:`x`}),captureUpdate:j.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,H.jsx)(Y,{hidden:!WD(t,r),type:`button`,icon:$x,onClick:()=>n(null),title:G(`labels.centerHorizontally`),"aria-label":G(`labels.centerHorizontally`),visible:Ki(At(e),t)})});var KD=(e,t)=>{let n=t.scene.getSelectedElements(e);return Eo(n,t.scene.getNonDeletedElementsMap(),e).length>2&&!n.some(e=>P(e))},qD=(e,t,n,r)=>{let i=n.scene.getSelectedElements(t),a=cn(i,n.scene.getNonDeletedElementsMap(),r,t,n.scene),o=ze(a);return vi(e.map(e=>o.get(e.id)||e),t,n)};X({name:`distributeHorizontally`,label:`labels.distributeHorizontally`,trackEvent:{category:`element`},perform:(e,t,n,r)=>({appState:t,elements:qD(e,t,r,{space:`between`,axis:`x`}),captureUpdate:j.IMMEDIATELY}),keyTest:e=>!e[I.CTRL_OR_CMD]&&e.altKey&&e.code===ir.H,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,H.jsx)(Y,{hidden:!KD(t,r),type:`button`,icon:Xx,onClick:()=>n(null),title:`${G(`labels.distributeHorizontally`)} \u2014 ${Z(`Alt+H`)}`,"aria-label":G(`labels.distributeHorizontally`),visible:Ki(At(e),t)})}),X({name:`distributeVertically`,label:`labels.distributeVertically`,trackEvent:{category:`element`},perform:(e,t,n,r)=>({appState:t,elements:qD(e,t,r,{space:`between`,axis:`y`}),captureUpdate:j.IMMEDIATELY}),keyTest:e=>!e[I.CTRL_OR_CMD]&&e.altKey&&e.code===ir.V,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,H.jsx)(Y,{hidden:!KD(t,r),type:`button`,icon:Zx,onClick:()=>n(null),title:`${G(`labels.distributeVertically`)} \u2014 ${Z(`Alt+V`)}`,"aria-label":G(`labels.distributeVertically`),visible:Ki(At(e),t)})});var JD=X({name:`flipHorizontal`,label:`labels.flipHorizontal`,icon:AC,trackEvent:{category:`element`},perform:(e,t,n,r)=>({elements:vi(XD(e,r.scene.getNonDeletedElementsMap(),t,`horizontal`,r),t,r),appState:t,captureUpdate:j.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===ir.H}),YD=X({name:`flipVertical`,label:`labels.flipVertical`,icon:kC,trackEvent:{category:`element`},perform:(e,t,n,r)=>({elements:vi(XD(e,r.scene.getNonDeletedElementsMap(),t,`vertical`,r),t,r),appState:t,captureUpdate:j.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===ir.V&&!e[I.CTRL_OR_CMD]}),XD=(e,t,n,r,i)=>{let a=ZD(is(At(e),n,{includeBoundTextElement:!0,includeElementsInFrames:!0}),t,r,i),o=ze(a);return e.map(e=>o.get(e.id)||e)},ZD=(e,t,n,r)=>{if(e.every(e=>Wa(e)&&(e.startBinding||e.endBinding)))return e.map(e=>{let t=e;return z(t,{startArrowhead:t.endArrowhead,endArrowhead:t.startArrowhead})});let{midX:i,midY:a}=Lt(e);Xi(e,t,`nw`,r.scene,new Map(Array.from(t.values()).map(e=>[e.id,ii(e)])),{flipByX:n===`horizontal`,flipByY:n===`vertical`,shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),wn(e.filter(Wa),r.scene,r.state);let{elbowArrows:o,otherElements:s}=e.reduce((e,t)=>fe(t)?{...e,elbowArrows:e.elbowArrows.concat(t)}:{...e,otherElements:e.otherElements.concat(t)},{elbowArrows:[],otherElements:[]}),{midX:c,midY:l}=Lt(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},QD=X({name:`copy`,label:`labels.copy`,icon:mx,trackEvent:{category:`element`},perform:async(e,t,n,r)=>{let i=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await $E(i,r.files,n)}catch(e){return{captureUpdate:j.EVENTUALLY,appState:{...t,errorMessage:e.message}}}return{captureUpdate:j.EVENTUALLY}},keyTest:void 0}),$D=X({name:`paste`,label:`labels.paste`,trackEvent:{category:`element`},perform:async(e,t,n,r)=>{let i;try{i=await nD()}catch(e){return e.name===`AbortError`||e.name===`NotAllowedError`?!1:(console.error(`actionPaste ${e.name}: ${e.message}`),kt?{captureUpdate:j.EVENTUALLY,appState:{...t,errorMessage:G(`hints.firefox_clipboard_write`)}}:{captureUpdate:j.EVENTUALLY,appState:{...t,errorMessage:G(`errors.asyncPasteFailedOnRead`)}})}try{r.pasteFromClipboard(ZE({types:i}))}catch(e){return console.error(e),{captureUpdate:j.EVENTUALLY,appState:{...t,errorMessage:G(`errors.asyncPasteFailedOnParse`)}}}return{captureUpdate:j.EVENTUALLY}},keyTest:void 0}),eO=X({name:`cut`,label:`labels.cut`,icon:nC,trackEvent:{category:`element`},perform:(e,t,n,r)=>(QD.perform(e,t,n,r),sw.perform(e,t,null,r)),keyTest:e=>e[I.CTRL_OR_CMD]&&e.key===I.X}),tO=X({name:`copyAsSvg`,label:`labels.copyAsSvg`,icon:NC,trackEvent:{category:`element`},perform:async(e,t,n,r)=>{if(!r.canvas)return{captureUpdate:j.EVENTUALLY};let{exportedElements:i,exportingFrame:a}=mD(e,t,!0);try{return await hD(`clipboard-svg`,i,t,r.files,{...t,exportingFrame:a,name:r.getName()}),{appState:{toast:{message:G(`toast.copyToClipboardAsSvg`,{exportSelection:r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}).length?G(`toast.selection`):G(`toast.canvas`),exportColorScheme:t.exportWithDarkMode?G(`buttons.darkMode`):G(`buttons.lightMode`)})}},captureUpdate:j.EVENTUALLY}}catch(e){return console.error(e),{appState:{errorMessage:e.message},captureUpdate:j.EVENTUALLY}}},predicate:e=>JE&&e.length>0,keywords:[`svg`,`clipboard`,`copy`]}),nO=X({name:`copyAsPng`,label:`labels.copyAsPng`,icon:PC,trackEvent:{category:`element`},perform:async(e,t,n,r)=>{if(!r.canvas)return{captureUpdate:j.EVENTUALLY};let i=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:a,exportingFrame:o}=mD(e,t,!0);try{return await hD(`clipboard`,a,t,r.files,{...t,exportingFrame:o,name:r.getName()}),{appState:{...t,toast:{message:G(`toast.copyToClipboardAsPng`,{exportSelection:i.length?G(`toast.selection`):G(`toast.canvas`),exportColorScheme:t.exportWithDarkMode?G(`buttons.darkMode`):G(`buttons.lightMode`)})}},captureUpdate:j.EVENTUALLY}}catch(e){return console.error(e),{appState:{...t,errorMessage:e.message},captureUpdate:j.EVENTUALLY}}},predicate:e=>YE&&e.length>0,keyTest:e=>e.code===ir.C&&e.altKey&&e.shiftKey,keywords:[`png`,`clipboard`,`copy`]}),rO=X({name:`copyText`,label:`labels.copyText`,trackEvent:{category:`element`},perform:(e,t,n,r)=>{let i=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0});try{dD(Ws(i))}catch{throw Error(G(`errors.copyToSystemClipboardFailed`))}return{captureUpdate:j.EVENTUALLY}},predicate:(e,t,n,r)=>JE&&r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0}).some(F),keywords:[`text`,`clipboard`,`copy`]}),iO=X({name:`gridMode`,icon:zC,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:j.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,t,n)=>n.gridModeEnabled===void 0,keyTest:e=>e[I.CTRL_OR_CMD]&&e.code===ir.QUOTE}),aO=X({name:`zenMode`,label:`buttons.zenMode`,icon:IC,viewMode:!0,trackEvent:{category:`canvas`,predicate:e=>!e.zenModeEnabled},perform(e,t){return{appState:{...t,zenModeEnabled:!this.checked(t)},captureUpdate:j.EVENTUALLY}},checked:e=>e.zenModeEnabled,predicate:(e,t,n,r)=>r.editorInterface.formFactor!==`phone`&&typeof n.zenModeEnabled>`u`,keyTest:e=>!e[I.CTRL_OR_CMD]&&e.altKey&&e.code===ir.Z}),oO=X({name:`objectsSnapMode`,label:`buttons.objectsSnapMode`,icon:FC,viewMode:!1,trackEvent:{category:`canvas`,predicate:e=>!e.objectsSnapModeEnabled},perform(e,t){return{appState:{...t,objectsSnapModeEnabled:!this.checked(t),gridModeEnabled:!1},captureUpdate:j.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,t,n)=>typeof n.objectsSnapModeEnabled>`u`,keyTest:e=>!e[I.CTRL_OR_CMD]&&e.altKey&&e.code===ir.S}),sO=X({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:j.NEVER}},checked:e=>e.bindingPreference===`enabled`}),cO=X({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:j.NEVER}},checked:e=>e.isMidpointSnappingEnabled}),lO=X({name:`stats`,label:`stats.fullTitle`,icon:OC,viewMode:!0,trackEvent:{category:`menu`},keywords:[`edit`,`attributes`,`customize`],perform(e,t){return{appState:{...t,stats:{...t.stats,open:!this.checked(t)}},captureUpdate:j.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[I.CTRL_OR_CMD]&&e.altKey&&e.code===ir.SLASH}),uO=X({name:`unbindText`,label:`labels.unbindText`,trackEvent:{category:`element`},predicate:(e,t,n,r)=>r.scene.getSelectedElements(t).some(e=>Qr(e)),perform:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t),a=r.scene.getNonDeletedElementsMap();return i.forEach(e=>{let t=ao(e,a);if(t){let{width:n,height:i}=xa(t.originalText,se(t),t.lineHeight),o=fr(e.id);Ms(e.id);let{x:s,y:c}=wi(e,t,a);r.scene.mutateElement(t,{containerId:null,width:n,height:i,text:t.originalText,x:s,y:c}),r.scene.mutateElement(e,{boundElements:e.boundElements?.filter(e=>e.id!==t.id),height:o||e.height})}}),{elements:e,appState:t,captureUpdate:j.IMMEDIATELY}}}),dO=X({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=F(i[0])||F(i[1]),t;if(Hi(i[0])?t=i[0]:Hi(i[1])&&(t=i[1]),e&&t&&ao(t,r.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t),a,o;F(i[0])&&Hi(i[1])?(a=i[0],o=i[1]):(a=i[1],o=i[0]),r.scene.mutateElement(a,{containerId:o.id,verticalAlign:D.MIDDLE,textAlign:io.CENTER,autoResize:!0,angle:Wa(o)?0:o?.angle??0}),r.scene.mutateElement(o,{boundElements:(o.boundElements||[]).concat({type:`text`,id:a.id})});let c=o.height;return ga(a,o,r.scene),s(o.id,c),{elements:fO(e,o,a),appState:{...t,selectedElementIds:{[o.id]:!0}},captureUpdate:j.IMMEDIATELY}}}),fO=(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),xt(r,ze([t,n])),r},pO=(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),xt(r,ze([t,n])),r},mO=X({name:`wrapTextInContainer`,label:`labels.createContainerFromText`,trackEvent:{category:`element`},predicate:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t),a=i.some(e=>F(e)&&!fs(e));return i.length>0&&a},perform:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t),a=e.slice(),o={};for(let e of i)if(F(e)&&!fs(e)){let n=_c({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:bc(`rectangle`,t.currentItemStrokeWidthKey),strokeStyle:t.currentItemStrokeStyle,roundness:t.currentItemRoundness===`round`?{type:at(`rectangle`)?qi.ADAPTIVE_RADIUS:qi.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:e.x-5,y:e.y-5,width:ka(e.width,`rectangle`),height:ka(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);a.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:D.MIDDLE,boundElements:null,textAlign:io.CENTER,autoResize:!0}),ga(e,n,r.scene),a=pO([...a,n],n,e),o[n.id]=!0}return{elements:a,appState:{...t,selectedElementIds:o},captureUpdate:j.IMMEDIATELY}}}),hO=380,gO=42,_O=5,vO=85,yO=500,bO=!1,xO=new Map,SO=({element:e,scene:t,setAppState:n,onLinkOpen:r,setToast:i,updateEmbedValidationStatus:a})=>{let o=t.getNonDeletedElementsMap(),s=SH(),c=_H(),l=vH(),u=e.link||``,[d,f]=(0,V.useState)(u),p=(0,V.useRef)(null),m=s.showHyperlinkPopup===`editor`,h=(0,V.useCallback)(()=>{if(!p.current)return;let r=Ea(p.current.value)||null;if(!e.link&&r&&hw(`hyperlink`,`create`),Fa(e)){if(s.activeEmbeddable?.element===e&&n({activeEmbeddable:null}),!r){t.mutateElement(e,{link:null}),a(e,!1);return}if(!Ac(r,c.validateEmbeddable))r&&i({message:G(`toast.unableToEmbed`),closable:!0}),e.link&&xO.set(e.id,e.link),t.mutateElement(e,{link:r}),a(e,!1);else{let{width:n,height:o}=e,s=ya(r);s?.error instanceof URIError&&i({message:G(`toast.unrecognizedLinkFormat`),closable:!0});let c=s?s.intrinsicSize.w/s.intrinsicSize.h:1,l=xO.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),xO.has(e.id)&&xO.delete(e.id)}}else t.mutateElement(e,{link:r})},[e,t,i,c.validateEmbeddable,s.activeEmbeddable,n,a]);(0,V.useLayoutEffect)(()=>()=>{h()},[h]),(0,V.useEffect)(()=>{m&&p?.current&&!(l.formFactor===`phone`||l.isTouchScreen)&&p.current.select()},[m,l.formFactor,l.isTouchScreen]),(0,V.useEffect)(()=>{let t=null,r=r=>{m||(t&&clearTimeout(t),kO(e,o,s,A(r.clientX,r.clientY))&&(t=window.setTimeout(()=>{n({showHyperlinkPopup:!1})},yO)))};return window.addEventListener(R.POINTER_MOVE,r,!1),()=>{window.removeEventListener(R.POINTER_MOVE,r,!1),t&&clearTimeout(t)}},[s,e,m,n,o]);let g=(0,V.useCallback)(()=>{hw(`hyperlink`,`delete`),t.mutateElement(e,{link:null}),n({showHyperlinkPopup:!1})},[n,e,t]),_=()=>{hw(`hyperlink`,`edit`,`popup-ui`),n({showHyperlinkPopup:`editor`})},{x:v,y}=CO(e,s,o);return s.contextMenu||s.selectedElementsAreBeingDragged||s.resizingElement||s.isRotating||s.openMenu||s.viewModeEnabled?null:(0,H.jsxs)(`div`,{className:`excalidraw-hyperlinkContainer`,style:{top:`${y}px`,left:`${v}px`,width:hO,padding:_O},children:[m?(0,H.jsx)(`input`,{className:U(`excalidraw-hyperlinkContainer-input`),placeholder:G(`labels.link.hint`),ref:p,value:d,onChange:e=>f(e.target.value),autoFocus:!0,onKeyDown:e=>{e.stopPropagation(),e[I.CTRL_OR_CMD]&&e.key===I.K&&e.preventDefault(),(e.key===I.ENTER||e.key===I.ESCAPE)&&(h(),n({showHyperlinkPopup:`info`}))}}):e.link?(0,H.jsx)(`a`,{href:Ea(e.link||``),className:`excalidraw-hyperlinkContainer-link`,target:en(e.link)?`_self`:`_blank`,onClick:t=>{if(e.link&&r){let n=Ns(R.EXCALIDRAW_LINK,t.nativeEvent);r({...e,link:Ea(e.link)},n),n.defaultPrevented&&t.preventDefault()}},rel:`noopener noreferrer`,children:e.link}):(0,H.jsx)(`div`,{className:`excalidraw-hyperlinkContainer-link`,children:G(`labels.link.empty`)}),(0,H.jsxs)(`div`,{className:`excalidraw-hyperlinkContainer__buttons`,children:[!m&&(0,H.jsx)(Y,{type:`button`,title:G(`buttons.edit`),"aria-label":G(`buttons.edit`),label:G(`buttons.edit`),onClick:_,className:`excalidraw-hyperlinkContainer--edit`,icon:ix}),(0,H.jsx)(Y,{type:`button`,title:G(`labels.linkToElement`),"aria-label":G(`labels.linkToElement`),label:G(`labels.linkToElement`),onClick:()=>{n({openDialog:{name:`elementLinkSelector`,sourceElementId:e.id}})},icon:JC}),u&&!Fa(e)&&(0,H.jsx)(Y,{type:`button`,title:G(`buttons.remove`),"aria-label":G(`buttons.remove`),label:G(`buttons.remove`),onClick:g,className:`excalidraw-hyperlinkContainer--remove`,icon:fx})]})]})},CO=(e,t,n)=>{let[r,i]=E(e,n),{x:a,y:o}=dn({sceneX:r+e.width/2,sceneY:i},t);return{x:a-t.offsetLeft-hO/2,y:o-t.offsetTop-vO}},wO=(e,t)=>{let n=is(e,t);return Fa(n[0])?`labels.link.editEmbed`:n[0]?.link?`labels.link.edit`:`labels.link.create`},TO=null,EO=(e,t,n)=>{TO&&clearTimeout(TO),TO=window.setTimeout(()=>DO(e,t,n),300)},DO=(e,t,n)=>{if(!e.link)return;let r=nE();r.classList.add(`excalidraw-tooltip--visible`),r.style.maxWidth=`20rem`,r.textContent=Po(e.link)?G(`labels.link.goToElement`):e.link;let[i,a,o,s]=E(e,n),[c,l,u,d]=yi([i,a,o,s],e.angle,t),f=dn({sceneX:c,sceneY:l},t);rE(r,{left:f.x,top:f.y,width:u,height:d},`top`),hw(`hyperlink`,`tooltip`,`link-icon`),bO=!0},OO=()=>{TO&&clearTimeout(TO),bO&&(bO=!1,nE().classList.remove(`excalidraw-tooltip--visible`))},kO=(e,t,n,[r,i])=>{let{x:a,y:o}=tc({clientX:r,clientY:i},n),s=15/n.zoom.value;if(mt(A(a,o),e,t))return!1;let[c,l,u]=E(e,t);if(a>=c&&a<=u&&o>=l-vO&&o<=l)return!1;let{x:d,y:f}=CO(e,n,t);return!(r>=d-s&&r<=d+hO+_O*2+s&&i>=f-s&&i<=f+s+_O*2+gO)},AO=X({name:`hyperlink`,label:(e,t)=>wO(At(e),t),icon:Ex,perform:(e,t)=>t.showHyperlinkPopup!==`editor`&&{elements:e,appState:{...t,showHyperlinkPopup:`editor`,openMenu:null},captureUpdate:j.IMMEDIATELY},trackEvent:{category:`hyperlink`,action:`click`},keyTest:e=>e[I.CTRL_OR_CMD]&&e.key===I.K,predicate:(e,t)=>is(e,t).length===1,PanelComponent:({elements:e,appState:t,updateData:n})=>{let r=is(e,t);return(0,H.jsx)(Y,{type:`toggle`,icon:Ex,"aria-label":G(wO(At(e),t)),title:`${Fa(e[0])?G(`labels.link.labelEmbed`):G(`labels.link.label`)} - ${Z(`CtrlOrCmd+K`)}`,onSelect:()=>n(null),checked:r.length===1&&!!r[0].link})}}),jO=e=>e.every(e=>!e.locked),MO=X({name:`toggleElementLock`,label:(e,t,n)=>jO(n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1}))?`labels.elementLock.lock`:`labels.elementLock.unlock`,icon:(e,t)=>jO(is(t,e))?Gb:Wb,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=jO(i),o=ze(i),s=i.length>1&&Va(i),c=i.length===1||s?null:Ae(),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]),z(e,{locked:a,groupIds:n.length===e.groupIds.length?e.groupIds:n})}),d=ze(u),f=a?{}:Object.fromEntries(i.map(e=>[e.id,!0])),p=i.map(e=>d.get(e.id)||e),m=a?{}:Nt(At(p),t),h=a?c||(s?i[0].groupIds.at(-1):i[0].id):null;return{elements:u,appState:{...t,selectedElementIds:f,selectedGroupIds:m,selectedLinearElement:a?null:t.selectedLinearElement,lockedMultiSelections:l,activeLockedId:h},captureUpdate:j.IMMEDIATELY}},keyTest:(e,t,n,r)=>e.key.toLocaleLowerCase()===I.L&&e[I.CTRL_OR_CMD]&&e.shiftKey&&r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1}).length>0}),NO=X({name:`unlockAllElements`,trackEvent:{category:`canvas`},viewMode:!1,icon:Wb,predicate:(e,t)=>is(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 z(e,{locked:!1,groupIds:e.groupIds.length===n.length?e.groupIds:n})}return e}),i=ze(r),a=n.map(e=>i.get(e.id)||e),o=At(a);return{elements:r,appState:{...t,selectedElementIds:Object.fromEntries(o.map(e=>[e.id,!0])),selectedGroupIds:Nt(o,t),lockedMultiSelections:{},activeLockedId:null},captureUpdate:j.IMMEDIATELY}},label:`labels.elementLock.unlockAll`}),PO=8,FO=10,IO=[`rectangle`,`diamond`,`ellipse`],LO=[`line`,`sharpArrow`,`curvedArrow`,`elbowArrow`],RO=new Set(IO),zO=new Set(LO),BO=e=>RO.has(e),VO=e=>e===`arrow`||zO.has(e),HO=Yc(null),UO=new Map,WO=new Map,GO=({app:e})=>{let t=e.scene.getSelectedElements(e.state),n=(0,V.useRef)(null);return(0,V.useEffect)(()=>{if(t.length===0){e.updateEditorAtom(HO,null);return}let r=YO(t);r&&!n.current?n.current=r:(n.current&&!r||n.current&&r!==n.current)&&(e.updateEditorAtom(HO,null),n.current=null)},[t,e]),(0,V.useEffect)(()=>()=>{UO.clear(),WO.clear()},[]),(0,H.jsx)(KO,{app:e,elements:t})},KO=({app:e,elements:t})=>{let n=YO(t),r=(0,V.useMemo)(()=>n===`generic`?QO(t):[],[n,t]),i=(0,V.useMemo)(()=>n===`linear`?$O(t):[],[n,t]),a=n===`generic`?r.every(e=>e.type===r[0].type):n===`linear`&&i.every(e=>zn(e)===zn(i[0])),[o,s]=(0,V.useState)({x:0,y:0}),c=(0,V.useRef)(``),l=(0,V.useRef)(null);(0,V.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]=E(t[0],e.scene.getNonDeletedElementsMap());a=_o(A(n,r),A(i,o),t[0].angle)}else{let{minX:e,maxY:n}=Lt(t);a=A(e,n)}let{x:o,y:l}=dn({sceneX:a[0],sceneY:a[1]},e.state);s({x:o,y:l})},[r,i,e.scene,e.state]),(0,V.useEffect)(()=>{for(let e of i){let t=ZO(e.id,ck(e));WO.has(t)||WO.set(t,e)}},[i]),(0,V.useEffect)(()=>{for(let t of r)if(!UO.has(t.id)){let n=ao(t,e.scene.getNonDeletedElementsMap());n&&UO.set(t.id,{fontSize:n.fontSize})}},[r,e.scene]);let u=n===`linear`?[[`line`,nx],[`sharpArrow`,VC],[`curvedArrow`,UC],[`elbowArrow`,HC]]:n===`generic`?[[`rectangle`,Qb],[`diamond`,$b],[`ellipse`,ex]]:[];return(0,H.jsx)(`div`,{ref:l,tabIndex:-1,style:{position:`absolute`,top:`${o.y+(FO+8)*e.state.zoom.value-e.state.offsetTop}px`,left:`${o.x-e.state.offsetLeft-PO}px`,zIndex:2},className:Os.CONVERT_ELEMENT_TYPE_POPUP,children:u.map(([o,s])=>{let c=a&&(n===`generic`&&r[0].type===o||n===`linear`&&zn(i[0])===o);return(0,H.jsx)(Y,{type:`toggle`,icon:s,checked:c,title:o,"aria-label":o,"data-testid":`toolbar-${o}`,onSelect:()=>{c||(e.state.activeTool.type!==o&&hw(`convertElementType`,o,`ui`),JO(e,{conversionType:n,nextType:o}),l.current?.focus())}},`${t[0].id}${t[0].version}_${o}`)})})},qO=(e,t,n)=>{let r=Ot(e,t),i=ro(e,t),a=yc(t.text,se(t),r),o=xa(a,se(t),t.lineHeight),s=t.fontSize;for(;(o.width>r||o.height>i)&&s>0;){--s;let e={...t,fontSize:s};o=xa(t.text,se(e),t.lineHeight)}ur(t,n.getNonDeletedElementsMap(),{fontSize:s,width:o.width,height:o.height}),ga(t,e,n)},JO=(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=QO(i),r=t.every(e=>e.type===t[0].type)?IO.indexOf(t[0].type):-1;if(n??=IO[(r+IO.length+o)%IO.length],n&&BO(n)){let r={};for(let i of t){let t=ok(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=ao(t,e.scene.getNonDeletedElementsMap());n&&(UO.get(t.id)&&ur(n,e.scene.getNonDeletedElementsMap(),{fontSize:UO.get(t.id)?.fontSize??n.fontSize}),qO(t,n,e.scene))}e.setState(e=>({selectedElementIds:a,activeTool:$r(e,{type:`selection`})}))}}if(t===`linear`){let t=$O(i);if(!n){let e=_e(t,zn);n=LO[((e?LO.indexOf(e):-1)+LO.length+o)%LO.length]}if(VO(n)){let r=[],i=e.scene.getElementsMapIncludingDeleted();for(let a of t){let t=WO.get(ZO(a.id,n));if(t&&zn(t)===n)i.set(t.id,t),r.push(t);else{let t=ok(a,n,e);i.set(t.id,t),r.push(t)}}e.scene.replaceAllElements(i);for(let t of r)if(vo(t)){if(fe(t)){let n=ik(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=Re(t,e.scene.getNonDeletedElementsMap(),{points:n,fixedSegments:r});ur(t,e.scene.getNonDeletedElementsMap(),{...i,endArrowhead:`arrow`})}else{let n=as([`line`,`sharpArrow`,`curvedArrow`],e=>WO.get(ZO(t.id,e)));if(n){let r=n.points;e.scene.mutateElement(t,{points:r})}}}}let r=$O(e.scene.getSelectedElements(e.state));e.setState(t=>({selectedElementIds:a,selectedLinearElement:r.length===1?new M(r[0],e.scene.getNonDeletedElementsMap()):null,activeTool:$r(t,{type:`selection`})}))}return!0},YO=e=>{if(e.length===0)return null;let t=!1;for(let n of e){if(BO(n.type))return`generic`;XO(n)&&(t=!0)}return t?`linear`:null},XO=e=>vo(e)&&(!Wa(e)||!Bi(e)&&!Qr(e)),ZO=(e,t)=>`${e}:${t}`,QO=e=>e.filter(e=>BO(e.type)),$O=e=>e.filter(e=>XO(e)),ek=20,tk=(e,t)=>e[0]===t[0],nk=(e,t)=>e[1]===t[1],rk=(e,t)=>tk(e,t)?Math.abs(e[1]-t[1]):Math.abs(e[0]-t[0]),ik=e=>{let t=[e.points[0]],n=ak(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])<ek?i[0]=r[0]:Math.abs(i[1]-r[1])<ek&&(i[1]=r[1]),tk(r,i)||nk(r,i)||t.push(A(r[0],i[1])),t.push(i)}let r=[t[0]];for(let e=1;e<t.length-1;++e)tk(t[e-1],t[e])&&tk(t[e],t[e+1])||nk(t[e-1],t[e])&&nk(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=tk(t,n),s=tk(n,a);if(o!==s){let e=rk(t,n),r=rk(n,a);if(e<ek||r<ek){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},ak=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},ok=(e,t,n)=>{if(!sk(e.type,t)){if(!Cn())throw Error(`Invalid conversion from ${e.type} to ${t}.`);return e}if(e.type===t)return e;if(yr.delete(e),BO(t)){let r=xr(_c({...e,type:t,roundness:e.roundness?{type:at(t)?qi.ADAPTIVE_RADIUS:qi.PROPORTIONAL_RADIUS}:e.roundness}));return An(r,n.scene,n.state),r}if(VO(t))switch(t){case`line`:return xr(ie({...e,type:`line`}));case`sharpArrow`:return xr(mi({...e,type:`arrow`,elbowed:!1,roundness:null,startArrowhead:n.state.currentItemStartArrowhead,endArrowhead:n.state.currentItemEndArrowhead}));case`curvedArrow`:return xr(mi({...e,type:`arrow`,elbowed:!1,roundness:{type:qi.PROPORTIONAL_RADIUS},startArrowhead:n.state.currentItemStartArrowhead,endArrowhead:n.state.currentItemEndArrowhead}));case`elbowArrow`:return xr(mi({...e,type:`arrow`,elbowed:!0,fixedSegments:null,roundness:null}))}return Cc(t,`unhandled conversion type: ${t}`),e},sk=(e,t)=>!!(BO(e)&&BO(t)||VO(e)&&VO(t)),ck=e=>vo(e)?zn(e):e.type,lk=GO,uk=X({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 Sb.set(HO,{type:`panel`}),{captureUpdate:j.NEVER}},checked:e=>e.gridModeEnabled,predicate:(e,t,n)=>YO(e)!==null}),dk=X({name:`copyElementLink`,label:`labels.copyElementLink`,icon:tC,trackEvent:{category:`element`},perform:async(e,t,n,r)=>{let i=is(e,t);try{if(window.location){let n=ma(i,t);return n?(await dD(r.props.generateLinkForSelection?r.props.generateLinkForSelection(n.id,n.type):Qe(n.id,n.type)),{appState:{toast:{message:G(`toast.elementLinkCopied`),closable:!0}},captureUpdate:j.EVENTUALLY}):{appState:t,elements:e,app:r,captureUpdate:j.EVENTUALLY}}}catch(e){console.error(e)}return{appState:t,elements:e,app:r,captureUpdate:j.EVENTUALLY}},predicate:(e,t)=>Br(is(e,t))}),fk=X({name:`linkToElement`,label:`labels.linkToElement`,icon:JC,perform:(e,t,n,r)=>{let i=is(e,t);return i.length!==1||!Br(i)?{elements:e,appState:t,app:r,captureUpdate:j.EVENTUALLY}:{appState:{...t,openDialog:{name:`elementLinkSelector`,sourceElementId:is(e,t)[0].id}},captureUpdate:j.IMMEDIATELY}},predicate:(e,t,n,r)=>{let i=is(e,t);return t.openDialog?.name!==`elementLinkSelector`&&i.length===1&&Br(i)},trackEvent:!1}),pk={toggleTheme:[Z(`Shift+Alt+D`)],saveScene:[Z(`CtrlOrCmd+S`)],loadScene:[Z(`CtrlOrCmd+O`)],clearCanvas:[Z(`CtrlOrCmd+Delete`)],imageExport:[Z(`CtrlOrCmd+Shift+E`)],commandPalette:[Z(`CtrlOrCmd+/`),Z(`CtrlOrCmd+Shift+P`)],cut:[Z(`CtrlOrCmd+X`)],copy:[Z(`CtrlOrCmd+C`)],paste:[Z(`CtrlOrCmd+V`)],copyStyles:[Z(`CtrlOrCmd+Alt+C`)],pasteStyles:[Z(`CtrlOrCmd+Alt+V`)],selectAll:[Z(`CtrlOrCmd+A`)],deleteSelectedElements:[Z(`Delete`)],duplicateSelection:[Z(`CtrlOrCmd+D`),Z(`Alt+${G(`helpDialog.drag`)}`)],sendBackward:[Z(`CtrlOrCmd+[`)],bringForward:[Z(`CtrlOrCmd+]`)],sendToBack:[Z(uo?`CtrlOrCmd+Alt+[`:`CtrlOrCmd+Shift+[`)],bringToFront:[Z(uo?`CtrlOrCmd+Alt+]`:`CtrlOrCmd+Shift+]`)],copyAsPng:[Z(`Shift+Alt+C`)],group:[Z(`CtrlOrCmd+G`)],ungroup:[Z(`CtrlOrCmd+Shift+G`)],gridMode:[Z(`CtrlOrCmd+'`)],zenMode:[Z(`Alt+Z`)],objectsSnapMode:[Z(`Alt+S`)],stats:[Z(`Alt+/`)],addToLibrary:[],flipHorizontal:[Z(`Shift+H`)],flipVertical:[Z(`Shift+V`)],viewMode:[Z(`Alt+R`)],hyperlink:[Z(`CtrlOrCmd+K`)],toggleElementLock:[Z(`CtrlOrCmd+Shift+L`)],resetZoom:[Z(`CtrlOrCmd+0`)],zoomOut:[Z(`CtrlOrCmd+-`)],zoomIn:[Z(`CtrlOrCmd++`)],zoomToFitSelection:[Z(`Shift+3`)],zoomToFit:[Z(`Shift+1`)],zoomToFitSelectionInViewport:[Z(`Shift+2`)],saveFileToDisk:[Z(`CtrlOrCmd+S`)],saveToActiveFile:[Z(`CtrlOrCmd+S`)],toggleShortcuts:[Z(`?`)],searchMenu:[Z(`CtrlOrCmd+F`)],wrapSelectionInFrame:[],toolLock:[Z(`Q`)]},mk=(e,t=0)=>{let n=pk[e];return n&&n.length>0?n[t]||n[0]:``},hk=RegExp(`[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]`,`g`),gk=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,_k={À:`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`},vk=e=>e.replace(gk,e=>_k[e]||e).replace(hk,``),yk=()=>{let[e,t]=(0,V.useState)(null);return[e,(0,V.useCallback)(e=>t(e),[])]},bk=({elements:e,appState:t,files:n,maxWidthOrHeight:r,getDimensions:i,exportPadding:a,exportingFrame:o})=>{let s=At(Le(e,null,{deleteInvisibleElements:!0})),c=La(t,null),{exportBackground:l,viewBackgroundColor:u}=c;return Dc(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}})},xk=async e=>{let{mimeType:t=L.png,quality:n}=e;t===L.png&&typeof n==`number`&&console.warn(`"quality" will be ignored for "${L.png}" mimeType`),t===`image/jpg`&&(t=L.jpg),t===L.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${L.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let r=await bk(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===L.png&&e.appState?.exportEmbedScene&&(n=await ki({blob:n,metadata:$s(e.elements,e.appState,e.files||{},`local`)})),i(n)},t,n)})},Sk=async({elements:e,appState:t=kr(),files:n={},exportPadding:r,renderEmbeddables:i,exportingFrame:a,skipInliningFonts:o,reuseImages:s})=>{let c=At(Le(e,null,{deleteInvisibleElements:!0})),l={...La(t,null),exportPadding:r};return O(c,l,n,{exportingFrame:a,renderEmbeddables:i,skipInliningFonts:o,reuseImages:s})},Ck=async e=>{if(e.type===`svg`)await dD((await Sk(e)).outerHTML);else if(e.type===`png`)await uD(xk(e));else if(e.type===`json`)await $E(e.elements,e.files);else throw Error(`Invalid export type`)},wk=Yc(new Map),Tk=async e=>await Sk({elements:e,appState:{exportBackground:!1,viewBackgroundColor:Tt.white},files:null,renderEmbeddables:!1,skipInliningFonts:!0}),Ek=(e,t,n,r)=>{let[i,a]=(0,V.useState)();return(0,V.useEffect)(()=>{if(t){if(e){let r=n.get(e);r?a(r):(async()=>{let r=await Tk(t);r.querySelector(`.style-fonts`)?.remove(),r&&(n.set(e,r),a(r))})()}else(async()=>{let e=await Tk(t);a(e)})()}},[e,t,n,a]),(0,V.useEffect)(()=>{let e=r.current;if(e)return i&&(e.innerHTML=i.outerHTML),()=>{e.innerHTML=``}},[i,r]),i},Dk=()=>{let[e]=_b(wk);return{clearLibraryCache:()=>e.clear(),deleteItemsFromLibraryCache:t=>{t.forEach(t=>e.delete(t))},svgCache:e}},Ok=[`excalidraw.com`,`raw.githubusercontent.com/excalidraw/excalidraw-libraries`],kk=new Qn,Ak=Yc({status:`loaded`,isInitialized:!1,libraryItems:[]}),jk=e=>g(e),Mk=(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)),Nk=(e,t)=>{let n=[];for(let r of t)Mk(e,r)&&n.push(r);return[...n,...e]},Pk=(e,t)=>{let n=ze(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=ze(e);for(let e of t){let t=i.get(e.id);t?Uk(t)!==Uk(e)&&r.updatedItems.set(e.id,e):r.addedItems.set(e.id,e)}return r},Fk=class{constructor(e){B(this,`currLibraryItems`,[]),B(this,`prevLibraryItems`,jk(this.currLibraryItems)),B(this,`app`),B(this,`updateQueue`,[]),B(this,`getLastUpdateTask`,()=>this.updateQueue[this.updateQueue.length-1]),B(this,`notifyListeners`,()=>{if(this.updateQueue.length>0)Sb.set(Ak,e=>({status:`loading`,libraryItems:this.currLibraryItems,isInitialized:e.isInitialized}));else{Sb.set(Ak,{status:`loaded`,libraryItems:this.currLibraryItems,isInitialized:!0});try{let e=this.prevLibraryItems;this.prevLibraryItems=jk(this.currLibraryItems);let t=jk(this.currLibraryItems);this.app.props.onLibraryChange?.(t),kk.trigger(Pk(e,t),t)}catch(e){console.error(e)}}}),B(this,`destroy`,()=>{this.updateQueue=[],this.currLibraryItems=[],Sb.set(wk,new Map)}),B(this,`resetLibrary`,()=>this.setLibrary([])),B(this,`getLatestLibrary`,()=>new Promise(async e=>{try{let t=await(this.getLastUpdateTask()||this.currLibraryItems);this.updateQueue.length>0?e(this.getLatestLibrary()):e(jk(t))}catch{return e(this.currLibraryItems)}})),B(this,`updateLibrary`,async({libraryItems:e,prompt:t=!1,merge:n=!1,openLibraryMenu:r=!1,defaultStatus:i=`unpublished`})=>(r&&this.app.setState({openSidebar:{name:lr.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 cc(o,i):ln(o,i),!t||window.confirm(G(`alerts.confirmAddLibrary`,{numShapes:s.length}))?(t&&this.app.focusContainer(),r(n?Nk(this.currLibraryItems,s):s)):a(new gs)}catch(e){a(e)}})))),B(this,`setLibrary`,e=>{let t=new Promise(async(t,n)=>{try{await this.getLastUpdateTask(),typeof e==`function`&&(e=e(this.currLibraryItems)),this.currLibraryItems=jk(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}},Ik=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}=Lt(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}=Lt(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 f 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:p,width:m,height:h}=Lt(f.elements),g=(c-m)/2,_=(s-h)/2;n.push(...f.elements.map(t=>({...t,x:t.x+a+g-e,y:t.y+o+_-p}))),a+=c+50,l++,u++}return n},Lk=(e,t=Ok)=>{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}"`)},Rk=()=>{let e=new URLSearchParams(window.location.hash.slice(1)).get(Yi.addLibrary)||new URLSearchParams(window.location.search).get(zo.addLibrary),t=e?new URLSearchParams(window.location.hash.slice(1)).get(`token`):null;return e?{libraryUrl:e,idToken:t}:null},zk=class e{constructor(e){B(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(ln(r?.libraryItems||[],`published`))}catch(e){r(e)}});return r?e.queue.push(i):i()}getLibraryItems(t){return e.getLibraryItems(this.adapter,t,!1)}};B(zk,`queue`,new zr),B(zk,`run`,async(e,t)=>{let n=new zk(e);return zk.queue.push(()=>t(n))});var Bk=zk,Vk=0,Hk=0,Uk=e=>`${e.id}:${e.name||``}:${oi(e.elements)}`,Wk=e=>_s(e.map(e=>Uk(e)).sort().join()),Gk=async(e,t)=>{try{return Hk++,await Bk.run(e,async n=>{let r=ze(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=Wk(a);return o!==Vk&&await e.save({libraryItems:a}),Vk=o,a})}finally{Hk--}},Kk=e=>{let{excalidrawAPI:t}=e,n=(0,V.useRef)(e);n.current=e;let r=(0,V.useRef)(!1);(0,V.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=_t(e),Lk(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(Yi.addLibrary)){let e=new URLSearchParams(window.location.hash.slice(1));e.delete(Yi.addLibrary),window.history.replaceState({},Mt,`#${e.toString()}`)}else if(window.location.search.includes(zo.addLibrary)){let e=new URLSearchParams(window.location.search);e.delete(zo.addLibrary),window.history.replaceState({},Mt,`?${e.toString()}`)}}},i=t=>{t.preventDefault();let n=Rk();n&&(t.stopImmediatePropagation(),window.history.replaceState({},``,t.oldURL),e(n))},a=Rk();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=pr();i?a.resolve(Us(i.load).then(async t=>{let n=null;try{if(!t)return Bk.getLibraryItems(e,`load`);n=ln(t.libraryItems||[],`published`);let r=await Gk(e,Pk([],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}`),Bk.getLibraryItems(e,`load`)))):a.resolve(Us(Bk.getLibraryItems,e,`load`)),t.updateLibrary({libraryItems:a.then(e=>{let t=e||[];return Vk=Wk(t),t}),merge:!0}).finally(()=>{r.current=!0})}return window.addEventListener(R.HASHCHANGE,i),()=>{window.removeEventListener(R.HASHCHANGE,i)}},[t]),(0,V.useEffect)(()=>{let e=kk.on(async(e,t)=>{let i=r.current,a=`adapter`in n.current&&n.current.adapter||null;try{a&&Vk!==Wk(t)&&await Gk(a,e)}catch(t){console.error(`couldn't persist library update: ${t.message}`,e),i&&n.current.excalidrawAPI&&n.current.excalidrawAPI.updateScene({appState:{errorMessage:G(`errors.saveLibraryError`)}})}}),t=e=>{Hk&&$e(e)};return window.addEventListener(R.BEFORE_UNLOAD,t),()=>{window.removeEventListener(R.BEFORE_UNLOAD,t),e(),Vk=0,Hk=0}},[])},qk=({theme:e,id:t,libraryReturnUrl:n})=>{let r=n||window.location.origin+window.location.pathname;return(0,H.jsx)(`a`,{className:`library-menu-browse-button`,href:`${nn.VITE_APP_LIBRARY_URL}?target=${window.name||`_blank`}&referrer=${r}&useHash=true&token=${t}&theme=${e}&version=${Rn.excalidrawLibrary}`,target:`_excalidraw_libraries`,children:G(`labels.libraries`)})},Jk=({libraryReturnUrl:e,theme:t,id:n,style:r,children:i,className:a})=>(0,H.jsxs)(`div`,{className:U(`library-menu-control-buttons`,a),style:r,children:[(0,H.jsx)(qk,{id:n,libraryReturnUrl:e,theme:t}),i]}),Yk=Yc(0),Xk=e=>{let[t,n]=_b(Yk);return(0,V.useEffect)(()=>{let{current:t}=e;if(!t)return;let r=(0,Kc.default)(()=>{let{scrollTop:e}=t;n(e)},200);return t.addEventListener(`scroll`,r),()=>{r.cancel(),t.removeEventListener(`scroll`,r)}},[e,n]),t},Zk=({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,H.jsxs)(`button`,{className:U(`Dialog__action-button`,c,n),type:a,"aria-label":e,onClick:t,...s,children:[r&&(0,H.jsx)(`div`,{style:o?{visibility:`hidden`}:{},children:r}),(0,H.jsx)(`div`,{style:o?{visibility:`hidden`}:{},children:e}),o&&(0,H.jsx)(`div`,{style:{position:`absolute`,inset:0},children:(0,H.jsx)(rw,{})})]})},Qk=e=>{let{onConfirm:t,onCancel:n,children:r,confirmText:i=G(`buttons.confirm`),cancelText:a=G(`buttons.cancel`),className:o=``,...s}=e,c=CH(),l=vb(JA),{container:u}=bH();return(0,H.jsxs)(nj,{onCloseRequest:n,size:`small`,...s,className:`confirm-dialog ${o}`,children:[r,(0,H.jsxs)(`div`,{className:`confirm-dialog-buttons`,children:[(0,H.jsx)(Zk,{label:a,onClick:()=>{c({openMenu:null}),l(!1),(0,qc.flushSync)(()=>{n()}),u?.focus()}}),(0,H.jsx)(Zk,{label:i,onClick:()=>{c({openMenu:null}),l(!1),(0,qc.flushSync)(()=>{t()}),u?.focus()},actionType:`danger`})]})]})},$k=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}}};B($k,`set`,(e,t)=>{try{return window.localStorage.setItem(e,JSON.stringify(t)),!0}catch(e){return console.warn(`localStorage.setItem error: ${e.message}`),!1}}),B($k,`delete`,e=>{try{window.localStorage.removeItem(e)}catch(e){console.warn(`localStorage.removeItem error: ${e.message}`)}});var eA=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,tA=/{{([\w-]+)}}/,nA=/<([\w-]+)>/,rA=/<\/([\w-]+)>/,iA=(e,t)=>{let n=[{name:``,children:[]}];return e.split(eA).filter(Boolean).forEach(r=>{let i=r.match(nA),a=r.match(rA),o=r.match(tA);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=V.createElement(V.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},aA=({i18nKey:e,children:t,...n})=>{let{t:r}=Pb();return V.createElement(V.Fragment,{},...iA(r(e),n))},oA=async e=>{let t=Go(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 bk({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 Kr(new File([await Ke(n)],`preview`,{type:L.png}),{outputType:L.jpg,maxWidthOrHeight:5e3})},sA=({libItem:e,appState:t,index:n,onChange:r,onRemove:i})=>{let a=(0,V.useRef)(null),o=(0,V.useRef)(null);return(0,V.useEffect)(()=>{let n=a.current;n&&(async()=>{let r=await Sk({elements:e.elements,appState:{...t,viewBackgroundColor:`#fff`,exportBackground:!0},files:null,skipInliningFonts:!0});n.innerHTML=r.outerHTML})()},[e.elements,t]),(0,H.jsxs)(`div`,{className:`single-library-item`,children:[e.status===`published`&&(0,H.jsx)(`span`,{className:`single-library-item-status`,children:G(`labels.statusPublished`)}),(0,H.jsx)(`div`,{ref:a,className:`single-library-item__svg`}),(0,H.jsx)(Y,{"aria-label":G(`buttons.remove`),type:`button`,icon:nS,className:`single-library-item--remove`,onClick:i.bind(null,e.id),title:G(`buttons.remove`)}),(0,H.jsxs)(`div`,{style:{display:`flex`,margin:`0.8rem 0`,width:`100%`,fontSize:`14px`,fontWeight:500,flexDirection:`column`},children:[(0,H.jsxs)(`label`,{style:{display:`flex`,justifyContent:`space-between`,flexDirection:`column`},children:[(0,H.jsxs)(`div`,{style:{padding:`0.5em 0`},children:[(0,H.jsx)(`span`,{style:{fontWeight:500,color:`#868e96`},children:G(`publishDialog.itemName`)}),(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`required`,children:`*`})]}),(0,H.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,H.jsx)(`span`,{className:`error`,children:e.error})]})]})},cA=({onClose:e,libraryItems:t,appState:n,onSuccess:r,onError:i,updateItemsInStorage:a,onRemove:o})=>{let[s,c]=(0,V.useState)({authorName:``,githubHandle:``,name:``,description:``,twitterHandle:``,website:``}),[l,u]=(0,V.useState)(!1);(0,V.useEffect)(()=>{let e=$k.get(ts.PUBLISH_LIBRARY);e&&c(e)},[]);let[d,f]=(0,V.useState)(t.slice());(0,V.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=G(`publishDialog.errors.required`),n=!0),t.push({...e,error:r})}),n){f(t),u(!1);return}let a=await oA(d),o={type:ot.excalidrawLibrary,version:Rn.excalidrawLibrary,source:Ys(),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(`${nn.VITE_APP_LIBRARY_BACKEND}/submit`,{method:`post`,body:p}).then(e=>e.ok?e.json().then(({url:e})=>{$k.delete(ts.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,H.jsx)(`div`,{className:`single-library-item-wrapper`,children:(0,H.jsx)(sA,{libItem:t,appState:n,index:r,onChange:(e,t)=>{let n=d.slice();n[t].name=e,f(n)},onRemove:o})},r))}),(0,H.jsx)(`div`,{className:`selected-library-items`,children:e})},g=(0,V.useCallback)(()=>{a(d),$k.set(ts.PUBLISH_LIBRARY,s),e()},[d,e,a,s]),_=!!t.length,v=t.some(e=>e.status===`published`);return(0,H.jsx)(nj,{onCloseRequest:g,title:G(`publishDialog.title`),className:`publish-library`,children:_?(0,H.jsxs)(`form`,{onSubmit:m,children:[(0,H.jsx)(`div`,{className:`publish-library-note`,children:(0,H.jsx)(aA,{i18nKey:`publishDialog.noteDescription`,link:e=>(0,H.jsx)(`a`,{href:`https://libraries.excalidraw.com`,target:`_blank`,rel:`noopener`,children:e})})}),(0,H.jsx)(`span`,{className:`publish-library-note`,children:(0,H.jsx)(aA,{i18nKey:`publishDialog.noteGuidelines`,link:e=>(0,H.jsx)(`a`,{href:`https://github.com/excalidraw/excalidraw-libraries#guidelines`,target:`_blank`,rel:`noopener noreferrer`,children:e})})}),(0,H.jsx)(`div`,{className:`publish-library-note`,children:G(`publishDialog.noteItems`)}),v&&(0,H.jsx)(`span`,{className:`publish-library-note publish-library-warning`,children:G(`publishDialog.republishWarning`)}),h(),(0,H.jsxs)(`div`,{className:`publish-library__fields`,children:[(0,H.jsxs)(`label`,{children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{children:G(`publishDialog.libraryName`)}),(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`required`,children:`*`})]}),(0,H.jsx)(`input`,{type:`text`,name:`name`,required:!0,value:s.name,onChange:p,placeholder:G(`publishDialog.placeholder.libraryName`)})]}),(0,H.jsxs)(`label`,{style:{alignItems:`flex-start`},children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{children:G(`publishDialog.libraryDesc`)}),(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`required`,children:`*`})]}),(0,H.jsx)(`textarea`,{name:`description`,rows:4,required:!0,value:s.description,onChange:p,placeholder:G(`publishDialog.placeholder.libraryDesc`)})]}),(0,H.jsxs)(`label`,{children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`span`,{children:G(`publishDialog.authorName`)}),(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`required`,children:`*`})]}),(0,H.jsx)(`input`,{type:`text`,name:`authorName`,required:!0,value:s.authorName,onChange:p,placeholder:G(`publishDialog.placeholder.authorName`)})]}),(0,H.jsxs)(`label`,{children:[(0,H.jsx)(`span`,{children:G(`publishDialog.githubUsername`)}),(0,H.jsx)(`input`,{type:`text`,name:`githubHandle`,value:s.githubHandle,onChange:p,placeholder:G(`publishDialog.placeholder.githubHandle`)})]}),(0,H.jsxs)(`label`,{children:[(0,H.jsx)(`span`,{children:G(`publishDialog.twitterUsername`)}),(0,H.jsx)(`input`,{type:`text`,name:`twitterHandle`,value:s.twitterHandle,onChange:p,placeholder:G(`publishDialog.placeholder.twitterHandle`)})]}),(0,H.jsxs)(`label`,{children:[(0,H.jsx)(`span`,{children:G(`publishDialog.website`)}),(0,H.jsx)(`input`,{type:`text`,name:`website`,pattern:`https?://.+`,title:G(`publishDialog.errors.website`),value:s.website,onChange:p,placeholder:G(`publishDialog.placeholder.website`)})]}),(0,H.jsx)(`span`,{className:`publish-library-note`,children:(0,H.jsx)(aA,{i18nKey:`publishDialog.noteLicense`,link:e=>(0,H.jsx)(`a`,{href:`https://github.com/excalidraw/excalidraw-libraries/blob/main/LICENSE`,target:`_blank`,rel:`noopener noreferrer`,children:e})})})]}),(0,H.jsxs)(`div`,{className:`publish-library__buttons`,children:[(0,H.jsx)(Zk,{label:G(`buttons.saveLibNames`),onClick:g,"data-testid":`cancel-clear-canvas-button`}),(0,H.jsx)(Zk,{type:`submit`,label:G(`buttons.submit`),actionType:`primary`,isLoading:l})]})]}):(0,H.jsx)(`p`,{style:{padding:`1em`,textAlign:`center`,fontWeight:500},children:G(`publishDialog.atleastOneLibItem`)})})},lA={Row:(0,V.forwardRef)(({children:e,gap:t,align:n,justifyContent:r,className:i,style:a},o)=>(0,H.jsx)(`div`,{className:U(`Stack Stack_horizontal`,i),style:{"--gap":t,alignItems:n,justifyContent:r,...a},ref:o,children:e})),Col:(0,V.forwardRef)(({children:e,gap:t,align:n,justifyContent:r,className:i,style:a},o)=>(0,H.jsx)(`div`,{className:U(`Stack Stack_vertical`,i),style:{"--gap":t,justifyItems:n,justifyContent:r,...a},ref:o,children:e}))},uA=({children:e,onClickOutside:t,className:n=``,onSelect:r,open:i=!0,align:a=`end`,style:o})=>{let s=vH(),c=(0,V.useRef)(null),l=Cw({onClickOutside:t});Sw(c,(0,V.useCallback)(e=>{c.current?.closest(`.${Os.DROPDOWN_MENU_EVENT_WRAPPER}`)?.contains(e.target)||l.onClickOutside?.()},[l])),(0,V.useEffect)(()=>{if(!i)return;let e=e=>{e.key===I.ESCAPE&&(e.preventDefault(),e.stopImmediatePropagation(),l.onClickOutside?.())},t={capture:!0};return document.addEventListener(R.KEYDOWN,e,t),()=>{document.removeEventListener(R.KEYDOWN,e,t)}},[l,i]);let u=U(`dropdown-menu ${n}`,{"dropdown-menu--mobile":s.formFactor===`phone`}).trim();return(0,H.jsx)(gT.Provider,{value:{onSelect:r},children:(0,H.jsx)(wv,{ref:c,className:u,style:o,"data-testid":`dropdown-menu`,align:a,sideOffset:8,onCloseAutoFocus:e=>e.preventDefault(),children:s.formFactor===`phone`?(0,H.jsx)(lA.Col,{className:`dropdown-menu-container`,children:e}):(0,H.jsx)(Aw,{className:`dropdown-menu-container`,padding:2,children:e})})})};uA.displayName=`DropdownMenuContent`;var dA=uA,fA=({children:e,className:t=``,selected:n,...r})=>(0,H.jsx)(`div`,{...r,className:`dropdown-menu-item-base dropdown-menu-item-custom ${t} ${n?`dropdown-menu-item--selected`:``}`.trim(),children:e}),pA=({icon:e,shortcut:t,href:n,children:r,onSelect:i,className:a=``,selected:o,rel:s=`noopener`,...c})=>{let l=vT(i);return(0,H.jsx)(Tv,{className:`radix-menu-item`,onSelect:l,asChild:!0,children:(0,H.jsx)(`a`,{...c,href:n,target:`_blank`,rel:`noopener ${s}`,className:_T(a,o),title:c.title??c[`aria-label`],children:(0,H.jsx)(bT,{icon:e,shortcut:t,children:r})})})},mA=pA;pA.displayName=`DropdownMenuItemLink`;var hA=()=>(0,H.jsx)(`div`,{style:{height:`1px`,backgroundColor:`var(--default-border-color)`,margin:`6px 0`,flex:`0 0 auto`}}),gA=hA;hA.displayName=`DropdownMenuSeparator`;var _A=-4,vA=4,yA=({children:e,className:t})=>{let n=vH(),r=U(`dropdown-menu dropdown-submenu ${t}`,{"dropdown-menu--mobile":n.formFactor===`phone`}).trim(),i=(0,V.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+_A),c(_A+8))}}},[]),[a,o]=(0,V.useState)(vA),[s,c]=(0,V.useState)(_A);return(0,H.jsx)(Ov,{className:r,sideOffset:a,alignOffset:s,collisionPadding:8,ref:i,children:n.formFactor===`phone`?(0,H.jsx)(lA.Col,{className:`dropdown-menu-container`,children:e}):(0,H.jsx)(Aw,{className:`dropdown-menu-container`,padding:2,style:{zIndex:1},children:e})})},bA=yA;yA.displayName=`DropdownMenuSubContent`;var xA=({children:e,icon:t,shortcut:n,className:r})=>(0,H.jsxs)(Dv,{className:`${_T(r)} dropdown-menu__submenu-trigger`,children:[(0,H.jsx)(bT,{icon:t,shortcut:n,children:e}),(0,H.jsx)(`div`,{className:`dropdown-menu__submenu-trigger-icon`,children:tw})]}),SA=xA;xA.displayName=`DropdownMenuSubTrigger`;var CA=e=>t=>V.Children.toArray(t).find(t=>V.isValidElement(t)&&typeof t.type!=`string`&&t?.type.displayName&&t.type.displayName===e)||null,wA=CA(`DropdownMenuTrigger`),TA=CA(`DropdownMenuContent`),EA=CA(`DropdownMenuSubTrigger`),DA=CA(`DropdownMenuSubContent`),OA=({children:e})=>{let t=EA(e),n=DA(e);return(0,H.jsxs)(Ev,{children:[t,n]})};OA.Trigger=SA,OA.Content=bA,OA.displayName=`DropdownMenuSub`;var kA=OA,AA=({className:e=``,children:t,onToggle:n,title:r,...i})=>{let a=vH(),o=U(`dropdown-menu-button ${e}`,`zen-mode-transition`,{"dropdown-menu-button--mobile":a.formFactor===`phone`}).trim();return(0,H.jsx)(Cv,{className:o,onClick:n,type:`button`,"data-testid":`dropdown-menu-button`,title:r,...i,children:t})},jA=AA;AA.displayName=`DropdownMenuTrigger`;var MA=e=>(0,H.jsx)(wT,{...e,icon:e.checked?Tx:$C}),NA=({children:e,open:t})=>{let n=wA(e),r=TA(e),i=r&&V.isValidElement(r)?V.cloneElement(r,{open:t}):r;return(0,H.jsx)(Sv,{open:t,modal:!1,children:(0,H.jsxs)(`div`,{className:Os.DROPDOWN_MENU_EVENT_WRAPPER,style:{display:`contents`},children:[n,i]})})};NA.Trigger=jA,NA.Content=dA,NA.Item=wT,NA.ItemCheckbox=MA,NA.ItemLink=mA,NA.ItemCustom=fA,NA.Group=hT,NA.Separator=gA,NA.Sub=kA;var Q=NA;NA.displayName=`DropdownMenu`;var PA=(e,t)=>e.filter(e=>t.includes(e.id)),FA=({setAppState:e,selectedItems:t,library:n,onRemoveFromLibrary:r,resetLibrary:i,onSelectItems:a,appState:o,className:s})=>{let[c]=_b(Ak),[l,u]=_b(JA),d=()=>{let e=t.length?G(`alerts.removeItemsFromsLibrary`,{count:t.length}):G(`alerts.resetLibrary`),n=t.length?G(`confirmDialog.removeItemsFromLib`):G(`confirmDialog.resetLibrary`);return(0,H.jsx)(Qk,{onConfirm:()=>{t.length?r():i(),p(!1)},onCancel:()=>{p(!1)},title:n,children:(0,H.jsx)(`p`,{children:e})})},[f,p]=(0,V.useState)(!1),m=!!t.length,h=m?c.libraryItems.filter(e=>t.includes(e.id)):c.libraryItems,g=G(m?`buttons.remove`:`buttons.resetLibrary`),[_,v]=(0,V.useState)(!1),[y,b]=(0,V.useState)(null),x=(0,V.useCallback)(()=>(0,H.jsxs)(nj,{onCloseRequest:()=>b(null),title:G(`publishSuccessDialog.title`),className:`publish-library-success`,size:`small`,children:[(0,H.jsx)(`p`,{children:(0,H.jsx)(aA,{i18nKey:`publishSuccessDialog.content`,authorName:y.authorName,link:e=>(0,H.jsx)(`a`,{href:y?.url,target:`_blank`,rel:`noopener noreferrer`,children:e})})}),(0,H.jsx)(Y,{type:`button`,title:G(`buttons.close`),"aria-label":G(`buttons.close`),label:G(`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,H.jsxs)(`div`,{className:U(`library-menu-dropdown-container`,s),children:[(0,H.jsxs)(Q,{open:l,children:[(0,H.jsx)(Q.Trigger,{onToggle:()=>u(!l),children:Bb}),(0,H.jsxs)(Q.Content,{onClickOutside:()=>u(!1),onSelect:()=>u(!1),className:`library-menu`,children:[!m&&(0,H.jsx)(Q.Item,{onSelect:async()=>{try{await n.updateLibrary({libraryItems:po({description:`Excalidraw library files`}),merge:!0,openLibraryMenu:!0})}catch(t){if(t?.name===`AbortError`){console.warn(t);return}e({errorMessage:G(`errors.importLibraryError`)})}},icon:kx,"data-testid":`lib-dropdown--load`,children:G(`buttons.load`)}),!!h.length&&(0,H.jsx)(Q.Item,{onSelect:async()=>{let t=m?h:await n.getLatestLibrary();qa(t).catch(Dr).catch(t=>{e({errorMessage:t.message})})},icon:vx,"data-testid":`lib-dropdown--export`,children:G(`buttons.export`)}),m&&(0,H.jsx)(Q.Item,{icon:QS,onSelect:()=>v(!0),"data-testid":`lib-dropdown--remove`,children:G(`buttons.publishLibrary`)}),!!h.length&&(0,H.jsx)(Q.Item,{onSelect:()=>p(!0),icon:fx,children:g})]})]}),t.length>0&&(0,H.jsx)(`div`,{className:`library-actions-counter`,children:t.length}),f&&d(),_&&(0,H.jsx)(cA,{onClose:()=>v(!1),libraryItems:PA(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()]})},IA=({selectedItems:e,onSelectItems:t,className:n})=>{let{library:r}=gH(),{clearLibraryCache:i,deleteItemsFromLibraryCache:a}=Dk(),o=bw(),s=CH(),[c]=_b(Ak),l=async n=>{let i=n.filter(t=>!e.includes(t.id));r.setLibrary(i).catch(()=>{s({errorMessage:G(`alerts.errorRemovingFromLibrary`)})}),a(e),t([])};return(0,H.jsx)(FA,{appState:o,setAppState:s,selectedItems:e,onSelectItems:t,library:r,onRemoveFromLibrary:()=>l(c.libraryItems),resetLibrary:()=>{r.resetLibrary(),i()},className:n})};function LA(){return[!1,(0,V.useCallback)(e=>e(),[])]}var RA=V.useTransition||LA,zA=(0,V.memo)(({id:e,elements:t,isPending:n,onClick:r,selected:i,onToggle:a,onDrag:o,svgCache:s})=>{let c=(0,V.useRef)(null),l=Ek(e,t,s,c),[u,d]=(0,V.useState)(!1),f=vH().formFactor===`phone`,p=n&&(0,H.jsx)(`div`,{className:`library-unit__adder`,children:zb});return(0,H.jsxs)(`div`,{className:U(`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,H.jsx)(`div`,{className:U(`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,H.jsx)(HE,{checked:i,onChange:(t,n)=>a(e,n),className:`library-unit__checkbox`})]})}),BA=()=>(0,H.jsx)(`div`,{className:`library-unit library-unit--skeleton`}),VA=({children:e})=>(0,H.jsx)(`div`,{className:`library-menu-items-container__grid`,children:e}),HA=(0,V.memo)(({items:e,onItemSelectToggle:t,onItemDrag:n,isItemSelected:r,onClick:i,svgCache:a,itemsRenderedPerBatch:o})=>{let[,s]=RA(),[c,l]=(0,V.useState)(0);return(0,V.useEffect)(()=>{c<e.length&&s(()=>{l(c+o)})},[c,e.length,s,o]),(0,H.jsx)(H.Fragment,{children:e.map((e,o)=>o<c?(0,H.jsx)(zA,{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,H.jsx)(BA,{},o))})}),UA=({type:e=`button`,onSelect:t,selected:n,children:r,className:i=``,...a})=>(0,H.jsx)(`button`,{onClick:jo(a.onClick,e=>{t()}),type:e,className:U(`excalidraw-button`,i,{selected:n}),...a,children:r}),WA=(0,V.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,V.useRef)(null);(0,V.useImperativeHandle)(f,()=>p.current),(0,V.useLayoutEffect)(()=>{a&&(p.current?.focus(),p.current?.select())},[a]);let[m,h]=(0,V.useState)(!1);return(0,H.jsxs)(`div`,{className:U(`ExcTextField`,l,{"ExcTextField--fullWidth":n,"ExcTextField--hasIcon":!!c}),onClick:()=>{p.current?.focus()},children:[c,t&&(0,H.jsx)(`div`,{className:`ExcTextField__label`,children:t}),(0,H.jsxs)(`div`,{className:U(`ExcTextField__input`,{"ExcTextField__input--readonly":i}),children:[(0,H.jsx)(`input`,{className:U({"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,H.jsx)(UA,{onSelect:()=>h(!m),style:{border:0,userSelect:`none`},children:m?vC:_C})]})]})}),GA=17,KA=64;function qA({isLoading:e,libraryItems:t,onAddToLibrary:n,onInsertLibraryItems:r,pendingElements:i,theme:a,id:o,libraryReturnUrl:s,onSelectItems:c,selectedItems:l}){let u=vH(),d=(0,V.useRef)(null),f=Xk(d);(0,V.useEffect)(()=>{f>0&&d.current?.scrollTo(0,f)},[]);let{svgCache:p}=Dk(),[m,h]=(0,V.useState)(null),[g,_]=(0,V.useState)(``),v=!t.length&&!i.length,y=!v&&!!g.trim(),b=(0,V.useMemo)(()=>{let e=vk(g.trim().toLowerCase());return e?t.filter(t=>{let n=t.name||``;return n.trim()&&vk(n.toLowerCase()).includes(e)}):[]},[t,g]),x=(0,V.useMemo)(()=>t.filter(e=>e.status!==`published`),[t]),S=(0,V.useMemo)(()=>t.filter(e=>e.status===`published`),[t]),C=(0,V.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=ze(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,V.useEffect)(()=>{l.length||h(null)},[l]);let w=(0,V.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:Ei({type:`everything`,elements:e.elements,randomizeSeed:!0,preserveFrameChildrenOrder:!0}).duplicatedElements}))},[t,l]),T=(0,V.useCallback)((e,t)=>{let n={itemIds:l.includes(e)?l:[e]};t.dataTransfer.setData(L.excalidrawlibIds,JSON.stringify(n))},[l]),E=(0,V.useCallback)(e=>e?l.includes(e):!1,[l]),D=(0,V.useCallback)(()=>{n(i)},[i,n]),ee=(0,V.useCallback)(e=>{e&&r(w(e))},[w,r]),O=p.size>=(b.length?b:t).length?KA:GA,k=(0,V.useRef)(null);(0,V.useEffect)(()=>{Ut(()=>{k.current?.focus()})},[]);let te=!y&&(0,H.jsxs)(H.Fragment,{children:[!v&&(0,H.jsx)(`div`,{className:`library-menu-items-container__header`,children:G(`labels.personalLib`)}),!i.length&&!x.length?(0,H.jsxs)(`div`,{className:`library-menu-items__no-items`,children:[!S.length&&(0,H.jsx)(`div`,{className:`library-menu-items__no-items__label`,children:G(`library.noItems`)}),(0,H.jsx)(`div`,{className:`library-menu-items__no-items__hint`,children:S.length>0?G(`library.hint_emptyPrivateLibrary`):G(`library.hint_emptyLibrary`)})]}):(0,H.jsxs)(VA,{children:[i.length>0&&(0,H.jsx)(HA,{itemsRenderedPerBatch:O,items:[{id:null,elements:i}],onItemSelectToggle:C,onItemDrag:T,onClick:D,isItemSelected:E,svgCache:p}),(0,H.jsx)(HA,{itemsRenderedPerBatch:O,items:x,onItemSelectToggle:C,onItemDrag:T,onClick:ee,isItemSelected:E,svgCache:p})]}),S.length>0&&(0,H.jsx)(`div`,{className:`library-menu-items-container__header`,style:{marginTop:`0.75rem`},children:G(`labels.excalidrawLib`)}),S.length>0&&(0,H.jsx)(VA,{children:(0,H.jsx)(HA,{itemsRenderedPerBatch:O,items:S,onItemSelectToggle:C,onItemDrag:T,onClick:ee,isItemSelected:E,svgCache:p})})]}),ne=y&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`library-menu-items-container__header`,children:[G(`library.search.heading`),!e&&(0,H.jsxs)(`div`,{className:`library-menu-items-container__header__hint`,style:{cursor:`pointer`},onPointerDown:e=>e.preventDefault(),onClick:e=>{_(``)},children:[(0,H.jsx)(`kbd`,{children:`esc`}),` to clear`]})]}),b.length>0?(0,H.jsx)(VA,{children:(0,H.jsx)(HA,{itemsRenderedPerBatch:O,items:b,onItemSelectToggle:C,onItemDrag:T,onClick:ee,isItemSelected:E,svgCache:p})}):(0,H.jsxs)(`div`,{className:`library-menu-items__no-items`,children:[(0,H.jsx)(`div`,{className:`library-menu-items__no-items__hint`,children:G(`library.search.noResults`)}),(0,H.jsx)(UA,{onPointerDown:e=>e.preventDefault(),onSelect:()=>{_(``)},style:{width:`auto`,marginTop:`1rem`},children:G(`library.search.clearSearch`)})]})]});return(0,H.jsxs)(`div`,{className:`library-menu-items-container`,style:i.length||x.length||S.length?{justifyContent:`flex-start`}:{borderBottom:0},children:[(0,H.jsxs)(`div`,{className:`library-menu-items-header`,children:[!v&&(0,H.jsx)(WA,{ref:k,type:`search`,className:U(`library-menu-items-container__search`,{hideCancelButton:u.formFactor!==`phone`}),placeholder:G(`library.search.inputPlaceholder`),value:g,onChange:e=>_(e)}),(0,H.jsx)(IA,{selectedItems:l,onSelectItems:c,className:`library-menu-dropdown-container--in-heading`})]}),(0,H.jsxs)(lA.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,H.jsx)(`div`,{style:{position:`absolute`,top:`var(--container-padding-y)`,right:`var(--container-padding-x)`,transform:`translateY(50%)`},children:(0,H.jsx)(rw,{})}),te,ne,v&&(0,H.jsx)(Jk,{style:{padding:`16px 0`,width:`100%`},id:o,libraryReturnUrl:s,theme:a})]})]})}var JA=Yc(!1),YA=({children:e})=>(0,H.jsx)(`div`,{className:`layer-ui__library`,children:e}),XA=(0,V.memo)(({onInsertLibraryItems:e,pendingElements:t,onAddToLibrary:n,setAppState:r,libraryReturnUrl:i,library:a,id:o,theme:s,selectedItems:c,onSelectItems:l})=>{let[u]=_b(Ak),d=(0,V.useCallback)(e=>{(async(e,t)=>{hw(`element`,`addToLibrary`,`ui`);for(let t of ls)if(e.some(e=>e.type===t))return r({errorMessage:G(`errors.libraryElementTypeError.${t}`)});let i=[{status:`unpublished`,elements:e,id:Ae(),created:Date.now()},...t];n(),a.setLibrary(i).catch(()=>{r({errorMessage:G(`alerts.errorAddingToLibrary`)})})})(e,u.libraryItems)},[n,a,r,u.libraryItems]),f=(0,V.useMemo)(()=>u.libraryItems,[u]);if(u.status===`loading`&&!u.isInitialized)return(0,H.jsx)(YA,{children:(0,H.jsx)(`div`,{className:`layer-ui__library-message`,children:(0,H.jsxs)(`div`,{children:[(0,H.jsx)(rw,{size:`2em`}),(0,H.jsx)(`span`,{children:G(`labels.libraryLoadingMessage`)})]})})});let p=u.libraryItems.length>0||t.length>0;return(0,H.jsxs)(YA,{children:[(0,H.jsx)(qA,{isLoading:u.status===`loading`,libraryItems:f,onAddToLibrary:d,onInsertLibraryItems:e,pendingElements:t,id:o,libraryReturnUrl:i,theme:s,onSelectItems:l,selectedItems:c}),p&&(0,H.jsx)(Jk,{className:`library-menu-control-buttons--at-bottom`,style:{padding:`16px 12px 0 12px`},id:o,libraryReturnUrl:i,theme:s})]})}),ZA=(e,t)=>({elements:e,pending:is(e,{selectedElementIds:t},{includeBoundTextElement:!0,includeElementsInFrames:!0}),selectedElementIds:t}),QA=(e,t)=>{let n=xH(),[r,i]=(0,V.useState)(()=>ZA(n,e.selectedElementIds)),a=(0,V.useRef)(new Map);return(0,V.useEffect)(()=>{for(let e of r.pending)a.current.set(e.id,e.version)},[r.pending]),(0,V.useEffect)(()=>{t.state.cursorButton===`up`&&t.state.activeTool.type===`selection`&&i(r=>{if(!Jn(r.selectedElementIds,e.selectedElementIds))return a.current.clear(),ZA(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 ZA(n,e.selectedElementIds)}return r})},[t,t.state.cursorButton,t.state.activeTool.type,e.selectedElementIds,n]),r.pending},$A=(0,V.memo)(()=>{let e=gH(),{onInsertElements:t}=e,n=_H(),r=bw(),i=CH(),[a,o]=(0,V.useState)([]),s=(0,V.useMemo)(()=>e.library,[e.library]),c=QA(r,e);(0,V.useEffect)(()=>Vs(document,R.KEYDOWN,t=>{if(t.key===I.ESCAPE&&t.target instanceof HTMLElement){let n=t.target;if(n.closest(`.${Os.SIDEBAR}`))a.length>0?(t.stopPropagation(),o([])):Ee(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(`.${Os.SIDEBAR}`)&&(t.stopPropagation(),o([]))}}},{capture:!0}),[a,i,e]);let l=(0,V.useCallback)(n=>{t(Ik(n)),e.focusContainer()},[t,e]),u=(0,V.useCallback)(()=>{i({selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null})},[i]);return(0,H.jsx)(XA,{pendingElements:c,onInsertLibraryItems:l,onAddToLibrary:u,setAppState:i,libraryReturnUrl:n.libraryReturnUrl,library:s,id:e.id,theme:r.theme,selectedItems:a,onSelectItems:o})}),ej=e=>{let{closeOnClickOutside:t=!0}=e,n=xw({className:`excalidraw-modal-container`}),r=(0,V.useRef)(document.body.classList.contains(`excalidraw-animations-disabled`));return n?(0,qc.createPortal)((0,H.jsxs)(`div`,{className:U(`Modal`,e.className,{"animations-disabled":r.current}),role:`dialog`,"aria-modal":`true`,onKeyDown:t=>{t.key===I.ESCAPE&&(t.preventDefault(),t.nativeEvent.stopImmediatePropagation(),t.stopPropagation(),e.onCloseRequest())},"aria-labelledby":e.labelledBy,children:[(0,H.jsx)(`div`,{className:`Modal__background`,onClick:t?e.onCloseRequest:void 0}),(0,H.jsx)(`div`,{className:`Modal__content`,style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),n):null};function tj(e){if(e&&typeof e==`number`)return e;switch(e){case`small`:return 550;case`wide`:return 1024;default:return 800}}var nj=e=>{let[t,n]=yk(),[r]=(0,V.useState)(document.activeElement),{id:i}=bH(),a=vH().formFactor===`phone`;(0,V.useEffect)(()=>{if(!t)return;let n=ha(t);setTimeout(()=>{n.length>0&&e.autofocus!==!1&&(n[1]||n[0]).focus()});let r=e=>{if(e.key===I.TAB){let n=ha(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=CH(),s=vb(JA),c=()=>{o({openMenu:null}),s(!1),r.focus(),e.onCloseRequest()};return(0,H.jsx)(ej,{className:U(`Dialog`,e.className,{"Dialog--fullscreen":a}),labelledBy:`dialog-title`,maxWidth:tj(e.size),onCloseRequest:c,closeOnClickOutside:e.closeOnClickOutside,children:(0,H.jsxs)(Aw,{ref:n,children:[e.title&&(0,H.jsx)(`h2`,{id:`${i}-dialog-title`,className:`Dialog__title`,children:(0,H.jsx)(`span`,{className:`Dialog__titleContent`,children:e.title})}),a&&(0,H.jsx)(`button`,{className:`Dialog__close`,onClick:c,title:G(`buttons.close`),"aria-label":G(`buttons.close`),type:`button`,children:nS}),(0,H.jsx)(`div`,{className:`Dialog__content`,children:e.children})]})})},rj=X({name:`viewMode`,label:`labels.viewMode`,icon:_C,viewMode:!0,trackEvent:{category:`canvas`,predicate:e=>!e.viewModeEnabled},perform(e,t){return{appState:{...t,viewModeEnabled:!this.checked(t)},captureUpdate:j.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,t,n,r)=>typeof n.viewModeEnabled>`u`&&r.isInteractionEnabled(),keyTest:e=>!e[I.CTRL_OR_CMD]&&e.altKey&&e.code===ir.R}),ij=(e,t)=>{let n=t[0]?.type||null;for(let e of t)if(e.type!==n){n=null;break}return Cr(e.activeTool.type)&&n!==`image`&&n!==`frame`&&n!==`magicframe`||t.some(e=>Cr(e.type))},aj=(e,t)=>dc(e.activeTool.type)||t.some(e=>dc(e.type)),oj=(e,t,n,r)=>{let i=e.activeTool.type,a=e=>e(i)||t.some(t=>e(t.type)),o=t.length===1,s=t.length===2&&(Qr(t[0])||Qr(t[1])),c=!!(e.editingTextElement||e.newElement),l=t.length>0;return{hasSelection:l,showExtraActions:l&&!c,strokeColor:ij(e,t),backgroundColor:aj(e,t),fill:i===`bucketfill`||dc(i)&&!Aa(e.currentItemBackgroundColor)||t.some(e=>dc(e.type)&&!Aa(e.backgroundColor)),strokeWidth:a(nc),freedrawMode:a(mo),strokeStyle:a(xn),sloppiness:a(xn),roundness:a(va),arrowType:a(lc),arrowheads:a(Ji),text:i===`text`||t.some(F),textAlign:i===`text`||Ht(t,n),verticalAlign:Pe(t,n),opacity:i!==`autoshape`||l,layers:i!==`freedraw`&&i!==`autoshape`&&!t.some(e=>e.type===`freedraw`)||is(n,e).some(e=>e.type===`freedraw`),align:!s&&WD(e,r),distribute:t.length>2,link:o||s,linkSingleOnly:o,cropEditor:!e.croppingElementId&&o&&it(t[0]),lineEditor:!e.selectedLinearElement?.isEditing&&o&&vo(t[0])&&!fe(t[0])}},sj=U([Os.SHAPE_ACTIONS_THEME_SCOPE,`properties-content`]),cj=({renderAction:e})=>(0,H.jsxs)(`fieldset`,{children:[(0,H.jsx)(`legend`,{children:G(`labels.layers`)}),(0,H.jsxs)(`div`,{className:`buttonList`,children:[e(`sendToBack`),e(`sendBackward`),e(`bringForward`),e(`bringToFront`)]})]}),lj=({renderAction:e,showDistribute:t})=>{let n=document.documentElement.getAttribute(`dir`)===`rtl`;return(0,H.jsxs)(`fieldset`,{children:[(0,H.jsx)(`legend`,{children:G(`labels.align`)}),(0,H.jsxs)(`div`,{className:`buttonList`,children:[n?(0,H.jsxs)(H.Fragment,{children:[e(`alignRight`),e(`alignHorizontallyCentered`),e(`alignLeft`)]}):(0,H.jsxs)(H.Fragment,{children:[e(`alignLeft`),e(`alignHorizontallyCentered`),e(`alignRight`)]}),t&&e(`distributeHorizontally`),(0,H.jsx)(`div`,{style:{flexBasis:`100%`,height:0}}),(0,H.jsxs)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:`.5rem`,marginTop:`-0.5rem`},children:[e(`alignTop`),e(`alignVerticallyCentered`),e(`alignBottom`),t&&e(`distributeVertically`)]})]})]})},uj=({appState:e,elementsMap:t,renderAction:n,app:r})=>{let i=oj(e,Xs(t,e),t,r);return e.activeTool.type===`bucketfill`?(0,H.jsxs)(`div`,{className:`selected-shape-actions`,children:[(0,H.jsx)(`div`,{children:n(`changeBucketFillBackgroundColor`)}),n(`changeFillStyle`),n(`changeOpacity`)]}):(0,H.jsxs)(`div`,{className:`selected-shape-actions`,children:[(0,H.jsx)(`div`,{children:i.strokeColor&&n(`changeStrokeColor`)}),i.backgroundColor&&(0,H.jsx)(`div`,{children:n(`changeBackgroundColor`)}),i.fill&&n(`changeFillStyle`),i.strokeWidth&&n(`changeStrokeWidth`),i.strokeStyle&&(0,H.jsx)(H.Fragment,{children:n(`changeStrokeStyle`)}),i.freedrawMode&&n(`changeFreedrawMode`),i.sloppiness&&(0,H.jsx)(H.Fragment,{children:n(`changeSloppiness`)}),i.roundness&&(0,H.jsx)(H.Fragment,{children:n(`changeRoundness`)}),i.arrowType&&(0,H.jsx)(H.Fragment,{children:n(`changeArrowType`)}),i.text&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`fieldset`,{children:n(`changeFontFamily`)}),n(`changeFontSize`),i.textAlign&&n(`changeTextAlign`)]}),i.verticalAlign&&n(`changeVerticalAlign`),i.arrowheads&&(0,H.jsx)(H.Fragment,{children:n(`changeArrowhead`)}),i.opacity&&n(`changeOpacity`),i.layers&&(0,H.jsx)(cj,{renderAction:n}),i.align&&(0,H.jsx)(lj,{renderAction:n,showDistribute:i.distribute}),i.showExtraActions&&(0,H.jsxs)(`fieldset`,{children:[(0,H.jsx)(`legend`,{children:G(`labels.actions`)}),(0,H.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`)]})]})]})},dj=({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,H.jsx)(`div`,{className:`compact-action-item`,children:(0,H.jsxs)(ty,{open:o,onOpenChange:e=>{n(e?{openPopup:`compactStrokeStyles`}:{openPopup:null})},children:[(0,H.jsx)(ny,{asChild:!0,children:(0,H.jsx)(`button`,{type:`button`,className:U(`compact-action-button properties-trigger`,{active:o}),title:G(`labels.stroke`),onClick:e=>{e.preventDefault(),e.stopPropagation(),n({openPopup:o?null:`compactStrokeStyles`})},children:YC})}),o&&(0,H.jsx)(jw,{className:sj,container:i,style:{maxWidth:`13rem`},onClose:()=>{},children:(0,H.jsxs)(`div`,{className:`selected-shape-actions`,children:[r.fill&&t(`changeFillStyle`),r.strokeWidth&&t(`changeStrokeWidth`),r.freedrawMode&&t(`changeFreedrawMode`),r.strokeStyle&&(0,H.jsx)(H.Fragment,{children:t(`changeStrokeStyle`)}),r.sloppiness&&(0,H.jsx)(H.Fragment,{children:t(`changeSloppiness`)}),r.roundness&&t(`changeRoundness`),r.opacity&&t(`changeOpacity`)]})})]})}):null},fj=({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,H.jsx)(`div`,{className:`compact-action-item`,children:(0,H.jsxs)(ty,{open:s,onOpenChange:e=>{n(e?{openPopup:`compactArrowProperties`}:{openPopup:null})},children:[(0,H.jsx)(ny,{asChild:!0,children:(0,H.jsx)(`button`,{type:`button`,className:U(`compact-action-button properties-trigger`,{active:s}),title:G(`labels.arrowtypes`),onClick:e=>{e.preventDefault(),e.stopPropagation(),n({openPopup:s?null:`compactArrowProperties`})},children:(()=>{let t=qT(r,o,e=>Wa(e)?e.elbowed?`elbow`:e.roundness?`round`:`sharp`:null,e=>Wa(e),t=>t?null:e.currentItemArrowType);return t===`elbow`?HC:t===`round`?UC:VC})()})}),s&&(0,H.jsx)(jw,{container:a,className:`properties-content`,style:{maxWidth:`13rem`},onClose:()=>{},children:t(`changeArrowProperties`)})]})})},pj=({appState:e,renderAction:t,setAppState:n,predicates:r,container:i})=>{let{saveCaretPosition:a,restoreCaretPosition:o}=Iw(),s=e.openPopup===`compactTextProperties`;return(0,H.jsx)(`div`,{className:`compact-action-item`,children:(0,H.jsxs)(ty,{open:s,onOpenChange:t=>{t?(e.editingTextElement&&a(),n({openPopup:`compactTextProperties`})):(n({openPopup:null}),e.editingTextElement&&o())},children:[(0,H.jsx)(ny,{asChild:!0,children:(0,H.jsx)(`button`,{type:`button`,className:U(`compact-action-button properties-trigger`,{active:s}),title:G(`labels.textAlign`),onClick:t=>{t.preventDefault(),t.stopPropagation(),s?n({openPopup:null}):(e.editingTextElement&&a(),n({openPopup:`compactTextProperties`}))},children:ox})}),e.openPopup===`compactTextProperties`&&(0,H.jsx)(jw,{className:sj,container:i,style:{maxWidth:`13rem`},preventAutoFocusOnTouch:!!e.editingTextElement,onClose:()=>{e.editingTextElement&&o()},children:(0,H.jsxs)(`div`,{className:`selected-shape-actions`,children:[r.text&&t(`changeFontSize`),r.textAlign&&t(`changeTextAlign`),r.verticalAlign&&t(`changeVerticalAlign`)]})})]})})},mj=({appState:e,renderAction:t,predicates:n,setAppState:r,container:i,showDuplicate:a,showDelete:o})=>{let s=e.openPopup===`compactOtherProperties`;return n.showExtraActions?(0,H.jsx)(`div`,{className:`compact-action-item`,children:(0,H.jsxs)(ty,{open:s,onOpenChange:e=>{r(e?{openPopup:`compactOtherProperties`}:{openPopup:null})},children:[(0,H.jsx)(ny,{asChild:!0,children:(0,H.jsx)(`button`,{type:`button`,className:U(`compact-action-button properties-trigger`,{active:s}),title:G(`labels.actions`),onClick:e=>{e.preventDefault(),e.stopPropagation(),r({openPopup:s?null:`compactOtherProperties`})},children:Vb})}),s&&(0,H.jsx)(jw,{className:sj,container:i,style:{maxWidth:`12rem`,justifyContent:`center`,alignItems:`center`},onClose:()=>{},children:(0,H.jsxs)(`div`,{className:`selected-shape-actions`,children:[n.layers&&(0,H.jsx)(cj,{renderAction:t}),n.align&&(0,H.jsx)(lj,{renderAction:t,showDistribute:n.distribute}),(0,H.jsxs)(`fieldset`,{children:[(0,H.jsx)(`legend`,{children:G(`labels.actions`)}),(0,H.jsxs)(`div`,{className:`buttonList`,children:[t(`group`),t(`ungroup`),n.linkSingleOnly&&t(`hyperlink`),n.cropEditor&&t(`cropEditor`),a&&t(`duplicateSelection`),o&&t(`deleteSelectedElements`)]})]})]})})]})}):null},hj=({renderAction:e,predicates:t})=>t.lineEditor?(0,H.jsx)(`div`,{className:`compact-action-item`,children:e(`toggleLinearEditor`)}):null,gj=({appState:e,elementsMap:t,renderAction:n,app:r,setAppState:i})=>{let a=Xs(t,e),o=oj(e,a,t,r),{container:s}=bH();return(0,H.jsxs)(`div`,{className:`compact-shape-actions`,children:[o.strokeColor&&(0,H.jsx)(`div`,{className:U(`compact-action-item`),children:n(`changeStrokeColor`)}),o.backgroundColor&&(0,H.jsx)(`div`,{className:`compact-action-item`,children:n(e.activeTool.type===`bucketfill`?`changeBucketFillBackgroundColor`:`changeBackgroundColor`)}),o.freedrawMode&&(0,H.jsx)(`div`,{className:`compact-action-item`,children:n(`changeFreedrawMode`,{cycle:!0})}),(0,H.jsx)(dj,{appState:e,renderAction:n,setAppState:i,predicates:o,container:s}),(0,H.jsx)(fj,{appState:e,renderAction:n,setAppState:i,targetElements:a,predicates:o,container:s,app:r}),o.lineEditor&&(0,H.jsx)(`div`,{className:`compact-action-item`,children:n(`toggleLinearEditor`)}),o.text&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`compact-action-item`,children:n(`changeFontFamily`)}),(0,H.jsx)(pj,{appState:e,renderAction:n,setAppState:i,predicates:o,container:s})]}),o.showExtraActions&&(0,H.jsx)(`div`,{className:`compact-action-item`,children:n(`duplicateSelection`)}),o.showExtraActions&&(0,H.jsx)(`div`,{className:`compact-action-item`,children:n(`deleteSelectedElements`)}),(0,H.jsx)(mj,{appState:e,renderAction:n,predicates:o,setAppState:i,container:s})]})},_j=({appState:e,elementsMap:t,renderAction:n,app:r,setAppState:i})=>{let a=Xs(t,e),o=oj(e,a,t,r),{container:s}=bH(),c=(0,V.useRef)(null),l=c.current?.getBoundingClientRect()?.width??0,u=l>=374,d=l>=412;return(0,H.jsxs)(Aw,{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,H.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,gap:6,flex:1},children:[o.strokeColor&&(0,H.jsx)(`div`,{className:U(`compact-action-item`),children:n(`changeStrokeColor`)}),o.backgroundColor&&(0,H.jsx)(`div`,{className:`compact-action-item`,children:n(e.activeTool.type===`bucketfill`?`changeBucketFillBackgroundColor`:`changeBackgroundColor`)}),(0,H.jsx)(dj,{appState:e,renderAction:n,setAppState:i,predicates:o,container:s}),(0,H.jsx)(fj,{appState:e,renderAction:n,setAppState:i,targetElements:a,predicates:o,container:s,app:r}),(0,H.jsx)(hj,{renderAction:n,predicates:o}),o.text&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`compact-action-item`,children:n(`changeFontFamily`)}),(0,H.jsx)(pj,{appState:e,renderAction:n,setAppState:i,predicates:o,container:s})]}),(0,H.jsx)(mj,{appState:e,renderAction:n,predicates:o,setAppState:i,container:s,showDuplicate:!d,showDelete:!u})]}),(0,H.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,gap:6},children:[(0,H.jsx)(`div`,{className:`compact-action-item`,children:n(`undo`)}),(0,H.jsx)(`div`,{className:`compact-action-item`,children:n(`redo`)}),d&&(0,H.jsx)(`div`,{className:`compact-action-item`,children:n(`duplicateSelection`)}),u&&(0,H.jsx)(`div`,{className:`compact-action-item`,children:n(`deleteSelectedElements`)})]})]})},vj=({renderAction:e})=>(0,H.jsx)(lA.Col,{gap:1,className:Os.ZOOM_ACTIONS,children:(0,H.jsxs)(lA.Row,{align:`center`,children:[e(`zoomOut`),e(`resetZoom`),e(`zoomIn`)]})}),yj=({renderAction:e,className:t})=>(0,H.jsxs)(`div`,{className:`undo-redo-buttons ${t}`,children:[(0,H.jsx)(`div`,{className:`undo-button-container`,children:(0,H.jsx)(aE,{label:G(`buttons.undo`),children:e(`undo`)})}),(0,H.jsx)(`div`,{className:`redo-button-container`,children:(0,H.jsxs)(aE,{label:G(`buttons.redo`),children:[` `,e(`redo`)]})})]}),bj=({actionManager:e,showExitZenModeBtn:t})=>(0,H.jsx)(`button`,{type:`button`,className:U(`disable-zen-mode`,{"disable-zen-mode--visible":t}),onClick:()=>e.executeAction(aO),children:G(`buttons.exitZenMode`)}),xj=({actionManager:e})=>(0,H.jsx)(`button`,{type:`button`,className:`disable-view-mode`,onClick:()=>e.executeAction(rj),children:ZC}),Sj=e=>{let t=(0,V.useRef)({userFn:e});return t.current.userFn=e,t.current.stableFn||(t.current.stableFn=(...e)=>t.current.userFn(...e)),t.current.stableFn},Cj=Yc(null),wj=()=>{let[e,t]=_b(Cj),n=wH();return e&&e===`clearCanvas`?(0,H.jsx)(Qk,{onConfirm:()=>{n.executeAction(uE),t(null)},onCancel:()=>t(null),title:G(`clearCanvasDialog.title`),children:(0,H.jsxs)(`p`,{className:`clear-canvas__content`,children:[` `,G(`alerts.clearReset`)]})}):null},Tj={},Ej=Yc(null),Dj={app:`App`,export:`Export`,tools:`Tools`,editor:`Editor`,elements:`Elements`,links:`Links`,library:`Library`},Oj=e=>{switch(e){case Dj.app:return 1;case Dj.export:return 2;case Dj.editor:return 3;case Dj.tools:return 4;case Dj.elements:return 5;case Dj.links:return 6;default:return 10}},kj=({shortcut:e,className:t,children:n})=>{let r=e.replace(`++`,`+$`).split(`+`);return(0,H.jsxs)(`div`,{className:U(`shortcut`,t),children:[r.map((e,t)=>(0,H.jsx)(`div`,{className:`shortcut-wrapper`,children:(0,H.jsx)(`div`,{className:`shortcut-key`,children:e===`$`?`+`:e})},e)),(0,H.jsx)(`div`,{className:`shortcut-desc`,children:n})]})},Aj=e=>!e.altKey&&e[I.CTRL_OR_CMD]&&(e.shiftKey&&e.key.toLowerCase()===I.P||e.key===I.SLASH),jj=Object.assign(e=>{let t=bw(),n=CH();return(0,V.useEffect)(()=>{let e=e=>{Aj(e)&&(e.preventDefault(),e.stopPropagation(),n(e=>{let t=e.openDialog?.name===`commandPalette`?null:{name:`commandPalette`};return t&&hw(`command_palette`,`open`,`shortcut`),{openDialog:t}}))};return window.addEventListener(R.KEYDOWN,e,{capture:!0}),()=>window.removeEventListener(R.KEYDOWN,e,{capture:!0})},[n]),t.openDialog?.name===`commandPalette`?(0,H.jsx)(Mj,{...e}):null},{defaultItems:Tj});function Mj({customCommandPaletteItems:e}){let t=gH(),n=bw(),r=CH(),i=_H(),a=wH(),[o,s]=_b(Ej),[c,l]=(0,V.useState)(null),u=(0,V.useRef)(null),d=Cw({uiAppState:n,customCommandPaletteItems:e,appProps:i}),[f]=_b(Ak),p=(0,V.useMemo)(()=>f.libraryItems?.filter(e=>!!e.name).map(e=>({label:e.name,icon:(0,H.jsx)(Nj,{id:e.id,elements:e.elements}),category:`Library`,order:Oj(`Library`),haystack:vk(e.name),perform:()=>{t.onInsertElements(Ik([e]))}}))||[],[t,f.libraryItems]);(0,V.useEffect)(()=>{let{uiAppState:e,customCommandPaletteItems:n,appProps:i}=d,c=n=>{let r=``;return n.label&&(r=typeof n.label==`function`?G(n.label(t.scene.getNonDeletedElements(),e,t)):G(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:mk(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,AO,dk,fk].map(e=>m(e,Dj.elements,(e,t)=>({...e,predicate:t.predicate?t.predicate:(e,t,n,r)=>is(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,Dj.editor)),g=[a.actions.saveToActiveFile,a.actions.saveFileToDisk,a.actions.copyAsPng,a.actions.copyAsSvg].map(e=>m(e,Dj.export));f=[...d,...h,{label:c(uE),icon:u(uE),shortcut:mk(uE.name),category:Dj.editor,keywords:[`delete`,`destroy`],viewMode:!1,perform:()=>{Sb.set(Cj,`clearCanvas`)}},{label:G(`buttons.exportImage`),category:Dj.export,icon:Nx,shortcut:mk(`imageExport`),keywords:[`export`,`image`,`png`,`jpeg`,`svg`,`clipboard`,`picture`],perform:()=>{r({openDialog:{name:`imageExport`}})}},...g];let _=[m(hE,Dj.app),{label:G(`toolBar.library`),category:Dj.app,icon:Rb,viewMode:!1,perform:()=>{e.openSidebar?r({openSidebar:null}):r({openSidebar:{name:lr.name,tab:lr.defaultTab}})}},{label:G(`search.title`),category:Dj.app,icon:xC,viewMode:!0,perform:()=>{a.executeAction(aN)}},{label:G(`labels.shapeSwitch`),category:Dj.elements,icon:EC,perform:()=>{a.executeAction(uk)}},{label:G(`labels.changeStroke`),keywords:[`color`,`outline`],category:Dj.elements,icon:jx,viewMode:!1,predicate:(e,t)=>{let n=is(e,t);return n.length>0&&ij(t,n)},perform:()=>{r(e=>({openPopup:`elementStroke`}))}},{label:G(`labels.changeBackground`),keywords:[`color`,`fill`],icon:jx,category:Dj.elements,viewMode:!1,predicate:(e,t)=>{let n=is(e,t);return n.length>0&&aj(t,n)},perform:()=>{r(e=>({openPopup:`elementBackground`}))}},{label:G(`labels.canvasBackground`),keywords:[`color`],icon:jx,category:Dj.editor,viewMode:!1,perform:()=>{r(e=>({openMenu:e.openMenu===`canvas`?null:`canvas`,openPopup:`canvasBackground`}))}},...Object.keys(_E).reduce((e,n)=>{let r=_E[n];if(i.UIOptions.tools?.[n]===!1)return e;let a=yE(n)||r.numericKey,o={label:G(`toolBar.${n}`),category:Dj.tools,shortcut:a,icon:r.icon,keywords:[`toolbar`],viewMode:!1,perform:()=>{t.setActiveTool({type:n},{toggle:!1})}};return e.push(o),e},[]),{label:G(`toolBar.lock`),category:Dj.tools,icon:e.activeTool.locked?Gb:Wb,shortcut:I.Q.toLocaleUpperCase(),viewMode:!1,perform:()=>{t.toggleLock()}},{label:`${G(`labels.textToDiagram`)}...`,category:Dj.tools,icon:bC,viewMode:!1,predicate:i.aiEnabled,perform:()=>{r(e=>({...e,openDialog:{name:`ttd`,tab:`text-to-diagram`}}))}},{label:`${G(`toolBar.mermaidToExcalidraw`)}...`,category:Dj.tools,icon:lC,viewMode:!1,predicate:i.aiEnabled,perform:()=>{r(e=>({...e,openDialog:{name:`ttd`,tab:`mermaid`}}))}}],v=[...f,..._,...n||[]].map(e=>({...e,icon:e.icon||EC,order:e.order??Oj(e.category),haystack:`${vk(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,V.useState)(``),[g,_]=(0,V.useState)(null),[v,y]=(0,V.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=Sj(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=Sj(e=>{let t=Ee(e.target)||Aj(e)||e.key===I.ESCAPE;if(t&&e.key!==I.ARROW_UP&&e.key!==I.ARROW_DOWN&&e.key!==I.ENTER)return;let n=Object.values(v).flat(),r=o&&!m&&S(o);if(e.key===I.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===I.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===I.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,V.useEffect)(()=>(window.addEventListener(R.KEYDOWN,C,{capture:!0}),()=>window.removeEventListener(R.KEYDOWN,C,{capture:!0})),[C]),(0,V.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=vk(m.toLocaleLowerCase().replace(/[<>_| -]/g,``));t=Ey.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,H.jsxs)(nj,{onCloseRequest:()=>b(),closeOnClickOutside:!0,title:!1,size:720,autofocus:!0,className:`command-palette-dialog`,children:[(0,H.jsx)(WA,{value:m,placeholder:G(`commandPalette.search.placeholder`),onChange:e=>{h(e)},selectOnRender:!0,ref:u}),t.editorInterface.formFactor!==`phone`&&(0,H.jsxs)(`div`,{className:`shortcuts-wrapper`,children:[(0,H.jsx)(kj,{shortcut:`↑↓`,children:G(`commandPalette.shortcuts.select`)}),(0,H.jsx)(kj,{shortcut:`↵`,children:G(`commandPalette.shortcuts.confirm`)}),(0,H.jsx)(kj,{shortcut:Z(`Esc`),children:G(`commandPalette.shortcuts.close`)})]}),(0,H.jsxs)(`div`,{className:`commands`,children:[o&&!m&&(0,H.jsxs)(`div`,{className:`command-category`,children:[(0,H.jsxs)(`div`,{className:`command-category-title`,children:[G(`commandPalette.recents`),(0,H.jsx)(`div`,{className:`icon`,style:{marginLeft:`6px`},children:SC})]}),(0,H.jsx)(Pj,{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,H.jsxs)(`div`,{className:`command-category`,children:[(0,H.jsx)(`div`,{className:`command-category-title`,children:e}),v[e].map(r=>(0,H.jsx)(Pj,{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,H.jsxs)(`div`,{className:`no-match`,children:[(0,H.jsx)(`div`,{className:`icon`,children:xC}),` `,G(`commandPalette.search.noMatch`)]}):null]})]})}var Nj=({id:e,elements:t})=>{let n=(0,V.useRef)(null),{svgCache:r}=Dk();return Ek(e,t,r,n),(0,H.jsx)(`div`,{className:`library-item-icon`,ref:n})},Pj=({command:e,isSelected:t,disabled:n,onMouseMove:r,onClick:i,showShortcut:a,appState:o,size:s=`small`})=>{let c=()=>{};return(0,H.jsxs)(`div`,{className:U(`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?G(`commandPalette.itemNotAvailable`):``,children:[(0,H.jsxs)(`div`,{className:`name`,children:[e.icon&&(0,H.jsx)(MT,{className:`icon`,size:`var(--icon-size, 1rem)`,icon:typeof e.icon==`function`?e.icon(o,[]):e.icon}),(0,H.jsx)(yT,{children:e.label})]}),a&&e.shortcut&&(0,H.jsx)(kj,{shortcut:e.shortcut})]})};function Fj([e,t,n],[r,i,a]){return[e+r,t+i,n+a]}function Ij([e,t,n],[r,i,a]){return[e-r,t-i,n-a]}function Lj([e,t,n],r){return[e*r,t*r,n*r]}function Rj([e,t,n]){return[e/Math.sqrt(e**2+t**2),t/Math.sqrt(e**2+t**2),n]}function zj([e,t,n],r){return[Math.cos(r)*e-Math.sin(r)*t,Math.sin(r)*e+Math.cos(r)*t,n]}function Bj(e,t,n){return Fj(e,Lj(Ij(t,e),n))}function Vj(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 Hj(e){return Math.atan2(Math.sin(e),Math.cos(e))}function Uj([e,t]){return Math.sqrt(e**2+t**2)}function Wj([e,t],[n,r]){return Math.sqrt((n-e)**2+(r-t)**2)}function Gj(e){if(e.length<2)return 0;let t=0;for(let n=1;n<=e.length-1;n++)t+=Wj(e[n-1],e[n]);return t+=Wj(e[e.length-2],e[e.length-1]),t}var Kj=(e,t,n)=>Math.max(t,Math.min(n,e));function qj(e,t,n){let r=Wj(t,n);if(r===0)return Wj(e,t);let i=Kj(((e[0]-t[0])*(n[0]-t[0])+(e[1]-t[1])*(n[1]-t[1]))/r**2,0,1);return Wj([t[0]+i*(n[0]-t[0]),t[1]+i*(n[1]-t[1]),e[2]],e)}function Jj(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=qj(i,n,r);return o>e?[o,a]:[e,t]},[0,-1]);if(i>=t){let i=e[a];return[...Jj([n,...e.slice(1,a),i],t).slice(0,-1),i,...Jj([i,...e.slice(a,-1),r],t).slice(1)]}return[n,r]}var Yj=class e{constructor(t){B(this,`options`),B(this,`originalPoints`,[]),B(this,`stablePoints`,[]),B(this,`tailPoints`,[]),B(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=Bj(this.lastPoint,t,1-this.options.streamline)),this.tailPoints.push(t),Gj(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=Jj(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(Fj(e,Lj(zj([1,0,0],t),i)));return a.push(Fj(e,Lj([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=Vj(e,[e[0],e[1]-100,e[2]],i);for(let t=c;t<=Math.PI+c;t+=Math.PI/16)s.push(Fj(e,Lj(zj([1,0,0],t),a)));for(let e=Math.PI+c;e<=Math.PI*2+c;e+=Math.PI/16)s.push(Fj(i,Lj(zj([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=Wj(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 _=Rj(Ij(d,f)),v=Rj(Ij(p,f)),y=zj(_,Math.PI/2),b=zj(_,-Math.PI/2),x=zj(v,Math.PI/2),S=zj(v,-Math.PI/2),C=Fj(f,Lj(y,g)),w=Fj(f,Lj(b,g)),T=Fj(f,Lj(x,g)),E=Fj(f,Lj(S,g)),D=Fj(y,S),ee=Fj(b,x),O=Fj(f,Lj(Uj(D)===0?_:Rj(D),g)),k=Fj(f,Lj(Uj(ee)===0?v:Rj(ee),g)),te=Hj(Vj(f,d,p)),ne=e.constants.cornerDetectionMaxAngle/180*Math.PI*e.constants.cornerDetectionVariance(o);if(Math.abs(te)<ne){let e=Math.abs(Hj(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(Fj(f,zj(Lj(y,g),t)));for(let t=e;t>=0;t-=e/4)a.push(Fj(f,zj(Lj(y,g),t)));a.push(k,T)}else{i.push(C,O);for(let t=0;t<=e;t+=e/4)a.push(Fj(f,zj(Lj(y,-g),-t)));for(let t=e;t>=0;t-=e/4)i.push(Fj(f,zj(Lj(y,-g),-t)));i.push(O,E)}}else i.push(O),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(Fj(e,Lj(zj([1,0,0],n),this.options.size)));return t.push(Fj(e,Lj([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=Rj(Ij(d,u)),h=Rj(Ij(f,p)),g=zj(m,-Math.PI/2),_=zj(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(Fj(u,zj(Lj(g,v),-e)));y.unshift(Fj(u,Lj(g,-v)))}else y.push(u);for(let e=0;e<=Math.PI*3;e+=Math.PI/16)x.push(Fj(p,zj(Lj(_,-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`?Jj(S,this.options.simplify):S}};B(Yj,`defaults`,{size:2,streamline:.45,simplify:.1,simplifyPhase:`output`,keepHead:!1,sizeMapping:()=>1}),B(Yj,`constants`,{cornerDetectionMaxAngle:75,cornerDetectionVariance:e=>e>35?.5:1,maxTailLength:50});var Xj=Yj,Zj=e=>{if(!e)return[];for(let t of e.sets)if(t.type===`path`)return t.ops;return e.sets[0].ops},Qj=e=>!!e&&e.type===`embeddable`,$j=e=>!!e&&e.type===`iframe`,eM=e=>!!e&&(e.type===`iframe`||e.type===`embeddable`),tM=e=>e!=null&&e.type===`text`,nM=e=>e!=null&&(e.type===`frame`||e.type===`magicframe`),rM=e=>e!=null&&oM(e.type),iM=e=>e!=null&&e.type===`arrow`,aM=e=>iM(e)&&e.elbowed,oM=e=>e===`arrow`||e===`line`,sM=e=>e!==null&&`containerId`in e&&e.containerId!==null&&tM(e),cM=(e,t=1)=>{if(e.length>=3){let[n,r]=[e[0],e[e.length-1]];return Sc(n,r)<=8/t}return!1},lM=(e,t)=>{if(t.roundness?.type===qi.PROPORTIONAL_RADIUS||t.roundness?.type===qi.LEGACY)return e*kn;if(t.roundness?.type===qi.ADAPTIVE_RADIUS){let n=t.roundness?.value??32;return e<=n/.25?e*kn:n}return 0};`ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789`.toLocaleUpperCase();var uM=(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 dM=(e,t,n)=>{let r=new Set,i=[];for(let a of e.values()){if(t.selectedElementIds[a.id]){CM(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&&sM(a)&&CM(a)&&t.selectedElementIds[a?.containerId]){i.push(a),r.add(a.id);continue}}if(n?.includeElementsInFrames){let t=[];return i.forEach(n=>{nM(n)&&uM(e,n.id).forEach(e=>!r.has(e.id)&&t.push(e)),t.push(n)}),t}return i},fM=(e,t)=>Jn(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:fM({...a.selectedElementIds,...l},o)},n},i=(e,t,n,i)=>{let a=i?i.scene.getSelectedElements({selectedElementIds:e.selectedElementIds,elements:t}):dM(t,e);return a.length?r(a,t,e,n):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:fM(e.selectedElementIds,n)}};return i.clearCache=()=>{t=null,e=null,n=null},i})();var pM=[1,0],mM=[0,1],hM=[-1,0],gM=[0,-1],_M=e=>{let[t,n]=e,r=Math.abs(t),i=Math.abs(n);return t>i?pM:t<=-i?hM:n>r?mM:gM},vM=(e,t)=>_M(pe(e,t)),yM=(e,t)=>xM(vM(e,t)),bM=(e,t)=>e[0]===t[0]&&e[1]===t[1],xM=e=>bM(e,pM)||bM(e,hM),SM=e=>e===`rectangle`||e===`iframe`||e===`embeddable`||e===`line`||e===`diamond`||e===`image`;(0,Kc.default)(e=>{(ht()||zi()||window?.DEBUG_FRACTIONAL_INDICES)&&Si(e,{shouldThrow:ht()||zi(),includeBoundTextValidation:!0})},6e4,{leading:!0,trailing:!1}),Math.PI/4;var CM=e=>!e.isDeleted,wM=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]},TM=20,EM=15,DM=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 EM;case`cardinality_one`:case`cardinality_exactly_one`:case`cardinality_zero_or_one`:return TM;default:return 15}},OM=e=>{switch(e){case`bar`:return 90;case`arrow`:return 20;default:return 25}},kM=(e,t,n,r,i=0)=>{if(r===null||t.length<1)return null;let a=Zj(t[0]);if(a.length<1)return null;let o=n===`start`?1:a.length-1,s=a[o].data;ho(s.length===6,`Op data length is not 6`);let c=A(s[4],s[5]),l=A(s[2],s[3]),u=A(s[0],s[1]),d=a[o-1],f=A(0,0);if(d.op===`move`){let e=Sa(d.data);ho(e!=null,`Op data is not a point`),f=e}else d.op===`bcurveTo`&&(f=A(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=DM(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 ee=OM(r);if(r===`cardinality_many`||r===`cardinality_one_or_many`){let[e,t]=_o(A(w,T),A(E,D),Ci(-ee)),[n,r]=_o(A(w,T),A(E,D),Ci(ee));return[E,D,e,t,n,r]}let[O,k]=_o(A(E,D),A(w,T),-ee*Math.PI/180),[te,ne]=_o(A(E,D),A(w,T),Ci(ee));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]=_o(A(w+C*2,T),A(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]=_o(A(w-C*2,T),A(w,T),Math.atan2(T-i,w-n))}return[w,T,O,k,t,r,te,ne]}return[w,T,O,k,te,ne]},AM=typeof document<`u`?document.createElement(`img`):{src:``};AM.src=`data:${L.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 jM=typeof document<`u`?document.createElement(`img`):{src:``};jM.src=`data:${L.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 MM=new WeakMap,NM=class{};B(NM,`rg`,new fo),B(NM,`cache`,new WeakMap),B(NM,`get`,(e,t)=>{let n=NM.cache.get(e);if(n&&(t===null||n.theme===t))return n.shape}),B(NM,`delete`,e=>{NM.cache.delete(e),MM.delete(e)}),B(NM,`destroy`,()=>{NM.cache=new WeakMap}),B(NM,`generateElementShape`,(e,t)=>{let n=t?.isExporting?void 0:NM.get(e,t?t.theme:null);if(n!==void 0)return n;MM.delete(e);let r=WM(e,NM.rg,t||{isExporting:!1,canvasBackgroundColor:Tt.white,embedsValidationStatus:null,theme:N.LIGHT});return t?.isExporting||NM.cache.set(e,{shape:r,theme:t?.theme||N.LIGHT}),r});var PM=e=>[8,8+e],FM=e=>[1.5,6+e];function IM(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&&SM(e.type)||rM(e)&&n>=50?t:Math.min(t/(n<10?3:2),2.5)}var LM=(e,t=!1,n=!1)=>{let r={seed:e.seed,strokeLineDash:e.strokeStyle===`dashed`?PM(e.strokeWidth):e.strokeStyle===`dotted`?FM(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:IM(e),stroke:Hn(e.strokeColor,n),preserveVertices:t||e.roughness<$i.cartoonist};switch(e.type){case`rectangle`:case`iframe`:case`embeddable`:case`diamond`:case`ellipse`:return r.fillStyle=e.fillStyle,r.fill=Aa(e.backgroundColor)?void 0:Hn(e.backgroundColor,n),e.type===`ellipse`&&(r.curveFitting=1),r;case`line`:case`freedraw`:return cM(e.points)&&(r.fillStyle=e.fillStyle,r.fill=e.backgroundColor===`transparent`?void 0:Hn(e.backgroundColor,n)),r;case`arrow`:return r;default:throw Error(`Unimplemented type ${e.type}`)}},RM=(e,t,n)=>eM(e)&&(t||Qj(e)&&n?.get(e.id)!==!0)&&Aa(e.backgroundColor)&&Aa(e.strokeColor)?{...e,roughness:0,backgroundColor:`#d3d3d3`,fillStyle:`solid`}:$j(e)?{...e,strokeColor:Aa(e.strokeColor)?`#000000`:e.strokeColor,backgroundColor:Aa(e.backgroundColor)?`#f4f4f6`:e.backgroundColor}:e,zM=(e,t,n)=>{if(t===null)return[];let[,,r,i,a,o]=t;return[e.line(r,i,a,o,n)]},BM=(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)]},VM=(e,t)=>{let n={...t};if(e.strokeStyle===`dotted`){let t=FM(e.strokeWidth-1);n.strokeLineDash=[t[0],t[1]-1]}else delete n.strokeLineDash;return n.roughness=Math.min(1,n.roughness||0),n},HM=(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)]},UM=(e,t,n,r,i,a,o,s)=>{if(r===null)return[];let c=Hn(e.strokeColor,s),l=Hn(o,s),u=.8;switch(r){case`circle`:case`circle_outline`:return HM(i,a,c,kM(e,t,n,r),r===`circle_outline`?l:c);case`triangle`:case`triangle_outline`:{let o=kM(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=kM(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 zM(i,kM(e,t,n,r),VM(e,a));case`cardinality_many`:return BM(i,kM(e,t,n,r),VM(e,a));case`cardinality_one_or_many`:{let r=VM(e,a);return[...BM(i,kM(e,t,n,`cardinality_many`),r),...zM(i,kM(e,t,n,`cardinality_one`,-.25),r)]}case`cardinality_exactly_one`:{let r=VM(e,a);return[...zM(i,kM(e,t,n,`cardinality_one`,-.5),r),...zM(i,kM(e,t,n,`cardinality_one`),r)]}case`cardinality_zero_or_one`:{let r=VM(e,a);return[...HM(i,a,c,kM(e,t,n,`circle_outline`,1.5),l,u),...zM(i,kM(e,t,n,`cardinality_one`,-.5),r)]}case`cardinality_zero_or_many`:{let r=VM(e,a);return[...BM(i,kM(e,t,n,`cardinality_many`),r),...HM(i,a,c,kM(e,t,n,`circle_outline`,1.5),l,u)]}default:return BM(i,kM(e,t,n,r),VM(e,a))}},WM=(e,t,{isExporting:n,canvasBackgroundColor:r,embedsValidationStatus:i,theme:a})=>{let o=a===N.DARK;switch(e.type){case`rectangle`:case`iframe`:case`embeddable`:{let r;if(e.roundness){let a=e.width,s=e.height,c=lM(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`,LM(RM(e,n,i),!0,o))}else r=t.rectangle(0,0,e.width,e.height,LM(RM(e,n,i),!1,o));return r}case`diamond`:{let n,[r,i,a,s,c,l,u,d]=wM(e);if(e.roundness){let f=lM(Math.abs(r-u),e),p=lM(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}`,LM(e,!0,o))}else n=t.polygon([[r,i],[a,s],[c,l],[u,d]],LM(e,!1,o));return n}case`ellipse`:return t.ellipse(e.width/2,e.height/2,e.width,e.height,LM(e,!1,o));case`line`:case`arrow`:{let n,i=LM(e,!1,o),a=e.points.length?e.points:[A(0,0)];if(aM(e)?a.every(e=>Math.abs(e[0])<=1e6&&Math.abs(e[1])<=1e6)?n=[t.path(GM(a,16),LM(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=UM(e,n,`start`,a,t,i,r,o);n.push(...s)}if(s!==null){let a=UM(e,n,`end`,s,t,i,r,o);n.push(...a)}}return n}case`freedraw`:{let n=[];if(cM(e.points)){let r=Ay(e.points,.75);n.push(t.curve(r,{...LM(e,!1,o),stroke:`none`}))}return n.push(KM(e)),n}case`frame`:case`magicframe`:case`text`:case`image`:return null;default:return Cc(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}},GM=(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=yM(o,i),c=yM(a,o),l=Math.min(t,Sc(e[r],a)/2,Sc(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(` `)},KM=e=>nN($M(e)),qM={SIZE_FACTOR:4.25,THINNING:.6,SMOOTHING:.5},JM={SIZE_FACTOR:1.4},YM=e=>e.strokeOptions?.streamline??.5,XM=e=>tb(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*qM.SIZE_FACTOR,thinning:qM.THINNING,smoothing:qM.SMOOTHING,streamline:YM(e),easing:e=>Math.sin(e*Math.PI/2),last:!0}),ZM=e=>new Xj({size:e.strokeWidth*JM.SIZE_FACTOR,streamline:YM(e),simplify:0,sizeMapping:e=>Math.max(.1,e.pressure)}),QM=e=>{let t=ZM(e);return e.points.map(([e,n])=>t.addPoint([e,n,1])),t.getStrokeOutline().map(([e,t])=>[e,t])},$M=e=>e.strokeOptions?.variability===`constant`?QM(e):XM(e),eN=(e,t)=>[(e[0]+t[0])/2,(e[1]+t[1])/2],tN=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g,nN=e=>{if(!e.length)return``;let t=e.length-1;return e.reduce((e,n,r,i)=>(r===t?e.push(n,eN(n,i[0]),`L`,i[0],`Z`):e.push(n,eN(n,i[r+1])),e),[`M`,e[0],`Q`]).join(` `).replace(tN,`$1`)},rN=(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??Ba(),updated:Fe()}},iN=X({name:`toggleLinearEditor`,category:Dj.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&&vo(i[0])&&!fe(i[0]))},perform(e,t,n,r){ho(t.selectedLinearElement,`No selected linear element found`);let i=r.scene.getElement(t.selectedLinearElement.elementId);ho(i,`No selected element found`);let a={...t.selectedLinearElement,isEditing:!t.selectedLinearElement.isEditing};return{appState:{...t,selectedLinearElement:a},captureUpdate:j.IMMEDIATELY}},PanelComponent:({appState:e,updateData:t,app:n})=>{let r=n.scene.getSelectedElements({selectedElementIds:e.selectedElementIds})[0];if(!r)return null;let i=G(r.type===`arrow`?`labels.lineEditor.editArrow`:`labels.lineEditor.edit`);return(0,H.jsx)(Y,{type:`button`,icon:BC,title:i,"aria-label":i,onClick:()=>t(null)})}});X({name:`togglePolygon`,category:Dj.elements,icon:Ub,keywords:[`loop`],label:(e,t,n)=>n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds}).some(e=>!Me(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=>Me(e)&&e.points.length>=4)},perform(e,t,n,r){let i=r.scene.getSelectedElements(t);if(i.some(e=>!Me(e)))return!1;let a=i,o=a.some(e=>!e.polygon),s=ze(a);return{elements:e.map(e=>!s.has(e.id)||!Me(e)?e:rN(e,{backgroundColor:o?e.backgroundColor:`transparent`,...Ir(e,o)})),appState:t,captureUpdate:j.IMMEDIATELY}},PanelComponent:({appState:e,updateData:t,app:n})=>{let r=n.scene.getSelectedElements({selectedElementIds:e.selectedElementIds});if(r.length===0||r.some(e=>!Me(e)||!e.polygon||e.points.length<3))return null;let i=r.every(e=>Me(e)&&e.polygon),a=G(i?`labels.polygon.breakPolygon`:`labels.polygon.convertToPolygon`);return(0,H.jsx)(Y,{type:`toggle`,icon:Ub,title:a,"aria-label":a,checked:i,onSelect:()=>t(null),style:{marginLeft:`auto`}})}});var aN=X({name:`searchMenu`,icon:xC,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===lr.name&&t.openSidebar.tab===`search`){let e=r.excalidrawContainerValue.container?.querySelector(`.${Os.SEARCH_MENU_INPUT_WRAPPER} input`);return e?.focus(),e?.select(),!1}return{appState:{...t,openSidebar:{name:lr.name,tab:_a},openDialog:null},captureUpdate:j.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,t,n)=>n.gridModeEnabled===void 0,keyTest:e=>e[I.CTRL_OR_CMD]&&e.key===I.F}),oN=X({name:`cropEditor`,label:`helpDialog.cropStart`,icon:qC,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:j.IMMEDIATELY}},predicate:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t);return!!(!t.croppingElementId&&i.length===1&&it(i[0]))},PanelComponent:({appState:e,updateData:t,app:n})=>{let r=G(`helpDialog.cropStart`);return(0,H.jsx)(Y,{type:`button`,icon:qC,title:r,"aria-label":r,onClick:()=>t(null)})}}),sN=(e,t)=>{let n=t.scene.getSelectedElements(e);return n.length===1&&P(n[0])},cN=X({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=tr(At(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:j.IMMEDIATELY}}return{elements:e,appState:t,captureUpdate:j.EVENTUALLY}},predicate:(e,t,n,r)=>sN(t,r)}),lN=X({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:Na(e,i),appState:{...t,selectedElementIds:{[i.id]:!0}},captureUpdate:j.IMMEDIATELY}:{elements:e,appState:t,captureUpdate:j.EVENTUALLY}},predicate:(e,t,n,r)=>sN(t,r)});X({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:j.EVENTUALLY}),checked:e=>e.frameRendering.enabled});var uN=X({name:`wrapSelectionInFrame`,label:`labels.wrapSelectionInFrame`,trackEvent:{category:`element`},predicate:(e,t,n,r)=>{let i=is(e,t);return i.length>0&&!i.some(e=>P(e))},perform:(e,t,n,r)=>{let i=is(e,t),a=r.scene.getNonDeletedElementsMap(),[o,s,c,l]=Bs(i,a),u=lt({x:o-16,y:s-16,width:c-o+32,height:l-s+32});if(t.editingGroupId){let e=St(i,t.editingGroupId);for(let n of e){let e=n.groupIds.indexOf(t.editingGroupId);ur(n,a,{groupIds:n.groupIds.slice(0,e)})}}return{elements:Xe([...r.scene.getElementsIncludingDeleted(),u],i,u),appState:{selectedElementIds:{[u.id]:!0}},captureUpdate:j.IMMEDIATELY}}}),dN=class extends us{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)}},fN=class{constructor(e=!0,t=!0){this.isUndoStackEmpty=e,this.isRedoStackEmpty=t}},pN=class e{constructor(e){this.store=e,B(this,`onHistoryChangedEmitter`,new Qn),B(this,`undoStack`,[]),B(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 dN)return;let t=dN.inverse(e);this.undoStack.push(t),t.elements.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new fN(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=j.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=C.create(o,t),r=dN.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 fN(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=dN.inverse(t);return e.push(n)}},mN=(e,t)=>{let[n,r]=(0,V.useState)(t);return(0,V.useEffect)(()=>{let t=e.on(e=>{r(e)});return()=>{t()}},[e]),n},hN=(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:j.EVENTUALLY};let[t,r]=e;return{appState:r,elements:so(Array.from(t.values())),captureUpdate:j.NEVER}}return{captureUpdate:j.EVENTUALLY}},gN=e=>({name:`undo`,label:`buttons.undo`,icon:Ix,trackEvent:{category:`history`},viewMode:!1,perform:(t,n,r,i)=>hN(i,n,()=>e.undo(ze(t),n)),keyTest:e=>e[I.CTRL_OR_CMD]&&Fr(e,I.Z)&&!e.shiftKey,PanelComponent:({appState:t,updateData:n,data:r,app:i})=>{let{isUndoStackEmpty:a}=mN(e.onHistoryChangedEmitter,new fN(e.isUndoStackEmpty,e.isRedoStackEmpty)),o=yH()===`mobile`;return(0,H.jsx)(Y,{type:`button`,icon:Ix,"aria-label":G(`buttons.undo`),onClick:n,size:r?.size||`medium`,disabled:a,"data-testid":`button-undo`,style:{...o?Ne:{}}})}}),_N=e=>({name:`redo`,label:`buttons.redo`,icon:Lx,trackEvent:{category:`history`},viewMode:!1,perform:(t,n,r,i)=>hN(i,n,()=>e.redo(ze(t),n)),keyTest:e=>e[I.CTRL_OR_CMD]&&e.shiftKey&&Fr(e,I.Z)||e[I.CTRL_OR_CMD]&&!e.shiftKey&&Fr(e,I.Y),PanelComponent:({appState:t,updateData:n,data:r,app:i})=>{let{isRedoStackEmpty:a}=mN(e.onHistoryChangedEmitter,new fN(e.isUndoStackEmpty,e.isRedoStackEmpty)),o=yH()===`mobile`;return(0,H.jsx)(Y,{type:`button`,icon:Lx,"aria-label":G(`buttons.redo`),onClick:n,size:r?.size||`medium`,disabled:a,"data-testid":`button-redo`,style:{...o?Ne:{}}})}}),vN=X({name:`autoResize`,label:`labels.autoResize`,icon:null,trackEvent:{category:`element`},predicate:(e,t,n)=>{let r=is(e,t);return r.length===1&&F(r[0])&&!r[0].autoResize},perform:(e,t,n,r)=>{let i=is(e,t),a=Pi(n)&&F(n)?n:i[0],o=e.find(e=>e.id===a?.id);if(!o||!F(o))return!1;let s=xa(o.originalText,se(o),o.lineHeight),c=Mi(o),l=z(o,{autoResize:!0,width:s.width,height:s.height,x:o.x+(o.width-s.width)*c.x,y:o.y+(o.height-s.height)*c.y,text:o.originalText});return Un(l)&&zt(l,r.scene,{changedElements:new Map([[l.id,l]])}),{appState:t,elements:e.map(e=>e.id===l.id?l:e),captureUpdate:j.IMMEDIATELY}}}),yN=(e,t,n,r,i,a)=>{if(e.trackEvent)try{typeof e.trackEvent==`object`&&(!e.trackEvent.predicate||e.trackEvent.predicate(n,r,a))&&hw(e.trackEvent.category,e.trackEvent.action||e.name,`${t} (${i.editorInterface.formFactor===`phone`?`mobile`:`desktop`})`)}catch(e){console.error(`error while logging action:`,e)}},bN=class{constructor(e,t,n,r){B(this,`actions`,{}),B(this,`updater`),B(this,`getAppState`),B(this,`getElementsIncludingDeleted`),B(this,`app`),B(this,`isActionBlockedByViewportTransition`,e=>e.navigation===!0&&this.app.viewport.isLockedTransitionPending),B(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;return r.displayName=`PanelComponent`,(0,H.jsx)(r,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:e=>{this.isActionBlockedByViewportTransition(n)||(yN(n,`ui`,this.getAppState(),this.getElementsIncludingDeleted(),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}),B(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(Yt(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 yN(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();yN(e,t,i,r,this.app,n),this.updater(e.perform(r,i,n,this.app))}},xN=e=>{let t=Array.from(e.values());return{x:CN(t,e=>e.x)/t.length,y:CN(t,e=>e.y)/t.length}},SN=([e,t])=>Math.hypot(e.x-t.x,e.y-t.y),CN=(e,t)=>e.reduce((e,n)=>e+t(n),0),wN=8,TN=99999,EN=e=>wN/e,DN=class{};B(DN,`referenceSnapPoints`,null),B(DN,`visibleGaps`,null),B(DN,`setReferenceSnapPoints`,e=>{DN.referenceSnapPoints=e}),B(DN,`getReferenceSnapPoints`,()=>DN.referenceSnapPoints),B(DN,`setVisibleGaps`,e=>{DN.visibleGaps=e}),B(DN,`getVisibleGaps`,()=>DN.visibleGaps),B(DN,`destroy`,()=>{DN.referenceSnapPoints=null,DN.visibleGaps=null});var ON=DN,kN=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,AN=({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[I.CTRL_OR_CMD]||!t.state.objectsSnapModeEnabled&&e[I.CTRL_OR_CMD]&&!kN(t))}return n.length===1&&n[0].type===`arrow`?!1:t.state.objectsSnapModeEnabled},jN=(e,t,n=.01)=>Math.abs(e-t)<=n,MN=(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]=E(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=_o(A(s,c+m),A(d,f),o.angle),t=_o(A(s+p,c),A(d,f),o.angle),r=_o(A(l,c+m),A(d,f),o.angle),i=_o(A(s+p,u),A(d,f),o.angle),h=A(d,f);a=n?[e,t,r,i]:[e,t,r,i,h]}else{let e=_o(A(s,c),A(d,f),o.angle),t=_o(A(l,c),A(d,f),o.angle),r=_o(A(s,u),A(d,f),o.angle),i=_o(A(l,u),A(d,f),o.angle),p=A(d,f);a=n?[e,t,r,i]:[e,t,r,i,p]}}else if(e.length>1){let[t,r,o,s]=ke(e,i??{x:0,y:0}),c=o-t,l=s-r,u=A(t,r),d=A(o,r),f=A(t,s),p=A(o,s),m=A(t+c/2,r+l/2);a=n?[u,d,f,p]:[u,d,f,p,m]}return a.map(e=>A(zN(e[0]),zN(e[1])))},NN=(e,t,n,r)=>Xa(e,t,n,r),PN=(e,t,n,r)=>{let i=NN(e,t,n,r),a=Bt(i,r).filter(e=>!(e.length===1&&fs(e[0]))).map(e=>Bs(e).map(e=>zN(e))),o=a.sort((e,t)=>e[0]-t[0]),s=[],c=0;e:for(let e=0;e<o.length;e++){let t=o[e];for(let n=e+1;n<o.length;n++){if(++c>TN)break e;let e=o[n],[,r,i,a]=t,[l,u,,d]=e;i<l&&qo(Js(r,a),Js(u,d))&&s.push({startBounds:t,endBounds:e,startSide:[A(i,r),A(i,a)],endSide:[A(l,u),A(l,d)],length:l-i,overlap:Do(Js(r,a),Js(u,d))})}}let l=a.sort((e,t)=>e[1]-t[1]),u=[];c=0;e:for(let e=0;e<l.length;e++){let t=l[e];for(let n=e+1;n<l.length;n++){if(++c>TN)break e;let e=l[n],[r,,i,a]=t,[o,s,d]=e;a<s&&qo(Js(r,i),Js(o,d))&&u.push({startBounds:t,endBounds:e,startSide:[A(r,a),A(i,a)],endSide:[A(o,s),A(d,s)],length:s-a,overlap:Do(Js(r,i),Js(o,d))})}}return{horizontalGaps:s,verticalGaps:u}},FN=(e,t,n,r,i,a,o)=>{if(!AN({app:n,event:r,selectedElements:e})||e.length===0)return[];let s=ON.getVisibleGaps();if(s){let{horizontalGaps:n,verticalGaps:r}=s,[c,l,u,d]=ke(e,t).map(e=>zN(e)),f=(c+u)/2,p=(l+d)/2;for(let e of n){if(!qo(Js(l,d),e.overlap))continue;let t=zN(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=zN(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=zN(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(!qo(Js(c,u),e.overlap))continue;let t=zN(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=zN(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=zN(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}}}},IN=(e,t,n,r)=>{let i=NN(e,t,n,r);return Bt(i,r).filter(e=>!(e.length===1&&fs(e[0]))).flatMap(e=>MN(e,r))},LN=(e,t,n,r,i,a,o)=>{if(!AN({app:n,event:r,selectedElements:e})||e.length===0&&t.length===0)return[];let s=ON.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))}},RN=(e,t,n,r,i)=>{let a=n.state,o=is(e,a);if(!AN({app:n,event:r,selectedElements:o})||o.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};t.x=zN(t.x),t.y=zN(t.y);let s=[],c=[],l=EN(a.zoom.value),u={x:l,y:l};LN(o,MN(o,i,{dragOffset:t}),n,r,s,c,u),FN(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:zN(t.x+d.x),y:zN(t.y+d.y)};LN(o,MN(o,i,{dragOffset:f}),n,r,s,c,u),FN(o,f,n,r,s,c,u);let p=VN(s,c),m=UN(o,f,[...s,...c].filter(e=>e.type===`gap`));return{snapOffset:d,snapLines:[...p,...m]}},zN=e=>Math.round(e*10**6)/10**6,BN=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())},VN=(e,t)=>{let n={},r={};if(e.length>0){for(let t of e)if(t.type===`point`){let e=zN(t.points[0][0]);n[e]||(n[e]=[]),n[e].push(...t.points.map(e=>A(zN(e[0]),zN(e[1]))))}}if(t.length>0){for(let e of t)if(e.type===`point`){let t=zN(e.points[0][1]);r[t]||(r[t]=[]),r[t].push(...e.points.map(e=>A(zN(e[0]),zN(e[1]))))}}return Object.entries(n).map(([e,t])=>({type:`points`,points:BN(t.map(t=>A(Number(e),t[1])).sort((e,t)=>e[1]-t[1]))})).concat(Object.entries(r).map(([e,t])=>({type:`points`,points:BN(t.map(t=>A(t[0],Number(e))).sort((e,t)=>e[0]-t[0]))})))},HN=e=>{let t=new Map;for(let n of e){let e=n.points.flat().map(e=>[zN(e)]).join(`,`);t.has(e)||t.set(e,n)}return Array.from(t.values())},UN=(e,t,n)=>{let[r,i,a,o]=ke(e,t),s=[];for(let e of n){let[t,n,c,l]=e.gap.startBounds,[u,d,f,p]=e.gap.endBounds,m=Do(Js(i,o),e.gap.overlap),h=Do(Js(r,a),e.gap.overlap);switch(e.direction){case`center_horizontal`:if(m){let t=(m[0]+m[1])/2;s.push({type:`gap`,direction:`horizontal`,points:[A(e.gap.startSide[0][0],t),A(r,t)]},{type:`gap`,direction:`horizontal`,points:[A(a,t),A(e.gap.endSide[0][0],t)]})}break;case`center_vertical`:if(h){let t=(h[0]+h[1])/2;s.push({type:`gap`,direction:`vertical`,points:[A(t,e.gap.startSide[0][1]),A(t,i)]},{type:`gap`,direction:`vertical`,points:[A(t,o),A(t,e.gap.endSide[0][1])]})}break;case`side_right`:if(m){let e=(m[0]+m[1])/2;s.push({type:`gap`,direction:`horizontal`,points:[A(c,e),A(u,e)]},{type:`gap`,direction:`horizontal`,points:[A(f,e),A(r,e)]})}break;case`side_left`:if(m){let e=(m[0]+m[1])/2;s.push({type:`gap`,direction:`horizontal`,points:[A(a,e),A(t,e)]},{type:`gap`,direction:`horizontal`,points:[A(c,e),A(u,e)]})}break;case`side_top`:if(h){let e=(h[0]+h[1])/2;s.push({type:`gap`,direction:`vertical`,points:[A(e,o),A(e,n)]},{type:`gap`,direction:`vertical`,points:[A(e,l),A(e,d)]})}break;case`side_bottom`:if(h){let e=(h[0]+h[1])/2;s.push({type:`gap`,direction:`vertical`,points:[A(e,l),A(e,d)]},{type:`gap`,direction:`vertical`,points:[A(e,p),A(e,i)]})}}}return HN(s.map(e=>({...e,points:e.points.map(e=>A(zN(e[0]),zN(e[1])))})))},WN=(e,t,n,r,i,a)=>{if(!AN({event:r,selectedElements:e,app:n})||e.length===0||e.length===1&&!jN(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[o,s,c,l]=Bs(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(A(c,s),A(c,l));break;case`w`:u.push(A(o,s),A(o,l));break;case`n`:u.push(A(o,s),A(c,s));break;case`s`:u.push(A(o,l),A(c,l));break;case`ne`:u.push(A(c,s));break;case`nw`:u.push(A(o,s));break;case`se`:u.push(A(c,l));break;case`sw`:u.push(A(o,l));break}let d=EN(n.state.zoom.value),f={x:d,y:d},p=[],m=[];LN(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]=Bs(e).map(e=>zN(e));return LN(e,[A(g,_),A(g,y),A(v,_),A(v,y)],n,r,p,m,f),{snapOffset:h,snapLines:VN(p,m)}},GN=(e,t,n,r,i,a)=>{if(!AN({event:n,selectedElements:[e],app:t}))return{snapOffset:{x:0,y:0},snapLines:[]};let o=[A(r.x+i.x,r.y+i.y)],s=EN(t.state.zoom.value),c={x:s,y:s},l=[],u=[];LN([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=MN([e],a,{boundingBoxCorners:!0,omitCenter:!0});return LN([e],f,t,n,l,u,c),{snapOffset:d,snapLines:VN(l,u)}},KN=(e,t,n,r,i)=>{if(!AN({event:r,selectedElements:[],app:t}))return{originOffset:{x:0,y:0},snapLines:[]};let a=Xa(e,[],t.state,i),o=EN(t.state.zoom.value),s={x:o,y:o},c=[],l=[];for(let e of a){let t=MN([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,A(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,A(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]}},qN=e=>e===ct.rectangle||e===ct.ellipse||e===ct.diamond||e===ct.frame||e===ct.magicframe||e===ct.image||e===ct.text,JN=class{constructor(e){B(this,`scene`),B(this,`_getRenderableElements`,Zs(({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}})),B(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&&x(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())Ai(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=gc(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=ze(t),i=e.filter(e=>!r.has(e.id)),a=dt(i,n.id);return a===null?e:[...i.slice(0,a),...t,...i.slice(a)]}destroy(){Oa.cancel(),this._getRenderableElements.clear()}},YN=5,XN=(e,t,n)=>{let[r,i]=E(e,n),{x:a,y:o}=dn({sceneX:r+e.width,sceneY:i},t);return{x:a-t.offsetLeft+10,y:o-t.offsetTop}},ZN=({children:e,element:t,elementsMap:n})=>{let r=SH();if(r.contextMenu||r.newElement||r.resizingElement||r.isRotating||r.openMenu||r.viewModeEnabled)return null;let{x:i,y:a}=XN(t,r,n);return(0,H.jsx)(`div`,{className:`excalidraw-canvas-buttons`,style:{top:`${a}px`,left:`${i}px`,padding:YN},children:e})},QN=e=>t=>{(0,qc.unstable_batchedUpdates)(e,t)},$N=e=>As(t=>{(0,qc.unstable_batchedUpdates)(e,t)}),eP=(()=>{let e;try{let t=V.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})(),tP=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||(eP()?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()}};B(tP,`scheduledFrame`,null),B(tP,`animations`,new Map);var nP=tP,rP=class e{constructor(t,n){this.app=t,this.options=n,B(this,`currentTrail`),B(this,`pastTrails`,[]),B(this,`container`),B(this,`trailElement`),B(this,`trailAnimation`),B(this,`key`),this.key=`animated-trail-${e.counter++}`,this.trailElement=document.createElementNS(Mc,`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),nP.running(this.key)||nP.start(this.key,()=>this.onFrame()?{keep:!0}:(this.cleanup(),null))}stop(){nP.cancel(this.key),this.cleanup()}startPath(e,t){this.currentTrail=new Xj(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=dn({sceneX:e,sceneY:n},t);return[r.x,r.y]}),r=this.trailAnimation?n.slice(0,n.length/2):n;return gr(r,!0)}};B(rP,`counter`,0);var iP=rP,aP=class{constructor(e){this.app=e,B(this,`localTrail`),B(this,`collabTrails`,new Map),B(this,`container`),this.localTrail=new iP(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(v(n),v(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 iP(this.app,{...this.getTrailOptions(),fill:()=>n.pointer?.laserColor||zD(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())}}}},oP=12,sP=16,cP=10,lP=sP+2,uP=.8,dP=e=>4/e,fP=(e,t,n)=>{let r=dP(t);if(n!==`desktop`||sP>(e.height+r*2)*t*uP)return null;let i=oP/t,a=sP/t,o=A(e.x+e.width/2,e.y+e.height/2),s=_o(A(o[0]+e.width/2+r+i,o[1]),o,e.angle);return{center:s,start:_o(A(s[0],s[1]-a/2),s,e.angle),end:_o(A(s[0],s[1]+a/2),s,e.angle),hitboxWidth:cP/t,hitboxHeight:lP/t}},pP=(e,t,n,r)=>{let i=fP(t,n,r);if(!i)return!1;let a=_o(A(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},mP=(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)`},hP=(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 ji(i)?`rtl`:`ltr`},gP=e=>{let t=[0],n=0;for(let r of Array.from(e))n+=r.length,t.push(n);return t},_P=({text:e,font:t,lineHeightPx:n,direction:r,targetX:i})=>{if(!e||!document.body||typeof document.createRange!=`function`)return null;let a=gP(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},vP=({onChange:e,onSubmit:t,getViewportCoords:n,element:r,canvas:i,excalidrawContainer:a,app:o,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 Fi({fontFamily:e.fontFamily})!==n||`${e.fontSize}px`!==t.style.fontSize},f=o.state.theme,p=()=>{f=o.state.theme;let e=o.state,t=o.scene.getElement(r.id);if(!t)return;let{textAlign:i,verticalAlign:a}=t,c=o.scene.getNonDeletedElementsMap();if(t&&F(t)){let r=t.x,l=t.y,f=bo(t,o.scene.getNonDeletedElementsMap()),p=t.width,h=t.height,g=t.width,_=t.height;if(f&&t.containerId){if(Wa(f)){let e=M.getBoundTextElementPosition(f,t,c);r=e.x,l=e.y}let e=d(t,m),n;if(e?n=s(f.id,f.height):(n=oe[f.id],n||=s(f.id,f.height)),g=Ot(f,t),_=ro(f,t),!Wa(f)&&h>_){let e=ka(h,f.type);o.scene.mutateElement(f,{height:e}),zt(f,o.scene);return}if(!Wa(f)&&f.height>n.height&&h<_){let e=ka(h,f.type);o.scene.mutateElement(f,{height:e}),zt(f,o.scene)}else{let{x:e,y:n}=wi(f,t,c);r=e,l=n}}let[v,y]=n(r,l);f?p+=.5:(g=(e.width-8-v)/e.zoom.value,p=Math.min(p,g)),h*=1.05;let b=se(t),x=ge(t,f),S=(e.height-y)/e.zoom.value;Object.assign(m.style,{font:b,lineHeight:t.lineHeight,width:`${p}px`,height:`${h}px`,left:`${v}px`,top:`${y}px`,transform:mP(p,h,x,e,g,S),textAlign:i,verticalAlign:a,color:Hn(t.strokeColor,e.theme===N.DARK),opacity:t.opacity/100,maxHeight:`${S}px`}),u={angle:x,font:b,height:t.height,lineHeightPx:Pr(t.fontSize,t.lineHeight),textAlign:i,width:t.width,x:r,y:l},m.scrollTop=0,zi()&&(m.style.fontFamily=Fi(t)),o.scene.mutateElement(t,{x:r,y:l})}},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`;(fs(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 _=()=>{if(!l||!u)return null;let e=u,t=A(e.x+e.width/2,e.y+e.height/2),[n,r]=_o(A(l.x,l.y),t,-e.angle),i=n-e.x,a=r-e.y,o=rn(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=hP(m.value,s.start),d=Ro(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=_P({text:s.text,font:e.font,lineHeightPx:e.lineHeightPx,direction:c,targetX:f});return s.start+(p||0)},v=(()=>{let e=_();return e===null?null:{start:e,end:e}})();e&&(m.onpaste=async e=>{let t=sD(e),n=null;if(t.has(L.excalidrawClipboard)||t.has(L.excalidraw)){e.preventDefault(),n=await cD(e);try{let e=await lD(n);if(e.elements){let t=Ws(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 cD(e);let i=n.findByType(L.text);if(!i)return;let a=wt(i.value);if(!a)return;let s=bo(r,o.scene.getNonDeletedElementsMap()),c=se({fontSize:o.state.currentItemFontSize,fontFamily:o.state.currentItemFontFamily});if(s){let e=ao(s,o.scene.getNonDeletedElementsMap()),t=yc(`${m.value}${a}`,c,Ot(s,e)),n=Ta(t,c);m.style.width=`${n}px`}},m.oninput=()=>{let t=wt(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&&dE.keyTest(e))e.preventDefault(),o.actionManager.executeAction(dE),p();else if(!e.shiftKey&&fE.keyTest(e))e.preventDefault(),o.actionManager.executeAction(fE),p();else if(!e.shiftKey&&pE.keyTest(e))e.preventDefault(),o.actionManager.executeAction(pE),p();else if($T.keyTest(e))o.actionManager.executeAction($T);else if(eE.keyTest(e))o.actionManager.executeAction(eE);else if(e.key===I.ESCAPE)e.preventDefault(),T=!0,E();else if(TD.keyTest(e))e.preventDefault(),E(),o.actionManager.executeAction(TD);else if(e.key===I.ENTER&&e[I.CTRL_OR_CMD]){if(e.preventDefault(),e.isComposing||e.keyCode===229)return;T=!0,E()}else if(e.key===I.TAB||e[I.CTRL_OR_CMD]&&(e.code===ir.BRACKET_LEFT||e.code===ir.BRACKET_RIGHT)){if(e.preventDefault(),e.isComposing)return;e.shiftKey||e.code===ir.BRACKET_LEFT?S():x(),m.dispatchEvent(new Event(`input`))}};let y=` `.repeat(4),b=RegExp(`^ {1,4}`),x=()=>{let{selectionStart:e,selectionEnd:t}=m,n=C(),r=m.value;n.forEach(e=>{let t=r.slice(0,e),n=r.slice(e);r=`${t}${y}${n}`}),m.value=r,m.selectionStart=e+4,m.selectionEnd=t+4*n.length},S=()=>{let{selectionStart:e,selectionEnd:t}=m,n=C(),r=[],i=m.value;n.forEach(e=>{let t=i.slice(e,e+4).match(b);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))},C=()=>{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()},w=e=>{e.target instanceof HTMLCanvasElement&&(e.preventDefault(),e.stopPropagation())},T=!1,E=()=>{if(ie)return;ie=!0,D();let e=o.scene.getElement(r.id);if(!e)return;let n=bo(e,o.scene.getNonDeletedElementsMap());if(n){if(m.value.trim()){let e=De(n);!e||e!==r.id?o.scene.mutateElement(n,{boundElements:(n.boundElements||[]).concat({type:`text`,id:r.id})}):Wa(n)&&xr(n)}else o.scene.mutateElement(n,{boundElements:n.boundElements?.filter(e=>!F(e))});ga(e,n,o.scene)}t({viaKeyboard:T,nextOriginalText:m.value})},D=()=>{m.onblur=null,m.oninput=null,m.onkeydown=null,ae&&ae.disconnect(),window.removeEventListener(`resize`,p),window.removeEventListener(`wheel`,w,!0),window.removeEventListener(`pointerdown`,k),window.removeEventListener(`pointerup`,ee),window.removeEventListener(`blur`,E),window.removeEventListener(`beforeunload`,E),ne(),te(),re(),m.remove()},ee=e=>{window.removeEventListener(`pointerup`,ee);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(`.${Os.SHAPE_ACTIONS_MENU}`)||!!t.closest(`.compact-shape-actions-island`));setTimeout(()=>{i||n||r||(m.onblur=E,m.focus(),v&&=(m.setSelectionRange(v.start,v.end),null))})},O=()=>{m.onblur=null,window.addEventListener(`pointerup`,ee),window.addEventListener(`blur`,E)},k=e=>{let t=e?.target;if(e.button===kc.WHEEL){t instanceof HTMLTextAreaElement&&(e.preventDefault(),o.handleCanvasPanUsingWheelOrSpaceDrag(e)),O();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(`.${Os.SHAPE_ACTIONS_MENU}, .${Os.ZOOM_ACTIONS}`)||e.target.closest(`.compact-shape-actions-island`))&&!Ee(e.target)||n||r?O():e.target instanceof HTMLCanvasElement&&!zi()&&requestAnimationFrame(()=>{E()})},te=o.onChangeEmitter.on(e=>{o.state.theme!==f&&p()}),ne=o.scene.onUpdate(()=>{p(),document.activeElement?.closest(`.properties-content`)||m.focus()}),re=o.onScrollChangeEmitter.on(()=>{p()}),ie=!1;c&&!v&&m.select(),ee();let ae=null;return i&&`ResizeObserver`in window?(ae=new window.ResizeObserver(()=>{p()}),ae.observe(i)):window.addEventListener(`resize`,p),m.onpointerdown=e=>e.stopPropagation(),requestAnimationFrame(()=>{window.addEventListener(`pointerdown`,k,{capture:!0})}),window.addEventListener(`beforeunload`,E),a?.querySelector(`.excalidraw-textEditorContainer`).appendChild(m),E},yP=4,bP=6,xP=`rgba(0,0,0,0.3)`,SP=(e,t,n,r)=>{if(!e.size)return{horizontal:null,vertical:null};let[i,a,o,s]=Bs(e),c=t/r.zoom.value,l=n/r.zoom.value,u={top:parseInt(Pc(`sat`))||0,bottom:parseInt(Pc(`sab`))||0,left:parseInt(Pc(`sal`))||0,right:parseInt(Pc(`sar`))||0},d=jb().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(yP*2,u.left+u.right)+bP*2,T=c/S*t-w,E=Math.max(yP*2,u.top+u.bottom)+bP*2,D=l/C*n-E,ee=S>b?S*r.zoom.value/(T+w):t/(T+w),O=C>x?C*r.zoom.value/(D+E):n/(D+E);return{horizontal:f===g&&m===v?null:{x:Math.max(u.left,yP)+bP+(f-g)/S*t,y:n-bP-Math.max(yP,u.bottom),width:T,height:bP,deltaMultiplier:ee},vertical:p===_&&h===y?null:{x:d?Math.max(u.left,yP):t-bP-Math.max(u.right,yP),y:Math.max(u.top,yP)+bP+(p-_)/C*n,width:bP,height:D,deltaMultiplier:O}}},CP=(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}},wP=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()),TP=e=>{let{lassoPath:t,elements:n,elementsMap:r,elementsSegments:i,intersectedElements:a,enclosedElements:o,simplifyDistance:s,mode:c=`contain`}=e,l=t;s&&(l=Ay(t,s));let u=n.filter(e=>!e.locked&&!fs(e));o.clear(),a.clear();let d=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]),p=re(l),m=[d[0]-hi,d[1]-hi,d[2]+hi,d[3]+hi];for(let e of u){let t=f(e,r),n=EP(e,t,r),s=DP(t,n);if(qs(d,s)&&!a.has(e.id)&&!o.has(e.id)){if(c===`contain`&&!Vr(m,s))continue;let t=jP(p,OP(e,r,i,n),s,c);c===`contain`?t&&!PP(l,e,r,n)&&o.add(e.id):t?o.add(e.id):PP(l,e,r,n)&&a.add(e.id)}}return{selectedElementIds:c===`contain`?AP([...o],r):[...a,...o]}},EP=(e,t,n)=>{let r=Wt(e,n);if(!r)return null;let i=f(r,n);return Vr(i,t)?null:Zn(e,r,n)?i:null},DP=(e,t)=>t?[Math.max(e[0],t[0]),Math.max(e[1],t[1]),Math.min(e[2],t[2]),Math.min(e[3],t[3])]:e,OP=(e,t,n,r)=>{let i=n.get(e.id)??[],a=ao(e,t),o=a?n.get(a.id):null,s=o?.length?[...i,...o]:i;return r?kP(s,r):s},kP=(e,t)=>{let[n,r,i,a]=t,o=[];for(let[[t,s],[c,l]]of e){let e=c-t,u=l-s,d=0,f=1,p=!0;for(let[o,c]of[[-e,t-n],[e,i-t],[-u,s-r],[u,a-s]]){if(o===0){if(c<0){p=!1;break}continue}let e=c/o;if(o<0){if(e>f){p=!1;break}d=Math.max(d,e)}else{if(e<d){p=!1;break}f=Math.min(f,e)}}p&&o.push(Ni(A(t+d*e,s+d*u),A(t+f*e,s+f*u)))}return o},AP=(e,t)=>{if(!e.some(e=>t.get(e)?.groupIds.length))return e;let n=new Map;for(let e of t.values()){let t=e.groupIds.at(-1);if(!t||e.locked||fs(e))continue;let r=n.get(t);r?r.push(e.id):n.set(t,[e.id])}if(!n.size)return e;let r=new Set(e);return e.filter(e=>{let i=t.get(e)?.groupIds.at(-1),a=i?n.get(i):null;return!a||a.every(e=>r.has(e))})},jP=(e,t,n,r)=>{let i=r===`contain`?`every`:`some`,a=t=>pa(t,e)||r===`contain`&&NP(t,e);return t.length===0?MP(n)[i](a):t[i](e=>e[i](a))},MP=([e,t,n,r])=>[A(e,t),A(n,t),A(n,r),A(e,r)],NP=(e,t)=>t.some((n,r)=>r>0&&rc(e,Ni(t[r-1],n))),PP=(e,t,n,r)=>{let i=e.slice(1).map((t,n)=>Ni(e[n],t)).concat([Ni(e[e.length-1],e[0])]),a=ao(t,n),o=(e,t)=>{let i=wo(e,n,t,0,!r);return r?i.some(e=>cs(e,r)):i.length>0};return i.some(e=>o(t,e)||!!a&&o({...a,...wi(t,a,n)},e))},FP=class extends iP{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(v(n),v(t))},fill:()=>`rgba(105,101,219,0.05)`,stroke:()=>`rgba(105,101,219)`}),B(this,`intersectedElements`,new Set),B(this,`enclosedElements`,new Set),B(this,`elementsSegments`,null),B(this,`canvasTranslate`,null),B(this,`keepPreviousSelection`,!1),B(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&&P(t)){let e=tr(this.app.scene.getNonDeletedElementsMap(),t.id);for(let t of e)delete n[t.id]}}let r=Xo({editingGroupId:t.editingGroupId,selectedElementIds:n},this.app.scene.getNonDeletedElements(),t,this.app),i=[...Object.keys(r.selectedElementIds)],a=[...Object.keys(r.selectedGroupIds)];return{selectedElementIds:r.selectedElementIds,selectedGroupIds:r.selectedGroupIds,selectedLinearElement:i.length===1&&!a.length&&vo(this.app.scene.getNonDeletedElement(i[0]))?new M(this.app.scene.getNonDeletedElement(i[0]),this.app.scene.getNonDeletedElementsMap()):null}})}),B(this,`addPointToPath`,(e,t,n=!1)=>{super.addPointToPath(e,t),this.keepPreviousSelection=n,this.updateSelection()}),B(this,`updateSelection`,()=>{let e=super.getCurrentTrail()?.originalPoints?.map(e=>A(e[0],e[1])),t={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom.value};if(!this.elementsSegments||!Jn(t,this.canvasTranslate??{})){this.canvasTranslate=t,this.elementsSegments=new Map;let e=ze(this.app.visibleElements);for(let t of this.app.visibleElements){let n=gi(t,e);this.elementsSegments.set(t.id,n)}}if(e){let{selectedElementIds:t}=TP({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,mode:this.app.state.boxSelectionMode});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}},IP=class extends iP{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(v(n),v(t))},fill:()=>e.state.theme===N.LIGHT?`rgba(0, 0, 0, 0.2)`:`rgba(255, 255, 255, 0.2)`}),B(this,`elementsToErase`,new Set),B(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=>A(e[0],e[1]))||[];if(t.length<2)return[];let n=Ni(t[t.length-1],t[t.length-2]),r=this.app.visibleElements.filter(e=>!e.locked),i=ze(r);for(let t of r)if(e&&this.elementsToErase.has(t.id)){if(LP(n,t,i,this.app.state.zoom.value)){let e=t.groupIds.at(-1);if(this.groupsToErase.has(e)){let t=St(this.app.scene.getNonDeletedElementsMap(),e);for(let e of t)this.elementsToErase.delete(e.id);this.groupsToErase.delete(e)}if(fs(t)&&this.elementsToErase.delete(t.containerId),Qr(t)){let e=De(t);e&&this.elementsToErase.delete(e)}this.elementsToErase.delete(t.id)}}else if(!e&&!this.elementsToErase.has(t.id)&&LP(n,t,i,this.app.state.zoom.value)){let e=t.groupIds.at(-1);if(!this.groupsToErase.has(e)){let t=St(this.app.scene.getNonDeletedElementsMap(),e);for(let e of t)this.elementsToErase.add(e.id);this.groupsToErase.add(e)}if(Qr(t)){let e=De(t);e&&this.elementsToErase.add(e)}fs(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()}},LP=(e,t,n,r)=>{let i=e[1],a=ja(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=f(t,n),c=[s[0]-a,s[1]-a,s[2]+a,s[3]+a];if(!qs(o,c))return!1;if(Nn(t)&&Se(i,t,n))return!0;if(ja(t)){let i=Ko(t),a=cr(t,i,n),o=Math.max(2.25,5/r);for(let t of a)if(zs(t,e)<=o)return!0;let s=Bn(...i.map(([e,n])=>A(t.x+e,t.y+n)));return!!pa(e[0],s)}let l=ao(t,n);if(Wa(t)||Me(t)&&!t.polygon){let i=Math.max(t.strokeWidth,t.strokeWidth*2/r),a=gi(t,n);for(let t of a)if(zs(t,e)<=i)return!0;return!1}return wo(t,n,e,0,!0).length>0||!!l&&wo({...l,...wi(t,l,n)},n,e,0,!0).length>0},RP=44,zP=22,BP=66,VP=48,HP=14,UP=304,WP=320,GP=5.87,KP=28,qP=4,JP=2,YP=10,XP=10,ZP=8,QP=12,$P=256,eF=10,tF=4,nF=QP*2,rF=QP*2,iF=100,aF=140,oF=.35,sF=QP/2,cF=20,lF=QP*2,uF=QP,dF={fillStyle:`hachure`,fontFamily:Pt,fontSize:20,opacity:100,roughness:1,strokeColor:Tt.black,roundness:null,strokeStyle:`solid`,strokeWidth:1,verticalAlign:D.MIDDLE,locked:!1},fF=er(4),pF=e=>e.labels?.length??e.series[0]?.values.length??0,mF=(e,t)=>{if(!e)return!1;let n=pF(e);return n<2?!1:t!==`radar`||n>=3},hF=(e,t)=>e+(t<=1?0:Math.min(BP,(t-1)*zP)),gF=(e,t)=>{if(e===`line`){let e=hF(VP,t);return{slotWidth:e,gap:HP,chartHeight:WP,xLabelMaxWidth:e+HP*3+YP}}let n=hF(RP,t);return{slotWidth:n,gap:HP,chartHeight:UP,xLabelMaxWidth:n+HP*3+YP}},_F=(e,t)=>({chartWidth:(t.slotWidth+t.gap)*e.series[0].values.length+t.gap,chartHeight:t.chartHeight+t.gap*2}),vF=()=>({chartWidth:$P+rF*2,chartHeight:$P+rF*2}),yF=(e,t,n)=>{let r=Math.abs(e-t);return Math.min(r,n-r)},bF=(e,t)=>{if(e<=0||fF.length===0)return[];let n=fF.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=>yF(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)=>fF[i[t%i.length]])},xF=e=>{if(fF.length===0)return 0;if(typeof e!=`number`||!Number.isFinite(e))return Math.floor(Math.random()*fF.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)%fF.length},SF=e=>fF[e],CF=(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>=iF;return{renderSteps:!1,normalize:(e,t)=>{let n=Math.max(0,e);return o?Math.log10(n+1)/Math.log10(i+1):n/i}}},wF=e=>/\s/.test(e.trim()),TF=(e,t,n)=>wF(e)?yc(e,t,n):e,EF=(e,t,n,r,i,a)=>{let o=Zo.Excalifont,s=Fo.sm,c=sa(o),l=se({fontFamily:o,fontSize:s}),u=Math.min(aF,i*(e.length>8?.56:.72)),d=En(l,c),f=e.map((e,f)=>{let p=t[f],m=Math.max(0,...e.trim().split(/\s+/).filter(Boolean).map(e=>xa(e,l,c).width)),h=TF(e,l,Math.max(d,u,m)),g=xa(h,l,c),_=Math.cos(p),v=Math.sin(p),y=_>oF?`left`:_<-oF?`right`:`center`,b=y===`center`?g.width/2:0,x=nF+(Math.abs(_)*b+Math.abs(v)*(g.height/2))+sF,S=n+_*(i+x),C=r+v*(i+x),w=v>oF?QP/3:v<-oF?-QP/3:0;return k({backgroundColor:a,...dF,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))}},DF=(e,t,n,r,i,a)=>{if(e.length<=1)return[];let o=Zo[`Lilita One`],s=Fo.lg,c=sa(o),l=se({fontFamily:o,fontSize:s}),u=e.map((e,n)=>{let r=e.title?.trim()||`Series ${n+1}`,i=TF(r,l,$P),a=xa(i,l,c),o=cF+uF+a.width;return{label:r,displayLabel:i,color:t[n],width:o,height:a.height}}),d=Math.max(cF/2,...u.map(e=>e.height/2)),f=Math.max(i,r+d+nF),p=lF,m=cF*.6,h=u.reduce((e,t)=>e+t.width,0)+lF*Math.max(0,u.length-1),g=h+p*2,_=d*2+m*2,v=[];v.push(_c({...dF,backgroundColor:`transparent`,type:`rectangle`,fillStyle:`solid`,strokeColor:Tt.black,x:n-g/2,y:f-_/2,width:g,height:_,roughness:$i.architect,roundness:{type:qi.PROPORTIONAL_RADIUS}}));let y=n-h/2;return u.forEach(e=>{v.push(_c({...dF,backgroundColor:e.color,type:`rectangle`,x:y,y:f-cF/2,width:cF,height:cF,fillStyle:`solid`,strokeColor:e.color,roughness:$i.architect,roundness:{type:qi.PROPORTIONAL_RADIUS}})),v.push(k({...dF,text:e.displayLabel,originalText:e.label,autoResize:!1,x:y+cF+uF,y:f,fontFamily:o,fontSize:s,lineHeight:c,textAlign:`left`,verticalAlign:`middle`})),y+=e.width+lF}),v},OF=(e,t,n,r)=>{if(xa(e,n,r).width<=t)return e;let i=e.length;for(;i>1;){let a=`${e.slice(0,i)}...`;if(xa(a,n,r).width<=t)return a;i--}return e[0]?`${e[0]}...`:e},kF=(e,t,n,r)=>{if(xa(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=>xa(e,n,r).width>t)&&t>=En(n,r)?{wrapped:!0,text:yc(e,n,t)}:{wrapped:!1,text:OF(e,t,n,r)}},AF=(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}},jF=e=>e.includes(`...`),MF=(e,t,n,r,i)=>{let a=Math.max(KP,Math.ceil(En(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:jF(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}=kF(e,t,r,i),s=xa(o,r,i),c=AF(s.width,s.height,GP),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}),!jF(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+ZP?f.spec:d.spec)},NF=e=>{if(e.type!==`text`)return e.y+e.height;let t=AF(e.width,e.height,e.angle);return e.y+e.height/2+t.height/2},PF=(e,t,n,r,i)=>{let a=dF.fontFamily,o=Fo.sm,s=sa(a),c=se({fontFamily:a,fontSize:o}),l=Math.max(1,i.slotWidth+i.gap-qP*2+XP),u=n;return e.labels?.map((e,n)=>{let a=MF(e,i.xLabelMaxWidth,l,c,s),d=t+n*(i.slotWidth+i.gap)+i.gap+i.slotWidth/2,f=u+JP+(a.rotatedHeight-a.metrics.height)/2;return k({backgroundColor:r,...dF,text:a.text,originalText:a.wrapped?e:a.text,autoResize:!a.wrapped,x:d,y:f,angle:GP,fontSize:o,lineHeight:s,textAlign:`center`,verticalAlign:`top`})})||[]},FF=(e,t,n,r,i,a=Math.max(...e.series[0].values))=>{let o=k({backgroundColor:r,...dF,x:t-i.gap,y:n-i.gap,text:`0`,textAlign:`right`});return[o,k({backgroundColor:r,...dF,x:t-i.gap,y:n-i.chartHeight-o.height/2,text:a.toLocaleString(),textAlign:`right`})]},IF=(e,t,n,r,i)=>{let{chartWidth:a,chartHeight:o}=_F(e,i);return[ie({backgroundColor:r,...dF,type:`line`,x:t,y:n,width:a,points:[A(0,0),A(a,0)]}),ie({backgroundColor:r,...dF,type:`line`,x:t,y:n,height:o,points:[A(0,0),A(0,-o)]}),ie({backgroundColor:r,...dF,type:`line`,x:t,y:n-i.chartHeight-i.gap,strokeStyle:`dotted`,width:a,opacity:eF,points:[A(0,0),A(a,0)]})]},LF=(e,t,n,r,i,a=Math.max(...e.series[0].values),o)=>{let{chartWidth:s,chartHeight:c}=_F(e,i),l=e.title?k({backgroundColor:r,...dF,text:e.title,x:t+s/2,y:n-i.chartHeight-i.gap*2-20,roundness:null,textAlign:`center`,fontSize:Fo.xl,fontFamily:Zo[`Lilita One`]}):null,u=o?_c({backgroundColor:r,...dF,type:`rectangle`,x:t,y:n-c,width:s,height:c,strokeColor:Tt.black,fillStyle:`solid`,opacity:6}):null;return[...u?[u]:[],...l?[l]:[],...PF(e,t,n,r,i),...FF(e,t,n,r,i,a),...IF(e,t,n,r,i)]},RF=(e,t,n,r)=>{let i=e.series,a=gF(`bar`,i.length),o=Math.max(1,...i.flatMap(e=>e.values.map(e=>Math.max(0,e)))),s=xF(r),c=SF(s),l=bF(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 _c({backgroundColor:m,...dF,type:`rectangle`,fillStyle:i.length>1?`solid`:dF.fillStyle,strokeColor:i.length>1?m:dF.strokeColor,x:t+r*(a.slotWidth+a.gap)+a.gap+p+s*(d+u),y:n-f-a.gap,width:d,height:f})})),h=LF(e,t,n,c,a,o,ht()),g=PF(e,t,n,c,a),_=Math.max(n+a.gap/2,...g.map(e=>NF(e))),{chartWidth:v}=_F(e,a),y=DF(i,l,t+v/2,_,n+a.gap*5,c);return[...h,...m,...y]},zF=(e,t,n,r)=>{let i=e.series,a=gF(`line`,i.length),o=Math.max(1,...i.flatMap(e=>e.values)),s=xF(r),c=SF(s),l=bF(i.length,s),u=i.map((e,r)=>{let i=e.values.map((e,t)=>A(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 ie({backgroundColor:`transparent`,...dF,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 _c({backgroundColor:l[r],...dF,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 ie({backgroundColor:c,...dF,type:`line`,x:t+i+a.slotWidth/2+a.gap/2,y:n-s,height:s,strokeStyle:`dotted`,opacity:eF,points:[A(0,0),A(0,s)]})}),p=LF(e,t,n,c,a,o,ht()),m=PF(e,t,n,c,a),h=Math.max(n+a.gap/2,...m.map(e=>NF(e))),{chartWidth:g}=_F(e,a),_=DF(i,l,t+g/2,h,n+a.gap*5,c);return[...p,...u,...f,...d,..._]},BF=e=>{let t=/^([-+]?)[$\u20AC\u00A3\u00A5\u20A9]?([-+]?)([\d.,]+)[%]?$/.exec(e);return t?parseFloat(`${(t[1]||t[2])+t[3]}`.replace(/,/g,``)):null},VF=(e,t)=>e.slice(1).every(e=>BF(e[t])!==null),HF=e=>{let t=e[0].length;if(t>2){let n=e[0].every(e=>BF(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=>BF(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=>BF(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=>BF(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(!VF(e,0))return{ok:!1,reason:`Value is not numeric`};let t=BF(e[0][0])===null,n=t?e[0][0]:null,r=(t?e.slice(1):e).map(e=>BF(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=BF(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=>BF(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=>BF(e[1]))}]}}},UF=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)?HF(r):{ok:!1,reason:`All rows don't have same number of columns`}},WF=(e,t,n,r)=>{if(!mF(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}=CF(a,i.length),c=xF(r),l=SF(c),u=bF(a.length,c),{chartWidth:d,chartHeight:f}=vF(),p=t+d/2,m=n-f/2,h=$P/2,g=i.map((e,t)=>-Math.PI/2+Math.PI*2*t/i.length),{axisLabels:_,axisLabelTopY:v,axisLabelBottomY:y}=EF(i,g,p,m,h,l),b=Zo[`Lilita One`],x=Fo.xl,S=sa(b),C=se({fontFamily:b,fontSize:x}),w=e.title?TF(e.title,C,d+nF*2):null,T=w?xa(w,C,S):null,E=w?k({backgroundColor:l,...dF,text:w,originalText:e.title??w,x:t+d/2,y:v-nF-T.height/2,fontFamily:b,fontSize:x,lineHeight:S,textAlign:`center`}):null,D=s?Array.from({length:tF},(e,t)=>{let n=(t+1)/tF,r=h*n,i=g.map(e=>A(Math.cos(e)*r,Math.sin(e)*r));return i.push(A(i[0][0],i[0][1])),ie({backgroundColor:`transparent`,...dF,type:`line`,x:p,y:m,width:r*2,height:r*2,strokeStyle:`solid`,roughness:$i.architect,opacity:eF,polygon:!0,points:i})}):[],ee=g.map(e=>{let t=Math.cos(e)*h,n=Math.sin(e)*h;return ie({backgroundColor:`transparent`,...dF,type:`line`,x:p,y:m,width:Math.abs(t),height:Math.abs(n),strokeStyle:`solid`,roughness:$i.architect,opacity:eF,points:[A(0,0),A(t,n)]})}),O=a.map((e,t)=>{let n=g.map((t,n)=>{let r=e.values[n]??0,i=o(r,n)*h;return A(Math.cos(t)*i,Math.sin(t)*i)});return n.push(A(n[0][0],n[0][1])),ie({backgroundColor:`transparent`,...dF,type:`line`,x:p,y:m,width:h*2,height:h*2,strokeColor:u[t],strokeWidth:2,polygon:!0,points:n})}),te=DF(a,u,p,y,n+QP*5,l);return[...E?[E]:[],..._,...D,...ee,...O,...te]},GF=(e,t,n,r,i)=>e===`line`?zF(t,n,r,i):e===`radar`?WF(t,n,r,i):RF(t,n,r,i),KF=class{constructor(e){this.app=e,B(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}),B(this,`refresh`,()=>{this.app.lastPointerMoveCoords&&this.updateHoveredAnchor(this.app.lastPointerMoveCoords)})}getBindableEndpointAtPosition(e,t){if(!Qs(this.app.state))return null;let n=xc(A(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!Wa(r)||ao(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 fa(e,t,this.app.scene.getNonDeletedElementsMap(),n)}bindText({arrow:e,startOrEnd:t},n,r){Ja(e,n,t,r,this.app.scene)}maybeDragNewText(e,t){return!F(e)||!ee(e,this.app.scene.getNonDeletedElementsMap())?!1:($t({newElement:e,...rr(e),pointerX:t.x,zoom:this.app.state.zoom.value,scene:this.app.scene}),!0)}},qF=Ua.filter(e=>e!==Tt.white),JF=class{constructor(e){this.app=e,B(this,`temporaryEyeDropper`,null),B(this,`pending`,null),B(this,`handlePointerDown`,e=>{this.pending=e}),B(this,`handlePointerUp`,()=>{let e=this.pending;this.pending=null,e&&this.fill(e)}),B(this,`cancel`,()=>{this.pending=null}),B(this,`cycleBackgroundColor`,()=>{let e=this.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor),t=qF[(qF.indexOf(e)+1)%qF.length];this.app.actionManager.executeAction(XT,`keyboard`,{currentItemBackgroundColor:t})}),B(this,`openTemporaryEyeDropper`,()=>{if(Sb.get(Ow))return;let e={colorPickerType:`elementBackground`,keepOpenOnAlt:!0,onSelect:e=>{this.app.actionManager.executeAction(XT,`ui`,{currentItemBackgroundColor:e})}};this.temporaryEyeDropper=e,this.app.updateEditorAtom(Ow,e)}),B(this,`closeTemporaryEyeDropper`,()=>{let e=this.temporaryEyeDropper;this.temporaryEyeDropper=null,e&&Sb.get(Ow)===e&&this.app.updateEditorAtom(Ow,null)}),B(this,`restyle`,e=>{let t=this.getBucketFillBackgroundColor(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}),yr.delete(e),this.app.scheduleCapture())}),B(this,`fill`,e=>{let t=this.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor),n=this.app.scene.getNonDeletedElements(),r=this.app.scene.getNonDeletedElementsMap(),i=A(e.x,e.y),a=this.app.getElementAtPosition(i[0],i[1]),o=to({point:i,elements:n,elementsMap:r});if(!o.ok){if(a&&ca(a)){this.restyle(a);return}o.reason===`too_complex`?this.app.setToast({message:G(`bucketfill.tooComplex`),duration:3e3}):(o.reason===`open_region`||o.reason===`too_small`||o.reason===`invalid_polygon`)&&this.app.setToast({message:G(`bucketfill.noRegion`),duration:3e3});return}if(a&&Ge({hitElement:a,scenePoints:o.scenePoints,elementsMap:r})){this.restyle(a);return}let{width:s,height:c}=Pn(o.scenePoints),[l,u]=o.scenePoints[0],d=o.scenePoints.map(e=>A(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=ie({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()}),B(this,`getBucketFillBackgroundColor`,(e,t)=>Aa(e)?Tt.green[1]:Hn(e,t===N.DARK))}},YF=`<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">`,XF=`<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"/>`,ZF=`<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"/>`,QF=`data:${L.svg},${encodeURIComponent(`${YF}${ZF}</svg>`)}`,$F=`data:${L.svg},${encodeURIComponent(`${YF}${XF}${ZF}</svg>`)}`,eI=e=>{let t=Ax.map((t,n)=>`<path d="${t}" ${n<2?`fill="${e}"`:``} />`).join(``);return`data:${L.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>`)}`},tI=class{constructor(e){this.app=e,B(this,`toolCursorMemo`,null),B(this,`eraserCanvasCache`,null),B(this,`eraserPreviewDataURL`,null),B(this,`set`,e=>{this.toolCursorMemo=null,this.canvas&&(this.canvas.style.cursor=e)}),B(this,`reset`,()=>{this.app.state.viewModeEnabled&&!this.app.isActiveToolPointerCapturing()?this.app.isNavigationEnabled()?this.set(We.GRAB):this.clear():this.applyForTool()}),B(this,`applyForTool`,(e=this.app.state.activeTool)=>{let t=this.canvas;if(!t)return;let n=e.type===`eraser`||e.type===`laser`||e.type===`bucketfill`?this.app.state.theme:void 0,r=e.type===`bucketfill`?this.app.bucketFill.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor,n):void 0,i=this.toolCursorMemo;if(i?.canvas!==t||i.type!==e.type||i.bucketFillColor!==r||i.theme!==n){if(e.type===`selection`)this.clear();else if(No({activeTool:e}))this.set(We.GRAB);else if(ti({activeTool:e}))this.applyEraser();else if(e.type===`autoshape`)this.set(We.CROSSHAIR);else if(e.type===`bucketfill`)this.set(`url(${eI(r)}) 5 18, auto`);else if(e.type===`laser`){let e=this.app.state.theme===N.LIGHT?QF:$F;this.set(`url(${e}), auto`)}else[`image`,`custom`].includes(e.type)?e.type!==`image`&&this.set(We.AUTO):this.set(We.CROSSHAIR);this.toolCursorMemo={canvas:t,type:e.type,bucketFillColor:r,theme:n}}}),B(this,`clear`,()=>{this.set(``)}),B(this,`applyEraser`,()=>{let e=this.app.state.theme;if(!this.eraserCanvasCache||this.eraserCanvasCache.theme!==e){let t=e===N.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(L.svg)}this.set(`url(${this.eraserPreviewDataURL}) 10 10, auto`)})}get canvas(){return this.app.interactiveCanvas}},nI=class{constructor(e){this.app=e,B(this,`trail`),this.trail=new iP(this.app,{...this.getTrailOptions(),fill:()=>e.state.theme===N.LIGHT?`rgba(0, 0, 0, 0.2)`:`rgba(255, 255, 255, 0.2)`})}getTrailOptions(){return{simplify:0,streamline:.4,size:1,sizeMapping:()=>bs(bc(`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])=>A(e,t)):[]}start(e){this.trail.start(e)}stop(){this.trail.stop()}},rI=class{constructor(e){this.app=e,B(this,`trail`),B(this,`gestureInProgress`,!1),B(this,`stop`,()=>{this.trail.stop()}),B(this,`hasPendingGesture`,()=>this.gestureInProgress),B(this,`handlePointerDown`,e=>{this.gestureInProgress&&this.app.actionManager.executeAction(zE),this.gestureInProgress=!0,this.trail.startPath(e.lastCoords.x,e.lastCoords.y)}),B(this,`handlePointerMove`,e=>xs(this.app,e)),B(this,`bindRecognizedArrow`,e=>{let{app:t}=this,n=t.scene.getNonDeletedElementsMap(),r=t.scene.getNonDeletedElements(),i=Fn(t.state.zoom),a=[`start`,`end`].map(t=>{let a=M.getPointAtIndexGlobalCoordinates(e,t===`start`?0:-1,n);return{startOrEnd:t,globalPoint:a,target:ec(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&&$n(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=_n(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&&M.movePoints(e,t.scene,c)}),B(this,`maybeUpgradeLineToArrow`,e=>{let{app:t}=this,n=t.scene.getNonDeletedElementsMap(),r=t.scene.getNonDeletedElements(),i=Fn(t.state.zoom),[a,o]=[0,-1].map(t=>ec(M.getPointAtIndexGlobalCoordinates(e,t,n),r,n,i));return!a&&!o||a===o?null:mi({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})}),B(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||Zi(t,e.state,e.scene.getNonDeletedElementsMap(),e.state.newElement,e.scene.getNonDeletedFramesLikes());if(n){let t={...n,seed:Ba(),opacity:e.state.currentItemOpacity};e.state.isBindingEnabled&&Me(t)&&(t=this.maybeUpgradeLineToArrow(t)??t),e.insertNewElement(t),e.state.isBindingEnabled&&Ur(t)&&this.bindRecognizedArrow(t)}}this.trail.clearTrails()}),this.trail=new nI(e)}},iI=class e{constructor(e){this.app=e,B(this,`creator`,new wr),B(this,`navigator`,new qr),B(this,`clear`,()=>{this.creator.clear(),this.navigator.clear()}),B(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===I.ESCAPE&&n.isCreatingChart)return n.clear(),{type:`canceled`};if(!To(t.key))return{type:`none`};if(t[I.CTRL_OR_CMD]&&!t.shiftKey){let r=is(i.scene.getNonDeletedElementsMap(),i.state);return r.length===1&&Ft(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=is(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[I.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:ci({[e.id]:!0},t)})),this.app.revealIfHidden([e])}captureUpdate(){this.app.syncActionResult({captureUpdate:j.IMMEDIATELY})}static getLinkDirectionFromKey(e){switch(e){case I.ARROW_UP:return`up`;case I.ARROW_DOWN:return`down`;case I.ARROW_RIGHT:return`right`;case I.ARROW_LEFT:return`left`;default:return`right`}}},aI=`animateScrollToContent`,oI=`animateScrollConstraintsSnapBack`,sI=500,cI=250,lI=200,uI=302,dI={full:216,compact:64},fI=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`)},pI=(e,t)=>{let n=t.get(e);return n?[n]:St(t,e)},mI=(e,t,n)=>{if(typeof e==`string`){let n=Po(e),r=n?`link`:`element`,i=n?Ve(e):e,a=i?pI(i,t):[];return a.length?{bounds:Bs(a,t),type:r}:{bounds:null,type:r}}if(jr(e))return{bounds:e,type:`area`};if(fI(e)&&!Pi(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:Bs(i,t),type:`element`}},hI=e=>e===!1?0:e===!0||e==null?150:Math.max(e,0),gI=(e,t,n=`scale-down`,r)=>{let{appState:i}=di({bounds:t,appState:e,fit:n,canvasOffsets:r,steppedZoom:!1});return{scrollX:i.scrollX,scrollY:i.scrollY,zoom:i.zoom}},_I=(e,t,{fit:n,offsets:r,lock:i})=>{let a=gI(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:hI(i.overscroll),offsets:r};return{...vc({...e,...a,scrollConstraints:u}),scrollConstraints:u}},vI=({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}}},yI=e=>e===!1?null:e===!0||e==null?sI:e.duration??sI,bI=(e,t,n,r,i)=>{nP.start(aI,({deltaTime:a,state:o})=>{let s=(o?.elapsed??0)+a,c=Math.min(s/n,1),l=v(bs(c,0,1));return c<1?(r({...vI({from:e,target:t,factor:l}),shouldCacheIgnoreZoom:!0}),{elapsed:s}):(i(),null)})},xI=(e,t,n=cI)=>{let r=vc(e);if(r.scrollX===e.scrollX&&r.scrollY===e.scrollY&&r.zoom.value===e.zoom.value||nP.running(aI))return;let i=(e.scrollX-r.scrollX)*e.zoom.value,a=(e.scrollY-r.scrollY)*e.zoom.value;nP.start(oI,({deltaTime:e,state:r})=>{let o=(r?.elapsed??0)+e,s=Math.min(o/n,1),c=1-v(bs(s,0,1));return t(e=>{if(!e.scrollConstraints)return null;let t=vc(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})},SI=class{constructor(e,t){this.app=e,this.dependencies=t,B(this,`lastPosition`,{x:0,y:0}),B(this,`activeTransition`,null),B(this,`uiLastMeasured`,new Map),B(this,`invalidateUIOffset`,e=>{this.uiLastMeasured.delete(e)}),B(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}}),B(this,`getOffsets`,e=>{let t=this.dependencies.getContainer(),n=t?.getBoundingClientRect(),r=jb().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`?dI.compact:dI.full}),e.reserve.sidebar&&t(`sidebar`,{side:r?`left`:`right`,offset:uI})}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}}),B(this,`resolveInitialViewport`,(e,t,n)=>{let{bounds:r}=mI(e.target,t,n);return r?_I(n,r,{...e,offsets:this.resolveOffsets(e.offsets)}):null}),B(this,`setViewport`,e=>{if(e===null){this.cancelTransition(),nP.cancel(oI),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}=mI(t,this.app.scene.getNonDeletedElementsMap(),this.app.state);if(!o){s===`link`&&this.app.setState({toast:{message:G(`elementLink.notFound`),duration:3e3,closable:!0}});return}let c=_I(this.app.state,o,{fit:n,offsets:a,lock:r}),l=yI(i),u={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom};if(this.cancelTransition(),nP.cancel(oI),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}),bI(u,c,l,e=>{this.activeTransition===d&&this.app.setState(e)},()=>{this.activeTransition===d&&(this.activeTransition=null,this.app.setState({...d.target,shouldCacheIgnoreZoom:!1}))})}),B(this,`translate`,(e,t)=>{if(this.isLockedTransitionPending)return!1;this.cancelTransition(),t?.preserveScrollConstraintsSnapBack||nP.cancel(oI),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(),vc(e,r)}),!0}),B(this,`constrain`,(e=0)=>{this.app.setState(t=>t.scrollConstraints?vc(t,e):null)}),B(this,`releaseOverscroll`,()=>{this.app.state.scrollConstraints&&(this.snapBackDebounced.cancel(),this.snapBack())}),B(this,`snapBack`,()=>{this.app.unmounted||this.dependencies.isGestureActive()||xI(this.app.state,e=>this.app.setState(t=>e(t)))}),B(this,`snapBackDebounced`,Ss(this.snapBack,lI)),B(this,`cancelTransition`,()=>{this.activeTransition=null,nP.cancel(aI)}),B(this,`destroy`,()=>{this.cancelTransition(),nP.cancel(oI),this.snapBackDebounced.cancel()})}get isAnimating(){return nP.running(aI)||nP.running(oI)}get isLockedTransitionPending(){return!!this.activeTransition?.target.scrollConstraints}},CI=()=>(0,H.jsxs)(`div`,{"data-testid":`brave-measure-text-error`,children:[(0,H.jsx)(`p`,{children:(0,H.jsx)(aA,{i18nKey:`errors.brave_measure_text_error.line1`,bold:e=>(0,H.jsx)(`span`,{style:{fontWeight:600},children:e})})}),(0,H.jsx)(`p`,{children:(0,H.jsx)(aA,{i18nKey:`errors.brave_measure_text_error.line2`,bold:e=>(0,H.jsx)(`span`,{style:{fontWeight:600},children:e})})}),(0,H.jsx)(`p`,{children:(0,H.jsx)(aA,{i18nKey:`errors.brave_measure_text_error.line3`,link:e=>(0,H.jsx)(`a`,{href:`http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser`,children:e})})}),(0,H.jsx)(`p`,{children:(0,H.jsx)(aA,{i18nKey:`errors.brave_measure_text_error.line4`,issueLink:e=>(0,H.jsx)(`a`,{href:`https://github.com/excalidraw/excalidraw/issues/new`,children:e}),discordLink:e=>(0,H.jsxs)(`a`,{href:`https://discord.gg/UexuTaE`,children:[e,`.`]})})})]}),wI=10,TI=({children:e,left:t,top:n,onCloseRequest:r,fitInViewport:i=!1,viewportWidth:a=window.innerWidth,viewportHeight:o=window.innerHeight,className:s})=>{let c=(0,V.useRef)(null);(0,V.useEffect)(()=>{let e=c.current;if(!e)return;e.contains(document.activeElement)||e.focus();let t=t=>{if(t.key===I.TAB){let n=ha(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,V.useRef)(null);return(0,V.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-wI*2);r>=s?(e.style.width=`${s}px`,e.style.left=`${wI}px`,e.style.overflowX=`scroll`):e.style.left=`${bs(t,wI,a-wI-r)}px`;let u=Math.max(0,o-wI*2);i>=u?(e.style.height=`${u}px`,e.style.top=`${wI}px`,e.style.overflowY=`scroll`):e.style.top=`${bs(n,wI,o-wI-i)}px`}},[n,t,i,a,o]),(0,V.useEffect)(()=>{if(r){let e=e=>{c.current?.contains(e.target)||(0,qc.unstable_batchedUpdates)(()=>r(e))};return document.addEventListener(`pointerdown`,e,!1),()=>document.removeEventListener(`pointerdown`,e,!1)}},[r]),(0,H.jsx)(`div`,{className:U(`popover`,s),ref:c,tabIndex:-1,children:e})},EI=`separator`,DI=V.memo(({actionManager:e,items:t,top:n,left:r,onClose:i})=>{let a=SH(),o=xH(),s=t.reduce((t,n)=>(n&&(n===EI||!n.predicate||n.predicate(o,a,e.app.props,e.app))&&t.push(n),t),[]);return(0,H.jsx)(TI,{onCloseRequest:()=>{i()},top:n,left:r,fitInViewport:!0,viewportWidth:a.width,viewportHeight:a.height,className:`context-menu-popover`,children:(0,H.jsx)(`ul`,{className:`context-menu`,onContextMenu:e=>e.preventDefault(),children:s.map((t,n)=>{if(t===EI)return!s[n-1]||s[n-1]===EI?null:(0,H.jsx)(`hr`,{className:`context-menu-item-separator`},n);let r=t.name,c=``;return t.label&&(c=typeof t.label==`function`?G(t.label(o,a,e.app)):G(t.label)),(0,H.jsx)(`li`,{"data-testid":r,onClick:()=>{i(()=>{e.executeAction(t,`contextMenu`)})},children:(0,H.jsxs)(`button`,{type:`button`,className:U(`context-menu-item`,{dangerous:r===`deleteSelectedElements`,checkmark:t.checked?.(a)}),children:[(0,H.jsx)(`div`,{className:`context-menu-item__label`,children:c}),(0,H.jsx)(`kbd`,{className:`context-menu-item__shortcut`,children:r?mk(r):``})]})},n)})})})}),OI=({border:e,style:t})=>(0,H.jsx)(`div`,{className:`viewport-status-frame__border`,style:{borderColor:e,...t}}),kI=({label:e,border:t})=>{let n=(0,V.useId)(),r=(0,H.jsxs)(H.Fragment,{children:[e.icon&&(0,H.jsx)(`span`,{className:`viewport-status-frame__badge-icon`,children:e.icon}),e.label]});return(0,H.jsxs)(`div`,{className:U(`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,H.jsx)(`button`,{type:`button`,className:`viewport-status-frame__badge-action`,"aria-labelledby":n,onClick:e.onClick}),(0,H.jsx)(`div`,{className:`viewport-status-frame__badge-label`,id:e.onClick?n:void 0,children:r}),e.onClose&&(0,H.jsx)(`button`,{type:`button`,className:`viewport-status-frame__badge-close`,"aria-label":G(`buttons.close`),onClick:e.onClose,children:nS})]})},AI=V.createContext(null),jI=()=>V.useContext(AI),MI=Pl(),NI=()=>V.useMemo(()=>({MainMenuTunnel:mb(),WelcomeScreenMenuHintTunnel:mb(),WelcomeScreenToolbarHintTunnel:mb(),WelcomeScreenHelpHintTunnel:mb(),WelcomeScreenCenterTunnel:mb(),FooterCenterTunnel:mb(),DefaultSidebarTriggerTunnel:mb(),DefaultSidebarTabTriggersTunnel:mb(),OverwriteConfirmDialogTunnel:mb(),TTDDialogTriggerTunnel:mb(),tunnelsJotai:MI}),[]),PI=({delay:e,theme:t})=>{let[n,r]=(0,V.useState)(!!e);return(0,V.useEffect)(()=>{if(!e)return;let t=setTimeout(()=>{r(!1)},e);return()=>clearTimeout(t)},[e]),n?null:(0,H.jsxs)(`div`,{className:U(`LoadingMessage`,{"LoadingMessage--dark":t===N.DARK}),children:[(0,H.jsx)(`div`,{children:(0,H.jsx)(rw,{})}),(0,H.jsx)(`div`,{className:`LoadingMessage-text`,children:G(`labels.loadingScene`)})]})},FI=({app:e,setAppState:t})=>{let n=e.state.activeTool,[r,i]=(0,V.useState)(!1),[a,o]=(0,V.useState)(`rectangle`),[s,c]=(0,V.useState)(`arrow`);(0,V.useEffect)(()=>{(n.type===`rectangle`||n.type===`diamond`||n.type===`ellipse`)&&o(n.type)},[n.type]),(0,V.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}=jI(),h=[`rectangle`,`diamond`,`ellipse`].map(e=>({type:e,icon:_E[e].icon,title:Qa(G(`toolBar.${e}`)),fillable:_E[e].fillable})),g=[`arrow`,`line`].map(e=>({type:e,icon:_E[e].icon,title:Qa(G(`toolBar.${e}`)),fillable:_E[e].fillable})),[_,v]=(0,V.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`?ax:n.type===`image`?sx:n.type===`frame`?cC:n.type===`embeddable`?px:n.type===`laser`?mC:n.type===`bucketfill`?jx:n.type===`magicframe`?hC:Bb:Bb,w={app:e,activeTool:n};return(0,H.jsxs)(`div`,{className:`mobile-toolbar`,ref:e=>{e&&v(e.getBoundingClientRect().width)},children:[(0,H.jsx)(wE,{...w,hideKeyBinding:!0}),(0,H.jsx)(LE,{...w,setAppState:t}),(0,H.jsx)(RE,{...w}),(0,H.jsx)(NE,{...w,hideShortcut:!0}),(0,H.jsx)(gE,{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,H.jsx)(gE,{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,H.jsx)(jE,{...w,hideShortcut:!0}),b&&(0,H.jsx)(ME,{...w,hideShortcut:!0}),x&&(0,H.jsx)(PE,{...w,hideShortcut:!0}),(0,H.jsxs)(Q,{open:r,children:[(0,H.jsx)(Q.Trigger,{className:U(`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:G(`toolBar.extraTools`),style:{width:36,height:36,display:`flex`,alignItems:`center`,justifyContent:`center`},children:C}),(0,H.jsxs)(Q.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:`App-toolbar__extra-tools-dropdown`,align:`start`,children:[!y&&(0,H.jsx)(Q.Item,{onSelect:()=>e.setActiveTool({type:`text`}),icon:ax,shortcut:I.T.toLocaleUpperCase(),"data-testid":`toolbar-text`,selected:n.type===`text`,disabled:SE(e,`text`),children:G(`toolBar.text`)}),!b&&(0,H.jsx)(Q.Item,{onSelect:()=>e.setActiveTool({type:`image`}),icon:sx,"data-testid":`toolbar-image`,selected:n.type===`image`,disabled:SE(e,`image`),children:G(`toolBar.image`)}),!x&&(0,H.jsx)(Q.Item,{onSelect:()=>e.setActiveTool({type:`frame`}),icon:cC,shortcut:I.F.toLocaleUpperCase(),"data-testid":`toolbar-frame`,selected:l,disabled:SE(e,`frame`),children:G(`toolBar.frame`)}),(0,H.jsx)(Q.Item,{onSelect:()=>e.setActiveTool({type:`embeddable`}),icon:px,"data-testid":`toolbar-embeddable`,selected:f,disabled:SE(e,`embeddable`),children:G(`toolBar.embeddable`)}),(0,H.jsx)(Q.Item,{onSelect:()=>e.setActiveTool({type:`autoshape`}),icon:pC,shortcut:bE(`autoshape`),"data-testid":`toolbar-autoshape`,selected:u,disabled:SE(e,`autoshape`),children:G(`toolBar.autoshape`)}),(0,H.jsx)(Q.Item,{onSelect:()=>e.setActiveTool({type:`laser`}),icon:mC,"data-testid":`toolbar-laser`,selected:d,shortcut:I.K.toLocaleUpperCase(),disabled:SE(e,`laser`),children:G(`toolBar.laser`)}),(0,H.jsx)(Q.Item,{onSelect:()=>e.setActiveTool({type:`bucketfill`}),icon:jx,"data-testid":`toolbar-bucketfill`,selected:p,shortcut:I.B.toLocaleUpperCase(),disabled:SE(e,`bucketfill`),children:G(`toolBar.bucketfill`)}),(0,H.jsx)(`div`,{style:{margin:`6px 0`,fontSize:14,fontWeight:600},children:`Generate`}),e.props.aiEnabled!==!1&&(0,H.jsx)(m.Out,{}),(0,H.jsx)(Q.Item,{onSelect:()=>e.setOpenDialog({name:`ttd`,tab:`mermaid`}),icon:lC,"data-testid":`toolbar-embeddable`,children:G(`toolBar.mermaidToExcalidraw`)}),e.props.aiEnabled!==!1&&e.plugins.diagramToCode&&(0,H.jsx)(H.Fragment,{children:(0,H.jsx)(Q.Item,{onSelect:()=>e.onMagicframeToolSelect(),icon:hC,"data-testid":`toolbar-magicframe`,badge:(0,H.jsx)(Q.Item.Badge,{children:`AI`}),disabled:SE(e,`magicframe`),children:G(`toolBar.magicframe`)})})]})]})]})},II=({children:e,side:t,className:n})=>(0,H.jsx)(`div`,{className:U(`FixedSideContainer`,`FixedSideContainer_side_${t}`,n),children:e}),LI=e=>e.penDetected?(0,H.jsx)(Y,{className:U(`ToolIcon__penMode`,{"is-mobile":e.isMobile}),type:`toggle`,icon:rx,checked:e.checked,title:`${e.title}`,"aria-label":`${e.title}`,onSelect:()=>e.onChange?.()}):null,RI=({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}=jI(),h=()=>{if(e.openDialog?.name===`elementLinkSelector`)return null;let t=(0,H.jsxs)(`div`,{className:`excalidraw-ui-top-right`,children:[a?.(!0,e)??(!e.viewModeEnabled&&(0,H.jsxs)(H.Fragment,{children:[c&&(0,H.jsx)(LI,{checked:e.penMode,onChange:()=>d(null),title:G(`toolBar.penMode`),isMobile:!0,penDetected:e.penDetected}),(0,H.jsx)(m.Out,{})]})),c&&e.viewModeEnabled&&u.isInteractionEnabled()&&(0,H.jsx)(xj,{actionManager:n})]}),r=(0,H.jsxs)(`div`,{className:`excalidraw-ui-top-left`,children:[i?.(!0,e),(0,H.jsx)(p.Out,{})]});return(0,H.jsxs)(`div`,{className:`App-toolbar-content`,style:{display:`flex`,flexDirection:`row`,justifyContent:`space-between`},children:[r,t]})},g=()=>(0,H.jsx)(FI,{app:u,setAppState:r}),_=l&&e.scrolledOutside,v=c&&!e.viewModeEnabled,y=_&&!e.openMenu&&!e.openSidebar?(0,H.jsx)(`button`,{type:`button`,className:`scroll-back-to-content`,onClick:()=>{r(e=>({...b(t,e)}))},children:G(`buttons.scrollBackToContent`)}):null,x=u.props.viewportStatusFrame?.label,S=x?(0,H.jsx)(kI,{label:x,border:u.props.viewportStatusFrame?.border}):null;return(0,H.jsxs)(H.Fragment,{children:[o(),(0,H.jsx)(`div`,{className:`App-welcome-screen`,children:s&&(0,H.jsx)(f.Out,{})}),v&&(0,H.jsxs)(`div`,{className:`App-bottom-bar`,style:{marginBottom:bP+yP},"data-viewport-ui":`bottom`,children:[y&&(0,H.jsx)(`div`,{className:`floating-status-stack`,children:y}),(0,H.jsx)(_j,{appState:e,elementsMap:u.scene.getNonDeletedElementsMap(),renderAction:n.renderAction,app:u,setAppState:r}),(0,H.jsx)(Aw,{className:`App-toolbar`,children:e.openDialog?.name!==`elementLinkSelector`&&g()})]}),!v&&y&&(0,H.jsx)(`div`,{className:`floating-status-stack`,children:y}),S&&(0,H.jsx)(`div`,{className:`viewport-status-frame__badge-row`,children:S}),(0,H.jsx)(II,{side:`top`,className:`App-top-bar`,children:h()})]})},zI=e=>{switch(e){case`bar`:return G(`labels.chartType_bar`);case`line`:return G(`labels.chartType_line`);case`radar`:return G(`labels.chartType_radar`);default:return e}},BI=e=>{let t=(0,V.useRef)(null),[n,r]=(0,V.useState)(null),{theme:i}=bw();(0,V.useLayoutEffect)(()=>{if(!e.spreadsheet){r(null);return}let n=GF(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 O(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=zI(e.chartType);return(0,H.jsxs)(`button`,{type:`button`,className:`ChartPreview`,"aria-label":a,onClick:()=>{n&&e.onClick(e.chartType,n)},children:[(0,H.jsx)(`div`,{className:`ChartPreview__canvas`,ref:t}),(0,H.jsx)(`div`,{className:`ChartPreview__label`,children:a})]})},VI=e=>{let t=(0,V.useRef)(null),{theme:n}=bw();return(0,V.useLayoutEffect)(()=>{if(!e.rawText)return;let r=k({text:e.rawText,x:0,y:0}),i=t.current;return(async()=>{let e=await O([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,H.jsxs)(`button`,{type:`button`,className:`ChartPreview`,"aria-label":G(`labels.chartType_plaintext`),onClick:()=>{e.onClick(e.rawText)},children:[(0,H.jsx)(`div`,{className:`ChartPreview__canvas`,ref:t}),(0,H.jsx)(`div`,{className:`ChartPreview__label`,children:G(`labels.chartType_plaintext`)})]})},HI=({data:e,rawText:t,onClose:n})=>{let{onInsertElements:r,focusContainer:i}=gH(),[a,o]=(0,V.useState)(Math.random()),s=V.useCallback(()=>{o(Math.random())},[]),c=V.useCallback(()=>{n&&n()},[n]),l=(e,t)=>{r(t),hw(`paste`,`chart`,e),n(),i()};return(0,H.jsx)(nj,{size:`regular`,onCloseRequest:c,title:(0,H.jsxs)(`div`,{className:`PasteChartDialog__title`,children:[(0,H.jsx)(`div`,{className:`PasteChartDialog__titleText`,children:G(`labels.pasteCharts`)}),(0,H.jsx)(`div`,{className:`PasteChartDialog__reshuffleBtn`,onClick:s,role:`button`,tabIndex:0,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),s())},children:jx})]}),className:`PasteChartDialog`,autofocus:!1,children:(0,H.jsxs)(`div`,{className:`container`,children:[[`bar`,`line`,`radar`].map(t=>mF(e,t)?(0,H.jsx)(BI,{chartType:t,spreadsheet:e,colorSeed:a,onClick:l},t):null),t&&(0,H.jsx)(VI,{rawText:t,onClick:e=>{let t=k({text:e,x:0,y:0});r([t]),hw(`paste`,`chart`,`plaintext`),n(),i()}})]})})},UI=({heading:e,children:t,...n})=>{let{id:r}=bH(),i=(0,H.jsx)(`h2`,{className:`visually-hidden`,id:`${r}-${e}-title`,children:G(`headings.${e}`)});return(0,H.jsx)(`section`,{...n,"aria-labelledby":`${r}-${e}-title`,children:typeof t==`function`?t(i):(0,H.jsxs)(H.Fragment,{children:[i,t]})})},WI=4,GI=8,KI=38,qI=21,JI=({shouldWrap:e,children:t,username:n})=>e?(0,H.jsx)(aE,{label:n||`Unknown user`,children:t}):(0,H.jsx)(H.Fragment,{children:t}),YI=({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,H.jsx)(JI,{username:t.username,shouldWrap:i,children:s},n)},XI=[`avatarUrl`,`id`,`socketId`,`username`,`isInCall`,`isSpeaking`,`isMuted`,`isCurrentUser`],ZI=V.memo(({className:e,mobile:t,collaborators:n,userToFollow:r,currentUserControls:i})=>{let a=wH(),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]=V.useState(``),f=s.filter(e=>e.username?.toLowerCase().includes(u)),p=V.useRef(null);(0,V.useLayoutEffect)(()=>{if(p.current){let e=e=>{h(e)};if(e(p.current.clientWidth),!Ia)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]=V.useState(WI*KI),g=c?m-qI:m,_=Math.max(1,Math.min(8,Math.floor(g/KI))),v=c?Math.max(0,_-1):_,y=l.slice(0,v),b=c?[...y,c]:y,x=b.map(e=>{let t=YI({actionManager:a,collaborator:e,socketId:e.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:e.socketId===r});return e.isCurrentUser?(0,H.jsxs)(ty,{children:[(0,H.jsx)(ny,{asChild:!0,children:(0,H.jsxs)(`div`,{className:`UserList__pill`,children:[t,(0,H.jsx)(`div`,{className:`UserList__pill-chevron`,children:ew})]})}),(0,H.jsx)(iy,{className:`focus-visible-none`,style:{zIndex:2,width:`15rem`,textAlign:`left`},align:`end`,sideOffset:10,children:(0,H.jsxs)(Aw,{padding:2,children:[s.length>=GI&&(0,H.jsx)(fT,{placeholder:G(`quickSearch.placeholder`),onChange:d}),(0,H.jsx)(pT,{className:`dropdown-menu UserList__collaborators`,placeholder:G(`userList.empty`),children:f.length>0?[(0,H.jsx)(`div`,{className:`hint`,children:G(`userList.hint.text`)},`hint`),f.map(e=>YI({actionManager:a,collaborator:e,socketId:e.socketId,withName:!0,isBeingFollowed:e.socketId===r}))]:[]}),o&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`UserList__menu-divider`}),(0,H.jsx)(ay,{asChild:!0,children:(0,H.jsx)(`div`,{className:`dropdown-menu`,children:o})})]}),(0,H.jsx)(oy,{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,H.jsxs)(`div`,{className:U(`UserList UserList_mobile`,e),children:[(0,H.jsx)(`div`,{className:`UserList_mobile__avatars`,children:s.map(e=>YI({actionManager:a,collaborator:e,socketId:e.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:e.socketId===r}))}),o&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`UserList__menu-divider`}),o]})]}):(0,H.jsx)(`div`,{className:`UserList__wrapper`,ref:p,children:(0,H.jsx)(`div`,{className:U(`UserList`,e),style:{"--max-avatars":b.length+(c?qI/KI: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||!Jn(i,e,XI))return!1}return!0}),QI=e=>(0,H.jsx)(aE,{label:`${G(`helpDialog.title`)} \u2014 ?`,children:(0,H.jsx)(`button`,{className:`help-icon`,onClick:e.onClick,type:`button`,"aria-label":G(`helpDialog.title`),children:yx})}),$I=({appState:e,actionManager:t,showExitZenModeBtn:n,renderWelcomeScreen:r,defaultUIEnabled:i,zoomUIEnabled:a})=>{let{FooterCenterTunnel:o,WelcomeScreenHelpHintTunnel:s}=jI(),c=gH();return(0,H.jsxs)(`footer`,{role:`contentinfo`,className:`layer-ui__wrapper__footer App-menu App-menu_bottom`,children:[(i||a&&c.isNavigationEnabled())&&(0,H.jsx)(`div`,{className:U(`layer-ui__wrapper__footer-left zen-mode-transition`,{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:(0,H.jsx)(lA.Col,{gap:2,children:(0,H.jsxs)(UI,{heading:`canvasActions`,children:[a&&c.isNavigationEnabled()&&(0,H.jsx)(vj,{renderAction:t.renderAction}),i&&!e.viewModeEnabled&&(0,H.jsx)(yj,{renderAction:t.renderAction,className:U(`zen-mode-transition`,{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})})]})})}),(0,H.jsx)(o.Out,{}),(i||r)&&(0,H.jsx)(`div`,{className:U(`layer-ui__wrapper__footer-right zen-mode-transition`,{"transition-right":e.zenModeEnabled}),children:(0,H.jsxs)(`div`,{style:{position:`relative`},children:[r&&(0,H.jsx)(s.Out,{}),i&&(0,H.jsx)(QI,{onClick:()=>t.executeAction(MD)})]})}),i&&(0,H.jsx)(bj,{actionManager:t,showExitZenModeBtn:n})]})},eL=$I;$I.displayName=`Footer`;var tL=V.createContext({}),nL=({children:e,className:t})=>{let n=vH(),r=(0,V.useContext)(tL),i=!!(n.canFitSidebar&&r.shouldRenderDockButton);return(0,H.jsxs)(`div`,{className:U(`sidebar__header`,t),"data-testid":`sidebar-header`,children:[e,(0,H.jsxs)(`div`,{className:`sidebar__header__buttons`,children:[i&&(0,H.jsx)(aE,{label:G(`labels.sidebarLock`),children:(0,H.jsx)(UA,{onSelect:()=>r.onDock?.(!r.docked),selected:!!r.docked,className:`sidebar__dock`,"data-testid":`sidebar-dock`,"aria-label":G(`labels.sidebarLock`),children:Hb})}),(0,H.jsx)(UA,{"data-testid":`sidebar-close`,className:`sidebar__close`,onSelect:r.onCloseRequest,"aria-label":G(`buttons.close`),children:nS})]})]})};nL.displayName=`SidebarHeader`;var rL=({children:e,tab:t,onSelect:n,...r})=>(0,H.jsx)(wy,{value:t,asChild:!0,onSelect:n,children:(0,H.jsx)(`button`,{type:`button`,className:`excalidraw-button sidebar-tab-trigger`,...r,children:e})});rL.displayName=`SidebarTabTrigger`;var iL=({children:e,...t})=>(0,H.jsx)(Cy,{className:`sidebar-triggers`,...t,children:e});iL.displayName=`SidebarTabTriggers`;var aL=({name:e,tab:t,icon:n,title:r,children:i,onToggle:a,className:o,style:s})=>{let c=CH(),l=bw().openSidebar?.name===e;return(0,H.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,H.jsxs)(`div`,{className:U(`sidebar-trigger`,o),style:s,children:[n&&(0,H.jsx)(`div`,{children:n}),i&&(0,H.jsx)(`div`,{className:`sidebar-trigger__label`,children:i})]})})};aL.displayName=`SidebarTrigger`;var oL=({children:e,...t})=>{let n=bw(),r=CH();if(!n.openSidebar)return null;let{name:i}=n.openSidebar;return(0,H.jsx)(Sy,{className:`sidebar-tabs-root`,value:n.openSidebar.tab,onValueChange:e=>r(t=>({...t,openSidebar:{...t.openSidebar,name:i,tab:e}})),...t,children:e})};oL.displayName=`SidebarTabs`;var sL=({tab:e,children:t,...n})=>(0,H.jsx)(Ty,{...n,value:e,"data-testid":e,children:t});sL.displayName=`SidebarTab`;var cL=Yc(!1),lL=(0,V.forwardRef)(({name:e,children:t,onDock:n,docked:r,className:i,...a},o)=>{ht()&&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=CH(),c=vb(cL);(0,V.useLayoutEffect)(()=>(c(!!r),()=>{c(!1)}),[c,r]);let l=(0,V.useRef)({});l.current.onCloseRequest=()=>{s({openSidebar:null})},l.current.onDock=e=>n?.(e),l.current=He(l.current,{docked:r,shouldRenderDockButton:!!n&&r!=null});let u=(0,V.useRef)(null);(0,V.useImperativeHandle)(o,()=>u.current);let d=vH(),f=(0,V.useCallback)(()=>{document.querySelector(`.Dialog`)||s({openSidebar:null})},[s]);return Sw(u,(0,V.useCallback)(e=>{e.target.closest(`.sidebar-trigger`)||(!r||!d.canFitSidebar)&&f()},[f,r,d.canFitSidebar])),(0,V.useEffect)(()=>{let e=e=>{e.key===I.ESCAPE&&(!r||!d.canFitSidebar)&&f()};return document.addEventListener(R.KEYDOWN,e),()=>{document.removeEventListener(R.KEYDOWN,e)}},[f,r,d.canFitSidebar]),(0,H.jsx)(Aw,{...a,className:U(Os.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,H.jsx)(tL.Provider,{value:l.current,children:t})})});lL.displayName=`SidebarInner`;var uL=Object.assign((0,V.forwardRef)((e,t)=>{let n=bw(),{onStateChange:r}=e,i=(0,V.useRef)(n.openSidebar);(0,V.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,V.useState)(!1);return(0,V.useLayoutEffect)(()=>(o(!0),()=>o(!1)),[]),a&&n.openSidebar?.name===e.name?(0,V.createElement)(lL,{...e,ref:t,key:e.name}):null}),{Header:nL,TabTriggers:iL,TabTrigger:rL,Tabs:oL,Tab:sL,Trigger:aL});uL.displayName=`Sidebar`;var dL=(e,t)=>{let n=Yc(0),r=e=>{let{tunnelsJotai:{useAtom:r}}=jI(),[,i]=r(n),a=(0,V.useRef)({preferHost:!1,counter:0});return(0,V.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,H.jsx)(t,{...e})};return r.displayName=e,r},fL={};Ic(fL,{ChangeCanvasBackground:()=>EL,ClearCanvas:()=>wL,CommandPalette:()=>xL,Export:()=>DL,Help:()=>CL,LiveCollaborationTrigger:()=>kL,LoadScene:()=>vL,Preferences:()=>zL,PreferencesToggleGridModeItem:()=>FL,PreferencesToggleZenModeItem:()=>IL,SaveAsImage:()=>bL,SaveToActiveFile:()=>yL,SearchMenu:()=>SL,Socials:()=>OL,ToggleTheme:()=>TL});var pL=Yc({active:!1});async function mL({title:e,description:t,actionLabel:n,color:r}){return new Promise(i=>{Sb.set(pL,{active:!0,onConfirm:()=>i(!0),onClose:()=>i(!1),onReject:()=>i(!1),title:e,description:t,actionLabel:n,color:r})})}var hL=function({onChange:e,value:t,choices:n,name:r}){return(0,H.jsx)(`div`,{className:`RadioGroup`,children:n.map(n=>(0,H.jsxs)(`div`,{className:U(`RadioGroup__choice`,{active:n.value===t}),title:n.ariaLabel,children:[(0,H.jsx)(`input`,{name:r,type:`radio`,checked:n.value===t,onChange:()=>e(n.value),"aria-label":n.ariaLabel}),n.label]},String(n.value)))})},gL=({value:e,shortcut:t,onChange:n,choices:r,children:i,name:a,icon:o})=>{let s=vH();return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`dropdown-menu-item-base dropdown-menu-item-bare`,children:[o&&(0,H.jsx)(`div`,{className:`dropdown-menu-item__icon`,children:o}),(0,H.jsx)(`label`,{className:`dropdown-menu-item__text`,children:(0,H.jsx)(yT,{children:i})}),(0,H.jsx)(hL,{name:a,value:e,onChange:n,choices:r})]}),t&&s.formFactor!==`phone`&&(0,H.jsx)(`div`,{className:`dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned`,children:t})]})};gL.displayName=`DropdownMenuItemContentRadio`;var _L=gL,vL=()=>{let{t:e}=Pb(),t=wH(),n=xH();return t.isActionEnabled(DD)?(0,H.jsx)(wT,{icon:kx,onSelect:async()=>{(!n.length||await mL({title:e(`overwriteConfirm.modal.loadFromFile.title`),actionLabel:e(`overwriteConfirm.modal.loadFromFile.button`),color:`warning`,description:(0,H.jsx)(aA,{i18nKey:`overwriteConfirm.modal.loadFromFile.description`,bold:e=>(0,H.jsx)(`strong`,{children:e}),br:()=>(0,H.jsx)(`br`,{})})}))&&t.executeAction(DD)},"data-testid":`load-button`,shortcut:mk(`loadScene`),"aria-label":e(`buttons.load`),children:e(`buttons.load`)}):null};vL.displayName=`LoadScene`;var yL=()=>{let{t:e}=Pb(),t=wH();return t.isActionEnabled(TD)?(0,H.jsx)(wT,{shortcut:mk(`saveScene`),"data-testid":`save-button`,onSelect:()=>t.executeAction(TD),icon:Dx,"aria-label":`${e(`buttons.save`)}`,children:`${e(`buttons.save`)}`}):null};yL.displayName=`SaveToActiveFile`;var bL=()=>{let e=CH(),{t}=Pb();return(0,H.jsx)(wT,{icon:Nx,"data-testid":`image-export-button`,onSelect:()=>e({openDialog:{name:`imageExport`}}),shortcut:mk(`imageExport`),"aria-label":t(`buttons.exportImage`),children:t(`buttons.exportImage`)})};bL.displayName=`SaveAsImage`;var xL=e=>{let t=CH(),{t:n}=Pb();return(0,H.jsx)(wT,{icon:EC,"data-testid":`command-palette-button`,onSelect:()=>{hw(`command_palette`,`open`,`menu`),t({openDialog:{name:`commandPalette`}})},shortcut:mk(`commandPalette`),"aria-label":n(`commandPalette.title`),className:e?.className,children:n(`commandPalette.title`)})};xL.displayName=`CommandPalette`;var SL=e=>{let{t}=Pb(),n=wH();return(0,H.jsx)(wT,{icon:xC,"data-testid":`search-menu-button`,onSelect:()=>{n.executeAction(aN)},shortcut:mk(`searchMenu`),"aria-label":t(`search.title`),className:e?.className,children:t(`search.title`)})};SL.displayName=`SearchMenu`;var CL=()=>{let{t:e}=Pb(),t=wH();return(0,H.jsx)(wT,{"data-testid":`help-menu-item`,icon:yx,onSelect:()=>t.executeAction(MD),shortcut:`?`,"aria-label":e(`helpDialog.title`),children:e(`helpDialog.title`)})};CL.displayName=`Help`;var wL=()=>{let{t:e}=Pb(),t=vb(Cj);return wH().isActionEnabled(uE)?(0,H.jsx)(wT,{icon:fx,onSelect:()=>t(`clearCanvas`),"data-testid":`clear-canvas-button`,"aria-label":e(`buttons.clearReset`),children:e(`buttons.clearReset`)}):null};wL.displayName=`ClearCanvas`;var TL=e=>{let{t}=Pb(),n=bw(),r=wH(),i=mk(`toggleTheme`),a=_H();return r.isActionEnabled(hE)?e?.allowSystemTheme?(0,H.jsx)(_L,{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:N.LIGHT,label:gx,ariaLabel:`${t(`buttons.lightMode`)} - ${i}`},{value:N.DARK,label:hx,ariaLabel:`${t(`buttons.darkMode`)} - ${i}`},{value:`system`,label:LC,ariaLabel:t(`buttons.systemMode`)}],children:t(`labels.theme`)}):(0,H.jsx)(wT,{onSelect:e=>{e.preventDefault(),r.executeAction(hE)},icon:n.theme===N.DARK?gx:hx,"data-testid":`toggle-dark-mode`,shortcut:i,"aria-label":n.theme===N.DARK?t(`buttons.lightMode`):t(`buttons.darkMode`),children:n.theme===N.DARK?t(`buttons.lightMode`):t(`buttons.darkMode`)}):null};TL.displayName=`ToggleTheme`;var EL=()=>{let{t:e}=Pb(),t=bw(),n=wH(),r=_H();return t.viewModeEnabled||!r.UIOptions.canvasActions.changeViewBackgroundColor?null:(0,H.jsxs)(`div`,{style:{marginTop:`0.75rem`},children:[(0,H.jsx)(`div`,{"data-testid":`canvas-background-label`,style:{fontSize:`0.875rem`,marginBottom:`0.25rem`,marginLeft:`0.5rem`},children:e(`labels.canvasBackground`)}),(0,H.jsx)(`div`,{style:{padding:`0 0.625rem`},children:n.renderAction(`changeViewBackgroundColor`)})]})};EL.displayName=`ChangeCanvasBackground`;var DL=()=>{let{t:e}=Pb(),t=CH();return(0,H.jsx)(wT,{icon:vx,onSelect:()=>{t({openDialog:{name:`jsonExport`}})},"data-testid":`json-export-button`,"aria-label":e(`buttons.export`),children:e(`buttons.export`)})};DL.displayName=`Export`;var OL=()=>{let{t:e}=Pb();return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(mA,{icon:Sx,href:`https://github.com/excalidraw/excalidraw`,"aria-label":`GitHub`,children:`GitHub`}),(0,H.jsx)(mA,{icon:wx,href:`https://x.com/excalidraw`,"aria-label":`X`,children:e(`labels.followUs`)}),(0,H.jsx)(mA,{icon:Cx,href:`https://discord.gg/UexuTaE`,"aria-label":`Discord`,children:e(`labels.discordChat`)})]})};OL.displayName=`Socials`;var kL=({onSelect:e,isCollaborating:t})=>{let{t:n}=Pb();return(0,H.jsx)(wT,{"data-testid":`collab-button`,icon:eS,className:U({"active-collab":t}),onSelect:e,children:n(`labels.liveCollaboration`)})};kL.displayName=`LiveCollaborationTrigger`;var AL=()=>{let{t:e}=Pb(),t=gH(),n=bw();return(0,H.jsx)(MA,{checked:n.activeTool.locked,shortcut:mk(`toolLock`),onSelect:e=>{t.toggleLock(),e.preventDefault()},children:e(`labels.preferences_toolLock`)})},jL=()=>{let{t:e}=Pb(),t=bw(),n=CH();return(0,H.jsx)(_L,{name:`boxSelectionMode`,icon:$C,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`)})},ML=()=>{let{t:e}=Pb(),t=wH(),n=bw();return(0,H.jsx)(MA,{checked:n.objectsSnapModeEnabled,shortcut:mk(`objectsSnapMode`),onSelect:e=>{t.executeAction(oO),e.preventDefault()},children:e(`buttons.objectsSnapMode`)})},NL=()=>{let{t:e}=Pb(),t=wH(),n=bw();return(0,H.jsx)(MA,{checked:n.bindingPreference===`enabled`,onSelect:e=>{t.executeAction(sO),e.preventDefault()},children:e(`labels.arrowBinding`)})},PL=()=>{let{t:e}=Pb(),t=wH(),n=bw();return(0,H.jsx)(MA,{checked:n.isMidpointSnappingEnabled,onSelect:e=>{t.executeAction(cO),e.preventDefault()},children:e(`labels.midpointSnapping`)})},FL=()=>{let{t:e}=Pb(),t=wH(),n=bw();return(0,H.jsx)(MA,{checked:n.gridModeEnabled,shortcut:mk(`gridMode`),onSelect:e=>{t.executeAction(iO),e.preventDefault()},children:e(`labels.toggleGrid`)})},IL=()=>{let{t:e}=Pb(),t=wH(),n=bw();return(0,H.jsx)(MA,{checked:n.zenModeEnabled,shortcut:mk(`zenMode`),onSelect:e=>{t.executeAction(aO),e.preventDefault()},children:e(`buttons.zenMode`)})},LL=()=>{let{t:e}=Pb(),t=wH(),n=bw();return t.isActionEnabled(rj)?(0,H.jsx)(MA,{checked:n.viewModeEnabled,shortcut:mk(`viewMode`),onSelect:e=>{t.executeAction(rj),e.preventDefault()},children:e(`labels.viewMode`)}):null},RL=()=>{let{t:e}=Pb(),t=wH(),n=bw();return(0,H.jsx)(MA,{checked:n.stats.open,shortcut:mk(`stats`),onSelect:e=>{t.executeAction(lO),e.preventDefault()},children:e(`stats.fullTitle`)})},zL=({children:e,additionalItems:t})=>{let{t:n}=Pb();return(0,H.jsxs)(kA,{children:[(0,H.jsx)(kA.Trigger,{icon:nw,children:n(`labels.preferences`)}),(0,H.jsxs)(kA.Content,{className:`excalidraw-main-menu-preferences-submenu`,children:[e||(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(jL,{}),(0,H.jsx)(AL,{}),(0,H.jsx)(ML,{}),(0,H.jsx)(FL,{}),(0,H.jsx)(IL,{}),(0,H.jsx)(LL,{}),(0,H.jsx)(RL,{}),(0,H.jsx)(NL,{}),(0,H.jsx)(PL,{})]}),t]})]})};zL.ToggleToolLock=AL,zL.BoxSelectionMode=jL,zL.ToggleSnapMode=ML,zL.ToggleArrowBinding=NL,zL.ToggleMidpointSnapping=PL,zL.ToggleGridMode=FL,zL.ToggleZenMode=IL,zL.ToggleViewMode=LL,zL.ToggleElementProperties=RL,zL.displayName=`Preferences`;var BL=Object.assign(dL(`MainMenu`,({children:e,onSelect:t})=>{let{MainMenuTunnel:n}=jI(),r=vH(),i=bw(),a=_H(),o=CH();return(0,H.jsx)(n.In,{children:(0,H.jsxs)(Q,{open:i.openMenu===`canvas`,children:[(0,H.jsx)(Q.Trigger,{onToggle:()=>{o({openMenu:i.openMenu===`canvas`?null:`canvas`,openPopup:null,openDialog:null})},"data-testid":`main-menu-trigger`,className:`main-menu-trigger`,children:_x}),(0,H.jsxs)(Q.Content,{onClickOutside:()=>o({openMenu:null}),onSelect:jo(t,()=>{o({openMenu:null})}),className:`main-menu`,align:`start`,children:[e,r.formFactor===`phone`&&i.collaborators.size>0&&(0,H.jsxs)(`fieldset`,{className:`UserList-Wrapper`,children:[(0,H.jsx)(`legend`,{children:G(`labels.collaborators`)}),(0,H.jsx)(ZI,{mobile:!0,collaborators:i.collaborators,userToFollow:a.userToFollow?.socketId||null,currentUserControls:a.currentUserControls})]})]})]})})}),{Trigger:Q.Trigger,Item:Q.Item,ItemLink:Q.ItemLink,ItemCustom:Q.ItemCustom,Group:Q.Group,Separator:Q.Separator,Sub:kA,DefaultItems:fL}),VL=(0,V.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,V.useState)(!1),m=async e=>{let t=n?.(e);if(Yt(t)){let e=window.setTimeout(()=>{p(!0)},50);try{await t}catch(e){if(e instanceof gs)console.warn(e);else throw e}finally{clearTimeout(e),p(!1)}}},h=f?`loading`:l;return a=h===`success`?`success`:a,(0,H.jsx)(`button`,{className:U(`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,H.jsxs)(`div`,{className:`ExcButton__contents`,children:[h===`loading`?(0,H.jsx)(rw,{className:`ExcButton__statusIcon`}):h===`success`&&(0,H.jsx)(`div`,{className:`ExcButton__statusIcon`,children:iC}),t&&(0,H.jsx)(`div`,{className:`ExcButton__icon`,"aria-hidden":!0,children:t}),i!==`icon`&&(e??r)]})})}),HL=({title:e,children:t,actionLabel:n,onClick:r})=>(0,H.jsxs)(`div`,{className:`OverwriteConfirm__Actions__Action`,children:[(0,H.jsx)(`h4`,{children:e}),(0,H.jsx)(`div`,{className:`OverwriteConfirm__Actions__Action__content`,children:t}),(0,H.jsx)(VL,{variant:`outlined`,color:`muted`,label:n,size:`large`,fullWidth:!0,onClick:r})]}),UL=Object.assign(({children:e})=>(0,H.jsx)(`div`,{className:`OverwriteConfirm__Actions`,children:e}),{ExportToImage:()=>{let{t:e}=Pb(),t=wH(),n=CH();return(0,H.jsx)(HL,{title:e(`overwriteConfirm.action.exportToImage.title`),actionLabel:e(`overwriteConfirm.action.exportToImage.button`),onClick:()=>{t.executeAction(bD,`ui`,!0),n({openDialog:{name:`imageExport`}})},children:e(`overwriteConfirm.action.exportToImage.description`)})},SaveToDisk:()=>{let{t:e}=Pb(),t=wH();return(0,H.jsx)(HL,{title:e(`overwriteConfirm.action.saveToDisk.title`),actionLabel:e(`overwriteConfirm.action.saveToDisk.button`),onClick:()=>{t.executeAction(ED,`ui`)},children:e(`overwriteConfirm.action.saveToDisk.description`)})}}),WL=Object.assign(dL(`OverwriteConfirmDialog`,({children:e})=>{let{OverwriteConfirmDialogTunnel:t}=jI(),[n,r]=_b(pL);return n.active?(0,H.jsx)(t.In,{children:(0,H.jsx)(nj,{onCloseRequest:()=>{n.onClose(),r(e=>({...e,active:!1}))},title:!1,size:916,children:(0,H.jsxs)(`div`,{className:`OverwriteConfirm`,children:[(0,H.jsx)(`h3`,{children:n.title}),(0,H.jsxs)(`div`,{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${n.color}`,children:[(0,H.jsx)(`div`,{className:`OverwriteConfirm__Description__icon`,children:aC}),(0,H.jsx)(`div`,{children:n.description}),(0,H.jsx)(`div`,{className:`OverwriteConfirm__Description__spacer`}),(0,H.jsx)(VL,{color:n.color,size:`large`,label:n.actionLabel,onClick:()=>{n.onConfirm(),r(e=>({...e,active:!1}))}})]}),(0,H.jsx)(UL,{children:e})]})})}):null}),{Actions:UL,Action:HL}),GL=Yc(``),KL=Yc(null),qL=350,JL=()=>{let e=gH(),t=CH(),n=(0,V.useRef)(null),[r,i]=_b(GL),a=r.trim(),[o,s]=(0,V.useState)(!1),[c,l]=(0,V.useState)({nonce:null,items:[]}),u=(0,V.useRef)(null),d=(0,V.useRef)(void 0),[f,p]=_b(KL),m=e.scene.getNonDeletedElementsMap();(0,V.useEffect)(()=>{o||(a!==u.current||e.scene.getSceneNonce()!==d.current)&&(u.current=null,nR(a,e,(n,r)=>{l({nonce:Ba(),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,V.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,V.useEffect)(()=>{if(c.items.length>0&&f!==null){let t=c.items[f];if(t){let n=e.state.zoom.value,r=k({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)?li.nameFontSize:t.element.fontSize,fontFamily:P(t.element)?Zo.Assistant:t.element.fontFamily}),i=r.fontSize,a=i*n<14;if(!Xr([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:Bs([r]),fit:t,animation:{duration:300},offsets:{ui:!0}})}}}},[f,c,e]),(0,V.useEffect)(()=>()=>{p(null),u.current=null,d.current=void 0,t({searchMatches:null}),s(!1)},[t,p]);let _=Cw({goToNextItem:h,goToPreviousItem:g,searchMatches:c});(0,V.useEffect)(()=>Vs(window,R.KEYDOWN,r=>{if(r.key===I.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){r.preventDefault(),r.stopPropagation(),t({openSidebar:null});return}if(r[I.CTRL_OR_CMD]&&r.key===I.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===I.ENTER&&(r.stopPropagation(),_.goToNextItem()),r.key===I.ARROW_UP?(r.stopPropagation(),_.goToPreviousItem()):r.key===I.ARROW_DOWN&&(r.stopPropagation(),_.goToNextItem()))},{capture:!0,passive:!1}),[t,_,e]);let v=`${c.items.length} ${c.items.length===1?G(`search.singleResult`):G(`search.multipleResults`)}`;return(0,H.jsxs)(`div`,{className:`layer-ui__search`,children:[(0,H.jsx)(`div`,{className:`layer-ui__search-header`,children:(0,H.jsx)(WA,{className:Os.SEARCH_MENU_INPUT_WRAPPER,value:r,ref:n,placeholder:G(`search.placeholder`),icon:xC,onChange:n=>{i(n),s(!0);let r=n.trim();nR(r,e,(n,i)=>{l({nonce:Ba(),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,H.jsxs)(`div`,{className:`layer-ui__search-count`,children:[c.items.length>0&&(0,H.jsxs)(H.Fragment,{children:[f!==null&&f>-1?(0,H.jsxs)(`div`,{children:[f+1,` / `,v]}):(0,H.jsx)(`div`,{children:v}),(0,H.jsxs)(`div`,{className:`result-nav`,children:[(0,H.jsx)(UA,{onSelect:()=>{h()},className:`result-nav-btn`,children:WC}),(0,H.jsx)(UA,{onSelect:()=>{g()},className:`result-nav-btn`,children:KC})]})]}),c.items.length===0&&a&&u.current&&(0,H.jsx)(`div`,{style:{margin:`1rem auto`},children:G(`search.noMatch`)})]}),(0,H.jsx)(XL,{matches:c,onItemClick:p,focusIndex:f,searchQuery:a})]})},YL=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,H.jsx)(`div`,{tabIndex:-1,className:U(`layer-ui__result-item`,{active:e.highlighted}),onClick:e.onClick,ref:t=>{e.highlighted&&t?.scrollIntoView({behavior:`auto`,block:`nearest`})},children:(0,H.jsx)(`div`,{className:`preview-text`,children:t.flatMap((e,t)=>(0,H.jsx)(V.Fragment,{children:t===2?(0,H.jsx)(`b`,{children:e}):e},t))})})},XL=(0,V.memo)(e=>{let t=(0,V.useMemo)(()=>e.matches.items.filter(e=>P(e.element)),[e.matches]),n=(0,V.useMemo)(()=>e.matches.items.filter(e=>F(e.element)),[e.matches]);return(0,H.jsxs)(`div`,{children:[t.length>0&&(0,H.jsxs)(`div`,{className:`layer-ui__search-result-container`,children:[(0,H.jsxs)(`div`,{className:`layer-ui__search-result-title`,children:[(0,H.jsx)(`div`,{className:`title-icon`,children:cC}),(0,H.jsx)(`div`,{children:G(`search.frames`)})]}),t.map((t,n)=>(0,H.jsx)(YL,{searchQuery:e.searchQuery,preview:t.preview,highlighted:n===e.focusIndex,onClick:()=>e.onItemClick(n)},t.element.id+t.index)),n.length>0&&(0,H.jsx)(`div`,{className:`layer-ui__divider`})]}),n.length>0&&(0,H.jsxs)(`div`,{className:`layer-ui__search-result-container`,children:[(0,H.jsxs)(`div`,{className:`layer-ui__search-result-title`,children:[(0,H.jsx)(`div`,{className:`title-icon`,children:ax}),(0,H.jsx)(`div`,{children:G(`search.texts`)})]}),n.map((n,r)=>(0,H.jsx)(YL,{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),ZL=(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}},QL=(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
- `)},$L=(e,t,n)=>{let r=QL(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=xa(r,se(e),e.lineHeight);if(r===``&&(a.width=0),e.textAlign!==`left`&&t.line.length>0){let n=xa(t.line,se(e),e.lineHeight),r=e.textAlign===`center`?(e.width-n.width)/2:e.width-n.width;a.width+=r}let{width:o,height:u}=xa(i,se(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},eR=(e,t,n,r)=>{let i=e.name??Cs(e),a=i.slice(n,n+t.length),o=i.slice(0,n),s=se({fontSize:li.nameFontSize,fontFamily:Zo.Assistant}),c=sa(Zo.Assistant),l=xa(o,s,c);o===``&&(l.width=0);let u=xa(a,s,c),d=l.width,f=-l.height-li.strokeWidth,p=u.width;return[{offsetX:d,offsetY:f,width:p,height:u.height,showOnCanvas:d+p<=e.width*r}]},tR=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,`\\$&`),nR=(0,hb.default)((e,t,n)=>{if(!e||e===``){n([],null);return}let r=t.scene.getNonDeletedElements(),i=r.filter(e=>F(e)),a=r.filter(e=>P(e));i.sort((e,t)=>e.y-t.y),a.sort((e,t)=>e.y-t.y);let o=[],s=new RegExp(tR(e),`gi`);for(let t of i){let n=null,r=t.originalText;for(;(n=s.exec(r))!==null;){let i=ZL(r,n.index,e),a=$L(t,e,n.index);a.length>0&&o.push({element:t,searchQuery:e,preview:i,index:n.index,matchedLines:a})}}let c=[];for(let n of a){let r=null,i=n.name??Cs(n);for(;(r=s.exec(i))!==null;){let a=ZL(i,r.index,e),o=eR(n,e,r.index,t.state.zoom.value);o.length>0&&c.push({element:n,searchQuery:e,preview:a,index:r.index,matchedLines:o})}}let l=new Set(t.visibleElements.map(e=>e.id)),u=[...c,...o];n(u,u.findIndex(e=>l.has(e.element.id))??null)},qL),rR=dL(`DefaultSidebarTrigger`,e=>{let{DefaultSidebarTriggerTunnel:t}=jI();return(0,H.jsx)(t.In,{children:(0,H.jsx)(uL.Trigger,{...e,className:`default-sidebar-trigger`,name:lr.name})})});rR.displayName=`DefaultSidebarTrigger`;var iR=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:t}=jI();return(0,H.jsx)(t.In,{children:e})};iR.displayName=`DefaultTabTriggers`;var aR=Object.assign(dL(`DefaultSidebar`,({children:e,className:t,onDock:n,docked:r,...i})=>{let a=bw(),o=CH(),{DefaultSidebarTabTriggersTunnel:s}=jI(),c=a.openSidebar?.tab===_a;return(0,V.createElement)(uL,{...i,name:`default`,key:`default`,className:U(`default-sidebar`,t),docked:c||(r??a.defaultSidebarDockedPreference),onDock:c||n===!1||!n&&r!=null?void 0:jo(n,e=>{o({defaultSidebarDockedPreference:e})})},(0,H.jsxs)(uL.Tabs,{children:[(0,H.jsx)(uL.Header,{children:(0,H.jsxs)(uL.TabTriggers,{children:[(0,H.jsx)(uL.TabTrigger,{tab:_a,children:xC}),(0,H.jsx)(uL.TabTrigger,{tab:wa,children:Rb}),(0,H.jsx)(s.Out,{})]})}),(0,H.jsx)(uL.Tab,{tab:wa,children:(0,H.jsx)($A,{})}),(0,H.jsx)(uL.Tab,{tab:_a,children:(0,H.jsx)(JL,{})}),e]}))}),{Trigger:rR,TabTriggers:iR}),oR=300,sR=({input:e,placeholder:t,onChange:r,onKeyboardSubmit:i,errorLine:a})=>{let o=(0,V.useRef)(null),s=(0,V.useRef)(i);s.current=i;let[c,l]=(0,V.useState)({type:`loading`}),[u,d]=(0,V.useState)(!1),{theme:f}=bw();if((0,V.useEffect)(()=>{let e=!1,t=setTimeout(()=>{e||d(!0)},oR);return n(()=>import(`./CodeMirrorEditor-UCMRAMCV-BPH4FJkv.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,V.useEffect)(()=>{if(c.type!==`fallback`||!s.current)return;let e=o.current;if(e){let t=e=>{e[I.CTRL_OR_CMD]&&e.key===I.ENTER&&(e.preventDefault(),s.current?.())};return e.focus(),e.addEventListener(R.KEYDOWN,t),()=>{e.removeEventListener(R.KEYDOWN,t)}}},[c.type]),c.type===`ready`){let n=c.component;return(0,H.jsx)(n,{value:e,onChange:r,onKeyboardSubmit:i,placeholder:t,theme:f,errorLine:a})}return c.type===`fallback`?(0,H.jsx)(`textarea`,{className:`ttd-dialog-input`,onChange:e=>r(e.target.value),value:e,placeholder:t,ref:o}):u?(0,H.jsx)(`div`,{className:`ttd-dialog-input ttd-dialog-input--loading`,children:(0,H.jsx)(rw,{})}):null},cR=/(?:Parse|Lexical) error on line (\d+)[.:]/i,lR=/Trying to inactivate an inactive participant \((.+)\)/i,uR=/^\s*-+\^\s*$/,dR=e=>cR.test(e),fR=e=>dR(e)||lR.test(e),pR=e=>uR.test(e),mR=e=>{let t=e.match(lR);return t?.[1]?t[1].trim():null},hR=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),gR=(e,t)=>{let n=mR(e);if(!n)return null;let r=RegExp(`^\\s*deactivate\\s+${hR(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},_R=(e,t)=>{let n=e.match(cR);return n?Number.parseInt(n[1],10):t?gR(e,t):null},vR=(e,t)=>(e.match(t)||[]).length,yR=(e,t)=>{if(!dR(e))return null;let n=_R(e,t),r=n?`Syntax error near line ${n}.`:`Syntax error in Mermaid diagram.`,i=[];return t&&(vR(t,/\[/g)!==vR(t,/\]/g)&&i.push(`Unbalanced square brackets in a node label.`),vR(t,/\(/g)!==vR(t,/\)/g)&&i.push(`Unbalanced parentheses in a node shape.`),vR(t,/\{/g)!==vR(t,/\}/g)&&i.push(`Unbalanced braces in a decision node.`),vR(t,/^\s*subgraph\b/gm)>vR(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)]}},bR=e=>dR(e)?e.replace(/\n\s*Expecting[\s\S]*$/,``).trimEnd():e,xR=({error:e,canvasRef:t,loaded:n,hideErrorDetails:r,sourceText:i,autoFixAvailable:a,onApplyAutoFix:o})=>{let s=e?r?G(`chat.errors.mermaidParseError`):bR(e.message):null,c=e&&!r?yR(e.message,i):null,l=!!a&&!!o&&!r,u=s?.split(/\r?\n/)??[];return(0,H.jsxs)(`div`,{className:`ttd-dialog-output-wrapper ${e?`ttd-dialog-output-wrapper--error`:``}`,children:[e&&(0,H.jsx)(`div`,{"data-testid":`ttd-dialog-output-error`,className:`ttd-dialog-output-error`,children:(0,H.jsxs)(`div`,{className:`ttd-dialog-output-error-content`,children:[(0,H.jsx)(`div`,{className:`ttd-dialog-output-error-icon`,children:aC}),c&&(0,H.jsxs)(`div`,{className:`ttd-dialog-output-error-summary`,children:[(0,H.jsx)(`div`,{className:`ttd-dialog-output-error-summary__headline`,children:c.summary}),(0,H.jsx)(`div`,{className:`ttd-dialog-output-error-summary__label`,children:`Likely causes:`}),(0,H.jsx)(`ul`,{className:`ttd-dialog-output-error-summary__causes`,children:c.likelyCauses.map(e=>(0,H.jsx)(`li`,{children:e},e))})]}),(0,H.jsx)(`div`,{className:`ttd-dialog-output-error-message`,children:u.map((e,t)=>(0,H.jsxs)(`span`,{className:pR(e)?`ttd-dialog-output-error-message__caret`:void 0,children:[e,t<u.length-1?`
63
- `:``]},`error-line-${t}`))}),!r&&(0,H.jsx)(`div`,{className:`ttd-dialog-output-error-autofix-slot`,children:l?(0,H.jsx)(UA,{className:`ttd-dialog-panel-button ttd-dialog-output-error-autofix`,onSelect:o,children:G(`mermaid.autoFixAvailable`)}):null})]})},`error`),n?(0,H.jsx)(`div`,{className:U(`ttd-dialog-output-canvas-container`,{invisible:!!e}),children:(0,H.jsx)(`div`,{ref:t,className:`ttd-dialog-output-canvas-content`})},`canvas`):(0,H.jsx)(rw,{size:`2rem`})]})},SR=({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,H.jsxs)(`button`,{className:U(`ttd-dialog-panel-action-link`,e.className),onClick:e.action,disabled:e?.disabled||r,type:`button`,children:[e.label,e.icon&&(0,H.jsx)(`span`,{className:`ttd-dialog-panel-action-link__icon`,children:e.icon})]});if(e?.variant===`button`)return(0,H.jsxs)(UA,{className:U(`ttd-dialog-panel-button`,e.className),onSelect:e.action?e.action:()=>{},disabled:e?.disabled||r,children:[(0,H.jsxs)(`div`,{className:U({invisible:r}),children:[e?.label,e?.icon&&(0,H.jsx)(`span`,{children:e.icon})]}),r&&(0,H.jsx)(rw,{})]});if(e?.variant===`rateLimit`)return(0,H.jsx)(`div`,{className:U(`ttd-dialog-panel__rate-limit`,e.className),children:e.label})};return(0,H.jsxs)(`div`,{className:U(`ttd-dialog-panel`,o),children:[(e||i)&&(0,H.jsxs)(`div`,{className:`ttd-dialog-panel__header`,children:[typeof e==`string`?(0,H.jsx)(`label`,{children:e}):e,i?.()]}),t,(0,H.jsxs)(`div`,{className:U(`ttd-dialog-panel-button-container`,{invisible:!n.length}),style:{justifyContent:s},children:[n.filter(Boolean).map(e=>(0,H.jsx)(V.Fragment,{children:c(e)},e.label)),!r&&a?.()]})]})},CR=({children:e})=>(0,H.jsx)(`div`,{className:`ttd-dialog-panels`,children:e}),wR=()=>(0,H.jsxs)(`div`,{className:`ttd-dialog-submit-shortcut`,children:[(0,H.jsx)(`div`,{className:`ttd-dialog-submit-shortcut__key`,children:Z(`CtrlOrCmd`)}),(0,H.jsx)(`div`,{className:`ttd-dialog-submit-shortcut__key`,children:Z(`Enter`)})]}),TR=(e,t)=>{let n=_R(e,t);return n==null?null:n-1},ER=(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
- `)},DR=e=>{let t=e.match(/^(.*(?:\[[^\]]*]|\([^)]*\)|\{[^}]*}|"(?:[^"]*)"|'(?:[^']*)'))([A-Za-z]+)\s*$/);if(t)return t[1];let n=e.match(/^(.*(?:\[[^\]]*]|\([^)]*\)|\{[^}]*}|"(?:[^"]*)"|'(?:[^']*)'))([,;:])\s*$/);return n?n[1]:e},OR=e=>e.replace(/(\|[^|\n]+\|)\s*>\s*(?=[A-Za-z0-9_("[{'`])/g,`$1 `),kR=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),AR=(e,t)=>{let n=RegExp(`^\\s*deactivate\\s+${kR(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},jR=(e,t)=>{let n=RegExp(`^\\s*deactivate\\s+${kR(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},MR=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}`},NR=e=>e.replace(/[“”]/g,`"`).replace(/[‘’]/g,`'`),PR=(e,t)=>{if(!fR(t)||!e.trim())return[];let n=[],r=new Set,i=t=>{!t||t===e||r.has(t)||(r.add(t),n.push(t))},a=mR(t);if(a&&(i(AR(e,a)),i(jR(e,a))),dR(t)){let n=e.split(/\r?\n/),r=TR(t,e),a=r==null?[]:[r,r-1,r+1];for(let e of a)i(ER(n,e,e=>DR(e))),i(ER(n,e,e=>OR(e)));i(OR(e)),i(MR(e));let o=NR(e);i(o===e?null:o)}return n},FR=({canvasRef:e,setError:t})=>{let n=e.current;if(!n)return;let r=n.parentElement;r&&(r.style.background=``,t(null),n.replaceChildren())},IR=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 FR({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:xi(l,{regenerateIds:!0}),files:u};let d=await bk({elements:i.current.elements,files:i.current.files,exportPadding:10,maxWidthOrHeight:Math.max(s.offsetWidth,s.offsetHeight)*window.devicePixelRatio,appState:{exportWithDarkMode:a===N.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}}},LR=e=>{$k.set(ts.MERMAID_TO_EXCALIDRAW,e)},RR=({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&&LR(n))},zR=`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]`,BR=Ss(LR,300),VR=500,HR=4,UR=30,WR=e=>e instanceof Error?e.message:typeof e==`string`?e:e&&typeof e==`object`&&`message`in e&&typeof e.message==`string`?e.message:``,GR=({mermaidToExcalidrawLib:e,isActive:t})=>{let[n,r]=(0,V.useState)(()=>$k.get(ts.MERMAID_TO_EXCALIDRAW)||zR),i=(0,V.useDeferredValue)(n),[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(null),l=a?.message?_R(a.message,i):null,u=(0,V.useRef)(null),d=(0,V.useRef)({elements:[],files:null}),f=gH(),{theme:p}=bw();(0,V.useEffect)(()=>{t&&((async()=>{try{if(!i.trim()){FR({canvasRef:u,setError:o});return}let t=await IR({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){ht()&&console.error(`Failed to parse mermaid definition`,e)}})(),BR(i))},[i,e,t,p]),(0,V.useEffect)(()=>()=>{BR.flush()},[]),(0,V.useEffect)(()=>{let n=a?.message??``,r=i;if(!(t&&fR(n)&&r.trim()&&e.loaded)){c(null);return}let o=PR(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<UR;){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>=HR)continue;let r=WR(t);if(!r)continue;let a=PR(e.text,r);for(let t of a)n.has(t)||i.push({text:t,depth:e.depth+1})}}}}catch{}s||c(null)},VR);return()=>{s=!0,clearTimeout(l)}},[i,a?.message,t,e]);let m=()=>{RR({app:f,data:d,text:n,shouldSaveMermaidDataToStorage:!0})};return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`ttd-dialog-desc`,children:(0,H.jsx)(aA,{i18nKey:`mermaid.description`,flowchartLink:e=>(0,H.jsx)(`a`,{href:`https://mermaid.js.org/syntax/flowchart.html`,target:`_blank`,rel:`noreferrer`,children:e}),sequenceLink:e=>(0,H.jsx)(`a`,{href:`https://mermaid.js.org/syntax/sequenceDiagram.html`,target:`_blank`,rel:`noreferrer`,children:e}),classLink:e=>(0,H.jsx)(`a`,{href:`https://mermaid.js.org/syntax/classDiagram.html`,target:`_blank`,rel:`noreferrer`,children:e}),erdLink:e=>(0,H.jsx)(`a`,{href:`https://mermaid.js.org/syntax/entityRelationshipDiagram.html`,target:`_blank`,rel:`noreferrer`,children:e})})}),(0,H.jsxs)(CR,{children:[(0,H.jsx)(SR,{children:(0,H.jsx)(sR,{input:n,placeholder:G(`mermaid.inputPlaceholder`),onChange:e=>r(e),errorLine:l,onKeyboardSubmit:()=>{m()}})}),(0,H.jsx)(SR,{panelActions:[{action:()=>{m()},label:G(`mermaid.button`),icon:fC,variant:`button`}],renderSubmitShortcut:()=>(0,H.jsx)(wR,{}),children:(0,H.jsx)(xR,{canvasRef:u,loaded:e.loaded,error:a,sourceText:n,autoFixAvailable:!!s,onApplyAutoFix:()=>{s&&r(s)}})})]})]})},KR=()=>(0,H.jsxs)(`div`,{className:`chat-interface__welcome-screen__welcome-message`,children:[(0,H.jsx)(`h3`,{children:G(`chat.placeholder.title`)}),(0,H.jsx)(`p`,{children:G(`chat.placeholder.description`)}),(0,H.jsx)(`p`,{children:G(`chat.placeholder.hint`)})]}),qR=({message:e,onMermaidTabClick:t,onAiRepairClick:n,onDeleteMessage:r,onInsertMessage:i,onRetry:a,rateLimitRemaining:o,isLastMessage:s,renderWarning:c,allowFixingParseError:l})=>{let[u,d]=(0,V.useState)(!1);(0,V.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,H.jsx)(`div`,{className:`chat-message chat-message--system`,children:(0,H.jsxs)(`div`,{className:`chat-message__content`,children:[(0,H.jsxs)(`div`,{className:`chat-message__header`,children:[(0,H.jsx)(`span`,{className:`chat-message__role`,children:G(`chat.role.system`)}),(0,H.jsx)(`span`,{className:`chat-message__timestamp`,children:f(e.timestamp)})]}),(0,H.jsx)(`div`,{className:`chat-message__body`,children:(0,H.jsx)(`div`,{className:`chat-message__text`,children:t||(e.warningType===`messageLimitExceeded`?(0,H.jsxs)(H.Fragment,{children:[G(`chat.rateLimit.messageLimit`),(0,H.jsx)(`div`,{style:{marginTop:`10px`},children:(0,H.jsx)(VL,{onClick:()=>{window.open(`${nn.VITE_APP_PLUS_LP}/plus?utm_source=excalidraw&utm_medium=app&utm_content=ttdChatBanner#excalidraw-redirect`,`_blank`,`noopener`)},children:G(`chat.upsellBtnLabel`)})})]}):G(`chat.rateLimit.generalRateLimit`))})})]})})}return(0,H.jsxs)(`div`,{className:`chat-message chat-message--${e.type}`,children:[(0,H.jsxs)(`div`,{className:`chat-message__content`,children:[(0,H.jsxs)(`div`,{className:`chat-message__header`,children:[(0,H.jsx)(`span`,{className:`chat-message__role`,children:e.type===`user`?G(`chat.role.user`):G(`chat.role.assistant`)}),(0,H.jsx)(`span`,{className:`chat-message__timestamp`,children:f(e.timestamp)})]}),(0,H.jsx)(`div`,{className:`chat-message__body`,children:e.error?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`chat-message__error`,children:e.content}),e.errorType!==`parse`&&(0,H.jsxs)(`div`,{className:`chat-message__error_message`,children:[`Error: `,e.error||G(`chat.errors.generationFailed`)]}),e.errorType===`parse`&&l&&(0,H.jsxs)(`div`,{className:`chat-message__error_message`,children:[(0,H.jsx)(`p`,{children:G(`chat.errors.invalidDiagram`)}),(0,H.jsxs)(`div`,{className:`chat-message__error-actions`,children:[t&&(0,H.jsx)(`button`,{className:`chat-message__error-link`,onClick:()=>t(e),type:`button`,children:G(`chat.errors.fixInMermaid`)}),n&&(0,H.jsx)(`button`,{className:`chat-message__error-link`,onClick:()=>n(e),disabled:o===0,type:`button`,children:G(`chat.errors.aiRepair`)})]})]})]}):(0,H.jsxs)(`div`,{className:`chat-message__text`,children:[e.content,e.isGenerating&&(0,H.jsx)(`span`,{className:`chat-message__cursor`,children:`▋`})]})})]}),e.type===`assistant`&&!e.isGenerating&&(0,H.jsxs)(`div`,{className:`chat-message__actions`,children:[!e.error&&i&&(0,H.jsx)(`button`,{className:`chat-message__action`,onClick:()=>i(e),type:`button`,"aria-label":G(`chat.insert`),title:G(`chat.insert`),children:dC}),t&&e.content&&(0,H.jsx)(`button`,{className:`chat-message__action`,onClick:()=>t(e),type:`button`,"aria-label":G(`chat.viewAsMermaid`),title:G(`chat.viewAsMermaid`),children:US}),r&&e.errorType!==`network`&&(0,H.jsx)(`button`,{className:`chat-message__action chat-message__action--danger`,onClick:()=>r(e.id),type:`button`,"aria-label":G(`chat.deleteMessage`),title:G(`chat.deleteMessage`),children:fx}),e.errorType===`network`&&a&&s&&(0,H.jsx)(`button`,{className:U(`chat-message__action`,{invisible:!u}),onClick:()=>a(e),type:`button`,"aria-label":G(`chat.retry`),title:G(`chat.retry`),children:uC})]})]})},JR=({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,V.useRef)(null),g=(0,V.useRef)(null);(0,V.useLayoutEffect)(()=>{h.current?.scrollIntoView()},[t]),(0,V.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===I.ENTER&&!e.shiftKey&&(e.preventDefault(),a||v())},b=n.trim().length>3&&!a&&(o?.rateLimitRemaining??1)>0,x=a&&!!s;return(0,H.jsxs)(`div`,{className:`chat-interface`,children:[(0,H.jsxs)(`div`,{className:`chat-interface__messages`,children:[t.length===0?(0,H.jsx)(`div`,{className:`chat-interface__welcome-screen`,children:p?p({rateLimits:o??null}):(0,H.jsx)(KR,{})}):t.map((e,n)=>(0,H.jsx)(qR,{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,H.jsx)(`div`,{ref:h,id:`messages-end`})]}),(0,H.jsx)(`div`,{className:`chat-interface__input-container`,children:(0,H.jsx)(`div`,{className:`chat-interface__input-outer`,children:(0,H.jsxs)(`div`,{className:`chat-interface__input-wrapper`,style:{borderColor:a?`var(--dialog-border-color)`:void 0},children:[(0,H.jsx)(`textarea`,{ref:g,autoFocus:!0,className:`chat-interface__input`,value:n,onChange:_,onKeyDown:y,placeholder:a?G(`chat.generating`):o?.rateLimitRemaining===0?G(`chat.rateLimit.messageLimitInputPlaceholder`):t.length>0?G(`chat.inputPlaceholderWithMessages`):G(`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,H.jsx)(`button`,{className:`chat-interface__send-button`,onClick:v,disabled:!b&&!x,type:`button`,children:(0,H.jsx)(MT,{size:`1.5em`,icon:a?tS:fC})})]})})})]})},YR=Yc(null),XR=Yc(!1),ZR=Yc(null),QR=Yc({id:Ae(),messages:[],currentPrompt:``}),$R=(e,t)=>{let{messages:n}=e,r=de(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}},ez=e=>{let{messages:t}=e;return t[de(t,e=>e.type===`assistant`)]},tz=(e,t)=>{let n=t.map(e=>({...e,id:Ae(),timestamp:new Date}));return{...e,messages:[...e.messages,...n]}},nz=e=>{let t=de(e.messages??[],e=>e.type===`assistant`);return t===-1?e:{...e,messages:e.messages.filter((e,n)=>n!==t)}},rz=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},iz=()=>{let[e,t]=_b(QR);return{addUserMessage:e=>{t(t=>tz(t,[{type:`user`,content:e}]))},addAssistantMessage:()=>{t(e=>tz(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=>$R(t,{isGenerating:!1,error:e,errorType:n,errorDetails:i}))},chatHistory:e,setChatHistory:t,setLastRetryAttempt:()=>{t(e=>$R(e,{lastAttemptAt:Date.now()}))}}},az=e=>{let t=e.trim();return t.length<=50?t:`${t.substring(0,47)}...`},oz=Yc([]),sz=Yc(!1),cz=Yc(!1),lz=({persistenceAdapter:e})=>{let[t]=_b(QR),[n,r]=_b(oz),[i,a]=_b(sz),[o,s]=_b(cz),c=(0,V.useRef)(n);c.current=n;let l=t?.messages[t?.messages.length-1],u=(0,V.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,V.useEffect)(()=>{u()},[]);let d=(0,V.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=az(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,V.useEffect)(()=>{l?.isGenerating||d()},[t.messages?.length,l?.id,l?.isGenerating]),{savedChats:n,saveCurrentChat:d,deleteChat:(0,V.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,V.useCallback)(e=>e,[]),createNewChatId:(0,V.useCallback)(async()=>(await d(),Ae()),[d])}},uz=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))},dz=300,fz=3e3,pz=100,mz=100,hz=({mermaidToExcalidrawLib:e,canvasRef:t})=>{let[n]=_b(QR),[,r]=_b(ZR),[i,a]=_b(XR),o=(0,V.useRef)(!1),s=(0,V.useMemo)(()=>ez(n),[n]),c=(0,V.useRef)(s);(0,V.useEffect)(()=>{c.current=s},[s]);let l=(0,V.useRef)({elements:[],files:null}),u=(0,V.useRef)(0),d=(0,V.useRef)(null),f=(0,V.useRef)(!1),p=(0,V.useRef)(dz),{theme:m}=bw(),h=(0,V.useCallback)(async n=>{if(!n.trim()||!e.loaded||o.current)return!1;o.current=!0;let i=performance.now(),a=await IR({canvasRef:t,data:l,mermaidToExcalidrawLib:e,setError:r,mermaidDefinition:n,theme:m});return performance.now()-i<pz?p.current=dz:p.current=fz,o.current=!1,a.success},[t,e,r,m]),g=(0,V.useMemo)(()=>{let e=async e=>{let t=Date.now(),n=t-u.current,r=p.current;if(!uz(e)){f.current||=(u.current=Math.max(u.current,t-r+mz),!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+mz,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,V.useCallback)(()=>{u.current=0,d.current=null,f.current=!1,p.current=dz},[]);return(0,V.useEffect)(()=>{s?.content&&s?.isGenerating?g(s.content):s?.isGenerating||(g.flush(),_(),s?.content&&g(s.content))},[_,g,s?.isGenerating,s?.content]),(0,V.useEffect)(()=>{let e=c.current;!e?.content||e.error||i&&h(e.content)},[n?.id,h,i]),(0,V.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}},gz=3,_z=1e4,vz=({onTextSubmit:e})=>{let[,t]=_b(ZR),[n,r]=_b(YR),[i,a]=_b(QR),{addUserMessage:o,addAssistantMessage:s,setAssistantError:c}=iz(),l=(0,V.useRef)(null),u=e=>e.length>_z||e.length<gz||n?.rateLimitRemaining===0?(e.length<gz&&t(Error(G(`chat.errors.promptTooShort`,{min:gz}))),e.length>_z&&t(Error(G(`chat.errors.promptTooLong`,{max:_z}))),!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=>$R(e,{isGenerating:!0,content:``,error:void 0,errorType:void 0,errorDetails:void 0})):(o(n),s());try{hw(`ai`,`generate`,`ttd`);let{generatedResponse:o,error:s,rateLimit:l,rateLimitRemaining:u}=await e({messages:[...rz(i).slice(-3),{role:`user`,content:n}],onStreamCreated:()=>{d&&a(e=>$R(e,{content:``,error:``,isGenerating:!0}))},onChunk:e=>{a(t=>$R(t,{content:ez(t).content+e}))},signal:f.signal});if(a(e=>$R(e,{isGenerating:!1})),Lo(l)&&Lo(u)&&r({rateLimit:l,rateLimitRemaining:u}),(s?.status===429||u===0)&&a(e=>(s?.status===429&&(e=nz(e)),e={...e,messages:e.messages.filter(e=>e.type!==`warning`||e.warningType===`rateLimitExceeded`||e.warningType===`messageLimitExceeded`)},tz(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||G(`chat.errors.requestFailed`));s.status!==429&&c(e.message,`network`),t(e);return}try{await Vc(o??``),hw(`ai`,`mermaid parse success`,`ttd`)}catch(e){hw(`ai`,`mermaid parse failed`,`ttd`);let n=Error(e.message||G(`chat.errors.mermaidParseError`));c(n.message,`parse`),t(n)}}catch(e){let n=Error(e.message||G(`chat.errors.generationFailed`));c(n.message,`other`),t(n)}finally{l.current=null}},handleAbort:()=>{l.current&&l.current.abort()}}},yz=({persistenceAdapter:e})=>{let t=vb(ZR),[n,r]=_b(QR),[i,a]=(0,V.useState)(!1),{restoreChat:o,deleteChat:s,createNewChatId:c}=lz({persistenceAdapter:e}),l=(0,V.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=ez(i);t(a?.error?Error(a?.error):null),r(i)},[t,r]),u=(0,V.useCallback)(async()=>{let e=await c();r({id:e,messages:[],currentPrompt:``}),t(null)},[c,r,t]);return{isMenuOpen:i,onRestoreChat:(0,V.useCallback)(e=>{let t=o(e);l(t),a(!1)},[o,l]),handleDeleteChat:(0,V.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,V.useCallback)(async()=>{await u(),a(!1)},[u]),handleMenuToggle:(0,V.useCallback)(()=>{a(e=>!e)},[]),handleMenuClose:(0,V.useCallback)(()=>{a(!1)},[])}},bz=({isOpen:e,onToggle:t,onClose:n,onNewChat:r,onRestoreChat:i,onDeleteChat:a,isNewChatBtnVisible:o,savedChats:s,activeSessionId:c,disabled:l})=>(0,H.jsxs)(`div`,{className:`ttd-chat-history-menu`,children:[o&&(0,H.jsx)(VL,{onClick:r,disabled:l,children:G(`chat.newChat`)}),s.length>0&&(0,H.jsx)(`div`,{className:`ttd-dialog-panel__menu-wrapper`,children:(0,H.jsxs)(Q,{open:e,children:[(0,H.jsx)(Q.Trigger,{onToggle:t,className:`ttd-dialog-menu-trigger`,disabled:l,title:G(`chat.menu`),"aria-label":G(`chat.menu`),children:CC}),(0,H.jsx)(Q.Content,{onClickOutside:n,onSelect:n,children:(0,H.jsx)(H.Fragment,{children:s.map(e=>(0,H.jsxs)(Q.ItemCustom,{className:U(`ttd-chat-menu-item`,{"ttd-chat-menu-item--active":e.id===c}),onClick:()=>{i(e)},children:[(0,H.jsx)(`span`,{className:`ttd-chat-menu-item__title`,children:e.title}),(0,H.jsx)(`button`,{className:`ttd-chat-menu-item__delete`,onClick:t=>a(e.id,t),title:G(`chat.deleteChat`),"aria-label":G(`chat.deleteChat`),type:`button`,children:fx})]},e.id))})})]})})]}),xz=({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]=_b(YR),T=(()=>{let e=[];return w&&e.push({label:G(`chat.rateLimitRemaining`,{count:w.rateLimitRemaining}),variant:`rateLimit`,className:w.rateLimitRemaining<5?`ttd-dialog-panel__rate-limit--danger`:``}),o&&e.push({action:x,label:G(`chat.viewAsMermaid`),icon:(0,H.jsx)(MT,{icon:fC}),variant:`link`}),e})();return(0,H.jsx)(SR,{label:(0,H.jsxs)(`div`,{className:`ttd-dialog-panel__label-wrapper`,children:[(0,H.jsx)(`div`,{className:`ttd-dialog-panel__label-group`}),(0,H.jsx)(`div`,{className:`ttd-dialog-panel__header-right`,children:(0,H.jsx)(bz,{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,H.jsx)(JR,{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})})},Sz=({canvasRef:e,error:t,loaded:n,onInsert:r,hideErrorDetails:i})=>{let a=[{action:r,label:G(`chat.insert`),icon:fC,variant:`button`}];return(0,H.jsx)(SR,{panelActionJustifyContent:`flex-end`,panelActions:a,className:`ttd-dialog-preview-panel`,children:(0,H.jsx)(xR,{canvasRef:e,error:t,loaded:n,hideErrorDetails:i})})},Cz=({mermaidToExcalidrawLib:e,onTextSubmit:t,renderWelcomeScreen:n,renderWarning:r,persistenceAdapter:i})=>{let a=gH(),o=CH(),s=(0,V.useRef)(null),[c,l]=_b(ZR),[u,d]=_b(QR),f=yb(XR),{savedChats:p}=lz({persistenceAdapter:i}),m=ez(u),{setLastRetryAttempt:h}=iz(),{data:g}=hz({canvasRef:s,mermaidToExcalidrawLib:e}),{onGenerate:_,handleAbort:v}=vz({onTextSubmit:t}),{isMenuOpen:y,onRestoreChat:b,handleDeleteChat:x,handleNewChat:S,handleMenuToggle:C,handleMenuClose:w}=yz({persistenceAdapter:i});return(0,H.jsxs)(`div`,{className:`ttd-dialog-layout ${f?`ttd-dialog-layout--split`:`ttd-dialog-layout--chat-only`}`,children:[(0,H.jsx)(xz,{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&&(LR(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 IR({canvasRef:s,data:r,mermaidToExcalidrawLib:e,setError:l,mermaidDefinition:n,theme:a.state.theme})).success&&RR({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`&&(LR(m.content),o({openDialog:{name:`ttd`,tab:`mermaid`}}))},renderWarning:r,renderWelcomeScreen:n}),f&&(0,H.jsx)(Sz,{canvasRef:s,hideErrorDetails:m?.errorType===`parse`,error:c,loaded:e.loaded,onInsert:()=>{RR({app:a,data:g})}})]})},wz=({mermaidToExcalidrawLib:e,onTextSubmit:t,renderWelcomeScreen:n,renderWarning:r,persistenceAdapter:i})=>(0,H.jsx)(Cz,{mermaidToExcalidrawLib:e,onTextSubmit:t,renderWelcomeScreen:n,renderWarning:r,persistenceAdapter:i}),Tz=e=>{let t=CH(),n=(0,V.useRef)(null),r=(0,V.useRef)(0);return(0,H.jsx)(Sy,{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`&&Zr([`text-to-diagram`,`mermaid`],i)&&t({openDialog:{name:e.dialog,tab:i}})},children:e.children})};Tz.displayName=`TTDDialogTabs`;var Ez=Tz,Dz=({children:e,...t})=>(0,H.jsx)(Cy,{className:`ttd-dialog-triggers`,...t,children:e});Dz.displayName=`TTDDialogTabTriggers`;var Oz=({children:e,tab:t,onSelect:n,...r})=>(0,H.jsx)(wy,{value:t,asChild:!0,onSelect:n,children:(0,H.jsx)(`button`,{type:`button`,className:`ttd-dialog-tab-trigger`,...r,children:e})});Oz.displayName=`TTDDialogTabTrigger`;var kz=({tab:e,children:t,...n})=>(0,H.jsx)(Ty,{...n,value:e,children:t});kz.displayName=`TTDDialogTab`;var Az=e=>{let t=bw();return t.openDialog?.name===`ttd`?(0,H.jsx)(jz,{...e,tab:t.openDialog.tab}):null};Az.WelcomeMessage=KR;var jz=dL(`TTDDialogBase`,({tab:e,...t})=>{let r=gH(),[i,a]=(0,V.useState)({loaded:!1,api:n(()=>import(`./excalidraw-mermaid-stub-DE5FTiZB.js`),__vite__mapDeps([69,70]),import.meta.url)});return(0,V.useEffect)(()=>{(async()=>{await i.api,a(e=>({...e,loaded:!0}))})()},[i.api]),(0,H.jsx)(nj,{className:`ttd-dialog`,onCloseRequest:()=>{r.setOpenDialog(null)},size:1520,title:!1,...t,autofocus:!1,children:(0,H.jsxs)(Ez,{dialog:`ttd`,tab:e,children:[`__fallback`in t&&t.__fallback?(0,H.jsx)(`p`,{className:`dialog-mermaid-title`,children:G(`mermaid.title`)}):(0,H.jsxs)(Dz,{children:[(0,H.jsx)(Oz,{tab:`text-to-diagram`,children:(0,H.jsxs)(`div`,{className:`ttd-dialog-tab-trigger__content`,children:[G(`labels.textToDiagram`),(0,H.jsx)(`div`,{className:`ttd-dialog-tab-trigger__badge`,children:G(`chat.aiBeta`)})]})}),(0,H.jsx)(Oz,{tab:`mermaid`,children:G(`mermaid.label`)})]}),!(`__fallback`in t)&&(0,H.jsx)(kz,{className:`ttd-dialog-content`,tab:`text-to-diagram`,children:(0,H.jsx)(wz,{mermaidToExcalidrawLib:i,onTextSubmit:t.onTextSubmit,renderWelcomeScreen:t.renderWelcomeScreen,renderWarning:t.renderWarning,persistenceAdapter:t.persistenceAdapter})}),(0,H.jsx)(kz,{className:`ttd-dialog-content`,tab:`mermaid`,children:(0,H.jsx)(GR,{mermaidToExcalidrawLib:i,isActive:e===`mermaid`})})]})})}),Mz=.01,Nz=10,Pz=(e,t)=>!(t===`angle`&&P(e)),Fz=(e,t)=>{let n=e+t/2;return n-n%t},Iz=(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),Lz=(e,t,n,r,i,a,o=!0)=>{if(Ur(n)&&(n.startBinding||n.endBinding)){if(Math.abs(e-n.x)<10&&Math.abs(t-n.y)<10)return;hn(n,`start`,r),hn(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]=_o(A(n.x,n.y),A(l,u),n.angle),p=e-d,m=t-f,[h,g]=_o(A(e,t),A(l+p,u+m),-n.angle);r.mutateElement(c,{x:h,y:g},{informMutation:o,isDragging:!1}),An(c,r,i);let _=ao(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=tr(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]=_o(A(t.x,t.y),A(a,c),t.angle),d=Math.round(l+p),f=Math.round(u+m),[h,g]=_o(A(d,f),A(a+p,c+m),-t.angle);r.mutateElement(n,{x:h,y:g},{informMutation:o,isDragging:!1}),An(n,r,i,{simultaneouslyUpdated:At(e)})})}},Rz=(e,t)=>{let n=Ds(t).map(t=>St(e,t).reduce((e,t)=>(e[t.id]=!0,e),{}));return e.filter(e=>!Da(e)).forEach(e=>{n.push({[e.id]:!0})}),n},zz=({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=gH(),p=CH(),m=(0,V.useRef)(null),h=(0,V.useRef)(null),[_,v]=(0,V.useState)(r.toString()),y=(0,V.useRef)(null);y.current||={originalAppState:g(l),originalElements:i,lastUpdatedValue:_,updatePending:!1},(0,V.useEffect)(()=>{let e=r.toString();v(e),y.current.lastUpdatedValue=e},[r]);let b=(e,t,i)=>{if(!y.current.updatePending)return!1;y.current.updatePending=!1;let a=Number(e);if(isNaN(a)){v(r.toString());return}let l=Number(a.toFixed(2)),u=Number(r);(isNaN(u)||Math.abs(l-u)>=Mz)&&(y.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=>v(String(e)),app:f,setAppState:p}),f.syncActionResult({captureUpdate:j.IMMEDIATELY}))},x=(0,V.useRef)({});return x.current.handleInputValue=b,(0,V.useEffect)(()=>{let e=m.current,t=x.current;return()=>{let n=e?.value;n&&t.handleInputValue?.(n,y.current.originalElements,y.current.originalAppState),window.removeEventListener(R.POINTER_MOVE,t.onPointerMove,!1),window.removeEventListener(R.POINTER_UP,t.onPointerUp,!1)}},[a]),a?(0,H.jsxs)(`div`,{className:U(`drag-input-container`,!a&&`disabled`),"data-testid":e,children:[(0,H.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,ii(t)),e),new Map),a=i.map(e=>r.get(e.id)),h=g(l),_=0,y=0,b=e=>{if(t&&r!==null&&a!==null){let i=e.clientX-t.x;i!==0&&(y+=i,Math.abs(y)>=u&&(y=Math.sign(y)*Math.floor(Math.abs(y)/u),_+=y,n({accumulatedChange:_,instantChange:y,originalElements:a,originalElementsMap:r,shouldKeepAspectRatio:o,shouldChangeByStepSize:e.shiftKey,property:s,scene:c,originalAppState:h,setInputValue:e=>v(String(e)),app:f,setAppState:p}),y=0))}t={x:e.clientX,y:e.clientY}},S=()=>{window.removeEventListener(R.POINTER_MOVE,b,!1),f.syncActionResult({captureUpdate:j.IMMEDIATELY}),d?.({app:f,setAppState:p,originalElements:a,originalAppState:h}),t=null,_=0,y=0,a=null,r=null,document.body.classList.remove(`excalidraw-cursor-resize`),window.removeEventListener(R.POINTER_UP,S,!1)};x.current.onPointerMove=b,x.current.onPointerUp=S,window.addEventListener(R.POINTER_MOVE,b,!1),window.addEventListener(R.POINTER_UP,S,!1)}},onPointerEnter:()=>{h.current&&(h.current.style.cursor=`ew-resize`)},children:t?(0,H.jsx)(MT,{icon:t}):e}),(0,H.jsx)(`input`,{className:`drag-input`,autoComplete:`off`,spellCheck:`false`,onKeyDown:e=>{if(a){let t=e.target;t instanceof HTMLInputElement&&e.key===I.ENTER&&(b(t.value,i,l),f.focusContainer())}},ref:m,value:_,onChange:e=>{y.current.updatePending=!0,v(e.target.value)},onFocus:e=>{e.target.select(),y.current.originalElements=i,y.current.originalAppState=g(l)},onBlur:e=>{_?a&&b(e.target.value,y.current.originalElements,y.current.originalAppState):v(r.toString())},disabled:!a})]}):null},Bz=15,Vz=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:n,nextValue:r,scene:i,app:a})=>{let o=i.getNonDeletedElementsMap(),s=t[0];if(s&&!fe(s)){let t=o.get(s.id);if(!t)return;if(r!==void 0){let e=Ci(r);i.mutateElement(t,{angle:e}),An(t,i,a.state);let n=ao(t,o);n&&!Wa(t)&&i.mutateElement(n,{angle:e});return}let c=(Math.round(Xn(s.angle)*100)/100+Math.round(e))%360;n&&(c=Fz(c,Bz)),c=c<0?c+360:c;let l=Ci(c);i.mutateElement(t,{angle:l}),An(t,i,a.state);let u=ao(t,o);u&&!Wa(t)&&i.mutateElement(u,{angle:l})}},Hz=({element:e,scene:t,appState:n,property:r})=>(0,H.jsx)(zz,{label:`A`,icon:ZS,value:Math.round(Xn(e.angle)%360*100)/100,elements:[e],dragInputCallback:Vz,editable:Pz(e,`angle`),scene:t,appState:n,property:r}),Uz=5,Wz=({property:e,scene:t,appState:n,setAppState:r})=>(0,H.jsx)(zz,{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?Fz(r.gridStep+Uz*Math.sign(t),Uz):r.gridStep+t),a?(a=ss(a),i(a),{gridStep:a}):(i(r.gridStep),null)})},scene:t,value:n.gridStep,property:e,appState:n}),Gz=10,Kz=e=>e.type===`image`,qz=({accumulatedChange:e,originalElements:t,originalElementsMap:n,shouldKeepAspectRatio:r,shouldChangeByStepSize:i,nextValue:a,property:o,originalAppState:s,instantChange:c,scene:l,app:u,setAppState:d})=>{let f=l.getNonDeletedElementsMap(),p=t[0],m=f.get(p.id);if(p&&m){let t=r||Kz(p),u=p.width/p.height;if(s.croppingElementId===p.id){let e=f.get(p.id);if(!e||!it(e)||!e.crop)return;let t=e.crop,n={...t},r=e.scale[0]===-1,i=e.scale[1]===-1,{width:s,height:u}=go(e),d=t.naturalWidth/s,m=t.naturalHeight/u,h=r?t.width+t.x:t.naturalWidth-t.x,g=i?t.height+t.y:t.naturalHeight-t.y,_=10*d,v=10*m;if(a!==void 0){if(o===`width`){let e=a*d,i=bs(e,_,h);n={...n,width:i,x:r?t.x+t.width-i:t.x}}else if(o===`height`){let e=a*m,r=bs(e,v,g);n={...n,height:r,y:i?t.y+t.height-r:t.y}}l.mutateElement(e,{crop:n,width:n.width/(t.naturalWidth/s),height:n.height/(t.naturalHeight/u)});return}let y=o===`width`?c:0,b=o===`height`?c:0,x=bs(t.width+y,_,h),S=bs(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},l.mutateElement(e,{crop:n,width:n.width/(t.naturalWidth/s),height:n.height/(t.naturalHeight/u)});return}if(a!==void 0){let e=Math.max(o===`width`?a:t?a*u:p.width,1),r=Math.max(o===`height`?a:t?a/u:p.height,1);if(Qi(e,r,m,p,n,l,o===`width`?`e`:`s`,{shouldMaintainAspectRatio:t}),P(m)){let e=js(l.getElementsIncludingDeleted(),m,s,l.getNonDeletedElementsMap()),t=Oi(l.getElementsIncludingDeleted(),e,m);l.replaceAllElements(t)}return}{let r=o===`width`?e:0,a=o===`height`?e:0,c=Math.max(0,p.width+r);o===`width`&&(c=i?Fz(c,Gz):Math.round(c));let f=Math.max(0,p.height+a);o===`height`&&(f=i?Fz(f,Gz):Math.round(f)),t&&(o===`width`?f=Math.round(c/u*100)/100:c=Math.round(f*u*100)/100),f=Math.max(1,f),c=Math.max(1,c),Qi(c,f,m,p,n,l,o===`width`?`e`:`s`,{shouldMaintainAspectRatio:t}),P(m)&&d({elementsToHighlight:At(js(l.getElementsIncludingDeleted(),m,s,l.getNonDeletedElementsMap()))})}}},Jz=({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=js(t.scene.getElementsIncludingDeleted(),o,r,t.scene.getNonDeletedElementsMap()),i=Oi(t.scene.getElementsIncludingDeleted(),n,o);t.scene.replaceAllElements(i),e({elementsToHighlight:null})}},Yz=({property:e,element:t,scene:n,appState:r})=>{let i=aa(e===`width`?t.width:t.height,2);if(r.croppingElementId&&r.croppingElementId===t.id&&it(t)&&t.crop){let{width:n,height:r}=go(t);if(e===`width`){let e=n/t.crop.naturalWidth;i=aa(t.crop.width*e,2)}if(e===`height`){let e=r/t.crop.naturalHeight;i=aa(t.crop.height*e,2)}}return(0,H.jsx)(zz,{label:e===`width`?`W`:`H`,elements:[t],dragInputCallback:qz,value:i,editable:Pz(t,e),scene:n,appState:r,property:e,dragFinishedCallback:Jz})},Xz=4,Zz=4,Qz=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:n,nextValue:r,scene:i})=>{let a=i.getNonDeletedElementsMap(),o=t[0];if(o){let t=a.get(o.id);if(!t||!F(t))return;let s;if(r!==void 0)s=Math.max(Math.round(r),Xz);else if(o.type===`text`){let t=Math.round(o.fontSize);s=Math.max(t+Math.round(e),Xz),n&&(s=Fz(s,Zz))}s&&(i.mutateElement(t,{fontSize:s}),ga(t,i.getContainerElement(t),i))}},$z=({element:e,scene:t,appState:n,property:r})=>{let i=F(e)?e:Qr(e)?ao(e,t.getNonDeletedElementsMap()):null;return i?(0,H.jsx)(zz,{label:`F`,value:Math.round(i.fontSize*10)/10,elements:[i],dragInputCallback:Qz,icon:BS,appState:n,scene:t,property:r}):null},eB=15,tB=({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&&!Da(e)&&Pz(e,i)),c=t.filter(e=>!Da(e)&&Pz(e,i));if(r!==void 0){let e=Ci(r);for(let t of s){if(!t)continue;a.mutateElement(t,{angle:e});let n=ao(t,o);n&&!Wa(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(Xn(i.angle)*100)/100+Math.round(e))%360;n&&(l=Fz(l,eB)),l=l<0?l+360:l;let u=Ci(l);a.mutateElement(r,{angle:u});let d=ao(r,o);d&&!Wa(r)&&a.mutateElement(d,{angle:u})}a.triggerUpdate()},nB=({elements:e,scene:t,appState:n,property:r})=>{let i=e.filter(e=>!Da(e)&&Pz(e,`angle`)),a=i.map(e=>Math.round(Xn(e.angle)%360*100)/100),o=new Set(a).size===1?a[0]:`Mixed`,s=i.some(e=>Pz(e,`angle`));return(0,H.jsx)(zz,{label:`A`,icon:ZS,value:o,elements:e,dragInputCallback:tB,editable:s,appState:n,scene:t,property:r})},rB=10,iB=(e,t,n,r)=>{let i=r.x-e,a=r.y-t,o=r.width*n,s=r.height*n;return{width:o,height:s,x:e+i*n,y:t+a*n,...Pa(r,o,s,!1),...F(r)?{fontSize:r.fontSize*n}:{}}},aB=(e,t,n,r,i,a,o,s)=>{let c=s.getNonDeletedElementsMap(),l=iB(e,t,r,a);s.mutateElement(i,l);let u=ao(a,o);if(u){let e=u.fontSize*r;zt(i,s);let t=c.get(u.id);t&&F(t)&&(s.mutateElement(t,{fontSize:e}),Ri(i,s,n===`width`?`e`:`s`,!0))}},oB=(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];aB(i[0],i[1],a,u,n,t,c,l)}},sB=({accumulatedChange:e,originalElements:t,originalElementsMap:n,originalAppState:r,shouldChangeByStepSize:i,nextValue:a,scene:o,property:s,setAppState:c,app:l})=>{let u=o.getNonDeletedElementsMap(),d=Rz(t,r);if(a!==void 0){for(let e of d){let t=Iz(e,u,n);if(t.length>1){let e=t.map(e=>e.latest),r=t.map(e=>e.original),[i,c,l,u]=Bs(r),d=l-i,f=u-c,p=d/f;oB(Math.max(1,s===`width`?Math.max(0,a):d),Math.max(1,s===`height`?Math.max(0,a):f),f,p,A(i,c),s,e,r,n,o)}else{let[e]=t,c=e?.latest,l=e?.original;if(c&&l&&Pz(c,s)){let e=s===`width`?Math.max(0,a):c.width;s===`width`&&(e=i?Fz(e,rB):Math.round(e));let t=s===`height`?Math.max(0,a):c.height;if(s===`height`&&(t=i?Fz(t,rB):Math.round(t)),e=Math.max(1,e),t=Math.max(1,t),Qi(e,t,c,l,n,o,s===`width`?`e`:`s`,{shouldInformMutation:!1}),P(c)){let e=js(o.getElementsIncludingDeleted(),c,r,o.getNonDeletedElementsMap()),t=Oi(o.getElementsIncludingDeleted(),e,c);o.replaceAllElements(t)}}}}o.triggerUpdate();return}let f=s===`width`?e:0,p=s===`height`?e:0,m=[];for(let e of d){let t=Iz(e,u,n);if(t.length>1){let e=t.map(e=>e.latest),r=t.map(e=>e.original),[a,c,l,u]=Bs(r),d=l-a,m=u-c,h=d/m,g=Math.max(0,d+f);s===`width`&&(g=i?Fz(g,rB):Math.round(g));let _=Math.max(0,m+p);s===`height`&&(_=i?Fz(_,rB):Math.round(_)),g=Math.max(1,g),_=Math.max(1,_),oB(g,_,m,h,A(a,c),s,e,r,n,o)}else{let[e]=t,a=e?.latest,c=e?.original;if(a&&c&&Pz(a,s)){let e=Math.max(0,c.width+f);s===`width`&&(e=i?Fz(e,rB):Math.round(e));let t=Math.max(0,c.height+p);if(s===`height`&&(t=i?Fz(t,rB):Math.round(t)),e=Math.max(1,e),t=Math.max(1,t),Qi(e,t,a,c,n,o,s===`width`?`e`:`s`,{shouldInformMutation:!1}),P(a)){let e=At(js(o.getElementsIncludingDeleted(),a,r,o.getNonDeletedElementsMap()));m.push(...e)}}}}c({elementsToHighlight:m}),o.triggerUpdate()},cB=({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=js(t.scene.getElementsIncludingDeleted(),o,r,t.scene.getNonDeletedElementsMap()),i=Oi(t.scene.getElementsIncludingDeleted(),n,o);t.scene.replaceAllElements(i),e({elementsToHighlight:null})}},lB=({property:e,elements:t,elementsMap:n,atomicUnits:r,scene:i,appState:a})=>{let o=(0,V.useMemo)(()=>r.map(t=>{let r=Iz(t,n);if(r.length>1){let[t,n,i,a]=Bs(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,H.jsx)(zz,{label:e===`width`?`W`:`H`,elements:t,dragInputCallback:sB,value:s,editable:c,appState:a,property:e,scene:i,dragFinishedCallback:cB})},uB=4,dB=4,fB=(e,t)=>e.reduce((e,n)=>{if(!n||Da(n))return e;if(F(n))return e.push(n),e;if(Qr(n)){let r=ao(n,t);if(r)return e.push(r),e}return e},[]),pB=({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),uB);for(let e of o)i.mutateElement(e,{fontSize:s}),ga(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),uB);n&&(l=Fz(l,dB)),i.mutateElement(a,{fontSize:l}),ga(a,i.getContainerElement(a),i)}i.triggerUpdate()}},mB=({elements:e,scene:t,appState:n,property:r,elementsMap:i})=>{let a=fB(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,H.jsx)(zz,{label:`F`,icon:BS,elements:a,dragInputCallback:pB,value:s,editable:c,scene:t,property:r,appState:n})},hB=(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]=_o(A(c.x,c.y),A(l,u),c.angle);Lz(e===`x`?Math.round(d+t):d,e===`y`?Math.round(f+n):f,c,a,o,i,!1)}},gB=(e,t,n,r,i,a)=>{let o=i.getNonDeletedElementsMap(),[s,c,,]=Bs(n),l=e-s,u=t-c;for(let e=0;e<n.length;e++){let t=n[e],s=o.get(t.id);if(s&&(!F(s)||!s.containerId)){let[e,n]=[s.x+s.width/2,s.y+s.height/2],[o,c]=_o(A(s.x,s.y),A(e,n),s.angle);Lz(o+l,c+u,t,i,a,r,!1)}}},_B=({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 Rz(t,s)){let t=Iz(e,l,n);if(t.length>1){let[e,r,,]=Bs(t.map(e=>e.latest));gB(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&&Pz(r,a)){let[t,r]=[e.x+e.width/2,e.y+e.height/2],[s,l]=_o(A(e.x,e.y),A(t,r),e.angle);Lz(a===`x`?i:s,a===`y`?i:l,e,o,c.state,n,!1)}}}o.triggerUpdate();return}let u=r?Fz(e,Nz):e;hB(a,a===`x`?u:0,a===`y`?u:0,t,n,o,c.state),o.triggerUpdate()},vB=({property:e,elements:t,elementsMap:n,atomicUnits:r,scene:i,appState:a})=>{let o=(0,V.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]=Bs(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]=_o(A(i.x,i.y),A(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,H.jsx)(zz,{label:e===`x`?`X`:`Y`,elements:t,dragInputCallback:_B,value:s,property:e,scene:i,appState:a})},yB=({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]=_o(A(d.x,d.y),A(f,p),d.angle);if(c.croppingElementId===d.id){let e=u.get(d.id);if(!e||!it(e)||!e.crop)return;let n=e.crop,r=n,i=e.scale[0]===-1,c=e.scale[1]===-1,{width:l,height:f}=go(e);if(a!==void 0){if(o===`x`){let e=a*(n.naturalWidth/l);r=i?{...n,x:bs(n.naturalWidth-e-n.width,0,n.naturalWidth-n.width)}:{...n,x:bs(a*(n.naturalWidth/l),0,n.naturalWidth-n.width)}}o===`y`&&(r={...n,y:bs(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:bs(n.x+p,0,n.naturalWidth-n.width),y:bs(n.y+m,0,n.naturalHeight-n.height)},s.mutateElement(e,{crop:r});return}if(a!==void 0){Lz(o===`x`?a:m,o===`y`?a:h,d,s,l.state,r);return}let g=o===`x`?e:0,_=o===`y`?e:0;Lz(o===`x`?Math.round(i?Fz(d.x+g,Nz):m+g):m,o===`y`?Math.round(i?Fz(d.y+_,Nz):h+_):h,d,s,l.state,r)},bB=({property:e,element:t,scene:n,appState:r})=>{let[i,a]=_o(A(t.x,t.y),A(t.x+t.width/2,t.y+t.height/2),t.angle),o=aa(e===`x`?i:a,2);if(r.croppingElementId===t.id&&it(t)&&t.crop){let n=Te(t);n&&(o=aa(e===`x`?n.x:n.y,2))}return(0,H.jsx)(zz,{label:e===`x`?`X`:`Y`,elements:[t],dragInputCallback:yB,scene:n,value:o,property:e,appState:r})},xB=50,SB=e=>{let t=SH(),n=e.app.scene.getSceneNonce()||1,r=e.app.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1}),i=kN(e.app);return(0,H.jsx)(TB,{...e,appState:t,sceneNonce:n,selectedElements:r,gridModeEnabled:i})},CB=({children:e,columns:t=1,heading:n,style:r,...i})=>(0,H.jsx)(`div`,{className:U(`exc-stats__row`,{"exc-stats__row--heading":n}),style:{gridTemplateColumns:`repeat(${t}, 1fr)`,...r},...i,children:e});CB.displayName=`StatsRow`;var wB=({children:e,order:t,style:n,...r})=>(0,H.jsx)(`div`,{className:`exc-stats__rows`,style:{order:t,...n},...r,children:e});wB.displayName=`StatsRows`,SB.StatsRow=CB,SB.StatsRows=wB;var TB=(0,V.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=CH(),d=r.length===1?r[0]:null,f=r.length>1?r:null,p=i.croppingElementId&&it(d),m=p?go(d):null,[h,g]=(0,V.useState)({width:0,height:0}),_=(0,V.useMemo)(()=>(0,Kc.default)(e=>{let t=Bs(e);g({width:Math.round(t[2])-Math.round(t[0]),height:Math.round(t[3])-Math.round(t[1])})},xB),[]);(0,V.useEffect)(()=>{_(c)},[a,c,_]),(0,V.useEffect)(()=>()=>_.cancel(),[_]);let v=(0,V.useMemo)(()=>Rz(r,i),[r,i]),y=(0,V.useMemo)(()=>Vn(r),[r]);return(0,H.jsx)(`div`,{className:`exc-stats`,children:(0,H.jsxs)(Aw,{padding:3,children:[(0,H.jsxs)(`div`,{className:`title`,children:[(0,H.jsx)(`h2`,{children:G(`stats.title`)}),(0,H.jsx)(`div`,{className:`close`,onClick:t,children:nS})]}),(0,H.jsxs)(NT,{label:(0,H.jsx)(`h3`,{children:G(`stats.generalStats`)}),open:!!(i.stats.panels&Jr.generalStats),openTrigger:()=>u(e=>({stats:{open:!0,panels:e.stats.panels^Jr.generalStats}})),children:[(0,H.jsxs)(wB,{children:[(0,H.jsx)(CB,{heading:!0,children:G(`stats.scene`)}),(0,H.jsxs)(CB,{columns:2,children:[(0,H.jsx)(`div`,{children:G(`stats.shapes`)}),(0,H.jsx)(`div`,{children:c.length})]}),(0,H.jsxs)(CB,{columns:2,children:[(0,H.jsx)(`div`,{children:G(`stats.width`)}),(0,H.jsx)(`div`,{children:h.width})]}),(0,H.jsxs)(CB,{columns:2,children:[(0,H.jsx)(`div`,{children:G(`stats.height`)}),(0,H.jsx)(`div`,{children:h.height})]}),o&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(CB,{heading:!0,children:`Canvas`}),(0,H.jsx)(CB,{children:(0,H.jsx)(Wz,{property:`gridStep`,scene:s,appState:i,setAppState:u})})]})]}),n?.(c,i)]}),!y&&r.length>0&&(0,H.jsx)(`div`,{id:`elementStats`,style:{marginTop:12},children:(0,H.jsx)(NT,{label:(0,H.jsx)(`h3`,{children:G(`stats.elementProperties`)}),open:!!(i.stats.panels&Jr.elementProperties),openTrigger:()=>u(e=>({stats:{open:!0,panels:e.stats.panels^Jr.elementProperties}})),children:(0,H.jsxs)(wB,{children:[d&&(0,H.jsxs)(H.Fragment,{children:[p&&(0,H.jsx)(CB,{heading:!0,children:G(`labels.unCroppedDimension`)}),i.croppingElementId&&it(d)&&m&&(0,H.jsxs)(CB,{columns:2,children:[(0,H.jsx)(`div`,{children:G(`stats.width`)}),(0,H.jsx)(`div`,{children:aa(m.width,2)})]}),i.croppingElementId&&it(d)&&m&&(0,H.jsxs)(CB,{columns:2,children:[(0,H.jsx)(`div`,{children:G(`stats.height`)}),(0,H.jsx)(`div`,{children:aa(m.height,2)})]}),(0,H.jsx)(CB,{heading:!0,"data-testid":`stats-element-type`,style:{margin:`0.3125rem 0`},children:i.croppingElementId?G(`labels.imageCropping`):G(`element.${d.type}`)}),(0,H.jsx)(CB,{children:(0,H.jsx)(bB,{element:d,property:`x`,elementsMap:l,scene:s,appState:i})}),(0,H.jsx)(CB,{children:(0,H.jsx)(bB,{element:d,property:`y`,elementsMap:l,scene:s,appState:i})}),(0,H.jsx)(CB,{children:(0,H.jsx)(Yz,{property:`width`,element:d,scene:s,appState:i})}),(0,H.jsx)(CB,{children:(0,H.jsx)(Yz,{property:`height`,element:d,scene:s,appState:i})}),(0,H.jsx)(CB,{children:(0,H.jsx)(Hz,{property:`angle`,element:d,scene:s,appState:i})}),(0,H.jsx)(CB,{children:(0,H.jsx)($z,{property:`fontSize`,element:d,scene:s,appState:i})})]}),f&&(0,H.jsxs)(H.Fragment,{children:[Va(f)&&(0,H.jsx)(CB,{heading:!0,children:G(`element.group`)}),(0,H.jsxs)(CB,{columns:2,style:{margin:`0.3125rem 0`},children:[(0,H.jsx)(`div`,{children:G(`stats.shapes`)}),(0,H.jsx)(`div`,{children:r.length})]}),(0,H.jsx)(CB,{children:(0,H.jsx)(vB,{property:`x`,elements:f,elementsMap:l,atomicUnits:v,scene:s,appState:i})}),(0,H.jsx)(CB,{children:(0,H.jsx)(vB,{property:`y`,elements:f,elementsMap:l,atomicUnits:v,scene:s,appState:i})}),(0,H.jsx)(CB,{children:(0,H.jsx)(lB,{property:`width`,elements:f,elementsMap:l,atomicUnits:v,scene:s,appState:i})}),(0,H.jsx)(CB,{children:(0,H.jsx)(lB,{property:`height`,elements:f,elementsMap:l,atomicUnits:v,scene:s,appState:i})}),(0,H.jsx)(CB,{children:(0,H.jsx)(nB,{property:`angle`,elements:f,scene:s,appState:i})}),(0,H.jsx)(CB,{children:(0,H.jsx)(mB,{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),EB=({sourceElementId:e,onClose:t,appState:n,scene:r,generateLinkForSelection:i=Qe})=>{let a=r.getNonDeletedElementsMap(),o=a.get(e)?.link??null,[s,c]=(0,V.useState)(o),[l,u]=(0,V.useState)(!1);(0,V.useEffect)(()=>{let e=is(a,n),t=o;if(e.length>0&&i){let r=ma(e,n);r&&(t=Ea(i(r.id,r.type)))}c(t)},[a,n,n.selectedElementIds,o,i]);let d=(0,V.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,V.useEffect)(()=>{let e=e=>{n.openDialog?.name===`elementLinkSelector`&&e.key===I.ENTER&&d(),n.openDialog?.name===`elementLinkSelector`&&e.key===I.ESCAPE&&t?.()};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[n,t,d]),(0,H.jsxs)(`div`,{className:`ElementLinkDialog`,children:[(0,H.jsxs)(`div`,{className:`ElementLinkDialog__header`,children:[(0,H.jsx)(`h2`,{children:G(`elementLink.title`)}),(0,H.jsx)(`p`,{children:G(`elementLink.desc`)})]}),(0,H.jsxs)(`div`,{className:`ElementLinkDialog__input`,children:[(0,H.jsx)(WA,{value:s??``,onChange:e=>{l||u(!0),c(e)},onKeyDown:e=>{e.key===I.ENTER&&d()},className:`ElementLinkDialog__input-field`,selectOnRender:!0}),o&&s&&(0,H.jsx)(Y,{type:`button`,title:G(`buttons.remove`),"aria-label":G(`buttons.remove`),label:G(`buttons.remove`),onClick:()=>{c(null),u(!0)},className:`ElementLinkDialog__remove`,icon:fx})]}),(0,H.jsxs)(`div`,{className:`ElementLinkDialog__actions`,children:[(0,H.jsx)(Zk,{label:G(`buttons.cancel`),onClick:()=>{t?.()},style:{marginRight:10}}),(0,H.jsx)(Zk,{label:G(`buttons.confirm`),onClick:d,actionType:`primary`})]})]})},DB=({children:e,onClose:t})=>{let[n,r]=(0,V.useState)(!!e),{container:i}=bH(),a=V.useCallback(()=>{r(!1),t&&t(),i?.focus()},[t,i]);return(0,H.jsx)(H.Fragment,{children:n&&(0,H.jsx)(nj,{size:`small`,onCloseRequest:a,title:G(`errorDialog.title`),children:(0,H.jsx)(`div`,{style:{whiteSpace:`pre-wrap`},children:e})})})},OB=()=>(0,H.jsxs)(`div`,{className:`HelpDialog__header`,children:[(0,H.jsxs)(`a`,{className:`HelpDialog__btn`,href:`https://docs.excalidraw.com`,target:`_blank`,rel:`noopener`,children:[(0,H.jsx)(`div`,{className:`HelpDialog__link-icon`,children:xx}),G(`helpDialog.documentation`)]}),(0,H.jsxs)(`a`,{className:`HelpDialog__btn`,href:`https://plus.excalidraw.com/blog`,target:`_blank`,rel:`noopener`,children:[(0,H.jsx)(`div`,{className:`HelpDialog__link-icon`,children:xx}),G(`helpDialog.blog`)]}),(0,H.jsxs)(`a`,{className:`HelpDialog__btn`,href:`https://github.com/excalidraw/excalidraw/issues`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,H.jsx)(`div`,{className:`HelpDialog__link-icon`,children:Sx}),G(`helpDialog.github`)]}),(0,H.jsxs)(`a`,{className:`HelpDialog__btn`,href:`https://youtube.com/@excalidraw`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,H.jsx)(`div`,{className:`HelpDialog__link-icon`,children:RC}),`YouTube`]})]}),kB=e=>(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`h3`,{children:e.title}),(0,H.jsx)(`div`,{className:`HelpDialog__islands-container`,children:e.children})]}),AB=e=>(0,H.jsxs)(`div`,{className:`HelpDialog__island ${e.className}`,children:[(0,H.jsx)(`h4`,{className:`HelpDialog__island-title`,children:e.caption}),(0,H.jsx)(`div`,{className:`HelpDialog__island-content`,children:e.children})]});function*jB(e,t){let n=!0;for(let r of e)n||(yield t),n=!1,yield r}var MB=e=>e.replace(/\b[a-z]\b/,e=>e.toUpperCase()),$=({label:e,shortcuts:t,isOr:n=!0})=>{let r=t.map(e=>(e.endsWith(`++`)?[...e.slice(0,-2).split(`+`),`+`]:e.split(`+`)).map(e=>(0,H.jsx)(NB,{children:MB(e)},e)));return(0,H.jsxs)(`div`,{className:`HelpDialog__shortcut`,children:[(0,H.jsx)(`div`,{children:e}),(0,H.jsx)(`div`,{className:`HelpDialog__key-container`,children:[...jB(r,n?G(`helpDialog.or`):``)]})]})},NB=e=>(0,H.jsx)(`kbd`,{className:`HelpDialog__key`,...e}),PB=({onClose:e})=>{let t=wH(),n=V.useCallback(()=>{e&&e()},[e]);return(0,H.jsx)(H.Fragment,{children:(0,H.jsxs)(nj,{onCloseRequest:n,title:G(`helpDialog.title`),className:`HelpDialog`,children:[(0,H.jsx)(OB,{}),(0,H.jsxs)(kB,{title:G(`helpDialog.shortcuts`),children:[(0,H.jsxs)(AB,{className:`HelpDialog__island--tools`,caption:G(`helpDialog.tools`),children:[(0,H.jsx)($,{label:G(`toolBar.hand`),shortcuts:[I.H]}),(0,H.jsx)($,{label:G(`toolBar.selection`),shortcuts:[I.V,I[1]]}),(0,H.jsx)($,{label:G(`toolBar.rectangle`),shortcuts:[I.R,I[2]]}),(0,H.jsx)($,{label:G(`toolBar.diamond`),shortcuts:[I.D,I[3]]}),(0,H.jsx)($,{label:G(`toolBar.ellipse`),shortcuts:[I.O,I[4]]}),(0,H.jsx)($,{label:G(`toolBar.arrow`),shortcuts:[I.A,I[5]]}),(0,H.jsx)($,{label:G(`toolBar.line`),shortcuts:[I.L,I[6]]}),(0,H.jsx)($,{label:G(`toolBar.freedraw`),shortcuts:[I.P,I[7]]}),(0,H.jsx)($,{label:G(`toolBar.text`),shortcuts:[I.T,I[8]]}),(0,H.jsx)($,{label:G(`toolBar.image`),shortcuts:[I[9]]}),(0,H.jsx)($,{label:G(`toolBar.eraser`),shortcuts:[I.E,I[0]]}),(0,H.jsx)($,{label:G(`toolBar.frame`),shortcuts:[I.F]}),(0,H.jsx)($,{label:G(`toolBar.laser`),shortcuts:[I.K]}),(0,H.jsx)($,{label:G(`toolBar.bucketfill`),shortcuts:[I.B]}),(0,H.jsx)($,{label:G(`labels.eyeDropper`),shortcuts:[I.I,`Shift+S`,`Shift+G`]}),(0,H.jsx)($,{label:G(`helpDialog.editLineArrowPoints`),shortcuts:[Z(`CtrlOrCmd+Enter`)]}),(0,H.jsx)($,{label:G(`helpDialog.editText`),shortcuts:[Z(`Enter`)]}),(0,H.jsx)($,{label:G(`helpDialog.textNewLine`),shortcuts:[Z(`Enter`),Z(`Shift+Enter`)]}),(0,H.jsx)($,{label:G(`helpDialog.textFinish`),shortcuts:[Z(`Esc`),Z(`CtrlOrCmd+Enter`)]}),(0,H.jsx)($,{label:G(`helpDialog.curvedArrow`),shortcuts:[`A`,G(`helpDialog.click`),G(`helpDialog.click`),G(`helpDialog.click`)],isOr:!1}),(0,H.jsx)($,{label:G(`helpDialog.curvedLine`),shortcuts:[`L`,G(`helpDialog.click`),G(`helpDialog.click`),G(`helpDialog.click`)],isOr:!1}),(0,H.jsx)($,{label:G(`helpDialog.cropStart`),shortcuts:[G(`helpDialog.doubleClick`),Z(`Enter`)],isOr:!0}),(0,H.jsx)($,{label:G(`helpDialog.cropFinish`),shortcuts:[Z(`Enter`),Z(`Escape`)],isOr:!0}),(0,H.jsx)($,{label:G(`toolBar.lock`),shortcuts:[I.Q]}),(0,H.jsx)($,{label:G(`helpDialog.preventBinding`),shortcuts:[Z(`CtrlOrCmd`)]}),(0,H.jsx)($,{label:G(`toolBar.link`),shortcuts:[Z(`CtrlOrCmd+K`)]}),(0,H.jsx)($,{label:G(`toolBar.convertElementType`),shortcuts:[`Tab`,`Shift+Tab`],isOr:!0})]}),(0,H.jsxs)(AB,{className:`HelpDialog__island--view`,caption:G(`helpDialog.view`),children:[(0,H.jsx)($,{label:G(`buttons.zoomIn`),shortcuts:[Z(`CtrlOrCmd++`)]}),(0,H.jsx)($,{label:G(`buttons.zoomOut`),shortcuts:[Z(`CtrlOrCmd+-`)]}),(0,H.jsx)($,{label:G(`buttons.resetZoom`),shortcuts:[Z(`CtrlOrCmd+0`)]}),(0,H.jsx)($,{label:G(`helpDialog.zoomToFit`),shortcuts:[`Shift+1`]}),(0,H.jsx)($,{label:G(`helpDialog.zoomToSelection`),shortcuts:[`Shift+2`]}),(0,H.jsx)($,{label:G(`helpDialog.movePageUpDown`),shortcuts:[`PgUp/PgDn`]}),(0,H.jsx)($,{label:G(`helpDialog.movePageLeftRight`),shortcuts:[`Shift+PgUp/PgDn`]}),(0,H.jsx)($,{label:G(`buttons.zenMode`),shortcuts:[Z(`Alt+Z`)]}),(0,H.jsx)($,{label:G(`buttons.objectsSnapMode`),shortcuts:[Z(`Alt+S`)]}),(0,H.jsx)($,{label:G(`labels.toggleGrid`),shortcuts:[Z(`CtrlOrCmd+'`)]}),(0,H.jsx)($,{label:G(`labels.viewMode`),shortcuts:[Z(`Alt+R`)]}),t.isActionEnabled(hE)&&(0,H.jsx)($,{label:G(`labels.toggleTheme`),shortcuts:[Z(`Alt+Shift+D`)]}),(0,H.jsx)($,{label:G(`stats.fullTitle`),shortcuts:[Z(`Alt+/`)]}),(0,H.jsx)($,{label:G(`search.title`),shortcuts:[mk(`searchMenu`)]}),(0,H.jsx)($,{label:G(`commandPalette.title`),shortcuts:kt?[mk(`commandPalette`)]:[mk(`commandPalette`),mk(`commandPalette`,1)]})]}),(0,H.jsxs)(AB,{className:`HelpDialog__island--editor`,caption:G(`helpDialog.editor`),children:[(0,H.jsx)($,{label:G(`helpDialog.createFlowchart`),shortcuts:[Z(`CtrlOrCmd+Arrow Key`)],isOr:!0}),(0,H.jsx)($,{label:G(`helpDialog.navigateFlowchart`),shortcuts:[Z(`Alt+Arrow Key`)],isOr:!0}),(0,H.jsx)($,{label:G(`labels.moveCanvas`),shortcuts:[Z(`Space+${G(`helpDialog.drag`)}`),Z(`Wheel+${G(`helpDialog.drag`)}`)],isOr:!0}),(0,H.jsx)($,{label:G(`buttons.clearReset`),shortcuts:[Z(`CtrlOrCmd+Delete`)]}),(0,H.jsx)($,{label:G(`labels.delete`),shortcuts:[Z(`Delete`)]}),(0,H.jsx)($,{label:G(`labels.cut`),shortcuts:[Z(`CtrlOrCmd+X`)]}),(0,H.jsx)($,{label:G(`labels.copy`),shortcuts:[Z(`CtrlOrCmd+C`)]}),(0,H.jsx)($,{label:G(`labels.paste`),shortcuts:[Z(`CtrlOrCmd+V`)]}),(0,H.jsx)($,{label:G(`labels.pasteAsPlaintext`),shortcuts:[Z(`CtrlOrCmd+Shift+V`)]}),(0,H.jsx)($,{label:G(`labels.selectAll`),shortcuts:[Z(`CtrlOrCmd+A`)]}),(0,H.jsx)($,{label:G(`labels.multiSelect`),shortcuts:[Z(`Shift+${G(`helpDialog.click`)}`)]}),(0,H.jsx)($,{label:G(`helpDialog.deepSelect`),shortcuts:[Z(`CtrlOrCmd+${G(`helpDialog.click`)}`)]}),(0,H.jsx)($,{label:G(`helpDialog.deepBoxSelect`),shortcuts:[Z(`CtrlOrCmd+${G(`helpDialog.drag`)}`)]}),(YE||kt)&&(0,H.jsx)($,{label:G(`labels.copyAsPng`),shortcuts:[Z(`Shift+Alt+C`)]}),(0,H.jsx)($,{label:G(`labels.copyStyles`),shortcuts:[Z(`CtrlOrCmd+Alt+C`)]}),(0,H.jsx)($,{label:G(`labels.pasteStyles`),shortcuts:[Z(`CtrlOrCmd+Alt+V`)]}),(0,H.jsx)($,{label:G(`labels.sendToBack`),shortcuts:[Z(uo?`CtrlOrCmd+Alt+[`:`CtrlOrCmd+Shift+[`)]}),(0,H.jsx)($,{label:G(`labels.bringToFront`),shortcuts:[Z(uo?`CtrlOrCmd+Alt+]`:`CtrlOrCmd+Shift+]`)]}),(0,H.jsx)($,{label:G(`labels.sendBackward`),shortcuts:[Z(`CtrlOrCmd+[`)]}),(0,H.jsx)($,{label:G(`labels.bringForward`),shortcuts:[Z(`CtrlOrCmd+]`)]}),(0,H.jsx)($,{label:G(`labels.alignTop`),shortcuts:[Z(`CtrlOrCmd+Shift+Up`)]}),(0,H.jsx)($,{label:G(`labels.alignBottom`),shortcuts:[Z(`CtrlOrCmd+Shift+Down`)]}),(0,H.jsx)($,{label:G(`labels.alignLeft`),shortcuts:[Z(`CtrlOrCmd+Shift+Left`)]}),(0,H.jsx)($,{label:G(`labels.alignRight`),shortcuts:[Z(`CtrlOrCmd+Shift+Right`)]}),(0,H.jsx)($,{label:G(`labels.duplicateSelection`),shortcuts:[Z(`CtrlOrCmd+D`),Z(`Alt+${G(`helpDialog.drag`)}`)]}),(0,H.jsx)($,{label:G(`helpDialog.toggleElementLock`),shortcuts:[Z(`CtrlOrCmd+Shift+L`)]}),(0,H.jsx)($,{label:G(`buttons.undo`),shortcuts:[Z(`CtrlOrCmd+Z`)]}),(0,H.jsx)($,{label:G(`buttons.redo`),shortcuts:u?[Z(`CtrlOrCmd+Y`),Z(`CtrlOrCmd+Shift+Z`)]:[Z(`CtrlOrCmd+Shift+Z`)]}),(0,H.jsx)($,{label:G(`labels.group`),shortcuts:[Z(`CtrlOrCmd+G`)]}),(0,H.jsx)($,{label:G(`labels.ungroup`),shortcuts:[Z(`CtrlOrCmd+Shift+G`)]}),(0,H.jsx)($,{label:G(`labels.flipHorizontal`),shortcuts:[Z(`Shift+H`)]}),(0,H.jsx)($,{label:G(`labels.flipVertical`),shortcuts:[Z(`Shift+V`)]}),(0,H.jsx)($,{label:G(`labels.showStroke`),shortcuts:[Z(`S`)]}),(0,H.jsx)($,{label:G(`labels.showBackground`),shortcuts:[Z(`G`)]}),(0,H.jsx)($,{label:G(`labels.showFonts`),shortcuts:[Z(`Shift+F`)]}),(0,H.jsx)($,{label:G(`labels.decreaseFontSize`),shortcuts:[Z(`CtrlOrCmd+Shift+<`)]}),(0,H.jsx)($,{label:G(`labels.increaseFontSize`),shortcuts:[Z(`CtrlOrCmd+Shift+>`)]})]})]})]})})},FB=2e3,IB=()=>{let[e,t]=(0,V.useState)(null),n=(0,V.useRef)(0);return{copyStatus:e,resetCopyStatus:(0,V.useCallback)(()=>{t(null)},[]),onCopy:()=>{clearTimeout(n.current),t(`success`),n.current=window.setTimeout(()=>{t(null)},FB)}}},LB=({title:e,name:t,checked:n,onChange:r,disabled:i=!1})=>(0,H.jsx)(`div`,{className:U(`Switch`,{toggled:n,disabled:i}),children:(0,H.jsx)(`input`,{name:t,id:t,title:e,type:`checkbox`,checked:n,disabled:i,onChange:()=>r(!n),onKeyDown:e=>{e.key===` `&&r(!n)}})}),RB=()=>(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h3`,{children:G(`canvasError.cannotShowPreview`)}),(0,H.jsx)(`p`,{children:(0,H.jsx)(`span`,{children:G(`canvasError.canvasTooBig`)})}),(0,H.jsxs)(`em`,{children:[`(`,G(`canvasError.canvasTooBigTip`),`)`]})]}),zB=({appStateSnapshot:e,elementsSnapshot:t,files:n,actionManager:r,onExportImage:i,name:a,exportWithDarkMode:o})=>{let s=Ki(t,e),[c,l]=(0,V.useState)(a),[u,d]=(0,V.useState)(s),[f,m]=(0,V.useState)(e.exportBackground),[h,g]=(0,V.useState)(e.exportEmbedScene),[_,v]=(0,V.useState)(e.exportScale),y=(0,V.useRef)(null),b=(0,V.useRef)(0),[x,S]=(0,V.useState)(null),{onCopy:C,copyStatus:w,resetCopyStatus:T}=IB();(0,V.useEffect)(()=>{T()},[c,f,o,_,h,T]);let{exportedElements:E,exportingFrame:D}=mD(t,e,u);return(0,V.useEffect)(()=>{let t=y.current;if(!t)return;let r=t.offsetWidth,i=t.offsetHeight;if(!r)return;let a=++b.current,s=()=>a!==b.current;return bk({elements:E,appState:{...e,name:c,exportBackground:f,exportWithDarkMode:o,exportScale:_,exportEmbedScene:h},files:n,exportPadding:10,maxWidthOrHeight:Math.max(r,i),exportingFrame:D}).then(async e=>{if(!s()){try{await Ke(e)}catch(e){throw e.name===`CANVAS_POSSIBLY_TOO_BIG`?Error(G(`canvasError.canvasTooBig`)):e}s()||(S(null),t.replaceChildren(e))}}).catch(e=>{s()||(console.error(e),S(e))}),()=>{b.current+=1}},[e,n,E,D,c,f,o,_,h]),(0,H.jsxs)(`div`,{className:`ImageExportModal`,children:[(0,H.jsx)(`h3`,{children:G(`imageExportDialog.header`)}),(0,H.jsxs)(`div`,{className:`ImageExportModal__preview`,children:[(0,H.jsx)(`div`,{className:`ImageExportModal__preview__canvas`,ref:y,children:x&&(0,H.jsx)(RB,{})}),(0,H.jsx)(`div`,{className:`ImageExportModal__preview__filename`,children:!Ts&&(0,H.jsx)(`input`,{type:`text`,className:`TextInput`,value:c,style:{width:`30ch`},onChange:e=>{l(e.target.value),r.executeAction(_D,`ui`,e.target.value)}})})]}),(0,H.jsxs)(`div`,{className:`ImageExportModal__settings`,children:[(0,H.jsx)(`h3`,{children:G(`imageExportDialog.header`)}),s&&(0,H.jsx)(BB,{label:G(`imageExportDialog.label.onlySelected`),name:`exportOnlySelected`,children:(0,H.jsx)(LB,{name:`exportOnlySelected`,checked:u,onChange:e=>{d(e)}})}),(0,H.jsx)(BB,{label:G(`imageExportDialog.label.withBackground`),name:`exportBackgroundSwitch`,children:(0,H.jsx)(LB,{name:`exportBackgroundSwitch`,checked:f,onChange:e=>{m(e),r.executeAction(yD,`ui`,e)}})}),(0,H.jsx)(BB,{label:G(`imageExportDialog.label.darkMode`),name:`exportDarkModeSwitch`,children:(0,H.jsx)(LB,{name:`exportDarkModeSwitch`,checked:o,onChange:e=>{r.executeAction(OD,`ui`,e)}})}),(0,H.jsx)(BB,{label:G(`imageExportDialog.label.embedScene`),tooltip:G(`imageExportDialog.tooltip.embedScene`),name:`exportEmbedSwitch`,children:(0,H.jsx)(LB,{name:`exportEmbedSwitch`,checked:h,onChange:e=>{g(e),r.executeAction(bD,`ui`,e)}})}),(0,H.jsx)(BB,{label:G(`imageExportDialog.label.scale`),name:`exportScale`,children:(0,H.jsx)(hL,{name:`exportScale`,value:_,onChange:e=>{v(e),r.executeAction(vD,`ui`,e)},choices:p.map(e=>({value:e,label:`${e}\xD7`}))})}),(0,H.jsxs)(`div`,{className:`ImageExportModal__settings__buttons`,children:[(0,H.jsx)(VL,{className:`ImageExportModal__settings__buttons__button`,label:G(`imageExportDialog.title.exportToPng`),onClick:()=>i(ae.png,E,{exportingFrame:D}),icon:eC,children:G(`imageExportDialog.button.exportToPng`)}),(0,H.jsx)(VL,{className:`ImageExportModal__settings__buttons__button`,label:G(`imageExportDialog.title.exportToSvg`),onClick:()=>i(ae.svg,E,{exportingFrame:D}),icon:eC,children:G(`imageExportDialog.button.exportToSvg`)}),(YE||kt)&&(0,H.jsx)(VL,{className:`ImageExportModal__settings__buttons__button`,label:G(`imageExportDialog.title.copyPngToClipboard`),status:w,onClick:async()=>{await i(ae.clipboard,E,{exportingFrame:D}),C()},icon:tC,children:G(`imageExportDialog.button.copyPngToClipboard`)})]})]})]})},BB=({label:e,children:t,tooltip:n,name:r})=>(0,H.jsxs)(`div`,{className:`ImageExportModal__settings__setting`,title:e,children:[(0,H.jsxs)(`label`,{htmlFor:r,className:`ImageExportModal__settings__setting__label`,children:[e,n&&(0,H.jsx)(aE,{label:n,long:!0,children:rC})]}),(0,H.jsx)(`div`,{className:`ImageExportModal__settings__setting__content`,children:t})]}),VB=({elements:e,appState:t,files:n,actionManager:r,onExportImage:i,onCloseRequest:a,name:o})=>{let[{appStateSnapshot:s,elementsSnapshot:c}]=(0,V.useState)(()=>({appStateSnapshot:g(t),elementsSnapshot:g(e)}));return(0,H.jsx)(nj,{onCloseRequest:a,size:`wide`,title:!1,children:(0,H.jsx)(zB,{elementsSnapshot:c,appStateSnapshot:s,files:n,actionManager:r,onExportImage:i,name:o,exportWithDarkMode:t.exportWithDarkMode})})},HB={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`}},UB=({children:e,color:t})=>(0,H.jsx)(`div`,{className:`Card`,style:{"--card-color":HB[t].base,"--card-color-darker":HB[t].darker,"--card-color-darkest":HB[t].darkest},children:e}),WB=({elements:e,appState:t,setAppState:n,files:r,actionManager:i,exportOpts:a,canvas:o,onCloseRequest:s})=>{let{onExportToBackend:c}=a;return(0,H.jsx)(`div`,{className:`ExportDialog ExportDialog--json`,children:(0,H.jsxs)(`div`,{className:`ExportDialog-cards`,children:[a.saveFileToDisk&&(0,H.jsxs)(UB,{color:`lime`,children:[(0,H.jsx)(`div`,{className:`Card-icon`,children:Px}),(0,H.jsx)(`h2`,{children:G(`exportDialog.disk_title`)}),(0,H.jsxs)(`div`,{className:`Card-details`,children:[G(`exportDialog.disk_details`),!Ts&&i.renderAction(`changeProjectName`)]}),(0,H.jsx)(Y,{className:`Card-button`,type:`button`,title:G(`exportDialog.disk_button`),"aria-label":G(`exportDialog.disk_button`),showAriaLabel:!0,onClick:()=>{i.executeAction(ED,`ui`)}})]}),c&&(0,H.jsxs)(UB,{color:`pink`,children:[(0,H.jsx)(`div`,{className:`Card-icon`,children:Ex}),(0,H.jsx)(`h2`,{children:G(`exportDialog.link_title`)}),(0,H.jsx)(`div`,{className:`Card-details`,children:G(`exportDialog.link_details`)}),(0,H.jsx)(Y,{className:`Card-button`,type:`button`,title:G(`exportDialog.link_button`),"aria-label":G(`exportDialog.link_button`),showAriaLabel:!0,onClick:async()=>{try{hw(`export`,`link`,`ui (${Rt()})`),await c(e,t,r),s()}catch(e){n({errorMessage:e.message})}}})]}),a.renderCustomUI&&a.renderCustomUI(e,t,r,o)]})})},GB=({elements:e,appState:t,files:n,actionManager:r,exportOpts:i,canvas:a,setAppState:o})=>{let s=V.useCallback(()=>{o({openDialog:null})},[o]);return(0,H.jsx)(H.Fragment,{children:t.openDialog?.name===`jsonExport`&&(0,H.jsx)(nj,{onCloseRequest:s,title:G(`buttons.export`),children:(0,H.jsx)(WB,{elements:e,appState:t,setAppState:o,files:n,actionManager:r,onCloseRequest:s,exportOpts:i,canvas:a})})})},KB=e=>(0,H.jsx)(Y,{className:U(`ToolIcon__LaserPointer`,{"is-mobile":e.isMobile}),type:`toggle`,size:`small`,icon:mC,checked:e.checked,title:`${e.title}`,"aria-label":`${e.title}`,"data-testid":`toolbar-LaserPointer`,onSelect:()=>e.onChange?.()}),qB=e=>Array.isArray(e)?`<kbd>${e.map(Z).join(` + `)}</kbd>`:`<kbd>${Z(e)}</kbd>`,JB=({appState:e,isMobile:t,editorInterface:n,app:r})=>{let{activeTool:i,isResizing:a,isRotating:o,lastPointerDownWith:s}=e,c=e.multiElement!==null;if(e.openSidebar?.name===lr.name&&e.openSidebar.tab===`search`&&e.searchMatches?.matches.length)return G(`hints.dismissSearch`,{shortcut:qB(`Escape`)});if(e.openSidebar&&!n.canFitSidebar)return null;if(ti(e))return G(`hints.eraserRevert`,{shortcut:qB(`Alt`)});let l=r.scene.getSelectedElements(e);if(e.selectedLinearElement?.isDragging&&l[0]?.type===`arrow`)return G(`hints.arrowBindModifiers`,{shortcut_1:qB(`Ctrl`),shortcut_2:qB(`Alt`)});if(i.type===`arrow`||i.type===`line`)return c?G(`hints.linearElementMulti`,{shortcut_1:qB(`Escape`),shortcut_2:qB(`Enter`)}):i.type===`arrow`?G(`hints.arrowTool`,{shortcut:qB(`A`)}):G(`hints.linearElement`);if(i.type===`freedraw`)return G(`hints.freeDraw`);if(i.type===`text`)return G(`hints.text`);if(i.type===`embeddable`)return G(`hints.embeddable`);if(i.type===`autoshape`)return G(`hints.autoshape`);if(a&&s===`mouse`&&l.length===1){let e=l[0];return vo(e)&&e.points.length===2?G(`hints.lockAngle`,{shortcut:qB(`Shift`)}):it(e)?G(`hints.resizeImage`,{shortcut_1:qB(`Shift`),shortcut_2:qB(`Alt`)}):G(`hints.resize`,{shortcut_1:qB(`Shift`),shortcut_2:qB(`Alt`)})}if(o&&s===`mouse`)return G(`hints.rotate`,{shortcut:qB(`Shift`)});if(l.length===1&&F(l[0]))return G(`hints.text_selected`,{shortcut:qB(`Enter`)});if(e.editingTextElement)return G(`hints.text_editing`,{shortcut_1:qB(`Escape`),shortcut_2:qB([`CtrlOrCmd`,`Enter`])});if(e.croppingElementId)return G(`hints.leaveCropEditor`,{shortcut_1:qB(`Enter`),shortcut_2:qB(`Escape`)});if(l.length===1&&it(l[0]))return G(`hints.enterCropEditor`,{shortcut:qB(`Enter`)});if(i.type===`selection`){if(e.selectionElement&&!l.length&&!e.editingTextElement&&!e.selectedLinearElement?.isEditing)return G(`hints.deepBoxSelect`,{shortcut:qB(`CtrlOrCmd`)});if(kN(r)&&e.selectedElementsAreBeingDragged)return G(`hints.disableSnapping`,{shortcut:qB(`CtrlOrCmd`)});if(!l.length&&!t)return G(`hints.canvasPanning`,{shortcut_1:qB(G(`keys.mmb`)),shortcut_2:qB(`Space`)});if(l.length===1){if(vo(l[0]))return Wa(l[0])&&e.selectedLinearElement?.elementId===l[0].id&&(e.selectedLinearElement.hoverPointIndex===0||e.selectedLinearElement.hoverPointIndex===l[0].points.length-1)?G(`hints.toggleArrowhead`):e.selectedLinearElement?.isEditing?e.selectedLinearElement.selectedPointsIndices?G(`hints.lineEditor_pointSelected`,{shortcut_1:qB(`Delete`),shortcut_2:qB([`CtrlOrCmd`,`D`])}):G(`hints.lineEditor_nothingSelected`,{shortcut_1:qB(`Shift`),shortcut_2:qB(`Alt`)}):Me(l[0])?G(`hints.lineEditor_line_info`,{shortcut:qB(`Enter`)}):G(`hints.lineEditor_info`,{shortcut_1:qB(`CtrlOrCmd`),shortcut_2:qB([`CtrlOrCmd`,`Enter`])});if(!e.newElement&&!e.selectedElementsAreBeingDragged&&Hi(l[0])){let e=G(`hints.bindTextToElement`,{shortcut:qB(`Enter`)}),t=G(`hints.createFlowchart`,{shortcut:qB([`CtrlOrCmd`,`↑↓`])});return Ft(l[0])?(hr(l[0],r.scene.getNonDeletedElementsMap()),[e,t]):e}}}return null},YB=({appState:e,isMobile:t,editorInterface:n,app:r})=>{let i=JB({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,H.jsx)(`kbd`,{children:n?n[1]:e},t)}return e});return(0,H.jsx)(`div`,{className:`HintViewer`,children:(0,H.jsx)(`span`,{children:a})})},XB=e=>(0,H.jsx)(Y,{className:U(`ToolIcon__lock`,{"is-mobile":e.isMobile}),type:`toggle`,icon:e.checked?Gb:Wb,checked:e.checked,disabled:e.disabled,title:`${e.title} \u2014 Q`,"aria-label":`${e.title}`,"data-testid":`toolbar-lock`,onSelect:()=>e.onChange?.()}),ZB=({app:e,activeTool:t,setAppState:n})=>{let[r,i]=(0,V.useState)(!1),a=yH()===`full`,{TTDDialogTriggerTunnel:o}=jI(),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,H.jsxs)(Q,{open:r,children:[(0,H.jsx)(Q.Trigger,{className:U(`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:G(`toolBar.extraTools`),children:s?cC:f?px:a&&c?pC:l&&!e.props.isCollaborating?mC:d?Zb:u?jx:Bb}),(0,H.jsxs)(Q.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:`App-toolbar__extra-tools-dropdown`,children:[(0,H.jsx)(Q.Item,{onSelect:()=>e.setActiveTool({type:`frame`}),icon:cC,shortcut:I.F.toLocaleUpperCase(),"data-testid":`toolbar-frame`,selected:s,disabled:SE(e,`frame`),children:G(`toolBar.frame`)}),(0,H.jsx)(Q.Item,{onSelect:()=>e.setActiveTool({type:`embeddable`}),icon:px,"data-testid":`toolbar-embeddable`,selected:f,disabled:SE(e,`embeddable`),children:G(`toolBar.embeddable`)}),(0,H.jsx)(Q.Item,{onSelect:()=>e.setActiveTool({type:`autoshape`}),icon:pC,shortcut:bE(`autoshape`),"data-testid":`toolbar-autoshape`,selected:c,disabled:SE(e,`autoshape`),children:G(`toolBar.autoshape`)}),(0,H.jsx)(Q.Item,{onSelect:()=>e.setActiveTool({type:`laser`}),icon:mC,"data-testid":`toolbar-laser`,selected:l,shortcut:I.K.toLocaleUpperCase(),disabled:SE(e,`laser`),children:G(`toolBar.laser`)}),(0,H.jsx)(Q.Item,{onSelect:()=>e.setActiveTool({type:`bucketfill`}),icon:jx,"data-testid":`toolbar-bucketfill`,selected:u,shortcut:I.B.toLocaleUpperCase(),disabled:SE(e,`bucketfill`),children:G(`toolBar.bucketfill`)}),a&&(0,H.jsx)(Q.Item,{onSelect:()=>e.setActiveTool({type:`lasso`}),icon:Zb,"data-testid":`toolbar-lasso`,selected:d,disabled:SE(e,`lasso`),children:G(`toolBar.lasso`)}),(0,H.jsx)(`div`,{style:{margin:`6px 0`,fontSize:14,fontWeight:600},children:`Generate`}),e.props.aiEnabled!==!1&&(0,H.jsx)(o.Out,{}),(0,H.jsx)(Q.Item,{onSelect:()=>e.setOpenDialog({name:`ttd`,tab:`mermaid`}),icon:lC,"data-testid":`toolbar-embeddable`,children:G(`toolBar.mermaidToExcalidraw`)}),e.props.aiEnabled!==!1&&e.plugins.diagramToCode&&(0,H.jsx)(Q.Item,{onSelect:()=>e.onMagicframeToolSelect(),icon:hC,"data-testid":`toolbar-magicframe`,badge:(0,H.jsx)(Q.Item.Badge,{children:`AI`}),disabled:SE(e,`magicframe`),children:G(`toolBar.magicframe`)})]})]})},QB=({app:e,appState:t,setAppState:n,UIOptions:r,onPenModeToggle:i,onLockToggle:a,heading:o})=>{let s=vH(),c=yH()===`compact`,l=t.activeTool,u={app:e,activeTool:l};return(0,H.jsxs)(Aw,{padding:1,className:U(`App-toolbar`,{"zen-mode":t.zenModeEnabled,"App-toolbar--compact":c}),"data-viewport-ui":`top`,children:[(0,H.jsx)(YB,{appState:t,isMobile:s.formFactor===`phone`,editorInterface:s,app:e}),o,(0,H.jsxs)(lA.Row,{gap:c?.5:1,children:[!c&&(0,H.jsx)(LI,{checked:t.penMode,onChange:()=>i(null),title:G(`toolBar.penMode`),penDetected:t.penDetected}),e.props.activeTool==null&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(XB,{checked:t.activeTool.locked,onChange:a,title:G(`toolBar.lock`),disabled:e.props.activeTool!=null}),(0,H.jsx)(`div`,{className:`App-toolbar__divider`,style:{marginRight:`0.25rem`}})]}),(0,H.jsx)(wE,{...u,hideKeyBinding:!0}),c?(0,H.jsx)(LE,{...u,setAppState:n}):t.preferredSelectionTool.type===`lasso`?(0,H.jsx)(IE,{...u}):(0,H.jsx)(FE,{...u}),(0,H.jsx)(TE,{...u}),(0,H.jsx)(EE,{...u}),(0,H.jsx)(DE,{...u}),(0,H.jsx)(OE,{...u}),(0,H.jsx)(kE,{...u}),c?(0,H.jsx)(RE,{...u}):(0,H.jsx)(AE,{...u}),(0,H.jsx)(jE,{...u}),r.tools?.image!==!1&&(0,H.jsx)(ME,{...u}),(0,H.jsx)(NE,{...u}),(0,H.jsx)(`div`,{className:`App-toolbar__divider`,style:{marginLeft:`0.25rem`}}),(0,H.jsx)(ZB,{app:e,activeTool:l,setAppState:n})]})]})},$B=({UIOptions:e})=>(0,H.jsxs)(BL,{__fallback:!0,children:[(0,H.jsx)(BL.DefaultItems.LoadScene,{}),(0,H.jsx)(BL.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&(0,H.jsx)(BL.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&(0,H.jsx)(BL.DefaultItems.SaveAsImage,{}),(0,H.jsx)(BL.DefaultItems.SearchMenu,{}),(0,H.jsx)(BL.DefaultItems.Help,{}),(0,H.jsx)(BL.DefaultItems.ClearCanvas,{}),(0,H.jsx)(BL.Separator,{}),(0,H.jsx)(BL.Group,{title:`Excalidraw links`,children:(0,H.jsx)(BL.DefaultItems.Socials,{})}),(0,H.jsx)(BL.Separator,{}),(0,H.jsx)(BL.DefaultItems.ToggleTheme,{allowSystemTheme:!1}),(0,H.jsx)(BL.DefaultItems.ChangeCanvasBackground,{})]}),eV=()=>(0,H.jsxs)(WL,{__fallback:!0,children:[(0,H.jsx)(WL.Actions.SaveToDisk,{}),(0,H.jsx)(WL.Actions.ExportToImage,{})]}),tV=({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:x,generateLinkForSelection:S,currentUserControls:C})=>{let w=vH(),T=_H(),E=yH()===`compact`,D=NI(),ee=E?{menuTopGap:4,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:.5,islandPadding:1,collabMarginLeft:8}:{menuTopGap:6,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:1,islandPadding:1,collabMarginLeft:8},O=D.tunnelsJotai.Provider,[k,te]=_b(Ow),ne=()=>f.canvasActions.export?(0,H.jsx)(GB,{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,H.jsx)(VB,{elements:i,appState:t,files:n,actionManager:e,onExportImage:p,onCloseRequest:()=>r({openDialog:null}),name:g.getName()}),ie=()=>(0,H.jsxs)(`div`,{style:{position:`relative`},children:[(0,H.jsxs)(`div`,{className:`excalidraw-ui-top-left`,children:[l?.(!1,t),(0,H.jsx)(D.MainMenuTunnel.Out,{})]}),m&&(0,H.jsx)(D.WelcomeScreenMenuHintTunnel.Out,{})]}),ae=()=>(0,H.jsx)(UI,{heading:`selectedShapeActions`,className:U(`selected-shape-actions zen-mode-transition`,{"transition-left":t.zenModeEnabled}),children:E?(0,H.jsx)(Aw,{className:U(`compact-shape-actions-island`),padding:0,"data-viewport-ui":`side`,"data-viewport-ui-name":`stylesPanel`,style:{maxHeight:`${t.height-166}px`},children:(0,H.jsx)(gj,{appState:t,elementsMap:g.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:g,setAppState:r})}):(0,H.jsx)(Aw,{className:Os.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${t.height-166}px`},"data-viewport-ui":`side`,"data-viewport-ui-name":`stylesPanel`,children:(0,H.jsx)(uj,{appState:t,elementsMap:g.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:g})})}),oe=()=>{let n=_&&Xt(t,i),a=_&&t.stats.open&&!t.zenModeEnabled&&!t.viewModeEnabled&&t.openDialog?.name!==`elementLinkSelector`;return(0,H.jsx)(II,{side:`top`,children:(0,H.jsxs)(`div`,{className:`App-menu App-menu_top`,children:[(0,H.jsxs)(lA.Col,{gap:ee.menuTopGap,className:U(`App-menu_top__left`),children:[ie(),_&&(0,H.jsx)(`div`,{className:U(`selected-shape-actions-container`,{"selected-shape-actions-container--compact":E}),children:n&&ae()}),_&&E&&!t.viewModeEnabled&&n&&(0,H.jsx)(LI,{checked:t.penMode,onChange:()=>s(null),title:G(`toolBar.penMode`),isMobile:!0,penDetected:t.penDetected})]}),_&&!t.viewModeEnabled&&t.openDialog?.name!==`elementLinkSelector`&&(0,H.jsx)(UI,{heading:`shapes`,className:`shapes-section`,children:e=>(0,H.jsxs)(`div`,{style:{position:`relative`},children:[m&&(0,H.jsx)(D.WelcomeScreenToolbarHintTunnel.Out,{}),(0,H.jsx)(lA.Col,{gap:ee.toolbarColGap,align:`start`,children:(0,H.jsxs)(lA.Row,{gap:ee.toolbarRowGap,className:U(`App-toolbar-container`,{"zen-mode":t.zenModeEnabled}),children:[(0,H.jsx)(QB,{app:g,appState:t,setAppState:r,UIOptions:f,onPenModeToggle:s,onLockToggle:o,heading:e}),x&&(0,H.jsx)(Aw,{style:{marginLeft:ee.collabMarginLeft,alignSelf:`center`,height:`fit-content`},children:(0,H.jsx)(KB,{title:G(`toolBar.laser`),checked:t.activeTool.type===ct.laser,onChange:()=>g.setActiveTool({type:ct.laser}),isMobile:!0})})]})})]})}),(0,H.jsxs)(`div`,{className:U(`layer-ui__wrapper__top-right zen-mode-transition`,{"transition-right":t.zenModeEnabled,"layer-ui__wrapper__top-right--compact":E}),children:[_&&t.collaborators.size>0&&(0,H.jsx)(ZI,{collaborators:t.collaborators,userToFollow:T.userToFollow?.socketId||null,currentUserControls:C}),u?.(w.formFactor===`phone`,t),!t.viewModeEnabled&&t.openDialog?.name!==`elementLinkSelector`&&(!ce||t.openSidebar?.name!==lr.name)&&(0,H.jsx)(D.DefaultSidebarTriggerTunnel.Out,{}),a&&(0,H.jsx)(SB,{app:g,onClose:()=>{e.executeAction(lO)},renderCustomStats:d})]})]})})},se=()=>_?(0,H.jsx)(aR,{__fallback:!0,onDock:e=>{hw(`sidebar`,`toggleDock (${e?`dock`:`undock`})`,`(${w.formFactor===`phone`?`mobile`:`desktop`})`)}}):null,ce=yb(cL),le=!!(t.openSidebar&&ce&&w.canFitSidebar),ue=(0,H.jsxs)(H.Fragment,{children:[h,_&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)($B,{UIOptions:f}),(0,H.jsx)(aR.Trigger,{__fallback:!0,icon:QC,title:Qa(G(`toolBar.library`)),onToggle:e=>{e&&hw(`sidebar`,`${lr.name} (open)`,`button (${w.formFactor===`phone`?`mobile`:`desktop`})`)},tab:lr.defaultTab})]}),(0,H.jsx)(eV,{}),t.openDialog?.name===`ttd`&&(0,H.jsx)(Az,{__fallback:!0}),_&&t.isLoading&&(0,H.jsx)(PI,{delay:250}),_&&t.errorMessage&&(0,H.jsx)(DB,{onClose:()=>r({errorMessage:null}),children:t.errorMessage}),_&&k&&w.formFactor!==`phone`&&(0,H.jsx)(kw,{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)ur(r,ze(i),{[a&&k.swapPreviewOnAlt?e===`elementBackground`?`strokeColor`:`backgroundColor`:e===`elementBackground`?`backgroundColor`:`strokeColor`]:t}),yr.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,H.jsx)(PB,{onClose:()=>{r({openDialog:null})}}),(0,H.jsx)(wj,{}),_&&t.openDialog?.name===`elementLinkSelector`&&(0,H.jsx)(EB,{sourceElementId:t.openDialog.sourceElementId,onClose:()=>{r({openDialog:null})},scene:g.scene,appState:t,generateLinkForSelection:S}),(0,H.jsx)(D.OverwriteConfirmDialogTunnel.Out,{}),re(),ne(),_&&t.openDialog?.name===`charts`&&(0,H.jsx)(HI,{data:t.openDialog.data,rawText:t.openDialog.rawText,onClose:()=>r({openDialog:null})}),w.formFactor===`phone`&&(0,H.jsx)(RI,{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}),w.formFactor!==`phone`&&(0,H.jsxs)(H.Fragment,{children:[T.viewportStatusFrame?.border&&(0,H.jsx)(OI,{border:T.viewportStatusFrame.border,style:le?{right:`calc(var(--right-sidebar-width) - var(--space-factor) * 2)`}:void 0}),(0,H.jsxs)(`div`,{className:`layer-ui__wrapper`,style:le?{width:`calc(100% - var(--right-sidebar-width))`}:{},children:[m&&(0,H.jsx)(D.WelcomeScreenCenterTunnel.Out,{}),oe(),(0,H.jsx)(eL,{appState:t,actionManager:e,showExitZenModeBtn:c,renderWelcomeScreen:m,defaultUIEnabled:_,zoomUIEnabled:v}),(t.toast||y&&t.scrolledOutside||T.viewportStatusFrame?.label)&&(0,H.jsxs)(`div`,{className:`floating-status-stack`,children:[t.toast&&(0,H.jsx)(qE,{message:t.toast.message,onClose:()=>r({toast:null}),duration:t.toast.duration,closable:t.toast.closable}),!t.toast&&y&&t.scrolledOutside&&(0,H.jsx)(`button`,{type:`button`,className:`scroll-back-to-content`,onClick:()=>{r(e=>({...b(i,e)}))},children:G(`buttons.scrollBackToContent`)}),T.viewportStatusFrame?.label&&(0,H.jsx)(kI,{label:T.viewportStatusFrame.label,border:T.viewportStatusFrame.border})]})]}),se()]})]});return(0,H.jsx)(yw.Provider,{value:t,children:(0,H.jsx)(O,{children:(0,H.jsx)(AI.Provider,{value:D,children:ue})})})},nV=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},rV=V.memo(tV,(e,t)=>{if(e.children!==t.children)return!1;let{canvas:n,appState:r,...i}=e,{canvas:a,appState:o,...s}=t;return Jn(nV(r),nV(o),{selectedElementIds:Jn,selectedGroupIds:Jn})&&Jn(i,s)}),iV=e=>(0,H.jsx)(Y,{className:U(`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?.()}),aV=({trails:e})=>{let t=(0,V.useRef)(null);return(0,V.useEffect)(()=>{if(t.current)for(let n of e)n.start(t.current);return()=>{for(let t of e)t.stop()}},e),(0,H.jsx)(`div`,{className:`SVGLayer`,children:(0,H.jsx)(`svg`,{ref:t})})},oV=`#ff6b6b`,sV=`#ff0000`,cV=1,lV=2,uV=(e,t)=>{if(!t.snapLines.length)return;let n=t.theme===N.LIGHT||t.zenModeEnabled?oV:sV,r=(t.zenModeEnabled?cV*1.5:cV)/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,fV(i,e,t)):i.type===`gap`?(e.lineWidth=r,e.strokeStyle=n,hV(i.points[0],i.points[1],i.direction,t,e)):i.type===`points`&&(e.lineWidth=r,e.strokeStyle=n,dV(i,e,t));e.restore()},dV=(e,t,n)=>{if(!n.zenModeEnabled){let n=e.points[0],r=e.points[e.points.length-1];mV(n,r,t)}for(let r of e.points)pV(r,n,t)},fV=(e,t,n)=>{pV(e.points[0],n,t),n.zenModeEnabled||mV(e.points[0],e.points[1],t)},pV=([e,t],n,r)=>{r.save();let i=(n.zenModeEnabled?lV*1.5:lV)/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()},mV=(e,t,n)=>{n.beginPath(),n.lineTo(e[0],e[1]),n.lineTo(t[0],t[1]),n.stroke()},hV=(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||mV(A(e[0],e[1]-a),A(e[0],e[1]+a),i),mV(A(n[0]-s,n[1]-o),A(n[0]-s,n[1]+o),i),mV(A(n[0]+s,n[1]-o),A(n[0]+s,n[1]+o),i),r.zenModeEnabled||(mV(A(t[0],t[1]-a),A(t[0],t[1]+a),i),mV(e,t,i))}else{let n=[e[0],(e[1]+t[1])/2];r.zenModeEnabled||mV(A(e[0]-a,e[1]),A(e[0]+a,e[1]),i),mV(A(n[0]-o,n[1]-s),A(n[0]+o,n[1]-s),i),mV(A(n[0]-o,n[1]+s),A(n[0]+o,n[1]+s),i),r.zenModeEnabled||(mV(A(t[0]-a,t[1]),A(t[0]+a,t[1]),i),mV(e,t,i))}},gV=(e,t)=>{ho(t.selectedLinearElement,`selectedLinearElement is null`);let{segmentMidPointHoveredCoords:n}=t.selectedLinearElement;ho(n,`midPointCoords is null`),vV(n,e,t)},_V=(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=M.getElement(r,n);a&&vV(M.getPointAtIndexGlobalCoordinates(a,i,n),e,t)},vV=(e,t,n)=>{t.save(),t.translate(n.scrollX,n.scrollY),t.fillStyle=`rgba(105, 101, 219, 0.4)`,Kn(t,e[0],e[1],M.POINT_HANDLE_SIZE/n.zoom.value,!1),t.restore()},yV=(e,t,n)=>{let{elementId:r,anchor:i}=t.hoveredArrowTextAnchor,a=n.get(r);!a||!Wa(a)||a.isDeleted||vV(i===`label`?M.getBoundTextElementCenter(a,n):M.getPointAtIndexGlobalCoordinates(a,i===`start`?0:-1,n),e,t)},bV=(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)`),Kn(e,n[0],n[1],(o?r*(t.selectedLinearElement?.isEditing?1.5:2):r)/t.zoom.value,!a,!o||i)},xV=(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(),li.radius&&e.roundRect?e.roundRect(-1,-1,o.width+1,o.height+1,li.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=li.strokeWidth/r.zoom.value,e.strokeStyle=r.theme===N.DARK?`rgba(3, 93, 161, 1)`:`rgba(106, 189, 252, 1)`,li.radius&&e.roundRect?(e.beginPath(),e.roundRect(0,0,t.element.width,t.element.height,li.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=ni(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=bs(1.75,t.element.strokeWidth,4)/Math.max(.25,r.zoom.value),e.strokeStyle=r.theme===N.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]=or(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]=Ar(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)||Oc(t.element))){let a=r.selectedLinearElement,o=a?.elementId&&M.getElement(a?.elementId,n),s=i&&d({point:i,element:t.element,elementsMap:n,threshold:0,overrideShouldTestInside:!0}),c=o&&fe(o)||r.activeTool.type===`arrow`&&r.currentItemArrowType===`elbow`;if(!s||c){e.save();let a=ni(t.element,n),o;if(t.element.type===`diamond`){let e=ni(t.element,n);o=h(t.element).map(n=>{let r=Vi(n,.5),i=_o(r,e,t.element.angle);return A(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=A(e.x+t.element.x,e.y+t.element.y),r=_o(n,a,t.element.angle);return A(r[0],r[1])});let l=i&&o.reduce((e,t,n)=>{let r=Sc(t,i);return n===-1||r<e.distance?{idx:n,distance:r}:e},{idx:-1,distance:1/0}),u=4/r.zoom.value,d=Fn(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===N.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===N.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()}}},SV=(e,t,n,r,i,a,o)=>{let s=e.state.bindMode===`orbit`&&e.bindModeHandler!==null,c=700-(o?.runtime??(s?0:700)),l=bs(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(),li.radius&&t.roundRect?t.roundRect(-1,-1,d.width+1,d.height+1,li.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=li.strokeWidth/i.zoom.value,t.strokeStyle=i.theme===N.DARK?`rgba(3, 93, 161, ${l})`:`rgba(106, 189, 252, ${l})`,li.radius&&t.roundRect?(t.beginPath(),t.roundRect(0,0,n.width,n.height,li.radius/i.zoom.value),t.stroke(),t.closePath()):t.strokeRect(0,0,n.width,n.height),t.restore();break;default:t.save();let e=ni(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=bs(2.5,n.strokeWidth*1.75,4)/Math.max(.25,i.zoom.value),t.strokeStyle=i.theme===N.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]=or(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]=Ar(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||!mc(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]=or(n),t=ni(n,r);o=e.map(e=>{let r=Vi(e,.5),i=_o(r,t,n.angle);return{x:i[0]-n.x,y:i[1]-n.y}})}else{let e=ni(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=A(t.x+n.x,t.y+n.y),i=_o(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===N.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}},CV=(e,t,n,r,i,a,o)=>{if(n!==null){if(ra(`COMPLEX_BINDINGS`))return SV(e,t,n.element,r,i,a,o);t.save(),t.translate(i.scrollX,i.scrollY),xV(t,n,r,i,e.lastPointerMoveCoords?A(e.lastPointerMoveCoords.x,e.lastPointerMoveCoords.y):null,!!e.lastPointerMoveEvent&&mc(e.lastPointerMoveEvent)),t.restore()}},wV=(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,Gs(e,i-h,a-h,p+h*2,m+h*2,l,u,r);e.restore()},TV=(e,t,n,r)=>{let[i,a,o,s]=E(n,r),c=o-i,l=s-a;e.strokeStyle=`rgb(0,118,255)`,e.lineWidth=li.strokeWidth/t.zoom.value,e.save(),e.translate(t.scrollX,t.scrollY),Gs(e,i,a,c,l,i+c/2,a+l/2,n.angle,!1,li.radius/t.zoom.value),e.restore()},EV=(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]=Bs(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=St(n,e);return c(t)};Object.entries(Nt(s,t)).filter(([e,t])=>t).map(([e,t])=>e).map(e=>l(e)).concat(o.map(e=>c([e]))).forEach(n=>wV(e,t,n))},DV=(e,t,n,r)=>{if(!t.selectedLinearElement)return;e.save(),e.translate(t.scrollX,t.scrollY),e.lineWidth=1/t.zoom.value;let i=M.getPointsGlobalCoordinates(n,r),{POINT_HANDLE_SIZE:a}=M,o=t.selectedLinearElement?.isEditing?a:a/2,s=fe(n),c=Me(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)&&ds(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),bV(e,t,r,o,u,!1,l)}),fe(n)){let o=n.fixedSegments?.map(e=>e.index)||[];i.slice(0,-1).forEach((s,c)=>{M.isSegmentTooShort(n,i[c+1],i[c],c,t.zoom,r)||bV(e,t,A((s[0]+i[c+1][0])/2,(s[1]+i[c+1][1])/2),a/2,!1,!o.includes(c+1),!1)})}else M.getEditorMidPoints(n,r,t).filter((e,t,r)=>e!==null&&!(fe(n)&&(t===0||t===r.length-1))).forEach(n=>{(t.selectedLinearElement?.isEditing||i.length===2)&&bV(e,t,n,a/2,!1,!0,!1)});e.restore()},OV=(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()},kV=(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)`,Kn(e,n[0],n[1],r/t.zoom.value,!0,!0),e.restore()},AV=({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||!Oc(o)||o.isDeleted)return;let s=ei(a.fixedPoint,o,i);if(!lo(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&&vV(s,r,t),!(d&&l)){let s=ei(a.fixedPoint,o,i),l=c?.hoveredFocusPointBinding===n;OV(r,t,M.getPointAtIndexGlobalCoordinates(e,u,i),s),kV(r,t,s,pt/1.5,l)}},jV=(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`?Kn(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()):Gs(e,r,s,c,l,r+c/2,s+l/2,i,!0),e.restore()}})},MV=(e,t,n,r,i)=>{let[a,o,,,s,c]=E(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()},NV=(e,t,n,r)=>{t.save();let i=dP(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()},PV=(e,t,n,r,i)=>{let a=fP(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())},FV=({app:e,canvas:t,elementsMap:n,visibleElements:r,selectedElements:i,allElementsMap:a,scale:o,appState:s,renderConfig:c,editorInterface:l,animationState:u,deltaTime:d})=>{if(t===null)return{};let[f,p]=br(t,o),m=u,h=It({canvas:t,scale:o,normalizedWidth:f,normalizedHeight:p});h.save(),h.scale(s.zoom.value,s.zoom.value);let g;if(r.forEach(e=>{s.selectedLinearElement?.isEditing&&s.selectedLinearElement.elementId===e.id&&e&&(g=e)}),g&&DV(h,s,g,n),s.selectionElement&&!s.isCropping)try{la(s.selectionElement,h,s,c.selectionColor)}catch(e){console.error(e)}let _=Ca(i,s);if(_&&!_.autoResize&&PV(_,h,s,c.selectionColor,l.formFactor),s.editingTextElement){let e=a.get(s.editingTextElement.id);e&&!e.autoResize&&NV(e,h,s,c.selectionColor)}if(m=s.isBindingEnabled&&s.suggestedBinding?{...u,bindingHighlight:CV(e,h,s.suggestedBinding,a,s,d,u?.bindingHighlight)}:{...u,bindingHighlight:void 0},s.hoveredArrowTextAnchor&&yV(h,s,a),s.frameToHighlight&&TV(h,s,s.frameToHighlight,n),s.elementsToHighlight&&EV(h,s,s.elementsToHighlight),s.activeLockedId){let e=a.get(s.activeLockedId);EV(h,s,e?[e]:St(a,s.activeLockedId),{colors:[`#ced4da`],dashed:!0})}let v=i.some(e=>P(e));i.length===1&&s.selectedLinearElement?.isEditing&&s.selectedLinearElement.elementId===i[0].id&&DV(h,s,i[0],n);let y=s.selectedLinearElement,b=y&&M.getElement(y.elementId,a);if(b&&(s.selectedLinearElement.isDragging||(y.segmentMidPointHoveredCoords?gV(h,s):(fe(b)?y.hoverPointIndex===0||y.hoverPointIndex===b.points.length-1:y.hoverPointIndex>=0)&&_V(h,s,n)),Wa(b)&&(AV({arrow:b,elementsMap:a,appState:s,context:h,type:`start`}),AV({arrow:b,elementsMap:a,appState:s,context:h,type:`end`}))),!s.multiElement&&!s.newElement&&!s.selectedLinearElement?.isEditing){let e=pc(i,s,l),t=i.length===1&&vo(i[0]);t&&s.selectedLinearElement?.elementId===i[0].id&&!i[0].locked&&DV(h,s,i[0],n);let r=c.selectionColor||`#000`;if(e){let e=ze(i),a=[];for(let i of n.values()){let o=[],l=c.remoteSelectedElementIds.get(i.id);if(t&&fe(i)&&(i.startBinding||i.endBinding)||(e.has(i.id)&&!Yn(s,i)&&o.push(r),l&&o.push(...l.map(e=>zD(e,s.collaborators.get(e))))),o.length){let[e,t,r,c,u,d]=E(i,n,!0);a.push({angle:i.angle,x1:e,y1:t,x2:r,y2:c,selectionColors:i.locked?[`#ced4da`]:o,dashed:!!l||i.locked,cx:u,cy:d,activeEmbeddable:s.activeEmbeddable?.element===i&&s.activeEmbeddable.state===`active`,padding:i.id===s.croppingElementId||it(i)?0:void 0})}}let o=e=>{let t=St(n,e),[r,i,o,s]=Bs(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 Ds(s))o(e);s.editingGroupId&&o(s.editingGroupId),a.forEach(e=>wV(h,s,e))}if(h.save(),h.translate(s.scrollX,s.scrollY),i.length===1){h.fillStyle=`#fff`;let t=Nc(i[0],s.zoom,n,`mouse`,je(l));if(!s.viewModeEnabled&&e&&!F(s.editingTextElement)&&!s.croppingElementId&&jV(h,c,s,t,i[0].angle),s.croppingElementId&&!s.isCropping){let e=n.get(s.croppingElementId);e&&it(e)&&MV(h,c,s,e,n)}}else if(i.length>1&&!s.isRotating&&!i.some(e=>e.locked)){let e=4/s.zoom.value;h.fillStyle=`#fff`;let[t,a,o,u]=Bs(i,n),d=h.getLineDash();h.setLineDash([2/s.zoom.value]);let f=h.lineWidth;h.lineWidth=1/s.zoom.value,h.strokeStyle=r,Gs(h,t-e,a-e,o-t+e*2,u-a+e*2,(t+o)/2,(a+u)/2,0),h.lineWidth=f,h.setLineDash(d);let p=pn([t,a,o,u,(t+o)/2,(a+u)/2],0,s.zoom,`mouse`,v?{...je(l),rotation:!0}:je(l));i.some(e=>!e.locked)&&jV(h,c,s,p,0)}h.restore()}s.searchMatches?.matches.forEach(({id:e,focus:t,matchedLines:r})=>{let i=n.get(e);if(i){let[e,a,,,o,c]=E(i,n,!0);h.save(),s.theme===N.LIGHT?t?h.fillStyle=`rgba(255, 124, 0, 0.4)`:h.fillStyle=`rgba(255, 226, 0, 0.4)`:t?h.fillStyle=`rgba(229, 82, 0, 0.4)`:h.fillStyle=`rgba(99, 52, 0, 0.4)`;let l=P(i)?s.zoom.value:1;h.translate(s.scrollX,s.scrollY),h.translate(o,c),h.rotate(i.angle),r.forEach(n=>{(n.showOnCanvas||t)&&h.fillRect(e+n.offsetX/l-o,a+n.offsetY/l-c,n.width/l,n.height/l)}),h.restore()}}),uV(h,s),h.restore(),VD({context:h,renderConfig:c,appState:s,normalizedWidth:f,normalizedHeight:p});let x;return c.renderScrollbars&&(x=SP(n,f,p,s),h.save(),h.fillStyle=xP,h.strokeStyle=`rgba(255,255,255,0.8)`,[x.horizontal,x.vertical].forEach(e=>{e&&LD(h,e.x,e.y,e.width,e.height,bP/2)}),h.restore()),{scrollBars:x,animationState:m}},IV=e=>{let t=FV(e);return e.callback(t),t},LV=`animateInteractiveScene`,RV=e=>{let t=(0,V.useRef)(!1),n=(0,V.useRef)(null);return(0,V.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,dn({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},nP.running(LV)||nP.start(LV,({deltaTime:e,state:t})=>{let r=IV({...n.current,deltaTime:e,animationState:t}).animationState;if(r){for(let e in r)if(r[e]!==void 0)return r}})}),(0,H.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:G(`labels.drawingCanvas`)})},zV=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}),BV=V.memo(RV,(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:Jn(zV(e.appState),zV(t.appState))),VV=e=>{let t=(0,V.useRef)(null),n=(0,V.useRef)(!1);return(0,V.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,V.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`)),ta({canvas:i,rc:e.rc,scale:e.scale,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,visibleElements:e.visibleElements,appState:e.appState,renderConfig:e.renderConfig},eP())}),(0,H.jsx)(`div`,{className:`excalidraw__canvas-wrapper`,ref:t})},HV=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}),UV=V.memo(VV,(e,t)=>e.canvasNonce!==t.canvasNonce||e.scale!==t.scale||e.elementsMap!==t.elementsMap||e.visibleElements!==t.visibleElements?!1:Jn(HV(e.appState),HV(t.appState))&&Jn(e.renderConfig,t.renderConfig)),WV=({canvas:e,rc:t,newElement:n,elementsMap:r,allElementsMap:i,scale:a,appState:o,renderConfig:s})=>{if(e){let[c,l]=br(e,a),u=It({canvas:e,scale:a,normalizedWidth:c,normalizedHeight:l});if(u.save(),u.scale(o.zoom.value,o.zoom.value),n&&n.type!==`selection`){if(Bo(n))return;if((n.frameId||o.frameToHighlight?.id)&&o.frameRendering.enabled&&o.frameRendering.clip){let e=ms(n,r,o);e&&Ie(n,e,o,r)&&Dt(e,u,s,o)}wc(n,r,i,t,u,s,o)}else u.clearRect(0,0,c,l);u.restore()}},GV=As(e=>{WV(e)}),KV=(e,t)=>{if(t){GV(e);return}WV(e)},qV=e=>{let t=(0,V.useRef)(null);return(0,V.useEffect)(()=>{t.current&&KV({canvas:t.current,scale:e.scale,newElement:e.newElement,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,rc:e.rc,renderConfig:e.renderConfig,appState:e.appState},eP())}),(0,H.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})},JV=700,YV=100,XV=16,ZV=3e5,QV=Yc(null),$V=e=>e===Gi.elbow?HC:e===Gi.round?UC:VC,eH=class{constructor(e){B(this,`app`),B(this,`lastShownAt`,0),B(this,`show`,e=>{let{x:t,y:n}=this.app.viewport.lastPosition;t===0&&n===0||(this.lastShownAt=Date.now(),this.app.updateEditorAtom(QV,{content:e,nonce:Math.random()}))}),B(this,`isOnCooldown`,()=>Date.now()-this.lastShownAt<ZV),B(this,`onArrowTypeCycled`,e=>{this.show($V(e))}),B(this,`onToolShortcut`,(e,t)=>{(t===`digit`||!this.isOnCooldown())&&this.show(e===`line`?nx:$V(this.app.state.currentItemArrowType))}),this.app=e}},tH=()=>{let[e,t]=_b(QV),n=gH(),{container:r}=bH(),i=(0,V.useRef)(null),[a,o]=(0,V.useState)(!1),s=e?.nonce;return(0,V.useLayoutEffect)(()=>{if(s==null||!r)return;let e=(e,t)=>{let n=i.current;if(!n)return;let{left:a,top:o}=Tw({cursor:{x:e,y:t},element:{width:n.offsetWidth,height:n.offsetHeight},container:r.getBoundingClientRect(),gap:XV});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(R.POINTER_MOVE,t),()=>{window.removeEventListener(R.POINTER_MOVE,t)}},[s,r,n]),(0,V.useEffect)(()=>()=>{t(null)},[t]),(0,V.useEffect)(()=>{if(s==null)return;o(!1);let e=window.setTimeout(()=>{o(!0)},JV),n=window.setTimeout(()=>{t(null)},JV+YV),r=()=>{t(null)};return window.addEventListener(R.POINTER_DOWN,r,{capture:!0}),()=>{window.clearTimeout(e),window.clearTimeout(n),window.removeEventListener(R.POINTER_DOWN,r,{capture:!0})}},[s,t]),e?(0,H.jsx)(`div`,{ref:i,className:U(`CursorHint`,{"CursorHint--fade-out":a}),"data-testid":`cursor-hint`,children:e.content}):null},nH=class{constructor(e){this.getState=e,B(this,`listeners`,[]),B(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=[]}},rH=({app:e,activeLockedId:t})=>{let n=e.scene.getElement(t);n&&!Un(n)&&console.error(`[NONDELETED][INVARIANT] UnlockPopup: activeLockedId points to a deleted element`);let r=n&&Un(n)?n:null,i=r?[r]:St(e.scene.getNonDeletedElementsMap(),t);if(i.length===0)return null;let[a,o]=Bs(i),{x:s,y:c}=dn({sceneX:a,sceneY:o},e.state);return(0,H.jsx)(`div`,{className:`UnlockPopup`,style:{bottom:`${e.state.height+12-c+e.state.offsetTop}px`,left:`${s-e.state.offsetLeft}px`},onClick:()=>{(0,qc.flushSync)(()=>{let t=Nt(i,e.state);e.setState({selectedElementIds:i.reduce((e,t)=>({...e,[t.id]:!0}),{}),selectedGroupIds:t,activeLockedId:null})}),e.actionManager.executeAction(MO)},title:G(`labels.elementLock.unlock`),children:Kb})},iH=V.createContext(null),aH=V.createContext(null),oH={formFactor:`desktop`,desktopUIMode:`full`,userAgent:vr(typeof navigator<`u`?navigator.userAgent:``),isTouchScreen:!1,canFitSidebar:!1,isLandscape:!0},sH=V.createContext(oH);sH.displayName=`EditorInterfaceContext`;var cH={"editor:mount":{cardinality:`once`,replay:`last`},"editor:initialize":{cardinality:`once`,replay:`last`},"editor:unmount":{cardinality:`once`,replay:`last`}},lH=V.createContext({container:null,id:null});lH.displayName=`ExcalidrawContainerContext`;var uH=V.createContext([]);uH.displayName=`ExcalidrawElementsContext`;var dH=V.createContext({...kr(),width:0,height:0,offsetLeft:0,offsetTop:0});dH.displayName=`ExcalidrawAppStateContext`;var fH=V.createContext(()=>{console.warn(`Uninitialized ExcalidrawSetAppStateContext context!`)});fH.displayName=`ExcalidrawSetAppStateContext`;var pH=V.createContext(null);pH.displayName=`ExcalidrawActionManagerContext`;var mH=V.createContext(null);mH.displayName=`ExcalidrawAPIContext`;var hH=V.createContext(null);hH.displayName=`ExcalidrawAPISetContext`;var gH=()=>(0,V.useContext)(iH),_H=()=>(0,V.useContext)(aH),vH=()=>(0,V.useContext)(sH),yH=()=>rt(vH()),bH=()=>(0,V.useContext)(lH),xH=()=>(0,V.useContext)(uH),SH=()=>(0,V.useContext)(dH),CH=()=>(0,V.useContext)(fH),wH=()=>(0,V.useContext)(pH),TH=()=>(0,V.useContext)(mH),EH=!1,DH=0,OH=null,kH=!1,AH=!1,jH=!1,MH={horizontal:null,vertical:null},NH=0,PH=!1,FH=new Map,IH=4,LH=!1,RH=0,zH=!1,BH=null,VH={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},HH=class e extends V.Component{constructor(t){super(t),B(this,`canvas`),B(this,`interactiveCanvas`,null),B(this,`sessionExportThemeOverride`),B(this,`rc`),B(this,`unmounted`,!1),B(this,`actionManager`),B(this,`editorInterface`,oH),B(this,`stylesPanelMode`,rt(oH)),B(this,`excalidrawContainerRef`,V.createRef()),B(this,`scene`),B(this,`fonts`),B(this,`renderer`),B(this,`visibleElements`),B(this,`hasRenderableElements`,!1),B(this,`resizeObserver`),B(this,`library`),B(this,`libraryItemsFromStorage`),B(this,`id`),B(this,`store`),B(this,`history`),B(this,`excalidrawContainerValue`),B(this,`files`,{}),B(this,`imageCache`,new Map),B(this,`iFrameRefs`,new Map),B(this,`embedsValidationStatus`,new Map),B(this,`initializedEmbeds`,new Set),B(this,`elementsPendingErasure`,new Set),B(this,`_initialized`,!1),B(this,`editorLifecycleEvents`,new Ga(cH)),B(this,`onEvent`,this.editorLifecycleEvents.on.bind(this.editorLifecycleEvents)),B(this,`appStateObserver`,new nH(()=>this.state)),B(this,`onStateChange`,this.appStateObserver.onStateChange),B(this,`bucketFill`,new JF(this)),B(this,`flowchart`,new iI(this)),B(this,`cursor`,new tI(this)),B(this,`arrowText`,new KF(this)),B(this,`viewport`,new SI(this,{getContainer:()=>this.excalidrawContainerRef.current,getStylesPanelMode:()=>this.stylesPanelMode,isGestureActive:()=>VH.pointers.size>=2||AH})),B(this,`bindModeHandler`,null),B(this,`textWysiwygSubmitHandler`,null),B(this,`hitLinkElement`),B(this,`lastPointerDownEvent`,null),B(this,`lastPointerUpEvent`,null),B(this,`lastPointerUpIsDoubleClick`,!1),B(this,`lastPointerMoveEvent`,null),B(this,`lastPointerMoveCoords`,null),B(this,`lastCompletedCanvasClicks`,[]),B(this,`previousPointerMoveCoords`,null),B(this,`drawShape`,new rI(this)),B(this,`laserTrails`,new aP(this)),B(this,`eraserTrail`,new IP(this)),B(this,`lassoTrail`,new FP(this)),B(this,`cursorHints`,new eH(this)),B(this,`onChangeEmitter`,new Qn),B(this,`onPointerDownEmitter`,new Qn),B(this,`onPointerUpEmitter`,new Qn),B(this,`onUserFollowEmitter`,new Qn),B(this,`onScrollChangeEmitter`,new Qn),B(this,`missingPointerEventCleanupEmitter`,new Qn),B(this,`onRemoveEventListenersEmitter`,new Qn),B(this,`api`),B(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}),B(this,`updateEditorAtom`,(e,...t)=>{let n=Sb.set(e,...t);return this.triggerRender(),n}),B(this,`previousHoveredBindableElement`,null),B(this,`getEffectiveGridSize`,()=>kN(this)?this.state.gridSize:null),B(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)}}),B(this,`handleIframeLikeElementHover`,({hitElement:e,scenePointer:t,moveEvent:n})=>e&&os(e)&&(this.state.viewModeEnabled||this.state.activeTool.type===`laser`||this.isIframeLikeElementCenter(e,n,t.x,t.y))?(this.cursor.set(We.POINTER),this.setState({activeEmbeddable:{element:e,state:`hover`}}),!0):(this.state.activeEmbeddable?.state===`hover`&&this.setState({activeEmbeddable:null}),!1)),B(this,`isDoubleClick`,(e,t)=>e!=null&&t.timeStamp-e.timeStamp<=300),B(this,`updateEmbedValidationStatus`,(e,t)=>{this.embedsValidationStatus.set(e.id,t),yr.delete(e)}),B(this,`updateEmbeddables`,()=>{let e=new Set,t=!1;this.scene.getNonDeletedElements().filter(n=>{if(Fa(n)){if(e.add(n.id),!this.embedsValidationStatus.has(n.id)){t=!0;let e=Ac(n.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(n,e)}}else Qt(n)&&e.add(n.id);return!1}),t&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((t,n)=>{e.has(n)||this.iFrameRefs.delete(n)})}),B(this,`getFrameNameDOMId`,e=>`${this.id}-frame-name-${e.id}`),B(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=tc({clientX:r.x,clientY:r.y},this.state),a=tc({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}),B(this,`resetEditingFrame`,e=>{e&&this.scene.mutateElement(e,{name:e.name?.trim()||null}),this.setState({editingFrame:null})}),B(this,`renderFrameNames`,()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return this.state.editingFrame&&this.resetEditingFrame(null),null;let e=this.state.theme===N.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(!Ai(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}=dn({sceneX:t.x,sceneY:t.y},this.state),a,o=un(t);if(t.id===this.state.editingFrame){let n=o;a=(0,H.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===I.ESCAPE||e.key===I.ENTER)&&this.resetEditingFrame(t)},style:{background:Hn(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:`${li.nameFontSize}px`,transform:`translate(-6px, 6px)`,color:e?li.nameColorDarkTheme:li.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,H.jsx)(`div`,{id:this.getFrameNameDOMId(t),className:Os.FRAME_NAME,style:{position:`absolute`,bottom:`${this.state.height+li.nameOffsetY-i+this.state.offsetTop}px`,left:`${r-this.state.offsetLeft}px`,zIndex:2,fontSize:li.nameFontSize,color:e?li.nameColorDarkTheme:li.nameColorLightTheme,lineHeight:li.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:We.MOVE,pointerEvents:this.state.viewModeEnabled?Ya.disabled:Ya.enabled},onPointerDown:e=>this.handleCanvasPointerDown(e),onWheel:e=>this.handleWheel(e),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:t.id})},children:a},t.id)})}),B(this,`focusContainer`,()=>{this.excalidrawContainerRef.current?.focus()}),B(this,`getSceneElementsIncludingDeleted`,()=>this.scene.getElementsIncludingDeleted()),B(this,`getSceneElementsMapIncludingDeleted`,()=>this.scene.getElementsMapIncludingDeleted()),B(this,`getSceneElements`,()=>this.scene.getNonDeletedElements()),B(this,`onInsertElements`,e=>{this.addElementsFromPasteOrLibrary({elements:e,position:`center`,files:null})}),B(this,`onExportImage`,async(e,t,n)=>{hw(`export`,e,`ui`);let r=await hD(e,t,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:n.exportingFrame}).catch(Dr).catch(e=>{console.error(e),this.setState({errorMessage:e.message})});this.state.exportEmbedScene&&r&&Fs(r)&&this.setState({fileHandle:r})}),B(this,`magicGenerations`,new Map),B(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()}),B(this,`plugins`,{}),B(this,`onMagicframeToolSelect`,()=>{let e=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});if(e.length===0)this.setActiveTool({type:ct.magicframe}),hw(`ai`,`tool-select (empty-selection)`,`d2c`);else{let t=e.length===1&&me(e[0])&&e[0];if(!t&&e.some(e=>P(e)||e.frameId)){this.setActiveTool({type:ct.magicframe});return}hw(`ai`,`tool-select (existing selection)`,`d2c`);let n;if(t)n=t;else{let[t,r,i,a]=Bs(e);n=nt({...li,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`)}}),B(this,`openEyeDropper`,({type:e})=>{this.updateEditorAtom(Ow,{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:j.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:t},captureUpdate:j.IMMEDIATELY}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(e=>this.state.selectedElementIds[e.id]?z(e,{[r?`strokeColor`:`backgroundColor`]:t}):e),captureUpdate:j.IMMEDIATELY})},keepOpenOnAlt:!1})}),B(this,`dismissLinearEditor`,()=>{setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isEditing:!1}})})}),B(this,`syncActionResult`,QN(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,a=e?.appState?.theme||this.props.theme||N.LIGHT,o=e?.appState?.name??this.state.name,s=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&&Un(r)&&F(r)?r:null}this.setState(t=>{let c=e.appState||{};return{...t,...c,contextMenu:null,editingTextElement:n,viewModeEnabled:r,zenModeEnabled:i,theme:a,name:o,errorMessage:s}}),t=!0}t||this.scene.triggerUpdate()})),B(this,`scheduleCapture`,()=>this.store.scheduleCapture()),B(this,`onBlur`,QN(()=>{kH=!1,this.setState({isBindingEnabled:this.state.bindingPreference===`enabled`})})),B(this,`onUnload`,()=>{this.onBlur()}),B(this,`disableEvent`,e=>{e.preventDefault()}),B(this,`preventBrowserZoomWheel`,e=>{e[I.CTRL_OR_CMD]&&e.preventDefault()}),B(this,`handleNavigationModeKeyDown`,e=>{if(this.maybeHandlePageScrollKeyDown(e)){e.preventDefault();return}this.actionManager.handleKeyDown(e)}),B(this,`maybeHandlePageScrollKeyDown`,e=>{if(e.key!==I.PAGE_UP&&e.key!==I.PAGE_DOWN)return!1;let t=(e.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;return e.key===I.PAGE_DOWN&&(t=-t),e.shiftKey?this.viewport.translate(e=>({scrollX:e.scrollX+t})):this.viewport.translate(e=>({scrollY:e.scrollY+t})),!0}),B(this,`preventBrowserZoomKeyDown`,e=>{e[I.CTRL_OR_CMD]&&(e.code===ir.EQUAL||e.code===ir.MINUS||e.code===ir.ZERO||e.code===ir.NUM_ADD||e.code===ir.NUM_SUBTRACT||e.code===ir.NUM_ZERO)&&e.preventDefault()}),B(this,`terminateActiveInteraction`,()=>{if(this.maybeCleanupAfterMissingPointerUp(null),kH=!1,AH=!1,jH=!1,BH=null,VH.pointers.clear(),VH.lastCenter=null,VH.initialDistance=null,VH.initialScale=null,clearTimeout(DH),DH=0,e.resetTapTwice(),this.resetContextMenuTimer(),clearTimeout(RH),RH=0,LH=!1,this.bindModeHandler&&=(clearTimeout(this.bindModeHandler),null),this.flowchart.clear(),Sb.set(Ow,null),Sb.set(HO,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())}),B(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,OO(),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:$r(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())}),B(this,`isSameForcedTool`,(e,t)=>e?.type===t?.type&&(e?.type===`custom`?e.customType??null:null)===(t?.type===`custom`?t.customType??null:null)),B(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)}),B(this,`resetHistory`,()=>{this.history.clear()}),B(this,`resetStore`,()=>{this.store.clear()}),B(this,`resetScene`,QN(e=>{this.scene.replaceAllElements([]),this.setState(t=>({...kr(),isLoading:!e?.resetLoadingState&&t.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()})),B(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=Le(e?.elements,null,{repairBindings:!0,deleteInvisibleElements:!0}),n=La(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=ze(e),o=this.viewport.resolveInitialViewport(a,r,i);o&&(n={...n,...o})}else e?.scrollToContent&&(n={...n,...b(t,i)});this.resetStore(),this.resetHistory(),this.syncActionResult({elements:t,appState:n,files:e?.files,captureUpdate:j.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(e=>{this.fonts.onLoaded(e)}),Po(window.location.href)&&this.viewport.setViewport({target:window.location.href,fit:`scale-down`,animation:!1})}),B(this,`getFormFactor`,(e,t)=>this.props.UIOptions.getFormFactor?.(e,t)??xe(e,t)),B(this,`refreshEditorInterface`,()=>{let e=this.excalidrawContainerRef.current;if(!e)return;let{width:t,height:n}=e.getBoundingClientRect(),r=Ls(),i=vr(typeof navigator<`u`?navigator.userAgent:``),a=this.props.UIOptions.dockedSidebarBreakpoint==null?Mn:this.props.UIOptions.dockedSidebarBreakpoint,o=He(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)}),B(this,`reconcileStylesPanelMode`,e=>{let t=rt(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}}))}),B(this,`setDesktopUIMode`,e=>{let t=ri(e);this.editorInterface=He(this.editorInterface,{desktopUIMode:t}),this.reconcileStylesPanelMode(this.editorInterface)}),B(this,`onResize`,QN(()=>{this.scene.getElementsIncludingDeleted().forEach(e=>yr.delete(e)),this.refreshEditorInterface(),this.updateDOMRect(),this.setState({})})),B(this,`onFullscreenChange`,()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state===`active`&&this.setState({activeEmbeddable:null})}),B(this,`renderInteractiveSceneCallback`,({scrollBars:e})=>{e&&(MH=e),this.scheduleImageRefresh()}),B(this,`onScroll`,Ss(()=>{let{offsetTop:e,offsetLeft:t}=this.getCanvasOffsets();this.setState(n=>n.offsetLeft===t&&n.offsetTop===e?null:{offsetTop:e,offsetLeft:t})},100)),B(this,`onCut`,QN(e=>{!this.isInteractionEnabled()||!this.excalidrawContainerRef.current?.contains(document.activeElement)||Ee(e.target)||(this.actionManager.executeAction(eO,`keyboard`,e),e.preventDefault(),e.stopPropagation())})),B(this,`onCopy`,QN(e=>{!this.isInteractionEnabled()||!this.excalidrawContainerRef.current?.contains(document.activeElement)||Ee(e.target)||(this.actionManager.executeAction(QD,`keyboard`,e),e.preventDefault(),e.stopPropagation())})),B(this,`onTouchStart`,t=>{if(this.isInteractionEnabled()){if(Ct&&t.preventDefault(),!EH){EH=!0,t.touches.length===1&&(OH={x:t.touches[0].clientX,y:t.touches[0].clientY}),clearTimeout(DH),DH=window.setTimeout(e.resetTapTwice,300);return}if(EH&&t.touches.length===1&&OH){let e=t.touches[0];Sc(A(e.clientX,e.clientY),A(OH.x,OH.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})),EH=!1,clearTimeout(DH)}t.touches.length===2&&this.setState({selectedElementIds:ci({},this.state),activeEmbeddable:null})}}),B(this,`onTouchEnd`,e=>{this.isInteractionEnabled()&&(this.resetContextMenuTimer(),e.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:ci(this.state.previousSelectedElementIds,this.state)}):VH.pointers.clear())}),B(this,`pasteFromClipboard`,QN(async e=>{if(!this.isInteractionEnabled())return;let t=!!LH,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)||Ee(n)))return;let a=await cD(e),o=a.getFiles(),s=await lD(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()})),B(this,`addElementsFromPasteOrLibrary`,e=>{let t=Le(e.elements,null,{deleteInvisibleElements:!0}),[n,r,i,a]=Bs(t),o=ws(n,i)/2,s=ws(r,a)/2,c=typeof e.position==`object`?e.position.clientX:e.position===`cursor`?this.viewport.lastPosition.x:this.state.width/2+this.state.offsetLeft,l=typeof e.position==`object`?e.position.clientY:e.position===`cursor`?this.viewport.lastPosition.y:this.state.height/2+this.state.offsetTop,{x:u,y:d}=tc({clientX:c,clientY:l},this.state),f=u-o,p=d-s,[m,h]=co(f,p,this.getEffectiveGridSize()),{duplicatedElements:g}=Ei({type:`everything`,elements:t.map(e=>z(e,{x:e.x+m-n,y:e.y+h-r})),randomizeSeed:!e.retainSeed,preserveFrameChildrenOrder:e.preserveFrameChildrenOrder}),_=this.scene.getElementsIncludingDeleted(),v=[..._,...g];v=this.props.onDuplicate?.(v,_)||v,xt(v,ze(g));let y=this.getTopLayerFrameAtSceneCoords({x:u,y:d});if(y){let e=Ce(g,y);v=Xe(v,e,y)}this.scene.replaceAllElements(v),g.forEach(e=>{if(F(e)&&fs(e)){let t=bo(e,this.scene.getElementsMapIncludingDeleted());ga(e,t,this.scene)}}),te&&vn.loadElementsFonts(g).then(e=>{this.fonts.onLoaded(e)}),e.files&&this.addMissingFiles(e.files);let b=za(g);this.store.scheduleCapture(),this.setState({...this.state,openSidebar:this.state.openSidebar&&this.editorInterface.canFitSidebar&&Sb.get(cL)?this.state.openSidebar:null,..._r(b,this.scene.getNonDeletedElements(),this.state)},()=>{e.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:this.state.preferredSelectionTool.type},{keepSelection:!0}),e.fit&&this.viewport.setViewport({target:g,fit:e.fit,animation:!1,offsets:{ui:!0}})}),B(this,`setAppState`,(e,t)=>{this.setState(e,t)}),B(this,`removePointer`,e=>{NH&&this.resetContextMenuTimer(),e.type===`pointercancel`&&this.bucketFill.cancel();let t=VH.pointers.size>=2;VH.pointers.delete(e.pointerId),t&&VH.pointers.size<2&&this.state.scrollConstraints&&this.viewport.releaseOverscroll()}),B(this,`toggleLock`,(e=`ui`)=>{this.props.activeTool||(this.state.activeTool.locked||hw(`toolbar`,`toggleLock`,`${e} (${this.editorInterface.formFactor===`phone`?`mobile`:`desktop`})`),this.setState(e=>({activeTool:{...e.activeTool,...$r(this.state,e.activeTool.locked?{type:this.state.preferredSelectionTool.type}:e.activeTool),locked:!e.activeTool.locked}})))}),B(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}}})}),B(this,`togglePenMode`,e=>{this.setState(t=>({penMode:e??!t.penMode,penDetected:!0,currentItemStrokeVariability:t.penDetected?t.currentItemStrokeVariability:`variable`}))}),B(this,`revealIfHidden`,e=>{!e.length||Xr(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:Bs(e),fit:`scale-down`,animation:{duration:300},offsets:{ui:!0}})}),B(this,`emitUserFollowIntent`,e=>{this.onUserFollowEmitter.trigger(e),this.props.onUserFollow?.(e)}),B(this,`requestUnfollow`,()=>{this.props.userToFollow&&this.emitUserFollowIntent({userToFollow:this.props.userToFollow,action:`UNFOLLOW`})}),B(this,`setToast`,e=>{this.setState({toast:e})}),B(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,Mt,window.location.pathname)}}catch(e){this.setState({errorMessage:e.message})}}),B(this,`addFiles`,QN(e=>{let{addedFiles:t}=this.addMissingFiles(e);this.clearImageShapeCache(t),this.scene.triggerUpdate(),this.addNewImagesToImageCache()})),B(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===L.svg))try{let t=Oe(Ye(le(e.dataURL)),L.svg);e.dataURL!==t&&(e.version=(e.version??1)+1,e.dataURL=t)}catch(e){console.error(e)}return this.files=n,{addedFiles:r}}),B(this,`updateScene`,QN(e=>{let{elements:t,appState:n,collaborators:r,captureUpdate:i}=e;if(i){let e=t||void 0,r=n?ic({...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}))})),B(this,`applyDeltas`,(e,t)=>{let n=us.squash(...e),r={...this.state},i=new Map(this.scene.getElementsMapIncludingDeleted());return us.applyTo(n,i,r,t)}),B(this,`mutateElement`,(e,t,n=!0)=>this.scene.mutateElement(e,t,{informMutation:n,isDragging:!1})),B(this,`triggerRender`,e=>{e===!0?this.scene.triggerUpdate():this.setState({})}),B(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}),B(this,`updateCurrentCursorPosition`,QN(e=>{this.viewport.lastPosition.x=e.clientX,this.viewport.lastPosition.y=e.clientY})),B(this,`onKeyDown`,QN(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}})),!gn(e.target)){if((e.key===I.ESCAPE||e.key===I.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let t=is(this.scene.getNonDeletedElementsMap(),this.state);if(t.length===1&&it(t[0])&&e.key===I.ENTER){this.startImageCropping(t[0]);return}if(e.key===I.ESCAPE)this.updateEditorAtom(HO,null);else if(e.key===I.TAB&&(document.activeElement===this.excalidrawContainerRef?.current||document.activeElement?.classList.contains(Os.CONVERT_ELEMENT_TYPE_POPUP))){e.preventDefault();let n=YO(t);Sb.get(HO)?.type===`panel`&&JO(this,{conversionType:n,direction:e.shiftKey?`left`:`right`})&&this.store.scheduleCapture(),n&&this.updateEditorAtom(HO,{type:`panel`})}if(this.flowchart.handleKeyEvent(e))return}if(e[I.CTRL_OR_CMD]&&e.key===I.P&&!e.shiftKey&&!e.altKey){this.setToast({message:G(`commandPalette.shortcutHint`,{shortcut:mk(`commandPalette`)})}),e.preventDefault();return}if(e[I.CTRL_OR_CMD]&&e.key.toLowerCase()===I.V&&(LH=e.shiftKey,clearTimeout(RH),RH=window.setTimeout(()=>{LH=!1},100)),e[I.CTRL_OR_CMD]&&Ee(e.target)&&(e.code===ir.MINUS||e.code===ir.EQUAL)){e.preventDefault();return}if(Ee(e.target)&&e.key!==I.ESCAPE||To(e.key)&&gn(e.target))return;if(e.key===I.QUESTION_MARK){this.setState({openDialog:{name:`help`}});return}if(e.key.toLowerCase()===I.E&&e.shiftKey&&e[I.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===I.ALT){if(this.state.activeTool.type===`bucketfill`){this.bucketFill.openTemporaryEyeDropper(),e.preventDefault();return}ra(`COMPLEX_BINDINGS`)?this.handleSkipBindMode():Io({app:this,event:e})}if(this.actionManager.handleKeyDown(e))return;let t=this.props.viewModeEnabled===!0;if(!t&&this.state.viewModeEnabled&&e.key===I.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=xE(e.key,this,e.shiftKey);if(this.state.viewModeEnabled&&!Zt(t,[`laser`,`hand`]))return;if(t){if(this.state.activeTool.type!==t&&hw(`toolbar`,t,`keyboard (${this.editorInterface.formFactor===`phone`?`mobile`:`desktop`})`),t===`arrow`&&this.state.activeTool.type===`arrow`){let e=this.state.currentItemArrowType===Gi.sharp?Gi.round:this.state.currentItemArrowType===Gi.round?Gi.elbow:Gi.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===I.Q){this.toggleLock(`keyboard`),e.stopPropagation();return}}if(this.state.viewModeEnabled)return;if(e[I.CTRL_OR_CMD]&&!e.repeat&&(ra(`COMPLEX_BINDINGS`)&&this.resetDelayedBindMode(),(0,qc.flushSync)(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!==`enabled`})}),this.arrowText.refresh(),Io({app:this,event:e})),To(e.key)){let t=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),n=new Set;t.filter(e=>Ur(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===I.ARROW_LEFT?i=-r:e.key===I.ARROW_RIGHT?i=r:e.key===I.ARROW_UP?a=-r:e.key===I.ARROW_DOWN&&(a=r),t.forEach(e=>{this.scene.mutateElement(e,{x:e.x+i,y:e.y+a},{informMutation:!1,isDragging:!1}),zt(e,this.scene,{simultaneouslyUpdated:t})}),this.scene.triggerUpdate(),e.preventDefault()}else if(e.key===I.ENTER){let t=this.scene.getSelectedElements(this.state);if(t.length===1){let n=t[0];if(e[I.CTRL_OR_CMD]||Me(n))vo(n)&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==n.id)&&(this.store.scheduleCapture(),fe(n)||this.actionManager.executeAction(iN));else if(F(n)||tn(n)){let t;F(n)||(t=n);let r=vt(n,this.scene.getNonDeletedElementsMap()),i=r.x,a=r.y;this.startTextEditing({sceneX:i,sceneY:a,container:t}),e.preventDefault();return}else P(n)&&this.setState({editingFrame:n.id})}}if(e.key===I.SPACE&&VH.pointers.size===0&&(kH=!0,this.cursor.set(We.GRAB),e.preventDefault()),(e.key===I.G||e.key===I.S)&&!e.altKey&&!e[I.CTRL_OR_CMD]){let t=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type===`selection`&&!t.length)return;e.key===I.G&&(dc(this.state.activeTool.type)||t.some(e=>dc(e.type)))&&(this.setState({openPopup:`elementBackground`}),e.stopPropagation()),e.key===I.S&&(this.setState({openPopup:`elementStroke`}),e.stopPropagation())}if(!e[I.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===I.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=>F(e)||ao(e,this.scene.getNonDeletedElementsMap())))&&(e.preventDefault(),this.setState({openPopup:`fontFamily`}))}e[I.CTRL_OR_CMD]&&(e.key===I.BACKSPACE||e.key===I.DELETE)&&this.updateEditorAtom(Cj,`clearCanvas`);let n=e.key.toLocaleLowerCase(),r=n===I.S&&e.shiftKey&&!e[I.CTRL_OR_CMD],i=e.key===I.I||n===I.G&&e.shiftKey;(r||i)&&this.openEyeDropper({type:r?`stroke`:`background`})})),B(this,`onKeyUp`,QN(e=>{if(this.isInteractionEnabled()){if(e.key===I.SPACE&&(this.state.viewModeEnabled&&this.state.activeTool.type!==`laser`||this.state.openDialog?.name===`elementLinkSelector`?this.cursor.set(We.GRAB):T(this.state.activeTool.type)?this.cursor.reset():(this.cursor.applyForTool(),this.setState({selectedElementIds:ci({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),kH=!1),e.key===I.ALT&&(this.bucketFill.closeTemporaryEyeDropper(),Io({app:this,event:e})),(e.key===I.ALT&&this.state.bindMode===`skip`||!e[I.CTRL_OR_CMD]&&!Qs(this.state))&&(this.setState({bindMode:`orbit`}),this.lastPointerMoveEvent&&ra(`COMPLEX_BINDINGS`))){let e=tc({clientX:this.lastPointerMoveEvent.clientX,clientY:this.lastPointerMoveEvent.clientY},this.state),t=ec(A(e.x,e.y),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(this.state.selectedLinearElement){let e=M.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());Ur(e)&&this.handleDelayedBindModeChange(e,t)}}if(!e[I.CTRL_OR_CMD]){let t=this.state.bindingPreference===`enabled`;this.state.isBindingEnabled!==t&&((0,qc.flushSync)(()=>{this.setState({isBindingEnabled:t})}),this.arrowText.refresh()),Io({app:this,event:e})}if(To(e.key)){wn(this.scene.getSelectedElements(this.state).filter(Wa),this.scene,this.state);let e=this.scene.getNonDeletedElementsMap();this.scene.getSelectedElements(this.state).filter(Jo).forEach(t=>{t.startBinding&&this.scene.mutateElement(t,{startBinding:{...t.startBinding,...Rr(t,e.get(t.startBinding.elementId),`start`,e)}}),t.endBinding&&this.scene.mutateElement(t,{endBinding:{...t.endBinding,...Rr(t,e.get(t.endBinding.elementId),`end`,e)}})}),this.setState({suggestedBinding:null})}this.flowchart.handleKeyEvent(e)}})),B(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(zE);let r=vE.includes(e.type),i=t.toggle===!0&&r&&this.state.activeTool.type===e.type?$r(this.state,{...this.state.activeTool.lastActiveTool||{type:this.state.preferredSelectionTool.type},lastActiveTool:null}):r&&this.state.activeTool.type!==e.type?$r(this.state,{...e,lastActiveTool:this.state.activeTool}):$r(this.state,e);i.type===`hand`?this.cursor.set(We.GRAB):kH||this.cursor.applyForTool(i),yo(document.activeElement)&&this.focusContainer(),Is(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:T(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:ci({},e),selectedGroupIds:ci({},e),editingGroupId:null,multiElement:null}}:i.type===`selection`?{...e,...t,activeTool:i}:{...e,...t,activeTool:i,selectedElementIds:ci({},e),selectedGroupIds:ci({},e),editingGroupId:null,multiElement:null}})}),B(this,`setOpenDialog`,e=>{this.setState({openDialog:e})}),B(this,`isTouchScreenMultiTouchGesture`,()=>VH.pointers.size>=2),B(this,`getName`,()=>this.state.name||this.props.name||`${G(`labels.untitled`)}-${Vt()}`),B(this,`onGestureStart`,QN(e=>{this.isNavigationEnabled()&&(e.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:ci({},this.state),activeEmbeddable:null}),VH.initialScale=this.state.zoom.value)})),B(this,`onGestureChange`,QN(e=>{if(!this.isNavigationEnabled()||(e.preventDefault(),this.isTouchScreenMultiTouchGesture()))return;let t=VH.initialScale;t&&this.viewport.translate(n=>({...Li({viewportX:this.viewport.lastPosition.x,viewportY:this.viewport.lastPosition.y,nextZoom:bi(t*e.scale)},n)}),{zoomPreConstrained:!0,preserveScrollConstraintsSnapBack:!0})})),B(this,`onGestureEnd`,QN(e=>{this.isNavigationEnabled()&&(e.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:ci(this.state.previousSelectedElementIds,this.state)}),VH.initialScale=null)})),B(this,`isHittingTextAutoResizeHandle`,(e,t)=>{let n=Ca(e,this.state);return!!(n&&!n.isDeleted&&!n.autoResize&&pP(t,n,this.state.zoom.value,this.editorInterface.formFactor))}),B(this,`handleTextAutoResizeHandlePointerDown`,(e,t)=>{let n=Ca(e,this.state);return!n||!this.isHittingTextAutoResizeHandle(e,t)?!1:(this.actionManager.executeAction(vN,`ui`,n),this.cursor.reset(),!0)}),B(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&&(ao(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||sa(d),p=this.state.currentItemFontSize;if(!u&&s&&r&&!Wa(r)){let n=En(se({fontSize:p,fontFamily:d}),f),i=_(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-Pr(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||k({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?D.MIDDLE:`top`),containerId:s?r?.id:void 0,groupIds:r?.groupIds??[],lineHeight:f,angle:r?Wa(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})}),B(this,`startImageCropping`,e=>{this.store.scheduleCapture(),this.setState({croppingElementId:e.id})}),B(this,`finishImageCropping`,()=>{this.state.croppingElementId&&(this.store.scheduleCapture(),this.setState({croppingElementId:null}))}),B(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 Sc(A(t.x,t.y),A(n.x,n.y))<=35}),B(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}=tc(e,this.state);if(t.length===1&&vo(t[0])){let i=t[0];if((e[I.CTRL_OR_CMD]&&Jo(i)||Me(i))&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==i.id)){this.actionManager.executeAction(iN);return}if(this.state.selectedLinearElement&&fe(t[0])){let e=M.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:n,y:r},this.state,this.scene.getNonDeletedElementsMap()),i=e?M.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,e,this.scene.getNonDeletedElementsMap()):-1;if(i&&i>-1){this.store.scheduleCapture(),M.deleteFixedSegment(t[0],this.scene,i);let a=M.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:n,y:r},this.state,this.scene.getNonDeletedElementsMap()),o=a?M.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&&Me(i))return}if(t.length===1&&it(t[0])){this.startImageCropping(t[0]);return}if(this.cursor.reset(),Ds(this.state).length>0){let e=this.getElementAtPosition(n,r),t=e&&Ln(e,this.state.selectedGroupIds);if(t){this.store.scheduleCapture(),this.setState(n=>({...n,...Xo({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(os(t)){this.setState({activeEmbeddable:{element:t,state:`active`}});return}if(!this.state.selectedLinearElement?.isEditing){let t=!e[I.CTRL_OR_CMD]&&this.getTextBindableContainerAtPosition(n,r);if(t&&(this.state.activeTool.type===`autoshape`||Qr(t)||!Aa(t.backgroundColor)||d({point:A(n,r),element:t,elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(t)}))){let e=vt(t,this.scene.getNonDeletedElementsMap());n=e.x,r=e.y}this.startTextEditing({sceneX:n,sceneY:r,insertAtParentCenter:!e.altKey,container:t||null})}}}),B(this,`handleCanvasClick`,e=>{if(this.isInteractionEnabled()){if(e.button!==kc.MAIN){this.lastCompletedCanvasClicks=[];return}this.lastCompletedCanvasClicks=[...this.lastCompletedCanvasClicks.slice(-1),{x:e.clientX,y:e.clientY}]}}),B(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&&Uo(a,this.scene.getNonDeletedElementsMap(),this.state,A(e.x,e.y),this.editorInterface.formFactor===`phone`))return a}}),B(this,`handleElementLinkClick`,e=>{let t=Sc(A(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),A(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||t>10)return;let n=tc(this.lastPointerDownEvent,this.state),r=this.scene.getNonDeletedElementsMap(),i=Uo(this.hitLinkElement,r,this.state,A(n.x,n.y),this.editorInterface.formFactor===`phone`),a=tc(this.lastPointerUpEvent,this.state),o=Uo(this.hitLinkElement,r,this.state,A(a.x,a.y),this.editorInterface.formFactor===`phone`);if(i&&o){OO();let t=this.hitLinkElement.link;if(t){t=Ea(t);let n;if(this.props.onLinkOpen&&(n=Ns(R.EXCALIDRAW_LINK,e.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:t},n)),!n?.defaultPrevented){let e=en(t)?`_self`:`_blank`,n=window.open(void 0,e);n&&(n.opener=null,n.location=t)}}}}),B(this,`applyElementLinkHoverAffordance`,()=>this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(this.cursor.set(We.POINTER),EO(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap()),!0):(OO(),!1)),B(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}),B(this,`handleInteractiveContentPointerMove`,e=>{let t=tc(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()}),B(this,`handleInteractiveContentPointerUp`,e=>{if(this.lastPointerUpEvent=e,this.isEmbedsEnabled()&&this.handleIframeLikeCenterClick())return;let t=tc(e,this.state);this.isLinksEnabled()&&this.maybeHandleElementLinkClick(e,t)||this.state.activeEmbeddable?.state===`active`&&this.setState({activeEmbeddable:null})}),B(this,`getTopLayerFrameAtSceneCoords`,(e,t)=>{let n=this.scene.getNonDeletedElementsMap(),r=this.scene.getNonDeletedFramesLikes().filter(t=>!t.locked&&qe(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}),B(this,`updateFrameToHighlight`,e=>{this.state.frameToHighlight!==e&&this.setState({frameToHighlight:e})}),B(this,`maybeUpdateFrameToHighlightOnPointerMove`,(e,t)=>{this.state.newElement||this.state.multiElement||this.state.selectionElement||this.state.selectedElementsAreBeingDragged||this.updateFrameToHighlight(!t&&Mr(this.state.activeTool.type)?this.getTopLayerFrameAtSceneCoords(e):null)}),B(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?dt(this.scene.getElementsIncludingDeleted(),t):null;this.scene.insertElementsAtIndex(e,n)}}),B(this,`insertNewElement`,e=>{this.insertNewElements([e]);let t=e.frameId?this.scene.getNonDeletedElement(e.frameId):null;this.updateFrameToHighlight(t&&P(t)?t:null)}),B(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())&&!AH&&this.handleInteractiveContentPointerMove(e);return}this.savePointer(e.clientX,e.clientY,this.state.cursorButton),this.lastPointerMoveEvent=e.nativeEvent;let t=tc(e,this.state),{x:n,y:r}=t;if(this.lastPointerMoveCoords={x:n,y:r},this.updateMultiTouchGesture(e),kH||AH||jH||No(this.state))return;let i=CP(MH,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(We.AUTO):this.cursor.applyForTool()),this.maybeUpdateFrameToHighlightOnPointerMove({x:n,y:r},i),!this.state.newElement&&qN(this.state.activeTool.type)){let{originOffset:t,snapLines:i}=KN(this.scene.getNonDeletedElements(),this,{x:n,y:r},e,this.scene.getNonDeletedElementsMap());this.setState(e=>{let n=we(e.snapLines,i),r=e.originSnapOffset?we(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:M.handlePointerMoveInEditMode(e,n,r,this);t&&t!==this.state.selectedLinearElement&&(0,qc.flushSync)(()=>{this.setState({selectedLinearElement:t})})}if(rs(this.state.activeTool.type)){let{newElement:e}=this.state;if(!e&&Qs(this.state)){let e=A(n,r),t=this.scene.getNonDeletedElementsMap(),i=ec(e,this.scene.getNonDeletedElements(),t,Fn(this.state.zoom));i?this.setState({suggestedBinding:{element:i,midPoint:Rs(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)Sc(A(n-a,r-o),c)>=8?(this.store.scheduleCapture(),(0,qc.flushSync)(()=>{ho(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,A(n-a,r-o)]},{informMutation:!1,isDragging:!1})):this.cursor.set(We.POINTER);else if(s.length>2&&l&&Sc(A(n-a,r-o),l)<8){this.cursor.set(We.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{Hs(s,this.state.zoom.value)&&this.cursor.set(We.POINTER);let i=this.scene.getNonDeletedElementsMap();if(Jo(t)){let e=ec(A(n,r),this.scene.getNonDeletedElements(),i);ra(`COMPLEX_BINDINGS`)&&this.handleDelayedBindModeChange(t,e)}ho(this.state.selectedLinearElement,`Expected selectedLinearElement to be set to operate on a linear element`);let a=M.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=A(n,r),t=ec(e,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),Fn(this.state.zoom)),i=this.scene.getNonDeletedElementsMap();t&&!Se(e,t,i)&&this.setState({suggestedBinding:{element:t,midPoint:Rs(e,t,i,this.state.zoom)}})}let a=!!e.buttons,o=this.state.activeTool.type===`laser`;if(a||!o&&this.state.activeTool.type!==`selection`&&this.state.activeTool.type!==`lasso`&&this.state.activeTool.type!==`text`&&this.state.activeTool.type!==`eraser`)return;let s=this.scene.getNonDeletedElements(),c=this.scene.getSelectedElements(this.state);if(this.isHittingTextAutoResizeHandle(c,t)){this.cursor.set(We.POINTER);return}if(c.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`&&!(c.length===1&&fe(c[0]))&&!(vo(c[0])&&(this.editorInterface.userAgent.isMobileDevice||c[0].points.length===2))){let t=yn(s,this.state,n,r,this.state.zoom,e.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);if(t&&t.transformHandleType){this.cursor.set(Gr(t));return}}}else if(c.length>1&&!i&&this.state.openDialog?.name!==`elementLinkSelector`){let t=gt(Bs(c),n,r,this.state.zoom,e.pointerType,this.editorInterface);if(t){this.cursor.set(Gr({transformHandleType:t}));return}}if(ti(this.state))return;let l=this.getElementAtPosition(n,r,{preferSelected:!0,includeLockedElements:!0}),u=null;u=l&&l.locked?null:l;let d=this.arrowText.updateHoveredAnchor(t);if(this.handleIframeLikeElementHover({hitElement:u,scenePointer:t,moveEvent:e})||(this.hitLinkElement=this.getElementLinkAtPosition(t,l)),!this.applyElementLinkHoverAffordance()){if(o)return;u&&(u.link||Fa(u))&&this.state.selectedElementIds[u.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:`info`}):this.state.activeTool.type===`text`?this.cursor.set(d?We.POINTER:F(u)?We.TEXT:We.CROSSHAIR):!e[I.CTRL_OR_CMD]&&this.isHittingCommonBoundingBoxOfSelectedElements(t,c)?this.cursor.set(We.MOVE):this.state.viewModeEnabled?this.cursor.set(We.GRAB):this.state.openDialog?.name===`elementLinkSelector`||i?this.cursor.set(We.AUTO):!e[I.CTRL_OR_CMD]&&u?.id!==this.state.editingTextElement?.id?(u||this.isHittingCommonBoundingBoxOfSelectedElements(t,c))&&!u?.locked&&(!u||!fe(u)||!(u.startBinding||u.endBinding))&&(this.state.activeTool.type!==`lasso`||c.length>0)&&this.cursor.set(We.MOVE):this.cursor.set(We.AUTO),this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,n,r)}this.state.openDialog?.name===`elementLinkSelector`&&u?this.setState(e=>({hoveredElementIds:we(e.hoveredElementIds,Xo({editingGroupId:e.editingGroupId,selectedElementIds:{[u.id]:!0}},this.scene.getNonDeletedElements(),e,this).selectedElementIds)})):this.state.openDialog?.name===`elementLinkSelector`&&!u&&this.setState(e=>({hoveredElementIds:we(e.hoveredElementIds,{})}))}),B(this,`handleEraser`,(e,t)=>{let n=this.eraserTrail.addPointToPath(t.x,t.y,e.altKey);this.elementsPendingErasure=new Set(n),this.triggerRender()}),B(this,`handleTouchMove`,e=>{this.isInteractionEnabled()&&(PH=!0)}),B(this,`handleCanvasPointerDown`,e=>{if(!this.isInteractionEnabled()&&!this.isToolSupported(this.state.activeTool.type)){(this.isLinksEnabled()||this.isEmbedsEnabled())&&(this.lastPointerDownEvent=e),this.isNavigationEnabled()&&(this.updateGestureOnPointerDown(e),AH||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=tc(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(KL,null)),Sb.get(HO)&&this.updateEditorAtom(HO,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:ci(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`?j.EVENTUALLY:j.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=He(this.editorInterface,{isTouchScreen:!0})),AH||(this.lastPointerDownEvent=e,this.handleCanvasPanUsingWheelOrSpaceDrag(e)))return;if(this.setState({lastPointerDownWith:e.pointerType,cursorButton:`down`}),this.savePointer(e.clientX,e.clientY,`down`),e.button===kc.ERASER&&this.isInteractionEnabled()&&!this.props.activeTool&&this.state.activeTool.type!==ct.eraser){this.setState({activeTool:$r(this.state,{type:ct.eraser,lastActiveTool:this.state.activeTool})},()=>{this.handleCanvasPointerDown(e);let t=()=>{n(),r?.(),ti(this.state)&&this.setState({activeTool:$r(this.state,{...this.state.activeTool.lastActiveTool||{type:ct.selection},lastActiveTool:null})})},n=Vs(window,R.POINTER_UP,t,{once:!0}),r;requestAnimationFrame(()=>{r=this.missingPointerEventCleanupEmitter.once(t)})});return}if(e.button!==kc.MAIN&&e.button!==kc.TOUCH&&e.button!==kc.ERASER||VH.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[I.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))tr(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=>St(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=>St(this.scene.getNonDeletedElements(),e)).forEach(e=>{delete t[e.id]}))})}return{...Xo({editingGroupId:e.editingGroupId,selectedElementIds:t},this.scene.getNonDeletedElements(),e,this),showHyperlinkPopup:r.link||Fa(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===ct.frame||this.state.activeTool.type===ct.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===ct.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(R.POINTER_MOVE,c),window.addEventListener(R.POINTER_UP,l),window.addEventListener(R.KEYDOWN,u),window.addEventListener(R.KEYUP,d),s.eventListeners.onMove=c,s.eventListeners.onUp=l,s.eventListeners.onKeyUp=d,s.eventListeners.onKeyDown=u)}),B(this,`handleCanvasPointerUp`,e=>{if(!this.isInteractionEnabled()){(this.isLinksEnabled()||this.isEmbedsEnabled())&&this.handleInteractiveContentPointerUp(e);return}if(ra(`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=tc({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:{}})}),B(this,`maybeOpenContextMenuAfterPointerDownOnTouchDevices`,e=>{e.pointerType===`touch`&&(PH=!1,NH?PH=!0:NH=window.setTimeout(()=>{NH=0,PH||this.handleCanvasContextMenu(e)},500))}),B(this,`resetContextMenuTimer`,()=>{clearTimeout(NH),NH=0,PH=!1}),B(this,`maybeCleanupAfterMissingPointerUp`,e=>{BH?.(),this.missingPointerEventCleanupEmitter.trigger(e).clear()}),B(this,`handleCanvasPanUsingWheelOrSpaceDrag`,e=>{if(!(VH.pointers.size<=1&&((e.button===kc.WHEEL||e.button===kc.MAIN&&kH||No(this.state))&&(this.isInteractionEnabled()||this.isNavigationEnabled())||this.state.viewModeEnabled&&!this.isActiveToolPointerCapturing())))return!1;AH=!0,this.focusContainer(),this.state.editingTextElement||e.preventDefault();let t=!1,n=/Linux/.test(window.navigator.platform);this.cursor.set(We.GRABBING);let{clientX:r,clientY:i}=e,a=$N(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(R.PASTE,e),t.stopPropagation()},n=()=>{setTimeout(()=>{document.body.removeEventListener(R.PASTE,e),window.removeEventListener(R.POINTER_UP,n)},100)};document.body.addEventListener(R.PASTE,e),window.addEventListener(R.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=QN(BH=()=>{BH=null,AH=!1,kH||this.cursor.reset(),this.setState({cursorButton:`up`},this.viewport.releaseOverscroll),this.savePointer(e.clientX,e.clientY,`up`),window.removeEventListener(R.POINTER_MOVE,a),window.removeEventListener(R.POINTER_UP,o),window.removeEventListener(R.BLUR,o),a.flush()});return window.addEventListener(R.BLUR,o),window.addEventListener(R.POINTER_MOVE,a,{passive:!0}),window.addEventListener(R.POINTER_UP,o),!0}),B(this,`updateMultiTouchGesture`,e=>{VH.pointers.has(e.pointerId)&&VH.pointers.set(e.pointerId,{x:e.clientX,y:e.clientY});let t=VH.initialScale;if(VH.pointers.size===2&&VH.lastCenter&&t&&VH.initialDistance){let e=xN(VH.pointers),n=e.x-VH.lastCenter.x,r=e.y-VH.lastCenter.y;VH.lastCenter=e;let i=SN(Array.from(VH.pointers.values())),a=this.state.activeTool.type===`freedraw`&&this.state.penMode?1:i/VH.initialDistance,o=a?bi(t*a):this.state.zoom.value;this.setState(t=>{let i=Li({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 VH.lastCenter=VH.initialDistance=VH.initialScale=null}),B(this,`clearSelectionIfNotUsingSelection`,()=>{T(this.state.activeTool.type)||this.setState({selectedElementIds:ci({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}),B(this,`handleSelectionOnPointerDown`,(e,t)=>{if(T(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&&!fe(i[0])&&!(vo(i[0])&&(this.editorInterface.userAgent.isMobileDevice||i[0].points.length===2))&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let r=yn(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=gt(Bs(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=ba(yt(t.resize.handleType,i,r,t.origin.x,t.origin.y)),i.length===1&&vo(i[0])&&i[0].points.length===2&&(t.resize.arrowDirection=jn(t.resize.handleType,i[0]));else{if(this.state.selectedLinearElement){let n=this.state.selectedLinearElement,r=M.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=M.getElement(n.elementId,i);if(a&&Ur(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?ci({[e.selectedLinearElement.elementId]:!0},this.state):ci({},e)}));else if(a!=null){if(e[I.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=>({...ve(e,a),previousSelectedElementIds:this.state.selectedElementIds})),!1);this.state.selectedElementIds[a.id]||(this.state.editingGroupId&&!Ks(a,this.state.editingGroupId)&&this.setState({selectedElementIds:ci({},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))tr(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=>St(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=>St(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})),{...Xo({editingGroupId:e.editingGroupId,selectedElementIds:t},this.scene.getNonDeletedElements(),e,this),showHyperlinkPopup:a.link||Fa(a)?`info`:!1}}),t.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1}),B(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);Qr(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:$r(this.state,{type:this.state.preferredSelectionTool.type})},()=>this.cursor.reset())}),B(this,`handleFreeDrawElementOnPointerDown`,(e,t,n)=>{let[r,i]=co(n.origin.x,n.origin.y,null),a=this.getTopLayerFrameAtSceneCoords({x:r,y:i}),o=e.pressure===.5,s=this.state.currentItemStrokeVariability,c=Wo({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`?si:hs},locked:!1,frameId:a?a.id:null,points:[A(0,0)],pressures:o?[]:[e.pressure]});this.insertNewElement(c),this.setState(e=>{let t={...e.selectedElementIds};return delete t[c.id],{selectedElementIds:ci(t,e)}}),this.setState({newElement:c,suggestedBinding:null})}),B(this,`insertIframeElement`,({sceneX:e,sceneY:t,width:n,height:r})=>{let[i,a]=co(e,t,this.lastPointerDownEvent?.[I.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),o=ne({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}),B(this,`insertEmbeddableElement`,({sceneX:e,sceneY:t,link:n})=>{let[r,i]=co(e,t,this.lastPointerDownEvent?.[I.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=ya(n);if(!a)return;a.error instanceof URIError&&this.setToast({message:G(`toast.unrecognizedLinkFormat`),closable:!0});let o=ar({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}),B(this,`newImagePlaceholder`,({sceneX:e,sceneY:t,addToFrameUnderCursor:n=!0})=>{let[r,i]=co(e,t,this.lastPointerDownEvent?.[I.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})}),B(this,`handleLinearElementOnPointerDown`,(e,t,n)=>{if(e.ctrlKey&&(0,qc.flushSync)(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!==`enabled`})}),this.state.multiElement){let{multiElement:t,selectedLinearElement:r}=this.state;if(ho(r,`selectedLinearElement is expected to be set`),t.type===`line`&&Hs(t.points,this.state.zoom.value)){(0,qc.flushSync)(()=>{this.setState({selectedLinearElement:{...r,lastCommittedPoint:t.points[t.points.length-1],initialState:{...r.initialState,lastClickedPoint:-1}}})}),this.actionManager.executeAction(zE);return}if(fe(t)&&t.points.length>1){this.actionManager.executeAction(zE,`ui`,{event:e.nativeEvent,sceneCoords:{x:n.origin.x,y:n.origin.y}});return}let{x:i,y:a}=t,{lastCommittedPoint:o}=r,s=tc(e,this.state),{start:c,end:l}=Ur(t)&&Qs(this.state)?ps(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&&!Se(l.focusPoint,l.element,u),f=l.mode===`orbit`&&t.startBinding?.elementId!==l.element?.id,p=o&&Sc(A(n.origin.x-i,n.origin.y-a),o)<8;if(f||d||t.points.length>1&&p){this.actionManager.executeAction(zE,`ui`,{event:e.nativeEvent,sceneCoords:{x:n.origin.x,y:n.origin.y}});return}this.setState(e=>({selectedElementIds:ci({...e.selectedElementIds,[t.id]:!0},e)})),this.cursor.set(We.POINTER)}else{let[r,i]=co(n.origin.x,n.origin.y,e[I.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`?mi({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===Gi.round?{type:qi.PROPORTIONAL_RADIUS}:null,startArrowhead:c,endArrowhead:l,locked:!1,frameId:a?a.id:null,elbowed:this.state.currentItemArrowType===Gi.elbow,fixedSegments:this.state.currentItemArrowType===Gi.elbow?[]:null}):ie({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:qi.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:a?a.id:null}),d=A(n.origin.x,n.origin.y),f=this.scene.getNonDeletedElementsMap(),p=Qs(this.state)?ec(d,this.scene.getNonDeletedElements(),f):null;this.scene.mutateElement(u,{points:[A(0,0),A(0,0)]}),this.insertNewElement(u),Ur(u)&&Et(u,new Map([[0,{point:A(0,0),isDragging:!1}]]),d[0],d[1],this.scene,this.state,{newArrow:!0,altKey:e.altKey,initialBinding:!0,angleLocked:mc(e.nativeEvent)}),(0,qc.flushSync)(()=>{this.setState(t=>{let r=null,i=t.selectedElementIds;if(vo(u)){r=new M(u,this.scene.getNonDeletedElementsMap());let t=u.points.length-1;r={...r,selectedPointsIndices:[t],initialState:{...r.initialState,arrowStartIsInside:e.altKey,lastClickedPoint:t,origin:A(n.origin.x,n.origin.y)}}}return i=this.isToolLocked()?t.selectedElementIds:ci({[u.id]:!0},t),{...t,bindMode:`orbit`,newElement:u,suggestedBinding:p&&Ur(u)?{element:p,midPoint:Rs(d,p,f,this.state.zoom)}:null,selectedElementIds:i,selectedLinearElement:r}})}),Ur(u)&&ra(`COMPLEX_BINDINGS`)&&this.handleDelayedBindModeChange(u,p)}}),B(this,`createGenericElementOnPointerDown`,(e,t)=>{let[n,r]=co(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[I.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`?ar({type:`embeddable`,...a}):_c({type:e,...a}),o.type===`selection`?this.setState({selectionElement:o}):(this.insertNewElement(o),this.setState({multiElement:null,newElement:o}))}),B(this,`createFrameElementOnPointerDown`,(e,t)=>{let[n,r]=co(e.origin.x,e.origin.y,this.lastPointerDownEvent?.[I.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),i={x:n,y:r,opacity:this.state.currentItemOpacity,locked:!1,...li},a=t===ct.magicframe?nt(i):lt(i);this.insertNewElement(a),this.setState({multiElement:null,newElement:a})}),B(this,`restoreReadyToEraseElements`,()=>{this.elementsPendingErasure=new Set,this.triggerRender()}),B(this,`eraseElements`,()=>{let e=!1;this.elementsPendingErasure.forEach(e=>{let t=this.scene.getElement(e);if(Ur(t)){if(t.startBinding){let e=this.scene.getElement(t.startBinding.elementId);ur(e,this.scene.getElementsMapIncludingDeleted(),{boundElements:e.boundElements.filter(e=>e.id!==t.id)})}if(t.endBinding){let e=this.scene.getElement(t.endBinding.elementId);ur(e,this.scene.getElementsMapIncludingDeleted(),{boundElements:e.boundElements.filter(e=>e.id!==t.id)})}}else Oc(t)&&t.boundElements?.forEach(e=>{if(e.type===`arrow`){let n=this.scene.getElement(e.id);n?.startBinding?.elementId===t.id&&ur(n,this.scene.getElementsMapIncludingDeleted(),{startBinding:null}),n?.endBinding?.elementId===t.id&&ur(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)||fs(t)&&this.elementsPendingErasure.has(t.containerId)?(e=!0,z(t,{isDeleted:!0})):t);this.elementsPendingErasure=new Set,e&&(this.store.scheduleCapture(),this.scene.replaceAllElements(t))}),B(this,`initializeImage`,async(e,t)=>{if(!dr(t))throw Error(G(`errors.unsupportedFileType`));let n=t.type;if(this.cursor.set(`wait`),n===L.svg)try{t=Ra(Ye(await t.text()),t.name)}catch(e){throw console.warn(e),Error(G(`errors.svgImageInsertError`))}let r=await(this.props.generateIdForFile?.(t)||Ho(t));if(!r)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),Error(G(`errors.imageInsertError`));if(!this.files[r]?.dataURL){let{maxWidthOrHeight:e,maxFileSizeBytes:n}=this.props.imageOptions;try{t=await Kr(t,{maxWidthOrHeight:e})}catch(e){console.error(`Error trying to resizing image file on insertion`,e)}if(t.size>n)throw Error(G(`errors.fileTooBig`,{maxSize:`${Math.trunc(n/1024/1024)}MB`}))}let i=this.files[r]?.dataURL||await ye(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(G(`errors.imageInsertError`)))}})}),B(this,`getLatestInitializedImageElement`,(e,t)=>{let n=this.scene.getElement(e.id)??e;return z(n,{fileId:t})}),B(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}=tc({clientX:e,clientY:t},this.state),i=await po({description:`Image`,extensions:Object.keys(bt),multiple:!0});this.insertImages(i,n,r)}catch(e){e.name===`AbortError`?console.warn(e):console.error(e),this.setState({newElement:null,activeTool:$r(this.state,{type:this.state.preferredSelectionTool.type})},()=>{this.actionManager.executeAction(zE)})}}),B(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}}),B(this,`updateImageCache`,async(e,t=this.files)=>{let{updatedFiles:n,erroredFiles:r}=await ia({imageCache:this.imageCache,fileIds:e.map(e=>e.fileId),files:t});return r.size&&(this.store.scheduleAction(j.NEVER),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(e=>ac(e)&&r.has(e.fileId)?z(e,{status:`error`}):e))),{updatedFiles:n,erroredFiles:r}}),B(this,`addNewImagesToImageCache`,async(e=be(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)&&yr.delete(t);e.size&&this.scene.triggerUpdate()}}),B(this,`scheduleImageRefresh`,(0,Kc.default)(()=>{this.addNewImagesToImageCache()},500)),B(this,`handleInteractiveCanvasRef`,e=>{e===null?(this.interactiveCanvas?.removeEventListener(R.TOUCH_START,this.onTouchStart),this.interactiveCanvas?.removeEventListener(R.TOUCH_END,this.onTouchEnd)):(this.interactiveCanvas=e,this.cursor.reset(),this.interactiveCanvas.addEventListener(R.TOUCH_START,this.onTouchStart,{passive:!1}),this.interactiveCanvas.addEventListener(R.TOUCH_END,this.onTouchEnd))}),B(this,`insertImages`,async(e,t,n)=>{let r=50/this.state.zoom.value,i=l(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 ua(e[n]))}catch(e){return this.setState({errorMessage:e.message||G(`errors.imageInsertError`)}),z(t,{isDeleted:!0})}})),o=ze(a),s=l(a.filter(e=>!e.isDeleted),t,n,r),c=ze(s),u=this.scene.getElementsIncludingDeleted().map(e=>c.get(e.id)??o.get(e.id)??e);this.updateScene({appState:{selectedElementIds:ci(Object.fromEntries(s.map(e=>[e.id,!0])),this.state)},elements:u,captureUpdate:j.IMMEDIATELY}),this.setState({},()=>{this.actionManager.executeAction(zE)})}),B(this,`handleAppOnDrop`,async e=>{if(!this.isInteractionEnabled())return;let{x:t,y:n}=tc(e,this.state),r=await cD(e),i=r.getFiles();if(i.length===1){let{file:e,fileHandle:t}=i[0];if(e&&(e.type===L.png||e.type===L.svg))try{let n=await Lr(e,this.state,this.scene.getElementsIncludingDeleted(),t);this.syncActionResult({...n,appState:{...n.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:j.IMMEDIATELY});return}catch(e){if(e.name!==`EncodingError`)throw Error(G(`alerts.couldNotLoadInvalidFile`))}}let a=i.map(e=>e.file).filter(e=>dr(e));if(a.length>0&&this.isToolSupported(`image`))return this.insertImages(a,t,n);let o=r.getData(L.excalidrawlibIds),s=r.getData(L.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=Es(s));t?.length&&(t=t.map(e=>({...e,elements:Ei({type:`everything`,elements:e.elements,randomizeSeed:!0,preserveFrameChildrenOrder:!0}).duplicatedElements})),this.addElementsFromPasteOrLibrary({elements:Ik(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(L.text);if(c){let e=c.value;if(e&&Ac(e,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(e)||ya(e)?.type===`video`)){let r=this.insertEmbeddableElement({sceneX:t,sceneY:n,link:Ea(e)});r&&(this.store.scheduleCapture(),this.setState({selectedElementIds:{[r.id]:!0}}))}}}),B(this,`loadFileToCanvas`,async(e,t)=>{e=await ua(e);try{let n=this.scene.getElementsIncludingDeleted(),r;try{r=await In(e,this.state,n,t)}catch(e){let t=e instanceof Co;if(t&&e.code===`IMAGE_NOT_CONTAINS_SCENE_DATA`&&!this.isToolSupported(`image`)){this.setState({isLoading:!1,errorMessage:G(`errors.imageToolNotSupported`)});return}let n=G(t?`alerts.cannotRestoreFromImage`:`alerts.couldNotLoadInvalidFile`);this.setState({isLoading:!1,errorMessage:n})}if(!r)return;r.type===L.excalidraw?(ui(n.concat(r.data.elements)),this.store.scheduleMicroAction({action:j.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:j.IMMEDIATELY})):r.type===L.excalidrawlib&&await this.library.updateLibrary({libraryItems:e,merge:!0,openLibraryMenu:!0}).catch(e=>{console.error(e),this.setState({errorMessage:G(`errors.importLibraryError`)})})}catch(e){this.setState({isLoading:!1,errorMessage:e.message})}}),B(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!==kc.SECONDARY)&&this.state.activeTool.type!==this.state.preferredSelectionTool.type))return;let{x:t,y:n}=tc(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;hw(`contextMenu`,`openContextMenu`,o),this.setState({...r&&!this.state.selectedElementIds[r.id]?{...this.state,...Xo({editingGroupId:this.state.editingGroupId,selectedElementIds:{[r.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:vo(r)?new M(r,this.scene.getNonDeletedElementsMap()):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:u,left:l,items:this.getContextMenuItems(o)}})})}),B(this,`maybeDragNewGenericElement`,(e,t,n=!0)=>{let r=this.state.selectionElement,i=e.lastCoords;if(r&&e.boxSelection.hasOccurred&&this.state.activeTool.type!==`eraser`){st({newElement:r,elementType:this.state.activeTool.type,originX:e.origin.x,originY:e.origin.y,x:i.x,y:i.y,width:ws(e.origin.x,i.x),height:ws(e.origin.y,i.y),shouldMaintainAspectRatio:uc(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]=co(i.x,i.y,t[I.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),c=ac(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}=GN(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}),Ur(a)||st({newElement:a,elementType:this.state.activeTool.type,originX:e.originInGrid.x,originY:e.originInGrid.y,x:o,y:s,width:ws(e.originInGrid.x,o),height:ws(e.originInGrid.y,s),shouldMaintainAspectRatio:it(a)?!uc(t):uc(t),shouldResizeFromCenter:vs(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===ct.frame||this.state.activeTool.type===ct.magicframe)&&this.setState({elementsToHighlight:js(this.scene.getNonDeletedElements(),a,this.state,this.scene.getNonDeletedElementsMap())})}),B(this,`maybeHandleCrop`,(e,t)=>{if(!this.state.croppingElementId)return!1;let n=e.resize.handleType,r=e.lastCoords,[i,a]=co(r.x-e.resize.offset.x,r.y-e.resize.offset.y,t[I.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),o=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(n&&o&&it(o)){let s=e.originalElements.get(o.id),c=ac(o)&&this.imageCache.get(o.fileId)?.image;if(s&&it(s)&&c&&!(c instanceof Promise)){let[l,u]=co(r.x,r.y,t[I.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}=WN([o],[s],this,t,d,n);this.scene.mutateElement(o,Ec(o,this.scene.getNonDeletedElementsMap(),n,c.naturalWidth,c.naturalHeight,i+f.x,a+f.y,t.shiftKey?s.width/s.height:void 0)),zt(o,this.scene),this.setState({isCropping:n&&n!==`rotation`,snapLines:p})}return!0}return!1}),B(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&&fe(n[0])||this.state.croppingElementId)return!1;this.setState({isResizing:i&&i!==`rotation`,isRotating:i===`rotation`,activeEmbeddable:null});let a=e.lastCoords,[o,s]=co(a.x-e.resize.offset.x,a.y-e.resize.offset.y,t[I.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),c=new Map;if(r.forEach(e=>{tr(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]=co(a.x,a.y,t[I.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}=WN(n,is(u,this.state),this,t,l,i);o+=d.x,s+=d.y,this.setState({snapLines:f})}if(On(e.originalElements,i,n,this.scene,mc(t),vs(t),n.some(e=>it(e))?!uc(t):uc(t),o,s,e.resize.center.x,e.resize.center.y)){let e=new Set;return r.forEach(t=>{js(this.scene.getNonDeletedElements(),t,this.state,this.scene.getNonDeletedElementsMap()).forEach(t=>{Un(t)?e.add(t):console.error(`[NONDELETED][INVARIANT] Skipped highlighting deleted element in resizing frame`)})}),this.setState({elementsToHighlight:[...e]}),!0}return!1}),B(this,`getContextMenuItems`,e=>{let t=[];if(t.push(nO,tO),e===`canvas`)return this.state.viewModeEnabled?[...t,iO,aO,rj,lO]:[$D,EI,nO,tO,rO,EI,fw,NO,EI,iO,oO,sO,cO,aO,rj,lO];if(t.push(rO),this.state.viewModeEnabled)return[QD,...t];let n=this.editorInterface.formFactor===`desktop`?[EI,cw,lw,uw,dw]:[];return[EI,eO,QD,$D,EI,cN,lN,uN,EI,oN,EI,...t,EI,AD,jD,EI,FD,vN,uO,dO,mO,ID,EI,UD,...n,EI,JD,YD,EI,iN,EI,AO,dk,EI,pw,MO,EI,sw]}),B(this,`handleWheel`,QN(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(Os.FRAME_NAME))){e[I.CTRL_OR_CMD]&&e.preventDefault();return}if(e.preventDefault(),AH)return;let{deltaX:t,deltaY:n}=e;if(e.metaKey||e.ctrlKey){let e=Math.sign(n),t=an*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:Yo;a=Math.max(a,o),this.viewport.translate(e=>({...Li({viewportX:this.viewport.lastPosition.x,viewportY:this.viewport.lastPosition.y,nextZoom:bi(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}))})),B(this,`savePointer`,(e,t,n)=>{if(!this.isInteractionEnabled()&&!this.isToolSupported(this.state.activeTool.type)||!e||!t)return;let{x:r,y:i}=tc({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:VH.pointers})}),B(this,`resetShouldCacheIgnoreZoomDebounced`,Ss(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300)),B(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()}}),B(this,`refresh`,()=>{this.setState({...this.getCanvasOffsets()})}),B(this,`watchState`,()=>{});let n=kr(),{viewModeEnabled:r=!1,zenModeEnabled:i=!1,gridModeEnabled:a=!1,objectsSnapModeEnabled:o=!1,theme:s=n.theme,name:c=`${G(`labels.untitled`)}-${Vt()}`}=t,u=null;t.activeTool&&(t.activeTool.type===`image`?console.warn(`"image" tool cannot be forced via "props.activeTool"`):this.isToolSupported(t.activeTool.type,t)?u=$r(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:s,exportWithDarkMode:s===N.DARK,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:!this.isInteractionEnabled(t)||r,activeTool:u??n.activeTool,zenModeEnabled:i,objectsSnapModeEnabled:o,gridModeEnabled:a??n.gridModeEnabled,name:c,width:window.innerWidth,height:window.innerHeight},this.refreshEditorInterface(),this.stylesPanelMode=rt(this.editorInterface),this.id=_i(),this.library=new Fk(this),this.actionManager=new bN(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new Ka,this.canvas=document.createElement(`canvas`),this.rc=Ii.canvas(this.canvas),this.renderer=new JN(this.scene),this.visibleElements=[],this.store=new So(this),this.history=new pN(this.store),this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new vn(this.scene),this.history=new pN(this.store),this.actionManager.registerAll(iw),this.actionManager.registerAction(gN(this.history)),this.actionManager.registerAction(_N(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(Wr).includes(n)&&FH.set(e,n)}break}}handleSkipBindMode(){if(this.state.selectedLinearElement?.initialState&&!this.state.selectedLinearElement.initialState.arrowStartIsInside){ho(this.lastPointerMoveCoords,`Missing last pointer move coords when changing bind skip mode for arrow start`);let e=this.scene.getNonDeletedElementsMap(),t=ec(A(this.lastPointerMoveCoords.x,this.lastPointerMoveCoords.y),this.scene.getNonDeletedElements(),e),n=M.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,qc.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;ho(n,`Last event must exist`);let r=e-this.state.selectedLinearElement.pointerOffset.x,i=t-this.state.selectedLinearElement.pointerOffset.y,a=this.state.multiElement?M.handlePointerMove(n,this,r,i,this.state.selectedLinearElement):M.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||fe(e))return;let n=()=>{if(this.bindModeHandler=null,ho(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=ec(A(t,n),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(r&&this.state.bindMode!==`skip`){ho(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,qc.flushSync)(()=>{ho(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;ho(a,`Last event must exist`);let o=t-this.state.selectedLinearElement.pointerOffset.x,s=n-this.state.selectedLinearElement.pointerOffset.y,c=this.state.multiElement?M.handlePointerMove(a,this,o,s,this.state.selectedLinearElement):M.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&&f(o,n),l=s&&f(s,n);r=!!(c&&l&&o.id!==s.id&&qs(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,qc.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!==kc.MAIN||kH||!Zt(this.state.activeTool.type,[`laser`,`selection`,`lasso`]))return!1;let e=A(tc({clientX:this.lastPointerDownEvent.clientX,clientY:this.lastPointerDownEvent.clientY},this.state)),t=A(tc({clientX:this.lastPointerUpEvent.clientX,clientY:this.lastPointerUpEvent.clientY},this.state));if(Sc(e,t)>10)return!1;let n=this.getElementAtPosition(e[0],e[1]);if(!(n&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<=300&&VH.pointers.size<2&&os(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),Qt(r)))return!0;let i=this.getHTMLIFrameElement(r);if(!i?.contentWindow)return!0;if(i.src.includes(`youtube`)){let e=FH.get(r.id);switch(e||(FH.set(r.id,Wr.UNSTARTED),i.contentWindow.postMessage(JSON.stringify({event:`listening`,id:r.id}),`*`)),e){case Wr.PLAYING:case Wr.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=>Fa(e)&&this.embedsValidationStatus.get(e.id)===!0||Qt(e));return(0,H.jsx)(H.Fragment,{children:r.map(r=>{let{x:i,y:a}=dn({sceneX:r.x,sceneY:r.y},this.state),o=Ai(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(Qt(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:()=>Oo(`
83
- <style>
84
- html, body {
85
- width: 100%;
86
- height: 100%;
87
- color: ${this.state.theme===N.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:()=>Oo(`
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: ${Tt.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=ya(_t(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=bs(d?e:1,.75,IH);return(0,H.jsx)(`div`,{className:U(`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:Sn(r,Wt(r,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name===`elementLinkSelector`?Hr:1),"--embeddable-radius":`${ns(Math.min(r.width,r.height),r)}px`},children:(0,H.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?Ya.enabled:Ya.disabled},children:[u&&(0,H.jsx)(`div`,{className:`excalidraw__embeddable-hint`,children:G(`buttons.embeddableInteractionButton`)}),(0,H.jsx)(`div`,{className:`excalidraw__embeddable__outer`,style:{padding:`${r.strokeWidth}px`},children:(0,H.jsx)(`div`,{className:`excalidraw__embeddable__content`,style:{width:`${f*100}%`,height:`${f*100}%`,transform:`scale(${1/f})`},children:(Fa(r)?this.props.renderEmbeddable?.(r,this.state):null)??(0,H.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=Sb.get(HO)?.type===`panel`;return(0,H.jsx)(`div`,{translate:`no`,className:U(`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?Ya.disabled:Ya.enabled,"--right-sidebar-width":`${uI}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,H.jsx)(mH.Provider,{value:this.api,children:(0,H.jsx)(iH.Provider,{value:this,children:(0,H.jsx)(aH.Provider,{value:this.props,children:(0,H.jsx)(lH.Provider,{value:this.excalidrawContainerValue,children:(0,H.jsx)(sH.Provider,{value:this.editorInterface,children:(0,H.jsx)(fH.Provider,{value:this.setAppState,children:(0,H.jsx)(dH.Provider,{value:this.state,children:(0,H.jsxs)(uH.Provider,{value:this.scene.getNonDeletedElements(),children:[(0,H.jsxs)(pH.Provider,{value:this.actionManager,children:[(0,H.jsx)(rV,{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:jb().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,H.jsx)(`div`,{className:`excalidraw-textEditorContainer`}),(0,H.jsx)(`div`,{className:`excalidraw-contextMenuContainer`}),(0,H.jsx)(`div`,{className:`excalidraw-eye-dropper-container`}),(0,H.jsx)(aV,{trails:[this.laserTrails,this.lassoTrail,this.eraserTrail,this.drawShape.trail]}),this.isDefaultUIEnabled()&&(0,H.jsx)(tH,{}),this.isDefaultUIEnabled()&&e.length===1&&this.state.openDialog?.name!==`elementLinkSelector`&&this.state.showHyperlinkPopup&&(0,H.jsx)(SO,{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&&me(u)&&(0,H.jsx)(ZN,{element:u,elementsMap:i,children:(0,H.jsx)(iV,{title:G(`labels.convertToCode`),icon:hC,checked:!1,onChange:()=>this.onMagicFrameGenerate(u,`button`)})}),this.isDefaultUIEnabled()&&e.length===1&&Qt(u)&&u.customData?.generationData?.status===`done`&&(0,H.jsxs)(ZN,{element:u,elementsMap:i,children:[(0,H.jsx)(iV,{title:G(`labels.copySource`),icon:tC,checked:!1,onChange:()=>this.onIframeSrcCopy(u)}),(0,H.jsx)(iV,{title:`Enter fullscreen`,icon:gC,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,H.jsx)(DI,{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,H.jsx)(UV,{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:kN(this),renderLinks:this.isLinksEnabled(),canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:this.flowchart.pendingNodes,theme:this.state.theme}}),s&&(0,H.jsx)(qV,{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,H.jsx)(BV,{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,H.jsx)(OI,{border:this.props.viewportStatusFrame.border}),this.renderFrameNames(),this.isDefaultUIEnabled()&&this.state.activeLockedId&&(0,H.jsx)(rH,{app:this,activeLockedId:this.state.activeLockedId}),this.isDefaultUIEnabled()&&d&&(0,H.jsx)(lk,{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=Gn(this.scene.getNonDeletedElements(),e,this.scene.getNonDeletedElementsMap()).filter(e=>!me(e));if(!r.length){t===`button`?(this.setState({errorMessage:`Cannot generate from an empty frame`}),hw(`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}}),hw(`ai`,`generate (start)`,`d2c`);try{let{html:t}=await n({frame:e,children:r});if(hw(`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){hw(`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`&&(dD(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=>{ac(e)&&t[e.fileId]&&(this.imageCache.delete(e.fileId),yr.delete(e))})}async componentDidMount(){this.unmounted=!1,this.api=this.createExcalidrawAPI(),this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,(zi()||ht())&&(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(),Ia&&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),Kt()&&!jt()&&this.setState({errorMessage:(0,H.jsx)(CI,{})});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 Ka,this.fonts=new vn(this.scene),this.renderer=new JN(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(),yr.destroy(),ON.destroy(),clearTimeout(NH),Ki.clearCache(),Xo.clearCache(),NH=0,document.documentElement.style.overscrollBehaviorX=``}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){if(this.removeEventListeners(),this.onRemoveEventListenersEmitter.once(Vs(window,R.MESSAGE,this.onWindowMessage,!1),Vs(document,R.POINTER_UP,this.removePointer,{passive:!1}),Vs(document.fonts,`loadingdone`,e=>{let t=e.fontfaces;this.fonts.onLoaded(t)},{passive:!1}),Vs(window,R.FOCUS,()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.isInteractionEnabled()){this.isNavigationEnabled()&&this.onRemoveEventListenersEmitter.once(Vs(this.excalidrawContainerRef.current,R.WHEEL,this.handleWheel,{passive:!1}),Vs(this.props.handleKeyboardGlobally?document:this.excalidrawContainerRef.current,R.KEYDOWN,this.handleNavigationModeKeyDown,!1),Vs(document,R.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),Vs(document,R.GESTURE_START,this.onGestureStart,!1),Vs(document,R.GESTURE_CHANGE,this.onGestureChange,!1),Vs(document,R.GESTURE_END,this.onGestureEnd,!1)),this.isBrowserZoomEnabled()||(this.isNavigationEnabled()||this.onRemoveEventListenersEmitter.once(Vs(this.excalidrawContainerRef.current,R.WHEEL,this.preventBrowserZoomWheel,{passive:!1}),Vs(this.excalidrawContainerRef.current,R.GESTURE_START,this.disableEvent,!1),Vs(this.excalidrawContainerRef.current,R.GESTURE_CHANGE,this.disableEvent,!1),Vs(this.excalidrawContainerRef.current,R.GESTURE_END,this.disableEvent,!1)),this.onRemoveEventListenersEmitter.once(Vs(this.props.handleKeyboardGlobally?document:this.excalidrawContainerRef.current,R.KEYDOWN,this.preventBrowserZoomKeyDown,!1)));return}this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(Vs(document,R.KEYDOWN,this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(Vs(this.excalidrawContainerRef.current,R.WHEEL,this.handleWheel,{passive:!1}),Vs(document,R.COPY,this.onCopy,{passive:!1}),Vs(document,R.KEYUP,this.onKeyUp,{passive:!0}),Vs(document,R.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),Vs(document,R.GESTURE_START,this.onGestureStart,!1),Vs(document,R.GESTURE_CHANGE,this.onGestureChange,!1),Vs(document,R.GESTURE_END,this.onGestureEnd,!1)),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(Vs(document,R.FULLSCREENCHANGE,this.onFullscreenChange,{passive:!1}),Vs(document,R.PASTE,this.pasteFromClipboard,{passive:!1}),Vs(document,R.CUT,this.onCut,{passive:!1}),Vs(window,R.RESIZE,this.onResize,!1),Vs(window,R.UNLOAD,this.onUnload,!1),Vs(window,R.BLUR,this.onBlur,!1),Vs(this.excalidrawContainerRef.current,R.WHEEL,this.handleWheel,{passive:!1}),Vs(this.excalidrawContainerRef.current,R.DRAG_OVER,this.disableEvent,!1),Vs(this.excalidrawContainerRef.current,R.DROP,this.disableEvent,!1)),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(Vs(Ti(this.excalidrawContainerRef.current),R.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)===N.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&&ti(this.state)&&this.setState({activeTool:$r(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(),ti(t)&&!ti(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===N.DARK),this.state.selectedLinearElement?.isEditing&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.actionManager.executeAction(zE)});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:ci(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(){EH=!1,OH=null}async insertClipboardContent(e,t,r){let{x:i,y:a}=tc({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=UF(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(Ra(t))}if(o.length>0){this.isToolSupported(`image`)?await this.insertImages(o,i,a):this.setState({errorMessage:G(`errors.imageToolNotSupported`)});return}if(e.elements){let t=e.programmaticAPI?xi(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&&wP(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=xi(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=oc(e.text).split(/\n+/).map(e=>e.trim()).filter(Boolean),c=s.map(e=>ks(e)).filter(e=>Ac(e,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(e)||ya(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:Ea(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 Gt(e)}}catch(e){let t=e.message;return e.cause===`FETCH_ERROR`?t=G(`errors.failedToFetchImage`):e.cause===`UNSUPPORTED`&&(t=G(`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}=tc({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:ft,verticalAlign:`top`,locked:!1},a=se({fontSize:i.fontSize,fontFamily:i.fontFamily}),o=sa(i.fontFamily),[s,,c]=ce(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=wt(t).trim();if(s.length){let t=this.getTopLayerFrameAtSceneCoords({x:n,y:u}),r=xa(s,a,o),c=r.width>l,d=c?yc(s,a,l):s;r=c?xa(d,a,o):r;let f=n-r.width/2,p=u-r.height/2,m=k({...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+=Pr(i.fontSize,o)+10);return e},[]);f.length!==0&&(this.insertNewElements(f),this.store.scheduleCapture(),this.setState({selectedElementIds:ci(Object.fromEntries(f.map(e=>[e.id,!0])),this.state)}),!t&&f.length>1&&zH===!1&&this.editorInterface.formFactor!==`phone`&&(this.setToast({message:G(`toast.pasteAsSingleElement`,{shortcut:Z(`CtrlOrCmd+Shift+V`)}),duration:5e3}),zH=!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&&F(i)?z(i,{originalText:t,isDeleted:n??i.isDeleted,...Yr(i,bo(i,r),r,t)}):i)])};this.textWysiwygSubmitHandler=vP({canvas:this.canvas,getViewportCoords:(e,t)=>{let{x:n,y:r}=dn({sceneX:e,sceneY:t},this.state);return[n-this.state.offsetLeft,r-this.state.offsetTop]},onChange:QN(t=>{i(t,!1),Un(e)&&zt(e,this.scene)}),onSubmit:QN(({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,qc.flushSync)(()=>{this.setState(e=>({selectedElementIds:ci({...e.selectedElementIds,[o]:!0},e)}))}),a&&ys(this.scene.getNonDeletedElements(),[e]),(!a||t)&&this.store.scheduleCapture(),(0,qc.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:ci({},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 F(n)?n:e?ao(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(F(r))return null;if(!tn(r))return;let i=this.getSelectedTextElement(r),a=this.getTextElementAtPosition(t.x,t.y);if(!(!i||a?.id!==i.id))return r}getTextElementAtPosition(e,t){let n=this.getElementAtPosition(e,t,{includeBoundTextElement:!0});return n&&F(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 d({point:A(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||!(F(e)&&e.containerId)))).filter(n=>this.hitElement(e,t,n)).filter(n=>{let r=Wt(n,i);return r&&!Un(r)&&console.error(`[NONDELETED][INVARIANT] Containing frame is deleted`),r&&this.state.frameRendering.enabled&&this.state.frameRendering.clip&&!os(n)?qe({x:e,y:t},r,i):!0}).filter(e=>!os(e)||(r.push(e),!1)).concat(r)}getElementHitThreshold(e){return Math.max(e.strokeWidth/2+.1,.85*(bn/this.state.zoom.value))}hitElement(e,t,n,r=!0){return r&&this.state.selectedElementIds[n.id]&&pc([n],this.state,this.editorInterface)&&mt(A(e,t),n,this.scene.getNonDeletedElementsMap(),this.getElementHitThreshold(n))||oa(A(e,t),n,this.scene.getNonDeletedElementsMap())?!0:d({point:A(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 Hi(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]=E(n[r],this.scene.getNonDeletedElementsMap());if(Wa(n[r])&&d({point:A(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 Hi(i,!1)?i:null}isEditingTextContent(){return!!this.state.editingTextElement||F(this.state.newElement)}handleHoverSelectedLinearElement(e,t,n){let r=this.scene.getNonDeletedElementsMap(),i=M.getElement(e.elementId,r);if(i){if(this.state.selectedLinearElement){let a=-1,o=null;d({point:A(t,n),element:i,elementsMap:r,threshold:this.getElementHitThreshold(i)})?(a=M.getPointIndexUnderCursor(i,r,this.state.zoom,t,n),o=M.getSegmentMidpointHitCoords(e,{x:t,y:n},this.state,this.scene.getNonDeletedElementsMap()),(fe(i)?a===0||a===i.points.length-1:a>=0)||o?this.cursor.set(We.POINTER):this.hitElement(t,n,i)&&(!fe(i)||!(i.startBinding||i.endBinding))&&(this.state.activeTool.type!==`lasso`||Object.keys(this.state.selectedElementIds).length>0)&&this.cursor.set(We.MOVE)):this.hitElement(t,n,i)&&(!fe(i)||!(i.startBinding||i.endBinding))&&(this.state.activeTool.type!==`lasso`||Object.keys(this.state.selectedElementIds).length>0)&&this.cursor.set(We.MOVE),this.state.selectedLinearElement.hoverPointIndex!==a&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:a}}),M.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,o)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:o}});let s=null,c=i;(c.startBinding||c.endBinding)&&(s=Er(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(We.POINTER)}else this.cursor.set(We.AUTO)}}updateGestureOnPointerDown(e){VH.pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),VH.pointers.size===2&&(VH.lastCenter=xN(VH.pointers),VH.initialScale=this.state.zoom.value,VH.initialDistance=SN(Array.from(VH.pointers.values())))}initialPointerDownState(e){let t=tc(e,this.state),n=this.scene.getSelectedElements(this.state),[r,i,a,o]=Bs(n),s=n.findIndex(fe)===0;return{origin:t,withCmdOrCtrl:e[I.CTRL_OR_CMD],originInGrid:ba(co(t.x,t.y,e[I.CTRL_OR_CMD]||s?null:this.getEffectiveGridSize())),scrollbars:CP(MH,e.clientX-this.state.offsetLeft,e.clientY-this.state.offsetTop),lastCoords:{...t},originalElements:this.scene.getNonDeletedElements().reduce((e,t)=>(e.set(t.id,ii(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;jH=!0,t.lastCoords.x=e.clientX,t.lastCoords.y=e.clientY;let n=$N(e=>{e.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(e,t)}),r=QN(()=>{BH=null,jH=!1,this.cursor.applyForTool(),this.setState({cursorButton:`up`}),this.savePointer(e.clientX,e.clientY,`up`),window.removeEventListener(R.POINTER_MOVE,n),window.removeEventListener(R.POINTER_UP,r),n.flush()});return BH=r,window.addEventListener(R.POINTER_MOVE,n),window.addEventListener(R.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(bn/this.state.zoom.value,1),r=4/this.state.zoom.value,[i,a,o,s]=Bs(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:at(e)?qi.ADAPTIVE_RADIUS:qi.PROPORTIONAL_RADIUS}:null}getCurrentItemStrokeWidth(e){return bc(e,this.state.currentItemStrokeWidthKey)}maybeCacheReferenceSnapPoints(e,t,n=!1){AN({event:e,app:this,selectedElements:t})&&(n||!ON.getReferenceSnapPoints())&&ON.setReferenceSnapPoints(IN(this.scene.getNonDeletedElements(),t,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(e,t,n=!1){AN({event:e,app:this,selectedElements:t})&&(n||!ON.getVisibleGaps())&&ON.setVisibleGaps(PN(this.scene.getNonDeletedElements(),t,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(e){return QN(t=>{this.maybeHandleResize(e,t)||this.maybeDragNewGenericElement(e,t)})}onKeyUpFromPointerDownHandler(e){return QN(t=>{t.key===I.ALT&&t.preventDefault(),!this.maybeHandleResize(e,t)&&this.maybeDragNewGenericElement(e,t)})}onPointerMoveFromPointerDownHandler(e){return $N(t=>{if(this.state.openDialog?.name===`elementLinkSelector`)return;let n=tc(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]=co(n.x,n.y,t[I.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),i=this.state.selectedLinearElement.initialState.segmentMidpoint.index;if(i<0){let t=M.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:e,y:r},this.state,this.scene.getNonDeletedElementsMap());i=t?M.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,t,this.scene.getNonDeletedElementsMap()):-1}let a=M.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=ba(Wi(this.scene.getSelectedElements(this.state),e.origin.x,e.origin.y))),!(t.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(t,e))return;if(ti(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]=co(n.x,n.y,t[I.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){Ha(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(M.shouldAddMidpoint(this.state.selectedLinearElement,n,this.state,o)){let e=M.addMidpoint(this.state.selectedLinearElement,n,this,!t[I.CTRL_OR_CMD],this.scene);if(!e)return;(0,qc.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=M.getElement(r.elementId,o);if(i?.isDeleted)return;if(Ur(i)){let e=ec(A(n.x,n.y),this.scene.getNonDeletedElements(),o);ra(`COMPLEX_BINDINGS`)&&this.handleDelayedBindModeChange(i,e)}if(t.altKey&&!this.state.selectedLinearElement?.initialState?.arrowStartIsInside&&ra(`COMPLEX_BINDINGS`)&&this.handleSkipBindMode(),r.initialState.lastClickedPoint===-1)return;let a=M.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||!Jn(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:x(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&&it(t)&&t.crop!==null&&e.hit.element===t){let e=t.crop,i=ac(t)&&this.imageCache.get(t.fileId)?.image;if(i&&!(i instanceof Promise)){let a=go(t),s=fc(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]=E(t,o),m=pe(_o(A(c,l),A(f,p),t.angle)),h=pe(_o(A(u,l),A(f,p),t.angle)),g=pe(_o(A(c,d),A(f,p),t.angle)),_=Ma(ai(h,m)),v=Ma(ai(g,m)),y=fc(oo(s,_),oo(s,v)),b={...e,x:bs(e.x-y[0]*Math.sign(t.scale[0]),0,i.naturalWidth-e.width),y:bs(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}=RN(s,a,this,t,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:u}),this.state.editingFrame||on(e,i,a,this.scene,l,t[I.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}=Ei({type:`in-place`,elements:n,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:a,overrides:({duplicateElement:e,origElement:t})=>({frameId:e.frameId??t.frameId,seed:Ba()})});o.forEach(t=>{e.originalElements.set(t.id,ii(t))});let u=c.map(t=>{if(a.has(t.id)){let n=e.originalElements.get(t.id);if(n)return z(t,{x:n.x,y:n.y})}return t}),d=this.props.onDuplicate?.(u,n),f=xt(d||u,ze(o));(0,qc.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=tc(t,this.state),this.setState(e=>({..._r(o,this.scene.getNonDeletedElements(),e)})),this.scene.replaceAllElements(f),i.forEach(e=>{Oc(e)&&e.boundElements?.some(e=>e.type===`arrow`)&&zt(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,A(i,a)],pressures:n},{informMutation:!1,isDragging:!1}),this.setState({newElement:r})}}else if(vo(r)&&!r.isDeleted){e.drag.hasOccurred=!0;let n=r.points;ho(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 M(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,...M.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)M.handleBoxSelection(t,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let r=!0;!t.shiftKey&&Ki(n,this.state)&&(e.withCmdOrCtrl&&e.hit.element?this.setState(t=>Xo({...t,selectedElementIds:{[e.hit.element.id]:!0}},this.scene.getNonDeletedElements(),t,this)):r=!1);let i=this.state.selectionElement?Ue(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},{...Xo({editingGroupId:t.editingGroupId,selectedElementIds:n},this.scene.getNonDeletedElements(),t,this),selectedLinearElement:i.length===1&&vo(i[0])?new M(i[0],this.scene.getNonDeletedElementsMap()):null,showHyperlinkPopup:i.length===1&&(i[0].link||Fa(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*(MH.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*(MH.vertical?.deltaMultiplier||1)/this.state.zoom.value}),t.lastCoords.y=n,!0}return!1}onPointerUpFromPointerDownHandler(e){return QN(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===ct.bucketfill?this.bucketFill.handlePointerUp():this.bucketFill.cancel();let{newElement:r,resizingElement:a,croppingElementId:s,multiElement:c,activeTool:l,isResizing:u,isRotating:d,isCropping:f}=this.state;this.setState(e=>({isResizing:!1,isRotating:!1,isCropping:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:`up`,snapLines:we(e.snapLines,[]),originSnapOffset:null})),this.lassoTrail.endPath(),this.previousPointerMoveCoords=null,ON.setReferenceSnapPoints(null),ON.setVisibleGaps(null),this.savePointer(t.clientX,t.clientY,`up`);let p=e.hit.allHitElements,m=tc({clientX:t.clientX,clientY:t.clientY},this.state);if(this.state.activeTool.type===`selection`&&!e.boxSelection.hasOccurred&&!e.resize.isResizing&&!p.some(e=>this.state.selectedElementIds[e.id])){let e=this.getElementAtPosition(m.x,m.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(ra(`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);Oc(t)&&t.boundElements?.filter(e=>e.type===`arrow`).map(e=>n.get(e.id)).filter(e=>fe(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(zE);else{let e=M.handlePointerUp(t,this.state.selectedLinearElement,this.state,this.scene);this.actionManager.executeAction(zE,`ui`,{event:t,sceneCoords:m}),e!==this.state.selectedLinearElement&&this.setState({selectedLinearElement:e,suggestedBinding:null})}}else if(this.state.selectedLinearElement){if(this.state.selectedLinearElement.elbowed){let e=M.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());e&&this.scene.mutateElement(e,{})}if(this.state.selectedLinearElement.draggedFocusPointBinding?(hc(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(zE,`ui`,{event:t,sceneCoords:m})):this.scene.getSelectedElements(this.state).length>1&&this.setState({selectedLinearElement:null}),this.state.newElement&&this.state.multiElement&&vo(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(R.POINTER_MOVE,e.eventListeners.onMove),window.removeEventListener(R.POINTER_UP,e.eventListeners.onUp),window.removeEventListener(R.KEYDOWN,e.eventListeners.onKeyDown),window.removeEventListener(R.KEYUP,e.eventListeners.onKeyUp),this.props?.onPointerUp?.(l,e),this.onPointerUpEmitter.trigger(this.state.activeTool,e,t),r?.type===`freedraw`){let e=tc(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,A(i,a)],pressures:o}),this.actionManager.executeAction(zE);return}if(vo(r)&&this.state.activeTool.type!==`autoshape`){let n=tc(t,this.state),i=Sc(A(n.x,n.y),A(e.origin.x,e.origin.y))*this.state.zoom.value;if((!e.drag.hasOccurred||i<20)&&r&&!c){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:[A(0,0),A(e,0)]},{informMutation:!1,isDragging:!1}),this.actionManager.executeAction(zE)}else this.setState({multiElement:r,newElement:r})}else e.drag.hasOccurred&&!c&&(this.store.scheduleCapture(),vo(r)&&this.actionManager.executeAction(zE,`ui`,{event:t,sceneCoords:m}),this.setState({suggestedBinding:null}),this.isToolLocked()?this.setState({newElement:null}):this.setState(e=>({newElement:null,activeTool:$r(this.state,{type:this.state.preferredSelectionTool.type}),selectedElementIds:ci({...e.selectedElementIds,[r.id]:!0},e),selectedLinearElement:new M(r,this.scene.getNonDeletedElementsMap())}),()=>this.cursor.reset()),this.scene.triggerUpdate());return}if(F(r)){let e=ko(se({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(l.type!==`selection`&&r&&Bo(r)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(e=>e.id!==r.id),appState:{newElement:null},captureUpdate:j.NEVER});return}if(P(r)){let e=Ao(this.scene.getElementsIncludingDeleted(),r,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(Xe(this.scene.getElementsMapIncludingDeleted(),e,r))}if(r&&(this.scene.mutateElement(r,i(r),{informMutation:!1,isDragging:!1}),this.scene.triggerUpdate()),e.drag.hasOccurred){let e=tc(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=Wt(e,n);t&&e&&(Zn(e,t,this.scene.getNonDeletedElementsMap())||(this.scene.mutateElement(e,{groupIds:[]}),o([e],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let t=this.scene.getSelectedElements(this.state),n=this.getTopLayerFrameAtSceneCoords(e,{currentFrameId:x(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&&St(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=>da(e,r,this.state));this.state.editingGroupId&&i(e),r=Xe(r,e,n)}else!n&&this.state.editingGroupId&&i(t.filter(e=>e.frameId&&!da(e,r,this.state)));r=vi(r,this.state,this),this.scene.replaceAllElements(r)}}if(a&&this.store.scheduleCapture(),a&&Bo(a)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(e=>e.id!==a.id),captureUpdate:j.NEVER}),e.resize.isResizing){let e=vi(this.scene.getElementsIncludingDeleted(),this.state,this),t=this.scene.getSelectedElements(this.state).filter(P);for(let r of t)e=Oi(e,js(this.scene.getElementsIncludingDeleted(),r,this.state,n),r);this.scene.replaceAllElements(e)}let h=e.hit.element;this.state.selectedLinearElement?.elementId!==h?.id&&vo(h)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new M(h,this.scene.getNonDeletedElementsMap())}),(!s||s&&(!h&&!f||h&&h.id!==s))&&this.finishImageCropping();let g=this.lastPointerDownEvent,_=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(ti(this.state)&&g&&_){if(this.eraserTrail.endPath(),Sc(A(g.clientX,g.clientY),A(_.clientX,_.clientY))===0){let e=tc({clientX:_.clientX,clientY:_.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(),h&&!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[h.id]?Yn(this.state,h)?this.setState(e=>{let t={...e.selectedElementIds};for(let e of h.groupIds.flatMap(e=>St(this.scene.getNonDeletedElements(),e)))delete t[e.id];return{selectedGroupIds:{...e.selectedElementIds,...h.groupIds.map(e=>({[e]:!1})).reduce((e,t)=>({...e,...t}),{})},selectedElementIds:ci(t,e)}}):this.state.selectedLinearElement?.isDragging||this.setState(e=>{let t={...e.selectedElementIds};delete t[h.id];let n=is(this.scene.getNonDeletedElements(),{selectedElementIds:t});return{...Xo({editingGroupId:e.editingGroupId,selectedElementIds:t},this.scene.getNonDeletedElements(),e,this),selectedLinearElement:n.length===1&&vo(n[0])?new M(n[0],this.scene.getNonDeletedElementsMap()):e.selectedLinearElement}}):h.frameId&&this.state.selectedElementIds[h.frameId]?this.setState(e=>{let t={...e.selectedElementIds,[h.id]:!0};return delete t[h.frameId],(this.scene.getElement(h.frameId)?.groupIds??[]).flatMap(e=>St(this.scene.getNonDeletedElements(),e)).forEach(e=>{delete t[e.id]}),{...Xo({editingGroupId:e.editingGroupId,selectedElementIds:t},this.scene.getNonDeletedElements(),e,this),showHyperlinkPopup:h.link||Fa(h)?`info`:!1}}):this.setState(e=>({selectedElementIds:ci({...e.selectedElementIds,[h.id]:!0},e)})):this.setState(e=>({...Xo({editingGroupId:e.editingGroupId,selectedElementIds:{[h.id]:!0}},this.scene.getNonDeletedElements(),e,this),selectedLinearElement:vo(h)&&e.selectedLinearElement?.elementId!==h.id?new M(h,this.scene.getNonDeletedElementsMap()):e.selectedLinearElement}))),this.state.activeTool.type!==`lasso`&&!(h&&fe(h))&&!e.drag.hasOccurred&&!this.state.isResizing&&(h&&w({point:A(e.origin.x,e.origin.y),element:h,elementsMap:n,threshold:this.getElementHitThreshold(h),frameNameBound:P(h)?this.frameNameBoundsCache.get(h):null},n)||!h&&e.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.selectedLinearElement?.isEditing?this.actionManager.executeAction(iN):this.setState({selectedElementIds:ci({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),this.cursor.set(We.AUTO);return}let v=this.getSelectedTextEditingContainerAtPosition(h,m);if(l.type===this.state.preferredSelectionTool.type&&!this.state.editingTextElement&&!e.drag.hasOccurred&&!e.hit.wasAddedToSelection&&!t.shiftKey&&!t[I.CTRL_OR_CMD]&&!t.altKey&&t.pointerType!==`touch`&&h&&(F(h)&&this.state.selectedElementIds[h.id]&&this.scene.getSelectedElements(this.state).length===1||v)){this.startTextEditing({sceneX:m.x,sceneY:m.y,container:v,initialCaretSceneCoords:this.lastPointerUpIsDoubleClick?void 0:m});return}if(!this.isToolLocked()&&l.type!==`freedraw`&&r&&this.setState(e=>({selectedElementIds:ci({...e.selectedElementIds,[r.id]:!0},e),showHyperlinkPopup:Fa(r)&&!r.link?`editor`:e.showHyperlinkPopup})),!this.isEditingTextContent()&&(l.type!==`selection`||Ki(this.scene.getNonDeletedElements(),this.state)||!Jn(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.scheduleCapture(),e.drag.hasOccurred&&!this.state.selectedLinearElement||u||d||f){let e=this.scene.getSelectedElements(this.state).filter(Wa);wn(e,this.scene,this.state)}if(l.type===`laser`){this.laserTrails.endPath();return}if(l.type===`autoshape`){this.actionManager.executeAction(zE);return}!this.isToolLocked()&&l.type!==`freedraw`&&l.type!==ct.bucketfill&&(l.type!==`lasso`||l.type===`lasso`&&l.fromSelection)?this.setState({newElement:null,suggestedBinding:null,activeTool:$r(this.state,{type:this.state.preferredSelectionTool.type})},()=>this.cursor.reset()):this.setState({newElement:null,suggestedBinding:null})})}clearSelection(e){this.setState(t=>({selectedElementIds:ci({},t),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:t.editingGroupId&&e!=null&&Ks(e,t.editingGroupId)?t.editingGroupId:null})),this.setState({selectedElementIds:ci({},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=vt(r,this.scene.getNonDeletedElementsMap());if(o&&(i=o.x,a=o.y),Math.hypot(e-i,t-a)<30){let{x:e,y:t}=dn({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 Ab(Eb.find(e=>e.code===this.props.langCode)||Tb),this.setAppState({})}};(zi()||ht())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(ui(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}));var UH=HH,WH=e=>{let[t,n]=(0,V.useState)(!0);return(0,V.useEffect)(()=>{let t=async()=>{await Ab(r),n(!1)},r=Eb.find(t=>t.code===e.langCode)||Tb;t()},[e.langCode]),t?(0,H.jsx)(PI,{theme:e.theme}):e.children},GH=({children:e})=>{let{FooterCenterTunnel:t}=jI(),n=bw();return(0,H.jsx)(t.In,{children:(0,H.jsx)(`div`,{className:U(`footer-center zen-mode-transition`,{"layer-ui__wrapper__footer-left--transition-bottom":n.zenModeEnabled}),children:e})})},KH=GH;GH.displayName=`FooterCenter`;var qH=({isCollaborating:e,onSelect:t,editorInterface:n,...r})=>{let i=bw(),a=n?.formFactor!==`desktop`||i.width<1440;return(0,H.jsxs)(UA,{...r,className:U(`collab-button`,{active:e}),type:`button`,onSelect:t,style:{position:`relative`,width:a?void 0:`auto`},title:G(`labels.liveCollaboration`),children:[a?zx:G(`labels.share`),i.collaborators.size>0&&(0,H.jsx)(`div`,{className:`CollabButton-collaborators`,children:i.collaborators.size})]})},JH=qH;qH.displayName=`LiveCollaborationTrigger`;var YH=()=>(0,H.jsx)(`svg`,{viewBox:`0 0 40 40`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,className:`ExcalidrawLogo-icon`,children:(0,H.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`})}),XH=()=>(0,H.jsxs)(`svg`,{viewBox:`0 0 450 55`,xmlns:`http://www.w3.org/2000/svg`,fill:`none`,className:`ExcalidrawLogo-text`,children:[(0,H.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,H.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,H.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,H.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)`})]}),ZH=({style:e,size:t=`small`,withText:n})=>(0,H.jsxs)(`div`,{className:`ExcalidrawLogo is-${t}`,style:e,children:[(0,H.jsx)(YH,{}),n&&(0,H.jsx)(XH,{})]}),QH=({icon:e,shortcut:t,children:n})=>{let r=vH();return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`welcome-screen-menu-item__icon`,children:e}),(0,H.jsx)(`div`,{className:`welcome-screen-menu-item__text`,children:n}),t&&r.formFactor!==`phone`&&(0,H.jsx)(`div`,{className:`welcome-screen-menu-item__shortcut`,children:t})]})};QH.displayName=`WelcomeScreenMenuItemContent`;var $H=({onSelect:e,children:t,icon:n,shortcut:r,className:i=``,...a})=>(0,H.jsx)(`button`,{...a,type:`button`,className:`welcome-screen-menu-item ${i}`,onClick:e,children:(0,H.jsx)(QH,{icon:n,shortcut:r,children:t})});$H.displayName=`WelcomeScreenMenuItem`;var eU=({children:e,href:t,icon:n,shortcut:r,className:i=``,...a})=>(0,H.jsx)(`a`,{...a,className:`welcome-screen-menu-item ${i}`,href:t,target:`_blank`,rel:`noopener`,children:(0,H.jsx)(QH,{icon:n,shortcut:r,children:e})});eU.displayName=`WelcomeScreenMenuItemLink`;var tU=({children:e})=>{let{WelcomeScreenCenterTunnel:t}=jI();return(0,H.jsx)(t.In,{children:(0,H.jsx)(`div`,{className:`welcome-screen-center`,children:e||(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(nU,{}),(0,H.jsx)(rU,{children:G(`welcomeScreen.defaults.center_heading`)}),(0,H.jsxs)(iU,{children:[(0,H.jsx)(oU,{}),(0,H.jsx)(aU,{})]})]})})})};tU.displayName=`Center`;var nU=({children:e})=>(0,H.jsx)(`div`,{className:`welcome-screen-center__logo excalifont welcome-screen-decor`,children:e||(0,H.jsx)(ZH,{withText:!0})});nU.displayName=`Logo`;var rU=({children:e})=>(0,H.jsx)(`div`,{className:`welcome-screen-center__heading welcome-screen-decor excalifont`,children:e});rU.displayName=`Heading`;var iU=({children:e})=>(0,H.jsx)(`div`,{className:`welcome-screen-menu`,children:e});iU.displayName=`Menu`;var aU=()=>{let e=wH();return(0,H.jsx)($H,{onSelect:()=>e.executeAction(MD),shortcut:`?`,icon:yx,children:G(`helpDialog.title`)})};aU.displayName=`MenuItemHelp`;var oU=()=>{let e=bw(),t=wH();return e.viewModeEnabled?null:(0,H.jsx)($H,{onSelect:()=>t.executeAction(DD),shortcut:mk(`loadScene`),icon:kx,children:G(`buttons.load`)})};oU.displayName=`MenuItemLoadScene`;var sU=({onSelect:e})=>{let{t}=Pb();return(0,H.jsx)($H,{shortcut:null,onSelect:e,icon:eS,children:t(`labels.liveCollaboration`)})};sU.displayName=`MenuItemLiveCollaborationTrigger`,tU.Logo=nU,tU.Heading=rU,tU.Menu=iU,tU.MenuItem=$H,tU.MenuItemLink=eU,tU.MenuItemHelp=aU,tU.MenuItemLoadScene=oU,tU.MenuItemLiveCollaborationTrigger=sU;var cU=({children:e})=>{let{WelcomeScreenMenuHintTunnel:t}=jI();return(0,H.jsx)(t.In,{children:(0,H.jsxs)(`div`,{className:`excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu`,children:[qb,(0,H.jsx)(`div`,{className:`welcome-screen-decor-hint__label`,children:e||G(`welcomeScreen.defaults.menuHint`)})]})})};cU.displayName=`MenuHint`;var lU=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:t}=jI();return(0,H.jsx)(t.In,{children:(0,H.jsxs)(`div`,{className:`excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar`,children:[(0,H.jsx)(`div`,{className:`welcome-screen-decor-hint__label`,children:e||G(`welcomeScreen.defaults.toolbarHint`)}),Yb]})})};lU.displayName=`ToolbarHint`;var uU=({children:e})=>{let{WelcomeScreenHelpHintTunnel:t}=jI();return(0,H.jsx)(t.In,{children:(0,H.jsxs)(`div`,{className:`excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help`,children:[(0,H.jsx)(`div`,{children:e||G(`welcomeScreen.defaults.helpHint`)}),Jb]})})};uU.displayName=`HelpHint`;var dU=e=>(0,H.jsx)(H.Fragment,{children:e.children||(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(tU,{}),(0,H.jsx)(cU,{}),(0,H.jsx)(lU,{}),(0,H.jsx)(uU,{})]})});dU.displayName=`WelcomeScreen`,dU.Center=tU,dU.Hints={MenuHint:cU,ToolbarHint:lU,HelpHint:uU};var fU=dU,pU=()=>{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)})},mU=(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)),hU=(0,Kc.default)((e,t,n)=>{if(ht()||zi()||window?.DEBUG_FRACTIONAL_INDICES){let r=ui(e.map(e=>({...e})));Si(r,{shouldThrow:zi()||ht(),includeBoundTextValidation:!0,reconciliationContext:{localElements:t,remoteElements:n}})}},6e4,{leading:!0,trailing:!1}),gU=(e,t,n)=>{let r=ze(e),i=[],a=new Set;for(let e of t)if(!a.has(e.id)){let t=r.get(e.id),o=mU(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=so(i);return hU(o,e,t),ui(o),o},_U=({children:e,icon:t})=>{let{t:n}=Pb(),{TTDDialogTriggerTunnel:r}=jI(),i=CH();return(0,H.jsx)(r.In,{children:(0,H.jsx)(Q.Item,{onSelect:()=>{hw(`ai`,`dialog open`,`ttd`),i({openDialog:{name:`ttd`,tab:`text-to-diagram`}})},icon:t??yC,badge:(0,H.jsx)(Q.Item.Badge,{children:`AI`}),children:e??n(`labels.textToDiagram`)})})};_U.displayName=`TTDDialogTrigger`;function vU(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*yU(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 bU(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=vU(l.headers)),!l.ok){if(l.status===429)return{...s,error:new $o({message:`Rate limit exceeded`,status:429})};let e=await l.text();throw new $o({message:e||`Generation failed...`,status:l.status})}let u=l.body?.getReader();if(!u)throw new $o({message:`Couldn't get reader from response body`,status:500});i?.();try{for await(let t of yU(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 $o({message:n.error.message,status:500})}}catch(e){console.warn(`Failed to parse SSE data:`,t,e)}}}catch(e){c=e.name===`AbortError`?new $o({message:`Request aborted`,status:499}):new $o({message:e.message||`Streaming error`,status:500})}return c?{...s,error:c}:e?{generatedResponse:e,error:null,...s}:{...s,error:new $o({message:`Generation failed...`,status:l.status})}}catch(e){return e.name===`AbortError`?{error:new $o({message:`Request aborted`,status:499})}:{error:new $o({message:e.message||`Request failed`,status:500})}}}var xU=e=>{let t=gH();return(0,V.useLayoutEffect)(()=>{t.setPlugins({diagramToCode:{generate:e.generate}})},[t,e.generate]),null};pU();var SU=({children:e})=>{let[t,n]=(0,V.useState)(null);return(0,H.jsx)(mH.Provider,{value:t,children:(0,H.jsx)(hH.Provider,{value:n,children:e})})},CU=V.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:_=Tb.code,viewModeEnabled:v,interaction:y,ui:b,activeTool:x,zenModeEnabled:S,gridModeEnabled:C,libraryReturnUrl:w,theme:T,name:E,renderCustomStats:D,onPaste:ee,detectScroll:O=!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:{...eo.canvasActions,...xe},tools:{image:e.UIOptions?.tools?.image??!0}};xe?.export&&(Se.canvasActions.export.saveFileToDisk=xe.export?.saveFileToDisk??eo.canvasActions.export.saveFileToDisk),Se.canvasActions.toggleTheme===null&&(T==null||a)&&(Se.canvasActions.toggleTheme=!0);let A={maxFileSizeBytes:be?.maxFileSizeBytes??Vo.maxFileSizeBytes,maxWidthOrHeight:be?.maxWidthOrHeight??Vo.maxWidthOrHeight},Ce=(0,V.useContext)(hH),we=(0,V.useRef)(l);we.current=l;let Te=(0,V.useCallback)(e=>{Ce?.(e),we.current?.(e)},[Ce]),Ee=typeof y==`object`&&!!y&&y.enabled?.browserZoom===!0&&y.enabled?.navigation!==!0;return(0,V.useEffect)(()=>{if((async()=>{await n(()=>import(`./roundRect-D01gJrlt.js`),[],import.meta.url)})(),Ee)return;let e=e=>{typeof e.scale==`number`&&e.scale!==1&&e.preventDefault()};return document.addEventListener(`touchmove`,e,{passive:!1}),()=>{document.removeEventListener(`touchmove`,e)}},[Ee]),(0,H.jsx)(xb,{store:Sb,children:(0,H.jsx)(WH,{langCode:_,theme:T,children:(0,H.jsx)(UH,{onExport:t,className:r,onChange:i,onThemeChange:a,onIncrement:o,initialData:s,initialState:c,onExcalidrawAPI:Te,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:ee,detectScroll:O,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:A,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??Vo.maxWidthOrHeight)===(d?.maxWidthOrHeight??Vo.maxWidthOrHeight)&&(i?.maxFileSizeBytes??Vo.maxFileSizeBytes)===(d?.maxFileSizeBytes??Vo.maxFileSizeBytes);return v&&y&&Jn(c,h)});CU.displayName=`Excalidraw`;function wU(e){return cE(e,!1)}export{JH as A,mF as C,yH as D,vH as E,Ck as F,TH as I,Sk as L,Nk as M,CU as N,jj as O,Tb as P,Gc as R,Wk as S,SU as T,mH as _,BL as a,UF as b,_U as c,uL as d,GF as f,xk as g,bk as h,UA as i,yT as j,Rk as k,bU as l,fU as m,KH as n,Kk as o,lE as p,Pb as r,SB as s,xU as t,Az as u,gU as v,Eb as w,wU as x,aR as y};