@1agh/maude 2.2.1 → 2.3.2
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.
- package/apps/studio/acp/agents/auth.ts +241 -0
- package/apps/studio/acp/agents/catalog.ts +308 -0
- package/apps/studio/acp/agents/chat-key.ts +64 -0
- package/apps/studio/acp/agents/conformance.ts +1853 -0
- package/apps/studio/acp/agents/consent.ts +92 -0
- package/apps/studio/acp/agents/descriptor.ts +188 -0
- package/apps/studio/acp/agents/discover.ts +491 -0
- package/apps/studio/acp/agents/e2e-model.ts +58 -0
- package/apps/studio/acp/agents/health.ts +46 -0
- package/apps/studio/acp/agents/link-scan.ts +230 -0
- package/apps/studio/acp/agents/spawn.ts +164 -0
- package/apps/studio/acp/agents/state.ts +132 -0
- package/apps/studio/acp/ask-queue.ts +13 -4
- package/apps/studio/acp/bootstrap-brief.ts +16 -3
- package/apps/studio/acp/bridge.ts +709 -99
- package/apps/studio/acp/env.ts +43 -1
- package/apps/studio/acp/index.ts +428 -43
- package/apps/studio/acp/may-scope.ts +244 -21
- package/apps/studio/acp/policy/agent-home.ts +202 -0
- package/apps/studio/acp/policy/bridge-gate.ts +68 -0
- package/apps/studio/acp/policy/codex-home.ts +228 -0
- package/apps/studio/acp/policy/enforce.ts +620 -0
- package/apps/studio/acp/policy/gate-types.ts +41 -0
- package/apps/studio/acp/policy/launch-codex.ts +351 -0
- package/apps/studio/acp/policy/launch-copilot.ts +119 -0
- package/apps/studio/acp/policy/launch-gemini.ts +120 -0
- package/apps/studio/acp/policy/launch-opencode.ts +131 -0
- package/apps/studio/acp/policy/opencode-user-config.ts +240 -0
- package/apps/studio/acp/probe.ts +78 -14
- package/apps/studio/acp/transcript.ts +14 -0
- package/apps/studio/acp/write-scope.ts +62 -2
- package/apps/studio/annotations-layer.tsx +8 -0
- package/apps/studio/bin/_capture-init.js +5 -0
- package/apps/studio/bin/screenshot.sh +7 -1
- package/apps/studio/bridge/dgn-protocol.ts +3 -2
- package/apps/studio/canvas-shell.tsx +54 -0
- package/apps/studio/client/panels/ChatPanel.jsx +19 -4
- package/apps/studio/client/panels/PermissionPrompt.jsx +11 -6
- package/apps/studio/client/panels/SyncConsentDialog.jsx +4 -1
- package/apps/studio/client/panels/acp-runtime.js +95 -7
- package/apps/studio/client/v2/ai/Advanced.jsx +4 -3
- package/apps/studio/client/v2/ai/AgentNotice.jsx +138 -0
- package/apps/studio/client/v2/ai/AgentOffer.jsx +110 -0
- package/apps/studio/client/v2/ai/AgentPicker.jsx +121 -0
- package/apps/studio/client/v2/ai/Composer.jsx +4 -0
- package/apps/studio/client/v2/ai/ConnectSheet.jsx +13 -0
- package/apps/studio/client/v2/ai/Feed.jsx +8 -0
- package/apps/studio/client/v2/ai/NeedsYouSlot.jsx +24 -1
- package/apps/studio/client/v2/ai/Suggest.jsx +5 -1
- package/apps/studio/client/v2/ai/advanced-model.js +17 -6
- package/apps/studio/client/v2/ai/agents-model.js +333 -0
- package/apps/studio/client/v2/ai/agents-store.js +223 -0
- package/apps/studio/client/v2/ai/ai.css +63 -0
- package/apps/studio/client/v2/ai/needs-you.js +1 -1
- package/apps/studio/client/v2/empty/empty-host.jsx +11 -2
- package/apps/studio/client/v2/empty/use-empty-canvas.js +22 -7
- package/apps/studio/client/v2/fold/fold-store.js +1 -0
- package/apps/studio/client/v2/preview/preview-chrome-host.jsx +1 -0
- package/apps/studio/client/v2/settings/agent-keys.js +88 -0
- package/apps/studio/client/v2/settings/agents-card.jsx +408 -0
- package/apps/studio/client/v2/settings/connections-model.js +1 -1
- package/apps/studio/client/v2/settings/connections-section.jsx +4 -0
- package/apps/studio/client/v2/settings/settings-cards.js +2 -1
- package/apps/studio/client/v2/settings/settings-model.js +1 -0
- package/apps/studio/client/v2/settings/settings.css +7 -0
- package/apps/studio/client/v2/shell/served-routes.js +1 -0
- package/apps/studio/client/v2/undo/zoom-undo.jsx +19 -2
- package/apps/studio/cloud-build.ts +5 -0
- package/apps/studio/comments/reveal.ts +13 -0
- package/apps/studio/comments-overlay.tsx +36 -0
- package/apps/studio/dist/client.bundle.js +535 -535
- package/apps/studio/dist/comment-mount.js +2 -2
- package/apps/studio/dist/styles.css +1 -1
- package/apps/studio/editing/annotation-count.ts +25 -0
- package/apps/studio/editing/empty-report.ts +8 -3
- package/apps/studio/editing/empty-reporter.tsx +10 -1
- package/apps/studio/generation/keys.ts +197 -11
- package/apps/studio/outbox/policy.ts +8 -2
- package/apps/studio/outbox/types.ts +5 -0
- package/apps/studio/routes/agents.ts +479 -0
- package/apps/studio/routes/index.ts +3 -0
- package/apps/studio/scripts/acp-conformance-local.ts +95 -0
- package/apps/studio/scripts/acp-e2e-local.ts +1026 -0
- package/apps/studio/server.ts +9 -0
- package/apps/studio/sync/index.ts +9 -1
- package/apps/studio/sync/writer-registry.ts +12 -0
- package/apps/studio/whats-new.json +19 -0
- package/apps/studio/ws.ts +3 -0
- package/cli/commands/codex.mjs +36 -2
- package/cli/lib/harness/codex-runtime.mjs +98 -11
- package/package.json +9 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Component as Ud,createElement as po,useCallback as co,useEffect as Ee,useMemo as Wd,useRef as Te,useState as ot}from"react";import{createRoot as Xd}from"react-dom/client";function ha(e,t){if(e==="present")return t?.kind==="artboards"?"present-artboards":"present-canvas";return e}var we=(e,t,n,o,r)=>Object.freeze({edit:e,preview:t,"present-artboards":n,"present-canvas":o,viewing:r}),ba=Object.freeze({clicks:we("tool","live","next-artboard","pan-zoom","specs"),toolbar:we("edit","preview","none","none","viewing"),annotations:we("quiet","drawn","hidden","hidden","read-only"),"comment-pins":we("shown","shown","hidden","hidden","shown"),measure:we("on","on","off","off","on"),"ai-changes":we("live","live","held","live-unmarked","live"),"left-panels":we("shown","shown","hidden","hidden","shown"),"ai-panel":we("shown","shown","hidden","hidden","none"),"share-cluster":we("full","full","hidden","hidden","full-access"),inspect:we("inspector","panel-on-cmd-click","hidden","hidden","panel-on-click"),"project-menu":we("pill","pill","esc-first","esc-first","pill"),esc:we("steps-back","steps-back","settles-back","same-view","deselect")});function Ve(e,t,n){return ba[e][ha(t,n)]}var ya=Object.freeze({measure:(e,t)=>Ve("measure",e,t)==="on","inspect-panel":(e,t)=>Ve("inspect",e,t).startsWith("panel"),"comment-pins":(e,t)=>Ve("comment-pins",e,t)==="shown","object-tools":(e,t)=>Ve("clicks",e,t)==="tool","live-design":(e,t)=>Ve("clicks",e,t)==="live","annotations-editable":(e,t)=>Ve("annotations",e,t)==="drawn",chrome:(e,t)=>Ve("share-cluster",e,t)!=="hidden"});function yt(e,t,n){if(!e)return t==="measure"||t==="comment-pins"||t==="object-tools";return ya[t](e,n)}var nn=["edit","viewing","preview","present"],bo=["artboards","canvas"],on=["browse","move","hand","comment","pen","highlighter","eraser","shape","sticky","section","arrow","text"],wa=["inspect","frame","el-shape","el-pen","el-text","image","component","line","ellipse","polygon","crop","slice","pointer"],rn=[...on,...wa],uu=new Set(nn),va=new Set(rn);var xa=(e)=>typeof e==="string"&&va.has(e),pu=Object.freeze({edit:!1,annotate:!1,comment:!1}),yo=Object.freeze({edit:!0,annotate:!0,comment:!0}),wo=(e)=>e.edit?"edit":"viewing";function vo(e,t){if(e==="edit"&&!t.edit)return"viewing";if(e==="viewing"&&t.edit)return"edit";return e}var xo=Object.freeze({edit:"edit",viewing:"edit",preview:"preview",present:"preview"}),sn=Object.freeze({edit:"move",viewing:"inspect",preview:"browse",present:"browse"}),go=Object.freeze({view:0,comment:1,edit:2});function ka(e){if(e.edit||e.annotate)return"edit";return e.comment?"comment":"view"}var J=(e)=>Object.freeze(e),st=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"})])})}),an=Object.freeze({});function ko(e,t){if(t(e))return e;let n=an[e];return n&&t(n)?n:null}var Sa=Object.freeze({edit:["preview"],preview:["edit"],viewing:["preview","edit"],present:[]});function Ea(e,t){for(let n of[e,...Sa[e]]){let o=st[n].slots.find((r)=>r.key===t);if(o)return{mode:n,slot:o}}return null}function So(e,t,n,o){let r=Ea(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,u=ka(n);if(go[u]<go[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 m={kind:"request",mode:r.mode};if(c)m.tool=c;if(a&&s.panel)m.panel=s.panel;return m}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 Ta=new Set(["hand"]);function ho(e,t){return st[e].slots.some((n)=>n.tool===t||n.tool!==null&&an[n.tool]===t||!!n.tips?.includes(t)||!!n.lights?.includes(t)||!!n.more?.some((o)=>o.tool===t))}function at(e,t,n){if(!xa(e)||Ta.has(e))return null;if(ho(n,e))return n;if(e==="move")return t.edit?"edit":"viewing";for(let o of["preview","edit"])if(ho(o,e))return o;return null}function ln(e,t){if(e==="present")return"back";let n=st[e].rest;if(t!==n&&an[n]!==t)return"rest";return"stay"}var cn=Object.freeze({top:0,right:0,bottom:0,left:0});function Eo(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 To(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}function Ro(e){if(!e||typeof e!=="object"||Array.isArray(e))return null;let{left:t,right:n}=e;if(typeof t!=="number"||typeof n!=="number")return null;if(!Number.isFinite(t)||!Number.isFinite(n))return null;let o=Math.round(t),r=Math.round(n);if(o<0||r>8192||!(o<r))return null;return{left:o,right:r}}var Ra=["image/png","image/jpeg","image/gif","image/webp"],Aa=new Set(["dgn","v","text","html","image"]),Ao=(e)=>typeof e==="string"&&e.length<=1e6,Ma=(e)=>typeof Blob<"u"&&e instanceof Blob&&Ra.includes(e.type)&&e.size>0&&e.size<=20971520;function Mo(e){if(!e||typeof e!=="object"||Array.isArray(e))return null;let t=e;for(let o of Object.keys(t))if(!Aa.has(o))return null;if(t.v!==1)return null;let n={v:1};if(t.text!==void 0){if(!Ao(t.text))return null;n.text=t.text}if(t.html!==void 0){if(!Ao(t.html))return null;n.html=t.html}if(t.image!==void 0){if(!Ma(t.image))return null;n.image=t.image}return n.text||n.html||n.image?n:null}var wt=(e)=>{if(e instanceof Uint8Array)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(e&&typeof e==="object"&&Object.prototype.toString.call(e)==="[object ArrayBuffer]")return new Uint8Array(e);return null},Xe=(e,t)=>String.fromCharCode(e[t],e[t+1],e[t+2],e[t+3]),dn=(e,t)=>(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0,Co=(e,t)=>e[t]|e[t+1]<<8|e[t+2]<<16;function Ca(e){let t=wt(e);if(!t)return{ok:!1,reason:"not-bytes"};if(t.length===0)return{ok:!1,reason:"empty"};if(t.length>262144)return{ok:!1,reason:"too-large"};if(t.length<30||Xe(t,0)!=="RIFF"||Xe(t,8)!=="WEBP")return{ok:!1,reason:"not-webp"};let n=dn(t,4);if(n+8!==t.length&&n+9!==t.length)return{ok:!1,reason:"bad-size"};let o=Xe(t,12),r=dn(t,16);if(r<10||20+r>t.length)return{ok:!1,reason:"bad-chunk"};let s=0,a=0;if(o==="VP8 "){if((t[20]&1)!==0||t[23]!==157||t[24]!==1||t[25]!==42)return{ok:!1,reason:"bad-chunk"};s=(t[26]|t[27]<<8)&16383,a=(t[28]|t[29]<<8)&16383}else if(o==="VP8L"){if(t[20]!==47)return{ok:!1,reason:"bad-chunk"};let c=dn(t,21);if(s=(c&16383)+1,a=(c>>>14&16383)+1,c>>>29!==0)return{ok:!1,reason:"bad-chunk"}}else if(o==="VP8X"){if((t[20]&2)!==0)return{ok:!1,reason:"animated"};s=Co(t,24)+1,a=Co(t,27)+1}else return{ok:!1,reason:"bad-chunk"};if(!(s>0&&a>0))return{ok:!1,reason:"bad-chunk"};if(s>401||a>1601)return{ok:!1,reason:"too-big"};return{ok:!0,w:s,h:a}}var Io=[137,80,78,71,13,10,26,10],un=(e,t)=>(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0,Ia=new Set(["sRGB","gAMA","cHRM","pHYs","sBIT","bKGD","tRNS","eXIf"]),Pa=new Set(["acTL","fcTL","fdAT"]),_a={0:[1,2,4,8,16],2:[8,16],3:[1,2,4,8],4:[8,16],6:[8,16]};function La(e){let t=wt(e);if(!t)return{ok:!1,reason:"not-bytes"};if(t.length===0)return{ok:!1,reason:"empty"};if(t.length>262144)return{ok:!1,reason:"too-large"};if(t.length<45||Io.some((m,h)=>t[h]!==m))return{ok:!1,reason:"not-png"};let n=8,o=!0,r=0,s=0,a=!1,c=!1,u="none";for(;;){let m=t.length-n;if(m<12)return{ok:!1,reason:"bad-chunk"};let h=un(t,n);if(h>m-12)return{ok:!1,reason:"bad-chunk"};let f=Xe(t,n+4),w=n+8;if(!/^[A-Za-z]{4}$/.test(f))return{ok:!1,reason:"bad-chunk"};if(o){if(f!=="IHDR"||h!==13)return{ok:!1,reason:"bad-chunk"};r=un(t,w),s=un(t,w+4);let M=t[w+8],g=t[w+9];if(!(_a[g]??[]).includes(M))return{ok:!1,reason:"bad-chunk"};if(t[w+10]!==0||t[w+11]!==0||t[w+12]!==0)return{ok:!1,reason:"bad-chunk"};if(!(r>0&&s>0))return{ok:!1,reason:"bad-chunk"};if(r>401||s>1601)return{ok:!1,reason:"too-big"};a=g===3,o=!1}else if(f==="IEND"){if(h!==0||u==="none"||a&&!c)return{ok:!1,reason:"bad-chunk"};if(w+4!==t.length)return{ok:!1,reason:"bad-size"};return{ok:!0,w:r,h:s}}else if(f==="IDAT"){if(u==="done")return{ok:!1,reason:"bad-chunk"};u="in"}else if(Pa.has(f))return{ok:!1,reason:"animated"};else if(f==="PLTE"||Ia.has(f)){if(u==="in")u="done";if(f==="PLTE"){if(c||u!=="none"||h===0||h>768||h%3!==0)return{ok:!1,reason:"bad-chunk"};c=!0}}else return{ok:!1,reason:"bad-chunk"};n=w+h+4}}function Oa(e){let t=wt(e);if(t&&t.length>=8&&Io.every((n,o)=>t[o]===n)){let n=La(t);return n.ok?{ok:!0,format:"png",w:n.w,h:n.h}:n}if(t&&t.length>=12&&Xe(t,0)==="RIFF"&&Xe(t,8)==="WEBP"){let n=Ca(t);return n.ok?{ok:!0,format:"webp",w:n.w,h:n.h}:n}if(!t)return{ok:!1,reason:"not-bytes"};if(t.length===0)return{ok:!1,reason:"empty"};if(t.length>262144)return{ok:!1,reason:"too-large"};return{ok:!1,reason:"not-image"}}function Po(e){if(!Oa(e).ok)return null;return wt(e).slice().buffer}var Na=/^data:image\/(?:png|webp|jpeg|gif);base64,[A-Za-z0-9+/]+={0,2}$/;function _o(e){return typeof e==="string"&&e.length<=400000&&Na.test(e)}var Da=["frame","text","image","path","shape","instance","artboard","multi"],v=Symbol("dgn.bad"),Et=4000,$e=1e4,Ka=16,xe=(e)=>!!e&&typeof e==="object"&&!Array.isArray(e),p=(e)=>typeof e==="string"&&e.length<=Et?e:v,P=(e)=>typeof e==="number"&&Number.isFinite(e)?e:v,fn=(e)=>typeof e==="number"&&Number.isFinite(e)&&e>=0&&e<=1?e:v,_=(e)=>typeof e==="boolean"?e:v,za=(e)=>_o(e)?e:v,Lo=(e)=>typeof e==="number"&&Number.isFinite(e)&&e>=0&&e<=86400?e:v,Va=(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]},V=(...e)=>(t)=>e.includes(t)?t:v,d=(e)=>(t)=>t===void 0?void 0:e(t),Fa=(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,Ce=(e)=>typeof e==="string"&&/^[A-Za-z0-9_-]{1,64}$/.test(e)?e:v,O=(e)=>(t)=>t===null?null:e(t),q=(e)=>(t)=>{if(!Array.isArray(t)||t.length>$e)return v;let n=[];for(let o of t){let r=e(o);if(r===v)return v;n.push(r)}return n},ve=(e)=>gn(e,0);function gn(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<=Et?e:v;if(t>=Ka||typeof e!=="object")return v;if(Array.isArray(e)){if(e.length>$e)return v;let r=[];for(let s of e){let a=gn(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>$e||r.length>Et)return v;let s=gn(e[r],t+1);if(s===v)return v;if(s!==void 0)n[r]=s}return n}var ae=(e)=>xe(e)?ve(e):v,Oo=(e)=>{if(!xe(e))return v;let t={},n=Object.keys(e);if(n.length>$e)return v;for(let o of n){let r=p(e[o]);if(r===v||o.length>Et)return v;t[o]=r}return t},Ha=256,vt=(e,t=Ha)=>(n)=>{if(!xe(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},xt=(e)=>typeof e==="string"&&/^[A-Za-z0-9_-]{1,64}$/.test(e)?e:v,D=(e)=>(t)=>typeof t==="string"&&t.length<=e?t:v,$a=(e)=>typeof e==="string"&&/^[A-Z][A-Za-z0-9]{0,63}$/.test(e)?e:v,No=(e)=>typeof e==="string"&&/^[a-z][a-z0-9-]{0,40}$/.test(e)?e:v,kt=(e)=>typeof e==="number"&&Number.isSafeInteger(e)&&e>=0&&e<=9999?e:v,W=(e)=>(t)=>{if(!xe(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},pe=(e,t)=>(n)=>typeof n==="number"&&Number.isInteger(n)&&n>=e&&n<=t?n:v,hn=(e)=>typeof e==="string"&&/^[\w-]{1,64}$/.test(e)?e:v,Fe=W({x:P,y:P,w:P,h:P}),ja=512,Vo=(e)=>{if(typeof e!=="string"||e.length<5||e.length>ja)return v;if(/[\u0000-\u001f\u007f]/.test(e)||e.split("|").length<3)return v;return e},qa=200,Fo=(e)=>typeof e==="string"&&e.length>0&&e.length<=qa&&!/[\u0000-\u001f\u007f]/.test(e)?e:v,Ho=(e)=>typeof e==="number"&&Number.isFinite(e)&&e>=1&&e<=8?e:v,$o=(e)=>Array.isArray(e)&&e.length===2&&fn(e[0])!==v&&fn(e[1])!==v?[e[0],e[1]]:v,Ba=(e)=>xe(e)&&typeof e.w==="number"&&typeof e.h==="number"&&e.w>0&&e.h>0&&e.w<=65536&&e.h<=65536?{w:e.w,h:e.h}:v,Ua=(e)=>{if(!Array.isArray(e)||e.length>Xo)return v;let t=W({clientID:pe(0,Number.MAX_SAFE_INTEGER),name:(o)=>typeof o==="string"&&o.length<=Yo?o:v,artboardId:Ce,frame:d(pe(0,1e7)),word:d(Vo)}),n=[];for(let o of e){if(!xe(o))return v;let r=t(o);if(r===v)return v;n.push(r)}return n},pn=(e)=>typeof e==="string"&&/^#[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$/.test(e)?e:v,jo=W({stickyColor:d(pn),ink:d(pn),thickness:d(V(3,6)),tip:d(V("pen","highlighter","eraser")),highlighterColor:d(pn),highlighterWidth:d(pe(1,64))}),St=V(...nn),bn=V(...rn),yn=W({kind:V(...bo),from:d(p),only:d(V("formats"))}),Wa=W({edit:_,annotate:_,comment:_,present:d(_)}),Xa=/^[a-z0-9]{8,32}$/,wn=(e)=>typeof e==="string"&&Xa.test(e)?e:v,Ya=64,Qa=(e)=>typeof e==="string"&&e.length<=Ya?e:v,Ga=(e)=>To(e)??v,Za=(e)=>e===void 0?void 0:Ro(e)??void 0,Ja=/^(?!\/)(?!.*\.\.)[A-Za-z0-9_][A-Za-z0-9 ._/-]{0,255}\.css$/,Tt=(e)=>typeof e==="string"&&Ja.test(e)?e:v,ei=/^(?:head|[0-9a-f]{64})$/,qo=16,Bo=(e)=>typeof e==="string"&&ei.test(e)?e:v,ti=(e)=>Array.isArray(e)&&e.length<=qo?q(Bo)(e):v,ni=200,oi=/^[A-Za-z0-9_.:-]{1,128}$/,Rt=(e)=>typeof e==="string"&&oi.test(e)?e:v,ri=(e)=>Array.isArray(e)&&e.length<=ni?q(Rt)(e):v,si=V("light","dark"),ai=200,ii=/^--[A-Za-z0-9_-]{1,128}$/,li=(e)=>typeof e==="string"&&ii.test(e)?e:v,Do=(e)=>Array.isArray(e)&&e.length<=ai?q(li)(e):v,ci=["brand","colour","type","space","motion","components","patterns"],di=V("waiting","drawing","done"),ui=(e)=>{if(!xe(e))return v;let t={};for(let n of Object.keys(e)){if(!ci.includes(n))return v;let o=di(e[n]);if(o===v)return v;t[n]=o}return t},Uo=500,pi=(e)=>Array.isArray(e)&&e.length<=Uo?q(Rt)(e):v,Wo=pe(0,1e6),mi=(e)=>e===null||Rt(e)!==v?e:v,fi=(e)=>Array.isArray(e)&&e.length<=Uo?q(W({id:Rt,x:P,y:P,w:P,h:P}))(e):v,gi=W({tokens:Tt,components:O(Tt)}),hi=(e)=>{if(!xe(e))return v;let t=Object.keys(e);if(t.length>qo)return v;let n=Object.create(null);for(let o of t){if(Bo(o)===v)return v;let r=gi(e[o]);if(r===v)return v;n[o]=r}return n},bi=(e)=>typeof e==="string"&&/^[A-Za-z_][\w-]{0,63}$/.test(e)?e:v,yi=2000,wi=W({id:D(200),label:D(200),x:P,y:P,w:P,h:P}),vi=(e)=>Array.isArray(e)&&e.length<=yi?q(wi)(e):v,xi=500,Xo=32,Yo=64,ki=/^(#[0-9a-f]{3,8}|oklch\([0-9.%\s/-]{1,40}\))$/i,Si=/^[A-Za-z0-9_-]{1,64}$/,Ei=["owner","member","viewer","observer"],Ti=(e)=>{if(!Array.isArray(e)||e.length>Xo)return v;let t=[];for(let n of e){if(!xe(n))return v;let{clientID:o,name:r,color:s,following:a,artboard:c,idleSince:u,surface:m,inComments:h,role:f}=n;if(typeof o!=="number"||!Number.isSafeInteger(o)||o<0)return v;if(typeof r!=="string"||r.length>Yo)return v;if(s!==void 0&&(typeof s!=="string"||!ki.test(s)))return v;if(a!==void 0&&typeof a!=="boolean")return v;if(c!==void 0&&(typeof c!=="string"||!Si.test(c)))return v;if(u!==void 0&&(typeof u!=="number"||!Number.isSafeInteger(u)||u<=0))return v;if(m!==void 0&&m!=="browser")return v;if(h!==void 0&&typeof h!=="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(u!==void 0)w.idleSince=u;if(m==="browser")w.surface="browser";if(h===!0)w.inComments=!0;if(Ei.includes(f))w.role=f;t.push(w)}return t},Ri=120,Ai=256,Ye=(e)=>typeof e==="string"&&e.length<=Ri?e:v,Mi=(e)=>Array.isArray(e)&&e.length<=Ai?q(W({artboard:Ye,element:Ye,occurrence:d((t)=>typeof t==="number"&&Number.isInteger(t)&&t>=0&&t<1e4?t:v),tag:Ye,mine:_,scope:d(_),point:d(_)}))(e):v,Ci=8,Ii=40,mn="[A-Za-z0-9_.:-]{1,128}",Pi=new RegExp(`^(?:ab:${mn}|el:${mn}/${mn})$`),_i=20,Li=(e)=>Array.isArray(e)&&e.length<=_i?q(W({from:hn,to:hn}))(e):v,Oi=(e)=>Array.isArray(e)&&e.length<=Ci?q(W({ref:(t)=>typeof t==="string"&&Pi.test(t)?t:v,tag:(t)=>typeof t==="string"&&t.length<=Ii?t:v}))(e):v,Ni=["add","reply","resolve","reopen","edit-own","delete-own","reattach"],Di=["to-sticky","convert-undo","convert-undoable"],it=(e)=>typeof e==="string"&&e.length>0&&e.length<=64||typeof e==="number"&&Number.isSafeInteger(e)?e:v,Ki=(e)=>{if(!xe(e))return v;if(Di.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(!Ni.includes(e.op))return v;return ve(e)},zi=W({id:D(200),name:D(120),role:d(D(40))}),Vi=256,Fi=64,Hi=W({name:O((e)=>typeof e==="string"&&e.length<=Fi&&!e.includes("@")?e:v),kind:O(V("mac","pc","linux")),self:_}),$i=W({rel:D(512),state:V("here","uploading","waiting","missing","lfs-pointer"),localObject:d(_),who:d(Hi),syncing:d(_),progress:d(fn)}),ji=(e)=>Array.isArray(e)&&e.length<=Vi?q($i)(e):v,qi=256,Bi=/^assets\/[0-9a-f]{8}\.[A-Za-z0-9]{1,8}$/,Ui=(e)=>Array.isArray(e)&&e.length<=qi&&e.every((t)=>typeof t==="string"&&Bi.test(t))?e.slice():v,Qo=(e)=>Po(e)??v,Go=(e)=>typeof e==="string"&&e.length>=1&&e.length<=200&&!/[\u0000-\u001f\u007f]/.test(e)?e:v,Zo=200,Wi=2000;function l(e){let t=W(e);return(n)=>{let o=t(n);return o===v?null:o}}var fe=(e)=>xe(e)?{}:null,Ko={refId:d(p),refIndex:d(P),artboardId:d(O(p)),position:d(p)},Ie={id:d(p)},He=W({artboard:p,element:p,occurrence:d(P)}),Xi=W({kind:V("picture","frame","artboard"),artboard:D(200),element:d(D(200)),occurrence:d(pe(1,$e))}),_e=(e,t)=>(n)=>Array.isArray(n)&&n.length<=e?t(n):v,Yi=W({id:d(D(128)),tag:d(D(24)),text:d(D(160)),selector:d(D(200)),index:d(P)}),Qi=W({label:p,ref:O(He)}),Gi=["held-by-ai","locked","stale","invalid","forbidden"],H="h/use-canvas-bridge",ce="canvas-shell",vn={loaded:{gate:"any",status:"live",owner:H,parse:l({file:p})},"canvas-rendered":{gate:"active",status:"live",owner:H,parse:l({file:p})},"canvas-failed":{gate:"active",status:"live",owner:H,parse:l({file:p})},"canvas-mounted":{gate:"any",status:"legacy",owner:"tpl/_shell.html (probe)",orphan:"no-handler",parse:l({file:p,children:P})},"render-error":{gate:"frame",status:"live",owner:"v2/create/use-render-error",parse:l({file:p,message:D(600)})},"render-ok":{gate:"frame",status:"live",owner:"v2/create/use-render-error",parse:l({file:p})},"ds-review":{gate:"active",status:"live",owner:"h/use-ds-frames",parse:fe},"copy-canvas-path":{gate:"active",status:"live",owner:H,parse:fe},"ds-rects-result":{gate:"frame",status:"live",owner:"v2/ds/reach-view",parse:l({seq:Wo,view:W({w:P,h:P}),label:d(D(120)),rects:fi})},"ds-pins-want":{gate:"active",status:"live",owner:"v2/ds/pins",parse:l({revs:ti})},"canvas-expired":{gate:"frame",status:"live",owner:"h/use-shell-core",parse:fe},"annotations-changed":{gate:"active",status:"live",orphan:"no-handler",owner:"annotations-layer (S4.9) → annotation-list (S4.17)",parse:l({file:p})},"annotation-to-comment":{gate:"active",status:"live",owner:"annotations-layer (S4.12) → shell convert (routes/annotations.ts, S4.7)",parse:l({id:xt})},"annotation-selection":{gate:"active",status:"live",owner:"annotations-layer (S4.12) → AI scope chip (S4.15, S5.8)",parse:l({ids:_e(500,q(xt)),kinds:vt(kt,16),artboards:_e(200,q(D(128)))})},"annotation-toast":{gate:"active",status:"live",owner:"annotations-layer (S4.12) → shell toast",parse:l({v:V(1),message:D(300),undo:_})},"annotation-ask-ai":{gate:"active",status:"live",owner:"annotations-layer (S4.12) → shell AI chat",parse:l({v:V(1)})},"object-history":{gate:"active",status:"live",owner:"editing/object-menu.tsx + annotations-layer (sticky menu) → shell history.object",parse:l({artboard:d(Ce),element:d(D(128)),annotation:d(xt)})},"view-only-gesture":{gate:"active",status:"live",owner:"view-only-gesture (S9.21b) → shell access host tip",parse:l({v:V(1),x:d(pe(0,16384)),y:d(pe(0,16384))})},"vote-cast":{gate:"active",status:"live",owner:"annotations/ui/vote-dots (S4.14) → shell vote store (routes/votes.ts)",parse:l({artboard:Ce,remove:d(_)})},"vote-board":{gate:"active",status:"live",owner:"annotations/ui/vote-dots + editing/artboard-menu (S4.14) → shell vote sheet",parse:l({artboards:_e(200,q(W({id:Ce,label:D(120),x:P,y:P,w:P,h:P}))),open:d(_),focus:d(Ce)})},"annotations-visibility":{gate:"active",status:"live",owner:"annotations-layer ⇧P (S4.18) → shell use-photo-and-timeline",parse:l({v:V(1),visible:_})},"canvas-notice":{gate:"active",status:"live",owner:"canvas-notice-message",parse:l({message:p,kind:V("info","success","error","warning","undo")})},"embed-escape":{gate:"active",status:"live",owner:"c/embed-view",parse:fe},"select-set":{gate:"active",status:"live",owner:H,parse:l({selection:O((e)=>Array.isArray(e)?q(ae)(e):ae(e)),refs:d(q(He)),crumbs:d(q(Qi)),kind:d(V(...Da))})},"edit-text":{gate:"active",status:"live",owner:H,parse:l({id:p,file:p,text:p,occurrence:d(P),before:d(p)})},"apply-edit":{gate:"active",status:"live",owner:"client/apply-edit-request",parse:l({requestId:p,op:ve,canvas:d(ve),id:d(ve),key:d(ve),value:d(ve),from:d(ve),occurrence:d(ve)})},"undo-barrier":{gate:"active",status:"live",owner:H,parse:l({requestId:p})},"undo-key":{gate:"active",status:"live",owner:"v2/undo/use-undo-mode-lane (S2.20b)",parse:l({redo:_})},"take-step":{gate:"active",status:"live",owner:"v2/assets/takes (S8.16)",parse:l({dir:V("next","prev")})},"edit-op":{gate:"active",status:"live",owner:"editing (S2.1)",parse:l({requestId:p,op:p,targets:q(He),params:d(ae),expectRev:d(p)})},"asset-drop-target":{gate:"active",status:"live",owner:"client/v2/assets/canvas-drop-catcher (r3)",parse:l({requestId:D(64),target:O(Xi)})},"active-artboard":{gate:"active",status:"live",owner:H,parse:l({id:O(p)})},"reorder-slot":{gate:"active",status:"live",owner:"editing/reorder-slot",parse:(e)=>{let t=l({index:pe(0,$e),total:pe(0,$e),parentId:d(hn)})(e);if(!t||t.index>t.total)return null;if(t.index>0&&t.parentId===void 0)return null;return t}},"layers-tree":{gate:"active",status:"live",owner:H,parse:l({artboardId:O(p),tree:q(ae)})},"open-inspector":{gate:"active",status:"live",owner:H,parse:l({tab:d(p)})},"copy-style":{gate:"active",status:"live",owner:H,parse:fe},"paste-style":{gate:"active",status:"live",owner:H,parse:l({id:p})},"insert-request":{gate:"active",status:"live",owner:H,parse:l({...Ko,kind:V("div","text","image"),src:d(p)})},"insert-image-request":{gate:"active",status:"live",owner:H,parse:l(Ko)},"delete-request":{gate:"active",status:"live",owner:H,parse:l({id:p,idIndex:d(P)})},"duplicate-request":{gate:"active",status:"live",owner:H,parse:l({id:p,idIndex:d(P)})},"reorder-request":{gate:"active",status:"live",owner:H,parse:l({id:p,refId:p,position:p,idIndex:d(P),refIndex:d(P)})},"reorder-revert":{gate:"active",status:"live",owner:H,parse:l({seq:P,dir:V("undo","redo")})},"reposition-request":{gate:"active",status:"live",owner:H,parse:l({id:p,left:p,top:p,beforeLeft:d(p),beforeTop:d(p),idIndex:d(P)})},"resize-request":{gate:"active",status:"live",owner:H,parse:l({id:p,patch:Oo,before:d(Oo),idIndex:d(P)})},"replace-media-request":{gate:"active",status:"live",owner:H,parse:l({id:p,before:d(p)})},"convert-to-absolute-request":{gate:"active",status:"live",owner:H,parse:l({artboardId:d(p),allowShared:d(_),containers:d(q(ve)),dissolve:d(q(ve)),containerId:d(p),children:d(q(ve)),containerSetRelative:d(_)})},"delete-artboard-request":{gate:"active",status:"live",owner:H,parse:l({artboardId:p})},"duplicate-artboard-request":{gate:"active",status:"live",owner:H,parse:l({artboardId:p,width:d(P)})},"rename-artboard-request":{gate:"active",status:"live",owner:H,parse:l({artboardId:p,label:p})},"resize-artboard-request":{gate:"active",status:"live",owner:H,parse:l({artboardId:p,width:P,height:P})},"set-artboard-kind-request":{gate:"active",status:"live",owner:H,parse:l({artboardId:p,kind:O(p)})},"open-timeline-request":{gate:"active",status:"live",owner:H,parse:l({artboardId:p})},"replace-annotation-media-request":{gate:"active",status:"live",owner:H,parse:l({id:p,before:d(p)})},"edit-annotation-photo-request":{gate:"active",status:"live",owner:H,parse:l({id:p,asset:p})},"comment-compose":{gate:"active",status:"live",owner:H,parse:l({selection:ae})},"comment-submit":{gate:"active",status:"live",owner:H,parse:l({payload:ae})},"comment-patch":{gate:"active",status:"live",owner:H,parse:l({id:p,patch:ae})},"comment-delete":{gate:"active",status:"live",owner:H,parse:l({id:p})},"comment-click":{gate:"active",status:"live",owner:H,parse:l({id:p})},"comment-op":{gate:"active",status:"live",owner:"v2/comments/comment-bridge (S9.22)",parse:l({reqId:it,op:Ki})},"comment-people-request":{gate:"active",status:"live",owner:"v2/comments/comment-bridge (S9.22)",parse:l({reqId:it})},"export-request":{gate:"active",status:"live",owner:H,orphan:"no-sender",parse:l({id:p,payload:ae})},"export-history-request":{gate:"active",status:"live",owner:H,orphan:"no-sender",parse:l({id:p})},"open-export":{gate:"active",status:"legacy",owner:H,parse:l({detail:ae})},"export-capture-progress":{gate:"asked",status:"live",owner:"h/use-shell-core",parse:l({id:p,current:P,total:P})},"export-capture-done":{gate:"asked",status:"live",owner:"h/use-shell-core",parse:l({id:p,items:q(ae)})},"export-capture-error":{gate:"asked",status:"live",owner:"h/use-shell-core",parse:l({id:p,message:p})},"export-selection":{gate:"asked",status:"live",owner:"c/app",parse:l({id:p,selectors:q(p)})},"timeline-comps":{gate:"active",status:"live",owner:H,parse:l({comps:q(ae)})},"timeline-frame":{gate:"active",status:"live",owner:H,parse:l({...Ie,frame:P})},"timeline-ended":{gate:"active",status:"live",owner:H,parse:l(Ie)},"timeline-playing":{gate:"active",status:"live",owner:"v2/timeline (S7.8)",parse:l({...Ie,playing:_})},key:{gate:"active",status:"live",owner:"actions/registry (V2-1.3)",parse:l({v:V(1),chord:p,hint:d(W({artboardId:d(p)}))})},"tool-cursor":{gate:"active",status:"live",owner:H,parse:l({tool:p})},peers:{gate:"active",status:"live",owner:"v2/shell/use-canvas-mode-lane (V2-4.3b)",parse:l({peers:Ti})},"hold-view":{gate:"active",status:"live",owner:"v2/inspector/view-mode (S2.18)",parse:l({person:O(W({name:Ye})),label:Ye,ai:O(W({label:Ye,held:_,mine:_}))})},select:{gate:"active",status:"legacy",owner:H,orphan:"no-sender",parse:l({selection:ae})},"clear-select":{gate:"active",status:"legacy",owner:H,orphan:"no-sender",parse:fe},artboards:{gate:"active",status:"live",owner:"v2/empty (S11.2); the shell bridge keeps the Layers count",parse:l({count:P})},"artboard-empty":{gate:"active",status:"live",owner:"v2/empty (S11.2)",parse:l({artboardId:O(p),rect:O(Fe),label:d(p),from:d(p)})},"artboard-anchor":{gate:"active",status:"live",owner:"v2/timeline (S7.7)",parse:l({artboardId:O(p),kind:d(p),label:d(p),rect:d(O(Fe))})},"artboard-live-size":{gate:"active",status:"live",owner:"v2/inspector live size (P8 c6)",parse:l({id:O(p),w:d(P),h:d(P),preset:d(O(p))})},"space-tap":{gate:"active",status:"live",owner:"v2/timeline (S7.8)",parse:fe},"canvas-pointerdown":{gate:"active",status:"live",owner:"v2/shell dismiss-outside (rc3 r4-12)",parse:fe},"timeline-peers":{gate:"active",status:"live",owner:"v2/timeline/peers (S7.17)",parse:l({peers:Ua})},"video-frame-commit":{gate:"active",status:"live",owner:"v2/timeline/frame-handle (T3.6b)",parse:l({v:V(1),artboardId:Ce,stableId:Fo,zoom:Ho,focus:$o})},"ask-selection":{gate:"active",status:"live",owner:"editing/ask-bubble (S2.19)",parse:l({refs:_e(200,q(He)),selection:d(_e(12,q(Yi))),rect:Fe,artboard:d(p)})},"ask-selection-rect":{gate:"active",status:"live",owner:"editing/ai-scope-outline (S2.19)",parse:l({rect:O(Fe)})},"insert-artboard-request":{gate:"active",status:"legacy",owner:H,orphan:"no-sender",parse:l({id:d(p),label:d(p),width:d(P),height:d(P)})},"mode-changed":{gate:"active",status:"live",owner:"v2/shell/use-canvas-mode-lane (V2-4.3b)",parse:l({seq:P,mode:St,tool:bn,present:O(yn),cause:V("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:St(e),tool:d(bn),present:d(yn),cause:V("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:St,rect:O(Fe)})},"toolbar-popover":{gate:"active",status:"live",owner:"tool-palette (#170 T2.4b); h/use-canvas-bridge → notifications (toast placement)",parse:l({open:_})},"tool-panel-open":{gate:"active",status:"live",owner:"tool-palette (V2-4.5c); shell tool panels (V2-4.5c)",parse:l({panel:V("stickers","components","templates","assets","sizes","image","generate"),anchor:O(Fe),replace:d(p)})},"size-place":{gate:"active",status:"live",owner:"editing/size-ghost (S7.20); client/v2/kinds",parse:l({presetId:D(40),world:W({x:P,y:P})})},"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:jo})},"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:P,fit:d(_)})},"pages-view":{gate:"active",status:"live",owner:"canvas-pages-view.tsx (2.0.7 B2) → v2/shell/use-canvas-mode-lane",parse:l({v:V(1),on:_,index:pe(0,1e4),total:pe(0,1e4),id:d(D(256))})},"pages-pick":{gate:"active",status:"live",owner:"canvas-pages.ts (2.0.7 B2) → v2/shell/pages-pick (the view file, main origin)",parse:l({v:V(1),view:V("canvas","pages")})},"theme-pick":{gate:"active",status:"live",owner:"canvas-theme.ts (r4 #6, 2.0.7 B2) → v2/shell/pages-pick (the view file, main origin)",parse:l({v:V(1),theme:V("light","dark")})},"present-position":{gate:"active",status:"live",owner:"v2/shell/use-canvas-mode-lane (S3.1)",parse:l({index:P,total:P,artboardId:p,sid:d(wn),seq:d(pe(0,2147483647))})},"present-run":{gate:"active",status:"live",owner:"present/present-stage.tsx (S3.6b)",parse:l({artboards:vi})},"present-follow-state":{gate:"active",status:"live",owner:"v2/present/follow-view (S3.7a)",parse:l({live:_,sid:O(wn),presenterName:Qa,presenterIndex:pe(0,2000),index:pe(0,2000),total:pe(0,2000),watchers:pe(0,1e5),ended:_})},"present-media":{gate:"active",status:"live",owner:"present/present-media (S3.3)",parse:l({playing:_,t:Lo,duration:Lo,muted:_,sources:d(Va),missing:d(_)})},"link-follow":{gate:"active",status:"live",owner:"S3 links (client/v2/preview/link-follow.js)",parse:l({elementId:Fa,artboardId:O(Ce)})},"asset-relink-request":{gate:"active",status:"live",owner:"client/v2/assets/asset-state-lane (S8.19)",parse:l({rel:D(512)})},"asset-lfs-fix-request":{gate:"active",status:"live",owner:"client/v2/assets/asset-state-lane (2.0.3 LFS placeholder)",parse:l({rel:D(512)})},"asset-lfs-copy-request":{gate:"active",status:"live",owner:"client/v2/assets/asset-state-lane (2.0.3 LFS placeholder)",parse:l({rel:D(512)})},"stills-want":{gate:"active",status:"live",owner:"client/v2/shell/still-bridge (#212 §5)",parse:l({file:D(1024)})},"still-put":{gate:"active",status:"live",owner:"client/v2/shell/still-bridge (#212 §5)",parse:l({file:D(1024),artboard:Go,sig:D(Zo),bytes:Qo})}},zo={theme:{gate:"any",target:"parent",status:"live",owner:ce,parse:l({theme:V("light","dark")})},"view-chrome":{gate:"any",target:"parent",status:"live",owner:ce,parse:l({minimap:d(_),zoom:d(_),present:d(_),guides:d(_),print:d(_),safeZones:d(_),zen:d(_)})},"view-annotations":{gate:"parent",status:"live",owner:"annotations-layer",parse:l({visible:_})},"canvas-cap":{gate:"parent",status:"live",owner:"tpl/_shell.html",parse:l({t:p})},"ds-css":{gate:"parent",status:"live",owner:"tpl/_shell.html",parse:l({tokens:d(O(Tt)),components:d(O(Tt))})},"ds-pins":{gate:"parent",status:"live",owner:"tpl/_shell.html",parse:l({revs:hi,rootClass:O(bi)})},"ds-update-dots":{gate:"parent",status:"live",owner:"tpl/_shell.html",parse:l({ids:ri})},"ds-theme-preview":{gate:"parent",status:"live",owner:"ds/board/state",parse:l({mode:si})},"ds-marks":{gate:"parent",status:"live",owner:"ds/board/state",parse:l({outside:Do,conflicts:Do})},"ds-make-states":{gate:"parent",status:"live",owner:"ds/board/outline",parse:l({sections:ui})},"ds-rects":{gate:"parent",status:"live",owner:"tpl/_shell.html",parse:l({seq:Wo,artboard:mi,ids:pi})},"ai-activity":{gate:"parent",status:"live",owner:"ai-banner",parse:l({file:p,entry:O(ae)})},"select-by-id":{gate:"parent",status:"live",owner:ce,parse:l({id:d(p),artboardId:d(O(p)),index:d(P),add:d(_)})},"select-by-selector":{gate:"parent",status:"live",owner:ce,parse:l({selector:p})},highlight:{gate:"any",target:"parent",status:"live",owner:ce,parse:l({id:O(p),artboardId:d(O(p)),index:d(P)})},"request-layers":{gate:"any",target:"parent",status:"live",owner:ce,parse:l({artboardId:O(p)})},"force-clear":{gate:"any",target:"parent|self",status:"live",owner:ce,parse:fe},"select-clear":{gate:"any",target:"parent|self",status:"legacy",owner:ce,orphan:"no-sender",parse:fe},"locked-set":{gate:"parent",status:"live",owner:ce,parse:l({locked:q(p)})},"apply-style":{gate:"parent",status:"live",owner:ce,parse:l({id:p,artboardId:d(O(p)),index:d(P),prop:p,value:O(p)})},"record-edit":{gate:"parent",status:"live",owner:ce,parse:l({payload:ae})},"apply-edit-result":{gate:"parent",status:"live",owner:ce,parse:l({requestId:p,ok:_,error:d(p),conflict:d(_)})},"undo-barrier-ok":{gate:"parent",status:"live",owner:ce,parse:l({requestId:p})},"edit-op-result":{gate:"parent",status:"live",owner:"editing (S2.1)",parse:l({requestId:p,ok:_,actionId:d(O(p)),writeId:d(p),rev:d(p),refs:d(q(He)),created:d(q(He)),code:d(V(...Gi)),message:d(p)})},"edit-reverted":{gate:"parent",status:"live",owner:ce,parse:l({op:p,id:d(p),reason:d(p)})},"reorder-failed":{gate:"parent",status:"live",owner:ce,parse:fe},"reposition-failed":{gate:"parent",status:"live",owner:ce,parse:fe},"resize-failed":{gate:"parent",status:"live",owner:"use-element-resize",parse:fe},"resize-artboard-failed":{gate:"parent",status:"live",owner:"use-element-resize",parse:fe},"freeze-and-set-kind":{gate:"parent",status:"live",owner:ce,parse:l({artboardId:p,kind:O(p),ask:d(_),freeze:d(_)})},"op-toast":{gate:"any",target:"parent",status:"live",owner:ce,parse:l({message:p})},"tool-set":{gate:"parent",status:"live",owner:"use-tool-mode",orphan:"no-sender",parse:l({tool:p})},"insert-sticker":{gate:"parent",status:"live",owner:"annotations-layer",parse:l({path:p,follow:d(_),preview:d(za),sticker:d(W({pack:p,id:p,flip:d(_)}))})},"reveal-artboard":{gate:"parent",status:"live",owner:"canvas-lib",parse:l({artboardId:p,glide:_,flash:_})},"convert-marks":{gate:"parent",status:"live",owner:"artboard-convert-marks",parse:l({v:V(1),from:p,to:p,extraPct:P,fill:O(D(40))})},"shell-panels":{gate:"parent",status:"live",owner:"shell-panels",parse:l({v:V(1),open:O(V("stickers","assets","components"))})},"ai-copies":{gate:"parent",status:"live",owner:"artboard-ai-copies",parse:l({v:V(1),copies:Li})},"ai-runs":{gate:"parent",status:"live",owner:"artboard-activity-overlay",parse:l({artboards:vt(W({state:V("running","needs-you","done"),who:D(200),tag:D(120),waiting:kt}))})},"insert-template":{gate:"parent",status:"live",owner:"annotations-layer",parse:l({id:p,follow:d(_)})},"trashed-artboards":{gate:"parent",status:"live",owner:"artboard-ghosts-overlay (S11.5)",parse:l({canvas:D(1024),items:q(W({id:D(128),label:D(200),rect:O(Fe)}))})},"place-component":{gate:"parent",status:"live",owner:"editing/place-ghost",parse:l({component:$a,label:d(D(64)),variant:d(No),glyph:d(No),mode:V("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:D(512),natural:d(O(W({w:P,h:P}))),label:d(D(200))})},"asset-drag-over":{gate:"parent",status:"live",owner:"editing/image-drop (r3)",parse:l({x:O(P),y:d(P)})},"asset-drop-at":{gate:"parent",status:"live",owner:"editing/image-drop (r3)",parse:l({requestId:D(64),x:P,y:P})},"asset-drop-done":{gate:"parent",status:"live",owner:"editing/image-drop (r3)",parse:l({requestId:D(64),ok:_,created:d(q(He)),message:d(D(400))})},"timeline-drop-hint":{gate:"parent",status:"live",owner:"editing/drop-chip (S7.9)",parse:l({artboardId:p,on:_})},"timeline-word":{gate:"parent",status:"live",owner:"collab/timeline-presence (S7.17)",parse:l({artboardId:O(Ce),wordKey:d(Vo)})},"video-frame-handle":{gate:"parent",status:"live",owner:"editing/video-frame-handle (T3.6b)",parse:l({v:V(1),artboardId:O(Ce),stableId:d(Fo),label:d(D(120)),src:d(O(Ba)),zoom:d(Ho),focus:d($o)})},"dim-artboards":{gate:"parent",status:"live",owner:"editing/kind-dim (S7.24b) ← client/v2/kinds/kind-dim-relay",parse:l({ids:O(_e(xi,q(D(128))))})},"size-ghost":{gate:"parent",status:"live",owner:"editing/size-ghost (S7.20)",parse:l({preset:O(W({id:D(40),label:D(80),sizeText:D(40),w:P,h:P}))})},"insert-annotation-media":{gate:"parent",status:"live",owner:"annotations-layer",parse:l({paths:q(p)})},"replace-annotation-media":{gate:"parent",status:"live",owner:"annotations-layer",parse:l({id:p,path:p,sticker:d(W({pack:p,id:p,flip:d(_)}))})},"photo-preview":{gate:"any",target:"parent",status:"live",owner:"canvas-lib (photo)",parse:l({asset:p,edit:O(ae),use:d(p)})},"photo-busy":{gate:"any",target:"parent",status:"live",owner:"canvas-lib (photo)",parse:l({asset:p,busy:_})},"comments-set":{gate:"any",target:"parent",status:"live",owner:"comments-overlay",parse:l({comments:q(ae)})},"comment-focus":{gate:"any",target:"parent",status:"live",owner:"comments-overlay",parse:l({id:O(p),reply:d(V(!0))})},"comment-op-ack":{gate:"parent",status:"live",owner:"comments-overlay (S9.22)",parse:l({reqId:O(it)})},"comment-op-result":{gate:"parent",status:"live",owner:"comments-overlay (S9.22)",parse:l({reqId:O(it),ok:_,comment:d(O(ae)),status:d(P),error:d(p)})},"comment-people":{gate:"parent",status:"live",owner:"comments-overlay (S9.22)",parse:l({reqId:O(it),people:O(q(zi))})},"annotation-select":{gate:"parent",status:"live",owner:"annotations-layer (S4.9)",parse:l({v:V(1),ids:q(D(200))})},"annotation-filter":{gate:"parent",status:"live",owner:"annotations-layer (S4.9)",parse:l({v:V(1),authors:q(D(200))})},"export-capture":{gate:"parent",status:"live",owner:"canvas-lib (export)",parse:l({id:p,format:p,artboardIds:q(p),scale:P})},"export-selection-query":{gate:"parent",status:"live",owner:"canvas-lib (export)",parse:l({id:p})},"export-result":{gate:"parent",status:"live",owner:"export-dialog",orphan:"no-handler",parse:l({id:p,ok:_,browser:d(_),jobId:d(p),error:d(p)})},"export-history-result":{gate:"parent",status:"live",owner:"export-dialog",orphan:"no-handler",parse:l({id:p,history:q(ae)})},"timeline-play":{gate:"any",target:"parent",status:"live",owner:"video-comp",parse:l(Ie)},"timeline-pause":{gate:"any",target:"parent",status:"live",owner:"video-comp",parse:l(Ie)},"timeline-seek":{gate:"any",target:"parent",status:"live",owner:"video-comp",parse:l({...Ie,frame:P})},"timeline-loop":{gate:"any",target:"parent",status:"live",owner:"video-comp",parse:l({...Ie,loop:_})},"timeline-mute":{gate:"any",target:"parent",status:"live",owner:"video-comp",parse:l({...Ie,muted:_})},"timeline-volume":{gate:"any",target:"parent",status:"live",owner:"video-comp",parse:l({...Ie,volume:P})},"timeline-request-comps":{gate:"any",target:"parent",status:"live",owner:"video-comp",parse:fe},"run-action":{gate:"parent",status:"live",owner:"actions/registry (V2-1.3)",parse:l({v:V(1),id:p,params:d(ae)})},"paste-data":{gate:"parent",status:"live",owner:"bridge/paste-data (p8-sweep-leftovers)",parse:(e)=>{let t=Mo(e);return t?{...t}:null}},"git-lifecycle":{gate:"parent",status:"legacy",owner:"c/app",orphan:"no-handler",parse:l({payload:ae})},"set-mode":{gate:"parent",status:"live",owner:"bridge/canvas-mode-store (V2-4.3b)",parse:l({v:V(2),seq:P,mode:St,present:O(yn),tool:d(bn),caps:Wa})},"occluded-insets":{gate:"parent",status:"new",owner:"bridge/canvas-mode-store",parse:l({seq:P,insets:Ga,topBand:Za})},"present-step":{gate:"parent",status:"live",owner:"bridge/canvas-mode-store (S3.1)",parse:l({to:(e)=>e==="next"||e==="prev"?e:P(e)})},"present-follow":{gate:"parent",status:"live",owner:"bridge/canvas-mode-store (S3.7a)",parse:l({sid:O(wn),live:_,locked:_})},"present-media-cmd":{gate:"parent",status:"live",owner:"present/present-media (S3.3)",parse:l({op:V("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:_})},"annotation-prefs":{gate:"parent",status:"live",owner:"annotations/ui/tool-state (S4.8)",parse:l({prefs:jo})},"vote-state":{gate:"parent",status:"live",owner:"annotations/ui/vote-dots (S4.14)",parse:l({vote:O(W({id:xt,targets:_e(32,q(D(200))),state:V("open","ended"),perVoter:pe(1,99),tallies:d(vt(kt,32))})),mine:vt(kt,32)})},"hold-intent":{gate:"parent",status:"live",owner:"editing/hold-rings (S2.18)",parse:l({field:_,app:_,gesture:d(_)})},"ai-holds":{gate:"parent",status:"live",owner:"editing/hold-rings (S2.18)",parse:l({holds:Mi})},"ai-seen":{gate:"parent",status:"live",owner:"annotations/ui/ai-seen (S4.15); sent by v2/ai/seen-relay.js",parse:l({targets:Oi})},"undo-preview":{gate:"parent",status:"live",owner:"editing/undo-preview (S2.20)",parse:l({artboards:q(p),tag:O(p)})},"asset-state":{gate:"parent",status:"live",owner:"canvas-lib asset placeholder frame (S8.19, L1)",parse:l({items:ji,lfsActions:d(_)})},"asset-lfs-copied":{gate:"parent",status:"live",owner:"canvas-lib asset placeholder frame (2.0.3 LFS placeholder)",parse:l({rel:D(512),ok:_})},"gen-takes":{gate:"parent",status:"live",owner:"editing/take-keys (S8.16, L1)",parse:l({assets:Ui})},stills:{gate:"parent",status:"live",owner:"artboard-still-persist (#212 §5)",parse:l({file:D(1024),items:_e(Wi,q(W({artboard:Go,sig:D(Zo),bytes:Qo})))})}};var Zi="dgn",Ji=(e,t)=>Object.assign({},e,{[Zi]:t}),Jo=(e,t)=>Object.hasOwn(e,t),el=(e)=>xe(e)&&typeof e.dgn==="string"?e.dgn:null;function tl(e){return Jo(vn,e)?vn[e]:null}function nl(e){return Jo(zo,e)?zo[e]:null}function ol(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 Su=new Set(Object.keys(vn).filter((e)=>tl(e)?.gate==="active"));function At(e,t){let n=el(e.data),o=n?nl(n):null;if(!n||!o||!ol(o.gate,e,t))return null;let r=o.parse(e.data);return r?Ji(r,n):null}var rl=/^[A-Za-z0-9_-]{1,64}$/;function lt(e){return typeof e==="string"&&rl.test(e)}function er(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 tr(){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 Mt(e,t){let n=tr();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 nr(e){let t=tr();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 Ct(e){if(typeof document>"u"||!lt(e))return null;return document.querySelector(`[data-id="${e}"][data-tool]`)}function or(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(!lt(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}var je=null;function Qe(){return je}function xn(e,t){if(typeof document>"u")return;try{document.dispatchEvent(new CustomEvent(e,{detail:t}))}catch{}}function rr(e){xn("cm:reattach-start",{id:e})}function It(){je=null,xn("cm:reattach-cancel",{})}function sr(e,t){if(typeof document>"u")return()=>{};let n=(r)=>{let s=r.detail?.id;if(typeof s!=="string"||!s)return;je=s,e()},o=()=>{je=null,t()};return document.addEventListener("cm:reattach-start",n),document.addEventListener("cm:reattach-cancel",o),()=>{document.removeEventListener("cm:reattach-start",n),document.removeEventListener("cm:reattach-cancel",o),je=null}}function ar(e,t,n){let o=je;if(o===null)return!1;return je=null,xn("cm:reattach",{id:o,selection:e,clientX:t,clientY:n}),!0}function ir(e,t){if(typeof document>"u")return()=>{};let n=(o)=>{let r=o.detail;if(!r||typeof r.id!=="string"||!r.selection||typeof r.selection.selector!=="string")return;e(r)};return document.addEventListener("cm:reattach",n),document.addEventListener("cm:reattach-cancel",t),()=>{document.removeEventListener("cm:reattach",n),document.removeEventListener("cm:reattach-cancel",t)}}function lr(e,t,n={}){return{op:"reattach",id:e,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.world?{world:t.world}:{},...n.artboard?{artboard:n.artboard}:{}}}import{useCallback as te,useEffect as me,useLayoutEffect as ps,useMemo as Be,useRef as he,useState as re}from"react";var Pt=null;function Le(){if(typeof window>"u")return!1;if(Pt===null)try{Pt=new URLSearchParams(window.location.search).get("ro")==="1"}catch{Pt=!1}return Pt}var _t=null;function Ge(){if(typeof window>"u")return!1;if(_t===null)try{_t=new URLSearchParams(window.location.search).get("cm")==="1"}catch{_t=!1}return _t}var Lt=null;function kn(){if(typeof window>"u")return!1;if(Lt===null)try{Lt=new URLSearchParams(window.location.search).get("cg")==="1"}catch{Lt=!1}return Lt}var ct="Comments are paused while this project is view only.",Ot=null;function Sn(){if(typeof window>"u")return!1;if(Ot===null)try{Ot=new URLSearchParams(window.location.search).get("embed")==="1"}catch{Ot=!1}return Ot}function En(){if(typeof window>"u")return!1;try{return new URLSearchParams(window.location.search).get("follow")==="1"}catch{return!1}}function cr(){if(typeof window>"u")return!1;try{return!!new URLSearchParams(window.location.search).get("sha")}catch{return!1}}var dr=Symbol.for("maude.canvasMode.v2");function Ae(e){let t=e,n=t[dr];if(n&&n.doc===e.document)return n;let o={insets:cn,insetsSeq:-1,topBand:null,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,u=new Set,m={get:()=>o,subscribe(h){return u.add(h),()=>{u.delete(h)}},claimEcho(h){if(h!==o.modeSeq||h<=a)return!1;return a=h,!0},claimRequest(h){let f=Date.now(),w=c.get(h);if(w!==void 0&&f-w<250)return!1;return c.set(h,f),!0}};return e.addEventListener("message",(h)=>{let f=At(h,e);if(f?.dgn==="set-mode"){if(f.seq<=o.modeSeq)return;c=new Map;let w=f.caps.present===!0&&!En(),M=Le()?{edit:!1,annotate:!1,comment:f.caps.comment,present:w}:{...f.caps,present:w},g=vo(f.mode,M),k=f.tool?at(f.tool,M,g):null,E=f.tool&&(k===null||k===g)?f.tool:null;o={...o,mode:g,present:g==="present"?f.present??{kind:"canvas"}:null,caps:Object.freeze(M),modeSeq:f.seq,tool:E,prevMode:o.mode,clamped:g!==f.mode,step:g==="present"?o.step:null};for(let b of u)b(o);return}if(f?.dgn==="present-step"){if(o.mode!=="present")return;r+=1,o={...o,step:Object.freeze({to:f.to,n:r})};for(let w of u)w(o);return}if(f?.dgn==="present-follow"){if(!En())return;s+=1,o={...o,follow:Object.freeze({sid:f.sid,live:f.live,locked:f.locked,n:s})};for(let w of u)w(o);return}if(f?.dgn==="key-prefs"){if(f.singleKeys===o.singleKeys)return;o={...o,singleKeys:f.singleKeys};for(let w of u)w(o);return}if(f?.dgn!=="occluded-insets")return;if(f.seq<=o.insetsSeq)return;o={...o,insets:Object.freeze({...f.insets}),insetsSeq:f.seq,topBand:f.topBand?Object.freeze({...f.topBand}):null};for(let w of u)w(o)}),Object.defineProperty(m,"doc",{value:e.document}),t[dr]=m,m}function ur(){return typeof window>"u"?cn:Ae(window).get().insets}if(typeof window<"u"&&typeof window.addEventListener==="function")Ae(window);var Oe=["sky","green","yellow","lilac","grey"],pr="yellow",Tn=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 mr(e){if(!e)return Oe[0];let t=5381;for(let o=0;o<e.length;o++)t=(t<<5)+t+e.charCodeAt(o)|0;let n=(t%Oe.length+Oe.length)%Oe.length;return Oe[n]??Oe[0]}var Rn=(e)=>Tn[e];var sl="Someone",al=(e)=>{if(typeof e!=="string")return!0;let t=e.trim().toLowerCase();return t===""||t==="unknown"};function dt(e,t){if(al(e))return{name:sl,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?pr:mr(n),you:o}}var il=(e)=>e.trim().split(/\s+/)[0]||"";function ut(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:il(t)}}function fr(e){let t=ut(e);return t.first?`From ${t.first}’s sticky`:"From a sticky"}var ll=/^[A-Za-z0-9._-]{1,40}$/;var cl={figma:"Figma"},dl=/[\p{Cc}\p{Cf}\p{Cs}\p{Co}\p{Cn}\p{Zl}\p{Zp}]/gu;function ul(e){if(typeof e!=="string")return"";let n=e.normalize("NFC").replace(/\s+/gu," ").replace(dl,"").replace(/\s+/gu," ").trim();return Array.from(n).slice(0,80).join("").trim()}var gr=(e)=>!!e&&typeof e==="object"&&!Array.isArray(e);function pl(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 An(e){if(!gr(e)||e.source!=="figma")return;let t=gr(e.author)?e.author:{},n={source:"figma",author:{name:ul(t.name)||"Someone"}};if(typeof t.handle==="string"&&t.handle.length<=40&&ll.test(t.handle))n.author.handle=t.handle;let o=pl(e.at);if(o)n.at=o;return n}function Mn(e){return e?`${e.author.name} · from ${cl[e.source]}`:""}function hr(e){return(String(e??"").trim().split(/\s+/)[0]??"").replace(/[^\w.-]/g,"").toLowerCase()}var ml="You";function br(e,t,n=!1){let{mine:o,...r}=e;if(!t)return r;return n?{...r,author:ml,mine:!0}:{...r,mine:!0}}function fl(e,t,n=!1){return(Array.isArray(e)?e:[]).map((o)=>{let r=br(o,t(o),n);if(Array.isArray(o.thread))r.thread=o.thread.map((s)=>s&&typeof s==="object"?br(s,t(s),n):s);return r})}function yr(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 wr(e,t){return fl(e,(n)=>typeof n.id==="string"&&t.has(n.id))}function Ze(e,t){return e?.mine===!0&&typeof e.author==="string"?e.author:t}var vr=Object.freeze({observer:"Can view",viewer:"Can comment",member:"Can edit",owner:"Owner"}),gl=(e)=>typeof e==="string"&&Object.hasOwn(vr,e)?vr[e]:void 0;function hl(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 u=typeof a.id==="string"&&a.id?a.id:c;if(o.has(u))continue;o.add(u);let m=gl(a.role);n.push(m?{id:u,name:c,role:m}:{id:u,name:c})}return n}function xr(e,t){if(!Array.isArray(e))return[];return hl(e.map((n)=>({name:n?.name})),t)}function bl(e,t=96){return e*t/25.4}function kr(e,t=96){return e*25.4/t}var yl=[{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 wl(e){return yl.find((t)=>t.id===e)}function vl(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 xl(e){return e.unit==="mm"?3:3.175}var Nt=5,kl=200;function Dt(e){if(!Number.isFinite(e))return 0;return Math.min(Math.max(e,0),kl)}function Sl(e){let t=e??{};return{top:typeof t.top==="number"?Dt(t.top):Nt,right:typeof t.right==="number"?Dt(t.right):Nt,bottom:typeof t.bottom==="number"?Dt(t.bottom):Nt,left:typeof t.left==="number"?Dt(t.left):Nt}}function Cn(e,t=96){return Math.round(bl(e,t))}function In(e){let t=wl(e.paper);if(!t)throw Error(`unknown paper preset: ${e.paper}`);let n=e.orientation??"portrait",{widthMm:o,heightMm:r}=vl(t,n),s=e.bleedMm??xl(t),a=Sl(e.marginsMm),c=Cn(s),u=Cn(o),m=Cn(r);return{paper:t.id,orientation:n,trimWidthMm:o,trimHeightMm:r,bleedMm:s,widthPx:u+2*c,heightPx:m+2*c,trimWidthPx:u,trimHeightPx:m,bleedPx:c,marginsMm:a}}function El(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 Tl=(e)=>`at ${El(e)}`,Rl=0.5;function Sr(e,t,n=Rl){if(t===null||t===void 0||!Number.isFinite(t))return!0;return Math.abs(t-e)<=n}function Pn(e){if(!e||typeof e!=="object")return null;let t=e;if(typeof t.paper!=="string")return null;try{let n=In({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 Er(e,t){if(!e||typeof e!=="object")return null;let n=e;if(typeof n.paper!=="string")return null;try{let o=In({paper:n.paper,orientation:n.orientation==="landscape"?"landscape":"portrait",...typeof n.bleedMm==="number"?{bleedMm:n.bleedMm}:{}}),r=(s)=>Math.round(kr(s)*10)/10;return{x:r(t.x-o.bleedPx),y:r(t.y-o.bleedPx)}}catch{return null}}var Kt=(e)=>`${Math.round(e)} mm`;function Al(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?`${Kt(t.wMm-e.x)} from the right`:`${Kt(e.x)} from the left`,s=o?`${Kt(t.hMm-e.y)} above the trim`:`${Kt(e.y)} from the top`;return`${r} · ${s}`}function _n(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:Tl(e.t),kind:"video"};let o=e.mm;if(o&&typeof o.x==="number"&&typeof o.y==="number")return{artboard:n,chip:Al({x:o.x,y:o.y},t),kind:"print"};return{artboard:n,chip:null,kind:n?"artboard":"canvas"}}class Ne extends Error{}var Ln=(e,t)=>Math.abs(e.x-t.x)<0.000001&&Math.abs(e.y-t.y)<0.000001,de=(e,t)=>({x:e,y:t}),zt=/([MmLlHhVvCcSsQqTtZzAa])|(-?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?)/g,Ml={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,Z:0};function Cl(e){let t=[];zt.lastIndex=0;let n=0;for(let o=zt.exec(e);o;o=zt.exec(e)){if(/[^\s,]/.test(e.slice(n,o.index)))throw new Ne("not a path");t.push(o[1]??Number(o[2])),n=zt.lastIndex}if(/[^\s,]/.test(e.slice(n)))throw new Ne("not a path");return t}function Tr(e){let t=Cl(e),n=[],o=null,r=de(0,0),s=de(0,0),a=null,c=null,u=0,m="",h=(g)=>{let k=[];for(let E=0;E<g;E++){let b=t[u++];if(typeof b!=="number")throw new Ne("not a path");k.push(b)}return k},f=(g)=>{o={closed:!1,points:[{...g}]},n.push(o),r=g,s=g},w=(g,k,E)=>{if(!o)f(r);let b=o,i=b.points[b.points.length-1];if(!Ln(g,i))i.out=g;let S={...E};if(!Ln(k,E))S.in=k;b.points.push(S),r=E,a=k,c="c"},M=(g)=>{if(!o)f(r);o.points.push({...g}),r=g,c=null};while(u<t.length){let g=t[u];if(typeof g==="string"){if(m=g,u++,g==="A"||g==="a")throw new Ne("arc")}else if(!m||m==="Z"||m==="z")throw new Ne("not a path");else if(m==="M")m="L";else if(m==="m")m="l";let k=m===m.toLowerCase(),E=m.toUpperCase(),b=k?r.x:0,i=k?r.y:0,S=Ml[E];if(S===void 0)throw new Ne("not a path");let R=h(S);switch(E){case"M":f(de(R[0]+b,R[1]+i)),c=null;break;case"L":M(de(R[0]+b,R[1]+i));break;case"H":M(de(R[0]+b,r.y));break;case"V":M(de(r.x,R[0]+i));break;case"C":w(de(R[0]+b,R[1]+i),de(R[2]+b,R[3]+i),de(R[4]+b,R[5]+i));break;case"S":{let F=c==="c"&&a?de(2*r.x-a.x,2*r.y-a.y):r;w(F,de(R[0]+b,R[1]+i),de(R[2]+b,R[3]+i));break}case"Q":case"T":{let F=r,A,L;if(E==="Q")A=de(R[0]+b,R[1]+i),L=de(R[2]+b,R[3]+i);else A=c==="q"&&a?de(2*r.x-a.x,2*r.y-a.y):r,L=de(R[0]+b,R[1]+i);w(de(F.x+0.6666666666666666*(A.x-F.x),F.y+0.6666666666666666*(A.y-F.y)),de(L.x+0.6666666666666666*(A.x-L.x),L.y+0.6666666666666666*(A.y-L.y)),L),a=A,c="q";break}case"Z":{if(o){let F=o;F.closed=!0;let A=F.points[0],L=F.points[F.points.length-1];if(F.points.length>1&&Ln(A,L)){if(L.in)A.in=L.in;F.points.pop()}}r=s,c=null;break}}}if(n.length===0)throw new Ne("empty");return{subs:n}}var Rr=(e)=>e.subs.reduce((t,n)=>t+n.points.length,0);var Il=new RegExp("^(?:#[0-9a-f]{3,8}|[a-z]+|(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch|color|color-mix|var|(?:repeating-)?(?:linear|radial|conic)-gradient)\\([^;{}<>\\\\\"'`]*\\))(?:\\s*,\\s*(?:#[0-9a-f]{3,8}|[a-z]+|(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch|color|color-mix|var|(?:repeating-)?(?:linear|radial|conic)-gradient)\\([^;{}<>\\\\\"'`]*\\)))*$","i"),Pl=/url\s*\(|image\s*\(|image-set|element\s*\(|expression/i;function Ar(e){return typeof e==="string"&&e.length>0&&e.length<=512&&Il.test(e)&&!Pl.test(e)}function Mr(e,t){return(t?.flexDirection||"row").trim().startsWith("row")?e==="width":e==="height"}var _l=new Set(["fit-content","max-content","min-content","auto"]),Ll=new Set(["100%","fill","-webkit-fill-available","stretch"]),Ol=(e)=>e==="flex"||e==="inline-flex";function Nl(e,t){let n=t.width.trim().toLowerCase();if(Ll.has(n))return"fill";if(_l.has(n))return"hug";if(/^-?\d/.test(n))return"fixed";if(Mr("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 Cr(e,t){if(!Ol(e.display)||t.length<2)return;let n=new Set(t.map((r)=>Nl(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 Dl=new WeakMap;var Ir=(e)=>Dl.get(e)??null;var Pr=(e)=>e?`${e.sub},${e.i},${e.kind},${e.x},${e.y}`:"";var On=["font-family","font-size","font-weight","line-height","letter-spacing","text-transform","font-style"];var Kl=/^t-[a-z][a-z0-9-]*$/,zl=(e)=>(e??"").split(/\s+/).filter(Boolean),_r=(e)=>zl(e).filter((t)=>Kl.test(t));var tp=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 np=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 Lr=(e,t)=>{let n=t.getComputedStyle(e),o={};for(let r of On)o[r]=n.getPropertyValue(r).trim();return o},Vl=(e)=>e.closest?.("[lang]")?.getAttribute("lang")?.trim()??"";function Or(e){let n=e.ownerDocument?.defaultView;if(!n||typeof n.getComputedStyle!=="function")return null;let o=_r(e.getAttribute("class"))[0]??null,r=Lr(e,n),s={role:o,values:{},differs:[],lang:Vl(e),upper:(n.getComputedStyle(e).getPropertyValue("text-transform")??"").trim()==="uppercase"};if(!o)return s;let a=e,c=e.hasAttribute("style"),u=e.getAttribute("style")??"";try{let m=`${u};transition:none`;a.setAttribute("style",m),a.setAttribute("style","transition:none"),s.values=Lr(e,n),a.setAttribute("style",m),n.getComputedStyle(e).getPropertyValue("font-size")}finally{if(c)a.setAttribute("style",u);else a.removeAttribute("style")}return s.differs=On.filter((m)=>r[m]!==s.values[m]),s}function Fl(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 Vt(){if(typeof window>"u")return null;try{return Fl(window.location.pathname,window.location.search)}catch{return null}}function Dn(){return Vt()??void 0}function Ft(e){if(!e)return"";return(e.getAttribute("class")??"").trim().split(/\s+/).filter((t)=>t&&!t.startsWith("dgn-")&&!t.startsWith("dc-cv-")).join(" ")}var Hl=/^$|^(inline|contents|ruby|ruby-text)$|^inline-/;function $l(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=!Hl.test(a);if(c)t+=" ";for(let u=r.firstChild;u;u=u.nextSibling)n(u);if(c)t+=" "};return n(e),t}function jl(e,t){if(!e)return"";let o=(e.innerText||(e.textContent?$l(e):"")).replace(/\s+/g," ").trim();return o.length>t?`${o.slice(0,t-1)}…`:o}function ql(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=Ft(n).split(/\s+/).filter(Boolean).slice(0,2);if(a.length)s+=`.${a.join(".")}`;let c=1,u=n.previousElementSibling;while(u)c++,u=u.previousElementSibling;s+=`:nth-child(${c})`,t.unshift(s),n=n.parentElement}return t.join(" > ")}function Dr(e){let t=e.nodeName.toLowerCase(),n=e.getAttribute?.("data-dc-element"),o=e.getAttribute?.("data-dc-screen");if(n)t+=`[data-dc-element="${n}"]`;else if(o)t+=`[data-dc-screen="${o}"]`;else if(e.id)t+=`#${e.id}`;let r=Ft(e).split(/\s+/).filter(Boolean).slice(0,2);if(r.length&&!n&&!o)t+=`.${r.join(".")}`;return t}function Kr(e){let t=[],n=e;while(n&&n.nodeType===1&&t.length<8)t.unshift(Dr(n)),n=n.parentElement;return t}function Bl(e,t){if(!e||!t)return null;let n=[],o=e;while(o&&o.nodeType===1){if(o.getAttribute?.("data-dc-screen")===t){if(n.length===0)return null;return`[data-dc-screen="${t}"] > ${n.join(" > ")}`}let r=1;for(let a=o.previousElementSibling;a;a=a.previousElementSibling)r++;let s=o.localName;n.unshift(`${s===s.toLowerCase()?s:"*"}:nth-child(${r})`),o=o.parentElement}return null}function Ul(e){return e.replace(/[^a-zA-Z0-9_-]/g,(t)=>`\\${t}`)}function zr(e,t){return t?`[data-dc-screen="${t}"] [data-cd-id="${e}"]`:`[data-cd-id="${e}"]`}function Vr(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 Fr(e,t,n){if(!t||!n)return 0;return Vr(e,`[data-cd-id="${Ul(t)}"]`,n)}function Kn(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(zr(t.id,t.artboardId));if(o)return o}if(t.selector)return n(t.selector);return null}function Wl(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 Hr(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 m=e.querySelector(`[data-dc-screen="${t.artboardId}"]`);if(m)r=m}let s=(t.classes||"").split(/\s+/).filter(Boolean),a=null,c=0,u=n[n.length-1];for(let m of Array.from(r.getElementsByTagName(o))){if(Dr(m)!==u)continue;let h=Wl(Kr(m),n);if(h===0)continue;let f=Ft(m).split(/\s+/).filter(Boolean),w=s.filter((g)=>f.includes(g)).length,M=h*10+w;if(M>c)c=M,a=m}return a}var Nr=["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"],Xl=/^(style|class|data-cd-id|data-dc-|data-dcid$)/;function Yl(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(Nr);for(let g of Nr){let k=t.getPropertyValue(g);if(k)o[g]=k.trim();let E=n.getPropertyValue(g);if(E)r[g]=E.trim()}let a=/^(margin|padding|border)(-|$)/,c={};for(let g=0;g<t.length;g++){let k=t.item(g);if(!k||s.has(k)||a.test(k))continue;let E=t.getPropertyValue(k);if(E)c[k]=E.trim()}let u={};for(let g of Array.from(e.attributes)){if(Xl.test(g.name))continue;u[g.name]=g.value}if(e.tagName.toLowerCase()==="svg"&&e.getAttribute("data-shape")==="path"){let g=e.querySelector("path")?.getAttribute("d");if(g)try{u["data-dc-pen-points"]=String(Rr(Tr(g)))}catch{}let k=Pr(Ir(e));if(k)u["data-dc-pen-point"]=k}if(e.hasAttribute("data-dc-screen")){for(let k of Array.from(e.attributes))if(k.name.startsWith("data-dc-")&&k.name!=="data-dcid")u[k.name]=k.value;let g=tc(e);if(g)u["data-dc-web-longest"]=String(g)}let m=e.parentElement,h=m?window.getComputedStyle(m).display:"",f=m&&(h==="flex"||h==="inline-flex")?window.getComputedStyle(m).flexDirection:"",w={},M=t.getPropertyValue("background").trim();if(Ar(M))w.background=M;return{authored:o,computed:r,customStyles:c,attrs:u,declared:w,parentDisplay:h,parentFlexDirection:f}}catch{return{authored:{},computed:{},customStyles:{},attrs:{}}}}function Ql(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 Gl=/^--[A-Za-z0-9_-]{1,128}$/,Zl=/^[A-Za-z][A-Za-z0-9]{0,63}$/;function $r(e){let t=e.getAttribute?.("data-ds-token");if(t&&Gl.test(t))return`[data-ds-token="${t}"]`;let n=e.getAttribute?.("data-ds-master");if(n&&Zl.test(n))return`[data-ds-master="${n}"]`;return null}function Ht(e,t){let n=e.el,o=n&&n.getBoundingClientRect?n.getBoundingClientRect():null,r=e.cdId,s=!r&&n?$r(n):null,a=r?zr(r,e.artboardId):s?e.artboardId?`[data-dc-screen="${e.artboardId}"] ${s}`:s:e.artboardId?`[data-dc-screen="${e.artboardId}"]`:ql(n),c=r&&typeof document<"u"?Vr(document,a,n):0;return{file:t??Dn(),id:r??void 0,selector:a,artboardId:s?null:e.artboardId,index:c,tag:n?.tagName.toLowerCase()??"",classes:Ft(n),text:jl(n,240),dom_path:Kr(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(Br(n)):void 0,worldH:n instanceof HTMLElement?Math.round(Nn(n)):void 0,geometry:n instanceof HTMLElement?Ql(n):void 0,html:n?(n.outerHTML??"").slice(0,4000):"",...(()=>{if(n?.tagName?.toLowerCase()!=="img")return{};let u=/assets\/[0-9a-f]{8}\.[a-z0-9]+/i,m=n.getAttribute?.("data-photo-asset");if(m&&u.test(m))return{photoKind:"artboard-img",photoAsset:m};let h=n.getAttribute?.("src")||"",f=u.exec(h);return f?{photoKind:"artboard-img",photoAsset:f[0]}:{}})(),...Yl(n),...ec(n),...Jl(n)}}function Jl(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=Cr({display:n,flexDirection:t.flexDirection,alignItems:t.alignItems},o);return r?{kids:r}:{}}catch{return{}}}function ec(e){if(!e||e.children.length>0)return{};if(!(e.textContent??"").trim()&&!e.getAttribute("class"))return{};let t=Or(e);return t?{textInfo:t}:{}}function jr(e,t,n,o){let r=Ht({el:e.el,cdId:e.cdId??null,artboardId:e.artboardId??null},o),s=e.el;if(s&&!e.cdId&&e.artboardId&&!$r(s)){let c=Bl(s,e.artboardId);if(c)r.selector=c,r.index=0}let a=Mt(t,n);return a?{...r,world:a}:r}function qr(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 Br(e){return qr(e)?.offsetWidth??e.offsetWidth}function tc(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(Br(a)))).size!==o.length)return null;let s=Nn(e);return o.every((a)=>a===e||Nn(a)<s)?o.length:null}function Nn(e){let t=qr(e);if(t)return t.offsetHeight;if(e.getAttribute("data-dc-fixed")!=="true"||!e.hasAttribute("data-dc-screen"))return e.offsetHeight;let n=Array.from(e.children).find((o)=>o.classList.contains("dc-artboard-label"));return e.offsetHeight-(n?n.offsetHeight:0)}function Ur(){if(typeof window>"u")return null;let e=window.__maudeFrameFreeze;return e&&typeof e.raf==="function"?e:null}function ie(e){let t=Ur();return t?t.raf(e):requestAnimationFrame(e)}function Re(e){let t=Ur();if(t)t.caf(e);else cancelAnimationFrame(e)}import*as Vn from"lib0/decoding";import*as pt from"lib0/encoding";import{createContext as rc,useCallback as $p,useContext as sc,useEffect as jp,useMemo as qp,useReducer as Bp,useRef as Up,useState as Wp}from"react";import{Awareness as Yp,applyAwarenessUpdate as Qp,encodeAwarenessUpdate as Gp}from"y-protocols/awareness";import{readSyncMessage as Jp,writeSyncStep1 as em,writeUpdate as tm}from"y-protocols/sync";import*as Fn from"yjs";import*as nc from"yjs";var oc=new WeakSet;function Wr(e){return oc.add(e),e}var hp=Wr(Object.freeze({maudeOrigin:"shell-edit"})),bp=Wr(Object.freeze({maudeOrigin:"sync-agent"}));import*as $t from"lib0/decoding";import*as Je from"lib0/encoding";import*as Xr from"y-protocols/awareness";import*as zn from"y-protocols/sync";var vp=Object.freeze(["timeline","editing","holding"]),xp=Object.freeze(["editing","holding"]);var lm=Oe.map((e)=>Tn[e]);var ac=rc(null);function Yr(){return sc(ac)}var cm=Object.freeze({maudeOrigin:"collab-epoch-resync"});import{createContext as ic,useCallback as ke,useContext as $n,useEffect as lc,useMemo as cc,useRef as mt,useState as dc}from"react";import{jsx as Hn,Fragment as hc}from"react/jsx-runtime";var qt=ic(null);function Me(e){return e.id?`id:${e.id}`:`sel:${e.selector}`}function jt(e){let t=[],n=new Set;for(let o of e){let r=Me(o);if(n.has(r))continue;n.add(r),t.push(o)}return t}var uc=50,Zr=500,pc=(e,t)=>e.length===t.length&&e.every((n,o)=>Me(n)===Me(t[o]));function Qr(e,t,n,o=Date.now()){return o-e<Zr&&!pc(n,t)}function mc(e,t,n=Date.now()){if(n-e.at>=Zr||t.length===0)return!1;let o=new Set(e.sel.map(Me));return t.every((r)=>o.has(Me(r)))}var Gr=null;function fc(e){if(!Gr||e.length===0)return null;try{return Gr(e)}catch{return null}}function gc({children:e,postTarget:t}){let[n,o]=dc([]),r=mt([]),s=mt(Number.NEGATIVE_INFINITY),a=mt({at:Number.NEGATIVE_INFINITY,sel:[]}),c=mt(null),u=mt(null),m=ke((A)=>{if(c.current)clearTimeout(c.current);u.current=()=>{c.current=null,u.current=null;let L=t??(typeof window<"u"?window.parent:null);if(!L)return;let K=A.length===0?null:A.length===1?A[0]??null:A;try{L.postMessage({dgn:"select-set",selection:K,...fc(A)},"*")}catch{}},c.current=setTimeout(()=>u.current?.(),uc)},[t]);lc(()=>()=>{if(c.current)clearTimeout(c.current);u.current?.()},[]);let h=ke((A)=>{r.current=A,o(A),m(A)},[m]),f=ke((A)=>{s.current=Date.now(),h(jt(Array.isArray(A)?A:[A]))},[h]),w=ke((A)=>mc(a.current,A),[]),M=ke((A)=>{let L=jt(Array.isArray(A)?A:[A]);if(Qr(s.current,r.current,L))return!1;if(w(L))return!1;return h(L),!0},[h,w]),g=ke((A)=>{let L=Array.isArray(A)?A:[A],K=jt([...r.current,...L]);if(Qr(s.current,r.current,K))return!1;if(w(L))return!1;return h(K),!0},[h,w]),k=ke(()=>r.current,[]),E=ke((A)=>{let L=r.current,K=L.filter(A);if(K.length===L.length)return;a.current={at:Date.now(),sel:L.filter((I)=>!A(I))},h(K)},[h]),b=ke((A)=>{let L=Array.isArray(A)?A:[A];s.current=Date.now(),o((K)=>{let I=jt([...K,...L]);return r.current=I,m(I),I})},[m]),i=ke((A)=>{let L=Me(A);s.current=Date.now(),o((K)=>{let I=K.filter((B)=>Me(B)!==L);return r.current=I,m(I),I})},[m]),S=ke((A)=>{let L=Me(A);s.current=Date.now(),o((K)=>{let I=K.some((B)=>Me(B)===L)?K.filter((B)=>Me(B)!==L):[...K,A];return r.current=I,m(I),I})},[m]),R=ke(()=>{s.current=Date.now(),h([])},[h]),F=cc(()=>({selected:n,replace:f,add:b,remove:i,toggle:S,clear:R,replaceFromShell:M,addFromShell:g,peek:k,drop:E}),[n,f,b,i,S,R,M,g,k,E]);return Hn(qt.Provider,{value:F,children:e})}function Jr({children:e}){if($n(qt))return Hn(hc,{children:e});return Hn(gc,{children:e})}function Bt(){let e=$n(qt);if(!e)throw Error("useSelectionSet must be used inside <SelectionSetProvider>");return e}function es(){return $n(qt)}import{jsx as C,jsxs as U,Fragment as Xc}from"react/jsx-runtime";var bc=800,yc=20000,De=new Map,ms=0;function wc(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)}`;De.get(n)?.(t)}function fs(){if(typeof window>"u")return;window.addEventListener("message",wc)}var gs=()=>typeof window<"u"&&window.parent!==window;function qn(e,t){return new Promise((n)=>{let o=setTimeout(()=>{De.delete(e),n(null)},t);De.set(e,(r)=>{clearTimeout(o),De.delete(e),n(r)})})}async function qe(e){if(!gs())return null;fs();let t=`cm${++ms}`,n=qn(`ack:${t}`,bc),o=qn(`res:${t}`,yc);try{window.parent.postMessage({dgn:"comment-op",reqId:t,op:e},"*")}catch{return De.delete(`ack:${t}`),De.delete(`res:${t}`),null}if(!await n)return De.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 vc(){if(!gs())return null;fs();let e=`cm${++ms}`,t=qn(`res:${e}`,2500);try{window.parent.postMessage({dgn:"comment-people-request",reqId:e},"*")}catch{return De.delete(`res:${e}`),null}let n=await t;return Array.isArray(n?.people)?n.people:null}function Xn(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 ts(e){let n=Xn(e)?.querySelector(".dc-artboard-label");return(n instanceof HTMLInputElement?n.value:n?.textContent)?.trim()||e}function hs(e){return(e.querySelector(".dc-artboard-body")??e).getBoundingClientRect()}function xc(e,t){if(typeof document>"u")return null;for(let n of document.querySelectorAll("[data-dc-screen]")){let o=hs(n);if(e>=o.left&&e<=o.right&&t>=o.top&&t<=o.bottom)return n.getAttribute("data-dc-screen")}return null}function Yn(e){let t=Xn(e)?.getAttribute("data-dc-print");if(!t)return null;try{return JSON.parse(t)}catch{return null}}function bs(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 kc(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 ns(e,t,n){let o=e||xc(t,n),r=o?Xn(o):null;if(!o||!r)return{};let s={artboard:o},a=r.getAttribute("data-dc-kind");if(a==="video"){let c=bs(o);if(c!==null)s.t=Math.round(c*1000)/1000}else if(a==="print"){let c=hs(r),u=r.querySelector(".dc-artboard-body"),m=u&&c.width>0?u.offsetWidth/c.width:1,h=Er(Yn(o),{x:(t-c.left)*(m||1),y:(n-c.top)*(m||1)});if(h)s.mm=h}return s}var Sc="/_client/comments-overlay.css";function Ec(){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=Sc,document.head.appendChild(e)}function Qn(){return Vt()}function Tc(e){if(!e)return"";return e.replace(/<[^>]*>?/g,"").replace(/ /g," ").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/&/g,"&").replace(/\s+/g," ").trim()}var Rc=1500;function os(e,t){let n=(e.textContent??"").replace(/\s+/g," ").trim();return n===t||t.length>=Rc&&n.startsWith(t)}var Ac=400;function Mc(e,t){if(e.length===0)return null;let n=t.index&&t.index>0&&t.index<e.length?t.index:0,o=e[n]??e[0]??null;if(e.length===1||e.length>Ac)return o;let r=Tc(t.html_excerpt);if(!r||o&&os(o,r))return o;let s=t.index??0,a=null,c=Number.POSITIVE_INFINITY;for(let u=0;u<e.length;u++){let m=e[u];if(!os(m,r))continue;let h=Math.abs(u-s);if(h<c)a=m,c=h}return a??o}function Cc(e){if(lt(e.annotationId))return Ct(e.annotationId);if(!e.selector)return null;let t=null;try{t=Mc(document.querySelectorAll(e.selector),e)}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=Hr(document,{artboardId:n,tag:e.tag,classes:e.classes,dom_path:e.dom_path})}return t}function Bn(e){let t=Cc(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 ys(e,t,n=ur()){let r=typeof window<"u"?window.innerWidth:e.x+t.w,s=typeof window<"u"?window.innerHeight:e.y+t.h,a=Eo(r,s,n),c=a.x+8,u=a.y+8,m=a.x+a.w,h=a.y+a.h,f=e.x;if(f+t.w+8>m){let M=e.x-t.w;f=M>=c?M:Math.max(c,m-t.w-8)}if(f<c)f=c;let w=e.y;if(w+t.h+8>h){let M=e.y-t.h;w=M>=u?M:Math.max(u,h-t.h-8)}if(w<u)w=u;return{x:f,y:w}}function ws(){Ec();let e=es(),[t,n]=re([]),[o,r]=re(null),[s,a]=re(0),[c,u]=re(null),m=Be(()=>Qn(),[]),[h,f]=re(!1),[w,M]=re(null),[g,k]=re(null),E=te((y)=>{n((x)=>x.some((T)=>T.id===y.id)?x.map((T)=>T.id===y.id?y:T):[...x,y])},[]);me(()=>{if(typeof document>"u")return;let y=document.getElementById("dgn-pin-layer");if(!y)return;let x=y.style.display;return y.style.display="none",()=>{y.style.display=x}},[]);let b=te((y)=>{if(!e)return;if(!y?.selector){e.clear();return}let x=y.selector.match(/data-cd-id="([^"]+)"/),T=x?x[1]:void 0,z,Y;try{let ue=document.querySelector(y.selector);if(ue)z=ue.tagName.toLowerCase(),Y=(ue.getAttribute("class")??"").split(/\s+/).filter((ge)=>ge&&!ge.startsWith("dgn-")&&!ge.startsWith("dc-cv-")).join(" ")}catch{}e.replace({file:m??void 0,id:T,selector:y.selector,tag:z,classes:Y,bounds:y.bounds??void 0})},[e,m]),i=he(t),S=he(new Set);i.current=t;let R=Yr(),F=Fc();me(()=>{if(!R)return;let y=R.doc.getArray("comments"),x=()=>{n(wr(y.toArray(),S.current))};if(y.length>0)x();return y.observe(x),()=>{try{y.unobserve(x)}catch{}}},[R]),me(()=>{if(typeof window>"u")return;let y=(x)=>{if(x.source!==window.parent)return;let T=x.data;if(!T||typeof T!=="object"||!T.dgn)return;if(T.dgn==="comments-set"&&Array.isArray(T.comments))S.current=yr(T.comments),n(T.comments);else if(T.dgn==="comment-focus"){let z=typeof T.id==="string"?T.id:null;if(r(z),z&&T.reply===!0)a((ue)=>ue+1);else a(0);let Y=z?i.current.find((ue)=>ue.id===z):void 0;b(Y)}};return window.addEventListener("message",y),()=>window.removeEventListener("message",y)},[b]),me(()=>{if(typeof document>"u")return;let y=(x)=>{let T=x.detail;if(!T?.selection)return;let z=typeof T.clientX==="number"?T.clientX:0,Y=typeof T.clientY==="number"?T.clientY:0;u({selection:T.selection,clientX:z,clientY:Y,anchors:ns(T.selection.artboardId,z,Y)})};return document.addEventListener("cm:open-composer",y),()=>document.removeEventListener("cm:open-composer",y)},[]);let A=te(()=>{if(u(null),typeof window>"u")return;try{window.parent.postMessage({dgn:"force-clear"},"*")}catch{}},[]),L=te((y)=>{if(!c)return;let x=c.selection,T={file:x.file,selector:x.selector,index:x.index,dom_path:x.dom_path,tag:x.tag,classes:x.classes,bounds:x.bounds,html_excerpt:x.html,...x.annotationId?{annotationId:x.annotationId}:{},...x.world?{world:x.world}:{},text:y};if(typeof window>"u")return;f(!0),(async()=>{let z=await qe({op:"add",...T,...c.anchors});if(f(!1),z===null){try{window.parent.postMessage({dgn:"comment-submit",payload:T},"*")}catch{}A();return}if(!z.ok){M(z.error??"That did not go through.");return}if(M(null),z.comment)E(z.comment);A()})()},[c,A,E]);me(()=>{if(!m)return;let y=!1;return(async()=>{try{let x=await fetch(`/_comments?file=${encodeURIComponent(m)}`);if(!x.ok){await x.body?.cancel().catch(()=>{});return}let T=await x.json();if(y)return;if(Array.isArray(T.comments))n((z)=>z.length===0?T.comments??[]:z)}catch{}})(),()=>{y=!0}},[m]);let K=Be(()=>[...new Set(t.filter((y)=>typeof y.t==="number"&&y.artboard).map((y)=>y.artboard))],[t]),[I,B]=re({});me(()=>{if(K.length===0)return;let y=()=>{let T={};for(let z of K){let Y=bs(z);T[z]=Y===null?null:Math.round(Y*4)/4}B((z)=>K.every((Y)=>z[Y]===T[Y])?z:T)};y();let x=setInterval(y,125);return()=>clearInterval(x)},[K]);let X=Be(()=>t.slice().sort((x,T)=>x.created.localeCompare(T.created)).filter((x)=>x.status!=="resolved"&&(typeof x.t!=="number"||!x.artboard||x.id===o||Sr(x.t,I[x.artboard]??null))),[t,I,o]),Q=Be(()=>{let y=new Map;return t.slice().sort((T,z)=>T.created.localeCompare(z.created)).forEach((T,z)=>{y.set(T.id,z+1)}),y},[t]),se=te((y)=>{if(r(y),b(t.find((x)=>x.id===y)),typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-click",id:y},"*")}catch{}},[t,b]),ee=te((y,x)=>{if(typeof window>"u")return;let T=()=>{try{window.parent.postMessage({dgn:"comment-patch",id:y,patch:x},"*")}catch{}},z=x.status==="resolved"?{op:"resolve",id:y}:x.status==="open"?{op:"reopen",id:y}:typeof x.text==="string"?{op:"edit-own",id:y,text:x.text}:null;if(!z)return T();qe(z).then((Y)=>{if(Y===null)return T();if(!Y.ok)return M(Y.error??"That did not go through.");if(M(null),Y.comment)E(Y.comment)})},[E]),oe=te((y)=>{if(typeof window>"u")return;r((x)=>x===y?null:x),qe({op:"delete-own",id:y}).then((x)=>{if(x===null){try{window.parent.postMessage({dgn:"comment-delete",id:y},"*")}catch{}return}if(!x.ok)return M(x.error??"That did not go through.");M(null),n((T)=>T.filter((z)=>z.id!==y))})},[]),le=te((y)=>{k(null);let x=ns(y.selection.artboardId,y.clientX,y.clientY);qe(lr(y.id,y.selection,x)).then((T)=>{if(T===null)return M("Re-attaching needs the Maude window.");if(!T.ok)return M(T.error??"That did not go through.");if(M(null),T.comment)E(T.comment);r(y.id)})},[E]);me(()=>ir(le,()=>k(null)),[le]);let ye=te((y)=>{k(y),rr(y)},[]),j=te(()=>{k(null),It()},[]),G=te(async(y,x)=>{if(typeof fetch>"u")return!1;let T=await qe({op:"reply",id:y,body:x});if(T){if(!T.ok)return M(T.error??"That did not go through."),!1;if(M(null),T.comment)E(T.comment);return!0}try{let z=await fetch(`/_api/comments/${encodeURIComponent(y)}/reply`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({body:x})});if(!z.ok)return!1;let Y=await z.json();return n((ue)=>ue.map((ge)=>ge.id===Y.id?Y:ge)),!0}catch{return!1}},[E]);return U("div",{className:"cm-layer","aria-hidden":!1,children:[X.map((y)=>{let x=Q.get(y.id)??0;return C(Dc,{comment:y,sequence:x,focused:o===y.id,viewer:F??R?.myName,onClick:se},y.id)}),c?C(Kc,{state:c,busy:h,onSubmit:L,onCancel:A}):null,w?U("div",{className:"cm-notice",role:"status","data-testid":"comment-notice",children:[C("span",{children:w}),C("button",{type:"button",className:"cm-notice__x","aria-label":"Dismiss",onClick:()=>M(null),children:"×"})]}):null,g?U("div",{className:"cm-notice",role:"status","data-testid":"comment-reattach-hint",children:[C("span",{children:"Click the element this comment belongs on. Esc to cancel."}),C("button",{type:"button",className:"cm-notice__x","aria-label":"Cancel re-attach",onClick:j,children:"×"})]}):null,(()=>{if(!o||g)return null;let y=X.find((x)=>x.id===o);if(!y)return null;return C($c,{comment:y,sequence:Q.get(y.id)??0,onReattach:()=>ye(y.id),onClose:()=>{r(null),e?.clear()},onPatch:(x)=>ee(y.id,x),onDelete:()=>oe(y.id),onReply:(x)=>G(y.id,x),focusReply:s,mine:(!Le()||Ge())&&(y.mine===!0||!!(F??R?.myName)&&(y.author??"").trim()===(F??R?.myName??"").trim()),me:(F??R?.myName)||void 0})})()]})}var jn=null,rs=0,Ic=60000;async function Pc(){try{let e=await fetch("/_api/git-committers");if(!e.ok)return[];let t=await e.json();return xr(t.committers)}catch{return[]}}function _c(){if(!(jn&&Date.now()-rs<Ic))rs=Date.now(),jn=(async()=>await vc()??await Pc())();return jn}function ss(e){return hr(e)}function Lc(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 vs(e,t){me(()=>{let n=e.current;if(!n)return;n.style.height="auto",n.style.height=`${Math.min(n.scrollHeight,160)}px`},[e,t])}function Un({className:e,value:t,onChange:n,onKeyDown:o,placeholder:r,rows:s,disabled:a,textareaRef:c,ariaLabel:u,title:m}){let h=he(null),f=te((I)=>{if(h.current=I,c)c.current=I},[c]),[w,M]=re([]),[g,k]=re(null),[E,b]=re(0),i=te(()=>{if(w.length>0)return;_c().then((I)=>M(I))},[w.length]),S=Be(()=>{if(!g)return[];let I=g.query.toLowerCase();return(!I?w:w.filter((X)=>X.name.toLowerCase().includes(I))).slice(0,8)},[g,w]),R=te((I)=>{let B=I.selectionStart??I.value.length,X=Lc(I.value,B);k(X),b(0)},[]),F=te((I)=>{n(I.target.value),R(I.target)},[n,R]),A=te((I)=>{if(!g)return;let B=h.current;if(!B)return;let X=`@${ss(I.name)}`,Q=`${t.slice(0,g.start)}${X} ${t.slice(g.end)}`;n(Q),k(null);let se=g.start+X.length+1;ie(()=>{B.focus(),B.setSelectionRange(se,se)})},[g,t,n]),L=te((I)=>{if(g&&S.length>0){if(I.key==="ArrowDown"){I.preventDefault(),b((B)=>(B+1)%S.length);return}if(I.key==="ArrowUp"){I.preventDefault(),b((B)=>(B-1+S.length)%S.length);return}if(I.key==="Enter"||I.key==="Tab"){I.preventDefault();let B=S[E]??S[0];if(B)A(B);return}if(I.key==="Escape"){I.preventDefault(),k(null);return}}o?.(I)},[g,S,E,A,o]),K=te((I)=>{R(I.currentTarget)},[R]);return U("div",{style:{position:"relative"},children:[C("textarea",{ref:f,className:e,value:t,placeholder:r,rows:s,disabled:a,"aria-label":u,title:m,onChange:F,onKeyDown:L,onFocus:i,onSelect:K,onClick:K}),g&&S.length>0?C("ul",{className:"cm-mention-popup",role:"listbox","aria-label":"Mention suggestions",style:{left:0,top:"100%"},children:S.map((I,B)=>U("li",{role:"option","aria-selected":B===E,className:"cm-mention-popup__item",onMouseEnter:()=>b(B),onMouseDown:(Q)=>{Q.preventDefault(),A(I)},children:[C(Wn,{name:I.name}),U("span",{className:"cm-mention-popup__name",children:["@",ss(I.name)]}),I.role?C("span",{className:"cm-mention-popup__role",children:I.role}):null]},I.id))}):null]})}var Oc=3000;function Nc(e){return{x:e.x-12,y:e.y-12,w:24,h:24}}function xs(e){let t=!!e.selector||lt(e.annotationId);if(t){let r=Bn(e);if(r)return{pos:r,missing:!1}}let n=er(e.world)?nr(e.world):null;return{pos:n?Nc(n):e.bounds??null,missing:t}}function Dc({comment:e,sequence:t,focused:n,viewer:o,onClick:r}){let s=he(null),a=he(null),c=he(null),[u,m]=re(!1),h=he(!1);me(()=>{let g=()=>{a.current=null;let k=s.current;if(!k)return;let{pos:E,missing:b}=xs(e),i=!1;if(b){if(c.current==null)c.current=Date.now();i=Date.now()-c.current>Oc}else c.current=null;if(i!==h.current)h.current=i,m(i);if(!E){k.style.display="none",a.current=ie(g);return}k.style.display="grid";let S=Math.round(E.x+E.w-14),R=Math.round(E.y-14);k.style.left=`${S}px`,k.style.top=`${R}px`,a.current=ie(g)};return a.current=ie(g),()=>{if(a.current!=null)Re(a.current)}},[e]);let f=dt(e.author,Ze(e,o)),w=1+(e.thread?.length??0),M=`Comment ${t} by ${f.name}${w>1?`, ${w} messages`:""}${u?" (detached: its target is gone)":""}`;return U("button",{ref:s,type:"button",className:"cm-pin","data-resolved":e.status==="resolved"?"true":"false","data-focused":n?"true":"false","data-detached":u?"true":"false","data-comment-pin":e.id,"aria-label":M,"aria-expanded":n,title:e.text.slice(0,200),"data-seq":t,style:{["--cm-pin-tone"]:Rn(f.tone)},onClick:(g)=>{g.preventDefault(),g.stopPropagation(),r(e.id)},children:[f.letter,w>1?C("span",{className:"cm-pin__n","data-testid":`comment-pin-count-${e.id}`,"aria-hidden":"true",children:w}):null]})}function Kc({state:e,busy:t=!1,paused:n=kn(),onSubmit:o,onCancel:r}){let[s,a]=re(""),c=he(null);vs(c,s);let u=he(null),m=he(null);ps(()=>{let g=()=>{m.current=null;let k=u.current;if(!k)return;let E=Wc(e),b=ys(E,{w:k.offsetWidth,h:k.offsetHeight});k.style.left=`${Math.round(b.x)}px`,k.style.top=`${Math.round(b.y)}px`,k.dataset.placed="1",m.current=ie(g)};return g(),()=>{if(m.current!=null)Re(m.current)}},[e]),me(()=>{c.current?.focus()},[]);let h=te(()=>{let g=s.trim();if(!g||t||n)return;o(g)},[s,t,n,o]),f=te((g)=>{if(g.key==="Escape"){g.preventDefault(),r();return}if((g.metaKey||g.ctrlKey)&&g.key==="Enter")g.preventDefault(),h()},[r,h]),w=Be(()=>ks({artboard:e.anchors?.artboard,selector:e.selection.selector}),[e.anchors,e.selection]),M=Be(()=>{let g=e.anchors;if(!g?.artboard)return null;return _n(g,Pn(Yn(g.artboard))).chip},[e.anchors]);return U("div",{ref:u,className:"cm-composer",role:"dialog","aria-label":"New comment",onClick:(g)=>g.stopPropagation(),onPointerDown:(g)=>g.stopPropagation(),children:[U("div",{className:"cm-composer__head",children:[C("span",{className:"cm-composer__where","data-testid":M?"comment-composer-place":"comment-composer-where",children:w}),C("button",{type:"button",className:"cm-thread__close","data-testid":"comment-composer-cancel","aria-label":"Cancel",title:"Cancel · esc",onClick:r,children:"×"})]}),M?C("span",{className:"cm-chip cm-composer__chip","data-testid":"comment-composer-where",children:M}):null,n?C("p",{className:"cm-composer__paused",role:"status","data-testid":"comment-composer-paused",children:ct}):null,U("div",{className:"cm-composer__field",children:[C(Un,{textareaRef:c,className:"cm-composer__textarea",value:s,placeholder:"Add a comment — @ mentions someone",onChange:a,onKeyDown:f,rows:1,ariaLabel:"Comment body",disabled:n,title:n?ct:void 0}),C("button",{type:"button",className:"cm-btn cm-btn--primary cm-composer__send","data-testid":"comment-composer-send","aria-label":"Send",title:n?ct:"Send · ⌘↵",disabled:!s.trim()||t||n,onClick:h,children:C("svg",{width:"14",height:"14",viewBox:"0 0 16 16","aria-hidden":"true",children:C("path",{d:"M6 3.5 10.5 8 6 12.5",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]})}function zc(e){if(e.artboard)return ts(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 ts(n);let o=t?.getAttribute?.("data-dc-element");if(o)return o.replace(/[-_]+/g," ");return"On the canvas"}function Vc(e=Qn()){let t=(e??"").split("/").pop()??"";if(!/\.[a-z0-9]+$/i.test(t))return"";return t.replace(/\.[a-z0-9]+$/i,"").replace(/[-_]+/g," ").trim()}function ks(e,t=Qn()){let n=zc(e),o=Vc(t);if(!o)return n;return n==="On the canvas"?o:`${o} · ${n}`}var as=null;function Fc(){let[e,t]=re(null);return me(()=>{if(typeof fetch>"u")return;as??=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 as.then((o)=>n&&t(o)),()=>{n=!1}},[]),e}function Hc(e){return!e.annotationId&&typeof e.t!=="number"&&!e.mm}function $c({comment:e,sequence:t,onClose:n,onPatch:o,onDelete:r,onReply:s,onReattach:a,focusReply:c=0,mine:u=!1,me:m}){let h=he(null),f=he(null),w=he(null),[M,g]=re("");vs(f,M);let[k,E]=re(!1),[b,i]=re(null),S=te(()=>{let N=(b??"").trim();if(!N)return;if(N!==e.text)o({text:N});i(null)},[b,e.text,o]);ps(()=>{let N=()=>{w.current=null;let Z=h.current;if(!Z)return;let ze=Uc(e),fo=ys(ze,{w:Z.offsetWidth,h:Z.offsetHeight});Z.style.left=`${Math.round(fo.x)}px`,Z.style.top=`${Math.round(fo.y)}px`,Z.dataset.placed="1",w.current=ie(N)};return N(),()=>{if(w.current!=null)Re(w.current)}},[e]),me(()=>{h.current?.focus();let N=e.id;return()=>{document.querySelector(`[data-comment-pin="${N}"]`)?.focus()}},[e.id]),me(()=>{if(c>0)f.current?.focus()},[c,e.id]),me(()=>{if(typeof document>"u")return;let N=(Z)=>{if(Z.key!=="Escape")return;let ze=h.current;if(!ze)return;if(ze.contains(Z.target)||document.activeElement===ze)Z.preventDefault(),n()};return document.addEventListener("keydown",N),()=>document.removeEventListener("keydown",N)},[n]);let R=te(async()=>{let N=M.trim();if(!N||k)return;E(!0);let Z=await s(N);if(E(!1),Z)g(""),f.current?.focus()},[M,k,s]),F=te((N)=>{if((N.metaKey||N.ctrlKey)&&N.key==="Enter")N.preventDefault(),R()},[R]),A=`cm-thread-head-${e.id}`,L=kn(),K=(!Le()||Ge())&&!L,I=_n(e,e.artboard?Pn(Yn(e.artboard)):null),B=ks({artboard:e.artboard,selector:e.selector}),X=e.from,Q=An(e.importedFrom),se=(m??"").trim(),ee=X?se?(X.convertedBy??"").trim()===se:u:!1,oe=X?(e.thread??[]).find((N)=>(N.author??"").trim()!==(se||(X.convertedBy??"").trim())):void 0,le=oe?`${is(oe.author??"")||"Someone"} replied — resolve the thread instead.`:null,ye=!!X&&!Le(),[j,G]=re(!1),y=!!X,[x,T]=re(!1);me(()=>{if(x)f.current?.focus()},[x]);let[z,Y]=re(null),[ue,ge]=re(!1);me(()=>{if(!X||!ee){ge(!1);return}let N=!0;return qe({op:"convert-undoable",commentId:e.id}).then((Z)=>{if(N)ge(!!Z?.ok)}),()=>{N=!1}},[e.id,X,ee]);let rt=async(N)=>{G(!1),Y(null);let Z=await qe({op:N,commentId:e.id});if(Z?.ok)n();else Y(Z?.error||"That did not go through.")};return U("div",{ref:h,className:"cm-thread","data-seq":t,role:"dialog","data-esc-owner":"focus","aria-labelledby":A,tabIndex:-1,onClick:(N)=>N.stopPropagation(),onPointerDown:(N)=>N.stopPropagation(),children:[U("div",{className:"cm-thread__head",id:A,children:[y?null:U("div",{className:"cm-thread__head-row",children:[C("span",{className:"cm-thread__where","data-testid":`comment-where-${e.id}`,children:B}),U("span",{className:"cm-thread__head-end",children:[K?U("span",{className:"cm-thread__actions",children:[a&&Hc(e)?C("button",{type:"button",className:"cm-btn","data-testid":`comment-reattach-${e.id}`,"aria-label":"Re-attach to element",title:"Re-attach to element",onClick:a,children:"Re-attach"}):null,u&&b===null&&!Q?C("button",{type:"button",className:"cm-btn","data-testid":"comment-edit",onClick:()=>i(e.text),children:"Edit"}):null,e.status==="resolved"?U("button",{type:"button",className:"cm-btn cm-btn--ghost","data-testid":`comment-reopen-${e.id}`,onClick:()=>o({status:"open"}),children:[C(et,{d:"M3.5 8a4.5 4.5 0 1 0 1.4-3.3M3.5 2.5v2.6h2.6"}),"Reopen"]}):U("button",{type:"button",className:"cm-btn cm-btn--ghost","data-testid":`comment-resolve-${e.id}`,onClick:()=>{o({status:"resolved"}),n()},children:[C(et,{d:"M3 8.4 6.4 11.8 13 4.6"}),"Resolve"]}),u?C(Bc,{id:e.id,onConfirm:()=>{r(),n()}}):null]}):null,C("button",{type:"button",className:"cm-thread__close","aria-label":"Close thread",title:"Close · esc",onClick:n,children:"×"})]})]}),!y&&I.chip?I.kind==="video"&&typeof e.t==="number"&&e.artboard?C("button",{type:"button",className:"cm-chip cm-chip--seek","data-testid":`comment-chip-${e.id}`,title:"Go to this moment",onClick:()=>kc(e.artboard,e.t),children:I.chip}):C("span",{className:"cm-chip","data-testid":`comment-chip-${e.id}`,children:I.chip}):null,e.from?U("div",{className:"cm-thread__from","data-testid":`comment-from-${e.id}`,children:[C("svg",{width:"14",height:"14",viewBox:"0 0 16 16","aria-hidden":"true",className:"cm-thread__from-ic",children:C("path",{d:"M3 2.5h10v8l-3 3H3zM10 13.5v-3h3",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinejoin:"round"})}),U("span",{children:[fr(e.from)," · turned into a comment by"," ",ee?"You":is(e.from.convertedBy||e.author||""),ee&&ue&&!le?U(Xc,{children:[" · ",C("button",{type:"button",className:"cm-link","data-testid":`comment-from-undo-${e.id}`,onClick:()=>void rt("convert-undo"),children:"Undo"})]}):null]})]}):null,z?C("div",{className:"cm-thread__convert-line",role:"alert",children:z}):null]}),b===null?U("div",{className:"cm-msg cm-msg--root",children:[Q?C(ls,{}):C(Wn,{name:e.from?ut(e.from).name:e.author,ai:e.from?ut(e.from).ai:e.authorKind==="ai",viewer:e.from?m:Ze(e,m)}),U("div",{className:"cm-msg__main",children:[U("div",{className:"cm-msg__head",children:[C("span",{className:"cm-thread__author","data-testid":Q?`comment-imported-${e.id}`:void 0,children:Q?Mn(Q):e.from?ut(e.from).name:dt(e.author,Ze(e,m)).name}),C("span",{className:"cm-thread__time",children:us(Q?.at??e.created)})]}),C("div",{className:"cm-thread__body",children:Q?e.text:ds(e.text)}),e.queued?C(cs,{id:e.id}):null]})]}):U("div",{className:"cm-thread__reply-form",children:[C(Un,{className:"cm-thread__reply-textarea",value:b,placeholder:"Edit your comment… ⌘↵ to save",onChange:i,onKeyDown:(N)=>{if((N.metaKey||N.ctrlKey)&&N.key==="Enter")N.preventDefault(),S()},rows:3,ariaLabel:"Edit comment"}),U("div",{className:"cm-thread__reply-actions",children:[C("button",{type:"button",className:"cm-btn",onClick:()=>i(null),children:"Cancel"}),C("button",{type:"button",className:"cm-btn cm-btn--primary","data-testid":"comment-edit-save",disabled:!b.trim(),onClick:S,children:"Save"})]})]}),(e.thread??[]).map((N)=>{let Z=An(N.importedFrom);return U("div",{className:"cm-msg cm-thread__reply",children:[Z?C(ls,{}):C(Wn,{name:N.author,ai:N.authorKind==="ai",viewer:Ze(N,m)}),U("div",{className:"cm-msg__main",children:[U("div",{className:"cm-thread__reply-head",children:[C("span",{className:"cm-thread__reply-author",children:Z?Mn(Z):dt(N.author,Ze(N,m)).name}),C("span",{className:"cm-thread__reply-time",children:us(Z?.at??N.created)})]}),C("div",{className:"cm-thread__reply-body",children:Z?N.body:ds(N.body)}),N.queued?C(cs,{id:N.id}):null]})]},N.id)}),y&&K?U("div",{className:"cm-thread__foot","data-testid":`comment-foot-${e.id}`,children:[e.status==="resolved"?U("button",{type:"button",className:"cm-btn cm-btn--ghost","data-testid":`comment-reopen-${e.id}`,onClick:()=>o({status:"open"}),children:[C(et,{d:"M3.5 8a4.5 4.5 0 1 0 1.4-3.3M3.5 2.5v2.6h2.6"}),"Reopen"]}):U("button",{type:"button",className:"cm-btn cm-btn--ghost","data-testid":`comment-resolve-${e.id}`,onClick:()=>{o({status:"resolved"}),n()},children:[C(et,{d:"M3 8.4 6.4 11.8 13 4.6"}),"Resolve"]}),U("span",{className:"cm-thread__more",children:[C("button",{type:"button",className:"cm-btn cm-btn--icon","aria-label":"More","aria-haspopup":"menu","aria-expanded":j,"data-testid":`comment-menu-${e.id}`,onClick:()=>G((N)=>!N),children:"⋯"}),j?U("span",{className:"cm-thread__menu",role:"menu",children:[C("button",{type:"button",role:"menuitem",className:"cm-thread__menu-item","data-testid":`comment-menu-reply-${e.id}`,onClick:()=>{G(!1),T(!0)},children:"Reply…"}),u&&b===null&&!Q?C("button",{type:"button",role:"menuitem",className:"cm-thread__menu-item","data-testid":"comment-edit",onClick:()=>{G(!1),i(e.text)},children:"Edit"}):null,ye?C("button",{type:"button",role:"menuitem",className:"cm-thread__menu-item","data-testid":`comment-menu-to-sticky-${e.id}`,disabled:!!le,onClick:()=>void rt("to-sticky"),children:"Turn back into a sticky"}):null,u?C("button",{type:"button",role:"menuitem",className:"cm-thread__menu-item cm-thread__menu-item--danger","data-testid":`comment-delete-${e.id}`,onClick:()=>{r(),n()},children:"Delete comment"}):null,le?C("span",{className:"cm-thread__menu-note",children:le}):null]}):null]})]}):null,L&&Ge()?C("p",{className:"cm-thread__paused",role:"status","data-testid":`comment-paused-${e.id}`,children:ct}):null,K&&(!y||x||c>0)&&U("div",{className:"cm-thread__reply-form cm-thread__reply-form--field",children:[C(Un,{textareaRef:f,className:"cm-thread__reply-textarea",value:M,placeholder:"Reply…",title:"⌘↵ to send · @name to tag",onChange:g,onKeyDown:F,rows:1,ariaLabel:"Reply",disabled:k}),C("div",{className:"cm-thread__reply-actions",children:C("button",{type:"button",className:"cm-btn cm-btn--primary cm-thread__send","aria-label":"Send",title:"Send · ⌘↵",disabled:!M.trim()||k,onClick:()=>void R(),children:C("svg",{width:"14",height:"14",viewBox:"0 0 16 16","aria-hidden":"true",children:C("path",{d:"M6 3.5 10.5 8 6 12.5",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})})})]})]})}function is(e){return e.trim().split(/\s+/)[0]||e}function ls(){return C("span",{className:"cm-av cm-av--imported","aria-hidden":"true"})}var jc="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",qc=4000;function Bc({id:e,onConfirm:t}){let[n,o]=re(!1);return me(()=>{if(!n)return;let r=setTimeout(()=>o(!1),qc);return()=>clearTimeout(r)},[n]),C("button",{type:"button",className:`cm-btn cm-btn--ghost cm-btn--danger cm-btn--trash${n?" is-armed":""}`,"aria-label":n?"Confirm delete comment":"Delete comment",title:n?"Press again to delete":"Delete comment","data-testid":`comment-delete-${e}`,"data-armed":n?"true":void 0,onBlur:()=>o(!1),onKeyDown:(r)=>{if(r.key==="Escape"&&n)r.stopPropagation(),o(!1)},onClick:(r)=>{if(!n)return o(!0);if(r.detail>1)return;o(!1),t()},children:C(et,{d:jc})})}function cs({id:e}){return U("span",{className:"cm-queued","data-testid":`comment-queued-${e}`,children:[C(et,{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 et({d:e}){return C("svg",{width:"13",height:"13",viewBox:"0 0 16 16","aria-hidden":"true",className:"cm-glyph",children:C("path",{d:e,fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Wn({name:e,ai:t=!1,viewer:n}){let o=dt(e,n);return C("span",{className:`cm-av${t?" cm-av--ai":""}`,style:t?void 0:{["--cm-av-tone"]:Rn(o.tone)},"aria-hidden":"true",children:t?"AI":o.letter})}function ds(e){if(!e)return null;let t=/(@[\w][\w.-]*)/g;return e.split(t).map((o,r)=>{let s=`${r}:${o}`;if(r%2===1)return C("strong",{"data-mention":"true",children:o},s);return C("span",{children:o},s)})}function us(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 Uc(e){let{pos:t}=xs(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 Wc(e){if(e.clientX||e.clientY){let t=e.selection.selector?Bn(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=Bn(e.selection);if(t)return{x:t.x,y:t.y+t.h+8}}return{x:16,y:16}}import{useEffect as ad}from"react";function Gn(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.checkItemFocused?["checkItemFocused"]:[]]),...e.singleKeys===!1?{singleKeys:!1}:{}}}var Ut=["⌃","⌥","⇧","⌘"],Wt={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","-":"−","–":"−"},Ss=new Set(["↵","esc","Space","tab","⌫","⌦","←","→","↑","↓","Home","End","PageUp","PageDown"]),Yc={cmd:"⌘",command:"⌘",meta:"⌘",ctrl:"⌃",control:"⌃",alt:"⌥",opt:"⌥",option:"⌥",shift:"⇧"};function Qc(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(Yc[s.toLowerCase()]),""));for(;;){t=t.replace(/^\s+/,"");let r=Ut.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(Wt[o])o=Wt[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 Ut.filter((r)=>n.has(r)).join("")+o}function Es(e){let t=Qc(e);if(!t)throw Error(`actions/keys: '${e}' is not a key chord`);return t}var Gc={Minus:"−",Equal:"=",Slash:"/",Backslash:"\\",BracketLeft:"[",BracketRight:"]",Comma:",",Period:".",Semicolon:";",Quote:"'",Backquote:"`",Space:"Space"};function Zn(e){let t=new Set;if(e.metaKey||e.ctrlKey)t.add("⌘");if(e.altKey)t.add("⌥");let n=e.key??"";if(Wt[n])n=Wt[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]:Gc[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)||Ss.has(n)||/^F\d/.test(n);if(e.shiftKey&&r)t.add("⇧");return Ut.filter((s)=>t.has(s)).join("")+n}function Ts(e){let{mods:t,key:n}=Zc(e);if(t.some((o)=>o!=="⇧"))return!1;if(Ss.has(n)||/^F\d{1,2}$/.test(n))return!1;return n.length===1}function Rs(e){return e.includes("⌘")||e.includes("⌃")}function Zc(e){let t=[],n=e;for(;;){let o=Ut.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 As=new Set(["⌘Z","⇧⌘Z","⌘Y","⌘A","⌘C","⌘X","⌘V","⇧⌘V","⌥⇧⌘V","⌘B","⌘I","⌘U","⌘←","⌘→","⌘↑","⌘↓","⇧⌘←","⇧⌘→","⌥←","⌥→","⌘⌫","⌥⌫"].map(Es)),Dm=new Set(["⌘N","⇧⌘N","⌘T","⌘W","⌘Q","⌘L"].map(Es));var Jn={view:0,comment:1,edit:2,owner:3},Ms=["timeline","selection","tools","global"];function eo(e,t){if(!e)return!0;if(e.minRole&&Jn[t.role]<Jn[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)=>eo(n,t)))return!1;return!0}function Jc(e,t){return eo(e.visible,t)}function Cs(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 ed(e){return e.inText??(Rs(e.chord)&&!As.has(e.chord))}function td(e,t){if(t.focus==="text"&&!ed(e.binding))return!1;if(t.focus==="modal"&&!e.binding.inModal)return!1;if(e.binding.layer==="timeline"&&t.focus!=="timeline")return!1;return Jc(e.action,t)&&eo(e.binding.when,t)}function to(e,t,n,o="tap"){if(n.singleKeys===!1&&Ts(t))return null;let r=e.get(t);if(!r?.length)return null;let s=r.filter((a)=>o==="hold"===!!a.binding.hold&&td(a,n));if(!s.length)return null;for(let a of Ms){let c=s.filter((u)=>u.binding.layer===a);if(c.length)return{action:c[0].action,binding:c[0].binding,ambiguous:c.slice(1)}}return null}function nd(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")||n.every((o)=>o==="text"))}function Is(e,t,n){return Cs(e,(o,r)=>n(o.id)&&nd(r,t))}var Xt=[{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:"artboard.cut",exec:"canvas",enabled:{minRole:"edit",selection:["artboard"]},keys:[{chord:"⌘X",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["artboard"]}}]},{id:"edit.copy-properties",exec:"canvas",visible:{minRole:"comment"},keys:[{chord:"⌥⌘C",layer:"selection",when:{focus:["canvas"],selection:["object"]}},{chord:"⌥⇧⌘C",layer:"selection",when:{focus:["canvas"],selection:["object"]},alias:!0}]},{id:"edit.paste-properties",exec:"canvas",visible:{minRole:"comment"},enabled:{minRole:"edit"},keys:[{chord:"⌥⌘V",layer:"selection",when:{focus:["canvas"],selection:["object"]}},{chord:"⌥⇧⌘V",layer:"selection",when:{focus:["canvas"],selection:["object"]},alias:!0}]},{id:"object.enter",exec:"canvas",keys:[{chord:"↵",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["object"],notFacts:["toolArmed"]}}]},{id:"object.select-parent",exec:"canvas",keys:[{chord:"⇧↵",layer:"selection",when:{focus:["canvas"],selection:["object"]}}]},{id:"object.select-next",exec:"canvas",keys:[{chord:"tab",layer:"selection",when:{focus:["canvas"],mode:["edit"]}}]},{id:"object.select-prev",exec:"canvas",keys:[{chord:"⇧tab",layer:"selection",when:{focus:["canvas"],mode:["edit"]}}]},{id:"object.remove",exec:"canvas",keys:[{chord:"⌫",layer:"selection",when:{focus:["canvas"],selection:["object"]}},{chord:"⇧⌫",layer:"selection",when:{focus:["canvas"],selection:["object"]},alias:!0},{chord:"⌦",layer:"selection",when:{focus:["canvas"],selection:["object"]}},{chord:"⇧⌦",layer:"selection",when:{focus:["canvas"],selection:["object"]},alias:!0}]},{id:"object.nudge",exec:"canvas",keys:[{chord:"←",layer:"selection",when:{focus:["canvas"],selection:["object","artboard"],notFacts:["selectionHasTakes"]}},{chord:"⇧←",layer:"selection",when:{focus:["canvas"],selection:["object","artboard"]},alias:!0},{chord:"→",layer:"selection",when:{focus:["canvas"],selection:["object","artboard"],notFacts:["selectionHasTakes"]}},{chord:"⇧→",layer:"selection",when:{focus:["canvas"],selection:["object","artboard"]},alias:!0},{chord:"↑",layer:"selection",when:{focus:["canvas"],selection:["object","artboard"]}},{chord:"⇧↑",layer:"selection",when:{focus:["canvas"],selection:["object","artboard"]},alias:!0},{chord:"↓",layer:"selection",when:{focus:["canvas"],selection:["object","artboard"]}},{chord:"⇧↓",layer:"selection",when:{focus:["canvas"],selection:["object","artboard"]},alias:!0}]},{id:"object.frame",exec:"canvas",enabled:{minRole:"edit",selection:["object"]},keys:[{chord:"⌥⌘G",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["object"]}},{chord:"⌘G",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["object"]},alias:!0}]},{id:"object.unframe",exec:"canvas",enabled:{minRole:"edit",selection:["object"]},keys:[{chord:"⇧⌘G",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["object"]}}]},{id:"object.bring-front",exec:"canvas",enabled:{minRole:"edit",selection:["object"]},keys:[{chord:"⌘]",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["object"]}}]},{id:"object.bring-forward",exec:"canvas",enabled:{minRole:"edit",selection:["object"]},keys:[{chord:"]",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["object"]}}]},{id:"object.send-backward",exec:"canvas",enabled:{minRole:"edit",selection:["object"]},keys:[{chord:"[",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["object"]}}]},{id:"object.send-back",exec:"canvas",enabled:{minRole:"edit",selection:["object"]},keys:[{chord:"⌘[",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["object"]}}]},{id:"object.lock",exec:"canvas",enabled:{minRole:"edit",selection:["object"]},keys:[{chord:"⇧⌘L",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["object"]}}]},{id:"artboard.duplicate",exec:"canvas",enabled:{minRole:"edit",selection:["artboard"]},keys:[{chord:"⌘D",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["artboard"]}}]},{id:"artboard.trash",exec:"canvas",enabled:{minRole:"edit",selection:["artboard"]},keys:[{chord:"⌫",layer:"selection",when:{focus:["canvas"],selection:["artboard"]}},{chord:"⇧⌫",layer:"selection",when:{focus:["canvas"],selection:["artboard"]},alias:!0},{chord:"⌦",layer:"selection",when:{focus:["canvas"],selection:["artboard"]}},{chord:"⇧⌦",layer:"selection",when:{focus:["canvas"],selection:["artboard"]},alias:!0}]},{id:"ai.ask-selection",exec:"canvas",visible:{minRole:"edit"},enabled:{minRole:"edit",selection:["object"]},keys:[{chord:"⌘/",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["object"]}}]},{id:"inspect.edit",exec:"canvas",enabled:{minRole:"edit",mode:["preview","viewing"],selection:["object"]},keys:[{chord:"↵",layer:"selection",when:{focus:["canvas"],mode:["preview","viewing"],selection:["object"]}}]},{id:"mode.preview",exec:"canvas",enabled:{notFacts:["pagesView"]},keys:[{chord:"⌥⌘P",layer:"global",inText:!0,when:{mode:["edit","preview","viewing"]}}]},{id:"view.panels",exec:"shell",fromCanvas:!0,keys:[{chord:"⌘\\",layer:"global",inText:!0}]},{id:"view.comments",exec:"shell",fromCanvas:!0,keys:[{chord:"⇧⌘M",layer:"global",inText:!0}]},{id:"history.open",exec:"shell",fromCanvas:!0,keys:[{chord:"⌥⌘H",layer:"global",inText:!0}]},{id:"view.inspector",exec:"shell",fromCanvas:!0,keys:[{chord:"⇧⌘I",layer:"global",inText:!0}]},{id:"view.timeline-keep-open",exec:"shell",fromCanvas:!0,keys:[{chord:"⇧⌘T",layer:"global",inText:!0}]},{id:"view.annotations",exec:"canvas",keys:[{chord:"⇧P",layer:"global",inText:!1,when:{focus:["canvas"]}}]},{id:"present.from-selection",exec:"shell",enabled:{notFacts:["pagesView"]},fromCanvas:!0,keys:[{chord:"⌥⌘↵",layer:"global",when:{mode:["edit","viewing","preview"]}}]},{id:"present.from-start",exec:"shell",enabled:{notFacts:["pagesView"]},fromCanvas:!0,keys:[{chord:"⌥⇧⌘↵",layer:"global",when:{mode:["edit","viewing","preview"]}}]},{id:"present.next",exec:"shell",keys:[{chord:"→",layer:"global",when:{mode:["present"]}},{chord:"Space",layer:"global",when:{mode:["present"]}}]},{id:"present.prev",exec:"shell",keys:[{chord:"←",layer:"global",when:{mode:["present"]}},{chord:"⇧Space",layer:"global",when:{mode:["present"]}}]},{id:"view.zoom-in",exec:"canvas",keys:[{chord:"⌘=",layer:"global",inText:!0,when:{focus:["canvas","text"]}},{chord:"⌘+",layer:"global",inText:!0,alias:!0,when:{focus:["canvas","text"]}}]},{id:"view.zoom-out",exec:"canvas",keys:[{chord:"⌘−",layer:"global",inText:!0,when:{focus:["canvas","text"]}}]},{id:"view.zoom-fit",exec:"canvas",keys:[{chord:"⌘0",layer:"global",inText:!0,when:{focus:["canvas","text"]}}]},{id:"view.zoom-actual",exec:"canvas",keys:[{chord:"⇧0",layer:"global",inText:!1,when:{focus:["canvas","text"]}}]},{id:"view.jump-artboard",exec:"canvas",keys:[{chord:"⌥⌘1",layer:"global",inText:!0,alias:!1,when:{focus:["canvas","text"]}},{chord:"⌥⌘2",layer:"global",inText:!0,alias:!0,when:{focus:["canvas","text"]}},{chord:"⌥⌘3",layer:"global",inText:!0,alias:!0,when:{focus:["canvas","text"]}},{chord:"⌥⌘4",layer:"global",inText:!0,alias:!0,when:{focus:["canvas","text"]}},{chord:"⌥⌘5",layer:"global",inText:!0,alias:!0,when:{focus:["canvas","text"]}},{chord:"⌥⌘6",layer:"global",inText:!0,alias:!0,when:{focus:["canvas","text"]}},{chord:"⌥⌘7",layer:"global",inText:!0,alias:!0,when:{focus:["canvas","text"]}},{chord:"⌥⌘8",layer:"global",inText:!0,alias:!0,when:{focus:["canvas","text"]}},{chord:"⌥⌘9",layer:"global",inText:!0,alias:!0,when:{focus:["canvas","text"]}}]},{id:"pages.next",exec:"canvas",enabled:{facts:["canvasOpen","pagesView"]},keys:[{chord:"PageDown",layer:"global",when:{focus:["canvas"],mode:["edit","viewing"]}},{chord:"→",layer:"global",alias:!0,when:{focus:["canvas"],mode:["edit","viewing"],selection:["none"]}}]},{id:"pages.prev",exec:"canvas",enabled:{facts:["canvasOpen","pagesView"]},keys:[{chord:"PageUp",layer:"global",when:{focus:["canvas"],mode:["edit","viewing"]}},{chord:"←",layer:"global",alias:!0,when:{focus:["canvas"],mode:["edit","viewing"],selection:["none"]}}]},{id:"tool.select",exec:"canvas",keys:[{chord:"V",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit"]}}]},{id:"tool.hand",exec:"canvas",keys:[{chord:"H",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit","preview"]}}]},{id:"tool.frame",exec:"canvas",keys:[{chord:"F",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit","preview","viewing"]}}]},{id:"tool.el-shape",exec:"canvas",keys:[{chord:"R",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit"]}}]},{id:"tool.el-pen",exec:"canvas",keys:[{chord:"P",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit","preview","viewing"]}}]},{id:"tool.el-text",exec:"canvas",keys:[{chord:"T",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit"]}}]},{id:"tool.image",exec:"canvas",keys:[{chord:"I",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit","preview","viewing"]}}]},{id:"tool.components",exec:"canvas",keys:[{chord:"⇧I",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit","preview","viewing"]}}]},{id:"tool.browse",exec:"canvas",keys:[{chord:"V",layer:"tools",when:{focus:["canvas","chrome"],mode:["preview","viewing"]}}]},{id:"tool.sticky",exec:"canvas",keys:[{chord:"N",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit","preview","viewing"]}}]},{id:"tool.comment",exec:"canvas",keys:[{chord:"C",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit","preview","viewing"]}}]},{id:"tool.pen",exec:"canvas",keys:[{chord:"M",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit","preview","viewing"]}}]},{id:"tool.arrow",exec:"canvas",keys:[{chord:"A",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit","preview","viewing"]}}]},{id:"tool.shape",exec:"canvas",keys:[{chord:"R",layer:"tools",when:{focus:["canvas","chrome"],mode:["preview","viewing"]}}]},{id:"tool.text",exec:"canvas",keys:[{chord:"T",layer:"tools",when:{focus:["canvas","chrome"],mode:["preview","viewing"]}}]},{id:"tool.stickers",exec:"canvas",keys:[{chord:"E",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit","preview","viewing"]}}]},{id:"tool.section",exec:"canvas",keys:[{chord:"S",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit","preview","viewing"]}}]},{id:"tool.inspect",exec:"canvas",keys:[{chord:"H",layer:"tools",when:{focus:["canvas","chrome"],mode:["viewing"]}}]},{id:"tool.pointer",exec:"canvas",keys:[{chord:"L",layer:"tools",when:{focus:["canvas","chrome"],mode:["present"]}}]},{id:"tool.hand-hold",exec:"canvas",keys:[{chord:"Space",layer:"tools",hold:!0,when:{focus:["canvas"]}},{chord:"⌥Space",layer:"tools",hold:!0,when:{focus:["canvas"]},alias:!0},{chord:"⇧Space",layer:"tools",hold:!0,when:{focus:["canvas"]},alias:!0},{chord:"⌥⇧Space",layer:"tools",hold:!0,when:{focus:["canvas"]},alias:!0},{chord:"⌘Space",layer:"tools",hold:!0,when:{focus:["canvas"]},alias:!0},{chord:"⌥⌘Space",layer:"tools",hold:!0,when:{focus:["canvas"]},alias:!0},{chord:"⇧⌘Space",layer:"tools",hold:!0,when:{focus:["canvas"]},alias:!0},{chord:"⌥⇧⌘Space",layer:"tools",hold:!0,when:{focus:["canvas"]},alias:!0}]},{id:"tool.create-default",exec:"canvas",enabled:{minRole:"edit"},keys:[{chord:"↵",layer:"tools",when:{focus:["canvas"],mode:["edit","preview"],facts:["toolArmed"]}}]},{id:"ui.step-back",exec:"shell",keys:[{chord:"esc",layer:"selection",inText:!1,when:{focus:["canvas"]}},{chord:"⌥esc",layer:"selection",inText:!1,when:{focus:["canvas"]},alias:!0},{chord:"⇧esc",layer:"selection",inText:!1,when:{focus:["canvas"]},alias:!0},{chord:"⌥⇧esc",layer:"selection",inText:!1,when:{focus:["canvas"]},alias:!0},{chord:"⌘esc",layer:"selection",inText:!1,when:{focus:["canvas"]},alias:!0},{chord:"⌥⌘esc",layer:"selection",inText:!1,when:{focus:["canvas"]},alias:!0},{chord:"⇧⌘esc",layer:"selection",inText:!1,when:{focus:["canvas"]},alias:!0},{chord:"⌥⇧⌘esc",layer:"selection",inText:!1,when:{focus:["canvas"]},alias:!0}]},{id:"ui.cycle-region",exec:"shell",fromCanvas:!0,keys:[{chord:"F6",layer:"global",inText:!0},{chord:"⇧F6",layer:"global",inText:!0,alias:!0}]},{id:"timeline.split",exec:"shell",keys:[{chord:"⌘B",layer:"global",when:{facts:["timelineVisible"]},inText:!1,alias:!0}]},{id:"export.open",exec:"shell",visible:{minRole:"comment"},fromCanvas:!0,keys:[{chord:"⇧⌘E",layer:"global",inText:!0}]},{id:"export.copy-png",exec:"shell",visible:{minRole:"comment"},enabled:{facts:["canvasOpen"]},fromCanvas:!0,keys:[{chord:"⇧⌘C",layer:"selection",inText:!1,when:{selection:["artboard","object","video-artboard","generated-image"]}}]},{id:"handoff.open",exec:"shell",visible:{minRole:"comment"},enabled:{minRole:"edit",facts:["canvasOpen"]},fromCanvas:!0,keys:[{chord:"⇧⌘H",layer:"global",inText:!0}]},{id:"settings.open",exec:"shell",fromCanvas:!0,keys:[{chord:"⌘,",layer:"global",inText:!0,when:{focus:["chrome","timeline","text","canvas"]}}]},{id:"help.shortcuts",exec:"shell",fromCanvas:!0,keys:[{chord:"?",layer:"global",inText:!1,when:{focus:["chrome","timeline","canvas"],notFacts:["rangeFocused"]}},{chord:"⌘?",layer:"global",inText:!1,alias:!0,when:{focus:["chrome","timeline","canvas"],notFacts:["rangeFocused"]}}]},{id:"annotation.group",exec:"canvas",keys:[{chord:"⌘G",layer:"selection",when:{focus:["canvas"],selection:["annotation"],mode:["preview"]}}]},{id:"annotation.ungroup",exec:"canvas",keys:[{chord:"⇧⌘G",layer:"selection",when:{focus:["canvas"],selection:["annotation"],mode:["preview"]}}]},{id:"annotation.lock",exec:"canvas",keys:[{chord:"⇧⌘L",layer:"selection",when:{focus:["canvas"],selection:["annotation"],mode:["preview"]}}]},{id:"annotation.duplicate",exec:"canvas",keys:[{chord:"⌘D",layer:"selection",when:{focus:["canvas"],selection:["annotation"]}}]},{id:"annotation.to-front",exec:"canvas",keys:[{chord:"]",layer:"selection",when:{focus:["canvas"],selection:["annotation"],mode:["preview"]}}]},{id:"annotation.forward",exec:"canvas",keys:[{chord:"⌘]",layer:"selection",when:{focus:["canvas"],selection:["annotation"],mode:["preview"]}}]},{id:"annotation.to-back",exec:"canvas",keys:[{chord:"[",layer:"selection",when:{focus:["canvas"],selection:["annotation"],mode:["preview"]}}]},{id:"annotation.backward",exec:"canvas",keys:[{chord:"⌘[",layer:"selection",when:{focus:["canvas"],selection:["annotation"],mode:["preview"]}}]},{id:"annotation.copy",exec:"canvas",keys:[{chord:"⌘C",layer:"selection",when:{focus:["canvas"],selection:["annotation"]}}]},{id:"annotation.cut",exec:"canvas",keys:[{chord:"⌘X",layer:"selection",when:{focus:["canvas"],selection:["annotation"]}}]},{id:"annotation.chain",exec:"canvas",keys:[{chord:"⌘↵",layer:"selection",when:{focus:["canvas"],selection:["annotation"]}}]},{id:"annotation.edit-text",exec:"canvas",keys:[{chord:"↵",layer:"selection",when:{focus:["canvas"],selection:["annotation"],notFacts:["checkItemFocused"]}}]},{id:"annotation.nudge",exec:"canvas",keys:[{chord:"←",layer:"selection",when:{focus:["canvas"],selection:["annotation"],notFacts:["checkItemFocused"]}},{chord:"⇧←",layer:"selection",when:{focus:["canvas"],selection:["annotation"],notFacts:["checkItemFocused"]},alias:!0},{chord:"→",layer:"selection",when:{focus:["canvas"],selection:["annotation"],notFacts:["checkItemFocused"]}},{chord:"⇧→",layer:"selection",when:{focus:["canvas"],selection:["annotation"],notFacts:["checkItemFocused"]},alias:!0},{chord:"↑",layer:"selection",when:{focus:["canvas"],selection:["annotation"],notFacts:["checkItemFocused"]}},{chord:"⇧↑",layer:"selection",when:{focus:["canvas"],selection:["annotation"],notFacts:["checkItemFocused"]},alias:!0},{chord:"↓",layer:"selection",when:{focus:["canvas"],selection:["annotation"],notFacts:["checkItemFocused"]}},{chord:"⇧↓",layer:"selection",when:{focus:["canvas"],selection:["annotation"],notFacts:["checkItemFocused"]},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:"checklist.toggle",exec:"canvas",enabled:{minRole:"edit",selection:["annotation"]},keys:[{chord:"Space",layer:"selection",when:{focus:["canvas"],selection:["annotation"],facts:["checkItemFocused"]}},{chord:"⌘↵",layer:"selection",when:{focus:["text"],selection:["annotation"],facts:["checkItemFocused"]},inText:!0}]},{id:"checklist.edit",exec:"canvas",enabled:{minRole:"edit",selection:["annotation"]},keys:[{chord:"↵",layer:"selection",when:{focus:["canvas"],selection:["annotation"],facts:["checkItemFocused"]}}]},{id:"checklist.add-below",exec:"canvas",enabled:{minRole:"edit",selection:["annotation"]},keys:[{chord:"↵",layer:"selection",when:{focus:["text"],selection:["annotation"],facts:["checkItemFocused"]},inText:!0}]},{id:"checklist.remove-empty",exec:"canvas",enabled:{minRole:"edit",selection:["annotation"]},keys:[{chord:"⌫",layer:"selection",when:{focus:["text"],selection:["annotation"],facts:["checkItemFocused"]},inText:!0}]},{id:"checklist.move-up",exec:"canvas",enabled:{minRole:"edit",selection:["annotation"]},keys:[{chord:"⌥⌘↑",layer:"selection",when:{focus:["canvas","text"],selection:["annotation"],facts:["checkItemFocused"]},inText:!0}]},{id:"checklist.move-down",exec:"canvas",enabled:{minRole:"edit",selection:["annotation"]},keys:[{chord:"⌥⌘↓",layer:"selection",when:{focus:["canvas","text"],selection:["annotation"],facts:["checkItemFocused"]},inText:!0}]},{id:"checklist.focus-prev",exec:"canvas",enabled:{minRole:"edit",selection:["annotation"]},keys:[{chord:"↑",layer:"selection",when:{focus:["canvas"],selection:["annotation"],facts:["checkItemFocused"]}}]},{id:"checklist.focus-next",exec:"canvas",enabled:{minRole:"edit",selection:["annotation"]},keys:[{chord:"↓",layer:"selection",when:{focus:["canvas"],selection:["annotation"],facts:["checkItemFocused"]}}]},{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 Ps(e){let t=new Set(e);return Is(Xt,"canvas",(n)=>t.has(n))}var Zm=Object.freeze({edit:["stroke","selection","tool"],preview:["stroke","tool","selection"],viewing:["stroke","tool","selection"],present:[]}),Jm=Object.freeze({edit:"stay",preview:"stay",viewing:"stay",present:"back"}),_s="data-esc-owner";function Ls(e){let t=e?.querySelectorAll?.(`[${_s}]`);if(!t)return!1;for(let n of Array.from(t)){if(n.getAttribute(_s)!=="focus")return!0;let o=e?.activeElement??null;if(o&&(n===o||n.contains(o)))return!0}return!1}var od=["pen","highlighter","eraser"],rd=Symbol.for("maude.markerTip.v2"),sd=(e)=>typeof e==="string"&&od.includes(e);function Os(){let e=globalThis[rd];return sd(e)?e:"pen"}function Ns(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 no(e,t){let n=null;if(t){let o=Ns(t.getBoundingClientRect());n=o.w>0&&o.h>0?o:null}return{dgn:"tool-panel-open",panel:e,anchor:n}}var Ds=!1,Ks=!1;function oo(e=globalThis.document){if(Ds=!0,Ks||!e)return;Ks=!0,e.addEventListener("pointerdown",()=>{Ds=!1},!0)}function zs(e,t){try{if(typeof window>"u"||window.parent===window)return;oo(),window.parent.postMessage(no(e,t),"*")}catch{}}function Vs(e,t){return t==="section"&&e!=="section"?"templates":null}var id=new Set(["pen","highlighter","shape","rect","ellipse","arrow","sticky","text","el-text","frame","el-shape","line","polygon","slice","el-pen","section","eraser"]);function Ws(e){return id.has(e)}var Xs={"ui.step-back":{kind:"escape"},"edit.undo":{kind:"undo"},"edit.redo":{kind:"redo"}},ld=Ps(Xt.filter((e)=>e.id.startsWith("tool.")&&e.id!=="tool.hand-hold"||e.id==="mode.preview").map((e)=>e.id).concat(Object.keys(Xs))),cd=new Set([...on,"el-text","frame","el-shape","ellipse","line","polygon","slice","el-pen","crop","inspect"]),Fs=(e)=>ko(e,(t)=>cd.has(t));function dd(e,t,n){let o=!!n.mode;if(!o&&e==="V")return{kind:"tool",tool:"move"};let r=So(t,e,n.caps??yo,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=Fs(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=Fs(r.tool??st[r.mode].rest);return s?{kind:"tool",tool:s}:{kind:"no-op"}}function ud(e){let t=Zn({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=to(ld,t,Gn({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 dd(r.binding.chord,o,e);let a=Xs[s];if(!a)return{kind:"no-op"};if(a.kind==="escape"&&n&&!Sn()){if(ln(n,e.activeTool)==="back")return{kind:"escape",back:!0};if(cr())return{kind:"escape",back:!0}}return{...a}}var ft=(e)=>!!(e.metaKey||e.ctrlKey);function Hs(e){if(!Ws(e.activeTool))return!1;return!e.mode||yt(e.mode,"annotations-editable")}function gt(e){if(e.type==="keydown")return ud(e);if(e.type==="contextmenu")return{kind:"context-menu",clientX:e.clientX??0,clientY:e.clientY??0};if(e.type==="pointermove"){if(Hs(e))return{kind:"no-op"};if(e.activeTool==="hand")return{kind:"no-op"};if(e.activeTool==="browse"){if(!ft(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:ft(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(Hs(e)&&!ft(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(!ft(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=ft(e);return{kind:"select",mode:!!e.shiftKey?"add":"replace",deep:t,clientX:e.clientX??0,clientY:e.clientY??0}}return{kind:"no-op"}}function Yt(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 ht(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 Ys(e){if(!e||typeof e.closest!=="function")return!1;let t=e;return!!t.closest("[data-dc-screen]")&&!t.closest(".dc-artboard-body")}function $s(e,t){if(!t||!yt(t,"live-design")||!e||typeof e.closest!=="function")return!1;return!!e.closest("button.dc-artboard-label")}function js(e,t,n){return e.kind==="select"&&!n.metaKey&&!n.ctrlKey&&(Ys(t)||pd(t,n.clientX,n.clientY))}function pd(e,t,n){if(!e||typeof e.closest!=="function")return!1;let o=e;if(!o.closest(".dc-artboard-body")||typeof t!=="number"||typeof n!=="number")return!1;let r=Qt(o.ownerDocument,t,n,{deep:!1});return!!r&&r.cdId===null&&r.el.hasAttribute("data-dc-screen")}function md(e,t,n){return e==="select"&&!n.metaKey&&!n.ctrlKey&&Ys(t)}var fd="maude:toolbar-insert",gd=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,hd=/^[A-Za-z0-9_-]{1,64}$/;function bd(e,t){if(!yt(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||!gd.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&&hd.test(r)?r:null}}var qs=new WeakSet;function yd(e){if(typeof window>"u"||window.parent===window)return!1;let t=bd(e.target,{mode:Ae(window).get()?.mode??null,button:e.button,mod:e.metaKey||e.ctrlKey,shift:e.shiftKey});if(!t)return!1;if(e.preventDefault(),qs.has(e))return!0;qs.add(e);try{window.parent.postMessage({dgn:"link-follow",elementId:t.elementId,artboardId:t.artboardId},"*")}catch{}return!0}function Bs(e){if(typeof window>"u"||window.parent===window)return;if(!Ae(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 Us(e){if(typeof window>"u"||window.parent===window)return;try{let t=document.querySelector(`[data-testid="toolbar-slot-${e}"]`);oo(),window.parent.postMessage(no(e,t),"*")}catch{}}function Qs(e){let{hostRef:t,getActiveTool:n,isSpaceHeld:o,callbacks:r,enabled:s=!0,claimableActions:a}=e;ad(()=>{if(!s)return;let c=t.current;if(!c)return;let u=(i)=>a&&i.kind!=="no-op"&&!a.has(i.kind)?{kind:"no-op"}:i,m=(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 S=r.onEscape?.();if(i.back&&S!==!0)Bs({mode:"back",cause:"esc"});break}case"mode-request":if(Bs(i),i.panel)Us(i.panel);break;case"insert":if(typeof document<"u")document.dispatchEvent(new CustomEvent(fd,{detail:{kind:i.insert}}));break;case"panel":Us(i.panel);break;case"undo":r.onUndo?.();break;case"redo":r.onRedo?.();break;case"no-op":break}},h=()=>typeof window<"u"?Ae(window).get().mode:null,f=(i)=>{let S=u(gt({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()}));m(S)},w=(i)=>{if(ht(i.target))return;if(Yt(i.target))return;let S=u(gt({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:$s(i.target,h())})),R=js(S,i.target,i)||S.kind==="select"&&n()==="inspect";if(S.kind!=="no-op"){if(i.preventDefault(),!R)i.stopImmediatePropagation()}m(S)},M=(i)=>{if(ht(i.target))return;if(Yt(i.target))return;let S=u(gt({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:$s(i.target,h())})),R=js(S,i.target,i);if(S.kind!=="no-op"){if(i.preventDefault(),!R)i.stopImmediatePropagation();if(S.kind==="select")try{window.focus()}catch{}}},g=(i)=>{if(ht(i.target))return;if(Yt(i.target))return;if(yd(i))return;let S=n(),R=i.metaKey||i.ctrlKey,F=S==="comment"?"drop-comment":(S==="move"||S==="inspect")&&i.button===0?"select":(Ws(S)||S==="browse")&&R&&i.button===0?"select":i.button===2?"context-menu":null;if(F&&(!a||a.has(F))){let A=md(F,i.target,i);if(i.preventDefault(),!A)i.stopImmediatePropagation()}},k=(i)=>{let S=u(gt({type:"contextmenu",clientX:i.clientX,clientY:i.clientY,metaKey:i.metaKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,altKey:i.altKey,activeTool:n()}));if(S.kind==="no-op")return;i.preventDefault(),i.stopImmediatePropagation(),m(S)},E=(i)=>{let S=typeof window<"u"?Ae(window).get():null,R=u(gt({type:"keydown",key:i.key,code:i.code,metaKey:i.metaKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,altKey:i.altKey,isEditable:Yt(i.target),activeTool:n(),mode:S?.mode??null,caps:S?.caps??null,markerTip:Os(),singleKeys:S?.singleKeys??!0}));if(R.kind==="escape"&&Ls(c.ownerDocument??document))return;if(R.kind==="tool"||R.kind==="mode-request"||R.kind==="insert"||R.kind==="panel"||R.kind==="escape"&&!Sn()||R.kind==="undo"||R.kind==="redo")i.preventDefault();m(R)};c.addEventListener("pointermove",f,{passive:!0}),c.addEventListener("pointerdown",w,{capture:!0}),c.addEventListener("mousedown",M,{capture:!0}),c.addEventListener("click",g,{capture:!0}),c.addEventListener("contextmenu",k,{capture:!0});let b=c.ownerDocument??document;return b.addEventListener("keydown",E,!0),()=>{c.removeEventListener("pointermove",f),c.removeEventListener("pointerdown",w,{capture:!0}),c.removeEventListener("mousedown",M,{capture:!0}),c.removeEventListener("click",g,{capture:!0}),c.removeEventListener("contextmenu",k,{capture:!0}),b.removeEventListener("keydown",E,!0)}},[s,t,n,o,r,a])}function wd(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 Qt(e,t,n,o){let r=e.elementFromPoint(t,n);if(!r)return null;if(r.closest?.(".dc-mm, .dc-zoom-tb, .dc-tool-palette, .dc-context-menu, .dc-cv-group-bbox"))return null;let s=r.closest?.("[data-dc-screen]")??null,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 M=r.getAttribute?.("data-cd-id")??null;return{el:r,cdId:M,artboardId:a}}let u=r,m=null,h=null;while(u&&u!==c){if(u.hasAttribute?.("data-cd-id"))h=m,m=u;u=u.parentElement}if(m&&wd(c)===m){if(!h)return s&&a?{el:s,cdId:null,artboardId:a}:null;m=h}let f=m??r,w=f.getAttribute?.("data-cd-id")??null;return{el:f,cdId:w,artboardId:a}}import{useCallback as Ld,useEffect as ia,useRef as en}from"react";var vd=!1;function Gs(){return vd}import{createContext as Ad,useCallback as We,useContext as sa,useEffect as bt,useMemo as ta,useRef as Ke,useState as Gt}from"react";function Pe(e,t,n,o){return`url("data:image/svg+xml,${encodeURIComponent(e.trim())}") ${t} ${n}, ${o}`}var so="width='24' height='24' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'",ao="#1f1f1f",ro="stroke='#ffffff' stroke-linejoin='round' stroke-linecap='round'";function Ue(e,t,n){let o=n?`<g transform='${n}'>`:"";return`<svg ${so}>${o}<path fill='#ffffff' d='${e}'/><path fill='${ao}' d='${t}'/>${n?"</g>":""}</svg>`}var ea="translate(0,32) scale(1,-1)",Zs=Pe(Ue("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"),xd=Pe(Ue("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"),kd=Pe(Ue("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"),Sd=Pe(Ue("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",ea),6,18,"crosshair"),Ed=Pe(Ue("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",ea),6,18,"crosshair"),Se=Pe(Ue("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"),Td=Pe(Ue("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"),Js=Pe(`<svg ${so}><path d='M16 4V28M11 4H21M11 28H21' fill='none' ${ro} stroke-width='5'/><path d='M16 4V28M11 4H21M11 28H21' fill='none' stroke='${ao}' stroke-width='2.25' stroke-linecap='round'/></svg>`,12,12,"text"),Rd=Pe(`<svg ${so}><path d='M6 5H21L26 10V27H6Z' fill='${ao}' ${ro} stroke-width='2.5'/><path d='M21 5V11H26' fill='none' ${ro} stroke-width='2.25'/></svg>`,5,5,"crosshair"),ne=Object.freeze({browse:"default",move:Zs,inspect:Zs,hand:xd,comment:kd,pen:Sd,section:Se,highlighter:Ed,shape:Se,rect:Se,ellipse:Se,sticky:Rd,arrow:Se,text:Js,"el-text":Js,frame:Se,"el-shape":Se,line:Se,polygon:Se,slice:Se,"el-pen":Se,crop:Se,eraser:Td});import{jsx as io,Fragment as _d}from"react/jsx-runtime";function na(e,t){if(typeof window>"u"||window.parent===window)return;if(!Ae(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 Zt="maude:tool-sync",oa=Object.freeze({preview:"browse",edit:"move"});function ra(e){if(e==="browse")return"preview";if(e==="move")return"edit";return null}var Md=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}]),Cd=new Set(["browse","move","hand","inspect"]);function Id(e,t,n=!1){return t?e.filter((o)=>Cd.has(o.id)||n&&o.id==="comment"):e}var lo=Ad(null);function Pd({children:e,tools:t=Md,initial:n,initialMode:o,governed:r=!1}){let s=Le(),a=s&&Ge(),c=ta(()=>Id(t,s,a),[t,s,a]),u=n??(s?"browse":"move"),m=o??ra(u)??(s?"preview":"edit"),[h,f]=Gt(u),w=Ke(u),M=We((j)=>{w.current=j,f(j)},[]),g=We(()=>w.current,[]),[k,E]=Gt(m),[b,i]=Gt(()=>({tool:null,locked:!1})),S=Ke(null),R=We((j)=>{if(!c.some((x)=>x.id===j))return;let G=S.current;if(G){let x=at(j,G.caps,G.mode);if(x&&x!==G.mode){if(G.mode!=="present")na(x,j);return}M(j),i((T)=>T.locked&&T.tool===j?T:{tool:null,locked:!1});return}M(j);let y=ra(j);if(y)E(y);i((x)=>x.locked&&x.tool===j?x:{tool:null,locked:!1})},[c]),F=We((j)=>{let G=S.current;if(G){na(j==="edit"?wo(G.caps):"preview");return}let y=oa[j];if(!c.some((x)=>x.id===y))return;E(j),M(y),i((x)=>x.locked&&x.tool===y?x:{tool:null,locked:!1})},[c]),A=We(()=>{let j=S.current;R(j?sn[j.mode]:oa[k])},[k,R]),L=Ke(k);L.current=k;let K=Ke(h);K.current=h;let I=Ke(h);bt(()=>{let j=Vs(I.current,h);if(I.current=h,j)zs(j)},[h]),bt(()=>{if(!r||typeof window>"u")return;let j=Ae(window),G=-1,y=null,x=()=>{let T=j.get();if(T.mode===null||!T.caps||T.modeSeq<=G)return;G=T.modeSeq,S.current={mode:T.mode,caps:T.caps};let z=xo[T.mode],Y=y===null?L.current!==z:y!==T.mode;y=T.mode;let ue=sn[T.mode],ge=(Z)=>!!Z&&c.some((ze)=>ze.id===Z),rt=T.tool??(Y?ue:null),N=ge(rt)?rt:Y&&ge(ue)?ue:null;if(E(z),N)M(N),K.current=N;if(Y)i({tool:null,locked:!1});if(j.claimEcho(T.modeSeq)&&window.parent!==window)try{window.parent.postMessage({dgn:"mode-changed",seq:T.modeSeq,mode:T.mode,tool:N??K.current,present:T.present,cause:T.clamped?"clamp":"set-mode"},"*")}catch{}};return x(),j.subscribe(x)},[c,r]);let B=We((j)=>{i((G)=>{if(G.locked&&G.tool===j)return{tool:null,locked:!1};return{tool:j,locked:!0}}),M(j)},[]),X=We(()=>{i({tool:null,locked:!1})},[]),[Q,se]=Gt("rounded"),ee=Ke(Math.random().toString(36).slice(2)),oe=Ke(h);oe.current=h;let le=Ke(!1);bt(()=>{if(!le.current){le.current=!0;return}if(typeof document>"u")return;document.dispatchEvent(new CustomEvent(Zt,{detail:{tool:h,from:ee.current}}))},[h]),bt(()=>{if(typeof document>"u")return;let j=(G)=>{let y=G.detail;if(!y||y.from===ee.current||typeof y.tool!=="string")return;if(y.tool===oe.current)return;let x=S.current;if(x){let T=at(y.tool,x.caps,x.mode);if(T&&T!==x.mode){document.dispatchEvent(new CustomEvent(Zt,{detail:{tool:oe.current,from:ee.current}}));return}}R(y.tool)};return document.addEventListener(Zt,j),()=>document.removeEventListener(Zt,j)},[R]),bt(()=>{if(typeof document>"u")return;let j=c.find((x)=>x.id===h);if(!j)return;let G=document.body.style.cursor,y=document.getElementById("dc-tool-cursor");if(!y)y=document.createElement("style"),y.id="dc-tool-cursor",document.head.appendChild(y);if(h==="browse"){if(document.body.style.cursor="",y.textContent="",typeof window<"u"&&window.parent&&window.parent!==window)try{window.parent.postMessage({dgn:"tool-cursor",tool:h},"*")}catch{}return()=>{document.body.style.cursor=G}}if(document.body.style.cursor=j.cursor,y.textContent=`* { cursor: ${j.cursor} !important; }`,typeof window<"u"&&window.parent&&window.parent!==window)try{window.parent.postMessage({dgn:"tool-cursor",tool:h},"*")}catch{}return()=>{document.body.style.cursor=G;let x=document.getElementById("dc-tool-cursor");if(x)x.textContent=""}},[h,c]);let ye=ta(()=>({tool:h,getTool:g,setTool:R,tools:c,mode:k,setMode:F,resetTool:A,sticky:b,toggleSticky:B,clearSticky:X,shapeKind:Q,setShapeKind:se}),[h,g,R,c,k,F,A,b,B,X,Q]);return io(lo.Provider,{value:ye,children:e})}function aa({children:e,initial:t,initialMode:n,governed:o}){if(sa(lo))return io(_d,{children:e});return io(Pd,{initial:t,initialMode:n,governed:o,children:e})}function Jt(){let e=sa(lo);if(!e)throw Error("useToolMode must be used inside <ToolProvider>");return e}import{jsx as Bd}from"react/jsx-runtime";var Od=`
|
|
1
|
+
import{Component as Yd,createElement as mo,useCallback as uo,useEffect as Te,useMemo as Qd,useRef as Re,useState as rt}from"react";import{createRoot as Gd}from"react-dom/client";function ba(e,t){if(e==="present")return t?.kind==="artboards"?"present-artboards":"present-canvas";return e}var ve=(e,t,n,o,r)=>Object.freeze({edit:e,preview:t,"present-artboards":n,"present-canvas":o,viewing:r}),ya=Object.freeze({clicks:ve("tool","live","next-artboard","pan-zoom","specs"),toolbar:ve("edit","preview","none","none","viewing"),annotations:ve("quiet","drawn","hidden","hidden","read-only"),"comment-pins":ve("shown","shown","hidden","hidden","shown"),measure:ve("on","on","off","off","on"),"ai-changes":ve("live","live","held","live-unmarked","live"),"left-panels":ve("shown","shown","hidden","hidden","shown"),"ai-panel":ve("shown","shown","hidden","hidden","none"),"share-cluster":ve("full","full","hidden","hidden","full-access"),inspect:ve("inspector","panel-on-cmd-click","hidden","hidden","panel-on-click"),"project-menu":ve("pill","pill","esc-first","esc-first","pill"),esc:ve("steps-back","steps-back","settles-back","same-view","deselect")});function Fe(e,t,n){return ya[e][ba(t,n)]}var wa=Object.freeze({measure:(e,t)=>Fe("measure",e,t)==="on","inspect-panel":(e,t)=>Fe("inspect",e,t).startsWith("panel"),"comment-pins":(e,t)=>Fe("comment-pins",e,t)==="shown","object-tools":(e,t)=>Fe("clicks",e,t)==="tool","live-design":(e,t)=>Fe("clicks",e,t)==="live","annotations-editable":(e,t)=>Fe("annotations",e,t)==="drawn",chrome:(e,t)=>Fe("share-cluster",e,t)!=="hidden"});function yt(e,t,n){if(!e)return t==="measure"||t==="comment-pins"||t==="object-tools";return wa[t](e,n)}var nn=["edit","viewing","preview","present"],yo=["artboards","canvas"],on=["browse","move","hand","comment","pen","highlighter","eraser","shape","sticky","section","arrow","text"],va=["inspect","frame","el-shape","el-pen","el-text","image","component","line","ellipse","polygon","crop","slice","pointer"],rn=[...on,...va],fu=new Set(nn),xa=new Set(rn);var ka=(e)=>typeof e==="string"&&xa.has(e),gu=Object.freeze({edit:!1,annotate:!1,comment:!1}),wo=Object.freeze({edit:!0,annotate:!0,comment:!0}),vo=(e)=>e.edit?"edit":"viewing";function xo(e,t){if(e==="edit"&&!t.edit)return"viewing";if(e==="viewing"&&t.edit)return"edit";return e}var ko=Object.freeze({edit:"edit",viewing:"edit",preview:"preview",present:"preview"}),sn=Object.freeze({edit:"move",viewing:"inspect",preview:"browse",present:"browse"}),ho=Object.freeze({view:0,comment:1,edit:2});function Sa(e){if(e.edit||e.annotate)return"edit";return e.comment?"comment":"view"}var ne=(e)=>Object.freeze(e),st=Object.freeze({edit:Object.freeze({rest:"move",slots:Object.freeze([ne({key:"V",label:"Select",tool:"move",minRole:"edit"}),ne({key:"H",label:"Hand",tool:"hand",minRole:"edit"}),ne({key:"F",label:"Artboard / Frame",tool:"frame",minRole:"edit"}),ne({key:"R",label:"Shape",tool:"el-shape",minRole:"edit"}),ne({key:"P",label:"Pen",tool:"el-pen",minRole:"edit"}),ne({key:"T",label:"Text",tool:"el-text",minRole:"edit"}),ne({key:"I",label:"Image",tool:"image",minRole:"edit",panel:"image",panelFirst:!0}),ne({key:"⇧I",label:"Component",tool:null,minRole:"edit",panel:"components"}),ne({key:"",label:"More",tool:null,minRole:"edit",popover:"more",more:Object.freeze([ne({key:"",label:"Line",tool:"line",minRole:"edit"}),ne({key:"",label:"Ellipse",tool:"ellipse",minRole:"edit"}),ne({key:"",label:"Polygon",tool:"polygon",minRole:"edit"}),ne({key:"",label:"Crop",tool:"crop",minRole:"edit"}),ne({key:"",label:"Export area",tool:"slice",minRole:"edit"})])})])}),preview:Object.freeze({rest:"browse",slots:Object.freeze([ne({key:"V",label:"Select",tool:"browse",minRole:"view"}),ne({key:"H",label:"Hand",tool:"hand",minRole:"view"}),ne({key:"N",label:"Sticky",tool:"sticky",minRole:"edit",popover:"sticky-colours"}),ne({key:"C",label:"Comment",tool:"comment",minRole:"comment"}),ne({key:"M",label:"Marker",tool:"pen",minRole:"edit",popover:"marker-tips",tips:["pen","highlighter","eraser"]}),ne({key:"A",label:"Arrow",tool:"arrow",minRole:"edit"}),ne({key:"R",label:"Shape",tool:"shape",minRole:"edit",popover:"shape-kinds"}),ne({key:"T",label:"Text",tool:"text",minRole:"edit"}),ne({key:"E",label:"Stickers",tool:null,minRole:"edit",panel:"stickers"}),ne({key:"S",label:"Section",tool:"section",minRole:"edit",panel:"templates"})])}),viewing:Object.freeze({rest:"inspect",slots:Object.freeze([ne({key:"H",label:"Hand",tool:"inspect",minRole:"view"}),ne({key:"C",label:"Comment",tool:"comment",minRole:"comment"})])}),present:Object.freeze({rest:"browse",hidden:!0,slots:Object.freeze([ne({key:"L",label:"Pointer",tool:"pointer",minRole:"view"})])})}),an=Object.freeze({});function So(e,t){if(t(e))return e;let n=an[e];return n&&t(n)?n:null}var Ea=Object.freeze({edit:["preview"],preview:["edit"],viewing:["preview","edit"],present:[]});function Ta(e,t){for(let n of[e,...Ea[e]]){let o=st[n].slots.find((r)=>r.key===t);if(o)return{mode:n,slot:o}}return null}function Eo(e,t,n,o){let r=Ta(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,u=Sa(n);if(ho[u]<ho[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 m={kind:"request",mode:r.mode};if(c)m.tool=c;if(a&&s.panel)m.panel=s.panel;return m}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 Ra=new Set(["hand"]);function bo(e,t){return st[e].slots.some((n)=>n.tool===t||n.tool!==null&&an[n.tool]===t||!!n.tips?.includes(t)||!!n.lights?.includes(t)||!!n.more?.some((o)=>o.tool===t))}function at(e,t,n){if(!ka(e)||Ra.has(e))return null;if(bo(n,e))return n;if(e==="move")return t.edit?"edit":"viewing";for(let o of["preview","edit"])if(bo(o,e))return o;return null}function ln(e,t){if(e==="present")return"back";let n=st[e].rest;if(t!==n&&an[n]!==t)return"rest";return"stay"}var cn=Object.freeze({top:0,right:0,bottom:0,left:0});function To(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 Ro(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}function Ao(e){if(!e||typeof e!=="object"||Array.isArray(e))return null;let{left:t,right:n}=e;if(typeof t!=="number"||typeof n!=="number")return null;if(!Number.isFinite(t)||!Number.isFinite(n))return null;let o=Math.round(t),r=Math.round(n);if(o<0||r>8192||!(o<r))return null;return{left:o,right:r}}var Aa=["image/png","image/jpeg","image/gif","image/webp"],Ma=new Set(["dgn","v","text","html","image"]),Mo=(e)=>typeof e==="string"&&e.length<=1e6,Ca=(e)=>typeof Blob<"u"&&e instanceof Blob&&Aa.includes(e.type)&&e.size>0&&e.size<=20971520;function Co(e){if(!e||typeof e!=="object"||Array.isArray(e))return null;let t=e;for(let o of Object.keys(t))if(!Ma.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(!Ca(t.image))return null;n.image=t.image}return n.text||n.html||n.image?n:null}var wt=(e)=>{if(e instanceof Uint8Array)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(e&&typeof e==="object"&&Object.prototype.toString.call(e)==="[object ArrayBuffer]")return new Uint8Array(e);return null},Ye=(e,t)=>String.fromCharCode(e[t],e[t+1],e[t+2],e[t+3]),dn=(e,t)=>(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0,Io=(e,t)=>e[t]|e[t+1]<<8|e[t+2]<<16;function Ia(e){let t=wt(e);if(!t)return{ok:!1,reason:"not-bytes"};if(t.length===0)return{ok:!1,reason:"empty"};if(t.length>262144)return{ok:!1,reason:"too-large"};if(t.length<30||Ye(t,0)!=="RIFF"||Ye(t,8)!=="WEBP")return{ok:!1,reason:"not-webp"};let n=dn(t,4);if(n+8!==t.length&&n+9!==t.length)return{ok:!1,reason:"bad-size"};let o=Ye(t,12),r=dn(t,16);if(r<10||20+r>t.length)return{ok:!1,reason:"bad-chunk"};let s=0,a=0;if(o==="VP8 "){if((t[20]&1)!==0||t[23]!==157||t[24]!==1||t[25]!==42)return{ok:!1,reason:"bad-chunk"};s=(t[26]|t[27]<<8)&16383,a=(t[28]|t[29]<<8)&16383}else if(o==="VP8L"){if(t[20]!==47)return{ok:!1,reason:"bad-chunk"};let c=dn(t,21);if(s=(c&16383)+1,a=(c>>>14&16383)+1,c>>>29!==0)return{ok:!1,reason:"bad-chunk"}}else if(o==="VP8X"){if((t[20]&2)!==0)return{ok:!1,reason:"animated"};s=Io(t,24)+1,a=Io(t,27)+1}else return{ok:!1,reason:"bad-chunk"};if(!(s>0&&a>0))return{ok:!1,reason:"bad-chunk"};if(s>401||a>1601)return{ok:!1,reason:"too-big"};return{ok:!0,w:s,h:a}}var Po=[137,80,78,71,13,10,26,10],un=(e,t)=>(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0,Pa=new Set(["sRGB","gAMA","cHRM","pHYs","sBIT","bKGD","tRNS","eXIf"]),_a=new Set(["acTL","fcTL","fdAT"]),La={0:[1,2,4,8,16],2:[8,16],3:[1,2,4,8],4:[8,16],6:[8,16]};function Oa(e){let t=wt(e);if(!t)return{ok:!1,reason:"not-bytes"};if(t.length===0)return{ok:!1,reason:"empty"};if(t.length>262144)return{ok:!1,reason:"too-large"};if(t.length<45||Po.some((m,h)=>t[h]!==m))return{ok:!1,reason:"not-png"};let n=8,o=!0,r=0,s=0,a=!1,c=!1,u="none";for(;;){let m=t.length-n;if(m<12)return{ok:!1,reason:"bad-chunk"};let h=un(t,n);if(h>m-12)return{ok:!1,reason:"bad-chunk"};let f=Ye(t,n+4),w=n+8;if(!/^[A-Za-z]{4}$/.test(f))return{ok:!1,reason:"bad-chunk"};if(o){if(f!=="IHDR"||h!==13)return{ok:!1,reason:"bad-chunk"};r=un(t,w),s=un(t,w+4);let R=t[w+8],g=t[w+9];if(!(La[g]??[]).includes(R))return{ok:!1,reason:"bad-chunk"};if(t[w+10]!==0||t[w+11]!==0||t[w+12]!==0)return{ok:!1,reason:"bad-chunk"};if(!(r>0&&s>0))return{ok:!1,reason:"bad-chunk"};if(r>401||s>1601)return{ok:!1,reason:"too-big"};a=g===3,o=!1}else if(f==="IEND"){if(h!==0||u==="none"||a&&!c)return{ok:!1,reason:"bad-chunk"};if(w+4!==t.length)return{ok:!1,reason:"bad-size"};return{ok:!0,w:r,h:s}}else if(f==="IDAT"){if(u==="done")return{ok:!1,reason:"bad-chunk"};u="in"}else if(_a.has(f))return{ok:!1,reason:"animated"};else if(f==="PLTE"||Pa.has(f)){if(u==="in")u="done";if(f==="PLTE"){if(c||u!=="none"||h===0||h>768||h%3!==0)return{ok:!1,reason:"bad-chunk"};c=!0}}else return{ok:!1,reason:"bad-chunk"};n=w+h+4}}function Na(e){let t=wt(e);if(t&&t.length>=8&&Po.every((n,o)=>t[o]===n)){let n=Oa(t);return n.ok?{ok:!0,format:"png",w:n.w,h:n.h}:n}if(t&&t.length>=12&&Ye(t,0)==="RIFF"&&Ye(t,8)==="WEBP"){let n=Ia(t);return n.ok?{ok:!0,format:"webp",w:n.w,h:n.h}:n}if(!t)return{ok:!1,reason:"not-bytes"};if(t.length===0)return{ok:!1,reason:"empty"};if(t.length>262144)return{ok:!1,reason:"too-large"};return{ok:!1,reason:"not-image"}}function _o(e){if(!Na(e).ok)return null;return wt(e).slice().buffer}var Da=/^data:image\/(?:png|webp|jpeg|gif);base64,[A-Za-z0-9+/]+={0,2}$/;function Lo(e){return typeof e==="string"&&e.length<=400000&&Da.test(e)}var Ka=["frame","text","image","path","shape","instance","artboard","multi"],v=Symbol("dgn.bad"),Et=4000,qe=1e4,za=16,ke=(e)=>!!e&&typeof e==="object"&&!Array.isArray(e),p=(e)=>typeof e==="string"&&e.length<=Et?e:v,I=(e)=>typeof e==="number"&&Number.isFinite(e)?e:v,fn=(e)=>typeof e==="number"&&Number.isFinite(e)&&e>=0&&e<=1?e:v,L=(e)=>typeof e==="boolean"?e:v,Va=(e)=>Lo(e)?e:v,Oo=(e)=>typeof e==="number"&&Number.isFinite(e)&&e>=0&&e<=86400?e:v,Fa=(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]},V=(...e)=>(t)=>e.includes(t)?t:v,d=(e)=>(t)=>t===void 0?void 0:e(t),Ha=(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,Ie=(e)=>typeof e==="string"&&/^[A-Za-z0-9_-]{1,64}$/.test(e)?e:v,N=(e)=>(t)=>t===null?null:e(t),j=(e)=>(t)=>{if(!Array.isArray(t)||t.length>qe)return v;let n=[];for(let o of t){let r=e(o);if(r===v)return v;n.push(r)}return n},xe=(e)=>gn(e,0);function gn(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<=Et?e:v;if(t>=za||typeof e!=="object")return v;if(Array.isArray(e)){if(e.length>qe)return v;let r=[];for(let s of e){let a=gn(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>qe||r.length>Et)return v;let s=gn(e[r],t+1);if(s===v)return v;if(s!==void 0)n[r]=s}return n}var ce=(e)=>ke(e)?xe(e):v,No=(e)=>{if(!ke(e))return v;let t={},n=Object.keys(e);if(n.length>qe)return v;for(let o of n){let r=p(e[o]);if(r===v||o.length>Et)return v;t[o]=r}return t},$a=256,vt=(e,t=$a)=>(n)=>{if(!ke(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},xt=(e)=>typeof e==="string"&&/^[A-Za-z0-9_-]{1,64}$/.test(e)?e:v,D=(e)=>(t)=>typeof t==="string"&&t.length<=e?t:v,qa=(e)=>typeof e==="string"&&/^[A-Z][A-Za-z0-9]{0,63}$/.test(e)?e:v,Do=(e)=>typeof e==="string"&&/^[a-z][a-z0-9-]{0,40}$/.test(e)?e:v,kt=(e)=>typeof e==="number"&&Number.isSafeInteger(e)&&e>=0&&e<=9999?e:v,Y=(e)=>(t)=>{if(!ke(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},fe=(e,t)=>(n)=>typeof n==="number"&&Number.isInteger(n)&&n>=e&&n<=t?n:v,hn=(e)=>typeof e==="string"&&/^[\w-]{1,64}$/.test(e)?e:v,He=Y({x:I,y:I,w:I,h:I}),ja=512,Fo=(e)=>{if(typeof e!=="string"||e.length<5||e.length>ja)return v;if(/[\u0000-\u001f\u007f]/.test(e)||e.split("|").length<3)return v;return e},Ba=200,Ho=(e)=>typeof e==="string"&&e.length>0&&e.length<=Ba&&!/[\u0000-\u001f\u007f]/.test(e)?e:v,$o=(e)=>typeof e==="number"&&Number.isFinite(e)&&e>=1&&e<=8?e:v,qo=(e)=>Array.isArray(e)&&e.length===2&&fn(e[0])!==v&&fn(e[1])!==v?[e[0],e[1]]:v,Wa=(e)=>ke(e)&&typeof e.w==="number"&&typeof e.h==="number"&&e.w>0&&e.h>0&&e.w<=65536&&e.h<=65536?{w:e.w,h:e.h}:v,Ua=(e)=>{if(!Array.isArray(e)||e.length>Yo)return v;let t=Y({clientID:fe(0,Number.MAX_SAFE_INTEGER),name:(o)=>typeof o==="string"&&o.length<=Qo?o:v,artboardId:Ie,frame:d(fe(0,1e7)),word:d(Fo)}),n=[];for(let o of e){if(!ke(o))return v;let r=t(o);if(r===v)return v;n.push(r)}return n},pn=(e)=>typeof e==="string"&&/^#[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$/.test(e)?e:v,jo=Y({stickyColor:d(pn),ink:d(pn),thickness:d(V(3,6)),tip:d(V("pen","highlighter","eraser")),highlighterColor:d(pn),highlighterWidth:d(fe(1,64))}),St=V(...nn),bn=V(...rn),yn=Y({kind:V(...yo),from:d(p),only:d(V("formats"))}),Xa=Y({edit:L,annotate:L,comment:L,present:d(L)}),Ya=/^[a-z0-9]{8,32}$/,wn=(e)=>typeof e==="string"&&Ya.test(e)?e:v,Qa=64,Ga=(e)=>typeof e==="string"&&e.length<=Qa?e:v,Za=(e)=>Ro(e)??v,Ja=(e)=>e===void 0?void 0:Ao(e)??void 0,ei=/^(?!\/)(?!.*\.\.)[A-Za-z0-9_][A-Za-z0-9 ._/-]{0,255}\.css$/,Tt=(e)=>typeof e==="string"&&ei.test(e)?e:v,ti=/^(?:head|[0-9a-f]{64})$/,Bo=16,Wo=(e)=>typeof e==="string"&&ti.test(e)?e:v,ni=(e)=>Array.isArray(e)&&e.length<=Bo?j(Wo)(e):v,oi=200,ri=/^[A-Za-z0-9_.:-]{1,128}$/,Rt=(e)=>typeof e==="string"&&ri.test(e)?e:v,si=(e)=>Array.isArray(e)&&e.length<=oi?j(Rt)(e):v,ai=V("light","dark"),ii=200,li=/^--[A-Za-z0-9_-]{1,128}$/,ci=(e)=>typeof e==="string"&&li.test(e)?e:v,Ko=(e)=>Array.isArray(e)&&e.length<=ii?j(ci)(e):v,di=["brand","colour","type","space","motion","components","patterns"],ui=V("waiting","drawing","done"),pi=(e)=>{if(!ke(e))return v;let t={};for(let n of Object.keys(e)){if(!di.includes(n))return v;let o=ui(e[n]);if(o===v)return v;t[n]=o}return t},Uo=500,mi=(e)=>Array.isArray(e)&&e.length<=Uo?j(Rt)(e):v,Xo=fe(0,1e6),fi=(e)=>e===null||Rt(e)!==v?e:v,gi=(e)=>Array.isArray(e)&&e.length<=Uo?j(Y({id:Rt,x:I,y:I,w:I,h:I}))(e):v,hi=Y({tokens:Tt,components:N(Tt)}),bi=(e)=>{if(!ke(e))return v;let t=Object.keys(e);if(t.length>Bo)return v;let n=Object.create(null);for(let o of t){if(Wo(o)===v)return v;let r=hi(e[o]);if(r===v)return v;n[o]=r}return n},yi=(e)=>typeof e==="string"&&/^[A-Za-z_][\w-]{0,63}$/.test(e)?e:v,wi=2000,vi=Y({id:D(200),label:D(200),x:I,y:I,w:I,h:I}),xi=(e)=>Array.isArray(e)&&e.length<=wi?j(vi)(e):v,ki=500,Yo=32,Qo=64,Si=/^(#[0-9a-f]{3,8}|oklch\([0-9.%\s/-]{1,40}\))$/i,Ei=/^[A-Za-z0-9_-]{1,64}$/,Ti=["owner","member","viewer","observer"],Ri=(e)=>{if(!Array.isArray(e)||e.length>Yo)return v;let t=[];for(let n of e){if(!ke(n))return v;let{clientID:o,name:r,color:s,following:a,artboard:c,idleSince:u,surface:m,inComments:h,role:f}=n;if(typeof o!=="number"||!Number.isSafeInteger(o)||o<0)return v;if(typeof r!=="string"||r.length>Qo)return v;if(s!==void 0&&(typeof s!=="string"||!Si.test(s)))return v;if(a!==void 0&&typeof a!=="boolean")return v;if(c!==void 0&&(typeof c!=="string"||!Ei.test(c)))return v;if(u!==void 0&&(typeof u!=="number"||!Number.isSafeInteger(u)||u<=0))return v;if(m!==void 0&&m!=="browser")return v;if(h!==void 0&&typeof h!=="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(u!==void 0)w.idleSince=u;if(m==="browser")w.surface="browser";if(h===!0)w.inComments=!0;if(Ti.includes(f))w.role=f;t.push(w)}return t},Ai=120,Mi=256,Qe=(e)=>typeof e==="string"&&e.length<=Ai?e:v,Ci=(e)=>Array.isArray(e)&&e.length<=Mi?j(Y({artboard:Qe,element:Qe,occurrence:d((t)=>typeof t==="number"&&Number.isInteger(t)&&t>=0&&t<1e4?t:v),tag:Qe,mine:L,scope:d(L),point:d(L)}))(e):v,Ii=8,Pi=40,mn="[A-Za-z0-9_.:-]{1,128}",_i=new RegExp(`^(?:ab:${mn}|el:${mn}/${mn})$`),Li=20,Oi=(e)=>Array.isArray(e)&&e.length<=Li?j(Y({from:hn,to:hn}))(e):v,Ni=(e)=>Array.isArray(e)&&e.length<=Ii?j(Y({ref:(t)=>typeof t==="string"&&_i.test(t)?t:v,tag:(t)=>typeof t==="string"&&t.length<=Pi?t:v}))(e):v,Di=["add","reply","resolve","reopen","edit-own","delete-own","reattach"],Ki=["to-sticky","convert-undo","convert-undoable"],it=(e)=>typeof e==="string"&&e.length>0&&e.length<=64||typeof e==="number"&&Number.isSafeInteger(e)?e:v,zi=(e)=>{if(!ke(e))return v;if(Ki.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(!Di.includes(e.op))return v;return xe(e)},Vi=Y({id:D(200),name:D(120),role:d(D(40))}),Fi=256,Hi=64,$i=Y({name:N((e)=>typeof e==="string"&&e.length<=Hi&&!e.includes("@")?e:v),kind:N(V("mac","pc","linux")),self:L}),qi=Y({rel:D(512),state:V("here","uploading","waiting","missing","lfs-pointer"),localObject:d(L),who:d($i),syncing:d(L),progress:d(fn)}),ji=(e)=>Array.isArray(e)&&e.length<=Fi?j(qi)(e):v,Bi=256,Wi=/^assets\/[0-9a-f]{8}\.[A-Za-z0-9]{1,8}$/,Ui=(e)=>Array.isArray(e)&&e.length<=Bi&&e.every((t)=>typeof t==="string"&&Wi.test(t))?e.slice():v,Go=(e)=>_o(e)??v,Zo=(e)=>typeof e==="string"&&e.length>=1&&e.length<=200&&!/[\u0000-\u001f\u007f]/.test(e)?e:v,Jo=200,Xi=2000;function l(e){let t=Y(e);return(n)=>{let o=t(n);return o===v?null:o}}var he=(e)=>ke(e)?{}:null,zo={refId:d(p),refIndex:d(I),artboardId:d(N(p)),position:d(p)},Pe={id:d(p)},$e=Y({artboard:p,element:p,occurrence:d(I)}),Yi=Y({kind:V("picture","frame","artboard"),artboard:D(200),element:d(D(200)),occurrence:d(fe(1,qe))}),Le=(e,t)=>(n)=>Array.isArray(n)&&n.length<=e?t(n):v,Qi=Y({id:d(D(128)),tag:d(D(24)),text:d(D(160)),selector:d(D(200)),index:d(I)}),Gi=Y({label:p,ref:N($e)}),Zi=["held-by-ai","locked","stale","invalid","forbidden"],F="h/use-canvas-bridge",de="canvas-shell",vn={loaded:{gate:"any",status:"live",owner:F,parse:l({file:p})},"canvas-rendered":{gate:"active",status:"live",owner:F,parse:l({file:p})},"canvas-failed":{gate:"active",status:"live",owner:F,parse:l({file:p})},"canvas-mounted":{gate:"any",status:"legacy",owner:"tpl/_shell.html (probe)",orphan:"no-handler",parse:l({file:p,children:I})},"render-error":{gate:"frame",status:"live",owner:"v2/create/use-render-error",parse:l({file:p,message:D(600)})},"render-ok":{gate:"frame",status:"live",owner:"v2/create/use-render-error",parse:l({file:p})},"ds-review":{gate:"active",status:"live",owner:"h/use-ds-frames",parse:he},"copy-canvas-path":{gate:"active",status:"live",owner:F,parse:he},"ds-rects-result":{gate:"frame",status:"live",owner:"v2/ds/reach-view",parse:l({seq:Xo,view:Y({w:I,h:I}),label:d(D(120)),rects:gi})},"ds-pins-want":{gate:"active",status:"live",owner:"v2/ds/pins",parse:l({revs:ni})},"canvas-expired":{gate:"frame",status:"live",owner:"h/use-shell-core",parse:he},"annotations-changed":{gate:"active",status:"live",orphan:"no-handler",owner:"annotations-layer (S4.9) → annotation-list (S4.17)",parse:l({file:p})},"annotation-to-comment":{gate:"active",status:"live",owner:"annotations-layer (S4.12) → shell convert (routes/annotations.ts, S4.7)",parse:l({id:xt})},"annotation-selection":{gate:"active",status:"live",owner:"annotations-layer (S4.12) → AI scope chip (S4.15, S5.8)",parse:l({ids:Le(500,j(xt)),kinds:vt(kt,16),artboards:Le(200,j(D(128)))})},"annotation-toast":{gate:"active",status:"live",owner:"annotations-layer (S4.12) → shell toast",parse:l({v:V(1),message:D(300),undo:L})},"annotation-ask-ai":{gate:"active",status:"live",owner:"annotations-layer (S4.12) → shell AI chat",parse:l({v:V(1)})},"object-history":{gate:"active",status:"live",owner:"editing/object-menu.tsx + annotations-layer (sticky menu) → shell history.object",parse:l({artboard:d(Ie),element:d(D(128)),annotation:d(xt)})},"view-only-gesture":{gate:"active",status:"live",owner:"view-only-gesture (S9.21b) → shell access host tip",parse:l({v:V(1),x:d(fe(0,16384)),y:d(fe(0,16384))})},"vote-cast":{gate:"active",status:"live",owner:"annotations/ui/vote-dots (S4.14) → shell vote store (routes/votes.ts)",parse:l({artboard:Ie,remove:d(L)})},"vote-board":{gate:"active",status:"live",owner:"annotations/ui/vote-dots + editing/artboard-menu (S4.14) → shell vote sheet",parse:l({artboards:Le(200,j(Y({id:Ie,label:D(120),x:I,y:I,w:I,h:I}))),open:d(L),focus:d(Ie)})},"annotations-visibility":{gate:"active",status:"live",owner:"annotations-layer ⇧P (S4.18) → shell use-photo-and-timeline",parse:l({v:V(1),visible:L})},"canvas-notice":{gate:"active",status:"live",owner:"canvas-notice-message",parse:l({message:p,kind:V("info","success","error","warning","undo")})},"embed-escape":{gate:"active",status:"live",owner:"c/embed-view",parse:he},"select-set":{gate:"active",status:"live",owner:F,parse:l({selection:N((e)=>Array.isArray(e)?j(ce)(e):ce(e)),refs:d(j($e)),crumbs:d(j(Gi)),kind:d(V(...Ka))})},"edit-text":{gate:"active",status:"live",owner:F,parse:l({id:p,file:p,text:p,occurrence:d(I),before:d(p)})},"apply-edit":{gate:"active",status:"live",owner:"client/apply-edit-request",parse:l({requestId:p,op:xe,canvas:d(xe),id:d(xe),key:d(xe),value:d(xe),from:d(xe),occurrence:d(xe)})},"undo-barrier":{gate:"active",status:"live",owner:F,parse:l({requestId:p})},"undo-key":{gate:"active",status:"live",owner:"v2/undo/use-undo-mode-lane (S2.20b)",parse:l({redo:L})},"take-step":{gate:"active",status:"live",owner:"v2/assets/takes (S8.16)",parse:l({dir:V("next","prev")})},"edit-op":{gate:"active",status:"live",owner:"editing (S2.1)",parse:l({requestId:p,op:p,targets:j($e),params:d(ce),expectRev:d(p)})},"asset-drop-target":{gate:"active",status:"live",owner:"client/v2/assets/canvas-drop-catcher (r3)",parse:l({requestId:D(64),target:N(Yi)})},"active-artboard":{gate:"active",status:"live",owner:F,parse:l({id:N(p)})},"reorder-slot":{gate:"active",status:"live",owner:"editing/reorder-slot",parse:(e)=>{let t=l({index:fe(0,qe),total:fe(0,qe),parentId:d(hn)})(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:F,parse:l({artboardId:N(p),tree:j(ce)})},"open-inspector":{gate:"active",status:"live",owner:F,parse:l({tab:d(p)})},"copy-style":{gate:"active",status:"live",owner:F,parse:he},"paste-style":{gate:"active",status:"live",owner:F,parse:l({id:p})},"insert-request":{gate:"active",status:"live",owner:F,parse:l({...zo,kind:V("div","text","image"),src:d(p)})},"insert-image-request":{gate:"active",status:"live",owner:F,parse:l(zo)},"delete-request":{gate:"active",status:"live",owner:F,parse:l({id:p,idIndex:d(I)})},"duplicate-request":{gate:"active",status:"live",owner:F,parse:l({id:p,idIndex:d(I)})},"reorder-request":{gate:"active",status:"live",owner:F,parse:l({id:p,refId:p,position:p,idIndex:d(I),refIndex:d(I)})},"reorder-revert":{gate:"active",status:"live",owner:F,parse:l({seq:I,dir:V("undo","redo")})},"reposition-request":{gate:"active",status:"live",owner:F,parse:l({id:p,left:p,top:p,beforeLeft:d(p),beforeTop:d(p),idIndex:d(I)})},"resize-request":{gate:"active",status:"live",owner:F,parse:l({id:p,patch:No,before:d(No),idIndex:d(I)})},"replace-media-request":{gate:"active",status:"live",owner:F,parse:l({id:p,before:d(p)})},"convert-to-absolute-request":{gate:"active",status:"live",owner:F,parse:l({artboardId:d(p),allowShared:d(L),containers:d(j(xe)),dissolve:d(j(xe)),containerId:d(p),children:d(j(xe)),containerSetRelative:d(L)})},"delete-artboard-request":{gate:"active",status:"live",owner:F,parse:l({artboardId:p})},"duplicate-artboard-request":{gate:"active",status:"live",owner:F,parse:l({artboardId:p,width:d(I)})},"rename-artboard-request":{gate:"active",status:"live",owner:F,parse:l({artboardId:p,label:p})},"resize-artboard-request":{gate:"active",status:"live",owner:F,parse:l({artboardId:p,width:I,height:I})},"set-artboard-kind-request":{gate:"active",status:"live",owner:F,parse:l({artboardId:p,kind:N(p)})},"open-timeline-request":{gate:"active",status:"live",owner:F,parse:l({artboardId:p})},"replace-annotation-media-request":{gate:"active",status:"live",owner:F,parse:l({id:p,before:d(p)})},"edit-annotation-photo-request":{gate:"active",status:"live",owner:F,parse:l({id:p,asset:p})},"comment-compose":{gate:"active",status:"live",owner:F,parse:l({selection:ce})},"comment-submit":{gate:"active",status:"live",owner:F,parse:l({payload:ce})},"comment-patch":{gate:"active",status:"live",owner:F,parse:l({id:p,patch:ce})},"comment-delete":{gate:"active",status:"live",owner:F,parse:l({id:p})},"comment-click":{gate:"active",status:"live",owner:F,parse:l({id:p})},"comment-op":{gate:"active",status:"live",owner:"v2/comments/comment-bridge (S9.22)",parse:l({reqId:it,op:zi})},"comment-people-request":{gate:"active",status:"live",owner:"v2/comments/comment-bridge (S9.22)",parse:l({reqId:it})},"export-request":{gate:"active",status:"live",owner:F,orphan:"no-sender",parse:l({id:p,payload:ce})},"export-history-request":{gate:"active",status:"live",owner:F,orphan:"no-sender",parse:l({id:p})},"open-export":{gate:"active",status:"legacy",owner:F,parse:l({detail:ce})},"export-capture-progress":{gate:"asked",status:"live",owner:"h/use-shell-core",parse:l({id:p,current:I,total:I})},"export-capture-done":{gate:"asked",status:"live",owner:"h/use-shell-core",parse:l({id:p,items:j(ce)})},"export-capture-error":{gate:"asked",status:"live",owner:"h/use-shell-core",parse:l({id:p,message:p})},"export-selection":{gate:"asked",status:"live",owner:"c/app",parse:l({id:p,selectors:j(p)})},"timeline-comps":{gate:"active",status:"live",owner:F,parse:l({comps:j(ce)})},"timeline-frame":{gate:"active",status:"live",owner:F,parse:l({...Pe,frame:I})},"timeline-ended":{gate:"active",status:"live",owner:F,parse:l(Pe)},"timeline-playing":{gate:"active",status:"live",owner:"v2/timeline (S7.8)",parse:l({...Pe,playing:L})},key:{gate:"active",status:"live",owner:"actions/registry (V2-1.3)",parse:l({v:V(1),chord:p,hint:d(Y({artboardId:d(p)}))})},"tool-cursor":{gate:"active",status:"live",owner:F,parse:l({tool:p})},peers:{gate:"active",status:"live",owner:"v2/shell/use-canvas-mode-lane (V2-4.3b)",parse:l({peers:Ri})},"hold-view":{gate:"active",status:"live",owner:"v2/inspector/view-mode (S2.18)",parse:l({person:N(Y({name:Qe})),label:Qe,ai:N(Y({label:Qe,held:L,mine:L}))})},select:{gate:"active",status:"legacy",owner:F,orphan:"no-sender",parse:l({selection:ce})},"clear-select":{gate:"active",status:"legacy",owner:F,orphan:"no-sender",parse:he},artboards:{gate:"active",status:"live",owner:"v2/empty (S11.2); the shell bridge keeps the Layers count",parse:l({count:I,annotations:d(I)})},"artboard-empty":{gate:"active",status:"live",owner:"v2/empty (S11.2)",parse:l({artboardId:N(p),rect:N(He),label:d(p),from:d(p)})},"artboard-anchor":{gate:"active",status:"live",owner:"v2/timeline (S7.7)",parse:l({artboardId:N(p),kind:d(p),label:d(p),rect:d(N(He))})},"artboard-live-size":{gate:"active",status:"live",owner:"v2/inspector live size (P8 c6)",parse:l({id:N(p),w:d(I),h:d(I),preset:d(N(p))})},"space-tap":{gate:"active",status:"live",owner:"v2/timeline (S7.8)",parse:he},"canvas-pointerdown":{gate:"active",status:"live",owner:"v2/shell dismiss-outside (rc3 r4-12)",parse:he},"timeline-peers":{gate:"active",status:"live",owner:"v2/timeline/peers (S7.17)",parse:l({peers:Ua})},"video-frame-commit":{gate:"active",status:"live",owner:"v2/timeline/frame-handle (T3.6b)",parse:l({v:V(1),artboardId:Ie,stableId:Ho,zoom:$o,focus:qo})},"ask-selection":{gate:"active",status:"live",owner:"editing/ask-bubble (S2.19)",parse:l({refs:Le(200,j($e)),selection:d(Le(12,j(Qi))),rect:He,artboard:d(p)})},"ask-selection-rect":{gate:"active",status:"live",owner:"editing/ai-scope-outline (S2.19)",parse:l({rect:N(He)})},"insert-artboard-request":{gate:"active",status:"legacy",owner:F,orphan:"no-sender",parse:l({id:d(p),label:d(p),width:d(I),height:d(I)})},"mode-changed":{gate:"active",status:"live",owner:"v2/shell/use-canvas-mode-lane (V2-4.3b)",parse:l({seq:I,mode:St,tool:bn,present:N(yn),cause:V("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:St(e),tool:d(bn),present:d(yn),cause:V("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:St,rect:N(He)})},"toolbar-popover":{gate:"active",status:"live",owner:"tool-palette (#170 T2.4b); h/use-canvas-bridge → notifications (toast placement)",parse:l({open:L})},"tool-panel-open":{gate:"active",status:"live",owner:"tool-palette (V2-4.5c); shell tool panels (V2-4.5c)",parse:l({panel:V("stickers","components","templates","assets","sizes","image","generate"),anchor:N(He),replace:d(p)})},"size-place":{gate:"active",status:"live",owner:"editing/size-ghost (S7.20); client/v2/kinds",parse:l({presetId:D(40),world:Y({x:I,y:I})})},"stamp-disarmed":{gate:"active",status:"live",owner:"annotations/ui/placement (15 an-stamps); shell tool panels (use-tool-panels.js)",parse:l({})},"annotation-prefs-set":{gate:"active",status:"live",owner:"annotations/ui/tool-state (S4.8); shell v2/shell/use-annotation-prefs (S4.8)",parse:l({prefs:jo})},"viewport-zoom":{gate:"active",status:"live",owner:"present/present-zoom.ts (S3.2b) + v2/preview/zoom-only (S3.9) ← canvas-lib ViewportZoomReporter",parse:l({zoom:I,fit:d(L)})},"pages-view":{gate:"active",status:"live",owner:"canvas-pages-view.tsx (2.0.7 B2) → v2/shell/use-canvas-mode-lane",parse:l({v:V(1),on:L,index:fe(0,1e4),total:fe(0,1e4),id:d(D(256))})},"pages-pick":{gate:"active",status:"live",owner:"canvas-pages.ts (2.0.7 B2) → v2/shell/pages-pick (the view file, main origin)",parse:l({v:V(1),view:V("canvas","pages")})},"theme-pick":{gate:"active",status:"live",owner:"canvas-theme.ts (r4 #6, 2.0.7 B2) → v2/shell/pages-pick (the view file, main origin)",parse:l({v:V(1),theme:V("light","dark")})},"present-position":{gate:"active",status:"live",owner:"v2/shell/use-canvas-mode-lane (S3.1)",parse:l({index:I,total:I,artboardId:p,sid:d(wn),seq:d(fe(0,2147483647))})},"present-run":{gate:"active",status:"live",owner:"present/present-stage.tsx (S3.6b)",parse:l({artboards:xi})},"present-follow-state":{gate:"active",status:"live",owner:"v2/present/follow-view (S3.7a)",parse:l({live:L,sid:N(wn),presenterName:Ga,presenterIndex:fe(0,2000),index:fe(0,2000),total:fe(0,2000),watchers:fe(0,1e5),ended:L})},"present-media":{gate:"active",status:"live",owner:"present/present-media (S3.3)",parse:l({playing:L,t:Oo,duration:Oo,muted:L,sources:d(Fa),missing:d(L)})},"link-follow":{gate:"active",status:"live",owner:"S3 links (client/v2/preview/link-follow.js)",parse:l({elementId:Ha,artboardId:N(Ie)})},"asset-relink-request":{gate:"active",status:"live",owner:"client/v2/assets/asset-state-lane (S8.19)",parse:l({rel:D(512)})},"asset-lfs-fix-request":{gate:"active",status:"live",owner:"client/v2/assets/asset-state-lane (2.0.3 LFS placeholder)",parse:l({rel:D(512)})},"asset-lfs-copy-request":{gate:"active",status:"live",owner:"client/v2/assets/asset-state-lane (2.0.3 LFS placeholder)",parse:l({rel:D(512)})},"stills-want":{gate:"active",status:"live",owner:"client/v2/shell/still-bridge (#212 §5)",parse:l({file:D(1024)})},"still-put":{gate:"active",status:"live",owner:"client/v2/shell/still-bridge (#212 §5)",parse:l({file:D(1024),artboard:Zo,sig:D(Jo),bytes:Go})}},Vo={theme:{gate:"any",target:"parent",status:"live",owner:de,parse:l({theme:V("light","dark")})},"view-chrome":{gate:"any",target:"parent",status:"live",owner:de,parse:l({minimap:d(L),zoom:d(L),present:d(L),guides:d(L),print:d(L),safeZones:d(L),zen:d(L)})},"view-annotations":{gate:"parent",status:"live",owner:"annotations-layer",parse:l({visible:L})},"canvas-cap":{gate:"parent",status:"live",owner:"tpl/_shell.html",parse:l({t:p})},"ds-css":{gate:"parent",status:"live",owner:"tpl/_shell.html",parse:l({tokens:d(N(Tt)),components:d(N(Tt))})},"ds-pins":{gate:"parent",status:"live",owner:"tpl/_shell.html",parse:l({revs:bi,rootClass:N(yi)})},"ds-update-dots":{gate:"parent",status:"live",owner:"tpl/_shell.html",parse:l({ids:si})},"ds-theme-preview":{gate:"parent",status:"live",owner:"ds/board/state",parse:l({mode:ai})},"ds-marks":{gate:"parent",status:"live",owner:"ds/board/state",parse:l({outside:Ko,conflicts:Ko})},"ds-make-states":{gate:"parent",status:"live",owner:"ds/board/outline",parse:l({sections:pi})},"ds-rects":{gate:"parent",status:"live",owner:"tpl/_shell.html",parse:l({seq:Xo,artboard:fi,ids:mi})},"ai-activity":{gate:"parent",status:"live",owner:"ai-banner",parse:l({file:p,entry:N(ce)})},"select-by-id":{gate:"parent",status:"live",owner:de,parse:l({id:d(p),artboardId:d(N(p)),index:d(I),add:d(L)})},"select-by-selector":{gate:"parent",status:"live",owner:de,parse:l({selector:p})},highlight:{gate:"any",target:"parent",status:"live",owner:de,parse:l({id:N(p),artboardId:d(N(p)),index:d(I)})},"request-layers":{gate:"any",target:"parent",status:"live",owner:de,parse:l({artboardId:N(p)})},"force-clear":{gate:"any",target:"parent|self",status:"live",owner:de,parse:he},"select-clear":{gate:"any",target:"parent|self",status:"legacy",owner:de,orphan:"no-sender",parse:he},"locked-set":{gate:"parent",status:"live",owner:de,parse:l({locked:j(p)})},"apply-style":{gate:"parent",status:"live",owner:de,parse:l({id:p,artboardId:d(N(p)),index:d(I),prop:p,value:N(p)})},"record-edit":{gate:"parent",status:"live",owner:de,parse:l({payload:ce})},"apply-edit-result":{gate:"parent",status:"live",owner:de,parse:l({requestId:p,ok:L,error:d(p),conflict:d(L)})},"undo-barrier-ok":{gate:"parent",status:"live",owner:de,parse:l({requestId:p})},"edit-op-result":{gate:"parent",status:"live",owner:"editing (S2.1)",parse:l({requestId:p,ok:L,actionId:d(N(p)),writeId:d(p),rev:d(p),refs:d(j($e)),created:d(j($e)),code:d(V(...Zi)),message:d(p)})},"edit-reverted":{gate:"parent",status:"live",owner:de,parse:l({op:p,id:d(p),reason:d(p)})},"reorder-failed":{gate:"parent",status:"live",owner:de,parse:he},"reposition-failed":{gate:"parent",status:"live",owner:de,parse:he},"resize-failed":{gate:"parent",status:"live",owner:"use-element-resize",parse:he},"resize-artboard-failed":{gate:"parent",status:"live",owner:"use-element-resize",parse:he},"freeze-and-set-kind":{gate:"parent",status:"live",owner:de,parse:l({artboardId:p,kind:N(p),ask:d(L),freeze:d(L)})},"op-toast":{gate:"any",target:"parent",status:"live",owner:de,parse:l({message:p})},"tool-set":{gate:"parent",status:"live",owner:"use-tool-mode",orphan:"no-sender",parse:l({tool:p})},"insert-sticker":{gate:"parent",status:"live",owner:"annotations-layer",parse:l({path:p,follow:d(L),preview:d(Va),sticker:d(Y({pack:p,id:p,flip:d(L)}))})},"reveal-artboard":{gate:"parent",status:"live",owner:"canvas-lib",parse:l({artboardId:p,glide:L,flash:L})},"convert-marks":{gate:"parent",status:"live",owner:"artboard-convert-marks",parse:l({v:V(1),from:p,to:p,extraPct:I,fill:N(D(40))})},"shell-panels":{gate:"parent",status:"live",owner:"shell-panels",parse:l({v:V(1),open:N(V("stickers","assets","components"))})},"ai-copies":{gate:"parent",status:"live",owner:"artboard-ai-copies",parse:l({v:V(1),copies:Oi})},"ai-runs":{gate:"parent",status:"live",owner:"artboard-activity-overlay",parse:l({artboards:vt(Y({state:V("running","needs-you","done"),who:D(200),tag:D(120),waiting:kt}))})},"insert-template":{gate:"parent",status:"live",owner:"annotations-layer",parse:l({id:p,follow:d(L)})},"trashed-artboards":{gate:"parent",status:"live",owner:"artboard-ghosts-overlay (S11.5)",parse:l({canvas:D(1024),items:j(Y({id:D(128),label:D(200),rect:N(He)}))})},"place-component":{gate:"parent",status:"live",owner:"editing/place-ghost",parse:l({component:qa,label:d(D(64)),variant:d(Do),glyph:d(Do),mode:V("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:D(512),natural:d(N(Y({w:I,h:I}))),label:d(D(200))})},"asset-drag-over":{gate:"parent",status:"live",owner:"editing/image-drop (r3)",parse:l({x:N(I),y:d(I)})},"asset-drop-at":{gate:"parent",status:"live",owner:"editing/image-drop (r3)",parse:l({requestId:D(64),x:I,y:I})},"asset-drop-done":{gate:"parent",status:"live",owner:"editing/image-drop (r3)",parse:l({requestId:D(64),ok:L,created:d(j($e)),message:d(D(400))})},"timeline-drop-hint":{gate:"parent",status:"live",owner:"editing/drop-chip (S7.9)",parse:l({artboardId:p,on:L})},"timeline-word":{gate:"parent",status:"live",owner:"collab/timeline-presence (S7.17)",parse:l({artboardId:N(Ie),wordKey:d(Fo)})},"video-frame-handle":{gate:"parent",status:"live",owner:"editing/video-frame-handle (T3.6b)",parse:l({v:V(1),artboardId:N(Ie),stableId:d(Ho),label:d(D(120)),src:d(N(Wa)),zoom:d($o),focus:d(qo)})},"dim-artboards":{gate:"parent",status:"live",owner:"editing/kind-dim (S7.24b) ← client/v2/kinds/kind-dim-relay",parse:l({ids:N(Le(ki,j(D(128))))})},"size-ghost":{gate:"parent",status:"live",owner:"editing/size-ghost (S7.20)",parse:l({preset:N(Y({id:D(40),label:D(80),sizeText:D(40),w:I,h:I}))})},"insert-annotation-media":{gate:"parent",status:"live",owner:"annotations-layer",parse:l({paths:j(p)})},"replace-annotation-media":{gate:"parent",status:"live",owner:"annotations-layer",parse:l({id:p,path:p,sticker:d(Y({pack:p,id:p,flip:d(L)}))})},"photo-preview":{gate:"any",target:"parent",status:"live",owner:"canvas-lib (photo)",parse:l({asset:p,edit:N(ce),use:d(p)})},"photo-busy":{gate:"any",target:"parent",status:"live",owner:"canvas-lib (photo)",parse:l({asset:p,busy:L})},"comments-set":{gate:"any",target:"parent",status:"live",owner:"comments-overlay",parse:l({comments:j(ce)})},"comment-focus":{gate:"any",target:"parent",status:"live",owner:"comments-overlay",parse:l({id:N(p),reply:d(V(!0))})},"comment-op-ack":{gate:"parent",status:"live",owner:"comments-overlay (S9.22)",parse:l({reqId:N(it)})},"comment-op-result":{gate:"parent",status:"live",owner:"comments-overlay (S9.22)",parse:l({reqId:N(it),ok:L,comment:d(N(ce)),status:d(I),error:d(p)})},"comment-people":{gate:"parent",status:"live",owner:"comments-overlay (S9.22)",parse:l({reqId:N(it),people:N(j(Vi))})},"annotation-select":{gate:"parent",status:"live",owner:"annotations-layer (S4.9)",parse:l({v:V(1),ids:j(D(200))})},"annotation-filter":{gate:"parent",status:"live",owner:"annotations-layer (S4.9)",parse:l({v:V(1),authors:j(D(200))})},"export-capture":{gate:"parent",status:"live",owner:"canvas-lib (export)",parse:l({id:p,format:p,artboardIds:j(p),scale:I})},"export-selection-query":{gate:"parent",status:"live",owner:"canvas-lib (export)",parse:l({id:p})},"export-result":{gate:"parent",status:"live",owner:"export-dialog",orphan:"no-handler",parse:l({id:p,ok:L,browser:d(L),jobId:d(p),error:d(p)})},"export-history-result":{gate:"parent",status:"live",owner:"export-dialog",orphan:"no-handler",parse:l({id:p,history:j(ce)})},"timeline-play":{gate:"any",target:"parent",status:"live",owner:"video-comp",parse:l(Pe)},"timeline-pause":{gate:"any",target:"parent",status:"live",owner:"video-comp",parse:l(Pe)},"timeline-seek":{gate:"any",target:"parent",status:"live",owner:"video-comp",parse:l({...Pe,frame:I})},"timeline-loop":{gate:"any",target:"parent",status:"live",owner:"video-comp",parse:l({...Pe,loop:L})},"timeline-mute":{gate:"any",target:"parent",status:"live",owner:"video-comp",parse:l({...Pe,muted:L})},"timeline-volume":{gate:"any",target:"parent",status:"live",owner:"video-comp",parse:l({...Pe,volume:I})},"timeline-request-comps":{gate:"any",target:"parent",status:"live",owner:"video-comp",parse:he},"run-action":{gate:"parent",status:"live",owner:"actions/registry (V2-1.3)",parse:l({v:V(1),id:p,params:d(ce)})},"paste-data":{gate:"parent",status:"live",owner:"bridge/paste-data (p8-sweep-leftovers)",parse:(e)=>{let t=Co(e);return t?{...t}:null}},"git-lifecycle":{gate:"parent",status:"legacy",owner:"c/app",orphan:"no-handler",parse:l({payload:ce})},"set-mode":{gate:"parent",status:"live",owner:"bridge/canvas-mode-store (V2-4.3b)",parse:l({v:V(2),seq:I,mode:St,present:N(yn),tool:d(bn),caps:Xa})},"occluded-insets":{gate:"parent",status:"new",owner:"bridge/canvas-mode-store",parse:l({seq:I,insets:Za,topBand:Ja})},"present-step":{gate:"parent",status:"live",owner:"bridge/canvas-mode-store (S3.1)",parse:l({to:(e)=>e==="next"||e==="prev"?e:I(e)})},"present-follow":{gate:"parent",status:"live",owner:"bridge/canvas-mode-store (S3.7a)",parse:l({sid:N(wn),live:L,locked:L})},"present-media-cmd":{gate:"parent",status:"live",owner:"present/present-media (S3.3)",parse:l({op:V("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:L})},"annotation-prefs":{gate:"parent",status:"live",owner:"annotations/ui/tool-state (S4.8)",parse:l({prefs:jo})},"vote-state":{gate:"parent",status:"live",owner:"annotations/ui/vote-dots (S4.14)",parse:l({vote:N(Y({id:xt,targets:Le(32,j(D(200))),state:V("open","ended"),perVoter:fe(1,99),tallies:d(vt(kt,32))})),mine:vt(kt,32)})},"hold-intent":{gate:"parent",status:"live",owner:"editing/hold-rings (S2.18)",parse:l({field:L,app:L,gesture:d(L)})},"ai-holds":{gate:"parent",status:"live",owner:"editing/hold-rings (S2.18)",parse:l({holds:Ci})},"ai-seen":{gate:"parent",status:"live",owner:"annotations/ui/ai-seen (S4.15); sent by v2/ai/seen-relay.js",parse:l({targets:Ni})},"undo-preview":{gate:"parent",status:"live",owner:"editing/undo-preview (S2.20)",parse:l({artboards:j(p),tag:N(p)})},"asset-state":{gate:"parent",status:"live",owner:"canvas-lib asset placeholder frame (S8.19, L1)",parse:l({items:ji,lfsActions:d(L)})},"asset-lfs-copied":{gate:"parent",status:"live",owner:"canvas-lib asset placeholder frame (2.0.3 LFS placeholder)",parse:l({rel:D(512),ok:L})},"gen-takes":{gate:"parent",status:"live",owner:"editing/take-keys (S8.16, L1)",parse:l({assets:Ui})},stills:{gate:"parent",status:"live",owner:"artboard-still-persist (#212 §5)",parse:l({file:D(1024),items:Le(Xi,j(Y({artboard:Zo,sig:D(Jo),bytes:Go})))})}};var Ji="dgn",el=(e,t)=>Object.assign({},e,{[Ji]:t}),er=(e,t)=>Object.hasOwn(e,t),tl=(e)=>ke(e)&&typeof e.dgn==="string"?e.dgn:null;function nl(e){return er(vn,e)?vn[e]:null}function ol(e){return er(Vo,e)?Vo[e]:null}function rl(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 Ru=new Set(Object.keys(vn).filter((e)=>nl(e)?.gate==="active"));function At(e,t){let n=tl(e.data),o=n?ol(n):null;if(!n||!o||!rl(o.gate,e,t))return null;let r=o.parse(e.data);return r?el(r,n):null}var sl=/^[A-Za-z0-9_-]{1,64}$/;function lt(e){return typeof e==="string"&&sl.test(e)}function tr(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 nr(){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 Mt(e,t){let n=nr();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 or(e){let t=nr();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 Ct(e){if(typeof document>"u"||!lt(e))return null;return document.querySelector(`[data-id="${e}"][data-tool]`)}function rr(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(!lt(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}var je=null;function Ge(){return je}function xn(e,t){if(typeof document>"u")return;try{document.dispatchEvent(new CustomEvent(e,{detail:t}))}catch{}}function sr(e){xn("cm:reattach-start",{id:e})}function It(){je=null,xn("cm:reattach-cancel",{})}function ar(e,t){if(typeof document>"u")return()=>{};let n=(r)=>{let s=r.detail?.id;if(typeof s!=="string"||!s)return;je=s,e()},o=()=>{je=null,t()};return document.addEventListener("cm:reattach-start",n),document.addEventListener("cm:reattach-cancel",o),()=>{document.removeEventListener("cm:reattach-start",n),document.removeEventListener("cm:reattach-cancel",o),je=null}}function ir(e,t,n){let o=je;if(o===null)return!1;return je=null,xn("cm:reattach",{id:o,selection:e,clientX:t,clientY:n}),!0}function lr(e,t){if(typeof document>"u")return()=>{};let n=(o)=>{let r=o.detail;if(!r||typeof r.id!=="string"||!r.selection||typeof r.selection.selector!=="string")return;e(r)};return document.addEventListener("cm:reattach",n),document.addEventListener("cm:reattach-cancel",t),()=>{document.removeEventListener("cm:reattach",n),document.removeEventListener("cm:reattach-cancel",t)}}function cr(e,t,n={}){return{op:"reattach",id:e,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.world?{world:t.world}:{},...n.artboard?{artboard:n.artboard}:{}}}import{useCallback as oe,useEffect as pe,useLayoutEffect as fs,useMemo as We,useRef as be,useState as ie}from"react";var Pt=null;function Oe(){if(typeof window>"u")return!1;if(Pt===null)try{Pt=new URLSearchParams(window.location.search).get("ro")==="1"}catch{Pt=!1}return Pt}var _t=null;function Ze(){if(typeof window>"u")return!1;if(_t===null)try{_t=new URLSearchParams(window.location.search).get("cm")==="1"}catch{_t=!1}return _t}var Lt=null;function kn(){if(typeof window>"u")return!1;if(Lt===null)try{Lt=new URLSearchParams(window.location.search).get("cg")==="1"}catch{Lt=!1}return Lt}var ct="Comments are paused while this project is view only.",Ot=null;function Sn(){if(typeof window>"u")return!1;if(Ot===null)try{Ot=new URLSearchParams(window.location.search).get("embed")==="1"}catch{Ot=!1}return Ot}function En(){if(typeof window>"u")return!1;try{return new URLSearchParams(window.location.search).get("follow")==="1"}catch{return!1}}function dr(){if(typeof window>"u")return!1;try{return!!new URLSearchParams(window.location.search).get("sha")}catch{return!1}}var ur=Symbol.for("maude.canvasMode.v2");function Me(e){let t=e,n=t[ur];if(n&&n.doc===e.document)return n;let o={insets:cn,insetsSeq:-1,topBand:null,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,u=new Set,m={get:()=>o,subscribe(h){return u.add(h),()=>{u.delete(h)}},claimEcho(h){if(h!==o.modeSeq||h<=a)return!1;return a=h,!0},claimRequest(h){let f=Date.now(),w=c.get(h);if(w!==void 0&&f-w<250)return!1;return c.set(h,f),!0}};return e.addEventListener("message",(h)=>{let f=At(h,e);if(f?.dgn==="set-mode"){if(f.seq<=o.modeSeq)return;c=new Map;let w=f.caps.present===!0&&!En(),R=Oe()?{edit:!1,annotate:!1,comment:f.caps.comment,present:w}:{...f.caps,present:w},g=xo(f.mode,R),x=f.tool?at(f.tool,R,g):null,S=f.tool&&(x===null||x===g)?f.tool:null;o={...o,mode:g,present:g==="present"?f.present??{kind:"canvas"}:null,caps:Object.freeze(R),modeSeq:f.seq,tool:S,prevMode:o.mode,clamped:g!==f.mode,step:g==="present"?o.step:null};for(let y of u)y(o);return}if(f?.dgn==="present-step"){if(o.mode!=="present")return;r+=1,o={...o,step:Object.freeze({to:f.to,n:r})};for(let w of u)w(o);return}if(f?.dgn==="present-follow"){if(!En())return;s+=1,o={...o,follow:Object.freeze({sid:f.sid,live:f.live,locked:f.locked,n:s})};for(let w of u)w(o);return}if(f?.dgn==="key-prefs"){if(f.singleKeys===o.singleKeys)return;o={...o,singleKeys:f.singleKeys};for(let w of u)w(o);return}if(f?.dgn!=="occluded-insets")return;if(f.seq<=o.insetsSeq)return;o={...o,insets:Object.freeze({...f.insets}),insetsSeq:f.seq,topBand:f.topBand?Object.freeze({...f.topBand}):null};for(let w of u)w(o)}),Object.defineProperty(m,"doc",{value:e.document}),t[ur]=m,m}function pr(){return typeof window>"u"?cn:Me(window).get().insets}if(typeof window<"u"&&typeof window.addEventListener==="function")Me(window);var Ne=["sky","green","yellow","lilac","grey"],mr="yellow",Tn=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 fr(e){if(!e)return Ne[0];let t=5381;for(let o=0;o<e.length;o++)t=(t<<5)+t+e.charCodeAt(o)|0;let n=(t%Ne.length+Ne.length)%Ne.length;return Ne[n]??Ne[0]}var Rn=(e)=>Tn[e];var al="Someone",il=(e)=>{if(typeof e!=="string")return!0;let t=e.trim().toLowerCase();return t===""||t==="unknown"};function dt(e,t){if(il(e))return{name:al,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?mr:fr(n),you:o}}var ll=(e)=>e.trim().split(/\s+/)[0]||"";function ut(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:ll(t)}}function gr(e){let t=ut(e);return t.first?`From ${t.first}’s sticky`:"From a sticky"}var cl=/^[A-Za-z0-9._-]{1,40}$/;var dl={figma:"Figma"},ul=/[\p{Cc}\p{Cf}\p{Cs}\p{Co}\p{Cn}\p{Zl}\p{Zp}]/gu;function pl(e){if(typeof e!=="string")return"";let n=e.normalize("NFC").replace(/\s+/gu," ").replace(ul,"").replace(/\s+/gu," ").trim();return Array.from(n).slice(0,80).join("").trim()}var hr=(e)=>!!e&&typeof e==="object"&&!Array.isArray(e);function ml(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 An(e){if(!hr(e)||e.source!=="figma")return;let t=hr(e.author)?e.author:{},n={source:"figma",author:{name:pl(t.name)||"Someone"}};if(typeof t.handle==="string"&&t.handle.length<=40&&cl.test(t.handle))n.author.handle=t.handle;let o=ml(e.at);if(o)n.at=o;return n}function Mn(e){return e?`${e.author.name} · from ${dl[e.source]}`:""}function br(e){return(String(e??"").trim().split(/\s+/)[0]??"").replace(/[^\w.-]/g,"").toLowerCase()}var fl="You";function yr(e,t,n=!1){let{mine:o,...r}=e;if(!t)return r;return n?{...r,author:fl,mine:!0}:{...r,mine:!0}}function gl(e,t,n=!1){return(Array.isArray(e)?e:[]).map((o)=>{let r=yr(o,t(o),n);if(Array.isArray(o.thread))r.thread=o.thread.map((s)=>s&&typeof s==="object"?yr(s,t(s),n):s);return r})}function wr(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 vr(e,t){return gl(e,(n)=>typeof n.id==="string"&&t.has(n.id))}function Je(e,t){return e?.mine===!0&&typeof e.author==="string"?e.author:t}var xr=Object.freeze({observer:"Can view",viewer:"Can comment",member:"Can edit",owner:"Owner"}),hl=(e)=>typeof e==="string"&&Object.hasOwn(xr,e)?xr[e]:void 0;function bl(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 u=typeof a.id==="string"&&a.id?a.id:c;if(o.has(u))continue;o.add(u);let m=hl(a.role);n.push(m?{id:u,name:c,role:m}:{id:u,name:c})}return n}function kr(e,t){if(!Array.isArray(e))return[];return bl(e.map((n)=>({name:n?.name})),t)}var Sr="cm:reveal";function yl(e,t=96){return e*t/25.4}function Er(e,t=96){return e*25.4/t}var wl=[{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 vl(e){return wl.find((t)=>t.id===e)}function xl(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 kl(e){return e.unit==="mm"?3:3.175}var Nt=5,Sl=200;function Dt(e){if(!Number.isFinite(e))return 0;return Math.min(Math.max(e,0),Sl)}function El(e){let t=e??{};return{top:typeof t.top==="number"?Dt(t.top):Nt,right:typeof t.right==="number"?Dt(t.right):Nt,bottom:typeof t.bottom==="number"?Dt(t.bottom):Nt,left:typeof t.left==="number"?Dt(t.left):Nt}}function Cn(e,t=96){return Math.round(yl(e,t))}function In(e){let t=vl(e.paper);if(!t)throw Error(`unknown paper preset: ${e.paper}`);let n=e.orientation??"portrait",{widthMm:o,heightMm:r}=xl(t,n),s=e.bleedMm??kl(t),a=El(e.marginsMm),c=Cn(s),u=Cn(o),m=Cn(r);return{paper:t.id,orientation:n,trimWidthMm:o,trimHeightMm:r,bleedMm:s,widthPx:u+2*c,heightPx:m+2*c,trimWidthPx:u,trimHeightPx:m,bleedPx:c,marginsMm:a}}function Tl(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 Rl=(e)=>`at ${Tl(e)}`,Al=0.5;function Tr(e,t,n=Al){if(t===null||t===void 0||!Number.isFinite(t))return!0;return Math.abs(t-e)<=n}function Pn(e){if(!e||typeof e!=="object")return null;let t=e;if(typeof t.paper!=="string")return null;try{let n=In({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 Rr(e,t){if(!e||typeof e!=="object")return null;let n=e;if(typeof n.paper!=="string")return null;try{let o=In({paper:n.paper,orientation:n.orientation==="landscape"?"landscape":"portrait",...typeof n.bleedMm==="number"?{bleedMm:n.bleedMm}:{}}),r=(s)=>Math.round(Er(s)*10)/10;return{x:r(t.x-o.bleedPx),y:r(t.y-o.bleedPx)}}catch{return null}}var Kt=(e)=>`${Math.round(e)} mm`;function Ml(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?`${Kt(t.wMm-e.x)} from the right`:`${Kt(e.x)} from the left`,s=o?`${Kt(t.hMm-e.y)} above the trim`:`${Kt(e.y)} from the top`;return`${r} · ${s}`}function _n(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:Rl(e.t),kind:"video"};let o=e.mm;if(o&&typeof o.x==="number"&&typeof o.y==="number")return{artboard:n,chip:Ml({x:o.x,y:o.y},t),kind:"print"};return{artboard:n,chip:null,kind:n?"artboard":"canvas"}}class De extends Error{}var Ln=(e,t)=>Math.abs(e.x-t.x)<0.000001&&Math.abs(e.y-t.y)<0.000001,ue=(e,t)=>({x:e,y:t}),zt=/([MmLlHhVvCcSsQqTtZzAa])|(-?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?)/g,Cl={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,Z:0};function Il(e){let t=[];zt.lastIndex=0;let n=0;for(let o=zt.exec(e);o;o=zt.exec(e)){if(/[^\s,]/.test(e.slice(n,o.index)))throw new De("not a path");t.push(o[1]??Number(o[2])),n=zt.lastIndex}if(/[^\s,]/.test(e.slice(n)))throw new De("not a path");return t}function Ar(e){let t=Il(e),n=[],o=null,r=ue(0,0),s=ue(0,0),a=null,c=null,u=0,m="",h=(g)=>{let x=[];for(let S=0;S<g;S++){let y=t[u++];if(typeof y!=="number")throw new De("not a path");x.push(y)}return x},f=(g)=>{o={closed:!1,points:[{...g}]},n.push(o),r=g,s=g},w=(g,x,S)=>{if(!o)f(r);let y=o,i=y.points[y.points.length-1];if(!Ln(g,i))i.out=g;let k={...S};if(!Ln(x,S))k.in=x;y.points.push(k),r=S,a=x,c="c"},R=(g)=>{if(!o)f(r);o.points.push({...g}),r=g,c=null};while(u<t.length){let g=t[u];if(typeof g==="string"){if(m=g,u++,g==="A"||g==="a")throw new De("arc")}else if(!m||m==="Z"||m==="z")throw new De("not a path");else if(m==="M")m="L";else if(m==="m")m="l";let x=m===m.toLowerCase(),S=m.toUpperCase(),y=x?r.x:0,i=x?r.y:0,k=Cl[S];if(k===void 0)throw new De("not a path");let A=h(k);switch(S){case"M":f(ue(A[0]+y,A[1]+i)),c=null;break;case"L":R(ue(A[0]+y,A[1]+i));break;case"H":R(ue(A[0]+y,r.y));break;case"V":R(ue(r.x,A[0]+i));break;case"C":w(ue(A[0]+y,A[1]+i),ue(A[2]+y,A[3]+i),ue(A[4]+y,A[5]+i));break;case"S":{let q=c==="c"&&a?ue(2*r.x-a.x,2*r.y-a.y):r;w(q,ue(A[0]+y,A[1]+i),ue(A[2]+y,A[3]+i));break}case"Q":case"T":{let q=r,E,P;if(S==="Q")E=ue(A[0]+y,A[1]+i),P=ue(A[2]+y,A[3]+i);else E=c==="q"&&a?ue(2*r.x-a.x,2*r.y-a.y):r,P=ue(A[0]+y,A[1]+i);w(ue(q.x+0.6666666666666666*(E.x-q.x),q.y+0.6666666666666666*(E.y-q.y)),ue(P.x+0.6666666666666666*(E.x-P.x),P.y+0.6666666666666666*(E.y-P.y)),P),a=E,c="q";break}case"Z":{if(o){let q=o;q.closed=!0;let E=q.points[0],P=q.points[q.points.length-1];if(q.points.length>1&&Ln(E,P)){if(P.in)E.in=P.in;q.points.pop()}}r=s,c=null;break}}}if(n.length===0)throw new De("empty");return{subs:n}}var Mr=(e)=>e.subs.reduce((t,n)=>t+n.points.length,0);var Pl=new RegExp("^(?:#[0-9a-f]{3,8}|[a-z]+|(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch|color|color-mix|var|(?:repeating-)?(?:linear|radial|conic)-gradient)\\([^;{}<>\\\\\"'`]*\\))(?:\\s*,\\s*(?:#[0-9a-f]{3,8}|[a-z]+|(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch|color|color-mix|var|(?:repeating-)?(?:linear|radial|conic)-gradient)\\([^;{}<>\\\\\"'`]*\\)))*$","i"),_l=/url\s*\(|image\s*\(|image-set|element\s*\(|expression/i;function Cr(e){return typeof e==="string"&&e.length>0&&e.length<=512&&Pl.test(e)&&!_l.test(e)}function Ir(e,t){return(t?.flexDirection||"row").trim().startsWith("row")?e==="width":e==="height"}var Ll=new Set(["fit-content","max-content","min-content","auto"]),Ol=new Set(["100%","fill","-webkit-fill-available","stretch"]),Nl=(e)=>e==="flex"||e==="inline-flex";function Dl(e,t){let n=t.width.trim().toLowerCase();if(Ol.has(n))return"fill";if(Ll.has(n))return"hug";if(/^-?\d/.test(n))return"fixed";if(Ir("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 Pr(e,t){if(!Nl(e.display)||t.length<2)return;let n=new Set(t.map((r)=>Dl(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 Kl=new WeakMap;var _r=(e)=>Kl.get(e)??null;var Lr=(e)=>e?`${e.sub},${e.i},${e.kind},${e.x},${e.y}`:"";var On=["font-family","font-size","font-weight","line-height","letter-spacing","text-transform","font-style"];var zl=/^t-[a-z][a-z0-9-]*$/,Vl=(e)=>(e??"").split(/\s+/).filter(Boolean),Or=(e)=>Vl(e).filter((t)=>zl.test(t));var sp=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 ap=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 Nr=(e,t)=>{let n=t.getComputedStyle(e),o={};for(let r of On)o[r]=n.getPropertyValue(r).trim();return o},Fl=(e)=>e.closest?.("[lang]")?.getAttribute("lang")?.trim()??"";function Dr(e){let n=e.ownerDocument?.defaultView;if(!n||typeof n.getComputedStyle!=="function")return null;let o=Or(e.getAttribute("class"))[0]??null,r=Nr(e,n),s={role:o,values:{},differs:[],lang:Fl(e),upper:(n.getComputedStyle(e).getPropertyValue("text-transform")??"").trim()==="uppercase"};if(!o)return s;let a=e,c=e.hasAttribute("style"),u=e.getAttribute("style")??"";try{let m=`${u};transition:none`;a.setAttribute("style",m),a.setAttribute("style","transition:none"),s.values=Nr(e,n),a.setAttribute("style",m),n.getComputedStyle(e).getPropertyValue("font-size")}finally{if(c)a.setAttribute("style",u);else a.removeAttribute("style")}return s.differs=On.filter((m)=>r[m]!==s.values[m]),s}function Hl(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 Vt(){if(typeof window>"u")return null;try{return Hl(window.location.pathname,window.location.search)}catch{return null}}function Dn(){return Vt()??void 0}function Ft(e){if(!e)return"";return(e.getAttribute("class")??"").trim().split(/\s+/).filter((t)=>t&&!t.startsWith("dgn-")&&!t.startsWith("dc-cv-")).join(" ")}var $l=/^$|^(inline|contents|ruby|ruby-text)$|^inline-/;function ql(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=!$l.test(a);if(c)t+=" ";for(let u=r.firstChild;u;u=u.nextSibling)n(u);if(c)t+=" "};return n(e),t}function jl(e,t){if(!e)return"";let o=(e.innerText||(e.textContent?ql(e):"")).replace(/\s+/g," ").trim();return o.length>t?`${o.slice(0,t-1)}…`:o}function Bl(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=Ft(n).split(/\s+/).filter(Boolean).slice(0,2);if(a.length)s+=`.${a.join(".")}`;let c=1,u=n.previousElementSibling;while(u)c++,u=u.previousElementSibling;s+=`:nth-child(${c})`,t.unshift(s),n=n.parentElement}return t.join(" > ")}function zr(e){let t=e.nodeName.toLowerCase(),n=e.getAttribute?.("data-dc-element"),o=e.getAttribute?.("data-dc-screen");if(n)t+=`[data-dc-element="${n}"]`;else if(o)t+=`[data-dc-screen="${o}"]`;else if(e.id)t+=`#${e.id}`;let r=Ft(e).split(/\s+/).filter(Boolean).slice(0,2);if(r.length&&!n&&!o)t+=`.${r.join(".")}`;return t}function Vr(e){let t=[],n=e;while(n&&n.nodeType===1&&t.length<8)t.unshift(zr(n)),n=n.parentElement;return t}function Wl(e,t){if(!e||!t)return null;let n=[],o=e;while(o&&o.nodeType===1){if(o.getAttribute?.("data-dc-screen")===t){if(n.length===0)return null;return`[data-dc-screen="${t}"] > ${n.join(" > ")}`}let r=1;for(let a=o.previousElementSibling;a;a=a.previousElementSibling)r++;let s=o.localName;n.unshift(`${s===s.toLowerCase()?s:"*"}:nth-child(${r})`),o=o.parentElement}return null}function Ul(e){return e.replace(/[^a-zA-Z0-9_-]/g,(t)=>`\\${t}`)}function Fr(e,t){return t?`[data-dc-screen="${t}"] [data-cd-id="${e}"]`:`[data-cd-id="${e}"]`}function Hr(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 $r(e,t,n){if(!t||!n)return 0;return Hr(e,`[data-cd-id="${Ul(t)}"]`,n)}function Kn(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(Fr(t.id,t.artboardId));if(o)return o}if(t.selector)return n(t.selector);return null}function Xl(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 qr(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 m=e.querySelector(`[data-dc-screen="${t.artboardId}"]`);if(m)r=m}let s=(t.classes||"").split(/\s+/).filter(Boolean),a=null,c=0,u=n[n.length-1];for(let m of Array.from(r.getElementsByTagName(o))){if(zr(m)!==u)continue;let h=Xl(Vr(m),n);if(h===0)continue;let f=Ft(m).split(/\s+/).filter(Boolean),w=s.filter((g)=>f.includes(g)).length,R=h*10+w;if(R>c)c=R,a=m}return a}var Kr=["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"],Yl=/^(style|class|data-cd-id|data-dc-|data-dcid$)/;function Ql(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(Kr);for(let g of Kr){let x=t.getPropertyValue(g);if(x)o[g]=x.trim();let S=n.getPropertyValue(g);if(S)r[g]=S.trim()}let a=/^(margin|padding|border)(-|$)/,c={};for(let g=0;g<t.length;g++){let x=t.item(g);if(!x||s.has(x)||a.test(x))continue;let S=t.getPropertyValue(x);if(S)c[x]=S.trim()}let u={};for(let g of Array.from(e.attributes)){if(Yl.test(g.name))continue;u[g.name]=g.value}if(e.tagName.toLowerCase()==="svg"&&e.getAttribute("data-shape")==="path"){let g=e.querySelector("path")?.getAttribute("d");if(g)try{u["data-dc-pen-points"]=String(Mr(Ar(g)))}catch{}let x=Lr(_r(e));if(x)u["data-dc-pen-point"]=x}if(e.hasAttribute("data-dc-screen")){for(let x of Array.from(e.attributes))if(x.name.startsWith("data-dc-")&&x.name!=="data-dcid")u[x.name]=x.value;let g=nc(e);if(g)u["data-dc-web-longest"]=String(g)}let m=e.parentElement,h=m?window.getComputedStyle(m).display:"",f=m&&(h==="flex"||h==="inline-flex")?window.getComputedStyle(m).flexDirection:"",w={},R=t.getPropertyValue("background").trim();if(Cr(R))w.background=R;return{authored:o,computed:r,customStyles:c,attrs:u,declared:w,parentDisplay:h,parentFlexDirection:f}}catch{return{authored:{},computed:{},customStyles:{},attrs:{}}}}function Gl(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 Zl=/^--[A-Za-z0-9_-]{1,128}$/,Jl=/^[A-Za-z][A-Za-z0-9]{0,63}$/;function jr(e){let t=e.getAttribute?.("data-ds-token");if(t&&Zl.test(t))return`[data-ds-token="${t}"]`;let n=e.getAttribute?.("data-ds-master");if(n&&Jl.test(n))return`[data-ds-master="${n}"]`;return null}function Ht(e,t){let n=e.el,o=n&&n.getBoundingClientRect?n.getBoundingClientRect():null,r=e.cdId,s=!r&&n?jr(n):null,a=r?Fr(r,e.artboardId):s?e.artboardId?`[data-dc-screen="${e.artboardId}"] ${s}`:s:e.artboardId?`[data-dc-screen="${e.artboardId}"]`:Bl(n),c=r&&typeof document<"u"?Hr(document,a,n):0;return{file:t??Dn(),id:r??void 0,selector:a,artboardId:s?null:e.artboardId,index:c,tag:n?.tagName.toLowerCase()??"",classes:Ft(n),text:jl(n,240),dom_path:Vr(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(Ur(n)):void 0,worldH:n instanceof HTMLElement?Math.round(Nn(n)):void 0,geometry:n instanceof HTMLElement?Gl(n):void 0,html:n?(n.outerHTML??"").slice(0,4000):"",...(()=>{if(n?.tagName?.toLowerCase()!=="img")return{};let u=/assets\/[0-9a-f]{8}\.[a-z0-9]+/i,m=n.getAttribute?.("data-photo-asset");if(m&&u.test(m))return{photoKind:"artboard-img",photoAsset:m};let h=n.getAttribute?.("src")||"",f=u.exec(h);return f?{photoKind:"artboard-img",photoAsset:f[0]}:{}})(),...Ql(n),...tc(n),...ec(n)}}function ec(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=Pr({display:n,flexDirection:t.flexDirection,alignItems:t.alignItems},o);return r?{kids:r}:{}}catch{return{}}}function tc(e){if(!e||e.children.length>0)return{};if(!(e.textContent??"").trim()&&!e.getAttribute("class"))return{};let t=Dr(e);return t?{textInfo:t}:{}}function Br(e,t,n,o){let r=Ht({el:e.el,cdId:e.cdId??null,artboardId:e.artboardId??null},o),s=e.el;if(s&&!e.cdId&&e.artboardId&&!jr(s)){let c=Wl(s,e.artboardId);if(c)r.selector=c,r.index=0}let a=Mt(t,n);return a?{...r,world:a}:r}function Wr(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 Ur(e){return Wr(e)?.offsetWidth??e.offsetWidth}function nc(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(Ur(a)))).size!==o.length)return null;let s=Nn(e);return o.every((a)=>a===e||Nn(a)<s)?o.length:null}function Nn(e){let t=Wr(e);if(t)return t.offsetHeight;if(e.getAttribute("data-dc-fixed")!=="true"||!e.hasAttribute("data-dc-screen"))return e.offsetHeight;let n=Array.from(e.children).find((o)=>o.classList.contains("dc-artboard-label"));return e.offsetHeight-(n?n.offsetHeight:0)}function Xr(){if(typeof window>"u")return null;let e=window.__maudeFrameFreeze;return e&&typeof e.raf==="function"?e:null}function le(e){let t=Xr();return t?t.raf(e):requestAnimationFrame(e)}function Ae(e){let t=Xr();if(t)t.caf(e);else cancelAnimationFrame(e)}import*as Vn from"lib0/decoding";import*as pt from"lib0/encoding";import{createContext as sc,useCallback as Wp,useContext as ac,useEffect as Up,useMemo as Xp,useReducer as Yp,useRef as Qp,useState as Gp}from"react";import{Awareness as Jp,applyAwarenessUpdate as em,encodeAwarenessUpdate as tm}from"y-protocols/awareness";import{readSyncMessage as om,writeSyncStep1 as rm,writeUpdate as sm}from"y-protocols/sync";import*as Fn from"yjs";import*as oc from"yjs";var rc=new WeakSet;function Yr(e){return rc.add(e),e}var vp=Yr(Object.freeze({maudeOrigin:"shell-edit"})),xp=Yr(Object.freeze({maudeOrigin:"sync-agent"}));import*as $t from"lib0/decoding";import*as et from"lib0/encoding";import*as Qr from"y-protocols/awareness";import*as zn from"y-protocols/sync";var Ep=Object.freeze(["timeline","editing","holding"]),Tp=Object.freeze(["editing","holding"]);var pm=Ne.map((e)=>Tn[e]);var ic=sc(null);function Gr(){return ac(ic)}var mm=Object.freeze({maudeOrigin:"collab-epoch-resync"});import{createContext as lc,useCallback as Se,useContext as $n,useEffect as cc,useMemo as dc,useRef as mt,useState as uc}from"react";import{jsx as Hn,Fragment as bc}from"react/jsx-runtime";var jt=lc(null);function Ce(e){return e.id?`id:${e.id}`:`sel:${e.selector}`}function qt(e){let t=[],n=new Set;for(let o of e){let r=Ce(o);if(n.has(r))continue;n.add(r),t.push(o)}return t}var pc=50,es=500,mc=(e,t)=>e.length===t.length&&e.every((n,o)=>Ce(n)===Ce(t[o]));function Zr(e,t,n,o=Date.now()){return o-e<es&&!mc(n,t)}function fc(e,t,n=Date.now()){if(n-e.at>=es||t.length===0)return!1;let o=new Set(e.sel.map(Ce));return t.every((r)=>o.has(Ce(r)))}var Jr=null;function gc(e){if(!Jr||e.length===0)return null;try{return Jr(e)}catch{return null}}function hc({children:e,postTarget:t}){let[n,o]=uc([]),r=mt([]),s=mt(Number.NEGATIVE_INFINITY),a=mt({at:Number.NEGATIVE_INFINITY,sel:[]}),c=mt(null),u=mt(null),m=Se((E)=>{if(c.current)clearTimeout(c.current);u.current=()=>{c.current=null,u.current=null;let P=t??(typeof window<"u"?window.parent:null);if(!P)return;let K=E.length===0?null:E.length===1?E[0]??null:E;try{P.postMessage({dgn:"select-set",selection:K,...gc(E)},"*")}catch{}},c.current=setTimeout(()=>u.current?.(),pc)},[t]);cc(()=>()=>{if(c.current)clearTimeout(c.current);u.current?.()},[]);let h=Se((E)=>{r.current=E,o(E),m(E)},[m]),f=Se((E)=>{s.current=Date.now(),h(qt(Array.isArray(E)?E:[E]))},[h]),w=Se((E)=>fc(a.current,E),[]),R=Se((E)=>{let P=qt(Array.isArray(E)?E:[E]);if(Zr(s.current,r.current,P))return!1;if(w(P))return!1;return h(P),!0},[h,w]),g=Se((E)=>{let P=Array.isArray(E)?E:[E],K=qt([...r.current,...P]);if(Zr(s.current,r.current,K))return!1;if(w(P))return!1;return h(K),!0},[h,w]),x=Se(()=>r.current,[]),S=Se((E)=>{let P=r.current,K=P.filter(E);if(K.length===P.length)return;a.current={at:Date.now(),sel:P.filter((_)=>!E(_))},h(K)},[h]),y=Se((E)=>{let P=Array.isArray(E)?E:[E];s.current=Date.now(),o((K)=>{let _=qt([...K,...P]);return r.current=_,m(_),_})},[m]),i=Se((E)=>{let P=Ce(E);s.current=Date.now(),o((K)=>{let _=K.filter((B)=>Ce(B)!==P);return r.current=_,m(_),_})},[m]),k=Se((E)=>{let P=Ce(E);s.current=Date.now(),o((K)=>{let _=K.some((B)=>Ce(B)===P)?K.filter((B)=>Ce(B)!==P):[...K,E];return r.current=_,m(_),_})},[m]),A=Se(()=>{s.current=Date.now(),h([])},[h]),q=dc(()=>({selected:n,replace:f,add:y,remove:i,toggle:k,clear:A,replaceFromShell:R,addFromShell:g,peek:x,drop:S}),[n,f,y,i,k,A,R,g,x,S]);return Hn(jt.Provider,{value:q,children:e})}function ts({children:e}){if($n(jt))return Hn(bc,{children:e});return Hn(hc,{children:e})}function Bt(){let e=$n(jt);if(!e)throw Error("useSelectionSet must be used inside <SelectionSetProvider>");return e}function ns(){return $n(jt)}import{jsx as C,jsxs as U,Fragment as Gc}from"react/jsx-runtime";var yc=800,wc=20000,Ke=new Map,gs=0;function vc(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)}`;Ke.get(n)?.(t)}function hs(){if(typeof window>"u")return;window.addEventListener("message",vc)}var bs=()=>typeof window<"u"&&window.parent!==window;function jn(e,t){return new Promise((n)=>{let o=setTimeout(()=>{Ke.delete(e),n(null)},t);Ke.set(e,(r)=>{clearTimeout(o),Ke.delete(e),n(r)})})}async function Be(e){if(!bs())return null;hs();let t=`cm${++gs}`,n=jn(`ack:${t}`,yc),o=jn(`res:${t}`,wc);try{window.parent.postMessage({dgn:"comment-op",reqId:t,op:e},"*")}catch{return Ke.delete(`ack:${t}`),Ke.delete(`res:${t}`),null}if(!await n)return Ke.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 xc(){if(!bs())return null;hs();let e=`cm${++gs}`,t=jn(`res:${e}`,2500);try{window.parent.postMessage({dgn:"comment-people-request",reqId:e},"*")}catch{return Ke.delete(`res:${e}`),null}let n=await t;return Array.isArray(n?.people)?n.people:null}function Xn(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 os(e){let n=Xn(e)?.querySelector(".dc-artboard-label");return(n instanceof HTMLInputElement?n.value:n?.textContent)?.trim()||e}function ys(e){return(e.querySelector(".dc-artboard-body")??e).getBoundingClientRect()}function kc(e,t){if(typeof document>"u")return null;for(let n of document.querySelectorAll("[data-dc-screen]")){let o=ys(n);if(e>=o.left&&e<=o.right&&t>=o.top&&t<=o.bottom)return n.getAttribute("data-dc-screen")}return null}function Yn(e){let t=Xn(e)?.getAttribute("data-dc-print");if(!t)return null;try{return JSON.parse(t)}catch{return null}}function ws(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 Sc(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 rs(e,t,n){let o=e||kc(t,n),r=o?Xn(o):null;if(!o||!r)return{};let s={artboard:o},a=r.getAttribute("data-dc-kind");if(a==="video"){let c=ws(o);if(c!==null)s.t=Math.round(c*1000)/1000}else if(a==="print"){let c=ys(r),u=r.querySelector(".dc-artboard-body"),m=u&&c.width>0?u.offsetWidth/c.width:1,h=Rr(Yn(o),{x:(t-c.left)*(m||1),y:(n-c.top)*(m||1)});if(h)s.mm=h}return s}var Ec="/_client/comments-overlay.css";function Tc(){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=Ec,document.head.appendChild(e)}function Qn(){return Vt()}function Rc(e){if(!e)return"";return e.replace(/<[^>]*>?/g,"").replace(/ /g," ").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/&/g,"&").replace(/\s+/g," ").trim()}var Ac=1500;function ss(e,t){let n=(e.textContent??"").replace(/\s+/g," ").trim();return n===t||t.length>=Ac&&n.startsWith(t)}var Mc=400;function Cc(e,t){if(e.length===0)return null;let n=t.index&&t.index>0&&t.index<e.length?t.index:0,o=e[n]??e[0]??null;if(e.length===1||e.length>Mc)return o;let r=Rc(t.html_excerpt);if(!r||o&&ss(o,r))return o;let s=t.index??0,a=null,c=Number.POSITIVE_INFINITY;for(let u=0;u<e.length;u++){let m=e[u];if(!ss(m,r))continue;let h=Math.abs(u-s);if(h<c)a=m,c=h}return a??o}function Ic(e){if(lt(e.annotationId))return Ct(e.annotationId);if(!e.selector)return null;let t=null;try{t=Cc(document.querySelectorAll(e.selector),e)}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=qr(document,{artboardId:n,tag:e.tag,classes:e.classes,dom_path:e.dom_path})}return t}function Bn(e){let t=Ic(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 vs(e,t,n=pr()){let r=typeof window<"u"?window.innerWidth:e.x+t.w,s=typeof window<"u"?window.innerHeight:e.y+t.h,a=To(r,s,n),c=a.x+8,u=a.y+8,m=a.x+a.w,h=a.y+a.h,f=e.x;if(f+t.w+8>m){let R=e.x-t.w;f=R>=c?R:Math.max(c,m-t.w-8)}if(f<c)f=c;let w=e.y;if(w+t.h+8>h){let R=e.y-t.h;w=R>=u?R:Math.max(u,h-t.h-8)}if(w<u)w=u;return{x:f,y:w}}function xs(){Tc();let e=ns(),[t,n]=ie([]),[o,r]=ie(null),[s,a]=ie(0),[c,u]=ie(null),m=We(()=>Qn(),[]),[h,f]=ie(!1),[w,R]=ie(null),[g,x]=ie(null),S=oe((b)=>{n((T)=>T.some((M)=>M.id===b.id)?T.map((M)=>M.id===b.id?b:M):[...T,b])},[]);pe(()=>{if(typeof document>"u")return;let b=document.getElementById("dgn-pin-layer");if(!b)return;let T=b.style.display;return b.style.display="none",()=>{b.style.display=T}},[]);let y=oe((b)=>{if(!e)return;if(!b?.selector){e.clear();return}let T=b.selector.match(/data-cd-id="([^"]+)"/),M=T?T[1]:void 0,z,Z;try{let ge=document.querySelector(b.selector);if(ge)z=ge.tagName.toLowerCase(),Z=(ge.getAttribute("class")??"").split(/\s+/).filter((O)=>O&&!O.startsWith("dgn-")&&!O.startsWith("dc-cv-")).join(" ")}catch{}e.replace({file:m??void 0,id:M,selector:b.selector,tag:z,classes:Z,bounds:b.bounds??void 0})},[e,m]),i=be(t),k=be(null),A=oe(()=>{let b=k.current;if(!b||typeof document>"u")return;let T=i.current.find((M)=>M.id===b);if(!T)return;k.current=null,le(()=>zc(T))},[]),q=be(new Set);i.current=t,pe(()=>{A()},[t,A]);let E=Gr(),P=qc();pe(()=>{if(!E)return;let b=E.doc.getArray("comments"),T=()=>{n(vr(b.toArray(),q.current))};if(b.length>0)T();return b.observe(T),()=>{try{b.unobserve(T)}catch{}}},[E]),pe(()=>{if(typeof window>"u")return;let b=(T)=>{if(T.source!==window.parent)return;let M=T.data;if(!M||typeof M!=="object"||!M.dgn)return;if(M.dgn==="comments-set"&&Array.isArray(M.comments))q.current=wr(M.comments),n(M.comments);else if(M.dgn==="comment-focus"){let z=typeof M.id==="string"?M.id:null;if(r(z),z&&M.reply===!0)a((ge)=>ge+1);else a(0);let Z=z?i.current.find((ge)=>ge.id===z):void 0;y(Z),k.current=z,A()}};return window.addEventListener("message",b),()=>window.removeEventListener("message",b)},[y]),pe(()=>{if(typeof document>"u")return;let b=(T)=>{let M=T.detail;if(!M?.selection)return;let z=typeof M.clientX==="number"?M.clientX:0,Z=typeof M.clientY==="number"?M.clientY:0;u({selection:M.selection,clientX:z,clientY:Z,anchors:rs(M.selection.artboardId,z,Z)})};return document.addEventListener("cm:open-composer",b),()=>document.removeEventListener("cm:open-composer",b)},[]);let K=oe(()=>{if(u(null),typeof window>"u")return;try{window.parent.postMessage({dgn:"force-clear"},"*")}catch{}},[]),_=oe((b)=>{if(!c)return;let T=c.selection,M={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:b};if(typeof window>"u")return;f(!0),(async()=>{let z=await Be({op:"add",...M,...c.anchors});if(f(!1),z===null){try{window.parent.postMessage({dgn:"comment-submit",payload:M},"*")}catch{}K();return}if(!z.ok){R(z.error??"That did not go through.");return}if(R(null),z.comment)S(z.comment);K()})()},[c,K,S]);pe(()=>{if(!m)return;let b=!1;return(async()=>{try{let T=await fetch(`/_comments?file=${encodeURIComponent(m)}`);if(!T.ok){await T.body?.cancel().catch(()=>{});return}let M=await T.json();if(b)return;if(Array.isArray(M.comments))n((z)=>z.length===0?M.comments??[]:z)}catch{}})(),()=>{b=!0}},[m]);let B=We(()=>[...new Set(t.filter((b)=>typeof b.t==="number"&&b.artboard).map((b)=>b.artboard))],[t]),[Q,G]=ie({});pe(()=>{if(B.length===0)return;let b=()=>{let M={};for(let z of B){let Z=ws(z);M[z]=Z===null?null:Math.round(Z*4)/4}G((z)=>B.every((Z)=>z[Z]===M[Z])?z:M)};b();let T=setInterval(b,125);return()=>clearInterval(T)},[B]);let se=We(()=>t.slice().sort((T,M)=>T.created.localeCompare(M.created)).filter((T)=>T.status!=="resolved"&&(typeof T.t!=="number"||!T.artboard||T.id===o||Tr(T.t,Q[T.artboard]??null))),[t,Q,o]),ee=We(()=>{let b=new Map;return t.slice().sort((M,z)=>M.created.localeCompare(z.created)).forEach((M,z)=>{b.set(M.id,z+1)}),b},[t]),ae=oe((b)=>{if(r(b),y(t.find((T)=>T.id===b)),typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-click",id:b},"*")}catch{}},[t,y]),me=oe((b,T)=>{if(typeof window>"u")return;let M=()=>{try{window.parent.postMessage({dgn:"comment-patch",id:b,patch:T},"*")}catch{}},z=T.status==="resolved"?{op:"resolve",id:b}:T.status==="open"?{op:"reopen",id:b}:typeof T.text==="string"?{op:"edit-own",id:b,text:T.text}:null;if(!z)return M();Be(z).then((Z)=>{if(Z===null)return M();if(!Z.ok)return R(Z.error??"That did not go through.");if(R(null),Z.comment)S(Z.comment)})},[S]),we=oe((b)=>{if(typeof window>"u")return;r((T)=>T===b?null:T),Be({op:"delete-own",id:b}).then((T)=>{if(T===null){try{window.parent.postMessage({dgn:"comment-delete",id:b},"*")}catch{}return}if(!T.ok)return R(T.error??"That did not go through.");R(null),n((M)=>M.filter((z)=>z.id!==b))})},[]),H=oe((b)=>{x(null);let T=rs(b.selection.artboardId,b.clientX,b.clientY);Be(cr(b.id,b.selection,T)).then((M)=>{if(M===null)return R("Re-attaching needs the Maude window.");if(!M.ok)return R(M.error??"That did not go through.");if(R(null),M.comment)S(M.comment);r(b.id)})},[S]);pe(()=>lr(H,()=>x(null)),[H]);let J=oe((b)=>{x(b),sr(b)},[]),X=oe(()=>{x(null),It()},[]),W=oe(async(b,T)=>{if(typeof fetch>"u")return!1;let M=await Be({op:"reply",id:b,body:T});if(M){if(!M.ok)return R(M.error??"That did not go through."),!1;if(R(null),M.comment)S(M.comment);return!0}try{let z=await fetch(`/_api/comments/${encodeURIComponent(b)}/reply`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({body:T})});if(!z.ok)return!1;let Z=await z.json();return n((ge)=>ge.map((O)=>O.id===Z.id?Z:O)),!0}catch{return!1}},[S]);return U("div",{className:"cm-layer","aria-hidden":!1,children:[se.map((b)=>{let T=ee.get(b.id)??0;return C(Vc,{comment:b,sequence:T,focused:o===b.id,viewer:P??E?.myName,onClick:ae},b.id)}),c?C(Fc,{state:c,busy:h,onSubmit:_,onCancel:K}):null,w?U("div",{className:"cm-notice",role:"status","data-testid":"comment-notice",children:[C("span",{children:w}),C("button",{type:"button",className:"cm-notice__x","aria-label":"Dismiss",onClick:()=>R(null),children:"×"})]}):null,g?U("div",{className:"cm-notice",role:"status","data-testid":"comment-reattach-hint",children:[C("span",{children:"Click the element this comment belongs on. Esc to cancel."}),C("button",{type:"button",className:"cm-notice__x","aria-label":"Cancel re-attach",onClick:X,children:"×"})]}):null,(()=>{if(!o||g)return null;let b=se.find((T)=>T.id===o);if(!b)return null;return C(Bc,{comment:b,sequence:ee.get(b.id)??0,onReattach:()=>J(b.id),onClose:()=>{r(null),e?.clear()},onPatch:(T)=>me(b.id,T),onDelete:()=>we(b.id),onReply:(T)=>W(b.id,T),focusReply:s,mine:(!Oe()||Ze())&&(b.mine===!0||!!(P??E?.myName)&&(b.author??"").trim()===(P??E?.myName??"").trim()),me:(P??E?.myName)||void 0})})()]})}var qn=null,as=0,Pc=60000;async function _c(){try{let e=await fetch("/_api/git-committers");if(!e.ok)return[];let t=await e.json();return kr(t.committers)}catch{return[]}}function Lc(){if(!(qn&&Date.now()-as<Pc))as=Date.now(),qn=(async()=>await xc()??await _c())();return qn}function is(e){return br(e)}function Oc(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 ks(e,t){pe(()=>{let n=e.current;if(!n)return;n.style.height="auto",n.style.height=`${Math.min(n.scrollHeight,160)}px`},[e,t])}function Wn({className:e,value:t,onChange:n,onKeyDown:o,placeholder:r,rows:s,disabled:a,textareaRef:c,ariaLabel:u,title:m}){let h=be(null),f=oe((_)=>{if(h.current=_,c)c.current=_},[c]),[w,R]=ie([]),[g,x]=ie(null),[S,y]=ie(0),i=oe(()=>{if(w.length>0)return;Lc().then((_)=>R(_))},[w.length]),k=We(()=>{if(!g)return[];let _=g.query.toLowerCase();return(!_?w:w.filter((Q)=>Q.name.toLowerCase().includes(_))).slice(0,8)},[g,w]),A=oe((_)=>{let B=_.selectionStart??_.value.length,Q=Oc(_.value,B);x(Q),y(0)},[]),q=oe((_)=>{n(_.target.value),A(_.target)},[n,A]),E=oe((_)=>{if(!g)return;let B=h.current;if(!B)return;let Q=`@${is(_.name)}`,G=`${t.slice(0,g.start)}${Q} ${t.slice(g.end)}`;n(G),x(null);let se=g.start+Q.length+1;le(()=>{B.focus(),B.setSelectionRange(se,se)})},[g,t,n]),P=oe((_)=>{if(g&&k.length>0){if(_.key==="ArrowDown"){_.preventDefault(),y((B)=>(B+1)%k.length);return}if(_.key==="ArrowUp"){_.preventDefault(),y((B)=>(B-1+k.length)%k.length);return}if(_.key==="Enter"||_.key==="Tab"){_.preventDefault();let B=k[S]??k[0];if(B)E(B);return}if(_.key==="Escape"){_.preventDefault(),x(null);return}}o?.(_)},[g,k,S,E,o]),K=oe((_)=>{A(_.currentTarget)},[A]);return U("div",{style:{position:"relative"},children:[C("textarea",{ref:f,className:e,value:t,placeholder:r,rows:s,disabled:a,"aria-label":u,title:m,onChange:q,onKeyDown:P,onFocus:i,onSelect:K,onClick:K}),g&&k.length>0?C("ul",{className:"cm-mention-popup",role:"listbox","aria-label":"Mention suggestions",style:{left:0,top:"100%"},children:k.map((_,B)=>U("li",{role:"option","aria-selected":B===S,className:"cm-mention-popup__item",onMouseEnter:()=>y(B),onMouseDown:(G)=>{G.preventDefault(),E(_)},children:[C(Un,{name:_.name}),U("span",{className:"cm-mention-popup__name",children:["@",is(_.name)]}),_.role?C("span",{className:"cm-mention-popup__role",children:_.role}):null]},_.id))}):null]})}var Nc=3000;function Dc(e){return{x:e.x-12,y:e.y-12,w:24,h:24}}function Gn(e){let t=!!e.selector||lt(e.annotationId);if(t){let r=Bn(e);if(r)return{pos:r,missing:!1}}let n=tr(e.world)?or(e.world):null;return{pos:n?Dc(n):e.bounds??null,missing:t}}function Kc(e){let t=e.artboard;if(typeof t==="string"&&t)return t;return e.selector?.match(/data-dc-screen="([^"]+)"/)?.[1]??null}function zc(e){if(typeof document>"u")return;let t={artboard:Kc(e),locate:()=>Gn(e).pos};document.dispatchEvent(new CustomEvent(Sr,{detail:t}))}function Vc({comment:e,sequence:t,focused:n,viewer:o,onClick:r}){let s=be(null),a=be(null),c=be(null),[u,m]=ie(!1),h=be(!1);pe(()=>{let g=()=>{a.current=null;let x=s.current;if(!x)return;let{pos:S,missing:y}=Gn(e),i=!1;if(y){if(c.current==null)c.current=Date.now();i=Date.now()-c.current>Nc}else c.current=null;if(i!==h.current)h.current=i,m(i);if(!S){x.style.display="none",a.current=le(g);return}x.style.display="grid";let k=Math.round(S.x+S.w-14),A=Math.round(S.y-14);x.style.left=`${k}px`,x.style.top=`${A}px`,a.current=le(g)};return a.current=le(g),()=>{if(a.current!=null)Ae(a.current)}},[e]);let f=dt(e.author,Je(e,o)),w=1+(e.thread?.length??0),R=`Comment ${t} by ${f.name}${w>1?`, ${w} messages`:""}${u?" (detached: its target is gone)":""}`;return U("button",{ref:s,type:"button",className:"cm-pin","data-resolved":e.status==="resolved"?"true":"false","data-focused":n?"true":"false","data-detached":u?"true":"false","data-comment-pin":e.id,"aria-label":R,"aria-expanded":n,title:e.text.slice(0,200),"data-seq":t,style:{["--cm-pin-tone"]:Rn(f.tone)},onClick:(g)=>{g.preventDefault(),g.stopPropagation(),r(e.id)},children:[f.letter,w>1?C("span",{className:"cm-pin__n","data-testid":`comment-pin-count-${e.id}`,"aria-hidden":"true",children:w}):null]})}function Fc({state:e,busy:t=!1,paused:n=kn(),onSubmit:o,onCancel:r}){let[s,a]=ie(""),c=be(null);ks(c,s);let u=be(null),m=be(null);fs(()=>{let g=()=>{m.current=null;let x=u.current;if(!x)return;let S=Qc(e),y=vs(S,{w:x.offsetWidth,h:x.offsetHeight});x.style.left=`${Math.round(y.x)}px`,x.style.top=`${Math.round(y.y)}px`,x.dataset.placed="1",m.current=le(g)};return g(),()=>{if(m.current!=null)Ae(m.current)}},[e]),pe(()=>{c.current?.focus()},[]);let h=oe(()=>{let g=s.trim();if(!g||t||n)return;o(g)},[s,t,n,o]),f=oe((g)=>{if(g.key==="Escape"){g.preventDefault(),r();return}if((g.metaKey||g.ctrlKey)&&g.key==="Enter")g.preventDefault(),h()},[r,h]),w=We(()=>Ss({artboard:e.anchors?.artboard,selector:e.selection.selector}),[e.anchors,e.selection]),R=We(()=>{let g=e.anchors;if(!g?.artboard)return null;return _n(g,Pn(Yn(g.artboard))).chip},[e.anchors]);return U("div",{ref:u,className:"cm-composer",role:"dialog","aria-label":"New comment",onClick:(g)=>g.stopPropagation(),onPointerDown:(g)=>g.stopPropagation(),children:[U("div",{className:"cm-composer__head",children:[C("span",{className:"cm-composer__where","data-testid":R?"comment-composer-place":"comment-composer-where",children:w}),C("button",{type:"button",className:"cm-thread__close","data-testid":"comment-composer-cancel","aria-label":"Cancel",title:"Cancel · esc",onClick:r,children:"×"})]}),R?C("span",{className:"cm-chip cm-composer__chip","data-testid":"comment-composer-where",children:R}):null,n?C("p",{className:"cm-composer__paused",role:"status","data-testid":"comment-composer-paused",children:ct}):null,U("div",{className:"cm-composer__field",children:[C(Wn,{textareaRef:c,className:"cm-composer__textarea",value:s,placeholder:"Add a comment — @ mentions someone",onChange:a,onKeyDown:f,rows:1,ariaLabel:"Comment body",disabled:n,title:n?ct:void 0}),C("button",{type:"button",className:"cm-btn cm-btn--primary cm-composer__send","data-testid":"comment-composer-send","aria-label":"Send",title:n?ct:"Send · ⌘↵",disabled:!s.trim()||t||n,onClick:h,children:C("svg",{width:"14",height:"14",viewBox:"0 0 16 16","aria-hidden":"true",children:C("path",{d:"M6 3.5 10.5 8 6 12.5",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]})}function Hc(e){if(e.artboard)return os(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 os(n);let o=t?.getAttribute?.("data-dc-element");if(o)return o.replace(/[-_]+/g," ");return"On the canvas"}function $c(e=Qn()){let t=(e??"").split("/").pop()??"";if(!/\.[a-z0-9]+$/i.test(t))return"";return t.replace(/\.[a-z0-9]+$/i,"").replace(/[-_]+/g," ").trim()}function Ss(e,t=Qn()){let n=Hc(e),o=$c(t);if(!o)return n;return n==="On the canvas"?o:`${o} · ${n}`}var ls=null;function qc(){let[e,t]=ie(null);return pe(()=>{if(typeof fetch>"u")return;ls??=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 ls.then((o)=>n&&t(o)),()=>{n=!1}},[]),e}function jc(e){return!e.annotationId&&typeof e.t!=="number"&&!e.mm}function Bc({comment:e,sequence:t,onClose:n,onPatch:o,onDelete:r,onReply:s,onReattach:a,focusReply:c=0,mine:u=!1,me:m}){let h=be(null),f=be(null),w=be(null),[R,g]=ie("");ks(f,R);let[x,S]=ie(!1),[y,i]=ie(null),k=oe(()=>{let O=(y??"").trim();if(!O)return;if(O!==e.text)o({text:O});i(null)},[y,e.text,o]);fs(()=>{let O=()=>{w.current=null;let te=h.current;if(!te)return;let Ve=Yc(e),go=vs(Ve,{w:te.offsetWidth,h:te.offsetHeight});te.style.left=`${Math.round(go.x)}px`,te.style.top=`${Math.round(go.y)}px`,te.dataset.placed="1",w.current=le(O)};return O(),()=>{if(w.current!=null)Ae(w.current)}},[e]),pe(()=>{h.current?.focus();let O=e.id;return()=>{document.querySelector(`[data-comment-pin="${O}"]`)?.focus()}},[e.id]),pe(()=>{if(c>0)f.current?.focus()},[c,e.id]),pe(()=>{if(typeof document>"u")return;let O=(te)=>{if(te.key!=="Escape")return;let Ve=h.current;if(!Ve)return;if(Ve.contains(te.target)||document.activeElement===Ve)te.preventDefault(),n()};return document.addEventListener("keydown",O),()=>document.removeEventListener("keydown",O)},[n]);let A=oe(async()=>{let O=R.trim();if(!O||x)return;S(!0);let te=await s(O);if(S(!1),te)g(""),f.current?.focus()},[R,x,s]),q=oe((O)=>{if((O.metaKey||O.ctrlKey)&&O.key==="Enter")O.preventDefault(),A()},[A]),E=`cm-thread-head-${e.id}`,P=kn(),K=(!Oe()||Ze())&&!P,_=_n(e,e.artboard?Pn(Yn(e.artboard)):null),B=Ss({artboard:e.artboard,selector:e.selector}),Q=e.from,G=An(e.importedFrom),se=(m??"").trim(),ee=Q?se?(Q.convertedBy??"").trim()===se:u:!1,ae=Q?(e.thread??[]).find((O)=>(O.author??"").trim()!==(se||(Q.convertedBy??"").trim())):void 0,me=ae?`${cs(ae.author??"")||"Someone"} replied — resolve the thread instead.`:null,we=!!Q&&!Oe(),[H,J]=ie(!1),X=!!Q,[W,b]=ie(!1);pe(()=>{if(W)f.current?.focus()},[W]);let[T,M]=ie(null),[z,Z]=ie(!1);pe(()=>{if(!Q||!ee){Z(!1);return}let O=!0;return Be({op:"convert-undoable",commentId:e.id}).then((te)=>{if(O)Z(!!te?.ok)}),()=>{O=!1}},[e.id,Q,ee]);let ge=async(O)=>{J(!1),M(null);let te=await Be({op:O,commentId:e.id});if(te?.ok)n();else M(te?.error||"That did not go through.")};return U("div",{ref:h,className:"cm-thread","data-seq":t,role:"dialog","data-esc-owner":"focus","aria-labelledby":E,tabIndex:-1,onClick:(O)=>O.stopPropagation(),onPointerDown:(O)=>O.stopPropagation(),children:[U("div",{className:"cm-thread__head",id:E,children:[X?null:U("div",{className:"cm-thread__head-row",children:[C("span",{className:"cm-thread__where","data-testid":`comment-where-${e.id}`,children:B}),U("span",{className:"cm-thread__head-end",children:[K?U("span",{className:"cm-thread__actions",children:[a&&jc(e)?C("button",{type:"button",className:"cm-btn","data-testid":`comment-reattach-${e.id}`,"aria-label":"Re-attach to element",title:"Re-attach to element",onClick:a,children:"Re-attach"}):null,u&&y===null&&!G?C("button",{type:"button",className:"cm-btn","data-testid":"comment-edit",onClick:()=>i(e.text),children:"Edit"}):null,e.status==="resolved"?U("button",{type:"button",className:"cm-btn cm-btn--ghost","data-testid":`comment-reopen-${e.id}`,onClick:()=>o({status:"open"}),children:[C(tt,{d:"M3.5 8a4.5 4.5 0 1 0 1.4-3.3M3.5 2.5v2.6h2.6"}),"Reopen"]}):U("button",{type:"button",className:"cm-btn cm-btn--ghost","data-testid":`comment-resolve-${e.id}`,onClick:()=>{o({status:"resolved"}),n()},children:[C(tt,{d:"M3 8.4 6.4 11.8 13 4.6"}),"Resolve"]}),u?C(Xc,{id:e.id,onConfirm:()=>{r(),n()}}):null]}):null,C("button",{type:"button",className:"cm-thread__close","aria-label":"Close thread",title:"Close · esc",onClick:n,children:"×"})]})]}),!X&&_.chip?_.kind==="video"&&typeof e.t==="number"&&e.artboard?C("button",{type:"button",className:"cm-chip cm-chip--seek","data-testid":`comment-chip-${e.id}`,title:"Go to this moment",onClick:()=>Sc(e.artboard,e.t),children:_.chip}):C("span",{className:"cm-chip","data-testid":`comment-chip-${e.id}`,children:_.chip}):null,e.from?U("div",{className:"cm-thread__from","data-testid":`comment-from-${e.id}`,children:[C("svg",{width:"14",height:"14",viewBox:"0 0 16 16","aria-hidden":"true",className:"cm-thread__from-ic",children:C("path",{d:"M3 2.5h10v8l-3 3H3zM10 13.5v-3h3",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinejoin:"round"})}),U("span",{children:[gr(e.from)," · turned into a comment by"," ",ee?"You":cs(e.from.convertedBy||e.author||""),ee&&z&&!me?U(Gc,{children:[" · ",C("button",{type:"button",className:"cm-link","data-testid":`comment-from-undo-${e.id}`,onClick:()=>void ge("convert-undo"),children:"Undo"})]}):null]})]}):null,T?C("div",{className:"cm-thread__convert-line",role:"alert",children:T}):null]}),y===null?U("div",{className:"cm-msg cm-msg--root",children:[G?C(ds,{}):C(Un,{name:e.from?ut(e.from).name:e.author,ai:e.from?ut(e.from).ai:e.authorKind==="ai",viewer:e.from?m:Je(e,m)}),U("div",{className:"cm-msg__main",children:[U("div",{className:"cm-msg__head",children:[C("span",{className:"cm-thread__author","data-testid":G?`comment-imported-${e.id}`:void 0,children:G?Mn(G):e.from?ut(e.from).name:dt(e.author,Je(e,m)).name}),C("span",{className:"cm-thread__time",children:ms(G?.at??e.created)})]}),C("div",{className:"cm-thread__body",children:G?e.text:ps(e.text)}),e.queued?C(us,{id:e.id}):null]})]}):U("div",{className:"cm-thread__reply-form",children:[C(Wn,{className:"cm-thread__reply-textarea",value:y,placeholder:"Edit your comment… ⌘↵ to save",onChange:i,onKeyDown:(O)=>{if((O.metaKey||O.ctrlKey)&&O.key==="Enter")O.preventDefault(),k()},rows:3,ariaLabel:"Edit comment"}),U("div",{className:"cm-thread__reply-actions",children:[C("button",{type:"button",className:"cm-btn",onClick:()=>i(null),children:"Cancel"}),C("button",{type:"button",className:"cm-btn cm-btn--primary","data-testid":"comment-edit-save",disabled:!y.trim(),onClick:k,children:"Save"})]})]}),(e.thread??[]).map((O)=>{let te=An(O.importedFrom);return U("div",{className:"cm-msg cm-thread__reply",children:[te?C(ds,{}):C(Un,{name:O.author,ai:O.authorKind==="ai",viewer:Je(O,m)}),U("div",{className:"cm-msg__main",children:[U("div",{className:"cm-thread__reply-head",children:[C("span",{className:"cm-thread__reply-author",children:te?Mn(te):dt(O.author,Je(O,m)).name}),C("span",{className:"cm-thread__reply-time",children:ms(te?.at??O.created)})]}),C("div",{className:"cm-thread__reply-body",children:te?O.body:ps(O.body)}),O.queued?C(us,{id:O.id}):null]})]},O.id)}),X&&K?U("div",{className:"cm-thread__foot","data-testid":`comment-foot-${e.id}`,children:[e.status==="resolved"?U("button",{type:"button",className:"cm-btn cm-btn--ghost","data-testid":`comment-reopen-${e.id}`,onClick:()=>o({status:"open"}),children:[C(tt,{d:"M3.5 8a4.5 4.5 0 1 0 1.4-3.3M3.5 2.5v2.6h2.6"}),"Reopen"]}):U("button",{type:"button",className:"cm-btn cm-btn--ghost","data-testid":`comment-resolve-${e.id}`,onClick:()=>{o({status:"resolved"}),n()},children:[C(tt,{d:"M3 8.4 6.4 11.8 13 4.6"}),"Resolve"]}),U("span",{className:"cm-thread__more",children:[C("button",{type:"button",className:"cm-btn cm-btn--icon","aria-label":"More","aria-haspopup":"menu","aria-expanded":H,"data-testid":`comment-menu-${e.id}`,onClick:()=>J((O)=>!O),children:"⋯"}),H?U("span",{className:"cm-thread__menu",role:"menu",children:[C("button",{type:"button",role:"menuitem",className:"cm-thread__menu-item","data-testid":`comment-menu-reply-${e.id}`,onClick:()=>{J(!1),b(!0)},children:"Reply…"}),u&&y===null&&!G?C("button",{type:"button",role:"menuitem",className:"cm-thread__menu-item","data-testid":"comment-edit",onClick:()=>{J(!1),i(e.text)},children:"Edit"}):null,we?C("button",{type:"button",role:"menuitem",className:"cm-thread__menu-item","data-testid":`comment-menu-to-sticky-${e.id}`,disabled:!!me,onClick:()=>void ge("to-sticky"),children:"Turn back into a sticky"}):null,u?C("button",{type:"button",role:"menuitem",className:"cm-thread__menu-item cm-thread__menu-item--danger","data-testid":`comment-delete-${e.id}`,onClick:()=>{r(),n()},children:"Delete comment"}):null,me?C("span",{className:"cm-thread__menu-note",children:me}):null]}):null]})]}):null,P&&Ze()?C("p",{className:"cm-thread__paused",role:"status","data-testid":`comment-paused-${e.id}`,children:ct}):null,K&&(!X||W||c>0)&&U("div",{className:"cm-thread__reply-form cm-thread__reply-form--field",children:[C(Wn,{textareaRef:f,className:"cm-thread__reply-textarea",value:R,placeholder:"Reply…",title:"⌘↵ to send · @name to tag",onChange:g,onKeyDown:q,rows:1,ariaLabel:"Reply",disabled:x}),C("div",{className:"cm-thread__reply-actions",children:C("button",{type:"button",className:"cm-btn cm-btn--primary cm-thread__send","aria-label":"Send",title:"Send · ⌘↵",disabled:!R.trim()||x,onClick:()=>void A(),children:C("svg",{width:"14",height:"14",viewBox:"0 0 16 16","aria-hidden":"true",children:C("path",{d:"M6 3.5 10.5 8 6 12.5",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})})})]})]})}function cs(e){return e.trim().split(/\s+/)[0]||e}function ds(){return C("span",{className:"cm-av cm-av--imported","aria-hidden":"true"})}var Wc="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",Uc=4000;function Xc({id:e,onConfirm:t}){let[n,o]=ie(!1);return pe(()=>{if(!n)return;let r=setTimeout(()=>o(!1),Uc);return()=>clearTimeout(r)},[n]),C("button",{type:"button",className:`cm-btn cm-btn--ghost cm-btn--danger cm-btn--trash${n?" is-armed":""}`,"aria-label":n?"Confirm delete comment":"Delete comment",title:n?"Press again to delete":"Delete comment","data-testid":`comment-delete-${e}`,"data-armed":n?"true":void 0,onBlur:()=>o(!1),onKeyDown:(r)=>{if(r.key==="Escape"&&n)r.stopPropagation(),o(!1)},onClick:(r)=>{if(!n)return o(!0);if(r.detail>1)return;o(!1),t()},children:C(tt,{d:Wc})})}function us({id:e}){return U("span",{className:"cm-queued","data-testid":`comment-queued-${e}`,children:[C(tt,{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 tt({d:e}){return C("svg",{width:"13",height:"13",viewBox:"0 0 16 16","aria-hidden":"true",className:"cm-glyph",children:C("path",{d:e,fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Un({name:e,ai:t=!1,viewer:n}){let o=dt(e,n);return C("span",{className:`cm-av${t?" cm-av--ai":""}`,style:t?void 0:{["--cm-av-tone"]:Rn(o.tone)},"aria-hidden":"true",children:t?"AI":o.letter})}function ps(e){if(!e)return null;let t=/(@[\w][\w.-]*)/g;return e.split(t).map((o,r)=>{let s=`${r}:${o}`;if(r%2===1)return C("strong",{"data-mention":"true",children:o},s);return C("span",{children:o},s)})}function ms(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 Yc(e){let{pos:t}=Gn(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 Qc(e){if(e.clientX||e.clientY){let t=e.selection.selector?Bn(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=Bn(e.selection);if(t)return{x:t.x,y:t.y+t.h+8}}return{x:16,y:16}}import{useEffect as cd}from"react";function Zn(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.checkItemFocused?["checkItemFocused"]:[]]),...e.singleKeys===!1?{singleKeys:!1}:{}}}var Wt=["⌃","⌥","⇧","⌘"],Ut={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","-":"−","–":"−"},Es=new Set(["↵","esc","Space","tab","⌫","⌦","←","→","↑","↓","Home","End","PageUp","PageDown"]),Zc={cmd:"⌘",command:"⌘",meta:"⌘",ctrl:"⌃",control:"⌃",alt:"⌥",opt:"⌥",option:"⌥",shift:"⇧"};function Jc(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(Zc[s.toLowerCase()]),""));for(;;){t=t.replace(/^\s+/,"");let r=Wt.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(Ut[o])o=Ut[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 Wt.filter((r)=>n.has(r)).join("")+o}function Ts(e){let t=Jc(e);if(!t)throw Error(`actions/keys: '${e}' is not a key chord`);return t}var ed={Minus:"−",Equal:"=",Slash:"/",Backslash:"\\",BracketLeft:"[",BracketRight:"]",Comma:",",Period:".",Semicolon:";",Quote:"'",Backquote:"`",Space:"Space"};function Jn(e){let t=new Set;if(e.metaKey||e.ctrlKey)t.add("⌘");if(e.altKey)t.add("⌥");let n=e.key??"";if(Ut[n])n=Ut[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]:ed[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)||Es.has(n)||/^F\d/.test(n);if(e.shiftKey&&r)t.add("⇧");return Wt.filter((s)=>t.has(s)).join("")+n}function Rs(e){let{mods:t,key:n}=td(e);if(t.some((o)=>o!=="⇧"))return!1;if(Es.has(n)||/^F\d{1,2}$/.test(n))return!1;return n.length===1}function As(e){return e.includes("⌘")||e.includes("⌃")}function td(e){let t=[],n=e;for(;;){let o=Wt.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 Ms=new Set(["⌘Z","⇧⌘Z","⌘Y","⌘A","⌘C","⌘X","⌘V","⇧⌘V","⌥⇧⌘V","⌘B","⌘I","⌘U","⌘←","⌘→","⌘↑","⌘↓","⇧⌘←","⇧⌘→","⌥←","⌥→","⌘⌫","⌥⌫"].map(Ts)),Hm=new Set(["⌘N","⇧⌘N","⌘T","⌘W","⌘Q","⌘L"].map(Ts));var eo={view:0,comment:1,edit:2,owner:3},Cs=["timeline","selection","tools","global"];function to(e,t){if(!e)return!0;if(e.minRole&&eo[t.role]<eo[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)=>to(n,t)))return!1;return!0}function nd(e,t){return to(e.visible,t)}function Is(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 od(e){return e.inText??(As(e.chord)&&!Ms.has(e.chord))}function rd(e,t){if(t.focus==="text"&&!od(e.binding))return!1;if(t.focus==="modal"&&!e.binding.inModal)return!1;if(e.binding.layer==="timeline"&&t.focus!=="timeline")return!1;return nd(e.action,t)&&to(e.binding.when,t)}function no(e,t,n,o="tap"){if(n.singleKeys===!1&&Rs(t))return null;let r=e.get(t);if(!r?.length)return null;let s=r.filter((a)=>o==="hold"===!!a.binding.hold&&rd(a,n));if(!s.length)return null;for(let a of Cs){let c=s.filter((u)=>u.binding.layer===a);if(c.length)return{action:c[0].action,binding:c[0].binding,ambiguous:c.slice(1)}}return null}function sd(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")||n.every((o)=>o==="text"))}function Ps(e,t,n){return Is(e,(o,r)=>n(o.id)&&sd(r,t))}var Xt=[{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:"artboard.cut",exec:"canvas",enabled:{minRole:"edit",selection:["artboard"]},keys:[{chord:"⌘X",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["artboard"]}}]},{id:"edit.copy-properties",exec:"canvas",visible:{minRole:"comment"},keys:[{chord:"⌥⌘C",layer:"selection",when:{focus:["canvas"],selection:["object"]}},{chord:"⌥⇧⌘C",layer:"selection",when:{focus:["canvas"],selection:["object"]},alias:!0}]},{id:"edit.paste-properties",exec:"canvas",visible:{minRole:"comment"},enabled:{minRole:"edit"},keys:[{chord:"⌥⌘V",layer:"selection",when:{focus:["canvas"],selection:["object"]}},{chord:"⌥⇧⌘V",layer:"selection",when:{focus:["canvas"],selection:["object"]},alias:!0}]},{id:"object.enter",exec:"canvas",keys:[{chord:"↵",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["object"],notFacts:["toolArmed"]}}]},{id:"object.select-parent",exec:"canvas",keys:[{chord:"⇧↵",layer:"selection",when:{focus:["canvas"],selection:["object"]}}]},{id:"object.select-next",exec:"canvas",keys:[{chord:"tab",layer:"selection",when:{focus:["canvas"],mode:["edit"]}}]},{id:"object.select-prev",exec:"canvas",keys:[{chord:"⇧tab",layer:"selection",when:{focus:["canvas"],mode:["edit"]}}]},{id:"object.remove",exec:"canvas",keys:[{chord:"⌫",layer:"selection",when:{focus:["canvas"],selection:["object"]}},{chord:"⇧⌫",layer:"selection",when:{focus:["canvas"],selection:["object"]},alias:!0},{chord:"⌦",layer:"selection",when:{focus:["canvas"],selection:["object"]}},{chord:"⇧⌦",layer:"selection",when:{focus:["canvas"],selection:["object"]},alias:!0}]},{id:"object.nudge",exec:"canvas",keys:[{chord:"←",layer:"selection",when:{focus:["canvas"],selection:["object","artboard"],notFacts:["selectionHasTakes"]}},{chord:"⇧←",layer:"selection",when:{focus:["canvas"],selection:["object","artboard"]},alias:!0},{chord:"→",layer:"selection",when:{focus:["canvas"],selection:["object","artboard"],notFacts:["selectionHasTakes"]}},{chord:"⇧→",layer:"selection",when:{focus:["canvas"],selection:["object","artboard"]},alias:!0},{chord:"↑",layer:"selection",when:{focus:["canvas"],selection:["object","artboard"]}},{chord:"⇧↑",layer:"selection",when:{focus:["canvas"],selection:["object","artboard"]},alias:!0},{chord:"↓",layer:"selection",when:{focus:["canvas"],selection:["object","artboard"]}},{chord:"⇧↓",layer:"selection",when:{focus:["canvas"],selection:["object","artboard"]},alias:!0}]},{id:"object.frame",exec:"canvas",enabled:{minRole:"edit",selection:["object"]},keys:[{chord:"⌥⌘G",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["object"]}},{chord:"⌘G",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["object"]},alias:!0}]},{id:"object.unframe",exec:"canvas",enabled:{minRole:"edit",selection:["object"]},keys:[{chord:"⇧⌘G",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["object"]}}]},{id:"object.bring-front",exec:"canvas",enabled:{minRole:"edit",selection:["object"]},keys:[{chord:"⌘]",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["object"]}}]},{id:"object.bring-forward",exec:"canvas",enabled:{minRole:"edit",selection:["object"]},keys:[{chord:"]",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["object"]}}]},{id:"object.send-backward",exec:"canvas",enabled:{minRole:"edit",selection:["object"]},keys:[{chord:"[",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["object"]}}]},{id:"object.send-back",exec:"canvas",enabled:{minRole:"edit",selection:["object"]},keys:[{chord:"⌘[",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["object"]}}]},{id:"object.lock",exec:"canvas",enabled:{minRole:"edit",selection:["object"]},keys:[{chord:"⇧⌘L",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["object"]}}]},{id:"artboard.duplicate",exec:"canvas",enabled:{minRole:"edit",selection:["artboard"]},keys:[{chord:"⌘D",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["artboard"]}}]},{id:"artboard.trash",exec:"canvas",enabled:{minRole:"edit",selection:["artboard"]},keys:[{chord:"⌫",layer:"selection",when:{focus:["canvas"],selection:["artboard"]}},{chord:"⇧⌫",layer:"selection",when:{focus:["canvas"],selection:["artboard"]},alias:!0},{chord:"⌦",layer:"selection",when:{focus:["canvas"],selection:["artboard"]}},{chord:"⇧⌦",layer:"selection",when:{focus:["canvas"],selection:["artboard"]},alias:!0}]},{id:"ai.ask-selection",exec:"canvas",visible:{minRole:"edit"},enabled:{minRole:"edit",selection:["object"]},keys:[{chord:"⌘/",layer:"selection",when:{focus:["canvas"],mode:["edit"],selection:["object"]}}]},{id:"inspect.edit",exec:"canvas",enabled:{minRole:"edit",mode:["preview","viewing"],selection:["object"]},keys:[{chord:"↵",layer:"selection",when:{focus:["canvas"],mode:["preview","viewing"],selection:["object"]}}]},{id:"mode.preview",exec:"canvas",enabled:{notFacts:["pagesView"]},keys:[{chord:"⌥⌘P",layer:"global",inText:!0,when:{mode:["edit","preview","viewing"]}}]},{id:"view.panels",exec:"shell",fromCanvas:!0,keys:[{chord:"⌘\\",layer:"global",inText:!0}]},{id:"view.comments",exec:"shell",fromCanvas:!0,keys:[{chord:"⇧⌘M",layer:"global",inText:!0}]},{id:"history.open",exec:"shell",fromCanvas:!0,keys:[{chord:"⌥⌘H",layer:"global",inText:!0}]},{id:"view.inspector",exec:"shell",fromCanvas:!0,keys:[{chord:"⇧⌘I",layer:"global",inText:!0}]},{id:"view.timeline-keep-open",exec:"shell",fromCanvas:!0,keys:[{chord:"⇧⌘T",layer:"global",inText:!0}]},{id:"view.annotations",exec:"canvas",keys:[{chord:"⇧P",layer:"global",inText:!1,when:{focus:["canvas"]}}]},{id:"present.from-selection",exec:"shell",enabled:{notFacts:["pagesView"]},fromCanvas:!0,keys:[{chord:"⌥⌘↵",layer:"global",when:{mode:["edit","viewing","preview"]}}]},{id:"present.from-start",exec:"shell",enabled:{notFacts:["pagesView"]},fromCanvas:!0,keys:[{chord:"⌥⇧⌘↵",layer:"global",when:{mode:["edit","viewing","preview"]}}]},{id:"present.next",exec:"shell",keys:[{chord:"→",layer:"global",when:{mode:["present"]}},{chord:"Space",layer:"global",when:{mode:["present"]}}]},{id:"present.prev",exec:"shell",keys:[{chord:"←",layer:"global",when:{mode:["present"]}},{chord:"⇧Space",layer:"global",when:{mode:["present"]}}]},{id:"view.zoom-in",exec:"canvas",keys:[{chord:"⌘=",layer:"global",inText:!0,when:{focus:["canvas","text"]}},{chord:"⌘+",layer:"global",inText:!0,alias:!0,when:{focus:["canvas","text"]}}]},{id:"view.zoom-out",exec:"canvas",keys:[{chord:"⌘−",layer:"global",inText:!0,when:{focus:["canvas","text"]}}]},{id:"view.zoom-fit",exec:"canvas",keys:[{chord:"⌘0",layer:"global",inText:!0,when:{focus:["canvas","text"]}}]},{id:"view.zoom-actual",exec:"canvas",keys:[{chord:"⇧0",layer:"global",inText:!1,when:{focus:["canvas","text"]}}]},{id:"view.jump-artboard",exec:"canvas",keys:[{chord:"⌥⌘1",layer:"global",inText:!0,alias:!1,when:{focus:["canvas","text"]}},{chord:"⌥⌘2",layer:"global",inText:!0,alias:!0,when:{focus:["canvas","text"]}},{chord:"⌥⌘3",layer:"global",inText:!0,alias:!0,when:{focus:["canvas","text"]}},{chord:"⌥⌘4",layer:"global",inText:!0,alias:!0,when:{focus:["canvas","text"]}},{chord:"⌥⌘5",layer:"global",inText:!0,alias:!0,when:{focus:["canvas","text"]}},{chord:"⌥⌘6",layer:"global",inText:!0,alias:!0,when:{focus:["canvas","text"]}},{chord:"⌥⌘7",layer:"global",inText:!0,alias:!0,when:{focus:["canvas","text"]}},{chord:"⌥⌘8",layer:"global",inText:!0,alias:!0,when:{focus:["canvas","text"]}},{chord:"⌥⌘9",layer:"global",inText:!0,alias:!0,when:{focus:["canvas","text"]}}]},{id:"pages.next",exec:"canvas",enabled:{facts:["canvasOpen","pagesView"]},keys:[{chord:"PageDown",layer:"global",when:{focus:["canvas"],mode:["edit","viewing"]}},{chord:"→",layer:"global",alias:!0,when:{focus:["canvas"],mode:["edit","viewing"],selection:["none"]}}]},{id:"pages.prev",exec:"canvas",enabled:{facts:["canvasOpen","pagesView"]},keys:[{chord:"PageUp",layer:"global",when:{focus:["canvas"],mode:["edit","viewing"]}},{chord:"←",layer:"global",alias:!0,when:{focus:["canvas"],mode:["edit","viewing"],selection:["none"]}}]},{id:"tool.select",exec:"canvas",keys:[{chord:"V",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit"]}}]},{id:"tool.hand",exec:"canvas",keys:[{chord:"H",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit","preview"]}}]},{id:"tool.frame",exec:"canvas",keys:[{chord:"F",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit","preview","viewing"]}}]},{id:"tool.el-shape",exec:"canvas",keys:[{chord:"R",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit"]}}]},{id:"tool.el-pen",exec:"canvas",keys:[{chord:"P",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit","preview","viewing"]}}]},{id:"tool.el-text",exec:"canvas",keys:[{chord:"T",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit"]}}]},{id:"tool.image",exec:"canvas",keys:[{chord:"I",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit","preview","viewing"]}}]},{id:"tool.components",exec:"canvas",keys:[{chord:"⇧I",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit","preview","viewing"]}}]},{id:"tool.browse",exec:"canvas",keys:[{chord:"V",layer:"tools",when:{focus:["canvas","chrome"],mode:["preview","viewing"]}}]},{id:"tool.sticky",exec:"canvas",keys:[{chord:"N",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit","preview","viewing"]}}]},{id:"tool.comment",exec:"canvas",keys:[{chord:"C",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit","preview","viewing"]}}]},{id:"tool.pen",exec:"canvas",keys:[{chord:"M",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit","preview","viewing"]}}]},{id:"tool.arrow",exec:"canvas",keys:[{chord:"A",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit","preview","viewing"]}}]},{id:"tool.shape",exec:"canvas",keys:[{chord:"R",layer:"tools",when:{focus:["canvas","chrome"],mode:["preview","viewing"]}}]},{id:"tool.text",exec:"canvas",keys:[{chord:"T",layer:"tools",when:{focus:["canvas","chrome"],mode:["preview","viewing"]}}]},{id:"tool.stickers",exec:"canvas",keys:[{chord:"E",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit","preview","viewing"]}}]},{id:"tool.section",exec:"canvas",keys:[{chord:"S",layer:"tools",when:{focus:["canvas","chrome"],mode:["edit","preview","viewing"]}}]},{id:"tool.inspect",exec:"canvas",keys:[{chord:"H",layer:"tools",when:{focus:["canvas","chrome"],mode:["viewing"]}}]},{id:"tool.pointer",exec:"canvas",keys:[{chord:"L",layer:"tools",when:{focus:["canvas","chrome"],mode:["present"]}}]},{id:"tool.hand-hold",exec:"canvas",keys:[{chord:"Space",layer:"tools",hold:!0,when:{focus:["canvas"]}},{chord:"⌥Space",layer:"tools",hold:!0,when:{focus:["canvas"]},alias:!0},{chord:"⇧Space",layer:"tools",hold:!0,when:{focus:["canvas"]},alias:!0},{chord:"⌥⇧Space",layer:"tools",hold:!0,when:{focus:["canvas"]},alias:!0},{chord:"⌘Space",layer:"tools",hold:!0,when:{focus:["canvas"]},alias:!0},{chord:"⌥⌘Space",layer:"tools",hold:!0,when:{focus:["canvas"]},alias:!0},{chord:"⇧⌘Space",layer:"tools",hold:!0,when:{focus:["canvas"]},alias:!0},{chord:"⌥⇧⌘Space",layer:"tools",hold:!0,when:{focus:["canvas"]},alias:!0}]},{id:"tool.create-default",exec:"canvas",enabled:{minRole:"edit"},keys:[{chord:"↵",layer:"tools",when:{focus:["canvas"],mode:["edit","preview"],facts:["toolArmed"]}}]},{id:"ui.step-back",exec:"shell",keys:[{chord:"esc",layer:"selection",inText:!1,when:{focus:["canvas"]}},{chord:"⌥esc",layer:"selection",inText:!1,when:{focus:["canvas"]},alias:!0},{chord:"⇧esc",layer:"selection",inText:!1,when:{focus:["canvas"]},alias:!0},{chord:"⌥⇧esc",layer:"selection",inText:!1,when:{focus:["canvas"]},alias:!0},{chord:"⌘esc",layer:"selection",inText:!1,when:{focus:["canvas"]},alias:!0},{chord:"⌥⌘esc",layer:"selection",inText:!1,when:{focus:["canvas"]},alias:!0},{chord:"⇧⌘esc",layer:"selection",inText:!1,when:{focus:["canvas"]},alias:!0},{chord:"⌥⇧⌘esc",layer:"selection",inText:!1,when:{focus:["canvas"]},alias:!0}]},{id:"ui.cycle-region",exec:"shell",fromCanvas:!0,keys:[{chord:"F6",layer:"global",inText:!0},{chord:"⇧F6",layer:"global",inText:!0,alias:!0}]},{id:"timeline.split",exec:"shell",keys:[{chord:"⌘B",layer:"global",when:{facts:["timelineVisible"]},inText:!1,alias:!0}]},{id:"export.open",exec:"shell",visible:{minRole:"comment"},fromCanvas:!0,keys:[{chord:"⇧⌘E",layer:"global",inText:!0}]},{id:"export.copy-png",exec:"shell",visible:{minRole:"comment"},enabled:{facts:["canvasOpen"]},fromCanvas:!0,keys:[{chord:"⇧⌘C",layer:"selection",inText:!1,when:{selection:["artboard","object","video-artboard","generated-image"]}}]},{id:"handoff.open",exec:"shell",visible:{minRole:"comment"},enabled:{minRole:"edit",facts:["canvasOpen"]},fromCanvas:!0,keys:[{chord:"⇧⌘H",layer:"global",inText:!0}]},{id:"settings.open",exec:"shell",fromCanvas:!0,keys:[{chord:"⌘,",layer:"global",inText:!0,when:{focus:["chrome","timeline","text","canvas"]}}]},{id:"help.shortcuts",exec:"shell",fromCanvas:!0,keys:[{chord:"?",layer:"global",inText:!1,when:{focus:["chrome","timeline","canvas"],notFacts:["rangeFocused"]}},{chord:"⌘?",layer:"global",inText:!1,alias:!0,when:{focus:["chrome","timeline","canvas"],notFacts:["rangeFocused"]}}]},{id:"annotation.group",exec:"canvas",keys:[{chord:"⌘G",layer:"selection",when:{focus:["canvas"],selection:["annotation"],mode:["preview"]}}]},{id:"annotation.ungroup",exec:"canvas",keys:[{chord:"⇧⌘G",layer:"selection",when:{focus:["canvas"],selection:["annotation"],mode:["preview"]}}]},{id:"annotation.lock",exec:"canvas",keys:[{chord:"⇧⌘L",layer:"selection",when:{focus:["canvas"],selection:["annotation"],mode:["preview"]}}]},{id:"annotation.duplicate",exec:"canvas",keys:[{chord:"⌘D",layer:"selection",when:{focus:["canvas"],selection:["annotation"]}}]},{id:"annotation.to-front",exec:"canvas",keys:[{chord:"]",layer:"selection",when:{focus:["canvas"],selection:["annotation"],mode:["preview"]}}]},{id:"annotation.forward",exec:"canvas",keys:[{chord:"⌘]",layer:"selection",when:{focus:["canvas"],selection:["annotation"],mode:["preview"]}}]},{id:"annotation.to-back",exec:"canvas",keys:[{chord:"[",layer:"selection",when:{focus:["canvas"],selection:["annotation"],mode:["preview"]}}]},{id:"annotation.backward",exec:"canvas",keys:[{chord:"⌘[",layer:"selection",when:{focus:["canvas"],selection:["annotation"],mode:["preview"]}}]},{id:"annotation.copy",exec:"canvas",keys:[{chord:"⌘C",layer:"selection",when:{focus:["canvas"],selection:["annotation"]}}]},{id:"annotation.cut",exec:"canvas",keys:[{chord:"⌘X",layer:"selection",when:{focus:["canvas"],selection:["annotation"]}}]},{id:"annotation.chain",exec:"canvas",keys:[{chord:"⌘↵",layer:"selection",when:{focus:["canvas"],selection:["annotation"]}}]},{id:"annotation.edit-text",exec:"canvas",keys:[{chord:"↵",layer:"selection",when:{focus:["canvas"],selection:["annotation"],notFacts:["checkItemFocused"]}}]},{id:"annotation.nudge",exec:"canvas",keys:[{chord:"←",layer:"selection",when:{focus:["canvas"],selection:["annotation"],notFacts:["checkItemFocused"]}},{chord:"⇧←",layer:"selection",when:{focus:["canvas"],selection:["annotation"],notFacts:["checkItemFocused"]},alias:!0},{chord:"→",layer:"selection",when:{focus:["canvas"],selection:["annotation"],notFacts:["checkItemFocused"]}},{chord:"⇧→",layer:"selection",when:{focus:["canvas"],selection:["annotation"],notFacts:["checkItemFocused"]},alias:!0},{chord:"↑",layer:"selection",when:{focus:["canvas"],selection:["annotation"],notFacts:["checkItemFocused"]}},{chord:"⇧↑",layer:"selection",when:{focus:["canvas"],selection:["annotation"],notFacts:["checkItemFocused"]},alias:!0},{chord:"↓",layer:"selection",when:{focus:["canvas"],selection:["annotation"],notFacts:["checkItemFocused"]}},{chord:"⇧↓",layer:"selection",when:{focus:["canvas"],selection:["annotation"],notFacts:["checkItemFocused"]},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:"checklist.toggle",exec:"canvas",enabled:{minRole:"edit",selection:["annotation"]},keys:[{chord:"Space",layer:"selection",when:{focus:["canvas"],selection:["annotation"],facts:["checkItemFocused"]}},{chord:"⌘↵",layer:"selection",when:{focus:["text"],selection:["annotation"],facts:["checkItemFocused"]},inText:!0}]},{id:"checklist.edit",exec:"canvas",enabled:{minRole:"edit",selection:["annotation"]},keys:[{chord:"↵",layer:"selection",when:{focus:["canvas"],selection:["annotation"],facts:["checkItemFocused"]}}]},{id:"checklist.add-below",exec:"canvas",enabled:{minRole:"edit",selection:["annotation"]},keys:[{chord:"↵",layer:"selection",when:{focus:["text"],selection:["annotation"],facts:["checkItemFocused"]},inText:!0}]},{id:"checklist.remove-empty",exec:"canvas",enabled:{minRole:"edit",selection:["annotation"]},keys:[{chord:"⌫",layer:"selection",when:{focus:["text"],selection:["annotation"],facts:["checkItemFocused"]},inText:!0}]},{id:"checklist.move-up",exec:"canvas",enabled:{minRole:"edit",selection:["annotation"]},keys:[{chord:"⌥⌘↑",layer:"selection",when:{focus:["canvas","text"],selection:["annotation"],facts:["checkItemFocused"]},inText:!0}]},{id:"checklist.move-down",exec:"canvas",enabled:{minRole:"edit",selection:["annotation"]},keys:[{chord:"⌥⌘↓",layer:"selection",when:{focus:["canvas","text"],selection:["annotation"],facts:["checkItemFocused"]},inText:!0}]},{id:"checklist.focus-prev",exec:"canvas",enabled:{minRole:"edit",selection:["annotation"]},keys:[{chord:"↑",layer:"selection",when:{focus:["canvas"],selection:["annotation"],facts:["checkItemFocused"]}}]},{id:"checklist.focus-next",exec:"canvas",enabled:{minRole:"edit",selection:["annotation"]},keys:[{chord:"↓",layer:"selection",when:{focus:["canvas"],selection:["annotation"],facts:["checkItemFocused"]}}]},{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 _s(e){let t=new Set(e);return Ps(Xt,"canvas",(n)=>t.has(n))}var of=Object.freeze({edit:["stroke","selection","tool"],preview:["stroke","tool","selection"],viewing:["stroke","tool","selection"],present:[]}),rf=Object.freeze({edit:"stay",preview:"stay",viewing:"stay",present:"back"}),Ls="data-esc-owner";function Os(e){let t=e?.querySelectorAll?.(`[${Ls}]`);if(!t)return!1;for(let n of Array.from(t)){if(n.getAttribute(Ls)!=="focus")return!0;let o=e?.activeElement??null;if(o&&(n===o||n.contains(o)))return!0}return!1}var ad=["pen","highlighter","eraser"],id=Symbol.for("maude.markerTip.v2"),ld=(e)=>typeof e==="string"&&ad.includes(e);function Ns(){let e=globalThis[id];return ld(e)?e:"pen"}function Ds(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 oo(e,t){let n=null;if(t){let o=Ds(t.getBoundingClientRect());n=o.w>0&&o.h>0?o:null}return{dgn:"tool-panel-open",panel:e,anchor:n}}var Ks=!1,zs=!1;function ro(e=globalThis.document){if(Ks=!0,zs||!e)return;zs=!0,e.addEventListener("pointerdown",()=>{Ks=!1},!0)}function Vs(e,t){try{if(typeof window>"u"||window.parent===window)return;ro(),window.parent.postMessage(oo(e,t),"*")}catch{}}function Fs(e,t){return t==="section"&&e!=="section"?"templates":null}var dd=new Set(["pen","highlighter","shape","rect","ellipse","arrow","sticky","text","el-text","frame","el-shape","line","polygon","slice","el-pen","section","eraser"]);function Xs(e){return dd.has(e)}var Ys={"ui.step-back":{kind:"escape"},"edit.undo":{kind:"undo"},"edit.redo":{kind:"redo"}},ud=_s(Xt.filter((e)=>e.id.startsWith("tool.")&&e.id!=="tool.hand-hold"||e.id==="mode.preview").map((e)=>e.id).concat(Object.keys(Ys))),pd=new Set([...on,"el-text","frame","el-shape","ellipse","line","polygon","slice","el-pen","crop","inspect"]),Hs=(e)=>So(e,(t)=>pd.has(t));function md(e,t,n){let o=!!n.mode;if(!o&&e==="V")return{kind:"tool",tool:"move"};let r=Eo(t,e,n.caps??wo,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=Hs(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=Hs(r.tool??st[r.mode].rest);return s?{kind:"tool",tool:s}:{kind:"no-op"}}function fd(e){let t=Jn({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=no(ud,t,Zn({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 md(r.binding.chord,o,e);let a=Ys[s];if(!a)return{kind:"no-op"};if(a.kind==="escape"&&n&&!Sn()){if(ln(n,e.activeTool)==="back")return{kind:"escape",back:!0};if(dr())return{kind:"escape",back:!0}}return{...a}}var ft=(e)=>!!(e.metaKey||e.ctrlKey);function $s(e){if(!Xs(e.activeTool))return!1;return!e.mode||yt(e.mode,"annotations-editable")}function gt(e){if(e.type==="keydown")return fd(e);if(e.type==="contextmenu")return{kind:"context-menu",clientX:e.clientX??0,clientY:e.clientY??0};if(e.type==="pointermove"){if($s(e))return{kind:"no-op"};if(e.activeTool==="hand")return{kind:"no-op"};if(e.activeTool==="browse"){if(!ft(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:ft(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($s(e)&&!ft(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(!ft(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=ft(e);return{kind:"select",mode:!!e.shiftKey?"add":"replace",deep:t,clientX:e.clientX??0,clientY:e.clientY??0}}return{kind:"no-op"}}function Yt(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 ht(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 Qs(e){if(!e||typeof e.closest!=="function")return!1;let t=e;return!!t.closest("[data-dc-screen]")&&!t.closest(".dc-artboard-body")}function qs(e,t){if(!t||!yt(t,"live-design")||!e||typeof e.closest!=="function")return!1;return!!e.closest("button.dc-artboard-label")}function js(e,t,n){return e.kind==="select"&&!n.metaKey&&!n.ctrlKey&&(Qs(t)||gd(t,n.clientX,n.clientY))}function gd(e,t,n){if(!e||typeof e.closest!=="function")return!1;let o=e;if(!o.closest(".dc-artboard-body")||typeof t!=="number"||typeof n!=="number")return!1;let r=Qt(o.ownerDocument,t,n,{deep:!1});return!!r&&r.cdId===null&&r.el.hasAttribute("data-dc-screen")}function hd(e,t,n){return e==="select"&&!n.metaKey&&!n.ctrlKey&&Qs(t)}var bd="maude:toolbar-insert",yd=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,wd=/^[A-Za-z0-9_-]{1,64}$/;function vd(e,t){if(!yt(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||!yd.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&&wd.test(r)?r:null}}var Bs=new WeakSet;function xd(e){if(typeof window>"u"||window.parent===window)return!1;let t=vd(e.target,{mode:Me(window).get()?.mode??null,button:e.button,mod:e.metaKey||e.ctrlKey,shift:e.shiftKey});if(!t)return!1;if(e.preventDefault(),Bs.has(e))return!0;Bs.add(e);try{window.parent.postMessage({dgn:"link-follow",elementId:t.elementId,artboardId:t.artboardId},"*")}catch{}return!0}function Ws(e){if(typeof window>"u"||window.parent===window)return;if(!Me(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 Us(e){if(typeof window>"u"||window.parent===window)return;try{let t=document.querySelector(`[data-testid="toolbar-slot-${e}"]`);ro(),window.parent.postMessage(oo(e,t),"*")}catch{}}function Gs(e){let{hostRef:t,getActiveTool:n,isSpaceHeld:o,callbacks:r,enabled:s=!0,claimableActions:a}=e;cd(()=>{if(!s)return;let c=t.current;if(!c)return;let u=(i)=>a&&i.kind!=="no-op"&&!a.has(i.kind)?{kind:"no-op"}:i,m=(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 k=r.onEscape?.();if(i.back&&k!==!0)Ws({mode:"back",cause:"esc"});break}case"mode-request":if(Ws(i),i.panel)Us(i.panel);break;case"insert":if(typeof document<"u")document.dispatchEvent(new CustomEvent(bd,{detail:{kind:i.insert}}));break;case"panel":Us(i.panel);break;case"undo":r.onUndo?.();break;case"redo":r.onRedo?.();break;case"no-op":break}},h=()=>typeof window<"u"?Me(window).get().mode:null,f=(i)=>{let k=u(gt({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()}));m(k)},w=(i)=>{if(ht(i.target))return;if(Yt(i.target))return;let k=u(gt({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:qs(i.target,h())})),A=js(k,i.target,i)||k.kind==="select"&&n()==="inspect";if(k.kind!=="no-op"){if(i.preventDefault(),!A)i.stopImmediatePropagation()}m(k)},R=(i)=>{if(ht(i.target))return;if(Yt(i.target))return;let k=u(gt({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:qs(i.target,h())})),A=js(k,i.target,i);if(k.kind!=="no-op"){if(i.preventDefault(),!A)i.stopImmediatePropagation();if(k.kind==="select")try{window.focus()}catch{}}},g=(i)=>{if(ht(i.target))return;if(Yt(i.target))return;if(xd(i))return;let k=n(),A=i.metaKey||i.ctrlKey,q=k==="comment"?"drop-comment":(k==="move"||k==="inspect")&&i.button===0?"select":(Xs(k)||k==="browse")&&A&&i.button===0?"select":i.button===2?"context-menu":null;if(q&&(!a||a.has(q))){let E=hd(q,i.target,i);if(i.preventDefault(),!E)i.stopImmediatePropagation()}},x=(i)=>{let k=u(gt({type:"contextmenu",clientX:i.clientX,clientY:i.clientY,metaKey:i.metaKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,altKey:i.altKey,activeTool:n()}));if(k.kind==="no-op")return;i.preventDefault(),i.stopImmediatePropagation(),m(k)},S=(i)=>{let k=typeof window<"u"?Me(window).get():null,A=u(gt({type:"keydown",key:i.key,code:i.code,metaKey:i.metaKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,altKey:i.altKey,isEditable:Yt(i.target),activeTool:n(),mode:k?.mode??null,caps:k?.caps??null,markerTip:Ns(),singleKeys:k?.singleKeys??!0}));if(A.kind==="escape"&&Os(c.ownerDocument??document))return;if(A.kind==="tool"||A.kind==="mode-request"||A.kind==="insert"||A.kind==="panel"||A.kind==="escape"&&!Sn()||A.kind==="undo"||A.kind==="redo")i.preventDefault();m(A)};c.addEventListener("pointermove",f,{passive:!0}),c.addEventListener("pointerdown",w,{capture:!0}),c.addEventListener("mousedown",R,{capture:!0}),c.addEventListener("click",g,{capture:!0}),c.addEventListener("contextmenu",x,{capture:!0});let y=c.ownerDocument??document;return y.addEventListener("keydown",S,!0),()=>{c.removeEventListener("pointermove",f),c.removeEventListener("pointerdown",w,{capture:!0}),c.removeEventListener("mousedown",R,{capture:!0}),c.removeEventListener("click",g,{capture:!0}),c.removeEventListener("contextmenu",x,{capture:!0}),y.removeEventListener("keydown",S,!0)}},[s,t,n,o,r,a])}function kd(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 Qt(e,t,n,o){let r=e.elementFromPoint(t,n);if(!r)return null;if(r.closest?.(".dc-mm, .dc-zoom-tb, .dc-tool-palette, .dc-context-menu, .dc-cv-group-bbox"))return null;let s=r.closest?.("[data-dc-screen]")??null,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 R=r.getAttribute?.("data-cd-id")??null;return{el:r,cdId:R,artboardId:a}}let u=r,m=null,h=null;while(u&&u!==c){if(u.hasAttribute?.("data-cd-id"))h=m,m=u;u=u.parentElement}if(m&&kd(c)===m){if(!h)return s&&a?{el:s,cdId:null,artboardId:a}:null;m=h}let f=m??r,w=f.getAttribute?.("data-cd-id")??null;return{el:f,cdId:w,artboardId:a}}import{useCallback as Dd,useEffect as la,useRef as en}from"react";var Sd=!1;function Zs(){return Sd}import{createContext as Id,useCallback as Xe,useContext as aa,useEffect as bt,useMemo as na,useRef as ze,useState as Gt}from"react";function _e(e,t,n,o){return`url("data:image/svg+xml,${encodeURIComponent(e.trim())}") ${t} ${n}, ${o}`}var ao="width='24' height='24' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'",io="#1f1f1f",so="stroke='#ffffff' stroke-linejoin='round' stroke-linecap='round'";function Ue(e,t,n){let o=n?`<g transform='${n}'>`:"";return`<svg ${ao}>${o}<path fill='#ffffff' d='${e}'/><path fill='${io}' d='${t}'/>${n?"</g>":""}</svg>`}var ta="translate(0,32) scale(1,-1)",Js=_e(Ue("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"),Ed=_e(Ue("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"),Td=_e(Ue("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"),Rd=_e(Ue("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",ta),6,18,"crosshair"),Ad=_e(Ue("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",ta),6,18,"crosshair"),Ee=_e(Ue("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"),Md=_e(Ue("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"),ea=_e(`<svg ${ao}><path d='M16 4V28M11 4H21M11 28H21' fill='none' ${so} stroke-width='5'/><path d='M16 4V28M11 4H21M11 28H21' fill='none' stroke='${io}' stroke-width='2.25' stroke-linecap='round'/></svg>`,12,12,"text"),Cd=_e(`<svg ${ao}><path d='M6 5H21L26 10V27H6Z' fill='${io}' ${so} stroke-width='2.5'/><path d='M21 5V11H26' fill='none' ${so} stroke-width='2.25'/></svg>`,5,5,"crosshair"),re=Object.freeze({browse:"default",move:Js,inspect:Js,hand:Ed,comment:Td,pen:Rd,section:Ee,highlighter:Ad,shape:Ee,rect:Ee,ellipse:Ee,sticky:Cd,arrow:Ee,text:ea,"el-text":ea,frame:Ee,"el-shape":Ee,line:Ee,polygon:Ee,slice:Ee,"el-pen":Ee,crop:Ee,eraser:Md});import{jsx as lo,Fragment as Nd}from"react/jsx-runtime";function oa(e,t){if(typeof window>"u"||window.parent===window)return;if(!Me(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 Zt="maude:tool-sync",ra=Object.freeze({preview:"browse",edit:"move"});function sa(e){if(e==="browse")return"preview";if(e==="move")return"edit";return null}var Pd=Object.freeze([{id:"browse",label:"Browse",shortcut:"",cursor:re.browse},{id:"move",label:"Select",shortcut:"V",cursor:re.move},{id:"inspect",label:"Inspect",shortcut:"",cursor:re.inspect},{id:"hand",label:"Hand",shortcut:"H",cursor:re.hand},{id:"comment",label:"Comment",shortcut:"C",cursor:re.comment},{id:"pen",label:"Pen",shortcut:"B",cursor:re.pen},{id:"highlighter",label:"Highlighter",shortcut:"I",cursor:re.highlighter},{id:"shape",label:"Shape",shortcut:"R",cursor:re.shape},{id:"sticky",label:"Sticky",shortcut:"N",cursor:re.sticky},{id:"section",label:"Section",shortcut:"⇧S",cursor:re.shape},{id:"arrow",label:"Arrow",shortcut:"A",cursor:re.arrow},{id:"text",label:"Text",shortcut:"T",cursor:re.text},{id:"el-text",label:"Text",shortcut:"T",cursor:re["el-text"]},{id:"frame",label:"Frame",shortcut:"F",cursor:re.frame},{id:"el-shape",label:"Shape",shortcut:"R",cursor:re["el-shape"]},{id:"ellipse",label:"Ellipse",shortcut:"",cursor:re.ellipse},{id:"line",label:"Line",shortcut:"",cursor:re.line},{id:"polygon",label:"Polygon",shortcut:"",cursor:re.polygon},{id:"slice",label:"Export area",shortcut:"",cursor:re.slice},{id:"el-pen",label:"Pen",shortcut:"P",cursor:re["el-pen"]},{id:"crop",label:"Crop",shortcut:"",cursor:re.crop},{id:"eraser",label:"Eraser",shortcut:"E",cursor:re.eraser}]),_d=new Set(["browse","move","hand","inspect"]);function Ld(e,t,n=!1){return t?e.filter((o)=>_d.has(o.id)||n&&o.id==="comment"):e}var co=Id(null);function Od({children:e,tools:t=Pd,initial:n,initialMode:o,governed:r=!1}){let s=Oe(),a=s&&Ze(),c=na(()=>Ld(t,s,a),[t,s,a]),u=n??(s?"browse":"move"),m=o??sa(u)??(s?"preview":"edit"),[h,f]=Gt(u),w=ze(u),R=Xe((H)=>{w.current=H,f(H)},[]),g=Xe(()=>w.current,[]),[x,S]=Gt(m),[y,i]=Gt(()=>({tool:null,locked:!1})),k=ze(null),A=Xe((H)=>{if(!c.some((W)=>W.id===H))return;let J=k.current;if(J){let W=at(H,J.caps,J.mode);if(W&&W!==J.mode){if(J.mode!=="present")oa(W,H);return}R(H),i((b)=>b.locked&&b.tool===H?b:{tool:null,locked:!1});return}R(H);let X=sa(H);if(X)S(X);i((W)=>W.locked&&W.tool===H?W:{tool:null,locked:!1})},[c]),q=Xe((H)=>{let J=k.current;if(J){oa(H==="edit"?vo(J.caps):"preview");return}let X=ra[H];if(!c.some((W)=>W.id===X))return;S(H),R(X),i((W)=>W.locked&&W.tool===X?W:{tool:null,locked:!1})},[c]),E=Xe(()=>{let H=k.current;A(H?sn[H.mode]:ra[x])},[x,A]),P=ze(x);P.current=x;let K=ze(h);K.current=h;let _=ze(h);bt(()=>{let H=Fs(_.current,h);if(_.current=h,H)Vs(H)},[h]),bt(()=>{if(!r||typeof window>"u")return;let H=Me(window),J=-1,X=null,W=()=>{let b=H.get();if(b.mode===null||!b.caps||b.modeSeq<=J)return;J=b.modeSeq,k.current={mode:b.mode,caps:b.caps};let T=ko[b.mode],M=X===null?P.current!==T:X!==b.mode;X=b.mode;let z=sn[b.mode],Z=(te)=>!!te&&c.some((Ve)=>Ve.id===te),ge=b.tool??(M?z:null),O=Z(ge)?ge:M&&Z(z)?z:null;if(S(T),O)R(O),K.current=O;if(M)i({tool:null,locked:!1});if(H.claimEcho(b.modeSeq)&&window.parent!==window)try{window.parent.postMessage({dgn:"mode-changed",seq:b.modeSeq,mode:b.mode,tool:O??K.current,present:b.present,cause:b.clamped?"clamp":"set-mode"},"*")}catch{}};return W(),H.subscribe(W)},[c,r]);let B=Xe((H)=>{i((J)=>{if(J.locked&&J.tool===H)return{tool:null,locked:!1};return{tool:H,locked:!0}}),R(H)},[]),Q=Xe(()=>{i({tool:null,locked:!1})},[]),[G,se]=Gt("rounded"),ee=ze(Math.random().toString(36).slice(2)),ae=ze(h);ae.current=h;let me=ze(!1);bt(()=>{if(!me.current){me.current=!0;return}if(typeof document>"u")return;document.dispatchEvent(new CustomEvent(Zt,{detail:{tool:h,from:ee.current}}))},[h]),bt(()=>{if(typeof document>"u")return;let H=(J)=>{let X=J.detail;if(!X||X.from===ee.current||typeof X.tool!=="string")return;if(X.tool===ae.current)return;let W=k.current;if(W){let b=at(X.tool,W.caps,W.mode);if(b&&b!==W.mode){document.dispatchEvent(new CustomEvent(Zt,{detail:{tool:ae.current,from:ee.current}}));return}}A(X.tool)};return document.addEventListener(Zt,H),()=>document.removeEventListener(Zt,H)},[A]),bt(()=>{if(typeof document>"u")return;let H=c.find((W)=>W.id===h);if(!H)return;let J=document.body.style.cursor,X=document.getElementById("dc-tool-cursor");if(!X)X=document.createElement("style"),X.id="dc-tool-cursor",document.head.appendChild(X);if(h==="browse"){if(document.body.style.cursor="",X.textContent="",typeof window<"u"&&window.parent&&window.parent!==window)try{window.parent.postMessage({dgn:"tool-cursor",tool:h},"*")}catch{}return()=>{document.body.style.cursor=J}}if(document.body.style.cursor=H.cursor,X.textContent=`* { cursor: ${H.cursor} !important; }`,typeof window<"u"&&window.parent&&window.parent!==window)try{window.parent.postMessage({dgn:"tool-cursor",tool:h},"*")}catch{}return()=>{document.body.style.cursor=J;let W=document.getElementById("dc-tool-cursor");if(W)W.textContent=""}},[h,c]);let we=na(()=>({tool:h,getTool:g,setTool:A,tools:c,mode:x,setMode:q,resetTool:E,sticky:y,toggleSticky:B,clearSticky:Q,shapeKind:G,setShapeKind:se}),[h,g,A,c,x,q,E,y,B,Q,G]);return lo(co.Provider,{value:we,children:e})}function ia({children:e,initial:t,initialMode:n,governed:o}){if(aa(co))return lo(Nd,{children:e});return lo(Od,{initial:t,initialMode:n,governed:o,children:e})}function Jt(){let e=aa(co);if(!e)throw Error("useToolMode must be used inside <ToolProvider>");return e}import{jsx as Xd}from"react/jsx-runtime";var Kd=`
|
|
2
2
|
.dc-el-resize-handle {
|
|
3
3
|
position: fixed;
|
|
4
4
|
width: 8px;
|
|
@@ -59,4 +59,4 @@ import{Component as Ud,createElement as po,useCallback as co,useEffect as Ee,use
|
|
|
59
59
|
@media (prefers-reduced-motion: reduce) {
|
|
60
60
|
.dc-el-resize-handle, .dc-el-resize-readout { transition-duration: 1ms; }
|
|
61
61
|
}
|
|
62
|
-
`.trim();function Nd(){if(typeof document>"u")return;if(document.getElementById("dc-el-resize-css"))return;let e=document.createElement("style");e.id="dc-el-resize-css",e.textContent=Od,document.head.appendChild(e)}var Dd=["nw","n","ne","e","se","s","sw","w"];function Kd(e){return{movesLeft:e==="nw"||e==="w"||e==="sw",movesRight:e==="ne"||e==="e"||e==="se",movesTop:e==="nw"||e==="n"||e==="ne",movesBottom:e==="sw"||e==="s"||e==="se"}}var tt=(e)=>Math.round(e*100)/100,tn=1;function zd(e,t,n,o,r,s){let{movesLeft:a,movesRight:c,movesTop:u,movesBottom:m}=Kd(e),h=r.center,{w:f,h:w}=t;if(c)f=t.w+(h?2*n:n);else if(a)f=t.w-(h?2*n:n);if(m)w=t.h+(h?2*o:o);else if(u)w=t.h-(h?2*o:o);if(r.aspect&&t.w>0&&t.h>0){let g=t.w/t.h;if((a||c)&&(u||m)){let E=Math.abs(f-t.w)/t.w,b=Math.abs(w-t.h)/t.h;if(E>=b)w=f/g;else f=w*g}else if(a||c)w=f/g;else if(u||m)f=w*g}if(f<tn)f=tn;if(w<tn)w=tn;let M={width:tt(f),height:tt(w)};if(h){if(s.canMoveLeft&&(a||c))M.left=tt(t.left+(t.w-f)/2);if(s.canMoveTop&&(u||m))M.top=tt(t.top+(t.h-w)/2)}else{if(s.canMoveLeft&&a)M.left=tt(t.left+t.w-f);if(s.canMoveTop&&u)M.top=tt(t.top+t.h-w)}return M}function la(e){if(!e||e==="none")return 0;let t=/matrix\(([^)]+)\)/.exec(e);if(!t)return 0;let n=t[1].split(",").map(Number),o=n[0]??1,r=n[1]??0;return Math.round(Math.atan2(r,o)*(180/Math.PI)*100)/100}function Vd(e){if(!e||e==="none")return 1;let t=/matrix\(([^)]+)\)/.exec(e);if(!t)return 1;let n=t[1].split(",").map(Number),o=n[0]??1,r=n[1]??0,s=Math.hypot(o,r);return s>0?s:1}function Fd(e){let t=e.closest(".dc-world");if(!t)return 1;let n=getComputedStyle(t),o=Number.parseFloat(n.zoom||"1")||1;return Vd(n.transform)*o}function ca(e,t,n){let o=n*Math.PI/180,r=Math.cos(o),s=Math.sin(o);return[e*r-t*s,e*s+t*r]}function da(e,t,n,o){return Math.atan2(o-t,n-e)}function Hd(e,t,n,o){let r=e+(n-t)*(180/Math.PI);while(r>180)r-=360;while(r<=-180)r+=360;if(o)r=Math.round(r/15)*15;return Math.round(r*100)/100}function $d(e,t){let n={width:`${t.width}px`,height:`${t.height}px`};if(typeof t.left==="number")n.left=`${t.left}px`;if(typeof t.top==="number")n.top=`${t.top}px`;try{window.parent.postMessage({dgn:"resize-request",id:e.cdId,patch:n,before:e.before,idIndex:e.idIndex},"*")}catch{}}function jd(e,t){if(!e.artboardId)return;try{window.parent.postMessage({dgn:"resize-artboard-request",artboardId:e.artboardId,width:t.width,height:t.height},"*")}catch{}}function qd(e,t){try{window.parent.postMessage({dgn:"resize-request",id:e.cdId,patch:{transform:t},before:e.before,idIndex:e.idIndex},"*")}catch{}}function ua(){Nd();let{selected:e}=Bt(),{tool:t}=Jt(),n=en(null),o=en(null),r=en(null),s=en(null),a=e.length===1?e[0]:null,c=a&&typeof a.id==="string"?a.id:null,u=a&&!c&&typeof a.artboardId==="string"?a.artboardId:null,m=t==="move"&&!!c;ia(()=>{let f=n.current;if(!f)return;let w=()=>{for(let g of Array.from(f.children)){let k=g;k.style.opacity="0",k.style.pointerEvents="none"}};if(!m||!a){w();return}let M=()=>{if(o.current=null,Gs()){w(),o.current=ie(M);return}let g=Kn(document,a);if(!g){w(),o.current=ie(M);return}let k=g.getBoundingClientRect();if(k.width<=0&&k.height<=0){w(),o.current=ie(M);return}let E=u?["e","s","se"]:Dd,b=u?[]:["rot-nw","rot-ne","rot-sw","rot-se"],i=E.length+b.length+1;while(f.children.length<i)f.appendChild(document.createElement("div"));while(f.children.length>i)f.lastChild&&f.removeChild(f.lastChild);let S=k.left+k.width/2,R=k.top+k.height/2,F=la(getComputedStyle(g).transform),A=Fd(g),L=g.offsetWidth*A/2,K=g.offsetHeight*A/2,I={nw:[-L,-K],n:[0,-K],ne:[L,-K],e:[L,0],se:[L,K],s:[0,K],sw:[-L,K],w:[-L,0],"rot-nw":[-L,-K],"rot-ne":[L,-K],"rot-sw":[-L,K],"rot-se":[L,K]},B=[...b,...E];for(let se=0;se<B.length;se++){let ee=B[se],oe=f.children[se],[le,ye]=I[ee]??[0,0],[j,G]=ca(le,ye,F),y=S+j,x=R+G,T=ee.startsWith("rot-"),z=ee==="n"||ee==="s",Y=ee==="e"||ee==="w",ue=T?10:z?7:Y?3:4,ge=T?10:z?3:Y?7:4;oe.className="dc-el-resize-handle",oe.dataset.corner=ee,oe.style.opacity="1",oe.style.pointerEvents="auto",oe.style.left=`${Math.round(y-ue)}px`,oe.style.top=`${Math.round(x-ge)}px`,oe.style.transform=T?"":`rotate(${F}deg)`}let X=f.children[B.length],Q=r.current;if(Q&&Q.el===g&&!Q.corner.startsWith("rot-")){let se=Q.lastResult?.width??g.offsetWidth,ee=Q.lastResult?.height??g.offsetHeight,oe=`${Math.round(se)} × ${Math.round(ee)}`,le=Q.lastResult?.left,ye=Q.lastResult?.top;if(typeof le==="number"||typeof ye==="number")oe+=` · ${Math.round(le??Q.start.left)}, ${Math.round(ye??Q.start.top)}`;X.className="dc-el-resize-readout",X.textContent=oe,X.style.opacity="1",X.style.left=`${Math.round(S)}px`,X.style.top=`${Math.round(R+K)}px`}else X.style.opacity="0";o.current=ie(M)};return o.current=ie(M),()=>{if(o.current!=null)Re(o.current)}},[m,a,u]);let h=Ld((f,w)=>{if(f.el.style.width=`${w.width}px`,f.el.style.height=`${w.height}px`,typeof w.left==="number")f.el.style.left=`${w.left}px`;if(typeof w.top==="number")f.el.style.top=`${w.top}px`;f.lastResult=w},[]);return ia(()=>{let f=n.current;if(!f)return;let w=(b,i)=>{let[S,R]=ca(i.clientX-b.startClientX,i.clientY-b.startClientY,-b.angle);return zd(b.corner,b.start,S/b.elZoom,R/b.elZoom,{aspect:!!i.shiftKey,center:!b.artboardId&&!!i.altKey},b.flags)},M=(b)=>{let i=b.target;if(!i?.classList.contains("dc-el-resize-handle"))return;let S=i.dataset.corner;if(!S||!a)return;let R=typeof a.id==="string"?a.id:null,F=!R&&typeof a.artboardId==="string"?a.artboardId:null;if(!R&&!F)return;let A=Kn(document,a);if(!A)return;b.preventDefault(),b.stopPropagation();let L=A.getBoundingClientRect(),K=A.offsetWidth?L.width/A.offsetWidth:1,I=getComputedStyle(A),B=!F&&(I.position==="absolute"||I.position==="fixed"),X=F?Number.NaN:Number.parseFloat(A.style.left),Q=F?Number.NaN:Number.parseFloat(A.style.top),se=F?0:la(I.transform),ee=K>0?K:1,oe=L.left+L.width/2,le=L.top+L.height/2,ye={pointerId:b.pointerId,corner:S,el:A,cdId:R??"",artboardId:F,idIndex:R?Fr(document,R,A):0,startClientX:b.clientX,startClientY:b.clientY,elZoom:ee,angle:se,cx:oe,cy:le,rotStartPointer:da(oe,le,b.clientX,b.clientY),start:{w:(se?A.offsetWidth:L.width/ee)||L.width/ee,h:(se?A.offsetHeight:L.height/ee)||L.height/ee,left:X,top:Q},flags:{canMoveLeft:B&&Number.isFinite(X),canMoveTop:B&&Number.isFinite(Q)},before:{width:A.style.width||null,height:A.style.height||null,left:A.style.left||null,top:A.style.top||null,transform:A.style.transform||null},lastResult:null,lastTransform:null};r.current=ye;try{i.setPointerCapture(b.pointerId)}catch{}},g=(b)=>{let i=r.current;if(!i||b.pointerId!==i.pointerId)return;if(b.preventDefault(),i.corner.startsWith("rot-")){let R=`rotate(${Hd(i.angle,i.rotStartPointer,da(i.cx,i.cy,b.clientX,b.clientY),!!b.shiftKey)}deg)`;i.el.style.transform=R,i.lastTransform=R;return}h(i,w(i,b))},k=(b)=>{let i=r.current;if(!i||b.pointerId!==i.pointerId)return;if(r.current=null,i.corner.startsWith("rot-")){let F=i.lastTransform;if(!F||F===i.before.transform)return;s.current={el:i.el,before:i.before},qd(i,F);return}let S=i.lastResult??w(i,b);if(!(`${S.width}px`!==i.before.width||`${S.height}px`!==i.before.height||typeof S.left==="number"&&`${S.left}px`!==i.before.left||typeof S.top==="number"&&`${S.top}px`!==i.before.top))return;if(s.current={el:i.el,before:i.before},i.artboardId)jd(i,S);else $d(i,S)},E=(b)=>{let i=b.data;if(i?.dgn!=="resize-failed"&&i?.dgn!=="resize-artboard-failed")return;if(b.source!==window.parent)return;let S=s.current;if(!S)return;if(S.el.style.width=S.before.width??"",S.el.style.height=S.before.height??"",S.before.left!==null||S.el.style.left)S.el.style.left=S.before.left??"";if(S.before.top!==null||S.el.style.top)S.el.style.top=S.before.top??"";if(S.before.transform!==null||S.el.style.transform)S.el.style.transform=S.before.transform??"";s.current=null};return f.addEventListener("pointerdown",M),window.addEventListener("pointermove",g),window.addEventListener("pointerup",k),window.addEventListener("pointercancel",k),window.addEventListener("message",E),()=>{f.removeEventListener("pointerdown",M),window.removeEventListener("pointermove",g),window.removeEventListener("pointerup",k),window.removeEventListener("pointercancel",k),window.removeEventListener("message",E)}},[a,h]),Bd("div",{ref:n,"aria-hidden":"true"})}import{jsx as be,jsxs as ga,Fragment as iu}from"react/jsx-runtime";var Yd=new Set(["drop-comment","tool","escape","hover"]);function Qd(e,t){if(!e)return!0;t();return}function nt(){return typeof document<"u"&&!document.querySelector(".dc-canvas")}function mo(e,t){if(typeof document>"u")return null;let n=document.elementFromPoint(e,t);if(!n)return null;if(n.closest(".cm-composer, .cm-thread, .cm-mention-popup, .cm-pin, [data-mc-hover-halo], [data-mc-selection-halo], .dc-el-resize-handle"))return null;let o=n.tagName;if(o==="HTML"||o==="BODY")return null;return n}function Gd(e,t){let n=mo(e,t);if(!n)return null;return n.closest("[data-cd-id]")??n}function Zd({children:e,file:t}){let{tool:n,setTool:o,getTool:r}=Jt(),s=Bt(),a=Te(null),[c,u]=ot(null),m=Te(n);m.current=n;let h=Wd(()=>()=>r?.()??m.current,[r]);Ee(()=>{if(n!=="comment")u(null)},[n]);let f=Te(!1);Ee(()=>sr(()=>{f.current=m.current!=="comment",o("comment")},()=>{if(f.current)o("move");f.current=!1}),[o]);let[w,M]=ot(null),[g,k]=ot(!1);return Ee(()=>{let E=()=>k(nt());E();let b=ie(E),i=setTimeout(E,120);return()=>{Re(b),clearTimeout(i)}},[]),Ee(()=>{if(typeof document>"u")return;let E=(b)=>{if(b.button!==0||!(b.metaKey||b.ctrlKey))return;if(!nt())return;if(ht(b.target))return;let i=Gd(b.clientX,b.clientY);if(!i)return;b.preventDefault(),b.stopImmediatePropagation();let S=i.getAttribute("data-cd-id"),R=Ht({el:i,cdId:S,artboardId:null});if(b.shiftKey)s.add(R);else s.replace(R);M(i)};return document.addEventListener("pointerdown",E,!0),()=>document.removeEventListener("pointerdown",E,!0)},[s]),Ee(()=>{if(s.selected.length===0)M(null)},[s.selected]),Ee(()=>{let E=a.current;if(E)E.setAttribute("data-active-tool",n);if(typeof document<"u"&&document.body)document.body.setAttribute("data-active-tool",n);return()=>{E?.removeAttribute("data-active-tool")}},[n]),Ee(()=>{if(typeof window>"u")return;let E=(b)=>{let i=b.data;if(!i||typeof i!=="object"||i.dgn!=="tool-set")return;if(b.source!==window.parent)return;if(typeof i.tool==="string")o(i.tool)};return window.addEventListener("message",E),()=>window.removeEventListener("message",E)},[o]),Qs({hostRef:a,getActiveTool:h,claimableActions:Yd,callbacks:{onHover:({clientX:E,clientY:b})=>{if(m.current!=="comment"||!nt()){u(null);return}let i=mo(E,b);u((S)=>S===i?S:i)},onTool:({tool:E})=>o(E),onEscape:()=>{if(Qe()!==null)It();return Qd(nt(),()=>{if(m.current!=="move")o("move");if(u(null),s.clear(),typeof window<"u")try{window.parent.postMessage({dgn:"force-clear"},"*")}catch{}})},onDropComment:({clientX:E,clientY:b})=>{let i=Qe()!==null;if(tu(E,b,s,t),i&&Qe()===null&&f.current)f.current=!1,o("move")}}}),ga("div",{"data-mc-host":!0,ref:a,style:{display:"contents"},children:[e,c?be(eu,{el:c}):null,w?be(Jd,{el:w}):null,g?be(ua,{}):null,be(ws,{})]})}function Jd({el:e}){let t=Te(null),n=Te(e);n.current=e;let o=Te(null);return Ee(()=>{let r=()=>{o.current=null;let s=t.current,a=n.current;if(s&&a?.isConnected){let c=a.getBoundingClientRect();if(c.width===0&&c.height===0)s.style.display="none";else s.style.display="block",s.style.left=`${Math.round(c.left)}px`,s.style.top=`${Math.round(c.top)}px`,s.style.width=`${Math.round(c.width)}px`,s.style.height=`${Math.round(c.height)}px`}else if(s)s.style.display="none";o.current=ie(r)};return o.current=ie(r),()=>{if(o.current!=null)Re(o.current)}},[]),be("div",{ref:t,"aria-hidden":"true","data-mc-selection-halo":"",style:{position:"fixed",display:"none",pointerEvents:"none",zIndex:2147483645,border:"1.5px solid var(--maude-hud-accent, oklch(0.680 0.180 268))",borderRadius:"3px",boxSizing:"border-box"}})}function eu({el:e}){let t=Te(null),n=Te(e);n.current=e;let o=Te(null);return Ee(()=>{let r=()=>{o.current=null;let s=t.current,a=n.current;if(s&&a?.isConnected){let c=a.getBoundingClientRect();if(c.width===0&&c.height===0)s.style.display="none";else s.style.display="block",s.style.left=`${Math.round(c.left)}px`,s.style.top=`${Math.round(c.top)}px`,s.style.width=`${Math.round(c.width)}px`,s.style.height=`${Math.round(c.height)}px`}else if(s)s.style.display="none";o.current=ie(r)};return o.current=ie(r),()=>{if(o.current!=null)Re(o.current)}},[]),be("div",{ref:t,"aria-hidden":"true","data-mc-hover-halo":"",style:{position:"fixed",display:"none",pointerEvents:"none",zIndex:2147483646,border:"2px solid var(--maude-hud-accent, #d63b1f)",borderRadius:"3px",boxSizing:"border-box"}})}function tu(e,t,n,o){if(typeof document>"u")return;let r=Mt(e,t)??void 0,s=or(e,t);if(s&&Qe()!==null)return;if(s){let u=Ct(s),m=u?.getBoundingClientRect(),h={file:o,id:void 0,selector:"",artboardId:null,tag:u?.getAttribute("data-tool")??"annotation",classes:"",text:"",dom_path:[],bounds:m?{x:m.left,y:m.top,w:m.width,h:m.height}:{x:e-12,y:t-12,w:24,h:24},html:"",annotationId:s,...r?{world:r}:{}};uo(h,e,t);return}let a=Qt(document,e,t,{deep:!0});if(!a)a=Qt(document,e,t,{deep:!1});if(!a&&!nt()&&typeof document.elementsFromPoint==="function"){let u=document.elementsFromPoint(e,t);for(let m of u){let h=m.closest?.("[data-cd-id]");if(!h)continue;if(!h.closest(".dc-artboard-body"))continue;let f=h.closest("[data-dc-screen]");a={el:h,cdId:h.getAttribute("data-cd-id"),artboardId:f?.getAttribute("data-dc-screen")??null};break}}if(!a&&nt()){let u=mo(e,t);if(u)a={el:u,cdId:u.getAttribute("data-cd-id"),artboardId:null}}if(!a&&Qe()!==null)return;if(!a){let u={file:o,id:void 0,selector:"",artboardId:null,tag:"",classes:"",text:"",dom_path:[],bounds:{x:e-12,y:t-12,w:24,h:24},html:"",...r?{world:r}:{}};uo(u,e,t);return}let c=jr(a,e,t,o);if(ar(c,e,t))return;n.replace(Ht(a,o)),uo(c,e,t)}function uo(e,t,n){if(typeof document<"u")try{document.dispatchEvent(new CustomEvent("cm:open-composer",{detail:{selection:e,clientX:t,clientY:n}}))}catch{}if(typeof window<"u")try{window.parent.postMessage({dgn:"comment-compose",selection:e},"*")}catch{}}function ma(e,t){return be(aa,{initial:"browse",children:be(Jr,{children:be(Zd,{file:t,children:be(e,{})})})})}function Gf(e,t){let n=Xd(t.rootEl);if(!t.commentsEnabled){n.render(po(e));return}let o=t.file??Dn();n.render(po(au,{initialCanvas:e,file:o}))}var pa="__maudeCanvasRuntime";function nu({Canvas:e,file:t,onOk:n}){return Ee(()=>{n()},[]),ma(e,t)}class fa extends Ud{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){this.props.onError(e)}componentDidUpdate(e){if(e.attempt!==this.props.attempt&&this.state.hasError)this.setState({hasError:!1})}render(){if(this.state.hasError)return this.props.fallback();return this.props.children}}var ou=300;function ru(e){let t="";try{t=e instanceof Error?e.message:String(e??"")}catch{}return(t.replace(/\s+/g," ").trim()||"The canvas stopped while drawing.").slice(0,ou)}function su({message:e}){return po("div",{className:"dc-hmr-holding",role:"status","aria-live":"polite",title:e?`Showing the last version that worked — ${e}`:"Showing the last version that worked"},"This canvas has an error. Showing the last version that worked.")}function au({initialCanvas:e,file:t}){let[{canvas:n,attempt:o},r]=ot({canvas:e,attempt:0}),[s,a]=ot({on:!1}),[c,u]=ot(!1);Ee(()=>{let k=(E)=>{if(E.source!==window.parent)return;if(E.data?.dgn!=="ai-runs")return;let b=At(E,window);if(b&&b.dgn==="ai-runs")u(Object.values(b.artboards).some((i)=>i.state!=="done"))};return window.addEventListener("message",k),()=>window.removeEventListener("message",k)},[]);let m=Te(null),h=Te(null),f=Te(n);f.current=n,Ee(()=>{let k={remount:(E)=>r((b)=>({canvas:E,attempt:b.attempt+1})),setHolding:(E,b)=>a(E?{on:!0,message:b,source:"build"}:{on:!1})};return window[pa]=k,()=>{window[pa]=void 0}},[]);let w=co(()=>{if(m.current=f.current,h.current=null,t)try{window.parent.postMessage({dgn:"render-ok",file:t},"*")}catch{}if(a((k)=>k.on?{on:!1}:k),o>0&&t)try{window.parent.postMessage({dgn:"loaded",file:t},"*")}catch{}},[o,t]),M=co((k)=>{let E=ru(k);if(a({on:!0,message:"render error",source:"render"}),h.current===f.current)return;if(h.current=f.current,t)try{window.parent.postMessage({dgn:"render-error",file:t,message:E},"*")}catch{}},[t]),g=co(()=>{let k=m.current;return k?ma(k,t):null},[t]);return ga(iu,{children:[be(fa,{attempt:o,onError:M,fallback:g,children:be(nu,{Canvas:n,file:t,onOk:w},o)}),s.on&&(s.source!=="render"||c)?be(su,{message:s.message}):null]})}export{fa as CanvasErrorBoundary,Qd as commentMountEscape,ru as describeRenderFailure,nt as isBareSpecimen,Gf as mountCanvas,Gd as pickSpecimenSelectEl};
|
|
62
|
+
`.trim();function zd(){if(typeof document>"u")return;if(document.getElementById("dc-el-resize-css"))return;let e=document.createElement("style");e.id="dc-el-resize-css",e.textContent=Kd,document.head.appendChild(e)}var Vd=["nw","n","ne","e","se","s","sw","w"];function Fd(e){return{movesLeft:e==="nw"||e==="w"||e==="sw",movesRight:e==="ne"||e==="e"||e==="se",movesTop:e==="nw"||e==="n"||e==="ne",movesBottom:e==="sw"||e==="s"||e==="se"}}var nt=(e)=>Math.round(e*100)/100,tn=1;function Hd(e,t,n,o,r,s){let{movesLeft:a,movesRight:c,movesTop:u,movesBottom:m}=Fd(e),h=r.center,{w:f,h:w}=t;if(c)f=t.w+(h?2*n:n);else if(a)f=t.w-(h?2*n:n);if(m)w=t.h+(h?2*o:o);else if(u)w=t.h-(h?2*o:o);if(r.aspect&&t.w>0&&t.h>0){let g=t.w/t.h;if((a||c)&&(u||m)){let S=Math.abs(f-t.w)/t.w,y=Math.abs(w-t.h)/t.h;if(S>=y)w=f/g;else f=w*g}else if(a||c)w=f/g;else if(u||m)f=w*g}if(f<tn)f=tn;if(w<tn)w=tn;let R={width:nt(f),height:nt(w)};if(h){if(s.canMoveLeft&&(a||c))R.left=nt(t.left+(t.w-f)/2);if(s.canMoveTop&&(u||m))R.top=nt(t.top+(t.h-w)/2)}else{if(s.canMoveLeft&&a)R.left=nt(t.left+t.w-f);if(s.canMoveTop&&u)R.top=nt(t.top+t.h-w)}return R}function ca(e){if(!e||e==="none")return 0;let t=/matrix\(([^)]+)\)/.exec(e);if(!t)return 0;let n=t[1].split(",").map(Number),o=n[0]??1,r=n[1]??0;return Math.round(Math.atan2(r,o)*(180/Math.PI)*100)/100}function $d(e){if(!e||e==="none")return 1;let t=/matrix\(([^)]+)\)/.exec(e);if(!t)return 1;let n=t[1].split(",").map(Number),o=n[0]??1,r=n[1]??0,s=Math.hypot(o,r);return s>0?s:1}function qd(e){let t=e.closest(".dc-world");if(!t)return 1;let n=getComputedStyle(t),o=Number.parseFloat(n.zoom||"1")||1;return $d(n.transform)*o}function da(e,t,n){let o=n*Math.PI/180,r=Math.cos(o),s=Math.sin(o);return[e*r-t*s,e*s+t*r]}function ua(e,t,n,o){return Math.atan2(o-t,n-e)}function jd(e,t,n,o){let r=e+(n-t)*(180/Math.PI);while(r>180)r-=360;while(r<=-180)r+=360;if(o)r=Math.round(r/15)*15;return Math.round(r*100)/100}function Bd(e,t){let n={width:`${t.width}px`,height:`${t.height}px`};if(typeof t.left==="number")n.left=`${t.left}px`;if(typeof t.top==="number")n.top=`${t.top}px`;try{window.parent.postMessage({dgn:"resize-request",id:e.cdId,patch:n,before:e.before,idIndex:e.idIndex},"*")}catch{}}function Wd(e,t){if(!e.artboardId)return;try{window.parent.postMessage({dgn:"resize-artboard-request",artboardId:e.artboardId,width:t.width,height:t.height},"*")}catch{}}function Ud(e,t){try{window.parent.postMessage({dgn:"resize-request",id:e.cdId,patch:{transform:t},before:e.before,idIndex:e.idIndex},"*")}catch{}}function pa(){zd();let{selected:e}=Bt(),{tool:t}=Jt(),n=en(null),o=en(null),r=en(null),s=en(null),a=e.length===1?e[0]:null,c=a&&typeof a.id==="string"?a.id:null,u=a&&!c&&typeof a.artboardId==="string"?a.artboardId:null,m=t==="move"&&!!c;la(()=>{let f=n.current;if(!f)return;let w=()=>{for(let g of Array.from(f.children)){let x=g;x.style.opacity="0",x.style.pointerEvents="none"}};if(!m||!a){w();return}let R=()=>{if(o.current=null,Zs()){w(),o.current=le(R);return}let g=Kn(document,a);if(!g){w(),o.current=le(R);return}let x=g.getBoundingClientRect();if(x.width<=0&&x.height<=0){w(),o.current=le(R);return}let S=u?["e","s","se"]:Vd,y=u?[]:["rot-nw","rot-ne","rot-sw","rot-se"],i=S.length+y.length+1;while(f.children.length<i)f.appendChild(document.createElement("div"));while(f.children.length>i)f.lastChild&&f.removeChild(f.lastChild);let k=x.left+x.width/2,A=x.top+x.height/2,q=ca(getComputedStyle(g).transform),E=qd(g),P=g.offsetWidth*E/2,K=g.offsetHeight*E/2,_={nw:[-P,-K],n:[0,-K],ne:[P,-K],e:[P,0],se:[P,K],s:[0,K],sw:[-P,K],w:[-P,0],"rot-nw":[-P,-K],"rot-ne":[P,-K],"rot-sw":[-P,K],"rot-se":[P,K]},B=[...y,...S];for(let se=0;se<B.length;se++){let ee=B[se],ae=f.children[se],[me,we]=_[ee]??[0,0],[H,J]=da(me,we,q),X=k+H,W=A+J,b=ee.startsWith("rot-"),T=ee==="n"||ee==="s",M=ee==="e"||ee==="w",z=b?10:T?7:M?3:4,Z=b?10:T?3:M?7:4;ae.className="dc-el-resize-handle",ae.dataset.corner=ee,ae.style.opacity="1",ae.style.pointerEvents="auto",ae.style.left=`${Math.round(X-z)}px`,ae.style.top=`${Math.round(W-Z)}px`,ae.style.transform=b?"":`rotate(${q}deg)`}let Q=f.children[B.length],G=r.current;if(G&&G.el===g&&!G.corner.startsWith("rot-")){let se=G.lastResult?.width??g.offsetWidth,ee=G.lastResult?.height??g.offsetHeight,ae=`${Math.round(se)} × ${Math.round(ee)}`,me=G.lastResult?.left,we=G.lastResult?.top;if(typeof me==="number"||typeof we==="number")ae+=` · ${Math.round(me??G.start.left)}, ${Math.round(we??G.start.top)}`;Q.className="dc-el-resize-readout",Q.textContent=ae,Q.style.opacity="1",Q.style.left=`${Math.round(k)}px`,Q.style.top=`${Math.round(A+K)}px`}else Q.style.opacity="0";o.current=le(R)};return o.current=le(R),()=>{if(o.current!=null)Ae(o.current)}},[m,a,u]);let h=Dd((f,w)=>{if(f.el.style.width=`${w.width}px`,f.el.style.height=`${w.height}px`,typeof w.left==="number")f.el.style.left=`${w.left}px`;if(typeof w.top==="number")f.el.style.top=`${w.top}px`;f.lastResult=w},[]);return la(()=>{let f=n.current;if(!f)return;let w=(y,i)=>{let[k,A]=da(i.clientX-y.startClientX,i.clientY-y.startClientY,-y.angle);return Hd(y.corner,y.start,k/y.elZoom,A/y.elZoom,{aspect:!!i.shiftKey,center:!y.artboardId&&!!i.altKey},y.flags)},R=(y)=>{let i=y.target;if(!i?.classList.contains("dc-el-resize-handle"))return;let k=i.dataset.corner;if(!k||!a)return;let A=typeof a.id==="string"?a.id:null,q=!A&&typeof a.artboardId==="string"?a.artboardId:null;if(!A&&!q)return;let E=Kn(document,a);if(!E)return;y.preventDefault(),y.stopPropagation();let P=E.getBoundingClientRect(),K=E.offsetWidth?P.width/E.offsetWidth:1,_=getComputedStyle(E),B=!q&&(_.position==="absolute"||_.position==="fixed"),Q=q?Number.NaN:Number.parseFloat(E.style.left),G=q?Number.NaN:Number.parseFloat(E.style.top),se=q?0:ca(_.transform),ee=K>0?K:1,ae=P.left+P.width/2,me=P.top+P.height/2,we={pointerId:y.pointerId,corner:k,el:E,cdId:A??"",artboardId:q,idIndex:A?$r(document,A,E):0,startClientX:y.clientX,startClientY:y.clientY,elZoom:ee,angle:se,cx:ae,cy:me,rotStartPointer:ua(ae,me,y.clientX,y.clientY),start:{w:(se?E.offsetWidth:P.width/ee)||P.width/ee,h:(se?E.offsetHeight:P.height/ee)||P.height/ee,left:Q,top:G},flags:{canMoveLeft:B&&Number.isFinite(Q),canMoveTop:B&&Number.isFinite(G)},before:{width:E.style.width||null,height:E.style.height||null,left:E.style.left||null,top:E.style.top||null,transform:E.style.transform||null},lastResult:null,lastTransform:null};r.current=we;try{i.setPointerCapture(y.pointerId)}catch{}},g=(y)=>{let i=r.current;if(!i||y.pointerId!==i.pointerId)return;if(y.preventDefault(),i.corner.startsWith("rot-")){let A=`rotate(${jd(i.angle,i.rotStartPointer,ua(i.cx,i.cy,y.clientX,y.clientY),!!y.shiftKey)}deg)`;i.el.style.transform=A,i.lastTransform=A;return}h(i,w(i,y))},x=(y)=>{let i=r.current;if(!i||y.pointerId!==i.pointerId)return;if(r.current=null,i.corner.startsWith("rot-")){let q=i.lastTransform;if(!q||q===i.before.transform)return;s.current={el:i.el,before:i.before},Ud(i,q);return}let k=i.lastResult??w(i,y);if(!(`${k.width}px`!==i.before.width||`${k.height}px`!==i.before.height||typeof k.left==="number"&&`${k.left}px`!==i.before.left||typeof k.top==="number"&&`${k.top}px`!==i.before.top))return;if(s.current={el:i.el,before:i.before},i.artboardId)Wd(i,k);else Bd(i,k)},S=(y)=>{let i=y.data;if(i?.dgn!=="resize-failed"&&i?.dgn!=="resize-artboard-failed")return;if(y.source!==window.parent)return;let k=s.current;if(!k)return;if(k.el.style.width=k.before.width??"",k.el.style.height=k.before.height??"",k.before.left!==null||k.el.style.left)k.el.style.left=k.before.left??"";if(k.before.top!==null||k.el.style.top)k.el.style.top=k.before.top??"";if(k.before.transform!==null||k.el.style.transform)k.el.style.transform=k.before.transform??"";s.current=null};return f.addEventListener("pointerdown",R),window.addEventListener("pointermove",g),window.addEventListener("pointerup",x),window.addEventListener("pointercancel",x),window.addEventListener("message",S),()=>{f.removeEventListener("pointerdown",R),window.removeEventListener("pointermove",g),window.removeEventListener("pointerup",x),window.removeEventListener("pointercancel",x),window.removeEventListener("message",S)}},[a,h]),Xd("div",{ref:n,"aria-hidden":"true"})}import{jsx as ye,jsxs as ha,Fragment as du}from"react/jsx-runtime";var Zd=new Set(["drop-comment","tool","escape","hover"]);function Jd(e,t){if(!e)return!0;t();return}function ot(){return typeof document<"u"&&!document.querySelector(".dc-canvas")}function fo(e,t){if(typeof document>"u")return null;let n=document.elementFromPoint(e,t);if(!n)return null;if(n.closest(".cm-composer, .cm-thread, .cm-mention-popup, .cm-pin, [data-mc-hover-halo], [data-mc-selection-halo], .dc-el-resize-handle"))return null;let o=n.tagName;if(o==="HTML"||o==="BODY")return null;return n}function eu(e,t){let n=fo(e,t);if(!n)return null;return n.closest("[data-cd-id]")??n}function tu({children:e,file:t}){let{tool:n,setTool:o,getTool:r}=Jt(),s=Bt(),a=Re(null),[c,u]=rt(null),m=Re(n);m.current=n;let h=Qd(()=>()=>r?.()??m.current,[r]);Te(()=>{if(n!=="comment")u(null)},[n]);let f=Re(!1);Te(()=>ar(()=>{f.current=m.current!=="comment",o("comment")},()=>{if(f.current)o("move");f.current=!1}),[o]);let[w,R]=rt(null),[g,x]=rt(!1);return Te(()=>{let S=()=>x(ot());S();let y=le(S),i=setTimeout(S,120);return()=>{Ae(y),clearTimeout(i)}},[]),Te(()=>{if(typeof document>"u")return;let S=(y)=>{if(y.button!==0||!(y.metaKey||y.ctrlKey))return;if(!ot())return;if(ht(y.target))return;let i=eu(y.clientX,y.clientY);if(!i)return;y.preventDefault(),y.stopImmediatePropagation();let k=i.getAttribute("data-cd-id"),A=Ht({el:i,cdId:k,artboardId:null});if(y.shiftKey)s.add(A);else s.replace(A);R(i)};return document.addEventListener("pointerdown",S,!0),()=>document.removeEventListener("pointerdown",S,!0)},[s]),Te(()=>{if(s.selected.length===0)R(null)},[s.selected]),Te(()=>{let S=a.current;if(S)S.setAttribute("data-active-tool",n);if(typeof document<"u"&&document.body)document.body.setAttribute("data-active-tool",n);return()=>{S?.removeAttribute("data-active-tool")}},[n]),Te(()=>{if(typeof window>"u")return;let S=(y)=>{let i=y.data;if(!i||typeof i!=="object"||i.dgn!=="tool-set")return;if(y.source!==window.parent)return;if(typeof i.tool==="string")o(i.tool)};return window.addEventListener("message",S),()=>window.removeEventListener("message",S)},[o]),Gs({hostRef:a,getActiveTool:h,claimableActions:Zd,callbacks:{onHover:({clientX:S,clientY:y})=>{if(m.current!=="comment"||!ot()){u(null);return}let i=fo(S,y);u((k)=>k===i?k:i)},onTool:({tool:S})=>o(S),onEscape:()=>{if(Ge()!==null)It();return Jd(ot(),()=>{if(m.current!=="move")o("move");if(u(null),s.clear(),typeof window<"u")try{window.parent.postMessage({dgn:"force-clear"},"*")}catch{}})},onDropComment:({clientX:S,clientY:y})=>{let i=Ge()!==null;if(ru(S,y,s,t),i&&Ge()===null&&f.current)f.current=!1,o("move")}}}),ha("div",{"data-mc-host":!0,ref:a,style:{display:"contents"},children:[e,c?ye(ou,{el:c}):null,w?ye(nu,{el:w}):null,g?ye(pa,{}):null,ye(xs,{})]})}function nu({el:e}){let t=Re(null),n=Re(e);n.current=e;let o=Re(null);return Te(()=>{let r=()=>{o.current=null;let s=t.current,a=n.current;if(s&&a?.isConnected){let c=a.getBoundingClientRect();if(c.width===0&&c.height===0)s.style.display="none";else s.style.display="block",s.style.left=`${Math.round(c.left)}px`,s.style.top=`${Math.round(c.top)}px`,s.style.width=`${Math.round(c.width)}px`,s.style.height=`${Math.round(c.height)}px`}else if(s)s.style.display="none";o.current=le(r)};return o.current=le(r),()=>{if(o.current!=null)Ae(o.current)}},[]),ye("div",{ref:t,"aria-hidden":"true","data-mc-selection-halo":"",style:{position:"fixed",display:"none",pointerEvents:"none",zIndex:2147483645,border:"1.5px solid var(--maude-hud-accent, oklch(0.680 0.180 268))",borderRadius:"3px",boxSizing:"border-box"}})}function ou({el:e}){let t=Re(null),n=Re(e);n.current=e;let o=Re(null);return Te(()=>{let r=()=>{o.current=null;let s=t.current,a=n.current;if(s&&a?.isConnected){let c=a.getBoundingClientRect();if(c.width===0&&c.height===0)s.style.display="none";else s.style.display="block",s.style.left=`${Math.round(c.left)}px`,s.style.top=`${Math.round(c.top)}px`,s.style.width=`${Math.round(c.width)}px`,s.style.height=`${Math.round(c.height)}px`}else if(s)s.style.display="none";o.current=le(r)};return o.current=le(r),()=>{if(o.current!=null)Ae(o.current)}},[]),ye("div",{ref:t,"aria-hidden":"true","data-mc-hover-halo":"",style:{position:"fixed",display:"none",pointerEvents:"none",zIndex:2147483646,border:"2px solid var(--maude-hud-accent, #d63b1f)",borderRadius:"3px",boxSizing:"border-box"}})}function ru(e,t,n,o){if(typeof document>"u")return;let r=Mt(e,t)??void 0,s=rr(e,t);if(s&&Ge()!==null)return;if(s){let u=Ct(s),m=u?.getBoundingClientRect(),h={file:o,id:void 0,selector:"",artboardId:null,tag:u?.getAttribute("data-tool")??"annotation",classes:"",text:"",dom_path:[],bounds:m?{x:m.left,y:m.top,w:m.width,h:m.height}:{x:e-12,y:t-12,w:24,h:24},html:"",annotationId:s,...r?{world:r}:{}};po(h,e,t);return}let a=Qt(document,e,t,{deep:!0});if(!a)a=Qt(document,e,t,{deep:!1});if(!a&&!ot()&&typeof document.elementsFromPoint==="function"){let u=document.elementsFromPoint(e,t);for(let m of u){let h=m.closest?.("[data-cd-id]");if(!h)continue;if(!h.closest(".dc-artboard-body"))continue;let f=h.closest("[data-dc-screen]");a={el:h,cdId:h.getAttribute("data-cd-id"),artboardId:f?.getAttribute("data-dc-screen")??null};break}}if(!a&&ot()){let u=fo(e,t);if(u)a={el:u,cdId:u.getAttribute("data-cd-id"),artboardId:null}}if(!a&&Ge()!==null)return;if(!a){let u={file:o,id:void 0,selector:"",artboardId:null,tag:"",classes:"",text:"",dom_path:[],bounds:{x:e-12,y:t-12,w:24,h:24},html:"",...r?{world:r}:{}};po(u,e,t);return}let c=Br(a,e,t,o);if(ir(c,e,t))return;n.replace(Ht(a,o)),po(c,e,t)}function po(e,t,n){if(typeof document<"u")try{document.dispatchEvent(new CustomEvent("cm:open-composer",{detail:{selection:e,clientX:t,clientY:n}}))}catch{}if(typeof window<"u")try{window.parent.postMessage({dgn:"comment-compose",selection:e},"*")}catch{}}function fa(e,t){return ye(ia,{initial:"browse",children:ye(ts,{children:ye(tu,{file:t,children:ye(e,{})})})})}function ng(e,t){let n=Gd(t.rootEl);if(!t.commentsEnabled){n.render(mo(e));return}let o=t.file??Dn();n.render(mo(cu,{initialCanvas:e,file:o}))}var ma="__maudeCanvasRuntime";function su({Canvas:e,file:t,onOk:n}){return Te(()=>{n()},[]),fa(e,t)}class ga extends Yd{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){this.props.onError(e)}componentDidUpdate(e){if(e.attempt!==this.props.attempt&&this.state.hasError)this.setState({hasError:!1})}render(){if(this.state.hasError)return this.props.fallback();return this.props.children}}var au=300;function iu(e){let t="";try{t=e instanceof Error?e.message:String(e??"")}catch{}return(t.replace(/\s+/g," ").trim()||"The canvas stopped while drawing.").slice(0,au)}function lu({message:e}){return mo("div",{className:"dc-hmr-holding",role:"status","aria-live":"polite",title:e?`Showing the last version that worked — ${e}`:"Showing the last version that worked"},"This canvas has an error. Showing the last version that worked.")}function cu({initialCanvas:e,file:t}){let[{canvas:n,attempt:o},r]=rt({canvas:e,attempt:0}),[s,a]=rt({on:!1}),[c,u]=rt(!1);Te(()=>{let x=(S)=>{if(S.source!==window.parent)return;if(S.data?.dgn!=="ai-runs")return;let y=At(S,window);if(y&&y.dgn==="ai-runs")u(Object.values(y.artboards).some((i)=>i.state!=="done"))};return window.addEventListener("message",x),()=>window.removeEventListener("message",x)},[]);let m=Re(null),h=Re(null),f=Re(n);f.current=n,Te(()=>{let x={remount:(S)=>r((y)=>({canvas:S,attempt:y.attempt+1})),setHolding:(S,y)=>a(S?{on:!0,message:y,source:"build"}:{on:!1})};return window[ma]=x,()=>{window[ma]=void 0}},[]);let w=uo(()=>{if(m.current=f.current,h.current=null,t)try{window.parent.postMessage({dgn:"render-ok",file:t},"*")}catch{}if(a((x)=>x.on?{on:!1}:x),o>0&&t)try{window.parent.postMessage({dgn:"loaded",file:t},"*")}catch{}},[o,t]),R=uo((x)=>{let S=iu(x);if(a({on:!0,message:"render error",source:"render"}),h.current===f.current)return;if(h.current=f.current,t)try{window.parent.postMessage({dgn:"render-error",file:t,message:S},"*")}catch{}},[t]),g=uo(()=>{let x=m.current;return x?fa(x,t):null},[t]);return ha(du,{children:[ye(ga,{attempt:o,onError:R,fallback:g,children:ye(su,{Canvas:n,file:t,onOk:w},o)}),s.on&&(s.source!=="render"||c)?ye(lu,{message:s.message}):null]})}export{ga as CanvasErrorBoundary,Jd as commentMountEscape,iu as describeRenderFailure,ot as isBareSpecimen,ng as mountCanvas,eu as pickSpecimenSelectEl};
|