@popmelt.com/core 0.30.0 → 0.31.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/README.md +37 -31
- package/claude-plugin/.claude-plugin/plugin.json +1 -1
- package/codex-plugin/.codex-plugin/plugin.json +1 -1
- package/dist/ParticipantRuntime-PPIOE3NJ.mjs +139 -0
- package/dist/{PopmeltTasteConnectedPane-L5ULGACH.mjs → PopmeltTasteConnectedPane-4WRVLYUV.mjs} +1 -1
- package/dist/{ThreadErrorCard-Q5GQ4EIF.mjs → ThreadErrorCard-5ADUBZKJ.mjs} +1 -1
- package/dist/adapter-react-three-fiber.d.mts +1 -1
- package/dist/bridge-entry.mjs +1 -1
- package/dist/browser-runtime-OZCPXHEN.mjs +2 -0
- package/dist/browser.d.mts +4 -4
- package/dist/browser.mjs +1 -1
- package/dist/{chunk-OFHBVUTT.mjs → chunk-4AEU4OCH.mjs} +2 -2
- package/dist/chunk-4LHTPRFY.mjs +2 -0
- package/dist/chunk-4V7SK3M6.mjs +0 -0
- package/dist/{chunk-O6HC437G.mjs → chunk-A7DRONSB.mjs} +2 -2
- package/dist/{chunk-MZNY6VXR.mjs → chunk-D32YV5O6.mjs} +1 -1
- package/dist/{chunk-YYWUENSJ.mjs → chunk-DPU2WFIZ.mjs} +1 -1
- package/dist/{chunk-N4F7DGFN.mjs → chunk-F3S6L45N.mjs} +1 -1
- package/dist/{chunk-4BEN6VQ7.mjs → chunk-G25T4PMF.mjs} +1 -1
- package/dist/chunk-J4WDYITA.mjs +2 -0
- package/dist/{chunk-HTHUSDZT.mjs → chunk-NE263MLG.mjs} +1 -1
- package/dist/chunk-PBQCGGJL.mjs +342 -0
- package/dist/chunk-RXRZTZPN.mjs +3 -0
- package/dist/chunk-UU5ISCUC.mjs +62 -0
- package/dist/{chunk-2BVRVVHJ.mjs → chunk-YM6BOUNF.mjs} +21 -21
- package/dist/cli.mjs +2 -2
- package/dist/codex-note-context-MKZ7WCS7.mjs +2 -0
- package/dist/{codex-project-P3J62GZR.mjs → codex-project-3OAJJ7ZI.mjs} +1 -1
- package/dist/codex-session-registry-25DAA2KO.mjs +0 -0
- package/dist/focus-inspection-GJKMI6OE.mjs +2 -0
- package/dist/index.d.mts +6 -5
- package/dist/index.mjs +1 -1
- package/dist/media.d.mts +3 -3
- package/dist/{participantBootstrap-QZ3wuqi1.d.mts → participantBootstrap-B0lvfCwM.d.mts} +2 -2
- package/dist/peer-client-WF35M2Y4.mjs +2 -0
- package/dist/plugin-astro.mjs +1 -1
- package/dist/plugin-nuxt.mjs +1 -1
- package/dist/plugin-vite.mjs +1 -1
- package/dist/server.mjs +1 -1
- package/dist/{subjects-CG6UyWFr.d.mts → subjects-EWAR5-0S.d.mts} +16 -1
- package/dist/{video-adapter-DrTI5cRl.d.mts → video-adapter-BUMpNTCP.d.mts} +1 -1
- package/dist/workspace-snapshot-LKQWBDNS.mjs +2 -0
- package/package.json +32 -22
- package/dist/ParticipantRuntime-AKVKVNO2.mjs +0 -139
- package/dist/browser-runtime-PPQ2GUER.mjs +0 -2
- package/dist/chunk-3LBOX7HQ.mjs +0 -3
- package/dist/chunk-AR4MHLWP.mjs +0 -342
- package/dist/chunk-ENGMQINZ.mjs +0 -62
- package/dist/codex-note-context-ZLQU57WU.mjs +0 -2
- package/dist/focus-inspection-2FPCQIN2.mjs +0 -2
- package/dist/peer-client-DGX6OHMK.mjs +0 -2
- package/dist/workspace-snapshot-EJQHHDQ4.mjs +0 -2
- /package/dist/{chunk-ZQTLCQPC.mjs → chunk-MINAH2EM.mjs} +0 -0
- /package/dist/{chunk-2RRYBN2J.mjs → chunk-V44RIEET.mjs} +0 -0
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{f as N}from"./chunk-J4WDYITA.mjs";import{l as W,d as z}from"./chunk-HGW2U6PD.mjs";import{destroyContext as F,domToCanvas as J,createContext as X}from"modern-screenshot";function A(t,e,n){if(t===null||typeof t=="string"||typeof t=="boolean")return;if(typeof t=="number"){if(!Number.isFinite(t))throw new TypeError(`Comment metadata at ${e} must be finite.`);return}if(typeof t!="object")throw new TypeError(`Comment metadata at ${e} must be JSON-serializable.`);if(n.has(t))throw new TypeError(`Comment metadata at ${e} contains a cycle.`);let r=Object.getPrototypeOf(t);if(!Array.isArray(t)&&r!==Object.prototype&&r!==null)throw new TypeError(`Comment metadata at ${e} must use plain objects and arrays.`);if(n.add(t),Array.isArray(t))t.forEach((i,o)=>A(i,`${e}[${o}]`,n));else for(let[i,o]of Object.entries(t))A(o,`${e}.${i}`,n);n.delete(t)}function q(t){if(t===void 0)return;if(t===null||Array.isArray(t)||typeof t!="object")throw new TypeError("Comment metadata must be a JSON object.");A(t,"meta",new Set);let e=JSON.stringify(t);if(new TextEncoder().encode(e).byteLength>65536)throw new RangeError("Comment metadata exceeds the 65536 byte limit.");return JSON.parse(e)}var S="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",G=1500,Q=5e3,K=24e6,V=16e3,Z=4,_=["position","inset","top","right","bottom","left","z-index","display","visibility","opacity","overflow","overflow-x","overflow-y","box-sizing","box-decoration-break","float","clear","width","min-width","max-width","height","min-height","max-height","margin","margin-top","margin-right","margin-bottom","margin-left","padding","padding-top","padding-right","padding-bottom","padding-left","border","border-width","border-style","border-color","border-top","border-right","border-bottom","border-left","border-radius","outline","outline-offset","box-shadow","background","background-color","background-image","background-size","background-position","background-repeat","background-clip","background-origin","color","font","font-family","font-size","font-style","font-weight","font-stretch","font-variant","line-height","letter-spacing","text-align","text-decoration","text-indent","text-overflow","text-shadow","text-transform","white-space","word-break","overflow-wrap","vertical-align","direction","writing-mode","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","align-content","align-items","align-self","justify-content","justify-items","justify-self","gap","row-gap","column-gap","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-row","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","order","columns","column-count","column-fill","column-rule","column-span","column-width","list-style","list-style-image","list-style-position","list-style-type","object-fit","object-position","aspect-ratio","transform","transform-box","transform-origin","transform-style","perspective","perspective-origin","backface-visibility","clip","clip-path","filter","backdrop-filter","mix-blend-mode","isolation","mask","mask-image","mask-position","mask-repeat","mask-size","content","quotes","counter-increment","counter-reset","appearance","accent-color","caret-color","cursor","pointer-events","fill","fill-opacity","fill-rule","stroke","stroke-width","stroke-opacity"];async function tt(t,e){try{let n=await t();if(n)return n}catch{}return e()}var C=new Map,$=new WeakMap,et=1;function p(){return typeof performance<"u"?performance.now():Date.now()}function R(t){if(t?.debug!==void 0)return t.debug;if(typeof window>"u")return!1;try{return window.localStorage.getItem("popmelt:screenshot-debug")==="true"}catch{return!1}}function nt(t){let e=0,n=0;for(let r of t.querySelectorAll("img[src]"))P(r.currentSrc||r.src)&&(e++,(!r.complete||r.naturalWidth===0)&&n++);return{remoteImages:e,unresolvedRemoteImages:n}}function ot(t){return new Promise((e,n)=>{let r=new FileReader;r.onload=()=>e(String(r.result)),r.onerror=()=>n(r.error??new Error("Asset could not be read")),r.readAsDataURL(t)})}function rt(t,e){let n=null;return async r=>{if(!P(r))return!1;n??(n=Date.now()+t);let i=n-Date.now();if(i<=0)return e(),S;let o=new AbortController,a=setTimeout(()=>o.abort(),i);try{let s=await fetch(r,{cache:"force-cache",mode:"cors",signal:o.signal});if(!s.ok)throw new Error(`Asset returned ${s.status}`);return await ot(await s.blob())}catch{return e(),S}finally{clearTimeout(a)}}}function at(t,e,n){let r=$.get(t);r||(r=et++,$.set(t,r));let i=e.filter(o=>(o.status??"pending")==="pending").map(o=>{let a=o.points[0],s=o.points[o.points.length-1];return`${o.id}:${o.points.length}:${a?.x??""}:${a?.y??""}:${s?.x??""}:${s?.y??""}`}).join("|");return[r,window.location.href,window.innerWidth,window.innerHeight,n?.dpr??window.devicePixelRatio??1,n?.viewportOnly?window.scrollY:"",i].join("::")}function it(t,e,n){let r=Math.min(e,n);return{top:Math.max(0,Math.min(t,n-r)),height:r,annotations:[]}}function P(t){if(typeof window>"u")return!1;try{let e=new URL(t,window.location.href);return e.protocol!=="http:"&&e.protocol!=="https:"?!1:e.origin!==window.location.origin}catch{return!1}}function lt(t){let e=document.createElement("canvas").getContext("2d");return e?(e.fillStyle=t,e.fillStyle):"#888888"}function j(t,e=[],n,r,i=[],o=[],a){let s=new Map,c=[];for(let l of t)if(l.groupId){let m=s.get(l.groupId)||[];m.push(l),s.set(l.groupId,m)}else c.push(l);let u=[];for(let[l,m]of s){let h=m.find(d=>d.type!=="text"),g=m.find(d=>d.type==="text");if(h){let d=h.linkedSelector||g?.linkedSelector,f=g?.imageCount||h.imageCount,w=g?.attachments||h.attachments,y=g?.interactionEpisode||h.interactionEpisode,v=h.pathname||g?.pathname;u.push({id:h.id,type:h.type,instruction:g?.text,...d?{linkedSelector:d}:{},...h.target||g?.target?{target:h.target??g?.target}:{},...v?{pathname:v}:{},elements:h.elements||[],...f?{imageCount:f}:{},...w?.length?{attachments:w}:{},...y?{interactionEpisode:y}:{}})}}for(let l of c)u.push({id:l.id,type:l.type,instruction:l.type==="text"?l.text:void 0,...l.linkedSelector?{linkedSelector:l.linkedSelector}:{},...l.target?{target:l.target}:{},...l.pathname?{pathname:l.pathname}:{},elements:l.elements||[],...l.region?{region:l.region}:{},...l.imageCount?{imageCount:l.imageCount}:{},...l.attachments?.length?{attachments:l.attachments}:{},...l.interactionEpisode?{interactionEpisode:l.interactionEpisode}:{}});return{timestamp:new Date().toISOString(),url:window.location.href,viewport:{width:window.innerWidth,height:window.innerHeight},scrollPosition:{x:window.scrollX,y:window.scrollY},annotations:u,styleModifications:e,...i.length>0?{textModifications:i}:{},...o.length>0?{domModifications:o}:{},...n?{inspectedElement:n}:{},...r&&r.length>0?{spacingTokenChanges:r}:{},...a?{meta:a}:{}}}function st(t){if(!t.points||t.points.length===0)return null;let e=[...t.points,...t.region?.points??[]],n=e.map(i=>i.x),r=e.map(i=>i.y);return{minX:Math.min(...n),minY:Math.min(...r),maxX:Math.max(...n),maxY:Math.max(...r)}}function ct(t,e){if(t.length===0)return[];let n=t.map(l=>({annotation:l,bounds:st(l)})).filter(l=>l.bounds!==null);if(n.length===0)return[];n.sort((l,m)=>l.bounds.minY-m.bounds.minY);let r=Math.min(...n.map(l=>l.bounds.minY)),i=Math.max(...n.map(l=>l.bounds.maxY));if(i-r<=e){let l=(r+i)/2,m=Math.max(0,l-e/2);return[{top:m,bottom:m+e,annotations:t}]}let o=[],a=50,s=Math.max(0,r-a),c=[],u=s;for(let{annotation:l,bounds:m}of n){let h=m.maxY+a;if(h-s<=e)c.push(l),u=Math.max(u,h);else{if(c.length>0){let g=(s+u)/2,d=Math.max(0,g-e/2);o.push({top:d,bottom:d+e,annotations:c})}s=Math.max(0,m.minY-a),c=[l],u=m.maxY+a}}if(c.length>0){let l=(s+u)/2,m=Math.max(0,l-e/2);o.push({top:m,bottom:m+e,annotations:c})}return o}function dt(t){let e=new Map;for(let n of t)if(n.linkedSelector)try{let r=W(n.linkedSelector);if(r){let i=z(r);e.set(n.id,{x:i.left+window.scrollX,y:i.top+window.scrollY,width:i.width,height:i.height})}}catch{}return e}function T(t,e,n,r,i){if(t.save(),t.scale(r,r),i)for(let o of e){let a=i.get(o.id);if(!a)continue;let s=a.y-n;t.fillStyle=o.color,t.globalAlpha=.05,t.fillRect(a.x,s,a.width,a.height),t.globalAlpha=1,t.strokeStyle=o.color,t.lineWidth=1,t.setLineDash([2,4]),t.strokeRect(a.x,s,a.width,a.height),t.setLineDash([])}for(let o of e){let a=o.points.map(s=>({x:s.x,y:s.y-n}));switch(t.strokeStyle=o.color,t.fillStyle=o.color,t.lineWidth=o.strokeWidth,t.lineCap="round",t.lineJoin="round",o.region&&N(t,o.region.points.map(s=>({x:s.x,y:s.y-n})),o.color),o.type){case"freehand":if(a.length<2)break;t.beginPath(),t.moveTo(a[0].x,a[0].y);for(let s=1;s<a.length;s++)t.lineTo(a[s].x,a[s].y);t.stroke();break;case"line":if(a.length<2)break;t.beginPath(),t.moveTo(a[0].x,a[0].y),t.lineTo(a[a.length-1].x,a[a.length-1].y),t.stroke();break;case"rectangle":{if(a.length<2)break;let s=a[0],c=a[a.length-1],u=Math.min(s.x,c.x),l=Math.min(s.y,c.y),m=Math.abs(c.x-s.x),h=Math.abs(c.y-s.y);t.strokeRect(u,l,m,h);break}case"circle":{if(a.length<2)break;let s=a[0],c=a[a.length-1],u=(s.x+c.x)/2,l=(s.y+c.y)/2,m=Math.abs(c.x-s.x)/2,h=Math.abs(c.y-s.y)/2;t.beginPath(),t.ellipse(u,l,m,h,0,0,Math.PI*2),t.stroke();break}case"text":{if(!o.text||a.length<1)break;let s=a[0],c=o.fontSize||16;t.font=`${c}px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`,t.fillStyle=o.color;let u=(o.imageCount&&o.imageCount>0?`[${o.imageCount} image${o.imageCount>1?"s":""}] ${o.text}`:o.text).split(`
|
|
3
|
+
`),l=c*1.2,m=4,h=0;for(let g of u)h=Math.max(h,t.measureText(g).width);t.fillRect(s.x-m,s.y-m,h+m*2,u.length*l+m*2),t.fillStyle="#ffffff",u.forEach((g,d)=>{t.fillText(g,s.x,s.y+c+d*l)});break}}}t.restore()}async function mt(t,e,n=[],r){let i=at(t,n,r),o=C.get(i);if(o)return R(r)&&console.debug("[Screenshot] Reusing in-flight capture",i),o;let a=vt(t,n,r).finally(()=>C.delete(i));return C.set(i,a),a}function ht(){let t=getComputedStyle(document.documentElement).backgroundColor;return t&&t!=="rgba(0, 0, 0, 0)"&&t!=="transparent"?t:"#ffffff"}function ut(t){return t instanceof HTMLElement?t.id==="devtools-canvas"||t.id==="devtools-toolbar"||t.id==="devtools-scrim"?!1:t.dataset.devtools===void 0:!0}function gt(t,e,n,r){return t.length===0?[{top:Math.max(0,Math.min(r,Math.max(0,n-e))),height:Math.min(e,n||e),annotations:[]}]:t.map(i=>{let o=Math.min(e,n||e);return{top:Math.max(0,Math.min(i.top,Math.max(0,n-o))),height:o,annotations:i.annotations}})}function ft(t,e,n){if(t.length===0)return null;let r=Math.min(...t.map(a=>a.top)),i=Math.max(...t.map(a=>a.top+a.height))-r,o=e*i*n*n;return i>V||o>K?null:{top:r,height:i}}async function pt(t,e){let n=[];for(let r of t){let i=Object.getOwnPropertyDescriptor(r.element,"toDataURL");try{Object.defineProperty(r.element,"toDataURL",{configurable:!0,value:()=>r.dataUrl}),n.push(()=>{i?Object.defineProperty(r.element,"toDataURL",i):Reflect.deleteProperty(r.element,"toDataURL")})}catch{}}try{return await e()}finally{for(let r of n.reverse())r()}}async function wt(t,e,n,r,i,o,a,s){let c=Math.max(document.body.scrollHeight,document.documentElement.scrollHeight)>window.innerHeight*Z||t.querySelectorAll("*").length>2500,u=s?await s():[];return pt(u,()=>X(t,{autoDestruct:!1,filter:ut,features:{restoreScrollPosition:!0},onCloneNode:l=>{t===document.body&&(l.style.margin=getComputedStyle(t).margin)},onCloneEachNode:l=>{if(l.nodeType===1&&l.localName==="html"&&l.ownerDocument!==document){let m=l.style;m.overflow="hidden",m.display="inline-block",m.clipPath=`inset(0 round ${m.borderRadius||"0px"})`}},scale:r,backgroundColor:ht(),width:n,height:e.height,style:{transform:`translate(${-window.scrollX}px, ${-e.top}px)`,transformOrigin:"top left"},timeout:i,debug:o,includeStyleProperties:c?[..._]:null,fetchFn:rt(i,()=>{a.remoteAssetFallbacks++}),fetch:{requestInit:{cache:"force-cache"},placeholderImage:S}}))}async function yt(t,e,n){return t.width=n,t.height=e.height,t.style={transform:`translate(${-window.scrollX}px, ${-e.top}px)`,transformOrigin:"top left"},J(t)}async function bt(t,e,n){let r=document.createElement("canvas");r.width=e,r.height=n;let i=r.getContext("2d");if(!i)throw new Error("Canvas context unavailable");if(typeof createImageBitmap=="function"){let s=await createImageBitmap(t);return i.drawImage(s,0,0,e,n),s.close(),r}let o=new Image,a=URL.createObjectURL(t);try{return await new Promise((s,c)=>{o.onload=()=>s(),o.onerror=()=>c(new Error("Native screenshot could not be decoded")),o.src=a}),i.drawImage(o,0,0,e,n),r}finally{URL.revokeObjectURL(a)}}async function L(t,e,n,r,i,o){if(r?.nativeCapture){let u=p();try{let l=await r.nativeCapture({url:window.location.href,clip:{x:window.scrollX,y:t.top,width:e,height:t.height},scale:n});if(o.nativeMs+=p()-u,l)return o.mode=o.renderMs>0||o.contextMs>0?"mixed":"native",bt(l,Math.round(e*n),Math.round(t.height*n))}catch(l){o.nativeMs+=p()-u,R(r)&&console.debug("[Screenshot] Native capture unavailable; using DOM fallback",l)}}let a=await i(),s=p(),c=await yt(a,t,e);return o.renderMs+=p()-s,o.mode=o.mode==="native"?"mixed":"dom",c}function U(t,e,n,r,i,o){let a=document.createElement("canvas");a.width=Math.round(r*i),a.height=Math.round(n.height*i);let s=a.getContext("2d");if(!s)throw new Error("Canvas context unavailable");let c=Math.round((n.top-e)*i);return s.drawImage(t,0,c,a.width,a.height,0,0,a.width,a.height),T(s,n.annotations,n.top,i,o),a}function xt(t){if(t.length===1)return t[0];let e=document.createElement("canvas");e.width=t[0]?.width??0,e.height=t.reduce((i,o)=>i+o.height,0);let n=e.getContext("2d");if(!n)throw new Error("Canvas context unavailable");let r=0;for(let i of t)n.drawImage(i,0,r),r+=i.height;return e}function Mt(t,e="image/webp",n=.8){return new Promise(r=>t.toBlob(r,e,n))}async function vt(t,e,n){let r=p(),i=n?.dpr??(window.devicePixelRatio||1),o=window.innerWidth,a=window.innerHeight,s=Math.max(document.body.scrollHeight,document.documentElement.scrollHeight),c=Math.max(250,n?.mediaTimeoutMs??G),u=R(n),l=e.filter(b=>(b.status??"pending")==="pending"),m=dt(l),h=n?.viewportOnly?[it(window.scrollY,a,s)]:gt(ct(l,a),a,s,window.scrollY),g=nt(t),d={startedAt:r,mode:"dom",mediaTimeoutMs:c,ranges:h.length,...g,remoteAssetFallbacks:0,nativeMs:0,contextMs:0,renderMs:0,compositeMs:0,encodeMs:0};console.log("[Screenshot] Starting capture with",l.length,"active annotations (filtered",e.length-l.length,"captured);",`${h.length} range(s), ${g.remoteImages} remote image(s), ${g.unresolvedRemoteImages} unresolved`);let f=null,w=null,y=ft(h,o,i),v=y??h[0],E=async()=>{if(!f){let b=p();f=wt(t,v,o,i,c,u,d,n?.captureSurfaces).then(x=>(w=x,d.contextMs+=p()-b,x))}return f};try{let b=p(),x;if(y){let M=await L(y,o,i,n,E,d);x=h.map(k=>U(M,y.top,k,o,i,m))}else{x=[];for(let M of h){let k=await L(M,o,i,n,E,d);x.push(U(k,M.top,M,o,i,m))}}let Y=xt(x);d.compositeMs+=p()-b-d.renderMs-d.nativeMs-d.contextMs;let B=p(),I=await Mt(Y);d.encodeMs=p()-B;let O=p()-d.startedAt,H={mode:d.mode,totalMs:Math.round(O),mediaTimeoutMs:d.mediaTimeoutMs,ranges:d.ranges,remoteImages:d.remoteImages,unresolvedRemoteImages:d.unresolvedRemoteImages,remoteAssetFallbacks:d.remoteAssetFallbacks,nativeMs:Math.round(d.nativeMs),contextMs:Math.round(d.contextMs),renderMs:Math.round(d.renderMs),compositeMs:Math.max(0,Math.round(d.compositeMs)),encodeMs:Math.round(d.encodeMs),overBudget:O>Q};return console.log("[Screenshot] Capture complete",JSON.stringify(H)),I?[I]:[]}catch(b){return console.error("[Screenshot] Capture failed:",b),[]}finally{w&&F(w)}}async function D(t){if(t.length===0)return null;if(t.length===1)return t[0];let e=await Promise.all(t.map(s=>new Promise((c,u)=>{let l=new Image;l.onload=()=>c(l),l.onerror=u,l.src=URL.createObjectURL(s)}))),n=e[0].width,r=e.reduce((s,c)=>s+c.height,0),i=document.createElement("canvas");i.width=n,i.height=r;let o=i.getContext("2d");if(!o)return null;let a=0;for(let s of e)o.drawImage(s,0,a),a+=s.height,URL.revokeObjectURL(s.src);return new Promise(s=>{i.toBlob(c=>s(c),"image/webp",.8)})}async function kt(t,e,n,r,i){try{let o=Array.isArray(t)?t:[t];if(o.length===0)return!1;let a=await D(o);if(!a)return!1;let s=a;if(a.type!=="image/png"){let g=new Image,d=URL.createObjectURL(a);await new Promise(w=>{g.onload=()=>w(),g.src=d}),URL.revokeObjectURL(d);let f=document.createElement("canvas");f.width=g.naturalWidth,f.height=g.naturalHeight,f.getContext("2d").drawImage(g,0,0),s=await new Promise(w=>f.toBlob(y=>w(y),"image/png"))}let c={"image/png":s},u=e&&e.length>0,l=n&&n.length>0,m=r&&r.length>0,h=i&&i.length>0;if(u||l||m||h){let g=e?e.filter(d=>(d.status??"pending")==="pending"):[];if(g.length>0||l||m||h){let d=j(g,n||[],void 0,void 0,r||[],i||[]),f=new Blob([JSON.stringify(d,null,2)],{type:"text/plain"});c["text/plain"]=f}}return await navigator.clipboard.write([new ClipboardItem(c)]),!0}catch(o){return console.warn("Clipboard write failed:",o),!1}}export{q as a,tt as b,lt as c,j as d,T as e,mt as f,D as g,kt as h};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{c as He,b as In}from"./chunk-4LHTPRFY.mjs";import{a as kn}from"./chunk-MP7S5ALD.mjs";import{j as bt,a as V,f as En,i as We,g as Cn,h as Mt}from"./chunk-XOGBFVWI.mjs";import{b as je,g as Ye,e as qe}from"./chunk-V44RIEET.mjs";import{a as An,b as Rn}from"./chunk-LVEMYZOA.mjs";import{a as St,d as Ee,v as Nn,h as Ln,i as Tt,c as Ce,f as Ae,b as It,e as Dn,g as On}from"./chunk-HGW2U6PD.mjs";import{Clock as kt,OctagonAlert as $n,MessageCircleQuestionMark as _n,TriangleAlert as Fn,Reply as Pn,Eye as zn,SendHorizontal as Re,CornerDownLeft as Bn}from"lucide-react";import{createContext as Ke,useContext as de,useState as re,useEffect as Q,useLayoutEffect as Et,useId as Hn,useRef as le,useMemo as Wn,useCallback as jn,useReducer as Yn,useSyncExternalStore as qn}from"react";import{jsxs as R,jsx as x,Fragment as W}from"react/jsx-runtime";var Ne=new Set,Le;function Xe(e){if(Ne.add(e),!Le){let t=new Map,o=new Map,i="",n=!0,r=!0,a=!1,l=!0,d=0,s=()=>{let h=new Set,u=new Map,f=y=>{if(h.add(y),!t.has(y)){let m=new MutationObserver(k=>{let w=k.filter(v=>!(v.target.nodeType===1?v.target:v.target.parentElement)?.closest("[data-devtools]"));w.length&&(n=!0),w.some(v=>v.type==="childList")&&(r=!0)});m.observe(y,{subtree:!0,childList:!0,characterData:!0,attributes:!0});let g=()=>{n=!0};y.addEventListener("scroll",g,!0),y.addEventListener("load",g,!0),t.set(y,()=>{m.disconnect(),y.removeEventListener("scroll",g,!0),y.removeEventListener("load",g,!0)})}for(let m of y.querySelectorAll("*")){if(m.shadowRoot&&!m.closest("[data-devtools]")&&f(m.shadowRoot),m.localName!=="iframe"||m.closest("[data-devtools],[data-popmelt-peer-surface]"))continue;let g=It(m);u.set(m,g),g&&f(g)}};f(document);for(let[y,m]of t)h.has(y)||(m(),t.delete(y));o=u,r=!1,n=!0},c=()=>{if(!l)return;(r||[...o].some(([f,y])=>It(f)!==y))&&s();let h=[];for(let[f,y]of o){let m=f.getBoundingClientRect();h.push(y?.URL,m.x,m.y,m.width,m.height,y?.defaultView?.scrollX,y?.defaultView?.scrollY)}let u=JSON.stringify(h);if((n||u!==i)&&(n=!1,i=u,a))for(let f of Ne)f();a=!0,l&&(d=requestAnimationFrame(c))};c(),Le=()=>{l=!1,cancelAnimationFrame(d);for(let h of t.values())h()}}return()=>{Ne.delete(e),Ne.size||(Le?.(),Le=void 0)}}var xe=Ke(!0);function Ue(e,t){let o=e.match(/^oklch\(([^)]+)\)$/i);if(o)return`oklch(${o[1]} / ${t})`;let i=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(i){let n=parseInt(i[1],16),r=parseInt(i[2],16),a=parseInt(i[3],16);return`rgba(${n}, ${r}, ${a}, ${t})`}return`color-mix(in srgb, ${e} ${Math.round(t*100)}%, transparent)`}function Ct(e,t){let o=Cn(e),i=t.toLowerCase(),n=-1;for(let r=o.length-1;r>=0;r--){let a=o[r].name;if(a===t){let l=Mt(o[r].fiber)??e;return{name:t,path:o.map(d=>d.name),depthIndex:r,rootElement:l}}if(n===-1){let l=a.toLowerCase();(l.length>=4&&i.includes(l)||i.length>=4&&l.includes(i))&&(n=r)}}if(n>=0){let r=Mt(o[n].fiber)??e;return{name:t,path:o.map(a=>a.name),depthIndex:n,rootElement:r}}return null}function Kn(e){let t=De(),o=[],i=new Set,n=t.currentNode;for(;n=t.nextNode();){let r=Ct(n,e);r&&!i.has(r.rootElement)&&(i.add(r.rootElement),o.push(r))}return o}function Xn(e){let t=new Map;if(e.size===0)return t;let o=new Set(e),i=De(),n=new Set,r=i.currentNode;for(;(r=i.nextNode())&&o.size>0;)for(let a of o){let l=Ct(r,a);if(!l||n.has(l.rootElement))continue;n.add(l.rootElement);let d=l.rootElement.getBoundingClientRect();t.set(a,d.top+window.scrollY),o.delete(a);break}for(let a of o)t.set(a,1/0);return t}function De(){return document.createTreeWalker(document.body,NodeFilter.SHOW_ELEMENT,{acceptNode(e){return e.closest("#devtools-toolbar, #devtools-canvas, #devtools-scrim, [data-popmelt-panel]")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}})}function q(e,t){return e.style.getPropertyValue(t)!==""}function Un(e,t=30){if(e<=0)return[];let o=[],i=De(),n=.5,r=i.currentNode;for(;(r=i.nextNode())&&o.length<t;){let a=r,l=a.getBoundingClientRect();if(l.bottom<-50||l.top>window.innerHeight+50||l.right<-50||l.left>window.innerWidth+50||l.width<1||l.height<1)continue;let d=getComputedStyle(a);!q(a,"padding-top")&&Math.abs((parseFloat(d.paddingTop)||0)-e)<n&&o.push({element:a,property:"padding-top"}),!q(a,"padding-bottom")&&Math.abs((parseFloat(d.paddingBottom)||0)-e)<n&&o.length<t&&o.push({element:a,property:"padding-bottom"}),!q(a,"padding-left")&&Math.abs((parseFloat(d.paddingLeft)||0)-e)<n&&o.length<t&&o.push({element:a,property:"padding-left"}),!q(a,"padding-right")&&Math.abs((parseFloat(d.paddingRight)||0)-e)<n&&o.length<t&&o.push({element:a,property:"padding-right"}),!q(a,"margin-top")&&Math.abs((parseFloat(d.marginTop)||0)-e)<n&&o.length<t&&o.push({element:a,property:"margin-top"}),!q(a,"margin-bottom")&&Math.abs((parseFloat(d.marginBottom)||0)-e)<n&&o.length<t&&o.push({element:a,property:"margin-bottom"}),!q(a,"margin-left")&&Math.abs((parseFloat(d.marginLeft)||0)-e)<n&&o.length<t&&o.push({element:a,property:"margin-left"}),!q(a,"margin-right")&&Math.abs((parseFloat(d.marginRight)||0)-e)<n&&o.length<t&&o.push({element:a,property:"margin-right"});let s=d.display;if((s.includes("flex")||s.includes("grid"))&&o.length<t){let c=q(a,"gap"),h=parseFloat(d.gap)||0,u=parseFloat(d.rowGap)||0,f=parseFloat(d.columnGap)||0;!c&&Math.abs(h-e)<n?o.push({element:a,property:"gap"}):!q(a,"row-gap")&&Math.abs(u-e)<n?o.push({element:a,property:"row-gap"}):!q(a,"column-gap")&&Math.abs(f-e)<n&&o.push({element:a,property:"column-gap"})}}return o}function Vn(e){return typeof e=="string"?{value:e}:e}var At={gap:["gap","row-gap","column-gap"],padding:["padding-top","padding-bottom","padding-left","padding-right"],margin:["margin-top","margin-bottom","margin-left","margin-right"]};function Rt(e,t){let o=At[t];return o?o.includes(e):!1}function Qn(e,t){let o=e.split(/\s+/);for(let i of o){if(i===t)return!0;let n=i.lastIndexOf(":");if(n>=0&&i.slice(n+1)===t)return!0}return!1}function Gn(e){let t=e.lastIndexOf(":"),o=t>=0?e.slice(t+1):e,i=o.indexOf("-");if(i<0)return null;let n=o.slice(0,i),r={gap:"gap","gap-x":"column-gap","gap-y":"row-gap",p:"padding",pt:"padding-top",pb:"padding-bottom",pl:"padding-left",pr:"padding-right",px:"padding-left",py:"padding-top",m:"margin",mt:"margin-top",mb:"margin-bottom",ml:"margin-left",mr:"margin-right",mx:"margin-left",my:"margin-top"},a=o.slice(0,o.indexOf("-",i+1)>0?o.indexOf("-",i+1):i);return r[a]??r[n]??null}function Jn(e,t=30){let o=parseFloat(e.value);if(isNaN(o)||o<=0)return[];if(e.bindings&&e.bindings.length>0){let n=[],r=De(),a=r.currentNode;for(;(a=r.nextNode())&&n.length<t;){let l=a,d=l.getBoundingClientRect();if(d.bottom<-50||d.top>window.innerHeight+50||d.right<-50||d.left>window.innerWidth+50||d.width<1||d.height<1)continue;let s=l.className;if(typeof s=="string")for(let c of e.bindings){if(!Qn(s,c))continue;let h=Gn(c);if(h&&!(e.property&&!Rt(h,e.property))){n.push({element:l,property:h});break}}}return n}let i=Un(o,t*2);return e.property?i.filter(n=>Rt(n.property,e.property)).slice(0,t):i.slice(0,t)}function Zn(e,t){let o=new Set,i=we(t);for(let n of e){let r=Nt[n.property];if(!r)continue;let a=n.element.className;if(typeof a=="string")for(let l of r){let d=`${l}-${i}`;for(let s of a.split(/\s+/)){let c=s.lastIndexOf(":"),h=c>=0?s.slice(c+1):s;if(h===d){o.add(h);break}}}}return[...o]}function eo(e){let t=new Set;for(let o of e)for(let[i,n]of Object.entries(At))if(n.includes(o.property)){t.add(i);break}if(t.size===1)return[...t][0]}function to(e,t,o){if(t===o)return e;let i=we(t),n=we(o);return e.map(r=>{let a=r.lastIndexOf("-");if(a<0)return r;let l=r.slice(0,a),d=r.slice(a+1);return d===i||d===`[${t}px]`?`${l}-${n}`:r})}var no={0:"0",1:"px",2:"0.5",4:"1",6:"1.5",8:"2",12:"3",16:"4",20:"5",24:"6",28:"7",32:"8",40:"10",48:"12",64:"16",80:"20",96:"24"};function we(e){return no[e]??`[${e}px]`}var Nt={"padding-top":["pt","py","p"],"padding-bottom":["pb","py","p"],"padding-left":["pl","px","p"],"padding-right":["pr","px","p"],"margin-top":["mt","my","m"],"margin-bottom":["mb","my","m"],"margin-left":["ml","mx","m"],"margin-right":["mr","mx","m"],gap:["gap"],"row-gap":["gap-y","gap"],"column-gap":["gap-x","gap"]};function oo(e,t,o,i){let n=Nt[t];if(!n)return null;let r=we(o);for(let a of n){let l=new RegExp("(?:^|\\s)((?:[\\w-]+:)*"+a+"-(?:"+io(r)+"|\\["+o+"px\\]))(?:\\s|$)"),d=e.match(l);if(d?.[1]){let s=we(i),c=d[1].lastIndexOf(":"),h=c>=0?d[1].slice(0,c+1):"";return{matched:d[1],suggested:`${h}${a}-${s}`}}}return null}function io(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ao(e,t,o){let i=new Set,n=[];for(let r of e){let a=V(r.element),l=`${a}::${r.property}`;if(i.has(l))continue;i.add(l);let d=En(r.element),s=r.element.className||"",c=oo(s,r.property,t,o);n.push({selector:a,reactComponent:d?.name,className:s,property:r.property,matchedClass:c?.matched,suggestedClass:c?.suggested})}return n}function ro(e){let t=window.getComputedStyle(e).display;return t==="flex"||t==="inline-flex"||t==="grid"||t==="inline-grid"}function lo(e){let t=window.getComputedStyle(e);return{row:parseFloat(t.rowGap)||0,column:parseFloat(t.columnGap)||0}}function so(e){let t=[];for(let o of e){let i=t.find(n=>n.axis!==o.axis?!1:o.axis==="row"?Math.abs(n.y-o.y)<2&&Math.abs(n.h-o.h)<2:Math.abs(n.x-o.x)<2&&Math.abs(n.w-o.w)<2);if(i)if(o.axis==="row"){let n=Math.min(i.x,o.x),r=Math.max(i.x+i.w,o.x+o.w);i.x=n,i.w=r-n}else{let n=Math.min(i.y,o.y),r=Math.max(i.y+i.h,o.y+o.h);i.y=n,i.h=r-n}else t.push({...o})}return t}function po(e){let t=Array.from(e.children).filter(l=>{if(!(l instanceof HTMLElement))return!1;let d=window.getComputedStyle(l);return d.display!=="none"&&d.position!=="absolute"&&d.position!=="fixed"});if(t.length<2)return[];let o=[],i=e.getBoundingClientRect(),n=window.getComputedStyle(e).flexDirection,r=n==="column"||n==="column-reverse",a=6;for(let l=0;l<t.length-1;l++){let d=t[l].getBoundingClientRect(),s=t[l+1].getBoundingClientRect();if(s.left>d.right+.5&&o.push({axis:"column",x:d.right,y:i.top,w:s.left-d.right,h:i.height}),s.top>d.bottom+.5&&o.push({axis:"row",x:i.left,y:d.bottom,w:i.width,h:s.top-d.bottom}),!(s.left>d.right+.5)&&!(s.top>d.bottom+.5))if(r){let c=(d.bottom+s.top)/2;o.push({axis:"row",x:i.left,y:c-a/2,w:i.width,h:a})}else{let c=(d.right+s.left)/2;o.push({axis:"column",x:c-a/2,y:i.top,w:a,h:i.height})}}return so(o)}function co(e,t){let o=window.getComputedStyle(e),i=o.display;if(i!=="flex"&&i!=="inline-flex")return!1;let n=o.justifyContent;if(n!=="space-between"&&n!=="space-around"&&n!=="space-evenly"&&n!=="stretch")return!1;let r=o.flexDirection;return!(t!==(r==="column"||r==="column-reverse"?"row":"column")||parseFloat(t==="row"?o.rowGap:o.columnGap)>0)}function uo(e){let t=window.getComputedStyle(e);return{top:parseFloat(t.paddingTop)||0,right:parseFloat(t.paddingRight)||0,bottom:parseFloat(t.paddingBottom)||0,left:parseFloat(t.paddingLeft)||0}}function fo(e){let t=window.getComputedStyle(e);return{top:parseFloat(t.marginTop)||0,right:parseFloat(t.marginRight)||0,bottom:parseFloat(t.marginBottom)||0,left:parseFloat(t.marginLeft)||0}}function Lt(e){let t=window.getComputedStyle(e);return{topLeft:t.borderTopLeftRadius,topRight:t.borderTopRightRadius,bottomRight:t.borderBottomRightRadius,bottomLeft:t.borderBottomLeftRadius}}function Dt(e){let t=window.getComputedStyle(e);return{"top-left":parseFloat(t.borderTopLeftRadius)||0,"top-right":parseFloat(t.borderTopRightRadius)||0,"bottom-right":parseFloat(t.borderBottomRightRadius)||0,"bottom-left":parseFloat(t.borderBottomLeftRadius)||0}}function ho(e){for(let t of e.childNodes)if(t.nodeType===Node.TEXT_NODE&&(t.textContent||"").trim().length>0)return!0;return!1}function go(e){let t=document.createRange(),o=!1;for(let c of e.childNodes)c.nodeType===Node.TEXT_NODE&&(c.textContent||"").trim().length>0&&(o||(t.setStart(c,0),o=!0),t.setEnd(c,c.textContent?.length??0));if(!o)return null;let i=t.getBoundingClientRect(),n=window.getComputedStyle(e),r=parseFloat(n.fontSize)||16,a=parseFloat(n.lineHeight);isNaN(a)&&(a=r*1.2);let l=Math.max(1,t.getClientRects().length),d=Math.max(i.height,l*a),s=(d-i.height)/2;return new DOMRect(i.x,i.y-s,i.width,d)}function mo(e){let t=window.getComputedStyle(e),o=parseFloat(t.fontSize)||16,i=parseFloat(t.lineHeight);return isNaN(i)&&(i=o*1.2),{fontSize:o,lineHeight:i}}function yo(e){let t=e.startsWith("top-");return{top:t?4:12,right:4,bottom:t?12:4,left:4}}function xo({hasCommentEntry:e,stagedChangeCount:t}){return e&&t===0?2:6}function wo({annotationNumber:e,stickerCount:t,interactionEpisodeStepCount:o,hasStatus:i,hasSend:n,controlGap:r}){let a=16+Math.max(1,e===void 0?0:String(e).length)*7.2,l=t*28-Math.max(0,t-1)*2,d=o>0?32+String(o).length*7.2:0,s=28,c=t>0?l+(d>0?d-2:0)+(n?s-2:0):0,h=[t>0?c:0,t===0?d:0,t===0&&n?s:0,i?s:0].filter(u=>u>0);return a+h.reduce((u,f)=>u+f,0)+h.length*r}function vo(e,t,o){let i=e.horizontalAlignment==="right"?e.left-t:e.left;return{left:i,top:e.top,right:i+t,bottom:e.top+o}}function bo(e,t){return e.left<t.right&&e.right>t.left&&e.top<t.bottom&&e.bottom>t.top}function Mo(e,t,o){let i=Math.max(0,e.left+t-o);return Math.max(0,t-e.right)<i?"right":"left"}function Ot(e,t,o,i,n=0,r=Number.POSITIVE_INFINITY){if(e.height>=i)return{anchor:"top-left",horizontalAlignment:"left",left:e.left+8,top:e.top+8};let a=Mo(e,n,r);return e.top>=t+o?{anchor:a==="right"?"top-right":"top-left",horizontalAlignment:a,left:a==="right"?e.right:e.left,top:e.top-t-o}:{anchor:a==="right"?"bottom-right":"bottom-left",horizontalAlignment:a,left:a==="right"?e.right:e.left,top:e.bottom+o}}function Ve(e){return e.left+e.width}function Oe(e){return e.top+e.height}function Qe(e,t){if(e.length===0)return t;let o=Math.min(...e.map(a=>a.left)),i=Math.min(...e.map(a=>a.top)),n=Math.max(...e.map(Ve)),r=Math.max(...e.map(Oe));return{left:o,top:i,width:n-o,height:r-i}}function Ge(e){let t=[...e].sort((i,n)=>i.top-n.top||i.left-n.left),o=[];for(let i of t){let n=i.top+i.height/2,r=o.find(c=>{let h=c.top+c.height/2;return Math.abs(n-h)<=Math.max(c.height,i.height)*.4});if(!r){o.push({...i});continue}let a=Math.min(r.left,i.left),l=Math.min(r.top,i.top),d=Math.max(Ve(r),Ve(i)),s=Math.max(Oe(r),Oe(i));r.left=a,r.top=l,r.width=d-a,r.height=s-l}return o.sort((i,n)=>i.top-n.top||i.left-n.left)}function So({display:e,fragmentRects:t,elementRect:o,parentContentRect:i}){let n=Ge(t),r=Qe(n,o);if(!(e==="inline"&&n.length>1&&i&&i.width>0))return{textRect:r,boundaryRect:o,boundaryRects:[o],firstLineIndent:0};let a=n[0],l={left:i.left,top:a.top,width:i.width,height:Math.max(r.height,Oe(r)-a.top)},d=Math.max(0,Math.min(l.width,a.left-l.left));return{textRect:r,boundaryRect:Qe(n,o),boundaryRects:n,flowRect:l,firstLineIndent:d}}var Je=new WeakMap;function To(e){let t={listeners:new Set,rafId:null,schedule:()=>{t.rafId===null&&(t.rafId=e.requestAnimationFrame(()=>{t.rafId=null;for(let o of t.listeners)o()}))}};return Je.set(e,t),e.addEventListener("scroll",t.schedule,{passive:!0,capture:!0}),e.addEventListener("resize",t.schedule),t}function $t(e,t=window){let o=Je.get(t)??To(t);return o.listeners.add(e),()=>{o.listeners.delete(e)&&(o.listeners.size>0||(t.removeEventListener("scroll",o.schedule,!0),t.removeEventListener("resize",o.schedule),o.rafId!==null&&t.cancelAnimationFrame(o.rafId),Je.delete(t)))}}var se={topLeft:"0px",topRight:"0px",bottomRight:"0px",bottomLeft:"0px"};function _t(e,t){return e.radii.topLeft!==t.radii.topLeft||e.radii.topRight!==t.radii.topRight||e.radii.bottomRight!==t.radii.bottomRight||e.radii.bottomLeft!==t.radii.bottomLeft||e.outline!==t.outline||e.fragments.length!==t.fragments.length?!1:e.fragments.every((o,i)=>{let n=t.fragments[i];return!!n&&o.left===n.left&&o.top===n.top&&o.width===n.width&&o.height===n.height})}function Ft(e){if(!e.isConnected||!Ln(e.ownerDocument))return{fragments:[],radii:se};let t=Tt(Ee(e),e.ownerDocument);if(St(e.ownerDocument)&&(!t.width||!t.height))return{fragments:[],radii:se};if(e.getAttribute("data-popmelt-subject-projection")==="true")return{fragments:[{left:t.left,top:t.top,width:t.width,height:t.height}],radii:se,outline:e.getAttribute("data-popmelt-subject-outline")??void 0};let o=Array.from(e.getClientRects()).map(i=>Tt(Ce(i,e.ownerDocument),e.ownerDocument)).filter(i=>i.width>0&&i.height>0).map(i=>({left:i.left,top:i.top,width:i.width,height:i.height}));return{fragments:Ge(o.length>0?o:[{left:t.left,top:t.top,width:t.width,height:t.height}]),radii:Lt(e)}}function Pt({element:e,projectedRect:t,isSelected:o=!1,elementInfo:i,color:n="#3b82f6",annotationNumber:r,changeCount:a,hideTooltip:l=!1,hideOutline:d=!1,hideFill:s=!1,fillOpacity:c=.05,subjectRegistry:h,railGap:u=2,railHeight:f=22,railWidth:y=0,renderRail:m,refreshKey:g,outlineZIndex:k=9996,onActivate:w,onRemove:v}){let S=de(xe),[b,C]=re({fragments:[],radii:se});Q(()=>{if(!S)return;if(!e){C({fragments:[],radii:se});return}let P=null,H=()=>{let ee=Ft(e);C(Ie=>_t(Ie,ee)?Ie:ee)},E=()=>{P===null&&(P=requestAnimationFrame(()=>{P=null,H()}))};H();let fe=e.getAttribute("data-popmelt-subject-projection")==="true"&&!!h,he=fe?h.subscribeFrame(H):void 0,ge=fe||typeof ResizeObserver>"u"?null:new ResizeObserver(E);ge?.observe(e);let B=fe?null:new MutationObserver(E);B?.observe(e,{attributes:!0,attributeFilter:["style","class"]});let ae=$t(H,e.ownerDocument.defaultView??window),me=St(e.ownerDocument)?Xe(H):void 0;return()=>{ae(),me?.(),he?.(),ge?.disconnect(),B?.disconnect(),P!==null&&cancelAnimationFrame(P)}},[S,e,h]),Et(()=>{if(!S||!e||g===void 0)return;let P=Ft(e);C(H=>_t(H,P)?H:P)},[S,e,g]);let{fragments:N,radii:z}=t?{fragments:[t],radii:se}:b;if(N.length===0||!e&&!t)return null;let A=Qe(N,N[0]),I=e?.tagName.toLowerCase()??"",U=e?.id?`#${e.id}`:"",oe=e&&e.classList.length>0?"."+Array.from(e.classList).slice(0,2).join("."):"",ie=i?.reactComponent,Me=e?.getAttribute("data-popmelt-subject-adapter"),Se=e?.getAttribute("data-popmelt-subject-label"),Pe=Me&&Se?`<${Se}>`:ie?`<${ie}> ${I}${U}${oe}`:`${I}${U}${oe}`,Z=Ot({left:A.left,right:A.left+A.width,top:A.top,bottom:A.top+A.height,height:A.height},f,u,window.innerHeight,y,window.innerWidth),Te={zIndex:9997,display:"flex",alignItems:"center",gap:6,backgroundColor:n,color:"#fff",fontSize:12,fontFamily:je,lineHeight:"14px",padding:"4px 8px",borderRadius:8,pointerEvents:"none",whiteSpace:"nowrap",maxWidth:400,position:"fixed",top:Z.top,left:Z.left},ze=!l&&R("div",{ref:P=>{e&&An(e,P)},"data-devtools":"tooltip",style:Te,children:[r!==void 0&&R("span",{children:[r,"."]}),x("span",{style:{overflow:"hidden",textOverflow:"ellipsis",flex:1,minWidth:0},children:Pe}),a!==void 0&&a>0&&R("span",{style:{opacity:.8},children:["(",a," ",a===1?"change":"changes",")"]})]});return R(W,{children:[!d&&N.map((P,H)=>x("div",{"data-devtools":"highlight",onContextMenu:v?E=>{E.preventDefault(),E.stopPropagation(),v()}:void 0,role:w?"button":void 0,tabIndex:w?0:void 0,"aria-label":w?"Open annotation thread":void 0,onPointerDown:w?E=>{E.preventDefault(),E.stopPropagation()}:void 0,onClick:w?E=>{E.preventDefault(),E.stopPropagation(),w()}:void 0,onKeyDown:w?E=>{(E.key==="Enter"||E.key===" ")&&(E.preventDefault(),E.stopPropagation(),w())}:void 0,style:{position:"fixed",top:P.top,left:P.left,width:P.width,height:P.height,pointerEvents:w||v?"auto":"none",cursor:w?"pointer":void 0,zIndex:k,overflow:"visible"},children:x("div",{style:b.outline?{position:"absolute",inset:0,pointerEvents:"none"}:{position:"absolute",inset:0,boxSizing:"border-box",backgroundColor:s?"transparent":Ue(n,c),borderColor:n,borderStyle:o?"solid":"dashed",borderWidth:1,borderTopLeftRadius:z.topLeft,borderTopRightRadius:z.topRight,borderBottomRightRadius:z.bottomRight,borderBottomLeftRadius:z.bottomLeft,pointerEvents:"none"},children:b.outline?x("svg",{viewBox:"0 0 1 1",preserveAspectRatio:"none",width:"100%",height:"100%",style:{display:"block",overflow:"visible"},"aria-hidden":"true",children:x("polygon",{points:b.outline,fill:s?"transparent":Ue(n,c),stroke:n,strokeWidth:1,strokeDasharray:o?void 0:"4 3",vectorEffect:"non-scaling-stroke"})}):null})},`${P.left}:${P.top}:${H}`)),m?m(Z,A):ze]})}function zt(e){return e==="bottom-left"?[2,8,8,8]:e==="bottom-right"?[8,2,8,8]:e==="top-right"?[8,8,2,8]:[8,8,8,2]}function Io(e){return zt(e).map(t=>`${t}px`).join(" ")}var ve=1.1666666666666667,Bt=2048;function Ze(e){return e.length>Bt?`${e.slice(0,Bt)}\u2026`:e}function ko(e,t,o){let i=Ze(t);if(!i||e.measureText(i).width<=o)return[i];let n=i.split(/\s+/),r=[],a="";for(let l of n){let d=a?`${a} ${l}`:l;a&&e.measureText(d).width>o?(r.push(a),a=l):a=d}return a&&r.push(a),r.length>0?r:[i]}function Eo(e,t,o){return t.flatMap(i=>ko(e,i,o))}var ne=je,et=400,Ht=16,tt=60,Co=12,nt=16;function Wt(e){let t=window.innerWidth-e-Ht;return Math.max(tt,Math.min(et,t))}function ot(e,t,o){let i=Ze(t);if(i===t&&e.measureText(i).width<=o)return i;let n="\u2026",r=0,a=i.endsWith(n)?i.length-1:i.length;for(;r<a;){let l=Math.ceil((r+a)/2);e.measureText(i.slice(0,l)+n).width<=o?r=l:a=l-1}return r>0?i.slice(0,r)+n:n}function Ao(e,t,o){if(e===void 0||t===void 0||o.avoidLeft===void 0&&o.avoidRight===void 0)return!0;let i=typeof window<"u"?window.innerWidth:9999,n=o.avoidLeft??0,r=o.avoidRight??i;return e+t>n&&e<r}function jt(e,t,o,i,n){let r=typeof window<"u"?window.innerHeight:9999,a=0,l=r;o&&Ao(i,n,o)&&(a=o.avoidTop??a,l=o.avoidBottom??l);let d=Math.max(a,l-t);return Math.max(a,Math.min(e,d))}function Yt(e,t=12,o,i){let n=t*ve+8,r=e.y-4,a=e.x-8,l=jt(r,n,o,a,i);return l===r?e:{...e,y:l+4}}function Ro(e,t,o,i,n=12,r,a,l,d="#dddddd",s,c=!1){if(!o)return;let h=n*ve,u=o.replace(/\n/g," "),f=r!==void 0?r+". "+u:u;e.font=`${n}px ${ne}`,e.textBaseline="middle";let y=a!==void 0?Math.min(et,Math.max(tt,window.innerWidth-a-Ht)):et,m=c?nt:0,g=ot(e,f,Math.max(tt,y-m)),k=e.measureText(g).width,w=m+k,v=Yt(t,n,l,w+16);e.fillStyle=i;let S=v.x-8,b=v.y-4,C=w+16,N=h+8;e.beginPath(),e.roundRect(S,b,C,N,zt(s)),e.fill();let z=v.y+h/2;if(c){let A=v.x,I=z-Co/2;e.strokeStyle=d,e.lineWidth=1.5,e.lineCap="round",e.lineJoin="round",e.beginPath(),e.moveTo(A+7.5,I+4),e.lineTo(A+10.5,I+6.5),e.lineTo(A+7.5,I+9),e.moveTo(A+1.5,I+1.5),e.lineTo(A+1.5,I+4.5),e.quadraticCurveTo(A+1.5,I+6.5,A+3.5,I+6.5),e.lineTo(A+10.5,I+6.5),e.stroke()}e.fillStyle=d,e.fillText(g,v.x+m,z)}function No(e,t,o){let i=e.filter(n=>!n.captured&&n.selector===t&&(!n.pathname||n.pathname===o));return i.length?{type:"MODIFY_TEXT_CONTENTS",payload:i.map(n=>({...n,modified:n.original}))}:null}function qt(e,t){return e.type!=="text"?!1:(e.groupId?t.filter(o=>o.groupId===e.groupId):[e]).every(o=>(o.status??"pending")==="pending"&&!o.threadId)}var Kt=Ke(0),it=`
|
|
3
|
+
0%, 100% { translate: 0 0; }
|
|
4
|
+
20% { translate: -4px 0; }
|
|
5
|
+
45% { translate: 4px 0; }
|
|
6
|
+
70% { translate: -2px 0; }
|
|
7
|
+
88% { translate: 1px 0; }
|
|
8
|
+
`;function at(e=22){return{height:e,minHeight:e,maxHeight:e,boxSizing:"border-box",flexShrink:0}}function Xt(e){return`
|
|
9
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%">
|
|
10
|
+
<defs>
|
|
11
|
+
<mask id="cutout">
|
|
12
|
+
<rect width="100%" height="100%" fill="white" />
|
|
13
|
+
<rect x="${e.x}" y="${e.y}" width="${e.width}" height="${e.height}" rx="${e.radius}" fill="black" />
|
|
14
|
+
</mask>
|
|
15
|
+
</defs>
|
|
16
|
+
<rect width="100%" height="100%" fill="white" mask="url(#cutout)" />
|
|
17
|
+
</svg>`}function Ut(e){return`url("data:image/svg+xml,${encodeURIComponent(e)}")`}var be=Ut(Xt({x:-100,y:-2,width:104,height:26,radius:10})),Lo=Ut(Xt({x:-100,y:-5.929,width:108,height:26,radius:10})),rt=10;function Do(e){if(!(!Number.isFinite(e)||e<=0))return Math.max(1,Math.round(e/He))*He}function Oo(e,t,o){let i={topLeft:Math.max(0,o.topLeft),topRight:Math.max(0,o.topRight),bottomRight:Math.max(0,o.bottomRight),bottomLeft:Math.max(0,o.bottomLeft)},n=Math.min(1,e/Math.max(1,i.topLeft+i.topRight),e/Math.max(1,i.bottomLeft+i.bottomRight),t/Math.max(1,i.topLeft+i.bottomLeft),t/Math.max(1,i.topRight+i.bottomRight));return{topLeft:i.topLeft*n,topRight:i.topRight*n,bottomRight:i.bottomRight*n,bottomLeft:i.bottomLeft*n}}function $o(e,t,o,i=.5){let n=Math.max(0,e-i*2),r=Math.max(0,t-i*2),a=Oo(e,t,o),l=Math.max(0,a.topLeft-i),d=Math.max(0,a.topRight-i),s=Math.max(0,a.bottomRight-i),c=Math.max(0,a.bottomLeft-i),h=i+n,u=i+r;return[`M ${i+l} ${i}`,`H ${h-d}`,`A ${d} ${d} 0 0 1 ${h} ${i+d}`,`V ${u-s}`,`A ${s} ${s} 0 0 1 ${h-s} ${u}`,`H ${i+c}`,`A ${c} ${c} 0 0 1 ${i} ${u-c}`,`V ${i+l}`,`A ${l} ${l} 0 0 1 ${i+l} ${i}`,"Z"].join(" ")}var pe=12,G=8,ce=8;function Vt(e){return e>0?16+String(e).length*7.2+16:0}function Qt({stepCount:e,onClear:t,layered:o=!1,submitted:i=!1,style:n}){let[r]=Ye(),a=qe[r];if(e<1)return null;let l=`${e} recorded ${e===1?"action":"actions"}${i?", sent":""}`;return R("span",{"data-devtools":"interaction-episode-badge","data-popmelt-submitted":i?"true":void 0,"aria-label":l,onContextMenu:d=>{d.preventDefault(),d.stopPropagation(),t?.()},style:{height:22,display:"inline-flex",alignItems:"center",boxSizing:"border-box",backgroundColor:i?"#8c8c8c":a.surface,border:`1px solid ${i?"#8c8c8c":a.border}`,borderRadius:G,color:i?"#dddddd":a.primary,fontFamily:ne,fontSize:12,fontWeight:600,padding:o?`0 8px 0 ${rt*.7}px`:"0 8px 0 5.6px",gap:4,pointerEvents:t?"auto":"none",WebkitMaskImage:o?be:void 0,maskImage:o?be:void 0,...n},children:[R("svg",{"aria-hidden":!0,width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[x("path",{d:"M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z"}),x("path",{d:"M21 11V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h6"})]}),x("span",{children:e})]})}var _o=3,Fo=250;function Po(e){let t=e?.current?.getBoundingClientRect();return!t||typeof window>"u"?{}:t.top<window.innerHeight/2?{avoidTop:t.bottom+ce,avoidLeft:t.left-ce,avoidRight:t.right+ce}:{avoidBottom:t.top-ce,avoidLeft:t.left-ce,avoidRight:t.right+ce}}function zo(e,t,o){if(o.avoidLeft===void 0&&o.avoidRight===void 0)return!0;let i=typeof window<"u"?window.innerWidth:9999,n=o.avoidLeft??0,r=o.avoidRight??i;return e+t>n&&e<r}function lt(e,t,o){return zo(t,o,e)?e:{}}function Bo(e,t,o){let i=o.avoidTop!==void 0?`${o.avoidTop}px`:"0px",n=o.avoidBottom!==void 0?`${o.avoidBottom}px`:"100dvh";return`translate(min(0px, calc(100vw - ${e} - 100%)), min(max(0px, calc(${i} - ${t})), calc(${n} - ${t} - 100%)))`}function Gt(e,t,o){if(o.avoidTop===void 0&&o.avoidBottom===void 0)return e;let i=typeof window<"u"?window.innerHeight:9999,n=o.avoidTop??0,r=o.avoidBottom??i,a=Math.max(n,r-t);return Math.max(n,Math.min(e,a))}function Jt({left:e,top:t,scrollX:o,scrollY:i,avoidTop:n,avoidBottom:r,style:a,children:l,...d}){let s=`calc(${e}px - var(--popmelt-scroll-x, ${o}px))`,c=`calc(${t}px - var(--popmelt-scroll-y, ${i}px))`,h=`calc(${e+pe}px - var(--popmelt-scroll-x, ${o}px))`,u=`calc(${t+pe}px - var(--popmelt-scroll-y, ${i}px))`;return x("div",{"data-devtools":"badge-hit-area",...d,style:{position:"fixed",left:0,top:0,padding:pe,...a,transform:`translate3d(${s}, ${c}, 0)`,willChange:"transform"},children:x("div",{style:{transform:Bo(h,u,{avoidTop:n,avoidBottom:r})},children:l})})}function Zt({bundleCount:e,style:t,layered:o=!1,compact:i=!1,description:n,replacementText:r,onHoverChange:a,onSend:l}){let[d,s]=re(!1),[c]=Ye(),h=qe[c],u=de(Kt),f=Hn(),y=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/.test(navigator.platform)?"\u2318":"Ctrl",m=Math.max(1,e),g=i&&!d,k=C=>g?x(Re,{size:12,strokeWidth:2,"aria-hidden":!0}):C?R(W,{children:[x("span",{style:{color:"inherit",fontWeight:600},children:m>1?`Send all ${m}`:"Send"}),x(Re,{size:12,strokeWidth:2,"aria-hidden":!0})]}):R(W,{children:[R("span",{style:{display:"inline-flex",alignItems:"center",gap:2,color:"inherit",fontWeight:600},children:[x("span",{children:y}),x("span",{children:"+"}),x(Bn,{size:12,strokeWidth:2,"aria-hidden":!0})]}),x("span",{style:{color:h.secondary,fontWeight:600},children:"to"}),x(Re,{size:12,strokeWidth:2,"aria-hidden":!0}),m>1&&x("span",{style:{color:"inherit",fontWeight:600},children:m})]}),w=C=>R(W,{children:[x("span",{className:"popmelt-send-hint-desktop",style:{alignItems:"center",gap:4},children:k(C)}),R("span",{className:"popmelt-send-hint-mobile",style:{alignItems:"center",gap:4},children:[!g&&x("span",{style:{color:"inherit",fontWeight:600},children:"Send"}),x(Re,{size:12,strokeWidth:2,"aria-hidden":!0})]})]}),v=r?x("span",{role:"tooltip","data-devtools":"parent-pinned-location-tooltip",style:{overflow:"hidden",textOverflow:"ellipsis"},children:r}):null,S={...at(),lineHeight:`${12*ve}px`,display:"flex",alignItems:"center",boxSizing:"border-box",backgroundColor:h.surface,border:`1px solid ${h.border}`,fontFamily:ne,fontSize:12,color:h.primary,userSelect:"none",padding:o?`0 8px 0 ${rt}px`:"0 8px",gap:4,whiteSpace:"nowrap",borderRadius:G,letterSpacing:"0.24px",WebkitMaskImage:o?be:void 0,maskImage:o?be:void 0},b=m>1?`Send all ${m} pending annotations`:"Send pending annotation";return R("div",{"data-devtools":"send-hint-hit-area","data-popmelt-send-rejection":u?u%2?"odd":"even":void 0,onMouseEnter:()=>{s(!0),a?.(!0)},onMouseLeave:()=>{s(!1),a?.(!1)},style:{display:"grid",width:"max-content",...t},children:[x("style",{children:`
|
|
18
|
+
@keyframes popmelt-send-rejection-odd { ${it} }
|
|
19
|
+
@keyframes popmelt-send-rejection-even { ${it} }
|
|
20
|
+
[data-popmelt-send-rejection="odd"] { animation: popmelt-send-rejection-odd 220ms ease-out; }
|
|
21
|
+
[data-popmelt-send-rejection="even"] { animation: popmelt-send-rejection-even 220ms ease-out; }
|
|
22
|
+
@media (prefers-reduced-motion: reduce) {
|
|
23
|
+
[data-popmelt-send-rejection] { animation: none; }
|
|
24
|
+
}
|
|
25
|
+
.popmelt-send-hint-desktop { display: inline-flex; }
|
|
26
|
+
.popmelt-send-hint-mobile { display: none; }
|
|
27
|
+
@media (max-width: 767px) {
|
|
28
|
+
.popmelt-send-hint-desktop { display: none; }
|
|
29
|
+
.popmelt-send-hint-mobile { display: inline-flex; }
|
|
30
|
+
}
|
|
31
|
+
`}),x("div",{"aria-hidden":!0,style:{...S,gridArea:"1 / 1",visibility:"hidden"},children:w(!1)}),R("button",{type:"button","data-devtools":"annotation-badge","aria-label":b,"aria-describedby":n?f:void 0,disabled:!l,onPointerDown:C=>{C.preventDefault(),C.stopPropagation()},onClick:C=>{C.preventDefault(),C.stopPropagation(),l?.()},style:{...S,gridArea:"1 / 1",justifySelf:"start",maxWidth:r?"min(320px, calc(100vw - 16px))":void 0,overflow:r?"hidden":void 0,appearance:"none",margin:0,opacity:1,cursor:l?"pointer":"default",touchAction:"manipulation"},children:[n&&x("span",{id:f,style:{position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:0},children:n}),v??w(d)]})]})}function en({count:e,color:t,size:o=22,onHoverChange:i}){return R("div",{"data-devtools":"nested-annotation-count-badge",onMouseEnter:()=>i?.(!0),onMouseLeave:()=>i?.(!1),style:{height:o,display:"flex",alignItems:"center",backgroundColor:t,color:t==="#8c8c8c"?"#dddddd":"#ffffff",fontFamily:ne,fontSize:12,fontWeight:600,lineHeight:1,padding:"0 8px",borderRadius:G,userSelect:"none",whiteSpace:"nowrap"},children:["+",e]})}function Ho({annotations:e,supersededAnnotations:t,inFlightIds:o,orientationLabels:i,activeIds:n,queuePositions:r,scrollX:a,scrollY:l,annotationGroupMap:d,onViewThread:s,onSelectAnnotation:c,onDeleteDraftAnnotation:h,onClearInteractionEpisode:u,onHoverAnnotation:f,canvasRef:y,toolbarRef:m,activeBundleAnnotationIds:g,inactiveBundleOpacity:k=.5,animateBundleOpacity:w=!0,hoverRestoredAnnotationIds:v,nestedAnnotationCountById:S,nestedAnnotationIdsById:b,onHoverNestedAnnotations:C,onHoverSendBundle:N,onSend:z,sendHintAnchorId:A,pendingBundleCount:I=1,parentPinnedAnnotationIds:U,parentPinnedLocationLabels:oe,parentPinnedTooltipAnnotationId:ie,onActivateAnnotation:Me,hiddenAnnotationIds:Se,displayAnnotations:Pe}){let Z=de(xe),Te=le(null),[ze,P]=re(0),H=!!(o&&o.size>0&&(n===void 0||n.size>0));Q(()=>{if(!H||!Z)return;let p=setInterval(()=>{P(M=>(M+1)%_o)},Fo);return()=>{clearInterval(p)}},[H,Z]),Q(()=>{if(!Z)return;let p=Te.current;if(!p)return;let M=()=>{p.style.setProperty("--popmelt-scroll-x",`${window.scrollX}px`),p.style.setProperty("--popmelt-scroll-y",`${window.scrollY}px`)};return M(),window.addEventListener("scroll",M,{passive:!0,capture:!0}),window.addEventListener("resize",M),()=>{window.removeEventListener("scroll",M,!0),window.removeEventListener("resize",M)}},[Z]);let E=[],fe=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/.test(navigator.platform)?"\u2318":"Ctrl";for(let p of e){if(p.type!=="text"||!p.text||!p.points[0]||t.has(p)||Se?.has(p.id))continue;let M=p.groupId?e.filter(T=>T.groupId===p.groupId):[p],O=p.status??"pending",F=I>0&&p.id===A,L=p.interactionEpisode?.steps.length??0,j=S?.get(p.id)??0,K=b?.get(p.id)??[],D=M.reduce((T,Tn)=>Math.max(T,Tn.replyCount??0),0),Y=O==="sending"||M.some(T=>T.status==="sending"),X=O==="awaiting_review",$=!Y&&(!!(o&&(o.has(p.id)||M.some(T=>o.has(T.id))))||p.status==="in_flight"||M.some(T=>T.status==="in_flight")),ye=M.some(T=>T.status==="resolved"&&(T.replyCount??0)>0||T.status==="needs_review"),te=M.some(T=>T.threadId),gn=!g||M.some(T=>g.has(T.id)||v?.has(T.id));if(!(F||Y||X||$||O==="resolved"||O==="failed"||O==="needs_review"||ye||te||L>0)&&j===0)continue;let mn=p.threadId||M.find(T=>T.threadId)?.threadId,ft=O==="needs_review"||M.some(T=>T.status==="needs_review"),ht=O==="waiting_input"||M.some(T=>T.status==="waiting_input"),gt=O==="failed"||M.some(T=>T.status==="failed"),mt=F||Y||X||$||ft||ht||gt||D>0||O==="resolved"&&te||L>0;if(!mt&&j===0)continue;let Be=p.points[0],yt=p.fontSize||12,yn=yt*ve,xt=d.get(p.id),wt=((Pe?.find(T=>T.id===p.id)??p).text??p.text).replace(/\n/g," "),xn=xt!==void 0?xt+". "+wt:wt,ke=y?.current?.getContext("2d")??document.createElement("canvas").getContext("2d");if(!ke)continue;ke.font=`${yt}px ${ne}`;let wn=Be.x-a,vt=U?.has(p.id)?nt:0,vn=Math.max(60,Wt(wn)-vt),bn=ot(ke,xn,vn),Mn=ke.measureText(bn).width,Sn=$&&!!n&&!n.has(p.id)&&!M.some(T=>n.has(T.id));E.push({id:p.id,threadId:mn,linkedSelector:p.linkedSelector||M.find(T=>T.linkedSelector)?.linkedSelector,x:Be.x+Mn+vt+8+2,y:Be.y-4,size:yn+8,color:F?"#000000":p.color,isSending:Y,isAwaitingReview:X,isInFlight:$,orientationLabel:i?.get(p.id)??M.map(T=>i?.get(T.id)).find(Boolean),isQueued:Sn,queuePosition:void 0,isNeedsReview:ft,isQuestion:ht,isFailed:gt,replyCount:D>0?D:O==="resolved"&&te?1:0,isInActiveBundle:gn,isSendHint:F,interactionEpisodeStepCount:L,interactionEpisodeSubmitted:O!=="pending",nestedCount:j,nestedAnnotationIds:K,nestedColor:O==="pending"?p.color:"#8c8c8c",showActionBadge:mt,canDeleteDraft:qt(p,e)})}let he=E.filter(p=>p.isQueued);if(he.length>0&&he.forEach((p,M)=>{p.queuePosition=r?.get(p.id)??`(${M+1}/${he.length})`}),E.length===0)return null;let ge=2,B=y?.current?.getContext("2d")??document.createElement("canvas").getContext("2d"),ae=E.map(p=>{B&&(B.font=`12px ${ne}`);let M=p.nestedCount>0?(B?.measureText(`+${p.nestedCount}`).width??String(p.nestedCount).length*7.2+7.2)+16:0,O=Vt(p.interactionEpisodeStepCount);if(!p.showActionBadge)return M+O;let F=ie===p.id?oe?.get(p.id):void 0,L;F?L=F:p.isSendHint?L=fe:p.isSending?L="Sending":p.isAwaitingReview?L="Awaiting review":p.isInFlight?L=p.isQueued?`Queued${p.queuePosition?` ${p.queuePosition}`:""}`:p.orientationLabel??"Thinking":p.isQuestion?L="Question":p.isFailed?L="Failed":p.replyCount>0?L="Replied":L="Needs decision";let j=p.isSendHint||F?0:12,K=4,D=L.length*7.2;B&&(D=B.measureText(L).width);let Y=p.isSendHint&&B?B.measureText("to").width:p.isSendHint?14.4:0,X=p.isSendHint&&B?B.measureText("+").width:p.isSendHint?7.2:0,$=p.isSendHint&&I>1&&B?B.measureText(String(I)).width:p.isSendHint&&I>1?7.2:0,ye=F?Math.min(D+16,320):p.isSendHint?D+X+Y+$+16+12+12+4+K*(I>1?3:2):6+j+K+D+8,te=+(O>0)+ +(M>0)+1;return O+M+ye+(te-1)*2}),me=Po(m),ee=[];for(let p=0;p<E.length;p++){let M=E[p].y-l,O=E[p].x-a,F=lt(me,O,ae[p]),L=Gt(M,E[p].size,F),j=L+E[p].size,K=O;for(let D=0;D<p;D++){let Y=E[D].y-l,X=lt(me,ee[D],ae[D]),$=Gt(Y,E[D].size,X),ye=$+E[D].size;if(!(L<ye&&j>$))continue;let te=ee[D]+ae[D];K<te+ge&&(K=te+ge)}ee.push(K)}let Ie={position:"fixed",inset:0,pointerEvents:"none",zIndex:9999,"--popmelt-scroll-x":`${a}px`,"--popmelt-scroll-y":`${l}px`};return R("div",{ref:Te,"data-devtools":"annotation-badge-layer",style:Ie,children:[x("style",{dangerouslySetInnerHTML:{__html:`
|
|
32
|
+
[data-devtools="annotation-badge-layer"] [data-devtools="annotation-badge"]::selection,
|
|
33
|
+
[data-devtools="annotation-badge-layer"] [data-devtools="annotation-badge"] *::selection {
|
|
34
|
+
background: #000000;
|
|
35
|
+
color: #ffffff;
|
|
36
|
+
}
|
|
37
|
+
`}}),E.map((p,M)=>{let O=!!p.threadId,F=oe?.get(p.id),L=!!F&&ie===p.id,j=O||!!F,K=p.showActionBadge&&p.isSendHint,D=j&&!K,Y=()=>{if(Me){Me(p.id,p.threadId);return}c?.(p.id),p.threadId&&s?.(p.threadId)},X=lt(me,ee[M],ae[M]);return x(Jt,{left:ee[M]+a-pe,top:p.y-pe,scrollX:a,scrollY:l,avoidTop:X.avoidTop,avoidBottom:X.avoidBottom,onMouseDown:$=>$.stopPropagation(),onContextMenu:$=>{$.preventDefault(),$.stopPropagation(),p.canDeleteDraft&&h&&h(p.id)},onClick:j?$=>{$.stopPropagation(),Y()}:void 0,onMouseEnter:()=>{f?.(p.id)},onMouseLeave:()=>{f?.(null)},onFocus:()=>f?.(p.id),onBlur:()=>f?.(null),onKeyDown:D?$=>{$.key!=="Enter"&&$.key!==" "||($.preventDefault(),Y())}:void 0,role:D?"button":void 0,tabIndex:D?0:void 0,"aria-label":D&&F?`${F}. Activate to reveal the annotation source${O?" and open its thread":""}`:void 0,style:{pointerEvents:"auto",cursor:j?"pointer":void 0,zIndex:9999,minWidth:p.isSendHint?ae[M]:void 0},children:R("div",{style:{position:"relative",display:"flex",alignItems:"center",gap:2},children:[x(Qt,{stepCount:p.interactionEpisodeStepCount,submitted:p.interactionEpisodeSubmitted,onClear:p.canDeleteDraft&&u?()=>u(p.id):void 0}),p.nestedCount>0&&x(en,{count:p.nestedCount,color:p.nestedColor,size:p.size,onHoverChange:$=>C?.(p.id,$?p.nestedAnnotationIds:null)}),p.showActionBadge&&(p.isSendHint?x(Zt,{bundleCount:I,description:F?`${F}. Activate the annotation label to reveal its source.`:void 0,replacementText:L?F:void 0,onHoverChange:N,onSend:z}):x("div",{"data-devtools":"annotation-badge",style:{...at(p.size),display:"flex",alignItems:"center",backgroundColor:p.color,fontFamily:ne,fontSize:12,color:"#ffffff",userSelect:"none",padding:"0 8px 0 6px",gap:4,whiteSpace:"nowrap",maxWidth:L?"min(320px, calc(100vw - 16px))":void 0,overflow:L?"hidden":void 0,borderRadius:G,opacity:p.isInActiveBundle?1:k,transition:w?"opacity 120ms ease-out":"none"},children:L?x("span",{role:"tooltip","data-devtools":"parent-pinned-location-tooltip",style:{overflow:"hidden",textOverflow:"ellipsis"},children:F}):p.isAwaitingReview?R(W,{children:[x(kt,{size:12,strokeWidth:2.25}),"Awaiting review"]}):p.isQueued?R("span",{style:{opacity:.6,color:"inherit",display:"inline-flex",alignItems:"center",gap:4},children:[x(kt,{size:12,strokeWidth:2.25}),"Queued",p.queuePosition?` ${p.queuePosition}`:""]}):p.isSending||p.isInFlight?R(W,{children:[p.orientationLabel==="Approval needed"?x($n,{size:12,"aria-label":"Approval needed"}):x("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",style:{verticalAlign:"middle",opacity:.6},children:ze===1?R(W,{children:[x("circle",{cx:"7",cy:"7",r:"2"}),x("circle",{cx:"17",cy:"7",r:"2"}),x("circle",{cx:"7",cy:"17",r:"2"}),x("circle",{cx:"17",cy:"17",r:"2"})]}):R(W,{children:[x("circle",{cx:"12",cy:"6",r:"2"}),x("circle",{cx:"6",cy:"12",r:"2"}),x("circle",{cx:"18",cy:"12",r:"2"}),x("circle",{cx:"12",cy:"18",r:"2"})]})}),x("span",{style:{opacity:.6,color:"inherit"},children:p.isSending?"Sending":p.isQueued?`Queued${p.queuePosition?` ${p.queuePosition}`:""}`:p.orientationLabel??"Thinking"})]}):R(W,{children:[p.isQuestion?x(_n,{size:12,strokeWidth:2.25}):p.isFailed?x(Fn,{size:12,strokeWidth:2.25}):p.replyCount>0?x(Pn,{size:12,strokeWidth:2.25}):R("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[x("path",{d:"M18 8a6 6 0 0 0-12 0c0 7-3 7-3 9h18c0-2-3-2-3-9"}),x("path",{d:"M10 21h4"})]}),x("span",{style:{color:"inherit"},children:p.isQuestion?"Question":p.isFailed?"Failed":p.replyCount>0?"Replied":"Needs decision"})]})}))]})},p.id)})]})}function tn({d:e,color:t,animated:o}){let i=le(null);return Et(()=>{let n=i.current;if(!n||typeof n.getTotalLength!="function")return;let r=Do(n.getTotalLength());r===void 0?n.removeAttribute("pathLength"):n.setAttribute("pathLength",String(r))},[e]),x("path",{ref:i,d:e,fill:"none",stroke:t,strokeWidth:1,strokeDasharray:o?In:void 0,"data-popmelt-marching-stroke":o||void 0,style:o?{animation:"popmelt-march 0.6s linear infinite"}:void 0})}function nn(){return x("style",{children:`
|
|
38
|
+
@keyframes popmelt-march {
|
|
39
|
+
from { stroke-dashoffset: 0; }
|
|
40
|
+
to { stroke-dashoffset: -${He}; }
|
|
41
|
+
}
|
|
42
|
+
@media (prefers-reduced-motion: reduce) {
|
|
43
|
+
[data-popmelt-marching-stroke="true"] { animation: none !important; }
|
|
44
|
+
}
|
|
45
|
+
`})}function Wo({annotations:e,activeIds:t,scrollX:o,scrollY:i,spotlightIds:n,emphasizedIds:r,hoverRestoredIds:a,inactiveOpacity:l=.5}){if(!de(xe))return null;let d=e.filter(s=>s.region&&s.region.points.length>=3&&t?.has(s.id));return d.length?R(W,{children:[x(nn,{}),x("svg",{"data-devtools":"marching-lasso","aria-hidden":!0,style:{position:"fixed",inset:0,width:"100%",height:"100%",pointerEvents:"none",zIndex:9995,overflow:"visible"},children:x("g",{transform:`translate(${-o} ${-i})`,children:d.map(s=>{let c=n?.size?n.has(s.id)?1:.2:r&&!r.has(s.id)&&!a?.has(s.id)?l:1;return x("g",{"data-popmelt-region-id":s.id,opacity:c,children:x(tn,{d:`${s.region.points.map((h,u)=>`${u?"L":"M"}${h.x} ${h.y}`).join(" ")} Z`,color:s.color,animated:!0})},s.id)})})})]}):null}function jo({inFlightSelectorColors:e,animated:t=!0,subjectRegistry:o,selectorElementInfo:i}){let n=de(xe),[r,a]=re([]);return Q(()=>{if(!n)return;if(e.size===0){a([]);return}let l=null,d=()=>{let f=[];for(let[y,m]of e){let g=Nn(y,i?.get(y));if(!g)continue;let k=Ee(g);f.push({selector:y,top:k.top,left:k.left,width:k.width,height:k.height,color:m,radius:Dt(g),radiusStyle:Lt(g)})}a(f)},s=()=>{l&&cancelAnimationFrame(l),l=requestAnimationFrame(d)};d(),window.addEventListener("scroll",s,!0),window.addEventListener("resize",s,!0);let c=new MutationObserver(s);c.observe(document.body,{attributes:!0,childList:!0,subtree:!0,attributeFilter:["style","class"]});let h=o?.subscribeFrame(d),u=[...e.keys()].some(f=>f.startsWith("@frame("))?Xe(d):void 0;return()=>{window.removeEventListener("scroll",s,!0),window.removeEventListener("resize",s,!0),c.disconnect(),h?.(),u?.(),l&&cancelAnimationFrame(l)}},[e,o,i,n]),r.length===0?null:R(W,{children:[t&&x(nn,{}),r.map(l=>x("div",{"data-devtools":"marching-ants",style:{position:"fixed",top:l.top,left:l.left,width:l.width,height:l.height,pointerEvents:"none",zIndex:9995,overflow:"visible",borderTopLeftRadius:l.radiusStyle.topLeft,borderTopRightRadius:l.radiusStyle.topRight,borderBottomRightRadius:l.radiusStyle.bottomRight,borderBottomLeftRadius:l.radiusStyle.bottomLeft},children:x("svg",{style:{position:"absolute",inset:0,width:"100%",height:"100%",overflow:"visible"},children:x(tn,{d:$o(l.width,l.height,{topLeft:l.radius["top-left"],topRight:l.radius["top-right"],bottomRight:l.radius["bottom-right"],bottomLeft:l.radius["bottom-left"]}),color:l.color,animated:t})})},l.selector))]})}function Yo({element:e,elements:t,registry:o,label:i="Looking",engaged:n=!0,outlineColor:r,inverse:a=!1}){let l=le(0),d=Wn(()=>t??(e?[e]:[]),[t,e]),[s,c]=re(()=>d.map(u=>({target:u,id:++l.current,animateEntrance:!0,exiting:!1}))),h=jn(u=>{c(f=>f.filter(y=>y.id!==u))},[]);return Q(()=>{d.length&&c(u=>{let f=u.some(({target:m})=>m.isConnected),y=d.map(m=>u.find(g=>g.target===m&&!g.exiting)??{target:m,id:++l.current,animateEntrance:!f,exiting:!1});return[...u.filter(m=>!m.exiting&&!d.includes(m.target)).map(m=>({...m,exiting:!0})),...y]})},[d]),x(W,{children:s.map(({target:u,id:f,animateEntrance:y,exiting:m})=>x(qo,{id:f,element:n&&d.includes(u)?u:null,target:u,animateEntrance:y,exiting:m,registry:o,label:i,outlineColor:r,inverse:a,onDone:h},f))})}function qo({id:e,element:t,target:o,animateEntrance:i,exiting:n,registry:r,label:a,outlineColor:l,inverse:d,onDone:s}){let[c]=Ye(),h=qe[c],u=o,[f,y]=re(!1),m=le(Date.now()),[g,k]=re(null);return Q(()=>{if(!u)return;let w,v=()=>{let S=Rn(u);k(b=>S?b?.left===S.left&&b.top===S.top?b:{left:S.left,top:S.top}:null),w=requestAnimationFrame(v)};return v(),()=>cancelAnimationFrame(w)},[u]),Q(()=>{let w,v;return n?v=setTimeout(()=>s(e),200):t?(m.current=Date.now(),y(!1)):w=setTimeout(()=>{y(!0),v=setTimeout(()=>s(e),300)},Math.max(0,m.current+1700-Date.now())),()=>{clearTimeout(w),clearTimeout(v)}},[t,n,e,s]),u?.isConnected?R(W,{children:[x("style",{children:`
|
|
46
|
+
@keyframes popmelt-looking-in-left { from { opacity: 0; transform: translateX(26px); clip-path: inset(0 100% 0 0); } to { opacity: 1; transform: translateX(0); clip-path: inset(0); } }
|
|
47
|
+
@keyframes popmelt-looking-out-left { from { opacity: 1; } to { opacity: 0; } }
|
|
48
|
+
@keyframes popmelt-looking-in-up { from { opacity: 0; transform: translateY(26px); clip-path: inset(0 0 100% 0); } to { opacity: 1; transform: translateY(0); clip-path: inset(0); } }
|
|
49
|
+
@keyframes popmelt-looking-in-alone-up-left { from { opacity: 0; transform: translate(8px, 8px); } to { opacity: 1; transform: translate(0, 0); } }
|
|
50
|
+
@keyframes popmelt-looking-in-alone-down-left { from { opacity: 0; transform: translate(8px, -8px); } to { opacity: 1; transform: translate(0, 0); } }
|
|
51
|
+
@keyframes popmelt-looking-in-alone-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
|
|
52
|
+
@keyframes popmelt-looking-in-alone-down { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
|
|
53
|
+
@keyframes popmelt-looking-out-up { from { opacity: 1; } to { opacity: 0; } }
|
|
54
|
+
@keyframes popmelt-looking-fade-in { from { opacity: 0; } to { opacity: 1; } }
|
|
55
|
+
@keyframes popmelt-looking-fade-out { from { opacity: 1; } to { opacity: 0; } }
|
|
56
|
+
@keyframes popmelt-looking-blink { 0%, 40%, 72.5%, 100% { transform: scaleY(1); } 50%, 62.5% { transform: scaleY(0.1); } }
|
|
57
|
+
.popmelt-looking-eye { animation: popmelt-looking-blink 1000ms 200ms both; transform-origin: center; }
|
|
58
|
+
@media (prefers-reduced-motion: reduce) {
|
|
59
|
+
[data-devtools="focus-inspection"], .popmelt-looking-eye { animation: none !important; }
|
|
60
|
+
[data-popmelt-looking-exiting] { opacity: 0 !important; }
|
|
61
|
+
}
|
|
62
|
+
`}),x(Pt,{element:u,subjectRegistry:r,hideOutline:!l||f||n,color:l,outlineZIndex:l?10002:void 0,hideFill:!0,hideTooltip:!0,railHeight:22,renderRail:(w,v)=>{let S=g??w,b=S.left>=28,C=!g&&w.anchor.startsWith("bottom-"),N=g?b?"left":"up":`${C?"down":"up"}${b?"-left":""}`,z=g&&!b?Math.max(4,S.top-22-2):S.top,A=b?S.left-22-2:S.left,I=v.left+v.width/2>=A+22/2,U=v.top+v.height/2>=z+22/2?I?"borderBottomRightRadius":"borderBottomLeftRadius":I?"borderTopRightRadius":"borderTopLeftRadius";return x("div",{"data-devtools":"focus-inspection","data-popmelt-looking-exiting":n?"true":void 0,"data-popmelt-canvas-block":!0,role:"status","aria-live":n?"off":"polite","aria-hidden":n||void 0,"aria-label":a,title:a,style:{position:"fixed",animation:n?"popmelt-looking-fade-out 200ms ease both":!f&&!i?"popmelt-looking-fade-in 200ms ease both":`popmelt-looking-${f?"out":g?"in":"in-alone"}-${f?b?"left":"up":N} ${f?300:200}ms ease both`,left:A,top:z,height:22,width:22,boxSizing:"border-box",display:"inline-flex",alignItems:"center",justifyContent:"center",backgroundColor:d?h.actionSurface:h.surface,color:d?h.actionForeground:h.primary,border:`1px solid ${d?h.actionHover:h.border}`,borderTopLeftRadius:G,borderTopRightRadius:G,borderBottomLeftRadius:G,borderBottomRightRadius:G,...g?{}:{[U]:2},fontFamily:je,fontSize:12,letterSpacing:"0.24px",whiteSpace:"nowrap",pointerEvents:n?"none":"auto",zIndex:u.hasAttribute("data-popmelt-thread-header")?10005:10002},children:x(zn,{className:i&&!n?"popmelt-looking-eye":void 0,size:12,"aria-hidden":!0})})}})]}):null}var Ko={production:{issuer:"https://popmelt.com",resource:"https://mcp.popmelt.com"},staging:{issuer:"https://webapp-staging-1bed.up.railway.app",resource:"https://mcp-staging-8731.up.railway.app"}};function Xo(e){if(typeof e!="string")throw new Error("Unexpected sign-in destination.");let t=new URL(e);if(!Object.values(Ko).some(({issuer:o})=>t.origin===o)||t.pathname!=="/mcp/grant"||t.username||t.password||t.hash)throw new Error("Unexpected sign-in destination.");return t}var $e={toolbar:{toggleKey:["Meta","Control"],toggleTaps:2,toggleWindowMs:300},tools:{imprint:{key:"i",tool:"model"},steer:{key:"s",tool:"sticker"},comment:{key:"c",tool:"inspector"}},actions:{send:{key:"Enter",commandOrControl:!0},screenshot:{key:"c",commandOrControl:!0},clear:{keys:["Backspace","Delete"],commandOrControl:!0},undo:{key:"z",commandOrControl:!0},redo:{key:"z",commandOrControl:!0,shift:!0}},omnidial:{previous:["a","ArrowLeft"],next:["d","ArrowRight"],previousFacet:["q"],nextFacet:["e"],descendOrApply:["w","Enter"],ascend:["s","Escape"],query:[" "]}},Uo=[{type:"model",label:"Imprint",shortcut:"I"},{type:"sticker",label:"Steer",shortcut:"S"},{type:"inspector",label:"Chat",shortcut:"C"}];function Vo(e){let t=e.toLowerCase();return Object.values($e.tools).find(o=>o.key===t)?.tool??null}function Qo(e){let t=e.length===1?e.toLowerCase():e,o=$e.omnidial;return[...o.previous,...o.next,...o.previousFacet,...o.nextFacet,...o.descendOrApply,...o.ascend,...o.query].includes(t)||/^[a-z0-9]$/i.test(e)}var on=Ke(null),Go=()=>()=>{},an=()=>null;function dt(){return Math.random().toString(36).substring(2,9)}function _e(e){return e.type==="text"&&e.region?.kind==="lasso"&&(e={...e,fontSize:12,linkedAnchor:e.linkedAnchor??"bottom-left"}),e.status?e:e.captured?{...e,status:"in_flight"}:{...e,status:"pending"}}function _(e){return{...e,undoStack:[...e.undoStack,{annotations:e.annotations,styleModifications:e.styleModifications,textModifications:e.textModifications,domModifications:e.domModifications,spacingTokenChanges:e.spacingTokenChanges,spacingTokenMods:e.spacingTokenMods}],redoStack:[]}}function Jo(e,t){return{...e,isAnnotating:t}}function Zo(e,t){return{...e,activeTool:t}}function ei(e,t){return{...e,activeColor:t}}function ti(e,t){return{...e,strokeWidth:t}}function ni(e,t){let o={id:t.id??dt(),type:"text",points:[t.point],text:t.text,fontSize:t.fontSize||12,color:e.activeColor,strokeWidth:e.strokeWidth,timestamp:Date.now(),status:"pending",pathname:typeof window<"u"?window.location.pathname:"/",groupId:t.groupId,linkedSelector:t.linkedSelector,target:t.target,linkedAnchor:t.linkedAnchor,elements:t.elements,...t.region?{region:t.region}:{},...t.imageCount?{imageCount:t.imageCount}:{},...t.attachments?.length?{attachments:t.attachments}:{},...t.interactionEpisode?{interactionEpisode:t.interactionEpisode}:{}};return{...t.groupId?e:_(e),annotations:[...e.annotations,o]}}function oi(e,t){return{..._(e),annotations:e.annotations.map(o=>o.id===t.id?{...o,text:t.text,...t.imageCount!=null?{imageCount:t.imageCount}:{},...t.attachments?{attachments:t.attachments}:{},...t.interactionEpisode?{interactionEpisode:t.interactionEpisode}:{}}:o)}}function ii(e,t){return{..._(e),annotations:e.annotations.map(o=>{if(o.id!==t.id)return o;let i=o.interactionEpisode?.frames?.length??0,{interactionEpisode:n,...r}=o;if(i===0)return r;let a=Math.max(0,(o.imageCount??0)-i);if(a===0){let{imageCount:l,...d}=r;return d}return{...r,imageCount:a}})}}function ai(e,t){let o=_(e),i=e.annotations.find(r=>r.id===t.id)?.groupId,n=new Set(e.annotations.filter(r=>r.id===t.id||i&&r.groupId===i).map(r=>r.id));return{...o,annotations:e.annotations.filter(r=>r.id!==t.id&&!(i&&r.groupId===i)),selectedAnnotationIds:e.selectedAnnotationIds.filter(r=>!n.has(r)),lastSelectedId:e.lastSelectedId&&n.has(e.lastSelectedId)?null:e.lastSelectedId}}function ri(e,t){let o=t.saveUndo?_(e):e,i=e.annotations.find(n=>n.id===t.id)?.groupId;return{...o,annotations:e.annotations.map(n=>{if(!(n.id===t.id||i&&n.groupId===i))return n;let r=t.delta.x,a=t.delta.y;return{...n,points:n.points.map(l=>({x:l.x+r,y:l.y+a}))}})}}function li(e,t){let o=t.saveUndo?_(e):e,i=e.annotations.find(a=>a.id===t.id);if(!i||i.type==="text"||i.points.length<2)return e;let n=0,r=0;if(i.type==="rectangle"&&i.groupId){let a=t.points,l=Math.min(a[0].x,a[1].x),d=Math.max(a[0].y,a[1].y),s=i.points[0],c=i.points[i.points.length-1],h=Math.min(s.x,c.x),u=Math.max(s.y,c.y);n=l-h,r=d-u}return{...o,annotations:e.annotations.map(a=>a.id===t.id?{...a,points:t.points}:i.groupId&&a.groupId===i.groupId&&a.type==="text"?{...a,points:a.points.map(l=>({x:l.x+n,y:l.y+r}))}:a)}}function di(e,t){return{..._(e),annotations:[...e.annotations,...t.annotations.map(_e)]}}function si(e,t){let o=new Set,i=[];for(let n of t.annotations)o.has(n.id)||(o.add(n.id),i.push(_e(n)));return{...e,annotations:i}}function pi(e,t){let o=new Map(e.annotations.map(n=>[n.id,n])),i=t.annotations.map(n=>{let r=_e(n),a=o.get(r.id);return!a||!r.linkedSelector||a.linkedSelector!==r.linkedSelector?r:{...r,points:a.points,linkedAnchor:a.linkedAnchor}});return{...e,annotations:i}}function ci(e,t){let o=new Set(e.annotations.map(n=>n.id)),i=t.annotations.filter(n=>!o.has(n.id)).map(_e);return i.length>0?{...e,annotations:[...e.annotations,...i]}:e}function ui(e){if(e.undoStack.length===0)return e;let t=e.undoStack[e.undoStack.length-1];return{...e,annotations:t?.annotations||[],styleModifications:t?.styleModifications||[],textModifications:t?.textModifications||[],domModifications:t?.domModifications||[],spacingTokenChanges:t?.spacingTokenChanges||[],spacingTokenMods:t?.spacingTokenMods||[],undoStack:e.undoStack.slice(0,-1),redoStack:[...e.redoStack,{annotations:e.annotations,styleModifications:e.styleModifications,textModifications:e.textModifications,domModifications:e.domModifications,spacingTokenChanges:e.spacingTokenChanges,spacingTokenMods:e.spacingTokenMods}]}}function fi(e){if(e.redoStack.length===0)return e;let t=e.redoStack[e.redoStack.length-1];return{...e,annotations:t?.annotations||[],styleModifications:t?.styleModifications||[],textModifications:t?.textModifications||[],domModifications:t?.domModifications||[],spacingTokenChanges:t?.spacingTokenChanges||[],spacingTokenMods:t?.spacingTokenMods||[],redoStack:e.redoStack.slice(0,-1),undoStack:[...e.undoStack,{annotations:e.annotations,styleModifications:e.styleModifications,textModifications:e.textModifications,domModifications:e.domModifications,spacingTokenChanges:e.spacingTokenChanges,spacingTokenMods:e.spacingTokenMods}]}}function hi(e,t){let{id:o,addToSelection:i}=t;if(o===null)return{...e,selectedAnnotationIds:[],lastSelectedId:null};if(i)if(e.selectedAnnotationIds.includes(o)){let n=e.selectedAnnotationIds.filter(r=>r!==o);return{...e,selectedAnnotationIds:n,lastSelectedId:n.length>0?n[n.length-1]:null}}else return{...e,selectedAnnotationIds:[...e.selectedAnnotationIds,o],lastSelectedId:o};return{...e,selectedAnnotationIds:[o],lastSelectedId:o}}function gi(e,t){let o=e.annotations.find(n=>n.id===t.id)?.groupId,i=new Set;for(let n of e.selectedAnnotationIds){let r=e.annotations.find(a=>a.id===n);r?.groupId&&i.add(r.groupId)}return{...e,annotations:e.annotations.map(n=>n.id===t.id||e.selectedAnnotationIds.includes(n.id)||n.groupId&&(n.groupId===o||i.has(n.groupId))?{...n,color:t.color}:n)}}function mi(e,t){let o=typeof window<"u"?window.location.pathname:"/",i=t?new Set(t):void 0;return{...e,annotations:e.annotations.map(n=>i&&!i.has(n.id)?n:{...n,captured:!0,status:n.status==="pending"||n.status==="sending"||!n.status?"in_flight":n.status}),styleModifications:e.styleModifications.map(n=>!n.pathname||n.pathname===o?{...n,captured:!0}:n),textModifications:e.textModifications.map(n=>!n.pathname||n.pathname===o?{...n,captured:!0}:n),domModifications:e.domModifications.map(n=>!n.pathname||n.pathname===o?{...n,captured:!0}:n),spacingTokenChanges:e.spacingTokenChanges.map(n=>({...n,captured:!0})),spacingTokenMods:e.spacingTokenMods.map(n=>({...n,captured:!0}))}}function yi(e){return e.annotations.some(t=>(t.status??"pending")==="pending")||e.styleModifications.some(t=>!t.captured)||e.textModifications.some(t=>!t.captured)||e.domModifications.some(t=>!t.captured)||e.spacingTokenChanges.some(t=>!t.captured)||e.spacingTokenMods.some(t=>!t.captured)?{..._(e),annotations:e.annotations.filter(t=>(t.status??"pending")!=="pending"),styleModifications:e.styleModifications.filter(t=>t.captured),textModifications:e.textModifications.filter(t=>t.captured),domModifications:e.domModifications.filter(t=>t.captured),spacingTokenChanges:e.spacingTokenChanges.filter(t=>t.captured),spacingTokenMods:e.spacingTokenMods.filter(t=>t.captured),selectedAnnotationIds:[],lastSelectedId:null}:e}function xi(e){return{...e,annotations:[],undoStack:[],redoStack:[],selectedAnnotationIds:[],lastSelectedId:null,textModifications:[],domModifications:[],spacingTokenChanges:[],spacingTokenMods:[]}}function wi(e,t){let{selector:o,element:i,property:n,original:r,modified:a}=t,l=typeof window<"u"?window.location.pathname:"/",d=e.styleModifications.findIndex(s=>s.selector===o&&(!s.pathname||s.pathname===l));if(r===a&&d<0)return e;if(d>=0){let s=e.styleModifications[d];if(s.captured){let y=_(e),m=y.styleModifications.map((g,k)=>k===d?{...g,changes:[{property:n,original:r,modified:a}],createdAt:g.createdAt??Date.now(),captured:!1,pathname:l}:g);return{...y,styleModifications:m}}let c=s.changes.findIndex(y=>y.property===n),h,u=e;if(c>=0){let y=s.changes[c];a===y.original?h=s.changes.filter((m,g)=>g!==c):h=s.changes.map((m,g)=>g===c?{...m,modified:a}:m)}else{if(r===a)return e;u=_(e),h=[...s.changes,{property:n,original:r,modified:a}]}if(h.length===0)return{...u,styleModifications:u.styleModifications.filter((y,m)=>m!==d)};let f=u.styleModifications.map((y,m)=>m===d?{...y,changes:h,createdAt:y.createdAt??Date.now()}:y);return{...u,styleModifications:f}}else{let s=_(e),c={selector:o,element:i,changes:[{property:n,original:r,modified:a}],createdAt:Date.now(),pathname:l};return{...s,styleModifications:[...s.styleModifications,c]}}}function vi(e,t){let{selector:o,durableSelector:i,element:n,changes:r}=t,a=typeof window<"u"?window.location.pathname:"/",l=r.filter(c=>c.original!==c.modified);if(l.length===0)return e;let d=_(e),s=d.styleModifications.findIndex(c=>c.selector===o&&(!c.pathname||c.pathname===a));if(s>=0){let c=d.styleModifications[s],h=c.captured?[]:[...c.changes];for(let u of l){let f=h.findIndex(y=>y.property===u.property);f>=0?u.modified===h[f].original?h=h.filter((y,m)=>m!==f):h=h.map((y,m)=>m===f?{...y,modified:u.modified,token:u.token,sticker:u.sticker}:y):h.push(u)}return h.length===0?{...d,styleModifications:d.styleModifications.filter((u,f)=>f!==s)}:{...d,styleModifications:d.styleModifications.map((u,f)=>f===s?{...u,changes:h,createdAt:u.createdAt??Date.now(),captured:!1,pathname:a}:u)}}else return{...d,styleModifications:[...d.styleModifications,{selector:o,durableSelector:i,element:n,changes:l,createdAt:Date.now(),pathname:a}]}}function bi(e,t){let{selector:o,property:i}=t,n=typeof window<"u"?window.location.pathname:"/",r=_(e),a=r.styleModifications.map(l=>l.selector!==o||l.pathname&&l.pathname!==n?l:{...l,changes:l.changes.filter(d=>d.property!==i)}).filter(l=>l.changes.length>0);return{...r,styleModifications:a}}function Mi(e,t){let{selector:o,sticker:i}=t,n=typeof window<"u"?window.location.pathname:"/";if(!e.styleModifications.find(l=>l.selector===o&&(!l.pathname||l.pathname===n)&&!l.captured&&l.changes.some(d=>d.sticker?.family===i.family&&d.sticker.subproperty===i.subproperty)))return e;let r=_(e),a=r.styleModifications.map(l=>l.selector!==o||l.pathname&&l.pathname!==n||l.captured?l:{...l,changes:l.changes.filter(d=>d.sticker?.family!==i.family||d.sticker.subproperty!==i.subproperty)}).filter(l=>l.changes.length>0);return{...r,styleModifications:a}}function Si(e){return e.styleModifications.length===0?e:{..._(e),styleModifications:[]}}function Ti(e,t){let o=new Set(t.selectors);if(o.size===0)return e;let i=e.styleModifications.filter(n=>!n.captured||!o.has(n.selector)&&(!n.durableSelector||!o.has(n.durableSelector)));return i.length===e.styleModifications.length?e:{...e,styleModifications:i}}function Ii(e,t){let o=Date.now();return{...e,styleModifications:t.map((i,n)=>({...i,createdAt:i.createdAt??o+n}))}}function ki(e,t,o,i){return e.selector===t&&(!e.pathname||e.pathname===i)&&e.textNodePath.length===o.length&&e.textNodePath.every((n,r)=>n===o[r])}function rn(e,t,o=!0){let{selector:i,durableSelector:n,element:r,textNodePath:a,original:l,modified:d}=t,s=typeof window<"u"?window.location.pathname:"/",c=e.textModifications.findIndex(u=>ki(u,i,a,s));if(l===d&&c<0)return e;if(c>=0){let u=e.textModifications[c],f=u.captured&&o?_(e):e,y=u.captured?l:u.original;return d===y?{...f,textModifications:f.textModifications.filter((m,g)=>g!==c)}:{...f,textModifications:f.textModifications.map((m,g)=>g===c?{...m,durableSelector:n,element:r,original:y,modified:d,createdAt:m.createdAt??Date.now(),captured:!1,pathname:s}:m)}}let h=o?_(e):e;return{...h,textModifications:[...h.textModifications,{selector:i,durableSelector:n,element:r,textNodePath:a,original:l,modified:d,createdAt:Date.now(),pathname:s}]}}function Ei(e,t,o=!0){return t.length===0?e:t.reduce((i,n)=>rn(i,n,!1),o?_(e):e)}function Ci(e,t){let o=Date.now();return{...e,textModifications:t.map((i,n)=>({...i,createdAt:i.createdAt??o+n}))}}function Ai(e,t){let o=_(e),i=o.domModifications.findIndex(n=>n.id===t.id);return i>=0?{...o,domModifications:o.domModifications.map((n,r)=>r===i?{...t,captured:!1}:n)}:{...o,domModifications:[...o.domModifications,t]}}function Ri(e,t){return{...e,domModifications:t}}function Ni(e,t){let{updates:o}=t,i=new Map(o.map(n=>[n.id,n]));return{...e,annotations:e.annotations.map(n=>{let r=i.get(n.id);return r?{...n,points:[r.point,...n.points.slice(1)],...r.linkedAnchor?{linkedAnchor:r.linkedAnchor}:{}}:n})}}function Li(e,t){let o=new Set(t.ids);return{...e,annotations:e.annotations.map(i=>o.has(i.id)?{...i,status:t.status}:i)}}function Di(e,t){let o=new Set(t.ids),i=new Set;for(let n of e.annotations)o.has(n.id)&&n.groupId&&i.add(n.groupId);return{...e,annotations:e.annotations.map(n=>{if(!o.has(n.id)&&!(n.groupId&&i.has(n.groupId)))return n;let r=!!t.jobId&&n.replyJobIds?.includes(t.jobId),a=n.status==="waiting_input";return{...n,status:a?"waiting_input":"resolved",replyCount:(n.replyCount??0)+(r?0:1),replyJobIds:t.jobId&&!r?[...n.replyJobIds??[],t.jobId]:n.replyJobIds,threadId:n.threadId||t.threadId,question:a?n.question:void 0}})}}function Oi(e,t){let o=new Set(t.ids),i=new Set;for(let n of e.annotations)o.has(n.id)&&n.groupId&&i.add(n.groupId);return{...e,annotations:e.annotations.map(n=>o.has(n.id)||n.groupId&&i.has(n.groupId)?{...n,status:"failed",threadId:n.threadId||t.threadId,question:void 0}:n)}}function $i(e,t){let o=new Set(t.ids),i=new Set;for(let n of e.annotations)o.has(n.id)&&n.groupId&&i.add(n.groupId);return{...e,annotations:e.annotations.map(n=>o.has(n.id)||n.groupId&&i.has(n.groupId)?{...n,threadId:t.threadId,targetBindingId:t.targetBindingId}:n)}}function _i(e,t){let o=new Set(t.ids),i=new Set;for(let n of e.annotations)o.has(n.id)&&n.groupId&&i.add(n.groupId);return{...e,annotations:e.annotations.map(n=>o.has(n.id)||n.groupId&&i.has(n.groupId)?{...n,status:"waiting_input",question:t.question,threadId:t.threadId}:n)}}function Fi(e,t){let o=new Map(t.resolutions.map(n=>[n.annotationId,n])),i=new Map;for(let n of e.annotations){let r=o.get(n.id);r&&n.groupId&&i.set(n.groupId,r)}return{...e,annotations:e.annotations.map(n=>{let r=o.get(n.id)||(n.groupId?i.get(n.groupId):void 0);if(!r)return n;let a=!!t.jobId&&n.replyJobIds?.includes(t.jobId);return{...n,status:r.status,resolutionSummary:r.summary,scope:r.finalScope??r.inferredScope??null,replyCount:(n.replyCount??0)+(a?0:1),replyJobIds:t.jobId&&!a?[...n.replyJobIds??[],t.jobId]:n.replyJobIds,question:void 0,threadId:n.threadId||t.threadId}})}}function Pi(e,t){let{linkedSelectors:o,styleSelectors:i}=t,n=new Set(o),r=new Set(i),a=typeof window<"u"?window.location.pathname:"/",l=new Set,d=new Set;for(let f of e.annotations)f.linkedSelector&&n.has(f.linkedSelector)&&(l.add(f.id),f.groupId&&d.add(f.groupId));for(let f of e.annotations)f.groupId&&d.has(f.groupId)&&l.add(f.id);let s=e.annotations.filter(f=>!l.has(f.id)),c=e.styleModifications.filter(f=>!r.has(f.selector)||f.pathname&&f.pathname!==a),h=e.domModifications.filter(f=>!r.has(f.selector)||f.pathname&&f.pathname!==a);if(s.length===e.annotations.length&&c.length===e.styleModifications.length&&h.length===e.domModifications.length)return e;let u=e.selectedAnnotationIds.filter(f=>!l.has(f));return{...e,annotations:s,styleModifications:c,domModifications:h,selectedAnnotationIds:u,lastSelectedId:u.length>0?u[u.length-1]:null}}function zi(e,t){let o=e.spacingTokenChanges.findIndex(i=>i.tokenPath===t.tokenPath);return o>=0?{...e,spacingTokenChanges:e.spacingTokenChanges.map((i,n)=>n===o?t:i)}:{...e,spacingTokenChanges:[...e.spacingTokenChanges,t]}}function Bi(e,t){return{...e,spacingTokenChanges:t}}function Hi(e,t){let o=_(e),i=e.spacingTokenMods.findIndex(r=>r.tokenPath===t.tokenPath),n;if(i>=0){let r=e.spacingTokenMods[i],a={...t,originalValue:r.captured?r.currentValue:r.originalValue,originalPx:r.captured?r.currentPx:r.originalPx,captured:!1};n=e.spacingTokenMods.map((l,d)=>d===i?a:l)}else n=[...e.spacingTokenMods,{...t,captured:!1}];return{...o,spacingTokenMods:n}}function Wi(e,t){let o=_(e),i=e.spacingTokenMods.findIndex(s=>s.tokenPath===t.tokenPath),n=i>=0?e.spacingTokenMods[i]:null,r=i>=0?n.captured?n.currentValue:n.originalValue:t.originalValue,a=i>=0?n.captured?n.currentPx:n.originalPx:parseFloat(t.originalValue)||0,l={tokenPath:t.tokenPath,originalValue:r,currentValue:"__deleted__",targets:n?.targets??[],originalPx:a,currentPx:0,captured:!1},d;return i>=0?d=e.spacingTokenMods.map((s,c)=>c===i?l:s):d=[...e.spacingTokenMods,l],{...o,spacingTokenMods:d}}function ln(e,t){switch(t.type){case"SET_ANNOTATING":return Jo(e,t.payload);case"SET_TOOL":return Zo(e,t.payload);case"SET_COLOR":return ei(e,t.payload);case"SET_STROKE_WIDTH":return ti(e,t.payload);case"ADD_TEXT":return ni(e,t.payload);case"UPDATE_TEXT":return oi(e,t.payload);case"CLEAR_INTERACTION_EPISODE":return ii(e,t.payload);case"DELETE_ANNOTATION":return ai(e,t.payload);case"MOVE_ANNOTATION":return ri(e,t.payload);case"RESIZE_ANNOTATION":return li(e,t.payload);case"PASTE_ANNOTATIONS":return di(e,t.payload);case"RESTORE_ANNOTATIONS":return si(e,t.payload);case"SYNC_ANNOTATIONS":return pi(e,t.payload);case"MERGE_ANNOTATIONS":return ci(e,t.payload);case"UNDO":return ui(e);case"REDO":return fi(e);case"SELECT_ANNOTATION":return hi(e,t.payload);case"UPDATE_ANNOTATION_COLOR":return gi(e,t.payload);case"MARK_CAPTURED":return mi(e,t.payload?.annotationIds);case"CLEAR":return xi(e);case"DISCARD_DRAFT":return yi(e);case"MODIFY_STYLE":return wi(e,t.payload);case"MODIFY_STYLES_BATCH":return vi(e,t.payload);case"CLEAR_STYLE":return bi(e,t.payload);case"CLEAR_STICKER":return Mi(e,t.payload);case"CLEAR_ALL_STYLES":return Si(e);case"SETTLE_CAPTURED_STYLES":return Ti(e,t.payload);case"RESTORE_STYLE_MODIFICATIONS":return Ii(e,t.payload);case"MODIFY_TEXT_CONTENT":return rn(e,t.payload);case"MODIFY_TEXT_CONTENTS":return Ei(e,t.payload,t.saveUndo??!0);case"RESTORE_TEXT_MODIFICATIONS":return Ci(e,t.payload);case"MODIFY_DOM_STRUCTURE":return Ai(e,t.payload);case"RESTORE_DOM_MODIFICATIONS":return Ri(e,t.payload);case"UPDATE_LINKED_POSITIONS":return Ni(e,t.payload);case"CLEANUP_ORPHANED":return Pi(e,t.payload);case"SET_ANNOTATION_STATUS":return Li(e,t.payload);case"MARK_ANNOTATIONS_REPLIED":return Di(e,t.payload);case"MARK_ANNOTATIONS_FAILED":return Oi(e,t.payload);case"SET_ANNOTATION_THREAD":return $i(e,t.payload);case"SET_ANNOTATION_QUESTION":return _i(e,t.payload);case"APPLY_RESOLUTIONS":return Fi(e,t.payload);case"ADD_SPACING_TOKEN_CHANGE":return zi(e,t.payload);case"RESTORE_SPACING_TOKEN_CHANGES":return Bi(e,t.payload);case"MODIFY_SPACING_TOKEN":return Hi(e,t.payload);case"DELETE_SPACING_TOKEN":return Wi(e,t.payload);default:return t}}function ji(e,t){let o=de(on),[i,n]=Yn(ln,kn),r=qn(o?.subscribe??Go,o?.getSnapshot??an,o?.getSnapshot??an)??i,a=o?.dispatch??n;Q(()=>{if(!r.isAnnotating)return;let d=s=>{t?.current||s.defaultPrevented||s.isComposing||s.altKey||s.composedPath().some(c=>c instanceof Element&&(c.matches('input, textarea, select, [role="textbox"]')||c instanceof HTMLElement&&c.isContentEditable||c.hasAttribute("contenteditable")&&c.getAttribute("contenteditable")!=="false"))||(s.metaKey||s.ctrlKey)&&s.key.toLowerCase()===$e.actions.undo.key&&(s.preventDefault(),s.shiftKey?a({type:"REDO"}):e?.current?.()||a({type:"UNDO"}))};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[a,r.isAnnotating,e,t]);let l=o?.getUndoHead?o.getUndoHead():r.undoStack.at(-1);return[r,a,l]}function ue(e){return e?!!e.closest("#devtools-toolbar, #devtools-scrim, #devtools-text-input, [data-devtools], [data-popmelt-panel], [data-popmelt-shadow-host]"):!1}function Yi(e,t,o=document){let i=o,n=i.caretPositionFromPoint?.(e,t);if(n?.offsetNode?.nodeType===Node.TEXT_NODE)return n.offsetNode;let r=i.caretRangeFromPoint?.(e,t);return r?.startContainer?.nodeType===Node.TEXT_NODE?r.startContainer:null}function qi(e,t){if(!e)return t();let o=e.style.pointerEvents;e.style.pointerEvents="none";try{return t()}finally{e.style.pointerEvents=o}}function Ki(e,t,o){let i=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode(r){return r.textContent?.trim()?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}}),n=i.nextNode();for(;n;){let r=n,a=e.ownerDocument.createRange();a.selectNodeContents(r);let l=Array.from(a.getClientRects());if(a.detach?.(),l.some(d=>t>=d.left&&t<=d.right&&o>=d.top&&o<=d.bottom))return r;n=i.nextNode()}return null}function Xi(e,t,o){return qi(o,()=>{let i=bt(e,t);if(!i||ue(i))return null;let n=i?.ownerDocument??document,r=Dn(e,t,n),a=Yi(r.x,r.y,n);if(a&&!i.contains(a)&&(a=null),!a){let b=i;b&&!ue(b)&&(a=Ki(b,r.x,r.y))}if(!a||!On(a.parentElement))return null;let l=a.parentElement;if(ue(l))return null;for(;l.parentElement&&l!==n.body;){let b=Ae(l).getComputedStyle(l).display,C=b==="inline-block"&&l.childNodes.length===1&&l.firstChild?.nodeType===Node.ELEMENT_NODE;if(b!=="inline"&&b!=="contents"&&!C)break;let N=l.parentElement;if(ue(N))break;if(Array.from(N.childNodes).some(I=>I.nodeType===Node.TEXT_NODE&&!!I.nodeValue?.trim())){l=N;continue}let z=Ae(N).getComputedStyle(N).display,A=z==="inline-block"&&N.childNodes.length===1&&N.firstChild?.nodeType===Node.ELEMENT_NODE;if(z==="inline"||z==="contents"||A){l=N;continue}break}let d=l.tagName.toLowerCase();if(d==="script"||d==="style"||d==="textarea"||d==="input")return null;let s=Vi(l),c=s.map(b=>b.originalText).join("");if(!c.trim())return null;let h=dn(l,a);if(!h)return null;let u=Ae(l).getComputedStyle(l),f=pn(s,l,u),{textRect:y,boundaryRect:m,boundaryRects:g,flowRect:k,firstLineIndent:w}=f;if(y.width<=0||y.height<=0)return null;let v=parseFloat(u.fontSize)||12,S=u.whiteSpace!=="nowrap"&&u.whiteSpace!=="pre"&&(Ji(a)||u.display!=="inline");return{textNode:a,targetElement:l,textNodePath:h,segments:s,originalText:c,rect:y,boundaryRect:m,boundaryRects:g,flowRect:k,firstLineIndent:w,styles:u,fontSize:v,wrapsText:S}})}function dn(e,t){let o=[],i=t;for(;i&&i!==e;){let n=i.parentNode;if(!n)return null;o.unshift(Array.prototype.indexOf.call(n.childNodes,i)),i=n}return i===e?o:null}function Ui(e,t){let o=e.ownerDocument.createRange();o.selectNodeContents(e);let i=Ce(o.getBoundingClientRect(),e.ownerDocument);if(o.detach?.(),i.width>0&&i.height>0)return{left:i.left,top:i.top,width:i.width,height:i.height};let n=Ee(t);return{left:n.left,top:n.top,width:n.width,height:n.height}}function Vi(e){let t=[],o=i=>{if(i.nodeType===Node.TEXT_NODE){let r=i,a=dn(e,r);a&&t.push({textNode:r,textNodePath:a,originalText:r.nodeValue??""});return}if(i.nodeType!==Node.ELEMENT_NODE&&i!==e)return;let n=i.tagName?.toLowerCase();n==="script"||n==="style"||i.childNodes.forEach(o)};return e.childNodes.forEach(o),t}function sn(e){return{left:e.left,top:e.top,width:e.width,height:e.height}}function Qi(e){let t=[];for(let o of e){if(!o.textNode.isConnected||!o.originalText.trim())continue;let i=o.textNode.ownerDocument.createRange();i.selectNodeContents(o.textNode),t.push(...Array.from(i.getClientRects()).filter(n=>n.width>0&&n.height>0).map(n=>sn(Ce(n,o.textNode.ownerDocument)))),i.detach?.()}return Ge(t)}function Gi(e){let t=e.getBoundingClientRect(),o=Ae(e).getComputedStyle(e),i=(parseFloat(o.borderLeftWidth)||0)+(parseFloat(o.paddingLeft)||0),n=(parseFloat(o.borderRightWidth)||0)+(parseFloat(o.paddingRight)||0),r=(parseFloat(o.borderTopWidth)||0)+(parseFloat(o.paddingTop)||0),a=(parseFloat(o.borderBottomWidth)||0)+(parseFloat(o.paddingBottom)||0);return Ce({left:t.left+i,top:t.top+r,width:Math.max(0,t.width-i-n),height:Math.max(0,t.height-r-a)},e.ownerDocument)}function pn(e,t,o){let i=sn(Ee(t)),n=Qi(e),r=e[0]?.textNode?Ui(e[0].textNode,t):i,a=n.length>0?n:[r];return So({display:o.display,fragmentRects:a,elementRect:i,parentContentRect:t.parentElement?Gi(t.parentElement):void 0})}function Ji(e){let t=e.ownerDocument.createRange();t.selectNodeContents(e);let o=Array.from(t.getClientRects()).filter(i=>i.width>0&&i.height>0).length;return t.detach?.(),o>1}function Zi(e,t,o){if(t===o||e.length===0)return[];let i=0;for(;i<t.length&&i<o.length&&t[i]===o[i];)i+=1;let n=0;for(;n<t.length-i&&n<o.length-i&&t[t.length-1-n]===o[o.length-1-n];)n+=1;let r=i,a=t.length-n,l=o.slice(i,o.length-n),d=0,s=!1;return e.flatMap((c,h)=>{let u=d,f=u+c.originalText.length;d=f;let y=r===a,m=y&&(r>=u&&r<f||h===e.length-1&&r===f),g=!y&&f>r&&u<a;if(!m&&!g)return[];let k=Math.max(0,Math.min(c.originalText.length,r-u)),w=Math.max(0,Math.min(c.originalText.length,a-u)),v=c.originalText.slice(0,k);return s||(v+=l,s=!0),v+=c.originalText.slice(w),v===c.originalText?[]:[{segment:c,modifiedText:v}]})}function st(e,t){return Math.abs(e.left-t.left)<.5&&Math.abs(e.top-t.top)<.5&&Math.abs(e.width-t.width)<.5&&Math.abs(e.height-t.height)<.5}function ea(e,t){return!e||!t?e===t:st(e,t)}function ta(e,t){return e.length===t.length&&e.every((o,i)=>st(o,t[i]))}function na(){return{isDragging:!1,hasMoved:!1,mode:"move",startX:0,startY:0,element:null,originalParent:null,originalIndex:-1,selector:null,durableSelector:null,elementInfo:null}}function Fe(e){if(!e||e===document.body||e===document.documentElement||ue(e))return!1;let t=e.tagName.toLowerCase();return["script","style","link","meta","head","html","body","input","textarea","select","option","button"].includes(t)?!1:!!e.parentElement}function J(e){let t=e.getAttribute("data-pm");return t||(t=Math.random().toString(36).substring(2,8),e.setAttribute("data-pm",t)),`[data-pm="${t}"]`}function pt(e){return e.parentElement?Array.from(e.parentElement.children).indexOf(e):-1}function cn(e){e.removeAttribute("data-pm"),e.querySelectorAll("[data-pm]").forEach(t=>t.removeAttribute("data-pm"))}function un(e,t,o,i,n=bt){let r=o.parentElement;if(!r)return null;let a=n(e,t);for(;a&&a!==document.body;){if(a===o||o.contains(a)){a=a.parentElement;continue}if(a.parentElement===r&&Fe(a))break;a=a.parentElement}if(!a||a===document.body||a.parentElement!==r||a===i)return null;let l=a.getBoundingClientRect(),d=l.height>=l.width?t<l.top+l.height/2?"before":"after":e<l.left+l.width/2?"before":"after",s=pt(a),c=d==="before"?s:s+1;return{parent:r,reference:a,placement:d,index:c}}function ct(e,t,o){let i=Array.from(e.children).filter(r=>r!==t),n=Math.max(0,Math.min(o,i.length));e.insertBefore(t,i[n]??null)}function oa({drag:e,clientX:t,clientY:o,pathname:i,createId:n,rootElement:r,elementAtPoint:a}){let l=e.element;if(!l||!e.selector||!e.durableSelector||!e.elementInfo)return null;let d=un(t,o,l,r,a);if(!d)return null;let s=e.originalParent===d.parent&&d.index>e.originalIndex?d.index-1:d.index;if(e.mode==="move"&&e.originalParent===d.parent&&(s===e.originalIndex||s===e.originalIndex+1))return null;let c=V(d.parent),h=J(d.parent),u=V(d.reference),f=J(d.reference),y=e.selector,m=e.durableSelector,g=e.elementInfo;if(e.mode==="copy"){let w=l.cloneNode(!0);if(!(w instanceof Element))return null;cn(w),ct(d.parent,w,s),y=J(w),m=V(w),g={...We(w),selector:y}}else ct(d.parent,l,s);let k=e.originalParent;return{id:n(),operation:e.mode,selector:y,durableSelector:m,element:g,sourceSelector:e.mode==="copy"?e.selector:void 0,sourceDurableSelector:e.mode==="copy"?e.durableSelector:void 0,sourceElement:e.mode==="copy"?e.elementInfo:void 0,originalParentSelector:k?J(k):void 0,originalParentDurableSelector:k?V(k):void 0,originalIndex:e.originalIndex,targetParentSelector:h,targetParentDurableSelector:c,targetIndex:s,referenceSelector:f,referenceDurableSelector:u,placement:d.placement,pathname:i}}function fn(e){return e instanceof HTMLElement&&(e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.isContentEditable===!0||e.getAttribute("contenteditable")==="true")}function ia(){if(typeof document>"u")return null;let e=document.activeElement;for(;e?.shadowRoot?.activeElement;)e=e.shadowRoot.activeElement;return e}function ut(e){let t=e.composedPath?.()[0]??e.target;return fn(t)||fn(ia())}function hn(e,t,o){if(o)return[o];let i=new Set(t),n=new Map;for(let a of e)a.groupId&&a.threadId&&n.set(a.groupId,a.threadId);let r=new Set;for(let a of e){if(!i.has(a.id))continue;let l=a.threadId||(a.groupId?n.get(a.groupId):void 0);l&&r.add(l)}return[...r]}function aa({state:e,stateRef:t,activeTextRef:o,selectedIdsRef:i,dispatch:n,clearSelection:r,selectAnnotation:a,handHoveredElement:l,onArchiveThread:d,openThreadId:s,currentPathname:c,hasOpenThread:h}){let u=le([]),f=le(0),y=le(null);Q(()=>{let m=g=>{if(g.key==="Escape"){if(g.defaultPrevented||g.repeat||o.current||h||ut(g))return;if(i.current.length>0){g.preventDefault(),r();return}let w=t.current;if(w.annotations.some(v=>(v.status??"pending")==="pending")||w.styleModifications.some(v=>!v.captured)||w.textModifications.some(v=>!v.captured)||w.domModifications.some(v=>!v.captured)||w.spacingTokenChanges.some(v=>!v.captured)||w.spacingTokenMods.some(v=>!v.captured)){g.preventDefault(),n({type:"DISCARD_DRAFT"});return}}if((g.metaKey||g.ctrlKey)&&g.key.toLowerCase()==="c"&&e.activeTool==="hand"&&l&&!o.current){if(Fe(l)){g.preventDefault();let w=J(l);y.current={source:l,sourceSelector:w,sourceDurableSelector:V(l),sourceElement:{...We(l),selector:w}}}return}if((g.metaKey||g.ctrlKey)&&g.key.toLowerCase()==="v"&&e.activeTool==="hand"&&y.current&&!o.current){let w=y.current,v=l&&Fe(l)?l:w.source,S=v.parentElement;if(S){g.preventDefault();let b=V(S),C=J(S),N=V(v),z=J(v),A=pt(v)+1,I=w.source.cloneNode(!0);if(I instanceof Element){cn(I),ct(S,I,A);let U=J(I),oe=V(I),ie={...We(I),selector:U};n({type:"MODIFY_DOM_STRUCTURE",payload:{id:dt(),operation:"copy",selector:U,durableSelector:oe,element:ie,sourceSelector:w.sourceSelector,sourceDurableSelector:w.sourceDurableSelector,sourceElement:w.sourceElement,targetParentSelector:C,targetParentDurableSelector:b,targetIndex:A,referenceSelector:z,referenceDurableSelector:N,placement:"after",pathname:c}})}}return}if((g.metaKey||g.ctrlKey)&&g.key==="v"&&u.current.length>0&&!o.current){g.preventDefault(),f.current+=1;let w=f.current*20,v=u.current[0]?.groupId?Math.random().toString(36).substring(2,9):void 0,S=u.current.map(C=>({...C,id:Math.random().toString(36).substring(2,9),groupId:C.groupId?v:void 0,timestamp:Date.now(),points:C.points.map(N=>({x:N.x+w,y:N.y+w}))}));n({type:"PASTE_ANNOTATIONS",payload:{annotations:S}});let b=S.find(C=>C.type!=="text")??S[0];b&&a(b.id);return}let k=i.current;if(!o.current&&!ut(g)&&(g.key==="Delete"||g.key==="Backspace")&&!g.metaKey&&!g.ctrlKey&&!g.altKey){if(k.length===0&&!s)return;let w=hn(t.current.annotations,k,s);if(!d||w.length===0)return;g.preventDefault();for(let v of w)d(v);r()}};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[o,r,c,n,l,h,d,s,a,i,e.activeTool,t])}export{Io as $,ue as A,Wo as Aa,Xi as B,jo as Ba,pn as C,Yo as Ca,Zi as D,Xo as Da,st as E,ea as F,ta as G,na as H,Fe as I,J,pt as K,un as L,oa as M,ut as N,hn as O,aa as P,Xe as Q,xe as R,Ue as S,yo as T,xo as U,wo as V,vo as W,bo as X,Ot as Y,$t as Z,Pt as _,$e as a,ve as aa,Uo as b,Ze as ba,Vo as c,Eo as ca,Qo as d,ne as da,on as e,nt as ea,dt as f,Wt as fa,ln as g,ot as ga,ji as h,jt as ha,Kn as i,Yt as ia,Xn as j,Ro as ja,Vn as k,No as ka,Jn as l,qt as la,Zn as m,Kt as ma,eo as n,it as na,to as o,at as oa,ao as p,be as pa,ro as q,Lo as qa,lo as r,rt as ra,po as s,pe as sa,co as t,G as ta,uo as u,Vt as ua,fo as v,Qt as va,Dt as w,Jt as wa,ho as x,Zt as xa,go as y,en as ya,mo as z,Ho as za};
|