@1agh/maude 0.41.0 → 0.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/studio/.ai/cache/_stats.json +7 -0
- package/apps/studio/acp/bootstrap-brief.ts +12 -2
- package/apps/studio/annotations-layer.tsx +1055 -278
- package/apps/studio/annotations-model.ts +58 -0
- package/apps/studio/api.ts +173 -63
- package/apps/studio/bin/_html-playwright.mjs +26 -4
- package/apps/studio/bin/_ingest-footage.mjs +386 -0
- package/apps/studio/bin/_pdf-playwright.mjs +13 -2
- package/apps/studio/bin/_png-playwright.mjs +15 -2
- package/apps/studio/bin/_pptx-playwright.mjs +17 -4
- package/apps/studio/bin/_probe-footage-playwright.mjs +269 -0
- package/apps/studio/bin/_screenshot-playwright.mjs +17 -2
- package/apps/studio/bin/_svg-playwright.mjs +26 -4
- package/apps/studio/bin/_video-playwright.mjs +141 -71
- package/apps/studio/bin/ingest-footage.sh +27 -0
- package/apps/studio/bin/photo-adjust.sh +163 -0
- package/apps/studio/bin/photo-bg-remove.sh +160 -0
- package/apps/studio/bin/probe-footage.sh +28 -0
- package/apps/studio/bin/read-annotations.mjs +125 -2
- package/apps/studio/bin/screenshot.sh +53 -4
- package/apps/studio/canvas-edit.ts +459 -10
- package/apps/studio/canvas-lib.tsx +523 -5
- package/apps/studio/canvas-pipeline.ts +65 -7
- package/apps/studio/canvas-shell.tsx +156 -16
- package/apps/studio/client/app.jsx +476 -88
- package/apps/studio/client/export-center.jsx +460 -0
- package/apps/studio/client/github.js +4 -0
- package/apps/studio/client/panels/GitPanel.jsx +8 -0
- package/apps/studio/client/panels/RepoBranchSwitcher.jsx +133 -21
- package/apps/studio/client/panels/StickerPicker.jsx +160 -0
- package/apps/studio/client/panels/TimelinePanel.jsx +15 -2
- package/apps/studio/client/photo-knobs.jsx +437 -0
- package/apps/studio/client/styles/3-shell-maude.css +59 -0
- package/apps/studio/client/styles/4-components.css +150 -0
- package/apps/studio/commands/edit-source-command.ts +31 -4
- package/apps/studio/config.schema.json +2 -2
- package/apps/studio/context-menu.tsx +31 -6
- package/apps/studio/dist/client.bundle.js +5561 -19
- package/apps/studio/dist/comment-mount.js +2 -2
- package/apps/studio/dist/runtime/.min-sizes.json +1 -0
- package/apps/studio/dist/runtime/@imgly_background-removal.js +5543 -0
- package/apps/studio/dist/runtime/pixi-js.js +519 -519
- package/apps/studio/dist/styles.css +1 -1
- package/apps/studio/dom-selection.ts +25 -0
- package/apps/studio/export-dialog.tsx +18 -25
- package/apps/studio/exporters/_runtime.ts +104 -0
- package/apps/studio/exporters/html.ts +12 -20
- package/apps/studio/exporters/index.ts +14 -2
- package/apps/studio/exporters/jobs.ts +376 -0
- package/apps/studio/exporters/pdf.ts +16 -20
- package/apps/studio/exporters/png.ts +12 -20
- package/apps/studio/exporters/pptx.ts +22 -23
- package/apps/studio/exporters/scope.ts +1 -0
- package/apps/studio/exporters/svg.ts +14 -22
- package/apps/studio/exporters/video.ts +37 -19
- package/apps/studio/footage/schema.test.ts +195 -0
- package/apps/studio/footage/schema.ts +484 -0
- package/apps/studio/footage-store.ts +235 -0
- package/apps/studio/fs-watch.ts +10 -0
- package/apps/studio/git/endpoints.ts +68 -7
- package/apps/studio/git/service.ts +198 -20
- package/apps/studio/github/service.ts +67 -0
- package/apps/studio/handoff.ts +3 -2
- package/apps/studio/http.ts +318 -64
- package/apps/studio/input-router.tsx +10 -0
- package/apps/studio/inspect.ts +53 -1
- package/apps/studio/paths.ts +10 -0
- package/apps/studio/photo/filters.ts +285 -0
- package/apps/studio/photo/pipeline.ts +607 -0
- package/apps/studio/photo/schema.ts +367 -0
- package/apps/studio/photo-store.ts +154 -0
- package/apps/studio/runtime-bundle.ts +29 -6
- package/apps/studio/server.ts +8 -2
- package/apps/studio/stickers/figjam-doodle/manifest.json +104 -0
- package/apps/studio/stickers/figjam-doodle/slice1.png +0 -0
- package/apps/studio/stickers/figjam-doodle/slice10.png +0 -0
- package/apps/studio/stickers/figjam-doodle/slice11.png +0 -0
- package/apps/studio/stickers/figjam-doodle/slice12.png +0 -0
- package/apps/studio/stickers/figjam-doodle/slice13.png +0 -0
- package/apps/studio/stickers/figjam-doodle/slice14.png +0 -0
- package/apps/studio/stickers/figjam-doodle/slice15.png +0 -0
- package/apps/studio/stickers/figjam-doodle/slice16.png +0 -0
- package/apps/studio/stickers/figjam-doodle/slice17.png +0 -0
- package/apps/studio/stickers/figjam-doodle/slice18.png +0 -0
- package/apps/studio/stickers/figjam-doodle/slice19.png +0 -0
- package/apps/studio/stickers/figjam-doodle/slice2.png +0 -0
- package/apps/studio/stickers/figjam-doodle/slice20.png +0 -0
- package/apps/studio/stickers/figjam-doodle/slice21.png +0 -0
- package/apps/studio/stickers/figjam-doodle/slice22.png +0 -0
- package/apps/studio/stickers/figjam-doodle/slice23.png +0 -0
- package/apps/studio/stickers/figjam-doodle/slice24.png +0 -0
- package/apps/studio/stickers/figjam-doodle/slice3.png +0 -0
- package/apps/studio/stickers/figjam-doodle/slice4.png +0 -0
- package/apps/studio/stickers/figjam-doodle/slice5.png +0 -0
- package/apps/studio/stickers/figjam-doodle/slice6.png +0 -0
- package/apps/studio/stickers/figjam-doodle/slice7.png +0 -0
- package/apps/studio/stickers/figjam-doodle/slice8.png +0 -0
- package/apps/studio/stickers/figjam-doodle/slice9.png +0 -0
- package/apps/studio/stickers/life-style/best.png +0 -0
- package/apps/studio/stickers/life-style/come-on.png +0 -0
- package/apps/studio/stickers/life-style/cut.png +0 -0
- package/apps/studio/stickers/life-style/detox.png +0 -0
- package/apps/studio/stickers/life-style/just.png +0 -0
- package/apps/studio/stickers/life-style/manifest.json +68 -0
- package/apps/studio/stickers/life-style/mirror.png +0 -0
- package/apps/studio/stickers/life-style/nice.png +0 -0
- package/apps/studio/stickers/life-style/objects.png +0 -0
- package/apps/studio/stickers/life-style/ok.png +0 -0
- package/apps/studio/stickers/life-style/queen.png +0 -0
- package/apps/studio/stickers/life-style/star.png +0 -0
- package/apps/studio/stickers/life-style/sun.png +0 -0
- package/apps/studio/stickers/life-style/water.png +0 -0
- package/apps/studio/stickers/life-style/yeah.png +0 -0
- package/apps/studio/stickers/life-style/you-can.png +0 -0
- package/apps/studio/stickers/opposing-thoughts/check-the-deets.png +0 -0
- package/apps/studio/stickers/opposing-thoughts/cut-it.png +0 -0
- package/apps/studio/stickers/opposing-thoughts/dope.png +0 -0
- package/apps/studio/stickers/opposing-thoughts/fresh.png +0 -0
- package/apps/studio/stickers/opposing-thoughts/hot.png +0 -0
- package/apps/studio/stickers/opposing-thoughts/idea.png +0 -0
- package/apps/studio/stickers/opposing-thoughts/keep-exploring.png +0 -0
- package/apps/studio/stickers/opposing-thoughts/killed-it.png +0 -0
- package/apps/studio/stickers/opposing-thoughts/love-it.png +0 -0
- package/apps/studio/stickers/opposing-thoughts/manifest.json +88 -0
- package/apps/studio/stickers/opposing-thoughts/not-sure.png +0 -0
- package/apps/studio/stickers/opposing-thoughts/ok.png +0 -0
- package/apps/studio/stickers/opposing-thoughts/pure-gold.png +0 -0
- package/apps/studio/stickers/opposing-thoughts/save-for-later.png +0 -0
- package/apps/studio/stickers/opposing-thoughts/steal-this.png +0 -0
- package/apps/studio/stickers/opposing-thoughts/take-a-peek.png +0 -0
- package/apps/studio/stickers/opposing-thoughts/this-or-that.png +0 -0
- package/apps/studio/stickers/opposing-thoughts/thoughts.png +0 -0
- package/apps/studio/stickers/opposing-thoughts/vibes.png +0 -0
- package/apps/studio/stickers/opposing-thoughts/winner.png +0 -0
- package/apps/studio/stickers/opposing-thoughts/wip.png +0 -0
- package/apps/studio/stickers/project-status/group-100.png +0 -0
- package/apps/studio/stickers/project-status/group-101.png +0 -0
- package/apps/studio/stickers/project-status/group-102.png +0 -0
- package/apps/studio/stickers/project-status/group-103.png +0 -0
- package/apps/studio/stickers/project-status/group-104.png +0 -0
- package/apps/studio/stickers/project-status/group-105.png +0 -0
- package/apps/studio/stickers/project-status/group-106.png +0 -0
- package/apps/studio/stickers/project-status/group-107.png +0 -0
- package/apps/studio/stickers/project-status/group-108.png +0 -0
- package/apps/studio/stickers/project-status/group-109.png +0 -0
- package/apps/studio/stickers/project-status/group-110.png +0 -0
- package/apps/studio/stickers/project-status/group-111.png +0 -0
- package/apps/studio/stickers/project-status/group-112.png +0 -0
- package/apps/studio/stickers/project-status/group-113.png +0 -0
- package/apps/studio/stickers/project-status/group-114.png +0 -0
- package/apps/studio/stickers/project-status/group-115.png +0 -0
- package/apps/studio/stickers/project-status/group-117.png +0 -0
- package/apps/studio/stickers/project-status/group-118.png +0 -0
- package/apps/studio/stickers/project-status/group-119.png +0 -0
- package/apps/studio/stickers/project-status/group-120.png +0 -0
- package/apps/studio/stickers/project-status/group-121.png +0 -0
- package/apps/studio/stickers/project-status/group-122.png +0 -0
- package/apps/studio/stickers/project-status/group-41.png +0 -0
- package/apps/studio/stickers/project-status/group-42.png +0 -0
- package/apps/studio/stickers/project-status/group-43.png +0 -0
- package/apps/studio/stickers/project-status/group-44.png +0 -0
- package/apps/studio/stickers/project-status/group-45.png +0 -0
- package/apps/studio/stickers/project-status/group-46.png +0 -0
- package/apps/studio/stickers/project-status/group-47.png +0 -0
- package/apps/studio/stickers/project-status/group-48.png +0 -0
- package/apps/studio/stickers/project-status/group-49.png +0 -0
- package/apps/studio/stickers/project-status/group-50.png +0 -0
- package/apps/studio/stickers/project-status/group-51.png +0 -0
- package/apps/studio/stickers/project-status/group-52.png +0 -0
- package/apps/studio/stickers/project-status/group-53.png +0 -0
- package/apps/studio/stickers/project-status/group-54.png +0 -0
- package/apps/studio/stickers/project-status/group-55.png +0 -0
- package/apps/studio/stickers/project-status/group-56.png +0 -0
- package/apps/studio/stickers/project-status/group-57.png +0 -0
- package/apps/studio/stickers/project-status/group-58.png +0 -0
- package/apps/studio/stickers/project-status/group-59.png +0 -0
- package/apps/studio/stickers/project-status/group-60.png +0 -0
- package/apps/studio/stickers/project-status/group-61.png +0 -0
- package/apps/studio/stickers/project-status/group-62.png +0 -0
- package/apps/studio/stickers/project-status/group-63.png +0 -0
- package/apps/studio/stickers/project-status/group-64.png +0 -0
- package/apps/studio/stickers/project-status/group-65.png +0 -0
- package/apps/studio/stickers/project-status/group-66.png +0 -0
- package/apps/studio/stickers/project-status/group-67.png +0 -0
- package/apps/studio/stickers/project-status/group-68.png +0 -0
- package/apps/studio/stickers/project-status/group-69.png +0 -0
- package/apps/studio/stickers/project-status/group-70.png +0 -0
- package/apps/studio/stickers/project-status/group-71.png +0 -0
- package/apps/studio/stickers/project-status/group-72.png +0 -0
- package/apps/studio/stickers/project-status/group-73.png +0 -0
- package/apps/studio/stickers/project-status/group-74.png +0 -0
- package/apps/studio/stickers/project-status/group-75.png +0 -0
- package/apps/studio/stickers/project-status/group-76.png +0 -0
- package/apps/studio/stickers/project-status/group-77.png +0 -0
- package/apps/studio/stickers/project-status/group-78.png +0 -0
- package/apps/studio/stickers/project-status/group-79.png +0 -0
- package/apps/studio/stickers/project-status/group-80.png +0 -0
- package/apps/studio/stickers/project-status/group-81.png +0 -0
- package/apps/studio/stickers/project-status/group-82.png +0 -0
- package/apps/studio/stickers/project-status/group-83.png +0 -0
- package/apps/studio/stickers/project-status/group-84.png +0 -0
- package/apps/studio/stickers/project-status/group-85.png +0 -0
- package/apps/studio/stickers/project-status/group-86.png +0 -0
- package/apps/studio/stickers/project-status/group-87.png +0 -0
- package/apps/studio/stickers/project-status/group-88.png +0 -0
- package/apps/studio/stickers/project-status/group-89.png +0 -0
- package/apps/studio/stickers/project-status/group-90.png +0 -0
- package/apps/studio/stickers/project-status/group-91.png +0 -0
- package/apps/studio/stickers/project-status/group-92.png +0 -0
- package/apps/studio/stickers/project-status/group-93.png +0 -0
- package/apps/studio/stickers/project-status/group-94.png +0 -0
- package/apps/studio/stickers/project-status/group-96.png +0 -0
- package/apps/studio/stickers/project-status/group-97.png +0 -0
- package/apps/studio/stickers/project-status/group-98.png +0 -0
- package/apps/studio/stickers/project-status/group-99.png +0 -0
- package/apps/studio/stickers/project-status/manifest.json +328 -0
- package/apps/studio/test/acp-bootstrap-brief.test.ts +11 -0
- package/apps/studio/test/acp-commands.test.ts +2 -1
- package/apps/studio/test/asset-api.test.ts +3 -3
- package/apps/studio/test/canvas-edit.test.ts +17 -6
- package/apps/studio/test/canvas-origin-gate.test.ts +19 -0
- package/apps/studio/test/dns-rebinding-guard.test.ts +27 -0
- package/apps/studio/test/dynamic-text-edit.test.ts +162 -0
- package/apps/studio/test/edit-source-command.test.ts +23 -0
- package/apps/studio/test/element-structural-edit.test.ts +46 -0
- package/apps/studio/test/export-center.test.tsx +287 -0
- package/apps/studio/test/export-shim-multi-capture.test.ts +83 -0
- package/apps/studio/test/exporters/history.test.ts +32 -3
- package/apps/studio/test/exporters/jobs.test.ts +263 -0
- package/apps/studio/test/footage-store.test.ts +100 -0
- package/apps/studio/test/git-branches.test.ts +97 -0
- package/apps/studio/test/github-api.test.ts +56 -1
- package/apps/studio/test/input-router.test.ts +33 -0
- package/apps/studio/test/inspect-script-syntax.test.ts +53 -0
- package/apps/studio/test/photo-canvas-bundle.test.ts +61 -0
- package/apps/studio/test/photo-edit-api.test.ts +201 -0
- package/apps/studio/test/photo-filters.test.ts +149 -0
- package/apps/studio/test/photo-pipeline.test.ts +106 -0
- package/apps/studio/test/photo-taxonomy.test.ts +96 -0
- package/apps/studio/test/read-annotations.test.ts +164 -0
- package/apps/studio/test/shell-importmap.test.ts +49 -0
- package/apps/studio/test/text-editability-stamp.test.ts +131 -0
- package/apps/studio/test/timeline-parse.test.ts +57 -0
- package/apps/studio/test/tool-palette-insert-anchor.test.ts +5 -3
- package/apps/studio/test/undo-stack.test.ts +33 -0
- package/apps/studio/test/video-asset.test.ts +5 -5
- package/apps/studio/test/video-render-bridge.test.ts +23 -1
- package/apps/studio/text-caret.ts +239 -0
- package/apps/studio/tool-palette.tsx +43 -20
- package/apps/studio/undo-stack.ts +94 -2
- package/apps/studio/use-annotation-resize.tsx +4 -4
- package/apps/studio/use-canvas-media-drop.tsx +38 -1
- package/apps/studio/use-selection-set.tsx +21 -0
- package/apps/studio/video-comp.tsx +48 -7
- package/apps/studio/whats-new.json +70 -0
- package/apps/studio/ws.ts +6 -0
- package/cli/commands/design.mjs +34 -3
- package/cli/lib/gitignore-block.mjs +2 -0
- package/package.json +10 -10
- package/plugins/design/templates/_shell.html +1 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Component as _0,createElement as h,Fragment as A0,useCallback as k7,useEffect as p,useMemo as I0,useRef as u,useState as $7}from"react";import{createRoot as O0}from"react-dom/client";import{useCallback as E,useEffect as S,useMemo as s,useRef as g,useState as m}from"react";function z7(){if(typeof window>"u")return;try{let Q=window.location.pathname;if(Q==="/_canvas-shell.html"||Q==="/_canvas-shell"){let $=new URLSearchParams(window.location.search),J=$.get("canvas")??"",V=($.get("designRel")??".design").replace(/^\/+|\/+$/g,"");return J?`${V}/${J}`:void 0}return decodeURIComponent(Q).replace(/^\//,"")}catch{return}}function Z7(Q){if(!Q)return"";return(Q.getAttribute("class")??"").trim().split(/\s+/).filter(($)=>$&&!$.startsWith("dgn-")&&!$.startsWith("dc-cv-")).join(" ")}function FQ(Q,$){if(!Q)return"";let J=(Q.innerText||Q.textContent||"").replace(/\s+/g," ").trim();return J.length>$?`${J.slice(0,$-1)}…`:J}function DQ(Q){if(!Q)return"";let $=[],J=Q;while(J&&J.nodeType===1&&$.length<8){let V=J.getAttribute?.("data-dc-element");if(V){$.unshift(`[data-dc-element="${V}"]`);break}let q=J.getAttribute?.("data-dc-screen");if(q){$.unshift(`[data-dc-screen="${q}"]`);break}let B=J.nodeName.toLowerCase();if(J.id){B=`#${J.id}`,$.unshift(B);break}let K=Z7(J).split(/\s+/).filter(Boolean).slice(0,2);if(K.length)B+=`.${K.join(".")}`;let X=1,F=J.previousElementSibling;while(F)X++,F=F.previousElementSibling;B+=`:nth-child(${X})`,$.unshift(B),J=J.parentElement}return $.join(" > ")}function C7(Q){let $=[],J=Q;while(J&&J.nodeType===1&&$.length<8){let V=J.nodeName.toLowerCase(),q=J.getAttribute?.("data-dc-element"),B=J.getAttribute?.("data-dc-screen");if(q)V+=`[data-dc-element="${q}"]`;else if(B)V+=`[data-dc-screen="${B}"]`;else if(J.id)V+=`#${J.id}`;let K=Z7(J).split(/\s+/).filter(Boolean).slice(0,2);if(K.length&&!q&&!B)V+=`.${K.join(".")}`;$.unshift(V),J=J.parentElement}return $}function LQ(Q){return Q.replace(/[^a-zA-Z0-9_-]/g,($)=>`\\${$}`)}function v7(Q,$){return $?`[data-dc-screen="${$}"] [data-cd-id="${Q}"]`:`[data-cd-id="${Q}"]`}function R7(Q,$,J){if(!J)return 0;try{let V=Q.querySelectorAll($);for(let q=0;q<V.length;q++)if(V[q]===J)return q}catch{}return 0}function S7(Q,$,J){if(!$||!J)return 0;return R7(Q,`[data-cd-id="${LQ($)}"]`,J)}function X7(Q,$){let J=(V)=>{try{let q=Q.querySelectorAll(V);if(!q.length)return null;let B=$.index&&$.index>0&&$.index<q.length?$.index:0;return q[B]??q[0]}catch{return null}};if($.id){let V=J(v7($.id,$.artboardId));if(V)return V}if($.selector)return J($.selector);return null}function PQ(Q,$){let J=0,V=Math.min(Q.length,$.length);for(let q=1;q<=V;q++){if(Q[Q.length-q]!==$[$.length-q])break;J++}return J}function g7(Q,$){let J=$.dom_path,V=($.tag||"").toLowerCase();if(!J||J.length===0||!V)return null;let q=Q;if($.artboardId){let F=Q.querySelector(`[data-dc-screen="${$.artboardId}"]`);if(F)q=F}let B=($.classes||"").split(/\s+/).filter(Boolean),K=null,X=0;for(let F of Array.from(q.querySelectorAll("[data-cd-id]"))){if(F.tagName.toLowerCase()!==V)continue;let j=PQ(C7(F),J);if(j===0)continue;let N=Z7(F).split(/\s+/).filter(Boolean),U=B.filter((H)=>N.includes(H)).length,G=j*10+U;if(G>X)X=G,K=F}return K}var x7=["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"],jQ=/^(style|class|data-cd-id|data-dc-|data-dcid$)/;function MQ(Q){if(!Q||typeof window>"u"||!window.getComputedStyle)return{authored:{},computed:{},customStyles:{},attrs:{}};try{let $=Q.style,J=window.getComputedStyle(Q),V={},q={},B=new Set(x7);for(let G of x7){let H=$.getPropertyValue(G);if(H)V[G]=H.trim();let Y=J.getPropertyValue(G);if(Y)q[G]=Y.trim()}let K=/^(margin|padding|border)(-|$)/,X={};for(let G=0;G<$.length;G++){let H=$.item(G);if(!H||B.has(H)||K.test(H))continue;let Y=$.getPropertyValue(H);if(Y)X[H]=Y.trim()}let F={};for(let G of Array.from(Q.attributes)){if(jQ.test(G.name))continue;F[G.name]=G.value}let j=Q.parentElement,N=j?window.getComputedStyle(j).display:"",U=j&&(N==="flex"||N==="inline-flex")?window.getComputedStyle(j).flexDirection:"";return{authored:V,computed:q,customStyles:X,attrs:F,parentDisplay:N,parentFlexDirection:U}}catch{return{authored:{},computed:{},customStyles:{},attrs:{}}}}function Y7(Q,$){let J=Q.el,V=J&&J.getBoundingClientRect?J.getBoundingClientRect():null,q=Q.cdId,B=q?v7(q,Q.artboardId):Q.artboardId?`[data-dc-screen="${Q.artboardId}"]`:DQ(J),K=q&&typeof document<"u"?R7(document,B,J):0;return{file:$??z7(),id:q??void 0,selector:B,artboardId:Q.artboardId,index:K,tag:J?.tagName.toLowerCase()??"",classes:Z7(J),text:FQ(J,240),dom_path:C7(J),bounds:V?{x:Math.round(V.left),y:Math.round(V.top),w:Math.round(V.width),h:Math.round(V.height)}:null,worldW:J instanceof HTMLElement?Math.round(J.offsetWidth):void 0,worldH:J instanceof HTMLElement?Math.round(J.offsetHeight):void 0,html:J?(J.outerHTML??"").slice(0,4000):"",...MQ(J)}}import*as H7 from"lib0/decoding";import*as a from"lib0/encoding";import{createContext as NQ,useCallback as h0,useContext as _Q,useEffect as f0,useMemo as p0,useReducer as u0,useRef as m0,useState as d0}from"react";import{Awareness as c0,applyAwarenessUpdate as l0,encodeAwarenessUpdate as r0}from"y-protocols/awareness";import{readSyncMessage as o0,writeSyncStep1 as a0,writeUpdate as s0}from"y-protocols/sync";import*as AQ from"yjs";import{jsx as e0}from"react/jsx-runtime";var IQ=NQ(null);function h7(){return _Q(IQ)}import{createContext as OQ,useCallback as l,useContext as D7,useEffect as TQ,useMemo as EQ,useRef as kQ,useState as wQ}from"react";import{jsx as F7,Fragment as xQ}from"react/jsx-runtime";var q7=OQ(null);function r(Q){return Q.id?`id:${Q.id}`:`sel:${Q.selector}`}function f7(Q){let $=[],J=new Set;for(let V of Q){let q=r(V);if(J.has(q))continue;J.add(q),$.push(V)}return $}var yQ=50;function bQ({children:Q,postTarget:$}){let[J,V]=wQ([]),q=kQ(null),B=l((G)=>{if(q.current)clearTimeout(q.current);q.current=setTimeout(()=>{q.current=null;let H=$??(typeof window<"u"?window.parent:null);if(!H)return;let Y=G.length===0?null:G.length===1?G[0]??null:G;try{H.postMessage({dgn:"select-set",selection:Y},"*")}catch{}},yQ)},[$]);TQ(()=>()=>{if(q.current)clearTimeout(q.current)},[]);let K=l((G)=>{let H=f7(Array.isArray(G)?G:[G]);V(H),B(H)},[B]),X=l((G)=>{let H=Array.isArray(G)?G:[G];V((Y)=>{let L=f7([...Y,...H]);return B(L),L})},[B]),F=l((G)=>{let H=r(G);V((Y)=>{let L=Y.filter((_)=>r(_)!==H);return B(L),L})},[B]),j=l((G)=>{let H=r(G);V((Y)=>{let L=Y.some((_)=>r(_)===H)?Y.filter((_)=>r(_)!==H):[...Y,G];return B(L),L})},[B]),N=l(()=>{V([]),B([])},[B]),U=EQ(()=>({selected:J,replace:K,add:X,remove:F,toggle:j,clear:N}),[J,K,X,F,j,N]);return F7(q7.Provider,{value:U,children:Q})}function p7({children:Q}){if(D7(q7))return F7(xQ,{children:Q});return F7(bQ,{children:Q})}function B7(){let Q=D7(q7);if(!Q)throw Error("useSelectionSet must be used inside <SelectionSetProvider>");return Q}function u7(){return D7(q7)}import{jsx as O,jsxs as k}from"react/jsx-runtime";var CQ="/_client/comments-overlay.css";function vQ(){if(typeof document>"u")return;if(document.getElementById("cm-overlay-css"))return;let Q=document.createElement("link");Q.id="cm-overlay-css",Q.rel="stylesheet",Q.href=CQ,document.head.appendChild(Q)}function RQ(){if(typeof window>"u")return null;try{let Q=window.location.pathname;if(Q==="/_canvas-shell.html"||Q==="/_canvas-shell"){let $=new URLSearchParams(window.location.search),J=$.get("canvas")??"",V=($.get("designRel")??".design").replace(/^\/+|\/+$/g,"");return J?`${V}/${J}`:null}return decodeURIComponent(Q).replace(/^\//,"")}catch{return null}}function SQ(Q){if(!Q.selector)return null;let $=null;try{let J=document.querySelectorAll(Q.selector),V=Q.index&&Q.index>0&&Q.index<J.length?Q.index:0;$=J[V]??J[0]??null}catch{$=null}if($&&Q.tag&&$.tagName.toLowerCase()!==Q.tag.toLowerCase())$=null;if(!$&&Q.dom_path?.length){let J=Q.selector.match(/data-dc-screen="([^"]+)"/)?.[1];$=g7(document,{artboardId:J,tag:Q.tag,classes:Q.classes,dom_path:Q.dom_path})}return $}function P7(Q){let $=SQ(Q);if(!$?.isConnected)return null;let J=$.getBoundingClientRect();if(J.width===0&&J.height===0)return null;return{x:J.left,y:J.top,w:J.width,h:J.height}}function c7(Q,$){let V=typeof window<"u"?window.innerWidth:Q.x+$.w,q=typeof window<"u"?window.innerHeight:Q.y+$.h,B=Q.x;if(B+$.w+8>V){let X=Q.x-$.w;B=X>=8?X:Math.max(8,V-$.w-8)}let K=Q.y;if(K+$.h+8>q){let X=Q.y-$.h;K=X>=8?X:Math.max(8,q-$.h-8)}return{x:B,y:K}}function l7(){vQ();let Q=u7(),[$,J]=m([]),[V,q]=m(null),[B,K]=m(null),X=s(()=>RQ(),[]);S(()=>{if(typeof document>"u")return;let W=document.getElementById("dgn-pin-layer");if(!W)return;let D=W.style.display;return W.style.display="none",()=>{W.style.display=D}},[]);let F=E((W)=>{if(!Q)return;if(!W?.selector){Q.clear();return}let D=W.selector.match(/data-cd-id="([^"]+)"/),M=D?D[1]:void 0,A,T;try{let P=document.querySelector(W.selector);if(P)A=P.tagName.toLowerCase(),T=(P.getAttribute("class")??"").split(/\s+/).filter((I)=>I&&!I.startsWith("dgn-")&&!I.startsWith("dc-cv-")).join(" ")}catch{}Q.replace({file:X??void 0,id:M,selector:W.selector,tag:A,classes:T,bounds:W.bounds??void 0})},[Q,X]),j=g($);j.current=$;let N=h7();S(()=>{if(!N)return;let W=N.doc.getArray("comments"),D=()=>{J(W.toArray())};if(W.length>0)D();return W.observe(D),()=>{try{W.unobserve(D)}catch{}}},[N]),S(()=>{if(typeof window>"u")return;let W=(D)=>{let M=D.data;if(!M||typeof M!=="object"||!M.dgn)return;if(M.dgn==="comments-set"&&Array.isArray(M.comments))J(M.comments);else if(M.dgn==="comment-focus"){let A=typeof M.id==="string"?M.id:null;q(A);let T=A?j.current.find((P)=>P.id===A):void 0;F(T)}};return window.addEventListener("message",W),()=>window.removeEventListener("message",W)},[F]),S(()=>{if(typeof document>"u")return;let W=(D)=>{let M=D.detail;if(!M?.selection)return;K({selection:M.selection,clientX:typeof M.clientX==="number"?M.clientX:0,clientY:typeof M.clientY==="number"?M.clientY:0})};return document.addEventListener("cm:open-composer",W),()=>document.removeEventListener("cm:open-composer",W)},[]);let U=E(()=>{if(K(null),typeof window>"u")return;try{window.parent.postMessage({dgn:"force-clear"},"*")}catch{}},[]),G=E((W)=>{if(!B)return;let D=B.selection,M={file:D.file,selector:D.selector,index:D.index,dom_path:D.dom_path,tag:D.tag,classes:D.classes,bounds:D.bounds,html_excerpt:D.html,text:W};if(typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-submit",payload:M},"*")}catch{}U()},[B,U]);S(()=>{if(!X)return;let W=!1;return(async()=>{try{let D=await fetch(`/_comments?file=${encodeURIComponent(X)}`);if(!D.ok)return;let M=await D.json();if(W)return;if(Array.isArray(M.comments))J((A)=>A.length===0?M.comments??[]:A)}catch{}})(),()=>{W=!0}},[X]);let H=s(()=>{return $.slice().sort((D,M)=>D.created.localeCompare(M.created)).filter((D)=>D.status!=="resolved")},[$]),Y=s(()=>{let W=new Map;return $.slice().sort((M,A)=>M.created.localeCompare(A.created)).forEach((M,A)=>{W.set(M.id,A+1)}),W},[$]),L=E((W)=>{if(q(W),F($.find((D)=>D.id===W)),typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-click",id:W},"*")}catch{}},[$,F]),_=E((W,D)=>{if(typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-patch",id:W,patch:D},"*")}catch{}},[]),Z=E((W)=>{if(typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-delete",id:W},"*")}catch{}q((D)=>D===W?null:D)},[]),z=E(async(W,D)=>{if(typeof fetch>"u")return!1;try{let M=await fetch(`/_api/comments/${encodeURIComponent(W)}/reply`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({body:D})});if(!M.ok)return!1;let A=await M.json();return J((T)=>T.map((P)=>P.id===A.id?A:P)),!0}catch{return!1}},[]);return k("div",{className:"cm-layer","aria-hidden":!1,children:[H.map((W)=>{let D=Y.get(W.id)??0;return O(pQ,{comment:W,sequence:D,focused:V===W.id,onClick:L,onOrphaned:Z},W.id)}),B?O(uQ,{state:B,onSubmit:G,onCancel:U}):null,(()=>{if(!V)return null;let W=H.find((D)=>D.id===V);if(!W)return null;return O(mQ,{comment:W,sequence:Y.get(W.id)??0,onClose:()=>{q(null),Q?.clear()},onPatch:(D)=>_(W.id,D),onDelete:()=>Z(W.id),onReply:(D)=>z(W.id,D)})})()]})}var L7=null;async function gQ(){if(!L7)L7=(async()=>{try{let Q=await fetch("/_api/git-committers");if(!Q.ok)return[];let $=await Q.json();return Array.isArray($.committers)?$.committers:[]}catch{return[]}})();return L7}function m7(Q){return(Q.trim().split(/\s+/)[0]??"").replace(/[^\w.-]/g,"").toLowerCase()}function hQ(Q,$){if($<=0||$>Q.length)return null;let J=$-1;while(J>=0){let V=Q[J]??"";if(V==="@"){let q=J>0?Q[J-1]:"";if(J===0||/\s/.test(q??"")){let B=Q.slice(J+1,$);return{start:J,end:$,query:B}}return null}if(!/[\w.-]/.test(V))return null;J-=1}return null}function r7({className:Q,value:$,onChange:J,onKeyDown:V,placeholder:q,rows:B,disabled:K,textareaRef:X,ariaLabel:F}){let j=g(null),N=E((P)=>{if(j.current=P,X)X.current=P},[X]),[U,G]=m([]),[H,Y]=m(null),[L,_]=m(0),Z=E(()=>{if(U.length>0)return;gQ().then((P)=>G(P))},[U.length]),z=s(()=>{if(!H)return[];let P=H.query.toLowerCase();return(!P?U:U.filter((w)=>w.name.toLowerCase().includes(P)||w.email.toLowerCase().includes(P))).slice(0,8)},[H,U]),W=E((P)=>{let I=P.selectionStart??P.value.length,w=hQ(P.value,I);Y(w),_(0)},[]),D=E((P)=>{J(P.target.value),W(P.target)},[J,W]),M=E((P)=>{if(!H)return;let I=j.current;if(!I)return;let w=`@${m7(P.name)}`,f=`${$.slice(0,H.start)}${w} ${$.slice(H.end)}`;J(f),Y(null);let x=H.start+w.length+1;requestAnimationFrame(()=>{I.focus(),I.setSelectionRange(x,x)})},[H,$,J]),A=E((P)=>{if(H&&z.length>0){if(P.key==="ArrowDown"){P.preventDefault(),_((I)=>(I+1)%z.length);return}if(P.key==="ArrowUp"){P.preventDefault(),_((I)=>(I-1+z.length)%z.length);return}if(P.key==="Enter"||P.key==="Tab"){P.preventDefault();let I=z[L]??z[0];if(I)M(I);return}if(P.key==="Escape"){P.preventDefault(),Y(null);return}}V?.(P)},[H,z,L,M,V]),T=E((P)=>{W(P.currentTarget)},[W]);return k("div",{style:{position:"relative"},children:[O("textarea",{ref:N,className:Q,value:$,placeholder:q,rows:B,disabled:K,"aria-label":F,onChange:D,onKeyDown:A,onFocus:Z,onSelect:T,onClick:T}),H&&z.length>0?O("ul",{className:"cm-mention-popup",role:"listbox","aria-label":"Mention suggestions",style:{left:0,top:"100%"},children:z.map((P,I)=>{return k("li",{role:"option","aria-selected":I===L,className:"cm-mention-popup__item",onMouseEnter:()=>_(I),onMouseDown:(f)=>{f.preventDefault(),M(P)},children:[k("span",{className:"cm-mention-popup__name",children:["@",m7(P.name)]}),O("span",{className:"cm-mention-popup__email",children:P.email})]},`${P.name}-${P.email}`)})}):null]})}var fQ=3000;function pQ({comment:Q,sequence:$,focused:J,onClick:V,onOrphaned:q}){let B=g(null),K=g(null),X=g(null);S(()=>{let N=()=>{K.current=null;let U=B.current;if(!U)return;let G=P7(Q);if(G)X.current=null;else{if(X.current==null)X.current=Date.now();else if(Date.now()-X.current>fQ)q(Q.id);if(Q.bounds)G={x:Q.bounds.x,y:Q.bounds.y,w:Q.bounds.w,h:Q.bounds.h}}if(!G){U.style.display="none",K.current=requestAnimationFrame(N);return}U.style.display="grid";let H=Math.round(G.x+G.w-12),Y=Math.round(G.y-12);U.style.left=`${H}px`,U.style.top=`${Y}px`,K.current=requestAnimationFrame(N)};return K.current=requestAnimationFrame(N),()=>{if(K.current!=null)cancelAnimationFrame(K.current)}},[Q,q]);let F=Q.author?.trim()||"unknown",j=`Comment ${$} by ${F}`;return O("button",{ref:B,type:"button",className:"cm-pin","data-resolved":Q.status==="resolved"?"true":"false","data-focused":J?"true":"false","data-comment-pin":Q.id,"aria-label":j,"aria-expanded":J,title:Q.text.slice(0,200),onClick:(N)=>{N.preventDefault(),N.stopPropagation(),V(Q.id)},children:$})}function uQ({state:Q,onSubmit:$,onCancel:J}){let[V,q]=m(""),B=g(null),K=g(null),X=g(null);S(()=>{let U=()=>{X.current=null;let G=K.current;if(!G)return;let H=cQ(Q),Y=c7(H,{w:G.offsetWidth,h:G.offsetHeight});G.style.left=`${Math.round(Y.x)}px`,G.style.top=`${Math.round(Y.y)}px`,X.current=requestAnimationFrame(U)};return X.current=requestAnimationFrame(U),()=>{if(X.current!=null)cancelAnimationFrame(X.current)}},[Q]),S(()=>{B.current?.focus()},[]);let F=E(()=>{let U=V.trim();if(!U)return;$(U)},[V,$]),j=E((U)=>{if(U.key==="Escape"){U.preventDefault(),J();return}if((U.metaKey||U.ctrlKey)&&U.key==="Enter")U.preventDefault(),F()},[J,F]),N=s(()=>{let U=Q.selection.selector||"";if(!U)return Q.selection.tag||"canvas";let G=U.match(/data-cd-id="([^"]+)"/);if(G)return`cd:${G[1]}`;return U.length>36?`${U.slice(0,33)}…`:U},[Q.selection]);return k("div",{ref:K,className:"cm-composer",role:"dialog","aria-label":"New comment",onClick:(U)=>U.stopPropagation(),onPointerDown:(U)=>U.stopPropagation(),children:[k("div",{className:"cm-composer__head",children:[O("span",{children:"New comment"}),O("span",{className:"cm-composer__selector",children:N})]}),O(r7,{textareaRef:B,className:"cm-composer__textarea",value:V,placeholder:"Type a comment. ⌘↵ to save · Esc to cancel · @name to tag",onChange:q,onKeyDown:j,rows:3,ariaLabel:"Comment body"}),k("div",{className:"cm-composer__actions",children:[O("button",{type:"button",className:"cm-btn",onClick:J,children:"Cancel"}),O("button",{type:"button",className:"cm-btn cm-btn--primary",disabled:!V.trim(),onClick:F,children:"Save"})]})]})}function mQ({comment:Q,sequence:$,onClose:J,onPatch:V,onDelete:q,onReply:B}){let K=g(null),X=g(null),F=g(null),[j,N]=m(""),[U,G]=m(!1);S(()=>{let Z=()=>{F.current=null;let z=K.current;if(!z)return;let W=iQ(Q),D=c7(W,{w:z.offsetWidth,h:z.offsetHeight});z.style.left=`${Math.round(D.x)}px`,z.style.top=`${Math.round(D.y)}px`,F.current=requestAnimationFrame(Z)};return F.current=requestAnimationFrame(Z),()=>{if(F.current!=null)cancelAnimationFrame(F.current)}},[Q]),S(()=>{K.current?.focus();let Z=Q.id;return()=>{document.querySelector(`[data-comment-pin="${Z}"]`)?.focus()}},[Q.id]),S(()=>{if(typeof document>"u")return;let Z=(z)=>{if(z.key!=="Escape")return;let W=K.current;if(!W)return;if(W.contains(z.target)||document.activeElement===W)z.preventDefault(),J()};return document.addEventListener("keydown",Z),()=>document.removeEventListener("keydown",Z)},[J]);let H=E(async()=>{let Z=j.trim();if(!Z||U)return;G(!0);let z=await B(Z);if(G(!1),z)N(""),X.current?.focus()},[j,U,B]),Y=E((Z)=>{if((Z.metaKey||Z.ctrlKey)&&Z.key==="Enter")Z.preventDefault(),H()},[H]),L=`cm-thread-head-${Q.id}`,_=dQ(Q.selector,"");return k("div",{ref:K,className:"cm-thread",role:"dialog","aria-labelledby":L,tabIndex:-1,onClick:(Z)=>Z.stopPropagation(),onPointerDown:(Z)=>Z.stopPropagation(),children:[k("div",{className:"cm-thread__head",id:L,children:[k("div",{className:"cm-thread__head-row",children:[O("span",{className:"cm-thread__seq","aria-hidden":"true",children:$}),O("span",{className:"cm-thread__author",children:Q.author?.trim()||"unknown"}),O("span",{className:"cm-thread__time",children:i7(Q.created)}),O("button",{type:"button",className:"cm-thread__close","aria-label":"Close thread",title:"Close · Esc",onClick:J,children:"×"})]}),_?O("code",{className:"cm-thread__selector",children:_}):null]}),O("div",{className:"cm-thread__body",children:d7(Q.text)}),(Q.thread??[]).map((Z)=>k("div",{className:"cm-thread__reply",children:[k("div",{className:"cm-thread__reply-head",children:[O("span",{className:"cm-thread__reply-author",children:Z.author?.trim()||"unknown"}),O("span",{className:"cm-thread__reply-time",children:i7(Z.created)})]}),O("div",{className:"cm-thread__reply-body",children:d7(Z.body)})]},Z.id)),k("div",{className:"cm-thread__reply-form",children:[O(r7,{textareaRef:X,className:"cm-thread__reply-textarea",value:j,placeholder:"Reply… ⌘↵ to send · @name to tag",onChange:N,onKeyDown:Y,rows:2,ariaLabel:"Reply",disabled:U}),O("div",{className:"cm-thread__reply-actions",children:O("button",{type:"button",className:"cm-btn cm-btn--primary",disabled:!j.trim()||U,onClick:()=>void H(),children:"Send"})})]}),k("div",{className:"cm-thread__actions",children:[Q.status==="resolved"?O("button",{type:"button",className:"cm-btn",onClick:()=>V({status:"open"}),children:"↺ Reopen"}):O("button",{type:"button",className:"cm-btn cm-btn--primary",onClick:()=>{V({status:"resolved"}),J()},children:"✓ Resolve"}),O("button",{type:"button",className:"cm-btn cm-btn--danger",onClick:()=>{q(),J()},children:"Delete"})]})]})}function d7(Q){if(!Q)return null;let $=/(@[\w][\w.-]*)/g;return Q.split($).map((V,q)=>{let B=`${q}:${V}`;if(q%2===1)return O("strong",{"data-mention":"true",children:V},B);return O("span",{children:V},B)})}function i7(Q){if(!Q)return"";let $=Date.parse(Q);if(!Number.isFinite($))return"";let J=Math.round((Date.now()-$)/1000);if(J<60)return`${Math.max(J,0)}s ago`;if(J<3600)return`${Math.round(J/60)}m ago`;if(J<86400)return`${Math.round(J/3600)}h ago`;return`${Math.round(J/86400)}d ago`}function dQ(Q,$){if(!Q)return $;let J=Q.match(/data-cd-id="([^"]+)"/);if(J)return`cd:${J[1]}`;return Q.length>36?`${Q.slice(0,33)}…`:Q}function iQ(Q){let $=Q.selector?P7(Q):null;if($)return{x:$.x+$.w-12,y:$.y+16};if(Q.bounds)return{x:Q.bounds.x+Q.bounds.w-12,y:Q.bounds.y+16};return{x:16,y:16}}function cQ(Q){if(Q.clientX||Q.clientY)return{x:Q.clientX,y:Q.clientY+8};if(Q.selection.selector){let $=P7(Q.selection);if($)return{x:$.x,y:$.y+$.h+8}}return{x:16,y:16}}import{useEffect as lQ}from"react";var rQ=new Set(["pen","highlighter","shape","rect","ellipse","arrow","sticky","text","section","eraser"]);function n7(Q){return rQ.has(Q)}var j7=(Q)=>!!(Q.metaKey||Q.ctrlKey);function t(Q){if(Q.type==="keydown"){if(Q.isEditable)return{kind:"no-op"};if(Q.metaKey||Q.ctrlKey||Q.altKey){if(Q.key==="Escape")return{kind:"escape"};let J=(Q.key||"").toLowerCase();if(!Q.altKey&&(Q.metaKey||Q.ctrlKey)){if(J==="z"&&Q.shiftKey)return{kind:"redo"};if(J==="z")return{kind:"undo"};if(J==="y"&&!Q.shiftKey)return{kind:"redo"}}return{kind:"no-op"}}let $=(Q.key||"").toLowerCase();if($==="v")return{kind:"tool",tool:"move"};if($==="h")return{kind:"tool",tool:"hand"};if($==="c")return{kind:"tool",tool:"comment"};if($==="b")return{kind:"tool",tool:"pen"};if($==="i")return{kind:"tool",tool:"highlighter"};if($==="r"||$==="o")return{kind:"tool",tool:"shape"};if($==="a")return{kind:"tool",tool:"arrow"};if($==="n")return{kind:"tool",tool:"sticky"};if($==="t")return{kind:"tool",tool:"text"};if($==="s"&&Q.shiftKey)return{kind:"tool",tool:"section"};if($==="e")return{kind:"tool",tool:"eraser"};if(Q.key==="Escape")return{kind:"escape"};return{kind:"no-op"}}if(Q.type==="contextmenu")return{kind:"context-menu",clientX:Q.clientX??0,clientY:Q.clientY??0};if(Q.type==="pointermove"){if(n7(Q.activeTool))return{kind:"no-op"};if(Q.activeTool==="hand")return{kind:"no-op"};if(Q.activeTool==="comment")return{kind:"hover",deep:!0,clientX:Q.clientX??0,clientY:Q.clientY??0};if(!j7(Q))return{kind:"no-op"};return{kind:"hover",deep:!0,clientX:Q.clientX??0,clientY:Q.clientY??0}}if(Q.type==="pointerdown"){if(Q.button===2)return{kind:"context-menu",clientX:Q.clientX??0,clientY:Q.clientY??0};if(Q.button===1||Q.spaceHeld)return{kind:"no-op"};if(Q.button!==0)return{kind:"no-op"};if(n7(Q.activeTool)&&!j7(Q))return{kind:"no-op"};if(Q.activeTool==="comment")return{kind:"drop-comment",clientX:Q.clientX??0,clientY:Q.clientY??0};if(Q.activeTool==="hand")return{kind:"no-op"};if(!j7(Q))return{kind:"no-op"};return{kind:"select",mode:!!Q.shiftKey?"add":"replace",deep:!0,clientX:Q.clientX??0,clientY:Q.clientY??0}}return{kind:"no-op"}}function nQ(Q){if(!Q||!Q.tagName)return!1;let $=Q,J=$.tagName;if(J==="INPUT"||J==="TEXTAREA"||J==="SELECT")return!0;if($.isContentEditable)return!0;return!1}function e(Q){if(!Q||!Q.closest)return!1;return!!Q.closest(".cm-composer, .cm-thread, .cm-mention-popup, .cm-pin, [data-mediaref-player]")}function o7(Q){let{hostRef:$,getActiveTool:J,isSpaceHeld:V,callbacks:q,enabled:B=!0,claimableActions:K}=Q;lQ(()=>{if(!B)return;let X=$.current;if(!X)return;let F=(Z)=>K&&Z.kind!=="no-op"&&!K.has(Z.kind)?{kind:"no-op"}:Z,j=(Z)=>{switch(Z.kind){case"hover":q.onHover?.(Z);break;case"select":q.onSelect?.(Z);break;case"drop-comment":q.onDropComment?.(Z);break;case"context-menu":q.onContextMenu?.(Z);break;case"tool":q.onTool?.(Z);break;case"escape":q.onEscape?.();break;case"undo":q.onUndo?.();break;case"redo":q.onRedo?.();break;case"no-op":break}},N=(Z)=>{let z=F(t({type:"pointermove",button:Z.button,metaKey:Z.metaKey,ctrlKey:Z.ctrlKey,shiftKey:Z.shiftKey,altKey:Z.altKey,clientX:Z.clientX,clientY:Z.clientY,spaceHeld:V?.()??!1,activeTool:J()}));j(z)},U=(Z)=>{if(e(Z.target))return;let z=F(t({type:"pointerdown",button:Z.button,metaKey:Z.metaKey,ctrlKey:Z.ctrlKey,shiftKey:Z.shiftKey,altKey:Z.altKey,clientX:Z.clientX,clientY:Z.clientY,spaceHeld:V?.()??!1,activeTool:J()}));if(z.kind!=="no-op")Z.preventDefault(),Z.stopImmediatePropagation();j(z)},G=(Z)=>{if(e(Z.target))return;let z=F(t({type:"pointerdown",button:Z.button,metaKey:Z.metaKey,ctrlKey:Z.ctrlKey,shiftKey:Z.shiftKey,altKey:Z.altKey,clientX:Z.clientX,clientY:Z.clientY,spaceHeld:V?.()??!1,activeTool:J()}));if(z.kind!=="no-op"){if(Z.preventDefault(),Z.stopImmediatePropagation(),z.kind==="select")try{window.focus()}catch{}}},H=(Z)=>{if(e(Z.target))return;let z=J(),W=Z.metaKey||Z.ctrlKey,D=z==="comment"?"drop-comment":z==="move"&&W&&Z.button===0?"select":Z.button===2?"context-menu":null;if(D&&(!K||K.has(D)))Z.preventDefault(),Z.stopImmediatePropagation()},Y=(Z)=>{let z=F(t({type:"contextmenu",clientX:Z.clientX,clientY:Z.clientY,metaKey:Z.metaKey,ctrlKey:Z.ctrlKey,shiftKey:Z.shiftKey,altKey:Z.altKey,activeTool:J()}));if(z.kind==="no-op")return;Z.preventDefault(),Z.stopImmediatePropagation(),j(z)},L=(Z)=>{let z=F(t({type:"keydown",key:Z.key,metaKey:Z.metaKey,ctrlKey:Z.ctrlKey,shiftKey:Z.shiftKey,altKey:Z.altKey,isEditable:nQ(Z.target),activeTool:J()}));if(z.kind==="tool"||z.kind==="escape"||z.kind==="undo"||z.kind==="redo")Z.preventDefault();j(z)};X.addEventListener("pointermove",N,{passive:!0}),X.addEventListener("pointerdown",U,{capture:!0}),X.addEventListener("mousedown",G,{capture:!0}),X.addEventListener("click",H,{capture:!0}),X.addEventListener("contextmenu",Y,{capture:!0});let _=X.ownerDocument??document;return _.addEventListener("keydown",L,!0),()=>{X.removeEventListener("pointermove",N),X.removeEventListener("pointerdown",U,{capture:!0}),X.removeEventListener("mousedown",G,{capture:!0}),X.removeEventListener("click",H,{capture:!0}),X.removeEventListener("contextmenu",Y,{capture:!0}),_.removeEventListener("keydown",L,!0)}},[B,$,J,V,q,K])}function M7(Q,$,J,V){let q=Q.elementFromPoint($,J);if(!q)return null;if(q.closest?.(".dc-mm, .dc-zoom-tb, .dc-tool-palette, .dc-context-menu, .dc-cv-group-bbox"))return null;let B=q.closest?.("[data-dc-screen]")??null,K=B?.getAttribute("data-dc-screen")??null,X=q.closest?.(".dc-artboard-body")??null;if(!X){if(B&&K)return{el:B,cdId:null,artboardId:K};return null}if(q===X){if(B&&K)return{el:B,cdId:null,artboardId:K};return null}if(V.deep){let G=q.getAttribute?.("data-cd-id")??null;return{el:q,cdId:G,artboardId:K}}let F=q,j=null;while(F&&F!==X){if(F.hasAttribute?.("data-cd-id"))j=F;F=F.parentElement}let N=j??q,U=N.getAttribute?.("data-cd-id")??null;return{el:N,cdId:U,artboardId:K}}import{useCallback as U0,useEffect as QQ,useRef as W7}from"react";var oQ=!1;function a7(){return oQ}import{createContext as Z0,useCallback as I7,useContext as t7,useEffect as q0,useMemo as B0,useState as O7}from"react";function d(Q,$,J,V){return`url("data:image/svg+xml,${encodeURIComponent(Q.trim())}") ${$} ${J}, ${V}`}var _7="width='24' height='24' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'",A7="#1f1f1f",N7="stroke='#ffffff' stroke-linejoin='round' stroke-linecap='round'";function i(Q,$,J){let V=J?`<g transform='${J}'>`:"";return`<svg ${_7}>${V}<path fill='#ffffff' d='${Q}'/><path fill='${A7}' d='${$}'/>${J?"</g>":""}</svg>`}var s7="translate(0,32) scale(1,-1)",aQ=d(i("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"),sQ=d(i("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"),tQ=d(i("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"),eQ=d(i("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",s7),6,18,"crosshair"),Q0=d(i("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",s7),6,18,"crosshair"),Q7=d(i("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"),$0=d(i("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"),J0=d(`<svg ${_7}><path d='M16 4V28M11 4H21M11 28H21' fill='none' ${N7} stroke-width='5'/><path d='M16 4V28M11 4H21M11 28H21' fill='none' stroke='${A7}' stroke-width='2.25' stroke-linecap='round'/></svg>`,12,12,"text"),V0=d(`<svg ${_7}><path d='M6 5H21L26 10V27H6Z' fill='${A7}' ${N7} stroke-width='2.5'/><path d='M21 5V11H26' fill='none' ${N7} stroke-width='2.25'/></svg>`,5,5,"crosshair"),R=Object.freeze({move:aQ,hand:sQ,comment:tQ,pen:eQ,section:Q7,highlighter:Q0,shape:Q7,rect:Q7,ellipse:Q7,sticky:V0,arrow:Q7,text:J0,eraser:$0});import{jsx as T7,Fragment as K0}from"react/jsx-runtime";var G0=Object.freeze([{id:"move",label:"Move",shortcut:"V",cursor:R.move},{id:"hand",label:"Hand",shortcut:"H",cursor:R.hand},{id:"comment",label:"Comment",shortcut:"C",cursor:R.comment},{id:"pen",label:"Pen",shortcut:"B",cursor:R.pen},{id:"highlighter",label:"Highlighter",shortcut:"I",cursor:R.highlighter},{id:"shape",label:"Shape",shortcut:"R",cursor:R.shape},{id:"sticky",label:"Sticky",shortcut:"N",cursor:R.sticky},{id:"section",label:"Section",shortcut:"⇧S",cursor:R.shape},{id:"arrow",label:"Arrow",shortcut:"A",cursor:R.arrow},{id:"text",label:"Text",shortcut:"T",cursor:R.text},{id:"eraser",label:"Eraser",shortcut:"E",cursor:R.eraser}]),E7=Z0(null);function W0({children:Q,tools:$=G0,initial:J="move"}){let[V,q]=O7(J),[B,K]=O7(()=>({tool:null,locked:!1})),X=I7((H)=>{q(H),K((Y)=>Y.locked&&Y.tool===H?Y:{tool:null,locked:!1})},[]),F=I7((H)=>{K((Y)=>{if(Y.locked&&Y.tool===H)return{tool:null,locked:!1};return{tool:H,locked:!0}}),q(H)},[]),j=I7(()=>{K({tool:null,locked:!1})},[]),[N,U]=O7("rounded");q0(()=>{if(typeof document>"u")return;let H=$.find((_)=>_.id===V);if(!H)return;let Y=document.body.style.cursor;document.body.style.cursor=H.cursor;let L=document.getElementById("dc-tool-cursor");if(!L)L=document.createElement("style"),L.id="dc-tool-cursor",document.head.appendChild(L);if(L.textContent=`* { cursor: ${H.cursor} !important; }`,typeof window<"u"&&window.parent&&window.parent!==window)try{window.parent.postMessage({dgn:"tool-cursor",tool:V},"*")}catch{}return()=>{document.body.style.cursor=Y;let _=document.getElementById("dc-tool-cursor");if(_)_.textContent=""}},[V,$]);let G=B0(()=>({tool:V,setTool:X,tools:$,sticky:B,toggleSticky:F,clearSticky:j,shapeKind:N,setShapeKind:U}),[V,X,$,B,F,j,N]);return T7(E7.Provider,{value:G,children:Q})}function e7({children:Q}){if(t7(E7))return T7(K0,{children:Q});return T7(W0,{children:Q})}function G7(){let Q=t7(E7);if(!Q)throw Error("useToolMode must be used inside <ToolProvider>");return Q}import{jsx as N0}from"react/jsx-runtime";var z0=`
|
|
1
|
+
import{Component as _Q,createElement as h,Fragment as AQ,useCallback as k7,useEffect as p,useMemo as IQ,useRef as u,useState as Q7}from"react";import{createRoot as OQ}from"react-dom/client";import{useCallback as E,useEffect as R,useMemo as s,useRef as g,useState as m}from"react";function z7(){if(typeof window>"u")return;try{let J=window.location.pathname;if(J==="/_canvas-shell.html"||J==="/_canvas-shell"){let Q=new URLSearchParams(window.location.search),$=Q.get("canvas")??"",V=(Q.get("designRel")??".design").replace(/^\/+|\/+$/g,"");return $?`${V}/${$}`:void 0}return decodeURIComponent(J).replace(/^\//,"")}catch{return}}function Z7(J){if(!J)return"";return(J.getAttribute("class")??"").trim().split(/\s+/).filter((Q)=>Q&&!Q.startsWith("dgn-")&&!Q.startsWith("dc-cv-")).join(" ")}function FJ(J,Q){if(!J)return"";let $=(J.innerText||J.textContent||"").replace(/\s+/g," ").trim();return $.length>Q?`${$.slice(0,Q-1)}…`:$}function DJ(J){if(!J)return"";let Q=[],$=J;while($&&$.nodeType===1&&Q.length<8){let V=$.getAttribute?.("data-dc-element");if(V){Q.unshift(`[data-dc-element="${V}"]`);break}let q=$.getAttribute?.("data-dc-screen");if(q){Q.unshift(`[data-dc-screen="${q}"]`);break}let B=$.nodeName.toLowerCase();if($.id){B=`#${$.id}`,Q.unshift(B);break}let K=Z7($).split(/\s+/).filter(Boolean).slice(0,2);if(K.length)B+=`.${K.join(".")}`;let U=1,H=$.previousElementSibling;while(H)U++,H=H.previousElementSibling;B+=`:nth-child(${U})`,Q.unshift(B),$=$.parentElement}return Q.join(" > ")}function C7(J){let Q=[],$=J;while($&&$.nodeType===1&&Q.length<8){let V=$.nodeName.toLowerCase(),q=$.getAttribute?.("data-dc-element"),B=$.getAttribute?.("data-dc-screen");if(q)V+=`[data-dc-element="${q}"]`;else if(B)V+=`[data-dc-screen="${B}"]`;else if($.id)V+=`#${$.id}`;let K=Z7($).split(/\s+/).filter(Boolean).slice(0,2);if(K.length&&!q&&!B)V+=`.${K.join(".")}`;Q.unshift(V),$=$.parentElement}return Q}function LJ(J){return J.replace(/[^a-zA-Z0-9_-]/g,(Q)=>`\\${Q}`)}function v7(J,Q){return Q?`[data-dc-screen="${Q}"] [data-cd-id="${J}"]`:`[data-cd-id="${J}"]`}function S7(J,Q,$){if(!$)return 0;try{let V=J.querySelectorAll(Q);for(let q=0;q<V.length;q++)if(V[q]===$)return q}catch{}return 0}function R7(J,Q,$){if(!Q||!$)return 0;return S7(J,`[data-cd-id="${LJ(Q)}"]`,$)}function X7(J,Q){let $=(V)=>{try{let q=J.querySelectorAll(V);if(!q.length)return null;let B=Q.index&&Q.index>0&&Q.index<q.length?Q.index:0;return q[B]??q[0]}catch{return null}};if(Q.id){let V=$(v7(Q.id,Q.artboardId));if(V)return V}if(Q.selector)return $(Q.selector);return null}function PJ(J,Q){let $=0,V=Math.min(J.length,Q.length);for(let q=1;q<=V;q++){if(J[J.length-q]!==Q[Q.length-q])break;$++}return $}function g7(J,Q){let $=Q.dom_path,V=(Q.tag||"").toLowerCase();if(!$||$.length===0||!V)return null;let q=J;if(Q.artboardId){let H=J.querySelector(`[data-dc-screen="${Q.artboardId}"]`);if(H)q=H}let B=(Q.classes||"").split(/\s+/).filter(Boolean),K=null,U=0;for(let H of Array.from(q.querySelectorAll("[data-cd-id]"))){if(H.tagName.toLowerCase()!==V)continue;let M=PJ(C7(H),$);if(M===0)continue;let j=Z7(H).split(/\s+/).filter(Boolean),z=B.filter((F)=>j.includes(F)).length,G=M*10+z;if(G>U)U=G,K=H}return K}var x7=["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"],MJ=/^(style|class|data-cd-id|data-dc-|data-dcid$)/;function jJ(J){if(!J||typeof window>"u"||!window.getComputedStyle)return{authored:{},computed:{},customStyles:{},attrs:{}};try{let Q=J.style,$=window.getComputedStyle(J),V={},q={},B=new Set(x7);for(let G of x7){let F=Q.getPropertyValue(G);if(F)V[G]=F.trim();let Y=$.getPropertyValue(G);if(Y)q[G]=Y.trim()}let K=/^(margin|padding|border)(-|$)/,U={};for(let G=0;G<Q.length;G++){let F=Q.item(G);if(!F||B.has(F)||K.test(F))continue;let Y=Q.getPropertyValue(F);if(Y)U[F]=Y.trim()}let H={};for(let G of Array.from(J.attributes)){if(MJ.test(G.name))continue;H[G.name]=G.value}let M=J.parentElement,j=M?window.getComputedStyle(M).display:"",z=M&&(j==="flex"||j==="inline-flex")?window.getComputedStyle(M).flexDirection:"";return{authored:V,computed:q,customStyles:U,attrs:H,parentDisplay:j,parentFlexDirection:z}}catch{return{authored:{},computed:{},customStyles:{},attrs:{}}}}function Y7(J,Q){let $=J.el,V=$&&$.getBoundingClientRect?$.getBoundingClientRect():null,q=J.cdId,B=q?v7(q,J.artboardId):J.artboardId?`[data-dc-screen="${J.artboardId}"]`:DJ($),K=q&&typeof document<"u"?S7(document,B,$):0;return{file:Q??z7(),id:q??void 0,selector:B,artboardId:J.artboardId,index:K,tag:$?.tagName.toLowerCase()??"",classes:Z7($),text:FJ($,240),dom_path:C7($),bounds:V?{x:Math.round(V.left),y:Math.round(V.top),w:Math.round(V.width),h:Math.round(V.height)}:null,worldW:$ instanceof HTMLElement?Math.round($.offsetWidth):void 0,worldH:$ instanceof HTMLElement?Math.round($.offsetHeight):void 0,html:$?($.outerHTML??"").slice(0,4000):"",...(()=>{if($?.tagName?.toLowerCase()!=="img")return{};let U=/assets\/[0-9a-f]{8}\.[a-z0-9]+/i,H=$.getAttribute?.("data-photo-asset");if(H&&U.test(H))return{photoKind:"artboard-img",photoAsset:H};let M=$.getAttribute?.("src")||"",j=U.exec(M);return j?{photoKind:"artboard-img",photoAsset:j[0]}:{}})(),...jJ($)}}import*as H7 from"lib0/decoding";import*as a from"lib0/encoding";import{createContext as NJ,useCallback as hQ,useContext as _J,useEffect as fQ,useMemo as pQ,useReducer as uQ,useRef as mQ,useState as dQ}from"react";import{Awareness as cQ,applyAwarenessUpdate as lQ,encodeAwarenessUpdate as rQ}from"y-protocols/awareness";import{readSyncMessage as oQ,writeSyncStep1 as aQ,writeUpdate as sQ}from"y-protocols/sync";import*as AJ from"yjs";import{jsx as eQ}from"react/jsx-runtime";var IJ=NJ(null);function h7(){return _J(IJ)}import{createContext as OJ,useCallback as l,useContext as D7,useEffect as TJ,useMemo as EJ,useRef as kJ,useState as wJ}from"react";import{jsx as F7,Fragment as xJ}from"react/jsx-runtime";var q7=OJ(null);function r(J){return J.id?`id:${J.id}`:`sel:${J.selector}`}function f7(J){let Q=[],$=new Set;for(let V of J){let q=r(V);if($.has(q))continue;$.add(q),Q.push(V)}return Q}var yJ=50;function bJ({children:J,postTarget:Q}){let[$,V]=wJ([]),q=kJ(null),B=l((G)=>{if(q.current)clearTimeout(q.current);q.current=setTimeout(()=>{q.current=null;let F=Q??(typeof window<"u"?window.parent:null);if(!F)return;let Y=G.length===0?null:G.length===1?G[0]??null:G;try{F.postMessage({dgn:"select-set",selection:Y},"*")}catch{}},yJ)},[Q]);TJ(()=>()=>{if(q.current)clearTimeout(q.current)},[]);let K=l((G)=>{let F=f7(Array.isArray(G)?G:[G]);V(F),B(F)},[B]),U=l((G)=>{let F=Array.isArray(G)?G:[G];V((Y)=>{let L=f7([...Y,...F]);return B(L),L})},[B]),H=l((G)=>{let F=r(G);V((Y)=>{let L=Y.filter((_)=>r(_)!==F);return B(L),L})},[B]),M=l((G)=>{let F=r(G);V((Y)=>{let L=Y.some((_)=>r(_)===F)?Y.filter((_)=>r(_)!==F):[...Y,G];return B(L),L})},[B]),j=l(()=>{V([]),B([])},[B]),z=EJ(()=>({selected:$,replace:K,add:U,remove:H,toggle:M,clear:j}),[$,K,U,H,M,j]);return F7(q7.Provider,{value:z,children:J})}function p7({children:J}){if(D7(q7))return F7(xJ,{children:J});return F7(bJ,{children:J})}function B7(){let J=D7(q7);if(!J)throw Error("useSelectionSet must be used inside <SelectionSetProvider>");return J}function u7(){return D7(q7)}import{jsx as O,jsxs as k}from"react/jsx-runtime";var CJ="/_client/comments-overlay.css";function vJ(){if(typeof document>"u")return;if(document.getElementById("cm-overlay-css"))return;let J=document.createElement("link");J.id="cm-overlay-css",J.rel="stylesheet",J.href=CJ,document.head.appendChild(J)}function SJ(){if(typeof window>"u")return null;try{let J=window.location.pathname;if(J==="/_canvas-shell.html"||J==="/_canvas-shell"){let Q=new URLSearchParams(window.location.search),$=Q.get("canvas")??"",V=(Q.get("designRel")??".design").replace(/^\/+|\/+$/g,"");return $?`${V}/${$}`:null}return decodeURIComponent(J).replace(/^\//,"")}catch{return null}}function RJ(J){if(!J.selector)return null;let Q=null;try{let $=document.querySelectorAll(J.selector),V=J.index&&J.index>0&&J.index<$.length?J.index:0;Q=$[V]??$[0]??null}catch{Q=null}if(Q&&J.tag&&Q.tagName.toLowerCase()!==J.tag.toLowerCase())Q=null;if(!Q&&J.dom_path?.length){let $=J.selector.match(/data-dc-screen="([^"]+)"/)?.[1];Q=g7(document,{artboardId:$,tag:J.tag,classes:J.classes,dom_path:J.dom_path})}return Q}function P7(J){let Q=RJ(J);if(!Q?.isConnected)return null;let $=Q.getBoundingClientRect();if($.width===0&&$.height===0)return null;return{x:$.left,y:$.top,w:$.width,h:$.height}}function c7(J,Q){let V=typeof window<"u"?window.innerWidth:J.x+Q.w,q=typeof window<"u"?window.innerHeight:J.y+Q.h,B=J.x;if(B+Q.w+8>V){let U=J.x-Q.w;B=U>=8?U:Math.max(8,V-Q.w-8)}let K=J.y;if(K+Q.h+8>q){let U=J.y-Q.h;K=U>=8?U:Math.max(8,q-Q.h-8)}return{x:B,y:K}}function l7(){vJ();let J=u7(),[Q,$]=m([]),[V,q]=m(null),[B,K]=m(null),U=s(()=>SJ(),[]);R(()=>{if(typeof document>"u")return;let W=document.getElementById("dgn-pin-layer");if(!W)return;let D=W.style.display;return W.style.display="none",()=>{W.style.display=D}},[]);let H=E((W)=>{if(!J)return;if(!W?.selector){J.clear();return}let D=W.selector.match(/data-cd-id="([^"]+)"/),N=D?D[1]:void 0,A,T;try{let P=document.querySelector(W.selector);if(P)A=P.tagName.toLowerCase(),T=(P.getAttribute("class")??"").split(/\s+/).filter((I)=>I&&!I.startsWith("dgn-")&&!I.startsWith("dc-cv-")).join(" ")}catch{}J.replace({file:U??void 0,id:N,selector:W.selector,tag:A,classes:T,bounds:W.bounds??void 0})},[J,U]),M=g(Q);M.current=Q;let j=h7();R(()=>{if(!j)return;let W=j.doc.getArray("comments"),D=()=>{$(W.toArray())};if(W.length>0)D();return W.observe(D),()=>{try{W.unobserve(D)}catch{}}},[j]),R(()=>{if(typeof window>"u")return;let W=(D)=>{let N=D.data;if(!N||typeof N!=="object"||!N.dgn)return;if(N.dgn==="comments-set"&&Array.isArray(N.comments))$(N.comments);else if(N.dgn==="comment-focus"){let A=typeof N.id==="string"?N.id:null;q(A);let T=A?M.current.find((P)=>P.id===A):void 0;H(T)}};return window.addEventListener("message",W),()=>window.removeEventListener("message",W)},[H]),R(()=>{if(typeof document>"u")return;let W=(D)=>{let N=D.detail;if(!N?.selection)return;K({selection:N.selection,clientX:typeof N.clientX==="number"?N.clientX:0,clientY:typeof N.clientY==="number"?N.clientY:0})};return document.addEventListener("cm:open-composer",W),()=>document.removeEventListener("cm:open-composer",W)},[]);let z=E(()=>{if(K(null),typeof window>"u")return;try{window.parent.postMessage({dgn:"force-clear"},"*")}catch{}},[]),G=E((W)=>{if(!B)return;let D=B.selection,N={file:D.file,selector:D.selector,index:D.index,dom_path:D.dom_path,tag:D.tag,classes:D.classes,bounds:D.bounds,html_excerpt:D.html,text:W};if(typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-submit",payload:N},"*")}catch{}z()},[B,z]);R(()=>{if(!U)return;let W=!1;return(async()=>{try{let D=await fetch(`/_comments?file=${encodeURIComponent(U)}`);if(!D.ok)return;let N=await D.json();if(W)return;if(Array.isArray(N.comments))$((A)=>A.length===0?N.comments??[]:A)}catch{}})(),()=>{W=!0}},[U]);let F=s(()=>{return Q.slice().sort((D,N)=>D.created.localeCompare(N.created)).filter((D)=>D.status!=="resolved")},[Q]),Y=s(()=>{let W=new Map;return Q.slice().sort((N,A)=>N.created.localeCompare(A.created)).forEach((N,A)=>{W.set(N.id,A+1)}),W},[Q]),L=E((W)=>{if(q(W),H(Q.find((D)=>D.id===W)),typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-click",id:W},"*")}catch{}},[Q,H]),_=E((W,D)=>{if(typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-patch",id:W,patch:D},"*")}catch{}},[]),Z=E((W)=>{if(typeof window>"u")return;try{window.parent.postMessage({dgn:"comment-delete",id:W},"*")}catch{}q((D)=>D===W?null:D)},[]),X=E(async(W,D)=>{if(typeof fetch>"u")return!1;try{let N=await fetch(`/_api/comments/${encodeURIComponent(W)}/reply`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({body:D})});if(!N.ok)return!1;let A=await N.json();return $((T)=>T.map((P)=>P.id===A.id?A:P)),!0}catch{return!1}},[]);return k("div",{className:"cm-layer","aria-hidden":!1,children:[F.map((W)=>{let D=Y.get(W.id)??0;return O(pJ,{comment:W,sequence:D,focused:V===W.id,onClick:L,onOrphaned:Z},W.id)}),B?O(uJ,{state:B,onSubmit:G,onCancel:z}):null,(()=>{if(!V)return null;let W=F.find((D)=>D.id===V);if(!W)return null;return O(mJ,{comment:W,sequence:Y.get(W.id)??0,onClose:()=>{q(null),J?.clear()},onPatch:(D)=>_(W.id,D),onDelete:()=>Z(W.id),onReply:(D)=>X(W.id,D)})})()]})}var L7=null;async function gJ(){if(!L7)L7=(async()=>{try{let J=await fetch("/_api/git-committers");if(!J.ok)return[];let Q=await J.json();return Array.isArray(Q.committers)?Q.committers:[]}catch{return[]}})();return L7}function m7(J){return(J.trim().split(/\s+/)[0]??"").replace(/[^\w.-]/g,"").toLowerCase()}function hJ(J,Q){if(Q<=0||Q>J.length)return null;let $=Q-1;while($>=0){let V=J[$]??"";if(V==="@"){let q=$>0?J[$-1]:"";if($===0||/\s/.test(q??"")){let B=J.slice($+1,Q);return{start:$,end:Q,query:B}}return null}if(!/[\w.-]/.test(V))return null;$-=1}return null}function r7({className:J,value:Q,onChange:$,onKeyDown:V,placeholder:q,rows:B,disabled:K,textareaRef:U,ariaLabel:H}){let M=g(null),j=E((P)=>{if(M.current=P,U)U.current=P},[U]),[z,G]=m([]),[F,Y]=m(null),[L,_]=m(0),Z=E(()=>{if(z.length>0)return;gJ().then((P)=>G(P))},[z.length]),X=s(()=>{if(!F)return[];let P=F.query.toLowerCase();return(!P?z:z.filter((w)=>w.name.toLowerCase().includes(P)||w.email.toLowerCase().includes(P))).slice(0,8)},[F,z]),W=E((P)=>{let I=P.selectionStart??P.value.length,w=hJ(P.value,I);Y(w),_(0)},[]),D=E((P)=>{$(P.target.value),W(P.target)},[$,W]),N=E((P)=>{if(!F)return;let I=M.current;if(!I)return;let w=`@${m7(P.name)}`,f=`${Q.slice(0,F.start)}${w} ${Q.slice(F.end)}`;$(f),Y(null);let x=F.start+w.length+1;requestAnimationFrame(()=>{I.focus(),I.setSelectionRange(x,x)})},[F,Q,$]),A=E((P)=>{if(F&&X.length>0){if(P.key==="ArrowDown"){P.preventDefault(),_((I)=>(I+1)%X.length);return}if(P.key==="ArrowUp"){P.preventDefault(),_((I)=>(I-1+X.length)%X.length);return}if(P.key==="Enter"||P.key==="Tab"){P.preventDefault();let I=X[L]??X[0];if(I)N(I);return}if(P.key==="Escape"){P.preventDefault(),Y(null);return}}V?.(P)},[F,X,L,N,V]),T=E((P)=>{W(P.currentTarget)},[W]);return k("div",{style:{position:"relative"},children:[O("textarea",{ref:j,className:J,value:Q,placeholder:q,rows:B,disabled:K,"aria-label":H,onChange:D,onKeyDown:A,onFocus:Z,onSelect:T,onClick:T}),F&&X.length>0?O("ul",{className:"cm-mention-popup",role:"listbox","aria-label":"Mention suggestions",style:{left:0,top:"100%"},children:X.map((P,I)=>{return k("li",{role:"option","aria-selected":I===L,className:"cm-mention-popup__item",onMouseEnter:()=>_(I),onMouseDown:(f)=>{f.preventDefault(),N(P)},children:[k("span",{className:"cm-mention-popup__name",children:["@",m7(P.name)]}),O("span",{className:"cm-mention-popup__email",children:P.email})]},`${P.name}-${P.email}`)})}):null]})}var fJ=3000;function pJ({comment:J,sequence:Q,focused:$,onClick:V,onOrphaned:q}){let B=g(null),K=g(null),U=g(null);R(()=>{let j=()=>{K.current=null;let z=B.current;if(!z)return;let G=P7(J);if(G)U.current=null;else{if(U.current==null)U.current=Date.now();else if(Date.now()-U.current>fJ)q(J.id);if(J.bounds)G={x:J.bounds.x,y:J.bounds.y,w:J.bounds.w,h:J.bounds.h}}if(!G){z.style.display="none",K.current=requestAnimationFrame(j);return}z.style.display="grid";let F=Math.round(G.x+G.w-12),Y=Math.round(G.y-12);z.style.left=`${F}px`,z.style.top=`${Y}px`,K.current=requestAnimationFrame(j)};return K.current=requestAnimationFrame(j),()=>{if(K.current!=null)cancelAnimationFrame(K.current)}},[J,q]);let H=J.author?.trim()||"unknown",M=`Comment ${Q} by ${H}`;return O("button",{ref:B,type:"button",className:"cm-pin","data-resolved":J.status==="resolved"?"true":"false","data-focused":$?"true":"false","data-comment-pin":J.id,"aria-label":M,"aria-expanded":$,title:J.text.slice(0,200),onClick:(j)=>{j.preventDefault(),j.stopPropagation(),V(J.id)},children:Q})}function uJ({state:J,onSubmit:Q,onCancel:$}){let[V,q]=m(""),B=g(null),K=g(null),U=g(null);R(()=>{let z=()=>{U.current=null;let G=K.current;if(!G)return;let F=cJ(J),Y=c7(F,{w:G.offsetWidth,h:G.offsetHeight});G.style.left=`${Math.round(Y.x)}px`,G.style.top=`${Math.round(Y.y)}px`,U.current=requestAnimationFrame(z)};return U.current=requestAnimationFrame(z),()=>{if(U.current!=null)cancelAnimationFrame(U.current)}},[J]),R(()=>{B.current?.focus()},[]);let H=E(()=>{let z=V.trim();if(!z)return;Q(z)},[V,Q]),M=E((z)=>{if(z.key==="Escape"){z.preventDefault(),$();return}if((z.metaKey||z.ctrlKey)&&z.key==="Enter")z.preventDefault(),H()},[$,H]),j=s(()=>{let z=J.selection.selector||"";if(!z)return J.selection.tag||"canvas";let G=z.match(/data-cd-id="([^"]+)"/);if(G)return`cd:${G[1]}`;return z.length>36?`${z.slice(0,33)}…`:z},[J.selection]);return k("div",{ref:K,className:"cm-composer",role:"dialog","aria-label":"New comment",onClick:(z)=>z.stopPropagation(),onPointerDown:(z)=>z.stopPropagation(),children:[k("div",{className:"cm-composer__head",children:[O("span",{children:"New comment"}),O("span",{className:"cm-composer__selector",children:j})]}),O(r7,{textareaRef:B,className:"cm-composer__textarea",value:V,placeholder:"Type a comment. ⌘↵ to save · Esc to cancel · @name to tag",onChange:q,onKeyDown:M,rows:3,ariaLabel:"Comment body"}),k("div",{className:"cm-composer__actions",children:[O("button",{type:"button",className:"cm-btn",onClick:$,children:"Cancel"}),O("button",{type:"button",className:"cm-btn cm-btn--primary",disabled:!V.trim(),onClick:H,children:"Save"})]})]})}function mJ({comment:J,sequence:Q,onClose:$,onPatch:V,onDelete:q,onReply:B}){let K=g(null),U=g(null),H=g(null),[M,j]=m(""),[z,G]=m(!1);R(()=>{let Z=()=>{H.current=null;let X=K.current;if(!X)return;let W=iJ(J),D=c7(W,{w:X.offsetWidth,h:X.offsetHeight});X.style.left=`${Math.round(D.x)}px`,X.style.top=`${Math.round(D.y)}px`,H.current=requestAnimationFrame(Z)};return H.current=requestAnimationFrame(Z),()=>{if(H.current!=null)cancelAnimationFrame(H.current)}},[J]),R(()=>{K.current?.focus();let Z=J.id;return()=>{document.querySelector(`[data-comment-pin="${Z}"]`)?.focus()}},[J.id]),R(()=>{if(typeof document>"u")return;let Z=(X)=>{if(X.key!=="Escape")return;let W=K.current;if(!W)return;if(W.contains(X.target)||document.activeElement===W)X.preventDefault(),$()};return document.addEventListener("keydown",Z),()=>document.removeEventListener("keydown",Z)},[$]);let F=E(async()=>{let Z=M.trim();if(!Z||z)return;G(!0);let X=await B(Z);if(G(!1),X)j(""),U.current?.focus()},[M,z,B]),Y=E((Z)=>{if((Z.metaKey||Z.ctrlKey)&&Z.key==="Enter")Z.preventDefault(),F()},[F]),L=`cm-thread-head-${J.id}`,_=dJ(J.selector,"");return k("div",{ref:K,className:"cm-thread",role:"dialog","aria-labelledby":L,tabIndex:-1,onClick:(Z)=>Z.stopPropagation(),onPointerDown:(Z)=>Z.stopPropagation(),children:[k("div",{className:"cm-thread__head",id:L,children:[k("div",{className:"cm-thread__head-row",children:[O("span",{className:"cm-thread__seq","aria-hidden":"true",children:Q}),O("span",{className:"cm-thread__author",children:J.author?.trim()||"unknown"}),O("span",{className:"cm-thread__time",children:i7(J.created)}),O("button",{type:"button",className:"cm-thread__close","aria-label":"Close thread",title:"Close · Esc",onClick:$,children:"×"})]}),_?O("code",{className:"cm-thread__selector",children:_}):null]}),O("div",{className:"cm-thread__body",children:d7(J.text)}),(J.thread??[]).map((Z)=>k("div",{className:"cm-thread__reply",children:[k("div",{className:"cm-thread__reply-head",children:[O("span",{className:"cm-thread__reply-author",children:Z.author?.trim()||"unknown"}),O("span",{className:"cm-thread__reply-time",children:i7(Z.created)})]}),O("div",{className:"cm-thread__reply-body",children:d7(Z.body)})]},Z.id)),k("div",{className:"cm-thread__reply-form",children:[O(r7,{textareaRef:U,className:"cm-thread__reply-textarea",value:M,placeholder:"Reply… ⌘↵ to send · @name to tag",onChange:j,onKeyDown:Y,rows:2,ariaLabel:"Reply",disabled:z}),O("div",{className:"cm-thread__reply-actions",children:O("button",{type:"button",className:"cm-btn cm-btn--primary",disabled:!M.trim()||z,onClick:()=>void F(),children:"Send"})})]}),k("div",{className:"cm-thread__actions",children:[J.status==="resolved"?O("button",{type:"button",className:"cm-btn",onClick:()=>V({status:"open"}),children:"↺ Reopen"}):O("button",{type:"button",className:"cm-btn cm-btn--primary",onClick:()=>{V({status:"resolved"}),$()},children:"✓ Resolve"}),O("button",{type:"button",className:"cm-btn cm-btn--danger",onClick:()=>{q(),$()},children:"Delete"})]})]})}function d7(J){if(!J)return null;let Q=/(@[\w][\w.-]*)/g;return J.split(Q).map((V,q)=>{let B=`${q}:${V}`;if(q%2===1)return O("strong",{"data-mention":"true",children:V},B);return O("span",{children:V},B)})}function i7(J){if(!J)return"";let Q=Date.parse(J);if(!Number.isFinite(Q))return"";let $=Math.round((Date.now()-Q)/1000);if($<60)return`${Math.max($,0)}s ago`;if($<3600)return`${Math.round($/60)}m ago`;if($<86400)return`${Math.round($/3600)}h ago`;return`${Math.round($/86400)}d ago`}function dJ(J,Q){if(!J)return Q;let $=J.match(/data-cd-id="([^"]+)"/);if($)return`cd:${$[1]}`;return J.length>36?`${J.slice(0,33)}…`:J}function iJ(J){let Q=J.selector?P7(J):null;if(Q)return{x:Q.x+Q.w-12,y:Q.y+16};if(J.bounds)return{x:J.bounds.x+J.bounds.w-12,y:J.bounds.y+16};return{x:16,y:16}}function cJ(J){if(J.clientX||J.clientY)return{x:J.clientX,y:J.clientY+8};if(J.selection.selector){let Q=P7(J.selection);if(Q)return{x:Q.x,y:Q.y+Q.h+8}}return{x:16,y:16}}import{useEffect as lJ}from"react";var rJ=new Set(["pen","highlighter","shape","rect","ellipse","arrow","sticky","text","section","eraser"]);function n7(J){return rJ.has(J)}var M7=(J)=>!!(J.metaKey||J.ctrlKey);function t(J){if(J.type==="keydown"){if(J.isEditable)return{kind:"no-op"};if(J.metaKey||J.ctrlKey||J.altKey){if(J.key==="Escape")return{kind:"escape"};let $=(J.key||"").toLowerCase();if(!J.altKey&&(J.metaKey||J.ctrlKey)){if($==="z"&&J.shiftKey)return{kind:"redo"};if($==="z")return{kind:"undo"};if($==="y"&&!J.shiftKey)return{kind:"redo"}}return{kind:"no-op"}}let Q=(J.key||"").toLowerCase();if(Q==="v")return{kind:"tool",tool:"move"};if(Q==="h")return{kind:"tool",tool:"hand"};if(Q==="c")return{kind:"tool",tool:"comment"};if(Q==="b")return{kind:"tool",tool:"pen"};if(Q==="i")return{kind:"tool",tool:"highlighter"};if(Q==="r"||Q==="o")return{kind:"tool",tool:"shape"};if(Q==="a")return{kind:"tool",tool:"arrow"};if(Q==="n")return{kind:"tool",tool:"sticky"};if(Q==="t")return{kind:"tool",tool:"text"};if(Q==="s"&&J.shiftKey)return{kind:"tool",tool:"section"};if(Q==="e")return{kind:"tool",tool:"eraser"};if(J.key==="Escape")return{kind:"escape"};return{kind:"no-op"}}if(J.type==="contextmenu")return{kind:"context-menu",clientX:J.clientX??0,clientY:J.clientY??0};if(J.type==="pointermove"){if(n7(J.activeTool))return{kind:"no-op"};if(J.activeTool==="hand")return{kind:"no-op"};if(J.activeTool==="comment")return{kind:"hover",deep:!0,clientX:J.clientX??0,clientY:J.clientY??0};if(!M7(J))return{kind:"no-op"};return{kind:"hover",deep:!0,clientX:J.clientX??0,clientY:J.clientY??0}}if(J.type==="pointerdown"){if(J.button===2)return{kind:"context-menu",clientX:J.clientX??0,clientY:J.clientY??0};if(J.button===1||J.spaceHeld)return{kind:"no-op"};if(J.button!==0)return{kind:"no-op"};if(n7(J.activeTool)&&!M7(J))return{kind:"no-op"};if(J.activeTool==="comment")return{kind:"drop-comment",clientX:J.clientX??0,clientY:J.clientY??0};if(J.activeTool==="hand")return{kind:"no-op"};if(!M7(J))return{kind:"no-op"};return{kind:"select",mode:!!J.shiftKey?"add":"replace",deep:!0,clientX:J.clientX??0,clientY:J.clientY??0}}return{kind:"no-op"}}function nJ(J){if(!J||!J.tagName)return!1;let Q=J,$=Q.tagName;if($==="INPUT"||$==="TEXTAREA"||$==="SELECT")return!0;if(Q.isContentEditable)return!0;let V=Q.getAttribute?.("contenteditable");if(V==="true"||V==="plaintext-only"||V==="")return!0;return!1}function e(J){if(!J||!J.closest)return!1;return!!J.closest(".cm-composer, .cm-thread, .cm-mention-popup, .cm-pin, [data-mediaref-player]")}function o7(J){let{hostRef:Q,getActiveTool:$,isSpaceHeld:V,callbacks:q,enabled:B=!0,claimableActions:K}=J;lJ(()=>{if(!B)return;let U=Q.current;if(!U)return;let H=(Z)=>K&&Z.kind!=="no-op"&&!K.has(Z.kind)?{kind:"no-op"}:Z,M=(Z)=>{switch(Z.kind){case"hover":q.onHover?.(Z);break;case"select":q.onSelect?.(Z);break;case"drop-comment":q.onDropComment?.(Z);break;case"context-menu":q.onContextMenu?.(Z);break;case"tool":q.onTool?.(Z);break;case"escape":q.onEscape?.();break;case"undo":q.onUndo?.();break;case"redo":q.onRedo?.();break;case"no-op":break}},j=(Z)=>{let X=H(t({type:"pointermove",button:Z.button,metaKey:Z.metaKey,ctrlKey:Z.ctrlKey,shiftKey:Z.shiftKey,altKey:Z.altKey,clientX:Z.clientX,clientY:Z.clientY,spaceHeld:V?.()??!1,activeTool:$()}));M(X)},z=(Z)=>{if(e(Z.target))return;let X=H(t({type:"pointerdown",button:Z.button,metaKey:Z.metaKey,ctrlKey:Z.ctrlKey,shiftKey:Z.shiftKey,altKey:Z.altKey,clientX:Z.clientX,clientY:Z.clientY,spaceHeld:V?.()??!1,activeTool:$()}));if(X.kind!=="no-op")Z.preventDefault(),Z.stopImmediatePropagation();M(X)},G=(Z)=>{if(e(Z.target))return;let X=H(t({type:"pointerdown",button:Z.button,metaKey:Z.metaKey,ctrlKey:Z.ctrlKey,shiftKey:Z.shiftKey,altKey:Z.altKey,clientX:Z.clientX,clientY:Z.clientY,spaceHeld:V?.()??!1,activeTool:$()}));if(X.kind!=="no-op"){if(Z.preventDefault(),Z.stopImmediatePropagation(),X.kind==="select")try{window.focus()}catch{}}},F=(Z)=>{if(e(Z.target))return;let X=$(),W=Z.metaKey||Z.ctrlKey,D=X==="comment"?"drop-comment":X==="move"&&W&&Z.button===0?"select":Z.button===2?"context-menu":null;if(D&&(!K||K.has(D)))Z.preventDefault(),Z.stopImmediatePropagation()},Y=(Z)=>{let X=H(t({type:"contextmenu",clientX:Z.clientX,clientY:Z.clientY,metaKey:Z.metaKey,ctrlKey:Z.ctrlKey,shiftKey:Z.shiftKey,altKey:Z.altKey,activeTool:$()}));if(X.kind==="no-op")return;Z.preventDefault(),Z.stopImmediatePropagation(),M(X)},L=(Z)=>{let X=H(t({type:"keydown",key:Z.key,metaKey:Z.metaKey,ctrlKey:Z.ctrlKey,shiftKey:Z.shiftKey,altKey:Z.altKey,isEditable:nJ(Z.target),activeTool:$()}));if(X.kind==="tool"||X.kind==="escape"||X.kind==="undo"||X.kind==="redo")Z.preventDefault();M(X)};U.addEventListener("pointermove",j,{passive:!0}),U.addEventListener("pointerdown",z,{capture:!0}),U.addEventListener("mousedown",G,{capture:!0}),U.addEventListener("click",F,{capture:!0}),U.addEventListener("contextmenu",Y,{capture:!0});let _=U.ownerDocument??document;return _.addEventListener("keydown",L,!0),()=>{U.removeEventListener("pointermove",j),U.removeEventListener("pointerdown",z,{capture:!0}),U.removeEventListener("mousedown",G,{capture:!0}),U.removeEventListener("click",F,{capture:!0}),U.removeEventListener("contextmenu",Y,{capture:!0}),_.removeEventListener("keydown",L,!0)}},[B,Q,$,V,q,K])}function j7(J,Q,$,V){let q=J.elementFromPoint(Q,$);if(!q)return null;if(q.closest?.(".dc-mm, .dc-zoom-tb, .dc-tool-palette, .dc-context-menu, .dc-cv-group-bbox"))return null;let B=q.closest?.("[data-dc-screen]")??null,K=B?.getAttribute("data-dc-screen")??null,U=q.closest?.(".dc-artboard-body")??null;if(!U){if(B&&K)return{el:B,cdId:null,artboardId:K};return null}if(q===U){if(B&&K)return{el:B,cdId:null,artboardId:K};return null}if(V.deep){let G=q.getAttribute?.("data-cd-id")??null;return{el:q,cdId:G,artboardId:K}}let H=q,M=null;while(H&&H!==U){if(H.hasAttribute?.("data-cd-id"))M=H;H=H.parentElement}let j=M??q,z=j.getAttribute?.("data-cd-id")??null;return{el:j,cdId:z,artboardId:K}}import{useCallback as UQ,useEffect as JJ,useRef as W7}from"react";var oJ=!1;function a7(){return oJ}import{createContext as ZQ,useCallback as I7,useContext as t7,useEffect as qQ,useMemo as BQ,useState as O7}from"react";function d(J,Q,$,V){return`url("data:image/svg+xml,${encodeURIComponent(J.trim())}") ${Q} ${$}, ${V}`}var _7="width='24' height='24' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'",A7="#1f1f1f",N7="stroke='#ffffff' stroke-linejoin='round' stroke-linecap='round'";function i(J,Q,$){let V=$?`<g transform='${$}'>`:"";return`<svg ${_7}>${V}<path fill='#ffffff' d='${J}'/><path fill='${A7}' d='${Q}'/>${$?"</g>":""}</svg>`}var s7="translate(0,32) scale(1,-1)",aJ=d(i("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"),sJ=d(i("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"),tJ=d(i("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"),eJ=d(i("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",s7),6,18,"crosshair"),JQ=d(i("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",s7),6,18,"crosshair"),J7=d(i("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"),QQ=d(i("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"),$Q=d(`<svg ${_7}><path d='M16 4V28M11 4H21M11 28H21' fill='none' ${N7} stroke-width='5'/><path d='M16 4V28M11 4H21M11 28H21' fill='none' stroke='${A7}' stroke-width='2.25' stroke-linecap='round'/></svg>`,12,12,"text"),VQ=d(`<svg ${_7}><path d='M6 5H21L26 10V27H6Z' fill='${A7}' ${N7} stroke-width='2.5'/><path d='M21 5V11H26' fill='none' ${N7} stroke-width='2.25'/></svg>`,5,5,"crosshair"),S=Object.freeze({move:aJ,hand:sJ,comment:tJ,pen:eJ,section:J7,highlighter:JQ,shape:J7,rect:J7,ellipse:J7,sticky:VQ,arrow:J7,text:$Q,eraser:QQ});import{jsx as T7,Fragment as KQ}from"react/jsx-runtime";var GQ=Object.freeze([{id:"move",label:"Move",shortcut:"V",cursor:S.move},{id:"hand",label:"Hand",shortcut:"H",cursor:S.hand},{id:"comment",label:"Comment",shortcut:"C",cursor:S.comment},{id:"pen",label:"Pen",shortcut:"B",cursor:S.pen},{id:"highlighter",label:"Highlighter",shortcut:"I",cursor:S.highlighter},{id:"shape",label:"Shape",shortcut:"R",cursor:S.shape},{id:"sticky",label:"Sticky",shortcut:"N",cursor:S.sticky},{id:"section",label:"Section",shortcut:"⇧S",cursor:S.shape},{id:"arrow",label:"Arrow",shortcut:"A",cursor:S.arrow},{id:"text",label:"Text",shortcut:"T",cursor:S.text},{id:"eraser",label:"Eraser",shortcut:"E",cursor:S.eraser}]),E7=ZQ(null);function WQ({children:J,tools:Q=GQ,initial:$="move"}){let[V,q]=O7($),[B,K]=O7(()=>({tool:null,locked:!1})),U=I7((F)=>{q(F),K((Y)=>Y.locked&&Y.tool===F?Y:{tool:null,locked:!1})},[]),H=I7((F)=>{K((Y)=>{if(Y.locked&&Y.tool===F)return{tool:null,locked:!1};return{tool:F,locked:!0}}),q(F)},[]),M=I7(()=>{K({tool:null,locked:!1})},[]),[j,z]=O7("rounded");qQ(()=>{if(typeof document>"u")return;let F=Q.find((_)=>_.id===V);if(!F)return;let Y=document.body.style.cursor;document.body.style.cursor=F.cursor;let L=document.getElementById("dc-tool-cursor");if(!L)L=document.createElement("style"),L.id="dc-tool-cursor",document.head.appendChild(L);if(L.textContent=`* { cursor: ${F.cursor} !important; }`,typeof window<"u"&&window.parent&&window.parent!==window)try{window.parent.postMessage({dgn:"tool-cursor",tool:V},"*")}catch{}return()=>{document.body.style.cursor=Y;let _=document.getElementById("dc-tool-cursor");if(_)_.textContent=""}},[V,Q]);let G=BQ(()=>({tool:V,setTool:U,tools:Q,sticky:B,toggleSticky:H,clearSticky:M,shapeKind:j,setShapeKind:z}),[V,U,Q,B,H,M,j]);return T7(E7.Provider,{value:G,children:J})}function e7({children:J}){if(t7(E7))return T7(KQ,{children:J});return T7(WQ,{children:J})}function G7(){let J=t7(E7);if(!J)throw Error("useToolMode must be used inside <ToolProvider>");return J}import{jsx as NQ}from"react/jsx-runtime";var zQ=`
|
|
2
2
|
.dc-el-resize-handle {
|
|
3
3
|
position: fixed;
|
|
4
4
|
width: 8px;
|
|
@@ -56,4 +56,4 @@ import{Component as _0,createElement as h,Fragment as A0,useCallback as k7,useEf
|
|
|
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 X0(){if(typeof document>"u")return;if(document.getElementById("dc-el-resize-css"))return;let Q=document.createElement("style");Q.id="dc-el-resize-css",Q.textContent=z0,document.head.appendChild(Q)}var Y0=["nw","n","ne","e","se","s","sw","w"];function H0(Q){return{movesLeft:Q==="nw"||Q==="w"||Q==="sw",movesRight:Q==="ne"||Q==="e"||Q==="se",movesTop:Q==="nw"||Q==="n"||Q==="ne",movesBottom:Q==="sw"||Q==="s"||Q==="se"}}var n=(Q)=>Math.round(Q*100)/100,K7=1;function F0(Q,$,J,V,q,B){let{movesLeft:K,movesRight:X,movesTop:F,movesBottom:j}=H0(Q),N=q.center,U=$.w,G=$.h;if(X)U=$.w+(N?2*J:J);else if(K)U=$.w-(N?2*J:J);if(j)G=$.h+(N?2*V:V);else if(F)G=$.h-(N?2*V:V);if(q.aspect&&$.w>0&&$.h>0){let Y=$.w/$.h;if((K||X)&&(F||j)){let _=Math.abs(U-$.w)/$.w,Z=Math.abs(G-$.h)/$.h;if(_>=Z)G=U/Y;else U=G*Y}else if(K||X)G=U/Y;else if(F||j)U=G*Y}if(U<K7)U=K7;if(G<K7)G=K7;let H={width:n(U),height:n(G)};if(N){if(B.canMoveLeft&&(K||X))H.left=n($.left+($.w-U)/2);if(B.canMoveTop&&(F||j))H.top=n($.top+($.h-G)/2)}else{if(B.canMoveLeft&&K)H.left=n($.left+$.w-U);if(B.canMoveTop&&F)H.top=n($.top+$.h-G)}return H}function $Q(Q){if(!Q||Q==="none")return 0;let $=/matrix\(([^)]+)\)/.exec(Q);if(!$)return 0;let J=$[1].split(",").map(Number),V=J[0]??1,q=J[1]??0;return Math.round(Math.atan2(q,V)*(180/Math.PI)*100)/100}function D0(Q){if(!Q||Q==="none")return 1;let $=/matrix\(([^)]+)\)/.exec(Q);if(!$)return 1;let J=$[1].split(",").map(Number),V=J[0]??1,q=J[1]??0,B=Math.hypot(V,q);return B>0?B:1}function JQ(Q,$,J){let V=J*Math.PI/180,q=Math.cos(V),B=Math.sin(V);return[Q*q-$*B,Q*B+$*q]}function VQ(Q,$,J,V){return Math.atan2(V-$,J-Q)}function L0(Q,$,J,V){let q=Q+(J-$)*(180/Math.PI);while(q>180)q-=360;while(q<=-180)q+=360;if(V)q=Math.round(q/15)*15;return Math.round(q*100)/100}function P0(Q,$){let J={width:`${$.width}px`,height:`${$.height}px`};if(typeof $.left==="number")J.left=`${$.left}px`;if(typeof $.top==="number")J.top=`${$.top}px`;try{window.parent.postMessage({dgn:"resize-request",id:Q.cdId,patch:J,before:Q.before,idIndex:Q.idIndex},"*")}catch{}}function j0(Q,$){if(!Q.artboardId)return;try{window.parent.postMessage({dgn:"resize-artboard-request",artboardId:Q.artboardId,width:$.width,height:$.height},"*")}catch{}}function M0(Q,$){try{window.parent.postMessage({dgn:"resize-request",id:Q.cdId,patch:{transform:$},before:Q.before,idIndex:Q.idIndex},"*")}catch{}}function ZQ(){X0();let{selected:Q}=B7(),{tool:$}=G7(),J=W7(null),V=W7(null),q=W7(null),B=W7(null),K=Q.length===1?Q[0]:null,X=K&&typeof K.id==="string"?K.id:null,F=K&&!X&&typeof K.artboardId==="string"?K.artboardId:null,j=$==="move"&&(!!X||!!F);QQ(()=>{let U=J.current;if(!U)return;let G=()=>{for(let Y of Array.from(U.children)){let L=Y;L.style.opacity="0",L.style.pointerEvents="none"}};if(!j||!K){G();return}let H=()=>{if(V.current=null,a7()){G(),V.current=requestAnimationFrame(H);return}let Y=X7(document,K);if(!Y){G(),V.current=requestAnimationFrame(H);return}let L=Y.getBoundingClientRect();if(L.width<=0&&L.height<=0){G(),V.current=requestAnimationFrame(H);return}let _=F?["e","s","se"]:Y0,Z=F?[]:["rot-nw","rot-ne","rot-sw","rot-se"],z=_.length+Z.length+1;while(U.children.length<z)U.appendChild(document.createElement("div"));while(U.children.length>z)U.lastChild&&U.removeChild(U.lastChild);let W=L.left+L.width/2,D=L.top+L.height/2,M=$Q(getComputedStyle(Y).transform),A=Y.closest(".dc-world"),T=A?D0(getComputedStyle(A).transform):1,P=Y.offsetWidth*T/2,I=Y.offsetHeight*T/2,w={nw:[-P,-I],n:[0,-I],ne:[P,-I],e:[P,0],se:[P,I],s:[0,I],sw:[-P,I],w:[-P,0],"rot-nw":[-P,-I],"rot-ne":[P,-I],"rot-sw":[-P,I],"rot-se":[P,I]},f=[...Z,..._];for(let C=0;C<f.length;C++){let v=f[C],b=U.children[C],[c,V7]=w[v]??[0,0],[KQ,UQ]=JQ(c,V7,M),zQ=W+KQ,XQ=D+UQ,U7=v.startsWith("rot-"),y7=v==="n"||v==="s",b7=v==="e"||v==="w",YQ=U7?10:y7?7:b7?3:4,HQ=U7?10:y7?3:b7?7:4;b.className="dc-el-resize-handle",b.dataset.corner=v,b.style.opacity="1",b.style.pointerEvents="auto",b.style.left=`${Math.round(zQ-YQ)}px`,b.style.top=`${Math.round(XQ-HQ)}px`,b.style.transform=U7?"":`rotate(${M}deg)`}let x=U.children[f.length],y=q.current;if(y&&y.el===Y&&!y.corner.startsWith("rot-")){let C=y.lastResult?.width??Y.offsetWidth,v=y.lastResult?.height??Y.offsetHeight,b=`${Math.round(C)} × ${Math.round(v)}`,c=y.lastResult?.left,V7=y.lastResult?.top;if(typeof c==="number"||typeof V7==="number")b+=` · ${Math.round(c??y.start.left)}, ${Math.round(V7??y.start.top)}`;x.className="dc-el-resize-readout",x.textContent=b,x.style.opacity="1",x.style.left=`${Math.round(W)}px`,x.style.top=`${Math.round(D+I)}px`}else x.style.opacity="0";V.current=requestAnimationFrame(H)};return V.current=requestAnimationFrame(H),()=>{if(V.current!=null)cancelAnimationFrame(V.current)}},[j,K,F]);let N=U0((U,G)=>{if(U.el.style.width=`${G.width}px`,U.el.style.height=`${G.height}px`,typeof G.left==="number")U.el.style.left=`${G.left}px`;if(typeof G.top==="number")U.el.style.top=`${G.top}px`;U.lastResult=G},[]);return QQ(()=>{let U=J.current;if(!U)return;let G=(Z,z)=>{let[W,D]=JQ(z.clientX-Z.startClientX,z.clientY-Z.startClientY,-Z.angle);return F0(Z.corner,Z.start,W/Z.elZoom,D/Z.elZoom,{aspect:!!z.shiftKey,center:!Z.artboardId&&!!z.altKey},Z.flags)},H=(Z)=>{let z=Z.target;if(!z?.classList.contains("dc-el-resize-handle"))return;let W=z.dataset.corner;if(!W||!K)return;let D=typeof K.id==="string"?K.id:null,M=!D&&typeof K.artboardId==="string"?K.artboardId:null;if(!D&&!M)return;let A=X7(document,K);if(!A)return;Z.preventDefault(),Z.stopPropagation();let T=A.getBoundingClientRect(),P=A.offsetWidth?T.width/A.offsetWidth:1,I=getComputedStyle(A),w=!M&&(I.position==="absolute"||I.position==="fixed"),f=M?Number.NaN:Number.parseFloat(A.style.left),x=M?Number.NaN:Number.parseFloat(A.style.top),y=M?0:$Q(I.transform),C=P>0?P:1,v=T.left+T.width/2,b=T.top+T.height/2,c={pointerId:Z.pointerId,corner:W,el:A,cdId:D??"",artboardId:M,idIndex:D?S7(document,D,A):0,startClientX:Z.clientX,startClientY:Z.clientY,elZoom:C,angle:y,cx:v,cy:b,rotStartPointer:VQ(v,b,Z.clientX,Z.clientY),start:{w:(y?A.offsetWidth:T.width/C)||T.width/C,h:(y?A.offsetHeight:T.height/C)||T.height/C,left:f,top:x},flags:{canMoveLeft:w&&Number.isFinite(f),canMoveTop:w&&Number.isFinite(x)},before:{width:A.style.width||null,height:A.style.height||null,left:A.style.left||null,top:A.style.top||null,transform:A.style.transform||null},lastResult:null,lastTransform:null};q.current=c;try{z.setPointerCapture(Z.pointerId)}catch{}},Y=(Z)=>{let z=q.current;if(!z||Z.pointerId!==z.pointerId)return;if(Z.preventDefault(),z.corner.startsWith("rot-")){let D=`rotate(${L0(z.angle,z.rotStartPointer,VQ(z.cx,z.cy,Z.clientX,Z.clientY),!!Z.shiftKey)}deg)`;z.el.style.transform=D,z.lastTransform=D;return}N(z,G(z,Z))},L=(Z)=>{let z=q.current;if(!z||Z.pointerId!==z.pointerId)return;if(q.current=null,z.corner.startsWith("rot-")){let M=z.lastTransform;if(!M||M===z.before.transform)return;B.current={el:z.el,before:z.before},M0(z,M);return}let W=z.lastResult??G(z,Z);if(!(`${W.width}px`!==z.before.width||`${W.height}px`!==z.before.height||typeof W.left==="number"&&`${W.left}px`!==z.before.left||typeof W.top==="number"&&`${W.top}px`!==z.before.top))return;if(B.current={el:z.el,before:z.before},z.artboardId)j0(z,W);else P0(z,W)},_=(Z)=>{let z=Z.data;if(z?.dgn!=="resize-failed"&&z?.dgn!=="resize-artboard-failed")return;if(Z.source!==window.parent)return;let W=B.current;if(!W)return;if(W.el.style.width=W.before.width??"",W.el.style.height=W.before.height??"",W.before.left!==null||W.el.style.left)W.el.style.left=W.before.left??"";if(W.before.top!==null||W.el.style.top)W.el.style.top=W.before.top??"";if(W.before.transform!==null||W.el.style.transform)W.el.style.transform=W.before.transform??"";B.current=null};return U.addEventListener("pointerdown",H),window.addEventListener("pointermove",Y),window.addEventListener("pointerup",L),window.addEventListener("pointercancel",L),window.addEventListener("message",_),()=>{U.removeEventListener("pointerdown",H),window.removeEventListener("pointermove",Y),window.removeEventListener("pointerup",L),window.removeEventListener("pointercancel",L),window.removeEventListener("message",_)}},[K,N]),N0("div",{ref:J,"aria-hidden":"true"})}import{jsx as o,jsxs as R0}from"react/jsx-runtime";var T0=new Set(["drop-comment","tool","escape","hover"]);function J7(){return typeof document<"u"&&!document.querySelector(".dc-canvas")}function w7(Q,$){if(typeof document>"u")return null;let J=document.elementFromPoint(Q,$);if(!J)return null;if(J.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 V=J.tagName;if(V==="HTML"||V==="BODY")return null;return J}function E0(Q,$){let J=w7(Q,$);if(!J)return null;return J.closest("[data-cd-id]")??J}function k0({children:Q,file:$}){let{tool:J,setTool:V}=G7(),q=B7(),B=u(null),[K,X]=$7(null),F=u(J);F.current=J;let j=I0(()=>()=>F.current,[]);p(()=>{if(J!=="comment")X(null)},[J]);let[N,U]=$7(null),[G,H]=$7(!1);return p(()=>{let Y=()=>H(J7());Y();let L=requestAnimationFrame(Y),_=setTimeout(Y,120);return()=>{cancelAnimationFrame(L),clearTimeout(_)}},[]),p(()=>{if(typeof document>"u")return;let Y=(L)=>{if(L.button!==0||!(L.metaKey||L.ctrlKey))return;if(!J7())return;if(e(L.target))return;let _=E0(L.clientX,L.clientY);if(!_)return;L.preventDefault(),L.stopImmediatePropagation();let Z=_.getAttribute("data-cd-id"),z=Y7({el:_,cdId:Z,artboardId:null});if(L.shiftKey)q.add(z);else q.replace(z);U(_)};return document.addEventListener("pointerdown",Y,!0),()=>document.removeEventListener("pointerdown",Y,!0)},[q]),p(()=>{if(q.selected.length===0)U(null)},[q.selected]),p(()=>{let Y=B.current;if(Y)Y.setAttribute("data-active-tool",J);if(typeof document<"u"&&document.body)document.body.setAttribute("data-active-tool",J);return()=>{Y?.removeAttribute("data-active-tool")}},[J]),p(()=>{if(typeof window>"u")return;let Y=(L)=>{let _=L.data;if(!_||typeof _!=="object"||_.dgn!=="tool-set")return;if(typeof _.tool==="string")V(_.tool)};return window.addEventListener("message",Y),()=>window.removeEventListener("message",Y)},[V]),o7({hostRef:B,getActiveTool:j,claimableActions:T0,callbacks:{onHover:({clientX:Y,clientY:L})=>{if(F.current!=="comment"||!J7()){X(null);return}let _=w7(Y,L);X((Z)=>Z===_?Z:_)},onTool:({tool:Y})=>V(Y),onEscape:()=>{if(F.current!=="move")V("move");if(X(null),q.clear(),typeof window<"u")try{window.parent.postMessage({dgn:"force-clear"},"*")}catch{}},onDropComment:({clientX:Y,clientY:L})=>b0(Y,L,q,$)}}),R0("div",{"data-mc-host":!0,ref:B,style:{display:"contents"},children:[Q,K?o(y0,{el:K}):null,N?o(w0,{el:N}):null,G?o(ZQ,{}):null,o(l7,{})]})}function w0({el:Q}){let $=u(null),J=u(Q);J.current=Q;let V=u(null);return p(()=>{let q=()=>{V.current=null;let B=$.current,K=J.current;if(B&&K?.isConnected){let X=K.getBoundingClientRect();if(X.width===0&&X.height===0)B.style.display="none";else B.style.display="block",B.style.left=`${Math.round(X.left)}px`,B.style.top=`${Math.round(X.top)}px`,B.style.width=`${Math.round(X.width)}px`,B.style.height=`${Math.round(X.height)}px`}else if(B)B.style.display="none";V.current=requestAnimationFrame(q)};return V.current=requestAnimationFrame(q),()=>{if(V.current!=null)cancelAnimationFrame(V.current)}},[]),o("div",{ref:$,"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 y0({el:Q}){let $=u(null),J=u(Q);J.current=Q;let V=u(null);return p(()=>{let q=()=>{V.current=null;let B=$.current,K=J.current;if(B&&K?.isConnected){let X=K.getBoundingClientRect();if(X.width===0&&X.height===0)B.style.display="none";else B.style.display="block",B.style.left=`${Math.round(X.left)}px`,B.style.top=`${Math.round(X.top)}px`,B.style.width=`${Math.round(X.width)}px`,B.style.height=`${Math.round(X.height)}px`}else if(B)B.style.display="none";V.current=requestAnimationFrame(q)};return V.current=requestAnimationFrame(q),()=>{if(V.current!=null)cancelAnimationFrame(V.current)}},[]),o("div",{ref:$,"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 b0(Q,$,J,V){if(typeof document>"u")return;let q=M7(document,Q,$,{deep:!0});if(!q)q=M7(document,Q,$,{deep:!1});if(!q&&!J7()&&typeof document.elementsFromPoint==="function"){let K=document.elementsFromPoint(Q,$);for(let X of K){let F=X.closest?.("[data-cd-id]");if(!F)continue;if(!F.closest(".dc-artboard-body"))continue;let j=F.closest("[data-dc-screen]");q={el:F,cdId:F.getAttribute("data-cd-id"),artboardId:j?.getAttribute("data-dc-screen")??null};break}}if(!q&&J7()){let K=w7(Q,$);if(K)q={el:K,cdId:K.getAttribute("data-cd-id"),artboardId:null}}if(!q){let K={file:V,id:void 0,selector:"",artboardId:null,tag:"",classes:"",text:"",dom_path:[],bounds:{x:Q-12,y:$-12,w:24,h:24},html:""};qQ(K,Q,$);return}let B=Y7(q,V);J.replace(B),qQ(B,Q,$)}function qQ(Q,$,J){if(typeof document<"u")try{document.dispatchEvent(new CustomEvent("cm:open-composer",{detail:{selection:Q,clientX:$,clientY:J}}))}catch{}if(typeof window<"u")try{window.parent.postMessage({dgn:"comment-compose",selection:Q},"*")}catch{}}function GQ(Q,$){return h(e7,null,h(p7,null,h(k0,{file:$},h(Q))))}function C3(Q,$){let J=O0($.rootEl);if(!$.commentsEnabled){J.render(h(Q));return}let V=$.file??z7();J.render(h(v0,{initialCanvas:Q,file:V}))}var BQ="__maudeCanvasRuntime";function x0({Canvas:Q,file:$,onOk:J}){return p(()=>{J()},[]),GQ(Q,$)}class WQ extends _0{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(){this.props.onError()}componentDidUpdate(Q){if(Q.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 C0({message:Q}){return h("div",{className:"dc-hmr-holding",role:"status","aria-live":"polite",title:Q?`Holding last working render — ${Q}`:"Holding last working render"},"⏸ build error — držím poslední funkční verzi")}function v0({initialCanvas:Q,file:$}){let[{canvas:J,attempt:V},q]=$7({canvas:Q,attempt:0}),[B,K]=$7({on:!1}),X=u(null),F=u(J);F.current=J,p(()=>{let G={remount:(H)=>q((Y)=>({canvas:H,attempt:Y.attempt+1})),setHolding:(H,Y)=>K(H?{on:!0,message:Y}:{on:!1})};return window[BQ]=G,()=>{window[BQ]=void 0}},[]);let j=k7(()=>{X.current=F.current,K((G)=>G.on?{on:!1}:G)},[]),N=k7(()=>{K({on:!0,message:"render error"})},[]),U=k7(()=>{let G=X.current;return G?GQ(G,$):null},[$]);return h(A0,null,h(WQ,{attempt:V,onError:N,fallback:U},h(x0,{key:V,Canvas:J,file:$,onOk:j})),B.on?h(C0,{message:B.message}):null)}export{E0 as pickSpecimenSelectEl,C3 as mountCanvas,J7 as isBareSpecimen,WQ as CanvasErrorBoundary};
|
|
59
|
+
`.trim();function XQ(){if(typeof document>"u")return;if(document.getElementById("dc-el-resize-css"))return;let J=document.createElement("style");J.id="dc-el-resize-css",J.textContent=zQ,document.head.appendChild(J)}var YQ=["nw","n","ne","e","se","s","sw","w"];function HQ(J){return{movesLeft:J==="nw"||J==="w"||J==="sw",movesRight:J==="ne"||J==="e"||J==="se",movesTop:J==="nw"||J==="n"||J==="ne",movesBottom:J==="sw"||J==="s"||J==="se"}}var n=(J)=>Math.round(J*100)/100,K7=1;function FQ(J,Q,$,V,q,B){let{movesLeft:K,movesRight:U,movesTop:H,movesBottom:M}=HQ(J),j=q.center,z=Q.w,G=Q.h;if(U)z=Q.w+(j?2*$:$);else if(K)z=Q.w-(j?2*$:$);if(M)G=Q.h+(j?2*V:V);else if(H)G=Q.h-(j?2*V:V);if(q.aspect&&Q.w>0&&Q.h>0){let Y=Q.w/Q.h;if((K||U)&&(H||M)){let _=Math.abs(z-Q.w)/Q.w,Z=Math.abs(G-Q.h)/Q.h;if(_>=Z)G=z/Y;else z=G*Y}else if(K||U)G=z/Y;else if(H||M)z=G*Y}if(z<K7)z=K7;if(G<K7)G=K7;let F={width:n(z),height:n(G)};if(j){if(B.canMoveLeft&&(K||U))F.left=n(Q.left+(Q.w-z)/2);if(B.canMoveTop&&(H||M))F.top=n(Q.top+(Q.h-G)/2)}else{if(B.canMoveLeft&&K)F.left=n(Q.left+Q.w-z);if(B.canMoveTop&&H)F.top=n(Q.top+Q.h-G)}return F}function QJ(J){if(!J||J==="none")return 0;let Q=/matrix\(([^)]+)\)/.exec(J);if(!Q)return 0;let $=Q[1].split(",").map(Number),V=$[0]??1,q=$[1]??0;return Math.round(Math.atan2(q,V)*(180/Math.PI)*100)/100}function DQ(J){if(!J||J==="none")return 1;let Q=/matrix\(([^)]+)\)/.exec(J);if(!Q)return 1;let $=Q[1].split(",").map(Number),V=$[0]??1,q=$[1]??0,B=Math.hypot(V,q);return B>0?B:1}function $J(J,Q,$){let V=$*Math.PI/180,q=Math.cos(V),B=Math.sin(V);return[J*q-Q*B,J*B+Q*q]}function VJ(J,Q,$,V){return Math.atan2(V-Q,$-J)}function LQ(J,Q,$,V){let q=J+($-Q)*(180/Math.PI);while(q>180)q-=360;while(q<=-180)q+=360;if(V)q=Math.round(q/15)*15;return Math.round(q*100)/100}function PQ(J,Q){let $={width:`${Q.width}px`,height:`${Q.height}px`};if(typeof Q.left==="number")$.left=`${Q.left}px`;if(typeof Q.top==="number")$.top=`${Q.top}px`;try{window.parent.postMessage({dgn:"resize-request",id:J.cdId,patch:$,before:J.before,idIndex:J.idIndex},"*")}catch{}}function MQ(J,Q){if(!J.artboardId)return;try{window.parent.postMessage({dgn:"resize-artboard-request",artboardId:J.artboardId,width:Q.width,height:Q.height},"*")}catch{}}function jQ(J,Q){try{window.parent.postMessage({dgn:"resize-request",id:J.cdId,patch:{transform:Q},before:J.before,idIndex:J.idIndex},"*")}catch{}}function ZJ(){XQ();let{selected:J}=B7(),{tool:Q}=G7(),$=W7(null),V=W7(null),q=W7(null),B=W7(null),K=J.length===1?J[0]:null,U=K&&typeof K.id==="string"?K.id:null,H=K&&!U&&typeof K.artboardId==="string"?K.artboardId:null,M=Q==="move"&&(!!U||!!H);JJ(()=>{let z=$.current;if(!z)return;let G=()=>{for(let Y of Array.from(z.children)){let L=Y;L.style.opacity="0",L.style.pointerEvents="none"}};if(!M||!K){G();return}let F=()=>{if(V.current=null,a7()){G(),V.current=requestAnimationFrame(F);return}let Y=X7(document,K);if(!Y){G(),V.current=requestAnimationFrame(F);return}let L=Y.getBoundingClientRect();if(L.width<=0&&L.height<=0){G(),V.current=requestAnimationFrame(F);return}let _=H?["e","s","se"]:YQ,Z=H?[]:["rot-nw","rot-ne","rot-sw","rot-se"],X=_.length+Z.length+1;while(z.children.length<X)z.appendChild(document.createElement("div"));while(z.children.length>X)z.lastChild&&z.removeChild(z.lastChild);let W=L.left+L.width/2,D=L.top+L.height/2,N=QJ(getComputedStyle(Y).transform),A=Y.closest(".dc-world"),T=A?DQ(getComputedStyle(A).transform):1,P=Y.offsetWidth*T/2,I=Y.offsetHeight*T/2,w={nw:[-P,-I],n:[0,-I],ne:[P,-I],e:[P,0],se:[P,I],s:[0,I],sw:[-P,I],w:[-P,0],"rot-nw":[-P,-I],"rot-ne":[P,-I],"rot-sw":[-P,I],"rot-se":[P,I]},f=[...Z,..._];for(let C=0;C<f.length;C++){let v=f[C],b=z.children[C],[c,V7]=w[v]??[0,0],[KJ,UJ]=$J(c,V7,N),zJ=W+KJ,XJ=D+UJ,U7=v.startsWith("rot-"),y7=v==="n"||v==="s",b7=v==="e"||v==="w",YJ=U7?10:y7?7:b7?3:4,HJ=U7?10:y7?3:b7?7:4;b.className="dc-el-resize-handle",b.dataset.corner=v,b.style.opacity="1",b.style.pointerEvents="auto",b.style.left=`${Math.round(zJ-YJ)}px`,b.style.top=`${Math.round(XJ-HJ)}px`,b.style.transform=U7?"":`rotate(${N}deg)`}let x=z.children[f.length],y=q.current;if(y&&y.el===Y&&!y.corner.startsWith("rot-")){let C=y.lastResult?.width??Y.offsetWidth,v=y.lastResult?.height??Y.offsetHeight,b=`${Math.round(C)} × ${Math.round(v)}`,c=y.lastResult?.left,V7=y.lastResult?.top;if(typeof c==="number"||typeof V7==="number")b+=` · ${Math.round(c??y.start.left)}, ${Math.round(V7??y.start.top)}`;x.className="dc-el-resize-readout",x.textContent=b,x.style.opacity="1",x.style.left=`${Math.round(W)}px`,x.style.top=`${Math.round(D+I)}px`}else x.style.opacity="0";V.current=requestAnimationFrame(F)};return V.current=requestAnimationFrame(F),()=>{if(V.current!=null)cancelAnimationFrame(V.current)}},[M,K,H]);let j=UQ((z,G)=>{if(z.el.style.width=`${G.width}px`,z.el.style.height=`${G.height}px`,typeof G.left==="number")z.el.style.left=`${G.left}px`;if(typeof G.top==="number")z.el.style.top=`${G.top}px`;z.lastResult=G},[]);return JJ(()=>{let z=$.current;if(!z)return;let G=(Z,X)=>{let[W,D]=$J(X.clientX-Z.startClientX,X.clientY-Z.startClientY,-Z.angle);return FQ(Z.corner,Z.start,W/Z.elZoom,D/Z.elZoom,{aspect:!!X.shiftKey,center:!Z.artboardId&&!!X.altKey},Z.flags)},F=(Z)=>{let X=Z.target;if(!X?.classList.contains("dc-el-resize-handle"))return;let W=X.dataset.corner;if(!W||!K)return;let D=typeof K.id==="string"?K.id:null,N=!D&&typeof K.artboardId==="string"?K.artboardId:null;if(!D&&!N)return;let A=X7(document,K);if(!A)return;Z.preventDefault(),Z.stopPropagation();let T=A.getBoundingClientRect(),P=A.offsetWidth?T.width/A.offsetWidth:1,I=getComputedStyle(A),w=!N&&(I.position==="absolute"||I.position==="fixed"),f=N?Number.NaN:Number.parseFloat(A.style.left),x=N?Number.NaN:Number.parseFloat(A.style.top),y=N?0:QJ(I.transform),C=P>0?P:1,v=T.left+T.width/2,b=T.top+T.height/2,c={pointerId:Z.pointerId,corner:W,el:A,cdId:D??"",artboardId:N,idIndex:D?R7(document,D,A):0,startClientX:Z.clientX,startClientY:Z.clientY,elZoom:C,angle:y,cx:v,cy:b,rotStartPointer:VJ(v,b,Z.clientX,Z.clientY),start:{w:(y?A.offsetWidth:T.width/C)||T.width/C,h:(y?A.offsetHeight:T.height/C)||T.height/C,left:f,top:x},flags:{canMoveLeft:w&&Number.isFinite(f),canMoveTop:w&&Number.isFinite(x)},before:{width:A.style.width||null,height:A.style.height||null,left:A.style.left||null,top:A.style.top||null,transform:A.style.transform||null},lastResult:null,lastTransform:null};q.current=c;try{X.setPointerCapture(Z.pointerId)}catch{}},Y=(Z)=>{let X=q.current;if(!X||Z.pointerId!==X.pointerId)return;if(Z.preventDefault(),X.corner.startsWith("rot-")){let D=`rotate(${LQ(X.angle,X.rotStartPointer,VJ(X.cx,X.cy,Z.clientX,Z.clientY),!!Z.shiftKey)}deg)`;X.el.style.transform=D,X.lastTransform=D;return}j(X,G(X,Z))},L=(Z)=>{let X=q.current;if(!X||Z.pointerId!==X.pointerId)return;if(q.current=null,X.corner.startsWith("rot-")){let N=X.lastTransform;if(!N||N===X.before.transform)return;B.current={el:X.el,before:X.before},jQ(X,N);return}let W=X.lastResult??G(X,Z);if(!(`${W.width}px`!==X.before.width||`${W.height}px`!==X.before.height||typeof W.left==="number"&&`${W.left}px`!==X.before.left||typeof W.top==="number"&&`${W.top}px`!==X.before.top))return;if(B.current={el:X.el,before:X.before},X.artboardId)MQ(X,W);else PQ(X,W)},_=(Z)=>{let X=Z.data;if(X?.dgn!=="resize-failed"&&X?.dgn!=="resize-artboard-failed")return;if(Z.source!==window.parent)return;let W=B.current;if(!W)return;if(W.el.style.width=W.before.width??"",W.el.style.height=W.before.height??"",W.before.left!==null||W.el.style.left)W.el.style.left=W.before.left??"";if(W.before.top!==null||W.el.style.top)W.el.style.top=W.before.top??"";if(W.before.transform!==null||W.el.style.transform)W.el.style.transform=W.before.transform??"";B.current=null};return z.addEventListener("pointerdown",F),window.addEventListener("pointermove",Y),window.addEventListener("pointerup",L),window.addEventListener("pointercancel",L),window.addEventListener("message",_),()=>{z.removeEventListener("pointerdown",F),window.removeEventListener("pointermove",Y),window.removeEventListener("pointerup",L),window.removeEventListener("pointercancel",L),window.removeEventListener("message",_)}},[K,j]),NQ("div",{ref:$,"aria-hidden":"true"})}import{jsx as o,jsxs as SQ}from"react/jsx-runtime";var TQ=new Set(["drop-comment","tool","escape","hover"]);function $7(){return typeof document<"u"&&!document.querySelector(".dc-canvas")}function w7(J,Q){if(typeof document>"u")return null;let $=document.elementFromPoint(J,Q);if(!$)return null;if($.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 V=$.tagName;if(V==="HTML"||V==="BODY")return null;return $}function EQ(J,Q){let $=w7(J,Q);if(!$)return null;return $.closest("[data-cd-id]")??$}function kQ({children:J,file:Q}){let{tool:$,setTool:V}=G7(),q=B7(),B=u(null),[K,U]=Q7(null),H=u($);H.current=$;let M=IQ(()=>()=>H.current,[]);p(()=>{if($!=="comment")U(null)},[$]);let[j,z]=Q7(null),[G,F]=Q7(!1);return p(()=>{let Y=()=>F($7());Y();let L=requestAnimationFrame(Y),_=setTimeout(Y,120);return()=>{cancelAnimationFrame(L),clearTimeout(_)}},[]),p(()=>{if(typeof document>"u")return;let Y=(L)=>{if(L.button!==0||!(L.metaKey||L.ctrlKey))return;if(!$7())return;if(e(L.target))return;let _=EQ(L.clientX,L.clientY);if(!_)return;L.preventDefault(),L.stopImmediatePropagation();let Z=_.getAttribute("data-cd-id"),X=Y7({el:_,cdId:Z,artboardId:null});if(L.shiftKey)q.add(X);else q.replace(X);z(_)};return document.addEventListener("pointerdown",Y,!0),()=>document.removeEventListener("pointerdown",Y,!0)},[q]),p(()=>{if(q.selected.length===0)z(null)},[q.selected]),p(()=>{let Y=B.current;if(Y)Y.setAttribute("data-active-tool",$);if(typeof document<"u"&&document.body)document.body.setAttribute("data-active-tool",$);return()=>{Y?.removeAttribute("data-active-tool")}},[$]),p(()=>{if(typeof window>"u")return;let Y=(L)=>{let _=L.data;if(!_||typeof _!=="object"||_.dgn!=="tool-set")return;if(typeof _.tool==="string")V(_.tool)};return window.addEventListener("message",Y),()=>window.removeEventListener("message",Y)},[V]),o7({hostRef:B,getActiveTool:M,claimableActions:TQ,callbacks:{onHover:({clientX:Y,clientY:L})=>{if(H.current!=="comment"||!$7()){U(null);return}let _=w7(Y,L);U((Z)=>Z===_?Z:_)},onTool:({tool:Y})=>V(Y),onEscape:()=>{if(H.current!=="move")V("move");if(U(null),q.clear(),typeof window<"u")try{window.parent.postMessage({dgn:"force-clear"},"*")}catch{}},onDropComment:({clientX:Y,clientY:L})=>bQ(Y,L,q,Q)}}),SQ("div",{"data-mc-host":!0,ref:B,style:{display:"contents"},children:[J,K?o(yQ,{el:K}):null,j?o(wQ,{el:j}):null,G?o(ZJ,{}):null,o(l7,{})]})}function wQ({el:J}){let Q=u(null),$=u(J);$.current=J;let V=u(null);return p(()=>{let q=()=>{V.current=null;let B=Q.current,K=$.current;if(B&&K?.isConnected){let U=K.getBoundingClientRect();if(U.width===0&&U.height===0)B.style.display="none";else B.style.display="block",B.style.left=`${Math.round(U.left)}px`,B.style.top=`${Math.round(U.top)}px`,B.style.width=`${Math.round(U.width)}px`,B.style.height=`${Math.round(U.height)}px`}else if(B)B.style.display="none";V.current=requestAnimationFrame(q)};return V.current=requestAnimationFrame(q),()=>{if(V.current!=null)cancelAnimationFrame(V.current)}},[]),o("div",{ref:Q,"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 yQ({el:J}){let Q=u(null),$=u(J);$.current=J;let V=u(null);return p(()=>{let q=()=>{V.current=null;let B=Q.current,K=$.current;if(B&&K?.isConnected){let U=K.getBoundingClientRect();if(U.width===0&&U.height===0)B.style.display="none";else B.style.display="block",B.style.left=`${Math.round(U.left)}px`,B.style.top=`${Math.round(U.top)}px`,B.style.width=`${Math.round(U.width)}px`,B.style.height=`${Math.round(U.height)}px`}else if(B)B.style.display="none";V.current=requestAnimationFrame(q)};return V.current=requestAnimationFrame(q),()=>{if(V.current!=null)cancelAnimationFrame(V.current)}},[]),o("div",{ref:Q,"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 bQ(J,Q,$,V){if(typeof document>"u")return;let q=j7(document,J,Q,{deep:!0});if(!q)q=j7(document,J,Q,{deep:!1});if(!q&&!$7()&&typeof document.elementsFromPoint==="function"){let K=document.elementsFromPoint(J,Q);for(let U of K){let H=U.closest?.("[data-cd-id]");if(!H)continue;if(!H.closest(".dc-artboard-body"))continue;let M=H.closest("[data-dc-screen]");q={el:H,cdId:H.getAttribute("data-cd-id"),artboardId:M?.getAttribute("data-dc-screen")??null};break}}if(!q&&$7()){let K=w7(J,Q);if(K)q={el:K,cdId:K.getAttribute("data-cd-id"),artboardId:null}}if(!q){let K={file:V,id:void 0,selector:"",artboardId:null,tag:"",classes:"",text:"",dom_path:[],bounds:{x:J-12,y:Q-12,w:24,h:24},html:""};qJ(K,J,Q);return}let B=Y7(q,V);$.replace(B),qJ(B,J,Q)}function qJ(J,Q,$){if(typeof document<"u")try{document.dispatchEvent(new CustomEvent("cm:open-composer",{detail:{selection:J,clientX:Q,clientY:$}}))}catch{}if(typeof window<"u")try{window.parent.postMessage({dgn:"comment-compose",selection:J},"*")}catch{}}function GJ(J,Q){return h(e7,null,h(p7,null,h(kQ,{file:Q},h(J))))}function C0(J,Q){let $=OQ(Q.rootEl);if(!Q.commentsEnabled){$.render(h(J));return}let V=Q.file??z7();$.render(h(vQ,{initialCanvas:J,file:V}))}var BJ="__maudeCanvasRuntime";function xQ({Canvas:J,file:Q,onOk:$}){return p(()=>{$()},[]),GJ(J,Q)}class WJ extends _Q{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(){this.props.onError()}componentDidUpdate(J){if(J.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 CQ({message:J}){return h("div",{className:"dc-hmr-holding",role:"status","aria-live":"polite",title:J?`Holding last working render — ${J}`:"Holding last working render"},"⏸ build error — držím poslední funkční verzi")}function vQ({initialCanvas:J,file:Q}){let[{canvas:$,attempt:V},q]=Q7({canvas:J,attempt:0}),[B,K]=Q7({on:!1}),U=u(null),H=u($);H.current=$,p(()=>{let G={remount:(F)=>q((Y)=>({canvas:F,attempt:Y.attempt+1})),setHolding:(F,Y)=>K(F?{on:!0,message:Y}:{on:!1})};return window[BJ]=G,()=>{window[BJ]=void 0}},[]);let M=k7(()=>{U.current=H.current,K((G)=>G.on?{on:!1}:G)},[]),j=k7(()=>{K({on:!0,message:"render error"})},[]),z=k7(()=>{let G=U.current;return G?GJ(G,Q):null},[Q]);return h(AQ,null,h(WJ,{attempt:V,onError:j,fallback:z},h(xQ,{key:V,Canvas:$,file:Q,onOk:M})),B.on?h(CQ,{message:B.message}):null)}export{EQ as pickSpecimenSelectEl,C0 as mountCanvas,$7 as isBareSpecimen,WJ as CanvasErrorBoundary};
|