@1agh/maude 1.8.1 → 1.9.1
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/bridge.ts +14 -2
- package/apps/studio/acp/probe.ts +51 -1
- package/apps/studio/api.ts +19 -4
- package/apps/studio/bin/_curl-local.mjs +7 -0
- package/apps/studio/bin/annotate.mjs +16 -7
- package/apps/studio/bin/read-annotations.mjs +62 -4
- package/apps/studio/client/app.jsx +428 -15977
- package/apps/studio/client/dialogs/asset-picker.jsx +331 -0
- package/apps/studio/client/dialogs/command-palette.jsx +112 -0
- package/apps/studio/client/dialogs/export-dialog.jsx +782 -0
- package/apps/studio/client/dialogs/help-modal.jsx +324 -0
- package/apps/studio/client/dialogs/shortcuts-overlay.jsx +144 -0
- package/apps/studio/client/hooks/use-canvas-bridge.jsx +2150 -0
- package/apps/studio/client/hooks/use-git-actions.jsx +236 -0
- package/apps/studio/client/hooks/use-keyboard-shortcuts.jsx +297 -0
- package/apps/studio/client/hooks/use-palette-and-panels.jsx +474 -0
- package/apps/studio/client/hooks/use-photo-and-timeline.jsx +901 -0
- package/apps/studio/client/hooks/use-project-data.jsx +90 -0
- package/apps/studio/client/hooks/use-shell-core.jsx +1212 -0
- package/apps/studio/client/hooks/use-tabs.jsx +723 -0
- package/apps/studio/client/hooks/use-web-socket.jsx +13 -0
- package/apps/studio/client/inspector/artboard-knobs.jsx +456 -0
- package/apps/studio/client/inspector/color-picker.jsx +196 -0
- package/apps/studio/client/inspector/color.js +92 -0
- package/apps/studio/client/inspector/css-knobs.jsx +1720 -0
- package/apps/studio/client/inspector/css-vocab.jsx +131 -0
- package/apps/studio/client/inspector/ds-tokens.js +90 -0
- package/apps/studio/client/inspector/grid-tracks-editor.jsx +97 -0
- package/apps/studio/client/inspector/inspect-computed.jsx +68 -0
- package/apps/studio/client/inspector/inspector-panel.jsx +769 -0
- package/apps/studio/client/inspector/layers.jsx +322 -0
- package/apps/studio/client/inspector/selection.js +65 -0
- package/apps/studio/client/inspector/token-popover.jsx +301 -0
- package/apps/studio/client/menus/menubar.jsx +856 -0
- package/apps/studio/client/selection-scope.js +40 -0
- package/apps/studio/client/shell/banners.jsx +272 -0
- package/apps/studio/client/shell/collapsed-rail.jsx +23 -0
- package/apps/studio/client/shell/comments-panel.jsx +177 -0
- package/apps/studio/client/shell/constants.js +60 -0
- package/apps/studio/client/shell/dock.jsx +131 -0
- package/apps/studio/client/shell/icons.jsx +370 -0
- package/apps/studio/client/shell/status-bar.jsx +215 -0
- package/apps/studio/client/shell/util.js +332 -0
- package/apps/studio/client/shell/viewport.jsx +254 -0
- package/apps/studio/client/system/system-view.jsx +255 -0
- package/apps/studio/client/tree/tree.jsx +1243 -0
- package/apps/studio/comments-overlay.tsx +6 -4
- package/apps/studio/config.schema.json +5 -0
- package/apps/studio/context.ts +13 -0
- package/apps/studio/dist/client.bundle.js +1337 -1337
- package/apps/studio/dist/comment-mount.js +2 -2
- package/apps/studio/exporters/_browser-bundles.ts +21 -2
- package/apps/studio/exporters/jobs.ts +75 -15
- package/apps/studio/exporters/scope.ts +15 -12
- package/apps/studio/format.ts +296 -0
- package/apps/studio/http.ts +217 -23
- package/apps/studio/server.ts +141 -30
- package/apps/studio/sync/accepted-link.ts +6 -0
- package/apps/studio/sync/agent.ts +9 -1
- package/apps/studio/sync/cold-start-apply.ts +29 -4
- package/apps/studio/sync/cold-start.ts +78 -0
- package/apps/studio/sync/file-plane.ts +61 -1
- package/apps/studio/sync/format-sync.ts +160 -0
- package/apps/studio/sync/index.ts +134 -10
- package/apps/studio/sync/journal-client.ts +25 -5
- package/apps/studio/sync/migrate-seed.ts +8 -1
- package/apps/studio/sync/status.ts +2 -0
- package/apps/studio/sync/transaction-client.ts +130 -13
- package/apps/studio/ui-prefs.ts +95 -10
- package/apps/studio/whats-new.json +9 -0
- package/apps/studio/ws.ts +19 -4
- package/cli/bin/claude-design-server.mjs +0 -0
- package/package.json +10 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Component as eo,createElement as $e,useCallback as ze,useEffect as Q,useMemo as to,useRef as F,useState as ie}from"react";import{createRoot as no}from"react-dom/client";var Kt=/^[A-Za-z0-9_-]{1,64}$/;function j(e){return typeof e==="string"&&Kt.test(e)}function Ye(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 Be(){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 We(e,t){let n=Be();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 qe(e){let t=Be();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 le(e){if(typeof document>"u"||!j(e))return null;return document.querySelector(`[data-id="${e}"][data-tool]`)}function Xe(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(!j(r))continue;let s=o.getBoundingClientRect();if(s.width<=0&&s.height<=0)continue;if(e<s.left||e>s.right||t<s.top||t>s.bottom)continue;let a=Math.max(1,s.width)*Math.max(1,s.height);if(!n||a<=n.area)n={id:r,area:a}}return n?.id??null}import{useCallback as A,useEffect as H,useMemo as J,useRef as P,useState as z}from"react";function we(){if(typeof window>"u")return;try{let e=window.location.pathname;if(e==="/_canvas-shell.html"||e==="/_canvas-shell"){let t=new URLSearchParams(window.location.search),n=t.get("canvas")??"",o=(t.get("designRel")??".design").replace(/^\/+|\/+$/g,"");return n?`${o}/${n}`:void 0}return decodeURIComponent(e).replace(/^\//,"")}catch{return}}function ae(e){if(!e)return"";return(e.getAttribute("class")??"").trim().split(/\s+/).filter((t)=>t&&!t.startsWith("dgn-")&&!t.startsWith("dc-cv-")).join(" ")}function $t(e,t){if(!e)return"";let n=(e.innerText||e.textContent||"").replace(/\s+/g," ").trim();return n.length>t?`${n.slice(0,t-1)}…`:n}function Qt(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=ae(n).split(/\s+/).filter(Boolean).slice(0,2);if(a.length)s+=`.${a.join(".")}`;let c=1,m=n.previousElementSibling;while(m)c++,m=m.previousElementSibling;s+=`:nth-child(${c})`,t.unshift(s),n=n.parentElement}return t.join(" > ")}function je(e){let t=[],n=e;while(n&&n.nodeType===1&&t.length<8){let o=n.nodeName.toLowerCase(),r=n.getAttribute?.("data-dc-element"),s=n.getAttribute?.("data-dc-screen");if(r)o+=`[data-dc-element="${r}"]`;else if(s)o+=`[data-dc-screen="${s}"]`;else if(n.id)o+=`#${n.id}`;let a=ae(n).split(/\s+/).filter(Boolean).slice(0,2);if(a.length&&!r&&!s)o+=`.${a.join(".")}`;t.unshift(o),n=n.parentElement}return t}function Ft(e){return e.replace(/[^a-zA-Z0-9_-]/g,(t)=>`\\${t}`)}function Ge(e,t){return t?`[data-dc-screen="${t}"] [data-cd-id="${e}"]`:`[data-cd-id="${e}"]`}function Ze(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 Je(e,t,n){if(!t||!n)return 0;return Ze(e,`[data-cd-id="${Ft(t)}"]`,n)}function ve(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(Ge(t.id,t.artboardId));if(o)return o}if(t.selector)return n(t.selector);return null}function Ut(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 et(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;for(let m of Array.from(r.querySelectorAll("[data-cd-id]"))){if(m.tagName.toLowerCase()!==o)continue;let v=Ut(je(m),n);if(v===0)continue;let x=ae(m).split(/\s+/).filter(Boolean),f=s.filter((h)=>x.includes(h)).length,u=v*10+f;if(u>c)c=u,a=m}return a}var Ve=["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","object-fit","aspect-ratio","object-position"],Yt=/^(style|class|data-cd-id|data-dc-|data-dcid$)/;function Bt(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(Ve);for(let u of Ve){let h=t.getPropertyValue(u);if(h)o[u]=h.trim();let d=n.getPropertyValue(u);if(d)r[u]=d.trim()}let a=/^(margin|padding|border)(-|$)/,c={};for(let u=0;u<t.length;u++){let h=t.item(u);if(!h||s.has(h)||a.test(h))continue;let d=t.getPropertyValue(h);if(d)c[h]=d.trim()}let m={};for(let u of Array.from(e.attributes)){if(Yt.test(u.name))continue;m[u.name]=u.value}if(e.hasAttribute("data-dc-screen")){for(let u of Array.from(e.attributes))if(u.name.startsWith("data-dc-")&&u.name!=="data-dcid")m[u.name]=u.value}let v=e.parentElement,x=v?window.getComputedStyle(v).display:"",f=v&&(x==="flex"||x==="inline-flex")?window.getComputedStyle(v).flexDirection:"";return{authored:o,computed:r,customStyles:c,attrs:m,parentDisplay:x,parentFlexDirection:f}}catch{return{authored:{},computed:{},customStyles:{},attrs:{}}}}function xe(e,t){let n=e.el,o=n&&n.getBoundingClientRect?n.getBoundingClientRect():null,r=e.cdId,s=r?Ge(r,e.artboardId):e.artboardId?`[data-dc-screen="${e.artboardId}"]`:Qt(n),a=r&&typeof document<"u"?Ze(document,s,n):0;return{file:t??we(),id:r??void 0,selector:s,artboardId:e.artboardId,index:a,tag:n?.tagName.toLowerCase()??"",classes:ae(n),text:$t(n,240),dom_path:je(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(n.offsetWidth):void 0,worldH:n instanceof HTMLElement?Math.round(n.offsetHeight):void 0,html:n?(n.outerHTML??"").slice(0,4000):"",...(()=>{if(n?.tagName?.toLowerCase()!=="img")return{};let c=/assets\/[0-9a-f]{8}\.[a-z0-9]+/i,m=n.getAttribute?.("data-photo-asset");if(m&&c.test(m))return{photoKind:"artboard-img",photoAsset:m};let v=n.getAttribute?.("src")||"",x=c.exec(v);return x?{photoKind:"artboard-img",photoAsset:x[0]}:{}})(),...Bt(n)}}var ce=null;function G(){if(typeof window>"u")return!1;if(ce===null)try{ce=new URLSearchParams(window.location.search).get("ro")==="1"}catch{ce=!1}return ce}var ue=null;function tt(){if(typeof window>"u")return!1;if(ue===null)try{ue=new URLSearchParams(window.location.search).get("embed")==="1"}catch{ue=!1}return ue}import*as Ee from"lib0/decoding";import*as Z from"lib0/encoding";import{createContext as Xt,useCallback as So,useContext as Vt,useEffect as Co,useMemo as To,useReducer as Lo,useRef as ko,useState as Ro}from"react";import{Awareness as Ao,applyAwarenessUpdate as _o,encodeAwarenessUpdate as Io}from"y-protocols/awareness";import{readSyncMessage as Oo,writeSyncStep1 as Do,writeUpdate as Ho}from"y-protocols/sync";import*as jt from"yjs";import*as Wt from"yjs";var qt=new WeakSet;function nt(e){return qt.add(e),e}var yo=nt(Object.freeze({maudeOrigin:"shell-edit"})),bo=nt(Object.freeze({maudeOrigin:"sync-agent"}));var Gt=Xt(null);function ot(){return Vt(Gt)}import{createContext as Zt,useCallback as q,useContext as Ce,useEffect as Jt,useMemo as en,useRef as rt,useState as tn}from"react";import{jsx as Se,Fragment as rn}from"react/jsx-runtime";var de=Zt(null);function X(e){return e.id?`id:${e.id}`:`sel:${e.selector}`}function it(e){let t=[],n=new Set;for(let o of e){let r=X(o);if(n.has(r))continue;n.add(r),t.push(o)}return t}var nn=50;function on({children:e,postTarget:t}){let[n,o]=tn([]),r=rt(null),s=rt(null),a=q((h)=>{if(r.current)clearTimeout(r.current);s.current=()=>{r.current=null,s.current=null;let d=t??(typeof window<"u"?window.parent:null);if(!d)return;let b=h.length===0?null:h.length===1?h[0]??null:h;try{d.postMessage({dgn:"select-set",selection:b},"*")}catch{}},r.current=setTimeout(()=>s.current?.(),nn)},[t]);Jt(()=>()=>{if(r.current)clearTimeout(r.current);s.current?.()},[]);let c=q((h)=>{let d=it(Array.isArray(h)?h:[h]);o(d),a(d)},[a]),m=q((h)=>{let d=Array.isArray(h)?h:[h];o((b)=>{let S=it([...b,...d]);return a(S),S})},[a]),v=q((h)=>{let d=X(h);o((b)=>{let S=b.filter((i)=>X(i)!==d);return a(S),S})},[a]),x=q((h)=>{let d=X(h);o((b)=>{let S=b.some((i)=>X(i)===d)?b.filter((i)=>X(i)!==d):[...b,h];return a(S),S})},[a]),f=q(()=>{o([]),a([])},[a]),u=en(()=>({selected:n,replace:c,add:m,remove:v,toggle:x,clear:f}),[n,c,m,v,x,f]);return Se(de.Provider,{value:u,children:e})}function st({children:e}){if(Ce(de))return Se(rn,{children:e});return Se(on,{children:e})}function me(){let e=Ce(de);if(!e)throw Error("useSelectionSet must be used inside <SelectionSetProvider>");return e}function lt(){return Ce(de)}import{jsx as R,jsxs as _,Fragment as En}from"react/jsx-runtime";var sn="/_client/comments-overlay.css";function ln(){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=sn,document.head.appendChild(e)}function an(){if(typeof window>"u")return null;try{let e=window.location.pathname;if(e==="/_canvas-shell.html"||e==="/_canvas-shell"){let t=new URLSearchParams(window.location.search),n=t.get("canvas")??"",o=(t.get("designRel")??".design").replace(/^\/+|\/+$/g,"");return n?`${o}/${n}`:null}return decodeURIComponent(e).replace(/^\//,"")}catch{return null}}function cn(e){if(j(e.annotationId))return le(e.annotationId);if(!e.selector)return null;let t=null;try{let n=document.querySelectorAll(e.selector),o=e.index&&e.index>0&&e.index<n.length?e.index:0;t=n[o]??n[0]??null}catch{t=null}if(t&&e.tag&&t.tagName.toLowerCase()!==e.tag.toLowerCase())t=null;if(!t&&e.dom_path?.length){let n=e.selector.match(/data-dc-screen="([^"]+)"/)?.[1];t=et(document,{artboardId:n,tag:e.tag,classes:e.classes,dom_path:e.dom_path})}return t}function ke(e){let t=cn(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 mt(e,t){let o=typeof window<"u"?window.innerWidth:e.x+t.w,r=typeof window<"u"?window.innerHeight:e.y+t.h,s=e.x;if(s+t.w+8>o){let c=e.x-t.w;s=c>=8?c:Math.max(8,o-t.w-8)}let a=e.y;if(a+t.h+8>r){let c=e.y-t.h;a=c>=8?c:Math.max(8,r-t.h-8)}return{x:s,y:a}}function ft(){ln();let e=lt(),[t,n]=z([]),[o,r]=z(null),[s,a]=z(null),c=J(()=>an(),[]);H(()=>{if(typeof document>"u")return;let g=document.getElementById("dgn-pin-layer");if(!g)return;let l=g.style.display;return g.style.display="none",()=>{g.style.display=l}},[]);let m=A((g)=>{if(!e)return;if(!g?.selector){e.clear();return}let l=g.selector.match(/data-cd-id="([^"]+)"/),y=l?l[1]:void 0,T,w;try{let C=document.querySelector(g.selector);if(C)T=C.tagName.toLowerCase(),w=(C.getAttribute("class")??"").split(/\s+/).filter((k)=>k&&!k.startsWith("dgn-")&&!k.startsWith("dc-cv-")).join(" ")}catch{}e.replace({file:c??void 0,id:y,selector:g.selector,tag:T,classes:w,bounds:g.bounds??void 0})},[e,c]),v=P(t);v.current=t;let x=ot(),f=yn();H(()=>{if(!x)return;let g=x.doc.getArray("comments"),l=()=>{n(g.toArray())};if(g.length>0)l();return g.observe(l),()=>{try{g.unobserve(l)}catch{}}},[x]),H(()=>{if(typeof window>"u")return;let g=(l)=>{let y=l.data;if(!y||typeof y!=="object"||!y.dgn)return;if(y.dgn==="comments-set"&&Array.isArray(y.comments))n(y.comments);else if(y.dgn==="comment-focus"){let T=typeof y.id==="string"?y.id:null;r(T);let w=T?v.current.find((C)=>C.id===T):void 0;m(w)}};return window.addEventListener("message",g),()=>window.removeEventListener("message",g)},[m]),H(()=>{if(typeof document>"u")return;let g=(l)=>{let y=l.detail;if(!y?.selection)return;a({selection:y.selection,clientX:typeof y.clientX==="number"?y.clientX:0,clientY:typeof y.clientY==="number"?y.clientY:0})};return document.addEventListener("cm:open-composer",g),()=>document.removeEventListener("cm:open-composer",g)},[]);let u=A(()=>{if(a(null),typeof window>"u")return;try{window.parent.postMessage({dgn:"force-clear"},"*")}catch{}},[]),h=A((g)=>{if(!s)return;let l=s.selection,y={file:l.file,selector:l.selector,index:l.index,dom_path:l.dom_path,tag:l.tag,classes:l.classes,bounds:l.bounds,html_excerpt:l.html,...l.annotationId?{annotationId:l.annotationId}:{},...l.world?{world:l.world}:{},text:g};if(typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-submit",payload:y},"*")}catch{}u()},[s,u]);H(()=>{if(!c)return;let g=!1;return(async()=>{try{let l=await fetch(`/_comments?file=${encodeURIComponent(c)}`);if(!l.ok)return;let y=await l.json();if(g)return;if(Array.isArray(y.comments))n((T)=>T.length===0?y.comments??[]:T)}catch{}})(),()=>{g=!0}},[c]);let d=J(()=>t.slice().sort((l,y)=>l.created.localeCompare(y.created)).filter((l)=>l.status!=="resolved"),[t]),b=J(()=>{let g=new Map;return t.slice().sort((y,T)=>y.created.localeCompare(T.created)).forEach((y,T)=>{g.set(y.id,T+1)}),g},[t]),S=A((g)=>{if(r(g),m(t.find((l)=>l.id===g)),typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-click",id:g},"*")}catch{}},[t,m]),i=A((g,l)=>{if(typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-patch",id:g,patch:l},"*")}catch{}},[]),p=A((g)=>{if(typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-delete",id:g},"*")}catch{}r((l)=>l===g?null:l)},[]),E=A(async(g,l)=>{if(typeof fetch>"u")return!1;try{let y=await fetch(`/_api/comments/${encodeURIComponent(g)}/reply`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({body:l})});if(!y.ok)return!1;let T=await y.json();return n((w)=>w.map((C)=>C.id===T.id?T:C)),!0}catch{return!1}},[]);return _("div",{className:"cm-layer","aria-hidden":!1,children:[d.map((g)=>{let l=b.get(g.id)??0;return R(hn,{comment:g,sequence:l,focused:o===g.id,onClick:S},g.id)}),s?R(gn,{state:s,onSubmit:h,onCancel:u}):null,(()=>{if(!o)return null;let g=d.find((l)=>l.id===o);if(!g)return null;return R(bn,{comment:g,sequence:b.get(g.id)??0,onClose:()=>{r(null),e?.clear()},onPatch:(l)=>i(g.id,l),onDelete:()=>p(g.id),onReply:(l)=>E(g.id,l),mine:!G()&&!!(f??x?.myName)&&(g.author??"").trim()===(f??x?.myName??"").trim()})})()]})}var Te=null;async function un(){if(!Te)Te=(async()=>{try{let e=await fetch("/_api/git-committers");if(!e.ok)return[];let t=await e.json();return Array.isArray(t.committers)?t.committers:[]}catch{return[]}})();return Te}function at(e){return(e.trim().split(/\s+/)[0]??"").replace(/[^\w.-]/g,"").toLowerCase()}function dn(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 Le({className:e,value:t,onChange:n,onKeyDown:o,placeholder:r,rows:s,disabled:a,textareaRef:c,ariaLabel:m}){let v=P(null),x=A((w)=>{if(v.current=w,c)c.current=w},[c]),[f,u]=z([]),[h,d]=z(null),[b,S]=z(0),i=A(()=>{if(f.length>0)return;un().then((w)=>u(w))},[f.length]),p=J(()=>{if(!h)return[];let w=h.query.toLowerCase();return(!w?f:f.filter((k)=>k.name.toLowerCase().includes(w)||k.email.toLowerCase().includes(w))).slice(0,8)},[h,f]),E=A((w)=>{let C=w.selectionStart??w.value.length,k=dn(w.value,C);d(k),S(0)},[]),g=A((w)=>{n(w.target.value),E(w.target)},[n,E]),l=A((w)=>{if(!h)return;let C=v.current;if(!C)return;let k=`@${at(w.name)}`,L=`${t.slice(0,h.start)}${k} ${t.slice(h.end)}`;n(L),d(null);let M=h.start+k.length+1;requestAnimationFrame(()=>{C.focus(),C.setSelectionRange(M,M)})},[h,t,n]),y=A((w)=>{if(h&&p.length>0){if(w.key==="ArrowDown"){w.preventDefault(),S((C)=>(C+1)%p.length);return}if(w.key==="ArrowUp"){w.preventDefault(),S((C)=>(C-1+p.length)%p.length);return}if(w.key==="Enter"||w.key==="Tab"){w.preventDefault();let C=p[b]??p[0];if(C)l(C);return}if(w.key==="Escape"){w.preventDefault(),d(null);return}}o?.(w)},[h,p,b,l,o]),T=A((w)=>{E(w.currentTarget)},[E]);return _("div",{style:{position:"relative"},children:[R("textarea",{ref:x,className:e,value:t,placeholder:r,rows:s,disabled:a,"aria-label":m,onChange:g,onKeyDown:y,onFocus:i,onSelect:T,onClick:T}),h&&p.length>0?R("ul",{className:"cm-mention-popup",role:"listbox","aria-label":"Mention suggestions",style:{left:0,top:"100%"},children:p.map((w,C)=>_("li",{role:"option","aria-selected":C===b,className:"cm-mention-popup__item",onMouseEnter:()=>S(C),onMouseDown:(L)=>{L.preventDefault(),l(w)},children:[_("span",{className:"cm-mention-popup__name",children:["@",at(w.name)]}),R("span",{className:"cm-mention-popup__email",children:w.email})]},`${w.name}-${w.email}`))}):null]})}var mn=3000;function fn(e){return{x:e.x-12,y:e.y-12,w:24,h:24}}function pn(e){let t=!!e.selector||j(e.annotationId);if(t){let r=ke(e);if(r)return{pos:r,missing:!1}}let n=Ye(e.world)?qe(e.world):null;return{pos:n?fn(n):e.bounds??null,missing:t}}function hn({comment:e,sequence:t,focused:n,onClick:o}){let r=P(null),s=P(null),a=P(null),[c,m]=z(!1),v=P(!1);H(()=>{let u=()=>{s.current=null;let h=r.current;if(!h)return;let{pos:d,missing:b}=pn(e),S=!1;if(b){if(a.current==null)a.current=Date.now();S=Date.now()-a.current>mn}else a.current=null;if(S!==v.current)v.current=S,m(S);if(!d){h.style.display="none",s.current=requestAnimationFrame(u);return}h.style.display="grid";let i=Math.round(d.x+d.w-12),p=Math.round(d.y-12);h.style.left=`${i}px`,h.style.top=`${p}px`,s.current=requestAnimationFrame(u)};return s.current=requestAnimationFrame(u),()=>{if(s.current!=null)cancelAnimationFrame(s.current)}},[e]);let x=e.author?.trim()||"unknown",f=`Comment ${t} by ${x}${c?" (detached: its target is gone)":""}`;return R("button",{ref:r,type:"button",className:"cm-pin","data-resolved":e.status==="resolved"?"true":"false","data-focused":n?"true":"false","data-detached":c?"true":"false","data-comment-pin":e.id,"aria-label":f,"aria-expanded":n,title:e.text.slice(0,200),onClick:(u)=>{u.preventDefault(),u.stopPropagation(),o(e.id)},children:t})}function gn({state:e,onSubmit:t,onCancel:n}){let[o,r]=z(""),s=P(null),a=P(null),c=P(null);H(()=>{let f=()=>{c.current=null;let u=a.current;if(!u)return;let h=xn(e),d=mt(h,{w:u.offsetWidth,h:u.offsetHeight});u.style.left=`${Math.round(d.x)}px`,u.style.top=`${Math.round(d.y)}px`,c.current=requestAnimationFrame(f)};return c.current=requestAnimationFrame(f),()=>{if(c.current!=null)cancelAnimationFrame(c.current)}},[e]),H(()=>{s.current?.focus()},[]);let m=A(()=>{let f=o.trim();if(!f)return;t(f)},[o,t]),v=A((f)=>{if(f.key==="Escape"){f.preventDefault(),n();return}if((f.metaKey||f.ctrlKey)&&f.key==="Enter")f.preventDefault(),m()},[n,m]),x=J(()=>{let f=e.selection.selector||"";if(!f)return e.selection.tag||(e.selection.annotationId?"annotation":"canvas");let u=f.match(/data-cd-id="([^"]+)"/);if(u)return`cd:${u[1]}`;return f.length>36?`${f.slice(0,33)}…`:f},[e.selection]);return _("div",{ref:a,className:"cm-composer",role:"dialog","aria-label":"New comment",onClick:(f)=>f.stopPropagation(),onPointerDown:(f)=>f.stopPropagation(),children:[_("div",{className:"cm-composer__head",children:[R("span",{children:"New comment"}),R("span",{className:"cm-composer__selector",children:x})]}),R(Le,{textareaRef:s,className:"cm-composer__textarea",value:o,placeholder:"Type a comment. ⌘↵ to save · Esc to cancel · @name to tag",onChange:r,onKeyDown:v,rows:3,ariaLabel:"Comment body"}),_("div",{className:"cm-composer__actions",children:[R("button",{type:"button",className:"cm-btn",onClick:n,children:"Cancel"}),R("button",{type:"button",className:"cm-btn cm-btn--primary",disabled:!o.trim(),onClick:m,children:"Save"})]})]})}var ct=null;function yn(){let[e,t]=z(null);return H(()=>{if(typeof fetch>"u")return;ct??=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 ct.then((o)=>n&&t(o)),()=>{n=!1}},[]),e}function bn({comment:e,sequence:t,onClose:n,onPatch:o,onDelete:r,onReply:s,mine:a=!1}){let c=P(null),m=P(null),v=P(null),[x,f]=z(""),[u,h]=z(!1),[d,b]=z(null),S=A(()=>{let l=(d??"").trim();if(!l)return;if(l!==e.text)o({text:l});b(null)},[d,e.text,o]);H(()=>{let l=()=>{v.current=null;let y=c.current;if(!y)return;let T=vn(e),w=mt(T,{w:y.offsetWidth,h:y.offsetHeight});y.style.left=`${Math.round(w.x)}px`,y.style.top=`${Math.round(w.y)}px`,v.current=requestAnimationFrame(l)};return v.current=requestAnimationFrame(l),()=>{if(v.current!=null)cancelAnimationFrame(v.current)}},[e]),H(()=>{c.current?.focus();let l=e.id;return()=>{document.querySelector(`[data-comment-pin="${l}"]`)?.focus()}},[e.id]),H(()=>{if(typeof document>"u")return;let l=(y)=>{if(y.key!=="Escape")return;let T=c.current;if(!T)return;if(T.contains(y.target)||document.activeElement===T)y.preventDefault(),n()};return document.addEventListener("keydown",l),()=>document.removeEventListener("keydown",l)},[n]);let i=A(async()=>{let l=x.trim();if(!l||u)return;h(!0);let y=await s(l);if(h(!1),y)f(""),m.current?.focus()},[x,u,s]),p=A((l)=>{if((l.metaKey||l.ctrlKey)&&l.key==="Enter")l.preventDefault(),i()},[i]),E=`cm-thread-head-${e.id}`,g=wn(e.selector,"");return _("div",{ref:c,className:"cm-thread",role:"dialog","aria-labelledby":E,tabIndex:-1,onClick:(l)=>l.stopPropagation(),onPointerDown:(l)=>l.stopPropagation(),children:[_("div",{className:"cm-thread__head",id:E,children:[_("div",{className:"cm-thread__head-row",children:[R("span",{className:"cm-thread__seq","aria-hidden":"true",children:t}),R("span",{className:"cm-thread__author",children:e.author?.trim()||"unknown"}),R("span",{className:"cm-thread__time",children:dt(e.created)}),R("button",{type:"button",className:"cm-thread__close","aria-label":"Close thread",title:"Close · Esc",onClick:n,children:"×"})]}),g?R("code",{className:"cm-thread__selector",children:g}):null]}),d===null?R("div",{className:"cm-thread__body",children:ut(e.text)}):_("div",{className:"cm-thread__reply-form",children:[R(Le,{className:"cm-thread__reply-textarea",value:d,placeholder:"Edit your comment… ⌘↵ to save",onChange:b,onKeyDown:(l)=>{if((l.metaKey||l.ctrlKey)&&l.key==="Enter")l.preventDefault(),S()},rows:3,ariaLabel:"Edit comment"}),_("div",{className:"cm-thread__reply-actions",children:[R("button",{type:"button",className:"cm-btn",onClick:()=>b(null),children:"Cancel"}),R("button",{type:"button",className:"cm-btn cm-btn--primary","data-testid":"comment-edit-save",disabled:!d.trim(),onClick:S,children:"Save"})]})]}),(e.thread??[]).map((l)=>_("div",{className:"cm-thread__reply",children:[_("div",{className:"cm-thread__reply-head",children:[R("span",{className:"cm-thread__reply-author",children:l.author?.trim()||"unknown"}),R("span",{className:"cm-thread__reply-time",children:dt(l.created)})]}),R("div",{className:"cm-thread__reply-body",children:ut(l.body)})]},l.id)),!G()&&_(En,{children:[_("div",{className:"cm-thread__reply-form",children:[R(Le,{textareaRef:m,className:"cm-thread__reply-textarea",value:x,placeholder:"Reply… ⌘↵ to send · @name to tag",onChange:f,onKeyDown:p,rows:2,ariaLabel:"Reply",disabled:u}),R("div",{className:"cm-thread__reply-actions",children:R("button",{type:"button",className:"cm-btn cm-btn--primary",disabled:!x.trim()||u,onClick:()=>void i(),children:"Send"})})]}),_("div",{className:"cm-thread__actions",children:[a&&d===null?R("button",{type:"button",className:"cm-btn","data-testid":"comment-edit",onClick:()=>b(e.text),children:"Edit"}):null,e.status==="resolved"?R("button",{type:"button",className:"cm-btn",onClick:()=>o({status:"open"}),children:"↺ Reopen"}):R("button",{type:"button",className:"cm-btn cm-btn--primary",onClick:()=>{o({status:"resolved"}),n()},children:"✓ Resolve"}),R("button",{type:"button",className:"cm-btn cm-btn--danger",onClick:()=>{r(),n()},children:"Delete"})]})]})]})}function ut(e){if(!e)return null;let t=/(@[\w][\w.-]*)/g;return e.split(t).map((o,r)=>{let s=`${r}:${o}`;if(r%2===1)return R("strong",{"data-mention":"true",children:o},s);return R("span",{children:o},s)})}function dt(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 wn(e,t){if(!e)return t;let n=e.match(/data-cd-id="([^"]+)"/);if(n)return`cd:${n[1]}`;return e.length>36?`${e.slice(0,33)}…`:e}function vn(e){let t=e.selector?ke(e):null;if(t)return{x:t.x+t.w-12,y:t.y+16};if(e.bounds)return{x:e.bounds.x+e.bounds.w-12,y:e.bounds.y+16};return{x:16,y:16}}function xn(e){if(e.clientX||e.clientY)return{x:e.clientX,y:e.clientY+8};if(e.selection.selector){let t=ke(e.selection);if(t)return{x:t.x,y:t.y+t.h+8}}return{x:16,y:16}}import{useEffect as Sn}from"react";var Cn=new Set(["pen","highlighter","shape","rect","ellipse","arrow","sticky","text","section","eraser"]);function Re(e){return Cn.has(e)}var ee=(e)=>!!(e.metaKey||e.ctrlKey);function te(e){if(e.type==="keydown"){if(e.isEditable)return{kind:"no-op"};if(e.metaKey||e.ctrlKey||e.altKey){if(e.key==="Escape")return{kind:"escape"};let n=(e.key||"").toLowerCase();if(!e.altKey&&(e.metaKey||e.ctrlKey)){if(n==="z"&&e.shiftKey)return{kind:"redo"};if(n==="z")return{kind:"undo"};if(n==="y"&&!e.shiftKey)return{kind:"redo"}}return{kind:"no-op"}}let t=(e.key||"").toLowerCase();if(t==="v")return{kind:"tool",tool:"move"};if(t==="h")return{kind:"tool",tool:"hand"};if(t==="c")return{kind:"tool",tool:"comment"};if(t==="b")return{kind:"tool",tool:"pen"};if(t==="i")return{kind:"tool",tool:"highlighter"};if(t==="r"||t==="o")return{kind:"tool",tool:"shape"};if(t==="a")return{kind:"tool",tool:"arrow"};if(t==="n")return{kind:"tool",tool:"sticky"};if(t==="t")return{kind:"tool",tool:"text"};if(t==="s"&&e.shiftKey)return{kind:"tool",tool:"section"};if(t==="e")return{kind:"tool",tool:"eraser"};if(e.key==="Escape")return{kind:"escape"};return{kind:"no-op"}}if(e.type==="contextmenu")return{kind:"context-menu",clientX:e.clientX??0,clientY:e.clientY??0};if(e.type==="pointermove"){if(Re(e.activeTool))return{kind:"no-op"};if(e.activeTool==="hand")return{kind:"no-op"};if(e.activeTool==="browse"){if(!ee(e))return{kind:"no-op"};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:ee(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(Re(e.activeTool)&&!ee(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==="browse"){if(!ee(e))return{kind:"no-op"};return{kind:"select",mode:e.shiftKey?"add":"replace",deep:!0,clientX:e.clientX??0,clientY:e.clientY??0}}let t=ee(e);return{kind:"select",mode:!!e.shiftKey?"add":"replace",deep:t,clientX:e.clientX??0,clientY:e.clientY??0}}return{kind:"no-op"}}function fe(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 ne(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], .dc-tool-palette, .dc-zoom-tb, .dc-mm, .dc-context-menu")}function ht(e){if(!e||typeof e.closest!=="function")return!1;let t=e;return!!t.closest("[data-dc-screen]")&&!t.closest(".dc-artboard-body")}function pt(e,t,n){return e.kind==="select"&&!n.metaKey&&!n.ctrlKey&&ht(t)}function Tn(e,t,n){return e==="select"&&!n.metaKey&&!n.ctrlKey&&ht(t)}function gt(e){let{hostRef:t,getActiveTool:n,isSpaceHeld:o,callbacks:r,enabled:s=!0,claimableActions:a}=e;Sn(()=>{if(!s)return;let c=t.current;if(!c)return;let m=(i)=>a&&i.kind!=="no-op"&&!a.has(i.kind)?{kind:"no-op"}:i,v=(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":r.onEscape?.();break;case"undo":r.onUndo?.();break;case"redo":r.onRedo?.();break;case"no-op":break}},x=(i)=>{let p=m(te({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()}));v(p)},f=(i)=>{if(ne(i.target))return;if(fe(i.target))return;let p=m(te({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()})),E=pt(p,i.target,i);if(p.kind!=="no-op"){if(i.preventDefault(),!E)i.stopImmediatePropagation()}v(p)},u=(i)=>{if(ne(i.target))return;if(fe(i.target))return;let p=m(te({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()})),E=pt(p,i.target,i);if(p.kind!=="no-op"){if(i.preventDefault(),!E)i.stopImmediatePropagation();if(p.kind==="select")try{window.focus()}catch{}}},h=(i)=>{if(ne(i.target))return;if(fe(i.target))return;let p=n(),E=i.metaKey||i.ctrlKey,g=p==="comment"?"drop-comment":p==="move"&&i.button===0?"select":(Re(p)||p==="browse")&&E&&i.button===0?"select":i.button===2?"context-menu":null;if(g&&(!a||a.has(g))){let l=Tn(g,i.target,i);if(i.preventDefault(),!l)i.stopImmediatePropagation()}},d=(i)=>{let p=m(te({type:"contextmenu",clientX:i.clientX,clientY:i.clientY,metaKey:i.metaKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,altKey:i.altKey,activeTool:n()}));if(p.kind==="no-op")return;i.preventDefault(),i.stopImmediatePropagation(),v(p)},b=(i)=>{let p=m(te({type:"keydown",key:i.key,metaKey:i.metaKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,altKey:i.altKey,isEditable:fe(i.target),activeTool:n()}));if(p.kind==="tool"||p.kind==="escape"&&!tt()||p.kind==="undo"||p.kind==="redo")i.preventDefault();v(p)};c.addEventListener("pointermove",x,{passive:!0}),c.addEventListener("pointerdown",f,{capture:!0}),c.addEventListener("mousedown",u,{capture:!0}),c.addEventListener("click",h,{capture:!0}),c.addEventListener("contextmenu",d,{capture:!0});let S=c.ownerDocument??document;return S.addEventListener("keydown",b,!0),()=>{c.removeEventListener("pointermove",x),c.removeEventListener("pointerdown",f,{capture:!0}),c.removeEventListener("mousedown",u,{capture:!0}),c.removeEventListener("click",h,{capture:!0}),c.removeEventListener("contextmenu",d,{capture:!0}),S.removeEventListener("keydown",b,!0)}},[s,t,n,o,r,a])}function Me(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 u=r.getAttribute?.("data-cd-id")??null;return{el:r,cdId:u,artboardId:a}}let m=r,v=null;while(m&&m!==c){if(m.hasAttribute?.("data-cd-id"))v=m;m=m.parentElement}let x=v??r,f=x.getAttribute?.("data-cd-id")??null;return{el:x,cdId:f,artboardId:a}}import{useCallback as Qn,useEffect as Ct,useRef as ge}from"react";var Ln=!1;function yt(){return Ln}import{createContext as Dn,useCallback as re,useContext as Et,useEffect as Ne,useMemo as wt,useRef as Oe,useState as pe}from"react";function U(e,t,n,o){return`url("data:image/svg+xml,${encodeURIComponent(e.trim())}") ${t} ${n}, ${o}`}var _e="width='24' height='24' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'",Ie="#1f1f1f",Ae="stroke='#ffffff' stroke-linejoin='round' stroke-linecap='round'";function B(e,t,n){let o=n?`<g transform='${n}'>`:"";return`<svg ${_e}>${o}<path fill='#ffffff' d='${e}'/><path fill='${Ie}' d='${t}'/>${n?"</g>":""}</svg>`}var bt="translate(0,32) scale(1,-1)",kn=U(B("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"),Rn=U(B("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"),Mn=U(B("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"),An=U(B("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",bt),6,18,"crosshair"),_n=U(B("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",bt),6,18,"crosshair"),oe=U(B("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"),In=U(B("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"),Nn=U(`<svg ${_e}><path d='M16 4V28M11 4H21M11 28H21' fill='none' ${Ae} stroke-width='5'/><path d='M16 4V28M11 4H21M11 28H21' fill='none' stroke='${Ie}' stroke-width='2.25' stroke-linecap='round'/></svg>`,12,12,"text"),On=U(`<svg ${_e}><path d='M6 5H21L26 10V27H6Z' fill='${Ie}' ${Ae} stroke-width='2.5'/><path d='M21 5V11H26' fill='none' ${Ae} stroke-width='2.25'/></svg>`,5,5,"crosshair"),O=Object.freeze({browse:"default",move:kn,hand:Rn,comment:Mn,pen:An,section:oe,highlighter:_n,shape:oe,rect:oe,ellipse:oe,sticky:On,arrow:oe,text:Nn,eraser:In});import{jsx as He,Fragment as $n}from"react/jsx-runtime";var De="maude:tool-sync",vt=Object.freeze({preview:"browse",edit:"move"});function xt(e){if(e==="browse")return"preview";if(e==="move")return"edit";return null}var Hn=Object.freeze([{id:"browse",label:"Browse",shortcut:"",cursor:O.browse},{id:"move",label:"Select",shortcut:"V",cursor:O.move},{id:"hand",label:"Hand",shortcut:"H",cursor:O.hand},{id:"comment",label:"Comment",shortcut:"C",cursor:O.comment},{id:"pen",label:"Pen",shortcut:"B",cursor:O.pen},{id:"highlighter",label:"Highlighter",shortcut:"I",cursor:O.highlighter},{id:"shape",label:"Shape",shortcut:"R",cursor:O.shape},{id:"sticky",label:"Sticky",shortcut:"N",cursor:O.sticky},{id:"section",label:"Section",shortcut:"⇧S",cursor:O.shape},{id:"arrow",label:"Arrow",shortcut:"A",cursor:O.arrow},{id:"text",label:"Text",shortcut:"T",cursor:O.text},{id:"eraser",label:"Eraser",shortcut:"E",cursor:O.eraser}]),Pn=new Set(["browse","move","hand"]);function zn(e,t){return t?e.filter((n)=>Pn.has(n.id)):e}var Pe=Dn(null);function Kn({children:e,tools:t=Hn,initial:n,initialMode:o}){let r=G(),s=wt(()=>zn(t,r),[t,r]),a=n??(r?"browse":"move"),c=o??xt(a)??(r?"preview":"edit"),[m,v]=pe(a),[x,f]=pe(c),[u,h]=pe(()=>({tool:null,locked:!1})),d=re((C)=>{if(!s.some((L)=>L.id===C))return;v(C);let k=xt(C);if(k)f(k);h((L)=>L.locked&&L.tool===C?L:{tool:null,locked:!1})},[s]),b=re((C)=>{let k=vt[C];if(!s.some((L)=>L.id===k))return;f(C),v(k),h((L)=>L.locked&&L.tool===k?L:{tool:null,locked:!1})},[s]),S=re(()=>{d(vt[x])},[x,d]),i=re((C)=>{h((k)=>{if(k.locked&&k.tool===C)return{tool:null,locked:!1};return{tool:C,locked:!0}}),v(C)},[]),p=re(()=>{h({tool:null,locked:!1})},[]),[E,g]=pe("rounded"),l=Oe(Math.random().toString(36).slice(2)),y=Oe(m);y.current=m;let T=Oe(!1);Ne(()=>{if(!T.current){T.current=!0;return}if(typeof document>"u")return;document.dispatchEvent(new CustomEvent(De,{detail:{tool:m,from:l.current}}))},[m]),Ne(()=>{if(typeof document>"u")return;let C=(k)=>{let L=k.detail;if(!L||L.from===l.current||typeof L.tool!=="string")return;if(L.tool===y.current)return;d(L.tool)};return document.addEventListener(De,C),()=>document.removeEventListener(De,C)},[d]),Ne(()=>{if(typeof document>"u")return;let C=s.find((M)=>M.id===m);if(!C)return;let k=document.body.style.cursor,L=document.getElementById("dc-tool-cursor");if(!L)L=document.createElement("style"),L.id="dc-tool-cursor",document.head.appendChild(L);if(m==="browse"){if(document.body.style.cursor="",L.textContent="",typeof window<"u"&&window.parent&&window.parent!==window)try{window.parent.postMessage({dgn:"tool-cursor",tool:m},"*")}catch{}return()=>{document.body.style.cursor=k}}if(document.body.style.cursor=C.cursor,L.textContent=`* { cursor: ${C.cursor} !important; }`,typeof window<"u"&&window.parent&&window.parent!==window)try{window.parent.postMessage({dgn:"tool-cursor",tool:m},"*")}catch{}return()=>{document.body.style.cursor=k;let M=document.getElementById("dc-tool-cursor");if(M)M.textContent=""}},[m,s]);let w=wt(()=>({tool:m,setTool:d,tools:s,mode:x,setMode:b,resetTool:S,sticky:u,toggleSticky:i,clearSticky:p,shapeKind:E,setShapeKind:g}),[m,d,s,x,b,S,u,i,p,E]);return He(Pe.Provider,{value:w,children:e})}function St({children:e,initial:t,initialMode:n}){if(Et(Pe))return He($n,{children:e});return He(Kn,{initial:t,initialMode:n,children:e})}function he(){let e=Et(Pe);if(!e)throw Error("useToolMode must be used inside <ToolProvider>");return e}import{jsx as Jn}from"react/jsx-runtime";var Fn=`
|
|
1
|
+
import{Component as eo,createElement as $e,useCallback as ze,useEffect as Q,useMemo as to,useRef as F,useState as ie}from"react";import{createRoot as no}from"react-dom/client";var Kt=/^[A-Za-z0-9_-]{1,64}$/;function j(e){return typeof e==="string"&&Kt.test(e)}function Ye(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 Be(){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 We(e,t){let n=Be();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 qe(e){let t=Be();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 le(e){if(typeof document>"u"||!j(e))return null;return document.querySelector(`[data-id="${e}"][data-tool]`)}function Xe(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(!j(r))continue;let s=o.getBoundingClientRect();if(s.width<=0&&s.height<=0)continue;if(e<s.left||e>s.right||t<s.top||t>s.bottom)continue;let a=Math.max(1,s.width)*Math.max(1,s.height);if(!n||a<=n.area)n={id:r,area:a}}return n?.id??null}import{useCallback as A,useEffect as H,useMemo as J,useRef as P,useState as z}from"react";function we(){if(typeof window>"u")return;try{let e=window.location.pathname;if(e==="/_canvas-shell.html"||e==="/_canvas-shell"){let t=new URLSearchParams(window.location.search),n=t.get("canvas")??"",o=(t.get("designRel")??".design").replace(/^\/+|\/+$/g,"");return n?`${o}/${n}`:void 0}return decodeURIComponent(e).replace(/^\//,"")}catch{return}}function ae(e){if(!e)return"";return(e.getAttribute("class")??"").trim().split(/\s+/).filter((t)=>t&&!t.startsWith("dgn-")&&!t.startsWith("dc-cv-")).join(" ")}function $t(e,t){if(!e)return"";let n=(e.innerText||e.textContent||"").replace(/\s+/g," ").trim();return n.length>t?`${n.slice(0,t-1)}…`:n}function Qt(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=ae(n).split(/\s+/).filter(Boolean).slice(0,2);if(a.length)s+=`.${a.join(".")}`;let c=1,m=n.previousElementSibling;while(m)c++,m=m.previousElementSibling;s+=`:nth-child(${c})`,t.unshift(s),n=n.parentElement}return t.join(" > ")}function je(e){let t=[],n=e;while(n&&n.nodeType===1&&t.length<8){let o=n.nodeName.toLowerCase(),r=n.getAttribute?.("data-dc-element"),s=n.getAttribute?.("data-dc-screen");if(r)o+=`[data-dc-element="${r}"]`;else if(s)o+=`[data-dc-screen="${s}"]`;else if(n.id)o+=`#${n.id}`;let a=ae(n).split(/\s+/).filter(Boolean).slice(0,2);if(a.length&&!r&&!s)o+=`.${a.join(".")}`;t.unshift(o),n=n.parentElement}return t}function Ft(e){return e.replace(/[^a-zA-Z0-9_-]/g,(t)=>`\\${t}`)}function Ge(e,t){return t?`[data-dc-screen="${t}"] [data-cd-id="${e}"]`:`[data-cd-id="${e}"]`}function Ze(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 Je(e,t,n){if(!t||!n)return 0;return Ze(e,`[data-cd-id="${Ft(t)}"]`,n)}function ve(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(Ge(t.id,t.artboardId));if(o)return o}if(t.selector)return n(t.selector);return null}function Ut(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 et(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;for(let m of Array.from(r.querySelectorAll("[data-cd-id]"))){if(m.tagName.toLowerCase()!==o)continue;let v=Ut(je(m),n);if(v===0)continue;let x=ae(m).split(/\s+/).filter(Boolean),f=s.filter((h)=>x.includes(h)).length,u=v*10+f;if(u>c)c=u,a=m}return a}var Ve=["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","object-fit","aspect-ratio","object-position"],Yt=/^(style|class|data-cd-id|data-dc-|data-dcid$)/;function Bt(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(Ve);for(let u of Ve){let h=t.getPropertyValue(u);if(h)o[u]=h.trim();let d=n.getPropertyValue(u);if(d)r[u]=d.trim()}let a=/^(margin|padding|border)(-|$)/,c={};for(let u=0;u<t.length;u++){let h=t.item(u);if(!h||s.has(h)||a.test(h))continue;let d=t.getPropertyValue(h);if(d)c[h]=d.trim()}let m={};for(let u of Array.from(e.attributes)){if(Yt.test(u.name))continue;m[u.name]=u.value}if(e.hasAttribute("data-dc-screen")){for(let u of Array.from(e.attributes))if(u.name.startsWith("data-dc-")&&u.name!=="data-dcid")m[u.name]=u.value}let v=e.parentElement,x=v?window.getComputedStyle(v).display:"",f=v&&(x==="flex"||x==="inline-flex")?window.getComputedStyle(v).flexDirection:"";return{authored:o,computed:r,customStyles:c,attrs:m,parentDisplay:x,parentFlexDirection:f}}catch{return{authored:{},computed:{},customStyles:{},attrs:{}}}}function xe(e,t){let n=e.el,o=n&&n.getBoundingClientRect?n.getBoundingClientRect():null,r=e.cdId,s=r?Ge(r,e.artboardId):e.artboardId?`[data-dc-screen="${e.artboardId}"]`:Qt(n),a=r&&typeof document<"u"?Ze(document,s,n):0;return{file:t??we(),id:r??void 0,selector:s,artboardId:e.artboardId,index:a,tag:n?.tagName.toLowerCase()??"",classes:ae(n),text:$t(n,240),dom_path:je(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(n.offsetWidth):void 0,worldH:n instanceof HTMLElement?Math.round(n.offsetHeight):void 0,html:n?(n.outerHTML??"").slice(0,4000):"",...(()=>{if(n?.tagName?.toLowerCase()!=="img")return{};let c=/assets\/[0-9a-f]{8}\.[a-z0-9]+/i,m=n.getAttribute?.("data-photo-asset");if(m&&c.test(m))return{photoKind:"artboard-img",photoAsset:m};let v=n.getAttribute?.("src")||"",x=c.exec(v);return x?{photoKind:"artboard-img",photoAsset:x[0]}:{}})(),...Bt(n)}}var ce=null;function G(){if(typeof window>"u")return!1;if(ce===null)try{ce=new URLSearchParams(window.location.search).get("ro")==="1"}catch{ce=!1}return ce}var ue=null;function tt(){if(typeof window>"u")return!1;if(ue===null)try{ue=new URLSearchParams(window.location.search).get("embed")==="1"}catch{ue=!1}return ue}import*as Ee from"lib0/decoding";import*as Z from"lib0/encoding";import{createContext as Xt,useCallback as So,useContext as Vt,useEffect as Co,useMemo as To,useReducer as Lo,useRef as ko,useState as Ro}from"react";import{Awareness as Ao,applyAwarenessUpdate as _o,encodeAwarenessUpdate as Io}from"y-protocols/awareness";import{readSyncMessage as Oo,writeSyncStep1 as Do,writeUpdate as Ho}from"y-protocols/sync";import*as jt from"yjs";import*as Wt from"yjs";var qt=new WeakSet;function nt(e){return qt.add(e),e}var yo=nt(Object.freeze({maudeOrigin:"shell-edit"})),bo=nt(Object.freeze({maudeOrigin:"sync-agent"}));var Gt=Xt(null);function ot(){return Vt(Gt)}import{createContext as Zt,useCallback as q,useContext as Ce,useEffect as Jt,useMemo as en,useRef as rt,useState as tn}from"react";import{jsx as Se,Fragment as rn}from"react/jsx-runtime";var de=Zt(null);function X(e){return e.id?`id:${e.id}`:`sel:${e.selector}`}function it(e){let t=[],n=new Set;for(let o of e){let r=X(o);if(n.has(r))continue;n.add(r),t.push(o)}return t}var nn=50;function on({children:e,postTarget:t}){let[n,o]=tn([]),r=rt(null),s=rt(null),a=q((h)=>{if(r.current)clearTimeout(r.current);s.current=()=>{r.current=null,s.current=null;let d=t??(typeof window<"u"?window.parent:null);if(!d)return;let w=h.length===0?null:h.length===1?h[0]??null:h;try{d.postMessage({dgn:"select-set",selection:w},"*")}catch{}},r.current=setTimeout(()=>s.current?.(),nn)},[t]);Jt(()=>()=>{if(r.current)clearTimeout(r.current);s.current?.()},[]);let c=q((h)=>{let d=it(Array.isArray(h)?h:[h]);o(d),a(d)},[a]),m=q((h)=>{let d=Array.isArray(h)?h:[h];o((w)=>{let S=it([...w,...d]);return a(S),S})},[a]),v=q((h)=>{let d=X(h);o((w)=>{let S=w.filter((i)=>X(i)!==d);return a(S),S})},[a]),x=q((h)=>{let d=X(h);o((w)=>{let S=w.some((i)=>X(i)===d)?w.filter((i)=>X(i)!==d):[...w,h];return a(S),S})},[a]),f=q(()=>{o([]),a([])},[a]),u=en(()=>({selected:n,replace:c,add:m,remove:v,toggle:x,clear:f}),[n,c,m,v,x,f]);return Se(de.Provider,{value:u,children:e})}function st({children:e}){if(Ce(de))return Se(rn,{children:e});return Se(on,{children:e})}function me(){let e=Ce(de);if(!e)throw Error("useSelectionSet must be used inside <SelectionSetProvider>");return e}function lt(){return Ce(de)}import{jsx as R,jsxs as _,Fragment as En}from"react/jsx-runtime";var sn="/_client/comments-overlay.css";function ln(){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=sn,document.head.appendChild(e)}function an(){if(typeof window>"u")return null;try{let e=window.location.pathname;if(e==="/_canvas-shell.html"||e==="/_canvas-shell"){let t=new URLSearchParams(window.location.search),n=t.get("canvas")??"",o=(t.get("designRel")??".design").replace(/^\/+|\/+$/g,"");return n?`${o}/${n}`:null}return decodeURIComponent(e).replace(/^\//,"")}catch{return null}}function cn(e){if(j(e.annotationId))return le(e.annotationId);if(!e.selector)return null;let t=null;try{let n=document.querySelectorAll(e.selector),o=e.index&&e.index>0&&e.index<n.length?e.index:0;t=n[o]??n[0]??null}catch{t=null}if(t&&e.tag&&t.tagName.toLowerCase()!==e.tag.toLowerCase())t=null;if(!t&&e.dom_path?.length){let n=e.selector.match(/data-dc-screen="([^"]+)"/)?.[1];t=et(document,{artboardId:n,tag:e.tag,classes:e.classes,dom_path:e.dom_path})}return t}function ke(e){let t=cn(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 mt(e,t){let o=typeof window<"u"?window.innerWidth:e.x+t.w,r=typeof window<"u"?window.innerHeight:e.y+t.h,s=e.x;if(s+t.w+8>o){let c=e.x-t.w;s=c>=8?c:Math.max(8,o-t.w-8)}let a=e.y;if(a+t.h+8>r){let c=e.y-t.h;a=c>=8?c:Math.max(8,r-t.h-8)}return{x:s,y:a}}function ft(){ln();let e=lt(),[t,n]=z([]),[o,r]=z(null),[s,a]=z(null),c=J(()=>an(),[]);H(()=>{if(typeof document>"u")return;let g=document.getElementById("dgn-pin-layer");if(!g)return;let l=g.style.display;return g.style.display="none",()=>{g.style.display=l}},[]);let m=A((g)=>{if(!e)return;if(!g?.selector){e.clear();return}let l=g.selector.match(/data-cd-id="([^"]+)"/),y=l?l[1]:void 0,T,b;try{let C=document.querySelector(g.selector);if(C)T=C.tagName.toLowerCase(),b=(C.getAttribute("class")??"").split(/\s+/).filter((k)=>k&&!k.startsWith("dgn-")&&!k.startsWith("dc-cv-")).join(" ")}catch{}e.replace({file:c??void 0,id:y,selector:g.selector,tag:T,classes:b,bounds:g.bounds??void 0})},[e,c]),v=P(t);v.current=t;let x=ot(),f=yn();H(()=>{if(!x)return;let g=x.doc.getArray("comments"),l=()=>{n(g.toArray())};if(g.length>0)l();return g.observe(l),()=>{try{g.unobserve(l)}catch{}}},[x]),H(()=>{if(typeof window>"u")return;let g=(l)=>{let y=l.data;if(!y||typeof y!=="object"||!y.dgn)return;if(y.dgn==="comments-set"&&Array.isArray(y.comments))n(y.comments);else if(y.dgn==="comment-focus"){let T=typeof y.id==="string"?y.id:null;r(T);let b=T?v.current.find((C)=>C.id===T):void 0;m(b)}};return window.addEventListener("message",g),()=>window.removeEventListener("message",g)},[m]),H(()=>{if(typeof document>"u")return;let g=(l)=>{let y=l.detail;if(!y?.selection)return;a({selection:y.selection,clientX:typeof y.clientX==="number"?y.clientX:0,clientY:typeof y.clientY==="number"?y.clientY:0})};return document.addEventListener("cm:open-composer",g),()=>document.removeEventListener("cm:open-composer",g)},[]);let u=A(()=>{if(a(null),typeof window>"u")return;try{window.parent.postMessage({dgn:"force-clear"},"*")}catch{}},[]),h=A((g)=>{if(!s)return;let l=s.selection,y={file:l.file,selector:l.selector,index:l.index,dom_path:l.dom_path,tag:l.tag,classes:l.classes,bounds:l.bounds,html_excerpt:l.html,...l.annotationId?{annotationId:l.annotationId}:{},...l.world?{world:l.world}:{},text:g};if(typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-submit",payload:y},"*")}catch{}u()},[s,u]);H(()=>{if(!c)return;let g=!1;return(async()=>{try{let l=await fetch(`/_comments?file=${encodeURIComponent(c)}`);if(!l.ok)return;let y=await l.json();if(g)return;if(Array.isArray(y.comments))n((T)=>T.length===0?y.comments??[]:T)}catch{}})(),()=>{g=!0}},[c]);let d=J(()=>t.slice().sort((l,y)=>l.created.localeCompare(y.created)).filter((l)=>l.status!=="resolved"),[t]),w=J(()=>{let g=new Map;return t.slice().sort((y,T)=>y.created.localeCompare(T.created)).forEach((y,T)=>{g.set(y.id,T+1)}),g},[t]),S=A((g)=>{if(r(g),m(t.find((l)=>l.id===g)),typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-click",id:g},"*")}catch{}},[t,m]),i=A((g,l)=>{if(typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-patch",id:g,patch:l},"*")}catch{}},[]),p=A((g)=>{if(typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-delete",id:g},"*")}catch{}r((l)=>l===g?null:l)},[]),E=A(async(g,l)=>{if(typeof fetch>"u")return!1;try{let y=await fetch(`/_api/comments/${encodeURIComponent(g)}/reply`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({body:l})});if(!y.ok)return!1;let T=await y.json();return n((b)=>b.map((C)=>C.id===T.id?T:C)),!0}catch{return!1}},[]);return _("div",{className:"cm-layer","aria-hidden":!1,children:[d.map((g)=>{let l=w.get(g.id)??0;return R(hn,{comment:g,sequence:l,focused:o===g.id,onClick:S},g.id)}),s?R(gn,{state:s,onSubmit:h,onCancel:u}):null,(()=>{if(!o)return null;let g=d.find((l)=>l.id===o);if(!g)return null;return R(bn,{comment:g,sequence:w.get(g.id)??0,onClose:()=>{r(null),e?.clear()},onPatch:(l)=>i(g.id,l),onDelete:()=>p(g.id),onReply:(l)=>E(g.id,l),mine:!G()&&!!(f??x?.myName)&&(g.author??"").trim()===(f??x?.myName??"").trim()})})()]})}var Te=null;async function un(){if(!Te)Te=(async()=>{try{let e=await fetch("/_api/git-committers");if(!e.ok)return[];let t=await e.json();return Array.isArray(t.committers)?t.committers:[]}catch{return[]}})();return Te}function at(e){return(e.trim().split(/\s+/)[0]??"").replace(/[^\w.-]/g,"").toLowerCase()}function dn(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 Le({className:e,value:t,onChange:n,onKeyDown:o,placeholder:r,rows:s,disabled:a,textareaRef:c,ariaLabel:m}){let v=P(null),x=A((b)=>{if(v.current=b,c)c.current=b},[c]),[f,u]=z([]),[h,d]=z(null),[w,S]=z(0),i=A(()=>{if(f.length>0)return;un().then((b)=>u(b))},[f.length]),p=J(()=>{if(!h)return[];let b=h.query.toLowerCase();return(!b?f:f.filter((k)=>k.name.toLowerCase().includes(b)||(k.email??"").toLowerCase().includes(b))).slice(0,8)},[h,f]),E=A((b)=>{let C=b.selectionStart??b.value.length,k=dn(b.value,C);d(k),S(0)},[]),g=A((b)=>{n(b.target.value),E(b.target)},[n,E]),l=A((b)=>{if(!h)return;let C=v.current;if(!C)return;let k=`@${at(b.name)}`,L=`${t.slice(0,h.start)}${k} ${t.slice(h.end)}`;n(L),d(null);let M=h.start+k.length+1;requestAnimationFrame(()=>{C.focus(),C.setSelectionRange(M,M)})},[h,t,n]),y=A((b)=>{if(h&&p.length>0){if(b.key==="ArrowDown"){b.preventDefault(),S((C)=>(C+1)%p.length);return}if(b.key==="ArrowUp"){b.preventDefault(),S((C)=>(C-1+p.length)%p.length);return}if(b.key==="Enter"||b.key==="Tab"){b.preventDefault();let C=p[w]??p[0];if(C)l(C);return}if(b.key==="Escape"){b.preventDefault(),d(null);return}}o?.(b)},[h,p,w,l,o]),T=A((b)=>{E(b.currentTarget)},[E]);return _("div",{style:{position:"relative"},children:[R("textarea",{ref:x,className:e,value:t,placeholder:r,rows:s,disabled:a,"aria-label":m,onChange:g,onKeyDown:y,onFocus:i,onSelect:T,onClick:T}),h&&p.length>0?R("ul",{className:"cm-mention-popup",role:"listbox","aria-label":"Mention suggestions",style:{left:0,top:"100%"},children:p.map((b,C)=>_("li",{role:"option","aria-selected":C===w,className:"cm-mention-popup__item",onMouseEnter:()=>S(C),onMouseDown:(L)=>{L.preventDefault(),l(b)},children:[_("span",{className:"cm-mention-popup__name",children:["@",at(b.name)]}),b.email?R("span",{className:"cm-mention-popup__email",children:b.email}):null]},`${b.name}-${b.email??""}`))}):null]})}var mn=3000;function fn(e){return{x:e.x-12,y:e.y-12,w:24,h:24}}function pn(e){let t=!!e.selector||j(e.annotationId);if(t){let r=ke(e);if(r)return{pos:r,missing:!1}}let n=Ye(e.world)?qe(e.world):null;return{pos:n?fn(n):e.bounds??null,missing:t}}function hn({comment:e,sequence:t,focused:n,onClick:o}){let r=P(null),s=P(null),a=P(null),[c,m]=z(!1),v=P(!1);H(()=>{let u=()=>{s.current=null;let h=r.current;if(!h)return;let{pos:d,missing:w}=pn(e),S=!1;if(w){if(a.current==null)a.current=Date.now();S=Date.now()-a.current>mn}else a.current=null;if(S!==v.current)v.current=S,m(S);if(!d){h.style.display="none",s.current=requestAnimationFrame(u);return}h.style.display="grid";let i=Math.round(d.x+d.w-12),p=Math.round(d.y-12);h.style.left=`${i}px`,h.style.top=`${p}px`,s.current=requestAnimationFrame(u)};return s.current=requestAnimationFrame(u),()=>{if(s.current!=null)cancelAnimationFrame(s.current)}},[e]);let x=e.author?.trim()||"unknown",f=`Comment ${t} by ${x}${c?" (detached: its target is gone)":""}`;return R("button",{ref:r,type:"button",className:"cm-pin","data-resolved":e.status==="resolved"?"true":"false","data-focused":n?"true":"false","data-detached":c?"true":"false","data-comment-pin":e.id,"aria-label":f,"aria-expanded":n,title:e.text.slice(0,200),onClick:(u)=>{u.preventDefault(),u.stopPropagation(),o(e.id)},children:t})}function gn({state:e,onSubmit:t,onCancel:n}){let[o,r]=z(""),s=P(null),a=P(null),c=P(null);H(()=>{let f=()=>{c.current=null;let u=a.current;if(!u)return;let h=xn(e),d=mt(h,{w:u.offsetWidth,h:u.offsetHeight});u.style.left=`${Math.round(d.x)}px`,u.style.top=`${Math.round(d.y)}px`,c.current=requestAnimationFrame(f)};return c.current=requestAnimationFrame(f),()=>{if(c.current!=null)cancelAnimationFrame(c.current)}},[e]),H(()=>{s.current?.focus()},[]);let m=A(()=>{let f=o.trim();if(!f)return;t(f)},[o,t]),v=A((f)=>{if(f.key==="Escape"){f.preventDefault(),n();return}if((f.metaKey||f.ctrlKey)&&f.key==="Enter")f.preventDefault(),m()},[n,m]),x=J(()=>{let f=e.selection.selector||"";if(!f)return e.selection.tag||(e.selection.annotationId?"annotation":"canvas");let u=f.match(/data-cd-id="([^"]+)"/);if(u)return`cd:${u[1]}`;return f.length>36?`${f.slice(0,33)}…`:f},[e.selection]);return _("div",{ref:a,className:"cm-composer",role:"dialog","aria-label":"New comment",onClick:(f)=>f.stopPropagation(),onPointerDown:(f)=>f.stopPropagation(),children:[_("div",{className:"cm-composer__head",children:[R("span",{children:"New comment"}),R("span",{className:"cm-composer__selector",children:x})]}),R(Le,{textareaRef:s,className:"cm-composer__textarea",value:o,placeholder:"Type a comment. ⌘↵ to save · Esc to cancel · @name to tag",onChange:r,onKeyDown:v,rows:3,ariaLabel:"Comment body"}),_("div",{className:"cm-composer__actions",children:[R("button",{type:"button",className:"cm-btn",onClick:n,children:"Cancel"}),R("button",{type:"button",className:"cm-btn cm-btn--primary",disabled:!o.trim(),onClick:m,children:"Save"})]})]})}var ct=null;function yn(){let[e,t]=z(null);return H(()=>{if(typeof fetch>"u")return;ct??=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 ct.then((o)=>n&&t(o)),()=>{n=!1}},[]),e}function bn({comment:e,sequence:t,onClose:n,onPatch:o,onDelete:r,onReply:s,mine:a=!1}){let c=P(null),m=P(null),v=P(null),[x,f]=z(""),[u,h]=z(!1),[d,w]=z(null),S=A(()=>{let l=(d??"").trim();if(!l)return;if(l!==e.text)o({text:l});w(null)},[d,e.text,o]);H(()=>{let l=()=>{v.current=null;let y=c.current;if(!y)return;let T=vn(e),b=mt(T,{w:y.offsetWidth,h:y.offsetHeight});y.style.left=`${Math.round(b.x)}px`,y.style.top=`${Math.round(b.y)}px`,v.current=requestAnimationFrame(l)};return v.current=requestAnimationFrame(l),()=>{if(v.current!=null)cancelAnimationFrame(v.current)}},[e]),H(()=>{c.current?.focus();let l=e.id;return()=>{document.querySelector(`[data-comment-pin="${l}"]`)?.focus()}},[e.id]),H(()=>{if(typeof document>"u")return;let l=(y)=>{if(y.key!=="Escape")return;let T=c.current;if(!T)return;if(T.contains(y.target)||document.activeElement===T)y.preventDefault(),n()};return document.addEventListener("keydown",l),()=>document.removeEventListener("keydown",l)},[n]);let i=A(async()=>{let l=x.trim();if(!l||u)return;h(!0);let y=await s(l);if(h(!1),y)f(""),m.current?.focus()},[x,u,s]),p=A((l)=>{if((l.metaKey||l.ctrlKey)&&l.key==="Enter")l.preventDefault(),i()},[i]),E=`cm-thread-head-${e.id}`,g=wn(e.selector,"");return _("div",{ref:c,className:"cm-thread",role:"dialog","aria-labelledby":E,tabIndex:-1,onClick:(l)=>l.stopPropagation(),onPointerDown:(l)=>l.stopPropagation(),children:[_("div",{className:"cm-thread__head",id:E,children:[_("div",{className:"cm-thread__head-row",children:[R("span",{className:"cm-thread__seq","aria-hidden":"true",children:t}),R("span",{className:"cm-thread__author",children:e.author?.trim()||"unknown"}),R("span",{className:"cm-thread__time",children:dt(e.created)}),R("button",{type:"button",className:"cm-thread__close","aria-label":"Close thread",title:"Close · Esc",onClick:n,children:"×"})]}),g?R("code",{className:"cm-thread__selector",children:g}):null]}),d===null?R("div",{className:"cm-thread__body",children:ut(e.text)}):_("div",{className:"cm-thread__reply-form",children:[R(Le,{className:"cm-thread__reply-textarea",value:d,placeholder:"Edit your comment… ⌘↵ to save",onChange:w,onKeyDown:(l)=>{if((l.metaKey||l.ctrlKey)&&l.key==="Enter")l.preventDefault(),S()},rows:3,ariaLabel:"Edit comment"}),_("div",{className:"cm-thread__reply-actions",children:[R("button",{type:"button",className:"cm-btn",onClick:()=>w(null),children:"Cancel"}),R("button",{type:"button",className:"cm-btn cm-btn--primary","data-testid":"comment-edit-save",disabled:!d.trim(),onClick:S,children:"Save"})]})]}),(e.thread??[]).map((l)=>_("div",{className:"cm-thread__reply",children:[_("div",{className:"cm-thread__reply-head",children:[R("span",{className:"cm-thread__reply-author",children:l.author?.trim()||"unknown"}),R("span",{className:"cm-thread__reply-time",children:dt(l.created)})]}),R("div",{className:"cm-thread__reply-body",children:ut(l.body)})]},l.id)),!G()&&_(En,{children:[_("div",{className:"cm-thread__reply-form",children:[R(Le,{textareaRef:m,className:"cm-thread__reply-textarea",value:x,placeholder:"Reply… ⌘↵ to send · @name to tag",onChange:f,onKeyDown:p,rows:2,ariaLabel:"Reply",disabled:u}),R("div",{className:"cm-thread__reply-actions",children:R("button",{type:"button",className:"cm-btn cm-btn--primary",disabled:!x.trim()||u,onClick:()=>void i(),children:"Send"})})]}),_("div",{className:"cm-thread__actions",children:[a&&d===null?R("button",{type:"button",className:"cm-btn","data-testid":"comment-edit",onClick:()=>w(e.text),children:"Edit"}):null,e.status==="resolved"?R("button",{type:"button",className:"cm-btn",onClick:()=>o({status:"open"}),children:"↺ Reopen"}):R("button",{type:"button",className:"cm-btn cm-btn--primary",onClick:()=>{o({status:"resolved"}),n()},children:"✓ Resolve"}),R("button",{type:"button",className:"cm-btn cm-btn--danger",onClick:()=>{r(),n()},children:"Delete"})]})]})]})}function ut(e){if(!e)return null;let t=/(@[\w][\w.-]*)/g;return e.split(t).map((o,r)=>{let s=`${r}:${o}`;if(r%2===1)return R("strong",{"data-mention":"true",children:o},s);return R("span",{children:o},s)})}function dt(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 wn(e,t){if(!e)return t;let n=e.match(/data-cd-id="([^"]+)"/);if(n)return`cd:${n[1]}`;return e.length>36?`${e.slice(0,33)}…`:e}function vn(e){let t=e.selector?ke(e):null;if(t)return{x:t.x+t.w-12,y:t.y+16};if(e.bounds)return{x:e.bounds.x+e.bounds.w-12,y:e.bounds.y+16};return{x:16,y:16}}function xn(e){if(e.clientX||e.clientY)return{x:e.clientX,y:e.clientY+8};if(e.selection.selector){let t=ke(e.selection);if(t)return{x:t.x,y:t.y+t.h+8}}return{x:16,y:16}}import{useEffect as Sn}from"react";var Cn=new Set(["pen","highlighter","shape","rect","ellipse","arrow","sticky","text","section","eraser"]);function Re(e){return Cn.has(e)}var ee=(e)=>!!(e.metaKey||e.ctrlKey);function te(e){if(e.type==="keydown"){if(e.isEditable)return{kind:"no-op"};if(e.metaKey||e.ctrlKey||e.altKey){if(e.key==="Escape")return{kind:"escape"};let n=(e.key||"").toLowerCase();if(!e.altKey&&(e.metaKey||e.ctrlKey)){if(n==="z"&&e.shiftKey)return{kind:"redo"};if(n==="z")return{kind:"undo"};if(n==="y"&&!e.shiftKey)return{kind:"redo"}}return{kind:"no-op"}}let t=(e.key||"").toLowerCase();if(t==="v")return{kind:"tool",tool:"move"};if(t==="h")return{kind:"tool",tool:"hand"};if(t==="c")return{kind:"tool",tool:"comment"};if(t==="b")return{kind:"tool",tool:"pen"};if(t==="i")return{kind:"tool",tool:"highlighter"};if(t==="r"||t==="o")return{kind:"tool",tool:"shape"};if(t==="a")return{kind:"tool",tool:"arrow"};if(t==="n")return{kind:"tool",tool:"sticky"};if(t==="t")return{kind:"tool",tool:"text"};if(t==="s"&&e.shiftKey)return{kind:"tool",tool:"section"};if(t==="e")return{kind:"tool",tool:"eraser"};if(e.key==="Escape")return{kind:"escape"};return{kind:"no-op"}}if(e.type==="contextmenu")return{kind:"context-menu",clientX:e.clientX??0,clientY:e.clientY??0};if(e.type==="pointermove"){if(Re(e.activeTool))return{kind:"no-op"};if(e.activeTool==="hand")return{kind:"no-op"};if(e.activeTool==="browse"){if(!ee(e))return{kind:"no-op"};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:ee(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(Re(e.activeTool)&&!ee(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==="browse"){if(!ee(e))return{kind:"no-op"};return{kind:"select",mode:e.shiftKey?"add":"replace",deep:!0,clientX:e.clientX??0,clientY:e.clientY??0}}let t=ee(e);return{kind:"select",mode:!!e.shiftKey?"add":"replace",deep:t,clientX:e.clientX??0,clientY:e.clientY??0}}return{kind:"no-op"}}function fe(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 ne(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], .dc-tool-palette, .dc-zoom-tb, .dc-mm, .dc-context-menu")}function ht(e){if(!e||typeof e.closest!=="function")return!1;let t=e;return!!t.closest("[data-dc-screen]")&&!t.closest(".dc-artboard-body")}function pt(e,t,n){return e.kind==="select"&&!n.metaKey&&!n.ctrlKey&&ht(t)}function Tn(e,t,n){return e==="select"&&!n.metaKey&&!n.ctrlKey&&ht(t)}function gt(e){let{hostRef:t,getActiveTool:n,isSpaceHeld:o,callbacks:r,enabled:s=!0,claimableActions:a}=e;Sn(()=>{if(!s)return;let c=t.current;if(!c)return;let m=(i)=>a&&i.kind!=="no-op"&&!a.has(i.kind)?{kind:"no-op"}:i,v=(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":r.onEscape?.();break;case"undo":r.onUndo?.();break;case"redo":r.onRedo?.();break;case"no-op":break}},x=(i)=>{let p=m(te({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()}));v(p)},f=(i)=>{if(ne(i.target))return;if(fe(i.target))return;let p=m(te({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()})),E=pt(p,i.target,i);if(p.kind!=="no-op"){if(i.preventDefault(),!E)i.stopImmediatePropagation()}v(p)},u=(i)=>{if(ne(i.target))return;if(fe(i.target))return;let p=m(te({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()})),E=pt(p,i.target,i);if(p.kind!=="no-op"){if(i.preventDefault(),!E)i.stopImmediatePropagation();if(p.kind==="select")try{window.focus()}catch{}}},h=(i)=>{if(ne(i.target))return;if(fe(i.target))return;let p=n(),E=i.metaKey||i.ctrlKey,g=p==="comment"?"drop-comment":p==="move"&&i.button===0?"select":(Re(p)||p==="browse")&&E&&i.button===0?"select":i.button===2?"context-menu":null;if(g&&(!a||a.has(g))){let l=Tn(g,i.target,i);if(i.preventDefault(),!l)i.stopImmediatePropagation()}},d=(i)=>{let p=m(te({type:"contextmenu",clientX:i.clientX,clientY:i.clientY,metaKey:i.metaKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,altKey:i.altKey,activeTool:n()}));if(p.kind==="no-op")return;i.preventDefault(),i.stopImmediatePropagation(),v(p)},w=(i)=>{let p=m(te({type:"keydown",key:i.key,metaKey:i.metaKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,altKey:i.altKey,isEditable:fe(i.target),activeTool:n()}));if(p.kind==="tool"||p.kind==="escape"&&!tt()||p.kind==="undo"||p.kind==="redo")i.preventDefault();v(p)};c.addEventListener("pointermove",x,{passive:!0}),c.addEventListener("pointerdown",f,{capture:!0}),c.addEventListener("mousedown",u,{capture:!0}),c.addEventListener("click",h,{capture:!0}),c.addEventListener("contextmenu",d,{capture:!0});let S=c.ownerDocument??document;return S.addEventListener("keydown",w,!0),()=>{c.removeEventListener("pointermove",x),c.removeEventListener("pointerdown",f,{capture:!0}),c.removeEventListener("mousedown",u,{capture:!0}),c.removeEventListener("click",h,{capture:!0}),c.removeEventListener("contextmenu",d,{capture:!0}),S.removeEventListener("keydown",w,!0)}},[s,t,n,o,r,a])}function Me(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 u=r.getAttribute?.("data-cd-id")??null;return{el:r,cdId:u,artboardId:a}}let m=r,v=null;while(m&&m!==c){if(m.hasAttribute?.("data-cd-id"))v=m;m=m.parentElement}let x=v??r,f=x.getAttribute?.("data-cd-id")??null;return{el:x,cdId:f,artboardId:a}}import{useCallback as Qn,useEffect as Ct,useRef as ge}from"react";var Ln=!1;function yt(){return Ln}import{createContext as Dn,useCallback as re,useContext as Et,useEffect as Ne,useMemo as wt,useRef as Oe,useState as pe}from"react";function U(e,t,n,o){return`url("data:image/svg+xml,${encodeURIComponent(e.trim())}") ${t} ${n}, ${o}`}var _e="width='24' height='24' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'",Ie="#1f1f1f",Ae="stroke='#ffffff' stroke-linejoin='round' stroke-linecap='round'";function B(e,t,n){let o=n?`<g transform='${n}'>`:"";return`<svg ${_e}>${o}<path fill='#ffffff' d='${e}'/><path fill='${Ie}' d='${t}'/>${n?"</g>":""}</svg>`}var bt="translate(0,32) scale(1,-1)",kn=U(B("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"),Rn=U(B("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"),Mn=U(B("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"),An=U(B("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",bt),6,18,"crosshair"),_n=U(B("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",bt),6,18,"crosshair"),oe=U(B("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"),In=U(B("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"),Nn=U(`<svg ${_e}><path d='M16 4V28M11 4H21M11 28H21' fill='none' ${Ae} stroke-width='5'/><path d='M16 4V28M11 4H21M11 28H21' fill='none' stroke='${Ie}' stroke-width='2.25' stroke-linecap='round'/></svg>`,12,12,"text"),On=U(`<svg ${_e}><path d='M6 5H21L26 10V27H6Z' fill='${Ie}' ${Ae} stroke-width='2.5'/><path d='M21 5V11H26' fill='none' ${Ae} stroke-width='2.25'/></svg>`,5,5,"crosshair"),O=Object.freeze({browse:"default",move:kn,hand:Rn,comment:Mn,pen:An,section:oe,highlighter:_n,shape:oe,rect:oe,ellipse:oe,sticky:On,arrow:oe,text:Nn,eraser:In});import{jsx as He,Fragment as $n}from"react/jsx-runtime";var De="maude:tool-sync",vt=Object.freeze({preview:"browse",edit:"move"});function xt(e){if(e==="browse")return"preview";if(e==="move")return"edit";return null}var Hn=Object.freeze([{id:"browse",label:"Browse",shortcut:"",cursor:O.browse},{id:"move",label:"Select",shortcut:"V",cursor:O.move},{id:"hand",label:"Hand",shortcut:"H",cursor:O.hand},{id:"comment",label:"Comment",shortcut:"C",cursor:O.comment},{id:"pen",label:"Pen",shortcut:"B",cursor:O.pen},{id:"highlighter",label:"Highlighter",shortcut:"I",cursor:O.highlighter},{id:"shape",label:"Shape",shortcut:"R",cursor:O.shape},{id:"sticky",label:"Sticky",shortcut:"N",cursor:O.sticky},{id:"section",label:"Section",shortcut:"⇧S",cursor:O.shape},{id:"arrow",label:"Arrow",shortcut:"A",cursor:O.arrow},{id:"text",label:"Text",shortcut:"T",cursor:O.text},{id:"eraser",label:"Eraser",shortcut:"E",cursor:O.eraser}]),Pn=new Set(["browse","move","hand"]);function zn(e,t){return t?e.filter((n)=>Pn.has(n.id)):e}var Pe=Dn(null);function Kn({children:e,tools:t=Hn,initial:n,initialMode:o}){let r=G(),s=wt(()=>zn(t,r),[t,r]),a=n??(r?"browse":"move"),c=o??xt(a)??(r?"preview":"edit"),[m,v]=pe(a),[x,f]=pe(c),[u,h]=pe(()=>({tool:null,locked:!1})),d=re((C)=>{if(!s.some((L)=>L.id===C))return;v(C);let k=xt(C);if(k)f(k);h((L)=>L.locked&&L.tool===C?L:{tool:null,locked:!1})},[s]),w=re((C)=>{let k=vt[C];if(!s.some((L)=>L.id===k))return;f(C),v(k),h((L)=>L.locked&&L.tool===k?L:{tool:null,locked:!1})},[s]),S=re(()=>{d(vt[x])},[x,d]),i=re((C)=>{h((k)=>{if(k.locked&&k.tool===C)return{tool:null,locked:!1};return{tool:C,locked:!0}}),v(C)},[]),p=re(()=>{h({tool:null,locked:!1})},[]),[E,g]=pe("rounded"),l=Oe(Math.random().toString(36).slice(2)),y=Oe(m);y.current=m;let T=Oe(!1);Ne(()=>{if(!T.current){T.current=!0;return}if(typeof document>"u")return;document.dispatchEvent(new CustomEvent(De,{detail:{tool:m,from:l.current}}))},[m]),Ne(()=>{if(typeof document>"u")return;let C=(k)=>{let L=k.detail;if(!L||L.from===l.current||typeof L.tool!=="string")return;if(L.tool===y.current)return;d(L.tool)};return document.addEventListener(De,C),()=>document.removeEventListener(De,C)},[d]),Ne(()=>{if(typeof document>"u")return;let C=s.find((M)=>M.id===m);if(!C)return;let k=document.body.style.cursor,L=document.getElementById("dc-tool-cursor");if(!L)L=document.createElement("style"),L.id="dc-tool-cursor",document.head.appendChild(L);if(m==="browse"){if(document.body.style.cursor="",L.textContent="",typeof window<"u"&&window.parent&&window.parent!==window)try{window.parent.postMessage({dgn:"tool-cursor",tool:m},"*")}catch{}return()=>{document.body.style.cursor=k}}if(document.body.style.cursor=C.cursor,L.textContent=`* { cursor: ${C.cursor} !important; }`,typeof window<"u"&&window.parent&&window.parent!==window)try{window.parent.postMessage({dgn:"tool-cursor",tool:m},"*")}catch{}return()=>{document.body.style.cursor=k;let M=document.getElementById("dc-tool-cursor");if(M)M.textContent=""}},[m,s]);let b=wt(()=>({tool:m,setTool:d,tools:s,mode:x,setMode:w,resetTool:S,sticky:u,toggleSticky:i,clearSticky:p,shapeKind:E,setShapeKind:g}),[m,d,s,x,w,S,u,i,p,E]);return He(Pe.Provider,{value:b,children:e})}function St({children:e,initial:t,initialMode:n}){if(Et(Pe))return He($n,{children:e});return He(Kn,{initial:t,initialMode:n,children:e})}function he(){let e=Et(Pe);if(!e)throw Error("useToolMode must be used inside <ToolProvider>");return e}import{jsx as Jn}from"react/jsx-runtime";var Fn=`
|
|
2
2
|
.dc-el-resize-handle {
|
|
3
3
|
position: fixed;
|
|
4
4
|
width: 8px;
|
|
@@ -56,4 +56,4 @@ import{Component as eo,createElement as $e,useCallback as ze,useEffect as Q,useM
|
|
|
56
56
|
@media (prefers-reduced-motion: reduce) {
|
|
57
57
|
.dc-el-resize-handle, .dc-el-resize-readout { transition-duration: 1ms; }
|
|
58
58
|
}
|
|
59
|
-
`.trim();function Un(){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=Fn,document.head.appendChild(e)}var Yn=["nw","n","ne","e","se","s","sw","w"];function Bn(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 V=(e)=>Math.round(e*100)/100,ye=1;function Wn(e,t,n,o,r,s){let{movesLeft:a,movesRight:c,movesTop:m,movesBottom:v}=Bn(e),x=r.center,{w:f,h:u}=t;if(c)f=t.w+(x?2*n:n);else if(a)f=t.w-(x?2*n:n);if(v)u=t.h+(x?2*o:o);else if(m)u=t.h-(x?2*o:o);if(r.aspect&&t.w>0&&t.h>0){let d=t.w/t.h;if((a||c)&&(m||v)){let S=Math.abs(f-t.w)/t.w,i=Math.abs(u-t.h)/t.h;if(S>=i)u=f/d;else f=u*d}else if(a||c)u=f/d;else if(m||v)f=u*d}if(f<ye)f=ye;if(u<ye)u=ye;let h={width:V(f),height:V(u)};if(x){if(s.canMoveLeft&&(a||c))h.left=V(t.left+(t.w-f)/2);if(s.canMoveTop&&(m||v))h.top=V(t.top+(t.h-u)/2)}else{if(s.canMoveLeft&&a)h.left=V(t.left+t.w-f);if(s.canMoveTop&&m)h.top=V(t.top+t.h-u)}return h}function Tt(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 qn(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 Xn(e){let t=e.closest(".dc-world");if(!t)return 1;let n=getComputedStyle(t),o=Number.parseFloat(n.zoom||"1")||1;return qn(n.transform)*o}function Lt(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 kt(e,t,n,o){return Math.atan2(o-t,n-e)}function Vn(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 jn(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 Gn(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 Zn(e,t){try{window.parent.postMessage({dgn:"resize-request",id:e.cdId,patch:{transform:t},before:e.before,idIndex:e.idIndex},"*")}catch{}}function Rt(){Un();let{selected:e}=me(),{tool:t}=he(),n=ge(null),o=ge(null),r=ge(null),s=ge(null),a=e.length===1?e[0]:null,c=a&&typeof a.id==="string"?a.id:null,m=a&&!c&&typeof a.artboardId==="string"?a.artboardId:null,v=t==="move"&&(!!c||!!m);Ct(()=>{let f=n.current;if(!f)return;let u=()=>{for(let d of Array.from(f.children)){let b=d;b.style.opacity="0",b.style.pointerEvents="none"}};if(!v||!a){u();return}let h=()=>{if(o.current=null,yt()){u(),o.current=requestAnimationFrame(h);return}let d=ve(document,a);if(!d){u(),o.current=requestAnimationFrame(h);return}let b=d.getBoundingClientRect();if(b.width<=0&&b.height<=0){u(),o.current=requestAnimationFrame(h);return}let S=m?["e","s","se"]:Yn,i=m?[]:["rot-nw","rot-ne","rot-sw","rot-se"],p=S.length+i.length+1;while(f.children.length<p)f.appendChild(document.createElement("div"));while(f.children.length>p)f.lastChild&&f.removeChild(f.lastChild);let E=b.left+b.width/2,g=b.top+b.height/2,l=Tt(getComputedStyle(d).transform),y=Xn(d),T=d.offsetWidth*y/2,w=d.offsetHeight*y/2,C={nw:[-T,-w],n:[0,-w],ne:[T,-w],e:[T,0],se:[T,w],s:[0,w],sw:[-T,w],w:[-T,0],"rot-nw":[-T,-w],"rot-ne":[T,-w],"rot-sw":[-T,w],"rot-se":[T,w]},k=[...i,...S];for(let K=0;K<k.length;K++){let I=k[K],N=f.children[K],[Y,W]=C[I]??[0,0],[Nt,Ot]=Lt(Y,W,l),Dt=E+Nt,Ht=g+Ot,be=I.startsWith("rot-"),Fe=I==="n"||I==="s",Ue=I==="e"||I==="w",Pt=be?10:Fe?7:Ue?3:4,zt=be?10:Fe?3:Ue?7:4;N.className="dc-el-resize-handle",N.dataset.corner=I,N.style.opacity="1",N.style.pointerEvents="auto",N.style.left=`${Math.round(Dt-Pt)}px`,N.style.top=`${Math.round(Ht-zt)}px`,N.style.transform=be?"":`rotate(${l}deg)`}let L=f.children[k.length],M=r.current;if(M&&M.el===d&&!M.corner.startsWith("rot-")){let K=M.lastResult?.width??d.offsetWidth,I=M.lastResult?.height??d.offsetHeight,N=`${Math.round(K)} × ${Math.round(I)}`,Y=M.lastResult?.left,W=M.lastResult?.top;if(typeof Y==="number"||typeof W==="number")N+=` · ${Math.round(Y??M.start.left)}, ${Math.round(W??M.start.top)}`;L.className="dc-el-resize-readout",L.textContent=N,L.style.opacity="1",L.style.left=`${Math.round(E)}px`,L.style.top=`${Math.round(g+w)}px`}else L.style.opacity="0";o.current=requestAnimationFrame(h)};return o.current=requestAnimationFrame(h),()=>{if(o.current!=null)cancelAnimationFrame(o.current)}},[v,a,m]);let x=Qn((f,u)=>{if(f.el.style.width=`${u.width}px`,f.el.style.height=`${u.height}px`,typeof u.left==="number")f.el.style.left=`${u.left}px`;if(typeof u.top==="number")f.el.style.top=`${u.top}px`;f.lastResult=u},[]);return Ct(()=>{let f=n.current;if(!f)return;let u=(i,p)=>{let[E,g]=Lt(p.clientX-i.startClientX,p.clientY-i.startClientY,-i.angle);return Wn(i.corner,i.start,E/i.elZoom,g/i.elZoom,{aspect:!!p.shiftKey,center:!i.artboardId&&!!p.altKey},i.flags)},h=(i)=>{let p=i.target;if(!p?.classList.contains("dc-el-resize-handle"))return;let E=p.dataset.corner;if(!E||!a)return;let g=typeof a.id==="string"?a.id:null,l=!g&&typeof a.artboardId==="string"?a.artboardId:null;if(!g&&!l)return;let y=ve(document,a);if(!y)return;i.preventDefault(),i.stopPropagation();let T=y.getBoundingClientRect(),w=y.offsetWidth?T.width/y.offsetWidth:1,C=getComputedStyle(y),k=!l&&(C.position==="absolute"||C.position==="fixed"),L=l?Number.NaN:Number.parseFloat(y.style.left),M=l?Number.NaN:Number.parseFloat(y.style.top),K=l?0:Tt(C.transform),I=w>0?w:1,N=T.left+T.width/2,Y=T.top+T.height/2,W={pointerId:i.pointerId,corner:E,el:y,cdId:g??"",artboardId:l,idIndex:g?Je(document,g,y):0,startClientX:i.clientX,startClientY:i.clientY,elZoom:I,angle:K,cx:N,cy:Y,rotStartPointer:kt(N,Y,i.clientX,i.clientY),start:{w:(K?y.offsetWidth:T.width/I)||T.width/I,h:(K?y.offsetHeight:T.height/I)||T.height/I,left:L,top:M},flags:{canMoveLeft:k&&Number.isFinite(L),canMoveTop:k&&Number.isFinite(M)},before:{width:y.style.width||null,height:y.style.height||null,left:y.style.left||null,top:y.style.top||null,transform:y.style.transform||null},lastResult:null,lastTransform:null};r.current=W;try{p.setPointerCapture(i.pointerId)}catch{}},d=(i)=>{let p=r.current;if(!p||i.pointerId!==p.pointerId)return;if(i.preventDefault(),p.corner.startsWith("rot-")){let g=`rotate(${Vn(p.angle,p.rotStartPointer,kt(p.cx,p.cy,i.clientX,i.clientY),!!i.shiftKey)}deg)`;p.el.style.transform=g,p.lastTransform=g;return}x(p,u(p,i))},b=(i)=>{let p=r.current;if(!p||i.pointerId!==p.pointerId)return;if(r.current=null,p.corner.startsWith("rot-")){let l=p.lastTransform;if(!l||l===p.before.transform)return;s.current={el:p.el,before:p.before},Zn(p,l);return}let E=p.lastResult??u(p,i);if(!(`${E.width}px`!==p.before.width||`${E.height}px`!==p.before.height||typeof E.left==="number"&&`${E.left}px`!==p.before.left||typeof E.top==="number"&&`${E.top}px`!==p.before.top))return;if(s.current={el:p.el,before:p.before},p.artboardId)Gn(p,E);else jn(p,E)},S=(i)=>{let p=i.data;if(p?.dgn!=="resize-failed"&&p?.dgn!=="resize-artboard-failed")return;if(i.source!==window.parent)return;let E=s.current;if(!E)return;if(E.el.style.width=E.before.width??"",E.el.style.height=E.before.height??"",E.before.left!==null||E.el.style.left)E.el.style.left=E.before.left??"";if(E.before.top!==null||E.el.style.top)E.el.style.top=E.before.top??"";if(E.before.transform!==null||E.el.style.transform)E.el.style.transform=E.before.transform??"";s.current=null};return f.addEventListener("pointerdown",h),window.addEventListener("pointermove",d),window.addEventListener("pointerup",b),window.addEventListener("pointercancel",b),window.addEventListener("message",S),()=>{f.removeEventListener("pointerdown",h),window.removeEventListener("pointermove",d),window.removeEventListener("pointerup",b),window.removeEventListener("pointercancel",b),window.removeEventListener("message",S)}},[a,x]),Jn("div",{ref:n,"aria-hidden":"true"})}import{jsx as D,jsxs as It,Fragment as fo}from"react/jsx-runtime";var oo=new Set(["drop-comment","tool","escape","hover"]);function se(){return typeof document<"u"&&!document.querySelector(".dc-canvas")}function Qe(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 ro(e,t){let n=Qe(e,t);if(!n)return null;return n.closest("[data-cd-id]")??n}function io({children:e,file:t}){let{tool:n,setTool:o}=he(),r=me(),s=F(null),[a,c]=ie(null),m=F(n);m.current=n;let v=to(()=>()=>m.current,[]);Q(()=>{if(n!=="comment")c(null)},[n]);let[x,f]=ie(null),[u,h]=ie(!1);return Q(()=>{let d=()=>h(se());d();let b=requestAnimationFrame(d),S=setTimeout(d,120);return()=>{cancelAnimationFrame(b),clearTimeout(S)}},[]),Q(()=>{if(typeof document>"u")return;let d=(b)=>{if(b.button!==0||!(b.metaKey||b.ctrlKey))return;if(!se())return;if(ne(b.target))return;let S=ro(b.clientX,b.clientY);if(!S)return;b.preventDefault(),b.stopImmediatePropagation();let i=S.getAttribute("data-cd-id"),p=xe({el:S,cdId:i,artboardId:null});if(b.shiftKey)r.add(p);else r.replace(p);f(S)};return document.addEventListener("pointerdown",d,!0),()=>document.removeEventListener("pointerdown",d,!0)},[r]),Q(()=>{if(r.selected.length===0)f(null)},[r.selected]),Q(()=>{let d=s.current;if(d)d.setAttribute("data-active-tool",n);if(typeof document<"u"&&document.body)document.body.setAttribute("data-active-tool",n);return()=>{d?.removeAttribute("data-active-tool")}},[n]),Q(()=>{if(typeof window>"u")return;let d=(b)=>{let S=b.data;if(!S||typeof S!=="object"||S.dgn!=="tool-set")return;if(typeof S.tool==="string")o(S.tool)};return window.addEventListener("message",d),()=>window.removeEventListener("message",d)},[o]),gt({hostRef:s,getActiveTool:v,claimableActions:oo,callbacks:{onHover:({clientX:d,clientY:b})=>{if(m.current!=="comment"||!se()){c(null);return}let S=Qe(d,b);c((i)=>i===S?i:S)},onTool:({tool:d})=>o(d),onEscape:()=>{if(m.current!=="move")o("move");if(c(null),r.clear(),typeof window<"u")try{window.parent.postMessage({dgn:"force-clear"},"*")}catch{}},onDropComment:({clientX:d,clientY:b})=>ao(d,b,r,t)}}),It("div",{"data-mc-host":!0,ref:s,style:{display:"contents"},children:[e,a?D(lo,{el:a}):null,x?D(so,{el:x}):null,u?D(Rt,{}):null,D(ft,{})]})}function so({el:e}){let t=F(null),n=F(e);n.current=e;let o=F(null);return Q(()=>{let r=()=>{o.current=null;let s=t.current,a=n.current;if(s&&a?.isConnected){let c=a.getBoundingClientRect();if(c.width===0&&c.height===0)s.style.display="none";else s.style.display="block",s.style.left=`${Math.round(c.left)}px`,s.style.top=`${Math.round(c.top)}px`,s.style.width=`${Math.round(c.width)}px`,s.style.height=`${Math.round(c.height)}px`}else if(s)s.style.display="none";o.current=requestAnimationFrame(r)};return o.current=requestAnimationFrame(r),()=>{if(o.current!=null)cancelAnimationFrame(o.current)}},[]),D("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 lo({el:e}){let t=F(null),n=F(e);n.current=e;let o=F(null);return Q(()=>{let r=()=>{o.current=null;let s=t.current,a=n.current;if(s&&a?.isConnected){let c=a.getBoundingClientRect();if(c.width===0&&c.height===0)s.style.display="none";else s.style.display="block",s.style.left=`${Math.round(c.left)}px`,s.style.top=`${Math.round(c.top)}px`,s.style.width=`${Math.round(c.width)}px`,s.style.height=`${Math.round(c.height)}px`}else if(s)s.style.display="none";o.current=requestAnimationFrame(r)};return o.current=requestAnimationFrame(r),()=>{if(o.current!=null)cancelAnimationFrame(o.current)}},[]),D("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 ao(e,t,n,o){if(typeof document>"u")return;let r=We(e,t)??void 0,s=Xe(e,t);if(s){let m=le(s),v=m?.getBoundingClientRect(),x={file:o,id:void 0,selector:"",artboardId:null,tag:m?.getAttribute("data-tool")??"annotation",classes:"",text:"",dom_path:[],bounds:v?{x:v.left,y:v.top,w:v.width,h:v.height}:{x:e-12,y:t-12,w:24,h:24},html:"",annotationId:s,...r?{world:r}:{}};Ke(x,e,t);return}let a=Me(document,e,t,{deep:!0});if(!a)a=Me(document,e,t,{deep:!1});if(!a&&!se()&&typeof document.elementsFromPoint==="function"){let m=document.elementsFromPoint(e,t);for(let v of m){let x=v.closest?.("[data-cd-id]");if(!x)continue;if(!x.closest(".dc-artboard-body"))continue;let f=x.closest("[data-dc-screen]");a={el:x,cdId:x.getAttribute("data-cd-id"),artboardId:f?.getAttribute("data-dc-screen")??null};break}}if(!a&&se()){let m=Qe(e,t);if(m)a={el:m,cdId:m.getAttribute("data-cd-id"),artboardId:null}}if(!a){let m={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}:{}};Ke(m,e,t);return}let c=xe(a,o);n.replace(c),Ke(c,e,t)}function Ke(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 At(e,t){return D(St,{initial:"browse",children:D(st,{children:D(io,{file:t,children:D(e,{})})})})}function Er(e,t){let n=no(t.rootEl);if(!t.commentsEnabled){n.render($e(e));return}let o=t.file??we();n.render($e(mo,{initialCanvas:e,file:o}))}var Mt="__maudeCanvasRuntime";function co({Canvas:e,file:t,onOk:n}){return Q(()=>{n()},[]),At(e,t)}class _t extends eo{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(){this.props.onError()}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}}function uo({message:e}){return $e("div",{className:"dc-hmr-holding",role:"status","aria-live":"polite",title:e?`Holding last working render — ${e}`:"Holding last working render"},"⏸ build error — držím poslední funkční verzi")}function mo({initialCanvas:e,file:t}){let[{canvas:n,attempt:o},r]=ie({canvas:e,attempt:0}),[s,a]=ie({on:!1}),c=F(null),m=F(n);m.current=n,Q(()=>{let u={remount:(h)=>r((d)=>({canvas:h,attempt:d.attempt+1})),setHolding:(h,d)=>a(h?{on:!0,message:d}:{on:!1})};return window[Mt]=u,()=>{window[Mt]=void 0}},[]);let v=ze(()=>{if(c.current=m.current,a((u)=>u.on?{on:!1}:u),o>0&&t)try{window.parent.postMessage({dgn:"loaded",file:t},"*")}catch{}},[o,t]),x=ze(()=>{a({on:!0,message:"render error"})},[]),f=ze(()=>{let u=c.current;return u?At(u,t):null},[t]);return It(fo,{children:[D(_t,{attempt:o,onError:x,fallback:f,children:D(co,{Canvas:n,file:t,onOk:v},o)}),s.on?D(uo,{message:s.message}):null]})}export{_t as CanvasErrorBoundary,se as isBareSpecimen,Er as mountCanvas,ro as pickSpecimenSelectEl};
|
|
59
|
+
`.trim();function Un(){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=Fn,document.head.appendChild(e)}var Yn=["nw","n","ne","e","se","s","sw","w"];function Bn(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 V=(e)=>Math.round(e*100)/100,ye=1;function Wn(e,t,n,o,r,s){let{movesLeft:a,movesRight:c,movesTop:m,movesBottom:v}=Bn(e),x=r.center,{w:f,h:u}=t;if(c)f=t.w+(x?2*n:n);else if(a)f=t.w-(x?2*n:n);if(v)u=t.h+(x?2*o:o);else if(m)u=t.h-(x?2*o:o);if(r.aspect&&t.w>0&&t.h>0){let d=t.w/t.h;if((a||c)&&(m||v)){let S=Math.abs(f-t.w)/t.w,i=Math.abs(u-t.h)/t.h;if(S>=i)u=f/d;else f=u*d}else if(a||c)u=f/d;else if(m||v)f=u*d}if(f<ye)f=ye;if(u<ye)u=ye;let h={width:V(f),height:V(u)};if(x){if(s.canMoveLeft&&(a||c))h.left=V(t.left+(t.w-f)/2);if(s.canMoveTop&&(m||v))h.top=V(t.top+(t.h-u)/2)}else{if(s.canMoveLeft&&a)h.left=V(t.left+t.w-f);if(s.canMoveTop&&m)h.top=V(t.top+t.h-u)}return h}function Tt(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 qn(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 Xn(e){let t=e.closest(".dc-world");if(!t)return 1;let n=getComputedStyle(t),o=Number.parseFloat(n.zoom||"1")||1;return qn(n.transform)*o}function Lt(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 kt(e,t,n,o){return Math.atan2(o-t,n-e)}function Vn(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 jn(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 Gn(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 Zn(e,t){try{window.parent.postMessage({dgn:"resize-request",id:e.cdId,patch:{transform:t},before:e.before,idIndex:e.idIndex},"*")}catch{}}function Rt(){Un();let{selected:e}=me(),{tool:t}=he(),n=ge(null),o=ge(null),r=ge(null),s=ge(null),a=e.length===1?e[0]:null,c=a&&typeof a.id==="string"?a.id:null,m=a&&!c&&typeof a.artboardId==="string"?a.artboardId:null,v=t==="move"&&(!!c||!!m);Ct(()=>{let f=n.current;if(!f)return;let u=()=>{for(let d of Array.from(f.children)){let w=d;w.style.opacity="0",w.style.pointerEvents="none"}};if(!v||!a){u();return}let h=()=>{if(o.current=null,yt()){u(),o.current=requestAnimationFrame(h);return}let d=ve(document,a);if(!d){u(),o.current=requestAnimationFrame(h);return}let w=d.getBoundingClientRect();if(w.width<=0&&w.height<=0){u(),o.current=requestAnimationFrame(h);return}let S=m?["e","s","se"]:Yn,i=m?[]:["rot-nw","rot-ne","rot-sw","rot-se"],p=S.length+i.length+1;while(f.children.length<p)f.appendChild(document.createElement("div"));while(f.children.length>p)f.lastChild&&f.removeChild(f.lastChild);let E=w.left+w.width/2,g=w.top+w.height/2,l=Tt(getComputedStyle(d).transform),y=Xn(d),T=d.offsetWidth*y/2,b=d.offsetHeight*y/2,C={nw:[-T,-b],n:[0,-b],ne:[T,-b],e:[T,0],se:[T,b],s:[0,b],sw:[-T,b],w:[-T,0],"rot-nw":[-T,-b],"rot-ne":[T,-b],"rot-sw":[-T,b],"rot-se":[T,b]},k=[...i,...S];for(let K=0;K<k.length;K++){let I=k[K],N=f.children[K],[Y,W]=C[I]??[0,0],[Nt,Ot]=Lt(Y,W,l),Dt=E+Nt,Ht=g+Ot,be=I.startsWith("rot-"),Fe=I==="n"||I==="s",Ue=I==="e"||I==="w",Pt=be?10:Fe?7:Ue?3:4,zt=be?10:Fe?3:Ue?7:4;N.className="dc-el-resize-handle",N.dataset.corner=I,N.style.opacity="1",N.style.pointerEvents="auto",N.style.left=`${Math.round(Dt-Pt)}px`,N.style.top=`${Math.round(Ht-zt)}px`,N.style.transform=be?"":`rotate(${l}deg)`}let L=f.children[k.length],M=r.current;if(M&&M.el===d&&!M.corner.startsWith("rot-")){let K=M.lastResult?.width??d.offsetWidth,I=M.lastResult?.height??d.offsetHeight,N=`${Math.round(K)} × ${Math.round(I)}`,Y=M.lastResult?.left,W=M.lastResult?.top;if(typeof Y==="number"||typeof W==="number")N+=` · ${Math.round(Y??M.start.left)}, ${Math.round(W??M.start.top)}`;L.className="dc-el-resize-readout",L.textContent=N,L.style.opacity="1",L.style.left=`${Math.round(E)}px`,L.style.top=`${Math.round(g+b)}px`}else L.style.opacity="0";o.current=requestAnimationFrame(h)};return o.current=requestAnimationFrame(h),()=>{if(o.current!=null)cancelAnimationFrame(o.current)}},[v,a,m]);let x=Qn((f,u)=>{if(f.el.style.width=`${u.width}px`,f.el.style.height=`${u.height}px`,typeof u.left==="number")f.el.style.left=`${u.left}px`;if(typeof u.top==="number")f.el.style.top=`${u.top}px`;f.lastResult=u},[]);return Ct(()=>{let f=n.current;if(!f)return;let u=(i,p)=>{let[E,g]=Lt(p.clientX-i.startClientX,p.clientY-i.startClientY,-i.angle);return Wn(i.corner,i.start,E/i.elZoom,g/i.elZoom,{aspect:!!p.shiftKey,center:!i.artboardId&&!!p.altKey},i.flags)},h=(i)=>{let p=i.target;if(!p?.classList.contains("dc-el-resize-handle"))return;let E=p.dataset.corner;if(!E||!a)return;let g=typeof a.id==="string"?a.id:null,l=!g&&typeof a.artboardId==="string"?a.artboardId:null;if(!g&&!l)return;let y=ve(document,a);if(!y)return;i.preventDefault(),i.stopPropagation();let T=y.getBoundingClientRect(),b=y.offsetWidth?T.width/y.offsetWidth:1,C=getComputedStyle(y),k=!l&&(C.position==="absolute"||C.position==="fixed"),L=l?Number.NaN:Number.parseFloat(y.style.left),M=l?Number.NaN:Number.parseFloat(y.style.top),K=l?0:Tt(C.transform),I=b>0?b:1,N=T.left+T.width/2,Y=T.top+T.height/2,W={pointerId:i.pointerId,corner:E,el:y,cdId:g??"",artboardId:l,idIndex:g?Je(document,g,y):0,startClientX:i.clientX,startClientY:i.clientY,elZoom:I,angle:K,cx:N,cy:Y,rotStartPointer:kt(N,Y,i.clientX,i.clientY),start:{w:(K?y.offsetWidth:T.width/I)||T.width/I,h:(K?y.offsetHeight:T.height/I)||T.height/I,left:L,top:M},flags:{canMoveLeft:k&&Number.isFinite(L),canMoveTop:k&&Number.isFinite(M)},before:{width:y.style.width||null,height:y.style.height||null,left:y.style.left||null,top:y.style.top||null,transform:y.style.transform||null},lastResult:null,lastTransform:null};r.current=W;try{p.setPointerCapture(i.pointerId)}catch{}},d=(i)=>{let p=r.current;if(!p||i.pointerId!==p.pointerId)return;if(i.preventDefault(),p.corner.startsWith("rot-")){let g=`rotate(${Vn(p.angle,p.rotStartPointer,kt(p.cx,p.cy,i.clientX,i.clientY),!!i.shiftKey)}deg)`;p.el.style.transform=g,p.lastTransform=g;return}x(p,u(p,i))},w=(i)=>{let p=r.current;if(!p||i.pointerId!==p.pointerId)return;if(r.current=null,p.corner.startsWith("rot-")){let l=p.lastTransform;if(!l||l===p.before.transform)return;s.current={el:p.el,before:p.before},Zn(p,l);return}let E=p.lastResult??u(p,i);if(!(`${E.width}px`!==p.before.width||`${E.height}px`!==p.before.height||typeof E.left==="number"&&`${E.left}px`!==p.before.left||typeof E.top==="number"&&`${E.top}px`!==p.before.top))return;if(s.current={el:p.el,before:p.before},p.artboardId)Gn(p,E);else jn(p,E)},S=(i)=>{let p=i.data;if(p?.dgn!=="resize-failed"&&p?.dgn!=="resize-artboard-failed")return;if(i.source!==window.parent)return;let E=s.current;if(!E)return;if(E.el.style.width=E.before.width??"",E.el.style.height=E.before.height??"",E.before.left!==null||E.el.style.left)E.el.style.left=E.before.left??"";if(E.before.top!==null||E.el.style.top)E.el.style.top=E.before.top??"";if(E.before.transform!==null||E.el.style.transform)E.el.style.transform=E.before.transform??"";s.current=null};return f.addEventListener("pointerdown",h),window.addEventListener("pointermove",d),window.addEventListener("pointerup",w),window.addEventListener("pointercancel",w),window.addEventListener("message",S),()=>{f.removeEventListener("pointerdown",h),window.removeEventListener("pointermove",d),window.removeEventListener("pointerup",w),window.removeEventListener("pointercancel",w),window.removeEventListener("message",S)}},[a,x]),Jn("div",{ref:n,"aria-hidden":"true"})}import{jsx as D,jsxs as It,Fragment as fo}from"react/jsx-runtime";var oo=new Set(["drop-comment","tool","escape","hover"]);function se(){return typeof document<"u"&&!document.querySelector(".dc-canvas")}function Qe(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 ro(e,t){let n=Qe(e,t);if(!n)return null;return n.closest("[data-cd-id]")??n}function io({children:e,file:t}){let{tool:n,setTool:o}=he(),r=me(),s=F(null),[a,c]=ie(null),m=F(n);m.current=n;let v=to(()=>()=>m.current,[]);Q(()=>{if(n!=="comment")c(null)},[n]);let[x,f]=ie(null),[u,h]=ie(!1);return Q(()=>{let d=()=>h(se());d();let w=requestAnimationFrame(d),S=setTimeout(d,120);return()=>{cancelAnimationFrame(w),clearTimeout(S)}},[]),Q(()=>{if(typeof document>"u")return;let d=(w)=>{if(w.button!==0||!(w.metaKey||w.ctrlKey))return;if(!se())return;if(ne(w.target))return;let S=ro(w.clientX,w.clientY);if(!S)return;w.preventDefault(),w.stopImmediatePropagation();let i=S.getAttribute("data-cd-id"),p=xe({el:S,cdId:i,artboardId:null});if(w.shiftKey)r.add(p);else r.replace(p);f(S)};return document.addEventListener("pointerdown",d,!0),()=>document.removeEventListener("pointerdown",d,!0)},[r]),Q(()=>{if(r.selected.length===0)f(null)},[r.selected]),Q(()=>{let d=s.current;if(d)d.setAttribute("data-active-tool",n);if(typeof document<"u"&&document.body)document.body.setAttribute("data-active-tool",n);return()=>{d?.removeAttribute("data-active-tool")}},[n]),Q(()=>{if(typeof window>"u")return;let d=(w)=>{let S=w.data;if(!S||typeof S!=="object"||S.dgn!=="tool-set")return;if(typeof S.tool==="string")o(S.tool)};return window.addEventListener("message",d),()=>window.removeEventListener("message",d)},[o]),gt({hostRef:s,getActiveTool:v,claimableActions:oo,callbacks:{onHover:({clientX:d,clientY:w})=>{if(m.current!=="comment"||!se()){c(null);return}let S=Qe(d,w);c((i)=>i===S?i:S)},onTool:({tool:d})=>o(d),onEscape:()=>{if(m.current!=="move")o("move");if(c(null),r.clear(),typeof window<"u")try{window.parent.postMessage({dgn:"force-clear"},"*")}catch{}},onDropComment:({clientX:d,clientY:w})=>ao(d,w,r,t)}}),It("div",{"data-mc-host":!0,ref:s,style:{display:"contents"},children:[e,a?D(lo,{el:a}):null,x?D(so,{el:x}):null,u?D(Rt,{}):null,D(ft,{})]})}function so({el:e}){let t=F(null),n=F(e);n.current=e;let o=F(null);return Q(()=>{let r=()=>{o.current=null;let s=t.current,a=n.current;if(s&&a?.isConnected){let c=a.getBoundingClientRect();if(c.width===0&&c.height===0)s.style.display="none";else s.style.display="block",s.style.left=`${Math.round(c.left)}px`,s.style.top=`${Math.round(c.top)}px`,s.style.width=`${Math.round(c.width)}px`,s.style.height=`${Math.round(c.height)}px`}else if(s)s.style.display="none";o.current=requestAnimationFrame(r)};return o.current=requestAnimationFrame(r),()=>{if(o.current!=null)cancelAnimationFrame(o.current)}},[]),D("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 lo({el:e}){let t=F(null),n=F(e);n.current=e;let o=F(null);return Q(()=>{let r=()=>{o.current=null;let s=t.current,a=n.current;if(s&&a?.isConnected){let c=a.getBoundingClientRect();if(c.width===0&&c.height===0)s.style.display="none";else s.style.display="block",s.style.left=`${Math.round(c.left)}px`,s.style.top=`${Math.round(c.top)}px`,s.style.width=`${Math.round(c.width)}px`,s.style.height=`${Math.round(c.height)}px`}else if(s)s.style.display="none";o.current=requestAnimationFrame(r)};return o.current=requestAnimationFrame(r),()=>{if(o.current!=null)cancelAnimationFrame(o.current)}},[]),D("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 ao(e,t,n,o){if(typeof document>"u")return;let r=We(e,t)??void 0,s=Xe(e,t);if(s){let m=le(s),v=m?.getBoundingClientRect(),x={file:o,id:void 0,selector:"",artboardId:null,tag:m?.getAttribute("data-tool")??"annotation",classes:"",text:"",dom_path:[],bounds:v?{x:v.left,y:v.top,w:v.width,h:v.height}:{x:e-12,y:t-12,w:24,h:24},html:"",annotationId:s,...r?{world:r}:{}};Ke(x,e,t);return}let a=Me(document,e,t,{deep:!0});if(!a)a=Me(document,e,t,{deep:!1});if(!a&&!se()&&typeof document.elementsFromPoint==="function"){let m=document.elementsFromPoint(e,t);for(let v of m){let x=v.closest?.("[data-cd-id]");if(!x)continue;if(!x.closest(".dc-artboard-body"))continue;let f=x.closest("[data-dc-screen]");a={el:x,cdId:x.getAttribute("data-cd-id"),artboardId:f?.getAttribute("data-dc-screen")??null};break}}if(!a&&se()){let m=Qe(e,t);if(m)a={el:m,cdId:m.getAttribute("data-cd-id"),artboardId:null}}if(!a){let m={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}:{}};Ke(m,e,t);return}let c=xe(a,o);n.replace(c),Ke(c,e,t)}function Ke(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 At(e,t){return D(St,{initial:"browse",children:D(st,{children:D(io,{file:t,children:D(e,{})})})})}function Er(e,t){let n=no(t.rootEl);if(!t.commentsEnabled){n.render($e(e));return}let o=t.file??we();n.render($e(mo,{initialCanvas:e,file:o}))}var Mt="__maudeCanvasRuntime";function co({Canvas:e,file:t,onOk:n}){return Q(()=>{n()},[]),At(e,t)}class _t extends eo{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(){this.props.onError()}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}}function uo({message:e}){return $e("div",{className:"dc-hmr-holding",role:"status","aria-live":"polite",title:e?`Holding last working render — ${e}`:"Holding last working render"},"⏸ build error — držím poslední funkční verzi")}function mo({initialCanvas:e,file:t}){let[{canvas:n,attempt:o},r]=ie({canvas:e,attempt:0}),[s,a]=ie({on:!1}),c=F(null),m=F(n);m.current=n,Q(()=>{let u={remount:(h)=>r((d)=>({canvas:h,attempt:d.attempt+1})),setHolding:(h,d)=>a(h?{on:!0,message:d}:{on:!1})};return window[Mt]=u,()=>{window[Mt]=void 0}},[]);let v=ze(()=>{if(c.current=m.current,a((u)=>u.on?{on:!1}:u),o>0&&t)try{window.parent.postMessage({dgn:"loaded",file:t},"*")}catch{}},[o,t]),x=ze(()=>{a({on:!0,message:"render error"})},[]),f=ze(()=>{let u=c.current;return u?At(u,t):null},[t]);return It(fo,{children:[D(_t,{attempt:o,onError:x,fallback:f,children:D(co,{Canvas:n,file:t,onOk:v},o)}),s.on?D(uo,{message:s.message}):null]})}export{_t as CanvasErrorBoundary,se as isBareSpecimen,Er as mountCanvas,ro as pickSpecimenSelectEl};
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// single-file IIFE bundles cached under the OS temp dir so the playwright
|
|
6
6
|
// shims can `addScriptTag({ path })` without re-bundling per request.
|
|
7
7
|
|
|
8
|
-
import { existsSync } from 'node:fs';
|
|
8
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
9
9
|
import { tmpdir } from 'node:os';
|
|
10
10
|
import path from 'node:path';
|
|
11
11
|
|
|
@@ -234,12 +234,31 @@ async function writeHashedBundle(code: string, stem: string): Promise<string> {
|
|
|
234
234
|
* exports under `window[globalName]`. Caches under the OS temp dir so a long-
|
|
235
235
|
* running dev server pays the build cost once.
|
|
236
236
|
*/
|
|
237
|
+
/**
|
|
238
|
+
* The package's entry FILE on disk, found by walking up from DEV_SERVER_ROOT (V2-2.8 P1).
|
|
239
|
+
* NOT `require.resolve`: inside the `bun --compile` sidecar a runtime resolve of a package that is
|
|
240
|
+
* not embedded never reaches disk (DDR-045 class) — SVG export failed "Cannot find module
|
|
241
|
+
* 'dom-to-svg'" in the desktop app. Bun.build then bundles from this path, the way
|
|
242
|
+
* video-encode-lib.ts reaches mediabunny.
|
|
243
|
+
*/
|
|
244
|
+
export function packageEntry(name: string, from: string = DEV_SERVER_ROOT): string {
|
|
245
|
+
for (let dir = from; ; dir = path.dirname(dir)) {
|
|
246
|
+
const pkgDir = path.join(dir, 'node_modules', name);
|
|
247
|
+
const pj = path.join(pkgDir, 'package.json');
|
|
248
|
+
if (existsSync(pj)) {
|
|
249
|
+
const pkg = JSON.parse(readFileSync(pj, 'utf8')) as { module?: string; main?: string };
|
|
250
|
+
return path.join(pkgDir, pkg.module ?? pkg.main ?? 'index.js');
|
|
251
|
+
}
|
|
252
|
+
if (path.dirname(dir) === dir) throw new Error(`Cannot find package '${name}' from ${from}`);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
237
256
|
export function getBrowserBundle(packageName: string, globalName: string): Promise<string> {
|
|
238
257
|
const key = `${packageName}::${globalName}`;
|
|
239
258
|
const existing = bundles.get(key);
|
|
240
259
|
if (existing) return existing.ready;
|
|
241
260
|
|
|
242
|
-
const entry =
|
|
261
|
+
const entry = packageEntry(packageName);
|
|
243
262
|
const cachePath = path.join(
|
|
244
263
|
tmpdir(),
|
|
245
264
|
`maude-${packageName.replace(/[^a-z0-9]/gi, '_')}-${globalName}.iife.js`
|
|
@@ -29,6 +29,7 @@ import path from 'node:path';
|
|
|
29
29
|
import { readAllArtboardPrintProps } from '../canvas-edit.ts';
|
|
30
30
|
|
|
31
31
|
import type { Bus } from '../context.ts';
|
|
32
|
+
import { currentSession, normalizeSessionKey } from '../session-scope.ts';
|
|
32
33
|
import { resolveRenderLane } from '../workspace-mode.ts';
|
|
33
34
|
import {
|
|
34
35
|
type ExportContext,
|
|
@@ -115,12 +116,27 @@ export interface EnqueueArgs {
|
|
|
115
116
|
* is `local` and this is never read.
|
|
116
117
|
*/
|
|
117
118
|
remoteCanvas?: RemoteCanvasAccess;
|
|
119
|
+
/**
|
|
120
|
+
* V2-2.8 S5 — whose job this is: the proxy-vouched session key of the member
|
|
121
|
+
* who asked (session-scope.ts). Defaults to the ambient request's session;
|
|
122
|
+
* `''` (desktop, CLI, tests) is the one shared owner a desktop always had.
|
|
123
|
+
*/
|
|
124
|
+
session?: string;
|
|
118
125
|
}
|
|
119
126
|
|
|
120
127
|
export type DownloadResult =
|
|
121
128
|
| { ok: true; bytes: Uint8Array; filename: string; contentType: string }
|
|
122
129
|
| { ok: false; reason: 'missing' | 'not-done' };
|
|
123
130
|
|
|
131
|
+
/**
|
|
132
|
+
* V2-2.8 S5 (V2-1.16 L7 "everyone-fix") — every read below is scoped to ONE
|
|
133
|
+
* owner: the `session` argument, defaulting to the ambient request's session
|
|
134
|
+
* key (session-scope.ts `currentSession()`, set per request by server.ts
|
|
135
|
+
* `withSession`). A cell serves every member from one process (DDR-209), and
|
|
136
|
+
* these used to answer with every member's jobs. An invisible job answers
|
|
137
|
+
* exactly like a missing one (U1). On a desktop every key is `''`, so the
|
|
138
|
+
* answers are unchanged.
|
|
139
|
+
*/
|
|
124
140
|
export interface ExportJobQueue {
|
|
125
141
|
enqueue(args: EnqueueArgs): { id: string; result: Promise<ExportResult> };
|
|
126
142
|
/**
|
|
@@ -128,11 +144,16 @@ export interface ExportJobQueue {
|
|
|
128
144
|
* lane) so it appears in the same ledger every other export does. No bytes
|
|
129
145
|
* are kept — the file never passed through this process.
|
|
130
146
|
*/
|
|
131
|
-
recordBrowserExport(args: {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
147
|
+
recordBrowserExport(args: {
|
|
148
|
+
format: Format;
|
|
149
|
+
scope: Scope;
|
|
150
|
+
filename: string;
|
|
151
|
+
session?: string;
|
|
152
|
+
}): ExportHistoryEntry;
|
|
153
|
+
get(id: string, session?: string): ExportJob | undefined;
|
|
154
|
+
list(session?: string): ExportJob[];
|
|
155
|
+
loadHistory(session?: string): ExportHistoryEntry[];
|
|
156
|
+
getBytes(id: string, session?: string): Promise<DownloadResult>;
|
|
136
157
|
}
|
|
137
158
|
|
|
138
159
|
const HISTORY_DEPTH = 20;
|
|
@@ -304,6 +325,12 @@ export function createExportJobQueue(bus: Bus, designRoot: string): ExportJobQue
|
|
|
304
325
|
const maxConcurrent = Math.max(1, Number(process.env.MAUDE_EXPORT_MAX_CONCURRENT) || 2);
|
|
305
326
|
const semaphore = new Semaphore(maxConcurrent);
|
|
306
327
|
const jobs = new Map<string, ExportJob>();
|
|
328
|
+
// V2-2.8 S5 — job id → the session key that asked for it. Kept beside the job
|
|
329
|
+
// rather than on it so no response, socket frame or public ledger row ever
|
|
330
|
+
// carries a session key; only the on-disk ledger stores it (as `session`).
|
|
331
|
+
const owners = new Map<string, string>();
|
|
332
|
+
const ownerOf = (id: string): string => owners.get(id) ?? '';
|
|
333
|
+
const ownedBy = (session: string) => (job: ExportJob) => ownerOf(job.id) === session;
|
|
307
334
|
|
|
308
335
|
// Seed the ledger from disk ONCE — the only read of the history file. Every
|
|
309
336
|
// later persist derives fresh from `jobs` and overwrites; there is no
|
|
@@ -334,6 +361,10 @@ export function createExportJobQueue(bus: Bus, designRoot: string): ExportJobQue
|
|
|
334
361
|
filename: e.filename as string | undefined,
|
|
335
362
|
error: e.error as string | undefined,
|
|
336
363
|
});
|
|
364
|
+
// V2-2.8 S5 — a row written before ownership existed has no `session`
|
|
365
|
+
// and stays the shared ('') owner's, which in a cell is nobody.
|
|
366
|
+
const owner = normalizeSessionKey(typeof e.session === 'string' ? e.session : '');
|
|
367
|
+
if (owner) owners.set(id, owner);
|
|
337
368
|
}
|
|
338
369
|
}
|
|
339
370
|
} catch {
|
|
@@ -352,12 +383,17 @@ export function createExportJobQueue(bus: Bus, designRoot: string): ExportJobQue
|
|
|
352
383
|
.then(() => {});
|
|
353
384
|
|
|
354
385
|
function emit(job: ExportJob): void {
|
|
355
|
-
|
|
386
|
+
// V2-2.8 S5 — the socket push goes to the owner's shell only (ws.ts honours
|
|
387
|
+
// `meta.session`); a desktop job (owner '') still reaches every socket.
|
|
388
|
+
const owner = ownerOf(job.id);
|
|
389
|
+
bus.emit('export:job', { ...job }, owner ? { session: owner } : undefined);
|
|
356
390
|
}
|
|
357
391
|
|
|
358
|
-
|
|
392
|
+
/** `filter` scopes the PUBLIC view; the on-disk ledger passes none. */
|
|
393
|
+
function deriveHistory(filter?: (job: ExportJob) => boolean): ExportHistoryEntry[] {
|
|
359
394
|
return Array.from(jobs.values())
|
|
360
395
|
.filter(isFinished)
|
|
396
|
+
.filter((j) => (filter ? filter(j) : true))
|
|
361
397
|
.sort((a, b) => (b.finishedAt ?? '').localeCompare(a.finishedAt ?? ''))
|
|
362
398
|
.slice(0, HISTORY_DEPTH)
|
|
363
399
|
.map((j) => ({
|
|
@@ -379,7 +415,14 @@ export function createExportJobQueue(bus: Bus, designRoot: string): ExportJobQue
|
|
|
379
415
|
}
|
|
380
416
|
|
|
381
417
|
async function persistAndEvict(): Promise<void> {
|
|
382
|
-
|
|
418
|
+
// The ledger keeps every member's rows, each with its owner (`session`,
|
|
419
|
+
// only when there is one — a desktop ledger is byte-for-byte unchanged), so
|
|
420
|
+
// ownership survives a restart. It is runtime state (DDR-115), never served
|
|
421
|
+
// as-is: GET /_api/export-history reads `loadHistory(session)` instead.
|
|
422
|
+
const history = deriveHistory().map((entry) => {
|
|
423
|
+
const owner = entry.id ? ownerOf(entry.id) : '';
|
|
424
|
+
return owner ? { ...entry, session: owner } : entry;
|
|
425
|
+
});
|
|
383
426
|
await Bun.write(historyPath, JSON.stringify(history, null, 2));
|
|
384
427
|
|
|
385
428
|
const now = Date.now();
|
|
@@ -402,6 +445,7 @@ export function createExportJobQueue(bus: Bus, designRoot: string): ExportJobQue
|
|
|
402
445
|
});
|
|
403
446
|
for (const job of staleBytes) {
|
|
404
447
|
jobs.delete(job.id);
|
|
448
|
+
owners.delete(job.id);
|
|
405
449
|
await rm(path.join(jobsDir, job.id), { recursive: true, force: true }).catch(() => {});
|
|
406
450
|
}
|
|
407
451
|
|
|
@@ -411,7 +455,10 @@ export function createExportJobQueue(bus: Bus, designRoot: string): ExportJobQue
|
|
|
411
455
|
const byteless = Array.from(jobs.values())
|
|
412
456
|
.filter((j) => isFinished(j) && (j.deliveredInBrowser || !j.filename))
|
|
413
457
|
.sort((a, b) => (b.finishedAt ?? '').localeCompare(a.finishedAt ?? ''));
|
|
414
|
-
for (const job of byteless.slice(HISTORY_DEPTH))
|
|
458
|
+
for (const job of byteless.slice(HISTORY_DEPTH)) {
|
|
459
|
+
jobs.delete(job.id);
|
|
460
|
+
owners.delete(job.id);
|
|
461
|
+
}
|
|
415
462
|
}
|
|
416
463
|
|
|
417
464
|
function enqueue(args: EnqueueArgs): { id: string; result: Promise<ExportResult> } {
|
|
@@ -430,6 +477,8 @@ export function createExportJobQueue(bus: Bus, designRoot: string): ExportJobQue
|
|
|
430
477
|
status: 'queued',
|
|
431
478
|
createdAt: new Date().toISOString(),
|
|
432
479
|
};
|
|
480
|
+
const owner = normalizeSessionKey(args.session ?? currentSession());
|
|
481
|
+
if (owner) owners.set(id, owner);
|
|
433
482
|
jobs.set(id, job);
|
|
434
483
|
emit(job);
|
|
435
484
|
|
|
@@ -584,9 +633,15 @@ export function createExportJobQueue(bus: Bus, designRoot: string): ExportJobQue
|
|
|
584
633
|
|
|
585
634
|
return {
|
|
586
635
|
enqueue,
|
|
587
|
-
get
|
|
588
|
-
|
|
589
|
-
|
|
636
|
+
get(id, session = currentSession()) {
|
|
637
|
+
const job = jobs.get(id);
|
|
638
|
+
return job && ownerOf(id) === normalizeSessionKey(session) ? job : undefined;
|
|
639
|
+
},
|
|
640
|
+
list: (session = currentSession()) =>
|
|
641
|
+
Array.from(jobs.values())
|
|
642
|
+
.filter(ownedBy(normalizeSessionKey(session)))
|
|
643
|
+
.sort((a, b) => b.createdAt.localeCompare(a.createdAt)),
|
|
644
|
+
recordBrowserExport({ format, scope, filename, session = currentSession() }) {
|
|
590
645
|
const now = new Date().toISOString();
|
|
591
646
|
const job: ExportJob = {
|
|
592
647
|
id: crypto.randomUUID(),
|
|
@@ -600,6 +655,8 @@ export function createExportJobQueue(bus: Bus, designRoot: string): ExportJobQue
|
|
|
600
655
|
filename,
|
|
601
656
|
deliveredInBrowser: true,
|
|
602
657
|
};
|
|
658
|
+
const owner = normalizeSessionKey(session);
|
|
659
|
+
if (owner) owners.set(job.id, owner);
|
|
603
660
|
jobs.set(job.id, job);
|
|
604
661
|
emit(job);
|
|
605
662
|
// Fire-and-forget: the member already HAS the file, so a slow ledger
|
|
@@ -618,10 +675,13 @@ export function createExportJobQueue(bus: Bus, designRoot: string): ExportJobQue
|
|
|
618
675
|
deliveredInBrowser: true,
|
|
619
676
|
};
|
|
620
677
|
},
|
|
621
|
-
loadHistory:
|
|
622
|
-
|
|
678
|
+
loadHistory: (session = currentSession()) =>
|
|
679
|
+
deriveHistory(ownedBy(normalizeSessionKey(session))),
|
|
680
|
+
async getBytes(id, session = currentSession()) {
|
|
623
681
|
const job = jobs.get(id);
|
|
624
|
-
|
|
682
|
+
// Another member's job answers exactly like a missing one (V2-1.16 U1).
|
|
683
|
+
if (!job || ownerOf(id) !== normalizeSessionKey(session))
|
|
684
|
+
return { ok: false, reason: 'missing' };
|
|
625
685
|
if (job.status !== 'done') return { ok: false, reason: 'not-done' };
|
|
626
686
|
if (!job.filename) return { ok: false, reason: 'missing' };
|
|
627
687
|
const file = Bun.file(path.join(jobsDir, id, job.filename));
|
|
@@ -13,6 +13,8 @@ import type { Dirent } from 'node:fs';
|
|
|
13
13
|
import { readdir } from 'node:fs/promises';
|
|
14
14
|
import path from 'node:path';
|
|
15
15
|
|
|
16
|
+
import { isRuntimeStateRel } from '../sync/file-membership.ts';
|
|
17
|
+
|
|
16
18
|
/** The user-facing scope choices from the export dialog. */
|
|
17
19
|
export type Scope =
|
|
18
20
|
| 'selection'
|
|
@@ -161,18 +163,16 @@ function readHints(options: Record<string, unknown> | undefined): ExportScopeHin
|
|
|
161
163
|
export const MAX_SELECTION_ALL = 256;
|
|
162
164
|
const MAX_SELECTOR_LEN = 1024;
|
|
163
165
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
'.DS_Store',
|
|
175
|
-
]);
|
|
166
|
+
/**
|
|
167
|
+
* Names a `project-raw` ZIP skips that are NOT Maude runtime state — build and
|
|
168
|
+
* OS litter. Runtime state is decided by the one DDR-115 classifier below
|
|
169
|
+
* (`isRuntimeStateRel`), never by a list here: this set used to carry its own
|
|
170
|
+
* copy of the runtime names, drifted, and shipped `_chat/` (every AI
|
|
171
|
+
* conversation), `_state/`, `_untrusted/`, `_trash/`, `_draw/`, `_reports/` and
|
|
172
|
+
* each member's `_active.<session>.json` to anyone who downloaded the project
|
|
173
|
+
* (V2-2.8 S8, V2-1.16 L7).
|
|
174
|
+
*/
|
|
175
|
+
const RAW_EXCLUDES = new Set(['node_modules', 'dist', '.DS_Store']);
|
|
176
176
|
|
|
177
177
|
/**
|
|
178
178
|
* Derive a canvas slug from a repo-relative or designRoot-relative file path.
|
|
@@ -229,6 +229,9 @@ async function walkProjectRaw(root: string): Promise<string[]> {
|
|
|
229
229
|
if (e.name.endsWith('.log')) continue;
|
|
230
230
|
const abs = path.join(absDir, e.name);
|
|
231
231
|
const rel = relDir ? path.posix.join(relDir, e.name) : e.name;
|
|
232
|
+
// DDR-115 runtime state, files and whole directories alike (the
|
|
233
|
+
// classifier matches a runtime dir's own path, so the walk never enters).
|
|
234
|
+
if (isRuntimeStateRel(rel)) continue;
|
|
232
235
|
if (e.isDirectory()) {
|
|
233
236
|
await walk(abs, rel);
|
|
234
237
|
} else if (e.isFile()) {
|