@1agh/maude 2.0.0-rc.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/apps/studio/acp/index.ts +35 -2
  2. package/apps/studio/acp/login-state.ts +3 -2
  3. package/apps/studio/actions/defs/chat.ts +4 -1
  4. package/apps/studio/actions.manifest.json +1 -1
  5. package/apps/studio/agent-runs.ts +3 -0
  6. package/apps/studio/ai/lease-home.ts +11 -1
  7. package/apps/studio/ai/run-lifecycle.ts +17 -0
  8. package/apps/studio/ai/runs.ts +64 -12
  9. package/apps/studio/api.ts +31 -5
  10. package/apps/studio/bridge/dgn-protocol.ts +13 -0
  11. package/apps/studio/canvas-imports.ts +23 -4
  12. package/apps/studio/canvas-lib.tsx +7 -0
  13. package/apps/studio/client/app.jsx +4 -0
  14. package/apps/studio/client/export-lane.js +4 -2
  15. package/apps/studio/client/fonts/LICENSE-Inter-Tight.txt +93 -0
  16. package/apps/studio/client/fonts/LICENSE-Inter.txt +93 -0
  17. package/apps/studio/client/fonts/LICENSE-JetBrains-Mono.txt +93 -0
  18. package/apps/studio/client/fonts/inter-latin-ext-wght-normal.woff2 +0 -0
  19. package/apps/studio/client/fonts/inter-latin-wght-normal.woff2 +0 -0
  20. package/apps/studio/client/fonts/inter-tight-latin-ext-wght-normal.woff2 +0 -0
  21. package/apps/studio/client/fonts/inter-tight-latin-wght-normal.woff2 +0 -0
  22. package/apps/studio/client/fonts/jetbrains-mono-latin-ext-wght-normal.woff2 +0 -0
  23. package/apps/studio/client/fonts/jetbrains-mono-latin-wght-normal.woff2 +0 -0
  24. package/apps/studio/client/hooks/use-canvas-bridge.jsx +6 -0
  25. package/apps/studio/client/index.html +0 -3
  26. package/apps/studio/client/panels/ChatPanel.jsx +10 -2
  27. package/apps/studio/client/panels/acp-runtime.js +14 -0
  28. package/apps/studio/client/styles/_index.css +2 -0
  29. package/apps/studio/client/styles/fonts.css +63 -0
  30. package/apps/studio/client/system/system-view.jsx +6 -2
  31. package/apps/studio/client/tree-row-menu.jsx +4 -0
  32. package/apps/studio/client/v2/ai/Advanced.jsx +23 -7
  33. package/apps/studio/client/v2/ai/AttachMenu.jsx +4 -0
  34. package/apps/studio/client/v2/ai/ChatList.jsx +7 -1
  35. package/apps/studio/client/v2/ai/ConnectSheet.jsx +75 -4
  36. package/apps/studio/client/v2/ai/NeedsYouSlot.jsx +42 -8
  37. package/apps/studio/client/v2/ai/NotReady.jsx +24 -3
  38. package/apps/studio/client/v2/ai/RunList.jsx +4 -0
  39. package/apps/studio/client/v2/ai/RunSurface.jsx +14 -4
  40. package/apps/studio/client/v2/ai/ScopeChip.jsx +4 -0
  41. package/apps/studio/client/v2/ai/Working.jsx +13 -1
  42. package/apps/studio/client/v2/ai/activity-line.js +390 -0
  43. package/apps/studio/client/v2/ai/activity-store.js +45 -0
  44. package/apps/studio/client/v2/ai/advanced-model.js +62 -12
  45. package/apps/studio/client/v2/ai/ai-list-advanced.css +7 -0
  46. package/apps/studio/client/v2/ai/ai-run.css +19 -0
  47. package/apps/studio/client/v2/ai/ai-send.js +6 -2
  48. package/apps/studio/client/v2/ai/connect-flow.js +29 -8
  49. package/apps/studio/client/v2/ai/needs-you.css +18 -0
  50. package/apps/studio/client/v2/ai/needs-you.js +10 -0
  51. package/apps/studio/client/v2/ai/ring-relay.js +11 -1
  52. package/apps/studio/client/v2/ai/use-activity-line.js +81 -0
  53. package/apps/studio/client/v2/annotations/templates-panel.jsx +4 -0
  54. package/apps/studio/client/v2/assets/kinds-chip.jsx +1 -1
  55. package/apps/studio/client/v2/assets/place-asset.js +20 -1
  56. package/apps/studio/client/v2/assets/tile-menu.jsx +1 -1
  57. package/apps/studio/client/v2/canvases/canvases-panel.jsx +5 -1
  58. package/apps/studio/client/v2/canvases/row-menu.jsx +4 -2
  59. package/apps/studio/client/v2/ds/review.css +2 -0
  60. package/apps/studio/client/v2/empty/ai-drafting.jsx +78 -0
  61. package/apps/studio/client/v2/empty/empty-host.jsx +17 -0
  62. package/apps/studio/client/v2/empty/empty.css +98 -0
  63. package/apps/studio/client/v2/export/advanced/render.jsx +5 -2
  64. package/apps/studio/client/v2/export/export-copy.js +11 -4
  65. package/apps/studio/client/v2/export/export-sheet.jsx +6 -2
  66. package/apps/studio/client/v2/export/exports-model.js +13 -0
  67. package/apps/studio/client/v2/export/exports-panel.jsx +4 -2
  68. package/apps/studio/client/v2/export/job-row.jsx +4 -0
  69. package/apps/studio/client/v2/export/other-formats.jsx +7 -1
  70. package/apps/studio/client/v2/export/sections/batch-model.js +3 -2
  71. package/apps/studio/client/v2/export/sections/batch.jsx +20 -4
  72. package/apps/studio/client/v2/inspector/sections/colour-popover.jsx +4 -0
  73. package/apps/studio/client/v2/inspector/token-chip.jsx +4 -0
  74. package/apps/studio/client/v2/kinds/SizePicker.jsx +4 -0
  75. package/apps/studio/client/v2/presence/faces.jsx +4 -0
  76. package/apps/studio/client/v2/share/role-menu.jsx +7 -1
  77. package/apps/studio/client/v2/share/share-model.js +20 -1
  78. package/apps/studio/client/v2/share/share-sheet.jsx +6 -4
  79. package/apps/studio/client/v2/shell/account-card.jsx +7 -1
  80. package/apps/studio/client/v2/shell/canvas-pointer.js +21 -0
  81. package/apps/studio/client/v2/shell/mode-switch.jsx +4 -0
  82. package/apps/studio/client/v2/shell/project-pill.jsx +4 -0
  83. package/apps/studio/client/v2/shell/save-status.js +10 -1
  84. package/apps/studio/client/v2/shell/share-cluster-host.jsx +2 -0
  85. package/apps/studio/client/v2/shell/share-cluster.jsx +6 -1
  86. package/apps/studio/client/v2/shell/use-dismiss-outside.js +14 -6
  87. package/apps/studio/client/v2/timeline/joins/transition-picker.jsx +7 -1
  88. package/apps/studio/client/v2/undo/undo-history.jsx +7 -1
  89. package/apps/studio/cloud/endpoints.ts +31 -1
  90. package/apps/studio/dist/client.bundle.js +921 -921
  91. package/apps/studio/dist/comment-mount.js +1 -1
  92. package/apps/studio/dist/styles.css +1 -1
  93. package/apps/studio/editing/canvas-pointer.ts +29 -0
  94. package/apps/studio/routes/cloud-move.ts +7 -4
  95. package/apps/studio/sync/ctl-provider.ts +4 -1
  96. package/apps/studio/sync/file-ledger.ts +12 -0
  97. package/apps/studio/sync/file-membership.ts +28 -0
  98. package/apps/studio/sync/file-plane.ts +119 -5
  99. package/apps/studio/sync/index.ts +55 -1
  100. package/apps/studio/sync/journal-client.ts +12 -0
  101. package/apps/studio/sync/poke.ts +30 -0
  102. package/apps/studio/sync/presentation.ts +6 -1
  103. package/apps/studio/sync/projection.ts +7 -0
  104. package/apps/studio/sync/retry-after.ts +27 -0
  105. package/apps/studio/sync/status.ts +9 -1
  106. package/apps/studio/video-play-overlay.tsx +67 -12
  107. package/apps/studio/whats-new.json +78 -6
  108. package/package.json +8 -8
@@ -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),H=(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,q=(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?H(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?H(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?H(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?H(wt)(e):v,Ao=de(0,1e6),Si=(e)=>e===null||wt(e)!==v?e:v,Ei=(e)=>Array.isArray(e)&&e.length<=Mo?H(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:q(200),label:q(200),x:C,y:C,w:C,h:C}),Ii=(e)=>Array.isArray(e)&&e.length<=Ri?H(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?H(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?H(X({from:on,to:on}))(e):v,ji=(e)=>Array.isArray(e)&&e.length<=Vi?H(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:q(200),name:q(120),role:d(q(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:q(512),state:U("here","uploading","waiting","missing"),who:d(Gi),syncing:d(P),progress:d(Ys)}),Ji=(e)=>Array.isArray(e)&&e.length<=Qi?H(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:q(200),element:d(q(200)),occurrence:d(de(1,He))}),ze=(e,t)=>(n)=>Array.isArray(n)&&n.length<=e?t(n):v,ra=X({id:d(q(128)),tag:d(q(24)),text:d(q(160)),selector:d(q(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:q(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(q(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,H(ft)),kinds:mt(gt,16),artboards:ze(200,H(q(128)))})},"annotation-toast":{gate:"active",status:"live",owner:"annotations-layer (S4.12) → shell toast",parse:l({v:U(1),message:q(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(q(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,H(X({id:Ke,label:q(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)?H(se)(e):se(e)),refs:d(H(Ve)),crumbs:d(H(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:H(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:q(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:H(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(H(ge)),dissolve:d(H(ge)),containerId:d(u),children:d(H(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:H(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:H(u)})},"timeline-comps":{gate:"active",status:"live",owner:V,parse:l({comps:H(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},"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,H(Ve)),selection:d(ze(12,H(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:q(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:q(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:H(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(H(Ve)),created:d(H(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:_(q(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:q(200),tag:q(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:q(1024),items:H(X({id:q(128),label:q(200),rect:_(De)}))})},"place-component":{gate:"parent",status:"live",owner:"editing/place-ghost",parse:l({component:ti,label:d(q(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:q(512),natural:d(_(X({w:C,h:C}))),label:d(q(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:q(64),x:C,y:C})},"asset-drop-done":{gate:"parent",status:"live",owner:"editing/image-drop (r3)",parse:l({requestId:q(64),ok:P,created:d(H(Ve)),message:d(q(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,H(q(128))))})},"size-ghost":{gate:"parent",status:"live",owner:"editing/size-ghost (S7.20)",parse:l({preset:_(X({id:q(40),label:q(80),sizeText:q(40),w:C,h:C}))})},"insert-annotation-media":{gate:"parent",status:"live",owner:"annotations-layer",parse:l({paths:H(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:H(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:_(H(Xi))})},"annotation-select":{gate:"parent",status:"live",owner:"annotations-layer (S4.9)",parse:l({v:U(1),ids:H(q(200))})},"annotation-filter":{gate:"parent",status:"live",owner:"annotations-layer (S4.9)",parse:l({v:U(1),authors:H(q(200))})},"export-capture":{gate:"parent",status:"live",owner:"canvas-lib (export)",parse:l({id:u,format:u,artboardIds:H(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:H(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,H(q(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:H(u),tag:_(u)})},"asset-state":{gate:"parent",status:"live",owner:"canvas-lib asset placeholder frame (S8.19, L1)",parse:l({items:Ji})},"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 F=document.querySelector(k.selector);if(F)M=F.tagName.toLowerCase(),K=(F.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((F)=>F+1);else a(0);let K=M?S.current.find((F)=>F.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((F)=>F.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,[F,j]=re(!1);ce(()=>{if(F)x.current?.focus()},[F]);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||F||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 F=ks(M);if(F)S(F);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 F=xs[M];if(!c.some((j)=>j.id===F))return;S(M),A(F),i((j)=>j.locked&&j.tool===F?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,F=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=F===null?z.current!==Ee:F!==Y.mode;F=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 F=K.detail;if(!F||F.from===te.current||typeof F.tool!=="string")return;if(F.tool===k.current)return;let j=b.current;if(j){let Y=et(F.tool,j.caps,j.mode);if(Y&&Y!==j.mode){document.dispatchEvent(new CustomEvent(qt,{detail:{tool:k.current,from:te.current}}));return}}E(F.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,F=document.getElementById("dc-tool-cursor");if(!F)F=document.createElement("style"),F.id="dc-tool-cursor",document.head.appendChild(F);if(x==="browse"){if(document.body.style.cursor="",F.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,F.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 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),H=(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,q=(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?H(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?H(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?H(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?H(wt)(e):v,Ao=de(0,1e6),Si=(e)=>e===null||wt(e)!==v?e:v,Ei=(e)=>Array.isArray(e)&&e.length<=Mo?H(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:q(200),label:q(200),x:C,y:C,w:C,h:C}),Ii=(e)=>Array.isArray(e)&&e.length<=Ri?H(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?H(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?H(X({from:on,to:on}))(e):v,ji=(e)=>Array.isArray(e)&&e.length<=Vi?H(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:q(200),name:q(120),role:d(q(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:q(512),state:U("here","uploading","waiting","missing"),who:d(Gi),syncing:d(P),progress:d(Ys)}),Ji=(e)=>Array.isArray(e)&&e.length<=Qi?H(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:q(200),element:d(q(200)),occurrence:d(de(1,He))}),ze=(e,t)=>(n)=>Array.isArray(n)&&n.length<=e?t(n):v,ra=X({id:d(q(128)),tag:d(q(24)),text:d(q(160)),selector:d(q(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:q(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(q(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,H(ft)),kinds:mt(gt,16),artboards:ze(200,H(q(128)))})},"annotation-toast":{gate:"active",status:"live",owner:"annotations-layer (S4.12) → shell toast",parse:l({v:U(1),message:q(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(q(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,H(X({id:Ke,label:q(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)?H(se)(e):se(e)),refs:d(H(Ve)),crumbs:d(H(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:H(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:q(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:H(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(H(ge)),dissolve:d(H(ge)),containerId:d(u),children:d(H(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:H(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:H(u)})},"timeline-comps":{gate:"active",status:"live",owner:V,parse:l({comps:H(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,H(Ve)),selection:d(ze(12,H(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:q(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:q(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:H(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(H(Ve)),created:d(H(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:_(q(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:q(200),tag:q(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:q(1024),items:H(X({id:q(128),label:q(200),rect:_(De)}))})},"place-component":{gate:"parent",status:"live",owner:"editing/place-ghost",parse:l({component:ti,label:d(q(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:q(512),natural:d(_(X({w:C,h:C}))),label:d(q(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:q(64),x:C,y:C})},"asset-drop-done":{gate:"parent",status:"live",owner:"editing/image-drop (r3)",parse:l({requestId:q(64),ok:P,created:d(H(Ve)),message:d(q(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,H(q(128))))})},"size-ghost":{gate:"parent",status:"live",owner:"editing/size-ghost (S7.20)",parse:l({preset:_(X({id:q(40),label:q(80),sizeText:q(40),w:C,h:C}))})},"insert-annotation-media":{gate:"parent",status:"live",owner:"annotations-layer",parse:l({paths:H(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:H(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:_(H(Xi))})},"annotation-select":{gate:"parent",status:"live",owner:"annotations-layer (S4.9)",parse:l({v:U(1),ids:H(q(200))})},"annotation-filter":{gate:"parent",status:"live",owner:"annotations-layer (S4.9)",parse:l({v:U(1),authors:H(q(200))})},"export-capture":{gate:"parent",status:"live",owner:"canvas-lib (export)",parse:l({id:u,format:u,artboardIds:H(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:H(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,H(q(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:H(u),tag:_(u)})},"asset-state":{gate:"parent",status:"live",owner:"canvas-lib asset placeholder frame (S8.19, L1)",parse:l({items:Ji})},"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 F=document.querySelector(k.selector);if(F)M=F.tagName.toLowerCase(),K=(F.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((F)=>F+1);else a(0);let K=M?S.current.find((F)=>F.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((F)=>F.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,[F,j]=re(!1);ce(()=>{if(F)x.current?.focus()},[F]);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||F||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 F=ks(M);if(F)S(F);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 F=xs[M];if(!c.some((j)=>j.id===F))return;S(M),A(F),i((j)=>j.locked&&j.tool===F?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,F=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=F===null?z.current!==Ee:F!==Y.mode;F=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 F=K.detail;if(!F||F.from===te.current||typeof F.tool!=="string")return;if(F.tool===k.current)return;let j=b.current;if(j){let Y=et(F.tool,j.caps,j.mode);if(Y&&Y!==j.mode){document.dispatchEvent(new CustomEvent(qt,{detail:{tool:k.current,from:te.current}}));return}}E(F.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,F=document.getElementById("dc-tool-cursor");if(!F)F=document.createElement("style"),F.id="dc-tool-cursor",document.head.appendChild(F);if(x==="browse"){if(document.body.style.cursor="",F.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,F.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=`
2
2
  .dc-el-resize-handle {
3
3
  position: fixed;
4
4
  width: 8px;