@popmelt.com/core 0.31.0 → 0.31.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/claude-plugin/.claude-plugin/plugin.json +1 -1
- package/codex-plugin/.codex-plugin/plugin.json +1 -1
- package/dist/{ParticipantRuntime-PPIOE3NJ.mjs → ParticipantRuntime-HU2P2PJ6.mjs} +1 -1
- package/dist/{PopmeltTasteConnectedPane-4WRVLYUV.mjs → PopmeltTasteConnectedPane-ALR3RTSC.mjs} +1 -1
- package/dist/{PreviewRuntime-JAZLAGQE.mjs → PreviewRuntime-YAUBP6HA.mjs} +1 -1
- package/dist/bridge-entry.mjs +1 -1
- package/dist/{browser-runtime-OZCPXHEN.mjs → browser-runtime-LTQBOXZW.mjs} +1 -1
- package/dist/browser.mjs +1 -1
- package/dist/chunk-253MCKJJ.mjs +62 -0
- package/dist/chunk-4V7SK3M6.mjs +0 -0
- package/dist/{chunk-SWTSMLHA.mjs → chunk-4ZZTJRHL.mjs} +1 -1
- package/dist/{chunk-G25T4PMF.mjs → chunk-CECQ4VMR.mjs} +1 -1
- package/dist/{chunk-PBQCGGJL.mjs → chunk-CXQWNKZ4.mjs} +14 -14
- package/dist/{chunk-A7DRONSB.mjs → chunk-E3ZTB2VR.mjs} +1 -1
- package/dist/{chunk-F3S6L45N.mjs → chunk-EG6SRS7N.mjs} +1 -1
- package/dist/{chunk-NE263MLG.mjs → chunk-GQ6CPJG6.mjs} +1 -1
- package/dist/{chunk-YM6BOUNF.mjs → chunk-IRFL32GJ.mjs} +3 -3
- package/dist/{chunk-4AEU4OCH.mjs → chunk-LSPIP2IX.mjs} +1 -1
- package/dist/chunk-OLLUQ45J.mjs +2 -0
- package/dist/{chunk-DPU2WFIZ.mjs → chunk-WIQ3RY6R.mjs} +1 -1
- package/dist/cli.mjs +2 -2
- package/dist/codex-note-context-NVDO3PVT.mjs +2 -0
- package/dist/{codex-project-3OAJJ7ZI.mjs → codex-project-IE6ZJFGB.mjs} +1 -1
- package/dist/codex-session-registry-25DAA2KO.mjs +0 -0
- package/dist/index.mjs +1 -1
- package/dist/peer-client-2THOHRGA.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/package.json +22 -32
- package/dist/chunk-MP7S5ALD.mjs +0 -2
- package/dist/chunk-UU5ISCUC.mjs +0 -62
- package/dist/codex-note-context-MKZ7WCS7.mjs +0 -2
- package/dist/peer-client-WF35M2Y4.mjs +0 -2
- /package/dist/{chunk-MINAH2EM.mjs → chunk-V6VQACC2.mjs} +0 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{c as He,b as En}from"./chunk-4LHTPRFY.mjs";import{a as Cn}from"./chunk-OLLUQ45J.mjs";import{j as St,a as Q,f as An,i as We,g as Rn,h as It}from"./chunk-XOGBFVWI.mjs";import{b as je,g as Ye,e as qe}from"./chunk-V44RIEET.mjs";import{a as Nn,b as Ln}from"./chunk-LVEMYZOA.mjs";import{a as Mt,d as Ee,v as On,h as Dn,i as Tt,c as Ce,f as Ae,b as kt,e as $n,g as _n}from"./chunk-HGW2U6PD.mjs";import{Clock as Et,OctagonAlert as Fn,MessageCircleQuestionMark as Pn,TriangleAlert as zn,Reply as Bn,Eye as Hn,SendHorizontal as Re,CornerDownLeft as Wn}from"lucide-react";import{createContext as Ke,useContext as de,useState as re,useEffect as V,useLayoutEffect as Ct,useId as jn,useRef as le,useMemo as Yn,useCallback as qn,useReducer as Kn,useSyncExternalStore as Un}from"react";import{jsxs as R,jsx as x,Fragment as W}from"react/jsx-runtime";var Ne=new Set,Le;function Ue(e){if(Ne.add(e),!Le){let t=new Map,n=new Map,i="",o=!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&&(o=!0),w.some(v=>v.type==="childList")&&(r=!0)});m.observe(y,{subtree:!0,childList:!0,characterData:!0,attributes:!0});let g=()=>{o=!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=kt(m);u.set(m,g),g&&f(g)}};f(document);for(let[y,m]of t)h.has(y)||(m(),t.delete(y));n=u,r=!1,o=!0},c=()=>{if(!l)return;(r||[...n].some(([f,y])=>kt(f)!==y))&&s();let h=[];for(let[f,y]of n){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((o||u!==i)&&(o=!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 Xe(e,t){let n=e.match(/^oklch\(([^)]+)\)$/i);if(n)return`oklch(${n[1]} / ${t})`;let i=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(i){let o=parseInt(i[1],16),r=parseInt(i[2],16),a=parseInt(i[3],16);return`rgba(${o}, ${r}, ${a}, ${t})`}return`color-mix(in srgb, ${e} ${Math.round(t*100)}%, transparent)`}function At(e,t){let n=Rn(e),i=t.toLowerCase(),o=-1;for(let r=n.length-1;r>=0;r--){let a=n[r].name;if(a===t){let l=It(n[r].fiber)??e;return{name:t,path:n.map(d=>d.name),depthIndex:r,rootElement:l}}if(o===-1){let l=a.toLowerCase();(l.length>=4&&i.includes(l)||i.length>=4&&l.includes(i))&&(o=r)}}if(o>=0){let r=It(n[o].fiber)??e;return{name:t,path:n.map(a=>a.name),depthIndex:o,rootElement:r}}return null}function Xn(e){let t=Oe(),n=[],i=new Set,o=t.currentNode;for(;o=t.nextNode();){let r=At(o,e);r&&!i.has(r.rootElement)&&(i.add(r.rootElement),n.push(r))}return n}function Qn(e){let t=new Map;if(e.size===0)return t;let n=new Set(e),i=Oe(),o=new Set,r=i.currentNode;for(;(r=i.nextNode())&&n.size>0;)for(let a of n){let l=At(r,a);if(!l||o.has(l.rootElement))continue;o.add(l.rootElement);let d=l.rootElement.getBoundingClientRect();t.set(a,d.top+window.scrollY),n.delete(a);break}for(let a of n)t.set(a,1/0);return t}function Oe(){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 Vn(e,t=30){if(e<=0)return[];let n=[],i=Oe(),o=.5,r=i.currentNode;for(;(r=i.nextNode())&&n.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)<o&&n.push({element:a,property:"padding-top"}),!q(a,"padding-bottom")&&Math.abs((parseFloat(d.paddingBottom)||0)-e)<o&&n.length<t&&n.push({element:a,property:"padding-bottom"}),!q(a,"padding-left")&&Math.abs((parseFloat(d.paddingLeft)||0)-e)<o&&n.length<t&&n.push({element:a,property:"padding-left"}),!q(a,"padding-right")&&Math.abs((parseFloat(d.paddingRight)||0)-e)<o&&n.length<t&&n.push({element:a,property:"padding-right"}),!q(a,"margin-top")&&Math.abs((parseFloat(d.marginTop)||0)-e)<o&&n.length<t&&n.push({element:a,property:"margin-top"}),!q(a,"margin-bottom")&&Math.abs((parseFloat(d.marginBottom)||0)-e)<o&&n.length<t&&n.push({element:a,property:"margin-bottom"}),!q(a,"margin-left")&&Math.abs((parseFloat(d.marginLeft)||0)-e)<o&&n.length<t&&n.push({element:a,property:"margin-left"}),!q(a,"margin-right")&&Math.abs((parseFloat(d.marginRight)||0)-e)<o&&n.length<t&&n.push({element:a,property:"margin-right"});let s=d.display;if((s.includes("flex")||s.includes("grid"))&&n.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)<o?n.push({element:a,property:"gap"}):!q(a,"row-gap")&&Math.abs(u-e)<o?n.push({element:a,property:"row-gap"}):!q(a,"column-gap")&&Math.abs(f-e)<o&&n.push({element:a,property:"column-gap"})}}return n}function Gn(e){return typeof e=="string"?{value:e}:e}var Rt={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 Nt(e,t){let n=Rt[t];return n?n.includes(e):!1}function Jn(e,t){let n=e.split(/\s+/);for(let i of n){if(i===t)return!0;let o=i.lastIndexOf(":");if(o>=0&&i.slice(o+1)===t)return!0}return!1}function Zn(e){let t=e.lastIndexOf(":"),n=t>=0?e.slice(t+1):e,i=n.indexOf("-");if(i<0)return null;let o=n.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=n.slice(0,n.indexOf("-",i+1)>0?n.indexOf("-",i+1):i);return r[a]??r[o]??null}function eo(e,t=30){let n=parseFloat(e.value);if(isNaN(n)||n<=0)return[];if(e.bindings&&e.bindings.length>0){let o=[],r=Oe(),a=r.currentNode;for(;(a=r.nextNode())&&o.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(!Jn(s,c))continue;let h=Zn(c);if(h&&!(e.property&&!Nt(h,e.property))){o.push({element:l,property:h});break}}}return o}let i=Vn(n,t*2);return e.property?i.filter(o=>Nt(o.property,e.property)).slice(0,t):i.slice(0,t)}function to(e,t){let n=new Set,i=we(t);for(let o of e){let r=Lt[o.property];if(!r)continue;let a=o.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){n.add(h);break}}}}return[...n]}function no(e){let t=new Set;for(let n of e)for(let[i,o]of Object.entries(Rt))if(o.includes(n.property)){t.add(i);break}if(t.size===1)return[...t][0]}function oo(e,t,n){if(t===n)return e;let i=we(t),o=we(n);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}-${o}`:r})}var io={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 io[e]??`[${e}px]`}var Lt={"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 ao(e,t,n,i){let o=Lt[t];if(!o)return null;let r=we(n);for(let a of o){let l=new RegExp("(?:^|\\s)((?:[\\w-]+:)*"+a+"-(?:"+ro(r)+"|\\["+n+"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 ro(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function lo(e,t,n){let i=new Set,o=[];for(let r of e){let a=Q(r.element),l=`${a}::${r.property}`;if(i.has(l))continue;i.add(l);let d=An(r.element),s=r.element.className||"",c=ao(s,r.property,t,n);o.push({selector:a,reactComponent:d?.name,className:s,property:r.property,matchedClass:c?.matched,suggestedClass:c?.suggested})}return o}function so(e){let t=window.getComputedStyle(e).display;return t==="flex"||t==="inline-flex"||t==="grid"||t==="inline-grid"}function po(e){let t=window.getComputedStyle(e);return{row:parseFloat(t.rowGap)||0,column:parseFloat(t.columnGap)||0}}function co(e){let t=[];for(let n of e){let i=t.find(o=>o.axis!==n.axis?!1:n.axis==="row"?Math.abs(o.y-n.y)<2&&Math.abs(o.h-n.h)<2:Math.abs(o.x-n.x)<2&&Math.abs(o.w-n.w)<2);if(i)if(n.axis==="row"){let o=Math.min(i.x,n.x),r=Math.max(i.x+i.w,n.x+n.w);i.x=o,i.w=r-o}else{let o=Math.min(i.y,n.y),r=Math.max(i.y+i.h,n.y+n.h);i.y=o,i.h=r-o}else t.push({...n})}return t}function uo(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 n=[],i=e.getBoundingClientRect(),o=window.getComputedStyle(e).flexDirection,r=o==="column"||o==="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&&n.push({axis:"column",x:d.right,y:i.top,w:s.left-d.right,h:i.height}),s.top>d.bottom+.5&&n.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;n.push({axis:"row",x:i.left,y:c-a/2,w:i.width,h:a})}else{let c=(d.right+s.left)/2;n.push({axis:"column",x:c-a/2,y:i.top,w:a,h:i.height})}}return co(n)}function fo(e,t){let n=window.getComputedStyle(e),i=n.display;if(i!=="flex"&&i!=="inline-flex")return!1;let o=n.justifyContent;if(o!=="space-between"&&o!=="space-around"&&o!=="space-evenly"&&o!=="stretch")return!1;let r=n.flexDirection;return!(t!==(r==="column"||r==="column-reverse"?"row":"column")||parseFloat(t==="row"?n.rowGap:n.columnGap)>0)}function ho(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 go(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 Ot(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 mo(e){for(let t of e.childNodes)if(t.nodeType===Node.TEXT_NODE&&(t.textContent||"").trim().length>0)return!0;return!1}function yo(e){let t=document.createRange(),n=!1;for(let c of e.childNodes)c.nodeType===Node.TEXT_NODE&&(c.textContent||"").trim().length>0&&(n||(t.setStart(c,0),n=!0),t.setEnd(c,c.textContent?.length??0));if(!n)return null;let i=t.getBoundingClientRect(),o=window.getComputedStyle(e),r=parseFloat(o.fontSize)||16,a=parseFloat(o.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 xo(e){let t=window.getComputedStyle(e),n=parseFloat(t.fontSize)||16,i=parseFloat(t.lineHeight);return isNaN(i)&&(i=n*1.2),{fontSize:n,lineHeight:i}}function wo(e){let t=e.startsWith("top-");return{top:t?4:12,right:4,bottom:t?12:4,left:4}}function vo({hasCommentEntry:e,stagedChangeCount:t}){return e&&t===0?2:6}function bo({annotationNumber:e,stickerCount:t,interactionEpisodeStepCount:n,hasStatus:i,hasSend:o,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=n>0?32+String(n).length*7.2:0,s=28,c=t>0?l+(d>0?d-2:0)+(o?s-2:0):0,h=[t>0?c:0,t===0?d:0,t===0&&o?s:0,i?s:0].filter(u=>u>0);return a+h.reduce((u,f)=>u+f,0)+h.length*r}function So(e,t,n){let i=e.horizontalAlignment==="right"?e.left-t:e.left;return{left:i,top:e.top,right:i+t,bottom:e.top+n}}function Io(e,t){return e.left<t.right&&e.right>t.left&&e.top<t.bottom&&e.bottom>t.top}function Mo(e,t,n){let i=Math.max(0,e.left+t-n);return Math.max(0,t-e.right)<i?"right":"left"}function $t(e,t,n,i,o=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,o,r);return e.top>=t+n?{anchor:a==="right"?"top-right":"top-left",horizontalAlignment:a,left:a==="right"?e.right:e.left,top:e.top-t-n}:{anchor:a==="right"?"bottom-right":"bottom-left",horizontalAlignment:a,left:a==="right"?e.right:e.left,top:e.bottom+n}}function Qe(e){return e.left+e.width}function De(e){return e.top+e.height}function Ve(e,t){if(e.length===0)return t;let n=Math.min(...e.map(a=>a.left)),i=Math.min(...e.map(a=>a.top)),o=Math.max(...e.map(Qe)),r=Math.max(...e.map(De));return{left:n,top:i,width:o-n,height:r-i}}function Ge(e){let t=[...e].sort((i,o)=>i.top-o.top||i.left-o.left),n=[];for(let i of t){let o=i.top+i.height/2,r=n.find(c=>{let h=c.top+c.height/2;return Math.abs(o-h)<=Math.max(c.height,i.height)*.4});if(!r){n.push({...i});continue}let a=Math.min(r.left,i.left),l=Math.min(r.top,i.top),d=Math.max(Qe(r),Qe(i)),s=Math.max(De(r),De(i));r.left=a,r.top=l,r.width=d-a,r.height=s-l}return n.sort((i,o)=>i.top-o.top||i.left-o.left)}function To({display:e,fragmentRects:t,elementRect:n,parentContentRect:i}){let o=Ge(t),r=Ve(o,n);if(!(e==="inline"&&o.length>1&&i&&i.width>0))return{textRect:r,boundaryRect:n,boundaryRects:[n],firstLineIndent:0};let a=o[0],l={left:i.left,top:a.top,width:i.width,height:Math.max(r.height,De(r)-a.top)},d=Math.max(0,Math.min(l.width,a.left-l.left));return{textRect:r,boundaryRect:Ve(o,n),boundaryRects:o,flowRect:l,firstLineIndent:d}}var Je=new WeakMap;function ko(e){let t={listeners:new Set,rafId:null,schedule:()=>{t.rafId===null&&(t.rafId=e.requestAnimationFrame(()=>{t.rafId=null;for(let n of t.listeners)n()}))}};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 n=Je.get(t)??ko(t);return n.listeners.add(e),()=>{n.listeners.delete(e)&&(n.listeners.size>0||(t.removeEventListener("scroll",n.schedule,!0),t.removeEventListener("resize",n.schedule),n.rafId!==null&&t.cancelAnimationFrame(n.rafId),Je.delete(t)))}}var se={topLeft:"0px",topRight:"0px",bottomRight:"0px",bottomLeft:"0px"};function Ft(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((n,i)=>{let o=t.fragments[i];return!!o&&n.left===o.left&&n.top===o.top&&n.width===o.width&&n.height===o.height})}function Pt(e){if(!e.isConnected||!Dn(e.ownerDocument))return{fragments:[],radii:se};let t=Tt(Ee(e),e.ownerDocument);if(Mt(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 n=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(n.length>0?n:[{left:t.left,top:t.top,width:t.width,height:t.height}]),radii:Ot(e)}}function zt({element:e,projectedRect:t,isSelected:n=!1,elementInfo:i,color:o="#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 I=de(xe),[b,C]=re({fragments:[],radii:se});V(()=>{if(!I)return;if(!e){C({fragments:[],radii:se});return}let P=null,H=()=>{let ee=Pt(e);C(Te=>Ft(Te,ee)?Te: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=Mt(e.ownerDocument)?Ue(H):void 0;return()=>{ae(),me?.(),he?.(),ge?.disconnect(),B?.disconnect(),P!==null&&cancelAnimationFrame(P)}},[I,e,h]),Ct(()=>{if(!I||!e||g===void 0)return;let P=Pt(e);C(H=>Ft(H,P)?H:P)},[I,e,g]);let{fragments:N,radii:z}=t?{fragments:[t],radii:se}:b;if(N.length===0||!e&&!t)return null;let A=Ve(N,N[0]),T=e?.tagName.toLowerCase()??"",X=e?.id?`#${e.id}`:"",oe=e&&e.classList.length>0?"."+Array.from(e.classList).slice(0,2).join("."):"",ie=i?.reactComponent,Se=e?.getAttribute("data-popmelt-subject-adapter"),Ie=e?.getAttribute("data-popmelt-subject-label"),Pe=Se&&Ie?`<${Ie}>`:ie?`<${ie}> ${T}${X}${oe}`:`${T}${X}${oe}`,Z=$t({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),Me={zIndex:9997,display:"flex",alignItems:"center",gap:6,backgroundColor:o,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&&Nn(e,P)},"data-devtools":"tooltip",style:Me,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":Xe(o,c),borderColor:o,borderStyle:n?"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":Xe(o,c),stroke:o,strokeWidth:1,strokeDasharray:n?void 0:"4 3",vectorEffect:"non-scaling-stroke"})}):null})},`${P.left}:${P.top}:${H}`)),m?m(Z,A):ze]})}function Bt(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 Eo(e){return Bt(e).map(t=>`${t}px`).join(" ")}var ve=1.1666666666666667,Ht=2048;function Ze(e){return e.length>Ht?`${e.slice(0,Ht)}\u2026`:e}function Co(e,t,n){let i=Ze(t);if(!i||e.measureText(i).width<=n)return[i];let o=i.split(/\s+/),r=[],a="";for(let l of o){let d=a?`${a} ${l}`:l;a&&e.measureText(d).width>n?(r.push(a),a=l):a=d}return a&&r.push(a),r.length>0?r:[i]}function Ao(e,t,n){return t.flatMap(i=>Co(e,i,n))}var ne=je,et=400,Wt=16,tt=60,Ro=12,nt=16;function jt(e){let t=window.innerWidth-e-Wt;return Math.max(tt,Math.min(et,t))}function ot(e,t,n){let i=Ze(t);if(i===t&&e.measureText(i).width<=n)return i;let o="\u2026",r=0,a=i.endsWith(o)?i.length-1:i.length;for(;r<a;){let l=Math.ceil((r+a)/2);e.measureText(i.slice(0,l)+o).width<=n?r=l:a=l-1}return r>0?i.slice(0,r)+o:o}function No(e,t,n){if(e===void 0||t===void 0||n.avoidLeft===void 0&&n.avoidRight===void 0)return!0;let i=typeof window<"u"?window.innerWidth:9999,o=n.avoidLeft??0,r=n.avoidRight??i;return e+t>o&&e<r}function Yt(e,t,n,i,o){let r=typeof window<"u"?window.innerHeight:9999,a=0,l=r;n&&No(i,o,n)&&(a=n.avoidTop??a,l=n.avoidBottom??l);let d=Math.max(a,l-t);return Math.max(a,Math.min(e,d))}function qt(e,t=12,n,i){let o=t*ve+8,r=e.y-4,a=e.x-8,l=Yt(r,o,n,a,i);return l===r?e:{...e,y:l+4}}function Lo(e,t,n,i,o=12,r,a,l,d="#dddddd",s,c=!1){if(!n)return;let h=o*ve,u=n.replace(/\n/g," "),f=r!==void 0?r+". "+u:u;e.font=`${o}px ${ne}`,e.textBaseline="middle";let y=a!==void 0?Math.min(et,Math.max(tt,window.innerWidth-a-Wt)):et,m=c?nt:0,g=ot(e,f,Math.max(tt,y-m)),k=e.measureText(g).width,w=m+k,v=qt(t,o,l,w+16);e.fillStyle=i;let I=v.x-8,b=v.y-4,C=w+16,N=h+8;e.beginPath(),e.roundRect(I,b,C,N,Bt(s)),e.fill();let z=v.y+h/2;if(c){let A=v.x,T=z-Ro/2;e.strokeStyle=d,e.lineWidth=1.5,e.lineCap="round",e.lineJoin="round",e.beginPath(),e.moveTo(A+7.5,T+4),e.lineTo(A+10.5,T+6.5),e.lineTo(A+7.5,T+9),e.moveTo(A+1.5,T+1.5),e.lineTo(A+1.5,T+4.5),e.quadraticCurveTo(A+1.5,T+6.5,A+3.5,T+6.5),e.lineTo(A+10.5,T+6.5),e.stroke()}e.fillStyle=d,e.fillText(g,v.x+m,z)}function Oo(e,t,n){let i=e.filter(o=>!o.captured&&o.selector===t&&(!o.pathname||o.pathname===n));return i.length?{type:"MODIFY_TEXT_CONTENTS",payload:i.map(o=>({...o,modified:o.original}))}:null}function Kt(e,t){return e.type!=="text"?!1:(e.groupId?t.filter(n=>n.groupId===e.groupId):[e]).every(n=>(n.status??"pending")==="pending"&&!n.threadId)}var Ut=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 Qt(e){return`url("data:image/svg+xml,${encodeURIComponent(e)}")`}var be=Qt(Xt({x:-100,y:-2,width:104,height:26,radius:10})),Do=Qt(Xt({x:-100,y:-5.929,width:108,height:26,radius:10})),rt=10;function $o(e){if(!(!Number.isFinite(e)||e<=0))return Math.max(1,Math.round(e/He))*He}function _o(e,t,n){let i={topLeft:Math.max(0,n.topLeft),topRight:Math.max(0,n.topRight),bottomRight:Math.max(0,n.bottomRight),bottomLeft:Math.max(0,n.bottomLeft)},o=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*o,topRight:i.topRight*o,bottomRight:i.bottomRight*o,bottomLeft:i.bottomLeft*o}}function Fo(e,t,n,i=.5){let o=Math.max(0,e-i*2),r=Math.max(0,t-i*2),a=_o(e,t,n),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+o,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 Gt({stepCount:e,onClear:t,layered:n=!1,submitted:i=!1,style:o}){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:n?`0 8px 0 ${rt*.7}px`:"0 8px 0 5.6px",gap:4,pointerEvents:t?"auto":"none",WebkitMaskImage:n?be:void 0,maskImage:n?be:void 0,...o},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 Po=3,zo=250;function Bo(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 Ho(e,t,n){if(n.avoidLeft===void 0&&n.avoidRight===void 0)return!0;let i=typeof window<"u"?window.innerWidth:9999,o=n.avoidLeft??0,r=n.avoidRight??i;return e+t>o&&e<r}function lt(e,t,n){return Ho(t,n,e)?e:{}}function Wo(e,t,n){let i=n.avoidTop!==void 0?`${n.avoidTop}px`:"0px",o=n.avoidBottom!==void 0?`${n.avoidBottom}px`:"100dvh";return`translate(min(0px, calc(100vw - ${e} - 100%)), min(max(0px, calc(${i} - ${t})), calc(${o} - ${t} - 100%)))`}function Jt(e,t,n){if(n.avoidTop===void 0&&n.avoidBottom===void 0)return e;let i=typeof window<"u"?window.innerHeight:9999,o=n.avoidTop??0,r=n.avoidBottom??i,a=Math.max(o,r-t);return Math.max(o,Math.min(e,a))}function Zt({left:e,top:t,scrollX:n,scrollY:i,avoidTop:o,avoidBottom:r,style:a,children:l,...d}){let s=`calc(${e}px - var(--popmelt-scroll-x, ${n}px))`,c=`calc(${t}px - var(--popmelt-scroll-y, ${i}px))`,h=`calc(${e+pe}px - var(--popmelt-scroll-x, ${n}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:Wo(h,u,{avoidTop:o,avoidBottom:r})},children:l})})}function en({bundleCount:e,style:t,layered:n=!1,compact:i=!1,description:o,replacementText:r,onHoverChange:a,onSend:l}){let[d,s]=re(!1),[c]=Ye(),h=qe[c],u=de(Ut),f=jn(),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(Wn,{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,I={...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:n?`0 8px 0 ${rt}px`:"0 8px",gap:4,whiteSpace:"nowrap",borderRadius:G,letterSpacing:"0.24px",WebkitMaskImage:n?be:void 0,maskImage:n?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:{...I,gridArea:"1 / 1",visibility:"hidden"},children:w(!1)}),R("button",{type:"button","data-devtools":"annotation-badge","aria-label":b,"aria-describedby":o?f:void 0,disabled:!l,onPointerDown:C=>{C.preventDefault(),C.stopPropagation()},onClick:C=>{C.preventDefault(),C.stopPropagation(),l?.()},style:{...I,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:[o&&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:o}),v??w(d)]})]})}function tn({count:e,color:t,size:n=22,onHoverChange:i}){return R("div",{"data-devtools":"nested-annotation-count-badge",onMouseEnter:()=>i?.(!0),onMouseLeave:()=>i?.(!1),style:{height:n,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 jo({annotations:e,supersededAnnotations:t,inFlightIds:n,orientationLabels:i,activeIds:o,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:I,nestedAnnotationIdsById:b,onHoverNestedAnnotations:C,onHoverSendBundle:N,onSend:z,sendHintAnchorId:A,pendingBundleCount:T=1,parentPinnedAnnotationIds:X,parentPinnedLocationLabels:oe,parentPinnedTooltipAnnotationId:ie,onActivateAnnotation:Se,hiddenAnnotationIds:Ie,displayAnnotations:Pe}){let Z=de(xe),Me=le(null),[ze,P]=re(0),H=!!(n&&n.size>0&&(o===void 0||o.size>0));V(()=>{if(!H||!Z)return;let p=setInterval(()=>{P(S=>(S+1)%Po)},zo);return()=>{clearInterval(p)}},[H,Z]),V(()=>{if(!Z)return;let p=Me.current;if(!p)return;let S=()=>{p.style.setProperty("--popmelt-scroll-x",`${window.scrollX}px`),p.style.setProperty("--popmelt-scroll-y",`${window.scrollY}px`)};return S(),window.addEventListener("scroll",S,{passive:!0,capture:!0}),window.addEventListener("resize",S),()=>{window.removeEventListener("scroll",S,!0),window.removeEventListener("resize",S)}},[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)||Ie?.has(p.id))continue;let S=p.groupId?e.filter(M=>M.groupId===p.groupId):[p],D=p.status??"pending",F=T>0&&p.id===A,L=p.interactionEpisode?.steps.length??0,j=I?.get(p.id)??0,K=b?.get(p.id)??[],O=S.reduce((M,kn)=>Math.max(M,kn.replyCount??0),0),Y=D==="sending"||S.some(M=>M.status==="sending"),U=D==="awaiting_review",$=!Y&&(!!(n&&(n.has(p.id)||S.some(M=>n.has(M.id))))||p.status==="in_flight"||S.some(M=>M.status==="in_flight")),ye=S.some(M=>M.status==="resolved"&&(M.replyCount??0)>0||M.status==="needs_review"),te=S.some(M=>M.threadId),yn=!g||S.some(M=>g.has(M.id)||v?.has(M.id));if(!(F||Y||U||$||D==="resolved"||D==="failed"||D==="needs_review"||ye||te||L>0)&&j===0)continue;let xn=p.threadId||S.find(M=>M.threadId)?.threadId,ht=D==="needs_review"||S.some(M=>M.status==="needs_review"),gt=D==="waiting_input"||S.some(M=>M.status==="waiting_input"),mt=D==="failed"||S.some(M=>M.status==="failed"),yt=F||Y||U||$||ht||gt||mt||O>0||D==="resolved"&&te||L>0;if(!yt&&j===0)continue;let Be=p.points[0],xt=p.fontSize||12,wn=xt*ve,wt=d.get(p.id),vt=((Pe?.find(M=>M.id===p.id)??p).text??p.text).replace(/\n/g," "),vn=wt!==void 0?wt+". "+vt:vt,ke=y?.current?.getContext("2d")??document.createElement("canvas").getContext("2d");if(!ke)continue;ke.font=`${xt}px ${ne}`;let bn=Be.x-a,bt=X?.has(p.id)?nt:0,Sn=Math.max(60,jt(bn)-bt),In=ot(ke,vn,Sn),Mn=ke.measureText(In).width,Tn=$&&!!o&&!o.has(p.id)&&!S.some(M=>o.has(M.id));E.push({id:p.id,threadId:xn,linkedSelector:p.linkedSelector||S.find(M=>M.linkedSelector)?.linkedSelector,x:Be.x+Mn+bt+8+2,y:Be.y-4,size:wn+8,color:F?"#000000":p.color,isSending:Y,isAwaitingReview:U,isInFlight:$,orientationLabel:i?.get(p.id)??S.map(M=>i?.get(M.id)).find(Boolean),isQueued:Tn,queuePosition:void 0,isNeedsReview:ht,isQuestion:gt,isFailed:mt,replyCount:O>0?O:D==="resolved"&&te?1:0,isInActiveBundle:yn,isSendHint:F,interactionEpisodeStepCount:L,interactionEpisodeSubmitted:D!=="pending",nestedCount:j,nestedAnnotationIds:K,nestedColor:D==="pending"?p.color:"#8c8c8c",showActionBadge:yt,canDeleteDraft:Kt(p,e)})}let he=E.filter(p=>p.isQueued);if(he.length>0&&he.forEach((p,S)=>{p.queuePosition=r?.get(p.id)??`(${S+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 S=p.nestedCount>0?(B?.measureText(`+${p.nestedCount}`).width??String(p.nestedCount).length*7.2+7.2)+16:0,D=Vt(p.interactionEpisodeStepCount);if(!p.showActionBadge)return S+D;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,O=L.length*7.2;B&&(O=B.measureText(L).width);let Y=p.isSendHint&&B?B.measureText("to").width:p.isSendHint?14.4:0,U=p.isSendHint&&B?B.measureText("+").width:p.isSendHint?7.2:0,$=p.isSendHint&&T>1&&B?B.measureText(String(T)).width:p.isSendHint&&T>1?7.2:0,ye=F?Math.min(O+16,320):p.isSendHint?O+U+Y+$+16+12+12+4+K*(T>1?3:2):6+j+K+O+8,te=+(D>0)+ +(S>0)+1;return D+S+ye+(te-1)*2}),me=Bo(m),ee=[];for(let p=0;p<E.length;p++){let S=E[p].y-l,D=E[p].x-a,F=lt(me,D,ae[p]),L=Jt(S,E[p].size,F),j=L+E[p].size,K=D;for(let O=0;O<p;O++){let Y=E[O].y-l,U=lt(me,ee[O],ae[O]),$=Jt(Y,E[O].size,U),ye=$+E[O].size;if(!(L<ye&&j>$))continue;let te=ee[O]+ae[O];K<te+ge&&(K=te+ge)}ee.push(K)}let Te={position:"fixed",inset:0,pointerEvents:"none",zIndex:9999,"--popmelt-scroll-x":`${a}px`,"--popmelt-scroll-y":`${l}px`};return R("div",{ref:Me,"data-devtools":"annotation-badge-layer",style:Te,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,S)=>{let D=!!p.threadId,F=oe?.get(p.id),L=!!F&&ie===p.id,j=D||!!F,K=p.showActionBadge&&p.isSendHint,O=j&&!K,Y=()=>{if(Se){Se(p.id,p.threadId);return}c?.(p.id),p.threadId&&s?.(p.threadId)},U=lt(me,ee[S],ae[S]);return x(Zt,{left:ee[S]+a-pe,top:p.y-pe,scrollX:a,scrollY:l,avoidTop:U.avoidTop,avoidBottom:U.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:O?$=>{$.key!=="Enter"&&$.key!==" "||($.preventDefault(),Y())}:void 0,role:O?"button":void 0,tabIndex:O?0:void 0,"aria-label":O&&F?`${F}. Activate to reveal the annotation source${D?" and open its thread":""}`:void 0,style:{pointerEvents:"auto",cursor:j?"pointer":void 0,zIndex:9999,minWidth:p.isSendHint?ae[S]:void 0},children:R("div",{style:{position:"relative",display:"flex",alignItems:"center",gap:2},children:[x(Gt,{stepCount:p.interactionEpisodeStepCount,submitted:p.interactionEpisodeSubmitted,onClear:p.canDeleteDraft&&u?()=>u(p.id):void 0}),p.nestedCount>0&&x(tn,{count:p.nestedCount,color:p.nestedColor,size:p.size,onHoverChange:$=>C?.(p.id,$?p.nestedAnnotationIds:null)}),p.showActionBadge&&(p.isSendHint?x(en,{bundleCount:T,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(Et,{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(Et,{size:12,strokeWidth:2.25}),"Queued",p.queuePosition?` ${p.queuePosition}`:""]}):p.isSending||p.isInFlight?R(W,{children:[p.orientationLabel==="Approval needed"?x(Fn,{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(Pn,{size:12,strokeWidth:2.25}):p.isFailed?x(zn,{size:12,strokeWidth:2.25}):p.replyCount>0?x(Bn,{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 nn({d:e,color:t,animated:n}){let i=le(null);return Ct(()=>{let o=i.current;if(!o||typeof o.getTotalLength!="function")return;let r=$o(o.getTotalLength());r===void 0?o.removeAttribute("pathLength"):o.setAttribute("pathLength",String(r))},[e]),x("path",{ref:i,d:e,fill:"none",stroke:t,strokeWidth:1,strokeDasharray:n?En:void 0,"data-popmelt-marching-stroke":n||void 0,style:n?{animation:"popmelt-march 0.6s linear infinite"}:void 0})}function on(){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 Yo({annotations:e,activeIds:t,scrollX:n,scrollY:i,spotlightIds:o,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(on,{}),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(${-n} ${-i})`,children:d.map(s=>{let c=o?.size?o.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(nn,{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 qo({inFlightSelectorColors:e,animated:t=!0,subjectRegistry:n,selectorElementInfo:i}){let o=de(xe),[r,a]=re([]);return V(()=>{if(!o)return;if(e.size===0){a([]);return}let l=null,d=()=>{let f=[];for(let[y,m]of e){let g=On(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:Ot(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=n?.subscribeFrame(d),u=[...e.keys()].some(f=>f.startsWith("@frame("))?Ue(d):void 0;return()=>{window.removeEventListener("scroll",s,!0),window.removeEventListener("resize",s,!0),c.disconnect(),h?.(),u?.(),l&&cancelAnimationFrame(l)}},[e,n,i,o]),r.length===0?null:R(W,{children:[t&&x(on,{}),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(nn,{d:Fo(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 Ko({element:e,elements:t,registry:n,label:i="Looking",engaged:o=!0,outlineColor:r,inverse:a=!1}){let l=le(0),d=Yn(()=>t??(e?[e]:[]),[t,e]),[s,c]=re(()=>d.map(u=>({target:u,id:++l.current,animateEntrance:!0,exiting:!1}))),h=qn(u=>{c(f=>f.filter(y=>y.id!==u))},[]);return V(()=>{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(Uo,{id:f,element:o&&d.includes(u)?u:null,target:u,animateEntrance:y,exiting:m,registry:n,label:i,outlineColor:r,inverse:a,onDone:h},f))})}function Uo({id:e,element:t,target:n,animateEntrance:i,exiting:o,registry:r,label:a,outlineColor:l,inverse:d,onDone:s}){let[c]=Ye(),h=qe[c],u=n,[f,y]=re(!1),m=le(Date.now()),[g,k]=re(null);return V(()=>{if(!u)return;let w,v=()=>{let I=Ln(u);k(b=>I?b?.left===I.left&&b.top===I.top?b:{left:I.left,top:I.top}:null),w=requestAnimationFrame(v)};return v(),()=>cancelAnimationFrame(w)},[u]),V(()=>{let w,v;return o?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,o,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(zt,{element:u,subjectRegistry:r,hideOutline:!l||f||o,color:l,outlineZIndex:l?10002:void 0,hideFill:!0,hideTooltip:!0,railHeight:22,renderRail:(w,v)=>{let I=g??w,b=I.left>=28,C=!g&&w.anchor.startsWith("bottom-"),N=g?b?"left":"up":`${C?"down":"up"}${b?"-left":""}`,z=g&&!b?Math.max(4,I.top-22-2):I.top,A=b?I.left-22-2:I.left,T=v.left+v.width/2>=A+22/2,X=v.top+v.height/2>=z+22/2?T?"borderBottomRightRadius":"borderBottomLeftRadius":T?"borderTopRightRadius":"borderTopLeftRadius";return x("div",{"data-devtools":"focus-inspection","data-popmelt-looking-exiting":o?"true":void 0,"data-popmelt-canvas-block":!0,role:"status","aria-live":o?"off":"polite","aria-hidden":o||void 0,"aria-label":a,title:a,style:{position:"fixed",animation:o?"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?{}:{[X]:2},fontFamily:je,fontSize:12,letterSpacing:"0.24px",whiteSpace:"nowrap",pointerEvents:o?"none":"auto",zIndex:u.hasAttribute("data-popmelt-thread-header")?10005:10002},children:x(Hn,{className:i&&!o?"popmelt-looking-eye":void 0,size:12,"aria-hidden":!0})})}})]}):null}var Xo={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 Qo(e){if(typeof e!="string")throw new Error("Unexpected sign-in destination.");let t=new URL(e);if(!Object.values(Xo).some(({issuer:n})=>t.origin===n)||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:[" "]}},Vo=[{type:"model",label:"Imprint",shortcut:"I"},{type:"sticker",label:"Steer",shortcut:"S"},{type:"inspector",label:"Chat",shortcut:"C"}];function Go(e){let t=e.toLowerCase();return Object.values($e.tools).find(n=>n.key===t)?.tool??null}function Jo(e){let t=e.length===1?e.toLowerCase():e,n=$e.omnidial;return[...n.previous,...n.next,...n.previousFacet,...n.nextFacet,...n.descendOrApply,...n.ascend,...n.query].includes(t)||/^[a-z0-9]$/i.test(e)}var an=Ke(null),Zo=()=>()=>{},rn=()=>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 st(e){return{annotations:e.annotations,styleModifications:e.styleModifications,textModifications:e.textModifications,domModifications:e.domModifications,spacingTokenChanges:e.spacingTokenChanges,spacingTokenMods:e.spacingTokenMods}}function _(e){return{...e,undoStack:[...e.undoStack,st(e)],redoStack:[]}}function ei(e,t){return{...e,isAnnotating:t}}function ti(e,t){return{...e,activeTool:t}}function ni(e,t){return{...e,activeColor:t}}function oi(e,t){return{...e,strokeWidth:t}}function ii(e,t){let n={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,n]}}function ai(e,t){return{..._(e),annotations:e.annotations.map(n=>n.id===t.id?{...n,text:t.text,...t.imageCount!=null?{imageCount:t.imageCount}:{},...t.attachments?{attachments:t.attachments}:{},...t.interactionEpisode?{interactionEpisode:t.interactionEpisode}:{}}:n)}}function ri(e,t){return{..._(e),annotations:e.annotations.map(n=>{if(n.id!==t.id)return n;let i=n.interactionEpisode?.frames?.length??0,{interactionEpisode:o,...r}=n;if(i===0)return r;let a=Math.max(0,(n.imageCount??0)-i);if(a===0){let{imageCount:l,...d}=r;return d}return{...r,imageCount:a}})}}function li(e,t){let n=_(e),i=e.annotations.find(r=>r.id===t.id)?.groupId,o=new Set(e.annotations.filter(r=>r.id===t.id||i&&r.groupId===i).map(r=>r.id));return{...n,annotations:e.annotations.filter(r=>r.id!==t.id&&!(i&&r.groupId===i)),selectedAnnotationIds:e.selectedAnnotationIds.filter(r=>!o.has(r)),lastSelectedId:e.lastSelectedId&&o.has(e.lastSelectedId)?null:e.lastSelectedId}}function di(e,t){let n=t.saveUndo?_(e):e,i=e.annotations.find(o=>o.id===t.id)?.groupId;return{...n,annotations:e.annotations.map(o=>{if(!(o.id===t.id||i&&o.groupId===i))return o;let r=t.delta.x,a=t.delta.y;return{...o,points:o.points.map(l=>({x:l.x+r,y:l.y+a}))}})}}function si(e,t){let n=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 o=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);o=l-h,r=d-u}return{...n,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+o,y:l.y+r}))}:a)}}function pi(e,t){return{..._(e),annotations:[...e.annotations,...t.annotations.map(_e)]}}function ci(e,t){let n=new Set,i=[];for(let o of t.annotations)n.has(o.id)||(n.add(o.id),i.push(_e(o)));return{...e,annotations:i}}function ui(e,t){let n=new Map(e.annotations.map(o=>[o.id,o])),i=t.annotations.map(o=>{let r=_e(o),a=n.get(r.id);return!a||!r.linkedSelector||a.linkedSelector!==r.linkedSelector?r:{...r,points:a.points,linkedAnchor:a.linkedAnchor}});return{...e,annotations:i}}function fi(e,t){let n=new Set(e.annotations.map(o=>o.id)),i=t.annotations.filter(o=>!n.has(o.id)).map(_e);return i.length>0?{...e,annotations:[...e.annotations,...i]}:e}function hi(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,st(e)]}}function gi(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,st(e)]}}function mi(e,t){let{id:n,addToSelection:i}=t;if(n===null)return{...e,selectedAnnotationIds:[],lastSelectedId:null};if(i)if(e.selectedAnnotationIds.includes(n)){let o=e.selectedAnnotationIds.filter(r=>r!==n);return{...e,selectedAnnotationIds:o,lastSelectedId:o.length>0?o[o.length-1]:null}}else return{...e,selectedAnnotationIds:[...e.selectedAnnotationIds,n],lastSelectedId:n};return{...e,selectedAnnotationIds:[n],lastSelectedId:n}}function yi(e,t){let n=e.annotations.find(o=>o.id===t.id)?.groupId,i=new Set;for(let o of e.selectedAnnotationIds){let r=e.annotations.find(a=>a.id===o);r?.groupId&&i.add(r.groupId)}return{...e,annotations:e.annotations.map(o=>o.id===t.id||e.selectedAnnotationIds.includes(o.id)||o.groupId&&(o.groupId===n||i.has(o.groupId))?{...o,color:t.color}:o)}}function xi(e,t,n){let i=typeof window<"u"?window.location.pathname:"/",o=t?new Set(t):void 0,r=n??e.textModifications.filter(d=>!d.pathname||d.pathname===i),a=d=>d.filter(s=>!r.some(c=>s.pathname===c.pathname&&ln(s,c.selector,c.textNodePath,c.pathname??"")&&s.createdAt===c.createdAt&&s.original===c.original&&s.modified===c.modified)),l=d=>({...d,textModifications:a(d.textModifications)});return{...e,undoStack:e.undoStack.map(l),redoStack:e.redoStack.map(l),annotations:e.annotations.map(d=>o&&!o.has(d.id)?d:{...d,captured:!0,status:d.status==="pending"||d.status==="sending"||!d.status?"in_flight":d.status}),styleModifications:e.styleModifications.map(d=>!d.pathname||d.pathname===i?{...d,captured:!0}:d),textModifications:a(e.textModifications),domModifications:e.domModifications.map(d=>!d.pathname||d.pathname===i?{...d,captured:!0}:d),spacingTokenChanges:e.spacingTokenChanges.map(d=>({...d,captured:!0})),spacingTokenMods:e.spacingTokenMods.map(d=>({...d,captured:!0}))}}function wi(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 vi(e){return{...e,annotations:[],undoStack:[],redoStack:[],selectedAnnotationIds:[],lastSelectedId:null,textModifications:[],domModifications:[],spacingTokenChanges:[],spacingTokenMods:[]}}function bi(e,t){let{selector:n,element:i,property:o,original:r,modified:a}=t,l=typeof window<"u"?window.location.pathname:"/",d=e.styleModifications.findIndex(s=>s.selector===n&&(!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:o,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===o),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:o,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:n,element:i,changes:[{property:o,original:r,modified:a}],createdAt:Date.now(),pathname:l};return{...s,styleModifications:[...s.styleModifications,c]}}}function Si(e,t){let{selector:n,durableSelector:i,element:o,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===n&&(!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:n,durableSelector:i,element:o,changes:l,createdAt:Date.now(),pathname:a}]}}function Ii(e,t){let{selector:n,property:i}=t,o=typeof window<"u"?window.location.pathname:"/",r=_(e),a=r.styleModifications.map(l=>l.selector!==n||l.pathname&&l.pathname!==o?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:n,sticker:i}=t,o=typeof window<"u"?window.location.pathname:"/";if(!e.styleModifications.find(l=>l.selector===n&&(!l.pathname||l.pathname===o)&&!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!==n||l.pathname&&l.pathname!==o||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 Ti(e){return e.styleModifications.length===0?e:{..._(e),styleModifications:[]}}function ki(e,t){let n=new Set(t.selectors);if(n.size===0)return e;let i=e.styleModifications.filter(o=>!o.captured||!n.has(o.selector)&&(!o.durableSelector||!n.has(o.durableSelector)));return i.length===e.styleModifications.length?e:{...e,styleModifications:i}}function Ei(e,t){let n=Date.now();return{...e,styleModifications:t.map((i,o)=>({...i,createdAt:i.createdAt??n+o}))}}function ln(e,t,n,i){return e.selector===t&&(!e.pathname||e.pathname===i)&&e.textNodePath.length===n.length&&e.textNodePath.every((o,r)=>o===n[r])}function dn(e,t,n=!0){let{selector:i,durableSelector:o,element:r,textNodePath:a,original:l,modified:d}=t,s=typeof window<"u"?window.location.pathname:"/",c=e.textModifications.findIndex(u=>ln(u,i,a,s));if(l===d&&c<0)return e;if(c>=0){let u=e.textModifications[c],f=u.captured&&n?_(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:o,element:r,original:y,modified:d,createdAt:m.createdAt??Date.now(),captured:!1,pathname:s}:m)}}let h=n?_(e):e;return{...h,textModifications:[...h.textModifications,{selector:i,durableSelector:o,element:r,textNodePath:a,original:l,modified:d,createdAt:Date.now(),pathname:s}]}}function Ci(e,t,n=!0){return t.length===0?e:t.reduce((i,o)=>dn(i,o,!1),n?_(e):e)}function Ai(e,t){let n=Date.now();return{...e,textModifications:t.filter(i=>!i.captured).map((i,o)=>({...i,createdAt:i.createdAt??n+o}))}}function Ri(e,t){let n=_(e),i=n.domModifications.findIndex(o=>o.id===t.id);return i>=0?{...n,domModifications:n.domModifications.map((o,r)=>r===i?{...t,captured:!1}:o)}:{...n,domModifications:[...n.domModifications,t]}}function Ni(e,t){return{...e,domModifications:t}}function Li(e,t){let{updates:n}=t,i=new Map(n.map(o=>[o.id,o]));return{...e,annotations:e.annotations.map(o=>{let r=i.get(o.id);return r?{...o,points:[r.point,...o.points.slice(1)],...r.linkedAnchor?{linkedAnchor:r.linkedAnchor}:{}}:o})}}function Oi(e,t){let n=new Set(t.ids);return{...e,annotations:e.annotations.map(i=>n.has(i.id)?{...i,status:t.status}:i)}}function Di(e,t){let n=new Set(t.ids),i=new Set;for(let o of e.annotations)n.has(o.id)&&o.groupId&&i.add(o.groupId);return{...e,annotations:e.annotations.map(o=>{if(!n.has(o.id)&&!(o.groupId&&i.has(o.groupId)))return o;let r=!!t.jobId&&o.replyJobIds?.includes(t.jobId),a=o.status==="waiting_input";return{...o,status:a?"waiting_input":"resolved",replyCount:(o.replyCount??0)+(r?0:1),replyJobIds:t.jobId&&!r?[...o.replyJobIds??[],t.jobId]:o.replyJobIds,threadId:o.threadId||t.threadId,question:a?o.question:void 0}})}}function $i(e,t){let n=new Set(t.ids),i=new Set;for(let o of e.annotations)n.has(o.id)&&o.groupId&&i.add(o.groupId);return{...e,annotations:e.annotations.map(o=>n.has(o.id)||o.groupId&&i.has(o.groupId)?{...o,status:"failed",threadId:o.threadId||t.threadId,question:void 0}:o)}}function _i(e,t){let n=new Set(t.ids),i=new Set;for(let o of e.annotations)n.has(o.id)&&o.groupId&&i.add(o.groupId);return{...e,annotations:e.annotations.map(o=>n.has(o.id)||o.groupId&&i.has(o.groupId)?{...o,threadId:t.threadId,targetBindingId:t.targetBindingId}:o)}}function Fi(e,t){let n=new Set(t.ids),i=new Set;for(let o of e.annotations)n.has(o.id)&&o.groupId&&i.add(o.groupId);return{...e,annotations:e.annotations.map(o=>n.has(o.id)||o.groupId&&i.has(o.groupId)?{...o,status:"waiting_input",question:t.question,threadId:t.threadId}:o)}}function Pi(e,t){let n=new Map(t.resolutions.map(o=>[o.annotationId,o])),i=new Map;for(let o of e.annotations){let r=n.get(o.id);r&&o.groupId&&i.set(o.groupId,r)}return{...e,annotations:e.annotations.map(o=>{let r=n.get(o.id)||(o.groupId?i.get(o.groupId):void 0);if(!r)return o;let a=!!t.jobId&&o.replyJobIds?.includes(t.jobId);return{...o,status:r.status,resolutionSummary:r.summary,scope:r.finalScope??r.inferredScope??null,replyCount:(o.replyCount??0)+(a?0:1),replyJobIds:t.jobId&&!a?[...o.replyJobIds??[],t.jobId]:o.replyJobIds,question:void 0,threadId:o.threadId||t.threadId}})}}function zi(e,t){let{linkedSelectors:n,styleSelectors:i}=t,o=new Set(n),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&&o.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 Bi(e,t){let n=e.spacingTokenChanges.findIndex(i=>i.tokenPath===t.tokenPath);return n>=0?{...e,spacingTokenChanges:e.spacingTokenChanges.map((i,o)=>o===n?t:i)}:{...e,spacingTokenChanges:[...e.spacingTokenChanges,t]}}function Hi(e,t){return{...e,spacingTokenChanges:t}}function Wi(e,t){let n=_(e),i=e.spacingTokenMods.findIndex(r=>r.tokenPath===t.tokenPath),o;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};o=e.spacingTokenMods.map((l,d)=>d===i?a:l)}else o=[...e.spacingTokenMods,{...t,captured:!1}];return{...n,spacingTokenMods:o}}function ji(e,t){let n=_(e),i=e.spacingTokenMods.findIndex(s=>s.tokenPath===t.tokenPath),o=i>=0?e.spacingTokenMods[i]:null,r=i>=0?o.captured?o.currentValue:o.originalValue:t.originalValue,a=i>=0?o.captured?o.currentPx:o.originalPx:parseFloat(t.originalValue)||0,l={tokenPath:t.tokenPath,originalValue:r,currentValue:"__deleted__",targets:o?.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],{...n,spacingTokenMods:d}}function sn(e,t){switch(t.type){case"SET_ANNOTATING":return ei(e,t.payload);case"SET_TOOL":return ti(e,t.payload);case"SET_COLOR":return ni(e,t.payload);case"SET_STROKE_WIDTH":return oi(e,t.payload);case"ADD_TEXT":return ii(e,t.payload);case"UPDATE_TEXT":return ai(e,t.payload);case"CLEAR_INTERACTION_EPISODE":return ri(e,t.payload);case"DELETE_ANNOTATION":return li(e,t.payload);case"MOVE_ANNOTATION":return di(e,t.payload);case"RESIZE_ANNOTATION":return si(e,t.payload);case"PASTE_ANNOTATIONS":return pi(e,t.payload);case"RESTORE_ANNOTATIONS":return ci(e,t.payload);case"SYNC_ANNOTATIONS":return ui(e,t.payload);case"MERGE_ANNOTATIONS":return fi(e,t.payload);case"UNDO":return hi(e);case"REDO":return gi(e);case"SELECT_ANNOTATION":return mi(e,t.payload);case"UPDATE_ANNOTATION_COLOR":return yi(e,t.payload);case"MARK_CAPTURED":return xi(e,t.payload?.annotationIds,t.payload?.textModifications);case"CLEAR":return vi(e);case"DISCARD_DRAFT":return wi(e);case"MODIFY_STYLE":return bi(e,t.payload);case"MODIFY_STYLES_BATCH":return Si(e,t.payload);case"CLEAR_STYLE":return Ii(e,t.payload);case"CLEAR_STICKER":return Mi(e,t.payload);case"CLEAR_ALL_STYLES":return Ti(e);case"SETTLE_CAPTURED_STYLES":return ki(e,t.payload);case"RESTORE_STYLE_MODIFICATIONS":return Ei(e,t.payload);case"MODIFY_TEXT_CONTENT":return dn(e,t.payload);case"MODIFY_TEXT_CONTENTS":return Ci(e,t.payload,t.saveUndo??!0);case"RESTORE_TEXT_MODIFICATIONS":return Ai(e,t.payload);case"MODIFY_DOM_STRUCTURE":return Ri(e,t.payload);case"RESTORE_DOM_MODIFICATIONS":return Ni(e,t.payload);case"UPDATE_LINKED_POSITIONS":return Li(e,t.payload);case"CLEANUP_ORPHANED":return zi(e,t.payload);case"SET_ANNOTATION_STATUS":return Oi(e,t.payload);case"MARK_ANNOTATIONS_REPLIED":return Di(e,t.payload);case"MARK_ANNOTATIONS_FAILED":return $i(e,t.payload);case"SET_ANNOTATION_THREAD":return _i(e,t.payload);case"SET_ANNOTATION_QUESTION":return Fi(e,t.payload);case"APPLY_RESOLUTIONS":return Pi(e,t.payload);case"ADD_SPACING_TOKEN_CHANGE":return Bi(e,t.payload);case"RESTORE_SPACING_TOKEN_CHANGES":return Hi(e,t.payload);case"MODIFY_SPACING_TOKEN":return Wi(e,t.payload);case"DELETE_SPACING_TOKEN":return ji(e,t.payload);default:return t}}function Yi(e,t){let n=de(an),[i,o]=Kn(sn,Cn),r=Un(n?.subscribe??Zo,n?.getSnapshot??rn,n?.getSnapshot??rn)??i,a=n?.dispatch??o;V(()=>{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=n?.getUndoHead?n.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 qi(e,t,n=document){let i=n,o=i.caretPositionFromPoint?.(e,t);if(o?.offsetNode?.nodeType===Node.TEXT_NODE)return o.offsetNode;let r=i.caretRangeFromPoint?.(e,t);return r?.startContainer?.nodeType===Node.TEXT_NODE?r.startContainer:null}function Ki(e,t){if(!e)return t();let n=e.style.pointerEvents;e.style.pointerEvents="none";try{return t()}finally{e.style.pointerEvents=n}}function Ui(e,t,n){let i=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode(r){return r.textContent?.trim()?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}}),o=i.nextNode();for(;o;){let r=o,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&&n>=d.top&&n<=d.bottom))return r;o=i.nextNode()}return null}function Xi(e,t,n){return Ki(n,()=>{let i=St(e,t);if(!i||ue(i))return null;let o=i?.ownerDocument??document,r=$n(e,t,o),a=qi(r.x,r.y,o);if(a&&!i.contains(a)&&(a=null),!a){let b=i;b&&!ue(b)&&(a=Ui(b,r.x,r.y))}if(!a||!_n(a.parentElement))return null;let l=a.parentElement;if(ue(l))return null;for(;l.parentElement&&l!==o.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(T=>T.nodeType===Node.TEXT_NODE&&!!T.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=pn(l,a);if(!h)return null;let u=Ae(l).getComputedStyle(l),f=un(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,I=u.whiteSpace!=="nowrap"&&u.whiteSpace!=="pre"&&(Zi(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:I}})}function pn(e,t){let n=[],i=t;for(;i&&i!==e;){let o=i.parentNode;if(!o)return null;n.unshift(Array.prototype.indexOf.call(o.childNodes,i)),i=o}return i===e?n:null}function Qi(e,t){let n=e.ownerDocument.createRange();n.selectNodeContents(e);let i=Ce(n.getBoundingClientRect(),e.ownerDocument);if(n.detach?.(),i.width>0&&i.height>0)return{left:i.left,top:i.top,width:i.width,height:i.height};let o=Ee(t);return{left:o.left,top:o.top,width:o.width,height:o.height}}function Vi(e){let t=[],n=i=>{if(i.nodeType===Node.TEXT_NODE){let r=i,a=pn(e,r);a&&t.push({textNode:r,textNodePath:a,originalText:r.nodeValue??""});return}if(i.nodeType!==Node.ELEMENT_NODE&&i!==e)return;let o=i.tagName?.toLowerCase();o==="script"||o==="style"||i.childNodes.forEach(n)};return e.childNodes.forEach(n),t}function cn(e){return{left:e.left,top:e.top,width:e.width,height:e.height}}function Gi(e){let t=[];for(let n of e){if(!n.textNode.isConnected||!n.originalText.trim())continue;let i=n.textNode.ownerDocument.createRange();i.selectNodeContents(n.textNode),t.push(...Array.from(i.getClientRects()).filter(o=>o.width>0&&o.height>0).map(o=>cn(Ce(o,n.textNode.ownerDocument)))),i.detach?.()}return Ge(t)}function Ji(e){let t=e.getBoundingClientRect(),n=Ae(e).getComputedStyle(e),i=(parseFloat(n.borderLeftWidth)||0)+(parseFloat(n.paddingLeft)||0),o=(parseFloat(n.borderRightWidth)||0)+(parseFloat(n.paddingRight)||0),r=(parseFloat(n.borderTopWidth)||0)+(parseFloat(n.paddingTop)||0),a=(parseFloat(n.borderBottomWidth)||0)+(parseFloat(n.paddingBottom)||0);return Ce({left:t.left+i,top:t.top+r,width:Math.max(0,t.width-i-o),height:Math.max(0,t.height-r-a)},e.ownerDocument)}function un(e,t,n){let i=cn(Ee(t)),o=Gi(e),r=e[0]?.textNode?Qi(e[0].textNode,t):i,a=o.length>0?o:[r];return To({display:n.display,fragmentRects:a,elementRect:i,parentContentRect:t.parentElement?Ji(t.parentElement):void 0})}function Zi(e){let t=e.ownerDocument.createRange();t.selectNodeContents(e);let n=Array.from(t.getClientRects()).filter(i=>i.width>0&&i.height>0).length;return t.detach?.(),n>1}function ea(e,t,n){if(t===n||e.length===0)return[];let i=0;for(;i<t.length&&i<n.length&&t[i]===n[i];)i+=1;let o=0;for(;o<t.length-i&&o<n.length-i&&t[t.length-1-o]===n[n.length-1-o];)o+=1;let r=i,a=t.length-o,l=n.slice(i,n.length-o),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 pt(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 ta(e,t){return!e||!t?e===t:pt(e,t)}function na(e,t){return e.length===t.length&&e.every((n,i)=>pt(n,t[i]))}function oa(){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 ct(e){return e.parentElement?Array.from(e.parentElement.children).indexOf(e):-1}function fn(e){e.removeAttribute("data-pm"),e.querySelectorAll("[data-pm]").forEach(t=>t.removeAttribute("data-pm"))}function hn(e,t,n,i,o=St){let r=n.parentElement;if(!r)return null;let a=o(e,t);for(;a&&a!==document.body;){if(a===n||n.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=ct(a),c=d==="before"?s:s+1;return{parent:r,reference:a,placement:d,index:c}}function ut(e,t,n){let i=Array.from(e.children).filter(r=>r!==t),o=Math.max(0,Math.min(n,i.length));e.insertBefore(t,i[o]??null)}function ia({drag:e,clientX:t,clientY:n,pathname:i,createId:o,rootElement:r,elementAtPoint:a}){let l=e.element;if(!l||!e.selector||!e.durableSelector||!e.elementInfo)return null;let d=hn(t,n,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=Q(d.parent),h=J(d.parent),u=Q(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;fn(w),ut(d.parent,w,s),y=J(w),m=Q(w),g={...We(w),selector:y}}else ut(d.parent,l,s);let k=e.originalParent;return{id:o(),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?Q(k):void 0,originalIndex:e.originalIndex,targetParentSelector:h,targetParentDurableSelector:c,targetIndex:s,referenceSelector:f,referenceDurableSelector:u,placement:d.placement,pathname:i}}function gn(e){return e instanceof HTMLElement&&(e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.isContentEditable===!0||e.getAttribute("contenteditable")==="true")}function aa(){if(typeof document>"u")return null;let e=document.activeElement;for(;e?.shadowRoot?.activeElement;)e=e.shadowRoot.activeElement;return e}function ft(e){let t=e.composedPath?.()[0]??e.target;return gn(t)||gn(aa())}function mn(e,t,n){if(n)return[n];let i=new Set(t),o=new Map;for(let a of e)a.groupId&&a.threadId&&o.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?o.get(a.groupId):void 0);l&&r.add(l)}return[...r]}function ra({state:e,stateRef:t,activeTextRef:n,selectedIdsRef:i,dispatch:o,clearSelection:r,selectAnnotation:a,handHoveredElement:l,onArchiveThread:d,openThreadId:s,currentPathname:c,hasOpenThread:h}){let u=le([]),f=le(0),y=le(null);V(()=>{let m=g=>{if(g.key==="Escape"){if(g.defaultPrevented||g.repeat||n.current||h||ft(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(),o({type:"DISCARD_DRAFT"});return}}if((g.metaKey||g.ctrlKey)&&g.key.toLowerCase()==="c"&&e.activeTool==="hand"&&l&&!n.current){if(Fe(l)){g.preventDefault();let w=J(l);y.current={source:l,sourceSelector:w,sourceDurableSelector:Q(l),sourceElement:{...We(l),selector:w}}}return}if((g.metaKey||g.ctrlKey)&&g.key.toLowerCase()==="v"&&e.activeTool==="hand"&&y.current&&!n.current){let w=y.current,v=l&&Fe(l)?l:w.source,I=v.parentElement;if(I){g.preventDefault();let b=Q(I),C=J(I),N=Q(v),z=J(v),A=ct(v)+1,T=w.source.cloneNode(!0);if(T instanceof Element){fn(T),ut(I,T,A);let X=J(T),oe=Q(T),ie={...We(T),selector:X};o({type:"MODIFY_DOM_STRUCTURE",payload:{id:dt(),operation:"copy",selector:X,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&&!n.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,I=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}))}));o({type:"PASTE_ANNOTATIONS",payload:{annotations:I}});let b=I.find(C=>C.type!=="text")??I[0];b&&a(b.id);return}let k=i.current;if(!n.current&&!ft(g)&&(g.key==="Delete"||g.key==="Backspace")&&!g.metaKey&&!g.ctrlKey&&!g.altKey){if(k.length===0&&!s)return;let w=mn(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)},[n,r,c,o,l,h,d,s,a,i,e.activeTool,t])}export{Eo as $,ue as A,Yo as Aa,Xi as B,qo as Ba,un as C,Ko as Ca,ea as D,Qo as Da,pt as E,ta as F,na as G,oa as H,Fe as I,J,ct as K,hn as L,ia as M,ft as N,mn as O,ra as P,Ue as Q,xe as R,Xe as S,wo as T,vo as U,bo as V,So as W,Io as X,$t as Y,_t as Z,zt as _,$e as a,ve as aa,Vo as b,Ze as ba,Go as c,Ao as ca,Jo as d,ne as da,an as e,nt as ea,dt as f,jt as fa,sn as g,ot as ga,Yi as h,Yt as ha,Xn as i,qt as ia,Qn as j,Lo as ja,Gn as k,Oo as ka,eo as l,Kt as la,to as m,Ut as ma,no as n,it as na,oo as o,at as oa,lo as p,be as pa,so as q,Do as qa,po as r,rt as ra,uo as s,pe as sa,fo as t,G as ta,ho as u,Vt as ua,go as v,Gt as va,Dt as w,Zt as wa,mo as x,en as xa,yo as y,tn as ya,xo as z,jo as za};
|
package/dist/chunk-4V7SK3M6.mjs
CHANGED
|
File without changes
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{c as v}from"./chunk-JQHZFDY5.mjs";import{a as P,l as R,h as $,j as x,k as g,i as b,m as y}from"./chunk-
|
|
2
|
+
import{c as v}from"./chunk-JQHZFDY5.mjs";import{a as P,l as R,h as $,j as x,k as g,i as b,m as y}from"./chunk-OLLUQ45J.mjs";import{v as A}from"./chunk-HGW2U6PD.mjs";var O="__popmelt_code_preview";function C(a,n){let t=new URL(a,n);if(t.origin!==new URL(n).origin||!/^https?:$/.test(t.protocol))throw new Error("Code previews must use the same application origin");return t.hash="",t.searchParams.delete("popmelt"),t.searchParams.set(O,"1"),t.href}function T(a,n){if(!new URL(location.href).searchParams.has(O))return!1;if(parent===window)return!0;window.__POPMELT_CODE_PREVIEW__?.dispose();let t=P,w="",s=!1,u=0,d=new Map,h=()=>{for(let[e,i]of d)i===null?e.removeAttribute("data-pm"):e.setAttribute("data-pm",i);d.clear()},r=new v(n?.get()??[]),m=()=>{for(let e of t.annotations)e.target&&r.resolve(e.target)},_=()=>{R(t.domModifications),$(t.styleModifications),x(t.textModifications),m();for(let e of t.annotations){let i=e.linkedSelector?.match(/^\[data-pm="([^"]+)"\]$/)?.[1];if(!i)continue;let o=A(e.linkedSelector,e.elements?.[0]);o&&(d.has(o)||d.set(o,o.getAttribute("data-pm")),o.setAttribute("data-pm",i))}},c=new MutationObserver(e=>{e.some(i=>i.addedNodes.length)&&(cancelAnimationFrame(u),u=requestAnimationFrame(()=>{c.disconnect(),_(),p()}))}),p=()=>c.observe(document.body,{childList:!0,subtree:!0}),E=()=>{let e=r;e.whenReady().then(()=>{!s&&r===e&&(m(),document.dispatchEvent(new Event("popmelt-subjects-ready")))})},L=n?.subscribe(()=>{r.destroy(),r=new v(n.get()),m(),E()});E();let f={dispose(){s||(s=!0,c.disconnect(),L?.(),r.destroy(),cancelAnimationFrame(u),window.removeEventListener("pagehide",f.dispose),window.__POPMELT_CODE_PREVIEW__===f&&delete window.__POPMELT_CODE_PREVIEW__,g(t.textModifications),b(t.styleModifications,!0),y(t.domModifications),h())},source:a,getSubjects:()=>r,update(e){if(s)throw new Error("Preview runtime closed");if(e.draft.source&&e.draft.source.sourceId!==a.sourceId)throw new Error("This draft belongs to a different source");let i=JSON.stringify([e.planeId,e.draft.revision,e.draft.source?.sourceId,e.draft.source?.revision]);if(w===i)return;let o=structuredClone(e.draft.state??P),l=M=>!M.pathname||M.pathname===location.pathname,I={...o,annotations:o.annotations.filter(l),styleModifications:o.styleModifications.filter(l),textModifications:o.textModifications.filter(l),domModifications:o.domModifications.filter(l)};c.disconnect(),g(t.textModifications),b(t.styleModifications,!0),y(t.domModifications),h(),t=I,_(),p(),w=i}};return window.__POPMELT_CODE_PREVIEW__=f,p(),window.addEventListener("pagehide",f.dispose,{once:!0}),!0}export{C as a,T as b};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{A as l,d as b,l as I,m as w,y as k}from"./chunk-
|
|
2
|
+
import{A as l,d as b,l as I,m as w,y as k}from"./chunk-LSPIP2IX.mjs";import{readFile as h,realpath as P,mkdir as x,writeFile as E}from"fs/promises";import{createHash as S}from"crypto";import{join as m,resolve as O}from"path";function N(t,e){let r=S("sha256").update(e).digest("hex");return m(t,".popmelt","participant-agents",r+".json")}async function M(t,e){if(e.storeId!==t.storeId)return{ok:!1,body:{status:"writable_store_required"}};if(typeof e.threadId!="string"||!e.threadId||typeof e.text!="string"||!e.text.trim()||e.text.length>8e3)return{ok:!1,body:{status:"invalid_note"}};let r;try{r=await v(t,t.sessionId,!0)}catch(a){if(a.code!=="ENOENT")throw a;return{ok:!1,body:{status:"participant_invitation_required"}}}if(!r)return{ok:!1,body:{status:"enrolled_bridge_required"}};let o=await l(r.endpoint,"/participants/thread-note",{...r.request,method:"POST",signal:AbortSignal.timeout(3e4),body:JSON.stringify({storeId:t.storeId,threadId:e.threadId,reply:e.text,sessionId:t.sessionId,requestId:e.requestId})});return{ok:o.response.ok,body:o.body}}async function v(t,e,r=!1){let o=await h(m(t.projectRoot,".popmelt","participant-bridge.json"),"utf8").then(JSON.parse).catch(c=>{if(c.code!=="ENOENT"||!t.bridgePort)throw c;return{projectId:t.projectId,port:t.bridgePort}});if(o.projectId!==t.projectId||!Number.isInteger(o.port)||o.port<1||o.port>65535)return null;let a={redirect:"error",signal:AbortSignal.timeout(3e3)},p=await l(o,"/status",a);if(!p.response.ok||p.body?.projectId!==t.projectId)return null;let i=N(t.projectRoot,e),n;try{n=JSON.parse(await h(i,"utf8"))}catch(c){if(c.code!=="ENOENT"||!r)throw c;let d=await P(t.projectRoot),u=b(e);if(w(d)!==t.projectId||!u)return null;let s=JSON.parse(await h(m(d,".popmelt","participant-host.json"),"utf8"));if(!(await l(o,"/participants/agent-join",{...a,method:"POST",headers:{"X-Popmelt-Participant-Id":s.participantId,"X-Popmelt-Participant-Token":s.token},body:JSON.stringify({sessionId:e,name:u,headless:!0})})).response.ok)return null;n=JSON.parse(await h(i,"utf8"))}return{endpoint:o,request:{...a,headers:{"X-Popmelt-Participant-Id":n.participantId,"X-Popmelt-Participant-Token":n.token}}}}async function F(t,e,r){let o=[t,...t.mountedStores].find(c=>c.storeId===e.storeId);if(!o||r&&o!==t)return{ok:!1,body:{status:"store_unavailable"}};if(r&&(typeof e.threadId!="string"||!e.threadId))return{ok:!1,body:{status:"thread_required"}};let a=await v(o,t.sessionId,r).catch(c=>{if(c.code==="ENOENT")return null;throw c});if(!a)return{ok:!1,body:{status:"enrolled_bridge_required",message:"Join this project as a Popmelt peer and check that its bridge is running."}};let{endpoint:p,request:i}=a,n=await l(p,r?t.sessionId.startsWith("claude:")?"/participants/link-claude-chat":"/participants/link-codex-chat":"/participants/check-claude-notes",{...i,method:"POST",body:JSON.stringify({sessionId:t.sessionId,...r?{threadId:e.threadId}:{}})});return{ok:n.response.ok,body:n.body}}async function _(t,e,r){if(!r.projectRoot)throw new Error("Participant connections require the active project root");let o=await P(r.projectRoot);if(w(o)!==t.projectId)throw new Error("Participant project does not match");let a=m(o,".popmelt"),p=S("sha256").update(e).digest("hex"),i=async(s,f,g)=>{let j=await l(t,"/participants/"+s,{method:"POST",redirect:"error",headers:{"X-Popmelt-Participant-Id":f.participantId,"X-Popmelt-Participant-Token":f.token},body:JSON.stringify(g),signal:AbortSignal.timeout(9e4)}),y=j.body;if(!j.response.ok||y.error)throw new Error(y.error??"Participant connection unavailable");return y},n,c;try{n=JSON.parse(await h(N(o,e),"utf8"))}catch(s){if(s.code!=="ENOENT")throw s;if(!r.name)return{status:"participant_invitation_required"};let f=JSON.parse(await h(m(a,"participant-host.json"),"utf8")),g=await i("agent-join",f,{sessionId:e,name:r.name});n=g.credential,c=g.participant}if(!r.action){let s=await i("agent-connect",n,{});return{status:"participant_connected",participantId:n.participantId,participant:s.participant??c}}let d=await i("agent-act",n,{action:I(r.action)}),u=d.evidence;if(u?.frame?.image){let s=u.frame.image;if(!/^data:image\/jpeg;base64,[A-Za-z0-9+/=]+$/.test(s)||s.length>7e5)throw new Error("Invalid participant preview");let f=m(a,"artifacts","participant-previews");await x(f,{recursive:!0,mode:448});let g=m(f,p+".jpg");return await E(g,Buffer.from(s.slice(s.indexOf(",")+1),"base64"),{mode:384}),{status:"participant_connected",participant:d.participant,evidence:{...u,frame:{imagePath:g,targets:u.frame.targets}}}}return{status:"participant_connected",participant:d.participant,evidence:d.evidence}}async function C(t,e,r={}){if(k())return{status:"already_managed_by_bridge"};if((await l(t,"/status",{redirect:"error",signal:AbortSignal.timeout(3e3)})).body?.participantSessions)return _(t,e,r);let a=async(c,d)=>{let u=await l(t,`/peers/${c}`,{method:"POST",body:JSON.stringify(d),signal:AbortSignal.timeout(5e4)}),s=u.body;if(!u.response.ok||s?.error)throw new Error(s?.error??"Peer connection unavailable");return s},p=await a("join",{sessionId:e,name:r.name}),i=r.action?await a("act",{token:p.token,clientId:r.clientId,action:I(r.action)}):p,n=i.peer;return{...i.status?{status:i.status}:{},...n?{peer:{...n,state:n.state?{annotations:n.state.annotations,styleModifications:n.state.styleModifications,textModifications:n.state.textModifications,undoDepth:n.state.undoStack.length,redoDepth:n.state.redoStack.length}:null}}:{},...i.evidence?{evidence:i.evidence}:{},clients:p.clients}}async function D(t){let e=c=>{let d=t.indexOf(c);return d>=0?t[d+1]:void 0},r=e("--session");if(!r)throw new Error("Usage: popmelt peer --session <stable-agent-session> [--project-root <active-project>] [--name <your-name>] [--client <canvas-id>] [--action <JSON>]");let o=await P(O(e("--project-root")??process.cwd())),a=JSON.parse(await h(m(o,".popmelt","bridge.lock"),"utf8")),p=w(o),i=await l({port:a.port,projectId:p},"/status",{signal:AbortSignal.timeout(3e3)});if(!i.response.ok||i.body.projectRoot!==o&&!(i.body.participantSessions&&i.body.projectId===p))throw new Error("No matching running project bridge");let n=e("--action");console.log(JSON.stringify(await C({port:a.port,projectId:p},r,{name:e("--name"),projectRoot:o,clientId:e("--client"),action:n?JSON.parse(n):void 0}),null,2))}export{N as a,M as b,v as c,F as d,C as e,D as f};
|