@1agh/maude 2.0.4 → 2.0.8

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 (272) hide show
  1. package/apps/hub/src/project-transactions/kernel.mjs +10 -1
  2. package/apps/studio/access/closure.ts +156 -16
  3. package/apps/studio/access/filters.ts +39 -5
  4. package/apps/studio/access/known-canvases.ts +24 -1
  5. package/apps/studio/access/refused-inputs.ts +89 -0
  6. package/apps/studio/actions/agents.ts +59 -0
  7. package/apps/studio/actions/ctx.ts +3 -0
  8. package/apps/studio/actions/defs/app.ts +12 -0
  9. package/apps/studio/actions/defs/sync.ts +13 -0
  10. package/apps/studio/actions/defs/view.ts +59 -3
  11. package/apps/studio/actions/keymap.gen.ts +35 -0
  12. package/apps/studio/actions/menu.ts +2 -0
  13. package/apps/studio/actions/types.ts +3 -1
  14. package/apps/studio/actions.manifest.json +148 -1
  15. package/apps/studio/actions.parity.json +31 -1
  16. package/apps/studio/annotations/ui/ai-seen.tsx +4 -3
  17. package/apps/studio/annotations/ui/element-node.tsx +139 -54
  18. package/apps/studio/annotations/ui/lod.tsx +1 -1
  19. package/apps/studio/annotations/ui/ride.ts +2 -1
  20. package/apps/studio/annotations/ui/text-style.ts +1 -1
  21. package/apps/studio/annotations-context-toolbar.tsx +5 -4
  22. package/apps/studio/annotations-layer.tsx +4 -15
  23. package/apps/studio/api.ts +425 -128
  24. package/apps/studio/artboard-activity-overlay.tsx +4 -4
  25. package/apps/studio/artboard-ai-copies.tsx +4 -4
  26. package/apps/studio/artboard-freeze.ts +108 -0
  27. package/apps/studio/artboard-live-gate.tsx +636 -0
  28. package/apps/studio/artboard-live.ts +831 -0
  29. package/apps/studio/artboard-placeholder.ts +197 -0
  30. package/apps/studio/artboard-still-raster.ts +485 -0
  31. package/apps/studio/artboard-still-warmup.ts +221 -0
  32. package/apps/studio/artboard-still.ts +1188 -0
  33. package/apps/studio/artboard-webgl.ts +669 -0
  34. package/apps/studio/asset-placeholder.tsx +237 -132
  35. package/apps/studio/asset-upload-bars.tsx +4 -4
  36. package/apps/studio/bin/_agent-browser-bin.mjs +8 -0
  37. package/apps/studio/bin/_agent-browser-safe.mjs +2 -1
  38. package/apps/studio/bin/_canvas-reasons.mjs +34 -0
  39. package/apps/studio/bin/_ds-check-live.mjs +37 -0
  40. package/apps/studio/bin/_ds-check.mjs +4 -1
  41. package/apps/studio/bin/_ds-prove-judge.mjs +167 -0
  42. package/apps/studio/bin/_ds-prove-playwright.mjs +183 -105
  43. package/apps/studio/bin/_import-asset.mjs +2 -1
  44. package/apps/studio/bin/_perf-probe-open.mjs +364 -0
  45. package/apps/studio/bin/_perf-probe.mjs +2 -1
  46. package/apps/studio/bin/_perf-shared.mjs +12 -7
  47. package/apps/studio/bin/_pw-launch.mjs +26 -1
  48. package/apps/studio/bin/_studio-verb.mjs +24 -3
  49. package/apps/studio/bin/_thumb-blank.mjs +70 -0
  50. package/apps/studio/bin/_thumb-cover.mjs +35 -0
  51. package/apps/studio/bin/_thumbs-playwright.mjs +89 -12
  52. package/apps/studio/bin/ds-check.sh +5 -1
  53. package/apps/studio/bin/perf.sh +30 -1
  54. package/apps/studio/bin/server-up.sh +7 -2
  55. package/apps/studio/bin/smoke.sh +19 -0
  56. package/apps/studio/bridge/dgn-protocol.ts +35 -0
  57. package/apps/studio/canvas-build-sandbox.ts +69 -13
  58. package/apps/studio/canvas-camera.ts +90 -0
  59. package/apps/studio/canvas-comment-mount.tsx +9 -9
  60. package/apps/studio/canvas-lib.tsx +289 -44
  61. package/apps/studio/canvas-pages-view.tsx +465 -0
  62. package/apps/studio/canvas-pages.ts +305 -0
  63. package/apps/studio/canvas-rows.ts +62 -0
  64. package/apps/studio/canvas-shell.tsx +62 -16
  65. package/apps/studio/canvas-theme-icons.tsx +41 -0
  66. package/apps/studio/canvas-theme-pill.tsx +15 -6
  67. package/apps/studio/canvas-theme.ts +12 -11
  68. package/apps/studio/client/app.jsx +7 -0
  69. package/apps/studio/client/canvas-url.js +36 -1
  70. package/apps/studio/client/home/HomeAccounts.jsx +262 -0
  71. package/apps/studio/client/home/Shelves.jsx +4 -3
  72. package/apps/studio/client/home/home-accounts-model.js +121 -0
  73. package/apps/studio/client/home/home-api.js +6 -0
  74. package/apps/studio/client/home/home-app.jsx +141 -40
  75. package/apps/studio/client/home/home-model.js +172 -6
  76. package/apps/studio/client/home/home.css +169 -5
  77. package/apps/studio/client/home/shell-mode.js +8 -1
  78. package/apps/studio/client/hooks/canvas-origin-probe.js +34 -0
  79. package/apps/studio/client/hooks/use-action-keys.jsx +3 -1
  80. package/apps/studio/client/hooks/use-canvas-bridge.jsx +1 -1
  81. package/apps/studio/client/hooks/use-palette-and-panels.jsx +23 -6
  82. package/apps/studio/client/hooks/use-photo-and-timeline.jsx +16 -8
  83. package/apps/studio/client/hooks/use-project-data.jsx +13 -2
  84. package/apps/studio/client/hooks/use-shell-core.jsx +19 -9
  85. package/apps/studio/client/index-loader.ts +41 -21
  86. package/apps/studio/client/inspector/inspector-panel.jsx +35 -14
  87. package/apps/studio/client/panels/ChatPanel.jsx +27 -20
  88. package/apps/studio/client/panels/CreateProject.jsx +19 -5
  89. package/apps/studio/client/panels/caps-cache.js +46 -0
  90. package/apps/studio/client/shell/viewport.jsx +66 -22
  91. package/apps/studio/client/tree/tree.jsx +17 -0
  92. package/apps/studio/client/v2/access/access-client.js +2 -0
  93. package/apps/studio/client/v2/access/access-host.jsx +12 -1
  94. package/apps/studio/client/v2/access/trashed-banner.jsx +6 -3
  95. package/apps/studio/client/v2/ai/Advanced.jsx +12 -0
  96. package/apps/studio/client/v2/ai/Composer.jsx +27 -10
  97. package/apps/studio/client/v2/canvases/canvases-panel.jsx +24 -0
  98. package/apps/studio/client/v2/canvases/use-canvas-index.js +24 -1
  99. package/apps/studio/client/v2/code/canvas-error-card.jsx +14 -2
  100. package/apps/studio/client/v2/code/canvas-imports-card.jsx +19 -14
  101. package/apps/studio/client/v2/code/canvas-imports-words.js +60 -0
  102. package/apps/studio/client/v2/code/canvas-waiting-card.jsx +59 -5
  103. package/apps/studio/client/v2/code/canvas-waiting.js +18 -1
  104. package/apps/studio/client/v2/code/code-bus.js +5 -0
  105. package/apps/studio/client/v2/code/code-consent-sheet.jsx +87 -0
  106. package/apps/studio/client/v2/code/code-consent.js +67 -0
  107. package/apps/studio/client/v2/diagnostics/sync-details/sync-details-model.js +62 -10
  108. package/apps/studio/client/v2/diagnostics/sync-details/sync-details.jsx +314 -5
  109. package/apps/studio/client/v2/ds/advanced-host.jsx +11 -26
  110. package/apps/studio/client/v2/ds/ds-refresh.js +161 -0
  111. package/apps/studio/client/v2/ds/library-host.jsx +45 -45
  112. package/apps/studio/client/v2/ds/make-host.jsx +13 -15
  113. package/apps/studio/client/v2/ds/off-system-host.jsx +18 -19
  114. package/apps/studio/client/v2/ds/review-host.jsx +7 -1
  115. package/apps/studio/client/v2/ds/truth-host.jsx +15 -17
  116. package/apps/studio/client/v2/ds/upgrade-host.jsx +26 -10
  117. package/apps/studio/client/v2/history/branch-actions.js +13 -9
  118. package/apps/studio/client/v2/history/git-advanced.jsx +8 -1
  119. package/apps/studio/client/v2/history/git-model.js +3 -1
  120. package/apps/studio/client/v2/history/git-parts.jsx +16 -1
  121. package/apps/studio/client/v2/layers/artboard-layers.jsx +24 -5
  122. package/apps/studio/client/v2/layers/layers-request.js +49 -0
  123. package/apps/studio/client/v2/left-panel/canvases-pinned.jsx +93 -3
  124. package/apps/studio/client/v2/left-panel/ds-boards.js +39 -0
  125. package/apps/studio/client/v2/left-panel/left-panel-model.js +13 -0
  126. package/apps/studio/client/v2/left-panel/left-panel.css +24 -0
  127. package/apps/studio/client/v2/presence/faces.jsx +42 -14
  128. package/apps/studio/client/v2/shell/account-card.jsx +10 -4
  129. package/apps/studio/client/v2/shell/canvas-crash-guard.js +172 -0
  130. package/apps/studio/client/v2/shell/canvas-mode.js +17 -1
  131. package/apps/studio/client/v2/shell/floating-panels.css +37 -1
  132. package/apps/studio/client/v2/shell/github-signin-host.jsx +42 -0
  133. package/apps/studio/client/v2/shell/menu-runner.js +11 -0
  134. package/apps/studio/client/v2/shell/mode-switch.jsx +14 -3
  135. package/apps/studio/client/v2/shell/opening-skeleton.js +118 -0
  136. package/apps/studio/client/v2/shell/opening-skeleton.jsx +103 -0
  137. package/apps/studio/client/v2/shell/pages-pick.js +49 -0
  138. package/apps/studio/client/v2/shell/project-account-card.jsx +203 -0
  139. package/apps/studio/client/v2/shell/project-account-model.js +182 -0
  140. package/apps/studio/client/v2/shell/project-menu-model.js +3 -0
  141. package/apps/studio/client/v2/shell/share-cluster-host.jsx +140 -11
  142. package/apps/studio/client/v2/shell/share-cluster.css +58 -0
  143. package/apps/studio/client/v2/shell/share-cluster.jsx +26 -7
  144. package/apps/studio/client/v2/shell/shell-parity.json +8 -0
  145. package/apps/studio/client/v2/shell/team-switch.js +94 -0
  146. package/apps/studio/client/v2/shell/too-heavy-card.jsx +38 -0
  147. package/apps/studio/client/v2/shell/use-account.js +8 -1
  148. package/apps/studio/client/v2/shell/use-canvas-mode-lane.js +30 -0
  149. package/apps/studio/collab/persistence.ts +9 -1
  150. package/apps/studio/collab/registry.ts +32 -0
  151. package/apps/studio/collab/room.ts +8 -0
  152. package/apps/studio/comments-overlay.tsx +12 -11
  153. package/apps/studio/config-reload-wire.ts +56 -0
  154. package/apps/studio/config.schema.json +6 -0
  155. package/apps/studio/context.ts +37 -1
  156. package/apps/studio/dist/client.bundle.js +1198 -1198
  157. package/apps/studio/dist/comment-mount.js +2 -2
  158. package/apps/studio/dist/styles.css +1 -1
  159. package/apps/studio/ds/board/board.css +6 -0
  160. package/apps/studio/ds/board/ds-bar.tsx +21 -3
  161. package/apps/studio/ds/board/specimen.tsx +16 -2
  162. package/apps/studio/ds/board/template.ts +39 -19
  163. package/apps/studio/ds/canvas-cli.ts +58 -2
  164. package/apps/studio/ds/check.ts +26 -1
  165. package/apps/studio/ds/cli.ts +14 -4
  166. package/apps/studio/ds/component-list.ts +2 -1
  167. package/apps/studio/ds/convert.ts +34 -6
  168. package/apps/studio/ds/default.ts +6 -1
  169. package/apps/studio/ds/ds-resolver.ts +58 -8
  170. package/apps/studio/ds/ds-verb.ts +13 -0
  171. package/apps/studio/ds/engine.ts +3 -1
  172. package/apps/studio/ds/folder-systems.ts +199 -0
  173. package/apps/studio/ds/pairing-css.ts +2 -1
  174. package/apps/studio/ds/post-build.ts +38 -0
  175. package/apps/studio/ds/rename.ts +10 -3
  176. package/apps/studio/ds/shell-fallbacks.ts +2 -1
  177. package/apps/studio/ds/upgrade-apply.ts +27 -5
  178. package/apps/studio/ds/upgrade-cli.ts +22 -2
  179. package/apps/studio/ds/upgrade-prove.ts +198 -15
  180. package/apps/studio/ds/upgrade-stage.ts +10 -3
  181. package/apps/studio/editing/ai-point-ring.tsx +4 -4
  182. package/apps/studio/editing/ai-scope-outline.tsx +4 -4
  183. package/apps/studio/editing/align-bar.tsx +4 -4
  184. package/apps/studio/editing/anchor-report.ts +3 -2
  185. package/apps/studio/editing/artboard-handles.tsx +4 -4
  186. package/apps/studio/editing/corner-dots.tsx +4 -4
  187. package/apps/studio/editing/crop-mode.tsx +4 -4
  188. package/apps/studio/editing/drop-chip.tsx +4 -4
  189. package/apps/studio/editing/empty-report.ts +3 -2
  190. package/apps/studio/editing/focus-model.tsx +4 -4
  191. package/apps/studio/editing/gap-bands.tsx +3 -3
  192. package/apps/studio/editing/hold-rings.tsx +4 -4
  193. package/apps/studio/editing/lock-badge.tsx +3 -3
  194. package/apps/studio/editing/long-page.ts +23 -1
  195. package/apps/studio/editing/nudge.tsx +2 -2
  196. package/apps/studio/editing/page-activity.ts +4 -3
  197. package/apps/studio/editing/paste-bar.tsx +4 -4
  198. package/apps/studio/editing/pen/overlay.tsx +4 -3
  199. package/apps/studio/editing/place-freely.tsx +3 -3
  200. package/apps/studio/editing/reorder-slot.tsx +3 -3
  201. package/apps/studio/editing/selection.tsx +4 -4
  202. package/apps/studio/editing/size-ghost.tsx +4 -4
  203. package/apps/studio/editing/tab-order.tsx +4 -4
  204. package/apps/studio/editing/text-in-place.tsx +4 -4
  205. package/apps/studio/editing/undo-preview.tsx +3 -3
  206. package/apps/studio/equal-spacing-handles.tsx +3 -3
  207. package/apps/studio/frame-clock.ts +89 -0
  208. package/apps/studio/history/trash.ts +6 -0
  209. package/apps/studio/home/accounts.ts +87 -0
  210. package/apps/studio/home/index-reader.ts +24 -2
  211. package/apps/studio/home/routes.ts +19 -0
  212. package/apps/studio/http.ts +80 -34
  213. package/apps/studio/index/ds-usage.ts +4 -1
  214. package/apps/studio/index-cache.ts +272 -0
  215. package/apps/studio/inspect-overlay.tsx +4 -3
  216. package/apps/studio/inspect.ts +7 -2
  217. package/apps/studio/link-chip-overlay.tsx +4 -3
  218. package/apps/studio/measure-overlay.tsx +4 -3
  219. package/apps/studio/present/pointer-dot.tsx +3 -2
  220. package/apps/studio/present/present-media.ts +6 -2
  221. package/apps/studio/present/present-stage.tsx +3 -2
  222. package/apps/studio/preview/preview-camera.tsx +3 -2
  223. package/apps/studio/routes/ds-convert.ts +18 -0
  224. package/apps/studio/routes/sync.ts +176 -0
  225. package/apps/studio/routes/trash.ts +16 -1
  226. package/apps/studio/safe-zones-overlay.tsx +3 -2
  227. package/apps/studio/server.ts +8 -10
  228. package/apps/studio/skip-dirs.ts +103 -47
  229. package/apps/studio/studio-page-host.ts +70 -0
  230. package/apps/studio/sync/accepted-cold-start.ts +28 -13
  231. package/apps/studio/sync/asset-push.ts +146 -23
  232. package/apps/studio/sync/asset-state.ts +3 -2
  233. package/apps/studio/sync/code-module-consent.ts +86 -0
  234. package/apps/studio/sync/file-ledger.ts +24 -0
  235. package/apps/studio/sync/file-membership.ts +28 -3
  236. package/apps/studio/sync/file-plane.ts +497 -61
  237. package/apps/studio/sync/file-pull.ts +304 -33
  238. package/apps/studio/sync/held-deletes.ts +230 -0
  239. package/apps/studio/sync/hub-link.ts +1 -2
  240. package/apps/studio/sync/hubs-config.ts +59 -2
  241. package/apps/studio/sync/index.ts +405 -163
  242. package/apps/studio/sync/journal-client.ts +94 -5
  243. package/apps/studio/sync/pending-deletes.ts +100 -0
  244. package/apps/studio/sync/projection.ts +77 -12
  245. package/apps/studio/sync/seed-progress.ts +104 -3
  246. package/apps/studio/sync/settings.ts +36 -1
  247. package/apps/studio/sync/status.ts +17 -1
  248. package/apps/studio/sync/writer-registry.ts +5 -0
  249. package/apps/studio/text-caret.ts +5 -3
  250. package/apps/studio/thumbs/service.ts +12 -2
  251. package/apps/studio/thumbs/validate.ts +7 -0
  252. package/apps/studio/toolbars/toolbar-rect.ts +3 -2
  253. package/apps/studio/ui-prefs-migrate.ts +4 -0
  254. package/apps/studio/use-annotation-resize.tsx +4 -3
  255. package/apps/studio/use-artboard-drag.tsx +3 -2
  256. package/apps/studio/use-element-resize.tsx +7 -6
  257. package/apps/studio/use-grid-track-handles.tsx +5 -4
  258. package/apps/studio/use-selection-set.tsx +64 -4
  259. package/apps/studio/use-spacing-handles.tsx +7 -6
  260. package/apps/studio/video-comp.tsx +75 -39
  261. package/apps/studio/video-play-overlay.tsx +4 -3
  262. package/apps/studio/whats-new.json +99 -0
  263. package/cli/commands/design.mjs +5 -2
  264. package/cli/commands/hub.mjs +10 -1
  265. package/cli/lib/bash-guard.mjs +27 -1
  266. package/cli/lib/design-help.gen.mjs +1 -1
  267. package/cli/lib/design-hook.mjs +20 -0
  268. package/cli/lib/design-link.mjs +42 -17
  269. package/cli/lib/hub-purge.mjs +183 -0
  270. package/cli/lib/studio-locate.mjs +35 -10
  271. package/package.json +8 -8
  272. package/plugins/design/templates/_shell.html +164 -1
@@ -1,4 +1,4 @@
1
- import{Component as Xc,createElement as Jn,useCallback as Gn,useEffect as ye,useMemo as Qc,useRef as we,useState as Ze}from"react";import{createRoot as Yc}from"react-dom/client";function Os(e,t){if(e==="present")return t?.kind==="artboards"?"present-artboards":"present-canvas";return e}var fe=(e,t,n,o,r)=>Object.freeze({edit:e,preview:t,"present-artboards":n,"present-canvas":o,viewing:r}),Ns=Object.freeze({clicks:fe("tool","live","next-artboard","pan-zoom","specs"),toolbar:fe("edit","preview","none","none","viewing"),annotations:fe("quiet","drawn","hidden","hidden","read-only"),"comment-pins":fe("shown","shown","hidden","hidden","shown"),measure:fe("on","on","off","off","on"),"ai-changes":fe("live","live","held","live-unmarked","live"),"left-panels":fe("shown","folded","hidden","hidden","shown"),"ai-panel":fe("shown","folded","hidden","hidden","none"),"share-cluster":fe("full","full","hidden","hidden","full-access"),inspect:fe("inspector","panel-on-cmd-click","hidden","hidden","panel-on-click"),"project-menu":fe("pill","pill","esc-first","esc-first","pill"),esc:fe("steps-back","steps-back","settles-back","same-view","deselect")});function Ne(e,t,n){return Ns[e][Os(t,n)]}var Ds=Object.freeze({measure:(e,t)=>Ne("measure",e,t)==="on","inspect-panel":(e,t)=>Ne("inspect",e,t).startsWith("panel"),"comment-pins":(e,t)=>Ne("comment-pins",e,t)==="shown","object-tools":(e,t)=>Ne("clicks",e,t)==="tool","live-design":(e,t)=>Ne("clicks",e,t)==="live","annotations-editable":(e,t)=>Ne("annotations",e,t)==="drawn",chrome:(e,t)=>Ne("share-cluster",e,t)!=="hidden"});function pt(e,t,n){if(!e)return t==="measure"||t==="comment-pins"||t==="object-tools";return Ds[t](e,n)}var Bt=["edit","viewing","preview","present"],oo=["artboards","canvas"],Xt=["browse","move","hand","comment","pen","highlighter","eraser","shape","sticky","section","arrow","text"],Ks=["inspect","frame","el-shape","el-pen","el-text","image","component","line","ellipse","polygon","crop","slice","pointer"],Qt=[...Xt,...Ks],md=new Set(Bt),zs=new Set(Qt);var Vs=(e)=>typeof e==="string"&&zs.has(e),fd=Object.freeze({edit:!1,annotate:!1,comment:!1}),ro=Object.freeze({edit:!0,annotate:!0,comment:!0}),so=(e)=>e.edit?"edit":"viewing";function io(e,t){if(e==="edit"&&!t.edit)return"viewing";if(e==="viewing"&&t.edit)return"edit";return e}var ao=Object.freeze({edit:"edit",viewing:"edit",preview:"preview",present:"preview"}),Yt=Object.freeze({edit:"move",viewing:"inspect",preview:"browse",present:"browse"}),to=Object.freeze({view:0,comment:1,edit:2});function Hs(e){if(e.edit||e.annotate)return"edit";return e.comment?"comment":"view"}var J=(e)=>Object.freeze(e),Je=Object.freeze({edit:Object.freeze({rest:"move",slots:Object.freeze([J({key:"V",label:"Select",tool:"move",minRole:"edit"}),J({key:"H",label:"Hand",tool:"hand",minRole:"edit"}),J({key:"F",label:"Artboard / Frame",tool:"frame",minRole:"edit"}),J({key:"R",label:"Shape",tool:"el-shape",minRole:"edit"}),J({key:"P",label:"Pen",tool:"el-pen",minRole:"edit"}),J({key:"T",label:"Text",tool:"el-text",minRole:"edit"}),J({key:"I",label:"Image",tool:"image",minRole:"edit",panel:"image",panelFirst:!0}),J({key:"⇧I",label:"Component",tool:null,minRole:"edit",panel:"components"}),J({key:"",label:"More",tool:null,minRole:"edit",popover:"more",more:Object.freeze([J({key:"",label:"Line",tool:"line",minRole:"edit"}),J({key:"",label:"Ellipse",tool:"ellipse",minRole:"edit"}),J({key:"",label:"Polygon",tool:"polygon",minRole:"edit"}),J({key:"",label:"Crop",tool:"crop",minRole:"edit"}),J({key:"",label:"Export area",tool:"slice",minRole:"edit"})])})])}),preview:Object.freeze({rest:"browse",slots:Object.freeze([J({key:"V",label:"Select",tool:"browse",minRole:"view"}),J({key:"H",label:"Hand",tool:"hand",minRole:"view"}),J({key:"N",label:"Sticky",tool:"sticky",minRole:"edit",popover:"sticky-colours"}),J({key:"C",label:"Comment",tool:"comment",minRole:"comment"}),J({key:"M",label:"Marker",tool:"pen",minRole:"edit",popover:"marker-tips",tips:["pen","highlighter","eraser"]}),J({key:"A",label:"Arrow",tool:"arrow",minRole:"edit"}),J({key:"R",label:"Shape",tool:"shape",minRole:"edit",popover:"shape-kinds"}),J({key:"T",label:"Text",tool:"text",minRole:"edit"}),J({key:"E",label:"Stickers",tool:null,minRole:"edit",panel:"stickers"}),J({key:"S",label:"Section",tool:"section",minRole:"edit",panel:"templates"})])}),viewing:Object.freeze({rest:"inspect",slots:Object.freeze([J({key:"H",label:"Hand",tool:"inspect",minRole:"view"}),J({key:"C",label:"Comment",tool:"comment",minRole:"comment"})])}),present:Object.freeze({rest:"browse",hidden:!0,slots:Object.freeze([J({key:"L",label:"Pointer",tool:"pointer",minRole:"view"})])})}),Gt=Object.freeze({});function lo(e,t){if(t(e))return e;let n=Gt[e];return n&&t(n)?n:null}var Fs=Object.freeze({edit:["preview"],preview:["edit"],viewing:["preview","edit"],present:[]});function $s(e,t){for(let n of[e,...Fs[e]]){let o=Je[n].slots.find((r)=>r.key===t);if(o)return{mode:n,slot:o}}return null}function co(e,t,n,o){let r=$s(e,t);if(!r||r.slot.pending)return null;let{slot:s}=r,a=!!s.panel&&(s.tool===null||!!s.panelFirst),c=s.insert||s.panelFirst?null:s.tips&&o&&s.tips.includes(o)?o:s.tool,p=Hs(n);if(to[p]<to[s.minRole]||r.mode==="edit"&&!n.edit){if(c)return{kind:"deny",mode:r.mode,tool:c};return a&&s.panel?{kind:"deny",mode:r.mode,panel:s.panel}:{kind:"deny",mode:r.mode}}if(r.mode!==e){let f={kind:"request",mode:r.mode};if(c)f.tool=c;if(a&&s.panel)f.panel=s.panel;return f}if(s.insert)return{kind:"insert",insert:s.insert};if(c)return{kind:"arm",tool:c};return s.panel?{kind:"panel",panel:s.panel}:null}var qs=new Set(["hand"]);function no(e,t){return Je[e].slots.some((n)=>n.tool===t||n.tool!==null&&Gt[n.tool]===t||!!n.tips?.includes(t)||!!n.lights?.includes(t)||!!n.more?.some((o)=>o.tool===t))}function et(e,t,n){if(!Vs(e)||qs.has(e))return null;if(no(n,e))return n;if(e==="move")return t.edit?"edit":"viewing";for(let o of["preview","edit"])if(no(o,e))return o;return null}function Zt(e,t){if(e==="present")return"back";let n=Je[e].rest;if(t!==n&&Gt[n]!==t)return"rest";return"stay"}var Jt=Object.freeze({top:0,right:0,bottom:0,left:0});function uo(e,t,n){let o=e-n.left-n.right,r=t-n.top-n.bottom,s=o>=240,a=r>=240;return{x:s?n.left:0,y:a?n.top:0,w:s?o:e,h:a?r:t}}function po(e){if(!e||typeof e!=="object"||Array.isArray(e))return null;let t=e,n={top:0,right:0,bottom:0,left:0};for(let o of["top","right","bottom","left"]){let r=t[o];if(typeof r!=="number"||!Number.isFinite(r)||r<0||r>8192)return null;n[o]=Math.round(r)}return n}var js=["image/png","image/jpeg","image/gif","image/webp"],Us=new Set(["dgn","v","text","html","image"]),mo=(e)=>typeof e==="string"&&e.length<=1e6,Ws=(e)=>typeof Blob<"u"&&e instanceof Blob&&js.includes(e.type)&&e.size>0&&e.size<=20971520;function fo(e){if(!e||typeof e!=="object"||Array.isArray(e))return null;let t=e;for(let o of Object.keys(t))if(!Us.has(o))return null;if(t.v!==1)return null;let n={v:1};if(t.text!==void 0){if(!mo(t.text))return null;n.text=t.text}if(t.html!==void 0){if(!mo(t.html))return null;n.html=t.html}if(t.image!==void 0){if(!Ws(t.image))return null;n.image=t.image}return n.text||n.html||n.image?n:null}var Bs=/^data:image\/(?:png|webp|jpeg|gif);base64,[A-Za-z0-9+/]+={0,2}$/;function go(e){return typeof e==="string"&&e.length<=400000&&Bs.test(e)}var Xs=["frame","text","image","path","shape","instance","artboard","multi"],v=Symbol("dgn.bad"),bt=4000,He=1e4,Qs=16,be=(e)=>!!e&&typeof e==="object"&&!Array.isArray(e),u=(e)=>typeof e==="string"&&e.length<=bt?e:v,C=(e)=>typeof e==="number"&&Number.isFinite(e)?e:v,Ys=(e)=>typeof e==="number"&&Number.isFinite(e)&&e>=0&&e<=1?e:v,P=(e)=>typeof e==="boolean"?e:v,Gs=(e)=>go(e)?e:v,ho=(e)=>typeof e==="number"&&Number.isFinite(e)&&e>=0&&e<=86400?e:v,Zs=(e)=>{if(!Array.isArray(e)||e.length>8)return v;for(let t of e)if(typeof t!=="string"||t.length>400)return v;return[...e]},U=(...e)=>(t)=>e.includes(t)?t:v,d=(e)=>(t)=>t===void 0?void 0:e(t),Js=(e)=>typeof e==="string"&&e.length<=48&&/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/.test(e)&&!/^[0-9a-f]{8}$/.test(e)?e:v,Ke=(e)=>typeof e==="string"&&/^[A-Za-z0-9_-]{1,64}$/.test(e)?e:v,_=(e)=>(t)=>t===null?null:e(t),F=(e)=>(t)=>{if(!Array.isArray(t)||t.length>He)return v;let n=[];for(let o of t){let r=e(o);if(r===v)return v;n.push(r)}return n},ge=(e)=>nn(e,0);function nn(e,t){if(e===null||typeof e==="boolean")return e;if(typeof e==="number")return Number.isFinite(e)?e:v;if(typeof e==="string")return e.length<=bt?e:v;if(t>=Qs||typeof e!=="object")return v;if(Array.isArray(e)){if(e.length>He)return v;let r=[];for(let s of e){let a=nn(s,t+1);if(a===v)return v;r.push(a)}return r}let n={},o=0;for(let r of Object.keys(e)){if(++o>He||r.length>bt)return v;let s=nn(e[r],t+1);if(s===v)return v;if(s!==void 0)n[r]=s}return n}var se=(e)=>be(e)?ge(e):v,bo=(e)=>{if(!be(e))return v;let t={},n=Object.keys(e);if(n.length>He)return v;for(let o of n){let r=u(e[o]);if(r===v||o.length>bt)return v;t[o]=r}return t},ei=256,mt=(e,t=ei)=>(n)=>{if(!be(n))return v;let o=Object.keys(n);if(o.length>t)return v;let r=Object.create(null);for(let s of o){if(s.length>200||s==="__proto__"||s==="constructor"||s==="prototype")return v;let a=e(n[s]);if(a===v)return v;r[s]=a}return r},ft=(e)=>typeof e==="string"&&/^[A-Za-z0-9_-]{1,64}$/.test(e)?e:v,H=(e)=>(t)=>typeof t==="string"&&t.length<=e?t:v,ti=(e)=>typeof e==="string"&&/^[A-Z][A-Za-z0-9]{0,63}$/.test(e)?e:v,yo=(e)=>typeof e==="string"&&/^[a-z][a-z0-9-]{0,40}$/.test(e)?e:v,gt=(e)=>typeof e==="number"&&Number.isSafeInteger(e)&&e>=0&&e<=9999?e:v,X=(e)=>(t)=>{if(!be(t))return v;let n={};for(let o of Object.keys(e)){let r=e[o](t[o]);if(r===v)return v;if(r!==void 0)n[o]=r}return n},de=(e,t)=>(n)=>typeof n==="number"&&Number.isInteger(n)&&n>=e&&n<=t?n:v,on=(e)=>typeof e==="string"&&/^[\w-]{1,64}$/.test(e)?e:v,De=X({x:C,y:C,w:C,h:C}),ni=512,ko=(e)=>{if(typeof e!=="string"||e.length<5||e.length>ni)return v;if(/[\u0000-\u001f\u007f]/.test(e)||e.split("|").length<3)return v;return e},oi=(e)=>{if(!Array.isArray(e)||e.length>Ro)return v;let t=X({clientID:de(0,Number.MAX_SAFE_INTEGER),name:(o)=>typeof o==="string"&&o.length<=Co?o:v,artboardId:Ke,frame:d(de(0,1e7)),word:d(ko)}),n=[];for(let o of e){if(!be(o))return v;let r=t(o);if(r===v)return v;n.push(r)}return n},en=(e)=>typeof e==="string"&&/^#[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$/.test(e)?e:v,So=X({stickyColor:d(en),ink:d(en),thickness:d(U(3,6)),tip:d(U("pen","highlighter","eraser")),highlighterColor:d(en),highlighterWidth:d(de(1,64))}),ht=U(...Bt),rn=U(...Qt),sn=X({kind:U(...oo),from:d(u),only:d(U("formats"))}),ri=X({edit:P,annotate:P,comment:P,present:d(P)}),si=/^[a-z0-9]{8,32}$/,an=(e)=>typeof e==="string"&&si.test(e)?e:v,ii=64,ai=(e)=>typeof e==="string"&&e.length<=ii?e:v,li=(e)=>po(e)??v,ci=/^(?!\/)(?!.*\.\.)[A-Za-z0-9_][A-Za-z0-9 ._/-]{0,255}\.css$/,yt=(e)=>typeof e==="string"&&ci.test(e)?e:v,di=/^(?:head|[0-9a-f]{64})$/,Eo=16,To=(e)=>typeof e==="string"&&di.test(e)?e:v,ui=(e)=>Array.isArray(e)&&e.length<=Eo?F(To)(e):v,pi=200,mi=/^[A-Za-z0-9_.:-]{1,128}$/,wt=(e)=>typeof e==="string"&&mi.test(e)?e:v,fi=(e)=>Array.isArray(e)&&e.length<=pi?F(wt)(e):v,gi=U("light","dark"),hi=200,bi=/^--[A-Za-z0-9_-]{1,128}$/,yi=(e)=>typeof e==="string"&&bi.test(e)?e:v,wo=(e)=>Array.isArray(e)&&e.length<=hi?F(yi)(e):v,wi=["brand","colour","type","space","motion","components","patterns"],vi=U("waiting","drawing","done"),xi=(e)=>{if(!be(e))return v;let t={};for(let n of Object.keys(e)){if(!wi.includes(n))return v;let o=vi(e[n]);if(o===v)return v;t[n]=o}return t},Mo=500,ki=(e)=>Array.isArray(e)&&e.length<=Mo?F(wt)(e):v,Ao=de(0,1e6),Si=(e)=>e===null||wt(e)!==v?e:v,Ei=(e)=>Array.isArray(e)&&e.length<=Mo?F(X({id:wt,x:C,y:C,w:C,h:C}))(e):v,Ti=X({tokens:yt,components:_(yt)}),Mi=(e)=>{if(!be(e))return v;let t=Object.keys(e);if(t.length>Eo)return v;let n=Object.create(null);for(let o of t){if(To(o)===v)return v;let r=Ti(e[o]);if(r===v)return v;n[o]=r}return n},Ai=(e)=>typeof e==="string"&&/^[A-Za-z_][\w-]{0,63}$/.test(e)?e:v,Ri=2000,Ci=X({id:H(200),label:H(200),x:C,y:C,w:C,h:C}),Ii=(e)=>Array.isArray(e)&&e.length<=Ri?F(Ci)(e):v,Pi=500,Ro=32,Co=64,_i=/^(#[0-9a-f]{3,8}|oklch\([0-9.%\s/-]{1,40}\))$/i,Li=/^[A-Za-z0-9_-]{1,64}$/,Oi=["owner","member","viewer","observer"],Ni=(e)=>{if(!Array.isArray(e)||e.length>Ro)return v;let t=[];for(let n of e){if(!be(n))return v;let{clientID:o,name:r,color:s,following:a,artboard:c,idleSince:p,surface:f,inComments:x,role:g}=n;if(typeof o!=="number"||!Number.isSafeInteger(o)||o<0)return v;if(typeof r!=="string"||r.length>Co)return v;if(s!==void 0&&(typeof s!=="string"||!_i.test(s)))return v;if(a!==void 0&&typeof a!=="boolean")return v;if(c!==void 0&&(typeof c!=="string"||!Li.test(c)))return v;if(p!==void 0&&(typeof p!=="number"||!Number.isSafeInteger(p)||p<=0))return v;if(f!==void 0&&f!=="browser")return v;if(x!==void 0&&typeof x!=="boolean")return v;let w={clientID:o,name:r};if(s!==void 0)w.color=s;if(a===!0)w.following=!0;if(c!==void 0)w.artboard=c;if(p!==void 0)w.idleSince=p;if(f==="browser")w.surface="browser";if(x===!0)w.inComments=!0;if(Oi.includes(g))w.role=g;t.push(w)}return t},Di=120,Ki=256,je=(e)=>typeof e==="string"&&e.length<=Di?e:v,zi=(e)=>Array.isArray(e)&&e.length<=Ki?F(X({artboard:je,element:je,occurrence:d((t)=>typeof t==="number"&&Number.isInteger(t)&&t>=0&&t<1e4?t:v),tag:je,mine:P,scope:d(P),point:d(P)}))(e):v,Vi=8,Hi=40,tn="[A-Za-z0-9_.:-]{1,128}",Fi=new RegExp(`^(?:ab:${tn}|el:${tn}/${tn})$`),$i=20,qi=(e)=>Array.isArray(e)&&e.length<=$i?F(X({from:on,to:on}))(e):v,ji=(e)=>Array.isArray(e)&&e.length<=Vi?F(X({ref:(t)=>typeof t==="string"&&Fi.test(t)?t:v,tag:(t)=>typeof t==="string"&&t.length<=Hi?t:v}))(e):v,Ui=["add","reply","resolve","reopen","edit-own","delete-own"],Wi=["to-sticky","convert-undo","convert-undoable"],tt=(e)=>typeof e==="string"&&e.length>0&&e.length<=64||typeof e==="number"&&Number.isSafeInteger(e)?e:v,Bi=(e)=>{if(!be(e))return v;if(Wi.includes(e.op))return typeof e.commentId==="string"&&/^[A-Za-z0-9_]{1,64}$/.test(e.commentId)?{op:e.op,commentId:e.commentId}:v;if(!Ui.includes(e.op))return v;return ge(e)},Xi=X({id:H(200),name:H(120),role:d(H(40))}),Qi=256,Yi=64,Gi=X({name:_((e)=>typeof e==="string"&&e.length<=Yi&&!e.includes("@")?e:v),kind:_(U("mac","pc","linux")),self:P}),Zi=X({rel:H(512),state:U("here","uploading","waiting","missing","lfs-pointer"),localObject:d(P),who:d(Gi),syncing:d(P),progress:d(Ys)}),Ji=(e)=>Array.isArray(e)&&e.length<=Qi?F(Zi)(e):v,ea=256,ta=/^assets\/[0-9a-f]{8}\.[A-Za-z0-9]{1,8}$/,na=(e)=>Array.isArray(e)&&e.length<=ea&&e.every((t)=>typeof t==="string"&&ta.test(t))?e.slice():v;function l(e){let t=X(e);return(n)=>{let o=t(n);return o===v?null:o}}var ue=(e)=>be(e)?{}:null,vo={refId:d(u),refIndex:d(C),artboardId:d(_(u)),position:d(u)},xe={id:d(u)},Ve=X({artboard:u,element:u,occurrence:d(C)}),oa=X({kind:U("picture","frame","artboard"),artboard:H(200),element:d(H(200)),occurrence:d(de(1,He))}),ze=(e,t)=>(n)=>Array.isArray(n)&&n.length<=e?t(n):v,ra=X({id:d(H(128)),tag:d(H(24)),text:d(H(160)),selector:d(H(200)),index:d(C)}),sa=X({label:u,ref:_(Ve)}),ia=["held-by-ai","locked","stale","invalid","forbidden"],V="h/use-canvas-bridge",ae="canvas-shell",ln={loaded:{gate:"any",status:"live",owner:V,parse:l({file:u})},"canvas-rendered":{gate:"active",status:"live",owner:V,parse:l({file:u})},"canvas-failed":{gate:"active",status:"live",owner:V,parse:l({file:u})},"canvas-mounted":{gate:"any",status:"legacy",owner:"tpl/_shell.html (probe)",orphan:"no-handler",parse:l({file:u,children:C})},"render-error":{gate:"frame",status:"live",owner:"v2/create/use-render-error",parse:l({file:u,message:H(600)})},"render-ok":{gate:"frame",status:"live",owner:"v2/create/use-render-error",parse:l({file:u})},"ds-review":{gate:"active",status:"live",owner:"h/use-ds-frames",parse:ue},"ds-rects-result":{gate:"frame",status:"live",owner:"v2/ds/reach-view",parse:l({seq:Ao,view:X({w:C,h:C}),label:d(H(120)),rects:Ei})},"ds-pins-want":{gate:"active",status:"live",owner:"v2/ds/pins",parse:l({revs:ui})},"canvas-expired":{gate:"frame",status:"live",owner:"h/use-shell-core",parse:ue},"annotations-changed":{gate:"active",status:"live",orphan:"no-handler",owner:"annotations-layer (S4.9) → annotation-list (S4.17)",parse:l({file:u})},"annotation-to-comment":{gate:"active",status:"live",owner:"annotations-layer (S4.12) → shell convert (routes/annotations.ts, S4.7)",parse:l({id:ft})},"annotation-selection":{gate:"active",status:"live",owner:"annotations-layer (S4.12) → AI scope chip (S4.15, S5.8)",parse:l({ids:ze(500,F(ft)),kinds:mt(gt,16),artboards:ze(200,F(H(128)))})},"annotation-toast":{gate:"active",status:"live",owner:"annotations-layer (S4.12) → shell toast",parse:l({v:U(1),message:H(300),undo:P})},"annotation-ask-ai":{gate:"active",status:"live",owner:"annotations-layer (S4.12) → shell AI chat",parse:l({v:U(1)})},"object-history":{gate:"active",status:"live",owner:"editing/object-menu.tsx + annotations-layer (sticky menu) → shell history.object",parse:l({artboard:d(Ke),element:d(H(128)),annotation:d(ft)})},"view-only-gesture":{gate:"active",status:"live",owner:"view-only-gesture (S9.21b) → shell access host tip",parse:l({v:U(1),x:d(de(0,16384)),y:d(de(0,16384))})},"vote-cast":{gate:"active",status:"live",owner:"annotations/ui/vote-dots (S4.14) → shell vote store (routes/votes.ts)",parse:l({artboard:Ke,remove:d(P)})},"vote-board":{gate:"active",status:"live",owner:"annotations/ui/vote-dots + editing/artboard-menu (S4.14) → shell vote sheet",parse:l({artboards:ze(200,F(X({id:Ke,label:H(120),x:C,y:C,w:C,h:C}))),open:d(P),focus:d(Ke)})},"annotations-visibility":{gate:"active",status:"live",owner:"annotations-layer ⇧P (S4.18) → shell use-photo-and-timeline",parse:l({v:U(1),visible:P})},"canvas-notice":{gate:"active",status:"live",owner:"canvas-notice-message",parse:l({message:u,kind:U("info","success","error","warning","undo")})},"embed-escape":{gate:"active",status:"live",owner:"c/embed-view",parse:ue},"select-set":{gate:"active",status:"live",owner:V,parse:l({selection:_((e)=>Array.isArray(e)?F(se)(e):se(e)),refs:d(F(Ve)),crumbs:d(F(sa)),kind:d(U(...Xs))})},"edit-text":{gate:"active",status:"live",owner:V,parse:l({id:u,file:u,text:u,occurrence:d(C),before:d(u)})},"apply-edit":{gate:"active",status:"live",owner:"client/apply-edit-request",parse:l({requestId:u,op:ge,canvas:d(ge),id:d(ge),key:d(ge),value:d(ge),from:d(ge),occurrence:d(ge)})},"undo-barrier":{gate:"active",status:"live",owner:V,parse:l({requestId:u})},"undo-key":{gate:"active",status:"live",owner:"v2/undo/use-undo-mode-lane (S2.20b)",parse:l({redo:P})},"take-step":{gate:"active",status:"live",owner:"v2/assets/takes (S8.16)",parse:l({dir:U("next","prev")})},"edit-op":{gate:"active",status:"live",owner:"editing (S2.1)",parse:l({requestId:u,op:u,targets:F(Ve),params:d(se),expectRev:d(u)})},"asset-drop-target":{gate:"active",status:"live",owner:"client/v2/assets/canvas-drop-catcher (r3)",parse:l({requestId:H(64),target:_(oa)})},"active-artboard":{gate:"active",status:"live",owner:V,parse:l({id:_(u)})},"reorder-slot":{gate:"active",status:"live",owner:"editing/reorder-slot",parse:(e)=>{let t=l({index:de(0,He),total:de(0,He),parentId:d(on)})(e);if(!t||t.index>t.total)return null;if(t.index>0&&t.parentId===void 0)return null;return t}},"layers-tree":{gate:"active",status:"live",owner:V,parse:l({artboardId:_(u),tree:F(se)})},"open-inspector":{gate:"active",status:"live",owner:V,parse:l({tab:d(u)})},"copy-style":{gate:"active",status:"live",owner:V,parse:ue},"paste-style":{gate:"active",status:"live",owner:V,parse:l({id:u})},"insert-request":{gate:"active",status:"live",owner:V,parse:l({...vo,kind:U("div","text","image"),src:d(u)})},"insert-image-request":{gate:"active",status:"live",owner:V,parse:l(vo)},"delete-request":{gate:"active",status:"live",owner:V,parse:l({id:u,idIndex:d(C)})},"duplicate-request":{gate:"active",status:"live",owner:V,parse:l({id:u,idIndex:d(C)})},"reorder-request":{gate:"active",status:"live",owner:V,parse:l({id:u,refId:u,position:u,idIndex:d(C),refIndex:d(C)})},"reorder-revert":{gate:"active",status:"live",owner:V,parse:l({seq:C,dir:U("undo","redo")})},"reposition-request":{gate:"active",status:"live",owner:V,parse:l({id:u,left:u,top:u,beforeLeft:d(u),beforeTop:d(u),idIndex:d(C)})},"resize-request":{gate:"active",status:"live",owner:V,parse:l({id:u,patch:bo,before:d(bo),idIndex:d(C)})},"replace-media-request":{gate:"active",status:"live",owner:V,parse:l({id:u,before:d(u)})},"convert-to-absolute-request":{gate:"active",status:"live",owner:V,parse:l({artboardId:d(u),allowShared:d(P),containers:d(F(ge)),dissolve:d(F(ge)),containerId:d(u),children:d(F(ge)),containerSetRelative:d(P)})},"delete-artboard-request":{gate:"active",status:"live",owner:V,parse:l({artboardId:u})},"duplicate-artboard-request":{gate:"active",status:"live",owner:V,parse:l({artboardId:u,width:d(C)})},"rename-artboard-request":{gate:"active",status:"live",owner:V,parse:l({artboardId:u,label:u})},"resize-artboard-request":{gate:"active",status:"live",owner:V,parse:l({artboardId:u,width:C,height:C})},"set-artboard-kind-request":{gate:"active",status:"live",owner:V,parse:l({artboardId:u,kind:_(u)})},"open-timeline-request":{gate:"active",status:"live",owner:V,parse:l({artboardId:u})},"replace-annotation-media-request":{gate:"active",status:"live",owner:V,parse:l({id:u,before:d(u)})},"edit-annotation-photo-request":{gate:"active",status:"live",owner:V,parse:l({id:u,asset:u})},"comment-compose":{gate:"active",status:"live",owner:V,parse:l({selection:se})},"comment-submit":{gate:"active",status:"live",owner:V,parse:l({payload:se})},"comment-patch":{gate:"active",status:"live",owner:V,parse:l({id:u,patch:se})},"comment-delete":{gate:"active",status:"live",owner:V,parse:l({id:u})},"comment-click":{gate:"active",status:"live",owner:V,parse:l({id:u})},"comment-op":{gate:"active",status:"live",owner:"v2/comments/comment-bridge (S9.22)",parse:l({reqId:tt,op:Bi})},"comment-people-request":{gate:"active",status:"live",owner:"v2/comments/comment-bridge (S9.22)",parse:l({reqId:tt})},"export-request":{gate:"active",status:"live",owner:V,orphan:"no-sender",parse:l({id:u,payload:se})},"export-history-request":{gate:"active",status:"live",owner:V,orphan:"no-sender",parse:l({id:u})},"open-export":{gate:"active",status:"legacy",owner:V,parse:l({detail:se})},"export-capture-progress":{gate:"asked",status:"live",owner:"h/use-shell-core",parse:l({id:u,current:C,total:C})},"export-capture-done":{gate:"asked",status:"live",owner:"h/use-shell-core",parse:l({id:u,items:F(se)})},"export-capture-error":{gate:"asked",status:"live",owner:"h/use-shell-core",parse:l({id:u,message:u})},"export-selection":{gate:"asked",status:"live",owner:"c/app",parse:l({id:u,selectors:F(u)})},"timeline-comps":{gate:"active",status:"live",owner:V,parse:l({comps:F(se)})},"timeline-frame":{gate:"active",status:"live",owner:V,parse:l({...xe,frame:C})},"timeline-ended":{gate:"active",status:"live",owner:V,parse:l(xe)},"timeline-playing":{gate:"active",status:"live",owner:"v2/timeline (S7.8)",parse:l({...xe,playing:P})},key:{gate:"active",status:"live",owner:"actions/registry (V2-1.3)",parse:l({v:U(1),chord:u,hint:d(X({artboardId:d(u)}))})},"tool-cursor":{gate:"active",status:"live",owner:V,parse:l({tool:u})},peers:{gate:"active",status:"live",owner:"v2/shell/use-canvas-mode-lane (V2-4.3b)",parse:l({peers:Ni})},"hold-view":{gate:"active",status:"live",owner:"v2/inspector/view-mode (S2.18)",parse:l({person:_(X({name:je})),label:je,ai:_(X({label:je,held:P,mine:P}))})},select:{gate:"active",status:"legacy",owner:V,orphan:"no-sender",parse:l({selection:se})},"clear-select":{gate:"active",status:"legacy",owner:V,orphan:"no-sender",parse:ue},artboards:{gate:"active",status:"live",owner:"v2/empty (S11.2); the shell bridge keeps the Layers count",parse:l({count:C})},"artboard-empty":{gate:"active",status:"live",owner:"v2/empty (S11.2)",parse:l({artboardId:_(u),rect:_(De),label:d(u),from:d(u)})},"artboard-anchor":{gate:"active",status:"live",owner:"v2/timeline (S7.7)",parse:l({artboardId:_(u),kind:d(u),label:d(u),rect:d(_(De))})},"artboard-live-size":{gate:"active",status:"live",owner:"v2/inspector live size (P8 c6)",parse:l({id:_(u),w:d(C),h:d(C),preset:d(_(u))})},"space-tap":{gate:"active",status:"live",owner:"v2/timeline (S7.8)",parse:ue},"canvas-pointerdown":{gate:"active",status:"live",owner:"v2/shell dismiss-outside (rc3 r4-12)",parse:ue},"timeline-peers":{gate:"active",status:"live",owner:"v2/timeline/peers (S7.17)",parse:l({peers:oi})},"ask-selection":{gate:"active",status:"live",owner:"editing/ask-bubble (S2.19)",parse:l({refs:ze(200,F(Ve)),selection:d(ze(12,F(ra))),rect:De,artboard:d(u)})},"ask-selection-rect":{gate:"active",status:"live",owner:"editing/ai-scope-outline (S2.19)",parse:l({rect:_(De)})},"insert-artboard-request":{gate:"active",status:"legacy",owner:V,orphan:"no-sender",parse:l({id:d(u),label:d(u),width:d(C),height:d(C)})},"mode-changed":{gate:"active",status:"live",owner:"v2/shell/use-canvas-mode-lane (V2-4.3b)",parse:l({seq:C,mode:ht,tool:rn,present:_(sn),cause:U("set-mode","tool","clamp","boot")})},"mode-request":{gate:"active",status:"live",owner:"v2/shell/use-canvas-mode-lane (V2-4.3b)",parse:l({mode:(e)=>e==="back"?e:ht(e),tool:d(rn),present:d(sn),cause:U("key","esc","inspect","toolbar","link")})},"toolbar-rect":{gate:"active",status:"live",owner:"tool-palette (V2-4.5a); shell tool panels (V2-4.5c)",parse:l({mode:ht,rect:_(De)})},"tool-panel-open":{gate:"active",status:"live",owner:"tool-palette (V2-4.5c); shell tool panels (V2-4.5c)",parse:l({panel:U("stickers","components","templates","assets","sizes","image","generate"),anchor:_(De),replace:d(u)})},"size-place":{gate:"active",status:"live",owner:"editing/size-ghost (S7.20); client/v2/kinds",parse:l({presetId:H(40),world:X({x:C,y:C})})},"stamp-disarmed":{gate:"active",status:"live",owner:"annotations/ui/placement (15 an-stamps); shell tool panels (use-tool-panels.js)",parse:l({})},"annotation-prefs-set":{gate:"active",status:"live",owner:"annotations/ui/tool-state (S4.8); shell v2/shell/use-annotation-prefs (S4.8)",parse:l({prefs:So})},"viewport-zoom":{gate:"active",status:"live",owner:"present/present-zoom.ts (S3.2b) + v2/preview/zoom-only (S3.9) ← canvas-lib ViewportZoomReporter",parse:l({zoom:C,fit:d(P)})},"present-position":{gate:"active",status:"live",owner:"v2/shell/use-canvas-mode-lane (S3.1)",parse:l({index:C,total:C,artboardId:u,sid:d(an),seq:d(de(0,2147483647))})},"present-run":{gate:"active",status:"live",owner:"present/present-stage.tsx (S3.6b)",parse:l({artboards:Ii})},"present-follow-state":{gate:"active",status:"live",owner:"v2/present/follow-view (S3.7a)",parse:l({live:P,sid:_(an),presenterName:ai,presenterIndex:de(0,2000),index:de(0,2000),total:de(0,2000),watchers:de(0,1e5),ended:P})},"present-media":{gate:"active",status:"live",owner:"present/present-media (S3.3)",parse:l({playing:P,t:ho,duration:ho,muted:P,sources:d(Zs),missing:d(P)})},"link-follow":{gate:"active",status:"live",owner:"S3 links (client/v2/preview/link-follow.js)",parse:l({elementId:Js,artboardId:_(Ke)})},"asset-relink-request":{gate:"active",status:"live",owner:"client/v2/assets/asset-state-lane (S8.19)",parse:l({rel:H(512)})},"asset-lfs-fix-request":{gate:"active",status:"live",owner:"client/v2/assets/asset-state-lane (2.0.3 LFS placeholder)",parse:l({rel:H(512)})},"asset-lfs-copy-request":{gate:"active",status:"live",owner:"client/v2/assets/asset-state-lane (2.0.3 LFS placeholder)",parse:l({rel:H(512)})}},xo={theme:{gate:"any",target:"parent",status:"live",owner:ae,parse:l({theme:U("light","dark")})},"view-chrome":{gate:"any",target:"parent",status:"live",owner:ae,parse:l({minimap:d(P),zoom:d(P),present:d(P),guides:d(P),print:d(P),safeZones:d(P),zen:d(P)})},"view-annotations":{gate:"parent",status:"live",owner:"annotations-layer",parse:l({visible:P})},"canvas-cap":{gate:"parent",status:"live",owner:"tpl/_shell.html",parse:l({t:u})},"ds-css":{gate:"parent",status:"live",owner:"tpl/_shell.html",parse:l({tokens:d(_(yt)),components:d(_(yt))})},"ds-pins":{gate:"parent",status:"live",owner:"tpl/_shell.html",parse:l({revs:Mi,rootClass:_(Ai)})},"ds-update-dots":{gate:"parent",status:"live",owner:"tpl/_shell.html",parse:l({ids:fi})},"ds-theme-preview":{gate:"parent",status:"live",owner:"ds/board/state",parse:l({mode:gi})},"ds-marks":{gate:"parent",status:"live",owner:"ds/board/state",parse:l({outside:wo,conflicts:wo})},"ds-make-states":{gate:"parent",status:"live",owner:"ds/board/outline",parse:l({sections:xi})},"ds-rects":{gate:"parent",status:"live",owner:"tpl/_shell.html",parse:l({seq:Ao,artboard:Si,ids:ki})},"ai-activity":{gate:"parent",status:"live",owner:"ai-banner",parse:l({file:u,entry:_(se)})},"select-by-id":{gate:"parent",status:"live",owner:ae,parse:l({id:d(u),artboardId:d(_(u)),index:d(C),add:d(P)})},"select-by-selector":{gate:"parent",status:"live",owner:ae,parse:l({selector:u})},highlight:{gate:"any",target:"parent",status:"live",owner:ae,parse:l({id:_(u),artboardId:d(_(u)),index:d(C)})},"request-layers":{gate:"any",target:"parent",status:"live",owner:ae,parse:l({artboardId:_(u)})},"force-clear":{gate:"any",target:"parent|self",status:"live",owner:ae,parse:ue},"select-clear":{gate:"any",target:"parent|self",status:"legacy",owner:ae,orphan:"no-sender",parse:ue},"locked-set":{gate:"parent",status:"live",owner:ae,parse:l({locked:F(u)})},"apply-style":{gate:"parent",status:"live",owner:ae,parse:l({id:u,artboardId:d(_(u)),index:d(C),prop:u,value:_(u)})},"record-edit":{gate:"parent",status:"live",owner:ae,parse:l({payload:se})},"apply-edit-result":{gate:"parent",status:"live",owner:ae,parse:l({requestId:u,ok:P,error:d(u),conflict:d(P)})},"undo-barrier-ok":{gate:"parent",status:"live",owner:ae,parse:l({requestId:u})},"edit-op-result":{gate:"parent",status:"live",owner:"editing (S2.1)",parse:l({requestId:u,ok:P,actionId:d(_(u)),writeId:d(u),rev:d(u),refs:d(F(Ve)),created:d(F(Ve)),code:d(U(...ia)),message:d(u)})},"edit-reverted":{gate:"parent",status:"live",owner:ae,parse:l({op:u,id:d(u),reason:d(u)})},"reorder-failed":{gate:"parent",status:"live",owner:ae,parse:ue},"reposition-failed":{gate:"parent",status:"live",owner:ae,parse:ue},"resize-failed":{gate:"parent",status:"live",owner:"use-element-resize",parse:ue},"resize-artboard-failed":{gate:"parent",status:"live",owner:"use-element-resize",parse:ue},"freeze-and-set-kind":{gate:"parent",status:"live",owner:ae,parse:l({artboardId:u,kind:_(u),ask:d(P),freeze:d(P)})},"op-toast":{gate:"any",target:"parent",status:"live",owner:ae,parse:l({message:u})},"tool-set":{gate:"parent",status:"live",owner:"use-tool-mode",orphan:"no-sender",parse:l({tool:u})},"insert-sticker":{gate:"parent",status:"live",owner:"annotations-layer",parse:l({path:u,follow:d(P),preview:d(Gs),sticker:d(X({pack:u,id:u,flip:d(P)}))})},"reveal-artboard":{gate:"parent",status:"live",owner:"canvas-lib",parse:l({artboardId:u,glide:P,flash:P})},"convert-marks":{gate:"parent",status:"live",owner:"artboard-convert-marks",parse:l({v:U(1),from:u,to:u,extraPct:C,fill:_(H(40))})},"shell-panels":{gate:"parent",status:"live",owner:"shell-panels",parse:l({v:U(1),open:_(U("stickers","assets","components"))})},"ai-copies":{gate:"parent",status:"live",owner:"artboard-ai-copies",parse:l({v:U(1),copies:qi})},"ai-runs":{gate:"parent",status:"live",owner:"artboard-activity-overlay",parse:l({artboards:mt(X({state:U("running","needs-you","done"),who:H(200),tag:H(120),waiting:gt}))})},"insert-template":{gate:"parent",status:"live",owner:"annotations-layer",parse:l({id:u,follow:d(P)})},"trashed-artboards":{gate:"parent",status:"live",owner:"artboard-ghosts-overlay (S11.5)",parse:l({canvas:H(1024),items:F(X({id:H(128),label:H(200),rect:_(De)}))})},"place-component":{gate:"parent",status:"live",owner:"editing/place-ghost",parse:l({component:ti,label:d(H(64)),variant:d(yo),glyph:d(yo),mode:U("ghost","selection","preview","cancel")})},"place-image":{gate:"parent",status:"live",owner:"editing/place-image (r2-p1 TD10); client/v2/shell/image-pick.js",parse:l({asset:H(512),natural:d(_(X({w:C,h:C}))),label:d(H(200))})},"asset-drag-over":{gate:"parent",status:"live",owner:"editing/image-drop (r3)",parse:l({x:_(C),y:d(C)})},"asset-drop-at":{gate:"parent",status:"live",owner:"editing/image-drop (r3)",parse:l({requestId:H(64),x:C,y:C})},"asset-drop-done":{gate:"parent",status:"live",owner:"editing/image-drop (r3)",parse:l({requestId:H(64),ok:P,created:d(F(Ve)),message:d(H(400))})},"timeline-drop-hint":{gate:"parent",status:"live",owner:"editing/drop-chip (S7.9)",parse:l({artboardId:u,on:P})},"timeline-word":{gate:"parent",status:"live",owner:"collab/timeline-presence (S7.17)",parse:l({artboardId:_(Ke),wordKey:d(ko)})},"dim-artboards":{gate:"parent",status:"live",owner:"editing/kind-dim (S7.24b) ← client/v2/kinds/kind-dim-relay",parse:l({ids:_(ze(Pi,F(H(128))))})},"size-ghost":{gate:"parent",status:"live",owner:"editing/size-ghost (S7.20)",parse:l({preset:_(X({id:H(40),label:H(80),sizeText:H(40),w:C,h:C}))})},"insert-annotation-media":{gate:"parent",status:"live",owner:"annotations-layer",parse:l({paths:F(u)})},"replace-annotation-media":{gate:"parent",status:"live",owner:"annotations-layer",parse:l({id:u,path:u,sticker:d(X({pack:u,id:u,flip:d(P)}))})},"photo-preview":{gate:"any",target:"parent",status:"live",owner:"canvas-lib (photo)",parse:l({asset:u,edit:_(se),use:d(u)})},"photo-busy":{gate:"any",target:"parent",status:"live",owner:"canvas-lib (photo)",parse:l({asset:u,busy:P})},"comments-set":{gate:"any",target:"parent",status:"live",owner:"comments-overlay",parse:l({comments:F(se)})},"comment-focus":{gate:"any",target:"parent",status:"live",owner:"comments-overlay",parse:l({id:_(u),reply:d(U(!0))})},"comment-op-ack":{gate:"parent",status:"live",owner:"comments-overlay (S9.22)",parse:l({reqId:_(tt)})},"comment-op-result":{gate:"parent",status:"live",owner:"comments-overlay (S9.22)",parse:l({reqId:_(tt),ok:P,comment:d(_(se)),status:d(C),error:d(u)})},"comment-people":{gate:"parent",status:"live",owner:"comments-overlay (S9.22)",parse:l({reqId:_(tt),people:_(F(Xi))})},"annotation-select":{gate:"parent",status:"live",owner:"annotations-layer (S4.9)",parse:l({v:U(1),ids:F(H(200))})},"annotation-filter":{gate:"parent",status:"live",owner:"annotations-layer (S4.9)",parse:l({v:U(1),authors:F(H(200))})},"export-capture":{gate:"parent",status:"live",owner:"canvas-lib (export)",parse:l({id:u,format:u,artboardIds:F(u),scale:C})},"export-selection-query":{gate:"parent",status:"live",owner:"canvas-lib (export)",parse:l({id:u})},"export-result":{gate:"parent",status:"live",owner:"export-dialog",orphan:"no-handler",parse:l({id:u,ok:P,browser:d(P),jobId:d(u),error:d(u)})},"export-history-result":{gate:"parent",status:"live",owner:"export-dialog",orphan:"no-handler",parse:l({id:u,history:F(se)})},"timeline-play":{gate:"any",target:"parent",status:"live",owner:"video-comp",parse:l(xe)},"timeline-pause":{gate:"any",target:"parent",status:"live",owner:"video-comp",parse:l(xe)},"timeline-seek":{gate:"any",target:"parent",status:"live",owner:"video-comp",parse:l({...xe,frame:C})},"timeline-loop":{gate:"any",target:"parent",status:"live",owner:"video-comp",parse:l({...xe,loop:P})},"timeline-mute":{gate:"any",target:"parent",status:"live",owner:"video-comp",parse:l({...xe,muted:P})},"timeline-volume":{gate:"any",target:"parent",status:"live",owner:"video-comp",parse:l({...xe,volume:C})},"timeline-request-comps":{gate:"any",target:"parent",status:"live",owner:"video-comp",parse:ue},"run-action":{gate:"parent",status:"live",owner:"actions/registry (V2-1.3)",parse:l({v:U(1),id:u,params:d(se)})},"paste-data":{gate:"parent",status:"live",owner:"bridge/paste-data (p8-sweep-leftovers)",parse:(e)=>{let t=fo(e);return t?{...t}:null}},"git-lifecycle":{gate:"parent",status:"legacy",owner:"c/app",orphan:"no-handler",parse:l({payload:se})},"set-mode":{gate:"parent",status:"live",owner:"bridge/canvas-mode-store (V2-4.3b)",parse:l({v:U(2),seq:C,mode:ht,present:_(sn),tool:d(rn),caps:ri})},"occluded-insets":{gate:"parent",status:"new",owner:"bridge/canvas-mode-store",parse:l({seq:C,insets:li})},"present-step":{gate:"parent",status:"live",owner:"bridge/canvas-mode-store (S3.1)",parse:l({to:(e)=>e==="next"||e==="prev"?e:C(e)})},"present-follow":{gate:"parent",status:"live",owner:"bridge/canvas-mode-store (S3.7a)",parse:l({sid:_(an),live:P,locked:P})},"present-media-cmd":{gate:"parent",status:"live",owner:"present/present-media (S3.3)",parse:l({op:U("play","pause","mute","unmute","captions-on","captions-off")})},"key-prefs":{gate:"parent",status:"live",owner:"bridge/canvas-mode-store (V2-4 gate)",parse:l({singleKeys:P})},"annotation-prefs":{gate:"parent",status:"live",owner:"annotations/ui/tool-state (S4.8)",parse:l({prefs:So})},"vote-state":{gate:"parent",status:"live",owner:"annotations/ui/vote-dots (S4.14)",parse:l({vote:_(X({id:ft,targets:ze(32,F(H(200))),state:U("open","ended"),perVoter:de(1,99),tallies:d(mt(gt,32))})),mine:mt(gt,32)})},"hold-intent":{gate:"parent",status:"live",owner:"editing/hold-rings (S2.18)",parse:l({field:P,app:P,gesture:d(P)})},"ai-holds":{gate:"parent",status:"live",owner:"editing/hold-rings (S2.18)",parse:l({holds:zi})},"ai-seen":{gate:"parent",status:"live",owner:"annotations/ui/ai-seen (S4.15); sent by v2/ai/seen-relay.js",parse:l({targets:ji})},"undo-preview":{gate:"parent",status:"live",owner:"editing/undo-preview (S2.20)",parse:l({artboards:F(u),tag:_(u)})},"asset-state":{gate:"parent",status:"live",owner:"canvas-lib asset placeholder frame (S8.19, L1)",parse:l({items:Ji,lfsActions:d(P)})},"asset-lfs-copied":{gate:"parent",status:"live",owner:"canvas-lib asset placeholder frame (2.0.3 LFS placeholder)",parse:l({rel:H(512),ok:P})},"gen-takes":{gate:"parent",status:"live",owner:"editing/take-keys (S8.16, L1)",parse:l({assets:na})}};var aa="dgn",la=(e,t)=>Object.assign({},e,{[aa]:t}),Io=(e,t)=>Object.hasOwn(e,t),ca=(e)=>be(e)&&typeof e.dgn==="string"?e.dgn:null;function da(e){return Io(ln,e)?ln[e]:null}function ua(e){return Io(xo,e)?xo[e]:null}function pa(e,t,n){if(e==="any")return!0;let o=t.source;if(o===n.parent)return!0;return e==="parent|self"&&o===n}var Sd=new Set(Object.keys(ln).filter((e)=>da(e)?.gate==="active"));function vt(e,t){let n=ca(e.data),o=n?ua(n):null;if(!n||!o||!pa(o.gate,e,t))return null;let r=o.parse(e.data);return r?la(r,n):null}var ma=/^[A-Za-z0-9_-]{1,64}$/;function nt(e){return typeof e==="string"&&ma.test(e)}function Po(e){if(!e||typeof e!=="object")return!1;let{x:t,y:n}=e;return typeof t==="number"&&typeof n==="number"&&Number.isFinite(t)&&Number.isFinite(n)&&Math.abs(t)<=1e7&&Math.abs(n)<=1e7}function _o(){if(typeof window>"u"||typeof document>"u")return null;let e=window.__maudeViewport?.()??null;if(!e||!(e.zoom>0))return null;let t=document.querySelector(".dc-canvas");if(!t)return null;let n=t.getBoundingClientRect();return{vp:e,left:n.left,top:n.top}}function Lo(e,t){let n=_o();if(!n)return null;let{vp:o}=n;return{x:(e-n.left-o.x)/o.zoom,y:(t-n.top-o.y)/o.zoom}}function Oo(e){let t=_o();if(!t)return null;let{vp:n}=t;return{x:t.left+n.x+e.x*n.zoom,y:t.top+n.y+e.y*n.zoom}}function xt(e){if(typeof document>"u"||!nt(e))return null;return document.querySelector(`[data-id="${e}"][data-tool]`)}function No(e,t){if(typeof document>"u")return null;let n=null;for(let o of Array.from(document.querySelectorAll("[data-id][data-tool]"))){if(o.getAttribute("data-tool")==="section")continue;let r=o.getAttribute("data-id");if(!nt(r))continue;let s=o.getBoundingClientRect();if(s.width<=0&&s.height<=0)continue;if(e<s.left||e>s.right||t<s.top||t>s.bottom)continue;let a=Math.max(1,s.width)*Math.max(1,s.height);if(!n||a<=n.area)n={id:r,area:a}}return n?.id??null}import{useCallback as ie,useEffect as ce,useMemo as Fe,useRef as pe,useState as re}from"react";var kt=null;function Re(){if(typeof window>"u")return!1;if(kt===null)try{kt=new URLSearchParams(window.location.search).get("ro")==="1"}catch{kt=!1}return kt}var St=null;function Ue(){if(typeof window>"u")return!1;if(St===null)try{St=new URLSearchParams(window.location.search).get("cm")==="1"}catch{St=!1}return St}var Et=null;function cn(){if(typeof window>"u")return!1;if(Et===null)try{Et=new URLSearchParams(window.location.search).get("cg")==="1"}catch{Et=!1}return Et}var ot="Comments are paused while this project is view only.",Tt=null;function dn(){if(typeof window>"u")return!1;if(Tt===null)try{Tt=new URLSearchParams(window.location.search).get("embed")==="1"}catch{Tt=!1}return Tt}function un(){if(typeof window>"u")return!1;try{return new URLSearchParams(window.location.search).get("follow")==="1"}catch{return!1}}function Do(){if(typeof window>"u")return!1;try{return!!new URLSearchParams(window.location.search).get("sha")}catch{return!1}}var Ko=Symbol.for("maude.canvasMode.v2");function ve(e){let t=e,n=t[Ko];if(n&&n.doc===e.document)return n;let o={insets:Jt,insetsSeq:-1,mode:null,present:null,caps:null,modeSeq:-1,tool:null,prevMode:null,clamped:!1,singleKeys:!0,step:null,follow:null},r=0,s=0,a=-1,c=new Map,p=new Set,f={get:()=>o,subscribe(x){return p.add(x),()=>{p.delete(x)}},claimEcho(x){if(x!==o.modeSeq||x<=a)return!1;return a=x,!0},claimRequest(x){let g=Date.now(),w=c.get(x);if(w!==void 0&&g-w<250)return!1;return c.set(x,g),!0}};return e.addEventListener("message",(x)=>{let g=vt(x,e);if(g?.dgn==="set-mode"){if(g.seq<=o.modeSeq)return;c=new Map;let w=g.caps.present===!0&&!un(),A=Re()?{edit:!1,annotate:!1,comment:g.caps.comment,present:w}:{...g.caps,present:w},m=io(g.mode,A),h=g.tool?et(g.tool,A,m):null,S=g.tool&&(h===null||h===m)?g.tool:null;o={...o,mode:m,present:m==="present"?g.present??{kind:"canvas"}:null,caps:Object.freeze(A),modeSeq:g.seq,tool:S,prevMode:o.mode,clamped:m!==g.mode,step:m==="present"?o.step:null};for(let y of p)y(o);return}if(g?.dgn==="present-step"){if(o.mode!=="present")return;r+=1,o={...o,step:Object.freeze({to:g.to,n:r})};for(let w of p)w(o);return}if(g?.dgn==="present-follow"){if(!un())return;s+=1,o={...o,follow:Object.freeze({sid:g.sid,live:g.live,locked:g.locked,n:s})};for(let w of p)w(o);return}if(g?.dgn==="key-prefs"){if(g.singleKeys===o.singleKeys)return;o={...o,singleKeys:g.singleKeys};for(let w of p)w(o);return}if(g?.dgn!=="occluded-insets")return;if(g.seq<=o.insetsSeq)return;o={...o,insets:Object.freeze({...g.insets}),insetsSeq:g.seq};for(let w of p)w(o)}),Object.defineProperty(f,"doc",{value:e.document}),t[Ko]=f,f}function zo(){return typeof window>"u"?Jt:ve(window).get().insets}if(typeof window<"u"&&typeof window.addEventListener==="function")ve(window);var Ce=["sky","green","yellow","lilac","grey"],Vo="yellow",pn=Object.freeze({sky:"oklch(0.78 0.10 230)",green:"oklch(0.74 0.13 152)",yellow:"oklch(0.82 0.14 95)",lilac:"oklch(0.76 0.10 290)",grey:"oklch(0.70 0.01 250)"});function Ho(e){if(!e)return Ce[0];let t=5381;for(let o=0;o<e.length;o++)t=(t<<5)+t+e.charCodeAt(o)|0;let n=(t%Ce.length+Ce.length)%Ce.length;return Ce[n]??Ce[0]}var mn=(e)=>pn[e];var fa="Someone",ga=(e)=>{if(typeof e!=="string")return!0;let t=e.trim().toLowerCase();return t===""||t==="unknown"};function rt(e,t){if(ga(e))return{name:fa,letter:"S",tone:"grey",you:!1};let n=e.trim(),o=!!t&&t.trim()===n;return{name:o?"You":n,letter:n.charAt(0).toUpperCase(),tone:o?Vo:Ho(n),you:o}}var ha=(e)=>e.trim().split(/\s+/)[0]||"";function st(e){let t=typeof e.author==="string"?e.author.trim():"";if(t==="AI")return{name:t,ai:!0,first:t};return{name:t,ai:!1,first:ha(t)}}function Fo(e){let t=st(e);return t.first?`From ${t.first}’s sticky`:"From a sticky"}var ba=/^[A-Za-z0-9._-]{1,40}$/;var ya={figma:"Figma"},wa=/[\p{Cc}\p{Cf}\p{Cs}\p{Co}\p{Cn}\p{Zl}\p{Zp}]/gu;function va(e){if(typeof e!=="string")return"";let n=e.normalize("NFC").replace(/\s+/gu," ").replace(wa,"").replace(/\s+/gu," ").trim();return Array.from(n).slice(0,80).join("").trim()}var $o=(e)=>!!e&&typeof e==="object"&&!Array.isArray(e);function xa(e){if(typeof e!=="string"||e.length>40)return;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toISOString():void 0}function fn(e){if(!$o(e)||e.source!=="figma")return;let t=$o(e.author)?e.author:{},n={source:"figma",author:{name:va(t.name)||"Someone"}};if(typeof t.handle==="string"&&t.handle.length<=40&&ba.test(t.handle))n.author.handle=t.handle;let o=xa(e.at);if(o)n.at=o;return n}function gn(e){return e?`${e.author.name} · from ${ya[e.source]}`:""}function qo(e){return(String(e??"").trim().split(/\s+/)[0]??"").replace(/[^\w.-]/g,"").toLowerCase()}function jo(e,t){let{mine:n,...o}=e;return t?{...o,mine:!0}:o}function ka(e,t){return(Array.isArray(e)?e:[]).map((n)=>{let o=jo(n,t(n));if(Array.isArray(n.thread))o.thread=n.thread.map((r)=>r&&typeof r==="object"?jo(r,t(r)):r);return o})}function Uo(e){let t=new Set;for(let n of Array.isArray(e)?e:[]){if(n?.mine===!0&&typeof n.id==="string")t.add(n.id);if(Array.isArray(n?.thread)){for(let o of n.thread)if(o?.mine===!0&&typeof o.id==="string")t.add(o.id)}}return t}function Wo(e,t){return ka(e,(n)=>typeof n.id==="string"&&t.has(n.id))}function We(e,t){return e?.mine===!0&&typeof e.author==="string"?e.author:t}var Bo=Object.freeze({observer:"Can view",viewer:"Can comment",member:"Can edit",owner:"Owner"}),Sa=(e)=>typeof e==="string"&&Object.hasOwn(Bo,e)?Bo[e]:void 0;function Ea(e,t){if(!Array.isArray(e))return[];let n=[],o=new Set,r=(t??"").trim().toLowerCase();for(let s of e.slice(0,200)){if(!s||typeof s!=="object")continue;let a=s;if(a.state!==void 0&&a.state!==null&&a.state!=="")continue;if(typeof a.name!=="string"||!a.name.trim())continue;let c=a.name.trim().slice(0,120);if(r&&c.toLowerCase()===r)continue;let p=typeof a.id==="string"&&a.id?a.id:c;if(o.has(p))continue;o.add(p);let f=Sa(a.role);n.push(f?{id:p,name:c,role:f}:{id:p,name:c})}return n}function Xo(e,t){if(!Array.isArray(e))return[];return Ea(e.map((n)=>({name:n?.name})),t)}function Ta(e,t=96){return e*t/25.4}function Qo(e,t=96){return e*25.4/t}var Ma=[{id:"a6",label:"A6",category:"iso",unit:"mm",width:105,height:148},{id:"a5",label:"A5",category:"iso",unit:"mm",width:148,height:210},{id:"a4",label:"A4",category:"iso",unit:"mm",width:210,height:297},{id:"a3",label:"A3",category:"iso",unit:"mm",width:297,height:420},{id:"a2",label:"A2",category:"iso",unit:"mm",width:420,height:594},{id:"a1",label:"A1",category:"iso",unit:"mm",width:594,height:841},{id:"a0",label:"A0",category:"iso",unit:"mm",width:841,height:1189},{id:"letter",label:"Letter",category:"us",unit:"in",width:8.5,height:11},{id:"legal",label:"Legal",category:"us",unit:"in",width:8.5,height:14},{id:"tabloid",label:"Tabloid",category:"us",unit:"in",width:11,height:17},{id:"dl",label:"DL envelope",category:"envelope",unit:"mm",width:110,height:220},{id:"c5",label:"C5 envelope",category:"envelope",unit:"mm",width:162,height:229},{id:"card-eu",label:"Business card (EU)",category:"card",unit:"mm",width:85,height:55},{id:"card-us",label:"Business card (US)",category:"card",unit:"in",width:3.5,height:2},{id:"poster-18x24",label:'Poster 18×24"',category:"poster",unit:"in",width:18,height:24},{id:"poster-24x36",label:'Poster 24×36"',category:"poster",unit:"in",width:24,height:36}];function Aa(e){return Ma.find((t)=>t.id===e)}function Ra(e,t){let n=e.unit==="mm"?e.width:e.width*25.4,o=e.unit==="mm"?e.height:e.height*25.4;return t==="landscape"?{widthMm:o,heightMm:n}:{widthMm:n,heightMm:o}}function Ca(e){return e.unit==="mm"?3:3.175}var Mt=5,Ia=200;function At(e){if(!Number.isFinite(e))return 0;return Math.min(Math.max(e,0),Ia)}function Pa(e){let t=e??{};return{top:typeof t.top==="number"?At(t.top):Mt,right:typeof t.right==="number"?At(t.right):Mt,bottom:typeof t.bottom==="number"?At(t.bottom):Mt,left:typeof t.left==="number"?At(t.left):Mt}}function hn(e,t=96){return Math.round(Ta(e,t))}function bn(e){let t=Aa(e.paper);if(!t)throw Error(`unknown paper preset: ${e.paper}`);let n=e.orientation??"portrait",{widthMm:o,heightMm:r}=Ra(t,n),s=e.bleedMm??Ca(t),a=Pa(e.marginsMm),c=hn(s),p=hn(o),f=hn(r);return{paper:t.id,orientation:n,trimWidthMm:o,trimHeightMm:r,bleedMm:s,widthPx:p+2*c,heightPx:f+2*c,trimWidthPx:p,trimHeightPx:f,bleedPx:c,marginsMm:a}}function _a(e){let t=Math.max(0,Math.floor(Number.isFinite(e)?e:0)),n=Math.floor(t/3600),o=Math.floor(t%3600/60),r=t%60,s=(a)=>String(a).padStart(2,"0");return n>0?`${n}:${s(o)}:${s(r)}`:`${o}:${s(r)}`}var La=(e)=>`at ${_a(e)}`,Oa=0.5;function Yo(e,t,n=Oa){if(t===null||t===void 0||!Number.isFinite(t))return!0;return Math.abs(t-e)<=n}function yn(e){if(!e||typeof e!=="object")return null;let t=e;if(typeof t.paper!=="string")return null;try{let n=bn({paper:t.paper,orientation:t.orientation==="landscape"?"landscape":"portrait",...typeof t.bleedMm==="number"?{bleedMm:t.bleedMm}:{}});return{wMm:n.trimWidthMm,hMm:n.trimHeightMm}}catch{return null}}function Go(e,t){if(!e||typeof e!=="object")return null;let n=e;if(typeof n.paper!=="string")return null;try{let o=bn({paper:n.paper,orientation:n.orientation==="landscape"?"landscape":"portrait",...typeof n.bleedMm==="number"?{bleedMm:n.bleedMm}:{}}),r=(s)=>Math.round(Qo(s)*10)/10;return{x:r(t.x-o.bleedPx),y:r(t.y-o.bleedPx)}}catch{return null}}var Rt=(e)=>`${Math.round(e)} mm`;function Na(e,t){if(t&&(e.x<0||e.y<0||e.x>t.wMm||e.y>t.hMm))return"In the bleed";let n=!!t&&e.x>t.wMm/2,o=!!t&&e.y>t.hMm/2,r=n?`${Rt(t.wMm-e.x)} from the right`:`${Rt(e.x)} from the left`,s=o?`${Rt(t.hMm-e.y)} above the trim`:`${Rt(e.y)} from the top`;return`${r} · ${s}`}function wn(e,t){let n=typeof e.artboard==="string"&&e.artboard?e.artboard:null;if(typeof e.t==="number"&&Number.isFinite(e.t))return{artboard:n,chip:La(e.t),kind:"video"};let o=e.mm;if(o&&typeof o.x==="number"&&typeof o.y==="number")return{artboard:n,chip:Na({x:o.x,y:o.y},t),kind:"print"};return{artboard:n,chip:null,kind:n?"artboard":"canvas"}}class Ie extends Error{}var vn=(e,t)=>Math.abs(e.x-t.x)<0.000001&&Math.abs(e.y-t.y)<0.000001,le=(e,t)=>({x:e,y:t}),Ct=/([MmLlHhVvCcSsQqTtZzAa])|(-?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?)/g,Da={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,Z:0};function Ka(e){let t=[];Ct.lastIndex=0;let n=0;for(let o=Ct.exec(e);o;o=Ct.exec(e)){if(/[^\s,]/.test(e.slice(n,o.index)))throw new Ie("not a path");t.push(o[1]??Number(o[2])),n=Ct.lastIndex}if(/[^\s,]/.test(e.slice(n)))throw new Ie("not a path");return t}function Zo(e){let t=Ka(e),n=[],o=null,r=le(0,0),s=le(0,0),a=null,c=null,p=0,f="",x=(m)=>{let h=[];for(let S=0;S<m;S++){let y=t[p++];if(typeof y!=="number")throw new Ie("not a path");h.push(y)}return h},g=(m)=>{o={closed:!1,points:[{...m}]},n.push(o),r=m,s=m},w=(m,h,S)=>{if(!o)g(r);let y=o,i=y.points[y.points.length-1];if(!vn(m,i))i.out=m;let b={...S};if(!vn(h,S))b.in=h;y.points.push(b),r=S,a=h,c="c"},A=(m)=>{if(!o)g(r);o.points.push({...m}),r=m,c=null};while(p<t.length){let m=t[p];if(typeof m==="string"){if(f=m,p++,m==="A"||m==="a")throw new Ie("arc")}else if(!f||f==="Z"||f==="z")throw new Ie("not a path");else if(f==="M")f="L";else if(f==="m")f="l";let h=f===f.toLowerCase(),S=f.toUpperCase(),y=h?r.x:0,i=h?r.y:0,b=Da[S];if(b===void 0)throw new Ie("not a path");let E=x(b);switch(S){case"M":g(le(E[0]+y,E[1]+i)),c=null;break;case"L":A(le(E[0]+y,E[1]+i));break;case"H":A(le(E[0]+y,r.y));break;case"V":A(le(r.x,E[0]+i));break;case"C":w(le(E[0]+y,E[1]+i),le(E[2]+y,E[3]+i),le(E[4]+y,E[5]+i));break;case"S":{let L=c==="c"&&a?le(2*r.x-a.x,2*r.y-a.y):r;w(L,le(E[0]+y,E[1]+i),le(E[2]+y,E[3]+i));break}case"Q":case"T":{let L=r,O,z;if(S==="Q")O=le(E[0]+y,E[1]+i),z=le(E[2]+y,E[3]+i);else O=c==="q"&&a?le(2*r.x-a.x,2*r.y-a.y):r,z=le(E[0]+y,E[1]+i);w(le(L.x+0.6666666666666666*(O.x-L.x),L.y+0.6666666666666666*(O.y-L.y)),le(z.x+0.6666666666666666*(O.x-z.x),z.y+0.6666666666666666*(O.y-z.y)),z),a=O,c="q";break}case"Z":{if(o){let L=o;L.closed=!0;let O=L.points[0],z=L.points[L.points.length-1];if(L.points.length>1&&vn(O,z)){if(z.in)O.in=z.in;L.points.pop()}}r=s,c=null;break}}}if(n.length===0)throw new Ie("empty");return{subs:n}}var Jo=(e)=>e.subs.reduce((t,n)=>t+n.points.length,0);function er(e,t){return(t?.flexDirection||"row").trim().startsWith("row")?e==="width":e==="height"}var za=new Set(["fit-content","max-content","min-content","auto"]),Va=new Set(["100%","fill","-webkit-fill-available","stretch"]),Ha=(e)=>e==="flex"||e==="inline-flex";function Fa(e,t){let n=t.width.trim().toLowerCase();if(Va.has(n))return"fill";if(za.has(n))return"hug";if(/^-?\d/.test(n))return"fixed";if(er("width",e))return Number.parseFloat(t.flexGrow||"0")>=1?"fill":"hug";let o=t.alignSelf.trim()||"auto",r=(e.alignItems||"normal").trim();return o==="stretch"||o==="auto"&&(r==="normal"||r==="stretch")?"fill":"hug"}function tr(e,t){if(!Ha(e.display)||t.length<2)return;let n=new Set(t.map((r)=>Fa(e,r))),o=new Set(t.map((r)=>r.tag.toLowerCase()));return{count:t.length,tag:o.size===1?[...o][0]:"",width:n.size===1?[...n][0]:"mixed"}}var $a=new WeakMap;var nr=(e)=>$a.get(e)??null;var or=(e)=>e?`${e.sub},${e.i},${e.kind},${e.x},${e.y}`:"";var xn=["font-family","font-size","font-weight","line-height","letter-spacing","text-transform","font-style"];var qa=/^t-[a-z][a-z0-9-]*$/,ja=(e)=>(e??"").split(/\s+/).filter(Boolean),rr=(e)=>ja(e).filter((t)=>qa.test(t));var Jd=Object.freeze({"font-family":"font","font-size":"size","font-weight":"weight","line-height":"line height","letter-spacing":"letter spacing","text-transform":"case","font-style":"italic"});var eu=Object.freeze([{tag:"cs",label:"Čeština"},{tag:"en",label:"English"},{tag:"sk",label:"Slovenčina"},{tag:"de",label:"Deutsch"},{tag:"pl",label:"Polski"}]);var sr=(e,t)=>{let n=t.getComputedStyle(e),o={};for(let r of xn)o[r]=n.getPropertyValue(r).trim();return o},Ua=(e)=>e.closest?.("[lang]")?.getAttribute("lang")?.trim()??"";function ir(e){let n=e.ownerDocument?.defaultView;if(!n||typeof n.getComputedStyle!=="function")return null;let o=rr(e.getAttribute("class"))[0]??null,r=sr(e,n),s={role:o,values:{},differs:[],lang:Ua(e),upper:(n.getComputedStyle(e).getPropertyValue("text-transform")??"").trim()==="uppercase"};if(!o)return s;let a=e,c=e.hasAttribute("style"),p=e.getAttribute("style")??"";try{let f=`${p};transition:none`;a.setAttribute("style",f),a.setAttribute("style","transition:none"),s.values=sr(e,n),a.setAttribute("style",f),n.getComputedStyle(e).getPropertyValue("font-size")}finally{if(c)a.setAttribute("style",p);else a.removeAttribute("style")}return s.differs=xn.filter((f)=>r[f]!==s.values[f]),s}function Wa(e,t){if(e==="/_canvas-shell.html"||e==="/_canvas-shell"){let n=new URLSearchParams(t),o=(n.get("designRel")??".design").replace(/^\/+|\/+$/g,""),r=(n.get("canvas")??"").replace(/^\/+/,"");if(o&&r.startsWith(`${o}/`))r=r.slice(o.length+1);if(!r)return null;return o?`${o}/${r}`:r}return decodeURIComponent(e).replace(/^\//,"")}function It(){if(typeof window>"u")return null;try{return Wa(window.location.pathname,window.location.search)}catch{return null}}function Sn(){return It()??void 0}function Pt(e){if(!e)return"";return(e.getAttribute("class")??"").trim().split(/\s+/).filter((t)=>t&&!t.startsWith("dgn-")&&!t.startsWith("dc-cv-")).join(" ")}var Ba=/^$|^(inline|contents|ruby|ruby-text)$|^inline-/;function Xa(e){let t="",n=(o)=>{if(o.nodeType===3){t+=o.nodeValue??"";return}if(o.nodeType!==1)return;let r=o,s=r.nodeName;if(s==="SCRIPT"||s==="STYLE"||s==="TEMPLATE"||s==="NOSCRIPT")return;if(s==="BR"){t+=" ";return}let a=getComputedStyle(r).display;if(a==="none"&&r!==e)return;let c=!Ba.test(a);if(c)t+=" ";for(let p=r.firstChild;p;p=p.nextSibling)n(p);if(c)t+=" "};return n(e),t}function Qa(e,t){if(!e)return"";let o=(e.innerText||(e.textContent?Xa(e):"")).replace(/\s+/g," ").trim();return o.length>t?`${o.slice(0,t-1)}…`:o}function Ya(e){if(!e)return"";let t=[],n=e;while(n&&n.nodeType===1&&t.length<8){let o=n.getAttribute?.("data-dc-element");if(o){t.unshift(`[data-dc-element="${o}"]`);break}let r=n.getAttribute?.("data-dc-screen");if(r){t.unshift(`[data-dc-screen="${r}"]`);break}let s=n.nodeName.toLowerCase();if(n.id){s=`#${n.id}`,t.unshift(s);break}let a=Pt(n).split(/\s+/).filter(Boolean).slice(0,2);if(a.length)s+=`.${a.join(".")}`;let c=1,p=n.previousElementSibling;while(p)c++,p=p.previousElementSibling;s+=`:nth-child(${c})`,t.unshift(s),n=n.parentElement}return t.join(" > ")}function lr(e){let t=[],n=e;while(n&&n.nodeType===1&&t.length<8){let o=n.nodeName.toLowerCase(),r=n.getAttribute?.("data-dc-element"),s=n.getAttribute?.("data-dc-screen");if(r)o+=`[data-dc-element="${r}"]`;else if(s)o+=`[data-dc-screen="${s}"]`;else if(n.id)o+=`#${n.id}`;let a=Pt(n).split(/\s+/).filter(Boolean).slice(0,2);if(a.length&&!r&&!s)o+=`.${a.join(".")}`;t.unshift(o),n=n.parentElement}return t}function Ga(e){return e.replace(/[^a-zA-Z0-9_-]/g,(t)=>`\\${t}`)}function cr(e,t){return t?`[data-dc-screen="${t}"] [data-cd-id="${e}"]`:`[data-cd-id="${e}"]`}function dr(e,t,n){if(!n)return 0;try{let o=e.querySelectorAll(t);for(let r=0;r<o.length;r++)if(o[r]===n)return r}catch{}return 0}function ur(e,t,n){if(!t||!n)return 0;return dr(e,`[data-cd-id="${Ga(t)}"]`,n)}function En(e,t){let n=(o)=>{try{let r=e.querySelectorAll(o);if(!r.length)return null;let s=t.index&&t.index>0&&t.index<r.length?t.index:0;return r[s]??r[0]}catch{return null}};if(t.id){let o=n(cr(t.id,t.artboardId));if(o)return o}if(t.selector)return n(t.selector);return null}function Za(e,t){let n=0,o=Math.min(e.length,t.length);for(let r=1;r<=o;r++){if(e[e.length-r]!==t[t.length-r])break;n++}return n}function pr(e,t){let n=t.dom_path,o=(t.tag||"").toLowerCase();if(!n||n.length===0||!o)return null;let r=e;if(t.artboardId){let p=e.querySelector(`[data-dc-screen="${t.artboardId}"]`);if(p)r=p}let s=(t.classes||"").split(/\s+/).filter(Boolean),a=null,c=0;for(let p of Array.from(r.querySelectorAll("[data-cd-id]"))){if(p.tagName.toLowerCase()!==o)continue;let f=Za(lr(p),n);if(f===0)continue;let x=Pt(p).split(/\s+/).filter(Boolean),g=s.filter((A)=>x.includes(A)).length,w=f*10+g;if(w>c)c=w,a=p}return a}var ar=["display","flex-direction","flex-wrap","align-items","justify-content","gap","flex","flex-grow","flex-shrink","flex-basis","align-self","font-family","color","font-size","font-weight","line-height","letter-spacing","text-align","margin","margin-top","margin-right","margin-bottom","margin-left","padding","padding-top","padding-right","padding-bottom","padding-left","width","height","min-width","min-height","max-width","max-height","background-color","border-radius","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius","border-width","border-style","border-color","box-shadow","opacity","position","top","right","bottom","left","z-index","transform","transform-origin","font-style","text-transform","text-decoration","white-space","overflow","stroke","stroke-width","stroke-linecap","stroke-linejoin","object-fit","aspect-ratio","object-position"],Ja=/^(style|class|data-cd-id|data-dc-|data-dcid$)/;function el(e){if(!e||typeof window>"u"||!window.getComputedStyle)return{authored:{},computed:{},customStyles:{},attrs:{}};try{let t=e.style,n=window.getComputedStyle(e),o={},r={},s=new Set(ar);for(let m of ar){let h=t.getPropertyValue(m);if(h)o[m]=h.trim();let S=n.getPropertyValue(m);if(S)r[m]=S.trim()}let a=/^(margin|padding|border)(-|$)/,c={};for(let m=0;m<t.length;m++){let h=t.item(m);if(!h||s.has(h)||a.test(h))continue;let S=t.getPropertyValue(h);if(S)c[h]=S.trim()}let p={};for(let m of Array.from(e.attributes)){if(Ja.test(m.name))continue;p[m.name]=m.value}if(e.tagName.toLowerCase()==="svg"&&e.getAttribute("data-shape")==="path"){let m=e.querySelector("path")?.getAttribute("d");if(m)try{p["data-dc-pen-points"]=String(Jo(Zo(m)))}catch{}let h=or(nr(e));if(h)p["data-dc-pen-point"]=h}if(e.hasAttribute("data-dc-screen")){for(let h of Array.from(e.attributes))if(h.name.startsWith("data-dc-")&&h.name!=="data-dcid")p[h.name]=h.value;let m=al(e);if(m)p["data-dc-web-longest"]=String(m)}let f=e.parentElement,x=f?window.getComputedStyle(f).display:"",g=f&&(x==="flex"||x==="inline-flex")?window.getComputedStyle(f).flexDirection:"",w={},A=t.getPropertyValue("background").trim();if(A)w.background=A;return{authored:o,computed:r,customStyles:c,attrs:p,declared:w,parentDisplay:x,parentFlexDirection:g}}catch{return{authored:{},computed:{},customStyles:{},attrs:{}}}}function tl(e){let t=e.offsetParent;return{x:Math.round(e.offsetLeft),y:Math.round(e.offsetTop),w:Math.round(e.offsetWidth),h:Math.round(e.offsetHeight),parentW:Math.round(t?.clientWidth??0),parentH:Math.round(t?.clientHeight??0)}}var nl=/^--[A-Za-z0-9_-]{1,128}$/,ol=/^[A-Za-z][A-Za-z0-9]{0,63}$/;function rl(e){let t=e.getAttribute?.("data-ds-token");if(t&&nl.test(t))return`[data-ds-token="${t}"]`;let n=e.getAttribute?.("data-ds-master");if(n&&ol.test(n))return`[data-ds-master="${n}"]`;return null}function Tn(e,t){let n=e.el,o=n&&n.getBoundingClientRect?n.getBoundingClientRect():null,r=e.cdId,s=!r&&n?rl(n):null,a=r?cr(r,e.artboardId):s?e.artboardId?`[data-dc-screen="${e.artboardId}"] ${s}`:s:e.artboardId?`[data-dc-screen="${e.artboardId}"]`:Ya(n),c=r&&typeof document<"u"?dr(document,a,n):0;return{file:t??Sn(),id:r??void 0,selector:a,artboardId:s?null:e.artboardId,index:c,tag:n?.tagName.toLowerCase()??"",classes:Pt(n),text:Qa(n,240),dom_path:lr(n),bounds:o?{x:Math.round(o.left),y:Math.round(o.top),w:Math.round(o.width),h:Math.round(o.height)}:null,worldW:n instanceof HTMLElement?Math.round(fr(n)):void 0,worldH:n instanceof HTMLElement?Math.round(kn(n)):void 0,geometry:n instanceof HTMLElement?tl(n):void 0,html:n?(n.outerHTML??"").slice(0,4000):"",...(()=>{if(n?.tagName?.toLowerCase()!=="img")return{};let p=/assets\/[0-9a-f]{8}\.[a-z0-9]+/i,f=n.getAttribute?.("data-photo-asset");if(f&&p.test(f))return{photoKind:"artboard-img",photoAsset:f};let x=n.getAttribute?.("src")||"",g=p.exec(x);return g?{photoKind:"artboard-img",photoAsset:g[0]}:{}})(),...el(n),...il(n),...sl(n)}}function sl(e){if(!e||typeof window>"u"||!window.getComputedStyle||!e.children?.length)return{};try{let t=window.getComputedStyle(e),n=t.display;if(n!=="flex"&&n!=="inline-flex")return{};let o=Array.from(e.children).filter((s)=>s instanceof HTMLElement).map((s)=>{let a=s.style,c=a.getPropertyValue("flex-grow").trim();return{tag:s.tagName.toLowerCase(),width:a.getPropertyValue("width").trim(),flexGrow:c||window.getComputedStyle(s).flexGrow||"",alignSelf:a.getPropertyValue("align-self").trim()}}),r=tr({display:n,flexDirection:t.flexDirection,alignItems:t.alignItems},o);return r?{kids:r}:{}}catch{return{}}}function il(e){if(!e||e.children.length>0)return{};if(!(e.textContent??"").trim()&&!e.getAttribute("class"))return{};let t=ir(e);return t?{textInfo:t}:{}}function mr(e){if(!e.hasAttribute("data-dc-screen"))return null;let t=Array.from(e.children).find((n)=>n.classList.contains("dc-artboard-body"));return t&&t.offsetWidth?t:null}function fr(e){return mr(e)?.offsetWidth??e.offsetWidth}function al(e){let t=(a)=>a.getAttribute("data-dc-kind")==="web"&&a.getAttribute("data-dc-fixed")!=="true";if(!e.hasAttribute("data-dc-screen")||!t(e))return null;let n=e.closest("[data-dc-section]")??e.ownerDocument,o=Array.from(n.querySelectorAll("[data-dc-screen]")).filter(t);if(o.length<2||!o.includes(e))return null;if(new Set(o.map((a)=>Math.round(fr(a)))).size!==o.length)return null;let s=kn(e);return o.every((a)=>a===e||kn(a)<s)?o.length:null}function kn(e){let t=mr(e);if(t)return t.offsetHeight;if(e.getAttribute("data-dc-fixed")!=="true"||!e.hasAttribute("data-dc-screen"))return e.offsetHeight;let n=Array.from(e.children).find((o)=>o.classList.contains("dc-artboard-label"));return e.offsetHeight-(n?n.offsetHeight:0)}import*as An from"lib0/decoding";import*as it from"lib0/encoding";import{createContext as dl,useCallback as Ku,useContext as ul,useEffect as zu,useMemo as Vu,useReducer as Hu,useRef as Fu,useState as $u}from"react";import{Awareness as ju,applyAwarenessUpdate as Uu,encodeAwarenessUpdate as Wu}from"y-protocols/awareness";import{readSyncMessage as Xu,writeSyncStep1 as Qu,writeUpdate as Yu}from"y-protocols/sync";import*as Rn from"yjs";import*as ll from"yjs";var cl=new WeakSet;function gr(e){return cl.add(e),e}var uu=gr(Object.freeze({maudeOrigin:"shell-edit"})),pu=gr(Object.freeze({maudeOrigin:"sync-agent"}));import*as _t from"lib0/decoding";import*as Be from"lib0/encoding";import*as hr from"y-protocols/awareness";import*as Mn from"y-protocols/sync";var gu=Object.freeze(["timeline","editing","holding"]),hu=Object.freeze(["editing","holding"]);var op=Ce.map((e)=>pn[e]);var pl=dl(null);function br(){return ul(pl)}var rp=Object.freeze({maudeOrigin:"collab-epoch-resync"});import{createContext as ml,useCallback as ke,useContext as In,useEffect as fl,useMemo as gl,useRef as Lt,useState as hl}from"react";import{jsx as Cn,Fragment as kl}from"react/jsx-runtime";var Nt=ml(null);function Pe(e){return e.id?`id:${e.id}`:`sel:${e.selector}`}function Ot(e){let t=[],n=new Set;for(let o of e){let r=Pe(o);if(n.has(r))continue;n.add(r),t.push(o)}return t}var bl=50,yl=500,wl=(e,t)=>e.length===t.length&&e.every((n,o)=>Pe(n)===Pe(t[o]));function yr(e,t,n,o=Date.now()){return o-e<yl&&!wl(n,t)}var wr=null;function vl(e){if(!wr||e.length===0)return null;try{return wr(e)}catch{return null}}function xl({children:e,postTarget:t}){let[n,o]=hl([]),r=Lt([]),s=Lt(Number.NEGATIVE_INFINITY),a=Lt(null),c=Lt(null),p=ke((i)=>{if(a.current)clearTimeout(a.current);c.current=()=>{a.current=null,c.current=null;let b=t??(typeof window<"u"?window.parent:null);if(!b)return;let E=i.length===0?null:i.length===1?i[0]??null:i;try{b.postMessage({dgn:"select-set",selection:E,...vl(i)},"*")}catch{}},a.current=setTimeout(()=>c.current?.(),bl)},[t]);fl(()=>()=>{if(a.current)clearTimeout(a.current);c.current?.()},[]);let f=ke((i)=>{r.current=i,o(i),p(i)},[p]),x=ke((i)=>{s.current=Date.now(),f(Ot(Array.isArray(i)?i:[i]))},[f]),g=ke((i)=>{let b=Ot(Array.isArray(i)?i:[i]);if(yr(s.current,r.current,b))return!1;return f(b),!0},[f]),w=ke((i)=>{let b=Ot([...r.current,...Array.isArray(i)?i:[i]]);if(yr(s.current,r.current,b))return!1;return f(b),!0},[f]),A=ke((i)=>{let b=Array.isArray(i)?i:[i];s.current=Date.now(),o((E)=>{let L=Ot([...E,...b]);return r.current=L,p(L),L})},[p]),m=ke((i)=>{let b=Pe(i);s.current=Date.now(),o((E)=>{let L=E.filter((O)=>Pe(O)!==b);return r.current=L,p(L),L})},[p]),h=ke((i)=>{let b=Pe(i);s.current=Date.now(),o((E)=>{let L=E.some((O)=>Pe(O)===b)?E.filter((O)=>Pe(O)!==b):[...E,i];return r.current=L,p(L),L})},[p]),S=ke(()=>{s.current=Date.now(),f([])},[f]),y=gl(()=>({selected:n,replace:x,add:A,remove:m,toggle:h,clear:S,replaceFromShell:g,addFromShell:w}),[n,x,A,m,h,S,g,w]);return Cn(Nt.Provider,{value:y,children:e})}function vr({children:e}){if(In(Nt))return Cn(kl,{children:e});return Cn(xl,{children:e})}function Dt(){let e=In(Nt);if(!e)throw Error("useSelectionSet must be used inside <SelectionSetProvider>");return e}function xr(){return In(Nt)}import{jsx as R,jsxs as B,Fragment as Yl}from"react/jsx-runtime";var Sl=800,El=20000,_e=new Map,Pr=0;function Tl(e){if(e.source!==window.parent)return;let t=e.data;if(!t||typeof t!=="object"||typeof t.dgn!=="string")return;if(t.dgn!=="comment-op-ack"&&t.dgn!=="comment-op-result"&&t.dgn!=="comment-people")return;let n=`${t.dgn==="comment-op-ack"?"ack":"res"}:${String(t.reqId)}`;_e.get(n)?.(t)}function _r(){if(typeof window>"u")return;window.addEventListener("message",Tl)}var Lr=()=>typeof window<"u"&&window.parent!==window;function _n(e,t){return new Promise((n)=>{let o=setTimeout(()=>{_e.delete(e),n(null)},t);_e.set(e,(r)=>{clearTimeout(o),_e.delete(e),n(r)})})}async function Xe(e){if(!Lr())return null;_r();let t=`cm${++Pr}`,n=_n(`ack:${t}`,Sl),o=_n(`res:${t}`,El);try{window.parent.postMessage({dgn:"comment-op",reqId:t,op:e},"*")}catch{return _e.delete(`ack:${t}`),_e.delete(`res:${t}`),null}if(!await n)return _e.delete(`res:${t}`),null;let r=await o;if(!r)return{ok:!1,error:"That did not go through."};return r.ok?{ok:!0,comment:r.comment??null}:{ok:!1,error:r.error||"That did not go through."}}async function Ml(){if(!Lr())return null;_r();let e=`cm${++Pr}`,t=_n(`res:${e}`,2500);try{window.parent.postMessage({dgn:"comment-people-request",reqId:e},"*")}catch{return _e.delete(`res:${e}`),null}let n=await t;return Array.isArray(n?.people)?n.people:null}function Dn(e){if(typeof document>"u")return null;for(let t of document.querySelectorAll("[data-dc-screen]"))if(t.getAttribute("data-dc-screen")===e)return t;return null}function kr(e){let n=Dn(e)?.querySelector(".dc-artboard-label");return(n instanceof HTMLInputElement?n.value:n?.textContent)?.trim()||e}function Or(e){return(e.querySelector(".dc-artboard-body")??e).getBoundingClientRect()}function Al(e,t){if(typeof document>"u")return null;for(let n of document.querySelectorAll("[data-dc-screen]")){let o=Or(n);if(e>=o.left&&e<=o.right&&t>=o.top&&t<=o.bottom)return n.getAttribute("data-dc-screen")}return null}function Kn(e){let t=Dn(e)?.getAttribute("data-dc-print");if(!t)return null;try{return JSON.parse(t)}catch{return null}}function Nr(e){let t=globalThis.__maudeVideoComps;if(!t)return null;for(let n of t.values()){if(n.artboardId!==e)continue;try{let o=n.ref.current?.getCurrentFrame?.();if(typeof o==="number"&&n.fps>0)return o/n.fps}catch{}}return null}function Rl(e,t){let n=globalThis.__maudeVideoComps;if(!n)return!1;for(let o of n.values()){if(o.artboardId!==e)continue;let r=o.ref.current;if(!r?.seekTo)continue;try{return r.pause?.(),r.seekTo(Math.max(0,Math.round(t*o.fps))),!0}catch{}}return!1}function Cl(e,t,n){let o=e||Al(t,n),r=o?Dn(o):null;if(!o||!r)return{};let s={artboard:o},a=r.getAttribute("data-dc-kind");if(a==="video"){let c=Nr(o);if(c!==null)s.t=Math.round(c*1000)/1000}else if(a==="print"){let c=Or(r),p=r.querySelector(".dc-artboard-body"),f=p&&c.width>0?p.offsetWidth/c.width:1,x=Go(Kn(o),{x:(t-c.left)*(f||1),y:(n-c.top)*(f||1)});if(x)s.mm=x}return s}var Il="/_client/comments-overlay.css";function Pl(){if(typeof document>"u")return;if(document.getElementById("cm-overlay-css"))return;let e=document.createElement("link");e.id="cm-overlay-css",e.rel="stylesheet",e.href=Il,document.head.appendChild(e)}function zn(){return It()}function _l(e){if(nt(e.annotationId))return xt(e.annotationId);if(!e.selector)return null;let t=null;try{let n=document.querySelectorAll(e.selector),o=e.index&&e.index>0&&e.index<n.length?e.index:0;t=n[o]??n[0]??null}catch{t=null}if(t&&e.tag&&t.tagName.toLowerCase()!==e.tag.toLowerCase())t=null;if(!t&&e.dom_path?.length){let n=e.selector.match(/data-dc-screen="([^"]+)"/)?.[1];t=pr(document,{artboardId:n,tag:e.tag,classes:e.classes,dom_path:e.dom_path})}return t}function Ln(e){let t=_l(e);if(!t?.isConnected)return null;let n=t.getBoundingClientRect();if(n.width===0&&n.height===0)return null;return{x:n.left,y:n.top,w:n.width,h:n.height}}function Dr(e,t,n=zo()){let r=typeof window<"u"?window.innerWidth:e.x+t.w,s=typeof window<"u"?window.innerHeight:e.y+t.h,a=uo(r,s,n),c=a.x+8,p=a.y+8,f=a.x+a.w,x=a.y+a.h,g=e.x;if(g+t.w+8>f){let A=e.x-t.w;g=A>=c?A:Math.max(c,f-t.w-8)}if(g<c)g=c;let w=e.y;if(w+t.h+8>x){let A=e.y-t.h;w=A>=p?A:Math.max(p,x-t.h-8)}if(w<p)w=p;return{x:g,y:w}}function Kr(){Pl();let e=xr(),[t,n]=re([]),[o,r]=re(null),[s,a]=re(0),[c,p]=re(null),f=Fe(()=>zn(),[]),[x,g]=re(!1),[w,A]=re(null),m=ie((k)=>{n((T)=>T.some((I)=>I.id===k.id)?T.map((I)=>I.id===k.id?k:I):[...T,k])},[]);ce(()=>{if(typeof document>"u")return;let k=document.getElementById("dgn-pin-layer");if(!k)return;let T=k.style.display;return k.style.display="none",()=>{k.style.display=T}},[]);let h=ie((k)=>{if(!e)return;if(!k?.selector){e.clear();return}let T=k.selector.match(/data-cd-id="([^"]+)"/),I=T?T[1]:void 0,M,K;try{let q=document.querySelector(k.selector);if(q)M=q.tagName.toLowerCase(),K=(q.getAttribute("class")??"").split(/\s+/).filter((j)=>j&&!j.startsWith("dgn-")&&!j.startsWith("dc-cv-")).join(" ")}catch{}e.replace({file:f??void 0,id:I,selector:k.selector,tag:M,classes:K,bounds:k.bounds??void 0})},[e,f]),S=pe(t),y=pe(new Set);S.current=t;let i=br(),b=ql();ce(()=>{if(!i)return;let k=i.doc.getArray("comments"),T=()=>{n(Wo(k.toArray(),y.current))};if(k.length>0)T();return k.observe(T),()=>{try{k.unobserve(T)}catch{}}},[i]),ce(()=>{if(typeof window>"u")return;let k=(T)=>{let I=T.data;if(!I||typeof I!=="object"||!I.dgn)return;if(I.dgn==="comments-set"&&Array.isArray(I.comments))y.current=Uo(I.comments),n(I.comments);else if(I.dgn==="comment-focus"){let M=typeof I.id==="string"?I.id:null;if(r(M),M&&I.reply===!0)a((q)=>q+1);else a(0);let K=M?S.current.find((q)=>q.id===M):void 0;h(K)}};return window.addEventListener("message",k),()=>window.removeEventListener("message",k)},[h]),ce(()=>{if(typeof document>"u")return;let k=(T)=>{let I=T.detail;if(!I?.selection)return;let M=typeof I.clientX==="number"?I.clientX:0,K=typeof I.clientY==="number"?I.clientY:0;p({selection:I.selection,clientX:M,clientY:K,anchors:Cl(I.selection.artboardId,M,K)})};return document.addEventListener("cm:open-composer",k),()=>document.removeEventListener("cm:open-composer",k)},[]);let E=ie(()=>{if(p(null),typeof window>"u")return;try{window.parent.postMessage({dgn:"force-clear"},"*")}catch{}},[]),L=ie((k)=>{if(!c)return;let T=c.selection,I={file:T.file,selector:T.selector,index:T.index,dom_path:T.dom_path,tag:T.tag,classes:T.classes,bounds:T.bounds,html_excerpt:T.html,...T.annotationId?{annotationId:T.annotationId}:{},...T.world?{world:T.world}:{},text:k};if(typeof window>"u")return;g(!0),(async()=>{let M=await Xe({op:"add",...I,...c.anchors});if(g(!1),M===null){try{window.parent.postMessage({dgn:"comment-submit",payload:I},"*")}catch{}E();return}if(!M.ok){A(M.error??"That did not go through.");return}if(A(null),M.comment)m(M.comment);E()})()},[c,E,m]);ce(()=>{if(!f)return;let k=!1;return(async()=>{try{let T=await fetch(`/_comments?file=${encodeURIComponent(f)}`);if(!T.ok){await T.body?.cancel().catch(()=>{});return}let I=await T.json();if(k)return;if(Array.isArray(I.comments))n((M)=>M.length===0?I.comments??[]:M)}catch{}})(),()=>{k=!0}},[f]);let O=Fe(()=>[...new Set(t.filter((k)=>typeof k.t==="number"&&k.artboard).map((k)=>k.artboard))],[t]),[z,G]=re({});ce(()=>{if(O.length===0)return;let k=()=>{let I={};for(let M of O){let K=Nr(M);I[M]=K===null?null:Math.round(K*4)/4}G((M)=>O.every((K)=>M[K]===I[K])?M:I)};k();let T=setInterval(k,125);return()=>clearInterval(T)},[O]);let D=Fe(()=>t.slice().sort((T,I)=>T.created.localeCompare(I.created)).filter((T)=>T.status!=="resolved"&&(typeof T.t!=="number"||!T.artboard||T.id===o||Yo(T.t,z[T.artboard]??null))),[t,z,o]),W=Fe(()=>{let k=new Map;return t.slice().sort((I,M)=>I.created.localeCompare(M.created)).forEach((I,M)=>{k.set(I.id,M+1)}),k},[t]),Q=ie((k)=>{if(r(k),h(t.find((T)=>T.id===k)),typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-click",id:k},"*")}catch{}},[t,h]),ee=ie((k,T)=>{if(typeof window>"u")return;let I=()=>{try{window.parent.postMessage({dgn:"comment-patch",id:k,patch:T},"*")}catch{}},M=T.status==="resolved"?{op:"resolve",id:k}:T.status==="open"?{op:"reopen",id:k}:typeof T.text==="string"?{op:"edit-own",id:k,text:T.text}:null;if(!M)return I();Xe(M).then((K)=>{if(K===null)return I();if(!K.ok)return A(K.error??"That did not go through.");if(A(null),K.comment)m(K.comment)})},[m]),oe=ie((k)=>{if(typeof window>"u")return;r((T)=>T===k?null:T),Xe({op:"delete-own",id:k}).then((T)=>{if(T===null){try{window.parent.postMessage({dgn:"comment-delete",id:k},"*")}catch{}return}if(!T.ok)return A(T.error??"That did not go through.");A(null),n((I)=>I.filter((M)=>M.id!==k))})},[]),te=ie(async(k,T)=>{if(typeof fetch>"u")return!1;let I=await Xe({op:"reply",id:k,body:T});if(I){if(!I.ok)return A(I.error??"That did not go through."),!1;if(A(null),I.comment)m(I.comment);return!0}try{let M=await fetch(`/_api/comments/${encodeURIComponent(k)}/reply`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({body:T})});if(!M.ok)return!1;let K=await M.json();return n((q)=>q.map((j)=>j.id===K.id?K:j)),!0}catch{return!1}},[m]);return B("div",{className:"cm-layer","aria-hidden":!1,children:[D.map((k)=>{let T=W.get(k.id)??0;return R(Vl,{comment:k,sequence:T,focused:o===k.id,viewer:b??i?.myName,onClick:Q},k.id)}),c?R(Hl,{state:c,busy:x,onSubmit:L,onCancel:E}):null,w?B("div",{className:"cm-notice",role:"status","data-testid":"comment-notice",children:[R("span",{children:w}),R("button",{type:"button",className:"cm-notice__x","aria-label":"Dismiss",onClick:()=>A(null),children:"×"})]}):null,(()=>{if(!o)return null;let k=D.find((T)=>T.id===o);if(!k)return null;return R(jl,{comment:k,sequence:W.get(k.id)??0,onClose:()=>{r(null),e?.clear()},onPatch:(T)=>ee(k.id,T),onDelete:()=>oe(k.id),onReply:(T)=>te(k.id,T),focusReply:s,mine:(!Re()||Ue())&&(k.mine===!0||!!(b??i?.myName)&&(k.author??"").trim()===(b??i?.myName??"").trim()),me:(b??i?.myName)||void 0})})()]})}var Pn=null,Sr=0,Ll=60000;async function Ol(){try{let e=await fetch("/_api/git-committers");if(!e.ok)return[];let t=await e.json();return Xo(t.committers)}catch{return[]}}function Nl(){if(!(Pn&&Date.now()-Sr<Ll))Sr=Date.now(),Pn=(async()=>await Ml()??await Ol())();return Pn}function Er(e){return qo(e)}function Dl(e,t){if(t<=0||t>e.length)return null;let n=t-1;while(n>=0){let o=e[n]??"";if(o==="@"){let r=n>0?e[n-1]:"";if(n===0||/\s/.test(r??"")){let s=e.slice(n+1,t);return{start:n,end:t,query:s}}return null}if(!/[\w.-]/.test(o))return null;n-=1}return null}function zr(e,t){ce(()=>{let n=e.current;if(!n)return;n.style.height="auto",n.style.height=`${Math.min(n.scrollHeight,160)}px`},[e,t])}function On({className:e,value:t,onChange:n,onKeyDown:o,placeholder:r,rows:s,disabled:a,textareaRef:c,ariaLabel:p,title:f}){let x=pe(null),g=ie((D)=>{if(x.current=D,c)c.current=D},[c]),[w,A]=re([]),[m,h]=re(null),[S,y]=re(0),i=ie(()=>{if(w.length>0)return;Nl().then((D)=>A(D))},[w.length]),b=Fe(()=>{if(!m)return[];let D=m.query.toLowerCase();return(!D?w:w.filter((Q)=>Q.name.toLowerCase().includes(D))).slice(0,8)},[m,w]),E=ie((D)=>{let W=D.selectionStart??D.value.length,Q=Dl(D.value,W);h(Q),y(0)},[]),L=ie((D)=>{n(D.target.value),E(D.target)},[n,E]),O=ie((D)=>{if(!m)return;let W=x.current;if(!W)return;let Q=`@${Er(D.name)}`,ee=`${t.slice(0,m.start)}${Q} ${t.slice(m.end)}`;n(ee),h(null);let oe=m.start+Q.length+1;requestAnimationFrame(()=>{W.focus(),W.setSelectionRange(oe,oe)})},[m,t,n]),z=ie((D)=>{if(m&&b.length>0){if(D.key==="ArrowDown"){D.preventDefault(),y((W)=>(W+1)%b.length);return}if(D.key==="ArrowUp"){D.preventDefault(),y((W)=>(W-1+b.length)%b.length);return}if(D.key==="Enter"||D.key==="Tab"){D.preventDefault();let W=b[S]??b[0];if(W)O(W);return}if(D.key==="Escape"){D.preventDefault(),h(null);return}}o?.(D)},[m,b,S,O,o]),G=ie((D)=>{E(D.currentTarget)},[E]);return B("div",{style:{position:"relative"},children:[R("textarea",{ref:g,className:e,value:t,placeholder:r,rows:s,disabled:a,"aria-label":p,title:f,onChange:L,onKeyDown:z,onFocus:i,onSelect:G,onClick:G}),m&&b.length>0?R("ul",{className:"cm-mention-popup",role:"listbox","aria-label":"Mention suggestions",style:{left:0,top:"100%"},children:b.map((D,W)=>B("li",{role:"option","aria-selected":W===S,className:"cm-mention-popup__item",onMouseEnter:()=>y(W),onMouseDown:(ee)=>{ee.preventDefault(),O(D)},children:[R(Nn,{name:D.name}),B("span",{className:"cm-mention-popup__name",children:["@",Er(D.name)]}),D.role?R("span",{className:"cm-mention-popup__role",children:D.role}):null]},D.id))}):null]})}var Kl=3000;function zl(e){return{x:e.x-12,y:e.y-12,w:24,h:24}}function Vr(e){let t=!!e.selector||nt(e.annotationId);if(t){let r=Ln(e);if(r)return{pos:r,missing:!1}}let n=Po(e.world)?Oo(e.world):null;return{pos:n?zl(n):e.bounds??null,missing:t}}function Vl({comment:e,sequence:t,focused:n,viewer:o,onClick:r}){let s=pe(null),a=pe(null),c=pe(null),[p,f]=re(!1),x=pe(!1);ce(()=>{let m=()=>{a.current=null;let h=s.current;if(!h)return;let{pos:S,missing:y}=Vr(e),i=!1;if(y){if(c.current==null)c.current=Date.now();i=Date.now()-c.current>Kl}else c.current=null;if(i!==x.current)x.current=i,f(i);if(!S){h.style.display="none",a.current=requestAnimationFrame(m);return}h.style.display="grid";let b=Math.round(S.x+S.w-14),E=Math.round(S.y-14);h.style.left=`${b}px`,h.style.top=`${E}px`,a.current=requestAnimationFrame(m)};return a.current=requestAnimationFrame(m),()=>{if(a.current!=null)cancelAnimationFrame(a.current)}},[e]);let g=rt(e.author,We(e,o)),w=1+(e.thread?.length??0),A=`Comment ${t} by ${g.name}${w>1?`, ${w} messages`:""}${p?" (detached: its target is gone)":""}`;return B("button",{ref:s,type:"button",className:"cm-pin","data-resolved":e.status==="resolved"?"true":"false","data-focused":n?"true":"false","data-detached":p?"true":"false","data-comment-pin":e.id,"aria-label":A,"aria-expanded":n,title:e.text.slice(0,200),"data-seq":t,style:{["--cm-pin-tone"]:mn(g.tone)},onClick:(m)=>{m.preventDefault(),m.stopPropagation(),r(e.id)},children:[g.letter,w>1?R("span",{className:"cm-pin__n","data-testid":`comment-pin-count-${e.id}`,"aria-hidden":"true",children:w}):null]})}function Hl({state:e,busy:t=!1,paused:n=cn(),onSubmit:o,onCancel:r}){let[s,a]=re(""),c=pe(null);zr(c,s);let p=pe(null),f=pe(null);ce(()=>{let m=()=>{f.current=null;let h=p.current;if(!h)return;let S=Ql(e),y=Dr(S,{w:h.offsetWidth,h:h.offsetHeight});h.style.left=`${Math.round(y.x)}px`,h.style.top=`${Math.round(y.y)}px`,f.current=requestAnimationFrame(m)};return f.current=requestAnimationFrame(m),()=>{if(f.current!=null)cancelAnimationFrame(f.current)}},[e]),ce(()=>{c.current?.focus()},[]);let x=ie(()=>{let m=s.trim();if(!m||t||n)return;o(m)},[s,t,n,o]),g=ie((m)=>{if(m.key==="Escape"){m.preventDefault(),r();return}if((m.metaKey||m.ctrlKey)&&m.key==="Enter")m.preventDefault(),x()},[r,x]),w=Fe(()=>Hr({artboard:e.anchors?.artboard,selector:e.selection.selector}),[e.anchors,e.selection]),A=Fe(()=>{let m=e.anchors;if(!m?.artboard)return null;return wn(m,yn(Kn(m.artboard))).chip},[e.anchors]);return B("div",{ref:p,className:"cm-composer",role:"dialog","aria-label":"New comment",onClick:(m)=>m.stopPropagation(),onPointerDown:(m)=>m.stopPropagation(),children:[B("div",{className:"cm-composer__head",children:[R("span",{className:"cm-composer__where","data-testid":A?"comment-composer-place":"comment-composer-where",children:w}),R("button",{type:"button",className:"cm-thread__close","data-testid":"comment-composer-cancel","aria-label":"Cancel",title:"Cancel · esc",onClick:r,children:"×"})]}),A?R("span",{className:"cm-chip cm-composer__chip","data-testid":"comment-composer-where",children:A}):null,n?R("p",{className:"cm-composer__paused",role:"status","data-testid":"comment-composer-paused",children:ot}):null,B("div",{className:"cm-composer__field",children:[R(On,{textareaRef:c,className:"cm-composer__textarea",value:s,placeholder:"Add a comment — @ mentions someone",onChange:a,onKeyDown:g,rows:1,ariaLabel:"Comment body",disabled:n,title:n?ot:void 0}),R("button",{type:"button",className:"cm-btn cm-btn--primary cm-composer__send","data-testid":"comment-composer-send","aria-label":"Send",title:n?ot:"Send · ⌘↵",disabled:!s.trim()||t||n,onClick:x,children:R("svg",{width:"14",height:"14",viewBox:"0 0 16 16","aria-hidden":"true",children:R("path",{d:"M6 3.5 10.5 8 6 12.5",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]})}function Fl(e){if(e.artboard)return kr(e.artboard);let t=null;try{t=e.selector&&typeof document<"u"?document.querySelector(e.selector):null}catch{t=null}let n=t?.closest?.("[data-dc-screen]")?.getAttribute("data-dc-screen");if(n)return kr(n);let o=t?.getAttribute?.("data-dc-element");if(o)return o.replace(/[-_]+/g," ");return"On the canvas"}function $l(e=zn()){let t=(e??"").split("/").pop()??"";if(!/\.[a-z0-9]+$/i.test(t))return"";return t.replace(/\.[a-z0-9]+$/i,"").replace(/[-_]+/g," ").trim()}function Hr(e,t=zn()){let n=Fl(e),o=$l(t);if(!o)return n;return n==="On the canvas"?o:`${o} · ${n}`}var Tr=null;function ql(){let[e,t]=re(null);return ce(()=>{if(typeof fetch>"u")return;Tr??=fetch("/_api/git-user").then((o)=>o.ok?o.json():null).then((o)=>typeof o?.name==="string"&&o.name.trim()?o.name.trim():null).catch(()=>null);let n=!0;return Tr.then((o)=>n&&t(o)),()=>{n=!1}},[]),e}function jl({comment:e,sequence:t,onClose:n,onPatch:o,onDelete:r,onReply:s,focusReply:a=0,mine:c=!1,me:p}){let f=pe(null),x=pe(null),g=pe(null),[w,A]=re("");zr(x,w);let[m,h]=re(!1),[S,y]=re(null),i=ie(()=>{let N=(S??"").trim();if(!N)return;if(N!==e.text)o({text:N});y(null)},[S,e.text,o]);ce(()=>{let N=()=>{g.current=null;let Z=f.current;if(!Z)return;let Ae=Xl(e),ut=Dr(Ae,{w:Z.offsetWidth,h:Z.offsetHeight});Z.style.left=`${Math.round(ut.x)}px`,Z.style.top=`${Math.round(ut.y)}px`,g.current=requestAnimationFrame(N)};return g.current=requestAnimationFrame(N),()=>{if(g.current!=null)cancelAnimationFrame(g.current)}},[e]),ce(()=>{f.current?.focus();let N=e.id;return()=>{document.querySelector(`[data-comment-pin="${N}"]`)?.focus()}},[e.id]),ce(()=>{if(a>0)x.current?.focus()},[a,e.id]),ce(()=>{if(typeof document>"u")return;let N=(Z)=>{if(Z.key!=="Escape")return;let Ae=f.current;if(!Ae)return;if(Ae.contains(Z.target)||document.activeElement===Ae)Z.preventDefault(),n()};return document.addEventListener("keydown",N),()=>document.removeEventListener("keydown",N)},[n]);let b=ie(async()=>{let N=w.trim();if(!N||m)return;h(!0);let Z=await s(N);if(h(!1),Z)A(""),x.current?.focus()},[w,m,s]),E=ie((N)=>{if((N.metaKey||N.ctrlKey)&&N.key==="Enter")N.preventDefault(),b()},[b]),L=`cm-thread-head-${e.id}`,O=cn(),z=(!Re()||Ue())&&!O,G=wn(e,e.artboard?yn(Kn(e.artboard)):null),D=Hr({artboard:e.artboard,selector:e.selector}),W=e.from,Q=fn(e.importedFrom),ee=(p??"").trim(),oe=W?ee?(W.convertedBy??"").trim()===ee:c:!1,te=W?(e.thread??[]).find((N)=>(N.author??"").trim()!==(ee||(W.convertedBy??"").trim())):void 0,k=te?`${Mr(te.author??"")||"Someone"} replied — resolve the thread instead.`:null,T=!!W&&!Re(),[I,M]=re(!1),K=!!W,[q,j]=re(!1);ce(()=>{if(q)x.current?.focus()},[q]);let[Y,Ee]=re(null),[Te,Me]=re(!1);ce(()=>{if(!W||!oe){Me(!1);return}let N=!0;return Xe({op:"convert-undoable",commentId:e.id}).then((Z)=>{if(N)Me(!!Z?.ok)}),()=>{N=!1}},[e.id,W,oe]);let Oe=async(N)=>{M(!1),Ee(null);let Z=await Xe({op:N,commentId:e.id});if(Z?.ok)n();else Ee(Z?.error||"That did not go through.")};return B("div",{ref:f,className:"cm-thread","data-seq":t,role:"dialog","data-esc-owner":"focus","aria-labelledby":L,tabIndex:-1,onClick:(N)=>N.stopPropagation(),onPointerDown:(N)=>N.stopPropagation(),children:[B("div",{className:"cm-thread__head",id:L,children:[K?null:B("div",{className:"cm-thread__head-row",children:[R("span",{className:"cm-thread__where","data-testid":`comment-where-${e.id}`,children:D}),B("span",{className:"cm-thread__head-end",children:[z?B("span",{className:"cm-thread__actions",children:[c&&S===null&&!Q?R("button",{type:"button",className:"cm-btn","data-testid":"comment-edit",onClick:()=>y(e.text),children:"Edit"}):null,e.status==="resolved"?B("button",{type:"button",className:"cm-btn cm-btn--ghost","data-testid":`comment-reopen-${e.id}`,onClick:()=>o({status:"open"}),children:[R(Qe,{d:"M3.5 8a4.5 4.5 0 1 0 1.4-3.3M3.5 2.5v2.6h2.6"}),"Reopen"]}):B("button",{type:"button",className:"cm-btn cm-btn--ghost","data-testid":`comment-resolve-${e.id}`,onClick:()=>{o({status:"resolved"}),n()},children:[R(Qe,{d:"M3 8.4 6.4 11.8 13 4.6"}),"Resolve"]}),c?R(Bl,{id:e.id,onConfirm:()=>{r(),n()}}):null]}):null,R("button",{type:"button",className:"cm-thread__close","aria-label":"Close thread",title:"Close · esc",onClick:n,children:"×"})]})]}),!K&&G.chip?G.kind==="video"&&typeof e.t==="number"&&e.artboard?R("button",{type:"button",className:"cm-chip cm-chip--seek","data-testid":`comment-chip-${e.id}`,title:"Go to this moment",onClick:()=>Rl(e.artboard,e.t),children:G.chip}):R("span",{className:"cm-chip","data-testid":`comment-chip-${e.id}`,children:G.chip}):null,e.from?B("div",{className:"cm-thread__from","data-testid":`comment-from-${e.id}`,children:[R("svg",{width:"14",height:"14",viewBox:"0 0 16 16","aria-hidden":"true",className:"cm-thread__from-ic",children:R("path",{d:"M3 2.5h10v8l-3 3H3zM10 13.5v-3h3",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinejoin:"round"})}),B("span",{children:[Fo(e.from)," · turned into a comment by"," ",oe?"You":Mr(e.from.convertedBy||e.author||""),oe&&Te&&!k?B(Yl,{children:[" · ",R("button",{type:"button",className:"cm-link","data-testid":`comment-from-undo-${e.id}`,onClick:()=>void Oe("convert-undo"),children:"Undo"})]}):null]})]}):null,Y?R("div",{className:"cm-thread__convert-line",role:"alert",children:Y}):null]}),S===null?B("div",{className:"cm-msg cm-msg--root",children:[Q?R(Ar,{}):R(Nn,{name:e.from?st(e.from).name:e.author,ai:e.from?st(e.from).ai:e.authorKind==="ai",viewer:e.from?p:We(e,p)}),B("div",{className:"cm-msg__main",children:[B("div",{className:"cm-msg__head",children:[R("span",{className:"cm-thread__author","data-testid":Q?`comment-imported-${e.id}`:void 0,children:Q?gn(Q):e.from?st(e.from).name:rt(e.author,We(e,p)).name}),R("span",{className:"cm-thread__time",children:Ir(Q?.at??e.created)})]}),R("div",{className:"cm-thread__body",children:Q?e.text:Cr(e.text)}),e.queued?R(Rr,{id:e.id}):null]})]}):B("div",{className:"cm-thread__reply-form",children:[R(On,{className:"cm-thread__reply-textarea",value:S,placeholder:"Edit your comment… ⌘↵ to save",onChange:y,onKeyDown:(N)=>{if((N.metaKey||N.ctrlKey)&&N.key==="Enter")N.preventDefault(),i()},rows:3,ariaLabel:"Edit comment"}),B("div",{className:"cm-thread__reply-actions",children:[R("button",{type:"button",className:"cm-btn",onClick:()=>y(null),children:"Cancel"}),R("button",{type:"button",className:"cm-btn cm-btn--primary","data-testid":"comment-edit-save",disabled:!S.trim(),onClick:i,children:"Save"})]})]}),(e.thread??[]).map((N)=>{let Z=fn(N.importedFrom);return B("div",{className:"cm-msg cm-thread__reply",children:[Z?R(Ar,{}):R(Nn,{name:N.author,ai:N.authorKind==="ai",viewer:We(N,p)}),B("div",{className:"cm-msg__main",children:[B("div",{className:"cm-thread__reply-head",children:[R("span",{className:"cm-thread__reply-author",children:Z?gn(Z):rt(N.author,We(N,p)).name}),R("span",{className:"cm-thread__reply-time",children:Ir(Z?.at??N.created)})]}),R("div",{className:"cm-thread__reply-body",children:Z?N.body:Cr(N.body)}),N.queued?R(Rr,{id:N.id}):null]})]},N.id)}),K&&z?B("div",{className:"cm-thread__foot","data-testid":`comment-foot-${e.id}`,children:[e.status==="resolved"?B("button",{type:"button",className:"cm-btn cm-btn--ghost","data-testid":`comment-reopen-${e.id}`,onClick:()=>o({status:"open"}),children:[R(Qe,{d:"M3.5 8a4.5 4.5 0 1 0 1.4-3.3M3.5 2.5v2.6h2.6"}),"Reopen"]}):B("button",{type:"button",className:"cm-btn cm-btn--ghost","data-testid":`comment-resolve-${e.id}`,onClick:()=>{o({status:"resolved"}),n()},children:[R(Qe,{d:"M3 8.4 6.4 11.8 13 4.6"}),"Resolve"]}),B("span",{className:"cm-thread__more",children:[R("button",{type:"button",className:"cm-btn cm-btn--icon","aria-label":"More","aria-haspopup":"menu","aria-expanded":I,"data-testid":`comment-menu-${e.id}`,onClick:()=>M((N)=>!N),children:"⋯"}),I?B("span",{className:"cm-thread__menu",role:"menu",children:[R("button",{type:"button",role:"menuitem",className:"cm-thread__menu-item","data-testid":`comment-menu-reply-${e.id}`,onClick:()=>{M(!1),j(!0)},children:"Reply…"}),c&&S===null&&!Q?R("button",{type:"button",role:"menuitem",className:"cm-thread__menu-item","data-testid":"comment-edit",onClick:()=>{M(!1),y(e.text)},children:"Edit"}):null,T?R("button",{type:"button",role:"menuitem",className:"cm-thread__menu-item","data-testid":`comment-menu-to-sticky-${e.id}`,disabled:!!k,onClick:()=>void Oe("to-sticky"),children:"Turn back into a sticky"}):null,c?R("button",{type:"button",role:"menuitem",className:"cm-thread__menu-item cm-thread__menu-item--danger","data-testid":`comment-delete-${e.id}`,onClick:()=>{r(),n()},children:"Delete comment"}):null,k?R("span",{className:"cm-thread__menu-note",children:k}):null]}):null]})]}):null,O&&Ue()?R("p",{className:"cm-thread__paused",role:"status","data-testid":`comment-paused-${e.id}`,children:ot}):null,z&&(!K||q||a>0)&&B("div",{className:"cm-thread__reply-form cm-thread__reply-form--field",children:[R(On,{textareaRef:x,className:"cm-thread__reply-textarea",value:w,placeholder:"Reply…",title:"⌘↵ to send · @name to tag",onChange:A,onKeyDown:E,rows:1,ariaLabel:"Reply",disabled:m}),R("div",{className:"cm-thread__reply-actions",children:R("button",{type:"button",className:"cm-btn cm-btn--primary cm-thread__send","aria-label":"Send",title:"Send · ⌘↵",disabled:!w.trim()||m,onClick:()=>void b(),children:R("svg",{width:"14",height:"14",viewBox:"0 0 16 16","aria-hidden":"true",children:R("path",{d:"M6 3.5 10.5 8 6 12.5",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})})})]})]})}function Mr(e){return e.trim().split(/\s+/)[0]||e}function Ar(){return R("span",{className:"cm-av cm-av--imported","aria-hidden":"true"})}var Ul="M3 4.5h10M6.5 4.5V3h3v1.5M4.5 4.5l.6 8.1a1 1 0 0 0 1 .9h3.8a1 1 0 0 0 1-.9l.6-8.1",Wl=4000;function Bl({id:e,onConfirm:t}){let[n,o]=re(!1);return ce(()=>{if(!n)return;let r=setTimeout(()=>o(!1),Wl);return()=>clearTimeout(r)},[n]),R("button",{type:"button",className:`cm-btn cm-btn--ghost cm-btn--danger cm-btn--trash${n?" is-armed":""}`,"aria-label":n?"Confirm delete comment":"Delete comment",title:n?"Press again to delete":"Delete comment","data-testid":`comment-delete-${e}`,"data-armed":n?"true":void 0,onBlur:()=>o(!1),onKeyDown:(r)=>{if(r.key==="Escape"&&n)r.stopPropagation(),o(!1)},onClick:(r)=>{if(!n)return o(!0);if(r.detail>1)return;o(!1),t()},children:R(Qe,{d:Ul})})}function Rr({id:e}){return B("span",{className:"cm-queued","data-testid":`comment-queued-${e}`,children:[R(Qe,{d:"M8 3.2v5l3 1.8M14 8A6 6 0 1 1 2 8a6 6 0 0 1 12 0Z"}),"Queued — sends when this Mac is online."]})}function Qe({d:e}){return R("svg",{width:"13",height:"13",viewBox:"0 0 16 16","aria-hidden":"true",className:"cm-glyph",children:R("path",{d:e,fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Nn({name:e,ai:t=!1,viewer:n}){let o=rt(e,n);return R("span",{className:`cm-av${t?" cm-av--ai":""}`,style:t?void 0:{["--cm-av-tone"]:mn(o.tone)},"aria-hidden":"true",children:t?"AI":o.letter})}function Cr(e){if(!e)return null;let t=/(@[\w][\w.-]*)/g;return e.split(t).map((o,r)=>{let s=`${r}:${o}`;if(r%2===1)return R("strong",{"data-mention":"true",children:o},s);return R("span",{children:o},s)})}function Ir(e){if(!e)return"";let t=Date.parse(e);if(!Number.isFinite(t))return"";let n=Math.round((Date.now()-t)/1000);if(n<60)return`${Math.max(n,0)}s ago`;if(n<3600)return`${Math.round(n/60)}m ago`;if(n<86400)return`${Math.round(n/3600)}h ago`;return`${Math.round(n/86400)}d ago`}function Xl(e){let{pos:t}=Vr(e);if(t){if(e.from)return{x:t.x+t.w+8,y:t.y-28};return{x:t.x+t.w-12,y:t.y+16}}return{x:16,y:16}}function Ql(e){if(e.clientX||e.clientY){let t=e.selection.selector?Ln(e.selection):null,n=t&&t.h<=200?Math.max(e.clientY,t.y+t.h):e.clientY;return{x:e.clientX,y:n+8}}if(e.selection.selector){let t=Ln(e.selection);if(t)return{x:t.x,y:t.y+t.h+8}}return{x:16,y:16}}import{useEffect as lc}from"react";function Vn(e){return{role:e.readOnly?"comment":"owner",shell:"browser",mode:e.mode??"edit",focus:e.typing?"text":"canvas",selection:e.selection??"none",facts:new Set([...e.toolArmed?["toolArmed"]:[],...e.selectionHasTakes?["selectionHasTakes"]:[]]),...e.singleKeys===!1?{singleKeys:!1}:{}}}var Kt=["⌃","⌥","⇧","⌘"],zt={Enter:"↵",Return:"↵","↩":"↵",Escape:"esc",Esc:"esc",esc:"esc"," ":"Space",Space:"Space",Spacebar:"Space",ArrowLeft:"←",ArrowRight:"→",ArrowUp:"↑",ArrowDown:"↓",Backspace:"⌫",Delete:"⌦",Del:"⌦",Tab:"tab",tab:"tab",Home:"Home",End:"End",PageUp:"PageUp",PageDown:"PageDown","-":"−","–":"−"},Fr=new Set(["↵","esc","Space","tab","⌫","⌦","←","→","↑","↓","Home","End","PageUp","PageDown"]),Gl={cmd:"⌘",command:"⌘",meta:"⌘",ctrl:"⌃",control:"⌃",alt:"⌥",opt:"⌥",option:"⌥",shift:"⇧"};function Zl(e){if(e===" ")return"Space";let t=String(e).trim();if(!t||/\b(click|hover|drag|scroll)\b/i.test(t))return null;let n=new Set;t=t.replace(/\b(cmd|command|meta|ctrl|control|alt|opt|option|shift)\s*\+\s*/gi,(r,s)=>(n.add(Gl[s.toLowerCase()]),""));for(;;){t=t.replace(/^\s+/,"");let r=Kt.find((s)=>t.startsWith(s));if(!r||t.trim().length===r.length)break;n.add(r),t=t.slice(r.length)}let o=t.trim();if(zt[o])o=zt[o];else if(/^[a-z]$/i.test(o))o=o.toUpperCase();else if(/^f\d{1,2}$/i.test(o))o=o.toUpperCase();if(!o)return null;return Kt.filter((r)=>n.has(r)).join("")+o}function $r(e){let t=Zl(e);if(!t)throw Error(`actions/keys: '${e}' is not a key chord`);return t}var Jl={Minus:"−",Equal:"=",Slash:"/",Backslash:"\\",BracketLeft:"[",BracketRight:"]",Comma:",",Period:".",Semicolon:";",Quote:"'",Backquote:"`",Space:"Space"};function Hn(e){let t=new Set;if(e.metaKey||e.ctrlKey)t.add("⌘");if(e.altKey)t.add("⌥");let n=e.key??"";if(zt[n])n=zt[n];else if(/^F\d{1,2}$/.test(n));else if(/^[\x21-\x7e]$/.test(n)){if(/^[a-z]$/i.test(n))n=n.toUpperCase();else if(n==="/"&&e.shiftKey&&e.code==="Slash"&&!e.altKey)n="?"}else if(e.code){let s=/^Key([A-Z])$/.exec(e.code)??/^Digit(\d)$/.exec(e.code);n=s?s[1]:Jl[e.code]??n}let o=e.shiftKey&&t.size===0?/^Digit(\d)$/.exec(e.code??""):null;if(o)n=o[1];let r=!!o||/^[A-Z]$/.test(n)||Fr.has(n)||/^F\d/.test(n);if(e.shiftKey&&r)t.add("⇧");return Kt.filter((s)=>t.has(s)).join("")+n}function qr(e){let{mods:t,key:n}=ec(e);if(t.some((o)=>o!=="⇧"))return!1;if(Fr.has(n)||/^F\d{1,2}$/.test(n))return!1;return n.length===1}function jr(e){return e.includes("⌘")||e.includes("⌃")}function ec(e){let t=[],n=e;for(;;){let o=Kt.find((r)=>n.startsWith(r)&&n.length>r.length);if(!o)break;t.push(o),n=n.slice(o.length)}return{mods:t,key:n}}var Ur=new Set(["⌘Z","⇧⌘Z","⌘Y","⌘A","⌘C","⌘X","⌘V","⇧⌘V","⌥⇧⌘V","⌘B","⌘I","⌘U","⌘←","⌘→","⌘↑","⌘↓","⇧⌘←","⇧⌘→","⌥←","⌥→","⌘⌫","⌥⌫"].map($r)),Cp=new Set(["⌘N","⇧⌘N","⌘T","⌘W","⌘Q","⌘L"].map($r));var Fn={view:0,comment:1,edit:2,owner:3},Wr=["timeline","selection","tools","global"];function $n(e,t){if(!e)return!0;if(e.minRole&&Fn[t.role]<Fn[e.minRole])return!1;if(e.shell&&!e.shell.includes(t.shell))return!1;if(e.notShell?.includes(t.shell))return!1;if(e.mode&&!e.mode.includes(t.mode))return!1;if(e.focus&&!e.focus.includes(t.focus))return!1;if(e.selection&&!e.selection.includes(t.selection))return!1;if(e.facts&&!e.facts.every((n)=>t.facts.has(n)))return!1;if(e.notFacts?.some((n)=>t.facts.has(n)))return!1;if(e.any&&!e.any.some((n)=>$n(n,t)))return!1;return!0}function tc(e,t){return $n(e.visible,t)}function Br(e,t=()=>!0){let n=new Map;for(let o of e)for(let r of o.keys??[]){if(!t(o,r))continue;let s=n.get(r.chord)??[];s.push({action:o,binding:r}),n.set(r.chord,s)}return n}function nc(e){return e.inText??(jr(e.chord)&&!Ur.has(e.chord))}function oc(e,t){if(t.focus==="text"&&!nc(e.binding))return!1;if(t.focus==="modal"&&!e.binding.inModal)return!1;if(e.binding.layer==="timeline"&&t.focus!=="timeline")return!1;return tc(e.action,t)&&$n(e.binding.when,t)}function qn(e,t,n,o="tap"){if(n.singleKeys===!1&&qr(t))return null;let r=e.get(t);if(!r?.length)return null;let s=r.filter((a)=>o==="hold"===!!a.binding.hold&&oc(a,n));if(!s.length)return null;for(let a of Wr){let c=s.filter((p)=>p.binding.layer===a);if(c.length)return{action:c[0].action,binding:c[0].binding,ambiguous:c.slice(1)}}return null}function rc(e,t){let n=e.when?.focus;if(t==="shell")return e.layer==="timeline"||!n||n.some((o)=>o==="chrome"||o==="timeline"||o==="modal");return e.layer!=="timeline"&&(!n||n.includes("canvas"))}function Xr(e,t,n){return Br(e,(o,r)=>n(o.id)&&rc(r,t))}var Vt=[{id:"search.open",exec:"shell",fromCanvas:!0,keys:[{chord:"⌘K",layer:"global",inText:!0,when:{notShell:["home"]}}]},{id:"canvas.new",exec:"shell",visible:{minRole:"edit"},keys:[{chord:"⌘N",layer:"global",inText:!0,when:{shell:["desktop"]}}]},{id:"canvas.reload",exec:"shell",fromCanvas:!0,keys:[{chord:"⌘R",layer:"global",inText:!0}]},{id:"edit.undo",exec:"canvas",enabled:{minRole:"edit"},keys:[{chord:"⌘Z",layer:"global",when:{focus:["canvas"]}}]},{id:"edit.redo",exec:"canvas",enabled:{minRole:"edit"},keys:[{chord:"⇧⌘Z",layer:"global",when:{focus:["canvas"]}},{chord:"⌘Y",layer:"global",alias:!0,when:{focus:["canvas"]}}]},{id:"select.all",exec:"canvas",visible:{minRole:"comment"},keys:[{chord:"⌘A",layer:"selection",when:{focus:["canvas"]}}]},{id:"select.all-annotations",exec:"canvas",visible:{minRole:"edit"},keys:[{chord:"⇧⌘A",layer:"global",inText:!1,when:{focus:["canvas"]}}]},{id:"object.duplicate",exec:"canvas",keys:[{chord:"⌘D",layer:"selection",when:{focus:["canvas"],selection:["object"]}}]},{id:"object.copy",exec:"canvas",enabled:{minRole:"edit",selection:["object"]},keys:[{chord:"⌘C",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["object"]}}]},{id:"object.cut",exec:"canvas",enabled:{minRole:"edit",selection:["object"]},keys:[{chord:"⌘X",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["object"]}}]},{id:"artboard.copy",exec:"canvas",enabled:{minRole:"edit",selection:["artboard"]},keys:[{chord:"⌘C",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["artboard"]}}]},{id:"edit.copy-properties",exec:"canvas",visible:{minRole:"comment"},keys:[{chord:"⌥⌘C",layer:"selection",when:{focus:["canvas"],selection:["object"]}},{chord:"⌥⇧⌘C",layer:"selection",when:{focus:["canvas"],selection:["object"]},alias:!0}]},{id:"edit.paste-properties",exec:"canvas",visible:{minRole:"comment"},enabled:{minRole:"edit"},keys:[{chord:"⌥⌘V",layer:"selection",when:{focus:["canvas"],selection:["object"]}},{chord:"⌥⇧⌘V",layer:"selection",when:{focus:["canvas"],selection:["object"]},alias:!0}]},{id:"object.enter",exec:"canvas",keys:[{chord:"↵",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["object"],notFacts:["toolArmed"]}}]},{id:"object.select-parent",exec:"canvas",keys:[{chord:"⇧↵",layer:"selection",when:{focus:["canvas"],selection:["object"]}}]},{id:"object.select-next",exec:"canvas",keys:[{chord:"tab",layer:"selection",when:{focus:["canvas"],mode:["edit"]}}]},{id:"object.select-prev",exec:"canvas",keys:[{chord:"⇧tab",layer:"selection",when:{focus:["canvas"],mode:["edit"]}}]},{id:"object.remove",exec:"canvas",keys:[{chord:"⌫",layer:"selection",when:{focus:["canvas"],selection:["object"]}},{chord:"⇧⌫",layer:"selection",when:{focus:["canvas"],selection:["object"]},alias:!0},{chord:"⌦",layer:"selection",when:{focus:["canvas"],selection:["object"]}},{chord:"⇧⌦",layer:"selection",when:{focus:["canvas"],selection:["object"]},alias:!0}]},{id:"object.nudge",exec:"canvas",keys:[{chord:"←",layer:"selection",when:{focus:["canvas"],selection:["object","artboard"],notFacts:["selectionHasTakes"]}},{chord:"⇧←",layer:"selection",when:{focus:["canvas"],selection:["object","artboard"]},alias:!0},{chord:"→",layer:"selection",when:{focus:["canvas"],selection:["object","artboard"],notFacts:["selectionHasTakes"]}},{chord:"⇧→",layer:"selection",when:{focus:["canvas"],selection:["object","artboard"]},alias:!0},{chord:"↑",layer:"selection",when:{focus:["canvas"],selection:["object","artboard"]}},{chord:"⇧↑",layer:"selection",when:{focus:["canvas"],selection:["object","artboard"]},alias:!0},{chord:"↓",layer:"selection",when:{focus:["canvas"],selection:["object","artboard"]}},{chord:"⇧↓",layer:"selection",when:{focus:["canvas"],selection:["object","artboard"]},alias:!0}]},{id:"object.frame",exec:"canvas",enabled:{minRole:"edit",selection:["object"]},keys:[{chord:"⌥⌘G",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["object"]}},{chord:"⌘G",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["object"]},alias:!0}]},{id:"object.unframe",exec:"canvas",enabled:{minRole:"edit",selection:["object"]},keys:[{chord:"⇧⌘G",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["object"]}}]},{id:"object.bring-front",exec:"canvas",enabled:{minRole:"edit",selection:["object"]},keys:[{chord:"⌘]",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["object"]}}]},{id:"object.bring-forward",exec:"canvas",enabled:{minRole:"edit",selection:["object"]},keys:[{chord:"]",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["object"]}}]},{id:"object.send-backward",exec:"canvas",enabled:{minRole:"edit",selection:["object"]},keys:[{chord:"[",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["object"]}}]},{id:"object.send-back",exec:"canvas",enabled:{minRole:"edit",selection:["object"]},keys:[{chord:"⌘[",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["object"]}}]},{id:"object.lock",exec:"canvas",enabled:{minRole:"edit",selection:["object"]},keys:[{chord:"⇧⌘L",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["object"]}}]},{id:"artboard.duplicate",exec:"canvas",enabled:{minRole:"edit",selection:["artboard"]},keys:[{chord:"⌘D",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["artboard"]}}]},{id:"artboard.trash",exec:"canvas",enabled:{minRole:"edit",selection:["artboard"]},keys:[{chord:"⌫",layer:"selection",when:{focus:["canvas"],selection:["artboard"]}},{chord:"⇧⌫",layer:"selection",when:{focus:["canvas"],selection:["artboard"]},alias:!0},{chord:"⌦",layer:"selection",when:{focus:["canvas"],selection:["artboard"]}},{chord:"⇧⌦",layer:"selection",when:{focus:["canvas"],selection:["artboard"]},alias:!0}]},{id:"ai.ask-selection",exec:"canvas",visible:{minRole:"edit"},enabled:{minRole:"edit",selection:["object"]},keys:[{chord:"⌘/",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["object"]}}]},{id:"inspect.edit",exec:"canvas",enabled:{minRole:"edit",mode:["preview","viewing"],selection:["object"]},keys:[{chord:"↵",layer:"selection",when:{focus:["canvas"],mode:["preview","viewing"],selection:["object"]}}]},{id:"mode.preview",exec:"canvas",keys:[{chord:"⌥⌘P",layer:"global",inText:!0,when:{mode:["edit","preview","viewing"]}}]},{id:"view.panels",exec:"shell",fromCanvas:!0,keys:[{chord:"⌘\\",layer:"global",inText:!0}]},{id:"view.comments",exec:"shell",fromCanvas:!0,keys:[{chord:"⇧⌘M",layer:"global",inText:!0}]},{id:"history.open",exec:"shell",fromCanvas:!0,keys:[{chord:"⌥⌘H",layer:"global",inText:!0}]},{id:"view.inspector",exec:"shell",fromCanvas:!0,keys:[{chord:"⇧⌘I",layer:"global",inText:!0}]},{id:"view.timeline-keep-open",exec:"shell",fromCanvas:!0,keys:[{chord:"⇧⌘T",layer:"global",inText:!0}]},{id:"view.annotations",exec:"canvas",keys:[{chord:"⇧P",layer:"global",inText:!1,when:{focus:["canvas"]}}]},{id:"present.from-selection",exec:"shell",fromCanvas:!0,keys:[{chord:"⌥⌘↵",layer:"global",when:{mode:["edit","viewing","preview"]}}]},{id:"present.from-start",exec:"shell",fromCanvas:!0,keys:[{chord:"⌥⇧⌘↵",layer:"global",when:{mode:["edit","viewing","preview"]}}]},{id:"present.next",exec:"shell",keys:[{chord:"→",layer:"global",when:{mode:["present"]}},{chord:"Space",layer:"global",when:{mode:["present"]}}]},{id:"present.prev",exec:"shell",keys:[{chord:"←",layer:"global",when:{mode:["present"]}},{chord:"⇧Space",layer:"global",when:{mode:["present"]}}]},{id:"view.zoom-in",exec:"canvas",keys:[{chord:"⌘=",layer:"global",inText:!0,when:{focus:["canvas","text"]}},{chord:"⌘+",layer:"global",inText:!0,alias:!0,when:{focus:["canvas","text"]}}]},{id:"view.zoom-out",exec:"canvas",keys:[{chord:"⌘−",layer:"global",inText:!0,when:{focus:["canvas","text"]}}]},{id:"view.zoom-fit",exec:"canvas",keys:[{chord:"⌘0",layer:"global",inText:!0,when:{focus:["canvas","text"]}}]},{id:"view.zoom-actual",exec:"canvas",keys:[{chord:"⇧0",layer:"global",inText:!1,when:{focus:["canvas","text"]}}]},{id:"view.jump-artboard",exec:"canvas",keys:[{chord:"⌥⌘1",layer:"global",inText:!0,alias:!1,when:{focus:["canvas","text"]}},{chord:"⌥⌘2",layer:"global",inText:!0,alias:!0,when:{focus:["canvas","text"]}},{chord:"⌥⌘3",layer:"global",inText:!0,alias:!0,when:{focus:["canvas","text"]}},{chord:"⌥⌘4",layer:"global",inText:!0,alias:!0,when:{focus:["canvas","text"]}},{chord:"⌥⌘5",layer:"global",inText:!0,alias:!0,when:{focus:["canvas","text"]}},{chord:"⌥⌘6",layer:"global",inText:!0,alias:!0,when:{focus:["canvas","text"]}},{chord:"⌥⌘7",layer:"global",inText:!0,alias:!0,when:{focus:["canvas","text"]}},{chord:"⌥⌘8",layer:"global",inText:!0,alias:!0,when:{focus:["canvas","text"]}},{chord:"⌥⌘9",layer:"global",inText:!0,alias:!0,when:{focus:["canvas","text"]}}]},{id:"tool.select",exec:"canvas",keys:[{chord:"V",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit"]}}]},{id:"tool.hand",exec:"canvas",keys:[{chord:"H",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit","preview"]}}]},{id:"tool.frame",exec:"canvas",keys:[{chord:"F",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit","preview","viewing"]}}]},{id:"tool.el-shape",exec:"canvas",keys:[{chord:"R",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit"]}}]},{id:"tool.el-pen",exec:"canvas",keys:[{chord:"P",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit","preview","viewing"]}}]},{id:"tool.el-text",exec:"canvas",keys:[{chord:"T",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit"]}}]},{id:"tool.image",exec:"canvas",keys:[{chord:"I",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit","preview","viewing"]}}]},{id:"tool.components",exec:"canvas",keys:[{chord:"⇧I",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit","preview","viewing"]}}]},{id:"tool.browse",exec:"canvas",keys:[{chord:"V",layer:"tools",when:{focus:["canvas","chrome"],mode:["preview","viewing"]}}]},{id:"tool.sticky",exec:"canvas",keys:[{chord:"N",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit","preview","viewing"]}}]},{id:"tool.comment",exec:"canvas",keys:[{chord:"C",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit","preview","viewing"]}}]},{id:"tool.pen",exec:"canvas",keys:[{chord:"M",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit","preview","viewing"]}}]},{id:"tool.arrow",exec:"canvas",keys:[{chord:"A",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit","preview","viewing"]}}]},{id:"tool.shape",exec:"canvas",keys:[{chord:"R",layer:"tools",when:{focus:["canvas","chrome"],mode:["preview","viewing"]}}]},{id:"tool.text",exec:"canvas",keys:[{chord:"T",layer:"tools",when:{focus:["canvas","chrome"],mode:["preview","viewing"]}}]},{id:"tool.stickers",exec:"canvas",keys:[{chord:"E",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit","preview","viewing"]}}]},{id:"tool.section",exec:"canvas",keys:[{chord:"S",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit","preview","viewing"]}}]},{id:"tool.inspect",exec:"canvas",keys:[{chord:"H",layer:"tools",when:{focus:["canvas","chrome"],mode:["viewing"]}}]},{id:"tool.pointer",exec:"canvas",keys:[{chord:"L",layer:"tools",when:{focus:["canvas","chrome"],mode:["present"]}}]},{id:"tool.hand-hold",exec:"canvas",keys:[{chord:"Space",layer:"tools",hold:!0,when:{focus:["canvas"]}},{chord:"⌥Space",layer:"tools",hold:!0,when:{focus:["canvas"]},alias:!0},{chord:"⇧Space",layer:"tools",hold:!0,when:{focus:["canvas"]},alias:!0},{chord:"⌥⇧Space",layer:"tools",hold:!0,when:{focus:["canvas"]},alias:!0},{chord:"⌘Space",layer:"tools",hold:!0,when:{focus:["canvas"]},alias:!0},{chord:"⌥⌘Space",layer:"tools",hold:!0,when:{focus:["canvas"]},alias:!0},{chord:"⇧⌘Space",layer:"tools",hold:!0,when:{focus:["canvas"]},alias:!0},{chord:"⌥⇧⌘Space",layer:"tools",hold:!0,when:{focus:["canvas"]},alias:!0}]},{id:"tool.create-default",exec:"canvas",enabled:{minRole:"edit"},keys:[{chord:"↵",layer:"tools",when:{focus:["canvas"],mode:["edit","preview"],facts:["toolArmed"]}}]},{id:"ui.step-back",exec:"shell",keys:[{chord:"esc",layer:"selection",inText:!1,when:{focus:["canvas"]}},{chord:"⌥esc",layer:"selection",inText:!1,when:{focus:["canvas"]},alias:!0},{chord:"⇧esc",layer:"selection",inText:!1,when:{focus:["canvas"]},alias:!0},{chord:"⌥⇧esc",layer:"selection",inText:!1,when:{focus:["canvas"]},alias:!0},{chord:"⌘esc",layer:"selection",inText:!1,when:{focus:["canvas"]},alias:!0},{chord:"⌥⌘esc",layer:"selection",inText:!1,when:{focus:["canvas"]},alias:!0},{chord:"⇧⌘esc",layer:"selection",inText:!1,when:{focus:["canvas"]},alias:!0},{chord:"⌥⇧⌘esc",layer:"selection",inText:!1,when:{focus:["canvas"]},alias:!0}]},{id:"ui.cycle-region",exec:"shell",fromCanvas:!0,keys:[{chord:"F6",layer:"global",inText:!0},{chord:"⇧F6",layer:"global",inText:!0,alias:!0}]},{id:"timeline.split",exec:"shell",keys:[{chord:"⌘B",layer:"global",when:{facts:["timelineVisible"]},inText:!1,alias:!0}]},{id:"export.open",exec:"shell",visible:{minRole:"comment"},fromCanvas:!0,keys:[{chord:"⇧⌘E",layer:"global",inText:!0}]},{id:"export.copy-png",exec:"shell",visible:{minRole:"comment"},enabled:{facts:["canvasOpen"]},fromCanvas:!0,keys:[{chord:"⇧⌘C",layer:"selection",inText:!1,when:{selection:["artboard","object","video-artboard","generated-image"]}}]},{id:"handoff.open",exec:"shell",visible:{minRole:"comment"},enabled:{minRole:"edit",facts:["canvasOpen"]},fromCanvas:!0,keys:[{chord:"⇧⌘H",layer:"global",inText:!0}]},{id:"settings.open",exec:"shell",fromCanvas:!0,keys:[{chord:"⌘,",layer:"global",inText:!0,when:{focus:["chrome","timeline","text","canvas"]}}]},{id:"help.shortcuts",exec:"shell",fromCanvas:!0,keys:[{chord:"?",layer:"global",inText:!1,when:{focus:["chrome","timeline","canvas"],notFacts:["rangeFocused"]}},{chord:"⌘?",layer:"global",inText:!1,alias:!0,when:{focus:["chrome","timeline","canvas"],notFacts:["rangeFocused"]}}]},{id:"annotation.group",exec:"canvas",keys:[{chord:"⌘G",layer:"selection",when:{focus:["canvas"],selection:["annotation"],mode:["preview"]}}]},{id:"annotation.ungroup",exec:"canvas",keys:[{chord:"⇧⌘G",layer:"selection",when:{focus:["canvas"],selection:["annotation"],mode:["preview"]}}]},{id:"annotation.lock",exec:"canvas",keys:[{chord:"⇧⌘L",layer:"selection",when:{focus:["canvas"],selection:["annotation"],mode:["preview"]}}]},{id:"annotation.duplicate",exec:"canvas",keys:[{chord:"⌘D",layer:"selection",when:{focus:["canvas"],selection:["annotation"]}}]},{id:"annotation.to-front",exec:"canvas",keys:[{chord:"]",layer:"selection",when:{focus:["canvas"],selection:["annotation"],mode:["preview"]}}]},{id:"annotation.forward",exec:"canvas",keys:[{chord:"⌘]",layer:"selection",when:{focus:["canvas"],selection:["annotation"],mode:["preview"]}}]},{id:"annotation.to-back",exec:"canvas",keys:[{chord:"[",layer:"selection",when:{focus:["canvas"],selection:["annotation"],mode:["preview"]}}]},{id:"annotation.backward",exec:"canvas",keys:[{chord:"⌘[",layer:"selection",when:{focus:["canvas"],selection:["annotation"],mode:["preview"]}}]},{id:"annotation.copy",exec:"canvas",keys:[{chord:"⌘C",layer:"selection",when:{focus:["canvas"],selection:["annotation"]}}]},{id:"annotation.cut",exec:"canvas",keys:[{chord:"⌘X",layer:"selection",when:{focus:["canvas"],selection:["annotation"]}}]},{id:"annotation.chain",exec:"canvas",keys:[{chord:"⌘↵",layer:"selection",when:{focus:["canvas"],selection:["annotation"]}}]},{id:"annotation.edit-text",exec:"canvas",keys:[{chord:"↵",layer:"selection",when:{focus:["canvas"],selection:["annotation"]}}]},{id:"annotation.nudge",exec:"canvas",keys:[{chord:"←",layer:"selection",when:{focus:["canvas"],selection:["annotation"]}},{chord:"⇧←",layer:"selection",when:{focus:["canvas"],selection:["annotation"]},alias:!0},{chord:"→",layer:"selection",when:{focus:["canvas"],selection:["annotation"]}},{chord:"⇧→",layer:"selection",when:{focus:["canvas"],selection:["annotation"]},alias:!0},{chord:"↑",layer:"selection",when:{focus:["canvas"],selection:["annotation"]}},{chord:"⇧↑",layer:"selection",when:{focus:["canvas"],selection:["annotation"]},alias:!0},{chord:"↓",layer:"selection",when:{focus:["canvas"],selection:["annotation"]}},{chord:"⇧↓",layer:"selection",when:{focus:["canvas"],selection:["annotation"]},alias:!0}]},{id:"annotation.remove",exec:"canvas",keys:[{chord:"⌫",layer:"selection",when:{focus:["canvas"],selection:["annotation"]}},{chord:"⇧⌫",layer:"selection",when:{focus:["canvas"],selection:["annotation"]},alias:!0},{chord:"⌦",layer:"selection",when:{focus:["canvas"],selection:["annotation"]}},{chord:"⇧⌦",layer:"selection",when:{focus:["canvas"],selection:["annotation"]},alias:!0}]},{id:"annotation.ask-ai",exec:"canvas",enabled:{minRole:"edit",selection:["annotation"]},keys:[{chord:"⌘/",layer:"selection",when:{focus:["canvas"],selection:["annotation"],mode:["preview"]}}]},{id:"project.new",exec:"shell",visible:{minRole:"comment"},keys:[{chord:"⇧⌘N",layer:"global",inText:!0,when:{shell:["desktop"]}}]},{id:"project.open",exec:"native",visible:{minRole:"comment"},keys:[{chord:"⌘O",layer:"global",inText:!0,when:{shell:["desktop"]}}]},{id:"home.open",exec:"native",keys:[{chord:"⌘T",layer:"global",inText:!0,when:{shell:["desktop"]}}]},{id:"home.search",exec:"shell",visible:{shell:["home"]},keys:[{chord:"⌘K",layer:"global",inText:!0,when:{shell:["home"]}}]},{id:"tab.close",exec:"native",keys:[{chord:"⌘W",layer:"global",inText:!0,when:{shell:["desktop"]}}]},{id:"tab.next",exec:"native",keys:[{chord:"⌃tab",layer:"global",inText:!0,when:{shell:["desktop"]}},{chord:"⇧⌘]",layer:"global",inText:!0,alias:!0,when:{shell:["desktop"]}}]},{id:"tab.prev",exec:"native",keys:[{chord:"⌃⇧tab",layer:"global",inText:!0,when:{shell:["desktop"]}},{chord:"⇧⌘[",layer:"global",inText:!0,alias:!0,when:{shell:["desktop"]}}]},{id:"tab.overview",exec:"native",keys:[{chord:"⇧⌘\\",layer:"global",inText:!0,when:{shell:["desktop"]}}]},{id:"tab.select-1",exec:"native",keys:[{chord:"⌘1",layer:"global",inText:!0,when:{shell:["desktop"]}}]},{id:"tab.select-2",exec:"native",keys:[{chord:"⌘2",layer:"global",inText:!0,when:{shell:["desktop"]}}]},{id:"tab.select-3",exec:"native",keys:[{chord:"⌘3",layer:"global",inText:!0,when:{shell:["desktop"]}}]},{id:"tab.select-4",exec:"native",keys:[{chord:"⌘4",layer:"global",inText:!0,when:{shell:["desktop"]}}]},{id:"tab.select-5",exec:"native",keys:[{chord:"⌘5",layer:"global",inText:!0,when:{shell:["desktop"]}}]},{id:"tab.select-6",exec:"native",keys:[{chord:"⌘6",layer:"global",inText:!0,when:{shell:["desktop"]}}]},{id:"tab.select-7",exec:"native",keys:[{chord:"⌘7",layer:"global",inText:!0,when:{shell:["desktop"]}}]},{id:"tab.select-8",exec:"native",keys:[{chord:"⌘8",layer:"global",inText:!0,when:{shell:["desktop"]}}]},{id:"tab.select-last",exec:"native",keys:[{chord:"⌘9",layer:"global",inText:!0,when:{shell:["desktop"]}}]}];function Qr(e){let t=new Set(e);return Xr(Vt,"canvas",(n)=>t.has(n))}var Up=Object.freeze({edit:["stroke","selection","tool"],preview:["stroke","tool","selection"],viewing:["stroke","tool","selection"],present:[]}),Wp=Object.freeze({edit:"stay",preview:"stay",viewing:"stay",present:"back"}),Yr="data-esc-owner";function Gr(e){let t=e?.querySelectorAll?.(`[${Yr}]`);if(!t)return!1;for(let n of Array.from(t)){if(n.getAttribute(Yr)!=="focus")return!0;let o=e?.activeElement??null;if(o&&(n===o||n.contains(o)))return!0}return!1}var sc=["pen","highlighter","eraser"],ic=Symbol.for("maude.markerTip.v2"),ac=(e)=>typeof e==="string"&&sc.includes(e);function Zr(){let e=globalThis[ic];return ac(e)?e:"pen"}function Jr(e){let t=(n)=>Number.isFinite(n)?Math.max(0,Math.round(n)):0;return{x:t(e.left),y:t(e.top),w:t(e.width),h:t(e.height)}}function jn(e,t){let n=null;if(t){let o=Jr(t.getBoundingClientRect());n=o.w>0&&o.h>0?o:null}return{dgn:"tool-panel-open",panel:e,anchor:n}}var es=!1,ts=!1;function Un(e=globalThis.document){if(es=!0,ts||!e)return;ts=!0,e.addEventListener("pointerdown",()=>{es=!1},!0)}function ns(e,t){try{if(typeof window>"u"||window.parent===window)return;Un(),window.parent.postMessage(jn(e,t),"*")}catch{}}function os(e,t){return t==="section"&&e!=="section"?"templates":null}var cc=new Set(["pen","highlighter","shape","rect","ellipse","arrow","sticky","text","el-text","frame","el-shape","line","polygon","slice","el-pen","section","eraser"]);function us(e){return cc.has(e)}var ps={"ui.step-back":{kind:"escape"},"edit.undo":{kind:"undo"},"edit.redo":{kind:"redo"}},dc=Qr(Vt.filter((e)=>e.id.startsWith("tool.")&&e.id!=="tool.hand-hold"||e.id==="mode.preview").map((e)=>e.id).concat(Object.keys(ps))),uc=new Set([...Xt,"el-text","frame","el-shape","ellipse","line","polygon","slice","el-pen","crop","inspect"]),rs=(e)=>lo(e,(t)=>uc.has(t));function pc(e,t,n){let o=!!n.mode;if(!o&&e==="V")return{kind:"tool",tool:"move"};let r=co(t,e,n.caps??ro,n.markerTip??"pen");if(!r)return{kind:"no-op"};if(r.kind==="insert")return{kind:"insert",insert:r.insert};if(r.kind==="panel")return{kind:"panel",panel:r.panel};if(r.kind==="arm"){let a=rs(r.tool);return a?{kind:"tool",tool:a}:{kind:"no-op"}}if(o){if(r.kind==="deny"&&r.panel)return{kind:"panel",panel:r.panel};let a={kind:"mode-request",mode:r.mode,cause:"key"};if(r.tool)a.tool=r.tool;if(r.kind==="request"&&r.panel)a.panel=r.panel;return a}if(r.kind==="request"&&r.panel)return{kind:"panel",panel:r.panel};let s=rs(r.tool??Je[r.mode].rest);return s?{kind:"tool",tool:s}:{kind:"no-op"}}function mc(e){let t=Hn({key:e.key??"",code:e.code,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey}),n=e.mode??null,o=n??(e.activeTool==="browse"?"preview":"edit"),r=qn(dc,t,Vn({typing:!!e.isEditable,readOnly:!1,mode:o,singleKeys:e.singleKeys}));if(!r)return{kind:"no-op"};let s=r.action.id;if(s==="mode.preview"){if(n)return{kind:"mode-request",mode:n==="preview"?"back":"preview",cause:"key"};return{kind:"tool",tool:e.activeTool==="browse"?"move":"browse"}}if(s.startsWith("tool."))return pc(r.binding.chord,o,e);let a=ps[s];if(!a)return{kind:"no-op"};if(a.kind==="escape"&&n&&!dn()){if(Zt(n,e.activeTool)==="back")return{kind:"escape",back:!0};if(Do())return{kind:"escape",back:!0}}return{...a}}var at=(e)=>!!(e.metaKey||e.ctrlKey);function ss(e){if(!us(e.activeTool))return!1;return!e.mode||pt(e.mode,"annotations-editable")}function lt(e){if(e.type==="keydown")return mc(e);if(e.type==="contextmenu")return{kind:"context-menu",clientX:e.clientX??0,clientY:e.clientY??0};if(e.type==="pointermove"){if(ss(e))return{kind:"no-op"};if(e.activeTool==="hand")return{kind:"no-op"};if(e.activeTool==="browse"){if(!at(e))return{kind:"no-op"};return{kind:"hover",deep:!0,clientX:e.clientX??0,clientY:e.clientY??0}}if(e.activeTool==="inspect")return{kind:"hover",deep:!0,clientX:e.clientX??0,clientY:e.clientY??0};if(e.activeTool==="comment")return{kind:"hover",deep:!0,clientX:e.clientX??0,clientY:e.clientY??0};return{kind:"hover",deep:at(e),clientX:e.clientX??0,clientY:e.clientY??0}}if(e.type==="pointerdown"){if(e.button===2)return{kind:"context-menu",clientX:e.clientX??0,clientY:e.clientY??0};if(e.button===1||e.spaceHeld)return{kind:"no-op"};if(e.button!==0)return{kind:"no-op"};if(ss(e)&&!at(e))return{kind:"no-op"};if(e.activeTool==="comment")return{kind:"drop-comment",clientX:e.clientX??0,clientY:e.clientY??0};if(e.activeTool==="hand")return{kind:"no-op"};if(e.activeTool==="inspect")return{kind:"select",mode:"replace",deep:!0,clientX:e.clientX??0,clientY:e.clientY??0};if(e.activeTool==="browse"){if(!at(e)){if(e.previewLabel)return{kind:"select",mode:e.shiftKey?"add":"replace",deep:!1,clientX:e.clientX??0,clientY:e.clientY??0};return{kind:"no-op"}}return{kind:"select",mode:e.shiftKey?"add":"replace",deep:!0,clientX:e.clientX??0,clientY:e.clientY??0}}let t=at(e);return{kind:"select",mode:!!e.shiftKey?"add":"replace",deep:t,clientX:e.clientX??0,clientY:e.clientY??0}}return{kind:"no-op"}}function Ht(e){if(!e||!e.tagName)return!1;let t=e,n=t.tagName;if(n==="INPUT"||n==="TEXTAREA"||n==="SELECT")return!0;if(t.isContentEditable)return!0;let o=t.getAttribute?.("contenteditable");if(o==="true"||o==="plaintext-only"||o==="")return!0;return!1}function ct(e){if(!e||!e.closest)return!1;let t=e;if(t.closest(".dc-world"))return!1;return!!t.closest(".cm-composer, .cm-thread, .cm-mention-popup, .cm-pin, [data-mediaref-player], [data-vplay], .dc-tool-palette, .dc-zoom-tb, .dc-mm, .dc-context-menu")}function ms(e){if(!e||typeof e.closest!=="function")return!1;let t=e;return!!t.closest("[data-dc-screen]")&&!t.closest(".dc-artboard-body")}function is(e,t){if(!t||!pt(t,"live-design")||!e||typeof e.closest!=="function")return!1;return!!e.closest("button.dc-artboard-label")}function as(e,t,n){return e.kind==="select"&&!n.metaKey&&!n.ctrlKey&&(ms(t)||fc(t,n.clientX,n.clientY))}function fc(e,t,n){if(!e||typeof e.closest!=="function")return!1;let o=e;if(!o.closest(".dc-artboard-body")||typeof t!=="number"||typeof n!=="number")return!1;let r=Ft(o.ownerDocument,t,n,{deep:!1});return!!r&&r.cdId===null&&r.el.hasAttribute("data-dc-screen")}function gc(e,t,n){return e==="select"&&!n.metaKey&&!n.ctrlKey&&ms(t)}var hc="maude:toolbar-insert",bc=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,yc=/^[A-Za-z0-9_-]{1,64}$/;function wc(e,t){if(!pt(t.mode,"live-design")||t.button!==0||t.mod||t.shift)return null;let n=e?.closest?.("[data-cd-link]"),o=n?.getAttribute("data-cd-id");if(!n||!o||o.length>48||!bc.test(o)||/^[0-9a-f]{8}$/.test(o))return null;let r=n.closest("[data-dc-screen]")?.getAttribute("data-dc-screen")??null;return{elementId:o,artboardId:r&&yc.test(r)?r:null}}var ls=new WeakSet;function vc(e){if(typeof window>"u"||window.parent===window)return!1;let t=wc(e.target,{mode:ve(window).get()?.mode??null,button:e.button,mod:e.metaKey||e.ctrlKey,shift:e.shiftKey});if(!t)return!1;if(e.preventDefault(),ls.has(e))return!0;ls.add(e);try{window.parent.postMessage({dgn:"link-follow",elementId:t.elementId,artboardId:t.artboardId},"*")}catch{}return!0}function cs(e){if(typeof window>"u"||window.parent===window)return;if(!ve(window).claimRequest(`${e.mode}|${e.tool??""}`))return;try{window.parent.postMessage(e.tool?{dgn:"mode-request",mode:e.mode,tool:e.tool,cause:e.cause}:{dgn:"mode-request",mode:e.mode,cause:e.cause},"*")}catch{}}function ds(e){if(typeof window>"u"||window.parent===window)return;try{let t=document.querySelector(`[data-testid="toolbar-slot-${e}"]`);Un(),window.parent.postMessage(jn(e,t),"*")}catch{}}function fs(e){let{hostRef:t,getActiveTool:n,isSpaceHeld:o,callbacks:r,enabled:s=!0,claimableActions:a}=e;lc(()=>{if(!s)return;let c=t.current;if(!c)return;let p=(i)=>a&&i.kind!=="no-op"&&!a.has(i.kind)?{kind:"no-op"}:i,f=(i)=>{switch(i.kind){case"hover":r.onHover?.(i);break;case"select":r.onSelect?.(i);break;case"drop-comment":r.onDropComment?.(i);break;case"context-menu":r.onContextMenu?.(i);break;case"tool":r.onTool?.(i);break;case"escape":{let b=r.onEscape?.();if(i.back&&b!==!0)cs({mode:"back",cause:"esc"});break}case"mode-request":if(cs(i),i.panel)ds(i.panel);break;case"insert":if(typeof document<"u")document.dispatchEvent(new CustomEvent(hc,{detail:{kind:i.insert}}));break;case"panel":ds(i.panel);break;case"undo":r.onUndo?.();break;case"redo":r.onRedo?.();break;case"no-op":break}},x=()=>typeof window<"u"?ve(window).get().mode:null,g=(i)=>{let b=p(lt({type:"pointermove",button:i.button,metaKey:i.metaKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,altKey:i.altKey,clientX:i.clientX,clientY:i.clientY,spaceHeld:o?.()??!1,activeTool:n()}));f(b)},w=(i)=>{if(ct(i.target))return;if(Ht(i.target))return;let b=p(lt({type:"pointerdown",button:i.button,metaKey:i.metaKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,altKey:i.altKey,clientX:i.clientX,clientY:i.clientY,spaceHeld:o?.()??!1,activeTool:n(),previewLabel:is(i.target,x())})),E=as(b,i.target,i)||b.kind==="select"&&n()==="inspect";if(b.kind!=="no-op"){if(i.preventDefault(),!E)i.stopImmediatePropagation()}f(b)},A=(i)=>{if(ct(i.target))return;if(Ht(i.target))return;let b=p(lt({type:"pointerdown",button:i.button,metaKey:i.metaKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,altKey:i.altKey,clientX:i.clientX,clientY:i.clientY,spaceHeld:o?.()??!1,activeTool:n(),previewLabel:is(i.target,x())})),E=as(b,i.target,i);if(b.kind!=="no-op"){if(i.preventDefault(),!E)i.stopImmediatePropagation();if(b.kind==="select")try{window.focus()}catch{}}},m=(i)=>{if(ct(i.target))return;if(Ht(i.target))return;if(vc(i))return;let b=n(),E=i.metaKey||i.ctrlKey,L=b==="comment"?"drop-comment":(b==="move"||b==="inspect")&&i.button===0?"select":(us(b)||b==="browse")&&E&&i.button===0?"select":i.button===2?"context-menu":null;if(L&&(!a||a.has(L))){let O=gc(L,i.target,i);if(i.preventDefault(),!O)i.stopImmediatePropagation()}},h=(i)=>{let b=p(lt({type:"contextmenu",clientX:i.clientX,clientY:i.clientY,metaKey:i.metaKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,altKey:i.altKey,activeTool:n()}));if(b.kind==="no-op")return;i.preventDefault(),i.stopImmediatePropagation(),f(b)},S=(i)=>{let b=typeof window<"u"?ve(window).get():null,E=p(lt({type:"keydown",key:i.key,code:i.code,metaKey:i.metaKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,altKey:i.altKey,isEditable:Ht(i.target),activeTool:n(),mode:b?.mode??null,caps:b?.caps??null,markerTip:Zr(),singleKeys:b?.singleKeys??!0}));if(E.kind==="escape"&&Gr(c.ownerDocument??document))return;if(E.kind==="tool"||E.kind==="mode-request"||E.kind==="insert"||E.kind==="panel"||E.kind==="escape"&&!dn()||E.kind==="undo"||E.kind==="redo")i.preventDefault();f(E)};c.addEventListener("pointermove",g,{passive:!0}),c.addEventListener("pointerdown",w,{capture:!0}),c.addEventListener("mousedown",A,{capture:!0}),c.addEventListener("click",m,{capture:!0}),c.addEventListener("contextmenu",h,{capture:!0});let y=c.ownerDocument??document;return y.addEventListener("keydown",S,!0),()=>{c.removeEventListener("pointermove",g),c.removeEventListener("pointerdown",w,{capture:!0}),c.removeEventListener("mousedown",A,{capture:!0}),c.removeEventListener("click",m,{capture:!0}),c.removeEventListener("contextmenu",h,{capture:!0}),y.removeEventListener("keydown",S,!0)}},[s,t,n,o,r,a])}function xc(e,t=(n)=>n.getBoundingClientRect()){let n=e.querySelector("[data-cd-id]");if(!n)return null;for(let s=n;s&&s!==e;s=s.parentElement)for(let a=s.nextElementSibling;a;a=a.nextElementSibling)if(a.hasAttribute("data-cd-id")||a.querySelector("[data-cd-id]"))return null;let o=t(e),r=t(n);if(!(o.width>0&&o.height>0))return null;if(r.width<o.width*0.98||r.height<o.height*0.98)return null;return n}function Ft(e,t,n,o){let r=e.elementFromPoint(t,n);if(!r)return null;if(r.closest?.(".dc-mm, .dc-zoom-tb, .dc-tool-palette, .dc-context-menu, .dc-cv-group-bbox"))return null;let s=r.closest?.("[data-dc-screen]")??null,a=s?.getAttribute("data-dc-screen")??null,c=r.closest?.(".dc-artboard-body")??null;if(!c){if(s&&a)return{el:s,cdId:null,artboardId:a};return null}if(r===c){if(s&&a)return{el:s,cdId:null,artboardId:a};return null}if(o.deep){let A=r.getAttribute?.("data-cd-id")??null;return{el:r,cdId:A,artboardId:a}}let p=r,f=null,x=null;while(p&&p!==c){if(p.hasAttribute?.("data-cd-id"))x=f,f=p;p=p.parentElement}if(f&&xc(c)===f){if(!x)return s&&a?{el:s,cdId:null,artboardId:a}:null;f=x}let g=f??r,w=g.getAttribute?.("data-cd-id")??null;return{el:g,cdId:w,artboardId:a}}import{useCallback as Nc,useEffect as Ts,useRef as Ut}from"react";var kc=!1;function gs(){return kc}import{createContext as Cc,useCallback as qe,useContext as Ss,useEffect as dt,useMemo as ws,useRef as Le,useState as $t}from"react";function Se(e,t,n,o){return`url("data:image/svg+xml,${encodeURIComponent(e.trim())}") ${t} ${n}, ${o}`}var Bn="width='24' height='24' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'",Xn="#1f1f1f",Wn="stroke='#ffffff' stroke-linejoin='round' stroke-linecap='round'";function $e(e,t,n){let o=n?`<g transform='${n}'>`:"";return`<svg ${Bn}>${o}<path fill='#ffffff' d='${e}'/><path fill='${Xn}' d='${t}'/>${n?"</g>":""}</svg>`}var ys="translate(0,32) scale(1,-1)",hs=Se($e("M10.25 8.25 L10.05 8.65 10 9 10 23.1 10.05 23.4 10.25 23.75 10.8 24 11.45 23.85 11.6 23.7 11.75 23.45 14.65 19.8 14.85 19.65 14.95 19.5 15.4 19.2 15.95 19.1 21.05 19.1 21.2 19.1 21.35 19.05 21.65 18.9 21.9 18.6 22 18.3 22 17.9 21.9 17.65 21.75 17.35 21.65 17.3 21.55 17.15 11.5 8.25 11.25 8.05 10.95 8 10.6 8.05 10.25 8.25 M9.15 6.6 L9.7 6.25 10 6.15 10.95 6 11.9 6.15 13 6.9 22.9 15.65 23 15.8 23.2 15.95 23.75 16.75 24 17.9 24 18.3 23.9 18.95 23.8 19.25 23.6 19.7 23.1 20.35 22.75 20.6 22.1 20.9 22.05 20.95 22 20.95 21.2 21.1 21.05 21.1 16.2 21.1 16.1 21.25 16.05 21.25 13.4 24.6 13.05 25.15 12.9 25.3 12.55 25.55 Q11.6 26.15 10.55 26 L10.5 26 Q9.65 25.85 9 25.3 L8.45 24.65 8.4 24.5 8.15 24.05 8 23.1 8 9 Q8 8.45 8.15 8.05 L8.25 7.75 8.45 7.35 9.15 6.6","M10.25 8.25 L10.6 8.05 10.95 8 11.25 8.05 11.5 8.25 21.55 17.15 21.65 17.3 21.75 17.35 21.9 17.65 22 17.9 22 18.3 21.9 18.6 21.65 18.9 21.35 19.05 21.2 19.1 21.05 19.1 15.95 19.1 15.4 19.2 14.95 19.5 14.85 19.65 14.65 19.8 11.75 23.45 11.6 23.7 11.45 23.85 10.8 24 10.25 23.75 10.05 23.4 10 23.1 10 9 10.05 8.65 10.25 8.25"),8,5,"default"),Sc=Se($e("M28.55 17.8 Q29.4 20.3 28.75 22.8 L28.7 23 28.15 24.55 28.05 24.75 Q26.4 28.2 22.75 29.4 L22.45 29.5 18 29.9 17.75 29.85 Q15.8 29.25 13.8 28.1 L13.45 27.95 Q12 27.05 10.35 26.8 L10.25 26.75 7.9 26.7 7.8 26.7 Q6.1 26.9 4.8 25.8 L4.75 25.8 4.65 25.7 4.6 25.65 Q3.25 24.5 3.05 22.85 L3 22.75 Q2.8 20.95 4 19.5 5.05 18.15 6.75 17.95 L8.4 17.9 7.5 15.55 7.3 15.2 7.2 15 5 10.95 Q3.9 9.15 4.3 7.75 L4.4 7.5 Q4.75 6.15 6.45 5.2 9 3.65 11 5 11.05 4.1 11.5 3.45 12.15 2.1 14.2 1.6 L14.35 1.6 Q18.05 0.6 19.6 4.4 L19.65 4.55 Q20.75 3.65 22.7 3.75 L22.75 3.75 Q26.75 4 27 8.15 L27 8.25 27 8.35 27 8.45 Q26.9 10.75 27.1 12.6 27.15 14.65 28.2 16.75 L28.55 17.8 M26.65 18.4 L26.1 16.8 26.1 16.85 Q24.8 13.7 25 8.35 L25 8.25 Q24.85 5.9 22.6 5.75 20.7 5.65 20.4 7.35 L20.1 7.95 19.5 8.2 18.85 8.05 18.45 7.5 17.75 5.15 Q16.85 2.95 14.7 3.55 L14.65 3.55 Q12.55 4.05 13.15 6.15 L13.85 8.75 13.75 9.45 13.25 9.95 12.55 9.95 12 9.55 10.9 7.7 Q9.5 5.7 7.45 6.9 6.5 7.45 6.25 8.15 6.1 8.9 6.7 9.85 9.2 13.9 10.8 18.65 L10.8 19.3 10.4 19.8 9.75 19.95 Q8.35 19.8 6.95 19.95 6.1 20.05 5.55 20.75 4.9 21.55 5 22.55 5.15 23.55 6 24.2 L6.05 24.25 Q6.75 24.85 7.65 24.7 L7.7 24.7 10.65 24.8 Q12.7 25.15 14.45 26.2 L14.5 26.2 Q16.4 27.35 18.3 27.9 L22.05 27.5 22.1 27.5 Q24.95 26.55 26.25 23.85 L26.8 22.3 Q27.3 20.35 26.65 18.4","M26.65 18.4 Q27.3 20.35 26.8 22.3 L26.25 23.85 Q24.95 26.55 22.1 27.5 L22.05 27.5 18.3 27.9 Q16.4 27.35 14.5 26.2 L14.45 26.2 Q12.7 25.15 10.65 24.8 L7.7 24.7 7.65 24.7 Q6.75 24.85 6.05 24.25 L6 24.2 Q5.15 23.55 5 22.55 4.9 21.55 5.55 20.75 6.1 20.05 6.95 19.95 8.35 19.8 9.75 19.95 L10.4 19.8 10.8 19.3 10.8 18.65 Q9.2 13.9 6.7 9.85 6.1 8.9 6.25 8.15 6.5 7.45 7.45 6.9 9.5 5.7 10.9 7.7 L12 9.55 12.55 9.95 13.25 9.95 13.75 9.45 13.85 8.75 13.15 6.15 Q12.55 4.05 14.65 3.55 L14.7 3.55 Q16.85 2.95 17.75 5.15 L18.45 7.5 18.85 8.05 19.5 8.2 20.1 7.95 20.4 7.35 Q20.7 5.65 22.6 5.75 24.85 5.9 25 8.25 L25 8.35 Q24.8 13.7 26.1 16.85 L26.1 16.8 26.65 18.4"),12,12,"grab"),Ec=Se($e("M28 14 Q28 9.85 24.45 6.9 20.95 4 16 4 11.05 4 7.5 6.9 L7.45 7 Q4 9.9 4 14 4 18.15 7.55 21.05 L7.5 21.05 Q9.2 22.45 11.2 23.2 L15.3 27.3 16 27.6 16.7 27.3 20.85 23.2 Q22.7 22.45 24.3 21.15 L24.45 21.05 Q28 18.15 28 14 M25.75 5.35 Q30.05 8.95 30 14 30.05 19.05 25.75 22.6 L25.4 22.85 Q23.8 24.1 22 24.9 L18.1 28.75 18.15 28.75 Q17.2 29.6 16 29.6 14.8 29.6 13.85 28.75 L13.9 28.75 10 24.9 6.6 22.85 6.25 22.6 Q1.95 19.05 2 14 1.95 8.95 6.25 5.35 10.3 2 16 2 21.7 2 25.75 5.35","M28 14 Q28 18.15 24.45 21.05 L24.3 21.15 Q22.7 22.45 20.85 23.2 L16.7 27.3 16 27.6 15.3 27.3 11.2 23.2 Q9.2 22.45 7.5 21.05 L7.55 21.05 Q4 18.15 4 14 4 9.9 7.45 7 L7.5 6.9 Q11.05 4 16 4 20.95 4 24.45 6.9 28 9.85 28 14"),12,21,"crosshair"),Tc=Se($e("M4 13.1 L4 6 Q4 5.15 4.6 4.6 5.15 4 6 4 L13.1 4 Q13.95 4 14.55 4.6 L28.65 18.75 Q29.8 19.9 29.75 21.45 L29.75 21.6 29.75 21.7 Q29.75 23.2 28.7 24.35 L24.45 28.65 24.35 28.75 Q23.15 29.85 21.65 29.8 L21.55 29.8 21.4 29.8 Q20.2 29.8 19.25 29.15 L18 29.35 Q16.6 29.4 15.25 28 L15.2 27.95 8.2 20.95 Q7.6 20.35 7.6 19.55 7.6 18.7 8.2 18.1 L4.6 14.5 Q4 13.9 4 13.1 M19.5 26.65 L20.1 27.25 Q20.7 27.85 21.5 27.8 22.35 27.85 23 27.25 L27.25 22.95 Q27.8 22.35 27.75 21.55 27.8 20.75 27.2 20.15 L13.1 6 6 6 6 13.1 12.35 19.45 9.6 19.5 16.65 26.55 Q18.05 28.05 19.5 26.65 M8.05 12.3 L8 8 12.25 8.05 13.8 9.6 9.6 13.85 8.05 12.3 M15.25 11.05 L23 18.8 18.8 23.05 11.05 15.3 15.25 11.05","M15.25 11.05 L11.05 15.3 18.8 23.05 23 18.8 15.25 11.05 M12.35 19.45 L6 13.1 6 6 13.1 6 27.2 20.15 Q27.8 20.75 27.75 21.55 27.8 22.35 27.25 22.95 L23 27.25 Q22.35 27.85 21.5 27.8 20.7 27.85 20.1 27.25 L19.5 26.65 12.35 19.45 M8.05 12.3 L9.6 13.85 13.8 9.6 12.25 8.05 8 8 8.05 12.3",ys),6,18,"crosshair"),Mc=Se($e("M5.15 10.85 Q4 9.65 4 8.1 L4 7.95 4 7.85 Q3.95 6.2 5.1 5.15 6.25 4 7.85 4 L7.95 4 8.1 4 Q9.65 4 10.85 5.15 L11 5.3 14.3 5.25 Q15.15 5.25 15.75 5.85 L29.9 20 Q31 21.15 31 22.75 L31 22.85 31 23 Q31.05 24.5 29.9 25.7 L29.55 25.95 25.65 29.9 25.65 29.95 Q24.45 31.1 22.75 31.1 21.2 31.15 20 29.95 L5.85 15.8 Q5.25 15.2 5.25 14.35 L5.25 10.95 5.15 10.85 M19.95 24.2 L18.55 22.8 22.8 18.55 24.2 19.95 19.95 24.2 M28.45 21.4 L14.3 7.25 10.15 7.3 9.4 6.55 Q8.8 5.95 7.95 6 7.1 5.95 6.5 6.55 5.95 7.1 6 7.95 5.95 8.8 6.55 9.4 L7.25 10.1 7.25 14.35 21.4 28.5 Q22 29.1 22.75 29.1 23.6 29.1 24.2 28.5 L28.45 24.25 Q29.05 23.65 29 22.85 29.05 22 28.45 21.4 M9.25 13.5 L9.25 9.3 13.5 9.25 14.3 10.05 10.05 14.3 9.25 13.5 M17.15 21.4 L11.5 15.75 15.75 11.5 21.4 17.15 17.15 21.4","M17.15 21.4 L21.4 17.15 15.75 11.5 11.5 15.75 17.15 21.4 M28.45 21.4 Q29.05 22 29 22.85 29.05 23.65 28.45 24.25 L24.2 28.5 Q23.6 29.1 22.75 29.1 22 29.1 21.4 28.5 L7.25 14.35 7.25 10.1 6.55 9.4 Q5.95 8.8 6 7.95 5.95 7.1 6.5 6.55 7.1 5.95 7.95 6 8.8 5.95 9.4 6.55 L10.15 7.3 14.3 7.25 28.45 21.4 M19.95 24.2 L24.2 19.95 22.8 18.55 18.55 22.8 19.95 24.2 M9.25 13.5 L10.05 14.3 14.3 10.05 13.5 9.25 9.25 9.3 9.25 13.5",ys),6,18,"crosshair"),he=Se($e("M17 2 Q18.2 2 19.15 2.9 20 3.8 20 5 L20 12 27 12 Q28.2 12 29.15 12.9 30 13.8 30 15 L30 17 Q30 18.2 29.15 19.15 28.2 20 27 20 L20 20 20 27 Q20 28.2 19.15 29.15 18.2 30 17 30 L15 30 Q13.8 30 12.9 29.15 12 28.2 12 27 L12 20 5 20 Q3.8 20 2.9 19.15 2 18.2 2 17 L2 15 Q2 13.8 2.9 12.9 3.8 12 5 12 L12 12 12 5 Q12 3.8 12.9 2.9 13.8 2 15 2 L17 2 M14 27 L14.3 27.7 Q14.6 28 15 28 L17 28 17.7 27.7 18 27 18 18.05 18.05 18 27 18 Q27.4 18 27.7 17.7 L28 17 28 15 27.7 14.3 Q27.4 14 27 14 L18 14 18 5 17.7 4.3 17 4 15 4 Q14.6 4 14.3 4.3 14 4.6 14 5 L14 14 5 14 Q4.6 14 4.3 14.3 4 14.6 4 15 L4 17 Q4 17.4 4.3 17.7 4.6 18 5 18 L14 18 14 27","M14 27 L14 18 5 18 Q4.6 18 4.3 17.7 4 17.4 4 17 L4 15 Q4 14.6 4.3 14.3 4.6 14 5 14 L14 14 14 5 Q14 4.6 14.3 4.3 14.6 4 15 4 L17 4 17.7 4.3 18 5 18 14 27 14 Q27.4 14 27.7 14.3 L28 15 28 17 27.7 17.7 Q27.4 18 27 18 L18.05 18 18 18.05 18 27 17.7 27.7 17 28 15 28 Q14.6 28 14.3 27.7 L14 27"),12,12,"crosshair"),Ac=Se($e("M3.9 11.35 Q2.3 12.5 3.7 13.9 L16.4 26.65 Q17.85 28.05 19.45 26.9 L27.65 21.15 Q29.3 20 27.85 18.6 L15.15 5.85 Q13.75 4.45 12.1 5.6 L3.9 11.35 M1.05 12.4 Q1 10.95 2.75 9.75 L10.95 4 10.95 3.95 Q14 1.85 16.6 4.45 L29.3 17.2 Q30.8 18.65 30.55 20.1 30.55 21.55 28.8 22.8 L20.6 28.55 20.65 28.55 Q17.7 30.65 15 28.1 L15 28.05 2.3 15.3 2.3 15.35 Q0.8 13.85 1.05 12.4 M13.5 7 L19.85 13.35 11.65 19.15 5.3 12.75 13.5 7","M13.5 7 L5.3 12.75 11.65 19.15 19.85 13.35 13.5 7 M3.9 11.35 L12.1 5.6 Q13.75 4.45 15.15 5.85 L27.85 18.6 Q29.3 20 27.65 21.15 L19.45 26.9 Q17.85 28.05 16.4 26.65 L3.7 13.9 Q2.3 12.5 3.9 11.35"),6,14,"cell"),bs=Se(`<svg ${Bn}><path d='M16 4V28M11 4H21M11 28H21' fill='none' ${Wn} stroke-width='5'/><path d='M16 4V28M11 4H21M11 28H21' fill='none' stroke='${Xn}' stroke-width='2.25' stroke-linecap='round'/></svg>`,12,12,"text"),Rc=Se(`<svg ${Bn}><path d='M6 5H21L26 10V27H6Z' fill='${Xn}' ${Wn} stroke-width='2.5'/><path d='M21 5V11H26' fill='none' ${Wn} stroke-width='2.25'/></svg>`,5,5,"crosshair"),ne=Object.freeze({browse:"default",move:hs,inspect:hs,hand:Sc,comment:Ec,pen:Tc,section:he,highlighter:Mc,shape:he,rect:he,ellipse:he,sticky:Rc,arrow:he,text:bs,"el-text":bs,frame:he,"el-shape":he,line:he,polygon:he,slice:he,"el-pen":he,crop:he,eraser:Ac});import{jsx as Qn,Fragment as Oc}from"react/jsx-runtime";function vs(e,t){if(typeof window>"u"||window.parent===window)return;if(!ve(window).claimRequest(`${e}|${t??""}`))return;try{window.parent.postMessage(t?{dgn:"mode-request",mode:e,tool:t,cause:"toolbar"}:{dgn:"mode-request",mode:e,cause:"toolbar"},"*")}catch{}}var qt="maude:tool-sync",xs=Object.freeze({preview:"browse",edit:"move"});function ks(e){if(e==="browse")return"preview";if(e==="move")return"edit";return null}var Ic=Object.freeze([{id:"browse",label:"Browse",shortcut:"",cursor:ne.browse},{id:"move",label:"Select",shortcut:"V",cursor:ne.move},{id:"inspect",label:"Inspect",shortcut:"",cursor:ne.inspect},{id:"hand",label:"Hand",shortcut:"H",cursor:ne.hand},{id:"comment",label:"Comment",shortcut:"C",cursor:ne.comment},{id:"pen",label:"Pen",shortcut:"B",cursor:ne.pen},{id:"highlighter",label:"Highlighter",shortcut:"I",cursor:ne.highlighter},{id:"shape",label:"Shape",shortcut:"R",cursor:ne.shape},{id:"sticky",label:"Sticky",shortcut:"N",cursor:ne.sticky},{id:"section",label:"Section",shortcut:"⇧S",cursor:ne.shape},{id:"arrow",label:"Arrow",shortcut:"A",cursor:ne.arrow},{id:"text",label:"Text",shortcut:"T",cursor:ne.text},{id:"el-text",label:"Text",shortcut:"T",cursor:ne["el-text"]},{id:"frame",label:"Frame",shortcut:"F",cursor:ne.frame},{id:"el-shape",label:"Shape",shortcut:"R",cursor:ne["el-shape"]},{id:"ellipse",label:"Ellipse",shortcut:"",cursor:ne.ellipse},{id:"line",label:"Line",shortcut:"",cursor:ne.line},{id:"polygon",label:"Polygon",shortcut:"",cursor:ne.polygon},{id:"slice",label:"Export area",shortcut:"",cursor:ne.slice},{id:"el-pen",label:"Pen",shortcut:"P",cursor:ne["el-pen"]},{id:"crop",label:"Crop",shortcut:"",cursor:ne.crop},{id:"eraser",label:"Eraser",shortcut:"E",cursor:ne.eraser}]),Pc=new Set(["browse","move","hand","inspect"]);function _c(e,t,n=!1){return t?e.filter((o)=>Pc.has(o.id)||n&&o.id==="comment"):e}var Yn=Cc(null);function Lc({children:e,tools:t=Ic,initial:n,initialMode:o,governed:r=!1}){let s=Re(),a=s&&Ue(),c=ws(()=>_c(t,s,a),[t,s,a]),p=n??(s?"browse":"move"),f=o??ks(p)??(s?"preview":"edit"),[x,g]=$t(p),w=Le(p),A=qe((M)=>{w.current=M,g(M)},[]),m=qe(()=>w.current,[]),[h,S]=$t(f),[y,i]=$t(()=>({tool:null,locked:!1})),b=Le(null),E=qe((M)=>{if(!c.some((j)=>j.id===M))return;let K=b.current;if(K){let j=et(M,K.caps,K.mode);if(j&&j!==K.mode){if(K.mode!=="present")vs(j,M);return}A(M),i((Y)=>Y.locked&&Y.tool===M?Y:{tool:null,locked:!1});return}A(M);let q=ks(M);if(q)S(q);i((j)=>j.locked&&j.tool===M?j:{tool:null,locked:!1})},[c]),L=qe((M)=>{let K=b.current;if(K){vs(M==="edit"?so(K.caps):"preview");return}let q=xs[M];if(!c.some((j)=>j.id===q))return;S(M),A(q),i((j)=>j.locked&&j.tool===q?j:{tool:null,locked:!1})},[c]),O=qe(()=>{let M=b.current;E(M?Yt[M.mode]:xs[h])},[h,E]),z=Le(h);z.current=h;let G=Le(x);G.current=x;let D=Le(x);dt(()=>{let M=os(D.current,x);if(D.current=x,M)ns(M)},[x]),dt(()=>{if(!r||typeof window>"u")return;let M=ve(window),K=-1,q=null,j=()=>{let Y=M.get();if(Y.mode===null||!Y.caps||Y.modeSeq<=K)return;K=Y.modeSeq,b.current={mode:Y.mode,caps:Y.caps};let Ee=ao[Y.mode],Te=q===null?z.current!==Ee:q!==Y.mode;q=Y.mode;let Me=Yt[Y.mode],Oe=(Ae)=>!!Ae&&c.some((ut)=>ut.id===Ae),N=Y.tool??(Te?Me:null),Z=Oe(N)?N:Te&&Oe(Me)?Me:null;if(S(Ee),Z)A(Z),G.current=Z;if(Te)i({tool:null,locked:!1});if(M.claimEcho(Y.modeSeq)&&window.parent!==window)try{window.parent.postMessage({dgn:"mode-changed",seq:Y.modeSeq,mode:Y.mode,tool:Z??G.current,present:Y.present,cause:Y.clamped?"clamp":"set-mode"},"*")}catch{}};return j(),M.subscribe(j)},[c,r]);let W=qe((M)=>{i((K)=>{if(K.locked&&K.tool===M)return{tool:null,locked:!1};return{tool:M,locked:!0}}),A(M)},[]),Q=qe(()=>{i({tool:null,locked:!1})},[]),[ee,oe]=$t("rounded"),te=Le(Math.random().toString(36).slice(2)),k=Le(x);k.current=x;let T=Le(!1);dt(()=>{if(!T.current){T.current=!0;return}if(typeof document>"u")return;document.dispatchEvent(new CustomEvent(qt,{detail:{tool:x,from:te.current}}))},[x]),dt(()=>{if(typeof document>"u")return;let M=(K)=>{let q=K.detail;if(!q||q.from===te.current||typeof q.tool!=="string")return;if(q.tool===k.current)return;let j=b.current;if(j){let Y=et(q.tool,j.caps,j.mode);if(Y&&Y!==j.mode){document.dispatchEvent(new CustomEvent(qt,{detail:{tool:k.current,from:te.current}}));return}}E(q.tool)};return document.addEventListener(qt,M),()=>document.removeEventListener(qt,M)},[E]),dt(()=>{if(typeof document>"u")return;let M=c.find((j)=>j.id===x);if(!M)return;let K=document.body.style.cursor,q=document.getElementById("dc-tool-cursor");if(!q)q=document.createElement("style"),q.id="dc-tool-cursor",document.head.appendChild(q);if(x==="browse"){if(document.body.style.cursor="",q.textContent="",typeof window<"u"&&window.parent&&window.parent!==window)try{window.parent.postMessage({dgn:"tool-cursor",tool:x},"*")}catch{}return()=>{document.body.style.cursor=K}}if(document.body.style.cursor=M.cursor,q.textContent=`* { cursor: ${M.cursor} !important; }`,typeof window<"u"&&window.parent&&window.parent!==window)try{window.parent.postMessage({dgn:"tool-cursor",tool:x},"*")}catch{}return()=>{document.body.style.cursor=K;let j=document.getElementById("dc-tool-cursor");if(j)j.textContent=""}},[x,c]);let I=ws(()=>({tool:x,getTool:m,setTool:E,tools:c,mode:h,setMode:L,resetTool:O,sticky:y,toggleSticky:W,clearSticky:Q,shapeKind:ee,setShapeKind:oe}),[x,m,E,c,h,L,O,y,W,Q,ee]);return Qn(Yn.Provider,{value:I,children:e})}function Es({children:e,initial:t,initialMode:n,governed:o}){if(Ss(Yn))return Qn(Oc,{children:e});return Qn(Lc,{initial:t,initialMode:n,governed:o,children:e})}function jt(){let e=Ss(Yn);if(!e)throw Error("useToolMode must be used inside <ToolProvider>");return e}import{jsx as Bc}from"react/jsx-runtime";var Dc=`
1
+ import{Component as Zc,createElement as to,useCallback as Jn,useEffect as xe,useMemo as Jc,useRef as ke,useState as et}from"react";import{createRoot as ed}from"react-dom/client";function zs(e,t){if(e==="present")return t?.kind==="artboards"?"present-artboards":"present-canvas";return e}var ge=(e,t,n,o,r)=>Object.freeze({edit:e,preview:t,"present-artboards":n,"present-canvas":o,viewing:r}),Vs=Object.freeze({clicks:ge("tool","live","next-artboard","pan-zoom","specs"),toolbar:ge("edit","preview","none","none","viewing"),annotations:ge("quiet","drawn","hidden","hidden","read-only"),"comment-pins":ge("shown","shown","hidden","hidden","shown"),measure:ge("on","on","off","off","on"),"ai-changes":ge("live","live","held","live-unmarked","live"),"left-panels":ge("shown","folded","hidden","hidden","shown"),"ai-panel":ge("shown","folded","hidden","hidden","none"),"share-cluster":ge("full","full","hidden","hidden","full-access"),inspect:ge("inspector","panel-on-cmd-click","hidden","hidden","panel-on-click"),"project-menu":ge("pill","pill","esc-first","esc-first","pill"),esc:ge("steps-back","steps-back","settles-back","same-view","deselect")});function Ke(e,t,n){return Vs[e][zs(t,n)]}var Hs=Object.freeze({measure:(e,t)=>Ke("measure",e,t)==="on","inspect-panel":(e,t)=>Ke("inspect",e,t).startsWith("panel"),"comment-pins":(e,t)=>Ke("comment-pins",e,t)==="shown","object-tools":(e,t)=>Ke("clicks",e,t)==="tool","live-design":(e,t)=>Ke("clicks",e,t)==="live","annotations-editable":(e,t)=>Ke("annotations",e,t)==="drawn",chrome:(e,t)=>Ke("share-cluster",e,t)!=="hidden"});function gt(e,t,n){if(!e)return t==="measure"||t==="comment-pins"||t==="object-tools";return Hs[t](e,n)}var Yt=["edit","viewing","preview","present"],so=["artboards","canvas"],Qt=["browse","move","hand","comment","pen","highlighter","eraser","shape","sticky","section","arrow","text"],Fs=["inspect","frame","el-shape","el-pen","el-text","image","component","line","ellipse","polygon","crop","slice","pointer"],Gt=[...Qt,...Fs],bd=new Set(Yt),$s=new Set(Gt);var qs=(e)=>typeof e==="string"&&$s.has(e),yd=Object.freeze({edit:!1,annotate:!1,comment:!1}),io=Object.freeze({edit:!0,annotate:!0,comment:!0}),ao=(e)=>e.edit?"edit":"viewing";function lo(e,t){if(e==="edit"&&!t.edit)return"viewing";if(e==="viewing"&&t.edit)return"edit";return e}var co=Object.freeze({edit:"edit",viewing:"edit",preview:"preview",present:"preview"}),Zt=Object.freeze({edit:"move",viewing:"inspect",preview:"browse",present:"browse"}),oo=Object.freeze({view:0,comment:1,edit:2});function js(e){if(e.edit||e.annotate)return"edit";return e.comment?"comment":"view"}var J=(e)=>Object.freeze(e),tt=Object.freeze({edit:Object.freeze({rest:"move",slots:Object.freeze([J({key:"V",label:"Select",tool:"move",minRole:"edit"}),J({key:"H",label:"Hand",tool:"hand",minRole:"edit"}),J({key:"F",label:"Artboard / Frame",tool:"frame",minRole:"edit"}),J({key:"R",label:"Shape",tool:"el-shape",minRole:"edit"}),J({key:"P",label:"Pen",tool:"el-pen",minRole:"edit"}),J({key:"T",label:"Text",tool:"el-text",minRole:"edit"}),J({key:"I",label:"Image",tool:"image",minRole:"edit",panel:"image",panelFirst:!0}),J({key:"⇧I",label:"Component",tool:null,minRole:"edit",panel:"components"}),J({key:"",label:"More",tool:null,minRole:"edit",popover:"more",more:Object.freeze([J({key:"",label:"Line",tool:"line",minRole:"edit"}),J({key:"",label:"Ellipse",tool:"ellipse",minRole:"edit"}),J({key:"",label:"Polygon",tool:"polygon",minRole:"edit"}),J({key:"",label:"Crop",tool:"crop",minRole:"edit"}),J({key:"",label:"Export area",tool:"slice",minRole:"edit"})])})])}),preview:Object.freeze({rest:"browse",slots:Object.freeze([J({key:"V",label:"Select",tool:"browse",minRole:"view"}),J({key:"H",label:"Hand",tool:"hand",minRole:"view"}),J({key:"N",label:"Sticky",tool:"sticky",minRole:"edit",popover:"sticky-colours"}),J({key:"C",label:"Comment",tool:"comment",minRole:"comment"}),J({key:"M",label:"Marker",tool:"pen",minRole:"edit",popover:"marker-tips",tips:["pen","highlighter","eraser"]}),J({key:"A",label:"Arrow",tool:"arrow",minRole:"edit"}),J({key:"R",label:"Shape",tool:"shape",minRole:"edit",popover:"shape-kinds"}),J({key:"T",label:"Text",tool:"text",minRole:"edit"}),J({key:"E",label:"Stickers",tool:null,minRole:"edit",panel:"stickers"}),J({key:"S",label:"Section",tool:"section",minRole:"edit",panel:"templates"})])}),viewing:Object.freeze({rest:"inspect",slots:Object.freeze([J({key:"H",label:"Hand",tool:"inspect",minRole:"view"}),J({key:"C",label:"Comment",tool:"comment",minRole:"comment"})])}),present:Object.freeze({rest:"browse",hidden:!0,slots:Object.freeze([J({key:"L",label:"Pointer",tool:"pointer",minRole:"view"})])})}),Jt=Object.freeze({});function uo(e,t){if(t(e))return e;let n=Jt[e];return n&&t(n)?n:null}var Us=Object.freeze({edit:["preview"],preview:["edit"],viewing:["preview","edit"],present:[]});function Ws(e,t){for(let n of[e,...Us[e]]){let o=tt[n].slots.find((r)=>r.key===t);if(o)return{mode:n,slot:o}}return null}function po(e,t,n,o){let r=Ws(e,t);if(!r||r.slot.pending)return null;let{slot:s}=r,i=!!s.panel&&(s.tool===null||!!s.panelFirst),c=s.insert||s.panelFirst?null:s.tips&&o&&s.tips.includes(o)?o:s.tool,p=js(n);if(oo[p]<oo[s.minRole]||r.mode==="edit"&&!n.edit){if(c)return{kind:"deny",mode:r.mode,tool:c};return i&&s.panel?{kind:"deny",mode:r.mode,panel:s.panel}:{kind:"deny",mode:r.mode}}if(r.mode!==e){let f={kind:"request",mode:r.mode};if(c)f.tool=c;if(i&&s.panel)f.panel=s.panel;return f}if(s.insert)return{kind:"insert",insert:s.insert};if(c)return{kind:"arm",tool:c};return s.panel?{kind:"panel",panel:s.panel}:null}var Bs=new Set(["hand"]);function ro(e,t){return tt[e].slots.some((n)=>n.tool===t||n.tool!==null&&Jt[n.tool]===t||!!n.tips?.includes(t)||!!n.lights?.includes(t)||!!n.more?.some((o)=>o.tool===t))}function nt(e,t,n){if(!qs(e)||Bs.has(e))return null;if(ro(n,e))return n;if(e==="move")return t.edit?"edit":"viewing";for(let o of["preview","edit"])if(ro(o,e))return o;return null}function en(e,t){if(e==="present")return"back";let n=tt[e].rest;if(t!==n&&Jt[n]!==t)return"rest";return"stay"}var tn=Object.freeze({top:0,right:0,bottom:0,left:0});function mo(e,t,n){let o=e-n.left-n.right,r=t-n.top-n.bottom,s=o>=240,i=r>=240;return{x:s?n.left:0,y:i?n.top:0,w:s?o:e,h:i?r:t}}function fo(e){if(!e||typeof e!=="object"||Array.isArray(e))return null;let t=e,n={top:0,right:0,bottom:0,left:0};for(let o of["top","right","bottom","left"]){let r=t[o];if(typeof r!=="number"||!Number.isFinite(r)||r<0||r>8192)return null;n[o]=Math.round(r)}return n}var Xs=["image/png","image/jpeg","image/gif","image/webp"],Ys=new Set(["dgn","v","text","html","image"]),go=(e)=>typeof e==="string"&&e.length<=1e6,Qs=(e)=>typeof Blob<"u"&&e instanceof Blob&&Xs.includes(e.type)&&e.size>0&&e.size<=20971520;function ho(e){if(!e||typeof e!=="object"||Array.isArray(e))return null;let t=e;for(let o of Object.keys(t))if(!Ys.has(o))return null;if(t.v!==1)return null;let n={v:1};if(t.text!==void 0){if(!go(t.text))return null;n.text=t.text}if(t.html!==void 0){if(!go(t.html))return null;n.html=t.html}if(t.image!==void 0){if(!Qs(t.image))return null;n.image=t.image}return n.text||n.html||n.image?n:null}var Gs=/^data:image\/(?:png|webp|jpeg|gif);base64,[A-Za-z0-9+/]+={0,2}$/;function bo(e){return typeof e==="string"&&e.length<=400000&&Gs.test(e)}var Zs=["frame","text","image","path","shape","instance","artboard","multi"],v=Symbol("dgn.bad"),vt=4000,$e=1e4,Js=16,we=(e)=>!!e&&typeof e==="object"&&!Array.isArray(e),u=(e)=>typeof e==="string"&&e.length<=vt?e:v,I=(e)=>typeof e==="number"&&Number.isFinite(e)?e:v,ei=(e)=>typeof e==="number"&&Number.isFinite(e)&&e>=0&&e<=1?e:v,O=(e)=>typeof e==="boolean"?e:v,ti=(e)=>bo(e)?e:v,yo=(e)=>typeof e==="number"&&Number.isFinite(e)&&e>=0&&e<=86400?e:v,ni=(e)=>{if(!Array.isArray(e)||e.length>8)return v;for(let t of e)if(typeof t!=="string"||t.length>400)return v;return[...e]},q=(...e)=>(t)=>e.includes(t)?t:v,d=(e)=>(t)=>t===void 0?void 0:e(t),oi=(e)=>typeof e==="string"&&e.length<=48&&/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/.test(e)&&!/^[0-9a-f]{8}$/.test(e)?e:v,Ve=(e)=>typeof e==="string"&&/^[A-Za-z0-9_-]{1,64}$/.test(e)?e:v,N=(e)=>(t)=>t===null?null:e(t),U=(e)=>(t)=>{if(!Array.isArray(t)||t.length>$e)return v;let n=[];for(let o of t){let r=e(o);if(r===v)return v;n.push(r)}return n},he=(e)=>rn(e,0);function rn(e,t){if(e===null||typeof e==="boolean")return e;if(typeof e==="number")return Number.isFinite(e)?e:v;if(typeof e==="string")return e.length<=vt?e:v;if(t>=Js||typeof e!=="object")return v;if(Array.isArray(e)){if(e.length>$e)return v;let r=[];for(let s of e){let i=rn(s,t+1);if(i===v)return v;r.push(i)}return r}let n={},o=0;for(let r of Object.keys(e)){if(++o>$e||r.length>vt)return v;let s=rn(e[r],t+1);if(s===v)return v;if(s!==void 0)n[r]=s}return n}var ie=(e)=>we(e)?he(e):v,wo=(e)=>{if(!we(e))return v;let t={},n=Object.keys(e);if(n.length>$e)return v;for(let o of n){let r=u(e[o]);if(r===v||o.length>vt)return v;t[o]=r}return t},ri=256,ht=(e,t=ri)=>(n)=>{if(!we(n))return v;let o=Object.keys(n);if(o.length>t)return v;let r=Object.create(null);for(let s of o){if(s.length>200||s==="__proto__"||s==="constructor"||s==="prototype")return v;let i=e(n[s]);if(i===v)return v;r[s]=i}return r},bt=(e)=>typeof e==="string"&&/^[A-Za-z0-9_-]{1,64}$/.test(e)?e:v,F=(e)=>(t)=>typeof t==="string"&&t.length<=e?t:v,si=(e)=>typeof e==="string"&&/^[A-Z][A-Za-z0-9]{0,63}$/.test(e)?e:v,vo=(e)=>typeof e==="string"&&/^[a-z][a-z0-9-]{0,40}$/.test(e)?e:v,yt=(e)=>typeof e==="number"&&Number.isSafeInteger(e)&&e>=0&&e<=9999?e:v,Y=(e)=>(t)=>{if(!we(t))return v;let n={};for(let o of Object.keys(e)){let r=e[o](t[o]);if(r===v)return v;if(r!==void 0)n[o]=r}return n},ue=(e,t)=>(n)=>typeof n==="number"&&Number.isInteger(n)&&n>=e&&n<=t?n:v,sn=(e)=>typeof e==="string"&&/^[\w-]{1,64}$/.test(e)?e:v,ze=Y({x:I,y:I,w:I,h:I}),ii=512,Eo=(e)=>{if(typeof e!=="string"||e.length<5||e.length>ii)return v;if(/[\u0000-\u001f\u007f]/.test(e)||e.split("|").length<3)return v;return e},ai=(e)=>{if(!Array.isArray(e)||e.length>Io)return v;let t=Y({clientID:ue(0,Number.MAX_SAFE_INTEGER),name:(o)=>typeof o==="string"&&o.length<=Po?o:v,artboardId:Ve,frame:d(ue(0,1e7)),word:d(Eo)}),n=[];for(let o of e){if(!we(o))return v;let r=t(o);if(r===v)return v;n.push(r)}return n},nn=(e)=>typeof e==="string"&&/^#[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$/.test(e)?e:v,To=Y({stickyColor:d(nn),ink:d(nn),thickness:d(q(3,6)),tip:d(q("pen","highlighter","eraser")),highlighterColor:d(nn),highlighterWidth:d(ue(1,64))}),wt=q(...Yt),an=q(...Gt),ln=Y({kind:q(...so),from:d(u),only:d(q("formats"))}),li=Y({edit:O,annotate:O,comment:O,present:d(O)}),ci=/^[a-z0-9]{8,32}$/,cn=(e)=>typeof e==="string"&&ci.test(e)?e:v,di=64,ui=(e)=>typeof e==="string"&&e.length<=di?e:v,pi=(e)=>fo(e)??v,mi=/^(?!\/)(?!.*\.\.)[A-Za-z0-9_][A-Za-z0-9 ._/-]{0,255}\.css$/,xt=(e)=>typeof e==="string"&&mi.test(e)?e:v,fi=/^(?:head|[0-9a-f]{64})$/,Mo=16,Ro=(e)=>typeof e==="string"&&fi.test(e)?e:v,gi=(e)=>Array.isArray(e)&&e.length<=Mo?U(Ro)(e):v,hi=200,bi=/^[A-Za-z0-9_.:-]{1,128}$/,kt=(e)=>typeof e==="string"&&bi.test(e)?e:v,yi=(e)=>Array.isArray(e)&&e.length<=hi?U(kt)(e):v,wi=q("light","dark"),vi=200,xi=/^--[A-Za-z0-9_-]{1,128}$/,ki=(e)=>typeof e==="string"&&xi.test(e)?e:v,xo=(e)=>Array.isArray(e)&&e.length<=vi?U(ki)(e):v,Si=["brand","colour","type","space","motion","components","patterns"],Ei=q("waiting","drawing","done"),Ti=(e)=>{if(!we(e))return v;let t={};for(let n of Object.keys(e)){if(!Si.includes(n))return v;let o=Ei(e[n]);if(o===v)return v;t[n]=o}return t},Ao=500,Mi=(e)=>Array.isArray(e)&&e.length<=Ao?U(kt)(e):v,Co=ue(0,1e6),Ri=(e)=>e===null||kt(e)!==v?e:v,Ai=(e)=>Array.isArray(e)&&e.length<=Ao?U(Y({id:kt,x:I,y:I,w:I,h:I}))(e):v,Ci=Y({tokens:xt,components:N(xt)}),Ii=(e)=>{if(!we(e))return v;let t=Object.keys(e);if(t.length>Mo)return v;let n=Object.create(null);for(let o of t){if(Ro(o)===v)return v;let r=Ci(e[o]);if(r===v)return v;n[o]=r}return n},Pi=(e)=>typeof e==="string"&&/^[A-Za-z_][\w-]{0,63}$/.test(e)?e:v,_i=2000,Li=Y({id:F(200),label:F(200),x:I,y:I,w:I,h:I}),Oi=(e)=>Array.isArray(e)&&e.length<=_i?U(Li)(e):v,Ni=500,Io=32,Po=64,Di=/^(#[0-9a-f]{3,8}|oklch\([0-9.%\s/-]{1,40}\))$/i,Ki=/^[A-Za-z0-9_-]{1,64}$/,zi=["owner","member","viewer","observer"],Vi=(e)=>{if(!Array.isArray(e)||e.length>Io)return v;let t=[];for(let n of e){if(!we(n))return v;let{clientID:o,name:r,color:s,following:i,artboard:c,idleSince:p,surface:f,inComments:y,role:g}=n;if(typeof o!=="number"||!Number.isSafeInteger(o)||o<0)return v;if(typeof r!=="string"||r.length>Po)return v;if(s!==void 0&&(typeof s!=="string"||!Di.test(s)))return v;if(i!==void 0&&typeof i!=="boolean")return v;if(c!==void 0&&(typeof c!=="string"||!Ki.test(c)))return v;if(p!==void 0&&(typeof p!=="number"||!Number.isSafeInteger(p)||p<=0))return v;if(f!==void 0&&f!=="browser")return v;if(y!==void 0&&typeof y!=="boolean")return v;let w={clientID:o,name:r};if(s!==void 0)w.color=s;if(i===!0)w.following=!0;if(c!==void 0)w.artboard=c;if(p!==void 0)w.idleSince=p;if(f==="browser")w.surface="browser";if(y===!0)w.inComments=!0;if(zi.includes(g))w.role=g;t.push(w)}return t},Hi=120,Fi=256,We=(e)=>typeof e==="string"&&e.length<=Hi?e:v,$i=(e)=>Array.isArray(e)&&e.length<=Fi?U(Y({artboard:We,element:We,occurrence:d((t)=>typeof t==="number"&&Number.isInteger(t)&&t>=0&&t<1e4?t:v),tag:We,mine:O,scope:d(O),point:d(O)}))(e):v,qi=8,ji=40,on="[A-Za-z0-9_.:-]{1,128}",Ui=new RegExp(`^(?:ab:${on}|el:${on}/${on})$`),Wi=20,Bi=(e)=>Array.isArray(e)&&e.length<=Wi?U(Y({from:sn,to:sn}))(e):v,Xi=(e)=>Array.isArray(e)&&e.length<=qi?U(Y({ref:(t)=>typeof t==="string"&&Ui.test(t)?t:v,tag:(t)=>typeof t==="string"&&t.length<=ji?t:v}))(e):v,Yi=["add","reply","resolve","reopen","edit-own","delete-own"],Qi=["to-sticky","convert-undo","convert-undoable"],ot=(e)=>typeof e==="string"&&e.length>0&&e.length<=64||typeof e==="number"&&Number.isSafeInteger(e)?e:v,Gi=(e)=>{if(!we(e))return v;if(Qi.includes(e.op))return typeof e.commentId==="string"&&/^[A-Za-z0-9_]{1,64}$/.test(e.commentId)?{op:e.op,commentId:e.commentId}:v;if(!Yi.includes(e.op))return v;return he(e)},Zi=Y({id:F(200),name:F(120),role:d(F(40))}),Ji=256,ea=64,ta=Y({name:N((e)=>typeof e==="string"&&e.length<=ea&&!e.includes("@")?e:v),kind:N(q("mac","pc","linux")),self:O}),na=Y({rel:F(512),state:q("here","uploading","waiting","missing","lfs-pointer"),localObject:d(O),who:d(ta),syncing:d(O),progress:d(ei)}),oa=(e)=>Array.isArray(e)&&e.length<=Ji?U(na)(e):v,ra=256,sa=/^assets\/[0-9a-f]{8}\.[A-Za-z0-9]{1,8}$/,ia=(e)=>Array.isArray(e)&&e.length<=ra&&e.every((t)=>typeof t==="string"&&sa.test(t))?e.slice():v;function l(e){let t=Y(e);return(n)=>{let o=t(n);return o===v?null:o}}var pe=(e)=>we(e)?{}:null,ko={refId:d(u),refIndex:d(I),artboardId:d(N(u)),position:d(u)},Te={id:d(u)},Fe=Y({artboard:u,element:u,occurrence:d(I)}),aa=Y({kind:q("picture","frame","artboard"),artboard:F(200),element:d(F(200)),occurrence:d(ue(1,$e))}),He=(e,t)=>(n)=>Array.isArray(n)&&n.length<=e?t(n):v,la=Y({id:d(F(128)),tag:d(F(24)),text:d(F(160)),selector:d(F(200)),index:d(I)}),ca=Y({label:u,ref:N(Fe)}),da=["held-by-ai","locked","stale","invalid","forbidden"],H="h/use-canvas-bridge",le="canvas-shell",dn={loaded:{gate:"any",status:"live",owner:H,parse:l({file:u})},"canvas-rendered":{gate:"active",status:"live",owner:H,parse:l({file:u})},"canvas-failed":{gate:"active",status:"live",owner:H,parse:l({file:u})},"canvas-mounted":{gate:"any",status:"legacy",owner:"tpl/_shell.html (probe)",orphan:"no-handler",parse:l({file:u,children:I})},"render-error":{gate:"frame",status:"live",owner:"v2/create/use-render-error",parse:l({file:u,message:F(600)})},"render-ok":{gate:"frame",status:"live",owner:"v2/create/use-render-error",parse:l({file:u})},"ds-review":{gate:"active",status:"live",owner:"h/use-ds-frames",parse:pe},"ds-rects-result":{gate:"frame",status:"live",owner:"v2/ds/reach-view",parse:l({seq:Co,view:Y({w:I,h:I}),label:d(F(120)),rects:Ai})},"ds-pins-want":{gate:"active",status:"live",owner:"v2/ds/pins",parse:l({revs:gi})},"canvas-expired":{gate:"frame",status:"live",owner:"h/use-shell-core",parse:pe},"annotations-changed":{gate:"active",status:"live",orphan:"no-handler",owner:"annotations-layer (S4.9) → annotation-list (S4.17)",parse:l({file:u})},"annotation-to-comment":{gate:"active",status:"live",owner:"annotations-layer (S4.12) → shell convert (routes/annotations.ts, S4.7)",parse:l({id:bt})},"annotation-selection":{gate:"active",status:"live",owner:"annotations-layer (S4.12) → AI scope chip (S4.15, S5.8)",parse:l({ids:He(500,U(bt)),kinds:ht(yt,16),artboards:He(200,U(F(128)))})},"annotation-toast":{gate:"active",status:"live",owner:"annotations-layer (S4.12) → shell toast",parse:l({v:q(1),message:F(300),undo:O})},"annotation-ask-ai":{gate:"active",status:"live",owner:"annotations-layer (S4.12) → shell AI chat",parse:l({v:q(1)})},"object-history":{gate:"active",status:"live",owner:"editing/object-menu.tsx + annotations-layer (sticky menu) → shell history.object",parse:l({artboard:d(Ve),element:d(F(128)),annotation:d(bt)})},"view-only-gesture":{gate:"active",status:"live",owner:"view-only-gesture (S9.21b) → shell access host tip",parse:l({v:q(1),x:d(ue(0,16384)),y:d(ue(0,16384))})},"vote-cast":{gate:"active",status:"live",owner:"annotations/ui/vote-dots (S4.14) → shell vote store (routes/votes.ts)",parse:l({artboard:Ve,remove:d(O)})},"vote-board":{gate:"active",status:"live",owner:"annotations/ui/vote-dots + editing/artboard-menu (S4.14) → shell vote sheet",parse:l({artboards:He(200,U(Y({id:Ve,label:F(120),x:I,y:I,w:I,h:I}))),open:d(O),focus:d(Ve)})},"annotations-visibility":{gate:"active",status:"live",owner:"annotations-layer ⇧P (S4.18) → shell use-photo-and-timeline",parse:l({v:q(1),visible:O})},"canvas-notice":{gate:"active",status:"live",owner:"canvas-notice-message",parse:l({message:u,kind:q("info","success","error","warning","undo")})},"embed-escape":{gate:"active",status:"live",owner:"c/embed-view",parse:pe},"select-set":{gate:"active",status:"live",owner:H,parse:l({selection:N((e)=>Array.isArray(e)?U(ie)(e):ie(e)),refs:d(U(Fe)),crumbs:d(U(ca)),kind:d(q(...Zs))})},"edit-text":{gate:"active",status:"live",owner:H,parse:l({id:u,file:u,text:u,occurrence:d(I),before:d(u)})},"apply-edit":{gate:"active",status:"live",owner:"client/apply-edit-request",parse:l({requestId:u,op:he,canvas:d(he),id:d(he),key:d(he),value:d(he),from:d(he),occurrence:d(he)})},"undo-barrier":{gate:"active",status:"live",owner:H,parse:l({requestId:u})},"undo-key":{gate:"active",status:"live",owner:"v2/undo/use-undo-mode-lane (S2.20b)",parse:l({redo:O})},"take-step":{gate:"active",status:"live",owner:"v2/assets/takes (S8.16)",parse:l({dir:q("next","prev")})},"edit-op":{gate:"active",status:"live",owner:"editing (S2.1)",parse:l({requestId:u,op:u,targets:U(Fe),params:d(ie),expectRev:d(u)})},"asset-drop-target":{gate:"active",status:"live",owner:"client/v2/assets/canvas-drop-catcher (r3)",parse:l({requestId:F(64),target:N(aa)})},"active-artboard":{gate:"active",status:"live",owner:H,parse:l({id:N(u)})},"reorder-slot":{gate:"active",status:"live",owner:"editing/reorder-slot",parse:(e)=>{let t=l({index:ue(0,$e),total:ue(0,$e),parentId:d(sn)})(e);if(!t||t.index>t.total)return null;if(t.index>0&&t.parentId===void 0)return null;return t}},"layers-tree":{gate:"active",status:"live",owner:H,parse:l({artboardId:N(u),tree:U(ie)})},"open-inspector":{gate:"active",status:"live",owner:H,parse:l({tab:d(u)})},"copy-style":{gate:"active",status:"live",owner:H,parse:pe},"paste-style":{gate:"active",status:"live",owner:H,parse:l({id:u})},"insert-request":{gate:"active",status:"live",owner:H,parse:l({...ko,kind:q("div","text","image"),src:d(u)})},"insert-image-request":{gate:"active",status:"live",owner:H,parse:l(ko)},"delete-request":{gate:"active",status:"live",owner:H,parse:l({id:u,idIndex:d(I)})},"duplicate-request":{gate:"active",status:"live",owner:H,parse:l({id:u,idIndex:d(I)})},"reorder-request":{gate:"active",status:"live",owner:H,parse:l({id:u,refId:u,position:u,idIndex:d(I),refIndex:d(I)})},"reorder-revert":{gate:"active",status:"live",owner:H,parse:l({seq:I,dir:q("undo","redo")})},"reposition-request":{gate:"active",status:"live",owner:H,parse:l({id:u,left:u,top:u,beforeLeft:d(u),beforeTop:d(u),idIndex:d(I)})},"resize-request":{gate:"active",status:"live",owner:H,parse:l({id:u,patch:wo,before:d(wo),idIndex:d(I)})},"replace-media-request":{gate:"active",status:"live",owner:H,parse:l({id:u,before:d(u)})},"convert-to-absolute-request":{gate:"active",status:"live",owner:H,parse:l({artboardId:d(u),allowShared:d(O),containers:d(U(he)),dissolve:d(U(he)),containerId:d(u),children:d(U(he)),containerSetRelative:d(O)})},"delete-artboard-request":{gate:"active",status:"live",owner:H,parse:l({artboardId:u})},"duplicate-artboard-request":{gate:"active",status:"live",owner:H,parse:l({artboardId:u,width:d(I)})},"rename-artboard-request":{gate:"active",status:"live",owner:H,parse:l({artboardId:u,label:u})},"resize-artboard-request":{gate:"active",status:"live",owner:H,parse:l({artboardId:u,width:I,height:I})},"set-artboard-kind-request":{gate:"active",status:"live",owner:H,parse:l({artboardId:u,kind:N(u)})},"open-timeline-request":{gate:"active",status:"live",owner:H,parse:l({artboardId:u})},"replace-annotation-media-request":{gate:"active",status:"live",owner:H,parse:l({id:u,before:d(u)})},"edit-annotation-photo-request":{gate:"active",status:"live",owner:H,parse:l({id:u,asset:u})},"comment-compose":{gate:"active",status:"live",owner:H,parse:l({selection:ie})},"comment-submit":{gate:"active",status:"live",owner:H,parse:l({payload:ie})},"comment-patch":{gate:"active",status:"live",owner:H,parse:l({id:u,patch:ie})},"comment-delete":{gate:"active",status:"live",owner:H,parse:l({id:u})},"comment-click":{gate:"active",status:"live",owner:H,parse:l({id:u})},"comment-op":{gate:"active",status:"live",owner:"v2/comments/comment-bridge (S9.22)",parse:l({reqId:ot,op:Gi})},"comment-people-request":{gate:"active",status:"live",owner:"v2/comments/comment-bridge (S9.22)",parse:l({reqId:ot})},"export-request":{gate:"active",status:"live",owner:H,orphan:"no-sender",parse:l({id:u,payload:ie})},"export-history-request":{gate:"active",status:"live",owner:H,orphan:"no-sender",parse:l({id:u})},"open-export":{gate:"active",status:"legacy",owner:H,parse:l({detail:ie})},"export-capture-progress":{gate:"asked",status:"live",owner:"h/use-shell-core",parse:l({id:u,current:I,total:I})},"export-capture-done":{gate:"asked",status:"live",owner:"h/use-shell-core",parse:l({id:u,items:U(ie)})},"export-capture-error":{gate:"asked",status:"live",owner:"h/use-shell-core",parse:l({id:u,message:u})},"export-selection":{gate:"asked",status:"live",owner:"c/app",parse:l({id:u,selectors:U(u)})},"timeline-comps":{gate:"active",status:"live",owner:H,parse:l({comps:U(ie)})},"timeline-frame":{gate:"active",status:"live",owner:H,parse:l({...Te,frame:I})},"timeline-ended":{gate:"active",status:"live",owner:H,parse:l(Te)},"timeline-playing":{gate:"active",status:"live",owner:"v2/timeline (S7.8)",parse:l({...Te,playing:O})},key:{gate:"active",status:"live",owner:"actions/registry (V2-1.3)",parse:l({v:q(1),chord:u,hint:d(Y({artboardId:d(u)}))})},"tool-cursor":{gate:"active",status:"live",owner:H,parse:l({tool:u})},peers:{gate:"active",status:"live",owner:"v2/shell/use-canvas-mode-lane (V2-4.3b)",parse:l({peers:Vi})},"hold-view":{gate:"active",status:"live",owner:"v2/inspector/view-mode (S2.18)",parse:l({person:N(Y({name:We})),label:We,ai:N(Y({label:We,held:O,mine:O}))})},select:{gate:"active",status:"legacy",owner:H,orphan:"no-sender",parse:l({selection:ie})},"clear-select":{gate:"active",status:"legacy",owner:H,orphan:"no-sender",parse:pe},artboards:{gate:"active",status:"live",owner:"v2/empty (S11.2); the shell bridge keeps the Layers count",parse:l({count:I})},"artboard-empty":{gate:"active",status:"live",owner:"v2/empty (S11.2)",parse:l({artboardId:N(u),rect:N(ze),label:d(u),from:d(u)})},"artboard-anchor":{gate:"active",status:"live",owner:"v2/timeline (S7.7)",parse:l({artboardId:N(u),kind:d(u),label:d(u),rect:d(N(ze))})},"artboard-live-size":{gate:"active",status:"live",owner:"v2/inspector live size (P8 c6)",parse:l({id:N(u),w:d(I),h:d(I),preset:d(N(u))})},"space-tap":{gate:"active",status:"live",owner:"v2/timeline (S7.8)",parse:pe},"canvas-pointerdown":{gate:"active",status:"live",owner:"v2/shell dismiss-outside (rc3 r4-12)",parse:pe},"timeline-peers":{gate:"active",status:"live",owner:"v2/timeline/peers (S7.17)",parse:l({peers:ai})},"ask-selection":{gate:"active",status:"live",owner:"editing/ask-bubble (S2.19)",parse:l({refs:He(200,U(Fe)),selection:d(He(12,U(la))),rect:ze,artboard:d(u)})},"ask-selection-rect":{gate:"active",status:"live",owner:"editing/ai-scope-outline (S2.19)",parse:l({rect:N(ze)})},"insert-artboard-request":{gate:"active",status:"legacy",owner:H,orphan:"no-sender",parse:l({id:d(u),label:d(u),width:d(I),height:d(I)})},"mode-changed":{gate:"active",status:"live",owner:"v2/shell/use-canvas-mode-lane (V2-4.3b)",parse:l({seq:I,mode:wt,tool:an,present:N(ln),cause:q("set-mode","tool","clamp","boot")})},"mode-request":{gate:"active",status:"live",owner:"v2/shell/use-canvas-mode-lane (V2-4.3b)",parse:l({mode:(e)=>e==="back"?e:wt(e),tool:d(an),present:d(ln),cause:q("key","esc","inspect","toolbar","link")})},"toolbar-rect":{gate:"active",status:"live",owner:"tool-palette (V2-4.5a); shell tool panels (V2-4.5c)",parse:l({mode:wt,rect:N(ze)})},"tool-panel-open":{gate:"active",status:"live",owner:"tool-palette (V2-4.5c); shell tool panels (V2-4.5c)",parse:l({panel:q("stickers","components","templates","assets","sizes","image","generate"),anchor:N(ze),replace:d(u)})},"size-place":{gate:"active",status:"live",owner:"editing/size-ghost (S7.20); client/v2/kinds",parse:l({presetId:F(40),world:Y({x:I,y:I})})},"stamp-disarmed":{gate:"active",status:"live",owner:"annotations/ui/placement (15 an-stamps); shell tool panels (use-tool-panels.js)",parse:l({})},"annotation-prefs-set":{gate:"active",status:"live",owner:"annotations/ui/tool-state (S4.8); shell v2/shell/use-annotation-prefs (S4.8)",parse:l({prefs:To})},"viewport-zoom":{gate:"active",status:"live",owner:"present/present-zoom.ts (S3.2b) + v2/preview/zoom-only (S3.9) ← canvas-lib ViewportZoomReporter",parse:l({zoom:I,fit:d(O)})},"pages-view":{gate:"active",status:"live",owner:"canvas-pages-view.tsx (2.0.7 B2) → v2/shell/use-canvas-mode-lane",parse:l({v:q(1),on:O,index:ue(0,1e4),total:ue(0,1e4),id:d(F(256))})},"pages-pick":{gate:"active",status:"live",owner:"canvas-pages.ts (2.0.7 B2) → v2/shell/pages-pick (the view file, main origin)",parse:l({v:q(1),view:q("canvas","pages")})},"theme-pick":{gate:"active",status:"live",owner:"canvas-theme.ts (r4 #6, 2.0.7 B2) → v2/shell/pages-pick (the view file, main origin)",parse:l({v:q(1),theme:q("light","dark")})},"present-position":{gate:"active",status:"live",owner:"v2/shell/use-canvas-mode-lane (S3.1)",parse:l({index:I,total:I,artboardId:u,sid:d(cn),seq:d(ue(0,2147483647))})},"present-run":{gate:"active",status:"live",owner:"present/present-stage.tsx (S3.6b)",parse:l({artboards:Oi})},"present-follow-state":{gate:"active",status:"live",owner:"v2/present/follow-view (S3.7a)",parse:l({live:O,sid:N(cn),presenterName:ui,presenterIndex:ue(0,2000),index:ue(0,2000),total:ue(0,2000),watchers:ue(0,1e5),ended:O})},"present-media":{gate:"active",status:"live",owner:"present/present-media (S3.3)",parse:l({playing:O,t:yo,duration:yo,muted:O,sources:d(ni),missing:d(O)})},"link-follow":{gate:"active",status:"live",owner:"S3 links (client/v2/preview/link-follow.js)",parse:l({elementId:oi,artboardId:N(Ve)})},"asset-relink-request":{gate:"active",status:"live",owner:"client/v2/assets/asset-state-lane (S8.19)",parse:l({rel:F(512)})},"asset-lfs-fix-request":{gate:"active",status:"live",owner:"client/v2/assets/asset-state-lane (2.0.3 LFS placeholder)",parse:l({rel:F(512)})},"asset-lfs-copy-request":{gate:"active",status:"live",owner:"client/v2/assets/asset-state-lane (2.0.3 LFS placeholder)",parse:l({rel:F(512)})}},So={theme:{gate:"any",target:"parent",status:"live",owner:le,parse:l({theme:q("light","dark")})},"view-chrome":{gate:"any",target:"parent",status:"live",owner:le,parse:l({minimap:d(O),zoom:d(O),present:d(O),guides:d(O),print:d(O),safeZones:d(O),zen:d(O)})},"view-annotations":{gate:"parent",status:"live",owner:"annotations-layer",parse:l({visible:O})},"canvas-cap":{gate:"parent",status:"live",owner:"tpl/_shell.html",parse:l({t:u})},"ds-css":{gate:"parent",status:"live",owner:"tpl/_shell.html",parse:l({tokens:d(N(xt)),components:d(N(xt))})},"ds-pins":{gate:"parent",status:"live",owner:"tpl/_shell.html",parse:l({revs:Ii,rootClass:N(Pi)})},"ds-update-dots":{gate:"parent",status:"live",owner:"tpl/_shell.html",parse:l({ids:yi})},"ds-theme-preview":{gate:"parent",status:"live",owner:"ds/board/state",parse:l({mode:wi})},"ds-marks":{gate:"parent",status:"live",owner:"ds/board/state",parse:l({outside:xo,conflicts:xo})},"ds-make-states":{gate:"parent",status:"live",owner:"ds/board/outline",parse:l({sections:Ti})},"ds-rects":{gate:"parent",status:"live",owner:"tpl/_shell.html",parse:l({seq:Co,artboard:Ri,ids:Mi})},"ai-activity":{gate:"parent",status:"live",owner:"ai-banner",parse:l({file:u,entry:N(ie)})},"select-by-id":{gate:"parent",status:"live",owner:le,parse:l({id:d(u),artboardId:d(N(u)),index:d(I),add:d(O)})},"select-by-selector":{gate:"parent",status:"live",owner:le,parse:l({selector:u})},highlight:{gate:"any",target:"parent",status:"live",owner:le,parse:l({id:N(u),artboardId:d(N(u)),index:d(I)})},"request-layers":{gate:"any",target:"parent",status:"live",owner:le,parse:l({artboardId:N(u)})},"force-clear":{gate:"any",target:"parent|self",status:"live",owner:le,parse:pe},"select-clear":{gate:"any",target:"parent|self",status:"legacy",owner:le,orphan:"no-sender",parse:pe},"locked-set":{gate:"parent",status:"live",owner:le,parse:l({locked:U(u)})},"apply-style":{gate:"parent",status:"live",owner:le,parse:l({id:u,artboardId:d(N(u)),index:d(I),prop:u,value:N(u)})},"record-edit":{gate:"parent",status:"live",owner:le,parse:l({payload:ie})},"apply-edit-result":{gate:"parent",status:"live",owner:le,parse:l({requestId:u,ok:O,error:d(u),conflict:d(O)})},"undo-barrier-ok":{gate:"parent",status:"live",owner:le,parse:l({requestId:u})},"edit-op-result":{gate:"parent",status:"live",owner:"editing (S2.1)",parse:l({requestId:u,ok:O,actionId:d(N(u)),writeId:d(u),rev:d(u),refs:d(U(Fe)),created:d(U(Fe)),code:d(q(...da)),message:d(u)})},"edit-reverted":{gate:"parent",status:"live",owner:le,parse:l({op:u,id:d(u),reason:d(u)})},"reorder-failed":{gate:"parent",status:"live",owner:le,parse:pe},"reposition-failed":{gate:"parent",status:"live",owner:le,parse:pe},"resize-failed":{gate:"parent",status:"live",owner:"use-element-resize",parse:pe},"resize-artboard-failed":{gate:"parent",status:"live",owner:"use-element-resize",parse:pe},"freeze-and-set-kind":{gate:"parent",status:"live",owner:le,parse:l({artboardId:u,kind:N(u),ask:d(O),freeze:d(O)})},"op-toast":{gate:"any",target:"parent",status:"live",owner:le,parse:l({message:u})},"tool-set":{gate:"parent",status:"live",owner:"use-tool-mode",orphan:"no-sender",parse:l({tool:u})},"insert-sticker":{gate:"parent",status:"live",owner:"annotations-layer",parse:l({path:u,follow:d(O),preview:d(ti),sticker:d(Y({pack:u,id:u,flip:d(O)}))})},"reveal-artboard":{gate:"parent",status:"live",owner:"canvas-lib",parse:l({artboardId:u,glide:O,flash:O})},"convert-marks":{gate:"parent",status:"live",owner:"artboard-convert-marks",parse:l({v:q(1),from:u,to:u,extraPct:I,fill:N(F(40))})},"shell-panels":{gate:"parent",status:"live",owner:"shell-panels",parse:l({v:q(1),open:N(q("stickers","assets","components"))})},"ai-copies":{gate:"parent",status:"live",owner:"artboard-ai-copies",parse:l({v:q(1),copies:Bi})},"ai-runs":{gate:"parent",status:"live",owner:"artboard-activity-overlay",parse:l({artboards:ht(Y({state:q("running","needs-you","done"),who:F(200),tag:F(120),waiting:yt}))})},"insert-template":{gate:"parent",status:"live",owner:"annotations-layer",parse:l({id:u,follow:d(O)})},"trashed-artboards":{gate:"parent",status:"live",owner:"artboard-ghosts-overlay (S11.5)",parse:l({canvas:F(1024),items:U(Y({id:F(128),label:F(200),rect:N(ze)}))})},"place-component":{gate:"parent",status:"live",owner:"editing/place-ghost",parse:l({component:si,label:d(F(64)),variant:d(vo),glyph:d(vo),mode:q("ghost","selection","preview","cancel")})},"place-image":{gate:"parent",status:"live",owner:"editing/place-image (r2-p1 TD10); client/v2/shell/image-pick.js",parse:l({asset:F(512),natural:d(N(Y({w:I,h:I}))),label:d(F(200))})},"asset-drag-over":{gate:"parent",status:"live",owner:"editing/image-drop (r3)",parse:l({x:N(I),y:d(I)})},"asset-drop-at":{gate:"parent",status:"live",owner:"editing/image-drop (r3)",parse:l({requestId:F(64),x:I,y:I})},"asset-drop-done":{gate:"parent",status:"live",owner:"editing/image-drop (r3)",parse:l({requestId:F(64),ok:O,created:d(U(Fe)),message:d(F(400))})},"timeline-drop-hint":{gate:"parent",status:"live",owner:"editing/drop-chip (S7.9)",parse:l({artboardId:u,on:O})},"timeline-word":{gate:"parent",status:"live",owner:"collab/timeline-presence (S7.17)",parse:l({artboardId:N(Ve),wordKey:d(Eo)})},"dim-artboards":{gate:"parent",status:"live",owner:"editing/kind-dim (S7.24b) ← client/v2/kinds/kind-dim-relay",parse:l({ids:N(He(Ni,U(F(128))))})},"size-ghost":{gate:"parent",status:"live",owner:"editing/size-ghost (S7.20)",parse:l({preset:N(Y({id:F(40),label:F(80),sizeText:F(40),w:I,h:I}))})},"insert-annotation-media":{gate:"parent",status:"live",owner:"annotations-layer",parse:l({paths:U(u)})},"replace-annotation-media":{gate:"parent",status:"live",owner:"annotations-layer",parse:l({id:u,path:u,sticker:d(Y({pack:u,id:u,flip:d(O)}))})},"photo-preview":{gate:"any",target:"parent",status:"live",owner:"canvas-lib (photo)",parse:l({asset:u,edit:N(ie),use:d(u)})},"photo-busy":{gate:"any",target:"parent",status:"live",owner:"canvas-lib (photo)",parse:l({asset:u,busy:O})},"comments-set":{gate:"any",target:"parent",status:"live",owner:"comments-overlay",parse:l({comments:U(ie)})},"comment-focus":{gate:"any",target:"parent",status:"live",owner:"comments-overlay",parse:l({id:N(u),reply:d(q(!0))})},"comment-op-ack":{gate:"parent",status:"live",owner:"comments-overlay (S9.22)",parse:l({reqId:N(ot)})},"comment-op-result":{gate:"parent",status:"live",owner:"comments-overlay (S9.22)",parse:l({reqId:N(ot),ok:O,comment:d(N(ie)),status:d(I),error:d(u)})},"comment-people":{gate:"parent",status:"live",owner:"comments-overlay (S9.22)",parse:l({reqId:N(ot),people:N(U(Zi))})},"annotation-select":{gate:"parent",status:"live",owner:"annotations-layer (S4.9)",parse:l({v:q(1),ids:U(F(200))})},"annotation-filter":{gate:"parent",status:"live",owner:"annotations-layer (S4.9)",parse:l({v:q(1),authors:U(F(200))})},"export-capture":{gate:"parent",status:"live",owner:"canvas-lib (export)",parse:l({id:u,format:u,artboardIds:U(u),scale:I})},"export-selection-query":{gate:"parent",status:"live",owner:"canvas-lib (export)",parse:l({id:u})},"export-result":{gate:"parent",status:"live",owner:"export-dialog",orphan:"no-handler",parse:l({id:u,ok:O,browser:d(O),jobId:d(u),error:d(u)})},"export-history-result":{gate:"parent",status:"live",owner:"export-dialog",orphan:"no-handler",parse:l({id:u,history:U(ie)})},"timeline-play":{gate:"any",target:"parent",status:"live",owner:"video-comp",parse:l(Te)},"timeline-pause":{gate:"any",target:"parent",status:"live",owner:"video-comp",parse:l(Te)},"timeline-seek":{gate:"any",target:"parent",status:"live",owner:"video-comp",parse:l({...Te,frame:I})},"timeline-loop":{gate:"any",target:"parent",status:"live",owner:"video-comp",parse:l({...Te,loop:O})},"timeline-mute":{gate:"any",target:"parent",status:"live",owner:"video-comp",parse:l({...Te,muted:O})},"timeline-volume":{gate:"any",target:"parent",status:"live",owner:"video-comp",parse:l({...Te,volume:I})},"timeline-request-comps":{gate:"any",target:"parent",status:"live",owner:"video-comp",parse:pe},"run-action":{gate:"parent",status:"live",owner:"actions/registry (V2-1.3)",parse:l({v:q(1),id:u,params:d(ie)})},"paste-data":{gate:"parent",status:"live",owner:"bridge/paste-data (p8-sweep-leftovers)",parse:(e)=>{let t=ho(e);return t?{...t}:null}},"git-lifecycle":{gate:"parent",status:"legacy",owner:"c/app",orphan:"no-handler",parse:l({payload:ie})},"set-mode":{gate:"parent",status:"live",owner:"bridge/canvas-mode-store (V2-4.3b)",parse:l({v:q(2),seq:I,mode:wt,present:N(ln),tool:d(an),caps:li})},"occluded-insets":{gate:"parent",status:"new",owner:"bridge/canvas-mode-store",parse:l({seq:I,insets:pi})},"present-step":{gate:"parent",status:"live",owner:"bridge/canvas-mode-store (S3.1)",parse:l({to:(e)=>e==="next"||e==="prev"?e:I(e)})},"present-follow":{gate:"parent",status:"live",owner:"bridge/canvas-mode-store (S3.7a)",parse:l({sid:N(cn),live:O,locked:O})},"present-media-cmd":{gate:"parent",status:"live",owner:"present/present-media (S3.3)",parse:l({op:q("play","pause","mute","unmute","captions-on","captions-off")})},"key-prefs":{gate:"parent",status:"live",owner:"bridge/canvas-mode-store (V2-4 gate)",parse:l({singleKeys:O})},"annotation-prefs":{gate:"parent",status:"live",owner:"annotations/ui/tool-state (S4.8)",parse:l({prefs:To})},"vote-state":{gate:"parent",status:"live",owner:"annotations/ui/vote-dots (S4.14)",parse:l({vote:N(Y({id:bt,targets:He(32,U(F(200))),state:q("open","ended"),perVoter:ue(1,99),tallies:d(ht(yt,32))})),mine:ht(yt,32)})},"hold-intent":{gate:"parent",status:"live",owner:"editing/hold-rings (S2.18)",parse:l({field:O,app:O,gesture:d(O)})},"ai-holds":{gate:"parent",status:"live",owner:"editing/hold-rings (S2.18)",parse:l({holds:$i})},"ai-seen":{gate:"parent",status:"live",owner:"annotations/ui/ai-seen (S4.15); sent by v2/ai/seen-relay.js",parse:l({targets:Xi})},"undo-preview":{gate:"parent",status:"live",owner:"editing/undo-preview (S2.20)",parse:l({artboards:U(u),tag:N(u)})},"asset-state":{gate:"parent",status:"live",owner:"canvas-lib asset placeholder frame (S8.19, L1)",parse:l({items:oa,lfsActions:d(O)})},"asset-lfs-copied":{gate:"parent",status:"live",owner:"canvas-lib asset placeholder frame (2.0.3 LFS placeholder)",parse:l({rel:F(512),ok:O})},"gen-takes":{gate:"parent",status:"live",owner:"editing/take-keys (S8.16, L1)",parse:l({assets:ia})}};var ua="dgn",pa=(e,t)=>Object.assign({},e,{[ua]:t}),_o=(e,t)=>Object.hasOwn(e,t),ma=(e)=>we(e)&&typeof e.dgn==="string"?e.dgn:null;function fa(e){return _o(dn,e)?dn[e]:null}function ga(e){return _o(So,e)?So[e]:null}function ha(e,t,n){if(e==="any")return!0;let o=t.source;if(o===n.parent)return!0;return e==="parent|self"&&o===n}var Rd=new Set(Object.keys(dn).filter((e)=>fa(e)?.gate==="active"));function St(e,t){let n=ma(e.data),o=n?ga(n):null;if(!n||!o||!ha(o.gate,e,t))return null;let r=o.parse(e.data);return r?pa(r,n):null}var ba=/^[A-Za-z0-9_-]{1,64}$/;function rt(e){return typeof e==="string"&&ba.test(e)}function Lo(e){if(!e||typeof e!=="object")return!1;let{x:t,y:n}=e;return typeof t==="number"&&typeof n==="number"&&Number.isFinite(t)&&Number.isFinite(n)&&Math.abs(t)<=1e7&&Math.abs(n)<=1e7}function Oo(){if(typeof window>"u"||typeof document>"u")return null;let e=window.__maudeViewport?.()??null;if(!e||!(e.zoom>0))return null;let t=document.querySelector(".dc-canvas");if(!t)return null;let n=t.getBoundingClientRect();return{vp:e,left:n.left,top:n.top}}function No(e,t){let n=Oo();if(!n)return null;let{vp:o}=n;return{x:(e-n.left-o.x)/o.zoom,y:(t-n.top-o.y)/o.zoom}}function Do(e){let t=Oo();if(!t)return null;let{vp:n}=t;return{x:t.left+n.x+e.x*n.zoom,y:t.top+n.y+e.y*n.zoom}}function Et(e){if(typeof document>"u"||!rt(e))return null;return document.querySelector(`[data-id="${e}"][data-tool]`)}function Ko(e,t){if(typeof document>"u")return null;let n=null;for(let o of Array.from(document.querySelectorAll("[data-id][data-tool]"))){if(o.getAttribute("data-tool")==="section")continue;let r=o.getAttribute("data-id");if(!rt(r))continue;let s=o.getBoundingClientRect();if(s.width<=0&&s.height<=0)continue;if(e<s.left||e>s.right||t<s.top||t>s.bottom)continue;let i=Math.max(1,s.width)*Math.max(1,s.height);if(!n||i<=n.area)n={id:r,area:i}}return n?.id??null}import{useCallback as ae,useEffect as de,useMemo as qe,useRef as me,useState as se}from"react";var Tt=null;function Pe(){if(typeof window>"u")return!1;if(Tt===null)try{Tt=new URLSearchParams(window.location.search).get("ro")==="1"}catch{Tt=!1}return Tt}var Mt=null;function Be(){if(typeof window>"u")return!1;if(Mt===null)try{Mt=new URLSearchParams(window.location.search).get("cm")==="1"}catch{Mt=!1}return Mt}var Rt=null;function un(){if(typeof window>"u")return!1;if(Rt===null)try{Rt=new URLSearchParams(window.location.search).get("cg")==="1"}catch{Rt=!1}return Rt}var st="Comments are paused while this project is view only.",At=null;function pn(){if(typeof window>"u")return!1;if(At===null)try{At=new URLSearchParams(window.location.search).get("embed")==="1"}catch{At=!1}return At}function mn(){if(typeof window>"u")return!1;try{return new URLSearchParams(window.location.search).get("follow")==="1"}catch{return!1}}function zo(){if(typeof window>"u")return!1;try{return!!new URLSearchParams(window.location.search).get("sha")}catch{return!1}}var Vo=Symbol.for("maude.canvasMode.v2");function Se(e){let t=e,n=t[Vo];if(n&&n.doc===e.document)return n;let o={insets:tn,insetsSeq:-1,mode:null,present:null,caps:null,modeSeq:-1,tool:null,prevMode:null,clamped:!1,singleKeys:!0,step:null,follow:null},r=0,s=0,i=-1,c=new Map,p=new Set,f={get:()=>o,subscribe(y){return p.add(y),()=>{p.delete(y)}},claimEcho(y){if(y!==o.modeSeq||y<=i)return!1;return i=y,!0},claimRequest(y){let g=Date.now(),w=c.get(y);if(w!==void 0&&g-w<250)return!1;return c.set(y,g),!0}};return e.addEventListener("message",(y)=>{let g=St(y,e);if(g?.dgn==="set-mode"){if(g.seq<=o.modeSeq)return;c=new Map;let w=g.caps.present===!0&&!mn(),A=Pe()?{edit:!1,annotate:!1,comment:g.caps.comment,present:w}:{...g.caps,present:w},m=lo(g.mode,A),h=g.tool?nt(g.tool,A,m):null,S=g.tool&&(h===null||h===m)?g.tool:null;o={...o,mode:m,present:m==="present"?g.present??{kind:"canvas"}:null,caps:Object.freeze(A),modeSeq:g.seq,tool:S,prevMode:o.mode,clamped:m!==g.mode,step:m==="present"?o.step:null};for(let b of p)b(o);return}if(g?.dgn==="present-step"){if(o.mode!=="present")return;r+=1,o={...o,step:Object.freeze({to:g.to,n:r})};for(let w of p)w(o);return}if(g?.dgn==="present-follow"){if(!mn())return;s+=1,o={...o,follow:Object.freeze({sid:g.sid,live:g.live,locked:g.locked,n:s})};for(let w of p)w(o);return}if(g?.dgn==="key-prefs"){if(g.singleKeys===o.singleKeys)return;o={...o,singleKeys:g.singleKeys};for(let w of p)w(o);return}if(g?.dgn!=="occluded-insets")return;if(g.seq<=o.insetsSeq)return;o={...o,insets:Object.freeze({...g.insets}),insetsSeq:g.seq};for(let w of p)w(o)}),Object.defineProperty(f,"doc",{value:e.document}),t[Vo]=f,f}function Ho(){return typeof window>"u"?tn:Se(window).get().insets}if(typeof window<"u"&&typeof window.addEventListener==="function")Se(window);var _e=["sky","green","yellow","lilac","grey"],Fo="yellow",fn=Object.freeze({sky:"oklch(0.78 0.10 230)",green:"oklch(0.74 0.13 152)",yellow:"oklch(0.82 0.14 95)",lilac:"oklch(0.76 0.10 290)",grey:"oklch(0.70 0.01 250)"});function $o(e){if(!e)return _e[0];let t=5381;for(let o=0;o<e.length;o++)t=(t<<5)+t+e.charCodeAt(o)|0;let n=(t%_e.length+_e.length)%_e.length;return _e[n]??_e[0]}var gn=(e)=>fn[e];var ya="Someone",wa=(e)=>{if(typeof e!=="string")return!0;let t=e.trim().toLowerCase();return t===""||t==="unknown"};function it(e,t){if(wa(e))return{name:ya,letter:"S",tone:"grey",you:!1};let n=e.trim(),o=!!t&&t.trim()===n;return{name:o?"You":n,letter:n.charAt(0).toUpperCase(),tone:o?Fo:$o(n),you:o}}var va=(e)=>e.trim().split(/\s+/)[0]||"";function at(e){let t=typeof e.author==="string"?e.author.trim():"";if(t==="AI")return{name:t,ai:!0,first:t};return{name:t,ai:!1,first:va(t)}}function qo(e){let t=at(e);return t.first?`From ${t.first}’s sticky`:"From a sticky"}var xa=/^[A-Za-z0-9._-]{1,40}$/;var ka={figma:"Figma"},Sa=/[\p{Cc}\p{Cf}\p{Cs}\p{Co}\p{Cn}\p{Zl}\p{Zp}]/gu;function Ea(e){if(typeof e!=="string")return"";let n=e.normalize("NFC").replace(/\s+/gu," ").replace(Sa,"").replace(/\s+/gu," ").trim();return Array.from(n).slice(0,80).join("").trim()}var jo=(e)=>!!e&&typeof e==="object"&&!Array.isArray(e);function Ta(e){if(typeof e!=="string"||e.length>40)return;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toISOString():void 0}function hn(e){if(!jo(e)||e.source!=="figma")return;let t=jo(e.author)?e.author:{},n={source:"figma",author:{name:Ea(t.name)||"Someone"}};if(typeof t.handle==="string"&&t.handle.length<=40&&xa.test(t.handle))n.author.handle=t.handle;let o=Ta(e.at);if(o)n.at=o;return n}function bn(e){return e?`${e.author.name} · from ${ka[e.source]}`:""}function Uo(e){return(String(e??"").trim().split(/\s+/)[0]??"").replace(/[^\w.-]/g,"").toLowerCase()}function Wo(e,t){let{mine:n,...o}=e;return t?{...o,mine:!0}:o}function Ma(e,t){return(Array.isArray(e)?e:[]).map((n)=>{let o=Wo(n,t(n));if(Array.isArray(n.thread))o.thread=n.thread.map((r)=>r&&typeof r==="object"?Wo(r,t(r)):r);return o})}function Bo(e){let t=new Set;for(let n of Array.isArray(e)?e:[]){if(n?.mine===!0&&typeof n.id==="string")t.add(n.id);if(Array.isArray(n?.thread)){for(let o of n.thread)if(o?.mine===!0&&typeof o.id==="string")t.add(o.id)}}return t}function Xo(e,t){return Ma(e,(n)=>typeof n.id==="string"&&t.has(n.id))}function Xe(e,t){return e?.mine===!0&&typeof e.author==="string"?e.author:t}var Yo=Object.freeze({observer:"Can view",viewer:"Can comment",member:"Can edit",owner:"Owner"}),Ra=(e)=>typeof e==="string"&&Object.hasOwn(Yo,e)?Yo[e]:void 0;function Aa(e,t){if(!Array.isArray(e))return[];let n=[],o=new Set,r=(t??"").trim().toLowerCase();for(let s of e.slice(0,200)){if(!s||typeof s!=="object")continue;let i=s;if(i.state!==void 0&&i.state!==null&&i.state!=="")continue;if(typeof i.name!=="string"||!i.name.trim())continue;let c=i.name.trim().slice(0,120);if(r&&c.toLowerCase()===r)continue;let p=typeof i.id==="string"&&i.id?i.id:c;if(o.has(p))continue;o.add(p);let f=Ra(i.role);n.push(f?{id:p,name:c,role:f}:{id:p,name:c})}return n}function Qo(e,t){if(!Array.isArray(e))return[];return Aa(e.map((n)=>({name:n?.name})),t)}function Ca(e,t=96){return e*t/25.4}function Go(e,t=96){return e*25.4/t}var Ia=[{id:"a6",label:"A6",category:"iso",unit:"mm",width:105,height:148},{id:"a5",label:"A5",category:"iso",unit:"mm",width:148,height:210},{id:"a4",label:"A4",category:"iso",unit:"mm",width:210,height:297},{id:"a3",label:"A3",category:"iso",unit:"mm",width:297,height:420},{id:"a2",label:"A2",category:"iso",unit:"mm",width:420,height:594},{id:"a1",label:"A1",category:"iso",unit:"mm",width:594,height:841},{id:"a0",label:"A0",category:"iso",unit:"mm",width:841,height:1189},{id:"letter",label:"Letter",category:"us",unit:"in",width:8.5,height:11},{id:"legal",label:"Legal",category:"us",unit:"in",width:8.5,height:14},{id:"tabloid",label:"Tabloid",category:"us",unit:"in",width:11,height:17},{id:"dl",label:"DL envelope",category:"envelope",unit:"mm",width:110,height:220},{id:"c5",label:"C5 envelope",category:"envelope",unit:"mm",width:162,height:229},{id:"card-eu",label:"Business card (EU)",category:"card",unit:"mm",width:85,height:55},{id:"card-us",label:"Business card (US)",category:"card",unit:"in",width:3.5,height:2},{id:"poster-18x24",label:'Poster 18×24"',category:"poster",unit:"in",width:18,height:24},{id:"poster-24x36",label:'Poster 24×36"',category:"poster",unit:"in",width:24,height:36}];function Pa(e){return Ia.find((t)=>t.id===e)}function _a(e,t){let n=e.unit==="mm"?e.width:e.width*25.4,o=e.unit==="mm"?e.height:e.height*25.4;return t==="landscape"?{widthMm:o,heightMm:n}:{widthMm:n,heightMm:o}}function La(e){return e.unit==="mm"?3:3.175}var Ct=5,Oa=200;function It(e){if(!Number.isFinite(e))return 0;return Math.min(Math.max(e,0),Oa)}function Na(e){let t=e??{};return{top:typeof t.top==="number"?It(t.top):Ct,right:typeof t.right==="number"?It(t.right):Ct,bottom:typeof t.bottom==="number"?It(t.bottom):Ct,left:typeof t.left==="number"?It(t.left):Ct}}function yn(e,t=96){return Math.round(Ca(e,t))}function wn(e){let t=Pa(e.paper);if(!t)throw Error(`unknown paper preset: ${e.paper}`);let n=e.orientation??"portrait",{widthMm:o,heightMm:r}=_a(t,n),s=e.bleedMm??La(t),i=Na(e.marginsMm),c=yn(s),p=yn(o),f=yn(r);return{paper:t.id,orientation:n,trimWidthMm:o,trimHeightMm:r,bleedMm:s,widthPx:p+2*c,heightPx:f+2*c,trimWidthPx:p,trimHeightPx:f,bleedPx:c,marginsMm:i}}function Da(e){let t=Math.max(0,Math.floor(Number.isFinite(e)?e:0)),n=Math.floor(t/3600),o=Math.floor(t%3600/60),r=t%60,s=(i)=>String(i).padStart(2,"0");return n>0?`${n}:${s(o)}:${s(r)}`:`${o}:${s(r)}`}var Ka=(e)=>`at ${Da(e)}`,za=0.5;function Zo(e,t,n=za){if(t===null||t===void 0||!Number.isFinite(t))return!0;return Math.abs(t-e)<=n}function vn(e){if(!e||typeof e!=="object")return null;let t=e;if(typeof t.paper!=="string")return null;try{let n=wn({paper:t.paper,orientation:t.orientation==="landscape"?"landscape":"portrait",...typeof t.bleedMm==="number"?{bleedMm:t.bleedMm}:{}});return{wMm:n.trimWidthMm,hMm:n.trimHeightMm}}catch{return null}}function Jo(e,t){if(!e||typeof e!=="object")return null;let n=e;if(typeof n.paper!=="string")return null;try{let o=wn({paper:n.paper,orientation:n.orientation==="landscape"?"landscape":"portrait",...typeof n.bleedMm==="number"?{bleedMm:n.bleedMm}:{}}),r=(s)=>Math.round(Go(s)*10)/10;return{x:r(t.x-o.bleedPx),y:r(t.y-o.bleedPx)}}catch{return null}}var Pt=(e)=>`${Math.round(e)} mm`;function Va(e,t){if(t&&(e.x<0||e.y<0||e.x>t.wMm||e.y>t.hMm))return"In the bleed";let n=!!t&&e.x>t.wMm/2,o=!!t&&e.y>t.hMm/2,r=n?`${Pt(t.wMm-e.x)} from the right`:`${Pt(e.x)} from the left`,s=o?`${Pt(t.hMm-e.y)} above the trim`:`${Pt(e.y)} from the top`;return`${r} · ${s}`}function xn(e,t){let n=typeof e.artboard==="string"&&e.artboard?e.artboard:null;if(typeof e.t==="number"&&Number.isFinite(e.t))return{artboard:n,chip:Ka(e.t),kind:"video"};let o=e.mm;if(o&&typeof o.x==="number"&&typeof o.y==="number")return{artboard:n,chip:Va({x:o.x,y:o.y},t),kind:"print"};return{artboard:n,chip:null,kind:n?"artboard":"canvas"}}class Le extends Error{}var kn=(e,t)=>Math.abs(e.x-t.x)<0.000001&&Math.abs(e.y-t.y)<0.000001,ce=(e,t)=>({x:e,y:t}),_t=/([MmLlHhVvCcSsQqTtZzAa])|(-?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?)/g,Ha={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,Z:0};function Fa(e){let t=[];_t.lastIndex=0;let n=0;for(let o=_t.exec(e);o;o=_t.exec(e)){if(/[^\s,]/.test(e.slice(n,o.index)))throw new Le("not a path");t.push(o[1]??Number(o[2])),n=_t.lastIndex}if(/[^\s,]/.test(e.slice(n)))throw new Le("not a path");return t}function er(e){let t=Fa(e),n=[],o=null,r=ce(0,0),s=ce(0,0),i=null,c=null,p=0,f="",y=(m)=>{let h=[];for(let S=0;S<m;S++){let b=t[p++];if(typeof b!=="number")throw new Le("not a path");h.push(b)}return h},g=(m)=>{o={closed:!1,points:[{...m}]},n.push(o),r=m,s=m},w=(m,h,S)=>{if(!o)g(r);let b=o,a=b.points[b.points.length-1];if(!kn(m,a))a.out=m;let x={...S};if(!kn(h,S))x.in=h;b.points.push(x),r=S,i=h,c="c"},A=(m)=>{if(!o)g(r);o.points.push({...m}),r=m,c=null};while(p<t.length){let m=t[p];if(typeof m==="string"){if(f=m,p++,m==="A"||m==="a")throw new Le("arc")}else if(!f||f==="Z"||f==="z")throw new Le("not a path");else if(f==="M")f="L";else if(f==="m")f="l";let h=f===f.toLowerCase(),S=f.toUpperCase(),b=h?r.x:0,a=h?r.y:0,x=Ha[S];if(x===void 0)throw new Le("not a path");let R=y(x);switch(S){case"M":g(ce(R[0]+b,R[1]+a)),c=null;break;case"L":A(ce(R[0]+b,R[1]+a));break;case"H":A(ce(R[0]+b,r.y));break;case"V":A(ce(r.x,R[0]+a));break;case"C":w(ce(R[0]+b,R[1]+a),ce(R[2]+b,R[3]+a),ce(R[4]+b,R[5]+a));break;case"S":{let j=c==="c"&&i?ce(2*r.x-i.x,2*r.y-i.y):r;w(j,ce(R[0]+b,R[1]+a),ce(R[2]+b,R[3]+a));break}case"Q":case"T":{let j=r,T,P;if(S==="Q")T=ce(R[0]+b,R[1]+a),P=ce(R[2]+b,R[3]+a);else T=c==="q"&&i?ce(2*r.x-i.x,2*r.y-i.y):r,P=ce(R[0]+b,R[1]+a);w(ce(j.x+0.6666666666666666*(T.x-j.x),j.y+0.6666666666666666*(T.y-j.y)),ce(P.x+0.6666666666666666*(T.x-P.x),P.y+0.6666666666666666*(T.y-P.y)),P),i=T,c="q";break}case"Z":{if(o){let j=o;j.closed=!0;let T=j.points[0],P=j.points[j.points.length-1];if(j.points.length>1&&kn(T,P)){if(P.in)T.in=P.in;j.points.pop()}}r=s,c=null;break}}}if(n.length===0)throw new Le("empty");return{subs:n}}var tr=(e)=>e.subs.reduce((t,n)=>t+n.points.length,0);function nr(e,t){return(t?.flexDirection||"row").trim().startsWith("row")?e==="width":e==="height"}var $a=new Set(["fit-content","max-content","min-content","auto"]),qa=new Set(["100%","fill","-webkit-fill-available","stretch"]),ja=(e)=>e==="flex"||e==="inline-flex";function Ua(e,t){let n=t.width.trim().toLowerCase();if(qa.has(n))return"fill";if($a.has(n))return"hug";if(/^-?\d/.test(n))return"fixed";if(nr("width",e))return Number.parseFloat(t.flexGrow||"0")>=1?"fill":"hug";let o=t.alignSelf.trim()||"auto",r=(e.alignItems||"normal").trim();return o==="stretch"||o==="auto"&&(r==="normal"||r==="stretch")?"fill":"hug"}function or(e,t){if(!ja(e.display)||t.length<2)return;let n=new Set(t.map((r)=>Ua(e,r))),o=new Set(t.map((r)=>r.tag.toLowerCase()));return{count:t.length,tag:o.size===1?[...o][0]:"",width:n.size===1?[...n][0]:"mixed"}}var Wa=new WeakMap;var rr=(e)=>Wa.get(e)??null;var sr=(e)=>e?`${e.sub},${e.i},${e.kind},${e.x},${e.y}`:"";var Sn=["font-family","font-size","font-weight","line-height","letter-spacing","text-transform","font-style"];var Ba=/^t-[a-z][a-z0-9-]*$/,Xa=(e)=>(e??"").split(/\s+/).filter(Boolean),ir=(e)=>Xa(e).filter((t)=>Ba.test(t));var ou=Object.freeze({"font-family":"font","font-size":"size","font-weight":"weight","line-height":"line height","letter-spacing":"letter spacing","text-transform":"case","font-style":"italic"});var ru=Object.freeze([{tag:"cs",label:"Čeština"},{tag:"en",label:"English"},{tag:"sk",label:"Slovenčina"},{tag:"de",label:"Deutsch"},{tag:"pl",label:"Polski"}]);var ar=(e,t)=>{let n=t.getComputedStyle(e),o={};for(let r of Sn)o[r]=n.getPropertyValue(r).trim();return o},Ya=(e)=>e.closest?.("[lang]")?.getAttribute("lang")?.trim()??"";function lr(e){let n=e.ownerDocument?.defaultView;if(!n||typeof n.getComputedStyle!=="function")return null;let o=ir(e.getAttribute("class"))[0]??null,r=ar(e,n),s={role:o,values:{},differs:[],lang:Ya(e),upper:(n.getComputedStyle(e).getPropertyValue("text-transform")??"").trim()==="uppercase"};if(!o)return s;let i=e,c=e.hasAttribute("style"),p=e.getAttribute("style")??"";try{let f=`${p};transition:none`;i.setAttribute("style",f),i.setAttribute("style","transition:none"),s.values=ar(e,n),i.setAttribute("style",f),n.getComputedStyle(e).getPropertyValue("font-size")}finally{if(c)i.setAttribute("style",p);else i.removeAttribute("style")}return s.differs=Sn.filter((f)=>r[f]!==s.values[f]),s}function Qa(e,t){if(e==="/_canvas-shell.html"||e==="/_canvas-shell"){let n=new URLSearchParams(t),o=(n.get("designRel")??".design").replace(/^\/+|\/+$/g,""),r=(n.get("canvas")??"").replace(/^\/+/,"");if(o&&r.startsWith(`${o}/`))r=r.slice(o.length+1);if(!r)return null;return o?`${o}/${r}`:r}return decodeURIComponent(e).replace(/^\//,"")}function Lt(){if(typeof window>"u")return null;try{return Qa(window.location.pathname,window.location.search)}catch{return null}}function Tn(){return Lt()??void 0}function Ot(e){if(!e)return"";return(e.getAttribute("class")??"").trim().split(/\s+/).filter((t)=>t&&!t.startsWith("dgn-")&&!t.startsWith("dc-cv-")).join(" ")}var Ga=/^$|^(inline|contents|ruby|ruby-text)$|^inline-/;function Za(e){let t="",n=(o)=>{if(o.nodeType===3){t+=o.nodeValue??"";return}if(o.nodeType!==1)return;let r=o,s=r.nodeName;if(s==="SCRIPT"||s==="STYLE"||s==="TEMPLATE"||s==="NOSCRIPT")return;if(s==="BR"){t+=" ";return}let i=getComputedStyle(r).display;if(i==="none"&&r!==e)return;let c=!Ga.test(i);if(c)t+=" ";for(let p=r.firstChild;p;p=p.nextSibling)n(p);if(c)t+=" "};return n(e),t}function Ja(e,t){if(!e)return"";let o=(e.innerText||(e.textContent?Za(e):"")).replace(/\s+/g," ").trim();return o.length>t?`${o.slice(0,t-1)}…`:o}function el(e){if(!e)return"";let t=[],n=e;while(n&&n.nodeType===1&&t.length<8){let o=n.getAttribute?.("data-dc-element");if(o){t.unshift(`[data-dc-element="${o}"]`);break}let r=n.getAttribute?.("data-dc-screen");if(r){t.unshift(`[data-dc-screen="${r}"]`);break}let s=n.nodeName.toLowerCase();if(n.id){s=`#${n.id}`,t.unshift(s);break}let i=Ot(n).split(/\s+/).filter(Boolean).slice(0,2);if(i.length)s+=`.${i.join(".")}`;let c=1,p=n.previousElementSibling;while(p)c++,p=p.previousElementSibling;s+=`:nth-child(${c})`,t.unshift(s),n=n.parentElement}return t.join(" > ")}function dr(e){let t=[],n=e;while(n&&n.nodeType===1&&t.length<8){let o=n.nodeName.toLowerCase(),r=n.getAttribute?.("data-dc-element"),s=n.getAttribute?.("data-dc-screen");if(r)o+=`[data-dc-element="${r}"]`;else if(s)o+=`[data-dc-screen="${s}"]`;else if(n.id)o+=`#${n.id}`;let i=Ot(n).split(/\s+/).filter(Boolean).slice(0,2);if(i.length&&!r&&!s)o+=`.${i.join(".")}`;t.unshift(o),n=n.parentElement}return t}function tl(e){return e.replace(/[^a-zA-Z0-9_-]/g,(t)=>`\\${t}`)}function ur(e,t){return t?`[data-dc-screen="${t}"] [data-cd-id="${e}"]`:`[data-cd-id="${e}"]`}function pr(e,t,n){if(!n)return 0;try{let o=e.querySelectorAll(t);for(let r=0;r<o.length;r++)if(o[r]===n)return r}catch{}return 0}function mr(e,t,n){if(!t||!n)return 0;return pr(e,`[data-cd-id="${tl(t)}"]`,n)}function Mn(e,t){let n=(o)=>{try{let r=e.querySelectorAll(o);if(!r.length)return null;let s=t.index&&t.index>0&&t.index<r.length?t.index:0;return r[s]??r[0]}catch{return null}};if(t.id){let o=n(ur(t.id,t.artboardId));if(o)return o}if(t.selector)return n(t.selector);return null}function nl(e,t){let n=0,o=Math.min(e.length,t.length);for(let r=1;r<=o;r++){if(e[e.length-r]!==t[t.length-r])break;n++}return n}function fr(e,t){let n=t.dom_path,o=(t.tag||"").toLowerCase();if(!n||n.length===0||!o)return null;let r=e;if(t.artboardId){let p=e.querySelector(`[data-dc-screen="${t.artboardId}"]`);if(p)r=p}let s=(t.classes||"").split(/\s+/).filter(Boolean),i=null,c=0;for(let p of Array.from(r.querySelectorAll("[data-cd-id]"))){if(p.tagName.toLowerCase()!==o)continue;let f=nl(dr(p),n);if(f===0)continue;let y=Ot(p).split(/\s+/).filter(Boolean),g=s.filter((A)=>y.includes(A)).length,w=f*10+g;if(w>c)c=w,i=p}return i}var cr=["display","flex-direction","flex-wrap","align-items","justify-content","gap","flex","flex-grow","flex-shrink","flex-basis","align-self","font-family","color","font-size","font-weight","line-height","letter-spacing","text-align","margin","margin-top","margin-right","margin-bottom","margin-left","padding","padding-top","padding-right","padding-bottom","padding-left","width","height","min-width","min-height","max-width","max-height","background-color","border-radius","border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius","border-width","border-style","border-color","box-shadow","opacity","position","top","right","bottom","left","z-index","transform","transform-origin","font-style","text-transform","text-decoration","white-space","overflow","stroke","stroke-width","stroke-linecap","stroke-linejoin","object-fit","aspect-ratio","object-position"],ol=/^(style|class|data-cd-id|data-dc-|data-dcid$)/;function rl(e){if(!e||typeof window>"u"||!window.getComputedStyle)return{authored:{},computed:{},customStyles:{},attrs:{}};try{let t=e.style,n=window.getComputedStyle(e),o={},r={},s=new Set(cr);for(let m of cr){let h=t.getPropertyValue(m);if(h)o[m]=h.trim();let S=n.getPropertyValue(m);if(S)r[m]=S.trim()}let i=/^(margin|padding|border)(-|$)/,c={};for(let m=0;m<t.length;m++){let h=t.item(m);if(!h||s.has(h)||i.test(h))continue;let S=t.getPropertyValue(h);if(S)c[h]=S.trim()}let p={};for(let m of Array.from(e.attributes)){if(ol.test(m.name))continue;p[m.name]=m.value}if(e.tagName.toLowerCase()==="svg"&&e.getAttribute("data-shape")==="path"){let m=e.querySelector("path")?.getAttribute("d");if(m)try{p["data-dc-pen-points"]=String(tr(er(m)))}catch{}let h=sr(rr(e));if(h)p["data-dc-pen-point"]=h}if(e.hasAttribute("data-dc-screen")){for(let h of Array.from(e.attributes))if(h.name.startsWith("data-dc-")&&h.name!=="data-dcid")p[h.name]=h.value;let m=ul(e);if(m)p["data-dc-web-longest"]=String(m)}let f=e.parentElement,y=f?window.getComputedStyle(f).display:"",g=f&&(y==="flex"||y==="inline-flex")?window.getComputedStyle(f).flexDirection:"",w={},A=t.getPropertyValue("background").trim();if(A)w.background=A;return{authored:o,computed:r,customStyles:c,attrs:p,declared:w,parentDisplay:y,parentFlexDirection:g}}catch{return{authored:{},computed:{},customStyles:{},attrs:{}}}}function sl(e){let t=e.offsetParent;return{x:Math.round(e.offsetLeft),y:Math.round(e.offsetTop),w:Math.round(e.offsetWidth),h:Math.round(e.offsetHeight),parentW:Math.round(t?.clientWidth??0),parentH:Math.round(t?.clientHeight??0)}}var il=/^--[A-Za-z0-9_-]{1,128}$/,al=/^[A-Za-z][A-Za-z0-9]{0,63}$/;function ll(e){let t=e.getAttribute?.("data-ds-token");if(t&&il.test(t))return`[data-ds-token="${t}"]`;let n=e.getAttribute?.("data-ds-master");if(n&&al.test(n))return`[data-ds-master="${n}"]`;return null}function Rn(e,t){let n=e.el,o=n&&n.getBoundingClientRect?n.getBoundingClientRect():null,r=e.cdId,s=!r&&n?ll(n):null,i=r?ur(r,e.artboardId):s?e.artboardId?`[data-dc-screen="${e.artboardId}"] ${s}`:s:e.artboardId?`[data-dc-screen="${e.artboardId}"]`:el(n),c=r&&typeof document<"u"?pr(document,i,n):0;return{file:t??Tn(),id:r??void 0,selector:i,artboardId:s?null:e.artboardId,index:c,tag:n?.tagName.toLowerCase()??"",classes:Ot(n),text:Ja(n,240),dom_path:dr(n),bounds:o?{x:Math.round(o.left),y:Math.round(o.top),w:Math.round(o.width),h:Math.round(o.height)}:null,worldW:n instanceof HTMLElement?Math.round(hr(n)):void 0,worldH:n instanceof HTMLElement?Math.round(En(n)):void 0,geometry:n instanceof HTMLElement?sl(n):void 0,html:n?(n.outerHTML??"").slice(0,4000):"",...(()=>{if(n?.tagName?.toLowerCase()!=="img")return{};let p=/assets\/[0-9a-f]{8}\.[a-z0-9]+/i,f=n.getAttribute?.("data-photo-asset");if(f&&p.test(f))return{photoKind:"artboard-img",photoAsset:f};let y=n.getAttribute?.("src")||"",g=p.exec(y);return g?{photoKind:"artboard-img",photoAsset:g[0]}:{}})(),...rl(n),...dl(n),...cl(n)}}function cl(e){if(!e||typeof window>"u"||!window.getComputedStyle||!e.children?.length)return{};try{let t=window.getComputedStyle(e),n=t.display;if(n!=="flex"&&n!=="inline-flex")return{};let o=Array.from(e.children).filter((s)=>s instanceof HTMLElement).map((s)=>{let i=s.style,c=i.getPropertyValue("flex-grow").trim();return{tag:s.tagName.toLowerCase(),width:i.getPropertyValue("width").trim(),flexGrow:c||window.getComputedStyle(s).flexGrow||"",alignSelf:i.getPropertyValue("align-self").trim()}}),r=or({display:n,flexDirection:t.flexDirection,alignItems:t.alignItems},o);return r?{kids:r}:{}}catch{return{}}}function dl(e){if(!e||e.children.length>0)return{};if(!(e.textContent??"").trim()&&!e.getAttribute("class"))return{};let t=lr(e);return t?{textInfo:t}:{}}function gr(e){if(!e.hasAttribute("data-dc-screen"))return null;let t=Array.from(e.children).find((n)=>n.classList.contains("dc-artboard-body"));return t&&t.offsetWidth?t:null}function hr(e){return gr(e)?.offsetWidth??e.offsetWidth}function ul(e){let t=(i)=>i.getAttribute("data-dc-kind")==="web"&&i.getAttribute("data-dc-fixed")!=="true";if(!e.hasAttribute("data-dc-screen")||!t(e))return null;let n=e.closest("[data-dc-section]")??e.ownerDocument,o=Array.from(n.querySelectorAll("[data-dc-screen]")).filter(t);if(o.length<2||!o.includes(e))return null;if(new Set(o.map((i)=>Math.round(hr(i)))).size!==o.length)return null;let s=En(e);return o.every((i)=>i===e||En(i)<s)?o.length:null}function En(e){let t=gr(e);if(t)return t.offsetHeight;if(e.getAttribute("data-dc-fixed")!=="true"||!e.hasAttribute("data-dc-screen"))return e.offsetHeight;let n=Array.from(e.children).find((o)=>o.classList.contains("dc-artboard-label"));return e.offsetHeight-(n?n.offsetHeight:0)}function br(){if(typeof window>"u")return null;let e=window.__maudeFrameFreeze;return e&&typeof e.raf==="function"?e:null}function re(e){let t=br();return t?t.raf(e):requestAnimationFrame(e)}function ve(e){let t=br();if(t)t.caf(e);else cancelAnimationFrame(e)}import*as Cn from"lib0/decoding";import*as lt from"lib0/encoding";import{createContext as fl,useCallback as $u,useContext as gl,useEffect as qu,useMemo as ju,useReducer as Uu,useRef as Wu,useState as Bu}from"react";import{Awareness as Yu,applyAwarenessUpdate as Qu,encodeAwarenessUpdate as Gu}from"y-protocols/awareness";import{readSyncMessage as Ju,writeSyncStep1 as ep,writeUpdate as tp}from"y-protocols/sync";import*as In from"yjs";import*as pl from"yjs";var ml=new WeakSet;function yr(e){return ml.add(e),e}var hu=yr(Object.freeze({maudeOrigin:"shell-edit"})),bu=yr(Object.freeze({maudeOrigin:"sync-agent"}));import*as Nt from"lib0/decoding";import*as Ye from"lib0/encoding";import*as wr from"y-protocols/awareness";import*as An from"y-protocols/sync";var vu=Object.freeze(["timeline","editing","holding"]),xu=Object.freeze(["editing","holding"]);var lp=_e.map((e)=>fn[e]);var hl=fl(null);function vr(){return gl(hl)}var cp=Object.freeze({maudeOrigin:"collab-epoch-resync"});import{createContext as bl,useCallback as be,useContext as _n,useEffect as yl,useMemo as wl,useRef as ct,useState as vl}from"react";import{jsx as Pn,Fragment as Ml}from"react/jsx-runtime";var Kt=bl(null);function Ee(e){return e.id?`id:${e.id}`:`sel:${e.selector}`}function Dt(e){let t=[],n=new Set;for(let o of e){let r=Ee(o);if(n.has(r))continue;n.add(r),t.push(o)}return t}var xl=50,Sr=500,kl=(e,t)=>e.length===t.length&&e.every((n,o)=>Ee(n)===Ee(t[o]));function xr(e,t,n,o=Date.now()){return o-e<Sr&&!kl(n,t)}function Sl(e,t,n=Date.now()){if(n-e.at>=Sr||t.length===0)return!1;let o=new Set(e.sel.map(Ee));return t.every((r)=>o.has(Ee(r)))}var kr=null;function El(e){if(!kr||e.length===0)return null;try{return kr(e)}catch{return null}}function Tl({children:e,postTarget:t}){let[n,o]=vl([]),r=ct([]),s=ct(Number.NEGATIVE_INFINITY),i=ct({at:Number.NEGATIVE_INFINITY,sel:[]}),c=ct(null),p=ct(null),f=be((T)=>{if(c.current)clearTimeout(c.current);p.current=()=>{c.current=null,p.current=null;let P=t??(typeof window<"u"?window.parent:null);if(!P)return;let z=T.length===0?null:T.length===1?T[0]??null:T;try{P.postMessage({dgn:"select-set",selection:z,...El(T)},"*")}catch{}},c.current=setTimeout(()=>p.current?.(),xl)},[t]);yl(()=>()=>{if(c.current)clearTimeout(c.current);p.current?.()},[]);let y=be((T)=>{r.current=T,o(T),f(T)},[f]),g=be((T)=>{s.current=Date.now(),y(Dt(Array.isArray(T)?T:[T]))},[y]),w=be((T)=>Sl(i.current,T),[]),A=be((T)=>{let P=Dt(Array.isArray(T)?T:[T]);if(xr(s.current,r.current,P))return!1;if(w(P))return!1;return y(P),!0},[y,w]),m=be((T)=>{let P=Array.isArray(T)?T:[T],z=Dt([...r.current,...P]);if(xr(s.current,r.current,z))return!1;if(w(P))return!1;return y(z),!0},[y,w]),h=be(()=>r.current,[]),S=be((T)=>{let P=r.current,z=P.filter(T);if(z.length===P.length)return;i.current={at:Date.now(),sel:P.filter((L)=>!T(L))},y(z)},[y]),b=be((T)=>{let P=Array.isArray(T)?T:[T];s.current=Date.now(),o((z)=>{let L=Dt([...z,...P]);return r.current=L,f(L),L})},[f]),a=be((T)=>{let P=Ee(T);s.current=Date.now(),o((z)=>{let L=z.filter((V)=>Ee(V)!==P);return r.current=L,f(L),L})},[f]),x=be((T)=>{let P=Ee(T);s.current=Date.now(),o((z)=>{let L=z.some((V)=>Ee(V)===P)?z.filter((V)=>Ee(V)!==P):[...z,T];return r.current=L,f(L),L})},[f]),R=be(()=>{s.current=Date.now(),y([])},[y]),j=wl(()=>({selected:n,replace:g,add:b,remove:a,toggle:x,clear:R,replaceFromShell:A,addFromShell:m,peek:h,drop:S}),[n,g,b,a,x,R,A,m,h,S]);return Pn(Kt.Provider,{value:j,children:e})}function Er({children:e}){if(_n(Kt))return Pn(Ml,{children:e});return Pn(Tl,{children:e})}function zt(){let e=_n(Kt);if(!e)throw Error("useSelectionSet must be used inside <SelectionSetProvider>");return e}function Tr(){return _n(Kt)}import{jsx as C,jsxs as X,Fragment as ec}from"react/jsx-runtime";var Rl=800,Al=20000,Oe=new Map,Nr=0;function Cl(e){if(e.source!==window.parent)return;let t=e.data;if(!t||typeof t!=="object"||typeof t.dgn!=="string")return;if(t.dgn!=="comment-op-ack"&&t.dgn!=="comment-op-result"&&t.dgn!=="comment-people")return;let n=`${t.dgn==="comment-op-ack"?"ack":"res"}:${String(t.reqId)}`;Oe.get(n)?.(t)}function Dr(){if(typeof window>"u")return;window.addEventListener("message",Cl)}var Kr=()=>typeof window<"u"&&window.parent!==window;function On(e,t){return new Promise((n)=>{let o=setTimeout(()=>{Oe.delete(e),n(null)},t);Oe.set(e,(r)=>{clearTimeout(o),Oe.delete(e),n(r)})})}async function Qe(e){if(!Kr())return null;Dr();let t=`cm${++Nr}`,n=On(`ack:${t}`,Rl),o=On(`res:${t}`,Al);try{window.parent.postMessage({dgn:"comment-op",reqId:t,op:e},"*")}catch{return Oe.delete(`ack:${t}`),Oe.delete(`res:${t}`),null}if(!await n)return Oe.delete(`res:${t}`),null;let r=await o;if(!r)return{ok:!1,error:"That did not go through."};return r.ok?{ok:!0,comment:r.comment??null}:{ok:!1,error:r.error||"That did not go through."}}async function Il(){if(!Kr())return null;Dr();let e=`cm${++Nr}`,t=On(`res:${e}`,2500);try{window.parent.postMessage({dgn:"comment-people-request",reqId:e},"*")}catch{return Oe.delete(`res:${e}`),null}let n=await t;return Array.isArray(n?.people)?n.people:null}function zn(e){if(typeof document>"u")return null;for(let t of document.querySelectorAll("[data-dc-screen]"))if(t.getAttribute("data-dc-screen")===e)return t;return null}function Mr(e){let n=zn(e)?.querySelector(".dc-artboard-label");return(n instanceof HTMLInputElement?n.value:n?.textContent)?.trim()||e}function zr(e){return(e.querySelector(".dc-artboard-body")??e).getBoundingClientRect()}function Pl(e,t){if(typeof document>"u")return null;for(let n of document.querySelectorAll("[data-dc-screen]")){let o=zr(n);if(e>=o.left&&e<=o.right&&t>=o.top&&t<=o.bottom)return n.getAttribute("data-dc-screen")}return null}function Vn(e){let t=zn(e)?.getAttribute("data-dc-print");if(!t)return null;try{return JSON.parse(t)}catch{return null}}function Vr(e){let t=globalThis.__maudeVideoComps;if(!t)return null;for(let n of t.values()){if(n.artboardId!==e)continue;try{let o=n.ref.current?.getCurrentFrame?.();if(typeof o==="number"&&n.fps>0)return o/n.fps}catch{}}return null}function _l(e,t){let n=globalThis.__maudeVideoComps;if(!n)return!1;for(let o of n.values()){if(o.artboardId!==e)continue;let r=o.ref.current;if(!r?.seekTo)continue;try{return r.pause?.(),r.seekTo(Math.max(0,Math.round(t*o.fps))),!0}catch{}}return!1}function Ll(e,t,n){let o=e||Pl(t,n),r=o?zn(o):null;if(!o||!r)return{};let s={artboard:o},i=r.getAttribute("data-dc-kind");if(i==="video"){let c=Vr(o);if(c!==null)s.t=Math.round(c*1000)/1000}else if(i==="print"){let c=zr(r),p=r.querySelector(".dc-artboard-body"),f=p&&c.width>0?p.offsetWidth/c.width:1,y=Jo(Vn(o),{x:(t-c.left)*(f||1),y:(n-c.top)*(f||1)});if(y)s.mm=y}return s}var Ol="/_client/comments-overlay.css";function Nl(){if(typeof document>"u")return;if(document.getElementById("cm-overlay-css"))return;let e=document.createElement("link");e.id="cm-overlay-css",e.rel="stylesheet",e.href=Ol,document.head.appendChild(e)}function Hn(){return Lt()}function Dl(e){if(rt(e.annotationId))return Et(e.annotationId);if(!e.selector)return null;let t=null;try{let n=document.querySelectorAll(e.selector),o=e.index&&e.index>0&&e.index<n.length?e.index:0;t=n[o]??n[0]??null}catch{t=null}if(t&&e.tag&&t.tagName.toLowerCase()!==e.tag.toLowerCase())t=null;if(!t&&e.dom_path?.length){let n=e.selector.match(/data-dc-screen="([^"]+)"/)?.[1];t=fr(document,{artboardId:n,tag:e.tag,classes:e.classes,dom_path:e.dom_path})}return t}function Nn(e){let t=Dl(e);if(!t?.isConnected)return null;let n=t.getBoundingClientRect();if(n.width===0&&n.height===0)return null;return{x:n.left,y:n.top,w:n.width,h:n.height}}function Hr(e,t,n=Ho()){let r=typeof window<"u"?window.innerWidth:e.x+t.w,s=typeof window<"u"?window.innerHeight:e.y+t.h,i=mo(r,s,n),c=i.x+8,p=i.y+8,f=i.x+i.w,y=i.y+i.h,g=e.x;if(g+t.w+8>f){let A=e.x-t.w;g=A>=c?A:Math.max(c,f-t.w-8)}if(g<c)g=c;let w=e.y;if(w+t.h+8>y){let A=e.y-t.h;w=A>=p?A:Math.max(p,y-t.h-8)}if(w<p)w=p;return{x:g,y:w}}function Fr(){Nl();let e=Tr(),[t,n]=se([]),[o,r]=se(null),[s,i]=se(0),[c,p]=se(null),f=qe(()=>Hn(),[]),[y,g]=se(!1),[w,A]=se(null),m=ae((k)=>{n((E)=>E.some((_)=>_.id===k.id)?E.map((_)=>_.id===k.id?k:_):[...E,k])},[]);de(()=>{if(typeof document>"u")return;let k=document.getElementById("dgn-pin-layer");if(!k)return;let E=k.style.display;return k.style.display="none",()=>{k.style.display=E}},[]);let h=ae((k)=>{if(!e)return;if(!k?.selector){e.clear();return}let E=k.selector.match(/data-cd-id="([^"]+)"/),_=E?E[1]:void 0,M,K;try{let W=document.querySelector(k.selector);if(W)M=W.tagName.toLowerCase(),K=(W.getAttribute("class")??"").split(/\s+/).filter((B)=>B&&!B.startsWith("dgn-")&&!B.startsWith("dc-cv-")).join(" ")}catch{}e.replace({file:f??void 0,id:_,selector:k.selector,tag:M,classes:K,bounds:k.bounds??void 0})},[e,f]),S=me(t),b=me(new Set);S.current=t;let a=vr(),x=Bl();de(()=>{if(!a)return;let k=a.doc.getArray("comments"),E=()=>{n(Xo(k.toArray(),b.current))};if(k.length>0)E();return k.observe(E),()=>{try{k.unobserve(E)}catch{}}},[a]),de(()=>{if(typeof window>"u")return;let k=(E)=>{let _=E.data;if(!_||typeof _!=="object"||!_.dgn)return;if(_.dgn==="comments-set"&&Array.isArray(_.comments))b.current=Bo(_.comments),n(_.comments);else if(_.dgn==="comment-focus"){let M=typeof _.id==="string"?_.id:null;if(r(M),M&&_.reply===!0)i((W)=>W+1);else i(0);let K=M?S.current.find((W)=>W.id===M):void 0;h(K)}};return window.addEventListener("message",k),()=>window.removeEventListener("message",k)},[h]),de(()=>{if(typeof document>"u")return;let k=(E)=>{let _=E.detail;if(!_?.selection)return;let M=typeof _.clientX==="number"?_.clientX:0,K=typeof _.clientY==="number"?_.clientY:0;p({selection:_.selection,clientX:M,clientY:K,anchors:Ll(_.selection.artboardId,M,K)})};return document.addEventListener("cm:open-composer",k),()=>document.removeEventListener("cm:open-composer",k)},[]);let R=ae(()=>{if(p(null),typeof window>"u")return;try{window.parent.postMessage({dgn:"force-clear"},"*")}catch{}},[]),j=ae((k)=>{if(!c)return;let E=c.selection,_={file:E.file,selector:E.selector,index:E.index,dom_path:E.dom_path,tag:E.tag,classes:E.classes,bounds:E.bounds,html_excerpt:E.html,...E.annotationId?{annotationId:E.annotationId}:{},...E.world?{world:E.world}:{},text:k};if(typeof window>"u")return;g(!0),(async()=>{let M=await Qe({op:"add",..._,...c.anchors});if(g(!1),M===null){try{window.parent.postMessage({dgn:"comment-submit",payload:_},"*")}catch{}R();return}if(!M.ok){A(M.error??"That did not go through.");return}if(A(null),M.comment)m(M.comment);R()})()},[c,R,m]);de(()=>{if(!f)return;let k=!1;return(async()=>{try{let E=await fetch(`/_comments?file=${encodeURIComponent(f)}`);if(!E.ok){await E.body?.cancel().catch(()=>{});return}let _=await E.json();if(k)return;if(Array.isArray(_.comments))n((M)=>M.length===0?_.comments??[]:M)}catch{}})(),()=>{k=!0}},[f]);let T=qe(()=>[...new Set(t.filter((k)=>typeof k.t==="number"&&k.artboard).map((k)=>k.artboard))],[t]),[P,z]=se({});de(()=>{if(T.length===0)return;let k=()=>{let _={};for(let M of T){let K=Vr(M);_[M]=K===null?null:Math.round(K*4)/4}z((M)=>T.every((K)=>M[K]===_[K])?M:_)};k();let E=setInterval(k,125);return()=>clearInterval(E)},[T]);let L=qe(()=>t.slice().sort((E,_)=>E.created.localeCompare(_.created)).filter((E)=>E.status!=="resolved"&&(typeof E.t!=="number"||!E.artboard||E.id===o||Zo(E.t,P[E.artboard]??null))),[t,P,o]),V=qe(()=>{let k=new Map;return t.slice().sort((_,M)=>_.created.localeCompare(M.created)).forEach((_,M)=>{k.set(_.id,M+1)}),k},[t]),Q=ae((k)=>{if(r(k),h(t.find((E)=>E.id===k)),typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-click",id:k},"*")}catch{}},[t,h]),ee=ae((k,E)=>{if(typeof window>"u")return;let _=()=>{try{window.parent.postMessage({dgn:"comment-patch",id:k,patch:E},"*")}catch{}},M=E.status==="resolved"?{op:"resolve",id:k}:E.status==="open"?{op:"reopen",id:k}:typeof E.text==="string"?{op:"edit-own",id:k,text:E.text}:null;if(!M)return _();Qe(M).then((K)=>{if(K===null)return _();if(!K.ok)return A(K.error??"That did not go through.");if(A(null),K.comment)m(K.comment)})},[m]),oe=ae((k)=>{if(typeof window>"u")return;r((E)=>E===k?null:E),Qe({op:"delete-own",id:k}).then((E)=>{if(E===null){try{window.parent.postMessage({dgn:"comment-delete",id:k},"*")}catch{}return}if(!E.ok)return A(E.error??"That did not go through.");A(null),n((_)=>_.filter((M)=>M.id!==k))})},[]),te=ae(async(k,E)=>{if(typeof fetch>"u")return!1;let _=await Qe({op:"reply",id:k,body:E});if(_){if(!_.ok)return A(_.error??"That did not go through."),!1;if(A(null),_.comment)m(_.comment);return!0}try{let M=await fetch(`/_api/comments/${encodeURIComponent(k)}/reply`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({body:E})});if(!M.ok)return!1;let K=await M.json();return n((W)=>W.map((B)=>B.id===K.id?K:B)),!0}catch{return!1}},[m]);return X("div",{className:"cm-layer","aria-hidden":!1,children:[L.map((k)=>{let E=V.get(k.id)??0;return C(ql,{comment:k,sequence:E,focused:o===k.id,viewer:x??a?.myName,onClick:Q},k.id)}),c?C(jl,{state:c,busy:y,onSubmit:j,onCancel:R}):null,w?X("div",{className:"cm-notice",role:"status","data-testid":"comment-notice",children:[C("span",{children:w}),C("button",{type:"button",className:"cm-notice__x","aria-label":"Dismiss",onClick:()=>A(null),children:"×"})]}):null,(()=>{if(!o)return null;let k=L.find((E)=>E.id===o);if(!k)return null;return C(Xl,{comment:k,sequence:V.get(k.id)??0,onClose:()=>{r(null),e?.clear()},onPatch:(E)=>ee(k.id,E),onDelete:()=>oe(k.id),onReply:(E)=>te(k.id,E),focusReply:s,mine:(!Pe()||Be())&&(k.mine===!0||!!(x??a?.myName)&&(k.author??"").trim()===(x??a?.myName??"").trim()),me:(x??a?.myName)||void 0})})()]})}var Ln=null,Rr=0,Kl=60000;async function zl(){try{let e=await fetch("/_api/git-committers");if(!e.ok)return[];let t=await e.json();return Qo(t.committers)}catch{return[]}}function Vl(){if(!(Ln&&Date.now()-Rr<Kl))Rr=Date.now(),Ln=(async()=>await Il()??await zl())();return Ln}function Ar(e){return Uo(e)}function Hl(e,t){if(t<=0||t>e.length)return null;let n=t-1;while(n>=0){let o=e[n]??"";if(o==="@"){let r=n>0?e[n-1]:"";if(n===0||/\s/.test(r??"")){let s=e.slice(n+1,t);return{start:n,end:t,query:s}}return null}if(!/[\w.-]/.test(o))return null;n-=1}return null}function $r(e,t){de(()=>{let n=e.current;if(!n)return;n.style.height="auto",n.style.height=`${Math.min(n.scrollHeight,160)}px`},[e,t])}function Dn({className:e,value:t,onChange:n,onKeyDown:o,placeholder:r,rows:s,disabled:i,textareaRef:c,ariaLabel:p,title:f}){let y=me(null),g=ae((L)=>{if(y.current=L,c)c.current=L},[c]),[w,A]=se([]),[m,h]=se(null),[S,b]=se(0),a=ae(()=>{if(w.length>0)return;Vl().then((L)=>A(L))},[w.length]),x=qe(()=>{if(!m)return[];let L=m.query.toLowerCase();return(!L?w:w.filter((Q)=>Q.name.toLowerCase().includes(L))).slice(0,8)},[m,w]),R=ae((L)=>{let V=L.selectionStart??L.value.length,Q=Hl(L.value,V);h(Q),b(0)},[]),j=ae((L)=>{n(L.target.value),R(L.target)},[n,R]),T=ae((L)=>{if(!m)return;let V=y.current;if(!V)return;let Q=`@${Ar(L.name)}`,ee=`${t.slice(0,m.start)}${Q} ${t.slice(m.end)}`;n(ee),h(null);let oe=m.start+Q.length+1;re(()=>{V.focus(),V.setSelectionRange(oe,oe)})},[m,t,n]),P=ae((L)=>{if(m&&x.length>0){if(L.key==="ArrowDown"){L.preventDefault(),b((V)=>(V+1)%x.length);return}if(L.key==="ArrowUp"){L.preventDefault(),b((V)=>(V-1+x.length)%x.length);return}if(L.key==="Enter"||L.key==="Tab"){L.preventDefault();let V=x[S]??x[0];if(V)T(V);return}if(L.key==="Escape"){L.preventDefault(),h(null);return}}o?.(L)},[m,x,S,T,o]),z=ae((L)=>{R(L.currentTarget)},[R]);return X("div",{style:{position:"relative"},children:[C("textarea",{ref:g,className:e,value:t,placeholder:r,rows:s,disabled:i,"aria-label":p,title:f,onChange:j,onKeyDown:P,onFocus:a,onSelect:z,onClick:z}),m&&x.length>0?C("ul",{className:"cm-mention-popup",role:"listbox","aria-label":"Mention suggestions",style:{left:0,top:"100%"},children:x.map((L,V)=>X("li",{role:"option","aria-selected":V===S,className:"cm-mention-popup__item",onMouseEnter:()=>b(V),onMouseDown:(ee)=>{ee.preventDefault(),T(L)},children:[C(Kn,{name:L.name}),X("span",{className:"cm-mention-popup__name",children:["@",Ar(L.name)]}),L.role?C("span",{className:"cm-mention-popup__role",children:L.role}):null]},L.id))}):null]})}var Fl=3000;function $l(e){return{x:e.x-12,y:e.y-12,w:24,h:24}}function qr(e){let t=!!e.selector||rt(e.annotationId);if(t){let r=Nn(e);if(r)return{pos:r,missing:!1}}let n=Lo(e.world)?Do(e.world):null;return{pos:n?$l(n):e.bounds??null,missing:t}}function ql({comment:e,sequence:t,focused:n,viewer:o,onClick:r}){let s=me(null),i=me(null),c=me(null),[p,f]=se(!1),y=me(!1);de(()=>{let m=()=>{i.current=null;let h=s.current;if(!h)return;let{pos:S,missing:b}=qr(e),a=!1;if(b){if(c.current==null)c.current=Date.now();a=Date.now()-c.current>Fl}else c.current=null;if(a!==y.current)y.current=a,f(a);if(!S){h.style.display="none",i.current=re(m);return}h.style.display="grid";let x=Math.round(S.x+S.w-14),R=Math.round(S.y-14);h.style.left=`${x}px`,h.style.top=`${R}px`,i.current=re(m)};return i.current=re(m),()=>{if(i.current!=null)ve(i.current)}},[e]);let g=it(e.author,Xe(e,o)),w=1+(e.thread?.length??0),A=`Comment ${t} by ${g.name}${w>1?`, ${w} messages`:""}${p?" (detached: its target is gone)":""}`;return X("button",{ref:s,type:"button",className:"cm-pin","data-resolved":e.status==="resolved"?"true":"false","data-focused":n?"true":"false","data-detached":p?"true":"false","data-comment-pin":e.id,"aria-label":A,"aria-expanded":n,title:e.text.slice(0,200),"data-seq":t,style:{["--cm-pin-tone"]:gn(g.tone)},onClick:(m)=>{m.preventDefault(),m.stopPropagation(),r(e.id)},children:[g.letter,w>1?C("span",{className:"cm-pin__n","data-testid":`comment-pin-count-${e.id}`,"aria-hidden":"true",children:w}):null]})}function jl({state:e,busy:t=!1,paused:n=un(),onSubmit:o,onCancel:r}){let[s,i]=se(""),c=me(null);$r(c,s);let p=me(null),f=me(null);de(()=>{let m=()=>{f.current=null;let h=p.current;if(!h)return;let S=Jl(e),b=Hr(S,{w:h.offsetWidth,h:h.offsetHeight});h.style.left=`${Math.round(b.x)}px`,h.style.top=`${Math.round(b.y)}px`,f.current=re(m)};return f.current=re(m),()=>{if(f.current!=null)ve(f.current)}},[e]),de(()=>{c.current?.focus()},[]);let y=ae(()=>{let m=s.trim();if(!m||t||n)return;o(m)},[s,t,n,o]),g=ae((m)=>{if(m.key==="Escape"){m.preventDefault(),r();return}if((m.metaKey||m.ctrlKey)&&m.key==="Enter")m.preventDefault(),y()},[r,y]),w=qe(()=>jr({artboard:e.anchors?.artboard,selector:e.selection.selector}),[e.anchors,e.selection]),A=qe(()=>{let m=e.anchors;if(!m?.artboard)return null;return xn(m,vn(Vn(m.artboard))).chip},[e.anchors]);return X("div",{ref:p,className:"cm-composer",role:"dialog","aria-label":"New comment",onClick:(m)=>m.stopPropagation(),onPointerDown:(m)=>m.stopPropagation(),children:[X("div",{className:"cm-composer__head",children:[C("span",{className:"cm-composer__where","data-testid":A?"comment-composer-place":"comment-composer-where",children:w}),C("button",{type:"button",className:"cm-thread__close","data-testid":"comment-composer-cancel","aria-label":"Cancel",title:"Cancel · esc",onClick:r,children:"×"})]}),A?C("span",{className:"cm-chip cm-composer__chip","data-testid":"comment-composer-where",children:A}):null,n?C("p",{className:"cm-composer__paused",role:"status","data-testid":"comment-composer-paused",children:st}):null,X("div",{className:"cm-composer__field",children:[C(Dn,{textareaRef:c,className:"cm-composer__textarea",value:s,placeholder:"Add a comment — @ mentions someone",onChange:i,onKeyDown:g,rows:1,ariaLabel:"Comment body",disabled:n,title:n?st:void 0}),C("button",{type:"button",className:"cm-btn cm-btn--primary cm-composer__send","data-testid":"comment-composer-send","aria-label":"Send",title:n?st:"Send · ⌘↵",disabled:!s.trim()||t||n,onClick:y,children:C("svg",{width:"14",height:"14",viewBox:"0 0 16 16","aria-hidden":"true",children:C("path",{d:"M6 3.5 10.5 8 6 12.5",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]})}function Ul(e){if(e.artboard)return Mr(e.artboard);let t=null;try{t=e.selector&&typeof document<"u"?document.querySelector(e.selector):null}catch{t=null}let n=t?.closest?.("[data-dc-screen]")?.getAttribute("data-dc-screen");if(n)return Mr(n);let o=t?.getAttribute?.("data-dc-element");if(o)return o.replace(/[-_]+/g," ");return"On the canvas"}function Wl(e=Hn()){let t=(e??"").split("/").pop()??"";if(!/\.[a-z0-9]+$/i.test(t))return"";return t.replace(/\.[a-z0-9]+$/i,"").replace(/[-_]+/g," ").trim()}function jr(e,t=Hn()){let n=Ul(e),o=Wl(t);if(!o)return n;return n==="On the canvas"?o:`${o} · ${n}`}var Cr=null;function Bl(){let[e,t]=se(null);return de(()=>{if(typeof fetch>"u")return;Cr??=fetch("/_api/git-user").then((o)=>o.ok?o.json():null).then((o)=>typeof o?.name==="string"&&o.name.trim()?o.name.trim():null).catch(()=>null);let n=!0;return Cr.then((o)=>n&&t(o)),()=>{n=!1}},[]),e}function Xl({comment:e,sequence:t,onClose:n,onPatch:o,onDelete:r,onReply:s,focusReply:i=0,mine:c=!1,me:p}){let f=me(null),y=me(null),g=me(null),[w,A]=se("");$r(y,w);let[m,h]=se(!1),[S,b]=se(null),a=ae(()=>{let D=(S??"").trim();if(!D)return;if(D!==e.text)o({text:D});b(null)},[S,e.text,o]);de(()=>{let D=()=>{g.current=null;let Z=f.current;if(!Z)return;let Ie=Zl(e),ft=Hr(Ie,{w:Z.offsetWidth,h:Z.offsetHeight});Z.style.left=`${Math.round(ft.x)}px`,Z.style.top=`${Math.round(ft.y)}px`,g.current=re(D)};return g.current=re(D),()=>{if(g.current!=null)ve(g.current)}},[e]),de(()=>{f.current?.focus();let D=e.id;return()=>{document.querySelector(`[data-comment-pin="${D}"]`)?.focus()}},[e.id]),de(()=>{if(i>0)y.current?.focus()},[i,e.id]),de(()=>{if(typeof document>"u")return;let D=(Z)=>{if(Z.key!=="Escape")return;let Ie=f.current;if(!Ie)return;if(Ie.contains(Z.target)||document.activeElement===Ie)Z.preventDefault(),n()};return document.addEventListener("keydown",D),()=>document.removeEventListener("keydown",D)},[n]);let x=ae(async()=>{let D=w.trim();if(!D||m)return;h(!0);let Z=await s(D);if(h(!1),Z)A(""),y.current?.focus()},[w,m,s]),R=ae((D)=>{if((D.metaKey||D.ctrlKey)&&D.key==="Enter")D.preventDefault(),x()},[x]),j=`cm-thread-head-${e.id}`,T=un(),P=(!Pe()||Be())&&!T,z=xn(e,e.artboard?vn(Vn(e.artboard)):null),L=jr({artboard:e.artboard,selector:e.selector}),V=e.from,Q=hn(e.importedFrom),ee=(p??"").trim(),oe=V?ee?(V.convertedBy??"").trim()===ee:c:!1,te=V?(e.thread??[]).find((D)=>(D.author??"").trim()!==(ee||(V.convertedBy??"").trim())):void 0,k=te?`${Ir(te.author??"")||"Someone"} replied — resolve the thread instead.`:null,E=!!V&&!Pe(),[_,M]=se(!1),K=!!V,[W,B]=se(!1);de(()=>{if(W)y.current?.focus()},[W]);let[G,Re]=se(null),[Ae,Ce]=se(!1);de(()=>{if(!V||!oe){Ce(!1);return}let D=!0;return Qe({op:"convert-undoable",commentId:e.id}).then((Z)=>{if(D)Ce(!!Z?.ok)}),()=>{D=!1}},[e.id,V,oe]);let De=async(D)=>{M(!1),Re(null);let Z=await Qe({op:D,commentId:e.id});if(Z?.ok)n();else Re(Z?.error||"That did not go through.")};return X("div",{ref:f,className:"cm-thread","data-seq":t,role:"dialog","data-esc-owner":"focus","aria-labelledby":j,tabIndex:-1,onClick:(D)=>D.stopPropagation(),onPointerDown:(D)=>D.stopPropagation(),children:[X("div",{className:"cm-thread__head",id:j,children:[K?null:X("div",{className:"cm-thread__head-row",children:[C("span",{className:"cm-thread__where","data-testid":`comment-where-${e.id}`,children:L}),X("span",{className:"cm-thread__head-end",children:[P?X("span",{className:"cm-thread__actions",children:[c&&S===null&&!Q?C("button",{type:"button",className:"cm-btn","data-testid":"comment-edit",onClick:()=>b(e.text),children:"Edit"}):null,e.status==="resolved"?X("button",{type:"button",className:"cm-btn cm-btn--ghost","data-testid":`comment-reopen-${e.id}`,onClick:()=>o({status:"open"}),children:[C(Ge,{d:"M3.5 8a4.5 4.5 0 1 0 1.4-3.3M3.5 2.5v2.6h2.6"}),"Reopen"]}):X("button",{type:"button",className:"cm-btn cm-btn--ghost","data-testid":`comment-resolve-${e.id}`,onClick:()=>{o({status:"resolved"}),n()},children:[C(Ge,{d:"M3 8.4 6.4 11.8 13 4.6"}),"Resolve"]}),c?C(Gl,{id:e.id,onConfirm:()=>{r(),n()}}):null]}):null,C("button",{type:"button",className:"cm-thread__close","aria-label":"Close thread",title:"Close · esc",onClick:n,children:"×"})]})]}),!K&&z.chip?z.kind==="video"&&typeof e.t==="number"&&e.artboard?C("button",{type:"button",className:"cm-chip cm-chip--seek","data-testid":`comment-chip-${e.id}`,title:"Go to this moment",onClick:()=>_l(e.artboard,e.t),children:z.chip}):C("span",{className:"cm-chip","data-testid":`comment-chip-${e.id}`,children:z.chip}):null,e.from?X("div",{className:"cm-thread__from","data-testid":`comment-from-${e.id}`,children:[C("svg",{width:"14",height:"14",viewBox:"0 0 16 16","aria-hidden":"true",className:"cm-thread__from-ic",children:C("path",{d:"M3 2.5h10v8l-3 3H3zM10 13.5v-3h3",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinejoin:"round"})}),X("span",{children:[qo(e.from)," · turned into a comment by"," ",oe?"You":Ir(e.from.convertedBy||e.author||""),oe&&Ae&&!k?X(ec,{children:[" · ",C("button",{type:"button",className:"cm-link","data-testid":`comment-from-undo-${e.id}`,onClick:()=>void De("convert-undo"),children:"Undo"})]}):null]})]}):null,G?C("div",{className:"cm-thread__convert-line",role:"alert",children:G}):null]}),S===null?X("div",{className:"cm-msg cm-msg--root",children:[Q?C(Pr,{}):C(Kn,{name:e.from?at(e.from).name:e.author,ai:e.from?at(e.from).ai:e.authorKind==="ai",viewer:e.from?p:Xe(e,p)}),X("div",{className:"cm-msg__main",children:[X("div",{className:"cm-msg__head",children:[C("span",{className:"cm-thread__author","data-testid":Q?`comment-imported-${e.id}`:void 0,children:Q?bn(Q):e.from?at(e.from).name:it(e.author,Xe(e,p)).name}),C("span",{className:"cm-thread__time",children:Or(Q?.at??e.created)})]}),C("div",{className:"cm-thread__body",children:Q?e.text:Lr(e.text)}),e.queued?C(_r,{id:e.id}):null]})]}):X("div",{className:"cm-thread__reply-form",children:[C(Dn,{className:"cm-thread__reply-textarea",value:S,placeholder:"Edit your comment… ⌘↵ to save",onChange:b,onKeyDown:(D)=>{if((D.metaKey||D.ctrlKey)&&D.key==="Enter")D.preventDefault(),a()},rows:3,ariaLabel:"Edit comment"}),X("div",{className:"cm-thread__reply-actions",children:[C("button",{type:"button",className:"cm-btn",onClick:()=>b(null),children:"Cancel"}),C("button",{type:"button",className:"cm-btn cm-btn--primary","data-testid":"comment-edit-save",disabled:!S.trim(),onClick:a,children:"Save"})]})]}),(e.thread??[]).map((D)=>{let Z=hn(D.importedFrom);return X("div",{className:"cm-msg cm-thread__reply",children:[Z?C(Pr,{}):C(Kn,{name:D.author,ai:D.authorKind==="ai",viewer:Xe(D,p)}),X("div",{className:"cm-msg__main",children:[X("div",{className:"cm-thread__reply-head",children:[C("span",{className:"cm-thread__reply-author",children:Z?bn(Z):it(D.author,Xe(D,p)).name}),C("span",{className:"cm-thread__reply-time",children:Or(Z?.at??D.created)})]}),C("div",{className:"cm-thread__reply-body",children:Z?D.body:Lr(D.body)}),D.queued?C(_r,{id:D.id}):null]})]},D.id)}),K&&P?X("div",{className:"cm-thread__foot","data-testid":`comment-foot-${e.id}`,children:[e.status==="resolved"?X("button",{type:"button",className:"cm-btn cm-btn--ghost","data-testid":`comment-reopen-${e.id}`,onClick:()=>o({status:"open"}),children:[C(Ge,{d:"M3.5 8a4.5 4.5 0 1 0 1.4-3.3M3.5 2.5v2.6h2.6"}),"Reopen"]}):X("button",{type:"button",className:"cm-btn cm-btn--ghost","data-testid":`comment-resolve-${e.id}`,onClick:()=>{o({status:"resolved"}),n()},children:[C(Ge,{d:"M3 8.4 6.4 11.8 13 4.6"}),"Resolve"]}),X("span",{className:"cm-thread__more",children:[C("button",{type:"button",className:"cm-btn cm-btn--icon","aria-label":"More","aria-haspopup":"menu","aria-expanded":_,"data-testid":`comment-menu-${e.id}`,onClick:()=>M((D)=>!D),children:"⋯"}),_?X("span",{className:"cm-thread__menu",role:"menu",children:[C("button",{type:"button",role:"menuitem",className:"cm-thread__menu-item","data-testid":`comment-menu-reply-${e.id}`,onClick:()=>{M(!1),B(!0)},children:"Reply…"}),c&&S===null&&!Q?C("button",{type:"button",role:"menuitem",className:"cm-thread__menu-item","data-testid":"comment-edit",onClick:()=>{M(!1),b(e.text)},children:"Edit"}):null,E?C("button",{type:"button",role:"menuitem",className:"cm-thread__menu-item","data-testid":`comment-menu-to-sticky-${e.id}`,disabled:!!k,onClick:()=>void De("to-sticky"),children:"Turn back into a sticky"}):null,c?C("button",{type:"button",role:"menuitem",className:"cm-thread__menu-item cm-thread__menu-item--danger","data-testid":`comment-delete-${e.id}`,onClick:()=>{r(),n()},children:"Delete comment"}):null,k?C("span",{className:"cm-thread__menu-note",children:k}):null]}):null]})]}):null,T&&Be()?C("p",{className:"cm-thread__paused",role:"status","data-testid":`comment-paused-${e.id}`,children:st}):null,P&&(!K||W||i>0)&&X("div",{className:"cm-thread__reply-form cm-thread__reply-form--field",children:[C(Dn,{textareaRef:y,className:"cm-thread__reply-textarea",value:w,placeholder:"Reply…",title:"⌘↵ to send · @name to tag",onChange:A,onKeyDown:R,rows:1,ariaLabel:"Reply",disabled:m}),C("div",{className:"cm-thread__reply-actions",children:C("button",{type:"button",className:"cm-btn cm-btn--primary cm-thread__send","aria-label":"Send",title:"Send · ⌘↵",disabled:!w.trim()||m,onClick:()=>void x(),children:C("svg",{width:"14",height:"14",viewBox:"0 0 16 16","aria-hidden":"true",children:C("path",{d:"M6 3.5 10.5 8 6 12.5",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})})})]})]})}function Ir(e){return e.trim().split(/\s+/)[0]||e}function Pr(){return C("span",{className:"cm-av cm-av--imported","aria-hidden":"true"})}var Yl="M3 4.5h10M6.5 4.5V3h3v1.5M4.5 4.5l.6 8.1a1 1 0 0 0 1 .9h3.8a1 1 0 0 0 1-.9l.6-8.1",Ql=4000;function Gl({id:e,onConfirm:t}){let[n,o]=se(!1);return de(()=>{if(!n)return;let r=setTimeout(()=>o(!1),Ql);return()=>clearTimeout(r)},[n]),C("button",{type:"button",className:`cm-btn cm-btn--ghost cm-btn--danger cm-btn--trash${n?" is-armed":""}`,"aria-label":n?"Confirm delete comment":"Delete comment",title:n?"Press again to delete":"Delete comment","data-testid":`comment-delete-${e}`,"data-armed":n?"true":void 0,onBlur:()=>o(!1),onKeyDown:(r)=>{if(r.key==="Escape"&&n)r.stopPropagation(),o(!1)},onClick:(r)=>{if(!n)return o(!0);if(r.detail>1)return;o(!1),t()},children:C(Ge,{d:Yl})})}function _r({id:e}){return X("span",{className:"cm-queued","data-testid":`comment-queued-${e}`,children:[C(Ge,{d:"M8 3.2v5l3 1.8M14 8A6 6 0 1 1 2 8a6 6 0 0 1 12 0Z"}),"Queued — sends when this Mac is online."]})}function Ge({d:e}){return C("svg",{width:"13",height:"13",viewBox:"0 0 16 16","aria-hidden":"true",className:"cm-glyph",children:C("path",{d:e,fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Kn({name:e,ai:t=!1,viewer:n}){let o=it(e,n);return C("span",{className:`cm-av${t?" cm-av--ai":""}`,style:t?void 0:{["--cm-av-tone"]:gn(o.tone)},"aria-hidden":"true",children:t?"AI":o.letter})}function Lr(e){if(!e)return null;let t=/(@[\w][\w.-]*)/g;return e.split(t).map((o,r)=>{let s=`${r}:${o}`;if(r%2===1)return C("strong",{"data-mention":"true",children:o},s);return C("span",{children:o},s)})}function Or(e){if(!e)return"";let t=Date.parse(e);if(!Number.isFinite(t))return"";let n=Math.round((Date.now()-t)/1000);if(n<60)return`${Math.max(n,0)}s ago`;if(n<3600)return`${Math.round(n/60)}m ago`;if(n<86400)return`${Math.round(n/3600)}h ago`;return`${Math.round(n/86400)}d ago`}function Zl(e){let{pos:t}=qr(e);if(t){if(e.from)return{x:t.x+t.w+8,y:t.y-28};return{x:t.x+t.w-12,y:t.y+16}}return{x:16,y:16}}function Jl(e){if(e.clientX||e.clientY){let t=e.selection.selector?Nn(e.selection):null,n=t&&t.h<=200?Math.max(e.clientY,t.y+t.h):e.clientY;return{x:e.clientX,y:n+8}}if(e.selection.selector){let t=Nn(e.selection);if(t)return{x:t.x,y:t.y+t.h+8}}return{x:16,y:16}}import{useEffect as pc}from"react";function Fn(e){return{role:e.readOnly?"comment":"owner",shell:"browser",mode:e.mode??"edit",focus:e.typing?"text":"canvas",selection:e.selection??"none",facts:new Set([...e.toolArmed?["toolArmed"]:[],...e.selectionHasTakes?["selectionHasTakes"]:[]]),...e.singleKeys===!1?{singleKeys:!1}:{}}}var Vt=["⌃","⌥","⇧","⌘"],Ht={Enter:"↵",Return:"↵","↩":"↵",Escape:"esc",Esc:"esc",esc:"esc"," ":"Space",Space:"Space",Spacebar:"Space",ArrowLeft:"←",ArrowRight:"→",ArrowUp:"↑",ArrowDown:"↓",Backspace:"⌫",Delete:"⌦",Del:"⌦",Tab:"tab",tab:"tab",Home:"Home",End:"End",PageUp:"PageUp",PageDown:"PageDown","-":"−","–":"−"},Ur=new Set(["↵","esc","Space","tab","⌫","⌦","←","→","↑","↓","Home","End","PageUp","PageDown"]),tc={cmd:"⌘",command:"⌘",meta:"⌘",ctrl:"⌃",control:"⌃",alt:"⌥",opt:"⌥",option:"⌥",shift:"⇧"};function nc(e){if(e===" ")return"Space";let t=String(e).trim();if(!t||/\b(click|hover|drag|scroll)\b/i.test(t))return null;let n=new Set;t=t.replace(/\b(cmd|command|meta|ctrl|control|alt|opt|option|shift)\s*\+\s*/gi,(r,s)=>(n.add(tc[s.toLowerCase()]),""));for(;;){t=t.replace(/^\s+/,"");let r=Vt.find((s)=>t.startsWith(s));if(!r||t.trim().length===r.length)break;n.add(r),t=t.slice(r.length)}let o=t.trim();if(Ht[o])o=Ht[o];else if(/^[a-z]$/i.test(o))o=o.toUpperCase();else if(/^f\d{1,2}$/i.test(o))o=o.toUpperCase();if(!o)return null;return Vt.filter((r)=>n.has(r)).join("")+o}function Wr(e){let t=nc(e);if(!t)throw Error(`actions/keys: '${e}' is not a key chord`);return t}var oc={Minus:"−",Equal:"=",Slash:"/",Backslash:"\\",BracketLeft:"[",BracketRight:"]",Comma:",",Period:".",Semicolon:";",Quote:"'",Backquote:"`",Space:"Space"};function $n(e){let t=new Set;if(e.metaKey||e.ctrlKey)t.add("⌘");if(e.altKey)t.add("⌥");let n=e.key??"";if(Ht[n])n=Ht[n];else if(/^F\d{1,2}$/.test(n));else if(/^[\x21-\x7e]$/.test(n)){if(/^[a-z]$/i.test(n))n=n.toUpperCase();else if(n==="/"&&e.shiftKey&&e.code==="Slash"&&!e.altKey)n="?"}else if(e.code){let s=/^Key([A-Z])$/.exec(e.code)??/^Digit(\d)$/.exec(e.code);n=s?s[1]:oc[e.code]??n}let o=e.shiftKey&&t.size===0?/^Digit(\d)$/.exec(e.code??""):null;if(o)n=o[1];let r=!!o||/^[A-Z]$/.test(n)||Ur.has(n)||/^F\d/.test(n);if(e.shiftKey&&r)t.add("⇧");return Vt.filter((s)=>t.has(s)).join("")+n}function Br(e){let{mods:t,key:n}=rc(e);if(t.some((o)=>o!=="⇧"))return!1;if(Ur.has(n)||/^F\d{1,2}$/.test(n))return!1;return n.length===1}function Xr(e){return e.includes("⌘")||e.includes("⌃")}function rc(e){let t=[],n=e;for(;;){let o=Vt.find((r)=>n.startsWith(r)&&n.length>r.length);if(!o)break;t.push(o),n=n.slice(o.length)}return{mods:t,key:n}}var Yr=new Set(["⌘Z","⇧⌘Z","⌘Y","⌘A","⌘C","⌘X","⌘V","⇧⌘V","⌥⇧⌘V","⌘B","⌘I","⌘U","⌘←","⌘→","⌘↑","⌘↓","⇧⌘←","⇧⌘→","⌥←","⌥→","⌘⌫","⌥⌫"].map(Wr)),Np=new Set(["⌘N","⇧⌘N","⌘T","⌘W","⌘Q","⌘L"].map(Wr));var qn={view:0,comment:1,edit:2,owner:3},Qr=["timeline","selection","tools","global"];function jn(e,t){if(!e)return!0;if(e.minRole&&qn[t.role]<qn[e.minRole])return!1;if(e.shell&&!e.shell.includes(t.shell))return!1;if(e.notShell?.includes(t.shell))return!1;if(e.mode&&!e.mode.includes(t.mode))return!1;if(e.focus&&!e.focus.includes(t.focus))return!1;if(e.selection&&!e.selection.includes(t.selection))return!1;if(e.facts&&!e.facts.every((n)=>t.facts.has(n)))return!1;if(e.notFacts?.some((n)=>t.facts.has(n)))return!1;if(e.any&&!e.any.some((n)=>jn(n,t)))return!1;return!0}function sc(e,t){return jn(e.visible,t)}function Gr(e,t=()=>!0){let n=new Map;for(let o of e)for(let r of o.keys??[]){if(!t(o,r))continue;let s=n.get(r.chord)??[];s.push({action:o,binding:r}),n.set(r.chord,s)}return n}function ic(e){return e.inText??(Xr(e.chord)&&!Yr.has(e.chord))}function ac(e,t){if(t.focus==="text"&&!ic(e.binding))return!1;if(t.focus==="modal"&&!e.binding.inModal)return!1;if(e.binding.layer==="timeline"&&t.focus!=="timeline")return!1;return sc(e.action,t)&&jn(e.binding.when,t)}function Un(e,t,n,o="tap"){if(n.singleKeys===!1&&Br(t))return null;let r=e.get(t);if(!r?.length)return null;let s=r.filter((i)=>o==="hold"===!!i.binding.hold&&ac(i,n));if(!s.length)return null;for(let i of Qr){let c=s.filter((p)=>p.binding.layer===i);if(c.length)return{action:c[0].action,binding:c[0].binding,ambiguous:c.slice(1)}}return null}function lc(e,t){let n=e.when?.focus;if(t==="shell")return e.layer==="timeline"||!n||n.some((o)=>o==="chrome"||o==="timeline"||o==="modal");return e.layer!=="timeline"&&(!n||n.includes("canvas"))}function Zr(e,t,n){return Gr(e,(o,r)=>n(o.id)&&lc(r,t))}var Ft=[{id:"search.open",exec:"shell",fromCanvas:!0,keys:[{chord:"⌘K",layer:"global",inText:!0,when:{notShell:["home"]}}]},{id:"canvas.new",exec:"shell",visible:{minRole:"edit"},keys:[{chord:"⌘N",layer:"global",inText:!0,when:{shell:["desktop"]}}]},{id:"canvas.reload",exec:"shell",fromCanvas:!0,keys:[{chord:"⌘R",layer:"global",inText:!0}]},{id:"edit.undo",exec:"canvas",enabled:{minRole:"edit"},keys:[{chord:"⌘Z",layer:"global",when:{focus:["canvas"]}}]},{id:"edit.redo",exec:"canvas",enabled:{minRole:"edit"},keys:[{chord:"⇧⌘Z",layer:"global",when:{focus:["canvas"]}},{chord:"⌘Y",layer:"global",alias:!0,when:{focus:["canvas"]}}]},{id:"select.all",exec:"canvas",visible:{minRole:"comment"},keys:[{chord:"⌘A",layer:"selection",when:{focus:["canvas"]}}]},{id:"select.all-annotations",exec:"canvas",visible:{minRole:"edit"},keys:[{chord:"⇧⌘A",layer:"global",inText:!1,when:{focus:["canvas"]}}]},{id:"object.duplicate",exec:"canvas",keys:[{chord:"⌘D",layer:"selection",when:{focus:["canvas"],selection:["object"]}}]},{id:"object.copy",exec:"canvas",enabled:{minRole:"edit",selection:["object"]},keys:[{chord:"⌘C",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["object"]}}]},{id:"object.cut",exec:"canvas",enabled:{minRole:"edit",selection:["object"]},keys:[{chord:"⌘X",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["object"]}}]},{id:"artboard.copy",exec:"canvas",enabled:{minRole:"edit",selection:["artboard"]},keys:[{chord:"⌘C",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["artboard"]}}]},{id:"edit.copy-properties",exec:"canvas",visible:{minRole:"comment"},keys:[{chord:"⌥⌘C",layer:"selection",when:{focus:["canvas"],selection:["object"]}},{chord:"⌥⇧⌘C",layer:"selection",when:{focus:["canvas"],selection:["object"]},alias:!0}]},{id:"edit.paste-properties",exec:"canvas",visible:{minRole:"comment"},enabled:{minRole:"edit"},keys:[{chord:"⌥⌘V",layer:"selection",when:{focus:["canvas"],selection:["object"]}},{chord:"⌥⇧⌘V",layer:"selection",when:{focus:["canvas"],selection:["object"]},alias:!0}]},{id:"object.enter",exec:"canvas",keys:[{chord:"↵",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["object"],notFacts:["toolArmed"]}}]},{id:"object.select-parent",exec:"canvas",keys:[{chord:"⇧↵",layer:"selection",when:{focus:["canvas"],selection:["object"]}}]},{id:"object.select-next",exec:"canvas",keys:[{chord:"tab",layer:"selection",when:{focus:["canvas"],mode:["edit"]}}]},{id:"object.select-prev",exec:"canvas",keys:[{chord:"⇧tab",layer:"selection",when:{focus:["canvas"],mode:["edit"]}}]},{id:"object.remove",exec:"canvas",keys:[{chord:"⌫",layer:"selection",when:{focus:["canvas"],selection:["object"]}},{chord:"⇧⌫",layer:"selection",when:{focus:["canvas"],selection:["object"]},alias:!0},{chord:"⌦",layer:"selection",when:{focus:["canvas"],selection:["object"]}},{chord:"⇧⌦",layer:"selection",when:{focus:["canvas"],selection:["object"]},alias:!0}]},{id:"object.nudge",exec:"canvas",keys:[{chord:"←",layer:"selection",when:{focus:["canvas"],selection:["object","artboard"],notFacts:["selectionHasTakes"]}},{chord:"⇧←",layer:"selection",when:{focus:["canvas"],selection:["object","artboard"]},alias:!0},{chord:"→",layer:"selection",when:{focus:["canvas"],selection:["object","artboard"],notFacts:["selectionHasTakes"]}},{chord:"⇧→",layer:"selection",when:{focus:["canvas"],selection:["object","artboard"]},alias:!0},{chord:"↑",layer:"selection",when:{focus:["canvas"],selection:["object","artboard"]}},{chord:"⇧↑",layer:"selection",when:{focus:["canvas"],selection:["object","artboard"]},alias:!0},{chord:"↓",layer:"selection",when:{focus:["canvas"],selection:["object","artboard"]}},{chord:"⇧↓",layer:"selection",when:{focus:["canvas"],selection:["object","artboard"]},alias:!0}]},{id:"object.frame",exec:"canvas",enabled:{minRole:"edit",selection:["object"]},keys:[{chord:"⌥⌘G",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["object"]}},{chord:"⌘G",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["object"]},alias:!0}]},{id:"object.unframe",exec:"canvas",enabled:{minRole:"edit",selection:["object"]},keys:[{chord:"⇧⌘G",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["object"]}}]},{id:"object.bring-front",exec:"canvas",enabled:{minRole:"edit",selection:["object"]},keys:[{chord:"⌘]",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["object"]}}]},{id:"object.bring-forward",exec:"canvas",enabled:{minRole:"edit",selection:["object"]},keys:[{chord:"]",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["object"]}}]},{id:"object.send-backward",exec:"canvas",enabled:{minRole:"edit",selection:["object"]},keys:[{chord:"[",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["object"]}}]},{id:"object.send-back",exec:"canvas",enabled:{minRole:"edit",selection:["object"]},keys:[{chord:"⌘[",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["object"]}}]},{id:"object.lock",exec:"canvas",enabled:{minRole:"edit",selection:["object"]},keys:[{chord:"⇧⌘L",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["object"]}}]},{id:"artboard.duplicate",exec:"canvas",enabled:{minRole:"edit",selection:["artboard"]},keys:[{chord:"⌘D",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["artboard"]}}]},{id:"artboard.trash",exec:"canvas",enabled:{minRole:"edit",selection:["artboard"]},keys:[{chord:"⌫",layer:"selection",when:{focus:["canvas"],selection:["artboard"]}},{chord:"⇧⌫",layer:"selection",when:{focus:["canvas"],selection:["artboard"]},alias:!0},{chord:"⌦",layer:"selection",when:{focus:["canvas"],selection:["artboard"]}},{chord:"⇧⌦",layer:"selection",when:{focus:["canvas"],selection:["artboard"]},alias:!0}]},{id:"ai.ask-selection",exec:"canvas",visible:{minRole:"edit"},enabled:{minRole:"edit",selection:["object"]},keys:[{chord:"⌘/",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["object"]}}]},{id:"inspect.edit",exec:"canvas",enabled:{minRole:"edit",mode:["preview","viewing"],selection:["object"]},keys:[{chord:"↵",layer:"selection",when:{focus:["canvas"],mode:["preview","viewing"],selection:["object"]}}]},{id:"mode.preview",exec:"canvas",enabled:{notFacts:["pagesView"]},keys:[{chord:"⌥⌘P",layer:"global",inText:!0,when:{mode:["edit","preview","viewing"]}}]},{id:"view.panels",exec:"shell",fromCanvas:!0,keys:[{chord:"⌘\\",layer:"global",inText:!0}]},{id:"view.comments",exec:"shell",fromCanvas:!0,keys:[{chord:"⇧⌘M",layer:"global",inText:!0}]},{id:"history.open",exec:"shell",fromCanvas:!0,keys:[{chord:"⌥⌘H",layer:"global",inText:!0}]},{id:"view.inspector",exec:"shell",fromCanvas:!0,keys:[{chord:"⇧⌘I",layer:"global",inText:!0}]},{id:"view.timeline-keep-open",exec:"shell",fromCanvas:!0,keys:[{chord:"⇧⌘T",layer:"global",inText:!0}]},{id:"view.annotations",exec:"canvas",keys:[{chord:"⇧P",layer:"global",inText:!1,when:{focus:["canvas"]}}]},{id:"present.from-selection",exec:"shell",enabled:{notFacts:["pagesView"]},fromCanvas:!0,keys:[{chord:"⌥⌘↵",layer:"global",when:{mode:["edit","viewing","preview"]}}]},{id:"present.from-start",exec:"shell",enabled:{notFacts:["pagesView"]},fromCanvas:!0,keys:[{chord:"⌥⇧⌘↵",layer:"global",when:{mode:["edit","viewing","preview"]}}]},{id:"present.next",exec:"shell",keys:[{chord:"→",layer:"global",when:{mode:["present"]}},{chord:"Space",layer:"global",when:{mode:["present"]}}]},{id:"present.prev",exec:"shell",keys:[{chord:"←",layer:"global",when:{mode:["present"]}},{chord:"⇧Space",layer:"global",when:{mode:["present"]}}]},{id:"view.zoom-in",exec:"canvas",keys:[{chord:"⌘=",layer:"global",inText:!0,when:{focus:["canvas","text"]}},{chord:"⌘+",layer:"global",inText:!0,alias:!0,when:{focus:["canvas","text"]}}]},{id:"view.zoom-out",exec:"canvas",keys:[{chord:"⌘−",layer:"global",inText:!0,when:{focus:["canvas","text"]}}]},{id:"view.zoom-fit",exec:"canvas",keys:[{chord:"⌘0",layer:"global",inText:!0,when:{focus:["canvas","text"]}}]},{id:"view.zoom-actual",exec:"canvas",keys:[{chord:"⇧0",layer:"global",inText:!1,when:{focus:["canvas","text"]}}]},{id:"view.jump-artboard",exec:"canvas",keys:[{chord:"⌥⌘1",layer:"global",inText:!0,alias:!1,when:{focus:["canvas","text"]}},{chord:"⌥⌘2",layer:"global",inText:!0,alias:!0,when:{focus:["canvas","text"]}},{chord:"⌥⌘3",layer:"global",inText:!0,alias:!0,when:{focus:["canvas","text"]}},{chord:"⌥⌘4",layer:"global",inText:!0,alias:!0,when:{focus:["canvas","text"]}},{chord:"⌥⌘5",layer:"global",inText:!0,alias:!0,when:{focus:["canvas","text"]}},{chord:"⌥⌘6",layer:"global",inText:!0,alias:!0,when:{focus:["canvas","text"]}},{chord:"⌥⌘7",layer:"global",inText:!0,alias:!0,when:{focus:["canvas","text"]}},{chord:"⌥⌘8",layer:"global",inText:!0,alias:!0,when:{focus:["canvas","text"]}},{chord:"⌥⌘9",layer:"global",inText:!0,alias:!0,when:{focus:["canvas","text"]}}]},{id:"pages.next",exec:"canvas",enabled:{facts:["canvasOpen","pagesView"]},keys:[{chord:"PageDown",layer:"global",when:{focus:["canvas"],mode:["edit","viewing"]}},{chord:"→",layer:"global",alias:!0,when:{focus:["canvas"],mode:["edit","viewing"],selection:["none"]}}]},{id:"pages.prev",exec:"canvas",enabled:{facts:["canvasOpen","pagesView"]},keys:[{chord:"PageUp",layer:"global",when:{focus:["canvas"],mode:["edit","viewing"]}},{chord:"←",layer:"global",alias:!0,when:{focus:["canvas"],mode:["edit","viewing"],selection:["none"]}}]},{id:"tool.select",exec:"canvas",keys:[{chord:"V",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit"]}}]},{id:"tool.hand",exec:"canvas",keys:[{chord:"H",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit","preview"]}}]},{id:"tool.frame",exec:"canvas",keys:[{chord:"F",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit","preview","viewing"]}}]},{id:"tool.el-shape",exec:"canvas",keys:[{chord:"R",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit"]}}]},{id:"tool.el-pen",exec:"canvas",keys:[{chord:"P",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit","preview","viewing"]}}]},{id:"tool.el-text",exec:"canvas",keys:[{chord:"T",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit"]}}]},{id:"tool.image",exec:"canvas",keys:[{chord:"I",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit","preview","viewing"]}}]},{id:"tool.components",exec:"canvas",keys:[{chord:"⇧I",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit","preview","viewing"]}}]},{id:"tool.browse",exec:"canvas",keys:[{chord:"V",layer:"tools",when:{focus:["canvas","chrome"],mode:["preview","viewing"]}}]},{id:"tool.sticky",exec:"canvas",keys:[{chord:"N",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit","preview","viewing"]}}]},{id:"tool.comment",exec:"canvas",keys:[{chord:"C",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit","preview","viewing"]}}]},{id:"tool.pen",exec:"canvas",keys:[{chord:"M",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit","preview","viewing"]}}]},{id:"tool.arrow",exec:"canvas",keys:[{chord:"A",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit","preview","viewing"]}}]},{id:"tool.shape",exec:"canvas",keys:[{chord:"R",layer:"tools",when:{focus:["canvas","chrome"],mode:["preview","viewing"]}}]},{id:"tool.text",exec:"canvas",keys:[{chord:"T",layer:"tools",when:{focus:["canvas","chrome"],mode:["preview","viewing"]}}]},{id:"tool.stickers",exec:"canvas",keys:[{chord:"E",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit","preview","viewing"]}}]},{id:"tool.section",exec:"canvas",keys:[{chord:"S",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit","preview","viewing"]}}]},{id:"tool.inspect",exec:"canvas",keys:[{chord:"H",layer:"tools",when:{focus:["canvas","chrome"],mode:["viewing"]}}]},{id:"tool.pointer",exec:"canvas",keys:[{chord:"L",layer:"tools",when:{focus:["canvas","chrome"],mode:["present"]}}]},{id:"tool.hand-hold",exec:"canvas",keys:[{chord:"Space",layer:"tools",hold:!0,when:{focus:["canvas"]}},{chord:"⌥Space",layer:"tools",hold:!0,when:{focus:["canvas"]},alias:!0},{chord:"⇧Space",layer:"tools",hold:!0,when:{focus:["canvas"]},alias:!0},{chord:"⌥⇧Space",layer:"tools",hold:!0,when:{focus:["canvas"]},alias:!0},{chord:"⌘Space",layer:"tools",hold:!0,when:{focus:["canvas"]},alias:!0},{chord:"⌥⌘Space",layer:"tools",hold:!0,when:{focus:["canvas"]},alias:!0},{chord:"⇧⌘Space",layer:"tools",hold:!0,when:{focus:["canvas"]},alias:!0},{chord:"⌥⇧⌘Space",layer:"tools",hold:!0,when:{focus:["canvas"]},alias:!0}]},{id:"tool.create-default",exec:"canvas",enabled:{minRole:"edit"},keys:[{chord:"↵",layer:"tools",when:{focus:["canvas"],mode:["edit","preview"],facts:["toolArmed"]}}]},{id:"ui.step-back",exec:"shell",keys:[{chord:"esc",layer:"selection",inText:!1,when:{focus:["canvas"]}},{chord:"⌥esc",layer:"selection",inText:!1,when:{focus:["canvas"]},alias:!0},{chord:"⇧esc",layer:"selection",inText:!1,when:{focus:["canvas"]},alias:!0},{chord:"⌥⇧esc",layer:"selection",inText:!1,when:{focus:["canvas"]},alias:!0},{chord:"⌘esc",layer:"selection",inText:!1,when:{focus:["canvas"]},alias:!0},{chord:"⌥⌘esc",layer:"selection",inText:!1,when:{focus:["canvas"]},alias:!0},{chord:"⇧⌘esc",layer:"selection",inText:!1,when:{focus:["canvas"]},alias:!0},{chord:"⌥⇧⌘esc",layer:"selection",inText:!1,when:{focus:["canvas"]},alias:!0}]},{id:"ui.cycle-region",exec:"shell",fromCanvas:!0,keys:[{chord:"F6",layer:"global",inText:!0},{chord:"⇧F6",layer:"global",inText:!0,alias:!0}]},{id:"timeline.split",exec:"shell",keys:[{chord:"⌘B",layer:"global",when:{facts:["timelineVisible"]},inText:!1,alias:!0}]},{id:"export.open",exec:"shell",visible:{minRole:"comment"},fromCanvas:!0,keys:[{chord:"⇧⌘E",layer:"global",inText:!0}]},{id:"export.copy-png",exec:"shell",visible:{minRole:"comment"},enabled:{facts:["canvasOpen"]},fromCanvas:!0,keys:[{chord:"⇧⌘C",layer:"selection",inText:!1,when:{selection:["artboard","object","video-artboard","generated-image"]}}]},{id:"handoff.open",exec:"shell",visible:{minRole:"comment"},enabled:{minRole:"edit",facts:["canvasOpen"]},fromCanvas:!0,keys:[{chord:"⇧⌘H",layer:"global",inText:!0}]},{id:"settings.open",exec:"shell",fromCanvas:!0,keys:[{chord:"⌘,",layer:"global",inText:!0,when:{focus:["chrome","timeline","text","canvas"]}}]},{id:"help.shortcuts",exec:"shell",fromCanvas:!0,keys:[{chord:"?",layer:"global",inText:!1,when:{focus:["chrome","timeline","canvas"],notFacts:["rangeFocused"]}},{chord:"⌘?",layer:"global",inText:!1,alias:!0,when:{focus:["chrome","timeline","canvas"],notFacts:["rangeFocused"]}}]},{id:"annotation.group",exec:"canvas",keys:[{chord:"⌘G",layer:"selection",when:{focus:["canvas"],selection:["annotation"],mode:["preview"]}}]},{id:"annotation.ungroup",exec:"canvas",keys:[{chord:"⇧⌘G",layer:"selection",when:{focus:["canvas"],selection:["annotation"],mode:["preview"]}}]},{id:"annotation.lock",exec:"canvas",keys:[{chord:"⇧⌘L",layer:"selection",when:{focus:["canvas"],selection:["annotation"],mode:["preview"]}}]},{id:"annotation.duplicate",exec:"canvas",keys:[{chord:"⌘D",layer:"selection",when:{focus:["canvas"],selection:["annotation"]}}]},{id:"annotation.to-front",exec:"canvas",keys:[{chord:"]",layer:"selection",when:{focus:["canvas"],selection:["annotation"],mode:["preview"]}}]},{id:"annotation.forward",exec:"canvas",keys:[{chord:"⌘]",layer:"selection",when:{focus:["canvas"],selection:["annotation"],mode:["preview"]}}]},{id:"annotation.to-back",exec:"canvas",keys:[{chord:"[",layer:"selection",when:{focus:["canvas"],selection:["annotation"],mode:["preview"]}}]},{id:"annotation.backward",exec:"canvas",keys:[{chord:"⌘[",layer:"selection",when:{focus:["canvas"],selection:["annotation"],mode:["preview"]}}]},{id:"annotation.copy",exec:"canvas",keys:[{chord:"⌘C",layer:"selection",when:{focus:["canvas"],selection:["annotation"]}}]},{id:"annotation.cut",exec:"canvas",keys:[{chord:"⌘X",layer:"selection",when:{focus:["canvas"],selection:["annotation"]}}]},{id:"annotation.chain",exec:"canvas",keys:[{chord:"⌘↵",layer:"selection",when:{focus:["canvas"],selection:["annotation"]}}]},{id:"annotation.edit-text",exec:"canvas",keys:[{chord:"↵",layer:"selection",when:{focus:["canvas"],selection:["annotation"]}}]},{id:"annotation.nudge",exec:"canvas",keys:[{chord:"←",layer:"selection",when:{focus:["canvas"],selection:["annotation"]}},{chord:"⇧←",layer:"selection",when:{focus:["canvas"],selection:["annotation"]},alias:!0},{chord:"→",layer:"selection",when:{focus:["canvas"],selection:["annotation"]}},{chord:"⇧→",layer:"selection",when:{focus:["canvas"],selection:["annotation"]},alias:!0},{chord:"↑",layer:"selection",when:{focus:["canvas"],selection:["annotation"]}},{chord:"⇧↑",layer:"selection",when:{focus:["canvas"],selection:["annotation"]},alias:!0},{chord:"↓",layer:"selection",when:{focus:["canvas"],selection:["annotation"]}},{chord:"⇧↓",layer:"selection",when:{focus:["canvas"],selection:["annotation"]},alias:!0}]},{id:"annotation.remove",exec:"canvas",keys:[{chord:"⌫",layer:"selection",when:{focus:["canvas"],selection:["annotation"]}},{chord:"⇧⌫",layer:"selection",when:{focus:["canvas"],selection:["annotation"]},alias:!0},{chord:"⌦",layer:"selection",when:{focus:["canvas"],selection:["annotation"]}},{chord:"⇧⌦",layer:"selection",when:{focus:["canvas"],selection:["annotation"]},alias:!0}]},{id:"annotation.ask-ai",exec:"canvas",enabled:{minRole:"edit",selection:["annotation"]},keys:[{chord:"⌘/",layer:"selection",when:{focus:["canvas"],selection:["annotation"],mode:["preview"]}}]},{id:"project.new",exec:"shell",visible:{minRole:"comment"},keys:[{chord:"⇧⌘N",layer:"global",inText:!0,when:{shell:["desktop"]}}]},{id:"project.open",exec:"native",visible:{minRole:"comment"},keys:[{chord:"⌘O",layer:"global",inText:!0,when:{shell:["desktop"]}}]},{id:"home.open",exec:"native",keys:[{chord:"⌘T",layer:"global",inText:!0,when:{shell:["desktop"]}}]},{id:"home.search",exec:"shell",visible:{shell:["home"]},keys:[{chord:"⌘K",layer:"global",inText:!0,when:{shell:["home"]}}]},{id:"tab.close",exec:"native",keys:[{chord:"⌘W",layer:"global",inText:!0,when:{shell:["desktop"]}}]},{id:"tab.next",exec:"native",keys:[{chord:"⌃tab",layer:"global",inText:!0,when:{shell:["desktop"]}},{chord:"⇧⌘]",layer:"global",inText:!0,alias:!0,when:{shell:["desktop"]}}]},{id:"tab.prev",exec:"native",keys:[{chord:"⌃⇧tab",layer:"global",inText:!0,when:{shell:["desktop"]}},{chord:"⇧⌘[",layer:"global",inText:!0,alias:!0,when:{shell:["desktop"]}}]},{id:"tab.overview",exec:"native",keys:[{chord:"⇧⌘\\",layer:"global",inText:!0,when:{shell:["desktop"]}}]},{id:"tab.select-1",exec:"native",keys:[{chord:"⌘1",layer:"global",inText:!0,when:{shell:["desktop"]}}]},{id:"tab.select-2",exec:"native",keys:[{chord:"⌘2",layer:"global",inText:!0,when:{shell:["desktop"]}}]},{id:"tab.select-3",exec:"native",keys:[{chord:"⌘3",layer:"global",inText:!0,when:{shell:["desktop"]}}]},{id:"tab.select-4",exec:"native",keys:[{chord:"⌘4",layer:"global",inText:!0,when:{shell:["desktop"]}}]},{id:"tab.select-5",exec:"native",keys:[{chord:"⌘5",layer:"global",inText:!0,when:{shell:["desktop"]}}]},{id:"tab.select-6",exec:"native",keys:[{chord:"⌘6",layer:"global",inText:!0,when:{shell:["desktop"]}}]},{id:"tab.select-7",exec:"native",keys:[{chord:"⌘7",layer:"global",inText:!0,when:{shell:["desktop"]}}]},{id:"tab.select-8",exec:"native",keys:[{chord:"⌘8",layer:"global",inText:!0,when:{shell:["desktop"]}}]},{id:"tab.select-last",exec:"native",keys:[{chord:"⌘9",layer:"global",inText:!0,when:{shell:["desktop"]}}]}];function Jr(e){let t=new Set(e);return Zr(Ft,"canvas",(n)=>t.has(n))}var Gp=Object.freeze({edit:["stroke","selection","tool"],preview:["stroke","tool","selection"],viewing:["stroke","tool","selection"],present:[]}),Zp=Object.freeze({edit:"stay",preview:"stay",viewing:"stay",present:"back"}),es="data-esc-owner";function ts(e){let t=e?.querySelectorAll?.(`[${es}]`);if(!t)return!1;for(let n of Array.from(t)){if(n.getAttribute(es)!=="focus")return!0;let o=e?.activeElement??null;if(o&&(n===o||n.contains(o)))return!0}return!1}var cc=["pen","highlighter","eraser"],dc=Symbol.for("maude.markerTip.v2"),uc=(e)=>typeof e==="string"&&cc.includes(e);function ns(){let e=globalThis[dc];return uc(e)?e:"pen"}function os(e){let t=(n)=>Number.isFinite(n)?Math.max(0,Math.round(n)):0;return{x:t(e.left),y:t(e.top),w:t(e.width),h:t(e.height)}}function Wn(e,t){let n=null;if(t){let o=os(t.getBoundingClientRect());n=o.w>0&&o.h>0?o:null}return{dgn:"tool-panel-open",panel:e,anchor:n}}var rs=!1,ss=!1;function Bn(e=globalThis.document){if(rs=!0,ss||!e)return;ss=!0,e.addEventListener("pointerdown",()=>{rs=!1},!0)}function is(e,t){try{if(typeof window>"u"||window.parent===window)return;Bn(),window.parent.postMessage(Wn(e,t),"*")}catch{}}function as(e,t){return t==="section"&&e!=="section"?"templates":null}var mc=new Set(["pen","highlighter","shape","rect","ellipse","arrow","sticky","text","el-text","frame","el-shape","line","polygon","slice","el-pen","section","eraser"]);function gs(e){return mc.has(e)}var hs={"ui.step-back":{kind:"escape"},"edit.undo":{kind:"undo"},"edit.redo":{kind:"redo"}},fc=Jr(Ft.filter((e)=>e.id.startsWith("tool.")&&e.id!=="tool.hand-hold"||e.id==="mode.preview").map((e)=>e.id).concat(Object.keys(hs))),gc=new Set([...Qt,"el-text","frame","el-shape","ellipse","line","polygon","slice","el-pen","crop","inspect"]),ls=(e)=>uo(e,(t)=>gc.has(t));function hc(e,t,n){let o=!!n.mode;if(!o&&e==="V")return{kind:"tool",tool:"move"};let r=po(t,e,n.caps??io,n.markerTip??"pen");if(!r)return{kind:"no-op"};if(r.kind==="insert")return{kind:"insert",insert:r.insert};if(r.kind==="panel")return{kind:"panel",panel:r.panel};if(r.kind==="arm"){let i=ls(r.tool);return i?{kind:"tool",tool:i}:{kind:"no-op"}}if(o){if(r.kind==="deny"&&r.panel)return{kind:"panel",panel:r.panel};let i={kind:"mode-request",mode:r.mode,cause:"key"};if(r.tool)i.tool=r.tool;if(r.kind==="request"&&r.panel)i.panel=r.panel;return i}if(r.kind==="request"&&r.panel)return{kind:"panel",panel:r.panel};let s=ls(r.tool??tt[r.mode].rest);return s?{kind:"tool",tool:s}:{kind:"no-op"}}function bc(e){let t=$n({key:e.key??"",code:e.code,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey}),n=e.mode??null,o=n??(e.activeTool==="browse"?"preview":"edit"),r=Un(fc,t,Fn({typing:!!e.isEditable,readOnly:!1,mode:o,singleKeys:e.singleKeys}));if(!r)return{kind:"no-op"};let s=r.action.id;if(s==="mode.preview"){if(n)return{kind:"mode-request",mode:n==="preview"?"back":"preview",cause:"key"};return{kind:"tool",tool:e.activeTool==="browse"?"move":"browse"}}if(s.startsWith("tool."))return hc(r.binding.chord,o,e);let i=hs[s];if(!i)return{kind:"no-op"};if(i.kind==="escape"&&n&&!pn()){if(en(n,e.activeTool)==="back")return{kind:"escape",back:!0};if(zo())return{kind:"escape",back:!0}}return{...i}}var dt=(e)=>!!(e.metaKey||e.ctrlKey);function cs(e){if(!gs(e.activeTool))return!1;return!e.mode||gt(e.mode,"annotations-editable")}function ut(e){if(e.type==="keydown")return bc(e);if(e.type==="contextmenu")return{kind:"context-menu",clientX:e.clientX??0,clientY:e.clientY??0};if(e.type==="pointermove"){if(cs(e))return{kind:"no-op"};if(e.activeTool==="hand")return{kind:"no-op"};if(e.activeTool==="browse"){if(!dt(e))return{kind:"no-op"};return{kind:"hover",deep:!0,clientX:e.clientX??0,clientY:e.clientY??0}}if(e.activeTool==="inspect")return{kind:"hover",deep:!0,clientX:e.clientX??0,clientY:e.clientY??0};if(e.activeTool==="comment")return{kind:"hover",deep:!0,clientX:e.clientX??0,clientY:e.clientY??0};return{kind:"hover",deep:dt(e),clientX:e.clientX??0,clientY:e.clientY??0}}if(e.type==="pointerdown"){if(e.button===2)return{kind:"context-menu",clientX:e.clientX??0,clientY:e.clientY??0};if(e.button===1||e.spaceHeld)return{kind:"no-op"};if(e.button!==0)return{kind:"no-op"};if(cs(e)&&!dt(e))return{kind:"no-op"};if(e.activeTool==="comment")return{kind:"drop-comment",clientX:e.clientX??0,clientY:e.clientY??0};if(e.activeTool==="hand")return{kind:"no-op"};if(e.activeTool==="inspect")return{kind:"select",mode:"replace",deep:!0,clientX:e.clientX??0,clientY:e.clientY??0};if(e.activeTool==="browse"){if(!dt(e)){if(e.previewLabel)return{kind:"select",mode:e.shiftKey?"add":"replace",deep:!1,clientX:e.clientX??0,clientY:e.clientY??0};return{kind:"no-op"}}return{kind:"select",mode:e.shiftKey?"add":"replace",deep:!0,clientX:e.clientX??0,clientY:e.clientY??0}}let t=dt(e);return{kind:"select",mode:!!e.shiftKey?"add":"replace",deep:t,clientX:e.clientX??0,clientY:e.clientY??0}}return{kind:"no-op"}}function $t(e){if(!e||!e.tagName)return!1;let t=e,n=t.tagName;if(n==="INPUT"||n==="TEXTAREA"||n==="SELECT")return!0;if(t.isContentEditable)return!0;let o=t.getAttribute?.("contenteditable");if(o==="true"||o==="plaintext-only"||o==="")return!0;return!1}function pt(e){if(!e||!e.closest)return!1;let t=e;if(t.closest(".dc-world"))return!1;return!!t.closest(".cm-composer, .cm-thread, .cm-mention-popup, .cm-pin, [data-mediaref-player], [data-vplay], .dc-tool-palette, .dc-zoom-tb, .dc-mm, .dc-context-menu")}function bs(e){if(!e||typeof e.closest!=="function")return!1;let t=e;return!!t.closest("[data-dc-screen]")&&!t.closest(".dc-artboard-body")}function ds(e,t){if(!t||!gt(t,"live-design")||!e||typeof e.closest!=="function")return!1;return!!e.closest("button.dc-artboard-label")}function us(e,t,n){return e.kind==="select"&&!n.metaKey&&!n.ctrlKey&&(bs(t)||yc(t,n.clientX,n.clientY))}function yc(e,t,n){if(!e||typeof e.closest!=="function")return!1;let o=e;if(!o.closest(".dc-artboard-body")||typeof t!=="number"||typeof n!=="number")return!1;let r=qt(o.ownerDocument,t,n,{deep:!1});return!!r&&r.cdId===null&&r.el.hasAttribute("data-dc-screen")}function wc(e,t,n){return e==="select"&&!n.metaKey&&!n.ctrlKey&&bs(t)}var vc="maude:toolbar-insert",xc=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,kc=/^[A-Za-z0-9_-]{1,64}$/;function Sc(e,t){if(!gt(t.mode,"live-design")||t.button!==0||t.mod||t.shift)return null;let n=e?.closest?.("[data-cd-link]"),o=n?.getAttribute("data-cd-id");if(!n||!o||o.length>48||!xc.test(o)||/^[0-9a-f]{8}$/.test(o))return null;let r=n.closest("[data-dc-screen]")?.getAttribute("data-dc-screen")??null;return{elementId:o,artboardId:r&&kc.test(r)?r:null}}var ps=new WeakSet;function Ec(e){if(typeof window>"u"||window.parent===window)return!1;let t=Sc(e.target,{mode:Se(window).get()?.mode??null,button:e.button,mod:e.metaKey||e.ctrlKey,shift:e.shiftKey});if(!t)return!1;if(e.preventDefault(),ps.has(e))return!0;ps.add(e);try{window.parent.postMessage({dgn:"link-follow",elementId:t.elementId,artboardId:t.artboardId},"*")}catch{}return!0}function ms(e){if(typeof window>"u"||window.parent===window)return;if(!Se(window).claimRequest(`${e.mode}|${e.tool??""}`))return;try{window.parent.postMessage(e.tool?{dgn:"mode-request",mode:e.mode,tool:e.tool,cause:e.cause}:{dgn:"mode-request",mode:e.mode,cause:e.cause},"*")}catch{}}function fs(e){if(typeof window>"u"||window.parent===window)return;try{let t=document.querySelector(`[data-testid="toolbar-slot-${e}"]`);Bn(),window.parent.postMessage(Wn(e,t),"*")}catch{}}function ys(e){let{hostRef:t,getActiveTool:n,isSpaceHeld:o,callbacks:r,enabled:s=!0,claimableActions:i}=e;pc(()=>{if(!s)return;let c=t.current;if(!c)return;let p=(a)=>i&&a.kind!=="no-op"&&!i.has(a.kind)?{kind:"no-op"}:a,f=(a)=>{switch(a.kind){case"hover":r.onHover?.(a);break;case"select":r.onSelect?.(a);break;case"drop-comment":r.onDropComment?.(a);break;case"context-menu":r.onContextMenu?.(a);break;case"tool":r.onTool?.(a);break;case"escape":{let x=r.onEscape?.();if(a.back&&x!==!0)ms({mode:"back",cause:"esc"});break}case"mode-request":if(ms(a),a.panel)fs(a.panel);break;case"insert":if(typeof document<"u")document.dispatchEvent(new CustomEvent(vc,{detail:{kind:a.insert}}));break;case"panel":fs(a.panel);break;case"undo":r.onUndo?.();break;case"redo":r.onRedo?.();break;case"no-op":break}},y=()=>typeof window<"u"?Se(window).get().mode:null,g=(a)=>{let x=p(ut({type:"pointermove",button:a.button,metaKey:a.metaKey,ctrlKey:a.ctrlKey,shiftKey:a.shiftKey,altKey:a.altKey,clientX:a.clientX,clientY:a.clientY,spaceHeld:o?.()??!1,activeTool:n()}));f(x)},w=(a)=>{if(pt(a.target))return;if($t(a.target))return;let x=p(ut({type:"pointerdown",button:a.button,metaKey:a.metaKey,ctrlKey:a.ctrlKey,shiftKey:a.shiftKey,altKey:a.altKey,clientX:a.clientX,clientY:a.clientY,spaceHeld:o?.()??!1,activeTool:n(),previewLabel:ds(a.target,y())})),R=us(x,a.target,a)||x.kind==="select"&&n()==="inspect";if(x.kind!=="no-op"){if(a.preventDefault(),!R)a.stopImmediatePropagation()}f(x)},A=(a)=>{if(pt(a.target))return;if($t(a.target))return;let x=p(ut({type:"pointerdown",button:a.button,metaKey:a.metaKey,ctrlKey:a.ctrlKey,shiftKey:a.shiftKey,altKey:a.altKey,clientX:a.clientX,clientY:a.clientY,spaceHeld:o?.()??!1,activeTool:n(),previewLabel:ds(a.target,y())})),R=us(x,a.target,a);if(x.kind!=="no-op"){if(a.preventDefault(),!R)a.stopImmediatePropagation();if(x.kind==="select")try{window.focus()}catch{}}},m=(a)=>{if(pt(a.target))return;if($t(a.target))return;if(Ec(a))return;let x=n(),R=a.metaKey||a.ctrlKey,j=x==="comment"?"drop-comment":(x==="move"||x==="inspect")&&a.button===0?"select":(gs(x)||x==="browse")&&R&&a.button===0?"select":a.button===2?"context-menu":null;if(j&&(!i||i.has(j))){let T=wc(j,a.target,a);if(a.preventDefault(),!T)a.stopImmediatePropagation()}},h=(a)=>{let x=p(ut({type:"contextmenu",clientX:a.clientX,clientY:a.clientY,metaKey:a.metaKey,ctrlKey:a.ctrlKey,shiftKey:a.shiftKey,altKey:a.altKey,activeTool:n()}));if(x.kind==="no-op")return;a.preventDefault(),a.stopImmediatePropagation(),f(x)},S=(a)=>{let x=typeof window<"u"?Se(window).get():null,R=p(ut({type:"keydown",key:a.key,code:a.code,metaKey:a.metaKey,ctrlKey:a.ctrlKey,shiftKey:a.shiftKey,altKey:a.altKey,isEditable:$t(a.target),activeTool:n(),mode:x?.mode??null,caps:x?.caps??null,markerTip:ns(),singleKeys:x?.singleKeys??!0}));if(R.kind==="escape"&&ts(c.ownerDocument??document))return;if(R.kind==="tool"||R.kind==="mode-request"||R.kind==="insert"||R.kind==="panel"||R.kind==="escape"&&!pn()||R.kind==="undo"||R.kind==="redo")a.preventDefault();f(R)};c.addEventListener("pointermove",g,{passive:!0}),c.addEventListener("pointerdown",w,{capture:!0}),c.addEventListener("mousedown",A,{capture:!0}),c.addEventListener("click",m,{capture:!0}),c.addEventListener("contextmenu",h,{capture:!0});let b=c.ownerDocument??document;return b.addEventListener("keydown",S,!0),()=>{c.removeEventListener("pointermove",g),c.removeEventListener("pointerdown",w,{capture:!0}),c.removeEventListener("mousedown",A,{capture:!0}),c.removeEventListener("click",m,{capture:!0}),c.removeEventListener("contextmenu",h,{capture:!0}),b.removeEventListener("keydown",S,!0)}},[s,t,n,o,r,i])}function Tc(e,t=(n)=>n.getBoundingClientRect()){let n=e.querySelector("[data-cd-id]");if(!n)return null;for(let s=n;s&&s!==e;s=s.parentElement)for(let i=s.nextElementSibling;i;i=i.nextElementSibling)if(i.hasAttribute("data-cd-id")||i.querySelector("[data-cd-id]"))return null;let o=t(e),r=t(n);if(!(o.width>0&&o.height>0))return null;if(r.width<o.width*0.98||r.height<o.height*0.98)return null;return n}function qt(e,t,n,o){let r=e.elementFromPoint(t,n);if(!r)return null;if(r.closest?.(".dc-mm, .dc-zoom-tb, .dc-tool-palette, .dc-context-menu, .dc-cv-group-bbox"))return null;let s=r.closest?.("[data-dc-screen]")??null,i=s?.getAttribute("data-dc-screen")??null,c=r.closest?.(".dc-artboard-body")??null;if(!c){if(s&&i)return{el:s,cdId:null,artboardId:i};return null}if(r===c){if(s&&i)return{el:s,cdId:null,artboardId:i};return null}if(o.deep){let A=r.getAttribute?.("data-cd-id")??null;return{el:r,cdId:A,artboardId:i}}let p=r,f=null,y=null;while(p&&p!==c){if(p.hasAttribute?.("data-cd-id"))y=f,f=p;p=p.parentElement}if(f&&Tc(c)===f){if(!y)return s&&i?{el:s,cdId:null,artboardId:i}:null;f=y}let g=f??r,w=g.getAttribute?.("data-cd-id")??null;return{el:g,cdId:w,artboardId:i}}import{useCallback as Vc,useEffect as Cs,useRef as Bt}from"react";var Mc=!1;function ws(){return Mc}import{createContext as Lc,useCallback as Ue,useContext as Rs,useEffect as mt,useMemo as Ss,useRef as Ne,useState as jt}from"react";function Me(e,t,n,o){return`url("data:image/svg+xml,${encodeURIComponent(e.trim())}") ${t} ${n}, ${o}`}var Yn="width='24' height='24' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'",Qn="#1f1f1f",Xn="stroke='#ffffff' stroke-linejoin='round' stroke-linecap='round'";function je(e,t,n){let o=n?`<g transform='${n}'>`:"";return`<svg ${Yn}>${o}<path fill='#ffffff' d='${e}'/><path fill='${Qn}' d='${t}'/>${n?"</g>":""}</svg>`}var ks="translate(0,32) scale(1,-1)",vs=Me(je("M10.25 8.25 L10.05 8.65 10 9 10 23.1 10.05 23.4 10.25 23.75 10.8 24 11.45 23.85 11.6 23.7 11.75 23.45 14.65 19.8 14.85 19.65 14.95 19.5 15.4 19.2 15.95 19.1 21.05 19.1 21.2 19.1 21.35 19.05 21.65 18.9 21.9 18.6 22 18.3 22 17.9 21.9 17.65 21.75 17.35 21.65 17.3 21.55 17.15 11.5 8.25 11.25 8.05 10.95 8 10.6 8.05 10.25 8.25 M9.15 6.6 L9.7 6.25 10 6.15 10.95 6 11.9 6.15 13 6.9 22.9 15.65 23 15.8 23.2 15.95 23.75 16.75 24 17.9 24 18.3 23.9 18.95 23.8 19.25 23.6 19.7 23.1 20.35 22.75 20.6 22.1 20.9 22.05 20.95 22 20.95 21.2 21.1 21.05 21.1 16.2 21.1 16.1 21.25 16.05 21.25 13.4 24.6 13.05 25.15 12.9 25.3 12.55 25.55 Q11.6 26.15 10.55 26 L10.5 26 Q9.65 25.85 9 25.3 L8.45 24.65 8.4 24.5 8.15 24.05 8 23.1 8 9 Q8 8.45 8.15 8.05 L8.25 7.75 8.45 7.35 9.15 6.6","M10.25 8.25 L10.6 8.05 10.95 8 11.25 8.05 11.5 8.25 21.55 17.15 21.65 17.3 21.75 17.35 21.9 17.65 22 17.9 22 18.3 21.9 18.6 21.65 18.9 21.35 19.05 21.2 19.1 21.05 19.1 15.95 19.1 15.4 19.2 14.95 19.5 14.85 19.65 14.65 19.8 11.75 23.45 11.6 23.7 11.45 23.85 10.8 24 10.25 23.75 10.05 23.4 10 23.1 10 9 10.05 8.65 10.25 8.25"),8,5,"default"),Rc=Me(je("M28.55 17.8 Q29.4 20.3 28.75 22.8 L28.7 23 28.15 24.55 28.05 24.75 Q26.4 28.2 22.75 29.4 L22.45 29.5 18 29.9 17.75 29.85 Q15.8 29.25 13.8 28.1 L13.45 27.95 Q12 27.05 10.35 26.8 L10.25 26.75 7.9 26.7 7.8 26.7 Q6.1 26.9 4.8 25.8 L4.75 25.8 4.65 25.7 4.6 25.65 Q3.25 24.5 3.05 22.85 L3 22.75 Q2.8 20.95 4 19.5 5.05 18.15 6.75 17.95 L8.4 17.9 7.5 15.55 7.3 15.2 7.2 15 5 10.95 Q3.9 9.15 4.3 7.75 L4.4 7.5 Q4.75 6.15 6.45 5.2 9 3.65 11 5 11.05 4.1 11.5 3.45 12.15 2.1 14.2 1.6 L14.35 1.6 Q18.05 0.6 19.6 4.4 L19.65 4.55 Q20.75 3.65 22.7 3.75 L22.75 3.75 Q26.75 4 27 8.15 L27 8.25 27 8.35 27 8.45 Q26.9 10.75 27.1 12.6 27.15 14.65 28.2 16.75 L28.55 17.8 M26.65 18.4 L26.1 16.8 26.1 16.85 Q24.8 13.7 25 8.35 L25 8.25 Q24.85 5.9 22.6 5.75 20.7 5.65 20.4 7.35 L20.1 7.95 19.5 8.2 18.85 8.05 18.45 7.5 17.75 5.15 Q16.85 2.95 14.7 3.55 L14.65 3.55 Q12.55 4.05 13.15 6.15 L13.85 8.75 13.75 9.45 13.25 9.95 12.55 9.95 12 9.55 10.9 7.7 Q9.5 5.7 7.45 6.9 6.5 7.45 6.25 8.15 6.1 8.9 6.7 9.85 9.2 13.9 10.8 18.65 L10.8 19.3 10.4 19.8 9.75 19.95 Q8.35 19.8 6.95 19.95 6.1 20.05 5.55 20.75 4.9 21.55 5 22.55 5.15 23.55 6 24.2 L6.05 24.25 Q6.75 24.85 7.65 24.7 L7.7 24.7 10.65 24.8 Q12.7 25.15 14.45 26.2 L14.5 26.2 Q16.4 27.35 18.3 27.9 L22.05 27.5 22.1 27.5 Q24.95 26.55 26.25 23.85 L26.8 22.3 Q27.3 20.35 26.65 18.4","M26.65 18.4 Q27.3 20.35 26.8 22.3 L26.25 23.85 Q24.95 26.55 22.1 27.5 L22.05 27.5 18.3 27.9 Q16.4 27.35 14.5 26.2 L14.45 26.2 Q12.7 25.15 10.65 24.8 L7.7 24.7 7.65 24.7 Q6.75 24.85 6.05 24.25 L6 24.2 Q5.15 23.55 5 22.55 4.9 21.55 5.55 20.75 6.1 20.05 6.95 19.95 8.35 19.8 9.75 19.95 L10.4 19.8 10.8 19.3 10.8 18.65 Q9.2 13.9 6.7 9.85 6.1 8.9 6.25 8.15 6.5 7.45 7.45 6.9 9.5 5.7 10.9 7.7 L12 9.55 12.55 9.95 13.25 9.95 13.75 9.45 13.85 8.75 13.15 6.15 Q12.55 4.05 14.65 3.55 L14.7 3.55 Q16.85 2.95 17.75 5.15 L18.45 7.5 18.85 8.05 19.5 8.2 20.1 7.95 20.4 7.35 Q20.7 5.65 22.6 5.75 24.85 5.9 25 8.25 L25 8.35 Q24.8 13.7 26.1 16.85 L26.1 16.8 26.65 18.4"),12,12,"grab"),Ac=Me(je("M28 14 Q28 9.85 24.45 6.9 20.95 4 16 4 11.05 4 7.5 6.9 L7.45 7 Q4 9.9 4 14 4 18.15 7.55 21.05 L7.5 21.05 Q9.2 22.45 11.2 23.2 L15.3 27.3 16 27.6 16.7 27.3 20.85 23.2 Q22.7 22.45 24.3 21.15 L24.45 21.05 Q28 18.15 28 14 M25.75 5.35 Q30.05 8.95 30 14 30.05 19.05 25.75 22.6 L25.4 22.85 Q23.8 24.1 22 24.9 L18.1 28.75 18.15 28.75 Q17.2 29.6 16 29.6 14.8 29.6 13.85 28.75 L13.9 28.75 10 24.9 6.6 22.85 6.25 22.6 Q1.95 19.05 2 14 1.95 8.95 6.25 5.35 10.3 2 16 2 21.7 2 25.75 5.35","M28 14 Q28 18.15 24.45 21.05 L24.3 21.15 Q22.7 22.45 20.85 23.2 L16.7 27.3 16 27.6 15.3 27.3 11.2 23.2 Q9.2 22.45 7.5 21.05 L7.55 21.05 Q4 18.15 4 14 4 9.9 7.45 7 L7.5 6.9 Q11.05 4 16 4 20.95 4 24.45 6.9 28 9.85 28 14"),12,21,"crosshair"),Cc=Me(je("M4 13.1 L4 6 Q4 5.15 4.6 4.6 5.15 4 6 4 L13.1 4 Q13.95 4 14.55 4.6 L28.65 18.75 Q29.8 19.9 29.75 21.45 L29.75 21.6 29.75 21.7 Q29.75 23.2 28.7 24.35 L24.45 28.65 24.35 28.75 Q23.15 29.85 21.65 29.8 L21.55 29.8 21.4 29.8 Q20.2 29.8 19.25 29.15 L18 29.35 Q16.6 29.4 15.25 28 L15.2 27.95 8.2 20.95 Q7.6 20.35 7.6 19.55 7.6 18.7 8.2 18.1 L4.6 14.5 Q4 13.9 4 13.1 M19.5 26.65 L20.1 27.25 Q20.7 27.85 21.5 27.8 22.35 27.85 23 27.25 L27.25 22.95 Q27.8 22.35 27.75 21.55 27.8 20.75 27.2 20.15 L13.1 6 6 6 6 13.1 12.35 19.45 9.6 19.5 16.65 26.55 Q18.05 28.05 19.5 26.65 M8.05 12.3 L8 8 12.25 8.05 13.8 9.6 9.6 13.85 8.05 12.3 M15.25 11.05 L23 18.8 18.8 23.05 11.05 15.3 15.25 11.05","M15.25 11.05 L11.05 15.3 18.8 23.05 23 18.8 15.25 11.05 M12.35 19.45 L6 13.1 6 6 13.1 6 27.2 20.15 Q27.8 20.75 27.75 21.55 27.8 22.35 27.25 22.95 L23 27.25 Q22.35 27.85 21.5 27.8 20.7 27.85 20.1 27.25 L19.5 26.65 12.35 19.45 M8.05 12.3 L9.6 13.85 13.8 9.6 12.25 8.05 8 8 8.05 12.3",ks),6,18,"crosshair"),Ic=Me(je("M5.15 10.85 Q4 9.65 4 8.1 L4 7.95 4 7.85 Q3.95 6.2 5.1 5.15 6.25 4 7.85 4 L7.95 4 8.1 4 Q9.65 4 10.85 5.15 L11 5.3 14.3 5.25 Q15.15 5.25 15.75 5.85 L29.9 20 Q31 21.15 31 22.75 L31 22.85 31 23 Q31.05 24.5 29.9 25.7 L29.55 25.95 25.65 29.9 25.65 29.95 Q24.45 31.1 22.75 31.1 21.2 31.15 20 29.95 L5.85 15.8 Q5.25 15.2 5.25 14.35 L5.25 10.95 5.15 10.85 M19.95 24.2 L18.55 22.8 22.8 18.55 24.2 19.95 19.95 24.2 M28.45 21.4 L14.3 7.25 10.15 7.3 9.4 6.55 Q8.8 5.95 7.95 6 7.1 5.95 6.5 6.55 5.95 7.1 6 7.95 5.95 8.8 6.55 9.4 L7.25 10.1 7.25 14.35 21.4 28.5 Q22 29.1 22.75 29.1 23.6 29.1 24.2 28.5 L28.45 24.25 Q29.05 23.65 29 22.85 29.05 22 28.45 21.4 M9.25 13.5 L9.25 9.3 13.5 9.25 14.3 10.05 10.05 14.3 9.25 13.5 M17.15 21.4 L11.5 15.75 15.75 11.5 21.4 17.15 17.15 21.4","M17.15 21.4 L21.4 17.15 15.75 11.5 11.5 15.75 17.15 21.4 M28.45 21.4 Q29.05 22 29 22.85 29.05 23.65 28.45 24.25 L24.2 28.5 Q23.6 29.1 22.75 29.1 22 29.1 21.4 28.5 L7.25 14.35 7.25 10.1 6.55 9.4 Q5.95 8.8 6 7.95 5.95 7.1 6.5 6.55 7.1 5.95 7.95 6 8.8 5.95 9.4 6.55 L10.15 7.3 14.3 7.25 28.45 21.4 M19.95 24.2 L24.2 19.95 22.8 18.55 18.55 22.8 19.95 24.2 M9.25 13.5 L10.05 14.3 14.3 10.05 13.5 9.25 9.25 9.3 9.25 13.5",ks),6,18,"crosshair"),ye=Me(je("M17 2 Q18.2 2 19.15 2.9 20 3.8 20 5 L20 12 27 12 Q28.2 12 29.15 12.9 30 13.8 30 15 L30 17 Q30 18.2 29.15 19.15 28.2 20 27 20 L20 20 20 27 Q20 28.2 19.15 29.15 18.2 30 17 30 L15 30 Q13.8 30 12.9 29.15 12 28.2 12 27 L12 20 5 20 Q3.8 20 2.9 19.15 2 18.2 2 17 L2 15 Q2 13.8 2.9 12.9 3.8 12 5 12 L12 12 12 5 Q12 3.8 12.9 2.9 13.8 2 15 2 L17 2 M14 27 L14.3 27.7 Q14.6 28 15 28 L17 28 17.7 27.7 18 27 18 18.05 18.05 18 27 18 Q27.4 18 27.7 17.7 L28 17 28 15 27.7 14.3 Q27.4 14 27 14 L18 14 18 5 17.7 4.3 17 4 15 4 Q14.6 4 14.3 4.3 14 4.6 14 5 L14 14 5 14 Q4.6 14 4.3 14.3 4 14.6 4 15 L4 17 Q4 17.4 4.3 17.7 4.6 18 5 18 L14 18 14 27","M14 27 L14 18 5 18 Q4.6 18 4.3 17.7 4 17.4 4 17 L4 15 Q4 14.6 4.3 14.3 4.6 14 5 14 L14 14 14 5 Q14 4.6 14.3 4.3 14.6 4 15 4 L17 4 17.7 4.3 18 5 18 14 27 14 Q27.4 14 27.7 14.3 L28 15 28 17 27.7 17.7 Q27.4 18 27 18 L18.05 18 18 18.05 18 27 17.7 27.7 17 28 15 28 Q14.6 28 14.3 27.7 L14 27"),12,12,"crosshair"),Pc=Me(je("M3.9 11.35 Q2.3 12.5 3.7 13.9 L16.4 26.65 Q17.85 28.05 19.45 26.9 L27.65 21.15 Q29.3 20 27.85 18.6 L15.15 5.85 Q13.75 4.45 12.1 5.6 L3.9 11.35 M1.05 12.4 Q1 10.95 2.75 9.75 L10.95 4 10.95 3.95 Q14 1.85 16.6 4.45 L29.3 17.2 Q30.8 18.65 30.55 20.1 30.55 21.55 28.8 22.8 L20.6 28.55 20.65 28.55 Q17.7 30.65 15 28.1 L15 28.05 2.3 15.3 2.3 15.35 Q0.8 13.85 1.05 12.4 M13.5 7 L19.85 13.35 11.65 19.15 5.3 12.75 13.5 7","M13.5 7 L5.3 12.75 11.65 19.15 19.85 13.35 13.5 7 M3.9 11.35 L12.1 5.6 Q13.75 4.45 15.15 5.85 L27.85 18.6 Q29.3 20 27.65 21.15 L19.45 26.9 Q17.85 28.05 16.4 26.65 L3.7 13.9 Q2.3 12.5 3.9 11.35"),6,14,"cell"),xs=Me(`<svg ${Yn}><path d='M16 4V28M11 4H21M11 28H21' fill='none' ${Xn} stroke-width='5'/><path d='M16 4V28M11 4H21M11 28H21' fill='none' stroke='${Qn}' stroke-width='2.25' stroke-linecap='round'/></svg>`,12,12,"text"),_c=Me(`<svg ${Yn}><path d='M6 5H21L26 10V27H6Z' fill='${Qn}' ${Xn} stroke-width='2.5'/><path d='M21 5V11H26' fill='none' ${Xn} stroke-width='2.25'/></svg>`,5,5,"crosshair"),ne=Object.freeze({browse:"default",move:vs,inspect:vs,hand:Rc,comment:Ac,pen:Cc,section:ye,highlighter:Ic,shape:ye,rect:ye,ellipse:ye,sticky:_c,arrow:ye,text:xs,"el-text":xs,frame:ye,"el-shape":ye,line:ye,polygon:ye,slice:ye,"el-pen":ye,crop:ye,eraser:Pc});import{jsx as Gn,Fragment as zc}from"react/jsx-runtime";function Es(e,t){if(typeof window>"u"||window.parent===window)return;if(!Se(window).claimRequest(`${e}|${t??""}`))return;try{window.parent.postMessage(t?{dgn:"mode-request",mode:e,tool:t,cause:"toolbar"}:{dgn:"mode-request",mode:e,cause:"toolbar"},"*")}catch{}}var Ut="maude:tool-sync",Ts=Object.freeze({preview:"browse",edit:"move"});function Ms(e){if(e==="browse")return"preview";if(e==="move")return"edit";return null}var Oc=Object.freeze([{id:"browse",label:"Browse",shortcut:"",cursor:ne.browse},{id:"move",label:"Select",shortcut:"V",cursor:ne.move},{id:"inspect",label:"Inspect",shortcut:"",cursor:ne.inspect},{id:"hand",label:"Hand",shortcut:"H",cursor:ne.hand},{id:"comment",label:"Comment",shortcut:"C",cursor:ne.comment},{id:"pen",label:"Pen",shortcut:"B",cursor:ne.pen},{id:"highlighter",label:"Highlighter",shortcut:"I",cursor:ne.highlighter},{id:"shape",label:"Shape",shortcut:"R",cursor:ne.shape},{id:"sticky",label:"Sticky",shortcut:"N",cursor:ne.sticky},{id:"section",label:"Section",shortcut:"⇧S",cursor:ne.shape},{id:"arrow",label:"Arrow",shortcut:"A",cursor:ne.arrow},{id:"text",label:"Text",shortcut:"T",cursor:ne.text},{id:"el-text",label:"Text",shortcut:"T",cursor:ne["el-text"]},{id:"frame",label:"Frame",shortcut:"F",cursor:ne.frame},{id:"el-shape",label:"Shape",shortcut:"R",cursor:ne["el-shape"]},{id:"ellipse",label:"Ellipse",shortcut:"",cursor:ne.ellipse},{id:"line",label:"Line",shortcut:"",cursor:ne.line},{id:"polygon",label:"Polygon",shortcut:"",cursor:ne.polygon},{id:"slice",label:"Export area",shortcut:"",cursor:ne.slice},{id:"el-pen",label:"Pen",shortcut:"P",cursor:ne["el-pen"]},{id:"crop",label:"Crop",shortcut:"",cursor:ne.crop},{id:"eraser",label:"Eraser",shortcut:"E",cursor:ne.eraser}]),Nc=new Set(["browse","move","hand","inspect"]);function Dc(e,t,n=!1){return t?e.filter((o)=>Nc.has(o.id)||n&&o.id==="comment"):e}var Zn=Lc(null);function Kc({children:e,tools:t=Oc,initial:n,initialMode:o,governed:r=!1}){let s=Pe(),i=s&&Be(),c=Ss(()=>Dc(t,s,i),[t,s,i]),p=n??(s?"browse":"move"),f=o??Ms(p)??(s?"preview":"edit"),[y,g]=jt(p),w=Ne(p),A=Ue((M)=>{w.current=M,g(M)},[]),m=Ue(()=>w.current,[]),[h,S]=jt(f),[b,a]=jt(()=>({tool:null,locked:!1})),x=Ne(null),R=Ue((M)=>{if(!c.some((B)=>B.id===M))return;let K=x.current;if(K){let B=nt(M,K.caps,K.mode);if(B&&B!==K.mode){if(K.mode!=="present")Es(B,M);return}A(M),a((G)=>G.locked&&G.tool===M?G:{tool:null,locked:!1});return}A(M);let W=Ms(M);if(W)S(W);a((B)=>B.locked&&B.tool===M?B:{tool:null,locked:!1})},[c]),j=Ue((M)=>{let K=x.current;if(K){Es(M==="edit"?ao(K.caps):"preview");return}let W=Ts[M];if(!c.some((B)=>B.id===W))return;S(M),A(W),a((B)=>B.locked&&B.tool===W?B:{tool:null,locked:!1})},[c]),T=Ue(()=>{let M=x.current;R(M?Zt[M.mode]:Ts[h])},[h,R]),P=Ne(h);P.current=h;let z=Ne(y);z.current=y;let L=Ne(y);mt(()=>{let M=as(L.current,y);if(L.current=y,M)is(M)},[y]),mt(()=>{if(!r||typeof window>"u")return;let M=Se(window),K=-1,W=null,B=()=>{let G=M.get();if(G.mode===null||!G.caps||G.modeSeq<=K)return;K=G.modeSeq,x.current={mode:G.mode,caps:G.caps};let Re=co[G.mode],Ae=W===null?P.current!==Re:W!==G.mode;W=G.mode;let Ce=Zt[G.mode],De=(Ie)=>!!Ie&&c.some((ft)=>ft.id===Ie),D=G.tool??(Ae?Ce:null),Z=De(D)?D:Ae&&De(Ce)?Ce:null;if(S(Re),Z)A(Z),z.current=Z;if(Ae)a({tool:null,locked:!1});if(M.claimEcho(G.modeSeq)&&window.parent!==window)try{window.parent.postMessage({dgn:"mode-changed",seq:G.modeSeq,mode:G.mode,tool:Z??z.current,present:G.present,cause:G.clamped?"clamp":"set-mode"},"*")}catch{}};return B(),M.subscribe(B)},[c,r]);let V=Ue((M)=>{a((K)=>{if(K.locked&&K.tool===M)return{tool:null,locked:!1};return{tool:M,locked:!0}}),A(M)},[]),Q=Ue(()=>{a({tool:null,locked:!1})},[]),[ee,oe]=jt("rounded"),te=Ne(Math.random().toString(36).slice(2)),k=Ne(y);k.current=y;let E=Ne(!1);mt(()=>{if(!E.current){E.current=!0;return}if(typeof document>"u")return;document.dispatchEvent(new CustomEvent(Ut,{detail:{tool:y,from:te.current}}))},[y]),mt(()=>{if(typeof document>"u")return;let M=(K)=>{let W=K.detail;if(!W||W.from===te.current||typeof W.tool!=="string")return;if(W.tool===k.current)return;let B=x.current;if(B){let G=nt(W.tool,B.caps,B.mode);if(G&&G!==B.mode){document.dispatchEvent(new CustomEvent(Ut,{detail:{tool:k.current,from:te.current}}));return}}R(W.tool)};return document.addEventListener(Ut,M),()=>document.removeEventListener(Ut,M)},[R]),mt(()=>{if(typeof document>"u")return;let M=c.find((B)=>B.id===y);if(!M)return;let K=document.body.style.cursor,W=document.getElementById("dc-tool-cursor");if(!W)W=document.createElement("style"),W.id="dc-tool-cursor",document.head.appendChild(W);if(y==="browse"){if(document.body.style.cursor="",W.textContent="",typeof window<"u"&&window.parent&&window.parent!==window)try{window.parent.postMessage({dgn:"tool-cursor",tool:y},"*")}catch{}return()=>{document.body.style.cursor=K}}if(document.body.style.cursor=M.cursor,W.textContent=`* { cursor: ${M.cursor} !important; }`,typeof window<"u"&&window.parent&&window.parent!==window)try{window.parent.postMessage({dgn:"tool-cursor",tool:y},"*")}catch{}return()=>{document.body.style.cursor=K;let B=document.getElementById("dc-tool-cursor");if(B)B.textContent=""}},[y,c]);let _=Ss(()=>({tool:y,getTool:m,setTool:R,tools:c,mode:h,setMode:j,resetTool:T,sticky:b,toggleSticky:V,clearSticky:Q,shapeKind:ee,setShapeKind:oe}),[y,m,R,c,h,j,T,b,V,Q,ee]);return Gn(Zn.Provider,{value:_,children:e})}function As({children:e,initial:t,initialMode:n,governed:o}){if(Rs(Zn))return Gn(zc,{children:e});return Gn(Kc,{initial:t,initialMode:n,governed:o,children:e})}function Wt(){let e=Rs(Zn);if(!e)throw Error("useToolMode must be used inside <ToolProvider>");return e}import{jsx as Gc}from"react/jsx-runtime";var Hc=`
2
2
  .dc-el-resize-handle {
3
3
  position: fixed;
4
4
  width: 8px;
@@ -59,4 +59,4 @@ import{Component as Xc,createElement as Jn,useCallback as Gn,useEffect as ye,use
59
59
  @media (prefers-reduced-motion: reduce) {
60
60
  .dc-el-resize-handle, .dc-el-resize-readout { transition-duration: 1ms; }
61
61
  }
62
- `.trim();function Kc(){if(typeof document>"u")return;if(document.getElementById("dc-el-resize-css"))return;let e=document.createElement("style");e.id="dc-el-resize-css",e.textContent=Dc,document.head.appendChild(e)}var zc=["nw","n","ne","e","se","s","sw","w"];function Vc(e){return{movesLeft:e==="nw"||e==="w"||e==="sw",movesRight:e==="ne"||e==="e"||e==="se",movesTop:e==="nw"||e==="n"||e==="ne",movesBottom:e==="sw"||e==="s"||e==="se"}}var Ye=(e)=>Math.round(e*100)/100,Wt=1;function Hc(e,t,n,o,r,s){let{movesLeft:a,movesRight:c,movesTop:p,movesBottom:f}=Vc(e),x=r.center,{w:g,h:w}=t;if(c)g=t.w+(x?2*n:n);else if(a)g=t.w-(x?2*n:n);if(f)w=t.h+(x?2*o:o);else if(p)w=t.h-(x?2*o:o);if(r.aspect&&t.w>0&&t.h>0){let m=t.w/t.h;if((a||c)&&(p||f)){let S=Math.abs(g-t.w)/t.w,y=Math.abs(w-t.h)/t.h;if(S>=y)w=g/m;else g=w*m}else if(a||c)w=g/m;else if(p||f)g=w*m}if(g<Wt)g=Wt;if(w<Wt)w=Wt;let A={width:Ye(g),height:Ye(w)};if(x){if(s.canMoveLeft&&(a||c))A.left=Ye(t.left+(t.w-g)/2);if(s.canMoveTop&&(p||f))A.top=Ye(t.top+(t.h-w)/2)}else{if(s.canMoveLeft&&a)A.left=Ye(t.left+t.w-g);if(s.canMoveTop&&p)A.top=Ye(t.top+t.h-w)}return A}function Ms(e){if(!e||e==="none")return 0;let t=/matrix\(([^)]+)\)/.exec(e);if(!t)return 0;let n=t[1].split(",").map(Number),o=n[0]??1,r=n[1]??0;return Math.round(Math.atan2(r,o)*(180/Math.PI)*100)/100}function Fc(e){if(!e||e==="none")return 1;let t=/matrix\(([^)]+)\)/.exec(e);if(!t)return 1;let n=t[1].split(",").map(Number),o=n[0]??1,r=n[1]??0,s=Math.hypot(o,r);return s>0?s:1}function $c(e){let t=e.closest(".dc-world");if(!t)return 1;let n=getComputedStyle(t),o=Number.parseFloat(n.zoom||"1")||1;return Fc(n.transform)*o}function As(e,t,n){let o=n*Math.PI/180,r=Math.cos(o),s=Math.sin(o);return[e*r-t*s,e*s+t*r]}function Rs(e,t,n,o){return Math.atan2(o-t,n-e)}function qc(e,t,n,o){let r=e+(n-t)*(180/Math.PI);while(r>180)r-=360;while(r<=-180)r+=360;if(o)r=Math.round(r/15)*15;return Math.round(r*100)/100}function jc(e,t){let n={width:`${t.width}px`,height:`${t.height}px`};if(typeof t.left==="number")n.left=`${t.left}px`;if(typeof t.top==="number")n.top=`${t.top}px`;try{window.parent.postMessage({dgn:"resize-request",id:e.cdId,patch:n,before:e.before,idIndex:e.idIndex},"*")}catch{}}function Uc(e,t){if(!e.artboardId)return;try{window.parent.postMessage({dgn:"resize-artboard-request",artboardId:e.artboardId,width:t.width,height:t.height},"*")}catch{}}function Wc(e,t){try{window.parent.postMessage({dgn:"resize-request",id:e.cdId,patch:{transform:t},before:e.before,idIndex:e.idIndex},"*")}catch{}}function Cs(){Kc();let{selected:e}=Dt(),{tool:t}=jt(),n=Ut(null),o=Ut(null),r=Ut(null),s=Ut(null),a=e.length===1?e[0]:null,c=a&&typeof a.id==="string"?a.id:null,p=a&&!c&&typeof a.artboardId==="string"?a.artboardId:null,f=t==="move"&&!!c;Ts(()=>{let g=n.current;if(!g)return;let w=()=>{for(let m of Array.from(g.children)){let h=m;h.style.opacity="0",h.style.pointerEvents="none"}};if(!f||!a){w();return}let A=()=>{if(o.current=null,gs()){w(),o.current=requestAnimationFrame(A);return}let m=En(document,a);if(!m){w(),o.current=requestAnimationFrame(A);return}let h=m.getBoundingClientRect();if(h.width<=0&&h.height<=0){w(),o.current=requestAnimationFrame(A);return}let S=p?["e","s","se"]:zc,y=p?[]:["rot-nw","rot-ne","rot-sw","rot-se"],i=S.length+y.length+1;while(g.children.length<i)g.appendChild(document.createElement("div"));while(g.children.length>i)g.lastChild&&g.removeChild(g.lastChild);let b=h.left+h.width/2,E=h.top+h.height/2,L=Ms(getComputedStyle(m).transform),O=$c(m),z=m.offsetWidth*O/2,G=m.offsetHeight*O/2,D={nw:[-z,-G],n:[0,-G],ne:[z,-G],e:[z,0],se:[z,G],s:[0,G],sw:[-z,G],w:[-z,0],"rot-nw":[-z,-G],"rot-ne":[z,-G],"rot-sw":[-z,G],"rot-se":[z,G]},W=[...y,...S];for(let oe=0;oe<W.length;oe++){let te=W[oe],k=g.children[oe],[T,I]=D[te]??[0,0],[M,K]=As(T,I,L),q=b+M,j=E+K,Y=te.startsWith("rot-"),Ee=te==="n"||te==="s",Te=te==="e"||te==="w",Me=Y?10:Ee?7:Te?3:4,Oe=Y?10:Ee?3:Te?7:4;k.className="dc-el-resize-handle",k.dataset.corner=te,k.style.opacity="1",k.style.pointerEvents="auto",k.style.left=`${Math.round(q-Me)}px`,k.style.top=`${Math.round(j-Oe)}px`,k.style.transform=Y?"":`rotate(${L}deg)`}let Q=g.children[W.length],ee=r.current;if(ee&&ee.el===m&&!ee.corner.startsWith("rot-")){let oe=ee.lastResult?.width??m.offsetWidth,te=ee.lastResult?.height??m.offsetHeight,k=`${Math.round(oe)} × ${Math.round(te)}`,T=ee.lastResult?.left,I=ee.lastResult?.top;if(typeof T==="number"||typeof I==="number")k+=` · ${Math.round(T??ee.start.left)}, ${Math.round(I??ee.start.top)}`;Q.className="dc-el-resize-readout",Q.textContent=k,Q.style.opacity="1",Q.style.left=`${Math.round(b)}px`,Q.style.top=`${Math.round(E+G)}px`}else Q.style.opacity="0";o.current=requestAnimationFrame(A)};return o.current=requestAnimationFrame(A),()=>{if(o.current!=null)cancelAnimationFrame(o.current)}},[f,a,p]);let x=Nc((g,w)=>{if(g.el.style.width=`${w.width}px`,g.el.style.height=`${w.height}px`,typeof w.left==="number")g.el.style.left=`${w.left}px`;if(typeof w.top==="number")g.el.style.top=`${w.top}px`;g.lastResult=w},[]);return Ts(()=>{let g=n.current;if(!g)return;let w=(y,i)=>{let[b,E]=As(i.clientX-y.startClientX,i.clientY-y.startClientY,-y.angle);return Hc(y.corner,y.start,b/y.elZoom,E/y.elZoom,{aspect:!!i.shiftKey,center:!y.artboardId&&!!i.altKey},y.flags)},A=(y)=>{let i=y.target;if(!i?.classList.contains("dc-el-resize-handle"))return;let b=i.dataset.corner;if(!b||!a)return;let E=typeof a.id==="string"?a.id:null,L=!E&&typeof a.artboardId==="string"?a.artboardId:null;if(!E&&!L)return;let O=En(document,a);if(!O)return;y.preventDefault(),y.stopPropagation();let z=O.getBoundingClientRect(),G=O.offsetWidth?z.width/O.offsetWidth:1,D=getComputedStyle(O),W=!L&&(D.position==="absolute"||D.position==="fixed"),Q=L?Number.NaN:Number.parseFloat(O.style.left),ee=L?Number.NaN:Number.parseFloat(O.style.top),oe=L?0:Ms(D.transform),te=G>0?G:1,k=z.left+z.width/2,T=z.top+z.height/2,I={pointerId:y.pointerId,corner:b,el:O,cdId:E??"",artboardId:L,idIndex:E?ur(document,E,O):0,startClientX:y.clientX,startClientY:y.clientY,elZoom:te,angle:oe,cx:k,cy:T,rotStartPointer:Rs(k,T,y.clientX,y.clientY),start:{w:(oe?O.offsetWidth:z.width/te)||z.width/te,h:(oe?O.offsetHeight:z.height/te)||z.height/te,left:Q,top:ee},flags:{canMoveLeft:W&&Number.isFinite(Q),canMoveTop:W&&Number.isFinite(ee)},before:{width:O.style.width||null,height:O.style.height||null,left:O.style.left||null,top:O.style.top||null,transform:O.style.transform||null},lastResult:null,lastTransform:null};r.current=I;try{i.setPointerCapture(y.pointerId)}catch{}},m=(y)=>{let i=r.current;if(!i||y.pointerId!==i.pointerId)return;if(y.preventDefault(),i.corner.startsWith("rot-")){let E=`rotate(${qc(i.angle,i.rotStartPointer,Rs(i.cx,i.cy,y.clientX,y.clientY),!!y.shiftKey)}deg)`;i.el.style.transform=E,i.lastTransform=E;return}x(i,w(i,y))},h=(y)=>{let i=r.current;if(!i||y.pointerId!==i.pointerId)return;if(r.current=null,i.corner.startsWith("rot-")){let L=i.lastTransform;if(!L||L===i.before.transform)return;s.current={el:i.el,before:i.before},Wc(i,L);return}let b=i.lastResult??w(i,y);if(!(`${b.width}px`!==i.before.width||`${b.height}px`!==i.before.height||typeof b.left==="number"&&`${b.left}px`!==i.before.left||typeof b.top==="number"&&`${b.top}px`!==i.before.top))return;if(s.current={el:i.el,before:i.before},i.artboardId)Uc(i,b);else jc(i,b)},S=(y)=>{let i=y.data;if(i?.dgn!=="resize-failed"&&i?.dgn!=="resize-artboard-failed")return;if(y.source!==window.parent)return;let b=s.current;if(!b)return;if(b.el.style.width=b.before.width??"",b.el.style.height=b.before.height??"",b.before.left!==null||b.el.style.left)b.el.style.left=b.before.left??"";if(b.before.top!==null||b.el.style.top)b.el.style.top=b.before.top??"";if(b.before.transform!==null||b.el.style.transform)b.el.style.transform=b.before.transform??"";s.current=null};return g.addEventListener("pointerdown",A),window.addEventListener("pointermove",m),window.addEventListener("pointerup",h),window.addEventListener("pointercancel",h),window.addEventListener("message",S),()=>{g.removeEventListener("pointerdown",A),window.removeEventListener("pointermove",m),window.removeEventListener("pointerup",h),window.removeEventListener("pointercancel",h),window.removeEventListener("message",S)}},[a,x]),Bc("div",{ref:n,"aria-hidden":"true"})}import{jsx as me,jsxs as Ls,Fragment as cd}from"react/jsx-runtime";var Gc=new Set(["drop-comment","tool","escape","hover"]);function Zc(e,t){if(!e)return!0;t();return}function Ge(){return typeof document<"u"&&!document.querySelector(".dc-canvas")}function eo(e,t){if(typeof document>"u")return null;let n=document.elementFromPoint(e,t);if(!n)return null;if(n.closest(".cm-composer, .cm-thread, .cm-mention-popup, .cm-pin, [data-mc-hover-halo], [data-mc-selection-halo], .dc-el-resize-handle"))return null;let o=n.tagName;if(o==="HTML"||o==="BODY")return null;return n}function Jc(e,t){let n=eo(e,t);if(!n)return null;return n.closest("[data-cd-id]")??n}function ed({children:e,file:t}){let{tool:n,setTool:o,getTool:r}=jt(),s=Dt(),a=we(null),[c,p]=Ze(null),f=we(n);f.current=n;let x=Qc(()=>()=>r?.()??f.current,[r]);ye(()=>{if(n!=="comment")p(null)},[n]);let[g,w]=Ze(null),[A,m]=Ze(!1);return ye(()=>{let h=()=>m(Ge());h();let S=requestAnimationFrame(h),y=setTimeout(h,120);return()=>{cancelAnimationFrame(S),clearTimeout(y)}},[]),ye(()=>{if(typeof document>"u")return;let h=(S)=>{if(S.button!==0||!(S.metaKey||S.ctrlKey))return;if(!Ge())return;if(ct(S.target))return;let y=Jc(S.clientX,S.clientY);if(!y)return;S.preventDefault(),S.stopImmediatePropagation();let i=y.getAttribute("data-cd-id"),b=Tn({el:y,cdId:i,artboardId:null});if(S.shiftKey)s.add(b);else s.replace(b);w(y)};return document.addEventListener("pointerdown",h,!0),()=>document.removeEventListener("pointerdown",h,!0)},[s]),ye(()=>{if(s.selected.length===0)w(null)},[s.selected]),ye(()=>{let h=a.current;if(h)h.setAttribute("data-active-tool",n);if(typeof document<"u"&&document.body)document.body.setAttribute("data-active-tool",n);return()=>{h?.removeAttribute("data-active-tool")}},[n]),ye(()=>{if(typeof window>"u")return;let h=(S)=>{let y=S.data;if(!y||typeof y!=="object"||y.dgn!=="tool-set")return;if(S.source!==window.parent)return;if(typeof y.tool==="string")o(y.tool)};return window.addEventListener("message",h),()=>window.removeEventListener("message",h)},[o]),fs({hostRef:a,getActiveTool:x,claimableActions:Gc,callbacks:{onHover:({clientX:h,clientY:S})=>{if(f.current!=="comment"||!Ge()){p(null);return}let y=eo(h,S);p((i)=>i===y?i:y)},onTool:({tool:h})=>o(h),onEscape:()=>Zc(Ge(),()=>{if(f.current!=="move")o("move");if(p(null),s.clear(),typeof window<"u")try{window.parent.postMessage({dgn:"force-clear"},"*")}catch{}}),onDropComment:({clientX:h,clientY:S})=>od(h,S,s,t)}}),Ls("div",{"data-mc-host":!0,ref:a,style:{display:"contents"},children:[e,c?me(nd,{el:c}):null,g?me(td,{el:g}):null,A?me(Cs,{}):null,me(Kr,{})]})}function td({el:e}){let t=we(null),n=we(e);n.current=e;let o=we(null);return ye(()=>{let r=()=>{o.current=null;let s=t.current,a=n.current;if(s&&a?.isConnected){let c=a.getBoundingClientRect();if(c.width===0&&c.height===0)s.style.display="none";else s.style.display="block",s.style.left=`${Math.round(c.left)}px`,s.style.top=`${Math.round(c.top)}px`,s.style.width=`${Math.round(c.width)}px`,s.style.height=`${Math.round(c.height)}px`}else if(s)s.style.display="none";o.current=requestAnimationFrame(r)};return o.current=requestAnimationFrame(r),()=>{if(o.current!=null)cancelAnimationFrame(o.current)}},[]),me("div",{ref:t,"aria-hidden":"true","data-mc-selection-halo":"",style:{position:"fixed",display:"none",pointerEvents:"none",zIndex:2147483645,border:"1.5px solid var(--maude-hud-accent, oklch(0.680 0.180 268))",borderRadius:"3px",boxSizing:"border-box"}})}function nd({el:e}){let t=we(null),n=we(e);n.current=e;let o=we(null);return ye(()=>{let r=()=>{o.current=null;let s=t.current,a=n.current;if(s&&a?.isConnected){let c=a.getBoundingClientRect();if(c.width===0&&c.height===0)s.style.display="none";else s.style.display="block",s.style.left=`${Math.round(c.left)}px`,s.style.top=`${Math.round(c.top)}px`,s.style.width=`${Math.round(c.width)}px`,s.style.height=`${Math.round(c.height)}px`}else if(s)s.style.display="none";o.current=requestAnimationFrame(r)};return o.current=requestAnimationFrame(r),()=>{if(o.current!=null)cancelAnimationFrame(o.current)}},[]),me("div",{ref:t,"aria-hidden":"true","data-mc-hover-halo":"",style:{position:"fixed",display:"none",pointerEvents:"none",zIndex:2147483646,border:"2px solid var(--maude-hud-accent, #d63b1f)",borderRadius:"3px",boxSizing:"border-box"}})}function od(e,t,n,o){if(typeof document>"u")return;let r=Lo(e,t)??void 0,s=No(e,t);if(s){let p=xt(s),f=p?.getBoundingClientRect(),x={file:o,id:void 0,selector:"",artboardId:null,tag:p?.getAttribute("data-tool")??"annotation",classes:"",text:"",dom_path:[],bounds:f?{x:f.left,y:f.top,w:f.width,h:f.height}:{x:e-12,y:t-12,w:24,h:24},html:"",annotationId:s,...r?{world:r}:{}};Zn(x,e,t);return}let a=Ft(document,e,t,{deep:!0});if(!a)a=Ft(document,e,t,{deep:!1});if(!a&&!Ge()&&typeof document.elementsFromPoint==="function"){let p=document.elementsFromPoint(e,t);for(let f of p){let x=f.closest?.("[data-cd-id]");if(!x)continue;if(!x.closest(".dc-artboard-body"))continue;let g=x.closest("[data-dc-screen]");a={el:x,cdId:x.getAttribute("data-cd-id"),artboardId:g?.getAttribute("data-dc-screen")??null};break}}if(!a&&Ge()){let p=eo(e,t);if(p)a={el:p,cdId:p.getAttribute("data-cd-id"),artboardId:null}}if(!a){let p={file:o,id:void 0,selector:"",artboardId:null,tag:"",classes:"",text:"",dom_path:[],bounds:{x:e-12,y:t-12,w:24,h:24},html:"",...r?{world:r}:{}};Zn(p,e,t);return}let c=Tn(a,o);n.replace(c),Zn(c,e,t)}function Zn(e,t,n){if(typeof document<"u")try{document.dispatchEvent(new CustomEvent("cm:open-composer",{detail:{selection:e,clientX:t,clientY:n}}))}catch{}if(typeof window<"u")try{window.parent.postMessage({dgn:"comment-compose",selection:e},"*")}catch{}}function Ps(e,t){return me(Es,{initial:"browse",children:me(vr,{children:me(ed,{file:t,children:me(e,{})})})})}function Vm(e,t){let n=Yc(t.rootEl);if(!t.commentsEnabled){n.render(Jn(e));return}let o=t.file??Sn();n.render(Jn(ld,{initialCanvas:e,file:o}))}var Is="__maudeCanvasRuntime";function rd({Canvas:e,file:t,onOk:n}){return ye(()=>{n()},[]),Ps(e,t)}class _s extends Xc{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){this.props.onError(e)}componentDidUpdate(e){if(e.attempt!==this.props.attempt&&this.state.hasError)this.setState({hasError:!1})}render(){if(this.state.hasError)return this.props.fallback();return this.props.children}}var sd=300;function id(e){let t="";try{t=e instanceof Error?e.message:String(e??"")}catch{}return(t.replace(/\s+/g," ").trim()||"The canvas stopped while drawing.").slice(0,sd)}function ad({message:e}){return Jn("div",{className:"dc-hmr-holding",role:"status","aria-live":"polite",title:e?`Showing the last version that worked — ${e}`:"Showing the last version that worked"},"This canvas has an error. Showing the last version that worked.")}function ld({initialCanvas:e,file:t}){let[{canvas:n,attempt:o},r]=Ze({canvas:e,attempt:0}),[s,a]=Ze({on:!1}),[c,p]=Ze(!1);ye(()=>{let h=(S)=>{if(S.source!==window.parent)return;if(S.data?.dgn!=="ai-runs")return;let y=vt(S,window);if(y&&y.dgn==="ai-runs")p(Object.values(y.artboards).some((i)=>i.state!=="done"))};return window.addEventListener("message",h),()=>window.removeEventListener("message",h)},[]);let f=we(null),x=we(null),g=we(n);g.current=n,ye(()=>{let h={remount:(S)=>r((y)=>({canvas:S,attempt:y.attempt+1})),setHolding:(S,y)=>a(S?{on:!0,message:y,source:"build"}:{on:!1})};return window[Is]=h,()=>{window[Is]=void 0}},[]);let w=Gn(()=>{if(f.current=g.current,x.current=null,t)try{window.parent.postMessage({dgn:"render-ok",file:t},"*")}catch{}if(a((h)=>h.on?{on:!1}:h),o>0&&t)try{window.parent.postMessage({dgn:"loaded",file:t},"*")}catch{}},[o,t]),A=Gn((h)=>{let S=id(h);if(a({on:!0,message:"render error",source:"render"}),x.current===g.current)return;if(x.current=g.current,t)try{window.parent.postMessage({dgn:"render-error",file:t,message:S},"*")}catch{}},[t]),m=Gn(()=>{let h=f.current;return h?Ps(h,t):null},[t]);return Ls(cd,{children:[me(_s,{attempt:o,onError:A,fallback:m,children:me(rd,{Canvas:n,file:t,onOk:w},o)}),s.on&&(s.source!=="render"||c)?me(ad,{message:s.message}):null]})}export{_s as CanvasErrorBoundary,Zc as commentMountEscape,id as describeRenderFailure,Ge as isBareSpecimen,Vm as mountCanvas,Jc as pickSpecimenSelectEl};
62
+ `.trim();function Fc(){if(typeof document>"u")return;if(document.getElementById("dc-el-resize-css"))return;let e=document.createElement("style");e.id="dc-el-resize-css",e.textContent=Hc,document.head.appendChild(e)}var $c=["nw","n","ne","e","se","s","sw","w"];function qc(e){return{movesLeft:e==="nw"||e==="w"||e==="sw",movesRight:e==="ne"||e==="e"||e==="se",movesTop:e==="nw"||e==="n"||e==="ne",movesBottom:e==="sw"||e==="s"||e==="se"}}var Ze=(e)=>Math.round(e*100)/100,Xt=1;function jc(e,t,n,o,r,s){let{movesLeft:i,movesRight:c,movesTop:p,movesBottom:f}=qc(e),y=r.center,{w:g,h:w}=t;if(c)g=t.w+(y?2*n:n);else if(i)g=t.w-(y?2*n:n);if(f)w=t.h+(y?2*o:o);else if(p)w=t.h-(y?2*o:o);if(r.aspect&&t.w>0&&t.h>0){let m=t.w/t.h;if((i||c)&&(p||f)){let S=Math.abs(g-t.w)/t.w,b=Math.abs(w-t.h)/t.h;if(S>=b)w=g/m;else g=w*m}else if(i||c)w=g/m;else if(p||f)g=w*m}if(g<Xt)g=Xt;if(w<Xt)w=Xt;let A={width:Ze(g),height:Ze(w)};if(y){if(s.canMoveLeft&&(i||c))A.left=Ze(t.left+(t.w-g)/2);if(s.canMoveTop&&(p||f))A.top=Ze(t.top+(t.h-w)/2)}else{if(s.canMoveLeft&&i)A.left=Ze(t.left+t.w-g);if(s.canMoveTop&&p)A.top=Ze(t.top+t.h-w)}return A}function Is(e){if(!e||e==="none")return 0;let t=/matrix\(([^)]+)\)/.exec(e);if(!t)return 0;let n=t[1].split(",").map(Number),o=n[0]??1,r=n[1]??0;return Math.round(Math.atan2(r,o)*(180/Math.PI)*100)/100}function Uc(e){if(!e||e==="none")return 1;let t=/matrix\(([^)]+)\)/.exec(e);if(!t)return 1;let n=t[1].split(",").map(Number),o=n[0]??1,r=n[1]??0,s=Math.hypot(o,r);return s>0?s:1}function Wc(e){let t=e.closest(".dc-world");if(!t)return 1;let n=getComputedStyle(t),o=Number.parseFloat(n.zoom||"1")||1;return Uc(n.transform)*o}function Ps(e,t,n){let o=n*Math.PI/180,r=Math.cos(o),s=Math.sin(o);return[e*r-t*s,e*s+t*r]}function _s(e,t,n,o){return Math.atan2(o-t,n-e)}function Bc(e,t,n,o){let r=e+(n-t)*(180/Math.PI);while(r>180)r-=360;while(r<=-180)r+=360;if(o)r=Math.round(r/15)*15;return Math.round(r*100)/100}function Xc(e,t){let n={width:`${t.width}px`,height:`${t.height}px`};if(typeof t.left==="number")n.left=`${t.left}px`;if(typeof t.top==="number")n.top=`${t.top}px`;try{window.parent.postMessage({dgn:"resize-request",id:e.cdId,patch:n,before:e.before,idIndex:e.idIndex},"*")}catch{}}function Yc(e,t){if(!e.artboardId)return;try{window.parent.postMessage({dgn:"resize-artboard-request",artboardId:e.artboardId,width:t.width,height:t.height},"*")}catch{}}function Qc(e,t){try{window.parent.postMessage({dgn:"resize-request",id:e.cdId,patch:{transform:t},before:e.before,idIndex:e.idIndex},"*")}catch{}}function Ls(){Fc();let{selected:e}=zt(),{tool:t}=Wt(),n=Bt(null),o=Bt(null),r=Bt(null),s=Bt(null),i=e.length===1?e[0]:null,c=i&&typeof i.id==="string"?i.id:null,p=i&&!c&&typeof i.artboardId==="string"?i.artboardId:null,f=t==="move"&&!!c;Cs(()=>{let g=n.current;if(!g)return;let w=()=>{for(let m of Array.from(g.children)){let h=m;h.style.opacity="0",h.style.pointerEvents="none"}};if(!f||!i){w();return}let A=()=>{if(o.current=null,ws()){w(),o.current=re(A);return}let m=Mn(document,i);if(!m){w(),o.current=re(A);return}let h=m.getBoundingClientRect();if(h.width<=0&&h.height<=0){w(),o.current=re(A);return}let S=p?["e","s","se"]:$c,b=p?[]:["rot-nw","rot-ne","rot-sw","rot-se"],a=S.length+b.length+1;while(g.children.length<a)g.appendChild(document.createElement("div"));while(g.children.length>a)g.lastChild&&g.removeChild(g.lastChild);let x=h.left+h.width/2,R=h.top+h.height/2,j=Is(getComputedStyle(m).transform),T=Wc(m),P=m.offsetWidth*T/2,z=m.offsetHeight*T/2,L={nw:[-P,-z],n:[0,-z],ne:[P,-z],e:[P,0],se:[P,z],s:[0,z],sw:[-P,z],w:[-P,0],"rot-nw":[-P,-z],"rot-ne":[P,-z],"rot-sw":[-P,z],"rot-se":[P,z]},V=[...b,...S];for(let oe=0;oe<V.length;oe++){let te=V[oe],k=g.children[oe],[E,_]=L[te]??[0,0],[M,K]=Ps(E,_,j),W=x+M,B=R+K,G=te.startsWith("rot-"),Re=te==="n"||te==="s",Ae=te==="e"||te==="w",Ce=G?10:Re?7:Ae?3:4,De=G?10:Re?3:Ae?7:4;k.className="dc-el-resize-handle",k.dataset.corner=te,k.style.opacity="1",k.style.pointerEvents="auto",k.style.left=`${Math.round(W-Ce)}px`,k.style.top=`${Math.round(B-De)}px`,k.style.transform=G?"":`rotate(${j}deg)`}let Q=g.children[V.length],ee=r.current;if(ee&&ee.el===m&&!ee.corner.startsWith("rot-")){let oe=ee.lastResult?.width??m.offsetWidth,te=ee.lastResult?.height??m.offsetHeight,k=`${Math.round(oe)} × ${Math.round(te)}`,E=ee.lastResult?.left,_=ee.lastResult?.top;if(typeof E==="number"||typeof _==="number")k+=` · ${Math.round(E??ee.start.left)}, ${Math.round(_??ee.start.top)}`;Q.className="dc-el-resize-readout",Q.textContent=k,Q.style.opacity="1",Q.style.left=`${Math.round(x)}px`,Q.style.top=`${Math.round(R+z)}px`}else Q.style.opacity="0";o.current=re(A)};return o.current=re(A),()=>{if(o.current!=null)ve(o.current)}},[f,i,p]);let y=Vc((g,w)=>{if(g.el.style.width=`${w.width}px`,g.el.style.height=`${w.height}px`,typeof w.left==="number")g.el.style.left=`${w.left}px`;if(typeof w.top==="number")g.el.style.top=`${w.top}px`;g.lastResult=w},[]);return Cs(()=>{let g=n.current;if(!g)return;let w=(b,a)=>{let[x,R]=Ps(a.clientX-b.startClientX,a.clientY-b.startClientY,-b.angle);return jc(b.corner,b.start,x/b.elZoom,R/b.elZoom,{aspect:!!a.shiftKey,center:!b.artboardId&&!!a.altKey},b.flags)},A=(b)=>{let a=b.target;if(!a?.classList.contains("dc-el-resize-handle"))return;let x=a.dataset.corner;if(!x||!i)return;let R=typeof i.id==="string"?i.id:null,j=!R&&typeof i.artboardId==="string"?i.artboardId:null;if(!R&&!j)return;let T=Mn(document,i);if(!T)return;b.preventDefault(),b.stopPropagation();let P=T.getBoundingClientRect(),z=T.offsetWidth?P.width/T.offsetWidth:1,L=getComputedStyle(T),V=!j&&(L.position==="absolute"||L.position==="fixed"),Q=j?Number.NaN:Number.parseFloat(T.style.left),ee=j?Number.NaN:Number.parseFloat(T.style.top),oe=j?0:Is(L.transform),te=z>0?z:1,k=P.left+P.width/2,E=P.top+P.height/2,_={pointerId:b.pointerId,corner:x,el:T,cdId:R??"",artboardId:j,idIndex:R?mr(document,R,T):0,startClientX:b.clientX,startClientY:b.clientY,elZoom:te,angle:oe,cx:k,cy:E,rotStartPointer:_s(k,E,b.clientX,b.clientY),start:{w:(oe?T.offsetWidth:P.width/te)||P.width/te,h:(oe?T.offsetHeight:P.height/te)||P.height/te,left:Q,top:ee},flags:{canMoveLeft:V&&Number.isFinite(Q),canMoveTop:V&&Number.isFinite(ee)},before:{width:T.style.width||null,height:T.style.height||null,left:T.style.left||null,top:T.style.top||null,transform:T.style.transform||null},lastResult:null,lastTransform:null};r.current=_;try{a.setPointerCapture(b.pointerId)}catch{}},m=(b)=>{let a=r.current;if(!a||b.pointerId!==a.pointerId)return;if(b.preventDefault(),a.corner.startsWith("rot-")){let R=`rotate(${Bc(a.angle,a.rotStartPointer,_s(a.cx,a.cy,b.clientX,b.clientY),!!b.shiftKey)}deg)`;a.el.style.transform=R,a.lastTransform=R;return}y(a,w(a,b))},h=(b)=>{let a=r.current;if(!a||b.pointerId!==a.pointerId)return;if(r.current=null,a.corner.startsWith("rot-")){let j=a.lastTransform;if(!j||j===a.before.transform)return;s.current={el:a.el,before:a.before},Qc(a,j);return}let x=a.lastResult??w(a,b);if(!(`${x.width}px`!==a.before.width||`${x.height}px`!==a.before.height||typeof x.left==="number"&&`${x.left}px`!==a.before.left||typeof x.top==="number"&&`${x.top}px`!==a.before.top))return;if(s.current={el:a.el,before:a.before},a.artboardId)Yc(a,x);else Xc(a,x)},S=(b)=>{let a=b.data;if(a?.dgn!=="resize-failed"&&a?.dgn!=="resize-artboard-failed")return;if(b.source!==window.parent)return;let x=s.current;if(!x)return;if(x.el.style.width=x.before.width??"",x.el.style.height=x.before.height??"",x.before.left!==null||x.el.style.left)x.el.style.left=x.before.left??"";if(x.before.top!==null||x.el.style.top)x.el.style.top=x.before.top??"";if(x.before.transform!==null||x.el.style.transform)x.el.style.transform=x.before.transform??"";s.current=null};return g.addEventListener("pointerdown",A),window.addEventListener("pointermove",m),window.addEventListener("pointerup",h),window.addEventListener("pointercancel",h),window.addEventListener("message",S),()=>{g.removeEventListener("pointerdown",A),window.removeEventListener("pointermove",m),window.removeEventListener("pointerup",h),window.removeEventListener("pointercancel",h),window.removeEventListener("message",S)}},[i,y]),Gc("div",{ref:n,"aria-hidden":"true"})}import{jsx as fe,jsxs as Ks,Fragment as md}from"react/jsx-runtime";var td=new Set(["drop-comment","tool","escape","hover"]);function nd(e,t){if(!e)return!0;t();return}function Je(){return typeof document<"u"&&!document.querySelector(".dc-canvas")}function no(e,t){if(typeof document>"u")return null;let n=document.elementFromPoint(e,t);if(!n)return null;if(n.closest(".cm-composer, .cm-thread, .cm-mention-popup, .cm-pin, [data-mc-hover-halo], [data-mc-selection-halo], .dc-el-resize-handle"))return null;let o=n.tagName;if(o==="HTML"||o==="BODY")return null;return n}function od(e,t){let n=no(e,t);if(!n)return null;return n.closest("[data-cd-id]")??n}function rd({children:e,file:t}){let{tool:n,setTool:o,getTool:r}=Wt(),s=zt(),i=ke(null),[c,p]=et(null),f=ke(n);f.current=n;let y=Jc(()=>()=>r?.()??f.current,[r]);xe(()=>{if(n!=="comment")p(null)},[n]);let[g,w]=et(null),[A,m]=et(!1);return xe(()=>{let h=()=>m(Je());h();let S=re(h),b=setTimeout(h,120);return()=>{ve(S),clearTimeout(b)}},[]),xe(()=>{if(typeof document>"u")return;let h=(S)=>{if(S.button!==0||!(S.metaKey||S.ctrlKey))return;if(!Je())return;if(pt(S.target))return;let b=od(S.clientX,S.clientY);if(!b)return;S.preventDefault(),S.stopImmediatePropagation();let a=b.getAttribute("data-cd-id"),x=Rn({el:b,cdId:a,artboardId:null});if(S.shiftKey)s.add(x);else s.replace(x);w(b)};return document.addEventListener("pointerdown",h,!0),()=>document.removeEventListener("pointerdown",h,!0)},[s]),xe(()=>{if(s.selected.length===0)w(null)},[s.selected]),xe(()=>{let h=i.current;if(h)h.setAttribute("data-active-tool",n);if(typeof document<"u"&&document.body)document.body.setAttribute("data-active-tool",n);return()=>{h?.removeAttribute("data-active-tool")}},[n]),xe(()=>{if(typeof window>"u")return;let h=(S)=>{let b=S.data;if(!b||typeof b!=="object"||b.dgn!=="tool-set")return;if(S.source!==window.parent)return;if(typeof b.tool==="string")o(b.tool)};return window.addEventListener("message",h),()=>window.removeEventListener("message",h)},[o]),ys({hostRef:i,getActiveTool:y,claimableActions:td,callbacks:{onHover:({clientX:h,clientY:S})=>{if(f.current!=="comment"||!Je()){p(null);return}let b=no(h,S);p((a)=>a===b?a:b)},onTool:({tool:h})=>o(h),onEscape:()=>nd(Je(),()=>{if(f.current!=="move")o("move");if(p(null),s.clear(),typeof window<"u")try{window.parent.postMessage({dgn:"force-clear"},"*")}catch{}}),onDropComment:({clientX:h,clientY:S})=>ad(h,S,s,t)}}),Ks("div",{"data-mc-host":!0,ref:i,style:{display:"contents"},children:[e,c?fe(id,{el:c}):null,g?fe(sd,{el:g}):null,A?fe(Ls,{}):null,fe(Fr,{})]})}function sd({el:e}){let t=ke(null),n=ke(e);n.current=e;let o=ke(null);return xe(()=>{let r=()=>{o.current=null;let s=t.current,i=n.current;if(s&&i?.isConnected){let c=i.getBoundingClientRect();if(c.width===0&&c.height===0)s.style.display="none";else s.style.display="block",s.style.left=`${Math.round(c.left)}px`,s.style.top=`${Math.round(c.top)}px`,s.style.width=`${Math.round(c.width)}px`,s.style.height=`${Math.round(c.height)}px`}else if(s)s.style.display="none";o.current=re(r)};return o.current=re(r),()=>{if(o.current!=null)ve(o.current)}},[]),fe("div",{ref:t,"aria-hidden":"true","data-mc-selection-halo":"",style:{position:"fixed",display:"none",pointerEvents:"none",zIndex:2147483645,border:"1.5px solid var(--maude-hud-accent, oklch(0.680 0.180 268))",borderRadius:"3px",boxSizing:"border-box"}})}function id({el:e}){let t=ke(null),n=ke(e);n.current=e;let o=ke(null);return xe(()=>{let r=()=>{o.current=null;let s=t.current,i=n.current;if(s&&i?.isConnected){let c=i.getBoundingClientRect();if(c.width===0&&c.height===0)s.style.display="none";else s.style.display="block",s.style.left=`${Math.round(c.left)}px`,s.style.top=`${Math.round(c.top)}px`,s.style.width=`${Math.round(c.width)}px`,s.style.height=`${Math.round(c.height)}px`}else if(s)s.style.display="none";o.current=re(r)};return o.current=re(r),()=>{if(o.current!=null)ve(o.current)}},[]),fe("div",{ref:t,"aria-hidden":"true","data-mc-hover-halo":"",style:{position:"fixed",display:"none",pointerEvents:"none",zIndex:2147483646,border:"2px solid var(--maude-hud-accent, #d63b1f)",borderRadius:"3px",boxSizing:"border-box"}})}function ad(e,t,n,o){if(typeof document>"u")return;let r=No(e,t)??void 0,s=Ko(e,t);if(s){let p=Et(s),f=p?.getBoundingClientRect(),y={file:o,id:void 0,selector:"",artboardId:null,tag:p?.getAttribute("data-tool")??"annotation",classes:"",text:"",dom_path:[],bounds:f?{x:f.left,y:f.top,w:f.width,h:f.height}:{x:e-12,y:t-12,w:24,h:24},html:"",annotationId:s,...r?{world:r}:{}};eo(y,e,t);return}let i=qt(document,e,t,{deep:!0});if(!i)i=qt(document,e,t,{deep:!1});if(!i&&!Je()&&typeof document.elementsFromPoint==="function"){let p=document.elementsFromPoint(e,t);for(let f of p){let y=f.closest?.("[data-cd-id]");if(!y)continue;if(!y.closest(".dc-artboard-body"))continue;let g=y.closest("[data-dc-screen]");i={el:y,cdId:y.getAttribute("data-cd-id"),artboardId:g?.getAttribute("data-dc-screen")??null};break}}if(!i&&Je()){let p=no(e,t);if(p)i={el:p,cdId:p.getAttribute("data-cd-id"),artboardId:null}}if(!i){let p={file:o,id:void 0,selector:"",artboardId:null,tag:"",classes:"",text:"",dom_path:[],bounds:{x:e-12,y:t-12,w:24,h:24},html:"",...r?{world:r}:{}};eo(p,e,t);return}let c=Rn(i,o);n.replace(c),eo(c,e,t)}function eo(e,t,n){if(typeof document<"u")try{document.dispatchEvent(new CustomEvent("cm:open-composer",{detail:{selection:e,clientX:t,clientY:n}}))}catch{}if(typeof window<"u")try{window.parent.postMessage({dgn:"comment-compose",selection:e},"*")}catch{}}function Ns(e,t){return fe(As,{initial:"browse",children:fe(Er,{children:fe(rd,{file:t,children:fe(e,{})})})})}function Xm(e,t){let n=ed(t.rootEl);if(!t.commentsEnabled){n.render(to(e));return}let o=t.file??Tn();n.render(to(pd,{initialCanvas:e,file:o}))}var Os="__maudeCanvasRuntime";function ld({Canvas:e,file:t,onOk:n}){return xe(()=>{n()},[]),Ns(e,t)}class Ds extends Zc{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){this.props.onError(e)}componentDidUpdate(e){if(e.attempt!==this.props.attempt&&this.state.hasError)this.setState({hasError:!1})}render(){if(this.state.hasError)return this.props.fallback();return this.props.children}}var cd=300;function dd(e){let t="";try{t=e instanceof Error?e.message:String(e??"")}catch{}return(t.replace(/\s+/g," ").trim()||"The canvas stopped while drawing.").slice(0,cd)}function ud({message:e}){return to("div",{className:"dc-hmr-holding",role:"status","aria-live":"polite",title:e?`Showing the last version that worked — ${e}`:"Showing the last version that worked"},"This canvas has an error. Showing the last version that worked.")}function pd({initialCanvas:e,file:t}){let[{canvas:n,attempt:o},r]=et({canvas:e,attempt:0}),[s,i]=et({on:!1}),[c,p]=et(!1);xe(()=>{let h=(S)=>{if(S.source!==window.parent)return;if(S.data?.dgn!=="ai-runs")return;let b=St(S,window);if(b&&b.dgn==="ai-runs")p(Object.values(b.artboards).some((a)=>a.state!=="done"))};return window.addEventListener("message",h),()=>window.removeEventListener("message",h)},[]);let f=ke(null),y=ke(null),g=ke(n);g.current=n,xe(()=>{let h={remount:(S)=>r((b)=>({canvas:S,attempt:b.attempt+1})),setHolding:(S,b)=>i(S?{on:!0,message:b,source:"build"}:{on:!1})};return window[Os]=h,()=>{window[Os]=void 0}},[]);let w=Jn(()=>{if(f.current=g.current,y.current=null,t)try{window.parent.postMessage({dgn:"render-ok",file:t},"*")}catch{}if(i((h)=>h.on?{on:!1}:h),o>0&&t)try{window.parent.postMessage({dgn:"loaded",file:t},"*")}catch{}},[o,t]),A=Jn((h)=>{let S=dd(h);if(i({on:!0,message:"render error",source:"render"}),y.current===g.current)return;if(y.current=g.current,t)try{window.parent.postMessage({dgn:"render-error",file:t,message:S},"*")}catch{}},[t]),m=Jn(()=>{let h=f.current;return h?Ns(h,t):null},[t]);return Ks(md,{children:[fe(Ds,{attempt:o,onError:A,fallback:m,children:fe(ld,{Canvas:n,file:t,onOk:w},o)}),s.on&&(s.source!=="render"||c)?fe(ud,{message:s.message}):null]})}export{Ds as CanvasErrorBoundary,nd as commentMountEscape,dd as describeRenderFailure,Je as isBareSpecimen,Xm as mountCanvas,od as pickSpecimenSelectEl};