koboyo 0.2.0 → 0.4.0

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 (208) hide show
  1. package/README.md +6 -1
  2. package/assets/editor/assets/DialogDescription-Ddhk2rmF.js +1 -0
  3. package/assets/editor/assets/DialogRoot-DUeVfNhS.js +1 -0
  4. package/assets/editor/assets/DialogTitle-D5au2NAn.js +1 -0
  5. package/assets/editor/assets/FloatingPortalLite-HnWQWrLk.js +1 -0
  6. package/assets/editor/assets/{IconAlertTriangle-CxPhYpe-.js → IconAlertTriangle-B33xznYN.js} +1 -1
  7. package/assets/editor/assets/{IconArrowLeft-DFk3Krim.js → IconArrowLeft-B4Zcy-Fc.js} +1 -1
  8. package/assets/editor/assets/IconChevronLeft-D7e7QC0h.js +1 -0
  9. package/assets/editor/assets/IconChevronRight-csfMBSUs.js +1 -0
  10. package/assets/editor/assets/{IconCode-hd05zxU4.js → IconCode-CHIz1nCU.js} +1 -1
  11. package/assets/editor/assets/IconCornerDownRight-DDiBMO4O.js +1 -0
  12. package/assets/editor/assets/{IconEraser-DlZQe3-r.js → IconEraser-CYfXj27R.js} +1 -1
  13. package/assets/editor/assets/{IconFocusCentered-C5PcDeR0.js → IconFocusCentered-Cn8rbfRI.js} +1 -1
  14. package/assets/editor/assets/IconHelp-CaEwHrsN.js +2 -0
  15. package/assets/editor/assets/IconLink-VS5p9Ytk.js +1 -0
  16. package/assets/editor/assets/IconLoader2-CzCTn-Sn.js +1 -0
  17. package/assets/editor/assets/IconMinus-BcaDLts8.js +1 -0
  18. package/assets/editor/assets/{IconMoodSmile-Bic_fw54.js → IconMoodSmile-CSZ5p_Hy.js} +1 -1
  19. package/assets/editor/assets/{IconPencil-C5Y-Y4dC.js → IconPencil-D_pQsAyv.js} +1 -1
  20. package/assets/editor/assets/{IconPhoto-CR36IK-b.js → IconPhoto-5zuCDtnR.js} +1 -1
  21. package/assets/editor/assets/{IconPlayerPlayFilled-D4OODBX7.js → IconPlayerPlayFilled-DVAWmYt7.js} +1 -1
  22. package/assets/editor/assets/{IconPlayerStopFilled-BUbX6ZO5.js → IconPlayerStopFilled-D4qdct2R.js} +1 -1
  23. package/assets/editor/assets/IconPlus-D4tAoi-A.js +1 -0
  24. package/assets/editor/assets/{IconPresentation-DCrY3PKL.js → IconPresentation-BMKzt7fv.js} +1 -1
  25. package/assets/editor/assets/{IconSearch-C1K0_Pq_.js → IconSearch-CCpMt02s.js} +1 -1
  26. package/assets/editor/assets/{IconSparkles-WDcg8BA9.js → IconSparkles-CnCp3BCQ.js} +1 -1
  27. package/assets/editor/assets/{IconTrash-DbN_RxB7.js → IconTrash-C8w6ThWx.js} +1 -1
  28. package/assets/editor/assets/{IconUsers-Bwnyj4mm.js → IconUsers-Dp85N225.js} +1 -1
  29. package/assets/editor/assets/IconX-KrRqxr2j.js +1 -0
  30. package/assets/editor/assets/MenuSubmenuTrigger-KacA9GM8.js +1 -0
  31. package/assets/editor/assets/PopoverPopup-B3Y0VRYc.js +1 -0
  32. package/assets/editor/assets/{asset-glyph-B3c--Mx2.js → asset-glyph-C1E6cGwM.js} +1 -1
  33. package/assets/editor/assets/billing-BSXr-z2r.js +1 -0
  34. package/assets/editor/assets/build-pips-BV-uwXlP.js +1 -0
  35. package/assets/editor/assets/build-visibility-DyML9SHt.js +1 -0
  36. package/assets/editor/assets/builders-DMHAOPEv.js +1 -0
  37. package/assets/editor/assets/{chart-Z4HQx-0h.js → chart-4iRduYdU.js} +4 -4
  38. package/assets/editor/assets/{chrome-layout-B8YmHznO.js → chrome-layout-BzPU9far.js} +1 -1
  39. package/assets/editor/assets/{code-panel-BfsykjSz.js → code-panel-koBUgEWp.js} +7 -7
  40. package/assets/editor/assets/command-palette-BR-_ChOL.js +1 -0
  41. package/assets/editor/assets/config-D8b1QyEk.js +1 -0
  42. package/assets/editor/assets/connector-labels-CrEgadsC.js +2 -0
  43. package/assets/editor/assets/copy-image-dialog-BzGP7Xw8.js +1 -0
  44. package/assets/editor/assets/{core-CBnmD9hT.js → core-CmsJyU_-.js} +1 -1
  45. package/assets/editor/assets/createReactComponent-C51FAx3B.js +1 -0
  46. package/assets/editor/assets/{diagram-fingerprint-CsqZK4xZ.js → diagram-fingerprint-WGQ5iVXx.js} +1 -1
  47. package/assets/editor/assets/dialog-DnXgEbpz.js +1 -0
  48. package/assets/editor/assets/{edit-BJ_kibk8.js → edit-C0sBxxsg.js} +1 -1
  49. package/assets/editor/assets/editor-BeufBV54.js +1 -0
  50. package/assets/editor/assets/{elk-api-DnfklSaw.js → elk-api-C4wlHVIw.js} +1 -1
  51. package/assets/editor/assets/{elk-worker-loader-CC-I9MmI.js → elk-worker-loader-CVBdN1je.js} +1 -1
  52. package/assets/editor/assets/{export-ChP0k5F5.js → export-Bce6ra0N.js} +1 -1
  53. package/assets/editor/assets/export-K2VWg76n.js +6 -0
  54. package/assets/editor/assets/export-dialog-x2n2a4KX.js +1 -0
  55. package/assets/editor/assets/flow-layer-ewaL7g2y.js +1 -0
  56. package/assets/editor/assets/flow-panel-BzXNGGke.js +1 -0
  57. package/assets/editor/assets/flow-stage-Ba_CAggI.js +1 -0
  58. package/assets/editor/assets/flow-start-CpAvU-9P.js +1 -0
  59. package/assets/editor/assets/{flows-GGbkNqs8.js → flows-Cj7AFMIA.js} +2 -2
  60. package/assets/editor/assets/frames-Cp1QD3LR.js +1 -0
  61. package/assets/editor/assets/icon-picker-Cg39IKNJ.js +1 -0
  62. package/assets/editor/assets/image-library-JQu_tb8P.js +1 -0
  63. package/assets/editor/assets/index-CBPPqsiR.js +24 -0
  64. package/assets/editor/assets/{index-CC2h28V_.css → index-DBrN0u0i.css} +1 -1
  65. package/assets/editor/assets/jsx-runtime-DKdBMi_L.js +1 -0
  66. package/assets/editor/assets/layout-offthread-mRHRulkS.js +18 -0
  67. package/assets/editor/assets/{layout.worker-BIE1_z0S.js → layout.worker-CekYkaxO.js} +2 -2
  68. package/assets/editor/assets/menu-B9BAk63v.js +1 -0
  69. package/assets/editor/assets/panel-controls-DWVXiNUZ.js +1 -0
  70. package/assets/editor/assets/{panel-shell-CG2aq4Ia.js → panel-shell-BnMOHgWM.js} +1 -1
  71. package/assets/editor/assets/{plan-jQm1jDpt.js → plan-CkgM52Yh.js} +1 -1
  72. package/assets/editor/assets/presentation-DJUO0t7I.js +1 -0
  73. package/assets/editor/assets/presenter-keys-Bs3LnmOa.js +1 -0
  74. package/assets/editor/assets/{jsx-runtime-2Zwg-L3c.js → react-lCSYwAWP.js} +1 -1
  75. package/assets/editor/assets/reflow-DaYiVkwp.js +1 -0
  76. package/assets/editor/assets/registry-rEGZW7Ab.js +1 -0
  77. package/assets/editor/assets/renderer-environment-D3n3hbug.js +1 -0
  78. package/assets/editor/assets/ride-overlay-Hx90v4ZK.js +1 -0
  79. package/assets/editor/assets/selection-overlay-primitives-BRp854AD.js +1 -0
  80. package/assets/editor/assets/shape-meta-COE2ATNh.js +1 -0
  81. package/assets/editor/assets/sign-in-dialog-tmQEB2bx.js +1 -0
  82. package/assets/editor/assets/slide-notes-dialog-BQBXpep6.js +1 -0
  83. package/assets/editor/assets/slides-D686obFO.js +15 -0
  84. package/assets/editor/assets/slides-panel-BEJCevJi.js +26 -0
  85. package/assets/editor/assets/text-breaks-DM4W6y5f.js +7 -0
  86. package/assets/editor/assets/{theme-palette-D1nbDFBC.js → theme-palette-Dl_G_VIJ.js} +1 -1
  87. package/assets/editor/assets/tidy-browser-dF3BON7J.js +1 -0
  88. package/assets/editor/assets/tidy-scope-BGG3ZXvZ.js +1 -0
  89. package/assets/editor/assets/toast-Czv_DJ-4.js +1 -0
  90. package/assets/editor/assets/tool-catalog-DXPhX2S1.js +1 -0
  91. package/assets/editor/assets/tool-drawer-CWOX_njp.js +1 -0
  92. package/assets/editor/assets/tooltip-CyBz17g8.js +1 -0
  93. package/assets/editor/assets/tree-KSgPjntC.js +1 -0
  94. package/assets/editor/assets/upgrade-dialog-DhSZnDpx.js +1 -0
  95. package/assets/editor/assets/use-drag-reorder-ye8-kpyR.js +1 -0
  96. package/assets/editor/assets/use-export-command-sC9UHj3_.js +2 -0
  97. package/assets/editor/assets/use-grid-keyboard-nav-DhQKecO1.js +0 -0
  98. package/assets/editor/assets/use-icon-node-BxqH7H27.js +1 -0
  99. package/assets/editor/assets/use-key-held-094C3Mn3.js +1 -0
  100. package/assets/editor/assets/use-recent-list-DuazDypH.js +1 -0
  101. package/assets/editor/assets/useAnchoredPopupScrollLock-i8D5Dm1d.js +1 -0
  102. package/assets/editor/assets/useBaseUiId-D2RfU0uY.js +1 -0
  103. package/assets/editor/assets/useButton-CLQYGhRJ.js +1 -0
  104. package/assets/editor/assets/useControlled-BE8zdmih.js +1 -0
  105. package/assets/editor/assets/usePositioner-AtbrPc7w.js +1 -0
  106. package/assets/editor/assets/useScrollLock-CQpr0n6U.js +1 -0
  107. package/assets/editor/assets/useValueChanged-SqLfIDi5.js +1 -0
  108. package/assets/editor/assets/web-controls-CLE9zr7i.js +1 -0
  109. package/assets/editor/assets/web-embed-dialog-XUNelFFM.js +1 -0
  110. package/assets/editor/assets/web-html-dialog-BcAyzH5D.js +1 -0
  111. package/assets/editor/assets/web-shape-C941TGTy.js +1 -0
  112. package/assets/editor/assets/widget-source-CHujvUeA.js +1 -0
  113. package/assets/editor/index.html +73 -69
  114. package/dist/koboyo.js +258 -214
  115. package/package.json +5 -5
  116. package/skills/koboyo/SKILL.md +22 -2
  117. package/skills/koboyo/references/architecture.md +1 -1
  118. package/skills/koboyo/references/bpmn.md +1 -1
  119. package/skills/koboyo/references/chart.md +1 -1
  120. package/skills/koboyo/references/cycle.md +1 -1
  121. package/skills/koboyo/references/erd.md +1 -1
  122. package/skills/koboyo/references/flowchart.md +1 -1
  123. package/skills/koboyo/references/funnel.md +1 -1
  124. package/skills/koboyo/references/gantt.md +1 -1
  125. package/skills/koboyo/references/gitgraph.md +1 -1
  126. package/skills/koboyo/references/journey.md +1 -1
  127. package/skills/koboyo/references/matrix.md +1 -1
  128. package/skills/koboyo/references/mindmap.md +1 -1
  129. package/skills/koboyo/references/orgchart.md +1 -1
  130. package/skills/koboyo/references/pyramid.md +1 -1
  131. package/skills/koboyo/references/sankey.md +1 -1
  132. package/skills/koboyo/references/sequence.md +1 -1
  133. package/skills/koboyo/references/statemachine.md +1 -1
  134. package/skills/koboyo/references/timeline.md +1 -1
  135. package/skills/koboyo/references/venn.md +1 -1
  136. package/skills/koboyo/references/wireframe.md +1 -1
  137. package/assets/editor/assets/DialogDescription-ZtZCUsfy.js +0 -1
  138. package/assets/editor/assets/DialogRoot-mHGRFW9m.js +0 -1
  139. package/assets/editor/assets/DialogTitle-CFhr-gP9.js +0 -1
  140. package/assets/editor/assets/FloatingPortalLite-Bf0q6fmL.js +0 -1
  141. package/assets/editor/assets/IconArrowBackUp-Brd2WpCh.js +0 -1
  142. package/assets/editor/assets/IconChevronLeft-BR0iwdRI.js +0 -1
  143. package/assets/editor/assets/IconChevronRight-DBDnxPYT.js +0 -1
  144. package/assets/editor/assets/IconHelp-DKNacRqS.js +0 -2
  145. package/assets/editor/assets/IconLoader2-BQaF1LKo.js +0 -1
  146. package/assets/editor/assets/IconMinus-y4ejub-s.js +0 -1
  147. package/assets/editor/assets/IconNote-CSELvWzx.js +0 -1
  148. package/assets/editor/assets/IconPlus-BbmieIBT.js +0 -1
  149. package/assets/editor/assets/IconX-AlbPkO_g.js +0 -1
  150. package/assets/editor/assets/MenuSubmenuTrigger-CpN67g09.js +0 -1
  151. package/assets/editor/assets/PopoverPopup-BqGWd_uB.js +0 -1
  152. package/assets/editor/assets/billing-C-BNGM3Z.js +0 -1
  153. package/assets/editor/assets/build-pips-CIaHaEPB.js +0 -1
  154. package/assets/editor/assets/build-visibility-E1mHeDCW.js +0 -1
  155. package/assets/editor/assets/builders-DbF28yId.js +0 -1
  156. package/assets/editor/assets/command-palette-BjFnQHnz.js +0 -1
  157. package/assets/editor/assets/config-a_lz-57R.js +0 -1
  158. package/assets/editor/assets/connector-labels-vVnYQJRz.js +0 -2
  159. package/assets/editor/assets/copy-image-dialog-CCY_6fM4.js +0 -1
  160. package/assets/editor/assets/createReactComponent-9UsI5fmM.js +0 -1
  161. package/assets/editor/assets/dialog-B32krrce.js +0 -1
  162. package/assets/editor/assets/editor-B0tARd79.js +0 -1
  163. package/assets/editor/assets/export-DEFKKRRi.js +0 -6
  164. package/assets/editor/assets/export-dialog-DPg1uzX5.js +0 -1
  165. package/assets/editor/assets/flow-layer-BC35drcK.js +0 -1
  166. package/assets/editor/assets/flow-panel-D_K9wgZi.js +0 -1
  167. package/assets/editor/assets/flow-stage-fiF5Nggn.js +0 -1
  168. package/assets/editor/assets/flow-start-ccYJ2KB9.js +0 -1
  169. package/assets/editor/assets/frames-CRP8oPP8.js +0 -1
  170. package/assets/editor/assets/icon-picker-NboB5Fvv.js +0 -1
  171. package/assets/editor/assets/image-library-Bb6bV6eK.js +0 -1
  172. package/assets/editor/assets/index-DfNbwHl_.js +0 -24
  173. package/assets/editor/assets/layout-offthread-BwetpTFH.js +0 -18
  174. package/assets/editor/assets/menu-BPrc8Ara.js +0 -1
  175. package/assets/editor/assets/panel-controls-DYZ7QFT5.js +0 -1
  176. package/assets/editor/assets/presentation-BavfNtxp.js +0 -1
  177. package/assets/editor/assets/presenter-keys-DVQcBdy1.js +0 -1
  178. package/assets/editor/assets/reflow-Cv75wPSh.js +0 -1
  179. package/assets/editor/assets/registry-DCgwH8wI.js +0 -1
  180. package/assets/editor/assets/renderer-environment-DmWXvuT4.js +0 -1
  181. package/assets/editor/assets/ride-overlay-DhygYdx1.js +0 -1
  182. package/assets/editor/assets/selection-overlay-primitives-hWJ1xjF7.js +0 -1
  183. package/assets/editor/assets/shape-meta-BpwsiB82.js +0 -1
  184. package/assets/editor/assets/sign-in-dialog-DRooo5xw.js +0 -1
  185. package/assets/editor/assets/slide-notes-dialog-DLdTmd7_.js +0 -1
  186. package/assets/editor/assets/slides-D9bnXqtf.js +0 -15
  187. package/assets/editor/assets/slides-panel-DV-zQJhV.js +0 -26
  188. package/assets/editor/assets/text-breaks-YU-ymaF9.js +0 -7
  189. package/assets/editor/assets/tidy-browser-BwodBnAH.js +0 -1
  190. package/assets/editor/assets/tidy-scope-BgBSUklT.js +0 -1
  191. package/assets/editor/assets/toast-Nu_fiCd9.js +0 -1
  192. package/assets/editor/assets/tool-catalog-ChSwaLIq.js +0 -1
  193. package/assets/editor/assets/tool-drawer-CG7-cnML.js +0 -1
  194. package/assets/editor/assets/tooltip-DgEojto1.js +0 -1
  195. package/assets/editor/assets/tree-rq4RTGgw.js +0 -1
  196. package/assets/editor/assets/upgrade-dialog-DpZeaLDB.js +0 -1
  197. package/assets/editor/assets/use-drag-reorder-C3h4ZMoZ.js +0 -1
  198. package/assets/editor/assets/use-export-command-CPc7qug1.js +0 -2
  199. package/assets/editor/assets/use-grid-keyboard-nav-B88Qw-cQ.js +0 -0
  200. package/assets/editor/assets/use-icon-node-DJZFjABX.js +0 -1
  201. package/assets/editor/assets/use-recent-list-BEG0iBIm.js +0 -1
  202. package/assets/editor/assets/useAnchoredPopupScrollLock-BGKchwpi.js +0 -1
  203. package/assets/editor/assets/useBaseUiId-C0Zm5sUV.js +0 -1
  204. package/assets/editor/assets/useButton-D3eS7fh5.js +0 -1
  205. package/assets/editor/assets/useControlled-C5xhvPXX.js +0 -1
  206. package/assets/editor/assets/usePositioner-DA3aR0-T.js +0 -1
  207. package/assets/editor/assets/useScrollLock-B7mQdXyv.js +0 -1
  208. package/assets/editor/assets/useValueChanged-p8z-93L4.js +0 -1
@@ -0,0 +1,24 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/tidy-browser-dF3BON7J.js","assets/slides-D686obFO.js","assets/style-BENGW2ZV.js","assets/elk-worker-loader-CVBdN1je.js","assets/rolldown-runtime-aKtaBQYM.js","assets/preload-helper-Czpn1I53.js","assets/text-breaks-DM4W6y5f.js","assets/blob-CTPsKWYv.js","assets/icons-DzW1j-r3.js","assets/icon-sources-CZI1h18s.js","assets/theme-palette-Dl_G_VIJ.js","assets/tidy-scope-BGG3ZXvZ.js","assets/widget-source-CHujvUeA.js","assets/react-lCSYwAWP.js","assets/reflow-DaYiVkwp.js","assets/asset-glyph-C1E6cGwM.js","assets/shape-meta-COE2ATNh.js","assets/layout-offthread-mRHRulkS.js","assets/registry-rEGZW7Ab.js","assets/builders-DMHAOPEv.js","assets/slides-panel-BEJCevJi.js","assets/jsx-runtime-DKdBMi_L.js","assets/tooltip-CyBz17g8.js","assets/useScrollLock-CQpr0n6U.js","assets/usePositioner-AtbrPc7w.js","assets/FloatingPortalLite-HnWQWrLk.js","assets/editor-BeufBV54.js","assets/keys-DrjiT9FL.js","assets/useBaseUiId-D2RfU0uY.js","assets/menu-B9BAk63v.js","assets/useButton-CLQYGhRJ.js","assets/createReactComponent-C51FAx3B.js","assets/useValueChanged-SqLfIDi5.js","assets/useAnchoredPopupScrollLock-i8D5Dm1d.js","assets/surface-Dke4SWpE.js","assets/config-D8b1QyEk.js","assets/renderer-environment-D3n3hbug.js","assets/panel-controls-DWVXiNUZ.js","assets/toast-Czv_DJ-4.js","assets/IconMinus-BcaDLts8.js","assets/IconPlus-D4tAoi-A.js","assets/PopoverPopup-B3Y0VRYc.js","assets/chrome-C2RCq3SI.js","assets/IconTrash-C8w6ThWx.js","assets/IconArrowLeft-B4Zcy-Fc.js","assets/IconPlayerStopFilled-D4qdct2R.js","assets/IconChevronLeft-D7e7QC0h.js","assets/IconChevronRight-csfMBSUs.js","assets/IconCode-CHIz1nCU.js","assets/build-visibility-DyML9SHt.js","assets/dom-PAoZruqo.js","assets/IconPencil-D_pQsAyv.js","assets/use-drag-reorder-ye8-kpyR.js","assets/IconSparkles-CnCp3BCQ.js","assets/IconX-KrRqxr2j.js","assets/IconPlayerPlayFilled-DVAWmYt7.js","assets/use-export-command-sC9UHj3_.js","assets/lazy-module-DkWvu4va.js","assets/clipboard-CO7YHov7.js","assets/plan-CkgM52Yh.js","assets/edit-C0sBxxsg.js","assets/DialogRoot-DUeVfNhS.js","assets/DialogTitle-D5au2NAn.js","assets/chrome-layout-BzPU9far.js","assets/panel-shell-BnMOHgWM.js","assets/export-K2VWg76n.js","assets/chart-4iRduYdU.js","assets/frames-Cp1QD3LR.js","assets/connector-labels-CrEgadsC.js","assets/code-panel-koBUgEWp.js","assets/diagram-fingerprint-WGQ5iVXx.js","assets/IconAlertTriangle-B33xznYN.js","assets/storage-CvDRYh5V.js","assets/dialog-DnXgEbpz.js","assets/flows-Cj7AFMIA.js","assets/core-CmsJyU_-.js","assets/icon-catalog-CbUlEKtK.js","assets/flow-panel-BzXNGGke.js","assets/editable-target-BTLnvKNi.js","assets/flow-start-CpAvU-9P.js","assets/tree-KSgPjntC.js","assets/IconCornerDownRight-DDiBMO4O.js","assets/IconLink-VS5p9Ytk.js","assets/MenuSubmenuTrigger-KacA9GM8.js","assets/flow-layer-ewaL7g2y.js","assets/use-key-held-094C3Mn3.js","assets/selection-overlay-primitives-BRp854AD.js","assets/IconFocusCentered-Cn8rbfRI.js","assets/flow-stage-Ba_CAggI.js","assets/presentation-DJUO0t7I.js","assets/presenter-keys-Bs3LnmOa.js","assets/web-embed-dialog-XUNelFFM.js","assets/web-shape-C941TGTy.js","assets/DialogDescription-Ddhk2rmF.js","assets/web-html-dialog-BcAyzH5D.js","assets/web-controls-CLE9zr7i.js","assets/slide-notes-dialog-BQBXpep6.js","assets/icon-picker-Cg39IKNJ.js","assets/use-grid-keyboard-nav-DhQKecO1.js","assets/use-icon-node-BxqH7H27.js","assets/use-recent-list-DuazDypH.js","assets/image-library-JQu_tb8P.js","assets/IconLoader2-CzCTn-Sn.js","assets/IconSearch-CCpMt02s.js","assets/tool-drawer-CWOX_njp.js","assets/tool-catalog-DXPhX2S1.js","assets/IconEraser-CYfXj27R.js","assets/IconMoodSmile-CSZ5p_Hy.js","assets/IconPhoto-5zuCDtnR.js","assets/command-palette-BR-_ChOL.js","assets/export-dialog-x2n2a4KX.js","assets/export-options-CJwykdP5.js","assets/copy-image-dialog-BzGP7Xw8.js","assets/build-pips-BV-uwXlP.js","assets/upgrade-dialog-DhSZnDpx.js","assets/useControlled-BE8zdmih.js","assets/billing-BSXr-z2r.js","assets/IconUsers-Dp85N225.js","assets/sign-in-dialog-tmQEB2bx.js","assets/IconPresentation-BMKzt7fv.js","assets/excalidraw-BwgRIDi9.js","assets/shared-DjLCTIA9.js","assets/tldraw-CE87oKyq.js"])))=>i.map(i=>d[i]);
2
+ import{i as e,n as t,t as n}from"./rolldown-runtime-aKtaBQYM.js";import{t as r}from"./react-lCSYwAWP.js";import{E as i,Fn as a,G as o,U as s,X as c,c as l,dt as u,ht as d,jn as f,ot as p,pt as m,w as h}from"./useScrollLock-CQpr0n6U.js";import{n as g,r as _,t as v}from"./toast-Czv_DJ-4.js";import{t as y}from"./jsx-runtime-DKdBMi_L.js";import{t as b}from"./useButton-CLQYGhRJ.js";import{n as x,t as S}from"./tooltip-CyBz17g8.js";import{D as C,E as w,O as T,S as E,T as D,_ as O,f as k,g as A,h as j,i as M,l as N,m as P,n as F,o as I,p as L,r as ee,t as R,v as z,x as B,y as V}from"./menu-B9BAk63v.js";import{i as te,n as ne,r as re,t as ie}from"./config-D8b1QyEk.js";import{A as ae,C as oe,D as se,E as ce,M as le,O as ue,T as de,_ as fe,a as H,c as pe,f as me,g as he,h as ge,i as _e,j as ve,k as ye,l as be,m as xe,n as Se,o as U,p as Ce,r as we,s as W,t as Te,u as Ee,v as De,w as Oe,y as ke}from"./editor-BeufBV54.js";import{C as Ae,a as je,b as Me,c as Ne,d as Pe,f as Fe,g as Ie,h as Le,i as Re,l as ze,m as Be,n as Ve,o as He,p as Ue,s as We,u as Ge,v as Ke,w as qe}from"./reflow-DaYiVkwp.js";import{$ as Je,$n as Ye,$r as Xe,$t as Ze,A as Qe,At as $e,Br as et,Bt as tt,C as nt,Dn as rt,Er as it,F as at,Fn as ot,Fr as st,Ft as ct,G as lt,Gr as ut,Gt as dt,Hn as ft,Hr as pt,Ht as mt,In as ht,Ir as gt,It as _t,Jn as vt,Jr as yt,Jt as bt,K as xt,Kr as St,Kt as Ct,L as wt,Ln as Tt,Lt as Et,M as Dt,Mn as Ot,Mt as kt,N as At,Nn as jt,Nr as Mt,Nt,On as Pt,Or as Ft,Pn as It,Pr as Lt,Pt as Rt,Q as zt,Qt as Bt,R as Vt,Rn as Ht,Rt as Ut,Sn as Wt,Sr as Gt,T as Kt,Tr as qt,Ur as Jt,Ut as Yt,V as Xt,Vr as Zt,Vt as Qt,W as $t,Wn as en,Wr as tn,Wt as nn,X as rn,Xn as an,Xr as on,Y as sn,Yn as cn,Yr as ln,Yt as un,Zn as dn,Zr as fn,Zt as pn,_ as mn,_n as hn,_r as gn,an as G,ar as _n,at as vn,b as yn,br as bn,bt as xn,ci as Sn,cn as Cn,dn as wn,dr as Tn,ei as En,en as Dn,er as On,et as kn,fr as An,g as jn,gn as Mn,hn as Nn,hr as Pn,ht as Fn,i as In,in as Ln,j as Rn,jt as zn,k as Bn,kt as Vn,l as Hn,li as Un,ln as Wn,mn as Gn,mr as Kn,nn as qn,nr as Jn,nt as Yn,o as Xn,on as Zn,pi as Qn,pn as $n,pr as er,pt as tr,q as nr,qr as rr,qt as ir,ri as ar,rn as or,si as sr,sn as cr,t as lr,ti as ur,tn as dr,tr as fr,ur as pr,ut as mr,v as hr,vr as gr,w as _r,wr as vr,x as yr,xn as br,xr,y as Sr,yn as Cr}from"./slides-D686obFO.js";import{$ as wr,A as Tr,B as Er,C as Dr,E as Or,G as kr,H as Ar,I as jr,J as Mr,K as Nr,N as Pr,O as Fr,Q as Ir,R as Lr,T as Rr,U as zr,V as Br,W as Vr,X as Hr,Y as Ur,Z as Wr,_ as Gr,a as Kr,at as qr,d as Jr,f as Yr,g as Xr,h as Zr,i as Qr,it as $r,j as ei,k as ti,l as ni,m as ri,n as ii,ot as ai,p as oi,q as si,r as ci,s as li,t as ui,u as di,v as fi,y as pi,z as mi}from"./style-BENGW2ZV.js";import{a as hi,d as gi,f as _i,i as vi,l as yi,m as bi,o as xi,p as Si,r as Ci,s as wi,t as Ti,u as Ei,z as Di}from"./registry-rEGZW7Ab.js";import{n as Oi,t as ki}from"./renderer-environment-D3n3hbug.js";import{t as Ai}from"./preload-helper-Czpn1I53.js";import{n as ji,t as Mi}from"./elk-worker-loader-CVBdN1je.js";import{c as Ni,d as Pi,h as Fi,i as Ii,l as Li,m as Ri,n as zi,o as Bi,p as Vi,r as Hi}from"./text-breaks-DM4W6y5f.js";import{t as Ui}from"./blob-CTPsKWYv.js";import{i as Wi,r as Gi}from"./icon-sources-CZI1h18s.js";import{t as Ki}from"./icons-DzW1j-r3.js";import{r as qi,t as Ji}from"./dom-PAoZruqo.js";import{_ as Yi,a as Xi,c as Zi,d as Qi,f as $i,g as ea,h as ta,i as na,l as ra,m as ia,n as aa,o as oa,p as sa,r as ca,s as la,t as ua,u as da,v as fa,y as pa}from"./selection-overlay-primitives-BRp854AD.js";import{a as ma,c as ha}from"./export-options-CJwykdP5.js";import{A as ga,C as _a,D as va,E as ya,O as ba,S as xa,T as Sa,_ as Ca,a as wa,b as Ta,c as Ea,d as Da,f as Oa,g as ka,h as Aa,i as ja,j as Ma,k as Na,l as Pa,m as Fa,n as Ia,o as La,p as Ra,r as za,s as Ba,t as Va,u as Ha,v as Ua,w as Wa,x as Ga,y as Ka}from"./panel-controls-DWVXiNUZ.js";import{a as qa,i as Ja,o as Ya,r as Xa,s as Za,t as Qa,u as $a}from"./presenter-keys-Bs3LnmOa.js";import{a as eo,c as to,i as no,n as ro,o as io,t as ao}from"./IconHelp-CaEwHrsN.js";import{i as oo,n as so,r as co}from"./lazy-module-DkWvu4va.js";import{n as lo}from"./tidy-scope-BGG3ZXvZ.js";import{r as uo}from"./clipboard-CO7YHov7.js";import{A as fo,C as po,D as mo,E as ho,F as go,M as _o,N as vo,O as yo,P as bo,S as xo,T as So,_ as Co,a as wo,b as To,c as Eo,d as Do,f as Oo,g as ko,h as Ao,i as jo,j as Mo,k as No,l as Po,m as Fo,n as Io,o as Lo,p as Ro,r as zo,s as Bo,u as Vo,v as Ho,w as Uo,x as Wo,y as Go}from"./chart-4iRduYdU.js";import{a as Ko,r as qo,t as Jo}from"./web-shape-C941TGTy.js";import{a as Yo,c as Xo,d as Zo,i as Qo,l as $o,n as es,r as ts,s as ns,t as rs,u as is}from"./frames-Cp1QD3LR.js";import{a as as,i as os,n as ss,o as cs,t as ls}from"./diagram-fingerprint-WGQ5iVXx.js";import{t as us}from"./editable-target-BTLnvKNi.js";import{n as ds,t as fs}from"./use-key-held-094C3Mn3.js";import{t as K}from"./createReactComponent-C51FAx3B.js";import{C as ps,E as ms,S as hs,T as gs,_ as _s,a as vs,b as ys,c as bs,d as xs,f as Ss,g as Cs,h as ws,i as Ts,l as Es,m as Ds,o as Os,p as ks,r as As,s as js,t as Ms,u as Ns,v as Ps,w as Fs,x as Is,y as Ls}from"./tool-catalog-DXPhX2S1.js";import{t as Rs}from"./IconAlertTriangle-B33xznYN.js";import{a as zs,n as Bs,r as Vs}from"./flow-start-CpAvU-9P.js";import{n as Hs,r as Us,t as Ws}from"./IconTrash-C8w6ThWx.js";import{t as Gs}from"./IconArrowLeft-B4Zcy-Fc.js";import{n as Ks,r as qs,t as Js}from"./IconPresentation-BMKzt7fv.js";import{i as Ys,r as Xs,t as Zs}from"./web-controls-CLE9zr7i.js";import{n as Qs}from"./useValueChanged-SqLfIDi5.js";import{t as $s}from"./IconChevronRight-csfMBSUs.js";import{t as ec}from"./IconCode-CHIz1nCU.js";import{n as tc,r as nc,t as rc}from"./useControlled-BE8zdmih.js";import{t as ic}from"./IconEraser-CYfXj27R.js";import{t as ac}from"./IconFocusCentered-Cn8rbfRI.js";import{a as oc,l as sc,n as cc,o as lc,r as uc,t as dc}from"./billing-BSXr-z2r.js";import{t as fc}from"./IconLink-VS5p9Ytk.js";import{t as pc}from"./IconLoader2-CzCTn-Sn.js";import{t as mc}from"./IconMinus-BcaDLts8.js";import{t as hc}from"./IconPencil-D_pQsAyv.js";import{t as gc}from"./IconPhoto-5zuCDtnR.js";import{t as _c}from"./IconPlus-D4tAoi-A.js";import{n as vc,r as yc,t as bc}from"./MenuSubmenuTrigger-KacA9GM8.js";import{t as xc}from"./IconSearch-CCpMt02s.js";import{t as Sc}from"./IconSparkles-CnCp3BCQ.js";import{t as Cc}from"./IconX-KrRqxr2j.js";import{t as wc}from"./IconPlayerPlayFilled-DVAWmYt7.js";import{S as Tc,_ as Ec,a as Dc,d as Oc,f as kc,g as Ac,h as jc,i as Mc,l as Nc,m as Pc,n as Fc,o as Ic,r as Lc,t as Rc}from"./PopoverPopup-B3Y0VRYc.js";import{n as zc,t as Bc}from"./keys-DrjiT9FL.js";import{n as Vc,t as Hc}from"./storage-CvDRYh5V.js";import{a as Uc,r as Wc,t as Gc}from"./core-CmsJyU_-.js";import{t as Kc}from"./use-export-command-sC9UHj3_.js";import{n as qc,r as Jc,t as Yc}from"./widget-source-CHujvUeA.js";import{i as Xc,n as Zc,o as Qc,t as $c}from"./asset-glyph-C1E6cGwM.js";import{t as el}from"./useBaseUiId-D2RfU0uY.js";import{n as q,t as tl}from"./surface-Dke4SWpE.js";import{_ as nl,d as rl}from"./plan-CkgM52Yh.js";import{a as il,c as al,i as ol,l as sl,n as cl,o as ll,r as ul,s as dl,t as fl,u as pl}from"./chrome-C2RCq3SI.js";import{a as ml,i as hl,n as gl,o as _l,r as vl,t as yl}from"./DialogRoot-DUeVfNhS.js";import{n as bl,t as xl}from"./DialogTitle-D5au2NAn.js";import{t as Sl}from"./DialogDescription-Ddhk2rmF.js";import{n as Cl,r as wl,t as Tl}from"./dialog-DnXgEbpz.js";import{i as El,n as Dl,r as Ol,t as kl}from"./use-icon-node-BxqH7H27.js";import{n as Al}from"./chrome-layout-BzPU9far.js";import{t as jl}from"./panel-shell-BnMOHgWM.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Ml=n((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),Nl=n(((e,t)=>{t.exports=Ml()})),Pl=n((e=>{var t=Nl(),n=r(),i=a();function o(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 s(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function c(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function l(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function u(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function d(e){if(c(e)!==e)throw Error(o(188))}function f(e){var t=e.alternate;if(!t){if(t=c(e),t===null)throw Error(o(188));return t===e?e:null}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var a=i.alternate;if(a===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===a.child){for(a=i.child;a;){if(a===n)return d(i),e;if(a===r)return d(i),t;a=a.sibling}throw Error(o(188))}if(n.return!==r.return)n=i,r=a;else{for(var s=!1,l=i.child;l;){if(l===n){s=!0,n=i,r=a;break}if(l===r){s=!0,r=i,n=a;break}l=l.sibling}if(!s){for(l=a.child;l;){if(l===n){s=!0,n=a,r=i;break}if(l===r){s=!0,r=a,n=i;break}l=l.sibling}if(!s)throw Error(o(189))}}if(n.alternate!==r)throw Error(o(190))}if(n.tag!==3)throw Error(o(188));return n.stateNode.current===n?e:t}function p(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=p(e),t!==null)return t;e=e.sibling}return null}var m=Object.assign,h=Symbol.for(`react.element`),g=Symbol.for(`react.transitional.element`),_=Symbol.for(`react.portal`),v=Symbol.for(`react.fragment`),y=Symbol.for(`react.strict_mode`),b=Symbol.for(`react.profiler`),x=Symbol.for(`react.consumer`),S=Symbol.for(`react.context`),C=Symbol.for(`react.forward_ref`),w=Symbol.for(`react.suspense`),T=Symbol.for(`react.suspense_list`),E=Symbol.for(`react.memo`),D=Symbol.for(`react.lazy`),O=Symbol.for(`react.activity`),k=Symbol.for(`react.memo_cache_sentinel`),A=Symbol.iterator;function j(e){return typeof e!=`object`||!e?null:(e=A&&e[A]||e[`@@iterator`],typeof e==`function`?e:null)}var M=Symbol.for(`react.client.reference`);function N(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===M?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case v:return`Fragment`;case b:return`Profiler`;case y:return`StrictMode`;case w:return`Suspense`;case T:return`SuspenseList`;case O:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case _:return`Portal`;case S:return e.displayName||`Context`;case x:return(e._context.displayName||`Context`)+`.Consumer`;case C:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case E:return t=e.displayName||null,t===null?N(e.type)||`Memo`:t;case D:t=e._payload,e=e._init;try{return N(e(t))}catch{}}return null}var P=Array.isArray,F=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,L={pending:!1,data:null,method:null,action:null},ee=[],R=-1;function z(e){return{current:e}}function B(e){0>R||(e.current=ee[R],ee[R]=null,R--)}function V(e,t){R++,ee[R]=e.current,e.current=t}var te=z(null),ne=z(null),re=z(null),ie=z(null);function ae(e,t){switch(V(re,t),V(ne,e),V(te,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Wd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Wd(t),e=Gd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}B(te),V(te,e)}function oe(){B(te),B(ne),B(re)}function se(e){e.memoizedState!==null&&V(ie,e);var t=te.current,n=Gd(t,e.type);t!==n&&(V(ne,e),V(te,n))}function ce(e){ne.current===e&&(B(te),B(ne)),ie.current===e&&(B(ie),tp._currentValue=L)}var le,ue;function de(e){if(le===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);le=t&&t[1]||``,ue=-1<e.stack.indexOf(`
3
+ at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
+ `+le+e+ue}var fe=!1;function H(e,t){if(!e||fe)return``;fe=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
5
+ `),l=s.split(`
6
+ `);for(i=r=0;r<c.length&&!c[r].includes(`DetermineComponentFrameRoot`);)r++;for(;i<l.length&&!l[i].includes(`DetermineComponentFrameRoot`);)i++;if(r===c.length||i===l.length)for(r=c.length-1,i=l.length-1;1<=r&&0<=i&&c[r]!==l[i];)i--;for(;1<=r&&0<=i;r--,i--)if(c[r]!==l[i]){if(r!==1||i!==1)do if(r--,i--,0>i||c[r]!==l[i]){var u=`
7
+ `+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(`<anonymous>`)&&(u=u.replace(`<anonymous>`,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{fe=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?de(n):``}function pe(e,t){switch(e.tag){case 26:case 27:case 5:return de(e.type);case 16:return de(`Lazy`);case 13:return e.child!==t&&t!==null?de(`Suspense Fallback`):de(`Suspense`);case 19:return de(`SuspenseList`);case 0:case 15:return H(e.type,!1);case 11:return H(e.type.render,!1);case 1:return H(e.type,!0);case 31:return de(`Activity`);default:return``}}function me(e){try{var t=``,n=null;do t+=pe(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
8
+ Error generating stack: `+e.message+`
9
+ `+e.stack}}var he=Object.prototype.hasOwnProperty,ge=t.unstable_scheduleCallback,_e=t.unstable_cancelCallback,ve=t.unstable_shouldYield,ye=t.unstable_requestPaint,be=t.unstable_now,xe=t.unstable_getCurrentPriorityLevel,Se=t.unstable_ImmediatePriority,U=t.unstable_UserBlockingPriority,Ce=t.unstable_NormalPriority,we=t.unstable_LowPriority,W=t.unstable_IdlePriority,Te=t.log,Ee=t.unstable_setDisableYieldValue,De=null,Oe=null;function ke(e){if(typeof Te==`function`&&Ee(e),Oe&&typeof Oe.setStrictMode==`function`)try{Oe.setStrictMode(De,e)}catch{}}var Ae=Math.clz32?Math.clz32:Ne,je=Math.log,Me=Math.LN2;function Ne(e){return e>>>=0,e===0?32:31-(je(e)/Me|0)|0}var Pe=256,Fe=262144,Ie=4194304;function Le(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Re(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=Le(n))):i=Le(o):i=Le(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=Le(n))):i=Le(o)):i=Le(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function ze(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Be(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Ve(){var e=Ie;return Ie<<=1,!(Ie&62914560)&&(Ie=4194304),e}function He(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Ue(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function We(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-Ae(n),d=1<<u;s[u]=0,c[u]=-1;var f=l[u];if(f!==null)for(l[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}r!==0&&Ge(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function Ge(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-Ae(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function Ke(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Ae(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function qe(e,t){var n=t&-t;return n=n&42?1:Je(n),(n&(e.suspendedLanes|t))===0?n:0}function Je(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function Ye(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function Xe(){var e=I.p;return e===0?(e=window.event,e===void 0?32:_p(e.type)):e}function Ze(e,t){var n=I.p;try{return I.p=e,t()}finally{I.p=n}}var Qe=Math.random().toString(36).slice(2),$e=`__reactFiber$`+Qe,et=`__reactProps$`+Qe,tt=`__reactContainer$`+Qe,nt=`__reactEvents$`+Qe,rt=`__reactListeners$`+Qe,it=`__reactHandles$`+Qe,at=`__reactResources$`+Qe,ot=`__reactMarker$`+Qe;function st(e){delete e[$e],delete e[et],delete e[nt],delete e[rt],delete e[it]}function ct(e){var t=e[$e];if(t)return t;for(var n=e.parentNode;n;){if(t=n[tt]||n[$e]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=mf(e);e!==null;){if(n=e[$e])return n;e=mf(e)}return t}e=n,n=e.parentNode}return null}function lt(e){if(e=e[$e]||e[tt]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function ut(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(o(33))}function dt(e){var t=e[at];return t||=e[at]={hoistableStyles:new Map,hoistableScripts:new Map},t}function ft(e){e[ot]=!0}var pt=new Set,mt={};function ht(e,t){gt(e,t),gt(e+`Capture`,t)}function gt(e,t){for(mt[e]=t,e=0;e<t.length;e++)pt.add(t[e])}var _t=RegExp(`^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$`),vt={},yt={};function bt(e){return he.call(yt,e)?!0:he.call(vt,e)?!1:_t.test(e)?yt[e]=!0:(vt[e]=!0,!1)}function xt(e,t,n){if(bt(t))if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:e.removeAttribute(t);return;case`boolean`:var r=t.toLowerCase().slice(0,5);if(r!==`data-`&&r!==`aria-`){e.removeAttribute(t);return}}e.setAttribute(t,``+n)}}function St(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(t);return}e.setAttribute(t,``+n)}}function Ct(e,t,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(n);return}e.setAttributeNS(t,n,``+r)}}function wt(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function Tt(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function Et(e,t,n){var r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&r!==void 0&&typeof r.get==`function`&&typeof r.set==`function`){var i=r.get,a=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){n=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(e){n=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Dt(e){if(!e._valueTracker){var t=Tt(e)?`checked`:`value`;e._valueTracker=Et(e,t,``+e[t])}}function Ot(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=Tt(e)?e.checked?`true`:`false`:e.value),e=r,e===n?!1:(t.setValue(e),!0)}function kt(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}var At=/[\n"\\]/g;function jt(e){return e.replace(At,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function Mt(e,t,n,r,i,a,o,s){e.name=``,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`?e.type=o:e.removeAttribute(`type`),t==null?o!==`submit`&&o!==`reset`||e.removeAttribute(`value`):o===`number`?(t===0&&e.value===``||e.value!=t)&&(e.value=``+wt(t)):e.value!==``+wt(t)&&(e.value=``+wt(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):Pt(e,o,wt(n)):Pt(e,o,wt(t)),i==null&&a!=null&&(e.defaultChecked=!!a),i!=null&&(e.checked=i&&typeof i!=`function`&&typeof i!=`symbol`),s!=null&&typeof s!=`function`&&typeof s!=`symbol`&&typeof s!=`boolean`?e.name=``+wt(s):e.removeAttribute(`name`)}function Nt(e,t,n,r,i,a,o,s){if(a!=null&&typeof a!=`function`&&typeof a!=`symbol`&&typeof a!=`boolean`&&(e.type=a),t!=null||n!=null){if(!(a!==`submit`&&a!==`reset`||t!=null)){Dt(e);return}n=n==null?``:``+wt(n),t=t==null?n:``+wt(t),s||t===e.value||(e.value=t),e.defaultValue=t}r??=i,r=typeof r!=`function`&&typeof r!=`symbol`&&!!r,e.checked=s?e.checked:!!r,e.defaultChecked=!!r,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`&&(e.name=o),Dt(e)}function Pt(e,t,n){t===`number`&&kt(e.ownerDocument)===e||e.defaultValue===``+n||(e.defaultValue=``+n)}function Ft(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t[`$`+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty(`$`+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=``+wt(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function It(e,t,n){if(t!=null&&(t=``+wt(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n==null?``:``+wt(n)}function Lt(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(o(92));if(P(r)){if(1<r.length)throw Error(o(93));r=r[0]}n=r}n??=``,t=n}n=wt(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),Dt(e)}function Rt(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var zt=new Set(`animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp`.split(` `));function Bt(e,t,n){var r=t.indexOf(`--`)===0;n==null||typeof n==`boolean`||n===``?r?e.setProperty(t,``):t===`float`?e.cssFloat=``:e[t]=``:r?e.setProperty(t,n):typeof n!=`number`||n===0||zt.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function Vt(e,t,n){if(t!=null&&typeof t!=`object`)throw Error(o(62));if(e=e.style,n!=null){for(var r in n)!n.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf(`--`)===0?e.setProperty(r,``):r===`float`?e.cssFloat=``:e[r]=``);for(var i in t)r=t[i],t.hasOwnProperty(i)&&n[i]!==r&&Bt(e,i,r)}else for(var a in t)t.hasOwnProperty(a)&&Bt(e,a,t[a])}function Ht(e){if(e.indexOf(`-`)===-1)return!1;switch(e){case`annotation-xml`:case`color-profile`:case`font-face`:case`font-face-src`:case`font-face-uri`:case`font-face-format`:case`font-face-name`:case`missing-glyph`:return!1;default:return!0}}var Ut=new Map([[`acceptCharset`,`accept-charset`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`],[`crossOrigin`,`crossorigin`],[`accentHeight`,`accent-height`],[`alignmentBaseline`,`alignment-baseline`],[`arabicForm`,`arabic-form`],[`baselineShift`,`baseline-shift`],[`capHeight`,`cap-height`],[`clipPath`,`clip-path`],[`clipRule`,`clip-rule`],[`colorInterpolation`,`color-interpolation`],[`colorInterpolationFilters`,`color-interpolation-filters`],[`colorProfile`,`color-profile`],[`colorRendering`,`color-rendering`],[`dominantBaseline`,`dominant-baseline`],[`enableBackground`,`enable-background`],[`fillOpacity`,`fill-opacity`],[`fillRule`,`fill-rule`],[`floodColor`,`flood-color`],[`floodOpacity`,`flood-opacity`],[`fontFamily`,`font-family`],[`fontSize`,`font-size`],[`fontSizeAdjust`,`font-size-adjust`],[`fontStretch`,`font-stretch`],[`fontStyle`,`font-style`],[`fontVariant`,`font-variant`],[`fontWeight`,`font-weight`],[`glyphName`,`glyph-name`],[`glyphOrientationHorizontal`,`glyph-orientation-horizontal`],[`glyphOrientationVertical`,`glyph-orientation-vertical`],[`horizAdvX`,`horiz-adv-x`],[`horizOriginX`,`horiz-origin-x`],[`imageRendering`,`image-rendering`],[`letterSpacing`,`letter-spacing`],[`lightingColor`,`lighting-color`],[`markerEnd`,`marker-end`],[`markerMid`,`marker-mid`],[`markerStart`,`marker-start`],[`overlinePosition`,`overline-position`],[`overlineThickness`,`overline-thickness`],[`paintOrder`,`paint-order`],[`panose-1`,`panose-1`],[`pointerEvents`,`pointer-events`],[`renderingIntent`,`rendering-intent`],[`shapeRendering`,`shape-rendering`],[`stopColor`,`stop-color`],[`stopOpacity`,`stop-opacity`],[`strikethroughPosition`,`strikethrough-position`],[`strikethroughThickness`,`strikethrough-thickness`],[`strokeDasharray`,`stroke-dasharray`],[`strokeDashoffset`,`stroke-dashoffset`],[`strokeLinecap`,`stroke-linecap`],[`strokeLinejoin`,`stroke-linejoin`],[`strokeMiterlimit`,`stroke-miterlimit`],[`strokeOpacity`,`stroke-opacity`],[`strokeWidth`,`stroke-width`],[`textAnchor`,`text-anchor`],[`textDecoration`,`text-decoration`],[`textRendering`,`text-rendering`],[`transformOrigin`,`transform-origin`],[`underlinePosition`,`underline-position`],[`underlineThickness`,`underline-thickness`],[`unicodeBidi`,`unicode-bidi`],[`unicodeRange`,`unicode-range`],[`unitsPerEm`,`units-per-em`],[`vAlphabetic`,`v-alphabetic`],[`vHanging`,`v-hanging`],[`vIdeographic`,`v-ideographic`],[`vMathematical`,`v-mathematical`],[`vectorEffect`,`vector-effect`],[`vertAdvY`,`vert-adv-y`],[`vertOriginX`,`vert-origin-x`],[`vertOriginY`,`vert-origin-y`],[`wordSpacing`,`word-spacing`],[`writingMode`,`writing-mode`],[`xmlnsXlink`,`xmlns:xlink`],[`xHeight`,`x-height`]]),Wt=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Gt(e){return Wt.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function Kt(){}var qt=null;function Jt(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Yt=null,Xt=null;function Zt(e){var t=lt(e);if(t&&(e=t.stateNode)){var n=e[et]||null;a:switch(e=t.stateNode,t.type){case`input`:if(Mt(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name="`+jt(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var i=r[et]||null;if(!i)throw Error(o(90));Mt(r,i.value,i.defaultValue,i.defaultValue,i.checked,i.defaultChecked,i.type,i.name)}}for(t=0;t<n.length;t++)r=n[t],r.form===e.form&&Ot(r)}break a;case`textarea`:It(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&Ft(e,!!n.multiple,t,!1)}}}var Qt=!1;function $t(e,t,n){if(Qt)return e(t,n);Qt=!0;try{return e(t)}finally{if(Qt=!1,(Yt!==null||Xt!==null)&&(bu(),Yt&&(t=Yt,e=Xt,Xt=Yt=null,Zt(t),e)))for(t=0;t<e.length;t++)Zt(e[t])}}function en(e,t){var n=e.stateNode;if(n===null)return null;var r=n[et]||null;if(r===null)return null;n=r[t];a:switch(t){case`onClick`:case`onClickCapture`:case`onDoubleClick`:case`onDoubleClickCapture`:case`onMouseDown`:case`onMouseDownCapture`:case`onMouseMove`:case`onMouseMoveCapture`:case`onMouseUp`:case`onMouseUpCapture`:case`onMouseEnter`:(r=!r.disabled)||(e=e.type,r=!(e===`button`||e===`input`||e===`select`||e===`textarea`)),e=!r;break a;default:e=!1}if(e)return null;if(n&&typeof n!=`function`)throw Error(o(231,t,typeof n));return n}var tn=!(typeof window>`u`||window.document===void 0||window.document.createElement===void 0),nn=!1;if(tn)try{var rn={};Object.defineProperty(rn,"passive",{get:function(){nn=!0}}),window.addEventListener(`test`,rn,rn),window.removeEventListener(`test`,rn,rn)}catch{nn=!1}var an=null,on=null,sn=null;function cn(){if(sn)return sn;var e,t=on,n=t.length,r,i=`value`in an?an.value:an.textContent,a=i.length;for(e=0;e<n&&t[e]===i[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===i[a-r];r++);return sn=i.slice(e,1<r?1-r:void 0)}function ln(e){var t=e.keyCode;return`charCode`in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function un(){return!0}function dn(){return!1}function fn(e){function t(t,n,r,i,a){for(var o in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=i,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented==null?!1===i.returnValue:i.defaultPrevented)?un:dn,this.isPropagationStopped=dn,this}return m(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():typeof e.returnValue!=`unknown`&&(e.returnValue=!1),this.isDefaultPrevented=un)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=un)},persist:function(){},isPersistent:un}),t}var pn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},mn=fn(pn),hn=m({},pn,{view:0,detail:0}),gn=fn(hn),G,_n,vn,yn=m({},hn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:An,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return`movementX`in e?e.movementX:(e!==vn&&(vn&&e.type===`mousemove`?(G=e.screenX-vn.screenX,_n=e.screenY-vn.screenY):_n=G=0,vn=e),G)},movementY:function(e){return`movementY`in e?e.movementY:_n}}),bn=fn(yn),xn=fn(m({},yn,{dataTransfer:0})),Sn=fn(m({},hn,{relatedTarget:0})),Cn=fn(m({},pn,{animationName:0,elapsedTime:0,pseudoElement:0})),wn=fn(m({},pn,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),Tn=fn(m({},pn,{data:0})),En={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},Dn={8:`Backspace`,9:`Tab`,12:`Clear`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,19:`Pause`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,45:`Insert`,46:`Delete`,112:`F1`,113:`F2`,114:`F3`,115:`F4`,116:`F5`,117:`F6`,118:`F7`,119:`F8`,120:`F9`,121:`F10`,122:`F11`,123:`F12`,144:`NumLock`,145:`ScrollLock`,224:`Meta`},On={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function kn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=On[e])?!!t[e]:!1}function An(){return kn}var jn=fn(m({},hn,{key:function(e){if(e.key){var t=En[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=ln(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?Dn[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:An,charCode:function(e){return e.type===`keypress`?ln(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?ln(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),Mn=fn(m({},yn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),Nn=fn(m({},hn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:An})),Pn=fn(m({},pn,{propertyName:0,elapsedTime:0,pseudoElement:0})),Fn=fn(m({},yn,{deltaX:function(e){return`deltaX`in e?e.deltaX:`wheelDeltaX`in e?-e.wheelDeltaX:0},deltaY:function(e){return`deltaY`in e?e.deltaY:`wheelDeltaY`in e?-e.wheelDeltaY:`wheelDelta`in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),In=fn(m({},pn,{newState:0,oldState:0})),Ln=[9,13,27,32],Rn=tn&&`CompositionEvent`in window,zn=null;tn&&`documentMode`in document&&(zn=document.documentMode);var Bn=tn&&`TextEvent`in window&&!zn,Vn=tn&&(!Rn||zn&&8<zn&&11>=zn),Hn=` `,Un=!1;function Wn(e,t){switch(e){case`keyup`:return Ln.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function Gn(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var Kn=!1;function qn(e,t){switch(e){case`compositionend`:return Gn(t);case`keypress`:return t.which===32?(Un=!0,Hn):null;case`textInput`:return e=t.data,e===Hn&&Un?null:e;default:return null}}function Jn(e,t){if(Kn)return e===`compositionend`||!Rn&&Wn(e,t)?(e=cn(),sn=on=an=null,Kn=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case`compositionend`:return Vn&&t.locale!==`ko`?null:t.data;default:return null}}var Yn={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Xn(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!Yn[e.type]:t===`textarea`}function Zn(e,t,n,r){Yt?Xt?Xt.push(r):Xt=[r]:Yt=r,t=Od(t,`onChange`),0<t.length&&(n=new mn(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var Qn=null,$n=null;function er(e){bd(e,0)}function tr(e){if(Ot(ut(e)))return e}function nr(e,t){if(e===`change`)return t}var rr=!1;if(tn){var ir;if(tn){var ar=`oninput`in document;if(!ar){var or=document.createElement(`div`);or.setAttribute(`oninput`,`return;`),ar=typeof or.oninput==`function`}ir=ar}else ir=!1;rr=ir&&(!document.documentMode||9<document.documentMode)}function sr(){Qn&&(Qn.detachEvent(`onpropertychange`,cr),$n=Qn=null)}function cr(e){if(e.propertyName===`value`&&tr($n)){var t=[];Zn(t,$n,e,Jt(e)),$t(er,t)}}function lr(e,t,n){e===`focusin`?(sr(),Qn=t,$n=n,Qn.attachEvent(`onpropertychange`,cr)):e===`focusout`&&sr()}function ur(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return tr($n)}function dr(e,t){if(e===`click`)return tr(t)}function fr(e,t){if(e===`input`||e===`change`)return tr(t)}function pr(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var mr=typeof Object.is==`function`?Object.is:pr;function hr(e,t){if(mr(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!he.call(t,i)||!mr(e[i],t[i]))return!1}return!0}function gr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function _r(e,t){var n=gr(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=gr(n)}}function vr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?vr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function yr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=kt(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=kt(e.document)}return t}function br(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var xr=tn&&`documentMode`in document&&11>=document.documentMode,Sr=null,Cr=null,wr=null,Tr=!1;function Er(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Tr||Sr==null||Sr!==kt(r)||(r=Sr,`selectionStart`in r&&br(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),wr&&hr(wr,r)||(wr=r,r=Od(Cr,`onSelect`),0<r.length&&(t=new mn(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=Sr)))}function Dr(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var Or={animationend:Dr(`Animation`,`AnimationEnd`),animationiteration:Dr(`Animation`,`AnimationIteration`),animationstart:Dr(`Animation`,`AnimationStart`),transitionrun:Dr(`Transition`,`TransitionRun`),transitionstart:Dr(`Transition`,`TransitionStart`),transitioncancel:Dr(`Transition`,`TransitionCancel`),transitionend:Dr(`Transition`,`TransitionEnd`)},kr={},Ar={};tn&&(Ar=document.createElement(`div`).style,`AnimationEvent`in window||(delete Or.animationend.animation,delete Or.animationiteration.animation,delete Or.animationstart.animation),`TransitionEvent`in window||delete Or.transitionend.transition);function jr(e){if(kr[e])return kr[e];if(!Or[e])return e;var t=Or[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Ar)return kr[e]=t[n];return e}var Mr=jr(`animationend`),Nr=jr(`animationiteration`),Pr=jr(`animationstart`),Fr=jr(`transitionrun`),Ir=jr(`transitionstart`),Lr=jr(`transitioncancel`),Rr=jr(`transitionend`),zr=new Map,Br=`abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel`.split(` `);Br.push(`scrollEnd`);function Vr(e,t){zr.set(e,t),ht(t,[e])}var Hr=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},Ur=[],Wr=0,Gr=0;function Kr(){for(var e=Wr,t=Gr=Wr=0;t<e;){var n=Ur[t];Ur[t++]=null;var r=Ur[t];Ur[t++]=null;var i=Ur[t];Ur[t++]=null;var a=Ur[t];if(Ur[t++]=null,r!==null&&i!==null){var o=r.pending;o===null?i.next=i:(i.next=o.next,o.next=i),r.pending=i}a!==0&&Xr(n,i,a)}}function qr(e,t,n,r){Ur[Wr++]=e,Ur[Wr++]=t,Ur[Wr++]=n,Ur[Wr++]=r,Gr|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function Jr(e,t,n,r){return qr(e,t,n,r),Zr(e)}function Yr(e,t){return qr(e,null,null,t),Zr(e)}function Xr(e,t,n){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n);for(var i=!1,a=e.return;a!==null;)a.childLanes|=n,r=a.alternate,r!==null&&(r.childLanes|=n),a.tag===22&&(e=a.stateNode,e===null||e._visibility&1||(i=!0)),e=a,a=a.return;return e.tag===3?(a=e.stateNode,i&&t!==null&&(i=31-Ae(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function Zr(e){if(50<du)throw du=0,fu=null,Error(o(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var Qr={};function $r(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ei(e,t,n,r){return new $r(e,t,n,r)}function ti(e){return e=e.prototype,!(!e||!e.isReactComponent)}function ni(e,t){var n=e.alternate;return n===null?(n=ei(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&65011712,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function ri(e,t){e.flags&=65011714;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function ii(e,t,n,r,i,a){var s=0;if(r=e,typeof e==`function`)ti(e)&&(s=1);else if(typeof e==`string`)s=Kf(e,n,te.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(e){case O:return e=ei(31,n,t,i),e.elementType=O,e.lanes=a,e;case v:return ai(n.children,i,a,t);case y:s=8,i|=24;break;case b:return e=ei(12,n,t,i|2),e.elementType=b,e.lanes=a,e;case w:return e=ei(13,n,t,i),e.elementType=w,e.lanes=a,e;case T:return e=ei(19,n,t,i),e.elementType=T,e.lanes=a,e;default:if(typeof e==`object`&&e)switch(e.$$typeof){case S:s=10;break a;case x:s=9;break a;case C:s=11;break a;case E:s=14;break a;case D:s=16,r=null;break a}s=29,n=Error(o(130,e===null?`null`:typeof e,``)),r=null}return t=ei(s,n,t,i),t.elementType=e,t.type=r,t.lanes=a,t}function ai(e,t,n,r){return e=ei(7,e,r,t),e.lanes=n,e}function oi(e,t,n){return e=ei(6,e,null,t),e.lanes=n,e}function si(e){var t=ei(18,null,null,0);return t.stateNode=e,t}function ci(e,t,n){return t=ei(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var li=new WeakMap;function ui(e,t){if(typeof e==`object`&&e){var n=li.get(e);return n===void 0?(t={value:e,source:t,stack:me(t)},li.set(e,t),t):n}return{value:e,source:t,stack:me(t)}}var di=[],fi=0,pi=null,mi=0,hi=[],gi=0,_i=null,vi=1,yi=``;function bi(e,t){di[fi++]=mi,di[fi++]=pi,pi=e,mi=t}function xi(e,t,n){hi[gi++]=vi,hi[gi++]=yi,hi[gi++]=_i,_i=e;var r=vi;e=yi;var i=32-Ae(r)-1;r&=~(1<<i),n+=1;var a=32-Ae(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,vi=1<<32-Ae(t)+i|n<<i|r,yi=a+e}else vi=1<<a|n<<i|r,yi=e}function Si(e){e.return!==null&&(bi(e,1),xi(e,1,0))}function Ci(e){for(;e===pi;)pi=di[--fi],di[fi]=null,mi=di[--fi],di[fi]=null;for(;e===_i;)_i=hi[--gi],hi[gi]=null,yi=hi[--gi],hi[gi]=null,vi=hi[--gi],hi[gi]=null}function wi(e,t){hi[gi++]=vi,hi[gi++]=yi,hi[gi++]=_i,vi=t.id,yi=t.overflow,_i=e}var Ti=null,Ei=null,Di=!1,Oi=null,ki=!1,Ai=Error(o(519));function ji(e){throw Li(ui(Error(o(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),Ai}function Mi(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[$e]=e,t[et]=r,n){case`dialog`:xd(`cancel`,t),xd(`close`,t);break;case`iframe`:case`object`:case`embed`:xd(`load`,t);break;case`video`:case`audio`:for(n=0;n<vd.length;n++)xd(vd[n],t);break;case`source`:xd(`error`,t);break;case`img`:case`image`:case`link`:xd(`error`,t),xd(`load`,t);break;case`details`:xd(`toggle`,t);break;case`input`:xd(`invalid`,t),Nt(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:xd(`invalid`,t);break;case`textarea`:xd(`invalid`,t),Lt(t,r.value,r.defaultValue,r.children)}n=r.children,typeof n!=`string`&&typeof n!=`number`&&typeof n!=`bigint`||t.textContent===``+n||!0===r.suppressHydrationWarning||Pd(t.textContent,n)?(r.popover!=null&&(xd(`beforetoggle`,t),xd(`toggle`,t)),r.onScroll!=null&&xd(`scroll`,t),r.onScrollEnd!=null&&xd(`scrollend`,t),r.onClick!=null&&(t.onclick=Kt),t=!0):t=!1,t||ji(e,!0)}function Ni(e){for(Ti=e.return;Ti;)switch(Ti.tag){case 5:case 31:case 13:ki=!1;return;case 27:case 3:ki=!0;return;default:Ti=Ti.return}}function Pi(e){if(e!==Ti)return!1;if(!Di)return Ni(e),Di=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=!(n!==`form`&&n!==`button`)||Kd(e.type,e.memoizedProps)),n=!n),n&&Ei&&ji(e),Ni(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(o(317));Ei=pf(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(o(317));Ei=pf(e)}else t===27?(t=Ei,ef(e.type)?(e=ff,ff=null,Ei=e):Ei=t):Ei=Ti?df(e.stateNode.nextSibling):null;return!0}function Fi(){Ei=Ti=null,Di=!1}function Ii(){var e=Oi;return e!==null&&(Zl===null?Zl=e:Zl.push.apply(Zl,e),Oi=null),e}function Li(e){Oi===null?Oi=[e]:Oi.push(e)}var Ri=z(null),zi=null,Bi=null;function Vi(e,t,n){V(Ri,t._currentValue),t._currentValue=n}function Hi(e){e._currentValue=Ri.current,B(Ri)}function Ui(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function Wi(e,t,n,r){var i=e.child;for(i!==null&&(i.return=e);i!==null;){var a=i.dependencies;if(a!==null){var s=i.child;a=a.firstContext;a:for(;a!==null;){var c=a;a=i;for(var l=0;l<t.length;l++)if(c.context===t[l]){a.lanes|=n,c=a.alternate,c!==null&&(c.lanes|=n),Ui(a.return,n,e),r||(s=null);break a}a=c.next}}else if(i.tag===18){if(s=i.return,s===null)throw Error(o(341));s.lanes|=n,a=s.alternate,a!==null&&(a.lanes|=n),Ui(s,n,e),s=null}else s=i.child;if(s!==null)s.return=i;else for(s=i;s!==null;){if(s===e){s=null;break}if(i=s.sibling,i!==null){i.return=s.return,s=i;break}s=s.return}i=s}}function Gi(e,t,n,r){e=null;for(var i=t,a=!1;i!==null;){if(!a){if(i.flags&524288)a=!0;else if(i.flags&262144)break}if(i.tag===10){var s=i.alternate;if(s===null)throw Error(o(387));if(s=s.memoizedProps,s!==null){var c=i.type;mr(i.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(i===ie.current){if(s=i.alternate,s===null)throw Error(o(387));s.memoizedState.memoizedState!==i.memoizedState.memoizedState&&(e===null?e=[tp]:e.push(tp))}i=i.return}e!==null&&Wi(t,e,n,r),t.flags|=262144}function Ki(e){for(e=e.firstContext;e!==null;){if(!mr(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function qi(e){zi=e,Bi=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Ji(e){return Xi(zi,e)}function Yi(e,t){return zi===null&&qi(e),Xi(e,t)}function Xi(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},Bi===null){if(e===null)throw Error(o(308));Bi=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Bi=Bi.next=t;return n}var Zi=typeof AbortController<`u`?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},Qi=t.unstable_scheduleCallback,$i=t.unstable_NormalPriority,ea={$$typeof:S,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function ta(){return{controller:new Zi,data:new Map,refCount:0}}function na(e){e.refCount--,e.refCount===0&&Qi($i,function(){e.controller.abort()})}var ra=null,ia=0,aa=0,oa=null;function sa(e,t){if(ra===null){var n=ra=[];ia=0,aa=fd(),oa={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return ia++,t.then(ca,ca),t}function ca(){if(--ia===0&&ra!==null){oa!==null&&(oa.status=`fulfilled`);var e=ra;ra=null,aa=0,oa=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function la(e,t){var n=[],r={status:`pending`,value:null,reason:null,then:function(e){n.push(e)}};return e.then(function(){r.status=`fulfilled`,r.value=t;for(var e=0;e<n.length;e++)(0,n[e])(t)},function(e){for(r.status=`rejected`,r.reason=e,e=0;e<n.length;e++)(0,n[e])(void 0)}),r}var ua=F.S;F.S=function(e,t){eu=be(),typeof t==`object`&&t&&typeof t.then==`function`&&sa(e,t),ua!==null&&ua(e,t)};var da=z(null);function fa(){var e=da.current;return e===null?Ll.pooledCache:e}function pa(e,t){t===null?V(da,da.current):V(da,t.pool)}function ma(){var e=fa();return e===null?null:{parent:ea._currentValue,pool:e}}var ha=Error(o(460)),ga=Error(o(474)),_a=Error(o(542)),va={then:function(){}};function ya(e){return e=e.status,e===`fulfilled`||e===`rejected`}function ba(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(Kt,Kt),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,wa(e),e;default:if(typeof t.status==`string`)t.then(Kt,Kt);else{if(e=Ll,e!==null&&100<e.shellSuspendCounter)throw Error(o(482));e=t,e.status=`pending`,e.then(function(e){if(t.status===`pending`){var n=t;n.status=`fulfilled`,n.value=e}},function(e){if(t.status===`pending`){var n=t;n.status=`rejected`,n.reason=e}})}switch(t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,wa(e),e}throw Sa=t,ha}}function xa(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(Sa=e,ha):e}}var Sa=null;function Ca(){if(Sa===null)throw Error(o(459));var e=Sa;return Sa=null,e}function wa(e){if(e===ha||e===_a)throw Error(o(483))}var Ta=null,Ea=0;function Da(e){var t=Ea;return Ea+=1,Ta===null&&(Ta=[]),ba(Ta,e,t)}function Oa(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function ka(e,t){throw t.$$typeof===h?Error(o(525)):(e=Object.prototype.toString.call(t),Error(o(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e)))}function Aa(e){function t(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;r!==null;)t(n,r),r=r.sibling;return null}function r(e){for(var t=new Map;e!==null;)e.key===null?t.set(e.index,e):t.set(e.key,e),e=e.sibling;return t}function i(e,t){return e=ni(e,t),e.index=0,e.sibling=null,e}function a(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=67108866,n):(r=r.index,r<n?(t.flags|=67108866,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=67108866),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=oi(n,e.mode,r),t.return=e,t):(t=i(t,n),t.return=e,t)}function l(e,t,n,r){var a=n.type;return a===v?d(e,t,n.props.children,r,n.key):t!==null&&(t.elementType===a||typeof a==`object`&&a&&a.$$typeof===D&&xa(a)===t.type)?(t=i(t,n.props),Oa(t,n),t.return=e,t):(t=ii(n.type,n.key,n.props,null,e.mode,r),Oa(t,n),t.return=e,t)}function u(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=ci(n,e.mode,r),t.return=e,t):(t=i(t,n.children||[]),t.return=e,t)}function d(e,t,n,r,a){return t===null||t.tag!==7?(t=ai(n,e.mode,r,a),t.return=e,t):(t=i(t,n),t.return=e,t)}function f(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`||typeof t==`bigint`)return t=oi(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case g:return n=ii(t.type,t.key,t.props,null,e.mode,n),Oa(n,t),n.return=e,n;case _:return t=ci(t,e.mode,n),t.return=e,t;case D:return t=xa(t),f(e,t,n)}if(P(t)||j(t))return t=ai(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,Da(t),n);if(t.$$typeof===S)return f(e,Yi(e,t),n);ka(e,t)}return null}function p(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`||typeof n==`bigint`)return i===null?c(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case g:return n.key===i?l(e,t,n,r):null;case _:return n.key===i?u(e,t,n,r):null;case D:return n=xa(n),p(e,t,n,r)}if(P(n)||j(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,Da(n),r);if(n.$$typeof===S)return p(e,t,Yi(e,n),r);ka(e,n)}return null}function m(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`||typeof r==`bigint`)return e=e.get(n)||null,c(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case g:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case _:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case D:return r=xa(r),m(e,t,n,r,i)}if(P(r)||j(r))return e=e.get(n)||null,d(t,e,r,i,null);if(typeof r.then==`function`)return m(e,t,n,Da(r),i);if(r.$$typeof===S)return m(e,t,n,Yi(t,r),i);ka(t,r)}return null}function h(i,o,s,c){for(var l=null,u=null,d=o,h=o=0,g=null;d!==null&&h<s.length;h++){d.index>h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),o=a(_,o,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),Di&&bi(i,h),l;if(d===null){for(;h<s.length;h++)d=f(i,s[h],c),d!==null&&(o=a(d,o,h),u===null?l=d:u.sibling=d,u=d);return Di&&bi(i,h),l}for(d=r(d);h<s.length;h++)g=m(d,i,h,s[h],c),g!==null&&(e&&g.alternate!==null&&d.delete(g.key===null?h:g.key),o=a(g,o,h),u===null?l=g:u.sibling=g,u=g);return e&&d.forEach(function(e){return t(i,e)}),Di&&bi(i,h),l}function y(i,s,c,l){if(c==null)throw Error(o(151));for(var u=null,d=null,h=s,g=s=0,_=null,v=c.next();h!==null&&!v.done;g++,v=c.next()){h.index>g?(_=h,h=null):_=h.sibling;var y=p(i,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(i,h),s=a(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(i,h),Di&&bi(i,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(i,v.value,l),v!==null&&(s=a(v,s,g),d===null?u=v:d.sibling=v,d=v);return Di&&bi(i,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,i,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.key),s=a(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(i,e)}),Di&&bi(i,g),u}function b(e,r,a,c){if(typeof a==`object`&&a&&a.type===v&&a.key===null&&(a=a.props.children),typeof a==`object`&&a){switch(a.$$typeof){case g:a:{for(var l=a.key;r!==null;){if(r.key===l){if(l=a.type,l===v){if(r.tag===7){n(e,r.sibling),c=i(r,a.props.children),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===D&&xa(l)===r.type){n(e,r.sibling),c=i(r,a.props),Oa(c,a),c.return=e,e=c;break a}n(e,r);break}else t(e,r);r=r.sibling}a.type===v?(c=ai(a.props.children,e.mode,c,a.key),c.return=e,e=c):(c=ii(a.type,a.key,a.props,null,e.mode,c),Oa(c,a),c.return=e,e=c)}return s(e);case _:a:{for(l=a.key;r!==null;){if(r.key===l)if(r.tag===4&&r.stateNode.containerInfo===a.containerInfo&&r.stateNode.implementation===a.implementation){n(e,r.sibling),c=i(r,a.children||[]),c.return=e,e=c;break a}else{n(e,r);break}else t(e,r);r=r.sibling}c=ci(a,e.mode,c),c.return=e,e=c}return s(e);case D:return a=xa(a),b(e,r,a,c)}if(P(a))return h(e,r,a,c);if(j(a)){if(l=j(a),typeof l!=`function`)throw Error(o(150));return a=l.call(a),y(e,r,a,c)}if(typeof a.then==`function`)return b(e,r,Da(a),c);if(a.$$typeof===S)return b(e,r,Yi(e,a),c);ka(e,a)}return typeof a==`string`&&a!==``||typeof a==`number`||typeof a==`bigint`?(a=``+a,r!==null&&r.tag===6?(n(e,r.sibling),c=i(r,a),c.return=e,e=c):(n(e,r),c=oi(a,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{Ea=0;var i=b(e,t,n,r);return Ta=null,i}catch(t){if(t===ha||t===_a)throw t;var a=ei(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var ja=Aa(!0),Ma=Aa(!1),Na=!1;function Pa(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Fa(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Ia(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function La(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Il&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=Zr(e),Xr(e,null,n),t}return qr(e,r,t,n),Zr(e)}function Ra(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ke(e,n)}}function za(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var Ba=!1;function Va(){if(Ba){var e=oa;if(e!==null)throw e}}function Ha(e,t,n,r){Ba=!1;var i=e.updateQueue;Na=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(X&f)===f:(r&f)===f){f!==0&&f===aa&&(Ba=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var h=e,g=s;f=t;var _=n;switch(g.tag){case 1:if(h=g.payload,typeof h==`function`){d=h.call(_,d,f);break a}d=h;break a;case 3:h.flags=h.flags&-65537|128;case 0:if(h=g.payload,f=typeof h==`function`?h.call(_,d,f):h,f==null)break a;d=m({},d,f);break a;case 2:Na=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),Gl|=o,e.lanes=o,e.memoizedState=d}}function Ua(e,t){if(typeof e!=`function`)throw Error(o(191,e));e.call(t)}function Wa(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)Ua(n[e],t)}var Ga=z(null),Ka=z(0);function qa(e,t){e=Ul,V(Ka,e),V(Ga,t),Ul=e|t.baseLanes}function Ja(){V(Ka,Ul),V(Ga,Ga.current)}function Ya(){Ul=Ka.current,B(Ga),B(Ka)}var Xa=z(null),Za=null;function Qa(e){var t=e.alternate;V(ro,ro.current&1),V(Xa,e),Za===null&&(t===null||Ga.current!==null||t.memoizedState!==null)&&(Za=e)}function $a(e){V(ro,ro.current),V(Xa,e),Za===null&&(Za=e)}function eo(e){e.tag===22?(V(ro,ro.current),V(Xa,e),Za===null&&(Za=e)):to(e)}function to(){V(ro,ro.current),V(Xa,Xa.current)}function no(e){B(Xa),Za===e&&(Za=null),B(ro)}var ro=z(0);function io(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||cf(n)||lf(n)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder===`forwards`||t.memoizedProps.revealOrder===`backwards`||t.memoizedProps.revealOrder===`unstable_legacy-backwards`||t.memoizedProps.revealOrder===`together`)){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var ao=0,oo=null,so=null,co=null,lo=!1,uo=!1,fo=!1,po=0,mo=0,ho=null,go=0;function _o(){throw Error(o(321))}function vo(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!mr(e[n],t[n]))return!1;return!0}function yo(e,t,n,r,i,a){return ao=a,oo=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,F.H=e===null||e.memoizedState===null?Fs:Is,fo=!1,a=n(r,i),fo=!1,uo&&(a=xo(t,n,r,i)),bo(e),a}function bo(e){F.H=Ps;var t=so!==null&&so.next!==null;if(ao=0,co=so=oo=null,lo=!1,mo=0,ho=null,t)throw Error(o(300));e===null||$s||(e=e.dependencies,e!==null&&Ki(e)&&($s=!0))}function xo(e,t,n,r){oo=e;var i=0;do{if(uo&&(ho=null),mo=0,uo=!1,25<=i)throw Error(o(301));if(i+=1,co=so=null,e.updateQueue!=null){var a=e.updateQueue;a.lastEffect=null,a.events=null,a.stores=null,a.memoCache!=null&&(a.memoCache.index=0)}F.H=Ls,a=t(n,r)}while(uo);return a}function So(){var e=F.H,t=e.useState()[0];return t=typeof t.then==`function`?ko(t):t,e=e.useState()[0],(so===null?null:so.memoizedState)!==e&&(oo.flags|=1024),t}function Co(){var e=po!==0;return po=0,e}function wo(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function To(e){if(lo){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}lo=!1}ao=0,co=so=oo=null,uo=!1,mo=po=0,ho=null}function Eo(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return co===null?oo.memoizedState=co=e:co=co.next=e,co}function Do(){if(so===null){var e=oo.alternate;e=e===null?null:e.memoizedState}else e=so.next;var t=co===null?oo.memoizedState:co.next;if(t!==null)co=t,so=e;else{if(e===null)throw oo.alternate===null?Error(o(467)):Error(o(310));so=e,e={memoizedState:so.memoizedState,baseState:so.baseState,baseQueue:so.baseQueue,queue:so.queue,next:null},co===null?oo.memoizedState=co=e:co=co.next=e}return co}function Oo(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function ko(e){var t=mo;return mo+=1,ho===null&&(ho=[]),e=ba(ho,e,t),t=oo,(co===null?t.memoizedState:co.next)===null&&(t=t.alternate,F.H=t===null||t.memoizedState===null?Fs:Is),e}function Ao(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return ko(e);if(e.$$typeof===S)return Ji(e)}throw Error(o(438,String(e)))}function jo(e){var t=null,n=oo.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=oo.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(e){return e.slice()}),index:0})))}if(t??={data:[],index:0},n===null&&(n=Oo(),oo.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),r=0;r<e;r++)n[r]=k;return t.index++,n}function Mo(e,t){return typeof t==`function`?t(e):t}function No(e){return Po(Do(),so,e)}function Po(e,t,n){var r=e.queue;if(r===null)throw Error(o(311));r.lastRenderedReducer=n;var i=e.baseQueue,a=r.pending;if(a!==null){if(i!==null){var s=i.next;i.next=a.next,a.next=s}t.baseQueue=i=a,r.pending=null}if(a=e.baseState,i===null)e.memoizedState=a;else{t=i.next;var c=s=null,l=null,u=t,d=!1;do{var f=u.lane&-536870913;if(f===u.lane?(ao&f)===f:(X&f)===f){var p=u.revertLane;if(p===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),f===aa&&(d=!0);else if((ao&p)===p){u=u.next,p===aa&&(d=!0);continue}else f={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=f,s=a):l=l.next=f,oo.lanes|=p,Gl|=p;f=u.action,fo&&n(a,f),a=u.hasEagerState?u.eagerState:n(a,f)}else p={lane:f,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=p,s=a):l=l.next=p,oo.lanes|=f,Gl|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=a:l.next=c,!mr(a,e.memoizedState)&&($s=!0,d&&(n=oa,n!==null)))throw n;e.memoizedState=a,e.baseState=s,e.baseQueue=l,r.lastRenderedState=a}return i===null&&(r.lanes=0),[e.memoizedState,r.dispatch]}function Fo(e){var t=Do(),n=t.queue;if(n===null)throw Error(o(311));n.lastRenderedReducer=e;var r=n.dispatch,i=n.pending,a=t.memoizedState;if(i!==null){n.pending=null;var s=i=i.next;do a=e(a,s.action),s=s.next;while(s!==i);mr(a,t.memoizedState)||($s=!0),t.memoizedState=a,t.baseQueue===null&&(t.baseState=a),n.lastRenderedState=a}return[a,r]}function Io(e,t,n){var r=oo,i=Do(),a=Di;if(a){if(n===void 0)throw Error(o(407));n=n()}else n=t();var s=!mr((so||i).memoizedState,n);if(s&&(i.memoizedState=n,$s=!0),i=i.queue,ss(zo.bind(null,r,i,e),[e]),i.getSnapshot!==t||s||co!==null&&co.memoizedState.tag&1){if(r.flags|=2048,ns(9,{destroy:void 0},Ro.bind(null,r,i,n,t),null),Ll===null)throw Error(o(349));a||ao&127||Lo(r,t,n)}return n}function Lo(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=oo.updateQueue,t===null?(t=Oo(),oo.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function Ro(e,t,n,r){t.value=n,t.getSnapshot=r,Bo(t)&&Vo(e)}function zo(e,t,n){return n(function(){Bo(t)&&Vo(e)})}function Bo(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!mr(e,n)}catch{return!0}}function Vo(e){var t=Yr(e,2);t!==null&&hu(t,e,2)}function Ho(e){var t=Eo();if(typeof e==`function`){var n=e;if(e=n(),fo){ke(!0);try{n()}finally{ke(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Mo,lastRenderedState:e},t}function Uo(e,t,n,r){return e.baseState=n,Po(e,so,typeof r==`function`?r:Mo)}function Wo(e,t,n,r,i){if(js(e))throw Error(o(485));if(e=t.action,e!==null){var a={payload:i,action:e,next:null,isTransition:!0,status:`pending`,value:null,reason:null,listeners:[],then:function(e){a.listeners.push(e)}};F.T===null?a.isTransition=!1:n(!0),r(a),n=t.pending,n===null?(a.next=t.pending=a,Go(t,a)):(a.next=n.next,t.pending=n.next=a)}}function Go(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=F.T,o={};F.T=o;try{var s=n(i,r),c=F.S;c!==null&&c(o,s),Ko(e,t,s)}catch(n){Jo(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),F.T=a}}else try{a=n(i,r),Ko(e,t,a)}catch(n){Jo(e,t,n)}}function Ko(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){qo(e,t,n)},function(n){return Jo(e,t,n)}):qo(e,t,n)}function qo(e,t,n){t.status=`fulfilled`,t.value=n,Yo(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,Go(e,n)))}function Jo(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,Yo(t),t=t.next;while(t!==r)}e.action=null}function Yo(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Xo(e,t){return t}function Zo(e,t){if(Di){var n=Ll.formState;if(n!==null){a:{var r=oo;if(Di){if(Ei){b:{for(var i=Ei,a=ki;i.nodeType!==8;){if(!a){i=null;break b}if(i=df(i.nextSibling),i===null){i=null;break b}}a=i.data,i=a===`F!`||a===`F`?i:null}if(i){Ei=df(i.nextSibling),r=i.data===`F!`;break a}}ji(r)}r=!1}r&&(t=n[0])}}return n=Eo(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Xo,lastRenderedState:t},n.queue=r,n=Os.bind(null,oo,r),r.dispatch=n,r=Ho(!1),a=As.bind(null,oo,!1,r.queue),r=Eo(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=Wo.bind(null,oo,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function Qo(e){return $o(Do(),so,e)}function $o(e,t,n){if(t=Po(e,t,Xo)[0],e=No(Mo)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=ko(t)}catch(e){throw e===ha?_a:e}else r=t;t=Do();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(oo.flags|=2048,ns(9,{destroy:void 0},es.bind(null,i,n),null)),[r,a,e]}function es(e,t){e.action=t}function ts(e){var t=Do(),n=so;if(n!==null)return $o(t,n,e);Do(),t=t.memoizedState,n=Do();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function ns(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=oo.updateQueue,t===null&&(t=Oo(),oo.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function rs(){return Do().memoizedState}function is(e,t,n,r){var i=Eo();oo.flags|=e,i.memoizedState=ns(1|t,{destroy:void 0},n,r===void 0?null:r)}function as(e,t,n,r){var i=Do();r=r===void 0?null:r;var a=i.memoizedState.inst;so!==null&&r!==null&&vo(r,so.memoizedState.deps)?i.memoizedState=ns(t,a,n,r):(oo.flags|=e,i.memoizedState=ns(1|t,a,n,r))}function os(e,t){is(8390656,8,e,t)}function ss(e,t){as(2048,8,e,t)}function cs(e){oo.flags|=4;var t=oo.updateQueue;if(t===null)t=Oo(),oo.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function ls(e){var t=Do().memoizedState;return cs({ref:t,nextImpl:e}),function(){if(Il&2)throw Error(o(440));return t.impl.apply(void 0,arguments)}}function us(e,t){return as(4,2,e,t)}function ds(e,t){return as(4,4,e,t)}function fs(e,t){if(typeof t==`function`){e=e();var n=t(e);return function(){typeof n==`function`?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function K(e,t,n){n=n==null?null:n.concat([e]),as(4,4,fs.bind(null,t,e),n)}function ps(){}function ms(e,t){var n=Do();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&vo(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function hs(e,t){var n=Do();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&vo(t,r[1]))return r[0];if(r=e(),fo){ke(!0);try{e()}finally{ke(!1)}}return n.memoizedState=[r,t],r}function gs(e,t,n){return n===void 0||ao&1073741824&&!(X&261930)?e.memoizedState=t:(e.memoizedState=n,e=mu(),oo.lanes|=e,Gl|=e,n)}function _s(e,t,n,r){return mr(n,t)?n:Ga.current===null?!(ao&42)||ao&1073741824&&!(X&261930)?($s=!0,e.memoizedState=n):(e=mu(),oo.lanes|=e,Gl|=e,t):(e=gs(e,n,r),mr(e,t)||($s=!0),e)}function vs(e,t,n,r,i){var a=I.p;I.p=a!==0&&8>a?a:8;var o=F.T,s={};F.T=s,As(e,!1,t,n);try{var c=i(),l=F.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?ks(e,t,la(c,r),pu(e)):ks(e,t,r,pu(e))}catch(n){ks(e,t,{then:function(){},status:`rejected`,reason:n},pu())}finally{I.p=a,o!==null&&s.types!==null&&(o.types=s.types),F.T=o}}function ys(){}function bs(e,t,n,r){if(e.tag!==5)throw Error(o(476));var i=xs(e).queue;vs(e,i,t,L,n===null?ys:function(){return Ss(e),n(r)})}function xs(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:L,baseState:L,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Mo,lastRenderedState:L},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Mo,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Ss(e){var t=xs(e);t.next===null&&(t=e.alternate.memoizedState),ks(e,t.next.queue,{},pu())}function Cs(){return Ji(tp)}function ws(){return Do().memoizedState}function Ts(){return Do().memoizedState}function Es(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=pu();e=Ia(n);var r=La(t,e,n);r!==null&&(hu(r,t,n),Ra(r,t,n)),t={cache:ta()},e.payload=t;return}t=t.return}}function Ds(e,t,n){var r=pu();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},js(e)?Ms(t,n):(n=Jr(e,t,n,r),n!==null&&(hu(n,e,r),Ns(n,t,r)))}function Os(e,t,n){ks(e,t,n,pu())}function ks(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(js(e))Ms(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,mr(s,o))return qr(e,t,i,0),Ll===null&&Kr(),!1}catch{}if(n=Jr(e,t,i,r),n!==null)return hu(n,e,r),Ns(n,t,r),!0}return!1}function As(e,t,n,r){if(r={lane:2,revertLane:fd(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},js(e)){if(t)throw Error(o(479))}else t=Jr(e,n,r,2),t!==null&&hu(t,e,2)}function js(e){var t=e.alternate;return e===oo||t!==null&&t===oo}function Ms(e,t){uo=lo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Ns(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ke(e,n)}}var Ps={readContext:Ji,use:Ao,useCallback:_o,useContext:_o,useEffect:_o,useImperativeHandle:_o,useLayoutEffect:_o,useInsertionEffect:_o,useMemo:_o,useReducer:_o,useRef:_o,useState:_o,useDebugValue:_o,useDeferredValue:_o,useTransition:_o,useSyncExternalStore:_o,useId:_o,useHostTransitionStatus:_o,useFormState:_o,useActionState:_o,useOptimistic:_o,useMemoCache:_o,useCacheRefresh:_o};Ps.useEffectEvent=_o;var Fs={readContext:Ji,use:Ao,useCallback:function(e,t){return Eo().memoizedState=[e,t===void 0?null:t],e},useContext:Ji,useEffect:os,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),is(4194308,4,fs.bind(null,t,e),n)},useLayoutEffect:function(e,t){return is(4194308,4,e,t)},useInsertionEffect:function(e,t){is(4,2,e,t)},useMemo:function(e,t){var n=Eo();t=t===void 0?null:t;var r=e();if(fo){ke(!0);try{e()}finally{ke(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=Eo();if(n!==void 0){var i=n(t);if(fo){ke(!0);try{n(t)}finally{ke(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=Ds.bind(null,oo,e),[r.memoizedState,e]},useRef:function(e){var t=Eo();return e={current:e},t.memoizedState=e},useState:function(e){e=Ho(e);var t=e.queue,n=Os.bind(null,oo,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:ps,useDeferredValue:function(e,t){return gs(Eo(),e,t)},useTransition:function(){var e=Ho(!1);return e=vs.bind(null,oo,e.queue,!0,!1),Eo().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=oo,i=Eo();if(Di){if(n===void 0)throw Error(o(407));n=n()}else{if(n=t(),Ll===null)throw Error(o(349));X&127||Lo(r,t,n)}i.memoizedState=n;var a={value:n,getSnapshot:t};return i.queue=a,os(zo.bind(null,r,a,e),[e]),r.flags|=2048,ns(9,{destroy:void 0},Ro.bind(null,r,a,n,t),null),n},useId:function(){var e=Eo(),t=Ll.identifierPrefix;if(Di){var n=yi,r=vi;n=(r&~(1<<32-Ae(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=po++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=go++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:Cs,useFormState:Zo,useActionState:Zo,useOptimistic:function(e){var t=Eo();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=As.bind(null,oo,!0,n),n.dispatch=t,[e,t]},useMemoCache:jo,useCacheRefresh:function(){return Eo().memoizedState=Es.bind(null,oo)},useEffectEvent:function(e){var t=Eo(),n={impl:e};return t.memoizedState=n,function(){if(Il&2)throw Error(o(440));return n.impl.apply(void 0,arguments)}}},Is={readContext:Ji,use:Ao,useCallback:ms,useContext:Ji,useEffect:ss,useImperativeHandle:K,useInsertionEffect:us,useLayoutEffect:ds,useMemo:hs,useReducer:No,useRef:rs,useState:function(){return No(Mo)},useDebugValue:ps,useDeferredValue:function(e,t){return _s(Do(),so.memoizedState,e,t)},useTransition:function(){var e=No(Mo)[0],t=Do().memoizedState;return[typeof e==`boolean`?e:ko(e),t]},useSyncExternalStore:Io,useId:ws,useHostTransitionStatus:Cs,useFormState:Qo,useActionState:Qo,useOptimistic:function(e,t){return Uo(Do(),so,e,t)},useMemoCache:jo,useCacheRefresh:Ts};Is.useEffectEvent=ls;var Ls={readContext:Ji,use:Ao,useCallback:ms,useContext:Ji,useEffect:ss,useImperativeHandle:K,useInsertionEffect:us,useLayoutEffect:ds,useMemo:hs,useReducer:Fo,useRef:rs,useState:function(){return Fo(Mo)},useDebugValue:ps,useDeferredValue:function(e,t){var n=Do();return so===null?gs(n,e,t):_s(n,so.memoizedState,e,t)},useTransition:function(){var e=Fo(Mo)[0],t=Do().memoizedState;return[typeof e==`boolean`?e:ko(e),t]},useSyncExternalStore:Io,useId:ws,useHostTransitionStatus:Cs,useFormState:ts,useActionState:ts,useOptimistic:function(e,t){var n=Do();return so===null?(n.baseState=e,[e,n.queue.dispatch]):Uo(n,so,e,t)},useMemoCache:jo,useCacheRefresh:Ts};Ls.useEffectEvent=ls;function Rs(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:m({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var zs={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=pu(),i=Ia(r);i.payload=t,n!=null&&(i.callback=n),t=La(e,i,r),t!==null&&(hu(t,e,r),Ra(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=pu(),i=Ia(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=La(e,i,r),t!==null&&(hu(t,e,r),Ra(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=pu(),r=Ia(n);r.tag=2,t!=null&&(r.callback=t),t=La(e,r,n),t!==null&&(hu(t,e,n),Ra(t,e,n))}};function Bs(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!hr(n,r)||!hr(i,a):!0}function Vs(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&zs.enqueueReplaceState(t,t.state,null)}function Hs(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=m({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function Us(e){Hr(e)}function Ws(e){console.error(e)}function Gs(e){Hr(e)}function Ks(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function qs(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function Js(e,t,n){return n=Ia(n),n.tag=3,n.payload={element:null},n.callback=function(){Ks(e,t)},n}function Ys(e){return e=Ia(e),e.tag=3,e}function Xs(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){qs(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){qs(t,n,r),typeof i!=`function`&&(ru===null?ru=new Set([this]):ru.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function Zs(e,t,n,r,i){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&Gi(t,n,i,!0),n=Xa.current,n!==null){switch(n.tag){case 31:case 13:return Za===null?Du():n.alternate===null&&Wl===0&&(Wl=3),n.flags&=-257,n.flags|=65536,n.lanes=i,r===va?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),Ku(e,r,i)),!1;case 22:return n.flags|=65536,r===va?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([r]):n.add(r)),Ku(e,r,i)),!1}throw Error(o(435,n.tag))}return Ku(e,r,i),Du(),!1}if(Di)return t=Xa.current,t===null?(r!==Ai&&(t=Error(o(423),{cause:r}),Li(ui(t,n))),e=e.current.alternate,e.flags|=65536,i&=-i,e.lanes|=i,r=ui(r,n),i=Js(e.stateNode,r,i),za(e,i),Wl!==4&&(Wl=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=i,r!==Ai&&(e=Error(o(422),{cause:r}),Li(ui(e,n)))),!1;var a=Error(o(520),{cause:r});if(a=ui(a,n),Xl===null?Xl=[a]:Xl.push(a),Wl!==4&&(Wl=2),t===null)return!0;r=ui(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=i&-i,n.lanes|=e,e=Js(n.stateNode,r,e),za(n,e),!1;case 1:if(t=n.type,a=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||a!==null&&typeof a.componentDidCatch==`function`&&(ru===null||!ru.has(a))))return n.flags|=65536,i&=-i,n.lanes|=i,i=Ys(i),Xs(i,e,n,r),za(n,i),!1}n=n.return}while(n!==null);return!1}var Qs=Error(o(461)),$s=!1;function ec(e,t,n,r){t.child=e===null?Ma(t,null,n,r):ja(t,e.child,n,r)}function tc(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return qi(t),r=yo(e,t,n,o,a,i),s=Co(),e!==null&&!$s?(wo(e,t,i),Tc(e,t,i)):(Di&&s&&Si(t),t.flags|=1,ec(e,t,r,i),t.child)}function nc(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!ti(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,rc(e,t,a,r,i)):(e=ii(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!Ec(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?hr:n,n(o,r)&&e.ref===t.ref)return Tc(e,t,i)}return t.flags|=1,e=ni(a,r),e.ref=t.ref,e.return=t,t.child=e}function rc(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(hr(a,r)&&e.ref===t.ref)if($s=!1,t.pendingProps=r=a,Ec(e,i))e.flags&131072&&($s=!0);else return t.lanes=e.lanes,Tc(e,t,i)}return dc(e,t,n,r,i)}function ic(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return oc(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&pa(t,a===null?null:a.cachePool),a===null?Ja():qa(t,a),eo(t);else return r=t.lanes=536870912,oc(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&pa(t,null),Ja(),to(t)):(pa(t,a.cachePool),qa(t,a),to(t),t.memoizedState=null);return ec(e,t,i,n),t.child}function ac(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function oc(e,t,n,r,i){var a=fa();return a=a===null?null:{parent:ea._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&pa(t,null),Ja(),eo(t),e!==null&&Gi(e,t,r,!0),t.childLanes=i,null}function sc(e,t){return t=bc({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function cc(e,t,n){return ja(t,e.child,null,n),e=sc(t,t.pendingProps),e.flags|=2,no(t),t.memoizedState=null,e}function lc(e,t,n){var r=t.pendingProps,i=(t.flags&128)!=0;if(t.flags&=-129,e===null){if(Di){if(r.mode===`hidden`)return e=sc(t,r),t.lanes=536870912,ac(null,e);if($a(t),(e=Ei)?(e=sf(e,ki),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:_i===null?null:{id:vi,overflow:yi},retryLane:536870912,hydrationErrors:null},n=si(e),n.return=t,t.child=n,Ti=t,Ei=null)):e=null,e===null)throw ji(t);return t.lanes=536870912,null}return sc(t,r)}var a=e.memoizedState;if(a!==null){var s=a.dehydrated;if($a(t),i)if(t.flags&256)t.flags&=-257,t=cc(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(o(558));else if($s||Gi(e,t,n,!1),i=(n&e.childLanes)!==0,$s||i){if(r=Ll,r!==null&&(s=qe(r,n),s!==0&&s!==a.retryLane))throw a.retryLane=s,Yr(e,s),hu(r,e,s),Qs;Du(),t=cc(e,t,n)}else e=a.treeContext,Ei=df(s.nextSibling),Ti=t,Di=!0,Oi=null,ki=!1,e!==null&&wi(t,e),t=sc(t,r),t.flags|=4096;return t}return e=ni(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function uc(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(o(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function dc(e,t,n,r,i){return qi(t),n=yo(e,t,n,r,void 0,i),r=Co(),e!==null&&!$s?(wo(e,t,i),Tc(e,t,i)):(Di&&r&&Si(t),t.flags|=1,ec(e,t,n,i),t.child)}function fc(e,t,n,r,i,a){return qi(t),t.updateQueue=null,n=xo(t,r,n,i),bo(e),r=Co(),e!==null&&!$s?(wo(e,t,a),Tc(e,t,a)):(Di&&r&&Si(t),t.flags|=1,ec(e,t,n,a),t.child)}function pc(e,t,n,r,i){if(qi(t),t.stateNode===null){var a=Qr,o=n.contextType;typeof o==`object`&&o&&(a=Ji(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=zs,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},Pa(t),o=n.contextType,a.context=typeof o==`object`&&o?Ji(o):Qr,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(Rs(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&zs.enqueueReplaceState(a,a.state,null),Ha(t,r,a,i),Va(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=Hs(n,s);a.props=c;var l=a.context,u=n.contextType;o=Qr,typeof u==`object`&&u&&(o=Ji(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&Vs(t,a,r,o),Na=!1;var f=t.memoizedState;a.state=f,Ha(t,r,a,i),Va(),l=t.memoizedState,s||f!==l||Na?(typeof d==`function`&&(Rs(t,n,d,r),l=t.memoizedState),(c=Na||Bs(t,n,c,r,f,l,o))?(u||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount==`function`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,Fa(e,t),o=t.memoizedProps,u=Hs(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=Qr,typeof l==`object`&&l&&(c=Ji(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&Vs(t,a,r,c),Na=!1,f=t.memoizedState,a.state=f,Ha(t,r,a,i),Va();var p=t.memoizedState;o!==d||f!==p||Na||e!==null&&e.dependencies!==null&&Ki(e.dependencies)?(typeof s==`function`&&(Rs(t,n,s,r),p=t.memoizedState),(u=Na||Bs(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&Ki(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,uc(e,t),r=(t.flags&128)!=0,a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=ja(t,e.child,null,i),t.child=ja(t,null,n,i)):ec(e,t,n,i),t.memoizedState=a.state,e=t.child):e=Tc(e,t,i),e}function mc(e,t,n,r){return Fi(),t.flags|=256,ec(e,t,n,r),t.child}var hc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function gc(e){return{baseLanes:e,cachePool:ma()}}function _c(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=Jl),e}function vc(e,t,n){var r=t.pendingProps,i=!1,a=(t.flags&128)!=0,s;if((s=a)||(s=e!==null&&e.memoizedState===null?!1:(ro.current&2)!=0),s&&(i=!0,t.flags&=-129),s=(t.flags&32)!=0,t.flags&=-33,e===null){if(Di){if(i?Qa(t):to(t),(e=Ei)?(e=sf(e,ki),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:_i===null?null:{id:vi,overflow:yi},retryLane:536870912,hydrationErrors:null},n=si(e),n.return=t,t.child=n,Ti=t,Ei=null)):e=null,e===null)throw ji(t);return lf(e)?t.lanes=32:t.lanes=536870912,null}var c=r.children;return r=r.fallback,i?(to(t),i=t.mode,c=bc({mode:`hidden`,children:c},i),r=ai(r,i,n,null),c.return=t,r.return=t,c.sibling=r,t.child=c,r=t.child,r.memoizedState=gc(n),r.childLanes=_c(e,s,n),t.memoizedState=hc,ac(null,r)):(Qa(t),yc(t,c))}var l=e.memoizedState;if(l!==null&&(c=l.dehydrated,c!==null)){if(a)t.flags&256?(Qa(t),t.flags&=-257,t=xc(e,t,n)):t.memoizedState===null?(to(t),c=r.fallback,i=t.mode,r=bc({mode:`visible`,children:r.children},i),c=ai(c,i,n,null),c.flags|=2,r.return=t,c.return=t,r.sibling=c,t.child=r,ja(t,e.child,null,n),r=t.child,r.memoizedState=gc(n),r.childLanes=_c(e,s,n),t.memoizedState=hc,t=ac(null,r)):(to(t),t.child=e.child,t.flags|=128,t=null);else if(Qa(t),lf(c)){if(s=c.nextSibling&&c.nextSibling.dataset,s)var u=s.dgst;s=u,r=Error(o(419)),r.stack=``,r.digest=s,Li({value:r,source:null,stack:null}),t=xc(e,t,n)}else if($s||Gi(e,t,n,!1),s=(n&e.childLanes)!==0,$s||s){if(s=Ll,s!==null&&(r=qe(s,n),r!==0&&r!==l.retryLane))throw l.retryLane=r,Yr(e,r),hu(s,e,r),Qs;cf(c)||Du(),t=xc(e,t,n)}else cf(c)?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,Ei=df(c.nextSibling),Ti=t,Di=!0,Oi=null,ki=!1,e!==null&&wi(t,e),t=yc(t,r.children),t.flags|=4096);return t}return i?(to(t),c=r.fallback,i=t.mode,l=e.child,u=l.sibling,r=ni(l,{mode:`hidden`,children:r.children}),r.subtreeFlags=l.subtreeFlags&65011712,u===null?(c=ai(c,i,n,null),c.flags|=2):c=ni(u,c),c.return=t,r.return=t,r.sibling=c,t.child=r,ac(null,r),r=t.child,c=e.child.memoizedState,c===null?c=gc(n):(i=c.cachePool,i===null?i=ma():(l=ea._currentValue,i=i.parent===l?i:{parent:l,pool:l}),c={baseLanes:c.baseLanes|n,cachePool:i}),r.memoizedState=c,r.childLanes=_c(e,s,n),t.memoizedState=hc,ac(e.child,r)):(Qa(t),n=e.child,e=n.sibling,n=ni(n,{mode:`visible`,children:r.children}),n.return=t,n.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=n,t.memoizedState=null,n)}function yc(e,t){return t=bc({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function bc(e,t){return e=ei(22,e,null,t),e.lanes=0,e}function xc(e,t,n){return ja(t,e.child,null,n),e=yc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Sc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Ui(e.return,t,n)}function Cc(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function wc(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=ro.current,s=(o&2)!=0;if(s?(o=o&1|2,t.flags|=128):o&=1,V(ro,o),ec(e,t,r,n),r=Di?mi:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Sc(e,n,t);else if(e.tag===19)Sc(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`forwards`:for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&io(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),Cc(t,!1,i,n,a,r);break;case`backwards`:case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&io(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}Cc(t,!0,n,null,a,r);break;case`together`:Cc(t,!1,null,null,void 0,r);break;default:t.memoizedState=null}return t.child}function Tc(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Gl|=t.lanes,(n&t.childLanes)===0)if(e!==null){if(Gi(e,t,n,!1),(n&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(o(153));if(t.child!==null){for(e=t.child,n=ni(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=ni(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Ec(e,t){return(e.lanes&t)===0?(e=e.dependencies,!!(e!==null&&Ki(e))):!0}function Dc(e,t,n){switch(t.tag){case 3:ae(t,t.stateNode.containerInfo),Vi(t,ea,e.memoizedState.cache),Fi();break;case 27:case 5:se(t);break;case 4:ae(t,t.stateNode.containerInfo);break;case 10:Vi(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,$a(t),null;break;case 13:var r=t.memoizedState;if(r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?(Qa(t),e=Tc(e,t,n),e===null?null:e.sibling):vc(e,t,n):(Qa(t),t.flags|=128,null);Qa(t);break;case 19:var i=(e.flags&128)!=0;if(r=(n&t.childLanes)!==0,r||=(Gi(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return wc(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),V(ro,ro.current),r)break;return null;case 22:return t.lanes=0,ic(e,t,n,t.pendingProps);case 24:Vi(t,ea,e.memoizedState.cache)}return Tc(e,t,n)}function Oc(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps)$s=!0;else{if(!Ec(e,n)&&!(t.flags&128))return $s=!1,Dc(e,t,n);$s=!!(e.flags&131072)}else $s=!1,Di&&t.flags&1048576&&xi(t,mi,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=xa(t.elementType),t.type=e,typeof e==`function`)ti(e)?(r=Hs(e,r),t.tag=1,t=pc(null,t,e,r,n)):(t.tag=0,t=dc(null,t,e,r,n));else{if(e!=null){var i=e.$$typeof;if(i===C){t.tag=11,t=tc(null,t,e,r,n);break a}else if(i===E){t.tag=14,t=nc(null,t,e,r,n);break a}}throw t=N(e)||e,Error(o(306,t,``))}}return t;case 0:return dc(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,i=Hs(r,t.pendingProps),pc(e,t,r,i,n);case 3:a:{if(ae(t,t.stateNode.containerInfo),e===null)throw Error(o(387));r=t.pendingProps;var a=t.memoizedState;i=a.element,Fa(e,t),Ha(t,r,null,n);var s=t.memoizedState;if(r=s.cache,Vi(t,ea,r),r!==a.cache&&Wi(t,[ea],n,!0),Va(),r=s.element,a.isDehydrated)if(a={element:r,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=a,t.memoizedState=a,t.flags&256){t=mc(e,t,r,n);break a}else if(r!==i){i=ui(Error(o(424)),t),Li(i),t=mc(e,t,r,n);break a}else{switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName===`HTML`?e.ownerDocument.body:e}for(Ei=df(e.firstChild),Ti=t,Di=!0,Oi=null,ki=!0,n=Ma(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(Fi(),r===i){t=Tc(e,t,n);break a}ec(e,t,r,n)}t=t.child}return t;case 26:return uc(e,t),e===null?(n=Mf(t.type,null,t.pendingProps,null))?t.memoizedState=n:Di||(n=t.type,e=t.pendingProps,r=Ud(re.current).createElement(n),r[$e]=t,r[et]=e,Ld(r,n,e),ft(r),t.stateNode=r):t.memoizedState=Mf(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return se(t),e===null&&Di&&(r=t.stateNode=hf(t.type,t.pendingProps,re.current),Ti=t,ki=!0,i=Ei,ef(t.type)?(ff=i,Ei=df(r.firstChild)):Ei=i),ec(e,t,t.pendingProps.children,n),uc(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&Di&&((i=r=Ei)&&(r=af(r,t.type,t.pendingProps,ki),r===null?i=!1:(t.stateNode=r,Ti=t,Ei=df(r.firstChild),ki=!1,i=!0)),i||ji(t)),se(t),i=t.type,a=t.pendingProps,s=e===null?null:e.memoizedProps,r=a.children,Kd(i,a)?r=null:s!==null&&Kd(i,s)&&(t.flags|=32),t.memoizedState!==null&&(i=yo(e,t,So,null,null,n),tp._currentValue=i),uc(e,t),ec(e,t,r,n),t.child;case 6:return e===null&&Di&&((e=n=Ei)&&(n=of(n,t.pendingProps,ki),n===null?e=!1:(t.stateNode=n,Ti=t,Ei=null,e=!0)),e||ji(t)),null;case 13:return vc(e,t,n);case 4:return ae(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=ja(t,null,r,n):ec(e,t,r,n),t.child;case 11:return tc(e,t,t.type,t.pendingProps,n);case 7:return ec(e,t,t.pendingProps,n),t.child;case 8:return ec(e,t,t.pendingProps.children,n),t.child;case 12:return ec(e,t,t.pendingProps.children,n),t.child;case 10:return r=t.pendingProps,Vi(t,t.type,r.value),ec(e,t,r.children,n),t.child;case 9:return i=t.type._context,r=t.pendingProps.children,qi(t),i=Ji(i),r=r(i),t.flags|=1,ec(e,t,r,n),t.child;case 14:return nc(e,t,t.type,t.pendingProps,n);case 15:return rc(e,t,t.type,t.pendingProps,n);case 19:return wc(e,t,n);case 31:return lc(e,t,n);case 22:return ic(e,t,n,t.pendingProps);case 24:return qi(t),r=Ji(ea),e===null?(i=fa(),i===null&&(i=Ll,a=ta(),i.pooledCache=a,a.refCount++,a!==null&&(i.pooledCacheLanes|=n),i=a),t.memoizedState={parent:r,cache:i},Pa(t),Vi(t,ea,i)):((e.lanes&n)!==0&&(Fa(e,t),Ha(t,null,null,n),Va()),i=e.memoizedState,a=t.memoizedState,i.parent===r?(r=a.cache,Vi(t,ea,r),r!==i.cache&&Wi(t,[ea],n,!0)):(i={parent:r,cache:r},t.memoizedState=i,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=i),Vi(t,ea,r))),ec(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(o(156,t.tag))}function kc(e){e.flags|=4}function Ac(e,t,n,r,i){if((t=(e.mode&32)!=0)&&(t=!1),t){if(e.flags|=16777216,(i&335544128)===i)if(e.stateNode.complete)e.flags|=8192;else if(wu())e.flags|=8192;else throw Sa=va,ga}else e.flags&=-16777217}function jc(e,t){if(t.type!==`stylesheet`||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!qf(t))if(wu())e.flags|=8192;else throw Sa=va,ga}function Mc(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:Ve(),e.lanes|=t,Yl|=t)}function Nc(e,t){if(!Di)switch(e.tailMode){case`hidden`:t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case`collapsed`:n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Pc(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&65011712,r|=i.flags&65011712,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function Fc(e,t,n){var r=t.pendingProps;switch(Ci(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Pc(t),null;case 1:return Pc(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),Hi(ea),oe(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(Pi(t)?kc(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Ii())),Pc(t),null;case 26:var i=t.type,a=t.memoizedState;return e===null?(kc(t),a===null?(Pc(t),Ac(t,i,null,r,n)):(Pc(t),jc(t,a))):a?a===e.memoizedState?(Pc(t),t.flags&=-16777217):(kc(t),Pc(t),jc(t,a)):(e=e.memoizedProps,e!==r&&kc(t),Pc(t),Ac(t,i,e,r,n)),null;case 27:if(ce(t),n=re.current,i=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&kc(t);else{if(!r){if(t.stateNode===null)throw Error(o(166));return Pc(t),null}e=te.current,Pi(t)?Mi(t,e):(e=hf(i,r,n),t.stateNode=e,kc(t))}return Pc(t),null;case 5:if(ce(t),i=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&kc(t);else{if(!r){if(t.stateNode===null)throw Error(o(166));return Pc(t),null}if(a=te.current,Pi(t))Mi(t,a);else{var s=Ud(re.current);switch(a){case 1:a=s.createElementNS(`http://www.w3.org/2000/svg`,i);break;case 2:a=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,i);break;default:switch(i){case`svg`:a=s.createElementNS(`http://www.w3.org/2000/svg`,i);break;case`math`:a=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,i);break;case`script`:a=s.createElement(`div`),a.innerHTML=`<script><\/script>`,a=a.removeChild(a.firstChild);break;case`select`:a=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?a.multiple=!0:r.size&&(a.size=r.size);break;default:a=typeof r.is==`string`?s.createElement(i,{is:r.is}):s.createElement(i)}}a[$e]=t,a[et]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)a.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=a;a:switch(Ld(a,i,r),i){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&kc(t)}}return Pc(t),Ac(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&kc(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(o(166));if(e=re.current,Pi(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,i=Ti,i!==null)switch(i.tag){case 27:case 5:r=i.memoizedProps}e[$e]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||Pd(e.nodeValue,n)),e||ji(t,!0)}else e=Ud(e).createTextNode(r),e[$e]=t,t.stateNode=e}return Pc(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=Pi(t),n!==null){if(e===null){if(!r)throw Error(o(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(o(557));e[$e]=t}else Fi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Pc(t),e=!1}else n=Ii(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(no(t),t):(no(t),null);if(t.flags&128)throw Error(o(558))}return Pc(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(i=Pi(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(o(318));if(i=t.memoizedState,i=i===null?null:i.dehydrated,!i)throw Error(o(317));i[$e]=t}else Fi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Pc(t),i=!1}else i=Ii(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=i),i=!0;if(!i)return t.flags&256?(no(t),t):(no(t),null)}return no(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,i=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(i=r.alternate.memoizedState.cachePool.pool),a=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(a=r.memoizedState.cachePool.pool),a!==i&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Mc(t,t.updateQueue),Pc(t),null);case 4:return oe(),e===null&&wd(t.stateNode.containerInfo),Pc(t),null;case 10:return Hi(t.type),Pc(t),null;case 19:if(B(ro),r=t.memoizedState,r===null)return Pc(t),null;if(i=(t.flags&128)!=0,a=r.rendering,a===null)if(i)Nc(r,!1);else{if(Wl!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=io(e),a!==null){for(t.flags|=128,Nc(r,!1),e=a.updateQueue,t.updateQueue=e,Mc(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)ri(n,e),n=n.sibling;return V(ro,ro.current&1|2),Di&&bi(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&be()>tu&&(t.flags|=128,i=!0,Nc(r,!1),t.lanes=4194304)}else{if(!i)if(e=io(a),e!==null){if(t.flags|=128,i=!0,e=e.updateQueue,t.updateQueue=e,Mc(t,e),Nc(r,!0),r.tail===null&&r.tailMode===`hidden`&&!a.alternate&&!Di)return Pc(t),null}else 2*be()-r.renderingStartTime>tu&&n!==536870912&&(t.flags|=128,i=!0,Nc(r,!1),t.lanes=4194304);r.isBackwards?(a.sibling=t.child,t.child=a):(e=r.last,e===null?t.child=a:e.sibling=a,r.last=a)}return r.tail===null?(Pc(t),null):(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=be(),e.sibling=null,n=ro.current,V(ro,i?n&1|2:n&1),Di&&bi(t,r.treeForkCount),e);case 22:case 23:return no(t),Ya(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(Pc(t),t.subtreeFlags&6&&(t.flags|=8192)):Pc(t),n=t.updateQueue,n!==null&&Mc(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&B(da),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Hi(ea),Pc(t),null;case 25:return null;case 30:return null}throw Error(o(156,t.tag))}function Ic(e,t){switch(Ci(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Hi(ea),oe(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return ce(t),null;case 31:if(t.memoizedState!==null){if(no(t),t.alternate===null)throw Error(o(340));Fi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(no(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(o(340));Fi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return B(ro),null;case 4:return oe(),null;case 10:return Hi(t.type),null;case 22:case 23:return no(t),Ya(),e!==null&&B(da),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Hi(ea),null;case 25:return null;default:return null}}function Lc(e,t){switch(Ci(t),t.tag){case 3:Hi(ea),oe();break;case 26:case 27:case 5:ce(t);break;case 4:oe();break;case 31:t.memoizedState!==null&&no(t);break;case 13:no(t);break;case 19:B(ro);break;case 10:Hi(t.type);break;case 22:case 23:no(t),Ya(),e!==null&&B(da);break;case 24:Hi(ea)}}function Rc(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){Gu(t,t.return,e)}}function zc(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){Gu(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Gu(t,t.return,e)}}function Bc(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{Wa(t,n)}catch(t){Gu(e,e.return,t)}}}function Vc(e,t,n){n.props=Hs(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Gu(e,t,n)}}function Hc(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Gu(e,t,n)}}function Uc(e,t){var n=e.ref,r=e.refCleanup;if(n!==null)if(typeof r==`function`)try{r()}catch(n){Gu(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){Gu(e,t,n)}else n.current=null}function Wc(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){Gu(e,e.return,t)}}function Gc(e,t,n){try{var r=e.stateNode;Rd(r,e.type,n,t),r[et]=t}catch(t){Gu(e,e.return,t)}}function Kc(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&ef(e.type)||e.tag===4}function qc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Kc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&ef(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Jc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Kt));else if(r!==4&&(r===27&&ef(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(Jc(e,t,n),e=e.sibling;e!==null;)Jc(e,t,n),e=e.sibling}function Yc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(r===27&&ef(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(Yc(e,t,n),e=e.sibling;e!==null;)Yc(e,t,n),e=e.sibling}function Xc(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);Ld(t,r,n),t[$e]=e,t[et]=n}catch(t){Gu(e,e.return,t)}}var Zc=!1,Qc=!1,$c=!1,el=typeof WeakSet==`function`?WeakSet:Set,q=null;function tl(e,t){if(e=e.containerInfo,Vd=up,e=yr(e),br(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var i=r.anchorOffset,a=r.focusNode;r=r.focusOffset;try{n.nodeType,a.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||i!==0&&f.nodeType!==3||(c=s+i),f!==a||r!==0&&f.nodeType!==3||(l=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===i&&(c=s),p===a&&++d===r&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(Hd={focusedElem:e,selectionRange:n},up=!1,q=t;q!==null;)if(t=q,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,q=e;else for(;q!==null;){switch(t=q,a=t.alternate,e=t.flags,t.tag){case 0:if(e&4&&(e=t.updateQueue,e=e===null?null:e.events,e!==null))for(n=0;n<e.length;n++)i=e[n],i.ref.impl=i.nextImpl;break;case 11:case 15:break;case 1:if(e&1024&&a!==null){e=void 0,n=t,i=a.memoizedProps,a=a.memoizedState,r=n.stateNode;try{var h=Hs(n.type,i);e=r.getSnapshotBeforeUpdate(h,a),r.__reactInternalSnapshotBeforeUpdate=e}catch(e){Gu(n,n.return,e)}}break;case 3:if(e&1024){if(e=t.stateNode.containerInfo,n=e.nodeType,n===9)rf(e);else if(n===1)switch(e.nodeName){case`HEAD`:case`HTML`:case`BODY`:rf(e);break;default:e.textContent=``}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if(e&1024)throw Error(o(163))}if(e=t.sibling,e!==null){e.return=t.return,q=e;break}q=t.return}}function nl(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:_l(e,n),r&4&&Rc(5,n);break;case 1:if(_l(e,n),r&4)if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){Gu(n,n.return,e)}else{var i=Hs(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){Gu(n,n.return,e)}}r&64&&Bc(n),r&512&&Hc(n,n.return);break;case 3:if(_l(e,n),r&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{Wa(e,t)}catch(e){Gu(n,n.return,e)}}break;case 27:t===null&&r&4&&Xc(n);case 26:case 5:_l(e,n),t===null&&r&4&&Wc(n),r&512&&Hc(n,n.return);break;case 12:_l(e,n);break;case 31:_l(e,n),r&4&&cl(e,n);break;case 13:_l(e,n),r&4&&ll(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=Yu.bind(null,n),uf(e,n))));break;case 22:if(r=n.memoizedState!==null||Zc,!r){t=t!==null&&t.memoizedState!==null||Qc,i=Zc;var a=Qc;Zc=r,(Qc=t)&&!a?yl(e,n,(n.subtreeFlags&8772)!=0):_l(e,n),Zc=i,Qc=a}break;case 30:break;default:_l(e,n)}}function rl(e){var t=e.alternate;t!==null&&(e.alternate=null,rl(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&st(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var il=null,al=!1;function ol(e,t,n){for(n=n.child;n!==null;)sl(e,t,n),n=n.sibling}function sl(e,t,n){if(Oe&&typeof Oe.onCommitFiberUnmount==`function`)try{Oe.onCommitFiberUnmount(De,n)}catch{}switch(n.tag){case 26:Qc||Uc(n,t),ol(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:Qc||Uc(n,t);var r=il,i=al;ef(n.type)&&(il=n.stateNode,al=!1),ol(e,t,n),gf(n.stateNode),il=r,al=i;break;case 5:Qc||Uc(n,t);case 6:if(r=il,i=al,il=null,ol(e,t,n),il=r,al=i,il!==null)if(al)try{(il.nodeType===9?il.body:il.nodeName===`HTML`?il.ownerDocument.body:il).removeChild(n.stateNode)}catch(e){Gu(n,t,e)}else try{il.removeChild(n.stateNode)}catch(e){Gu(n,t,e)}break;case 18:il!==null&&(al?(e=il,tf(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),Ip(e)):tf(il,n.stateNode));break;case 4:r=il,i=al,il=n.stateNode.containerInfo,al=!0,ol(e,t,n),il=r,al=i;break;case 0:case 11:case 14:case 15:zc(2,n,t),Qc||zc(4,n,t),ol(e,t,n);break;case 1:Qc||(Uc(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&Vc(n,t,r)),ol(e,t,n);break;case 21:ol(e,t,n);break;case 22:Qc=(r=Qc)||n.memoizedState!==null,ol(e,t,n),Qc=r;break;default:ol(e,t,n)}}function cl(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Ip(e)}catch(e){Gu(t,t.return,e)}}}function ll(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Ip(e)}catch(e){Gu(t,t.return,e)}}function ul(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new el),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new el),t;default:throw Error(o(435,e.tag))}}function dl(e,t){var n=ul(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=Xu.bind(null,e,t);t.then(r,r)}})}function fl(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r],a=e,s=t,c=s;a:for(;c!==null;){switch(c.tag){case 27:if(ef(c.type)){il=c.stateNode,al=!1;break a}break;case 5:il=c.stateNode,al=!1;break a;case 3:case 4:il=c.stateNode.containerInfo,al=!0;break a}c=c.return}if(il===null)throw Error(o(160));sl(a,s,i),il=null,al=!1,a=i.alternate,a!==null&&(a.return=null),i.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)ml(t,e),t=t.sibling}var pl=null;function ml(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:fl(t,e),hl(e),r&4&&(zc(3,e,e.return),Rc(3,e),zc(5,e,e.return));break;case 1:fl(t,e),hl(e),r&512&&(Qc||n===null||Uc(n,n.return)),r&64&&Zc&&(e=e.updateQueue,e!==null&&(r=e.callbacks,r!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?r:n.concat(r))));break;case 26:var i=pl;if(fl(t,e),hl(e),r&512&&(Qc||n===null||Uc(n,n.return)),r&4){var a=n===null?null:n.memoizedState;if(r=e.memoizedState,n===null)if(r===null)if(e.stateNode===null){a:{r=e.type,n=e.memoizedProps,i=i.ownerDocument||i;b:switch(r){case`title`:a=i.getElementsByTagName(`title`)[0],(!a||a[ot]||a[$e]||a.namespaceURI===`http://www.w3.org/2000/svg`||a.hasAttribute(`itemprop`))&&(a=i.createElement(r),i.head.insertBefore(a,i.querySelector(`head > title`))),Ld(a,r,n),a[$e]=e,ft(a),r=a;break a;case`link`:var s=Wf(`link`,`href`,i).get(r+(n.href||``));if(s){for(var c=0;c<s.length;c++)if(a=s[c],a.getAttribute(`href`)===(n.href==null||n.href===``?null:n.href)&&a.getAttribute(`rel`)===(n.rel==null?null:n.rel)&&a.getAttribute(`title`)===(n.title==null?null:n.title)&&a.getAttribute(`crossorigin`)===(n.crossOrigin==null?null:n.crossOrigin)){s.splice(c,1);break b}}a=i.createElement(r),Ld(a,r,n),i.head.appendChild(a);break;case`meta`:if(s=Wf(`meta`,`content`,i).get(r+(n.content||``))){for(c=0;c<s.length;c++)if(a=s[c],a.getAttribute(`content`)===(n.content==null?null:``+n.content)&&a.getAttribute(`name`)===(n.name==null?null:n.name)&&a.getAttribute(`property`)===(n.property==null?null:n.property)&&a.getAttribute(`http-equiv`)===(n.httpEquiv==null?null:n.httpEquiv)&&a.getAttribute(`charset`)===(n.charSet==null?null:n.charSet)){s.splice(c,1);break b}}a=i.createElement(r),Ld(a,r,n),i.head.appendChild(a);break;default:throw Error(o(468,r))}a[$e]=e,ft(a),r=a}e.stateNode=r}else Gf(i,e.type,e.stateNode);else e.stateNode=zf(i,r,e.memoizedProps);else a===r?r===null&&e.stateNode!==null&&Gc(e,e.memoizedProps,n.memoizedProps):(a===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):a.count--,r===null?Gf(i,e.type,e.stateNode):zf(i,r,e.memoizedProps))}break;case 27:fl(t,e),hl(e),r&512&&(Qc||n===null||Uc(n,n.return)),n!==null&&r&4&&Gc(e,e.memoizedProps,n.memoizedProps);break;case 5:if(fl(t,e),hl(e),r&512&&(Qc||n===null||Uc(n,n.return)),e.flags&32){i=e.stateNode;try{Rt(i,``)}catch(t){Gu(e,e.return,t)}}r&4&&e.stateNode!=null&&(i=e.memoizedProps,Gc(e,i,n===null?i:n.memoizedProps)),r&1024&&($c=!0);break;case 6:if(fl(t,e),hl(e),r&4){if(e.stateNode===null)throw Error(o(162));r=e.memoizedProps,n=e.stateNode;try{n.nodeValue=r}catch(t){Gu(e,e.return,t)}}break;case 3:if(Uf=null,i=pl,pl=yf(t.containerInfo),fl(t,e),pl=i,hl(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Ip(t.containerInfo)}catch(t){Gu(e,e.return,t)}$c&&($c=!1,gl(e));break;case 4:r=pl,pl=yf(e.stateNode.containerInfo),fl(t,e),hl(e),pl=r;break;case 12:fl(t,e),hl(e);break;case 31:fl(t,e),hl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,dl(e,r)));break;case 13:fl(t,e),hl(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&($l=be()),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,dl(e,r)));break;case 22:i=e.memoizedState!==null;var l=n!==null&&n.memoizedState!==null,u=Zc,d=Qc;if(Zc=u||i,Qc=d||l,fl(t,e),Qc=d,Zc=u,hl(e),r&8192)a:for(t=e.stateNode,t._visibility=i?t._visibility&-2:t._visibility|1,i&&(n===null||l||Zc||Qc||vl(e)),n=null,t=e;;){if(t.tag===5||t.tag===26){if(n===null){l=n=t;try{if(a=l.stateNode,i)s=a.style,typeof s.setProperty==`function`?s.setProperty(`display`,`none`,`important`):s.display=`none`;else{c=l.stateNode;var f=l.memoizedProps.style,p=f!=null&&f.hasOwnProperty(`display`)?f.display:null;c.style.display=p==null||typeof p==`boolean`?``:(``+p).trim()}}catch(e){Gu(l,l.return,e)}}}else if(t.tag===6){if(n===null){l=t;try{l.stateNode.nodeValue=i?``:l.memoizedProps}catch(e){Gu(l,l.return,e)}}}else if(t.tag===18){if(n===null){l=t;try{var m=l.stateNode;i?nf(m,!0):nf(l.stateNode,!1)}catch(e){Gu(l,l.return,e)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break a;for(;t.sibling===null;){if(t.return===null||t.return===e)break a;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}r&4&&(r=e.updateQueue,r!==null&&(n=r.retryQueue,n!==null&&(r.retryQueue=null,dl(e,n))));break;case 19:fl(t,e),hl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,dl(e,r)));break;case 30:break;case 21:break;default:fl(t,e),hl(e)}}function hl(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(Kc(r)){n=r;break}r=r.return}if(n==null)throw Error(o(160));switch(n.tag){case 27:var i=n.stateNode;Yc(e,qc(e),i);break;case 5:var a=n.stateNode;n.flags&32&&(Rt(a,``),n.flags&=-33),Yc(e,qc(e),a);break;case 3:case 4:var s=n.stateNode.containerInfo;Jc(e,qc(e),s);break;default:throw Error(o(161))}}catch(t){Gu(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function gl(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;gl(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function _l(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)nl(e,t.alternate,t),t=t.sibling}function vl(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:zc(4,t,t.return),vl(t);break;case 1:Uc(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount==`function`&&Vc(t,t.return,n),vl(t);break;case 27:gf(t.stateNode);case 26:case 5:Uc(t,t.return),vl(t);break;case 22:t.memoizedState===null&&vl(t);break;case 30:vl(t);break;default:vl(t)}e=e.sibling}}function yl(e,t,n){for(n&&=(t.subtreeFlags&8772)!=0,t=t.child;t!==null;){var r=t.alternate,i=e,a=t,o=a.flags;switch(a.tag){case 0:case 11:case 15:yl(i,a,n),Rc(4,a);break;case 1:if(yl(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){Gu(r,r.return,e)}if(r=a,i=r.updateQueue,i!==null){var s=r.stateNode;try{var c=i.shared.hiddenCallbacks;if(c!==null)for(i.shared.hiddenCallbacks=null,i=0;i<c.length;i++)Ua(c[i],s)}catch(e){Gu(r,r.return,e)}}n&&o&64&&Bc(a),Hc(a,a.return);break;case 27:Xc(a);case 26:case 5:yl(i,a,n),n&&r===null&&o&4&&Wc(a),Hc(a,a.return);break;case 12:yl(i,a,n);break;case 31:yl(i,a,n),n&&o&4&&cl(i,a);break;case 13:yl(i,a,n),n&&o&4&&ll(i,a);break;case 22:a.memoizedState===null&&yl(i,a,n),Hc(a,a.return);break;case 30:break;default:yl(i,a,n)}t=t.sibling}}function bl(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&na(n))}function xl(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&na(e))}function Sl(e,t,n,r){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)Cl(e,t,n,r),t=t.sibling}function Cl(e,t,n,r){var i=t.flags;switch(t.tag){case 0:case 11:case 15:Sl(e,t,n,r),i&2048&&Rc(9,t);break;case 1:Sl(e,t,n,r);break;case 3:Sl(e,t,n,r),i&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&na(e)));break;case 12:if(i&2048){Sl(e,t,n,r),e=t.stateNode;try{var a=t.memoizedProps,o=a.id,s=a.onPostCommit;typeof s==`function`&&s(o,t.alternate===null?`mount`:`update`,e.passiveEffectDuration,-0)}catch(e){Gu(t,t.return,e)}}else Sl(e,t,n,r);break;case 31:Sl(e,t,n,r);break;case 13:Sl(e,t,n,r);break;case 23:break;case 22:a=t.stateNode,o=t.alternate,t.memoizedState===null?a._visibility&2?Sl(e,t,n,r):(a._visibility|=2,wl(e,t,n,r,(t.subtreeFlags&10256)!=0||!1)):a._visibility&2?Sl(e,t,n,r):Tl(e,t),i&2048&&bl(o,t);break;case 24:Sl(e,t,n,r),i&2048&&xl(t.alternate,t);break;default:Sl(e,t,n,r)}}function wl(e,t,n,r,i){for(i&&=(t.subtreeFlags&10256)!=0||!1,t=t.child;t!==null;){var a=e,o=t,s=n,c=r,l=o.flags;switch(o.tag){case 0:case 11:case 15:wl(a,o,s,c,i),Rc(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,wl(a,o,s,c,i)):u._visibility&2?wl(a,o,s,c,i):Tl(a,o),i&&l&2048&&bl(o.alternate,o);break;case 24:wl(a,o,s,c,i),i&&l&2048&&xl(o.alternate,o);break;default:wl(a,o,s,c,i)}t=t.sibling}}function Tl(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,r=t,i=r.flags;switch(r.tag){case 22:Tl(n,r),i&2048&&bl(r.alternate,r);break;case 24:Tl(n,r),i&2048&&xl(r.alternate,r);break;default:Tl(n,r)}t=t.sibling}}var El=8192;function Dl(e,t,n){if(e.subtreeFlags&El)for(e=e.child;e!==null;)Ol(e,t,n),e=e.sibling}function Ol(e,t,n){switch(e.tag){case 26:Dl(e,t,n),e.flags&El&&e.memoizedState!==null&&Jf(n,pl,e.memoizedState,e.memoizedProps);break;case 5:Dl(e,t,n);break;case 3:case 4:var r=pl;pl=yf(e.stateNode.containerInfo),Dl(e,t,n),pl=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=El,El=16777216,Dl(e,t,n),El=r):Dl(e,t,n));break;default:Dl(e,t,n)}}function kl(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function Al(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];q=r,Pl(r,e)}kl(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)jl(e),e=e.sibling}function jl(e){switch(e.tag){case 0:case 11:case 15:Al(e),e.flags&2048&&zc(9,e,e.return);break;case 3:Al(e);break;case 12:Al(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,Ml(e)):Al(e);break;default:Al(e)}}function Ml(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];q=r,Pl(r,e)}kl(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:zc(8,t,t.return),Ml(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,Ml(t));break;default:Ml(t)}e=e.sibling}}function Pl(e,t){for(;q!==null;){var n=q;switch(n.tag){case 0:case 11:case 15:zc(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var r=n.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:na(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,q=r;else a:for(n=e;q!==null;){r=q;var i=r.sibling,a=r.return;if(rl(r),r===n){q=null;break a}if(i!==null){i.return=a,q=i;break a}q=a}}}var Fl={getCacheForType:function(e){var t=Ji(ea),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return Ji(ea).controller.signal}},J=typeof WeakMap==`function`?WeakMap:Map,Il=0,Ll=null,Y=null,X=0,Rl=0,zl=null,Bl=!1,Vl=!1,Hl=!1,Ul=0,Wl=0,Gl=0,Kl=0,ql=0,Jl=0,Yl=0,Xl=null,Zl=null,Ql=!1,$l=0,eu=0,tu=1/0,nu=null,ru=null,iu=0,au=null,ou=null,su=0,cu=0,lu=null,uu=null,du=0,fu=null;function pu(){return Il&2&&X!==0?X&-X:F.T===null?Xe():fd()}function mu(){if(Jl===0)if(!(X&536870912)||Di){var e=Fe;Fe<<=1,!(Fe&3932160)&&(Fe=262144),Jl=e}else Jl=536870912;return e=Xa.current,e!==null&&(e.flags|=32),Jl}function hu(e,t,n){(e===Ll&&(Rl===2||Rl===9)||e.cancelPendingCommit!==null)&&(Su(e,0),yu(e,X,Jl,!1)),Ue(e,n),(!(Il&2)||e!==Ll)&&(e===Ll&&(!(Il&2)&&(Kl|=n),Wl===4&&yu(e,X,Jl,!1)),id(e))}function gu(e,t,n){if(Il&6)throw Error(o(327));var r=!n&&(t&127)==0&&(t&e.expiredLanes)===0||ze(e,t),i=r?Au(e,t):Ou(e,t,!0),a=r;do{if(i===0){Vl&&!r&&yu(e,t,0,!1);break}else{if(n=e.current.alternate,a&&!vu(n)){i=Ou(e,t,!1),a=!1;continue}if(i===2){if(a=t,e.errorRecoveryDisabledLanes&a)var s=0;else s=e.pendingLanes&-536870913,s=s===0?s&536870912?536870912:0:s;if(s!==0){t=s;a:{var c=e;i=Xl;var l=c.current.memoizedState.isDehydrated;if(l&&(Su(c,s).flags|=256),s=Ou(c,s,!1),s!==2){if(Hl&&!l){c.errorRecoveryDisabledLanes|=a,Kl|=a,i=4;break a}a=Zl,Zl=i,a!==null&&(Zl===null?Zl=a:Zl.push.apply(Zl,a))}i=s}if(a=!1,i!==2)continue}}if(i===1){Su(e,0),yu(e,t,0,!0);break}a:{switch(r=e,a=i,a){case 0:case 1:throw Error(o(345));case 4:if((t&4194048)!==t)break;case 6:yu(r,t,Jl,!Bl);break a;case 2:Zl=null;break;case 3:case 5:break;default:throw Error(o(329))}if((t&62914560)===t&&(i=$l+300-be(),10<i)){if(yu(r,t,Jl,!Bl),Re(r,0,!0)!==0)break a;su=t,r.timeoutHandle=Yd(_u.bind(null,r,n,Zl,nu,Ql,t,Jl,Kl,Yl,Bl,a,`Throttled`,-0,0),i);break a}_u(r,n,Zl,nu,Ql,t,Jl,Kl,Yl,Bl,a,null,-0,0)}}break}while(1);id(e)}function _u(e,t,n,r,i,a,o,s,c,l,u,d,f,p){if(e.timeoutHandle=-1,d=t.subtreeFlags,d&8192||(d&16785408)==16785408){d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Kt},Ol(t,a,d);var m=(a&62914560)===a?$l-be():(a&4194048)===a?eu-be():0;if(m=Xf(d,m),m!==null){su=a,e.cancelPendingCommit=m(Lu.bind(null,e,t,a,n,r,i,o,s,c,u,d,null,f,p)),yu(e,a,o,!l);return}}Lu(e,t,a,n,r,i,o,s,c)}function vu(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!mr(a(),i))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function yu(e,t,n,r){t&=~ql,t&=~Kl,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-Ae(i),o=1<<a;r[a]=-1,i&=~o}n!==0&&Ge(e,n,t)}function bu(){return Il&6?!0:(ad(0,!1),!1)}function xu(){if(Y!==null){if(Rl===0)var e=Y.return;else e=Y,Bi=zi=null,To(e),Ta=null,Ea=0,e=Y;for(;e!==null;)Lc(e.alternate,e),e=e.return;Y=null}}function Su(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,Xd(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),su=0,xu(),Ll=e,Y=n=ni(e.current,null),X=t,Rl=0,zl=null,Bl=!1,Vl=ze(e,t),Hl=!1,Yl=Jl=ql=Kl=Gl=Wl=0,Zl=Xl=null,Ql=!1,t&8&&(t|=t&32);var r=e.entangledLanes;if(r!==0)for(e=e.entanglements,r&=t;0<r;){var i=31-Ae(r),a=1<<i;t|=e[i],r&=~a}return Ul=t,Kr(),n}function Cu(e,t){oo=null,F.H=Ps,t===ha||t===_a?(t=Ca(),Rl=3):t===ga?(t=Ca(),Rl=4):Rl=t===Qs?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,zl=t,Y===null&&(Wl=1,Ks(e,ui(t,e.current)))}function wu(){var e=Xa.current;return e===null?!0:(X&4194048)===X?Za===null:(X&62914560)===X||X&536870912?e===Za:!1}function Tu(){var e=F.H;return F.H=Ps,e===null?Ps:e}function Eu(){var e=F.A;return F.A=Fl,e}function Du(){Wl=4,Bl||(X&4194048)!==X&&Xa.current!==null||(Vl=!0),!(Gl&134217727)&&!(Kl&134217727)||Ll===null||yu(Ll,X,Jl,!1)}function Ou(e,t,n){var r=Il;Il|=2;var i=Tu(),a=Eu();(Ll!==e||X!==t)&&(nu=null,Su(e,t)),t=!1;var o=Wl;a:do try{if(Rl!==0&&Y!==null){var s=Y,c=zl;switch(Rl){case 8:xu(),o=6;break a;case 3:case 2:case 9:case 6:Xa.current===null&&(t=!0);var l=Rl;if(Rl=0,zl=null,Pu(e,s,c,l),n&&Vl){o=0;break a}break;default:l=Rl,Rl=0,zl=null,Pu(e,s,c,l)}}ku(),o=Wl;break}catch(t){Cu(e,t)}while(1);return t&&e.shellSuspendCounter++,Bi=zi=null,Il=r,F.H=i,F.A=a,Y===null&&(Ll=null,X=0,Kr()),o}function ku(){for(;Y!==null;)Mu(Y)}function Au(e,t){var n=Il;Il|=2;var r=Tu(),i=Eu();Ll!==e||X!==t?(nu=null,tu=be()+500,Su(e,t)):Vl=ze(e,t);a:do try{if(Rl!==0&&Y!==null){t=Y;var a=zl;b:switch(Rl){case 1:Rl=0,zl=null,Pu(e,t,a,1);break;case 2:case 9:if(ya(a)){Rl=0,zl=null,Nu(t);break}t=function(){Rl!==2&&Rl!==9||Ll!==e||(Rl=7),id(e)},a.then(t,t);break a;case 3:Rl=7;break a;case 4:Rl=5;break a;case 7:ya(a)?(Rl=0,zl=null,Nu(t)):(Rl=0,zl=null,Pu(e,t,a,7));break;case 5:var s=null;switch(Y.tag){case 26:s=Y.memoizedState;case 5:case 27:var c=Y;if(s?qf(s):c.stateNode.complete){Rl=0,zl=null;var l=c.sibling;if(l!==null)Y=l;else{var u=c.return;u===null?Y=null:(Y=u,Fu(u))}break b}}Rl=0,zl=null,Pu(e,t,a,5);break;case 6:Rl=0,zl=null,Pu(e,t,a,6);break;case 8:xu(),Wl=6;break a;default:throw Error(o(462))}}ju();break}catch(t){Cu(e,t)}while(1);return Bi=zi=null,F.H=r,F.A=i,Il=n,Y===null?(Ll=null,X=0,Kr(),Wl):0}function ju(){for(;Y!==null&&!ve();)Mu(Y)}function Mu(e){var t=Oc(e.alternate,e,Ul);e.memoizedProps=e.pendingProps,t===null?Fu(e):Y=t}function Nu(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=fc(n,t,t.pendingProps,t.type,void 0,X);break;case 11:t=fc(n,t,t.pendingProps,t.type.render,t.ref,X);break;case 5:To(t);default:Lc(n,t),t=Y=ri(t,Ul),t=Oc(n,t,Ul)}e.memoizedProps=e.pendingProps,t===null?Fu(e):Y=t}function Pu(e,t,n,r){Bi=zi=null,To(t),Ta=null,Ea=0;var i=t.return;try{if(Zs(e,i,t,n,X)){Wl=1,Ks(e,ui(n,e.current)),Y=null;return}}catch(t){if(i!==null)throw Y=i,t;Wl=1,Ks(e,ui(n,e.current)),Y=null;return}t.flags&32768?(Di||r===1?e=!0:Vl||X&536870912?e=!1:(Bl=e=!0,(r===2||r===9||r===3||r===6)&&(r=Xa.current,r!==null&&r.tag===13&&(r.flags|=16384))),Iu(t,e)):Fu(t)}function Fu(e){var t=e;do{if(t.flags&32768){Iu(t,Bl);return}e=t.return;var n=Fc(t.alternate,t,Ul);if(n!==null){Y=n;return}if(t=t.sibling,t!==null){Y=t;return}Y=t=e}while(t!==null);Wl===0&&(Wl=5)}function Iu(e,t){do{var n=Ic(e.alternate,e);if(n!==null){n.flags&=32767,Y=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){Y=e;return}Y=e=n}while(e!==null);Wl=6,Y=null}function Lu(e,t,n,r,i,a,s,c,l){e.cancelPendingCommit=null;do Hu();while(iu!==0);if(Il&6)throw Error(o(327));if(t!==null){if(t===e.current)throw Error(o(177));if(a=t.lanes|t.childLanes,a|=Gr,We(e,n,a,s,c,l),e===Ll&&(Y=Ll=null,X=0),ou=t,au=e,su=n,cu=a,lu=i,uu=r,t.subtreeFlags&10256||t.flags&10256?(e.callbackNode=null,e.callbackPriority=0,Zu(Ce,function(){return Uu(),null})):(e.callbackNode=null,e.callbackPriority=0),r=(t.flags&13878)!=0,t.subtreeFlags&13878||r){r=F.T,F.T=null,i=I.p,I.p=2,s=Il,Il|=4;try{tl(e,t,n)}finally{Il=s,I.p=i,F.T=r}}iu=1,Ru(),zu(),Bu()}}function Ru(){if(iu===1){iu=0;var e=au,t=ou,n=(t.flags&13878)!=0;if(t.subtreeFlags&13878||n){n=F.T,F.T=null;var r=I.p;I.p=2;var i=Il;Il|=4;try{ml(t,e);var a=Hd,o=yr(e.containerInfo),s=a.focusedElem,c=a.selectionRange;if(o!==s&&s&&s.ownerDocument&&vr(s.ownerDocument.documentElement,s)){if(c!==null&&br(s)){var l=c.start,u=c.end;if(u===void 0&&(u=l),`selectionStart`in s)s.selectionStart=l,s.selectionEnd=Math.min(u,s.value.length);else{var d=s.ownerDocument||document,f=d&&d.defaultView||window;if(f.getSelection){var p=f.getSelection(),m=s.textContent.length,h=Math.min(c.start,m),g=c.end===void 0?h:Math.min(c.end,m);!p.extend&&h>g&&(o=g,g=h,h=o);var _=_r(s,h),v=_r(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;s<d.length;s++){var b=d[s];b.element.scrollLeft=b.left,b.element.scrollTop=b.top}}up=!!Vd,Hd=Vd=null}finally{Il=i,I.p=r,F.T=n}}e.current=t,iu=2}}function zu(){if(iu===2){iu=0;var e=au,t=ou,n=(t.flags&8772)!=0;if(t.subtreeFlags&8772||n){n=F.T,F.T=null;var r=I.p;I.p=2;var i=Il;Il|=4;try{nl(e,t.alternate,t)}finally{Il=i,I.p=r,F.T=n}}iu=3}}function Bu(){if(iu===4||iu===3){iu=0,ye();var e=au,t=ou,n=su,r=uu;t.subtreeFlags&10256||t.flags&10256?iu=5:(iu=0,ou=au=null,Vu(e,e.pendingLanes));var i=e.pendingLanes;if(i===0&&(ru=null),Ye(n),t=t.stateNode,Oe&&typeof Oe.onCommitFiberRoot==`function`)try{Oe.onCommitFiberRoot(De,t,void 0,(t.current.flags&128)==128)}catch{}if(r!==null){t=F.T,i=I.p,I.p=2,F.T=null;try{for(var a=e.onRecoverableError,o=0;o<r.length;o++){var s=r[o];a(s.value,{componentStack:s.stack})}}finally{F.T=t,I.p=i}}su&3&&Hu(),id(e),i=e.pendingLanes,n&261930&&i&42?e===fu?du++:(du=0,fu=e):du=0,ad(0,!1)}}function Vu(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,na(t)))}function Hu(){return Ru(),zu(),Bu(),Uu()}function Uu(){if(iu!==5)return!1;var e=au,t=cu;cu=0;var n=Ye(su),r=F.T,i=I.p;try{I.p=32>n?32:n,F.T=null,n=lu,lu=null;var a=au,s=su;if(iu=0,ou=au=null,su=0,Il&6)throw Error(o(331));var c=Il;if(Il|=4,jl(a.current),Cl(a,a.current,s,n),Il=c,ad(0,!1),Oe&&typeof Oe.onPostCommitFiberRoot==`function`)try{Oe.onPostCommitFiberRoot(De,a)}catch{}return!0}finally{I.p=i,F.T=r,Vu(e,t)}}function Wu(e,t,n){t=ui(n,t),t=Js(e.stateNode,t,2),e=La(e,t,2),e!==null&&(Ue(e,2),id(e))}function Gu(e,t,n){if(e.tag===3)Wu(e,e,n);else for(;t!==null;){if(t.tag===3){Wu(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(ru===null||!ru.has(r))){e=ui(n,e),n=Ys(2),r=La(t,n,2),r!==null&&(Xs(n,r,t,e),Ue(r,2),id(r));break}}t=t.return}}function Ku(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new J;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(Hl=!0,i.add(n),e=qu.bind(null,e,t,n),t.then(e,e))}function qu(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Ll===e&&(X&n)===n&&(Wl===4||Wl===3&&(X&62914560)===X&&300>be()-$l?!(Il&2)&&Su(e,0):ql|=n,Yl===X&&(Yl=0)),id(e)}function Ju(e,t){t===0&&(t=Ve()),e=Yr(e,t),e!==null&&(Ue(e,t),id(e))}function Yu(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Ju(e,n)}function Xu(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,i=e.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(o(314))}r!==null&&r.delete(t),Ju(e,n)}function Zu(e,t){return ge(e,t)}var Qu=null,$u=null,ed=!1,td=!1,nd=!1,rd=0;function id(e){e!==$u&&e.next===null&&($u===null?Qu=$u=e:$u=$u.next=e),td=!0,ed||(ed=!0,dd())}function ad(e,t){if(!nd&&td){nd=!0;do for(var n=!1,r=Qu;r!==null;){if(!t)if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-Ae(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,ud(r,a))}else a=X,a=Re(r,r===Ll?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||ze(r,a)||(n=!0,ud(r,a));r=r.next}while(n);nd=!1}}function od(){sd()}function sd(){td=ed=!1;var e=0;rd!==0&&Jd()&&(e=rd);for(var t=be(),n=null,r=Qu;r!==null;){var i=r.next,a=cd(r,t);a===0?(r.next=null,n===null?Qu=i:n.next=i,i===null&&($u=n)):(n=r,(e!==0||a&3)&&(td=!0)),r=i}iu!==0&&iu!==5||ad(e,!1),rd!==0&&(rd=0)}function cd(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-Ae(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=Be(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=Ll,n=X,n=Re(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(Rl===2||Rl===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&_e(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||ze(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&_e(r),Ye(n)){case 2:case 8:n=U;break;case 32:n=Ce;break;case 268435456:n=W;break;default:n=Ce}return r=ld.bind(null,e),n=ge(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&_e(r),e.callbackPriority=2,e.callbackNode=null,2}function ld(e,t){if(iu!==0&&iu!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(Hu()&&e.callbackNode!==n)return null;var r=X;return r=Re(e,e===Ll?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(gu(e,r,t),cd(e,be()),e.callbackNode!=null&&e.callbackNode===n?ld.bind(null,e):null)}function ud(e,t){if(Hu())return null;gu(e,t,!0)}function dd(){Qd(function(){Il&6?ge(Se,od):sd()})}function fd(){if(rd===0){var e=aa;e===0&&(e=Pe,Pe<<=1,!(Pe&261888)&&(Pe=256)),rd=e}return rd}function pd(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:Gt(``+e)}function md(e,t){var n=t.ownerDocument.createElement(`input`);return n.name=t.name,n.value=t.value,e.id&&n.setAttribute(`form`,e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}function hd(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=pd((i[et]||null).action),o=r.submitter;o&&(t=(t=o[et]||null)?pd(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new mn(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(rd!==0){var e=o?md(i,o):new FormData(i);bs(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=o?md(i,o):new FormData(i),bs(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var gd=0;gd<Br.length;gd++){var _d=Br[gd];Vr(_d.toLowerCase(),`on`+(_d[0].toUpperCase()+_d.slice(1)))}Vr(Mr,`onAnimationEnd`),Vr(Nr,`onAnimationIteration`),Vr(Pr,`onAnimationStart`),Vr(`dblclick`,`onDoubleClick`),Vr(`focusin`,`onFocus`),Vr(`focusout`,`onBlur`),Vr(Fr,`onTransitionRun`),Vr(Ir,`onTransitionStart`),Vr(Lr,`onTransitionCancel`),Vr(Rr,`onTransitionEnd`),gt(`onMouseEnter`,[`mouseout`,`mouseover`]),gt(`onMouseLeave`,[`mouseout`,`mouseover`]),gt(`onPointerEnter`,[`pointerout`,`pointerover`]),gt(`onPointerLeave`,[`pointerout`,`pointerover`]),ht(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),ht(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),ht(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),ht(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),ht(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),ht(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var vd=`abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting`.split(` `),yd=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat(vd));function bd(e,t){t=(t&4)!=0;for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;a:{var a=void 0;if(t)for(var o=r.length-1;0<=o;o--){var s=r[o],c=s.instance,l=s.currentTarget;if(s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){Hr(e)}i.currentTarget=null,a=c}else for(o=0;o<r.length;o++){if(s=r[o],c=s.instance,l=s.currentTarget,s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){Hr(e)}i.currentTarget=null,a=c}}}}function xd(e,t){var n=t[nt];n===void 0&&(n=t[nt]=new Set);var r=e+`__bubble`;n.has(r)||(Td(t,e,2,!1),n.add(r))}function Sd(e,t,n){var r=0;t&&(r|=4),Td(n,e,r,t)}var Cd=`_reactListening`+Math.random().toString(36).slice(2);function wd(e){if(!e[Cd]){e[Cd]=!0,pt.forEach(function(t){t!==`selectionchange`&&(yd.has(t)||Sd(t,!1,e),Sd(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Cd]||(t[Cd]=!0,Sd(`selectionchange`,!1,t))}}function Td(e,t,n,r){switch(_p(t)){case 2:var i=dp;break;case 8:i=fp;break;default:i=pp}n=i.bind(null,t,n,e),i=void 0,!nn||t!==`touchstart`&&t!==`touchmove`&&t!==`wheel`||(i=!0),r?i===void 0?e.addEventListener(t,n,!0):e.addEventListener(t,n,{capture:!0,passive:i}):i===void 0?e.addEventListener(t,n,!1):e.addEventListener(t,n,{passive:i})}function Ed(e,t,n,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)a:for(;;){if(r===null)return;var o=r.tag;if(o===3||o===4){var s=r.stateNode.containerInfo;if(s===i)break;if(o===4)for(o=r.return;o!==null;){var l=o.tag;if((l===3||l===4)&&o.stateNode.containerInfo===i)return;o=o.return}for(;s!==null;){if(o=ct(s),o===null)return;if(l=o.tag,l===5||l===6||l===26||l===27){r=a=o;continue a}s=s.parentNode}}r=r.return}$t(function(){var r=a,i=Jt(n),o=[];a:{var s=zr.get(e);if(s!==void 0){var l=mn,u=e;switch(e){case`keypress`:if(ln(n)===0)break a;case`keydown`:case`keyup`:l=jn;break;case`focusin`:u=`focus`,l=Sn;break;case`focusout`:u=`blur`,l=Sn;break;case`beforeblur`:case`afterblur`:l=Sn;break;case`click`:if(n.button===2)break a;case`auxclick`:case`dblclick`:case`mousedown`:case`mousemove`:case`mouseup`:case`mouseout`:case`mouseover`:case`contextmenu`:l=bn;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:l=xn;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:l=Nn;break;case Mr:case Nr:case Pr:l=Cn;break;case Rr:l=Pn;break;case`scroll`:case`scrollend`:l=gn;break;case`wheel`:l=Fn;break;case`copy`:case`cut`:case`paste`:l=wn;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:l=Mn;break;case`toggle`:case`beforetoggle`:l=In}var d=(t&4)!=0,f=!d&&(e===`scroll`||e===`scrollend`),p=d?s===null?null:s+`Capture`:s;d=[];for(var m=r,h;m!==null;){var g=m;if(h=g.stateNode,g=g.tag,g!==5&&g!==26&&g!==27||h===null||p===null||(g=en(m,p),g!=null&&d.push(Dd(m,g,h))),f)break;m=m.return}0<d.length&&(s=new l(s,u,null,n,i),o.push({event:s,listeners:d}))}}if(!(t&7)){a:{if(s=e===`mouseover`||e===`pointerover`,l=e===`mouseout`||e===`pointerout`,s&&n!==qt&&(u=n.relatedTarget||n.fromElement)&&(ct(u)||u[tt]))break a;if((l||s)&&(s=i.window===i?i:(s=i.ownerDocument)?s.defaultView||s.parentWindow:window,l?(u=n.relatedTarget||n.toElement,l=r,u=u?ct(u):null,u!==null&&(f=c(u),d=u.tag,u!==f||d!==5&&d!==27&&d!==6)&&(u=null)):(l=null,u=r),l!==u)){if(d=bn,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=Mn,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=l==null?s:ut(l),h=u==null?s:ut(u),s=new d(g,m+`leave`,l,n,i),s.target=f,s.relatedTarget=h,g=null,ct(i)===r&&(d=new d(p,m+`enter`,u,n,i),d.target=h,d.relatedTarget=f,g=d),f=g,l&&u)b:{for(d=kd,p=l,m=u,h=0,g=p;g;g=d(g))h++;g=0;for(var _=m;_;_=d(_))g++;for(;0<h-g;)p=d(p),h--;for(;0<g-h;)m=d(m),g--;for(;h--;){if(p===m||m!==null&&p===m.alternate){d=p;break b}p=d(p),m=d(m)}d=null}else d=null;l!==null&&Ad(o,s,l,d,!1),u!==null&&f!==null&&Ad(o,f,u,d,!0)}}a:{if(s=r?ut(r):window,l=s.nodeName&&s.nodeName.toLowerCase(),l===`select`||l===`input`&&s.type===`file`)var v=nr;else if(Xn(s))if(rr)v=fr;else{v=ur;var y=lr}else l=s.nodeName,!l||l.toLowerCase()!==`input`||s.type!==`checkbox`&&s.type!==`radio`?r&&Ht(r.elementType)&&(v=nr):v=dr;if(v&&=v(e,r)){Zn(o,v,n,i);break a}y&&y(e,s,r),e===`focusout`&&r&&s.type===`number`&&r.memoizedProps.value!=null&&Pt(s,`number`,s.value)}switch(y=r?ut(r):window,e){case`focusin`:(Xn(y)||y.contentEditable===`true`)&&(Sr=y,Cr=r,wr=null);break;case`focusout`:wr=Cr=Sr=null;break;case`mousedown`:Tr=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:Tr=!1,Er(o,n,i);break;case`selectionchange`:if(xr)break;case`keydown`:case`keyup`:Er(o,n,i)}var b;if(Rn)b:{switch(e){case`compositionstart`:var x=`onCompositionStart`;break b;case`compositionend`:x=`onCompositionEnd`;break b;case`compositionupdate`:x=`onCompositionUpdate`;break b}x=void 0}else Kn?Wn(e,n)&&(x=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(x=`onCompositionStart`);x&&(Vn&&n.locale!==`ko`&&(Kn||x!==`onCompositionStart`?x===`onCompositionEnd`&&Kn&&(b=cn()):(an=i,on=`value`in an?an.value:an.textContent,Kn=!0)),y=Od(r,x),0<y.length&&(x=new Tn(x,e,null,n,i),o.push({event:x,listeners:y}),b?x.data=b:(b=Gn(n),b!==null&&(x.data=b)))),(b=Bn?qn(e,n):Jn(e,n))&&(x=Od(r,`onBeforeInput`),0<x.length&&(y=new Tn(`onBeforeInput`,`beforeinput`,null,n,i),o.push({event:y,listeners:x}),y.data=b)),hd(o,e,r,n,i)}bd(o,t)})}function Dd(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Od(e,t){for(var n=t+`Capture`,r=[];e!==null;){var i=e,a=i.stateNode;if(i=i.tag,i!==5&&i!==26&&i!==27||a===null||(i=en(e,n),i!=null&&r.unshift(Dd(e,i,a)),i=en(e,t),i!=null&&r.push(Dd(e,i,a))),e.tag===3)return r;e=e.return}return[]}function kd(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Ad(e,t,n,r,i){for(var a=t._reactName,o=[];n!==null&&n!==r;){var s=n,c=s.alternate,l=s.stateNode;if(s=s.tag,c!==null&&c===r)break;s!==5&&s!==26&&s!==27||l===null||(c=l,i?(l=en(n,a),l!=null&&o.unshift(Dd(n,l,c))):i||(l=en(n,a),l!=null&&o.push(Dd(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var jd=/\r\n?/g,Md=/\u0000|\uFFFD/g;function Nd(e){return(typeof e==`string`?e:``+e).replace(jd,`
10
+ `).replace(Md,``)}function Pd(e,t){return t=Nd(t),Nd(e)===t}function Fd(e,t,n,r,i,a){switch(n){case`children`:typeof r==`string`?t===`body`||t===`textarea`&&r===``||Rt(e,r):(typeof r==`number`||typeof r==`bigint`)&&t!==`body`&&Rt(e,``+r);break;case`className`:St(e,`class`,r);break;case`tabIndex`:St(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:St(e,n,r);break;case`style`:Vt(e,r,a);break;case`data`:if(t!==`object`){St(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)){e.removeAttribute(n);break}if(r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=Gt(``+r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}else typeof a==`function`&&(n===`formAction`?(t!==`input`&&Fd(e,t,`name`,i.name,i,null),Fd(e,t,`formEncType`,i.formEncType,i,null),Fd(e,t,`formMethod`,i.formMethod,i,null),Fd(e,t,`formTarget`,i.formTarget,i,null)):(Fd(e,t,`encType`,i.encType,i,null),Fd(e,t,`method`,i.method,i,null),Fd(e,t,`target`,i.target,i,null)));if(r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=Gt(``+r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=Kt);break;case`onScroll`:r!=null&&xd(`scroll`,e);break;case`onScrollEnd`:r!=null&&xd(`scrollend`,e);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(o(61));if(n=r.__html,n!=null){if(i.children!=null)throw Error(o(60));e.innerHTML=n}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=Gt(``+r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``+r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:xd(`beforetoggle`,e),xd(`toggle`,e),xt(e,`popover`,r);break;case`xlinkActuate`:Ct(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:Ct(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:Ct(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:Ct(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:Ct(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:Ct(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:Ct(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:Ct(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:Ct(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:xt(e,`is`,r);break;case`innerText`:case`textContent`:break;default:(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)&&(n=Ut.get(n)||n,xt(e,n,r))}}function Id(e,t,n,r,i,a){switch(n){case`style`:Vt(e,r,a);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(o(61));if(n=r.__html,n!=null){if(i.children!=null)throw Error(o(60));e.innerHTML=n}}break;case`children`:typeof r==`string`?Rt(e,r):(typeof r==`number`||typeof r==`bigint`)&&Rt(e,``+r);break;case`onScroll`:r!=null&&xd(`scroll`,e);break;case`onScrollEnd`:r!=null&&xd(`scrollend`,e);break;case`onClick`:r!=null&&(e.onclick=Kt);break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:break;case`innerText`:case`textContent`:break;default:if(!mt.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(i=n.endsWith(`Capture`),t=n.slice(2,i?n.length-7:void 0),a=e[et]||null,a=a==null?null:a[n],typeof a==`function`&&e.removeEventListener(t,a,i),typeof r==`function`)){typeof a!=`function`&&a!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,r,i);break a}n in e?e[n]=r:!0===r?e.setAttribute(n,``):xt(e,n,r)}}}function Ld(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:xd(`error`,e),xd(`load`,e);var r=!1,i=!1,a;for(a in n)if(n.hasOwnProperty(a)){var s=n[a];if(s!=null)switch(a){case`src`:r=!0;break;case`srcSet`:i=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(o(137,t));default:Fd(e,t,a,s,n,null)}}i&&Fd(e,t,`srcSet`,n.srcSet,n,null),r&&Fd(e,t,`src`,n.src,n,null);return;case`input`:xd(`invalid`,e);var c=a=s=i=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:i=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:a=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(o(137,t));break;default:Fd(e,t,r,d,n,null)}}Nt(e,a,c,l,u,s,i,!1);return;case`select`:for(i in xd(`invalid`,e),r=s=a=null,n)if(n.hasOwnProperty(i)&&(c=n[i],c!=null))switch(i){case`value`:a=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:Fd(e,t,i,c,n,null)}t=a,n=s,e.multiple=!!r,t==null?n!=null&&Ft(e,!!r,n,!0):Ft(e,!!r,t,!1);return;case`textarea`:for(s in xd(`invalid`,e),a=i=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:i=c;break;case`children`:a=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(o(91));break;default:Fd(e,t,s,c,n,null)}Lt(e,r,i,a);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:Fd(e,t,l,r,n,null)}return;case`dialog`:xd(`beforetoggle`,e),xd(`toggle`,e),xd(`cancel`,e),xd(`close`,e);break;case`iframe`:case`object`:xd(`load`,e);break;case`video`:case`audio`:for(r=0;r<vd.length;r++)xd(vd[r],e);break;case`image`:xd(`error`,e),xd(`load`,e);break;case`details`:xd(`toggle`,e);break;case`embed`:case`source`:case`link`:xd(`error`,e),xd(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(o(137,t));default:Fd(e,t,u,r,n,null)}return;default:if(Ht(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&Id(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&Fd(e,t,c,r,n,null))}function Rd(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var i=null,a=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||Fd(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:a=m;break;case`name`:i=m;break;case`checked`:u=m;break;case`defaultChecked`:d=m;break;case`value`:s=m;break;case`defaultValue`:c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(o(137,t));break;default:m!==f&&Fd(e,t,p,m,r,f)}}Mt(e,s,c,l,u,d,a,i);return;case`select`:for(a in m=s=c=p=null,n)if(l=n[a],n.hasOwnProperty(a)&&l!=null)switch(a){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(a)||Fd(e,t,a,null,r,l)}for(i in r)if(a=r[i],l=n[i],r.hasOwnProperty(i)&&(a!=null||l!=null))switch(i){case`value`:p=a;break;case`defaultValue`:c=a;break;case`multiple`:s=a;default:a!==l&&Fd(e,t,i,a,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?Ft(e,!!n,n?[]:``,!1):Ft(e,!!n,t,!0)):Ft(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(i=n[c],n.hasOwnProperty(c)&&i!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:Fd(e,t,c,null,r,i)}for(s in r)if(i=r[s],a=n[s],r.hasOwnProperty(s)&&(i!=null||a!=null))switch(s){case`value`:p=i;break;case`defaultValue`:m=i;break;case`children`:break;case`dangerouslySetInnerHTML`:if(i!=null)throw Error(o(91));break;default:i!==a&&Fd(e,t,s,i,r,a)}It(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:Fd(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:Fd(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&Fd(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(o(137,t));break;default:Fd(e,t,u,p,r,m)}return;default:if(Ht(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&Id(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||Id(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&Fd(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||Fd(e,t,f,p,r,m)}function zd(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function Bd(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&zd(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&zd(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var Vd=null,Hd=null;function Ud(e){return e.nodeType===9?e:e.ownerDocument}function Wd(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function Gd(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function Kd(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var qd=null;function Jd(){var e=window.event;return e&&e.type===`popstate`?e===qd?!1:(qd=e,!0):(qd=null,!1)}var Yd=typeof setTimeout==`function`?setTimeout:void 0,Xd=typeof clearTimeout==`function`?clearTimeout:void 0,Zd=typeof Promise==`function`?Promise:void 0,Qd=typeof queueMicrotask==`function`?queueMicrotask:Zd===void 0?Yd:function(e){return Zd.resolve(null).then(e).catch($d)};function $d(e){setTimeout(function(){throw e})}function ef(e){return e===`head`}function tf(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Ip(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)gf(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,gf(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[ot]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&gf(e.ownerDocument.body);n=i}while(n);Ip(t)}function nf(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8)if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++;n=r}while(n)}function rf(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:rf(n),st(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function af(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r)if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e;else if(!e[ot])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=df(e.nextSibling),e===null)break}return null}function of(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=df(e.nextSibling),e===null))return null;return e}function sf(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=df(e.nextSibling),e===null))return null;return e}function cf(e){return e.data===`$?`||e.data===`$~`}function lf(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function uf(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function df(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var ff=null;function pf(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return df(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function mf(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function hf(e,t,n){switch(t=Ud(n),e){case`html`:if(e=t.documentElement,!e)throw Error(o(452));return e;case`head`:if(e=t.head,!e)throw Error(o(453));return e;case`body`:if(e=t.body,!e)throw Error(o(454));return e;default:throw Error(o(451))}}function gf(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);st(e)}var _f=new Map,vf=new Set;function yf(e){return typeof e.getRootNode==`function`?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var bf=I.d;I.d={f:xf,r:Sf,D:Tf,C:Ef,L:Df,m:Of,X:Af,S:kf,M:jf};function xf(){var e=bf.f(),t=bu();return e||t}function Sf(e){var t=lt(e);t!==null&&t.tag===5&&t.type===`form`?Ss(t):bf.r(e)}var Cf=typeof document>`u`?null:document;function wf(e,t,n){var r=Cf;if(r&&typeof t==`string`&&t){var i=jt(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),vf.has(i)||(vf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Ld(t,`link`,e),ft(t),r.head.appendChild(t)))}}function Tf(e){bf.D(e),wf(`dns-prefetch`,e,null)}function Ef(e,t){bf.C(e,t),wf(`preconnect`,e,t)}function Df(e,t,n){bf.L(e,t,n);var r=Cf;if(r&&e&&t){var i=`link[rel="preload"][as="`+jt(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+jt(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+jt(n.imageSizes)+`"]`)):i+=`[href="`+jt(e)+`"]`;var a=i;switch(t){case`style`:a=Nf(e);break;case`script`:a=Lf(e)}_f.has(a)||(e=m({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),_f.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Pf(a))||t===`script`&&r.querySelector(Rf(a))||(t=r.createElement(`link`),Ld(t,`link`,e),ft(t),r.head.appendChild(t)))}}function Of(e,t){bf.m(e,t);var n=Cf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+jt(r)+`"][href="`+jt(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Lf(e)}if(!_f.has(a)&&(e=m({rel:`modulepreload`,href:e},t),_f.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Rf(a)))return}r=n.createElement(`link`),Ld(r,`link`,e),ft(r),n.head.appendChild(r)}}}function kf(e,t,n){bf.S(e,t,n);var r=Cf;if(r&&e){var i=dt(r).hoistableStyles,a=Nf(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Pf(a)))s.loading=5;else{e=m({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=_f.get(a))&&Vf(e,n);var c=o=r.createElement(`link`);ft(c),Ld(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Bf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Af(e,t){bf.X(e,t);var n=Cf;if(n&&e){var r=dt(n).hoistableScripts,i=Lf(e),a=r.get(i);a||(a=n.querySelector(Rf(i)),a||(e=m({src:e,async:!0},t),(t=_f.get(i))&&Hf(e,t),a=n.createElement(`script`),ft(a),Ld(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function jf(e,t){bf.M(e,t);var n=Cf;if(n&&e){var r=dt(n).hoistableScripts,i=Lf(e),a=r.get(i);a||(a=n.querySelector(Rf(i)),a||(e=m({src:e,async:!0,type:`module`},t),(t=_f.get(i))&&Hf(e,t),a=n.createElement(`script`),ft(a),Ld(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Mf(e,t,n,r){var i=(i=re.current)?yf(i):null;if(!i)throw Error(o(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=Nf(n.href),n=dt(i).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Nf(n.href);var a=dt(i).hoistableStyles,s=a.get(e);if(s||(i=i.ownerDocument||i,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},a.set(e,s),(a=i.querySelector(Pf(e)))&&!a._p&&(s.instance=a,s.state.loading=5),_f.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},_f.set(e,n),a||If(i,e,n,s.state))),t&&r===null)throw Error(o(528,``));return s}if(t&&r!==null)throw Error(o(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Lf(n),n=dt(i).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(o(444,e))}}function Nf(e){return`href="`+jt(e)+`"`}function Pf(e){return`link[rel="stylesheet"][`+e+`]`}function Ff(e){return m({},e,{"data-precedence":e.precedence,precedence:null})}function If(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Ld(t,`link`,n),ft(t),e.head.appendChild(t))}function Lf(e){return`[src="`+jt(e)+`"]`}function Rf(e){return`script[async]`+e}function zf(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+jt(n.href)+`"]`);if(r)return t.instance=r,ft(r),r;var i=m({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),ft(r),Ld(r,`style`,i),Bf(r,n.precedence,e),t.instance=r;case`stylesheet`:i=Nf(n.href);var a=e.querySelector(Pf(i));if(a)return t.state.loading|=4,t.instance=a,ft(a),a;r=Ff(n),(i=_f.get(i))&&Vf(r,i),a=(e.ownerDocument||e).createElement(`link`),ft(a);var s=a;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Ld(a,`link`,r),t.state.loading|=4,Bf(a,n.precedence,e),t.instance=a;case`script`:return a=Lf(n.src),(i=e.querySelector(Rf(a)))?(t.instance=i,ft(i),i):(r=n,(i=_f.get(a))&&(r=m({},n),Hf(r,i)),e=e.ownerDocument||e,i=e.createElement(`script`),ft(i),Ld(i,`link`,r),e.head.appendChild(i),t.instance=i);case`void`:return null;default:throw Error(o(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Bf(r,n.precedence,e));return t.instance}function Bf(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Vf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function Hf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Uf=null;function Wf(e,t,n){if(Uf===null){var r=new Map,i=Uf=new Map;i.set(n,r)}else i=Uf,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[ot]||a[$e]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function Gf(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function Kf(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function qf(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Jf(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Nf(r.href),a=t.querySelector(Pf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=Zf.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,ft(a);return}a=t.ownerDocument||t,r=Ff(r),(i=_f.get(i))&&Vf(r,i),a=a.createElement(`link`),ft(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Ld(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=Zf.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var Yf=0;function Xf(e,t){return e.stylesheets&&e.count===0&&$f(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&$f(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&Yf===0&&(Yf=62500*Bd());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&$f(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>Yf?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function Zf(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)$f(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Qf=null;function $f(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Qf=new Map,t.forEach(ep,e),Qf=null,Zf.call(e))}function ep(e,t){if(!(t.state.loading&4)){var n=Qf.get(e);if(n)var r=n.get(null);else{n=new Map,Qf.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=Zf.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var tp={$$typeof:S,Provider:null,Consumer:null,_currentValue:L,_currentValue2:L,_threadCount:0};function np(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=He(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=He(0),this.hiddenUpdates=He(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.incompleteTransitions=new Map}function rp(e,t,n,r,i,a,o,s,c,l,u,d){return e=new np(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=ei(3,null,null,t),e.current=a,a.stateNode=e,t=ta(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},Pa(a),e}function ip(e){return e?(e=Qr,e):Qr}function ap(e,t,n,r,i,a){i=ip(i),r.context===null?r.context=i:r.pendingContext=i,r=Ia(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=La(e,r,t),n!==null&&(hu(n,e,t),Ra(n,e,t))}function op(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function sp(e,t){op(e,t),(e=e.alternate)&&op(e,t)}function cp(e){if(e.tag===13||e.tag===31){var t=Yr(e,67108864);t!==null&&hu(t,e,67108864),sp(e,67108864)}}function lp(e){if(e.tag===13||e.tag===31){var t=pu();t=Je(t);var n=Yr(e,t);n!==null&&hu(n,e,t),sp(e,t)}}var up=!0;function dp(e,t,n,r){var i=F.T;F.T=null;var a=I.p;try{I.p=2,pp(e,t,n,r)}finally{I.p=a,F.T=i}}function fp(e,t,n,r){var i=F.T;F.T=null;var a=I.p;try{I.p=8,pp(e,t,n,r)}finally{I.p=a,F.T=i}}function pp(e,t,n,r){if(up){var i=mp(r);if(i===null)Ed(e,t,r,hp,n),Ep(e,r);else if(Op(i,e,t,n,r))r.stopPropagation();else if(Ep(e,r),t&4&&-1<Tp.indexOf(e)){for(;i!==null;){var a=lt(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=Le(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-Ae(o);s.entanglements[1]|=c,o&=~c}id(a),!(Il&6)&&(tu=be()+500,ad(0,!1))}}break;case 31:case 13:s=Yr(a,2),s!==null&&hu(s,a,2),bu(),sp(a,2)}if(a=mp(r),a===null&&Ed(e,t,r,hp,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else Ed(e,t,r,null,n)}}function mp(e){return e=Jt(e),gp(e)}var hp=null;function gp(e){if(hp=null,e=ct(e),e!==null){var t=c(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=l(t),e!==null)return e;e=null}else if(n===31){if(e=u(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return hp=e,null}function _p(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`resize`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(xe()){case Se:return 2;case U:return 8;case Ce:case we:return 32;case W:return 268435456;default:return 32}default:return 32}}var vp=!1,yp=null,bp=null,xp=null,Sp=new Map,Cp=new Map,wp=[],Tp=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset`.split(` `);function Ep(e,t){switch(e){case`focusin`:case`focusout`:yp=null;break;case`dragenter`:case`dragleave`:bp=null;break;case`mouseover`:case`mouseout`:xp=null;break;case`pointerover`:case`pointerout`:Sp.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:Cp.delete(t.pointerId)}}function Dp(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=lt(t),t!==null&&cp(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Op(e,t,n,r,i){switch(t){case`focusin`:return yp=Dp(yp,e,t,n,r,i),!0;case`dragenter`:return bp=Dp(bp,e,t,n,r,i),!0;case`mouseover`:return xp=Dp(xp,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return Sp.set(a,Dp(Sp.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,Cp.set(a,Dp(Cp.get(a)||null,e,t,n,r,i)),!0}return!1}function kp(e){var t=ct(e.target);if(t!==null){var n=c(t);if(n!==null){if(t=n.tag,t===13){if(t=l(n),t!==null){e.blockedOn=t,Ze(e.priority,function(){lp(n)});return}}else if(t===31){if(t=u(n),t!==null){e.blockedOn=t,Ze(e.priority,function(){lp(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Ap(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=mp(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);qt=r,n.target.dispatchEvent(r),qt=null}else return t=lt(n),t!==null&&cp(t),e.blockedOn=n,!1;t.shift()}return!0}function jp(e,t,n){Ap(e)&&n.delete(t)}function Mp(){vp=!1,yp!==null&&Ap(yp)&&(yp=null),bp!==null&&Ap(bp)&&(bp=null),xp!==null&&Ap(xp)&&(xp=null),Sp.forEach(jp),Cp.forEach(jp)}function Np(e,n){e.blockedOn===n&&(e.blockedOn=null,vp||(vp=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Mp)))}var Pp=null;function Fp(e){Pp!==e&&(Pp=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Pp===e&&(Pp=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(gp(r||n)===null)continue;break}var a=lt(n);a!==null&&(e.splice(t,3),t-=3,bs(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Ip(e){function t(t){return Np(t,e)}yp!==null&&Np(yp,e),bp!==null&&Np(bp,e),xp!==null&&Np(xp,e),Sp.forEach(t),Cp.forEach(t);for(var n=0;n<wp.length;n++){var r=wp[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<wp.length&&(n=wp[0],n.blockedOn===null);)kp(n),n.blockedOn===null&&wp.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[et]||null;if(typeof a==`function`)o||Fp(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[et]||null)s=o.formAction;else if(gp(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Fp(n)}}}function Lp(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function Rp(e){this._internalRoot=e}zp.prototype.render=Rp.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(o(409));var n=t.current;ap(n,pu(),e,t,null,null)},zp.prototype.unmount=Rp.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;ap(e.current,2,null,e,null,null),bu(),t[tt]=null}};function zp(e){this._internalRoot=e}zp.prototype.unstable_scheduleHydration=function(e){if(e){var t=Xe();e={blockedOn:null,target:e,priority:t};for(var n=0;n<wp.length&&t!==0&&t<wp[n].priority;n++);wp.splice(n,0,e),n===0&&kp(e)}};var Bp=n.version;if(Bp!==`19.2.7`)throw Error(o(527,Bp,`19.2.7`));I.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(o(188)):(e=Object.keys(e).join(`,`),Error(o(268,e)));return e=f(t),e=e===null?null:p(e),e=e===null?null:e.stateNode,e};var Vp={bundleType:0,version:`19.2.7`,rendererPackageName:`react-dom`,currentDispatcherRef:F,reconcilerVersion:`19.2.7`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var Hp=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Hp.isDisabled&&Hp.supportsFiber)try{De=Hp.inject(Vp),Oe=Hp}catch{}}e.createRoot=function(e,t){if(!s(e))throw Error(o(299));var n=!1,r=``,i=Us,a=Ws,c=Gs;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(i=t.onUncaughtError),t.onCaughtError!==void 0&&(a=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=rp(e,1,!1,null,null,n,r,null,i,a,c,Lp),e[tt]=t.current,wd(e),new Rp(t)}})),Fl=n(((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=Pl()})),J=e(r(),1),Il=Fl(),Ll=class extends Error{status;diagnostics;constructor(e,t,n=[]){super(t),this.status=e,this.diagnostics=n}};async function Y(e,t,n,r){let i=await fetch(t,{method:e,credentials:`same-origin`,cache:`no-store`,headers:n===void 0?void 0:{"content-type":`application/json`},body:n===void 0?void 0:JSON.stringify(n),signal:r}),a=await i.json().catch(()=>({}));if(!i.ok)throw new Ll(i.status,typeof a.error==`string`?a.error:`The server answered ${i.status}.`,Array.isArray(a.diagnostics)?a.diagnostics:[]);return a}function X(e){return`/api/files/${encodeURIComponent(e)}`}async function Rl(e){return(await Y(`POST`,`/api/session`,{token:e})).session}function zl(e){return Y(`GET`,X(e))}var Bl=6e4;function Vl(e){return new TextEncoder().encode(e).length<=Bl}function Hl(e){return Vl(JSON.stringify(e))}async function Ul(e,t,n={keepalive:!1}){let r=JSON.stringify(t),i;try{i=await fetch(X(e),{method:`PUT`,credentials:`same-origin`,headers:{"content-type":`application/json`},body:r,keepalive:n.keepalive&&Vl(r)})}catch{throw Error(`koboyo isn't answering`)}let a=await i.json().catch(()=>({}));if(i.ok)return{kind:`saved`,revision:a.revision};if(i.status===409){let e=a;return{kind:`conflict`,revision:e.revision,document:e.document}}if(i.status>=500)throw Error(typeof a.error==`string`?a.error:`koboyo could not save`);return{kind:`rejected`,message:typeof a.error==`string`?a.error:`The board could not be saved.`}}async function Wl(e,t){return(await Y(`POST`,`${X(e)}/code`,{choice:t})).code}async function Gl(e,t,n=null){await Y(`POST`,`/api/send`,{file:e,note:t,chosen:n})}function Kl(e,t){return Y(`POST`,`/api/cloud`,e,t)}function ql(e){return Y(`POST`,`/api/cloud/sign-in`,{},e)}var Jl={list(e){return Y(`GET`,`${X(e)}/comments`)},create(e,t,n,r){return Y(`POST`,`${X(e)}/comments`,{id:t,body:n,anchor:r})},reply(e,t,n,r){return Y(`POST`,`${X(e)}/comments/${encodeURIComponent(t)}/replies`,{id:n,body:r})},update(e,t,n){return Y(`PATCH`,`${X(e)}/comments/${encodeURIComponent(t)}`,{body:n})},move(e,t,n){return Y(`PUT`,`${X(e)}/comments/${encodeURIComponent(t)}/anchor`,{anchor:n})},resolve(e,t,n){return Y(`PUT`,`${X(e)}/comments/${encodeURIComponent(t)}/resolved`,{resolved:n})},remove(e,t){return Y(`DELETE`,`${X(e)}/comments/${encodeURIComponent(t)}`)}};function Yl(e){return{x:e.x+e.width+48,y:e.y}}function Xl(e,t,n){if(e.length===0)return[];let r=Math.ceil(Math.sqrt(e.length)),i=Math.max(...e.map(e=>e.width)),a=[],o=t.y;for(let s=0;s*r<e.length;s+=1){let c=e.slice(s*r,s*r+r),l=0;c.forEach((e,r)=>{a.push({x:t.x+r*(i+n),y:o}),l=Math.max(l,e.height)}),o+=l+n}return a}function Zl(e,t,n,r=188){let i=Cn(e),a={right:{x:i.width+r,y:0},left:{x:-(i.width+r),y:0},down:{x:0,y:i.height+r},up:{x:0,y:-(i.height+r)}}[t],o=t===`left`||t===`right`?{x:0,y:i.height+r}:{x:i.width+r,y:0},s=i.x+a.x,c=i.y+a.y,l=n.filter(t=>t.id!==e.id&&(Gn(t)&&t.type!==`figure`||t.type===`table`)),u=()=>l.some(e=>{let t=Cn(e);return s-24<t.x+t.width&&s+i.width+24>t.x&&c-24<t.y+t.height&&c+i.height+24>t.y});for(let e=0;e<50&&u();e+=1)s+=o.x,c+=o.y;return{x:s,y:c,width:i.width,height:i.height}}function Ql(e){return e.type===`arrow`?!e.startBinding&&!e.endBinding:e.type!==`polygon`||e.band==null}function $l(e,t,n){let r=e.filter(Ql);if(r.length<2)return e;let i=r.map(e=>Cn(e,n)),a=wr(i.flatMap(e=>[{x:e.x,y:e.y},{x:e.x+e.width,y:e.y+e.height}])),o=a.x,s=a.x+a.width,c=a.y,l=a.y+a.height,u=(o+s)/2,d=(c+l)/2,f=new Map(r.map((e,n)=>{let r=i[n],a=0,f=0;switch(t){case`left`:a=o-r.x;break;case`right`:a=s-(r.x+r.width);break;case`center-h`:a=u-(r.x+r.width/2);break;case`top`:f=c-r.y;break;case`bottom`:f=l-(r.y+r.height);break;case`middle`:f=d-(r.y+r.height/2);break}return[e.id,Yt(e,{x:a,y:f})]}));return e.map(e=>f.get(e.id)??e)}function eu(e,t,n){let r=e.filter(Ql);if(r.length<3)return e;let i=t===`horizontal`,a=r.map(e=>({shape:e,b:Cn(e,n)}));a.sort((e,t)=>i?e.b.x-t.b.x:e.b.y-t.b.y);let o=e=>i?e.width:e.height,s=e=>i?e.x:e.y,c=s(a[0].b),l=a[a.length-1].b,u=s(l)+o(l),d=a.reduce((e,t)=>e+o(t.b),0),f=(u-c-d)/(a.length-1),p=new Map,m=c;for(let e of a){let t=m-s(e.b);p.set(e.shape.id,Yt(e.shape,i?{x:t,y:0}:{x:0,y:t})),m+=o(e.b)+f}return e.map(e=>p.get(e.id)??e)}function tu(e,t){return{x:t.x,y:t.y,width:t.width,height:t.height,align:`center`,valign:`middle`,fontSize:e.fontSize}}var nu={input:(e,t,n)=>({...n,x:t.x+12,width:t.width-24,align:`left`}),search:(e,t,n)=>{let r=tr(t);return{...n,x:t.x+r,width:t.width-r-12,align:`left`}},dropdown:(e,t,n)=>({...n,x:t.x+12,width:t.width-12-30,align:`left`}),checkbox:(e,t,n)=>({...n,x:t.x+32,width:t.width-32,align:`left`}),radio:(e,t,n)=>({...n,x:t.x+32,width:t.width-32,align:`left`}),toggle:(e,t,n)=>{let r=xn(t);return{...n,x:t.x+r,width:Math.max(40,t.width-r),align:`left`}},slider:(e,t,n)=>({...n,y:t.y+2,height:e.fontSize*1.4,align:`left`,valign:`top`,fontSize:e.fontSize*.7}),heading:(e,t,n)=>({...n,align:`left`,fontSize:e.fontSize*Yn}),badge:(e,t,n)=>({...n,fontSize:e.fontSize*kn}),statusbar:(e,t,n)=>({...n,x:t.x+8,width:Math.max(40,t.width/2),align:`left`,fontSize:e.fontSize*vn}),image:(e,t,n)=>({...n,y:t.y+t.height/2,height:t.height/2,fontSize:e.fontSize*.8}),paragraph:(e,t,n)=>({...n,align:`left`,valign:`top`,fontSize:e.fontSize*.9}),textarea:(e,t,n)=>({...n,x:t.x+12,y:t.y+12,width:t.width-24,height:t.height-24,align:`left`,valign:`top`,fontSize:e.fontSize*.9}),stepbadge:(e,t,n)=>{let r=Math.min(t.width,t.height)/2;return{...n,fontSize:r*.95}},stepper:(e,t,n)=>{let r=Fn(t);return{...n,x:t.x+r,width:Math.max(20,t.width-r*2)}},alert:(e,t,n)=>{let r=mr(t);return{...n,x:t.x+r,width:Math.max(40,t.width-r-12),align:`left`}},card:(e,t,n,r)=>{let i=r===`body`?yi(e).body:yi(e).title;return{...n,x:i.x,y:i.y,width:i.width,height:i.height,align:`left`,valign:`top`,fontSize:i.fontSize}},modal:(e,t,n,r)=>{let i=_i(t);if(r===`primary`||r===`secondary`){let i=Ei(t),a=i?i[r]:null;if(a)return{...n,x:a.x,y:a.y,width:a.width,height:a.height,align:`center`,valign:`middle`,fontSize:e.fontSize*.82}}if(r===`body`){let r=t.y+i+10,a=t.y+t.height-gi(t);return{...n,x:t.x+12,y:r,width:t.width-24,height:Math.max(e.fontSize,a-r),align:`left`,valign:`top`,fontSize:e.fontSize*.92}}return{...n,x:t.x+12,y:t.y,width:Math.max(40,t.width-24-24),height:i,align:`left`}},entity:(e,t,n,r)=>{let i=r===`body`?Xt(e).body:Xt(e).title;return{...n,x:i.x,y:i.y,width:i.width,height:i.height,align:r===`body`?`left`:`center`,valign:r===`body`?`top`:`middle`,fontSize:i.fontSize,lineHeight:at}},breadcrumbs:(e,t,n)=>({...n,align:`left`}),lifeline:(e,t,n)=>({...n,height:rn(e)}),fragment:(e,t,n)=>({...n,x:t.x+12,y:t.y+e.fontSize*wt,width:Math.max(e.fontSize*3,t.width-24),height:lt(e),align:`left`,valign:`middle`,fontSize:e.fontSize}),tooltip:(e,t,n)=>({...n,height:t.height-8})};function ru(e,t=`label`){let n=G(e),r=tu(e,n);return nu[e.kind]?.(e,n,r,t)??r}function iu(e){return e===`card`||e===`modal`||e===`entity`}var au=500;function ou(e){let t=()=>e.temporal.getState(),n=null,r=null;e.historyGate.holding=()=>{if(n===null)return!1;let e=t().pastStates;return(e.length>0?e[e.length-1]:null)!==r};let i=[],a=new Map,o=new WeakMap;function s(){if(i.length===0)return;let n=i,a=e=>{let t=o.get(e);if(t===void 0||!e.shapes)return e;let r=e.shapes;for(let e=t;e<n.length;e+=1){let t=n[e].filter(e=>e.o!==`put`||ae(e.shape));r=de(r,t)}return{...e,shapes:r}},{pastStates:s,futureStates:c}=t(),u=s.map(a),d=r===null?-1:s.indexOf(r);d!==-1&&(r=u[d]);let f=l===null?-1:s.indexOf(l);l=f===-1?null:u[f],e.temporal.setState({pastStates:u,futureStates:c.map(a)}),i=[],o=new WeakMap}let c=!1,l=null,u=0,d=0;function f(){a=new Map;let e=t().pastStates;n=e.length,r=e.length>0?e[e.length-1]:null}function p(){let t=e.getState(),{shapes:n,activeGroupId:r,selectedIds:i,lockRevealId:a}=t;r&&!n.some(e=>e.groupId===r)&&t.setActiveGroupId(null);let o=new Set(n.map(e=>e.id));[...i].some(e=>!o.has(e))&&t.setSelectedIds(new Set([...i].filter(e=>o.has(e)))),a&&!o.has(a)&&t.setLockRevealId(null)}function m(){if(n===null)return;let i=r;n=null,r=null;let a=t().pastStates,o;if(i===null)o=+(a.length>0);else{let e=a.indexOf(i);o=e===-1?1:e+2}a.length>o&&e.temporal.setState({pastStates:a.slice(0,o),futureStates:[]})}function h(){m()}function g(){n!==null&&m(),f()}function _(e){if(d>0)return e();g(),d+=1;try{return e()}finally{--d,h()}}function v(){let e=t().pastStates;return e.length>0?e[e.length-1]:null}function y(t){if(u>0)return t();if(!c)throw Error(`The user stopped this turn, so nothing was applied.`);if(e.getState().viewMode)throw Error(`The board is in view mode, so nothing was changed.`);let i=n===null?null:a;i&&m();let o=l!==null&&v()===l;f();let s=r;u=1;try{return t()}finally{u=0,m(),b(o,s),i&&(f(),a=i)}}function b(n,r){let i=t().pastStates;if(!(i.length>0&&i[i.length-1]!==r))return;let a=n?i.indexOf(l):-1;if(a!==-1&&a===i.length-2){e.temporal.setState({pastStates:i.slice(0,a+1)});return}l=i[i.length-1]}function x(n,r){if(e.getState().viewModeLocked)return 0;m(),l=null,s();let i=0;for(let e=0;e<r;e+=1){let e=t();if(n===`undo`){if(e.pastStates.length===0)break;e.undo()}else{if(e.futureStates.length===0)break;e.redo()}i+=1}return p(),i}function S(e,t){if(!c)throw Error(`The user stopped this turn, so nothing was applied.`);return x(e,t)}return{undo(){x(`undo`,1)},redo(){x(`redo`,1)},stepHistory:x,beginTransaction:g,endTransaction:h,withTransaction:_,async withTransactionAsync(e){g();try{return await e()}finally{h()}},beginAiTurn(){c=!0,l=null},endAiTurn(){c=!1,l=null},ai:{withTransaction:y,stepHistory:S},runWithoutHistory(e){let n=t();n.pause();try{e()}finally{n.resume()}},remoteEditsDuringGesture:()=>a,applyRemote(r){if(r.length===0)return;let c=t(),l=i.length;for(let e of[...c.pastStates,...c.futureStates])o.has(e)||o.set(e,l);i.push(r);for(let e of r){if(e.o===`put`){a.set(e.shape.id,`all`);continue}if(e.o!==`set`)continue;let t=a.get(e.id);if(t===`all`)continue;let n=t??new Set;for(let t of[...Object.keys(e.props),...e.unset??[]])n.add(t);a.set(e.id,n)}c.pause();try{e.getState().applyRemoteOps(r)}finally{c.resume()}i.length>au&&n===null&&s()}}}function su(e){let t=!1,n=()=>{t=document.querySelector(`[data-panel-popup][data-open][data-editor-runtime-id="${e}"]`)!==null};return{install(){return window.addEventListener(`pointerdown`,n,!0),window.addEventListener(`keydown`,n,!0),()=>{window.removeEventListener(`pointerdown`,n,!0),window.removeEventListener(`keydown`,n,!0)}},openAtEvent:()=>t}}function cu(){let e=!1,t=0,n=()=>{t!==0&&(cancelAnimationFrame(t),t=0)};return{guard(){e=!0,n(),t=requestAnimationFrame(()=>{t=requestAnimationFrame(()=>{t=0,e=!1})})},isGuarded:()=>e,release(){n(),e=!1},dispose(){n(),e=!1}}}var lu=800;function uu(){let e=null;return{note(t){e={...t,at:performance.now()}},take(){let t=e;return e=null,!t||performance.now()-t.at>lu?null:{x:t.x,y:t.y}}}}function du(e,t){let n=e.ownerDocument,r=null;if(typeof n.caretPositionFromPoint==`function`){let e=n.caretPositionFromPoint(t.x,t.y);e&&(r=n.createRange(),r.setStart(e.offsetNode,e.offset))}else typeof n.caretRangeFromPoint==`function`&&(r=n.caretRangeFromPoint(t.x,t.y));return!r||!e.contains(r.startContainer)?null:(r.collapse(!0),r)}var fu=320;function pu(e){return e<.5?4*e*e*e:1-(-2*e+2)**3/2}var mu={requestFrame:e=>requestAnimationFrame(e),cancelFrame:e=>cancelAnimationFrame(e),now:()=>performance.now(),addPointerDownListener:e=>(window.addEventListener(`pointerdown`,e,{capture:!0}),()=>window.removeEventListener(`pointerdown`,e,{capture:!0}))};function hu(e=mu){let t=0,n=null,r=()=>{e.cancelFrame(t),n?.(),n=null};return{animate:(i,a,o,s=fu)=>{if(r(),s<=0){o(a);return}let c=e.now();n=e.addPointerDownListener(r);let l=r=>{let u=kr((r-c)/s),d=pu(u);o({x:i.x+(a.x-i.x)*d,y:i.y+(a.y-i.y)*d,zoom:i.zoom+(a.zoom-i.zoom)*d}),u<1?t=e.requestFrame(l):(n?.(),n=null)};t=e.requestFrame(l)},cancel:r,isAnimating:()=>n!==null}}function gu(){let e=null;return{recordFreedSpace(t){e=t},takeFreedSpace(t){return _u(e,t,()=>{e=null})}}}function _u(e,t,n){return n(),e?t.some(t=>t.type===`arrow`||t.type===`line`||t.type===`draw`?!1:zr(G(t),e))?null:{x:e.x,y:e.y}:null}function vu(){return{labelHeights:new Map,labelWidths:new Map}}function yu(e,t){let n=(n,r)=>{let i=e.current?.querySelector(r);return i instanceof HTMLElement?{width:i.offsetWidth,height:i.offsetHeight}:(t.add(n),null)};return{textBounds:e=>n(e,qi(e)),iconLabelBounds:e=>n(e,Ji(`data-icon-label`,e))}}var bu=0;function xu(e){bu+=1;let t=`editor-runtime-${bu}`,n={current:null},r=new Set,i=yu(n,r),a=Se(e,i),o=cu(),s=hu();return{id:t,store:a,history:ou(a),popupGuard:su(t),textEditGuard:o,editEntry:uu(),viewportAnimation:s,placement:gu(),measurements:vu(),measurementRoot:n,measurement:i,measureMisses:r,dispose:()=>{s.cancel(),o.dispose()}}}function Su(e,t,n={}){return{id:$e(),type:`text`,x:e.x,y:e.y,text:``,fontSize:t.fontSize,fontFamily:t.fontFamily,rotation:0,color:t.color===`transparent`?Ht:t.color,opacity:t.opacity,...n}}function Cu(e,t){return t.lockId?e.filter(e=>e.lockId===t.lockId):[t]}function wu(e,t){let n=t?Qe(e,t):void 0;return n&&n.locked?Cu(e,n):[]}function Tu(e){return wn[e.type].hit===`stroke`}var Eu=16;function Du(e){if(!Tu(e))return null;if(e.type===`arrow`){if(e.bendStyle===`elbow`)return St(e);let t=tn(e);return t?Array.from({length:17},(e,n)=>t.pointAt(n/Eu)):[{x:e.x,y:e.y},{x:e.x2,y:e.y2}]}return e.type===`draw`||e.type===`line`?e.points:null}function Ou(e){return e.type===`draw`?gn(e)/2:(`strokeWidth`in e?e.strokeWidth??0:0)/2}function ku(e){return Ou(e)}function Au(e,t){let n=Du(e);if(!n||n.length<2)return!1;let r=Ou(e);for(let e=0;e<n.length-1;e+=1)if(qr(n[e],n[e+1],t,r))return!0;return!1}function ju(e,t,n=16/2){let r=Du(e);if(!r||r.length<2)return!1;let i=n+Ou(e);for(let e=0;e<r.length-1;e+=1)if(Ir(t,r[e],r[e+1])<=i)return!0;return!1}function Mu(e){return e.length>0&&e.every(Tu)}var Nu=.5;function Pu(e,t,n){let r=[...e].reverse().find(e=>{if(!Nn(e))return!1;let{body:r,toLocal:i}=pa(e,n),a=i(t);return Math.abs(a.x-(r.x+r.width/2))<=r.width*Nu/2&&Math.abs(a.y-(r.y+r.height/2))<=r.height*Nu/2});return r?{kind:`label`,id:r.id}:e.some(e=>fa(e,t,n))?{kind:`shape`}:{kind:`empty`}}function Fu(e,t){return Mu(e)?null:pn(e,t)}function Iu(e,t,n,r){let{shapes:i,selectedIds:a,activeGroupId:o,lockRevealId:s}=e,c=Fu(wu(i,s),r);if(c&&Wr(t,c))return null;let l=Fu(ha(i,a),r);if(l&&Wr(t,l))return null;if(n?.locked)return{lockRevealId:n.id,selectedIds:new Set};if(!n)return{lockRevealId:null,selectedIds:new Set};let u=n.groupId&&n.groupId!==o?i.filter(e=>e.groupId===n.groupId).map(e=>e.id):[n.id];return{lockRevealId:null,selectedIds:new Set(u)}}function Lu(){let{notify:e}=_(),t=W(),n=U(e=>e.limitNotice);(0,J.useEffect)(()=>{n&&(e(n.message),t.getState().clearLimitNotice())},[n,e,t]);let r=U(e=>e.opaqueShapes),i=(0,J.useRef)(null);(0,J.useEffect)(()=>{r.length===0||i.current===r||(i.current=r,e(r.length===1?`One shape here was made in a newer version of Koboyo. It is kept and saved, but this version can't show or edit it.`:`${r.length} shapes here were made in a newer version of Koboyo. They are kept and saved, but this version can't show or edit them.`))},[r,e]),(0,J.useEffect)(()=>{let n=Oe(t.getState().shapes.length,`resume`);n&&e(n.message)},[])}function Ru(e){let{onDocumentChange:t,onViewportChange:n,onPreferencesChange:r}=e,i=W();(0,J.useEffect)(()=>i.subscribe((e,i)=>{t&&e.shapes!==i.shapes&&t({version:ge,shapes:e.shapes}),n&&e.viewport!==i.viewport&&e.presentingIndex===null&&n(e.viewport),r&&(e.showGrid!==i.showGrid||e.snapEnabled!==i.snapEnabled||e.presentationAnimation!==i.presentationAnimation||e.showZoomIndicator!==i.showZoomIndicator||e.theme!==i.theme)&&r({showGrid:e.showGrid,snapEnabled:e.snapEnabled,presentationAnimation:e.presentationAnimation,showZoomIndicator:e.showZoomIndicator,theme:e.theme})}),[i,t,n,r])}function zu(e,t){return e*t>=5}function Bu(e){let t=new Set;for(let n of e){let e=`fontSize`in n?n.fontSize:void 0;t.add(typeof e==`number`?e:20)}return[...t].sort((e,t)=>e-t)}function Vu(e,t){return e.filter(e=>zu(e,t)).join(`,`)}var Hu=5/20;function Uu(e,t,n){let r=In(e);if(r.length>0)return yr(G(r.find(e=>!e.slideSkipped)??r[0],n),t);let i=pn(e,n);if(i===null)return null;let a=yr(i,t);if(a.zoom>=Hu)return a;let o=Hu;return{zoom:o,x:t.width/2-(i.x+i.width/2)*o,y:t.height/2-(i.y+i.height/2)*o}}function Wu(e,t){let{publicShare:n}=te(),r=H();(0,J.useLayoutEffect)(()=>{let i=e.current;if(!i)return;let{store:a,measurement:o}=r,{shapes:s,setViewport:c,fitToBounds:l}=a.getState(),u=i.getBoundingClientRect(),d={width:u.width,height:u.height},f={x:u.width/2,y:u.height/2},p=pn(s,o);if(p===null){t||c(e=>({...e,x:f.x,y:f.y}));return}if(n&&!t){let e=Uu(s,d,o);e&&c(()=>e);return}let m=a.getState().viewport,h=t?m:{...m,...f};if(Ar(p,{x:-h.x/h.zoom,y:-h.y/h.zoom,width:u.width/h.zoom,height:u.height/h.zoom})){t||c(e=>({...e,x:f.x,y:f.y}));return}l(p,d)},[e,t,n,r])}function Gu(e,t,n){for(let r of document.elementsFromPoint(t,n)){let t=r.closest(`[data-shape-id]`)?.getAttribute(`data-shape-id`);if(t)return Qe(e,t)??null}return null}var Ku=[`Shift`,`Meta`,`Alt`,`Control`],qu=1e3,Ju=`keydown`,Yu=typeof navigator==`object`?navigator.platform:``,Xu=/Mac|iPod|iPhone|iPad/.test(Yu)?`Meta`:`Control`,Zu=Yu===`Win32`?[`Control`,`Alt`]:[`Alt`];function Qu(e){return!!(e.key&&e.code&&e.getModifierState)}function $u(e){let t=e.target;return e.repeat||e.isComposing||t!==e.currentTarget&&t.matches(`[contenteditable],input,select,textarea`)}function ed(e,t){return typeof e.getModifierState==`function`?e.getModifierState(t)||Zu.includes(t)&&e.getModifierState(`AltGraph`):!1}function td(e){return e.trim().split(` `).map(e=>{let t=e.split(/(?<=\w|\])\+/),n=t.pop(),r=n.match(/^\((.+)\)$/),i=r?RegExp(`^(?:${r[1]})$`,`iv`):n,a=[],o=[];for(let e of t){let t=e.match(/^\[(.*)\]$/),n=t?.[1]??e;n=n===`$mod`?Xu:n,t?o.push(n):a.push(n)}return[a,o,i]})}function nd(e,[t,n,r]){let i=t.includes(`AltGraph`);return!((r instanceof RegExp?!(r.test(e.key)||r.test(e.code)):r.toUpperCase()!==e.key.toUpperCase()&&r!==e.code)||t.find(t=>!ed(e,t))||Ku.find(a=>!t.includes(a)&&!n.includes(a)&&r!==a&&ed(e,a)&&!(i&&Zu.includes(a))))}function rd(e,t={}){let n=t.timeout??qu,r=t.ignore??$u,i=Object.keys(e).map(t=>[t,td(t),e[t]]),a=new Map,o=null;return e=>{if(!Qu(e)||r(e))return;let t=[];for(let[n,r,o]of i){let[i,...s]=a.get(n)||r;if(!nd(e,i))ed(e,e.key)||a.delete(n);else if(s.length>0)a.set(n,s),t.push(n);else if(a.delete(n),t.length)console.warn(`tinykeys: Conflict found, "${n}" did not fire, waiting for:`,t);else{o(e);break}}o&&clearTimeout(o),o=setTimeout(()=>a.clear(),n)}}function id(e,t,n={}){let r=n.event??Ju,i=rd(t,n);return e.addEventListener(r,i,n.capture),()=>{e.removeEventListener(r,i,n.capture)}}var ad=`infinite-canvas/clipboard`,od=1,sd=`data-infinite-canvas-clipboard`;function cd(e,t){return JSON.stringify({type:ad,version:1,copyId:t,shapes:e})}function ld(e){if(!e)return null;let t;try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!=`object`)return null;let n=t;if(n.type!==ad||n.version!==od||!Array.isArray(n.shapes)||n.shapes.length===0)return null;let r=he({version:ge,shapes:n.shapes});return r.status===`valid`?{copyId:typeof n.copyId==`string`?n.copyId:``,shapes:ke(r.document,r.opaque).shapes}:null}function ud(e){if(!e)return null;let t=e.match(RegExp(`${sd}="([^"]*)"`));return t?ld(pd(t[1])):null}function dd(e){let t=[];for(let n of e){let e=n,r=fd(typeof e.text==`string`?e.text:typeof e.label==`string`?e.label:``).trim();r&&t.push(r)}return t.join(`
11
+ `)}function fd(e){return pd(e.replace(/<br\s*\/?>/gi,`
12
+ `).replace(/<\/(p|div|li|h[1-6])>/gi,`
13
+ `).replace(/<[^>]+>/g,``).replace(/&nbsp;/g,` `))}function pd(e){return e.replace(/&lt;/g,`<`).replace(/&gt;/g,`>`).replace(/&quot;/g,`"`).replace(/&#39;/g,`'`).replace(/&amp;/g,`&`)}async function md(e,t){let n=cd(e,t),r=dd(e),i=`<div ${sd}="${ve(n)}">${ve(r)}</div>`;try{await uo(r,i)}catch{}}var hd=`http://www.w3.org/2000/svg`,gd=5e5,_d=300,vd=150,yd={"":1,px:1,pt:96/72,pc:16,in:96,cm:96/2.54,mm:96/25.4};function bd(e){if(!e||e.length>gd)return!1;let t=e.search(/<svg[\s>]/i);if(t===-1)return!1;let n=e.slice(0,t).trim();return n&&!/^(?:<\?xml[^>]*\?>|<!DOCTYPE[^>]*>|<!--[\s\S]*?-->|\s)+$/i.test(n)?!1:/<\/svg\s*>\s*$/i.test(e)}function xd(e){let t=Ad(e.viewBox),n=kd(e.width),r=kd(e.height);return t&&(n&&!r?r=n*(t.height/t.width):r&&!n&&(n=r*(t.width/t.height))),{width:jd(n??t?.width??_d),height:jd(r??t?.height??vd)}}function Sd(e){let t=e.trim();if(!bd(t))return null;let n=Td(t);if(!n)return null;Ed(n);let r=xd({width:n.getAttribute(`width`),height:n.getAttribute(`height`),viewBox:n.getAttribute(`viewBox`)});return n.getAttribute(`viewBox`)||n.setAttribute(`viewBox`,`0 0 ${r.width} ${r.height}`),n.setAttribute(`width`,String(r.width)),n.setAttribute(`height`,String(r.height)),n.setAttribute(`xmlns`,hd),{markup:new XMLSerializer().serializeToString(n),width:r.width,height:r.height}}function Cd(e){let t=new TextEncoder().encode(e),n=``;for(let e=0;e<t.length;e+=8192)n+=String.fromCharCode(...t.subarray(e,e+8192));return`data:image/svg+xml;base64,${btoa(n)}`}function wd(e){let t=Sd(e);return t?new File([t.markup],`pasted.svg`,{type:`image/svg+xml`}):null}function Td(e){let t=e;/\sxmlns\s*=/i.test(t)||(t=t.replace(/<svg\b/i,`<svg xmlns="${hd}"`)),/\sxlink:/i.test(t)&&!/\sxmlns:xlink\s*=/i.test(t)&&(t=t.replace(/<svg\b/i,`<svg xmlns:xlink="http://www.w3.org/1999/xlink"`));let n;try{n=new DOMParser().parseFromString(t,`image/svg+xml`)}catch{return null}if(n.getElementsByTagName(`parsererror`).length>0)return null;let r=n.documentElement;return r.namespaceURI!==hd||r.localName.toLowerCase()!==`svg`?null:r}function Ed(e){for(let t of[...e.querySelectorAll(`script`)])t.remove();let t=e=>{for(let t of[...e.attributes]){let n=t.name.toLowerCase();(n.startsWith(`on`)||Dd(n)&&Od(t.value))&&e.removeAttribute(t.name)}for(let n of e.children)t(n)};t(e)}function Dd(e){return e===`href`||e===`xlink:href`||e===`src`}function Od(e){let t=e.trim().toLowerCase();return t.startsWith(`javascript:`)||t.startsWith(`vbscript:`)||t.startsWith(`data:text/html`)}function kd(e){if(!e)return null;let t=/^\s*([+-]?(?:\d+\.?\d*|\.\d+))\s*([a-z%]*)\s*$/i.exec(e);if(!t)return null;let n=yd[t[2].toLowerCase()];if(n===void 0)return null;let r=Number(t[1])*n;return r>0?r:null}function Ad(e){if(!e)return null;let t=e.trim().split(/[\s,]+/).map(Number);if(t.length!==4||t.some(e=>!Number.isFinite(e)))return null;let[,,n,r]=t;return n<=0||r<=0?null:{width:n,height:r}}function jd(e){return Math.max(1,Math.round(e*100)/100)}var Md=new Set([`image/heic`,`image/heif`,`image/heic-sequence`,`image/heif-sequence`]),Nd=/\.(heic|heif|hif)$/i,Pd=`image/heic`;function Fd(e){let t=e.type.toLowerCase();return Md.has(t)?!0:Nd.test(e.name)?!t.startsWith(`image/`):!1}async function Id(e,t){try{return await createImageBitmap(e)}catch{}if(!t)return null;try{return await t(e)}catch(e){return console.warn(`[koboyo] HEIC decode failed: ${String(e)}`),null}}var Ld=new Set([`image/svg+xml`,`image/gif`]);function Rd(e){return e.type.startsWith(`image/`)||Fd(e)}function zd(e){return new Promise((t,n)=>{let r=new Image;r.onload=()=>t(r),r.onerror=()=>n(Error(`Failed to decode image`)),r.src=e})}function Bd(e,t){let n=Math.max(1,Math.round(e.width)),r=Math.max(1,Math.round(e.height)),i={width:n,height:r,encodeAs:null};if(Ld.has(e.type))return i;let a=Math.min(1,t.maxEdge/Math.max(n,r));if(a>=1&&e.bytes<t.minBytes&&!Md.has(e.type))return i;let o=e.type===`image/png`&&t.keepPng===`always`?`image/png`:`image/jpeg`;return{width:Math.max(1,Math.round(n*a)),height:Math.max(1,Math.round(r*a)),encodeAs:o}}function Vd(e){let t=e.slice(e.indexOf(`,`)+1);return Math.floor(t.length*3/4)}function Hd(e,t,n){try{let{data:r}=e.getImageData(0,0,t,n);for(let e=3;e<r.length;e+=4)if(r[e]<255)return!0;return!1}catch{return!0}}async function Ud(e,t,n){let r=Fd(e)?await Gd(e,n):await Wd(e);if(!r)return null;try{return Kd(r,t)}finally{typeof ImageBitmap<`u`&&r.pixels instanceof ImageBitmap&&r.pixels.close()}}async function Wd(e){let t,n;try{t=await Ui(e),n=await zd(t)}catch{return null}return{pixels:n,width:n.naturalWidth||1,height:n.naturalHeight||1,bytes:e.size,type:e.type||`image/png`,original:t}}async function Gd(e,t){let n=await Id(e,t);return n?{pixels:n,width:n.width||1,height:n.height||1,bytes:e.size,type:Pd,original:null}:null}function Kd(e,t){let n=e.original,r=Bd(e,t),i=()=>n===null?null:{url:n,mediaType:e.type,width:e.width,height:e.height};if(!r.encodeAs)return i();try{let a=document.createElement(`canvas`);a.width=r.width,a.height=r.height;let o=a.getContext(`2d`);if(!o)return i();o.imageSmoothingEnabled=!0,o.imageSmoothingQuality=`high`,o.drawImage(e.pixels,0,0,r.width,r.height);let s=r.encodeAs===`image/jpeg`&&t.keepPng===`when-transparent`&&Hd(o,r.width,r.height)?`image/png`:r.encodeAs,c=s===`image/png`?a.toDataURL(`image/png`):a.toDataURL(`image/jpeg`,t.quality),l=r.width===e.width&&r.height===e.height;return n!==null&&l&&Vd(c)>=Vd(n)?i():{url:c,mediaType:s,width:r.width,height:r.height}}catch{return i()}}function qd(e,t,n){let r=e.clipboardData,i=ud(r?.getData(`text/html`)??``)??ld(r?.getData(`text/plain`)??``);if(i){e.preventDefault(),i.copyId===t.clipboardCopyId()&&t.hasClipboard()?t.pasteClipboard():t.pasteExternal(i.shapes,i.copyId);return}let a=wd(r?.getData(`text/plain`)??``);if(a){e.preventDefault(),t.addImageFromFile(a);return}let o=qo(r?.getData(`text/plain`)??``);if(o){e.preventDefault(),t.pasteEmbed(o);return}let s=r?.getData(`text/plain`)??``,c=ho(r?.getData(`text/html`)??``),l=c?null:mo(s),u=c||l?null:So(s),d=c??l??(u&&u.length>1?u:null);if(d){e.preventDefault(),t.pasteGrid(d);return}let f=null;if(r?.items){for(let e of r.items)if(e.type.startsWith(`image/`)){f=e.getAsFile();break}}if(!f&&r&&(f=[...r.files].find(Rd)??null),f){e.preventDefault(),t.addImageFromFile(f);return}if(r&&r.files.length>0){e.preventDefault(),n(`Unsupported file type`);return}let p=(r?.getData(`text/plain`)??``).trim();if(p){e.preventDefault(),t.pasteText(p);return}if(t.hasClipboard()){e.preventDefault(),t.pasteClipboard();return}n(`Nothing to paste`)}function Jd(e){if(e.type===`line`)return e.points;if(e.type===`arrow`){let t=e.elbowPoints??e.elbowRoute;return e.bendStyle===`elbow`&&t&&t.length>=2?t:[{x:e.x,y:e.y},{x:e.x2,y:e.y2}]}return null}function Yd(e){return e.type===`line`||e.type===`arrow`&&e.bendStyle!==`elbow`&&!e.bend}function Xd(e,t){let n=[];for(let r of e){if(r.id===t||r.type===`draw`)continue;if(r.type===`line`){let e=r.points.length-1;r.points.forEach((t,i)=>{n.push({point:t,attach:{shapeId:r.id,seg:i===e?e-1:i,t:+(i===e)}})});continue}if(r.type===`arrow`){n.push({point:{x:r.x,y:r.y},attach:{shapeId:r.id,seg:0,t:0}},{point:{x:r.x2,y:r.y2},attach:{shapeId:r.id,seg:0,t:1}});continue}let{body:e,toWorld:i}=pa(r),a=[e.x,e.x+e.width/2,e.x+e.width],o=[e.y,e.y+e.height/2,e.y+e.height];for(let e of a)for(let t of o)n.push({point:i({x:e,y:t}),attach:null})}return n}function Zd(e,t){let n=[];for(let r of e){if(r.id===t||r.type!==`line`&&r.type!==`arrow`||r.type===`arrow`&&r.bendStyle!==`elbow`&&r.bend)continue;let e=Jd(r);if(!e)continue;let i=Yd(r);for(let t=0;t<e.length-1;t+=1)n.push({a:e[t],b:e[t+1],attach:i?{shapeId:r.id,seg:t,t:0}:null})}return n}var Qd=256,$d=4;function ef(e,t){return`${e},${t}`}function tf(e){let t=new Map;return e.forEach((e,n)=>{let r=ef(Math.floor(e.point.x/Qd),Math.floor(e.point.y/Qd)),i=t.get(r);i?i.push(n):t.set(r,[n])}),t}function nf(e,t,n){let r=Math.floor((t.x-n)/Qd),i=Math.floor((t.x+n)/Qd),a=Math.floor((t.y-n)/Qd),o=Math.floor((t.y+n)/Qd);if(!Number.isFinite(r+i+a+o)||i-r>$d||o-a>$d)return e.points;e.grid??=tf(e.points);let s=[];for(let t=r;t<=i;t+=1)for(let n=a;n<=o;n+=1){let r=e.grid.get(ef(t,n));for(let e of r??[])s.push(e)}return s.sort((e,t)=>e-t),s.map(t=>e.points[t])}var rf=null;function af(e,t,n){if(e===t)return!0;if(e.length!==t.length)return!1;for(let r=0;r<e.length;r+=1)if(e[r]!==t[r]&&(e[r].id!==n||t[r].id!==n))return!1;return!0}function of(e,t){return rf&&rf.excludeId===t&&af(rf.shapes,e,t)||(rf={shapes:e,excludeId:t,points:Xd(e,t),grid:null,segments:null}),rf}function sf(e,t,n){let r=null,i=n;for(let n of t){let t=Mr(e,n.point);t<=i&&(r={point:n.point,attach:n.attach},i=t)}return r}function cf(e,t,n){let r=null,i=n;for(let n of t){let t=Nr(e,n.a,n.b),a=Mr(e,t);if(a<=i){let e=Mr(n.a,n.b);r={point:t,attach:n.attach&&e?{...n.attach,t:Mr(n.a,t)/e}:null},i=a}}return r}function lf(e,t,n,r,i){let a=of(t,r),o=sf(e,nf(a,e,n),n);if(i){let t=o?Mr(e,o.point):n;for(let n of i){let r=Mr(e,n);r<=t&&(o={point:n,attach:null},t=r)}}return o||(a.segments??=Zd(t,r),cf(e,a.segments,n))}function uf(e,t,n){return{...xi(n,e,{fontFamily:t.fontFamily,color:t.color,opacity:t.opacity}),width:0,height:0}}function df(e,t,n){return{id:$e(),type:`icon`,x:e.x,y:e.y,width:0,height:0,rotation:0,source:n.source,name:n.name,label:``,fontSize:24,fontFamily:t.fontFamily,color:t.color,strokeWidth:3,opacity:t.opacity}}function ff(e,t,n){return{id:$e(),type:`rectangle`,kind:n,x:e.x,y:e.y,width:0,height:0,rotation:0,label:``,fontSize:t.fontSize,fontFamily:t.fontFamily,textAlign:t.textAlign,textVAlign:t.textVAlign,textPadding:t.textPadding,color:t.color,fill:t.fill,fillStyle:t.fillStyle,stroke:t.stroke===`auto`?void 0:t.stroke,shadow:t.shadow||void 0,strokeWidth:t.strokeWidth,dash:t.dash,opacity:t.opacity}}function pf(e,t,n){return{id:$e(),type:`figure`,...n===`simple`?{}:{kind:n},...ns(n)?{lanes:[...rs]}:{},...n===`boundary`?{dash:`dashed`}:{},x:e.x,y:e.y,width:0,height:0,rotation:0,label:ts[n],fontSize:t.fontSize,fontFamily:t.fontFamily,color:ci,opacity:t.opacity}}function mf(e,t,n){return{...cs(e,{fontFamily:t.fontFamily,color:ci,opacity:t.opacity},n),width:0,height:0}}function hf(e,t,n=!1){return{id:$e(),type:`draw`,points:[e],color:t.color,strokeWidth:t.strokeWidth,...n?{highlighter:!0}:{},opacity:t.opacity}}function gf(e,t=!0){return{label:``,fontSize:e.fontSize,fontFamily:e.fontFamily,color:e.color,strokeWidth:e.strokeWidth,dash:e.dash,startArrow:t&&e.startArrow,endArrow:t&&e.endArrow,startHead:e.startHead,endHead:e.endHead,opacity:e.opacity}}function _f(e){return{bend:0,bendAlong:0,bow:0,bendStyle:e.bendStyle}}function vf(e){let{world:t,style:n,tool:r,shapes:i,zoom:a,alt:o,measurement:s}=e,c=Fe(i,t,void 0,s),l=r===`line`,u=t,d=null;if(!c&&!o){let e=lf(t,i,10/a);e&&(u=e.point,e.attach&&(d={kind:`path`,...e.attach}))}return{id:$e(),type:`arrow`,x:u.x,y:u.y,x2:u.x,y2:u.y,..._f(n),startBinding:c&&!o?He(c,t,s):d,endBinding:null,...gf(n,!l)}}var yf={rectangle:e=>ff(e.world,e.style,e.shapeKind),figure:e=>pf(e.world,e.style,e.frameKind),chart:e=>mf(e.world,e.style,e.chartKind),arrow:e=>vf({world:e.world,style:e.style,tool:`arrow`,shapes:e.shapes,zoom:e.zoom,alt:e.alt,measurement:e.measurement}),line:e=>vf({world:e.world,style:e.style,tool:`line`,shapes:e.shapes,zoom:e.zoom,alt:e.alt,measurement:e.measurement}),draw:e=>hf(e.world,e.style),highlight:e=>hf(e.world,e.style,!0)},bf={table:{build:(e,t)=>xo(Array.from({length:3},()=>[``,``,``]),e,{fontSize:t.fontSize,fontFamily:t.fontFamily,color:ci,opacity:t.opacity}),edit:!1},sticky:{build:Li,edit:!0},text:{build:Su,edit:!0,untracked:!0}},xf=[`right`,`down`,`left`,`up`];function Sf(e,t){let n=Math.round(cr(e)/90);return xf[((xf.indexOf(t)+n)%4+4)%4]}function Cf(e,t){let n=e.find(e=>t.has(e.id)&&(e.type===`rectangle`||e.type===`icon`));return!n||t.size!==1?null:n}function wf(e){let{shapes:t,selectedIds:n}=e.getState();return Cf(t,n)!==null}function Tf(e,t,n,r,i){let a=e.getState().style,o=G(t),s=G(n),c={x:o.x+o.width/2,y:o.y+o.height/2},l={x:s.x+s.width/2,y:s.y+s.height/2};return{id:$e(),type:`arrow`,x:c.x,y:c.y,x2:(r??l).x,y2:(r??l).y,..._f(a),startBinding:He(t,c),endBinding:r?He(n,r,i):He(n,l),...gf(a)}}function Ef(e,t,n){let r=e.getState();r.addMany([n,Tf(e,t,n)]),r.setSelectedIds(new Set([n.id]))}function Df(e,t,n,r,i){let a=e.getState();a.addMany([Tf(e,t,n,r,i)]),a.setSelectedIds(new Set([n.id]))}function Of(e,t,n){let{shapes:r,selectedIds:i}=e.getState(),a=Cf(r,i);if(!a)return!1;let o=G(a),s=Dn(a,n),c=Zl(a,t,r),l=o.x-s.x,u=o.y-s.y;return Ef(e,a,{...a,id:$e(),x:c.x+l,y:c.y+u,rotation:0,label:``}),!0}function kf(e,t,n){let{shapes:r,selectedIds:i}=e.getState(),a=Cf(r,i);if(!a)return;let o=Fe(r,t,a.id,n);if(o){Df(e,a,o,t,n);return}let s=G(a);Ef(e,a,{...a,id:$e(),x:t.x-s.width/2,y:t.y-s.height/2,rotation:0,label:``})}function Af(e,t,n){let{shapes:r,selectedIds:i}=e.getState(),a=Cf(r,i);return a?Fe(r,t,a.id,n):null}function jf(e,t){let{shapes:n,selectedIds:r}=e.getState(),i=Cf(n,r);return i?Zl(i,t,n):null}var Mf=K(`outline`,`activity`,`Activity`,[[`path`,{d:`M3 12h4l3 8l4 -16l3 8h4`,key:`svg-0`}]]),Nf=K(`outline`,`arrow-bar-to-down`,`ArrowBarToDown`,[[`path`,{d:`M4 20l16 0`,key:`svg-0`}],[`path`,{d:`M12 14l0 -10`,key:`svg-1`}],[`path`,{d:`M12 14l4 -4`,key:`svg-2`}],[`path`,{d:`M12 14l-4 -4`,key:`svg-3`}]]),Pf=K(`outline`,`arrow-bar-to-up`,`ArrowBarToUp`,[[`path`,{d:`M12 10l0 10`,key:`svg-0`}],[`path`,{d:`M12 10l4 4`,key:`svg-1`}],[`path`,{d:`M12 10l-4 4`,key:`svg-2`}],[`path`,{d:`M4 4l16 0`,key:`svg-3`}]]),Ff=K(`outline`,`arrow-forward-up`,`ArrowForwardUp`,[[`path`,{d:`M15 14l4 -4l-4 -4`,key:`svg-0`}],[`path`,{d:`M19 10h-11a4 4 0 1 0 0 8h1`,key:`svg-1`}]]),If=K(`outline`,`at`,`At`,[[`path`,{d:`M8 12a4 4 0 1 0 8 0a4 4 0 1 0 -8 0`,key:`svg-0`}],[`path`,{d:`M16 12v1.5a2.5 2.5 0 0 0 5 0v-1.5a9 9 0 1 0 -5.5 8.28`,key:`svg-1`}]]),Lf=K(`outline`,`ban`,`Ban`,[[`path`,{d:`M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0`,key:`svg-0`}],[`path`,{d:`M5.7 5.7l12.6 12.6`,key:`svg-1`}]]),Rf=K(`outline`,`bell-off`,`BellOff`,[[`path`,{d:`M9.346 5.353c.21 -.129 .428 -.246 .654 -.353a2 2 0 1 1 4 0a7 7 0 0 1 4 6v3m-1 3h-13a4 4 0 0 0 2 -3v-3a6.996 6.996 0 0 1 1.273 -3.707`,key:`svg-0`}],[`path`,{d:`M9 17v1a3 3 0 0 0 6 0v-1`,key:`svg-1`}],[`path`,{d:`M3 3l18 18`,key:`svg-2`}]]),zf=K(`outline`,`bell`,`Bell`,[[`path`,{d:`M10 5a2 2 0 1 1 4 0a7 7 0 0 1 4 6v3a4 4 0 0 0 2 3h-16a4 4 0 0 0 2 -3v-3a7 7 0 0 1 4 -6`,key:`svg-0`}],[`path`,{d:`M9 17v1a3 3 0 0 0 6 0v-1`,key:`svg-1`}]]),Bf=K(`outline`,`bold`,`Bold`,[[`path`,{d:`M7 5h6a3.5 3.5 0 0 1 0 7h-6l0 -7`,key:`svg-0`}],[`path`,{d:`M13 12h1a3.5 3.5 0 0 1 0 7h-7v-7`,key:`svg-1`}]]),Vf=K(`outline`,`border-corner-rounded`,`BorderCornerRounded`,[[`path`,{d:`M4 20v-10a6 6 0 0 1 6 -6h10`,key:`svg-0`}]]),Hf=K(`outline`,`border-corner-square`,`BorderCornerSquare`,[[`path`,{d:`M4 20v-15a1 1 0 0 1 1 -1h15`,key:`svg-0`}]]),Uf=K(`outline`,`box-align-top-left`,`BoxAlignTopLeft`,[[`path`,{d:`M11 5v5a1 1 0 0 1 -1 1h-5a1 1 0 0 1 -1 -1v-5a1 1 0 0 1 1 -1h5a1 1 0 0 1 1 1`,key:`svg-0`}],[`path`,{d:`M15 4h-.01`,key:`svg-1`}],[`path`,{d:`M20 4h-.01`,key:`svg-2`}],[`path`,{d:`M20 9h-.01`,key:`svg-3`}],[`path`,{d:`M20 15h-.01`,key:`svg-4`}],[`path`,{d:`M4 15h-.01`,key:`svg-5`}],[`path`,{d:`M20 20h-.01`,key:`svg-6`}],[`path`,{d:`M15 20h-.01`,key:`svg-7`}],[`path`,{d:`M9 20h-.01`,key:`svg-8`}],[`path`,{d:`M4 20h-.01`,key:`svg-9`}]]),Wf=K(`outline`,`brand-codepen`,`BrandCodepen`,[[`path`,{d:`M3 15l9 6l9 -6l-9 -6l-9 6`,key:`svg-0`}],[`path`,{d:`M3 9l9 6l9 -6l-9 -6l-9 6`,key:`svg-1`}],[`path`,{d:`M3 9l0 6`,key:`svg-2`}],[`path`,{d:`M21 9l0 6`,key:`svg-3`}],[`path`,{d:`M12 3l0 6`,key:`svg-4`}],[`path`,{d:`M12 15l0 6`,key:`svg-5`}]]),Gf=K(`outline`,`brand-codesandbox`,`BrandCodesandbox`,[[`path`,{d:`M20 7.5v9l-4 2.25l-4 2.25l-4 -2.25l-4 -2.25v-9l4 -2.25l4 -2.25l4 2.25l4 2.25`,key:`svg-0`}],[`path`,{d:`M12 12l4 -2.25l4 -2.25`,key:`svg-1`}],[`path`,{d:`M12 12l0 9`,key:`svg-2`}],[`path`,{d:`M12 12l-4 -2.25l-4 -2.25`,key:`svg-3`}],[`path`,{d:`M20 12l-4 2v4.75`,key:`svg-4`}],[`path`,{d:`M4 12l4 2l0 4.75`,key:`svg-5`}],[`path`,{d:`M8 5.25l4 2.25l4 -2.25`,key:`svg-6`}]]),Kf=K(`outline`,`brand-figma`,`BrandFigma`,[[`path`,{d:`M12 12a3 3 0 1 0 6 0a3 3 0 1 0 -6 0`,key:`svg-0`}],[`path`,{d:`M6 6a3 3 0 0 1 3 -3h6a3 3 0 0 1 3 3a3 3 0 0 1 -3 3h-6a3 3 0 0 1 -3 -3`,key:`svg-1`}],[`path`,{d:`M9 9a3 3 0 0 0 0 6h3m-3 0a3 3 0 1 0 3 3v-15`,key:`svg-2`}]]),qf=K(`outline`,`brand-spotify`,`BrandSpotify`,[[`path`,{d:`M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0`,key:`svg-0`}],[`path`,{d:`M8 11.973c2.5 -1.473 5.5 -.973 7.5 .527`,key:`svg-1`}],[`path`,{d:`M9 15c1.5 -1 4 -1 5 .5`,key:`svg-2`}],[`path`,{d:`M7 9c2 -1 6 -2 10 .5`,key:`svg-3`}]]),Jf=K(`outline`,`brand-vimeo`,`BrandVimeo`,[[`path`,{d:`M3 8.5l1 1s1.5 -1.102 2 -.5c.509 .609 1.863 7.65 2.5 9c.556 1.184 1.978 2.89 4 1.5c2 -1.5 7.5 -5.5 8.5 -11.5c.444 -2.661 -1 -4 -2.5 -4c-2 0 -4.047 1.202 -4.5 4c2.05 -1.254 2.551 1 1.5 3c-1.052 2 -2 3 -2.5 3c-.49 0 -.924 -1.165 -1.5 -3.5c-.59 -2.42 -.5 -6.5 -3 -6.5s-5.5 4.5 -5.5 4.5`,key:`svg-0`}]]),Yf=K(`outline`,`chart-radar`,`ChartRadar`,[[`path`,{d:`M12 3l9.5 7l-3.5 11h-12l-3.5 -11l9.5 -7`,key:`svg-0`}],[`path`,{d:`M12 7.5l5.5 4l-2.5 5.5h-6.5l-2 -5.5l5.5 -4`,key:`svg-1`}],[`path`,{d:`M2.5 10l9.5 3l9.5 -3`,key:`svg-2`}],[`path`,{d:`M12 3v10l6 8`,key:`svg-3`}],[`path`,{d:`M6 21l6 -8`,key:`svg-4`}]]),Xf=K(`outline`,`chevron-up`,`ChevronUp`,[[`path`,{d:`M6 15l6 -6l6 6`,key:`svg-0`}]]),Zf=K(`outline`,`clipboard`,`Clipboard`,[[`path`,{d:`M9 5h-2a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-12a2 2 0 0 0 -2 -2h-2`,key:`svg-0`}],[`path`,{d:`M9 5a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2`,key:`svg-1`}]]),Qf=K(`outline`,`clock`,`Clock`,[[`path`,{d:`M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0`,key:`svg-0`}],[`path`,{d:`M12 7v5l3 3`,key:`svg-1`}]]),$f=K(`outline`,`cloud-upload`,`CloudUpload`,[[`path`,{d:`M7 18a4.6 4.4 0 0 1 0 -9a5 4.5 0 0 1 11 2h1a3.5 3.5 0 0 1 0 7h-1`,key:`svg-0`}],[`path`,{d:`M9 15l3 -3l3 3`,key:`svg-1`}],[`path`,{d:`M12 12l0 9`,key:`svg-2`}]]),ep=K(`outline`,`dimensions`,`Dimensions`,[[`path`,{d:`M3 5h11`,key:`svg-0`}],[`path`,{d:`M12 7l2 -2l-2 -2`,key:`svg-1`}],[`path`,{d:`M5 3l-2 2l2 2`,key:`svg-2`}],[`path`,{d:`M19 10v11`,key:`svg-3`}],[`path`,{d:`M17 19l2 2l2 -2`,key:`svg-4`}],[`path`,{d:`M21 12l-2 -2l-2 2`,key:`svg-5`}],[`path`,{d:`M3 12a2 2 0 0 1 2 -2h7a2 2 0 0 1 2 2v7a2 2 0 0 1 -2 2h-7a2 2 0 0 1 -2 -2l0 -7`,key:`svg-6`}]]),tp=K(`outline`,`dots-vertical`,`DotsVertical`,[[`path`,{d:`M11 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`,key:`svg-0`}],[`path`,{d:`M11 19a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`,key:`svg-1`}],[`path`,{d:`M11 5a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`,key:`svg-2`}]]),np=K(`outline`,`file-export`,`FileExport`,[[`path`,{d:`M14 3v4a1 1 0 0 0 1 1h4`,key:`svg-0`}],[`path`,{d:`M11.5 21h-4.5a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v5m-5 6h7m-3 -3l3 3l-3 3`,key:`svg-1`}]]),rp=K(`outline`,`file-import`,`FileImport`,[[`path`,{d:`M14 3v4a1 1 0 0 0 1 1h4`,key:`svg-0`}],[`path`,{d:`M5 13v-8a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2h-5.5m-9.5 -2h7m-3 -3l3 3l-3 3`,key:`svg-1`}]]),ip=K(`outline`,`file-vector`,`FileVector`,[[`path`,{d:`M14 3v4a1 1 0 0 0 1 1h4`,key:`svg-0`}],[`path`,{d:`M8 16.5a1.5 1.5 0 1 0 3 0a1.5 1.5 0 1 0 -3 0`,key:`svg-1`}],[`path`,{d:`M13 12.5a1.5 1.5 0 1 0 3 0a1.5 1.5 0 1 0 -3 0`,key:`svg-2`}],[`path`,{d:`M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2`,key:`svg-3`}],[`path`,{d:`M9.5 15a2.5 2.5 0 0 1 2.5 -2.5h1`,key:`svg-4`}]]),ap=K(`outline`,`folder-open`,`FolderOpen`,[[`path`,{d:`M5 19l2.757 -7.351a1 1 0 0 1 .936 -.649h12.307a1 1 0 0 1 .986 1.164l-.996 5.211a2 2 0 0 1 -1.964 1.625h-14.026a2 2 0 0 1 -2 -2v-11a2 2 0 0 1 2 -2h4l3 3h7a2 2 0 0 1 2 2v2`,key:`svg-0`}]]),op=K(`outline`,`folder-share`,`FolderShare`,[[`path`,{d:`M13 19h-8a2 2 0 0 1 -2 -2v-11a2 2 0 0 1 2 -2h4l3 3h7a2 2 0 0 1 2 2v4`,key:`svg-0`}],[`path`,{d:`M16 22l5 -5`,key:`svg-1`}],[`path`,{d:`M21 21.5v-4.5h-4.5`,key:`svg-2`}]]),sp=K(`outline`,`git-fork`,`GitFork`,[[`path`,{d:`M10 18a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`,key:`svg-0`}],[`path`,{d:`M5 6a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`,key:`svg-1`}],[`path`,{d:`M15 6a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`,key:`svg-2`}],[`path`,{d:`M7 8v2a2 2 0 0 0 2 2h6a2 2 0 0 0 2 -2v-2`,key:`svg-3`}],[`path`,{d:`M12 12l0 4`,key:`svg-4`}]]),cp=K(`outline`,`grid-dots`,`GridDots`,[[`path`,{d:`M4 5a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`,key:`svg-0`}],[`path`,{d:`M11 5a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`,key:`svg-1`}],[`path`,{d:`M18 5a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`,key:`svg-2`}],[`path`,{d:`M4 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`,key:`svg-3`}],[`path`,{d:`M11 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`,key:`svg-4`}],[`path`,{d:`M18 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`,key:`svg-5`}],[`path`,{d:`M4 19a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`,key:`svg-6`}],[`path`,{d:`M11 19a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`,key:`svg-7`}],[`path`,{d:`M18 19a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`,key:`svg-8`}]]),lp=K(`outline`,`hand-finger`,`HandFinger`,[[`path`,{d:`M8 13v-8.5a1.5 1.5 0 0 1 3 0v7.5`,key:`svg-0`}],[`path`,{d:`M11 11.5v-2a1.5 1.5 0 1 1 3 0v2.5`,key:`svg-1`}],[`path`,{d:`M14 10.5a1.5 1.5 0 0 1 3 0v1.5`,key:`svg-2`}],[`path`,{d:`M17 11.5a1.5 1.5 0 0 1 3 0v4.5a6 6 0 0 1 -6 6h-2h.208a6 6 0 0 1 -5.012 -2.7a69.74 69.74 0 0 1 -.196 -.3c-.312 -.479 -1.407 -2.388 -3.286 -5.728a1.5 1.5 0 0 1 .536 -2.022a1.867 1.867 0 0 1 2.28 .28l1.47 1.47`,key:`svg-3`}]]),up=K(`outline`,`italic`,`Italic`,[[`path`,{d:`M11 5l6 0`,key:`svg-0`}],[`path`,{d:`M7 19l6 0`,key:`svg-1`}],[`path`,{d:`M14 5l-4 14`,key:`svg-2`}]]),dp=K(`outline`,`layout-align-bottom`,`LayoutAlignBottom`,[[`path`,{d:`M4 20l16 0`,key:`svg-0`}],[`path`,{d:`M9 6a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2l0 -8`,key:`svg-1`}]]),fp=K(`outline`,`layout-align-center`,`LayoutAlignCenter`,[[`path`,{d:`M12 4l0 5`,key:`svg-0`}],[`path`,{d:`M12 15l0 5`,key:`svg-1`}],[`path`,{d:`M6 11a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v2a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2l0 -2`,key:`svg-2`}]]),pp=K(`outline`,`layout-align-left`,`LayoutAlignLeft`,[[`path`,{d:`M4 4l0 16`,key:`svg-0`}],[`path`,{d:`M8 11a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v2a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2l0 -2`,key:`svg-1`}]]),mp=K(`outline`,`layout-align-middle`,`LayoutAlignMiddle`,[[`path`,{d:`M4 12l5 0`,key:`svg-0`}],[`path`,{d:`M15 12l5 0`,key:`svg-1`}],[`path`,{d:`M9 8a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2l0 -8`,key:`svg-2`}]]),hp=K(`outline`,`layout-align-right`,`LayoutAlignRight`,[[`path`,{d:`M20 4l0 16`,key:`svg-0`}],[`path`,{d:`M4 11a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v2a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2l0 -2`,key:`svg-1`}]]),gp=K(`outline`,`layout-align-top`,`LayoutAlignTop`,[[`path`,{d:`M4 4l16 0`,key:`svg-0`}],[`path`,{d:`M9 10a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2l0 -8`,key:`svg-1`}]]),_p=K(`outline`,`layout-board-split`,`LayoutBoardSplit`,[[`path`,{d:`M4 6a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2l0 -12`,key:`svg-0`}],[`path`,{d:`M4 12h8`,key:`svg-1`}],[`path`,{d:`M12 15h8`,key:`svg-2`}],[`path`,{d:`M12 9h8`,key:`svg-3`}],[`path`,{d:`M12 4v16`,key:`svg-4`}]]),vp=K(`outline`,`layout-board`,`LayoutBoard`,[[`path`,{d:`M4 6a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2l0 -12`,key:`svg-0`}],[`path`,{d:`M4 9h8`,key:`svg-1`}],[`path`,{d:`M12 15h8`,key:`svg-2`}],[`path`,{d:`M12 4v16`,key:`svg-3`}]]),yp=K(`outline`,`layout-distribute-horizontal`,`LayoutDistributeHorizontal`,[[`path`,{d:`M4 4l16 0`,key:`svg-0`}],[`path`,{d:`M4 20l16 0`,key:`svg-1`}],[`path`,{d:`M6 11a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v2a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2l0 -2`,key:`svg-2`}]]),bp=K(`outline`,`layout-distribute-vertical`,`LayoutDistributeVertical`,[[`path`,{d:`M4 4l0 16`,key:`svg-0`}],[`path`,{d:`M20 4l0 16`,key:`svg-1`}],[`path`,{d:`M9 8a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2l0 -8`,key:`svg-2`}]]),xp=K(`outline`,`layout-grid-add`,`LayoutGridAdd`,[[`path`,{d:`M4 5a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4`,key:`svg-0`}],[`path`,{d:`M14 5a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4`,key:`svg-1`}],[`path`,{d:`M4 15a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4`,key:`svg-2`}],[`path`,{d:`M14 17h6m-3 -3v6`,key:`svg-3`}]]),Sp=K(`outline`,`list-check`,`ListCheck`,[[`path`,{d:`M3.5 5.5l1.5 1.5l2.5 -2.5`,key:`svg-0`}],[`path`,{d:`M3.5 11.5l1.5 1.5l2.5 -2.5`,key:`svg-1`}],[`path`,{d:`M3.5 17.5l1.5 1.5l2.5 -2.5`,key:`svg-2`}],[`path`,{d:`M11 6l9 0`,key:`svg-3`}],[`path`,{d:`M11 12l9 0`,key:`svg-4`}],[`path`,{d:`M11 18l9 0`,key:`svg-5`}]]),Cp=K(`outline`,`lock-open`,`LockOpen`,[[`path`,{d:`M5 13a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v6a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2l0 -6`,key:`svg-0`}],[`path`,{d:`M11 16a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`,key:`svg-1`}],[`path`,{d:`M8 11v-5a4 4 0 0 1 8 0`,key:`svg-2`}]]),wp=K(`outline`,`lock`,`Lock`,[[`path`,{d:`M5 13a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v6a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-6`,key:`svg-0`}],[`path`,{d:`M11 16a1 1 0 1 0 2 0a1 1 0 0 0 -2 0`,key:`svg-1`}],[`path`,{d:`M8 11v-4a4 4 0 1 1 8 0v4`,key:`svg-2`}]]),Tp=K(`outline`,`login-2`,`Login2`,[[`path`,{d:`M9 8v-2a2 2 0 0 1 2 -2h7a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-7a2 2 0 0 1 -2 -2v-2`,key:`svg-0`}],[`path`,{d:`M3 12h13l-3 -3`,key:`svg-1`}],[`path`,{d:`M13 15l3 -3`,key:`svg-2`}]]),Ep=K(`outline`,`logout`,`Logout`,[[`path`,{d:`M14 8v-2a2 2 0 0 0 -2 -2h-7a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h7a2 2 0 0 0 2 -2v-2`,key:`svg-0`}],[`path`,{d:`M9 12h12l-3 -3`,key:`svg-1`}],[`path`,{d:`M18 15l3 -3`,key:`svg-2`}]]),Dp=K(`outline`,`map-pin`,`MapPin`,[[`path`,{d:`M9 11a3 3 0 1 0 6 0a3 3 0 0 0 -6 0`,key:`svg-0`}],[`path`,{d:`M17.657 16.657l-4.243 4.243a2 2 0 0 1 -2.827 0l-4.244 -4.243a8 8 0 1 1 11.314 0`,key:`svg-1`}]]),Op=K(`outline`,`maximize`,`Maximize`,[[`path`,{d:`M4 8v-2a2 2 0 0 1 2 -2h2`,key:`svg-0`}],[`path`,{d:`M4 16v2a2 2 0 0 0 2 2h2`,key:`svg-1`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v2`,key:`svg-2`}],[`path`,{d:`M16 20h2a2 2 0 0 0 2 -2v-2`,key:`svg-3`}]]),kp=K(`outline`,`message-circle`,`MessageCircle`,[[`path`,{d:`M3 20l1.3 -3.9c-2.324 -3.437 -1.426 -7.872 2.1 -10.374c3.526 -2.501 8.59 -2.296 11.845 .48c3.255 2.777 3.695 7.266 1.029 10.501c-2.666 3.235 -7.615 4.215 -11.574 2.293l-4.7 1`,key:`svg-0`}]]),Ap=K(`outline`,`message-off`,`MessageOff`,[[`path`,{d:`M8 9h1m4 0h3`,key:`svg-0`}],[`path`,{d:`M8 13h5`,key:`svg-1`}],[`path`,{d:`M8 4h10a3 3 0 0 1 3 3v8c0 .577 -.163 1.116 -.445 1.573m-2.555 1.427h-5l-5 3v-3h-2a3 3 0 0 1 -3 -3v-8c0 -1.085 .576 -2.036 1.439 -2.562`,key:`svg-2`}],[`path`,{d:`M3 3l18 18`,key:`svg-3`}]]),jp=K(`outline`,`messages`,`Messages`,[[`path`,{d:`M21 14l-3 -3h-7a1 1 0 0 1 -1 -1v-6a1 1 0 0 1 1 -1h9a1 1 0 0 1 1 1v10`,key:`svg-0`}],[`path`,{d:`M14 15v2a1 1 0 0 1 -1 1h-7l-3 3v-10a1 1 0 0 1 1 -1h2`,key:`svg-1`}]]),Mp=K(`outline`,`mood-plus`,`MoodPlus`,[[`path`,{d:`M20.985 12.528a9 9 0 1 0 -8.45 8.456`,key:`svg-0`}],[`path`,{d:`M16 19h6`,key:`svg-1`}],[`path`,{d:`M19 16v6`,key:`svg-2`}],[`path`,{d:`M9 10h.01`,key:`svg-3`}],[`path`,{d:`M15 10h.01`,key:`svg-4`}],[`path`,{d:`M9.5 15c.658 .64 1.56 1 2.5 1s1.842 -.36 2.5 -1`,key:`svg-5`}]]),Np=K(`outline`,`moon`,`Moon`,[[`path`,{d:`M12 3c.132 0 .263 0 .393 0a7.5 7.5 0 0 0 7.92 12.446a9 9 0 1 1 -8.313 -12.454l0 .008`,key:`svg-0`}]]),Pp=K(`outline`,`pilcrow`,`Pilcrow`,[[`path`,{d:`M13 4v16`,key:`svg-0`}],[`path`,{d:`M17 4v16`,key:`svg-1`}],[`path`,{d:`M19 4h-9.5a4.5 4.5 0 0 0 0 9h3.5`,key:`svg-2`}]]),Fp=K(`outline`,`rectangle-vertical`,`RectangleVertical`,[[`path`,{d:`M5 5a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2l0 -14`,key:`svg-0`}]]),Ip=K(`outline`,`select-all`,`SelectAll`,[[`path`,{d:`M8 9a1 1 0 0 1 1 -1h6a1 1 0 0 1 1 1v6a1 1 0 0 1 -1 1h-6a1 1 0 0 1 -1 -1l0 -6`,key:`svg-0`}],[`path`,{d:`M12 20v.01`,key:`svg-1`}],[`path`,{d:`M16 20v.01`,key:`svg-2`}],[`path`,{d:`M8 20v.01`,key:`svg-3`}],[`path`,{d:`M4 20v.01`,key:`svg-4`}],[`path`,{d:`M4 16v.01`,key:`svg-5`}],[`path`,{d:`M4 12v.01`,key:`svg-6`}],[`path`,{d:`M4 8v.01`,key:`svg-7`}],[`path`,{d:`M4 4v.01`,key:`svg-8`}],[`path`,{d:`M8 4v.01`,key:`svg-9`}],[`path`,{d:`M12 4v.01`,key:`svg-10`}],[`path`,{d:`M16 4v.01`,key:`svg-11`}],[`path`,{d:`M20 4v.01`,key:`svg-12`}],[`path`,{d:`M20 8v.01`,key:`svg-13`}],[`path`,{d:`M20 12v.01`,key:`svg-14`}],[`path`,{d:`M20 16v.01`,key:`svg-15`}],[`path`,{d:`M20 20v.01`,key:`svg-16`}]]),Lp=K(`outline`,`send`,`Send`,[[`path`,{d:`M10 14l11 -11`,key:`svg-0`}],[`path`,{d:`M21 3l-6.5 18a.55 .55 0 0 1 -1 0l-3.5 -7l-7 -3.5a.55 .55 0 0 1 0 -1l18 -6.5`,key:`svg-1`}]]),Rp=K(`outline`,`shadow`,`Shadow`,[[`path`,{d:`M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0`,key:`svg-0`}],[`path`,{d:`M13 12h5`,key:`svg-1`}],[`path`,{d:`M13 15h4`,key:`svg-2`}],[`path`,{d:`M13 18h1`,key:`svg-3`}],[`path`,{d:`M13 9h4`,key:`svg-4`}],[`path`,{d:`M13 6h1`,key:`svg-5`}]]),zp=K(`outline`,`share-2`,`Share2`,[[`path`,{d:`M8 9h-1a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-8a2 2 0 0 0 -2 -2h-1`,key:`svg-0`}],[`path`,{d:`M12 14v-11`,key:`svg-1`}],[`path`,{d:`M9 6l3 -3l3 3`,key:`svg-2`}]]),Bp=K(`outline`,`skateboard`,`Skateboard`,[[`path`,{d:`M5 15a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`,key:`svg-0`}],[`path`,{d:`M15 15a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`,key:`svg-1`}],[`path`,{d:`M3 9a2 1 0 0 0 2 1h14a2 1 0 0 0 2 -1`,key:`svg-2`}]]),Vp=K(`outline`,`square-dot`,`SquareDot`,[[`path`,{d:`M3 5a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14`,key:`svg-0`}],[`path`,{d:`M11 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`,key:`svg-1`}]]),Hp=K(`outline`,`strikethrough`,`Strikethrough`,[[`path`,{d:`M5 12l14 0`,key:`svg-0`}],[`path`,{d:`M16 6.5a4 2 0 0 0 -4 -1.5h-1a3.5 3.5 0 0 0 0 7h2a3.5 3.5 0 0 1 0 7h-1.5a4 2 0 0 1 -4 -1.5`,key:`svg-1`}]]),Up=K(`outline`,`triangle-square-circle`,`TriangleSquareCircle`,[[`path`,{d:`M12 3l-4 7h8l-4 -7`,key:`svg-0`}],[`path`,{d:`M14 17a3 3 0 1 0 6 0a3 3 0 1 0 -6 0`,key:`svg-1`}],[`path`,{d:`M4 15a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4`,key:`svg-2`}]]),Wp=K(`outline`,`underline`,`Underline`,[[`path`,{d:`M7 5v5a5 5 0 0 0 10 0v-5`,key:`svg-0`}],[`path`,{d:`M5 19h14`,key:`svg-1`}]]),Gp=K(`outline`,`user`,`User`,[[`path`,{d:`M8 7a4 4 0 1 0 8 0a4 4 0 0 0 -8 0`,key:`svg-0`}],[`path`,{d:`M6 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2`,key:`svg-1`}]]),Kp=K(`outline`,`vector-bezier-2`,`VectorBezier2`,[[`path`,{d:`M3 4a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1l0 -2`,key:`svg-0`}],[`path`,{d:`M17 18a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1l0 -2`,key:`svg-1`}],[`path`,{d:`M7 5l7 0`,key:`svg-2`}],[`path`,{d:`M10 19l7 0`,key:`svg-3`}],[`path`,{d:`M8 19a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`,key:`svg-4`}],[`path`,{d:`M14 5a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`,key:`svg-5`}],[`path`,{d:`M7 5.5a5 6.5 0 0 1 5 6.5a5 6.5 0 0 0 5 6.5`,key:`svg-6`}]]),qp=K(`outline`,`vector-triangle`,`VectorTriangle`,[[`path`,{d:`M10 5a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1l0 -2`,key:`svg-0`}],[`path`,{d:`M3 18a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1l0 -2`,key:`svg-1`}],[`path`,{d:`M17 18a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1l0 -2`,key:`svg-2`}],[`path`,{d:`M6.5 17.1l5 -9.1`,key:`svg-3`}],[`path`,{d:`M17.5 17.1l-5 -9.1`,key:`svg-4`}],[`path`,{d:`M7 19l10 0`,key:`svg-5`}]]),Jp=K(`outline`,`video`,`Video`,[[`path`,{d:`M15 10l4.553 -2.276a1 1 0 0 1 1.447 .894v6.764a1 1 0 0 1 -1.447 .894l-4.553 -2.276v-4`,key:`svg-0`}],[`path`,{d:`M3 8a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2l0 -8`,key:`svg-1`}]]),Yp=K(`outline`,`world`,`World`,[[`path`,{d:`M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0`,key:`svg-0`}],[`path`,{d:`M3.6 9h16.8`,key:`svg-1`}],[`path`,{d:`M3.6 15h16.8`,key:`svg-2`}],[`path`,{d:`M11.5 3a17 17 0 0 0 0 18`,key:`svg-3`}],[`path`,{d:`M12.5 3a17 17 0 0 1 0 18`,key:`svg-4`}]]),Xp=K(`outline`,`zoom-scan`,`ZoomScan`,[[`path`,{d:`M8 11a3 3 0 1 0 6 0a3 3 0 0 0 -6 0`,key:`svg-0`}],[`path`,{d:`M16 16l-2.5 -2.5`,key:`svg-1`}],[`path`,{d:`M3 7v-2a2 2 0 0 1 2 -2h2`,key:`svg-2`}],[`path`,{d:`M3 17v2a2 2 0 0 0 2 2h2`,key:`svg-3`}],[`path`,{d:`M17 3h2a2 2 0 0 1 2 2v2`,key:`svg-4`}],[`path`,{d:`M17 21h2a2 2 0 0 0 2 -2v-2`,key:`svg-5`}]]),Zp=K(`filled`,`brand-youtube-filled`,`BrandYoutubeFilled`,[[`path`,{d:`M18 3a5 5 0 0 1 5 5v8a5 5 0 0 1 -5 5h-12a5 5 0 0 1 -5 -5v-8a5 5 0 0 1 5 -5zm-9 6v6a1 1 0 0 0 1.514 .857l5 -3a1 1 0 0 0 0 -1.714l-5 -3a1 1 0 0 0 -1.514 .857z`,key:`svg-0`}]]),Z={palette:{chord:`$mod+k`,viewSafe:!0},toolDrawer:{chord:`/`},bold:{chord:`$mod+b`},italic:{chord:`$mod+i`},underline:{chord:`$mod+u`},strikethrough:{chord:`$mod+Shift+x`},eyedropper:{chord:`Shift+KeyI`},imageLibrary:{chord:`Shift+KeyS`},copy:{chord:`$mod+c`,viewSafe:!0},cut:{chord:`$mod+x`},pasteAsText:{chord:`$mod+Shift+v`},copyPng:{chord:`$mod+Shift+c`,viewSafe:!0},duplicate:{chord:`$mod+d`},undo:{chord:`$mod+z`},redo:{chord:`$mod+Shift+z`},redoAlt:{chord:`$mod+y`},save:{chord:`$mod+s`},print:{chord:`$mod+p`,viewSafe:!0},open:{chord:`$mod+o`},selectAll:{chord:`$mod+a`,viewSafe:!0},lock:{chord:`$mod+Shift+KeyL`},group:{chord:`$mod+g`},ungroup:{chord:`$mod+Shift+g`},flipHorizontal:{chord:`Shift+KeyH`},flipVertical:{chord:`Shift+KeyV`},sendBackward:{chord:`$mod+BracketLeft`},bringForward:{chord:`$mod+BracketRight`},sendToBack:{chord:`$mod+Alt+BracketLeft`},bringToFront:{chord:`$mod+Alt+BracketRight`},copyStyles:{chord:`$mod+Alt+KeyC`},pasteStyles:{chord:`$mod+Alt+KeyV`},present:{chord:`$mod+Alt+KeyP`,viewSafe:!0},presentFromStart:{chord:`$mod+Shift+Alt+KeyP`,viewSafe:!0},alignLeft:{chord:`Alt+KeyL`},alignCenter:{chord:`Alt+KeyC`},alignRight:{chord:`Alt+KeyR`},alignTop:{chord:`Alt+KeyT`},alignMiddle:{chord:`Alt+KeyM`},alignBottom:{chord:`Alt+KeyB`},tidy:{chord:`Alt+KeyU`},zoomIn:{chord:`$mod+Equal`,viewSafe:!0,gestureSafe:!0},zoomInPlus:{chord:`$mod+Shift+Equal`,viewSafe:!0,gestureSafe:!0},zoomOut:{chord:`$mod+Minus`,viewSafe:!0,gestureSafe:!0},resetZoom:{chord:`$mod+Digit0`,viewSafe:!0,gestureSafe:!0},zoomToFit:{chord:`$mod+Digit1`,viewSafe:!0,gestureSafe:!0},toolLock:{chord:`$mod+Period`},zen:{chord:`Alt+KeyZ`,viewSafe:!0,gestureSafe:!0},ride:{chord:`Shift+KeyR`,viewSafe:!0},aiPanel:{chord:`Alt+KeyA`},slidesPanel:{chord:`Alt+KeyS`},codePanel:{chord:`Alt+KeyD`},connectRight:{chord:`Tab`},connectBelow:{chord:`Shift+Tab`}};function Qp(e){return Bc(Z[e].chord)}function $p(e,t,n){let r=new Set,i=new Set(t);for(let t of e)t.groupId&&t.groupId!==n&&i.has(t.id)&&r.add(t.groupId);if(r.size===0)return i;for(let t of e)t.groupId&&r.has(t.groupId)&&!t.locked&&i.add(t.id);return i}var em=`Grouped as one — nested groups aren't supported`;function tm(e,t){return e.some(e=>t.has(e.id)&&e.groupId!==void 0)}function nm(e,t){return e.length>1&&e[0].groupId!==void 0&&e[0].groupId!==t&&e.every(t=>t.groupId===e[0].groupId)}function rm(e){if(e.selectedIds.size===0)return;let t=be(e.editSession);t&&e.selectedIds.has(t)&&e.endEdit(),e.removeShapes(e.selectedIds),e.setSelectedIds(new Set)}function im(){let e=window.getSelection();if(!e||e.isCollapsed)return!1;let t=e.anchorNode;return!!(t instanceof Element?t:t?.parentElement)?.closest(`.select-text`)}var am=e=>wn[e.type].textField===`label`?`label`:`text`;function om(e,t){if(e.editSession.kind!==`none`)return;let n=e.shapes.filter(t=>e.selectedIds.has(t.id)&&wn[t.type].edit===`text`);if(n.length===0)return;let r=e=>e[am(e)],i=!n.every(e=>Pt(typeof r(e)==`string`?r(e):``,t));e.replaceMany(n.map(e=>{let n=am(e),a=r(e);return{...e,[n]:br(typeof a==`string`?a:``,t,i)}}))}function sm(e,t){if(t||e.shapes.length===0)return;let n=Xn(In(e.shapes)).length>0;e.setExportDialog(ma({hasSlides:n}))}function cm(e){e.setTool(`select`),e.setSelectedIds(new Set(e.shapes.filter(e=>!e.locked).map(e=>e.id))),e.setLockRevealId(null)}function lm(e,t){if(e.selectedIds.size<2)return;let n=tm(e.shapes,e.selectedIds);e.group(e.selectedIds),n&&t(em)}function um(e){e.ungroup(e.selectedIds),e.setActiveGroupId(null)}function dm(e){let t=e.metaKey||e.ctrlKey;if(t&&!e.shiftKey)return null;let n=e.shiftKey?t?100:10:1,r=0,i=0;return e.key===`ArrowUp`?i=-n:e.key===`ArrowDown`?i=n:e.key===`ArrowLeft`?r=-n:e.key===`ArrowRight`&&(r=n),{dx:r,dy:i}}function fm(e){if(e.lockRevealId){e.setLockRevealId(null);return}if(e.pendingIcon||e.pendingControl){e.setPendingIcon(null),e.setPendingControl(null),e.setTool(`select`);return}if(Ee(e.editSession)){e.endEdit();return}if(e.animateSlideId){e.setAnimateSlideId(null);return}if(e.activeGroupId){let t=e.shapes.filter(t=>t.groupId===e.activeGroupId).map(e=>e.id);e.setActiveGroupId(null),e.setSelectedIds(new Set(t));return}e.setSelectedIds(new Set),e.endEdit(),e.setTool(`select`)}var pm=new Set(Object.values(Z).filter(e=>e.gestureSafe).map(e=>e.chord)),mm=new Set([Z.connectRight.chord,Z.connectBelow.chord]),hm=new Set([...Object.values(Z),...Object.values(Es)].filter(e=>e.viewSafe).map(e=>e.chord));function gm(e){let t=(0,J.useRef)(e);t.current=e;let{notify:n}=_(),{ai:r,embed:i}=te(),a=i!==void 0,o=H(),s=o.store,{undo:c,redo:l}=o.history,u=o.popupGuard;(0,J.useEffect)(()=>{let e=()=>s.getState(),i=()=>e().viewMode;function d(){e().endEdit()}let f=n=>r=>{r.preventDefault(),e().selectedIds.size>=2&&t.current.align(n)},p=t=>n=>{n.preventDefault(),om(e(),t)},m={[Z.palette.chord]:t=>{t.preventDefault();let n=e();n.setPaletteOpen(!n.paletteOpen)},[Z.toolDrawer.chord]:t=>{t.preventDefault();let n=e();n.setToolDrawerOpen(!n.toolDrawerOpen)},[Z.bold.chord]:p(`strong`),[Z.italic.chord]:p(`em`),[Z.underline.chord]:p(`u`),[Z.strikethrough.chord]:p(`s`),[Z.eyedropper.chord]:e=>{e.preventDefault(),t.current.eyedrop()},[Z.imageLibrary.chord]:t=>{t.preventDefault(),e().setImageLibraryOpen(!0),e().setIconPickerOpen(!1)},[Z.copy.chord]:e=>{im()||(e.preventDefault(),t.current.copySelection())},[Z.cut.chord]:e=>{im()||(e.preventDefault(),t.current.cutSelection())},[Z.pasteAsText.chord]:e=>{e.preventDefault(),t.current.pasteAsText()},[Z.copyPng.chord]:e=>{e.preventDefault(),t.current.copyPng()},[Z.duplicate.chord]:e=>{e.preventDefault(),t.current.duplicate()},[Z.undo.chord]:n=>{if(n.preventDefault(),e().polyDraft){t.current.removeLastPolylinePoint();return}d(),c()},[Z.redo.chord]:e=>{e.preventDefault(),d(),l()},[Z.redoAlt.chord]:e=>{e.preventDefault(),d(),l()},[Z.save.chord]:e=>{e.preventDefault(),t.current.saveNow()},[Z.print.chord]:t=>{t.preventDefault(),sm(e(),a)},[Z.open.chord]:e=>{e.preventDefault(),t.current.openFile()},[Z.selectAll.chord]:t=>{t.preventDefault(),cm(e())},[Z.lock.chord]:e=>{e.preventDefault(),t.current.toggleLock()},[Z.group.chord]:t=>{t.preventDefault(),lm(e(),n)},[Z.ungroup.chord]:t=>{t.preventDefault(),um(e())},[Z.flipHorizontal.chord]:e=>{e.preventDefault(),t.current.flip(`horizontal`)},[Z.flipVertical.chord]:e=>{e.preventDefault(),t.current.flip(`vertical`)},[Z.sendBackward.chord]:e=>{e.preventDefault(),t.current.reorder(`backward`)},[Z.bringForward.chord]:e=>{e.preventDefault(),t.current.reorder(`forward`)},[Z.sendToBack.chord]:e=>{e.preventDefault(),t.current.reorder(`back`)},[Z.bringToFront.chord]:e=>{e.preventDefault(),t.current.reorder(`front`)},[Z.copyStyles.chord]:e=>{e.preventDefault(),t.current.copyStyles()},[Z.present.chord]:e=>{e.preventDefault(),t.current.startPresentation()},[Z.presentFromStart.chord]:e=>{e.preventDefault(),t.current.startPresentation(`beginning`)},[Z.pasteStyles.chord]:e=>{e.preventDefault(),t.current.pasteStyles()},[Z.alignLeft.chord]:f(`left`),[Z.alignCenter.chord]:f(`center-h`),[Z.alignRight.chord]:f(`right`),[Z.alignTop.chord]:f(`top`),[Z.alignMiddle.chord]:f(`middle`),[Z.alignBottom.chord]:f(`bottom`),[Z.tidy.chord]:n=>{n.preventDefault();let r=e();lo(r.shapes,r.selectedIds)&&t.current.tidy()},[Z.zoomIn.chord]:e=>{e.preventDefault(),t.current.zoomIn()},[Z.zoomInPlus.chord]:e=>{e.preventDefault(),t.current.zoomIn()},[Z.zoomOut.chord]:e=>{e.preventDefault(),t.current.zoomOut()},[Z.resetZoom.chord]:e=>{e.preventDefault(),t.current.resetZoom()},[Z.zoomToFit.chord]:e=>{e.preventDefault(),t.current.zoomToFit()},[Z.toolLock.chord]:t=>{t.preventDefault(),e().setToolLock(e=>!e)},[Z.zen.chord]:t=>{t.preventDefault(),e().setZenMode(e=>!e)},[Z.ride.chord]:t=>{t.preventDefault(),e().setRideMode(e=>!e)},[Z.aiPanel.chord]:t=>{t.preventDefault(),r&&e().setAiOpen(e=>!e)},[Z.slidesPanel.chord]:t=>{t.preventDefault(),e().setSlidesOpen(e=>!e)},[Z.codePanel.chord]:t=>{t.preventDefault(),e().setCodeOpen(e=>!e)},[Es.ellipse.chord]:()=>{t.current.selectTool(`rectangle`),e().setShapeKind(`ellipse`)},[Es.comment.chord]:e=>{e.preventDefault(),t.current.addComment()},[Es.stepbadge.chord]:e=>{e.preventDefault(),t.current.insertControl(`stepbadge`)},[Z.connectRight.chord]:e=>{fs(e.target)||Of(s,`right`,o.measurement)&&e.preventDefault()},[Z.connectBelow.chord]:e=>{fs(e.target)||Of(s,`down`,o.measurement)&&e.preventDefault()}};for(let[n,r]of Object.entries(bs))m[n]=n=>{n.preventDefault(),!e().animateSlideId&&(t.current.selectTool(r),r===`rectangle`&&e().setShapeKind(`rectangle`),r===`figure`&&e().setFrameKind(`simple`))};for(let[e,t]of Object.entries(m))hm.has(e)||(m[e]=n=>{if(i()){mm.has(e)||n.preventDefault();return}t(n)});for(let[t,n]of Object.entries(m))pm.has(t)||t in bs||(m[t]=r=>{if(pe(e())){mm.has(t)||r.preventDefault();return}n(r)});let h=id(window,m,{ignore:t=>t.repeat||t.isComposing||us(t.target)||e().presentingIndex!==null||e().flowPlay!==null});function g(n){if(us(n.target)||e().presentingIndex!==null||e().flowPlay!==null||pe(e()))return;let r=t.current,a=e();if(a.polyDraft){if(n.key===`Delete`||n.key===`Backspace`){n.preventDefault(),r.removeLastPolylinePoint();return}if(n.key===`Enter`){n.preventDefault(),r.commitPolyline();return}if(n.key===`Escape`){n.preventDefault(),r.cancelPolyline();return}}if(n.key===`Delete`||n.key===`Backspace`){n.preventDefault(),i()||rm(e());return}if(!u.openAtEvent()){if(n.key.startsWith(`Arrow`)){if(n.target instanceof HTMLInputElement||i())return;let e=dm(n);if(!e)return;r.nudgeSelection(e.dx,e.dy),n.preventDefault();return}if(n.key===`Escape`){fm(a);return}if(n.key===`Enter`){if(fs(n.target))return;if(a.editSession.kind===`crop`){a.endEdit(),n.preventDefault();return}a.selectedIds.size>0&&a.editSession.kind===`none`&&!i()&&(r.editSelection(),n.preventDefault())}}}function _(r){us(r.target)||e().presentingIndex!==null||i()||pe(e())||qd(r,t.current,n)}return window.addEventListener(`keydown`,g),window.addEventListener(`paste`,_),()=>{h(),window.removeEventListener(`keydown`,g),window.removeEventListener(`paste`,_)}},[s,c,l,u,n,o.measurement,r,a])}function _m(){let e=te().embed?.askAbout,t=W(),{notify:n}=_(),r=(0,J.useCallback)(()=>{if(!e)return;let{shapes:r,selectedIds:i}=t.getState(),a=ha(r,i);a.length!==0&&e.run(a).then(n,()=>n(`Couldn't reach the chat. Try again.`))},[e,t,n]),i=e?.label;return(0,J.useMemo)(()=>i===void 0?null:{label:i,run:r},[i,r])}var vm=(e,t)=>e.length===t.length&&e.every((e,n)=>e.flowId===t[n].flowId&&e.name===t[n].name&&e.frameId===t[n].frameId);function ym(e){let t=(0,J.useRef)(e);t.current=e;let n=U(e=>e.shapes.length>0),r=U(e=>e.selectedIds.size>0),i=Ga(),a=U(e=>e.zenMode),o=U(e=>e.rideMode),s=U(e=>e.viewMode),c=U(e=>e.viewModeLocked),{ai:l,embed:u}=te(),d=_m(),f=W(),p=_e(e=>[e.shapes],e=>Bn(e).some(e=>e.slideOrder!==void 0&&!e.slideSkipped)),m=_e(e=>[e.shapes],e=>Wc(e).flatMap(e=>(e.flows??[]).map(t=>({frameId:e.id,flowId:t.id,name:t.name}))),vm);return(0,J.useMemo)(()=>{let e=()=>f.getState(),h=[];for(let t of m)h.push({id:`play-flow-${t.flowId}`,group:`Panels`,label:`Play flow: ${t.name}`,keywords:`flow walkthrough steps walk through play`,icon:yc,run:()=>e().setFlowPlay({frameId:t.frameId,flowId:t.flowId,step:0})});if(s||h.push({id:`paste`,group:`Edit`,label:`Paste`,hint:`⌘V`,icon:Zf,run:()=>t.current.pasteClipboard()},{id:`paste-text`,group:`Edit`,label:`Paste as plain text`,hint:Qp(`pasteAsText`),keywords:`unformatted strip`,icon:Zf,run:()=>void t.current.pasteAsText()}),n&&(h.push({id:`select-all`,group:`Edit`,label:`Select all`,hint:Qp(`selectAll`),icon:Ip,run:()=>t.current.selectAll()}),s||h.push({id:`clear-canvas`,group:`Edit`,label:`Clear canvas`,keywords:`reset delete all empty wipe erase`,icon:Ws,run:()=>t.current.clearCanvas()})),!s){h.push({id:`new-slide`,group:`Panels`,label:`New slide`,keywords:`add create deck`,icon:_p,run:()=>{e().setSlidesOpen(!0),e().setSlidePickerOpen(!0)}});let t=In(e().shapes),n=lr(t,e().viewport,{width:window.innerWidth,height:window.innerHeight}),r=t[Math.max(0,n)];r&&h.push({id:`animate-slide`,group:`Panels`,label:`Animate slide`,keywords:`build steps reveal appear order animation`,icon:Sc,run:()=>e().setAnimateSlideId(r.id)})}return h.push({id:`slides`,group:`Panels`,label:`Slides panel`,keywords:`deck`,icon:_p,run:()=>e().setSlidesOpen(!0)},{id:`present`,group:`Panels`,label:`Present from current slide`,hint:Qp(`present`),keywords:`present slides play deck fullscreen slideshow here`,icon:D,run:()=>t.current.startPresentation(`current`)},{id:`present-beginning`,group:`Panels`,label:`Present from beginning`,hint:Qp(`presentFromStart`),keywords:`present slides play deck fullscreen slideshow start first`,icon:D,run:()=>t.current.startPresentation(`beginning`)}),s||h.push({id:`code`,group:`Panels`,label:`Diagram as code`,keywords:`dsl mermaid`,icon:ec,run:()=>e().setCodeOpen(!0)}),l&&!s&&(h.push({id:`ai`,group:`Panels`,label:`AI assistant`,keywords:`chat ask`,icon:Sc,run:()=>e().setAiOpen(!0)},{id:`ask-ai`,group:`AI`,label:`Ask AI…`,keywords:`assistant chat question help`,icon:Sc,run:()=>e().askAi(``,!1)},{id:`ai-diagram`,group:`AI`,label:`Generate diagram with AI`,keywords:`assistant architecture flowchart create`,icon:Sc,run:()=>e().askAi(`Draw a diagram of `,!1)},{id:`ai-deck`,group:`AI`,label:`Generate slides with AI`,keywords:`assistant deck presentation create`,icon:Sc,run:()=>e().askAi(`Create a short deck about `,!1)}),r&&h.push({id:`ai-explain`,group:`AI`,label:`Explain selection with AI`,keywords:`assistant what is this describe`,icon:Sc,run:()=>e().askAi(`Explain what the selected shapes are and how they connect. If the labels alone don't tell the story, look at the canvas first.`,!0)},{id:`ai-tidy`,group:`AI`,label:`Tidy selection with AI`,keywords:`assistant clean up layout arrange`,icon:Sc,run:()=>e().askAi(`Tidy up the selection. If it's a diagram, re-lay it out and fix the arrows; otherwise align and space the shapes cleanly. Don't change colours, fonts or styling.`,!0)})),h.push({id:`zoom-fit`,group:`View`,label:`Zoom to fit`,hint:Qp(`zoomToFit`),icon:Xp,run:()=>t.current.zoomToFit()},{id:`zoom-reset`,group:`View`,label:`Reset zoom to 100%`,hint:Qp(`resetZoom`),icon:ac,run:()=>t.current.resetZoom()},{id:`back-to-content`,group:`View`,label:`Back to content`,icon:ac,run:()=>t.current.backToContent()},{id:`toggle-grid`,group:`View`,label:`Toggle grid`,icon:cp,run:()=>t.current.toggleGrid()},{id:`theme`,group:`View`,label:i===`dark`?`Light mode`:`Dark mode`,keywords:`theme dark light appearance toggle`,icon:Np,run:()=>e().setTheme(i===`dark`?`light`:`dark`)},{id:`zen-mode`,group:`View`,label:a?`Exit zen mode`:`Zen mode`,hint:Qp(`zen`),keywords:`distraction free focus hide chrome ui`,icon:Na,run:()=>e().setZenMode(e=>!e)},{id:`ride-mode`,group:`View`,label:o?`Stop riding`:`Ride the canvas`,hint:Qp(`ride`),keywords:`line rider bike physics play game fun`,icon:Bp,run:()=>e().setRideMode(e=>!e)},...c?[]:[{id:`view-mode`,group:`View`,label:s?`Exit view mode`:`View mode (read-only)`,keywords:`read only lock viewer inspect`,icon:ba,run:()=>e().setViewMode(e=>!e)}]),r&&h.push({id:`zoom-selection`,group:`View`,label:`Zoom to selection`,keywords:`fit frame`,icon:Xp,run:()=>t.current.zoomToSelection()}),r&&d&&h.push({id:`ask-host`,group:`AI`,label:d.label,keywords:`assistant chat explain question`,icon:kp,run:d.run}),u?(h.push({id:`open-in-app`,group:`Export`,label:u.openInApp.label,keywords:`export download png svg pdf share present save file open`,icon:Ys,run:u.openInApp.run}),h):(n&&h.push({id:`export-png`,group:`Export`,label:`Export as PNG…`,icon:gc,run:()=>e().setExportDialog({format:`png`})},{id:`export-svg`,group:`Export`,label:`Export as SVG…`,icon:ip,run:()=>e().setExportDialog({format:`svg`})}),p&&h.push({id:`export-pdf`,group:`Export`,label:`Export slides as PDF…`,keywords:`deck presentation print download`,icon:ya,run:()=>e().setExportDialog({format:`pdf`})}),h)},[n,r,i,a,o,s,c,l,f,p,u,d,m])}var bm=()=>Ai(()=>import(`./tidy-browser-dF3BON7J.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]));function xm(){so(bm)}function Sm(){return oo(bm)!==void 0}async function Cm(e,t,n){return(await co(bm)).tidyInBrowser(e,t,n)}var wm=24,Tm=38,Em=16,Dm=220;function Om(e){let t=[];for(let n of e){let e=`fill`in n?n.fill:void 0;typeof e==`string`&&e&&e!==`transparent`&&!t.includes(e)&&t.push(e)}return t}function km(e){return Om(e).length>=2}function Am(e){let t=Om(e),n=pn(e);if(t.length<2||!n)return[];let r=$e(),{x:i,y:a}=Yl(n),o=[zn({x:i,y:a,width:Dm,height:Em*2+t.length*Tm,fill:`#ffffff`,fillStyle:`pastel`,groupId:r})];return t.forEach((e,t)=>{let n=a+Em+t*Tm;o.push(zn({x:i+Em,y:n,width:wm,height:wm,fill:e,fillStyle:`pastel`,groupId:r}),{id:$e(),type:`text`,x:i+Em+wm+12,y:n+2,text:`Theme ${t+1}`,fontSize:18,fontFamily:li,rotation:0,color:Kr,opacity:1,groupId:r})}),o}var jm=16;function Mm(e){if(e.length<2)return[];let t=[...e].sort(Ni),n=wr(t),r=Xl(t,{x:n.x,y:n.y},jm),i=$e();return t.map((e,t)=>({...e,x:r[t].x,y:r[t].y,groupId:i}))}var Nm=16,Pm=16;function Fm(e){return It(e.text).replace(/\s+/g,` `).trim()}function Im(e){if(e.length<1)return null;let t=[...e].sort(Ni),n=t.map(Fm).filter(e=>e.length>0),r=pn(t);return!r||n.length===0?null:{card:zn({...Yl(r),width:340,height:Math.max(140,n.length*18*1.6+Nm*2),label:Wt(n),fontSize:18,fontFamily:t[0].fontFamily,textAlign:`left`,textVAlign:`top`,textPadding:Nm,fill:`#ffffff`,fillStyle:`pastel`}),removeIds:t.map(e=>e.id)}}function Lm(e){return It(e.type===`rectangle`?e.label:e.text).split(`
14
+ `).map(e=>e.trim()).filter(e=>e.length>0).length}function Rm(e){let t=It(e.type===`rectangle`?e.label:e.text).split(`
15
+ `).map(e=>e.replace(/\s+/g,` `).trim()).filter(e=>e.length>0);if(t.length<1)return[];let n=G(e),r=Xl(t.map(()=>({width:180,height:180})),{x:n.x,y:n.y},Pm),i=$e();return t.map((t,n)=>({id:$e(),type:`sticky`,x:r[n].x,y:r[n].y,width:180,height:180,rotation:0,text:t,fontSize:16,fontFamily:e.fontFamily,fill:Bi,opacity:1,groupId:i}))}function zm(e,t,n={}){let r=jn(e,t,n.measurement),i=$p(e,r.map(e=>e.id),n.activeGroupId??null),a=new Set(r.map(e=>e.id)),o=[...r,...e.filter(e=>i.has(e.id)&&!a.has(e.id))];return n.includeLocked?o:o.filter(e=>!e.locked)}function Bm(e){return e.shapes.filter(t=>t.type===`figure`&&e.selectedIds.has(t.id)&&(t.kind??`simple`)===`simple`&&!t.groupId&&t.slideOrder===void 0&&!hr(e.shapes,t))}function Vm(e){return e.shapes.filter(t=>t.type===`figure`&&e.selectedIds.has(t.id)&&t.slideOrder!==void 0)}function Hm(e){return e.shapes.filter(t=>t.type===`sticky`&&e.selectedIds.has(t.id))}function Um(e){let t=ha(e.shapes,e.selectedIds);if(t.length!==1)return null;let n=t[0];return n.type!==`rectangle`&&n.type!==`text`?null:Lm(n)>=2?n:null}function Wm(e){let{replaceMany:t,removeShapes:n,addShape:r,addMany:i,setSelectedIds:a,setLockRevealId:o}=e,s=H(),{beginTransaction:c,endTransaction:l}=s.history,{measurement:u,store:d}=s,[f,p]=(0,J.useState)(`idle`),m=(0,J.useCallback)(()=>{Sm()||p(`loading`);let{shapes:e,selectedIds:n}=d.getState();Cm({selection:!0},e,n).then(e=>{p(`idle`),e.length!==0&&(t(e),a(new Set(e.map(e=>e.id))))},()=>{p(`failed`)})},[d,t,a]),h=(0,J.useMemo)(()=>({status:f,retry:m}),[f,m]),g=(0,J.useCallback)(()=>{let e=d.getState(),n=Bm(e);if(n.length===0)return;let r=oe(e.shapes);t(n.map(e=>({...e,slideOrder:r++}))),a(new Set(n.map(e=>e.id)))},[d,t,a]),_=(0,J.useCallback)(()=>{let e=d.getState(),n=Vm(e);if(n.length===0)return;let r=new Set(n.map(e=>e.id)),i=n.map(e=>({...e,slideOrder:void 0})),a=In(e.shapes).filter(e=>!r.has(e.id)).map((e,t)=>({...e,slideOrder:t}));t([...i,...a])},[d,t]),v=(0,J.useCallback)(()=>{let e=Mm(Hm(d.getState()));e.length!==0&&(t(e),a(new Set(e.map(e=>e.id))))},[d,t,a]),y=(0,J.useCallback)(()=>{let e=Im(Hm(d.getState()));e&&(c(),n(new Set(e.removeIds)),r(e.card),l(),a(new Set([e.card.id])))},[d,n,r,a,c,l]),b=(0,J.useCallback)(()=>{let e=Um(d.getState());if(!e)return;let t=Rm(e);t.length!==0&&(c(),n(new Set([e.id])),i(t),l(),a(new Set(t.map(e=>e.id))))},[d,n,i,a,c,l]),x=(0,J.useCallback)(()=>{let{shapes:e,selectedIds:t}=d.getState(),n=Am(ha(e,t));n.length!==0&&(c(),i(n),l(),a(new Set(n.map(e=>e.id))))},[d,i,a,c,l]),S=(0,J.useCallback)(()=>{let e=d.getState(),n=ha(e.shapes,e.selectedIds);if(n.length===0)return;let r=zm(e.shapes,n,{activeGroupId:e.activeGroupId,measurement:u});if(r.length===0)return;let i=r.length>1?$e():void 0;t(r.map(e=>({...e,locked:!0,lockId:i}))),a(new Set),o(n[0].id)},[d,u,t,a,o]),C=(0,J.useCallback)(()=>{let{shapes:e,lockRevealId:n}=d.getState(),r=n?Qe(e,n):void 0;if(!r||!r.locked)return;let i=Cu(e,r);t(i.map(e=>({...e,locked:!1,lockId:void 0}))),o(null),a(new Set(i.map(e=>e.id)))},[d,t,o,a]),w=(0,J.useCallback)(()=>{if(d.getState().lockRevealId){C();return}S()},[d,S,C]),T=(0,J.useCallback)(()=>{let e=d.getState(),t=pn(ha(e.shapes,e.selectedIds));if(!t)return;let n={id:$e(),type:`figure`,...Ur(t,24),rotation:0,label:`Frame`,fontSize:e.style.fontSize,fontFamily:e.style.fontFamily,color:ci,opacity:1};e.addShapeBehind(n,e.selectedIds),a(new Set([n.id]))},[d,a]);return(0,J.useMemo)(()=>({tidySelection:m,tidyState:h,addFramesToSlides:g,removeFramesFromSlides:_,clusterSelectedStickies:v,convertStickiesToOutline:y,convertOutlineToStickies:b,addColorLegend:x,lockSelection:S,unlockReveal:C,toggleLock:w,wrapSelectionInFrame:T}),[m,h,g,_,v,y,b,x,S,C,w,T])}function Gm(e){let{selection:t,documents:n,tools:r,paste:i,structure:a,tables:o,zoom:s,comments:c,ai:l,embedFrame:u,pasteTargetRef:d}=e,f=W(),p=H(),m=Kc(),{notify:h}=_(),g=te().embed?.openInApp??null,v=_m();return()=>{let e=f.getState(),{shapes:_,selectedIds:y,viewMode:b,showGrid:x,snapEnabled:S,presentationAnimation:C,showZoomIndicator:w,setExportDialog:T,group:E,ungroup:D,setActiveGroupId:O,setCodeOpen:k,askAi:A}=e,j=ha(_,y),M=nm(j,e.activeGroupId),N=j.length===1?j[0]:void 0,P=n.exportTargets;return{readOnly:b,hasSelection:j.length>0,hasClipboard:i.hasClipboard(),hasStyleClipboard:i.hasStyleClipboard(),canGroup:j.length>=2&&!M,canAlign:j.length>=2,canDistribute:j.length>=3,onAlign:t.alignSelection,onDistribute:t.distributeSelection,canUngroup:j.some(e=>e.groupId!==void 0),canSelectAll:_.length>0,onCut:i.cutSelection,onCopy:i.copySelection,onDuplicate:i.duplicateSelection,onPaste:()=>i.pasteClipboard(d.current??void 0),canComment:c.available,onAddComment:()=>c.addComment(d.current??void 0),onWrapInFrame:a.wrapSelectionInFrame,onCopyStyles:i.copyStyles,onPasteStyles:i.pasteStyles,onSendBackward:()=>t.reorderSelection(`backward`),onBringForward:()=>t.reorderSelection(`forward`),onSendToBack:()=>t.reorderSelection(`back`),onBringToFront:()=>t.reorderSelection(`front`),onFlipHorizontal:()=>t.flipSelection(`horizontal`),onFlipVertical:()=>t.flipSelection(`vertical`),onGroup:()=>{let e=tm(_,y);E(y),e&&h(em)},onUngroup:()=>{D(y),O(null)},onSelectAll:t.selectAll,onDelete:t.deleteSelection,isLocked:wu(_,e.lockRevealId).length>0,onLock:a.lockSelection,onUnlock:a.unlockReveal,canOpenWebLink:N?.type===`web`&&N.kind===`embed`&&_n(N.url)!==null,onOpenWebLink:()=>{let e=N?.type===`web`?_n(N.url):null;e&&window.open(e,`_blank`,`noopener,noreferrer`)},canCopyWebHtml:N?.type===`web`&&Jc(N)!==null,onCopyWebHtml:()=>{let e=N?.type===`web`?Jc(N):null;e&&(`html`in e?Promise.resolve(e.html):Yc(e.src)).then(e=>{if(e===null)throw Error(`source unavailable`);return navigator.clipboard.writeText(e)}).then(()=>h(`Copied HTML`),()=>h(`Couldn't copy the HTML`))},isTable:j.length===1&&j[0].type===`table`,onCopyCsv:o.copyTableCsv,onConvertToChart:o.convertTableToChart,isChart:j.length===1&&j[0].type===`chart`,onConvertToTable:o.convertChartToTable,canEditAsCode:j.length===1&&(j[0].type===`figure`||j[0].type===`chart`)&&typeof j[0].code==`string`&&j[0].code.trim().length>0,onEditAsCode:()=>k(!0),canResetArrowRoute:j.length===1&&j[0].type===`arrow`&&j[0].bendStyle===`elbow`&&(j[0].elbowMid!==void 0||j[0].elbowPoints!==void 0),onResetArrowRoute:()=>{j.length===1&&t.resetArrowBend(j[0].id)},canTidy:lo(_,y),onTidy:a.tidySelection,onMenuOpen:()=>{let e=f.getState();lo(e.shapes,e.selectedIds)&&xm()},canCluster:j.filter(e=>e.type===`sticky`).length>=2,onCluster:a.clusterSelectedStickies,canToOutline:Hm(e).length>=2,onToOutline:a.convertStickiesToOutline,canToStickies:Um(e)!==null,onToStickies:a.convertOutlineToStickies,canColorLegend:km(j),onColorLegend:a.addColorLegend,canAddToSlides:Bm(e).length>0,onAddToSlides:a.addFramesToSlides,canRemoveFromSlides:Vm(e).length>0,onRemoveFromSlides:a.removeFramesFromSlides,canAddFlow:j.length>0&&!b,onAddFlow:()=>{let e=Gc(_,j);if(e){Vs(p,e.id);return}a.wrapSelectionInFrame();let[t]=f.getState().selectedIds;t&&Vs(p,t)},canEmbedFrame:u!==null&&j.length===1&&j[0].type===`figure`,onEmbedFrame:()=>{u&&j.length===1&&u(j[0].id)},canExport:_.length>0,onExportPng:()=>T({format:`png`,scope:j.length>0?`selection`:`board`}),onExportSvg:()=>T({format:`svg`,scope:j.length>0?`selection`:`board`}),onCopyPng:()=>void m(`copyPng`,P()),onCopySvg:()=>void m(`copySvg`,P()),openInApp:g,askHost:j.length>0?v:null,canAskAi:l&&j.length>0,onAskExplain:()=>A(j.length===1?`Explain what this is and its role on the board. If the labels alone don't tell the story, look at the canvas first.`:`Explain what the selected shapes are and how they connect. If the labels alone don't tell the story, look at the canvas first.`,!0),onAskFeedback:()=>A(`Review the selection as a critical colleague: point out missing pieces, unclear names, and confusing or ambiguous flows. If a frame is selected, review what's inside it. Don't change anything; answer in text.`,!0),onAskTidy:()=>A(`Tidy up the selection. If it's a diagram, re-lay it out and fix the arrows; otherwise align and space the shapes cleanly. Then look at the result and fix anything still off (overlaps, stray labels, spacing). Don't change colours, fonts or styling.`,!0),onAskProofread:()=>A(`Fix any spelling or grammar mistakes in the text of the selected shapes; if a frame is selected, check the shapes inside it too. Keep the wording, formatting and meaning otherwise, and leave text that has no mistakes untouched. If nothing needs fixing, just say so.`,!0),onAskIcons:()=>A(`Add fitting icons to the selected shapes that represent recognizable things (services, products, people); if a frame is selected, work on the shapes inside it. Leave the rest alone.`,!0),onAskRestyle:()=>A(`Restyle the selected shapes: `,!1),onAskCustom:()=>A(``,!1),showGrid:x,onToggleGrid:r.toggleGrid,snapEnabled:S,onToggleSnap:r.toggleSnap,presentationAnimation:C,onTogglePresentationAnimation:r.togglePresentationAnimation,showZoomIndicator:w,onToggleShowZoomIndicator:r.toggleShowZoomIndicator,onZoomToFit:s.zoomToFit,onResetZoom:s.resetZoomCentered,onZoomToSelection:s.zoomToSelection,canClear:_.length>0,onClear:n.clearCanvas}}}function Km(e){let{containerRef:t,fitToBounds:n,zoomIn:r,zoomOut:i,resetZoom:a}=e,o=H(),s=o.store,c=o.measurement,l=(0,J.useCallback)(()=>{let e=s.getState();return ha(e.shapes,e.selectedIds)},[s]),u=(0,J.useCallback)(()=>{let e=t.current;if(!e)return;let r={width:e.clientWidth,height:e.clientHeight},i=l(),a=i.length>0?i:s.getState().shapes;n(pn(a,c),r)},[t,s,l,n,c]),d=(0,J.useCallback)(()=>{let e=t.current,r=l();!e||r.length===0||n(pn(r,c),{width:e.clientWidth,height:e.clientHeight})},[t,l,n,c]),f=(0,J.useCallback)(()=>{let e=t.current;e&&n(pn(s.getState().shapes,c),{width:e.clientWidth,height:e.clientHeight})},[t,s,n,c]),p=(0,J.useCallback)(()=>{let e=t.current?.getBoundingClientRect();return{x:(e?.width??0)/2,y:(e?.height??0)/2}},[t]),m=(0,J.useCallback)(()=>r(p()),[r,p]),h=(0,J.useCallback)(()=>i(p()),[i,p]),g=(0,J.useCallback)(()=>a(p()),[a,p]);return(0,J.useMemo)(()=>({zoomToFit:u,zoomToSelection:d,backToContent:f,zoomInCentered:m,zoomOutCentered:h,resetZoomCentered:g}),[u,d,f,m,h,g])}function qm(e,t,n){for(let r=e.length-1;r>=0;--r){let i=e[r];if(i.locked)continue;let a=Cn(i,n);if(!(a.width<=0||a.height<=0)){if(Tu(i)){if(ju(i,t))return i;continue}if(fa(i,t,n))return i}}return null}function Jm(e,t,n){let r=qm(e,t,n);if(!r)return{kind:`point`,x:t.x,y:t.y};let{footprint:i,toLocal:a}=pa(r,n),o=a(t);return{kind:`shape`,shapeId:r.id,fx:i.width>0?(o.x-i.x)/i.width:.5,fy:i.height>0?(o.y-i.y)/i.height:.5}}function Ym(e,t,n){if(e.kind===`point`)return{x:e.x,y:e.y};let r=t.get(e.shapeId);if(!r)return null;let{footprint:i,toWorld:a}=pa(r,n);return a({x:i.x+e.fx*i.width,y:i.y+e.fy*i.height})}function Xm(){let e=W(),t=H(),n=re()!==null,r=(0,J.useCallback)(()=>{if(!n)return;let t=e.getState(),r=ha(t.shapes,t.selectedIds)[0];r&&t.setCommentDraft({kind:`shape`,shapeId:r.id,fx:1,fy:0})},[n,e]),i=(0,J.useCallback)(r=>{if(!n)return;let i=e.getState();i.setCommentDraft(Jm(i.shapes,r,t.measurement))},[n,t,e]),a=(0,J.useCallback)(t=>{if(e.getState().selectedIds.size>0){r();return}t&&i(t)},[i,r,e]);return(0,J.useMemo)(()=>({available:n,addComment:a,commentAt:i,commentOnSelection:r}),[n,a,i,r])}var Zm=[`startArrow`,`endArrow`,`startHead`,`endHead`,`flow`],Qm=[`lineHeight`,`letterSpacing`],$m={rectangle:[`fillStyle`,`stroke`,`shadow`,`corner`,`textAlign`,`textVAlign`,`textPadding`,`labelColor`,...Qm],text:[`textAlign`,`textVAlign`,...Qm],sticky:Qm,image:[`corner`],polygon:[`smooth`],arrow:[`bendStyle`],table:[`background`],figure:[`fill`,`strokeWidth`,`dash`],control:[`fill`]};function eh(e){let t=wn[e],n=new Set([`opacity`,...$m[e]??[]]);return t.color&&n.add(`color`),t.fill&&n.add(`fill`),t.stroke&&n.add(`strokeWidth`),t.dash&&n.add(`dash`),t.font!==`none`&&(n.add(`fontSize`),n.add(`fontFamily`)),t.arrowEnds&&Zm.forEach(e=>n.add(e)),n}var th=Object.fromEntries(Object.keys(wn).map(e=>[e,eh(e)]));function nh(e,t){for(let n of e)if(th[n].has(t))return!0;return!1}function rh(e){return e.type===`rectangle`||e.type===`image`}function ih(e){return e.type===`rectangle`?qt(e.kind):`sharp`}function ah(e){return e.type===`text`?{...e,text:ht(e.text)}:(e.type===`rectangle`||e.type===`icon`||e.type===`arrow`||e.type===`line`)&&e.label?{...e,label:ht(e.label)}:e}var oh=[`fill`,`fillStyle`,`stroke`,`labelColor`];function sh(e,t){let n=e;n.type===`rectangle`&&n.fillStyle===`outline`&&oh.some(e=>t[e]!==void 0)&&(n={...n,...Pr(n.fill,n.labelColor)});let r=th[n.type],i={};for(let e of Object.keys(t)){let a=t[e];a===void 0||!r.has(e)||e===`background`||(i[e]=ch(n,e,a))}return Object.keys(i).length===0?n:(`shadow`in i&&!(`fillStyle`in i)&&n.type===`rectangle`&&n.fillStyle===`shadow`&&(i.fillStyle=`bold`),`bendStyle`in i&&Object.assign(i,{bend:0,bendAlong:0,bow:0,bowAlong:0,elbowPoints:void 0,elbowRoute:void 0,elbowMidHandle:void 0}),n={...n,...i},`color`in i||`labelColor`in i?ah(n):n)}function ch(e,t,n){return t===`stroke`||t===`labelColor`?n===`auto`?void 0:n:t===`shadow`||t===`smooth`?n||void 0:t===`corner`&&rh(e)&&n===ih(e)?void 0:n}function lh(e,t){if($n(e)){let n=e.fill;return n&&n!==`transparent`?{fill:t}:{color:t}}return e.type===`rectangle`&&e.kind===`fork-join`?{color:t}:Cr(e)?{fill:t}:{color:t}}function uh(e,t){if(!e)return t;let n=th[e.type],r=e,i={};for(let a of Object.keys(dh))i[a]=n.has(a)?r[a]??fh(e,a,t):t[a];if(e.type===`rectangle`&&e.fillStyle===`outline`){let t=Pr(e.fill,e.labelColor);i.fill=t.fill,i.fillStyle=t.fillStyle??i.fillStyle,i.stroke=t.stroke??`auto`,i.labelColor=t.labelColor??`auto`}return i}var dh={color:!0,fill:!0,fillStyle:!0,stroke:!0,shadow:!0,strokeWidth:!0,dash:!0,opacity:!0,corner:!0,fontSize:!0,fontFamily:!0,textAlign:!0,textVAlign:!0,textPadding:!0,lineHeight:!0,letterSpacing:!0,labelColor:!0,startArrow:!0,endArrow:!0,startHead:!0,endHead:!0,flow:!0,bendStyle:!0,background:!0,smooth:!0};function fh(e,t,n){switch(t){case`fill`:return`transparent`;case`fillStyle`:return ti;case`stroke`:case`labelColor`:return`auto`;case`shadow`:return e.type===`rectangle`&&e.fillStyle===`shadow`;case`corner`:return rh(e)?ih(e):void 0;case`strokeWidth`:case`dash`:return e.type===`figure`?hn(e)[t]:void 0;case`fontSize`:case`fontFamily`:return n[t];case`textAlign`:return e.type===`rectangle`?`center`:`left`;case`textVAlign`:return e.type===`rectangle`?`middle`:`top`;case`textPadding`:return 6;case`startHead`:case`endHead`:return`arrow`;case`flow`:return!1;default:return}}var ph=t({clipboardCopyId:()=>Ih,copySelection:()=>Oh,copyStyles:()=>Nh,cutSelection:()=>kh,duplicateSelection:()=>Mh,hasClipboard:()=>Fh,hasStyleClipboard:()=>Lh,noteDuplication:()=>Ch,noteMove:()=>wh,pasteClipboard:()=>Ah,pasteExternal:()=>jh,pasteStyles:()=>Ph});function mh(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}var hh=24,gh=[],_h=``,vh=null,yh=null;function bh(e){return vh?.deref()===e}var xh=null;function Sh(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function Ch(e,t){xh={ids:new Set(e),offset:t}}function wh(e,t){!xh||!Sh(xh.ids,e)||(xh={ids:e,offset:{x:xh.offset.x+t.x,y:xh.offset.y+t.y}})}function Th(e,t,n){let r=e.getState(),{activeGroupId:i}=r,a=Vn(t,n),o=i&&t.every(e=>e.groupId===i)?a.map(e=>({...e,groupId:i})):a;return r.addMany(o),r.setSelectedIds(new Set(o.map(e=>e.id))),o}function Eh(e,t,n){let{shapes:r,selectedIds:i,activeGroupId:a}=e.getState();return zm(r,ha(r,i),{activeGroupId:a,measurement:t,includeLocked:n})}function Dh(e,t){let n=$e();gh=t,_h=n,vh=new WeakRef(e),md(t,n)}function Oh(e,t){let n=Eh(e,t,!0);n.length!==0&&Dh(e,n)}function kh(e,t){let n=Eh(e,t,!1);if(n.length===0)return;Dh(e,n);let r=e.getState();r.removeShapes(new Set(n.map(e=>e.id))),r.setSelectedIds(new Set)}function Ah(e,t,n){if(gh.length===0)return;if(!bh(e)){let r=t??(n?{x:n.x+n.width/2,y:n.y+n.height/2}:null);jh(e,gh,_h,r);return}let r={x:hh,y:hh},i=pn(gh);t&&i?r={x:t.x-(i.x+i.width/2),y:t.y-(i.y+i.height/2)}:!t&&i&&n&&!mh(i,n)&&(r={x:n.x+n.width/2-(i.x+i.width/2),y:n.y+n.height/2-(i.y+i.height/2)}),gh=Th(e,gh,r)}function jh(e,t,n,r){if(t.length===0)return;let i={x:hh,y:hh},a=pn(t);a&&r&&(i={x:r.x-(a.x+a.width/2),y:r.y-(a.y+a.height/2)}),gh=Th(e,t,i),_h=n,vh=new WeakRef(e)}function Mh(e,t){let n=Eh(e,t,!0);if(n.length===0)return;let r=new Set(n.map(e=>e.id)),i=xh&&Sh(xh.ids,r)?xh.offset:{x:hh,y:hh},a=Th(e,n,i);xh={ids:new Set(a.map(e=>e.id)),offset:i}}function Nh(e){let{shapes:t,selectedIds:n,style:r}=e.getState(),i=t.find(e=>n.has(e.id));i&&(yh=uh(i,r))}function Ph(e){if(!yh)return;let t=yh,n=e.getState(),r=ha(n.shapes,n.selectedIds).map(e=>sh(e,t));r.length>0&&n.replaceMany(r)}function Fh(){return gh.length>0}function Ih(){return _h}function Lh(){return yh!==null}var Rh=0;function zh(e){let t=Rh;Rh=(t+1)%8;let n=t*24;return{x:e.x+n,y:e.y+n}}function Bh(e,t,n){let r=e.getState(),i=zh(n),a=xo(t,i,{fontSize:r.style.fontSize,fontFamily:r.style.fontFamily,color:ci,opacity:1}),o=vo(a),s={...a,x:i.x-o.width/2,y:i.y-o.height/2};r.addShape(s),r.setSelectedIds(new Set([s.id]))}function Vh(e,t,n,r){let i=e.getState(),a=zh(r),o=cs({x:0,y:0},{fontFamily:i.style.fontFamily,color:ci,opacity:1}),s={...o,chartType:n,cells:Uo(t),x:a.x-o.width/2,y:a.y-o.height/2};i.addShape(s),i.setSelectedIds(new Set([s.id]))}function Hh(e,t,n){if(Ao(t)){e.getState().setPasteChoiceGrid(t);return}Bh(e,t,n)}function Uh(e,t,n){let r=e.getState(),i=r.pasteChoiceGrid;if(r.setPasteChoiceGrid(null),i){if(t===`table`){Bh(e,i,n);return}Vh(e,i,t,n)}}function Wh(e){let{containerRef:t,addShape:n,setSelectedIds:r}=e,i=W(),{measurement:a}=H(),o=(0,J.useCallback)(()=>{let e=t.current?.getBoundingClientRect();return e?nt({x:e.width/2,y:e.height/2},i.getState().viewport):{x:0,y:0}},[t,i]),s=(0,J.useCallback)(()=>{let e=t.current?.getBoundingClientRect();if(!e)return;let n=i.getState().viewport,r=nt({x:0,y:0},n),a=nt({x:e.width,y:e.height},n);return{x:r.x,y:r.y,width:a.x-r.x,height:a.y-r.y}},[t,i]),c=U(e=>e.pasteChoiceGrid)!==null,l=(0,J.useCallback)(e=>Hh(i,e,o()),[i,o]),u=(0,J.useCallback)(e=>Uh(i,e,o()),[i,o]),{hasClipboard:d,clipboardCopyId:f,hasStyleClipboard:p}=ph,m=(0,J.useCallback)(()=>Oh(i,a),[i,a]),h=(0,J.useCallback)(()=>kh(i,a),[i,a]),g=(0,J.useCallback)(()=>Nh(i),[i]),_=(0,J.useCallback)(()=>Ph(i),[i]),v=(0,J.useCallback)(()=>Mh(i,a),[i,a]),y=(0,J.useCallback)(e=>Ah(i,e,s()),[i,s]),b=(0,J.useCallback)((e,t)=>jh(i,e,t,o()),[i,o]),x=(0,J.useCallback)(e=>{let t=e.trim();if(!t)return;let a=Su(o(),i.getState().style,{text:t});n(a),r(new Set([a.id]))},[i,o,n,r]),S=(0,J.useCallback)(e=>{let t=Jo(e,o());n(t),r(new Set([t.id]))},[o,n,r]),C=(0,J.useCallback)(async()=>{let e=``;try{e=await navigator.clipboard.readText()}catch{return}x(e)},[x]);return(0,J.useMemo)(()=>({viewportCenterWorld:o,viewportBoundsWorld:s,pasteChoiceOpen:c,pasteGrid:l,resolvePasteChoice:u,copySelection:m,cutSelection:h,copyStyles:g,pasteStyles:_,duplicateSelection:v,hasClipboard:d,clipboardCopyId:f,hasStyleClipboard:p,pasteClipboard:y,pasteExternal:b,pasteText:x,pasteEmbed:S,pasteAsText:C}),[o,s,c,l,u,m,h,g,_,v,d,f,p,y,b,x,S,C])}function Gh(){return new Map}var Kh=Gh();function qh(e,t=``){return`${t?`${t} `:``}16px ${e}`}var Jh=[`bold`,`italic`,`italic bold`];function Yh(e,t,n){let r=t.map(t=>{let r=n.get(t);if(r)return r;let i=e.load(t).catch(e=>{throw n.delete(t),e});return n.set(t,i),i});return Promise.all(r).then(()=>void 0,()=>void 0)}function Xh(e){let t=Vi(e).families;return ni.map(e=>e.value).filter(e=>t.has(Pi(e)))}function Zh(e,t,n){return Yh(e,[qh(t),...Jh.map(e=>qh(t,e))],n)}function Qh(e){let t=window;if(t.requestIdleCallback){let n=t.requestIdleCallback(e);return()=>{t.cancelIdleCallback?.(n)}}let n=window.setTimeout(e,200);return()=>{window.clearTimeout(n)}}var $h=qh(li);function eg(e){return Array.from(new Set([li,...Xh(e.getState().shapes)]))}function tg(){let[e,t]=(0,J.useState)(!1),n=W();return(0,J.useEffect)(()=>{if(typeof document>`u`||!(`fonts`in document)){t(!0);return}let e=!1,r=()=>{},i=eg(n),a=i.map(e=>qh(e)),o=i.flatMap(e=>Jh.map(t=>qh(e,t))),s=()=>{e||(t(!0),r=Qh(()=>{Yh(document.fonts,o,Kh)}))};return Yh(document.fonts,[$h,...a],Kh).then(s,s),()=>{e=!0,r()}},[n]),e}function ng(){let e=Ga();(0,J.useEffect)(()=>{let t=document.documentElement;t.classList.toggle(`dark`,e===`dark`),t.style.colorScheme=e,document.querySelector(`meta[name="theme-color"]`)?.setAttribute(`content`,e===`dark`?`#1c1c1f`:`#ffffff`)},[e])}var rg=`(max-width: 639px)`,ig=`(max-width: 1023px)`,ag=`(pointer: coarse)`;function og(e,t){return e.matches?`phone`:t.matches?`tablet`:`desktop`}function sg(){let e=W();(0,J.useEffect)(()=>{let t=window.matchMedia(rg),n=window.matchMedia(ig),r=window.matchMedia(ag),{setDeviceMode:i,setCoarsePointer:a}=e.getState(),o=()=>{i(og(t,n)),a(r.matches)};o();for(let e of[t,n,r])e.addEventListener(`change`,o);return()=>{for(let e of[t,n,r])e.removeEventListener(`change`,o)}},[e])}function cg(){let{uploadImage:e}=te(),{store:t,history:n}=H(),{runWithoutHistory:r}=n,i=(0,J.useRef)(new Map);(0,J.useEffect)(()=>{if(!e)return;let n=i.current,a=(e,n)=>{let i=t.getState(),a=At(i.shapes,`image`).filter(t=>t.src===e);a.length!==0&&r(()=>{for(let e of a)i.updateShape(e.id,{src:n})})},o=t=>{for(let r of At(t,`image`)){if(!r.src.startsWith(`data:`))continue;let t=r.src,i=n.get(t);if(!(i===`pending`||i===`failed`)){if(typeof i==`string`){a(t,i);continue}n.set(t,`pending`),e(t).then(e=>{n.set(t,e),a(t,e)},()=>{n.set(t,`failed`)})}}};return o(t.getState().shapes),t.subscribe((e,t)=>{e.shapes!==t.shapes&&o(e.shapes)})},[e,t,r])}function lg(){let e=te(),t=e.widgetOrigin,n=e.embed!==void 0,r=e.publicShare===!0;return(0,J.useMemo)(()=>({widgetOrigin:t,embedded:n,clickToRun:r}),[t,n,r])}var ug=6,dg=3,fg=160;function pg(e){return e?.startsWith(`http://localhost`)?dg:ug}var mg=new Map;function hg(e){let t=mg.get(e);if(t!==void 0)return t;let n=Qn(e);return mg.size>500&&mg.clear(),mg.set(e,n),n}function gg(e,t){if(t.embedded)return null;if(e.kind===`embed`){let t=e.url?hg(e.url):null;return t?{kind:`embed`,embed:t}:null}if(e.kind===`html`){let n=Jc(e);return!t.widgetOrigin||!n?null:{kind:`html`,source:n,origin:t.widgetOrigin}}return null}function _g(e,t){return e.kind===`embed`?e.embed.video:t.clickToRun}function vg(e){if(!e.video)return e.src;let t=new URL(e.src);return t.searchParams.set(`autoplay`,`1`),t.href}function yg(e){let{candidates:t,viewport:n,view:r,interactingId:i,selectedIds:a,limit:o}=e,s=n.zoom,c=-n.x/s,l=-n.y/s,u=c+r.width/s,d=l+r.height/s,f=(c+u)/2,p=(l+d)/2,m=[];for(let e of t){let t=e.id===i;if(!t&&(!(e.x<u&&e.x+e.width>c&&e.y<d&&e.y+e.height>l)||e.width*s<fg))continue;let n=t?0:a.has(e.id)?1:e.bare?2:3,r=e.x+e.width/2-f,o=e.y+e.height/2-p;m.push({id:e.id,rank:n,distance:r*r+o*o})}return m.sort((e,t)=>e.rank-t.rank||e.distance-t.distance),m.slice(0,Math.max(0,o)).map(e=>e.id)}function bg(e){let{previous:t,wanted:n,now:r,mayMount:i,urgent:a,limit:o,graceMs:s}=e,c=new Set(n),l=new Set,u=new Map;for(let e of t.live){if(c.has(e)){l.add(e);continue}let n=t.graceUntil.get(e)??r+s;n>r&&(l.add(e),u.set(e,n))}let d=n.filter(e=>!l.has(e)&&(i||e===a));for(let e of d){if(l.size>=o){let e=[...u.entries()].sort((e,t)=>e[1]-t[1])[0];if(!e)break;l.delete(e[0]),u.delete(e[0])}l.add(e)}return{live:l,graceUntil:u}}function xg(e){return e.type===`web`}var Sg=120,Cg=50,wg=9,Tg=2;function Eg(e){return e.length<2?``:bn(xr(e.map(e=>[e.x,e.y]),{size:wg,thinning:0,smoothing:.5,streamline:.32,simulatePressure:!1,start:{taper:60,cap:!0},end:{taper:0,cap:!0}}))}function Dg(){let e=W(),t=(0,J.useRef)([]),n=(0,J.useRef)(!1),r=(0,J.useRef)(``);(0,J.useEffect)(()=>{let n=0,i=()=>{let a=performance.now()-Sg,o=t.current;for(;o.length>0&&o[0].t<a;)o.shift();let s=0;for(let e=o.length-1;e>0;--e)if(s+=Math.hypot(o[e].x-o[e-1].x,o[e].y-o[e-1].y),s>Cg){o.splice(0,e);break}let c=Eg(o);c!==r.current&&(r.current=c,e.getState().setEraserTrail(c)),n=requestAnimationFrame(i)};return n=requestAnimationFrame(i),()=>cancelAnimationFrame(n)},[e]);function i(e){n.current=!0,t.current.push({x:e.x,y:e.y,t:performance.now()})}function a(e){if(!n.current)return;let r=t.current,i=r[r.length-1];(!i||Math.abs(e.x-i.x)>=Tg||Math.abs(e.y-i.y)>=Tg)&&r.push({x:e.x,y:e.y,t:performance.now()})}function o(){n.current=!1}return{start:i,move:a,end:o}}var Og={move(e,t,n){let r=t.getState();if(!e.moved){let t=Math.hypot(n.clientX-e.startX,n.clientY-e.startY);if(t<4&&e.button===2)return;e.moved=t>=4,r.setIsPanning(!0)}let i=e.viewportX+(n.clientX-e.startX),a=e.viewportY+(n.clientY-e.startY);r.setViewport(e=>({...e,x:i,y:a}))},end(e,t,n){if(e.button===2){if(!e.menuSwallowed){t.suppressNextMenu.current=e.moved;return}e.moved||document.elementFromPoint(n.clientX,n.clientY)?.dispatchEvent(new MouseEvent(`contextmenu`,{bubbles:!0,cancelable:!0,view:window,clientX:n.clientX,clientY:n.clientY,button:2}))}}};function kg(e){if(wn[e.type].hit===`outline`){let t=G(e);return[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y},{x:t.x+t.width,y:t.y+t.height},{x:t.x,y:t.y+t.height},{x:t.x,y:t.y}]}return Du(e)}function Ag(e,t,n){let r=1/0;for(let i=0;i<n.length-1;i+=1){let a=n[i],o=n[i+1];if(r=Math.min(r,Ir(e,a,o),Ir(t,a,o),Ir(a,e,t),Ir(o,e,t)),r===0)return 0}return r}function jg(e,t,n,r,i){if(!Ze(e)){let i=`strokeWidth`in e?e.strokeWidth??0:0,a=r+(e.type===`draw`?gn(e):i)+1;if(!Ar(Ur(Bt(e),a),wr([t,n])))return!1}let a=kg(e);if(a){if(a.length<2)return!1;let i=e.type===`draw`?gn(e):`strokeWidth`in e?e.strokeWidth??0:0;return Ag(t,n,a)<=r+i/2}let o=pa(e,i);return qr(o.toLocal(t),o.toLocal(n),o.footprint,r)}var Mg=.5;function Ng(e,t){return t===`x`?[e.x,e.x+e.width/2,e.x+e.width]:[e.y,e.y+e.height/2,e.y+e.height]}function Pg(e,t,n){let[r,i,a]=Ng(e,t),[o,s,c]=Ng(e,t===`x`?`y`:`x`);return Math.abs(r-n)<=Mg||Math.abs(a-n)<=Mg?[o,c]:Math.abs(i-n)<=Mg?[s]:[]}function Fg(e,t,n,r=[]){let i=[...n.flatMap(n=>Pg(n,e,t)),...r],a=n.flatMap(t=>{let[n,,r]=Ng(t,e===`x`?`y`:`x`);return[n,r]});return{axis:e,pos:t,start:Math.min(...a,...r),end:Math.max(...a,...r),marks:i}}function Ig(e,t,n,r){let i=null;for(let a of t)for(let t of Ng(a,n))for(let n of e){let e=t-n;Math.abs(e)<=r&&(!i||Math.abs(e)<Math.abs(i.delta))&&(i={delta:e,pos:t,target:a})}return i}function Lg(e,t,n){let r=Ig(Ng(e,`x`),t,`x`,n),i=Ig(Ng(e,`y`),t,`y`,n),a=r?r.delta:0,o=i?i.delta:0,s={x:e.x+a,y:e.y+o,width:e.width,height:e.height},c=[];if(r){let e=Math.abs(s.x-r.target.x)<=Mg,t=Math.abs(s.x+s.width-(r.target.x+r.target.width))<=Mg;e&&t?(c.push(Fg(`x`,s.x,[s,r.target])),c.push(Fg(`x`,s.x+s.width,[s,r.target]))):c.push(Fg(`x`,r.pos,[s,r.target]))}if(i){let e=Math.abs(s.y-i.target.y)<=Mg,t=Math.abs(s.y+s.height-(i.target.y+i.target.height))<=Mg;e&&t?(c.push(Fg(`y`,s.y,[s,i.target])),c.push(Fg(`y`,s.y+s.height,[s,i.target]))):c.push(Fg(`y`,i.pos,[s,i.target]))}return{dx:a,dy:o,guides:c}}function Rg(e,t,n){let r=Ig([e.x],t,`x`,n),i=Ig([e.y],t,`y`,n),a=r?r.pos:e.x,o=i?i.pos:e.y,s=[];return r&&s.push(Fg(`x`,r.pos,[r.target],[o])),i&&s.push(Fg(`y`,i.pos,[i.target],[a])),{point:{x:a,y:o},guides:s}}var zg=32;function Bg(e,t,n,r){let i=r===`x`?`x`:`y`,a=r===`x`?`width`:`height`,o=r===`x`?`y`:`x`,s=r===`x`?`height`:`width`,c=e=>e[i],l=e=>e[i]+e[a],u=e=>e[o],d=e=>e[o]+e[s],f=(e,t)=>Math.min(d(e),d(t))-Math.max(u(e),u(t)),p=t.filter(t=>f(e,t)>0),m=c(e),h=e[a];if(p.length>zg){let e=m+h/2;p=p.map(t=>({t,dist:Math.abs(c(t)+t[a]/2-e)})).sort((e,t)=>e.dist-t.dist).slice(0,zg).map(e=>e.t)}let g=null,_=n,v=(t,n,i)=>{let a=t-m,o=Math.abs(a);o>_||(g={delta:a,guide:{kind:`gap`,axis:r,cross:(Math.max(u(e),...n.map(u))+Math.min(d(e),...n.map(d)))/2,bars:i}},_=o)};for(let e of p)for(let t of p){if(e===t||l(e)>c(t))continue;let n=(c(t)-l(e)-h)/2;if(n>=-.01){let r=l(e)+n;v(r,[e,t],[{from:l(e),to:r},{from:r+h,to:c(t)}])}if(f(e,t)>0){let n=c(t)-l(e),r=l(t)+n;v(r,[e,t],[{from:l(e),to:c(t)},{from:l(t),to:r}]);let i=c(e)-n-h;v(i,[e,t],[{from:i+h,to:c(e)},{from:l(e),to:c(t)}])}}return g}function Vg(e,t,n){let r=Bg(e,t,n,`x`),i=Bg(e,t,n,`y`),a=[];return r&&a.push(r.guide),i&&a.push(i.guide),{dx:r?r.delta:0,dy:i?i.delta:0,snappedX:r!==null,snappedY:i!==null,guides:a}}var Hg=Math.PI/12;function Ug(e,t){let n=e.x+e.width/2;t.includes(`w`)?n=e.x:t.includes(`e`)&&(n=e.x+e.width);let r=e.y+e.height/2;return t.includes(`n`)?r=e.y:t.includes(`s`)&&(r=e.y+e.height),{x:n,y:r}}function Wg(e,t,n,r,i){if(e.type===`arrow`)return null;let a;a=e.type===`text`&&r?r.box:e.type===`icon`&&i?i:G(e);let o=cr(e)*Math.PI/180,s=o?Ln(n,Zn(e),-o):n,c=Ug(a,t);return{x:s.x-c.x,y:s.y-c.y}}function Gg(e,t,n){return nt({x:e.clientX-t.left,y:e.clientY-t.top},n)}function Kg(e,t){return{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),width:Math.abs(e.x-t.x),height:Math.abs(e.y-t.y)}}function qg(e,t){return e.x<=t.x&&e.y<=t.y&&e.x+e.width>=t.x+t.width&&e.y+e.height>=t.y+t.height}function Jg(e,t,n){let r=t.x-e.x,i=t.y-e.y,a=Math.hypot(r,i),o=Math.round(Math.atan2(i,r)/n)*n;return{x:e.x+Math.cos(o)*a,y:e.y+Math.sin(o)*a}}function Yg(e,t,n,r,i,a){let o=n,s;if(!r.shift&&!r.alt&&!r.noSnap){let t=i(new Set([e.id])),n=Rg(o,t,a);o=n.point,s=n.guides}let c=o.x-t.startWorld.x,l=o.y-t.startWorld.y;if(r.shift){let e=Math.max(Math.abs(c),Math.abs(l));c=(c<0?-1:1)*e,l=(l<0?-1:1)*e}return r.alt?{draft:{...e,x:t.startWorld.x-c,y:t.startWorld.y-l,width:c*2,height:l*2},guides:s}:{draft:{...e,width:c,height:l},guides:s}}function Xg(e,t,n){let r=Math.abs(e.x-t.x),i=Math.abs(e.y-t.y);return i<=r&&i<=n?{point:{x:e.x,y:t.y},guide:{axis:`y`,pos:t.y,start:Math.min(t.x,e.x),end:Math.max(t.x,e.x)}}:r<=n?{point:{x:t.x,y:e.y},guide:{axis:`x`,pos:t.x,start:Math.min(t.y,e.y),end:Math.max(t.y,e.y)}}:{point:e,guide:null}}function Zg(e,t,n,r,i,a){let o=Fe(n,e,i.excludeId,a);o&&i.forbidNode?.(o)&&(o=null);let s=t.shift?Jg(i.anchor,e,Hg):e,c=e,l=null,u=null,d=[];if(o)c=t.shift&&Fe(n,s,i.excludeId,a)===o?s:e;else{let f=lf(s,n,r/6*10,i.excludeId);if(f)if(c=f.point,l=f.point,f.attach)je(n,i.excludeId,f.attach.shapeId)||(u={kind:`path`,...f.attach});else{let e=Fe(n,f.point,i.excludeId,a);e&&!i.forbidNode?.(e)&&(o=e,l=null)}else if(t.shift)c=s;else{let t=Xg(e,i.otherRef(),r);c=t.point,t.guide&&(d=[t.guide])}}return{point:c,node:o,attach:u,snapDot:l,guides:d}}function Qg(e,t,n,r,i,a,o,s){if(e.type===`rectangle`||e.type===`figure`||e.type===`chart`||e.type===`control`)return Yg(e,t,n,r,a,o);if(e.type===`icon`){let r=n.x-t.startWorld.x,i=n.y-t.startWorld.y,a=Rt(Math.max(Math.abs(r),Math.abs(i)),Zc(e.source,e.name));return{draft:{...e,x:r<0?t.startWorld.x-a.width:t.startWorld.x,y:i<0?t.startWorld.y-a.height:t.startWorld.y,width:a.width,height:a.height}}}if(e.type===`draw`)return{draft:{...e,points:[...e.points,n]}};if(e.type===`arrow`){if(r.alt){let i=r.shift?Jg(t.startWorld,n,Hg):n;return{draft:{...e,x2:i.x,y2:i.y},guides:[],bindTarget:null,snapDot:null}}let{point:a,node:c,snapDot:l,guides:u}=Zg(n,r,i,o,{excludeId:e.id,anchor:t.startWorld,otherRef:()=>Re(e,i,void 0,s).start},s);return{draft:{...e,x2:a.x,y2:a.y},guides:u,bindTarget:c?{id:c.id,point:We(c,a,s)}:null,snapDot:l}}return{draft:e}}function $g(e,t){if(e.length===1){let n=G(e[0],t);return{x:n.x+n.width/2,y:n.y+n.height/2}}let n=pn(e,t);return n?{x:n.x+n.width/2,y:n.y+n.height/2}:null}function e_(e,t,n){let r=Math.atan2(t.y-e.center.y,t.x-e.center.x)-e.startAngle;if(!n.shift)return r;let i=e.frameAngle*Math.PI/180;return Math.round((i+r)/Hg)*Hg-i}function t_(e,t,n){let r=e_(e,t,n);return{shapes:e.originals.map(t=>Ct(t,e.center,r))}}var n_={move(e,t,n){let r=t.getState(),i=Gg(n,e.rect,r.viewport),a=5/r.viewport.zoom,o=!1;for(let n of r.shapes)e.ids.has(n.id)||n.locked||jg(n,e.last,i,a,t.measurement)&&(e.ids.add(n.id),o=!0);e.last=i,t.eraserTrail.move({x:n.clientX,y:n.clientY}),o&&r.setErasingIds(new Set(e.ids))},end(e,t){let n=t.getState();e.ids.size>0&&(n.removeShapes(e.ids),n.setSelectedIds(new Set([...n.selectedIds].filter(t=>!e.ids.has(t))))),t.getState().setErasingIds(new Set),t.eraserTrail.end()}},r_=3,i_={width:os.width/2,height:os.height/2},a_=new Set([`image`,`avatar`,`divider`,`progress`,`slider`,`scrollbar`,`rating`,`lifeline`]);function o_(e){return e.type===`chart`?i_:e.type===`control`&&!a_.has(e.kind)?Ci[e.kind]:null}function s_(e){if(e.type!==`control`&&e.type!==`chart`)return!0;let t=o_(e);return!t||Math.abs(e.width)>=t.width&&Math.abs(e.height)>=t.height}function c_(e,t,n=!1,r){if(e.type===`draw`)return e.points.length>=2?e:null;if(e.type===`rectangle`){if(Math.abs(e.width)<r_&&Math.abs(e.height)<r_){let t=Nt(e.kind);return{...e,width:t.width,height:t.height}}return e}if(e.type===`icon`)return e.width<r_&&e.height<r_?{...e,...Xc(e.source,e.name)}:e;if(e.type===`figure`){if(Math.abs(e.width)<r_&&Math.abs(e.height)<r_){let t=es[e.kind??`simple`];return{...e,width:t.width,height:t.height}}return e}if(e.type===`control`||e.type===`chart`){let t=G(e);if(e.type===`chart`&&t.width<r_&&t.height<r_){let n=as(e.chartType);return{...e,x:t.x,y:t.y,width:n.width,height:n.height}}let n=o_(e);if(n)return{...e,x:t.x,y:t.y,width:Math.max(t.width,n.width),height:Math.max(t.height,n.height)};if(e.type===`control`&&t.width<r_&&t.height<r_){let n=Ci[e.kind];return{...e,x:t.x,y:t.y,width:n.width,height:n.height}}return e}if(e.type===`arrow`){if(Math.hypot(e.x2-e.x,e.y2-e.y)<r_)return null;let i={x:e.x2,y:e.y2},a=n?null:Fe(t,i,e.id,r),o=n?null:e.startBinding,s=a?He(a,i,r):null;if(!a&&!n){let n=lf(i,t,.01,e.id);n?.attach&&(s={kind:`path`,...n.attach})}return o&&s&&o.shapeId===s.shapeId&&!Ge(o)&&(o=null,s=null),{...e,startBinding:o,endBinding:s}}return e}var l_={x:0,y:0},u_=1e-6;function d_(e){return e*Math.PI/180}function f_(e){let t=((e+180)%360+360)%360-180,n=t===-180?180:t;return Math.abs(n)<u_?0:n}function p_(e,t,n,r){if(!e||e.selection!==t||n.length<2||e.shapes.length!==n.length)return null;let i=new Map(e.shapes.map(e=>[e.id,e]));for(let e of n){let t=i.get(e.id);if(!t||!r&&t!==e)return null}return e.angle}function m_(e,t,n){let r=f_(n);return t.length<2||r===0?null:{angle:r,selection:e,shapes:t}}function h_(e){return[{x:e.x,y:e.y},{x:e.x+e.width,y:e.y},{x:e.x+e.width,y:e.y+e.height},{x:e.x,y:e.y+e.height}]}function g_(e){return wr(e)}function __(e,t,n){if(e.type===`arrow`||e.type===`draw`||e.type===`line`||e.type===`polygon`)return Cn(Ct(e,l_,-t),n);let r=G(e,n),i={x:r.x+r.width/2,y:r.y+r.height/2},a=d_(cr(e));return g_(h_(Dn(e,n)).map(e=>Ln(Ln(e,i,a),l_,-t)))}function v_(e,t,n){if(e.length===0)return null;let r=d_(t),i=g_(e.map(e=>__(e,r,n)).flatMap(h_)),a=Ln({x:i.x+i.width/2,y:i.y+i.height/2},l_,r);return{bounds:{x:a.x-i.width/2,y:a.y-i.height/2,width:i.width,height:i.height},angle:t}}function y_(e,t){return Ln(e,t.pivot,-d_(t.angle))}function b_(e,t,n,r,i){let a=d_(t.angle);return Ct(ir(Ct(e,t.pivot,-a),n,r,i),t.pivot,a)}function x_(e,t,n){return{world:Gg(n,e.rect,t.viewport),snapDist:6/t.viewport.zoom,mods:{shift:n.shiftKey,alt:n.altKey,noSnap:!t.snapEnabled||n.metaKey||n.ctrlKey}}}function S_(e,t,n){return n.size===0?t:t.map(t=>{let r=n.get(t.id),i=Qe(e.shapes,t.id);if(!r||r===`all`||!i)return t;let a={...t},o=i;for(let e of r)e in o?a[e]=o[e]:delete a[e];return a})}function C_(e,t,n){let r=e.getState(),i=Wn(t),a=S_(r,i,e.remoteEdits());a.length!==0&&r.replaceMany(a,a===i?n:void 0)}function w_(e,t){let n=e.getState();t.shape&&dr(t.shape)&&n.replaceShape(S_(n,[t.shape],e.remoteEdits())[0]),t.shapes&&C_(e,t.shapes),t.guides&&n.setSnapGuides(t.guides),`bindTarget`in t&&n.setBindTarget(t.bindTarget??null),`snapDot`in t&&n.setSnapDot(t.snapDot??null)}function T_(e){let t=p_(e.selectionFrame,e.selectedIds,ha(e.shapes,e.selectedIds),!1);return t===null&&e.selectionFrame&&e.setSelectionFrame(null),t}function E_(e,t){let n=ha(e.shapes,e.selectedIds);if(t.kind===`rotate`){let r=n.length===t.originals.length&&t.originals.every(t=>e.selectedIds.has(t.id)),i=(t.turned??0)*180/Math.PI,a=r?m_(e.selectedIds,n,t.frameAngle+i):null;(a||e.selectionFrame)&&e.setSelectionFrame(a);return}if(t.kind!==`group-resize`&&t.kind!==`move`||!e.selectionFrame)return;let r=p_(e.selectionFrame,e.selectedIds,n,!0);e.setSelectionFrame(r===null?null:m_(e.selectedIds,n,r))}var D_={move(e,t,n){let r=t.draft.current;if(!r)return;let i=t.getState(),{world:a,mods:o,snapDist:s}=x_(e,i,n),c=Qg(r,e,a,o,i.shapes,t.snapTargets,s,t.measurement);t.writeDraft(c.draft),c.guides&&i.setSnapGuides(c.guides),`bindTarget`in c&&i.setBindTarget(c.bindTarget??null),`snapDot`in c&&i.setSnapDot(c.snapDot??null)},end(e,t,n){let r=t.draft.current;t.writeDraft(null);let i=t.getState(),a=r?c_(r,i.shapes,n.altKey,t.measurement):null;a&&(i.addShape(a),a.type!==`draw`&&(i.setSelectedIds(new Set([a.id])),i.releaseTool(),a.type===`icon`&&i.setPendingIcon(null),a.type===`control`&&i.setPendingControl(null)))}};function O_(e,t,n,r,i,a,o){if(t.handle===`start`||t.handle===`end`){let s=t.handle===`start`?e.endBinding:e.startBinding,c=t.handle===`start`?{x:e.x2,y:e.y2}:{x:e.x,y:e.y},{point:l,node:u,attach:d,snapDot:f,guides:p}=r.alt?{point:n,node:null,attach:null,snapDot:null,guides:[]}:Zg(n,r,i,a,{excludeId:e.id,anchor:c,otherRef:()=>{let n=Re(e,i,void 0,o);return t.handle===`start`?n.end:n.start},forbidNode:e=>s!=null&&s.shapeId===e.id||Fe([e],c,void 0,o)===e},o),m=u?{id:u.id,point:We(u,l,o)}:null,h=u?He(u,l,o):d,g=t.handle===`start`?{...e,x:l.x,y:l.y,startBinding:h}:{...e,x2:l.x,y2:l.y,endBinding:h};return g.bendStyle===`elbow`&&g.elbowPoints&&(g=Be(g,i,void 0,o)),{shape:g,bindTarget:m,snapDot:f,guides:p}}if(t.handle===`bend`){if(e.bendStyle===`elbow`&&t.elbowSegment!=null&&t.elbowBase)return k_(e,t,n,a);if(e.bendStyle===`elbow`){let t=ze(e,i,void 0,o),r=t.midHandle,s=r?.axis===`x`?t.midXRange:t.midYRange;if(!r||!s)return null;let c=r.axis===`x`?n.x:n.y,l=a/6*10,u=(s.lo+s.hi)/2,d=Math.abs(c-u)<=l?u:c,f=s.hi-s.lo,p=f===0?.5:kr((d-s.lo)/f);return{shape:{...e,elbowMid:p}}}let r=a/6*10;if(e.startBinding||e.endBinding){let t=Re(e,i,void 0,o),a=Xe(t.start,t.end,n),s=ur(a.bowAlong,Mr(t.start,t.end),r);return{shape:{...e,bow:a.bow,bowAlong:s}}}let s=fn(e,n),c=Math.hypot(e.x2-e.x,e.y2-e.y),l=ur(s.bendAlong,c,r);return{shape:{...e,bend:s.bend,bendAlong:l,bow:s.bend,bowAlong:l}}}return null}function k_(e,t,n,r){let i=t.elbowBase,a=t.elbowSegment,o=i[a],s=i[a+1];if(!o||!s)return null;let c=Math.abs(s.y-o.y)<=Math.abs(s.x-o.x),l=c?n.y:n.x,u=r/6*10,d=[c?o.y:o.x];a>=1&&d.push(c?i[a-1].y:i[a-1].x),a+2<i.length&&d.push(c?i[a+2].y:i[a+2].x);for(let e of d)if(Math.abs(l-e)<=u){l=e;break}let f=ar(i,a,l);return f?f.length<3?{shape:{...e,elbowMid:void 0,elbowPoints:void 0,elbowRoute:void 0,elbowMidHandle:void 0}}:{shape:{...e,elbowMid:void 0,elbowPoints:f,elbowRoute:f,elbowMidHandle:void 0}}:null}var A_=.05,j_=.95;function M_(e,t,n,r){let i={x:t.x-n.x,y:t.y-n.y},a=Vr(e.type===`arrow`?yt(e,i):si(e.points,i),A_,j_),o={...e,labelAlong:a},s=o.type===`arrow`?ln(o):Zt(o.points,a),c=e.type===`arrow`?ln({...e,labelAlong:void 0}):Zt(e.points),l=r/6*10;return Mr(s,c)<=l?{shape:{...e,labelAlong:void 0}}:{shape:o}}function N_(e){return e.type===`arrow`?ln(e):Zt(e.points,e.labelAlong)}var P_=.02,F_=16,I_={width:80,height:60},L_=20;function R_(e){return{hasX:e.includes(`e`)||e.includes(`w`),hasY:e.includes(`n`)||e.includes(`s`)}}function z_(e){if(e.type===`rectangle`||e.type===`figure`||e.type===`chart`)return{x:!0,y:!0};if(e.type===`web`)return e.keepAspect?{x:!1,y:!1}:{x:!0,y:!0};if(e.type===`table`)return{x:!0,y:!1};if(e.type===`control`){let t=Ti[e.kind];return t.resize===`width`?{x:!0,y:!1}:t.resize===`height`?{x:!1,y:!0}:t.resize===`free`?{x:!0,y:!0}:{x:!1,y:!1}}return{x:!1,y:!1}}function B_(e,t){let n=e.x+e.width/2;t.includes(`w`)?n=e.x+e.width:t.includes(`e`)&&(n=e.x);let r=e.y+e.height/2;return t.includes(`n`)?r=e.y+e.height:t.includes(`s`)&&(r=e.y),{x:n,y:r}}function V_(e,t,n,r){if(e.type===`arrow`||e.type===`draw`||e.type===`polygon`||e.type===`line`)return e;let i=G(e),a=B_(i,t),o={x:i.x+i.width/2,y:i.y+i.height/2},s=Ln(a,n,r),c=Ln(a,o,r);return{...e,x:e.x+(s.x-c.x),y:e.y+(s.y-c.y)}}function H_(e,t,n){let r=n.x+n.width/2,i=n.y+n.height/2;return{x:e.flipX?2*r-(t.x+t.width):t.x,y:e.flipY?2*i-(t.y+t.height):t.y,width:t.width,height:t.height}}function U_(e,t,n){let r=e.original,i=e.startBounds,a=H_(r,e.imageBox,i),o=e.handle,s=cr(r)*Math.PI/180,c=Zn(r),l=s?Ln(t,c,-s):t,{hasX:u,hasY:d}=R_(o),f=u&&d,p=nn(i,o,l);if(n.alt){let e=i.x+i.width/2,t=i.y+i.height/2,n=p.x,r=p.x+p.width,a=p.y,s=p.y+p.height;if(u){let t=Math.abs((o.includes(`w`)?p.x:r)-e);n=e-t,r=e+t}if(d){let e=Math.abs((o.includes(`n`)?p.y:s)-t);a=t-e,s=t+e}p={x:n,y:a,width:r-n,height:s-a}}if(n.shift&&f){let e=(i.width||1)/(i.height||1),t=p.width,r=p.height;if(t/e>=r?r=t/e:t=r*e,n.alt){let e=i.x+i.width/2,n=i.y+i.height/2;p={x:e-t/2,y:n-r/2,width:t,height:r}}else{let e=o.includes(`w`),n=o.includes(`n`),i=e?p.x+p.width:p.x,a=n?p.y+p.height:p.y;p={x:e?i-t:i,y:n?a-r:a,width:t,height:r}}}let m=Math.max(a.x,Math.min(p.x,a.x+a.width)),h=Math.max(a.x,Math.min(p.x+p.width,a.x+a.width)),g=Math.max(a.y,Math.min(p.y,a.y+a.height)),_=Math.max(a.y,Math.min(p.y+p.height,a.y+a.height)),v={x:Math.min(m,h),y:Math.min(g,_),width:Math.max(8,Math.abs(h-m)),height:Math.max(8,Math.abs(_-g))},y={x:0,y:0,width:1,height:1};if(a.width>0&&a.height>0){let e=v.width/a.width,t=v.height/a.height,n=(v.x-a.x)/a.width,i=(v.y-a.y)/a.height;y={x:r.flipX?1-n-e:n,y:r.flipY?1-i-t:i,width:e,height:t}}let b={x:v.x+v.width/2,y:v.y+v.height/2},x=s?Ln(b,c,s):b;return{shape:{...r,x:x.x-v.width/2,y:x.y-v.height/2,width:v.width,height:v.height,crop:y}}}function W_(e,t,n){if(e.type!==`rectangle`)return e;let r=Qe(t,e.id);return r?.type===`rectangle`?R_(n).hasY?{...e,minHeight:r.minHeight,autoHeightFrom:void 0}:{...e,minHeight:r.minHeight,height:r.height,autoHeightFrom:r.autoHeightFrom}:e}function G_(e,t,n,r,i,a,o){let s=W_(e.original,r,e.handle);if(e.labelDrag&&(s.type===`arrow`||s.type===`line`))return M_(s,t,e.grabOffset??{x:0,y:0},a);if((s.type===`line`||s.type===`polygon`)&&e.lineVertex!=null)return K_(s,e.lineVertex,t,n,r,i,a);if(s.type===`arrow`)return O_(s,e,t,n,r,a,o);let c=cr(s)*Math.PI/180,l=Zn(s),u=e.grabOffset??{x:0,y:0},d={x:t.x-u.x,y:t.y-u.y},f;if(!c&&!n.shift&&!n.alt&&!n.noSnap){let t=R_(e.handle),n=z_(s),r=t.hasX&&n.x,o=t.hasY&&n.y;if(r||o){let e=Rg(d,i(new Set([s.id])),a);d={x:r?e.point.x:d.x,y:o?e.point.y:d.y},f=e.guides.filter(e=>e.axis===`x`&&r||e.axis===`y`&&o)}}let p=Ln(t,l,-c),m=c?{x:p.x-u.x,y:p.y-u.y}:d;if(n.alt&&(s.type===`rectangle`||s.type===`image`))return{shape:q_(s,e,m,l,n)};let h=X_(s,e,m,n);return h?{shape:c?V_(h,e.handle,l,c):h,guides:f}:null}function K_(e,t,n,r,i,a,o){let s=n,c=null,l;if(r.shift){let r=e.points[t-1]??e.points[t+1];r&&(s=Jg(r,n,Hg))}else{if(!r.alt){let r=e.points.filter((e,n)=>n!==t),a=lf(n,i,o/6*10,e.id,r);a&&(s=a.point,c=a.point)}if(!c&&!r.noSnap){let t=Rg(n,a(new Set([e.id])),o);s=t.point,l=t.guides}}return{shape:{...e,points:e.points.map((e,n)=>n===t?s:e)},guides:l,snapDot:c}}function q_(e,t,n,r,i){let a=G(e),{hasX:o,hasY:s}=R_(t.handle),c=o?Math.abs(n.x-r.x):a.width/2,l=s?Math.abs(n.y-r.y):a.height/2;if(e.type===`image`||i.shift&&o&&s){let e=(a.width||1)/(a.height||1);o&&s?c/e>=l?l=c/e:c=l*e:o?l=c/e:c=l*e}return{...e,x:r.x-c,y:r.y-l,width:c*2,height:l*2}}function J_(e,t,n,r){let i=(e.width||1)/(e.height||1),a=R_(t);if(a.hasX&&a.hasY){let r=B_(e,t),a=mt(t),o=Math.max(P_,tt(n.x,r.x,a.x)/(e.width||1),tt(n.y,r.y,a.y)/(e.height||1)),s=(e.width||1)*o,c=s/i;return{x:a.x===1?r.x:r.x-s,y:a.y===1?r.y:r.y-c,width:s,height:c}}let o=nn(e,t,n,r);if(a.hasX){let t=o.width,n=t/i;return{x:o.x,y:e.y+e.height/2-n/2,width:t,height:n}}let s=o.height,c=s*i;return{x:e.x+e.width/2-c/2,y:o.y,width:c,height:s}}function Y_(e,t,n,r){let i=t.iconFootprint??G(e),a=G(e),{hasX:o,hasY:s}=R_(t.handle),c;if(r.alt){let e=i.x+i.width/2,t=i.y+i.height/2,r=Math.abs(n.x-e)*2/i.width,a=Math.abs(n.y-t)*2/i.height;c=o&&s?Math.max(r,a):o?r:a}else{let e=B_(i,t.handle),r=mt(t.handle),a=tt(n.x,e.x,r.x)/i.width,l=tt(n.y,e.y,r.y)/i.height;c=o&&s?Math.max(a,l):o?a:l}let l=Math.max(a.width,a.height),u=Math.max(F_,l*c),d=l?u/l:1,f=i.width*d,p=i.height*d,m,h;if(r.alt)m=i.x+i.width/2-f/2,h=i.y+i.height/2-p/2;else{let e=B_(i,t.handle);m=o?t.handle.includes(`w`)?e.x-f:e.x:i.x+i.width/2-f/2,h=s?t.handle.includes(`n`)?e.y-p:e.y:i.y+i.height/2-p/2}return{...e,x:m+(a.x-i.x)*d,y:h+(a.y-i.y)*d,width:a.width*d,height:a.height*d,fontSize:Math.max(6,Math.round((e.fontSize??36)*d))}}function X_(e,t,n,r){if(e.type===`image`)return{...e,...J_(G(e),t.handle,n)};if(e.type===`rectangle`){let i=R_(t.handle);return r.shift&&i.hasX&&i.hasY?{...e,...J_(G(e),t.handle,n)}:{...e,...nn(G(e),t.handle,n,{height:e.minHeight??0})}}if(e.type===`icon`)return Y_(e,t,n,r);if(e.type===`web`){let i=R_(t.handle),a=e.keepAspect===!0||r.shift&&i.hasX&&i.hasY,o=G(e);return{...e,...a?J_(o,t.handle,n,I_):nn(o,t.handle,n,I_)}}if(e.type===`figure`)return{...e,...nn(G(e),t.handle,n)};if(e.type===`table`){let r=G(e),i=nn(r,t.handle,n),a=r.width?i.width/r.width:1;return{...e,x:i.x,colWidths:e.colWidths.map(e=>Math.max(L_,e*a))}}if(e.type===`chart`){let r=o_(e)??{width:360,height:240};return{...e,...nn(G(e),t.handle,n,r)}}if(e.type===`control`){let r=G(e),i=Ti[e.kind];if(i.resize===`aspect`)return{...e,...J_(r,t.handle,n,{width:24,height:24})};let a=i.resize===`free`?o_(e)??{width:24,height:16}:{width:24,height:16},o=nn(r,t.handle,n,a);return i.resize===`width`?{...e,x:o.x,y:r.y,width:o.width,height:r.height}:i.resize===`height`?{...e,x:r.x,y:o.y,width:r.width,height:o.height}:e.kind===`lifeline`&&R_(t.handle).hasX?{...e,...o,widthManual:!0}:{...e,...o}}if(e.type===`draw`||e.type===`polygon`||e.type===`line`){let r=G(e),i=nn(r,t.handle,n),a=r.width?i.width/r.width:1,o=r.height?i.height/r.height:1;return{...e,points:e.points.map(e=>({x:i.x+(e.x-r.x)*a,y:i.y+(e.y-r.y)*o}))}}return e.type===`text`&&t.textStart?dt(e,t.handle,n,t.textStart,r.alt):null}function Z_(e,t,n,r,i){let a=e.startBounds,{hasX:o,hasY:s}=R_(e.handle),c=e.grabOffset??{x:0,y:0},l=e.frame,u=l?y_(t,l):t,d={x:u.x-c.x,y:u.y-c.y},f;if(!l&&!n.shift&&!n.noSnap){let t=new Set(e.originals.map(e=>e.id)),n=Rg(d,r(t),i);d={x:o?n.point.x:d.x,y:s?n.point.y:d.y},f=n.guides.filter(e=>e.axis===`x`&&o||e.axis===`y`&&s)}let p=e.handle.includes(`w`)?a.x+a.width:a.x,m=e.handle.includes(`n`)?a.y+a.height:a.y,h=mt(e.handle),g=o&&a.width?Math.max(P_,tt(d.x,p,h.x)/a.width):1,_=s&&a.height?Math.max(P_,tt(d.y,m,h.y)/a.height):1;if(n.shift&&o&&s){let e=Math.max(g,_);g=e,_=e}let v={x:p,y:m};return{shapes:e.originals.map(e=>l?b_(e,l,v,g,_):ir(e,v,g,_)),guides:f}}function Q_(e,t,n,r,i,a){let o=e.type===`icon`?Cn(e,a):null;return{kind:`resize`,handle:t,original:e,rect:r,textStart:i,iconFootprint:o,grabOffset:Wg(e,t,n,i,o)}}function $_(e,t,n){let r=N_(e);return{kind:`resize`,handle:`bend`,original:e,rect:n,textStart:null,iconFootprint:null,labelDrag:!0,grabOffset:{x:t.x-r.x,y:t.y-r.y}}}function ev(e,t,n){return{kind:`resize`,handle:`bend`,original:e,rect:n,textStart:null,iconFootprint:null,lineVertex:t}}function tv(e,t,n){return{kind:`resize`,handle:`bend`,original:e,rect:n,textStart:null,iconFootprint:null,elbowSegment:t,elbowBase:St(e)}}function nv(e,t,n,r){let i=G(e,r);return{kind:`crop`,original:e,handle:t,imageBox:Et(i,e.crop),startBounds:i,rect:n}}function rv(e,t,n,r,i){let a=ha(e.shapes,e.selectedIds),o=T_(e),s=o===null?null:v_(a,o,i),c=s?.bounds??pn(a,i);if(!c)return null;let l=s?{pivot:{x:c.x+c.width/2,y:c.y+c.height/2},angle:s.angle}:void 0,u=l?y_(n,l):n,d=Ug(c,t);return{kind:`group-resize`,handle:t,originals:a,startBounds:c,rect:r,grabOffset:{x:u.x-d.x,y:u.y-d.y},frame:l}}function iv(e,t,n,r){let i=ha(e.shapes,e.selectedIds),a=T_(e),o=a===null?null:v_(i,a,r),s=o?{x:o.bounds.x+o.bounds.width/2,y:o.bounds.y+o.bounds.height/2}:$g(i,r);return s?{kind:`rotate`,originals:i,center:s,startAngle:Math.atan2(t.y-s.y,t.x-s.x),rect:n,frameAngle:a??0}:null}var av={move(e,t,n){let r=t.getState(),{world:i,mods:a}=x_(e,r,n);r.setTransforming(!0),e.turned=e_(e,i,a),w_(t,t_(e,i,a))}},ov={move(e,t,n){let{world:r,mods:i}=x_(e,t.getState(),n);w_(t,U_(e,r,i))}},sv={move(e,t,n){let r=t.getState(),{world:i,mods:a,snapDist:o}=x_(e,r,n);r.setTransforming(!0),r.setResizing(!0);let s=G_(e,i,a,r.shapes,t.snapTargets,o,t.measurement);s&&w_(t,s)}},cv={move(e,t,n){let r=t.getState(),{world:i,mods:a,snapDist:o}=x_(e,r,n);r.setTransforming(!0),w_(t,Z_(e,i,a,t.snapTargets,o))}};function lv(e,t){return qg({x:t.x+8,y:t.y+8,width:t.width-16,height:t.height-16},e)}function uv(e){return[{x:e.x,y:e.y},{x:e.x+e.width,y:e.y},{x:e.x+e.width,y:e.y+e.height},{x:e.x,y:e.y+e.height}]}function dv(e,t){for(let n of[e,t])for(let r=0;r<n.length;r+=1){let i=n[r],a=n[(r+1)%n.length],o={x:a.y-i.y,y:i.x-a.x},s=e=>e.x*o.x+e.y*o.y,c=e.map(s),l=t.map(s);if(Math.max(...c)<Math.min(...l)||Math.max(...l)<Math.min(...c))return!1}return!0}function fv(e,t){let n=pa(e,t);return{local:n.footprint,polygon:uv(n.footprint).map(n.toWorld),toLocal:e=>uv(e).map(n.toLocal)}}function pv(e,t,n){let r=fv(e,n);if(!dv(r.polygon,uv(t)))return!1;if(!Nn(e))return!0;let i=r.toLocal(t),a=i.map(e=>e.x),o=i.map(e=>e.y);return!lv({x:Math.min(...a),y:Math.min(...o),width:Math.max(...a)-Math.min(...a),height:Math.max(...o)-Math.min(...o)},r.local)}function mv(e,t,n,r,i){let a=new Set(n);for(let n of e){let e=Cn(n,i),r;r=n.type===`figure`?qg(t,e):Tu(n)?Ar(Ur(e,ku(n)+1),t)&&Au(n,t):cr(n)?zr(e,t)&&pv(n,t,i):Nn(n)?zr(e,t)&&!lv(t,e):zr(e,t),r&&!n.locked&&a.add(n.id)}return $p(e,a,r)}function hv(e,t){if(t.length<3)return!1;let n=!1;for(let r=0,i=t.length-1;r<t.length;i=r,r+=1){let a=t[r],o=t[i];a.y>e.y!=o.y>e.y&&e.x<(o.x-a.x)*(e.y-a.y)/(o.y-a.y)+a.x&&(n=!n)}return n}function gv(e,t){return[{x:e.x,y:e.y},{x:e.x+e.width,y:e.y},{x:e.x,y:e.y+e.height},{x:e.x+e.width,y:e.y+e.height}].every(e=>hv(e,t))}function _v(e){return wr(e)}var vv=192;function yv(e){return Math.max(1,Math.ceil((e-1)/vv))}function bv(e,t){let n=yv(e.length);for(let r=0;r<e.length;r+=n)if(hv(e[r],t))return!0;for(let r=0;r+n<e.length;r+=n)for(let i=0,a=t.length-1;i<t.length;a=i,i+=1)if(ai(e[r],e[r+n],t[a],t[i]))return!0;return!1}function xv(e,t,n,r){let i=new Set(n);if(t.length>=3){let n=_v(t);for(let r of e){if(r.locked)continue;let e;if(r.type===`figure`){let i=Cn(r);e=Sv(i,n)&&gv(i,t)}else if(Tu(r)){let i=Ar(Cn(r),n)?Du(r):null;e=i!==null&&bv(i,t)}else{let i=Zn(r);e=Wr(i,n)&&hv(i,t)}e&&i.add(r.id)}}return $p(e,i,r)}function Sv(e,t){return e.x>=t.x&&e.y>=t.y&&e.x+e.width<=t.x+t.width&&e.y+e.height<=t.y+t.height}var Cv={move(e,t,n){let r=t.getState(),{world:i}=x_(e,r,n);r.setMarquee({start:e.startWorld,end:i});let a=Kg(e.startWorld,i),o=r.viewport.zoom;(a.width*o>4||a.height*o>4)&&(t.moved.current=!0),r.setSelectedIds(mv(r.shapes,a,e.base,r.activeGroupId,t.measurement))}},wv={move(e,t,n){let r=t.getState(),{world:i}=x_(e,r,n);e.points.push(i),r.setLasso([...e.points]),r.setSelectedIds(xv(r.shapes,e.points,e.base,r.activeGroupId))},end(e,t){t.getState().releaseTool()}},Tv=new WeakMap;function Ev(e,t){let n=Tv.get(e);if(n)return n;let r=new Map(e.map(e=>[e.id,e])),i=new Set(r.keys()),a={movingIds:i,originalById:r,sliderIds:new Set(e.filter(e=>Ne(e,i)).map(e=>e.id)),rigidIds:Ve(e),base:pn(e,t)};return Tv.set(e,a),a}function Dv(e,t,n,r,i){let{movingIds:a,originalById:o}=Ev(e,i),{position:s,dependents:c}=Rn(t),l=[],u=new Set,d=new Map,f=e=>{let n=s.get(e),r=n===void 0?void 0:t[n],i=o.get(e)??r;i&&d.set(e,i)};for(let e of a)for(let n of c.get(e)??[]){if(u.has(n))continue;u.add(n);let e=s.get(n),r=e===void 0?void 0:t[e],i=o.get(n)??r;if(i?.type!==`arrow`||!i.startBinding||!i.endBinding)continue;let c=a.has(i.startBinding.shapeId);c!==a.has(i.endBinding.shapeId)&&(l.push({arrow:i,startMoving:c,at:e??-1}),f(i.startBinding.shapeId),f(i.endBinding.shapeId))}l.sort((e,t)=>e.at-t.at);let p=null,m=null;for(let{arrow:e,startMoving:a}of l){let o=Re(e,t,d,i),s=a?o.start:o.end,c=a?o.end:o.start,l={x:s.x+n.x,y:s.y+n.y},u=c.x-l.x,f=c.y-l.y;Math.abs(f)<=Math.abs(u)?Math.abs(f)<=r&&(!m||Math.abs(f)<Math.abs(m.adjust))&&(m={adjust:f,fixed:c,moving:l}):Math.abs(u)<=r&&(!p||Math.abs(u)<Math.abs(p.adjust))&&(p={adjust:u,fixed:c,moving:l})}let h=[],g=p?p.adjust:0,_=m?m.adjust:0;if(m){let e=m.moving.x+g;h.push({axis:`y`,pos:m.fixed.y,start:Math.min(m.fixed.x,e),end:Math.max(m.fixed.x,e)})}if(p){let e=p.moving.y+_;h.push({axis:`x`,pos:p.fixed.x,start:Math.min(p.fixed.y,e),end:Math.max(p.fixed.y,e)})}return{dx:g,dy:_,snappedX:p!==null,snappedY:m!==null,guides:h}}function Ov(e,t,n,r,i){let a=Math.abs(e.y2-e.y)<=Math.abs(e.x2-e.x),o=e=>a?(e.y+e.y2)/2:(e.x+e.x2)/2,s=o(e)+(a?t.y:t.x),c=n.filter(t=>t.id!==e.id&&t.type===`arrow`&&Ne(t,r)&&Math.abs(t.y2-t.y)<=Math.abs(t.x2-t.x)===a).map(o).sort((e,t)=>e-t);if(c.length===0)return{delta:t,guide:null};let l=[...c];for(let e=0;e<c.length-1;e+=1)l.push((c[e]+c[e+1])/2);let u=null,d=i;for(let e of l){let t=Math.abs(s-e);t<=d&&(u=e,d=t)}if(u===null)return{delta:t,guide:null};let f=u-s;return{delta:a?{x:t.x,y:t.y+f}:{x:t.x+f,y:t.y},guide:a?{axis:`y`,pos:u,start:Math.min(e.x,e.x2),end:Math.max(e.x,e.x2)}:{axis:`x`,pos:u,start:Math.min(e.y,e.y2),end:Math.max(e.y,e.y2)}}}function kv(e,t,n,r,i,a=[],o){let s={x:t.x-e.startWorld.x,y:t.y-e.startWorld.y},c=Math.abs(s.x)>.01||Math.abs(s.y)>.01,{movingIds:l,sliderIds:u,rigidIds:d,base:f}=Ev(e.originals,o),p=u.size>0&&u.size===e.originals.length,m;if(n.shift)Math.abs(s.x)>Math.abs(s.y)?s.y=0:s.x=0;else if(!n.noSnap&&!p){let t=[],n=Dv(e.originals,a,s,i,o);s.x+=n.dx,s.y+=n.dy,t.push(...n.guides);let c=n.snappedX,u=n.snappedY,d=r(l);if(f&&d.length>0){let e=()=>({x:f.x+s.x,y:f.y+s.y,width:f.width,height:f.height}),n=Vg(e(),d,i),r=!c&&n.snappedX,a=!u&&n.snappedY;r&&(s.x+=n.dx,c=!0),a&&(s.y+=n.dy,u=!0);for(let e of n.guides)e.axis===`x`&&r&&t.push(e),e.axis===`y`&&a&&t.push(e);let o=Lg(e(),d,i);c||(s.x+=o.dx),u||(s.y+=o.dy);for(let e of o.guides)e.axis===`x`&&!c&&t.push(e),e.axis===`y`&&!u&&t.push(e)}m=t.length>0?t:void 0}else if(!n.shift&&!n.noSnap&&p&&e.originals.length===1){let t=Ov(e.originals[0],s,a,l,i);s.x=t.delta.x,s.y=t.delta.y,m=t.guide?[t.guide]:void 0}return{shapes:e.originals.map(e=>Pe(e,s,a,l,o)),guides:m,moved:c,rigidIds:d}}var Av={pan:Og,erase:n_,draw:D_,rotate:av,crop:ov,resize:sv,"group-resize":cv,marquee:Cv,lasso:wv,move:{move(e,t,n){let r=t.getState(),{world:i,mods:a,snapDist:o}=x_(e,r,n);if(!e.armed){let t=r.viewport.zoom,n=(i.x-e.startWorld.x)*t,a=(i.y-e.startWorld.y)*t;if(Math.hypot(n,a)<=3)return;if(e.armed=!0,e.duplicated){let t=Vn(e.originals,{x:0,y:0});r.addMany(t),r.setSelectedIds(new Set(t.map(e=>e.id))),e.originals=t}}r.setDragging(!0),r.setTransforming(!0);let s=kv(e,i,a,t.snapTargets,o,t.getState().shapes,t.measurement);s.moved&&(t.moved.current=!0),s.guides&&r.setSnapGuides(s.guides),C_(t,s.shapes,s.rigidIds)},end(e,t){if(!t.moved.current)return;let n=new Set(e.originals.map(e=>e.id)),r=pn(e.originals,t.measurement),i=pn(t.getState().shapes.filter(e=>n.has(e.id)),t.measurement);if(!r||!i)return;let a={x:i.x-r.x,y:i.y-r.y};if(e.duplicated){Ch([...n],a);return}wh(n,a)}}};function jv(e){return Av[e.kind]}function Mv(e,t,n){let r=new Set(e);for(let e of t)n?r.delete(e):r.add(e);return r}function Nv(e,t){let n=(0,J.useRef)(e);return n.current!==e&&!t(n.current,e)&&(n.current=e),n.current}function Pv(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function Fv(e,t){let n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(n=>Object.is(e[n],t[n]))}function Iv(e,t){let n=nt({x:0,y:0},t);return{x:n.x,y:n.y,width:e.width/t.zoom,height:e.height/t.zoom}}function Lv(e){let{writeDraft:t,cancelGesture:n,eraserTrailRef:r}=e,{gestureRef:i,draftRef:a,movedRef:o,pendingToggleRef:s,pendingDrillRef:c,recentDrillRef:l,suppressNextMenuRef:u}=e.refs,d=H(),f=d.store,{endTransaction:p,remoteEditsDuringGesture:m}=d.history,h=d.popupGuard;(0,J.useEffect)(()=>{let e=null,g=t=>{let n=i.current,{shapes:r,viewport:a}=f.getState();if(n&&e?.gesture===n&&e.viewport===a&&Pv(e.excludeIds,t))return e.bounds;let o=n&&`rect`in n?Iv(n.rect,a):null,s=o&&Ur(o,Math.max(o.width,o.height)/2),c=[];for(let e of r){if(t.has(e.id)||e.type===`arrow`||s&&!Ar(Bt(e),s))continue;let n=Cn(e,d.measurement);(!o||Ar(n,o))&&c.push(n)}return n&&(e={gesture:n,excludeIds:t,viewport:a,bounds:c}),c};function _(e){if(i.current){if(e.pointerType!==`touch`&&e.buttons===0){x(e);return}y(e)}}let v={getState:f.getState,measurement:d.measurement,snapTargets:g,draft:a,writeDraft:t,moved:o,eraserTrail:{move:e=>r.current.move(e),end:()=>r.current.end()},remoteEdits:m,suppressNextMenu:u};function y(e){let t=i.current;t&&(t.kind!==`pan`&&t.kind!==`erase`&&f.getState().clearSnapGuides(),jv(t).move(t,v,e))}function b(e){let t=s.current;s.current=null,t&&!o.current&&t.wasSelected&&e.setSelectedIds(Mv(e.selectedIds,t.ids,!0));let n=c.current;c.current=null,n&&!o.current&&(e.setSelectedIds(new Set([n.id])),e.setActiveGroupId(n.groupId),l.current=n.id)}function x(e){let t=i.current;i.current=null;let n=f.getState();if(!t){b(n),p();return}E_(n,t),n.resetGestureVisuals(),b(n),jv(t).end?.(t,v,e),p()}function S(e){if(i.current){if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),n();return}(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`z`&&n()}}function C(){if(!i.current){p();return}n()}function w(){i.current&&n()}window.addEventListener(`pointermove`,_),window.addEventListener(`pointerup`,x),window.addEventListener(`pointercancel`,C),window.addEventListener(`keydown`,S,!0);let T=Yi(w),E=h.install();return()=>{window.removeEventListener(`pointermove`,_),window.removeEventListener(`pointerup`,x),window.removeEventListener(`pointercancel`,C),window.removeEventListener(`keydown`,S,!0),T(),E()}},[t,n,f,p,m,h,d.measurement,r,i,a,o,s,c,l,u])}function Rv(e){return e.metaKey||e.ctrlKey}function zv(e,t){for(let n=e.length-1;n>=0;n--){let r=e[n];if(!(!Nn(r)||r.locked)&&fa(r,t))return r}return null}function Bv(e,t){let n=pa(t);return e.some(e=>e.id===t.id||e.locked||Vv(e,t)?!1:Wr(n.toLocal(Zn(e)),n.body))}function Vv(e,t){let n=G(e),r=G(t);return n.x<=r.x&&n.y<=r.y&&n.x+n.width>=r.x+r.width&&n.y+n.height>=r.y+r.height}function Hv(e){let t=document.querySelector(qi(e));return t instanceof HTMLElement?{width:t.offsetWidth,height:t.offsetHeight}:null}function Uv(e){return e.target instanceof Element&&!!e.target.closest(`[data-overlay]`)}function Wv(e,t){let n=e.button===0?1:e.button===1?4:2;return t&&(e.buttons&~n)!==0?!1:e.button===0||e.button===1||e.button===2}var Gv=(e,t)=>{let{event:n,state:r}=e;return!e.panMode&&n.button!==1&&n.button!==2?!1:(n.button!==2&&t.setIsPanning(!0),t.gestureRef.current={kind:`pan`,startX:n.clientX,startY:n.clientY,viewportX:r.viewport.x,viewportY:r.viewport.y,button:n.button,moved:!1,menuSwallowed:!1},!0)},Kv=(e,t)=>e.state.tool===`comment`?(e.event.preventDefault(),t.gestureRef.current=null,!0):!1,qv=(e,t)=>{let{event:n,state:r,world:i,rect:a}=e;if(!r.viewMode)return!1;let{shapes:o,selectedIds:s}=r;r.setLockRevealId(null);let c=n.shiftKey,l=Rv(n)?null:zv(o,i);if(l&&!Bv(o,l)){let e=$p(o,[l.id],r.activeGroupId);if(c){let t=s.has(l.id);return r.setSelectedIds(Mv(s,e,t)),!0}return r.setSelectedIds(e),!0}let u=c?s:new Set;return c||(r.setSelectedIds(new Set),r.setActiveGroupId(null)),t.gestureRef.current={kind:`marquee`,startWorld:i,rect:a,base:u},t.setMarquee({start:i,end:i}),!0},Jv=(e,t)=>{let{event:n,state:r,world:i,rect:a}=e;if(r.tool!==`eraser`)return!1;let o=new Set,s=5/r.viewport.zoom;for(let e of r.shapes)!e.locked&&jg(e,i,i,s,t.measurement)&&o.add(e.id);return t.gestureRef.current={kind:`erase`,rect:a,last:i,ids:o},r.setErasingIds(new Set(o)),t.eraserTrailRef.current.start({x:n.clientX,y:n.clientY}),!0},Yv=(e,t)=>{let{event:n,state:r,world:i,rect:a}=e;if(r.tool!==`lasso`)return!1;let o=n.shiftKey?new Set(r.selectedIds):new Set;return t.gestureRef.current={kind:`lasso`,points:[i],rect:a,base:o},t.setLasso([i]),t.movedRef.current=!0,!0};function Xv(e,t,n){t.writeDraft(n),t.gestureRef.current={kind:`draw`,startWorld:e.world,rect:e.rect}}var Zv=[Gv,Kv,qv,Jv,Yv,(e,t)=>{let{state:n,world:r}=e,{pendingControl:i,pendingIcon:a,style:o}=n;return i?i===`heading`?(n.setPendingControl(null),n.placeShape(Su(r,o,{text:`Heading`,fontSize:26,width:240}),{edit:!0}),!0):(Xv(e,t,uf(r,o,i)),!0):a?(Xv(e,t,df(r,o,a)),!0):!1},(e,t)=>{let{event:n,state:r,world:i}=e,a=yf[r.tool];return a?(Xv(e,t,a({world:i,style:r.style,shapeKind:r.shapeKind,frameKind:r.frameKind,chartKind:r.chartKind,shapes:r.shapes,zoom:r.viewport.zoom,alt:n.altKey,measurement:t.measurement})),!0):!1},(e,t)=>{let{event:n,state:r,world:i}=e,a=bf[r.tool];if(!a)return!1;a.edit&&n.preventDefault(),t.gestureRef.current=null;let o=a.build(i,r.style),s=()=>r.placeShape(o,{edit:a.edit});return a.untracked?t.runWithoutHistory(s):s(),!0},(e,t)=>{let{event:n,state:r,world:i}=e;return r.tool!==`polyline`&&r.tool!==`polygon`?!1:(t.handlePolylinePress(i,n,r.shapes,r.viewport.zoom),!0)},(e,t)=>{let{event:n,state:r,world:i,rect:a}=e,{selectedIds:o,shapes:s}=r;if(n.shiftKey||Rv(n)||o.size===0)return!1;let c=s.filter(e=>o.has(e.id)),l=Mu(c)?null:pn(c,t.measurement);return!l||!Wr(i,l)?!1:(t.startMove(c,i,a,n.altKey),!0)},(e,t)=>{let{event:n,state:r,world:i,rect:a}=e,{selectedIds:o,shapes:s}=r;r.setLockRevealId(null);let c=n.shiftKey,l=c?o:new Set,u=Rv(n)?null:zv(s,i);if(u&&!Bv(s,u)){let e=$p(s,[u.id],r.activeGroupId);if(c){let c=o.has(u.id),l=Mv(o,e,!1);return r.setSelectedIds(l),t.pendingToggleRef.current={ids:e,wasSelected:c},t.startMove(s.filter(e=>l.has(e.id)),i,a,n.altKey),!0}return r.activeGroupId&&u.groupId!==r.activeGroupId&&r.setActiveGroupId(null),r.setSelectedIds(e),t.startMove(s.filter(t=>e.has(t.id)),i,a,n.altKey),!0}return c||(r.setSelectedIds(new Set),r.setActiveGroupId(null)),t.gestureRef.current={kind:`marquee`,startWorld:i,rect:a,base:l},t.setMarquee({start:i,end:i}),!0}];function Qv(e,t){for(let n of Zv)if(n(e,t))return}function $v(e){let{setSnapDot:t}=e,n=W(),r=(0,J.useRef)(null),i=(0,J.useCallback)(e=>{r.current=e,n.getState().setPolyDraft(e)},[n]);return{commitPolyline:(0,J.useCallback)((e=!0)=>{let t=r.current;if(!t)return;i(null);let a=et(t.points),o=n.getState(),s=o.style,c=t.closed;if(a.length<(c?3:2))return;let l=c?{id:$e(),type:`polygon`,points:a,fill:s.fill,color:s.color,strokeWidth:s.strokeWidth,opacity:s.opacity}:{id:$e(),type:`line`,points:a,...gf(s)};o.addShape(l),e&&(o.setSelectedIds(new Set([l.id])),o.releaseTool())},[i,n]),removeLastPolylinePoint:(0,J.useCallback)(()=>{let e=r.current;if(!e)return;let t=e.points.slice(0,-1);i(t.length>0?{...e,points:t}:null)},[i]),cancelPolyline:(0,J.useCallback)(()=>{i(null)},[i]),handlePolylinePress:(0,J.useCallback)((e,t,a,o)=>{let s=r.current,c=s?.closed??n.getState().tool===`polygon`,l=e;t.altKey||(l=lf(e,a,10/o,void 0,s?.points.slice(0,-1))?.point??e),i({points:s?[...s.points,l]:[l],cursor:l,closed:c})},[i,n]),handlePolylineHover:(0,J.useCallback)((e,n,a,o)=>{let s=r.current,c=e,l=null;if(!n.altKey){let t=lf(e,a,10/o,void 0,s?.points.slice(0,-1));t&&(c=t.point,l=t.point)}t(l),s&&i({...s,cursor:c})},[t,i])}}function ey(e){let{containerRef:t,panMode:n,pinchingRef:r}=e,i=U(e=>e.tool),a=H(),o=a.store,{beginTransaction:s,endTransaction:c,runWithoutHistory:l}=a.history,u=a.popupGuard,d=lg(),f=Dg(),p=(0,J.useRef)(f);p.current=f;let{setDraft:m,setIsPanning:h,setMarquee:g,setLasso:_,setBindTarget:v,setSnapDot:y,setHoverWorld:b}=o.getState(),x=(0,J.useRef)(null),S=(0,J.useRef)(null),C=(0,J.useRef)(!1),w=(0,J.useRef)(null),T=(0,J.useRef)(null),E=(0,J.useRef)(null),D=(0,J.useRef)(!1),O=(0,J.useCallback)(e=>{S.current=e,m(e)},[m]),{commitPolyline:k,removeLastPolylinePoint:A,cancelPolyline:j,handlePolylinePress:M,handlePolylineHover:N}=$v({setSnapDot:y}),P=(0,J.useCallback)(()=>{let e=x.current;x.current=null,e?.kind===`erase`&&(o.getState().setErasingIds(new Set),p.current.end()),e&&E_(o.getState(),e),O(null),C.current=!1,w.current=null,T.current=null,o.getState().resetGestureVisuals(),c()},[O,o,c]);(0,J.useEffect)(()=>{b(null),v(null),y(null),i!==`polyline`&&i!==`polygon`&&k(!1)},[i,k,b,v,y]);let F=(0,J.useCallback)((e,t,n,r)=>{C.current=!1;let i=o.getState(),s=zm(i.shapes,e,{activeGroupId:i.activeGroupId,measurement:a.measurement});s.length!==0&&(T_(i),x.current={kind:`move`,startWorld:t,originals:s,rect:n,duplicated:r})},[o,a.measurement]);Lv({writeDraft:O,cancelGesture:P,eraserTrailRef:p,refs:{gestureRef:x,draftRef:S,movedRef:C,pendingToggleRef:w,pendingDrillRef:T,recentDrillRef:E,suppressNextMenuRef:D}});let I=(0,J.useCallback)(e=>{let t=x.current;return t?.kind===`pan`&&t.button===2?(t.menuSwallowed=!0,e.preventDefault(),e.stopPropagation(),!0):D.current?(D.current=!1,e.preventDefault(),e.stopPropagation(),!0):!1},[]),L=(0,J.useCallback)(e=>{if(Uv(e))return;D.current=!1;let i=t.current;if(!i||r.current||!Wv(e,x.current)||u.openAtEvent())return;let c=o.getState(),d=i.getBoundingClientRect();b(null),Ee(c.editSession)&&c.endEdit(),s(),Qv({event:e,state:c,world:nt({x:e.clientX-d.left,y:e.clientY-d.top},c.viewport),rect:d,panMode:n},{gestureRef:x,movedRef:C,pendingToggleRef:w,eraserTrailRef:p,writeDraft:O,startMove:F,handlePolylinePress:M,runWithoutHistory:l,setIsPanning:h,setMarquee:g,setLasso:_,measurement:a.measurement})},[t,n,r,F,O,M,o,s,l,u,a.measurement,b,h,g,_]),ee=(0,J.useCallback)(e=>{if(x.current)return;let n=t.current;if(!n)return;let r=o.getState(),i=n.getBoundingClientRect(),s=nt({x:e.clientX-i.left,y:e.clientY-i.top},r.viewport),{tool:c,pendingIcon:l,pendingControl:u,shapes:d}=r;if(c===`polyline`||c===`polygon`){N(s,e,d,r.viewport.zoom);return}if(c===`rectangle`||c===`chart`||c===`table`||c===`sticky`||c===`figure`||c===`comment`||l||u){b(s);return}if(c===`arrow`||c===`line`){let t=e.altKey?null:Fe(d,s,void 0,a.measurement);v(t?{id:t.id,point:We(t,s,a.measurement)}:null),y(t||e.altKey?null:lf(s,d,10/r.viewport.zoom)?.point??null)}},[t,N,o,b,v,y,a.measurement]),R=(0,J.useCallback)(()=>{b(null),v(null),y(null)},[b,v,y]),z=(0,J.useCallback)(e=>{let n=o.getState();if(n.tool!==`comment`||e.target instanceof Element&&e.target.closest(`[data-overlay]`))return;let r=t.current;if(!r)return;let i=r.getBoundingClientRect(),s=nt({x:e.clientX-i.left,y:e.clientY-i.top},n.viewport);n.setCommentDraft(Jm(n.shapes,s,a.measurement)),n.releaseTool(),b(null)},[t,o,a.measurement,b]),B=(0,J.useCallback)(e=>{let n=t.current;if(!n||r.current||e.button!==0)return null;e.stopPropagation();let i=o.getState(),a=n.getBoundingClientRect();return{store:i,rect:a,world:nt({x:e.clientX-a.left,y:e.clientY-a.top},i.viewport)}},[t,r,o]),V=(0,J.useCallback)((e,t,n)=>{let r=B(e);if(!r)return;let i=t(r);i&&(s(),x.current=n(i,r))},[B,s]),te=(0,J.useCallback)((e,t)=>{if(Rv(t)||o.getState().tool===`comment`)return;let n=B(t);if(!n)return;let{store:r,rect:i,world:a}=n,{shapes:c,selectedIds:l,activeGroupId:u}=r;E.current=null;let f=c.find(t=>t.id===e);if(f?.locked){r.setLockRevealId(f.id),r.setSelectedIds(new Set),r.setActiveGroupId(null),r.endEdit();return}if(r.setLockRevealId(null),r.editSession.kind===`interact`&&r.editSession.shapeId===e)return;if(r.viewMode){let n=f?.type===`web`&&!f.groupId&&!t.shiftKey?gg(f,d):null;if(n){r.setSelectedIds(new Set([e])),n.kind===`embed`&&n.embed.video&&r.startWeb(e),r.beginInteract(e);return}let i=$p(c,[e],u);if(t.shiftKey){let t=l.has(e);r.setSelectedIds(Mv(l,i,t));return}r.setSelectedIds(i);return}Ee(r.editSession)&&r.endEdit(),s();let p=$p(c,[e],u);if(t.shiftKey){let n=l.has(e),o=Mv(l,p,!1);r.setSelectedIds(o);let s=c.filter(e=>o.has(e.id));w.current={ids:p,wasSelected:n},F(s,a,i,t.altKey);return}let m=c.find(t=>t.id===e);u&&m?.groupId!==u&&r.setActiveGroupId(null);let h=[...p].every(e=>l.has(e));h&&!t.altKey&&m?.groupId&&m.groupId!==u&&(T.current={id:e,groupId:m.groupId});let g=h?l:p;h||r.setSelectedIds(g);let _=c.filter(e=>g.has(e.id));F(_,a,i,t.altKey)},[o,B,F,s,d]),ne=(0,J.useCallback)((e,t,n)=>{V(n,({store:t})=>{let n=t.shapes.find(t=>t.id===e);return n&&!n.locked?n:null},(n,{rect:r,world:i})=>{let o=null;if(n.type===`text`){let t=Hv(e);t&&(o={box:{x:n.x,y:n.y,width:t.width,height:t.height},fontSize:n.fontSize,width:n.width,height:n.height})}return Q_(n,t,i,r,o,a.measurement)})},[V,a.measurement]),re=(0,J.useCallback)((e,t)=>{let n=o.getState(),r=n.shapes.find(t=>t.id===e);if(!r||r.type!==`arrow`&&r.type!==`line`||r.locked||n.viewMode||n.tool===`comment`||Rv(t)||t.shiftKey||t.altKey||r.groupId!=null&&r.groupId!==n.activeGroupId){te(e,t);return}let i=B(t);if(!i)return;let{rect:a,world:c}=i;E.current=null,n.setLockRevealId(null),Ee(n.editSession)&&n.endEdit(),n.selectedIds.has(e)||n.setSelectedIds(new Set([e])),s(),x.current=$_(r,c,a)},[o,B,te,s]),ie=(0,J.useCallback)((e,t,n)=>{V(n,({store:t})=>{let n=t.shapes.find(t=>t.id===e);return n?.type===`line`||n?.type===`polygon`?n:null},(e,{rect:n})=>ev(e,t,n))},[V]),ae=(0,J.useCallback)((e,t,n)=>{V(n,({store:t})=>{let n=t.shapes.find(t=>t.id===e);return n?.type===`arrow`&&!n.locked?n:null},(e,{rect:n})=>tv(e,t,n))},[V]),oe=(0,J.useCallback)((e,t,n)=>{V(n,({store:t})=>{let n=t.shapes.find(t=>t.id===e);return n?.type===`image`?n:null},(e,{rect:n})=>nv(e,t,n,a.measurement))},[V,a.measurement]),se=(0,J.useCallback)((e,t)=>{V(t,({store:t,rect:n,world:r})=>rv(t,e,r,n,a.measurement),e=>e)},[V,a.measurement]),ce=(0,J.useCallback)(e=>{V(e,({store:e,rect:t,world:n})=>iv(e,n,t,a.measurement),e=>e)},[V,a.measurement]),le=(0,J.useCallback)((e,t)=>{let n=B(t);if(!n)return;let{store:r,rect:i,world:a}=n,o=r.shapes.find(t=>t.id===e);if(!o||o.locked)return;let[c]=Vn([o],{x:0,y:0});if(c.type!==`sticky`)return;let l={...c,text:``,height:180};s(),r.addShape(l),r.setSelectedIds(new Set([l.id])),F([l],a,i,!1)},[B,F,s]),ue=(0,J.useCallback)(e=>{if(r.current||o.getState().tool===`comment`)return;E.current=null;let t=Gu(o.getState().shapes,e.clientX,e.clientY);if(t&&!t.locked){te(t.id,e);return}if(e.shiftKey||Rv(e))return;let n=B(e);if(!n)return;let{store:i,rect:a,world:c}=n,l=i.shapes.filter(e=>i.selectedIds.has(e.id));l.length!==0&&(s(),F(l,c,a,e.altKey))},[r,B,te,F,o,s]),de=(0,J.useCallback)(e=>{if(x.current)return;let t=o.getState(),n=Gu(t.shapes,e.clientX,e.clientY);t.setHoveredId(n&&!n.locked?n.id:null)},[o]),fe=(0,J.useCallback)(()=>{o.getState().setHoveredId(null)},[o]);return{commitPolyline:k,removeLastPolylinePoint:A,cancelPolyline:j,cancelGesture:P,onContainerPointerDown:L,onContainerPointerMove:ee,onContainerPointerLeave:R,onContainerClick:z,interceptContextMenu:I,onShapePointerDown:te,onLabelPointerDown:re,selectionGestures:(0,J.useMemo)(()=>({onHandlePointerDown:ne,onLineVertexPointerDown:ie,onElbowSegmentPointerDown:ae,onGroupHandlePointerDown:se,onSelectionPointerDown:ue,onSelectionPointerMove:de,onSelectionPointerLeave:fe,onRotateHandlePointerDown:ce,onCropHandlePointerDown:oe,onStickyDuplicatePointerDown:le}),[ne,ie,ae,se,ue,de,fe,ce,oe,le]),recentDrillRef:E}}function ty(){let e=!1;function t(t){!e||!t.isTrusted||(t.preventDefault(),t.stopImmediatePropagation(),t.type===`click`&&(e=!1))}return window.addEventListener(`mousedown`,t,{capture:!0}),window.addEventListener(`mouseup`,t,{capture:!0}),window.addEventListener(`click`,t,{capture:!0}),{arm:()=>{e=!0},release:()=>{e=!1},dispose:()=>{window.removeEventListener(`mousedown`,t,{capture:!0}),window.removeEventListener(`mouseup`,t,{capture:!0}),window.removeEventListener(`click`,t,{capture:!0})}}}var ny=300,ry=35;function iy(e){(0,J.useEffect)(()=>{let t=null,n=0,r=ty();function i(i){if(r.release(),i.pointerType!==`touch`||!i.isPrimary){t=null;return}let a=i.target instanceof Element?i.target:null;if(!a||!e.current?.contains(a)||a.closest(`[data-overlay]`)||us(a)){t=null;return}let o=performance.now();if(!(t&&o-t.time<=ny&&Math.hypot(i.clientX-t.x,i.clientY-t.y)<=ry)){t={time:o,x:i.clientX,y:i.clientY};return}t=null,i.preventDefault(),i.stopPropagation(),n=o+500,r.arm(),document.elementFromPoint(i.clientX,i.clientY)?.dispatchEvent(new MouseEvent(`dblclick`,{bubbles:!0,cancelable:!0,view:window,detail:2,clientX:i.clientX,clientY:i.clientY}))}function a(e){e.isTrusted&&performance.now()<n&&(e.preventDefault(),e.stopImmediatePropagation())}return window.addEventListener(`pointerdown`,i,{capture:!0}),window.addEventListener(`dblclick`,a,{capture:!0}),()=>{window.removeEventListener(`pointerdown`,i,{capture:!0}),window.removeEventListener(`dblclick`,a,{capture:!0}),r.dispose()}},[e])}var ay=500,oy=10;function sy(e){return(e.tool===`select`||e.tool===`hand`)&&!e.pendingIcon&&!e.pendingControl&&!e.polyDraft&&!e.draft}function cy(e){let t=W();(0,J.useEffect)(()=>{let n=0,r=null,i=ty(),a=()=>{window.clearTimeout(n),r=null};function o(){if(!r)return;let{x:e,y:t,pointerId:n}=r;r=null,i.arm(),window.dispatchEvent(new PointerEvent(`pointercancel`,{pointerId:n,pointerType:`touch`,isPrimary:!0,bubbles:!0,cancelable:!0,clientX:e,clientY:t})),document.elementFromPoint(e,t)?.dispatchEvent(new MouseEvent(`contextmenu`,{bubbles:!0,cancelable:!0,view:window,clientX:e,clientY:t}))}function s(s){if(i.release(),s.pointerType!==`touch`)return;if(!s.isPrimary){a();return}let c=s.target instanceof Element?s.target:null;if(!c||!e.current?.contains(c)||c.closest(`[data-overlay]`)||us(c)||t.getState().presentingIndex!==null||!sy(t.getState())){a();return}window.clearTimeout(n),r={x:s.clientX,y:s.clientY,pointerId:s.pointerId},n=window.setTimeout(o,ay)}function c(e){!r||e.pointerId!==r.pointerId||Math.hypot(e.clientX-r.x,e.clientY-r.y)>oy&&a()}function l(e){r&&e.pointerId===r.pointerId&&a()}function u(t){let n=t.target instanceof Element?t.target:null;n&&e.current?.contains(n)&&t.stopPropagation()}return window.addEventListener(`pointerdown`,s,{capture:!0}),window.addEventListener(`pointermove`,c,{capture:!0}),window.addEventListener(`pointerup`,l,{capture:!0}),window.addEventListener(`pointercancel`,l,{capture:!0}),window.addEventListener(`touchstart`,u,{capture:!0}),()=>{a(),window.removeEventListener(`pointerdown`,s,{capture:!0}),window.removeEventListener(`pointermove`,c,{capture:!0}),window.removeEventListener(`pointerup`,l,{capture:!0}),window.removeEventListener(`pointercancel`,l,{capture:!0}),window.removeEventListener(`touchstart`,u,{capture:!0}),i.dispose()}},[e,t])}function ly(e,t){return{x:(e.x+t.x)/2,y:(e.y+t.y)/2}}function uy(e,t,n){let r=Mr(e.a,e.b),i=Mr(t,n),a=r===0?1:i/r,o=yn(e.viewport.zoom*a),s=nt(ly(e.a,e.b),e.viewport),c=ly(t,n);return{zoom:o,x:c.x-s.x*o,y:c.y-s.y*o}}function dy(e){let{containerRef:t,pinchingRef:n,onPinchStart:r}=e,i=W();(0,J.useEffect)(()=>{let e=t.current;if(!e)return;let a=new Map,o=null;function s(t){let n=e.getBoundingClientRect();return{x:t.clientX-n.left,y:t.clientY-n.top}}function c(){if(a.size<2)return null;let e=a.values();return[e.next().value,e.next().value]}function l(t){if(t.pointerType!==`touch`||i.getState().presentingIndex!==null)return;let l=t.target;if(!(!(l instanceof Node)||!e.contains(l))&&!(l instanceof Element&&l.closest(`[data-overlay]`))&&(a.set(t.pointerId,s(t)),a.size===2&&!n.current)){let e=c();e&&(n.current=!0,r(),o={a:e[0],b:e[1],viewport:i.getState().viewport})}}function u(e){if(e.pointerType!==`touch`||!a.has(e.pointerId)||(a.set(e.pointerId,s(e)),!o))return;let t=c();if(t){let e=i.getState(),n=uy(o,t[0],t[1]),r=n.zoom!==e.viewport.zoom;e.setViewport(n),r&&e.pulseZoomGesture()}}function d(e){e.pointerType===`touch`&&(a.delete(e.pointerId),a.size<2&&(o=null,n.current=!1))}function f(){a.clear(),o=null,n.current=!1}window.addEventListener(`pointerdown`,l,{capture:!0}),window.addEventListener(`pointermove`,u,{capture:!0}),window.addEventListener(`pointerup`,d,{capture:!0}),window.addEventListener(`pointercancel`,d,{capture:!0});let p=Yi(f);return()=>{window.removeEventListener(`pointerdown`,l,{capture:!0}),window.removeEventListener(`pointermove`,u,{capture:!0}),window.removeEventListener(`pointerup`,d,{capture:!0}),window.removeEventListener(`pointercancel`,d,{capture:!0}),p(),f()}},[t,n,r,i])}function fy(e,t,n){return Math.max(0,e+n-t)}function py(e,t,n,r){return e-fy(t,n,r)}var my=24;function hy(){let e=W();(0,J.useEffect)(()=>{let t=window.visualViewport;if(!t)return;let n=null;function r(){let r=t,i=e.getState(),a=i.editSession.kind!==`none`,o=document.querySelector(`[contenteditable="true"]`),s=r.offsetTop+r.height;if(!a||!(o instanceof HTMLElement)){if(n!==null){let e=n;n=null,i.setViewport(t=>({...t,y:e}))}return}let c=o.getBoundingClientRect();fy(c.bottom,s,my)<=0||(n===null&&(n=i.viewport.y),i.setViewport(e=>({...e,y:py(e.y,c.bottom,s,my)})))}return t.addEventListener(`resize`,r),t.addEventListener(`scroll`,r),()=>{t.removeEventListener(`resize`,r),t.removeEventListener(`scroll`,r)}},[e])}function gy(e,t,n){return`${e}:${t}:${n}`}function _y(){let{store:e,history:t}=H(),{runWithoutHistory:n}=t,{updateShape:r}=e.getState(),i=(0,J.useRef)(new Map),a=(0,J.useCallback)((t,i)=>{let a=Qe(e.getState().shapes,t);if(a?.type===`sticky`){let e=Math.max(180,i);Math.abs(e-a.height)>.5&&n(()=>r(t,{height:e}));return}if(!a||a.type!==`rectangle`)return;let o={};Math.abs((a.minHeight??0)-i)>.5&&(o.minHeight=i);let s=a.autoHeightFrom,c=s!==void 0&&Math.abs(a.height-Math.max(s,a.minHeight??0))<=.5;if(s!==void 0&&!c&&(o.autoHeightFrom=void 0),i>a.height+.5)o.height=i,c||(o.autoHeightFrom=a.height);else if(c&&s!==void 0){let e=Math.max(s,i);Math.abs(e-a.height)>.5&&(o.height=e),e<=s+.5&&(o.autoHeightFrom=void 0)}Object.keys(o).length>0&&n(()=>r(t,o))},[e,r,n]),o=(0,J.useCallback)((t,i)=>{let a=Qe(e.getState().shapes,t);if(a?.type!==`control`||a.kind!==`lifeline`)return;let o=Math.max(60,i);if(!(a.widthManual&&a.width>=o-.5)&&Math.abs(o-a.width)>.5){let e=a.x+a.width/2-o/2;n(()=>r(t,{width:o,x:e}))}},[e,r,n]),s=(0,J.useCallback)(t=>{let a=e.getState(),o=Qe(a.shapes,t);if(!o||o.type!==`table`)return;let s=i.current,c=a.editSession,l=c.kind===`table-cell`&&c.shapeId===t?c:null,u=po(o,(e,n)=>{if(!(!(l?.row===e&&l.col===n)&&!o.cells[e]?.[n]))return s.get(gy(t,e,n))});u.some((e,t)=>Math.abs(e-o.rowHeights[t])>.5)&&n(()=>r(t,{rowHeights:u}))},[e,r,n]);return{onMeasureLabel:a,onMeasureLifelineWidth:o,onMeasureCell:(0,J.useCallback)((e,t,n,r)=>{i.current.set(gy(e,t,n),r),s(e)},[s]),refitRows:s,remapCellHeights:(0,J.useCallback)((e,t,n,r)=>{let a=`${e}:`,o=new Map;for(let[s,c]of i.current){if(!s.startsWith(a)){o.set(s,c);continue}let[i,l]=s.slice(a.length).split(`:`).map(Number),u=t===`row`?i:l;if(u<n){o.set(s,c);continue}if(r<0&&u===n)continue;let d=u+r;o.set(t===`row`?gy(e,d,l):gy(e,i,d),c)}i.current=o},[])}}function vy(e){let{replaceShape:t,endEdit:n}=e,{refitRows:r,remapCellHeights:i}=e,{notify:a}=_(),o=W(),s=(0,J.useCallback)((e,i,a,s)=>{let c=Qe(o.getState().shapes,e);if(!c||c.type!==`table`)return;let l=s.trim(),u=o.getState().editSession;if(u.kind===`table-cell`&&u.row===i&&u.col===a&&n(e),(c.cells[i]?.[a]??``)===l)return;let d=c.cells.map((e,t)=>t===i?e.map((e,t)=>t===a?l:e):e);t({...c,cells:d}),r(e)},[o,t,n,r]),c=(0,J.useCallback)((e,n)=>{let r=Qe(o.getState().shapes,e);!r||r.type!==`chart`||t({...r,cells:n})},[o,t]),l=(0,J.useCallback)((e,n)=>{let r=o.getState().shapes.find(t=>t.id===e&&t.type===`table`);r&&t(n(r))},[o,t]),u=(0,J.useCallback)((e,t)=>l(e,n=>(i(e,`col`,t,1),Co(n,t))),[l,i]),d=(0,J.useCallback)((e,t)=>l(e,n=>{let r=yo(n,t);return r!==n&&i(e,`col`,t,-1),r}),[l,i]),f=(0,J.useCallback)((e,t)=>l(e,n=>(i(e,`row`,t,1),Ho(n,t))),[l,i]),p=(0,J.useCallback)((e,t)=>l(e,n=>{let r=No(n,t);return r!==n&&i(e,`row`,t,-1),r}),[l,i]),m=(0,J.useCallback)(e=>{let{shapes:t,selectedIds:n}=o.getState();return t.find(t=>t.type===e&&n.has(t.id))},[o]),h=(0,J.useCallback)(()=>{let e=m(`table`);e&&(navigator.clipboard?.writeText(go(e)),a(`Copied as CSV`))},[m,a]),g=(0,J.useCallback)(()=>{let e=m(`table`);if(!e)return;let n=cs({x:e.x,y:e.y},{fontFamily:e.fontFamily,color:e.color,opacity:e.opacity});t({...n,id:e.id,groupId:e.groupId,locked:e.locked,lockId:e.lockId,x:e.x,y:e.y,cells:e.cells})},[m,t]),v=(0,J.useCallback)(()=>{let e=m(`chart`);if(!e)return;let n=xo(e.cells,{x:e.x,y:e.y},{fontSize:o.getState().style.fontSize,fontFamily:e.fontFamily,color:e.color,opacity:e.opacity});t({...n,id:e.id,groupId:e.groupId,locked:e.locked,lockId:e.lockId})},[o,m,t]);return(0,J.useMemo)(()=>({commitCell:s,setChartCells:c,mutateTable:l,insertColumn:u,deleteColumn:d,insertRow:f,deleteRow:p,copyTableCsv:h,convertTableToChart:g,convertChartToTable:v}),[s,c,l,u,d,f,p,h,g,v])}function yy(e){let{updateShape:t,beginLaneEdit:n,endEdit:r,setSelectedIds:i,setActiveGroupId:a}=e,o=W();return{beginEditLane:(0,J.useCallback)((e,t)=>{let r=o.getState(),s=Qe(r.shapes,e);if(!(!s||s.type!==`figure`||s.locked)){if(s.groupId&&s.groupId!==r.activeGroupId){a(s.groupId),i(new Set);return}i(new Set([e])),n(e,t)}},[o,a,i,n]),commitLane:(0,J.useCallback)((e,n,i)=>{if(i!==null){let r=Qe(o.getState().shapes,e);if(r?.type===`figure`){let a=r.lanes??[],o=i.trim();n<a.length&&o.length>0&&o!==a[n]&&t(e,{lanes:a.map((e,t)=>t===n?o:e)})}}r(e)},[o,t,r]),addLane:(0,J.useCallback)(e=>{let n=Qe(o.getState().shapes,e);if(!n||n.type!==`figure`||!ns(n.kind))return;let r=n.lanes&&n.lanes.length>0?n.lanes:rs,i=[...r,`Lane ${r.length+1}`],a=n.laneSizes,s=a&&a.length===r.length?[...a,a.reduce((e,t)=>e+t,0)/a.length]:void 0,c=s?{laneSizes:s}:{};if(is(n.kind)){t(e,{lanes:i,...c,width:n.width+n.width/r.length});return}t(e,{lanes:i,...c,height:n.height+n.height/r.length})},[o,t]),deleteLane:(0,J.useCallback)((e,n)=>{let r=Qe(o.getState().shapes,e);if(!r||r.type!==`figure`||!ns(r.kind))return;let i=r.lanes&&r.lanes.length>0?r.lanes:rs;if(i.length<=2||n>=i.length)return;let a=i.filter((e,t)=>t!==n),s=$o(i.length,r.laneSizes)[n],c=r.laneSizes,l=c&&c.length===i.length?c.filter((e,t)=>t!==n):void 0,u=l?{laneSizes:l}:{};if(is(r.kind)){t(e,{lanes:a,...u,width:r.width-r.width*s});return}t(e,{lanes:a,...u,height:r.height-r.height*s})},[o,t])}}function by(e){let{replaceMany:t,setStyle:n,setShapeKind:r}=e,i=W(),a=(0,J.useCallback)(e=>{let{shapes:n,selectedIds:r}=i.getState(),a=ha(n,r).map(e);a.length>0&&t(a)},[i,t]),o=(0,J.useCallback)(e=>{let{shapes:r,selectedIds:a,tableSelection:o}=i.getState();if(a.size===0){let t={...e};delete t.bendStyle,Object.keys(t).length>0&&n(e=>({...e,...t}));return}let s=ha(r,a).map(t=>t.type===`table`?_o(t,o&&o.id===t.id?{axis:o.axis,index:o.index}:null,e):sh(t,e));s.length>0&&t(s)},[i,t,n]),s=(0,J.useCallback)(e=>{let{shapes:r,selectedIds:a,tableSelection:o}=i.getState(),s=ha(r,a);if(s.length===0){n(t=>({...t,fill:e}));return}let c=s.map(t=>t.type===`table`?_o(t,o&&o.id===t.id?{axis:o.axis,index:o.index}:null,{background:e}):sh(t,lh(t,e)));t(c)},[i,t,n]),c=(0,J.useCallback)(e=>{a(t=>t.type===`figure`?{...t,...e}:t)},[a]),l=(0,J.useCallback)(e=>{a(t=>t.type===`control`?{...t,...e}:t)},[a]),u=(0,J.useCallback)(e=>{a(t=>t.type===`rectangle`||t.type===`control`?{...t,link:e||void 0}:t)},[a]),d=(0,J.useCallback)(e=>{a(t=>t.type===`chart`?{...t,...e}:t)},[a]),f=(0,J.useCallback)(e=>{a(t=>t.type===`text`?bt(t,e):t)},[a]),p=(0,J.useCallback)(e=>{r(e),a(t=>t.type===`rectangle`?{...t,kind:e}:t)},[r,a]),m=(0,J.useCallback)((e,t)=>{a(n=>n.type===`icon`?{...n,name:e,source:t}:n)},[a]),h=(0,J.useCallback)(e=>{a(t=>t.type===`rectangle`?{...t,titleIcon:e}:t)},[a]);return(0,J.useMemo)(()=>({updateSelected:a,changeStyle:o,applyEyedropper:s,changeFigure:c,changeControl:l,changeLink:u,changeChart:d,changeTextSizing:f,changeShapeKind:p,pickIcon:m,patchBadge:h}),[a,o,s,c,l,u,d,f,p,m,h])}function xy(e){(0,J.useEffect)(()=>{let t=window;t.__koboyoTrace&&(t.__koboyoTrace[e]=(t.__koboyoTrace[e]??0)+1)})}var Sy=J.createContext(void 0);function Cy(){let e=J.useContext(Sy);if(e===void 0)throw Error(f(30));return e}var wy=function(e){return e.checked=`data-checked`,e.unchecked=`data-unchecked`,e.disabled=`data-disabled`,e.highlighted=`data-highlighted`,e}({}),Ty={checked(e){return e?{[wy.checked]:``}:{[wy.unchecked]:``}},...m},Q=y(),Ey=J.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:l=!1,closeOnClick:u=!1,checked:f,defaultChecked:p,onCheckedChange:m,style:h,...g}=e,_=O({label:a}),v=E(!0),y=el(i),{store:b}=B(),x=b.useState(`isActive`,_.index),S=b.useState(`itemProps`),[C,w]=rc({controlled:f,default:p??!1,name:`MenuCheckboxItem`,state:`checked`}),{getItemProps:T,itemRef:D}=V({closeOnClick:u,disabled:l,highlighted:x,id:y,store:b,nativeButton:o,nodeId:v?.context.nodeId,itemMetadata:z}),k=J.useMemo(()=>({disabled:l,highlighted:x,checked:C}),[l,x,C]);function A(e){let t=s(c,e.nativeEvent,void 0,{preventUnmountOnClose(){}});m?.(!C,t),!t.isCanceled&&w(e=>!e)}let j=d(`div`,e,{state:k,stateAttributesMapping:Ty,props:[S,{role:`menuitemcheckbox`,"aria-checked":C,onClick:A},g,T],ref:[D,t,_.ref]});return(0,Q.jsx)(Sy.Provider,{value:k,children:j})}),Dy=J.forwardRef(function(e,t){let{render:n,className:r,style:a,keepMounted:o=!1,...s}=e,c=Cy(),l=J.useRef(null),{transitionStatus:f,setMounted:p}=i(c.checked);return u({open:c.checked,ref:l,onComplete(){c.checked||p(!1)}}),d(`span`,e,{state:{checked:c.checked,disabled:c.disabled,highlighted:c.highlighted,transitionStatus:f},ref:[t,l],stateAttributesMapping:Ty,props:{"aria-hidden":!0,...s},enabled:o||c.checked})});function Oy(){let e=W(),[t,n]=(0,J.useState)(()=>e.getState().coarsePointer);return(0,J.useEffect)(()=>{if(!t)return;let e,r=()=>{e=window.setTimeout(()=>n(!1),150)};window.addEventListener(`pointerup`,r,{once:!0});let i=window.setTimeout(()=>n(!1),800);return()=>{window.removeEventListener(`pointerup`,r),window.clearTimeout(e),window.clearTimeout(i)}},[t]),t?{pointerEvents:`none`}:void 0}var ky=`flex cursor-default select-none items-center justify-between gap-6 rounded-lg px-2 py-1.5 text-[13px] text-[var(--chrome-fg-700)] outline-none data-[highlighted]:bg-[var(--chrome-hover)]`;function $(e){let{testId:t,onClick:n,children:r,hint:i}=e;return(0,Q.jsxs)(A,{className:ky,"data-testid":t,onClick:n,children:[(0,Q.jsx)(`span`,{children:r}),i?(0,Q.jsx)(`span`,{className:`text-[var(--chrome-fg-400)]`,children:zc(i)}):null]})}function Ay(e){return[{when:e.canOpenWebLink,separatorBefore:!0,testId:`ctx-open-link`,label:`Open link`,onClick:e.onOpenWebLink},{when:e.canCopyWebHtml,separatorBefore:!0,testId:`ctx-copy-html`,label:`Copy HTML`,onClick:e.onCopyWebHtml},{when:e.isTable,separatorBefore:!0,testId:`ctx-copy-csv`,label:`Copy as CSV`,onClick:e.onCopyCsv},{when:e.isTable,testId:`ctx-convert-chart`,label:`Convert to chart`,onClick:e.onConvertToChart},{when:e.isChart,separatorBefore:!0,testId:`ctx-convert-table`,label:`Convert to table`,onClick:e.onConvertToTable},{when:e.canEditAsCode,separatorBefore:!0,testId:`ctx-edit-as-code`,label:`Edit as code`,onClick:e.onEditAsCode},{when:e.canResetArrowRoute,separatorBefore:!0,testId:`ctx-reset-route`,label:`Reset connector route`,onClick:e.onResetArrowRoute},{when:e.canTidy,separatorBefore:!0,testId:`ctx-tidy`,label:`Tidy up layout`,hint:Qp(`tidy`),onClick:e.onTidy},{when:e.canCluster,testId:`ctx-cluster`,label:`Cluster sticky notes`,onClick:e.onCluster},{when:e.canToOutline,testId:`ctx-to-outline`,label:`Convert to outline`,onClick:e.onToOutline},{when:e.canToStickies,testId:`ctx-to-stickies`,label:`Convert to sticky notes`,onClick:e.onToStickies},{when:e.canColorLegend,testId:`ctx-color-legend`,label:`Add colour legend`,onClick:e.onColorLegend},{when:e.canAddToSlides,testId:`ctx-add-to-slides`,label:`Add to slides`,onClick:e.onAddToSlides},{when:e.canRemoveFromSlides,testId:`ctx-remove-from-slides`,label:`Remove from slides`,onClick:e.onRemoveFromSlides},{when:e.canAddFlow,testId:`ctx-add-flow`,label:`Add flow`,onClick:e.onAddFlow}]}function jy(e){return(0,Q.jsx)(Q.Fragment,{children:Ay(e.model).filter(e=>e.when).map(e=>(0,Q.jsxs)(J.Fragment,{children:[e.separatorBefore?(0,Q.jsx)(M,{}):null,(0,Q.jsx)($,{testId:e.testId,onClick:e.onClick,hint:e.hint,children:e.label})]},e.testId))})}var My=`min-w-[180px] p-1 outline-none ${q.popup}`;function Ny(e){let{label:t,testId:n,children:r}=e;return(0,Q.jsxs)(vc,{children:[(0,Q.jsxs)(bc,{className:ky,"data-testid":n,children:[(0,Q.jsx)(`span`,{children:t}),(0,Q.jsx)($s,{size:14,stroke:1.75,className:`text-[var(--chrome-fg-400)]`})]}),(0,Q.jsx)(P,{children:(0,Q.jsx)(L,{className:`outline-none`,children:(0,Q.jsx)(j,{className:My,children:r})})})]})}var Py=[{type:`left`,label:`Align left`,hint:Qp(`alignLeft`)},{type:`center-h`,label:`Align centre`,hint:Qp(`alignCenter`)},{type:`right`,label:`Align right`,hint:Qp(`alignRight`)},{type:`top`,label:`Align top`,hint:Qp(`alignTop`)},{type:`middle`,label:`Align middle`,hint:Qp(`alignMiddle`)},{type:`bottom`,label:`Align bottom`,hint:Qp(`alignBottom`)}];function Fy(e){let{model:t}=e;return t.canAlign?(0,Q.jsxs)(Ny,{label:`Align`,testId:`ctx-align`,children:[Py.map(e=>(0,Q.jsx)($,{testId:`ctx-align-${e.type}`,onClick:()=>t.onAlign(e.type),hint:e.hint,children:e.label},e.type)),t.canDistribute?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(M,{}),(0,Q.jsx)($,{testId:`ctx-distribute-horizontal`,onClick:()=>t.onDistribute(`horizontal`),children:`Distribute horizontally`}),(0,Q.jsx)($,{testId:`ctx-distribute-vertical`,onClick:()=>t.onDistribute(`vertical`),children:`Distribute vertically`})]}):null]}):null}function Iy(e){let{model:t}=e;return(0,Q.jsxs)(Ny,{label:`Reorder`,testId:`ctx-reorder`,children:[(0,Q.jsx)($,{testId:`ctx-send-backward`,onClick:t.onSendBackward,hint:Qp(`sendBackward`),children:`Send backward`}),(0,Q.jsx)($,{testId:`ctx-bring-forward`,onClick:t.onBringForward,hint:Qp(`bringForward`),children:`Bring forward`}),(0,Q.jsx)($,{testId:`ctx-send-back`,onClick:t.onSendToBack,hint:Qp(`sendToBack`),children:`Send to back`}),(0,Q.jsx)($,{testId:`ctx-bring-front`,onClick:t.onBringToFront,hint:Qp(`bringToFront`),children:`Bring to front`})]})}function Ly(e){let{model:t}=e;return t.canExport?(0,Q.jsxs)(Ny,{label:`Export`,testId:`ctx-export`,children:[t.openInApp?null:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)($,{testId:`ctx-export-png`,onClick:t.onExportPng,children:`Export as PNG…`}),(0,Q.jsx)($,{testId:`ctx-export-svg`,onClick:t.onExportSvg,children:`Export as SVG…`}),(0,Q.jsx)(M,{})]}),(0,Q.jsx)($,{testId:`ctx-copy-png`,onClick:t.onCopyPng,children:`Copy as PNG`}),(0,Q.jsx)($,{testId:`ctx-copy-svg`,onClick:t.onCopySvg,children:`Copy as SVG`}),t.openInApp?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(M,{}),(0,Q.jsx)($,{testId:`ctx-open-in-app`,onClick:t.openInApp.run,children:t.openInApp.label})]}):null]}):null}function Ry(e){let{model:t}=e;return t.canAskAi?(0,Q.jsxs)(Ny,{label:`Ask AI`,testId:`ctx-ask-ai`,children:[(0,Q.jsx)($,{testId:`ctx-ai-explain`,onClick:t.onAskExplain,children:`Explain this`}),(0,Q.jsx)($,{testId:`ctx-ai-feedback`,onClick:t.onAskFeedback,children:`Give feedback`}),(0,Q.jsx)(M,{}),(0,Q.jsx)($,{testId:`ctx-ai-tidy`,onClick:t.onAskTidy,children:`Tidy it up`}),(0,Q.jsx)($,{testId:`ctx-ai-proofread`,onClick:t.onAskProofread,children:`Fix spelling and grammar`}),(0,Q.jsx)($,{testId:`ctx-ai-icons`,onClick:t.onAskIcons,children:`Add icons`}),(0,Q.jsx)($,{testId:`ctx-ai-restyle`,onClick:t.onAskRestyle,children:`Restyle…`}),(0,Q.jsx)(M,{}),(0,Q.jsx)($,{testId:`ctx-ai-custom`,onClick:t.onAskCustom,children:`Ask about this…`})]}):null}function zy(e){let{model:t,selectAll:n=!0}=e;return(0,Q.jsxs)(Q.Fragment,{children:[n&&t.canSelectAll?(0,Q.jsx)($,{testId:`ctx-select-all`,onClick:t.onSelectAll,hint:Qp(`selectAll`),children:`Select all`}):null,(0,Q.jsx)($,{testId:`ctx-zoom-fit`,onClick:t.onZoomToFit,children:`Zoom to fit`}),(0,Q.jsx)($,{testId:`ctx-reset-zoom`,onClick:t.onResetZoom,children:`Zoom to 100%`}),t.canExport?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(M,{}),(0,Q.jsx)(Ly,{model:t})]}):null]})}function By(e){let t=Oy();return(0,Q.jsx)(j,{"data-overlay":!0,"data-testid":`context-menu`,style:t,className:`min-w-[200px] p-1 outline-none ${q.popup}`,children:e.children})}function Vy(e){U();let t=e.buildModel();return(0,Q.jsx)(L,{className:`outline-none`,children:(0,Q.jsx)(By,{children:t.readOnly?(0,Q.jsxs)(Q.Fragment,{children:[t.canComment?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)($,{testId:`ctx-add-comment`,onClick:t.onAddComment,hint:Ns(`comment`),children:t.hasSelection?`Comment on this`:`Add comment here`}),(0,Q.jsx)(M,{})]}):null,t.hasSelection?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)($,{testId:`ctx-copy`,onClick:t.onCopy,hint:Qp(`copy`),children:`Copy`}),(0,Q.jsx)($,{testId:`ctx-zoom-selection`,onClick:t.onZoomToSelection,children:`Zoom to selection`}),t.canOpenWebLink?(0,Q.jsx)($,{testId:`ctx-open-link`,onClick:t.onOpenWebLink,children:`Open link`}):null,(0,Q.jsx)(M,{})]}):null,(0,Q.jsx)(zy,{model:t})]}):t.isLocked?(0,Q.jsx)($,{testId:`ctx-unlock`,onClick:t.onUnlock,hint:Qp(`lock`),children:`Unlock`}):t.hasSelection?(0,Q.jsxs)(Q.Fragment,{children:[t.canComment?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)($,{testId:`ctx-add-comment`,onClick:t.onAddComment,hint:Ns(`comment`),children:`Comment on this`}),(0,Q.jsx)(M,{})]}):null,(0,Q.jsx)($,{testId:`ctx-cut`,onClick:t.onCut,hint:Qp(`cut`),children:`Cut`}),(0,Q.jsx)($,{testId:`ctx-copy`,onClick:t.onCopy,hint:Qp(`copy`),children:`Copy`}),(0,Q.jsx)($,{testId:`ctx-duplicate`,onClick:t.onDuplicate,hint:Qp(`duplicate`),children:`Duplicate`}),t.hasClipboard?(0,Q.jsx)($,{testId:`ctx-paste`,onClick:t.onPaste,hint:`⌘V`,children:`Paste here`}):null,t.canAskAi?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(M,{}),(0,Q.jsx)(Ry,{model:t})]}):null,t.askHost?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(M,{}),(0,Q.jsx)($,{testId:`ctx-ask-host`,onClick:t.askHost.run,children:t.askHost.label})]}):null,(0,Q.jsx)(M,{}),(0,Q.jsx)($,{testId:`ctx-wrap-frame`,onClick:t.onWrapInFrame,children:`Wrap selection in frame`}),(0,Q.jsx)($,{testId:`ctx-zoom-selection`,onClick:t.onZoomToSelection,children:`Zoom to selection`}),(0,Q.jsx)(M,{}),(0,Q.jsx)($,{testId:`ctx-copy-styles`,onClick:t.onCopyStyles,hint:Qp(`copyStyles`),children:`Copy styles`}),t.hasStyleClipboard?(0,Q.jsx)($,{testId:`ctx-paste-styles`,onClick:t.onPasteStyles,hint:Qp(`pasteStyles`),children:`Paste styles`}):null,(0,Q.jsx)(M,{}),(0,Q.jsx)(Fy,{model:t}),(0,Q.jsx)(Iy,{model:t}),(0,Q.jsx)(M,{}),(0,Q.jsx)($,{testId:`ctx-flip-h`,onClick:t.onFlipHorizontal,hint:Qp(`flipHorizontal`),children:`Flip horizontal`}),(0,Q.jsx)($,{testId:`ctx-flip-v`,onClick:t.onFlipVertical,hint:Qp(`flipVertical`),children:`Flip vertical`}),(0,Q.jsx)(jy,{model:t}),t.canGroup||t.canUngroup?(0,Q.jsx)(M,{}):null,t.canGroup?(0,Q.jsx)($,{testId:`ctx-group`,onClick:t.onGroup,hint:Qp(`group`),children:`Group`}):null,t.canUngroup?(0,Q.jsx)($,{testId:`ctx-ungroup`,onClick:t.onUngroup,hint:Qp(`ungroup`),children:`Ungroup`}):null,(0,Q.jsx)(M,{}),(0,Q.jsx)(Ly,{model:t}),t.canEmbedFrame?(0,Q.jsx)($,{testId:`ctx-embed-frame`,onClick:t.onEmbedFrame,children:`Embed frame…`}):null,(0,Q.jsx)(M,{}),(0,Q.jsx)($,{testId:`ctx-lock`,onClick:t.onLock,hint:Qp(`lock`),children:`Lock`}),(0,Q.jsx)($,{testId:`ctx-delete`,onClick:t.onDelete,hint:`⌫`,children:`Delete`})]}):(0,Q.jsxs)(Q.Fragment,{children:[t.canComment?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)($,{testId:`ctx-add-comment`,onClick:t.onAddComment,hint:Ns(`comment`),children:`Add comment here`}),(0,Q.jsx)(M,{})]}):null,t.hasClipboard?(0,Q.jsx)($,{testId:`ctx-paste`,onClick:t.onPaste,hint:`⌘V`,children:`Paste here`}):null,t.canSelectAll?(0,Q.jsx)($,{testId:`ctx-select-all`,onClick:t.onSelectAll,hint:Qp(`selectAll`),children:`Select all`}):null,t.hasClipboard||t.canSelectAll?(0,Q.jsx)(M,{}):null,(0,Q.jsx)(zy,{model:t,selectAll:!1}),(0,Q.jsx)(M,{}),(0,Q.jsxs)(Ey,{className:ky,"data-testid":`ctx-grid`,checked:t.showGrid,onCheckedChange:()=>t.onToggleGrid(),children:[(0,Q.jsx)(`span`,{children:`Show grid`}),(0,Q.jsx)(Dy,{children:(0,Q.jsx)(Qs,{size:14,stroke:2})})]}),(0,Q.jsxs)(Ey,{className:ky,"data-testid":`ctx-snap`,checked:t.snapEnabled,onCheckedChange:()=>t.onToggleSnap(),children:[(0,Q.jsx)(`span`,{children:`Enable snapping`}),(0,Q.jsx)(Dy,{children:(0,Q.jsx)(Qs,{size:14,stroke:2})})]}),(0,Q.jsxs)(Ey,{className:ky,"data-testid":`ctx-presentation-animation`,checked:t.presentationAnimation,onCheckedChange:()=>t.onTogglePresentationAnimation(),children:[(0,Q.jsx)(`span`,{children:`Presentation animation`}),(0,Q.jsx)(Dy,{children:(0,Q.jsx)(Qs,{size:14,stroke:2})})]}),(0,Q.jsxs)(Ey,{className:ky,"data-testid":`ctx-zoom-indicator`,checked:t.showZoomIndicator,onCheckedChange:()=>t.onToggleShowZoomIndicator(),children:[(0,Q.jsx)(`span`,{children:`Zoom indicator`}),(0,Q.jsx)(Dy,{children:(0,Q.jsx)(Qs,{size:14,stroke:2})})]}),t.canClear?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(M,{}),(0,Q.jsx)($,{testId:`ctx-clear-canvas`,onClick:t.onClear,children:`Clear canvas`})]}):null]})})})}function Hy(e){let{buildModel:t,children:n}=e;return(0,Q.jsxs)(Ka,{onOpenChange:e=>{e&&t().onMenuOpen()},children:[(0,Q.jsx)(Ua,{render:(0,Q.jsx)(`div`,{style:{display:`contents`}}),children:n}),(0,Q.jsx)(P,{children:(0,Q.jsx)(Vy,{buildModel:t})})]})}function Uy(e,t){return{load:e,pick:t}}var Wy=Uy(()=>Ai(()=>import(`./slides-panel-BEJCevJi.js`),__vite__mapDeps([20,4,13,21,22,23,24,25,26,14,1,2,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,16,51,52,53,54,55,56,5,57,58,59,60,61,62,63,64,19,65,18,6,9,66,67,68])),e=>e.SlidesPanel),Gy=Uy(()=>Ai(()=>import(`./code-panel-koBUgEWp.js`),__vite__mapDeps([69,4,13,23,21,22,24,25,26,14,1,2,27,28,18,36,9,8,5,70,16,31,71,48,54,72,42,61,62,30,73,63,64,17,3,6,7,10,19,65,66,67,68,74,75,76])),e=>e.CodePanel),Ky=Uy(()=>Ai(()=>import(`./flow-panel-BzXNGGke.js`),__vite__mapDeps([77,4,13,21,22,23,24,25,26,14,1,2,27,28,29,30,31,32,33,34,35,78,71,79,75,43,80,74,46,47,81,82,51,40,83,52,53,54,55,42,63,64,61])),e=>e.FlowPanel),qy=Uy(()=>Ai(()=>import(`./flow-panel-BzXNGGke.js`),__vite__mapDeps([77,4,13,21,22,23,24,25,26,14,1,2,27,28,29,30,31,32,33,34,35,78,71,79,75,43,80,74,46,47,81,82,51,40,83,52,53,54,55,42,63,64,61])),e=>e.FlowMenuPopup),Jy=Uy(()=>Ai(()=>import(`./flow-layer-ewaL7g2y.js`),__vite__mapDeps([84,4,13,21,26,14,1,2,50,78,85,86,18,31,79,75,80,74,46,47,87,82,51,40,54,55,63,88])),e=>e.FlowLayer),Yy=Uy(()=>Ai(()=>import(`./presentation-DJUO0t7I.js`),__vite__mapDeps([89,4,13,21,26,14,1,2,90,86,18,46,31,47,49,50,16,54,75,59,42,74,88])),e=>e.Presentation),Xy=Uy(()=>Ai(()=>import(`./web-embed-dialog-XUNelFFM.js`),__vite__mapDeps([91,4,13,21,26,14,1,2,92,71,31,34,61,23,62,30,28,93,73])),e=>e.WebEmbedDialog),Zy=Uy(()=>Ai(()=>import(`./web-html-dialog-BcAyzH5D.js`),__vite__mapDeps([94,4,13,21,26,14,1,2,95,22,23,24,25,27,28,31,48,42,12,34,61,62,30,93,73])),e=>e.WebHtmlDialog),Qy=Uy(()=>Ai(()=>import(`./slide-notes-dialog-BQBXpep6.js`),__vite__mapDeps([96,4,13,21,26,14,1,2,54,31,61,23,62,30,28])),e=>e.SlideNotesDialog),$y=()=>Ai(()=>import(`./icon-picker-Cg39IKNJ.js`),__vite__mapDeps([97,4,13,21,26,14,1,2,5,9,8,41,23,24,33,42,76,98,22,25,27,28,72,99,15,100])),eb=Uy($y,e=>e.IconPicker),tb=Uy($y,e=>e.IconPickerContent),nb=Uy(()=>Ai(()=>import(`./image-library-JQu_tb8P.js`),__vite__mapDeps([101,4,13,21,35,26,14,1,2,8,5,9,102,31,103,15,34,61,23,98,22,24,25,27,28,72,99,100])),e=>e.ImageLibraryDialog),rb=Uy(()=>Ai(()=>import(`./tool-drawer-CWOX_njp.js`),__vite__mapDeps([104,4,13,21,35,26,14,1,2,105,67,31,71,106,82,39,107,51,108,103,53,41,23,24,33,27,72,42,109,34,61,100])),e=>e.ToolDrawer),ib=Uy(()=>Ai(()=>import(`./export-dialog-x2n2a4KX.js`),__vite__mapDeps([110,4,13,21,35,26,14,1,2,111,72,54,31,56,38,23,25,36,5,57,58,34,61,62,30,28,73])),e=>e.ExportDialog),ab=Uy(()=>Ai(()=>import(`./copy-image-dialog-BzGP7Xw8.js`),__vite__mapDeps([112,4,13,21,26,14,1,2,7,54,31,34,61,23,62,30,28,93,73])),e=>e.CopyImageDialog),ob=Uy(()=>Ai(()=>import(`./command-palette-BR-_ChOL.js`),__vite__mapDeps([109,4,13,21,26,14,1,2,103,31,27,34,61,23])),e=>e.CommandPalette),sb=Uy(()=>Ai(()=>import(`./build-pips-BV-uwXlP.js`),__vite__mapDeps([113,4,13,21,26,14,1,2,81,31,59,60])),e=>e.BuildPips),cb=Uy(()=>Ai(()=>import(`./upgrade-dialog-DhSZnDpx.js`),__vite__mapDeps([114,4,13,23,21,30,35,31,32,115,116,102,51,108,53,117,54,28,34,61,62,93,73])),e=>e.UpgradeDialog),lb=Uy(()=>Ai(()=>import(`./sign-in-dialog-tmQEB2bx.js`),__vite__mapDeps([118,4,13,38,23,21,25,35,31,44,119,116,107,53,117,54,34,61,62,30,28,93])),e=>e.SignInDialog);function ub(e){return(0,J.useEffect)(()=>Qh(()=>eo(cb)),[]),(0,Q.jsx)(no,{active:e.open,retain:!0,feature:cb,children:t=>(0,Q.jsx)(t,{...e})})}function db(e){return(0,J.useEffect)(()=>Qh(()=>eo(lb)),[]),(0,Q.jsx)(no,{active:e.open,retain:!0,feature:lb,children:t=>(0,Q.jsx)(t,{...e})})}var fb=24,pb=16,mb=64;function hb(e){if(!(e>0)||!Number.isFinite(e))return fb;let t=fb*e;for(;t<pb;)t*=2;for(;t>mb;)t/=2;return t}function gb(e){let{viewport:t}=e,n=hb(t.zoom),r=Vr(t.zoom*.8,.65,1);return(0,Q.jsx)(`div`,{"aria-hidden":!0,"data-testid":`grid`,className:`pointer-events-none absolute inset-0`,style:{backgroundImage:[`linear-gradient(var(--canvas-paper-tint), var(--canvas-paper-tint))`,`radial-gradient(circle, var(--canvas-dot) ${r}px, transparent ${r+.2}px)`].join(`, `),backgroundSize:`auto, ${n}px ${n}px`,backgroundPosition:`0 0, ${t.x}px ${t.y}px`}})}var _b=(0,J.memo)(gb);function vb(){let e=U(e=>e.animateSlideId),t=U(e=>e.hoveredId),n=U(e=>e.shapes);return(0,J.useMemo)(()=>{if(!e||!t||t===e)return null;let r=In(n).find(t=>t.id===e);if(!r)return null;let i=Hn(n,r),a=i.find(e=>e.id===t);if(!a)return null;let o=a.groupId;return o&&nl(n,r).has(o)?i.filter(e=>e.groupId===o):[a]},[e,t,n])}function yb(e){let{interactive:t,transforming:n,zoom:r}=e,i=U(e=>e.hoveredId),a=_e(e=>[e.shapes,e.hoveredId],(e,t)=>t?Qe(e,t):void 0),o=_e(e=>[e.shapes,a?.groupId],(e,t)=>t?e.filter(e=>e.groupId===t):Cb),s=U(e=>e.selectedIds),c=U(e=>e.editSession.kind===`crop`?e.editSession.shapeId:null),l=U(e=>e.activeGroupId),u=U(e=>e.coarsePointer),d=vb()?.some(e=>e.id===i)??!1,f=H().measurement;if(u||!i||!t||n||i===c||d||!a||a.locked)return null;if(a.groupId&&a.groupId!==l){let e=o;if(e.every(e=>s.has(e.id)))return(0,Q.jsx)(Eb,{shape:a,zoom:r});let t=pn(e,f);return t?(0,Q.jsx)(bb,{bounds:t,zoom:r}):null}return s.has(i)?null:(0,Q.jsx)(Eb,{shape:a,zoom:r})}function bb(e){let{bounds:t,zoom:n}=e;return(0,Q.jsx)(`svg`,{"data-testid":`hover-indicator`,className:`absolute overflow-visible`,width:1,height:1,style:{pointerEvents:`none`},children:(0,Q.jsx)(`rect`,{x:t.x,y:t.y,width:t.width,height:t.height,rx:4,fill:`none`,stroke:`var(--canvas-selection)`,strokeWidth:1.5/n})})}var xb=new Set([`arrow`,`line`,`draw`]),Sb=1e3,Cb=[];function wb(e){let{interactive:t,zoom:n,shapes:r}=e,i=U(e=>e.selectedIds),a=U(e=>be(e.editSession)),o=U(e=>e.activeGroupId),s=U(e=>e.viewMode),c=U(e=>e.transforming);if(!t||c||i.size===0)return null;let l=r.filter(e=>i.has(e.id)&&e.id!==a);return l.length>Sb||!s&&(i.size===1&&l.length===1&&!xb.has(l[0].type)||l.length>1&&l[0].groupId&&l[0].groupId!==o&&l.every(e=>e.groupId===l[0].groupId))?null:(0,Q.jsx)(Q.Fragment,{children:l.map(e=>(0,Q.jsx)(Eb,{shape:e,zoom:n,testId:`selection-outline`},e.id))})}function Tb(e){let{shape:t,stroke:n,strokeWidth:r,strokeOpacity:i,linecap:a}=e,o=H().measurement,s={fill:`none`,stroke:n,strokeWidth:r,...i===void 0?{}:{strokeOpacity:i},style:{pointerEvents:`none`}};if(t.type===`arrow`)return(0,Q.jsx)(`path`,{d:on(t),strokeLinejoin:`round`,strokeLinecap:a,...s});if(t.type===`line`)return(0,Q.jsx)(`path`,{d:pt(t.points),strokeLinejoin:`round`,strokeLinecap:`round`,...s});if(t.type===`draw`)return(0,Q.jsx)(`path`,{d:gr(t),strokeLinejoin:`round`,strokeLinecap:`round`,...s});let c=t.type===`icon`?Dn(t,o):G(t,o),l=G(t,o),u=l.x+l.width/2,d=l.y+l.height/2,f=cr(t),p=t.type===`rectangle`?(0,Q.jsx)(`path`,{d:it(t.kind,c,t.corner,{x:t.flipX,y:t.flipY}),strokeLinejoin:`round`,...s}):(0,Q.jsx)(`rect`,{x:c.x,y:c.y,width:c.width,height:c.height,rx:t.type===`image`?2:4,...s});return(0,Q.jsx)(`g`,{transform:f?`rotate(${f} ${u} ${d})`:void 0,children:p})}function Eb(e){let{shape:t,zoom:n,testId:r}=e;return(0,Q.jsx)(`svg`,{"data-testid":r??`hover-indicator`,className:`absolute overflow-visible`,width:1,height:1,style:{pointerEvents:`none`},children:(0,Q.jsx)(Tb,{shape:t,stroke:`var(--canvas-selection)`,strokeWidth:1.5/n})})}function Db(e,t,n,r){return e.map((e,i)=>i===t?e.map((e,t)=>t===n?r:e):e)}function Ob(e,t){let n=e[0]?.length??1,r=n=>n===0?`Point ${e.length}`:t?`0.5`:``;return[...e,Array.from({length:n},(e,t)=>r(t))]}function kb(e){return e.map((e,t)=>[...e,t===0?`Series ${e.length}`:``])}function Ab(e,t){return t===0||e.length<=2?e:e.filter((e,n)=>n!==t)}function jb(e,t){return t===0||(e[0]?.length??0)<=2?e:e.map(e=>e.filter((e,n)=>n!==t))}var Mb=`h-7 w-20 rounded-md border border-[var(--chrome-ring)] bg-[var(--chrome-popup)] px-1.5 text-[12px] text-[var(--chrome-fg-700)] outline-none focus:border-gray-400`;function Nb(e){let{shape:t,viewport:n,onChange:r,onClose:i}=e,{history:a}=H(),o=t.cells,s=o[0]?.length??1,c=t.chartType===`quadrant`,l=(0,J.useRef)(null);(0,J.useEffect)(()=>{function e(e){l.current&&!l.current.contains(e.target)&&i()}return window.addEventListener(`pointerdown`,e,!0),()=>window.removeEventListener(`pointerdown`,e,!0)},[i]);let u=_r({x:t.x+t.width,y:t.y},n),d=_r({x:t.x,y:t.y},n),f=96+s*84,p=u.x+12+f>window.innerWidth?Math.max(8,d.x-12-f):u.x+12,m=Math.max(8,u.y);return(0,Q.jsxs)(`div`,{ref:l,"data-testid":`chart-data-editor`,"data-overlay":!0,className:`absolute z-10 rounded-xl p-2.5 ${dl}`,style:{left:p,top:m,maxHeight:`60vh`,overflow:`auto`},onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),children:[(0,Q.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-6`,children:[(0,Q.jsx)(`span`,{className:`text-[12px] text-[var(--chrome-fg-500)]`,children:c?`Quadrant points`:`Chart data`}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Done`,onClick:i,className:`flex h-6 w-6 items-center justify-center rounded-md text-[var(--chrome-fg-500)] transition-colors hover:bg-[var(--chrome-divider)]`,children:(0,Q.jsx)(Cc,{size:14,stroke:1.75})})]}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-1`,children:o.map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[e.map((e,n)=>(0,Q.jsxs)(`div`,{className:`relative`,children:[t===0&&n>0&&s>2&&!c&&(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Remove series ${n}`,onClick:()=>r(jb(o,n)),className:`absolute -top-2 right-0 flex h-4 w-4 items-center justify-center rounded-full bg-[var(--chrome-popup)] text-[var(--chrome-fg-400)] ring-1 ring-[var(--chrome-ring)] transition-colors hover:text-[var(--chrome-fg-700)]`,children:(0,Q.jsx)(Cc,{size:10,stroke:2})}),(0,Q.jsx)(`input`,{value:e,inputMode:t>0&&n>0?`decimal`:void 0,placeholder:t===0&&n===0?`-`:void 0,onChange:e=>r(Db(o,t,n,e.target.value)),onFocus:a.beginTransaction,onBlur:a.endTransaction,className:t===0||n===0?`${Mb} font-medium text-[var(--chrome-fg-800)]`:Mb})]},n)),(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Remove row ${t}`,onClick:()=>r(Ab(o,t)),disabled:t===0||o.length<=2,className:`flex h-6 w-6 items-center justify-center rounded-md text-[var(--chrome-fg-300)] transition-colors hover:bg-[var(--chrome-divider)] enabled:hover:text-[var(--chrome-fg-700)] disabled:opacity-0`,children:(0,Q.jsx)(Cc,{size:13,stroke:1.75})})]},t))}),(0,Q.jsxs)(`div`,{className:`mt-2 flex items-center gap-1 border-t border-[var(--chrome-ring)] pt-2`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>r(Ob(o,c)),className:`flex h-7 items-center gap-1 rounded-md px-2 text-[12px] text-[var(--chrome-fg-700)] transition-colors hover:bg-[var(--chrome-divider)]`,children:[(0,Q.jsx)(_c,{size:13,stroke:2}),` `,c?`Point`:`Row`]}),!c&&(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>r(kb(o)),className:`flex h-7 items-center gap-1 rounded-md px-2 text-[12px] text-[var(--chrome-fg-700)] transition-colors hover:bg-[var(--chrome-divider)]`,children:[(0,Q.jsx)(_c,{size:13,stroke:2}),` Series`]})]})]})}var Pb=J.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:c=!0,...l}=e,{buttonRef:u,getButtonProps:f}=b({disabled:a,focusableWhenDisabled:!1,native:c}),{store:p}=Ic();return Fc(),d(`button`,e,{ref:[t,u],props:[{onClick(e){p.setOpen(!1,s(o,e.nativeEvent))}},l,f]})}),Fb=4e3,Ib=`pending:`;function Lb(e){return e.startsWith(Ib)}var Rb=[`@`,`+`];function zb(e){return ml(e,`alert-dialog`)}var Bb=J.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,payload:c,handle:u,...m}=e,g=_l(!0),_=u?.store??g?.store;if(!_)throw Error(f(79));let v=el(s),y=_.useState(`floatingRootContext`),x=_.useState(`isOpenedByTrigger`,v),S=_.useState(`triggerPopupId`,v),C=J.useRef(null),{registerTrigger:w,isMountedByThisTrigger:E}=h(v,C,_,{payload:c}),{getButtonProps:D,buttonRef:O}=b({disabled:a,native:o}),A=T(y,{enabled:y!=null}),j=k(()=>_.select(`open`),e=>{_.set(`openMethod`,e)}),M={disabled:a,open:x},N=_.useState(`triggerProps`,E);return d(`button`,e,{state:M,ref:[O,t,w,C],props:[A.reference,N,j,{[p]:``,id:v,"aria-haspopup":`dialog`,"aria-expanded":x,"aria-controls":S},m,D],stateAttributesMapping:l})});function Vb(e){let{open:t,onOpenChange:n,title:r,description:i,confirmLabel:a,destructive:o,onConfirm:s,testId:c}=e,{pending:l,error:u,run:d}=wl({open:t}),f=o?`bg-red-600 hover:bg-red-700`:`bg-[var(--chrome-accent)] hover:bg-[var(--chrome-accent-hover)]`;function p(){d(()=>s(),{onSuccess:()=>n(!1),errorFor:e=>Cl(e,`That didn't work. Try again.`)})}return(0,Q.jsx)(zb,{open:t,onOpenChange:e=>{l&&!e||n(e)},children:(0,Q.jsxs)(gl,{children:[(0,Q.jsx)(hl,{className:q.dialogBackdrop}),(0,Q.jsxs)(vl,{"data-overlay":!0,"data-testid":c,className:`w-[min(400px,92vw)] p-5 ${q.dialogPopup}`,children:[(0,Q.jsx)(xl,{className:`text-[15px] text-[var(--chrome-fg-900)]`,children:r}),(0,Q.jsx)(Sl,{className:`mt-2 text-[13px] leading-relaxed text-[var(--chrome-fg-500)]`,children:i}),u&&(0,Q.jsx)(`p`,{role:`alert`,"data-testid":c?`${c}-error`:void 0,className:`mt-3 text-[12px] leading-relaxed text-[var(--chrome-danger)]`,children:u}),(0,Q.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,Q.jsx)(bl,{disabled:l,className:`h-8 rounded-xl bg-[var(--chrome-popup)] px-3.5 text-[13px] text-[var(--chrome-fg-700)] outline-none ring-1 ring-[var(--chrome-ring)] transition-colors hover:bg-[var(--chrome-hover)] disabled:opacity-60`,children:`Cancel`}),(0,Q.jsx)(`button`,{type:`button`,"data-testid":c?`${c}-accept`:void 0,disabled:l,onClick:()=>p(),className:tl(`h-8 rounded-xl px-3.5 text-[13px] text-white outline-none transition-colors active:scale-[0.97] disabled:opacity-60 disabled:active:scale-100`,f),children:l?`Working…`:a})]})]})]})})}var Hb=`hidden`;function Ub(e,t){return!e||!t?null:`${Vc.commentsHidden}:${e}:${t}`}function Wb(e){return!e||Hc.getString(e)!==Hb}function Gb(e,t){if(e){if(t){Hc.remove(e);return}Hc.setString(e,Hb)}}function Kb(){let e=re(),t=W(),n=Ub(e?.currentUser?.id,e?.canvasId);(0,J.useEffect)(()=>{if(n)return t.getState().setCommentsVisible(Wb(n)),t.subscribe((e,t)=>{e.commentsVisible!==t.commentsVisible&&Gb(n,e.commentsVisible)})},[n,t])}function qb(e,t){if(t.length===0||!e.includes(`@`))return[{text:e,mention:!1}];let n=[...t].sort((e,t)=>t.length-e.length),r=[],i=``,a=0;for(;a<e.length;){let t=``;if(e[a]===`@`){let r=e.slice(a+1),i=n.find(e=>{if(!r.startsWith(e))return!1;let t=r[e.length];return t===void 0||/\W/.test(t)});i&&(t=`@${i}`)}if(t){i&&=(r.push({text:i,mention:!1}),``),r.push({text:t,mention:!0}),a+=t.length;continue}i+=e[a],a+=1}return i&&r.push({text:i,mention:!1}),r}function Jb(e,t){let n=null;for(let r of Rb){let i=e.lastIndexOf(r,t-1);if(i<0)continue;let a=i===0?``:e[i-1];if(a&&!/\s/.test(a))continue;let o=e.slice(i+1,t);/\s/.test(o)||(!n||i>n.at)&&(n={text:o,at:i})}return n}function Yb(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=e.filter(e=>e.name.toLowerCase().startsWith(n)),i=e.filter(e=>!e.name.toLowerCase().startsWith(n)&&e.name.toLowerCase().includes(n));return[...r,...i]}function Xb(e,t,n,r){let i=`@${n.name} `;return{value:e.slice(0,t.at)+i+e.slice(r),caret:t.at+i.length}}function Zb(e,t){let n=new Set(qb(e,t.map(e=>e.name)).filter(e=>e.mention).map(e=>e.text.slice(1))),r=t.filter(e=>n.has(e.name)).map(e=>e.userId);return[...new Set(r)]}function Qb(e,t){return e.notifications?.unread[t]??0}function $b(e){let t=e.notifications?.unread??{};return e.threads.some(e=>(t[e.id]??0)>0)}function ex(e){let t=re(),n=t&&e?Qb(t,e):0,r=t?.notifications?.markThreadRead;(0,J.useEffect)(()=>{!e||n===0||!r||r(e)},[e,n,r])}function tx(e,t){let n=e.store.getState(),r=new Map(n.shapes.map(e=>[e.id,e])),i=Ym(t.anchor,r,e.measurement);if(!i)return!1;let a=document.querySelector(`[data-canvas-root]`);if(a instanceof HTMLElement){let{viewport:t}=n;e.viewportAnimation.animate(t,{zoom:t.zoom,x:a.clientWidth/2-i.x*t.zoom,y:a.clientHeight/2-i.y*t.zoom},n.setViewport)}return n.setCommentsVisible(!0),n.setOpenThreadId(t.id),!0}function nx(){let e=re(),t=H(),n=e?.focusThreadId??null,r=e?.loaded??!1,i=e?.threads,a=e?.onFocusHandled;(0,J.useEffect)(()=>{if(!n||!r||!i)return;let e=i.find(e=>e.id===n);e&&tx(t,e),a?.()},[n,r,i,t,a])}function rx(e,t){let n=Math.max(0,t-e),r=Math.floor(n/6e4);if(r<1)return`now`;if(r<60)return`${r}m`;let i=Math.floor(r/60);if(i<24)return`${i}h`;let a=Math.floor(i/24);return a<7?`${a}d`:new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function ix(e){return(e.trim()[0]??`?`).toUpperCase()}function ax(e){let{placeholder:t,submitLabel:n,initialValue:r,autoFocus:i,members:a,onSubmit:o,onCancel:s,cancelLabel:c,testId:l,handleRef:u,confirmDiscard:d}=e,[f,p]=(0,J.useState)(r??``),[m,h]=(0,J.useState)(!1),[g,_]=(0,J.useState)(null),[v,y]=(0,J.useState)(null),[b,x]=(0,J.useState)(0),S=(0,J.useRef)(null),C=(0,J.useRef)(null),w=(0,J.useRef)(!1),T=f.trim()!==(r??``).trim();(0,J.useImperativeHandle)(u,()=>({isDirty:()=>T,discard:()=>p(r??``)})),(0,J.useEffect)(()=>{i&&S.current?.focus()},[i]);let E=f.trim(),D=E.length>Fb,O=E.length>0&&!D,k=a??[],A=v?Yb(k,v.text).slice(0,6):[],j=v!==null&&A.length>0,M=v!==null&&k.length===0;function N(e,t){y(Jb(e,t)),x(0)}function P(e){let t=S.current;if(!v||!t)return;let n=Xb(f,v,e,t.selectionStart??f.length);t.value=n.value,t.setSelectionRange(n.caret,n.caret),t.focus(),p(n.value),y(null)}async function F(){if(!O||w.current)return;let e=E;w.current=!0,h(!0),_(null),p(``),y(null);try{await o(e)}catch(t){p(e),_(Cl(t,`That didn't send. Try again.`))}finally{w.current=!1,h(!1)}}return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`div`,{ref:C,"aria-hidden":!0,className:`pointer-events-none absolute inset-0 overflow-hidden whitespace-pre-wrap break-words rounded-lg px-3 py-2 text-[13px] leading-relaxed text-transparent`,children:qb(f,k.map(e=>e.name)).map((e,t)=>e.mention?(0,Q.jsx)(`span`,{"data-testid":`comment-compose-mention`,className:`rounded bg-[var(--chrome-active)] box-decoration-clone`,children:e.text},t):(0,Q.jsx)(`span`,{children:e.text},t))}),(0,Q.jsx)(`textarea`,{ref:S,value:f,rows:2,"data-testid":l,placeholder:t,onChange:e=>{p(e.target.value),N(e.target.value,e.target.selectionStart??0)},onClick:e=>N(e.currentTarget.value,e.currentTarget.selectionStart??0),onBlur:()=>y(null),onScroll:e=>{let t=C.current;t&&(t.scrollTop=e.currentTarget.scrollTop)},onKeyDown:e=>{if(!(e.nativeEvent.isComposing||e.keyCode===229)){if((j||M)&&e.key===`Escape`){e.preventDefault(),e.stopPropagation(),y(null);return}if(j){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;x(e=>(e+t+A.length)%A.length);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),P(A[b]);return}}if(M&&e.key===`Enter`){e.preventDefault(),y(null);return}if(e.key===`Enter`&&!e.shiftKey){e.preventDefault(),F();return}if(e.key===`Escape`&&s){if(e.preventDefault(),e.stopPropagation(),T&&d){d(s);return}s()}}},className:`${Tl.field} relative resize-none leading-relaxed`}),(j||M)&&(0,Q.jsxs)(`div`,{"data-testid":`comment-mention-list`,className:`absolute bottom-full left-0 z-10 mb-1 w-full overflow-hidden rounded-lg bg-[var(--chrome-popup)] py-1 shadow-[0_1px_2px_rgba(0,0,0,0.05),0_4px_12px_rgba(0,0,0,0.06)] ring-1 ring-[var(--chrome-ring)]`,children:[M&&(0,Q.jsx)(`p`,{"data-testid":`comment-mention-empty`,className:`px-2 py-1.5 text-[13px] text-[var(--chrome-fg-400)]`,children:`No one to mention yet.`}),A.map((e,t)=>(0,Q.jsxs)(`button`,{type:`button`,"data-testid":`comment-mention-option`,onPointerDown:t=>{t.preventDefault(),P(e)},onPointerEnter:()=>x(t),className:`flex w-full items-center gap-2 px-2 py-1.5 text-left text-[13px] text-[var(--chrome-fg-700)] ${t===b?`bg-[var(--chrome-hover)]`:``}`,children:[e.avatarUrl?(0,Q.jsx)(`img`,{src:e.avatarUrl,alt:``,referrerPolicy:`no-referrer`,className:`h-5 w-5 shrink-0 rounded-full object-cover`}):(0,Q.jsx)(`span`,{className:`flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-[var(--chrome-active)] text-[10px]`,children:ix(e.name)}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.name}),e.self&&(0,Q.jsx)(`span`,{className:`text-[var(--chrome-fg-400)]`,children:`(you)`})]},e.userId))]})]}),(g||D)&&(0,Q.jsx)(`p`,{role:`alert`,"data-testid":l?`${l}-error`:void 0,className:Tl.error,children:D?`Comments are limited to 4000 characters.`:g}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[k.length>0&&(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Mention someone`,"data-testid":`comment-mention-trigger`,onClick:()=>{let e=S.current;if(!e)return;let t=e.selectionStart??f.length,n=`${t>0&&!/\s/.test(f[t-1]??` `)?` `:``}@`,r=f.slice(0,t)+n+f.slice(t);p(r);let i=t+n.length;requestAnimationFrame(()=>{e.focus(),e.setSelectionRange(i,i),N(r,i)})},className:`flex h-8 w-8 cursor-pointer items-center justify-center rounded-lg text-[var(--chrome-fg-600)] transition-[background-color,scale] hover:bg-[var(--chrome-hover)] active:scale-[0.96] coarse:h-11 coarse:w-11 mr-auto h-8 w-8`,children:(0,Q.jsx)(If,{size:16,stroke:1.75})}),s&&(0,Q.jsx)(`button`,{type:`button`,onClick:s,className:Tl.cancelButton,children:c??`Cancel`}),(0,Q.jsx)(`button`,{type:`button`,disabled:!O||m,"data-testid":l?`${l}-submit`:void 0,onClick:()=>void F(),className:Tl.submitButton,children:n})]})]})}function ox(e){let{author:t,size:n=`md`,testId:r}=e,i=n===`sm`?`h-4 w-4 text-[9px]`:`h-6 w-6 text-[11px]`;return t.avatarUrl?(0,Q.jsx)(`img`,{src:t.avatarUrl,alt:``,"data-testid":r,referrerPolicy:`no-referrer`,className:`${i} shrink-0 rounded-full object-cover`}):(0,Q.jsx)(`span`,{"data-testid":r,className:`${i} flex shrink-0 items-center justify-center rounded-full bg-[var(--chrome-active)] text-[var(--chrome-fg-700)]`,children:ix(t.name)})}function sx(e){let{text:t,names:n}=e;return(0,Q.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-[13px] leading-relaxed text-[var(--chrome-fg-700)]`,children:qb(t,n).map((e,t)=>e.mention?(0,Q.jsx)(`span`,{"data-testid":`comment-mention`,className:`whitespace-nowrap rounded bg-[var(--chrome-active)] px-0.5 text-[var(--chrome-fg-900)]`,children:e.text},t):(0,Q.jsx)(`span`,{children:e.text},t))})}function cx(e){let{comment:t,isRoot:n,comments:r,names:i,now:a,editing:o,onEdit:s,onEditDone:c,composerRef:l,confirmDiscard:u}=e,[d,f]=(0,J.useState)(!1),p=t.author.id!==null&&t.author.id===r.currentUser?.id,m=!n&&(p||r.canModerate);return o?(0,Q.jsx)(`div`,{className:`flex flex-col gap-2 px-3 py-2`,children:(0,Q.jsx)(ax,{placeholder:`Edit your comment`,submitLabel:`Save`,cancelLabel:`Discard`,initialValue:t.body,members:r.members,autoFocus:!0,testId:`comment-edit`,handleRef:l,confirmDiscard:u,onCancel:c,onSubmit:async e=>{await r.update(t.id,e,Zb(e,r.members)),c()}})}):(0,Q.jsxs)(`div`,{className:`group/comment flex gap-2 px-3 py-2`,"data-testid":`comment-row`,children:[(0,Q.jsx)(ox,{author:t.author}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-baseline gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`truncate text-[13px] text-[var(--chrome-fg-900)]`,children:t.author.name}),(0,Q.jsx)(`span`,{className:`shrink-0 text-[11px] text-[var(--chrome-fg-400)]`,children:rx(t.createdAt,a)}),t.editedAt!==null&&(0,Q.jsx)(`span`,{className:`shrink-0 text-[11px] italic text-[var(--chrome-fg-400)]`,children:`edited`})]}),(0,Q.jsx)(sx,{text:t.body,names:i})]}),(p||m)&&(0,Q.jsxs)(N,{children:[(0,Q.jsx)(I,{render:(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Comment actions`,"data-testid":`comment-actions`,className:`flex h-8 w-8 cursor-pointer items-center justify-center rounded-lg text-[var(--chrome-fg-600)] transition-[background-color,scale] hover:bg-[var(--chrome-hover)] active:scale-[0.96] coarse:h-11 coarse:w-11 h-6 w-6 shrink-0 opacity-0 coarse:h-8 coarse:w-8 coarse:opacity-100 group-hover/comment:opacity-100 data-[popup-open]:opacity-100`,children:(0,Q.jsx)(w,{size:15,stroke:1.75})})}),(0,Q.jsx)(P,{children:(0,Q.jsx)(L,{side:`bottom`,align:`end`,sideOffset:4,className:`outline-none`,children:(0,Q.jsxs)(ee,{"data-overlay":!0,className:`min-w-36 p-1`,children:[p&&(0,Q.jsx)(F,{"data-testid":`comment-edit-action`,onClick:s,children:`Edit`}),m&&(0,Q.jsx)(F,{"data-testid":`comment-delete-action`,onClick:()=>f(!0),className:`text-[var(--chrome-danger)]`,children:`Delete`})]})})})]}),(0,Q.jsx)(Vb,{open:d,onOpenChange:f,title:`Delete this comment?`,description:`This reply will be removed. This can't be undone.`,confirmLabel:`Delete`,destructive:!0,testId:`comment-delete-confirm`,onConfirm:()=>r.remove(t.id)})]})}function lx(e,t){let n=e.comments[0];return n?.author.id!=null&&n.author.id===t.currentUser?.id||t.canModerate}function ux(e){let{thread:t,comments:n,onCloseThread:r,onDeleteRequest:i}=e,{notify:a}=_(),o=t.resolvedAt!==null;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(F,{"data-testid":`comment-resolve-action`,onClick:()=>{n.resolve(t.id,!o).catch(e=>a(Cl(e,`Couldn't update the thread. Try again.`))),o||r()},children:o?`Reopen thread`:`Resolve thread`}),lx(t,n)&&(0,Q.jsx)(F,{"data-testid":`comment-delete-thread-action`,onClick:i,className:`text-[var(--chrome-danger)]`,children:`Delete thread`})]})}function dx(e){let{open:t,onOpenChange:n,onConfirm:r}=e;return(0,Q.jsx)(Vb,{open:t,onOpenChange:n,title:`Delete this thread?`,description:`The pin and every reply under it will be removed. This can't be undone.`,confirmLabel:`Delete`,destructive:!0,testId:`comment-delete-confirm`,onConfirm:r})}function fx(e){let{thread:t,comments:n,onClose:r,now:i,composerRef:a,confirmDiscard:o}=e,[s,c]=(0,J.useState)(!1),[l,u]=(0,J.useState)(!1),[d,f]=(0,J.useState)(null),p=t.comments.length,m=t.resolvedAt!==null,h=n.members.map(e=>e.name);return(0,Q.jsxs)(`div`,{className:`flex w-[304px] flex-col`,"data-testid":`comment-thread`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between border-b border-[var(--chrome-divider)] py-1.5 pl-3 pr-1.5`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[12px] text-[var(--chrome-fg-500)]`,children:[m&&(0,Q.jsxs)(`span`,{"data-testid":`comment-resolved-tag`,className:`flex items-center gap-1 text-[var(--chrome-fg-400)]`,children:[(0,Q.jsx)(Qs,{size:13,stroke:2}),`Resolved`]}),(0,Q.jsxs)(`span`,{"data-testid":`comment-count`,children:[p,` `,p===1?`comment`:`comments`]})]}),(0,Q.jsxs)(N,{children:[(0,Q.jsx)(I,{render:(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Thread actions`,"data-testid":`comment-thread-actions`,className:`${il} h-7 w-7 coarse:h-9 coarse:w-9`,children:(0,Q.jsx)(w,{size:15,stroke:1.75})})}),(0,Q.jsx)(P,{children:(0,Q.jsx)(L,{side:`bottom`,align:`end`,sideOffset:4,className:`outline-none`,children:(0,Q.jsx)(ee,{"data-overlay":!0,className:`min-w-40 p-1`,children:(0,Q.jsx)(ux,{thread:t,comments:n,onCloseThread:r,onDeleteRequest:()=>c(!0)})})})})]})]}),(0,Q.jsx)(`div`,{className:`scrollbar-slim max-h-[320px] divide-y divide-[var(--chrome-divider)] overflow-y-auto`,children:t.comments.map((e,t)=>(0,Q.jsx)(cx,{comment:e,editing:d===e.id,onEdit:()=>{u(!1),f(e.id)},onEditDone:()=>f(null),composerRef:d===e.id?a:void 0,confirmDiscard:o,isRoot:t===0,comments:n,names:h,now:i},e.id))}),d===null&&(0,Q.jsx)(`div`,{className:`border-t border-[var(--chrome-divider)] p-2`,children:l?(0,Q.jsx)(ax,{placeholder:m?`Reply and reopen…`:`Reply…`,submitLabel:`Reply`,members:n.members,autoFocus:!0,testId:`comment-reply`,handleRef:a,confirmDiscard:o,onCancel:()=>u(!1),onSubmit:async e=>{await n.reply(t.id,e,Zb(e,n.members)),u(!1)}}):(0,Q.jsx)(`button`,{type:`button`,"data-testid":`comment-reply-open`,onClick:()=>u(!0),className:`w-full rounded-lg px-3 py-2 text-left text-[13px] text-[var(--chrome-fg-400)] outline-none ring-1 ring-[var(--chrome-input)] transition-shadow hover:ring-[var(--chrome-input-hover)]`,children:m?`Reply and reopen…`:`Add a reply…`})}),(0,Q.jsx)(dx,{open:s,onOpenChange:c,onConfirm:()=>n.remove(t.id)})]})}function px(e){let{members:t,onSubmit:n,onCancel:r,composerRef:i,confirmDiscard:a}=e;return(0,Q.jsxs)(`div`,{className:`flex w-[304px] flex-col`,"data-testid":`comment-draft`,children:[(0,Q.jsx)(`div`,{className:`border-b border-[var(--chrome-divider)] py-1.5 pl-3 pr-1.5 text-[12px] text-[var(--chrome-fg-500)]`,children:`New comment`}),(0,Q.jsx)(`div`,{className:`p-2`,children:(0,Q.jsx)(ax,{placeholder:`Leave a note…`,submitLabel:`Comment`,members:t,autoFocus:!0,testId:`comment-new`,handleRef:i,confirmDiscard:a,onCancel:r,onSubmit:n})})]})}var mx=q.popup,hx=6e4,gx=4,_x=new Map;function vx(e,t){let n=_r(e,t);return{left:n.x,top:n.y-28}}function yx(e){let{at:t,viewport:n,open:r,onOpenChange:i,label:a,testId:o,muted:s,unread:c,dragging:l,pending:u,movable:d,author:f,badge:p,card:m,menu:h,onPointerDown:g}=e,_=vx(t,n),v=(0,Q.jsxs)(Dc,{open:r,onOpenChange:i,children:[(e=>f?(0,Q.jsx)(S,{label:f.name,shortcut:d&&!u?`Drag to move`:void 0,side:`top`,disabled:r||l,testId:`comment-pin-tooltip`,leading:(0,Q.jsx)(ox,{author:f,size:`sm`,testId:`comment-pin-tooltip-avatar`}),children:e}):e)((0,Q.jsx)(Ca,{render:(0,Q.jsx)(`button`,{type:`button`,"aria-label":a,"data-testid":o,"data-resolved":s?`true`:void 0,"data-unread":c?`true`:void 0,"data-pending":u?`true`:void 0,onPointerDown:u||!d?void 0:g,className:`pointer-events-auto absolute flex touch-none items-center justify-center rounded-full rounded-bl-[3px] text-[11px] transition-shadow ${c?`ring-2`:`ring-1`} ${u||!d?`cursor-pointer`:l?`cursor-grabbing`:`cursor-grab`} ${s?`text-[var(--chrome-fg-500)]`:`text-[#1e1e1e]`} ${r?`shadow-[0_3px_10px_rgba(0,0,0,0.20)]`:`shadow-[0_1px_2px_rgba(0,0,0,0.10)] hover:shadow-[0_2px_6px_rgba(0,0,0,0.16)]`} ${c?`ring-[var(--chrome-unread)]`:s?`ring-[var(--chrome-ring)]`:`ring-black/10`}`,style:{left:_.left,top:_.top,width:28,height:28,backgroundColor:s?`var(--chrome-popup)`:Di},children:p})})),(0,Q.jsx)(Mc,{children:(0,Q.jsx)(Lc,{side:`right`,align:`start`,sideOffset:8,collisionPadding:12,children:(0,Q.jsx)(Rc,{"data-overlay":!0,className:mx,children:m})})})]});return h?(0,Q.jsx)(`div`,{style:{display:`contents`},onContextMenu:e=>e.stopPropagation(),children:(0,Q.jsxs)(Ka,{children:[(0,Q.jsx)(Ua,{render:(0,Q.jsx)(`div`,{style:{display:`contents`}}),children:v}),(0,Q.jsx)(P,{children:(0,Q.jsx)(L,{className:`outline-none`,children:(0,Q.jsx)(ee,{"data-overlay":!0,"data-testid":`comment-pin-menu`,className:`min-w-40 p-1`,children:h})})})]})}):v}function bx(e){let{at:t,viewport:n}=e,r=vx(t,n);return(0,Q.jsx)(`div`,{"data-testid":`comment-ghost-pin`,className:`pointer-events-none absolute flex items-center justify-center rounded-full rounded-bl-[3px] text-[#1e1e1e] opacity-50 ring-1 ring-black/10`,style:{left:r.left,top:r.top,width:28,height:28,backgroundColor:Di},children:(0,Q.jsx)(ks,{size:14,stroke:1.75})})}function xx(e){let{viewport:t}=e,n=re(),r=H(),i=W(),a=U(e=>e.shapes),o=U(e=>e.openThreadId),s=U(e=>e.commentDraft),c=U(e=>e.commentsVisible),l=U(e=>e.tool===`comment`?e.hoverWorld:null),u=U(e=>e.presentingIndex!==null),d=U(e=>e.zenMode),[f,p]=(0,J.useState)(()=>Date.now()),[m,h]=(0,J.useState)(null),[g,v]=(0,J.useState)(null),y=(0,J.useRef)({at:null,moved:!1,grab:{x:0,y:0}}),[b,x]=(0,J.useState)(null),S=(0,J.useRef)(null),C=(0,J.useRef)(null),[w,T]=(0,J.useState)(!1),E=(0,J.useRef)(null),[D,O]=(0,J.useState)(null),{notify:k}=_(),A=(0,J.useRef)(null);Kb(),nx(),ex(o);let j=o!==null||s!==null;(0,J.useEffect)(()=>{if(!j)return;p(Date.now());let e=setInterval(()=>p(Date.now()),hx);return()=>clearInterval(e)},[j]);let M=n!==null&&!u&&!d&&c&&(n.threads.length>0||s!==null),N=(0,J.useMemo)(()=>M?(Rn(a),{get:e=>Qe(a,e)}):_x,[M,a]);if((0,J.useEffect)(()=>{if(m===null)return;let e=document.querySelector(`[data-canvas-root]`),t=t=>{let n=e?.getBoundingClientRect(),r=nt({x:t.clientX-(n?.left??0),y:t.clientY-(n?.top??0)},i.getState().viewport),{grab:a}=y.current,o={x:r.x-a.x,y:r.y-a.y};y.current={...y.current,at:o,moved:!0},v(o)},a=()=>{let{at:e,moved:t}=y.current;if(y.current={at:null,moved:!1,grab:{x:0,y:0}},t){let e=e=>{e.stopPropagation(),e.preventDefault()};window.addEventListener(`click`,e,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener(`click`,e,{capture:!0}),0)}if(h(null),v(null),!t||!e||!n)return;let a=Jm(i.getState().shapes,e,r.measurement);x({id:m,at:e}),n.move(m,a).catch(e=>k(Cl(e,`Couldn't move that pin. Try again.`))).finally(()=>x(null))},o=()=>{y.current={at:null,moved:!1,grab:{x:0,y:0}},h(null),v(null)};return window.addEventListener(`pointermove`,t),window.addEventListener(`pointerup`,a),window.addEventListener(`pointercancel`,o),()=>{window.removeEventListener(`pointermove`,t),window.removeEventListener(`pointerup`,a),window.removeEventListener(`pointercancel`,o)}},[m,n,r,i,k]),!n||u||d||!c)return null;let{setOpenThreadId:P,setCommentDraft:F}=i.getState();function I(e,t){if(e?.isDirty()){E.current=t,T(!0);return}t()}let L=[];for(let e of n.threads){let t=m===e.id&&g?g:b?.id===e.id?b.at:Ym(e.anchor,N,r.measurement);t&&L.push({thread:e,at:t})}let ee=s?Ym(s,N,r.measurement):null;ee&&(A.current=ee);let R=s?ee??A.current:null,z=s&&!ee&&R?{kind:`point`,x:R.x,y:R.y}:s,B=n.currentUser?.id??null;return(0,Q.jsxs)(`div`,{className:`pointer-events-none absolute inset-0`,"data-overlay":!0,"data-testid":`comment-pins`,children:[l&&!s&&(0,Q.jsx)(bx,{at:l,viewport:t}),L.map(({thread:e,at:r})=>{let a=e.resolvedAt!==null;return(0,Q.jsx)(yx,{at:r,viewport:t,open:o===e.id&&m===null,muted:a,unread:Qb(n,e.id)>0,dragging:m===e.id,pending:Lb(e.id),movable:n.canModerate||B!==null&&e.comments[0]?.author.id===B,author:e.comments[0]?.author,menu:Lb(e.id)?void 0:(0,Q.jsx)(ux,{thread:e,comments:n,onCloseThread:()=>P(null),onDeleteRequest:()=>O(e.id)}),onOpenChange:t=>{if(!t){I(C.current,()=>P(null));return}P(e.id)},onPointerDown:t=>{if(t.button!==0)return;let n=document.querySelector(`[data-canvas-root]`)?.getBoundingClientRect(),a=nt({x:t.clientX-(n?.left??0),y:t.clientY-(n?.top??0)},i.getState().viewport),o=n=>{Math.hypot(n.clientX-t.clientX,n.clientY-t.clientY)<gx||(s(),P(null),y.current={at:r,moved:!1,grab:{x:a.x-r.x,y:a.y-r.y}},h(e.id),v(r))},s=()=>{window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,s)},label:`Comment thread, ${e.comments.length} ${e.comments.length===1?`comment`:`comments`}`,testId:`comment-pin`,badge:a?(0,Q.jsx)(Qs,{size:14,stroke:2.25,"data-testid":`comment-pin-resolved`}):(0,Q.jsx)(`span`,{"data-testid":`comment-pin-count`,children:e.comments.length}),card:(0,Q.jsx)(fx,{thread:e,comments:n,onClose:()=>P(null),now:f,composerRef:C,confirmDiscard:e=>I(C.current,e)})},e.id)}),s&&R&&(0,Q.jsx)(yx,{at:R,viewport:t,open:!0,onOpenChange:e=>{e||I(S.current,()=>F(null))},label:`New comment`,testId:`comment-draft-pin`,badge:(0,Q.jsx)(ks,{size:14,stroke:1.75}),card:(0,Q.jsx)(px,{members:n.members,composerRef:S,confirmDiscard:e=>I(S.current,e),onCancel:()=>F(null),onSubmit:async e=>{await n.createThread({body:e,anchor:z??s,mentions:Zb(e,n.members)}),F(null)}})}),(0,Q.jsx)(Vb,{open:w,onOpenChange:e=>{T(e),e||(E.current=null)},title:`Discard this comment?`,description:`You've written something that hasn't been posted yet. Discarding throws it away.`,confirmLabel:`Discard`,destructive:!0,testId:`comment-discard-confirm`,onConfirm:()=>{S.current?.discard(),C.current?.discard(),E.current?.(),E.current=null}}),(0,Q.jsx)(dx,{open:D!==null,onOpenChange:e=>{e||O(null)},onConfirm:()=>{D&&n.remove(D).catch(e=>k(Cl(e,`Couldn't delete that thread. Try again.`)))}})]})}var Sx=[{value:`table`,label:`Table`,Icon:xs},{value:`bar`,label:`Bar`,Icon:hs},{value:`line`,label:`Line`,Icon:Ls},{value:`pie`,label:`Pie`,Icon:Ps}];function Cx(e){let{onPick:t,onCancel:n}=e;return(0,J.useEffect)(()=>{function e(e){e.key===`Escape`?(e.preventDefault(),n()):e.key===`Enter`&&(e.preventDefault(),t(`table`))}return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[n,t]),(0,Q.jsx)(`div`,{className:`absolute inset-0 z-20 flex items-center justify-center`,"data-overlay":!0,onPointerDown:n,children:(0,Q.jsxs)(`div`,{"data-testid":`paste-chooser`,className:`rounded-xl p-2.5 ${dl}`,onPointerDown:e=>e.stopPropagation(),children:[(0,Q.jsx)(`div`,{className:`mb-1.5 px-1 text-[12px] text-[var(--chrome-fg-500)]`,children:`Paste as`}),(0,Q.jsx)(`div`,{className:`flex gap-1.5`,children:Sx.map(e=>(0,Q.jsxs)(`button`,{type:`button`,"data-testid":`paste-as-${e.value}`,onClick:()=>t(e.value),className:`flex h-[72px] w-[72px] flex-col items-center justify-center gap-1.5 rounded-lg bg-[var(--chrome-rest)] text-[var(--chrome-fg-600)] transition-colors hover:bg-blue-600/10 hover:text-blue-600`,children:[(0,Q.jsx)(e.Icon,{size:22,stroke:1.5}),(0,Q.jsx)(`span`,{className:`text-[12px]`,children:e.label})]},e.value))})]})})}function wx(e){let{shape:t,point:n}=e,r=H().measurement,i=t.type===`icon`&&!!t.label,a=i?Cn(t,r):G(t,r),o=i?0:cr(t),s=a.x+a.width/2,c=a.y+a.height/2;return(0,Q.jsxs)(`g`,{style:{pointerEvents:`none`},children:[(0,Q.jsx)(`rect`,{"data-testid":`bind-highlight`,x:a.x-4,y:a.y-4,width:a.width+8,height:a.height+8,transform:o?`rotate(${o} ${s} ${c})`:void 0,rx:10,fill:`none`,stroke:`var(--canvas-selection)`,strokeWidth:2,strokeDasharray:`4 4`}),(0,Q.jsx)(`circle`,{cx:n.x,cy:n.y,r:5,fill:`var(--canvas-selection)`,stroke:`#fff`,strokeWidth:1.5})]})}var Tx=.32;function Ex(e,t){return t?e*Tx:e}function Dx(e,t){return{onPointerEnter:()=>t(e),onPointerLeave:()=>t(null)}}function Ox(e,t){e.key===`Escape`&&(e.stopPropagation(),t(),e.currentTarget.blur())}function kx(e,t){(0,J.useEffect)(()=>{if(!t)return;let n=e.current;if(!n)return;let r=requestAnimationFrame(()=>{n.focus();let e=window.getSelection();if(e){let t=document.createRange();t.selectNodeContents(n),e.removeAllRanges(),e.addRange(t)}});return()=>cancelAnimationFrame(r)},[e,t])}var Ax=`--min-world-stroke`,jx=`--min-world-hit`,Mx=.5;function Nx(e){return`max(${e}px, var(${jx}, 0px))`}function Px(e){let t=Number(e[`stroke-width`]),n=e.stroke;return!Number.isFinite(t)||t<=0||!n||n===`none`?{}:{strokeWidth:`max(${t}px, var(${Ax}, 0px))`}}var Fx=34;function Ix(e){return e.split(/[ ,]+/).reduce((e,t)=>e+(Number(t)||0),0)}function Lx(e){let{node:t,reverse:n,testid:r}=e,i=Ix(String(t.attrs[`stroke-dasharray`]??``));if(!i)return(0,Q.jsx)(Vx,{node:t,testid:r});let a=Math.max(.1,i/Fx);return(0,Q.jsx)(`path`,{...Bx(t.attrs,`ink`),style:Px(t.attrs),"data-testid":r,children:(0,Q.jsx)(`animate`,{attributeName:`stroke-dashoffset`,from:n?0:i,to:n?i:0,dur:`${a.toFixed(2)}s`,repeatCount:`indefinite`})})}function Rx(e){let{d:t,color:n,strokeWidth:r,startHead:i,endHead:a,reverse:o,testid:s}=e,c=(0,J.useRef)(null),[l,u]=(0,J.useState)(null);(0,J.useEffect)(()=>{let e=c.current;if(!e)return;let t=e.getTotalLength(),n=sr(r),o=e=>(e?Sn(n,e,t):0)+r*1.5,s=o(i),l=t-o(a);if(!(l>s+1)){u(null);return}let d=[];for(let t=s;t<l;t+=6){let n=e.getPointAtLength(t);d.push(`${n.x.toFixed(1)} ${n.y.toFixed(1)}`)}let f=e.getPointAtLength(l);d.push(`${f.x.toFixed(1)} ${f.y.toFixed(1)}`),u(`M ${d.join(` L `)}`)},[t,r,i,a]);let d=Math.max(14,r*5),f=d+.01,p=Math.max(.1,f/Fx);return(0,Q.jsxs)(`g`,{style:{pointerEvents:`none`},children:[(0,Q.jsx)(`path`,{ref:c,d:t,fill:`none`,stroke:`none`}),l&&(0,Q.jsx)(`path`,{"data-testid":s,d:l,fill:`none`,stroke:n,strokeWidth:r*2.2,strokeLinecap:`round`,strokeDasharray:`0.01 ${d}`,children:(0,Q.jsx)(`animate`,{attributeName:`stroke-dashoffset`,from:o?0:f,to:o?f:0,dur:`${p.toFixed(2)}s`,repeatCount:`indefinite`})})]})}var zx={"fill-opacity":`fillOpacity`,"stroke-width":`strokeWidth`,"stroke-opacity":`strokeOpacity`,"stroke-dasharray":`strokeDasharray`,"stroke-linecap":`strokeLinecap`,"stroke-linejoin":`strokeLinejoin`};function Bx(e,t=`keep`,n){let r={};for(let[i,a]of Object.entries(e))r[zx[i]??i]=typeof a==`string`?Ye(i,a,t,vt,dn,n):a;return r}function Vx(e){let{node:t,testid:n,fillMode:r,tint:i}=e,a=t.tag;return(0,Q.jsx)(a,{"data-testid":n,...Bx(t.attrs,r,i),style:{pointerEvents:`none`,...Px(t.attrs)}})}function Hx(e){let{shape:t,interactive:n,selected:r,erasing:i,onPointerDown:a,onBeginEdit:o,onHover:s}=e;xy(`shape:${t.id}`);let c=G(t),l=n&&(!Nn(t)||!!r),u=(0,J.useMemo)(()=>Eo(t),[t]),d=(0,J.useMemo)(()=>{let e=Lr(t);return e?cn(e):void 0},[t]);return(0,Q.jsxs)(`g`,{"data-shape-id":t.id,"data-shape-kind":t.kind,"data-testid":`node`,transform:`translate(${c.x} ${c.y}) rotate(${t.rotation??0} ${c.width/2} ${c.height/2})`,opacity:Ex(t.opacity,i),children:[u.shadow&&(0,Q.jsx)(Vx,{node:u.shadow,testid:`node-shadow`}),u.fill&&(0,Q.jsx)(Vx,{node:u.fill,testid:`node-fill`,fillMode:t.fill===`#ffffff`?`paper`:`keep`,tint:d}),(0,Q.jsx)(`path`,{"data-testid":`node-hit`,d:u.fillPath,fill:`transparent`,stroke:`none`,style:{pointerEvents:l?`all`:`none`},onPointerDown:e=>a(t.id,e),onDoubleClick:()=>n&&o(t.id),...Dx(t.id,s)}),u.strokes.map((e,t)=>(0,Q.jsx)(Vx,{node:e,testid:`node-stroke`,tint:d},t)),(0,Q.jsx)(`path`,{"data-testid":`node-border-hit`,d:u.hitPath,fill:`none`,stroke:`transparent`,strokeWidth:Math.max(16,t.strokeWidth+12),style:{pointerEvents:n?`stroke`:`none`,strokeWidth:Nx(Math.max(16,t.strokeWidth+12))},onPointerDown:e=>a(t.id,e),onDoubleClick:()=>n&&o(t.id),...Dx(t.id,s)})]})}var Ux=(0,J.memo)(Hx);function Wx(e){let{shape:t,interactive:n,erasing:r,onPointerDown:i,onBeginEdit:a,onHover:o}=e,s=G(t),c=Po(t);return(0,Q.jsxs)(`g`,{"data-shape-id":t.id,"data-testid":`sticky`,transform:`translate(${s.x} ${s.y}) rotate(${t.rotation??0} ${s.width/2} ${s.height/2})`,opacity:Ex(t.opacity,r),children:[(0,Q.jsx)(Vx,{node:c.shadow}),(0,Q.jsx)(`rect`,{"data-testid":`sticky-fill`,...c.card.attrs,style:{pointerEvents:n?`all`:`none`},onPointerDown:e=>i(t.id,e),onDoubleClick:()=>n&&a(t.id),...Dx(t.id,o)})]})}var Gx=(0,J.memo)(Wx),Kx=14;function qx(e){let{shape:t,interactive:n,erasing:r,onPointerDown:i,onBeginEdit:a,onHover:o}=e,s=G(t),c=cr(t),l=s.x+s.width/2,u=s.y+s.height/2,d=(0,J.useMemo)(()=>Lo(t),[t]);return(0,Q.jsxs)(`g`,{"data-shape-id":t.id,"data-testid":`figure`,transform:c?`rotate(${c} ${l} ${u})`:void 0,opacity:Ex(t.opacity,r),children:[(0,Q.jsxs)(`g`,{style:{pointerEvents:`none`},children:[(0,Q.jsx)(Vx,{node:d.outline,fillMode:`paper`}),d.chrome.map((e,t)=>(0,Q.jsx)(Vx,{node:e},t))]}),(0,Q.jsx)(`rect`,{"data-testid":`figure-hit`,x:s.x,y:s.y,width:s.width,height:s.height,rx:10,fill:`none`,stroke:`transparent`,strokeWidth:Kx,style:{pointerEvents:n?`stroke`:`none`,strokeWidth:Nx(Kx)},onPointerDown:e=>i(t.id,e),onDoubleClick:()=>n&&a(t.id),...Dx(t.id,o)}),ns(t.kind)&&(0,Q.jsxs)(`g`,{style:{pointerEvents:n?`all`:`none`},children:[(0,Q.jsx)(`rect`,{"data-testid":`lanes-gutter-hit`,x:s.x,y:s.y,width:is(t.kind)?s.width:30,height:is(t.kind)?30:s.height,fill:`transparent`,onPointerDown:e=>i(t.id,e),onDoubleClick:()=>n&&a(t.id),...Dx(t.id,o)}),Xo(t.lanes?.length??0,is(t.kind)?s.width:s.height,t.laneSizes).slice(1,-1).map((e,r)=>is(t.kind)?(0,Q.jsx)(`rect`,{x:s.x+e-6,y:s.y,width:12,height:s.height,fill:`transparent`,onPointerDown:e=>i(t.id,e),onDoubleClick:()=>n&&a(t.id),...Dx(t.id,o)},r):(0,Q.jsx)(`rect`,{x:s.x,y:s.y+e-6,width:s.width,height:12,fill:`transparent`,onPointerDown:e=>i(t.id,e),onDoubleClick:()=>n&&a(t.id),...Dx(t.id,o)},r))]})]})}var Jx=(0,J.memo)(qx);function Yx(e){let{shape:t,path:n,kind:r}=e,i=(0,J.useMemo)(()=>jo(t),[t]),a=t.startArrow&&!t.endArrow;return(0,Q.jsxs)(Q.Fragment,{children:[i.strokes.map((e,n)=>t.flow&&t.dash!==`solid`?(0,Q.jsx)(Lx,{node:e,reverse:a,testid:`${r}-flow`},n):(0,Q.jsx)(Vx,{node:e,testid:`${r}-stroke`},n)),t.flow&&t.dash===`solid`&&(0,Q.jsx)(Rx,{d:n,color:vt(t.color),strokeWidth:t.strokeWidth,startHead:t.startArrow?t.startHead??`arrow`:null,endHead:t.endArrow?t.endHead??`arrow`:null,reverse:a,testid:`${r}-flow`}),i.heads.map((e,t)=>(0,Q.jsx)(Vx,{node:e,fillMode:`ink`,testid:`${r}-head`},`head-${t}`))]})}function Xx(e){let{shape:t,interactive:n,erasing:r,onPointerDown:i,onBeginEdit:a,onHover:o}=e,s=on(t);return(0,Q.jsxs)(`g`,{"data-shape-id":t.id,"data-testid":`arrow`,opacity:Ex(t.opacity,r),onPointerDown:e=>i(t.id,e),onDoubleClick:e=>{n&&(e.stopPropagation(),a(t.id))},...Dx(t.id,o),children:[(0,Q.jsx)(`path`,{"data-testid":`arrow-path`,d:s,fill:`none`,stroke:`transparent`,strokeWidth:16,style:{pointerEvents:n?`stroke`:`none`,strokeWidth:Nx(16)}}),(0,Q.jsx)(Yx,{shape:t,path:s,kind:`arrow`})]})}var Zx=(0,J.memo)(Xx);function Qx(e){let{shape:t,interactive:n,cropping:r,erasing:i,onPointerDown:a,onBeginCrop:o,onHover:s}=e,c=G(t),l=c.x+c.width/2,u=c.y+c.height/2,d=Et(c,t.crop),f=_t(t.corner,c),p=`imgclip-${t.id}`,m=t.flipX||t.flipY,h=`rotate(${t.rotation??0} ${l} ${u})`+(m?` translate(${l} ${u}) scale(${t.flipX?-1:1} ${t.flipY?-1:1}) translate(${-l} ${-u})`:``);return r?(0,Q.jsxs)(`g`,{transform:h,children:[(0,Q.jsx)(`image`,{href:t.src,x:d.x,y:d.y,width:d.width,height:d.height,preserveAspectRatio:`none`,opacity:.4,style:{pointerEvents:`none`}}),(0,Q.jsx)(`clipPath`,{id:p,children:(0,Q.jsx)(`rect`,{x:c.x,y:c.y,width:c.width,height:c.height,rx:f})}),(0,Q.jsx)(`image`,{href:t.src,x:d.x,y:d.y,width:d.width,height:d.height,preserveAspectRatio:`none`,clipPath:`url(#${p})`,style:{pointerEvents:`none`}})]}):(0,Q.jsxs)(`g`,{"data-shape-id":t.id,"data-testid":`image`,transform:h,opacity:Ex(t.opacity,i),children:[(0,Q.jsx)(`clipPath`,{id:p,children:(0,Q.jsx)(`rect`,{x:c.x,y:c.y,width:c.width,height:c.height,rx:f})}),(0,Q.jsx)(`image`,{"data-testid":`image-hit`,href:t.src,x:d.x,y:d.y,width:d.width,height:d.height,preserveAspectRatio:`none`,clipPath:`url(#${p})`,style:{pointerEvents:n?`all`:`none`},onPointerDown:e=>a(t.id,e),onDoubleClick:()=>n&&o(t.id),...Dx(t.id,s)})]})}var $x=(0,J.memo)(Qx);function eS(e){let{shape:t,interactive:n,erasing:r,onPointerDown:i,onHover:a}=e,o=(0,J.useMemo)(()=>wo(t),[t]);return(0,Q.jsx)(`path`,{"data-shape-id":t.id,"data-testid":`draw`,...Bx(o.attrs,`ink`),opacity:Ex(t.opacity,r),"data-highlighter":t.highlighter?``:void 0,style:{pointerEvents:n?`all`:`none`},onPointerDown:e=>i(t.id,e),...Dx(t.id,a)})}var tS=(0,J.memo)(eS);function nS(e){let{shape:t,interactive:n,erasing:r,onPointerDown:i,onBeginVertexEdit:a,onHover:o}=e,s=Bo(t.points,t.smooth);return(0,Q.jsx)(`path`,{"data-shape-id":t.id,"data-testid":`polygon`,d:s,fill:t.fill,stroke:t.color,strokeWidth:t.strokeWidth,opacity:Ex(t.opacity,r),style:{pointerEvents:n?`all`:`none`},onPointerDown:e=>i(t.id,e),onDoubleClick:()=>n&&a(t.id),...Dx(t.id,o)})}var rS=(0,J.memo)(nS);function iS(e){let{shape:t,interactive:n,erasing:r,onPointerDown:i,onBeginEdit:a,onHover:o}=e,s=pt(t.points);return(0,Q.jsxs)(`g`,{"data-shape-id":t.id,"data-testid":`line`,opacity:Ex(t.opacity,r),onPointerDown:e=>i(t.id,e),onDoubleClick:e=>{n&&(e.stopPropagation(),a(t.id))},...Dx(t.id,o),children:[(0,Q.jsx)(`path`,{"data-testid":`line-path`,d:s,fill:`none`,stroke:`transparent`,strokeWidth:16,strokeLinejoin:`round`,strokeLinecap:`round`,style:{pointerEvents:n?`stroke`:`none`,strokeWidth:Nx(16)}}),(0,Q.jsx)(Yx,{shape:t,path:s,kind:`line`})]})}var aS=(0,J.memo)(iS);function oS(e){let{shape:t,interactive:n,erasing:r,onPointerDown:i,onBeginEdit:a,onHover:o}=e,s=G(t),c=s.x+s.width/2,l=s.y+s.height/2,u=t.flipX||t.flipY,d=`rotate(${t.rotation??0} ${c} ${l})`+(u?` translate(${c} ${l}) scale(${t.flipX?-1:1} ${t.flipY?-1:1}) translate(${-c} ${-l})`:``);return(0,Q.jsxs)(`g`,{"data-shape-id":t.id,"data-testid":`icon`,transform:d,opacity:Ex(t.opacity,r),children:[(0,Q.jsx)(`rect`,{"data-testid":`icon-hit`,x:s.x,y:s.y,width:s.width,height:s.height,fill:`transparent`,style:{pointerEvents:n?`all`:`none`},onPointerDown:e=>i(t.id,e),onDoubleClick:()=>n&&a(t.id),...Dx(t.id,o)}),Gi(t.source)?Wi(t.source)?(0,Q.jsx)(sS,{shape:t,bounds:s}):(0,Q.jsx)(`image`,{href:Ki().assetIconUrl(t.source,t.name),x:s.x,y:s.y,width:s.width,height:s.height,style:{pointerEvents:`none`}}):(0,Q.jsx)(lS,{shape:t,bounds:s})]})}function sS(e){let{shape:t,bounds:n}=e,r=Ol(t.source,t.name),i=(0,J.useMemo)(()=>({__html:r?.inner??``}),[r?.inner]);if(!r||!(n.width>0)||!(n.height>0))return null;let a=cS(r.viewBox,n),o=Ut(t.strokeWidth,n.width)/a,s=`mono-erode-${t.id}`;return(0,Q.jsxs)(`svg`,{x:n.x,y:n.y,width:n.width,height:n.height,viewBox:r.viewBox,fill:`currentColor`,overflow:`visible`,stroke:o>0?`currentColor`:`none`,strokeWidth:o>0?o:void 0,strokeLinejoin:`round`,strokeLinecap:`round`,style:{color:vt(t.color),pointerEvents:`none`},children:[o<0&&(0,Q.jsx)(`filter`,{id:s,children:(0,Q.jsx)(`feMorphology`,{operator:`erode`,radius:-o/4})}),(0,Q.jsx)(`g`,{filter:o<0?`url(#${s})`:void 0,dangerouslySetInnerHTML:i})]})}function cS(e,t){let n=e.trim().split(/[\s,]+/).map(Number),[,,r,i]=n;return n.length!==4||!(r>0)||!(i>0)?1:Math.min(t.width/r,t.height/i)}function lS(e){let{shape:t,bounds:n}=e,r=El(t.name);return r?(0,Q.jsx)(kl,{node:r,at:{x:n.x,y:n.y},size:n.width,stroke:vt(t.color),strokeWidth:ct(t.strokeWidth,n.width),style:{pointerEvents:`none`}}):null}var uS=(0,J.memo)(oS);function dS(e){let{prim:t}=e;return t.kind===`rect`?(0,Q.jsx)(`rect`,{"data-testid":t.testId,x:t.x,y:t.y,width:t.width,height:Math.max(0,t.height),rx:t.rx,fill:fr(t.fill),style:{pointerEvents:`none`}}):t.kind===`line`?(0,Q.jsx)(`line`,{"data-testid":t.testId,x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:fr(t.stroke),strokeWidth:t.width,style:{pointerEvents:`none`}}):t.kind===`polyline`?(0,Q.jsx)(`polyline`,{"data-testid":t.testId,points:t.points.map(e=>`${e.x},${e.y}`).join(` `),fill:`none`,stroke:fr(t.stroke),strokeWidth:t.width,strokeLinecap:`round`,strokeLinejoin:`round`,style:{pointerEvents:`none`}}):t.kind===`path`?(0,Q.jsx)(`path`,{"data-testid":t.testId,d:t.d,fill:Jn(t.fill)??`none`,fillOpacity:t.fillOpacity,stroke:Jn(t.stroke)??`none`,strokeWidth:t.width,style:{pointerEvents:`none`}}):t.kind===`circle`?(0,Q.jsx)(`circle`,{"data-testid":t.testId,cx:t.cx,cy:t.cy,r:t.r,fill:fr(t.fill),stroke:Jn(t.stroke),strokeWidth:t.width,style:{pointerEvents:`none`}}):(0,Q.jsx)(`text`,{"data-testid":t.testId,x:t.x,y:t.y,fontFamily:t.family,fontSize:t.size,fill:fr(t.color),textAnchor:t.anchor,dominantBaseline:t.baseline,transform:t.rotate?`rotate(${t.rotate} ${t.x} ${t.y})`:void 0,style:{pointerEvents:`none`},children:t.text})}function fS(e){let{shape:t,mark:n}=e,r=t.fontSize,i=n.label.split(`
16
+ `),a=r*1.3,o=Math.max(...i.map(e=>e.length))*r*.58+12,s=i.length*a+12,c=n.tipX-o/2;c=Math.max(t.x+2,Math.min(c,t.x+t.width-o-2));let l=n.tipY-8-s;return l<t.y&&(l=n.tipY+10),(0,Q.jsxs)(`g`,{"data-testid":`chart-tooltip`,style:{pointerEvents:`none`},children:[(0,Q.jsx)(`rect`,{x:c,y:l,width:o,height:s,rx:6,fill:`#1e1e1e`,opacity:.92}),i.map((e,n)=>(0,Q.jsx)(`text`,{x:c+6,y:l+6+n*a,fontFamily:t.fontFamily,fontSize:r,fill:`#ffffff`,dominantBaseline:`hanging`,children:e},n))]})}function pS(e){let{shape:t,interactive:n,erasing:r,onPointerDown:i,onBeginEdit:a,onHover:o}=e,s=G(t),c=cr(t),l=s.x+s.width/2,u=s.y+s.height/2,d=(0,J.useMemo)(()=>zo(t),[t]),[f,p]=(0,J.useState)(null),m=f==null?null:d.marks[f];return(0,Q.jsxs)(`g`,{"data-shape-id":t.id,"data-testid":`chart`,transform:c?`rotate(${c} ${l} ${u})`:void 0,opacity:Ex(t.opacity,r),children:[(0,Q.jsx)(`rect`,{x:s.x,y:s.y,width:s.width,height:s.height,rx:4,fill:`var(--paper-bg)`,style:{pointerEvents:`none`}}),d.prims.map((e,t)=>(0,Q.jsx)(dS,{prim:e},t)),(0,Q.jsx)(`rect`,{"data-testid":`chart-hit`,x:s.x,y:s.y,width:s.width,height:s.height,fill:`transparent`,style:{pointerEvents:n?`all`:`none`},onPointerDown:e=>i(t.id,e),onDoubleClick:()=>n&&a?.(t.id),...Dx(t.id,o)}),n&&d.marks.map((e,n)=>(0,Q.jsx)(`rect`,{x:e.x,y:e.y,width:Math.max(0,e.width),height:Math.max(0,e.height),fill:`transparent`,style:{pointerEvents:`all`},onPointerDown:e=>i(t.id,e),onDoubleClick:()=>a?.(t.id),onPointerEnter:()=>{p(n),o(t.id)},onPointerLeave:()=>{p(e=>e===n?null:e),o(null)}},`mark-${n}`)),m&&(0,Q.jsx)(fS,{shape:t,mark:m})]})}var mS=(0,J.memo)(pS);function hS(e,t,n){return t.kind===`entity`?n===`body`?e.testId===`entity-row`||e.testId===`entity-divider`:e.kind===`text`&&e.testId===`entity-title`:t.kind===`fragment`?e.testId===`fragment-tab`||e.testId===`fragment-label`:e.kind===`text`?t.kind===`modal`?n===`primary`||n===`secondary`?e.testId===`modal-${n}`:e.testId===(n===`body`?`card-body`:`card-title`):t.kind!==`card`||e.testId===(n===`body`?`card-body`:`card-title`):!1}function gS(e,t){if(!iu(e.kind))return`label`;let n=t.currentTarget.getScreenCTM();if(!n)return`label`;let r=new DOMPoint(t.clientX,t.clientY).matrixTransform(n.inverse()),i=G(e);if(e.kind===`modal`){let e=Ei(i);if(e){let t=e=>r.x>=e.x&&r.x<=e.x+e.width&&r.y>=e.y&&r.y<=e.y+e.height;if(t(e.primary))return`primary`;if(t(e.secondary))return`secondary`}}let a=e.kind===`card`?yi(e).body:ru(e,`body`);return r.y>=a.y?`body`:`label`}var _S=8;function vS(e){let{shape:t,interactive:n,onPointerDown:r,onBeginEdit:i,onHover:a}=e,o=Oi(),s=G(t),c=$t(t,o.text),l=Math.min(_S,s.width/2,s.height/2),u={pointerEvents:n?`all`:`none`},d=e=>r(t.id,e),f=Dx(t.id,a),p=(e,t,n,r,i)=>(0,Q.jsx)(`rect`,{x:e,y:t,width:n,height:r,fill:`transparent`,style:u,onPointerDown:d,...f},i);return(0,Q.jsxs)(Q.Fragment,{children:[p(s.x,s.y,s.width,l,`top`),p(s.x,s.y+s.height-l,s.width,l,`bottom`),p(s.x,s.y,l,s.height,`left`),p(s.x+s.width-l,s.y,l,s.height,`right`),(0,Q.jsx)(`rect`,{"data-testid":`control-hit`,x:s.x,y:s.y,width:c.width,height:c.height,fill:`transparent`,style:u,onPointerDown:d,onDoubleClick:()=>{n&&i(t.id,`label`)},...f})]})}function yS(e){let{shape:t,interactive:n,editingField:r,erasing:i,onPointerDown:a,onBeginEdit:o,onHover:s}=e,c=Oi(),l=G(t),u=cr(t),d=l.x+l.width/2,f=l.y+l.height/2,p=(0,J.useMemo)(()=>vi(t,c.text),[t,c]).filter(e=>t.kind===`lifeline`&&e.kind===`text`&&e.testId===`lifeline-name`?!1:!r||!hS(e,t,r));return(0,Q.jsxs)(`g`,{"data-shape-id":t.id,"data-testid":`control`,"data-control-kind":t.kind,transform:u?`rotate(${u} ${d} ${f})`:void 0,opacity:Ex(t.opacity,i),children:[p.map((e,t)=>(0,Q.jsx)(dS,{prim:e},t)),t.kind===`fragment`?(0,Q.jsx)(vS,{shape:t,interactive:n,onPointerDown:a,onBeginEdit:o,onHover:s}):(0,Q.jsx)(`rect`,{"data-testid":`control-hit`,x:l.x,y:l.y,width:l.width,height:l.height,fill:`transparent`,style:{pointerEvents:n?`all`:`none`},onPointerDown:e=>a(t.id,e),onDoubleClick:e=>{n&&hi(t.kind)&&o(t.id,gS(t,e))},...Dx(t.id,s)})]})}var bS=(0,J.memo)(yS);function xS(e){let{source:t,name:n,size:r}=e,i=Ol(t,n),a=(0,J.useMemo)(()=>({__html:i?.inner??``}),[i?.inner]);return i?(0,Q.jsx)(`svg`,{width:r,height:r,viewBox:i.viewBox,fill:`currentColor`,style:{display:`block`},dangerouslySetInnerHTML:a}):(0,Q.jsx)(`span`,{style:{width:r,height:r}})}function SS(e){let{name:t,source:n,size:r=20}=e,i=El(Gi(n)?``:t);return Gi(n)?Wi(n)?(0,Q.jsx)(xS,{source:n,name:t,size:r}):(0,Q.jsx)(`img`,{src:Ki().assetIconUrl(n,t),alt:t,draggable:!1,style:{width:r,height:r}}):i?(0,Q.jsx)(Dl,{node:i,size:r}):(0,Q.jsx)(`span`,{style:{width:r,height:r}})}var CS=`[data-caret-safe]`;function wS(e){return e instanceof Element&&e.closest(CS)!==null}function TS(e){return/[A-Za-z0-9]/.test(e)}function ES(e,t,n){if(t<2)return null;let r=(n,r,i,a)=>{let o=n+r,s=t-r;if(s<=o)return null;let c=e.slice(o,s);return c.trim()===``||a&&(TS(n>0?e[n-1]:``)||/\s/.test(c[0])||/\s/.test(c[c.length-1]))?null:{openStart:n,contentStart:o,contentEnd:s,tag:i}};if(n==="`"){let n=e.lastIndexOf("`",t-2);return n<0?null:r(n,1,`code`,!1)}if(n===`=`){if(e[t-2]!==`=`)return null;let n=e.lastIndexOf(`==`,t-3);return n<0?null:r(n,2,`mark`,!1)}if(n===`~`){if(e[t-2]===`~`){let n=e.lastIndexOf(`~~`,t-3);return n<0?null:r(n,2,`s`,!1)}let n=e.lastIndexOf(`~`,t-2);return n<0||e[n-1]===`~`?null:r(n,1,`s`,!1)}if(n===`*`||n===`_`){if(e[t-2]===n){let i=e.lastIndexOf(n+n,t-3);return i<0?null:r(i,2,`strong`,!1)}let i=e.lastIndexOf(n,t-2);return i<0||e[i-1]===n?null:r(i,1,`em`,!0)}return null}function DS(e){let t=window.getSelection()?.anchorNode??null;for(;t&&t!==e;){if(t.nodeType===1){let e=t.tagName;if(e===`UL`||e===`OL`)return t}t=t.parentNode}return null}function OS(e){let t=DS(e);if(t&&t.hasAttribute(`data-checklist`)){t.removeAttribute(`data-checklist`),t.querySelectorAll(`li[data-checked]`).forEach(e=>{e.removeAttribute(`data-checked`)});return}document.execCommand(`insertUnorderedList`)}function kS(e){let t=DS(e);if(t&&t.hasAttribute(`data-checklist`)){document.execCommand(`insertUnorderedList`);return}(!t||t.tagName===`OL`)&&document.execCommand(`insertUnorderedList`),AS(e)}function AS(e){let t=DS(e);t&&t.tagName===`UL`&&t.setAttribute(`data-checklist`,`true`)}function jS(e,t){let n=[...e.querySelectorAll(`ul, ol`)].filter(e=>!e.parentElement?.closest(`ul, ol`)&&t.intersectsNode(e));if(n.length===0)return null;let r=[],i=t.cloneRange();for(let e of n){let n=i.cloneRange();n.setEndBefore(e),n.collapsed||r.push(n);for(let n of e.querySelectorAll(`:scope > li`)){if(!t.intersectsNode(n))continue;let e=document.createRange();e.selectNodeContents(n),n.contains(t.startContainer)&&e.setStart(t.startContainer,t.startOffset),n.contains(t.endContainer)&&e.setEnd(t.endContainer,t.endOffset),e.collapsed||r.push(e)}i=i.cloneRange(),i.setStartAfter(e)}return i.collapsed||r.push(i),r}function MS(e){let t=window.getSelection()?.anchorNode??null;for(;t&&t!==e;){if(t.nodeType===1&&t.tagName===`LI`)return t;t=t.parentNode}return null}function NS(e){let t=window.getSelection(),n=t&&t.rangeCount>0?{node:t.anchorNode,offset:t.anchorOffset}:null,r=t&&t.rangeCount>0?{node:t.focusNode,offset:t.focusOffset}:null;e(),t&&n?.node&&r?.node&&t.setBaseAndExtent(n.node,n.offset,r.node,r.offset)}function PS(e){let t=MS(e);if(!t)return!1;let n=t.previousElementSibling,r=t.parentElement;return!n||n.tagName!==`LI`||!r||NS(()=>{let e=n.lastElementChild;(e&&e.tagName===r.tagName&&e.hasAttribute(`data-checklist`)===r.hasAttribute(`data-checklist`)?e:n.appendChild(r.cloneNode(!1))).appendChild(t)}),!0}function FS(e){let t=MS(e);if(!t)return!1;let n=t.parentElement,r=n?.parentElement;return!n||!r||r.tagName!==`LI`||NS(()=>{if(t.nextElementSibling){let e=n.cloneNode(!1);for(;t.nextElementSibling;)e.appendChild(t.nextElementSibling);t.appendChild(e)}r.after(t),n.firstElementChild||n.remove()}),!0}function IS(e){let t=e;for(;t&&t!==document.body;){if(t.nodeType===1&&t.hasAttribute(`data-rich`))return t;t=t.parentNode}return null}function LS(){let e=window.getSelection();if(!e||e.rangeCount===0||e.isCollapsed)return null;let t=IS(e.anchorNode);return!t||!t.isContentEditable||!t.contains(e.focusNode)?null:{sel:e,range:e.getRangeAt(0),editable:t}}function RS(){let e=window.getSelection();if(!e||e.rangeCount===0||!e.isCollapsed)return null;let t=IS(e.anchorNode);return!t||!t.isContentEditable?null:{sel:e,range:e.getRangeAt(0),editable:t}}function zS(e,t){let n=LS();return{live:n,editable:n?.editable??e,range:n?.range??t}}function BS(e,t){if(e.focus(),!t)return;let n=window.getSelection();n&&(n.removeAllRanges(),n.addRange(t.cloneRange()))}function VS(e,t,n){let r=t;for(;r&&r!==e;){if(r.nodeType===1&&r.tagName.toLowerCase()===n)return r;r=r.parentNode}return null}function HS(e){let t=window.getSelection();if(!t)return;let n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)}function US(e,t,n){if(e.collapsed)return null;let r=document.createElement(t);n?.(r);try{r.appendChild(e.extractContents()),e.insertNode(r)}catch{return null}return r}function WS(e){let t=e.parentNode;if(t){for(;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}}function GS(e){if(!e.parentNode)return;let t=e.firstChild,n=e.lastChild;WS(e);let r=window.getSelection();if(t&&n&&r){let e=document.createRange();e.setStartBefore(t),e.setEndAfter(n),r.removeAllRanges(),r.addRange(e)}}function KS(e){let t=window.getSelection();if(!t||t.rangeCount===0||!e.contains(t.focusNode))return null;let n=document.createRange();return n.selectNodeContents(e),n.setEnd(t.focusNode,t.focusOffset),n.toString().length}function qS(e,t){let n=window.getSelection();if(!n)return;let r=t,i=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(let e=i.nextNode();e;e=i.nextNode()){let t=(e.nodeValue??``).length;if(r<=t){n.collapse(e,r);return}r-=t}n.collapse(e,e.childNodes.length)}function JS(e,t){let n=window.getSelection();if(!n||!n.isCollapsed||n.rangeCount===0)return!1;let r=n.anchorNode;if(!r||r.nodeType!==3||!e.contains(r))return!1;let i=r.nodeValue??``,a=n.anchorOffset,o=ES(i,a,t);if(!o)return!1;let s=e.ownerDocument,c=r.parentNode;if(!c)return!1;let l=i.slice(0,o.openStart),u=i.slice(o.contentStart,o.contentEnd),d=i.slice(a),f=s.createElement(o.tag);f.textContent=u;let p=s.createTextNode(`\u200B${d}`);c.insertBefore(p,r.nextSibling),c.insertBefore(f,p),l?r.nodeValue=l:c.removeChild(r);let m=s.createRange();return m.setStart(p,1),m.collapse(!0),n.removeAllRanges(),n.addRange(m),!0}function YS(e,t){let n=US(e,`a`,e=>e.setAttribute(`href`,t));return n?.querySelectorAll(`a`).forEach(WS),n}function XS(e,t,n){let r=VS(e,t.startContainer,`a`),i=VS(e,t.endContainer,`a`);if(r&&r===i)return r.setAttribute(`href`,n),r;let a=jS(e,t);if(!a)return YS(t,n);let o=null;for(let e of a)o=YS(e,n)??o;return o}function ZS(e,t,n){let r=e.startContainer.ownerDocument??document,i=r.createElement(`a`);i.setAttribute(`href`,t),i.textContent=n;let a=r.createTextNode(`​`);return e.insertNode(a),e.insertNode(i),a}function QS(e,t,n){let r=e.parentNode;if(!r)return;let i=document.createRange();i.selectNodeContents(e),i.setEnd(t.startContainer,t.startOffset);let a=document.createRange();a.selectNodeContents(e),a.setStart(t.endContainer,t.endOffset);let o=i.extractContents(),s=a.extractContents();if(o.childNodes.length>0){let t=document.createElement(n);t.appendChild(o),r.insertBefore(t,e)}if(s.childNodes.length>0){let t=document.createElement(n);t.appendChild(s),r.insertBefore(t,e.nextSibling)}GS(e)}function $S(e,t,n){if(t.collapsed)return null;let r=document.createElement(`span`),i=document.createElement(`span`),a=t.cloneRange();a.collapse(!1),a.insertNode(i);let o=t.cloneRange();o.collapse(!0),o.insertNode(r);let s=document.createRange();s.setStartAfter(r),s.setEndBefore(i);let c=s.extractContents();c.querySelectorAll(n).forEach(e=>{let t=e.parentNode;if(t){for(;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}}),s.insertNode(c);let l=document.createRange();return l.setStartAfter(r),l.setEndBefore(i),r.remove(),i.remove(),e.normalize(),l}function eC(e){e.querySelectorAll(`mark, em, i, strong, b, u, s, code, a, span`).forEach(e=>{e.textContent===``&&e.remove()}),e.normalize()}function tC(e,t,n){let r=n.split(/\r?\n/);for(;r.length>1&&r[r.length-1].trim()===``;)r.pop();let i=VS(e,t.startContainer,`li`),a=[...e.querySelectorAll(`li`)].filter(e=>t.intersectsNode(e));t.deleteContents(),i?.isConnected&&!i.contains(t.startContainer)&&(t.selectNodeContents(i),t.collapse(!1));let o=document.createTextNode(r[0]??``);t.insertNode(o);let s=o;for(let e of r.slice(1)){if(i?.isConnected){let t=document.createElement(`li`);t.textContent=e,(s===o?i:s).after(t),s=t;continue}let t=document.createElement(`br`),n=document.createTextNode(e);s.after(t),t.after(n),s=n}let c=i?.isConnected?i:null;for(let e of a)if(!(e===c||!e.isConnected||e.contains(s))&&e.textContent?.trim()===``){let t=e.parentElement;e.remove(),t&&(t.tagName===`UL`||t.tagName===`OL`)&&!t.querySelector(`li`)&&t.remove()}return eC(e),s}function nC(e,t,n){for(let r of e.querySelectorAll(n))if(t.intersectsNode(r))return!0;return!1}function rC(e,t){let n=window.getSelection();if(!n||n.rangeCount===0||!n.isCollapsed)return;let r=n.getRangeAt(0);if(!e.contains(r.startContainer))return;let i=e.ownerDocument,a=i.createTextNode(`​`),o=VS(e,r.startContainer,t);if(!o){let e=i.createElement(t);e.appendChild(a),r.insertNode(e),n.collapse(a,1);return}let s=i.createRange();s.selectNodeContents(o),s.setStart(r.startContainer,r.startOffset);let c=s.extractContents(),l=a;for(let e=r.startContainer.nodeType===3?r.startContainer.parentNode:r.startContainer;e&&e!==o;e=e.parentNode){let t=e.cloneNode(!1);t.appendChild(l),l=t}if(o.after(l),(c.textContent??``).replace(/\u200B/g,``)!==``){let e=o.cloneNode(!1);e.appendChild(c),l.after(e)}o.textContent===``&&o.remove(),n.collapse(a,1)}function iC(e,t){let n=window.getSelection();if(!n||n.rangeCount===0)return;let r=n.getRangeAt(0);if(r.collapsed)return;let i=VS(e,r.startContainer,t),a=VS(e,r.endContainer,t),o=!!(i||a||nC(e,r,t)),s=jS(e,r)??[r],c=[];for(let n of s){if(o){let r=VS(e,n.startContainer,t);if(r&&r===VS(e,n.endContainer,t)){QS(r,n,t);continue}let i=$S(e,n,t);i&&c.push(i);continue}let r=US(n,t);if(r){let e=document.createRange();e.selectNodeContents(r),c.push(e)}}if(c.length===0)return;let l=document.createRange();l.setStart(c[0].startContainer,c[0].startOffset);let u=c[c.length-1];l.setEnd(u.endContainer,u.endOffset),n.removeAllRanges(),n.addRange(l)}var aC=200,oC=1e3;function sC(e){return e===`insertText`||e===`insertCompositionText`?`type`:e===`deleteContentBackward`||e===`deleteContentForward`?`delete`:null}function cC(e,t){let n=[],r=t;for(;r&&r!==e;){let e=r.parentNode;if(!e)return null;n.unshift(Array.prototype.indexOf.call(e.childNodes,r)),r=e}return r===e?n:null}function lC(e,t){let n=e;for(let e of t)n=n?.childNodes[e]??null;return n}function uC(e,t,n){let r=t?cC(e,t):null;return r?{path:r,offset:n}:null}function dC(e){return e.nodeType===3?(e.nodeValue??``).length:e.childNodes.length}function fC(e,t){let n=[],r=[],i=null,a=null;function o(){let t=window.getSelection(),n=t&&t.rangeCount>0&&e.contains(t.anchorNode);return{html:e.innerHTML,anchor:n?uC(e,t.anchorNode,t.anchorOffset):null,focus:n?uC(e,t.focusNode,t.focusOffset):null}}let s=o();function c(e,t,n){return!e||!a||a.kind!==e||n-a.at>oC?!1:!(e===`type`&&/\s$/.test(a.data)&&!/^\s/.test(t))}function l(){let e=i?.kind??null,l=i?.data??``;i=null;let u=o();if(u.html===s.html){s=u;return}let d=performance.now();c(e,l,d)||(n.push(s),n.length>aC&&n.shift()),s=u,r=[],a=e?{kind:e,at:d,data:l}:null,t?.()}let u=new MutationObserver(l);u.observe(e,{childList:!0,subtree:!0,characterData:!0,attributes:!0});function d(){u.takeRecords().length>0&&l()}function f(t){e.innerHTML=t.html,u.takeRecords();let n=window.getSelection();if(!n)return;let r=t=>{let n=t?lC(e,t.path):null;return!n||!t?{node:e,offset:e.childNodes.length}:{node:n,offset:Math.min(t.offset,dC(n))}},i=r(t.anchor),a=r(t.focus??t.anchor);n.setBaseAndExtent(i.node,i.offset,a.node,a.offset)}function p(e,n){d();let r=e.pop();r&&(n.push(s),f(r),s=r,a=null,t?.())}function m(e){if(e.inputType===`historyUndo`||e.inputType===`historyRedo`){e.preventDefault(),e.inputType===`historyUndo`?p(n,r):p(r,n);return}d(),i={kind:sC(e.inputType),data:e.data??``}}return e.addEventListener(`beforeinput`,m),{undo:()=>p(n,r),redo:()=>p(r,n),flush:d,absorb(){u.takeRecords(),s=o()},reset(){u.takeRecords(),n.length=0,r=[],a=null,s=o()},dispose(){u.disconnect(),e.removeEventListener(`beforeinput`,m)}}}function pC(e){let t=e.target;if(!t||typeof t.closest!=`function`)return null;let n=t.closest(`li`);return!n||!n.parentElement?.matches(`ul[data-checklist]`)||e.clientX>=n.getBoundingClientRect().left?null:n}function mC(e){e.hasAttribute(`data-checked`)?e.removeAttribute(`data-checked`):e.setAttribute(`data-checked`,`true`)}var hC=new Set([`BR`,`LI`,`UL`,`OL`,`DIV`,`P`]);function gC(e,t,n){let r=``,i=!1,a=e=>{if(i)return;if(e.nodeType===3){if(e===t){r+=(e.nodeValue??``).slice(0,n),i=!0;return}r+=e.nodeValue??``;return}if(e.nodeType!==1)return;let o=hC.has(e.tagName);o&&(r=``),e.childNodes.forEach(a),o&&!i&&(r=``)};return e.childNodes.forEach(a),r.slice(r.lastIndexOf(`
17
+ `)+1)}function _C(e,t){if(!t||t.tagName!==e.tagName||t.hasAttribute(`data-checklist`)!==e.hasAttribute(`data-checklist`))return!1;let n=e=>(e.textContent??``).replace(/\u200B/g,``)===``,r=r=>{for(let i=r(e);i;i=r(i)){if(i===t)return!0;if(!n(i))return!1}return!1};return r(e=>e.previousSibling)||r(e=>e.nextSibling)}function vC(e){let t=e.parentElement;if(!t)return;let n=t.cloneNode(!1);for(;t.firstElementChild&&t.firstElementChild!==e;)n.appendChild(t.firstElementChild);let r=t.cloneNode(!1);for(let t=e.nextElementSibling;t;){let e=t.nextElementSibling;r.appendChild(t),t=e}n.firstElementChild&&t.before(n),r.firstElementChild&&t.after(r),t.removeAttribute(`data-checklist`),e.removeAttribute(`data-checked`)}function yC(e){let t=e,n=e.previousElementSibling;if(_C(e,n)){for(;e.firstChild;)n.appendChild(e.firstChild);e.remove(),t=n}let r=t.nextElementSibling;if(_C(t,r)){for(;r.firstChild;)t.appendChild(r.firstChild);r.remove()}}function bC(e){if(e.key!==` `)return;let t=window.getSelection();if(!t||!t.isCollapsed||t.rangeCount===0)return;let n=t.anchorNode;if(!n||n.nodeType!==3)return;let r=e.currentTarget,i=MS(r),a=gC(r,n,t.anchorOffset).replace(/\u200B/g,``),o=!i&&a===`1.`,s=!i&&(a===`-`||a===`*`),c=a===`[]`||a===`[ ]`;if(!o&&!s&&!c||t.anchorOffset<a.length||i&&i.parentElement?.hasAttribute(`data-checklist`))return;e.preventDefault();let l=document.createRange();if(l.setStart(n,t.anchorOffset-a.length),l.setEnd(n,t.anchorOffset),t.removeAllRanges(),t.addRange(l),document.execCommand(`delete`),i){kS(r);return}document.execCommand(o?`insertOrderedList`:`insertUnorderedList`),SC(r);let u=MS(r),d=u?.parentElement;if(!u||!d)return;d.hasAttribute(`data-checklist`)!==c&&(u.previousElementSibling||u.nextElementSibling)&&vC(u),c&&AS(r);let f=MS(r)?.parentElement;f&&yC(f)}function xC(e){if(e.key!==`Backspace`)return;let t=window.getSelection();if(!t||!t.isCollapsed||t.rangeCount===0)return;let n=e.currentTarget,r=MS(n);if(!r||r.previousElementSibling)return;let i=r.parentElement;if(!i||i.tagName!==`UL`&&i.tagName!==`OL`)return;let a=document.createRange();if(a.selectNodeContents(r),a.setEnd(t.anchorNode,t.anchorOffset),!(a.toString().replace(/\u200B/g,``).length>0)){if(e.preventDefault(),i.parentElement?.tagName===`LI`){FS(n);return}document.execCommand(i.tagName===`OL`?`insertOrderedList`:`insertUnorderedList`)}}function SC(e){let t=window.getSelection(),n=MS(e);if(!t||t.rangeCount===0||!n)return;let r=[],i=document.createTreeWalker(n,NodeFilter.SHOW_TEXT);for(let e=i.nextNode();e;e=i.nextNode())r.push(e);let a=!1;for(let e of r)(e.nodeValue??``).includes(`​`)&&(e.nodeValue=(e.nodeValue??``).replace(/\u200B/g,``),a=!0),e.nodeValue===``&&e.parentNode?.removeChild(e);if(!a)return;n.firstChild||n.appendChild(document.createElement(`br`));let o=document.createRange(),s=n.lastChild;s&&s.nodeType===3?o.setStart(s,(s.nodeValue??``).length):o.setStart(n,0),o.collapse(!0),t.removeAllRanges(),t.addRange(o)}function CC(e){if(e.key!==`Enter`)return;let t=window.getSelection();if(!t||MS(e.currentTarget))return;e.preventDefault();let n=TC(t,e.currentTarget);if(n){let e=document.createTextNode(`
18
+ ​`);n.parentNode?.insertBefore(e,n.nextSibling);let r=document.createRange();r.setStart(e,e.length),r.collapse(!0),t.removeAllRanges(),t.addRange(r);return}document.execCommand(`insertLineBreak`)}function wC(e){let t=e;for(;t&&t.lastChild;)t=t.lastChild;return t&&t.nodeType===3?t:null}function TC(e,t){let n=e.anchorNode;if(!n||n.nodeType!==3||e.anchorOffset!==(n.nodeValue??``).length)return null;let r=n.parentNode;for(;r&&r!==t;){if(r.nodeType===1){let e=r;if(e.tagName===`SPAN`&&e.style.fontSize)return wC(e)===n?e:null}r=r.parentNode}return null}function EC(e,t,n){if(t.nodeType===3){let e=(t.nodeValue??``).indexOf(`
19
+ `,n);if(e!==-1)return{node:t,offset:e}}let r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);if(t.nodeType===3)r.currentNode=t;else if(n<t.childNodes.length){let e=t.childNodes[n];if(r.currentNode=e,e.nodeType===3){let t=(e.nodeValue??``).indexOf(`
20
+ `);if(t!==-1)return{node:e,offset:t}}}else return{node:e,offset:e.childNodes.length};let i=r.nextNode();for(;i;){let e=(i.nodeValue??``).indexOf(`
21
+ `);if(e!==-1)return{node:i,offset:e};i=r.nextNode()}return{node:e,offset:e.childNodes.length}}var DC=[2,1.5,1.25,1.1];function OC(e){if(e.key!==` `)return!1;let t=window.getSelection();if(!t||!t.isCollapsed||t.rangeCount===0)return!1;let n=t.anchorNode;if(!n||n.nodeType!==3)return!1;let r=e.currentTarget;if(MS(r))return!1;let i=gC(r,n,t.anchorOffset).replace(/\u200B/g,``);if(!/^#+$/.test(i)||t.anchorOffset<i.length)return!1;e.preventDefault();let a=DC[Math.min(i.length,DC.length)-1],o=document.createRange();o.setStart(n,t.anchorOffset-i.length),o.setEnd(n,t.anchorOffset),t.removeAllRanges(),t.addRange(o),document.execCommand(`delete`);let s=parseFloat(getComputedStyle(r).fontSize)||24,c=Math.min(240,Math.round(s*a)),l=document.createElement(`span`);l.style.fontSize=`${c}px`;let u=t.getRangeAt(0),d=EC(r,u.startContainer,u.startOffset),f=document.createRange();f.setStart(u.startContainer,u.startOffset),f.setEnd(d.node,d.offset);let p=document.createRange();if(f.collapsed){let e=document.createTextNode(`​`);l.appendChild(e),f.insertNode(l),p.setStart(e,1)}else l.appendChild(f.extractContents()),f.insertNode(l),p.selectNodeContents(l);return p.collapse(!0),t.removeAllRanges(),t.addRange(p),!0}var kC=/^(?:(?:https?:\/\/|mailto:)\S+|www\.[\w-]+(?:\.[\w-]+)+\S*)$/i;function AC(e,t){if(!e.hasAttribute(`data-rich`))return!1;let n=window.getSelection();if(!n||!n.isCollapsed||n.rangeCount===0)return!1;let r=n.anchorNode;if(!r||r.nodeType!==3||!e.contains(r)||VS(e,r,`a`))return!1;let i=(r.nodeValue??``).slice(0,n.anchorOffset-t),a=/[^\s\u200B]+$/.exec(i);if(!a)return!1;let o=a[0].replace(/[.,;:!?)\]'"]+$/,``),s=kC.test(o)?_n(o):null;if(!s)return!1;let c=document.createRange();c.setStart(r,a.index),c.setEnd(r,a.index+o.length);let l=document.createElement(`a`);if(l.setAttribute(`href`,s),l.appendChild(c.extractContents()),c.insertNode(l),t===0&&o.length===a[0].length){let e=document.createTextNode(`​`);l.after(e),n.collapse(e,1)}return!0}function jC(e,t){if(!e.hasAttribute(`data-rich`))return!1;let n=t.trim();if(!kC.test(n))return!1;let r=_n(n);if(!r)return!1;let i=window.getSelection();if(!i||i.rangeCount===0||i.isCollapsed)return!1;let a=i.getRangeAt(0);if(!e.contains(a.startContainer)||!e.contains(a.endContainer))return!1;let o=XS(e,a,r);if(!o)return!1;let s=e.ownerDocument.createTextNode(`​`);o.after(s);let c=e.ownerDocument.createRange();return c.setStart(s,1),c.collapse(!0),i.removeAllRanges(),i.addRange(c),!0}function MC(e){e.preventDefault();let t=e.clipboardData.getData(`text/plain`);if(jC(e.currentTarget,t))return;let n=t.replace(/\r\n?/g,`
22
+ `).split(`
23
+ `),r=MS(e.currentTarget)!==null;n.forEach((e,t)=>{t>0&&document.execCommand(r?`insertParagraph`:`insertLineBreak`),e&&document.execCommand(`insertText`,!1,e)})}function NC(e){let t=e.key===`Backspace`||e.key===`ArrowLeft`,n=e.key===`Delete`||e.key===`ArrowRight`;if(!t&&!n)return!1;let r=window.getSelection();if(!r||!r.isCollapsed||r.rangeCount===0)return!1;let i=r.anchorNode;if(!i||i.nodeType!==3||!e.currentTarget.contains(i))return!1;let a=i,o=r.anchorOffset,s=!1;for(;;){let e=t?o-1:o;if(a.data[e]!==`​`)break;a.deleteData(e,1),o=e,s=!0}return s&&r.collapse(a,o),s}function PC(e,t){if(e.type===`control`)return t===`body`?`body`:t===`primary`?`primaryLabel`:t===`secondary`?`secondaryLabel`:`label`;let n=wn[e.type].textField;return n===`text-or-delete`?e.type===`text`?`text`:null:n}function FC(e,t,n){let{editSession:r,shapes:i,updateShape:a}=e.store.getState();if(r.kind!==`text`||r.shapeId!==t.shapeId||r.field!==t.field)return!1;let o=Qe(i,t.shapeId),s=o?PC(o,t.field):null;return!o||!s||(o[s]??``)===n?!1:(e.history.runWithoutHistory(()=>a(o.id,{[s]:n})),!0)}function IC(e,t){let n=0,r=Math.min(e.length,t.length);for(;n<r&&e[n]===t[n];)n+=1;let i=0;for(;i<r-n&&e[e.length-1-i]===t[t.length-1-i];)i+=1;return{start:n,end:e.length-i,text:t.slice(n,t.length-i)}}function LC(e,t,n){if(t===e||t===n)return n;if(n===e)return t;let r=IC(e,t),i=IC(e,n),[a,o]=r.start<i.start||r.start===i.start&&r.end<=i.end?[r,i]:[i,r];return a.end>o.start||a.start===o.start&&a.end===o.end?null:e.slice(0,a.start)+a.text+e.slice(a.end,o.start)+o.text+e.slice(o.end)}var RC=500;function zC(e,t){if(t)return e.innerText??``;let n=ot(e.innerHTML);return rt(n)?n:e.innerText??``}function BC(e){return rt(e)?jt(e):e.trim()===``}function VC(e,t){let n=e.textContent??``,r=KS(e);if(e.innerHTML=t,r===null)return;let i=e.textContent??``,a=0;for(;a<n.length&&a<i.length&&n[a]===i[a];)a+=1;qS(e,Vr(r<=a?r:r+i.length-n.length,0,i.length))}function HC(e){let{value:t,isEditing:n,interactive:r,onCommit:i,editableRef:a,onPointerDown:o,onClick:s,onDoubleClick:c,plain:l,prose:u,softBreaks:d,...f}=e,p=H(),{store:m,textEditGuard:h}=p,g=(0,J.useRef)(null),_=a??g,v=(0,J.useRef)(t);v.current=t;let y=(0,J.useRef)(null),b=(0,J.useRef)({target:null,origin:``,shared:``,written:!1,remote:!1,timer:0,save:null}),x=d?.width,S=d?.fontSize,C=(0,J.useMemo)(()=>({__html:x===void 0||S===void 0?Ot(t):rt(t)?Hi(Ot(t),x,S):zi(t,x,S)}),[t,x,S]);(0,J.useLayoutEffect)(()=>{if(!n)return;let e=a?.current??g.current;if(!e)return;e.innerHTML=Ot(v.current);let t=m.getState().editSession,r=b.current;r.target=t.kind===`text`?{shapeId:t.shapeId,field:t.field}:null,r.origin=v.current,r.shared=v.current,r.written=!1,r.remote=!1;let i=()=>{window.clearTimeout(r.timer),r.timer=0;let t=zC(e,l);!r.target||BC(t)||FC(p,r.target,t)&&(r.written=!0,r.shared=t)};r.save=i;let o=fC(e,()=>{window.clearTimeout(r.timer),r.timer=window.setTimeout(i,RC)});y.current=o;let s=()=>{r.timer!==0&&i()},c=()=>{document.visibilityState===`hidden`&&s()};window.addEventListener(`pagehide`,s,!0),window.addEventListener(`visibilitychange`,c,!0);let d=()=>{window.clearTimeout(r.timer),r.timer=0,window.removeEventListener(`pagehide`,s,!0),window.removeEventListener(`visibilitychange`,c,!0),o.dispose(),y.current=null,r.save=null},f=p.editEntry.take(),h=u?f:null,_=()=>{e.focus();let t=window.getSelection();if(!t)return;let n=h?du(e,h):null;n||(n=document.createRange(),n.selectNodeContents(e)),t.removeAllRanges(),t.addRange(n)};if(m.getState().coarsePointer||f)return _(),d;let x=requestAnimationFrame(_);return()=>{cancelAnimationFrame(x),d()}},[n,m,a,p,l,u]),(0,J.useEffect)(()=>{let e=b.current,r=_.current;if(!n||!r||!e.target||t===e.shared)return;let i=zC(r,l),a=LC(e.shared,i,t);e.shared=t,e.remote=!0,!(a===null||a===i)&&(VC(r,Ot(a)),y.current?.reset(),a!==t&&e.save?.())},[t,n,l,_]);function w(e){if(!(e.nativeEvent.isComposing||e.keyCode===229)&&(Ox(e,h.release),!T(e))){if(e.key===`Tab`){E(e);return}if(NC(e)&&y.current?.absorb(),l){CC(e);return}y.current?.flush(),!OC(e)&&(e.key===`Enter`&&!e.shiftKey&&(AC(e.currentTarget,0),y.current?.flush()),bC(e),xC(e),CC(e))}}function T(e){if(!(e.metaKey||e.ctrlKey)||e.altKey)return!1;let t=e.key.toLowerCase(),n=t===`z`&&e.shiftKey||t===`y`&&!e.shiftKey;return t!==`z`&&!n?!1:(e.preventDefault(),n?y.current?.redo():y.current?.undo(),!0)}function E(e){if(e.preventDefault(),e.stopPropagation(),e.metaKey||e.ctrlKey||e.altKey)return;if(!l){y.current?.flush();let t=e.currentTarget;if(e.shiftKey?FS(t):PS(t))return}let t=m.getState().editSession;if(t.kind!==`text`||t.field!==`label`||!wf(m)||(h.release(),e.currentTarget.blur(),!Of(m,e.shiftKey?`down`:`right`,p.measurement)))return;let[n]=m.getState().selectedIds;n&&m.getState().beginTextEdit(n)}function D(e){let t=pC(e);if(t){e.preventDefault(),e.stopPropagation(),mC(t);return}o?.(e)}function O(e){let t=e.nativeEvent;if(t.inputType===`insertText`&&t.data){l||(y.current?.flush(),t.data===` `?AC(e.currentTarget,1):JS(e.currentTarget,t.data));return}if(t.inputType!==`insertParagraph`)return;let n=window.getSelection()?.anchorNode??null;for(;n&&n!==e.currentTarget;){if(n.nodeType===1&&n.tagName===`LI`){let e=n;e.parentElement?.matches(`ul[data-checklist]`)&&e.removeAttribute(`data-checked`);return}n=n.parentNode}}function k(e){if(r&&pC(e)){e.preventDefault(),e.stopPropagation();return}o?.(e)}function A(e){let n=r?pC(e):null;if(!n){s?.(e);return}e.stopPropagation();let a=e.currentTarget.querySelectorAll(`ul[data-checklist] > li`),o=Tt(t,Array.prototype.indexOf.call(a,n));o!==null&&i(o)}function j(e){if(r&&pC(e)){e.stopPropagation();return}c?.(e)}function M(e){if(h.isGuarded()||wS(e.relatedTarget))return;let t=b.current;window.clearTimeout(t.timer),t.timer=0,t.written&&t.target&&!t.remote&&(FC(p,t.target,t.origin),t.written=!1),i(zC(e.currentTarget,l))}return n?(0,Q.jsx)(`div`,{...f,ref:_,...l?{}:{"data-rich":!0},translate:`no`,className:`notranslate ${f.className??``}`,contentEditable:!0,suppressContentEditableWarning:!0,spellCheck:!!u,onKeyDown:w,onPointerDown:D,onClick:s,onDoubleClick:c,onInput:O,onPaste:MC,onBlur:M}):(0,Q.jsx)(`div`,{...f,ref:_,"data-rich":!0,translate:`no`,className:`notranslate ${f.className??``}`,onPointerDown:k,onClick:A,onDoubleClick:j,dangerouslySetInnerHTML:C})}function UC(e,t,n,r,i,a,o=0){let s=H().measurements.labelHeights;(0,J.useEffect)(()=>{let c=e.current;if(!c)return;let l=()=>r(t,c.offsetHeight+n*2+o);if(s.get(t)!==i&&(s.set(t,i),l()),!a)return;let u=new ResizeObserver(l);return u.observe(c),()=>u.disconnect()},[e,t,n,r,i,a,s,o])}function WC(e){return{fontSize:e.fontSize??20,fontFamily:e.fontFamily,fontWeight:Fr(e.fontFamily),lineHeight:e.lineHeight,letterSpacing:e.letterSpacing?`${e.letterSpacing}em`:void 0}}function GC(e){let{shape:t,isEditing:n,interactive:r,erasing:i,onPointerDown:a,onBeginEdit:o,onCommitText:s,onMeasure:c,onHover:l}=e,u=(0,J.useRef)(null),d=G(t),f=t.textPadding??6,p={x:t.flipX,y:t.flipY},m=Kn(t.kind,d.width,d.height,p),h={x:d.x+m.left,y:d.y+m.top,width:d.width-m.left-m.right,height:d.height-m.top-m.bottom};if(UC(u,t.id,f,c,[t.width,t.height,t.label,t.fontSize,t.fontFamily,t.lineHeight,t.letterSpacing,t.textPadding,t.flipX,t.flipY].join(`|`),n,m.top+m.bottom),!n&&t.label.length===0&&!t.titleIcon)return null;let g=t.fill===`transparent`||t.fill===`#ffffff`||Lr(t)!==null,_=g?vt(jr(t)):jr(t),v=t.textAlign??`center`,y=t.textVAlign??`middle`,b=t.titleIcon?.placement===`inside`?er(t.fontSize)+An(t.fontSize):0;return(0,Q.jsxs)(`div`,{className:`absolute flex`,style:{left:h.x,top:h.y,width:h.width,height:h.height,alignItems:y===`top`?`flex-start`:y===`bottom`?`flex-end`:`center`,justifyContent:v===`left`?`flex-start`:v===`right`?`flex-end`:`center`,transform:t.rotation?`rotate(${t.rotation}deg)`:void 0,transformOrigin:`center center`,padding:f,pointerEvents:`none`,opacity:Ex(t.opacity,i)},children:[t.titleIcon&&t.titleIcon.placement!==`inside`&&(()=>{let e=Pn(t.kind,h.width,h.height,p);return(0,Q.jsx)(`span`,{className:`absolute flex items-center justify-center rounded-md bg-[var(--canvas-bg)]`,"data-testid":`node-title-icon`,style:{left:e.x-28/2,top:e.y-28/2,width:28,height:28,border:`1.5px solid ${vt(t.color)}`,color:vt(t.color)},children:(0,Q.jsx)(SS,{name:t.titleIcon.name,source:t.titleIcon.source,size:18})})})(),t.titleIcon&&t.titleIcon.placement===`inside`&&(0,Q.jsx)(`span`,{className:`flex shrink-0 items-center`,"data-testid":`node-inside-icon`,style:{color:_,marginRight:An(t.fontSize)},children:(0,Q.jsx)(SS,{name:t.titleIcon.name,source:t.titleIcon.source,size:er(t.fontSize)})}),(0,Q.jsx)(HC,{value:t.label,isEditing:n,interactive:r&&!t.locked,editableRef:u,onCommit:e=>s(t.id,e),"data-testid":`node-label`,softBreaks:{width:h.width-f*2-b,fontSize:t.fontSize},"data-shape-id":t.id,"data-fixed-ink":!g||void 0,onPointerDown:e=>{!n&&r&&a(t.id,e)},onDoubleClick:()=>r&&o(t.id),...Dx(t.id,l),className:`max-w-full whitespace-pre-wrap break-words leading-tight outline-none`,style:{...WC(t),textAlign:v,color:_,cursor:n?`text`:void 0,pointerEvents:n||r?`all`:`none`}})]})}var KC=(0,J.memo)(GC);function qC(e){let{shape:t,isEditing:n,interactive:r,erasing:i,onBeginEdit:a,onCommitText:o,onMeasure:s}=e,c=(0,J.useRef)(null),l=G(t);return UC(c,t.id,14,s,[t.text,t.fontSize,t.fontFamily,t.lineHeight,t.letterSpacing].join(`|`),n),(0,Q.jsx)(`div`,{className:`absolute flex items-center justify-center`,style:{left:l.x,top:l.y,width:l.width,height:l.height,transform:t.rotation?`rotate(${t.rotation}deg)`:void 0,transformOrigin:`center center`,padding:14,pointerEvents:`none`,opacity:Ex(t.opacity,i)},children:(0,Q.jsx)(HC,{value:t.text,isEditing:n,interactive:r&&!t.locked,editableRef:c,onCommit:e=>o(t.id,e),"data-testid":`sticky-text`,prose:!0,softBreaks:{width:l.width-28,fontSize:t.fontSize},"data-shape-id":t.id,"data-fixed-ink":t.fill!==`transparent`||void 0,onDoubleClick:()=>r&&a(t.id),className:`max-w-full whitespace-pre-wrap break-words text-center leading-tight outline-none`,style:{...WC(t),color:t.fill===`transparent`?`var(--canvas-ink)`:Er(t.fill),cursor:n?`text`:void 0,pointerEvents:n?`all`:`none`}})})}var JC=(0,J.memo)(qC),YC={onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation()};function XC(e){let{frame:t,readOnly:n,canStart:r,buttonStyle:i,hover:a}=e,o=H(),s=U(e=>e.lastFlow[t.id]),[c,l]=(0,J.useState)(!1),u=t.flows??[];if(u.length===0)return r?(0,Q.jsxs)(`button`,{type:`button`,"data-testid":`figure-flow-edit`,title:`Walk through this diagram one step at a time`,className:`flex cursor-pointer items-center gap-1 whitespace-nowrap leading-none opacity-45 transition-opacity hover:opacity-75`,style:i,...YC,onClick:e=>{e.stopPropagation(),Vs(o,t.id)},...a,children:[(0,Q.jsx)(yc,{size:13,stroke:1.75}),`Flow`]}):null;let d=Uc(u,s);return(0,Q.jsxs)(`span`,{className:`flex items-center gap-2 whitespace-nowrap leading-none`,"data-testid":`figure-flows`,children:[d&&(0,Q.jsxs)(`button`,{type:`button`,"data-testid":`figure-flow-play`,title:`Play ${d.name}`,className:`flex cursor-pointer items-center gap-1 whitespace-nowrap leading-none opacity-90 transition-opacity hover:opacity-100`,style:i,...YC,onClick:e=>{e.stopPropagation(),Bs(o,t.id,d.id)},...a,children:[(0,Q.jsx)(D,{size:13,stroke:1.75}),d.name]}),(0,Q.jsxs)(N,{onOpenChange:e=>{if(l(e),e){eo(Jy);return}o.store.getState().setFlowPreview(null)},children:[(0,Q.jsxs)(I,{"data-testid":`figure-flow-menu`,"aria-label":`${u.length===1?`The flow`:`All ${u.length} flows`} on ${t.label||`this diagram`}`,title:`All flows`,className:`flex cursor-pointer items-center gap-0.5 whitespace-nowrap leading-none opacity-60 transition-opacity hover:opacity-100 data-[popup-open]:opacity-100`,style:i,...YC,onPointerEnter:e=>{eo(qy),a.onPointerEnter?.(e)},onPointerLeave:a.onPointerLeave,onFocus:()=>eo(qy),children:[d?u.length:`${u.length} ${u.length===1?`flow`:`flows`}`,(0,Q.jsx)(`svg`,{width:`9`,height:`9`,viewBox:`0 0 9 9`,"aria-hidden":!0,children:(0,Q.jsx)(`path`,{d:`M1.5 3.25 4.5 6.25 7.5 3.25`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`})})]}),(0,Q.jsx)(no,{active:c,retain:!0,feature:qy,children:e=>(0,Q.jsx)(e,{frameId:t.id,readOnly:n})})]})]})}function ZC(e){let{shapeId:t,fontFamily:n,color:r,codeStale:i,interactive:a,noun:o,testId:s,staleDotTestId:c,onEditCode:l,onHover:u}=e;return(0,Q.jsxs)(`button`,{type:`button`,"data-testid":s,"data-code-stale":i?`true`:`false`,title:i?`Edited on the canvas since its code was generated, so updating from code would replace those edits`:`Open this ${o}'s code`,className:`flex cursor-pointer items-center gap-1 whitespace-nowrap leading-none transition-opacity ${i?`opacity-100`:`opacity-70 hover:opacity-100`}`,style:{fontSize:12,fontFamily:n,fontWeight:Fr(n),color:i?`#d97706`:vt(r),pointerEvents:a?`all`:`none`},onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),l(t)},...Dx(t,u),children:[i&&(0,Q.jsx)(`span`,{"aria-hidden":!0,"data-testid":c,style:{width:6,height:6,borderRadius:9999,background:`#f59e0b`}}),(0,Q.jsx)(ec,{size:13,stroke:1.75}),`Edit as code`]})}function QC(e){let{value:t,left:n,top:r,width:i,transform:a,fontFamily:o,color:s,onDone:c}=e,l=(0,J.useRef)(null),u=(0,J.useRef)(!1);return(0,J.useEffect)(()=>{let e=requestAnimationFrame(()=>{l.current?.focus(),l.current?.select()});return()=>cancelAnimationFrame(e)},[]),(0,Q.jsx)(`input`,{ref:l,"data-testid":`lane-title-input`,defaultValue:t,onPointerDown:e=>e.stopPropagation(),onKeyDown:e=>{if(e.key===`Enter`){e.preventDefault(),e.currentTarget.blur();return}e.key===`Escape`&&(e.stopPropagation(),u.current=!0,e.currentTarget.blur())},onBlur:e=>c(u.current?null:e.currentTarget.value),className:`absolute rounded-[4px] bg-[var(--canvas-bg)] px-1.5 py-0.5 text-center leading-none outline-none`,style:{left:n,top:r,transform:a,width:i,fontSize:14,fontFamily:o,fontWeight:Fr(o),color:s,pointerEvents:`all`}})}function $C(e){let{shape:t,erasing:n,interactive:r,editingLane:i,onPointerDown:a,onBeginEditLane:o,onCommitLane:s,onHover:c}=e,l=t.lanes??[];if(!ns(t.kind)||l.length===0)return null;let u=is(t.kind),d=G(t),f=Xo(l.length,u?d.width:d.height,t.laneSizes),p=e=>(f[e]+f[e+1])/2,m=e=>f[e+1]-f[e];return(0,Q.jsxs)(`div`,{className:`absolute`,style:{left:d.x,top:d.y,width:u?d.width:30,height:u?30:d.height,pointerEvents:`none`,opacity:Ex(t.opacity,n)},children:[l.map((e,n)=>(0,Q.jsx)(`div`,{"data-testid":`figure-lane-title`,"data-shape-id":t.id,onPointerDown:e=>{r&&a(t.id,e)},onDoubleClick:e=>{r&&(e.stopPropagation(),o(t.id,n))},...Dx(t.id,c),className:`absolute overflow-hidden text-ellipsis whitespace-nowrap px-3 text-center leading-none`,style:{left:u?p(n):30/2,top:u?30/2:p(n),width:m(n),boxSizing:`border-box`,transform:u?`translate(-50%, -50%)`:`translate(-50%, -50%) rotate(-90deg)`,fontSize:14,fontFamily:t.fontFamily,fontWeight:Fr(t.fontFamily),color:vt(t.color),opacity:Qo,cursor:`move`,pointerEvents:r&&!t.locked&&i===null?`all`:`none`},children:e},n)),i!==null&&i<l.length&&(0,Q.jsx)(QC,{value:l[i],left:u?p(i):30/2,top:u?30/2:p(i),width:Math.max(80,m(i)-24),transform:u?`translate(-50%, -50%)`:`translate(-50%, -50%) rotate(-90deg)`,fontFamily:t.fontFamily,color:vt(t.color),onDone:e=>s(t.id,i,e)},i)]})}function ew(e){let{shape:t,isEditing:n,interactive:r,readOnly:i,erasing:a,editingLane:o,codeStale:s,animated:c,nested:l,onPointerDown:u,onBeginEdit:d,onBeginEditLane:f,onCommitText:p,onCommitLane:m,onEditNotes:h,onAnimate:g,onEditCode:_,onPresent:v,onHover:y}=e,b=G(t),x=t.slideOrder!==void 0,S=(t.notes??``).trim().length>0,C=typeof t.code==`string`&&t.code.trim().length>0,w=t.flows??[],T=!i&&!l&&(!x||w.length>0),E={fontSize:12,fontFamily:t.fontFamily,fontWeight:Fr(t.fontFamily),color:vt(t.color),pointerEvents:r?`all`:`none`};return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`absolute flex items-end gap-1`,style:{left:b.x,top:b.y-4,pointerEvents:`none`,opacity:Ex(t.opacity,a)},children:[x&&(0,Q.jsx)(`span`,{className:`-translate-y-full`,"data-testid":`figure-slide-indicator`,title:`In the slide deck`,style:{color:vt(t.color),opacity:.7},children:(0,Q.jsx)(Js,{size:15,stroke:1.75})}),t.titleIcon&&(0,Q.jsx)(`span`,{className:`-translate-y-full`,"data-testid":`figure-title-icon`,style:{color:vt(t.color)},children:(0,Q.jsx)(SS,{name:t.titleIcon.name,source:t.titleIcon.source,size:15})}),(0,Q.jsx)(HC,{value:t.label,isEditing:n,onCommit:e=>p(t.id,e),"data-testid":`figure-label`,"data-shape-id":t.id,onPointerDown:e=>{!n&&r&&u(t.id,e)},onDoubleClick:e=>{r&&(e.stopPropagation(),d(t.id))},...Dx(t.id,y),className:`-translate-y-full whitespace-nowrap leading-none outline-none`,style:{fontSize:14,fontFamily:t.fontFamily,fontWeight:Fr(t.fontFamily),color:vt(t.color),cursor:n?`text`:`move`,pointerEvents:r?`all`:`none`}})]}),(x||C&&!i||w.length>0||T)&&(0,Q.jsx)(`div`,{className:`absolute`,style:{left:b.x+b.width,top:b.y-4,pointerEvents:`none`,opacity:Ex(t.opacity,a)},children:(0,Q.jsxs)(`div`,{className:`-translate-x-full -translate-y-full flex items-center gap-3 whitespace-nowrap leading-none`,children:[(0,Q.jsx)(XC,{frame:t,readOnly:i,canStart:T,buttonStyle:E,hover:Dx(t.id,y)}),C&&!i&&(0,Q.jsx)(ZC,{shapeId:t.id,fontFamily:t.fontFamily,color:t.color,codeStale:s??!1,interactive:r,noun:`diagram`,testId:`figure-edit-code`,staleDotTestId:`figure-code-stale-dot`,onEditCode:_,onHover:y}),x&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[!i&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsxs)(`button`,{type:`button`,"data-testid":`figure-notes-button`,title:S?t.notes:`Add speaker notes`,className:`flex cursor-pointer items-center gap-1 whitespace-nowrap leading-none transition-opacity ${S?`opacity-90 hover:opacity-100`:`opacity-45 hover:opacity-75`}`,style:{fontSize:12,fontFamily:t.fontFamily,fontWeight:Fr(t.fontFamily),color:vt(t.color),pointerEvents:r?`all`:`none`},onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),h(t.id)},...Dx(t.id,y),children:[S?(0,Q.jsx)(hc,{size:13,stroke:1.75}):(0,Q.jsx)(_c,{size:13,stroke:1.75}),`Speaker notes`]}),(0,Q.jsxs)(`button`,{type:`button`,"data-testid":`figure-animate-button`,"data-animated":c?`true`:`false`,title:c?`This slide builds in steps. Click to edit the order.`:`Set the order this slide's contents appear in`,className:`flex cursor-pointer items-center gap-1 whitespace-nowrap leading-none transition-opacity ${c?`opacity-90 hover:opacity-100`:`opacity-45 hover:opacity-75`}`,style:{fontSize:12,fontFamily:t.fontFamily,fontWeight:Fr(t.fontFamily),color:vt(t.color),pointerEvents:r?`all`:`none`},onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),g(t.id)},...Dx(t.id,y),children:[(0,Q.jsx)(Sa,{size:13,stroke:1.75}),`Animate`]})]}),(0,Q.jsx)(`span`,{className:`h-3 w-px`,style:{background:vt(t.color),opacity:.25}})]}),(0,Q.jsxs)(`button`,{type:`button`,"data-testid":`figure-present-button`,title:`Present from this slide`,className:`flex cursor-pointer items-center gap-1 whitespace-nowrap leading-none opacity-90 transition-opacity hover:opacity-100`,style:{fontSize:12,fontFamily:t.fontFamily,fontWeight:Fr(t.fontFamily),color:vt(t.color),pointerEvents:r?`all`:`none`},onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),v(t.id)},...Dx(t.id,y),children:[(0,Q.jsx)(D,{size:13,stroke:1.75}),`Present`]})]})]})}),(0,Q.jsx)($C,{shape:t,erasing:a,interactive:r,editingLane:o,onPointerDown:u,onBeginEditLane:f,onCommitLane:m,onHover:y})]})}var tw=(0,J.memo)(ew);function nw(e){let{id:t,label:n,point:r,fontSize:i,fontFamily:a,color:o,opacity:s,testId:c,isEditing:l,interactive:u,locked:d,erasing:f,onPointerDown:p,onLabelPointerDown:m,onBeginEdit:h,onCommitText:g,onHover:_}=e;if(!l&&n.length===0)return null;let v=a??li,y=o===`transparent`?`var(--canvas-ink)`:o;return(0,Q.jsx)(HC,{value:n,isEditing:l,interactive:u&&!d,onCommit:e=>g(t,e),"data-testid":c,"data-shape-id":t,onPointerDown:e=>{if(l){e.stopPropagation();return}u&&(m??p)(t,e)},onDoubleClick:e=>{u&&(e.stopPropagation(),h(t))},...Dx(t,_),className:`absolute whitespace-pre rounded-[2px] text-center outline-none`,style:{left:r.x,top:r.y,transform:`translate(-50%, -50%)`,transformOrigin:`center center`,lineHeight:pr,fontSize:i??20,fontFamily:v,fontWeight:Fr(v),color:y,opacity:Ex(s,f),backgroundColor:`var(--canvas-bg)`,padding:`0 10px`,pointerEvents:u||l?`all`:`none`,cursor:l?`text`:u&&!d&&m?`move`:void 0,outline:l?`1.5px solid var(--canvas-selection)`:void 0,outlineOffset:l?3:void 0}})}function rw(e){let{shape:t,isEditing:n,interactive:r,erasing:i,onPointerDown:a,onLabelPointerDown:o,onBeginEdit:s,onCommitText:c,onHover:l}=e;return(0,Q.jsx)(nw,{id:t.id,label:t.label??``,point:ln(t),fontSize:t.fontSize,fontFamily:t.fontFamily,color:vt(t.color),opacity:t.opacity,testId:`arrow-label`,isEditing:n,interactive:r,locked:t.locked,erasing:i,onPointerDown:a,onLabelPointerDown:o,onBeginEdit:s,onCommitText:c,onHover:l})}var iw=(0,J.memo)(rw);function aw(e){let{shape:t,text:n,end:r,erasing:i}=e;if(n.length===0)return null;let a=rr(t,r),o=t.fontFamily??li,s=t.color===`transparent`?`var(--canvas-ink)`:t.color;return(0,Q.jsx)(`div`,{"data-testid":`arrow-${r}-label`,"data-shape-id":t.id,className:`absolute whitespace-pre rounded-[2px] text-center`,style:{left:a.x,top:a.y,transform:`translate(-50%, -50%)`,lineHeight:pr,fontSize:14,fontFamily:o,fontWeight:Fr(o),color:s,opacity:Ex(t.opacity,i),backgroundColor:`var(--canvas-bg)`,padding:`0 4px`,pointerEvents:`none`},children:n})}function ow(e){let{shape:t,erasing:n}=e;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(aw,{shape:t,text:t.startLabel??``,end:`start`,erasing:n}),(0,Q.jsx)(aw,{shape:t,text:t.endLabel??``,end:`end`,erasing:n})]})}var sw=(0,J.memo)(ow);function cw(e){let{shape:t,isEditing:n,interactive:r,erasing:i,onPointerDown:a,onLabelPointerDown:o,onBeginEdit:s,onCommitText:c,onHover:l}=e;return(0,Q.jsx)(nw,{id:t.id,label:t.label??``,point:Zt(t.points,t.labelAlong),fontSize:t.fontSize,fontFamily:t.fontFamily,color:vt(t.color),opacity:t.opacity,testId:`line-label`,isEditing:n,interactive:r,locked:t.locked,erasing:i,onPointerDown:a,onLabelPointerDown:o,onBeginEdit:s,onCommitText:c,onHover:l})}var lw=(0,J.memo)(cw),uw=`#8a8f98`;function dw(e){let{shape:t,field:n,onCommitText:r}=e,i=ru(t,n),a=cr(t),o=G(t),s=o.x+o.width/2-i.x,c=o.y+o.height/2-i.y,l=n===`body`?t.body??``:n===`primary`?Si(t):n===`secondary`?bi(t):t.label,u;if(n===`primary`){let e=ft(en(t.color));u=e?fr(e):Er(t.color)}else u=n===`body`&&t.kind===`card`?uw:vt(t.color);return(0,Q.jsx)(`div`,{className:`absolute flex ${i.valign===`top`?`items-start`:`items-center`} ${i.align===`left`?`justify-start`:`justify-center`}`,style:{left:i.x,top:i.y,width:i.width,height:i.height,transform:a?`rotate(${a}deg)`:void 0,transformOrigin:`${s}px ${c}px`},"data-testid":`control-label-editor`,"data-control-field":n,children:(0,Q.jsx)(HC,{value:l,isEditing:!0,interactive:!0,plain:!0,onCommit:e=>r(t.id,e,n),className:`max-w-full whitespace-pre-wrap break-words outline-none ${i.align===`left`?`text-left`:`text-center`}`,style:{fontSize:i.fontSize,fontFamily:t.fontFamily,fontWeight:Fr(t.fontFamily),lineHeight:i.lineHeight,color:u,cursor:`text`,pointerEvents:`all`}})})}var fw=(0,J.memo)(dw);function pw(e,t,n,r,i,a){let o=H().measurements.labelWidths;(0,J.useEffect)(()=>{let s=e.current;if(!s)return;let c=()=>r(t,s.offsetWidth+n*2);if(o.get(t)!==i&&(o.set(t,i),c()),!a)return;let l=new ResizeObserver(c);return l.observe(s),()=>l.disconnect()},[e,t,n,r,i,a,o])}var mw=16;function hw(e){let{shape:t,isEditing:n,interactive:r,erasing:i,onPointerDown:a,onBeginEdit:o,onCommitText:s,onMeasure:c,onHover:l}=e,u=(0,J.useRef)(null),d=G(t);return pw(u,t.id,mw,c,`${t.label}|${t.fontSize}|${t.fontFamily}`,n),(0,Q.jsx)(`div`,{className:`absolute flex items-center justify-center`,style:{left:d.x,top:d.y,width:d.width,height:rn(t),pointerEvents:`none`,opacity:Ex(t.opacity,i)},children:(0,Q.jsx)(HC,{value:t.label,isEditing:n,interactive:r&&!t.locked,editableRef:u,plain:!0,onCommit:e=>s(t.id,e),"data-testid":`lifeline-name`,"data-shape-id":t.id,onPointerDown:e=>{!n&&r&&a(t.id,e)},onDoubleClick:()=>r&&o(t.id),...Dx(t.id,l),className:`whitespace-nowrap leading-none outline-none`,style:{fontSize:t.fontSize,fontFamily:t.fontFamily,fontWeight:Fr(t.fontFamily),color:zt(t)??vt(t.color),cursor:n?`text`:`move`,pointerEvents:n||r?`all`:`none`}})})}var gw=(0,J.memo)(hw);function _w(e,t,n,r){let{store:i,history:a}=H(),{runWithoutHistory:o}=a,s=(0,J.useRef)(null),c=(0,J.useRef)({store:i,runWithoutHistory:o});c.current={store:i,runWithoutHistory:o},(0,J.useEffect)(()=>{let r=e.current;if(!r||!n){s.current=null;return}s.current={width:r.offsetWidth,height:r.offsetHeight};let i=new ResizeObserver(()=>{let e=s.current,i=r.offsetWidth,a=r.offsetHeight;if(!e||e.width===i&&e.height===a)return;s.current={width:i,height:a};let o=n*Math.PI/180,l=Math.cos(o),u=Math.sin(o),d=(e.width-i)/2,f=(e.height-a)/2,p=d*(1-l)+f*u,m=f*(1-l)-d*u;if(Math.abs(p)<.01&&Math.abs(m)<.01)return;let h=c.current.store.getState(),g=Qe(h.shapes,t);g?.type===`text`&&c.current.runWithoutHistory(()=>h.updateShape(t,{x:g.x+p,y:g.y+m}))});return i.observe(r),()=>i.disconnect()},[e,t,n,r])}function vw(e){let{shape:t,isEditing:n,interactive:r,erasing:i,onPointerDown:a,onBeginEdit:o,onCommitText:s,onHover:c}=e,l=(0,J.useRef)(null);_w(l,t.id,t.rotation,n);function u(e){if(n){e.stopPropagation();return}r&&a(t.id,e)}let d=t.width!=null,f=t.height!=null,p=t.textVAlign??`top`,m=[t.rotation?`rotate(${t.rotation}deg)`:``,t.flipX?`scaleX(-1)`:``,t.flipY?`scaleY(-1)`:``].filter(Boolean).join(` `);return f?(0,Q.jsx)(`div`,{ref:l,"data-shape-id":t.id,"data-testid":`text-box`,onPointerDown:u,onDoubleClick:()=>r&&o(t.id),onPointerEnter:()=>c(t.id),onPointerLeave:()=>c(null),className:`absolute flex flex-col rounded-[2px]`,style:{left:t.x,top:t.y,width:d?t.width:void 0,minHeight:t.height,justifyContent:p===`top`?`flex-start`:p===`bottom`?`flex-end`:`center`,transform:m||void 0,transformOrigin:`center center`,pointerEvents:r||n?`all`:`none`,opacity:Ex(t.opacity,i),outline:n?`1.5px solid var(--canvas-selection)`:void 0,outlineOffset:n?3:void 0},children:(0,Q.jsx)(HC,{value:t.text,isEditing:n,interactive:r&&!t.locked,onCommit:e=>s(t.id,e),"data-testid":`text`,prose:!0,softBreaks:t.width==null?void 0:{width:t.width,fontSize:t.fontSize},className:`outline-none`,style:{...WC(t),width:d?`100%`:void 0,minWidth:n?void 0:t.fontSize,lineHeight:t.lineHeight??1.15,textAlign:t.textAlign,color:vt(t.color),whiteSpace:d?`pre-wrap`:`pre`,overflowWrap:d?`break-word`:void 0,cursor:n?`text`:void 0}})}):(0,Q.jsx)(HC,{value:t.text,isEditing:n,interactive:r&&!t.locked,onCommit:e=>s(t.id,e),editableRef:l,"data-shape-id":t.id,"data-testid":`text`,prose:!0,softBreaks:t.width==null?void 0:{width:t.width,fontSize:t.fontSize},onPointerDown:u,onDoubleClick:()=>r&&o(t.id),onPointerEnter:()=>c(t.id),onPointerLeave:()=>c(null),className:`absolute rounded-[2px] outline-none`,style:{...WC(t),left:t.x,top:t.y,lineHeight:t.lineHeight??1.15,textAlign:t.textAlign,color:vt(t.color),opacity:Ex(t.opacity,i),width:d?t.width:void 0,minWidth:n?void 0:t.fontSize,minHeight:t.fontSize,whiteSpace:d?`pre-wrap`:`pre`,overflowWrap:d?`break-word`:void 0,transform:m||void 0,transformOrigin:`center center`,pointerEvents:r||n?`all`:`none`,cursor:n?`text`:void 0,outline:n?`1.5px solid var(--canvas-selection)`:void 0,outlineOffset:n?3:void 0}})}var yw=(0,J.memo)(vw);function bw(e){let{shape:t,isEditing:n,interactive:r,erasing:i,onPointerDown:a,onBeginEdit:o,onCommitText:s,onHover:c}=e,l=G(t);if(!n&&t.label.length===0)return null;let u=l.x+l.width/2,d=t.fontSize??36,f=or(d);return(0,Q.jsx)(`div`,{className:`absolute`,style:{left:u,top:l.y+l.height+f,transform:t.rotation?`translateX(-50%) rotate(${t.rotation}deg)`:`translateX(-50%)`,transformOrigin:`center ${-(l.height/2+f)}px`,opacity:Ex(t.opacity,i),pointerEvents:`none`},children:(0,Q.jsx)(HC,{value:t.label,isEditing:n,interactive:r&&!t.locked,onCommit:e=>s(t.id,e),"data-icon-label":t.id,onPointerDown:e=>{if(n){e.stopPropagation();return}r&&a(t.id,e)},onDoubleClick:()=>r&&o(t.id),...Dx(t.id,c),className:`whitespace-pre text-center leading-tight outline-none`,style:{fontSize:d,fontFamily:t.fontFamily,fontWeight:Fr(t.fontFamily),color:t.color===`transparent`?`var(--canvas-ink)`:vt(t.color),cursor:n?`text`:void 0,pointerEvents:r||n?`all`:`none`}})})}var xw=(0,J.memo)(bw);function Sw(e){let{shape:t,interactive:n,erasing:r,codeStale:i,onEditCode:a,onHover:o}=e,s=G(t),c=cr(t);return(0,Q.jsx)(`div`,{className:`absolute`,style:{left:s.x+s.width,top:s.y,transform:c?`rotate(${c}deg)`:void 0,transformOrigin:`${-s.width/2}px ${s.height/2}px`,pointerEvents:`none`,opacity:Ex(t.opacity,r)},children:(0,Q.jsx)(`div`,{className:`-translate-x-full -translate-y-full flex items-center whitespace-nowrap pb-1 leading-none`,children:(0,Q.jsx)(ZC,{shapeId:t.id,fontFamily:t.fontFamily,color:t.color,codeStale:i,interactive:n,noun:`chart`,testId:`chart-edit-code`,staleDotTestId:`chart-code-stale-dot`,onEditCode:a,onHover:o})})})}function Cw(e){let{shape:t,interactive:n,erasing:r,onPointerDown:i,onBeginEditCell:a,onHover:o}=e,{store:s}=H(),c=bo(t),l={pointerEvents:`none`};return(0,Q.jsxs)(`g`,{"data-shape-id":t.id,"data-testid":`table`,opacity:Ex(t.opacity,r),children:[(0,Q.jsx)(`rect`,{x:c.frame.x,y:c.frame.y,width:c.frame.width,height:c.frame.height,rx:2,fill:`var(--paper-bg)`,stroke:ko,strokeWidth:1.25,style:l}),c.cellFills.map(e=>(0,Q.jsx)(`rect`,{"data-testid":`table-cell-bg`,x:e.rect.x,y:e.rect.y,width:e.rect.width,height:e.rect.height,fill:an(e.fill),style:l},e.key)),c.dividers.map(e=>(0,Q.jsx)(`line`,{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:ko,strokeWidth:1,style:l},e.key)),t.cells.flatMap((e,r)=>e.map((e,c)=>{let l=Go(t,r,c);return(0,Q.jsx)(`rect`,{"data-testid":`table-cell-hit`,x:l.x,y:l.y,width:l.width,height:l.height,fill:`transparent`,style:{pointerEvents:n?`all`:`none`},onPointerDown:e=>{s.getState().setTableSelection(null),i(t.id,e)},onDoubleClick:()=>n&&a(t.id,r,c),...Dx(t.id,o)},`hit-${r}-${c}`)}))]})}function ww(e,t,n,r){let i=e.cells.length,a=e.cells[0]?.length??0;if(!(r.metaKey||r.ctrlKey||r.altKey)){if(r.key===`Tab`){let e=t*a+n+(r.shiftKey?-1:1);return e<0||e>=i*a?{row:t,col:n}:{row:Math.floor(e/a),col:e%a}}if(r.key===`Enter`&&!r.shiftKey)return t+1<i?{row:t+1,col:n}:null}}function Tw(e){let{shape:t,row:n,col:r,text:i,rect:a,editing:o,erasing:s,onCommit:c,onMeasure:l}=e,{store:u,textEditGuard:d}=H(),f=(0,J.useRef)(null);kx(f,o);let p=To(t,n,r);return(0,J.useEffect)(()=>{let e=f.current;if(!e)return;let i=()=>l(t.id,n,r,e.offsetHeight+16);i();let a=new ResizeObserver(i);return a.observe(e),()=>a.disconnect()},[l,t.id,n,r,i,a.width,p.fontSize,p.fontFamily,o]),(0,Q.jsx)(`div`,{"data-testid":`table-cell-box`,className:`absolute flex flex-col justify-center overflow-hidden`,style:{left:a.x,top:a.y,width:a.width,height:a.height,padding:8,boxSizing:`border-box`,opacity:Ex(t.opacity,s),pointerEvents:o?`all`:`none`,outline:o?`1.5px solid var(--canvas-selection)`:void 0,outlineOffset:-1},children:(0,Q.jsx)(`div`,{ref:f,"data-testid":`table-cell`,"data-shape-id":t.id,contentEditable:o,suppressContentEditableWarning:!0,spellCheck:!1,onKeyDown:e=>{if(Ox(e,d.release),e.nativeEvent.isComposing)return;let i=ww(t,n,r,e);i!==void 0&&(e.preventDefault(),e.stopPropagation(),d.release(),e.currentTarget.blur(),i&&u.getState().beginTableCellEdit(t.id,i.row,i.col))},onBlur:e=>c(t.id,n,r,e.currentTarget.innerText??``),className:`w-full whitespace-pre-wrap break-words leading-tight outline-none`,style:{fontSize:p.fontSize,fontFamily:p.fontFamily,fontWeight:Fr(p.fontFamily),color:vt(p.color),cursor:o?`text`:void 0},children:o?i:Ii(i,a.width-16,p.fontSize)})})}function Ew(e){let{shape:t,editingCell:n,erasing:r,onCommitCell:i,onMeasureCell:a}=e;return(0,Q.jsx)(Q.Fragment,{children:t.cells.flatMap((e,o)=>e.map((e,s)=>{let c=n?.row===o&&n?.col===s;return e.length===0&&!c?null:(0,Q.jsx)(Tw,{shape:t,row:o,col:s,text:e,rect:Go(t,o,s),editing:c,erasing:r,onCommit:i,onMeasure:a},`${o}-${s}`)}))})}var Dw=(0,J.memo)(Cw),Ow=(0,J.memo)(Ew),kw={youtube:Zp,vimeo:Jf,loom:Jp,figma:Kf,codepen:Wf,codesandbox:Gf,"google-maps":Dp,spotify:qf,generic:Yp};function Aw(e,t){return Math.max(10,Math.min(22,Math.min(e/30,t/12)))}function jw(e){let{info:t,provider:n,image:r,width:i,height:a,loading:o,failed:s}=e,c=Aw(i,a),l=n===`html`?ec:kw[n],[u,d]=(0,J.useState)(null),f=r!==void 0&&u!==r;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{"data-testid":`web-card`,className:`pointer-events-none absolute inset-0 flex select-none flex-col items-center justify-center overflow-hidden px-[6%] text-center text-[var(--canvas-ink)]`,style:{fontFamily:Ri,gap:c*.5,background:`linear-gradient(180deg, var(--paper-bg), color-mix(in srgb, var(--canvas-ink) 4%, var(--paper-bg)))`},children:[(0,Q.jsx)(`div`,{className:`flex items-center justify-center rounded-[28%]`,style:{width:c*2.8,height:c*2.8,background:`color-mix(in srgb, var(--canvas-ink) 7%, transparent)`},children:(0,Q.jsx)(l,{size:c*1.5,stroke:1.6,className:o?`animate-pulse opacity-70`:`opacity-70`})}),(0,Q.jsx)(`div`,{className:`max-w-full truncate font-medium leading-tight`,style:{fontSize:c*1.1},children:t.title}),(0,Q.jsx)(`div`,{className:`max-w-full truncate leading-tight opacity-55`,style:{fontSize:c*.85},children:s?`This widget didn't start`:o?`Loading…`:t.caption})]}),f&&(0,Q.jsx)(`img`,{src:r,alt:``,draggable:!1,loading:`lazy`,decoding:`async`,onError:()=>d(r),className:`pointer-events-none absolute inset-0 h-full w-full select-none object-cover`})]})}function Mw(e){let{width:t,height:n,onPlay:r}=e,i=Math.max(36,Math.min(88,Math.min(t,n)/4.5));return(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Play`,"data-testid":`web-play`,onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),r()},className:`absolute left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-full bg-black/60 text-white shadow-[0_4px_24px_rgba(0,0,0,0.35)] outline-none ring-1 ring-white/25 backdrop-blur-sm transition-transform hover:scale-105 hover:bg-black/75`,style:{width:i,height:i},children:(0,Q.jsx)(wc,{size:i*.42,className:`translate-x-[6%]`})})}function Nw(e){let{width:t,height:n,onRun:r}=e,i=Aw(t,n);return(0,Q.jsxs)(`button`,{type:`button`,"data-testid":`web-run`,onPointerDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),r()},className:`absolute bottom-[10%] left-1/2 flex -translate-x-1/2 items-center rounded-full bg-[var(--canvas-ink)] font-medium text-[var(--paper-bg)] shadow-[0_2px_10px_rgba(0,0,0,0.18)] outline-none transition-opacity hover:opacity-85`,style:{fontFamily:Ri,fontSize:i*.95,gap:i*.4,padding:`${i*.45}px ${i*1.1}px`},children:[(0,Q.jsx)(wc,{size:i}),`Run widget`]})}var Pw=1e4;function Fw(e){let{shape:t,interactive:n,interacting:r,erasing:i,onPointerDown:a,onBeginEdit:o,onHover:s}=e,c=W(),l=lg(),u=(0,J.useMemo)(()=>gg(t,l),[t,l]),d=U(e=>e.liveWebIds.has(t.id)),f=U(e=>e.startedWebIds.has(t.id)),[p,m]=(0,J.useState)(!1),[h,g]=(0,J.useState)(!1),_=d&&u!==null,v=qc(u?.kind===`html`?u.source:null,_),y=v?.status===`ready`?v.html:null,[b,x]=(0,J.useState)(null);(0,J.useEffect)(()=>{y!==null&&x(y)},[y]);let S=y??(v?.status===`loading`?b:null),C=_&&v?.status===`failed`;(0,J.useEffect)(()=>{_||(m(!1),g(!1))},[_]);let w=Fi(t),T=u?.kind===`embed`?u.embed:null,E=u!==null&&_g(u,l)&&!f,D=t.poster??T?.thumbnail,O=Math.min(12,t.width/8,t.height/8),k=()=>{let e=c.getState();e.startWeb(t.id),e.setSelectedIds(new Set([t.id])),e.beginInteract(t.id)};return(0,Q.jsxs)(`div`,{"data-shape-id":t.id,"data-testid":`web`,"data-web-kind":t.kind,"data-live":_?`true`:`false`,"data-interacting":r?`true`:void 0,className:`group absolute overflow-hidden`,style:{left:t.x,top:t.y,width:t.width,height:t.height,borderRadius:O,opacity:Ex(t.opacity,i),pointerEvents:n||r?`auto`:`none`,boxShadow:r?`0 0 0 2px var(--canvas-selection), 0 8px 28px rgba(0,0,0,0.12)`:`0 0 0 1px color-mix(in srgb, var(--canvas-ink) 14%, transparent), 0 1px 3px rgba(0,0,0,0.06)`,background:`var(--paper-bg)`},onPointerDown:e=>a(t.id,e),onDoubleClick:()=>o(t.id),...Dx(t.id,s),children:[(0,Q.jsx)(jw,{info:w,provider:t.kind===`html`?`html`:T?.provider??`generic`,image:D,width:t.width,height:t.height,loading:_&&!p&&!h&&!C,failed:h||C}),!_&&(0,Q.jsx)(`div`,{className:`pointer-events-none absolute inset-0 bg-[var(--canvas-selection)] opacity-0 transition-opacity group-hover:opacity-[0.04]`}),E&&T?.video&&!_&&(0,Q.jsx)(Mw,{width:t.width,height:t.height,onPlay:k}),E&&t.kind===`html`&&!_&&(0,Q.jsx)(Nw,{width:t.width,height:t.height,onRun:k}),_&&T&&(0,Q.jsx)(Lw,{embed:T,title:w.title,interacting:r,loaded:p,onLoaded:()=>m(!0)},T.src),_&&u?.kind===`html`&&S!==null&&(0,Q.jsx)(Rw,{html:S,origin:u.origin,title:w.title,interacting:r,loaded:p,onLoaded:()=>m(!0),onFailed:()=>g(!0)},qe(S,0,0))]})}function Iw(e,t){return{pointerEvents:e?`auto`:`none`,opacity:+!!t,transition:`opacity 160ms ease-out`,colorScheme:`normal`}}function Lw(e){let{embed:t,title:n,interacting:r,loaded:i,onLoaded:a}=e;return(0,Q.jsx)(`iframe`,{"data-testid":`web-frame`,title:n,src:vg(t),sandbox:t.sandbox,allow:t.allow,referrerPolicy:Un,onLoad:a,className:`absolute inset-0 h-full w-full border-0 ${t.provider===`generic`?`bg-transparent`:`bg-[var(--paper-bg)]`}`,style:Iw(r,i)})}function Rw(e){let{html:t,origin:n,title:r,interacting:i,loaded:a,onLoaded:o,onFailed:s}=e,c=(0,J.useRef)(null),l=(0,J.useRef)({onLoaded:o,onFailed:s});return l.current={onLoaded:o,onFailed:s},(0,J.useEffect)(()=>{let e=!1;function n(n){let r=c.current?.contentWindow;if(!(!r||n.source!==r||!Me(n.data))){if(n.data.type===`ready`){let e={source:Ie,type:`render`,html:t};r.postMessage(e,`*`);return}e=!0,l.current.onLoaded()}}window.addEventListener(`message`,n);let r=window.setTimeout(()=>{e||l.current.onFailed()},Pw);return()=>{window.removeEventListener(`message`,n),window.clearTimeout(r)}},[t]),(0,Q.jsx)(`iframe`,{ref:c,"data-testid":`web-frame`,title:r,src:`${n}/w`,sandbox:Ke,referrerPolicy:`no-referrer`,className:`absolute inset-0 h-full w-full border-0 bg-white`,style:Iw(i,a)})}var zw=(0,J.memo)(Fw),Bw=(0,J.createContext)(null),Vw=Bw.Provider;function Hw(){let e=(0,J.useContext)(Bw);if(!e)throw Error(`Shape views render under <Scene>.`);return e}var Uw={arrow:{geometry:(e,t)=>(0,Q.jsx)(Zx,{shape:e,interactive:t.interactive,erasing:t.erasing,onPointerDown:t.handlers.onShapePointerDown,onBeginEdit:t.handlers.onBeginEdit,onHover:t.handlers.onHover},e.id),overlay:(e,t)=>{let n=t.edit.kind===`text`,r=(e.label??``).length>0||n,i=(e.startLabel??``).length>0||(e.endLabel??``).length>0;return!r&&!i||!n&&!t.legible(e.fontSize??20)?null:(0,Q.jsxs)(J.Fragment,{children:[r&&(0,Q.jsx)(iw,{shape:e,isEditing:n,interactive:t.interactive,erasing:t.erasing,onPointerDown:t.handlers.onShapePointerDown,onLabelPointerDown:t.handlers.onLabelPointerDown,onBeginEdit:t.handlers.onBeginEdit,onCommitText:t.handlers.onCommitText,onHover:t.handlers.onHover}),i&&(0,Q.jsx)(sw,{shape:e,erasing:t.erasing})]},`label-${e.id}`)}},image:{geometry:(e,t)=>(0,Q.jsx)($x,{shape:e,interactive:t.interactive,cropping:t.edit.kind===`crop`,erasing:t.erasing,onPointerDown:t.handlers.onShapePointerDown,onBeginCrop:t.handlers.onBeginCrop,onHover:t.handlers.onHover},e.id)},icon:{geometry:(e,t)=>(0,Q.jsx)(uS,{shape:e,interactive:t.interactive,erasing:t.erasing,onPointerDown:t.handlers.onShapePointerDown,onBeginEdit:t.handlers.onBeginEdit,onHover:t.handlers.onHover},e.id),overlay:(e,t)=>{let n=t.edit.kind===`text`;return e.label.length===0&&!n||!n&&!t.legible(e.fontSize)?null:(0,Q.jsx)(xw,{shape:e,isEditing:n,interactive:t.interactive,erasing:t.erasing,onPointerDown:t.handlers.onShapePointerDown,onBeginEdit:t.handlers.onBeginEdit,onCommitText:t.handlers.onCommitText,onHover:t.handlers.onHover},`label-${e.id}`)}},rectangle:{geometry:(e,t)=>(0,Q.jsx)(Ux,{shape:e,interactive:t.interactive,selected:t.selected,erasing:t.erasing,onPointerDown:t.handlers.onShapePointerDown,onBeginEdit:t.handlers.onBeginEdit,onHover:t.handlers.onHover},e.id),overlay:(e,t)=>{let n=t.edit.kind===`text`;return e.label.length===0&&!n&&!e.titleIcon||!n&&!t.legible(e.fontSize)?null:(0,Q.jsx)(KC,{shape:e,isEditing:n,interactive:t.interactive,erasing:t.erasing,onPointerDown:t.handlers.onShapePointerDown,onBeginEdit:t.handlers.onBeginEdit,onCommitText:t.handlers.onCommitText,onMeasure:t.handlers.onMeasureLabel,onHover:t.handlers.onHover},`label-${e.id}`)}},sticky:{geometry:(e,t)=>(0,Q.jsx)(Gx,{shape:e,interactive:t.interactive,erasing:t.erasing,onPointerDown:t.handlers.onShapePointerDown,onBeginEdit:t.handlers.onBeginEdit,onHover:t.handlers.onHover},e.id),overlay:(e,t)=>{let n=t.edit.kind===`text`;return!n&&!t.legible(e.fontSize)?null:(0,Q.jsx)(JC,{shape:e,isEditing:n,interactive:t.interactive,erasing:t.erasing,onBeginEdit:t.handlers.onBeginEdit,onCommitText:t.handlers.onCommitText,onMeasure:t.handlers.onMeasureLabel},`label-${e.id}`)}},draw:{geometry:(e,t)=>(0,Q.jsx)(tS,{shape:e,interactive:t.interactive,erasing:t.erasing,onPointerDown:t.handlers.onShapePointerDown,onHover:t.handlers.onHover},e.id)},polygon:{geometry:(e,t)=>(0,Q.jsx)(rS,{shape:e,interactive:t.interactive,erasing:t.erasing,onPointerDown:t.handlers.onShapePointerDown,onBeginVertexEdit:t.handlers.onBeginVertexEdit,onHover:t.handlers.onHover},e.id)},line:{geometry:(e,t)=>(0,Q.jsx)(aS,{shape:e,interactive:t.interactive,erasing:t.erasing,onPointerDown:t.handlers.onShapePointerDown,onBeginEdit:t.handlers.onBeginEdit,onHover:t.handlers.onHover},e.id),overlay:(e,t)=>{let n=t.edit.kind===`text`;return(e.label??``).length===0&&!n||!n&&!t.legible(e.fontSize??20)?null:(0,Q.jsx)(lw,{shape:e,isEditing:n,interactive:t.interactive,erasing:t.erasing,onPointerDown:t.handlers.onShapePointerDown,onLabelPointerDown:t.handlers.onLabelPointerDown,onBeginEdit:t.handlers.onBeginEdit,onCommitText:t.handlers.onCommitText,onHover:t.handlers.onHover},`label-${e.id}`)}},table:{geometry:(e,t)=>(0,Q.jsx)(Dw,{shape:e,interactive:t.interactive,erasing:t.erasing,onPointerDown:t.handlers.onShapePointerDown,onBeginEditCell:t.handlers.onBeginEditCell,onHover:t.handlers.onHover},e.id),overlay:(e,t)=>{let n=t.edit;return n.kind!==`table-cell`&&!t.legible(e.fontSize)?null:(0,Q.jsx)(Ow,{shape:e,editingCell:n.kind===`table-cell`?{row:n.row,col:n.col}:null,erasing:t.erasing,onCommitCell:t.handlers.onCommitCell,onMeasureCell:t.handlers.onMeasureCell},`cells-${e.id}`)}},chart:{geometry:(e,t)=>(0,Q.jsx)(mS,{shape:e,interactive:t.interactive,erasing:t.erasing,onPointerDown:t.handlers.onShapePointerDown,onBeginEdit:t.handlers.onBeginEdit,onHover:t.handlers.onHover},e.id),overlay:(e,t)=>t.chromeReadOnly||typeof e.code!=`string`||e.code.trim().length===0?null:(0,Q.jsx)(Sw,{shape:e,interactive:t.interactive,erasing:t.erasing,codeStale:t.codeStale,onEditCode:t.handlers.onEditCode,onHover:t.handlers.onHover},`code-${e.id}`)},control:{geometry:(e,t)=>(0,Q.jsx)(bS,{shape:e,interactive:t.interactive,editingField:t.edit.kind===`text`?t.edit.field:null,erasing:t.erasing,onPointerDown:t.handlers.onShapePointerDown,onBeginEdit:t.handlers.onBeginEdit,onHover:t.handlers.onHover},e.id),overlay:(e,t)=>{let n=t.edit;return e.kind===`lifeline`?(0,Q.jsx)(gw,{shape:e,isEditing:n.kind===`text`,interactive:t.interactive,erasing:t.erasing,onPointerDown:t.handlers.onShapePointerDown,onBeginEdit:t.handlers.onBeginEdit,onCommitText:t.handlers.onCommitText,onMeasure:t.handlers.onMeasureLifelineWidth,onHover:t.handlers.onHover},`label-${e.id}`):n.kind===`text`?(0,Q.jsx)(fw,{shape:e,field:n.field,onCommitText:t.handlers.onCommitText},`label-${e.id}`):null}},web:{overlay:(e,t)=>(0,Q.jsx)(zw,{shape:e,interactive:t.interactive,interacting:t.edit.kind===`interact`,erasing:t.erasing,onPointerDown:t.handlers.onShapePointerDown,onBeginEdit:t.handlers.onBeginEdit,onHover:t.handlers.onHover},e.id)},text:{overlay:(e,t)=>(0,Q.jsx)(yw,{shape:e,isEditing:t.edit.kind===`text`,interactive:t.interactive,erasing:t.erasing,onPointerDown:t.handlers.onShapePointerDown,onBeginEdit:t.handlers.onBeginEdit,onCommitText:t.handlers.onCommitText,onHover:t.handlers.onHover},e.id)},figure:{geometry:(e,t)=>(0,Q.jsx)(Jx,{shape:e,interactive:t.interactive,erasing:t.erasing,onPointerDown:t.handlers.onShapePointerDown,onBeginEdit:t.handlers.onBeginEdit,onHover:t.handlers.onHover},e.id),overlay:(e,t)=>{if(t.hideFigures&&!t.nested)return null;let n=t.edit;return(0,Q.jsx)(tw,{shape:e,isEditing:n.kind===`text`,interactive:t.interactive,readOnly:t.chromeReadOnly,erasing:t.erasing,editingLane:n.kind===`lane`?n.lane:null,codeStale:t.codeStale,animated:t.animated,nested:t.nested,onPointerDown:t.handlers.onShapePointerDown,onBeginEdit:t.handlers.onBeginEdit,onBeginEditLane:t.handlers.onBeginEditLane,onCommitText:t.handlers.onCommitText,onCommitLane:t.handlers.onCommitLane,onEditNotes:t.handlers.onEditNotes,onAnimate:t.handlers.onAnimate,onEditCode:t.handlers.onEditCode,onPresent:t.handlers.onPresent,onHover:t.handlers.onHover},`label-${e.id}`)}}};function Ww(e,t){return Uw[e.type].geometry?.(e,t)??null}function Gw(e,t){return Uw[e.type].overlay?.(e,t)??null}var Kw={className:`absolute overflow-visible`,width:1,height:1,style:{pointerEvents:`none`}},qw=256;function Jw(e){let{shapes:t,editSession:n,interactive:r,erasingIds:i,selectedIds:a,staleCodeFrames:o,animatedSlides:s,nestedIds:c,readOnly:l,zoom:u,hideFigures:d}=e,f=Hw(),p=nT(),m=e=>zu(e,u),h=l||d;function g(e){return{edit:Ce(n,e.id),interactive:r,erasing:i.has(e.id),selected:a.has(e.id),codeStale:o.has(e.id),animated:s.has(e.id),nested:c.has(e.id),hideFigures:d,chromeReadOnly:h,legible:m,handlers:f}}let _=[],v=[],y=null;for(let e of t){let t=g(e),n=e.type===`figure`?null:Ww(e,t);n&&(y||(y={ids:[],nodes:[]},_.push({group:v.length}),v.push(y)),y.ids.push(e.id),y.nodes.push(n));let r=Gw(e,t);r&&(y=null,_.push({overlay:r}))}let b=p(v.map(e=>e.ids));return(0,Q.jsx)(Q.Fragment,{children:_.map(e=>`overlay`in e?e.overlay:(0,Q.jsx)(`svg`,{...Kw,children:v[e.group].nodes},`chunk-${b[e.group]}`))})}function Yw(e,t,n){return e===t||n.every(n=>e.has(n.id)===t.has(n.id))}var Xw={shapes:`reference`,editSession:`editSession`,interactive:`reference`,erasingIds:`membership`,selectedIds:`membership`,staleCodeFrames:`membership`,animatedSlides:`membership`,nestedIds:`membership`,readOnly:`reference`,zoom:`reference`,hideFigures:`reference`},Zw=Object.keys(Xw);function Qw(e,t){for(let n of Zw){let r=Xw[n];if(r===`reference`){if(e[n]!==t[n])return!1;continue}if(r===`membership`){if(!Yw(e[n],t[n],t.shapes))return!1;continue}if(e.editSession!==t.editSession){let n=be(e.editSession),r=be(t.editSession);if(t.shapes.some(e=>e.id===n||e.id===r))return!1}}return!0}var $w=(0,J.memo)(Jw,Qw);function eT(e){let t=(0,J.useRef)([]);return(0,J.useMemo)(()=>{let n=aT(t.current,e);return t.current=n,n},[e])}function tT(e,t){let n=new Map,r=new Set,i=e.next;return{keys:t.map(t=>{let a;for(let n of t){let t=e.keyOf.get(n);if(t!==void 0&&!r.has(t)){a=t;break}}a??=String(i++),r.add(a);for(let e of t)n.set(e,a);return a}),state:{keyOf:n,next:i}}}function nT(){let e=(0,J.useRef)({keyOf:new Map,next:0});return t=>{let{keys:n,state:r}=tT(e.current,t);return e.current=r,n}}function rT(e){let t=(0,J.useRef)({keyOfRun:new WeakMap,keyOfId:new Map,next:0});return(0,J.useMemo)(()=>{let n=t.current,r=new Set,i=e.map(e=>{let t=n.keyOfRun.get(e);if(!(t===void 0||r.has(t)))return r.add(t),t});e.forEach((e,t)=>{if(i[t]!==void 0)return;let a;for(let t of e){let e=n.keyOfId.get(t.id);if(e!==void 0&&!r.has(e)){a=e;break}}a??=String(n.next++),r.add(a),i[t]=a,n.keyOfRun.set(e,a);for(let t of e)n.keyOfId.set(t.id,a)});let a=e.reduce((e,t)=>e+t.length,0);return n.keyOfId.size>a*2+qw&&(n.keyOfId=new Map,e.forEach((e,t)=>{for(let r of e)n.keyOfId.set(r.id,i[t])})),i},[e])}var iT=qw/8;function aT(e,t){let n=new Map;for(let t of e)n.set(t[0],t);let r=[],i=[],a=()=>{for(let e=0;e<i.length;e+=qw)r.push(i.slice(e,e+qw));i=[]},o=0;for(;o<t.length;){let e=n.get(t[o]);if(e&&oT(e,t,o)){i.length>0&&i.length<iT&&i.length+e.length<=qw?(r.push([...i,...e]),i=[]):(a(),r.push(e)),o+=e.length;continue}i.push(t[o]),o+=1,i.length===qw&&a()}return a(),r}function oT(e,t,n){if(n+e.length>t.length)return!1;for(let r=0;r<e.length;r+=1)if(e[r]!==t[n+r])return!1;return!0}function sT(e,t,n){let r=(0,J.useRef)(null);return(0,J.useMemo)(()=>{if(n&&r.current!==null)return r.current;let i=e(t);return r.current=i,i},[e,t,n])}var cT=e=>new Set(rl(e).keys());function lT(e){let{shapes:t,draft:n,lineDraft:r,editSession:i,interactive:a,bindTarget:o,snapDot:s,onShapePointerDown:c,onLabelPointerDown:l,onBeginEdit:u,onBeginEditCell:d,onBeginEditLane:f,onBeginCrop:p,onBeginVertexEdit:m,onCommitText:h,onCommitCell:g,onCommitLane:_,onMeasureCell:v,onMeasureLabel:y,onMeasureLifelineWidth:b,onHover:x,zoom:S,hideFigures:C}=e;xy(`Scene`);let w=W(),T=(0,J.useCallback)(e=>{let t=w.getState();t.viewMode||t.setNotesEditorId(e)},[w]),E=(0,J.useCallback)(e=>{let t=w.getState();t.viewMode||t.setAnimateSlideId(e)},[w]),D=(0,J.useCallback)(e=>{let t=w.getState();t.viewMode||(t.setSelectedIds(new Set([e])),t.setCodeOpen(!0))},[w]),O=(0,J.useCallback)(e=>{let t=w.getState(),n=In(t.shapes).findIndex(t=>t.id===e);n<0||t.setPresentingIndex(n)},[w]),k=U(e=>e.viewMode),A=U(e=>e.erasingIds),j=U(e=>e.selectedIds),M=U(e=>e.shapes),N=U(e=>e.transforming),P=sT(ss,M,N),F=sT(cT,M,N),I=sT(Sr,M,N),L=(0,J.useMemo)(()=>C?Sr(t):I,[C,t,I]),ee=o?Qe(t,o.id):void 0,R=t.filter(e=>e.type===`figure`&&(!C||L.has(e.id))),z=eT(t),B=rT(z),V=(0,J.useMemo)(()=>({onShapePointerDown:c,onLabelPointerDown:l,onBeginEdit:u,onBeginEditCell:d,onBeginEditLane:f,onBeginCrop:p,onBeginVertexEdit:m,onCommitText:h,onCommitCell:g,onCommitLane:_,onMeasureCell:v,onMeasureLabel:y,onMeasureLifelineWidth:b,onHover:x,onEditNotes:T,onAnimate:E,onEditCode:D,onPresent:O}),[c,l,u,d,f,p,m,h,g,_,v,y,b,x,T,E,D,O]),te=e=>({...dT,interactive:a,erasing:A.has(e.id),handlers:V}),ne={...dT,handlers:V};return(0,Q.jsxs)(Vw,{value:V,children:[(0,Q.jsx)(`svg`,{...Kw,children:R.map(e=>Ww(e,te(e)))}),z.map((e,t)=>(0,Q.jsx)($w,{shapes:e,editSession:i,interactive:a,erasingIds:A,selectedIds:j,staleCodeFrames:P,animatedSlides:F,nestedIds:L,readOnly:k,zoom:S,hideFigures:C??!1},B[t])),(0,Q.jsxs)(`svg`,{...Kw,children:[n&&uT(n,ne),r&&(0,Q.jsxs)(Q.Fragment,{children:[Ww(r,ne),r.points.slice(0,-1).map((e,t)=>(0,Q.jsx)(`circle`,{cx:e.x,cy:e.y,r:4,fill:`#fff`,stroke:`var(--canvas-selection)`,strokeWidth:1.5,style:{pointerEvents:`none`}},t))]}),ee&&o&&(0,Q.jsx)(wx,{shape:ee,point:o.point}),s&&(0,Q.jsx)(`circle`,{"data-testid":`snap-dot`,cx:s.x,cy:s.y,r:5,fill:`var(--canvas-selection)`,stroke:`#fff`,strokeWidth:1.5,style:{pointerEvents:`none`}})]})]})}function uT(e,t){return(e.type===`chart`||e.type===`control`)&&!s_(e)?(0,Q.jsx)(fT,{shape:e}):Ww(e,t)}var dT={edit:{kind:`none`},interactive:!1,erasing:!1,selected:!1,codeStale:!1,animated:!1,nested:!1,hideFigures:!1,chromeReadOnly:!1,legible:()=>!0};function fT(e){let{shape:t}=e;return(0,Q.jsx)(`rect`,{x:Math.min(t.x,t.x+t.width),y:Math.min(t.y,t.y+t.height),width:Math.abs(t.width),height:Math.abs(t.height),rx:4,fill:`none`,stroke:`var(--canvas-origin)`,strokeWidth:1.5,strokeDasharray:`6 4`,style:{pointerEvents:`none`}})}var pT=(0,J.memo)(lT),mT=`var(--canvas-origin)`;function hT(e){let t=e.shape,n=t.x,r=t.y,i=t.width,a=t.height;return typeof n!=`number`||typeof r!=`number`||typeof i!=`number`||typeof a!=`number`||!Number.isFinite(n)||!Number.isFinite(r)||!Number.isFinite(i)||!Number.isFinite(a)||i<=0||a<=0?null:{x:n,y:r,width:i,height:a}}function gT(){let e=U(e=>e.opaqueShapes);if(e.length===0)return null;let t=e.map(e=>({id:e.id,bounds:hT(e)})).filter(e=>e.bounds!==null);return t.length===0?null:(0,Q.jsx)(`svg`,{className:`absolute overflow-visible`,width:1,height:1,style:{pointerEvents:`none`},"data-testid":`opaque-shapes`,"aria-hidden":!0,children:t.map(e=>(0,Q.jsx)(`rect`,{x:e.bounds.x,y:e.bounds.y,width:e.bounds.width,height:e.bounds.height,rx:8,fill:mT,fillOpacity:.04,stroke:mT,strokeOpacity:.35,strokeWidth:1.5,strokeDasharray:`4 6`,strokeLinecap:`round`,strokeLinejoin:`round`},e.id))})}var _T=14,vT=4,yT=14,bT=`var(--canvas-origin)`;function xT(e){let{position:t,onDragStart:n,onHoverChange:r}=e;return(0,Q.jsxs)(`button`,{type:`button`,"data-testid":`quick-connect`,"aria-label":`Add connected node`,onPointerDown:e=>{e.stopPropagation(),n(e)},onPointerEnter:()=>r(!0),onPointerLeave:()=>r(!1),className:`group absolute flex h-[22px] w-[22px] -translate-x-1/2 -translate-y-1/2 items-center justify-center opacity-60 transition-opacity hover:opacity-100`,style:{left:t.x,top:t.y,cursor:`grab`,pointerEvents:`all`},children:[(0,Q.jsx)(`span`,{className:`absolute inset-0 rounded-full bg-[var(--canvas-selection)]/25 opacity-0 transition-opacity group-hover:opacity-100`}),(0,Q.jsx)(`span`,{className:`h-[7px] w-[7px] rounded-full bg-[var(--canvas-selection)]`})]})}function ST(e){let{source:t,name:n,bounds:r}=e;return Gi(t)?(0,Q.jsx)(`image`,{"data-testid":`connect-ghost-icon`,href:Ki().assetIconUrl(t,n),x:r.x,y:r.y,width:r.width,height:r.height,opacity:.5}):(0,Q.jsx)(CT,{name:n,bounds:r})}function CT(e){let{name:t,bounds:n}=e,r=El(t);return r?(0,Q.jsx)(kl,{node:r,at:{x:n.x,y:n.y},size:n.width,stroke:bT,strokeWidth:ct(3,n.width),"data-testid":`connect-ghost-icon`}):null}function wT(e,t,n=6){return $r(Ur(e,n),Br(e),t)}function TT(e){let t=(0,J.useRef)({inputs:e,answers:new Map});return e.some((e,n)=>e!==t.current.inputs[n])&&(t.current={inputs:e,answers:new Map}),t.current.answers}function ET(e){let{shape:t,viewport:n,onConnectingChange:r}=e,i=W(),a=H().measurement,o=U(e=>e.shapes),s=U(e=>e.style),c=s.strokeWidth,l=`strokeWidth`in t?t.strokeWidth:c,u=U(e=>e.coarsePointer),[d,f]=(0,J.useState)(null),[p,m]=(0,J.useState)(null),[h,g]=(0,J.useState)(null);(0,J.useEffect)(()=>{if(u)return;let e=0,t=null;function n(){e=0,t&&m(t)}function r(r){t={x:r.clientX,y:r.clientY},e===0&&(e=requestAnimationFrame(n))}return document.addEventListener(`pointermove`,r),()=>{document.removeEventListener(`pointermove`,r),e!==0&&cancelAnimationFrame(e)}},[u]),(0,J.useEffect)(()=>{if(!h)return;let e=h;function r(t){m({x:t.clientX,y:t.clientY}),Math.hypot(t.clientX-e.start.x,t.clientY-e.start.y)>vT&&!e.moved&&g({...e,moved:!0})}function o(r){Math.hypot(r.clientX-e.start.x,r.clientY-e.start.y)>vT?kf(i,nt({x:r.clientX,y:r.clientY},n),a):Of(i,Sf(t,e.direction),a),g(null),f(null)}function s(e){e.key===`Escape`&&(e.preventDefault(),g(null),f(null))}return window.addEventListener(`pointermove`,r),window.addEventListener(`pointerup`,o),window.addEventListener(`keydown`,s),()=>{window.removeEventListener(`pointermove`,r),window.removeEventListener(`pointerup`,o),window.removeEventListener(`keydown`,s)}},[h,n,i,a,t]);let _=!!h?.moved;(0,J.useEffect)(()=>(r(_),()=>r(!1)),[_,r]);let v=TT([o,n,t,a]),y=pa(t,a),{body:b,footprint:x}=y;if(Math.min(b.width,b.height)*n.zoom<24)return null;let S=b.width/2,C=b.height/2,w={x:b.x+S,y:b.y+C},T=_r(w,n),E={up:{x:0,y:-C},down:{x:0,y:x.y+x.height-w.y},left:{x:-S,y:0},right:{x:S,y:0}};function D(e){let t=E[e],r=_r(y.toWorld({x:w.x+t.x,y:w.y+t.y}),n),i=r.x-T.x,a=r.y-T.y,o=Math.hypot(i,a)||1;return{x:r.x+i/o*_T,y:r.y+a/o*_T}}function O(e){let r=D(e),i=nt(r,n),s=yT/n.zoom;return o.some(e=>{if(e.id===t.id||e.type!==`rectangle`&&e.type!==`icon`&&e.type!==`image`&&e.type!==`sticky`||!Ze(e)&&!Wr(i,Ur(Bt(e),s)))return!1;let o=Cn(e,a),c=_r({x:o.x,y:o.y},n),l=Math.max(c.x,Math.min(r.x,c.x+o.width*n.zoom)),u=Math.max(c.y,Math.min(r.y,c.y+o.height*n.zoom));return Math.hypot(r.x-l,r.y-u)<yT})}function k(e){let t=v.get(e);if(t!==void 0)return t;let n=O(e);return v.set(e,n),n}let A=null;if(p){let e=y.toLocal(nt(p,n)),t=e.x-w.x,r=e.y-w.y;A=Math.abs(t)/(S||1)>=Math.abs(r)/(C||1)?t>=0?`right`:`left`:r>=0?`down`:`up`}A&&k(A)&&(A=null);function j(e,r){let i=_r({x:e.x,y:e.y},n),o={x:e.x+e.width/2,y:e.y+e.height/2},u=wT(b,o),d=wT(e,w),f=d;if(r){let e=He(r.target,r.drop,a);u=wT(b,Ue(r.target,e,a)),d=Le(r.target,e,w,void 0,a),f=`precise`in e&&e.precise?We(r.target,r.drop,a):d}let p=_r(u,n),m=_r(d,n),h=Math.atan2(m.y-p.y,m.x-p.x),g=sr(c),_=Mr(u,d),v=c*n.zoom,y=(e,t,r,i)=>gt(r,e,t,Sn(g,r,_)*n.zoom).map((e,t)=>(0,Q.jsx)(`path`,{"data-testid":t===0?i:void 0,d:e.d,fill:e.fill===`solid`?bT:`none`,stroke:bT,strokeWidth:v,strokeLinecap:`round`,strokeLinejoin:`round`},`${i??`head`}-${t}`)),x=t.type===`rectangle`?t.kind:`rectangle`,S=t.type===`rectangle`?t.corner:void 0,C=t.type===`rectangle`?{x:t.flipX,y:t.flipY}:void 0,T={x:i.x,y:i.y,width:e.width*n.zoom,height:e.height*n.zoom},E=T.x+T.width/2,D=T.y+T.height/2;return(0,Q.jsxs)(`svg`,{className:`pointer-events-none absolute inset-0 h-full w-full`,style:{overflow:`visible`},children:[r?(0,Q.jsx)(`rect`,{"data-testid":`connect-bind-highlight`,x:T.x-4,y:T.y-4,width:T.width+8,height:T.height+8,transform:r.rotation?`rotate(${r.rotation} ${E} ${D})`:void 0,rx:10,fill:`none`,stroke:`var(--canvas-selection)`,strokeWidth:2,strokeDasharray:`4 4`}):t.type===`icon`?(0,Q.jsx)(ST,{source:t.source,name:t.name,bounds:T}):(0,Q.jsx)(`path`,{"data-testid":`connect-ghost-node`,d:Ft(x,T,S,C),fill:`none`,stroke:bT,strokeWidth:l*n.zoom,strokeLinejoin:`round`}),(0,Q.jsx)(`line`,{"data-testid":`connect-ghost-link`,x1:p.x,y1:p.y,x2:m.x,y2:m.y,stroke:bT,strokeWidth:v,strokeLinecap:`round`}),s.endArrow&&y(m,h,s.endHead??`arrow`,`connect-ghost-head`),s.startArrow&&y(p,h+Math.PI,s.startHead??`arrow`),r&&(0,Q.jsx)(`circle`,{"data-testid":`connect-bind-dot`,cx:_r(f,n).x,cy:_r(f,n).y,r:5,fill:`var(--canvas-selection)`,stroke:`#fff`,strokeWidth:1.5})]})}function M(e){let t=_r(wT(b,e),n),r=_r(e,n);return(0,Q.jsxs)(`svg`,{className:`pointer-events-none absolute inset-0 h-full w-full`,style:{overflow:`visible`},children:[(0,Q.jsx)(`line`,{"data-testid":`connect-ghost-link`,x1:t.x,y1:t.y,x2:r.x,y2:r.y,stroke:bT,strokeWidth:c*n.zoom,strokeLinecap:`round`}),(0,Q.jsx)(`circle`,{"data-testid":`connect-drag-dot`,cx:r.x,cy:r.y,r:5,fill:bT})]})}let N=null;if(h?.moved&&p){let e=nt(p,n),t=Af(i,e,a);N=t?j(t.type===`icon`&&t.label?Cn(t,a):G(t,a),{rotation:t.type===`icon`&&t.label?0:cr(t),target:t,drop:e}):M(e)}else if(d){let e=jf(i,Sf(t,d));e&&(N=j({x:e.x+(b.x-x.x),y:e.y+(b.y-x.y),width:b.width,height:b.height}))}let P=h?h.direction:A,F=u?h?[h.direction]:[`up`,`down`,`left`,`right`].filter(e=>!k(e)):P?[P]:[];return(0,Q.jsxs)(Q.Fragment,{children:[N,!_&&F.map(e=>(0,Q.jsx)(xT,{position:D(e),onDragStart:t=>g({direction:e,start:{x:t.clientX,y:t.clientY},moved:!1}),onHoverChange:t=>f(t?e:null)},e))]})}function DT(e,t,n){let r=St(e),i=[];for(let e=0;e<r.length-1;e+=1){let a=r[e],o=r[e+1];if((Math.abs(o.x-a.x)+Math.abs(o.y-a.y))*t<=20)continue;let s={x:(a.x+o.x)/2,y:(a.y+o.y)/2};if(n&&Math.abs(s.x-n.x)<1&&Math.abs(s.y-n.y)<1)continue;let c=Math.abs(o.y-a.y)<=Math.abs(o.x-a.x);i.push({index:e,mid:s,axis:c?`y`:`x`})}return i}function OT(e){let{shape:t,viewport:n,onHandlePointerDown:r,onElbowSegmentPointerDown:i,onBendReset:a}=e,o=_r({x:t.x,y:t.y},n),s=_r({x:t.x2,y:t.y2},n),c=t.bendStyle===`elbow`,l=c?ut(t):null,u=l!==null&&l.span*n.zoom>20,d=c?DT(t,n.zoom,l):[];return(0,Q.jsxs)(Q.Fragment,{children:[c?u&&l&&(0,Q.jsx)(Xi,{testId:`elbow-mid-handle`,position:_r(l,n),cursor:l.axis===`x`?`ew-resize`:`ns-resize`,round:!0,onPointerDown:e=>r(t.id,`bend`,e),onDoubleClick:()=>a(t.id)}):(0,Q.jsx)(Xi,{testId:`arrow-handle-bend`,position:_r(Jt(t),n),cursor:`grab`,round:!0,onPointerDown:e=>r(t.id,`bend`,e),onDoubleClick:()=>a(t.id)}),d.map(e=>(0,Q.jsx)(Xi,{testId:`elbow-segment-handle-${e.index}`,position:_r(e.mid,n),cursor:e.axis===`x`?`ew-resize`:`ns-resize`,round:!0,onPointerDown:n=>i(t.id,e.index,n),onDoubleClick:()=>a(t.id)},e.index)),(0,Q.jsx)(Xi,{testId:`arrow-handle-start`,position:o,cursor:`move`,round:!0,onPointerDown:e=>r(t.id,`start`,e)}),(0,Q.jsx)(Xi,{testId:`arrow-handle-end`,position:s,cursor:`move`,round:!0,onPointerDown:e=>r(t.id,`end`,e)})]})}var kT=[{handle:`nw`,corner:`border-t-[3px] border-l-[3px]`,cursor:`nwse-resize`},{handle:`ne`,corner:`border-t-[3px] border-r-[3px]`,cursor:`nesw-resize`},{handle:`sw`,corner:`border-b-[3px] border-l-[3px]`,cursor:`nesw-resize`},{handle:`se`,corner:`border-b-[3px] border-r-[3px]`,cursor:`nwse-resize`}],AT=[{handle:`n`,cursor:`ns-resize`},{handle:`s`,cursor:`ns-resize`},{handle:`w`,cursor:`ew-resize`},{handle:`e`,cursor:`ew-resize`}];function jT(e){let{shape:t,viewport:n,onCrop:r}=e,i=ea(t),a=_r({x:i.x+i.width/2,y:i.y+i.height/2},n),o=i.width*n.zoom,s=i.height*n.zoom;return(0,Q.jsxs)(`div`,{className:`pointer-events-none absolute`,style:{left:a.x,top:a.y,width:o,height:s,transform:`translate(-50%, -50%) rotate(${cr(t)}deg)`},children:[(0,Q.jsx)(`div`,{className:`absolute inset-0 border border-[var(--canvas-selection)]`}),kT.map(e=>{let n=ra(e.handle,o,s);return(0,Q.jsx)(`div`,{"data-testid":`crop-${e.handle}`,onPointerDown:n=>r(t.id,e.handle,n),className:`absolute h-4 w-4 -translate-x-1/2 -translate-y-1/2 ${la} ${e.corner}`,style:{left:n.x,top:n.y,borderColor:`var(--canvas-selection)`,cursor:e.cursor,pointerEvents:`all`}},e.handle)}),AT.map(e=>{let n=ra(e.handle,o,s),i=e.handle===`w`||e.handle===`e`;return(0,Q.jsx)(`div`,{"data-testid":`crop-${e.handle}`,onPointerDown:n=>r(t.id,e.handle,n),className:`absolute -translate-x-1/2 -translate-y-1/2 rounded bg-[var(--canvas-selection)] ${la} ${i?`h-6 w-1`:`h-1 w-6`}`,style:{left:n.x,top:n.y,cursor:e.cursor,pointerEvents:`all`}},e.handle)})]})}function MT(e){let{bounds:t,rotation:n,viewport:r,onGroupHandlePointerDown:i,onRotate:a,showHandles:o,outlined:s,isGroup:c,titledTop:l}=e,u=U(e=>e.coarsePointer),d=_r({x:t.x,y:t.y},r),f=t.width*r.zoom,p=t.height*r.zoom,m=Math.min(f,p)<24?6:0,h=Math.min(f,p)<16,g=h?ua.filter(e=>e.handle===`nw`||e.handle===`se`):ua,_=l&&!n?$i(r.zoom):void 0,v=(e,t)=>n?ia(e,n):t;return(0,Q.jsxs)(`div`,{className:`pointer-events-none absolute`,style:{left:d.x,top:d.y,width:f,height:p,transform:n?`rotate(${n}deg)`:void 0},children:[(0,Q.jsx)(`div`,{"data-testid":`group-box`,"data-rotation":n?Math.round(n*100)/100:void 0,className:`absolute inset-0 border-[1.5px] ${c?`border-dashed border-[var(--canvas-group-selection)]`:`border-[var(--canvas-selection)]`} ${s?``:`invisible`}`}),o&&(0,Q.jsxs)(Q.Fragment,{children:[!h&&(0,Q.jsx)(oa,{testId:`group-rotate-handle`,position:{x:f+da(),y:p+da()},onPointerDown:a}),!u&&aa.map(e=>(0,Q.jsx)(na,{testId:`group-resize-${e.handle}`,edge:e.handle,cursor:v(e.handle,e.cursor),along:e.handle===`n`||e.handle===`s`?f:p,across:e.handle===`n`||e.handle===`s`?p:f,outwardLimit:e.handle===`n`?_:void 0,onPointerDown:t=>i(e.handle,t)},e.handle)),g.map(e=>(0,Q.jsx)(Xi,{testId:`group-resize-${e.handle}`,position:ra(e.handle,f,p,m),cursor:v(e.handle,e.cursor),minHitTop:_===void 0||!e.handle.startsWith(`n`)?void 0:-_,onPointerDown:t=>i(e.handle,t)},e.handle))]})]})}function NT(){let e=(0,J.useRef)(null),t=(0,J.useCallback)(t=>{let n=e.current;n&&(e.current=null,n.teardown(),n.callbacks.onEnd(t))},[]),n=(0,J.useCallback)((n,r)=>{t(`replace`);let i=n.pointerId;function a(e){e.pointerId===i&&r.onMove(e)}function o(e){e.pointerId===i&&t(e.type===`pointercancel`?`cancel`:`up`)}window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o),window.addEventListener(`pointercancel`,o);let s=Yi(()=>t(`deactivate`));function c(){window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,o),s()}e.current={callbacks:r,teardown:c};try{r.onStart?.()}catch(t){throw e.current=null,c(),t}},[t]);return(0,J.useEffect)(()=>()=>t(`unmount`),[t]),n}var PT=2;function FT(e){let{shape:t,viewport:n,onLaneAdd:r,onLaneDelete:i,onLaneEdit:a}=e,{store:o,history:s}=H(),c=NT(),l=t.lanes&&t.lanes.length>0?t.lanes:rs,u=is(t.kind),d=n.zoom,f=_r({x:t.x,y:t.y},n),p=30*d,m=u?t.width:t.height,h=Xo(l.length,m,t.laneSizes),g=e=>h[e]*d,_=e=>(h[e+1]-h[e])*d,v=`flex items-center justify-center rounded-md bg-[var(--chrome-popup)] text-[var(--chrome-fg-900)] shadow-sm ring-1 ring-[var(--chrome-ring)] hover:bg-[var(--chrome-hover)]`;function y(e,n){n.stopPropagation(),n.preventDefault();let r=u?n.clientX:n.clientY,i=$o(l.length,t.laneSizes);c(n,{onStart:s.beginTransaction,onMove(n){let a=o.getState(),s=Qe(a.shapes,t.id);if(s?.type!==`figure`)return;let c=u?s.width:s.height,l=((u?n.clientX:n.clientY)-r)/a.viewport.zoom,d=Zo(i,e-1,l/c);a.replaceShape({...s,laneSizes:d})},onEnd(){s.endTransaction()}})}return(0,Q.jsxs)(Q.Fragment,{children:[l.map((e,n)=>(0,Q.jsx)(`div`,{"data-testid":`lane-gutter-hover`,"data-index":n,onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>{e.stopPropagation(),a(t.id,n)},className:`group absolute`,style:u?{left:f.x+g(n),top:f.y+3,width:_(n),height:Math.max(0,p-3),pointerEvents:`all`}:{left:f.x+3,top:f.y+g(n),width:Math.max(0,p-3),height:_(n),pointerEvents:`all`},children:l.length>PT&&(0,Q.jsx)(`button`,{type:`button`,"data-testid":`lane-delete`,"data-index":n,onClick:()=>i(t.id,n),className:`${v} absolute h-5 w-5 opacity-0 transition-opacity group-hover:opacity-100`,style:u?{top:p/2-3,right:8,transform:`translateY(-50%)`}:{left:p/2-3,top:8,transform:`translateX(-50%)`},children:(0,Q.jsx)(Cc,{size:12,stroke:2})})},n)),h.slice(1,-1).map((e,n)=>(0,Q.jsx)(`div`,{"data-testid":`lane-resize`,"data-index":n,onPointerDown:e=>y(n+1,e),className:`absolute`,style:u?{left:f.x+e*d-4,top:f.y,width:8,height:t.height*d,cursor:`col-resize`,pointerEvents:`all`}:{left:f.x,top:f.y+e*d-4,width:t.width*d,height:8,cursor:`row-resize`,pointerEvents:`all`}},`resize-${n}`)),(0,Q.jsx)(`button`,{type:`button`,"data-testid":`lane-add`,onPointerDown:e=>e.stopPropagation(),onClick:()=>r(t.id),className:`${v} absolute h-6 w-6 ${u?`-translate-y-1/2`:`-translate-x-1/2`}`,style:u?{left:f.x+t.width*d+10,top:f.y+p/2,pointerEvents:`all`}:{left:f.x+p/2,top:f.y+t.height*d+10,pointerEvents:`all`},children:(0,Q.jsx)(_c,{size:14,stroke:2})})]})}function IT(e){let{shape:t,viewport:n,onLineVertexPointerDown:r}=e;return(0,Q.jsx)(Q.Fragment,{children:t.points.map((e,i)=>(0,Q.jsx)(Xi,{testId:`line-vertex-${i}`,position:_r(e,n),cursor:`move`,round:!0,onPointerDown:e=>r(t.id,i,e)},i))})}var LT=[`n`,`e`,`s`,`w`];function RT(e){let{shape:t,viewport:n,onHandlePointerDown:r,onRotate:i,onDuplicate:a,showHandles:o,outlined:s}=e,c=ta(t),l=H().measurement,u=cr(t),d=Qi(t,c,n.zoom,l),f=_r({x:c.x,y:c.y},n),p=c.width*n.zoom,m=c.height*n.zoom,{edges:h,corners:g}=Zi(t),_=t.type!==`sticky`,v=U(e=>e.coarsePointer)&&g.length>0?[]:h,y=g.length>0&&Math.min(p,m)<24?6:0,b=Math.min(p,m)<16,x=b?g.filter(e=>e.handle===`nw`||e.handle===`se`):g,S=t.type===`figure`?$i(n.zoom):void 0;return(0,Q.jsxs)(`div`,{className:`pointer-events-none absolute`,style:{left:f.x,top:f.y,width:p,height:m,transform:u?`rotate(${u}deg)`:void 0,transformOrigin:`${d.x}px ${d.y}px`},children:[(0,Q.jsx)(`div`,{"data-testid":`selection-box`,className:`absolute inset-0 border-[1.5px] border-[var(--canvas-selection)] ${s?``:`invisible`}`}),o&&(0,Q.jsxs)(Q.Fragment,{children:[Mn(t)&&!b&&(0,Q.jsx)(oa,{testId:`rotate-handle`,position:{x:p+da(),y:m+da()},onPointerDown:i}),_&&v.map(e=>(0,Q.jsx)(na,{testId:`resize-${e.handle}`,edge:e.handle,cursor:ia(e.handle,u),along:e.handle===`n`||e.handle===`s`?p:m,across:e.handle===`n`||e.handle===`s`?m:p,inset:g.length===0?0:void 0,outwardLimit:e.handle===`n`?S:void 0,onPointerDown:n=>r(t.id,e.handle,n)},e.handle)),_&&x.map(e=>(0,Q.jsx)(Xi,{testId:`resize-${e.handle}`,position:ra(e.handle,p,m,y),cursor:ia(e.handle,u),minHitTop:S===void 0||!e.handle.startsWith(`n`)?void 0:-S,onPointerDown:n=>r(t.id,e.handle,n)},e.handle)),t.type===`sticky`&&LT.map(e=>(0,Q.jsx)(ca,{position:ra(e,p,m),onPointerDown:e=>a(t.id,e)},e))]})]})}var zT=14;function BT(e){let{shape:t,viewport:n,onInsertColumn:r,onDeleteColumn:i,onInsertRow:a,onDeleteRow:o}=e,{store:s,history:c}=H(),l=U(e=>e.tableSelection),u=U(e=>e.setTableSelection),d=l&&l.id===t.id?l:null,f=(e,n)=>u({id:t.id,axis:e,index:n}),[p,m]=(0,J.useState)(null),h=NT();(0,J.useEffect)(()=>()=>u(null),[u]);let g=n.zoom,_=vo(t),v=_r({x:t.x,y:t.y},n),y=Wo(t),b=Mo(t),x=_.width*g,S=_.height*g;function C(e,t,n){n.preventDefault(),n.stopPropagation(),f(e,t),m({axis:e,index:t,x:n.clientX,y:n.clientY})}function w(e,t,n){n.stopPropagation(),f(e,t)}function T(e,n){n.stopPropagation(),n.preventDefault();let r=n.clientX,i=t.colWidths[e];h(n,{onStart:c.beginTransaction,onMove(n){let a=s.getState(),o=Qe(a.shapes,t.id);if(o?.type!==`table`)return;let c=(n.clientX-r)/a.viewport.zoom;a.replaceShape(fo(o,e,i,c))},onEnd(){c.endTransaction()}})}let E=`absolute flex items-center justify-center border border-[var(--canvas-selection)]/40 bg-[var(--chrome-popup)]`,D=(e,t)=>d?.axis===e&&d.index===t;return(0,Q.jsxs)(Q.Fragment,{children:[t.colWidths.map((e,t)=>(0,Q.jsx)(`div`,{"data-testid":`table-col-header`,"data-index":t,onPointerDown:e=>w(`col`,t,e),onContextMenu:e=>C(`col`,t,e),className:`${E} cursor-pointer ${D(`col`,t)?`bg-[var(--canvas-selection)]/20`:`hover:bg-[var(--canvas-selection)]/10`}`,style:{left:v.x+y[t]*g,top:v.y-zT,width:e*g,height:zT,pointerEvents:`all`}},`col-${t}`)),t.colWidths.map((e,t)=>(0,Q.jsx)(`div`,{"data-testid":`table-col-resize`,"data-index":t,onPointerDown:e=>T(t,e),className:`absolute ${la}`,style:{left:v.x+y[t+1]*g-3,top:v.y-zT,width:6,height:zT,cursor:`col-resize`,pointerEvents:`all`}},`col-resize-${t}`)),t.rowHeights.map((e,t)=>(0,Q.jsx)(`div`,{"data-testid":`table-row-header`,"data-index":t,onPointerDown:e=>w(`row`,t,e),onContextMenu:e=>C(`row`,t,e),className:`${E} cursor-pointer ${D(`row`,t)?`bg-[var(--canvas-selection)]/20`:`hover:bg-[var(--canvas-selection)]/10`}`,style:{left:v.x-zT,top:v.y+b[t]*g,width:zT,height:e*g,pointerEvents:`all`}},`row-${t}`)),d&&(0,Q.jsx)(`div`,{className:`pointer-events-none absolute bg-[var(--canvas-selection)]/10`,style:d.axis===`col`?{left:v.x+y[d.index]*g,top:v.y,width:t.colWidths[d.index]*g,height:S}:{left:v.x,top:v.y+b[d.index]*g,width:x,height:t.rowHeights[d.index]*g}}),p&&(0,Q.jsx)(VT,{menu:p,onClose:()=>m(null),onInsertBefore:()=>{p.axis===`col`?r(t.id,p.index):a(t.id,p.index)},onInsertAfter:()=>{p.axis===`col`?r(t.id,p.index+1):a(t.id,p.index+1)},onDelete:()=>{p.axis===`col`?i(t.id,p.index):o(t.id,p.index),u(null)}})]})}function VT(e){let{menu:t,onClose:n,onInsertBefore:r,onInsertAfter:i,onDelete:a}=e,o=t.axis===`col`,s=(0,J.useRef)(null),c=`block w-full cursor-pointer rounded-lg px-2.5 py-1.5 text-left text-[13px] text-[var(--chrome-fg-700)] outline-none hover:bg-[var(--chrome-hover)]`;function l(e){e(),n()}return(0,J.useEffect)(()=>{function e(e){s.current?.contains(e.target)||n()}function t(e){e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n())}return window.addEventListener(`pointerdown`,e,!0),window.addEventListener(`keydown`,t,!0),()=>{window.removeEventListener(`pointerdown`,e,!0),window.removeEventListener(`keydown`,t,!0)}},[n]),(0,Q.jsxs)(`div`,{ref:s,"data-testid":`table-header-menu`,onPointerDown:e=>e.stopPropagation(),className:`fixed min-w-[170px] p-1 ${q.popup}`,style:{left:t.x,top:t.y,pointerEvents:`all`},children:[(0,Q.jsx)(`button`,{type:`button`,"data-testid":`table-menu-insert-before`,className:c,onClick:()=>l(r),children:o?`Insert column left`:`Insert row above`}),(0,Q.jsx)(`button`,{type:`button`,"data-testid":`table-menu-insert-after`,className:c,onClick:()=>l(i),children:o?`Insert column right`:`Insert row below`}),(0,Q.jsx)(`div`,{className:`mx-1 my-1 h-px bg-[var(--chrome-divider)]`}),(0,Q.jsx)(`button`,{type:`button`,"data-testid":`table-menu-delete`,className:c,onClick:()=>l(a),children:o?`Delete column`:`Delete row`})]})}var HT=50;function UT(e,t,n,r,i){let a=p_(t,n,e,r),o=a===null?null:v_(e,a,i),s=e.length>1?o?.bounds??pn(e,i):null,c=s!==null&&e.some(e=>e.type===`figure`&&Math.abs(G(e).y-s.y)<.5);return{group:s,rotation:o?.angle??0,titledTop:c}}function WT(e){let{shapes:t,viewport:n,gestures:r,onArrowBendReset:i,onSurfaceDoubleClick:a,cropping:o,editingVertices:s,transforming:c,isGroup:l,onTableInsertColumn:u,onTableDeleteColumn:d,onTableInsertRow:f,onTableDeleteRow:p,onLaneAdd:m,onLaneDelete:h,onLaneEdit:g,laneEditing:_}=e,{onHandlePointerDown:v,onLineVertexPointerDown:y,onElbowSegmentPointerDown:b,onGroupHandlePointerDown:x,onSelectionPointerDown:S,onSelectionPointerMove:C,onSelectionPointerLeave:w,onRotateHandlePointerDown:T,onCropHandlePointerDown:E,onStickyDuplicatePointerDown:D}=r,O=H().measurement,k=t.length===1?t[0]:null,A=U(e=>e.selectionFrame),j=U(e=>e.selectedIds),[M,N]=(0,J.useReducer)(e=>e+1,0),P=(0,J.useRef)(null),F=[t,A,j,c,M],I;t.length>HT&&P.current!==null&&P.current.key.every((e,t)=>e===F[t])?I=P.current.value:(I=UT(t,A,j,c,O),P.current={key:F,value:I});let{group:L}=I,ee=I.rotation,R=L?_r({x:L.x,y:L.y},n):null,z=U(e=>e.resizing),B=!c||k?.type===`text`&&z,[V,te]=(0,J.useState)(!1),ne=k?.type===`text`?k.id:null;(0,J.useEffect)(()=>{if(!ne)return;let e=document.querySelector(qi(ne));if(!(e instanceof HTMLElement))return;let t=new ResizeObserver(()=>N());return t.observe(e),()=>t.disconnect()},[ne]);let re=k?.type===`icon`?k:null;return(0,J.useLayoutEffect)(()=>{re?.label&&N()},[re?.id,re?.label,re?.fontSize,re?.fontFamily]),(0,Q.jsxs)(`div`,{className:`pointer-events-none absolute inset-0`,children:[L&&R&&(0,Q.jsx)(`div`,{"data-testid":`selection-surface`,onPointerDown:S,onPointerMove:C,onPointerLeave:w,onDoubleClick:a,style:{position:`absolute`,left:R.x,top:R.y,width:L.width*n.zoom,height:L.height*n.zoom,transform:ee?`rotate(${ee}deg)`:void 0,pointerEvents:`all`}}),k&&o&&(0,Q.jsx)(jT,{shape:k,viewport:n,onCrop:E}),k&&!o&&k.type===`arrow`&&!c&&(0,Q.jsx)(OT,{shape:k,viewport:n,onHandlePointerDown:v,onElbowSegmentPointerDown:b,onBendReset:i}),k&&!o&&(k.type===`line`||k.type===`polygon`&&s)&&(0,Q.jsx)(IT,{shape:k,viewport:n,onLineVertexPointerDown:y}),k&&!o&&!s&&k.type!==`arrow`&&k.type!==`line`&&(0,Q.jsx)(RT,{shape:k,viewport:n,onHandlePointerDown:v,onRotate:T,onDuplicate:D,showHandles:!c&&!V,outlined:B}),k&&!o&&k.type===`figure`&&ns(k.kind)&&!k.locked&&!c&&!_&&(0,Q.jsx)(FT,{shape:k,viewport:n,onLaneAdd:m,onLaneDelete:h,onLaneEdit:g}),k&&!o&&k.type===`table`&&!c&&(0,Q.jsx)(BT,{shape:k,viewport:n,onInsertColumn:u,onDeleteColumn:d,onInsertRow:f,onDeleteRow:p}),k&&!o&&(k.type===`rectangle`||k.type===`icon`)&&!c&&(0,Q.jsx)(ET,{shape:k,viewport:n,onConnectingChange:te}),L&&(0,Q.jsx)(MT,{bounds:L,rotation:ee,viewport:n,onGroupHandlePointerDown:x,onRotate:T,showHandles:!c,outlined:B,isGroup:l,titledTop:I.titledTop})]})}function GT(e,t){return t===`start`?e.startBinding:e.endBinding}function KT(e,t){let n=[];for(let r of t)if(r.type===`arrow`)for(let t of[`start`,`end`]){let i=GT(r,t);i&&!Ge(i)&&i.shapeId===e.id&&i.precise&&n.push({arrow:r,end:t,binding:i})}return n}function qT(e){let{shape:t,shapes:n,mode:r,start:i,index:a,delta:o}=e,s=rn(t),c=t.height,l=t.activations??[],u=e=>l.map((t,n)=>n===a?e:t);if(r===`move`){let e=Math.min(Math.max(i.top+o,s),c-i.height),r=e-i.top;if(r===0)return{activations:u(i),arrows:[]};let a=sn(t),l=t.y+i.top,d=l+i.height,f=new Map;for(let e of KT(t,n)){let t=a.y+e.binding.anchor.y*a.height;if(t<l||t>d)continue;let n=kr(e.binding.anchor.y+r/a.height),i=f.get(e.arrow.id)??e.arrow,o={...e.binding,anchor:{x:e.binding.anchor.x,y:n}};f.set(e.arrow.id,{...i,...e.end===`start`?{startBinding:o}:{endBinding:o}})}return{activations:u({top:e,height:i.height}),arrows:[...f.values()]}}let d=i.top+i.height,f=i.top,p=i.height;return r===`top`?(f=Math.min(Math.max(i.top+o,s),d-12),p=d-f):p=Math.min(Math.max(d+o,i.top+12),c)-f,{activations:u({top:f,height:p}),arrows:[]}}function JT(e,t){let n=[];for(let r of t)if(r.id!==e.id){if(r.type===`control`&&r.kind===`lifeline`){let e=nr(r);if(e.length>0){n.push(...e);continue}}n.push(G(r))}return n}function YT(e,t,n,r){let i=e=>e.filter(e=>e.axis===`y`);if(e===`move`){let e=Lg(t,n,r);return{dy:e.dy,guides:i(e.guides)}}let a=t.x+t.width/2,o=e===`top`?t.y:t.y+t.height,s=Rg({x:a,y:o},n,r);return{dy:s.point.y-o,guides:i(s.guides)}}var XT=18,ZT=8,QT=3;function $T(e){let{shape:t,viewport:n,setSnapGuides:r}=e,{store:i,history:a}=H(),o=NT(),s=nr(t);if(s.length===0)return null;let c=n.zoom;function l(e,n,s){s.stopPropagation(),s.preventDefault();let c=s.clientY,l=t.activations?.[n]??{top:0,height:0},u=null,d=!1;o(s,{onMove(o){let s=i.getState();if(!d){if(Math.abs(o.clientY-c)<QT)return;d=!0,u=s.shapes,a.beginTransaction()}let f=Qe(s.shapes,t.id);if(f?.type!==`control`||!u)return;let p=(o.clientY-c)/s.viewport.zoom,m=p,h=[],g=qT({shape:f,shapes:u,mode:e,start:l,index:n,delta:p}),_=nr({...f,activations:g.activations})[n];if(_){let t=YT(e,_,JT(f,s.shapes),6/s.viewport.zoom);m=p+t.dy,h=t.guides}let{activations:v,arrows:y}=m===p?g:qT({shape:f,shapes:u,mode:e,start:l,index:n,delta:m});r?.(h);let b={...f,activations:v};y.length>0?s.replaceMany([b,...y]):s.replaceShape(b)},onEnd(e){d?(r?.([]),a.endTransaction()):e===`up`&&i.getState().setSelectedIds(new Set([t.id]))}})}return(0,Q.jsx)(Q.Fragment,{children:s.map((e,t)=>{let r=_r({x:e.x,y:e.y},n),i=e.width*c,a=e.height*c,o=r.x+i/2;return(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{"data-testid":`lifeline-activation-move`,onPointerDown:e=>l(`move`,t,e),className:`absolute`,style:{left:o-XT/2,top:r.y,width:XT,height:a,cursor:`move`,pointerEvents:`all`}}),(0,Q.jsx)(`div`,{"data-testid":`lifeline-activation-top`,onPointerDown:e=>l(`top`,t,e),className:`absolute`,style:{left:o-XT/2,top:r.y-ZT/2,width:XT,height:ZT,cursor:`ns-resize`,pointerEvents:`all`}}),(0,Q.jsx)(`div`,{"data-testid":`lifeline-activation-bottom`,onPointerDown:e=>l(`bottom`,t,e),className:`absolute`,style:{left:o-XT/2,top:r.y+a-ZT/2,width:XT,height:ZT,cursor:`ns-resize`,pointerEvents:`all`}})]},t)})})}function eE(e){let{viewport:t,setSnapGuides:n}=e,r=_e(e=>[e.shapes],e=>At(e,`control`).filter(e=>e.kind===`lifeline`&&(e.activations?.length??0)>0&&!e.locked),we);return U(e=>e.tool)!==`select`||r.length===0?null:(0,Q.jsx)(`div`,{className:`pointer-events-none absolute inset-0`,children:r.map(e=>(0,Q.jsx)($T,{shape:e,viewport:t,setSnapGuides:n},e.id))})}function tE(e,t,n){let r=t;for(;r&&r!==e;){if(r.nodeType===1){let e=r;if(e.tagName.toLowerCase()===`span`&&e.style[n])return e}r=r.parentNode}return null}function nE(e,t,n){let r=e.parentNode;if(!r)return e;let i=document.createRange();i.selectNodeContents(e),i.setEnd(t.startContainer,t.startOffset);let a=document.createRange();a.selectNodeContents(e),a.setStart(t.endContainer,t.endOffset);let o=i.extractContents(),s=a.extractContents();if(o.textContent!==``){let t=e.cloneNode(!1);t.appendChild(o),r.insertBefore(t,e)}if(s.textContent!==``){let t=e.cloneNode(!1);t.appendChild(s),r.insertBefore(t,e.nextSibling)}return n(e),e}function rE(e,t,n){let r=window.getSelection(),i=r&&r.rangeCount>0?r.getRangeAt(0):null;if(!i||i.collapsed||!e.contains(i.startContainer))return;let a=tE(e,i.startContainer,t),o=tE(e,i.endContainer,t),s;a&&a===o?s=nE(a,i,n):(s=US(i,`span`,n),s?.querySelectorAll(`span`).forEach(e=>{e.style[t]=``})),s&&HS(s)}function iE(e,t){rE(e,`fontSize`,e=>{e.style.fontSize=`${t}px`})}function aE(e,t){rE(e,`color`,e=>{e.style.color=t})}var oE=class extends Error{constructor(){super(`Sign in to edit text with AI`),this.name=`RewriteSignInError`}},sE=class extends Error{upgradable;constructor(e,t){super(e),this.name=`RewriteLimitError`,this.upgradable=t}};async function cE(e,t,n,r){let i=await fetch(`${n}/v1-text`,{method:`POST`,credentials:`include`,headers:{"content-type":`application/json`},body:JSON.stringify({text:e,instruction:t,...r?{workspaceId:r}:{}})});if(!i.ok){if(i.status===401)throw new oE;if(i.status===429){let e=await i.json().catch(()=>null);throw new sE(e?.message??`That's a lot of rewrites at once. Try again shortly.`,e?.upgradable===!0)}throw Error(`Rewrite failed: ${i.status}`)}let a=await i.json();if(typeof a.text!=`string`||a.text.length===0)throw Error(`Rewrite returned nothing`);return a.text}var lE=[{id:`fix`,label:`Fix spelling`,instruction:`Fix spelling, grammar and punctuation. Change nothing else.`},{id:`shorten`,label:`Shorten`,instruction:`Shorten this text: keep the meaning, cut the words.`},{id:`simplify`,label:`Simplify`,instruction:`Rewrite this in plain language: everyday words, shorter sentences, no jargon. Keep every point it makes.`},{id:`professional`,label:`Professional`,instruction:`Rewrite this in a professional tone: no emoji, no slang, no exclamation marks. Keep the meaning and the length.`}],uE=`custom`;function dE(){return(0,Q.jsx)(pc,{size:13,stroke:1.75,className:`animate-spin text-[var(--chrome-fg-500)]`})}function fE(e){let{hidden:t,editableRef:n,lastRange:r,update:i}=e,{apiUrl:a,workspaceId:o}=te(),s=U(e=>e.setTextAiSignInOpen),c=U(e=>e.setTextAiUpgradeOpen),l=ne().state.status,[u,d]=(0,J.useState)(null),[f,p]=(0,J.useState)(null),[m,h]=(0,J.useState)(``),[g,_]=(0,J.useState)(!1);(0,J.useEffect)(()=>{t&&(_(!1),h(``),p(null))},[t]);async function v(e){if(u)return;if(l===`guest`){s(!0);return}let{editable:t,range:c}=zS(n.current,r.current);if(!t||!c||c.toString().trim().length===0)return;let f=c.cloneRange();p(null),d(e.id);try{let n=await cE(c.toString(),e.instruction,a??``,o??null);if(!t.isConnected)return;let s=tC(t,f,n),l=window.getSelection();if(l&&s){let e=document.createRange();e.setStartBefore(s),e.setEndAfter(s),l.removeAllRanges(),l.addRange(e),r.current=e.cloneRange()}t.dispatchEvent(new InputEvent(`input`,{bubbles:!0})),i()}catch(e){if(e instanceof oE){s(!0);return}p(e instanceof sE?{message:e.message,upgradable:e.upgradable}:{message:`Couldn't rewrite`,upgradable:!1})}finally{d(null)}}function y(){let e=n.current;e&&(BS(e,r.current),i())}function b(e){_(e),e||(h(``),y())}function x(){p(null),h(``),_(!1)}return{busy:u,error:f,prompt:m,promptOpen:g,apply:v,openPrompt:b,reset:x,setPrompt:h,openUpgrade:()=>c(!0)}}function pE(e){let{busy:t,error:n,prompt:r,promptOpen:i,onPromptOpenChange:a,onPromptChange:o,onPromptFocusChange:s,onApply:c,onUpgrade:l,onHoldFocus:u}=e,d=r.trim(),f=()=>{d.length===0||t!==null||c({id:uE,label:`Ask AI`,instruction:d})},p=()=>a(!1);return(0,Q.jsxs)(`div`,{className:`flex w-full flex-col gap-1 pt-0.5`,"data-testid":`format-ai-row`,children:[i?(0,Q.jsxs)(`div`,{className:`flex w-full items-center gap-0.5`,children:[(0,Q.jsx)(`input`,{autoFocus:!0,value:r,placeholder:`Ask AI to…`,disabled:t!==null,"data-testid":`format-ai-prompt`,onMouseDown:e=>e.stopPropagation(),onFocus:()=>s(!0),onBlur:()=>s(!1),onChange:e=>o(e.currentTarget.value),onKeyDown:e=>{if(e.key===`Enter`){e.preventDefault(),f();return}if(e.key===`Escape`){e.preventDefault(),p();return}e.stopPropagation()},className:`h-7 min-w-0 flex-1 rounded-lg bg-transparent px-2 text-[11px] text-[var(--chrome-fg-800)] outline-none placeholder:text-[var(--chrome-fg-400)]`}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Cancel`,"data-testid":`format-ai-prompt-cancel`,disabled:t!==null,onMouseDown:u,onClick:p,className:`${pl(!1)} h-7 w-7 disabled:text-[var(--chrome-fg-300)]`,children:(0,Q.jsx)(Cc,{size:15,stroke:1.75})}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Ask AI`,"data-testid":`format-ai-prompt-submit`,disabled:t!==null||d.length===0,onMouseDown:u,onClick:f,className:`${pl(!1)} h-7 w-7 disabled:text-[var(--chrome-fg-300)]`,children:t===uE?(0,Q.jsx)(dE,{}):(0,Q.jsx)(Qs,{size:15,stroke:1.75})})]}):(0,Q.jsxs)(`div`,{className:`flex w-full items-center gap-0.5`,children:[lE.map(e=>(0,Q.jsxs)(`button`,{type:`button`,"aria-label":e.label,disabled:t!==null,"data-testid":`format-ai-${e.id}`,onMouseDown:u,onClick:()=>c(e),className:`${pl(!1)} relative w-auto px-1.5 disabled:text-[var(--chrome-fg-300)]`,children:[(0,Q.jsx)(`span`,{className:`whitespace-nowrap text-[11px] ${t===e.id?`opacity-0`:``}`,children:e.label}),t===e.id&&(0,Q.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,Q.jsx)(dE,{})})]},e.id)),(0,Q.jsx)(`span`,{className:`mx-0.5 h-5 w-px bg-[var(--chrome-divider)]`}),(0,Q.jsx)(`button`,{type:`button`,disabled:t!==null,"data-testid":`format-ai-prompt-open`,onMouseDown:u,onClick:()=>a(!0),className:`${pl(!1)} w-auto px-1.5 disabled:text-[var(--chrome-fg-300)]`,children:(0,Q.jsx)(`span`,{className:`whitespace-nowrap text-[11px]`,children:`Ask AI to…`})})]}),n?.upgradable?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 pb-0.5`,children:[(0,Q.jsx)(`span`,{className:`text-[11px] text-[var(--chrome-fg-600)]`,children:n.message}),(0,Q.jsx)(`button`,{type:`button`,"data-testid":`format-ai-upgrade`,onMouseDown:u,onClick:l,className:`shrink-0 cursor-pointer rounded-lg bg-[var(--chrome-accent)] px-2 py-1 text-[11px] text-white transition-[background-color,scale] hover:bg-[var(--chrome-accent-hover)] active:scale-[0.96]`,children:`Upgrade`})]}):n&&(0,Q.jsx)(`span`,{className:`text-[11px] text-red-600`,"data-testid":`format-ai-error`,children:n.message})]})}function mE(e){let{open:t,setOpen:n,editableRef:r,lastRange:i,textEditGuard:a,update:o}=e,[s,c]=(0,J.useState)(``),l=(0,J.useRef)(null),u=(0,J.useRef)(null);(0,J.useEffect)(()=>{t&&(u.current?.focus(),u.current?.select())},[t]);let d=(0,J.useCallback)(()=>{let{editable:e,range:t}=zS(r.current,i.current);if(!e||!t)return;r.current=e,l.current=t.cloneRange();let o=VS(e,t.startContainer,`a`);c(o?.getAttribute(`href`)??``),a.guard(),n(!0)},[r,i,n,a]);function f(e){let t=l.current;l.current=null,n(!1);let i=r.current;if(!t||!i)return;let c=_n(s),u=VS(i,t.startContainer,`a`);if(c&&t.collapsed&&!u){let e=ZS(t,c,s.trim());i.focus(),window.getSelection()?.collapse(e,1),o();return}if(c?XS(i,t,c):s.trim()===``&&u&&GS(u),i.focus(),e===`end`){a.release(),i.blur();return}o()}function p(){let e=l.current;l.current=null,n(!1);let t=r.current;if(!e||!t)return;let i=VS(t,e.startContainer,`a`);i&&GS(i),t.focus(),o()}function m(){let e=l.current;l.current=null,n(!1);let t=r.current;t&&BS(t,e)}function h(){let e=_n(s);e&&window.open(e,`_blank`,`noopener,noreferrer`)}return{inputRef:u,value:s,setValue:c,openEditor:d,commit:f,remove:p,close:m,openCurrent:h}}function hE(e){let{inputRef:t,value:n,onChange:r,onCommit:i,onOpen:a,onRemove:o,onCancel:s}=e;return(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 px-1`,children:[(0,Q.jsx)(`input`,{ref:t,value:n,placeholder:`example.com`,onMouseDown:e=>e.stopPropagation(),onChange:e=>r(e.currentTarget.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),i(`refocus`)):e.key===`Escape`&&(e.preventDefault(),s())},onBlur:e=>{let t=e.relatedTarget,n=t&&typeof t.closest==`function`&&t.closest(`[data-format-toolbar]`)!==null;i(n?`refocus`:`end`)},className:`h-8 w-44 rounded-lg bg-transparent px-2 text-sm text-[var(--chrome-fg-800)] outline-none placeholder:text-[var(--chrome-fg-400)]`}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Open link`,onMouseDown:e=>e.preventDefault(),onClick:a,className:`flex h-8 w-8 items-center justify-center rounded-lg text-[var(--chrome-fg-600)] hover:bg-[var(--chrome-divider)]`,children:(0,Q.jsx)(Ys,{size:16,stroke:1.75})}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Remove link`,onMouseDown:e=>e.preventDefault(),onClick:o,className:`flex h-8 w-8 items-center justify-center rounded-lg text-[var(--chrome-fg-600)] hover:bg-[var(--chrome-divider)]`,children:(0,Q.jsx)(Ws,{size:16,stroke:1.75})})]})}var gE=ii.filter(e=>e!==`transparent`),_E={b:`strong`,i:`em`,u:`u`,e:`code`},vE={h:`mark`,x:`s`};function yE(e,t){for(let n=t;n;n=n.parentElement){if(n instanceof HTMLElement&&n.style.color)return On(n.style.color);if(n===e)return null}return null}function bE(e){let t=/^rgba?\((\d+),\s*(\d+),\s*(\d+)/i.exec(e);if(!t)return null;let n=e=>Number(e).toString(16).padStart(2,`0`);return`#${n(t[1])}${n(t[2])}${n(t[3])}`}var xE=10,SE={bold:!1,italic:!1,underline:!1,strike:!1,code:!1,highlight:!1,link:!1,list:!1,checklist:!1,fontSize:24,color:`rgb(30, 30, 30)`,storedColor:`#1e1e1e`};function CE(e){let{active:t,viewport:n}=e,{ai:r}=te(),{textEditGuard:i}=H(),[a,o]=(0,J.useState)(null),[s,c]=(0,J.useState)(SE),[l,u]=(0,J.useState)(!1),[d,f]=(0,J.useState)(null),[p,m]=(0,J.useState)(!1),[h,g]=(0,J.useState)(!1),[_,v]=(0,J.useState)(!1),y=(0,J.useRef)(null),b=(0,J.useRef)(null),x=(0,J.useRef)(null),S=U(e=>e.coarsePointer),C=(0,J.useCallback)((e,t)=>{let n=e.getBoundingClientRect();n.width===0&&n.height===0&&(n=t.getBoundingClientRect()),o(n),u(n.top<58)},[]),w=(0,J.useCallback)(()=>{if(!t){o(null);return}let e=LS();if(!e){!_&&!p&&!h&&(o(null),f(null));return}y.current=e.editable,i.isGuarded()||(b.current=e.range.cloneRange()),C(e.range,e.editable);let n=e.sel.anchorNode,r=n instanceof Element?n:n?.parentElement??null,a=r?getComputedStyle(r):null,s=VS(e.editable,e.sel.anchorNode,`li`),l=s?.parentElement?.matches(`ul[data-checklist]`)??!1;c({bold:VS(e.editable,e.sel.anchorNode,`strong`)!==null||VS(e.editable,e.sel.anchorNode,`b`)!==null,italic:VS(e.editable,e.sel.anchorNode,`em`)!==null||VS(e.editable,e.sel.anchorNode,`i`)!==null,underline:VS(e.editable,e.sel.anchorNode,`u`)!==null,strike:VS(e.editable,e.sel.anchorNode,`s`)!==null,code:VS(e.editable,e.sel.anchorNode,`code`)!==null,highlight:VS(e.editable,e.sel.anchorNode,`mark`)!==null,link:VS(e.editable,e.sel.anchorNode,`a`)!==null,list:s!==null&&!l,checklist:l,fontSize:a&&Math.round(parseFloat(a.fontSize))||24,color:a?a.color:SE.color,storedColor:yE(e.editable,r)??a?.color??SE.color})},[t,_,p,h,i,C]),T=fE({hidden:a===null,editableRef:y,lastRange:b,update:w}),E=mE({open:_,setOpen:v,editableRef:y,lastRange:b,textEditGuard:i,update:w});(0,J.useEffect)(()=>{if(!t){o(null),f(null),m(!1),v(!1),g(!1);return}let e=()=>{_||w()};return document.addEventListener(`selectionchange`,e),()=>document.removeEventListener(`selectionchange`,e)},[t,w,_]),(0,J.useLayoutEffect)(()=>{w()},[w,n]),(0,J.useLayoutEffect)(()=>{let e=x.current;if(!e||!a)return;let t=e.offsetWidth/2,n=a.left+a.width/2;e.style.left=`${Vr(n,8+t,window.innerWidth-8-t)}px`});let D=(0,J.useCallback)(e=>{let{live:t,editable:n}=zS(y.current,b.current);if(!n)return;let r=b.current;!t&&r&&BS(n,r),e(n),eC(n),w()},[w]),O=E.openEditor;if((0,J.useEffect)(()=>{if(!t)return;let e=e=>{if(!(e.metaKey||e.ctrlKey)||e.altKey)return;let t=e.key.toLowerCase(),n=e.shiftKey?vE[t]??null:_E[t]??null;if(n){if(e.preventDefault(),LS()){D(e=>iC(e,n));return}let t=RS();t&&(rC(t.editable,n),w())}else if(t===`k`&&!e.shiftKey){if(e.preventDefault(),LS()){O();return}let t=RS();t&&(y.current=t.editable,b.current=t.range.cloneRange(),C(t.range,t.editable),O())}};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[t,D,w,O,C]),!t||!a)return null;function k(e){let t=Vr(Math.round(e),8,240);D(e=>{iE(e,t)})}function A(e){D(t=>{aE(t,e)})}return(0,Q.jsx)(`div`,{ref:x,"data-format-toolbar":!0,"data-caret-safe":!0,"data-overlay":!0,onPointerDown:e=>{e.stopPropagation();let t=LS();t&&t.editable===y.current&&(b.current=t.range.cloneRange()),i.guard()},onMouseDown:e=>e.preventDefault(),className:`fixed z-50`,style:{left:a.left+a.width/2,top:l?a.bottom+xE:a.top-xE,transform:`translate(-50%, ${l?`0`:`-100%`})`},children:(0,Q.jsx)(`div`,{className:`flex flex-col items-center gap-1.5 p-1 ${q.popup}`,children:_?(0,Q.jsx)(hE,{inputRef:E.inputRef,value:E.value,onChange:E.setValue,onCommit:E.commit,onOpen:E.openCurrent,onRemove:E.remove,onCancel:E.close}):(0,Q.jsxs)(Q.Fragment,{children:[d===`size`&&(0,Q.jsx)(TE,{fontSize:s.fontSize,onApply:k}),d===`color`&&(0,Q.jsx)(EE,{color:s.storedColor,onApply:A,onPopoverOpenChange:m,onGuard:i.guard}),d===`ai`&&(0,Q.jsx)(pE,{busy:T.busy,error:T.error,promptOpen:T.promptOpen,onPromptOpenChange:e=>{e||g(!1),T.openPrompt(e)},onUpgrade:T.openUpgrade,prompt:T.prompt,onPromptChange:T.setPrompt,onPromptFocusChange:g,onApply:e=>void T.apply(e),onHoldFocus:wE}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[r&&!S&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(DE,{label:`Rewrite with AI`,active:d===`ai`,onMouseDown:wE,onClick:()=>{T.reset(),g(!1),f(e=>e===`ai`?null:`ai`)},children:(0,Q.jsx)(Sc,{size:16,stroke:1.75})}),(0,Q.jsx)(`span`,{className:`mx-0.5 h-5 w-px bg-[var(--chrome-divider)]`})]}),(0,Q.jsx)(DE,{label:`Font size`,active:d===`size`,onMouseDown:wE,onClick:()=>f(e=>e===`size`?null:`size`),children:(0,Q.jsx)(`span`,{className:`text-[12px] tabular-nums`,"data-testid":`format-size`,children:s.fontSize})}),(0,Q.jsx)(DE,{label:`Text color`,active:d===`color`,onMouseDown:wE,onClick:()=>{m(!1),f(e=>e===`color`?null:`color`)},children:(0,Q.jsxs)(`span`,{className:`flex flex-col items-center leading-none`,children:[(0,Q.jsx)(`span`,{className:`text-[13px] font-medium`,style:{color:s.color},children:`A`}),(0,Q.jsx)(`span`,{className:`mt-[1px] h-[3px] w-3.5 rounded-full`,style:{background:s.color}})]})}),(0,Q.jsx)(`span`,{className:`mx-0.5 h-5 w-px bg-[var(--chrome-divider)]`}),(0,Q.jsx)(DE,{label:`Bold`,active:s.bold,onMouseDown:wE,onClick:()=>D(e=>iC(e,`strong`)),children:(0,Q.jsx)(Bf,{size:17,stroke:1.75})}),(0,Q.jsx)(DE,{label:`Italic`,active:s.italic,onMouseDown:wE,onClick:()=>D(e=>iC(e,`em`)),children:(0,Q.jsx)(up,{size:17,stroke:1.75})}),(0,Q.jsx)(DE,{label:`Underline`,active:s.underline,onMouseDown:wE,onClick:()=>D(e=>iC(e,`u`)),children:(0,Q.jsx)(Wp,{size:17,stroke:1.75})}),(0,Q.jsx)(DE,{label:`Strikethrough`,active:s.strike,onMouseDown:wE,onClick:()=>D(e=>iC(e,`s`)),children:(0,Q.jsx)(Hp,{size:17,stroke:1.75})}),!S&&(0,Q.jsx)(DE,{label:`Code`,active:s.code,onMouseDown:wE,onClick:()=>D(e=>iC(e,`code`)),children:(0,Q.jsx)(ec,{size:17,stroke:1.75})}),(0,Q.jsx)(DE,{label:`Highlight`,active:s.highlight,onMouseDown:wE,onClick:()=>D(e=>iC(e,`mark`)),children:(0,Q.jsx)(Pc,{size:17,stroke:1.75})}),!S&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(DE,{label:`Link`,active:s.link,onMouseDown:wE,onClick:O,children:(0,Q.jsx)(fc,{size:17,stroke:1.75})}),(0,Q.jsx)(DE,{label:`Bullet list`,active:s.list,onMouseDown:wE,onClick:()=>D(e=>OS(e)),children:(0,Q.jsx)(ws,{size:17,stroke:1.75})}),(0,Q.jsx)(DE,{label:`Checklist`,active:s.checklist,onMouseDown:wE,onClick:()=>D(e=>kS(e)),children:(0,Q.jsx)(Sp,{size:17,stroke:1.75})})]})]})]})})})}function wE(e){e.preventDefault()}function TE(e){let{fontSize:t,onApply:n}=e;return(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 px-1 pt-0.5`,"data-testid":`format-size-row`,children:[di.map((e,r)=>(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Font size ${Jr[r]}`,"aria-pressed":t===e,"data-testid":`format-size-${e}`,onMouseDown:wE,onClick:()=>n(e),className:pl(t===e),children:(0,Q.jsx)(`span`,{className:`text-[11px] font-medium`,children:Jr[r]})},e)),(0,Q.jsx)(`span`,{className:`mx-0.5 h-5 w-px bg-[var(--chrome-divider)]`}),(0,Q.jsx)(Ra,{value:t,onChange:n,onMouseDown:wE,testId:`format-size`})]})}function EE(e){let{color:t,onApply:n,onPopoverOpenChange:r,onGuard:i}=e;return(0,Q.jsx)(`div`,{className:`px-1 pt-0.5`,"data-testid":`format-color-row`,children:(0,Q.jsx)(Ba,{value:bE(t)??t,colors:gE,onChange:n,testId:`format-color`,customFallback:`#1971c2`,onMouseDown:i,onOpenChange:r})})}function DE(e){let{label:t,active:n,children:r,onMouseDown:i,onClick:a}=e;return(0,Q.jsx)(`button`,{type:`button`,"aria-label":t,"aria-pressed":n,onMouseDown:i,onClick:a,className:pl(!!n),children:r})}function OE(){let e=U(e=>e.textAiSignInOpen),t=U(e=>e.setTextAiSignInOpen),n=U(e=>e.textAiUpgradeOpen),r=U(e=>e.setTextAiUpgradeOpen),{state:i}=ne(),a=i.status===`authenticated`?i.usage?.plan??`free`:`free`;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(db,{open:e,onOpenChange:t,title:`Sign in to edit text with AI`,description:`AI text edits are part of Koboyo Pro. Sign in to start your free trial, and your canvas stays exactly where it is.`}),(0,Q.jsx)(ub,{open:n,onOpenChange:r,currentPlan:a,title:`Get more AI text editing`,description:`Move to Pro to keep rewriting, shortening and fixing text as you write — plus a monthly assistant allowance, image generation, and unlimited canvases.`,testId:`text-ai-upgrade-dialog`})]})}var kE=60;function AE(e){return[...e].map(([e,t])=>`${e}\u0000${t.name}\u0000${t.color}`).join(``)}function jE(){let e=H(),t=U(e=>AE(e.remoteCursors)),n=e.store.getState().remoteCursors,r=(0,J.useRef)(new Map),i=(0,J.useRef)(new Map);return(0,J.useEffect)(()=>{if(t===``){i.current.clear();return}let n=0,a=performance.now(),o=t=>{let s=1-Math.exp(-(t-a)/kE);a=t;let{remoteCursors:c,viewport:l}=e.store.getState();for(let[e,t]of c){let n=r.current.get(e);if(!n)continue;let a=i.current.get(e),o=a?{x:a.x+(t.x-a.x)*s,y:a.y+(t.y-a.y)*s}:{x:t.x,y:t.y};i.current.set(e,o);let c=_r(o,l);n.style.transform=`translate3d(${c.x}px, ${c.y}px, 0)`}for(let e of i.current.keys())c.has(e)||i.current.delete(e);n=requestAnimationFrame(o)};return n=requestAnimationFrame(o),()=>cancelAnimationFrame(n)},[t,e]),n.size===0?null:(0,Q.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-30 overflow-hidden`,"data-testid":`remote-cursors`,children:[...n].map(([e,t])=>(0,Q.jsxs)(`div`,{ref:t=>{t?r.current.set(e,t):r.current.delete(e)},"data-testid":`remote-cursor`,"data-cursor-name":t.name,className:`absolute top-0 left-0 will-change-transform`,style:{transform:`translate3d(-100px, -100px, 0)`},children:[(0,Q.jsx)(`svg`,{width:`18`,height:`20`,viewBox:`0 0 18 20`,className:`block drop-shadow-sm`,children:(0,Q.jsx)(`path`,{d:`M1.5 1.5 L1.5 16.5 L5.8 12.6 L8.6 18.6 L11.4 17.3 L8.7 11.4 L14.5 11.4 Z`,fill:t.color,stroke:`white`,strokeWidth:`1.5`,strokeLinejoin:`round`})}),(0,Q.jsx)(`div`,{className:`absolute top-4 left-3.5 max-w-40 truncate rounded-md px-1.5 py-0.5 text-[11px] leading-4 font-medium whitespace-nowrap text-white shadow-sm`,style:{backgroundColor:t.color},children:t.name})]},e))})}var ME=`#f24822`;function NE(e){let{guides:t,viewport:n}=e;return t.length===0?null:(0,Q.jsx)(`svg`,{"data-testid":`snap-guides`,className:`pointer-events-none absolute inset-0 h-full w-full`,style:{overflow:`visible`},children:t.map((e,t)=>e.kind===`gap`?(0,Q.jsx)(LE,{guide:e,viewport:n},t):(0,Q.jsx)(IE,{guide:e,viewport:n},t))})}var PE=3.5;function FE(e,t){let n=[...e].sort((e,t)=>e-t),r=[],i=[];for(let e of n)i.length>0&&e-i[i.length-1]>t&&(r.push((i[0]+i[i.length-1])/2),i=[]),i.push(e);return i.length>0&&r.push((i[0]+i[i.length-1])/2),r}function IE(e){let{guide:t,viewport:n}=e,r=e=>_r(t.axis===`x`?{x:t.pos,y:e}:{x:e,y:t.pos},n),i=r(t.start),a=r(t.end),o=FE(t.marks??[t.start,t.end],PE*2/n.zoom);return(0,Q.jsxs)(`g`,{"data-testid":`snap-guide-line`,stroke:ME,strokeWidth:1,children:[(0,Q.jsx)(`line`,{x1:i.x,y1:i.y,x2:a.x,y2:a.y}),o.map((e,t)=>{let n=r(e);return(0,Q.jsx)(`path`,{"data-testid":`snap-guide-mark`,d:`M${n.x-PE},${n.y-PE}L${n.x+PE},${n.y+PE}M${n.x-PE},${n.y+PE}L${n.x+PE},${n.y-PE}`},t)})]})}function LE(e){let{guide:t,viewport:n}=e,r=t.axis===`x`,i=(e,t)=>(0,Q.jsx)(`line`,{x1:r?e.x:e.x-4,y1:r?e.y-4:e.y,x2:r?e.x:e.x+4,y2:r?e.y+4:e.y},t);return(0,Q.jsx)(`g`,{stroke:ME,strokeWidth:1,children:t.bars.map((e,a)=>{let o=_r(r?{x:e.from,y:t.cross}:{x:t.cross,y:e.from},n),s=_r(r?{x:e.to,y:t.cross}:{x:t.cross,y:e.to},n);return(0,Q.jsxs)(`g`,{children:[(0,Q.jsx)(`line`,{x1:o.x,y1:o.y,x2:s.x,y2:s.y}),i(o,`a`),i(s,`b`)]},a)})})}var RE=`var(--canvas-origin)`;function zE(e){let{bounds:t}=e;return(0,Q.jsx)(`svg`,{className:`absolute overflow-visible`,width:1,height:1,style:{pointerEvents:`none`},"data-testid":`ai-ghost`,children:(0,Q.jsxs)(`g`,{className:`animate-pulse`,children:[(0,Q.jsx)(`rect`,{x:t.x,y:t.y,width:t.width,height:t.height,rx:18,fill:RE,fillOpacity:.06,stroke:RE,strokeWidth:2,strokeDasharray:`6 9`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,Q.jsx)(`text`,{x:t.x+t.width/2,y:t.y+t.height/2,textAnchor:`middle`,dominantBaseline:`middle`,fill:`#94a3b8`,fontSize:20,fontFamily:li,children:`Generating…`})]})})}function BE(e){let{tool:t,kind:n,chartKind:r,frameKind:i,at:a,icon:o,control:s}=e;if(s)return(0,Q.jsx)(GE,{kind:s,at:a});if(o)return(0,Q.jsx)(KE,{icon:o,at:a});if(t===`chart`)return(0,Q.jsx)(HE,{at:a,kind:r});if(t===`figure`)return(0,Q.jsx)(VE,{at:a,kind:i});if(t===`table`)return(0,Q.jsx)(WE,{at:a});if(t===`sticky`)return(0,Q.jsx)(UE,{at:a});if(t!==`rectangle`)return null;let c=Nt(n);return(0,Q.jsx)(`svg`,{className:`absolute overflow-visible`,width:1,height:1,style:{pointerEvents:`none`},children:(0,Q.jsx)(`path`,{d:Ft(n,{x:a.x,y:a.y,width:c.width,height:c.height}),fill:`none`,stroke:RE,strokeWidth:1.5,strokeLinejoin:`round`})})}function VE(e){let{at:t,kind:n}=e,r=es[n],{border:i,details:a}=Yo(n,{x:t.x,y:t.y,width:r.width,height:r.height});return(0,Q.jsx)(`svg`,{"data-testid":`frame-ghost`,className:`absolute overflow-visible`,width:1,height:1,style:{pointerEvents:`none`},children:[i,...a].map((e,t)=>(0,Q.jsx)(`path`,{d:e,fill:`none`,stroke:RE,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`},t))})}function HE(e){let{at:t,kind:n}=e,r=(0,J.useMemo)(()=>Io(cs({x:0,y:0},{fontFamily:li,color:RE,opacity:1},n)),[n]);return(0,Q.jsx)(`svg`,{"data-testid":`chart-ghost`,className:`absolute overflow-visible`,width:1,height:1,style:{pointerEvents:`none`},children:(0,Q.jsx)(`g`,{opacity:.55,transform:`translate(${t.x} ${t.y})`,children:r.map((e,t)=>(0,Q.jsx)(dS,{prim:e},t))})})}function UE(e){let{at:t}=e;return(0,Q.jsx)(`svg`,{className:`absolute overflow-visible`,width:1,height:1,style:{pointerEvents:`none`},children:(0,Q.jsx)(`rect`,{x:t.x,y:t.y,width:180,height:180,rx:2,fill:RE,fillOpacity:.15,stroke:RE,strokeWidth:1.5})})}function WE(e){let{at:t}=e,n=[];for(let e=1;e<3;e+=1){let r=t.x+168*e/3;n.push((0,Q.jsx)(`line`,{x1:r,y1:t.y,x2:r,y2:t.y+96},`c${e}`))}for(let e=1;e<3;e+=1){let r=t.y+96*e/3;n.push((0,Q.jsx)(`line`,{x1:t.x,y1:r,x2:t.x+168,y2:r},`r${e}`))}return(0,Q.jsxs)(`svg`,{className:`absolute overflow-visible`,width:1,height:1,style:{pointerEvents:`none`},children:[(0,Q.jsx)(`rect`,{x:t.x,y:t.y,width:168,height:96,rx:2,fill:`none`,stroke:RE,strokeWidth:1.5}),(0,Q.jsx)(`g`,{stroke:RE,strokeWidth:1,opacity:.7,children:n})]})}function GE(e){let{kind:t,at:n}=e,r=Oi(),i=(0,J.useMemo)(()=>vi(xi(t,{x:0,y:0},{fontFamily:li,color:RE,opacity:1}),r.text),[t,r]);return(0,Q.jsx)(`svg`,{className:`absolute overflow-visible`,width:1,height:1,style:{pointerEvents:`none`},children:(0,Q.jsx)(`g`,{opacity:.55,transform:`translate(${n.x} ${n.y})`,children:i.map((e,t)=>(0,Q.jsx)(dS,{prim:e},t))})})}function KE(e){let{icon:t,at:n}=e;return Gi(t.source)?Wi(t.source)?(0,Q.jsx)(JE,{source:t.source,slug:t.name,at:n}):(0,Q.jsx)(XE,{source:t.source,slug:t.name,at:n,box:qE(t.source)}):(0,Q.jsx)(YE,{name:t.name,at:n})}function qE(e){let t=kt(e);return{width:t,height:t}}function JE(e){let{source:t,slug:n,at:r}=e,i=Ol(t,n),a=i?Qc(i.viewBox):null;return(0,Q.jsx)(XE,{source:t,slug:n,at:r,box:Rt(kt(t),a?a.width/a.height:1)})}function YE(e){let{name:t,at:n}=e,r=El(t);return(0,Q.jsx)(`svg`,{className:`absolute overflow-visible`,width:1,height:1,style:{pointerEvents:`none`},children:r&&(0,Q.jsx)(kl,{node:r,at:n,size:55,stroke:RE,strokeWidth:ct(3,55),opacity:.7})})}function XE(e){let{source:t,slug:n,at:r,box:i}=e;return(0,Q.jsx)(`svg`,{className:`absolute overflow-visible`,width:1,height:1,style:{pointerEvents:`none`},children:(0,Q.jsx)(`image`,{href:Ki().assetIconUrl(t,n),x:r.x,y:r.y,width:i.width,height:i.height,opacity:.7})})}var ZE=5;function QE(e){let{shape:t,viewport:n,measurement:r,className:i,testId:a}=e,o=ea(t,r),s=_r({x:o.x,y:o.y},n),c=cr(t),l=Qi(t,o,n.zoom,r);return(0,Q.jsx)(`div`,{"data-testid":a,className:i,style:{left:s.x-ZE,top:s.y-ZE,width:o.width*n.zoom+ZE*2,height:o.height*n.zoom+ZE*2,transform:c?`rotate(${c}deg)`:void 0,transformOrigin:`${l.x+ZE}px ${l.y+ZE}px`}})}function $E(e,t,n){return _r(sa(e,n),t)}function eD(e){let{interactive:t,transforming:n,revealed:r,viewport:i}=e,a=_e(e=>[e.shapes,e.hoveredId],(e,t)=>t?Qe(e,t):void 0);return!t||n||r||!a?.locked?null:(0,Q.jsx)(tD,{shape:a,viewport:i})}function tD(e){let{shape:t,viewport:n}=e,r=H().measurement,i=$E(t,n,r);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(QE,{shape:t,viewport:n,measurement:r,testId:`locked-hover`,className:`pointer-events-none absolute rounded-[4px] border border-dashed border-gray-400/50`}),(0,Q.jsx)(`div`,{className:`pointer-events-none absolute flex h-5 w-5 items-center justify-center rounded bg-[var(--chrome-surface)] text-[var(--chrome-fg-400)] ring-1 ring-[var(--chrome-ring)]`,style:{left:i.x-ZE,top:i.y-ZE-23},children:(0,Q.jsx)(wp,{size:11,stroke:2})})]})}function nD(e){if(e)return e.type===`rectangle`||e.type===`control`?e.link:void 0}function rD(e){let{link:t,left:n,top:r}=e,i=_n(t);return i?(0,Q.jsx)(S,{label:i,side:`top`,children:(0,Q.jsx)(`a`,{"data-testid":`link-badge`,href:i,target:`_blank`,rel:`noopener noreferrer`,onPointerDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),className:`absolute flex h-6 w-6 items-center justify-center rounded-md bg-[var(--chrome-popup)] text-blue-600 shadow-[0_2px_8px_rgba(0,0,0,0.12)] ring-1 ring-[var(--chrome-ring)] transition-colors hover:bg-blue-50`,style:{left:n,top:r},children:(0,Q.jsx)(fc,{size:13,stroke:2})})}):null}function iD(e){let{interactive:t,transforming:n,viewport:r}=e,i=U(e=>e.selectedIds),a=_e(e=>[e.shapes,e.selectedIds],(e,t)=>t.size===1?Qe(e,[...t][0]):void 0),o=nD(a);if(!t||n||i.size!==1||!a||!o)return null;let s=$E(a,r);return(0,Q.jsx)(rD,{link:o,left:s.x-ZE,top:s.y-ZE-28})}function aD(e){let{shapes:t,viewport:n,onUnlock:r}=e,i=H().measurement,a=pn(t,i);if(!a)return null;let o=t.length===1?$E(t[0],n,i):_r({x:a.x,y:a.y},n),s=t.length===1?nD(t[0]):void 0;return(0,Q.jsxs)(Q.Fragment,{children:[t.map(e=>(0,Q.jsx)(QE,{shape:e,viewport:n,measurement:i,testId:`locked-outline`,className:`pointer-events-none absolute rounded-[4px] border border-dashed border-gray-400/60`},e.id)),(0,Q.jsx)(S,{label:`Unlock`,side:`top`,children:(0,Q.jsx)(`button`,{type:`button`,"data-testid":`lock-badge`,"aria-label":`Unlock`,onPointerDown:e=>e.stopPropagation(),onClick:r,className:`absolute flex h-6 w-6 items-center justify-center rounded-md bg-[var(--chrome-popup)] text-[var(--chrome-fg-500)] shadow-[0_2px_8px_rgba(0,0,0,0.12)] ring-1 ring-[var(--chrome-ring)] transition-colors hover:bg-[var(--chrome-hover)] hover:text-[var(--chrome-fg-900)]`,style:{left:o.x-ZE,top:o.y-ZE-28},children:(0,Q.jsx)(wp,{size:13,stroke:2})})}),s&&(0,Q.jsx)(rD,{link:s,left:o.x-ZE+28,top:o.y-ZE-28})]})}function oD(e){let{viewport:t}=e,n=H().measurement,r=_e(e=>[e.shapes,e.activeGroupId],(e,t)=>t?pn(e.filter(e=>e.groupId===t),n):null);if(!r)return null;let i=_r({x:r.x,y:r.y},t);return(0,Q.jsx)(`div`,{"data-testid":`entered-group-outline`,className:`pointer-events-none absolute border border-dashed border-[var(--canvas-group-selection)] opacity-50`,style:{left:i.x-6,top:i.y-6,width:r.width*t.zoom+12,height:r.height*t.zoom+12}})}var sD=10,cD=28;function lD(e){let{viewport:t}=e,n=_e(e=>[e.shapes,e.animateSlideId],(e,t)=>t?In(e).find(e=>e.id===t):null);if(!n)return null;let r=G(n),i=_r({x:r.x-sD,y:r.y-cD},t),a=_r({x:r.x+r.width+sD,y:r.y+r.height+sD},t);return(0,Q.jsx)(`div`,{"data-testid":`animate-spotlight`,className:`pointer-events-none absolute rounded-lg`,style:{left:i.x,top:i.y,width:Math.max(0,a.x-i.x),height:Math.max(0,a.y-i.y),boxShadow:`0 0 0 9999px var(--canvas-scrim)`}})}var uD=7,dD=9,fD=26,pD=.15;function mD(e){let{zoom:t}=e,n=vb(),r=H().measurement,i=n?pn(n,r):null;if(!i)return null;let a=uD/t,o=fD/t,s=Math.max(i.width,o),c=Math.max(i.height,o);return(0,Q.jsx)(`svg`,{"data-testid":`build-highlight`,className:`pointer-events-none absolute overflow-visible`,width:1,height:1,children:(0,Q.jsx)(`rect`,{x:i.x+i.width/2-s/2-a,y:i.y+i.height/2-c/2-a,width:s+a*2,height:c+a*2,rx:dD/t,fill:`var(--canvas-selection)`,fillOpacity:pD})})}var hD=160;function gD(e){return 1.25**Math.round(Math.log(e)/Math.log(1.25))}function _D(e){let{viewport:t,children:n}=e,[r,i]=(0,J.useState)(!1),a=(0,J.useRef)(t),o=(0,J.useRef)(null),[s,c]=(0,J.useState)(t.zoom);return(0,J.useLayoutEffect)(()=>{let e=window.setTimeout(()=>c(t.zoom),hD);return()=>window.clearTimeout(e)},[t.zoom]),(0,J.useLayoutEffect)(()=>{let e=a.current;if(a.current=t,t.zoom!==e.zoom){o.current!=null&&(window.clearTimeout(o.current),o.current=null),i(!1);return}t.x===e.x&&t.y===e.y||(i(!0),o.current!=null&&window.clearTimeout(o.current),o.current=window.setTimeout(()=>i(!1),hD))},[t]),(0,J.useLayoutEffect)(()=>()=>{o.current!=null&&window.clearTimeout(o.current)},[]),(0,Q.jsx)(`div`,{"data-testid":`world-layer`,className:`absolute left-0 top-0 origin-top-left`,style:{transform:`translate(${t.x}px, ${t.y}px) scale(${t.zoom})`,willChange:r?`transform`:void 0,[Ax]:`${Mx/gD(s)}px`,[jx]:`${12/gD(s)}px`},children:n})}var vD=16;function yD(e){let{containerRef:t,setViewport:n}=e,r=W();(0,J.useEffect)(()=>{function e(e){e.ctrlKey&&e.preventDefault()}function t(e){e.preventDefault()}return window.addEventListener(`wheel`,e,{passive:!1,capture:!0}),window.addEventListener(`gesturestart`,t),window.addEventListener(`gesturechange`,t),window.addEventListener(`gestureend`,t),()=>{window.removeEventListener(`wheel`,e,{capture:!0}),window.removeEventListener(`gesturestart`,t),window.removeEventListener(`gesturechange`,t),window.removeEventListener(`gestureend`,t)}},[]),(0,J.useEffect)(()=>{let e=t.current;if(!e)return;let i=Ja(e=>{n(t=>{let n=t;return(e.dx!==0||e.dy!==0)&&(n={...n,x:n.x-e.dx,y:n.y-e.dy}),e.anchor&&e.zoomFactor!==1&&(n=Kt(n,yn(n.zoom*e.zoomFactor),e.anchor)),n}),e.anchor&&e.zoomFactor!==1&&r.getState().pulseZoomGesture()});function a(e){if(e.target instanceof Element&&e.target.closest(`[data-overlay]`))return;if(o.isActive()){e.preventDefault();return}e.preventDefault();let t=e.currentTarget.getBoundingClientRect();if(e.ctrlKey||e.metaKey){let n={x:e.clientX-t.left,y:e.clientY-t.top};i.queue(t=>{t.zoomFactor*=qa(e.deltaY),t.anchor=n});return}let n=e.deltaMode===1?vD:1,r=e.deltaX*n,a=e.deltaY*n;i.queue(t=>{if(e.shiftKey&&r===0){t.dx+=a;return}t.dx+=r,t.dy+=a})}let o=Xa(e,t=>{if(r.getState().presentingIndex!==null||t.target instanceof Element&&t.target.closest(`[data-overlay]`))return;let n=e.getBoundingClientRect();i.queue(e=>{e.zoomFactor*=t.factor,e.anchor={x:t.clientX-n.left,y:t.clientY-n.top}})});return e.addEventListener(`wheel`,a,{passive:!1}),()=>{e.removeEventListener(`wheel`,a),o.stop(),i.cancel()}},[t,n,r])}function bD(e,t){let n=Vu((0,J.useMemo)(()=>Bu(e),[e]),t),r=(0,J.useRef)(null);return(r.current===null||r.current.key!==n)&&(r.current={key:n,zoom:t}),r.current.zoom}function xD(e,t){let n=e.measureMisses;if(n.size===0)return;let{shapes:r,settleBindings:i}=e.store.getState(),{dependents:a}=Rn(r);for(let e of[...n])a.has(e)||n.delete(e);if(n.size===0)return;let o=new Set;for(let r of t)n.has(r.id)&&(r.type===`text`?e.measurement.textBounds(r.id):r.type===`icon`&&r.label&&e.measurement.iconLabelBounds(r.id))&&o.add(r.id);if(o.size!==0){for(let e of o)n.delete(e);e.history.runWithoutHistory(()=>{i(o)})}}function SD(e,t){let n=H(),r=U(e=>e.transforming);(0,J.useEffect)(()=>{r||xD(n,e)},[n,e,t,r])}var CD=.25,wD=CD/2,TD=200,ED=500;function DD(e,t){return t.minX>=e.minX&&t.minY>=e.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function OD(e){let{shapes:t,viewport:n,containerSize:r,selectedIds:i,editingId:a}=e,o=(0,J.useRef)(null),[s,c]=(0,J.useState)(0);return(0,J.useEffect)(()=>{let e=o.current?.computedViewport;if(e===void 0||e===n)return;let t=window.setTimeout(()=>c(e=>e+1),TD);return()=>window.clearTimeout(t)},[n]),(0,J.useMemo)(()=>{let e=r.width>0&&r.height>0?r:typeof window<`u`?{width:window.innerWidth,height:window.innerHeight}:null;if(e==null)return t;let c=nt({x:0,y:0},n),l=nt({x:e.width,y:e.height},n),u=l.x-c.x,d=l.y-c.y,f={minX:c.x,minY:c.y,maxX:l.x,maxY:l.y},p=o.current;if(p!==null&&p.nonce===s&&p.shapes===t&&p.selectedIds===i&&p.editingId===a&&p.width===e.width&&p.height===e.height&&DD(p.reuseWindow,f))return p.visible;let m=u*CD,h=d*CD,g=f.minX-m,_=f.minY-h,v=f.maxX+m,y=f.maxY+h,b=i.size<=ED,x=t.filter(e=>{if(b&&i.has(e.id)||e.id===a)return!0;let t=Bt(e);return t.x<=v&&t.x+t.width>=g&&t.y<=y&&t.y+t.height>=_});return p!==null&&p.visible.length===x.length&&p.visible.every((e,t)=>e===x[t])&&(x=p.visible),o.current={shapes:t,selectedIds:i,editingId:a,width:e.width,height:e.height,computedViewport:n,nonce:s,reuseWindow:{minX:f.minX-u*wD,minY:f.minY-d*wD,maxX:f.maxX+u*wD,maxY:f.maxY+d*wD},visible:x},x},[t,n,r,i,a,s])}var kD=160,AD=2e3;function jD(e){let{viewport:t,containerSize:n}=e,r=W(),i=lg(),a=pg(i.widgetOrigin),o=U(e=>e.shapes),s=(0,J.useMemo)(()=>o.filter(xg),[o]),c=U(e=>e.selectedIds),l=U(e=>e.editSession.kind===`interact`?e.editSession.shapeId:null),u=U(e=>e.startedWebIds),d=U(e=>e.transforming||e.marquee!==null||e.lasso!==null),f=(0,J.useRef)({live:new Set,graceUntil:new Map}),p=(0,J.useRef)(0),m=(0,J.useRef)(null);(0,J.useLayoutEffect)(()=>{p.current=performance.now()},[t.x,t.y,t.zoom]),(0,J.useEffect)(()=>{if(s.length===0&&f.current.live.size===0)return;let e=[],o=new Set;for(let t of s){let n=gg(t,i);if(!n||(n.kind===`embed`&&n.embed.video&&o.add(t.id),_g(n,i)&&!u.has(t.id)))continue;let r=t.poster??(n.kind===`embed`?n.embed.thumbnail:void 0);e.push({id:t.id,x:t.x,y:t.y,width:t.width,height:t.height,bare:!r})}let h=yg({candidates:e,viewport:t,view:n,interactingId:l,selectedIds:c,limit:a}),g=()=>{m.current=null;let e=performance.now(),t=p.current+kD,n=f.current,i=bg({previous:n,wanted:h,now:e,mayMount:!d&&e>=t,urgent:l,limit:a,graceMs:AD});f.current=i;let s=r.getState();s.setLiveWebIds(i.live);for(let e of n.live)!i.live.has(e)&&o.has(e)&&s.stopWeb(e);let c=h.some(e=>!i.live.has(e)),u=Math.min(c&&!d?Math.max(t,e+16):1/0,...i.graceUntil.values());Number.isFinite(u)&&(m.current=window.setTimeout(g,Math.max(0,u-e)))};return g(),()=>{m.current!==null&&(window.clearTimeout(m.current),m.current=null)}},[r,i,a,s,t,n,c,l,u,d])}var MD=8,ND=32;function PD(e){let{viewport:t}=e,n=W(),r=U(e=>e.editSession.kind===`interact`?e.editSession.shapeId:null),i=U(e=>r?Qe(e.shapes,r):void 0);if((0,J.useEffect)(()=>{if(!r)return;let e=e=>{let t=e.target;t instanceof Element&&(t.closest(`[data-web-interact-chrome]`)||t.closest(`[data-shape-id="${CSS.escape(r)}"]`))||n.getState().endEdit(r)};return window.addEventListener(`pointerdown`,e,!0),()=>window.removeEventListener(`pointerdown`,e,!0)},[r,n]),!i||i.type!==`web`)return null;let a=_r({x:i.x+i.width,y:i.y},t),o=a.y-MD-ND>=0,s=i.kind===`embed`&&i.url?_n(i.url):null;return(0,Q.jsxs)(`div`,{"data-overlay":!0,"data-web-interact-chrome":!0,"data-testid":`web-interact-chrome`,className:`absolute z-10 flex -translate-x-full items-center gap-0.5 rounded-xl p-1 text-[13px] ${dl}`,style:{left:a.x,top:o?a.y-MD-ND:a.y+MD,height:ND},children:[s&&(0,Q.jsxs)(`a`,{href:s,target:`_blank`,rel:`noopener noreferrer`,"data-testid":`web-open-link`,className:`flex h-6 items-center gap-1 rounded-lg px-2 text-[var(--chrome-fg-600)] transition-colors hover:bg-[var(--chrome-hover)]`,children:[(0,Q.jsx)(Ys,{size:14,stroke:1.75}),`Open`]}),(0,Q.jsx)(`button`,{type:`button`,"data-testid":`web-done`,onClick:()=>n.getState().endEdit(i.id),className:`h-6 rounded-lg bg-[var(--chrome-accent)] px-2.5 text-white transition-colors hover:bg-[var(--chrome-accent-hover)]`,children:`Done`})]})}function FD(e){let{containerRef:t,interactive:n,interaction:r,selection:i,panel:a,tables:o,lanes:s,measure:c,pasteChoiceOpen:l,resolvePasteChoice:u,unlockReveal:d}=e;xy(`CanvasScene`);let f=W(),p=U(e=>e.viewport),m=U(e=>e.shapes),h=U(e=>e.selectedIds),g=U(e=>e.editSession),_=be(g),v=U(e=>e.aiGhost),y=U(e=>e.animateSlideId!==null),b=U(e=>e.flowEdit!==null||e.flowPlay!==null||e.flowPreview!==null),x=U(e=>e.tool),S=U(e=>e.shapeKind),C=U(e=>e.chartKind),w=U(e=>e.frameKind),T=U(e=>e.pendingIcon),E=U(e=>e.pendingControl),D=U(e=>e.showGrid),O=U(e=>e.presentingIndex!==null),k=U(e=>e.draft),A=U(e=>e.polyDraft),j=U(e=>e.marquee),M=U(e=>e.lasso),N=U(e=>e.bindTarget),P=U(e=>e.snapDot),F=U(e=>e.hoverWorld),I=U(e=>e.snapGuides),L=U(e=>e.transforming),ee=U(e=>e.eraserTrail),R=U(e=>e.style),{setViewport:z,endEdit:B,setSnapGuides:V}=f.getState(),te=(0,J.useMemo)(()=>{if(!A)return null;let e=[...A.points,A.cursor],t=A.closed&&e.length>2?[e[0]]:[];return{id:`__line_draft__`,type:`line`,points:[...e,...t],color:R.color,strokeWidth:R.strokeWidth,dash:R.dash,startArrow:!A.closed&&R.startArrow,endArrow:!A.closed&&R.endArrow,startHead:R.startHead,endHead:R.endHead,opacity:R.opacity}},[A,R]),ne=a.editingChart;yD({containerRef:t,setViewport:z});let[re,ie]=(0,J.useState)({width:0,height:0});(0,J.useEffect)(()=>{let e=t.current;if(!e)return;let n=()=>ie({width:e.clientWidth,height:e.clientHeight});n();let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[t]);let ae=OD({shapes:m,viewport:p,containerSize:re,selectedIds:h,editingId:_});jD({viewport:p,containerSize:re});let oe=bD(ae,p.zoom);SD(ae,oe);let se=j?(()=>{let e=_r(j.start,p),t=_r(j.end,p);return{left:Math.min(e.x,t.x),top:Math.min(e.y,t.y),width:Math.abs(e.x-t.x),height:Math.abs(e.y-t.y)}})():null,ce=M&&M.length>1?M.map(e=>{let t=_r(e,p);return`${t.x},${t.y}`}).join(` `):null;return(0,Q.jsxs)(Q.Fragment,{children:[D&&(0,Q.jsx)(_b,{viewport:p}),(0,Q.jsxs)(_D,{viewport:p,children:[(0,Q.jsx)(gT,{}),(0,Q.jsx)(pT,{shapes:ae,draft:k,lineDraft:te,editSession:g,interactive:n,bindTarget:N,snapDot:P,onShapePointerDown:r.onShapePointerDown,onLabelPointerDown:r.onLabelPointerDown,onBeginEdit:i.beginEdit,onBeginEditCell:i.beginEditCell,onBeginEditLane:s.beginEditLane,onBeginCrop:i.beginCrop,onBeginVertexEdit:i.beginVertexEdit,onCommitText:i.commitText,onCommitCell:o.commitCell,onCommitLane:s.commitLane,onMeasureCell:c.onMeasureCell,onMeasureLabel:c.onMeasureLabel,onMeasureLifelineWidth:c.onMeasureLifelineWidth,onHover:i.onHover,zoom:oe,hideFigures:O}),!O&&(0,Q.jsx)(mD,{zoom:p.zoom}),!O&&(0,Q.jsx)(no,{active:y,feature:sb,children:e=>(0,Q.jsx)(e,{zoom:p.zoom})}),(0,Q.jsx)(yb,{interactive:n,transforming:L,zoom:p.zoom}),(0,Q.jsx)(wb,{interactive:n,zoom:p.zoom,shapes:ae}),v&&(0,Q.jsx)(zE,{bounds:v}),F&&!k&&(0,Q.jsx)(BE,{tool:x,kind:S,chartKind:C,frameKind:w,at:F,icon:T,control:E})]}),!O&&(0,Q.jsx)(lD,{viewport:p}),!O&&(0,Q.jsx)(no,{active:b,feature:Jy,children:e=>(0,Q.jsx)(e,{viewport:p})}),se&&(0,Q.jsx)(`div`,{className:`pointer-events-none absolute border border-[var(--canvas-selection)] bg-[var(--canvas-selection)]/10`,style:se}),ce&&(0,Q.jsx)(`svg`,{className:`pointer-events-none absolute inset-0 h-full w-full`,"data-testid":`lasso`,children:(0,Q.jsx)(`polygon`,{points:ce,className:`fill-[var(--canvas-selection)]/10 stroke-[var(--canvas-selection)]`,strokeWidth:1,strokeDasharray:`4 3`})}),(0,Q.jsx)(NE,{guides:I,viewport:p}),n&&!O&&(0,Q.jsx)(oD,{viewport:p}),n&&!O&&(0,Q.jsx)(eE,{viewport:p,setSnapGuides:V}),i.showSelection&&(0,Q.jsx)(WT,{shapes:i.selectedShapes,viewport:p,gestures:r.selectionGestures,onArrowBendReset:i.resetArrowBend,onSurfaceDoubleClick:i.editSelection,cropping:g.kind===`crop`&&i.selectedShapes.length===1&&i.selectedShapes[0].id===g.shapeId,editingVertices:g.kind===`vertices`&&i.selectedShapes.length===1&&i.selectedShapes[0].id===g.shapeId,transforming:L,isGroup:i.selectionIsGroup,onTableInsertColumn:o.insertColumn,onTableDeleteColumn:o.deleteColumn,onTableInsertRow:o.insertRow,onTableDeleteRow:o.deleteRow,onLaneAdd:s.addLane,onLaneDelete:s.deleteLane,onLaneEdit:s.beginEditLane,laneEditing:g.kind===`lane`}),!O&&(0,Q.jsx)(PD,{viewport:p}),(0,Q.jsx)(CE,{active:n&&xe(g,m),viewport:p}),(0,Q.jsx)(OE,{}),n&&ne&&(0,Q.jsx)(Nb,{shape:ne,viewport:p,onChange:e=>o.setChartCells(ne.id,e),onClose:()=>B(ne.id)}),l&&(0,Q.jsx)(Cx,{onPick:u,onCancel:()=>u(`table`)}),n&&i.revealedUnit.length>0&&(0,Q.jsx)(aD,{shapes:i.revealedUnit,viewport:p,onUnlock:d}),(0,Q.jsx)(eD,{interactive:n,transforming:L,revealed:i.revealedUnit.length>0,viewport:p}),(0,Q.jsx)(iD,{interactive:n,transforming:L,viewport:p}),(0,Q.jsx)(xx,{viewport:p}),!O&&(0,Q.jsx)(jE,{}),x===`laser`&&!O&&(0,Q.jsx)(Za,{}),!O&&(0,Q.jsx)(Ya,{trail:ee}),(0,Q.jsx)(ro,{})]})}function ID(e){let{kinds:t,iconsInk:n,iconLabeled:r,shapeKind:i,control:a,chart:o,textSizing:s,selectionCount:c,laneFrame:l}=e,u=t.has(`icon`)&&n,d=i===`fork-join`,f=a?Ti[a.kind].fill:!1,p=a?Ti[a.kind].font:t.has(`control`),m=(e,n=[])=>nh(new Set([...t].filter(e=>!n.includes(e))),e),h=t.has(`rectangle`)&&!d,g=t.has(`figure`)&&!l,_=h||t.has(`polygon`)||g||f,v=_||t.has(`sticky`),y=h,b=h,x=m(`smooth`),S=m(`background`),C=t.has(`rectangle`)||t.has(`arrow`)||t.has(`draw`)||t.has(`line`)||t.has(`figure`),w=C||u,T=C,E=t.has(`rectangle`)||t.has(`figure`),D=m(`fontSize`,[`control`])||p,O=m(`textAlign`),k=m(`textVAlign`,[`text`])||t.has(`text`)&&s===`fixed`,A=m(`textPadding`),j=t.has(`text`)&&s!=null,M=m(`lineHeight`),N=m(`labelColor`),P=!!o,F=t.has(`arrow`)||t.has(`text`)||t.has(`draw`)||t.has(`line`)||t.has(`control`)||t.has(`figure`)||u||r||d,I=m(`bendStyle`),L=m(`startArrow`),ee=c>=1,R=c>=2,z=c>=3;return{showShapeKind:t.has(`rectangle`),showCorner:t.has(`rectangle`)&&vr(i)||m(`corner`,[`rectangle`]),showFill:v,showFillStyles:y,showOutline:b,showFillTransparent:_,showBackground:S,showStroke:w,showStrokeStyle:T,showNoBorder:E,showFont:D,showTextAlign:O,showTextVAlign:k,showTextPadding:A,showTextSizing:j,showTextSpacing:M,showLabelColor:N,showChartType:P,showColor:F,showLineType:I,showArrowheads:L,showSmooth:x,showLayer:ee,showAlign:R,showDistribute:z}}var LD={solid:`border-solid`,dashed:`border-dashed`,dotted:`border-dotted`},RD=24,zD=9;function BD(e,t,n){return e===`none`?[]:gt(e,t,n,zD)}function VD(e){let{pieces:t}=e;return(0,Q.jsx)(Q.Fragment,{children:t.map((e,t)=>(0,Q.jsx)(`path`,{d:e.d,fill:e.fill===`solid`?`currentColor`:e.fill===`white`?`#ffffff`:`none`,stroke:`currentColor`,strokeWidth:1.75,strokeLinecap:`round`,strokeLinejoin:`round`},t))})}function HD(e){let{style:t,side:n}=e,r=RD/2,i=n===`end`?{x:RD-5,y:r}:{x:5,y:r},a=n===`end`?{x:5,y:r}:{x:RD-5,y:r},o=n===`end`?0:Math.PI;return(0,Q.jsxs)(`svg`,{width:22,height:22,viewBox:`0 0 ${RD} ${RD}`,"aria-hidden":!0,children:[(0,Q.jsx)(`line`,{x1:a.x,y1:a.y,x2:i.x,y2:i.y,stroke:`currentColor`,strokeWidth:1.75,strokeLinecap:`round`}),(0,Q.jsx)(VD,{pieces:BD(t,i,o)})]})}var UD={bar:2,crowOne:6,circle:8,circleOutline:8,cross:8,crowOneOrMany:12,crowZeroOrOne:12,crowZeroOrMany:15},WD=e=>e===`none`?zD:UD[e]??zD;function GD(e){let{start:t,end:n}=e,r=RD/2,i=Math.max(26,4+WD(t)+7+WD(n)+4),a=(e,t)=>{let n=e===`end`?{x:i-4,y:r}:{x:4,y:r};return(0,Q.jsx)(`g`,{opacity:t===`none`?.3:1,children:(0,Q.jsx)(VD,{pieces:BD(t===`none`?`arrow`:t,n,e===`end`?0:Math.PI)})})};return(0,Q.jsxs)(`svg`,{width:i*22/RD,height:22,viewBox:`0 0 ${i} ${RD}`,"aria-hidden":!0,children:[(0,Q.jsx)(`line`,{x1:4,y1:r,x2:i-4,y2:r,stroke:`currentColor`,strokeWidth:1.75,strokeLinecap:`round`}),a(`start`,t),a(`end`,n)]})}function KD(e){let{option:t,side:n,active:r,onClick:i}=e;return(0,Q.jsx)(`button`,{type:`button`,"data-testid":`arrowhead-${n}-${t}`,"aria-pressed":r,onClick:i,className:`flex aspect-square items-center justify-center rounded-lg transition-colors ${al(r)}`,children:(0,Q.jsx)(HD,{style:t,side:n})})}function qD(e){let{style:t,onChange:n}=e,r=t.startArrow?t.startHead:`none`,i=t.endArrow?t.endHead:`none`,a=(e,t)=>e&&!Lt.includes(t),[o,s]=(0,J.useState)(a(t.startArrow,t.startHead)||a(t.endArrow,t.endHead));function c(e,t){if(t===`none`){n(e===`end`?{endArrow:!1}:{startArrow:!1});return}n(e===`end`?{endArrow:!0,endHead:t}:{startArrow:!0,startHead:t})}function l(e){let n=e===`end`?t.endArrow:t.startArrow,r=e===`end`?t.endHead:t.startHead,i=[`none`,...Lt,...o?[...st,...Mt]:[]];return(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`div`,{className:`px-1 text-[11px] text-[var(--chrome-fg-500)]`,children:e===`end`?`End`:`Start`}),(0,Q.jsx)(`div`,{className:`grid grid-cols-5 gap-1.5`,children:i.map(t=>(0,Q.jsx)(KD,{option:t,side:e,active:t===`none`?!n:n&&r===t,onClick:()=>c(e,t)},t))})]})}return(0,Q.jsx)(Va,{label:`Arrowheads`,caret:!0,trigger:(0,Q.jsx)(`span`,{children:(0,Q.jsx)(GD,{start:r,end:i})}),children:(0,Q.jsxs)(`div`,{className:`w-56 space-y-2`,children:[l(`start`),l(`end`),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>s(e=>!e),className:`flex w-full items-center justify-between rounded-md px-1 py-1 text-[12px] text-[var(--chrome-fg-500)] transition-colors hover:bg-[var(--chrome-rest)]`,children:[(0,Q.jsx)(`span`,{children:`More options`}),(0,Q.jsx)(C,{size:14,stroke:2,className:`transition-transform ${o?`rotate-180`:``}`})]})]})})}var JD=ii.filter(e=>e!==`transparent`);function YD(e){let{title:t,values:n,labels:r,testPrefix:i,isActive:a,onPick:o}=e;return(0,Q.jsxs)(`div`,{className:`mt-2 space-y-1 border-t border-[var(--chrome-ring)] pt-2`,children:[(0,Q.jsx)(`div`,{className:`px-1 text-[11px] text-[var(--chrome-fg-500)]`,children:t}),(0,Q.jsx)(`div`,{className:`flex items-center gap-1`,children:n.map((e,n)=>(0,Q.jsx)(La,{testId:`${i}-${e}`,ariaLabel:`${t} ${r[n]}`,active:a(e),onClick:()=>o(e),children:(0,Q.jsx)(`span`,{className:`text-[11px] font-medium tabular-nums`,children:r[n]})},e))})]})}function XD(e){let{value:t,autoColor:n,onChange:r}=e;return(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(`span`,{className:`flex-1 px-1 text-[11px] text-[var(--chrome-fg-500)]`,children:`Text`}),(0,Q.jsx)(Pa,{value:t,autoColor:n,colors:JD,customFallback:`#9c36b5`,testId:`label-color`,ariaLabel:`Text color`,onPick:r})]})}var ZD=ii.filter(e=>e!==`transparent`);function QD(e){let{style:t,onChange:n}=e,r=t.dash===`none`,i=r?`none`:t.stroke??`auto`,a=r?{dash:`solid`}:{};return(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(`span`,{className:`flex-1 px-1 text-[11px] text-[var(--chrome-fg-500)]`,children:`Outline`}),(0,Q.jsx)(Pa,{value:i,autoColor:`var(--canvas-ink)`,noneOption:!0,colors:ZD,customFallback:`#1971c2`,testId:`outline`,ariaLabel:`Outline color`,onPick:e=>{if(e===`none`){n({dash:`none`});return}if(e===`auto`){n({stroke:`auto`,...a});return}n({stroke:e,...a})}})]})}function $D(e){let{style:t,showFill:n,showFillStyles:r,showOutline:i,showFillTransparent:a,showSmooth:o,showColor:s,showLabelColor:c,showBackground:l,onChange:u}=e,d=t.fill!==`transparent`&&!Tr.some(e=>e.pastel===t.fill),f=t.fillStyle===`shadow`?`bold`:t.fillStyle,p=t.shadow??t.fillStyle===`shadow`,m=t.background??`transparent`,h=[n,s,c,l].filter(Boolean).length>1,g=h?`Colors`:n?`Fill`:s?`Color`:c?`Text color`:`Background`,_=n?mi(t.fill,f):null,v=_?_.fill===`none`?`transparent`:_.fill:l?m:null,y=s?t.color:c?t.labelColor??`auto`:null,b=t.fill===`transparent`||t.fill===`#ffffff`,x=`var(--canvas-ink)`;return _&&(x=b?vt(_.text):_.text),(0,Q.jsx)(Va,{label:g,caret:!0,trigger:v!==null&&y!==null?Da(v,(0,Q.jsx)(`span`,{className:`text-[12px] leading-none`,style:{color:y===`auto`?x:vt(y)},children:`A`})):Da(v??y??`#1e1e1e`),children:(0,Q.jsxs)(`div`,{className:`w-56 space-y-2.5 [&>*+*]:border-t [&>*+*]:border-[var(--chrome-ring)] [&>*+*]:pt-2.5`,children:[n&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[h&&!r&&(0,Q.jsx)(`div`,{className:`px-1 text-[11px] text-[var(--chrome-fg-500)]`,children:`Fill`}),r&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`px-1 text-[11px] text-[var(--chrome-fg-500)]`,children:`Style`}),(0,Q.jsxs)(`div`,{className:`flex gap-1`,children:[ei.map(e=>(0,Q.jsx)(`button`,{type:`button`,title:e.hint,"data-testid":`fill-style-${e.value}`,onClick:()=>u({fillStyle:e.value,shadow:p}),className:`flex-1 rounded-md px-0.5 py-1 text-[11px] transition-colors ${al(f===e.value)}`,children:e.label},e.value)),(0,Q.jsx)(S,{label:`Drop shadow`,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Drop shadow`,"aria-pressed":p,"data-testid":`fill-shadow`,onClick:()=>u({shadow:!p}),className:`ml-1 flex w-8 items-center justify-center rounded-md py-1 transition-colors ${al(p)}`,children:(0,Q.jsx)(Rp,{size:14,stroke:1.75})})})]}),(0,Q.jsx)(`div`,{className:`px-1 text-[11px] text-[var(--chrome-fg-500)]`,children:`Color`})]}),o&&(0,Q.jsxs)(`div`,{className:`mb-1 flex items-center gap-1`,children:[(0,Q.jsx)(S,{label:`Rounded outline`,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Rounded outline`,"aria-pressed":!!t.smooth,"data-testid":`polygon-smooth`,onClick:()=>u({smooth:!t.smooth}),className:`flex w-8 items-center justify-center rounded-md py-1 transition-colors ${al(!!t.smooth)}`,children:(0,Q.jsx)(Kp,{size:14,stroke:1.75})})}),(0,Q.jsx)(`span`,{className:`text-[11px] text-[var(--chrome-fg-500)]`,children:`Rounded`})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[a&&(0,Q.jsx)(Ha,{hue:`transparent`,fillStyle:f,active:t.fill===`transparent`,onClick:()=>u({fill:`transparent`}),testId:`fill-hue-transparent`}),Tr.map(e=>(0,Q.jsx)(Ha,{hue:e.pastel,fillStyle:f,active:t.fill===e.pastel,onClick:()=>u({fill:e.pastel}),testId:`fill-hue-${e.key}`},e.key)),(0,Q.jsx)(Ea,{active:d,picked:d?t.fill:`#3b82f6`,onChange:e=>u({fill:e}),baseTestId:`fill`})]})]}),i&&(0,Q.jsx)(QD,{style:t,onChange:u}),s&&(0,Q.jsx)(Ba,{title:h?`Ink`:void 0,value:t.color,onChange:e=>u({color:e}),testId:`color`}),c&&(0,Q.jsx)(XD,{value:t.labelColor??`auto`,autoColor:x,onChange:e=>u({labelColor:e})}),l&&(0,Q.jsx)(Ba,{title:h?`Background`:void 0,value:m,onChange:e=>u({background:e}),testId:`bg`,customFallback:`#ffe8a3`})]})})}var eO=[{value:`bar`,label:`Bar`,Icon:hs},{value:`line`,label:`Line`,Icon:Ls},{value:`area`,label:`Area`,Icon:ps},{value:`scatter`,label:`Scatter`,Icon:Is},{value:`pie`,label:`Pie`,Icon:Ps},{value:`donut`,label:`Donut`,Icon:_s},{value:`radar`,label:`Radar`,Icon:Yf},{value:`quadrant`,label:`Quadrant`,Icon:ys}],tO=[{value:`number`,label:`1.2k`},{value:`percent`,label:`%`},{value:`currency`,label:`$`}];function nO(e){return e===`bar`||e===`line`||e===`area`||e===`scatter`}function rO(e){return e!==`pie`&&e!==`donut`&&e!==`quadrant`}function iO(e){let{label:t,on:n,onClick:r}=e;return(0,Q.jsxs)(`button`,{type:`button`,onClick:r,className:`flex w-full items-center justify-between gap-3 rounded-lg px-1.5 py-1 text-[13px] text-[var(--chrome-fg-700)] transition-colors hover:bg-[var(--chrome-divider)]`,children:[(0,Q.jsx)(`span`,{children:t}),(0,Q.jsx)(`span`,{className:`flex h-4 w-7 items-center rounded-full p-0.5 transition-colors ${n?`bg-[var(--chrome-accent)]`:`bg-[var(--chrome-active)]`}`,children:(0,Q.jsx)(`span`,{className:`h-3 w-3 rounded-full bg-white transition-transform ${n?`translate-x-3`:``}`})})]})}function aO(e){let{placeholder:t,value:n,testId:r,onChange:i,onBlur:a}=e,{history:o}=H();return(0,Q.jsx)(`input`,{value:n,placeholder:t,"data-testid":r,onChange:e=>i(e.target.value),onFocus:o.beginTransaction,onBlur:()=>{o.endTransaction(),a?.()},className:`h-7 w-full rounded-md border border-[var(--chrome-ring)] px-2 text-[12px] text-[var(--chrome-fg-700)] outline-none focus:border-gray-400`})}function oO(e){let{placeholder:t,testId:n,value:r,onChange:i}=e,[a,o]=(0,J.useState)(null);return(0,Q.jsx)(aO,{placeholder:t,testId:n,value:a??r,onChange:e=>{o(e),i(e)},onBlur:()=>o(null)})}function sO(e){let{chart:t,onPatch:n}=e;return(0,Q.jsx)(Va,{label:`Chart type`,caret:!0,trigger:(0,Q.jsx)((eO.find(e=>e.value===t.chartType)??eO[0]).Icon,{size:18,stroke:1.75}),children:(0,Q.jsx)(`div`,{className:`grid w-40 grid-cols-3 gap-1`,children:eO.map(e=>(0,Q.jsxs)(`button`,{type:`button`,"data-testid":`chart-type-${e.value}`,onClick:()=>n({chartType:e.value,...e.value===`quadrant`?{showTitles:!0}:{}}),className:`flex h-12 flex-col items-center justify-center gap-1 rounded-lg text-[10px] transition-colors ${sl(t.chartType===e.value)}`,children:[(0,Q.jsx)(e.Icon,{size:18,stroke:1.75}),e.label]},e.value))})})}function cO(e){let{chart:t,onPatch:n}=e,r=Fo(t).series,i=(e,r)=>{let i=(t.seriesColors??[]).slice();for(;i.length<=e;)i.push(void 0);i[e]=r,n({seriesColors:i})};return(0,Q.jsx)(Va,{label:`Series colors`,caret:!0,trigger:(0,Q.jsx)(`span`,{className:`flex items-center -space-x-1`,children:r.slice(0,3).map((e,t)=>(0,Q.jsx)(`span`,{className:`h-3.5 w-3.5 rounded-full ring-1 ring-white`,style:{background:e.color}},t))}),children:(0,Q.jsx)(`div`,{className:`w-56 space-y-2`,children:r.map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`w-14 shrink-0 truncate text-[12px] text-[var(--chrome-fg-600)]`,children:e.name||`Series ${t+1}`}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:Ro.map(n=>(0,Q.jsx)(`button`,{type:`button`,"aria-label":n,onClick:()=>i(t,n),className:`h-5 w-5 rounded-full transition-transform hover:scale-110 ${e.color===n?`ring-2 ring-[var(--chrome-fg-900)] ring-offset-1`:``}`,style:{background:n}},n))})]},t))})})}function lO(e){return(0,Q.jsx)(`div`,{className:`px-0.5 pt-1 text-[11px] text-[var(--chrome-fg-500)]`,children:e.children})}var uO=[{index:1,placeholder:`Top left`},{index:0,placeholder:`Top right`},{index:2,placeholder:`Bottom left`},{index:3,placeholder:`Bottom right`}];function dO(e){let{color:t,label:n,testId:r,onChange:i}=e,a=H();return(0,Q.jsxs)(Dc,{children:[(0,Q.jsx)(S,{label:n,children:(0,Q.jsx)(Ca,{"aria-label":n,"data-testid":r,className:`h-5 w-5 shrink-0 cursor-pointer rounded-full ring-1 ring-black/20 transition-transform hover:scale-110 data-[popup-open]:scale-110`,style:{background:t}})}),(0,Q.jsx)(Mc,{children:(0,Q.jsx)(Lc,{side:`top`,align:`center`,sideOffset:8,className:`outline-none`,children:(0,Q.jsx)(Rc,{"data-overlay":!0,"data-panel-popup":!0,"data-editor-runtime-id":a.id,"data-testid":`${r}-popup`,className:`p-2.5 ${q.popup}`,children:(0,Q.jsx)(Ba,{value:t,onChange:i,testId:r,customFallback:t,colors:Ro})})})})]})}function fO(e){let{chart:t,onPatch:n}=e,r=t.quadrantLabels??[],i=Do(t.xTitle),a=Do(t.yTitle),o=(e,t)=>{let i=r.slice();for(;i.length<4;)i.push(``);i[e]=t,n({quadrantLabels:i})},s=(e,r)=>{let i=(t.quadrantColors??[]).slice();for(;i.length<4;)i.push(void 0);i[e]=r,n({quadrantColors:i})},c=e=>t.quadrantColors?.[e]??Vo[e],l=t.seriesColors?.[0]??Ro[0];return(0,Q.jsxs)(`div`,{className:`w-60 space-y-1`,children:[(0,Q.jsx)(lO,{children:`Title`}),(0,Q.jsx)(aO,{placeholder:`Chart title`,value:t.title??``,onChange:e=>n({title:e,showTitles:!0})}),(0,Q.jsx)(lO,{children:`X-axis (left → right)`}),(0,Q.jsxs)(`div`,{className:`flex gap-1`,children:[(0,Q.jsx)(`div`,{className:`flex-1`,children:(0,Q.jsx)(oO,{placeholder:`Low`,testId:`quad-x-low`,value:i.low,onChange:e=>n({xTitle:Oo(e,i.high)})})}),(0,Q.jsx)(`div`,{className:`flex-1`,children:(0,Q.jsx)(oO,{placeholder:`High`,testId:`quad-x-high`,value:i.high,onChange:e=>n({xTitle:Oo(i.low,e)})})})]}),(0,Q.jsx)(lO,{children:`Y-axis (bottom → top)`}),(0,Q.jsxs)(`div`,{className:`flex gap-1`,children:[(0,Q.jsx)(`div`,{className:`flex-1`,children:(0,Q.jsx)(oO,{placeholder:`Low`,testId:`quad-y-low`,value:a.low,onChange:e=>n({yTitle:Oo(e,a.high)})})}),(0,Q.jsx)(`div`,{className:`flex-1`,children:(0,Q.jsx)(oO,{placeholder:`High`,testId:`quad-y-high`,value:a.high,onChange:e=>n({yTitle:Oo(a.low,e)})})})]}),(0,Q.jsx)(lO,{children:`Quadrant labels`}),(0,Q.jsx)(`div`,{className:`grid grid-cols-2 gap-1`,children:uO.map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(dO,{color:c(e.index),label:`${e.placeholder} color`,testId:`quad-zone-${e.index}`,onChange:t=>s(e.index,t)}),(0,Q.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Q.jsx)(aO,{placeholder:e.placeholder,value:r[e.index]??``,onChange:t=>o(e.index,t)})})]},e.index))}),(0,Q.jsx)(lO,{children:`Point color`}),(0,Q.jsx)(Ba,{value:l,onChange:e=>n({seriesColors:[e]}),testId:`quad-point`,customFallback:l,colors:Ro})]})}function pO(e){let{chart:t,onPatch:n}=e,r=t.chartType,i=nO(r),a=!!t.showLegend,o=i?`number`:`percent`;return r===`quadrant`?(0,Q.jsx)(Va,{label:`Chart options`,caret:!0,trigger:(0,Q.jsx)(ms,{size:17,stroke:1.75}),children:(0,Q.jsx)(fO,{chart:t,onPatch:n})}):(0,Q.jsx)(Va,{label:`Chart options`,caret:!0,trigger:(0,Q.jsx)(ms,{size:17,stroke:1.75}),children:(0,Q.jsxs)(`div`,{className:`w-56 space-y-1`,children:[r===`bar`&&(0,Q.jsx)(iO,{label:`Horizontal`,on:!!t.horizontal,onClick:()=>n({horizontal:!t.horizontal})}),(r===`bar`||r===`area`)&&(0,Q.jsx)(iO,{label:`Stacked`,on:!!t.stacked,onClick:()=>n({stacked:!t.stacked})}),i&&(0,Q.jsx)(iO,{label:`Value labels`,on:!!t.showValues,onClick:()=>n({showValues:!t.showValues})}),(0,Q.jsx)(iO,{label:`Legend`,on:a,onClick:()=>n({showLegend:!a})}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-1.5 py-1 text-[13px] text-[var(--chrome-fg-700)]`,children:[(0,Q.jsx)(`span`,{children:`Numbers`}),(0,Q.jsx)(`div`,{className:`flex items-center gap-1`,children:tO.map(e=>(0,Q.jsx)(La,{testId:`number-format-${e.value}`,active:(t.numberFormat??o)===e.value,onClick:()=>n({numberFormat:e.value}),children:(0,Q.jsx)(`span`,{className:`px-0.5 text-[11px]`,children:e.label})},e.value))})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5 border-t border-[var(--chrome-ring)] pt-1.5`,children:[(0,Q.jsx)(iO,{label:`Titles`,on:!!t.showTitles,onClick:()=>n({showTitles:!t.showTitles})}),t.showTitles&&(0,Q.jsxs)(`div`,{className:`space-y-1.5 px-1.5`,children:[(0,Q.jsx)(aO,{placeholder:`Chart title`,value:t.title??``,onChange:e=>n({title:e})}),i&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(aO,{placeholder:`X-axis title`,value:t.xTitle??``,onChange:e=>n({xTitle:e})}),(0,Q.jsx)(aO,{placeholder:`Y-axis title`,value:t.yTitle??``,onChange:e=>n({yTitle:e})})]})]})]})]})})}function mO(e){return rO(e.chartType)&&Fo(e).series.length>0}function hO(e){return Ti[e.kind].value!==void 0}function gO(e){let{control:t,onPatch:n}=e,{history:r}=H(),i=ka(r),a=Ti[t.kind].value;if(a===`range`){let e=Math.round((t.value??.5)*100);return(0,Q.jsx)(Va,{label:t.kind===`slider`?`Slider value`:`Fill level`,caret:!0,trigger:(0,Q.jsx)(ms,{size:18,stroke:1.75}),children:(0,Q.jsxs)(`div`,{className:`flex w-44 items-center gap-2 px-1`,children:[(0,Q.jsx)(`input`,{type:`range`,min:0,max:100,value:e,"data-testid":`control-value-slider`,onChange:e=>n({value:Number(e.target.value)/100}),...i,className:`h-1 flex-1 cursor-pointer accent-[var(--chrome-fg-600)]`}),(0,Q.jsxs)(`span`,{className:`w-9 text-right text-[12px] text-[var(--chrome-fg-500)]`,children:[e,`%`]})]})})}if(a===`alert`){let e=Math.max(0,Math.min(wi.length-1,Math.round(t.value??0)));return(0,Q.jsx)(Va,{label:`Alert type`,caret:!0,trigger:(0,Q.jsx)(Rs,{size:18,stroke:1.75}),children:(0,Q.jsx)(`div`,{className:`flex w-44 flex-col gap-1`,children:wi.map((t,r)=>(0,Q.jsxs)(`button`,{type:`button`,"data-testid":`control-alert-${t.key}`,onClick:()=>n({value:r}),className:`flex items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-[12px] transition-colors ${sl(r===e)}`,children:[(0,Q.jsx)(`span`,{className:`h-3 w-3 shrink-0 rounded-full`,style:{backgroundColor:t.ink}}),t.label]},t.key))})})}if(a===`stars`){let e=Vr(Math.round(t.value??3),0,5);return(0,Q.jsx)(Va,{label:`Rating`,caret:!0,trigger:(0,Q.jsx)(Sp,{size:18,stroke:1.75}),children:(0,Q.jsx)(`div`,{className:`flex w-44 items-center gap-1 px-1`,children:[1,2,3,4,5].map(t=>(0,Q.jsx)(`button`,{type:`button`,"data-testid":`control-rating-${t}`,onClick:()=>n({value:t}),className:`flex-1 rounded-lg px-1.5 py-1.5 text-[12px] transition-colors ${sl(t<=e)}`,children:t},t))})})}if(a===`index`){let e=t.label.split(` | `).map(e=>e.trim()).filter(e=>e.length>0),r=Math.max(0,Math.min(e.length-1,Math.round(t.value??0)));return(0,Q.jsx)(Va,{label:`Active item`,caret:!0,trigger:(0,Q.jsx)(Sp,{size:18,stroke:1.75}),children:(0,Q.jsx)(`div`,{className:`flex w-44 flex-col gap-1`,children:e.map((e,t)=>(0,Q.jsx)(`button`,{type:`button`,"data-testid":`control-active-${t}`,onClick:()=>n({value:t}),className:`truncate rounded-lg px-2.5 py-1.5 text-left text-[12px] transition-colors ${sl(t===r)}`,children:e},`${e}-${t}`))})})}if(a===`operator`){let e=t.label.trim().split(/\s+/)[0]?.toLowerCase()??``;return(0,Q.jsx)(Va,{label:`Operator`,caret:!0,trigger:(0,Q.jsx)(Fs,{size:18,stroke:1.75}),children:(0,Q.jsx)(`div`,{className:`grid w-44 grid-cols-2 gap-1`,children:Vt.map(r=>(0,Q.jsx)(`button`,{type:`button`,"data-testid":`control-operator-${r}`,onClick:()=>n({label:xt(t.label,r)}),className:`rounded-lg px-2.5 py-1.5 text-left text-[12px] transition-colors ${sl(r===e)}`,children:r},r))})})}if(a===`activation`){let e=[...t.activations??[]].sort((e,t)=>e.top-t.top);return(0,Q.jsx)(Va,{label:`Activation bars`,caret:!0,testId:`control-activation`,trigger:(0,Q.jsx)(Fp,{size:18,stroke:1.75}),children:(0,Q.jsxs)(`div`,{className:`flex w-44 flex-col gap-1`,children:[e.map((t,r)=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsxs)(`span`,{className:`flex-1 truncate px-2.5 py-1.5 text-left text-[12px] text-[var(--chrome-fg-600)]`,children:[`Bar `,r+1]}),(0,Q.jsx)(S,{label:`Remove bar`,side:`top`,children:(0,Q.jsx)(`button`,{type:`button`,"data-testid":`control-activation-remove-${r}`,onClick:()=>n({activations:e.length===1?void 0:e.filter((e,t)=>t!==r)}),className:`rounded-lg p-1.5 transition-colors ${sl(!1)}`,children:(0,Q.jsx)(Cc,{size:14,stroke:1.75})})})]},`${t.top}-${r}`)),(0,Q.jsxs)(`button`,{type:`button`,"data-testid":`control-activation-add`,onClick:()=>n({activations:[...e,Je(t)].sort((e,t)=>e.top-t.top)}),className:`flex items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-[12px] transition-colors ${sl(!1)}`,children:[(0,Q.jsx)(_c,{size:14,stroke:1.75}),`Add bar`]})]})})}let o=(t.value??0)>=.5;return(0,Q.jsx)(S,{label:t.kind===`toggle`?`On / off`:`Checked`,side:`top`,children:(0,Q.jsx)(`span`,{children:(0,Q.jsx)(La,{testId:`control-checked`,active:o,onClick:()=>n({value:+!o}),children:(0,Q.jsx)(Sp,{size:18,stroke:1.75})})})})}function _O(){xy(`SelectionStats`);let e=W(),t=H(),n=U(e=>e.shapes),r=U(e=>e.selectedIds),{replaceMany:i}=e.getState(),a=(0,J.useMemo)(()=>ha(n,r),[n,r]),o=(0,J.useMemo)(()=>pn(a,t.measurement),[a,t]);if(!o||a.length===0)return null;let s=a.length===1&&qn(a[0])?cr(a[0]):null,c=s!==null&&s%360!=0?a[0]:null,l=c?G(c,t.measurement):o,u=e=>{if(e.x!==void 0||e.y!==void 0){let r={x:(e.x??o.x)-o.x,y:(e.y??o.y)-o.y},s=new Set(a.map(e=>e.id));i(a.map(e=>Pe(e,r,n,s,t.measurement)));return}if(e.width!==void 0||e.height!==void 0){let t=l.width>0?Math.max(1,e.width??l.width)/l.width:1,n=l.height>0?Math.max(1,e.height??l.height)/l.height:1,r=c?{x:l.x+l.width/2,y:l.y+l.height/2}:{x:o.x,y:o.y};i(a.map(e=>ir(e,r,t,n)));return}if(e.angle!==void 0&&a.length===1){let t=a[0],n=(e.angle-cr(t))*Math.PI/180,r=Ct(t,Zn(t),n);i([`rotation`in r?{...r,rotation:e.angle}:r])}};return(0,Q.jsx)(Va,{label:`Position and size`,caret:!0,trigger:(0,Q.jsx)(ep,{size:18,stroke:1.75}),children:(0,Q.jsx)(`div`,{className:`flex flex-col gap-1.5`,"data-testid":`stats-popover`,children:(0,Q.jsxs)(`div`,{className:`grid grid-cols-2 gap-1.5`,children:[(0,Q.jsx)(Aa,{label:`X`,testId:`stat-x`,value:o.x,onCommit:e=>u({x:e})}),(0,Q.jsx)(Aa,{label:`Y`,testId:`stat-y`,value:o.y,onCommit:e=>u({y:e})}),(0,Q.jsx)(Aa,{label:`W`,testId:`stat-w`,value:l.width,onCommit:e=>u({width:e})}),(0,Q.jsx)(Aa,{label:`H`,testId:`stat-h`,value:l.height,onCommit:e=>u({height:e})}),s!==null&&(0,Q.jsx)(Aa,{label:`R`,testId:`stat-angle`,value:(s%360+360)%360,onCommit:e=>u({angle:e})})]})})})}function vO(e){let{value:t,onChange:n}=e,r=H(),[i,a]=(0,J.useState)(!1),[o,s]=(0,J.useState)(t),c=Oa();function l(){o.trim()!==t&&n(o.trim()||void 0)}function u(){let e=_n(o.trim());e&&window.open(e,`_blank`,`noopener,noreferrer`)}return(0,Q.jsxs)(Dc,{open:i,onOpenChange:e=>{if(a(e),e){s(t);return}l(),c.restore()},children:[(0,Q.jsx)(S,{label:`Link`,children:(0,Q.jsx)(Ca,{"aria-label":`Link`,"data-testid":`link-control`,onPointerDown:c.onPointerDown,onMouseDown:c.onMouseDown,className:`flex h-8 w-8 cursor-pointer items-center justify-center rounded-lg transition-colors hover:bg-[var(--chrome-hover)] data-[popup-open]:bg-[var(--chrome-hover)] ${t?`text-[var(--chrome-fg-900)]`:`text-[var(--chrome-fg-500)]`}`,children:(0,Q.jsx)(fc,{size:18,stroke:1.75})})}),(0,Q.jsx)(Mc,{children:(0,Q.jsx)(Lc,{sideOffset:8,side:`top`,children:(0,Q.jsx)(Rc,{"data-panel-popup":!0,"data-editor-runtime-id":r.id,"data-caret-safe":!0,...c.focusProps,onPointerDown:c.onPointerDown,onMouseDown:c.onMouseDown,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 p-1.5 ${q.popup}`,children:[(0,Q.jsx)(`input`,{"data-testid":`link-input`,value:o,autoFocus:!0,placeholder:`https://…`,onChange:e=>s(e.target.value),onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`&&(l(),a(!1))},className:`h-8 w-56 rounded-lg px-2 text-[13px] text-[var(--chrome-fg-900)] outline-none ring-1 ring-[var(--chrome-ring)] focus:ring-black/25`}),(0,Q.jsx)(S,{label:`Open link`,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Open link`,"data-testid":`link-open`,disabled:!o.trim(),onClick:u,className:`flex h-8 w-8 cursor-pointer items-center justify-center rounded-lg text-[var(--chrome-fg-700)] transition-colors hover:bg-[var(--chrome-hover)] disabled:text-[var(--chrome-fg-300)]`,children:(0,Q.jsx)(Ys,{size:18,stroke:1.75})})})]})})})})]})}function yO(){return(0,Q.jsx)(`div`,{"data-testid":`icon-picker-loading`,className:`flex w-[min(380px,calc(100vw-1rem))] items-center justify-center text-[12px] text-[var(--chrome-fg-500)] ${q.popup}`,style:{height:`min(70vh, 560px)`},children:`Loading icons…`})}function bO(e){let{icon:t,onPick:n}=e,r=H(),[i,a]=(0,J.useState)(!1),o=Oa();return t.source===`drawnicons`?(0,Q.jsx)(xO,{icon:t,onPick:n}):(0,Q.jsxs)(Dc,{open:i,onOpenChange:e=>{a(e),e||o.restore()},children:[(0,Q.jsx)(S,{label:`Icon`,children:(0,Q.jsxs)(Ca,{"aria-label":`Icon`,"data-testid":`icon-switcher`,onPointerDown:o.onPointerDown,onMouseDown:o.onMouseDown,onPointerEnter:()=>eo(tb),className:`flex h-8 cursor-pointer items-center justify-center gap-1 rounded-lg px-2 text-[var(--chrome-fg-900)] transition-colors hover:bg-[var(--chrome-hover)] data-[popup-open]:bg-[var(--chrome-hover)]`,children:[(0,Q.jsx)(SS,{name:t.name,source:t.source}),(0,Q.jsx)(Nc,{})]})}),(0,Q.jsx)(Mc,{children:(0,Q.jsx)(Lc,{side:`top`,align:`start`,sideOffset:8,children:(0,Q.jsx)(Rc,{"data-panel-popup":!0,"data-editor-runtime-id":r.id,"data-caret-safe":!0,...o.focusProps,onPointerDown:o.onPointerDown,onMouseDown:o.onMouseDown,children:(0,Q.jsx)(no,{active:i,feature:tb,fallback:(0,Q.jsx)(yO,{}),children:e=>(0,Q.jsx)(e,{onPick:(e,t)=>{n(e,t),a(!1)}})})})})})]})}function xO(e){let{icon:t,onPick:n}=e,[r,i]=(0,J.useState)(!1);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(S,{label:`Image`,children:(0,Q.jsxs)(`button`,{type:`button`,"aria-label":`Image`,"data-testid":`icon-switcher`,onPointerEnter:()=>eo(nb),onClick:()=>i(!0),className:`flex h-8 cursor-pointer items-center justify-center gap-1 rounded-lg px-2 text-[var(--chrome-fg-900)] transition-colors hover:bg-[var(--chrome-hover)] aria-expanded:bg-[var(--chrome-hover)]`,"aria-expanded":r,children:[(0,Q.jsx)(SS,{name:t.name,source:t.source}),(0,Q.jsx)(Nc,{})]})}),(0,Q.jsx)(no,{active:r,feature:nb,children:e=>(0,Q.jsx)(e,{open:!0,onOpenChange:i,onPick:n})})]})}function SO(e){let{icon:t,label:n,testId:r,placement:i,onPick:a,onRemove:o,onPlacement:s}=e,c=H(),[l,u]=(0,J.useState)(!1),[d,f]=(0,J.useState)(!1),p=Oa(),m=[{value:`hanging`,label:`Hang icon on the border`,glyph:Uf},{value:`inside`,label:`Icon inside, before the label`,glyph:Vp}],h=`flex w-full cursor-pointer items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[12px] text-[var(--chrome-fg-600)] transition-colors hover:bg-[var(--chrome-hover)]`;return(0,Q.jsxs)(Dc,{open:l,onOpenChange:e=>{u(e),e||(f(!1),p.restore())},children:[(0,Q.jsx)(S,{label:n,children:(0,Q.jsxs)(Ca,{"aria-label":n,"data-testid":r,onPointerDown:p.onPointerDown,onMouseDown:p.onMouseDown,onPointerEnter:()=>eo(tb),className:`flex h-8 cursor-pointer items-center justify-center gap-1 rounded-lg px-2 text-[var(--chrome-fg-900)] transition-colors hover:bg-[var(--chrome-hover)] data-[popup-open]:bg-[var(--chrome-hover)]`,children:[t?(0,Q.jsx)(SS,{name:t.name,source:t.source}):(0,Q.jsx)(Mp,{size:18,stroke:1.75,className:`text-[var(--chrome-fg-500)]`}),(0,Q.jsx)(Nc,{})]})}),(0,Q.jsx)(Mc,{children:(0,Q.jsx)(Lc,{side:`top`,align:`start`,sideOffset:8,children:(0,Q.jsx)(Rc,{"data-panel-popup":!0,"data-editor-runtime-id":c.id,"data-caret-safe":!0,...p.focusProps,onPointerDown:p.onPointerDown,onMouseDown:p.onMouseDown,children:!t||d?(0,Q.jsx)(no,{active:l&&(!t||d),feature:tb,fallback:(0,Q.jsx)(yO,{}),children:e=>(0,Q.jsx)(e,{onPick:(e,t)=>{a(e,t),u(!1),f(!1)}})}):(0,Q.jsxs)(`div`,{className:`flex w-44 flex-col p-1.5 ${q.popup}`,children:[s&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`px-1.5 pb-1 text-[11px] text-[var(--chrome-fg-500)]`,children:`Position`}),(0,Q.jsx)(`div`,{className:`flex items-center gap-1`,children:m.map(({value:e,label:t,glyph:n})=>(0,Q.jsx)(La,{testId:`icon-placement-${e}`,ariaLabel:t,active:(i??`hanging`)===e,onClick:()=>s(e),children:(0,Q.jsx)(n,{size:18,stroke:1.75})},e))}),(0,Q.jsx)(`div`,{className:`my-1.5 h-px bg-[var(--chrome-divider)]`})]}),(0,Q.jsxs)(`button`,{type:`button`,"data-testid":`icon-change`,onClick:()=>f(!0),className:h,children:[(0,Q.jsx)(Xs,{size:14,stroke:1.75}),`Change icon`]}),(0,Q.jsxs)(`button`,{type:`button`,"data-testid":`icon-remove`,onClick:()=>{o(),u(!1)},className:h,children:[(0,Q.jsx)(Ws,{size:14,stroke:1.75}),`Remove icon`]})]})})},!t||d?`picker`:`menu`)})]})}var CO=[{value:`sharp`,label:`Sharp corners`,Icon:Hf},{value:`rounded`,label:`Rounded corners`,Icon:Vf}];function wO(e){return Vr(Math.round(e*.85),1,7)}function TO(e){let{corner:t}=e;return(0,Q.jsx)(t===`rounded`?Vf:Hf,{size:16,stroke:1.75})}function EO(e){return e===`none`?`border-solid`:LD[e]}function DO(e){typeof document>`u`||!(`fonts`in document)||Zh(document.fonts,e,Kh)}var OO=[{value:`curved`,label:`Curved`},{value:`elbow`,label:`Elbow`}],kO=[{value:`left`,label:`Align text left`},{value:`center`,label:`Align text center`},{value:`right`,label:`Align text right`}],AO=[{value:`top`,label:`Align text top`},{value:`middle`,label:`Align text middle`},{value:`bottom`,label:`Align text bottom`}];function jO(e){let{figure:t,icon:n,onFigurePatch:r,onPickIcon:i}=e;return n?(0,Q.jsx)(bO,{icon:n,onPick:i}):t?(0,Q.jsx)(SO,{icon:t.titleIcon??null,label:`Frame icon`,testId:`icon-switcher`,onPick:(e,t)=>r({titleIcon:{name:e,source:t}}),onRemove:()=>r({titleIcon:void 0})}):null}function MO(e){let{badge:t,onBadgePatch:n}=e;return(0,Q.jsx)(SO,{icon:t??null,label:`Badge icon`,testId:`badge-switcher`,placement:t?.placement,onPick:(e,r)=>n({name:e,source:r,placement:t?.placement}),onRemove:()=>n(void 0),onPlacement:t?e=>n({...t,placement:e}):void 0})}function NO(e){let{shapeKind:t,onShapeKind:n}=e;return(0,Q.jsx)(Va,{label:`Shape`,caret:!0,closeOnPick:U(e=>e.coarsePointer),trigger:(0,Q.jsx)(jc,{kind:t}),children:(0,Q.jsx)(`div`,{className:`grid w-72 grid-cols-7 gap-1`,children:Gt.map(e=>(0,Q.jsx)(`button`,{type:`button`,"aria-label":e,"data-testid":`kind-${e}`,onClick:()=>n(e),className:`flex h-10 items-center justify-center rounded-lg transition-colors ${sl(t===e)}`,children:(0,Q.jsx)(jc,{kind:e,size:20})},e))})})}function PO(e){let{control:t,onControlPatch:n}=e;return t?(0,Q.jsx)(gO,{control:t,onPatch:n}):null}function FO(e){let{chart:t,onChartPatch:n}=e;return t?(0,Q.jsx)(sO,{chart:t,onPatch:n}):null}function IO(e){let{chart:t,onChartPatch:n}=e;return t?(0,Q.jsx)(cO,{chart:t,onPatch:n}):null}function LO(e){let{chart:t,onChartPatch:n}=e;return t?(0,Q.jsx)(pO,{chart:t,onPatch:n}):null}function RO(e){let{style:t,onChange:n,showFill:r,showFillStyles:i,showOutline:a,showFillTransparent:o,showSmooth:s,showBackground:c,showLabelColor:l,showColor:u}=e;return(0,Q.jsx)($D,{style:t,showFill:r,showFillStyles:i,showOutline:a,showFillTransparent:o,showSmooth:s,showColor:u,showLabelColor:l,showBackground:c,onChange:n})}function zO(e){let{style:t,shapeKind:n,onChange:r,showCorner:i,showStroke:a,showStrokeStyle:o,showNoBorder:s,showArrowheads:c}=e,l=a||o,{history:u}=H();return(0,Q.jsx)(Va,{label:l?`Stroke`:`Corners`,caret:!0,trigger:(0,Q.jsx)(`span`,{className:`flex w-5 items-center justify-center`,children:l?t.flow&&o?(0,Q.jsx)(Mf,{size:16,stroke:1.75}):t.dash===`none`&&o?(0,Q.jsx)(Lf,{size:16,stroke:1.75}):(0,Q.jsx)(`span`,{className:`w-5 border-[var(--chrome-fg-800)] ${o?EO(t.dash):`border-solid`}`,style:{borderTopWidth:wO(t.strokeWidth)}}):(0,Q.jsx)(TO,{corner:t.corner})}),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[a&&(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`div`,{className:`px-1 text-[11px] text-[var(--chrome-fg-500)]`,children:`Width`}),(0,Q.jsx)(`div`,{className:`flex w-44 items-center gap-2`,children:Dr.map((e,n)=>(0,Q.jsx)(La,{testId:`stroke-width-${e}`,active:t.strokeWidth===e,onClick:()=>r({strokeWidth:e}),children:(0,Q.jsx)(`span`,{className:`w-5 rounded-full bg-current`,style:{height:1+n*2}})},e))}),(0,Q.jsx)(`div`,{className:`flex w-44 items-center`,children:(0,Q.jsx)(Fa,{value:t.strokeWidth,onChange:e=>r({strokeWidth:e}),min:.25,max:64,step:.25,precision:2,label:`Stroke width`,fullWidth:!0,testId:`stroke-width-custom`,onNudgeStart:u.beginTransaction,onNudgeEnd:u.endTransaction})})]}),o&&(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`div`,{className:`px-1 text-[11px] text-[var(--chrome-fg-500)]`,children:`Style`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 ${s||c?`w-44`:`w-32`}`,children:[Qr.map(e=>(0,Q.jsx)(La,{testId:`dash-${e}`,active:t.dash===e&&!t.flow,onClick:()=>r({dash:e,flow:!1}),children:(0,Q.jsx)(`span`,{className:`w-5 border-t-2 border-current ${LD[e]}`})},e)),c&&(0,Q.jsx)(La,{testId:`dash-flow`,ariaLabel:`Animated flow`,active:t.flow??!1,onClick:()=>r({dash:`dashed`,flow:!0}),children:(0,Q.jsx)(Mf,{size:16,stroke:1.75})}),s&&(0,Q.jsx)(La,{testId:`dash-none`,active:t.dash===`none`,onClick:()=>r({dash:`none`,flow:!1}),children:(0,Q.jsx)(Lf,{size:16,stroke:1.75})})]})]}),i&&(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`div`,{className:`px-1 text-[11px] text-[var(--chrome-fg-500)]`,children:`Corners`}),(0,Q.jsx)(`div`,{className:`flex w-44 items-center gap-2`,children:CO.map(e=>(0,Q.jsx)(La,{testId:`corner-${e.value}`,ariaLabel:e.label,active:(t.corner??qt(n))===e.value,onClick:()=>r({corner:e.value}),children:(0,Q.jsx)(e.Icon,{size:16,stroke:1.75})},e.value))})]})]})})}function BO(e){let{style:t,onChange:n,showLineType:r,showArrowheads:i}=e;return(0,Q.jsxs)(Q.Fragment,{children:[r&&(0,Q.jsx)(Va,{label:`Line type`,caret:!0,trigger:(0,Q.jsx)(Ec,{bend:t.bendStyle,size:20}),children:(0,Q.jsx)(`div`,{className:`flex w-28 items-center gap-2`,children:OO.map(e=>(0,Q.jsx)(La,{testId:`bend-style-${e.value}`,ariaLabel:e.label,active:t.bendStyle===e.value,onClick:()=>n({bendStyle:e.value}),children:(0,Q.jsx)(Ec,{bend:e.value,size:24})},e.value))})}),i&&(0,Q.jsx)(qD,{style:t,onChange:n})]})}function VO(e){let{style:t,chart:n,onChange:r}=e,{history:i}=H();return(0,Q.jsx)(Va,{label:`Font`,caret:!0,trigger:(0,Q.jsx)(`span`,{style:{fontFamily:t.fontFamily,fontWeight:Fr(t.fontFamily)},children:`Aa`}),children:(0,Q.jsxs)(`div`,{className:`w-48`,children:[(0,Q.jsx)(`div`,{className:`-mx-1 flex flex-col px-1`,children:ni.map(e=>(0,Q.jsx)(`button`,{type:`button`,onPointerEnter:()=>DO(e.value),onFocus:()=>DO(e.value),onClick:()=>{DO(e.value),r({fontFamily:e.value})},style:{fontFamily:e.value,fontWeight:Fr(e.value)},className:`flex h-9 shrink-0 items-center rounded-lg px-3 text-base transition-colors ${sl(t.fontFamily===e.value)}`,children:e.label},e.value))}),(0,Q.jsxs)(`div`,{className:`mt-2 space-y-2 border-t border-[var(--chrome-ring)] pt-2`,children:[(0,Q.jsx)(Ra,{value:t.fontSize,onChange:e=>r({fontSize:e}),onNudgeStart:i.beginTransaction,onNudgeEnd:i.endTransaction}),(0,Q.jsx)(`div`,{className:`flex items-center gap-1`,children:(n?ui:di).map((e,n)=>(0,Q.jsx)(La,{testId:`font-size-${e}`,active:t.fontSize===e,onClick:()=>r({fontSize:e}),children:(0,Q.jsx)(`span`,{className:`text-[11px] font-medium`,children:Jr[n]})},e))})]})]})})}function HO(e){let{style:t,textSizing:n,onChange:r,onTextSizing:i,showTextAlign:a,showTextVAlign:o,showTextPadding:s,showTextSizing:c,showTextSpacing:l}=e;return(0,Q.jsx)(Va,{label:`Text layout`,caret:!0,trigger:(0,Q.jsx)(Pp,{size:18,stroke:1.75}),children:(0,Q.jsxs)(`div`,{className:`flex w-44 flex-col gap-1`,children:[a&&(0,Q.jsx)(`div`,{className:`flex items-center gap-1`,children:kO.map(e=>(0,Q.jsx)(La,{testId:`text-align-${e.value}`,ariaLabel:e.label,active:t.textAlign===e.value,onClick:()=>r({textAlign:e.value}),children:(0,Q.jsx)(Tc,{type:e.value,size:20,stroke:1.75})},e.value))}),o&&(0,Q.jsx)(`div`,{className:`flex items-center gap-1`,children:AO.map(e=>(0,Q.jsx)(La,{testId:`text-valign-${e.value}`,ariaLabel:e.label,active:t.textVAlign===e.value,onClick:()=>r({textVAlign:e.value}),children:(0,Q.jsx)(Tc,{type:e.value,size:20,stroke:1.75})},e.value))}),s&&(0,Q.jsxs)(`div`,{className:`mt-1 space-y-1 border-t border-[var(--chrome-ring)] pt-2`,children:[(0,Q.jsx)(`div`,{className:`px-1 text-[11px] text-[var(--chrome-fg-500)]`,children:`Padding`}),(0,Q.jsx)(`div`,{className:`flex items-center gap-1`,children:Rr.map((e,n)=>(0,Q.jsx)(La,{testId:`text-padding-${e}`,ariaLabel:`Text padding ${Or[n]}`,active:t.textPadding===e,onClick:()=>r({textPadding:e}),children:(0,Q.jsx)(`span`,{className:`text-[11px] font-medium`,children:Or[n]})},e))})]}),c&&(0,Q.jsxs)(`div`,{className:`mt-1 space-y-1 border-t border-[var(--chrome-ring)] pt-2`,children:[(0,Q.jsx)(`div`,{className:`px-1 text-[11px] text-[var(--chrome-fg-500)]`,children:`Sizing`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(La,{testId:`text-sizing-auto-width`,ariaLabel:`Auto width`,active:n===`auto-width`,onClick:()=>i(`auto-width`),children:(0,Q.jsx)(`span`,{className:`text-[11px] font-medium`,children:`Auto width`})}),(0,Q.jsx)(La,{testId:`text-sizing-auto-height`,ariaLabel:`Auto height`,active:n!==`auto-width`,onClick:()=>i(`auto-height`),children:(0,Q.jsx)(`span`,{className:`text-[11px] font-medium`,children:`Auto height`})})]})]}),l&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(YD,{title:`Line height`,values:fi,labels:pi,testPrefix:`line-height`,isActive:e=>t.lineHeight===e,onPick:e=>r({lineHeight:e})}),(0,Q.jsx)(YD,{title:`Letter spacing`,values:Xr,labels:Gr,testPrefix:`letter-spacing`,isActive:e=>(t.letterSpacing??0)===e,onPick:e=>r({letterSpacing:e})})]})]})})}function UO(e){let{style:t,onChange:n}=e,r=ka(H().history);return(0,Q.jsx)(Va,{label:`Opacity`,trigger:(0,Q.jsxs)(`span`,{className:`text-[13px] tabular-nums text-[var(--chrome-fg-900)]`,children:[Math.round(t.opacity*100),`%`]}),children:(0,Q.jsx)(`input`,{type:`range`,"data-testid":`opacity-range`,min:.1,max:1,step:.05,value:t.opacity,onChange:e=>n({opacity:Number(e.target.value)}),...r,className:`h-1.5 w-40 cursor-pointer accent-[var(--chrome-fg-600)]`})})}function WO(){return(0,Q.jsx)(_O,{})}function GO(e){let{onReorder:t}=e;return(0,Q.jsx)(Va,{label:`Layer`,caret:!0,trigger:(0,Q.jsx)(xa,{size:18,stroke:1.75}),children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(wa,{action:`front`,label:`Bring to front`,onReorder:t,Icon:Pf}),(0,Q.jsx)(wa,{action:`forward`,label:`Bring forward`,onReorder:t,Icon:Hs}),(0,Q.jsx)(wa,{action:`backward`,label:`Send backward`,onReorder:t,Icon:Us}),(0,Q.jsx)(wa,{action:`back`,label:`Send to back`,onReorder:t,Icon:Nf})]})})}function KO(e){let{link:t,onLink:n}=e;return(0,Q.jsx)(vO,{value:t??``,onChange:n??(()=>{})})}function qO(e){return e.web?(0,Q.jsx)(Zs,{web:e.web}):null}function JO(e){let{onAlign:t,onDistribute:n,showDistribute:r}=e;return(0,Q.jsx)(Va,{label:`Align`,caret:!0,trigger:(0,Q.jsx)(fp,{size:18,stroke:1.75}),children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(Ia,{type:`left`,onAlign:t,Icon:pp}),(0,Q.jsx)(Ia,{type:`center-h`,onAlign:t,Icon:fp}),(0,Q.jsx)(Ia,{type:`right`,onAlign:t,Icon:hp}),(0,Q.jsx)(Ia,{type:`top`,onAlign:t,Icon:gp}),(0,Q.jsx)(Ia,{type:`middle`,onAlign:t,Icon:mp}),(0,Q.jsx)(Ia,{type:`bottom`,onAlign:t,Icon:dp})]}),r&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(za,{axis:`horizontal`,onDistribute:n,Icon:bp}),(0,Q.jsx)(za,{axis:`vertical`,onDistribute:n,Icon:yp})]})]})})}var YO=[{key:`icon`,visible:e=>!!e.icon||!!e.figure,Component:jO},{key:`badge`,visible:e=>e.badge!==void 0,Component:MO},{key:`web`,visible:e=>e.web!==void 0,Component:qO},{key:`shape`,visible:e=>e.showShapeKind,Component:NO},{key:`controlValue`,visible:e=>!!e.control&&hO(e.control),Component:PO},{key:`chartType`,visible:e=>e.showChartType,Component:FO},{key:`chartColors`,visible:e=>!!e.chart&&mO(e.chart),Component:IO},{key:`chartOptions`,visible:e=>e.showChartType,Component:LO},{key:`color`,visible:e=>e.showColor||e.showLabelColor||e.showBackground||e.showFill,Component:RO},{key:`stroke`,visible:e=>e.showStroke||e.showStrokeStyle||e.showCorner,Component:zO},{key:`line`,visible:e=>e.showLineType||e.showArrowheads,Component:BO},{key:`font`,visible:e=>e.showFont,Component:VO},{key:`textLayout`,visible:e=>e.showTextAlign||e.showTextSpacing||e.showTextSizing,Component:HO},{key:`opacity`,visible:()=>!0,Component:UO},{key:`stats`,visible:e=>e.selectionCount>=1,Component:WO},{key:`layer`,visible:e=>e.showLayer,Component:GO},{key:`link`,visible:e=>e.link!==void 0&&!!e.onLink,Component:KO},{key:`align`,visible:e=>e.showAlign,Component:JO}];function XO(e){xy(`PropertiesPanel`);let{kinds:t,iconsInk:n,iconLabeled:r,selectionCount:i,shapeKind:a,chart:o,control:s,figure:c}=e,{textSizing:l,onDelete:u,onDuplicate:d}=e,f=U(e=>e.deviceMode===`phone`),p=Oa(),m=ID({kinds:t,iconsInk:n,iconLabeled:r,shapeKind:a,control:s,chart:o,textSizing:l,selectionCount:i,laneFrame:c?ns(c.kind):!1}),h={...e,...m},g=YO.filter(e=>e.visible(h)).map(e=>({key:e.key,node:(0,Q.jsx)(e.Component,{...h})}));if(f){let e=g.filter(e=>!QO.has(e.key)),t=g.filter(e=>QO.has(e.key));return(0,Q.jsxs)(`div`,{className:`absolute bottom-[max(4.5rem,calc(env(safe-area-inset-bottom)+4rem))] left-2 flex items-center gap-0.5 rounded-xl p-1 ${dl}`,"data-overlay":!0,"data-caret-safe":!0,"data-testid":`properties-panel`,onPointerDown:e=>{e.stopPropagation(),p.onPointerDown()},onMouseDown:p.onMouseDown,onDoubleClick:e=>e.stopPropagation(),children:[e.length>0&&(0,Q.jsx)($O,{label:`Style`,testId:`style`,icon:(0,Q.jsx)(Wa,{size:17,stroke:1.75}),groups:e}),t.length>0&&(0,Q.jsx)($O,{label:`More options`,testId:`more-options`,icon:(0,Q.jsx)(w,{size:17,stroke:1.75}),groups:t}),(0,Q.jsx)(`div`,{className:ol}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Duplicate`,"data-testid":`selection-duplicate`,onClick:d,className:pl(!1),children:(0,Q.jsx)(ga,{size:16,stroke:1.75})}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Delete`,"data-testid":`selection-delete`,onClick:u,className:pl(!1),children:(0,Q.jsx)(Ws,{size:16,stroke:1.75})})]})}return(0,Q.jsx)(`div`,{className:`absolute bottom-4 left-1/2 flex max-w-[calc(100vw-1rem)] -translate-x-1/2 items-center gap-0.5 overflow-x-auto rounded-xl p-1 [&>*]:shrink-0 ${dl}`,"data-overlay":!0,"data-caret-safe":!0,"data-testid":`properties-panel`,onPointerDown:e=>{e.stopPropagation(),p.onPointerDown()},onMouseDown:p.onMouseDown,onDoubleClick:e=>e.stopPropagation(),children:g.map((e,t)=>(0,Q.jsxs)(J.Fragment,{children:[t>0&&(0,Q.jsx)(ja,{}),e.node]},e.key))})}var ZO=(0,J.memo)(XO),QO=new Set([`align`,`layer`,`stats`,`link`]);function $O(e){let{label:t,testId:n,icon:r,groups:i}=e,a=Oa();return(0,Q.jsxs)(Dc,{onOpenChange:e=>{e||a.restore()},children:[(0,Q.jsx)(Ca,{"aria-label":t,"data-testid":`${n}-open`,onPointerDown:a.onPointerDown,onMouseDown:a.onMouseDown,className:`${pl(!1)} data-[popup-open]:bg-[var(--chrome-hover)]`,children:r}),(0,Q.jsx)(Mc,{children:(0,Q.jsx)(Lc,{side:`top`,align:`start`,sideOffset:8,collisionPadding:8,children:(0,Q.jsx)(Rc,{"data-overlay":!0,"data-testid":`${n}-island`,"data-caret-safe":!0,...a.focusProps,onPointerDown:a.onPointerDown,onMouseDown:a.onMouseDown,className:`flex max-h-[60dvh] max-w-[min(92vw,420px)] flex-col gap-1.5 overflow-y-auto p-1.5 ${q.popup}`,children:i.map((e,t)=>(0,Q.jsxs)(J.Fragment,{children:[t>0&&(0,Q.jsx)(`div`,{className:`h-px shrink-0 bg-[var(--chrome-divider)]`}),(0,Q.jsx)(`div`,{className:`flex items-center gap-0.5 overflow-x-auto [&>*]:shrink-0`,children:e.node})]},e.key))})})})]})}var ek=18;function tk(e,t){let n=Es[t];return{id:e,label:n.label,shortcut:Ns(t),icon:n.icon??Ss}}var nk=[tk(`select`,`select`),tk(`hand`,`hand`)],rk=[tk(`arrow`,`arrow`),tk(`line`,`line`),tk(`polyline`,`polyline`),tk(`polygon`,`polygon`)],ik=tk(`rectangle`,`rectangle`),ak=tk(`rectangle`,`ellipse`),ok=tk(`draw`,`draw`),sk=tk(`eraser`,`eraser`),ck=[tk(`text`,`text`),ok],lk=tk(`comment`,`comment`),uk=[tk(`image`,`image`),tk(`icon`,`icon`)],dk=[tk(`lasso`,`lasso`),tk(`laser`,`laser`),sk,{...tk(`highlight`,`highlight`),testid:`tool-highlight`},tk(`sticky`,`sticky`)];function fk(e){return Ts.find(t=>t.value===e)?.icon??xs}var pk=[{kind:`stepbadge`,label:Es.stepbadge.label,icon:Es.stepbadge.icon,shortcut:Ns(`stepbadge`)},{kind:`entity`,label:`Class / entity`,icon:kc},{kind:`lifeline`,label:`Lifeline`,icon:Ac},{kind:`fragment`,label:`Fragment`,icon:Fs}];function mk(e){return`relative ${pl(e)}`}function hk(e){let{label:t,shortcut:n,children:r}=e;return(0,Q.jsx)(S,{label:t,shortcut:n,side:U(e=>e.deviceMode===`phone`)?`top`:`right`,sideOffset:10,children:r})}function gk(e){let{tool:t,active:n,onSelect:r}=e,i=t.icon;return(0,Q.jsx)(hk,{label:t.label,shortcut:t.shortcut,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":t.label,"aria-pressed":n,onClick:r,className:mk(n),children:(0,Q.jsx)(i,{size:ek,stroke:1.75})})})}function _k(e){let{label:t,shortcut:n,active:r,icon:i,children:a}=e,[o,s]=(0,J.useState)(!1),c=U(e=>e.deviceMode===`phone`);return(0,Q.jsxs)(Dc,{open:o,onOpenChange:s,children:[(0,Q.jsx)(hk,{label:t,shortcut:n,children:(0,Q.jsx)(Ca,{render:(0,Q.jsxs)(`button`,{type:`button`,"aria-label":t,"aria-pressed":r,className:r?mk(!0):`${mk(!1)} data-[popup-open]:bg-[var(--chrome-hover)]`,children:[i,(0,Q.jsx)(Oc,{})]})})}),(0,Q.jsx)(Mc,{children:(0,Q.jsx)(Lc,{side:c?`top`:`right`,align:`start`,sideOffset:10,collisionPadding:8,children:(0,Q.jsx)(Rc,{"data-overlay":!0,className:`scrollbar-slim max-h-[var(--available-height)] overflow-y-auto p-1 ${q.popup}`,children:a(()=>s(!1))})})})]})}function vk(e){xy(`Toolbar`);let{tool:t,shapeKind:n,chartKind:r,frameKind:i,onToolChange:a,onShapeKind:o,onChartKind:s,onFrameKind:c,onInsertControl:l,commentsAvailable:u,toolLock:d,onToggleToolLock:f}=e,p=W(),m=U(e=>e.deviceMode===`phone`),h=m?`flex flex-row gap-0.5`:`flex flex-col gap-0.5`,g=m?`mx-0.5 my-1.5 w-px shrink-0 self-stretch bg-[var(--chrome-divider)]`:ul;function _(e){a(e)}function v(e){a(`rectangle`),o(e)}function y(e){a(`figure`),c(e)}function b(e){if(e===`table`){a(`table`);return}a(`chart`),s(e)}function C(e){return e===`table`?t===`table`:t===`chart`&&r===e}let w=t===`rectangle`&&vs.includes(n),T=t===`chart`||t===`table`,E=fk(t===`table`?`table`:r),D=rk.find(e=>e.id===t),O=!!D,k=(D??rk[0]).icon,A=(Os.find(e=>e.kind===i)??Os[0]).icon,j=dk.find(e=>e.id===t),M=t===`figure`||!!j,N=t===`figure`?A:j?.icon??xp,P=m&&t===`rectangle`&&n===`ellipse`,F=(0,Q.jsx)(_k,{label:`More shapes`,active:w||P,icon:w||P?(0,Q.jsx)(jc,{kind:n,size:ek}):(0,Q.jsx)(Up,{size:ek,stroke:1.75}),children:e=>(0,Q.jsxs)(`div`,{className:`grid gap-1 ${m?`grid-cols-5`:`grid-cols-4`}`,children:[m&&(0,Q.jsx)(S,{label:`Ellipse`,side:`bottom`,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Ellipse`,onClick:()=>{v(`ellipse`),e()},className:pl(P),children:(0,Q.jsx)(Cs,{size:18,stroke:1.75})})}),vs.map(r=>(0,Q.jsx)(S,{label:js[r],side:`bottom`,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":js[r],onClick:()=>{v(r),e()},className:pl(t===`rectangle`&&n===r),children:(0,Q.jsx)(jc,{kind:r,size:18})})},r)),pk.map(t=>(0,Q.jsx)(S,{label:t.label,shortcut:t.shortcut,side:`bottom`,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":t.label,"data-testid":`control-tool-${t.kind}`,onClick:()=>{l(t.kind),e()},className:pl(!1),children:(0,Q.jsx)(t.icon,{size:18,stroke:1.75})})},t.kind))]})}),I=(0,Q.jsx)(_k,{label:`Connector`,active:O,icon:(0,Q.jsx)(k,{size:ek,stroke:1.75}),children:e=>(0,Q.jsx)(`div`,{className:`grid grid-cols-3 gap-1`,children:rk.map(n=>(0,Q.jsx)(S,{label:n.label,shortcut:n.shortcut,side:`bottom`,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":n.label,onClick:()=>{_(n.id),e()},className:pl(t===n.id),children:(0,Q.jsx)(n.icon,{size:18,stroke:1.75})})},n.id))})}),L=nk.map(e=>(0,Q.jsx)(gk,{tool:e,active:t===e.id,onSelect:()=>_(e.id)},e.id));return(0,Q.jsx)(x,{delay:0,children:(0,Q.jsx)(`div`,{className:m?`absolute inset-x-0 bottom-0 px-1 pb-[max(0.5rem,env(safe-area-inset-bottom))]`:`absolute left-4 top-[calc(3.5rem+var(--koboyo-host-inset-top))]`,"data-overlay":!0,"data-canvas-toolbar":!0,onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),children:(0,Q.jsxs)(`div`,{className:m?`flex flex-row items-center overflow-x-auto touch-pan-x rounded-xl p-0.5 ${dl}`:`flex max-h-[calc(100dvh-72px)] flex-col gap-0.5 overflow-y-auto ${ll}`,children:[m&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:h,children:L}),(0,Q.jsx)(`div`,{className:g}),(0,Q.jsxs)(`div`,{className:h,children:[(0,Q.jsx)(gk,{tool:ok,active:t===`draw`,onSelect:()=>_(`draw`)}),(0,Q.jsx)(gk,{tool:sk,active:t===`eraser`,onSelect:()=>_(`eraser`)})]}),(0,Q.jsx)(`div`,{className:g}),(0,Q.jsxs)(`div`,{className:h,children:[(0,Q.jsx)(gk,{tool:ik,active:t===`rectangle`&&n===`rectangle`,onSelect:()=>v(`rectangle`)}),F,I]}),(0,Q.jsx)(`div`,{className:g}),(0,Q.jsx)(S,{label:`All tools`,shortcut:`/`,side:`top`,sideOffset:10,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":`All tools`,"data-testid":`all-tools`,onClick:()=>p.getState().setToolDrawerOpen(!0),className:mk(!1),children:(0,Q.jsx)(xp,{size:ek,stroke:1.75})})})]}),!m&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:h,children:L}),(0,Q.jsx)(`div`,{className:g}),(0,Q.jsxs)(`div`,{className:h,children:[(0,Q.jsx)(gk,{tool:ik,active:t===`rectangle`&&n===`rectangle`,onSelect:()=>v(`rectangle`)}),(0,Q.jsx)(gk,{tool:ak,active:t===`rectangle`&&n===`ellipse`,onSelect:()=>v(`ellipse`)}),F]}),I,(0,Q.jsx)(`div`,{className:g}),(0,Q.jsx)(`div`,{className:h,children:ck.map(e=>(0,Q.jsx)(gk,{tool:e,active:t===e.id,onSelect:()=>_(e.id)},e.id))}),(0,Q.jsx)(`div`,{className:g}),(0,Q.jsxs)(`div`,{className:h,children:[uk.map(e=>(0,Q.jsx)(gk,{tool:e,active:t===e.id,onSelect:()=>_(e.id)},e.id)),(0,Q.jsx)(hk,{label:`Web embed`,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Web embed`,"data-testid":`toolbar-web-embed`,onClick:()=>{_(`select`),p.getState().setWebEmbedDialog({mode:`insert`})},className:mk(!1),children:(0,Q.jsx)(gs,{size:ek,stroke:1.75})})}),(0,Q.jsx)(_k,{label:`Table & charts`,shortcut:Ns(`chart`),active:T,icon:(0,Q.jsx)(E,{size:ek,stroke:1.75}),children:e=>(0,Q.jsx)(`div`,{className:`grid grid-cols-3 gap-1`,children:Ts.map(t=>(0,Q.jsx)(S,{label:t.label,side:`bottom`,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":t.label,onClick:()=>{b(t.value),e()},className:pl(C(t.value)),children:(0,Q.jsx)(t.icon,{size:18,stroke:1.75})})},t.value))})})]}),(0,Q.jsx)(`div`,{className:g}),(0,Q.jsx)(_k,{label:`More controls`,active:M,icon:(0,Q.jsx)(N,{size:ek,stroke:1.75}),children:e=>(0,Q.jsxs)(`div`,{className:`w-52`,children:[(0,Q.jsx)(`div`,{className:`px-2 pb-1 pt-1.5 text-[11px] text-[var(--chrome-fg-400)]`,children:`Frames`}),(0,Q.jsx)(`div`,{className:`grid grid-cols-5 gap-1`,children:Os.map(n=>(0,Q.jsx)(S,{label:ts[n.kind],shortcut:n.kind===`simple`?Ns(`figure`):void 0,side:`bottom`,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":ts[n.kind],onClick:()=>{y(n.kind),e()},className:pl(t===`figure`&&i===n.kind),children:(0,Q.jsx)(n.icon,{size:18,stroke:1.75})})},n.kind))}),(0,Q.jsx)(`div`,{className:`px-2 pb-1 pt-2 text-[11px] text-[var(--chrome-fg-400)]`,children:`Tools`}),(0,Q.jsx)(`div`,{className:`grid grid-cols-5 gap-1`,children:dk.map(n=>(0,Q.jsx)(S,{label:n.label,shortcut:n.shortcut,side:`bottom`,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":n.label,"data-testid":n.testid,onClick:()=>{_(n.id),e()},className:pl(t===n.id),children:(0,Q.jsx)(n.icon,{size:18,stroke:1.75})})},n.id))}),(0,Q.jsx)(`div`,{className:`px-2 pb-1 pt-2 text-[11px] text-[var(--chrome-fg-400)]`,children:`Wireframe`}),(0,Q.jsx)(`div`,{className:`grid grid-cols-5 gap-1`,children:As.map(t=>(0,Q.jsx)(S,{label:t.label,side:`bottom`,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":t.label,"data-testid":`control-tool-${t.kind}`,onClick:()=>{l(t.kind),e()},className:pl(!1),children:(0,Q.jsx)(t.icon,{size:18,stroke:1.75})})},t.kind))})]})}),u&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:g}),(0,Q.jsx)(gk,{tool:lk,active:t===`comment`,onSelect:()=>_(`comment`)})]}),(0,Q.jsx)(`div`,{className:g}),(0,Q.jsx)(S,{label:`Keep tool active`,shortcut:Qp(`toolLock`),side:`right`,sideOffset:10,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Keep tool active`,"aria-pressed":d,onClick:f,className:mk(d),children:d?(0,Q.jsx)(wp,{size:ek,stroke:1.75}):(0,Q.jsx)(Cp,{size:ek,stroke:1.75})})})]})]})})})}var yk=(0,J.memo)(vk),bk=`.kby`,xk=`koboyo`,Sk=`application/json`;function Ck(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.format===xk&&Array.isArray(t.shapes)&&typeof t.viewport==`object`&&t.viewport!==null}function wk(e,t){let n={format:xk,version:ge,shapes:e.shapes,viewport:e.viewport},r=new Blob([JSON.stringify(n)],{type:Sk}),i=URL.createObjectURL(r),a=window.document.createElement(`a`);a.href=i,a.download=`${Tk(t)}${bk}`,a.rel=`noopener`,window.document.body.appendChild(a),a.click(),a.remove(),setTimeout(()=>URL.revokeObjectURL(i),1e3)}function Tk(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`untitled`}var Ek={excalidraw:`Excalidraw`,tldraw:`tldraw`};function Dk(e){if(e.format===`koboyo`)return`Opened file`;let t=`Imported ${Ek[e.format]} board`;if(e.skipped===0)return t;let n=e.skipped===1?`element`:`elements`;return`${t}. ${e.skipped} unsupported ${n} skipped.`}function Ok(e){let t=e.format===`koboyo`?`Added the file`:`Added the ${Ek[e.format]} board`;if(e.skipped===0)return`${t} next to your canvas`;let n=e.skipped===1?`element`:`elements`;return`${t} next to your canvas. ${e.skipped} unsupported ${n} skipped.`}function kk(e,t){if(e.length===0)throw Error(`That file has nothing we can import`);Ak(e);let n=he({version:ge,shapes:e});if(n.status!==`valid`)throw Error(t);return n.document.shapes}function Ak(e){let t=Oe(e.length,`open`);if(t?.kind===`block`)throw Error(t.message)}async function jk(e){let t;try{t=JSON.parse(await e.text())}catch{throw Error(`That file isn't a supported board file.`)}if(Ck(t)){Ak(t.shapes);let e=he({version:t.version,shapes:t.shapes});if(e.status===`unsupported-version`)throw Error(`This board was saved by a newer version of Koboyo and can't be opened here.`);if(e.status===`invalid`)throw Error(`That board file is damaged and couldn't be opened.`);return{shapes:e.document.shapes,viewport:fe(t.viewport),format:`koboyo`,skipped:0}}let[{importExcalidraw:n,isExcalidrawData:r},{importTldraw:i,isTldrawData:a}]=await Promise.all([Ai(()=>import(`./excalidraw-BwgRIDi9.js`),__vite__mapDeps([120,2,121])),Ai(()=>import(`./tldraw-CE87oKyq.js`),__vite__mapDeps([122,2,121]))]);if(r(t)){let e=n(t);return{shapes:kk(e.shapes,`That Excalidraw file couldn't be imported.`),viewport:null,format:`excalidraw`,skipped:e.skipped}}if(a(t)){let e=i(t);return{shapes:kk(e.shapes,`That tldraw file couldn't be imported.`),viewport:null,format:`tldraw`,skipped:e.skipped}}throw Error(`That file isn't a supported board file.`)}function Mk(e){let{pending:t,error:n,errorTestId:r,submitTestId:i,submitLabel:a,submitDisabled:o,cancelDisabled:s,leading:c}=e;return(0,Q.jsxs)(Q.Fragment,{children:[n&&(0,Q.jsx)(`p`,{"data-testid":r,className:Tl.error,children:n}),(0,Q.jsxs)(`div`,{className:Tl.actions,children:[c&&(0,Q.jsx)(`div`,{className:`mr-auto flex items-center`,children:c}),(0,Q.jsx)(bl,{className:Tl.cancelButton,disabled:s,children:`Cancel`}),(0,Q.jsx)(`button`,{type:`submit`,"data-testid":i,disabled:t||o,className:Tl.submitButton,children:t?`Saving…`:a})]})]})}var Nk=`__new__`;function Pk(e){let{open:t,onOpenChange:n,title:r,description:i,submitLabel:a,initialName:o,initialDescription:s,destination:c,onSubmit:l,onDelete:u}=e,[d,f]=(0,J.useState)(o??``),[p,m]=(0,J.useState)(s??``),[h,g]=(0,J.useState)(``),[_,v]=(0,J.useState)(``),{pending:y,error:b,run:x}=wl({open:t}),[S,w]=(0,J.useState)(!1),T=c!=null&&(c.workspaces.length===0||h===Nk),E=(0,J.useRef)({initialName:o,initialDescription:s,destination:c});E.current={initialName:o,initialDescription:s,destination:c},(0,J.useEffect)(()=>{if(!t)return;w(!1);let e=E.current;if(f(e.initialName??``),m(e.initialDescription??``),e.destination){let t=e.destination.workspaces.filter(e=>!e.full),n=t.find(t=>t.id===e.destination?.initialWorkspaceId);g(n?.id??t[0]?.id??Nk),v(``)}},[t]);let D=!T||_.trim().length>0;function O(){!u||y||x(()=>u(),{onSuccess:()=>n(!1),errorFor:e=>Cl(e,`That didn't delete. Try again.`)})}function k(e){e.preventDefault();let t=d.trim();if(!t||y||!D)return;let r=c?T?{kind:`new`,workspaceName:_.trim()}:{kind:`existing`,workspaceId:h}:void 0;x(()=>l({name:t,description:p.trim()||null},r),{onSuccess:()=>n(!1),errorFor:e=>Cl(e,`That didn't save. Check your connection and try again.`)})}return(0,Q.jsx)(yl,{open:t,onOpenChange:n,children:(0,Q.jsxs)(gl,{children:[(0,Q.jsx)(hl,{className:q.dialogBackdrop}),(0,Q.jsxs)(vl,{"data-overlay":!0,"data-testid":`canvas-meta-dialog`,className:`w-[min(420px,92vw)] p-5 ${q.dialogPopup}`,children:[(0,Q.jsx)(xl,{className:Tl.title,children:S?`Delete canvas?`:r}),!S&&(0,Q.jsx)(Sl,{className:tl(`mt-1`,Tl.description),children:i}),S?(0,Q.jsxs)(`div`,{"data-testid":`canvas-meta-delete-confirm`,className:`mt-4 flex flex-col gap-3`,children:[(0,Q.jsxs)(`p`,{className:`text-[13px] leading-relaxed text-[var(--chrome-fg-700)]`,children:[`Move “`,o||`this canvas`,`” to the trash? Everyone in the workspace loses access, and you can restore it from Trash for 30 days.`]}),b&&(0,Q.jsx)(`p`,{"data-testid":`canvas-meta-error`,className:Tl.error,children:b}),(0,Q.jsxs)(`div`,{className:Tl.actions,children:[(0,Q.jsx)(`button`,{type:`button`,"data-testid":`canvas-meta-delete-back`,disabled:y,onClick:()=>w(!1),className:Tl.cancelButton,children:`Back`}),(0,Q.jsx)(`button`,{type:`button`,"data-testid":`canvas-meta-delete-accept`,disabled:y,onClick:O,className:Tl.dangerButton,children:y?`Deleting…`:`Move to trash`})]})]}):(0,Q.jsxs)(`form`,{className:`mt-4 flex flex-col gap-3`,onSubmit:k,children:[(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`span`,{className:Tl.label,children:`Name`}),(0,Q.jsx)(`input`,{"data-testid":`canvas-meta-name`,className:Tl.field,value:d,maxLength:120,placeholder:`Untitled canvas`,autoFocus:!0,onChange:e=>f(e.target.value)})]}),c&&c.workspaces.length>0&&(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`span`,{className:Tl.label,children:`Workspace`}),(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsxs)(`select`,{"data-testid":`canvas-meta-workspace`,className:Tl.select,value:h,onChange:e=>g(e.target.value),children:[c.workspaces.map(e=>(0,Q.jsx)(`option`,{value:e.id,disabled:e.full,children:e.full?`${e.name} (Full)`:e.name},e.id)),(0,Q.jsx)(`option`,{value:Nk,children:`New workspace…`})]}),(0,Q.jsx)(C,{size:16,stroke:1.75,className:Tl.selectChevron})]}),c.workspaces.some(e=>e.full)&&(0,Q.jsx)(`span`,{"data-testid":`canvas-meta-workspace-full-hint`,className:`text-[12px] leading-relaxed text-[var(--chrome-fg-400)]`,children:`A full workspace needs an upgrade or a free slot before it can take another canvas.`})]}),T&&(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`span`,{className:Tl.label,children:c&&c.workspaces.length>0?`New workspace name`:`Save to a new workspace`}),(0,Q.jsx)(`input`,{"data-testid":`canvas-meta-workspace-name`,className:Tl.field,value:_,maxLength:60,placeholder:`Acme, Design team, …`,onChange:e=>v(e.target.value)}),(0,Q.jsx)(`span`,{className:`text-[12px] leading-relaxed text-[var(--chrome-fg-400)]`,children:`Name it after the people who'll work in it. You can invite them later.`})]}),(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`span`,{className:Tl.label,children:`Description`}),(0,Q.jsx)(`textarea`,{"data-testid":`canvas-meta-description`,className:`${Tl.field} min-h-[64px] resize-none`,value:p,maxLength:500,placeholder:`What is this canvas about? (optional)`,rows:3,onChange:e=>m(e.target.value)})]}),(0,Q.jsx)(Mk,{pending:y,error:b,errorTestId:`canvas-meta-error`,submitTestId:`canvas-meta-submit`,submitLabel:a,submitDisabled:d.trim().length===0||!D,leading:u?(0,Q.jsx)(`button`,{type:`button`,"data-testid":`canvas-meta-delete`,disabled:y,onClick:()=>w(!0),className:Tl.dangerTextButton,children:`Delete canvas`}):void 0})]})]})]})})}var Fk=`${bk},.excalidraw,.tldr,application/json`,Ik=`.excalidraw,.tldr,application/json`;function Lk(e,t){return(e?.trim()||t).charAt(0).toUpperCase()}function Rk(e){let{onLoadDocument:t,ref:n}=e,r=ne(),{notify:i}=_(),a=te(),o=W(),s=U(e=>e.shapes.length===0),c=_e(e=>[e.shapes],e=>Bn(e).some(zk)),l=U(e=>e.setExportDialog),u=Ga(),d=U(e=>e.setTheme),f=U(e=>e.zenMode),p=U(e=>e.setZenMode),m=U(e=>e.viewMode),h=U(e=>e.setViewMode),g=U(e=>e.viewModeLocked),v=(0,J.useRef)(null),[y,b]=(0,J.useState)(null),[x,S]=(0,J.useState)(!1),C=r.state.status===`authenticated`?r.state.user:null,w=C!=null&&a.onNewCanvas!=null;function T(e){let t=v.current;t&&(t.accept=e,t.click())}function E(e){if(s){T(e);return}b(e)}(0,J.useImperativeHandle)(n,()=>({openFile:()=>{a.embed||E(Fk)}}));async function D(e){try{let n=await jk(e);if(t(n)!==`loaded`)return;i(Dk(n))}catch(e){i(e instanceof Error?e.message:`Couldn't open that file`)}}function O(){let{shapes:e,viewport:t}=o.getState();wk({shapes:e,viewport:t},`untitled`),i(`Saved ${bk} file`)}return(0,Q.jsxs)(`div`,{className:`absolute left-4 top-[var(--chrome-top)]`,"data-overlay":!0,"data-testid":`main-menu`,onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),children:[(0,Q.jsx)(`input`,{ref:v,type:`file`,accept:Fk,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&D(t),e.target.value=``}}),(0,Q.jsxs)(N,{children:[(0,Q.jsx)(I,{render:(0,Q.jsx)(`button`,{type:`button`,"aria-label":C?`Menu & account`:`Menu`,"data-testid":`main-menu-button`,className:`flex h-8 w-10 cursor-pointer items-center justify-center rounded-lg text-[var(--chrome-fg-600)] transition-colors hover:text-[var(--chrome-fg-900)] data-[popup-open]:text-[var(--chrome-fg-900)] coarse:h-11 coarse:w-12 ${dl}`,children:C?C.avatarUrl?(0,Q.jsx)(`img`,{src:C.avatarUrl,alt:``,referrerPolicy:`no-referrer`,"data-testid":`main-menu-avatar`,className:`h-6 w-6 rounded-full object-cover`}):(0,Q.jsx)(`span`,{"data-testid":`main-menu-avatar`,className:`flex h-6 w-6 items-center justify-center rounded-full bg-[var(--chrome-active)] text-[11px] text-[var(--chrome-fg-700)]`,children:Lk(C.name,C.email)}):(0,Q.jsx)(Ds,{size:17,stroke:1.75})})}),(0,Q.jsx)(P,{children:(0,Q.jsx)(L,{side:`bottom`,align:`start`,sideOffset:8,className:`outline-none`,children:(0,Q.jsxs)(j,{"data-overlay":!0,"data-testid":`main-menu-popup`,className:Vk,children:[C&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex flex-col px-2 py-1.5`,children:[C.name&&(0,Q.jsx)(`span`,{className:`truncate text-[13px] text-[var(--chrome-fg-800)]`,children:C.name}),(0,Q.jsx)(`span`,{className:`truncate text-[12px] text-[var(--chrome-fg-500)]`,children:C.email})]}),(0,Q.jsx)(M,{})]}),(w||C&&a.onShowCanvases)&&(0,Q.jsxs)(Q.Fragment,{children:[w&&(0,Q.jsx)(R,{testId:`menu-new-canvas`,icon:(0,Q.jsx)(_c,{size:16,stroke:1.75}),onClick:()=>S(!0),children:`New canvas…`}),C&&a.onShowCanvases&&(0,Q.jsx)(R,{testId:`menu-my-canvases`,icon:(0,Q.jsx)(tc,{size:16,stroke:1.75}),onClick:a.onShowCanvases,children:`My canvases`}),(0,Q.jsx)(M,{})]}),a.embed?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(R,{testId:`menu-open-in-app`,icon:(0,Q.jsx)(Ys,{size:16,stroke:1.75}),onClick:a.embed.openInApp.run,children:a.embed.openInApp.label}),(0,Q.jsx)(M,{})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(R,{testId:`menu-open`,icon:(0,Q.jsx)(ap,{size:16,stroke:1.75}),onClick:()=>E(Fk),disabled:m,children:`Open…`}),(0,Q.jsx)(R,{testId:`menu-import`,icon:(0,Q.jsx)(rp,{size:16,stroke:1.75}),onClick:()=>E(Ik),disabled:m,children:`Import…`}),(0,Q.jsx)(R,{testId:`menu-save`,icon:(0,Q.jsx)(nc,{size:16,stroke:1.75}),onClick:O,disabled:s,children:`Save`}),(0,Q.jsx)(M,{}),(0,Q.jsxs)(Hk,{testId:`menu-export`,icon:(0,Q.jsx)(np,{size:16,stroke:1.75}),label:`Export`,children:[(0,Q.jsx)(R,{testId:`menu-export-png`,icon:(0,Q.jsx)(_a,{size:16,stroke:1.75}),onClick:()=>l({format:`png`}),disabled:s,children:`PNG image…`}),(0,Q.jsx)(R,{testId:`menu-export-svg`,icon:(0,Q.jsx)(va,{size:16,stroke:1.75}),onClick:()=>l({format:`svg`}),disabled:s,children:`SVG image…`}),(0,Q.jsx)(R,{testId:`menu-export-pdf`,icon:(0,Q.jsx)(ya,{size:16,stroke:1.75}),onClick:()=>l({format:`pdf`}),disabled:!c,children:`Slides as PDF…`})]})]}),(0,Q.jsxs)(Hk,{testId:`menu-view`,icon:(0,Q.jsx)(ms,{size:16,stroke:1.75}),label:`View`,children:[(0,Q.jsxs)(Ey,{className:q.menuItem,"data-testid":`menu-dark-mode`,closeOnClick:!1,checked:u===`dark`,onCheckedChange:e=>d(e?`dark`:`light`),children:[(0,Q.jsx)(`span`,{className:`text-[var(--chrome-fg-600)]`,children:(0,Q.jsx)(Np,{size:16,stroke:1.75})}),(0,Q.jsx)(`span`,{children:`Dark mode`}),(0,Q.jsx)(Dy,{className:`ml-auto`,children:(0,Q.jsx)(Qs,{size:15,stroke:2})})]}),(0,Q.jsxs)(Ey,{className:q.menuItem,"data-testid":`menu-zen-mode`,closeOnClick:!0,checked:f,onCheckedChange:e=>p(e),children:[(0,Q.jsx)(`span`,{className:`text-[var(--chrome-fg-600)]`,children:(0,Q.jsx)(Na,{size:16,stroke:1.75})}),(0,Q.jsx)(`span`,{children:`Zen mode`}),(0,Q.jsx)(Dy,{className:`ml-auto`,children:(0,Q.jsx)(Qs,{size:15,stroke:2})})]}),(0,Q.jsxs)(Ey,{className:q.menuItem,"data-testid":`menu-view-mode`,closeOnClick:!0,disabled:g,checked:m,onCheckedChange:e=>h(e),children:[(0,Q.jsx)(`span`,{className:`text-[var(--chrome-fg-600)]`,children:(0,Q.jsx)(ba,{size:16,stroke:1.75})}),(0,Q.jsx)(`span`,{children:`View only`}),(0,Q.jsx)(Dy,{className:`ml-auto`,children:(0,Q.jsx)(Qs,{size:15,stroke:2})})]})]}),C&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(M,{}),(0,Q.jsx)(R,{testId:`account-logout`,icon:(0,Q.jsx)(Ep,{size:16,stroke:1.75}),onClick:()=>{r.logout().catch(e=>{i(e instanceof Error&&e.message?e.message:`Couldn't log out. Try again.`)})},children:`Log out`})]})]})})})]}),w&&a.onNewCanvas&&(0,Q.jsx)(Pk,{open:x,onOpenChange:S,title:`New canvas`,description:`Name the canvas you're about to start, and choose where it lives.`,submitLabel:`Create`,destination:a.saveDestination,onSubmit:a.onNewCanvas}),(0,Q.jsx)(zb,{open:y!==null,onOpenChange:e=>{e||b(null)},children:(0,Q.jsxs)(gl,{children:[(0,Q.jsx)(hl,{className:q.dialogBackdrop}),(0,Q.jsxs)(vl,{"data-overlay":!0,"data-testid":`open-confirm`,className:`w-[min(400px,92vw)] p-5 ${q.dialogPopup}`,children:[(0,Q.jsx)(xl,{className:`text-[15px] text-[var(--chrome-fg-900)]`,children:`Open a file?`}),(0,Q.jsxs)(Sl,{className:`mt-2 text-[13px] leading-relaxed text-[var(--chrome-fg-500)]`,children:[`Opening a file replaces everything currently on the canvas. This can be undone with`,` `,zc(Qp(`undo`)),`.`]}),(0,Q.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,Q.jsx)(bl,{className:`h-8 rounded-full px-3.5 text-[13px] text-[var(--chrome-fg-600)] outline-none transition-colors hover:bg-[var(--chrome-divider)]`,children:`Cancel`}),(0,Q.jsx)(bl,{"data-testid":`open-confirm-accept`,onClick:()=>{y&&T(y)},className:`h-8 rounded-full bg-[var(--chrome-accent)] px-3.5 text-[13px] text-white outline-none transition-colors hover:bg-[var(--chrome-accent-hover)]`,children:`Open file`})]})]})]})})]})}function zk(e){return e.type===`figure`&&e.slideOrder!==void 0&&!e.slideSkipped}var Bk=(0,J.memo)(Rk),Vk=`min-w-[180px] p-1 outline-none ${q.popup}`;function Hk(e){let{testId:t,icon:n,label:r,children:i}=e;return(0,Q.jsxs)(vc,{children:[(0,Q.jsxs)(bc,{className:q.menuItem,"data-testid":t,children:[(0,Q.jsx)(`span`,{className:`text-[var(--chrome-fg-400)]`,children:n}),(0,Q.jsx)(`span`,{children:r}),(0,Q.jsx)($s,{size:14,stroke:1.75,className:`ml-auto text-[var(--chrome-fg-400)]`})]}),(0,Q.jsx)(P,{children:(0,Q.jsx)(L,{className:`outline-none`,children:(0,Q.jsx)(j,{"data-overlay":!0,className:Vk,children:i})})})]})}function Uk(e){return typeof e==`object`&&!!e&&e.code===`canvas_limit`}var Wk=uc(lc.monthly.amountCents,`usd`);function Gk(e){return new Date(`${cc}T00:00:00Z`).toLocaleDateString(`en-US`,{month:e,day:`numeric`,timeZone:`UTC`})}function Kk(e){let{boardName:t}=e,n=ne(),r=W(),{notify:i}=_(),[a,o]=(0,J.useState)(!1);return n.state.status!==`authenticated`||n.state.user.requiresPlan||n.state.usage?.plan!==`free`||Date.now()>=dc?null:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`button`,{type:`button`,"data-testid":`free-plan-notice`,onClick:()=>o(!0),className:`${cl} bg-[var(--cta-save-bg)] text-[var(--cta-save-fg)] ring-[var(--cta-save-ring)] hover:bg-[var(--cta-save-bg-hover)]`,children:[(0,Q.jsx)(Qf,{size:16,stroke:1.75}),(0,Q.jsx)(`span`,{className:`whitespace-nowrap`,children:`Free plan ends ${Gk(`short`)}`})]}),(0,Q.jsx)(yl,{open:a,onOpenChange:o,children:(0,Q.jsxs)(gl,{children:[(0,Q.jsx)(hl,{className:q.dialogBackdrop}),(0,Q.jsxs)(vl,{"data-overlay":!0,"data-testid":`free-plan-dialog`,className:`flex w-[min(420px,92vw)] flex-col gap-6 p-8 ${q.dialogPopup}`,children:[(0,Q.jsx)(bl,{"aria-label":`Close`,className:`absolute right-3 top-3 flex h-7 w-7 items-center justify-center rounded-md text-[var(--chrome-fg-400)] outline-none transition-colors hover:bg-[var(--chrome-divider)] hover:text-[var(--chrome-fg-600)]`,children:(0,Q.jsx)(Cc,{size:16,stroke:1.75})}),(0,Q.jsx)(`span`,{className:`flex h-10 w-10 items-center justify-center rounded-xl bg-[var(--cta-save-bg)] text-[var(--cta-save-fg)]`,children:(0,Q.jsx)(Qf,{size:20,stroke:1.75})}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(xl,{className:`text-[20px] leading-tight text-[var(--chrome-fg-900)]`,children:`Your free plan ends on ${Gk(`long`)}`}),(0,Q.jsx)(Sl,{className:`text-[13.5px] leading-relaxed text-[var(--chrome-fg-500)]`,children:`On that day this account is turned off. Download your board first to keep it. You can still draw on Koboyo without signing in, and open your file there.`})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsxs)(`button`,{type:`button`,"data-testid":`free-plan-download`,onClick:()=>{let{shapes:e,viewport:n}=r.getState();wk({shapes:e,viewport:n},t),i(`Saved ${bk} file`)},className:`flex h-11 cursor-pointer items-center justify-center gap-2 rounded-lg bg-[var(--chrome-accent)] px-4 text-[14px] text-white outline-none transition-colors hover:bg-[var(--chrome-accent-hover)]`,children:[(0,Q.jsx)(nc,{size:16,stroke:1.75}),`Download board`]}),(0,Q.jsx)(`a`,{href:`/start`,className:`flex h-11 items-center justify-center rounded-lg bg-[var(--chrome-popup)] px-4 text-[14px] text-[var(--chrome-fg-800)] outline-none ring-1 ring-[var(--chrome-input)] transition-colors hover:bg-[var(--chrome-hover)]`,children:`Keep it with Pro`})]}),(0,Q.jsx)(`p`,{className:`text-[11.5px] leading-relaxed text-[var(--chrome-fg-400)]`,children:`Pro is free for 14 days, then ${Wk} a month. Cancel any time.`})]})]})})]})}var qk=q.menuItem,Jk=`${qk} text-red-600 data-[highlighted]:bg-red-50`,Yk=`max-h-[min(420px,70vh)] min-w-[200px] max-w-[300px] overflow-y-auto p-1 outline-none ${q.popup}`,Xk=`shrink-0 text-[var(--chrome-fg-400)]`,Zk=`flex h-full min-w-0 cursor-pointer items-center gap-1.5 rounded-md px-2 outline-none transition-colors hover:bg-[var(--chrome-hover)] data-[popup-open]:bg-[var(--chrome-hover)]`,Qk=`px-2 py-1.5 text-[12px] text-[var(--chrome-fg-400)]`,$k=2;function eA(e,t){let[n,r]=(0,J.useState)({status:`loading`}),i=e.listLevel;return(0,J.useEffect)(()=>{let e=!1;return r({status:`loading`}),i(t).then(t=>{e||r({status:`ready`,...t})},()=>{e||r({status:`error`})}),()=>{e=!0}},[i,t]),n}function tA(e,t){return n=>{n.metaKey||n.ctrlKey||n.shiftKey||n.button!==0||(n.preventDefault(),e.navigate(t))}}function nA(e){let t=e.location,n=e.folderId,r=eA(t,n),i=t.folderHref(n);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(A,{className:qk,"data-testid":`location-open-level`,render:(0,Q.jsx)(`a`,{href:i}),onClick:tA(t,i),children:[(0,Q.jsx)(qs,{size:15,stroke:1.75,className:Xk}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.openLabel})]}),(0,Q.jsx)(M,{}),r.status===`loading`&&(0,Q.jsx)(`div`,{className:Qk,children:`Loading…`}),r.status===`error`&&(0,Q.jsx)(`div`,{className:Qk,children:`Couldn't load this folder.`}),r.status===`ready`&&r.entries.length===0&&(0,Q.jsx)(`div`,{className:Qk,children:`Nothing here yet.`}),r.status===`ready`&&r.entries.map(e=>e.kind===`folder`?(0,Q.jsx)(rA,{location:t,entry:e},`folder:${e.id}`):(0,Q.jsx)(iA,{location:t,entry:e},`canvas:${e.id}`)),r.status===`ready`&&r.more&&(0,Q.jsx)(A,{className:qk,render:(0,Q.jsx)(`a`,{href:i}),onClick:tA(t,i),children:(0,Q.jsx)(`span`,{className:`pl-[23px] text-[var(--chrome-fg-500)]`,children:`Show all…`})})]})}function rA(e){let t=e.location,n=e.entry;return(0,Q.jsxs)(vc,{children:[(0,Q.jsxs)(bc,{className:qk,"data-testid":`location-folder-entry`,children:[(0,Q.jsx)(sc,{size:15,stroke:1.75,className:Xk}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n.name}),(0,Q.jsx)($s,{size:14,stroke:1.75,className:Xk})]}),(0,Q.jsx)(P,{children:(0,Q.jsx)(L,{className:`z-50 outline-none`,children:(0,Q.jsx)(j,{"data-overlay":!0,className:Yk,children:(0,Q.jsx)(nA,{location:t,folderId:n.id,openLabel:`Open ${n.name}`})})})})]})}function iA(e){let t=e.location,n=e.entry;if(n.id===t.canvasId)return(0,Q.jsxs)(A,{className:qk,"data-testid":`location-current-canvas`,children:[(0,Q.jsx)(Qs,{size:15,stroke:1.75,className:`shrink-0 text-[var(--chrome-fg-700)]`}),(0,Q.jsx)(`span`,{className:`truncate font-medium text-[var(--chrome-fg-900)]`,children:n.name})]});let r=t.canvasHref(n.id);return(0,Q.jsxs)(A,{className:qk,"data-testid":`location-canvas-entry`,render:(0,Q.jsx)(`a`,{href:r}),onClick:tA(t,r),children:[(0,Q.jsx)(qp,{size:15,stroke:1.75,className:Xk}),(0,Q.jsx)(`span`,{className:`truncate`,children:n.name})]})}function aA(){let{notify:e}=_();return t=>{let n=new URL(t,window.location.origin).href;navigator.clipboard.writeText(n).then(()=>e(`Link copied`),()=>e(`Couldn't copy the link.`))}}function oA(e){let t=e.href,n=aA();return(0,Q.jsxs)(Ka,{children:[(0,Q.jsx)(Ua,{render:(0,Q.jsx)(`div`,{className:`flex h-full min-w-0`}),children:e.children}),(0,Q.jsx)(P,{children:(0,Q.jsx)(L,{className:`z-50 outline-none`,children:(0,Q.jsxs)(j,{"data-overlay":!0,"data-testid":e.testId,className:Yk,children:[(0,Q.jsxs)(A,{className:qk,onClick:()=>window.open(t,`_blank`,`noopener`),children:[(0,Q.jsx)(Ys,{size:15,stroke:1.75,className:Xk}),(0,Q.jsx)(`span`,{children:`Open in new tab`})]}),(0,Q.jsxs)(A,{className:qk,onClick:()=>n(t),children:[(0,Q.jsx)(fc,{size:15,stroke:1.75,className:Xk}),(0,Q.jsx)(`span`,{children:`Copy link`})]})]})})})]})}function sA(e){let t=e.location,n=e.folderId,r=e.label;return(0,Q.jsx)(oA,{href:t.folderHref(n),testId:`${e.testId}-context`,children:(0,Q.jsxs)(N,{children:[(0,Q.jsx)(I,{"data-testid":e.testId,className:`${Zk} text-[var(--chrome-fg-600)] hover:text-[var(--chrome-fg-900)]`,children:(0,Q.jsx)(`span`,{className:`max-w-[140px] truncate`,children:r})}),(0,Q.jsx)(P,{children:(0,Q.jsx)(L,{side:`bottom`,align:`start`,sideOffset:8,className:`z-50 outline-none`,children:(0,Q.jsx)(j,{"data-overlay":!0,"data-testid":`${e.testId}-menu`,className:Yk,children:(0,Q.jsx)(nA,{location:t,folderId:n,openLabel:`Open ${r}`})})})})]})})}function cA(e){let t=e.location;return(0,Q.jsxs)(N,{children:[(0,Q.jsx)(I,{"aria-label":`Show full path`,"data-testid":`location-collapsed`,className:`${Zk} text-[var(--chrome-fg-600)] hover:text-[var(--chrome-fg-900)]`,children:`…`}),(0,Q.jsx)(P,{children:(0,Q.jsx)(L,{side:`bottom`,align:`start`,sideOffset:8,className:`z-50 outline-none`,children:(0,Q.jsx)(j,{"data-overlay":!0,className:Yk,children:e.folders.map((e,n)=>{let r=t.folderHref(e.id);return(0,Q.jsxs)(A,{className:qk,render:(0,Q.jsx)(`a`,{href:r}),onClick:tA(t,r),style:{paddingLeft:`${8+n*12}px`},children:[(0,Q.jsx)(sc,{size:15,stroke:1.75,className:Xk}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.name})]},e.id)})})})})]})}function lA(){return(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`hidden select-none px-0.5 text-[12px] text-[var(--chrome-fg-400)] sm:block`,children:`/`})}function uA(e){let t=e.location,n=t.folderPath,r=n[n.length-1],i=n.length>$k?n.slice(0,-1):[],a=i.length>0?n.slice(-1):n;return(0,Q.jsxs)(Q.Fragment,{children:[e.onBack&&(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Back to ${r?.name??e.workspaceName}`,"data-testid":`canvas-back-button`,onClick:e.onBack,className:`flex h-full w-7 shrink-0 cursor-pointer items-center justify-center rounded-md text-[var(--chrome-fg-600)] transition-colors hover:bg-[var(--chrome-hover)] hover:text-[var(--chrome-fg-900)] coarse:w-10`,children:(0,Q.jsx)(Gs,{size:16,stroke:1.75})}),(0,Q.jsxs)(`div`,{className:`hidden h-full min-w-0 items-center sm:flex`,children:[(0,Q.jsx)(sA,{location:t,folderId:null,label:e.workspaceName,testId:`location-workspace`}),i.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(lA,{}),(0,Q.jsx)(cA,{location:t,folders:i})]}),a.map(e=>(0,Q.jsxs)(`div`,{className:`flex h-full min-w-0 items-center`,children:[(0,Q.jsx)(lA,{}),(0,Q.jsx)(sA,{location:t,folderId:e.id,label:e.name,testId:`location-folder`})]},e.id)),(0,Q.jsx)(lA,{})]})]})}function dA(e){let t=e.actions,n=e.Item;function r(t,r,i,a){return(0,Q.jsxs)(n,{className:qk,"data-testid":`${e.prefix}-${t}`,onClick:a,children:[(0,Q.jsx)(`span`,{className:Xk,children:r}),(0,Q.jsx)(`span`,{children:i})]})}return(0,Q.jsxs)(Q.Fragment,{children:[t.onRename&&r(`rename`,(0,Q.jsx)(hc,{size:15,stroke:1.75}),`Rename…`,t.onRename),t.onDuplicate&&r(`duplicate`,(0,Q.jsx)(ga,{size:15,stroke:1.75}),`Duplicate`,t.onDuplicate),t.onMove&&r(`move`,(0,Q.jsx)(op,{size:15,stroke:1.75}),`Move to folder…`,t.onMove),t.onShare&&r(`share`,(0,Q.jsx)(zp,{size:15,stroke:1.75}),`Share…`,t.onShare),r(`copy-link`,(0,Q.jsx)(fc,{size:15,stroke:1.75}),`Copy link`,t.onCopyLink),t.onDelete&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(M,{}),(0,Q.jsxs)(n,{className:Jk,"data-testid":`${e.prefix}-delete`,onClick:t.onDelete,children:[(0,Q.jsx)(Ws,{size:15,stroke:1.75,className:`shrink-0 text-red-400`}),(0,Q.jsx)(`span`,{children:`Move to trash`})]})]})]})}function fA(e){let t=e.name,n=e.onDuplicate,r=e.onDelete,{notify:i}=_(),a=aA(),[o,s]=(0,J.useState)(!1),c={onRename:e.onRename,onDuplicate:n?()=>{n().catch(()=>i(`Couldn't duplicate “${t}”. Try again.`))}:void 0,onMove:e.onMove,onShare:e.onShare,onCopyLink:()=>a(window.location.pathname),onDelete:r?()=>s(!0):void 0};return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(Ka,{children:[(0,Q.jsx)(Ua,{render:(0,Q.jsx)(`div`,{className:`flex h-full min-w-0`}),children:(0,Q.jsxs)(N,{children:[(0,Q.jsxs)(I,{"data-testid":`canvas-meta-button`,className:`${Zk} text-[var(--chrome-fg-900)]`,children:[(0,Q.jsx)(`span`,{className:`max-w-[260px] truncate`,children:t}),(0,Q.jsx)(C,{size:14,stroke:1.75,className:`shrink-0 text-[var(--chrome-fg-500)]`})]}),(0,Q.jsx)(P,{children:(0,Q.jsx)(L,{side:`bottom`,align:`start`,sideOffset:8,className:`z-50 outline-none`,children:(0,Q.jsx)(j,{"data-overlay":!0,"data-testid":`canvas-title-menu`,className:Yk,children:(0,Q.jsx)(dA,{actions:c,prefix:`canvas-title`,Item:A})})})})]})}),(0,Q.jsx)(P,{children:(0,Q.jsx)(L,{className:`z-50 outline-none`,children:(0,Q.jsx)(j,{"data-overlay":!0,"data-testid":`canvas-title-context`,className:Yk,children:(0,Q.jsx)(dA,{actions:c,prefix:`canvas-title-ctx`,Item:A})})})})]}),r&&(0,Q.jsx)(Vb,{open:o,onOpenChange:s,title:`Move “${t}” to the trash?`,description:`You can restore it from the trash later.`,confirmLabel:`Move to trash`,destructive:!0,onConfirm:r,testId:`canvas-title-delete-confirm`})]})}function pA(e){let t=e.hasShapes;return(0,Q.jsxs)(N,{children:[(0,Q.jsxs)(I,{"data-testid":`scratch-title-button`,className:`${Zk} text-[var(--chrome-fg-900)]`,children:[(0,Q.jsx)(`span`,{children:`Scratch`}),(0,Q.jsx)(C,{size:14,stroke:1.75,className:`shrink-0 text-[var(--chrome-fg-500)]`})]}),(0,Q.jsx)(P,{children:(0,Q.jsx)(L,{side:`bottom`,align:`start`,sideOffset:8,className:`z-50 outline-none`,children:(0,Q.jsxs)(j,{"data-overlay":!0,"data-testid":`scratch-title-menu`,className:Yk,children:[(0,Q.jsxs)(A,{className:qk,"data-testid":`scratch-save`,disabled:!t,onClick:e.onSave,children:[(0,Q.jsx)(Ks,{size:15,stroke:1.75,className:Xk}),(0,Q.jsx)(`span`,{children:`Save to workspace…`})]}),(0,Q.jsxs)(A,{className:qk,"data-testid":`scratch-download`,disabled:!t,onClick:e.onDownload,children:[(0,Q.jsx)(nc,{size:15,stroke:1.75,className:Xk}),(0,Q.jsx)(`span`,{children:`Download a copy`})]}),(0,Q.jsx)(M,{}),(0,Q.jsxs)(A,{className:Jk,"data-testid":`scratch-clear`,disabled:!t,onClick:e.onClear,children:[(0,Q.jsx)(ic,{size:15,stroke:1.75,className:`shrink-0 text-red-400`}),(0,Q.jsx)(`span`,{children:`Clear canvas`})]})]})})})]})}var mA=4;function hA(){let e=te(),t=H(),n=U(e=>[...e.lastPeerPointers.keys()].sort().join(`\0`)),r=e.presence??[];if(r.length===0)return null;let i=new Set(n.split(`\0`)),a=e=>{let{lastPeerPointers:n,viewport:r,setViewport:i}=t.store.getState(),a=n.get(e),o=t.measurementRoot.current;!a||!(o instanceof HTMLElement)||t.viewportAnimation.animate(r,{...r,x:o.clientWidth/2-a.x*r.zoom,y:o.clientHeight/2-a.y*r.zoom},i)},o=r.slice(0,mA),s=r.length-o.length;return(0,Q.jsxs)(`div`,{className:`flex items-center -space-x-1.5`,"data-testid":`presence-avatars`,children:[o.map(e=>{let t=i.has(e.id);return(0,Q.jsx)(S,{label:t?`Go to ${e.name}`:`${e.name} isn't pointing at the canvas`,side:`bottom`,children:(0,Q.jsx)(`button`,{type:`button`,"data-testid":`presence-avatar`,"aria-label":`${e.name} is on this canvas`,"aria-disabled":!t,onClick:()=>a(e.id),className:`flex h-6 w-6 select-none items-center justify-center rounded-full text-[11px] font-medium text-white ring-2 ring-[var(--chrome-surface)] ${t?`cursor-pointer transition-transform hover:z-10 hover:scale-110`:`cursor-default`}`,style:{backgroundColor:e.color},children:(e.name[0]??`?`).toUpperCase()})},e.id)}),s>0&&(0,Q.jsxs)(`span`,{className:`flex h-6 min-w-6 select-none items-center justify-center rounded-full bg-[var(--chrome-hover)] px-1 text-[11px] text-[var(--chrome-fg-600)] ring-2 ring-[var(--chrome-surface)]`,children:[`+`,s]})]})}var gA={retrying:`Not saved, retrying`,"auth-required":`Sign in to save`,"storage-error":`Not saved on this device`,error:`Not saved`,"too-large":`Too large to save`,conflict:`Saving stopped`,rejected:`Can't be saved`};function _A(e){let t=e.label,n=e.onClick,r=e.icon;return(0,Q.jsxs)(`button`,{type:`button`,"data-testid":`account-save-button`,onClick:n,className:`${cl} bg-[var(--cta-save-bg)] text-[var(--cta-save-fg)] ring-[var(--cta-save-ring)] hover:bg-[var(--cta-save-bg-hover)]`,children:[r===`login`&&(0,Q.jsx)(Tp,{size:16,stroke:1.75}),!r&&(0,Q.jsx)(Ks,{size:16,stroke:1.75}),(0,Q.jsx)(`span`,{children:vA(t)})]})}function vA(e){let t=e.split(` / `);return t.length===1?e:t.map((e,t)=>(0,Q.jsxs)(J.Fragment,{children:[t>0&&(0,Q.jsx)(`span`,{className:`mx-1 opacity-40`,children:`/`}),e]},e))}function yA(e){let{owner:t}=e,n=t?.name?.trim()??``,r=n?`Created by ${n}`:`Author unknown`;return(0,Q.jsx)(`span`,{"data-testid":`share-owner-avatar`,title:r,"aria-label":r,className:`flex h-full shrink-0 items-center pl-[3px] pr-1`,children:t?.avatarUrl?(0,Q.jsx)(`img`,{src:t.avatarUrl,alt:``,referrerPolicy:`no-referrer`,"data-testid":`share-owner-photo`,className:`h-[22px] w-[22px] rounded-full object-cover`}):(0,Q.jsx)(`span`,{className:`flex h-[22px] w-[22px] items-center justify-center rounded-full bg-[var(--chrome-active)] text-[11px] text-[var(--chrome-fg-700)]`,children:n?n[0]?.toUpperCase():(0,Q.jsx)(Gp,{size:13,stroke:1.75})})})}function bA(){xy(`AccountButton`);let e=ne(),t=te(),n=e.state.status===`authenticated`?e.state.user:null,r=e.state.status===`authenticated`?e.state.usage:void 0,[i,a]=(0,J.useState)(null),[o,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)(!1),u=W(),{notify:d}=_(),f=U(e=>e.shapes.length>0),p=(0,J.useCallback)(()=>{let e=u.getState();e.loadShapes([]),e.setSelectedIds(new Set),e.endEdit(),e.setLockRevealId(null),d(`Canvas cleared. ${zc(Qp(`undo`))} brings it back.`)},[u,d]),m=(0,J.useCallback)(()=>{let{shapes:e,viewport:t}=u.getState();wk({shapes:e,viewport:t},`scratch`),d(`Saved ${bk} file`)},[u,d]),[h,g]=(0,J.useState)(!1),v=(0,J.useRef)(!1),y=(0,J.useRef)(!1),b=(0,J.useRef)(!1),x=t.onSaveDismissed,S=(0,J.useCallback)(()=>{b.current||(b.current=!0,x?.())},[x]);(0,J.useEffect)(()=>{n&&(a(null),i!==null&&!t.canvasMeta&&t.onSaveCanvas&&g(!0))},[n,i,t.canvasMeta,t.onSaveCanvas]),(0,J.useEffect)(()=>{if(!n){g(!1);return}let e=t.autoSavePrompt===!0&&!v.current&&!t.canvasMeta&&t.onSaveCanvas!=null;if(!(!h&&!e)){if(t.documentEmpty===!0){v.current=!0,h&&S();return}t.saveAtLimit!=null&&(g(!1),v.current=!0,t.saveAtLimit?l(!0):s(!0))}},[h,n,t.documentEmpty,S,t.saveAtLimit,t.autoSavePrompt,t.canvasMeta,t.onSaveCanvas]);let C=(0,J.useRef)(!1);if((0,J.useEffect)(()=>{if(!(t.autoSavePrompt!==!0||y.current||b.current)){if(o||c){C.current=!0;return}C.current&&S()}},[t.autoSavePrompt,o,c,S]),e.state.status===`disabled`&&!t.publicShare||e.state.status===`loading`)return null;let w=t.publicShare?t.canvasMeta??null:n?t.canvasMeta:null,T=t.onSaveCanvas,E=n!=null&&!w&&T!=null,D=w!=null&&t.onEditCanvasMeta!=null,O=oc[r?.plan??`free`],k=w!=null&&t.readOnly!==!0&&t.onOpenShare!=null,A=t.onShowCanvases!=null&&(n!=null||t.canvasMeta!=null);return n&&!E&&!w?null:(0,Q.jsxs)(`div`,{className:`absolute top-[var(--chrome-top)] flex items-center gap-2 ${t.publicShare?`left-4`:`left-16 coarse:left-[4.5rem]`}`,"data-overlay":!0,"data-testid":`account-button`,onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),children:[t.scratch&&(0,Q.jsxs)(`div`,{className:`flex h-8 items-center rounded-lg p-[3px] text-[13px] coarse:h-11 ${dl}`,children:[A&&t.onShowCanvases&&(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Back to your canvases`,"data-testid":`canvas-back-button`,onClick:t.onShowCanvases,className:`flex h-full w-7 shrink-0 cursor-pointer items-center justify-center rounded-md text-[var(--chrome-fg-600)] transition-colors hover:bg-[var(--chrome-hover)] hover:text-[var(--chrome-fg-900)] coarse:w-10`,children:(0,Q.jsx)(Gs,{size:16,stroke:1.75})}),(0,Q.jsx)(pA,{hasShapes:f,onSave:()=>{if(!n){a(`save`);return}if(t.saveAtLimit){l(!0);return}s(!0)},onDownload:m,onClear:p})]}),!w&&!t.scratch&&A&&t.onShowCanvases&&(0,Q.jsxs)(`button`,{type:`button`,"aria-label":t.workspaceName?`Back to ${t.workspaceName}`:`Back to your canvases`,"data-testid":`canvas-back-button`,onClick:t.onShowCanvases,className:`flex h-8 cursor-pointer items-center justify-center rounded-lg text-[var(--chrome-fg-600)] transition-colors hover:bg-[var(--chrome-hover)] hover:text-[var(--chrome-fg-900)] coarse:h-11 ${t.workspaceName?`gap-1.5 px-2 coarse:px-3`:`w-8 coarse:w-11`} ${dl}`,children:[(0,Q.jsx)(Gs,{size:16,stroke:1.75,className:`shrink-0`}),t.workspaceName&&(0,Q.jsx)(`span`,{className:`hidden max-w-[140px] truncate text-[13px] sm:block`,children:t.workspaceName})]}),!n&&!t.publicShare&&(0,Q.jsx)(_A,{icon:`login`,label:t.canvasMeta?`Log in to keep saving`:`Log in / Sign up`,onClick:()=>a(`login`)}),E&&(0,Q.jsx)(_A,{label:t.scratch?`Save to workspace`:`Save your work`,onClick:()=>t.saveAtLimit?l(!0):s(!0)}),w&&(0,Q.jsxs)(`div`,{className:`flex h-8 items-center rounded-lg p-[3px] text-[13px] coarse:h-11 ${dl}`,children:[t.publicShare&&(0,Q.jsx)(yA,{owner:t.shareOwner??null}),t.location&&!t.publicShare?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(uA,{location:t.location,workspaceName:t.workspaceName??`Workspace`,onBack:A?t.onShowCanvases:void 0}),(0,Q.jsx)(fA,{name:w.name,onRename:D?()=>s(!0):void 0,onDuplicate:t.onDuplicateCanvas,onMove:t.onMoveCanvas,onShare:k?t.onOpenShare:void 0,onDelete:t.onDeleteCanvas})]}):(0,Q.jsxs)(Q.Fragment,{children:[A&&t.onShowCanvases&&(0,Q.jsxs)(`button`,{type:`button`,"aria-label":t.workspaceName?`Back to ${t.workspaceName}`:`Back to your canvases`,"data-testid":`canvas-back-button`,onClick:t.onShowCanvases,className:`flex h-full cursor-pointer items-center gap-1.5 rounded-md px-2 text-[var(--chrome-fg-600)] transition-colors hover:bg-[var(--chrome-hover)] hover:text-[var(--chrome-fg-900)]`,children:[(0,Q.jsx)(Gs,{size:16,stroke:1.75,className:`shrink-0`}),t.workspaceName&&(0,Q.jsx)(`span`,{className:`hidden max-w-[140px] truncate sm:block`,children:t.workspaceName})]}),A&&t.onShowCanvases&&t.workspaceName&&(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`hidden select-none px-0.5 text-[12px] text-[var(--chrome-fg-400)] sm:block`,children:`/`}),D?(0,Q.jsxs)(`button`,{type:`button`,"data-testid":`canvas-meta-button`,onClick:()=>s(!0),className:`flex h-full min-w-0 cursor-pointer items-center gap-1.5 rounded-md px-2 text-[var(--chrome-fg-900)] transition-colors hover:bg-[var(--chrome-hover)]`,children:[(0,Q.jsx)(`span`,{className:`max-w-[260px] truncate`,children:w.name}),(0,Q.jsx)(hc,{size:14,stroke:1.75,className:`shrink-0 text-[var(--chrome-fg-500)]`})]}):(0,Q.jsx)(`span`,{"data-testid":`canvas-meta-name`,className:`flex h-full min-w-0 items-center px-2 text-[var(--chrome-fg-900)]`,children:(0,Q.jsx)(`span`,{className:`max-w-[260px] truncate`,children:w.name})})]})]}),D&&t.saveStatus&&gA[t.saveStatus]&&(0,Q.jsx)(`span`,{"aria-live":`polite`,"data-testid":`canvas-save-status`,className:`whitespace-nowrap text-[12px] text-[var(--chrome-fg-500)]`,children:gA[t.saveStatus]}),k&&(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Share`,"data-testid":`canvas-share-button`,onClick:t.onOpenShare,className:`flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-lg text-[var(--chrome-fg-600)] transition-colors hover:bg-[var(--chrome-hover)] hover:text-[var(--chrome-fg-900)] coarse:h-11 coarse:w-11 ${dl}`,children:(0,Q.jsx)(zp,{size:16,stroke:1.75})}),(0,Q.jsx)(Kk,{boardName:w?.name??`board`}),(0,Q.jsx)(hA,{}),(0,Q.jsx)(db,{open:i!==null,onOpenChange:e=>{e||a(null)},title:i===`login`?`Log in or sign up`:void 0}),E&&T&&(0,Q.jsx)(Pk,{open:o,onOpenChange:s,title:`Save your canvas`,description:`Give it a name and choose where it lives.`,submitLabel:`Save`,destination:t.saveDestination,onSubmit:async(e,t)=>{try{await T(e,t),y.current=!0}catch(e){if(Uk(e)){l(!0);return}throw e}}}),E&&(0,Q.jsx)(ub,{open:c,onOpenChange:l,currentPlan:O.id,title:`Canvas limit reached`,description:O.canvasLimit===1?`The ${O.label} plan is limited to one canvas. Upgrade for unlimited canvases.`:`Your plan allows ${O.canvasLimit??`your`} canvases. To save this one, upgrade, or free a slot first.`,reassurance:`Don't worry, your work is saved on this device and will be right here when you come back.`,onPurchased:e=>{e!==`credits`&&s(!0)},secondaryLabel:t.onShowCanvases?`Go to dashboard`:void 0,onSecondary:t.onShowCanvases,testId:`canvas-limit-save`}),D&&t.onEditCanvasMeta&&(0,Q.jsx)(Pk,{open:o,onOpenChange:s,title:`Edit canvas`,description:`Rename or re-describe this canvas. Links to it keep working.`,submitLabel:`Save`,initialName:w.name,initialDescription:w.description,onSubmit:t.onEditCanvasMeta,onDelete:t.onDeleteCanvas})]})}var xA=(0,J.memo)(bA);function SA(){let e=W(),{undo:t,redo:n}=H().history;return{canUndo:le(e.temporal,e=>e.pastStates.length>0),canRedo:le(e.temporal,e=>e.futureStates.length>0),undo:t,redo:n}}var CA={panel:`h-10 coarse:h-11`,pill:`h-8 coarse:h-11`};function wA(e={}){let t=e.beside??`pill`,n=te(),r=ne(),i=n.onForkCanvas,[a,o]=(0,J.useState)(!1),[s,c]=(0,J.useState)(!1),[l,u]=(0,J.useState)(!1),[d,f]=(0,J.useState)(!1),p=r.state.status===`authenticated`?r.state.user:null,m=oc[(r.state.status===`authenticated`?r.state.usage:void 0)?.plan??`free`];function h(){if(n.forkAtLimit){u(!0);return}c(!0)}if((0,J.useEffect)(()=>{!d||!p||(f(!1),h())},[d,p,n.forkAtLimit]),!i)return null;let g=n.canvasMeta?.name;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`button`,{type:`button`,"data-testid":`share-fork`,"aria-label":`Fork this canvas`,title:`Take a copy into your own account`,onClick:()=>{if(!p){f(!0),o(!0);return}h()},onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),className:`pointer-events-auto flex ${CA[t]} cursor-pointer items-center gap-1.5 rounded-xl bg-[var(--chrome-accent)] px-3 text-[12px] text-white outline-none transition-colors active:scale-[0.97] hover:bg-[var(--chrome-accent-hover)]`,children:[(0,Q.jsx)(sp,{size:14,stroke:1.75}),`Fork`]}),(0,Q.jsx)(db,{open:a,onOpenChange:e=>{o(e),e||f(!1)},title:`Sign in to fork this canvas`,description:`Your copy lands in your own account, where you can edit it freely.`}),(0,Q.jsx)(Pk,{open:s,onOpenChange:c,title:`Fork this canvas`,description:`Name your copy and choose where it lives.`,submitLabel:`Fork`,initialName:g?`Copy of ${g}`:void 0,destination:n.saveDestination,onSubmit:async(e,t)=>{try{await i(e,t)}catch(e){if(Uk(e)){u(!0);return}throw e}}}),(0,Q.jsx)(ub,{open:l,onOpenChange:u,currentPlan:m.id,title:`Canvas limit reached`,description:m.canvasLimit===1?`The ${m.label} plan is limited to one canvas. Upgrade for unlimited canvases.`:`Your plan allows ${m.canvasLimit??`your`} canvases. To fork this one, upgrade, or free a slot first.`,reassurance:`This canvas isn't going anywhere — the link keeps working, so you can come back and fork it once there's room.`,onPurchased:e=>{e!==`credits`&&c(!0)},secondaryLabel:n.onShowCanvases?`Go to dashboard`:void 0,onSecondary:n.onShowCanvases,testId:`share-fork-limit`})]})}function TA(e){let{onZoomToFit:t}=e,{ai:n,publicShare:r,onForkCanvas:i}=te(),a=_e(e=>[e.shapes,r],(e,t)=>!t||Bn(e).some(e=>e.slideOrder!==void 0)),o=U(e=>e.viewMode),{canUndo:s,canRedo:c,undo:l,redo:u}=SA(),{setSlidesOpen:d,setAiOpen:f,setCodeOpen:p}=W().getState();return(0,Q.jsxs)(`div`,{className:`absolute right-4 top-[var(--chrome-top)] flex flex-col items-end gap-2`,"data-overlay":!0,"data-testid":`mobile-top-bar`,onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),children:[i!=null&&(0,Q.jsx)(wA,{}),(0,Q.jsxs)(N,{children:[(0,Q.jsx)(I,{render:(0,Q.jsx)(`button`,{type:`button`,"aria-label":`More`,"data-testid":`mobile-overflow`,className:`flex h-8 w-10 cursor-pointer items-center justify-center rounded-xl text-[var(--chrome-fg-600)] transition-colors hover:text-[var(--chrome-fg-900)] data-[popup-open]:text-[var(--chrome-fg-900)] coarse:h-11 coarse:w-12 ${dl}`,children:(0,Q.jsx)(tp,{size:17,stroke:1.75})})}),(0,Q.jsx)(P,{children:(0,Q.jsx)(L,{side:`bottom`,align:`end`,sideOffset:8,className:`outline-none`,children:(0,Q.jsxs)(j,{"data-overlay":!0,"data-testid":`mobile-overflow-popup`,className:`min-w-[190px] p-1 outline-none ${q.popup}`,children:[!o&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(R,{testId:`overflow-undo`,icon:(0,Q.jsx)(zs,{size:15,stroke:1.75}),disabled:!s,onClick:()=>l(),children:`Undo`}),(0,Q.jsx)(R,{testId:`overflow-redo`,icon:(0,Q.jsx)(Ff,{size:15,stroke:1.75}),disabled:!c,onClick:()=>u(),children:`Redo`}),(0,Q.jsx)(M,{})]}),(0,Q.jsx)(R,{testId:`overflow-zoom-fit`,icon:(0,Q.jsx)(ac,{size:15,stroke:1.75}),onClick:t,children:`Zoom to fit`}),(0,Q.jsx)(M,{}),n&&(0,Q.jsx)(R,{testId:`overflow-ai`,icon:(0,Q.jsx)(Sc,{size:15,stroke:1.75}),onClick:()=>f(!0),children:`AI assistant`}),a&&(0,Q.jsx)(R,{testId:`overflow-slides`,icon:(0,Q.jsx)(Js,{size:15,stroke:1.75}),onClick:()=>d(!0),children:`Slides`}),!r&&(0,Q.jsx)(R,{testId:`overflow-code`,icon:(0,Q.jsx)(ec,{size:15,stroke:1.75}),onClick:()=>p(!0),children:`Diagram as code`})]})})})]})]})}function EA(e){let{containerRef:t,onBackToContent:n}=e,r=U(e=>e.shapes),i=U(e=>e.viewport),a=U(e=>e.transforming),o=(0,J.useRef)(r);a||(o.current=r);let s=o.current,[c,l]=(0,J.useState)({width:0,height:0});(0,J.useEffect)(()=>{let e=t.current;if(!e)return;let n=()=>{l({width:e.clientWidth,height:e.clientHeight})};n();let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[t]);let u=(0,J.useMemo)(()=>{let e=s.map(Bt),t=1/0,n=1/0,r=-1/0,i=-1/0;for(let a of e)Hr(a)&&(t=Math.min(t,a.x),n=Math.min(n,a.y),r=Math.max(r,a.x+a.width),i=Math.max(i,a.y+a.height));return{boxes:e,bounds:t===1/0?null:{x:t,y:n,width:r-t,height:i-n}}},[s]),d=(0,J.useRef)(0),f=(0,J.useMemo)(()=>{if(u.boxes.length===0||c.width===0||c.height===0)return!1;let e={x:-i.x/i.zoom,y:-i.y/i.zoom,width:c.width/i.zoom,height:c.height/i.zoom};if(!u.bounds||!Ar(e,u.bounds))return!0;let t=u.boxes[d.current];if(t&&Ar(e,t))return!1;let n=u.boxes.findIndex(t=>Ar(e,t));return n===-1?!0:(d.current=n,!1)},[u,i,c]),p=(0,J.useMemo)(()=>{if(!f||!u.bounds)return 0;let e={x:u.bounds.x+u.bounds.width/2,y:u.bounds.y+u.bounds.height/2},t={x:(c.width/2-i.x)/i.zoom,y:(c.height/2-i.y)/i.zoom},n=Math.atan2(e.y-t.y,e.x-t.x);return Math.round(n*180/Math.PI+90)},[u,i,c,f]);return f?(0,Q.jsx)(`div`,{className:`pointer-events-auto`,"data-overlay":!0,onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),children:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>n(),className:`flex h-9 items-center gap-1.5 rounded-full bg-[var(--chrome-accent)] pl-3 pr-4 text-[13px] text-white transition-colors hover:bg-[var(--chrome-accent-hover)] ${fl}`,children:[(0,Q.jsx)(Hs,{size:15,stroke:1.75,className:`text-white/70`,style:{transform:`rotate(${p}deg)`}}),`Back to content`]})}):null}var DA=(0,J.memo)(EA);function OA(e){let{containerRef:t,onZoomIn:n,onZoomOut:r,onReset:i,onZoomToFit:a}=e,o=U(e=>e.viewport.zoom);function s(){let e=t.current;if(!e)return{x:0,y:0};let n=e.getBoundingClientRect();return{x:n.width/2,y:n.height/2}}return(0,Q.jsxs)(`div`,{className:`flex items-center gap-0.5 ${ll}`,onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),children:[(0,Q.jsx)(S,{label:`Zoom out`,side:`top`,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Zoom out`,onClick:()=>r(s()),className:`flex h-8 w-8 items-center justify-center rounded-lg text-[var(--chrome-fg-600)] transition-colors hover:bg-[var(--chrome-hover)]`,children:(0,Q.jsx)(mc,{size:16,stroke:1.75})})}),(0,Q.jsx)(S,{label:`Reset to 100%`,side:`top`,children:(0,Q.jsxs)(`button`,{type:`button`,"aria-label":`Reset zoom to 100%`,onClick:()=>i(s()),className:`min-w-[52px] rounded-lg px-2 py-1 text-center text-[13px] font-medium tabular-nums text-[var(--chrome-fg-700)] transition-colors hover:bg-[var(--chrome-hover)]`,children:[Math.round(o*100),`%`]})}),(0,Q.jsx)(S,{label:`Zoom in`,side:`top`,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Zoom in`,onClick:()=>n(s()),className:`flex h-8 w-8 items-center justify-center rounded-lg text-[var(--chrome-fg-600)] transition-colors hover:bg-[var(--chrome-hover)]`,children:(0,Q.jsx)(_c,{size:16,stroke:1.75})})}),(0,Q.jsx)(`span`,{className:`mx-0.5 h-5 w-px bg-[var(--chrome-divider)]`}),(0,Q.jsx)(S,{label:`Zoom to fit`,side:`top`,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Zoom to fit`,onClick:()=>a(),className:`flex h-8 w-8 items-center justify-center rounded-lg text-[var(--chrome-fg-600)] transition-colors hover:bg-[var(--chrome-hover)]`,children:(0,Q.jsx)(Op,{size:15,stroke:1.75})})})]})}var kA=(0,J.memo)(OA);function AA(){let e=U(e=>e.viewport.zoom),t=U(e=>e.zoomGestureNonce),n=U(e=>e.showZoomIndicator),[r,i]=(0,J.useState)(!1),a=(0,J.useRef)(null),o=(0,J.useRef)(t);return(0,J.useEffect)(()=>{if(t!==o.current)return o.current=t,i(!0),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>i(!1),300),()=>{a.current&&clearTimeout(a.current)}},[t]),n?(0,Q.jsxs)(`div`,{"data-testid":`zoom-indicator`,"aria-hidden":!0,className:`pointer-events-none absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 rounded-xl px-4 py-2 text-[15px] font-medium tabular-nums text-[var(--chrome-fg-700)] ${dl} ${r?`opacity-100`:`opacity-0`}`,children:[Math.round(e*100),`%`]}):null}var jA=(0,J.memo)(AA),MA={sm:`rounded-md bg-[var(--chrome-hover)] px-2 py-1 text-center text-[11px] leading-none text-[var(--chrome-fg-500)] ring-1 ring-[var(--chrome-ring)]`,md:`rounded-md bg-[var(--chrome-hover)] px-2 py-0.5 font-sans text-[13px] text-[var(--chrome-fg-500)] ring-1 ring-[var(--chrome-ring)]`};function NA(e){return(0,Q.jsx)(`kbd`,{className:MA[e.size??`sm`],children:e.children})}var PA=`M7 18.3895C8.23437 16.6169 11.9752 11.5804 16.3514 8.74789C19.6425 6.61824 22.7512 9.42977 20.3407 12.2607C17.9836 15.0302 14.8214 18.8419 13.4722 20.734C12.0727 22.6957 14.4676 25.0677 16.864 22.8104C18.4663 21.3012 20.1347 19.5658 21.8298 18.2828C24.1193 16.5523 26.0833 18.0809 25.0848 20.0312C24.3614 21.4418 23.8378 22.0639 23.2356 23.2515C22.6317 24.4375 23.2701 25.861 24.1837 25.9822C25.3159 26.1341 26.0329 25.2987 27 23.998`;function FA(e){let{size:t}=e;return(0,Q.jsx)(`svg`,{width:t,height:t,viewBox:`0 0 34 34`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,"aria-hidden":!0,children:(0,Q.jsx)(`path`,{d:PA,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function IA(e){let{size:t,className:n,testId:r}=e;return(0,Q.jsx)(`span`,{"data-testid":r,className:`flex shrink-0 items-center justify-center bg-[var(--chrome-fg-900)] text-[var(--chrome-page)] ${n??``}`,style:{width:t,height:t,borderRadius:t*7/34},children:(0,Q.jsx)(FA,{size:t})})}var LA=`"Balsamiq Sans Neue", ui-sans-serif, system-ui, cursive`,RA=2.5;function zA(e,t,n,r,i){let a=1-i;return{x:a*a*a*e.x+3*a*a*i*t.x+3*a*i*i*n.x+i*i*i*r.x,y:a*a*a*e.y+3*a*a*i*t.y+3*a*i*i*n.y+i*i*i*r.y}}function BA(e,t,n,r,i){if(!n||!r)return Math.atan2(t.y-e.y,t.x-e.x);let a=t,o=i;for(let i=1;i<=64;i+=1){let s=zA(e,n,r,t,1-i/64);if(o-=Mr(a,s),o<=0)return Math.atan2(t.y-s.y,t.x-s.x);a=s}return Math.atan2(t.y-e.y,t.x-e.x)}function VA(e){let{className:t,width:n,height:r,from:i,to:a,c1:o,c2:s}=e,c=sr(RA/2.5),l=o&&s?`M ${i.x} ${i.y} C ${o.x} ${o.y}, ${s.x} ${s.y}, ${a.x} ${a.y}`:`M ${i.x} ${i.y} L ${a.x} ${a.y}`,u=En(a,BA(i,a,o,s,c),c);return(0,Q.jsxs)(`svg`,{className:`absolute text-[var(--chrome-fg-300)] ${t}`,width:n,height:r,viewBox:`0 0 ${n} ${r}`,fill:`none`,stroke:`currentColor`,strokeWidth:RA,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0,children:[(0,Q.jsx)(`path`,{d:l}),(0,Q.jsx)(`path`,{d:u})]})}function HA(e){let{icon:t,label:n,shortcut:r,testId:i,onClick:a,onPreload:o}=e;return(0,Q.jsxs)(`button`,{type:`button`,"data-testid":i,onClick:a,onPointerEnter:o,onFocus:o,className:`group flex h-9 cursor-pointer items-center gap-2 rounded-xl bg-[var(--chrome-hover)] px-3 text-[13px] text-[var(--chrome-fg-900)] transition-[background-color,scale] hover:bg-[color-mix(in_srgb,var(--chrome-active)_50%,var(--chrome-hover))] active:scale-[0.97]`,children:[(0,Q.jsx)(`span`,{className:`text-[var(--chrome-fg-600)] transition-colors group-hover:text-[var(--chrome-fg-800)]`,children:t}),n,(0,Q.jsx)(`span`,{className:`text-[12px] text-[var(--chrome-fg-500)] transition-colors group-hover:text-[var(--chrome-fg-600)]`,children:zc(r)})]})}function UA(e){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`absolute whitespace-nowrap text-[19px] leading-none text-[var(--chrome-fg-400)] ${e.labelClass}`,style:{fontFamily:LA},children:e.label}),e.arrow]})}function WA(){let{assistant:e,publicShare:t}=te(),n=re(),r=W(),i=U(e=>e.shapes.length===0),a=U(e=>e.tool!==`select`),o=U(e=>e.rightPanel!==null),s=U(e=>e.pasteChoiceGrid!==null),c=U(e=>e.commentDraft!==null),l=(n?.threads.length??0)>0,u=U(e=>e.deviceMode===`phone`);return!i||a||o||s||c||l?null:u?(0,Q.jsx)(`div`,{"data-testid":`empty-hint`,"aria-hidden":!0,className:`pointer-events-none absolute inset-0 z-20`,children:(0,Q.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-3 px-8 text-center`,children:[(0,Q.jsx)(IA,{size:52,className:`mb-3 opacity-90`,testId:`empty-hint-logo`}),(0,Q.jsx)(`div`,{className:`text-[18px] text-[var(--chrome-fg-400)]`,children:`Double-tap anywhere to add text`}),(0,Q.jsx)(`div`,{className:`text-[14px] text-[var(--chrome-fg-400)]`,children:`or pick a tool from the bar below`})]})})}):(0,Q.jsxs)(`div`,{"data-testid":`empty-hint`,className:`pointer-events-none absolute inset-0 z-20`,children:[(0,Q.jsx)(UA,{labelClass:`left-[145px] top-[calc(136px+var(--koboyo-host-inset-top))]`,label:`Pick a tool from here`,arrow:(0,Q.jsx)(VA,{className:`left-[73px] top-[calc(140px+var(--koboyo-host-inset-top))]`,width:78,height:52,from:{x:61,y:12},to:{x:4,y:44}})}),(0,Q.jsx)(UA,{labelClass:`right-[133px] top-[calc(100px+var(--koboyo-host-inset-top))]`,label:`Slides & Diagrams as Code`,arrow:(0,Q.jsx)(VA,{className:`right-[60px] top-[calc(27px+var(--koboyo-host-inset-top))]`,width:110,height:70,from:{x:7,y:62},c1:{x:30,y:30},c2:{x:70,y:14},to:{x:97,y:14}})}),(0,Q.jsx)(UA,{labelClass:`bottom-[122px] left-[150px]`,label:`Zoom & reset view`,arrow:(0,Q.jsx)(VA,{className:`bottom-[63px] left-[80px]`,width:70,height:80,from:{x:58,y:13},c1:{x:33,y:16},c2:{x:9,y:44},to:{x:9,y:74}})}),(0,Q.jsx)(UA,{labelClass:`bottom-[120px] right-[127px]`,label:`Keyboard shortcuts`,arrow:(0,Q.jsx)(VA,{className:`bottom-[54px] right-[23px]`,width:130,height:90,from:{x:43,y:16},c1:{x:78,y:12},c2:{x:114,y:50},to:{x:114,y:84}})}),(0,Q.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-3 text-center`,children:[(0,Q.jsx)(IA,{size:52,className:`mb-3 opacity-90`,testId:`empty-hint-logo`}),(0,Q.jsx)(`div`,{className:`text-[18px] text-[var(--chrome-fg-400)]`,children:`Double-click anywhere to add text`}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-x-2 gap-y-1.5 text-[14px] text-[var(--chrome-fg-400)]`,children:[(0,Q.jsx)(`span`,{children:`or pick a tool`}),(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Q.jsx)(NA,{size:`md`,children:`R`}),` rectangle`]}),(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Q.jsx)(NA,{size:`md`,children:`O`}),` ellipse`]}),(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Q.jsx)(NA,{size:`md`,children:`A`}),` arrow`]}),(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Q.jsx)(NA,{size:`md`,children:`/`}),` all tools`]})]}),(0,Q.jsxs)(`div`,{className:`pointer-events-auto mt-5 flex flex-wrap items-center justify-center gap-2`,"data-overlay":!0,onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),children:[e&&(0,Q.jsx)(HA,{icon:(0,Q.jsx)(Sc,{size:16,stroke:1.75}),label:`Generate with AI`,shortcut:Qp(`aiPanel`),testId:`empty-hint-ai`,onClick:()=>r.getState().setAiOpen(!0),onPreload:()=>eo(e)}),(0,Q.jsx)(HA,{icon:(0,Q.jsx)(Js,{size:16,stroke:1.75}),label:`Create slides`,shortcut:Qp(`slidesPanel`),testId:`empty-hint-slides`,onClick:()=>r.getState().setSlidesOpen(!0),onPreload:()=>eo(Wy)}),!t&&(0,Q.jsx)(HA,{icon:(0,Q.jsx)(ec,{size:16,stroke:1.75}),label:`Diagram as code`,shortcut:Qp(`codePanel`),testId:`empty-hint-code`,onClick:()=>r.getState().setCodeOpen(!0),onPreload:()=>eo(Gy)})]})]})})]})}var GA=(0,J.memo)(WA);function KA(){let{canUndo:e,canRedo:t,undo:n,redo:r}=SA();return(0,Q.jsxs)(`div`,{className:`flex items-center gap-0.5 ${ll}`,"data-overlay":!0,onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),children:[(0,Q.jsx)(S,{label:`Undo`,side:`top`,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Undo`,disabled:!e,onClick:()=>n(),className:`${il} disabled:pointer-events-none disabled:text-[var(--chrome-fg-300)]`,children:(0,Q.jsx)(zs,{size:16,stroke:1.75})})}),(0,Q.jsx)(S,{label:`Redo`,side:`top`,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Redo`,disabled:!t,onClick:()=>r(),className:`${il} disabled:pointer-events-none disabled:text-[var(--chrome-fg-300)]`,children:(0,Q.jsx)(Ff,{size:16,stroke:1.75})})})]})}var qA=(0,J.memo)(KA);function JA(e){switch(wn[e.type].search){case`label`:return It(e.label??``);case`label-and-name`:{let t=e;return`${It(t.label??``)}\n${t.name}`}case`text`:return It(e.text);case`cells`:return e.cells.flat().map(It).join(`
24
+ `);case`none`:return``}}function YA(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>JA(e).toLowerCase().includes(n)):[]}var XA=80,ZA=[],QA=`${il} disabled:pointer-events-none disabled:text-[var(--chrome-fg-300)]`;function $A(e){let{containerRef:t}=e,{store:n,viewportAnimation:r}=H(),i=U(e=>e.shapes),a=U(e=>e.searchOpen),o=U(e=>e.setSearchOpen),[s,c]=(0,J.useState)(``),[l,u]=(0,J.useState)(``),[d,f]=(0,J.useState)(0),p=(0,J.useRef)(null),m=(0,J.useMemo)(()=>a?YA(i,l):ZA,[a,i,l]),h=m.length,g=Math.min(d,Math.max(0,h-1));(0,J.useEffect)(()=>{function e(e){e.key.toLowerCase()===`f`&&(e.metaKey||e.ctrlKey)&&!e.shiftKey&&!e.altKey&&(e.preventDefault(),o(!0),requestAnimationFrame(()=>p.current?.select()))}return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[o]),(0,J.useEffect)(()=>{a&&p.current?.select()},[a]);function _(e){let i=n.getState();i.setSelectedIds(e.locked?new Set:new Set([e.id]));let a=t.current;if(!a)return;let o={width:a.clientWidth,height:a.clientHeight},s=Cn(e),{viewport:c}=i,l=Math.min((o.width-XA*2)/s.width,(o.height-XA*2)/s.height),u=yn(Math.min(c.zoom,l)),d={zoom:u,x:o.width/2-(s.x+s.width/2)*u,y:o.height/2-(s.y+s.height/2)*u};r.animate(c,d,i.setViewport)}function v(e){u(e),f(0);let t=YA(n.getState().shapes,e);t.length>0&&_(t[0])}function y(e){if(s!==l){v(s);return}if(h===0)return;let t=(g+e+h)%h;f(t),_(m[t])}function b(){o(!1)}return a?(0,Q.jsxs)(`div`,{"data-overlay":!0,"data-testid":`canvas-search`,className:`pointer-events-auto flex items-center gap-0.5 ${ll}`,onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),children:[(0,Q.jsx)(xc,{size:16,stroke:1.75,className:`ml-2 shrink-0 text-[var(--chrome-fg-400)]`}),(0,Q.jsx)(`input`,{ref:p,"data-testid":`canvas-search-input`,value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`&&(e.preventDefault(),y(e.shiftKey?-1:1)),e.key===`Escape`&&b()},placeholder:`Search`,className:`h-8 w-44 bg-transparent px-1.5 text-[13px] text-[var(--chrome-fg-900)] outline-none placeholder:text-[var(--chrome-fg-400)]`}),l.trim()&&(0,Q.jsx)(`span`,{"data-testid":`canvas-search-count`,className:`min-w-9 shrink-0 text-center text-[11px] tabular-nums text-[var(--chrome-fg-500)]`,children:h===0?`0/0`:`${g+1}/${h}`}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Previous match`,disabled:h===0,onClick:()=>y(-1),className:QA,children:(0,Q.jsx)(Xf,{size:16,stroke:1.75})}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Next match`,disabled:h===0,onClick:()=>y(1),className:QA,children:(0,Q.jsx)(C,{size:16,stroke:1.75})}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Close search`,onClick:b,className:il,children:(0,Q.jsx)(Cc,{size:16,stroke:1.75})})]}):null}var ej=(0,J.memo)($A);function tj(e,t){return e.anchor.kind===`point`||Rn(t).position.has(e.anchor.shapeId)}var nj=[];function rj(){let e=re(),t=H(),{notify:n}=_(),[r,i]=(0,J.useState)(!1),a=U(e=>r?e.shapes:nj),[o,s]=(0,J.useState)(`open`),[c,l]=(0,J.useState)(null),[u,d]=(0,J.useState)(()=>Date.now()),f=(0,J.useRef)(null),[p,m]=(0,J.useState)(!1),h=(0,J.useRef)(null);if(ex(r?c:null),!e||e.threads.length===0)return null;let g=[...e.threads].sort((e,t)=>t.updatedAt-e.updatedAt),v=g.filter(e=>e.resolvedAt===null),y=g.filter(e=>e.resolvedAt!==null),b=o===`open`?v:y,x=c?g.find(e=>e.id===c):void 0;function C(e){if(f.current?.isDirty()){h.current=e,m(!0);return}e()}function w(){i(!1),l(null)}function T(e){w(),tx(t,e)}let E=e.notifications,D=$b(e);function O(){if(!E)return;let e=!E.muted;E.setMuted(e).then(()=>n(e?`Canvas muted. You won't be notified about it.`:`Canvas unmuted. You'll be notified about it again.`)).catch(e=>n(Cl(e,`Couldn't change that. Try again.`)))}return(0,Q.jsxs)(Dc,{open:r,onOpenChange:e=>{if(e){d(Date.now()),i(!0);return}C(w)},children:[(0,Q.jsx)(S,{label:`All comments`,side:`left`,children:(0,Q.jsx)(Ca,{render:(0,Q.jsxs)(`button`,{type:`button`,"aria-label":D?`All comments, new activity`:`All comments`,"data-testid":`comments-list-open`,"data-unread":D?`true`:void 0,className:`relative ${pl(r)}`,children:[(0,Q.jsx)(jp,{size:17,stroke:1.75}),D&&(0,Q.jsx)(`span`,{"aria-hidden":!0,"data-testid":`comments-unread-dot`,className:`absolute right-1 top-1 h-2 w-2 rounded-full bg-[var(--chrome-unread)] ring-2 ring-[var(--chrome-popup)]`})]})})}),(0,Q.jsx)(Mc,{children:(0,Q.jsx)(Lc,{side:`left`,align:`start`,sideOffset:8,collisionPadding:12,children:(0,Q.jsx)(Rc,{"data-overlay":!0,"data-testid":`comments-list`,className:mx,children:x?(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Q.jsxs)(`button`,{type:`button`,"data-testid":`comments-list-back`,onClick:()=>C(()=>l(null)),className:`flex items-center gap-1.5 px-3 pt-2 text-left text-[12px] text-[var(--chrome-fg-500)] hover:text-[var(--chrome-fg-900)]`,children:[(0,Q.jsx)(Gs,{size:13,stroke:1.75}),`All comments`]}),(0,Q.jsx)(fx,{thread:x,comments:e,onClose:()=>l(null),now:u,composerRef:f,confirmDiscard:e=>C(e)})]}):(0,Q.jsxs)(`div`,{className:`flex w-[304px] flex-col`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-[var(--chrome-divider)] p-1.5`,children:[(0,Q.jsx)(`div`,{role:`tablist`,className:`flex flex-1 gap-1`,children:[[`open`,`Open`,v.length],[`resolved`,`Resolved`,y.length]].map(([e,t,n])=>(0,Q.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":o===e,"data-testid":`comments-list-filter-${e}`,onClick:()=>s(e),className:`flex h-7 cursor-pointer items-center gap-1 rounded-lg px-2.5 text-[12px] text-[var(--chrome-fg-700)] transition-colors hover:bg-[var(--chrome-hover)] ${o===e?`bg-[var(--chrome-active)]`:``}`,children:[t,(0,Q.jsx)(`span`,{className:`text-[var(--chrome-fg-400)]`,children:n})]},e))}),E&&(0,Q.jsx)(S,{label:E.muted?`Unmute this canvas`:`Mute this canvas (no notifications about it)`,side:`top`,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":E.muted?`Unmute this canvas`:`Mute this canvas`,"aria-pressed":E.muted,"data-testid":`comments-mute-toggle`,onClick:O,className:`flex h-7 w-7 shrink-0 cursor-pointer items-center justify-center rounded-lg text-[var(--chrome-fg-500)] transition-colors hover:bg-[var(--chrome-hover)] hover:text-[var(--chrome-fg-900)]`,children:E.muted?(0,Q.jsx)(Rf,{size:15,stroke:1.75}):(0,Q.jsx)(zf,{size:15,stroke:1.75})})})]}),(0,Q.jsxs)(`div`,{className:`scrollbar-slim max-h-[360px] overflow-y-auto py-1`,children:[b.length===0&&(0,Q.jsx)(`p`,{className:`px-3 py-3 text-[13px] text-[var(--chrome-fg-400)]`,children:o===`open`?`No open comments.`:`No resolved comments.`}),b.map(t=>{let n=t.comments[0],r=tj(t,a),i=t.comments.length-1,o=Qb(e,t.id);return(0,Q.jsxs)(`button`,{type:`button`,"data-testid":`comments-list-row`,"data-detached":r?void 0:`true`,"data-unread":o>0?`true`:void 0,onClick:()=>r?T(t):l(t.id),className:`relative flex w-full flex-col gap-0.5 px-3 py-2 text-left hover:bg-[var(--chrome-hover)] ${o>0?`bg-[var(--chrome-unread-bg)]`:``}`,children:[(0,Q.jsxs)(`span`,{className:`flex items-baseline gap-1.5 text-[12px] text-[var(--chrome-fg-500)]`,children:[(0,Q.jsx)(`span`,{className:`truncate text-[var(--chrome-fg-900)]`,children:n?.author.name}),(0,Q.jsx)(`span`,{className:`shrink-0`,children:rx(t.updatedAt,u)}),i>0&&(0,Q.jsxs)(`span`,{className:`shrink-0`,children:[`· `,i,` `,i===1?`reply`:`replies`]}),o>0&&(0,Q.jsxs)(`span`,{"data-testid":`comments-list-row-new`,className:`ml-auto flex shrink-0 items-center gap-1 self-center text-[11px] text-[var(--chrome-unread)]`,children:[i>0&&`${o} new`,(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`h-2 w-2 rounded-full bg-[var(--chrome-unread)]`})]})]}),(0,Q.jsx)(`span`,{className:`line-clamp-2 text-[13px] text-[var(--chrome-fg-700)]`,children:n?.body}),!r&&(0,Q.jsx)(`span`,{className:`text-[11px] text-[var(--chrome-fg-400)]`,children:`Its shape was deleted`})]},t.id)})]})]})})})}),(0,Q.jsx)(Vb,{open:p,onOpenChange:e=>{m(e),e||(h.current=null)},title:`Discard this comment?`,description:`You've written something that hasn't been posted yet. Discarding throws it away.`,confirmLabel:`Discard`,destructive:!0,testId:`comment-discard-confirm`,onConfirm:()=>{f.current?.discard(),h.current?.(),h.current=null}})]})}function ij(){let{assistant:e,publicShare:t,onForkCanvas:n}=te(),r=_e(e=>[e.shapes,t],(e,t)=>!t||Bn(e).some(e=>e.slideOrder!==void 0)),i=U(e=>e.viewMode),a=U(e=>e.rightPanel),o=a===`ai`,s=a===`slides`,c=a===`code`,l=U(e=>e.rightPanel===`flow`),u=_e(e=>[e.shapes,e.viewMode,t],(e,t,n)=>Bn(e).some(e=>(e.flows?.length??0)>0)||!t&&!n&&Bn(e).length>0),d=U(e=>e.animateSlideId!==null),f=re(),p=f?.threads,m=_e(e=>[e.shapes,p],(e,t)=>t?.some(t=>tj(t,e))??!1),h=U(e=>e.commentsVisible),{setAiOpen:g,setSlidesOpen:_,setCodeOpen:v,setFlowsOpen:y,setCommentsVisible:b}=W().getState(),x=Al(a),C=t&&!e&&!r,w=n!=null;return d&&!w?null:C?(0,Q.jsxs)(`div`,{className:`absolute top-[var(--chrome-top)] flex flex-row-reverse items-start gap-2`,style:{right:x},"data-overlay":!0,onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),children:[(0,Q.jsxs)(`a`,{href:`https://koboyo.com`,"aria-label":`Made with Koboyo`,"data-testid":`share-made-with`,className:`flex h-8 items-center gap-1.5 rounded-xl px-2.5 text-[12px] text-[var(--chrome-fg-500)] outline-none transition-colors hover:text-[var(--chrome-fg-900)] ${dl}`,children:[(0,Q.jsx)(IA,{size:14}),`Made with Koboyo`]}),w&&(0,Q.jsx)(wA,{})]}):(0,Q.jsxs)(`div`,{className:`absolute top-[var(--chrome-top)] flex flex-row-reverse items-start gap-2`,style:{right:x},"data-overlay":!0,"data-testid":`right-rail`,onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),children:[!d&&(0,Q.jsxs)(`div`,{className:`${ll} flex flex-col`,children:[e&&!i&&(0,Q.jsx)(S,{label:`AI assistant`,side:`left`,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":`AI assistant`,"data-testid":`ai-open`,onClick:()=>g(!o),onPointerEnter:()=>eo(e),onFocus:()=>eo(e),className:pl(o),children:(0,Q.jsx)(Sc,{size:17,stroke:1.75})})}),r&&(0,Q.jsx)(S,{label:`Slides`,side:`left`,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Slides`,"data-testid":`slides-open`,onClick:()=>_(!s),onPointerEnter:()=>eo(Wy),onFocus:()=>eo(Wy),className:pl(s),children:(0,Q.jsx)(Js,{size:17,stroke:1.75})})}),u&&(0,Q.jsx)(S,{label:`Flows`,side:`left`,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Flows`,"data-testid":`flows-open`,onClick:()=>y(!l),onPointerEnter:()=>eo(Ky),onFocus:()=>eo(Ky),className:pl(l),children:(0,Q.jsx)(yc,{size:17,stroke:1.75})})}),!t&&!i&&(0,Q.jsx)(S,{label:`Diagram as code`,side:`left`,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Diagram as code`,"data-testid":`code-open`,onClick:()=>v(!c),onPointerEnter:()=>eo(Gy),onFocus:()=>eo(Gy),className:pl(c),children:(0,Q.jsx)(ec,{size:17,stroke:1.75})})}),f&&m&&(0,Q.jsx)(S,{label:h?`Hide comments`:`Show comments`,side:`left`,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":h?`Hide comments`:`Show comments`,"aria-pressed":!h,"data-testid":`comments-toggle`,onClick:()=>b(!h),className:pl(!h),children:h?(0,Q.jsx)(ks,{size:17,stroke:1.75}):(0,Q.jsx)(Ap,{size:17,stroke:1.75})})}),(0,Q.jsx)(rj,{})]}),w&&(0,Q.jsx)(wA,{beside:`panel`})]})}var aj=(0,J.memo)(ij),oj=[{title:`Tools`,shortcuts:[{keys:`/`,label:`Search all tools`},...Object.entries(Es).map(([e,t])=>({keys:Ns(e),label:`help`in t?t.help:t.label})),{keys:Qp(`toolLock`),label:`Keep tool active (lock)`}]},{title:`Edit`,shortcuts:[{keys:`⌘C`,label:`Copy`},{keys:`⌘X`,label:`Cut`},{keys:`⌘V`,label:`Paste`},{keys:`⌘⇧V`,label:`Paste as plain text`},{keys:`⌘D`,label:`Duplicate`},{keys:`⌘A`,label:`Select all`},{keys:`⌫`,label:`Delete`},{keys:`⌘Z`,label:`Undo`},{keys:`⌘⇧Z / ⌘Y`,label:`Redo`},{keys:`⌘G`,label:`Group`},{keys:`⌘⇧G`,label:`Ungroup`},{keys:`⌘⇧L`,label:`Lock / unlock`},{keys:`⌘⇧C`,label:`Copy as PNG`},{keys:`⌘B`,label:`Bold text`},{keys:`⌘I`,label:`Italic text`},{keys:`⌘U`,label:`Underline text`},{keys:`⌘⇧X`,label:`Strikethrough text`},{keys:`⇧I`,label:`Pick colour (eyedropper)`},{keys:`⏎`,label:`Edit selected shape`},{keys:`Tab`,label:`Add connected shape`},{keys:`⇧Tab`,label:`Add connected shape below`}]},{title:`Arrange`,shortcuts:[{keys:`⌘]`,label:`Bring forward`},{keys:`⌘[`,label:`Send backward`},{keys:`⌘⌥]`,label:`Bring to front`},{keys:`⌘⌥[`,label:`Send to back`},{keys:`⌘⌥C`,label:`Copy styles`},{keys:`⌘⌥V`,label:`Paste styles`},{keys:`⇧H`,label:`Flip horizontal`},{keys:`⇧V`,label:`Flip vertical`}]},{title:`Align (2+ selected)`,shortcuts:[{keys:`⌥L`,label:`Align left`},{keys:`⌥C`,label:`Align centre`},{keys:`⌥R`,label:`Align right`},{keys:`⌥T`,label:`Align top`},{keys:`⌥M`,label:`Align middle`},{keys:`⌥B`,label:`Align bottom`},{keys:`⌥U`,label:`Tidy up layout`}]},{title:`Move & view`,shortcuts:[{keys:`← ↑ ↓ →`,label:`Nudge 1px`},{keys:`⇧ Arrows`,label:`Nudge 10px`},{keys:`⌘⇧ Arrows`,label:`Nudge 100px`},{keys:`⌘=`,label:`Zoom in`},{keys:`⌘-`,label:`Zoom out`},{keys:`⌘0`,label:`Reset zoom`},{keys:`⌘1`,label:`Zoom to fit`},{keys:`⌘F`,label:`Find on canvas`},{keys:`⌘K`,label:`Command palette`},{keys:`⌥Z`,label:`Zen mode (hide the chrome)`},{keys:`Right-drag`,label:`Pan the canvas`},{keys:`?`,label:`Keyboard shortcuts (this dialog)`}]},{title:`Panels`,shortcuts:[{keys:`⌥A`,label:`AI assistant`},{keys:`⌥S`,label:`Slides`},{keys:`⌥D`,label:`Diagram as code`}]},{title:`File`,shortcuts:[{keys:`⌘S`,label:`Save now (it already saves itself)`},{keys:`⌘O`,label:`Open / import a board file`},{keys:`⌘P`,label:`Print: export slides as PDF, or the board as an image`}]},{title:`Slides`,shortcuts:[{keys:`⌘⌥P`,label:`Present from current slide`},{keys:`⇧⌘⌥P`,label:`Present from beginning`},...Qa.map(e=>({keys:e.help,label:e.label}))]},{title:`Text (while editing)`,shortcuts:[{keys:`⌘B`,label:`Bold`},{keys:`⌘I`,label:`Italic`},{keys:`⌘U`,label:`Underline`},{keys:`⌘⇧X`,label:`Strikethrough`},{keys:`⌘E`,label:`Code`},{keys:`⌘⇧H`,label:`Highlight`},{keys:`⌘K`,label:`Link (at the caret: insert one)`},{keys:`URL + space`,label:`Link a typed URL`},{keys:`- / *`,label:`Bullet list`},{keys:`1.`,label:`Numbered list`},{keys:`[]`,label:`Checklist`},{keys:`# … ####`,label:`Heading (4 levels)`},{keys:`**text**`,label:`Bold (markdown)`},{keys:`*text*`,label:`Italic (markdown)`},{keys:"`text`",label:`Code (markdown)`},{keys:`==text==`,label:`Highlight (markdown)`},{keys:`~~text~~`,label:`Strikethrough (markdown)`},{keys:`⏎`,label:`New line`},{keys:`⌘Z`,label:`Undo typing`},{keys:`Tab / ⇧Tab`,label:`Indent / outdent a list item`},{keys:`Tab`,label:`Next connected shape (on a node's label)`},{keys:`⇧Tab`,label:`Next connected shape below`},{keys:`Esc`,label:`Done editing`}]}];function sj(){let[e,t]=(0,J.useState)(!1),[n,r]=(0,J.useState)(``),i=(0,J.useRef)(null),a=Al(U(e=>e.rightPanel));(0,J.useEffect)(()=>{function e(e){e.key===`?`&&!us(e.target)&&(e.preventDefault(),t(!0))}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let o=n.trim().toLowerCase(),s=(0,J.useMemo)(()=>o?oj.map(e=>({title:e.title,shortcuts:e.shortcuts.filter(t=>`${t.label} ${t.keys} ${e.title}`.toLowerCase().includes(o))})).filter(e=>e.shortcuts.length>0):oj,[o]);function c(e){t(e),e||r(``)}return(0,Q.jsxs)(yl,{open:e,onOpenChange:c,children:[(0,Q.jsx)(S,{label:`Keyboard shortcuts`,shortcut:`?`,side:`left`,children:(0,Q.jsx)(Bb,{render:(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Keyboard shortcuts`,style:{right:a},className:`absolute bottom-4 flex h-8 w-8 items-center justify-center rounded-xl text-[var(--chrome-fg-500)] transition-colors hover:text-[var(--chrome-fg-900)] ${dl}`,children:(0,Q.jsx)(ao,{size:16,stroke:1.75})})})}),(0,Q.jsxs)(gl,{children:[(0,Q.jsx)(hl,{className:`fixed inset-0 bg-gray-900/15`}),(0,Q.jsxs)(vl,{initialFocus:i,"data-overlay":!0,className:`fixed left-1/2 top-[12vh] flex max-h-[76vh] min-h-[340px] w-[min(720px,92vw)] -translate-x-1/2 flex-col overflow-hidden rounded-2xl bg-[var(--chrome-popup)] shadow-[0_24px_70px_rgba(0,0,0,0.22)] outline-none ring-1 ring-[var(--chrome-ring)]`,children:[(0,Q.jsx)(xl,{className:`sr-only`,children:`Keyboard shortcuts`}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-[var(--chrome-ring)] px-4 py-2.5`,children:[(0,Q.jsx)(xc,{size:16,stroke:1.75,className:`shrink-0 text-[var(--chrome-fg-400)]`}),(0,Q.jsx)(`input`,{ref:i,value:n,onChange:e=>r(e.target.value),placeholder:`Search shortcuts…`,"aria-label":`Search shortcuts`,className:`w-full bg-transparent text-[13.5px] text-[var(--chrome-fg-900)] outline-none placeholder:text-[var(--chrome-fg-400)]`}),(0,Q.jsx)(bl,{"aria-label":`Close`,className:`-mr-1 flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-[var(--chrome-fg-400)] outline-none transition-colors hover:bg-[var(--chrome-divider)] hover:text-[var(--chrome-fg-600)]`,children:(0,Q.jsx)(Cc,{size:16,stroke:1.75})})]}),(0,Q.jsx)(`div`,{className:`scrollbar-slim flex-1 overflow-y-auto`,children:s.length===0?(0,Q.jsxs)(`div`,{className:`px-5 py-14 text-center text-[13px] text-[var(--chrome-fg-400)]`,children:[`No shortcuts match “`,n.trim(),`”`]}):(0,Q.jsx)(`div`,{className:`columns-1 gap-x-10 px-5 py-5 sm:columns-2`,children:s.map(e=>(0,Q.jsxs)(`section`,{className:`mb-6 break-inside-avoid`,children:[(0,Q.jsx)(`h3`,{className:`mb-3 text-[11px] uppercase tracking-wider text-[var(--chrome-fg-400)]`,children:e.title}),(0,Q.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:e.shortcuts.map(e=>(0,Q.jsxs)(`li`,{className:`flex items-center justify-between gap-6 text-[13px]`,children:[(0,Q.jsx)(`span`,{className:`text-[var(--chrome-fg-600)]`,children:e.label}),(0,Q.jsx)(`span`,{className:`flex shrink-0 items-center gap-1`,children:zc(e.keys).split(` `).map((e,t)=>e===`/`?(0,Q.jsx)(`span`,{className:`text-[11px] text-[var(--chrome-fg-400)]`,children:`/`},t):(0,Q.jsx)(`kbd`,{className:`rounded-md bg-[var(--chrome-hover)] px-2 py-1 text-center text-[11px] leading-none tabular-nums text-[var(--chrome-fg-500)] ring-1 ring-[var(--chrome-ring)]`,children:e},t))})]},e.label))})]},e.title))})})]})]})]})}var cj=(0,J.memo)(sj);function lj(e){let{width:t,ariaLabel:n,onDismiss:r}=e;return(0,Q.jsx)(jl,{width:t,testId:`panel-loading`,ariaLabel:n,onDismiss:r,children:(0,Q.jsx)(`div`,{"aria-busy":`true`,className:`flex h-full items-center justify-center text-[12px] text-[var(--chrome-fg-400)]`,children:`Loading…`})})}function uj(e){let{containerRef:t,mainMenuRef:n,loadDocument:r,tools:i,panel:a,styles:o,deleteSelection:s,alignSelection:c,distributeSelection:l,reorderSelection:u,duplicateSelection:d,pasteEmbed:f,zoomToFit:p,backToContent:m,paletteCommands:h}=e;xy(`CanvasChrome`);let g=W(),_=te().assistant,v=te(),y=v.readOnly===!0,b=y&&v.readOnlyPill===!1,x=te().publicShare===!0,S=re()!==null,C=U(e=>e.tool),w=U(e=>e.shapeKind),T=U(e=>e.chartKind),E=U(e=>e.frameKind),D=U(e=>e.toolLock),O=U(e=>e.iconPickerOpen),k=U(e=>e.imageLibraryOpen),A=U(e=>e.setImageLibraryOpen),j=U(e=>e.toolDrawerOpen),M=U(e=>e.paletteOpen),N=U(e=>e.rightPanel===`slides`),P=U(e=>e.animateSlideId!==null),F=U(e=>e.rightPanel===`ai`),I=U(e=>e.rightPanel===`code`),L=U(e=>e.rightPanel===`flow`),ee=U(e=>e.notesEditorId!==null),R=U(e=>e.exportDialog),z=U(e=>e.imageToCopy),B=U(e=>e.webEmbedDialog!==null),V=U(e=>e.webHtmlEditorId!==null),ne=U(e=>e.rideMode),ie=U(e=>e.zenMode)||ne,ae=U(e=>e.viewMode),oe=U(e=>e.presentingIndex!==null),se=_e(e=>[e.shapes,x],(e,t)=>!!t&&Bn(e).some(e=>e.slideOrder!==void 0&&!e.slideSkipped));(0,J.useEffect)(()=>{N&&(eo(Yy),eo(sb))},[N]);let ce=U(e=>e.deviceMode===`phone`),{setShapeKind:le,setChartKind:ue,setFrameKind:de,setToolLock:fe,setIconPickerOpen:H,setToolDrawerOpen:pe,setPaletteOpen:me,setExportDialog:he,setImageToCopy:ge,setSlidesOpen:ve,setAiOpen:ye,setCodeOpen:be,setZenMode:xe,setViewMode:Se,setPresentingIndex:Ce,zoomIn:we,zoomOut:Te,resetZoom:Ee}=g.getState(),De=(0,J.useCallback)(()=>fe(e=>!e),[fe]);return(0,Q.jsxs)(Q.Fragment,{children:[!oe&&!ie&&(0,Q.jsxs)(Q.Fragment,{children:[!x&&(0,Q.jsx)(Bk,{ref:n,onLoadDocument:r}),(0,Q.jsx)(xA,{}),!ae&&!P&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(GA,{}),(0,Q.jsx)(yk,{tool:C,shapeKind:w,chartKind:T,frameKind:E,onToolChange:i.selectTool,onShapeKind:le,onChartKind:ue,onFrameKind:de,onInsertControl:i.insertControl,commentsAvailable:S,toolLock:D,onToggleToolLock:De})]})]}),(0,Q.jsx)(no,{active:O,feature:eb,children:e=>(0,Q.jsx)(e,{onPick:i.placeIcon,onClose:()=>H(!1)})}),(0,Q.jsx)(no,{active:k,feature:nb,children:e=>(0,Q.jsx)(e,{open:!0,onOpenChange:e=>A(e),onPick:i.placeIcon})}),(0,Q.jsx)(no,{active:j&&!oe,feature:rb,children:e=>(0,Q.jsx)(e,{onPick:i.runTool,onClose:()=>pe(!1)})}),a.showPanel&&!oe&&!ie&&!ae&&(0,Q.jsx)(ZO,{onDelete:s,onDuplicate:d,style:a.displayStyle,kinds:a.panelKinds,iconsInk:a.iconsInk,iconLabeled:a.iconLabeled,selectionCount:a.selectionCount,shapeKind:a.rectangleKind??w,chart:a.chart,control:a.control,figure:a.figure,web:a.web,icon:a.icon,badge:a.hasBadgeSlot?a.badge??null:void 0,link:a.link,onLink:o.changeLink,textSizing:a.textSizingMode,onChange:o.changeStyle,onChartPatch:o.changeChart,onControlPatch:o.changeControl,onFigurePatch:o.changeFigure,onTextSizing:o.changeTextSizing,onShapeKind:o.changeShapeKind,onPickIcon:o.pickIcon,onBadgePatch:o.patchBadge,onAlign:c,onDistribute:l,onReorder:u}),!oe&&(0,Q.jsxs)(Q.Fragment,{children:[!ie&&!ce&&(0,Q.jsxs)(`div`,{className:`absolute bottom-4 left-4 flex items-center gap-2`,"data-overlay":!0,children:[(0,Q.jsx)(kA,{containerRef:t,onZoomIn:we,onZoomOut:Te,onReset:Ee,onZoomToFit:p}),!ae&&(0,Q.jsx)(qA,{})]}),se&&!ie&&(0,Q.jsx)(`div`,{className:`absolute bottom-4 left-1/2 -translate-x-1/2`,"data-overlay":!0,children:(0,Q.jsxs)(`button`,{type:`button`,"data-testid":`share-present`,"aria-label":`Present this deck`,title:`Play the deck full-screen`,onClick:()=>Ce(0),onPointerEnter:()=>eo(Yy),onFocus:()=>eo(Yy),onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),className:`pointer-events-auto flex h-9 cursor-pointer items-center gap-2 rounded-xl px-4 text-[13px] text-[var(--chrome-fg-800)] transition-colors hover:text-[var(--chrome-fg-900)] ${dl}`,children:[(0,Q.jsx)(wc,{size:13}),`Present`]})}),(0,Q.jsxs)(to,{children:[(0,Q.jsx)(ej,{containerRef:t}),ie&&!ne&&(0,Q.jsxs)(`button`,{type:`button`,"data-testid":`zen-exit`,"data-overlay":!0,title:`Exit zen mode (${zc(Qp(`zen`))})`,onClick:()=>xe(!1),onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),className:`pointer-events-auto flex h-8 cursor-pointer items-center gap-1.5 rounded-xl px-3 text-[12px] text-[var(--chrome-fg-600)] transition-colors hover:text-[var(--chrome-fg-900)] ${dl}`,children:[(0,Q.jsx)(Na,{size:14,stroke:1.75}),`Exit zen`]}),ae&&!ie&&!b&&(0,Q.jsxs)(`div`,{"data-testid":`view-mode-pill`,"data-overlay":!0,onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),className:`pointer-events-auto flex h-8 items-center gap-2 rounded-xl text-[12px] text-[var(--chrome-fg-600)] ${y?`px-3`:`pl-3 pr-1`} ${dl}`,children:[(0,Q.jsx)(ba,{size:14,stroke:1.75}),`View only`,!y&&(0,Q.jsx)(`button`,{type:`button`,"data-testid":`view-mode-exit`,"aria-label":`Exit view mode`,onClick:()=>Se(!1),className:`flex h-6 cursor-pointer items-center rounded-lg px-2 text-[var(--chrome-fg-500)] transition-colors hover:bg-[var(--chrome-hover)] hover:text-[var(--chrome-fg-900)]`,children:`Exit`})]}),!ie&&(0,Q.jsx)(DA,{containerRef:t,onBackToContent:m})]}),!ie&&(ce?(0,Q.jsx)(TA,{onZoomToFit:p}):(0,Q.jsx)(aj,{})),(0,Q.jsx)(no,{active:M,retain:!0,feature:ob,children:e=>(0,Q.jsx)(e,{open:M,onOpenChange:me,commands:h})}),!ie&&(0,Q.jsx)(no,{active:N,feature:Wy,fallback:(0,Q.jsx)(lj,{width:272,ariaLabel:`Slides`,onDismiss:()=>ve(!1)}),children:e=>(0,Q.jsx)(e,{containerRef:t})}),!ie&&(0,Q.jsx)(no,{active:L,feature:Ky,children:e=>(0,Q.jsx)(e,{})}),(0,Q.jsx)(no,{active:ee,retain:!0,feature:Qy,children:e=>(0,Q.jsx)(e,{})}),(0,Q.jsx)(no,{active:B,retain:!0,feature:Xy,children:e=>(0,Q.jsx)(e,{onInsert:f})}),(0,Q.jsx)(no,{active:V,retain:!0,feature:Zy,children:e=>(0,Q.jsx)(e,{})}),(0,Q.jsx)(no,{active:R!==null,feature:ib,children:e=>R&&(0,Q.jsx)(e,{request:R,onClose:()=>he(null)})}),(0,Q.jsx)(no,{active:z!==null,feature:ab,children:e=>z&&(0,Q.jsx)(e,{image:z,onClose:()=>ge(null)})}),!ie&&(0,Q.jsx)(no,{active:I,retain:!0,feature:Gy,fallback:(0,Q.jsx)(lj,{width:360,ariaLabel:`Diagram code`,onDismiss:()=>be(!1)}),children:e=>(0,Q.jsx)(e,{containerRef:t})}),!ie&&!ce&&(0,Q.jsx)(jA,{}),!ie&&!ce&&(0,Q.jsx)(cj,{})]}),_&&(0,Q.jsx)(no,{active:F,retain:!0,feature:_,fallback:ie||oe?null:(0,Q.jsx)(lj,{width:340,ariaLabel:`AI assistant`,onDismiss:()=>ye(!1)}),children:e=>(0,Q.jsx)(e,{containerRef:t,hidden:ie||oe||ae})}),(0,Q.jsx)(pj,{loadDocument:r}),(0,Q.jsx)(no,{active:oe,retain:!0,feature:Yy,children:e=>(0,Q.jsx)(e,{containerRef:t})})]})}var dj=(0,J.memo)(uj),fj=160;function pj(e){let{loadDocument:t}=e,n=W(),{measurement:r}=H(),i=U(e=>e.pendingBoard),{notify:a}=_();function o(){let e=n.getState().pendingBoard;n.getState().setPendingBoard(null),e&&t(e)===`loaded`&&a(Dk(e))}function s(){let e=n.getState().pendingBoard;if(n.getState().setPendingBoard(null),!e||e.shapes.length===0)return;let t=n.getState(),i=pn(t.shapes,r),o=pn(e.shapes,r),s=i&&o?{x:i.x+i.width+fj-o.x,y:i.y-o.y}:{x:0,y:0},c=Vn(e.shapes,s),l=t.shapes.length;t.addMany(c),n.getState().shapes.length!==l&&(t.setSelectedIds(new Set(c.map(e=>e.id))),a(Ok(e)))}return(0,Q.jsx)(zb,{open:i!==null,onOpenChange:e=>{e||n.getState().setPendingBoard(null)},children:(0,Q.jsxs)(gl,{children:[(0,Q.jsx)(hl,{className:q.dialogBackdrop}),(0,Q.jsxs)(vl,{"data-overlay":!0,"data-testid":`drop-confirm`,className:`w-[min(400px,92vw)] p-5 ${q.dialogPopup}`,children:[(0,Q.jsx)(xl,{className:`text-[15px] text-[var(--chrome-fg-900)]`,children:`Open this file?`}),(0,Q.jsxs)(Sl,{className:`mt-2 text-[13px] leading-relaxed text-[var(--chrome-fg-500)]`,children:[`Replace everything on the canvas with it, or add its content next to what's already here. Either can be undone with `,zc(Qp(`undo`)),`.`]}),(0,Q.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,Q.jsx)(bl,{className:`h-8 rounded-full px-3.5 text-[13px] text-[var(--chrome-fg-600)] outline-none transition-colors hover:bg-[var(--chrome-divider)]`,children:`Cancel`}),(0,Q.jsx)(bl,{"data-testid":`drop-confirm-add`,onClick:s,className:`h-8 rounded-full px-3.5 text-[13px] text-[var(--chrome-fg-900)] outline-none ring-1 ring-[var(--chrome-ring)] transition-colors hover:bg-[var(--chrome-hover)]`,children:`Add next to canvas`}),(0,Q.jsx)(bl,{"data-testid":`drop-confirm-accept`,onClick:o,className:`h-8 rounded-full bg-[var(--chrome-accent)] px-3.5 text-[13px] text-white outline-none transition-colors hover:bg-[var(--chrome-accent-hover)]`,children:`Replace canvas`})]})]})]})})}var mj=2560,hj=.9,gj=3e5;async function _j(e,t,n,r,i){let a=await vj(e,i);if(!a)return null;let o=t?t.width/n.zoom:1e3,s=t?t.height/n.zoom:700,c=Math.min(1,o*.8/a.width,s*.8/a.height),l=a.width*c,u=a.height*c,d=r??(t?nt({x:t.width/2,y:t.height/2},n):{x:0,y:0});return{id:$e(),type:`image`,x:d.x-l/2,y:d.y-u/2,width:l,height:u,rotation:0,src:a.url,crop:{x:0,y:0,width:1,height:1},opacity:1}}async function vj(e,t){if(e.type===`image/svg+xml`){let t=Sd(await e.text().catch(()=>``));if(t)return{url:Cd(t.markup),width:t.width,height:t.height}}return Ud(e,{maxEdge:mj,quality:hj,minBytes:gj,keepPng:`when-transparent`},t)}function yj(e,t,n,r,i={}){let a=G(e),o=Math.min(a.width*.4,a.height*.72)/Math.max(t,n);i.noUpscale&&(o=Math.min(o,1));let s=t*o,c=n*o,l=a.width*.06,u=a.height*.06,d=[{x:a.x+a.width-s-l,y:a.y+(a.height-c)/2},{x:a.x+l,y:a.y+(a.height-c)/2},{x:a.x+(a.width-s)/2,y:a.y+a.height-c-u},{x:a.x+(a.width-s)/2,y:a.y+u},{x:a.x+(a.width-s)/2,y:a.y+(a.height-c)/2}],f=mn(r,e).filter(e=>e.type!==`figure`&&e.type!==`arrow`&&e.type!==`line`&&e.type!==`draw`),p=d.find(e=>!f.some(t=>zr(G(t),{x:e.x,y:e.y,width:s,height:c})))??d[0];return{x:p.x,y:p.y,width:s,height:c}}function bj(e){let{status:t,savedToAccount:n,failed:r}=e;return t===`auth-required`?`Sign in to save. Your work is safe on this device meanwhile.`:t===`conflict`?`Saving is stopped: this canvas changed somewhere else.`:t===`rejected`?`This canvas can't be saved to your account. Your work is safe on this device.`:t===`too-large`?`This canvas is too large to save. Remove images or large shapes.`:t===`storage-error`?`This device's storage is full, so changes aren't kept here.`:r||t===`error`||t===`retrying`?`Not saved yet, still trying. Leave this tab open.`:n?`Saved. This canvas saves itself as you work.`:`Saved on this device. Your sketch saves itself as you work.`}function xj(e){let{containerRef:t}=e,n=W(),r=H(),i=te(),{notify:a}=_(),{addShape:o,loadShapes:s,setViewport:c,fitToBounds:l,setSelectedIds:u,endEdit:d,setLockRevealId:f,setPendingBoard:p}=n.getState(),m=(0,J.useCallback)(()=>{let{shapes:e,selectedIds:t}=n.getState(),i=ha(e,t);return i.length>0?jn(e,i,r.measurement):e},[n,r.measurement]),h=(0,J.useCallback)(e=>{if(n.getState().viewModeLocked)return a(`This canvas is view only.`),`refused`;let i=Oe(e.shapes.length,`open`);if(i?.kind===`block`)return a(i.message),`refused`;if(i?a(i.message):e.skipped>0&&a(Dk(e)),s(e.shapes),e.viewport)c(e.viewport);else{let n=t.current;n&&l(pn(e.shapes,r.measurement),{width:n.clientWidth,height:n.clientHeight})}return u(new Set),d(),i||e.skipped>0?`warned`:`loaded`},[n,t,r.measurement,s,c,l,u,d,a]),g=(0,J.useCallback)((e,r)=>{_j(e,t.current?.getBoundingClientRect()??null,n.getState().viewport,r,i.decodeHeic).then(t=>{if(!t){let t=/\.(\w+)$/.exec(e.name)?.[1]??e.type.split(`/`)[1];a(t?`Unsupported image type (.${t.toLowerCase()})`:`Couldn't read that image`);return}let i=t;if(!r&&t.type===`image`){let e=n.getState(),r=[...e.selectedIds],a=r.length===1?e.shapes.find(e=>e.id===r[0]&&e.type===`figure`):void 0;if(a){let n=yj(a,t.width,t.height,e.shapes,{noUpscale:!0});i={...t,...n}}}o(i),u(new Set([i.id]))})},[t,n,o,u,a,i.decodeHeic]),v=(0,J.useCallback)(e=>{let r=[...e.dataTransfer.files],i=t.current?.getBoundingClientRect(),s=i?nt({x:e.clientX-i.left,y:e.clientY-i.top},n.getState().viewport):null;if(r.length===0){let t=Ko(e.dataTransfer.getData(`text/uri-list`)),r=t?qo(t):null;if(!r||!s||(e.preventDefault(),n.getState().viewMode))return;let i=Jo(r,s);o(i),u(new Set([i.id]));return}if(e.preventDefault(),n.getState().viewMode)return;let c=r.find(e=>/\.(kby|excalidraw|tldr)$/i.test(e.name)||e.type===`application/json`);if(c){jk(c).then(e=>{if(n.getState().shapes.length>0){p(e);return}h(e)===`loaded`&&a(Dk(e))}).catch(e=>{a(e instanceof Error?e.message:`Couldn't open that file`)});return}let l=r.filter(Rd);if(l.length===0){a(`Unsupported file type`);return}l.forEach((e,t)=>{let n=s?{x:s.x+t*24,y:s.y+t*24}:void 0;g(e,n)})},[t,n,g,o,u,h,p,a]),y=(0,J.useCallback)(e=>{let t=e.dataTransfer.types;(t.includes(`Files`)||t.includes(`text/uri-list`))&&e.preventDefault()},[]),b=(0,J.useRef)(i.saveStatus);b.current=i.saveStatus;let x=i.onSaveNow,S=i.canvasMeta!=null,C=(0,J.useCallback)(async()=>{if(!x)return;let e=!1;try{await x()}catch{e=!0}a(bj({status:b.current,savedToAccount:S,failed:e}))},[x,S,a]),w=(0,J.useCallback)(()=>{s([]),u(new Set),d(),f(null)},[s,u,d,f]);return(0,J.useMemo)(()=>({exportTargets:m,loadDocument:h,addImageFromFile:g,onCanvasDrop:v,onCanvasDragOver:y,clearCanvas:w,saveNow:C}),[m,h,g,v,y,w,C])}function Sj(e,t,n,r,i){let a=new Map(t.map(e=>[e.id,e])),o=new Map(n.map(e=>[e.id,e]));for(let t of n){let n=a.get(t.id);if(t.type!==`figure`||n?.type!==`figure`)continue;let s={x:t.x-n.x,y:t.y-n.y};if(!(s.x===0&&s.y===0))for(let t of zm(e,[n],{activeGroupId:r,measurement:i}))o.has(t.id)||o.set(t.id,Yt(t,s))}return[...o.values()]}function Cj(e){let{replaceMany:t,removeShapes:n,setSelectedIds:r,setTool:i,setLockRevealId:a,bringToFront:o,bringForward:s,sendBackward:c,sendToBack:l}=e,u=W(),d=H().measurement,f=(0,J.useCallback)((e,n)=>{let{shapes:r,selectedIds:i,activeGroupId:a}=u.getState(),o=Dt(r,i);if(o.length===0)return;let s=zm(r,o,{activeGroupId:a,measurement:d}),c=new Set(s.map(e=>e.id)),l={x:e,y:n};t(s.map(e=>Pe(e,l,r,c,d)),Ve(s))},[u,t,d]),p=(0,J.useCallback)(e=>{let n=u.getState(),r=ha(n.shapes,n.selectedIds);t(Sj(n.shapes,r,$l(r,e,d),n.activeGroupId,d))},[u,t,d]),m=(0,J.useCallback)(e=>{let n=u.getState(),r=ha(n.shapes,n.selectedIds);t(Sj(n.shapes,r,eu(r,e,d),n.activeGroupId,d))},[u,t,d]),h=(0,J.useCallback)(e=>{let{selectedIds:t}=u.getState();if(t.size===0)return;let n={front:o,forward:s,backward:c,back:l}[e];n(t)},[u,o,s,c,l]),g=(0,J.useCallback)(()=>{let e=u.getState(),t=e.shapes.filter(t=>e.selectedIds.has(t.id)&&!t.locked);t.length!==0&&(n(new Set(t.map(e=>e.id))),r(new Set))},[u,n,r]),_=(0,J.useCallback)(e=>{let{shapes:n,selectedIds:r,activeGroupId:i}=u.getState(),a=ha(n,r);if(a.length===0)return;let o=zm(n,a,{activeGroupId:i,measurement:d});t(Qt(o,e))},[u,t,d]),v=(0,J.useCallback)(()=>{i(`select`);let{shapes:e}=u.getState();r(new Set(e.filter(e=>!e.locked).map(e=>e.id))),a(null)},[u,i,r,a]);return(0,J.useMemo)(()=>({nudgeSelection:f,alignSelection:p,distributeSelection:m,reorderSelection:h,deleteSelection:g,flipSelection:_,selectAll:v}),[f,p,m,h,g,_,v])}var wj=[];function Tj(e){let{recentDrillRef:t,interactive:n}=e,r=W(),{history:i}=H(),a=_e(e=>[e.shapes,e.selectedIds],(e,t)=>t.size===0?wj:Dt(e,t),we),o=U(e=>be(e.editSession)),s=U(e=>me(e.editSession)),c=U(e=>e.activeGroupId),l=U(e=>e.viewMode),u=lg(),{addShape:d,replaceShape:f,replaceMany:p,updateShape:m,removeShape:h,removeShapes:g,bringToFront:_,sendToBack:v,bringForward:y,sendBackward:b,setTool:x,setSelectedIds:S,beginTextEdit:C,beginTableCellEdit:w,beginChartDataEdit:T,beginCrop:E,beginVertexEdit:D,beginInteract:O,endEdit:k,setHoveredId:A,setActiveGroupId:j,setLockRevealId:M}=r.getState(),N=_e(e=>[e.shapes,e.lockRevealId],wu,we),P=_e(e=>[e.shapes,e.hoveredId],(e,t)=>t?!!Qe(e,t)?.locked:!1),F=!s&&a.length===1&&a[0].id===o,I=n&&a.length>0&&!F&&!l,L=nm(a,c),ee=(0,J.useCallback)((e,n=`label`)=>{if(t.current===e){t.current=null;return}let a=r.getState();if(a.viewMode)return;let o=Qe(a.shapes,e);if(o?.locked){M(o.id),S(new Set);return}if(o?.groupId&&o.groupId!==a.activeGroupId){j(o.groupId),S(new Set);return}if(S(new Set([e])),o?.type===`web`){let t=gg(o,u);if(!t)return;t.kind===`embed`&&t.embed.video&&a.startWeb(e),O(e);return}if(o?.type===`chart`){T(e);return}if(o?.type===`rectangle`){let t=Tn(o);t<o.fontSize&&i.runWithoutHistory(()=>m(e,{fontSize:t}))}C(e,n)},[t,r,i,m,M,S,j,T,C,O,u]),R=(0,J.useCallback)((e,t,n)=>{r.getState().viewMode||(S(new Set([e])),w(e,t,n))},[r,S,w]),z=(0,J.useCallback)(e=>{r.getState().viewMode||(S(new Set([e])),E(e))},[r,S,E]),B=(0,J.useCallback)(e=>{r.getState().viewMode||(S(new Set([e])),D(e))},[r,S,D]),V=(0,J.useCallback)((e,t,n=`label`)=>{let a=rt(t),o=a?jt(t):t.trim().length===0,s=o?``:a?t:t.trim(),c=o?``:a?t:t.replace(/\n$/,``),l=Qe(r.getState().shapes,e),u=t=>{let n=l;Object.entries(t).some(([e,t])=>(n?.[e]??``)!==t)&&m(e,t)};if(l?.type===`control`){u({[PC(l,n)??`label`]:s}),k(e);return}let f=l?wn[l.type].textField:null;if(f===`label`){u({label:s}),k(e);return}if(f===`text`){u({text:s}),k(e);return}if(!l||l.type!==`text`){k(e);return}let p=l.text===``;if(o){p?i.runWithoutHistory(()=>h(e)):h(e),S(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n}),k(e);return}p?(i.runWithoutHistory(()=>h(e)),d({...l,text:c})):l.text!==c&&m(e,{text:c}),S(new Set([e])),k(e)},[r,i,d,h,m,S,k]),te=(0,J.useCallback)(()=>{let{shapes:e,selectedIds:t,activeGroupId:n}=r.getState(),i=e.filter(e=>t.has(e.id)),a=i[0]?.groupId;if(a&&nm(i,n)){j(a),S(new Set);return}if(i.length!==1)return;let o=i[0],s=wn[o.type].edit;if(s===`crop`){z(o.id);return}if(s===`vertices`){B(o.id);return}if(s===`interact`){ee(o.id);return}if(o.type===`table`){R(o.id,0,0);return}o.type!==`draw`&&ee(o.id)},[r,ee,R,z,B,S,j]),ne=(0,J.useCallback)(e=>{let t=Qe(r.getState().shapes,e);if(!(!t||t.type!==`arrow`)){if(t.bendStyle===`elbow`){f({...t,elbowMid:void 0,elbowPoints:void 0,elbowRoute:void 0,elbowMidHandle:void 0});return}f({...t,bend:0,bendAlong:0,bow:0,bowAlong:0})}},[r,f]),re=(0,J.useCallback)(e=>A(e),[A]),ie=Cj({replaceMany:p,removeShapes:g,setSelectedIds:S,setTool:x,setLockRevealId:M,bringToFront:_,bringForward:y,sendBackward:b,sendToBack:v});return(0,J.useMemo)(()=>({selectedShapes:a,revealedUnit:N,hoveringLocked:P,showSelection:I,selectionIsGroup:L,beginEdit:ee,beginEditCell:R,beginCrop:z,beginVertexEdit:B,commitText:V,editSelection:te,resetArrowBend:ne,onHover:re,...ie}),[a,N,P,I,L,ee,R,z,B,V,te,ne,re,ie])}function Ej(e,t){return e===void 0||t===void 0?e===t:Fv(e,t)}function Dj(e){let{selectedShapes:t}=e,n=U(e=>e.editSession),r=U(e=>e.tool),i=U(e=>e.style),a=r===`line`?`arrow`:r===`polyline`?`line`:r===`highlight`?`draw`:r,o=Nv(new Set(t.length>0?t.map(e=>e.type):a===`rectangle`||a===`arrow`||a===`text`||a===`draw`||a===`line`||a===`polygon`||a===`sticky`?[a]:[]),Pv),s=o.size>0,c=n.kind===`chart-data`?t.find(e=>e.type===`chart`&&e.id===n.shapeId):void 0,l=t.every(e=>e.type!==`icon`||!Gi(e.source)||Wi(e.source)),u=t.some(e=>e.type===`icon`&&e.label.trim().length>0),d=t[0],f=t.find(e=>e.type===`text`),p=Nv(uh(d,i),Fv),m=t.find(e=>e.type===`icon`),h=d?.type===`rectangle`?d.kind:void 0,g=Nv(d?.type===`rectangle`?d.titleIcon??void 0:void 0,Ej),_=d?.type===`rectangle`,v=(d?.type===`rectangle`||d?.type===`control`)&&t.length===1?d.link??``:void 0,y=f?.type===`text`?un(f):void 0,b=Nv(m?.type===`icon`?{name:m.name,source:m.source}:void 0,Ej),x=t.length,S=d?.type===`chart`?d:void 0,C=d?.type===`control`?d:void 0,w=d?.type===`figure`?d:void 0,T=d?.type===`web`&&t.length===1?d:void 0,E=qc(T?Jc(T):null,!0),D=E?.status===`ready`?E.html:null,O=(0,J.useMemo)(()=>D===null?null:Ae(D),[D]),k=Nv(T?{id:T.id,kind:T.kind,url:T.url,keepAspect:T.keepAspect===!0,htmlBytes:O}:void 0,Ej);return(0,J.useMemo)(()=>({panelKinds:o,showPanel:s,displayStyle:p,iconsInk:l,iconLabeled:u,selectionCount:x,rectangleKind:h,hasBadgeSlot:_,badge:g,link:v,textSizingMode:y,icon:b,chart:S,control:C,figure:w,web:k,editingChart:c}),[o,s,p,l,u,x,h,_,g,v,y,b,S,C,w,k,c])}function Oj(e){let{containerRef:t,fileInputRef:n}=e,r=W(),{notify:i}=_(),a=U(e=>e.tool),o=U(e=>e.pendingIcon),s=U(e=>e.pendingControl),{askAi:c,setTool:l,setSelectedIds:u,endEdit:d,setStyle:f,setShapeKind:p,setChartKind:m,setFrameKind:h,setPendingIcon:g,setPendingControl:v,setIconPickerOpen:y,setCommentsVisible:b,setLockRevealId:x,setPresentingIndex:S,setShowGrid:C,setSnapEnabled:w,setPresentationAnimation:T,setShowZoomIndicator:E,setWebEmbedDialog:D}=r.getState(),O=(0,J.useCallback)(e=>{l(`select`),g(null),v(e)},[l,g,v]),k=(0,J.useCallback)(e=>{if(g(null),v(null),x(null),f(()=>{let t={...Zr};return(e===`line`||e===`polyline`||e===`polygon`)&&(t.startArrow=!1,t.endArrow=!1),e===`sticky`&&(t.fill=Bi),e===`highlight`&&(t.color=Yr,t.opacity=oi,t.strokeWidth=ri),t}),e===`image`){l(`select`),n.current?.click();return}if(e===`icon`){l(`select`),y(!0);return}l(e),e===`comment`&&b(!0),(kj.has(e)||e===`eraser`||e===`laser`)&&(u(new Set),d())},[n,g,v,x,f,l,y,b,u,d]),A=(0,J.useCallback)(e=>{Ms(e,{selectTool:k,setShapeKind:p,setChartKind:m,setFrameKind:h,insertControl:O,askAi:c,openWebEmbed:()=>{l(`select`),D({mode:`insert`})}})},[k,p,m,h,O,c,l,D]),j=(0,J.useCallback)((e,t)=>{y(!1),$c(t,e,g)},[g,y]),M=(0,J.useCallback)((e=`current`)=>{let n=r.getState(),a=In(n.shapes);if(a.length===0){i(`No slides to present. Draw a frame first`);return}if(a.every(e=>e.slideSkipped)){i(`Every slide is skipped. Unskip one to present`);return}if(e===`beginning`){S(0);return}let o=t.current,s={width:o?.clientWidth??0,height:o?.clientHeight??0};S(Math.max(0,lr(a,n.viewport,s)))},[r,t,S,i]),N=(0,J.useCallback)(()=>{C(e=>!e)},[C]),P=(0,J.useCallback)(()=>{w(e=>!e)},[w]),F=(0,J.useCallback)(()=>{T(e=>!e)},[T]),I=(0,J.useCallback)(()=>{E(e=>!e)},[E]);return(0,J.useMemo)(()=>({tool:a,pendingIcon:o,pendingControl:s,insertControl:O,selectTool:k,runTool:A,placeIcon:j,startPresentation:M,toggleGrid:N,toggleSnap:P,togglePresentationAnimation:F,toggleShowZoomIndicator:I}),[a,o,s,O,k,A,j,M,N,P,F,I])}var kj=new Set([`rectangle`,`arrow`,`line`,`polyline`,`polygon`,`text`,`draw`,`highlight`]);function Aj(e){let{hasInitialViewport:t,onDocumentChange:n,onViewportChange:r,onPreferencesChange:i}=e,{ai:a}=te(),o=Kc(),s=W(),c=H(),l=(0,J.useRef)(null),u=(0,J.useRef)(null),d=(0,J.useRef)(null),f=(0,J.useRef)(!1),p=(0,J.useRef)(null),m=tg();Lu();let h=Ta(`frame`),g=U(e=>e.embedSignInOpen),_=U(e=>e.setEmbedSignInOpen);(0,J.useEffect)(()=>{let e=c.measurementRoot;return e.current=l.current,()=>{e.current=null}},[c]),(0,J.useEffect)(()=>{let e=c.editEntry;function t(t){t.target instanceof Node&&l.current?.contains(t.target)&&e.note({x:t.clientX,y:t.clientY})}return window.addEventListener(`dblclick`,t,!0),()=>window.removeEventListener(`dblclick`,t,!0)},[c]),(0,J.useEffect)(()=>{m&&c.history.runWithoutHistory(()=>{c.store.getState().remeasureBindings()})},[m,c]);let v=U(e=>e.presentingIndex!==null),y=U(e=>e.viewMode),b=U(e=>e.isPanning),S=U(e=>e.dragging),{addShape:C,addMany:w,replaceShape:T,replaceMany:E,updateShape:D,removeShapes:O,setSelectedIds:k,beginLaneEdit:A,endEdit:j,setActiveGroupId:M,setStyle:N,setShapeKind:P,setLockRevealId:F,zoomIn:I,zoomOut:L,resetZoom:ee,fitToBounds:R}=s.getState(),z=Oj({containerRef:l,fileInputRef:u}),B=ds(`Space`,{preventDefault:!0}),V=z.tool===`hand`||B,ne=z.tool===`select`&&!V&&!z.pendingIcon&&!z.pendingControl;xy(`CanvasBody`);let re=ey({containerRef:l,panMode:V,pinchingRef:f});dy({containerRef:l,pinchingRef:f,onPinchStart:re.cancelGesture}),iy(l),cy(l),hy();let ie=Tj({recentDrillRef:re.recentDrillRef,interactive:ne}),{commitPolyline:ae,interceptContextMenu:oe}=re,{beginEdit:se}=ie,ce=Dj({selectedShapes:ie.selectedShapes}),le=xj({containerRef:l}),ue=yy({updateShape:D,beginLaneEdit:A,endEdit:j,setSelectedIds:k,setActiveGroupId:M}),de=_y(),fe=vy({replaceShape:T,endEdit:j,refitRows:de.refitRows,remapCellHeights:de.remapCellHeights}),pe=Wm({replaceMany:E,removeShapes:O,addShape:C,addMany:w,setSelectedIds:k,setLockRevealId:F}),me=by({replaceMany:E,setStyle:N,setShapeKind:P}),he=Wh({containerRef:l,addShape:C,setSelectedIds:k}),ge=Xm(),_e=Km({containerRef:l,fitToBounds:R,zoomIn:I,zoomOut:L,resetZoom:ee}),ve=(0,J.useCallback)(e=>{if(z.tool===`polyline`||z.tool===`polygon`){ae();return}if(!ne)return;let t=l.current;if(!(e.target instanceof Element)||!t?.contains(e.target)||e.target.closest(`[data-overlay]`)||e.target instanceof Element&&e.target.closest(`[data-shape-id], [data-testid="selection-surface"]`))return;let n=l.current;if(!n)return;let{shapes:r,style:i,viewport:a}=s.getState(),o=n.getBoundingClientRect(),u=nt({x:e.clientX-o.left,y:e.clientY-o.top},a),d=Pu(r,u,c.measurement);if(d.kind===`label`){se(d.id);return}if(d.kind===`shape`)return;let f=Su({x:u.x,y:u.y-i.fontSize/2},i);c.history.runWithoutHistory(()=>C(f)),se(f.id)},[z.tool,ne,s,c.measurement,c.history,C,se,ae]),ye=(0,J.useCallback)(e=>{if(oe(e))return;let t=l.current;if(!t)return;let n=s.getState(),{shapes:r}=n,i=t.getBoundingClientRect(),a=nt({x:e.clientX-i.left,y:e.clientY-i.top},n.viewport);p.current=a;let o=Iu(n,a,Fe(r,a,void 0,c.measurement)??Gu(r,e.clientX,e.clientY),c.measurement);o&&(F(o.lockRevealId),k(o.selectedIds))},[oe,s,c.measurement,k,F]);Wu(l,t),Ru({onDocumentChange:n,onViewportChange:r,onPreferencesChange:i}),ng(),sg(),cg(),gm({commitPolyline:re.commitPolyline,removeLastPolylinePoint:re.removeLastPolylinePoint,cancelPolyline:re.cancelPolyline,nudgeSelection:ie.nudgeSelection,copySelection:he.copySelection,cutSelection:he.cutSelection,pasteClipboard:he.pasteClipboard,pasteAsText:()=>void he.pasteAsText(),pasteText:he.pasteText,pasteEmbed:he.pasteEmbed,selectTool:z.selectTool,insertControl:z.insertControl,addComment:()=>{if(ge.available){if(s.getState().selectedIds.size>0){ge.commentOnSelection();return}z.selectTool(`comment`)}},addImageFromFile:le.addImageFromFile,hasClipboard:he.hasClipboard,clipboardCopyId:he.clipboardCopyId,pasteExternal:he.pasteExternal,pasteGrid:he.pasteGrid,duplicate:he.duplicateSelection,flip:ie.flipSelection,reorder:ie.reorderSelection,align:ie.alignSelection,tidy:pe.tidySelection,copyStyles:he.copyStyles,pasteStyles:he.pasteStyles,toggleLock:pe.toggleLock,copyPng:()=>void o(`copyPng`,le.exportTargets()),zoomIn:_e.zoomInCentered,zoomOut:_e.zoomOutCentered,resetZoom:_e.resetZoomCentered,zoomToFit:_e.zoomToFit,startPresentation:z.startPresentation,openFile:()=>d.current?.openFile(),saveNow:()=>void le.saveNow(),editSelection:ie.editSelection,eyedrop:()=>void Ma().then(e=>{e&&me.applyEyedropper(e)})});let be=`default`;b?be=`grabbing`:V?be=`grab`:S?be=`move`:kj.has(z.tool)||z.pendingIcon||z.pendingControl||z.tool===`eraser`||z.tool===`comment`?be=`crosshair`:ne&&ie.hoveringLocked&&ie.revealedUnit.length===0&&(be=`not-allowed`);let xe=ym({pasteClipboard:he.pasteClipboard,pasteAsText:he.pasteAsText,selectAll:ie.selectAll,clearCanvas:le.clearCanvas,startPresentation:z.startPresentation,zoomToFit:_e.zoomToFit,resetZoom:_e.resetZoomCentered,backToContent:_e.backToContent,toggleGrid:z.toggleGrid,zoomToSelection:_e.zoomToSelection});return(0,Q.jsx)(x,{delay:0,children:(0,Q.jsx)(Hy,{buildModel:Gm({selection:ie,documents:le,tools:z,paste:he,structure:pe,tables:fe,zoom:_e,comments:ge,ai:a,embedFrame:h,pasteTargetRef:p}),children:(0,Q.jsxs)(`div`,{ref:l,"data-testid":`canvas`,"data-canvas-root":!0,className:`relative h-dvh w-screen touch-none select-none overflow-clip bg-[var(--canvas-bg)]`,style:{cursor:v?$a:be,contain:`strict`,visibility:m?void 0:`hidden`},onPointerDown:v?void 0:re.onContainerPointerDown,onPointerMove:v?void 0:re.onContainerPointerMove,onPointerLeave:v?void 0:re.onContainerPointerLeave,onClick:v?void 0:re.onContainerClick,onDoubleClick:v||y?void 0:ve,onContextMenu:v?void 0:ye,onDragOver:v||y?void 0:le.onCanvasDragOver,onDrop:v||y?void 0:le.onCanvasDrop,children:[(0,Q.jsx)(`input`,{ref:u,type:`file`,accept:`image/*,.heic,.heif`,className:`hidden`,"data-testid":`canvas-image-input`,onChange:e=>{let t=e.target.files?.[0];t&&le.addImageFromFile(t),e.target.value=``}}),(0,Q.jsx)(FD,{containerRef:l,interactive:ne,interaction:re,selection:ie,panel:ce,tables:fe,lanes:ue,measure:de,pasteChoiceOpen:he.pasteChoiceOpen,resolvePasteChoice:he.resolvePasteChoice,unlockReveal:pe.unlockReveal}),(0,Q.jsx)(dj,{containerRef:l,mainMenuRef:d,loadDocument:le.loadDocument,tools:z,panel:ce,styles:me,deleteSelection:ie.deleteSelection,alignSelection:ie.alignSelection,distributeSelection:ie.distributeSelection,reorderSelection:ie.reorderSelection,duplicateSelection:he.duplicateSelection,pasteEmbed:he.pasteEmbed,zoomToFit:_e.zoomToFit,backToContent:_e.backToContent,paletteCommands:xe}),pe.tidyState.status===`loading`?(0,Q.jsx)(io,{testId:`tidy-pending`,tone:`pending`,children:`Tidying up…`}):null,pe.tidyState.status===`failed`?(0,Q.jsx)(io,{testId:`tidy-error`,tone:`error`,action:{label:`Retry`,testId:`tidy-retry`,onClick:pe.tidyState.retry},children:`Couldn't load the layout engine`}):null,(0,Q.jsx)(db,{open:g,onOpenChange:_,title:`Sign in to embed this frame`,description:`Embedding puts a live image of this frame on any page — it updates as you edit. Sign in to save this canvas and get its link.`})]})})})}function jj(){let[e,t]=(0,J.useState)(!0),n=U(e=>e.deviceMode===`phone`);return(0,Q.jsx)(yl,{open:e,onOpenChange:t,children:(0,Q.jsxs)(gl,{children:[(0,Q.jsx)(hl,{className:`fixed inset-0 z-50 bg-gray-900/15`}),(0,Q.jsx)(vl,{"data-overlay":!0,"data-testid":`icon-library-guide-dialog`,className:`fixed top-1/2 left-1/2 z-50 max-h-[92vh] w-[min(560px,92vw)] -translate-x-1/2 -translate-y-1/2 overflow-y-auto rounded-2xl bg-[var(--chrome-popup)] p-6 outline-none ring-1 ring-[var(--chrome-ring)]`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-3 text-center`,children:[(0,Q.jsx)(xl,{className:`text-[15px] font-medium text-[var(--chrome-fg-900)]`,children:`Where the icons live`}),(0,Q.jsx)(`img`,{src:`/icon-picker-guide.webp`,alt:`The canvas toolbar, with the smiley icon button near the bottom marked 1, and the panel it opens marked 2.`,width:1494,height:1208,className:`w-full rounded-xl ring-1 ring-[var(--chrome-ring)]`,draggable:!1}),n?(0,Q.jsx)(Sl,{className:`text-[13px] leading-relaxed text-[var(--chrome-fg-500)]`,children:`Follow the steps above to open the icon library, then tap an icon to place it.`}):(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-x-1.5 gap-y-1 text-[13px] text-[var(--chrome-fg-500)]`,children:[(0,Q.jsx)(`span`,{children:`Follow the steps above, or press`}),(0,Q.jsx)(NA,{children:`Shift`}),(0,Q.jsx)(NA,{children:`S`}),(0,Q.jsx)(`span`,{children:`to search the library.`})]}),(0,Q.jsx)(bl,{className:`mt-3 h-8 rounded-xl bg-[var(--chrome-accent)] px-3.5 text-[13px] text-white outline-none transition-colors hover:bg-[var(--chrome-accent-hover)] active:scale-[0.97]`,children:`Start drawing`})]})})]})})}function Mj(e){let{icon:t}=e,[n,r]=(0,J.useState)(!0),i=U(e=>e.deviceMode===`phone`);return(0,Q.jsx)(yl,{open:n,onOpenChange:r,children:(0,Q.jsxs)(gl,{children:[(0,Q.jsx)(hl,{className:`fixed inset-0 z-50 bg-gray-900/15`}),(0,Q.jsx)(vl,{"data-overlay":!0,"data-testid":`icon-welcome-dialog`,className:`fixed left-1/2 top-1/2 z-50 w-[min(400px,92vw)] -translate-x-1/2 -translate-y-1/2 rounded-2xl bg-[var(--chrome-popup)] p-6 outline-none ring-1 ring-[var(--chrome-ring)]`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-3 text-center`,children:[Gi(t.source)&&(0,Q.jsx)(`div`,{className:`mb-1 grid h-20 w-20 place-items-center rounded-xl bg-[var(--chrome-hover)] ring-1 ring-[var(--chrome-ring)]`,children:(0,Q.jsx)(`img`,{src:Ki().assetIconUrl(t.source,t.name),alt:``,width:52,height:52,draggable:!1})}),(0,Q.jsx)(xl,{className:`text-[15px] font-medium text-[var(--chrome-fg-900)]`,children:`Icon has been selected`}),(0,Q.jsx)(Sl,{className:`text-[13px] leading-relaxed text-[var(--chrome-fg-500)]`,children:i?`Your icon is ready to place — tap anywhere on the canvas to drop it, then keep sketching.`:`Your icon is riding the cursor — click anywhere on the canvas to place it, then start drawing with your mouse.`}),!i&&(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-x-1.5 gap-y-1 text-[13px] text-[var(--chrome-fg-500)]`,children:[(0,Q.jsx)(`span`,{children:`Press`}),(0,Q.jsx)(NA,{children:`Shift`}),(0,Q.jsx)(NA,{children:`S`}),(0,Q.jsx)(`span`,{children:`to search the library for more icons.`})]}),(0,Q.jsx)(bl,{className:`mt-3 h-8 rounded-xl bg-[var(--chrome-accent)] px-3.5 text-[13px] text-white outline-none transition-colors hover:bg-[var(--chrome-accent-hover)] active:scale-[0.97]`,children:`Start drawing`})]})})]})})}var Nj=80;function Pj(e){let{apiUrl:t,assistant:n,debug:r,canvasMeta:i,saveStatus:a,readOnly:o,readOnlyPill:s,publicShare:c,shareOwner:l,widgetOrigin:u,onSaveCanvas:d,onSaveNow:f,autoSavePrompt:p,documentEmpty:m,onSaveDismissed:h,saveAtLimit:g,saveDestination:_,onForkCanvas:v,forkAtLimit:y,workspaceId:b,workspaceName:x,location:S,onDuplicateCanvas:C,onMoveCanvas:w,onEditCanvasMeta:T,onDeleteCanvas:E,scratch:D,onNewCanvas:O,onShowCanvases:k,onOpenShare:A,onEmbedFrame:j,account:M,uploadImage:N,decodeHeic:P,searchIcons:F,embed:I,presence:L,comments:ee}=e,R=t!=null&&n!=null&&o!==!0,z=(0,J.useMemo)(()=>({apiUrl:t,ai:R,assistant:R?n:void 0,canvasMeta:i,saveStatus:a,readOnly:o,readOnlyPill:s,publicShare:c,shareOwner:l,widgetOrigin:u,onSaveCanvas:d,onSaveNow:f,autoSavePrompt:p,documentEmpty:m,onSaveDismissed:h,saveAtLimit:g,saveDestination:_,onForkCanvas:v,forkAtLimit:y,workspaceId:b,workspaceName:x,location:S,onDuplicateCanvas:C,onMoveCanvas:w,onEditCanvasMeta:T,onDeleteCanvas:E,scratch:D,onNewCanvas:O,onShowCanvases:k,onOpenShare:A,onEmbedFrame:j,account:M,uploadImage:N,decodeHeic:P,searchIcons:F,embed:I,presence:L,comments:ee}),[t,R,n,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A,j,M,N,P,F,I,L,ee]),[B]=(0,J.useState)(()=>{let t=xu({document:e.initialDocument??null,viewport:e.initialViewport??null,preferences:e.initialPreferences??null});if(e.readOnly&&(t.store.getState().setViewMode(!0),t.store.getState().setViewModeLocked(!0)),e.initialPendingIcon&&!e.readOnly){let{source:n,name:r}=e.initialPendingIcon;$c(n,r,e=>t.store.getState().setPendingIcon(e))}return e.initialDiagramCode&&!e.readOnly&&(t.store.getState().setCodeOpen(!0),t.store.getState().setCodeSeed(e.initialDiagramCode)),t}),V=B.store,te=(0,J.useRef)(e.readOnly===!0);(0,J.useEffect)(()=>{let e=o===!0;if(te.current===e)return;te.current=e;let t=V.getState();if(e){t.setViewMode(!0),t.setViewModeLocked(!0);return}t.setViewModeLocked(!1),t.setViewMode(!1)},[o,V]);let[ne]=(0,J.useState)(()=>e.environment??ji({elk:Mi}));(0,J.useEffect)(()=>()=>B.dispose(),[B]),(0,J.useEffect)(()=>{let t=e.bindEditorApi;if(t)return t({loadShapes:e=>V.getState().loadShapes(e),adoptShapes:e=>B.history.applyRemote(ce(V.getState().shapes,e)),applyRemote:e=>B.history.applyRemote(e),setRemoteCursors:e=>V.getState().setRemoteCursors(e),revealShapes:e=>{let t=V.getState(),n=new Set(e),r=pn(t.shapes.filter(e=>n.has(e.id))),i=B.measurementRoot.current;if(!r||!(i instanceof HTMLElement))return;let a={width:i.clientWidth,height:i.clientHeight};B.viewportAnimation.animate(t.viewport,yr(r,a,Nj),t.setViewport)},onPointerMove:e=>{let t=t=>{if(t.pointerType===`touch`)return;let n=B.measurementRoot.current;if(!(n instanceof HTMLElement))return;let r=n.getBoundingClientRect(),i=t.clientX-r.left,a=t.clientY-r.top;if(i<0||a<0||i>r.width||a>r.height){e(null);return}e(nt({x:i,y:a},V.getState().viewport))},n=()=>e(null);return window.addEventListener(`pointermove`,t,{passive:!0}),document.documentElement.addEventListener(`pointerleave`,n),window.addEventListener(`blur`,n),()=>{window.removeEventListener(`pointermove`,t),document.documentElement.removeEventListener(`pointerleave`,n),window.removeEventListener(`blur`,n)}}}),()=>t(null)},[e.bindEditorApi,V,B]),(0,J.useEffect)(()=>{if(!r||typeof window>`u`)return;let e=window;return e.__koboyoStore=V,()=>{e.__koboyoStore===V&&delete e.__koboyoStore}},[r,V]);let re=e.onDocumentChange,ae=(0,J.useMemo)(()=>{if(re)return e=>{re(De(e,V.getState().opaqueShapes))}},[re,V]);return(0,Q.jsx)(ie,{value:z,children:(0,Q.jsx)(ki,{value:ne,children:(0,Q.jsxs)(Te,{value:B,children:[(0,Q.jsx)(Aj,{hasInitialViewport:e.initialViewport!=null,onDocumentChange:ae,onViewportChange:e.onViewportChange,onPreferencesChange:e.onPreferencesChange}),e.initialPendingIcon&&!e.readOnly&&(0,Q.jsx)(Mj,{icon:e.initialPendingIcon}),e.initialIconGuide&&!e.initialPendingIcon&&!e.readOnly&&(0,Q.jsx)(jj,{})]})})})}var Fj=400,Ij=1e3,Lj=1e4;function Rj(e,t){return se(e.shapes)===se(t.shapes)}function zj(e,t){let n=e,r=null,i=null,a=!1,o=0,s=null,c=!1,l=[];function u(e,n=null){c||t.effects.status(e,n)}function d(e){let t=l;l=[];for(let n of t)n(e)}function f(){r===null&&i===null&&(u(`saved`),d(!0))}function p(e){s?.(),s=t.schedule(e,()=>{s=null,g()})}function m(){return r||(i&&!i.merged?i.document:null)}function h(e,a){let o=m(),s=n.document;if(i&&(i.merged=!0),n={revision:e,document:a},!o){t.effects.adopt(a);return}let c=ye(s,o,a).document,l=ue(s,a,c);t.effects.adopt(c),l>0&&t.effects.keptLocal(l),r=Rj(c,a)?null:c}async function g(e=!1){if(c||i||!r||a)return;let s={document:r,merged:!1};r=null,i=s,u(`saving`);let l;try{l=await t.save(s.document,n.revision,{keepalive:e})}catch(e){if(i=null,s.merged||(r??=s.document),d(!1),!r){f();return}o+=1,u(`offline`,e instanceof Error&&e.message?e.message:null),p(Math.min(Ij*2**(o-1),Lj));return}if(o=0,i=null,!c){if(l.kind===`saved`)l.revision>n.revision&&(n={revision:l.revision,document:s.document});else if(l.kind===`conflict`)s.merged||(r??=s.document),l.revision>n.revision&&h(l.revision,l.document);else if(s.merged||(r??=s.document),r){a=!0,u(`rejected`,l.message),d(!1);return}if(r){g();return}f()}}return{edit(e){c||(r=e,a=!1,u(`dirty`),p(Fj))},remote(e,t,a){c||a||e<=n.revision||(h(e,t),r&&!i&&p(Fj))},flush(){if(c||a)return Promise.resolve(!1);if(!r&&!i)return Promise.resolve(!0);let e=new Promise(e=>l.push(e));return s?.(),s=null,g(),e},unsaved(){let e=m();return e?{base:n.document,document:e}:null},leave(){c||i||!r||a||(s?.(),s=null,g(!0))},open(){c=!1,r&&p(Fj)},close(){c=!0,s?.(),s=null,d(!1)}}}function Bj(e){return`koboyo.local-draft:${e}`}function Vj(e,t,n){return e.setString(Bj(t),JSON.stringify(n))}function Hj(e,t){e.remove(Bj(t))}function Uj(e){return typeof e==`object`&&!!e&&Array.isArray(e.shapes)}function Wj(e,t){let n=e.getString(Bj(t));if(!n)return null;try{let e=JSON.parse(n);return!Uj(e.base)||!Uj(e.document)?null:{base:e.base,document:e.document}}catch{return null}}function Gj(e,t){return se(e.shapes)===se(t.shapes)}function Kj(e,t){let n=new Set(e.shapes.map(e=>e.id));return t.shapes.some(e=>n.has(e.id))}function qj(e,t){if(e.base.shapes.length>0&&!Kj(e.base,t))return null;let n=Gj(e.base,t)?e.document:ye(e.base,e.document,t).document;return Gj(n,t)?null:n}var Jj=g(),Yj={id:`you`,name:`You`,avatarUrl:null},Xj=[];function Zj(){let e=crypto.randomUUID();return{id:e,pending:`${Ib}${e}`}}function Qj(e,t,n){return e.map(e=>e.id===t?n(e):e)}function $j(e,t){return e.comments.some(e=>e.id===t)}function eM(e){let{file:t,subscribe:n}=e,[r,i]=(0,J.useState)(null),a=(0,J.useCallback)(e=>{i(t=>t!==null&&t.revision>e.revision?t:e)},[]),[o,s]=(0,J.useState)([]),[c,l]=(0,J.useState)(null),[u,d]=(0,J.useState)(0),f=(0,J.useRef)(0),p=(0,J.useRef)(new Set);(0,J.useEffect)(()=>{let e=!0;return l(null),Jl.list(t).then(t=>{e&&a(t)}).catch(t=>{e&&l(t instanceof Error?t.message:String(t))}),()=>{e=!1}},[t,u,a]),(0,J.useEffect)(()=>n(e=>{e.type===`comments`&&e.file===t&&(a({threads:e.threads,revision:e.revision}),l(null))}),[n,t,a]);let m=(0,J.useCallback)(()=>d(e=>e+1),[]),h=(0,J.useCallback)(async(e,t)=>{f.current+=1;let n={id:f.current,apply:e};s(e=>[...e,n]);let r=t();p.current.add(r);try{a(await r)}finally{p.current.delete(r),s(e=>e.filter(e=>e.id!==n.id))}},[a]),g=(0,J.useCallback)(e=>{let n=Date.now(),{id:r,pending:i}=Zj(),a={id:i,anchor:e.anchor,comments:[{id:i,author:Yj,body:e.body,createdAt:n,editedAt:null}],createdAt:n,updatedAt:n,resolvedAt:null};return h(e=>e.some(e=>e.id===r)?e:[...e,a],()=>Jl.create(t,r,e.body,e.anchor))},[h,t]),_=(0,J.useCallback)((e,n)=>{let r=Date.now(),{id:i,pending:a}=Zj();return h(t=>Qj(t,e,e=>$j(e,i)?e:{...e,comments:[...e.comments,{id:a,author:Yj,body:n,createdAt:r,editedAt:null}],updatedAt:r}),()=>Jl.reply(t,e,i,n))},[h,t]),v=(0,J.useCallback)((e,n)=>{let r=Date.now();return h(t=>t.map(t=>$j(t,e)?{...t,comments:t.comments.map(t=>t.id===e?{...t,body:n,editedAt:r}:t)}:t),()=>Jl.update(t,e,n))},[h,t]),y=(0,J.useCallback)((e,n)=>h(t=>Qj(t,e,e=>({...e,anchor:n})),()=>Jl.move(t,e,n)),[h,t]),b=(0,J.useCallback)((e,n)=>{let r=Date.now();return h(t=>Qj(t,e,e=>({...e,resolvedAt:n?r:null})),()=>Jl.resolve(t,e,n))},[h,t]),x=(0,J.useCallback)(e=>h(t=>t.flatMap(t=>t.comments[0]?.id===e?[]:$j(t,e)?[{...t,comments:t.comments.filter(t=>t.id!==e)}]:[t]),()=>Jl.remove(t,e)),[h,t]),S=(0,J.useMemo)(()=>o.reduce((e,t)=>t.apply(e),r?.threads??[]),[r,o]),C=(0,J.useCallback)(async()=>(await Promise.allSettled([...p.current])).every(e=>e.status===`fulfilled`),[]),w=(0,J.useMemo)(()=>({canvasId:`local:${t}`,threads:S,loaded:r!==null,error:c,reload:m,currentUser:Yj,canModerate:!0,members:Xj,createThread:g,reply:_,update:v,move:y,resolve:b,remove:x}),[t,S,r,c,m,g,_,v,y,b,x]);return(0,J.useMemo)(()=>({integration:w,settle:C}),[w,C])}function tM(e){if(!(e.hostname!==`127.0.0.1`||e.port===``))return`http://localhost:${e.port}`}function nM(e,t){let n=Wj(Hc,e);if(!n)return{...t,recovered:null};let r=qj({base:rM(n.base),document:rM(n.document)},t.document);return r||Hj(Hc,e),{...t,recovered:r}}function rM(e){let t=he(e);return t.status===`valid`?t.document:e}function iM(e,t){if(!t)return!1;let n=e.shapes.find(e=>e.id===t);return n?.type===`figure`&&ls(e.shapes,n)}var aM=250;function oM(e,t){let n=pn(e.shapes);if(!n)return null;let r=yr(n,{width:window.innerWidth-t.left,height:window.innerHeight-t.top});return{...r,y:r.y+t.top}}function sM(e){let{file:t}=e,[n,r]=(0,J.useState)({kind:`loading`}),[i,a]=(0,J.useState)(0);(0,J.useEffect)(()=>{let e=!0;return r({kind:`loading`}),zl(t.id).then(n=>{e&&r({kind:`ready`,seed:nM(t.id,{...n,document:rM(n.document)})})}).catch(t=>{e&&r({kind:`failed`,message:t instanceof Error?t.message:String(t),diagnostics:t instanceof Ll?t.diagnostics:[]})}),()=>{e=!1}},[t.id,i]);let{subscribe:o}=e,s=n.kind===`failed`;return(0,J.useEffect)(()=>{if(s)return o(e=>{(e.type===`code`||e.type===`document`)&&e.file===t.id&&a(e=>e+1)})},[s,o,t.id]),n.kind===`loading`?(0,Q.jsx)(`div`,{className:`absolute inset-0`,"aria-busy":`true`}):n.kind===`failed`?(0,Q.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center p-6 pt-[calc(var(--koboyo-host-inset-top)+24px)]`,children:(0,Q.jsxs)(`div`,{className:`w-full max-w-[460px] rounded-xl bg-[var(--chrome-popup)] p-5 ring-1 ring-[var(--chrome-ring)]`,children:[(0,Q.jsxs)(`p`,{className:`m-0 text-balance text-[14px] font-medium text-[var(--chrome-fg-900)]`,children:[t.label,` can't be opened yet`]}),(0,Q.jsx)(`p`,{className:`m-0 mt-1.5 text-balance text-[13px] leading-5 text-[var(--chrome-fg-600)]`,children:n.message}),n.diagnostics.length>0&&(0,Q.jsx)(`ul`,{className:`m-0 mt-3 list-none space-y-1 rounded-lg bg-[var(--chrome-rest)] p-3 font-mono text-[12px] text-[var(--chrome-fg-700)]`,children:n.diagnostics.slice(0,8).map(e=>(0,Q.jsxs)(`li`,{children:[e.line>0?`line ${e.line}: `:``,e.message]},`${e.line}:${e.message}`))}),(0,Q.jsx)(`p`,{className:`m-0 mt-3 text-balance text-[12.5px] text-[var(--chrome-fg-500)]`,children:`Fix the file and it opens here by itself.`})]})}):(0,Q.jsx)(cM,{...e,seed:n.seed})}function cM(e){let{file:t,client:n,seed:r,onState:i,onViewport:a,subscribe:o}=e,s=(0,J.useMemo)(()=>ji({elk:Mi}),[]),c=(0,J.useMemo)(()=>tM(window.location),[]),l=(0,J.useRef)(null),u=(0,J.useRef)(!1),[d]=(0,J.useState)(()=>e.initialViewport??oM(r.document,e.viewInset)),f=(0,J.useRef)(d),p=(0,J.useRef)(r.recovered??r.document),m=(0,J.useRef)(r.code),[h,g]=(0,J.useState)({status:`saved`,detail:null,handEdited:iM(r.document,r.code.frameId),code:r.code,openComments:0});(0,J.useEffect)(()=>{i(h)},[h,i]);let _=(0,J.useRef)(null),v=(0,J.useCallback)(()=>{_.current&&clearTimeout(_.current),_.current=setTimeout(()=>{_.current=null;let e=iM(p.current,m.current.frameId);g(t=>t.handEdited===e?t:{...t,handEdited:e})},aM)},[]);(0,J.useEffect)(()=>()=>{_.current&&clearTimeout(_.current)},[]);let y=eM({file:t.id,subscribe:o}),b=y.integration.threads.filter(e=>e.resolvedAt===null).length;(0,J.useEffect)(()=>{g(e=>e.openComments===b?e:{...e,openComments:b})},[b]);let x=(0,J.useRef)(null);x.current===null&&(x.current=zj({revision:r.revision,document:r.document},{save:async(e,r,i)=>{let a=await Ul(t.id,{baseRevision:r,client:n,document:e,viewport:f.current},i);return a.kind===`conflict`?{...a,document:rM(a.document)}:a},schedule:(e,t)=>{let n=setTimeout(t,e);return()=>clearTimeout(n)},effects:{status:(e,n)=>{e===`saved`&&Hj(Hc,t.id),g(t=>t.status===e&&t.detail===n?t:{...t,status:e,detail:n})},adopt:e=>{p.current=e;let t=l.current;if(t){u.current=!0;try{t.adoptShapes(e.shapes)}finally{u.current=!1}}v()},keptLocal:e=>Jj.notify(`${t.board} changed while you were editing. Both are combined; your version of ${e===1?`1 shape`:`${e} shapes`} was kept.`)}}));let S=x.current;(0,J.useEffect)(()=>(S.open(),()=>S.close()),[S]);let C=r.recovered,w=(0,J.useRef)(!1);(0,J.useEffect)(()=>{!C||w.current||(w.current=!0,S.edit(C),Jj.notify(`Restored edits to ${t.label} that weren't saved when this page last closed.`))},[C,S,t.label]);let T=(0,J.useCallback)(()=>{let e=S.unsaved();e&&Vj(Hc,t.id,e)},[S,t.id]);(0,J.useImperativeHandle)(e.handle,()=>({flush:async()=>{let[e,t]=await Promise.all([S.flush(),y.settle()]);return e||T(),e&&t},reveal:e=>{l.current?.revealShapes(e)}}),[S,T,y]),(0,J.useEffect)(()=>o(e=>{if(e.type===`document`&&e.file===t.id){S.remote(e.revision,rM(e.document),e.client===n);return}e.type===`code`&&e.file===t.id&&(m.current=e.code,g(t=>({...t,code:e.code})),v())}),[o,S,t.id,n,v]);let E=(0,J.useRef)(h);E.current=h,(0,J.useEffect)(()=>{let e=()=>{T(),S.leave()},t=()=>{document.visibilityState===`hidden`&&e()},r=e=>{let t=S.unsaved();if(!t)return;let r=E.current.status;r!==`offline`&&r!==`rejected`&&Hl({baseRevision:0,client:n,document:t.document,viewport:f.current})||e.preventDefault()};return window.addEventListener(`pagehide`,e),window.addEventListener(`beforeunload`,r),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`pagehide`,e),window.removeEventListener(`beforeunload`,r),document.removeEventListener(`visibilitychange`,t)}},[S,T,n]);let D=(0,J.useCallback)(e=>{p.current=e,v(),!u.current&&S.edit(e)},[S,v]),O=(0,J.useCallback)(e=>{l.current=e},[]),k=(0,J.useCallback)(e=>{f.current=e,a(e)},[a]),A=(0,J.useCallback)(async()=>{if(!await S.flush())throw Error(`not saved`)},[S]);return(0,Q.jsx)(Pj,{initialDocument:r.recovered??r.document,initialViewport:d,onDocumentChange:D,onViewportChange:k,onSaveNow:A,bindEditorApi:O,environment:s,readOnly:e.readOnly,readOnlyPill:!1,widgetOrigin:c,comments:e.readOnly?void 0:y.integration})}var lM=`flex h-8 min-w-0 shrink cursor-pointer items-center gap-1.5 rounded-lg px-2.5 text-[13px] font-medium outline-none transition-colors`,uM=`shrink-0 cursor-pointer rounded-lg px-2.5 py-1.5 text-[13px] font-medium text-[var(--chrome-fg-700)] transition-colors hover:bg-[var(--chrome-hover)]`,dM=`shrink-0 cursor-pointer rounded-lg bg-[var(--chrome-accent)] px-2.5 py-1.5 text-[13px] font-medium text-white transition-colors hover:bg-[var(--chrome-accent-hover)]`;function fM(e){return(0,Q.jsxs)(Dc,{children:[(0,Q.jsx)(Ca,{"data-testid":e.testId,className:e.triggerClassName,title:e.title,children:e.trigger}),(0,Q.jsx)(Mc,{children:(0,Q.jsx)(Lc,{sideOffset:8,align:`start`,className:`z-[70]`,children:(0,Q.jsx)(Rc,{className:`${q.popup} w-[360px] max-w-[calc(100vw-24px)] p-3.5 text-[13px] leading-5 text-[var(--chrome-fg-700)] outline-none`,children:e.children})})})]})}function pM(e){return(0,Q.jsxs)(fM,{testId:`agent-note`,title:`${e.agent}: ${e.message}`,triggerClassName:`${lM} max-w-[340px] font-normal text-[var(--chrome-fg-700)] hover:bg-[var(--chrome-hover)]`,trigger:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(ks,{size:15,stroke:1.75,className:`shrink-0`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`truncate max-md:hidden`,children:e.message})]}),children:[(0,Q.jsxs)(`p`,{className:`m-0 text-[12.5px] font-medium text-[var(--chrome-fg-500)]`,children:[`Note from `,e.agent]}),(0,Q.jsx)(`p`,{className:`m-0 mt-1 whitespace-pre-wrap text-[var(--chrome-fg-900)]`,children:e.message})]})}function mM(e){return(0,Q.jsxs)(fM,{testId:`agent-choice`,title:e.choice.question,triggerClassName:`${lM} max-w-[340px] bg-[var(--chrome-accent)] text-white hover:bg-[var(--chrome-accent-hover)]`,trigger:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Sp,{size:15,stroke:1.75,className:`shrink-0`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.choice.question})]}),children:[(0,Q.jsxs)(`p`,{className:`m-0 text-[12.5px] font-medium text-[var(--chrome-fg-500)]`,children:[e.agent,` asks`]}),(0,Q.jsx)(`p`,{className:`m-0 mt-1 text-balance font-medium text-[var(--chrome-fg-900)]`,children:e.choice.question}),(0,Q.jsx)(`ul`,{className:`m-0 mt-3 list-none space-y-1 p-0`,children:e.choice.options.map(t=>(0,Q.jsxs)(`li`,{"data-testid":`agent-choice-option`,className:`flex items-center gap-2 rounded-lg px-1 py-0.5`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[var(--chrome-fg-900)]`,children:t.label}),(0,Q.jsx)(`button`,{type:`button`,className:uM,onClick:()=>e.onReveal(t.frameId),children:`Show`}),(0,Q.jsx)(Pb,{className:dM,disabled:e.picking,onClick:()=>e.onPick(t.frameId),children:`Pick this one`})]},t.frameId))})]})}function hM(e){return(0,Q.jsxs)(fM,{testId:`code-changed`,triggerClassName:`${lM} bg-[var(--cta-save-bg)] text-[var(--cta-save-fg)] hover:bg-[var(--cta-save-bg-hover)]`,trigger:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(ec,{size:15,stroke:1.75,className:`shrink-0`,"aria-hidden":!0}),(0,Q.jsxs)(`span`,{className:`truncate`,children:[e.file.label,` changed`]})]}),children:[(0,Q.jsxs)(`p`,{className:`m-0 text-balance`,children:[(0,Q.jsxs)(`span`,{className:`font-medium text-[var(--chrome-fg-900)]`,children:[`The agent changed `,e.file.label,`.`]}),` `,`You've edited this drawing by hand, so it wasn't replaced.`]}),(0,Q.jsxs)(`div`,{className:`mt-3 flex justify-end gap-1.5`,children:[(0,Q.jsx)(Pb,{className:uM,onClick:e.onKeepMine,children:`Keep my edits`}),(0,Q.jsx)(Pb,{className:dM,onClick:e.onUseAgent,children:`Use the agent's version`})]})]})}function gM(e){let t=e.errors.length===1?`1 error`:`${e.errors.length} errors`;return(0,Q.jsxs)(fM,{testId:`code-errors`,triggerClassName:`${lM} text-[var(--chrome-danger)] hover:bg-[var(--chrome-hover)]`,trigger:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Rs,{size:15,stroke:1.75,className:`shrink-0`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`truncate`,children:t})]}),children:[(0,Q.jsxs)(`p`,{className:`m-0 text-balance`,children:[(0,Q.jsxs)(`span`,{className:`font-medium text-[var(--chrome-fg-900)]`,children:[e.file.label,` has `,e.errors.length===1?`an error`:t]}),`, so the board still shows the last drawing that worked.`]}),(0,Q.jsx)(`ul`,{className:`m-0 mt-2 max-h-[240px] list-none space-y-1 overflow-auto p-0 font-mono text-[12px] text-[var(--chrome-fg-600)]`,children:e.errors.map((e,t)=>(0,Q.jsxs)(`li`,{children:[e.line>0?`line ${e.line}: `:``,e.message]},t))})]})}function _M(e,t){return e===`sent`?{title:`Sent to ${t}`,body:`You can close this tab.`}:e===`timeout`?{title:`${t} stopped waiting`,body:`The wait timed out. Run koboyo open again to keep editing.`}:{title:`This editor has stopped`,body:`koboyo open is no longer running. Run it again to keep editing.`}}function vM(e){let t=_M(e.reason,e.agent);return(0,Q.jsx)(`div`,{"data-testid":`ended-card`,role:`status`,className:`absolute inset-0 z-[80] flex items-center justify-center bg-gray-900/10 p-6`,children:(0,Q.jsxs)(`div`,{className:`w-full max-w-[380px] rounded-xl bg-[var(--chrome-popup)] p-5 text-center shadow-[0_1px_2px_rgba(0,0,0,0.05),0_16px_32px_-8px_rgba(0,0,0,0.16)] ring-1 ring-[var(--chrome-ring)]`,children:[e.reason===`sent`&&(0,Q.jsx)(`span`,{className:`mx-auto mb-3 flex h-9 w-9 items-center justify-center rounded-full bg-[var(--chrome-rest)] text-[var(--chrome-fg-700)]`,children:(0,Q.jsx)(Qs,{size:18,stroke:2,"aria-hidden":!0})}),(0,Q.jsx)(`p`,{className:`m-0 text-balance text-[15px] font-medium text-[var(--chrome-fg-900)]`,children:t.title}),(0,Q.jsx)(`p`,{className:`m-0 mt-1.5 text-balance text-[13.5px] leading-5 text-[var(--chrome-fg-600)]`,children:t.body}),e.board&&(0,Q.jsxs)(`p`,{className:`m-0 mt-3 text-balance text-[12.5px] text-[var(--chrome-fg-500)]`,children:[`Your board is saved in `,(0,Q.jsx)(`span`,{className:`font-mono`,children:e.board}),`.`]})]})})}var yM=`flex h-8 shrink-0 cursor-pointer items-center justify-center gap-1.5 rounded-lg px-3 text-[13px] font-medium outline-none transition-colors disabled:cursor-default disabled:opacity-60`,bM=`${yM} bg-[var(--chrome-accent)] text-white hover:bg-[var(--chrome-accent-hover)]`,xM=`${yM} text-[var(--chrome-fg-700)] hover:bg-[var(--chrome-hover)]`;function SM(e){return(0,Q.jsx)(`p`,{className:`m-0 text-balance text-[13px] font-medium text-[var(--chrome-fg-900)]`,children:e.children})}function CM(e){return(0,Q.jsx)(`p`,{className:`m-0 mt-1 text-balance text-[13px] leading-5 text-[var(--chrome-fg-600)]`,children:e.children})}function wM(e){return(0,Q.jsx)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-1.5`,children:e.children})}function TM(e){let[t,n]=(0,J.useState)(!1),{answer:r}=e;async function i(){try{await navigator.clipboard.writeText(r.url),n(!0),setTimeout(()=>n(!1),1500)}catch{n(!1)}}return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(SM,{children:(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(Qs,{size:15,stroke:2,className:`text-[var(--flow-accent)]`,"aria-hidden":!0}),r.created?`Saved to your Koboyo account`:`Updated on Koboyo`]})}),(0,Q.jsx)(CM,{children:r.created?`A new board${r.workspace?` in ${r.workspace}`:``}. Saving again updates it.`:`The board${r.workspace?` in ${r.workspace}`:``} now matches this one.`}),(0,Q.jsx)(`input`,{readOnly:!0,value:r.url,"aria-label":`Link to the board`,onFocus:e=>e.currentTarget.select(),className:`mt-2.5 block w-full truncate rounded-lg bg-[var(--chrome-rest)] px-2.5 py-1.5 text-[12.5px] text-[var(--chrome-fg-800)] outline-none ring-1 ring-[var(--chrome-input)]`}),(0,Q.jsxs)(wM,{children:[(0,Q.jsxs)(`button`,{type:`button`,className:xM,onClick:()=>void i(),children:[t?(0,Q.jsx)(Qs,{size:15,stroke:2,"aria-hidden":!0}):(0,Q.jsx)(ga,{size:15,stroke:1.75,"aria-hidden":!0}),t?`Copied`:`Copy link`]}),(0,Q.jsxs)(`a`,{href:r.url,target:`_blank`,rel:`noopener noreferrer`,className:bM,children:[(0,Q.jsx)(Ys,{size:15,stroke:1.75,"aria-hidden":!0}),`Open`]})]})]})}function EM(e){let[t,n]=(0,J.useState)(e.workspaces[0]?.id??``);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(SM,{children:`Save to cloud`}),(0,Q.jsx)(CM,{children:e.message}),(0,Q.jsx)(`div`,{role:`radiogroup`,className:`mt-2.5 flex flex-col gap-1`,children:e.workspaces.map(e=>(0,Q.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 text-[13px] text-[var(--chrome-fg-800)] hover:bg-[var(--chrome-hover)]`,children:[(0,Q.jsx)(`input`,{type:`radio`,name:`cloud-workspace`,value:e.id,checked:t===e.id,onChange:()=>n(e.id)}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),(0,Q.jsx)(`span`,{className:`text-[12px] text-[var(--chrome-fg-500)]`,children:e.plan})]},e.id))}),(0,Q.jsx)(wM,{children:(0,Q.jsx)(`button`,{type:`button`,className:bM,disabled:!t,onClick:()=>e.onPick(t),children:`Save here`})})]})}function DM(e){let[t,n]=(0,J.useState)(!1),[r,i]=(0,J.useState)({kind:`working`,label:``}),a=(0,J.useRef)(null),{subscribe:o}=e;(0,J.useEffect)(()=>o(e=>{e.type===`sign-in`&&i(t=>t.kind===`signing-in`?{kind:`signing-in`,url:e.url}:t)}),[o]);function s(){a.current?.abort(),a.current=null}async function c(t=`update`,r){s();let o=new AbortController;a.current=o,n(!0),i({kind:`working`,label:`Saving to your Koboyo account…`});try{if(!await e.flush()){i({kind:`error`,message:`Your latest edits aren't saved to disk yet, so nothing was uploaded. Try again.`,mode:t});return}let n=await Kl({file:e.file.id,mode:t,workspaceId:r},o.signal);o.signal.aborted||i({kind:`answer`,answer:n,mode:t})}catch(e){o.signal.aborted||i({kind:`error`,message:e instanceof Error?e.message:String(e),mode:t})}}async function l(){s();let e=new AbortController;a.current=e,i({kind:`signing-in`,url:null});try{let t=await ql(e.signal);if(e.signal.aborted)return;if(t.status===`signed-in`){await c();return}i({kind:`error`,message:t.message,mode:`update`})}catch(t){e.signal.aborted||i({kind:`error`,message:t instanceof Error?t.message:String(t),mode:`update`})}}function u(){if(r.kind===`working`)return(0,Q.jsxs)(`p`,{className:`m-0 flex items-center gap-2 text-[13px] text-[var(--chrome-fg-600)]`,children:[(0,Q.jsx)(pc,{size:15,className:`animate-spin`,"aria-hidden":!0}),r.label]});if(r.kind===`signing-in`)return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(SM,{children:`Finish signing in in your browser`}),(0,Q.jsxs)(CM,{children:[`Approve koboyo on koboyo.com, and this board saves as soon as you're back.`,r.url&&(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsx)(`a`,{href:r.url,target:`_blank`,rel:`noopener noreferrer`,className:`font-medium text-[var(--chrome-fg-900)] underline underline-offset-2`,children:`Open the sign-in page`}),` `,`if it didn't open.`]})]}),(0,Q.jsx)(wM,{children:(0,Q.jsx)(`button`,{type:`button`,className:xM,onClick:()=>{s(),n(!1)},children:`Cancel`})})]});if(r.kind===`error`)return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(SM,{children:`Not saved`}),(0,Q.jsx)(CM,{children:r.message}),(0,Q.jsx)(wM,{children:(0,Q.jsx)(`button`,{type:`button`,className:xM,onClick:()=>void c(r.mode),children:`Try again`})})]});let{answer:e,mode:t}=r;switch(e.status){case`saved`:return(0,Q.jsx)(TM,{answer:e});case`signed-out`:return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(SM,{children:`Sign in to save to the cloud`}),(0,Q.jsx)(CM,{children:`Save this board to your Koboyo account to get a link you can share. Saving again updates it.`}),(0,Q.jsx)(wM,{children:(0,Q.jsx)(`button`,{type:`button`,className:bM,onClick:()=>void l(),children:`Sign in to Koboyo`})})]});case`plan-required`:return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(SM,{children:`Save to cloud is part of Koboyo Pro`}),(0,Q.jsx)(CM,{children:e.message}),e.account&&(0,Q.jsxs)(`p`,{className:`m-0 mt-1.5 text-[12px] text-[var(--chrome-fg-500)]`,children:[`Signed in as `,e.account]}),(0,Q.jsxs)(wM,{children:[(0,Q.jsx)(`button`,{type:`button`,className:xM,onClick:()=>void c(t),children:`I've started it`}),(0,Q.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:bM,children:`Start free trial`})]})]});case`choose-workspace`:return(0,Q.jsx)(EM,{message:e.message,workspaces:e.workspaces,onPick:e=>void c(t,e)});case`changed`:return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(SM,{children:`Changed on koboyo.com`}),(0,Q.jsxs)(CM,{children:[e.message,` `,(0,Q.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`font-medium text-[var(--chrome-fg-900)] underline underline-offset-2`,children:`See it`})]}),(0,Q.jsxs)(wM,{children:[(0,Q.jsx)(`button`,{type:`button`,className:xM,onClick:()=>void c(`new`),children:`Save as new board`}),(0,Q.jsx)(`button`,{type:`button`,className:bM,onClick:()=>void c(`replace`),children:`Replace it`})]})]});case`failed`:case`unavailable`:return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(SM,{children:`Not saved`}),(0,Q.jsx)(CM,{children:e.message}),e.status===`failed`&&(0,Q.jsx)(wM,{children:(0,Q.jsx)(`button`,{type:`button`,className:xM,onClick:()=>void c(t),children:`Try again`})})]})}}return(0,Q.jsxs)(Dc,{open:t,onOpenChange:e=>{n(e)},children:[(0,Q.jsxs)(Ca,{"data-testid":`save-to-cloud`,className:`${yM} text-[var(--chrome-fg-700)] hover:bg-[var(--chrome-hover)]`,onClick:e=>{e.preventDefault(),!(t&&r.kind===`signing-in`)&&c()},children:[(0,Q.jsx)($f,{size:16,stroke:1.75,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`max-sm:hidden`,children:`Save to cloud`}),(0,Q.jsx)(`span`,{className:`rounded-md bg-[var(--cta-save-bg)] px-1.5 py-px text-[10.5px] font-semibold uppercase tracking-wide text-[var(--cta-save-fg)]`,children:`Pro`})]}),(0,Q.jsx)(Mc,{children:(0,Q.jsx)(Lc,{sideOffset:8,align:`end`,className:`z-[70]`,children:(0,Q.jsx)(Rc,{"data-testid":`cloud-panel`,className:`${q.popup} w-[320px] p-4 outline-none`,children:u()})})})]})}var OM=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform)?`⌘`:`Ctrl+`;function kM(e){let{state:t,connection:n}=e;return t?t.status===`rejected`?(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1 text-[12.5px] text-[var(--chrome-danger)]`,children:[(0,Q.jsx)(Rs,{size:14,stroke:1.75,className:`shrink-0`,"aria-hidden":!0}),(0,Q.jsxs)(`span`,{className:`truncate`,children:[`Not saved: `,t.detail??`the board was refused`]})]}):t.status===`offline`||n===`lost`&&t.status!==`saved`?(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1 text-[12.5px] text-[var(--chrome-danger)]`,children:[(0,Q.jsx)(Rs,{size:14,stroke:1.75,className:`shrink-0`,"aria-hidden":!0}),(0,Q.jsxs)(`span`,{className:`truncate`,children:[`Not saved: `,t.detail??`koboyo isn't answering`,`. Retrying…`]})]}):null:null}function AM(e){return(0,Q.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 rounded-full bg-[var(--cta-save-bg)] px-2 py-0.5 text-[12px] font-medium text-[var(--cta-save-fg)]`,title:`You changed the drawing by hand, so ${e.file.label} no longer describes it. If the code changes, you'll be asked before your edits are replaced.`,children:[(0,Q.jsx)(lp,{size:13,stroke:1.75,"aria-hidden":!0}),`Hand-edited`]})}var jM=`flex h-8 shrink-0 cursor-pointer items-center gap-1.5 rounded-lg px-3 text-[13px] font-medium outline-none transition-colors disabled:cursor-default disabled:opacity-60`;function MM(e){let[t,n]=(0,J.useState)(!1),[r,i]=(0,J.useState)(``),{onSend:a}=e;async function o(){await a(r.trim())&&(n(!1),i(``))}let s=(0,J.useRef)(o);return s.current=o,(0,J.useEffect)(()=>{let e=e=>{if(e.key!==`Enter`||!(e.metaKey||e.ctrlKey)||e.defaultPrevented)return;let t=e.target,n=t?.dataset.sendNote!==void 0;(t?.isContentEditable||t?.tagName===`TEXTAREA`||t?.tagName===`INPUT`)&&!n||(e.preventDefault(),s.current())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,Q.jsxs)(Dc,{open:t,onOpenChange:n,children:[(0,Q.jsxs)(Ca,{"data-testid":`send-back`,className:`${jM} bg-[var(--chrome-accent)] text-white hover:bg-[var(--chrome-accent-hover)]`,children:[(0,Q.jsx)(Lp,{size:15,stroke:1.75,"aria-hidden":!0}),(0,Q.jsxs)(`span`,{children:[`Send back to `,e.agent]})]}),(0,Q.jsx)(Mc,{children:(0,Q.jsx)(Lc,{sideOffset:8,align:`end`,className:`z-[70]`,children:(0,Q.jsxs)(Rc,{className:`${q.popup} w-[340px] p-3 outline-none`,children:[(0,Q.jsxs)(`label`,{htmlFor:`send-note`,className:`block px-1 pb-1.5 text-[12.5px] font-medium text-[var(--chrome-fg-700)]`,children:[`Add a note for `,e.agent,` `,(0,Q.jsx)(`span`,{className:`font-normal text-[var(--chrome-fg-500)]`,children:`(optional)`})]}),(0,Q.jsx)(`textarea`,{id:`send-note`,"data-send-note":``,autoFocus:!0,rows:3,maxLength:2e3,value:r,onChange:e=>i(e.target.value),placeholder:`e.g. the cache sits in front of Postgres`,className:`block w-full resize-none rounded-lg bg-[var(--chrome-rest)] px-2.5 py-2 text-[13px] leading-5 text-[var(--chrome-fg-900)] outline-none ring-1 ring-[var(--chrome-input)] placeholder:text-[var(--chrome-fg-400)] focus:ring-[var(--chrome-input-hover)]`}),(0,Q.jsxs)(`div`,{className:`mt-2.5 flex items-center justify-between gap-2 px-1`,children:[(0,Q.jsxs)(`span`,{className:`text-[12px] text-[var(--chrome-fg-500)]`,children:[e.openComments>0&&(0,Q.jsxs)(Q.Fragment,{children:[e.openComments===1?`Your comment goes with it`:`${String(e.openComments)} comments go with it`,` · `]}),OM,`↵ to send`]}),(0,Q.jsx)(`button`,{type:`button`,disabled:e.sending,onClick:()=>void o(),className:`${jM} bg-[var(--chrome-accent)] text-white hover:bg-[var(--chrome-accent-hover)]`,children:e.sending?`Sending…`:`Send`})]})]})})})]})}function NM(e){let{file:t,state:n,ended:r}=e,i=n?.code??null,a=t!==null&&r===null;return(0,Q.jsxs)(`header`,{"data-testid":`host-bar`,"data-save-state":n?.status??`none`,className:`absolute inset-x-0 top-0 z-[60] flex items-center gap-3 border-b border-[var(--chrome-divider)] bg-[var(--chrome-page)] px-3 sm:px-4`,style:{height:48},children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2.5`,children:[(0,Q.jsx)(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-[var(--chrome-fg-900)] text-[var(--chrome-page)]`,children:(0,Q.jsx)(FA,{size:18})}),(0,Q.jsx)(`span`,{className:`text-[14px] font-medium tracking-tight text-[var(--chrome-fg-900)] max-sm:hidden`,children:`Koboyo`}),t&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`text-[var(--chrome-fg-300)]`,"aria-hidden":!0,children:`/`}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-[13.5px] text-[var(--chrome-fg-700)]`,title:t.kind===`code`?`${t.label} · edits save to ${t.board}`:t.label,children:t.label})]}),t&&n?.handEdited&&(0,Q.jsx)(AM,{file:t}),a&&i?.agentChanged&&(0,Q.jsx)(hM,{file:t,onKeepMine:()=>e.onChoose(`mine`),onUseAgent:()=>e.onChoose(`agent`)}),a&&i&&i.errors.length>0&&(0,Q.jsx)(gM,{file:t,errors:i.errors}),a&&(0,Q.jsx)(kM,{state:n,connection:e.connection})]}),a&&(0,Q.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center gap-1.5`,children:[e.waiting&&e.choice&&(0,Q.jsx)(mM,{agent:e.agent,choice:e.choice,picking:e.sending,onReveal:e.onReveal,onPick:e.onPick}),e.waiting&&e.note&&(0,Q.jsx)(pM,{agent:e.agent,message:e.note}),(0,Q.jsx)(DM,{file:t,flush:e.flush,subscribe:e.subscribe}),e.waiting&&(0,Q.jsx)(MM,{agent:e.agent,openComments:n?.openComments??0,sending:e.sending,onSend:e.onSend})]})]})}function PM(e){let t=e.lastIndexOf(`/`);return t===-1?{directory:``,name:e}:{directory:e.slice(0,t+1),name:e.slice(t+1)}}function FM(e){return(0,Q.jsxs)(`nav`,{"aria-label":`Diagrams`,className:`scrollbar-slim absolute bottom-0 left-0 z-[50] overflow-y-auto border-r border-[var(--chrome-divider)] bg-[var(--chrome-sidebar)] p-2`,style:{top:48,width:240},children:[(0,Q.jsx)(`p`,{className:`m-0 px-2 pb-1.5 pt-1 text-[12px] font-medium text-[var(--chrome-fg-500)]`,children:e.files.length===1?`1 diagram`:`${e.files.length} diagrams`}),(0,Q.jsx)(`ul`,{className:`m-0 list-none space-y-0.5 p-0`,children:e.files.map(t=>{let n=t.id===e.active,r=PM(t.id),i=t.kind===`code`?ec:vp;return(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(`button`,{type:`button`,"aria-current":n?`page`:void 0,onClick:()=>e.onOpen(t.id),title:t.label,className:`flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 text-left text-[13px] transition-colors ${n?`bg-[var(--chrome-active)] text-[var(--chrome-fg-900)]`:`text-[var(--chrome-fg-700)] hover:bg-[var(--chrome-sidebar-hover)]`}`,children:[(0,Q.jsx)(i,{size:15,stroke:1.75,className:`shrink-0 text-[var(--chrome-fg-500)]`,"aria-hidden":!0}),(0,Q.jsxs)(`span`,{className:`min-w-0 truncate`,children:[r.directory&&(0,Q.jsx)(`span`,{className:`text-[var(--chrome-fg-500)]`,children:r.directory}),r.name]})]})},t.id)})})]})}var IM=15e3;function LM(e){let[t,n]=(0,J.useState)(`connecting`),r=(0,J.useRef)(e);return r.current=e,(0,J.useEffect)(()=>{let e=new EventSource(`/api/events`),t=Date.now(),i=!1,a=e=>{e.onopen=()=>{t=Date.now(),n(`open`)},e.onerror=()=>{i||n(`lost`)},e.addEventListener(`ping`,()=>{t=Date.now()}),e.onmessage=n=>{t=Date.now();let a=JSON.parse(n.data);a.type===`shutdown`&&(i=!0,e.close()),r.current(a)}};a(e);let o=setInterval(()=>{i||!e||Date.now()-t<15e3*3||(e.close(),n(`lost`),e=new EventSource(`/api/events`),t=Date.now(),a(e))},IM);return()=>{i=!0,clearInterval(o),e?.close(),e=null}},[]),t}function RM(){let e=new URL(window.location.href),t=e.searchParams.get(`t`);return t!==null&&(e.searchParams.delete(`t`),window.history.replaceState(null,``,`${e.pathname}${e.search}${e.hash}`)),t}function zM(){let[e,t]=(0,J.useState)({kind:`signing-in`});return(0,J.useEffect)(()=>{let e=!0;return Rl(RM()).then(n=>{e&&t({kind:`ready`,session:n})}).catch(n=>{e&&t({kind:`refused`,message:n instanceof Error?n.message:String(n)})}),()=>{e=!1}},[]),e.kind===`signing-in`?null:e.kind===`refused`?(0,Q.jsx)(BM,{message:e.message}):(0,Q.jsx)(VM,{initial:e.session})}function BM(e){return(0,Q.jsx)(`div`,{className:`flex h-full items-center justify-center bg-[var(--chrome-page)] p-6`,children:(0,Q.jsxs)(`div`,{className:`max-w-[420px] text-center`,children:[(0,Q.jsx)(`p`,{className:`m-0 text-balance text-[15px] font-medium text-[var(--chrome-fg-900)]`,children:`This editor link can't be opened`}),(0,Q.jsx)(`p`,{className:`m-0 mt-2 text-balance text-[13.5px] leading-5 text-[var(--chrome-fg-600)]`,children:e.message})]})})}function VM(e){let[t,n]=(0,J.useState)(e.initial),[r,i]=(0,J.useState)(e.initial.initialFile),[a,o]=(0,J.useState)(null),[s,c]=(0,J.useState)(null),[l,u]=(0,J.useState)(!1),d=(0,J.useMemo)(()=>crypto.randomUUID(),[]),f=(0,J.useRef)(null),p=(0,J.useRef)(new Map),m=(0,J.useRef)(new Set),h=(0,J.useRef)(`Your agent`),g=(0,J.useRef)(!1),_=(0,J.useRef)(e.initial.wait),v=LM((0,J.useCallback)(e=>{if(e.type===`session`){let t=_.current,r=e.session.wait;t.waiting&&!r.waiting&&g.current&&(g.current=!1,t.endsSession||Jj.notify(`Sent to ${t.agent}.`)),_.current=r,n(e.session);return}e.type===`shutdown`&&c(e.reason);for(let t of m.current)t(e)},[])),y=(0,J.useCallback)(e=>(m.current.add(e),()=>{m.current.delete(e)}),[]);t.wait.waiting&&(h.current=t.wait.agent);let b=t.files.find(e=>e.id===r)??t.files[0]??null,x=t.wait.waiting&&s===null,S=(0,J.useCallback)(async e=>{if(e!==b?.id){if(!(await f.current?.flush()??!0)){Jj.notify(`Couldn't save ${b?.label??`this file`}, so it stays open. Your edits are kept in this browser.`);return}o(null),i(e)}},[b?.id,b?.label]),C=(0,J.useCallback)(async(e,t=null)=>{if(!x||l)return!1;u(!0);try{return await f.current?.flush()??!0?(g.current=!0,await Gl(b?.id??null,e,t),!0):(Jj.notify(`Your latest edits aren't saved yet, so nothing was sent.`),!1)}catch(e){return g.current=!1,Jj.notify(e instanceof Error?e.message:String(e)),!1}finally{u(!1)}},[x,l,b?.id]),w=(0,J.useCallback)(async()=>await f.current?.flush()??!0,[]),T=(0,J.useCallback)(async e=>{if(b)try{await f.current?.flush();let t=await Wl(b.id,e);o(e=>e&&{...e,code:t})}catch(e){Jj.notify(e instanceof Error?e.message:String(e))}},[b]),E=(0,J.useCallback)(e=>{b&&p.current.set(b.id,e)},[b]),D=t.folder;return(0,J.useEffect)(()=>(document.documentElement.style.setProperty(`--koboyo-host-inset-top`,`48px`),()=>{document.documentElement.style.removeProperty(`--koboyo-host-inset-top`)}),[]),(0,Q.jsxs)(`div`,{className:`fixed inset-0`,children:[(0,Q.jsx)(`div`,{className:`absolute inset-y-0 right-0`,style:{left:D?240:0},children:b?(0,Q.jsx)(sM,{file:b,client:d,readOnly:s!==null,initialViewport:p.current.get(b.id)??null,viewInset:{left:D?240:0,top:48},onViewport:E,onState:o,subscribe:y,handle:f},b.id):(0,Q.jsx)(`div`,{className:`flex h-full items-center justify-center text-[13.5px] text-[var(--chrome-fg-500)] text-balance px-6 text-center`,children:`No diagrams in this folder yet. Add a .kbd file and it shows up here.`})}),(0,Q.jsx)(NM,{file:b,state:a,connection:v,ended:s,waiting:x,agent:h.current,note:t.wait.waiting?t.wait.message:null,choice:t.wait.waiting?t.wait.choice:null,sending:l,onSend:C,onReveal:e=>f.current?.reveal([e]),onPick:e=>void C(``,e),onChoose:e=>void T(e),flush:w,subscribe:y}),D&&(0,Q.jsx)(FM,{files:t.files,active:b?.id??null,onOpen:e=>void S(e)}),s!==null&&(0,Q.jsx)(vM,{reason:s,agent:h.current,board:b?.board??null})]})}function HM(){let e=`<svg xmlns="http://www.w3.org/2000/svg" width="34" height="34" viewBox="0 0 34 34" fill="none"><style>.b{fill:#000}.m{stroke:#fff}@media (prefers-color-scheme:dark){.b{fill:#fff}.m{stroke:#000}}</style><rect class="b" width="34" height="34" rx="7"/><path class="m" d="${PA}" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`,t=document.createElement(`link`);t.rel=`icon`,t.type=`image/svg+xml`,t.href=`data:image/svg+xml,${encodeURIComponent(e)}`,document.head.appendChild(t)}HM();var UM=document.getElementById(`root`);UM&&(0,Il.createRoot)(UM).render((0,Q.jsx)(J.StrictMode,{children:(0,Q.jsx)(v,{controller:Jj,children:(0,Q.jsx)(zM,{})})}));