@flyfish-group/file-viewer-web 1.0.9

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 (201) hide show
  1. package/LICENSE +160 -0
  2. package/README.md +41 -0
  3. package/dist/index.d.ts +60 -0
  4. package/dist/index.js +165 -0
  5. package/dist/node.d.ts +23 -0
  6. package/dist/node.js +43 -0
  7. package/package.json +67 -0
  8. package/scripts/copy-assets.mjs +59 -0
  9. package/viewer/assets/AudioViewer-0CSMvCtp.css +1 -0
  10. package/viewer/assets/AudioViewer-HHLkFx24.js +1 -0
  11. package/viewer/assets/CadViewer-BYC0zQ0T.js +1 -0
  12. package/viewer/assets/CadViewer-Cv8b95Gj.css +1 -0
  13. package/viewer/assets/CodeViewer-HGV-dwr6.css +1 -0
  14. package/viewer/assets/CodeViewer-VQE6BewI.js +4 -0
  15. package/viewer/assets/DrawingViewer-BtEGTvJQ.js +2 -0
  16. package/viewer/assets/DrawingViewer-CHm6iXmV.css +1 -0
  17. package/viewer/assets/EpubViewer-5hOhOgl5.js +2 -0
  18. package/viewer/assets/EpubViewer-Cci0l1Vm.css +1 -0
  19. package/viewer/assets/ImageViewer-D2_fTk_7.css +10 -0
  20. package/viewer/assets/ImageViewer-D8t2LOeu.js +1 -0
  21. package/viewer/assets/MarkdownViewer-47tSKoCN.css +1 -0
  22. package/viewer/assets/MarkdownViewer-CauCMix8.js +64 -0
  23. package/viewer/assets/OfdViewer-DZCDN3UD.css +1 -0
  24. package/viewer/assets/OfdViewer-d-bt92VG.js +2 -0
  25. package/viewer/assets/PdfView-BmvyynSl.js +558 -0
  26. package/viewer/assets/PdfView-CS_IFVnD.css +1 -0
  27. package/viewer/assets/PptxRender-BQ5mqB0E.css +1 -0
  28. package/viewer/assets/PptxRender-DPUrsWGR.js +32 -0
  29. package/viewer/assets/UmdViewer-DgDIrlID.js +3 -0
  30. package/viewer/assets/UmdViewer-DpObj56a.css +1 -0
  31. package/viewer/assets/XlsxTable-BxlH06s2.css +1 -0
  32. package/viewer/assets/XlsxTable-Dca8o5_N.js +5 -0
  33. package/viewer/assets/ar-SA-G6X2FPQ2-DWAZRxPu.js +10 -0
  34. package/viewer/assets/arc-Dimj_7G-.js +1 -0
  35. package/viewer/assets/architecture-7EHR7CIX-PuoqTBea.js +1 -0
  36. package/viewer/assets/architectureDiagram-3BPJPVTR-ourcMGqp.js +36 -0
  37. package/viewer/assets/az-AZ-76LH7QW2-CD-SA1wC.js +1 -0
  38. package/viewer/assets/bg-BG-XCXSNQG7-lFFvFyxW.js +5 -0
  39. package/viewer/assets/blockDiagram-GPEHLZMM-DETJLwVU.js +132 -0
  40. package/viewer/assets/bn-BD-2XOGV67Q-CuUcZaL8.js +5 -0
  41. package/viewer/assets/c4Diagram-AAUBKEIU-DCfnD0yS.js +10 -0
  42. package/viewer/assets/ca-ES-6MX7JW3Y-Cj4OlC6R.js +8 -0
  43. package/viewer/assets/channel-Cvj3_InT.js +1 -0
  44. package/viewer/assets/chunk-2J33WTMH-vXxffsmH.js +1 -0
  45. package/viewer/assets/chunk-3OPIFGDE-C9LtEwmG.js +62 -0
  46. package/viewer/assets/chunk-4BX2VUAB-CIKyExbu.js +1 -0
  47. package/viewer/assets/chunk-55IACEB6-uprZKw0K.js +1 -0
  48. package/viewer/assets/chunk-5ZQYHXKU-C2girjDc.js +2 -0
  49. package/viewer/assets/chunk-6U3AYISY-sM9HnDSj.js +12 -0
  50. package/viewer/assets/chunk-727SXJPM-BJJusOVj.js +206 -0
  51. package/viewer/assets/chunk-AGHRB4JF-vbzngFky.js +1 -0
  52. package/viewer/assets/chunk-AQP2D5EJ-BPoH0fiI.js +231 -0
  53. package/viewer/assets/chunk-BSJP7CBP-9m7kELGq.js +1 -0
  54. package/viewer/assets/chunk-CSCIHK7Q-OdsAx3G8.js +124 -0
  55. package/viewer/assets/chunk-EIO257PC-B13QElRc.js +22 -0
  56. package/viewer/assets/chunk-FMBD7UC4-DiXlV5mw.js +15 -0
  57. package/viewer/assets/chunk-K2UTITRG-CJkr0tXj.js +35 -0
  58. package/viewer/assets/chunk-KSCS5N6A-WSLcjFr5.js +10 -0
  59. package/viewer/assets/chunk-L5ZTLDWV-B_HlbJUe.js +1 -0
  60. package/viewer/assets/chunk-LZXEDZCA-Cqd1LSkM.js +2 -0
  61. package/viewer/assets/chunk-ND2GUHAM-28eJdx7E.js +1 -0
  62. package/viewer/assets/chunk-NZK2D7GU-BUIZFEFT.js +1 -0
  63. package/viewer/assets/chunk-O5CBEL6O-DZNjSn6F.js +70 -0
  64. package/viewer/assets/chunk-QZHKN3VN-DQmrlo26.js +1 -0
  65. package/viewer/assets/chunk-SRAX5OIU-D2mqL_eA.js +1 -0
  66. package/viewer/assets/chunk-WU5MYG2G-CI2E4kog.js +1 -0
  67. package/viewer/assets/chunk-XPW4576I-CvDbpA2d.js +32 -0
  68. package/viewer/assets/chunk-Z3N5DIM6-DVAc8Qv7.js +1 -0
  69. package/viewer/assets/chunk-ZUYEQ4TG-DaQMhOk1.js +7 -0
  70. package/viewer/assets/classDiagram-4FO5ZUOK-BR_8dE4R.js +1 -0
  71. package/viewer/assets/classDiagram-v2-Q7XG4LA2-BSPdc-Mh.js +1 -0
  72. package/viewer/assets/cose-bilkent-S5V4N54A-DT4OXn3T.js +1 -0
  73. package/viewer/assets/cs-CZ-2BRQDIVT-9YP2OnzR.js +11 -0
  74. package/viewer/assets/cytoscape.esm-DQPqE0MR.js +321 -0
  75. package/viewer/assets/da-DK-5WZEPLOC-DyH5OvyC.js +5 -0
  76. package/viewer/assets/dagre-BM42HDAG-BQqjetsc.js +4 -0
  77. package/viewer/assets/dagre-D7L3ChvY.js +1 -0
  78. package/viewer/assets/de-DE-XR44H4JA-Dm-lIYs8.js +8 -0
  79. package/viewer/assets/defaultLocale-GXPQCpCV.js +1 -0
  80. package/viewer/assets/diagram-2AECGRRQ-DQj687EE.js +43 -0
  81. package/viewer/assets/diagram-5GNKFQAL-C9cKajpJ.js +10 -0
  82. package/viewer/assets/diagram-KO2AKTUF-BrHr9ddz.js +3 -0
  83. package/viewer/assets/diagram-LMA3HP47-B_3VIpAA.js +24 -0
  84. package/viewer/assets/diagram-OG6HWLK6-CKGkIofl.js +24 -0
  85. package/viewer/assets/directory-open-01563666-DJpMaT5E.js +1 -0
  86. package/viewer/assets/directory-open-4ed118d0-vrMz6VGC.js +1 -0
  87. package/viewer/assets/dist-BWLXExfL.js +27 -0
  88. package/viewer/assets/dist-Bl_HJvJC.js +1 -0
  89. package/viewer/assets/dist-CDIdMEAB.js +7 -0
  90. package/viewer/assets/docx-preview-CiJ_X4bw.js +20 -0
  91. package/viewer/assets/el-GR-BZB4AONW-r581kidc.js +10 -0
  92. package/viewer/assets/en-B4ZKOASM-Crn8bm25.js +1 -0
  93. package/viewer/assets/erDiagram-TEJ5UH35-BEdSv6Fr.js +85 -0
  94. package/viewer/assets/es-ES-U4NZUMDT-Cwbu6VfM.js +9 -0
  95. package/viewer/assets/eu-ES-A7QVB2H4-BQQ8mY2m.js +11 -0
  96. package/viewer/assets/eventmodeling-FCH6USID-ClPyqCMG.js +1 -0
  97. package/viewer/assets/fa-IR-HGAKTJCU-eYy7h0Hx.js +8 -0
  98. package/viewer/assets/fi-FI-Z5N7JZ37-0dUJDB5b.js +6 -0
  99. package/viewer/assets/file-open-002ab408-D8YX4_im.js +1 -0
  100. package/viewer/assets/file-open-7c801643-ssV9zcu_.js +1 -0
  101. package/viewer/assets/file-save-3189631c-DxUkN-yO.js +1 -0
  102. package/viewer/assets/file-save-745eba88-VPL_lGKy.js +1 -0
  103. package/viewer/assets/flowDiagram-I6XJVG4X-BuWsqPkc.js +162 -0
  104. package/viewer/assets/fr-FR-RHASNOE6-CcYw1Zvt.js +9 -0
  105. package/viewer/assets/ganttDiagram-6RSMTGT7-CJySS69b.js +292 -0
  106. package/viewer/assets/gitGraph-WXDBUCRP-ce180Qdx.js +1 -0
  107. package/viewer/assets/gitGraphDiagram-PVQCEYII-DR2VhZO_.js +106 -0
  108. package/viewer/assets/gl-ES-HMX3MZ6V-C3Iv5ndX.js +10 -0
  109. package/viewer/assets/graphlib-Bk2wNdF0.js +1 -0
  110. package/viewer/assets/he-IL-6SHJWFNN-CL8Or2hC.js +10 -0
  111. package/viewer/assets/hi-IN-IWLTKZ5I-DgAD87B-.js +4 -0
  112. package/viewer/assets/hu-HU-A5ZG7DT2-B8ITrvUt.js +7 -0
  113. package/viewer/assets/id-ID-SAP4L64H-VQ2OqDi1.js +10 -0
  114. package/viewer/assets/image-GAAHSSAO-DbYjE9JA.js +1 -0
  115. package/viewer/assets/image-blob-reduce.esm-Co0wHMYu.js +2 -0
  116. package/viewer/assets/index-0hvuUhZv.js +106 -0
  117. package/viewer/assets/index-Bwjgtadn.css +1 -0
  118. package/viewer/assets/info-J43DQDTF-CMRAUPs-.js +1 -0
  119. package/viewer/assets/infoDiagram-5YYISTIA-DxNv4IA7.js +2 -0
  120. package/viewer/assets/init-Bj57mB65.js +1 -0
  121. package/viewer/assets/ishikawaDiagram-YF4QCWOH-2rCqsio7.js +70 -0
  122. package/viewer/assets/it-IT-JPQ66NNP-D777F8zf.js +11 -0
  123. package/viewer/assets/ja-JP-DBVTYXUO-D1PJdPJe.js +8 -0
  124. package/viewer/assets/journeyDiagram-JHISSGLW-DQQq5Lp7.js +139 -0
  125. package/viewer/assets/jszip.min-D1xSKQ08.js +2 -0
  126. package/viewer/assets/kaa-6HZHGXH3-fRgBr8Mi.js +1 -0
  127. package/viewer/assets/kab-KAB-ZGHBKWFO-DlQ49dRn.js +8 -0
  128. package/viewer/assets/kanban-definition-UN3LZRKU-B5eO6Mg1.js +89 -0
  129. package/viewer/assets/katex-C22v-RF3.js +257 -0
  130. package/viewer/assets/kk-KZ-P5N5QNE5-Hq_H-Gj0.js +1 -0
  131. package/viewer/assets/km-KH-HSX4SM5Z-BhI31DxZ.js +11 -0
  132. package/viewer/assets/ko-KR-MTYHY66A-ImUZQcvz.js +9 -0
  133. package/viewer/assets/ku-TR-6OUDTVRD-DfaC8QXn.js +9 -0
  134. package/viewer/assets/linear-CjCAJGt1.js +1 -0
  135. package/viewer/assets/logo-DG62cSZK.png +0 -0
  136. package/viewer/assets/lt-LT-XHIRWOB4-I-ZCC3dU.js +3 -0
  137. package/viewer/assets/lv-LV-5QDEKY6T-Qq5QdgfN.js +7 -0
  138. package/viewer/assets/mermaid-parser.core-Bdy3q53b.js +161 -0
  139. package/viewer/assets/mindmap-definition-RKZ34NQL-m96D2ClP.js +96 -0
  140. package/viewer/assets/mr-IN-CRQNXWMA-BeP3PnlU.js +13 -0
  141. package/viewer/assets/my-MM-5M5IBNSE-BYx0eFn7.js +1 -0
  142. package/viewer/assets/nb-NO-T6EIAALU-C9J5JzGe.js +10 -0
  143. package/viewer/assets/nl-NL-IS3SIHDZ-CMVLrD7F.js +8 -0
  144. package/viewer/assets/nn-NO-6E72VCQL-BBxsrvc2.js +8 -0
  145. package/viewer/assets/oc-FR-POXYY2M6-CHEXPovt.js +8 -0
  146. package/viewer/assets/ofd-D8TA6tcU.js +6 -0
  147. package/viewer/assets/ordinal-CEZ33b-s.js +1 -0
  148. package/viewer/assets/pa-IN-N4M65BXN-Bnyu119-.js +4 -0
  149. package/viewer/assets/packet-YPE3B663-mGtuymGQ.js +1 -0
  150. package/viewer/assets/pdf.worker-BZPf8fJG.js +50 -0
  151. package/viewer/assets/percentages-BXMCSKIN-CBvdjJLu.js +1 -0
  152. package/viewer/assets/pica-CB7jwGa3.js +2 -0
  153. package/viewer/assets/pie-DUmD7IHG.js +1 -0
  154. package/viewer/assets/pie-LRSECV5Y-CGMZQePM.js +1 -0
  155. package/viewer/assets/pieDiagram-4H26LBE5-DVleOheM.js +30 -0
  156. package/viewer/assets/pl-PL-T2D74RX3-Cw72z8vE.js +9 -0
  157. package/viewer/assets/pptx.worker-c0GnmoEE.js +23 -0
  158. package/viewer/assets/prod-Npfld6sP.js +149 -0
  159. package/viewer/assets/pt-BR-5N22H2LF-ok3TV3dt.js +9 -0
  160. package/viewer/assets/pt-PT-UZXXM6DQ-BX423IXU.js +9 -0
  161. package/viewer/assets/quadrantDiagram-W4KKPZXB-CV_EkNJ-.js +7 -0
  162. package/viewer/assets/radar-GUYGQ44K-C81hKZN2.js +1 -0
  163. package/viewer/assets/requirementDiagram-4Y6WPE33-B_kmlnjO.js +84 -0
  164. package/viewer/assets/ro-RO-JPDTUUEW-Pv4aDgxu.js +11 -0
  165. package/viewer/assets/rough.esm-BrTFrov0.js +1 -0
  166. package/viewer/assets/roundRect-BDOnP7qU.js +1 -0
  167. package/viewer/assets/ru-RU-B4JR7IUQ-BGRCDPgW.js +9 -0
  168. package/viewer/assets/sankeyDiagram-5OEKKPKP-CCXvqmNS.js +40 -0
  169. package/viewer/assets/sequenceDiagram-3UESZ5HK-CoR9l1O_.js +162 -0
  170. package/viewer/assets/sheet.worker-DXcmIjpw.js +68 -0
  171. package/viewer/assets/si-LK-N5RQ5JYF-CSeZ8jFh.js +1 -0
  172. package/viewer/assets/sk-SK-C5VTKIMK-BrMoO_Q1.js +6 -0
  173. package/viewer/assets/sl-SI-NN7IZMDC-B_x--94y.js +6 -0
  174. package/viewer/assets/src-BBw8FbvP.js +1 -0
  175. package/viewer/assets/src-BbUo_1sw.js +5 -0
  176. package/viewer/assets/stateDiagram-AJRCARHV-DdTaUVJA.js +1 -0
  177. package/viewer/assets/stateDiagram-v2-BHNVJYJU-D9_r8kG7.js +1 -0
  178. package/viewer/assets/subset-shared.chunk-DpZLNUjP.js +1 -0
  179. package/viewer/assets/subset-worker.chunk-DoDHTOze.js +1 -0
  180. package/viewer/assets/sv-SE-XGPEYMSR-BB4gq_Zc.js +10 -0
  181. package/viewer/assets/ta-IN-2NMHFXQM-9zxtttPw.js +9 -0
  182. package/viewer/assets/th-TH-HPSO5L25-Bu674ZxS.js +2 -0
  183. package/viewer/assets/time-0omzMTb_.js +1 -0
  184. package/viewer/assets/timeline-definition-PNZ67QCA-CLUsDmue.js +120 -0
  185. package/viewer/assets/tr-TR-DEFEU3FU-BOU8hW6c.js +7 -0
  186. package/viewer/assets/treeView-BLDUP644-NZTNRLdP.js +1 -0
  187. package/viewer/assets/treemap-LRROVOQU-BMknj0en.js +1 -0
  188. package/viewer/assets/uk-UA-QMV73CPH-DExt1pCB.js +6 -0
  189. package/viewer/assets/vennDiagram-CIIHVFJN-DFmAzwyu.js +34 -0
  190. package/viewer/assets/vi-VN-M7AON7JQ-ChzDxy_w.js +5 -0
  191. package/viewer/assets/wardley-L42UT6IY-D9i-Iven.js +1 -0
  192. package/viewer/assets/wardleyDiagram-YWT4CUSO-DpnSL_l7.js +78 -0
  193. package/viewer/assets/worker-ref-zQl5Zn-S.js +1 -0
  194. package/viewer/assets/xlsx-ff7ER-JZ.png +0 -0
  195. package/viewer/assets/xychartDiagram-2RQKCTM6-DTybmPGf.js +7 -0
  196. package/viewer/assets/zh-CN-LNUGB5OW-AIyEr3br.js +10 -0
  197. package/viewer/assets/zh-HK-E62DVLB3-CyQvIghB.js +1 -0
  198. package/viewer/assets/zh-TW-RAJ6MFWO-C9bb32Ou.js +9 -0
  199. package/viewer/favicon.ico +0 -0
  200. package/viewer/flyfish-viewer-manifest.json +5 -0
  201. package/viewer/index.html +14 -0
@@ -0,0 +1,149 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ar-SA-G6X2FPQ2-DWAZRxPu.js","./chunk-SRAX5OIU-D2mqL_eA.js","./index-0hvuUhZv.js","./index-Bwjgtadn.css","./az-AZ-76LH7QW2-CD-SA1wC.js","./bg-BG-XCXSNQG7-lFFvFyxW.js","./bn-BD-2XOGV67Q-CuUcZaL8.js","./ca-ES-6MX7JW3Y-Cj4OlC6R.js","./cs-CZ-2BRQDIVT-9YP2OnzR.js","./da-DK-5WZEPLOC-DyH5OvyC.js","./de-DE-XR44H4JA-Dm-lIYs8.js","./el-GR-BZB4AONW-r581kidc.js","./en-B4ZKOASM-Crn8bm25.js","./chunk-6U3AYISY-sM9HnDSj.js","./es-ES-U4NZUMDT-Cwbu6VfM.js","./eu-ES-A7QVB2H4-BQQ8mY2m.js","./fa-IR-HGAKTJCU-eYy7h0Hx.js","./fi-FI-Z5N7JZ37-0dUJDB5b.js","./fr-FR-RHASNOE6-CcYw1Zvt.js","./gl-ES-HMX3MZ6V-C3Iv5ndX.js","./he-IL-6SHJWFNN-CL8Or2hC.js","./hi-IN-IWLTKZ5I-DgAD87B-.js","./hu-HU-A5ZG7DT2-B8ITrvUt.js","./id-ID-SAP4L64H-VQ2OqDi1.js","./it-IT-JPQ66NNP-D777F8zf.js","./ja-JP-DBVTYXUO-D1PJdPJe.js","./kaa-6HZHGXH3-fRgBr8Mi.js","./kab-KAB-ZGHBKWFO-DlQ49dRn.js","./kk-KZ-P5N5QNE5-Hq_H-Gj0.js","./km-KH-HSX4SM5Z-BhI31DxZ.js","./ko-KR-MTYHY66A-ImUZQcvz.js","./ku-TR-6OUDTVRD-DfaC8QXn.js","./lt-LT-XHIRWOB4-I-ZCC3dU.js","./lv-LV-5QDEKY6T-Qq5QdgfN.js","./mr-IN-CRQNXWMA-BeP3PnlU.js","./my-MM-5M5IBNSE-BYx0eFn7.js","./nb-NO-T6EIAALU-C9J5JzGe.js","./nl-NL-IS3SIHDZ-CMVLrD7F.js","./nn-NO-6E72VCQL-BBxsrvc2.js","./oc-FR-POXYY2M6-CHEXPovt.js","./pa-IN-N4M65BXN-Bnyu119-.js","./percentages-BXMCSKIN-CBvdjJLu.js","./chunk-Z3N5DIM6-DVAc8Qv7.js","./pl-PL-T2D74RX3-Cw72z8vE.js","./pt-BR-5N22H2LF-ok3TV3dt.js","./pt-PT-UZXXM6DQ-BX423IXU.js","./ro-RO-JPDTUUEW-Pv4aDgxu.js","./ru-RU-B4JR7IUQ-BGRCDPgW.js","./si-LK-N5RQ5JYF-CSeZ8jFh.js","./sk-SK-C5VTKIMK-BrMoO_Q1.js","./sl-SI-NN7IZMDC-B_x--94y.js","./sv-SE-XGPEYMSR-BB4gq_Zc.js","./ta-IN-2NMHFXQM-9zxtttPw.js","./th-TH-HPSO5L25-Bu674ZxS.js","./tr-TR-DEFEU3FU-BOU8hW6c.js","./uk-UA-QMV73CPH-DExt1pCB.js","./vi-VN-M7AON7JQ-ChzDxy_w.js","./zh-CN-LNUGB5OW-AIyEr3br.js","./zh-HK-E62DVLB3-CyQvIghB.js","./zh-TW-RAJ6MFWO-C9bb32Ou.js","./image-GAAHSSAO-DbYjE9JA.js","./chunk-K2UTITRG-CJkr0tXj.js","./chunk-ZUYEQ4TG-DaQMhOk1.js","./dist-BWLXExfL.js","./chunk-O5CBEL6O-DZNjSn6F.js","./src-BBw8FbvP.js","./chunk-5ZQYHXKU-C2girjDc.js","./dist-Bl_HJvJC.js","./chunk-AGHRB4JF-vbzngFky.js","./chunk-CSCIHK7Q-OdsAx3G8.js","./chunk-3OPIFGDE-C9LtEwmG.js","./chunk-L5ZTLDWV-B_HlbJUe.js","./chunk-NZK2D7GU-BUIZFEFT.js","./rough.esm-BrTFrov0.js","./chunk-BSJP7CBP-9m7kELGq.js","./chunk-KSCS5N6A-WSLcjFr5.js","./chunk-LZXEDZCA-Cqd1LSkM.js","./chunk-WU5MYG2G-CI2E4kog.js","./chunk-XPW4576I-CvDbpA2d.js"])))=>i.map(i=>d[i]);
2
+ import{A as e,D as t,t as n}from"./index-0hvuUhZv.js";import{t as r}from"./chunk-ZUYEQ4TG-DaQMhOk1.js";import{i,n as a,r as o}from"./chunk-SRAX5OIU-D2mqL_eA.js";import{$ as s,$a as c,$c as l,$i as u,$l as d,$n as f,$o as p,$r as m,$s as h,$t as g,$u as _,A as v,Aa as y,Ac as b,Ai as x,Al as S,An as C,Ao as w,Ar as T,As as ee,At as te,B as ne,Ba as re,Bc as ie,Bi as ae,Bl as oe,Bn as se,Bo as ce,Br as le,Bs as ue,Bt as de,Bu as fe,C as pe,Ca as me,Cc as he,Ci as ge,Cl as _e,Cn as ve,Co as ye,Cr as be,Cs as xe,Ct as Se,Cu as Ce,D as we,Da as Te,Dc as Ee,Di as De,Dl as Oe,Dn as ke,Do as Ae,Dr as je,Ds as Me,Dt as Ne,Du as Pe,E as Fe,Ea as Ie,Ec as Le,Ei as Re,El as ze,En as Be,Eo as Ve,Er as He,Es as Ue,Et as We,Eu as Ge,F as Ke,Fc as qe,Fi as Je,Fl as Ye,Fn as Xe,Fo as Ze,Fr as Qe,Fs as $e,Ft as et,Fu as tt,G as nt,Gc as rt,Gi as it,Gl as at,Gn as ot,Go as st,Gr as ct,Gs as lt,Gt as ut,Gu as dt,H as ft,Ha as pt,Hc as mt,Hi as ht,Hl as gt,Hn as _t,Ho as vt,Hr as E,Hs as yt,Ht as bt,Hu as xt,I as St,Ia as Ct,Ic as wt,Ii as Tt,Il as Et,In as Dt,Io as Ot,Ir as kt,Is as At,It as jt,Iu as Mt,J as Nt,Ja as Pt,Jc as Ft,Ji as It,Jl as Lt,Jn as Rt,Jo as zt,Jr as Bt,Js as Vt,Jt as Ht,Ju as Ut,K as D,Ka as Wt,Kc as Gt,Ki as Kt,Kl as qt,Kn as Jt,Ko as Yt,Kr as Xt,Ks as Zt,Kt as Qt,Ku as $t,L as en,La as tn,Lc as nn,Li as rn,Ll as an,Ln as O,Lo as on,Lr as sn,Ls as cn,Lt as ln,Lu as un,M as dn,Ma as fn,Mc as pn,Mi as mn,Ml as hn,Mn as gn,Mo as _n,Mr as vn,Ms as yn,Mt as bn,Mu as xn,N as Sn,Na as Cn,Nc as wn,Ni as Tn,Nl as k,Nn as En,No as A,Nr as Dn,Ns as On,Nt as kn,Nu as An,O as jn,Oa as Mn,Oc as Nn,Oi as Pn,Ol as Fn,On as In,Oo as Ln,Or as Rn,Os as zn,Ot as Bn,Ou as Vn,P as Hn,Pa as Un,Pc as Wn,Pi as Gn,Pl as Kn,Pn as qn,Po as Jn,Pr as Yn,Pt as Xn,Pu as Zn,Q as Qn,Qa as $n,Qc as er,Qi as tr,Ql as nr,Qn as rr,Qo as ir,Qr as ar,Qs as or,Qt as sr,Qu as cr,R as lr,Ra as ur,Rc as dr,Ri as fr,Rl as pr,Rn as mr,Ro as j,Rr as hr,Rs as gr,Rt as _r,Ru as vr,S as yr,Sa as br,Sc as xr,Si as Sr,Sl as Cr,Sn as wr,So as M,Sr as Tr,Ss as Er,St as Dr,Su as Or,Ta as kr,Tc as N,Ti as Ar,Tl as jr,Tn as Mr,To as Nr,Tr as Pr,Ts as Fr,Tt as Ir,Tu as Lr,U as Rr,Ua as zr,Uc as Br,Ui as Vr,Ul as Hr,Un as Ur,Uo as Wr,Ur as Gr,Us as Kr,Ut as qr,Uu as Jr,V as Yr,Va as Xr,Vc as Zr,Vi as Qr,Vl as P,Vn as $r,Vo as ei,Vr as ti,Vs as ni,Vt as ri,Vu as ii,W as ai,Wa as oi,Wc as si,Wi as ci,Wl as li,Wn as ui,Wo as di,Wr as fi,Ws as pi,Wt as F,Wu as mi,X as hi,Xa as gi,Xc as _i,Xi as vi,Xl as yi,Xn as bi,Xo as xi,Xr as Si,Xs as I,Xt as Ci,Xu as wi,Y as Ti,Yc as Ei,Yi as Di,Yl as Oi,Yn as ki,Yo as Ai,Yr as ji,Ys as Mi,Yu as Ni,Z as Pi,Za as Fi,Zc as Ii,Zi as Li,Zl as Ri,Zn as zi,Zo as Bi,Zr as Vi,Zs as Hi,Zt as Ui,Zu as L,_ as Wi,_a as Gi,_c as Ki,_i as qi,_l as Ji,_n as Yi,_o as Xi,_r as Zi,_s as Qi,_t as R,_u as $i,a as ea,aa as ta,ac as na,ai as ra,al as ia,an as aa,ao as oa,ar as sa,as as ca,at as la,au as ua,b as da,ba as fa,bc as pa,bi as ma,bl as ha,bn as ga,bo as _a,br as va,bs as ya,bt as ba,bu as xa,c as Sa,ca as Ca,cc as wa,ci as Ta,cl as Ea,cn as Da,co as Oa,cr as ka,cs as Aa,cu as z,d as ja,da as Ma,dc as Na,di as Pa,dl as Fa,dn as Ia,do as La,dr as Ra,ds as za,dt as Ba,du as Va,ea as Ha,ec as B,ed as Ua,ei as Wa,el as Ga,en as Ka,eo as qa,er as Ja,es as Ya,et as Xa,eu as Za,f as Qa,fa as $a,fc as eo,fi as to,fl as no,fn as ro,fo as io,fr as ao,fs as oo,ft as so,fu as co,g as lo,ga as uo,gc as fo,gi as po,gl as mo,gn as ho,go,gr as _o,gs as vo,gt as yo,gu as bo,h as xo,ha as V,hc as So,hi as Co,hl as wo,hn as H,ho as To,hr as Eo,hs as Do,ht as Oo,hu as ko,i as Ao,ic as jo,ii as Mo,il as No,in as Po,io as Fo,ir as Io,is as Lo,it as Ro,iu as zo,j as Bo,ja as Vo,jc as Ho,ji as Uo,jl as Wo,jn as Go,jo as Ko,jr as qo,js as Jo,jt as Yo,ju as Xo,k as Zo,ka as Qo,ki as $o,kl as es,kn as ts,ko as ns,kr as rs,ks as is,kt as as,ku as os,l as ss,la as cs,lc as ls,li as us,ll as ds,ln as fs,lo as ps,lr as ms,ls as hs,lt as gs,lu as _s,m as vs,ma as ys,mc as bs,mi as xs,ml as Ss,mn as Cs,mo as ws,mr as Ts,ms as Es,mt as Ds,na as Os,nc as ks,nd as As,ni as js,nl as Ms,nn as Ns,no as Ps,nr as Fs,ns as Is,nt as Ls,nu as Rs,o as zs,oc as Bs,oi as Vs,ol as Hs,on as Us,oo as Ws,or as Gs,os as Ks,ot as qs,ou as Js,p as Ys,pa as Xs,pc as Zs,pi as Qs,pl as $s,pn as ec,po as tc,pr as nc,ps as rc,pt as ic,pu as ac,q as oc,qa as sc,qc as cc,qi as lc,ql as uc,qn as dc,qo as fc,qr as pc,qs as mc,qt as hc,qu as gc,r as _c,ra as U,rc as vc,ri as yc,rl as bc,rn as xc,ro as W,rr as Sc,rs as Cc,rt as wc,ru as Tc,s as Ec,sa as Dc,sc as Oc,si as kc,sl as Ac,sn as jc,so as Mc,sr as Nc,ss as Pc,st as Fc,su as Ic,t as Lc,ta as Rc,tc as zc,td as Bc,ti as Vc,tl as Hc,tn as Uc,to as Wc,tr as Gc,ts as Kc,tt as qc,u as Jc,ua as Yc,uc as Xc,ui as Zc,ul as Qc,uo as $c,ur as el,us as tl,ut as nl,uu as rl,v as il,va as al,vc as ol,vi as sl,vl as cl,vn as ll,vo as ul,vr as dl,vs as fl,vt as pl,vu as ml,w as hl,wa as gl,wc as _l,wi as vl,wl as yl,wn as bl,wo as xl,wr as Sl,ws as Cl,wt as wl,wu as Tl,xa as El,xc as Dl,xi as Ol,xl as kl,xn as Al,xo as jl,xr as Ml,xs as Nl,xu as Pl,y as Fl,ya as Il,yc as Ll,yi as Rl,yl as zl,yn as Bl,yo as Vl,yr as Hl,ys as Ul,yt as Wl,yu as Gl,z as Kl,za as ql,zc as Jl,zi as Yl,zl as Xl,zn as Zl,zo as Ql,zr as $l,zs as eu,zt as tu,zu as G}from"./chunk-K2UTITRG-CJkr0tXj.js";import{n as nu}from"./chunk-6U3AYISY-sM9HnDSj.js";import{t as ru}from"./chunk-Z3N5DIM6-DVAc8Qv7.js";var K=e(cr(),1),q=wi(),iu=0;function au(e,t){let n=`atom${++iu}`,r={toString(){return n}};return typeof e==`function`?r.read=e:(r.init=e,r.read=ou,r.write=su),t&&(r.write=t),r}function ou(e){return e(this)}function su(e,t,n){return t(this,typeof n==`function`?n(e(this)):n)}var cu=(e,t)=>e.unstable_is?e.unstable_is(t):t===e,lu=e=>`init`in e,uu=e=>!!e.write,du=new WeakMap,fu=e=>hu(e)&&!du.get(e)?.[1],pu=(e,t)=>{let n=du.get(e);n&&(n[1]=!0,n[0].forEach(e=>e(t)))},mu=e=>{if(du.has(e))return;let t=[new Set,!1];du.set(e,t);let n=()=>{t[1]=!0};e.then(n,n),e.onCancel=e=>{t[0].add(e)}},hu=e=>typeof e?.then==`function`,gu=e=>`v`in e||`e`in e,_u=e=>{if(`e`in e)throw e.e;return e.v},vu=(e,t,n)=>{n.p.has(e)||(n.p.add(e),t.then(()=>{n.p.delete(e)},()=>{n.p.delete(e)}))},yu=(e,t,n,r,i)=>{var a;n.d.set(r,i.n),fu(n.v)&&vu(t,n.v,i),(a=i.m)==null||a.t.add(t),e&&Cu(e,r,t)},bu=()=>({D:new Map,H:new Set,M:new Set,L:new Set}),xu=(e,t,n)=>{e[t].add(n)},Su=(e,t,n)=>{e.D.has(t)||(e.D.set(t,new Set),xu(e,`M`,()=>{var t;(t=n.m)==null||t.l.forEach(t=>xu(e,`M`,t))}))},Cu=(e,t,n)=>{let r=e.D.get(t);r&&r.add(n)},wu=(e,t)=>e.D.get(t),Tu=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},Eu=(...[e,t,n,r])=>{let i=(t,n,r)=>{let i=`v`in n,a=n.v,o=fu(n.v)?n.v:null;if(hu(r)){mu(r);for(let i of n.d.keys())vu(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&&pu(o,r))},a=(n,r)=>{var o;let s=e(r);if(gu(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(cu(r,t)){let n=e(t);if(!gu(n))if(lu(t))i(t,n,t.init);else throw Error(`no atom init`);return _u(n)}let o=a(n,t);try{return _u(o)}finally{if(c)yu(n,r,s,t,o);else{let e=bu();yu(e,r,s,t,o),d(e,r,s),Tu(e)}}},f,p,m={get signal(){return f||=new AbortController,f.signal},get setSelf(){return!p&&uu(r)&&(p=(...e)=>{if(!c)return u(r,...e)}),p}};try{let e=t(r,l,m);if(i(r,s,e),hu(e)){(o=e.onCancel)==null||o.call(e,()=>f?.abort());let t=()=>{if(s.m){let e=bu();d(e,r,s),Tu(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=>_u(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=wu(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])}xu(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&&(Su(e,i,o),n.add(i))),delete o.x}})},l=(t,r,...o)=>{let s=!0,u=e=>_u(a(t,e)),f=(n,...a)=>{let o=e(n);try{if(cu(r,n)){if(!lu(n))throw Error(`atom not writable`);let e=o.n,r=a[0];i(n,o,r),d(t,n,o),e!==o.n&&(Su(t,n,o),c(t,n,o));return}else return l(t,n,...a)}finally{s||Tu(t)}};try{return n(r,u,f,...o)}finally{s=!1}},u=(e,...t)=>{let n=bu();try{return l(n,e,...t)}finally{Tu(n)}},d=(t,n,r)=>{if(r.m&&!fu(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},uu(n)){let e=i.m,a,o=(e,t)=>{let r=!0;a=(...t)=>{try{return l(e,n,...t)}finally{r||Tu(e)}};try{return t()}finally{r=!1}};xu(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&&xu(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=bu(),i=e(t),a=f(r,t,i).l;return a.add(n),Tu(r),()=>{a.delete(n);let e=bu();p(e,t,i),Tu(e)}},unstable_derive:i=>Eu(...i(e,t,n,r))}},Du=()=>{let e=new WeakMap;return Eu(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))},Ou,ku=()=>(Ou||=Du(),Ou),Au=(0,K.createContext)(void 0),ju=e=>{let t=(0,K.useContext)(Au);return e?.store||t||ku()},Mu=e=>typeof e?.then==`function`,Nu=e=>{e.status=`pending`,e.then(t=>{e.status=`fulfilled`,e.value=t},t=>{e.status=`rejected`,e.reason=t})},Pu=K.use||(e=>{if(e.status===`pending`)throw e;if(e.status===`fulfilled`)return e.value;throw e.status===`rejected`?e.reason:(Nu(e),e)}),Fu=new WeakMap,Iu=e=>{let t=Fu.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=>{Mu(e)?(Fu.set(e,t),i=e,e.then(a(e),o(e)),s(e)):n(e)})};e.then(a(e),o(e)),s(e)}),Fu.set(e,t)),t};function Lu(e,t){let n=ju(t),[[r,i,a],o]=(0,K.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,K.useEffect)(()=>{let t=n.sub(e,()=>{if(typeof c==`number`){let t=n.get(e);Mu(t)&&Nu(Iu(t)),setTimeout(o,c);return}o()});return o(),t},[n,e,c]),(0,K.useDebugValue)(s),Mu(s)?Pu(Iu(s)):s}function Ru(e,t){let n=ju(t);return(0,K.useCallback)((...t)=>n.set(e,...t),[n,e])}function zu(e,t){return[Lu(e,t),Ru(e,t)]}var Bu=new WeakMap;function Vu(e,t){let n=ju(t),r=Hu(n);for(let[i,a]of e)(!r.has(i)||t?.dangerouslyForceHydrate)&&(r.add(i),n.set(i,a))}var Hu=e=>{let t=Bu.get(e);return t||(t=new WeakSet,Bu.set(e,t)),t};function Uu(){return Uu=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},Uu.apply(this,arguments)}function Wu(){let e=(0,K.createContext)(null);function t({store:t,initialValues:n=[],children:r}){let i=(0,K.useRef)(t);return i.current||=Du(),Vu(n,{store:i.current}),(0,q.jsx)(e.Provider,{value:i.current,children:r})}let n=t=>{let n=(0,K.useContext)(e);if(!n)throw Error(`Missing Provider from createIsolation`);return ju(Uu({store:n},t))};return{Provider:t,useStore:n,useAtom:(e,t)=>{let r=n();return zu(e,Uu({store:r},t))},useAtomValue:(e,t)=>{let r=n();return Lu(e,Uu({store:r},t))},useSetAtom:(e,t)=>{let r=n();return Ru(e,Uu({store:r},t))}}}var{read:Gu,write:Ku}=au(null);(0,K.createContext)({scope:void 0,baseStore:void 0});var qu=t((e=>{var t=cr();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;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.unstable_batchedUpdates=function(e,t){return e(t)}})),Ju=e(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=qu()}))(),1);function Yu(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}function Xu(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function Zu(...e){return t=>{let n=!1,r=e.map(e=>{let r=Xu(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():Xu(e[t],null)}}}}function Qu(...e){return K.useCallback(Zu(...e),e)}function $u(e,t=[]){let n=[];function r(t,r){let i=K.createContext(r),a=n.length;n=[...n,r];let o=t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=K.useMemo(()=>o,Object.values(o));return(0,q.jsx)(s.Provider,{value:c,children:r})};o.displayName=t+`Provider`;function s(n,o){let s=o?.[e]?.[a]||i,c=K.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=>K.createContext(e));return function(n){let r=n?.[e]||t;return K.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,ed(i,...t)]}function ed(...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 K.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}var td=K.forwardRef((e,t)=>{let{children:n,...r}=e,i=K.Children.toArray(n),a=i.find(id);if(a){let e=a.props.children,n=i.map(t=>t===a?K.Children.count(e)>1?K.Children.only(null):K.isValidElement(e)?e.props.children:null:t);return(0,q.jsx)(nd,{...r,ref:t,children:K.isValidElement(e)?K.cloneElement(e,void 0,n):null})}return(0,q.jsx)(nd,{...r,ref:t,children:n})});td.displayName=`Slot`;var nd=K.forwardRef((e,t)=>{let{children:n,...r}=e;if(K.isValidElement(n)){let e=od(n),i=ad(r,n.props);return n.type!==K.Fragment&&(i.ref=t?Zu(t,e):e),K.cloneElement(n,i)}return K.Children.count(n)>1?K.Children.only(null):null});nd.displayName=`SlotClone`;var rd=({children:e})=>(0,q.jsx)(q.Fragment,{children:e});function id(e){return K.isValidElement(e)&&e.type===rd}function ad(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)=>{a(...e),i(...e)}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function od(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 sd=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=K.forwardRef((e,n)=>{let{asChild:r,...i}=e,a=r?td:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,q.jsx)(a,{...i,ref:n})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function cd(e,t){e&&Ju.flushSync(()=>e.dispatchEvent(t))}function ld(e){let t=K.useRef(e);return K.useEffect(()=>{t.current=e}),K.useMemo(()=>(...e)=>t.current?.(...e),[])}function ud(e,t=globalThis?.document){let n=ld(e);K.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 dd=`DismissableLayer`,fd=`dismissableLayer.update`,pd=`dismissableLayer.pointerDownOutside`,md=`dismissableLayer.focusOutside`,hd,gd=K.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),_d=K.forwardRef((e,t)=>{let{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:a,onInteractOutside:o,onDismiss:s,...c}=e,l=K.useContext(gd),[u,d]=K.useState(null),f=u?.ownerDocument??globalThis?.document,[,p]=K.useState({}),m=Qu(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=bd(e=>{let t=e.target,n=[...l.branches].some(e=>e.contains(t));!b||n||(i?.(e),o?.(e),e.defaultPrevented||s?.())},f),S=xd(e=>{let t=e.target;[...l.branches].some(e=>e.contains(t))||(a?.(e),o?.(e),e.defaultPrevented||s?.())},f);return ud(e=>{v===l.layers.size-1&&(r?.(e),!e.defaultPrevented&&s&&(e.preventDefault(),s()))},f),K.useEffect(()=>{if(u)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(hd=f.body.style.pointerEvents,f.body.style.pointerEvents=`none`),l.layersWithOutsidePointerEventsDisabled.add(u)),l.layers.add(u),Sd(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=hd)}},[u,f,n,l]),K.useEffect(()=>()=>{u&&(l.layers.delete(u),l.layersWithOutsidePointerEventsDisabled.delete(u),Sd())},[u,l]),K.useEffect(()=>{let e=()=>p({});return document.addEventListener(fd,e),()=>document.removeEventListener(fd,e)},[]),(0,q.jsx)(sd.div,{...c,ref:m,style:{pointerEvents:y?b?`auto`:`none`:void 0,...e.style},onFocusCapture:Yu(e.onFocusCapture,S.onFocusCapture),onBlurCapture:Yu(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:Yu(e.onPointerDownCapture,x.onPointerDownCapture)})});_d.displayName=dd;var vd=`DismissableLayerBranch`,yd=K.forwardRef((e,t)=>{let n=K.useContext(gd),r=K.useRef(null),i=Qu(t,r);return K.useEffect(()=>{let e=r.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),(0,q.jsx)(sd.div,{...e,ref:i})});yd.displayName=vd;function bd(e,t=globalThis?.document){let n=ld(e),r=K.useRef(!1),i=K.useRef(()=>{});return K.useEffect(()=>{let e=e=>{if(e.target&&!r.current){let r=function(){Cd(pd,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 xd(e,t=globalThis?.document){let n=ld(e),r=K.useRef(!1);return K.useEffect(()=>{let e=e=>{e.target&&!r.current&&Cd(md,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 Sd(){let e=new CustomEvent(fd);document.dispatchEvent(e)}function Cd(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?cd(i,a):i.dispatchEvent(a)}var wd=0;function Td(){K.useEffect(()=>{let e=document.querySelectorAll(`[data-radix-focus-guard]`);return document.body.insertAdjacentElement(`afterbegin`,e[0]??Ed()),document.body.insertAdjacentElement(`beforeend`,e[1]??Ed()),wd++,()=>{wd===1&&document.querySelectorAll(`[data-radix-focus-guard]`).forEach(e=>e.remove()),wd--}},[])}function Ed(){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 Dd=`focusScope.autoFocusOnMount`,Od=`focusScope.autoFocusOnUnmount`,kd={bubbles:!1,cancelable:!0},Ad=`FocusScope`,jd=K.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=K.useState(null),l=ld(i),u=ld(a),d=K.useRef(null),f=Qu(t,e=>c(e)),p=K.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;K.useEffect(()=>{if(r){let e=function(e){if(p.paused||!s)return;let t=e.target;s.contains(t)?d.current=t:Rd(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||Rd(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&Rd(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]),K.useEffect(()=>{if(s){zd.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(Dd,kd);s.addEventListener(Dd,l),s.dispatchEvent(t),t.defaultPrevented||(Md(Hd(Pd(s)),{select:!0}),document.activeElement===e&&Rd(s))}return()=>{s.removeEventListener(Dd,l),setTimeout(()=>{let t=new CustomEvent(Od,kd);s.addEventListener(Od,u),s.dispatchEvent(t),t.defaultPrevented||Rd(e??document.body,{select:!0}),s.removeEventListener(Od,u),zd.remove(p)},0)}}},[s,l,u,p]);let m=K.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]=Nd(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&Rd(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&Rd(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,q.jsx)(sd.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});jd.displayName=Ad;function Md(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(Rd(r,{select:t}),document.activeElement!==n)return}function Nd(e){let t=Pd(e);return[Fd(t,e),Fd(t.reverse(),e)]}function Pd(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 Fd(e,t){for(let n of e)if(!Id(n,{upTo:t}))return n}function Id(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 Ld(e){return e instanceof HTMLInputElement&&`select`in e}function Rd(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Ld(e)&&t&&e.select()}}var zd=Bd();function Bd(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=Vd(e,t),e.unshift(t)},remove(t){e=Vd(e,t),e[0]?.resume()}}}function Vd(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Hd(e){return e.filter(e=>e.tagName!==`A`)}var Ud=globalThis?.document?K.useLayoutEffect:()=>{},Wd=K.useId||(()=>void 0),Gd=0;function Kd(e){let[t,n]=K.useState(Wd());return Ud(()=>{e||n(e=>e??String(Gd++))},[e]),e||(t?`radix-${t}`:``)}var qd=[`top`,`right`,`bottom`,`left`],Jd=Math.min,Yd=Math.max,Xd=Math.round,Zd=Math.floor,Qd=e=>({x:e,y:e}),$d={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function ef(e,t,n){return Yd(e,Jd(t,n))}function tf(e,t){return typeof e==`function`?e(t):e}function nf(e){return e.split(`-`)[0]}function rf(e){return e.split(`-`)[1]}function af(e){return e===`x`?`y`:`x`}function of(e){return e===`y`?`height`:`width`}function sf(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function cf(e){return af(sf(e))}function lf(e,t,n){n===void 0&&(n=!1);let r=rf(e),i=cf(e),a=of(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=vf(o)),[o,vf(o)]}function uf(e){let t=vf(e);return[df(e),t,df(t)]}function df(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var ff=[`left`,`right`],pf=[`right`,`left`],mf=[`top`,`bottom`],hf=[`bottom`,`top`];function gf(e,t,n){switch(e){case`top`:case`bottom`:return n?t?pf:ff:t?ff:pf;case`left`:case`right`:return t?mf:hf;default:return[]}}function _f(e,t,n,r){let i=rf(e),a=gf(nf(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(df)))),a}function vf(e){let t=nf(e);return $d[t]+e.slice(t.length)}function yf(e){return{top:0,right:0,bottom:0,left:0,...e}}function bf(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:yf(e)}function xf(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 Sf(e,t,n){let{reference:r,floating:i}=e,a=sf(t),o=cf(t),s=of(o),c=nf(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(rf(t)){case`start`:p[o]-=f*(n&&l?-1:1);break;case`end`:p[o]+=f*(n&&l?-1:1);break}return p}async function Cf(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}=tf(t,e),p=bf(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=xf(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=xf(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 wf=50,Tf=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:Cf},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=Sf(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<wf&&(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}=Sf(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},Ef=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}=tf(e,t)||{};if(l==null)return{};let d=bf(u),f={x:n,y:r},p=cf(i),m=of(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,ee=Jd(d[_],T),te=Jd(d[v],T),ne=ee,re=C-h[m]-te,ie=C/2-h[m]/2+w,ae=ef(ne,ie,re),oe=!c.arrow&&rf(i)!=null&&ie!==ae&&a.reference[m]/2-(ie<ne?ee:te)-h[m]/2<0,se=oe?ie<ne?ie-ne:ie-re:0;return{[p]:f[p]+se,data:{[p]:ae,centerOffset:ie-ae-se,...oe&&{alignmentOffset:se}},reset:oe}}}),Df=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}=tf(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=nf(r),_=sf(o),v=nf(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[vf(o)]:uf(o)),x=p!==`none`;!d&&x&&b.push(..._f(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=lf(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`&&_!==sf(t))||T.every(e=>sf(e.placement)===_?e.overflows[0]>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=sf(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;break}if(r!==n)return{reset:{placement:n}}}return{}}}};function Of(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function kf(e){return qd.some(t=>e[t]>=0)}var Af=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=tf(e,t);switch(i){case`referenceHidden`:{let e=Of(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:kf(e)}}}case`escaped`:{let e=Of(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:kf(e)}}}default:return{}}}}},jf=new Set([`left`,`top`]);async function Mf(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=nf(n),s=rf(n),c=sf(n)===`y`,l=jf.has(o)?-1:1,u=a&&c?-1:1,d=tf(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 Nf=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 Mf(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}}}}},Pf=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}=tf(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=sf(nf(i)),p=af(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=ef(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=ef(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}}}}}},Ff=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}=tf(e,t),u={x:n,y:r},d=sf(i),f=af(d),p=u[f],m=u[d],h=tf(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=jf.has(nf(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}}}},If=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}=tf(e,t),u=await o.detectOverflow(t,l),d=nf(i),f=rf(i),p=sf(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=Jd(h-u[g],v),x=Jd(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=Yd(u.left,0),t=Yd(u.right,0),n=Yd(u.top,0),r=Yd(u.bottom,0);p?w=m-2*(e!==0||t!==0?e+t:Yd(u.left,u.right)):C=h-2*(n!==0||r!==0?n+r:Yd(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 Lf(){return typeof window<`u`}function Rf(e){return Vf(e)?(e.nodeName||``).toLowerCase():`#document`}function zf(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Bf(e){return((Vf(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function Vf(e){return Lf()?e instanceof Node||e instanceof zf(e).Node:!1}function Hf(e){return Lf()?e instanceof Element||e instanceof zf(e).Element:!1}function Uf(e){return Lf()?e instanceof HTMLElement||e instanceof zf(e).HTMLElement:!1}function Wf(e){return!Lf()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof zf(e).ShadowRoot}function Gf(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=np(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function Kf(e){return/^(table|td|th)$/.test(Rf(e))}function qf(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var Jf=/transform|translate|scale|rotate|perspective|filter/,Yf=/paint|layout|strict|content/,Xf=e=>!!e&&e!==`none`,Zf;function Qf(e){let t=Hf(e)?np(e):e;return Xf(t.transform)||Xf(t.translate)||Xf(t.scale)||Xf(t.rotate)||Xf(t.perspective)||!ep()&&(Xf(t.backdropFilter)||Xf(t.filter))||Jf.test(t.willChange||``)||Yf.test(t.contain||``)}function $f(e){let t=ip(e);for(;Uf(t)&&!tp(t);){if(Qf(t))return t;if(qf(t))return null;t=ip(t)}return null}function ep(){return Zf??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Zf}function tp(e){return/^(html|body|#document)$/.test(Rf(e))}function np(e){return zf(e).getComputedStyle(e)}function rp(e){return Hf(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ip(e){if(Rf(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||Wf(e)&&e.host||Bf(e);return Wf(t)?t.host:t}function ap(e){let t=ip(e);return tp(t)?e.ownerDocument?e.ownerDocument.body:e.body:Uf(t)&&Gf(t)?t:ap(t)}function op(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=ap(e),i=r===e.ownerDocument?.body,a=zf(r);if(i){let e=sp(a);return t.concat(a,a.visualViewport||[],Gf(r)?r:[],e&&n?op(e):[])}else return t.concat(r,op(r,[],n))}function sp(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function cp(e){let t=np(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=Uf(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=Xd(n)!==a||Xd(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function lp(e){return Hf(e)?e:e.contextElement}function up(e){let t=lp(e);if(!Uf(t))return Qd(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=cp(t),o=(a?Xd(n.width):n.width)/r,s=(a?Xd(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var dp=Qd(0);function fp(e){let t=zf(e);return!ep()||!t.visualViewport?dp:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function pp(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==zf(e)?!1:t}function mp(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=lp(e),o=Qd(1);t&&(r?Hf(r)&&(o=up(r)):o=up(e));let s=pp(a,n,r)?fp(a):Qd(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=zf(a),t=r&&Hf(r)?zf(r):r,n=e,i=sp(n);for(;i&&r&&t!==n;){let e=up(i),t=i.getBoundingClientRect(),r=np(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=zf(i),i=sp(n)}}return xf({width:u,height:d,x:c,y:l})}function hp(e,t){let n=rp(e).scrollLeft;return t?t.left+n:mp(Bf(e)).left+n}function gp(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-hp(e,n),y:n.top+t.scrollTop}}function _p(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=Bf(r),s=t?qf(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=Qd(1),u=Qd(0),d=Uf(r);if((d||!d&&!a)&&((Rf(r)!==`body`||Gf(o))&&(c=rp(r)),d)){let e=mp(r);l=up(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?gp(o,c):Qd(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 vp(e){return Array.from(e.getClientRects())}function yp(e){let t=Bf(e),n=rp(e),r=e.ownerDocument.body,i=Yd(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=Yd(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+hp(e),s=-n.scrollTop;return np(r).direction===`rtl`&&(o+=Yd(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}var bp=25;function xp(e,t){let n=zf(e),r=Bf(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=ep();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=hp(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<=bp&&(a-=o)}else l<=bp&&(a+=l);return{width:a,height:o,x:s,y:c}}function Sp(e,t){let n=mp(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=Uf(e)?up(e):Qd(1);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function Cp(e,t,n){let r;if(t===`viewport`)r=xp(e,n);else if(t===`document`)r=yp(Bf(e));else if(Hf(t))r=Sp(t,n);else{let n=fp(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return xf(r)}function wp(e,t){let n=ip(e);return n===t||!Hf(n)||tp(n)?!1:np(n).position===`fixed`||wp(n,t)}function Tp(e,t){let n=t.get(e);if(n)return n;let r=op(e,[],!1).filter(e=>Hf(e)&&Rf(e)!==`body`),i=null,a=np(e).position===`fixed`,o=a?ip(e):e;for(;Hf(o)&&!tp(o);){let t=np(o),n=Qf(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&(i.position===`absolute`||i.position===`fixed`)||Gf(o)&&!n&&wp(e,o))?r=r.filter(e=>e!==o):i=t,o=ip(o)}return t.set(e,r),r}function Ep(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?qf(t)?[]:Tp(t,this._c):[].concat(n),r],o=Cp(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=Cp(t,a[e],i);s=Yd(n.top,s),c=Jd(n.right,c),l=Jd(n.bottom,l),u=Yd(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function Dp(e){let{width:t,height:n}=cp(e);return{width:t,height:n}}function Op(e,t,n){let r=Uf(t),i=Bf(t),a=n===`fixed`,o=mp(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=Qd(0);function l(){c.x=hp(i)}if(r||!r&&!a)if((Rf(t)!==`body`||Gf(i))&&(s=rp(t)),r){let e=mp(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}else i&&l();a&&!r&&i&&l();let u=i&&!r&&!a?gp(i,s):Qd(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 kp(e){return np(e).position===`static`}function Ap(e,t){if(!Uf(e)||np(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return Bf(e)===n&&(n=n.ownerDocument.body),n}function jp(e,t){let n=zf(e);if(qf(e))return n;if(!Uf(e)){let t=ip(e);for(;t&&!tp(t);){if(Hf(t)&&!kp(t))return t;t=ip(t)}return n}let r=Ap(e,t);for(;r&&Kf(r)&&kp(r);)r=Ap(r,t);return r&&tp(r)&&kp(r)&&!Qf(r)?n:r||$f(e)||n}var Mp=async function(e){let t=this.getOffsetParent||jp,n=this.getDimensions,r=await n(e.floating);return{reference:Op(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Np(e){return np(e).direction===`rtl`}var Pp={convertOffsetParentRelativeRectToViewportRelativeRect:_p,getDocumentElement:Bf,getClippingRect:Ep,getOffsetParent:jp,getElementRects:Mp,getClientRects:vp,getDimensions:Dp,getScale:up,isElement:Hf,isRTL:Np};function Fp(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Ip(e,t){let n=null,r,i=Bf(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=Zd(d),h=Zd(i.clientWidth-(u+f)),g=Zd(i.clientHeight-(d+p)),_=Zd(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:Yd(0,Jd(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&&!Fp(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 Lp(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=lp(e),u=i||a?[...l?op(l):[],...t?op(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?Ip(l,n):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?mp(e):null;c&&g();function g(){let t=mp(e);h&&!Fp(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 Rp=Nf,zp=Pf,Bp=Df,Vp=If,Hp=Af,Up=Ef,Wp=Ff,Gp=(e,t,n)=>{let r=new Map,i={platform:Pp,...n},a={...i.platform,_c:r};return Tf(e,t,{...i,platform:a})},Kp=typeof document<`u`?K.useLayoutEffect:function(){};function qp(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(!qp(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)&&!qp(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function Jp(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Yp(e,t){let n=Jp(e);return Math.round(t*n)/n}function Xp(e){let t=K.useRef(e);return Kp(()=>{t.current=e}),t}function Zp(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]=K.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=K.useState(r);qp(f,r)||p(r);let[m,h]=K.useState(null),[g,_]=K.useState(null),v=K.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=K.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=K.useRef(null),C=K.useRef(null),w=K.useRef(u),T=c!=null,ee=Xp(c),te=Xp(i),ne=Xp(l),re=K.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};te.current&&(e.platform=te.current),Gp(S.current,C.current,e).then(e=>{let t={...e,isPositioned:ne.current!==!1};ie.current&&!qp(w.current,t)&&(w.current=t,Ju.flushSync(()=>{d(t)}))})},[f,t,n,te,ne]);Kp(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let ie=K.useRef(!1);Kp(()=>(ie.current=!0,()=>{ie.current=!1}),[]),Kp(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(ee.current)return ee.current(b,x,re);re()}},[b,x,re,ee,T]);let ae=K.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),oe=K.useMemo(()=>({reference:b,floating:x}),[b,x]),se=K.useMemo(()=>{let e={position:n,left:0,top:0};if(!oe.floating)return e;let t=Yp(oe.floating,u.x),r=Yp(oe.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...Jp(oe.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,oe.floating,u.x,u.y]);return K.useMemo(()=>({...u,update:re,refs:ae,elements:oe,floatingStyles:se}),[u,re,ae,oe,se])}var Qp=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?{}:Up({element:r.current,padding:i}).fn(n):r?Up({element:r,padding:i}).fn(n):{}}}},$p=(e,t)=>{let n=Rp(e);return{name:n.name,fn:n.fn,options:[e,t]}},em=(e,t)=>{let n=zp(e);return{name:n.name,fn:n.fn,options:[e,t]}},tm=(e,t)=>({fn:Wp(e).fn,options:[e,t]}),nm=(e,t)=>{let n=Bp(e);return{name:n.name,fn:n.fn,options:[e,t]}},rm=(e,t)=>{let n=Vp(e);return{name:n.name,fn:n.fn,options:[e,t]}},im=(e,t)=>{let n=Hp(e);return{name:n.name,fn:n.fn,options:[e,t]}},am=(e,t)=>{let n=Qp(e);return{name:n.name,fn:n.fn,options:[e,t]}},om=`Arrow`,sm=K.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,q.jsx)(sd.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,q.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});sm.displayName=om;var cm=sm;function lm(e){let[t,n]=K.useState(void 0);return Ud(()=>{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)}else n(void 0)},[e]),t}var um=`Popper`,[dm,fm]=$u(um),[pm,mm]=dm(um),hm=e=>{let{__scopePopper:t,children:n}=e,[r,i]=K.useState(null);return(0,q.jsx)(pm,{scope:t,anchor:r,onAnchorChange:i,children:n})};hm.displayName=um;var gm=`PopperAnchor`,_m=K.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=mm(gm,n),o=K.useRef(null),s=Qu(t,o);return K.useEffect(()=>{a.onAnchorChange(r?.current||o.current)}),r?null:(0,q.jsx)(sd.div,{...i,ref:s})});_m.displayName=gm;var vm=`PopperContent`,[ym,bm]=dm(vm),xm=K.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=mm(vm,n),[_,v]=K.useState(null),y=Qu(t,e=>v(e)),[b,x]=K.useState(null),S=lm(b),C=S?.width??0,w=S?.height??0,T=r+(a===`center`?``:`-`+a),ee=typeof u==`number`?u:{top:0,right:0,bottom:0,left:0,...u},te=Array.isArray(l)?l:[l],ne=te.length>0,re={padding:ee,boundary:te.filter(Tm),altBoundary:ne},{refs:ie,floatingStyles:ae,placement:oe,isPositioned:se,middlewareData:ce}=Zp({strategy:`fixed`,placement:T,whileElementsMounted:(...e)=>Lp(...e,{animationFrame:p===`always`}),elements:{reference:g.anchor},middleware:[$p({mainAxis:i+w,alignmentAxis:o}),c&&em({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?tm():void 0,...re}),c&&nm({...re}),rm({...re,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&&am({element:b,padding:s}),Em({arrowWidth:C,arrowHeight:w}),f&&im({strategy:`referenceHidden`,...re})]}),[le,ue]=Dm(oe),de=ld(m);Ud(()=>{se&&de?.()},[se,de]);let fe=ce.arrow?.x,pe=ce.arrow?.y,me=ce.arrow?.centerOffset!==0,[he,ge]=K.useState();return Ud(()=>{_&&ge(window.getComputedStyle(_).zIndex)},[_]),(0,q.jsx)(`div`,{ref:ie.setFloating,"data-radix-popper-content-wrapper":``,style:{...ae,transform:se?ae.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:he,"--radix-popper-transform-origin":[ce.transformOrigin?.x,ce.transformOrigin?.y].join(` `),...ce.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,q.jsx)(ym,{scope:n,placedSide:le,onArrowChange:x,arrowX:fe,arrowY:pe,shouldHideArrow:me,children:(0,q.jsx)(sd.div,{"data-side":le,"data-align":ue,...h,ref:y,style:{...h.style,animation:se?void 0:`none`}})})})});xm.displayName=vm;var Sm=`PopperArrow`,Cm={top:`bottom`,right:`left`,bottom:`top`,left:`right`},wm=K.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=bm(Sm,n),a=Cm[i.placedSide];return(0,q.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,q.jsx)(cm,{...r,ref:t,style:{...r.style,display:`block`}})})});wm.displayName=Sm;function Tm(e){return e!==null}var Em=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]=Dm(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 Dm(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var Om=hm,km=_m,Am=xm,jm=wm,Mm=`Portal`,Nm=K.forwardRef((e,t)=>{let{container:n,...r}=e,[i,a]=K.useState(!1);Ud(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?Ju.createPortal((0,q.jsx)(sd.div,{...r,ref:t}),o):null});Nm.displayName=Mm;function Pm(e,t){return K.useReducer((e,n)=>t[e][n]??e,e)}var Fm=e=>{let{present:t,children:n}=e,r=Im(t),i=typeof n==`function`?n({present:r.isPresent}):K.Children.only(n),a=Qu(r.ref,Rm(i));return typeof n==`function`||r.isPresent?K.cloneElement(i,{ref:a}):null};Fm.displayName=`Presence`;function Im(e){let[t,n]=K.useState(),r=K.useRef({}),i=K.useRef(e),a=K.useRef(`none`),[o,s]=Pm(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return K.useEffect(()=>{let e=Lm(r.current);a.current=o===`mounted`?e:`none`},[o]),Ud(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,o=Lm(t);e?s(`MOUNT`):o===`none`||t?.display===`none`?s(`UNMOUNT`):s(n&&r!==o?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,s]),Ud(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=Lm(r.current).includes(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=Lm(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)}}else s(`ANIMATION_END`)},[t,s]),{isPresent:[`mounted`,`unmountSuspended`].includes(o),ref:K.useCallback(e=>{e&&(r.current=getComputedStyle(e)),n(e)},[])}}function Lm(e){return e?.animationName||`none`}function Rm(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)}function zm({prop:e,defaultProp:t,onChange:n=()=>{}}){let[r,i]=Bm({defaultProp:t,onChange:n}),a=e!==void 0,o=a?e:r,s=ld(n);return[o,K.useCallback(t=>{if(a){let n=typeof t==`function`?t(e):t;n!==e&&s(n)}else i(t)},[a,e,i,s])]}function Bm({defaultProp:e,onChange:t}){let n=K.useState(e),[r]=n,i=K.useRef(r),a=ld(t);return K.useEffect(()=>{i.current!==r&&(a(r),i.current=r)},[r,i,a]),n}var Vm=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},Hm=new WeakMap,Um=new WeakMap,Wm={},Gm=0,Km=function(e){return e&&(e.host||Km(e.parentNode))},qm=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=Km(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})},Jm=function(e,t,n,r){var i=qm(t,Array.isArray(e)?e:[e]);Wm[n]||(Wm[n]=new WeakMap);var a=Wm[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=(Hm.get(e)||0)+1,l=(a.get(e)||0)+1;Hm.set(e,c),a.set(e,l),o.push(e),c===1&&i&&Um.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(),Gm++,function(){o.forEach(function(e){var t=Hm.get(e)-1,i=a.get(e)-1;Hm.set(e,t),a.set(e,i),t||(Um.has(e)||e.removeAttribute(r),Um.delete(e)),i||e.removeAttribute(n)}),Gm--,Gm||(Hm=new WeakMap,Hm=new WeakMap,Um=new WeakMap,Wm={})}},Ym=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||Vm(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),Jm(r,i,n,`aria-hidden`)):function(){return null}},Xm=function(){return Xm=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},Xm.apply(this,arguments)};function Zm(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 Qm(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 $m=`right-scroll-bar-position`,eh=`width-before-scroll-bar`,th=`with-scroll-bars-hidden`,nh=`--removed-body-scroll-bar-size`;function rh(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function ih(e,t){var n=(0,K.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 ah=typeof window<`u`?K.useLayoutEffect:K.useEffect,oh=new WeakMap;function sh(e,t){var n=ih(t||null,function(t){return e.forEach(function(e){return rh(e,t)})});return ah(function(){var t=oh.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||rh(e,null)}),i.forEach(function(e){r.has(e)||rh(e,a)})}oh.set(n,e)},[e]),n}function ch(e){return e}function lh(e,t){t===void 0&&(t=ch);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 uh(e){e===void 0&&(e={});var t=lh(null);return t.options=Xm({async:!0,ssr:!1},e),t}var dh=function(e){var t=e.sideCar,n=Zm(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 K.createElement(r,Xm({},n))};dh.isSideCarExport=!0;function fh(e,t){return e.useMedium(t),dh}var ph=uh(),mh=function(){},hh=K.forwardRef(function(e,t){var n=K.useRef(null),r=K.useState({onScrollCapture:mh,onWheelCapture:mh,onTouchMoveCapture:mh}),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=Zm(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),x=f,S=sh([n,t]),C=Xm(Xm({},b),i);return K.createElement(K.Fragment,null,u&&K.createElement(x,{sideCar:ph,removeScrollBar:l,shards:d,noRelative:p,noIsolation:m,inert:h,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:y}),o?K.cloneElement(K.Children.only(s),Xm(Xm({},C),{ref:S})):K.createElement(v,Xm({},C,{className:c,ref:S}),s))});hh.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},hh.classNames={fullWidth:eh,zeroRight:$m};var gh,_h=function(){if(gh)return gh;if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function vh(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=_h();return t&&e.setAttribute(`nonce`,t),e}function yh(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function bh(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var xh=function(){var e=0,t=null;return{add:function(n){e==0&&(t=vh())&&(yh(t,n),bh(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Sh=function(){var e=xh();return function(t,n){K.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Ch=function(){var e=Sh();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},wh={left:0,top:0,right:0,gap:0},Th=function(e){return parseInt(e||``,10)||0},Eh=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[Th(n),Th(r),Th(i)]},Dh=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return wh;var t=Eh(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])}},Oh=Ch(),kh=`data-scroll-locked`,Ah=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
+ .${th} {
4
+ overflow: hidden ${r};
5
+ padding-right: ${s}px ${r};
6
+ }
7
+ body[${kh}] {
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
+ .${$m} {
21
+ right: ${s}px ${r};
22
+ }
23
+
24
+ .${eh} {
25
+ margin-right: ${s}px ${r};
26
+ }
27
+
28
+ .${$m} .${$m} {
29
+ right: 0 ${r};
30
+ }
31
+
32
+ .${eh} .${eh} {
33
+ margin-right: 0 ${r};
34
+ }
35
+
36
+ body[${kh}] {
37
+ ${nh}: ${s}px;
38
+ }
39
+ `},jh=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},Mh=function(){K.useEffect(function(){return document.body.setAttribute(kh,(jh()+1).toString()),function(){var e=jh()-1;e<=0?document.body.removeAttribute(kh):document.body.setAttribute(kh,e.toString())}},[])},Nh=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;Mh();var a=K.useMemo(function(){return Dh(i)},[i]);return K.createElement(Oh,{styles:Ah(a,!t,i,n?``:`!important`)})},Ph=!1;if(typeof window<`u`)try{var Fh=Object.defineProperty({},`passive`,{get:function(){return Ph=!0,!0}});window.addEventListener(`test`,Fh,Fh),window.removeEventListener(`test`,Fh,Fh)}catch{Ph=!1}var Ih=Ph?{passive:!1}:!1,Lh=function(e){return e.tagName===`TEXTAREA`},Rh=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!Lh(e)&&n[t]===`visible`)},zh=function(e){return Rh(e,`overflowY`)},Bh=function(e){return Rh(e,`overflowX`)},Vh=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),Wh(e,r)){var i=Gh(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Hh=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},Uh=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},Wh=function(e,t){return e===`v`?zh(t):Bh(t)},Gh=function(e,t){return e===`v`?Hh(t):Uh(t)},Kh=function(e,t){return e===`h`&&t===`rtl`?-1:1},qh=function(e,t,n,r,i){var a=Kh(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=Gh(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&Wh(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},Jh=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Yh=function(e){return[e.deltaX,e.deltaY]},Xh=function(e){return e&&`current`in e?e.current:e},Zh=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Qh=function(e){return`
40
+ .block-interactivity-${e} {pointer-events: none;}
41
+ .allow-interactivity-${e} {pointer-events: all;}
42
+ `},$h=0,eg=[];function tg(e){var t=K.useRef([]),n=K.useRef([0,0]),r=K.useRef(),i=K.useState($h++)[0],a=K.useState(Ch)[0],o=K.useRef(e);K.useEffect(function(){o.current=e},[e]),K.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=Qm([e.lockRef.current],(e.shards||[]).map(Xh),!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=K.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=Jh(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=Vh(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=Vh(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 qh(h,t,e,h===`h`?s:c,!0)},[]),c=K.useCallback(function(e){var n=e;if(!(!eg.length||eg[eg.length-1]!==a)){var r=`deltaY`in n?Yh(n):Jh(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&Zh(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(Xh).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=K.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:ng(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=K.useCallback(function(e){n.current=Jh(e),r.current=void 0},[]),d=K.useCallback(function(t){l(t.type,Yh(t),t.target,s(t,e.lockRef.current))},[]),f=K.useCallback(function(t){l(t.type,Jh(t),t.target,s(t,e.lockRef.current))},[]);K.useEffect(function(){return eg.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,Ih),document.addEventListener(`touchmove`,c,Ih),document.addEventListener(`touchstart`,u,Ih),function(){eg=eg.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,Ih),document.removeEventListener(`touchmove`,c,Ih),document.removeEventListener(`touchstart`,u,Ih)}},[]);var p=e.removeScrollBar,m=e.inert;return K.createElement(K.Fragment,null,m?K.createElement(a,{styles:Qh(i)}):null,p?K.createElement(Nh,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function ng(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var rg=fh(ph,tg),ig=K.forwardRef(function(e,t){return K.createElement(hh,Xm({},e,{ref:t,sideCar:rg}))});ig.classNames=hh.classNames;var ag=`Popover`,[og,sg]=$u(ag,[fm]),cg=fm(),[lg,ug]=og(ag),dg=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=cg(t),c=K.useRef(null),[l,u]=K.useState(!1),[d=!1,f]=zm({prop:r,defaultProp:i,onChange:a});return(0,q.jsx)(Om,{...s,children:(0,q.jsx)(lg,{scope:t,contentId:Kd(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:K.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:K.useCallback(()=>u(!0),[]),onCustomAnchorRemove:K.useCallback(()=>u(!1),[]),modal:o,children:n})})};dg.displayName=ag;var fg=`PopoverAnchor`,pg=K.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=ug(fg,n),a=cg(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return K.useEffect(()=>(o(),()=>s()),[o,s]),(0,q.jsx)(km,{...a,...r,ref:t})});pg.displayName=fg;var mg=`PopoverTrigger`,hg=K.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=ug(mg,n),a=cg(n),o=Qu(t,i.triggerRef),s=(0,q.jsx)(sd.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":kg(i.open),...r,ref:o,onClick:Yu(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,q.jsx)(km,{asChild:!0,...a,children:s})});hg.displayName=mg;var gg=`PopoverPortal`,[_g,vg]=og(gg,{forceMount:void 0}),yg=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=ug(gg,t);return(0,q.jsx)(_g,{scope:t,forceMount:n,children:(0,q.jsx)(Fm,{present:n||a.open,children:(0,q.jsx)(Nm,{asChild:!0,container:i,children:r})})})};yg.displayName=gg;var bg=`PopoverContent`,xg=K.forwardRef((e,t)=>{let n=vg(bg,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=ug(bg,e.__scopePopover);return(0,q.jsx)(Fm,{present:r||a.open,children:a.modal?(0,q.jsx)(Sg,{...i,ref:t}):(0,q.jsx)(Cg,{...i,ref:t})})});xg.displayName=bg;var Sg=K.forwardRef((e,t)=>{let n=ug(bg,e.__scopePopover),r=K.useRef(null),i=Qu(t,r),a=K.useRef(!1);return K.useEffect(()=>{let e=r.current;if(e)return Ym(e)},[]),(0,q.jsx)(ig,{as:td,allowPinchZoom:!0,children:(0,q.jsx)(wg,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Yu(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:Yu(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;a.current=t.button===2||n},{checkForDefaultPrevented:!1}),onFocusOutside:Yu(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),Cg=K.forwardRef((e,t)=>{let n=ug(bg,e.__scopePopover),r=K.useRef(!1),i=K.useRef(!1);return(0,q.jsx)(wg,{...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()}})}),wg=K.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=ug(bg,n),p=cg(n);return Td(),(0,q.jsx)(jd,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,q.jsx)(_d,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),children:(0,q.jsx)(Am,{"data-state":kg(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)`}})})})}),Tg=`PopoverClose`,Eg=K.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=ug(Tg,n);return(0,q.jsx)(sd.button,{type:`button`,...r,ref:t,onClick:Yu(e.onClick,()=>i.onOpenChange(!1))})});Eg.displayName=Tg;var Dg=`PopoverArrow`,Og=K.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=cg(n);return(0,q.jsx)(jm,{...i,...r,ref:t})});Og.displayName=Dg;function kg(e){return e?`open`:`closed`}var Ag=dg,jg=hg,Mg=yg,Ng=xg,Pg=Og,Fg=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}})()})),Ig=e(Ua(),1),Lg=e(Fg(),1),Rg=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:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{n.clear()}};return t=e(r,i,a),a},zg=e=>e?Rg(e):Rg,Bg=t((e=>{var t=cr();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})),Vg=t(((e,t)=>{t.exports=Bg()})),Hg=t((e=>{var t=cr(),n=Vg();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)?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}})),{useSyncExternalStoreWithSelector:Ug}=e(t(((e,t)=>{t.exports=Hg()}))(),1).default;function Wg(e,t=e.getState,n){let r=Ug(e.subscribe,e.getState,e.getServerState||e.getState,t,n);return(0,K.useDebugValue)(r),r}var Gg=e=>{let t=typeof e==`function`?zg(e):e,n=(e,n)=>Wg(t,e,n);return Object.assign(n,t),n},Kg=e=>e?Gg(e):Gg,qg,Jg=typeof window<`u`&&((qg=window.document)!=null&&qg.createElement||window.navigator?.product===`ReactNative`)?K.useLayoutEffect:K.useEffect;function Yg(){let e=Kg(e=>({current:[],version:0,set:e}));return{In:({children:t})=>{let n=e(e=>e.set),r=e(e=>e.version);return Jg(()=>{n(e=>({version:e.version+1}))},[]),Jg(()=>(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 K.createElement(K.Fragment,null,t)}}}function Xg(){return Xg=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Xg.apply(null,arguments)}function Zg(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}function Qg(e,t=[]){let n=[];function r(t,r){let i=(0,K.createContext)(r),a=n.length;n=[...n,r];function o(t){let{scope:n,children:r,...o}=t,s=n?.[e][a]||i,c=(0,K.useMemo)(()=>o,Object.values(o));return(0,K.createElement)(s.Provider,{value:c},r)}function s(n,o){let s=(0,K.useContext)(o?.[e][a]||i);if(s)return s;if(r!==void 0)return r;throw Error(`\`${n}\` must be used within \`${t}\``)}return o.displayName=t+`Provider`,[o,s]}let i=()=>{let t=n.map(e=>(0,K.createContext)(e));return function(n){let r=n?.[e]||t;return(0,K.useMemo)(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,$g(i,...t)]}function $g(...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(0,K.useMemo)(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}function e_(e,t){typeof e==`function`?e(t):e!=null&&(e.current=t)}function t_(...e){return t=>e.forEach(e=>e_(e,t))}function n_(...e){return(0,K.useCallback)(t_(...e),e)}var r_=(0,K.forwardRef)((e,t)=>{let{children:n,...r}=e,i=K.Children.toArray(n),a=i.find(o_);if(a){let e=a.props.children,n=i.map(t=>t===a?K.Children.count(e)>1?K.Children.only(null):(0,K.isValidElement)(e)?e.props.children:null:t);return(0,K.createElement)(i_,Xg({},r,{ref:t}),(0,K.isValidElement)(e)?(0,K.cloneElement)(e,void 0,n):null)}return(0,K.createElement)(i_,Xg({},r,{ref:t}),n)});r_.displayName=`Slot`;var i_=(0,K.forwardRef)((e,t)=>{let{children:n,...r}=e;return(0,K.isValidElement)(n)?(0,K.cloneElement)(n,{...s_(r,n.props),ref:t_(t,n.ref)}):K.Children.count(n)>1?K.Children.only(null):null});i_.displayName=`SlotClone`;var a_=({children:e})=>(0,K.createElement)(K.Fragment,null,e);function o_(e){return(0,K.isValidElement)(e)&&e.type===a_}function s_(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)=>{a(...e),i(...e)}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function c_(e){let t=e+`CollectionProvider`,[n,r]=Qg(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=e=>{let{scope:t,children:n}=e,r=K.useRef(null),a=K.useRef(new Map).current;return K.createElement(i,{scope:t,itemMap:a,collectionRef:r},n)},s=e+`CollectionSlot`,c=K.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=n_(t,a(s,n).collectionRef);return K.createElement(r_,{ref:i},r)}),l=e+`CollectionItemSlot`,u=`data-radix-collection-item`,d=K.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=K.useRef(null),s=n_(t,o),c=a(l,n);return K.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),K.createElement(r_,{[u]:``,ref:s},r)});function f(t){let n=a(e+`CollectionConsumer`,t);return K.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${u}]`));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:c,ItemSlot:d},f,r]}var l_=globalThis!=null&&globalThis.document?K.useLayoutEffect:()=>{},u_=K.useId||(()=>void 0),d_=0;function f_(e){let[t,n]=K.useState(u_());return l_(()=>{e||n(e=>e??String(d_++))},[e]),e||(t?`radix-${t}`:``)}var p_=[`a`,`button`,`div`,`h2`,`h3`,`img`,`label`,`li`,`nav`,`ol`,`p`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=(0,K.forwardRef)((e,n)=>{let{asChild:r,...i}=e,a=r?r_:t;return(0,K.useEffect)(()=>{window[Symbol.for(`radix-ui`)]=!0},[]),(0,K.createElement)(a,Xg({},i,{ref:n}))});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function m_(e){let t=(0,K.useRef)(e);return(0,K.useEffect)(()=>{t.current=e}),(0,K.useMemo)(()=>(...e)=>t.current?.call(t,...e),[])}function h_({prop:e,defaultProp:t,onChange:n=()=>{}}){let[r,i]=g_({defaultProp:t,onChange:n}),a=e!==void 0,o=a?e:r,s=m_(n);return[o,(0,K.useCallback)(t=>{if(a){let n=typeof t==`function`?t(e):t;n!==e&&s(n)}else i(t)},[a,e,i,s])]}function g_({defaultProp:e,onChange:t}){let n=(0,K.useState)(e),[r]=n,i=(0,K.useRef)(r),a=m_(t);return(0,K.useEffect)(()=>{i.current!==r&&(a(r),i.current=r)},[r,i,a]),n}var __=(0,K.createContext)(void 0);function v_(e){let t=(0,K.useContext)(__);return e||t||`ltr`}var y_=`rovingFocusGroup.onEntryFocus`,b_={bubbles:!1,cancelable:!0},x_=`RovingFocusGroup`,[S_,C_,w_]=c_(x_),[T_,E_]=Qg(x_,[w_]),[D_,O_]=T_(x_),k_=(0,K.forwardRef)((e,t)=>(0,K.createElement)(S_.Provider,{scope:e.__scopeRovingFocusGroup},(0,K.createElement)(S_.Slot,{scope:e.__scopeRovingFocusGroup},(0,K.createElement)(A_,Xg({},e,{ref:t}))))),A_=(0,K.forwardRef)((e,t)=>{let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,...u}=e,d=(0,K.useRef)(null),f=n_(t,d),p=v_(a),[m=null,h]=h_({prop:o,defaultProp:s,onChange:c}),[g,_]=(0,K.useState)(!1),v=m_(l),y=C_(n),b=(0,K.useRef)(!1),[x,S]=(0,K.useState)(0);return(0,K.useEffect)(()=>{let e=d.current;if(e)return e.addEventListener(y_,v),()=>e.removeEventListener(y_,v)},[v]),(0,K.createElement)(D_,{scope:n,orientation:r,dir:p,loop:i,currentTabStopId:m,onItemFocus:(0,K.useCallback)(e=>h(e),[h]),onItemShiftTab:(0,K.useCallback)(()=>_(!0),[]),onFocusableItemAdd:(0,K.useCallback)(()=>S(e=>e+1),[]),onFocusableItemRemove:(0,K.useCallback)(()=>S(e=>e-1),[])},(0,K.createElement)(p_.div,Xg({tabIndex:g||x===0?-1:0,"data-orientation":r},u,{ref:f,style:{outline:`none`,...e.style},onMouseDown:Zg(e.onMouseDown,()=>{b.current=!0}),onFocus:Zg(e.onFocus,e=>{let t=!b.current;if(e.target===e.currentTarget&&t&&!g){let t=new CustomEvent(y_,b_);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=y().filter(e=>e.focusable);I_([e.find(e=>e.active),e.find(e=>e.id===m),...e].filter(Boolean).map(e=>e.ref.current))}}b.current=!1}),onBlur:Zg(e.onBlur,()=>_(!1))})))}),j_=`RovingFocusGroupItem`,M_=(0,K.forwardRef)((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,...o}=e,s=f_(),c=a||s,l=O_(j_,n),u=l.currentTabStopId===c,d=C_(n),{onFocusableItemAdd:f,onFocusableItemRemove:p}=l;return(0,K.useEffect)(()=>{if(r)return f(),()=>p()},[r,f,p]),(0,K.createElement)(S_.ItemSlot,{scope:n,id:c,focusable:r,active:i},(0,K.createElement)(p_.span,Xg({tabIndex:u?0:-1,"data-orientation":l.orientation},o,{ref:t,onMouseDown:Zg(e.onMouseDown,e=>{r?l.onItemFocus(c):e.preventDefault()}),onFocus:Zg(e.onFocus,()=>l.onItemFocus(c)),onKeyDown:Zg(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){l.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=F_(e,l.orientation,l.dir);if(t!==void 0){e.preventDefault();let n=d().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=l.loop?L_(n,r+1):n.slice(r+1)}setTimeout(()=>I_(n))}})})))}),N_={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function P_(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function F_(e,t,n){let r=P_(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return N_[r]}function I_(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function L_(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var R_=k_,z_=M_;function B_(e,t){return(0,K.useReducer)((e,n)=>t[e][n]??e,e)}var V_=e=>{let{present:t,children:n}=e,r=H_(t),i=typeof n==`function`?n({present:r.isPresent}):K.Children.only(n),a=n_(r.ref,i.ref);return typeof n==`function`||r.isPresent?(0,K.cloneElement)(i,{ref:a}):null};V_.displayName=`Presence`;function H_(e){let[t,n]=(0,K.useState)(),r=(0,K.useRef)({}),i=(0,K.useRef)(e),a=(0,K.useRef)(`none`),[o,s]=B_(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return(0,K.useEffect)(()=>{let e=U_(r.current);a.current=o===`mounted`?e:`none`},[o]),l_(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,o=U_(t);e?s(`MOUNT`):o===`none`||t?.display===`none`?s(`UNMOUNT`):s(n&&r!==o?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,s]),l_(()=>{if(t){let e=e=>{let n=U_(r.current).includes(e.animationName);e.target===t&&n&&(0,Ju.flushSync)(()=>s(`ANIMATION_END`))},n=e=>{e.target===t&&(a.current=U_(r.current))};return t.addEventListener(`animationstart`,n),t.addEventListener(`animationcancel`,e),t.addEventListener(`animationend`,e),()=>{t.removeEventListener(`animationstart`,n),t.removeEventListener(`animationcancel`,e),t.removeEventListener(`animationend`,e)}}else s(`ANIMATION_END`)},[t,s]),{isPresent:[`mounted`,`unmountSuspended`].includes(o),ref:(0,K.useCallback)(e=>{e&&(r.current=getComputedStyle(e)),n(e)},[])}}function U_(e){return e?.animationName||`none`}var W_=`Tabs`,[G_,K_]=Qg(W_,[E_]),q_=E_(),[J_,Y_]=G_(W_),X_=(0,K.forwardRef)((e,t)=>{let{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o=`horizontal`,dir:s,activationMode:c=`automatic`,...l}=e,u=v_(s),[d,f]=h_({prop:r,onChange:i,defaultProp:a});return(0,K.createElement)(J_,{scope:n,baseId:f_(),value:d,onValueChange:f,orientation:o,dir:u,activationMode:c},(0,K.createElement)(p_.div,Xg({dir:u,"data-orientation":o},l,{ref:t})))}),Z_=`TabsList`,Q_=(0,K.forwardRef)((e,t)=>{let{__scopeTabs:n,loop:r=!0,...i}=e,a=Y_(Z_,n);return(0,K.createElement)(R_,Xg({asChild:!0},q_(n),{orientation:a.orientation,dir:a.dir,loop:r}),(0,K.createElement)(p_.div,Xg({role:`tablist`,"aria-orientation":a.orientation},i,{ref:t})))}),$_=`TabsTrigger`,ev=(0,K.forwardRef)((e,t)=>{let{__scopeTabs:n,value:r,disabled:i=!1,...a}=e,o=Y_($_,n),s=q_(n),c=rv(o.baseId,r),l=iv(o.baseId,r),u=r===o.value;return(0,K.createElement)(z_,Xg({asChild:!0},s,{focusable:!i,active:u}),(0,K.createElement)(p_.button,Xg({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:Zg(e.onMouseDown,e=>{!i&&e.button===0&&e.ctrlKey===!1?o.onValueChange(r):e.preventDefault()}),onKeyDown:Zg(e.onKeyDown,e=>{[` `,`Enter`].includes(e.key)&&o.onValueChange(r)}),onFocus:Zg(e.onFocus,()=>{let e=o.activationMode!==`manual`;!u&&!i&&e&&o.onValueChange(r)})})))}),tv=`TabsContent`,nv=(0,K.forwardRef)((e,t)=>{let{__scopeTabs:n,value:r,forceMount:i,children:a,...o}=e,s=Y_(tv,n),c=rv(s.baseId,r),l=iv(s.baseId,r),u=r===s.value,d=(0,K.useRef)(u);return(0,K.useEffect)(()=>{let e=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,K.createElement)(V_,{present:i||u},({present:n})=>(0,K.createElement)(p_.div,Xg({"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}}),n&&a))});function rv(e,t){return`${e}-trigger-${t}`}function iv(e,t){return`${e}-content-${t}`}var av=X_,ov=Q_,sv=ev,cv=nv,lv=e(t(((e,t)=>{var n=`Expected a function`,r=NaN,i=`[object Symbol]`,a=/^\s+|\s+$/g,o=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,c=/^0o[0-7]+$/i,l=parseInt,u=typeof global==`object`&&global&&global.Object===Object&&global,d=typeof self==`object`&&self&&self.Object===Object&&self,f=u||d||Function(`return this`)(),p=Object.prototype.toString,m=Math.max,h=Math.min,g=function(){return f.Date.now()};function _(e,t,r){var i,a,o,s,c,l,u=0,d=!1,f=!1,p=!0;if(typeof e!=`function`)throw TypeError(n);t=x(t)||0,v(r)&&(d=!!r.leading,f=`maxWait`in r,o=f?m(x(r.maxWait)||0,t):o,p=`trailing`in r?!!r.trailing:p);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?h(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=g();if(S(e))return w(e);c=setTimeout(C,b(e))}function w(e){return c=void 0,p&&i?_(e):(i=a=void 0,s)}function T(){c!==void 0&&clearTimeout(c),u=0,i=l=a=c=void 0}function ee(){return c===void 0?s:w(g())}function te(){var e=g(),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 te.cancel=T,te.flush=ee,te}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)&&p.call(e)==i}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(a,``);var n=s.test(e);return n||c.test(e)?l(e.slice(2),n?2:8):o.test(e)?r:+e}t.exports=_}))(),1);function uv(e,t,n,r){Object.defineProperty(e,t,{get:n,set:r,enumerable:!0,configurable:!0})}uv({},`LaserPointer`,()=>Tv);function dv([e,t,n],[r,i,a]){return[e+r,t+i,n+a]}function fv([e,t,n],[r,i,a]){return[e-r,t-i,n-a]}function pv([e,t,n],r){return[e*r,t*r,n*r]}function mv([e,t,n]){return[e/Math.sqrt(e**2+t**2),t/Math.sqrt(e**2+t**2),n]}function hv([e,t,n],r){return[Math.cos(r)*e-Math.sin(r)*t,Math.sin(r)*e+Math.cos(r)*t,n]}function gv(e,t,n){return dv(e,pv(fv(t,e),n))}function _v(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 vv(e){return Math.atan2(Math.sin(e),Math.cos(e))}function yv([e,t]){return Math.sqrt(e**2+t**2)}function bv([e,t],[n,r]){return Math.sqrt((n-e)**2+(r-t)**2)}function xv(e){if(e.length<2)return 0;let t=0;for(let n=1;n<=e.length-1;n++)t+=bv(e[n-1],e[n]);return t+=bv(e[e.length-2],e[e.length-1]),t}var Sv=(e,t,n)=>Math.max(t,Math.min(n,e));function Cv(e,t,n){let r=bv(t,n);if(r===0)return bv(e,t);let i=Sv(((e[0]-t[0])*(n[0]-t[0])+(e[1]-t[1])*(n[1]-t[1]))/r**2,0,1);return bv([t[0]+i*(n[0]-t[0]),t[1]+i*(n[1]-t[1]),e[2]],e)}function wv(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=Cv(i,n,r);return o>e?[o,a]:[e,t]},[0,-1]);if(i>=t){let i=e[a];return[...wv([n,...e.slice(1,a),i],t).slice(0,-1),i,...wv([i,...e.slice(a,-1),r],t).slice(1)]}else return[n,r]}var Tv=class e{static{this.defaults={size:2,streamline:.45,simplify:.1,simplifyPhase:`output`,keepHead:!1,sizeMapping:()=>1}}static{this.constants={cornerDetectionMaxAngle:75,cornerDetectionVariance:e=>e>35?.5:1,maxTailLength:50}}constructor(t){this.originalPoints=[],this.stablePoints=[],this.tailPoints=[],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=gv(this.lastPoint,t,1-this.options.streamline)),this.tailPoints.push(t),xv(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=wv(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(dv(e,pv(hv([1,0,0],t),i)));return a.push(dv(e,pv([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=_v(e,[e[0],e[1]-100,e[2]],i);for(let t=c;t<=Math.PI+c;t+=Math.PI/16)s.push(dv(e,pv(hv([1,0,0],t),a)));for(let e=Math.PI+c;e<=Math.PI*2+c;e+=Math.PI/16)s.push(dv(i,pv(hv([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=bv(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 _=mv(fv(d,f)),v=mv(fv(p,f)),y=hv(_,Math.PI/2),b=hv(_,-Math.PI/2),x=hv(v,Math.PI/2),S=hv(v,-Math.PI/2),C=dv(f,pv(y,g)),w=dv(f,pv(b,g)),T=dv(f,pv(x,g)),ee=dv(f,pv(S,g)),te=dv(y,S),ne=dv(b,x),re=dv(f,pv(yv(te)===0?_:mv(te),g)),ie=dv(f,pv(yv(ne)===0?v:mv(ne),g)),ae=vv(_v(f,d,p)),oe=e.constants.cornerDetectionMaxAngle/180*Math.PI*e.constants.cornerDetectionVariance(o);if(Math.abs(ae)<oe){let e=Math.abs(vv(Math.PI-ae));if(e===0)continue;if(ae<0){a.push(w,ie);for(let t=0;t<=e;t+=e/4)i.push(dv(f,hv(pv(y,g),t)));for(let t=e;t>=0;t-=e/4)a.push(dv(f,hv(pv(y,g),t)));a.push(ie,T)}else{i.push(C,re);for(let t=0;t<=e;t+=e/4)a.push(dv(f,hv(pv(y,-g),-t)));for(let t=e;t>=0;t-=e/4)i.push(dv(f,hv(pv(y,-g),-t)));i.push(re,ee)}}else i.push(re),a.push(ie);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(dv(e,pv(hv([1,0,0],n),this.options.size)));return t.push(dv(e,pv([1,0,0],this.options.size))),t}else return[];let u=n[c],d=n[c+1],f=n[r-2],p=n[r-1],m=mv(fv(d,u)),h=mv(fv(f,p)),g=hv(m,-Math.PI/2),_=hv(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(dv(u,hv(pv(g,v),-e)));y.unshift(dv(u,pv(g,-v)))}else y.push(u);for(let e=0;e<=Math.PI*3;e+=Math.PI/16)x.push(dv(p,hv(pv(_,-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`?wv(S,this.options.simplify):S}},Ev=Wu(),{useAtom:Dv,useSetAtom:Ov,useAtomValue:kv,useStore:Av}=Ev,jv=Ev.Provider,Mv=Du(),Nv=a({"./locales/ar-SA.json":()=>n(()=>import(`./ar-SA-G6X2FPQ2-DWAZRxPu.js`),__vite__mapDeps([0,1,2,3]),import.meta.url),"./locales/az-AZ.json":()=>n(()=>import(`./az-AZ-76LH7QW2-CD-SA1wC.js`),__vite__mapDeps([4,1,2,3]),import.meta.url),"./locales/bg-BG.json":()=>n(()=>import(`./bg-BG-XCXSNQG7-lFFvFyxW.js`),__vite__mapDeps([5,1,2,3]),import.meta.url),"./locales/bn-BD.json":()=>n(()=>import(`./bn-BD-2XOGV67Q-CuUcZaL8.js`),__vite__mapDeps([6,1,2,3]),import.meta.url),"./locales/ca-ES.json":()=>n(()=>import(`./ca-ES-6MX7JW3Y-Cj4OlC6R.js`),__vite__mapDeps([7,1,2,3]),import.meta.url),"./locales/cs-CZ.json":()=>n(()=>import(`./cs-CZ-2BRQDIVT-9YP2OnzR.js`),__vite__mapDeps([8,1,2,3]),import.meta.url),"./locales/da-DK.json":()=>n(()=>import(`./da-DK-5WZEPLOC-DyH5OvyC.js`),__vite__mapDeps([9,1,2,3]),import.meta.url),"./locales/de-DE.json":()=>n(()=>import(`./de-DE-XR44H4JA-Dm-lIYs8.js`),__vite__mapDeps([10,1,2,3]),import.meta.url),"./locales/el-GR.json":()=>n(()=>import(`./el-GR-BZB4AONW-r581kidc.js`),__vite__mapDeps([11,1,2,3]),import.meta.url),"./locales/en.json":()=>n(()=>import(`./en-B4ZKOASM-Crn8bm25.js`),__vite__mapDeps([12,13,1,2,3]),import.meta.url),"./locales/es-ES.json":()=>n(()=>import(`./es-ES-U4NZUMDT-Cwbu6VfM.js`),__vite__mapDeps([14,1,2,3]),import.meta.url),"./locales/eu-ES.json":()=>n(()=>import(`./eu-ES-A7QVB2H4-BQQ8mY2m.js`),__vite__mapDeps([15,1,2,3]),import.meta.url),"./locales/fa-IR.json":()=>n(()=>import(`./fa-IR-HGAKTJCU-eYy7h0Hx.js`),__vite__mapDeps([16,1,2,3]),import.meta.url),"./locales/fi-FI.json":()=>n(()=>import(`./fi-FI-Z5N7JZ37-0dUJDB5b.js`),__vite__mapDeps([17,1,2,3]),import.meta.url),"./locales/fr-FR.json":()=>n(()=>import(`./fr-FR-RHASNOE6-CcYw1Zvt.js`),__vite__mapDeps([18,1,2,3]),import.meta.url),"./locales/gl-ES.json":()=>n(()=>import(`./gl-ES-HMX3MZ6V-C3Iv5ndX.js`),__vite__mapDeps([19,1,2,3]),import.meta.url),"./locales/he-IL.json":()=>n(()=>import(`./he-IL-6SHJWFNN-CL8Or2hC.js`),__vite__mapDeps([20,1,2,3]),import.meta.url),"./locales/hi-IN.json":()=>n(()=>import(`./hi-IN-IWLTKZ5I-DgAD87B-.js`),__vite__mapDeps([21,1,2,3]),import.meta.url),"./locales/hu-HU.json":()=>n(()=>import(`./hu-HU-A5ZG7DT2-B8ITrvUt.js`),__vite__mapDeps([22,1,2,3]),import.meta.url),"./locales/id-ID.json":()=>n(()=>import(`./id-ID-SAP4L64H-VQ2OqDi1.js`),__vite__mapDeps([23,1,2,3]),import.meta.url),"./locales/it-IT.json":()=>n(()=>import(`./it-IT-JPQ66NNP-D777F8zf.js`),__vite__mapDeps([24,1,2,3]),import.meta.url),"./locales/ja-JP.json":()=>n(()=>import(`./ja-JP-DBVTYXUO-D1PJdPJe.js`),__vite__mapDeps([25,1,2,3]),import.meta.url),"./locales/kaa.json":()=>n(()=>import(`./kaa-6HZHGXH3-fRgBr8Mi.js`),__vite__mapDeps([26,1,2,3]),import.meta.url),"./locales/kab-KAB.json":()=>n(()=>import(`./kab-KAB-ZGHBKWFO-DlQ49dRn.js`),__vite__mapDeps([27,1,2,3]),import.meta.url),"./locales/kk-KZ.json":()=>n(()=>import(`./kk-KZ-P5N5QNE5-Hq_H-Gj0.js`),__vite__mapDeps([28,1,2,3]),import.meta.url),"./locales/km-KH.json":()=>n(()=>import(`./km-KH-HSX4SM5Z-BhI31DxZ.js`),__vite__mapDeps([29,1,2,3]),import.meta.url),"./locales/ko-KR.json":()=>n(()=>import(`./ko-KR-MTYHY66A-ImUZQcvz.js`),__vite__mapDeps([30,1,2,3]),import.meta.url),"./locales/ku-TR.json":()=>n(()=>import(`./ku-TR-6OUDTVRD-DfaC8QXn.js`),__vite__mapDeps([31,1,2,3]),import.meta.url),"./locales/lt-LT.json":()=>n(()=>import(`./lt-LT-XHIRWOB4-I-ZCC3dU.js`),__vite__mapDeps([32,1,2,3]),import.meta.url),"./locales/lv-LV.json":()=>n(()=>import(`./lv-LV-5QDEKY6T-Qq5QdgfN.js`),__vite__mapDeps([33,1,2,3]),import.meta.url),"./locales/mr-IN.json":()=>n(()=>import(`./mr-IN-CRQNXWMA-BeP3PnlU.js`),__vite__mapDeps([34,1,2,3]),import.meta.url),"./locales/my-MM.json":()=>n(()=>import(`./my-MM-5M5IBNSE-BYx0eFn7.js`),__vite__mapDeps([35,1,2,3]),import.meta.url),"./locales/nb-NO.json":()=>n(()=>import(`./nb-NO-T6EIAALU-C9J5JzGe.js`),__vite__mapDeps([36,1,2,3]),import.meta.url),"./locales/nl-NL.json":()=>n(()=>import(`./nl-NL-IS3SIHDZ-CMVLrD7F.js`),__vite__mapDeps([37,1,2,3]),import.meta.url),"./locales/nn-NO.json":()=>n(()=>import(`./nn-NO-6E72VCQL-BBxsrvc2.js`),__vite__mapDeps([38,1,2,3]),import.meta.url),"./locales/oc-FR.json":()=>n(()=>import(`./oc-FR-POXYY2M6-CHEXPovt.js`),__vite__mapDeps([39,1,2,3]),import.meta.url),"./locales/pa-IN.json":()=>n(()=>import(`./pa-IN-N4M65BXN-Bnyu119-.js`),__vite__mapDeps([40,1,2,3]),import.meta.url),"./locales/percentages.json":()=>n(()=>import(`./percentages-BXMCSKIN-CBvdjJLu.js`),__vite__mapDeps([41,1,2,3,42]),import.meta.url),"./locales/pl-PL.json":()=>n(()=>import(`./pl-PL-T2D74RX3-Cw72z8vE.js`),__vite__mapDeps([43,1,2,3]),import.meta.url),"./locales/pt-BR.json":()=>n(()=>import(`./pt-BR-5N22H2LF-ok3TV3dt.js`),__vite__mapDeps([44,1,2,3]),import.meta.url),"./locales/pt-PT.json":()=>n(()=>import(`./pt-PT-UZXXM6DQ-BX423IXU.js`),__vite__mapDeps([45,1,2,3]),import.meta.url),"./locales/ro-RO.json":()=>n(()=>import(`./ro-RO-JPDTUUEW-Pv4aDgxu.js`),__vite__mapDeps([46,1,2,3]),import.meta.url),"./locales/ru-RU.json":()=>n(()=>import(`./ru-RU-B4JR7IUQ-BGRCDPgW.js`),__vite__mapDeps([47,1,2,3]),import.meta.url),"./locales/si-LK.json":()=>n(()=>import(`./si-LK-N5RQ5JYF-CSeZ8jFh.js`),__vite__mapDeps([48,1,2,3]),import.meta.url),"./locales/sk-SK.json":()=>n(()=>import(`./sk-SK-C5VTKIMK-BrMoO_Q1.js`),__vite__mapDeps([49,1,2,3]),import.meta.url),"./locales/sl-SI.json":()=>n(()=>import(`./sl-SI-NN7IZMDC-B_x--94y.js`),__vite__mapDeps([50,1,2,3]),import.meta.url),"./locales/sv-SE.json":()=>n(()=>import(`./sv-SE-XGPEYMSR-BB4gq_Zc.js`),__vite__mapDeps([51,1,2,3]),import.meta.url),"./locales/ta-IN.json":()=>n(()=>import(`./ta-IN-2NMHFXQM-9zxtttPw.js`),__vite__mapDeps([52,1,2,3]),import.meta.url),"./locales/th-TH.json":()=>n(()=>import(`./th-TH-HPSO5L25-Bu674ZxS.js`),__vite__mapDeps([53,1,2,3]),import.meta.url),"./locales/tr-TR.json":()=>n(()=>import(`./tr-TR-DEFEU3FU-BOU8hW6c.js`),__vite__mapDeps([54,1,2,3]),import.meta.url),"./locales/uk-UA.json":()=>n(()=>import(`./uk-UA-QMV73CPH-DExt1pCB.js`),__vite__mapDeps([55,1,2,3]),import.meta.url),"./locales/vi-VN.json":()=>n(()=>import(`./vi-VN-M7AON7JQ-ChzDxy_w.js`),__vite__mapDeps([56,1,2,3]),import.meta.url),"./locales/zh-CN.json":()=>n(()=>import(`./zh-CN-LNUGB5OW-AIyEr3br.js`),__vite__mapDeps([57,1,2,3]),import.meta.url),"./locales/zh-HK.json":()=>n(()=>import(`./zh-HK-E62DVLB3-CyQvIghB.js`),__vite__mapDeps([58,1,2,3]),import.meta.url),"./locales/zh-TW.json":()=>n(()=>import(`./zh-TW-RAJ6MFWO-C9bb32Ou.js`),__vite__mapDeps([59,1,2,3]),import.meta.url)}),Pv=85,Fv={code:`en`,label:`English`},Iv=[Fv,...[{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=>ru[e.code]>=Pv).sort((e,t)=>e.label>t.label?1:-1)],Lv=`__test__`;r.DEV&&Iv.unshift({code:Lv,label:`test language`},{code:`${Lv}.rtl`,label:`‪test language (rtl)‬`,rtl:!0});var Rv=Fv,zv={},Bv=async e=>{if(Rv=e,document.documentElement.dir=Rv.rtl?`rtl`:`ltr`,document.documentElement.lang=Rv.code,e.code.startsWith(Lv))zv={};else try{zv=await Nv(`./locales/${Rv.code}.json`)}catch(t){console.error(`Failed to load language ${e.code}:`,t.message),zv=nu}Mv.set(Uv,e.code)},Vv=()=>Rv,Hv=(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},J=(e,t,n)=>{if(Rv.code.startsWith(Lv))return`\u202A[[${t?`${e}(${JSON.stringify(t).slice(1,-1)})`:e}]]\u202C`;let i=e.split(`.`),a=Hv(zv,i)||Hv(nu,i)||n;if(a===void 0){let t=`Can't find translation for ${e}`;if(r.PROD)return console.warn(t),``;throw Error(t)}if(t)for(let e in t)a=a.replace(`{{${e}}}`,String(t[e]));return a},Uv=au(Fv.code),Wv=()=>({t:J,langCode:kv(Uv)}),Gv=({size:e=`1em`,circleWidth:t=8,synchronized:n=!1,className:r=``})=>{let i=-(K.useRef(Date.now()).current%1600);return(0,q.jsx)(`div`,{className:`Spinner ${r}`,children:(0,q.jsx)(`svg`,{viewBox:`0 0 100 100`,style:{width:e,height:e,"--spinner-delay":n?`${i}ms`:0},children:(0,q.jsx)(`circle`,{cx:`50`,cy:`50`,r:50-t/2,strokeWidth:t,fill:`none`,strokeMiterlimit:`10`})})})},Kv=({delay:e,theme:t})=>{let[n,r]=(0,K.useState)(!!e);return(0,K.useEffect)(()=>{if(!e)return;let t=setTimeout(()=>{r(!1)},e);return()=>clearTimeout(t)},[e]),n?null:(0,q.jsxs)(`div`,{className:L(`LoadingMessage`,{"LoadingMessage--dark":t===B.DARK}),children:[(0,q.jsx)(`div`,{children:(0,q.jsx)(Gv,{})}),(0,q.jsx)(`div`,{className:`LoadingMessage-text`,children:J(`labels.loadingScene`)})]})},qv=e=>{let[t,n]=(0,K.useState)(!0);return(0,K.useEffect)(()=>{let t=async()=>{await Bv(r),n(!1)},r=Iv.find(t=>t.code===e.langCode)||Fv;t()},[e.langCode]),t?(0,q.jsx)(Kv,{theme:e.theme}):e.children},Y=K.forwardRef(({size:e=`medium`,visible:t=!0,className:n=``,...r},i)=>{let{id:a}=Ok(),o=K.useRef(null);K.useImperativeHandle(i,()=>o.current);let s=`ToolIcon_size_${e}`,[c,l]=(0,K.useState)(!1),u=(0,K.useRef)(!0),d=async e=>{let t=`onClick`in r&&r.onClick?.(e);if(as(t))try{l(!0),await t}catch(e){if(e instanceof ai)console.warn(e);else throw e}finally{u.current&&l(!1)}};(0,K.useEffect)(()=>(u.current=!0,()=>{u.current=!1}),[]);let f=(0,K.useRef)(null);if(r.type===`button`||r.type===`icon`||r.type===`submit`){let e=r.type===`icon`?`button`:r.type;return(0,q.jsxs)(`button`,{className:L(`ToolIcon_type_button`,s,n,t&&!r.hidden?`ToolIcon_type_button--show`:`ToolIcon_type_button--hide`,{ToolIcon:!r.hidden,"ToolIcon--selected":r.selected,"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:e,onClick:d,ref:o,disabled:c||r.isLoading||!!r.disabled,children:[(r.icon||r.label)&&(0,q.jsxs)(`div`,{className:`ToolIcon__icon`,"aria-hidden":`true`,"aria-disabled":!!r.disabled,children:[r.icon||r.label,r.keyBindingLabel&&(0,q.jsx)(`span`,{className:`ToolIcon__keybinding`,children:r.keyBindingLabel}),r.isLoading&&(0,q.jsx)(Gv,{})]}),r.showAriaLabel&&(0,q.jsxs)(`div`,{className:`ToolIcon__label`,children:[r[`aria-label`],` `,c&&(0,q.jsx)(Gv,{})]}),r.children]})}return(0,q.jsxs)(`label`,{className:L(`ToolIcon`,n),title:r.title,onPointerDown:e=>{f.current=e.pointerType||null,r.onPointerDown?.({pointerType:e.pointerType||null})},onPointerUp:()=>{requestAnimationFrame(()=>{f.current=null})},children:[(0,q.jsx)(`input`,{className:`ToolIcon_type_radio ${s}`,type:`radio`,name:r.name,"aria-label":r[`aria-label`],"aria-keyshortcuts":r[`aria-keyshortcuts`],"data-testid":r[`data-testid`],id:`${a}-${r.id}`,onChange:()=>{r.onChange?.({pointerType:f.current})},checked:r.checked,ref:o}),(0,q.jsxs)(`div`,{className:`ToolIcon__icon`,children:[r.icon,r.keyBindingLabel&&(0,q.jsx)(`span`,{className:`ToolIcon__keybinding`,children:r.keyBindingLabel})]})]})});Y.displayName=`ToolButton`;var Jv=(e,t,n)=>{let r=new Set(W(e.filter(e=>A(e)),t).map(e=>e.id)),i={},a=n.scene.getNonDeletedElementsMap(),o=new Set;for(let t of r){let n=xl(e,t);for(let e of n)if(!o.has(e.id)){if(nc(e)){let t=ia(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=nc(e)?ia(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&&U(r)&&(V(r,{startBinding:e.id===r.startBinding?.elementId?null:r.startBinding,endBinding:e.id===r.endBinding?.elementId?null:r.endBinding}),V(r,{points:r.points}))}),z(e,{isDeleted:!0}))}return e.frameId&&r.has(e.frameId)?(s=!1,nc(e)||(i[e.id]=!0),z(e,{frameId:null})):nc(e)&&t.selectedElementIds[e.containerId]?z(e,{isDeleted:!0}):e}),l=t.editingGroupId;if(s&&t.editingGroupId){let e=Wc(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=Wc(c,r).filter(e=>!e.isDeleted);e.length>1&&(l=r,e.forEach(e=>{i[e.id]=!0}))}}}}return{elements:c,appState:{...t,...Fi({selectedElementIds:i,editingGroupId:l},c,t,null)}}},Yv=(e,t)=>{if(e.editingGroupId){let n=Wc(R(t),e.editingGroupId);if(n.length)return{...e,selectedElementIds:{[n[0].id]:!0}}}return e},Xv=O({name:`deleteSelectedElements`,label:`labels.delete`,icon:ge,trackEvent:{category:`element`,action:`delete`},perform:(e,t,n,r)=>{if(t.editingLinearElement){let{elementId:n,selectedPointsIndices:i,startBindingElement:a,endBindingElement:o}=t.editingLinearElement,s=r.scene.getNonDeletedElementsMap(),c=G.getElement(n,s);if(!c||i==null)return!1;if(c.points.length<2){let n=e.map(e=>e.id===c.id?z(e,{isDeleted:!0}):e);return{elements:n,appState:{...Yv(t,n),editingLinearElement:null},captureUpdate:j.IMMEDIATELY}}let l={startBindingElement:i?.includes(0)?null:a,endBindingElement:i?.includes(c.points.length-1)?null:o};return G.deletePoints(c,i),{elements:e,appState:{...t,editingLinearElement:{...t.editingLinearElement,...l,selectedPointsIndices:i?.[0]>0?[i[0]-1]:[0]}},captureUpdate:j.IMMEDIATELY}}let{elements:i,appState:a}=Jv(e,t,r);return Mr(i,i.filter(e=>e.isDeleted)),a=Yv(a,i),{elements:i,appState:{...a,activeTool:Sa(t,{type:`selection`}),multiElement:null,activeEmbeddable:null},captureUpdate:xc(R(e),t)?j.IMMEDIATELY:j.EVENTUALLY}},keyTest:(e,t,n)=>(e.key===E.BACKSPACE||e.key===E.DELETE)&&!e[E.CTRL_OR_CMD],PanelComponent:({elements:e,appState:t,updateData:n})=>(0,q.jsx)(Y,{type:`button`,icon:ge,title:J(`labels.delete`),"aria-label":J(`labels.delete`),onClick:()=>n(null),visible:xc(R(e),t)})}),Zv=(e,t)=>e.frameId===t||e.id===t,Qv=(e,t,n)=>{let r=[],i=[],a=null,o=-1,s=k(n||W(e,t,{includeBoundTextElement:!0,includeElementsInFrames:!0}));for(;++o<e.length;){let t=e[o];s.get(t.id)?(i.length&&(r=r.concat(i),i=[]),r.push(o),a=o+1):t.isDeleted&&a===o?(a=o+1,i.push(o)):i=[]}return r},$v=e=>{let t=0;return e.reduce((n,r,i)=>(i>0&&e[i-1]!==r-1&&(t=++t),(n[t]||(n[t]=[])).push(r),n),[])},ey=(e,t,n)=>{if(`containerId`in e&&e.containerId){let r=Ol.getScene(e).getElement(e.containerId);if(r)return n===`left`?Math.min(t.indexOf(r),t.indexOf(e)):Math.max(t.indexOf(r),t.indexOf(e))}else{let r=e.boundElements?.find(e=>e.type!==`arrow`)?.id;if(r){let i=Ol.getScene(e).getElement(r);if(i)return n===`left`?Math.min(t.indexOf(i),t.indexOf(e)):Math.max(t.indexOf(i),t.indexOf(e))}}},ty=(e,t)=>{let n=-1,r=-1;return e.forEach((e,i)=>{Zv(e,t)&&(n===-1&&(n=i),r=i)}),n===-1?[]:e.slice(n,r+1)},ny=(e,t,n,r,i)=>{let a=t[n],o=t=>t.isDeleted?!1:i?t.frameId===i:e.editingGroupId?t.groupIds.includes(e.editingGroupId):!0,s=r===`left`?Ft(t,e=>o(e),Math.max(0,n-1)):Lo(t,e=>o(e),n+1),c=t[s];if(!c)return-1;if(e.editingGroupId){if(a?.groupIds.join(``)===c?.groupIds.join(``))return ey(c,t,r)??s;if(!c?.groupIds.includes(e.editingGroupId))return-1}if(!i&&(c.frameId||A(c))){let e=ty(t,c.frameId||c.id);return r===`left`?t.indexOf(e[0]):t.indexOf(e[e.length-1])}if(!c.groupIds.length)return ey(c,t,r)??s;let l=Wc(t,e.editingGroupId?c.groupIds[c.groupIds.indexOf(e.editingGroupId)-1]:c.groupIds[c.groupIds.length-1]);return l.length?r===`left`?t.indexOf(l[0]):t.indexOf(l[l.length-1]):s},ry=(e,t)=>t.reduce((t,n)=>{let r=e[n];return t.set(r.id,r),t},new Map),iy=(e,t,n)=>{let r=Qv(e,t),i=ry(e,r),a=$v(r);n===`right`&&(a=a.reverse());let o=new Set(r.filter(t=>A(e[t])).map(t=>e[t].id));return a.forEach((r,i)=>{let a=r[0],s=r[r.length-1],c=n===`left`?a:s,l=r.some(t=>{let n=e[t];return n.frameId&&o.has(n.frameId)})?null:e[c]?.frameId,u=ny(t,e,c,n,l);if(u===-1||c===u)return;let d=n===`left`?e.slice(0,u):e.slice(0,a),f=e.slice(a,s+1),p=n===`left`?e.slice(u,a):e.slice(s+1,u+1),m=n===`left`?e.slice(s+1):e.slice(u+1);e=n===`left`?[...d,...f,...p,...m]:[...d,...p,...f,...m]}),Un(e,i),e},ay=(e,t,n,r,i)=>{let a=Qv(e,t,i),o=ry(e,a),s=[],c,l;if(n===`left`){if(r)c=Lo(e,e=>Zv(e,r));else if(t.editingGroupId){let n=Wc(e,t.editingGroupId);if(!n.length)return e;c=e.indexOf(n[0])}else c=0;l=a[a.length-1]}else{if(r)l=Ft(e,e=>Zv(e,r));else if(t.editingGroupId){let n=Wc(e,t.editingGroupId);if(!n.length)return e;l=e.indexOf(n[n.length-1])}else l=e.length-1;c=a[0]}c===-1&&(c=0);for(let t=c;t<l+1;t++)a.includes(t)||s.push(e[t]);let u=Array.from(o.values()),d=e.slice(0,c),f=e.slice(l+1),p=n===`left`?[...d,...u,...s,...f]:[...d,...s,...u,...f];return Un(p,o),p};function oy(e,t,n,r){let i=k(W(e,t,{includeBoundTextElement:!0,includeElementsInFrames:!0})),a={regularElements:[],frameChildren:new Map},o=new Set;for(let t of e)i.has(t.id)&&A(t)&&o.add(t.id);for(let t of e)if(i.has(t.id))if(A(t)||t.frameId&&o.has(t.frameId))a.regularElements.push(t);else if(!t.frameId)a.regularElements.push(t);else{let e=a.frameChildren.get(t.frameId)||[];e.push(t),a.frameChildren.set(t.frameId,e)}let s=e,c=Array.from(a.frameChildren.entries());for(let[i,a]of c)s=r(e,t,n,i,a);return r(s,t,n,null,a.regularElements)}var sy=(e,t)=>iy(e,t,`left`),cy=(e,t)=>iy(e,t,`right`),ly=(e,t)=>oy(e,t,`left`,ay),uy=(e,t)=>oy(e,t,`right`,ay),dy=O({name:`sendBackward`,label:`labels.sendBackward`,keywords:[`move down`,`zindex`,`layer`],icon:Ze,trackEvent:{category:`element`},perform:(e,t)=>({elements:sy(e,t),appState:t,captureUpdate:j.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[E.CTRL_OR_CMD]&&!e.shiftKey&&e.code===D.BRACKET_LEFT,PanelComponent:({updateData:e,appState:t})=>(0,q.jsx)(`button`,{type:`button`,className:`zIndexButton`,onClick:()=>e(null),title:`${J(`labels.sendBackward`)} \u2014 ${M(`CtrlOrCmd+[`)}`,children:Ze})}),fy=O({name:`bringForward`,label:`labels.bringForward`,keywords:[`move up`,`zindex`,`layer`],icon:jr,trackEvent:{category:`element`},perform:(e,t)=>({elements:cy(e,t),appState:t,captureUpdate:j.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[E.CTRL_OR_CMD]&&!e.shiftKey&&e.code===D.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:t})=>(0,q.jsx)(`button`,{type:`button`,className:`zIndexButton`,onClick:()=>e(null),title:`${J(`labels.bringForward`)} \u2014 ${M(`CtrlOrCmd+]`)}`,children:jr})}),py=O({name:`sendToBack`,label:`labels.sendToBack`,keywords:[`move down`,`zindex`,`layer`],icon:fo,trackEvent:{category:`element`},perform:(e,t)=>({elements:ly(e,t),appState:t,captureUpdate:j.IMMEDIATELY}),keyTest:e=>Ri?e[E.CTRL_OR_CMD]&&e.altKey&&e.code===D.BRACKET_LEFT:e[E.CTRL_OR_CMD]&&e.shiftKey&&e.code===D.BRACKET_LEFT,PanelComponent:({updateData:e,appState:t})=>(0,q.jsx)(`button`,{type:`button`,className:`zIndexButton`,onClick:()=>e(null),title:`${J(`labels.sendToBack`)} \u2014 ${M(Ri?`CtrlOrCmd+Alt+[`:`CtrlOrCmd+Shift+[`)}`,children:fo})}),my=O({name:`bringToFront`,label:`labels.bringToFront`,keywords:[`move up`,`zindex`,`layer`],icon:ye,trackEvent:{category:`element`},perform:(e,t)=>({elements:uy(e,t),appState:t,captureUpdate:j.IMMEDIATELY}),keyTest:e=>Ri?e[E.CTRL_OR_CMD]&&e.altKey&&e.code===D.BRACKET_RIGHT:e[E.CTRL_OR_CMD]&&e.shiftKey&&e.code===D.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:t})=>(0,q.jsx)(`button`,{type:`button`,className:`zIndexButton`,onClick:t=>e(null),title:`${J(`labels.bringToFront`)} \u2014 ${M(Ri?`CtrlOrCmd+Alt+]`:`CtrlOrCmd+Shift+]`)}`,children:ye})}),hy=O({name:`selectAll`,label:`labels.selectAll`,icon:Yr,trackEvent:{category:`canvas`},viewMode:!1,perform:(e,t,n,r)=>{if(t.editingLinearElement)return!1;let i=e.filter(e=>!e.isDeleted&&!(I(e)&&e.containerId)&&!e.locked).reduce((e,t)=>(e[t.id]=!0,e),{});return{appState:{...t,...Fi({editingGroupId:null,selectedElementIds:i},R(e),t,r),selectedLinearElement:Object.keys(i).length===1&&c(e[0])?new G(e[0]):null},captureUpdate:j.IMMEDIATELY}},keyTest:e=>e[E.CTRL_OR_CMD]&&e.key===E.A}),gy=e=>{let t=e.slice(),n=new Set,r=e=>{let t=e[0]?.groupIds?.join(``),n=[e[0]],i=[];for(let r of e.slice(1))r.groupIds?.join(``)===t?n.push(r):i.push(r);return i.length?[...n,...r(i)]:n},i=new Map;return t.forEach((e,a)=>{if(!i.has(e.id))if(e.groupIds?.length){let o=e.groupIds[e.groupIds.length-1],s=t.slice(a).filter(e=>{let t=e?.groupIds?.some(e=>e===o);return t&&i.set(e.id,!0),t});for(let e of r(s))n.add(e)}else n.add(e)}),n.size===e.length?[...n]:(console.error(`normalizeGroupElementOrder: lost some elements... bailing!`),e)},_y=e=>{let t=vo(e),n=e.slice(),r=new Set;return n.forEach((e,i)=>{e&&(e.boundElements?.length?(r.add(e),n[i]=null,e.boundElements.forEach(e=>{let i=t.get(e.id);i&&e.type===`text`&&(r.add(i[0]),n[i[1]]=null)})):e.type===`text`&&e.containerId&&t.get(e.containerId)?.[0].boundElements?.find(t=>t.id===e.id)||(r.add(e),n[i]=null))}),r.size===e.length?[...r]:(console.error(`normalizeBoundElementsOrder: lost some elements... bailing!`),e)},vy=e=>_y(gy(e)),yy=O({name:`duplicateSelection`,label:`labels.duplicateSelection`,icon:ki,trackEvent:{category:`element`},perform:(e,t,n,r)=>{if(t.editingLinearElement)try{return{elements:e,appState:G.duplicateSelectedPoints(t,r.scene.getNonDeletedElementsMap()),captureUpdate:j.IMMEDIATELY}}catch{return!1}let i=by(e,t);if(r.props.onDuplicate&&i.elements){let t=r.props.onDuplicate(i.elements,e);t&&(i.elements=t)}return{...i,captureUpdate:j.IMMEDIATELY}},keyTest:e=>e[E.CTRL_OR_CMD]&&e.key===E.D,PanelComponent:({elements:e,appState:t,updateData:n})=>(0,q.jsx)(Y,{type:`button`,icon:ki,title:`${J(`labels.duplicateSelection`)} \u2014 ${M(`CtrlOrCmd+D`)}`,"aria-label":J(`labels.duplicateSelection`),onClick:()=>n(null),visible:xc(R(e),t)})}),by=(e,t)=>{let n=new Map,r=[],i=[],a=new Map,o=new Map,s=k(e),c=e=>{let s=ea(e).reduce((e,s)=>{if(u.has(s.id))return e;u.set(s.id,!0);let c=mi(t.editingGroupId,n,s,{x:s.x+20/2,y:s.y+20/2});return u.set(c.id,!0),o.set(c.id,c),a.set(s.id,c.id),i.push(s),r.push(c),e.push(c),e},[]);return Array.isArray(e)?s:s[0]||null};e=vy(e);let l=k(W(e,t,{includeBoundTextElement:!0,includeElementsInFrames:!0})),u=new Map,d=e.slice(),f=(e,t)=>{lo(e!==-1,`targetIndex === -1 `),!(!Array.isArray(t)&&!t)&&d.splice(e+1,0,...ea(t))},m=new Set(e.filter(e=>l.has(e.id)&&A(e)).map(e=>e.id));for(let n of e){if(u.has(n.id)||!l.has(n.id))continue;let r=Ja(t,n);if(r){let t=Wc(e,r).flatMap(t=>A(t)?[...xl(e,t.id),t]:[t]);f(Ft(d,e=>e.groupIds?.includes(r)),c(t));continue}if(!(n.frameId&&m.has(n.frameId))){if(A(n)){let t=n.id,r=xl(e,t);f(Ft(d,e=>e.frameId===t||e.id===t),c([...r,n]));continue}if(ws(n)){let e=dr(n,s),t=Ft(d,e=>e.id===n.id||`containerId`in e&&e.containerId===n.id);e?f(t,c([n,e])):f(t,c(n));continue}if(nc(n)){let e=ia(n,s),t=Ft(d,t=>t.id===n.id||t.id===e?.id);e?f(t,c([e,n])):f(t,c(n));continue}f(Ft(d,e=>e.id===n.id),c(n))}}w(d,i,a),Ys(d,i,a),Hr(d,i,a);let h=p(r);return{elements:d,appState:{...t,...Fi({editingGroupId:t.editingGroupId,selectedElementIds:h.reduce((e,t)=>(nc(t)||(e[t.id]=!0),e),{})},R(d),t,null)}}},xy=new Set([`command_palette`,`export`]),X=(e,t,n,i)=>{try{if(typeof window>`u`||r.VITE_WORKER_ID||r.VITE_APP_ENABLE_TRACKING!==`true`||!xy.has(e)||r.DEV)return;r.PROD||console.info(`trackEvent`,{category:e,action:t,label:n,value:i}),window.sa_event&&window.sa_event(t,{category:e,label:n,value:i})}catch(e){console.error(`error during analytics`,e)}},Sy=(0,K.forwardRef)((e,t)=>{let{title:n,className:r,testId:i,active:a,standalone:o,icon:s,onClick:c}=e;return(0,q.jsx)(`button`,{type:`button`,ref:t,title:n,"data-testid":i,className:L(r,{standalone:o,active:a}),onClick:c,children:s},n)}),Cy=e=>(0,q.jsx)(`div`,{className:`buttonList`,children:e.options.map(t=>e.type===`button`?(0,q.jsx)(Sy,{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,q.jsxs)(`label`,{className:L({active:e.value===t.value}),title:t.text,children:[(0,q.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))}),wy=({onChange:e,type:t,activeColor:n,topPicks:r})=>{let i;return t===`elementStroke`&&(i=lc),t===`elementBackground`&&(i=xt),t===`canvasBackground`&&(i=fi),r&&(i=r),i?(0,q.jsx)(`div`,{className:`color-picker__top-picks`,children:i.map(t=>(0,q.jsx)(`button`,{className:L(`color-picker__button`,{active:t===n,"is-transparent":t===`transparent`||!t}),style:{"--swatch-color":t},type:`button`,title:t,onClick:()=>e(t),"data-testid":`color-top-pick-${t}`,children:(0,q.jsx)(`div`,{className:`color-picker__button-outline`})},t))}):(console.error(`Invalid type for TopPicks`),null)},Ty=()=>(0,q.jsx)(`div`,{style:{width:1,height:`1rem`,backgroundColor:`var(--default-border-color)`,margin:`0 auto`}}),Ey=({palette:e,color:t})=>{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},Dy=[[`q`,`w`,`e`,`r`,`t`],[`a`,`s`,`d`,`f`,`g`],[`z`,`x`,`c`,`v`,`b`]].flat(),Oy=({color:e,palette:t})=>!Object.values(t).flat().includes(e),ky=(e,t,n)=>{let r={elementBackground:`backgroundColor`,elementStroke:`strokeColor`},i=e.filter(e=>{if(e.isDeleted)return!1;let i=e[r[t]];return Oy({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)},Ay=au(null),jy=(e,t,n)=>(e*299+t*587+n*114)/1e3>=160?`black`:`white`,My=(e,t)=>{if(t){let t=new Option().style;if(t.color=e,t.color){let e=t.color.replace(/^(rgb|rgba)\(/,``).replace(/\)$/,``).replace(/\s/g,``).split(`,`);return jy(parseInt(e[0]),parseInt(e[1]),parseInt(e[2]))}}return e===`transparent`?`black`:jy(parseInt(e.substring(1,3),16),parseInt(e.substring(3,5),16),parseInt(e.substring(5,7),16))},Ny=({color:e,keyLabel:t,isCustomColor:n=!1,isShade:r=!1})=>(0,q.jsxs)(`div`,{className:`color-picker__button__hotkey-label`,style:{color:My(e,n)},children:[r&&`⇧`,t]}),Py=({hex:e,onChange:t,palette:n})=>{let r=Ey({color:e||`transparent`,palette:n}),[i,a]=Dv(Ay),o=(0,K.useRef)(null);if((0,K.useEffect)(()=>{o.current&&i===`shades`&&o.current.focus()},[r,i]),r){let{colorName:e,shade:s}=r,c=n[e];if(Array.isArray(c))return(0,q.jsx)(`div`,{className:`color-picker-content--default shades`,children:c.map((n,r)=>(0,q.jsxs)(`button`,{ref:r===s&&i===`shades`?o:void 0,tabIndex:-1,type:`button`,className:L(`color-picker__button color-picker__button--large`,{active:r===s}),"aria-label":`Shade`,title:`${e} - ${r+1}`,style:n?{"--swatch-color":n}:void 0,onClick:()=>{t(n),a(`shades`)},children:[(0,q.jsx)(`div`,{className:`color-picker__button-outline`}),(0,q.jsx)(Ny,{color:n,keyLabel:r+1,isShade:!0})]},r))})}return(0,q.jsxs)(`div`,{className:`color-picker-content--default`,style:{position:`relative`},tabIndex:-1,children:[(0,q.jsx)(`button`,{type:`button`,tabIndex:-1,className:`color-picker__button color-picker__button--large color-picker__button--no-focus-visible`}),(0,q.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:J(`colorPicker.noShades`)})]})},Fy=({palette:e,color:t,onChange:n,label:r,activeShade:i})=>{let a=Ey({color:t||`transparent`,palette:e}),[o,s]=Dv(Ay),c=(0,K.useRef)(null);return(0,K.useEffect)(()=>{c.current&&o===`baseColors`&&c.current.focus()},[a?.colorName,o]),(0,q.jsx)(`div`,{className:`color-picker-content--default`,children:Object.entries(e).map(([e,t],r)=>{let o=(Array.isArray(t)?t[i]:t)||`transparent`,l=Dy[r],u=J(`colors.${e.replace(/\d+/,``)}`,null,``);return(0,q.jsxs)(`button`,{ref:a?.colorName===e?c:void 0,tabIndex:-1,type:`button`,className:L(`color-picker__button color-picker__button--large`,{active:a?.colorName===e,"is-transparent":o===`transparent`||!o}),onClick:()=>{n(o),s(`baseColors`)},title:`${u}${o.startsWith(`#`)?` ${o}`:``} \u2014 ${l}`,"aria-label":`${u} \u2014 ${l}`,style:o?{"--swatch-color":o}:void 0,"data-testid":`color-${e}`,children:[(0,q.jsx)(`div`,{className:`color-picker__button-outline`}),(0,q.jsx)(Ny,{color:o,keyLabel:l})]},e)})})},Iy=({colors:e,color:t,onChange:n,label:r})=>{let[i,a]=Dv(Ay),o=(0,K.useRef)(null);return(0,K.useEffect)(()=>{o.current&&o.current.focus()},[t,i]),(0,q.jsx)(`div`,{className:`color-picker-content--default`,children:e.map((e,i)=>(0,q.jsxs)(`button`,{ref:t===e?o:void 0,tabIndex:-1,type:`button`,className:L(`color-picker__button color-picker__button--large`,{active:t===e,"is-transparent":e===`transparent`||!e}),onClick:()=>{n(e),a(`custom`)},title:e,"aria-label":r,style:{"--swatch-color":e},children:[(0,q.jsx)(`div`,{className:`color-picker__button-outline`}),(0,q.jsx)(Ny,{color:e,keyLabel:i+1,isCustomColor:!0})]},i))})},Ly=(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}}},Ry=({e,colorObj:t,onChange:n,palette:r,customColors:i,setActiveColorPickerSection:a,activeShade:o})=>{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(Dy.includes(e.key)){let t=Dy.indexOf(e.key),i=r[Object.keys(r)[t]];return n(Array.isArray(i)?i[o]:i),a(`baseColors`),!0}return!1},zy=({event:e,activeColorPickerSection:t,palette:n,color:r,onChange:i,customColors:a,setActiveColorPickerSection:o,updateData:s,activeShade:c,onEyeDropperToggle:l,onEscape:u})=>{if(e[E.CTRL_OR_CMD])return!1;if(e.key===E.ESCAPE)return u(e),!0;if(e.key===E.ALT)return l(!0),!0;if(e.key===E.I)return l(),!0;let d=Ey({color:r,palette:n});if(e.key===E.TAB){let s={custom:!!a.length,baseColors:!0,shades:d?.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,f=c[l+u>c.length-1?0:l+u<0?c.length-1:l+u];return f&&o(f),f===`custom`?i(a[0]):f===`baseColors`&&(Object.entries(n).find(([e,t])=>Array.isArray(t)?t.includes(r):t===r?e:null)||i(kr.black)),e.preventDefault(),e.stopPropagation(),!0}if(Ry({e,colorObj:d,onChange:i,palette:n,customColors:a,setActiveColorPickerSection:o,activeShade:c}))return!0;if(t===`shades`&&d){let{shade:t}=d,r=Ly(e.key,t,5);if(r!==void 0)return i(n[d.colorName][r]),!0}if(t===`baseColors`&&d){let{colorName:t}=d,r=Object.keys(n),a=r.indexOf(t),o=Ly(e.key,a,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=a.indexOf(r),n=Ly(e.key,t,a.length);if(n!==void 0){let e=a[n];return i(e),!0}}return!1},By=({children:e})=>(0,q.jsx)(`div`,{className:`color-picker__heading`,children:e}),Vy=({color:e,onChange:t,label:n,type:r,elements:i,palette:a,updateData:o,children:s,onEyeDropperToggle:c,onEscape:l})=>{let[u]=K.useState(()=>r===`canvasBackground`?[]:ky(i,r,a)),[d,f]=Dv(Ay),p=Ey({color:e,palette:a});(0,K.useEffect)(()=>{if(!d){let t=Oy({color:e,palette:a});f(t&&!u.includes(e)?`hex`:t?`custom`:p?.shade==null?`baseColors`:`shades`)}},[d,e,a,f,p,u]);let[m,h]=(0,K.useState)(p?.shade??(r===`elementBackground`?1:4));(0,K.useEffect)(()=>{p?.shade!=null&&h(p.shade);let e=e=>{e.key===E.ALT&&c(!1)};return document.addEventListener(`keyup`,e,{capture:!0}),()=>{document.removeEventListener(`keyup`,e,{capture:!0})}},[p,c]);let g=K.useRef(null);return(0,q.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":J(`labels.colorPicker`),children:(0,q.jsxs)(`div`,{ref:g,onKeyDown:n=>{zy({event:n,activeColorPickerSection:d,palette:a,color:e,onChange:t,onEyeDropperToggle:c,customColors:u,setActiveColorPickerSection:f,updateData:o,activeShade:m,onEscape:l})&&(n.preventDefault(),n.stopPropagation())},className:`color-picker-content properties-content`,tabIndex:-1,children:[!!u.length&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(By,{children:J(`colorPicker.mostUsedCustomColors`)}),(0,q.jsx)(Iy,{colors:u,color:e,label:J(`colorPicker.mostUsedCustomColors`),onChange:t})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(By,{children:J(`colorPicker.colors`)}),(0,q.jsx)(Fy,{color:e,label:n,palette:a,onChange:t,activeShade:m})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(By,{children:J(`colorPicker.shades`)}),(0,q.jsx)(Py,{hex:e,onChange:t,palette:a})]}),s]})})},Hy=K.createContext(null),Uy=()=>K.useContext(Hy),Wy=e=>{let[t,n]=(0,K.useState)(null),r=Dk(),{theme:i}=Uy(),{container:a}=Ok();return(0,K.useLayoutEffect)(()=>{t&&(t.className=``,t.classList.add(`excalidraw`,...e?.className?.split(/\s+/)||[]),t.classList.toggle(`excalidraw--mobile`,r.editor.isMobile),t.classList.toggle(`theme--dark`,i===B.DARK))},[t,i,r.editor.isMobile,e?.className]),(0,K.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 Gy(e,t,n){(0,K.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(`pointerdown`,r),document.addEventListener(`touchstart`,r),()=>{document.removeEventListener(`pointerdown`,r),document.removeEventListener(`touchstart`,r)}},[e,t,n])}var Ky=e=>{let t=(0,K.useRef)(e);return Object.assign(t.current,e),t.current},qy=au(null),Jy=({onCancel:e,onChange:t,onSelect:n,colorPickerType:r})=>{let i=Wy({className:`excalidraw-eye-dropper-backdrop`,parentSelector:`.excalidraw-eye-dropper-container`}),a=Uy(),o=kk(),s=Tk(),c=Ky({app:s,onCancel:e,onChange:t,onSelect:n,selectedElements:W(o,a)}),{container:l}=Ok();(0,K.useEffect)(()=>{let e=u.current;if(!e||!s.canvas||!i)return;let t=!1,n=s.canvas.getContext(`2d`),o=({clientX:e,clientY:t})=>{let r=n.getImageData((e-a.offsetLeft)*window.devicePixelRatio,(t-a.offsetTop)*window.devicePixelRatio,1,1).data;return S(r[0],r[1],r[2])},d=({clientX:n,clientY:i,altKey:a})=>{e.style.top=`${i+20}px`,e.style.left=`${n+20}px`;let s=o({clientX:n,clientY:i});t&&c.onChange(r,s,c.selectedElements,{altKey:a}),e.style.background=s},f=()=>{c.onCancel()},p=(e,t)=>{c.onSelect(e,t)},m=e=>{t=!0,e.stopImmediatePropagation()},h=e=>{t=!1,l?.focus(),e.stopImmediatePropagation(),e.preventDefault(),p(o(e),e)},g=e=>{e.key===E.ESCAPE&&(e.preventDefault(),e.stopImmediatePropagation(),f())};return i.tabIndex=-1,i.focus(),d({clientX:c.app.lastViewportPosition.x,clientY:c.app.lastViewportPosition.y,altKey:!1}),i.addEventListener(`keydown`,g),i.addEventListener(`pointerdown`,m),i.addEventListener(`pointerup`,h),window.addEventListener(`pointermove`,d,{passive:!0}),window.addEventListener(`blur`,f),()=>{t=!1,i.removeEventListener(`keydown`,g),i.removeEventListener(`pointerdown`,m),i.removeEventListener(`pointerup`,h),window.removeEventListener(`pointermove`,d),window.removeEventListener(`blur`,f)}},[c,s.canvas,i,r,l,a.offsetLeft,a.offsetTop]);let u=(0,K.useRef)(null);return Gy(u,()=>{e()},e=>!!e.target.closest(`.excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop`)),i?(0,Ju.createPortal)((0,q.jsx)(`div`,{ref:u,className:`excalidraw-eye-dropper-preview`}),i):null},Yy=({color:e,onChange:t,label:n,colorPickerType:r})=>{let i=Dk(),[a,o]=(0,K.useState)(e),[s,c]=Dv(Ay);(0,K.useEffect)(()=>{o(e)},[e]);let l=(0,K.useCallback)(e=>{let n=e.toLowerCase(),r=$y(n);r&&t(r),o(n)},[t]),u=(0,K.useRef)(null),d=(0,K.useRef)(null);(0,K.useEffect)(()=>{u.current&&u.current.focus()},[s]);let[f,p]=Dv(qy);return(0,K.useEffect)(()=>()=>{p(null)},[p]),(0,q.jsxs)(`div`,{className:`color-picker__input-label`,children:[(0,q.jsx)(`div`,{className:`color-picker__input-hash`,children:`#`}),(0,q.jsx)(`input`,{ref:s===`hex`?u:void 0,style:{border:0,padding:0},spellCheck:!1,className:`color-picker-input`,"aria-label":n,onChange:e=>{l(e.target.value)},value:(a||``).replace(/^#/,``),onBlur:()=>{o(e)},tabIndex:-1,onFocus:()=>c(`hex`),onKeyDown:e=>{e.key!==E.TAB&&(e.key===E.ESCAPE&&d.current?.focus(),e.stopPropagation())}}),!i.editor.isMobile&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{style:{width:`1px`,height:`1.25rem`,backgroundColor:`var(--default-border-color)`}}),(0,q.jsx)(`div`,{ref:d,className:L(`excalidraw-eye-dropper-trigger`,{selected:f}),onClick:()=>p(e=>e?null:{keepOpenOnAlt:!1,onSelect:e=>t(e),colorPickerType:r}),title:`${J(`labels.eyeDropper`)} \u2014 ${E.I.toLocaleUpperCase()} or ${M(`Alt`)} `,children:ji})]})]})},Xy=K.forwardRef(({children:e,padding:t,className:n,style:r},i)=>(0,q.jsx)(`div`,{className:L(`Island`,n),style:{"--padding":t,...r},ref:i,children:e})),Zy=K.forwardRef(({className:e,container:t,children:n,style:r,onClose:i,onKeyDown:a,onFocusOutside:o,onPointerLeave:s,onPointerDownOutside:c},l)=>{let u=Dk();return(0,q.jsx)(Mg,{container:t,children:(0,q.jsxs)(Ng,{ref:l,className:L(`focus-visible-none`,e),"data-prevent-outside-click":!0,side:u.editor.isMobile&&!u.viewport.isLandscape?`bottom`:`right`,align:u.editor.isMobile&&!u.viewport.isLandscape?`center`:`start`,alignOffset:-16,sideOffset:20,style:{zIndex:`var(--zIndex-popup)`},onPointerLeave:s,onKeyDown:a,onFocusOutside:o,onPointerDownOutside:c,onCloseAutoFocus:e=>{e.stopPropagation(),e.preventDefault(),t&&!ue(document.activeElement)&&t.focus(),i()},children:[(0,q.jsx)(Xy,{padding:3,style:r,children:n}),(0,q.jsx)(Pg,{width:20,height:10,style:{fill:`var(--popup-bg-color)`,filter:`drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)`}})]})})}),Qy=e=>{let t=new Option().style;return t.color=e,!!t.color},$y=e=>Rc(e)?e:Qy(`#${e}`)?`#${e}`:Qy(e)?e:null,eb=({type:e,color:t,onChange:n,label:r,elements:i,palette:a=kr,updateData:o})=>{let{container:s}=Ok(),[,c]=Dv(Ay),[l,u]=Dv(qy),d=(0,q.jsxs)(`div`,{children:[(0,q.jsx)(By,{children:J(`colorPicker.hexCode`)}),(0,q.jsx)(Yy,{color:t,label:r,onChange:e=>{n(e)},colorPickerType:e})]}),f=(0,K.useRef)(null),p=()=>{f.current?.querySelector(`.color-picker-content`)?.focus()};return(0,q.jsx)(Zy,{container:s,style:{maxWidth:`13rem`},onFocusOutside:e=>{p(),e.preventDefault()},onPointerDownOutside:e=>{l&&e.preventDefault()},onClose:()=>{o({openPopup:null}),c(null)},children:a?(0,q.jsx)(Vy,{palette:a,color:t,onChange:e=>{n(e)},onEyeDropperToggle:t=>{u(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=>{l?u(null):o({openPopup:null})},label:r,type:e,elements:i,updateData:o,children:d}):d})},tb=({label:e,color:t,type:n})=>(0,q.jsx)(jg,{type:`button`,className:L(`color-picker__button active-color properties-trigger`,{"is-transparent":t===`transparent`||!t}),"aria-label":e,style:t?{"--swatch-color":t}:void 0,title:J(n===`elementStroke`?`labels.showStroke`:`labels.showBackground`),children:(0,q.jsx)(`div`,{className:`color-picker__button-outline`})}),nb=({type:e,color:t,onChange:n,label:r,elements:i,palette:a=kr,topPicks:o,updateData:s,appState:c})=>(0,q.jsx)(`div`,{children:(0,q.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,className:`color-picker-container`,children:[(0,q.jsx)(wy,{activeColor:t,onChange:n,type:e,topPicks:o}),(0,q.jsx)(Ty,{}),(0,q.jsxs)(Ag,{open:c.openPopup===e,onOpenChange:t=>{s({openPopup:t?e:null})},children:[(0,q.jsx)(tb,{color:t,label:r,type:e}),c.openPopup===e&&(0,q.jsx)(eb,{type:e,color:t,onChange:n,label:r,elements:i,palette:a,updateData:s})]})]})}),rb=({icon:e})=>(0,q.jsx)(`span`,{style:{width:`1em`,margin:`0 0.5ex 0 0.5ex`,display:`inline-block`,lineHeight:0,verticalAlign:`middle`},children:e}),ib=({label:e,open:t,openTrigger:n,children:r,className:i})=>(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{style:{cursor:`pointer`,display:`flex`,justifyContent:`space-between`,alignItems:`center`},className:i,onClick:n,children:[e,(0,q.jsx)(rb,{icon:t?ei:Oe})]}),t&&(0,q.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`},children:r})]}),ab=au(!1);function ob({options:e,value:t,label:n,onChange:r,onClose:i,numberOfOptionsToAlwaysShow:a=e.length}){let o=Dk(),s=n=>{let o=e.find(e=>e.keyBinding===n.key.toLowerCase());if(!(n.metaKey||n.altKey||n.ctrlKey)&&o)r(o.value),n.preventDefault();else if(n.key===E.TAB){let i=e.findIndex(e=>e.value===t);r(e[n.shiftKey?(e.length+i-1)%e.length:(i+1)%e.length].value)}else if(ne(n.key)){let i=Vv().rtl,o=e.findIndex(e=>e.value===t);if(o!==-1){let t=e.length,s=o;switch(n.key){case i?E.ARROW_LEFT:E.ARROW_RIGHT:s=(o+1)%t;break;case i?E.ARROW_RIGHT:E.ARROW_LEFT:s=(t+o-1)%t;break;case E.ARROW_DOWN:s=(o+(a??1))%t;break;case E.ARROW_UP:s=(t+o-(a??1))%t;break}r(e[s].value)}n.preventDefault()}else (n.key===E.ESCAPE||n.key===E.ENTER)&&(n.preventDefault(),i());n.nativeEvent.stopImmediatePropagation(),n.stopPropagation()},[c,l]=Dv(ab),u=K.useMemo(()=>e.slice(0,a),[e,a]),d=K.useMemo(()=>e.slice(a),[e,a]);(0,K.useEffect)(()=>{u.some(e=>e.value===t)||l(!0)},[t,u,l]);let f=e=>(0,q.jsx)(`div`,{className:`picker-content`,children:e.map((e,n)=>(0,q.jsxs)(`button`,{type:`button`,className:L(`picker-option`,{active:t===e.value}),onClick:t=>{r(e.value)},title:`${e.text} ${e.keyBinding&&`\u2014 ${e.keyBinding.toUpperCase()}`}`,"aria-label":e.text||`none`,"aria-keyshortcuts":e.keyBinding||void 0,ref:n=>{t===e.value&&setTimeout(()=>{n?.focus()},0)},children:[e.icon,e.keyBinding&&(0,q.jsx)(`span`,{className:`picker-keybinding`,children:e.keyBinding})]},e.text))});return(0,q.jsx)(Ng,{side:o.editor.isMobile&&!o.viewport.isLandscape?`top`:`bottom`,align:`start`,sideOffset:12,style:{zIndex:`var(--zIndex-popup)`},onKeyDown:s,children:(0,q.jsxs)(`div`,{className:`picker`,role:`dialog`,"aria-modal":`true`,"aria-label":n,children:[f(u),d.length>0&&(0,q.jsx)(ib,{label:J(`labels.more_options`),open:c,openTrigger:()=>{l(e=>!e)},className:`picker-collapsible`,children:f(d)})]})})}function sb({value:e,label:t,options:n,onChange:r,group:i=``,numberOfOptionsToAlwaysShow:a}){let[o,s]=K.useState(!1),c=K.useRef(null);return(0,q.jsx)(`div`,{children:(0,q.jsxs)(Ag,{open:o,onOpenChange:e=>s(e),children:[(0,q.jsx)(jg,{name:i,type:`button`,"aria-label":t,onClick:()=>s(!o),ref:c,className:o?`active`:``,children:n.find(t=>t.value===e)?.icon}),o&&(0,q.jsx)(ob,{options:n,value:e,label:t,onChange:r,onClose:()=>{s(!1)},numberOfOptionsToAlwaysShow:a})]})})}var cb=K.forwardRef(({className:e,placeholder:t,onChange:n},r)=>(0,q.jsxs)(`div`,{className:L(`QuickSearch__wrapper`,e),children:[ja,(0,q.jsx)(`input`,{ref:r,className:`QuickSearch__input`,type:`text`,placeholder:t,onChange:e=>n(e.target.value.trim().toLowerCase())})]})),lb=({className:e,placeholder:t,children:n})=>{let r=!K.Children.count(n);return(0,q.jsx)(`div`,{className:L(`ScrollableList__wrapper`,e),role:`menu`,children:r?(0,q.jsx)(`div`,{className:`empty`,children:t}):n})},ub=({children:e,className:t=``,style:n,title:r})=>(0,q.jsxs)(`div`,{className:`dropdown-menu-group ${t}`,style:n,children:[r&&(0,q.jsx)(`p`,{className:`dropdown-menu-group-title`,children:r}),e]}),db=ub;ub.displayName=`DropdownMenuGroup`;var fb=K.createContext({}),pb=(e=``,t=!1,n=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e}
43
+ ${t?`dropdown-menu-item--selected`:``} ${n?`dropdown-menu-item--hovered`:``}`.trim(),mb=(e,t)=>{let n=(0,K.useContext)(fb);return Rl(e,e=>{let r=new CustomEvent(`menu.itemSelect`,{bubbles:!0,cancelable:!0});t?.(r),r.defaultPrevented||n.onSelect?.(r)})},hb=({textStyle:e,icon:t,shortcut:n,children:r})=>{let i=Dk();return(0,q.jsxs)(q.Fragment,{children:[t&&(0,q.jsx)(`div`,{className:`dropdown-menu-item__icon`,children:t}),(0,q.jsx)(`div`,{style:e,className:`dropdown-menu-item__text`,children:r}),n&&!i.editor.isMobile&&(0,q.jsx)(`div`,{className:`dropdown-menu-item__shortcut`,children:n})]})},gb=({icon:e,value:t,order:n,children:r,shortcut:i,className:a,hovered:o,selected:s,textStyle:c,onSelect:l,onClick:u,...d})=>{let f=mb(u,l),p=(0,K.useRef)(null);return(0,K.useEffect)(()=>{o&&(n===0?p.current?.scrollIntoView({block:`end`}):p.current?.scrollIntoView({block:`nearest`}))},[o,n]),(0,q.jsx)(`button`,{...d,ref:p,value:t,onClick:f,className:pb(a,s,o),title:d.title??d[`aria-label`],children:(0,q.jsx)(hb,{textStyle:c,icon:e,shortcut:i,children:r})})};gb.displayName=`DropdownMenuItem`;var _b={GREEN:`green`,RED:`red`,BLUE:`blue`},vb=({type:e=_b.BLUE,children:t})=>{let{theme:n}=Ak(),r={display:`inline-flex`,marginLeft:`auto`,padding:`2px 4px`,borderRadius:6,fontSize:9,fontFamily:`Cascadia, monospace`,border:n===B.LIGHT?`1.5px solid white`:`none`};switch(e){case _b.GREEN:Object.assign(r,{backgroundColor:`var(--background-color-badge)`,color:`var(--color-badge)`});break;case _b.RED:Object.assign(r,{backgroundColor:`pink`,color:`darkred`});break;case _b.BLUE:default:Object.assign(r,{background:`var(--color-promo)`,color:`var(--color-surface-lowest)`})}return(0,q.jsx)(`div`,{className:`DropDownMenuItemBadge`,style:r,children:t})};vb.displayName=`DropdownMenuItemBadge`,gb.Badge=vb;var yb=gb,bb=({event:e,inputRef:t,hoveredFont:n,filteredFonts:r,onClose:i,onSelect:a,onHover:o})=>{if(!e[E.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===E.F)return t.current?.focus(),!0;if(e.key===E.ESCAPE)return i(),!0;if(e.key===E.ENTER)return n?.value&&a(n.value),!0;if(e.key===E.ARROW_DOWN)return n?.next?o(n.next.value):r[0]?.value&&o(r[0].value),!0;if(e.key===E.ARROW_UP)return n?.prev?o(n.prev.value):r[r.length-1]?.value&&o(r[r.length-1].value),!0},xb=K.memo(({selectedFontFamily:e,hoveredFontFamily:t,onSelect:n,onHover:r,onLeave:i,onOpen:a,onClose:o})=>{let{container:s}=Ok(),{fonts:c}=Tk(),{showDeprecatedFonts:l}=Ek(),[u,d]=(0,K.useState)(``),f=(0,K.useRef)(null),p=(0,K.useMemo)(()=>Array.from(Eo.registered.entries()).filter(([e,{metadata:t}])=>!t.serverSide&&!t.fallback).map(([e,{metadata:t,fontFaces:n}])=>{let r={value:e,icon:t.icon??bs,text:n[0]?.fontFace?.family??`Unknown`};return t.deprecated&&Object.assign(r,{deprecated:t.deprecated,badge:{type:_b.RED,placeholder:J(`fontList.badge.old`)}}),r}).sort((e,t)=>e.text.toLowerCase()>t.text.toLowerCase()?1:-1),[]),m=(0,K.useMemo)(()=>new Set(c.getSceneFamilies()),[e]),h=(0,K.useMemo)(()=>p.filter(e=>m.has(e.value)),[p,m]),g=(0,K.useMemo)(()=>p.filter(e=>!m.has(e.value)&&(l||!e.deprecated)),[p,m,l]),_=(0,K.useMemo)(()=>Ce([...h,...g].filter(e=>e.text?.toLowerCase().includes(u))),[h,g,u]),v=(0,K.useMemo)(()=>{let n;return t?n=_.find(e=>e.value===t):e&&(n=_.find(t=>t.value===e)),!n&&u&&(_[0]?.value?r(_[0].value):i()),n},[t,e,u,_,r,i]),y=(0,K.useCallback)(e=>{bb({event:e,inputRef:f,hoveredFont:v,filteredFonts:_,onSelect:n,onHover:r,onClose:o})&&(e.preventDefault(),e.stopPropagation())},[v,_,n,r,o]);(0,K.useEffect)(()=>(a(),()=>{o()}),[]);let b=(0,K.useMemo)(()=>_.filter(e=>m.has(e.value)),[_,m]),x=(0,K.useMemo)(()=>_.filter(e=>!m.has(e.value)),[_,m]),S=(t,i)=>(0,q.jsxs)(yb,{icon:t.icon,value:t.value,order:i,textStyle:{fontFamily:di({fontFamily:t.value})},hovered:t.value===v?.value,selected:t.value===e,tabIndex:t.value===e?0:-1,onClick:e=>{n(Number(e.currentTarget.value))},onMouseMove:()=>{v?.value!==t.value&&r(t.value)},children:[t.text,t.badge&&(0,q.jsx)(vb,{type:t.badge.type,children:t.badge.placeholder})]},t.value),C=[];return b.length&&C.push((0,q.jsx)(db,{title:J(`fontList.sceneFonts`),children:b.map(S)},`group_1`)),x.length&&C.push((0,q.jsx)(db,{title:J(`fontList.availableFonts`),children:x.map((e,t)=>S(e,t+b.length))},`group_2`)),(0,q.jsxs)(Zy,{className:`properties-content`,container:s,style:{width:`15rem`},onClose:o,onPointerLeave:i,onKeyDown:y,children:[(0,q.jsx)(cb,{ref:f,placeholder:J(`quickSearch.placeholder`),onChange:Ec(d,20)}),(0,q.jsx)(lb,{className:`dropdown-menu fonts manual-hover`,placeholder:J(`fontList.empty`),children:C.length?C:null})]})},(e,t)=>e.selectedFontFamily===t.selectedFontFamily&&e.hoveredFontFamily===t.hoveredFontFamily),Sb=({selectedFontFamily:e})=>{let t=(0,K.useMemo)(()=>!!(e&&!Tb(e)),[e]);return(0,q.jsx)(jg,{asChild:!0,children:(0,q.jsx)(`div`,{children:(0,q.jsx)(Sy,{standalone:!0,icon:xo,title:J(`labels.showFonts`),className:`properties-trigger`,testId:`font-family-show-fonts`,active:t,onClick:()=>{}})})})},Cb=[{value:Po.Excalifont,icon:Zi,text:J(`labels.handDrawn`),testId:`font-family-hand-drawn`},{value:Po.Nunito,icon:bs,text:J(`labels.normal`),testId:`font-family-normal`},{value:Po[`Comic Shanns`],icon:$o,text:J(`labels.code`),testId:`font-family-code`}],wb=new Set(Cb.map(e=>e.value)),Tb=e=>e?wb.has(e):!1,Eb=K.memo(({isOpened:e,selectedFontFamily:t,hoveredFontFamily:n,onSelect:r,onHover:i,onLeave:a,onPopupChange:o})=>{let s=(0,K.useMemo)(()=>Cb,[]),c=(0,K.useCallback)(e=>{e&&r(e)},[r]);return(0,q.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,className:`FontPicker__container`,children:[(0,q.jsx)(Cy,{type:`button`,options:s,value:t,onClick:c}),(0,q.jsx)(Ty,{}),(0,q.jsxs)(Ag,{open:e,onOpenChange:o,children:[(0,q.jsx)(Sb,{selectedFontFamily:t}),e&&(0,q.jsx)(xb,{selectedFontFamily:t,hoveredFontFamily:n,onSelect:c,onHover:i,onLeave:a,onOpen:()=>o(!0),onClose:()=>o(!1)})]})]})},(e,t)=>e.isOpened===t.isOpened&&e.selectedFontFamily===t.selectedFontFamily&&e.hoveredFontFamily===t.hoveredFontFamily),Db=({updateData:e,appState:t,elements:n,testId:r})=>{let i=K.useRef(null),a=K.useRef(null),o=Ab(n,t,e=>e.opacity,!0,t.currentItemOpacity);return(0,K.useEffect)(()=>{if(i.current&&a.current){let e=i.current,t=a.current,n=e.offsetWidth,r=o/100*(n-15)+15/2;t.style.left=`${r}px`,e.style.background=`linear-gradient(to right, var(--color-slider-track) 0%, var(--color-slider-track) ${o}%, var(--button-bg) ${o}%, var(--button-bg) 100%)`}},[o]),(0,q.jsxs)(`label`,{className:`control-label`,children:[J(`labels.opacity`),(0,q.jsxs)(`div`,{className:`range-wrapper`,children:[(0,q.jsx)(`input`,{ref:i,type:`range`,min:`0`,max:`100`,step:`10`,onChange:t=>{e(+t.target.value)},value:o,className:`range-input`,"data-testid":r}),(0,q.jsx)(`div`,{className:`value-bubble`,ref:a,children:o===0?null:o}),(0,q.jsx)(`div`,{className:`zero-label`,children:`0`})]})]})},Ob=.1,kb=(e,t,n,r=!1)=>{let i=k(W(e,t,{includeBoundTextElement:r}));return e.map(e=>i.get(e.id)||e.id===t.editingTextElement?.id?n(e):e)},Ab=function(e,t,n,r,i){let a=t.editingTextElement,o=R(e),s=null;return a&&(s=n(a)),s||=xc(o,t)?ko(r===!0?o:o.filter(e=>r(e)),t,n)??(typeof i==`function`?i(!0):i):typeof i==`function`?i(!1):i,s},jb=(e,t)=>nc(t)||!t.autoResize?t:V(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},!1),Mb=(e,t,n,r,i)=>{let a=new Set,o=kb(e,t,e=>{if(I(e)){let t=r(e);a.add(t);let i=z(e,{fontSize:t});return cs(i,n.scene.getContainerElement(e),n.scene.getNonDeletedElementsMap()),i=jb(e,i),i}return e},!0),s=k(o);return W(e,t,{includeBoundTextElement:!0}).forEach(e=>{I(e)&&ga(e,s)}),{elements:o,appState:{...t,currentItemFontSize:a.size===1?[...a][0]:i??t.currentItemFontSize},captureUpdate:j.IMMEDIATELY}};O({name:`changeStrokeColor`,label:`labels.stroke`,trackEvent:!1,perform:(e,t,n)=>({...n.currentItemStrokeColor&&{elements:kb(e,t,e=>el(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,appProps:r})=>(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`h3`,{"aria-hidden":`true`,children:J(`labels.stroke`)}),(0,q.jsx)(nb,{topPicks:lc,palette:Zt,type:`elementStroke`,label:J(`labels.stroke`),color:Ab(e,t,e=>e.strokeColor,!0,t.currentItemStrokeColor),onChange:e=>n({currentItemStrokeColor:e}),elements:e,appState:t,updateData:n})]})}),O({name:`changeBackgroundColor`,label:`labels.changeBackground`,trackEvent:!1,perform:(e,t,n)=>({...n.currentItemBackgroundColor&&{elements:kb(e,t,e=>z(e,{backgroundColor:n.currentItemBackgroundColor}))},appState:{...t,...n},captureUpdate:n.currentItemBackgroundColor?j.IMMEDIATELY:j.EVENTUALLY}),PanelComponent:({elements:e,appState:t,updateData:n,appProps:r})=>(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`h3`,{"aria-hidden":`true`,children:J(`labels.background`)}),(0,q.jsx)(nb,{topPicks:xt,palette:Wr,type:`elementBackground`,label:J(`labels.background`),color:Ab(e,t,e=>e.backgroundColor,!0,t.currentItemBackgroundColor),onChange:e=>n({currentItemBackgroundColor:e}),elements:e,appState:t,updateData:n})]})}),O({name:`changeFillStyle`,label:`labels.fill`,trackEvent:!1,perform:(e,t,n,r)=>(X(`element`,`changeFillStyle`,`${n} (${r.device.editor.isMobile?`mobile`:`desktop`})`),{elements:kb(e,t,e=>z(e,{fillStyle:n})),appState:{...t,currentItemFillStyle:n},captureUpdate:j.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n})=>{let r=W(e,t),i=r.length>0&&r.every(e=>e.fillStyle===`zigzag`);return(0,q.jsxs)(`fieldset`,{children:[(0,q.jsx)(`legend`,{children:J(`labels.fill`)}),(0,q.jsx)(Cy,{type:`button`,options:[{value:`hachure`,text:`${J(i?`labels.zigzag`:`labels.hachure`)} (${M(`Alt-Click`)})`,icon:i?qc:kc,active:i?!0:void 0,testId:`fill-hachure`},{value:`cross-hatch`,text:J(`labels.crossHatch`),icon:Ic,testId:`fill-cross-hatch`},{value:`solid`,text:J(`labels.solid`),icon:zs,testId:`fill-solid`}],value:Ab(e,t,e=>e.fillStyle,e=>e.hasOwnProperty(`fillStyle`),e=>e?null:t.currentItemFillStyle),onClick:(e,t)=>{n(t.altKey&&e===`hachure`&&r.every(e=>e.fillStyle===`hachure`)?`zigzag`:e)}})]})}}),O({name:`changeStrokeWidth`,label:`labels.strokeWidth`,trackEvent:!1,perform:(e,t,n)=>({elements:kb(e,t,e=>z(e,{strokeWidth:n})),appState:{...t,currentItemStrokeWidth:n},captureUpdate:j.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n})=>(0,q.jsxs)(`fieldset`,{children:[(0,q.jsx)(`legend`,{children:J(`labels.strokeWidth`)}),(0,q.jsx)(Cy,{group:`stroke-width`,options:[{value:bl.thin,text:J(`labels.thin`),icon:sn,testId:`strokeWidth-thin`},{value:bl.bold,text:J(`labels.bold`),icon:Ts,testId:`strokeWidth-bold`},{value:bl.extraBold,text:J(`labels.extraBold`),icon:Ne,testId:`strokeWidth-extraBold`}],value:Ab(e,t,e=>e.strokeWidth,e=>e.hasOwnProperty(`strokeWidth`),e=>e?null:t.currentItemStrokeWidth),onChange:e=>n(e)})]})}),O({name:`changeSloppiness`,label:`labels.sloppiness`,trackEvent:!1,perform:(e,t,n)=>({elements:kb(e,t,e=>z(e,{seed:Vr(),roughness:n})),appState:{...t,currentItemRoughness:n},captureUpdate:j.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n})=>(0,q.jsxs)(`fieldset`,{children:[(0,q.jsx)(`legend`,{children:J(`labels.sloppiness`)}),(0,q.jsx)(Cy,{group:`sloppiness`,options:[{value:0,text:J(`labels.architect`),icon:il},{value:1,text:J(`labels.artist`),icon:C},{value:2,text:J(`labels.cartoonist`),icon:Qt}],value:Ab(e,t,e=>e.roughness,e=>e.hasOwnProperty(`roughness`),e=>e?null:t.currentItemRoughness),onChange:e=>n(e)})]})}),O({name:`changeStrokeStyle`,label:`labels.strokeStyle`,trackEvent:!1,perform:(e,t,n)=>({elements:kb(e,t,e=>z(e,{strokeStyle:n})),appState:{...t,currentItemStrokeStyle:n},captureUpdate:j.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n})=>(0,q.jsxs)(`fieldset`,{children:[(0,q.jsx)(`legend`,{children:J(`labels.strokeStyle`)}),(0,q.jsx)(Cy,{group:`strokeStyle`,options:[{value:`solid`,text:J(`labels.strokeStyle_solid`),icon:sn},{value:`dashed`,text:J(`labels.strokeStyle_dashed`),icon:pt},{value:`dotted`,text:J(`labels.strokeStyle_dotted`),icon:Rn}],value:Ab(e,t,e=>e.strokeStyle,e=>e.hasOwnProperty(`strokeStyle`),e=>e?null:t.currentItemStrokeStyle),onChange:e=>n(e)})]})}),O({name:`changeOpacity`,label:`labels.opacity`,trackEvent:!1,perform:(e,t,n)=>({elements:kb(e,t,e=>z(e,{opacity:n}),!0),appState:{...t,currentItemOpacity:n},captureUpdate:j.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n})=>(0,q.jsx)(Db,{updateData:n,elements:e,appState:t,testId:`opacity`})}),O({name:`changeFontSize`,label:`labels.fontSize`,trackEvent:!1,perform:(e,t,n,r)=>Mb(e,t,r,()=>n,n),PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,q.jsxs)(`fieldset`,{children:[(0,q.jsx)(`legend`,{children:J(`labels.fontSize`)}),(0,q.jsx)(Cy,{group:`font-size`,options:[{value:16,text:J(`labels.small`),icon:Fn,testId:`fontSize-small`},{value:20,text:J(`labels.medium`),icon:Nn,testId:`fontSize-medium`},{value:28,text:J(`labels.large`),icon:Fa,testId:`fontSize-large`},{value:36,text:J(`labels.veryLarge`),icon:nn,testId:`fontSize-veryLarge`}],value:Ab(e,t,e=>{if(I(e))return e.fontSize;let t=dr(e,r.scene.getNonDeletedElementsMap());return t?t.fontSize:null},e=>I(e)||dr(e,r.scene.getNonDeletedElementsMap())!==null,e=>e?null:t.currentItemFontSize||20),onChange:e=>n(e)})]})});var Nb=O({name:`decreaseFontSize`,label:`labels.decreaseFontSize`,icon:On,trackEvent:!1,perform:(e,t,n,r)=>Mb(e,t,r,e=>Math.round(1/(1+Ob)*e.fontSize)),keyTest:e=>e[E.CTRL_OR_CMD]&&e.shiftKey&&(e.key===E.CHEVRON_LEFT||e.key===E.COMMA)}),Pb=O({name:`increaseFontSize`,label:`labels.increaseFontSize`,icon:On,trackEvent:!1,perform:(e,t,n,r)=>Mb(e,t,r,e=>Math.round(e.fontSize*(1+Ob))),keyTest:e=>e[E.CTRL_OR_CMD]&&e.shiftKey&&(e.key===E.CHEVRON_RIGHT||e.key===E.PERIOD)});O({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:kb(e,t,e=>{let t=i?.get(e.id);return t?z(e,{...t}):e},!0),appState:{...t,...s},captureUpdate:j.NEVER};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=W(e,t,{includeBoundTextElement:!0}).filter(e=>I(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(Eo.loadedFontsCache.values()),f=Object.entries(Po).find(([e,t])=>t===d)?.[0];l&&f&&u.some(e=>e.startsWith(f))&&(s=!0),Object.assign(p,{elements:kb(e,t,e=>{if(I(e)&&(e.fontFamily!==d||c)){let t=z(e,{fontFamily:d,lineHeight:vc(d)}),c=i?.get(e.containerId||``)||{},l=r.scene.getContainerElement(e);return o&&l&&c&&V(l,{...c},!1),s||(a=new Set([...a,...Array.from(t.originalText)])),n.set(t,l),t}return e},!0)});let m=`10px ${di({fontFamily:d})}`,h=Array.from(a.values()).join();if(s||window.document.fonts.check(m,h))for(let[e,t]of n)cs(e,t,r.scene.getNonDeletedElementsMap(),!1);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&&cs(n,i,r.scene.getNonDeletedElementsMap(),!1)}r.fonts.onLoaded(e)})}return p},PanelComponent:({elements:e,appState:t,app:n,updateData:r})=>{let i=(0,K.useRef)(new Map),a=(0,K.useRef)(null),[o,s]=(0,K.useState)({}),c=(0,K.useRef)(!0),l=(0,K.useMemo)(()=>{let r=(e,n)=>Ab(e,t,e=>{if(I(e))return e.fontFamily;let t=dr(e,n);return t?t.fontFamily:null},e=>I(e)||dr(e,n)!==null,e=>e?null:t.currentItemFontFamily||te);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.scene]);return(0,K.useEffect)(()=>{a.current=l},[l]),(0,K.useEffect)(()=>{Object.keys(o).length&&(r(o),s({}))},[o]),(0,K.useEffect)(()=>(c.current=!1,()=>{c.current=!0}),[]),(0,q.jsxs)(`fieldset`,{children:[(0,q.jsx)(`legend`,{children:J(`labels.fontFamily`)}),(0,q.jsx)(Eb,{isOpened:t.openPopup===`fontFamily`,selectedFontFamily:l,hoveredFontFamily:t.currentHoveredFontFamily,onSelect:e=>{s({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:e}),i.current.clear()},onHover:e=>{s({currentHoveredFontFamily:e,cachedElements:new Map(i.current),resetContainers:!0})},onLeave:()=>{s({currentHoveredFontFamily:null,cachedElements:new Map(i.current),resetAll:!0})},onPopupChange:a=>{if(a){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=W(e,t,{includeBoundTextElement:!0});for(let e of n)i.current.set(e.id,z(e,{},!0))}s({openPopup:`fontFamily`})}else{let e={openPopup:null,currentHoveredFontFamily:null,cachedElements:new Map(i.current),resetAll:!0};c.current?r({...o,...e}):s(e),i.current.clear()}}})]})}}),O({name:`changeTextAlign`,label:`Change text alignment`,trackEvent:!1,perform:(e,t,n,r)=>({elements:kb(e,t,e=>{if(I(e)){let t=z(e,{textAlign:n});return cs(t,r.scene.getContainerElement(e),r.scene.getNonDeletedElementsMap()),t}return e},!0),appState:{...t,currentItemTextAlign:n},captureUpdate:j.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>{let i=r.scene.getNonDeletedElementsMap();return(0,q.jsxs)(`fieldset`,{children:[(0,q.jsx)(`legend`,{children:J(`labels.textAlign`)}),(0,q.jsx)(Cy,{group:`text-align`,options:[{value:`left`,text:J(`labels.left`),icon:Pt,testId:`align-left`},{value:`center`,text:J(`labels.center`),icon:ha,testId:`align-horizontal-center`},{value:`right`,text:J(`labels.right`),icon:ns,testId:`align-right`}],value:Ab(e,t,e=>{if(I(e))return e.textAlign;let t=dr(e,i);return t?t.textAlign:null},e=>I(e)||dr(e,i)!==null,e=>e?null:t.currentItemTextAlign),onChange:e=>n(e)})]})}}),O({name:`changeVerticalAlign`,label:`Change vertical alignment`,trackEvent:{category:`element`},perform:(e,t,n,r)=>({elements:kb(e,t,e=>{if(I(e)){let t=z(e,{verticalAlign:n});return cs(t,r.scene.getContainerElement(e),r.scene.getNonDeletedElementsMap()),t}return e},!0),appState:{...t},captureUpdate:j.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,q.jsx)(`fieldset`,{children:(0,q.jsx)(Cy,{group:`text-align`,options:[{value:Oc.TOP,text:J(`labels.alignTop`),icon:(0,q.jsx)(ul,{theme:t.theme}),testId:`align-top`},{value:Oc.MIDDLE,text:J(`labels.centerVertically`),icon:(0,q.jsx)(vl,{theme:t.theme}),testId:`align-middle`},{value:Oc.BOTTOM,text:J(`labels.alignBottom`),icon:(0,q.jsx)(wa,{theme:t.theme}),testId:`align-bottom`}],value:Ab(e,t,e=>{if(I(e)&&e.containerId)return e.verticalAlign;let t=dr(e,r.scene.getNonDeletedElementsMap());return t?t.verticalAlign:null},e=>I(e)||dr(e,r.scene.getNonDeletedElementsMap())!==null,e=>e?null:Oc.MIDDLE),onChange:e=>n(e)})})}),O({name:`changeRoundness`,label:`Change edge roundness`,trackEvent:!1,perform:(e,t,n)=>({elements:kb(e,t,e=>U(e)?e:z(e,{roundness:n===`round`?{type:T(e.type)?Zr.ADAPTIVE_RADIUS:Zr.PROPORTIONAL_RADIUS}:null})),appState:{...t,currentItemRoundness:n},captureUpdate:j.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n})=>{let r=Vi(R(e),t).some(e=>e.roundness?.type===Zr.LEGACY);return(0,q.jsxs)(`fieldset`,{children:[(0,q.jsx)(`legend`,{children:J(`labels.edges`)}),(0,q.jsx)(Cy,{group:`edges`,options:[{value:`sharp`,text:J(`labels.sharp`),icon:Yi},{value:`round`,text:J(`labels.round`),icon:br}],value:Ab(e,t,e=>r?null:e.roundness?`round`:`sharp`,e=>!st(e)&&e.hasOwnProperty(`roundness`),e=>e?null:t.currentItemRoundness),onChange:e=>n(e)})]})}});var Fb=e=>[{value:null,text:J(`labels.arrowhead_none`),keyBinding:`q`,icon:ft},{value:`arrow`,text:J(`labels.arrowhead_arrow`),keyBinding:`w`,icon:(0,q.jsx)(ae,{flip:e})},{value:`triangle`,text:J(`labels.arrowhead_triangle`),icon:(0,q.jsx)(zc,{flip:e}),keyBinding:`e`},{value:`triangle_outline`,text:J(`labels.arrowhead_triangle_outline`),icon:(0,q.jsx)(fn,{flip:e}),keyBinding:`r`},{value:`circle`,text:J(`labels.arrowhead_circle`),keyBinding:`a`,icon:(0,q.jsx)(Hs,{flip:e})},{value:`circle_outline`,text:J(`labels.arrowhead_circle_outline`),keyBinding:`s`,icon:(0,q.jsx)(Yc,{flip:e})},{value:`diamond`,text:J(`labels.arrowhead_diamond`),icon:(0,q.jsx)(tr,{flip:e}),keyBinding:`d`},{value:`diamond_outline`,text:J(`labels.arrowhead_diamond_outline`),icon:(0,q.jsx)($t,{flip:e}),keyBinding:`f`},{value:`bar`,text:J(`labels.arrowhead_bar`),keyBinding:`z`,icon:(0,q.jsx)(jt,{flip:e})},{value:`crowfoot_one`,text:J(`labels.arrowhead_crowfoot_one`),icon:(0,q.jsx)(Vt,{flip:e}),keyBinding:`c`},{value:`crowfoot_many`,text:J(`labels.arrowhead_crowfoot_many`),icon:(0,q.jsx)(ct,{flip:e}),keyBinding:`x`},{value:`crowfoot_one_or_many`,text:J(`labels.arrowhead_crowfoot_one_or_many`),icon:(0,q.jsx)(vt,{flip:e}),keyBinding:`v`}];O({name:`changeArrowhead`,label:`Change arrowheads`,trackEvent:!1,perform:(e,t,n)=>({elements:kb(e,t,e=>{if(c(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})=>{let r=Vv().rtl;return(0,q.jsxs)(`fieldset`,{children:[(0,q.jsx)(`legend`,{children:J(`labels.arrowheads`)}),(0,q.jsxs)(`div`,{className:`iconSelectList buttonList`,children:[(0,q.jsx)(sb,{label:`arrowhead_start`,options:Fb(!r),value:Ab(e,t,e=>c(e)&&ll(e.type)?e.startArrowhead:t.currentItemStartArrowhead,!0,t.currentItemStartArrowhead),onChange:e=>n({position:`start`,type:e}),numberOfOptionsToAlwaysShow:4}),(0,q.jsx)(sb,{label:`arrowhead_end`,group:`arrowheads`,options:Fb(!!r),value:Ab(e,t,e=>c(e)&&ll(e.type)?e.endArrowhead:t.currentItemEndArrowhead,!0,t.currentItemEndArrowhead),onChange:e=>n({position:`end`,type:e}),numberOfOptionsToAlwaysShow:4})]})]})}}),O({name:`changeArrowType`,label:`Change arrow types`,trackEvent:!1,perform:(e,t,n,r)=>{let i=kb(e,t,i=>{if(!st(i))return i;let a=z(i,{roundness:n===Ha.round?{type:Zr.PROPORTIONAL_RADIUS}:null,elbowed:n===Ha.elbow,points:n===Ha.elbow||i.elbowed?[i.points[0],i.points[i.points.length-1]]:i.points});if(U(a)){let n=r.scene.getNonDeletedElementsMap();r.dismissLinearEditor();let i=G.getPointAtIndexGlobalCoordinates(a,0,n),o=G.getPointAtIndexGlobalCoordinates(a,-1,n),s=!a.startBinding&&Ke(yi(i),e,n,t.zoom,!1,!0),c=!a.endBinding&&Ke(yi(o),e,n,t.zoom,!1,!0),l=s||a.startBinding&&n.get(a.startBinding.elementId),u=c||a.endBinding&&n.get(a.endBinding.elementId),d=s?Ks(a,s,`start`):i,f=c?Ks(a,c,`end`):o;s&&Ot(a,s,`start`,n),c&&Ot(a,c,`end`,n),V(a,{points:[d,f].map(e=>P(e[0]-a.x,e[1]-a.y)),...l&&a.startBinding?{startBinding:{...a.startBinding,...Ln(a,l,`start`,n)}}:{},...u&&a.endBinding?{endBinding:{...a.endBinding,...Ln(a,u,`end`,n)}}:{}}),G.updateEditorMidPointsCache(a,n,r.state)}return a}),a={...t,currentItemArrowType:n},o=t.selectedLinearElement?.elementId;if(o){let e=i.find(e=>e.id===o);e&&(a.selectedLinearElement=new G(e))}return{elements:i,appState:a,captureUpdate:j.IMMEDIATELY}},PanelComponent:({elements:e,appState:t,updateData:n})=>(0,q.jsxs)(`fieldset`,{children:[(0,q.jsx)(`legend`,{children:J(`labels.arrowtypes`)}),(0,q.jsx)(Cy,{group:`arrowtypes`,options:[{value:Ha.sharp,text:J(`labels.arrowtype_sharp`),icon:mt,testId:`sharp-arrow`},{value:Ha.round,text:J(`labels.arrowtype_round`),icon:Fo,testId:`round-arrow`},{value:Ha.elbow,text:J(`labels.arrowtype_elbowed`),icon:pi,testId:`elbow-arrow`}],value:Ab(e,t,e=>st(e)?e.elbowed?Ha.elbow:e.roundness?Ha.round:Ha.sharp:null,e=>st(e),e=>e?null:t.currentItemArrowType),onChange:e=>n(e)})]})});var Ib=({viewportX:e,viewportY:t,nextZoom:n},r)=>{let i=e-r.offsetLeft,a=t-r.offsetTop,o=r.zoom.value,s=r.scrollX+(i-i/o),c=r.scrollY+(a-a/o),l=-(i-i/n),u=-(a-a/n);return{scrollX:s+l,scrollY:c+u,zoom:{value:n}}},Lb=()=>{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},Rb=(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`})},zb=(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,Rb(t,e.getBoundingClientRect())},Bb=({children:e,label:t,long:n=!1,style:r,disabled:i})=>((0,K.useEffect)(()=>()=>Lb().classList.remove(`excalidraw-tooltip--visible`),[]),i?null:(0,q.jsx)(`div`,{className:`excalidraw-tooltip-wrapper`,onPointerEnter:e=>zb(e.currentTarget,Lb(),t,n),onPointerLeave:()=>Lb().classList.remove(`excalidraw-tooltip--visible`),style:r,children:e}));O({name:`changeViewBackgroundColor`,label:`labels.canvasBackground`,paletteName:`Change canvas background color`,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})=>(0,q.jsx)(nb,{palette:null,topPicks:fi,label:J(`labels.canvasBackground`),type:`canvasBackground`,color:t.viewBackgroundColor,onChange:e=>n({viewBackgroundColor:e}),"data-testid":`canvas-background-picker`,elements:e,appState:t,updateData:n})});var Vb=O({name:`clearCanvas`,label:`labels.clearCanvas`,paletteName:`Clear canvas`,icon:ge,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:{...Le(),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,pasteDialog:t.pasteDialog,activeTool:t.activeTool.type===`image`?{...t.activeTool,type:`selection`}:t.activeTool},captureUpdate:j.IMMEDIATELY})}),Hb=O({name:`zoomIn`,label:`buttons.zoomIn`,viewMode:!0,icon:Da,trackEvent:{category:`canvas`},perform:(e,t,n,r)=>({appState:{...t,...Ib({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:He(t.zoom.value+Ti)},t),userToFollow:null},captureUpdate:j.EVENTUALLY}),PanelComponent:({updateData:e,appState:t})=>(0,q.jsx)(Y,{type:`button`,className:`zoom-in-button zoom-button`,icon:Da,title:`${J(`buttons.zoomIn`)} \u2014 ${M(`CtrlOrCmd++`)}`,"aria-label":J(`buttons.zoomIn`),disabled:t.zoom.value>=30,onClick:()=>{e(null)}}),keyTest:e=>(e.code===D.EQUAL||e.code===D.NUM_ADD)&&(e[E.CTRL_OR_CMD]||e.shiftKey)}),Ub=O({name:`zoomOut`,label:`buttons.zoomOut`,icon:ml,viewMode:!0,trackEvent:{category:`canvas`},perform:(e,t,n,r)=>({appState:{...t,...Ib({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:He(t.zoom.value-Ti)},t),userToFollow:null},captureUpdate:j.EVENTUALLY}),PanelComponent:({updateData:e,appState:t})=>(0,q.jsx)(Y,{type:`button`,className:`zoom-out-button zoom-button`,icon:ml,title:`${J(`buttons.zoomOut`)} \u2014 ${M(`CtrlOrCmd+-`)}`,"aria-label":J(`buttons.zoomOut`),disabled:t.zoom.value<=Bl,onClick:()=>{e(null)}}),keyTest:e=>(e.code===D.MINUS||e.code===D.NUM_SUBTRACT)&&(e[E.CTRL_OR_CMD]||e.shiftKey)}),Wb=O({name:`resetZoom`,label:`buttons.resetZoom`,icon:Wa,viewMode:!0,trackEvent:{category:`canvas`},perform:(e,t,n,r)=>({appState:{...t,...Ib({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:He(1)},t),userToFollow:null},captureUpdate:j.EVENTUALLY}),PanelComponent:({updateData:e,appState:t})=>(0,q.jsx)(Bb,{label:J(`buttons.resetZoom`),style:{height:`100%`},children:(0,q.jsxs)(Y,{type:`button`,className:`reset-zoom-button zoom-button`,title:J(`buttons.resetZoom`),"aria-label":J(`buttons.resetZoom`),onClick:()=>{e(null)},children:[(t.zoom.value*100).toFixed(0),`%`]})}),keyTest:e=>(e.code===D.ZERO||e.code===D.NUM_ZERO)&&(e[E.CTRL_OR_CMD]||e.shiftKey)}),Gb=(e,t,n=1)=>{let[r,i,a,o]=e,s=a-r,c=t.width/s,l=o-i,u=t.height/l,d=Math.min(c,u)*_e(n,.1,1);return Math.min(d,1)},Kb=({bounds:e,appState:t,canvasOffsets:n,fitToViewport:r=!1,viewportZoomFactor:i=1,minZoom:a=-1/0,maxZoom:o=1/0})=>{i=_e(i,Bl,30);let[s,c,l,u]=e,d=(s+l)/2,f=(c+u)/2,p=n?.left??0,m=n?.top??0,h=n?.right??0,g=n?.bottom??0,_=t.width-p-h,v=t.height-m-g,y;if(r){let e=l-s,t=u-c;y=Math.min(_/e,v/t)*i}else y=Gb(e,{width:_,height:v},i);let b=He(_e(It(y,Ti,`floor`),a,o)),x=An({scenePoint:{x:d,y:f},viewportDimensions:{width:t.width,height:t.height},offsets:n,zoom:{value:b}});return{appState:{...t,scrollX:x.scrollX,scrollY:x.scrollY,zoom:{value:b}},captureUpdate:j.EVENTUALLY}},qb=({canvasOffsets:e,targetElements:t,appState:n,fitToViewport:r,viewportZoomFactor:i,minZoom:a,maxZoom:o})=>Kb({canvasOffsets:e,bounds:Ao(R(t)),appState:n,fitToViewport:r,viewportZoomFactor:i,minZoom:a,maxZoom:o});O({name:`zoomToFitSelectionInViewport`,label:`labels.zoomToFitViewport`,icon:Hi,trackEvent:{category:`canvas`},perform:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t);return qb({targetElements:i.length?i:e,appState:{...t,userToFollow:null},fitToViewport:!1,canvasOffsets:r.getEditorUIOffsets()})},keyTest:e=>e.code===D.TWO&&e.shiftKey&&!e.altKey&&!e[E.CTRL_OR_CMD]}),O({name:`zoomToFitSelection`,label:`helpDialog.zoomToSelection`,icon:Hi,trackEvent:{category:`canvas`},perform:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t);return qb({targetElements:i.length?i:e,appState:{...t,userToFollow:null},fitToViewport:!0,canvasOffsets:r.getEditorUIOffsets()})},keyTest:e=>e.code===D.THREE&&e.shiftKey&&!e.altKey&&!e[E.CTRL_OR_CMD]}),O({name:`zoomToFit`,label:`helpDialog.zoomToFit`,icon:Hi,viewMode:!0,trackEvent:{category:`canvas`},perform:(e,t,n,r)=>qb({targetElements:e,appState:{...t,userToFollow:null},fitToViewport:!1,canvasOffsets:r.getEditorUIOffsets()}),keyTest:e=>e.code===D.ONE&&e.shiftKey&&!e.altKey&&!e[E.CTRL_OR_CMD]});var Jb=O({name:`toggleTheme`,label:(e,t)=>t.theme===B.DARK?`buttons.lightMode`:`buttons.darkMode`,keywords:[`toggle`,`dark`,`light`,`mode`,`theme`],icon:e=>e.theme===B.LIGHT?la:us,viewMode:!0,trackEvent:{category:`canvas`},perform:(e,t,n)=>({appState:{...t,theme:n||(t.theme===B.LIGHT?B.DARK:B.LIGHT)},captureUpdate:j.EVENTUALLY}),keyTest:e=>e.altKey&&e.shiftKey&&e.code===D.D,predicate:(e,t,n,r)=>!!r.props.UIOptions.canvasActions.toggleTheme});O({name:`toggleEraserTool`,label:`toolBar.eraser`,trackEvent:{category:`toolbar`},perform:(e,t)=>{let n;return n=hn(t)?Sa(t,{...t.activeTool.lastActiveTool||{type:`selection`},lastActiveToolBeforeEraser:null}):Sa(t,{type:`eraser`,lastActiveToolBeforeEraser:t.activeTool}),{appState:{...t,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:n},captureUpdate:j.IMMEDIATELY}},keyTest:e=>e.key===E.E});var Yb=O({name:`toggleHandTool`,label:`toolBar.hand`,paletteName:`Toggle hand tool`,trackEvent:{category:`toolbar`},icon:ol,viewMode:!1,perform:(e,t,n,r)=>{let i;return Ho(t)?i=Sa(t,{...t.activeTool.lastActiveTool||{type:`selection`},lastActiveToolBeforeEraser:null}):(i=Sa(t,{type:`hand`,lastActiveToolBeforeEraser:t.activeTool}),H(r.interactiveCanvas,N.GRAB)),{appState:{...t,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:i},captureUpdate:j.IMMEDIATELY}},keyTest:e=>!e.altKey&&!e[E.CTRL_OR_CMD]&&e.key===E.H}),Xb=O({name:`finalize`,label:``,trackEvent:!1,perform:(e,t,n,r)=>{let{interactiveCanvas:i,focusContainer:a,scene:o}=r,s=o.getNonDeletedElementsMap();if(t.editingLinearElement){let{elementId:n,startBindingElement:r,endBindingElement:i}=t.editingLinearElement,a=G.getElement(n,s);if(a)return le(a)&&Bo(a,r,i,s,o),{elements:a.points.length<2||Ps(a)?e.filter(e=>e.id!==a.id):void 0,appState:{...t,cursorButton:`up`,editingLinearElement:null},captureUpdate:j.IMMEDIATELY}}let l=e,u=t.pendingImageElementId&&o.getElement(t.pendingImageElementId);u&&V(u,{isDeleted:!0},!1),window.document.activeElement instanceof HTMLElement&&a();let d=t.multiElement?t.multiElement:t.newElement?.type===`freedraw`?t.newElement:null;if(d){if(d.type!==`freedraw`&&t.lastPointerDownWith!==`touch`){let{points:e,lastCommittedPoint:t}=d;(!t||e[e.length-1]!==t)&&V(d,{points:d.points.slice(0,-1)})}Ps(d)&&(l=l.filter(e=>e.id!==d.id));let n=qn(d.points,t.zoom.value);if((d.type===`line`||d.type===`freedraw`)&&n){let e=d.points,t=e[0];V(d,{points:e.map((n,r)=>r===e.length-1?P(t[0],t[1]):n)})}if(le(d)&&!n&&d.points.length>1){let[n,r]=G.getPointAtIndexGlobalCoordinates(d,-1,k(e));Sl(d,t,{x:n,y:r},s,e)}}(!t.activeTool.locked&&t.activeTool.type!==`freedraw`||!d)&&ut(i);let f;return f=t.activeTool.type===`eraser`?Sa(t,{...t.activeTool.lastActiveTool||{type:`selection`},lastActiveToolBeforeEraser:null}):Sa(t,{type:`selection`}),{elements:l,appState:{...t,cursorButton:`up`,activeTool:(t.activeTool.locked||t.activeTool.type===`freedraw`)&&d?t.activeTool:f,activeEmbeddable:null,newElement:null,selectionElement:null,multiElement:null,editingTextElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:d&&!t.activeTool.locked&&t.activeTool.type!==`freedraw`?{...t.selectedElementIds,[d.id]:!0}:t.selectedElementIds,selectedLinearElement:d&&c(d)?new G(d):t.selectedLinearElement,pendingImageElementId:null},captureUpdate:j.IMMEDIATELY}},keyTest:(e,t)=>e.key===E.ESCAPE&&(t.editingLinearElement!==null||!t.newElement&&t.multiElement===null)||(e.key===E.ESCAPE||e.key===E.ENTER)&&t.multiElement!==null,PanelComponent:({appState:e,updateData:t,data:n})=>(0,q.jsx)(Y,{type:`button`,icon:Os,title:J(`buttons.done`),"aria-label":J(`buttons.done`),onClick:t,visible:e.multiElement!=null,size:n?.size||`medium`,style:{pointerEvents:`all`}})}),Zb=e=>{let{id:t}=Ok(),[n,r]=(0,K.useState)(e.value);return(0,q.jsxs)(`div`,{className:`ProjectName`,children:[(0,q.jsx)(`label`,{className:`ProjectName-label`,htmlFor:`filename`,children:`${e.label}:`}),(0,q.jsx)(`input`,{type:`text`,className:`TextInput`,onBlur:t=>{e.ignoreFocus||io(t.target);let n=t.target.value;n!==e.value&&e.onChange(n)},onKeyDown:e=>{if(e.key===E.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)})]})},Qb=e=>{let t=e.title||(e.value===B.DARK?J(`buttons.lightMode`):J(`buttons.darkMode`));return(0,q.jsx)(Y,{type:`icon`,icon:e.value===B.LIGHT?$b.MOON:$b.SUN,title:t,"aria-label":t,onClick:()=>e.onChange(e.value===B.DARK?B.LIGHT:B.DARK),"data-testid":`toggle-dark-mode`})},$b={SUN:(0,q.jsx)(`svg`,{width:`512`,height:`512`,className:`rtl-mirror`,viewBox:`0 0 512 512`,children:(0,q.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,q.jsx)(`svg`,{width:`512`,height:`512`,className:`rtl-mirror`,viewBox:`0 0 512 512`,children:(0,q.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`})})},ex=(e,{selectedElementIds:t},n)=>{e=R(e);let r=n&&xc(e,{selectedElementIds:t}),i=null,a=r?W(e,{selectedElementIds:t},{includeBoundTextElement:!0}):e;return r&&(a.length===1&&A(a[0])?(i=a[0],a=yo(e,i)):a.length>1&&(a=W(e,{selectedElementIds:t},{includeBoundTextElement:!0,includeElementsInFrames:!0}))),{exportingFrame:i,exportedElements:ui(a)}},tx=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(J(`alerts.cannotExportEmptyCanvas`));if(e===`svg`||e===`clipboard-svg`){let n=nr(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 xi(n.then(e=>new Blob([e.outerHTML],{type:de.svg})),{description:`Export to SVG`,name:c,extension:r.exportEmbedScene?`excalidraw.svg`:`svg`,mimeTypes:[Mt.svg],fileHandle:l});if(e===`clipboard-svg`){let e=await n.then(e=>e.outerHTML);try{await Jo(e)}catch{throw Error(J(`errors.copyToSystemClipboardFailed`))}return}}let d=Ii(t,r,i,{exportBackground:a,viewBackgroundColor:s,exportPadding:o,exportingFrame:u});if(e===`png`){let e=zo(d);return r.exportEmbedScene&&(e=e.then(e=>n(async()=>{let{encodePngMetadata:e}=await import(`./image-GAAHSSAO-DbYjE9JA.js`);return{encodePngMetadata:e}},__vite__mapDeps([60,61,2,3,1,62]),import.meta.url).then(({encodePngMetadata:n})=>n({blob:e,metadata:Et(t,r,i,`local`)})))),xi(e,{description:`Export to PNG`,name:c,extension:r.exportEmbedScene?`excalidraw.png`:`png`,mimeTypes:[Mt.png],fileHandle:l})}else if(e===`clipboard`)try{await en(zo(d))}catch(e){throw console.warn(e),e.name===`CANVAS_POSSIBLY_TOO_BIG`?Error(J(`canvasError.canvasTooBig`)):gi&&e.name===`TypeError`?Error(`${J(`alerts.couldNotCopyToClipboard`)}
44
+
45
+ ${J(`hints.firefox_clipboard_write`)}`):Error(J(`alerts.couldNotCopyToClipboard`))}else throw Error(`Unsupported export type`)},nx=async(e,t,n,r)=>{let{exportBackground:i,viewBackgroundColor:a,fileHandle:o}=t,s=ve(o);if(!o||!Qn(s))throw Error(`fileHandle should exist and should be of type svg or png when resaving`);t={...t,exportEmbedScene:!0};let{exportedElements:c,exportingFrame:l}=ex(e,t,!1);return await tx(s,c,t,n,{exportBackground:i,viewBackgroundColor:a,name:r,fileHandle:o,exportingFrame:l}),{fileHandle:o}},rx=({children:e,checked:t,onChange:n,className:r})=>(0,q.jsxs)(`div`,{className:L(`Checkbox`,r,{"is-checked":t}),onClick:e=>{n(!t,e),e.currentTarget.querySelector(`.Checkbox-box`).focus()},children:[(0,q.jsx)(`button`,{type:`button`,className:`Checkbox-box`,role:`checkbox`,"aria-checked":t,children:hl}),(0,q.jsx)(`div`,{className:`Checkbox-label`,children:e})]}),ix=O({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,q.jsx)(Zb,{label:J(`labels.fileTitle`),value:i.getName(),onChange:e=>t(e),ignoreFocus:r?.ignoreFocus??!1})}),ax=O({name:`changeExportScale`,label:`imageExportDialog.scale`,trackEvent:{category:`export`,action:`scale`},perform:(e,t,n)=>({appState:{...t,exportScale:n},captureUpdate:j.EVENTUALLY}),PanelComponent:({elements:e,appState:t,updateData:n})=>{let r=R(e),i=xc(r,t)?W(r,t):r;return(0,q.jsx)(q.Fragment,{children:nt.map(e=>{let[r,a]=xs(i,10,e),o=`${J(`imageExportDialog.label.scale`)} ${e}x (${r}x${a})`;return(0,q.jsx)(Y,{size:`small`,type:`radio`,icon:`${e}x`,name:`export-canvas-scale`,title:o,"aria-label":o,id:`export-canvas-scale`,checked:e===t.exportScale,onChange:()=>n(e)},e)})})}}),ox=O({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,q.jsx)(rx,{checked:e.exportBackground,onChange:e=>t(e),children:J(`imageExportDialog.label.withBackground`)})}),sx=O({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,q.jsxs)(rx,{checked:e.exportEmbedScene,onChange:e=>t(e),children:[J(`imageExportDialog.label.embedScene`),(0,q.jsx)(Bb,{label:J(`imageExportDialog.tooltip.embedScene`),long:!0,children:(0,q.jsx)(`div`,{className:`excalidraw-tooltip-icon`,children:Yt})})]})}),cx=O({name:`saveToActiveFile`,label:`buttons.save`,icon:ss,trackEvent:{category:`export`},predicate:(e,t,n,r)=>!!r.props.UIOptions.canvasActions.saveToActiveFile&&!!t.fileHandle&&!t.viewModeEnabled,perform:async(e,t,n,r)=>{let i=!!t.fileHandle;try{let{fileHandle:n}=it(t.fileHandle)?await nx(e,t,r.files,r.getName()):await Cl(e,t,r.files,r.getName());return{captureUpdate:j.EVENTUALLY,appState:{...t,fileHandle:n,toast:i?{message:n?.name?J(`toast.fileSavedToFilename`).replace(`{filename}`,`"${n.name}"`):J(`toast.fileSaved`)}:null}}}catch(e){return e?.name===`AbortError`?console.warn(e):console.error(e),{captureUpdate:j.EVENTUALLY}}},keyTest:e=>e.key===E.S&&e[E.CTRL_OR_CMD]&&!e.shiftKey}),lx=O({name:`saveFileToDisk`,label:`exportDialog.disk_title`,icon:ss,viewMode:!0,trackEvent:{category:`export`},perform:async(e,t,n,r)=>{try{let{fileHandle:n}=await Cl(e,{...t,fileHandle:null},r.files,r.getName());return{captureUpdate:j.EVENTUALLY,appState:{...t,openDialog:null,fileHandle:n,toast:{message:J(`toast.fileSaved`)}}}}catch(e){return e?.name===`AbortError`?console.warn(e):console.error(e),{captureUpdate:j.EVENTUALLY}}},keyTest:e=>e.key===E.S&&e.shiftKey&&e[E.CTRL_OR_CMD],PanelComponent:({updateData:e})=>(0,q.jsx)(Y,{type:`button`,icon:Al,title:J(`buttons.saveAs`),"aria-label":J(`buttons.saveAs`),showAriaLabel:Dk().editor.isMobile,hidden:!Ni,onClick:()=>e(null),"data-testid":`save-as-button`})}),ux=O({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 xn(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[E.CTRL_OR_CMD]&&e.key===E.O}),dx=O({name:`exportWithDarkMode`,label:`imageExportDialog.label.darkMode`,trackEvent:{category:`export`,action:`toggleTheme`},perform:(e,t,n)=>({appState:{...t,exportWithDarkMode:n},captureUpdate:j.EVENTUALLY}),PanelComponent:({appState:e,updateData:t})=>(0,q.jsx)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,marginTop:`-45px`,marginBottom:`10px`},children:(0,q.jsx)(Qb,{value:e.exportWithDarkMode?B.DARK:B.LIGHT,onChange:e=>{t(e===B.DARK)},title:J(`imageExportDialog.label.darkMode`)})})}),fx=`{}`,px=O({name:`copyStyles`,label:`labels.copyStyles`,icon:bn,trackEvent:{category:`element`},perform:(e,t,n,r)=>{let i=[],a=e.find(e=>t.selectedElementIds[e.id]);if(i.push(a),a&&ws(a)){let e=dr(a,r.scene.getNonDeletedElementsMap());i.push(e)}return a&&(fx=JSON.stringify(i)),{appState:{...t,toast:{message:J(`toast.copyStyles`)}},captureUpdate:j.EVENTUALLY}},keyTest:e=>e[E.CTRL_OR_CMD]&&e.altKey&&e.code===D.C}),mx=O({name:`pasteStyles`,label:`labels.pasteStyles`,icon:bn,trackEvent:{category:`element`},perform:(e,t,n,r)=>{let i=JSON.parse(fx),a=i[0],o=i[1];if(!Ss(a))return{elements:e,captureUpdate:j.EVENTUALLY};let s=W(e,t,{includeBoundTextElement:!0}),c=s.map(e=>e.id);return{elements:e.map(e=>{if(c.includes(e.id)){let t=a;if(I(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?Wi(t.roundness.type,e)?t.roundness:ts(e):null});if(I(n)){let e=t.fontSize||20,i=t.fontFamily||te;n=z(n,{fontSize:e,fontFamily:i,textAlign:t.textAlign||`left`,lineHeight:t.lineHeight||vc(i)});let a=null;n.containerId&&(a=s.find(e=>I(n)&&e.id===n.containerId)||null),cs(n,a,r.scene.getNonDeletedElementsMap())}return n.type===`arrow`&&st(t)&&(n=z(n,{startArrowhead:t.startArrowhead,endArrowhead:t.endArrowhead})),A(e)&&(n=z(n,{roundness:null,backgroundColor:`transparent`})),n}return e}),captureUpdate:j.IMMEDIATELY}},keyTest:e=>e[E.CTRL_OR_CMD]&&e.altKey&&e.code===D.V});O({name:`toggleCanvasMenu`,label:`buttons.menu`,trackEvent:{category:`menu`},perform:(e,t)=>({appState:{...t,openMenu:t.openMenu===`canvas`?null:`canvas`},captureUpdate:j.EVENTUALLY}),PanelComponent:({appState:e,updateData:t})=>(0,q.jsx)(Y,{type:`button`,icon:_s,"aria-label":J(`buttons.menu`),onClick:t,selected:e.openMenu===`canvas`})}),O({name:`toggleEditMenu`,label:`buttons.edit`,trackEvent:{category:`menu`},perform:(e,t)=>({appState:{...t,openMenu:t.openMenu===`shape`?null:`shape`},captureUpdate:j.EVENTUALLY}),PanelComponent:({elements:e,appState:t,updateData:n})=>(0,q.jsx)(Y,{visible:Tr(t,R(e)),type:`button`,icon:ci,"aria-label":J(`buttons.edit`),onClick:n,selected:t.openMenu===`shape`})});var hx=O({name:`toggleShortcuts`,label:`welcomeScreen.defaults.helpHint`,icon:dl,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`}},captureUpdate:j.EVENTUALLY}),keyTest:e=>e.key===E.QUESTION_MARK}),gx=e=>{if(e.length>=2){let t=e[0].groupIds;for(let n of t)if(e.reduce((e,t)=>e&&_t(t,n),!0))return!0}return!1},_x=(e,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0});return r.length>=2&&!gx(r)&&!Uc(r)},vx=O({name:`group`,label:`labels.group`,icon:e=>(0,q.jsx)(Fs,{theme:e.theme}),trackEvent:{category:`element`},perform:(e,t,n,r)=>{let i=Ve(r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0}));if(i.length<2)return{appState:t,elements:e,captureUpdate:j.EVENTUALLY};let a=_n(t);if(a.length===1){let n=a[0],r=new Set(Wc(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 o=[...e];new Set(i.map(e=>e.frameId)).size>1&&$c(i).forEach((e,t)=>{$a(e,r.scene.getNonDeletedElementsMap())});let s=Ro(),c=k(i);o=o.map(e=>c.get(e.id)?z(e,{groupIds:De(e.groupIds,s,t.editingGroupId)}):e);let l=Wc(o,s),u=l[l.length-1],d=o.lastIndexOf(u),f=o.slice(d+1),p=Un([...o.slice(0,d).filter(e=>!_t(e,s)),...l,...f],k(l));return{appState:{...t,...qi(s,{...t,selectedGroupIds:{}},R(o))},elements:p,captureUpdate:j.IMMEDIATELY}},predicate:(e,t,n,r)=>_x(e,t,r),keyTest:e=>!e.shiftKey&&e[E.CTRL_OR_CMD]&&e.key===E.G,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,q.jsx)(Y,{hidden:!_x(e,t,r),type:`button`,icon:(0,q.jsx)(Fs,{theme:t.theme}),onClick:()=>n(null),title:`${J(`labels.group`)} \u2014 ${M(`CtrlOrCmd+G`)}`,"aria-label":J(`labels.group`),visible:xc(R(e),t)})}),yx=O({name:`ungroup`,label:`labels.ungroup`,icon:e=>(0,q.jsx)(ot,{theme:e.theme}),trackEvent:{category:`element`},perform:(e,t,n,r)=>{let i=_n(t),a=k(e);if(i.length===0)return{appState:t,elements:e,captureUpdate:j.EVENTUALLY};let o=[...e],s=[];o=o.map(e=>{nc(e)&&s.push(e.id);let n=Kc(e.groupIds,t.selectedGroupIds);return n.length===e.groupIds.length?e:z(e,{groupIds:n})});let c=Fi(t,R(o),t,null),l=r.scene.getSelectedElements(t),u=new Set(l.filter(e=>e.frameId).map(e=>e.frameId));return Ql(e).filter(e=>u.has(e.id)).forEach(e=>{e&&(o=xe(o,so(o,e,t,a),e,r))}),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[E.CTRL_OR_CMD]&&e.key===E.G.toUpperCase(),predicate:(e,t)=>_n(t).length>0,PanelComponent:({elements:e,appState:t,updateData:n})=>(0,q.jsx)(Y,{type:`button`,hidden:_n(t).length===0,icon:(0,q.jsx)(ot,{theme:t.theme}),onClick:()=>n(null),title:`${J(`labels.ungroup`)} \u2014 ${M(`CtrlOrCmd+Shift+G`)}`,"aria-label":J(`labels.ungroup`),visible:xc(R(e),t)})}),bx=(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 xx(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 Sx=(e,t)=>`hsl(${Math.abs(xx(t?.id||e))%37*10}, 100%, 83%)`,Cx=e=>{let t=e?.trim()?.codePointAt(0);return(t?String.fromCodePoint(t):`?`).toUpperCase()},wx=({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=Sx(a,l);e.save(),e.strokeStyle=d,e.fillStyle=d;let f=t.remotePointerUserStates.get(a),p=u||f===`idle`||f===`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===B.DARK?`#2f6330`:g,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=Er,e.strokeStyle=Er,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 _=t.remotePointerUsernames.get(a)||``;if(!u&&_){e.font=`600 12px sans-serif`;let t=(h?s+0:s)+11/2,n=(h?c+0:c)+14+2,r=e.measureText(_),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())):bx(e,o,l,u,f,8,`#ffffff`),e.fillStyle=`#1e1e1e`,e.fillText(_,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-8/2),2,8),e.fillRect(o+u+8+5,l+(f/2-16/2),2,16),e.fillRect(o+u+8+10,l+(f/2-8/2),2,8))}e.restore(),e.closePath()}},Tx=({color:e,onClick:t,name:n,src:r,className:i})=>{let a=Cx(n),[o,s]=(0,K.useState)(!1),c=!o&&r,l=c?void 0:{background:e};return(0,q.jsx)(`div`,{className:L(`Avatar`,i),style:l,onClick:t,children:c?(0,q.jsx)(`img`,{className:`Avatar-img`,src:r,alt:a,referrerPolicy:`no-referrer`,onError:()=>s(!0)}):a})};O({name:`goToCollaborator`,label:`Go to a collaborator`,viewMode:!0,trackEvent:{category:`collab`},perform:(e,t,n)=>!n.socketId||t.userToFollow?.socketId===n.socketId||n.isCurrentUser?{appState:{...t,userToFollow:null},captureUpdate:j.EVENTUALLY}:{appState:{...t,userToFollow:{socketId:n.socketId,username:n.username||``},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=Sx(r,i),c=L({"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,q.jsxs)(`div`,{className:`UserList__collaborator-status-icon-speaking-indicator`,title:J(`userList.hint.isSpeaking`),children:[(0,q.jsx)(`div`,{}),(0,q.jsx)(`div`,{}),(0,q.jsx)(`div`,{})]}):i.isMuted?(0,q.jsx)(`div`,{className:`UserList__collaborator-status-icon-microphone-muted`,title:J(`userList.hint.micMuted`),children:fs}):(0,q.jsx)(`div`,{title:J(`userList.hint.inCall`),children:ri}):null;return a?(0,q.jsxs)(`div`,{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${c}`,style:{"--avatar-size":`1.5rem`},onClick:()=>e(i),children:[(0,q.jsx)(Tx,{color:s,onClick:()=>{},name:i.username||``,src:i.avatarUrl,className:c}),(0,q.jsx)(`div`,{className:`UserList__collaborator-name`,children:i.username}),(0,q.jsxs)(`div`,{className:`UserList__collaborator-status-icons`,"aria-hidden":!0,children:[o&&(0,q.jsx)(`div`,{className:`UserList__collaborator-status-icon-is-followed`,title:J(`userList.hint.followStatus`),children:Wl}),l]})]}):(0,q.jsxs)(`div`,{className:`UserList__collaborator UserList__collaborator--avatar-only ${c}`,children:[(0,q.jsx)(Tx,{color:s,onClick:()=>{e(i)},name:i.username||``,src:i.avatarUrl,className:c}),l&&(0,q.jsx)(`div`,{className:`UserList__collaborator-status-icon`,children:l})]})}});var Ex=O({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 ro)if(i.some(t=>t.type===e))return{captureUpdate:j.EVENTUALLY,appState:{...t,errorMessage:J(`errors.libraryElementTypeError.${e}`)}};return r.library.getLatestLibrary().then(e=>r.library.setLibrary([{id:Ro(),status:`unpublished`,elements:i.map(_r),created:Date.now()},...e])).then(()=>({captureUpdate:j.EVENTUALLY,appState:{...t,toast:{message:J(`toast.addedToLibrary`)}}})).catch(e=>({captureUpdate:j.EVENTUALLY,appState:{...t,errorMessage:e.message}}))},label:`labels.addToLibrary`}),Dx=(e,t,n,r)=>{let i=Cs(e,t),a=ao(e);return i.flatMap(e=>{let t=Ox(e,a,n);return e.map(n=>{let i=V(n,{x:n.x+t.x,y:n.y+t.y});return ga(n,r.getNonDeletedElementsMap(),{simultaneouslyUpdated:e}),i})})},Ox=(e,t,{axis:n,position:r})=>{let i=ao(e),[a,o]=n===`x`?[`minX`,`maxX`]:[`minY`,`maxY`],s={x:0,y:0};return r===`start`?{...s,[n]:t[a]-i[a]}:r===`end`?{...s,[n]:t[o]-i[o]}:{...s,[n]:(t[a]+t[o])/2-(i[a]+i[o])/2}},kx=(e,t)=>{let n=t.scene.getSelectedElements(e);return n.length>1&&!n.some(e=>A(e))},Ax=(e,t,n,r)=>{let i=k(Dx(n.scene.getSelectedElements(t),k(e),r,n.scene));return Xo(e.map(e=>i.get(e.id)||e),t,n)};O({name:`alignTop`,label:`labels.alignTop`,icon:Uo,trackEvent:{category:`element`},predicate:(e,t,n,r)=>kx(t,r),perform:(e,t,n,r)=>({appState:t,elements:Ax(e,t,r,{position:`start`,axis:`y`}),captureUpdate:j.IMMEDIATELY}),keyTest:e=>e[E.CTRL_OR_CMD]&&e.shiftKey&&e.key===E.ARROW_UP,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,q.jsx)(Y,{hidden:!kx(t,r),type:`button`,icon:Uo,onClick:()=>n(null),title:`${J(`labels.alignTop`)} \u2014 ${M(`CtrlOrCmd+Shift+Up`)}`,"aria-label":J(`labels.alignTop`),visible:xc(R(e),t)})}),O({name:`alignBottom`,label:`labels.alignBottom`,icon:ca,trackEvent:{category:`element`},predicate:(e,t,n,r)=>kx(t,r),perform:(e,t,n,r)=>({appState:t,elements:Ax(e,t,r,{position:`end`,axis:`y`}),captureUpdate:j.IMMEDIATELY}),keyTest:e=>e[E.CTRL_OR_CMD]&&e.shiftKey&&e.key===E.ARROW_DOWN,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,q.jsx)(Y,{hidden:!kx(t,r),type:`button`,icon:ca,onClick:()=>n(null),title:`${J(`labels.alignBottom`)} \u2014 ${M(`CtrlOrCmd+Shift+Down`)}`,"aria-label":J(`labels.alignBottom`),visible:xc(R(e),t)})}),O({name:`alignLeft`,label:`labels.alignLeft`,icon:Ei,trackEvent:{category:`element`},predicate:(e,t,n,r)=>kx(t,r),perform:(e,t,n,r)=>({appState:t,elements:Ax(e,t,r,{position:`start`,axis:`x`}),captureUpdate:j.IMMEDIATELY}),keyTest:e=>e[E.CTRL_OR_CMD]&&e.shiftKey&&e.key===E.ARROW_LEFT,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,q.jsx)(Y,{hidden:!kx(t,r),type:`button`,icon:Ei,onClick:()=>n(null),title:`${J(`labels.alignLeft`)} \u2014 ${M(`CtrlOrCmd+Shift+Left`)}`,"aria-label":J(`labels.alignLeft`),visible:xc(R(e),t)})}),O({name:`alignRight`,label:`labels.alignRight`,icon:Lt,trackEvent:{category:`element`},predicate:(e,t,n,r)=>kx(t,r),perform:(e,t,n,r)=>({appState:t,elements:Ax(e,t,r,{position:`end`,axis:`x`}),captureUpdate:j.IMMEDIATELY}),keyTest:e=>e[E.CTRL_OR_CMD]&&e.shiftKey&&e.key===E.ARROW_RIGHT,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,q.jsx)(Y,{hidden:!kx(t,r),type:`button`,icon:Lt,onClick:()=>n(null),title:`${J(`labels.alignRight`)} \u2014 ${M(`CtrlOrCmd+Shift+Right`)}`,"aria-label":J(`labels.alignRight`),visible:xc(R(e),t)})}),O({name:`alignVerticallyCentered`,label:`labels.centerVertically`,icon:Oo,trackEvent:{category:`element`},predicate:(e,t,n,r)=>kx(t,r),perform:(e,t,n,r)=>({appState:t,elements:Ax(e,t,r,{position:`center`,axis:`y`}),captureUpdate:j.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,q.jsx)(Y,{hidden:!kx(t,r),type:`button`,icon:Oo,onClick:()=>n(null),title:J(`labels.centerVertically`),"aria-label":J(`labels.centerVertically`),visible:xc(R(e),t)})}),O({name:`alignHorizontallyCentered`,label:`labels.centerHorizontally`,icon:Qi,trackEvent:{category:`element`},predicate:(e,t,n,r)=>kx(t,r),perform:(e,t,n,r)=>({appState:t,elements:Ax(e,t,r,{position:`center`,axis:`x`}),captureUpdate:j.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,q.jsx)(Y,{hidden:!kx(t,r),type:`button`,icon:Qi,onClick:()=>n(null),title:J(`labels.centerHorizontally`),"aria-label":J(`labels.centerHorizontally`),visible:xc(R(e),t)})});var jx=(e,t,n)=>{let[r,i,a,o]=n.axis===`x`?[`minX`,`midX`,`maxX`,`width`]:[`minY`,`midY`,`maxY`,`height`],s=ao(e),c=Cs(e,t).map(e=>[e,ao(e)]).sort((e,t)=>e[1][i]-t[1][i]),l=0;for(let e of c)l+=e[1][o];let u=(s[o]-l)/(c.length-1);if(u<0){let e=c.findIndex(e=>e[1][r]===s[r]),t=c.findIndex(e=>e[1][a]===s[a]),o=(c[t][1][i]-c[e][1][i])/(c.length-1),l=c[e][1][i];return c.flatMap(([r,a],s)=>{let c={x:0,y:0};return s!==e&&s!==t&&(l+=o,c[n.axis]=l-a[i]),r.map(e=>z(e,{x:e.x+c.x,y:e.y+c.y}))})}let d=s[r];return c.flatMap(([e,t])=>{let i={x:0,y:0};return i[n.axis]=d-t[r],d+=u,d+=t[o],e.map(e=>z(e,{x:e.x+i.x,y:e.y+i.y}))})},Mx=(e,t)=>{let n=t.scene.getSelectedElements(e);return n.length>1&&!n.some(e=>A(e))},Nx=(e,t,n,r)=>{let i=k(jx(n.scene.getSelectedElements(t),n.scene.getNonDeletedElementsMap(),r));return Xo(e.map(e=>i.get(e.id)||e),t,n)};O({name:`distributeHorizontally`,label:`labels.distributeHorizontally`,trackEvent:{category:`element`},perform:(e,t,n,r)=>({appState:t,elements:Nx(e,t,r,{space:`between`,axis:`x`}),captureUpdate:j.IMMEDIATELY}),keyTest:e=>!e[E.CTRL_OR_CMD]&&e.altKey&&e.code===D.H,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,q.jsx)(Y,{hidden:!Mx(t,r),type:`button`,icon:xr,onClick:()=>n(null),title:`${J(`labels.distributeHorizontally`)} \u2014 ${M(`Alt+H`)}`,"aria-label":J(`labels.distributeHorizontally`),visible:xc(R(e),t)})}),O({name:`distributeVertically`,label:`labels.distributeVertically`,trackEvent:{category:`element`},perform:(e,t,n,r)=>({appState:t,elements:Nx(e,t,r,{space:`between`,axis:`y`}),captureUpdate:j.IMMEDIATELY}),keyTest:e=>!e[E.CTRL_OR_CMD]&&e.altKey&&e.code===D.V,PanelComponent:({elements:e,appState:t,updateData:n,app:r})=>(0,q.jsx)(Y,{hidden:!Mx(t,r),type:`button`,icon:tc,onClick:()=>n(null),title:`${J(`labels.distributeVertically`)} \u2014 ${M(`Alt+V`)}`,"aria-label":J(`labels.distributeVertically`),visible:xc(R(e),t)})});var Px=O({name:`flipHorizontal`,label:`labels.flipHorizontal`,icon:ta,trackEvent:{category:`element`},perform:(e,t,n,r)=>({elements:Xo(Ix(e,r.scene.getNonDeletedElementsMap(),t,`horizontal`,r),t,r),appState:t,captureUpdate:j.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===D.H}),Fx=O({name:`flipVertical`,label:`labels.flipVertical`,icon:Hc,trackEvent:{category:`element`},perform:(e,t,n,r)=>({elements:Xo(Ix(e,r.scene.getNonDeletedElementsMap(),t,`vertical`,r),t,r),appState:t,captureUpdate:j.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===D.V&&!e[E.CTRL_OR_CMD]}),Ix=(e,t,n,r,i)=>{let a=k(Lx(W(R(e),n,{includeBoundTextElement:!0,includeElementsInFrames:!0}),t,n,r,i));return e.map(e=>a.get(e.id)||e)},Lx=(e,t,n,r,i)=>{if(e.every(e=>st(e)&&(e.startBinding||e.endBinding)))return e.map(e=>{let t=e;return z(t,{startArrowhead:t.endArrowhead,endArrowhead:t.startArrowhead})});let{midX:a,midY:o}=ao(e);Dn(e,t,`nw`,i.scene,new Map(Array.from(t.values()).map(e=>[e.id,_r(e)])),{flipByX:r===`horizontal`,flipByY:r===`vertical`,shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),jn(e.filter(c),t,i.scene.getNonDeletedElements(),i.scene,Ir(n),[],n.zoom);let{elbowArrows:s,otherElements:l}=e.reduce((e,t)=>U(t)?{...e,elbowArrows:e.elbowArrows.concat(t)}:{...e,otherElements:e.otherElements.concat(t)},{elbowArrows:[],otherElements:[]}),{midX:u,midY:d}=ao(e),[f,p]=[a-u,o-d];return l.forEach(e=>V(e,{x:e.x+f,y:e.y+p})),s.forEach(e=>V(e,{x:e.x+f,y:e.y+p})),e},Rx=O({name:`copy`,label:`labels.copy`,icon:ki,trackEvent:{category:`element`},perform:async(e,t,n,r)=>{let i=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await _o(i,r.files,n)}catch(e){return{captureUpdate:j.EVENTUALLY,appState:{...t,errorMessage:e.message}}}return{captureUpdate:j.EVENTUALLY}},keyTest:void 0}),zx=O({name:`paste`,label:`labels.paste`,trackEvent:{category:`element`},perform:async(e,t,n,r)=>{let i;try{i=await yc()}catch(e){return e.name===`AbortError`||e.name===`NotAllowedError`?!1:(console.error(`actionPaste ${e.name}: ${e.message}`),gi?{captureUpdate:j.EVENTUALLY,appState:{...t,errorMessage:J(`hints.firefox_clipboard_write`)}}:{captureUpdate:j.EVENTUALLY,appState:{...t,errorMessage:J(`errors.asyncPasteFailedOnRead`)}})}try{r.pasteFromClipboard(Pi({types:i}))}catch(e){return console.error(e),{captureUpdate:j.EVENTUALLY,appState:{...t,errorMessage:J(`errors.asyncPasteFailedOnParse`)}}}return{captureUpdate:j.EVENTUALLY}},keyTest:void 0}),Bx=O({name:`cut`,label:`labels.cut`,icon:hs,trackEvent:{category:`element`},perform:(e,t,n,r)=>(Rx.perform(e,t,n,r),Xv.perform(e,t,null,r)),keyTest:e=>e[E.CTRL_OR_CMD]&&e.key===E.X}),Vx=O({name:`copyAsSvg`,label:`labels.copyAsSvg`,icon:Te,trackEvent:{category:`element`},perform:async(e,t,n,r)=>{if(!r.canvas)return{captureUpdate:j.EVENTUALLY};let{exportedElements:i,exportingFrame:a}=ex(e,t,!0);try{return await tx(`clipboard-svg`,i,t,r.files,{...t,exportingFrame:a,name:r.getName()}),{appState:{toast:{message:J(`toast.copyToClipboardAsSvg`,{exportSelection:r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}).length?J(`toast.selection`):J(`toast.canvas`),exportColorScheme:t.exportWithDarkMode?J(`buttons.darkMode`):J(`buttons.lightMode`)})}},captureUpdate:j.EVENTUALLY}}catch(e){return console.error(e),{appState:{errorMessage:e.message},captureUpdate:j.EVENTUALLY}}},predicate:e=>or&&e.length>0,keywords:[`svg`,`clipboard`,`copy`]}),Hx=O({name:`copyAsPng`,label:`labels.copyAsPng`,icon:Kt,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}=ex(e,t,!0);try{return await tx(`clipboard`,a,t,r.files,{...t,exportingFrame:o,name:r.getName()}),{appState:{...t,toast:{message:J(`toast.copyToClipboardAsPng`,{exportSelection:i.length?J(`toast.selection`):J(`toast.canvas`),exportColorScheme:t.exportWithDarkMode?J(`buttons.darkMode`):J(`buttons.lightMode`)})}},captureUpdate:j.EVENTUALLY}}catch(e){return console.error(e),{appState:{...t,errorMessage:e.message},captureUpdate:j.EVENTUALLY}}},predicate:e=>se&&e.length>0,keyTest:e=>e.code===D.C&&e.altKey&&e.shiftKey,keywords:[`png`,`clipboard`,`copy`]}),Ux=O({name:`copyText`,label:`labels.copyText`,trackEvent:{category:`element`},perform:(e,t,n,r)=>{let i=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0});try{Jo(dn(i))}catch{throw Error(J(`errors.copyToSystemClipboardFailed`))}return{captureUpdate:j.EVENTUALLY}},predicate:(e,t,n,r)=>or&&r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0}).some(I),keywords:[`text`,`clipboard`,`copy`]}),Wx=O({name:`gridMode`,icon:wt,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[E.CTRL_OR_CMD]&&e.code===D.QUOTE}),Gx=O({name:`zenMode`,label:`buttons.zenMode`,icon:Gr,paletteName:`Toggle zen mode`,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)=>typeof n.zenModeEnabled>`u`,keyTest:e=>!e[E.CTRL_OR_CMD]&&e.altKey&&e.code===D.Z}),Kx=O({name:`objectsSnapMode`,label:`buttons.objectsSnapMode`,icon:ii,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[E.CTRL_OR_CMD]&&e.altKey&&e.code===D.S}),qx=O({name:`stats`,label:`stats.fullTitle`,icon:Tt,paletteName:`Toggle stats`,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[E.CTRL_OR_CMD]&&e.altKey&&e.code===D.SLASH}),Jx=O({name:`unbindText`,label:`labels.unbindText`,trackEvent:{category:`element`},predicate:(e,t,n,r)=>r.scene.getSelectedElements(t).some(e=>ws(e)),perform:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t),a=r.scene.getNonDeletedElementsMap();return i.forEach(e=>{let t=dr(e,a);if(t){let{width:n,height:r}=yn(t.originalText,Ds(t),t.lineHeight),i=Di(e.id);rl(e.id);let{x:o,y:s}=Bt(e,t,a);V(t,{containerId:null,width:n,height:r,text:t.originalText,x:o,y:s}),V(e,{boundElements:e.boundElements?.filter(e=>e.id!==t.id),height:i||e.height})}}),{elements:e,appState:t,captureUpdate:j.IMMEDIATELY}}}),Yx=O({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=I(i[0])||I(i[1]),t;if(ba(i[0])?t=i[0]:ba(i[1])&&(t=i[1]),e&&t&&dr(t,r.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t),a,o;I(i[0])&&ba(i[1])?(a=i[0],o=i[1]):(a=i[1],o=i[0]),V(a,{containerId:o.id,verticalAlign:Oc.MIDDLE,textAlign:Ma.CENTER,autoResize:!0}),V(o,{boundElements:(o.boundElements||[]).concat({type:`text`,id:a.id})});let s=o.height;return cs(a,o,r.scene.getNonDeletedElementsMap()),Ui(o.id,s),{elements:Xx(e,o,a),appState:{...t,selectedElementIds:{[o.id]:!0}},captureUpdate:j.IMMEDIATELY}}}),Xx=(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),Un(r,k([t,n])),r},Zx=(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),Un(r,k([t,n])),r},Qx=O({name:`wrapTextInContainer`,label:`labels.createContainerFromText`,trackEvent:{category:`element`},predicate:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t),a=i.every(e=>I(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(I(e)){let n=Xs({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:t.currentItemStrokeWidth,strokeStyle:t.currentItemStrokeStyle,roundness:t.currentItemRoundness===`round`?{type:T(`rectangle`)?Zr.ADAPTIVE_RADIUS:Zr.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:e.x-5,y:e.y-5,width:No(e.width,`rectangle`),height:No(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 r=t.startBinding,i=t.endBinding;r?.elementId===e.id&&(r={...r,elementId:n.id}),i?.elementId===e.id&&(i={...i,elementId:n.id}),(r||i)&&V(t,{startBinding:r,endBinding:i},!1)})}V(e,{containerId:n.id,verticalAlign:Oc.MIDDLE,boundElements:null,textAlign:Ma.CENTER,autoResize:!0},!1),cs(e,n,r.scene.getNonDeletedElementsMap()),a=Zx([...a,n],n,e),o[n.id]=!0}return{elements:a,appState:{...t,selectedElementIds:o},captureUpdate:j.IMMEDIATELY}}}),$x=380,eS=42,tS=5,nS=85,rS=500,iS=!1,aS=new Map,oS=({element:e,elementsMap:t,setAppState:n,onLinkOpen:r,setToast:i,updateEmbedValidationStatus:a})=>{let o=Ak(),s=Ek(),c=Dk(),l=e.link||``,[u,d]=(0,K.useState)(l),f=(0,K.useRef)(null),p=o.showHyperlinkPopup===`editor`,m=(0,K.useCallback)(()=>{if(!f.current)return;let t=on(f.current.value)||null;if(!e.link&&t&&X(`hyperlink`,`create`),St(e)){if(o.activeEmbeddable?.element===e&&n({activeEmbeddable:null}),!t){V(e,{link:null}),a(e,!1);return}if(!Il(t,s.validateEmbeddable))t&&i({message:J(`toast.unableToEmbed`),closable:!0}),e.link&&aS.set(e.id,e.link),V(e,{link:t}),a(e,!1);else{let{width:n,height:r}=e,o=Je(t);o?.error instanceof URIError&&i({message:J(`toast.unrecognizedLinkFormat`),closable:!0});let s=o?o.intrinsicSize.w/o.intrinsicSize.h:1;V(e,{...aS.get(e.id)===e.link?{}:{width:o?.type===`video`?n>r?n:r*s:n,height:o?.type===`video`&&n>r?n/s:r},link:t}),a(e,!0),aS.has(e.id)&&aS.delete(e.id)}}else V(e,{link:t})},[e,i,s.validateEmbeddable,o.activeEmbeddable,n,a]);(0,K.useLayoutEffect)(()=>()=>{m()},[m]),(0,K.useEffect)(()=>{p&&f?.current&&!(c.viewport.isMobile||c.isTouchScreen)&&f.current.select()},[p,c.viewport.isMobile,c.isTouchScreen]),(0,K.useEffect)(()=>{let r=null,i=i=>{p||(r&&clearTimeout(r),pS(e,t,o,P(i.clientX,i.clientY))&&(r=window.setTimeout(()=>{n({showHyperlinkPopup:!1})},rS)))};return window.addEventListener(`pointermove`,i,!1),()=>{window.removeEventListener(`pointermove`,i,!1),r&&clearTimeout(r)}},[o,e,p,n,t]);let h=(0,K.useCallback)(()=>{X(`hyperlink`,`delete`),V(e,{link:null}),n({showHyperlinkPopup:!1})},[n,e]),g=()=>{X(`hyperlink`,`edit`,`popup-ui`),n({showHyperlinkPopup:`editor`})},{x:_,y:v}=sS(e,o,t);return o.contextMenu||o.selectedElementsAreBeingDragged||o.resizingElement||o.isRotating||o.openMenu||o.viewModeEnabled?null:(0,q.jsxs)(`div`,{className:`excalidraw-hyperlinkContainer`,style:{top:`${v}px`,left:`${_}px`,width:$x,padding:tS},children:[p?(0,q.jsx)(`input`,{className:L(`excalidraw-hyperlinkContainer-input`),placeholder:J(`labels.link.hint`),ref:f,value:u,onChange:e=>d(e.target.value),autoFocus:!0,onKeyDown:e=>{e.stopPropagation(),e[E.CTRL_OR_CMD]&&e.key===E.K&&e.preventDefault(),(e.key===E.ENTER||e.key===E.ESCAPE)&&(m(),n({showHyperlinkPopup:`info`}))}}):e.link?(0,q.jsx)(`a`,{href:on(e.link||``),className:`excalidraw-hyperlinkContainer-link`,target:za(e.link)?`_self`:`_blank`,onClick:t=>{if(e.link&&r){let n=tt(`excalidraw-link`,t.nativeEvent);r({...e,link:on(e.link)},n),n.defaultPrevented&&t.preventDefault()}},rel:`noopener noreferrer`,children:e.link}):(0,q.jsx)(`div`,{className:`excalidraw-hyperlinkContainer-link`,children:J(`labels.link.empty`)}),(0,q.jsxs)(`div`,{className:`excalidraw-hyperlinkContainer__buttons`,children:[!p&&(0,q.jsx)(Y,{type:`button`,title:J(`buttons.edit`),"aria-label":J(`buttons.edit`),label:J(`buttons.edit`),onClick:g,className:`excalidraw-hyperlinkContainer--edit`,icon:Zi}),(0,q.jsx)(Y,{type:`button`,title:J(`labels.linkToElement`),"aria-label":J(`labels.linkToElement`),label:J(`labels.linkToElement`),onClick:()=>{n({openDialog:{name:`elementLinkSelector`,sourceElementId:e.id}})},icon:Tn}),l&&!St(e)&&(0,q.jsx)(Y,{type:`button`,title:J(`buttons.remove`),"aria-label":J(`buttons.remove`),label:J(`buttons.remove`),onClick:h,className:`excalidraw-hyperlinkContainer--remove`,icon:ge})]})]})},sS=(e,t,n)=>{let[r,i]=Kl(e,n),{x:a,y:o}=Wo({sceneX:r+e.width/2,sceneY:i},t);return{x:a-t.offsetLeft-$x/2,y:o-t.offsetTop-nS}},cS=(e,t)=>{let n=W(e,t);return St(n[0])?`labels.link.editEmbed`:n[0]?.link?`labels.link.edit`:`labels.link.create`},lS=null,uS=(e,t,n)=>{lS&&clearTimeout(lS),lS=window.setTimeout(()=>dS(e,t,n),300)},dS=(e,t,n)=>{if(!e.link)return;let r=Lb();r.classList.add(`excalidraw-tooltip--visible`),r.style.maxWidth=`20rem`,r.textContent=ie(e.link)?J(`labels.link.goToElement`):e.link;let[i,a,o,s]=Kl(e,n),[c,l,u,d]=yt([i,a,o,s],e.angle,t),f=Wo({sceneX:c,sceneY:l},t);Rb(r,{left:f.x,top:f.y,width:u,height:d},`top`),X(`hyperlink`,`tooltip`,`link-icon`),iS=!0},fS=()=>{lS&&clearTimeout(lS),iS&&(iS=!1,Lb().classList.remove(`excalidraw-tooltip--visible`))},pS=(e,t,n,[r,i])=>{let{x:a,y:o}=Ls({clientX:r,clientY:i},n),s=15/n.zoom.value;if(La(a,o,e,t))return!1;let[c,l,u]=Kl(e,t);if(a>=c&&a<=u&&o>=l-nS&&o<=l)return!1;let{x:d,y:f}=sS(e,n,t);return!(r>=d-s&&r<=d+$x+tS*2+s&&i>=f-s&&i<=f+s+tS*2+eS)},mS=O({name:`hyperlink`,label:(e,t)=>cS(e,t),icon:Xe,perform:(e,t)=>t.showHyperlinkPopup===`editor`?!1:{elements:e,appState:{...t,showHyperlinkPopup:`editor`,openMenu:null},captureUpdate:j.IMMEDIATELY},trackEvent:{category:`hyperlink`,action:`click`},keyTest:e=>e[E.CTRL_OR_CMD]&&e.key===E.K,predicate:(e,t)=>W(e,t).length===1,PanelComponent:({elements:e,appState:t,updateData:n})=>{let r=W(e,t);return(0,q.jsx)(Y,{type:`button`,icon:Xe,"aria-label":J(cS(e,t)),title:`${St(e[0])?J(`labels.link.labelEmbed`):J(`labels.link.label`)} - ${M(`CtrlOrCmd+K`)}`,onClick:()=>n(null),selected:r.length===1&&!!r[0].link})}}),hS=e=>e.every(e=>!e.locked),gS=O({name:`toggleElementLock`,label:(e,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1});return r.length===1&&!A(r[0])?r[0].locked?`labels.elementLock.unlock`:`labels.elementLock.lock`:hS(r)?`labels.elementLock.lockAll`:`labels.elementLock.unlockAll`},icon:(e,t)=>hS(W(t,e))?Xi:Ee,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=hS(i),o=k(i);return{elements:e.map(e=>o.has(e.id)?z(e,{locked:a}):e),appState:{...t,selectedLinearElement:a?null:t.selectedLinearElement},captureUpdate:j.IMMEDIATELY}},keyTest:(e,t,n,r)=>e.key.toLocaleLowerCase()===E.L&&e[E.CTRL_OR_CMD]&&e.shiftKey&&r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1}).length>0}),_S=O({name:`unlockAllElements`,paletteName:`Unlock all elements`,trackEvent:{category:`canvas`},viewMode:!1,icon:Ee,predicate:(e,t)=>W(e,t).length===0&&e.some(e=>e.locked),perform:(e,t)=>{let n=e.filter(e=>e.locked);return{elements:e.map(e=>e.locked?z(e,{locked:!1}):e),appState:{...t,selectedElementIds:Object.fromEntries(n.map(e=>[e.id,!0]))},captureUpdate:j.IMMEDIATELY}},label:`labels.elementLock.unlockAll`}),vS=()=>{let[e,t]=(0,K.useState)(null);return[e,(0,K.useCallback)(e=>t(e),[])]},yS=e=>{let{closeOnClickOutside:t=!0}=e,n=Wy({className:`excalidraw-modal-container`}),r=(0,K.useRef)(document.body.classList.contains(`excalidraw-animations-disabled`));return n?(0,Ju.createPortal)((0,q.jsxs)(`div`,{className:L(`Modal`,e.className,{"animations-disabled":r.current}),role:`dialog`,"aria-modal":`true`,onKeyDown:t=>{t.key===E.ESCAPE&&(t.nativeEvent.stopImmediatePropagation(),t.stopPropagation(),e.onCloseRequest())},"aria-labelledby":e.labelledBy,"data-prevent-outside-click":!0,children:[(0,q.jsx)(`div`,{className:`Modal__background`,onClick:t?e.onCloseRequest:void 0}),(0,q.jsx)(`div`,{className:`Modal__content`,style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),n):null},bS=au(new Map),xS=async e=>await $s({elements:e,appState:{exportBackground:!1,viewBackgroundColor:kr.white},files:null,renderEmbeddables:!1,skipInliningFonts:!0}),SS=(e,t,n)=>{let[r,i]=(0,K.useState)();return(0,K.useEffect)(()=>{if(t)if(e){let r=n.get(e);r?i(r):(async()=>{let r=await xS(t);r.querySelector(`.style-fonts`)?.remove(),r&&(n.set(e,r),i(r))})()}else (async()=>{i(await xS(t))})()},[e,t,n,i]),r},CS=()=>{let[e]=Dv(bS);return{clearLibraryCache:()=>e.clear(),deleteItemsFromLibraryCache:t=>{t.forEach(t=>e.delete(t))},svgCache:e}},wS=class{constructor(){i(this,`jobs`,[]),i(this,`running`,!1)}tick(){if(this.running)return;let e=this.jobs.shift();e?(this.running=!0,e.promise.resolve(_l(e.jobFactory,...e.args).finally(()=>{this.running=!1,this.tick()}))):this.running=!1}push(e,...t){let n=uc();return this.jobs.push({jobFactory:e,promise:n,args:t}),this.tick(),n}},TS=new zn,ES=au({status:`loaded`,isInitialized:!1,libraryItems:[]}),DS=e=>ui(e),OS=(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):!1),kS=(e,t)=>{let n=[];for(let r of t)OS(e,r)&&n.push(r);return[...n,...e]},AS=(e,t)=>{let n=k(t),r={deletedItems:new Map,addedItems:new Map};for(let t of e)n.has(t.id)||r.deletedItems.set(t.id,t);let i=k(e);for(let e of t)i.has(e.id)||r.addedItems.set(e.id,e);return r},jS=class{constructor(e){i(this,`currLibraryItems`,[]),i(this,`prevLibraryItems`,DS(this.currLibraryItems)),i(this,`app`),i(this,`updateQueue`,[]),i(this,`getLastUpdateTask`,()=>this.updateQueue[this.updateQueue.length-1]),i(this,`notifyListeners`,()=>{if(this.updateQueue.length>0)Mv.set(ES,e=>({status:`loading`,libraryItems:this.currLibraryItems,isInitialized:e.isInitialized}));else{Mv.set(ES,{status:`loaded`,libraryItems:this.currLibraryItems,isInitialized:!0});try{let e=this.prevLibraryItems;this.prevLibraryItems=DS(this.currLibraryItems);let t=DS(this.currLibraryItems);this.app.props.onLibraryChange?.(t),TS.trigger(AS(e,t),t)}catch(e){console.error(e)}}}),i(this,`destroy`,()=>{this.updateQueue=[],this.currLibraryItems=[],Mv.set(bS,new Map)}),i(this,`resetLibrary`,()=>this.setLibrary([])),i(this,`getLatestLibrary`,()=>new Promise(async e=>{try{let t=await(this.getLastUpdateTask()||this.currLibraryItems);this.updateQueue.length>0?e(this.getLatestLibrary()):e(DS(t))}catch{return e(this.currLibraryItems)}})),i(this,`updateLibrary`,async({libraryItems:e,prompt:t=!1,merge:n=!1,openLibraryMenu:r=!1,defaultStatus:i=`unpublished`})=>(r&&this.app.setState({openSidebar:{name:Bs.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 Mo(o,i):dc(o,i),!t||window.confirm(J(`alerts.confirmAddLibrary`,{numShapes:s.length}))?(t&&this.app.focusContainer(),r(n?kS(this.currLibraryItems,s):s)):a(new ai)}catch(e){a(e)}})))),i(this,`setLibrary`,e=>{let t=new Promise(async(t,n)=>{try{await this.getLastUpdateTask(),typeof e==`function`&&(e=e(this.currLibraryItems)),this.currLibraryItems=DS(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}},MS=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}=ao(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}=ao(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}=ao(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},NS=class e{constructor(e){i(this,`adapter`),this.adapter=e}static async getLibraryItems(t,n,r=!0){let i=()=>new Promise(async(e,r)=>{try{e(dc((await t.load({source:n}))?.libraryItems||[],`published`))}catch(e){r(e)}});return r?e.queue.push(i):i()}getLibraryItems(t){return e.getLibraryItems(this.adapter,t,!1)}};i(NS,`queue`,new wS),i(NS,`run`,async(e,t)=>{let n=new NS(e);return NS.queue.push(()=>t(n))});var PS={Row:(0,K.forwardRef)(({children:e,gap:t,align:n,justifyContent:r,className:i,style:a},o)=>(0,q.jsx)(`div`,{className:L(`Stack Stack_horizontal`,i),style:{"--gap":t,alignItems:n,justifyContent:r,...a},ref:o,children:e})),Col:(0,K.forwardRef)(({children:e,gap:t,align:n,justifyContent:r,className:i,style:a},o)=>(0,q.jsx)(`div`,{className:L(`Stack Stack_vertical`,i),style:{"--gap":t,justifyItems:n,justifyContent:r,...a},ref:o,children:e}))},FS=({theme:e,id:t,libraryReturnUrl:n})=>{let i=n||window.location.origin+window.location.pathname;return(0,q.jsx)(`a`,{className:`library-menu-browse-button`,href:`${r.VITE_APP_LIBRARY_URL}?target=${window.name||`_blank`}&referrer=${i}&useHash=true&token=${t}&theme=${e}&version=${Ac.excalidrawLibrary}`,target:`_excalidraw_libraries`,children:J(`labels.libraries`)})},IS=({libraryReturnUrl:e,theme:t,id:n,style:r,children:i,className:a})=>(0,q.jsxs)(`div`,{className:L(`library-menu-control-buttons`,a),style:r,children:[(0,q.jsx)(FS,{id:n,libraryReturnUrl:e,theme:t}),i]}),LS=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,RS=/{{([\w-]+)}}/,zS=/<([\w-]+)>/,BS=/<\/([\w-]+)>/,VS=(e,t)=>{let n=[{name:``,children:[]}];return e.split(LS).filter(Boolean).forEach(r=>{let i=r.match(zS),a=r.match(BS),o=r.match(RS);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=K.createElement(K.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},HS=({i18nKey:e,children:t,...n})=>{let{t:r}=Wv();return K.createElement(K.Fragment,{},...VS(r(e),n))},US=({label:e,onClick:t,className:n,children:r,actionType:i,type:a=`button`,isLoading:o,...s})=>(0,q.jsxs)(`button`,{className:L(`Dialog__action-button`,i?`Dialog__action-button--${i}`:``,n),type:a,"aria-label":e,onClick:t,...s,children:[r&&(0,q.jsx)(`div`,{style:o?{visibility:`hidden`}:{},children:r}),(0,q.jsx)(`div`,{style:o?{visibility:`hidden`}:{},children:e}),o&&(0,q.jsx)(`div`,{style:{position:`absolute`,inset:0},children:(0,q.jsx)(Gv,{})})]}),WS=e=>{let{onConfirm:t,onCancel:n,children:r,confirmText:i=J(`buttons.confirm`),cancelText:a=J(`buttons.cancel`),className:o=``,...s}=e,c=jk(),l=Ov(xC),{container:u}=Ok();return(0,q.jsxs)(OC,{onCloseRequest:n,size:`small`,...s,className:`confirm-dialog ${o}`,children:[r,(0,q.jsxs)(`div`,{className:`confirm-dialog-buttons`,children:[(0,q.jsx)(US,{label:a,onClick:()=>{c({openMenu:null}),l(!1),(0,Ju.flushSync)(()=>{n()}),u?.focus()}}),(0,q.jsx)(US,{label:i,onClick:()=>{c({openMenu:null}),l(!1),(0,Ju.flushSync)(()=>{t()}),u?.focus()},actionType:`danger`})]})]})},GS=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}}};i(GS,`set`,(e,t)=>{try{return window.localStorage.setItem(e,JSON.stringify(t)),!0}catch(e){return console.warn(`localStorage.setItem error: ${e.message}`),!1}}),i(GS,`delete`,e=>{try{window.localStorage.removeItem(e)}catch(e){console.warn(`localStorage.removeItem error: ${e.message}`)}});var KS=async e=>{let t=Jn(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=As.white,r.fillRect(0,0,n.width,n.height);for(let[t,n]of e.entries()){let e=await es({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=As.gray[4],r.strokeRect(s+8/2,o+8/2,136,136)}return await re(new File([await zo(n)],`preview`,{type:de.png}),{outputType:de.jpg,maxWidthOrHeight:5e3})},qS=({libItem:e,appState:t,index:n,onChange:r,onRemove:i})=>{let a=(0,K.useRef)(null),o=(0,K.useRef)(null);return(0,K.useEffect)(()=>{let n=a.current;n&&(async()=>{n.innerHTML=(await $s({elements:e.elements,appState:{...t,viewBackgroundColor:As.white,exportBackground:!0},files:null,skipInliningFonts:!0})).outerHTML})()},[e.elements,t]),(0,q.jsxs)(`div`,{className:`single-library-item`,children:[e.status===`published`&&(0,q.jsx)(`span`,{className:`single-library-item-status`,children:J(`labels.statusPublished`)}),(0,q.jsx)(`div`,{ref:a,className:`single-library-item__svg`}),(0,q.jsx)(Y,{"aria-label":J(`buttons.remove`),type:`button`,icon:Us,className:`single-library-item--remove`,onClick:i.bind(null,e.id),title:J(`buttons.remove`)}),(0,q.jsxs)(`div`,{style:{display:`flex`,margin:`0.8rem 0`,width:`100%`,fontSize:`14px`,fontWeight:500,flexDirection:`column`},children:[(0,q.jsxs)(`label`,{style:{display:`flex`,justifyContent:`space-between`,flexDirection:`column`},children:[(0,q.jsxs)(`div`,{style:{padding:`0.5em 0`},children:[(0,q.jsx)(`span`,{style:{fontWeight:500,color:As.gray[6]},children:J(`publishDialog.itemName`)}),(0,q.jsx)(`span`,{"aria-hidden":`true`,className:`required`,children:`*`})]}),(0,q.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,q.jsx)(`span`,{className:`error`,children:e.error})]})]})},JS=({onClose:e,libraryItems:t,appState:n,onSuccess:i,onError:a,updateItemsInStorage:o,onRemove:s})=>{let[c,l]=(0,K.useState)({authorName:``,githubHandle:``,name:``,description:``,twitterHandle:``,website:``}),[u,d]=(0,K.useState)(!1);(0,K.useEffect)(()=>{let e=GS.get(al.PUBLISH_LIBRARY);e&&l(e)},[]);let[f,p]=(0,K.useState)(t.slice());(0,K.useEffect)(()=>{p(t.slice())},[t]);let m=e=>{l({...c,[e.target.name]:e.target.value})},h=async e=>{e.preventDefault(),d(!0);let t=[],n=!1;if(f.forEach(e=>{let r=``;e.name||(r=J(`publishDialog.errors.required`),n=!0),t.push({...e,error:r})}),n){p(t),d(!1);return}let o=await KS(f),s={type:Vo.excalidrawLibrary,version:Ac.excalidrawLibrary,source:Rr,libraryItems:f},l=JSON.stringify(s,null,2),u=new Blob([l],{type:`application/json`}),m=new FormData;m.append(`excalidrawLib`,u),m.append(`previewImage`,o),m.append(`previewImageType`,o.type),m.append(`title`,c.name),m.append(`authorName`,c.authorName),m.append(`githubHandle`,c.githubHandle),m.append(`name`,c.name),m.append(`description`,c.description),m.append(`twitterHandle`,c.twitterHandle),m.append(`website`,c.website),fetch(`${r.VITE_APP_LIBRARY_BACKEND}/submit`,{method:`post`,body:m}).then(e=>e.ok?e.json().then(({url:e})=>{GS.delete(al.PUBLISH_LIBRARY),i({url:e,authorName:c.authorName,items:f})}):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),a(e),d(!1)}).catch(e=>{console.error(e),a(e),d(!1)})},g=()=>{let e=[];return f.forEach((t,r)=>{e.push((0,q.jsx)(`div`,{className:`single-library-item-wrapper`,children:(0,q.jsx)(qS,{libItem:t,appState:n,index:r,onChange:(e,t)=>{let n=f.slice();n[t].name=e,p(n)},onRemove:s})},r))}),(0,q.jsx)(`div`,{className:`selected-library-items`,children:e})},_=(0,K.useCallback)(()=>{o(f),GS.set(al.PUBLISH_LIBRARY,c),e()},[f,e,o,c]),v=!!t.length,y=t.some(e=>e.status===`published`);return(0,q.jsx)(OC,{onCloseRequest:_,title:J(`publishDialog.title`),className:`publish-library`,children:v?(0,q.jsxs)(`form`,{onSubmit:h,children:[(0,q.jsx)(`div`,{className:`publish-library-note`,children:(0,q.jsx)(HS,{i18nKey:`publishDialog.noteDescription`,link:e=>(0,q.jsx)(`a`,{href:`https://libraries.excalidraw.com`,target:`_blank`,rel:`noopener noreferrer`,children:e})})}),(0,q.jsx)(`span`,{className:`publish-library-note`,children:(0,q.jsx)(HS,{i18nKey:`publishDialog.noteGuidelines`,link:e=>(0,q.jsx)(`a`,{href:`https://github.com/excalidraw/excalidraw-libraries#guidelines`,target:`_blank`,rel:`noopener noreferrer`,children:e})})}),(0,q.jsx)(`div`,{className:`publish-library-note`,children:J(`publishDialog.noteItems`)}),y&&(0,q.jsx)(`span`,{className:`publish-library-note publish-library-warning`,children:J(`publishDialog.republishWarning`)}),g(),(0,q.jsxs)(`div`,{className:`publish-library__fields`,children:[(0,q.jsxs)(`label`,{children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`span`,{children:J(`publishDialog.libraryName`)}),(0,q.jsx)(`span`,{"aria-hidden":`true`,className:`required`,children:`*`})]}),(0,q.jsx)(`input`,{type:`text`,name:`name`,required:!0,value:c.name,onChange:m,placeholder:J(`publishDialog.placeholder.libraryName`)})]}),(0,q.jsxs)(`label`,{style:{alignItems:`flex-start`},children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`span`,{children:J(`publishDialog.libraryDesc`)}),(0,q.jsx)(`span`,{"aria-hidden":`true`,className:`required`,children:`*`})]}),(0,q.jsx)(`textarea`,{name:`description`,rows:4,required:!0,value:c.description,onChange:m,placeholder:J(`publishDialog.placeholder.libraryDesc`)})]}),(0,q.jsxs)(`label`,{children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`span`,{children:J(`publishDialog.authorName`)}),(0,q.jsx)(`span`,{"aria-hidden":`true`,className:`required`,children:`*`})]}),(0,q.jsx)(`input`,{type:`text`,name:`authorName`,required:!0,value:c.authorName,onChange:m,placeholder:J(`publishDialog.placeholder.authorName`)})]}),(0,q.jsxs)(`label`,{children:[(0,q.jsx)(`span`,{children:J(`publishDialog.githubUsername`)}),(0,q.jsx)(`input`,{type:`text`,name:`githubHandle`,value:c.githubHandle,onChange:m,placeholder:J(`publishDialog.placeholder.githubHandle`)})]}),(0,q.jsxs)(`label`,{children:[(0,q.jsx)(`span`,{children:J(`publishDialog.twitterUsername`)}),(0,q.jsx)(`input`,{type:`text`,name:`twitterHandle`,value:c.twitterHandle,onChange:m,placeholder:J(`publishDialog.placeholder.twitterHandle`)})]}),(0,q.jsxs)(`label`,{children:[(0,q.jsx)(`span`,{children:J(`publishDialog.website`)}),(0,q.jsx)(`input`,{type:`text`,name:`website`,pattern:`https?://.+`,title:J(`publishDialog.errors.website`),value:c.website,onChange:m,placeholder:J(`publishDialog.placeholder.website`)})]}),(0,q.jsx)(`span`,{className:`publish-library-note`,children:(0,q.jsx)(HS,{i18nKey:`publishDialog.noteLicense`,link:e=>(0,q.jsx)(`a`,{href:`https://github.com/excalidraw/excalidraw-libraries/blob/main/LICENSE`,target:`_blank`,rel:`noopener noreferrer`,children:e})})})]}),(0,q.jsxs)(`div`,{className:`publish-library__buttons`,children:[(0,q.jsx)(US,{label:J(`buttons.cancel`),onClick:_,"data-testid":`cancel-clear-canvas-button`}),(0,q.jsx)(US,{type:`submit`,label:J(`buttons.submit`),actionType:`primary`,isLoading:u})]})]}):(0,q.jsx)(`p`,{style:{padding:`1em`,textAlign:`center`,fontWeight:500},children:J(`publishDialog.atleastOneLibItem`)})})},YS=({className:e=``,children:t,onToggle:n,title:r,...i})=>{let a=Dk();return(0,q.jsx)(`button`,{"data-prevent-outside-click":!0,className:L(`dropdown-menu-button ${e}`,`zen-mode-transition`,{"dropdown-menu-button--mobile":a.editor.isMobile}).trim(),onClick:n,type:`button`,"data-testid":`dropdown-menu-button`,title:r,...i,children:t})},XS=YS;YS.displayName=`DropdownMenuTrigger`;var ZS=()=>(0,q.jsx)(`div`,{style:{height:`1px`,backgroundColor:`var(--default-border-color)`,margin:`.5rem 0`}}),QS=ZS;ZS.displayName=`DropdownMenuSeparator`;var $S=({children:e,onClickOutside:t,className:n=``,onSelect:r,style:i})=>{let a=Dk(),o=(0,K.useRef)(null),s=Ky({onClickOutside:t});Gy(o,()=>{s.onClickOutside?.()}),(0,K.useEffect)(()=>{let e=e=>{e.key===E.ESCAPE&&(e.stopImmediatePropagation(),s.onClickOutside?.())},t={capture:!0};return document.addEventListener(`keydown`,e,t),()=>{document.removeEventListener(`keydown`,e,t)}},[s]);let c=L(`dropdown-menu ${n}`,{"dropdown-menu--mobile":a.editor.isMobile}).trim();return(0,q.jsx)(fb.Provider,{value:{onSelect:r},children:(0,q.jsx)(`div`,{ref:o,className:c,style:i,"data-testid":`dropdown-menu`,children:a.editor.isMobile?(0,q.jsx)(PS.Col,{className:`dropdown-menu-container`,children:e}):(0,q.jsx)(Xy,{className:`dropdown-menu-container`,padding:2,style:{zIndex:2},children:e})})})};$S.displayName=`DropdownMenuContent`;var eC=$S,tC=({icon:e,shortcut:t,href:n,children:r,onSelect:i,className:a=``,selected:o,rel:s=`noreferrer`,...c})=>{let l=mb(c.onClick,i);return(0,q.jsx)(`a`,{...c,href:n,target:`_blank`,rel:`noreferrer`,className:pb(a,o),title:c.title??c[`aria-label`],onClick:l,children:(0,q.jsx)(hb,{icon:e,shortcut:t,children:r})})},nC=tC;tC.displayName=`DropdownMenuItemLink`;var rC=({children:e,className:t=``,selected:n,...r})=>(0,q.jsx)(`div`,{...r,className:`dropdown-menu-item-base dropdown-menu-item-custom ${t} ${n?`dropdown-menu-item--selected`:``}`.trim(),children:e}),iC=e=>K.Children.toArray(e).find(e=>K.isValidElement(e)&&typeof e.type!=`string`&&e?.type.displayName&&e.type.displayName===`DropdownMenuTrigger`)||null,aC=e=>K.Children.toArray(e).find(e=>K.isValidElement(e)&&typeof e.type!=`string`&&e?.type.displayName&&e.type.displayName===`DropdownMenuContent`)||null,oC=({children:e,open:t})=>{let n=iC(e),r=aC(e);return(0,q.jsxs)(q.Fragment,{children:[n,t&&r]})};oC.Trigger=XS,oC.Content=eC,oC.Item=yb,oC.ItemLink=nC,oC.ItemCustom=rC,oC.Group=db,oC.Separator=QS;var Z=oC;oC.displayName=`DropdownMenu`;var sC=(e,t)=>e.filter(e=>t.includes(e.id)),cC=({setAppState:e,selectedItems:t,library:n,onRemoveFromLibrary:r,resetLibrary:i,onSelectItems:a,appState:o,className:s})=>{let[c]=Dv(ES),[l,u]=Dv(xC),d=()=>{let e=t.length?J(`alerts.removeItemsFromsLibrary`,{count:t.length}):J(`alerts.resetLibrary`);return(0,q.jsx)(WS,{onConfirm:()=>{t.length?r():i(),p(!1)},onCancel:()=>{p(!1)},title:t.length?J(`confirmDialog.removeItemsFromLib`):J(`confirmDialog.resetLibrary`),children:(0,q.jsx)(`p`,{children:e})})},[f,p]=(0,K.useState)(!1),m=!!t.length,h=m?c.libraryItems.filter(e=>t.includes(e.id)):c.libraryItems,g=J(m?`buttons.remove`:`buttons.resetLibrary`),[_,v]=(0,K.useState)(!1),[y,b]=(0,K.useState)(null),S=(0,K.useCallback)(()=>(0,q.jsxs)(OC,{onCloseRequest:()=>b(null),title:J(`publishSuccessDialog.title`),className:`publish-library-success`,size:`small`,children:[(0,q.jsx)(`p`,{children:(0,q.jsx)(HS,{i18nKey:`publishSuccessDialog.content`,authorName:y.authorName,link:e=>(0,q.jsx)(`a`,{href:y?.url,target:`_blank`,rel:`noopener noreferrer`,children:e})})}),(0,q.jsx)(Y,{type:`button`,title:J(`buttons.close`),"aria-label":J(`buttons.close`),label:J(`buttons.close`),onClick:()=>b(null),"data-testid":`publish-library-success-close`,className:`publish-library-success-close`})]}),[b,y]),C=(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,q.jsxs)(`div`,{className:L(`library-menu-dropdown-container`,s),children:[(0,q.jsxs)(Z,{open:l,children:[(0,q.jsx)(Z.Trigger,{onToggle:()=>u(!l),children:er}),(0,q.jsxs)(Z.Content,{onClickOutside:()=>u(!1),onSelect:()=>u(!1),className:`library-menu`,children:[!m&&(0,q.jsx)(Z.Item,{onSelect:async()=>{try{await n.updateLibrary({libraryItems:Ie({description:`Excalidraw library files`}),merge:!0,openLibraryMenu:!0})}catch(t){if(t?.name===`AbortError`){console.warn(t);return}e({errorMessage:J(`errors.importLibraryError`)})}},icon:gl,"data-testid":`lib-dropdown--load`,children:J(`buttons.load`)}),!!h.length&&(0,q.jsx)(Z.Item,{onSelect:async()=>{Ns(m?h:await n.getLatestLibrary()).catch(x).catch(t=>{e({errorMessage:t.message})})},icon:ss,"data-testid":`lib-dropdown--export`,children:J(`buttons.export`)}),!!h.length&&(0,q.jsx)(Z.Item,{onSelect:()=>p(!0),icon:ge,children:g}),m&&(0,q.jsx)(Z.Item,{icon:si,onSelect:()=>v(!0),"data-testid":`lib-dropdown--remove`,children:J(`buttons.publishLibrary`)})]})]}),t.length>0&&(0,q.jsx)(`div`,{className:`library-actions-counter`,children:t.length}),f&&d(),_&&(0,q.jsx)(JS,{onClose:()=>v(!1),libraryItems:sC(c.libraryItems,t),appState:o,onSuccess:e=>C(e,c.libraryItems),onError:e=>window.alert(e),updateItemsInStorage:()=>n.setLibrary(c.libraryItems),onRemove:e=>a(t.filter(t=>t!==e))}),y&&S()]})},lC=({selectedItems:e,onSelectItems:t,className:n})=>{let{library:r}=Tk(),{clearLibraryCache:i,deleteItemsFromLibraryCache:a}=CS(),o=Uy(),s=jk(),[c]=Dv(ES),l=async n=>{let i=n.filter(t=>!e.includes(t.id));r.setLibrary(i).catch(()=>{s({errorMessage:J(`alerts.errorRemovingFromLibrary`)})}),a(e),t([])};return(0,q.jsx)(cC,{appState:o,setAppState:s,selectedItems:e,onSelectItems:t,library:r,onRemoveFromLibrary:()=>l(c.libraryItems),resetLibrary:()=>{r.resetLibrary(),i()},className:n})},uC=(0,K.memo)(({id:e,elements:t,isPending:n,onClick:r,selected:i,onToggle:a,onDrag:o,svgCache:s})=>{let c=(0,K.useRef)(null),l=SS(e,t,s);(0,K.useEffect)(()=>{let e=c.current;if(e)return l&&(e.innerHTML=l.outerHTML),()=>{e.innerHTML=``}},[l]);let[u,d]=(0,K.useState)(!1),f=Dk().editor.isMobile,p=n&&(0,q.jsx)(`div`,{className:`library-unit__adder`,children:Aa});return(0,q.jsxs)(`div`,{className:L(`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,q.jsx)(`div`,{className:L(`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,q.jsx)(rx,{checked:i,onChange:(t,n)=>a(e,n),className:`library-unit__checkbox`})]})}),dC=()=>(0,q.jsx)(`div`,{className:`library-unit library-unit--skeleton`});function fC(){return[!1,(0,K.useCallback)(e=>e(),[])]}var pC=K.useTransition||fC,mC=({children:e})=>(0,q.jsx)(`div`,{className:`library-menu-items-container__grid`,children:e}),hC=(0,K.memo)(({items:e,onItemSelectToggle:t,onItemDrag:n,isItemSelected:r,onClick:i,svgCache:a,itemsRenderedPerBatch:o})=>{let[,s]=pC(),[c,l]=(0,K.useState)(0);return(0,K.useEffect)(()=>{c<e.length&&s(()=>{l(c+o)})},[c,e.length,s,o]),(0,q.jsx)(q.Fragment,{children:e.map((e,o)=>o<c?(0,q.jsx)(uC,{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,q.jsx)(dC,{},o))})}),gC=au(0),_C=e=>{let[t,n]=Dv(gC);return(0,K.useEffect)(()=>{let{current:t}=e;if(!t)return;let r=(0,Ig.default)(()=>{let{scrollTop:e}=t;n(e)},200);return t.addEventListener(`scroll`,r),()=>{r.cancel(),t.removeEventListener(`scroll`,r)}},[e,n]),t},vC=17,yC=64;function bC({isLoading:e,libraryItems:t,onAddToLibrary:n,onInsertLibraryItems:r,pendingElements:i,theme:a,id:o,libraryReturnUrl:s,onSelectItems:c,selectedItems:l}){let u=(0,K.useRef)(null),d=_C(u);(0,K.useEffect)(()=>{d>0&&u.current?.scrollTo(0,d)},[]);let{svgCache:f}=CS(),p=(0,K.useMemo)(()=>t.filter(e=>e.status!==`published`),[t]),m=(0,K.useMemo)(()=>t.filter(e=>e.status===`published`),[t]),h=!t.length&&!i.length,g=!i.length&&!p.length&&!m.length,[_,v]=(0,K.useState)(null),y=(0,K.useCallback)((e,t)=>{let n=!l.includes(e),r=[...p,...m];if(n){if(t.shiftKey&&_){let t=r.findIndex(e=>e.id===_),n=r.findIndex(t=>t.id===e);if(t===-1||n===-1){c([...l,e]);return}let i=k(l);c(r.reduce((e,r,a)=>((a>=t&&a<=n||i.has(r.id))&&e.push(r.id),e),[]))}else c([...l,e]);v(e)}else v(null),c(l.filter(t=>t!==e))},[_,c,m,l,p]),b=(0,K.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:Mn(e.elements,{randomizeSeed:!0})}))},[t,l]),x=(0,K.useCallback)((e,t)=>{t.dataTransfer.setData(de.excalidrawlib,rt(b(e)))},[b]),S=(0,K.useCallback)(e=>e?l.includes(e):!1,[l]),C=(0,K.useCallback)(()=>{n(i)},[i,n]),w=(0,K.useCallback)(e=>{e&&r(b(e))},[b,r]),T=f.size>=t.length?yC:vC;return(0,q.jsxs)(`div`,{className:`library-menu-items-container`,style:i.length||p.length||m.length?{justifyContent:`flex-start`}:{borderBottom:0},children:[!g&&(0,q.jsx)(lC,{selectedItems:l,onSelectItems:c,className:`library-menu-dropdown-container--in-heading`}),(0,q.jsxs)(PS.Col,{className:`library-menu-items-container__items`,align:`start`,gap:1,style:{flex:m.length>0?1:`0 1 auto`,marginBottom:0},ref:u,children:[(0,q.jsxs)(q.Fragment,{children:[!g&&(0,q.jsx)(`div`,{className:`library-menu-items-container__header`,children:J(`labels.personalLib`)}),e&&(0,q.jsx)(`div`,{style:{position:`absolute`,top:`var(--container-padding-y)`,right:`var(--container-padding-x)`,transform:`translateY(50%)`},children:(0,q.jsx)(Gv,{})}),!i.length&&!p.length?(0,q.jsxs)(`div`,{className:`library-menu-items__no-items`,children:[(0,q.jsx)(`div`,{className:`library-menu-items__no-items__label`,children:J(`library.noItems`)}),(0,q.jsx)(`div`,{className:`library-menu-items__no-items__hint`,children:m.length>0?J(`library.hint_emptyPrivateLibrary`):J(`library.hint_emptyLibrary`)})]}):(0,q.jsxs)(mC,{children:[i.length>0&&(0,q.jsx)(hC,{itemsRenderedPerBatch:T,items:[{id:null,elements:i}],onItemSelectToggle:y,onItemDrag:x,onClick:C,isItemSelected:S,svgCache:f}),(0,q.jsx)(hC,{itemsRenderedPerBatch:T,items:p,onItemSelectToggle:y,onItemDrag:x,onClick:w,isItemSelected:S,svgCache:f})]})]}),(0,q.jsxs)(q.Fragment,{children:[(m.length>0||i.length>0||p.length>0)&&(0,q.jsx)(`div`,{className:`library-menu-items-container__header library-menu-items-container__header--excal`,children:J(`labels.excalidrawLib`)}),m.length>0?(0,q.jsx)(mC,{children:(0,q.jsx)(hC,{itemsRenderedPerBatch:T,items:m,onItemSelectToggle:y,onItemDrag:x,onClick:w,isItemSelected:S,svgCache:f})}):p.length>0?(0,q.jsx)(`div`,{style:{margin:`1rem 0`,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,width:`100%`,fontSize:`.9rem`},children:J(`library.noItems`)}):null]}),h&&(0,q.jsx)(IS,{style:{padding:`16px 0`,width:`100%`},id:o,libraryReturnUrl:s,theme:a,children:(0,q.jsx)(lC,{selectedItems:l,onSelectItems:c})})]})]})}var xC=au(!1),SC=({children:e})=>(0,q.jsx)(`div`,{className:`layer-ui__library`,children:e}),CC=(0,K.memo)(({onInsertLibraryItems:e,pendingElements:t,onAddToLibrary:n,setAppState:r,libraryReturnUrl:i,library:a,id:o,theme:s,selectedItems:c,onSelectItems:l})=>{let[u]=Dv(ES),d=(0,K.useCallback)(e=>{(async(e,t)=>{X(`element`,`addToLibrary`,`ui`);for(let t of ro)if(e.some(e=>e.type===t))return r({errorMessage:J(`errors.libraryElementTypeError.${t}`)});let i=[{status:`unpublished`,elements:e,id:Ro(),created:Date.now()},...t];n(),a.setLibrary(i).catch(()=>{r({errorMessage:J(`alerts.errorAddingToLibrary`)})})})(e,u.libraryItems)},[n,a,r,u.libraryItems]),f=(0,K.useMemo)(()=>u.libraryItems,[u]);if(u.status===`loading`&&!u.isInitialized)return(0,q.jsx)(SC,{children:(0,q.jsx)(`div`,{className:`layer-ui__library-message`,children:(0,q.jsxs)(`div`,{children:[(0,q.jsx)(Gv,{size:`2em`}),(0,q.jsx)(`span`,{children:J(`labels.libraryLoadingMessage`)})]})})});let p=u.libraryItems.length>0||t.length>0;return(0,q.jsxs)(SC,{children:[(0,q.jsx)(bC,{isLoading:u.status===`loading`,libraryItems:f,onAddToLibrary:d,onInsertLibraryItems:e,pendingElements:t,id:o,libraryReturnUrl:i,theme:s,onSelectItems:l,selectedItems:c}),p&&(0,q.jsx)(IS,{className:`library-menu-control-buttons--at-bottom`,style:{padding:`16px 12px 0 12px`},id:o,libraryReturnUrl:i,theme:s})]})}),wC=(e,t)=>({elements:e,pending:W(e,{selectedElementIds:t},{includeBoundTextElement:!0,includeElementsInFrames:!0}),selectedElementIds:t}),TC=(e,t)=>{let n=kk(),[r,i]=(0,K.useState)(()=>wC(n,e.selectedElementIds)),a=(0,K.useRef)(new Map);return(0,K.useEffect)(()=>{for(let e of r.pending)a.current.set(e.id,e.version)},[r.pending]),(0,K.useEffect)(()=>{t.state.cursorButton===`up`&&t.state.activeTool.type===`selection`&&i(r=>{if(!Xt(r.selectedElementIds,e.selectedElementIds))return a.current.clear(),wC(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 wC(n,e.selectedElementIds)}return r})},[t,t.state.cursorButton,t.state.activeTool.type,e.selectedElementIds,n]),r.pending},EC=(0,K.memo)(()=>{let e=Tk(),{onInsertElements:t}=e,n=Ek(),r=Uy(),i=jk(),[a,o]=(0,K.useState)([]),s=(0,K.useMemo)(()=>e.library,[e.library]);return(0,q.jsx)(CC,{pendingElements:TC(r,e),onInsertLibraryItems:(0,K.useCallback)(e=>{t(MS(e))},[t]),onAddToLibrary:(0,K.useCallback)(()=>{i({selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null})},[i]),setAppState:i,libraryReturnUrl:n.libraryReturnUrl,library:s,id:e.id,theme:r.theme,selectedItems:a,onSelectItems:o})});function DC(e){if(e&&typeof e==`number`)return e;switch(e){case`small`:return 550;case`wide`:return 1024;default:return 800}}var OC=e=>{let[t,n]=vS(),[r]=(0,K.useState)(document.activeElement),{id:i}=Ok(),a=Dk().viewport.isMobile;(0,K.useEffect)(()=>{if(!t)return;let n=m(t);setTimeout(()=>{n.length>0&&e.autofocus!==!1&&(n[1]||n[0]).focus()});let r=e=>{if(e.key===E.TAB){let n=m(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=jk(),s=Ov(xC),c=()=>{o({openMenu:null}),s(!1),r.focus(),e.onCloseRequest()};return(0,q.jsx)(yS,{className:L(`Dialog`,e.className,{"Dialog--fullscreen":a}),labelledBy:`dialog-title`,maxWidth:DC(e.size),onCloseRequest:c,closeOnClickOutside:e.closeOnClickOutside,children:(0,q.jsxs)(Xy,{ref:n,children:[e.title&&(0,q.jsx)(`h2`,{id:`${i}-dialog-title`,className:`Dialog__title`,children:(0,q.jsx)(`span`,{className:`Dialog__titleContent`,children:e.title})}),a&&(0,q.jsx)(`button`,{className:`Dialog__close`,onClick:c,title:J(`buttons.close`),"aria-label":J(`buttons.close`),type:`button`,children:Us}),(0,q.jsx)(`div`,{className:`Dialog__content`,children:e.children})]})})},kC=({type:e=`button`,onSelect:t,selected:n,children:r,className:i=``,...a})=>(0,q.jsx)(`button`,{onClick:Rl(a.onClick,e=>{t()}),type:e,className:L(`excalidraw-button`,i,{selected:n}),...a,children:r}),AC=(0,K.forwardRef)(({onChange:e,label:t,fullWidth:n,placeholder:r,readonly:i,selectOnRender:a,onKeyDown:o,isRedacted:s=!1,icon:c,className:l,...u},d)=>{let f=(0,K.useRef)(null);(0,K.useImperativeHandle)(d,()=>f.current),(0,K.useLayoutEffect)(()=>{a&&(f.current?.focus(),f.current?.select())},[a]);let[p,m]=(0,K.useState)(!1);return(0,q.jsxs)(`div`,{className:L(`ExcTextField`,l,{"ExcTextField--fullWidth":n,"ExcTextField--hasIcon":!!c}),onClick:()=>{f.current?.focus()},children:[c,t&&(0,q.jsx)(`div`,{className:`ExcTextField__label`,children:t}),(0,q.jsxs)(`div`,{className:L(`ExcTextField__input`,{"ExcTextField__input--readonly":i}),children:[(0,q.jsx)(`input`,{className:L({"is-redacted":`value`in u&&u.value&&s&&!p}),readOnly:i,value:`value`in u?u.value:void 0,defaultValue:`defaultValue`in u?u.defaultValue:void 0,placeholder:r,ref:f,onChange:t=>e?.(t.target.value),onKeyDown:o}),s&&(0,q.jsx)(kC,{onSelect:()=>m(!p),style:{border:0,userSelect:`none`},children:p?Fe:Wl})]})]})}),jC={toggleTheme:[M(`Shift+Alt+D`)],saveScene:[M(`CtrlOrCmd+S`)],loadScene:[M(`CtrlOrCmd+O`)],clearCanvas:[M(`CtrlOrCmd+Delete`)],imageExport:[M(`CtrlOrCmd+Shift+E`)],commandPalette:[M(`CtrlOrCmd+/`),M(`CtrlOrCmd+Shift+P`)],cut:[M(`CtrlOrCmd+X`)],copy:[M(`CtrlOrCmd+C`)],paste:[M(`CtrlOrCmd+V`)],copyStyles:[M(`CtrlOrCmd+Alt+C`)],pasteStyles:[M(`CtrlOrCmd+Alt+V`)],selectAll:[M(`CtrlOrCmd+A`)],deleteSelectedElements:[M(`Delete`)],duplicateSelection:[M(`CtrlOrCmd+D`),M(`Alt+${J(`helpDialog.drag`)}`)],sendBackward:[M(`CtrlOrCmd+[`)],bringForward:[M(`CtrlOrCmd+]`)],sendToBack:[M(Ri?`CtrlOrCmd+Alt+[`:`CtrlOrCmd+Shift+[`)],bringToFront:[M(Ri?`CtrlOrCmd+Alt+]`:`CtrlOrCmd+Shift+]`)],copyAsPng:[M(`Shift+Alt+C`)],group:[M(`CtrlOrCmd+G`)],ungroup:[M(`CtrlOrCmd+Shift+G`)],gridMode:[M(`CtrlOrCmd+'`)],zenMode:[M(`Alt+Z`)],objectsSnapMode:[M(`Alt+S`)],stats:[M(`Alt+/`)],addToLibrary:[],flipHorizontal:[M(`Shift+H`)],flipVertical:[M(`Shift+V`)],viewMode:[M(`Alt+R`)],hyperlink:[M(`CtrlOrCmd+K`)],toggleElementLock:[M(`CtrlOrCmd+Shift+L`)],resetZoom:[M(`CtrlOrCmd+0`)],zoomOut:[M(`CtrlOrCmd+-`)],zoomIn:[M(`CtrlOrCmd++`)],zoomToFitSelection:[M(`Shift+3`)],zoomToFit:[M(`Shift+1`)],zoomToFitSelectionInViewport:[M(`Shift+2`)],toggleEraserTool:[M(`E`)],toggleHandTool:[M(`H`)],setFrameAsActiveTool:[M(`F`)],saveFileToDisk:[M(`CtrlOrCmd+S`)],saveToActiveFile:[M(`CtrlOrCmd+S`)],toggleShortcuts:[M(`?`)],searchMenu:[M(`CtrlOrCmd+F`)],wrapSelectionInFrame:[]},MC=(e,t=0)=>{let n=jC[e];return n&&n.length>0?n[t]||n[0]:``},NC=RegExp(`[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]`,`g`),PC=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,FC={À:`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`},IC=e=>e.replace(PC,e=>FC[e]||e).replace(NC,``),LC=K.createContext(null),RC=()=>K.useContext(LC),zC=Wu(),BC=()=>K.useMemo(()=>({MainMenuTunnel:Yg(),WelcomeScreenMenuHintTunnel:Yg(),WelcomeScreenToolbarHintTunnel:Yg(),WelcomeScreenHelpHintTunnel:Yg(),WelcomeScreenCenterTunnel:Yg(),FooterCenterTunnel:Yg(),DefaultSidebarTriggerTunnel:Yg(),DefaultSidebarTabTriggersTunnel:Yg(),OverwriteConfirmDialogTunnel:Yg(),TTDDialogTriggerTunnel:Yg(),tunnelsJotai:zC}),[]),VC=(e,t)=>{let n=t[0]?.type||null;for(let e of t)if(e.type!==n){n=null;break}return el(e.activeTool.type)&&e.activeTool.type!==`image`&&n!==`image`&&n!==`frame`&&n!==`magicframe`||t.some(e=>el(e.type))},HC=(e,t)=>Fl(e.activeTool.type)||t.some(e=>Fl(e.type)),UC=({appState:e,elementsMap:t,renderAction:n,app:r})=>{let i=Vi(t,e),a=!1;i.length===2&&(ws(i[0])||ws(i[1]))&&(a=!0);let o=!!(e.editingTextElement||e.newElement),s=Dk(),l=document.documentElement.getAttribute(`dir`)===`rtl`,u=Fl(e.activeTool.type)&&!Rc(e.currentItemBackgroundColor)||i.some(e=>Fl(e.type)&&!Rc(e.backgroundColor)),d=i.length===1||a,f=!e.editingLinearElement&&i.length===1&&c(i[0])&&!U(i[0]),p=!e.croppingElementId&&i.length===1&&El(i[0]),m=!a&&kx(e,r);return(0,q.jsxs)(`div`,{className:`panelColumn`,children:[(0,q.jsx)(`div`,{children:VC(e,i)&&n(`changeStrokeColor`)}),HC(e,i)&&(0,q.jsx)(`div`,{children:n(`changeBackgroundColor`)}),u&&n(`changeFillStyle`),(gn(e.activeTool.type)||i.some(e=>gn(e.type)))&&n(`changeStrokeWidth`),(e.activeTool.type===`freedraw`||i.some(e=>e.type===`freedraw`))&&n(`changeStrokeShape`),(Ht(e.activeTool.type)||i.some(e=>Ht(e.type)))&&(0,q.jsxs)(q.Fragment,{children:[n(`changeStrokeStyle`),n(`changeSloppiness`)]}),(po(e.activeTool.type)||i.some(e=>po(e.type)))&&(0,q.jsx)(q.Fragment,{children:n(`changeRoundness`)}),(Se(e.activeTool.type)||i.some(e=>Se(e.type)))&&(0,q.jsx)(q.Fragment,{children:n(`changeArrowType`)}),(e.activeTool.type===`text`||i.some(I))&&(0,q.jsxs)(q.Fragment,{children:[n(`changeFontFamily`),n(`changeFontSize`),(e.activeTool.type===`text`||Ya(i,t))&&n(`changeTextAlign`)]}),Re(i,t)&&n(`changeVerticalAlign`),(ll(e.activeTool.type)||i.some(e=>ll(e.type)))&&(0,q.jsx)(q.Fragment,{children:n(`changeArrowhead`)}),n(`changeOpacity`),(0,q.jsxs)(`fieldset`,{children:[(0,q.jsx)(`legend`,{children:J(`labels.layers`)}),(0,q.jsxs)(`div`,{className:`buttonList`,children:[n(`sendToBack`),n(`sendBackward`),n(`bringForward`),n(`bringToFront`)]})]}),m&&!a&&(0,q.jsxs)(`fieldset`,{children:[(0,q.jsx)(`legend`,{children:J(`labels.align`)}),(0,q.jsxs)(`div`,{className:`buttonList`,children:[l?(0,q.jsxs)(q.Fragment,{children:[n(`alignRight`),n(`alignHorizontallyCentered`),n(`alignLeft`)]}):(0,q.jsxs)(q.Fragment,{children:[n(`alignLeft`),n(`alignHorizontallyCentered`),n(`alignRight`)]}),i.length>2&&n(`distributeHorizontally`),(0,q.jsx)(`div`,{style:{flexBasis:`100%`,height:0}}),(0,q.jsxs)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:`.5rem`,marginTop:`-0.5rem`},children:[n(`alignTop`),n(`alignVerticallyCentered`),n(`alignBottom`),i.length>2&&n(`distributeVertically`)]})]})]}),!o&&i.length>0&&(0,q.jsxs)(`fieldset`,{children:[(0,q.jsx)(`legend`,{children:J(`labels.actions`)}),(0,q.jsxs)(`div`,{className:`buttonList`,children:[!s.editor.isMobile&&n(`duplicateSelection`),!s.editor.isMobile&&n(`deleteSelectedElements`),n(`group`),n(`ungroup`),d&&n(`hyperlink`),p&&n(`cropEditor`),f&&n(`toggleLinearEditor`)]})]})]})},WC=({activeTool:e,appState:t,app:n,UIOptions:r})=>{let[i,a]=(0,K.useState)(!1),o=e.type===`frame`,s=e.type===`laser`,c=e.type===`embeddable`,{TTDDialogTriggerTunnel:l}=RC();return(0,q.jsxs)(q.Fragment,{children:[Sc.map(({value:i,icon:a,key:o,numericKey:s,fillable:c},l)=>{if(r.tools?.[i]===!1)return null;let u=J(`toolBar.${i}`),d=o&&Ji(typeof o==`string`?o:o[0]),f=d?`${d} ${J(`helpDialog.or`)} ${s}`:`${s}`;return(0,q.jsx)(Y,{className:L(`Shape`,{fillable:c}),type:`radio`,icon:a,checked:e.type===i,name:`editor-current-shape`,title:`${Ji(u)} \u2014 ${f}`,keyBindingLabel:s||d,"aria-label":Ji(u),"aria-keyshortcuts":f,"data-testid":`toolbar-${i}`,onPointerDown:({pointerType:e})=>{!t.penDetected&&e===`pen`&&n.togglePenMode(!0)},onChange:({pointerType:e})=>{t.activeTool.type!==i&&X(`toolbar`,i,`ui`),i===`image`?n.setActiveTool({type:i,insertOnCanvasDirectly:e!==`mouse`}):n.setActiveTool({type:i})}},i)}),(0,q.jsx)(`div`,{className:`App-toolbar__divider`}),(0,q.jsxs)(Z,{open:i,children:[(0,q.jsx)(Z.Trigger,{className:L(`App-toolbar__extra-tools-trigger`,{"App-toolbar__extra-tools-trigger--selected":o||c||s&&!n.props.isCollaborating}),onToggle:()=>a(!i),title:J(`toolBar.extraTools`),children:to}),(0,q.jsxs)(Z.Content,{onClickOutside:()=>a(!1),onSelect:()=>a(!1),className:`App-toolbar__extra-tools-dropdown`,children:[(0,q.jsx)(Z.Item,{onSelect:()=>n.setActiveTool({type:`frame`}),icon:zi,shortcut:E.F.toLocaleUpperCase(),"data-testid":`toolbar-frame`,selected:o,children:J(`toolBar.frame`)}),(0,q.jsx)(Z.Item,{onSelect:()=>n.setActiveTool({type:`embeddable`}),icon:Gs,"data-testid":`toolbar-embeddable`,selected:c,children:J(`toolBar.embeddable`)}),(0,q.jsx)(Z.Item,{onSelect:()=>n.setActiveTool({type:`laser`}),icon:Vc,"data-testid":`toolbar-laser`,selected:s,shortcut:E.K.toLocaleUpperCase(),children:J(`toolBar.laser`)}),(0,q.jsx)(`div`,{style:{margin:`6px 0`,fontSize:14,fontWeight:600},children:`Generate`}),n.props.aiEnabled!==!1&&(0,q.jsx)(l.Out,{}),(0,q.jsx)(Z.Item,{onSelect:()=>n.setOpenDialog({name:`ttd`,tab:`mermaid`}),icon:mr,"data-testid":`toolbar-embeddable`,children:J(`toolBar.mermaidToExcalidraw`)}),n.props.aiEnabled!==!1&&n.plugins.diagramToCode&&(0,q.jsx)(q.Fragment,{children:(0,q.jsxs)(Z.Item,{onSelect:()=>n.onMagicframeToolSelect(),icon:Za,"data-testid":`toolbar-magicframe`,children:[J(`toolBar.magicframe`),(0,q.jsx)(Z.Item.Badge,{children:`AI`})]})})]})]})]})},GC=({renderAction:e,zoom:t})=>(0,q.jsx)(PS.Col,{gap:1,className:oo.ZOOM_ACTIONS,children:(0,q.jsxs)(PS.Row,{align:`center`,children:[e(`zoomOut`),e(`resetZoom`),e(`zoomIn`)]})}),KC=({renderAction:e,className:t})=>(0,q.jsxs)(`div`,{className:`undo-redo-buttons ${t}`,children:[(0,q.jsx)(`div`,{className:`undo-button-container`,children:(0,q.jsx)(Bb,{label:J(`buttons.undo`),children:e(`undo`)})}),(0,q.jsx)(`div`,{className:`redo-button-container`,children:(0,q.jsxs)(Bb,{label:J(`buttons.redo`),children:[` `,e(`redo`)]})})]}),qC=({actionManager:e,showExitZenModeBtn:t})=>(0,q.jsx)(`button`,{type:`button`,className:L(`disable-zen-mode`,{"disable-zen-mode--visible":t}),onClick:()=>e.executeAction(Gx),children:J(`buttons.exitZenMode`)}),JC=({renderAction:e,className:t})=>(0,q.jsx)(`div`,{className:`finalize-button ${t}`,children:e(`finalize`,{size:`small`})}),YC=e=>{let t=(0,K.useRef)({userFn:e});return t.current.userFn=e,t.current.stableFn||(t.current.stableFn=(...e)=>t.current.userFn(...e)),t.current.stableFn},XC=au(null),ZC=()=>{let[e,t]=Dv(XC),n=Mk();return e&&e===`clearCanvas`?(0,q.jsx)(WS,{onConfirm:()=>{n.executeAction(Vb),t(null)},onCancel:()=>t(null),title:J(`clearCanvasDialog.title`),children:(0,q.jsxs)(`p`,{className:`clear-canvas__content`,children:[` `,J(`alerts.clearReset`)]})}):null},QC={};o(QC,{toggleTheme:()=>$C});var $C={...Jb,category:`App`,label:`Toggle theme`,perform:({actionManager:e})=>{e.executeAction(Jb,`commandPalette`)}},ew=O({name:`copyElementLink`,label:`labels.copyElementLink`,icon:Fc,trackEvent:{category:`element`},perform:async(e,t,n,r)=>{let i=W(e,t);try{if(window.location){let n=Ca(i,t);return n?(await Jo(r.props.generateLinkForSelection?r.props.generateLinkForSelection(n.id,n.type):bc(n.id,n.type)),{appState:{toast:{message:J(`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)=>gs(W(e,t))}),tw=O({name:`linkToElement`,label:`labels.linkToElement`,icon:Tn,perform:(e,t,n,r)=>{let i=W(e,t);return i.length!==1||!gs(i)?{elements:e,appState:t,app:r,captureUpdate:j.EVENTUALLY}:{appState:{...t,openDialog:{name:`elementLinkSelector`,sourceElementId:W(e,t)[0].id}},captureUpdate:j.IMMEDIATELY}},predicate:(e,t,n,r)=>{let i=W(e,t);return t.openDialog?.name!==`elementLinkSelector`&&i.length===1&&gs(i)},trackEvent:!1}),nw=au(null),rw={app:`App`,export:`Export`,tools:`Tools`,editor:`Editor`,elements:`Elements`,links:`Links`},iw=e=>{switch(e){case rw.app:return 1;case rw.export:return 2;case rw.editor:return 3;case rw.tools:return 4;case rw.elements:return 5;case rw.links:return 6;default:return 10}},aw=({shortcut:e,className:t,children:n})=>{let r=e.replace(`++`,`+$`).split(`+`);return(0,q.jsxs)(`div`,{className:L(`shortcut`,t),children:[r.map((e,t)=>(0,q.jsx)(`div`,{className:`shortcut-wrapper`,children:(0,q.jsx)(`div`,{className:`shortcut-key`,children:e===`$`?`+`:e})},e)),(0,q.jsx)(`div`,{className:`shortcut-desc`,children:n})]})},ow=e=>!e.altKey&&e[E.CTRL_OR_CMD]&&(e.shiftKey&&e.key.toLowerCase()===E.P||e.key===E.SLASH);Object.assign(e=>{let t=Uy(),n=jk();return(0,K.useEffect)(()=>{let e=e=>{ow(e)&&(e.preventDefault(),e.stopPropagation(),n(e=>{let t=e.openDialog?.name===`commandPalette`?null:{name:`commandPalette`};return t&&X(`command_palette`,`open`,`shortcut`),{openDialog:t}}))};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},[n]),t.openDialog?.name===`commandPalette`?(0,q.jsx)(sw,{...e}):null},{defaultItems:QC});function sw({customCommandPaletteItems:e}){let t=Tk(),n=Uy(),r=jk(),i=Ek(),a=Mk(),[o,s]=Dv(nw),[c,l]=(0,K.useState)(null),u=(0,K.useRef)(null),d=Ky({uiAppState:n,customCommandPaletteItems:e,appProps:i});(0,K.useEffect)(()=>{let{uiAppState:e,customCommandPaletteItems:n,appProps:i}=d,c=n=>{let r=``;return n.label&&(r=typeof n.label==`function`?J(n.label(t.scene.getNonDeletedElements(),e,t)):J(n.label)),r},u=n=>typeof n.icon==`function`?n.icon(e,t.scene.getNonDeletedElements()):n.icon,f=[],p=(e,t,n)=>{let r={label:c(e),icon:u(e),category:t,shortcut:MC(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,mS,ew,tw].map(e=>p(e,rw.elements,(e,t)=>({...e,predicate:t.predicate?t.predicate:(e,t,n,r)=>W(e,t).length>0}))),m=[a.actions.toggleHandTool,a.actions.setFrameAsActiveTool].map(e=>p(e,rw.tools)),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=>p(e,rw.editor)),g=[a.actions.saveToActiveFile,a.actions.saveFileToDisk,a.actions.copyAsPng,a.actions.copyAsSvg].map(e=>p(e,rw.export));f=[...d,...h,{label:c(Vb),icon:u(Vb),shortcut:MC(Vb.name),category:rw.editor,keywords:[`delete`,`destroy`],viewMode:!1,perform:()=>{Mv.set(XC,`clearCanvas`)}},{label:J(`buttons.exportImage`),category:rw.export,icon:ys,shortcut:MC(`imageExport`),keywords:[`export`,`image`,`png`,`jpeg`,`svg`,`clipboard`,`picture`],perform:()=>{r({openDialog:{name:`imageExport`}})}},...g];let _=[{label:J(`toolBar.library`),category:rw.app,icon:mn,viewMode:!1,perform:()=>{e.openSidebar?r({openSidebar:null}):r({openSidebar:{name:Bs.name,tab:Bs.defaultTab}})}},{label:J(`search.title`),category:rw.app,icon:ja,viewMode:!0,perform:()=>{a.executeAction(uw)}},{label:J(`labels.changeStroke`),keywords:[`color`,`outline`],category:rw.elements,icon:Qc,viewMode:!1,predicate:(e,t)=>{let n=W(e,t);return n.length>0&&VC(t,n)},perform:()=>{r(e=>({openMenu:e.openMenu===`shape`?null:`shape`,openPopup:`elementStroke`}))}},{label:J(`labels.changeBackground`),keywords:[`color`,`fill`],icon:Qc,category:rw.elements,viewMode:!1,predicate:(e,t)=>{let n=W(e,t);return n.length>0&&HC(t,n)},perform:()=>{r(e=>({openMenu:e.openMenu===`shape`?null:`shape`,openPopup:`elementBackground`}))}},{label:J(`labels.canvasBackground`),keywords:[`color`],icon:Qc,category:rw.editor,viewMode:!1,perform:()=>{r(e=>({openMenu:e.openMenu===`canvas`?null:`canvas`,openPopup:`canvasBackground`}))}},...Sc.reduce((e,n)=>{let{value:r,icon:a,key:o,numericKey:s}=n;if(i.UIOptions.tools?.[r]===!1)return e;let c=o&&Ji(typeof o==`string`?o:o[0])||s,l={label:J(`toolBar.${r}`),category:rw.tools,shortcut:c,icon:a,keywords:[`toolbar`],viewMode:!1,perform:({event:e})=>{r===`image`?t.setActiveTool({type:r,insertOnCanvasDirectly:e.type===`keydown`}):t.setActiveTool({type:r})}};return e.push(l),e},[]),...m,{label:J(`toolBar.lock`),category:rw.tools,icon:e.activeTool.locked?Xi:Ee,shortcut:E.Q.toLocaleUpperCase(),viewMode:!1,perform:()=>{t.toggleLock()}},{label:`${J(`labels.textToDiagram`)}...`,category:rw.tools,icon:Ml,viewMode:!1,predicate:i.aiEnabled,perform:()=>{r(e=>({...e,openDialog:{name:`ttd`,tab:`text-to-diagram`}}))}},{label:`${J(`toolBar.mermaidToExcalidraw`)}...`,category:rw.tools,icon:mr,viewMode:!1,predicate:i.aiEnabled,perform:()=>{r(e=>({...e,openDialog:{name:`ttd`,tab:`mermaid`}}))}}],v=[...f,..._,...n||[]].map(e=>({...e,icon:e.icon||Gi,order:e.order??iw(e.category),haystack:`${IC(e.label.toLocaleLowerCase())} ${e.keywords?.join(` `)||``}`}));l(v),s(v.find(e=>e.label===o?.label)??null)}},[d,t,a,l,o?.label,s,r]);let[f,p]=(0,K.useState)(``),[m,h]=(0,K.useState)(null),[g,_]=(0,K.useState)({}),v=e=>{r({openDialog:null},e),p(``)},y=(e,t)=>{n.openDialog?.name===`commandPalette`&&(t.stopPropagation(),t.preventDefault(),document.body.classList.add(`excalidraw-animations-disabled`),v(()=>{e.perform({actionManager:a,event:t}),s(e),requestAnimationFrame(()=>{document.body.classList.remove(`excalidraw-animations-disabled`)})}))},b=YC(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),x=YC(e=>{let t=qa(e.target)||ow(e)||e.key===E.ESCAPE;if(t&&e.key!==E.ARROW_UP&&e.key!==E.ARROW_DOWN&&e.key!==E.ENTER)return;let n=Object.values(g).flat(),r=o&&!f&&b(o);if(e.key===E.ARROW_UP){e.preventDefault();let t=n.findIndex(e=>e.label===m?.label);if(r){if(t===0){h(o);return}if(m===o){let e=n[n.length-1];e&&h(e);return}}let i;i=t===-1||t===0?n.length-1:(t-1)%n.length;let a=n[i];a&&h(a);return}if(e.key===E.ARROW_DOWN){e.preventDefault();let t=n.findIndex(e=>e.label===m?.label);if(r){if(!m||t===n.length-1){h(o);return}if(m===o){let e=n[0];e&&h(e);return}}let i=n[(t+1)%n.length];i&&h(i);return}if(e.key===E.ENTER&&m&&setTimeout(()=>{y(m,e)}),!t){if(e.stopPropagation(),/^[a-zA-Z0-9]$/.test(e.key)){u?.current?.focus();return}e.preventDefault()}});return(0,K.useEffect)(()=>(window.addEventListener(`keydown`,x,{capture:!0}),()=>window.removeEventListener(`keydown`,x,{capture:!0})),[x]),(0,K.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=c.filter(b).sort((e,t)=>e.order-t.order),n=!f&&o&&b(o);if(!f){_(e(n?t.filter(e=>e.label!==o?.label):t)),h(n?o:t[0]||null);return}let r=IC(f.toLocaleLowerCase().replace(/[<>_| -]/g,``));t=Lg.default.filter(r,t,{extract:e=>e.haystack}).sort((e,t)=>t.score-e.score).map(e=>e.original),_(e(t)),h(t[0]??null)},[f,c,b,o]),(0,q.jsxs)(OC,{onCloseRequest:()=>v(),closeOnClickOutside:!0,title:!1,size:720,autofocus:!0,className:`command-palette-dialog`,children:[(0,q.jsx)(AC,{value:f,placeholder:J(`commandPalette.search.placeholder`),onChange:e=>{p(e)},selectOnRender:!0,ref:u}),!t.device.viewport.isMobile&&(0,q.jsxs)(`div`,{className:`shortcuts-wrapper`,children:[(0,q.jsx)(aw,{shortcut:`↑↓`,children:J(`commandPalette.shortcuts.select`)}),(0,q.jsx)(aw,{shortcut:`↵`,children:J(`commandPalette.shortcuts.confirm`)}),(0,q.jsx)(aw,{shortcut:M(`Esc`),children:J(`commandPalette.shortcuts.close`)})]}),(0,q.jsxs)(`div`,{className:`commands`,children:[o&&!f&&(0,q.jsxs)(`div`,{className:`command-category`,children:[(0,q.jsxs)(`div`,{className:`command-category-title`,children:[J(`commandPalette.recents`),(0,q.jsx)(`div`,{className:`icon`,style:{marginLeft:`6px`},children:wr})]}),(0,q.jsx)(cw,{command:o,isSelected:o.label===m?.label,onClick:e=>y(o,e),disabled:!b(o),onMouseMove:()=>h(o),showShortcut:!t.device.viewport.isMobile,appState:n})]}),Object.keys(g).length>0?Object.keys(g).map((e,r)=>(0,q.jsxs)(`div`,{className:`command-category`,children:[(0,q.jsx)(`div`,{className:`command-category-title`,children:e}),g[e].map(e=>(0,q.jsx)(cw,{command:e,isSelected:e.label===m?.label,onClick:t=>y(e,t),onMouseMove:()=>h(e),showShortcut:!t.device.viewport.isMobile,appState:n},e.label))]},e)):c?(0,q.jsxs)(`div`,{className:`no-match`,children:[(0,q.jsx)(`div`,{className:`icon`,children:ja}),` `,J(`commandPalette.search.noMatch`)]}):null]})]})}var cw=({command:e,isSelected:t,disabled:n,onMouseMove:r,onClick:i,showShortcut:a,appState:o})=>{let s=()=>{};return(0,q.jsxs)(`div`,{className:L(`command-item`,{"item-selected":t,"item-disabled":n}),ref:e=>{t&&!n&&e?.scrollIntoView?.({block:`nearest`})},onClick:n?s:i,onMouseMove:n?s:r,title:n?J(`commandPalette.itemNotAvailable`):``,children:[(0,q.jsxs)(`div`,{className:`name`,children:[e.icon&&(0,q.jsx)(rb,{icon:typeof e.icon==`function`?e.icon(o):e.icon}),e.label]}),a&&e.shortcut&&(0,q.jsx)(aw,{shortcut:e.shortcut})]})},lw=O({name:`toggleLinearEditor`,category:rw.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.editingLinearElement&&i.length===1&&c(i[0])&&!U(i[0]))},perform(e,t,n,r){let i=r.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0})[0],a=t.editingLinearElement?.elementId===i.id?null:new G(i);return{appState:{...t,editingLinearElement:a},captureUpdate:j.IMMEDIATELY}},PanelComponent:({appState:e,updateData:t,app:n})=>{let r=n.scene.getSelectedElements({selectedElementIds:e.selectedElementIds})[0],i=J(r.type===`arrow`?`labels.lineEditor.editArrow`:`labels.lineEditor.edit`);return(0,q.jsx)(Y,{type:`button`,icon:zl,title:i,"aria-label":i,onClick:()=>t(null)})}}),uw=O({name:`searchMenu`,icon:ja,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.openSidebar?.name===Bs.name&&t.openSidebar.tab===`search`){let e=r.excalidrawContainerValue.container?.querySelector(`.${oo.SEARCH_MENU_INPUT_WRAPPER} input`);return e?.matches(`:focus`)?{appState:{...t,openSidebar:null},captureUpdate:j.EVENTUALLY}:(e?.focus(),e?.select(),!1)}return{appState:{...t,openSidebar:{name:Bs.name,tab:qr},openDialog:null},captureUpdate:j.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,t,n)=>n.gridModeEnabled===void 0,keyTest:e=>e[E.CTRL_OR_CMD]&&e.key===E.F}),dw=O({name:`cropEditor`,label:`helpDialog.cropStart`,icon:Ki,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&&El(i[0]))},PanelComponent:({appState:e,updateData:t,app:n})=>{let r=J(`helpDialog.cropStart`);return(0,q.jsx)(Y,{type:`button`,icon:Ki,title:r,"aria-label":r,onClick:()=>t(null)})}}),fw=class{constructor(e=!0,t=!0){this.isUndoStackEmpty=e,this.isRedoStackEmpty=t}},pw=class e{constructor(){i(this,`onHistoryChangedEmitter`,new zn),i(this,`undoStack`,[]),i(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,t){let n=mw.create(t,e);n.isEmpty()||(this.undoStack.push(n.inverse()),n.elementsChange.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new fw(this.isUndoStackEmpty,this.isRedoStackEmpty)))}undo(t,n,r){return this.perform(t,n,r,()=>e.pop(this.undoStack),n=>e.push(this.redoStack,n,t))}redo(t,n,r){return this.perform(t,n,r,()=>e.pop(this.redoStack),n=>e.push(this.undoStack,n,t))}perform(e,t,n,r,i){try{let a=r();if(a===null)return;let o=e,s=t,c=!1;for(;a;){try{[o,s,c]=a.applyTo(o,s,n)}finally{i(a)}if(c)break;a=r()}return[o,s]}finally{this.onHistoryChangedEmitter.trigger(new fw(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,n){let r=t.inverse().applyLatestChanges(n);return e.push(r)}},mw=class e{constructor(e,t){this.appStateChange=e,this.elementsChange=t}static create(t,n){return new e(t,n)}inverse(){return new e(this.appStateChange.inverse(),this.elementsChange.inverse())}applyTo(e,t,n){let[r,i]=this.elementsChange.applyTo(e,n.elements),[a,o]=this.appStateChange.applyTo(t,r);return[r,a,i||o]}applyLatestChanges(t){let n=this.elementsChange.applyLatestChanges(t);return e.create(this.appStateChange,n)}isEmpty(){return this.appStateChange.isEmpty()&&this.elementsChange.isEmpty()}},hw=(e,t)=>{let[n,r]=(0,K.useState)(t);return(0,K.useEffect)(()=>{let t=e.on(e=>{r(e)});return()=>{t()}},[e]),n},gw=(e,t,n)=>{if(!t.multiElement&&!t.resizingElement&&!t.editingTextElement&&!t.newElement&&!t.selectedElementsAreBeingDragged&&!t.selectionElement&&!e.flowChartCreator.isCreatingChart){let e=n();if(!e)return{captureUpdate:j.EVENTUALLY};let[t,r]=e;return{appState:r,elements:Array.from(t.values()),captureUpdate:j.NEVER}}return{captureUpdate:j.EVENTUALLY}},_w=(e,t)=>({name:`undo`,label:`buttons.undo`,icon:pc,trackEvent:{category:`history`},viewMode:!1,perform:(n,r,i,a)=>gw(a,r,()=>e.undo(k(n),r,t.snapshot)),keyTest:e=>e[E.CTRL_OR_CMD]&&uo(e,E.Z)&&!e.shiftKey,PanelComponent:({updateData:t,data:n})=>{let{isUndoStackEmpty:r}=hw(e.onHistoryChangedEmitter,new fw(e.isUndoStackEmpty,e.isRedoStackEmpty));return(0,q.jsx)(Y,{type:`button`,icon:pc,"aria-label":J(`buttons.undo`),onClick:t,size:n?.size||`medium`,disabled:r,"data-testid":`button-undo`})}}),vw=(e,t)=>({name:`redo`,label:`buttons.redo`,icon:Mi,trackEvent:{category:`history`},viewMode:!1,perform:(n,r,i,a)=>gw(a,r,()=>e.redo(k(n),r,t.snapshot)),keyTest:e=>e[E.CTRL_OR_CMD]&&e.shiftKey&&uo(e,E.Z)||$e&&e.ctrlKey&&!e.shiftKey&&uo(e,E.Y),PanelComponent:({updateData:t,data:n})=>{let{isRedoStackEmpty:r}=hw(e.onHistoryChangedEmitter,new fw(e.isUndoStackEmpty,e.isRedoStackEmpty));return(0,q.jsx)(Y,{type:`button`,icon:Mi,"aria-label":J(`buttons.redo`),onClick:t,size:n?.size||`medium`,disabled:r,"data-testid":`button-redo`})}}),yw=(e,t,n,r,i,a)=>{if(e.trackEvent)try{typeof e.trackEvent==`object`&&(!e.trackEvent.predicate||e.trackEvent.predicate(n,r,a))&&X(e.trackEvent.category,e.trackEvent.action||e.name,`${t} (${i.device.editor.isMobile?`mobile`:`desktop`})`)}catch(e){console.error(`error while logging action:`,e)}},bw=class{constructor(e,t,n,r){i(this,`actions`,{}),i(this,`updater`),i(this,`getAppState`),i(this,`getElementsIncludingDeleted`),i(this,`app`),i(this,`renderAction`,(e,t)=>{let n=this.app.props.UIOptions.canvasActions;if(this.actions[e]&&`PanelComponent`in this.actions[e]&&(!(e in n)||n[e])){let n=this.actions[e],r=n.PanelComponent;r.displayName=`PanelComponent`;let i=this.getElementsIncludingDeleted(),a=this.getAppState();return(0,q.jsx)(r,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:e=>{yw(n,`ui`,a,i,this.app,e),this.updater(n.perform(this.getElementsIncludingDeleted(),this.getAppState(),e,this.app))},appProps:this.app.props,app:this.app,data:t})}return null}),i(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(as(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){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.getAppState().viewModeEnabled&&r.viewMode!==!0)return!1;let i=this.getElementsIncludingDeleted(),a=this.getAppState();return yw(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){let r=this.getElementsIncludingDeleted(),i=this.getAppState();yw(e,t,i,r,this.app,n),this.updater(e.perform(r,i,n,this.app))}},xw=e=>{let t=Array.from(e.values());return{x:Cw(t,e=>e.x)/t.length,y:Cw(t,e=>e.y)/t.length}},Sw=([e,t])=>Math.hypot(e.x-t.x,e.y-t.y),Cw=(e,t)=>e.reduce((e,n)=>e+t(n),0),ww=({children:e,left:t,top:n,onCloseRequest:r,fitInViewport:i=!1,offsetLeft:a=0,offsetTop:o=0,viewportWidth:s=window.innerWidth,viewportHeight:c=window.innerHeight})=>{let l=(0,K.useRef)(null);(0,K.useEffect)(()=>{let e=l.current;if(!e)return;e.contains(document.activeElement)||e.focus();let t=t=>{if(t.key===E.TAB){let n=m(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 u=(0,K.useRef)(null);return(0,K.useLayoutEffect)(()=>{if(i&&l.current&&n!=null&&t!=null){let e=l.current,{width:r,height:i}=e.getBoundingClientRect();if(u.current?.top===n&&u.current?.left===t)return;u.current={top:n,left:t},r>=s?(e.style.width=`${s}px`,e.style.left=`0px`,e.style.overflowX=`scroll`):t+r-a>s?e.style.left=`${s-r-10}px`:e.style.left=`${t}px`,i>=c?(e.style.height=`${c-20}px`,e.style.top=`10px`,e.style.overflowY=`scroll`):n+i-o>c?e.style.top=`${c-i}px`:e.style.top=`${n}px`}},[n,t,i,s,c,a,o]),(0,K.useEffect)(()=>{if(r){let e=e=>{l.current?.contains(e.target)||(0,Ju.unstable_batchedUpdates)(()=>r(e))};return document.addEventListener(`pointerdown`,e,!1),()=>document.removeEventListener(`pointerdown`,e,!1)}},[r]),(0,q.jsx)(`div`,{className:`popover`,ref:l,tabIndex:-1,children:e})},Tw=`separator`,Ew=K.memo(({actionManager:e,items:t,top:n,left:r,onClose:i})=>{let a=Ak(),o=kk(),s=t.reduce((t,n)=>(n&&(n===Tw||!n.predicate||n.predicate(o,a,e.app.props,e.app))&&t.push(n),t),[]);return(0,q.jsx)(ww,{onCloseRequest:()=>{i()},top:n,left:r,fitInViewport:!0,offsetLeft:a.offsetLeft,offsetTop:a.offsetTop,viewportWidth:a.width,viewportHeight:a.height,children:(0,q.jsx)(`ul`,{className:`context-menu`,onContextMenu:e=>e.preventDefault(),children:s.map((t,n)=>{if(t===Tw)return!s[n-1]||s[n-1]===Tw?null:(0,q.jsx)(`hr`,{className:`context-menu-item-separator`},n);let r=t.name,c=``;return t.label&&(c=typeof t.label==`function`?J(t.label(o,a,e.app)):J(t.label)),(0,q.jsx)(`li`,{"data-testid":r,onClick:()=>{i(()=>{e.executeAction(t,`contextMenu`)})},children:(0,q.jsxs)(`button`,{type:`button`,className:L(`context-menu-item`,{dangerous:r===`deleteSelectedElements`,checkmark:t.checked?.(a)}),children:[(0,q.jsx)(`div`,{className:`context-menu-item__label`,children:c}),(0,q.jsx)(`kbd`,{className:`context-menu-item__shortcut`,children:r?MC(r):``})]})},n)})})})}),Dw=({children:e,onClose:t})=>{let[n,r]=(0,K.useState)(!!e),{container:i}=Ok(),a=K.useCallback(()=>{r(!1),t&&t(),i?.focus()},[t,i]);return(0,q.jsx)(q.Fragment,{children:n&&(0,q.jsx)(OC,{size:`small`,onCloseRequest:a,title:J(`errorDialog.title`),children:(0,q.jsx)(`div`,{style:{whiteSpace:`pre-wrap`},children:e})})})},Ow=function({onChange:e,value:t,choices:n,name:r}){return(0,q.jsx)(`div`,{className:`RadioGroup`,children:n.map(n=>(0,q.jsxs)(`div`,{className:L(`RadioGroup__choice`,{active:n.value===t}),title:n.ariaLabel,children:[(0,q.jsx)(`input`,{name:r,type:`radio`,checked:n.value===t,onChange:()=>e(n.value),"aria-label":n.ariaLabel}),n.label]},String(n.value)))})},kw=({title:e,name:t,checked:n,onChange:r,disabled:i=!1})=>(0,q.jsx)(`div`,{className:L(`Switch`,{toggled:n,disabled:i}),children:(0,q.jsx)(`input`,{name:t,id:t,title:e,type:`checkbox`,checked:n,disabled:i,onChange:()=>r(!n),onKeyDown:e=>{e.key===` `&&r(!n)}})}),Aw=(0,K.forwardRef)(({children:e,icon:t,onClick:n,label:r,variant:i=`filled`,color:a=`primary`,size:o=`medium`,fullWidth:s,className:c,status:l},u)=>{let[d,f]=(0,K.useState)(!1),p=async e=>{let t=n?.(e);if(as(t)){let e=window.setTimeout(()=>{f(!0)},50);try{await t}catch(e){if(e instanceof ai)console.warn(e);else throw e}finally{clearTimeout(e),f(!1)}}},m=d?`loading`:l;return a=m===`success`?`success`:a,(0,q.jsx)(`button`,{className:L(`ExcButton`,`ExcButton--color-${a}`,`ExcButton--variant-${i}`,`ExcButton--size-${o}`,`ExcButton--status-${m}`,{"ExcButton--fullWidth":s},c),onClick:p,type:`button`,"aria-label":r,ref:u,disabled:m===`loading`||m===`success`,children:(0,q.jsxs)(`div`,{className:`ExcButton__contents`,children:[m===`loading`?(0,q.jsx)(Gv,{className:`ExcButton__statusIcon`}):m===`success`&&(0,q.jsx)(`div`,{className:`ExcButton__statusIcon`,children:sr}),t&&(0,q.jsx)(`div`,{className:`ExcButton__icon`,"aria-hidden":!0,children:t}),i!==`icon`&&(e??r)]})})}),jw=2e3,Mw=()=>{let[e,t]=(0,K.useState)(null),n=(0,K.useRef)(0);return{copyStatus:e,resetCopyStatus:(0,K.useCallback)(()=>{t(null)},[]),onCopy:()=>{clearTimeout(n.current),t(`success`),n.current=window.setTimeout(()=>{t(null)},jw)}}},Nw=`filter`in document.createElement(`canvas`).getContext(`2d`),Pw=()=>(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h3`,{children:J(`canvasError.cannotShowPreview`)}),(0,q.jsx)(`p`,{children:(0,q.jsx)(`span`,{children:J(`canvasError.canvasTooBig`)})}),(0,q.jsxs)(`em`,{children:[`(`,J(`canvasError.canvasTooBigTip`),`)`]})]}),Fw=({appStateSnapshot:e,elementsSnapshot:t,files:n,actionManager:r,onExportImage:i,name:a})=>{let o=xc(t,e),[s,c]=(0,K.useState)(a),[l,u]=(0,K.useState)(o),[d,f]=(0,K.useState)(e.exportBackground),[p,m]=(0,K.useState)(e.exportWithDarkMode),[h,g]=(0,K.useState)(e.exportEmbedScene),[_,v]=(0,K.useState)(e.exportScale),y=(0,K.useRef)(null),[b,x]=(0,K.useState)(null),{onCopy:S,copyStatus:C,resetCopyStatus:w}=Mw();(0,K.useEffect)(()=>{w()},[s,d,p,_,h,w]);let{exportedElements:T,exportingFrame:ee}=ex(t,e,l);return(0,K.useEffect)(()=>{let t=y.current;if(!t)return;let r=t.offsetWidth,i=t.offsetHeight;r&&es({elements:T,appState:{...e,name:s,exportBackground:d,exportWithDarkMode:p,exportScale:_,exportEmbedScene:h},files:n,exportPadding:10,maxWidthOrHeight:Math.max(r,i),exportingFrame:ee}).then(e=>(x(null),zo(e).then(()=>{t.replaceChildren(e)}).catch(e=>{throw e.name===`CANVAS_POSSIBLY_TOO_BIG`?Error(J(`canvasError.canvasTooBig`)):e}))).catch(e=>{console.error(e),x(e)})},[e,n,T,ee,s,d,p,_,h]),(0,q.jsxs)(`div`,{className:`ImageExportModal`,children:[(0,q.jsx)(`h3`,{children:J(`imageExportDialog.header`)}),(0,q.jsxs)(`div`,{className:`ImageExportModal__preview`,children:[(0,q.jsx)(`div`,{className:`ImageExportModal__preview__canvas`,ref:y,children:b&&(0,q.jsx)(Pw,{})}),(0,q.jsx)(`div`,{className:`ImageExportModal__preview__filename`,children:!Ni&&(0,q.jsx)(`input`,{type:`text`,className:`TextInput`,value:s,style:{width:`30ch`},onChange:e=>{c(e.target.value),r.executeAction(ix,`ui`,e.target.value)}})})]}),(0,q.jsxs)(`div`,{className:`ImageExportModal__settings`,children:[(0,q.jsx)(`h3`,{children:J(`imageExportDialog.header`)}),o&&(0,q.jsx)(Iw,{label:J(`imageExportDialog.label.onlySelected`),name:`exportOnlySelected`,children:(0,q.jsx)(kw,{name:`exportOnlySelected`,checked:l,onChange:e=>{u(e)}})}),(0,q.jsx)(Iw,{label:J(`imageExportDialog.label.withBackground`),name:`exportBackgroundSwitch`,children:(0,q.jsx)(kw,{name:`exportBackgroundSwitch`,checked:d,onChange:e=>{f(e),r.executeAction(ox,`ui`,e)}})}),Nw&&(0,q.jsx)(Iw,{label:J(`imageExportDialog.label.darkMode`),name:`exportDarkModeSwitch`,children:(0,q.jsx)(kw,{name:`exportDarkModeSwitch`,checked:p,onChange:e=>{m(e),r.executeAction(dx,`ui`,e)}})}),(0,q.jsx)(Iw,{label:J(`imageExportDialog.label.embedScene`),tooltip:J(`imageExportDialog.tooltip.embedScene`),name:`exportEmbedSwitch`,children:(0,q.jsx)(kw,{name:`exportEmbedSwitch`,checked:h,onChange:e=>{g(e),r.executeAction(sx,`ui`,e)}})}),(0,q.jsx)(Iw,{label:J(`imageExportDialog.label.scale`),name:`exportScale`,children:(0,q.jsx)(Ow,{name:`exportScale`,value:_,onChange:e=>{v(e),r.executeAction(ax,`ui`,e)},choices:nt.map(e=>({value:e,label:`${e}\xD7`}))})}),(0,q.jsxs)(`div`,{className:`ImageExportModal__settings__buttons`,children:[(0,q.jsx)(Aw,{className:`ImageExportModal__settings__buttons__button`,label:J(`imageExportDialog.title.exportToPng`),onClick:()=>i(co.png,T,{exportingFrame:ee}),icon:Ws,children:J(`imageExportDialog.button.exportToPng`)}),(0,q.jsx)(Aw,{className:`ImageExportModal__settings__buttons__button`,label:J(`imageExportDialog.title.exportToSvg`),onClick:()=>i(co.svg,T,{exportingFrame:ee}),icon:Ws,children:J(`imageExportDialog.button.exportToSvg`)}),(se||gi)&&(0,q.jsx)(Aw,{className:`ImageExportModal__settings__buttons__button`,label:J(`imageExportDialog.title.copyPngToClipboard`),status:C,onClick:async()=>{await i(co.clipboard,T,{exportingFrame:ee}),S()},icon:Fc,children:J(`imageExportDialog.button.copyPngToClipboard`)})]})]})]})},Iw=({label:e,children:t,tooltip:n,name:r})=>(0,q.jsxs)(`div`,{className:`ImageExportModal__settings__setting`,title:e,children:[(0,q.jsxs)(`label`,{htmlFor:r,className:`ImageExportModal__settings__setting__label`,children:[e,n&&(0,q.jsx)(Bb,{label:n,long:!0,children:Gl})]}),(0,q.jsx)(`div`,{className:`ImageExportModal__settings__setting__content`,children:t})]}),Lw=({elements:e,appState:t,files:n,actionManager:r,onExportImage:i,onCloseRequest:a,name:o})=>{let[{appStateSnapshot:s,elementsSnapshot:c}]=(0,K.useState)(()=>({appStateSnapshot:ui(t),elementsSnapshot:ui(e)}));return(0,q.jsx)(OC,{onCloseRequest:a,size:`wide`,title:!1,children:(0,q.jsx)(Fw,{elementsSnapshot:c,appStateSnapshot:s,files:n,actionManager:r,onExportImage:i,name:o})})},Rw=({children:e,side:t,className:n})=>(0,q.jsx)(`div`,{className:L(`FixedSideContainer`,`FixedSideContainer_side_${t}`,n),children:e}),zw=100,Bw=100,Vw=e=>{switch(e){case E.ARROW_UP:return`up`;case E.ARROW_DOWN:return`down`;case E.ARROW_RIGHT:return`right`;case E.ARROW_LEFT:return`left`;default:return`right`}},Hw=(e,t,n,r)=>{let i=[...n.values()].reduce((r,i)=>{let a;if(U(i)&&(a=i[e===`predecessors`?`startBinding`:`endBinding`])&&i[e===`predecessors`?`endBinding`:`startBinding`]?.elementId===t.id){let o=n.get(a.elementId);if(!o)return r;lo(Pe(o),`not an ExcalidrawBindableElement`);let s=e===`predecessors`?i.points[i.points.length-1]:[0,0],c=Ga(t,$i(t),[s[0]+i.x,s[1]+i.y]);r.push({relative:o,heading:c})}return r},[]);switch(r){case`up`:return i.filter(e=>ua(e.heading,dt)).map(e=>e.relative);case`down`:return i.filter(e=>ua(e.heading,We)).map(e=>e.relative);case`right`:return i.filter(e=>ua(e.heading,ar)).map(e=>e.relative);case`left`:return i.filter(e=>ua(e.heading,qe)).map(e=>e.relative)}},Uw=(e,t,n)=>Hw(`successors`,e,t,n),Ww=(e,t,n)=>Hw(`predecessors`,e,t,n),Gw=(e,t,n)=>{let r=Bw+e.width;if(n===`up`||n===`down`){let r=zw+e.height,i=e.x,a=e.x+e.width;if(t.every(e=>e.x+e.width<i||e.x>a))return{x:0,y:r*(n===`up`?-1:1)}}else if(n===`right`||n===`left`){let r=e.y,i=e.y+e.height;if(t.every(e=>e.y+e.height<r||e.y>i))return{x:(Bw+e.width)*(n===`left`?-1:1),y:0}}if(n===`up`||n===`down`){let i=zw+e.height,a=(t.length,i),o=t.length===0?0:(t.length+1)%2==0?(t.length+1)/2*r:t.length/2*r*-1;return n===`up`?{x:o,y:a*-1}:{x:o,y:a}}let i=zw+e.height,a=(t.length,Bw+e.width),o=t.length===0?0:(t.length+1)%2==0?(t.length+1)/2*i:t.length/2*i*-1;return n===`left`?{x:a*-1,y:o}:{x:a,y:o}},Kw=(e,t,n,r)=>{let i=Uw(e,t,r),a=Ww(e,t,r),o=Gw(e,[...i,...a],r),s=Xs({type:e.type,x:e.x+o.x,y:e.y+o.y,width:e.width,height:e.height,roundness:e.roundness,roughness:e.roughness,backgroundColor:e.backgroundColor,strokeColor:e.strokeColor,strokeWidth:e.strokeWidth,opacity:e.opacity,fillStyle:e.fillStyle,strokeStyle:e.strokeStyle});return lo(je(s),`not an ExcalidrawFlowchartNodeElement`),{nextNode:s,bindingArrow:Jw(e,s,t,r,n)}},qw=(e,t,n,r,i)=>{let a=[];for(let o=0;o<i;o++){let s,c;if(r===`left`||r===`right`){let t=zw*(i-1)+i*e.height,n=e.y+e.height/2-t/2,a=Bw+e.width;r===`left`&&(a*=-1),s=e.x+a,c=n+(zw+e.height)*o}else{let t=Bw*(i-1)+i*e.width,n=e.x+e.width/2-t/2,a=zw+e.height;r===`up`&&(a*=-1),c=e.y+a,s=n+(Bw+e.width)*o}let l=Xs({type:e.type,x:s,y:c,width:e.width,height:e.height,roundness:e.roundness,roughness:e.roughness,backgroundColor:e.backgroundColor,strokeColor:e.strokeColor,strokeWidth:e.strokeWidth,opacity:e.opacity,fillStyle:e.fillStyle,strokeStyle:e.strokeStyle});lo(je(l),`not an ExcalidrawFlowchartNodeElement`);let u=Jw(e,l,t,r,n);a.push(l),a.push(u)}return a},Jw=(e,t,n,r,i)=>{let a,o;switch(r){case`up`:a=e.x+e.width/2,o=e.y-6;break;case`down`:a=e.x+e.width/2,o=e.y+e.height+6;break;case`right`:a=e.x+e.width+6,o=e.y+e.height/2;break;case`left`:a=e.x-6,o=e.y+e.height/2;break}let s,c;switch(r){case`up`:s=t.x+t.width/2-a,c=t.y+t.height-o+6;break;case`down`:s=t.x+t.width/2-a,c=t.y-o-6;break;case`right`:s=t.x-a-6,c=t.y-o+t.height/2;break;case`left`:s=t.x+t.width-a+6,c=t.y-o+t.height/2;break}let l=y({type:`arrow`,x:a,y:o,startArrowhead:null,endArrowhead:i.currentItemEndArrowhead,strokeColor:e.strokeColor,strokeStyle:e.strokeStyle,strokeWidth:e.strokeWidth,opacity:e.opacity,roughness:e.roughness,points:[P(0,0),P(s,c)],elbowed:!0});Ot(l,e,`start`,n),Ot(l,t,`end`,n);let u=new Map;u.set(e.id,e),u.set(t.id,t),u.set(l.id,l),G.movePoints(l,[{index:1,point:l.points[1]}]);let d=hr(l,Xl(new Map([...n.entries(),[e.id,e],[t.id,t],[l.id,l]])),{points:l.points});return{...l,...d}},Yw=class{constructor(){i(this,`isExploring`,!1),i(this,`sameLevelNodes`,[]),i(this,`sameLevelIndex`,0),i(this,`direction`,null),i(this,`visitedNodes`,new Set)}clear(){this.isExploring=!1,this.sameLevelNodes=[],this.sameLevelIndex=0,this.direction=null,this.visitedNodes.clear()}exploreByDirection(e,t,n){if(!Pe(e))return null;if(n!==this.direction&&this.clear(),this.visitedNodes.has(e.id)||this.visitedNodes.add(e.id),this.isExploring&&n===this.direction&&this.sameLevelNodes.length>1)return this.sameLevelIndex=(this.sameLevelIndex+1)%this.sameLevelNodes.length,this.sameLevelNodes[this.sameLevelIndex].id;let r=[...Uw(e,t,n),...Ww(e,t,n)];if(r.length>0)return this.sameLevelIndex=0,this.isExploring=!0,this.sameLevelNodes=r,this.direction=n,this.visitedNodes.add(r[0].id),r[0].id;if(n===this.direction||!this.isExploring){this.isExploring||this.visitedNodes.add(e.id);let r=[`up`,`right`,`down`,`left`].filter(e=>e!==n).map(n=>[...Uw(e,t,n),...Ww(e,t,n)]).flat().filter(e=>!this.visitedNodes.has(e.id));for(let e of r)if(!this.visitedNodes.has(e.id))return this.visitedNodes.add(e.id),this.isExploring=!0,this.direction=n,e.id}return null}},Xw=class{constructor(){i(this,`isCreatingChart`,!1),i(this,`numberOfNodes`,0),i(this,`direction`,`right`),i(this,`pendingNodes`,null)}createNodes(e,t,n,r){if(r!==this.direction){let{nextNode:i,bindingArrow:a}=Kw(e,t,n,r);this.numberOfNodes=1,this.isCreatingChart=!0,this.direction=r,this.pendingNodes=[i,a]}else{this.numberOfNodes+=1;let i=qw(e,t,n,r,this.numberOfNodes);this.isCreatingChart=!0,this.direction=r,this.pendingNodes=i}if(e.frameId){let n=t.get(e.frameId);lo(n&&Fr(n),`not an ExcalidrawFrameElement`),n&&this.pendingNodes.every(e=>Hn([e],n,t)||ee(e,n,t))&&(this.pendingNodes=this.pendingNodes.map(t=>V(t,{frameId:e.frameId},!1)))}}clear(){this.isCreatingChart=!1,this.pendingNodes=null,this.direction=null,this.numberOfNodes=0}},Zw=(e,t)=>{for(let[,n]of t)if(n.type===`arrow`&&(n.startBinding?.elementId===e.id||n.endBinding?.elementId===e.id))return!0;return!1},Qw=({appState:e,isMobile:t,device:n,app:r})=>{let{activeTool:i,isResizing:a,isRotating:o,lastPointerDownWith:s}=e,l=e.multiElement!==null;if(e.openSidebar?.name===Bs.name&&e.openSidebar.tab===`search`&&e.searchMatches?.length)return J(`hints.dismissSearch`);if(e.openSidebar&&!n.editor.canFitSidebar)return null;if(hn(e))return J(`hints.eraserRevert`);if(i.type===`arrow`||i.type===`line`)return l?J(`hints.linearElementMulti`):i.type===`arrow`?J(`hints.arrowTool`,{arrowShortcut:M(`A`)}):J(`hints.linearElement`);if(i.type===`freedraw`)return J(`hints.freeDraw`);if(i.type===`text`)return J(`hints.text`);if(i.type===`embeddable`)return J(`hints.embeddable`);if(e.activeTool.type===`image`&&e.pendingImageElementId)return J(`hints.placeImage`);let u=r.scene.getSelectedElements(e);if(a&&s===`mouse`&&u.length===1){let e=u[0];return c(e)&&e.points.length===2?J(`hints.lockAngle`):El(e)?J(`hints.resizeImage`):J(`hints.resize`)}if(o&&s===`mouse`)return J(`hints.rotate`);if(u.length===1&&I(u[0]))return J(`hints.text_selected`);if(e.editingTextElement)return J(`hints.text_editing`);if(e.croppingElementId)return J(`hints.leaveCropEditor`);if(u.length===1&&El(u[0]))return J(`hints.enterCropEditor`);if(i.type===`selection`){if(e.selectionElement&&!u.length&&!e.editingTextElement&&!e.editingLinearElement)return J(`hints.deepBoxSelect`);if(ra(r)&&e.selectedElementsAreBeingDragged)return J(`hints.disableSnapping`);if(!u.length&&!t)return J(`hints.canvasPanning`);if(u.length===1){if(c(u[0]))return e.editingLinearElement?e.editingLinearElement.selectedPointsIndices?J(`hints.lineEditor_pointSelected`):J(`hints.lineEditor_nothingSelected`):J(`hints.lineEditor_info`);if(!e.newElement&&!e.selectedElementsAreBeingDragged&&ba(u[0]))return je(u[0])?(Zw(u[0],r.scene.getNonDeletedElementsMap()),[J(`hints.bindTextToElement`),J(`hints.createFlowchart`)]):J(`hints.bindTextToElement`)}}return null},$w=({appState:e,isMobile:t,device:n,app:r})=>{let i=Qw({appState:e,isMobile:t,device:n,app:r});return i?(0,q.jsx)(`div`,{className:`HintViewer`,children:(0,q.jsx)(`span`,{children:Array.isArray(i)?i.map(e=>M(e).replace(/\. ?$/,``)).join(`. `):M(i)})}):null},eT=`medium`,tT={CHECKED:Xi,UNCHECKED:Ee},nT=e=>(0,q.jsxs)(`label`,{className:L(`ToolIcon ToolIcon__lock`,`ToolIcon_size_${eT}`,{"is-mobile":e.isMobile}),title:`${e.title} \u2014 Q`,children:[(0,q.jsx)(`input`,{className:`ToolIcon_type_checkbox`,type:`checkbox`,name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":`toolbar-lock`}),(0,q.jsx)(`div`,{className:`ToolIcon__icon`,children:e.checked?tT.CHECKED:tT.UNCHECKED})]}),rT=({heading:e,children:t,...n})=>{let{id:r}=Ok(),i=(0,q.jsx)(`h2`,{className:`visually-hidden`,id:`${r}-${e}-title`,children:J(`headings.${e}`)});return(0,q.jsx)(`section`,{...n,"aria-labelledby":`${r}-${e}-title`,children:typeof t==`function`?t(i):(0,q.jsxs)(q.Fragment,{children:[i,t]})})},iT=4,aT=6,oT=`rgba(0,0,0,0.3)`,sT=(e,t,n,r)=>{if(!e.length)return{horizontal:null,vertical:null};let[i,a,o,s]=Ao(e),c=t/r.zoom.value,l=n/r.zoom.value,u=t-c,d=n-l,f={top:parseInt(So(`sat`))||0,bottom:parseInt(So(`sab`))||0,left:parseInt(So(`sal`))||0,right:parseInt(So(`sar`))||0},p=Vv().rtl,m=-r.scrollX+u/2+f.left,h=-r.scrollY+d/2+f.top,g=m+c-f.right,_=h+l-f.bottom,v=Math.min(i,m),y=Math.min(a,h),b=Math.max(o,g),x=Math.max(s,_);return{horizontal:m===v&&g===b?null:{x:Math.max(f.left,iT)+(m-v)/(b-v)*t,y:n-aT-Math.max(iT,f.bottom),width:(g-m)/(b-v)*t-Math.max(iT*2,f.left+f.right),height:aT},vertical:h===y&&_===x?null:{x:p?Math.max(f.left,iT):t-aT-Math.max(f.right,iT),y:(h-y)/(x-y)*n+Math.max(f.top,iT),width:aT,height:(_-h)/(x-y)*n-Math.max(iT*2,f.top+f.bottom)}}},cT=(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}},lT=`medium`,uT=e=>e.penDetected?(0,q.jsxs)(`label`,{className:L(`ToolIcon ToolIcon__penMode`,`ToolIcon_size_${lT}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[(0,q.jsx)(`input`,{className:`ToolIcon_type_checkbox`,type:`checkbox`,name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),(0,q.jsx)(`div`,{className:`ToolIcon__icon`,children:vr})]}):null,dT=e=>(0,q.jsx)(Y,{className:L(`Shape`,{fillable:!1}),type:`radio`,icon:ol,name:`editor-current-shape`,checked:e.checked,title:`${e.title} \u2014 H`,keyBindingLabel:e.isMobile?void 0:E.H.toLocaleUpperCase(),"aria-label":`${e.title} \u2014 H`,"aria-keyshortcuts":E.H,"data-testid":`toolbar-hand`,onChange:()=>e.onChange?.()}),fT=({appState:e,elements:t,actionManager:n,setAppState:r,onLockToggle:i,onHandToolToggle:a,onPenModeToggle:o,renderTopRightUI:s,renderCustomStats:c,renderSidebars:l,device:u,renderWelcomeScreen:d,UIOptions:f,app:p})=>{let{WelcomeScreenCenterTunnel:m,MainMenuTunnel:h,DefaultSidebarTriggerTunnel:g}=RC();return(0,q.jsxs)(q.Fragment,{children:[l(),!e.viewModeEnabled&&e.openDialog?.name!==`elementLinkSelector`&&(0,q.jsxs)(Rw,{side:`top`,className:`App-top-bar`,children:[d&&(0,q.jsx)(m.Out,{}),(0,q.jsx)(rT,{heading:`shapes`,children:t=>(0,q.jsx)(PS.Col,{gap:4,align:`center`,children:(0,q.jsxs)(PS.Row,{gap:1,className:`App-toolbar-container`,children:[(0,q.jsxs)(Xy,{padding:1,className:`App-toolbar App-toolbar--mobile`,children:[t,(0,q.jsx)(PS.Row,{gap:1,children:(0,q.jsx)(WC,{appState:e,activeTool:e.activeTool,UIOptions:f,app:p})})]}),s&&s(!0,e),(0,q.jsxs)(`div`,{className:`mobile-misc-tools-container`,children:[!e.viewModeEnabled&&e.openDialog?.name!==`elementLinkSelector`&&(0,q.jsx)(g.Out,{}),(0,q.jsx)(uT,{checked:e.penMode,onChange:()=>o(null),title:J(`toolBar.penMode`),isMobile:!0,penDetected:e.penDetected}),(0,q.jsx)(nT,{checked:e.activeTool.locked,onChange:i,title:J(`toolBar.lock`),isMobile:!0}),(0,q.jsx)(dT,{checked:Ho(e),onChange:()=>a(),title:J(`toolBar.hand`),isMobile:!0})]})]})})}),(0,q.jsx)($w,{appState:e,isMobile:!0,device:u,app:p})]}),(0,q.jsx)(`div`,{className:`App-bottom-bar`,style:{marginBottom:aT+iT*2,marginLeft:aT+iT*2,marginRight:aT+iT*2},children:(0,q.jsxs)(Xy,{padding:0,children:[e.openMenu===`shape`&&!e.viewModeEnabled&&e.openDialog?.name!==`elementLinkSelector`&&Tr(e,t)?(0,q.jsx)(rT,{className:`App-mobile-menu`,heading:`selectedShapeActions`,children:(0,q.jsx)(UC,{appState:e,elementsMap:p.scene.getNonDeletedElementsMap(),renderAction:n.renderAction,app:p})}):null,(0,q.jsxs)(`footer`,{className:`App-toolbar`,children:[e.viewModeEnabled||e.openDialog?.name===`elementLinkSelector`?(0,q.jsx)(`div`,{className:`App-toolbar-content`,children:(0,q.jsx)(h.Out,{})}):(0,q.jsxs)(`div`,{className:`App-toolbar-content`,children:[(0,q.jsx)(h.Out,{}),n.renderAction(`toggleEditMenu`),n.renderAction(e.multiElement?`finalize`:`duplicateSelection`),n.renderAction(`deleteSelectedElements`),(0,q.jsxs)(`div`,{children:[n.renderAction(`undo`),n.renderAction(`redo`)]})]}),e.scrolledOutside&&!e.openMenu&&!e.openSidebar&&(0,q.jsx)(`button`,{type:`button`,className:`scroll-back-to-content`,onClick:()=>{r(e=>({...Xr(t,e)}))},children:J(`buttons.scrollBackToContent`)})]})]})})]})},pT=e=>{let t=(0,K.useRef)(null),[n,r]=(0,K.useState)(null);return(0,K.useLayoutEffect)(()=>{if(!e.spreadsheet)return;let n=li(e.chartType,e.spreadsheet,0,0);r(n);let i,a=t.current;return(async()=>(i=await nr(n,{exportBackground:!1,viewBackgroundColor:As.white},null,{skipInliningFonts:!0}),i.querySelector(`.style-fonts`)?.remove(),a.replaceChildren(),a.appendChild(i),e.selected&&a.parentNode.focus()))(),()=>{a.replaceChildren()}},[e.spreadsheet,e.chartType,e.selected]),(0,q.jsx)(`button`,{type:`button`,className:`ChartPreview`,onClick:()=>{n&&e.onClick(e.chartType,n)},children:(0,q.jsx)(`div`,{ref:t})})},mT=({setAppState:e,appState:t,onClose:n})=>{let{onInsertElements:r}=Tk(),i=K.useCallback(()=>{n&&n()},[n]),a=(t,n)=>{r(n),X(`paste`,`chart`,t),e({currentChartType:t,pasteDialog:{shown:!1,data:null}})};return(0,q.jsx)(OC,{size:`small`,onCloseRequest:i,title:J(`labels.pasteCharts`),className:`PasteChartDialog`,autofocus:!1,children:(0,q.jsxs)(`div`,{className:`container`,children:[(0,q.jsx)(pT,{chartType:`bar`,spreadsheet:t.pasteDialog.data,selected:t.currentChartType===`bar`,onClick:a}),(0,q.jsx)(pT,{chartType:`line`,spreadsheet:t.pasteDialog.data,selected:t.currentChartType===`line`,onClick:a})]})})},hT=()=>(0,q.jsxs)(`div`,{className:`HelpDialog__header`,children:[(0,q.jsxs)(`a`,{className:`HelpDialog__btn`,href:`https://docs.excalidraw.com`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,q.jsx)(`div`,{className:`HelpDialog__link-icon`,children:Yo}),J(`helpDialog.documentation`)]}),(0,q.jsxs)(`a`,{className:`HelpDialog__btn`,href:`https://plus.excalidraw.com/blog`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,q.jsx)(`div`,{className:`HelpDialog__link-icon`,children:Yo}),J(`helpDialog.blog`)]}),(0,q.jsxs)(`a`,{className:`HelpDialog__btn`,href:`https://github.com/excalidraw/excalidraw/issues`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,q.jsx)(`div`,{className:`HelpDialog__link-icon`,children:lr}),J(`helpDialog.github`)]}),(0,q.jsxs)(`a`,{className:`HelpDialog__btn`,href:`https://youtube.com/@excalidraw`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,q.jsx)(`div`,{className:`HelpDialog__link-icon`,children:oe}),`YouTube`]})]}),gT=e=>(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`h3`,{children:e.title}),(0,q.jsx)(`div`,{className:`HelpDialog__islands-container`,children:e.children})]}),_T=e=>(0,q.jsxs)(`div`,{className:`HelpDialog__island ${e.className}`,children:[(0,q.jsx)(`h4`,{className:`HelpDialog__island-title`,children:e.caption}),(0,q.jsx)(`div`,{className:`HelpDialog__island-content`,children:e.children})]});function*vT(e,t){let n=!0;for(let r of e)n||(yield t),n=!1,yield r}var yT=e=>e.replace(/\b[a-z]\b/,e=>e.toUpperCase()),Q=({label:e,shortcuts:t,isOr:n=!0})=>{let r=t.map(e=>(e.endsWith(`++`)?[...e.slice(0,-2).split(`+`),`+`]:e.split(`+`)).map(e=>(0,q.jsx)(bT,{children:yT(e)},e)));return(0,q.jsxs)(`div`,{className:`HelpDialog__shortcut`,children:[(0,q.jsx)(`div`,{children:e}),(0,q.jsx)(`div`,{className:`HelpDialog__key-container`,children:[...vT(r,n?J(`helpDialog.or`):null)]})]})},bT=e=>(0,q.jsx)(`kbd`,{className:`HelpDialog__key`,...e}),xT=({onClose:e})=>(0,q.jsx)(q.Fragment,{children:(0,q.jsxs)(OC,{onCloseRequest:K.useCallback(()=>{e&&e()},[e]),title:J(`helpDialog.title`),className:`HelpDialog`,children:[(0,q.jsx)(hT,{}),(0,q.jsxs)(gT,{title:J(`helpDialog.shortcuts`),children:[(0,q.jsxs)(_T,{className:`HelpDialog__island--tools`,caption:J(`helpDialog.tools`),children:[(0,q.jsx)(Q,{label:J(`toolBar.hand`),shortcuts:[E.H]}),(0,q.jsx)(Q,{label:J(`toolBar.selection`),shortcuts:[E.V,E[1]]}),(0,q.jsx)(Q,{label:J(`toolBar.rectangle`),shortcuts:[E.R,E[2]]}),(0,q.jsx)(Q,{label:J(`toolBar.diamond`),shortcuts:[E.D,E[3]]}),(0,q.jsx)(Q,{label:J(`toolBar.ellipse`),shortcuts:[E.O,E[4]]}),(0,q.jsx)(Q,{label:J(`toolBar.arrow`),shortcuts:[E.A,E[5]]}),(0,q.jsx)(Q,{label:J(`toolBar.line`),shortcuts:[E.L,E[6]]}),(0,q.jsx)(Q,{label:J(`toolBar.freedraw`),shortcuts:[E.P,E[7]]}),(0,q.jsx)(Q,{label:J(`toolBar.text`),shortcuts:[E.T,E[8]]}),(0,q.jsx)(Q,{label:J(`toolBar.image`),shortcuts:[E[9]]}),(0,q.jsx)(Q,{label:J(`toolBar.eraser`),shortcuts:[E.E,E[0]]}),(0,q.jsx)(Q,{label:J(`toolBar.frame`),shortcuts:[E.F]}),(0,q.jsx)(Q,{label:J(`toolBar.laser`),shortcuts:[E.K]}),(0,q.jsx)(Q,{label:J(`labels.eyeDropper`),shortcuts:[E.I,`Shift+S`,`Shift+G`]}),(0,q.jsx)(Q,{label:J(`helpDialog.editLineArrowPoints`),shortcuts:[M(`CtrlOrCmd+Enter`)]}),(0,q.jsx)(Q,{label:J(`helpDialog.editText`),shortcuts:[M(`Enter`)]}),(0,q.jsx)(Q,{label:J(`helpDialog.textNewLine`),shortcuts:[M(`Enter`),M(`Shift+Enter`)]}),(0,q.jsx)(Q,{label:J(`helpDialog.textFinish`),shortcuts:[M(`Esc`),M(`CtrlOrCmd+Enter`)]}),(0,q.jsx)(Q,{label:J(`helpDialog.curvedArrow`),shortcuts:[`A`,J(`helpDialog.click`),J(`helpDialog.click`),J(`helpDialog.click`)],isOr:!1}),(0,q.jsx)(Q,{label:J(`helpDialog.curvedLine`),shortcuts:[`L`,J(`helpDialog.click`),J(`helpDialog.click`),J(`helpDialog.click`)],isOr:!1}),(0,q.jsx)(Q,{label:J(`helpDialog.cropStart`),shortcuts:[J(`helpDialog.doubleClick`),M(`Enter`)],isOr:!0}),(0,q.jsx)(Q,{label:J(`helpDialog.cropFinish`),shortcuts:[M(`Enter`),M(`Escape`)],isOr:!0}),(0,q.jsx)(Q,{label:J(`toolBar.lock`),shortcuts:[E.Q]}),(0,q.jsx)(Q,{label:J(`helpDialog.preventBinding`),shortcuts:[M(`CtrlOrCmd`)]}),(0,q.jsx)(Q,{label:J(`toolBar.link`),shortcuts:[M(`CtrlOrCmd+K`)]})]}),(0,q.jsxs)(_T,{className:`HelpDialog__island--view`,caption:J(`helpDialog.view`),children:[(0,q.jsx)(Q,{label:J(`buttons.zoomIn`),shortcuts:[M(`CtrlOrCmd++`)]}),(0,q.jsx)(Q,{label:J(`buttons.zoomOut`),shortcuts:[M(`CtrlOrCmd+-`)]}),(0,q.jsx)(Q,{label:J(`buttons.resetZoom`),shortcuts:[M(`CtrlOrCmd+0`)]}),(0,q.jsx)(Q,{label:J(`helpDialog.zoomToFit`),shortcuts:[`Shift+1`]}),(0,q.jsx)(Q,{label:J(`helpDialog.zoomToSelection`),shortcuts:[`Shift+2`]}),(0,q.jsx)(Q,{label:J(`helpDialog.movePageUpDown`),shortcuts:[`PgUp/PgDn`]}),(0,q.jsx)(Q,{label:J(`helpDialog.movePageLeftRight`),shortcuts:[`Shift+PgUp/PgDn`]}),(0,q.jsx)(Q,{label:J(`buttons.zenMode`),shortcuts:[M(`Alt+Z`)]}),(0,q.jsx)(Q,{label:J(`buttons.objectsSnapMode`),shortcuts:[M(`Alt+S`)]}),(0,q.jsx)(Q,{label:J(`labels.toggleGrid`),shortcuts:[M(`CtrlOrCmd+'`)]}),(0,q.jsx)(Q,{label:J(`labels.viewMode`),shortcuts:[M(`Alt+R`)]}),(0,q.jsx)(Q,{label:J(`labels.toggleTheme`),shortcuts:[M(`Alt+Shift+D`)]}),(0,q.jsx)(Q,{label:J(`stats.fullTitle`),shortcuts:[M(`Alt+/`)]}),(0,q.jsx)(Q,{label:J(`search.title`),shortcuts:[MC(`searchMenu`)]}),(0,q.jsx)(Q,{label:J(`commandPalette.title`),shortcuts:gi?[MC(`commandPalette`)]:[MC(`commandPalette`),MC(`commandPalette`,1)]})]}),(0,q.jsxs)(_T,{className:`HelpDialog__island--editor`,caption:J(`helpDialog.editor`),children:[(0,q.jsx)(Q,{label:J(`helpDialog.createFlowchart`),shortcuts:[M(`CtrlOrCmd+Arrow Key`)],isOr:!0}),(0,q.jsx)(Q,{label:J(`helpDialog.navigateFlowchart`),shortcuts:[M(`Alt+Arrow Key`)],isOr:!0}),(0,q.jsx)(Q,{label:J(`labels.moveCanvas`),shortcuts:[M(`Space+${J(`helpDialog.drag`)}`),M(`Wheel+${J(`helpDialog.drag`)}`)],isOr:!0}),(0,q.jsx)(Q,{label:J(`buttons.clearReset`),shortcuts:[M(`CtrlOrCmd+Delete`)]}),(0,q.jsx)(Q,{label:J(`labels.delete`),shortcuts:[M(`Delete`)]}),(0,q.jsx)(Q,{label:J(`labels.cut`),shortcuts:[M(`CtrlOrCmd+X`)]}),(0,q.jsx)(Q,{label:J(`labels.copy`),shortcuts:[M(`CtrlOrCmd+C`)]}),(0,q.jsx)(Q,{label:J(`labels.paste`),shortcuts:[M(`CtrlOrCmd+V`)]}),(0,q.jsx)(Q,{label:J(`labels.pasteAsPlaintext`),shortcuts:[M(`CtrlOrCmd+Shift+V`)]}),(0,q.jsx)(Q,{label:J(`labels.selectAll`),shortcuts:[M(`CtrlOrCmd+A`)]}),(0,q.jsx)(Q,{label:J(`labels.multiSelect`),shortcuts:[M(`Shift+${J(`helpDialog.click`)}`)]}),(0,q.jsx)(Q,{label:J(`helpDialog.deepSelect`),shortcuts:[M(`CtrlOrCmd+${J(`helpDialog.click`)}`)]}),(0,q.jsx)(Q,{label:J(`helpDialog.deepBoxSelect`),shortcuts:[M(`CtrlOrCmd+${J(`helpDialog.drag`)}`)]}),(se||gi)&&(0,q.jsx)(Q,{label:J(`labels.copyAsPng`),shortcuts:[M(`Shift+Alt+C`)]}),(0,q.jsx)(Q,{label:J(`labels.copyStyles`),shortcuts:[M(`CtrlOrCmd+Alt+C`)]}),(0,q.jsx)(Q,{label:J(`labels.pasteStyles`),shortcuts:[M(`CtrlOrCmd+Alt+V`)]}),(0,q.jsx)(Q,{label:J(`labels.sendToBack`),shortcuts:[M(Ri?`CtrlOrCmd+Alt+[`:`CtrlOrCmd+Shift+[`)]}),(0,q.jsx)(Q,{label:J(`labels.bringToFront`),shortcuts:[M(Ri?`CtrlOrCmd+Alt+]`:`CtrlOrCmd+Shift+]`)]}),(0,q.jsx)(Q,{label:J(`labels.sendBackward`),shortcuts:[M(`CtrlOrCmd+[`)]}),(0,q.jsx)(Q,{label:J(`labels.bringForward`),shortcuts:[M(`CtrlOrCmd+]`)]}),(0,q.jsx)(Q,{label:J(`labels.alignTop`),shortcuts:[M(`CtrlOrCmd+Shift+Up`)]}),(0,q.jsx)(Q,{label:J(`labels.alignBottom`),shortcuts:[M(`CtrlOrCmd+Shift+Down`)]}),(0,q.jsx)(Q,{label:J(`labels.alignLeft`),shortcuts:[M(`CtrlOrCmd+Shift+Left`)]}),(0,q.jsx)(Q,{label:J(`labels.alignRight`),shortcuts:[M(`CtrlOrCmd+Shift+Right`)]}),(0,q.jsx)(Q,{label:J(`labels.duplicateSelection`),shortcuts:[M(`CtrlOrCmd+D`),M(`Alt+${J(`helpDialog.drag`)}`)]}),(0,q.jsx)(Q,{label:J(`helpDialog.toggleElementLock`),shortcuts:[M(`CtrlOrCmd+Shift+L`)]}),(0,q.jsx)(Q,{label:J(`buttons.undo`),shortcuts:[M(`CtrlOrCmd+Z`)]}),(0,q.jsx)(Q,{label:J(`buttons.redo`),shortcuts:$e?[M(`CtrlOrCmd+Y`),M(`CtrlOrCmd+Shift+Z`)]:[M(`CtrlOrCmd+Shift+Z`)]}),(0,q.jsx)(Q,{label:J(`labels.group`),shortcuts:[M(`CtrlOrCmd+G`)]}),(0,q.jsx)(Q,{label:J(`labels.ungroup`),shortcuts:[M(`CtrlOrCmd+Shift+G`)]}),(0,q.jsx)(Q,{label:J(`labels.flipHorizontal`),shortcuts:[M(`Shift+H`)]}),(0,q.jsx)(Q,{label:J(`labels.flipVertical`),shortcuts:[M(`Shift+V`)]}),(0,q.jsx)(Q,{label:J(`labels.showStroke`),shortcuts:[M(`S`)]}),(0,q.jsx)(Q,{label:J(`labels.showBackground`),shortcuts:[M(`G`)]}),(0,q.jsx)(Q,{label:J(`labels.showFonts`),shortcuts:[M(`Shift+F`)]}),(0,q.jsx)(Q,{label:J(`labels.decreaseFontSize`),shortcuts:[M(`CtrlOrCmd+Shift+<`)]}),(0,q.jsx)(Q,{label:J(`labels.increaseFontSize`),shortcuts:[M(`CtrlOrCmd+Shift+>`)]})]})]})]})}),ST=4,CT=8,wT=({shouldWrap:e,children:t,username:n})=>e?(0,q.jsx)(Bb,{label:n||`Unknown user`,children:t}):(0,q.jsx)(q.Fragment,{children:t}),TT=({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,q.jsx)(wT,{username:t.username,shouldWrap:i,children:s},n)},ET=[`avatarUrl`,`id`,`socketId`,`username`,`isInCall`,`isSpeaking`,`isMuted`],DT=K.memo(({className:e,mobile:t,collaborators:n,userToFollow:r})=>{let i=Mk(),a=new Map;n.forEach((e,t)=>{let n=e.id||t;a.set(n,{...e,socketId:t})});let o=Array.from(a.values()).filter(e=>e.username?.trim()),[s,c]=K.useState(``),l=o.filter(e=>e.username?.toLowerCase().includes(s)),u=K.useRef(null);(0,K.useLayoutEffect)(()=>{if(u.current){let e=e=>{f(Math.max(1,Math.min(8,Math.floor(e/38))))};if(e(u.current.clientWidth),!_a)return;let t=new ResizeObserver(t=>{for(let n of t){let{width:t}=n.contentRect;e(t)}});return t.observe(u.current),()=>{t.disconnect()}}},[]);let[d,f]=K.useState(ST),p=o.slice(0,d-1).map(e=>TT({actionManager:i,collaborator:e,socketId:e.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:e.socketId===r}));return t?(0,q.jsx)(`div`,{className:L(`UserList UserList_mobile`,e),children:o.map(e=>TT({actionManager:i,collaborator:e,socketId:e.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:e.socketId===r}))}):(0,q.jsx)(`div`,{className:`UserList__wrapper`,ref:u,children:(0,q.jsxs)(`div`,{className:L(`UserList`,e),style:{"--max-avatars":d},children:[p,o.length>d-1&&(0,q.jsxs)(Ag,{children:[(0,q.jsxs)(jg,{className:`UserList__more`,children:[`+`,o.length-d+1]}),(0,q.jsx)(Ng,{style:{zIndex:2,width:`15rem`,textAlign:`left`},align:`end`,sideOffset:10,children:(0,q.jsxs)(Xy,{padding:2,children:[o.length>=CT&&(0,q.jsx)(cb,{placeholder:J(`quickSearch.placeholder`),onChange:c}),(0,q.jsx)(lb,{className:`dropdown-menu UserList__collaborators`,placeholder:J(`userList.empty`),children:l.length>0?[(0,q.jsx)(`div`,{className:`hint`,children:J(`userList.hint.text`)}),l.map(e=>TT({actionManager:i,collaborator:e,socketId:e.socketId,withName:!0,isBeingFollowed:e.socketId===r}))]:[]}),(0,q.jsx)(Pg,{width:20,height:10,style:{fill:`var(--popup-bg-color)`,filter:`drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)`}})]})})]})]})})},(e,t)=>{if(e.collaborators.size!==t.collaborators.size||e.mobile!==t.mobile||e.className!==t.className||e.userToFollow!==t.userToFollow)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||!Xt(i,e,ET))return!1}return!0}),OT=({children:e,color:t})=>(0,q.jsx)(`div`,{className:`Card`,style:{"--card-color":t===`primary`?`var(--color-primary)`:As[t][7],"--card-color-darker":t===`primary`?`var(--color-primary-darker)`:As[t][8],"--card-color-darkest":t===`primary`?`var(--color-primary-darkest)`:As[t][9]},children:e}),kT=({elements:e,appState:t,setAppState:n,files:r,actionManager:i,exportOpts:a,canvas:o,onCloseRequest:s})=>{let{onExportToBackend:c}=a;return(0,q.jsx)(`div`,{className:`ExportDialog ExportDialog--json`,children:(0,q.jsxs)(`div`,{className:`ExportDialog-cards`,children:[a.saveFileToDisk&&(0,q.jsxs)(OT,{color:`lime`,children:[(0,q.jsx)(`div`,{className:`Card-icon`,children:tu}),(0,q.jsx)(`h2`,{children:J(`exportDialog.disk_title`)}),(0,q.jsxs)(`div`,{className:`Card-details`,children:[J(`exportDialog.disk_details`),!Ni&&i.renderAction(`changeProjectName`)]}),(0,q.jsx)(Y,{className:`Card-button`,type:`button`,title:J(`exportDialog.disk_button`),"aria-label":J(`exportDialog.disk_button`),showAriaLabel:!0,onClick:()=>{i.executeAction(lx,`ui`)}})]}),c&&(0,q.jsxs)(OT,{color:`pink`,children:[(0,q.jsx)(`div`,{className:`Card-icon`,children:Xe}),(0,q.jsx)(`h2`,{children:J(`exportDialog.link_title`)}),(0,q.jsx)(`div`,{className:`Card-details`,children:J(`exportDialog.link_details`)}),(0,q.jsx)(Y,{className:`Card-button`,type:`button`,title:J(`exportDialog.link_button`),"aria-label":J(`exportDialog.link_button`),showAriaLabel:!0,onClick:async()=>{try{X(`export`,`link`,`ui (${bo()})`),await c(e,t,r),s()}catch(e){n({errorMessage:e.message})}}})]}),a.renderCustomUI&&a.renderCustomUI(e,t,r,o)]})})},AT=({elements:e,appState:t,files:n,actionManager:r,exportOpts:i,canvas:a,setAppState:o})=>{let s=K.useCallback(()=>{o({openDialog:null})},[o]);return(0,q.jsx)(q.Fragment,{children:t.openDialog?.name===`jsonExport`&&(0,q.jsx)(OC,{onCloseRequest:s,title:J(`buttons.export`),children:(0,q.jsx)(kT,{elements:e,appState:t,setAppState:o,files:n,actionManager:r,onCloseRequest:s,exportOpts:i,canvas:a})})})},jT=e=>(0,q.jsx)(`button`,{className:`help-icon`,onClick:e.onClick,type:`button`,title:`${J(`helpDialog.title`)} \u2014 ?`,"aria-label":J(`helpDialog.title`),children:ti}),MT=({appState:e,actionManager:t,showExitZenModeBtn:n,renderWelcomeScreen:r})=>{let{FooterCenterTunnel:i,WelcomeScreenHelpHintTunnel:a}=RC(),o=Dk(),s=!e.viewModeEnabled&&e.multiElement&&o.isTouchScreen;return(0,q.jsxs)(`footer`,{role:`contentinfo`,className:`layer-ui__wrapper__footer App-menu App-menu_bottom`,children:[(0,q.jsx)(`div`,{className:L(`layer-ui__wrapper__footer-left zen-mode-transition`,{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:(0,q.jsx)(PS.Col,{gap:2,children:(0,q.jsxs)(rT,{heading:`canvasActions`,children:[(0,q.jsx)(GC,{renderAction:t.renderAction,zoom:e.zoom}),!e.viewModeEnabled&&(0,q.jsx)(KC,{renderAction:t.renderAction,className:L(`zen-mode-transition`,{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})}),s&&(0,q.jsx)(JC,{renderAction:t.renderAction,className:L(`zen-mode-transition`,{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled})})]})})}),(0,q.jsx)(i.Out,{}),(0,q.jsx)(`div`,{className:L(`layer-ui__wrapper__footer-right zen-mode-transition`,{"transition-right":e.zenModeEnabled}),children:(0,q.jsxs)(`div`,{style:{position:`relative`},children:[r&&(0,q.jsx)(a.Out,{}),(0,q.jsx)(jT,{onClick:()=>t.executeAction(hx)})]})}),(0,q.jsx)(qC,{actionManager:t,showExitZenModeBtn:n})]})},NT=MT;MT.displayName=`Footer`;var PT=K.createContext({}),FT=({children:e,className:t})=>{let n=Dk(),r=(0,K.useContext)(PT),i=!!(n.editor.canFitSidebar&&r.shouldRenderDockButton);return(0,q.jsxs)(`div`,{className:L(`sidebar__header`,t),"data-testid":`sidebar-header`,children:[e,(0,q.jsxs)(`div`,{className:`sidebar__header__buttons`,children:[i&&(0,q.jsx)(Bb,{label:J(`labels.sidebarLock`),children:(0,q.jsx)(kC,{onSelect:()=>r.onDock?.(!r.docked),selected:!!r.docked,className:`sidebar__dock`,"data-testid":`sidebar-dock`,"aria-label":J(`labels.sidebarLock`),children:d})}),(0,q.jsx)(kC,{"data-testid":`sidebar-close`,className:`sidebar__close`,onSelect:r.onCloseRequest,"aria-label":J(`buttons.close`),children:Us})]})]})};FT.displayName=`SidebarHeader`;var IT=({name:e,tab:t,icon:n,title:r,children:i,onToggle:a,className:o,style:s})=>{let c=jk();return(0,q.jsxs)(`label`,{title:r,className:`sidebar-trigger__label-element`,children:[(0,q.jsx)(`input`,{className:`ToolIcon_type_checkbox`,type:`checkbox`,onChange:n=>{document.querySelector(`.layer-ui__wrapper`)?.classList.remove(`animate`);let r=n.target.checked;c({openSidebar:r?{name:e,tab:t}:null}),a?.(r)},checked:Uy().openSidebar?.name===e,"aria-label":r,"aria-keyshortcuts":`0`}),(0,q.jsxs)(`div`,{className:L(`sidebar-trigger`,o),style:s,children:[n&&(0,q.jsx)(`div`,{children:n}),i&&(0,q.jsx)(`div`,{className:`sidebar-trigger__label`,children:i})]})]})};IT.displayName=`SidebarTrigger`;var LT=({children:e,...t})=>(0,q.jsx)(ov,{className:`sidebar-triggers`,...t,children:e});LT.displayName=`SidebarTabTriggers`;var RT=({children:e,tab:t,onSelect:n,...r})=>(0,q.jsx)(sv,{value:t,asChild:!0,onSelect:n,children:(0,q.jsx)(`button`,{type:`button`,className:`excalidraw-button sidebar-tab-trigger`,...r,children:e})});RT.displayName=`SidebarTabTrigger`;var zT=({children:e,...t})=>{let n=Uy(),r=jk();if(!n.openSidebar)return null;let{name:i}=n.openSidebar;return(0,q.jsx)(av,{className:`sidebar-tabs-root`,value:n.openSidebar.tab,onValueChange:e=>r(t=>({...t,openSidebar:{...t.openSidebar,name:i,tab:e}})),...t,children:e})};zT.displayName=`SidebarTabs`;var BT=({tab:e,children:t,...n})=>(0,q.jsx)(cv,{...n,value:e,"data-testid":e,children:t});BT.displayName=`SidebarTab`;var VT=au(!1),HT=(0,K.forwardRef)(({name:e,children:t,onDock:n,docked:i,className:a,...o},s)=>{r.DEV&&n&&i==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 c=jk(),l=Ov(VT);(0,K.useLayoutEffect)(()=>(l(!!i),()=>{l(!1)}),[l,i]);let u=(0,K.useRef)({});u.current.onCloseRequest=()=>{c({openSidebar:null})},u.current.onDock=e=>n?.(e),u.current=aa(u.current,{docked:i,shouldRenderDockButton:!!n&&i!=null});let d=(0,K.useRef)(null);(0,K.useImperativeHandle)(s,()=>d.current);let f=Dk(),p=(0,K.useCallback)(()=>{document.querySelector(`.Dialog`)||c({openSidebar:null})},[c]);return Gy(d,(0,K.useCallback)(e=>{e.target.closest(`.sidebar-trigger`)||(!i||!f.editor.canFitSidebar)&&p()},[p,i,f.editor.canFitSidebar])),(0,K.useEffect)(()=>{let e=e=>{e.key===E.ESCAPE&&(!i||!f.editor.canFitSidebar)&&p()};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e)}},[p,i,f.editor.canFitSidebar]),(0,q.jsx)(Xy,{...o,className:L(`sidebar`,{"sidebar--docked":i},a),ref:d,children:(0,q.jsx)(PT.Provider,{value:u.current,children:t})})});HT.displayName=`SidebarInner`;var UT=Object.assign((0,K.forwardRef)((e,t)=>{let n=Uy(),{onStateChange:r}=e,i=(0,K.useRef)(n.openSidebar);(0,K.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,K.useState)(!1);return(0,K.useLayoutEffect)(()=>(o(!0),()=>o(!1)),[]),a&&n.openSidebar?.name===e.name?(0,K.createElement)(HT,{...e,ref:t,key:e.name}):null}),{Header:FT,TabTriggers:LT,TabTrigger:RT,Tabs:zT,Tab:BT,Trigger:IT});UT.displayName=`Sidebar`;var WT={};o(WT,{ChangeCanvasBackground:()=>rE,ClearCanvas:()=>tE,CommandPalette:()=>QT,Export:()=>iE,Help:()=>eE,LiveCollaborationTrigger:()=>oE,LoadScene:()=>YT,SaveAsImage:()=>ZT,SaveToActiveFile:()=>XT,SearchMenu:()=>$T,Socials:()=>aE,ToggleTheme:()=>nE});var GT=au({active:!1});async function KT({title:e,description:t,actionLabel:n,color:r}){return new Promise(i=>{Mv.set(GT,{active:!0,onConfirm:()=>i(!0),onClose:()=>i(!1),onReject:()=>i(!1),title:e,description:t,actionLabel:n,color:r})})}var qT=({value:e,shortcut:t,onChange:n,choices:r,children:i,name:a})=>{let o=Dk();return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`dropdown-menu-item-base dropdown-menu-item-bare`,children:[(0,q.jsx)(`label`,{className:`dropdown-menu-item__text`,htmlFor:a,children:i}),(0,q.jsx)(Ow,{name:a,value:e,onChange:n,choices:r})]}),t&&!o.editor.isMobile&&(0,q.jsx)(`div`,{className:`dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned`,children:t})]})};qT.displayName=`DropdownMenuItemContentRadio`;var JT=qT,YT=()=>{let{t:e}=Wv(),t=Mk(),n=kk();return t.isActionEnabled(ux)?(0,q.jsx)(yb,{icon:gl,onSelect:async()=>{(!n.length||await KT({title:e(`overwriteConfirm.modal.loadFromFile.title`),actionLabel:e(`overwriteConfirm.modal.loadFromFile.button`),color:`warning`,description:(0,q.jsx)(HS,{i18nKey:`overwriteConfirm.modal.loadFromFile.description`,bold:e=>(0,q.jsx)(`strong`,{children:e}),br:()=>(0,q.jsx)(`br`,{})})}))&&t.executeAction(ux)},"data-testid":`load-button`,shortcut:MC(`loadScene`),"aria-label":e(`buttons.load`),children:e(`buttons.load`)}):null};YT.displayName=`LoadScene`;var XT=()=>{let{t:e}=Wv(),t=Mk();return t.isActionEnabled(cx)?(0,q.jsx)(yb,{shortcut:MC(`saveScene`),"data-testid":`save-button`,onSelect:()=>t.executeAction(cx),icon:Ci,"aria-label":`${e(`buttons.save`)}`,children:`${e(`buttons.save`)}`}):null};XT.displayName=`SaveToActiveFile`;var ZT=()=>{let e=jk(),{t}=Wv();return(0,q.jsx)(yb,{icon:ys,"data-testid":`image-export-button`,onSelect:()=>e({openDialog:{name:`imageExport`}}),shortcut:MC(`imageExport`),"aria-label":t(`buttons.exportImage`),children:t(`buttons.exportImage`)})};ZT.displayName=`SaveAsImage`;var QT=e=>{let t=jk(),{t:n}=Wv();return(0,q.jsx)(yb,{icon:Gi,"data-testid":`command-palette-button`,onSelect:()=>{X(`command_palette`,`open`,`menu`),t({openDialog:{name:`commandPalette`}})},shortcut:MC(`commandPalette`),"aria-label":n(`commandPalette.title`),className:e?.className,children:n(`commandPalette.title`)})};QT.displayName=`CommandPalette`;var $T=e=>{let{t}=Wv(),n=Mk();return(0,q.jsx)(yb,{icon:ja,"data-testid":`search-menu-button`,onSelect:()=>{n.executeAction(uw)},shortcut:MC(`searchMenu`),"aria-label":t(`search.title`),className:e?.className,children:t(`search.title`)})};$T.displayName=`SearchMenu`;var eE=()=>{let{t:e}=Wv(),t=Mk();return(0,q.jsx)(yb,{"data-testid":`help-menu-item`,icon:ti,onSelect:()=>t.executeAction(hx),shortcut:`?`,"aria-label":e(`helpDialog.title`),children:e(`helpDialog.title`)})};eE.displayName=`Help`;var tE=()=>{let{t:e}=Wv(),t=Ov(XC);return Mk().isActionEnabled(Vb)?(0,q.jsx)(yb,{icon:ge,onSelect:()=>t(`clearCanvas`),"data-testid":`clear-canvas-button`,"aria-label":e(`buttons.clearReset`),children:e(`buttons.clearReset`)}):null};tE.displayName=`ClearCanvas`;var nE=e=>{let{t}=Wv(),n=Uy(),r=Mk(),i=MC(`toggleTheme`);return r.isActionEnabled(Jb)?e?.allowSystemTheme?(0,q.jsx)(JT,{name:`theme`,value:e.theme,onChange:t=>e.onSelect(t),choices:[{value:B.LIGHT,label:us,ariaLabel:`${t(`buttons.lightMode`)} - ${i}`},{value:B.DARK,label:la,ariaLabel:`${t(`buttons.darkMode`)} - ${i}`},{value:`system`,label:lt,ariaLabel:t(`buttons.systemMode`)}],children:t(`labels.theme`)}):(0,q.jsx)(yb,{onSelect:t=>{if(t.preventDefault(),e?.onSelect)e.onSelect(n.theme===B.DARK?B.LIGHT:B.DARK);else return r.executeAction(Jb)},icon:n.theme===B.DARK?us:la,"data-testid":`toggle-dark-mode`,shortcut:i,"aria-label":n.theme===B.DARK?t(`buttons.lightMode`):t(`buttons.darkMode`),children:n.theme===B.DARK?t(`buttons.lightMode`):t(`buttons.darkMode`)}):null};nE.displayName=`ToggleTheme`;var rE=()=>{let{t:e}=Wv(),t=Uy(),n=Mk(),r=Ek();return t.viewModeEnabled||!r.UIOptions.canvasActions.changeViewBackgroundColor?null:(0,q.jsxs)(`div`,{style:{marginTop:`0.5rem`},children:[(0,q.jsx)(`div`,{"data-testid":`canvas-background-label`,style:{fontSize:`.75rem`,marginBottom:`.5rem`},children:e(`labels.canvasBackground`)}),(0,q.jsx)(`div`,{style:{padding:`0 0.625rem`},children:n.renderAction(`changeViewBackgroundColor`)})]})};rE.displayName=`ChangeCanvasBackground`;var iE=()=>{let{t:e}=Wv(),t=jk();return(0,q.jsx)(yb,{icon:ss,onSelect:()=>{t({openDialog:{name:`jsonExport`}})},"data-testid":`json-export-button`,"aria-label":e(`buttons.export`),children:e(`buttons.export`)})};iE.displayName=`Export`;var aE=()=>{let{t:e}=Wv();return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(nC,{icon:lr,href:`https://github.com/excalidraw/excalidraw`,"aria-label":`GitHub`,children:`GitHub`}),(0,q.jsx)(nC,{icon:vn,href:`https://x.com/excalidraw`,"aria-label":`X`,children:e(`labels.followUs`)}),(0,q.jsx)(nC,{icon:sc,href:`https://discord.gg/UexuTaE`,"aria-label":`Discord`,children:e(`labels.discordChat`)})]})};aE.displayName=`Socials`;var oE=({onSelect:e,isCollaborating:t})=>{let{t:n}=Wv();return(0,q.jsx)(yb,{"data-testid":`collab-button`,icon:Tl,className:L({"active-collab":t}),onSelect:e,children:n(`labels.liveCollaboration`)})};oE.displayName=`LiveCollaborationTrigger`;var sE=(e,t)=>{let n=au(0),r=e=>{let{tunnelsJotai:{useAtom:r}}=RC(),[,i]=r(n),a=(0,K.useRef)({preferHost:!1,counter:0});return(0,K.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,q.jsx)(t,{...e})};return r.displayName=e,r},cE=Object.assign(sE(`MainMenu`,({children:e,onSelect:t})=>{let{MainMenuTunnel:n}=RC(),r=Dk(),i=Uy(),a=jk(),o=r.editor.isMobile?void 0:()=>a({openMenu:null});return(0,q.jsx)(n.In,{children:(0,q.jsxs)(Z,{open:i.openMenu===`canvas`,children:[(0,q.jsx)(Z.Trigger,{onToggle:()=>{a({openMenu:i.openMenu===`canvas`?null:`canvas`})},"data-testid":`main-menu-trigger`,className:`main-menu-trigger`,children:_s}),(0,q.jsxs)(Z.Content,{onClickOutside:o,onSelect:Rl(t,()=>{a({openMenu:null})}),children:[e,r.editor.isMobile&&i.collaborators.size>0&&(0,q.jsxs)(`fieldset`,{className:`UserList-Wrapper`,children:[(0,q.jsx)(`legend`,{children:J(`labels.collaborators`)}),(0,q.jsx)(DT,{mobile:!0,collaborators:i.collaborators,userToFollow:i.userToFollow?.socketId||null})]})]})]})})}),{Trigger:Z.Trigger,Item:Z.Item,ItemLink:Z.ItemLink,ItemCustom:Z.ItemCustom,Group:Z.Group,Separator:Z.Separator,DefaultItems:WT}),lE=({title:e,children:t,actionLabel:n,onClick:r})=>(0,q.jsxs)(`div`,{className:`OverwriteConfirm__Actions__Action`,children:[(0,q.jsx)(`h4`,{children:e}),(0,q.jsx)(`div`,{className:`OverwriteConfirm__Actions__Action__content`,children:t}),(0,q.jsx)(Aw,{variant:`outlined`,color:`muted`,label:n,size:`large`,fullWidth:!0,onClick:r})]}),uE=Object.assign(({children:e})=>(0,q.jsx)(`div`,{className:`OverwriteConfirm__Actions`,children:e}),{ExportToImage:()=>{let{t:e}=Wv(),t=Mk(),n=jk();return(0,q.jsx)(lE,{title:e(`overwriteConfirm.action.exportToImage.title`),actionLabel:e(`overwriteConfirm.action.exportToImage.button`),onClick:()=>{t.executeAction(sx,`ui`,!0),n({openDialog:{name:`imageExport`}})},children:e(`overwriteConfirm.action.exportToImage.description`)})},SaveToDisk:()=>{let{t:e}=Wv(),t=Mk();return(0,q.jsx)(lE,{title:e(`overwriteConfirm.action.saveToDisk.title`),actionLabel:e(`overwriteConfirm.action.saveToDisk.button`),onClick:()=>{t.executeAction(lx,`ui`)},children:e(`overwriteConfirm.action.saveToDisk.description`)})}}),dE=Object.assign(sE(`OverwriteConfirmDialog`,({children:e})=>{let{OverwriteConfirmDialogTunnel:t}=RC(),[n,r]=Dv(GT);return n.active?(0,q.jsx)(t.In,{children:(0,q.jsx)(OC,{onCloseRequest:()=>{n.onClose(),r(e=>({...e,active:!1}))},title:!1,size:916,children:(0,q.jsxs)(`div`,{className:`OverwriteConfirm`,children:[(0,q.jsx)(`h3`,{children:n.title}),(0,q.jsxs)(`div`,{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${n.color}`,children:[(0,q.jsx)(`div`,{className:`OverwriteConfirm__Description__icon`,children:Va}),(0,q.jsx)(`div`,{children:n.description}),(0,q.jsx)(`div`,{className:`OverwriteConfirm__Description__spacer`}),(0,q.jsx)(Aw,{color:n.color,size:`large`,label:n.actionLabel,onClick:()=>{n.onConfirm(),r(e=>({...e,active:!1}))}})]}),(0,q.jsx)(uE,{children:e})]})})}):null}),{Actions:uE,Action:lE}),fE=au(``),pE=au(null),mE=350,hE=()=>{let e=Tk(),t=jk(),n=(0,K.useRef)(null),[r,i]=Dv(fE),a=r.trim(),[o,s]=(0,K.useState)(!1),[c,l]=(0,K.useState)({nonce:null,items:[]}),u=(0,K.useRef)(null),d=(0,K.useRef)(void 0),[f,p]=Dv(pE);(0,K.useEffect)(()=>{o||(a!==u.current||e.scene.getSceneNonce()!==d.current)&&(u.current=null,SE(a,e,(n,r)=>{l({nonce:Vr(),items:n}),u.current=a,d.current=e.scene.getSceneNonce(),t({searchMatches:n.map(e=>({id:e.textElement.id,focus:!1,matchedLines:e.matchedLines}))})}))},[o,a,e.scene.getNonDeletedElementsMap(),e,t,p,d]);let m=()=>{c.items.length>0&&p(e=>e===null?0:(e+1)%c.items.length)},h=()=>{c.items.length>0&&p(e=>e===null?0:e-1<0?c.items.length-1:e-1)};(0,K.useEffect)(()=>{t(e=>({searchMatches:e.searchMatches.map((e,t)=>t===f?{...e,focus:!0}:{...e,focus:!1})}))},[f,t]),(0,K.useEffect)(()=>{if(c.items.length>0&&f!==null){let t=c.items[f];if(t){let n=e.state.zoom.value,r=ds({text:t.searchQuery,x:t.textElement.x+(t.matchedLines[0]?.offsetX??0),y:t.textElement.y+(t.matchedLines[0]?.offsetY??0),width:t.matchedLines[0]?.width,height:t.matchedLines[0]?.height,fontSize:t.textElement.fontSize,fontFamily:t.textElement.fontFamily}),i=t.textElement.fontSize,a=i*n<14;if(!At([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.getEditorUIOffsets())||a){let t;t=a?i>=14?{fitToContent:!0}:{fitToViewport:!0,maxZoom:ma(14/i,1)}:{fitToContent:!0},e.scrollToContent(r,{animate:!0,duration:300,...t,canvasOffsets:e.getEditorUIOffsets()})}}}},[f,c,e]),(0,K.useEffect)(()=>()=>{p(null),u.current=null,d.current=void 0,t({searchMatches:[]}),s(!1)},[t,p]);let g=Ky({goToNextItem:m,goToPreviousItem:h,searchMatches:c});(0,K.useEffect)(()=>Vs(window,`keydown`,r=>{if(r.key===E.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){r.preventDefault(),r.stopPropagation(),t({openSidebar:null});return}r[E.CTRL_OR_CMD]&&r.key===E.F&&(r.preventDefault(),r.stopPropagation(),n.current?.matches(`:focus`)?t({openSidebar:null}):(e.state.openDialog&&t({openDialog:null}),n.current?.focus(),n.current?.select())),r.target instanceof HTMLElement&&r.target.closest(`.layer-ui__search`)&&g.searchMatches.items.length&&(r.key===E.ENTER&&(r.stopPropagation(),g.goToNextItem()),r.key===E.ARROW_UP?(r.stopPropagation(),g.goToPreviousItem()):r.key===E.ARROW_DOWN&&(r.stopPropagation(),g.goToNextItem()))},{capture:!0,passive:!1}),[t,g,e]);let _=`${c.items.length} ${c.items.length===1?J(`search.singleResult`):J(`search.multipleResults`)}`;return(0,q.jsxs)(`div`,{className:`layer-ui__search`,children:[(0,q.jsx)(`div`,{className:`layer-ui__search-header`,children:(0,q.jsx)(AC,{className:oo.SEARCH_MENU_INPUT_WRAPPER,value:r,ref:n,placeholder:J(`search.placeholder`),icon:ja,onChange:n=>{i(n),s(!0);let r=n.trim();SE(r,e,(n,i)=>{l({nonce:Vr(),items:n}),p(i),u.current=r,d.current=e.scene.getSceneNonce(),t({searchMatches:n.map(e=>({id:e.textElement.id,focus:!1,matchedLines:e.matchedLines}))}),s(!1)})},selectOnRender:!0})}),(0,q.jsxs)(`div`,{className:`layer-ui__search-count`,children:[c.items.length>0&&(0,q.jsxs)(q.Fragment,{children:[f!==null&&f>-1?(0,q.jsxs)(`div`,{children:[f+1,` / `,_]}):(0,q.jsx)(`div`,{children:_}),(0,q.jsxs)(`div`,{className:`result-nav`,children:[(0,q.jsx)(kC,{onSelect:()=>{m()},className:`result-nav-btn`,children:Oe}),(0,q.jsx)(kC,{onSelect:()=>{h()},className:`result-nav-btn`,children:Ae})]})]}),c.items.length===0&&a&&u.current&&(0,q.jsx)(`div`,{style:{margin:`1rem auto`},children:J(`search.noMatch`)})]}),(0,q.jsx)(_E,{matches:c,onItemClick:p,focusIndex:f,searchQuery:a})]})},gE=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,q.jsx)(`div`,{tabIndex:-1,className:L(`layer-ui__result-item`,{active:e.highlighted}),onClick:e.onClick,ref:t=>{e.highlighted&&t?.scrollIntoView({behavior:`auto`,block:`nearest`})},children:(0,q.jsx)(`div`,{className:`preview-text`,children:t.flatMap((e,t)=>(0,q.jsx)(K.Fragment,{children:t===2?(0,q.jsx)(`b`,{children:e}):e},t))})})},_E=(0,K.memo)(e=>(0,q.jsx)(`div`,{className:`layer-ui__search-result-container`,children:e.matches.items.map((t,n)=>(0,q.jsx)(gE,{searchQuery:e.searchQuery,preview:t.preview,highlighted:n===e.focusIndex,onClick:()=>e.onItemClick(n)},t.textElement.id+t.index))}),(e,t)=>e.matches.nonce===t.matches.nonce&&e.focusIndex===t.focusIndex),vE=(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}},yE=(e,t)=>{let n=e.split(`
46
+ `),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(`
47
+ `)},bE=(e,t,n)=>{let r=yE(e.text,e.originalText).split(`
48
+ `),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=yn(r,Ds(e),e.lineHeight);if(r===``&&(a.width=0),e.textAlign!==`left`&&t.line.length>0){let n=yn(t.line,Ds(e),e.lineHeight),r=e.textAlign===`center`?(e.width-n.width)/2:e.width-n.width;a.width+=r}let{width:o,height:u}=yn(i,Ds(e),e.lineHeight),d=a.width,f=t.lineNumber*a.height;l.push({offsetX:d,offsetY:f,width:o,height:u}),s+=n}}return l},xE=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,`\\$&`),SE=(0,lv.default)((e,t,n)=>{if(!e||e===``){n([],null);return}let r=t.scene.getNonDeletedElements().filter(e=>I(e));r.sort((e,t)=>e.y-t.y);let i=[],a=new RegExp(xE(e),`gi`);for(let t of r){let n=null,r=t.originalText;for(;(n=a.exec(r))!==null;){let a=vE(r,n.index,e),o=bE(t,e,n.index);o.length>0&&i.push({textElement:t,searchQuery:e,preview:a,index:n.index,matchedLines:o})}}let o=new Set(t.visibleElements.map(e=>e.id));n(i,i.findIndex(e=>o.has(e.textElement.id))??null)},mE),CE=sE(`DefaultSidebarTrigger`,e=>{let{DefaultSidebarTriggerTunnel:t}=RC();return(0,q.jsx)(t.In,{children:(0,q.jsx)(UT.Trigger,{...e,className:`default-sidebar-trigger`,name:Bs.name})})});CE.displayName=`DefaultSidebarTrigger`;var wE=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:t}=RC();return(0,q.jsx)(t.In,{children:e})};wE.displayName=`DefaultTabTriggers`;var TE=Object.assign(sE(`DefaultSidebar`,({children:e,className:t,onDock:n,docked:r,...i})=>{let a=Uy(),o=jk(),{DefaultSidebarTabTriggersTunnel:s}=RC(),c=a.openSidebar?.tab===qr;return(0,K.createElement)(UT,{...i,name:`default`,key:`default`,className:L(`default-sidebar`,t),docked:c||(r??a.defaultSidebarDockedPreference),onDock:c||n===!1||!n&&r!=null?void 0:Rl(n,e=>{o({defaultSidebarDockedPreference:e})})},(0,q.jsxs)(UT.Tabs,{children:[(0,q.jsx)(UT.Header,{children:(0,q.jsxs)(UT.TabTriggers,{children:[(0,q.jsx)(UT.TabTrigger,{tab:qr,children:ja}),(0,q.jsx)(UT.TabTrigger,{tab:Mc,children:mn}),(0,q.jsx)(s.Out,{})]})}),(0,q.jsx)(UT.Tab,{tab:Mc,children:(0,q.jsx)(EC,{})}),(0,q.jsx)(UT.Tab,{tab:qr,children:(0,q.jsx)(hE,{})}),e]}))}),{Trigger:CE,TabTriggers:wE}),EE=`small`,DE=e=>(0,q.jsxs)(`label`,{className:L(`ToolIcon ToolIcon__LaserPointer`,`ToolIcon_size_${EE}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[(0,q.jsx)(`input`,{className:`ToolIcon_type_checkbox`,type:`checkbox`,name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":`toolbar-LaserPointer`}),(0,q.jsx)(`div`,{className:`ToolIcon__icon`,children:Vc})]}),OE=({canvasRef:e,setError:t})=>{let n=e.current;if(!n)return;let r=n.parentElement;r&&(r.style.background=``,t(null),n.replaceChildren())},kE=async({canvasRef:e,mermaidToExcalidrawLib:t,mermaidDefinition:n,setError:r,data:i})=>{let a=e.current,o=a?.parentElement;if(!(!a||!o)){if(!n){OE({canvasRef:e,setError:r});return}try{let e=await t.api,s;try{s=await e.parseMermaidToExcalidraw(n)}catch{s=await e.parseMermaidToExcalidraw(n.replace(/"/g,`'`))}let{elements:c,files:l={}}=s;r(null),i.current={elements:dO(c,{regenerateIds:!0}),files:l};let u=await es({elements:i.current.elements,files:i.current.files,exportPadding:10,maxWidthOrHeight:Math.max(o.offsetWidth,o.offsetHeight)*window.devicePixelRatio});try{await zo(u)}catch(e){throw e.name===`CANVAS_POSSIBLY_TOO_BIG`?Error(J(`canvasError.canvasTooBig`)):e}o.style.background=`var(--default-bg-color)`,a.replaceChildren(u)}catch(e){throw o.style.background=`var(--default-bg-color)`,n&&r(e),e}}},AE=e=>{GS.set(al.MERMAID_TO_EXCALIDRAW,e)},jE=({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`,fitToContent:!0}),e.setOpenDialog(null),r&&n&&AE(n))},ME=({children:e})=>(0,q.jsx)(`div`,{className:`ttd-dialog-panels`,children:e}),NE=({label:e,children:t,panelAction:n,panelActionDisabled:r=!1,onTextSubmitInProgess:i,renderTopRight:a,renderSubmitShortcut:o,renderBottomRight:s})=>(0,q.jsxs)(`div`,{className:`ttd-dialog-panel`,children:[(0,q.jsxs)(`div`,{className:`ttd-dialog-panel__header`,children:[(0,q.jsx)(`label`,{children:e}),a?.()]}),t,(0,q.jsxs)(`div`,{className:L(`ttd-dialog-panel-button-container`,{invisible:!n}),style:{display:`flex`,alignItems:`center`},children:[(0,q.jsxs)(kC,{className:`ttd-dialog-panel-button`,onSelect:n?n.action:()=>{},disabled:r||i,children:[(0,q.jsxs)(`div`,{className:L({invisible:i}),children:[n?.label,n?.icon&&(0,q.jsx)(`span`,{children:n.icon})]}),i&&(0,q.jsx)(Gv,{})]}),!r&&!i&&o?.(),s?.()]})]}),PE=({input:e,placeholder:t,onChange:n,onKeyboardSubmit:r})=>{let i=(0,K.useRef)(null),a=(0,K.useRef)(r);return a.current=r,(0,K.useEffect)(()=>{if(!a.current)return;let e=i.current;if(e){let t=e=>{e[E.CTRL_OR_CMD]&&e.key===E.ENTER&&(e.preventDefault(),a.current?.())};return e.addEventListener(`keydown`,t),()=>{e.removeEventListener(`keydown`,t)}}},[]),(0,q.jsx)(`textarea`,{className:`ttd-dialog-input`,onChange:n,value:e,placeholder:t,autoFocus:!0,ref:i})},FE=({error:e})=>(0,q.jsxs)(`div`,{"data-testid":`ttd-dialog-output-error`,className:`ttd-dialog-output-error`,children:[`Error! `,(0,q.jsx)(`p`,{children:e})]}),IE=({error:e,canvasRef:t,loaded:n})=>(0,q.jsxs)(`div`,{className:`ttd-dialog-output-wrapper`,children:[e&&(0,q.jsx)(FE,{error:e.message}),n?(0,q.jsx)(`div`,{ref:t,style:{opacity:e?`0.15`:1},className:`ttd-dialog-output-canvas-container`}):(0,q.jsx)(Gv,{size:`2rem`})]}),LE=()=>(0,q.jsxs)(`div`,{className:`ttd-dialog-submit-shortcut`,children:[(0,q.jsx)(`div`,{className:`ttd-dialog-submit-shortcut__key`,children:M(`CtrlOrCmd`)}),(0,q.jsx)(`div`,{className:`ttd-dialog-submit-shortcut__key`,children:M(`Enter`)})]}),RE=`flowchart TD
49
+ A[Christmas] -->|Get money| B(Go shopping)
50
+ B --> C{Let me think}
51
+ C -->|One| D[Laptop]
52
+ C -->|Two| E[iPhone]
53
+ C -->|Three| F[Car]`,zE=Ec(AE,300),BE=({mermaidToExcalidrawLib:e})=>{let[t,n]=(0,K.useState)(()=>GS.get(al.MERMAID_TO_EXCALIDRAW)||RE),r=(0,K.useDeferredValue)(t.trim()),[i,a]=(0,K.useState)(null),o=(0,K.useRef)(null),s=(0,K.useRef)({elements:[],files:null}),c=Tk();(0,K.useEffect)(()=>{kE({canvasRef:o,data:s,mermaidToExcalidrawLib:e,setError:a,mermaidDefinition:r}).catch(e=>{Me()&&console.error(`Failed to parse mermaid definition`,e)}),zE(r)},[r,e]),(0,K.useEffect)(()=>()=>{zE.flush()},[]);let l=()=>{jE({app:c,data:s,text:t,shouldSaveMermaidDataToStorage:!0})};return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`ttd-dialog-desc`,children:(0,q.jsx)(HS,{i18nKey:`mermaid.description`,flowchartLink:e=>(0,q.jsx)(`a`,{href:`https://mermaid.js.org/syntax/flowchart.html`,children:e}),sequenceLink:e=>(0,q.jsx)(`a`,{href:`https://mermaid.js.org/syntax/sequenceDiagram.html`,children:e}),classLink:e=>(0,q.jsx)(`a`,{href:`https://mermaid.js.org/syntax/classDiagram.html`,children:e})})}),(0,q.jsxs)(ME,{children:[(0,q.jsx)(NE,{label:J(`mermaid.syntax`),children:(0,q.jsx)(PE,{input:t,placeholder:`Write Mermaid diagram defintion here...`,onChange:e=>n(e.target.value),onKeyboardSubmit:()=>{l()}})}),(0,q.jsx)(NE,{label:J(`mermaid.preview`),panelAction:{action:()=>{l()},label:J(`mermaid.button`),icon:oc},renderSubmitShortcut:()=>(0,q.jsx)(LE,{}),children:(0,q.jsx)(IE,{canvasRef:o,loaded:e.loaded,error:i})})]})]})},VE=e=>{let t=jk(),n=(0,K.useRef)(null),r=(0,K.useRef)(0);return(0,q.jsx)(av,{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`&&ic([`text-to-diagram`,`mermaid`],i)&&t({openDialog:{name:e.dialog,tab:i}})},children:e.children})};VE.displayName=`TTDDialogTabs`;var HE=VE,UE=({children:e,...t})=>(0,q.jsx)(ov,{className:`ttd-dialog-triggers`,...t,children:e});UE.displayName=`TTDDialogTabTriggers`;var WE=({children:e,tab:t,onSelect:n,...r})=>(0,q.jsx)(sv,{value:t,asChild:!0,onSelect:n,children:(0,q.jsx)(`button`,{type:`button`,className:`ttd-dialog-tab-trigger`,...r,children:e})});WE.displayName=`TTDDialogTabTrigger`;var GE=({tab:e,children:t,...n})=>(0,q.jsx)(cv,{...n,value:e,children:t});GE.displayName=`TTDDialogTab`;var KE=3,qE=1e3,JE=au(null),YE=au(null),XE=e=>{let t=Uy();return t.openDialog?.name===`ttd`?(0,q.jsx)(ZE,{...e,tab:t.openDialog.tab}):null},ZE=sE(`TTDDialogBase`,({tab:e,...t})=>{let r=Tk(),i=jk(),a=(0,K.useRef)(null),[o,s]=Dv(YE),[c,l]=(0,K.useState)(o?.prompt??``),u=c.trim(),d=e=>{l(e.target.value),s(t=>({generatedResponse:t?.generatedResponse??null,prompt:e.target.value}))},[f,p]=(0,K.useState)(!1),[m,h]=Dv(JE),g=async()=>{if(u.length>qE||u.length<KE||f||m?.rateLimitRemaining===0||`__fallback`in t){u.length<KE&&S(Error(`Prompt is too short (min ${KE} characters)`)),u.length>qE&&S(Error(`Prompt is too long (max ${qE} characters)`));return}try{p(!0),X(`ai`,`generate`,`ttd`);let{generatedResponse:e,error:n,rateLimit:r,rateLimitRemaining:i}=await t.onTextSubmit(u);if(typeof e==`string`&&s(t=>({generatedResponse:e,prompt:t?.prompt??null})),Io(r)&&Io(i)&&h({rateLimit:r,rateLimitRemaining:i}),n){S(n);return}if(!e){S(Error(`Generation failed`));return}try{await kE({canvasRef:a,data:b,mermaidToExcalidrawLib:v,setError:S,mermaidDefinition:e}),X(`ai`,`mermaid parse success`,`ttd`)}catch(e){console.info(`%cTTD mermaid render errror: ${e.message}`,`color: red`),console.info(`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
54
+ TTD mermaid definition render errror: ${e.message}`,`color: yellow`),X(`ai`,`mermaid parse failed`,`ttd`),S(Error(`Generated an invalid diagram :(. You may also try a different prompt.`))}}catch(e){let t=e.message;(!t||t===`Failed to fetch`)&&(t=`Request failed`),S(Error(t))}finally{p(!1)}},_=(0,K.useRef)(g);_.current=g;let[v,y]=(0,K.useState)({loaded:!1,api:n(()=>import(`./dist-BWLXExfL.js`),__vite__mapDeps([63,2,3,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78]),import.meta.url)});(0,K.useEffect)(()=>{(async()=>{await v.api,y(e=>({...e,loaded:!0}))})()},[v.api]);let b=(0,K.useRef)({elements:[],files:null}),[x,S]=(0,K.useState)(null);return(0,q.jsx)(OC,{className:`ttd-dialog`,onCloseRequest:()=>{r.setOpenDialog(null)},size:1200,title:!1,...t,autofocus:!1,children:(0,q.jsxs)(HE,{dialog:`ttd`,tab:e,children:[`__fallback`in t&&t.__fallback?(0,q.jsx)(`p`,{className:`dialog-mermaid-title`,children:J(`mermaid.title`)}):(0,q.jsxs)(UE,{children:[(0,q.jsx)(WE,{tab:`text-to-diagram`,children:(0,q.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`},children:[J(`labels.textToDiagram`),(0,q.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`center`,padding:`1px 6px`,marginLeft:`10px`,fontSize:10,borderRadius:`12px`,background:`var(--color-promo)`,color:`var(--color-surface-lowest)`},children:`AI Beta`})]})}),(0,q.jsx)(WE,{tab:`mermaid`,children:`Mermaid`})]}),(0,q.jsx)(GE,{className:`ttd-dialog-content`,tab:`mermaid`,children:(0,q.jsx)(BE,{mermaidToExcalidrawLib:v})}),!(`__fallback`in t)&&(0,q.jsxs)(GE,{className:`ttd-dialog-content`,tab:`text-to-diagram`,children:[(0,q.jsx)(`div`,{className:`ttd-dialog-desc`,children:`Currently we use Mermaid as a middle step, so you'll get best results if you describe a diagram, workflow, flow chart, and similar.`}),(0,q.jsxs)(ME,{children:[(0,q.jsx)(NE,{label:J(`labels.prompt`),panelAction:{action:g,label:`Generate`,icon:oc},onTextSubmitInProgess:f,panelActionDisabled:u.length>qE||m?.rateLimitRemaining===0,renderTopRight:()=>m?(0,q.jsxs)(`div`,{className:`ttd-dialog-rate-limit`,style:{fontSize:12,marginLeft:`auto`,color:m.rateLimitRemaining===0?`var(--color-danger)`:void 0},children:[m.rateLimitRemaining,` requests left today`]}):null,renderSubmitShortcut:()=>(0,q.jsx)(LE,{}),renderBottomRight:()=>{if(typeof o?.generatedResponse==`string`)return(0,q.jsxs)(`div`,{className:`excalidraw-link`,style:{marginLeft:`auto`,fontSize:14},onClick:()=>{typeof o?.generatedResponse==`string`&&(AE(o.generatedResponse),i({openDialog:{name:`ttd`,tab:`mermaid`}}))},children:[`View as Mermaid`,(0,q.jsx)(rb,{icon:oc})]});let e=u.length/qE;return e>.8?(0,q.jsxs)(`div`,{style:{marginLeft:`auto`,fontSize:12,fontFamily:`monospace`,color:e>1?`var(--color-danger)`:void 0},children:[`Length: `,u.length,`/`,qE]}):null},children:(0,q.jsx)(PE,{onChange:d,input:c,placeholder:`Describe what you want to see...`,onKeyboardSubmit:()=>{_.current()}})}),(0,q.jsx)(NE,{label:`Preview`,panelAction:{action:()=>{console.info(`Panel action clicked`),jE({app:r,data:b})},label:`Insert`,icon:oc},children:(0,q.jsx)(IE,{canvasRef:a,error:x,loaded:v.loaded})})]})]})]})})}),QE=.01,$E=(e,t)=>!(t===`height`&&I(e)||t===`width`&&I(e)||t===`angle`&&A(e)),eD=(e,t)=>{let n=e+t/2;return n-n%t},tD=(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),nD=(e,t,n,r,i,a,o,s=!0)=>{let c=r.get(n.id);if(!c)return;let[l,u]=[n.x+n.width/2,n.y+n.height/2],[d,f]=Zc(P(n.x,n.y),P(l,u),n.angle),p=e-d,m=t-f,[h,g]=Zc(P(e,t),P(l+p,u+m),-n.angle);V(c,{x:h,y:g},s),iD(c,r,i,a);let _=dr(n,o);if(_){let e=r.get(_.id);e&&V(e,{x:_.x+p,y:_.y+m},s)}},rD=(e,t)=>{let n=_n(t).map(t=>Wc(e,t).reduce((e,t)=>(e[t.id]=!0,e),{}));return e.filter(e=>!qs(e)).forEach(e=>{n.push({[e.id]:!0})}),n},iD=(e,t,n,r,i)=>{c(e)?jn([e],t,n,r,!0,[],i?.zoom):ga(e,t,i)},aD=({label:e,icon:t,dragInputCallback:n,value:r,elements:i,editable:a=!0,shouldKeepAspectRatio:o,property:s,scene:c,appState:l,sensitivity:u=1})=>{let d=Tk(),f=(0,K.useRef)(null),p=(0,K.useRef)(null),[m,h]=(0,K.useState)(r.toString()),g=(0,K.useRef)(null);g.current||={originalAppState:ui(l),originalElements:i,lastUpdatedValue:m,updatePending:!1},(0,K.useEffect)(()=>{let e=r.toString();h(e),g.current.lastUpdatedValue=e},[r]);let _=(e,t,i)=>{if(!g.current.updatePending)return!1;g.current.updatePending=!1;let a=Number(e);if(isNaN(a)){h(r.toString());return}let l=Number(a.toFixed(2)),u=Number(r);(isNaN(u)||Math.abs(l-u)>=QE)&&(g.current.lastUpdatedValue=e,n({accumulatedChange:0,instantChange:0,originalElements:t,originalElementsMap:d.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:o,shouldChangeByStepSize:!1,scene:c,nextValue:l,property:s,originalAppState:i,setInputValue:e=>h(String(e))}),d.syncActionResult({captureUpdate:j.IMMEDIATELY}))},v=(0,K.useRef)({});return v.current.handleInputValue=_,(0,K.useEffect)(()=>{let e=f.current,t=v.current;return()=>{let n=e?.value;n&&t.handleInputValue?.(n,g.current.originalElements,g.current.originalAppState),window.removeEventListener(`pointermove`,t.onPointerMove,!1),window.removeEventListener(`pointerup`,t.onPointerUp,!1)}},[a]),a?(0,q.jsxs)(`div`,{className:L(`drag-input-container`,!a&&`disabled`),"data-testid":e,children:[(0,q.jsx)(`div`,{className:`drag-input-label`,ref:p,onPointerDown:e=>{if(f.current&&a){document.body.classList.add(`excalidraw-cursor-resize`);let e=Number(f.current.value);isNaN(e)&&(e=0);let t=null,r=d.scene.getNonDeletedElements().reduce((e,t)=>(e.set(t.id,_r(t)),e),new Map),a=i.map(e=>r.get(e.id)),p=ui(l),m=0,g=0,_=e=>{if(t&&r!==null&&a!==null){let i=e.clientX-t.x;i!==0&&(g+=i,Math.abs(g)>=u&&(g=Math.sign(g)*Math.floor(Math.abs(g)/u),m+=g,n({accumulatedChange:m,instantChange:g,originalElements:a,originalElementsMap:r,shouldKeepAspectRatio:o,shouldChangeByStepSize:e.shiftKey,property:s,scene:c,originalAppState:p,setInputValue:e=>h(String(e))}),g=0))}t={x:e.clientX,y:e.clientY}},y=()=>{window.removeEventListener(`pointermove`,_,!1),d.syncActionResult({captureUpdate:j.IMMEDIATELY}),t=null,m=0,g=0,a=null,r=null,document.body.classList.remove(`excalidraw-cursor-resize`),window.removeEventListener(`pointerup`,y,!1)};v.current.onPointerMove=_,v.current.onPointerUp=y,window.addEventListener(`pointermove`,_,!1),window.addEventListener(`pointerup`,y,!1)}},onPointerEnter:()=>{p.current&&(p.current.style.cursor=`ew-resize`)},children:t?(0,q.jsx)(rb,{icon:t}):e}),(0,q.jsx)(`input`,{className:`drag-input`,autoComplete:`off`,spellCheck:`false`,onKeyDown:e=>{if(a){let t=e.target;t instanceof HTMLInputElement&&e.key===E.ENTER&&(_(t.value,i,l),d.focusContainer())}},ref:f,value:m,onChange:e=>{g.current.updatePending=!0,h(e.target.value)},onFocus:e=>{e.target.select(),g.current.originalElements=i,g.current.originalAppState=ui(l)},onBlur:e=>{m?a&&_(e.target.value,g.current.originalElements,g.current.originalAppState):h(r.toString())},disabled:!a})]}):null},oD=10,sD=e=>e.type===`image`,cD=({accumulatedChange:e,originalElements:t,originalElementsMap:n,shouldKeepAspectRatio:r,shouldChangeByStepSize:i,nextValue:a,property:o,originalAppState:s,instantChange:c,scene:l})=>{let u=l.getNonDeletedElementsMap(),d=t[0],f=u.get(d.id);if(d&&f){let t=r||sD(d),l=d.width/d.height;if(s.croppingElementId===d.id){let e=u.get(d.id);if(!e||!El(e)||!e.crop)return;let t=e.crop,n={...t},r=e.scale[0]===-1,i=e.scale[1]===-1,{width:s,height:l}=Ai(e),f=t.naturalWidth/s,p=t.naturalHeight/l,m=r?t.width+t.x:t.naturalWidth-t.x,h=i?t.height+t.y:t.naturalHeight-t.y,g=10*f,_=10*p;if(a!==void 0){if(o===`width`){let e=_e(a*f,g,m);n={...n,width:e,x:r?t.x+t.width-e:t.x}}else if(o===`height`){let e=_e(a*p,_,h);n={...n,height:e,y:i?t.y+t.height-e:t.y}}V(e,{crop:n,width:n.width/(t.naturalWidth/s),height:n.height/(t.naturalHeight/l)});return}let v=o===`width`?c:0,y=o===`height`?c:0,b=_e(t.width+v,g,m),x=_e(t.height+y,g,h);n={...t,x:r?t.x+t.width-b:t.x,y:i?t.y+t.height-x:t.y,width:b,height:x},V(e,{crop:n,width:n.width/(t.naturalWidth/s),height:n.height/(t.naturalHeight/l)});return}if(a!==void 0){js(Math.max(o===`width`?a:t?a*l:d.width,1),Math.max(o===`height`?a:t?a/l:d.height,1),f,d,u,n,o===`width`?`e`:`s`,{shouldMaintainAspectRatio:t});return}let p=o===`width`?e:0,m=o===`height`?e:0,h=Math.max(0,d.width+p);o===`width`&&(h=i?eD(h,oD):Math.round(h));let g=Math.max(0,d.height+m);o===`height`&&(g=i?eD(g,oD):Math.round(g)),t&&(o===`width`?g=Math.round(h/l*100)/100:h=Math.round(g*l*100)/100),g=Math.max(1,g),h=Math.max(1,h),js(h,g,f,d,u,n,o===`width`?`e`:`s`,{shouldMaintainAspectRatio:t})}},lD=({property:e,element:t,scene:n,appState:r})=>{let i=ma(e===`width`?t.width:t.height,2);if(r.croppingElementId&&r.croppingElementId===t.id&&El(t)&&t.crop){let{width:n,height:r}=Ai(t);if(e===`width`){let e=n/t.crop.naturalWidth;i=ma(t.crop.width*e,2)}if(e===`height`){let e=r/t.crop.naturalHeight;i=ma(t.crop.height*e,2)}}return(0,q.jsx)(aD,{label:e===`width`?`W`:`H`,elements:[t],dragInputCallback:cD,value:i,editable:$E(t,e),scene:n,appState:r,property:e})},uD=15,dD=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:n,nextValue:r,scene:i})=>{let a=i.getNonDeletedElementsMap(),o=i.getNonDeletedElements(),s=t[0];if(s&&!U(s)){let t=a.get(s.id);if(!t)return;if(r!==void 0){let e=un(r);V(t,{angle:e}),iD(t,a,o,i);let n=dr(t,a);n&&!st(t)&&V(n,{angle:e});return}let c=(Math.round(wo(s.angle)*100)/100+Math.round(e))%360;n&&(c=eD(c,uD)),c=c<0?c+360:c;let l=un(c);V(t,{angle:l}),iD(t,a,o,i);let u=dr(t,a);u&&!st(t)&&V(u,{angle:l})}},fD=({element:e,scene:t,appState:n,property:r})=>(0,q.jsx)(aD,{label:`A`,icon:ir,value:Math.round(wo(e.angle)%360*100)/100,elements:[e],dragInputCallback:dD,editable:$E(e,`angle`),scene:t,appState:n,property:r}),pD=4,mD=4,hD=({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||!I(t))return;let s;if(r!==void 0)s=Math.max(Math.round(r),pD);else if(o.type===`text`){let t=Math.round(o.fontSize);s=Math.max(t+Math.round(e),pD),n&&(s=eD(s,mD))}s&&(V(t,{fontSize:s}),cs(t,i.getContainerElement(t),i.getNonDeletedElementsMap()))}},gD=({element:e,scene:t,appState:n,property:r})=>{let i=I(e)?e:ws(e)?dr(e,t.getNonDeletedElementsMap()):null;return i?(0,q.jsx)(aD,{label:`F`,value:Math.round(i.fontSize*10)/10,elements:[i],dragInputCallback:hD,icon:On,appState:n,scene:t,property:r}):null},_D=10,vD=(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,...no(r,o,s,!1),...I(r)?{fontSize:r.fontSize*n}:{}}},yD=(e,t,n,r,i,a,o,s)=>{let c=vD(e,t,r,a);V(i,c,!1);let l=dr(a,s);if(l){let e=l.fontSize*r;ga(i,o,{newSize:{width:c.width,height:c.height}});let t=o.get(l.id);t&&I(t)&&(V(t,{fontSize:e},!1),zr(i,o,n===`width`?`e`:`s`,!0))}},bD=(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];yD(i[0],i[1],a,u,n,t,c,l)}},xD=({accumulatedChange:e,originalElements:t,originalElementsMap:n,originalAppState:r,shouldChangeByStepSize:i,nextValue:a,scene:o,property:s})=>{let c=o.getNonDeletedElementsMap(),l=rD(t,r);if(a!==void 0){for(let e of l){let t=tD(e,c,n);if(t.length>1){let e=t.map(e=>e.latest),r=t.map(e=>e.original),[i,o,l,u]=Ao(r),d=l-i,f=u-o,p=d/f;bD(Math.max(1,s===`width`?Math.max(0,a):d),Math.max(1,s===`height`?Math.max(0,a):f),f,p,P(i,o),s,e,r,c,n)}else{let[e]=t,r=e?.latest,o=e?.original;if(r&&o&&$E(r,s)){let e=s===`width`?Math.max(0,a):r.width;s===`width`&&(e=i?eD(e,_D):Math.round(e));let t=s===`height`?Math.max(0,a):r.height;s===`height`&&(t=i?eD(t,_D):Math.round(t)),e=Math.max(1,e),t=Math.max(1,t),js(e,t,r,o,c,n,s===`width`?`e`:`s`,{shouldInformMutation:!1})}}}o.triggerUpdate();return}let u=s===`width`?e:0,d=s===`height`?e:0;for(let e of l){let t=tD(e,c,n);if(t.length>1){let e=t.map(e=>e.latest),r=t.map(e=>e.original),[a,o,l,f]=Ao(r),p=l-a,m=f-o,h=p/m,g=Math.max(0,p+u);s===`width`&&(g=i?eD(g,_D):Math.round(g));let _=Math.max(0,m+d);s===`height`&&(_=i?eD(_,_D):Math.round(_)),g=Math.max(1,g),_=Math.max(1,_),bD(g,_,m,h,P(a,o),s,e,r,c,n)}else{let[e]=t,r=e?.latest,a=e?.original;if(r&&a&&$E(r,s)){let e=Math.max(0,a.width+u);s===`width`&&(e=i?eD(e,_D):Math.round(e));let t=Math.max(0,a.height+d);s===`height`&&(t=i?eD(t,_D):Math.round(t)),e=Math.max(1,e),t=Math.max(1,t),js(e,t,r,a,c,n,s===`width`?`e`:`s`,{shouldInformMutation:!1})}}}o.triggerUpdate()},SD=({property:e,elements:t,elementsMap:n,atomicUnits:r,scene:i,appState:a})=>{let o=(0,K.useMemo)(()=>r.map(t=>{let r=tD(t,n);if(r.length>1){let[t,n,i,a]=Ao(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,q.jsx)(aD,{label:e===`width`?`W`:`H`,elements:t,dragInputCallback:xD,value:s,editable:c,appState:a,property:e,scene:i})},CD=15,wD=({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&&!qs(e)&&$E(e,i)),c=t.filter(e=>!qs(e)&&$E(e,i));if(r!==void 0){let e=un(r);for(let t of s){if(!t)continue;V(t,{angle:e},!1);let n=dr(t,o);n&&!st(t)&&V(n,{angle:e},!1)}a.triggerUpdate();return}for(let t=0;t<s.length;t++){let r=s[t];if(!r)continue;let i=c[t],a=(Math.round(wo(i.angle)*100)/100+Math.round(e))%360;n&&(a=eD(a,CD)),a=a<0?a+360:a;let l=un(a);V(r,{angle:l},!1);let u=dr(r,o);u&&!st(r)&&V(u,{angle:l},!1)}a.triggerUpdate()},TD=({elements:e,scene:t,appState:n,property:r})=>{let i=e.filter(e=>!qs(e)&&$E(e,`angle`)),a=i.map(e=>Math.round(wo(e.angle)%360*100)/100);return(0,q.jsx)(aD,{label:`A`,icon:ir,value:new Set(a).size===1?a[0]:`Mixed`,elements:e,dragInputCallback:wD,editable:i.some(e=>$E(e,`angle`)),appState:n,scene:t,property:r})},ED=4,DD=4,OD=(e,t)=>e.reduce((e,n)=>{if(!n||qs(n))return e;if(I(n))return e.push(n),e;if(ws(n)){let r=dr(n,t);if(r)return e.push(r),e}return e},[]),kD=({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),ED);for(let e of o)V(e,{fontSize:s},!1),cs(e,i.getContainerElement(e),a,!1);i.triggerUpdate()}else{let r=t;for(let t=0;t<o.length;t++){let s=o[t],c=r[t],l=Math.round(c.fontSize),u=Math.max(l+Math.round(e),ED);n&&(u=eD(u,DD)),V(s,{fontSize:u},!1),cs(s,i.getContainerElement(s),a,!1)}i.triggerUpdate()}},AD=({elements:e,scene:t,appState:n,property:r,elementsMap:i})=>{let a=OD(e,i);if(!a.length)return null;let o=a.map(e=>Math.round(e.fontSize*10)/10);return(0,q.jsx)(aD,{label:`F`,icon:On,elements:a,dragInputCallback:kD,value:new Set(o).size===1?o[0]:`Mixed`,editable:o.length>0,scene:t,property:r,appState:n})},jD=10,MD=({accumulatedChange:e,instantChange:t,originalElements:n,originalElementsMap:r,shouldChangeByStepSize:i,nextValue:a,property:o,scene:s,originalAppState:c})=>{let l=s.getNonDeletedElementsMap(),u=s.getNonDeletedElements(),d=n[0],[f,p]=[d.x+d.width/2,d.y+d.height/2],[m,h]=Zc(P(d.x,d.y),P(f,p),d.angle);if(c.croppingElementId===d.id){let e=l.get(d.id);if(!e||!El(e)||!e.crop)return;let n=e.crop,r=n,i=e.scale[0]===-1,s=e.scale[1]===-1,{width:c,height:u}=Ai(e);if(a!==void 0){if(o===`x`){let e=a*(n.naturalWidth/c);r=i?{...n,x:_e(n.naturalWidth-e-n.width,0,n.naturalWidth-n.width)}:{...n,x:_e(a*(n.naturalWidth/c),0,n.naturalWidth-n.width)}}o===`y`&&(r={...n,y:_e(a*(n.naturalHeight/u),0,n.naturalHeight-n.height)}),V(e,{crop:r});return}let f=(o===`x`?t:0)*(i?-1:1),p=(o===`y`?t:0)*(s?-1:1);r={...n,x:_e(n.x+f,0,n.naturalWidth-n.width),y:_e(n.y+p,0,n.naturalHeight-n.height)},V(e,{crop:r});return}if(a!==void 0){nD(o===`x`?a:m,o===`y`?a:h,d,l,u,s,r);return}let g=o===`x`?e:0,_=o===`y`?e:0;nD(o===`x`?Math.round(i?eD(d.x+g,jD):m+g):m,o===`y`?Math.round(i?eD(d.y+_,jD):h+_):h,d,l,u,s,r)},ND=({property:e,element:t,elementsMap:n,scene:r,appState:i})=>{let[a,o]=Zc(P(t.x,t.y),P(t.x+t.width/2,t.y+t.height/2),t.angle),s=ma(e===`x`?a:o,2);if(i.croppingElementId===t.id&&El(t)&&t.crop){let n=Pn(t);n&&(s=ma(e===`x`?n.x:n.y,2))}return(0,q.jsx)(aD,{label:e===`x`?`X`:`Y`,elements:[t],dragInputCallback:MD,scene:r,value:s,property:e,appState:i})},PD=10,FD=(e,t,n,r,i,a,o,s)=>{for(let c=0;c<r.length;c++){let l=i[c],[u,d]=[l.x+l.width/2,l.y+l.height/2],[f,p]=Zc(P(l.x,l.y),P(u,d),l.angle);nD(e===`x`?Math.round(f+t):f,e===`y`?Math.round(p+n):p,l,a,r,s,o,!1)}},ID=(e,t,n,r,i,a,o)=>{let[s,c,,]=Ao(n),l=e-s,u=t-c;for(let e=0;e<n.length;e++){let t=n[e],s=r.get(t.id);if(s&&(!I(s)||!s.containerId)){let[e,n]=[s.x+s.width/2,s.y+s.height/2],[c,d]=Zc(P(s.x,s.y),P(e,n),s.angle);nD(c+l,d+u,t,r,i,o,a,!1)}}},LD=({accumulatedChange:e,originalElements:t,originalElementsMap:n,shouldChangeByStepSize:r,nextValue:i,property:a,scene:o,originalAppState:s})=>{let c=o.getNonDeletedElementsMap(),l=o.getNonDeletedElements();if(i!==void 0){for(let e of rD(t,s)){let t=tD(e,c,n);if(t.length>1){let[e,r,,]=Ao(t.map(e=>e.latest));ID(a===`x`?i:e,a===`y`?i:r,t.map(e=>e.original),c,l,n,o)}else{let e=t[0]?.original,r=t[0]?.latest;if(e&&r&&$E(r,a)){let[t,r]=[e.x+e.width/2,e.y+e.height/2],[s,u]=Zc(P(e.x,e.y),P(t,r),e.angle);nD(a===`x`?i:s,a===`y`?i:u,e,c,l,o,n,!1)}}}o.triggerUpdate();return}let u=r?eD(e,PD):e;FD(a,a===`x`?u:0,a===`y`?u:0,t,t,c,n,o),o.triggerUpdate()},RD=({property:e,elements:t,elementsMap:n,atomicUnits:r,scene:i,appState:a})=>{let o=(0,K.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]=Ao(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]=Zc(P(i.x,i.y),P(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,q.jsx)(aD,{label:e===`x`?`X`:`Y`,elements:t,dragInputCallback:LD,value:s,property:e,scene:i,appState:a})},zD=5,BD=({property:e,scene:t,appState:n,setAppState:r})=>(0,q.jsx)(aD,{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?eD(r.gridStep+zD*Math.sign(t),zD):r.gridStep+t),a?(a=In(a),i(a),{gridStep:a}):(i(r.gridStep),null)})},scene:t,value:n.gridStep,property:e,appState:n}),VD=50,HD=e=>{let t=Ak(),n=e.app.scene.getSceneNonce()||1,r=e.app.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1}),i=ra(e.app);return(0,q.jsx)(GD,{...e,appState:t,sceneNonce:n,selectedElements:r,gridModeEnabled:i})},UD=({children:e,columns:t=1,heading:n,style:r,...i})=>(0,q.jsx)(`div`,{className:L(`exc-stats__row`,{"exc-stats__row--heading":n}),style:{gridTemplateColumns:`repeat(${t}, 1fr)`,...r},...i,children:e});UD.displayName=`StatsRow`;var WD=({children:e,order:t,style:n,...r})=>(0,q.jsx)(`div`,{className:`exc-stats__rows`,style:{order:t,...n},...r,children:e});WD.displayName=`StatsRows`,HD.StatsRow=UD,HD.StatsRows=WD;var GD=(0,K.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=jk(),d=r.length===1?r[0]:null,f=r.length>1?r:null,p=i.croppingElementId&&El(d),m=p?Ai(d):null,[h,g]=(0,K.useState)({width:0,height:0}),_=(0,K.useMemo)(()=>(0,Ig.default)(e=>{let t=Ao(e);g({width:Math.round(t[2])-Math.round(t[0]),height:Math.round(t[3])-Math.round(t[1])})},VD),[]);(0,K.useEffect)(()=>{_(c)},[a,c,_]),(0,K.useEffect)(()=>()=>_.cancel(),[_]);let v=(0,K.useMemo)(()=>rD(r,i),[r,i]),y=(0,K.useMemo)(()=>Uc(r),[r]);return(0,q.jsx)(`div`,{className:`exc-stats`,children:(0,q.jsxs)(Xy,{padding:3,children:[(0,q.jsxs)(`div`,{className:`title`,children:[(0,q.jsx)(`h2`,{children:J(`stats.title`)}),(0,q.jsx)(`div`,{className:`close`,onClick:t,children:Us})]}),(0,q.jsxs)(ib,{label:(0,q.jsx)(`h3`,{children:J(`stats.generalStats`)}),open:!!(i.stats.panels&ks.generalStats),openTrigger:()=>u(e=>({stats:{open:!0,panels:e.stats.panels^ks.generalStats}})),children:[(0,q.jsxs)(WD,{children:[(0,q.jsx)(UD,{heading:!0,children:J(`stats.scene`)}),(0,q.jsxs)(UD,{columns:2,children:[(0,q.jsx)(`div`,{children:J(`stats.shapes`)}),(0,q.jsx)(`div`,{children:c.length})]}),(0,q.jsxs)(UD,{columns:2,children:[(0,q.jsx)(`div`,{children:J(`stats.width`)}),(0,q.jsx)(`div`,{children:h.width})]}),(0,q.jsxs)(UD,{columns:2,children:[(0,q.jsx)(`div`,{children:J(`stats.height`)}),(0,q.jsx)(`div`,{children:h.height})]}),o&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(UD,{heading:!0,children:`Canvas`}),(0,q.jsx)(UD,{children:(0,q.jsx)(BD,{property:`gridStep`,scene:s,appState:i,setAppState:u})})]})]}),n?.(c,i)]}),!y&&r.length>0&&(0,q.jsx)(`div`,{id:`elementStats`,style:{marginTop:12},children:(0,q.jsx)(ib,{label:(0,q.jsx)(`h3`,{children:J(`stats.elementProperties`)}),open:!!(i.stats.panels&ks.elementProperties),openTrigger:()=>u(e=>({stats:{open:!0,panels:e.stats.panels^ks.elementProperties}})),children:(0,q.jsxs)(WD,{children:[d&&(0,q.jsxs)(q.Fragment,{children:[p&&(0,q.jsx)(UD,{heading:!0,children:J(`labels.unCroppedDimension`)}),i.croppingElementId&&El(d)&&m&&(0,q.jsxs)(UD,{columns:2,children:[(0,q.jsx)(`div`,{children:J(`stats.width`)}),(0,q.jsx)(`div`,{children:ma(m.width,2)})]}),i.croppingElementId&&El(d)&&m&&(0,q.jsxs)(UD,{columns:2,children:[(0,q.jsx)(`div`,{children:J(`stats.height`)}),(0,q.jsx)(`div`,{children:ma(m.height,2)})]}),(0,q.jsx)(UD,{heading:!0,"data-testid":`stats-element-type`,children:i.croppingElementId?J(`labels.imageCropping`):J(`element.${d.type}`)}),(0,q.jsx)(UD,{children:(0,q.jsx)(ND,{element:d,property:`x`,elementsMap:l,scene:s,appState:i})}),(0,q.jsx)(UD,{children:(0,q.jsx)(ND,{element:d,property:`y`,elementsMap:l,scene:s,appState:i})}),(0,q.jsx)(UD,{children:(0,q.jsx)(lD,{property:`width`,element:d,scene:s,appState:i})}),(0,q.jsx)(UD,{children:(0,q.jsx)(lD,{property:`height`,element:d,scene:s,appState:i})}),!U(d)&&(0,q.jsx)(UD,{children:(0,q.jsx)(fD,{property:`angle`,element:d,scene:s,appState:i})}),(0,q.jsx)(UD,{children:(0,q.jsx)(gD,{property:`fontSize`,element:d,scene:s,appState:i})})]}),f&&(0,q.jsxs)(q.Fragment,{children:[oa(f)&&(0,q.jsx)(UD,{heading:!0,children:J(`element.group`)}),(0,q.jsxs)(UD,{columns:2,style:{margin:`0.3125rem 0`},children:[(0,q.jsx)(`div`,{children:J(`stats.shapes`)}),(0,q.jsx)(`div`,{children:r.length})]}),(0,q.jsx)(UD,{children:(0,q.jsx)(RD,{property:`x`,elements:f,elementsMap:l,atomicUnits:v,scene:s,appState:i})}),(0,q.jsx)(UD,{children:(0,q.jsx)(RD,{property:`y`,elements:f,elementsMap:l,atomicUnits:v,scene:s,appState:i})}),(0,q.jsx)(UD,{children:(0,q.jsx)(SD,{property:`width`,elements:f,elementsMap:l,atomicUnits:v,scene:s,appState:i})}),(0,q.jsx)(UD,{children:(0,q.jsx)(SD,{property:`height`,elements:f,elementsMap:l,atomicUnits:v,scene:s,appState:i})}),(0,q.jsx)(UD,{children:(0,q.jsx)(TD,{property:`angle`,elements:f,scene:s,appState:i})}),(0,q.jsx)(UD,{children:(0,q.jsx)(AD,{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),KD=({sourceElementId:e,onClose:t,elementsMap:n,appState:r,generateLinkForSelection:i=bc})=>{let a=n.get(e)?.link??null,[o,s]=(0,K.useState)(a),[c,l]=(0,K.useState)(!1);(0,K.useEffect)(()=>{let e=W(n,r),t=a;if(e.length>0&&i){let n=Ca(e,r);n&&(t=on(i(n.id,n.type)))}s(t)},[n,r,r.selectedElementIds,a,i]);let u=(0,K.useCallback)(()=>{if(o&&o!==n.get(e)?.link){let t=n.get(e);t&&V(t,{link:o})}if(!o&&c&&e){let t=n.get(e);t&&V(t,{link:null})}t?.()},[e,o,n,c,t]);return(0,K.useEffect)(()=>{let e=e=>{r.openDialog?.name===`elementLinkSelector`&&e.key===E.ENTER&&u(),r.openDialog?.name===`elementLinkSelector`&&e.key===E.ESCAPE&&t?.()};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[r,t,u]),(0,q.jsxs)(`div`,{className:`ElementLinkDialog`,children:[(0,q.jsxs)(`div`,{className:`ElementLinkDialog__header`,children:[(0,q.jsx)(`h2`,{children:J(`elementLink.title`)}),(0,q.jsx)(`p`,{children:J(`elementLink.desc`)})]}),(0,q.jsxs)(`div`,{className:`ElementLinkDialog__input`,children:[(0,q.jsx)(AC,{value:o??``,onChange:e=>{c||l(!0),s(e)},onKeyDown:e=>{e.key===E.ENTER&&u()},className:`ElementLinkDialog__input-field`,selectOnRender:!0}),a&&o&&(0,q.jsx)(Y,{type:`button`,title:J(`buttons.remove`),"aria-label":J(`buttons.remove`),label:J(`buttons.remove`),onClick:()=>{s(null),l(!0)},className:`ElementLinkDialog__remove`,icon:ge})]}),(0,q.jsxs)(`div`,{className:`ElementLinkDialog__actions`,children:[(0,q.jsx)(US,{label:J(`buttons.cancel`),onClick:()=>{t?.()},style:{marginRight:10}}),(0,q.jsx)(US,{label:J(`buttons.confirm`),onClick:u,actionType:`primary`})]})]})},qD=({UIOptions:e})=>(0,q.jsxs)(cE,{__fallback:!0,children:[(0,q.jsx)(cE.DefaultItems.LoadScene,{}),(0,q.jsx)(cE.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&(0,q.jsx)(cE.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&(0,q.jsx)(cE.DefaultItems.SaveAsImage,{}),(0,q.jsx)(cE.DefaultItems.SearchMenu,{}),(0,q.jsx)(cE.DefaultItems.Help,{}),(0,q.jsx)(cE.DefaultItems.ClearCanvas,{}),(0,q.jsx)(cE.Separator,{}),(0,q.jsx)(cE.Group,{title:`Excalidraw links`,children:(0,q.jsx)(cE.DefaultItems.Socials,{})}),(0,q.jsx)(cE.Separator,{}),(0,q.jsx)(cE.DefaultItems.ToggleTheme,{}),(0,q.jsx)(cE.DefaultItems.ChangeCanvasBackground,{})]}),JD=()=>(0,q.jsxs)(dE,{__fallback:!0,children:[(0,q.jsx)(dE.Actions.SaveToDisk,{}),(0,q.jsx)(dE.Actions.ExportToImage,{})]}),YD=({actionManager:e,appState:t,files:n,setAppState:r,elements:i,canvas:a,onLockToggle:o,onHandToolToggle:s,onPenModeToggle:c,showExitZenModeBtn:l,renderTopRightUI:u,renderCustomStats:d,UIOptions:f,onExportImage:p,renderWelcomeScreen:m,children:h,app:g,isCollaborating:_,generateLinkForSelection:v})=>{let y=Dk(),b=BC(),x=b.tunnelsJotai.Provider,[S,C]=Dv(qy),w=()=>f.canvasActions.export?(0,q.jsx)(AT,{elements:i,appState:t,files:n,actionManager:e,exportOpts:f.canvasActions.export,canvas:a,setAppState:r}):null,T=()=>!f.canvasActions.saveAsImage||t.openDialog?.name!==`imageExport`?null:(0,q.jsx)(Lw,{elements:i,appState:t,files:n,actionManager:e,onExportImage:p,onCloseRequest:()=>r({openDialog:null}),name:g.getName()}),ee=()=>(0,q.jsxs)(`div`,{style:{position:`relative`},children:[(0,q.jsx)(b.MainMenuTunnel.Out,{}),m&&(0,q.jsx)(b.WelcomeScreenMenuHintTunnel.Out,{})]}),te=()=>(0,q.jsx)(rT,{heading:`selectedShapeActions`,className:L(`selected-shape-actions zen-mode-transition`,{"transition-left":t.zenModeEnabled}),children:(0,q.jsx)(Xy,{className:oo.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${t.height-166}px`},children:(0,q.jsx)(UC,{appState:t,elementsMap:g.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:g})})}),ne=()=>{let n=Tr(t,i),r=t.stats.open&&!t.zenModeEnabled&&!t.viewModeEnabled&&t.openDialog?.name!==`elementLinkSelector`;return(0,q.jsx)(Rw,{side:`top`,children:(0,q.jsxs)(`div`,{className:`App-menu App-menu_top`,children:[(0,q.jsxs)(PS.Col,{gap:6,className:L(`App-menu_top__left`),children:[ee(),n&&te()]}),!t.viewModeEnabled&&t.openDialog?.name!==`elementLinkSelector`&&(0,q.jsx)(rT,{heading:`shapes`,className:`shapes-section`,children:e=>(0,q.jsxs)(`div`,{style:{position:`relative`},children:[m&&(0,q.jsx)(b.WelcomeScreenToolbarHintTunnel.Out,{}),(0,q.jsx)(PS.Col,{gap:4,align:`start`,children:(0,q.jsxs)(PS.Row,{gap:1,className:L(`App-toolbar-container`,{"zen-mode":t.zenModeEnabled}),children:[(0,q.jsxs)(Xy,{padding:1,className:L(`App-toolbar`,{"zen-mode":t.zenModeEnabled}),children:[(0,q.jsx)($w,{appState:t,isMobile:y.editor.isMobile,device:y,app:g}),e,(0,q.jsxs)(PS.Row,{gap:1,children:[(0,q.jsx)(uT,{zenModeEnabled:t.zenModeEnabled,checked:t.penMode,onChange:()=>c(null),title:J(`toolBar.penMode`),penDetected:t.penDetected}),(0,q.jsx)(nT,{checked:t.activeTool.locked,onChange:o,title:J(`toolBar.lock`)}),(0,q.jsx)(`div`,{className:`App-toolbar__divider`}),(0,q.jsx)(dT,{checked:Ho(t),onChange:()=>s(),title:J(`toolBar.hand`),isMobile:!0}),(0,q.jsx)(WC,{appState:t,activeTool:t.activeTool,UIOptions:f,app:g})]})]}),_&&(0,q.jsx)(Xy,{style:{marginLeft:8,alignSelf:`center`,height:`fit-content`},children:(0,q.jsx)(DE,{title:J(`toolBar.laser`),checked:t.activeTool.type===Pc.laser,onChange:()=>g.setActiveTool({type:Pc.laser}),isMobile:!0})})]})})]})}),(0,q.jsxs)(`div`,{className:L(`layer-ui__wrapper__top-right zen-mode-transition`,{"transition-right":t.zenModeEnabled}),children:[t.collaborators.size>0&&(0,q.jsx)(DT,{collaborators:t.collaborators,userToFollow:t.userToFollow?.socketId||null}),u?.(y.editor.isMobile,t),!t.viewModeEnabled&&t.openDialog?.name!==`elementLinkSelector`&&(!ie||t.openSidebar?.name!==Bs.name)&&(0,q.jsx)(b.DefaultSidebarTriggerTunnel.Out,{}),r&&(0,q.jsx)(HD,{app:g,onClose:()=>{e.executeAction(qx)},renderCustomStats:d})]})]})})},re=()=>(0,q.jsx)(TE,{__fallback:!0,onDock:e=>{X(`sidebar`,`toggleDock (${e?`dock`:`undock`})`,`(${y.editor.isMobile?`mobile`:`desktop`})`)}}),ie=kv(VT),ae=(0,q.jsxs)(q.Fragment,{children:[h,(0,q.jsx)(qD,{UIOptions:f}),(0,q.jsx)(TE.Trigger,{__fallback:!0,icon:mn,title:Ji(J(`toolBar.library`)),onToggle:e=>{e&&X(`sidebar`,`${Bs.name} (open)`,`button (${y.editor.isMobile?`mobile`:`desktop`})`)},tab:Bs.defaultTab,children:J(`toolBar.library`)}),(0,q.jsx)(JD,{}),t.openDialog?.name===`ttd`&&(0,q.jsx)(XE,{__fallback:!0}),t.isLoading&&(0,q.jsx)(Kv,{delay:250}),t.errorMessage&&(0,q.jsx)(Dw,{onClose:()=>r({errorMessage:null}),children:t.errorMessage}),S&&!y.editor.isMobile&&(0,q.jsx)(Jy,{colorPickerType:S.colorPickerType,onCancel:()=>{C(null)},onChange:(e,t,n,{altKey:i})=>{if(!(e!==`elementBackground`&&e!==`elementStroke`))if(n.length){for(let r of n)V(r,{[i&&S.swapPreviewOnAlt?e===`elementBackground`?`strokeColor`:`backgroundColor`:e===`elementBackground`?`backgroundColor`:`strokeColor`]:t},!1),Ue.delete(r);Ol.getScene(n[0])?.triggerUpdate()}else r(e===`elementBackground`?{currentItemBackgroundColor:t}:{currentItemStrokeColor:t})},onSelect:(e,t)=>{C(e=>e?.keepOpenOnAlt&&t.altKey?e:null),S?.onSelect?.(e,t)}}),t.openDialog?.name===`help`&&(0,q.jsx)(xT,{onClose:()=>{r({openDialog:null})}}),(0,q.jsx)(ZC,{}),t.openDialog?.name===`elementLinkSelector`&&(0,q.jsx)(KD,{sourceElementId:t.openDialog.sourceElementId,onClose:()=>{r({openDialog:null})},elementsMap:g.scene.getNonDeletedElementsMap(),appState:t,generateLinkForSelection:v}),(0,q.jsx)(b.OverwriteConfirmDialogTunnel.Out,{}),T(),w(),t.pasteDialog.shown&&(0,q.jsx)(mT,{setAppState:r,appState:t,onClose:()=>r({pasteDialog:{shown:!1,data:null}})}),y.editor.isMobile&&(0,q.jsx)(fT,{app:g,appState:t,elements:i,actionManager:e,renderJSONExportDialog:w,renderImageExportDialog:T,setAppState:r,onLockToggle:o,onHandToolToggle:s,onPenModeToggle:c,renderTopRightUI:u,renderCustomStats:d,renderSidebars:re,device:y,renderWelcomeScreen:m,UIOptions:f}),!y.editor.isMobile&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`layer-ui__wrapper`,style:t.openSidebar&&ie&&y.editor.canFitSidebar?{width:`calc(100% - var(--right-sidebar-width))`}:{},children:[m&&(0,q.jsx)(b.WelcomeScreenCenterTunnel.Out,{}),ne(),(0,q.jsx)(NT,{appState:t,actionManager:e,showExitZenModeBtn:l,renderWelcomeScreen:m}),t.scrolledOutside&&(0,q.jsx)(`button`,{type:`button`,className:`scroll-back-to-content`,onClick:()=>{r(e=>({...Xr(i,e)}))},children:J(`buttons.scrollBackToContent`)})]}),re()]})]});return(0,q.jsx)(Hy.Provider,{value:t,children:(0,q.jsx)(x,{children:(0,q.jsx)(LC.Provider,{value:b,children:ae})})})},XD=e=>{let{suggestedBindings:t,startBoundElement:n,cursorButton:r,scrollX:i,scrollY:a,...o}=e;return o},ZD=K.memo(YD,(e,t)=>{if(e.children!==t.children)return!1;let{canvas:n,appState:r,...i}=e,{canvas:a,appState:o,...s}=t;return Xt(XD(r),XD(o),{selectedElementIds:Xt,selectedGroupIds:Xt})&&Xt(i,s)}),QD=5e3,$D=({message:e,onClose:t,closable:n=!1,duration:r=QD,style:i})=>{let a=(0,K.useRef)(0),o=r!==1/0,s=(0,K.useCallback)(()=>{o&&(a.current=window.setTimeout(()=>t(),r))},[t,r,o]);return(0,K.useEffect)(()=>{if(o)return s(),()=>clearTimeout(a.current)},[s,e,r,o]),(0,q.jsxs)(`div`,{className:`Toast`,onMouseEnter:o?()=>clearTimeout(a?.current):void 0,onMouseLeave:o?s:void 0,style:i,children:[(0,q.jsx)(`p`,{className:`Toast__message`,children:e}),n&&(0,q.jsx)(Y,{icon:Us,"aria-label":`close`,type:`icon`,onClick:t,className:`close`})]})},eO=O({name:`viewMode`,label:`labels.viewMode`,paletteName:`Toggle view mode`,icon:Wl,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)=>typeof n.viewModeEnabled>`u`,keyTest:e=>!e[E.CTRL_OR_CMD]&&e.altKey&&e.code===D.R}),tO=(e,t)=>{let n=t.scene.getSelectedElements(e);return n.length===1&&A(n[0])},nO=O({name:`selectAllElementsInFrame`,label:`labels.selectAllElementsInFrame`,trackEvent:{category:`canvas`},perform:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t).at(0)||null;if(A(i)){let n=xl(R(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)=>tO(t,r)}),rO=O({name:`removeAllElementsFromFrame`,label:`labels.removeAllElementsFromFrame`,trackEvent:{category:`history`},perform:(e,t,n,r)=>{let i=r.scene.getSelectedElements(t).at(0)||null;return A(i)?{elements:Ar(e,i),appState:{...t,selectedElementIds:{[i.id]:!0}},captureUpdate:j.IMMEDIATELY}:{elements:e,appState:t,captureUpdate:j.EVENTUALLY}},predicate:(e,t,n,r)=>tO(t,r)});O({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}),O({name:`setFrameAsActiveTool`,label:`toolBar.frame`,trackEvent:{category:`toolbar`},icon:zi,viewMode:!1,perform:(e,t,n,r)=>{let i=Sa(t,{type:`frame`});return Lc(r.interactiveCanvas,{...t,activeTool:i}),{elements:e,appState:{...t,activeTool:Sa(t,{type:`frame`})},captureUpdate:j.EVENTUALLY}},keyTest:e=>!e[E.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===E.F});var iO=O({name:`wrapSelectionInFrame`,label:`labels.wrapSelectionInFrame`,trackEvent:{category:`element`},predicate:(e,t,n,r)=>{let i=W(e,t);return i.length>0&&!i.some(e=>A(e))},perform:(e,t,n,r)=>{let i=W(e,t),[a,o,s,c]=Ao(i,r.scene.getNonDeletedElementsMap()),l=Dc({x:a-16,y:o-16,width:s-a+32,height:c-o+32});if(t.editingGroupId){let e=Wc(i,t.editingGroupId);for(let n of e){let e=n.groupIds.indexOf(t.editingGroupId);V(n,{groupIds:n.groupIds.slice(0,e)},!1)}}return{elements:ls([...r.scene.getElementsIncludingDeleted(),l],i,l,t),appState:{selectedElementIds:{[l.id]:!0}},captureUpdate:j.IMMEDIATELY}}}),aO=()=>(0,q.jsxs)(`div`,{"data-testid":`brave-measure-text-error`,children:[(0,q.jsx)(`p`,{children:(0,q.jsx)(HS,{i18nKey:`errors.brave_measure_text_error.line1`,bold:e=>(0,q.jsx)(`span`,{style:{fontWeight:600},children:e})})}),(0,q.jsx)(`p`,{children:(0,q.jsx)(HS,{i18nKey:`errors.brave_measure_text_error.line2`,bold:e=>(0,q.jsx)(`span`,{style:{fontWeight:600},children:e})})}),(0,q.jsx)(`p`,{children:(0,q.jsx)(HS,{i18nKey:`errors.brave_measure_text_error.line3`,link:e=>(0,q.jsx)(`a`,{href:`http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser`,children:e})})}),(0,q.jsx)(`p`,{children:(0,q.jsx)(HS,{i18nKey:`errors.brave_measure_text_error.line4`,issueLink:e=>(0,q.jsx)(`a`,{href:`https://github.com/excalidraw/excalidraw/issues/new`,children:e}),discordLink:e=>(0,q.jsxs)(`a`,{href:`https://discord.gg/UexuTaE`,children:[e,`.`]})})})]}),oO={width:100,height:0},sO=100,cO=(e,t,n)=>{let r=ds({x:0,y:0,textAlign:Ma.CENTER,verticalAlign:Oc.MIDDLE,...t,containerId:e.id,strokeColor:t.strokeColor||e.strokeColor});return Object.assign(e,{boundElements:(e.boundElements||[]).concat({type:`text`,id:r.id})}),cs(r,e,n),[e,r]},lO=(e,t,n,r,i)=>{let a,o;if(Object.assign(e,{startBinding:e?.startBinding||null,endBinding:e.endBinding||null}),t){let n=t?.width??sO,o=t?.height??sO,s;t.id&&(s=r.getElement(t.id),s||console.error(`No element for start binding with id ${t.id} found`));let c=t.x||e.x-n,l=t.y||e.y-o/2,u=s?s.type:t.type;if(u){if(u===`text`){let n=``;s&&s.type===`text`?n=s.text:t.type===`text`&&(n=t.text),n||console.error(`No text found for start binding text element for ${e.id}`),a=ds({x:c,y:l,type:`text`,...s,...t,text:n}),Object.assign(a,{x:t.x||e.x-a.width,y:t.y||e.y-a.height/2})}else switch(u){case`rectangle`:case`ellipse`:case`diamond`:a=Xs({x:c,y:l,width:n,height:o,...s,...t,type:u});break;default:Ta(e,`Unhandled element start type "${t.type}"`,!0)}Ot(e,a,`start`,i)}}if(n){let t=n?.height??sO,a=n?.width??sO,s;n.id&&(s=r.getElement(n.id),s||console.error(`No element for end binding with id ${n.id} found`));let c=n.x||e.x+e.width,l=n.y||e.y-t/2,u=s?s.type:n.type;if(u){if(u===`text`){let t=``;s&&s.type===`text`?t=s.text:n.type===`text`&&(t=n.text),t||console.error(`No text found for end binding text element for ${e.id}`),o=ds({x:c,y:l,type:`text`,...s,...n,text:t}),Object.assign(o,{y:n.y||e.y-o.height/2})}else switch(u){case`rectangle`:case`ellipse`:case`diamond`:o=Xs({x:c,y:l,width:a,height:t,...s,...n,type:u});break;default:Ta(e,`Unhandled element end type "${u}"`,!0)}Ot(e,o,`end`,i)}}if(e.points.length<2)return{linearElement:e,startBoundElement:a,endBoundElement:o};let s=e.points.length-1,c=.5,l=ui(e.points);return e.points[s][0]>e.points[s-1][0]&&(l[0][0]=c,l[s][0]-=c),e.points[s][0]<e.points[s-1][0]&&(l[0][0]=-c,l[s][0]+=c),e.points[s][1]>e.points[s-1][1]&&(l[0][1]=c,l[s][1]-=c),e.points[s][1]<e.points[s-1][1]&&(l[0][1]=-c,l[s][1]+=c),Object.assign(e,{points:l}),{linearElement:e,startBoundElement:a,endBoundElement:o}},uO=class{constructor(){i(this,`excalidrawElements`,new Map),i(this,`add`,e=>{e&&this.excalidrawElements.set(e.id,e)}),i(this,`getElements`,()=>da(Array.from(this.excalidrawElements.values()))),i(this,`getElementsMap`,()=>Xl(k(this.getElements()))),i(this,`getElement`,e=>this.excalidrawElements.get(e))}},dO=(e,t)=>{if(!e)return[];let n=ui(e),r=new uO,i=new Map,a=new Map;for(let e of n){let n,o=e.id;switch(t?.regenerateIds!==!1&&Object.assign(e,{id:Ro()}),e.type){case`rectangle`:case`ellipse`:case`diamond`:{let t=e?.label?.text&&e.width===void 0?0:e?.width||sO,r=e?.label?.text&&e.height===void 0?0:e?.height||sO;n=Xs({...e,width:t,height:r});break}case`line`:{let t=e.width||oO.width,r=e.height||oO.height;n=rs({width:t,height:r,points:[P(0,0),P(t,r)],...e});break}case`arrow`:{let t=e.width||oO.width,r=e.height||oO.height;n=y({width:t,height:r,endArrowhead:`arrow`,points:[P(0,0),P(t,r)],...e,type:`arrow`}),Object.assign(n,Ge(n.points));break}case`text`:{let t=e?.fontFamily||te,r=e?.fontSize||20,i=e?.lineHeight||vc(t),a=yn(gr(e.text??``),Ds({fontFamily:t,fontSize:r}),i);n=ds({width:a.width,height:a.height,fontFamily:t,fontSize:r,...e});break}case`image`:n=vi({width:e?.width||sO,height:e?.height||sO,...e});break;case`frame`:n=Dc({x:0,y:0,...e});break;case`magicframe`:n=kn({x:0,y:0,...e});break;case`freedraw`:case`iframe`:case`embeddable`:n=e;break;default:n=e,Ta(e,`Unhandled element type "${e.type}"`,!0)}r.getElement(n.id)?console.error(`Duplicate id found for ${n.id}`):(r.add(n),i.set(n.id,e),o&&a.set(o,n.id))}let o=r.getElementsMap();for(let[e,t]of i){let n=r.getElement(e);switch(t.type){case`rectangle`:case`ellipse`:case`diamond`:case`arrow`:if(t.label?.text){let[e,i]=cO(n,t?.label,o);if(r.add(e),r.add(i),st(e)){let n=t.type===`arrow`?t?.start:void 0,i=t.type===`arrow`?t?.end:void 0;if(n&&n.id){let e=a.get(n.id);e&&Object.assign(n,{id:e})}if(i&&i.id){let e=a.get(i.id);e&&Object.assign(i,{id:e})}let{linearElement:s,startBoundElement:c,endBoundElement:l}=lO(e,n,i,r,o);e=s,r.add(s),r.add(c),r.add(l)}}else switch(t.type){case`arrow`:{let{start:e,end:i}=t;if(e&&e.id){let t=a.get(e.id);Object.assign(e,{id:t})}if(i&&i.id){let e=a.get(i.id);Object.assign(i,{id:e})}let{linearElement:s,startBoundElement:c,endBoundElement:l}=lO(n,e,i,r,o);r.add(s),r.add(c),r.add(l);break}}break}}for(let[e,t]of i){if(t.type!==`frame`&&t.type!==`magicframe`)continue;let n=r.getElement(e);if(!n)throw Error(`Excalidraw element with id ${e} doesn't exist`);let i=[];t.children.forEach(e=>{let t=a.get(e);if(!t)throw Error(`Element with ${e} wasn't mapped correctly`);let o=r.getElement(t);if(!o)throw Error(`Frame element with id ${t} doesn't exist`);Object.assign(o,{frameId:n.id}),o?.boundElements?.forEach(e=>{let t=r.getElement(e.id);if(!t)throw Error(`Bound element with id ${e.id} doesn't exist`);Object.assign(t,{frameId:n.id}),i.push(t)}),i.push(o)});let[o,s,c,l]=Ao(i);o-=10,s-=10,c+=10,l+=10;let u=n?.x||o,d=n?.y||s,f=n?.width||c-o,p=n?.height||l-s;Object.assign(n,{x:u,y:d,width:f,height:p}),Me()&&t.children.length&&(n?.x||n?.y||n?.width||n?.height)&&console.info(`User provided frame attributes are being considered, if you find this inaccurate, please remove any of the attributes - x, y, width and height so frame coordinates and dimensions are calculated automatically`)}return r.getElements()},fO=e=>t=>{(0,Ju.unstable_batchedUpdates)(e,t)},pO=e=>cc(t=>{(0,Ju.unstable_batchedUpdates)(e,t)}),mO=(()=>{let e;try{let t=K.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})(),hO=`#ff6b6b`,gO=`#ff0000`,_O=1,vO=2,yO=(e,t)=>{if(!t.snapLines.length)return;let n=t.theme===B.LIGHT||t.zenModeEnabled?hO:gO,r=(t.zenModeEnabled?_O*1.5:_O)/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,xO(i,e,t)):i.type===`gap`?(e.lineWidth=r,e.strokeStyle=n,wO(i.points[0],i.points[1],i.direction,t,e)):i.type===`points`&&(e.lineWidth=r,e.strokeStyle=n,bO(i,e,t));e.restore()},bO=(e,t,n)=>{if(!n.zenModeEnabled){let n=e.points[0],r=e.points[e.points.length-1];CO(n,r,t)}for(let r of e.points)SO(r,n,t)},xO=(e,t,n)=>{SO(e.points[0],n,t),n.zenModeEnabled||CO(e.points[0],e.points[1],t)},SO=([e,t],n,r)=>{r.save();let i=(n.zenModeEnabled?vO*1.5:vO)/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()},CO=(e,t,n)=>{n.beginPath(),n.lineTo(e[0],e[1]),n.lineTo(t[0],t[1]),n.stroke()},wO=(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||CO(P(e[0],e[1]-a),P(e[0],e[1]+a),i),CO(P(n[0]-s,n[1]-o),P(n[0]-s,n[1]+o),i),CO(P(n[0]+s,n[1]-o),P(n[0]+s,n[1]+o),i),r.zenModeEnabled||(CO(P(t[0],t[1]-a),P(t[0],t[1]+a),i),CO(e,t,i))}else{let n=[e[0],(e[1]+t[1])/2];r.zenModeEnabled||CO(P(e[0]-a,e[1]),P(e[0]+a,e[1]),i),CO(P(n[0]-o,n[1]-s),P(n[0]+o,n[1]-s),i),CO(P(n[0]-o,n[1]+s),P(n[0]+o,n[1]+s),i),r.zenModeEnabled||(CO(P(t[0]-a,t[1]),P(t[0]+a,t[1]),i),CO(e,t,i))}},TO=(e,t)=>{lo(t.selectedLinearElement,`selectedLinearElement is null`);let{segmentMidPointHoveredCoords:n}=t.selectedLinearElement;lo(n,`midPointCoords is null`),e.save(),e.translate(t.scrollX,t.scrollY),DO(n,e,t),e.restore()},EO=(e,t,n)=>{let{elementId:r,hoverPointIndex:i}=t.selectedLinearElement;if(t.editingLinearElement?.selectedPointsIndices?.includes(i))return;let a=G.getElement(r,n);if(!a)return;let o=G.getPointAtIndexGlobalCoordinates(a,i,n);e.save(),e.translate(t.scrollX,t.scrollY),DO(o,e,t),e.restore()},DO=(e,t,n)=>{t.fillStyle=`rgba(105, 101, 219, 0.4)`,Be(t,e[0],e[1],G.POINT_HANDLE_SIZE/n.zoom.value,!1)},OO=(e,t,n,r,i,a,o,s,c=!1,l=0)=>{e.save(),e.translate(a,o),e.rotate(s),c&&e.fillRect(t-a,n-o,r,i),l&&e.roundRect?(e.beginPath(),e.roundRect(t-a,n-o,r,i,l),e.stroke(),e.closePath()):e.strokeRect(t-a,n-o,r,i),e.restore()},kO=(e,t,n,r,i,a)=>{e.save(),e.translate(r,i),e.rotate(a),e.beginPath(),e.moveTo(0,n/2),e.lineTo(t/2,0),e.lineTo(0,-n/2),e.lineTo(-t/2,0),e.closePath(),e.stroke(),e.restore()},AO=(e,t,n,r,i,a=!1)=>{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)`),Be(e,n[0],n[1],r/t.zoom.value,!a)},jO=(e,t,n,r,i,a)=>{e.beginPath(),e.ellipse(r,i,t/2,n/2,a,0,Math.PI*2),e.stroke()},MO=(e,t,n,r)=>{let[i,a,o,s]=Kl(t,n),c=o-i,l=s-a;e.strokeStyle=`rgba(0,0,0,.05)`,e.lineWidth=10/(r.value<1?r.value:1);let u=e.lineWidth/2+4,d=Kr(Math.min(t.width,t.height),t);switch(t.type){case`rectangle`:case`text`:case`image`:case`iframe`:case`embeddable`:case`frame`:case`magicframe`:OO(e,i-u,a-u,c+u*2,l+u*2,i+c/2,a+l/2,t.angle,void 0,d);break;case`diamond`:let n=Math.hypot(c,l),r=u*n/l,o=u*n/c;kO(e,c+r*2,l+o*2,i+c/2,a+l/2,t.angle);break;case`ellipse`:jO(e,c+u*2,l+u*2,i+c/2,a+l/2,t.angle);break}},NO=(e,t,n,r)=>{let[i,a,o]=t,s=_i(o,o.width,o.height,r);e.strokeStyle=`rgba(0,0,0,0)`,e.fillStyle=`rgba(0,0,0,.05)`,(a===`both`?[0,-1]:a===`start`?[0]:[-1]).forEach(t=>{let[r,a]=G.getPointAtIndexGlobalCoordinates(i,t,n);Be(e,r,a,s)})},PO=(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,OO(e,i-h,a-h,p+h*2,m+h*2,l,u,r);e.restore()},FO=(e,t,n,r)=>{let i=Array.isArray(n)?NO:MO;e.save(),e.translate(t.scrollX,t.scrollY),i(e,n,r,t.zoom),e.restore()},IO=(e,t,n,r)=>{let[i,a,o,s]=Kl(n,r),c=o-i,l=s-a;e.strokeStyle=`rgb(0,118,255)`,e.lineWidth=kt.strokeWidth/t.zoom.value,e.save(),e.translate(t.scrollX,t.scrollY),OO(e,i,a,c,l,i+c/2,a+l/2,n.angle,!1,kt.radius/t.zoom.value),e.restore()},LO=(e,t,n)=>{let r=n.filter(e=>e.groupIds.length===0),i=n.filter(e=>e.groupIds.length>0),a=e=>{let[t,n,r,i]=Ao(e);return{angle:0,x1:t,x2:r,y1:n,y2:i,selectionColors:[`rgb(0,118,255)`],dashed:!1,cx:t+(r-t)/2,cy:n+(i-n)/2,activeEmbeddable:!1}},o=e=>a(Wc(n,e));Object.entries(Br(i,t)).filter(([e,t])=>t).map(([e,t])=>e).map(e=>o(e)).concat(r.map(e=>a([e]))).forEach(n=>PO(e,t,n))},RO=(e,t,n,r)=>{if(!t.selectedLinearElement)return;e.save(),e.translate(t.scrollX,t.scrollY),e.lineWidth=1/t.zoom.value;let i=G.getPointsGlobalCoordinates(n,r),{POINT_HANDLE_SIZE:a}=G,o=t.editingLinearElement?a:a/2;if(i.forEach((r,a)=>{U(n)&&a!==0&&a!==i.length-1||AO(e,t,r,o,!!t.editingLinearElement?.selectedPointsIndices?.includes(a))}),U(n)){let r=n.fixedSegments?.map(e=>e.index)||[];i.slice(0,-1).forEach((o,s)=>{G.isSegmentTooShort(n,i[s+1],i[s],s,t.zoom)||AO(e,t,P((o[0]+i[s+1][0])/2,(o[1]+i[s+1][1])/2),a/2,!1,!r.includes(s+1))})}else G.getEditorMidPoints(n,r,t).filter((e,t,r)=>e!==null&&!(U(n)&&(t===0||t===r.length-1))).forEach(n=>{(t.editingLinearElement||i.length===2)&&AO(e,t,n,a/2,!1,!0)});e.restore()},zO=(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`?Be(e,r+c/2,s+l/2,c/2):e.roundRect?(e.beginPath(),e.roundRect(r,s,c,l,2/n.zoom.value),e.fill(),e.stroke()):OO(e,r,s,c,l,r+c/2,s+l/2,i,!0),e.restore()}})},BO=(e,t,n,r,i)=>{let[a,o,,,s,c]=Kl(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()},VO=(e,t,n,r)=>{t.save();let i=4/n.zoom.value,a=e.width+i*2,o=e.height+i*2,s=e.x+a/2,c=e.y+o/2,l=-(a/2+i),u=-(o/2+i);t.translate(s+n.scrollX,c+n.scrollY),t.rotate(e.angle),t.lineWidth=1/n.zoom.value,t.strokeStyle=r,t.strokeRect(l,u,a,o),t.restore()},HO=({canvas:e,elementsMap:t,visibleElements:n,selectedElements:r,allElementsMap:i,scale:a,appState:o,renderConfig:s,device:l})=>{if(e===null)return{atLeastOneVisibleElement:!1,elementsMap:t};let[u,d]=Wn(e,a),f=cl({canvas:e,scale:a,normalizedWidth:u,normalizedHeight:d});f.save(),f.scale(o.zoom.value,o.zoom.value);let p;if(n.forEach(e=>{o.editingLinearElement?.elementId===e.id&&e&&(p=e)}),p&&RO(f,o,p,t),o.selectionElement&&!o.isCropping)try{Tc(o.selectionElement,f,o,s.selectionColor)}catch(e){console.error(e)}if(o.editingTextElement&&I(o.editingTextElement)){let e=i.get(o.editingTextElement.id);e&&!e.autoResize&&VO(e,f,o,s.selectionColor)}o.isBindingEnabled&&o.suggestedBindings.filter(e=>e!=null).forEach(e=>{FO(f,o,e,t)}),o.frameToHighlight&&IO(f,o,o.frameToHighlight,t),o.elementsToHighlight&&LO(f,o,o.elementsToHighlight);let m=r.some(e=>A(e));if(r.length===1&&o.editingLinearElement?.elementId===r[0].id&&RO(f,o,r[0],t),U(r[0])&&o.selectedLinearElement&&o.selectedLinearElement.segmentMidPointHoveredCoords?TO(f,o):o.selectedLinearElement&&o.selectedLinearElement.hoverPointIndex>=0&&!(U(r[0])&&o.selectedLinearElement.hoverPointIndex>0&&o.selectedLinearElement.hoverPointIndex<r[0].points.length-1)&&EO(f,o,t),!o.multiElement&&!o.editingLinearElement){let e=Is(r,o),n=r.length===1&&c(r[0]);n&&o.selectedLinearElement?.elementId===r[0].id&&!r[0].locked&&RO(f,o,r[0],t);let i=s.selectionColor||As.black;if(e){let e=k(r),a=[];for(let r of t.values()){let c=[],l=s.remoteSelectedElementIds.get(r.id);if(n&&U(r)&&(r.startBinding||r.endBinding)||(e.has(r.id)&&!Cr(o,r)&&c.push(i),l&&c.push(...l.map(e=>Sx(e,o.collaborators.get(e))))),c.length){let[e,n,i,s,u,d]=Kl(r,t,!0);a.push({angle:r.angle,x1:e,y1:n,x2:i,y2:s,selectionColors:c,dashed:!!l,cx:u,cy:d,activeEmbeddable:o.activeEmbeddable?.element===r&&o.activeEmbeddable.state===`active`,padding:r.id===o.croppingElementId||El(r)?0:void 0})}}let c=e=>{let[n,r,i,o]=Ao(Wc(t,e));a.push({angle:0,x1:n,x2:i,y1:r,y2:o,selectionColors:[As.black],dashed:!0,cx:n+(i-n)/2,cy:r+(o-r)/2,activeEmbeddable:!1})};for(let e of _n(o))c(e);o.editingGroupId&&c(o.editingGroupId),a.forEach(e=>PO(f,o,e))}if(f.save(),f.translate(o.scrollX,o.scrollY),r.length===1){f.fillStyle=As.white;let n=wc(r[0],o.zoom,t,`mouse`,Rt(l));if(!o.viewModeEnabled&&e&&!I(o.editingTextElement)&&!o.croppingElementId&&zO(f,s,o,n,r[0].angle),o.croppingElementId&&!o.isCropping){let e=t.get(o.croppingElementId);e&&El(e)&&BO(f,s,o,e,t)}}else if(r.length>1&&!o.isRotating){let e=4/o.zoom.value;f.fillStyle=As.white;let[t,n,a,c]=Ao(r),u=f.getLineDash();f.setLineDash([2/o.zoom.value]);let d=f.lineWidth;f.lineWidth=1/o.zoom.value,f.strokeStyle=i,OO(f,t-e,n-e,a-t+e*2,c-n+e*2,(t+a)/2,(n+c)/2,0),f.lineWidth=d,f.setLineDash(u);let p=Go([t,n,a,c,(t+a)/2,(n+c)/2],0,o.zoom,`mouse`,m?{...Rt(l),rotation:!0}:Rt(l));r.some(e=>!e.locked)&&zO(f,s,o,p,0)}f.restore()}o.searchMatches.forEach(({id:e,focus:n,matchedLines:r})=>{let i=t.get(e);if(i&&I(i)){let[e,a,,,s,c]=Kl(i,t,!0);f.save(),o.theme===B.LIGHT?n?f.fillStyle=`rgba(255, 124, 0, 0.4)`:f.fillStyle=`rgba(255, 226, 0, 0.4)`:n?f.fillStyle=`rgba(229, 82, 0, 0.4)`:f.fillStyle=`rgba(99, 52, 0, 0.4)`,f.translate(o.scrollX,o.scrollY),f.translate(s,c),f.rotate(i.angle),r.forEach(t=>{f.fillRect(e+t.offsetX-s,a+t.offsetY-c,t.width,t.height)}),f.restore()}}),yO(f,o),f.restore(),wx({context:f,renderConfig:s,appState:o,normalizedWidth:u,normalizedHeight:d});let h;return s.renderScrollbars&&(h=sT(n,u,d,o),f.save(),f.fillStyle=oT,f.strokeStyle=`rgba(255,255,255,0.8)`,[h.horizontal,h.vertical].forEach(e=>{e&&bx(f,e.x,e.y,e.width,e.height,aT/2)}),f.restore()),{scrollBars:h,atLeastOneVisibleElement:n.length>0,elementsMap:t}},UO=cc(e=>{let t=HO(e);e.callback?.(t)},{trailing:!0}),WO=(e,t)=>{if(t){UO(e);return}let n=HO(e);return e.callback(n),n},GO=e=>{let t=(0,K.useRef)(!1);return(0,K.useEffect)(()=>{if(!t.current){t.current=!0;return}let n=new Map,r=new Map,i=new Map,a=new Map,o=new Map;e.appState.collaborators.forEach((t,s)=>{if(t.selectedElementIds)for(let e of Object.keys(t.selectedElementIds))i.has(e)||i.set(e,[]),i.get(e).push(s);!t.pointer||t.pointer.renderCursor===!1||(t.username&&a.set(s,t.username),t.userState&&o.set(s,t.userState),r.set(s,Wo({sceneX:t.pointer.x,sceneY:t.pointer.y},e.appState)),n.set(s,t.button))});let s=e.containerRef?.current&&getComputedStyle(e.containerRef.current).getPropertyValue(`--color-selection`)||`#6965db`;WO({canvas:e.canvas,elementsMap:e.elementsMap,visibleElements:e.visibleElements,selectedElements:e.selectedElements,allElementsMap:e.allElementsMap,scale:window.devicePixelRatio,appState:e.appState,renderConfig:{remotePointerViewportCoords:r,remotePointerButton:n,remoteSelectedElementIds:i,remotePointerUsernames:a,remotePointerUserStates:o,selectionColor:s,renderScrollbars:!1},device:e.device,callback:e.renderInteractiveSceneCallback},mO())}),(0,q.jsx)(`canvas`,{className:`excalidraw__canvas interactive`,style:{width:e.appState.width,height:e.appState.height,cursor:e.appState.viewModeEnabled?N.GRAB:N.AUTO},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:e.handleCanvasRef,onContextMenu:e.onContextMenu,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onPointerCancel:e.onPointerCancel,onTouchMove:e.onTouchMove,onPointerDown:e.onPointerDown,onDoubleClick:e.appState.viewModeEnabled?void 0:e.onDoubleClick,children:J(`labels.drawingCanvas`)})},KO=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,openDialog:e.openDialog,editingGroupId:e.editingGroupId,editingLinearElement:e.editingLinearElement,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,pendingImageElementId:e.pendingImageElementId,selectionElement:e.selectionElement,selectedGroupIds:e.selectedGroupIds,selectedLinearElement:e.selectedLinearElement,multiElement:e.multiElement,isBindingEnabled:e.isBindingEnabled,suggestedBindings:e.suggestedBindings,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}),qO=K.memo(GO,(e,t)=>e.selectionNonce!==t.selectionNonce||e.sceneNonce!==t.sceneNonce||e.scale!==t.scale||e.elementsMap!==t.elementsMap||e.visibleElements!==t.visibleElements||e.selectedElements!==t.selectedElements?!1:Xt(KO(e.appState),KO(t.appState))),JO=e=>{let t=(0,K.useRef)(null),n=(0,K.useRef)(!1);return(0,K.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`));let a=`${e.appState.width}px`,o=`${e.appState.height}px`;i.style.width!==a&&(i.style.width=a),i.style.height!==o&&(i.style.height=o);let s=e.appState.width*e.scale,c=e.appState.height*e.scale;i.width!==s&&(i.width=s),i.height!==c&&(i.height=c),Nr({canvas:i,rc:e.rc,scale:e.scale,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,visibleElements:e.visibleElements,appState:e.appState,renderConfig:e.renderConfig},mO())}),(0,q.jsx)(`div`,{className:`excalidraw__canvas-wrapper`,ref:t})},YO=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,pendingImageElementId:e.pendingImageElementId,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}),XO=K.memo(JO,(e,t)=>e.sceneNonce!==t.sceneNonce||e.scale!==t.scale||e.elementsMap!==t.elementsMap||e.visibleElements!==t.visibleElements?!1:Xt(YO(e.appState),YO(t.appState))&&Xt(e.renderConfig,t.renderConfig)),ZO=class{constructor(e){i(this,`scene`),i(this,`getRenderableElements`,(()=>{let e=({elementsMap:e,zoom:t,offsetLeft:n,offsetTop:r,scrollX:i,scrollY:a,height:o,width:s})=>{let c=[];for(let l of e.values())jo(l,s,o,{zoom:t,offsetLeft:n,offsetTop:r,scrollX:i,scrollY:a},e)&&c.push(l);return c},t=({elements:e,editingTextElement:t,newElementId:n,pendingImageElementId:r})=>{let i=Xl(new Map);for(let a of e)El(a)&&r===a.id||n!==a.id&&(!t||t.type!==`text`||a.id!==t.id)&&i.set(a.id,a);return i};return Gc(({zoom:n,offsetLeft:r,offsetTop:i,scrollX:a,scrollY:o,height:s,width:c,editingTextElement:l,newElementId:u,pendingImageElementId:d,sceneNonce:f})=>{let p=t({elements:this.scene.getNonDeletedElements(),editingTextElement:l,newElementId:u,pendingImageElementId:d});return{elementsMap:p,visibleElements:e({elementsMap:p,zoom:n,offsetLeft:r,offsetTop:i,scrollX:a,scrollY:o,height:s,width:c})}})})()),this.scene=e}destroy(){UO.cancel(),xa.cancel(),this.getRenderableElements.clear()}},QO=({trails:e})=>{let t=(0,K.useRef)(null);return(0,K.useEffect)(()=>{if(t.current)for(let n of e)n.start(t.current);return()=>{for(let t of e)t.stop()}},e),(0,q.jsx)(`div`,{className:`SVGLayer`,children:(0,q.jsx)(`svg`,{ref:t})})},$O=5,ek=(e,t,n)=>{let[r,i]=Kl(e,n),{x:a,y:o}=Wo({sceneX:r+e.width,sceneY:i},t);return{x:a-t.offsetLeft+10,y:o-t.offsetTop}},tk=({children:e,element:t,elementsMap:n})=>{let r=Ak();if(r.contextMenu||r.newElement||r.resizingElement||r.isRotating||r.openMenu||r.viewModeEnabled)return null;let{x:i,y:a}=ek(t,r,n);return(0,q.jsx)(`div`,{className:`excalidraw-canvas-buttons`,style:{top:`${a}px`,left:`${i}px`,padding:$O},children:e})},nk=`small`,rk=e=>(0,q.jsxs)(`label`,{className:L(`ToolIcon ToolIcon__MagicButton`,`ToolIcon_size_${nk}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[(0,q.jsx)(`input`,{className:`ToolIcon_type_checkbox`,type:`checkbox`,name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),(0,q.jsx)(`div`,{className:`ToolIcon__icon`,children:e.icon})]}),ik=({height:e,width:t,userToFollow:n,onDisconnect:r})=>(0,q.jsx)(`div`,{className:`follow-mode`,style:{width:t,height:e},children:(0,q.jsxs)(`div`,{className:`follow-mode__badge`,children:[(0,q.jsxs)(`div`,{className:`follow-mode__badge__label`,children:[`Following`,` `,(0,q.jsx)(`span`,{className:`follow-mode__badge__username`,title:n.username,children:n.username})]}),(0,q.jsx)(`button`,{type:`button`,onClick:r,className:`follow-mode__disconnect-btn`,children:Us})]})}),ak=class{constructor(){i(this,`targets`,new WeakMap),i(this,`rafIds`,new WeakMap)}register(e,t){this.targets.set(e,{callback:t,stopped:!0})}start(e){let t=this.targets.get(e);t&&(this.rafIds.has(e)||(this.targets.set(e,{...t,stopped:!1}),this.scheduleFrame(e)))}stop(e){let t=this.targets.get(e);t&&!t.stopped&&this.targets.set(e,{...t,stopped:!0}),this.cancelFrame(e)}constructFrame(e){return t=>{let n=this.targets.get(e);if(!n)return;let r=this.onFrame(n,t);!n.stopped&&!r?this.scheduleFrame(e):this.cancelFrame(e)}}scheduleFrame(e){let t=requestAnimationFrame(this.constructFrame(e));this.rafIds.set(e,t)}cancelFrame(e){if(this.rafIds.has(e)){let t=this.rafIds.get(e);cancelAnimationFrame(t)}this.rafIds.delete(e)}onFrame(e,t){return e.callback(t)??!1}},ok=class{constructor(e,t,n){this.animationFrameHandler=e,this.app=t,this.options=n,i(this,`currentTrail`),i(this,`pastTrails`,[]),i(this,`container`),i(this,`trailElement`),this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.trailElement=document.createElementNS(mo,`path`)}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}start(e){e&&(this.container=e),this.trailElement.parentNode!==this.container&&this.container&&this.container.appendChild(this.trailElement),this.animationFrameHandler.start(this)}stop(){this.animationFrameHandler.stop(this),this.trailElement.parentNode===this.container&&this.container?.removeChild(this.trailElement)}startPath(e,t){this.currentTrail=new Tv(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())}update(){this.start()}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)}this.pastTrails=this.pastTrails.filter(e=>e.getStrokeOutline().length!==0),e.length===0&&this.stop();let t=e.join(` `).trim();this.trailElement.setAttribute(`d`,t),this.trailElement.setAttribute(`fill`,(this.options.fill??(()=>`black`))(this))}drawTrail(e,t){return Js(e.getStrokeOutline(e.options.size/t.zoom.value).map(([e,n])=>{let r=Wo({sceneX:e,sceneY:n},t);return[r.x,r.y]}),!0)}},sk=class{constructor(e,t){this.animationFrameHandler=e,this.app=t,i(this,`localTrail`),i(this,`collabTrails`,new Map),i(this,`container`),this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.localTrail=new ok(e,t,{...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(at(n),at(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.animationFrameHandler.start(this),this.localTrail.start(e)}stop(){this.animationFrameHandler.stop(this),this.localTrail.stop()}onFrame(){this.updateCollabTrails()}updateCollabTrails(){if(!(!this.container||this.app.state.collaborators.size===0)){for(let[e,t]of this.app.state.collaborators.entries()){let n;this.collabTrails.has(e)?n=this.collabTrails.get(e):(n=new ok(this.animationFrameHandler,this.app,{...this.getTrailOptions(),fill:()=>t.pointer?.laserColor||Sx(e,t)}),n.start(this.container),this.collabTrails.set(e,n)),t.pointer&&t.pointer.tool===`laser`&&(t.button===`down`&&!n.hasCurrentTrail&&n.startPath(t.pointer.x,t.pointer.y),t.button===`down`&&n.hasCurrentTrail&&!n.hasLastPoint(t.pointer.x,t.pointer.y)&&n.addPointToPath(t.pointer.x,t.pointer.y),t.button===`up`&&n.hasCurrentTrail&&(n.addPointToPath(t.pointer.x,t.pointer.y),n.endPath()))}for(let e of this.collabTrails.keys())this.app.state.collaborators.has(e)||(this.collabTrails.get(e).stop(),this.collabTrails.delete(e))}}},ck=(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)`},lk=({id:e,onChange:t,onSubmit:n,getViewportCoords:r,element:i,canvas:a,excalidrawContainer:o,app:c,autoSelect:l=!0})=>{let u=(e,t)=>{if(!t.style.fontFamily||!t.style.fontSize)return!1;let n=t.style.fontFamily.replace(/"/g,``);return di({fontFamily:e.fontFamily})!==n||`${e.fontSize}px`!==t.style.fontSize},d=()=>{let t=c.state,n=Ol.getScene(i)?.getElement(e);if(!n)return;let{textAlign:a,verticalAlign:o}=n,s=c.scene.getNonDeletedElementsMap();if(n&&I(n)){let e=n.x,i=n.y,l=ia(n,c.scene.getNonDeletedElementsMap()),d=n.width,p=n.height,m=n.width,h=n.height;if(l&&n.containerId){if(st(l)){let t=G.getBoundTextElementPosition(l,n,s);e=t.x,i=t.y}let t=u(n,f),r;if(t?r=Ui(l.id,l.height):(r=Ea[l.id],r||=Ui(l.id,l.height)),m=Sr(l,n),h=yr(l,n),!st(l)&&p>h){V(l,{height:No(p,l.type)});return}else if(!st(l)&&l.height>r.height&&p<h)V(l,{height:No(p,l.type)});else{let{y:e}=Bt(l,n,s);i=e}}let[g,_]=r(e,i),v=f.selectionStart,y=f.selectionEnd,b=f.value.length;if(v===y&&y!==b){let e=b-y;f.selectionStart=f.value.length-e,f.selectionEnd=f.value.length-e}l?d+=.5:(m=(t.width-8-g)/t.zoom.value,d=Math.min(d,m)),p*=1.05;let x=Ds(n),S=(t.height-_)/t.zoom.value;Object.assign(f.style,{font:x,lineHeight:n.lineHeight,width:`${d}px`,height:`${p}px`,left:`${g}px`,top:`${_}px`,transform:ck(d,p,Xc(n,l),t,m,S),textAlign:a,verticalAlign:o,color:n.strokeColor,opacity:n.opacity/100,filter:`var(--theme-filter)`,maxHeight:`${S}px`}),f.scrollTop=0,qo()&&(f.style.fontFamily=di(n)),V(n,{x:e,y:i})}},f=document.createElement(`textarea`);f.dir=`auto`,f.tabIndex=0,f.dataset.type=`wysiwyg`,f.wrap=`off`,f.classList.add(`excalidraw-wysiwyg`);let p=`pre`,m=`normal`;(nc(i)||!i.autoResize)&&(p=`pre-wrap`,m=`break-word`),Object.assign(f.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:m,whiteSpace:p,overflowWrap:`break-word`,boxSizing:`content-box`}),f.value=i.originalText,d(),t&&(f.onpaste=async e=>{let t=await Rs(e,!0);if(!t.text)return;let n=gr(t.text);if(!n)return;let r=ia(i,c.scene.getNonDeletedElementsMap()),a=Ds({fontSize:c.state.currentItemFontSize,fontFamily:c.state.currentItemFontFamily});if(r){let e=dr(r,c.scene.getNonDeletedElementsMap()),t=s(fc(`${f.value}${n}`,a,Sr(r,e)),a);f.style.width=`${t}px`}},f.oninput=()=>{let e=gr(f.value);if(f.value!==e){let t=f.selectionStart;f.value=e,f.selectionStart=t,f.selectionEnd=t}t(f.value)}),f.onkeydown=e=>{if(!e.shiftKey&&Hb.keyTest(e))e.preventDefault(),c.actionManager.executeAction(Hb),d();else if(!e.shiftKey&&Ub.keyTest(e))e.preventDefault(),c.actionManager.executeAction(Ub),d();else if(!e.shiftKey&&Wb.keyTest(e))e.preventDefault(),c.actionManager.executeAction(Wb),d();else if(Nb.keyTest(e))c.actionManager.executeAction(Nb);else if(Pb.keyTest(e))c.actionManager.executeAction(Pb);else if(e.key===E.ESCAPE)e.preventDefault(),x=!0,S();else if(e.key===E.ENTER&&e[E.CTRL_OR_CMD]){if(e.preventDefault(),e.isComposing||e.keyCode===229)return;x=!0,S()}else if(e.key===E.TAB||e[E.CTRL_OR_CMD]&&(e.code===D.BRACKET_LEFT||e.code===D.BRACKET_RIGHT)){if(e.preventDefault(),e.isComposing)return;e.shiftKey||e.code===D.BRACKET_LEFT?v():_(),f.dispatchEvent(new Event(`input`))}};let h=` `.repeat(4),g=RegExp(`^ {1,4}`),_=()=>{let{selectionStart:e,selectionEnd:t}=f,n=y(),r=f.value;n.forEach(e=>{r=`${r.slice(0,e)}${h}${r.slice(e)}`}),f.value=r,f.selectionStart=e+4,f.selectionEnd=t+4*n.length},v=()=>{let{selectionStart:e,selectionEnd:t}=f,n=y(),r=[],i=f.value;n.forEach(e=>{let t=i.slice(e,e+4).match(g);t&&(i=`${i.slice(0,e)}${i.slice(e+t[0].length)}`,r.push(e))}),f.value=i,r.length&&(e>r[r.length-1]?f.selectionStart=Math.max(e-4,r[r.length-1]):f.selectionStart=e,f.selectionEnd=Math.max(f.selectionStart,t-4*r.length))},y=()=>{let{selectionStart:e,selectionEnd:t,value:n}=f,r=n.slice(0,e).match(/[^\n]*$/)[0].length;return e-=r,n.slice(e,t).split(`
55
+ `).reduce((t,n,r,i)=>t.concat(r?t[r-1]+i[r-1].length+1:e),[]).reverse()},b=e=>{e.target instanceof HTMLCanvasElement&&(e.preventDefault(),e.stopPropagation())},x=!1,S=()=>{if(re)return;re=!0,C();let e=Ol.getScene(i)?.getElement(i.id);if(!e)return;let t=ia(e,c.scene.getNonDeletedElementsMap());if(t){if(f.value.trim()){let e=me(t);!e||e!==i.id?V(t,{boundElements:(t.boundElements||[]).concat({type:`text`,id:i.id})}):st(t)&&na(t)}else V(t,{boundElements:t.boundElements?.filter(e=>!I(e))});cs(e,t,c.scene.getNonDeletedElementsMap())}n({viaKeyboard:x,nextOriginalText:f.value})},C=()=>{f.onblur=null,f.oninput=null,f.onkeydown=null,ie&&ie.disconnect(),window.removeEventListener(`resize`,d),window.removeEventListener(`wheel`,b,!0),window.removeEventListener(`pointerdown`,ee),window.removeEventListener(`pointerup`,w),window.removeEventListener(`blur`,S),window.removeEventListener(`beforeunload`,S),te(),ne(),f.remove()},w=e=>{window.removeEventListener(`pointerup`,w);let t=e?.target,n=t instanceof HTMLElement&&t.classList.contains(`properties-trigger`);setTimeout(()=>{f.onblur=S,n||f.focus()})},T=()=>{f.onblur=null,window.addEventListener(`pointerup`,w),window.addEventListener(`blur`,S)},ee=e=>{let t=e?.target;if(e.button===Ll.WHEEL){t instanceof HTMLTextAreaElement&&(e.preventDefault(),c.handleCanvasPanUsingWheelOrSpaceDrag(e)),T();return}let n=t instanceof HTMLElement&&t.classList.contains(`properties-trigger`);(e.target instanceof HTMLElement||e.target instanceof SVGElement)&&e.target.closest(`.${oo.SHAPE_ACTIONS_MENU}, .${oo.ZOOM_ACTIONS}`)&&!qa(e.target)||n?T():e.target instanceof HTMLCanvasElement&&!qo()&&requestAnimationFrame(()=>{S()})},te=c.scene.onUpdate(()=>{d(),document.activeElement?.closest(`.properties-content`)||f.focus()}),ne=c.onScrollChangeEmitter.on(()=>{d()}),re=!1;l&&f.select(),w();let ie=null;a&&`ResizeObserver`in window?(ie=new window.ResizeObserver(()=>{d()}),ie.observe(a)):window.addEventListener(`resize`,d),f.onpointerdown=e=>e.stopPropagation(),requestAnimationFrame(()=>{window.addEventListener(`pointerdown`,ee,{capture:!0})}),window.addEventListener(`beforeunload`,S),o?.querySelector(`.excalidraw-textEditorContainer`).appendChild(f)},uk=O({name:`autoResize`,label:`labels.autoResize`,icon:null,trackEvent:{category:`element`},predicate:(e,t,n,r)=>{let i=W(e,t);return i.length===1&&I(i[0])&&!i[0].autoResize},perform:(e,t,n,r)=>{let i=W(e,t);return{appState:t,elements:e.map(e=>{if(e.id===i[0].id&&I(e)){let t=yn(e.originalText,Ds(e),e.lineHeight);return z(e,{autoResize:!0,width:t.width,height:t.height,text:e.originalText})}return e}),captureUpdate:j.IMMEDIATELY}}}),dk=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()),fk=({canvas:e,rc:t,newElement:n,elementsMap:r,allElementsMap:i,scale:a,appState:o,renderConfig:s})=>{if(e){let[c,l]=Wn(e,a),u=cl({canvas:e,scale:a,normalizedWidth:c,normalizedHeight:l});u.save(),u.scale(o.zoom.value,o.zoom.value),n&&n.type!==`selection`?Bn(n,r,i,t,u,s,o):u.clearRect(0,0,c,l)}},pk=cc(e=>{fk(e)},{trailing:!0}),mk=(e,t)=>{if(t){pk(e);return}fk(e)},hk=e=>{let t=(0,K.useRef)(null);return(0,K.useEffect)(()=>{t.current&&mk({canvas:t.current,scale:e.scale,newElement:e.appState.newElement,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,rc:e.rc,renderConfig:e.renderConfig,appState:e.appState},mO())}),(0,q.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})},gk=K.createContext(null),_k=K.createContext(null),vk={viewport:{isMobile:!1,isLandscape:!1},editor:{isMobile:!1,canFitSidebar:!1},isTouchScreen:!1},yk=K.createContext(vk);yk.displayName=`DeviceContext`;var bk=K.createContext({container:null,id:null});bk.displayName=`ExcalidrawContainerContext`;var xk=K.createContext([]);xk.displayName=`ExcalidrawElementsContext`;var Sk=K.createContext({...Le(),width:0,height:0,offsetLeft:0,offsetTop:0});Sk.displayName=`ExcalidrawAppStateContext`;var Ck=K.createContext(()=>{console.warn(`Uninitialized ExcalidrawSetAppStateContext context!`)});Ck.displayName=`ExcalidrawSetAppStateContext`;var wk=K.createContext(null);wk.displayName=`ExcalidrawActionManagerContext`;var Tk=()=>(0,K.useContext)(gk),Ek=()=>(0,K.useContext)(_k),Dk=()=>(0,K.useContext)(yk),Ok=()=>(0,K.useContext)(bk),kk=()=>(0,K.useContext)(xk),Ak=()=>(0,K.useContext)(Sk),jk=()=>(0,K.useContext)(Ck),Mk=()=>(0,K.useContext)(wk),Nk=!1,Pk=0,Fk=!1,Ik=!1,Lk=!1,Rk={horizontal:null,vertical:null},zk=0,Bk=!1,Vk=new Map,Hk=!1,Uk=0,Wk=!1,Gk=null,$={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},Kk=class e extends K.Component{constructor(t){super(t),i(this,`canvas`),i(this,`interactiveCanvas`,null),i(this,`rc`),i(this,`unmounted`,!1),i(this,`actionManager`),i(this,`device`,vk),i(this,`excalidrawContainerRef`,K.createRef()),i(this,`scene`),i(this,`fonts`),i(this,`renderer`),i(this,`visibleElements`),i(this,`resizeObserver`),i(this,`nearestScrollableContainer`),i(this,`library`),i(this,`libraryItemsFromStorage`),i(this,`id`),i(this,`store`),i(this,`history`),i(this,`excalidrawContainerValue`),i(this,`files`,{}),i(this,`imageCache`,new Map),i(this,`iFrameRefs`,new Map),i(this,`embedsValidationStatus`,new Map),i(this,`initializedEmbeds`,new Set),i(this,`elementsPendingErasure`,new Set),i(this,`flowChartCreator`,new Xw),i(this,`flowChartNavigator`,new Yw),i(this,`hitLinkElement`),i(this,`lastPointerDownEvent`,null),i(this,`lastPointerUpEvent`,null),i(this,`lastPointerMoveEvent`,null),i(this,`lastPointerMoveCoords`,null),i(this,`lastViewportPosition`,{x:0,y:0}),i(this,`animationFrameHandler`,new ak),i(this,`laserTrails`,new sk(this.animationFrameHandler,this)),i(this,`eraserTrail`,new ok(this.animationFrameHandler,this,{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(at(n),at(t))},fill:()=>this.state.theme===B.LIGHT?`rgba(0, 0, 0, 0.2)`:`rgba(255, 255, 255, 0.2)`})),i(this,`onChangeEmitter`,new zn),i(this,`onPointerDownEmitter`,new zn),i(this,`onPointerUpEmitter`,new zn),i(this,`onUserFollowEmitter`,new zn),i(this,`onScrollChangeEmitter`,new zn),i(this,`missingPointerEventCleanupEmitter`,new zn),i(this,`onRemoveEventListenersEmitter`,new zn),i(this,`getEffectiveGridSize`,()=>ra(this)?this.state.gridSize:null),i(this,`updateEmbedValidationStatus`,(e,t)=>{this.embedsValidationStatus.set(e.id,t),Ue.delete(e)}),i(this,`updateEmbeddables`,()=>{let e=new Set,t=!1;this.scene.getNonDeletedElements().filter(n=>{if(St(n)){if(e.add(n.id),!this.embedsValidationStatus.has(n.id)){t=!0;let e=Il(n.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(n,e)}}else oi(n)&&e.add(n.id);return!1}),t&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((t,n)=>{e.has(n)||this.iFrameRefs.delete(n)})}),i(this,`getFrameNameDOMId`,e=>`${this.id}-frame-name-${e.id}`),i(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=Ls({clientX:r.x,clientY:r.y},this.state),a=Ls({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,angle:0,zoom:this.state.zoom.value,versionNonce:e.versionNonce},this.frameNameBoundsCache._cache.set(e.id,t),t}return null}return t},_cache:new Map}),i(this,`resetEditingFrame`,e=>{e&&V(e,{name:e.name?.trim()||null}),this.setState({editingFrame:null})}),i(this,`renderFrameNames`,()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return this.state.editingFrame&&this.resetEditingFrame(null),null;let e=this.state.theme===B.DARK;return this.scene.getNonDeletedFramesLikes().map(t=>{if(!jo(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:n,y:r}=Wo({sceneX:t.x,sceneY:t.y},this.state),i,a=To(t);if(t.id===this.state.editingFrame){let r=a;i=(0,q.jsx)(`input`,{autoFocus:!0,value:r,onChange:e=>{V(t,{name:e.target.value})},onFocus:e=>e.target.select(),onBlur:()=>this.resetEditingFrame(t),onKeyDown:e=>{(e.key===E.ESCAPE||e.key===E.ENTER)&&this.resetEditingFrame(t)},style:{background:this.state.viewBackgroundColor,filter:e?jc:`none`,zIndex:2,border:`none`,display:`block`,padding:`6px`,borderRadius:4,boxShadow:`inset 0 0 0 1px var(--color-primary)`,fontFamily:`Assistant`,fontSize:`14px`,transform:`translate(-6px, 6px)`,color:`var(--color-gray-80)`,overflow:`hidden`,maxWidth:`${document.body.clientWidth-n-6}px`},size:r.length+1||1,dir:`auto`,autoComplete:`off`,autoCapitalize:`off`,autoCorrect:`off`})}else i=a;return(0,q.jsx)(`div`,{id:this.getFrameNameDOMId(t),style:{position:`absolute`,bottom:`${this.state.height+kt.nameOffsetY-r+this.state.offsetTop}px`,left:`${n-this.state.offsetLeft}px`,zIndex:2,fontSize:kt.nameFontSize,color:e?kt.nameColorDarkTheme:kt.nameColorLightTheme,lineHeight:kt.nameLineHeight,width:`max-content`,maxWidth:`${t.width}px`,overflow:t.id===this.state.editingFrame?`visible`:`hidden`,whiteSpace:`nowrap`,textOverflow:`ellipsis`,cursor:N.MOVE,pointerEvents:this.state.viewModeEnabled?ps.disabled:ps.enabled},onPointerDown:e=>this.handleCanvasPointerDown(e),onWheel:e=>this.handleWheel(e),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:t.id})},children:i},t.id)})}),i(this,`focusContainer`,()=>{this.excalidrawContainerRef.current?.focus()}),i(this,`getSceneElementsIncludingDeleted`,()=>this.scene.getElementsIncludingDeleted()),i(this,`getSceneElements`,()=>this.scene.getNonDeletedElements()),i(this,`onInsertElements`,e=>{this.addElementsFromPasteOrLibrary({elements:e,position:`center`,files:null})}),i(this,`onExportImage`,async(e,t,n)=>{X(`export`,e,`ui`);let r=await tx(e,t,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:n.exportingFrame}).catch(x).catch(e=>{console.error(e),this.setState({errorMessage:e.message})});this.state.exportEmbedScene&&r&&it(r)&&this.setState({fileHandle:r})}),i(this,`magicGenerations`,new Map),i(this,`updateMagicGeneration`,({frameElement:e,data:t})=>{t.status===`pending`?V(e,{customData:{generationData:void 0}},!1):V(e,{customData:{generationData:t}},!1),this.magicGenerations.set(e.id,t),this.triggerRender()}),i(this,`plugins`,{}),i(this,`onMagicframeToolSelect`,()=>{let e=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});if(e.length===0)this.setActiveTool({type:Pc.magicframe}),X(`ai`,`tool-select (empty-selection)`,`d2c`);else{let t=e.length===1&&Zn(e[0])&&e[0];if(!t&&e.some(e=>A(e)||e.frameId)){this.setActiveTool({type:Pc.magicframe});return}X(`ai`,`tool-select (existing selection)`,`d2c`);let n;if(t)n=t;else{let[t,r,i,a]=Ao(e);n=kn({...kt,x:t-50,y:r-50,width:i-t+100,height:a-r+100,opacity:100,locked:!1}),this.scene.insertElement(n);for(let t of e)V(t,{frameId:n.id});this.setState({selectedElementIds:{[n.id]:!0}})}this.onMagicFrameGenerate(n,`upstream`)}}),i(this,`openEyeDropper`,({type:e})=>{Mv.set(qy,{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})}),i(this,`dismissLinearEditor`,()=>{setTimeout(()=>{this.setState({editingLinearElement:null})})}),i(this,`syncActionResult`,fO(e=>{if(this.unmounted||e===!1)return;e.captureUpdate===j.NEVER?this.store.shouldUpdateSnapshot():e.captureUpdate===j.IMMEDIATELY&&this.store.shouldCaptureIncrement();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||B.LIGHT,o=e?.appState?.name??this.state.name,s=e?.appState?.errorMessage??this.state.errorMessage;typeof this.props.viewModeEnabled<`u`&&(r=this.props.viewModeEnabled),typeof this.props.zenModeEnabled<`u`&&(i=this.props.zenModeEnabled),n=e.appState?.editingTextElement||null,e.elements&&n&&e.elements.forEach(e=>{n?.id===e.id&&n!==e&&gc(e)&&I(e)&&(n=e)}),n?.isDeleted&&(n=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&&e.captureUpdate!==j.EVENTUALLY&&this.scene.triggerUpdate()})),i(this,`onBlur`,fO(()=>{Fk=!1,this.setState({isBindingEnabled:!0})})),i(this,`onUnload`,()=>{this.onBlur()}),i(this,`disableEvent`,e=>{e.preventDefault()}),i(this,`resetHistory`,()=>{this.history.clear()}),i(this,`resetStore`,()=>{this.store.clear()}),i(this,`resetScene`,fO(e=>{this.scene.replaceAllElements([]),this.setState(t=>({...Le(),isLoading:e?.resetLoadingState?!1:t.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()})),i(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=ni(e,null,null,{repairBindings:!0});t.appState={...t.appState,theme:this.props.theme||t.appState.theme,openSidebar:t.appState?.openSidebar||this.state.openSidebar,activeTool:t.appState.activeTool.type===`image`?{...t.appState.activeTool,type:`selection`}:t.appState.activeTool,isLoading:!1,toast:this.state.toast},e?.scrollToContent&&(t.appState={...t.appState,...Xr(t.elements,{...t.appState,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft})}),this.resetStore(),this.resetHistory(),this.syncActionResult({...t,captureUpdate:j.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(e=>{this.fonts.onLoaded(e)}),ie(window.location.href)&&this.scrollToContent(window.location.href,{animate:!1})}),i(this,`isMobileBreakpoint`,(e,t)=>e<730||t<500&&e<1e3),i(this,`refreshViewportBreakpoints`,()=>{if(!this.excalidrawContainerRef.current)return;let{clientWidth:e,clientHeight:t}=document.body,n=this.device.viewport,r=aa(n,{isLandscape:e>t,isMobile:this.isMobileBreakpoint(e,t)});return n===r?!1:(this.device={...this.device,viewport:r},!0)}),i(this,`refreshEditorBreakpoints`,()=>{let e=this.excalidrawContainerRef.current;if(!e)return;let{width:t,height:n}=e.getBoundingClientRect(),r=this.props.UIOptions.dockedSidebarBreakpoint==null?ur:this.props.UIOptions.dockedSidebarBreakpoint,i=this.device.editor,a=aa(i,{isMobile:this.isMobileBreakpoint(t,n),canFitSidebar:t>r});return i===a?!1:(this.device={...this.device,editor:a},!0)}),i(this,`onResize`,fO(()=>{this.scene.getElementsIncludingDeleted().forEach(e=>Ue.delete(e)),this.refreshViewportBreakpoints(),this.updateDOMRect(),_a||this.refreshEditorBreakpoints(),this.setState({})})),i(this,`onFullscreenChange`,()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state===`active`&&this.setState({activeEmbeddable:null})}),i(this,`renderInteractiveSceneCallback`,({atLeastOneVisibleElement:e,scrollBars:t,elementsMap:n})=>{t&&(Rk=t);let r=this.state.editingTextElement?!1:!e&&n.size>0;this.state.scrolledOutside!==r&&this.setState({scrolledOutside:r}),this.scheduleImageRefresh()}),i(this,`onScroll`,Ec(()=>{let{offsetTop:e,offsetLeft:t}=this.getCanvasOffsets();this.setState(n=>n.offsetLeft===t&&n.offsetTop===e?null:{offsetTop:e,offsetLeft:t})},100)),i(this,`onCut`,fO(e=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||qa(e.target)||(this.actionManager.executeAction(Bx,`keyboard`,e),e.preventDefault(),e.stopPropagation())})),i(this,`onCopy`,fO(e=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||qa(e.target)||(this.actionManager.executeAction(Rx,`keyboard`,e),e.preventDefault(),e.stopPropagation())})),i(this,`onTouchStart`,t=>{if(Wt&&t.preventDefault(),!Nk){Nk=!0,clearTimeout(Pk),Pk=window.setTimeout(e.resetTapTwice,300);return}if(Nk&&t.touches.length===1){let e=t.touches[0];this.handleCanvasDoubleClick({clientX:e.clientX,clientY:e.clientY}),Nk=!1,clearTimeout(Pk)}t.touches.length===2&&this.setState({selectedElementIds:F({},this.state),activeEmbeddable:null})}),i(this,`onTouchEnd`,e=>{this.resetContextMenuTimer(),e.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:F(this.state.previousSelectedElementIds,this.state)}):$.pointers.clear()}),i(this,`pasteFromClipboard`,fO(async e=>{let t=!!Hk,r=document.activeElement,i=this.excalidrawContainerRef.current?.contains(r);if(e&&!i)return;let a=document.elementFromPoint(this.lastViewportPosition.x,this.lastViewportPosition.y);if(e&&(!(a instanceof HTMLCanvasElement)||qa(r)))return;let{x:o,y:s}=Ls({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),c=e?.clipboardData?.files[0],l=await Rs(e,t);if(!c&&!t){if(l.mixedContent)return this.addElementsFromMixedContentPaste(l.mixedContent,{isPlainPaste:t,sceneX:o,sceneY:s});if(l.text){let e=l.text.trim();e.startsWith(`<svg`)&&e.endsWith(`</svg>`)&&(c=Pr(e))}}if(hc(c)&&!l.spreadsheet){if(!this.isToolSupported(`image`)){this.setState({errorMessage:J(`errors.imageToolNotSupported`)});return}let e=this.createImageElement({sceneX:o,sceneY:s});this.insertImageElement(e,c),this.initializeImageDimensions(e),this.setState({selectedElementIds:F({[e.id]:!0},this.state)});return}if(this.props.onPaste)try{if(await this.props.onPaste(l,e)===!1)return}catch(e){console.error(e)}if(l.errorMessage)this.setState({errorMessage:l.errorMessage});else if(l.spreadsheet&&!t)this.setState({pasteDialog:{data:l.spreadsheet,shown:!0}});else if(l.elements){let e=l.programmaticAPI?dO(l.elements):l.elements;this.addElementsFromPasteOrLibrary({elements:e,files:l.files||null,position:`cursor`,retainSeed:t})}else if(l.text){if(l.text&&dk(l.text)){let e=await n(()=>import(`./dist-BWLXExfL.js`),__vite__mapDeps([63,2,3,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78]),import.meta.url);try{let{elements:t,files:n={}}=await e.parseMermaidToExcalidraw(l.text),r=dO(t,{regenerateIds:!0});this.addElementsFromPasteOrLibrary({elements:r,files:n,position:`cursor`});return}catch(e){console.warn(`parsing pasted text as mermaid definition failed: ${e.message}`)}}let e=Do(l.text).split(/\n+/).map(e=>e.trim()).filter(Boolean),r=e.map(e=>ec(e)).filter(e=>Il(e,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(e)||Je(e)?.type===`video`));if(!Hk&&r.length>0&&r.length===e.length){let e=[];for(let t of r){let n=e[e.length-1],r=this.insertEmbeddableElement({sceneX:n?n.x+n.width+20:o,sceneY:s,link:on(t)});r&&e.push(r)}e.length&&this.setState({selectedElementIds:Object.fromEntries(e.map(e=>[e.id,!0]))});return}this.addTextFromPaste(l.text,t)}this.setActiveTool({type:`selection`}),e?.preventDefault()})),i(this,`addElementsFromPasteOrLibrary`,e=>{let t=sa(e.elements,null,void 0),[n,r,i,a]=Ao(t),o=ce(n,i)/2,s=ce(r,a)/2,{x:c,y:l}=Ls({clientX:typeof e.position==`object`?e.position.clientX:e.position===`cursor`?this.lastViewportPosition.x:this.state.width/2+this.state.offsetLeft,clientY:typeof e.position==`object`?e.position.clientY:e.position===`cursor`?this.lastViewportPosition.y:this.state.height/2+this.state.offsetTop},this.state),[u,d]=ht(c-o,l-s,this.getEffectiveGridSize()),f=Mn(t.map(e=>z(e,{x:e.x+u-n,y:e.y+d-r})),{randomizeSeed:!e.retainSeed}),m=this.scene.getElementsIncludingDeleted(),h=[...m,...f];h=this.props.onDuplicate?.(h,m)||h,Un(h,k(f));let g=this.getTopLayerFrameAtSceneCoords({x:c,y:l});if(g){let e=Or(f,g);ls(h,e,g,this.state)}this.scene.replaceAllElements(h),f.forEach(e=>{I(e)&&nc(e)&&cs(e,ia(e,this.scene.getElementsMapIncludingDeleted()),this.scene.getElementsMapIncludingDeleted())}),kl&&Eo.loadElementsFonts(f).then(e=>{this.fonts.onLoaded(e)}),e.files&&this.addMissingFiles(e.files),this.store.shouldCaptureIncrement();let _=p(f);this.setState({...this.state,openSidebar:this.state.openSidebar&&this.device.editor.canFitSidebar&&Mv.get(VT)?this.state.openSidebar:null,...Fi({editingGroupId:null,selectedElementIds:_.reduce((e,t)=>(nc(t)||(e[t.id]=!0),e),{})},this.scene.getNonDeletedElements(),this.state,this)},()=>{e.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:`selection`}),e.fitToContent&&this.scrollToContent(f,{fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()})}),i(this,`setAppState`,(e,t)=>{this.setState(e,t)}),i(this,`removePointer`,e=>{zk&&this.resetContextMenuTimer(),$.pointers.delete(e.pointerId)}),i(this,`toggleLock`,(e=`ui`)=>{this.state.activeTool.locked||X(`toolbar`,`toggleLock`,`${e} (${this.device.editor.isMobile?`mobile`:`desktop`})`),this.setState(e=>({activeTool:{...e.activeTool,...Sa(this.state,e.activeTool.locked?{type:`selection`}:e.activeTool),locked:!e.activeTool.locked}}))}),i(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}}})}),i(this,`togglePenMode`,e=>{this.setState(t=>({penMode:e??!t.penMode,penDetected:!0}))}),i(this,`onHandToolToggle`,()=>{this.actionManager.executeAction(Yb)}),i(this,`zoomCanvas`,e=>{this.setState({...Ib({viewportX:this.state.width/2+this.state.offsetLeft,viewportY:this.state.height/2+this.state.offsetTop,nextZoom:He(e)},this.state)})}),i(this,`cancelInProgressAnimation`,null),i(this,`scrollToContent`,(e=this.scene.getNonDeletedElements(),t)=>{if(typeof e==`string`){let n;if(n=ie(e)?Xn(e):e,n){let r=this.scene.getElementsFromId(n);r?.length?this.scrollToContent(r,{fitToContent:t?.fitToContent??!0,animate:t?.animate??!0}):ie(e)&&this.setState({toast:{message:J(`elementLink.notFound`),duration:3e3,closable:!0}})}return}this.cancelInProgressAnimation?.();let n=Array.isArray(e)?e:[e],r=this.state.zoom,i=this.state.scrollX,a=this.state.scrollY;if(t?.fitToContent||t?.fitToViewport){let{appState:e}=qb({canvasOffsets:t.canvasOffsets,targetElements:n,appState:this.state,fitToViewport:!!t?.fitToViewport,viewportZoomFactor:t?.viewportZoomFactor,minZoom:t?.minZoom,maxZoom:t?.maxZoom});r=e.zoom,i=e.scrollX,a=e.scrollY}else{let e=Xr(n,this.state);i=e.scrollX,a=e.scrollY}if(t?.animate){let e=this.state.scrollX,n=this.state.scrollY,o=this.state.zoom.value,s=yl({fromValues:{scrollX:e,scrollY:n,zoom:o},toValues:{scrollX:i,scrollY:a,zoom:r.value},interpolateValue:(e,t,n,r)=>{if(r===`zoom`)return e*(t/e)**+at(n)},onStep:({scrollX:e,scrollY:t,zoom:n})=>{this.setState({scrollX:e,scrollY:t,zoom:{value:n}})},onStart:()=>{this.setState({shouldCacheIgnoreZoom:!0})},onEnd:()=>{this.setState({shouldCacheIgnoreZoom:!1})},onCancel:()=>{this.setState({shouldCacheIgnoreZoom:!1})},duration:t?.duration??500});this.cancelInProgressAnimation=()=>{s(),this.cancelInProgressAnimation=null}}else this.setState({scrollX:i,scrollY:a,zoom:r})}),i(this,`maybeUnfollowRemoteUser`,()=>{this.state.userToFollow&&this.setState({userToFollow:null})}),i(this,`translateCanvas`,e=>{this.cancelInProgressAnimation?.(),this.maybeUnfollowRemoteUser(),this.setState(e)}),i(this,`setToast`,e=>{this.setState({toast:e})}),i(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,Na,window.location.pathname)}}catch(e){this.setState({errorMessage:e.message})}}),i(this,`addFiles`,fO(e=>{let{addedFiles:t}=this.addMissingFiles(e);this.clearImageShapeCache(t),this.scene.triggerUpdate(),this.addNewImagesToImageCache()})),i(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===de.svg))try{let t=Ra($r(v(e.dataURL)),de.svg);e.dataURL!==t&&(e.version=(e.version??1)+1,e.dataURL=t)}catch(e){console.error(e)}return this.files=n,{addedFiles:r}}),i(this,`updateScene`,fO(e=>{let t=da(e.elements??[]);if(e.captureUpdate&&e.captureUpdate!==j.EVENTUALLY){let n=this.store.snapshot.appState,r=this.store.snapshot.elements,i=e.appState?Object.assign({},n,e.appState):n,a=e.elements?this.store.filterUncomittedElements(this.scene.getElementsMapIncludingDeleted(),k(t)):r;e.captureUpdate===j.IMMEDIATELY?this.store.captureIncrement(a,i):e.captureUpdate===j.NEVER&&this.store.updateSnapshot(a,i)}e.appState&&this.setState(e.appState),e.elements&&this.scene.replaceAllElements(t),e.collaborators&&this.setState({collaborators:e.collaborators})})),i(this,`triggerRender`,e=>{e===!0?this.scene.triggerUpdate():this.setState({})}),i(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}),i(this,`updateCurrentCursorPosition`,fO(e=>{this.lastViewportPosition.x=e.clientX,this.lastViewportPosition.y=e.clientY})),i(this,`getEditorUIOffsets`,()=>{let e=this.excalidrawContainerRef?.current?.querySelector(`.App-toolbar`)?.getBoundingClientRect()?.bottom??0,t=this.excalidrawContainerRef?.current?.querySelector(`.sidebar`)?.getBoundingClientRect(),n=this.excalidrawContainerRef?.current?.querySelector(`.App-menu__left`)?.getBoundingClientRect();return Vv().rtl?{top:e+16,right:Math.max(this.state.width-(n?.left??this.state.width),0)+16,bottom:16,left:Math.max(t?.right??0,0)+16}:{top:e+16,right:Math.max(this.state.width-(t?.left??this.state.width)+16,0),bottom:16,left:Math.max(n?.right??0,0)+16}}),i(this,`onKeyDown`,fO(e=>{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}})),!Nt(e.target)){if((e.key===E.ESCAPE||e.key===E.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let t=W(this.scene.getNonDeletedElementsMap(),this.state);if(t.length===1&&El(t[0])&&e.key===E.ENTER){this.startImageCropping(t[0]);return}if(e.key===E.ESCAPE&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.clear(),this.triggerRender(!0);return}let n=ne(e.key);if(e[E.CTRL_OR_CMD]&&n&&!e.shiftKey){e.preventDefault();let t=W(this.scene.getNonDeletedElementsMap(),this.state);t.length===1&&je(t[0])&&this.flowChartCreator.createNodes(t[0],this.scene.getNonDeletedElementsMap(),this.state,Vw(e.key)),this.flowChartCreator.pendingNodes?.length&&!At(this.flowChartCreator.pendingNodes,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.getEditorUIOffsets())&&this.scrollToContent(this.flowChartCreator.pendingNodes,{animate:!0,duration:300,fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()});return}if(e.altKey){let t=W(this.scene.getNonDeletedElementsMap(),this.state);if(t.length===1&&n){e.preventDefault();let n=this.flowChartNavigator.exploreByDirection(t[0],this.scene.getNonDeletedElementsMap(),Vw(e.key));if(n){this.setState(e=>({selectedElementIds:F({[n]:!0},e)}));let e=this.scene.getNonDeletedElementsMap().get(n);e&&!At([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.getEditorUIOffsets())&&this.scrollToContent(e,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})}return}}}if(e[E.CTRL_OR_CMD]&&e.key===E.P&&!e.shiftKey&&!e.altKey){this.setToast({message:J(`commandPalette.shortcutHint`,{shortcut:MC(`commandPalette`)})}),e.preventDefault();return}if(e[E.CTRL_OR_CMD]&&e.key.toLowerCase()===E.V&&(Hk=e.shiftKey,clearTimeout(Uk),Uk=window.setTimeout(()=>{Hk=!1},100)),e[E.CTRL_OR_CMD]&&qa(e.target)&&(e.code===D.MINUS||e.code===D.EQUAL)){e.preventDefault();return}if(qa(e.target)&&e.key!==E.ESCAPE||ne(e.key)&&Nt(e.target))return;if(e.key===E.QUESTION_MARK){this.setState({openDialog:{name:`help`}});return}else if(e.key.toLowerCase()===E.E&&e.shiftKey&&e[E.CTRL_OR_CMD]){e.preventDefault(),this.setState({openDialog:{name:`imageExport`}});return}if(e.key===E.PAGE_UP||e.key===E.PAGE_DOWN){let t=(e.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;e.key===E.PAGE_DOWN&&(t=-t),e.shiftKey?this.translateCanvas(e=>({scrollX:e.scrollX+t})):this.translateCanvas(e=>({scrollY:e.scrollY+t}))}if(this.state.openDialog?.name===`elementLinkSelector`||this.actionManager.handleKeyDown(e)||this.state.viewModeEnabled)return;if(e[E.CTRL_OR_CMD]&&this.state.isBindingEnabled&&this.setState({isBindingEnabled:!1}),ne(e.key)){let t=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),n=t.find(U),r=new Set;t.filter(U).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=>r.add(e.id)),t=t.filter(e=>!r.has(e.id));let i=this.getEffectiveGridSize()&&(e.shiftKey?1:this.getEffectiveGridSize())||(e.shiftKey?5:1),a=0,o=0;e.key===E.ARROW_LEFT?a=-i:e.key===E.ARROW_RIGHT?a=i:e.key===E.ARROW_UP?o=-i:e.key===E.ARROW_DOWN&&(o=i),t.forEach(e=>{V(e,{x:e.x+a,y:e.y+o},!1),ga(e,this.scene.getNonDeletedElementsMap(),{simultaneouslyUpdated:t})}),this.setState({suggestedBindings:ql(t.filter(e=>e.id!==n?.id||i!==0),this.scene.getNonDeletedElementsMap(),this.state.zoom)}),this.scene.triggerUpdate(),e.preventDefault()}else if(e.key===E.ENTER){let t=this.scene.getSelectedElements(this.state);if(t.length===1){let n=t[0];if(e[E.CTRL_OR_CMD])c(n)&&(!this.state.editingLinearElement||this.state.editingLinearElement.elementId!==t[0].id)&&(this.store.shouldCaptureIncrement(),U(n)||this.setState({editingLinearElement:new G(n)}));else if(I(n)||Gt(n)){let t;I(n)||(t=n);let r=Vl(n,this.state,this.scene.getNonDeletedElementsMap()),i=r.x,a=r.y;this.startTextEditing({sceneX:i,sceneY:a,container:t}),e.preventDefault();return}else A(n)&&this.setState({editingFrame:n.id})}}else if(!e.ctrlKey&&!e.altKey&&!e.metaKey&&!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged){let t=cn(e.key);t?(this.state.activeTool.type!==t&&X(`toolbar`,t,`keyboard (${this.device.editor.isMobile?`mobile`:`desktop`})`),t===`arrow`&&this.state.activeTool.type===`arrow`&&this.setState(e=>({currentItemArrowType:e.currentItemArrowType===Ha.sharp?Ha.round:e.currentItemArrowType===Ha.round?Ha.elbow:Ha.sharp})),this.setActiveTool({type:t}),e.stopPropagation()):e.key===E.Q&&(this.toggleLock(`keyboard`),e.stopPropagation())}if(e.key===E.SPACE&&$.pointers.size===0&&(Fk=!0,H(this.interactiveCanvas,N.GRAB),e.preventDefault()),(e.key===E.G||e.key===E.S)&&!e.altKey&&!e[E.CTRL_OR_CMD]){let t=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type===`selection`&&!t.length)return;e.key===E.G&&(Fl(this.state.activeTool.type)||t.some(e=>Fl(e.type)))&&(this.setState({openPopup:`elementBackground`}),e.stopPropagation()),e.key===E.S&&(this.setState({openPopup:`elementStroke`}),e.stopPropagation())}if(!e[E.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===E.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=>I(e)||dr(e,this.scene.getNonDeletedElementsMap())))&&(e.preventDefault(),this.setState({openPopup:`fontFamily`}))}if(e.key===E.K&&!e.altKey&&!e[E.CTRL_OR_CMD]){this.state.activeTool.type===`laser`?this.setActiveTool({type:`selection`}):this.setActiveTool({type:`laser`});return}e[E.CTRL_OR_CMD]&&(e.key===E.BACKSPACE||e.key===E.DELETE)&&Mv.set(XC,`clearCanvas`);let t=e.key.toLocaleLowerCase(),n=t===E.S&&e.shiftKey,r=e.key===E.I||t===E.G&&e.shiftKey;(n||r)&&this.openEyeDropper({type:n?`stroke`:`background`})})),i(this,`onKeyUp`,fO(e=>{if(e.key===E.SPACE&&(this.state.viewModeEnabled||this.state.openDialog?.name===`elementLinkSelector`?H(this.interactiveCanvas,N.GRAB):this.state.activeTool.type===`selection`?ut(this.interactiveCanvas):(Lc(this.interactiveCanvas,this.state),this.setState({selectedElementIds:F({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),Fk=!1),!e[E.CTRL_OR_CMD]&&!this.state.isBindingEnabled&&this.setState({isBindingEnabled:!0}),ne(e.key)&&(jn(this.scene.getSelectedElements(this.state).filter(c),this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements(),this.scene,Ir(this.state),this.state.selectedLinearElement?.selectedPointsIndices??[],this.state.zoom),this.setState({suggestedBindings:[]})),e.altKey||this.flowChartNavigator.isExploring&&(this.flowChartNavigator.clear(),this.syncActionResult({captureUpdate:j.IMMEDIATELY})),!e[E.CTRL_OR_CMD]&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.pendingNodes?.length&&this.scene.insertElements(this.flowChartCreator.pendingNodes);let e=this.flowChartCreator.pendingNodes?.[0];e&&(this.setState(t=>({selectedElementIds:F({[e.id]:!0},t)})),At([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.getEditorUIOffsets())||this.scrollToContent(e,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})),this.flowChartCreator.clear(),this.syncActionResult({captureUpdate:j.IMMEDIATELY})}})),i(this,`isToolSupported`,e=>this.props.UIOptions.tools?.[e]!==!1),i(this,`setActiveTool`,e=>{if(!this.isToolSupported(e.type)){console.warn(`"${e.type}" tool is disabled via "UIOptions.canvasActions.tools.${e.type}"`);return}let t=Sa(this.state,e);t.type===`hand`?H(this.interactiveCanvas,N.GRAB):Fk||Lc(this.interactiveCanvas,{...this.state,activeTool:t}),Jl(document.activeElement)&&this.focusContainer(),b(t.type)||this.setState({suggestedBindings:[]}),t.type===`image`&&this.onImageAction({insertOnCanvasDirectly:(e.type===`image`&&e.insertOnCanvasDirectly)??!1}),this.setState(e=>{let n={snapLines:e.snapLines.length?[]:e.snapLines,originSnapOffset:null,activeEmbeddable:null};return t.type===`freedraw`&&this.store.shouldCaptureIncrement(),t.type===`selection`?{...e,activeTool:t,...n}:{...e,activeTool:t,selectedElementIds:F({},e),selectedGroupIds:F({},e),editingGroupId:null,multiElement:null,...n}})}),i(this,`setOpenDialog`,e=>{this.setState({openDialog:e})}),i(this,`setCursor`,e=>{H(this.interactiveCanvas,e)}),i(this,`resetCursor`,()=>{ut(this.interactiveCanvas)}),i(this,`isTouchScreenMultiTouchGesture`,()=>$.pointers.size>=2),i(this,`getName`,()=>this.state.name||this.props.name||`${J(`labels.untitled`)}-${pn()}`),i(this,`onGestureStart`,fO(e=>{e.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:F({},this.state),activeEmbeddable:null}),$.initialScale=this.state.zoom.value})),i(this,`onGestureChange`,fO(e=>{if(e.preventDefault(),this.isTouchScreenMultiTouchGesture())return;let t=$.initialScale;t&&this.setState(n=>({...Ib({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:He(t*e.scale)},n)}))})),i(this,`onGestureEnd`,fO(e=>{e.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:F(this.state.previousSelectedElementIds,this.state)}),$.initialScale=null})),i(this,`startTextEditing`,({sceneX:e,sceneY:t,insertAtParentCenter:n=!0,container:r,autoEdit:i=!0})=>{let a=!1,o=n&&this.getTextWysiwygSnappedToCenterPosition(e,t,this.state,r);r&&o&&(dr(r,this.scene.getNonDeletedElementsMap())||(a=!0));let s=null,c=this.scene.getSelectedElements(this.state);s=c.length===1?I(c[0])?c[0]:r?dr(c[0],this.scene.getNonDeletedElementsMap()):this.getTextElementAtPosition(e,t):this.getTextElementAtPosition(e,t);let l=s?.fontFamily||this.state.currentItemFontFamily,u=s?.lineHeight||vc(l),d=this.state.currentItemFontSize;if(!s&&a&&r&&!st(r)){let n=sl(Ds({fontSize:d,fontFamily:l}),u),i=Ur(d,u),a=Math.max(r.height,i),s=Math.max(r.width,n);V(r,{height:a,width:s}),e=r.x+s/2,t=r.y+a/2,o&&=this.getTextWysiwygSnappedToCenterPosition(e,t,this.state,r)}let f=this.getTopLayerFrameAtSceneCoords({x:e,y:t}),p=s||ds({x:o?o.elementCenterX:e,y:o?o.elementCenterY:t,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:``,fontSize:d,fontFamily:l,textAlign:o?`center`:this.state.currentItemTextAlign,verticalAlign:o?Oc.MIDDLE:`top`,containerId:a?r?.id:void 0,groupIds:r?.groupIds??[],lineHeight:u,angle:r?.angle??0,frameId:f?f.id:null});if(!s&&a&&r&&V(r,{boundElements:(r.boundElements||[]).concat({type:`text`,id:p.id})}),this.setState({editingTextElement:p}),!s)if(r&&a){let e=this.scene.getElementIndex(r.id);this.scene.insertElementAtIndex(p,e+1)}else this.scene.insertElement(p);i||s||r?this.handleTextWysiwyg(p,{isExistingElement:!!s}):this.setState({newElement:p,multiElement:null})}),i(this,`startImageCropping`,e=>{this.store.shouldCaptureIncrement(),this.setState({croppingElementId:e.id})}),i(this,`finishImageCropping`,()=>{this.state.croppingElementId&&(this.store.shouldCaptureIncrement(),this.setState({croppingElementId:null}))}),i(this,`handleCanvasDoubleClick`,e=>{if(this.state.multiElement||this.state.activeTool.type!==`selection`)return;let t=this.scene.getSelectedElements(this.state),{x:n,y:r}=Ls(e,this.state);if(t.length===1&&c(t[0])){if(e[E.CTRL_OR_CMD]&&(!this.state.editingLinearElement||this.state.editingLinearElement.elementId!==t[0].id)&&!U(t[0])){this.store.shouldCaptureIncrement(),this.setState({editingLinearElement:new G(t[0])});return}else if(this.state.selectedLinearElement&&U(t[0])){let e=G.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:n,y:r},this.state,this.scene.getNonDeletedElementsMap()),i=e?G.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,e,this.scene.getNonDeletedElementsMap()):-1;if(i&&i>-1){this.store.shouldCaptureIncrement(),G.deleteFixedSegment(t[0],i);let a=G.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:n,y:r},this.state,this.scene.getNonDeletedElementsMap()),o=a?G.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,a,this.scene.getNonDeletedElementsMap()):null;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:{...this.state.selectedLinearElement.pointerDownState,segmentMidpoint:{index:o,value:e,added:!1}},segmentMidPointHoveredCoords:a}});return}}}if(t.length===1&&El(t[0])){this.startImageCropping(t[0]);return}if(ut(this.interactiveCanvas),_n(this.state).length>0){let e=this.getElementAtPosition(n,r),t=e&&eo(e,this.state.selectedGroupIds);if(t){this.store.shouldCaptureIncrement(),this.setState(n=>({...n,...Fi({editingGroupId:t,selectedElementIds:{[e.id]:!0}},this.scene.getNonDeletedElements(),n,this)}));return}}if(ut(this.interactiveCanvas),!e[E.CTRL_OR_CMD]&&!this.state.viewModeEnabled){let t=this.getElementAtPosition(n,r);if(fl(t)){this.setState({activeEmbeddable:{element:t,state:`active`}});return}let i=this.getTextBindableContainerAtPosition(n,r);if(i&&(ws(i)||!Rc(i.backgroundColor)||Lr({x:n,y:r,element:i,shape:Ye(i,this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold()}))){let e=Vl(i,this.state,this.scene.getNonDeletedElementsMap());n=e.x,r=e.y}this.startTextEditing({sceneX:n,sceneY:r,insertAtParentCenter:!e.altKey,container:i})}}),i(this,`getElementLinkAtPosition`,(e,t)=>{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&&Zo(a,this.scene.getNonDeletedElementsMap(),this.state,P(e.x,e.y),this.device.editor.isMobile))return a}}),i(this,`redirectToLink`,(e,t)=>{let n=eu(P(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),P(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||n>10)return;let r=Ls(this.lastPointerDownEvent,this.state),i=this.scene.getNonDeletedElementsMap(),a=Zo(this.hitLinkElement,i,this.state,P(r.x,r.y),this.device.editor.isMobile),o=Ls(this.lastPointerUpEvent,this.state),s=Zo(this.hitLinkElement,i,this.state,P(o.x,o.y),this.device.editor.isMobile);if(a&&s){fS();let t=this.hitLinkElement.link;if(t){t=on(t);let n;if(this.props.onLinkOpen&&(n=tt(`excalidraw-link`,e.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:t},n)),!n?.defaultPrevented){let e=za(t)?`_self`:`_blank`,n=window.open(void 0,e);n&&(n.opener=null,n.location=t)}}}}),i(this,`getTopLayerFrameAtSceneCoords`,e=>{let t=this.scene.getNonDeletedElementsMap(),n=this.scene.getNonDeletedFramesLikes().filter(n=>pa(e,n,t));return n.length?n[n.length-1]:null}),i(this,`handleCanvasPointerMove`,e=>{this.savePointer(e.clientX,e.clientY,this.state.cursorButton),this.lastPointerMoveEvent=e.nativeEvent,$.pointers.has(e.pointerId)&&$.pointers.set(e.pointerId,{x:e.clientX,y:e.clientY});let t=$.initialScale;if($.pointers.size===2&&$.lastCenter&&t&&$.initialDistance){let e=xw($.pointers),n=e.x-$.lastCenter.x,r=e.y-$.lastCenter.y;$.lastCenter=e;let i=Sw(Array.from($.pointers.values())),a=this.state.activeTool.type===`freedraw`&&this.state.penMode?1:i/$.initialDistance,o=a?He(t*a):this.state.zoom.value;this.setState(t=>{let i=Ib({viewportX:e.x,viewportY:e.y,nextZoom:o},t);this.translateCanvas({zoom:i.zoom,scrollX:i.scrollX+n/o*2,scrollY:i.scrollY+r/o*2,shouldCacheIgnoreZoom:!0})}),this.resetShouldCacheIgnoreZoomDebounced()}else $.lastCenter=$.initialDistance=$.initialScale=null;if(Fk||Ik||Lk||Ho(this.state))return;let n=cT(Rk,e.clientX-this.state.offsetLeft,e.clientY-this.state.offsetTop).isOverEither;!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.multiElement&&(n?ut(this.interactiveCanvas):Lc(this.interactiveCanvas,this.state));let r=Ls(e,this.state),{x:i,y:a}=r;if(!this.state.newElement&&hi(this.state.activeTool.type)){let{originOffset:t,snapLines:n}=Zl(this.scene.getNonDeletedElements(),this,{x:i,y:a},e,this.scene.getNonDeletedElementsMap());this.setState(e=>{let r=Xa(e.snapLines,n),i=e.originSnapOffset?Xa(e.originSnapOffset,t):t;return e.snapLines===r&&e.originSnapOffset===i?null:{snapLines:r,originSnapOffset:i}})}else !this.state.newElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.selectionElement&&this.setState(e=>e.snapLines.length?{snapLines:[]}:null);if(this.state.editingLinearElement&&!this.state.editingLinearElement.isDragging){let t=G.handlePointerMove(e,i,a,this,this.scene.getNonDeletedElementsMap());t&&t!==this.state.editingLinearElement&&(0,Ju.flushSync)(()=>{this.setState({editingLinearElement:t})}),t?.lastUncommittedPoint==null?(0,Ju.flushSync)(()=>{this.setState({suggestedBindings:[]})}):this.maybeSuggestBindingAtCursor(r,t.elbowed)}if(ka(this.state.activeTool.type)){let{newElement:e}=this.state;le(e,!1)?this.maybeSuggestBindingsForLinearElementAtCoords(e,[r],this.state.startBoundElement):this.maybeSuggestBindingAtCursor(r,!1)}if(this.state.multiElement){let{multiElement:t}=this.state,{x:n,y:r}=t,{points:o,lastCommittedPoint:s}=t,c=o[o.length-1];if(Lc(this.interactiveCanvas,this.state),c===s)eu(P(i-n,a-r),c)>=8?V(t,{points:[...o,P(i-n,a-r)]},!1):H(this.interactiveCanvas,N.POINTER);else if(o.length>2&&s&&eu(P(i-n,a-r),s)<8)H(this.interactiveCanvas,N.POINTER),V(t,{points:o.slice(0,-1)},!1);else{let[s,c]=ht(i,a,e[E.CTRL_OR_CMD]||U(t)?null:this.getEffectiveGridSize()),[l,u]=t?.lastCommittedPoint??[0,0],d=s-n-l,f=c-r-u;Es(e)&&({width:d,height:f}=fr(l+n,u+r,s,c)),qn(o,this.state.zoom.value)&&H(this.interactiveCanvas,N.POINTER),V(t,{points:[...o.slice(0,-1),P(l+d,u+f)]},!1,{isDragging:!0}),this.triggerRender(!1)}return}if(e.buttons||this.state.activeTool.type!==`selection`&&this.state.activeTool.type!==`text`&&this.state.activeTool.type!==`eraser`)return;let o=this.scene.getNonDeletedElements(),s=this.scene.getSelectedElements(this.state);if(s.length===1&&!n&&!this.state.editingLinearElement){if(this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,i,a),(!this.state.selectedLinearElement||this.state.selectedLinearElement.hoverPointIndex===-1)&&this.state.openDialog?.name!==`elementLinkSelector`&&!(s.length===1&&U(s[0]))){let t=nl(o,this.state,i,a,this.state.zoom,e.pointerType,this.scene.getNonDeletedElementsMap(),this.device);if(t&&t.transformHandleType){H(this.interactiveCanvas,Nl(t));return}}}else if(s.length>1&&!n&&this.state.openDialog?.name!==`elementLinkSelector`){let t=tl(Ao(s),i,a,this.state.zoom,e.pointerType,this.device);if(t){H(this.interactiveCanvas,Nl({transformHandleType:t}));return}}let c=this.getElementAtPosition(r.x,r.y);this.hitLinkElement=this.getElementLinkAtPosition(r,c),!hn(this.state)&&(this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(H(this.interactiveCanvas,N.POINTER),uS(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap())):(fS(),c&&(c.link||St(c))&&this.state.selectedElementIds[c.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:`info`}):this.state.activeTool.type===`text`?H(this.interactiveCanvas,I(c)?N.TEXT:N.CROSSHAIR):this.state.viewModeEnabled?H(this.interactiveCanvas,N.GRAB):this.state.openDialog?.name===`elementLinkSelector`||n?H(this.interactiveCanvas,N.AUTO):this.state.selectedLinearElement?this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,i,a):e[E.CTRL_OR_CMD]?H(this.interactiveCanvas,N.AUTO):(c||this.isHittingCommonBoundingBoxOfSelectedElements(r,s))&&!c?.locked&&(c&&fl(c)&&this.isIframeLikeElementCenter(c,e,i,a)?(H(this.interactiveCanvas,N.POINTER),this.setState({activeEmbeddable:{element:c,state:`hover`}})):(!c||!U(c))&&(H(this.interactiveCanvas,N.MOVE),this.state.activeEmbeddable?.state===`hover`&&this.setState({activeEmbeddable:null})))),this.state.openDialog?.name===`elementLinkSelector`&&c?this.setState(e=>({hoveredElementIds:Xa(e.hoveredElementIds,Fi({editingGroupId:e.editingGroupId,selectedElementIds:{[c.id]:!0}},this.scene.getNonDeletedElements(),e,this).selectedElementIds)})):this.state.openDialog?.name===`elementLinkSelector`&&!c&&this.setState(e=>({hoveredElementIds:Xa(e.hoveredElementIds,{})})))}),i(this,`handleEraser`,(e,t,n)=>{this.eraserTrail.addPointToPath(n.x,n.y);let r=!1,i=new Set,a=this.scene.getNonDeletedElements(),o=t=>{for(let n of t){if(n.locked)return;if(e.altKey?this.elementsPendingErasure.delete(n.id)&&(r=!0):this.elementsPendingErasure.has(n.id)||(r=!0,this.elementsPendingErasure.add(n.id)),r&&n.groupIds?.length){let t=n.groupIds.at(-1);if(!i.has(t)){i.add(t);let n=Wc(a,t);for(let t of n)e.altKey?this.elementsPendingErasure.delete(t.id):this.elementsPendingErasure.add(t.id)}}}},s=eu(P(t.lastCoords.x,t.lastCoords.y),P(n.x,n.y)),c=this.getElementHitThreshold(),l={...t.lastCoords},u=0;for(;u<=s&&(o(this.getElementsAtPosition(l.x,l.y)),u!==s);){u=Math.min(u+c,s);let e=u/s,t=(1-e)*l.x+e*n.x,r=(1-e)*l.y+e*n.y;l.x=t,l.y=r}if(t.lastCoords.x=n.x,t.lastCoords.y=n.y,r){for(let t of this.scene.getNonDeletedElements())nc(t)&&(this.elementsPendingErasure.has(t.id)||this.elementsPendingErasure.has(t.containerId))&&(e.altKey?(this.elementsPendingErasure.delete(t.id),this.elementsPendingErasure.delete(t.containerId)):(this.elementsPendingErasure.add(t.id),this.elementsPendingErasure.add(t.containerId)));this.elementsPendingErasure=new Set(this.elementsPendingErasure),this.triggerRender()}}),i(this,`handleTouchMove`,e=>{Bk=!0}),i(this,`handleCanvasPointerDown`,e=>{let t=e.target;if(t.setPointerCapture&&t.setPointerCapture(e.pointerId),this.maybeCleanupAfterMissingPointerUp(e.nativeEvent),this.maybeUnfollowRemoteUser(),this.state.searchMatches&&(this.setState(e=>({searchMatches:e.searchMatches.map(e=>({...e,focus:!1}))})),Mv.set(pE,null)),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),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,startBoundElement:null,suggestedBindings:[],selectedElementIds:F(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 n=document.getSelection();if(n?.anchorNode&&n.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(e),!this.state.penDetected&&e.pointerType===`pen`&&this.setState(e=>({penMode:!0,penDetected:!0})),!this.device.isTouchScreen&&[`pen`,`touch`].includes(e.pointerType)&&(this.device=aa(this.device,{isTouchScreen:!0})),Ik||(this.lastPointerDownEvent=e,this.handleCanvasPanUsingWheelOrSpaceDrag(e)))return;if(this.setState({lastPointerDownWith:e.pointerType,cursorButton:`down`}),this.savePointer(e.clientX,e.clientY,`down`),e.button===Ll.ERASER&&this.state.activeTool.type!==Pc.eraser){this.setState({activeTool:Sa(this.state,{type:Pc.eraser,lastActiveToolBeforeEraser:this.state.activeTool})},()=>{this.handleCanvasPointerDown(e);let t=()=>{n(),r?.(),hn(this.state)&&this.setState({activeTool:Sa(this.state,{...this.state.activeTool.lastActiveTool||{type:Pc.selection},lastActiveToolBeforeEraser:null})})},n=Vs(window,`pointerup`,t,{once:!0}),r;requestAnimationFrame(()=>{r=this.missingPointerEventCleanupEmitter.once(t)})});return}if(e.button!==Ll.MAIN&&e.button!==Ll.TOUCH&&e.button!==Ll.ERASER||$.pointers.size>1)return;let r=this.initialPointerDownState(e);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleDraggingScrollBar(e,r)||(this.clearSelectionIfNotUsingSelection(),this.updateBindingEnabledOnPointerMove(e),this.handleSelectionOnPointerDown(e,r))||!(!this.state.penMode||e.pointerType!==`touch`||this.state.activeTool.type===`selection`||this.state.activeTool.type===`text`||this.state.activeTool.type===`image`))return;if(this.state.activeTool.type===`text`)this.handleTextOnPointerDown(e,r);else if(this.state.activeTool.type===`arrow`||this.state.activeTool.type===`line`)this.handleLinearElementOnPointerDown(e,this.state.activeTool.type,r);else if(this.state.activeTool.type===`image`){H(this.interactiveCanvas,N.CROSSHAIR);let t=this.state.pendingImageElementId&&this.scene.getElement(this.state.pendingImageElementId);if(!t)return;this.setState({newElement:t,pendingImageElementId:null,multiElement:null});let{x:n,y:r}=Ls(e,this.state),i=this.getTopLayerFrameAtSceneCoords({x:n,y:r});V(t,{x:n,y:r,frameId:i?i.id:null})}else this.state.activeTool.type===`freedraw`?this.handleFreeDrawElementOnPointerDown(e,this.state.activeTool.type,r):this.state.activeTool.type===`custom`?Lc(this.interactiveCanvas,this.state):this.state.activeTool.type===Pc.frame||this.state.activeTool.type===Pc.magicframe?this.createFrameElementOnPointerDown(r,this.state.activeTool.type):this.state.activeTool.type===`laser`?this.laserTrails.startPath(r.lastCoords.x,r.lastCoords.y):this.state.activeTool.type!==`eraser`&&this.state.activeTool.type!==`hand`&&this.createGenericElementOnPointerDown(this.state.activeTool.type,r);this.props?.onPointerDown?.(this.state.activeTool,r),this.onPointerDownEmitter.trigger(this.state.activeTool,r,e),this.state.activeTool.type===`eraser`&&this.eraserTrail.startPath(r.lastCoords.x,r.lastCoords.y);let i=this.onPointerMoveFromPointerDownHandler(r),a=this.onPointerUpFromPointerDownHandler(r),o=this.onKeyDownFromPointerDownHandler(r),s=this.onKeyUpFromPointerDownHandler(r);this.missingPointerEventCleanupEmitter.once(t=>a(t||e.nativeEvent)),(!this.state.viewModeEnabled||this.state.activeTool.type===`laser`)&&(window.addEventListener(`pointermove`,i),window.addEventListener(`pointerup`,a),window.addEventListener(`keydown`,o),window.addEventListener(`keyup`,s),r.eventListeners.onMove=i,r.eventListeners.onUp=a,r.eventListeners.onKeyUp=s,r.eventListeners.onKeyDown=o)}),i(this,`handleCanvasPointerUp`,e=>{this.removePointer(e),this.lastPointerUpEvent=e;let t=Ls({clientX:e.clientX,clientY:e.clientY},this.state),n=e.timeStamp-(this.lastPointerDownEvent?.timeStamp??0);if(this.device.editor.isMobile&&n<300){let n=this.getElementAtPosition(t.x,t.y);if(fl(n)&&this.isIframeLikeElementCenter(n,e,t.x,t.y)){this.handleEmbeddableCenterClick(n);return}}if(this.device.isTouchScreen){let e=this.getElementAtPosition(t.x,t.y);this.hitLinkElement=this.getElementLinkAtPosition(t,e)}this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?n<300&&fl(this.hitLinkElement)&&!Oa(this.hitLinkElement,this.scene.getNonDeletedElementsMap(),this.state,P(t.x,t.y))?this.handleEmbeddableCenterClick(this.hitLinkElement):this.redirectToLink(e,this.device.isTouchScreen):this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})}),i(this,`maybeOpenContextMenuAfterPointerDownOnTouchDevices`,e=>{e.pointerType===`touch`&&(Bk=!1,zk?Bk=!0:zk=window.setTimeout(()=>{zk=0,Bk||this.handleCanvasContextMenu(e)},500))}),i(this,`resetContextMenuTimer`,()=>{clearTimeout(zk),zk=0,Bk=!1}),i(this,`maybeCleanupAfterMissingPointerUp`,e=>{Gk?.(),this.missingPointerEventCleanupEmitter.trigger(e).clear()}),i(this,`handleCanvasPanUsingWheelOrSpaceDrag`,e=>{if(!($.pointers.size<=1&&(e.button===Ll.WHEEL||e.button===Ll.MAIN&&Fk||Ho(this.state)||this.state.viewModeEnabled)))return!1;Ik=!0,this.focusContainer(),this.state.editingTextElement||e.preventDefault();let t=!1,n=/Linux/.test(window.navigator.platform);H(this.interactiveCanvas,N.GRABBING);let{clientX:r,clientY:i}=e,a=pO(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(`paste`,e),t.stopPropagation()},n=()=>{setTimeout(()=>{document.body.removeEventListener(`paste`,e),window.removeEventListener(`pointerup`,n)},100)};document.body.addEventListener(`paste`,e),window.addEventListener(`pointerup`,n)}this.translateCanvas({scrollX:this.state.scrollX-a/this.state.zoom.value,scrollY:this.state.scrollY-o/this.state.zoom.value})}),o=fO(Gk=()=>{Gk=null,Ik=!1,Fk||(this.state.viewModeEnabled?H(this.interactiveCanvas,N.GRAB):Lc(this.interactiveCanvas,this.state)),this.setState({cursorButton:`up`}),this.savePointer(e.clientX,e.clientY,`up`),window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),window.removeEventListener(`blur`,o),a.flush()});return window.addEventListener(`blur`,o),window.addEventListener(`pointermove`,a,{passive:!0}),window.addEventListener(`pointerup`,o),!0}),i(this,`clearSelectionIfNotUsingSelection`,()=>{this.state.activeTool.type!==`selection`&&this.setState({selectedElementIds:F({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}),i(this,`handleSelectionOnPointerDown`,(e,t)=>{if(this.state.activeTool.type===`selection`){let n=this.scene.getNonDeletedElements(),r=this.scene.getNonDeletedElementsMap(),i=this.scene.getSelectedElements(this.state);if(i.length===1&&!this.state.editingLinearElement&&!U(i[0])&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let r=nl(n,this.state,t.origin.x,t.origin.y,this.state.zoom,e.pointerType,this.scene.getNonDeletedElementsMap(),this.device);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=tl(Ao(i),t.origin.x,t.origin.y,this.state.zoom,e.pointerType,this.device));if(t.resize.handleType)t.resize.isResizing=!0,t.resize.offset=yi(Qs(t.resize.handleType,i,r,t.origin.x,t.origin.y)),i.length===1&&c(i[0])&&i[0].points.length===2&&(t.resize.arrowDirection=rr(t.resize.handleType,i[0]));else{if(this.state.selectedLinearElement){let n=this.state.editingLinearElement||this.state.selectedLinearElement,r=G.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}),this.state.editingLinearElement&&this.setState({editingLinearElement:r.linearElementEditor})),r.didAddPoint)return!0}if(t.hit.element=t.hit.element??this.getElementAtPosition(t.origin.x,t.origin.y),this.hitLinkElement=this.getElementLinkAtPosition(t.origin,t.hit.element),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=this.getElementsAtPosition(t.origin.x,t.origin.y);let n=t.hit.element,r=t.hit.allHitElements.some(e=>this.isASelectedElement(e));if((n===null||!r)&&!e.shiftKey&&!t.hit.hasHitCommonBoundingBoxOfSelectedElements&&this.clearSelection(n),this.state.editingLinearElement)this.setState({selectedElementIds:F({[this.state.editingLinearElement.elementId]:!0},this.state)});else if(n!=null){if(e[E.CTRL_OR_CMD])return this.state.selectedElementIds[n.id]||(t.hit.wasAddedToSelection=!0),this.setState(e=>({...jl(e,n),previousSelectedElementIds:this.state.selectedElementIds})),!1;this.state.selectedElementIds[n.id]||(this.state.editingGroupId&&!_t(n,this.state.editingGroupId)&&this.setState({selectedElementIds:F({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!r&&!t.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(e=>{let t={...e.selectedElementIds,[n.id]:!0},r=[];if(Object.keys(e.selectedElementIds).forEach(e=>{let t=this.scene.getElement(e);t&&r.push(t)}),A(n))xl(r,n.id).forEach(e=>{delete t[e.id]});else if(n.frameId)t[n.frameId]&&delete t[n.id];else{let e=n.groupIds,i=new Set(e.flatMap(e=>Wc(this.scene.getNonDeletedElements(),e)).filter(e=>A(e)).map(e=>e.id));i.size>0&&r.forEach(e=>{e.frameId&&i.has(e.frameId)&&(delete t[e.id],e.groupIds.flatMap(e=>Wc(this.scene.getNonDeletedElements(),e)).forEach(e=>{delete t[e.id]}))})}return e.openDialog?.name===`elementLinkSelector`&&(n.groupIds.some(t=>e.selectedGroupIds[t])||(t={[n.id]:!0})),{...Fi({editingGroupId:e.editingGroupId,selectedElementIds:t},this.scene.getNonDeletedElements(),e,this),showHyperlinkPopup:n.link||St(n)?`info`:!1}}),t.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1}),i(this,`handleTextOnPointerDown`,(e,t)=>{if(this.state.editingTextElement)return;let n=t.origin.x,r=t.origin.y,i=this.getElementAtPosition(n,r,{includeBoundTextElement:!0}),a=this.getTextBindableContainerAtPosition(n,r);ws(i)&&(a=i,n=i.x+i.width/2,r=i.y+i.height/2),this.startTextEditing({sceneX:n,sceneY:r,insertAtParentCenter:!e.altKey,container:a,autoEdit:!1}),ut(this.interactiveCanvas),this.state.activeTool.locked||this.setState({activeTool:Sa(this.state,{type:`selection`})})}),i(this,`handleFreeDrawElementOnPointerDown`,(e,t,n)=>{let[r,i]=ht(n.origin.x,n.origin.y,null),a=this.getTopLayerFrameAtSceneCoords({x:r,y:i}),o=e.pressure===.5,s=h({type:t,x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:null,simulatePressure:o,locked:!1,frameId:a?a.id:null,points:[P(0,0)],pressures:o?[]:[e.pressure]});this.scene.insertElement(s),this.setState(e=>{let t={...e.selectedElementIds};return delete t[s.id],{selectedElementIds:F(t,e)}});let c=Ke(n.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom);this.setState({newElement:s,startBoundElement:c,suggestedBindings:[]})}),i(this,`insertIframeElement`,({sceneX:e,sceneY:t,width:n,height:r})=>{let[i,a]=ht(e,t,this.lastPointerDownEvent?.[E.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),o=Ms({type:`iframe`,x:i,y:a,strokeColor:`transparent`,backgroundColor:`transparent`,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness(`iframe`),opacity:this.state.currentItemOpacity,locked:!1,width:n,height:r});return this.scene.insertElement(o),o}),i(this,`insertEmbeddableElement`,({sceneX:e,sceneY:t,link:n})=>{let[r,i]=ht(e,t,this.lastPointerDownEvent?.[E.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=Je(n);if(!a)return;a.error instanceof URIError&&this.setToast({message:J(`toast.unrecognizedLinkFormat`),closable:!0});let o=rn({type:`embeddable`,x:r,y:i,strokeColor:`transparent`,backgroundColor:`transparent`,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,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.scene.insertElement(o),o}),i(this,`createImageElement`,({sceneX:e,sceneY:t,addToFrameUnderCursor:n=!0})=>{let[r,i]=ht(e,t,this.lastPointerDownEvent?.[E.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=n?this.getTopLayerFrameAtSceneCoords({x:r,y:i}):null;return vi({type:`image`,x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:null,opacity:this.state.currentItemOpacity,locked:!1,frameId:a?a.id:null})}),i(this,`handleLinearElementOnPointerDown`,(e,t,n)=>{if(this.state.multiElement){let{multiElement:e}=this.state;if(e.type===`line`&&qn(e.points,this.state.zoom.value)){V(e,{lastCommittedPoint:e.points[e.points.length-1]}),this.actionManager.executeAction(Xb);return}if(U(e)&&e.points.length>1){V(e,{lastCommittedPoint:e.points[e.points.length-1]}),this.actionManager.executeAction(Xb);return}let{x:t,y:r,lastCommittedPoint:i}=e;if(e.points.length>1&&i&&eu(P(n.origin.x-t,n.origin.y-r),i)<8){this.actionManager.executeAction(Xb);return}this.setState(t=>({selectedElementIds:F({...t.selectedElementIds,[e.id]:!0},t)})),V(e,{lastCommittedPoint:e.points[e.points.length-1]}),H(this.interactiveCanvas,N.POINTER)}else{let[r,i]=ht(n.origin.x,n.origin.y,e[E.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`?y({type:t,x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemArrowType===Ha.round?{type:Zr.PROPORTIONAL_RADIUS}:null,startArrowhead:c,endArrowhead:l,locked:!1,frameId:a?a.id:null,elbowed:this.state.currentItemArrowType===Ha.elbow,fixedSegments:this.state.currentItemArrowType===Ha.elbow?[]:null}):rs({type:t,x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemRoundness===`round`?{type:Zr.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:a?a.id:null});this.setState(e=>{let t={...e.selectedElementIds};return delete t[u.id],{selectedElementIds:F(t,e)}}),V(u,{points:[...u.points,P(0,0)]});let d=Ke(n.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,U(u),U(u));this.scene.insertElement(u),this.setState({newElement:u,startBoundElement:d,suggestedBindings:[]})}}),i(this,`createGenericElementOnPointerDown`,(e,t)=>{let[n,r]=ht(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[E.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.state.currentItemStrokeWidth,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`?rn({type:`embeddable`,...a}):Xs({type:e,...a}),o.type===`selection`?this.setState({selectionElement:o}):(this.scene.insertElement(o),this.setState({multiElement:null,newElement:o}))}),i(this,`createFrameElementOnPointerDown`,(e,t)=>{let[n,r]=ht(e.origin.x,e.origin.y,this.lastPointerDownEvent?.[E.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),i={x:n,y:r,opacity:this.state.currentItemOpacity,locked:!1,...kt},a=t===Pc.magicframe?kn(i):Dc(i);this.scene.insertElement(a),this.setState({multiElement:null,newElement:a})}),i(this,`restoreReadyToEraseElements`,()=>{this.elementsPendingErasure=new Set,this.triggerRender()}),i(this,`eraseElements`,()=>{let e=!1,t=this.scene.getElementsIncludingDeleted().map(t=>this.elementsPendingErasure.has(t.id)||t.frameId&&this.elementsPendingErasure.has(t.frameId)||nc(t)&&this.elementsPendingErasure.has(t.containerId)?(e=!0,z(t,{isDeleted:!0})):t);this.elementsPendingErasure=new Set,e&&(this.store.shouldCaptureIncrement(),this.scene.replaceAllElements(t))}),i(this,`initializeImage`,async({imageFile:e,imageElement:t,showCursorImagePreview:n=!1})=>{if(!hc(e))throw Error(J(`errors.unsupportedFileType`));let r=e.type;if(H(this.interactiveCanvas,`wait`),r===de.svg)try{e=Pr($r(await e.text()),e.name)}catch(e){throw console.warn(e),Error(J(`errors.svgImageInsertError`))}let i=await(this.props.generateIdForFile?.(e)||_c(e));if(!i)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),Error(J(`errors.imageInsertError`));if(!this.files[i]?.dataURL){try{e=await re(e,{maxWidthOrHeight:be})}catch(e){console.error(`Error trying to resizing image file on insertion`,e)}if(e.size>4194304)throw Error(J(`errors.fileTooBig`,{maxSize:`${Math.trunc(Qa/1024/1024)}MB`}))}if(n){let t=this.files[i]?.dataURL,n=t&&wl(t);this.setImagePreviewCursor(n||e)}let a=this.files[i]?.dataURL||await Qe(e),o=V(t,{fileId:i},!1);return new Promise(async(e,t)=>{try{this.addMissingFiles([{mimeType:r,id:i,dataURL:a,created:Date.now(),lastRetrieved:Date.now()}]);let t=this.imageCache.get(i);t||(this.addNewImagesToImageCache(),await this.updateImageCache([o])),t?.image instanceof Promise&&await t.image,this.state.pendingImageElementId!==o.id&&this.state.newElement?.id!==o.id&&this.initializeImageDimensions(o,!0),e(o)}catch(e){console.error(e),t(Error(J(`errors.imageInsertError`)))}finally{n||ut(this.interactiveCanvas)}})}),i(this,`insertImageElement`,async(e,t,n)=>{if(!this.isToolSupported(`image`)){this.setState({errorMessage:J(`errors.imageToolNotSupported`)});return}this.scene.insertElement(e);try{return await this.initializeImage({imageFile:t,imageElement:e,showCursorImagePreview:n})}catch(t){return V(e,{isDeleted:!0}),this.actionManager.executeAction(Xb),this.setState({errorMessage:t.message||J(`errors.imageInsertError`)}),null}}),i(this,`setImagePreviewCursor`,async e=>{let t;try{t=await re(e,{maxWidthOrHeight:96})}catch(e){throw e.cause===`UNSUPPORTED`?Error(J(`errors.unsupportedFileType`)):e}let n=await Qe(t);if(e.type===de.svg){let e=await gt(n),t=Math.min(e.height,96),r=t*(e.width/e.height);r>96&&(r=96,t=r*(e.height/e.width));let i=document.createElement(`canvas`);i.height=t,i.width=r,i.getContext(`2d`).drawImage(e,0,0,r,t),n=i.toDataURL(de.svg)}this.state.pendingImageElementId&&H(this.interactiveCanvas,`url(${n}) 4 4, auto`)}),i(this,`onImageAction`,async({insertOnCanvasDirectly:e})=>{try{let{x:t,y:n}=Ls({clientX:this.state.width/2+this.state.offsetLeft,clientY:this.state.height/2+this.state.offsetTop},this.state),r=await Ie({description:`Image`,extensions:Object.keys(Mt)}),i=this.createImageElement({sceneX:t,sceneY:n,addToFrameUnderCursor:!1});e?(this.insertImageElement(i,r),this.initializeImageDimensions(i),this.setState({selectedElementIds:F({[i.id]:!0},this.state)},()=>{this.actionManager.executeAction(Xb)})):this.setState({pendingImageElementId:i.id},()=>{this.insertImageElement(i,r,!0)})}catch(e){e.name===`AbortError`?console.warn(e):console.error(e),this.setState({pendingImageElementId:null,newElement:null,activeTool:Sa(this.state,{type:`selection`})},()=>{this.actionManager.executeAction(Xb)})}}),i(this,`initializeImageDimensions`,(e,t=!1)=>{let n=pe(e)&&this.imageCache.get(e.fileId)?.image;if(!n||n instanceof Promise){if(e.width<10/this.state.zoom.value&&e.height<10/this.state.zoom.value){let t=100/this.state.zoom.value;V(e,{x:e.x-t/2,y:e.y-t/2,width:t,height:t})}return}if(t||e.width<10/this.state.zoom.value&&e.height<10/this.state.zoom.value){let t=Math.max(this.state.height-120,160),r=Math.min(t,Math.floor(this.state.height*.5)/this.state.zoom.value),i=Math.min(n.naturalHeight,r),a=i*(n.naturalWidth/n.naturalHeight);V(e,{x:e.x+e.width/2-a/2,y:e.y+e.height/2-i/2,width:a,height:i,crop:null})}}),i(this,`updateImageCache`,async(e,t=this.files)=>{let{updatedFiles:n,erroredFiles:r}=await zt({imageCache:this.imageCache,fileIds:e.map(e=>e.fileId),files:t});if(n.size||r.size)for(let t of e)n.has(t.fileId)&&Ue.delete(t);return r.size&&this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(e=>pe(e)&&r.has(e.fileId)?z(e,{status:`error`}):e)),{updatedFiles:n,erroredFiles:r}}),i(this,`addNewImagesToImageCache`,async(e=an(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);e.size&&this.scene.triggerUpdate()}}),i(this,`scheduleImageRefresh`,(0,Ig.default)(()=>{this.addNewImagesToImageCache()},500)),i(this,`updateBindingEnabledOnPointerMove`,e=>{let t=Dr(e);this.state.isBindingEnabled!==t&&this.setState({isBindingEnabled:t})}),i(this,`maybeSuggestBindingAtCursor`,(e,t)=>{let n=Ke(e,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,!1,t);this.setState({suggestedBindings:n==null?[]:[n]})}),i(this,`maybeSuggestBindingsForLinearElementAtCoords`,(e,t,n)=>{if(!t.length)return;let r=t.reduce((t,r)=>{let i=Ke(r,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,U(e),U(e));return i!=null&&!$n(e,n?.id,i)&&t.push(i),t},[]);this.setState({suggestedBindings:r})}),i(this,`handleInteractiveCanvasRef`,e=>{e===null?(this.interactiveCanvas?.removeEventListener(`touchstart`,this.onTouchStart),this.interactiveCanvas?.removeEventListener(`touchend`,this.onTouchEnd)):(this.interactiveCanvas=e,this.interactiveCanvas.addEventListener(`touchstart`,this.onTouchStart,{passive:!1}),this.interactiveCanvas.addEventListener(`touchend`,this.onTouchEnd))}),i(this,`handleAppOnDrop`,async e=>{let{file:t,fileHandle:n}=await ke(e),{x:r,y:i}=Ls(e,this.state);try{if(hc(t)&&this.isToolSupported(`image`)){if(t?.type===de.png||t?.type===de.svg)try{let e=await fe(t,this.state,this.scene.getElementsIncludingDeleted(),n);this.syncActionResult({...e,appState:{...e.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:j.IMMEDIATELY});return}catch(e){if(e.name!==`EncodingError`)throw Error(J(`alerts.couldNotLoadInvalidFile`))}let e=this.createImageElement({sceneX:r,sceneY:i});this.insertImageElement(e,t),this.initializeImageDimensions(e),this.setState({selectedElementIds:F({[e.id]:!0},this.state)});return}}catch(e){return this.setState({isLoading:!1,errorMessage:e.message})}let a=e.dataTransfer.getData(de.excalidrawlib);if(a&&typeof a==`string`){try{let t=Ia(a);this.addElementsFromPasteOrLibrary({elements:MS(t),position:e,files:null})}catch(e){this.setState({errorMessage:e.message})}return}if(t&&await this.loadFileToCanvas(t,n),e.dataTransfer?.types?.includes(`text/plain`)){let t=e.dataTransfer?.getData(`text`);if(t&&Il(t,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(t)||Je(t)?.type===`video`)){let e=this.insertEmbeddableElement({sceneX:r,sceneY:i,link:on(t)});e&&this.setState({selectedElementIds:{[e.id]:!0}})}}}),i(this,`loadFileToCanvas`,async(e,t)=>{e=await pr(e);try{let n=this.scene.getElementsIncludingDeleted(),r;try{r=await bt(e,this.state,n,t)}catch(e){let t=e instanceof wn;if(t&&e.code===`IMAGE_NOT_CONTAINS_SCENE_DATA`&&!this.isToolSupported(`image`)){this.setState({isLoading:!1,errorMessage:J(`errors.imageToolNotSupported`)});return}let n=J(t?`alerts.cannotRestoreFromImage`:`alerts.couldNotLoadInvalidFile`);this.setState({isLoading:!1,errorMessage:n})}if(!r)return;r.type===de.excalidraw?(da(n.concat(r.data.elements)),this.store.updateSnapshot(k(n),this.state),this.setState({isLoading:!0}),this.syncActionResult({...r.data,appState:{...r.data.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:j.IMMEDIATELY})):r.type===de.excalidrawlib&&await this.library.updateLibrary({libraryItems:e,merge:!0,openLibraryMenu:!0}).catch(e=>{console.error(e),this.setState({errorMessage:J(`errors.importLibraryError`)})})}catch(e){this.setState({isLoading:!1,errorMessage:e.message})}}),i(this,`handleCanvasContextMenu`,e=>{if(e.preventDefault(),(`pointerType`in e.nativeEvent&&e.nativeEvent.pointerType===`touch`||`pointerType`in e.nativeEvent&&e.nativeEvent.pointerType===`pen`&&e.button!==Ll.SECONDARY)&&this.state.activeTool.type!==`selection`)return;let{x:t,y:n}=Ls(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:l}=this.excalidrawContainerRef.current.getBoundingClientRect(),u=e.clientX-l,d=e.clientY-s;X(`contextMenu`,`openContextMenu`,o),this.setState({...r&&!this.state.selectedElementIds[r.id]?{...this.state,...Fi({editingGroupId:this.state.editingGroupId,selectedElementIds:{[r.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:c(r)?new G(r):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:d,left:u,items:this.getContextMenuItems(o)}})})}),i(this,`maybeDragNewGenericElement`,(e,t,n=!0)=>{let r=this.state.selectionElement,i=e.lastCoords;if(r&&this.state.activeTool.type!==`eraser`){tn({newElement:r,elementType:this.state.activeTool.type,originX:e.origin.x,originY:e.origin.y,x:i.x,y:i.y,width:ce(e.origin.x,i.x),height:ce(e.origin.y,i.y),shouldMaintainAspectRatio:l(t),shouldResizeFromCenter:Gn(t),zoom:this.state.zoom.value,informMutation:n});return}let a=this.state.newElement;if(!a)return;let[o,s]=ht(i.x,i.y,t[E.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),c=pe(a)&&this.imageCache.get(a.fileId)?.image,u=c&&!(c instanceof Promise)?c.width/c.height:null;this.maybeCacheReferenceSnapPoints(t,[a]);let{snapOffset:d,snapLines:p}=f(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+=d.x,s+=d.y,this.setState({snapLines:p}),tn({newElement:a,elementType:this.state.activeTool.type,originX:e.originInGrid.x,originY:e.originInGrid.y,x:o,y:s,width:ce(e.originInGrid.x,o),height:ce(e.originInGrid.y,s),shouldMaintainAspectRatio:El(a)?!l(t):l(t),shouldResizeFromCenter:Gn(t),zoom:this.state.zoom.value,widthAspectRatio:u,originOffset:this.state.originSnapOffset,informMutation:n}),this.setState({newElement:a}),(this.state.activeTool.type===Pc.frame||this.state.activeTool.type===Pc.magicframe)&&this.setState({elementsToHighlight:so(this.scene.getNonDeletedElements(),a,this.state,this.scene.getNonDeletedElementsMap())})}),i(this,`maybeHandleCrop`,(e,t)=>{if(!this.state.croppingElementId)return!1;let n=e.resize.handleType,r=e.lastCoords,[i,a]=ht(r.x-e.resize.offset.x,r.y-e.resize.offset.y,t[E.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),o=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(n&&o&&El(o)){let s=e.originalElements.get(o.id),c=pe(o)&&this.imageCache.get(o.fileId)?.image;if(s&&El(s)&&c&&!(c instanceof Promise)){let[l,u]=ht(r.x,r.y,t[E.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}=Co([o],[s],this,t,d,n);V(o,Zs(o,n,c.naturalWidth,c.naturalHeight,i+f.x,a+f.y,t.shiftKey?s.width/s.height:void 0)),ga(o,this.scene.getNonDeletedElementsMap(),{newSize:{width:o.width,height:o.height}}),this.setState({isCropping:n&&n!==`rotation`,snapLines:p})}return!0}return!1}),i(this,`maybeHandleResize`,(e,t)=>{let n=this.scene.getSelectedElements(this.state),r=n.filter(e=>A(e)),i=e.resize.handleType;if(r.length>0&&i===`rotation`||n.length===1&&U(n[0])||this.state.croppingElementId)return!1;this.setState({isResizing:i&&i!==`rotation`,isRotating:i===`rotation`,activeEmbeddable:null});let a=e.lastCoords,[o,s]=ht(a.x-e.resize.offset.x,a.y-e.resize.offset.y,t[E.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),c=new Map;if(r.forEach(e=>{xl(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]=ht(a.x,a.y,t[E.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}=Co(n,W(u,this.state),this,t,l,i);o+=d.x,s+=d.y,this.setState({snapLines:f})}if(os(e.originalElements,i,n,this.scene.getElementsMapIncludingDeleted(),this.scene,Es(t),Gn(t),n.some(e=>El(e))?!l(t):l(t),o,s,e.resize.center.x,e.resize.center.y)){let e=ql(n,this.scene.getNonDeletedElementsMap(),this.state.zoom),t=new Set;return r.forEach(e=>{so(this.scene.getNonDeletedElements(),e,this.state,this.scene.getNonDeletedElementsMap()).forEach(e=>t.add(e))}),this.setState({elementsToHighlight:[...t],suggestedBindings:e}),!0}return!1}),i(this,`getContextMenuItems`,e=>{let t=[];return t.push(Hx,Vx),e===`canvas`?this.state.viewModeEnabled?[...t,Wx,Gx,eO,qx]:[zx,Tw,Hx,Vx,Ux,Tw,hy,_S,Tw,Wx,Kx,Gx,eO,qx]:(t.push(Ux),this.state.viewModeEnabled?[Rx,...t]:[Tw,Bx,Rx,zx,Tw,nO,rO,iO,Tw,dw,Tw,...t,Tw,px,mx,Tw,vx,uk,Jx,Yx,Qx,yx,Tw,Ex,Tw,dy,fy,py,my,Tw,Px,Fx,Tw,lw,Tw,mS,ew,Tw,yy,gS,Tw,Xv])}),i(this,`handleWheel`,fO(e=>{if(!(e.target instanceof HTMLCanvasElement||e.target instanceof HTMLTextAreaElement||e.target instanceof HTMLIFrameElement)){e[E.CTRL_OR_CMD]&&e.preventDefault();return}if(e.preventDefault(),Ik)return;let{deltaX:t,deltaY:n}=e;if(e.metaKey||e.ctrlKey){let e=Math.sign(n),t=Ti*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),this.translateCanvas(e=>({...Ib({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:He(a)},e),shouldCacheIgnoreZoom:!0})),this.resetShouldCacheIgnoreZoomDebounced();return}if(e.shiftKey){this.translateCanvas(({zoom:e,scrollX:r})=>({scrollX:r-(n||t)/e.value}));return}this.translateCanvas(({zoom:e,scrollX:r,scrollY:i})=>({scrollX:r-t/e.value,scrollY:i-n/e.value}))})),i(this,`savePointer`,(e,t,n)=>{if(!e||!t)return;let{x:r,y:i}=Ls({clientX:e,clientY:t},this.state),a={x:r,y:i,tool:this.state.activeTool.type===`laser`?`laser`:`pointer`};this.props.onPointerUpdate?.({pointer:a,button:n,pointersMap:$.pointers})}),i(this,`resetShouldCacheIgnoreZoomDebounced`,Ec(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300)),i(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()})}}),i(this,`refresh`,()=>{this.setState({...this.getCanvasOffsets()})});let r=Le(),{excalidrawAPI:a,viewModeEnabled:o=!1,zenModeEnabled:s=!1,gridModeEnabled:u=!1,objectsSnapModeEnabled:d=!1,theme:m=r.theme,name:g=`${J(`labels.untitled`)}-${pn()}`}=t;if(this.state={...r,theme:m,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:o,zenModeEnabled:s,objectsSnapModeEnabled:d,gridModeEnabled:u??r.gridModeEnabled,name:g,width:window.innerWidth,height:window.innerHeight},this.id=Bc(),this.library=new jS(this),this.actionManager=new bw(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new Ol,this.canvas=document.createElement(`canvas`),this.rc=_.canvas(this.canvas),this.renderer=new ZO(this.scene),this.visibleElements=[],this.store=new va,this.history=new pw,a){let e={updateScene:this.updateScene,updateLibrary:this.library.updateLibrary,addFiles:this.addFiles,resetScene:this.resetScene,getSceneElementsIncludingDeleted:this.getSceneElementsIncludingDeleted,history:{clear:this.resetHistory},scrollToContent:this.scrollToContent,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.setCursor,resetCursor:this.resetCursor,updateFrameRendering:this.updateFrameRendering,toggleSidebar:this.toggleSidebar,onChange:e=>this.onChangeEmitter.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)};typeof a==`function`?a(e):console.error(`excalidrawAPI should be a function!`)}this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new Eo(this.scene),this.history=new pw,this.actionManager.registerAll(bi),this.actionManager.registerAction(_w(this.history,this.store)),this.actionManager.registerAction(vw(this.history,this.store))}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(Ba).includes(n)&&Vk.set(e,n)}break}}cacheEmbeddableRef(e,t){t&&this.iFrameRefs.set(e.id,t)}getHTMLIFrameElement(e){return this.iFrameRefs.get(e.id)}handleEmbeddableCenterClick(e){if(this.state.activeEmbeddable?.element===e&&this.state.activeEmbeddable?.state===`active`||(setTimeout(()=>{this.setState({activeEmbeddable:{element:e,state:`active`},selectedElementIds:{[e.id]:!0},newElement:null,selectionElement:null})},100),oi(e)))return;let t=this.getHTMLIFrameElement(e);if(t?.contentWindow){if(t.src.includes(`youtube`)){let n=Vk.get(e.id);switch(n||(Vk.set(e.id,Ba.UNSTARTED),t.contentWindow.postMessage(JSON.stringify({event:`listening`,id:e.id}),`*`)),n){case Ba.PLAYING:case Ba.BUFFERING:t.contentWindow?.postMessage(JSON.stringify({event:`command`,func:`pauseVideo`,args:``}),`*`);break;default:t.contentWindow?.postMessage(JSON.stringify({event:`command`,func:`playVideo`,args:``}),`*`)}}t.src.includes(`player.vimeo.com`)&&t.contentWindow.postMessage(JSON.stringify({method:`paused`}),`*`)}}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;return(0,q.jsx)(q.Fragment,{children:this.scene.getNonDeletedElements().filter(e=>St(e)&&this.embedsValidationStatus.get(e.id)===!0||oi(e)).map(r=>{let{x:i,y:a}=Wo({sceneX:r.x,sceneY:r.y},this.state),o=jo(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(oi(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:()=>Jr(`
56
+ <style>
57
+ html, body {
58
+ width: 100%;
59
+ height: 100%;
60
+ color: ${this.state.theme===B.DARK?`white`:`black`};
61
+ }
62
+ body {
63
+ display: flex;
64
+ align-items: center;
65
+ justify-content: center;
66
+ flex-direction: column;
67
+ gap: 1rem;
68
+ }
69
+
70
+ .Spinner {
71
+ display: flex;
72
+ align-items: center;
73
+ justify-content: center;
74
+ margin-left: auto;
75
+ margin-right: auto;
76
+ }
77
+
78
+ .Spinner svg {
79
+ animation: rotate 1.6s linear infinite;
80
+ transform-origin: center center;
81
+ width: 40px;
82
+ height: 40px;
83
+ }
84
+
85
+ .Spinner circle {
86
+ stroke: currentColor;
87
+ animation: dash 1.6s linear 0s infinite;
88
+ stroke-linecap: round;
89
+ }
90
+
91
+ @keyframes rotate {
92
+ 100% {
93
+ transform: rotate(360deg);
94
+ }
95
+ }
96
+
97
+ @keyframes dash {
98
+ 0% {
99
+ stroke-dasharray: 1, 300;
100
+ stroke-dashoffset: 0;
101
+ }
102
+ 50% {
103
+ stroke-dasharray: 150, 300;
104
+ stroke-dashoffset: -200;
105
+ }
106
+ 100% {
107
+ stroke-dasharray: 1, 300;
108
+ stroke-dashoffset: -280;
109
+ }
110
+ }
111
+ </style>
112
+ <div class="Spinner">
113
+ <svg
114
+ viewBox="0 0 100 100"
115
+ >
116
+ <circle
117
+ cx="50"
118
+ cy="50"
119
+ r="46"
120
+ stroke-width="8"
121
+ fill="none"
122
+ stroke-miter-limit="10"
123
+ />
124
+ </svg>
125
+ </div>
126
+ <div>Generating...</div>
127
+ `)};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:()=>Jr(`
128
+ <style>
129
+ html, body {
130
+ height: 100%;
131
+ }
132
+ body {
133
+ display: flex;
134
+ flex-direction: column;
135
+ align-items: center;
136
+ justify-content: center;
137
+ color: ${kr.red[3]};
138
+ }
139
+ h1, h3 {
140
+ margin-top: 0;
141
+ margin-bottom: 0.5rem;
142
+ }
143
+ </style>
144
+ <h1>Error!</h1>
145
+ <h3>${t}</h3>
146
+ `)}}}else c=Je(Pa(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`;return(0,q.jsx)(`div`,{className:L(`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:$l(r,Li(r,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name===`elementLinkSelector`?Ut:1),"--embeddable-radius":`${Kr(Math.min(r.width,r.height),r)}px`},children:(0,q.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?ps.enabled:ps.disabled},children:[u&&(0,q.jsx)(`div`,{className:`excalidraw__embeddable-hint`,children:J(`buttons.embeddableInteractionButton`)}),(0,q.jsx)(`div`,{className:`excalidraw__embeddable__outer`,style:{padding:`${r.strokeWidth}px`},children:(St(r)?this.props.renderEmbeddable?.(r,this.state):null)??(0,q.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,renderCustomStats:n}=this.props,r=this.scene.getSceneNonce(),{elementsMap:i,visibleElements:a}=this.renderer.getRenderableElements({sceneNonce:r,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,newElementId:this.state.newElement?.id,pendingImageElementId:this.state.pendingImageElementId});this.visibleElements=a;let o=this.scene.getNonDeletedElementsMap(),s=`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`,c=e[0];return(0,q.jsx)(`div`,{className:L(`excalidraw excalidraw-container`,{"excalidraw--view-mode":this.state.viewModeEnabled||this.state.openDialog?.name===`elementLinkSelector`,"excalidraw--mobile":this.device.editor.isMobile}),style:{"--ui-pointerEvents":s?ps.disabled:ps.enabled,"--right-sidebar-width":`302px`},ref:this.excalidrawContainerRef,onDrop:this.handleAppOnDrop,tabIndex:0,onKeyDown:this.props.handleKeyboardGlobally?void 0:this.onKeyDown,onPointerEnter:this.toggleOverscrollBehavior,onPointerLeave:this.toggleOverscrollBehavior,children:(0,q.jsx)(gk.Provider,{value:this,children:(0,q.jsx)(_k.Provider,{value:this.props,children:(0,q.jsx)(bk.Provider,{value:this.excalidrawContainerValue,children:(0,q.jsx)(yk.Provider,{value:this.device,children:(0,q.jsx)(Ck.Provider,{value:this.setAppState,children:(0,q.jsx)(Sk.Provider,{value:this.state,children:(0,q.jsxs)(xk.Provider,{value:this.scene.getNonDeletedElements(),children:[(0,q.jsxs)(wk.Provider,{value:this.actionManager,children:[(0,q.jsx)(ZD,{canvas:this.canvas,appState:this.state,files:this.files,setAppState:this.setAppState,actionManager:this.actionManager,elements:this.scene.getNonDeletedElements(),onLockToggle:this.toggleLock,onPenModeToggle:this.togglePenMode,onHandToolToggle:this.onHandToolToggle,langCode:Vv().code,renderTopRightUI:t,renderCustomStats:n,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===`selection`&&!this.state.zenModeEnabled&&!this.scene.getElementsIncludingDeleted().length,app:this,isCollaborating:this.props.isCollaborating,generateLinkForSelection:this.props.generateLinkForSelection,children:this.props.children}),(0,q.jsx)(`div`,{className:`excalidraw-textEditorContainer`}),(0,q.jsx)(`div`,{className:`excalidraw-contextMenuContainer`}),(0,q.jsx)(`div`,{className:`excalidraw-eye-dropper-container`}),(0,q.jsx)(QO,{trails:[this.laserTrails,this.eraserTrail]}),e.length===1&&this.state.openDialog?.name!==`elementLinkSelector`&&this.state.showHyperlinkPopup&&(0,q.jsx)(oS,{element:c,elementsMap:o,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},c.id),this.props.aiEnabled!==!1&&e.length===1&&Zn(c)&&(0,q.jsx)(tk,{element:c,elementsMap:i,children:(0,q.jsx)(rk,{title:J(`labels.convertToCode`),icon:Za,checked:!1,onChange:()=>this.onMagicFrameGenerate(c,`button`)})}),e.length===1&&oi(c)&&c.customData?.generationData?.status===`done`&&(0,q.jsxs)(tk,{element:c,elementsMap:i,children:[(0,q.jsx)(rk,{title:J(`labels.copySource`),icon:Fc,checked:!1,onChange:()=>this.onIframeSrcCopy(c)}),(0,q.jsx)(rk,{title:`Enter fullscreen`,icon:Nc,checked:!1,onChange:()=>{let e=this.getHTMLIFrameElement(c);if(e)try{e.requestFullscreen(),this.setState({activeEmbeddable:{element:c,state:`active`},selectedElementIds:{[c.id]:!0},newElement:null,selectionElement:null})}catch(e){console.warn(e),this.setState({errorMessage:`Couldn't enter fullscreen`})}}})]}),this.state.toast!==null&&(0,q.jsx)($D,{message:this.state.toast.message,onClose:()=>this.setToast(null),duration:this.state.toast.duration,closable:this.state.toast.closable}),this.state.contextMenu&&(0,q.jsx)(Ew,{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,q.jsx)(XO,{canvas:this.canvas,rc:this.rc,elementsMap:i,allElementsMap:o,visibleElements:a,sceneNonce:r,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:ra(this),canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:this.flowChartCreator.pendingNodes}}),this.state.newElement&&(0,q.jsx)(hk,{appState:this.state,scale:window.devicePixelRatio,rc:this.rc,elementsMap:i,allElementsMap:o,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:!1,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:null}}),(0,q.jsx)(qO,{containerRef:this.excalidrawContainerRef,canvas:this.interactiveCanvas,elementsMap:i,visibleElements:a,allElementsMap:o,selectedElements:e,sceneNonce:r,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,device:this.device,renderInteractiveSceneCallback:this.renderInteractiveSceneCallback,handleCanvasRef:this.handleInteractiveCanvasRef,onContextMenu:this.handleCanvasContextMenu,onPointerMove:this.handleCanvasPointerMove,onPointerUp:this.handleCanvasPointerUp,onPointerCancel:this.removePointer,onTouchMove:this.handleTouchMove,onPointerDown:this.handleCanvasPointerDown,onDoubleClick:this.handleCanvasDoubleClick}),this.state.userToFollow&&(0,q.jsx)(ik,{width:this.state.width,height:this.state.height,userToFollow:this.state.userToFollow,onDisconnect:this.maybeUnfollowRemoteUser}),this.renderFrameNames()]}),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=yo(this.scene.getNonDeletedElements(),e).filter(e=>!Zn(e));if(!r.length){t===`button`?(this.setState({errorMessage:`Cannot generate from an empty frame`}),X(`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}}),X(`ai`,`generate (start)`,`d2c`);try{let{html:t}=await n({frame:e,children:r});if(X(`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){X(`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`&&(Jo(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=>{pe(e)&&t[e.fileId]&&(this.imageCache.delete(e.fileId),Ue.delete(e))})}async componentDidMount(){this.unmounted=!1,this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,(r.MODE===mc.TEST||r.DEV)&&(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.onStoreIncrementEmitter.on(e=>{this.history.record(e.elementsChange,e.appStateChange)}),this.scene.onUpdate(this.triggerRender),this.addEventListeners(),this.props.autoFocus&&this.excalidrawContainerRef.current&&this.focusContainer(),qo()||(this.refreshViewportBreakpoints(),this.refreshEditorBreakpoints()),_a&&this.excalidrawContainerRef.current&&(this.resizeObserver=new ResizeObserver(()=>{this.refreshEditorBreakpoints(),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),Ko()&&!Yl()&&this.setState({errorMessage:(0,q.jsx)(aO,{})})}componentWillUnmount(){window.launchQueue?.setConsumer(()=>{}),this.renderer.destroy(),this.scene.destroy(),this.scene=new Ol,this.fonts=new Eo(this.scene),this.renderer=new ZO(this.scene),this.files={},this.imageCache.clear(),this.resizeObserver?.disconnect(),this.unmounted=!0,this.removeEventListeners(),this.library.destroy(),this.laserTrails.stop(),this.eraserTrail.stop(),this.onChangeEmitter.clear(),this.store.onStoreIncrementEmitter.clear(),Ue.destroy(),he.destroy(),clearTimeout(zk),xc.clearCache(),Fi.clearCache(),zk=0,document.documentElement.style.overscrollBehaviorX=``}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){this.removeEventListeners(),this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(Vs(document,`keydown`,this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(Vs(this.excalidrawContainerRef.current,`wheel`,this.handleWheel,{passive:!1}),Vs(window,`message`,this.onWindowMessage,!1),Vs(document,`pointerup`,this.removePointer,{passive:!1}),Vs(document,`copy`,this.onCopy,{passive:!1}),Vs(document,`keyup`,this.onKeyUp,{passive:!0}),Vs(document,`pointermove`,this.updateCurrentCursorPosition,{passive:!1}),Vs(document.fonts,`loadingdone`,e=>{let t=e.fontfaces;this.fonts.onLoaded(t)},{passive:!1}),Vs(document,`gesturestart`,this.onGestureStart,!1),Vs(document,`gesturechange`,this.onGestureChange,!1),Vs(document,`gestureend`,this.onGestureEnd,!1),Vs(window,`focus`,()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(Vs(document,`fullscreenchange`,this.onFullscreenChange,{passive:!1}),Vs(document,`paste`,this.pasteFromClipboard,{passive:!1}),Vs(document,`cut`,this.onCut,{passive:!1}),Vs(window,`resize`,this.onResize,!1),Vs(window,`unload`,this.onUnload,!1),Vs(window,`blur`,this.onBlur,!1),Vs(this.excalidrawContainerRef.current,`wheel`,this.handleWheel,{passive:!1}),Vs(this.excalidrawContainerRef.current,`dragover`,this.disableEvent,!1),Vs(this.excalidrawContainerRef.current,`drop`,this.disableEvent,!1)),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(Vs(Dl(this.excalidrawContainerRef.current),`scroll`,this.onScroll,{passive:!1})))}componentDidUpdate(e,t){this.updateEmbeddables();let n=this.scene.getElementsIncludingDeleted(),r=this.scene.getElementsMapIncludingDeleted(),i=this.scene.getNonDeletedElementsMap();!this.state.showWelcomeScreen&&!n.length&&this.setState({showWelcomeScreen:!0}),e.UIOptions.dockedSidebarBreakpoint!==this.props.UIOptions.dockedSidebarBreakpoint&&this.refreshEditorBreakpoints(),t.userToFollow&&!this.state.collaborators.has(t.userToFollow.socketId)&&this.maybeUnfollowRemoteUser(),(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)),t.userToFollow!==this.state.userToFollow&&(t.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:t.userToFollow,action:`UNFOLLOW`}),this.state.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:this.state.userToFollow,action:`FOLLOW`})),Object.keys(this.state.selectedElementIds).length&&hn(this.state)&&this.setState({activeTool:Sa(this.state,{type:`selection`})}),this.state.activeTool.type===`eraser`&&t.theme!==this.state.theme&&fa(this.interactiveCanvas,this.state.theme),t.activeTool.type===`selection`&&this.state.activeTool.type!==`selection`&&this.state.showHyperlinkPopup&&this.setState({showHyperlinkPopup:!1}),e.langCode!==this.props.langCode&&this.updateLanguage(),hn(t)&&!hn(this.state)&&this.eraserTrail.endPath(),e.viewModeEnabled!==this.props.viewModeEnabled&&this.setState({viewModeEnabled:!!this.props.viewModeEnabled}),t.viewModeEnabled!==this.state.viewModeEnabled&&(this.addEventListeners(),this.deselectElements()),(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===B.DARK),this.state.editingLinearElement&&!this.state.selectedElementIds[this.state.editingLinearElement.elementId]&&setTimeout(()=>{this.state.editingLinearElement&&this.actionManager.executeAction(Xb)}),this.state.editingTextElement?.isDeleted&&this.setState({editingTextElement:null}),this.state.selectedLinearElement&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&this.setState({selectedLinearElement:null});let{multiElement:a}=t;t.activeTool!==this.state.activeTool&&a!=null&&Ir(this.state)&&le(a,!1)&&Sl(a,this.state,yi(G.getPointAtIndexGlobalCoordinates(a,-1,i)),this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements()),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(){Nk=!1}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 vs(e)}}catch(e){let t=e.message;return e.cause===`FETCH_ERROR`?t=J(`errors.failedToFetchImage`):e.cause===`UNSUPPORTED`&&(t=J(`errors.unsupportedFileType`)),{errorMessage:t}}})),a=r,o=!1,s={};for(let e of i)if(e.file){let t=this.createImageElement({sceneX:n,sceneY:a}),r=await this.insertImageElement(t,e.file);r&&(o||(o=!0,a-=r.height/2),V(r,{y:a},!1),a=t.y+t.height+25,s[t.id]=!0)}this.setState({selectedElementIds:F(s,this.state)});let c=i.find(e=>!!e.errorMessage);c&&c.errorMessage&&this.setState({errorMessage:c.errorMessage})}else{let n=e.filter(e=>e.type===`text`);n.length&&this.addTextFromPaste(n.map(e=>e.value).join(`
147
+
148
+ `),t)}}addTextFromPaste(e,t=!1){let{x:n,y:r}=Ls({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),i={x:n,y:r,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,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:Qr,verticalAlign:`top`,locked:!1},a=Ds({fontSize:i.fontSize,fontFamily:i.fontFamily}),o=vc(i.fontFamily),[s,,c]=Cc(this.state),l=Math.max(Math.min((c-s)*.5,800),200),u=r,d=t?[e]:e.split(`
149
+ `),f=d.reduce((e,t,r)=>{let s=gr(t).trim();if(s.length){let t=this.getTopLayerFrameAtSceneCoords({x:n,y:u}),r=yn(s,a,o),c=r.width>l,d=c?fc(s,a,l):s;r=c?yn(d,a,o):r;let f=n-r.width/2,p=u-r.height/2,m=ds({...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+=Cn(i.fontSize,o)+10);return e},[]);f.length!==0&&(this.scene.insertElements(f),this.setState({selectedElementIds:F(Object.fromEntries(f.map(e=>[e.id,!0])),this.state)}),!t&&f.length>1&&Wk===!1&&!this.device.editor.isMobile&&(this.setToast({message:J(`toast.pasteAsSingleElement`,{shortcut:M(`CtrlOrCmd+Shift+V`)}),duration:5e3}),Wk=!0),this.store.shouldCaptureIncrement())}handleTextWysiwyg(e,{isExistingElement:t=!1}){let n=this.scene.getElementsMapIncludingDeleted(),r=(t,r)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(i=>i.id===e.id&&I(i)?z(i,{originalText:t,isDeleted:r??i.isDeleted,...et(i,ia(i,n),n,t)}):i)])};lk({id:e.id,canvas:this.canvas,getViewportCoords:(e,t)=>{let{x:n,y:r}=Wo({sceneX:e,sceneY:t},this.state);return[n-this.state.offsetLeft,r-this.state.offsetTop]},onChange:fO(t=>{r(t,!1),gc(e)&&ga(e,this.scene.getNonDeletedElementsMap())}),onSubmit:fO(({viaKeyboard:n,nextOriginalText:i})=>{let a=!i.trim();if(r(i,a),!a&&n){let t=e.containerId?e.containerId:e.id;(0,Ju.flushSync)(()=>{this.setState(e=>({selectedElementIds:F({...e.selectedElementIds,[t]:!0},e)}))})}a&&Mr(this.scene.getNonDeletedElements(),[e]),(!a||t)&&this.store.shouldCaptureIncrement(),(0,Ju.flushSync)(()=>{this.setState({newElement:null,editingTextElement:null})}),this.state.activeTool.locked&&Lc(this.interactiveCanvas,this.state),this.focusContainer()}),element:e,excalidrawContainer:this.excalidrawContainerRef.current,app:this,autoSelect:!this.device.isTouchScreen}),this.deselectElements(),r(e.originalText,!1)}deselectElements(){this.setState({selectedElementIds:F({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getTextElementAtPosition(e,t){let n=this.getElementAtPosition(e,t,{includeBoundTextElement:!0});return n&&I(n)&&!n.isDeleted?n:null}getElementAtPosition(e,t,n){let r=this.getElementsAtPosition(e,t,n?.includeBoundTextElement,n?.includeLockedElements);if(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 Lr({x:e,y:t,element:i,shape:Ye(i,this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold()/2,frameNameBound:A(i)?this.frameNameBoundsCache.get(i):null})?i:r[r.length-2]}return r.length===1?r[0]:null}getElementsAtPosition(e,t,n=!1,r=!1){let i=[],a=this.scene.getNonDeletedElementsMap();return(n&&r?this.scene.getNonDeletedElements():this.scene.getNonDeletedElements().filter(e=>(r||!e.locked)&&(n||!(I(e)&&e.containerId)))).filter(n=>this.hitElement(e,t,n)).filter(n=>{let r=Li(n,a);return r&&this.state.frameRendering.enabled&&this.state.frameRendering.clip?pa({x:e,y:t},r,a):!0}).filter(e=>oi(e)?(i.push(e),!1):!0).concat(i)}getElementHitThreshold(){return Pl/this.state.zoom.value}hitElement(e,t,n,r=!0){if(r&&this.state.selectedElementIds[n.id]&&Is([n],this.state)){let r=Bi(n,this.scene.getNonDeletedElementsMap(),El(n)?0:this.getElementHitThreshold());if(u(P(e,t),r))return!0}return is(e,t,Dt(n,this.scene.getNonDeletedElementsMap()))?!0:Lr({x:e,y:t,element:n,shape:Ye(n,this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold(),frameNameBound:A(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 ba(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]=Kl(n[r],this.scene.getNonDeletedElementsMap());if(st(n[r])&&Lr({x:e,y:t,element:n[r],shape:Ye(n[r],this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold()})){i=n[r];break}else if(a<e&&e<s&&o<t&&t<c){i=n[r];break}}return ba(i,!1)?i:null}handleHoverSelectedLinearElement(e,t,n){let r=this.scene.getNonDeletedElementsMap(),i=G.getElement(e.elementId,r);if(i)if(this.state.selectedLinearElement){let a=-1,o=null;Lr({x:t,y:n,element:i,shape:Ye(i,this.scene.getNonDeletedElementsMap())})?(a=G.getPointIndexUnderCursor(i,r,this.state.zoom,t,n),o=G.getSegmentMidpointHitCoords(e,{x:t,y:n},this.state,this.scene.getNonDeletedElementsMap()),(U(i)?a===0||a===i.points.length-1:a>=0)||o?H(this.interactiveCanvas,N.POINTER):this.hitElement(t,n,i)&&H(this.interactiveCanvas,N.MOVE)):this.hitElement(t,n,i)&&(!U(i)||!(i.startBinding||i.endBinding))&&H(this.interactiveCanvas,N.MOVE),this.state.selectedLinearElement.hoverPointIndex!==a&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:a}}),G.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,o)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:o}})}else H(this.interactiveCanvas,N.AUTO)}updateGestureOnPointerDown(e){$.pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),$.pointers.size===2&&($.lastCenter=xw($.pointers),$.initialScale=this.state.zoom.value,$.initialDistance=Sw(Array.from($.pointers.values())))}initialPointerDownState(e){let t=Ls(e,this.state),n=this.scene.getSelectedElements(this.state),[r,i,a,o]=Ao(n),s=n.findIndex(U)===0;return{origin:t,withCmdOrCtrl:e[E.CTRL_OR_CMD],originInGrid:yi(ht(t.x,t.y,e[E.CTRL_OR_CMD]||s?null:this.getEffectiveGridSize())),scrollbars:cT(Rk,e.clientX-this.state.offsetLeft,e.clientY-this.state.offsetTop),lastCoords:{...t},originalElements:this.scene.getNonDeletedElements().reduce((e,t)=>(e.set(t.id,_r(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},eventListeners:{onMove:null,onUp:null,onKeyUp:null,onKeyDown:null},boxSelection:{hasOccurred:!1}}}handleDraggingScrollBar(e,t){if(!(t.scrollbars.isOverEither&&!this.state.multiElement))return!1;Lk=!0,t.lastCoords.x=e.clientX,t.lastCoords.y=e.clientY;let n=pO(e=>{e.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(e,t)}),r=fO(()=>{Gk=null,Lk=!1,Lc(this.interactiveCanvas,this.state),this.setState({cursorButton:`up`}),this.savePointer(e.clientX,e.clientY,`up`),window.removeEventListener(`pointermove`,n),window.removeEventListener(`pointerup`,r),n.flush()});return Gk=r,window.addEventListener(`pointermove`,n),window.addEventListener(`pointerup`,r),!0}isASelectedElement(e){return e!=null&&this.state.selectedElementIds[e.id]}isHittingCommonBoundingBoxOfSelectedElements(e,t){if(t.length<2)return!1;let n=this.getElementHitThreshold(),[r,i,a,o]=Ao(t);return e.x>r-n&&e.x<a+n&&e.y>i-n&&e.y<o+n}getCurrentItemRoundness(e){return this.state.currentItemRoundness===`round`?{type:T(e)?Zr.ADAPTIVE_RADIUS:Zr.PROPORTIONAL_RADIUS}:null}maybeCacheReferenceSnapPoints(e,t,n=!1){ze({event:e,app:this,selectedElements:t})&&(n||!he.getReferenceSnapPoints())&&he.setReferenceSnapPoints(ac(this.scene.getNonDeletedElements(),t,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(e,t,n=!1){ze({event:e,app:this,selectedElements:t})&&(n||!he.getVisibleGaps())&&he.setVisibleGaps(Ka(this.scene.getNonDeletedElements(),t,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(e){return fO(t=>{this.maybeHandleResize(e,t)||this.maybeDragNewGenericElement(e,t)})}onKeyUpFromPointerDownHandler(e){return fO(t=>{t.key===E.ALT&&t.preventDefault(),!this.maybeHandleResize(e,t)&&this.maybeDragNewGenericElement(e,t)})}onPointerMoveFromPointerDownHandler(e){return pO(t=>{if(this.state.openDialog?.name===`elementLinkSelector`)return;let n=Ls(t,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.elbowed&&this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index){let[e,r]=ht(n.x,n.y,t[E.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),i=this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index;if(i<0){let t=G.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:e,y:r},this.state,this.scene.getNonDeletedElementsMap());i=t?G.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,t,this.scene.getNonDeletedElementsMap()):-1}let a=G.moveFixedSegment(this.state.selectedLinearElement,i,e,r,this.scene.getNonDeletedElementsMap());(0,Ju.flushSync)(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:a.segmentMidPointHoveredCoords,pointerDownState:a.pointerDownState}})});return}let r=this.lastPointerMoveCoords??e.origin;if(this.lastPointerMoveCoords=n,e.drag.offset===null&&(e.drag.offset=yi(we(this.scene.getSelectedElements(this.state),e.origin.x,e.origin.y))),!(t.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(t,e))return;if(hn(this.state)){this.handleEraser(t,e,n);return}this.state.activeTool.type===`laser`&&this.laserTrails.addPointToPath(n.x,n.y);let[i,a]=ht(n.x,n.y,t[E.CTRL_OR_CMD]?null:this.getEffectiveGridSize());if(!e.drag.hasOccurred&&(this.state.activeTool.type===`arrow`||this.state.activeTool.type===`line`)&&eu(P(n.x,n.y),P(e.origin.x,e.origin.y))<10)return;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.editingLinearElement||this.state.selectedLinearElement;if(G.shouldAddMidpoint(this.state.selectedLinearElement,n,this.state,o)){let e=G.addMidpoint(this.state.selectedLinearElement,n,this,!t[E.CTRL_OR_CMD],o);if(!e)return;(0,Ju.flushSync)(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:e.pointerDownState,selectedPointsIndices:e.selectedPointsIndices}}),this.state.editingLinearElement&&this.setState({editingLinearElement:{...this.state.editingLinearElement,pointerDownState:e.pointerDownState,selectedPointsIndices:e.selectedPointsIndices}})});return}else if(r.pointerDownState.segmentMidpoint.value!==null&&!r.pointerDownState.segmentMidpoint.added)return;if(G.handlePointDragging(t,this,n.x,n.y,(e,t)=>{this.maybeSuggestBindingsForLinearElementAtCoords(e,t)},r,this.scene)){e.lastCoords.x=n.x,e.lastCoords.y=n.y,e.drag.hasOccurred=!0,this.state.editingLinearElement&&!this.state.editingLinearElement.isDragging&&this.setState({editingLinearElement:{...this.state.editingLinearElement,isDragging:!0}}),this.state.selectedLinearElement.isDragging||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!0}});return}}let s=e.hit.allHitElements.some(e=>this.isASelectedElement(e)),l=this.state.editingLinearElement&&t.shiftKey&&this.state.editingLinearElement.elementId===e.hit.element?.id;if((s||e.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!l){let i=this.scene.getSelectedElements(this.state);if(i.every(e=>e.locked))return;let a=i.find(e=>A(e)),s=this.getTopLayerFrameAtSceneCoords(n),c=s&&!a?s:null;if(this.state.frameToHighlight!==c&&(0,Ju.flushSync)(()=>{this.setState({frameToHighlight:c})}),e.drag.hasOccurred=!0,i.length>0&&!e.withCmdOrCtrl&&!this.state.editingTextElement&&this.state.activeEmbeddable?.state!==`active`){let a={x:n.x-e.origin.x,y:n.y-e.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&&El(t)&&t.crop!==null&&e.hit.element===t){let e=t.crop,i=pe(t)&&this.imageCache.get(t.fileId)?.image;if(i&&!(i instanceof Promise)){let a=qt(Sn(n.x-r.x,n.y-r.y),Math.max(this.state.zoom.value,2)),[s,c,l,u,d,f]=Kl(t,o),p=Hl(Zc(P(s,c),P(d,f),t.angle)),m=Hl(Zc(P(l,c),P(d,f),t.angle)),h=Hl(Zc(P(s,u),P(d,f),t.angle)),g=ho(Jt(m,p)),_=ho(Jt(h,p)),v=Sn(ya(a,g),ya(a,_));V(t,{crop:{...e,x:_e(e.x-v[0]*Math.sign(t.scale[0]),0,i.naturalWidth-e.width),y:_e(e.y-v[1]*Math.sign(t.scale[1]),0,i.naturalHeight-e.height)}});return}}}this.maybeCacheVisibleGaps(t,i),this.maybeCacheReferenceSnapPoints(t,i);let{snapOffset:l,snapLines:u}=Si(s,a,this,t,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:u}),this.state.editingFrame||ms(e,i,a,this.scene,l,t[E.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),this.setState({selectedElementsAreBeingDragged:!0,selectionElement:null}),(i.length!==1||!U(i[0]))&&this.setState({suggestedBindings:ql(i,this.scene.getNonDeletedElementsMap(),this.state.zoom)}),t.altKey&&!e.hit.hasBeenDuplicated){e.hit.hasBeenDuplicated=!0;let n=[],r=[],a=new Map,o=new Map,s=e.hit.element,c=new Set(this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}).map(e=>e.id)),l=this.scene.getElementsIncludingDeleted();for(let t of l){let i=c.has(t.id)||t.id===s?.id&&e.hit.wasAddedToSelection;if(Math.abs(t.x)>1e7||Math.abs(t.x)>1e7||Math.abs(t.width)>1e7||Math.abs(t.height)>1e7){console.error(`Alt+dragging element in scene with invalid dimensions`,t.x,t.y,t.width,t.height,i);return}if(i){let i=mi(this.state.editingGroupId,a,t);if(Math.abs(i.x)>1e7||Math.abs(i.x)>1e7||Math.abs(i.width)>1e7||Math.abs(i.height)>1e7){console.error(`Alt+dragging duplicated element with invalid dimensions`,i.x,i.y,i.width,i.height);return}let s=e.originalElements.get(t.id);if(Math.abs(s.x)>1e7||Math.abs(s.x)>1e7||Math.abs(s.width)>1e7||Math.abs(s.height)>1e7){console.error(`Alt+dragging duplicated element with invalid dimensions`,s.x,s.y,s.width,s.height);return}V(i,{x:s.x,y:s.y}),e.originalElements.set(i.id,i),n.push(i),r.push(t),o.set(t.id,i.id)}else n.push(t)}let u=[...n,...r];u=this.props.onDuplicate?.(u,l)||u,Un(u,k(r)),w(n,r,o),Ys(u,r,o,`duplicatesServeAsOld`),Hr(u,r,o),this.scene.replaceAllElements(u),this.maybeCacheVisibleGaps(t,i,!0),this.maybeCacheReferenceSnapPoints(t,i,!0)}return}}if(this.state.selectionElement)e.lastCoords.x=n.x,e.lastCoords.y=n.y,this.maybeDragNewGenericElement(e,t);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];V(r,{points:[...e,P(i,a)],pressures:n},!1),this.setState({newElement:r})}}else if(c(r)){e.drag.hasOccurred=!0;let o=r.points,s=i-r.x,c=a-r.y;Es(t)&&o.length===2&&({width:s,height:c}=fr(r.x,r.y,n.x,n.y)),o.length===1?V(r,{points:[...o,P(s,c)]},!1):(o.length===2||o.length>1&&U(r))&&V(r,{points:[...o.slice(0,-1),P(s,c)]},!1,{isDragging:!0}),this.setState({newElement:r}),le(r,!1)&&this.maybeSuggestBindingsForLinearElementAtCoords(r,[n],this.state.startBoundElement)}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.editingLinearElement)G.handleBoxSelection(t,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let r=!0;!t.shiftKey&&xc(n,this.state)&&(e.withCmdOrCtrl&&e.hit.element?this.setState(t=>Fi({...t,selectedElementIds:{[e.hit.element.id]:!0}},this.scene.getNonDeletedElements(),t,this)):r=!1);let i=this.state.selectionElement?Oi(n,this.state.selectionElement,this.scene.getNonDeletedElementsMap(),!1):[];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},{...Fi({editingGroupId:t.editingGroupId,selectedElementIds:n},this.scene.getNonDeletedElements(),t,this),selectedLinearElement:i.length===1&&c(i[0])?new G(i[0]):null,showHyperlinkPopup:i.length===1&&(i[0].link||St(i[0]))?`info`:!1}})}}})}handlePointerMoveOverScrollbars(e,t){if(t.scrollbars.isOverHorizontal){let n=e.clientX,r=n-t.lastCoords.x;return this.translateCanvas({scrollX:this.state.scrollX-r/this.state.zoom.value}),t.lastCoords.x=n,!0}if(t.scrollbars.isOverVertical){let n=e.clientY,r=n-t.lastCoords.y;return this.translateCanvas({scrollY:this.state.scrollY-r/this.state.zoom.value}),t.lastCoords.y=n,!0}return!1}onPointerUpFromPointerDownHandler(e){return fO(t=>{this.removePointer(t),e.eventListeners.onMove&&e.eventListeners.onMove.flush();let{newElement:n,resizingElement:r,croppingElementId:i,multiElement:a,activeTool:o,isResizing:s,isRotating:l,isCropping:u}=this.state;this.setState(e=>({isResizing:!1,isRotating:!1,isCropping:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:`up`,snapLines:Xa(e.snapLines,[]),originSnapOffset:null})),this.lastPointerMoveCoords=null,he.setReferenceSnapPoints(null),he.setVisibleGaps(null),this.savePointer(t.clientX,t.clientY,`up`),this.setState({selectedElementsAreBeingDragged:!1});let d=this.scene.getNonDeletedElementsMap();if(e.drag.hasOccurred&&e.hit?.element?.id){let t=d.get(e.hit.element.id);Pe(t)&&t.boundElements?.filter(e=>e.type===`arrow`).map(e=>d.get(e.id)).filter(e=>U(e)).forEach(e=>{e&&V(e,{},!0)})}if(this.state.editingLinearElement)if(!e.boxSelection.hasOccurred&&e.hit?.element?.id!==this.state.editingLinearElement.elementId)this.actionManager.executeAction(Xb);else{let e=G.handlePointerUp(t,this.state.editingLinearElement,this.state,this.scene);e!==this.state.editingLinearElement&&this.setState({editingLinearElement:e,suggestedBindings:[]})}else if(this.state.selectedLinearElement){if(this.state.selectedLinearElement.elbowed){let e=G.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());e&&V(e,{},!0)}if(e.hit?.element?.id!==this.state.selectedLinearElement.elementId)this.scene.getSelectedElements(this.state).length>1&&this.setState({selectedLinearElement:null});else{let e=G.handlePointerUp(t,this.state.selectedLinearElement,this.state,this.scene),{startBindingElement:n,endBindingElement:r}=e,i=this.scene.getElement(e.elementId);le(i)&&Bo(i,n,r,d,this.scene),e!==this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...e,selectedPointsIndices:null},suggestedBindings:[]})}}if(this.missingPointerEventCleanupEmitter.clear(),window.removeEventListener(`pointermove`,e.eventListeners.onMove),window.removeEventListener(`pointerup`,e.eventListeners.onUp),window.removeEventListener(`keydown`,e.eventListeners.onKeyDown),window.removeEventListener(`keyup`,e.eventListeners.onKeyUp),this.state.pendingImageElementId&&this.setState({pendingImageElementId:null}),this.props?.onPointerUp?.(o,e),this.onPointerUpEmitter.trigger(this.state.activeTool,e,t),n?.type===`freedraw`){let e=Ls(t,this.state),r=n.points,i=e.x-n.x,a=e.y-n.y;i===r[0][0]&&a===r[0][1]&&(a+=1e-4,i+=1e-4);let o=n.simulatePressure?[]:[...n.pressures,t.pressure];V(n,{points:[...r,P(i,a)],pressures:o,lastCommittedPoint:P(i,a)}),this.actionManager.executeAction(Xb);return}if(El(n)){let e=n;try{this.initializeImageDimensions(e),this.setState({selectedElementIds:F({[e.id]:!0},this.state)},()=>{this.actionManager.executeAction(Xb)})}catch(t){console.error(t),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().filter(t=>t.id!==e.id)),this.actionManager.executeAction(Xb)}return}if(c(n)){n.points.length>1&&this.store.shouldCaptureIncrement();let r=Ls(t,this.state);!e.drag.hasOccurred&&n&&!a?(V(n,{points:[...n.points,P(r.x-n.x,r.y-n.y)]}),this.setState({multiElement:n,newElement:n})):e.drag.hasOccurred&&!a&&(Ir(this.state)&&le(n,!1)&&Sl(n,this.state,r,this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements()),this.setState({suggestedBindings:[],startBoundElement:null}),o.locked?this.setState(e=>({newElement:null})):(ut(this.interactiveCanvas),this.setState(e=>({newElement:null,activeTool:Sa(this.state,{type:`selection`}),selectedElementIds:F({...e.selectedElementIds,[n.id]:!0},e),selectedLinearElement:new G(n)}))),this.scene.triggerUpdate());return}if(I(n)){let e=En(Ds({fontSize:n.fontSize,fontFamily:n.fontFamily}),n.lineHeight);n.width<e&&V(n,{autoResize:!0}),this.resetCursor(),this.handleTextWysiwyg(n,{isExistingElement:!0})}if(o.type!==`selection`&&n&&Ps(n)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(e=>e.id!==n.id),appState:{newElement:null},captureUpdate:j.NEVER});return}if(A(n)){let e=rc(this.scene.getElementsIncludingDeleted(),n,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(ls(this.scene.getElementsMapIncludingDeleted(),e,n,this.state))}if(n&&(V(n,go(n)),this.scene.triggerUpdate()),e.drag.hasOccurred){let e=Ls(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=Li(e,d);t&&e&&(ee(e,t,this.scene.getNonDeletedElementsMap())||(V(e,{groupIds:[]}),$a([e],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let t=this.getTopLayerFrameAtSceneCoords(e),n=this.scene.getSelectedElements(this.state),r=this.scene.getElementsMapIncludingDeleted(),i=e=>{if(e.length>0){for(let t of e){let e=t.groupIds.indexOf(this.state.editingGroupId);V(t,{groupIds:t.groupIds.slice(0,e)},!1)}r.forEach(e=>{e.groupIds.length&&Wc(r,e.groupIds[e.groupIds.length-1]).length<2&&V(e,{groupIds:[]},!1)}),this.setState({editingGroupId:null})}};if(t&&!this.state.selectedElementIds[t.id]){let e=n.filter(e=>e.frameId!==t.id&&ln(e,r,this.state));this.state.editingGroupId&&i(e),r=ls(r,e,t,this.state)}else !t&&this.state.editingGroupId&&i(n.filter(e=>e.frameId&&!ln(e,r,this.state)));r=Xo(r,this.state,this),this.scene.replaceAllElements(r)}}if(r&&this.store.shouldCaptureIncrement(),r&&Ps(r)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(e=>e.id!==r.id),captureUpdate:j.NEVER}),e.resize.isResizing){let e=Xo(this.scene.getElementsIncludingDeleted(),this.state,this),t=this.scene.getSelectedElements(this.state).filter(e=>A(e));for(let n of t)e=xe(e,so(this.scene.getElementsIncludingDeleted(),n,this.state,d),n,this);this.scene.replaceAllElements(e)}let f=e.hit.element;this.state.selectedLinearElement?.elementId!==f?.id&&c(f)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new G(f)}),(!i||i&&(!f&&!u||f&&f.id!==i))&&this.finishImageCropping();let p=this.lastPointerDownEvent,m=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(hn(this.state)&&p&&m){if(this.eraserTrail.endPath(),eu(P(p.clientX,p.clientY),P(m.clientX,m.clientY))===0){let e=Ls({clientX:m.clientX,clientY:m.clientY},this.state);this.getElementsAtPosition(e.x,e.y).forEach(e=>this.elementsPendingErasure.add(e.id))}this.eraseElements();return}else this.elementsPendingErasure.size&&this.restoreReadyToEraseElements();if(f&&!e.drag.hasOccurred&&!e.hit.wasAddedToSelection&&(!this.state.editingLinearElement||!e.boxSelection.hasOccurred)&&(t.shiftKey&&!this.state.editingLinearElement?this.state.selectedElementIds[f.id]?Cr(this.state,f)?this.setState(e=>{let t={...e.selectedElementIds};for(let e of f.groupIds.flatMap(e=>Wc(this.scene.getNonDeletedElements(),e)))delete t[e.id];return{selectedGroupIds:{...e.selectedElementIds,...f.groupIds.map(e=>({[e]:!1})).reduce((e,t)=>({...e,...t}),{})},selectedElementIds:F(t,e)}}):this.state.selectedLinearElement?.isDragging||this.setState(e=>{let t={...e.selectedElementIds};delete t[f.id];let n=W(this.scene.getNonDeletedElements(),{selectedElementIds:t});return{...Fi({editingGroupId:e.editingGroupId,selectedElementIds:t},this.scene.getNonDeletedElements(),e,this),selectedLinearElement:n.length===1&&c(n[0])?new G(n[0]):e.selectedLinearElement}}):f.frameId&&this.state.selectedElementIds[f.frameId]?this.setState(e=>{let t={...e.selectedElementIds,[f.id]:!0};return delete t[f.frameId],(this.scene.getElement(f.frameId)?.groupIds??[]).flatMap(e=>Wc(this.scene.getNonDeletedElements(),e)).forEach(e=>{delete t[e.id]}),{...Fi({editingGroupId:e.editingGroupId,selectedElementIds:t},this.scene.getNonDeletedElements(),e,this),showHyperlinkPopup:f.link||St(f)?`info`:!1}}):this.setState(e=>({selectedElementIds:F({...e.selectedElementIds,[f.id]:!0},e)})):this.setState(e=>({...Fi({editingGroupId:e.editingGroupId,selectedElementIds:{[f.id]:!0}},this.scene.getNonDeletedElements(),e,this),selectedLinearElement:c(f)&&e.selectedLinearElement?.elementId!==f.id?new G(f):e.selectedLinearElement}))),!(f&&U(f))&&!e.drag.hasOccurred&&!this.state.isResizing&&(f&&Jc({x:e.origin.x,y:e.origin.y,element:f,shape:Ye(f,this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold(),frameNameBound:A(f)?this.frameNameBoundsCache.get(f):null},d)||!f&&e.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.editingLinearElement?this.setState({editingLinearElement:null}):this.setState({selectedElementIds:F({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),H(this.interactiveCanvas,N.AUTO);return}if(!o.locked&&o.type!==`freedraw`&&n&&this.setState(e=>({selectedElementIds:F({...e.selectedElementIds,[n.id]:!0},e),showHyperlinkPopup:St(n)&&!n.link?`editor`:e.showHyperlinkPopup})),(o.type!==`selection`||xc(this.scene.getNonDeletedElements(),this.state)||!Xt(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.shouldCaptureIncrement(),(e.drag.hasOccurred||s||l||u)&&jn(this.scene.getSelectedElements(this.state).filter(c),this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements(),this.scene,Ir(this.state),this.state.selectedLinearElement?.selectedPointsIndices??[],this.state.zoom),o.type===`laser`){this.laserTrails.endPath();return}!o.locked&&o.type!==`freedraw`?(ut(this.interactiveCanvas),this.setState({newElement:null,suggestedBindings:[],activeTool:Sa(this.state,{type:`selection`})})):this.setState({newElement:null,suggestedBindings:[]}),f&&this.lastPointerUpEvent&&this.lastPointerDownEvent&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<300&&$.pointers.size<=1&&fl(f)&&this.isIframeLikeElementCenter(f,this.lastPointerUpEvent,e.origin.x,e.origin.y)&&this.handleEmbeddableCenterClick(f)})}clearSelection(e){this.setState(t=>({selectedElementIds:F({},t),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:t.editingGroupId&&e!=null&&_t(e,t.editingGroupId)?t.editingGroupId:null})),this.setState({selectedElementIds:F({},this.state),activeEmbeddable:null,previousSelectedElementIds:this.state.selectedElementIds})}getTextWysiwygSnappedToCenterPosition(e,t,n,r){if(r){let i=r.x+r.width/2,a=r.y+r.height/2,o=Vl(r,n,this.scene.getNonDeletedElementsMap());if(o&&(i=o.x,a=o.y),Math.hypot(e-i,t-a)<30){let{x:e,y:t}=Wo({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 Bv(Iv.find(e=>e.code===this.props.langCode)||Fv),this.setAppState({})}};(r.MODE===mc.TEST||r.DEV)&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(da(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}));var qk=Kk,Jk=()=>{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}),Element.prototype.replaceChildren||(Element.prototype.replaceChildren=function(...e){this.innerHTML=``,this.append(...e)})},Yk=({children:e})=>{let{FooterCenterTunnel:t}=RC(),n=Uy();return(0,q.jsx)(t.In,{children:(0,q.jsx)(`div`,{className:L(`footer-center zen-mode-transition`,{"layer-ui__wrapper__footer-left--transition-bottom":n.zenModeEnabled}),children:e})})};Yk.displayName=`FooterCenter`;var Xk=()=>(0,q.jsx)(`svg`,{viewBox:`0 0 40 40`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,className:`ExcalidrawLogo-icon`,children:(0,q.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`})}),Zk=()=>(0,q.jsxs)(`svg`,{viewBox:`0 0 450 55`,xmlns:`http://www.w3.org/2000/svg`,fill:`none`,className:`ExcalidrawLogo-text`,children:[(0,q.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,q.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,q.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,q.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)`})]}),Qk=({style:e,size:t=`small`,withText:n})=>(0,q.jsxs)(`div`,{className:`ExcalidrawLogo is-${t}`,style:e,children:[(0,q.jsx)(Xk,{}),n&&(0,q.jsx)(Zk,{})]}),$k=({icon:e,shortcut:t,children:n})=>{let r=Dk();return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`welcome-screen-menu-item__icon`,children:e}),(0,q.jsx)(`div`,{className:`welcome-screen-menu-item__text`,children:n}),t&&!r.editor.isMobile&&(0,q.jsx)(`div`,{className:`welcome-screen-menu-item__shortcut`,children:t})]})};$k.displayName=`WelcomeScreenMenuItemContent`;var eA=({onSelect:e,children:t,icon:n,shortcut:r,className:i=``,...a})=>(0,q.jsx)(`button`,{...a,type:`button`,className:`welcome-screen-menu-item ${i}`,onClick:e,children:(0,q.jsx)($k,{icon:n,shortcut:r,children:t})});eA.displayName=`WelcomeScreenMenuItem`;var tA=({children:e,href:t,icon:n,shortcut:r,className:i=``,...a})=>(0,q.jsx)(`a`,{...a,className:`welcome-screen-menu-item ${i}`,href:t,target:`_blank`,rel:`noreferrer`,children:(0,q.jsx)($k,{icon:n,shortcut:r,children:e})});tA.displayName=`WelcomeScreenMenuItemLink`;var nA=({children:e})=>{let{WelcomeScreenCenterTunnel:t}=RC();return(0,q.jsx)(t.In,{children:(0,q.jsx)(`div`,{className:`welcome-screen-center`,children:e||(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(rA,{}),(0,q.jsx)(iA,{children:J(`welcomeScreen.defaults.center_heading`)}),(0,q.jsxs)(aA,{children:[(0,q.jsx)(sA,{}),(0,q.jsx)(oA,{})]})]})})})};nA.displayName=`Center`;var rA=({children:e})=>(0,q.jsx)(`div`,{className:`welcome-screen-center__logo excalifont welcome-screen-decor`,children:e||(0,q.jsx)(Qk,{withText:!0})});rA.displayName=`Logo`;var iA=({children:e})=>(0,q.jsx)(`div`,{className:`welcome-screen-center__heading welcome-screen-decor excalifont`,children:e});iA.displayName=`Heading`;var aA=({children:e})=>(0,q.jsx)(`div`,{className:`welcome-screen-menu`,children:e});aA.displayName=`Menu`;var oA=()=>{let e=Mk();return(0,q.jsx)(eA,{onSelect:()=>e.executeAction(hx),shortcut:`?`,icon:ti,children:J(`helpDialog.title`)})};oA.displayName=`MenuItemHelp`;var sA=()=>{let e=Uy(),t=Mk();return e.viewModeEnabled?null:(0,q.jsx)(eA,{onSelect:()=>t.executeAction(ux),shortcut:MC(`loadScene`),icon:gl,children:J(`buttons.load`)})};sA.displayName=`MenuItemLoadScene`;var cA=({onSelect:e})=>{let{t}=Wv();return(0,q.jsx)(eA,{shortcut:null,onSelect:e,icon:Tl,children:t(`labels.liveCollaboration`)})};cA.displayName=`MenuItemLiveCollaborationTrigger`,nA.Logo=rA,nA.Heading=iA,nA.Menu=aA,nA.MenuItem=eA,nA.MenuItemLink=tA,nA.MenuItemHelp=oA,nA.MenuItemLoadScene=sA,nA.MenuItemLiveCollaborationTrigger=cA;var lA=({children:e})=>{let{WelcomeScreenMenuHintTunnel:t}=RC();return(0,q.jsx)(t.In,{children:(0,q.jsxs)(`div`,{className:`excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu`,children:[pl,(0,q.jsx)(`div`,{className:`welcome-screen-decor-hint__label`,children:e||J(`welcomeScreen.defaults.menuHint`)})]})})};lA.displayName=`MenuHint`;var uA=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:t}=RC();return(0,q.jsx)(t.In,{children:(0,q.jsxs)(`div`,{className:`excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar`,children:[(0,q.jsx)(`div`,{className:`welcome-screen-decor-hint__label`,children:e||J(`welcomeScreen.defaults.toolbarHint`)}),Vn]})})};uA.displayName=`ToolbarHint`;var dA=({children:e})=>{let{WelcomeScreenHelpHintTunnel:t}=RC();return(0,q.jsx)(t.In,{children:(0,q.jsxs)(`div`,{className:`excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help`,children:[(0,q.jsx)(`div`,{children:e||J(`welcomeScreen.defaults.helpHint`)}),Ul]})})};dA.displayName=`HelpHint`;var fA=e=>(0,q.jsx)(q.Fragment,{children:e.children||(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(nA,{}),(0,q.jsx)(lA,{}),(0,q.jsx)(uA,{}),(0,q.jsx)(dA,{})]})});fA.displayName=`WelcomeScreen`,fA.Center=nA,fA.Hints={MenuHint:lA,ToolbarHint:uA,HelpHint:dA};var pA=({isCollaborating:e,onSelect:t,...n})=>{let r=Uy(),i=r.width<830;return(0,q.jsxs)(kC,{...n,className:L(`collab-button`,{active:e}),type:`button`,onSelect:t,style:{position:`relative`,width:i?void 0:`auto`},title:J(`labels.liveCollaboration`),children:[i?Kn:J(`labels.share`),r.collaborators.size>0&&(0,q.jsx)(`div`,{className:`CollabButton-collaborators`,children:r.collaborators.size})]})};pA.displayName=`LiveCollaborationTrigger`,(0,Ig.default)((e,t,n)=>{(r.DEV||r.MODE===mc.TEST||window?.DEBUG_FRACTIONAL_INDICES)&&Qo(da(e.map(e=>({...e}))),{shouldThrow:r.DEV||r.MODE===mc.TEST,includeBoundTextValidation:!0,reconciliationContext:{localElements:t,remoteElements:n}})},1e3*60,{leading:!0,trailing:!1});var mA=({children:e,icon:t})=>{let{TTDDialogTriggerTunnel:n}=RC(),r=jk();return(0,q.jsx)(n.In,{children:(0,q.jsxs)(Z.Item,{onSelect:()=>{X(`ai`,`dialog open`,`ttd`),r({openDialog:{name:`ttd`,tab:`text-to-diagram`}})},icon:t??Ct,children:[e??J(`labels.textToDiagram`),(0,q.jsx)(Z.Item.Badge,{children:`AI`})]})})};mA.displayName=`TTDDialogTrigger`,Jk();var hA=K.memo(e=>{let{onChange:t,initialData:r,excalidrawAPI:i,isCollaborating:a=!1,onPointerUpdate:o,renderTopRightUI:s,langCode:c=Fv.code,viewModeEnabled:l,zenModeEnabled:u,gridModeEnabled:d,libraryReturnUrl:f,theme:p,name:m,renderCustomStats:h,onPaste:g,detectScroll:_=!0,handleKeyboardGlobally:v=!1,onLibraryChange:y,autoFocus:b=!1,generateIdForFile:x,onLinkOpen:S,generateLinkForSelection:C,onPointerDown:w,onPointerUp:T,onScrollChange:ee,onDuplicate:te,children:ne,validateEmbeddable:re,renderEmbeddable:ie,aiEnabled:ae,showDeprecatedFonts:oe}=e,se=e.UIOptions?.canvasActions,ce={...e.UIOptions,canvasActions:{...Yn.canvasActions,...se},tools:{image:e.UIOptions?.tools?.image??!0}};return se?.export&&(ce.canvasActions.export.saveFileToDisk=se.export?.saveFileToDisk??Yn.canvasActions.export.saveFileToDisk),ce.canvasActions.toggleTheme===null&&typeof p>`u`&&(ce.canvasActions.toggleTheme=!0),(0,K.useEffect)(()=>{(async()=>{await n(()=>import(`./roundRect-BDOnP7qU.js`),[],import.meta.url)})();let e=e=>{typeof e.scale==`number`&&e.scale!==1&&e.preventDefault()};return document.addEventListener(`touchmove`,e,{passive:!1}),()=>{document.removeEventListener(`touchmove`,e)}},[]),(0,q.jsx)(jv,{store:Mv,children:(0,q.jsx)(qv,{langCode:c,theme:p,children:(0,q.jsx)(qk,{onChange:t,initialData:r,excalidrawAPI:i,isCollaborating:a,onPointerUpdate:o,renderTopRightUI:s,langCode:c,viewModeEnabled:l,zenModeEnabled:u,gridModeEnabled:d,libraryReturnUrl:f,theme:p,name:m,renderCustomStats:h,UIOptions:ce,onPaste:g,detectScroll:_,handleKeyboardGlobally:v,onLibraryChange:y,autoFocus:b,generateIdForFile:x,onLinkOpen:S,generateLinkForSelection:C,onPointerDown:w,onPointerUp:T,onScrollChange:ee,onDuplicate:te,validateEmbeddable:re,renderEmbeddable:ie,aiEnabled:ae!==!1,showDeprecatedFonts:oe,children:ne})})})},(e,t)=>{if(e.children!==t.children)return!1;let{initialData:n,UIOptions:r={},...i}=e,{initialData:a,UIOptions:o={},...s}=t,c=Object.keys(r),l=Object.keys(o);return c.length===l.length?c.every(e=>e===`canvasActions`?Object.keys(r.canvasActions).every(e=>e===`export`&&r?.canvasActions?.export&&o?.canvasActions?.export?r.canvasActions.export.saveFileToDisk===o.canvasActions.export.saveFileToDisk:r?.canvasActions?.[e]===o?.canvasActions?.[e]):r[e]===o[e])&&Xt(i,s):!1});hA.displayName=`Excalidraw`;export{$s as exportToSvg,ni as restore};