@popmelt.com/core 0.34.0 → 0.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/README.md +23 -863
  2. package/THIRD_PARTY_NOTICES.md +46 -0
  3. package/claude-plugin/.claude-plugin/plugin.json +1 -1
  4. package/codex-plugin/.codex-plugin/plugin.json +1 -1
  5. package/dist/ExploreAttachment-TTEKD4AU.mjs +1 -0
  6. package/dist/PagePreviewLayer-TJZOJBSD.mjs +1 -0
  7. package/dist/ParticipantRuntime-BQAOTSQZ.mjs +1 -0
  8. package/dist/PhoneHostGate-LNSDZOG2.mjs +1 -0
  9. package/dist/PopmeltTasteConnectedPane-NCCF7YUX.mjs +1 -0
  10. package/dist/{PreviewRuntime-EYKB7MG5.mjs → PreviewRuntime-H2UOLP6T.mjs} +1 -1
  11. package/dist/QueuedReplies-LQUBEZ6K.mjs +1 -0
  12. package/dist/SuppliedContext-YKQSMF3J.mjs +1 -0
  13. package/dist/ThreadErrorCard-4MOA34C4.mjs +1 -0
  14. package/dist/ThreadPanel-T6IXWFLA.mjs +1 -0
  15. package/dist/adapter-react-three-fiber.d.mts +1 -1
  16. package/dist/bridge-entry.mjs +1 -1
  17. package/dist/browser-runtime-HQM2Y6EL.mjs +1 -0
  18. package/dist/browser.d.mts +4 -4
  19. package/dist/browser.mjs +1 -1
  20. package/dist/{checkFixture-AMLLLJNS.mjs → checkFixture-BXILOUP5.mjs} +1 -1
  21. package/dist/{chunk-2ETPREWQ.mjs → chunk-66VOM5NA.mjs} +1 -1
  22. package/dist/chunk-APP5IYTE.mjs +1 -0
  23. package/dist/chunk-AYDREFWN.mjs +1 -0
  24. package/dist/chunk-CRJPE33X.mjs +1 -0
  25. package/dist/chunk-DC47WNPG.mjs +1 -0
  26. package/dist/chunk-DJTGR3RO.mjs +1 -0
  27. package/dist/chunk-DOJBWTT5.mjs +1 -0
  28. package/dist/chunk-F45IVFS3.mjs +1 -0
  29. package/dist/chunk-GKOMTSWV.mjs +1 -0
  30. package/dist/chunk-HU2XWUJC.mjs +1 -0
  31. package/dist/{chunk-MJ2PFKF3.mjs → chunk-KTRMNVPZ.mjs} +1 -1
  32. package/dist/{chunk-YXPRWW6B.mjs → chunk-M5P6VHZY.mjs} +1 -1
  33. package/dist/{chunk-QQB5G3VB.mjs → chunk-N4737FRL.mjs} +1 -1
  34. package/dist/{chunk-YTUQYKLM.mjs → chunk-NDGM4DAP.mjs} +1 -1
  35. package/dist/{chunk-GSEMSZDB.mjs → chunk-OAHYSDJ4.mjs} +1 -1
  36. package/dist/chunk-PYGRFSUU.mjs +1 -0
  37. package/dist/chunk-R34FOW4D.mjs +1 -0
  38. package/dist/{chunk-H2RLTCUJ.mjs → chunk-R3AJWOID.mjs} +1 -1
  39. package/dist/{chunk-RSUMSUAW.mjs → chunk-S7BCEQKP.mjs} +1 -1
  40. package/dist/{chunk-E5WNW4WE.mjs → chunk-T4CCY2EL.mjs} +1 -1
  41. package/dist/chunk-TH7DML4A.mjs +1 -0
  42. package/dist/chunk-UEGDSECJ.mjs +1 -0
  43. package/dist/chunk-WDAXARLI.mjs +1 -0
  44. package/dist/{chunk-Y6WD56SO.mjs → chunk-XG2YIAJS.mjs} +1 -1
  45. package/dist/chunk-Y3SF5YCR.mjs +1 -0
  46. package/dist/{chunk-BACXPVHP.mjs → chunk-ZG6XHKYO.mjs} +1 -1
  47. package/dist/chunk-ZG7MAEEV.mjs +30 -0
  48. package/dist/chunk-ZSL57PQ7.mjs +1 -0
  49. package/dist/cli.mjs +1 -1
  50. package/dist/codex-note-context-OUG4S6XE.mjs +1 -0
  51. package/dist/codex-project-B5466BL6.mjs +1 -0
  52. package/dist/focus-inspection-SZJ5KP23.mjs +1 -0
  53. package/dist/index.d.mts +5 -5
  54. package/dist/index.mjs +1 -1
  55. package/dist/media.d.mts +3 -3
  56. package/dist/{participantBootstrap-ClKpD2qC.d.mts → participantBootstrap-DFJlcKRI.d.mts} +2 -2
  57. package/dist/peer-client-SCSWLRCX.mjs +1 -0
  58. package/dist/plugin-astro.mjs +1 -1
  59. package/dist/plugin-nuxt.mjs +1 -1
  60. package/dist/plugin-vite.mjs +1 -1
  61. package/dist/server.d.mts +3 -3
  62. package/dist/server.mjs +1 -1
  63. package/dist/{steerStyles-VKQD57KC.mjs → steerStyles-E76E44PI.mjs} +1 -1
  64. package/dist/{subjects-EWAR5-0S.d.mts → subjects-DdavjSTL.d.mts} +12 -0
  65. package/dist/{video-adapter-BUMpNTCP.d.mts → video-adapter-DB6Hex1f.d.mts} +1 -1
  66. package/package.json +1 -3
  67. package/dist/ExploreAttachment-BG7ZOQSA.mjs +0 -1
  68. package/dist/PagePreviewLayer-CBDGPMJQ.mjs +0 -1
  69. package/dist/ParticipantRuntime-FSZX2PUQ.mjs +0 -1
  70. package/dist/PhoneHostGate-OM7FLOJ2.mjs +0 -1
  71. package/dist/PopmeltTasteConnectedPane-KJSBPJQR.mjs +0 -1
  72. package/dist/QueuedReplies-ZYUDSTS2.mjs +0 -1
  73. package/dist/SuppliedContext-7THB2WZY.mjs +0 -1
  74. package/dist/ThreadErrorCard-J2VTA5JW.mjs +0 -1
  75. package/dist/ThreadPanel-PNVMIIYJ.mjs +0 -1
  76. package/dist/browser-runtime-FFT5NH66.mjs +0 -1
  77. package/dist/chunk-3WSTAV5B.mjs +0 -1
  78. package/dist/chunk-67OWRNU3.mjs +0 -30
  79. package/dist/chunk-BFVLMSG5.mjs +0 -1
  80. package/dist/chunk-BJ25TGJN.mjs +0 -1
  81. package/dist/chunk-FMI4VQDZ.mjs +0 -1
  82. package/dist/chunk-GRPDZGPP.mjs +0 -1
  83. package/dist/chunk-JRP5XFYN.mjs +0 -1
  84. package/dist/chunk-LD3532UC.mjs +0 -1
  85. package/dist/chunk-MP6ZV2DN.mjs +0 -1
  86. package/dist/chunk-N66ZZG3L.mjs +0 -1
  87. package/dist/chunk-P4KM3K5M.mjs +0 -1
  88. package/dist/chunk-R3FPXDQS.mjs +0 -1
  89. package/dist/chunk-TRHC7WBO.mjs +0 -1
  90. package/dist/chunk-XSMCZUDR.mjs +0 -1
  91. package/dist/chunk-YC5CUNRU.mjs +0 -1
  92. package/dist/codex-note-context-NUKGR2WT.mjs +0 -1
  93. package/dist/codex-project-KE7ZZ6YX.mjs +0 -1
  94. package/dist/focus-inspection-BPPRCMNN.mjs +0 -1
  95. package/dist/peer-client-UQDASAO7.mjs +0 -1
  96. /package/dist/{chunk-G6RYESYI.mjs → chunk-6LBPTCGC.mjs} +0 -0
  97. /package/dist/{chunk-3GXLNBXU.mjs → chunk-XM6RE6HT.mjs} +0 -0
@@ -1 +0,0 @@
1
- "use client";import{c as e}from"./chunk-RK6UROPO.mjs";import{a as t}from"./chunk-G2ZHJXHZ.mjs";import{b as n}from"./chunk-G6RYESYI.mjs";import{c as o,b as i}from"./chunk-4LHTPRFY.mjs";import{a}from"./chunk-JRP5XFYN.mjs";import{g as r,a as l,f as d}from"./chunk-XT6PHPPG.mjs";import{n as s,h as c,i as p,o as u}from"./chunk-RR4SHK7O.mjs";import{a as f,c as h}from"./chunk-53SKVMWR.mjs";import{c as m,a as g}from"./chunk-57FM7XQV.mjs";import{a as y,b as v,c as x}from"./chunk-5K7SACPW.mjs";import{a as w,b}from"./chunk-LVEMYZOA.mjs";import{a as I,d as S,v as T,h as M,i as k,c as E,f as A,b as C,e as R,g as N}from"./chunk-WHJEKDNP.mjs";import{Eye as L,Clock as O,OctagonAlert as D,MessageCircleQuestionMark as $,TriangleAlert as P,Reply as _,SendHorizontal as F,CornerDownLeft as z}from"lucide-react";import{createContext as W,useContext as H,useState as B,useEffect as j,useLayoutEffect as Y,useId as K,useRef as q,useMemo as X,useCallback as V,useReducer as U,useSyncExternalStore as G}from"react";import{jsxs as Q,jsx as J,Fragment as Z}from"react/jsx-runtime";var ee,te=new Set;function ne(e){if(te.add(e),!ee){let e=new Map,t=new Map,n="",o=!0,i=!0,a=!1,r=!0,l=0,d=()=>{let n=new Set,a=new Map,r=t=>{if(n.add(t),!e.has(t)){let n=new MutationObserver(e=>{let t=e.filter(e=>!(1===e.target.nodeType?e.target:e.target.parentElement)?.closest("[data-devtools]"));t.length&&(o=!0),t.some(e=>"childList"===e.type)&&(i=!0)});n.observe(t,{subtree:!0,childList:!0,characterData:!0,attributes:!0});let a=()=>{o=!0};t.addEventListener("scroll",a,!0),t.addEventListener("load",a,!0),e.set(t,()=>{n.disconnect(),t.removeEventListener("scroll",a,!0),t.removeEventListener("load",a,!0)})}for(let e of t.querySelectorAll("*")){if(e.shadowRoot&&!e.closest("[data-devtools]")&&r(e.shadowRoot),"iframe"!==e.localName||e.closest("[data-devtools],[data-popmelt-peer-surface]"))continue;let t=C(e);a.set(e,t),t&&r(t)}};r(document);for(let[t,o]of e)n.has(t)||(o(),e.delete(t));t=a,i=!1,o=!0},s=()=>{if(!r)return;(i||[...t].some(([e,t])=>C(e)!==t))&&d();let e=[];for(let[n,o]of t){let t=n.getBoundingClientRect();e.push(o?.URL,t.x,t.y,t.width,t.height,o?.defaultView?.scrollX,o?.defaultView?.scrollY)}let c=JSON.stringify(e);if((o||c!==n)&&(o=!1,n=c,a))for(let e of te)e();a=!0,r&&(l=requestAnimationFrame(s))};s(),ee=()=>{r=!1,cancelAnimationFrame(l);for(let t of e.values())t()}}return()=>{te.delete(e),te.size||(ee?.(),ee=void 0)}}var oe=W(!0);function ie(e,t){let n=e.match(/^oklch\(([^)]+)\)$/i);if(n)return`oklch(${n[1]} / ${t})`;let o=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(o){return`rgba(${parseInt(o[1],16)}, ${parseInt(o[2],16)}, ${parseInt(o[3],16)}, ${t})`}return`color-mix(in srgb, ${e} ${Math.round(100*t)}%, transparent)`}function ae(e,t){let n=v(e),o=t.toLowerCase(),i=-1;for(let a=n.length-1;a>=0;a--){let r=n[a].name;if(r===t){let o=x(n[a].fiber)??e;return{name:t,path:n.map(e=>e.name),depthIndex:a,rootElement:o}}if(-1===i){let e=r.toLowerCase();(e.length>=4&&o.includes(e)||o.length>=4&&e.includes(o))&&(i=a)}}if(i>=0){let o=x(n[i].fiber)??e;return{name:t,path:n.map(e=>e.name),depthIndex:i,rootElement:o}}return null}function re(e){let t=de(),n=[],o=new Set,i=t.currentNode;for(;i=t.nextNode();){let t=ae(i,e);t&&!o.has(t.rootElement)&&(o.add(t.rootElement),n.push(t))}return n}function le(e){let t=new Map;if(0===e.size)return t;let n=new Set(e),o=de(),i=new Set,a=o.currentNode;for(;(a=o.nextNode())&&n.size>0;)for(let e of n){let o=ae(a,e);if(!o||i.has(o.rootElement))continue;i.add(o.rootElement);let r=o.rootElement.getBoundingClientRect();t.set(e,r.top+window.scrollY),n.delete(e);break}for(let e of n)t.set(e,1/0);return t}function de(){return document.createTreeWalker(document.body,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>e.closest("#devtools-toolbar, #devtools-canvas, #devtools-scrim, [data-popmelt-panel]")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT})}function se(e,t){return""!==e.style.getPropertyValue(t)}function ce(e){return"string"==typeof e?{value:e}:e}var pe={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 ue(e,t){let n=pe[t];return!!n&&n.includes(e)}function fe(e,t){let n=e.split(/\s+/);for(let e of n){if(e===t)return!0;let n=e.lastIndexOf(":");if(n>=0&&e.slice(n+1)===t)return!0}return!1}function he(e){let t=e.lastIndexOf(":"),n=t>=0?e.slice(t+1):e,o=n.indexOf("-");if(o<0)return null;let i=n.slice(0,o),a={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"};return a[n.slice(0,n.indexOf("-",o+1)>0?n.indexOf("-",o+1):o)]??a[i]??null}function me(e,t=30){let n=parseFloat(e.value);if(isNaN(n)||n<=0)return[];if(e.bindings&&e.bindings.length>0){let n=[],o=de(),i=o.currentNode;for(;(i=o.nextNode())&&n.length<t;){let t=i,o=t.getBoundingClientRect();if(o.bottom<-50||o.top>window.innerHeight+50||o.right<-50||o.left>window.innerWidth+50||o.width<1||o.height<1)continue;let a=t.className;if("string"==typeof a)for(let o of e.bindings){if(!fe(a,o))continue;let i=he(o);if(i&&(!e.property||ue(i,e.property))){n.push({element:t,property:i});break}}}return n}let o=function(e,t=30){if(e<=0)return[];let n=[],o=de(),i=.5,a=o.currentNode;for(;(a=o.nextNode())&&n.length<t;){let o=a,r=o.getBoundingClientRect();if(r.bottom<-50||r.top>window.innerHeight+50||r.right<-50||r.left>window.innerWidth+50||r.width<1||r.height<1)continue;let l=getComputedStyle(o);!se(o,"padding-top")&&Math.abs((parseFloat(l.paddingTop)||0)-e)<i&&n.push({element:o,property:"padding-top"}),!se(o,"padding-bottom")&&Math.abs((parseFloat(l.paddingBottom)||0)-e)<i&&n.length<t&&n.push({element:o,property:"padding-bottom"}),!se(o,"padding-left")&&Math.abs((parseFloat(l.paddingLeft)||0)-e)<i&&n.length<t&&n.push({element:o,property:"padding-left"}),!se(o,"padding-right")&&Math.abs((parseFloat(l.paddingRight)||0)-e)<i&&n.length<t&&n.push({element:o,property:"padding-right"}),!se(o,"margin-top")&&Math.abs((parseFloat(l.marginTop)||0)-e)<i&&n.length<t&&n.push({element:o,property:"margin-top"}),!se(o,"margin-bottom")&&Math.abs((parseFloat(l.marginBottom)||0)-e)<i&&n.length<t&&n.push({element:o,property:"margin-bottom"}),!se(o,"margin-left")&&Math.abs((parseFloat(l.marginLeft)||0)-e)<i&&n.length<t&&n.push({element:o,property:"margin-left"}),!se(o,"margin-right")&&Math.abs((parseFloat(l.marginRight)||0)-e)<i&&n.length<t&&n.push({element:o,property:"margin-right"});let d=l.display;if((d.includes("flex")||d.includes("grid"))&&n.length<t){let t=se(o,"gap"),a=parseFloat(l.gap)||0,r=parseFloat(l.rowGap)||0,d=parseFloat(l.columnGap)||0;!t&&Math.abs(a-e)<i?n.push({element:o,property:"gap"}):!se(o,"row-gap")&&Math.abs(r-e)<i?n.push({element:o,property:"row-gap"}):!se(o,"column-gap")&&Math.abs(d-e)<i&&n.push({element:o,property:"column-gap"})}}return n}(n,2*t);return e.property?o.filter(t=>ue(t.property,e.property)).slice(0,t):o.slice(0,t)}function ge(e,t){let n=new Set,o=we(t);for(let t of e){let e=be[t.property];if(!e)continue;let i=t.element.className;if("string"==typeof i)for(let t of e){let e=`${t}-${o}`;for(let t of i.split(/\s+/)){let o=t.lastIndexOf(":"),i=o>=0?t.slice(o+1):t;if(i===e){n.add(i);break}}}}return[...n]}function ye(e){let t=new Set;for(let n of e)for(let[e,o]of Object.entries(pe))if(o.includes(n.property)){t.add(e);break}if(1===t.size)return[...t][0]}function ve(e,t,n){if(t===n)return e;let o=we(t),i=we(n);return e.map(e=>{let n=e.lastIndexOf("-");if(n<0)return e;let a=e.slice(0,n),r=e.slice(n+1);return r===o||r===`[${t}px]`?`${a}-${i}`:e})}var xe={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 xe[e]??`[${e}px]`}var be={"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 Ie(e,t,n,o){let i=be[t];if(!i)return null;let a=we(n);for(let t of i){let i=new RegExp("(?:^|\\s)((?:[\\w-]+:)*"+t+"-(?:"+Se(a)+"|\\["+n+"px\\]))(?:\\s|$)"),r=e.match(i);if(r?.[1]){let e=we(o),n=r[1].lastIndexOf(":"),i=n>=0?r[1].slice(0,n+1):"";return{matched:r[1],suggested:`${i}${t}-${e}`}}}return null}function Se(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Te(e,t,n){let o=new Set,i=[];for(let a of e){let e=l(a.element),r=`${e}::${a.property}`;if(o.has(r))continue;o.add(r);let d=y(a.element),s=a.element.className||"",c=Ie(s,a.property,t,n);i.push({selector:e,reactComponent:d?.name,className:s,property:a.property,matchedClass:c?.matched,suggestedClass:c?.suggested})}return i}function Me(e){let t=e.startsWith("top-");return{top:t?4:12,right:4,bottom:t?12:4,left:4}}function ke({hasCommentEntry:e,stagedChangeCount:t}){return e&&0===t?2:6}function Ee({annotationNumber:e,stickerCount:t,interactionEpisodeStepCount:n,hasStatus:o,hasSend:i,controlGap:a}){let r=16+7.2*Math.max(1,void 0===e?0:String(e).length),l=28*t-2*Math.max(0,t-1),d=n>0?32+7.2*String(n).length:0,s=[t>0?t>0?l+(d>0?d-2:0)+(i?26:0):0:0,0===t?d:0,0===t&&i?28:0,o?28:0].filter(e=>e>0);return r+s.reduce((e,t)=>e+t,0)+s.length*a}function Ae(e,t,n){let o="right"===e.horizontalAlignment?e.left-t:e.left;return{left:o,top:e.top,right:o+t,bottom:e.top+n}}function Ce(e,t){return e.left<t.right&&e.right>t.left&&e.top<t.bottom&&e.bottom>t.top}function Re(e,t,n,o,i=0,a=Number.POSITIVE_INFINITY){if(e.height>=o)return{anchor:"top-left",horizontalAlignment:"left",left:e.left+8,top:e.top+8};let r=function(e,t,n){let o=Math.max(0,e.left+t-n);return Math.max(0,t-e.right)<o?"right":"left"}(e,i,a);return e.top>=t+n?{anchor:"right"===r?"top-right":"top-left",horizontalAlignment:r,left:"right"===r?e.right:e.left,top:e.top-t-n}:{anchor:"right"===r?"bottom-right":"bottom-left",horizontalAlignment:r,left:"right"===r?e.right:e.left,top:e.bottom+n}}function Ne(e){return e.left+e.width}function Le(e){return e.top+e.height}function Oe(e,t){if(0===e.length)return t;let n=Math.min(...e.map(e=>e.left)),o=Math.min(...e.map(e=>e.top));return{left:n,top:o,width:Math.max(...e.map(Ne))-n,height:Math.max(...e.map(Le))-o}}function De(e){let t=[...e].sort((e,t)=>e.top-t.top||e.left-t.left),n=[];for(let e of t){let t=e.top+e.height/2,o=n.find(n=>{let o=n.top+n.height/2;return Math.abs(t-o)<=.4*Math.max(n.height,e.height)});if(!o){n.push({...e});continue}let i=Math.min(o.left,e.left),a=Math.min(o.top,e.top),r=Math.max(Ne(o),Ne(e)),l=Math.max(Le(o),Le(e));o.left=i,o.top=a,o.width=r-i,o.height=l-a}return n.sort((e,t)=>e.top-t.top||e.left-t.left)}var $e={topLeft:"0px",topRight:"0px",bottomRight:"0px",bottomLeft:"0px"};function Pe(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&&e.fragments.every((e,n)=>{let o=t.fragments[n];return!!o&&e.left===o.left&&e.top===o.top&&e.width===o.width&&e.height===o.height})}function _e(e){if(!(e=u(e)??e).isConnected||!M(e.ownerDocument))return{fragments:[],radii:$e};let t=k(S(e),e.ownerDocument);if(I(e.ownerDocument)&&(!t.width||!t.height))return{fragments:[],radii:$e};if("true"===e.getAttribute("data-popmelt-subject-projection"))return{fragments:[{left:t.left,top:t.top,width:t.width,height:t.height}],radii:$e,outline:e.getAttribute("data-popmelt-subject-outline")??void 0};let n=Array.from(e.getClientRects()).map(t=>k(E(t,e.ownerDocument),e.ownerDocument)).filter(e=>e.width>0&&e.height>0).map(e=>({left:e.left,top:e.top,width:e.width,height:e.height}));return{fragments:De(n.length>0?n:[{left:t.left,top:t.top,width:t.width,height:t.height}]),radii:c(e)}}function Fe({element:t,projectedRect:o,isSelected:i=!1,elementInfo:a,color:r="#3b82f6",annotationNumber:l,changeCount:d,hideTooltip:c=!1,hideOutline:p=!1,hideFill:u=!1,fillOpacity:f=.05,subjectRegistry:h,railGap:m=2,railHeight:g=22,railWidth:y=0,renderRail:v,refreshKey:x,outlineZIndex:b=9996,onActivate:S,onRemove:T}){let M=H(oe),[k,E]=B({fragments:[],radii:$e});j(()=>{if(!M)return;if(!t)return void E({fragments:[],radii:$e});let n=null,o=()=>{let e=_e(t);E(t=>Pe(t,e)?t:e)},i=()=>{null===n&&(n=requestAnimationFrame(()=>{n=null,o()}))};o();let a=s(o),r="true"===t.getAttribute("data-popmelt-subject-projection")&&!!h,l=r?h.subscribeFrame(o):void 0,d=r||typeof ResizeObserver>"u"?null:new ResizeObserver(i);d?.observe(t);let c=r?null:new MutationObserver(i);c?.observe(t,{attributes:!0,attributeFilter:["style","class"]});let p=e(o,t.ownerDocument.defaultView??window),u=I(t.ownerDocument)?ne(o):void 0;return()=>{a(),p(),u?.(),l?.(),d?.disconnect(),c?.disconnect(),null!==n&&cancelAnimationFrame(n)}},[M,t,h]),Y(()=>{if(!M||!t||void 0===x)return;let e=_e(t);E(t=>Pe(t,e)?t:e)},[M,t,x]);let{fragments:A,radii:C}=o?{fragments:[o],radii:$e}:k;if(0===A.length||!t&&!o)return null;let R=Oe(A,A[0]),N=t?.tagName.toLowerCase()??"",L=t?.id?`#${t.id}`:"",O=t&&t.classList.length>0?"."+Array.from(t.classList).slice(0,2).join("."):"",D=a?.reactComponent,$=t?.getAttribute("data-popmelt-label")?.trim(),P=t?.getAttribute("data-popmelt-subject-adapter"),_=t?.getAttribute("data-popmelt-subject-label"),F=P&&_?`<${_}>`:$||(D?`<${D}> ${N}${L}${O}`:`${N}${L}${O}`),z=Re({left:R.left,right:R.left+R.width,top:R.top,bottom:R.top+R.height,height:R.height},g,m,window.innerHeight,y,window.innerWidth),W={zIndex:9997,display:"flex",alignItems:"center",gap:6,backgroundColor:r,color:"#fff",fontSize:12,fontFamily:n,lineHeight:"14px",padding:"4px 8px",borderRadius:8,pointerEvents:"none",whiteSpace:"nowrap",maxWidth:400,position:"fixed",top:z.top,left:z.left},K=!c&&Q("div",{ref:e=>{t&&w(t,e)},"data-devtools":"tooltip",style:W,children:[void 0!==l&&Q("span",{children:[l,"."]}),J("span",{style:{overflow:"hidden",textOverflow:"ellipsis",flex:1,minWidth:0},children:F}),void 0!==d&&d>0&&Q("span",{style:{opacity:.8},children:["(",d," ",1===d?"change":"changes",")"]})]});return Q(Z,{children:[!p&&A.map((e,t)=>J("div",{"data-devtools":"highlight",onContextMenu:T?e=>{e.preventDefault(),e.stopPropagation(),T()}:void 0,role:S?"button":void 0,tabIndex:S?0:void 0,"aria-label":S?"Open annotation thread":void 0,onPointerDown:S?e=>{e.preventDefault(),e.stopPropagation()}:void 0,onClick:S?e=>{e.preventDefault(),e.stopPropagation(),S()}:void 0,onKeyDown:S?e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),e.stopPropagation(),S())}:void 0,style:{position:"fixed",top:e.top,left:e.left,width:e.width,height:e.height,pointerEvents:S||T?"auto":"none",cursor:S?"pointer":void 0,zIndex:b,overflow:"visible"},children:J("div",{style:k.outline?{position:"absolute",inset:0,pointerEvents:"none"}:{position:"absolute",inset:0,boxSizing:"border-box",backgroundColor:u?"transparent":ie(r,f),borderColor:r,borderStyle:i?"solid":"dashed",borderWidth:1,borderTopLeftRadius:C.topLeft,borderTopRightRadius:C.topRight,borderBottomRightRadius:C.bottomRight,borderBottomLeftRadius:C.bottomLeft,pointerEvents:"none"},children:k.outline?J("svg",{viewBox:"0 0 1 1",preserveAspectRatio:"none",width:"100%",height:"100%",style:{display:"block",overflow:"visible"},"aria-hidden":"true",children:J("polygon",{points:k.outline,fill:u?"transparent":ie(r,f),stroke:r,strokeWidth:1,strokeDasharray:i?void 0:"4 3",vectorEffect:"non-scaling-stroke"})}):null})},`${e.left}:${e.top}:${t}`)),v?v(z,R):K]})}function ze(e=22){return{height:e,minHeight:e,maxHeight:e,boxSizing:"border-box",flexShrink:0}}var We=28;function He({threadId:e,color:n,size:o}){let i=H(t);if(!e||i?.preview?.threadId!==e)return null;let a=i.preview.enabled;return J("button",{type:"button","data-devtools":"explore-preview-badge","aria-label":"Preview option on page","aria-pressed":a,title:a?"Turn off page preview":"Preview option on page",onPointerDown:e=>{e.preventDefault(),e.stopPropagation()},onKeyDown:e=>e.stopPropagation(),onClick:t=>{t.preventDefault(),t.stopPropagation(),i.setPreview(t=>t&&t.threadId===e?{...t,enabled:!t.enabled,revealOnPage:!1}:t)},style:{...ze(o),appearance:"none",width:28,minWidth:28,padding:0,margin:0,border:0,display:"grid",placeItems:"center",cursor:"pointer",backgroundColor:n,color:"#fff",borderRadius:8,opacity:a?1:.5},children:J(L,{size:12,strokeWidth:2.25})})}function Be(e){return"bottom-left"===e?[2,8,8,8]:"bottom-right"===e?[8,2,8,8]:"top-right"===e?[8,8,2,8]:[8,8,8,2]}function je(e){return Be(e).map(e=>`${e}px`).join(" ")}var Ye=1.1666666666666667;function Ke(e){return e.length>2048?`${e.slice(0,2048)}…`:e}function qe(e,t,n){return t.flatMap(t=>function(e,t,n){let o=Ke(t);if(!o||e.measureText(o).width<=n)return[o];let i=o.split(/\s+/),a=[],r="";for(let t of i){let o=r?`${r} ${t}`:t;r&&e.measureText(o).width>n?(a.push(r),r=t):r=o}return r&&a.push(r),a.length>0?a:[o]}(e,t,n))}var Xe=n,Ve=16;function Ue(e){let t=window.innerWidth-e-16;return Math.max(60,Math.min(400,t))}function Ge(e,t,n){let o=Ke(t);if(o===t&&e.measureText(o).width<=n)return o;let i="…",a=0,r=o.endsWith(i)?o.length-1:o.length;for(;a<r;){let t=Math.ceil((a+r)/2);e.measureText(o.slice(0,t)+i).width<=n?a=t:r=t-1}return a>0?o.slice(0,a)+i:i}function Qe(e,t,n,o,i){let a=0,r=typeof window<"u"?window.innerHeight:9999;n&&function(e,t,n){if(void 0===e||void 0===t||void 0===n.avoidLeft&&void 0===n.avoidRight)return!0;let o=typeof window<"u"?window.innerWidth:9999,i=n.avoidLeft??0,a=n.avoidRight??o;return e+t>i&&e<a}(o,i,n)&&(a=n.avoidTop??a,r=n.avoidBottom??r);let l=Math.max(a,r-t);return Math.max(a,Math.min(e,l))}function Je(e,t=12,n,o){let i=t*Ye+8,a=e.y-4,r=Qe(a,i,n,e.x-8,o);return r===a?e:{...e,y:r+4}}function Ze(e,t,n,o,i=12,a,r,l,d="#dddddd",s,c=!1){if(!n)return;let p=i*Ye,u=n.replace(/\n/g," "),f=void 0!==a?a+". "+u:u;e.font=`${i}px ${Xe}`,e.textBaseline="middle";let h=void 0!==r?Math.min(400,Math.max(60,window.innerWidth-r-16)):400,m=c?16:0,g=Ge(e,f,Math.max(60,h-m)),y=m+e.measureText(g).width,v=Je(t,i,l,y+16);e.fillStyle=o;let x=v.x-8,w=v.y-4,b=y+16,I=p+8;e.beginPath(),e.roundRect(x,w,b,I,Be(s)),e.fill();let S=v.y+p/2;if(c){let t=v.x,n=S-6;e.strokeStyle=d,e.lineWidth=1.5,e.lineCap="round",e.lineJoin="round",e.beginPath(),e.moveTo(t+7.5,n+4),e.lineTo(t+10.5,n+6.5),e.lineTo(t+7.5,n+9),e.moveTo(t+1.5,n+1.5),e.lineTo(t+1.5,n+4.5),e.quadraticCurveTo(t+1.5,n+6.5,t+3.5,n+6.5),e.lineTo(t+10.5,n+6.5),e.stroke()}e.fillStyle=d,e.fillText(g,v.x+m,S)}function et(e,t,n){let o=e.filter(e=>!(e.captured||e.selector!==t||e.pathname&&e.pathname!==n));return o.length?{type:"MODIFY_TEXT_CONTENTS",payload:o.map(e=>({...e,modified:e.original}))}:null}function tt(e,t){return"text"===e.type&&(e.groupId?t.filter(t=>t.groupId===e.groupId):[e]).every(e=>"pending"===(e.status??"pending")&&!e.threadId)}var nt=W(0),ot="\n 0%, 100% { translate: 0 0; }\n 20% { translate: -4px 0; }\n 45% { translate: 4px 0; }\n 70% { translate: -2px 0; }\n 88% { translate: 1px 0; }\n";function it(e,t,n,o=.5){let i=Math.max(0,e-2*o),a=Math.max(0,t-2*o),r=function(e,t,n){let o=Math.max(0,n.topLeft),i=Math.max(0,n.topRight),a=Math.max(0,n.bottomRight),r=Math.max(0,n.bottomLeft),l=Math.min(1,e/Math.max(1,o+i),e/Math.max(1,r+a),t/Math.max(1,o+r),t/Math.max(1,i+a));return{topLeft:o*l,topRight:i*l,bottomRight:a*l,bottomLeft:r*l}}(e,t,n),l=Math.max(0,r.topLeft-o),d=Math.max(0,r.topRight-o),s=Math.max(0,r.bottomRight-o),c=Math.max(0,r.bottomLeft-o),p=o+i,u=o+a;return[`M ${o+l} ${o}`,"H "+(p-d),`A ${d} ${d} 0 0 1 ${p} ${o+d}`,"V "+(u-s),`A ${s} ${s} 0 0 1 ${p-s} ${u}`,`H ${o+c}`,`A ${c} ${c} 0 0 1 ${o} ${u-c}`,`V ${o+l}`,`A ${l} ${l} 0 0 1 ${o+l} ${o}`,"Z"].join(" ")}var at=12,rt=8;function lt(e){return e>0?16+7.2*String(e).length+16:0}function dt({stepCount:e,onClear:t,layered:n=!1,submitted:o=!1,style:i}){let[a]=m(),r=g[a];return e<1?null:Q("span",{"data-devtools":"interaction-episode-badge","data-popmelt-submitted":o?"true":void 0,"aria-label":`${e} recorded ${1===e?"action":"actions"}${o?", sent":""}`,onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),t?.()},style:{height:22,display:"inline-flex",alignItems:"center",boxSizing:"border-box",backgroundColor:o?"#8c8c8c":r.surface,border:`1px solid ${o?"#8c8c8c":r.border}`,borderRadius:8,color:o?"#dddddd":r.primary,fontFamily:Xe,fontSize:12,fontWeight:600,padding:n?`0 8px 0 ${.7*h}px`:"0 8px 0 5.6px",gap:4,pointerEvents:t?"auto":"none",WebkitMaskImage:n?f:void 0,maskImage:n?f:void 0,...i},children:[Q("svg",{"aria-hidden":!0,width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[J("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"}),J("path",{d:"M21 11V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h6"})]}),J("span",{children:e})]})}function st(e,t,n){return function(e,t,n){if(void 0===n.avoidLeft&&void 0===n.avoidRight)return!0;let o=typeof window<"u"?window.innerWidth:9999,i=n.avoidLeft??0,a=n.avoidRight??o;return e+t>i&&e<a}(t,n,e)?e:{}}function ct(e,t,n){return`translate(min(0px, calc(100vw - ${e} - 100%)), min(max(0px, calc(${void 0!==n.avoidTop?`${n.avoidTop}px`:"0px"} - ${t})), calc(${void 0!==n.avoidBottom?`${n.avoidBottom}px`:"100dvh"} - ${t} - 100%)))`}function pt(e,t,n){if(void 0===n.avoidTop&&void 0===n.avoidBottom)return e;let o=typeof window<"u"?window.innerHeight:9999,i=n.avoidTop??0,a=n.avoidBottom??o,r=Math.max(i,a-t);return Math.max(i,Math.min(e,r))}function ut({left:e,top:t,scrollX:n,scrollY:o,avoidTop:i,avoidBottom:a,style:r,children:l,...d}){return J("div",{"data-devtools":"badge-hit-area",...d,style:{position:"fixed",left:0,top:0,padding:at,...r,transform:`translate3d(${`calc(${e}px - var(--popmelt-scroll-x, ${n}px))`}, ${`calc(${t}px - var(--popmelt-scroll-y, ${o}px))`}, 0)`,willChange:"transform"},children:J("div",{style:{transform:ct(`calc(${e+at}px - var(--popmelt-scroll-x, ${n}px))`,`calc(${t+at}px - var(--popmelt-scroll-y, ${o}px))`,{avoidTop:i,avoidBottom:a})},children:l})})}function ft({bundleCount:e,style:t,layered:n=!1,compact:o=!1,description:i,replacementText:a,onHoverChange:r,onSend:l}){let[d,s]=B(!1),[c]=m(),p=g[c],u=H(nt),y=K(),v=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/.test(navigator.platform)?"⌘":"Ctrl",x=Math.max(1,e),w=o&&!d,b=e=>w?J(F,{size:12,strokeWidth:2,"aria-hidden":!0}):Q(Z,e?{children:[J("span",{style:{color:"inherit",fontWeight:600},children:x>1?`Send all ${x}`:"Send"}),J(F,{size:12,strokeWidth:2,"aria-hidden":!0})]}:{children:[Q("span",{style:{display:"inline-flex",alignItems:"center",gap:2,color:"inherit",fontWeight:600},children:[J("span",{children:v}),J("span",{children:"+"}),J(z,{size:12,strokeWidth:2,"aria-hidden":!0})]}),J("span",{style:{color:p.secondary,fontWeight:600},children:"to"}),J(F,{size:12,strokeWidth:2,"aria-hidden":!0}),x>1&&J("span",{style:{color:"inherit",fontWeight:600},children:x})]}),I=e=>Q(Z,{children:[J("span",{className:"popmelt-send-hint-desktop",style:{alignItems:"center",gap:4},children:b(e)}),Q("span",{className:"popmelt-send-hint-mobile",style:{alignItems:"center",gap:4},children:[!w&&J("span",{style:{color:"inherit",fontWeight:600},children:"Send"}),J(F,{size:12,strokeWidth:2,"aria-hidden":!0})]})]}),S=a?J("span",{role:"tooltip","data-devtools":"parent-pinned-location-tooltip",style:{overflow:"hidden",textOverflow:"ellipsis"},children:a}):null,T={...ze(),lineHeight:"14px",display:"flex",alignItems:"center",boxSizing:"border-box",backgroundColor:p.surface,border:`1px solid ${p.border}`,fontFamily:Xe,fontSize:12,color:p.primary,userSelect:"none",padding:n?`0 8px 0 ${h}px`:"0 8px",gap:4,whiteSpace:"nowrap",borderRadius:8,letterSpacing:"0.24px",WebkitMaskImage:n?f:void 0,maskImage:n?f:void 0},M=x>1?`Send all ${x} pending annotations`:"Send pending annotation";return Q("div",{"data-devtools":"send-hint-hit-area","data-popmelt-send-rejection":u?u%2?"odd":"even":void 0,onMouseEnter:()=>{s(!0),r?.(!0)},onMouseLeave:()=>{s(!1),r?.(!1)},style:{display:"grid",width:"max-content",...t},children:[J("style",{children:`\n@keyframes popmelt-send-rejection-odd { ${ot} }\n@keyframes popmelt-send-rejection-even { ${ot} }\n[data-popmelt-send-rejection="odd"] { animation: popmelt-send-rejection-odd 220ms ease-out; }\n[data-popmelt-send-rejection="even"] { animation: popmelt-send-rejection-even 220ms ease-out; }\n@media (prefers-reduced-motion: reduce) {\n [data-popmelt-send-rejection] { animation: none; }\n}\n.popmelt-send-hint-desktop { display: inline-flex; }\n.popmelt-send-hint-mobile { display: none; }\n@media (max-width: 767px) {\n .popmelt-send-hint-desktop { display: none; }\n .popmelt-send-hint-mobile { display: inline-flex; }\n}\n `}),J("div",{"aria-hidden":!0,style:{...T,gridArea:"1 / 1",visibility:"hidden"},children:I(!1)}),Q("button",{type:"button","data-devtools":"annotation-badge","aria-label":M,"aria-describedby":i?y:void 0,disabled:!l,onPointerDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>{e.preventDefault(),e.stopPropagation(),l?.()},style:{...T,gridArea:"1 / 1",justifySelf:"start",maxWidth:a?"min(320px, calc(100vw - 16px))":void 0,overflow:a?"hidden":void 0,appearance:"none",margin:0,opacity:1,cursor:l?"pointer":"default",touchAction:"manipulation"},children:[i&&J("span",{id:y,style:{position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:0},children:i}),S??I(d)]})]})}function ht({count:e,color:t,size:n=22,onHoverChange:o}){return Q("div",{"data-devtools":"nested-annotation-count-badge",onMouseEnter:()=>o?.(!0),onMouseLeave:()=>o?.(!1),style:{height:n,display:"flex",alignItems:"center",backgroundColor:t,color:"#8c8c8c"===t?"#dddddd":"#ffffff",fontFamily:Xe,fontSize:12,fontWeight:600,lineHeight:1,padding:"0 8px",borderRadius:8,userSelect:"none",whiteSpace:"nowrap"},children:["+",e]})}function mt({annotations:e,supersededAnnotations:n,inFlightIds:o,orientationLabels:i,activeIds:a,queuePositions:r,scrollX:l,scrollY:d,annotationGroupMap:s,onViewThread:c,onSelectAnnotation:p,onDeleteDraftAnnotation:u,onClearInteractionEpisode:f,onHoverAnnotation:h,canvasRef:m,toolbarRef:g,activeBundleAnnotationIds:y,inactiveBundleOpacity:v=.5,animateBundleOpacity:x=!0,hoverRestoredAnnotationIds:w,nestedAnnotationCountById:b,nestedAnnotationIdsById:I,onHoverNestedAnnotations:S,onHoverSendBundle:T,onSend:M,sendHintAnchorId:k,pendingBundleCount:E=1,parentPinnedAnnotationIds:A,parentPinnedLocationLabels:C,parentPinnedTooltipAnnotationId:R,onActivateAnnotation:N,hiddenAnnotationIds:L,displayAnnotations:F}){let z=H(t),W=H(oe),Y=q(null),[K,X]=B(0),V=!!(o&&o.size>0&&(void 0===a||a.size>0));j(()=>{if(!V||!W)return;let e=setInterval(()=>{X(e=>(e+1)%3)},250);return()=>{clearInterval(e)}},[V,W]),j(()=>{if(!W)return;let e=Y.current;if(!e)return;let t=()=>{e.style.setProperty("--popmelt-scroll-x",`${window.scrollX}px`),e.style.setProperty("--popmelt-scroll-y",`${window.scrollY}px`)};return t(),window.addEventListener("scroll",t,{passive:!0,capture:!0}),window.addEventListener("resize",t),()=>{window.removeEventListener("scroll",t,!0),window.removeEventListener("resize",t)}},[W]);let U=[],G=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/.test(navigator.platform)?"⌘":"Ctrl";for(let t of e){if("text"!==t.type||!t.text||!t.points[0]||n.has(t)||L?.has(t.id))continue;let r=t.groupId?e.filter(e=>e.groupId===t.groupId):[t],d=t.status??"pending",c=E>0&&t.id===k,p=t.interactionEpisode?.steps.length??0,u=b?.get(t.id)??0,f=I?.get(t.id)??[],h=r.reduce((e,t)=>Math.max(e,t.replyCount??0),0),g="sending"===d||r.some(e=>"sending"===e.status),v="awaiting_review"===d,x=!g&&(!(!o||!o.has(t.id)&&!r.some(e=>o.has(e.id)))||"in_flight"===t.status||r.some(e=>"in_flight"===e.status)),S=r.some(e=>"resolved"===e.status&&(e.replyCount??0)>0||"needs_review"===e.status),T=r.some(e=>e.threadId),M=!y||r.some(e=>y.has(e.id)||w?.has(e.id));if(!(c||g||v||x||"resolved"===d||"failed"===d||"needs_review"===d||S||T||p>0)&&0===u)continue;let C=t.threadId||r.find(e=>e.threadId)?.threadId,R="needs_review"===d||r.some(e=>"needs_review"===e.status),N="waiting_input"===d||r.some(e=>"waiting_input"===e.status),O="failed"===d||r.some(e=>"failed"===e.status),D=c||g||v||x||R||N||O||h>0||"resolved"===d&&T||p>0;if(!D&&0===u)continue;let $=t.points[0],P=t.fontSize||12,_=P*Ye,z=s.get(t.id),W=((F?.find(e=>e.id===t.id)??t).text??t.text).replace(/\n/g," "),H=void 0!==z?z+". "+W:W,B=m?.current?.getContext("2d")??document.createElement("canvas").getContext("2d");if(!B)continue;B.font=`${P}px ${Xe}`;let j=$.x-l,Y=A?.has(t.id)?16:0,K=Ge(B,H,Math.max(60,Ue(j)-Y)),q=B.measureText(K).width,X=x&&!!a&&!a.has(t.id)&&!r.some(e=>a.has(e.id));U.push({id:t.id,threadId:C,linkedSelector:t.linkedSelector||r.find(e=>e.linkedSelector)?.linkedSelector,x:$.x+q+Y+8+2,y:$.y-4,size:_+8,color:c?"#000000":t.color,isSending:g,isAwaitingReview:v,isInFlight:x,orientationLabel:i?.get(t.id)??r.map(e=>i?.get(e.id)).find(Boolean),isQueued:X,queuePosition:void 0,isNeedsReview:R,isQuestion:N,isFailed:O,replyCount:h>0?h:"resolved"===d&&T?1:0,isInActiveBundle:M,isSendHint:c,interactionEpisodeStepCount:p,interactionEpisodeSubmitted:"pending"!==d,nestedCount:u,nestedAnnotationIds:f,nestedColor:"pending"===d?t.color:"#8c8c8c",showActionBadge:D,canDeleteDraft:tt(t,e)})}let ee=U.filter(e=>e.isQueued);if(ee.length>0&&ee.forEach((e,t)=>{e.queuePosition=r?.get(e.id)??`(${t+1}/${ee.length})`}),0===U.length)return null;let te=m?.current?.getContext("2d")??document.createElement("canvas").getContext("2d"),ne=U.map(e=>{te&&(te.font=`12px ${Xe}`);let t=e.nestedCount>0?(te?.measureText(`+${e.nestedCount}`).width??7.2*String(e.nestedCount).length+7.2)+16:0,n=lt(e.interactionEpisodeStepCount),o=e.threadId&&z?.preview?.threadId===e.threadId?30:0;if(!e.showActionBadge)return t+n+o;let i,a=R===e.id?C?.get(e.id):void 0;i=a||(e.isSendHint?G:e.isSending?"Sending":e.isAwaitingReview?"Awaiting review":e.isInFlight?e.isQueued?"Queued"+(e.queuePosition?` ${e.queuePosition}`:""):e.orientationLabel??"Thinking":e.isQuestion?"Question":e.isFailed?"Failed":e.replyCount>0?"Replied":"Needs decision");let r=e.isSendHint||a?0:12,l=7.2*i.length;te&&(l=te.measureText(i).width);let d=e.isSendHint&&te?te.measureText("to").width:e.isSendHint?14.4:0,s=e.isSendHint&&te?te.measureText("+").width:e.isSendHint?7.2:0,c=e.isSendHint&&E>1&&te?te.measureText(String(E)).width:e.isSendHint&&E>1?7.2:0;return n+t+(a?Math.min(l+16,320):e.isSendHint?l+s+d+c+16+12+12+4+4*(E>1?3:2):6+r+4+l+8)+2*(+(n>0)+ +(t>0)+1-1)+o}),ie=function(e){let t=e?.current?.getBoundingClientRect();return!t||typeof window>"u"?{}:t.top<window.innerHeight/2?{avoidTop:t.bottom+8,avoidLeft:t.left-8,avoidRight:t.right+8}:{avoidBottom:t.top-8,avoidLeft:t.left-8,avoidRight:t.right+8}}(g),ae=[];for(let e=0;e<U.length;e++){let t=U[e].y-d,n=U[e].x-l,o=st(ie,n,ne[e]),i=pt(t,U[e].size,o),a=i+U[e].size,r=n;for(let t=0;t<e;t++){let e=U[t].y-d,n=st(ie,ae[t],ne[t]),o=pt(e,U[t].size,n);if(!(i<o+U[t].size&&a>o))continue;let l=ae[t]+ne[t];r<l+2&&(r=l+2)}ae.push(r)}return Q("div",{ref:Y,"data-devtools":"annotation-badge-layer",style:{position:"fixed",inset:0,pointerEvents:"none",zIndex:9999,"--popmelt-scroll-x":`${l}px`,"--popmelt-scroll-y":`${d}px`},children:[J("style",{dangerouslySetInnerHTML:{__html:'\n[data-devtools="annotation-badge-layer"] [data-devtools="annotation-badge"]::selection,\n[data-devtools="annotation-badge-layer"] [data-devtools="annotation-badge"] *::selection {\n background: #000000;\n color: #ffffff;\n}\n'}}),U.map((e,t)=>{let n=!!e.threadId,o=C?.get(e.id),i=!!o&&R===e.id,a=n||!!o,r=!!e.threadId&&z?.preview?.threadId===e.threadId,s=e.showActionBadge&&e.isSendHint||r,m=a&&!s,g=()=>{N?N(e.id,e.threadId):(p?.(e.id),e.threadId&&c?.(e.threadId))},y=st(ie,ae[t],ne[t]);return J(ut,{left:ae[t]+l-at,top:e.y-at,scrollX:l,scrollY:d,avoidTop:y.avoidTop,avoidBottom:y.avoidBottom,onMouseDown:e=>e.stopPropagation(),onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),e.canDeleteDraft&&u&&u(e.id)},onClick:a?e=>{e.stopPropagation(),g()}:void 0,onMouseEnter:()=>{h?.(e.id)},onMouseLeave:()=>{h?.(null)},onFocus:()=>h?.(e.id),onBlur:()=>h?.(null),onKeyDown:m?e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),g())}:void 0,role:m?"button":void 0,tabIndex:m?0:void 0,"aria-label":m&&o?`${o}. Activate to reveal the annotation source${n?" and open its thread":""}`:void 0,style:{pointerEvents:"auto",cursor:a?"pointer":void 0,zIndex:9999,minWidth:e.isSendHint?ne[t]:void 0},children:Q("div",{style:{position:"relative",display:"flex",alignItems:"center",gap:2},children:[J(dt,{stepCount:e.interactionEpisodeStepCount,submitted:e.interactionEpisodeSubmitted,onClear:e.canDeleteDraft&&f?()=>f(e.id):void 0}),e.nestedCount>0&&J(ht,{count:e.nestedCount,color:e.nestedColor,size:e.size,onHoverChange:t=>S?.(e.id,t?e.nestedAnnotationIds:null)}),J(He,{threadId:e.threadId,color:e.color,size:e.size}),e.showActionBadge&&(e.isSendHint?J(ft,{bundleCount:E,description:o?`${o}. Activate the annotation label to reveal its source.`:void 0,replacementText:i?o:void 0,onHoverChange:T,onSend:M}):J("div",{"data-devtools":"annotation-badge",style:{...ze(e.size),display:"flex",alignItems:"center",backgroundColor:e.color,fontFamily:Xe,fontSize:12,color:"#ffffff",userSelect:"none",padding:"0 8px 0 6px",gap:4,whiteSpace:"nowrap",maxWidth:i?"min(320px, calc(100vw - 16px))":void 0,overflow:i?"hidden":void 0,borderRadius:8,opacity:e.isInActiveBundle?1:v,transition:x?"opacity 120ms ease-out":"none"},children:i?J("span",{role:"tooltip","data-devtools":"parent-pinned-location-tooltip",style:{overflow:"hidden",textOverflow:"ellipsis"},children:o}):e.isAwaitingReview?Q(Z,{children:[J(O,{size:12,strokeWidth:2.25}),"Awaiting review"]}):e.isQueued?Q("span",{style:{opacity:.6,color:"inherit",display:"inline-flex",alignItems:"center",gap:4},children:[J(O,{size:12,strokeWidth:2.25}),"Queued",e.queuePosition?` ${e.queuePosition}`:""]}):e.isSending||e.isInFlight?Q(Z,{children:["Approval needed"===e.orientationLabel?J(D,{size:12,"aria-label":"Approval needed"}):J("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",style:{verticalAlign:"middle",opacity:.6},children:Q(Z,1===K?{children:[J("circle",{cx:"7",cy:"7",r:"2"}),J("circle",{cx:"17",cy:"7",r:"2"}),J("circle",{cx:"7",cy:"17",r:"2"}),J("circle",{cx:"17",cy:"17",r:"2"})]}:{children:[J("circle",{cx:"12",cy:"6",r:"2"}),J("circle",{cx:"6",cy:"12",r:"2"}),J("circle",{cx:"18",cy:"12",r:"2"}),J("circle",{cx:"12",cy:"18",r:"2"})]})}),J("span",{style:{opacity:.6,color:"inherit"},children:e.isSending?"Sending":e.isQueued?"Queued"+(e.queuePosition?` ${e.queuePosition}`:""):e.orientationLabel??"Thinking"})]}):Q(Z,{children:[e.isQuestion?J($,{size:12,strokeWidth:2.25}):e.isFailed?J(P,{size:12,strokeWidth:2.25}):e.replyCount>0?J(_,{size:12,strokeWidth:2.25}):Q("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[J("path",{d:"M18 8a6 6 0 0 0-12 0c0 7-3 7-3 9h18c0-2-3-2-3-9"}),J("path",{d:"M10 21h4"})]}),J("span",{style:{color:"inherit"},children:e.isQuestion?"Question":e.isFailed?"Failed":e.replyCount>0?"Replied":"Needs decision"})]})}))]})},e.id)})]})}function gt({d:e,color:t,animated:n}){let a=q(null);return Y(()=>{let e=a.current;if(!e||"function"!=typeof e.getTotalLength)return;let t=function(e){if(Number.isFinite(e)&&!(e<=0))return Math.max(1,Math.round(e/o))*o}(e.getTotalLength());void 0===t?e.removeAttribute("pathLength"):e.setAttribute("pathLength",String(t))},[e]),J("path",{ref:a,d:e,fill:"none",stroke:t,strokeWidth:1,strokeDasharray:n?i:void 0,"data-popmelt-marching-stroke":n||void 0,style:n?{animation:"popmelt-march 0.6s linear infinite"}:void 0})}function yt(){return J("style",{children:`\n @keyframes popmelt-march {\n from { stroke-dashoffset: 0; }\n to { stroke-dashoffset: -${o}; }\n }\n @media (prefers-reduced-motion: reduce) {\n [data-popmelt-marching-stroke="true"] { animation: none !important; }\n }\n `})}function vt({annotations:e,activeIds:t,scrollX:n,scrollY:o,spotlightIds:i,emphasizedIds:a,hoverRestoredIds:r,inactiveOpacity:l=.5}){if(!H(oe))return null;let d=e.filter(e=>e.region&&e.region.points.length>=3&&t?.has(e.id));return d.length?Q(Z,{children:[J(yt,{}),J("svg",{"data-devtools":"marching-lasso","aria-hidden":!0,style:{position:"fixed",inset:0,width:"100%",height:"100%",pointerEvents:"none",zIndex:9995,overflow:"visible"},children:J("g",{transform:`translate(${-n} ${-o})`,children:d.map(e=>{let t=i?.size?i.has(e.id)?1:.2:!a||a.has(e.id)||r?.has(e.id)?1:l;return J("g",{"data-popmelt-region-id":e.id,opacity:t,children:J(gt,{d:`${e.region.points.map((e,t)=>`${t?"L":"M"}${e.x} ${e.y}`).join(" ")} Z`,color:e.color,animated:!0})},e.id)})})})]}):null}function xt({inFlightSelectorColors:e,animated:t=!0,subjectRegistry:n,selectorElementInfo:o}){let i=H(oe),[a,r]=B([]);return j(()=>{if(!i)return;if(0===e.size)return void r([]);let t=null,a=()=>{let t=[];for(let[n,i]of e){let e=T(n,o?.get(n));if(!e)continue;let a=S(e);t.push({selector:n,top:a.top,left:a.left,width:a.width,height:a.height,color:i,radius:p(e),radiusStyle:c(e)})}r(t)},l=()=>{t&&cancelAnimationFrame(t),t=requestAnimationFrame(a)};a(),window.addEventListener("scroll",l,!0),window.addEventListener("resize",l,!0);let d=new MutationObserver(l);d.observe(document.body,{attributes:!0,childList:!0,subtree:!0,attributeFilter:["style","class"]});let s=n?.subscribeFrame(a),u=[...e.keys()].some(e=>e.startsWith("@frame("))?ne(a):void 0;return()=>{window.removeEventListener("scroll",l,!0),window.removeEventListener("resize",l,!0),d.disconnect(),s?.(),u?.(),t&&cancelAnimationFrame(t)}},[e,n,o,i]),0===a.length?null:Q(Z,{children:[t&&J(yt,{}),a.map(e=>J("div",{"data-devtools":"marching-ants",style:{position:"fixed",top:e.top,left:e.left,width:e.width,height:e.height,pointerEvents:"none",zIndex:9995,overflow:"visible",borderTopLeftRadius:e.radiusStyle.topLeft,borderTopRightRadius:e.radiusStyle.topRight,borderBottomRightRadius:e.radiusStyle.bottomRight,borderBottomLeftRadius:e.radiusStyle.bottomLeft},children:J("svg",{style:{position:"absolute",inset:0,width:"100%",height:"100%",overflow:"visible"},children:J(gt,{d:it(e.width,e.height,{topLeft:e.radius["top-left"],topRight:e.radius["top-right"],bottomRight:e.radius["bottom-right"],bottomLeft:e.radius["bottom-left"]}),color:e.color,animated:t})})},e.selector))]})}function wt({element:e,elements:t,registry:n,label:o="Looking",engaged:i=!0,outlineColor:a,inverse:r=!1}){let l=q(0),d=X(()=>t??(e?[e]:[]),[t,e]),[s,c]=B(()=>d.map(e=>({target:e,id:++l.current,animateEntrance:!0,exiting:!1}))),p=V(e=>{c(t=>t.filter(t=>t.id!==e))},[]);return j(()=>{d.length&&c(e=>{let t=e.some(({target:e})=>e.isConnected),n=d.map(n=>e.find(e=>e.target===n&&!e.exiting)??{target:n,id:++l.current,animateEntrance:!t,exiting:!1});return[...e.filter(e=>!e.exiting&&!d.includes(e.target)).map(e=>({...e,exiting:!0})),...n]})},[d]),J(Z,{children:s.map(({target:e,id:t,animateEntrance:l,exiting:s})=>J(bt,{id:t,element:i&&d.includes(e)?e:null,target:e,animateEntrance:l,exiting:s,registry:n,label:o,outlineColor:a,inverse:r,onDone:p},t))})}function bt({id:e,element:t,target:o,animateEntrance:i,exiting:a,registry:r,label:l,outlineColor:d,inverse:s,onDone:c}){let[p]=m(),u=g[p],f=o,[h,y]=B(!1),v=q(Date.now()),[x,w]=B(null);return j(()=>{if(!f)return;let e,t=()=>{let n=b(f);w(e=>n?e?.left===n.left&&e.top===n.top?e:{left:n.left,top:n.top}:null),e=requestAnimationFrame(t)};return t(),()=>cancelAnimationFrame(e)},[f]),j(()=>{let n,o;return a?o=setTimeout(()=>c(e),200):t?(v.current=Date.now(),y(!1)):n=setTimeout(()=>{y(!0),o=setTimeout(()=>c(e),300)},Math.max(0,v.current+1700-Date.now())),()=>{clearTimeout(n),clearTimeout(o)}},[t,a,e,c]),f?.isConnected?Q(Z,{children:[J("style",{children:'\n @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); } }\n @keyframes popmelt-looking-out-left { from { opacity: 1; } to { opacity: 0; } }\n @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); } }\n @keyframes popmelt-looking-in-alone-up-left { from { opacity: 0; transform: translate(8px, 8px); } to { opacity: 1; transform: translate(0, 0); } }\n @keyframes popmelt-looking-in-alone-down-left { from { opacity: 0; transform: translate(8px, -8px); } to { opacity: 1; transform: translate(0, 0); } }\n @keyframes popmelt-looking-in-alone-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }\n @keyframes popmelt-looking-in-alone-down { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }\n @keyframes popmelt-looking-out-up { from { opacity: 1; } to { opacity: 0; } }\n @keyframes popmelt-looking-fade-in { from { opacity: 0; } to { opacity: 1; } }\n @keyframes popmelt-looking-fade-out { from { opacity: 1; } to { opacity: 0; } }\n @keyframes popmelt-looking-blink { 0%, 40%, 72.5%, 100% { transform: scaleY(1); } 50%, 62.5% { transform: scaleY(0.1); } }\n .popmelt-looking-eye { animation: popmelt-looking-blink 1000ms 200ms both; transform-origin: center; }\n @media (prefers-reduced-motion: reduce) {\n [data-devtools="focus-inspection"], .popmelt-looking-eye { animation: none !important; }\n [data-popmelt-looking-exiting] { opacity: 0 !important; }\n }\n '}),J(Fe,{element:f,subjectRegistry:r,hideOutline:!d||h||a,color:d,outlineZIndex:d?10002:void 0,hideFill:!0,hideTooltip:!0,railHeight:22,renderRail:(e,t)=>{let o=x??e,r=o.left>=28,d=!x&&e.anchor.startsWith("bottom-"),c=x?r?"left":"up":`${d?"down":"up"}${r?"-left":""}`,p=x&&!r?Math.max(4,o.top-22-2):o.top,m=r?o.left-22-2:o.left,g=t.left+t.width/2>=m+11,y=t.top+t.height/2>=p+11?g?"borderBottomRightRadius":"borderBottomLeftRadius":g?"borderTopRightRadius":"borderTopLeftRadius";return J("div",{"data-devtools":"focus-inspection","data-popmelt-looking-exiting":a?"true":void 0,"data-popmelt-canvas-block":!0,role:"status","aria-live":a?"off":"polite","aria-hidden":a||void 0,"aria-label":l,title:l,style:{position:"fixed",animation:a?"popmelt-looking-fade-out 200ms ease both":h||i?`popmelt-looking-${h?"out":x?"in":"in-alone"}-${h?r?"left":"up":c} ${h?300:200}ms ease both`:"popmelt-looking-fade-in 200ms ease both",left:m,top:p,height:22,width:22,boxSizing:"border-box",display:"inline-flex",alignItems:"center",justifyContent:"center",backgroundColor:s?u.actionSurface:u.surface,color:s?u.actionForeground:u.primary,border:`1px solid ${s?u.actionHover:u.border}`,borderTopLeftRadius:8,borderTopRightRadius:8,borderBottomLeftRadius:8,borderBottomRightRadius:8,...x?{}:{[y]:2},fontFamily:n,fontSize:12,letterSpacing:"0.24px",whiteSpace:"nowrap",pointerEvents:a?"none":"auto",zIndex:f.hasAttribute("data-popmelt-thread-header")?10006:10002},children:J(L,{className:i&&!a?"popmelt-looking-eye":void 0,size:12,"aria-hidden":!0})})}})]}):null}var It={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:[" "]}},St=[{type:"model",label:"Imprint",shortcut:"I"},{type:"sticker",label:"Steer",shortcut:"S"},{type:"inspector",label:"Chat",shortcut:"C"}];function Tt(e){let t=e.toLowerCase();return Object.values(It.tools).find(e=>e.key===t)?.tool??null}function Mt(e){let t=1===e.length?e.toLowerCase():e,n=It.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 kt=W(null),Et=()=>()=>{},At=()=>null;function Ct(){return Math.random().toString(36).substring(2,9)}function Rt(e){return"text"===e.type&&"lasso"===e.region?.kind&&(e={...e,fontSize:12,linkedAnchor:e.linkedAnchor??"bottom-left"}),e.status?e:e.captured?{...e,status:"in_flight"}:{...e,status:"pending"}}function Nt(e){return{annotations:e.annotations,styleModifications:e.styleModifications,textModifications:e.textModifications,domModifications:e.domModifications,spacingTokenChanges:e.spacingTokenChanges,spacingTokenMods:e.spacingTokenMods}}function Lt(e){return{...e,undoStack:[...e.undoStack,Nt(e)],redoStack:[]}}function Ot(e,t,n,o){return e.selector===t&&(!e.pathname||e.pathname===o)&&e.textNodePath.length===n.length&&e.textNodePath.every((e,t)=>e===n[t])}function Dt(e,t,n=!0){let{selector:o,durableSelector:i,element:a,textNodePath:r,original:l,modified:d}=t,s=typeof window<"u"?window.location.pathname:"/",c=e.textModifications.findIndex(e=>Ot(e,o,r,s));if(l===d&&c<0)return e;if(c>=0){let t=e.textModifications[c],o=t.captured&&n?Lt(e):e,r=t.captured?l:t.original;return d===r?{...o,textModifications:o.textModifications.filter((e,t)=>t!==c)}:{...o,textModifications:o.textModifications.map((e,t)=>t===c?{...e,durableSelector:i,element:a,original:r,modified:d,createdAt:e.createdAt??Date.now(),captured:!1,pathname:s}:e)}}let p=n?Lt(e):e;return{...p,textModifications:[...p.textModifications,{selector:o,durableSelector:i,element:a,textNodePath:r,original:l,modified:d,createdAt:Date.now(),pathname:s}]}}function $t(e,t){switch(t.type){case"SET_ANNOTATING":return function(e,t){return{...e,isAnnotating:t}}(e,t.payload);case"SET_TOOL":return function(e,t){return{...e,activeTool:t}}(e,t.payload);case"SET_COLOR":return function(e,t){return{...e,activeColor:t}}(e,t.payload);case"SET_STROKE_WIDTH":return function(e,t){return{...e,strokeWidth:t}}(e,t.payload);case"ADD_TEXT":return function(e,t){let n={id:t.id??Ct(),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:Lt(e),annotations:[...e.annotations,n]}}(e,t.payload);case"UPDATE_TEXT":return function(e,t){return{...Lt(e),annotations:e.annotations.map(e=>e.id===t.id?{...e,text:t.text,...null!=t.imageCount?{imageCount:t.imageCount}:{},...t.attachments?{attachments:t.attachments}:{},...t.interactionEpisode?{interactionEpisode:t.interactionEpisode}:{}}:e)}}(e,t.payload);case"CLEAR_INTERACTION_EPISODE":return function(e,t){return{...Lt(e),annotations:e.annotations.map(e=>{if(e.id!==t.id)return e;let n=e.interactionEpisode?.frames?.length??0,{interactionEpisode:o,...i}=e;if(0===n)return i;let a=Math.max(0,(e.imageCount??0)-n);if(0===a){let{imageCount:e,...t}=i;return t}return{...i,imageCount:a}})}}(e,t.payload);case"DELETE_ANNOTATION":return function(e,t){let n=Lt(e),o=e.annotations.find(e=>e.id===t.id)?.groupId,i=new Set(e.annotations.filter(e=>e.id===t.id||o&&e.groupId===o).map(e=>e.id));return{...n,annotations:e.annotations.filter(e=>e.id!==t.id&&!(o&&e.groupId===o)),selectedAnnotationIds:e.selectedAnnotationIds.filter(e=>!i.has(e)),lastSelectedId:e.lastSelectedId&&i.has(e.lastSelectedId)?null:e.lastSelectedId}}(e,t.payload);case"MOVE_ANNOTATION":return function(e,t){let n=t.saveUndo?Lt(e):e,o=e.annotations.find(e=>e.id===t.id)?.groupId;return{...n,annotations:e.annotations.map(e=>{if(!(e.id===t.id||o&&e.groupId===o))return e;let n=t.delta.x,i=t.delta.y;return{...e,points:e.points.map(e=>({x:e.x+n,y:e.y+i}))}})}}(e,t.payload);case"RESIZE_ANNOTATION":return function(e,t){let n=t.saveUndo?Lt(e):e,o=e.annotations.find(e=>e.id===t.id);if(!o||"text"===o.type||o.points.length<2)return e;let i=0,a=0;if("rectangle"===o.type&&o.groupId){let e=t.points,n=Math.min(e[0].x,e[1].x),r=Math.max(e[0].y,e[1].y),l=o.points[0],d=o.points[o.points.length-1],s=Math.min(l.x,d.x),c=Math.max(l.y,d.y);i=n-s,a=r-c}return{...n,annotations:e.annotations.map(e=>e.id===t.id?{...e,points:t.points}:o.groupId&&e.groupId===o.groupId&&"text"===e.type?{...e,points:e.points.map(e=>({x:e.x+i,y:e.y+a}))}:e)}}(e,t.payload);case"PASTE_ANNOTATIONS":return function(e,t){return{...Lt(e),annotations:[...e.annotations,...t.annotations.map(Rt)]}}(e,t.payload);case"RESTORE_ANNOTATIONS":return function(e,t){let n=new Set,o=[];for(let e of t.annotations)n.has(e.id)||(n.add(e.id),o.push(Rt(e)));return{...e,annotations:o}}(e,t.payload);case"SYNC_ANNOTATIONS":return function(e,t){let n=new Map(e.annotations.map(e=>[e.id,e])),o=t.annotations.map(e=>{let t=Rt(e),o=n.get(t.id);return o&&t.linkedSelector&&o.linkedSelector===t.linkedSelector?{...t,points:o.points,linkedAnchor:o.linkedAnchor}:t});return{...e,annotations:o}}(e,t.payload);case"MERGE_ANNOTATIONS":return function(e,t){let n=new Set(e.annotations.map(e=>e.id)),o=t.annotations.filter(e=>!n.has(e.id)).map(Rt);return o.length>0?{...e,annotations:[...e.annotations,...o]}:e}(e,t.payload);case"UNDO":return function(e){if(0===e.undoStack.length)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,Nt(e)]}}(e);case"REDO":return function(e){if(0===e.redoStack.length)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,Nt(e)]}}(e);case"SELECT_ANNOTATION":return function(e,t){let{id:n,addToSelection:o}=t;if(null===n)return{...e,selectedAnnotationIds:[],lastSelectedId:null};if(o){if(e.selectedAnnotationIds.includes(n)){let t=e.selectedAnnotationIds.filter(e=>e!==n);return{...e,selectedAnnotationIds:t,lastSelectedId:t.length>0?t[t.length-1]:null}}return{...e,selectedAnnotationIds:[...e.selectedAnnotationIds,n],lastSelectedId:n}}return{...e,selectedAnnotationIds:[n],lastSelectedId:n}}(e,t.payload);case"UPDATE_ANNOTATION_COLOR":return function(e,t){let n=e.annotations.find(e=>e.id===t.id)?.groupId,o=new Set;for(let t of e.selectedAnnotationIds){let n=e.annotations.find(e=>e.id===t);n?.groupId&&o.add(n.groupId)}return{...e,annotations:e.annotations.map(i=>i.id===t.id||e.selectedAnnotationIds.includes(i.id)||i.groupId&&(i.groupId===n||o.has(i.groupId))?{...i,color:t.color}:i)}}(e,t.payload);case"MARK_CAPTURED":return function(e,t,n){let o=typeof window<"u"?window.location.pathname:"/",i=t?new Set(t):void 0,a=n??e.textModifications.filter(e=>!e.pathname||e.pathname===o),r=e=>e.filter(e=>!a.some(t=>e.pathname===t.pathname&&Ot(e,t.selector,t.textNodePath,t.pathname??"")&&e.createdAt===t.createdAt&&e.original===t.original&&e.modified===t.modified)),l=e=>({...e,textModifications:r(e.textModifications)});return{...e,undoStack:e.undoStack.map(l),redoStack:e.redoStack.map(l),annotations:e.annotations.map(e=>i&&!i.has(e.id)?e:{...e,captured:!0,status:"pending"!==e.status&&"sending"!==e.status&&e.status?e.status:"in_flight"}),styleModifications:e.styleModifications.map(e=>e.pathname&&e.pathname!==o?e:{...e,captured:!0}),textModifications:r(e.textModifications),domModifications:e.domModifications.map(e=>e.pathname&&e.pathname!==o?e:{...e,captured:!0}),spacingTokenChanges:e.spacingTokenChanges.map(e=>({...e,captured:!0})),spacingTokenMods:e.spacingTokenMods.map(e=>({...e,captured:!0}))}}(e,t.payload?.annotationIds,t.payload?.textModifications);case"CLEAR":return function(e){return{...e,annotations:[],undoStack:[],redoStack:[],selectedAnnotationIds:[],lastSelectedId:null,textModifications:[],domModifications:[],spacingTokenChanges:[],spacingTokenMods:[]}}(e);case"DISCARD_DRAFT":return function(e){return e.annotations.some(e=>"pending"===(e.status??"pending"))||e.styleModifications.some(e=>!e.captured)||e.textModifications.some(e=>!e.captured)||e.domModifications.some(e=>!e.captured)||e.spacingTokenChanges.some(e=>!e.captured)||e.spacingTokenMods.some(e=>!e.captured)?{...Lt(e),annotations:e.annotations.filter(e=>"pending"!==(e.status??"pending")),styleModifications:e.styleModifications.filter(e=>e.captured),textModifications:e.textModifications.filter(e=>e.captured),domModifications:e.domModifications.filter(e=>e.captured),spacingTokenChanges:e.spacingTokenChanges.filter(e=>e.captured),spacingTokenMods:e.spacingTokenMods.filter(e=>e.captured),selectedAnnotationIds:[],lastSelectedId:null}:e}(e);case"MODIFY_STYLE":return function(e,t){let{selector:n,element:o,property:i,original:a,modified:r}=t,l=typeof window<"u"?window.location.pathname:"/",d=e.styleModifications.findIndex(e=>e.selector===n&&(!e.pathname||e.pathname===l));if(a===r&&d<0)return e;if(d>=0){let t=e.styleModifications[d];if(t.captured){let t=Lt(e),n=t.styleModifications.map((e,t)=>t===d?{...e,changes:[{property:i,original:a,modified:r}],createdAt:e.createdAt??Date.now(),captured:!1,pathname:l}:e);return{...t,styleModifications:n}}let n,o=t.changes.findIndex(e=>e.property===i),s=e;if(o>=0){let e=t.changes[o];n=r===e.original?t.changes.filter((e,t)=>t!==o):t.changes.map((e,t)=>t===o?{...e,modified:r}:e)}else{if(a===r)return e;s=Lt(e),n=[...t.changes,{property:i,original:a,modified:r}]}if(0===n.length)return{...s,styleModifications:s.styleModifications.filter((e,t)=>t!==d)};let c=s.styleModifications.map((e,t)=>t===d?{...e,changes:n,createdAt:e.createdAt??Date.now()}:e);return{...s,styleModifications:c}}{let t=Lt(e),d={selector:n,element:o,changes:[{property:i,original:a,modified:r}],createdAt:Date.now(),pathname:l};return{...t,styleModifications:[...t.styleModifications,d]}}}(e,t.payload);case"MODIFY_STYLES_BATCH":return function(e,t){let{selector:n,durableSelector:o,element:i,changes:a}=t,r=typeof window<"u"?window.location.pathname:"/",l=a.filter(e=>e.original!==e.modified);if(0===l.length)return e;let d=Lt(e),s=d.styleModifications.findIndex(e=>e.selector===n&&(!e.pathname||e.pathname===r));if(s>=0){let e=d.styleModifications[s],t=e.captured?[]:[...e.changes];for(let e of l){let n=t.findIndex(t=>t.property===e.property);n>=0?t=e.modified===t[n].original?t.filter((e,t)=>t!==n):t.map((t,o)=>o===n?{...t,modified:e.modified,token:e.token,sticker:e.sticker}:t):t.push(e)}return 0===t.length?{...d,styleModifications:d.styleModifications.filter((e,t)=>t!==s)}:{...d,styleModifications:d.styleModifications.map((e,n)=>n===s?{...e,changes:t,createdAt:e.createdAt??Date.now(),captured:!1,pathname:r}:e)}}return{...d,styleModifications:[...d.styleModifications,{selector:n,durableSelector:o,element:i,changes:l,createdAt:Date.now(),pathname:r}]}}(e,t.payload);case"CLEAR_STYLE":return function(e,t){let{selector:n,property:o}=t,i=typeof window<"u"?window.location.pathname:"/",a=Lt(e),r=a.styleModifications.map(e=>e.selector!==n||e.pathname&&e.pathname!==i?e:{...e,changes:e.changes.filter(e=>e.property!==o)}).filter(e=>e.changes.length>0);return{...a,styleModifications:r}}(e,t.payload);case"CLEAR_STICKER":return function(e,t){let{selector:n,sticker:o}=t,i=typeof window<"u"?window.location.pathname:"/";if(!e.styleModifications.find(e=>e.selector===n&&(!e.pathname||e.pathname===i)&&!e.captured&&e.changes.some(e=>e.sticker?.family===o.family&&e.sticker.subproperty===o.subproperty)))return e;let a=Lt(e),r=a.styleModifications.map(e=>e.selector!==n||e.pathname&&e.pathname!==i||e.captured?e:{...e,changes:e.changes.filter(e=>e.sticker?.family!==o.family||e.sticker.subproperty!==o.subproperty)}).filter(e=>e.changes.length>0);return{...a,styleModifications:r}}(e,t.payload);case"CLEAR_ALL_STYLES":return function(e){return 0===e.styleModifications.length?e:{...Lt(e),styleModifications:[]}}(e);case"SETTLE_CAPTURED_STYLES":return function(e,t){let n=new Set(t.selectors);if(0===n.size)return e;let o=e.styleModifications.filter(e=>!(e.captured&&(n.has(e.selector)||e.durableSelector&&n.has(e.durableSelector))));return o.length===e.styleModifications.length?e:{...e,styleModifications:o}}(e,t.payload);case"RESTORE_STYLE_MODIFICATIONS":return function(e,t){let n=Date.now();return{...e,styleModifications:t.map((e,t)=>({...e,createdAt:e.createdAt??n+t}))}}(e,t.payload);case"MODIFY_TEXT_CONTENT":return Dt(e,t.payload);case"MODIFY_TEXT_CONTENTS":return function(e,t,n=!0){return 0===t.length?e:t.reduce((e,t)=>Dt(e,t,!1),n?Lt(e):e)}(e,t.payload,t.saveUndo??!0);case"RESTORE_TEXT_MODIFICATIONS":return function(e,t){let n=Date.now();return{...e,textModifications:t.filter(e=>!e.captured).map((e,t)=>({...e,createdAt:e.createdAt??n+t}))}}(e,t.payload);case"MODIFY_DOM_STRUCTURE":return function(e,t){let n=Lt(e),o=n.domModifications.findIndex(e=>e.id===t.id);return o>=0?{...n,domModifications:n.domModifications.map((e,n)=>n===o?{...t,captured:!1}:e)}:{...n,domModifications:[...n.domModifications,t]}}(e,t.payload);case"RESTORE_DOM_MODIFICATIONS":return function(e,t){return{...e,domModifications:t}}(e,t.payload);case"UPDATE_LINKED_POSITIONS":return function(e,t){let{updates:n}=t,o=new Map(n.map(e=>[e.id,e]));return{...e,annotations:e.annotations.map(e=>{let t=o.get(e.id);return t?{...e,points:[t.point,...e.points.slice(1)],...t.linkedAnchor?{linkedAnchor:t.linkedAnchor}:{}}:e})}}(e,t.payload);case"CLEANUP_ORPHANED":return function(e,t){let{linkedSelectors:n,styleSelectors:o}=t,i=new Set(n),a=new Set(o),r=typeof window<"u"?window.location.pathname:"/",l=new Set,d=new Set;for(let t of e.annotations)t.linkedSelector&&i.has(t.linkedSelector)&&(l.add(t.id),t.groupId&&d.add(t.groupId));for(let t of e.annotations)t.groupId&&d.has(t.groupId)&&l.add(t.id);let s=e.annotations.filter(e=>!l.has(e.id)),c=e.styleModifications.filter(e=>!a.has(e.selector)||e.pathname&&e.pathname!==r),p=e.domModifications.filter(e=>!a.has(e.selector)||e.pathname&&e.pathname!==r);if(s.length===e.annotations.length&&c.length===e.styleModifications.length&&p.length===e.domModifications.length)return e;let u=e.selectedAnnotationIds.filter(e=>!l.has(e));return{...e,annotations:s,styleModifications:c,domModifications:p,selectedAnnotationIds:u,lastSelectedId:u.length>0?u[u.length-1]:null}}(e,t.payload);case"SET_ANNOTATION_STATUS":return function(e,t){let n=new Set(t.ids);return{...e,annotations:e.annotations.map(e=>n.has(e.id)?{...e,status:t.status}:e)}}(e,t.payload);case"MARK_ANNOTATIONS_REPLIED":return function(e,t){let n=new Set(t.ids),o=new Set;for(let t of e.annotations)n.has(t.id)&&t.groupId&&o.add(t.groupId);return{...e,annotations:e.annotations.map(e=>{if(!(n.has(e.id)||e.groupId&&o.has(e.groupId)))return e;let i=!!t.jobId&&e.replyJobIds?.includes(t.jobId),a="waiting_input"===e.status;return{...e,status:a?"waiting_input":"resolved",replyCount:(e.replyCount??0)+(i?0:1),replyJobIds:t.jobId&&!i?[...e.replyJobIds??[],t.jobId]:e.replyJobIds,threadId:e.threadId||t.threadId,question:a?e.question:void 0}})}}(e,t.payload);case"MARK_ANNOTATIONS_FAILED":return function(e,t){let n=new Set(t.ids),o=new Set;for(let t of e.annotations)n.has(t.id)&&t.groupId&&o.add(t.groupId);return{...e,annotations:e.annotations.map(e=>n.has(e.id)||e.groupId&&o.has(e.groupId)?{...e,status:"failed",threadId:e.threadId||t.threadId,question:void 0}:e)}}(e,t.payload);case"SET_ANNOTATION_THREAD":return function(e,t){let n=new Set(t.ids),o=new Set;for(let t of e.annotations)n.has(t.id)&&t.groupId&&o.add(t.groupId);return{...e,annotations:e.annotations.map(e=>n.has(e.id)||e.groupId&&o.has(e.groupId)?{...e,threadId:t.threadId,targetBindingId:t.targetBindingId}:e)}}(e,t.payload);case"SET_ANNOTATION_QUESTION":return function(e,t){let n=new Set(t.ids),o=new Set;for(let t of e.annotations)n.has(t.id)&&t.groupId&&o.add(t.groupId);return{...e,annotations:e.annotations.map(e=>n.has(e.id)||e.groupId&&o.has(e.groupId)?{...e,status:"waiting_input",question:t.question,threadId:t.threadId}:e)}}(e,t.payload);case"APPLY_RESOLUTIONS":return function(e,t){let n=new Map(t.resolutions.map(e=>[e.annotationId,e])),o=new Map;for(let t of e.annotations){let e=n.get(t.id);e&&t.groupId&&o.set(t.groupId,e)}return{...e,annotations:e.annotations.map(e=>{let i=n.get(e.id)||(e.groupId?o.get(e.groupId):void 0);if(!i)return e;let a=!!t.jobId&&e.replyJobIds?.includes(t.jobId);return{...e,status:i.status,resolutionSummary:i.summary,scope:i.finalScope??i.inferredScope??null,replyCount:(e.replyCount??0)+(a?0:1),replyJobIds:t.jobId&&!a?[...e.replyJobIds??[],t.jobId]:e.replyJobIds,question:void 0,threadId:e.threadId||t.threadId}})}}(e,t.payload);case"ADD_SPACING_TOKEN_CHANGE":return function(e,t){let n=e.spacingTokenChanges.findIndex(e=>e.tokenPath===t.tokenPath);return n>=0?{...e,spacingTokenChanges:e.spacingTokenChanges.map((e,o)=>o===n?t:e)}:{...e,spacingTokenChanges:[...e.spacingTokenChanges,t]}}(e,t.payload);case"RESTORE_SPACING_TOKEN_CHANGES":return function(e,t){return{...e,spacingTokenChanges:t}}(e,t.payload);case"MODIFY_SPACING_TOKEN":return function(e,t){let n,o=Lt(e),i=e.spacingTokenMods.findIndex(e=>e.tokenPath===t.tokenPath);if(i>=0){let o=e.spacingTokenMods[i],a={...t,originalValue:o.captured?o.currentValue:o.originalValue,originalPx:o.captured?o.currentPx:o.originalPx,captured:!1};n=e.spacingTokenMods.map((e,t)=>t===i?a:e)}else n=[...e.spacingTokenMods,{...t,captured:!1}];return{...o,spacingTokenMods:n}}(e,t.payload);case"DELETE_SPACING_TOKEN":return function(e,t){let n,o=Lt(e),i=e.spacingTokenMods.findIndex(e=>e.tokenPath===t.tokenPath),a=i>=0?e.spacingTokenMods[i]:null,r=i>=0?a.captured?a.currentValue:a.originalValue:t.originalValue,l=i>=0?a.captured?a.currentPx:a.originalPx:parseFloat(t.originalValue)||0,d={tokenPath:t.tokenPath,originalValue:r,currentValue:"__deleted__",targets:a?.targets??[],originalPx:l,currentPx:0,captured:!1};return n=i>=0?e.spacingTokenMods.map((e,t)=>t===i?d:e):[...e.spacingTokenMods,d],{...o,spacingTokenMods:n}}(e,t.payload);default:return t}}function Pt(e,t){let n=H(kt),[o,i]=U($t,a),r=G(n?.subscribe??Et,n?.getSnapshot??At,n?.getSnapshot??At)??o,l=n?.dispatch??i;j(()=>{if(!r.isAnnotating)return;let n=n=>{t?.current||n.defaultPrevented||n.isComposing||n.altKey||n.composedPath().some(e=>e instanceof Element&&(e.matches('input, textarea, select, [role="textbox"]')||e instanceof HTMLElement&&e.isContentEditable||e.hasAttribute("contenteditable")&&"false"!==e.getAttribute("contenteditable")))||(n.metaKey||n.ctrlKey)&&n.key.toLowerCase()===It.actions.undo.key&&(n.preventDefault(),n.shiftKey?l({type:"REDO"}):e?.current?.()||l({type:"UNDO"}))};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[l,r.isAnnotating,e,t]);let d=n?.getUndoHead?n.getUndoHead():r.undoStack.at(-1);return[r,l,d]}function _t(e){return!!e&&!!e.closest("#devtools-toolbar, #devtools-scrim, #devtools-text-input, [data-devtools], [data-popmelt-panel], [data-popmelt-shadow-host]")}function Ft(e,t,n,o=!1){return function(e,t){if(!e)return t();let n=e.style.pointerEvents;e.style.pointerEvents="none";try{return t()}finally{e.style.pointerEvents=n}}(n,()=>{let n=r(e,t);if(!n||_t(n))return null;let i=n?.ownerDocument??document,a=R(e,t,i),l=function(e,t,n=document){let o=n,i=o.caretPositionFromPoint?.(e,t);if(i?.offsetNode?.nodeType===Node.TEXT_NODE)return i.offsetNode;let a=o.caretRangeFromPoint?.(e,t);return a?.startContainer?.nodeType===Node.TEXT_NODE?a.startContainer:null}(a.x,a.y,i);if(l&&!n.contains(l)&&(l=null),!l){let e=n;e&&!_t(e)&&(l=function(e,t,n){let o=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode:e=>e.textContent?.trim()?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}),i=o.nextNode();for(;i;){let a=i,r=e.ownerDocument.createRange();r.selectNodeContents(a);let l=Array.from(r.getClientRects());if(r.detach?.(),l.some(e=>t>=e.left&&t<=e.right&&n>=e.top&&n<=e.bottom))return a;i=o.nextNode()}return null}(e,a.x,a.y))}if(!l||!N(l.parentElement))return null;let d=l.parentElement;if(_t(d))return null;for(;!o&&d.parentElement&&d!==i.body;){let e=A(d).getComputedStyle(d).display,t="inline-block"===e&&1===d.childNodes.length&&d.firstChild?.nodeType===Node.ELEMENT_NODE;if("inline"!==e&&"contents"!==e&&!t)break;let n=d.parentElement;if(_t(n))break;if(Array.from(n.childNodes).some(e=>e.nodeType===Node.TEXT_NODE&&!!e.nodeValue?.trim())){d=n;continue}let o=A(n).getComputedStyle(n).display,i="inline-block"===o&&1===n.childNodes.length&&n.firstChild?.nodeType===Node.ELEMENT_NODE;if("inline"!==o&&"contents"!==o&&!i)break;d=n}let s=d.tagName.toLowerCase();if("script"===s||"style"===s||"textarea"===s||"input"===s)return null;let c=function(e){let t=[],n=o=>{if(o.nodeType===Node.TEXT_NODE){let n=o,i=zt(e,n);return void(i&&t.push({textNode:n,textNodePath:i,originalText:n.nodeValue??""}))}if(o.nodeType!==Node.ELEMENT_NODE&&o!==e)return;let i=o.tagName?.toLowerCase();"script"===i||"style"===i||o.childNodes.forEach(n)};return e.childNodes.forEach(n),t}(d).filter(e=>!o||e.textNode===l),p=c.map(e=>e.originalText).join("");if(!p.trim())return null;let u=zt(d,l);if(!u)return null;let f=A(d).getComputedStyle(d),h=Bt(c,d,f,o),{textRect:m,boundaryRect:g,boundaryRects:y,flowRect:v,firstLineIndent:x}=h;if(m.width<=0||m.height<=0)return null;let w=parseFloat(f.fontSize)||12,b="nowrap"!==f.whiteSpace&&"pre"!==f.whiteSpace&&(o?y.length>1:function(e){let t=e.ownerDocument.createRange();t.selectNodeContents(e);let n=Array.from(t.getClientRects()).filter(e=>e.width>0&&e.height>0).length;return t.detach?.(),n>1}(l)||"inline"!==f.display);return{textNode:l,targetElement:d,textNodePath:u,segments:c,originalText:p,rect:m,boundaryRect:g,boundaryRects:y,flowRect:v,firstLineIndent:x,styles:f,fontSize:w,wrapsText:b,singleTextNode:o}})}function zt(e,t){let n=[],o=t;for(;o&&o!==e;){let e=o.parentNode;if(!e)return null;n.unshift(Array.prototype.indexOf.call(e.childNodes,o)),o=e}return o===e?n:null}function Wt(e){return{left:e.left,top:e.top,width:e.width,height:e.height}}function Ht(e){let t=e.getBoundingClientRect(),n=A(e).getComputedStyle(e),o=(parseFloat(n.borderLeftWidth)||0)+(parseFloat(n.paddingLeft)||0),i=(parseFloat(n.borderRightWidth)||0)+(parseFloat(n.paddingRight)||0),a=(parseFloat(n.borderTopWidth)||0)+(parseFloat(n.paddingTop)||0),r=(parseFloat(n.borderBottomWidth)||0)+(parseFloat(n.paddingBottom)||0);return E({left:t.left+o,top:t.top+a,width:Math.max(0,t.width-o-i),height:Math.max(0,t.height-a-r)},e.ownerDocument)}function Bt(e,t,n,o=!1){let i=Wt(S(t)),a=function(e){let t=[];for(let n of e){if(!n.textNode.isConnected||!n.originalText.trim())continue;let e=n.textNode.ownerDocument.createRange();e.selectNodeContents(n.textNode),t.push(...Array.from(e.getClientRects()).filter(e=>e.width>0&&e.height>0).map(e=>Wt(E(e,n.textNode.ownerDocument)))),e.detach?.()}return De(t)}(e),r=e[0]?.textNode?function(e,t){let n=e.ownerDocument.createRange();n.selectNodeContents(e);let o=E(n.getBoundingClientRect(),e.ownerDocument);if(n.detach?.(),o.width>0&&o.height>0)return{left:o.left,top:o.top,width:o.width,height:o.height};let i=S(t);return{left:i.left,top:i.top,width:i.width,height:i.height}}(e[0].textNode,t):i,l=a.length>0?a:[r];return function({display:e,singleTextNode:t=!1,fragmentRects:n,elementRect:o,parentContentRect:i}){let a=De(n),r=Oe(a,o);if(!("inline"===e&&a.length>1&&i&&i.width>0))return{textRect:r,boundaryRect:t?r:o,boundaryRects:t?a:[o],firstLineIndent:0};let l=a[0],d={left:i.left,top:l.top,width:i.width,height:Math.max(r.height,Le(r)-l.top)},s=Math.max(0,Math.min(d.width,l.left-d.left));return{textRect:r,boundaryRect:Oe(a,o),boundaryRects:a,flowRect:d,firstLineIndent:s}}({display:n.display,singleTextNode:o,fragmentRects:l,elementRect:i,parentContentRect:t.parentElement?Ht(t.parentElement):void 0})}function jt(e,t,n){if(t===n||0===e.length)return[];let o=0;for(;o<t.length&&o<n.length&&t[o]===n[o];)o+=1;let i=0;for(;i<t.length-o&&i<n.length-o&&t[t.length-1-i]===n[n.length-1-i];)i+=1;let a=o,r=t.length-i,l=n.slice(o,n.length-i),d=0,s=!1;return e.flatMap((t,n)=>{let o=d,i=o+t.originalText.length;d=i;let c=a===r;if(!(c&&(a>=o&&a<i||n===e.length-1&&a===i))&&!(!c&&i>a&&o<r))return[];let p=Math.max(0,Math.min(t.originalText.length,a-o)),u=Math.max(0,Math.min(t.originalText.length,r-o)),f=t.originalText.slice(0,p);return s||(f+=l,s=!0),f+=t.originalText.slice(u),f===t.originalText?[]:[{segment:t,modifiedText:f}]})}function Yt(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 Kt(e,t){return e&&t?Yt(e,t):e===t}function qt(e,t){return e.length===t.length&&e.every((e,n)=>Yt(e,t[n]))}function Xt(){return{isDragging:!1,hasMoved:!1,mode:"move",startX:0,startY:0,element:null,originalParent:null,originalIndex:-1,selector:null,durableSelector:null,elementInfo:null}}function Vt(e){if(!e||e===document.body||e===document.documentElement||_t(e))return!1;let t=e.tagName.toLowerCase();return!["script","style","link","meta","head","html","body","input","textarea","select","option","button"].includes(t)&&!!e.parentElement}function Ut(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 Gt(e){return e.parentElement?Array.from(e.parentElement.children).indexOf(e):-1}function Qt(e){e.removeAttribute("data-pm"),e.querySelectorAll("[data-pm]").forEach(e=>e.removeAttribute("data-pm"))}function Jt(e,t,n,o,i=r){let a=n.parentElement;if(!a)return null;let l=i(e,t);for(;l&&l!==document.body;)if(l===n||n.contains(l))l=l.parentElement;else{if(l.parentElement===a&&Vt(l))break;l=l.parentElement}if(!l||l===document.body||l.parentElement!==a||l===o)return null;let d=l.getBoundingClientRect(),s=d.height>=d.width?t<d.top+d.height/2?"before":"after":e<d.left+d.width/2?"before":"after",c=Gt(l);return{parent:a,reference:l,placement:s,index:"before"===s?c:c+1}}function Zt(e,t,n){let o=Array.from(e.children).filter(e=>e!==t),i=Math.max(0,Math.min(n,o.length));e.insertBefore(t,o[i]??null)}function en({drag:e,clientX:t,clientY:n,pathname:o,createId:i,rootElement:a,elementAtPoint:r}){let s=e.element;if(!(s&&e.selector&&e.durableSelector&&e.elementInfo))return null;let c=Jt(t,n,s,a,r);if(!c)return null;let p=e.originalParent===c.parent&&c.index>e.originalIndex?c.index-1:c.index;if("move"===e.mode&&e.originalParent===c.parent&&(p===e.originalIndex||p===e.originalIndex+1))return null;let u=l(c.parent),f=Ut(c.parent),h=l(c.reference),m=Ut(c.reference),g=e.selector,y=e.durableSelector,v=e.elementInfo;if("copy"===e.mode){let e=s.cloneNode(!0);if(!(e instanceof Element))return null;Qt(e),Zt(c.parent,e,p),g=Ut(e),y=l(e),v={...d(e),selector:g}}else Zt(c.parent,s,p);let x=e.originalParent;return{id:i(),operation:e.mode,selector:g,durableSelector:y,element:v,sourceSelector:"copy"===e.mode?e.selector:void 0,sourceDurableSelector:"copy"===e.mode?e.durableSelector:void 0,sourceElement:"copy"===e.mode?e.elementInfo:void 0,originalParentSelector:x?Ut(x):void 0,originalParentDurableSelector:x?l(x):void 0,originalIndex:e.originalIndex,targetParentSelector:f,targetParentDurableSelector:u,targetIndex:p,referenceSelector:m,referenceDurableSelector:h,placement:c.placement,pathname:o}}function tn(e){return e instanceof HTMLElement&&("INPUT"===e.tagName||"TEXTAREA"===e.tagName||!0===e.isContentEditable||"true"===e.getAttribute("contenteditable"))}function nn(e){return tn(e.composedPath?.()[0]??e.target)||tn(function(){if(typeof document>"u")return null;let e=document.activeElement;for(;e?.shadowRoot?.activeElement;)e=e.shadowRoot.activeElement;return e}())}function on(e,t,n){if(n)return[n];let o=new Set(t),i=new Map;for(let t of e)t.groupId&&t.threadId&&i.set(t.groupId,t.threadId);let a=new Set;for(let t of e){if(!o.has(t.id))continue;let e=t.threadId||(t.groupId?i.get(t.groupId):void 0);e&&a.add(e)}return[...a]}function an({state:e,stateRef:t,activeTextRef:n,selectedIdsRef:o,dispatch:i,clearSelection:a,selectAnnotation:r,handHoveredElement:s,onArchiveThread:c,openThreadId:p,currentPathname:u,hasOpenThread:f}){let h=q([]),m=q(0),g=q(null);j(()=>{let y=y=>{if("Escape"===y.key){if(y.defaultPrevented||y.repeat||n.current||f||nn(y))return;if(o.current.length>0)return y.preventDefault(),void a();let e=t.current;if(e.annotations.some(e=>"pending"===(e.status??"pending"))||e.styleModifications.some(e=>!e.captured)||e.textModifications.some(e=>!e.captured)||e.domModifications.some(e=>!e.captured)||e.spacingTokenChanges.some(e=>!e.captured)||e.spacingTokenMods.some(e=>!e.captured))return y.preventDefault(),void i({type:"DISCARD_DRAFT"})}if((y.metaKey||y.ctrlKey)&&"c"===y.key.toLowerCase()&&"hand"===e.activeTool&&s&&!n.current){if(Vt(s)){y.preventDefault();let e=Ut(s);g.current={source:s,sourceSelector:e,sourceDurableSelector:l(s),sourceElement:{...d(s),selector:e}}}return}if((y.metaKey||y.ctrlKey)&&"v"===y.key.toLowerCase()&&"hand"===e.activeTool&&g.current&&!n.current){let e=g.current,t=s&&Vt(s)?s:e.source,n=t.parentElement;if(n){y.preventDefault();let o=l(n),a=Ut(n),r=l(t),s=Ut(t),c=Gt(t)+1,p=e.source.cloneNode(!0);if(p instanceof Element){Qt(p),Zt(n,p,c);let t=Ut(p),f=l(p),h={...d(p),selector:t};i({type:"MODIFY_DOM_STRUCTURE",payload:{id:Ct(),operation:"copy",selector:t,durableSelector:f,element:h,sourceSelector:e.sourceSelector,sourceDurableSelector:e.sourceDurableSelector,sourceElement:e.sourceElement,targetParentSelector:a,targetParentDurableSelector:o,targetIndex:c,referenceSelector:s,referenceDurableSelector:r,placement:"after",pathname:u}})}}return}if((y.metaKey||y.ctrlKey)&&"v"===y.key&&h.current.length>0&&!n.current){y.preventDefault(),m.current+=1;let e=20*m.current,t=h.current[0]?.groupId?Math.random().toString(36).substring(2,9):void 0,n=h.current.map(n=>({...n,id:Math.random().toString(36).substring(2,9),groupId:n.groupId?t:void 0,timestamp:Date.now(),points:n.points.map(t=>({x:t.x+e,y:t.y+e}))}));i({type:"PASTE_ANNOTATIONS",payload:{annotations:n}});let o=n.find(e=>"text"!==e.type)??n[0];return void(o&&r(o.id))}let v=o.current;if(!(n.current||nn(y)||"Delete"!==y.key&&"Backspace"!==y.key||y.metaKey||y.ctrlKey||y.altKey)){if(0===v.length&&!p)return;let e=on(t.current.annotations,v,p);if(!c||0===e.length)return;y.preventDefault();for(let t of e)c(t);a()}};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[n,a,u,i,s,f,c,p,r,o,e.activeTool,t])}export{Qe as $,Gt as A,Jt as B,en as C,nn as D,on as E,an as F,ne as G,oe as H,ie as I,Me as J,ke as K,Ee as L,Ae as M,Ce as N,Re as O,Fe as P,ze as Q,We as R,He as S,je as T,Ye as U,Ke as V,qe as W,Xe as X,Ve as Y,Ue as Z,Ge as _,It as a,Je as aa,St as b,Ze as ba,Tt as c,et as ca,Mt as d,tt as da,kt as e,nt as ea,Ct as f,ot as fa,$t as g,at as ga,Pt as h,rt as ha,re as i,lt as ia,le as j,dt as ja,ce as k,ut as ka,me as l,ft as la,ge as m,ht as ma,ye as n,mt as na,ve as o,vt as oa,Te as p,xt as pa,_t as q,wt as qa,Ft as r,Bt as s,jt as t,Yt as u,Kt as v,qt as w,Xt as x,Vt as y,Ut as z};
@@ -1 +0,0 @@
1
- "use client";import{b as e}from"./chunk-F5XSNRGT.mjs";import{b as t}from"./chunk-RK6UROPO.mjs";import{a as i}from"./chunk-57FM7XQV.mjs";import{useSyncExternalStore as r,useState as n,useRef as o,useLayoutEffect as a}from"react";import{Minus as l,Plus as c,Minimize2 as s}from"lucide-react";import{jsxs as u,jsx as d,Fragment as h}from"react/jsx-runtime";var m=[1,1.5,2.25,3.375,4];function p(e=1){let t=e,i=null,r=0,n=0,o=()=>null===i?1:i/(t??1),a=e=>Math.max(Math.min(1,o()),Math.min(4/(t??1),e)),l=new Set,c=(e,t)=>t<=1?(1-t)/2:Math.max(1-t,Math.min(0,e));function s(e,o,a){let c=1===e?null:e*(t??1);if(i!==c||r!==o||n!==a){i=c,r=o,n=a;for(let e of l)e()}}return{clampScale:a,snapshot:()=>({pageScale:i,focusX:r,focusY:n}),restore(e){if(e.pageScale!==i||e.focusX!==r||e.focusY!==n){({pageScale:i,focusX:r,focusY:n}=e);for(let e of l)e()}},getFitScale:()=>t,setFitScale(e){if(t!==e){t=e;for(let e of l)e()}},getScale:o,setScale(e){let t=a(e);s(t,1===t?0:r,1===t?0:n)},getView(e,a){let l=o(),s=(1-l)/2,u=i??t??1;return{scale:l,x:c(e>0?s-r*u/e:s,l),y:c(a>0?s-n*u/a:s,l)}},setView(e,i,r,n,o){if(!n||!o)return;let l=a(e),u=(1-l)/2,d=l*(t??1);s(l,(u-c(i,l))*n/d,(u-c(r,l))*o/d)},subscribe:e=>(l.add(e),()=>{l.delete(e)})}}function f({framing:t}){let i=r(t.subscribe,t.getScale,t.getScale),n=r(t.subscribe,t.getFitScale,t.getFitScale),o=null===n?[]:m.map(e=>e/n),a=o.find(e=>e>i)??i,s=o.filter(e=>e<i).pop()??Math.min(1,i);function h(e,t){if(null===n)return`Zoom ${e}`;let r=Math.round(n*t*100)+"%";return t===i?"out"===e?`Fit (${r})`:`Maximum zoom (${r})`:`Zoom ${e} to ${r}`}return u("div",{"data-preview-zoom-controls":"",role:"group","aria-label":"Preview framing","data-popmelt-canvas-block":"",children:[d(e,{type:"button","aria-label":"Zoom out",hint:h("out",s),disabled:s===i,onClick:()=>t.setScale(s),children:d(l,{size:14})}),d(e,{type:"button","aria-label":"Zoom in",hint:h("in",a),disabled:a===i,onClick:()=>t.setScale(a),children:d(c,{size:14})})]})}function g({children:e,overlay:r,interactive:l=!1,framing:c,parentGestureSurface:m}){let g=i.dark,[v]=n(p),w=c??v,b=o(null),[y,x]=n(),[z,S]=n({scale:1,x:0,y:0}),M=o(z);return a(()=>{let e=b.current;if(!e)return;let t=()=>{let t=e.getBoundingClientRect(),i=w.getView(t.width,t.height);M.current=i,S(i)},i=()=>{x({width:e.clientWidth,height:e.clientHeight}),t()},r=w.subscribe(t);i();let n=typeof ResizeObserver<"u"?new ResizeObserver(i):void 0;n?.observe(e);let o=()=>window.matchMedia("(any-hover: hover) and (any-pointer: fine)").matches,a=t=>(m&&t.currentTarget===m?e.ownerDocument.defaultView?.frameElement:e)?.getBoundingClientRect()??e.getBoundingClientRect(),c=(t,i,r,n=e.getBoundingClientRect())=>{if(!n.width||!n.height)return;let o=M.current,a=w.clampScale(t),l=Math.max(0,Math.min(1,(i-n.left)/n.width)),c=Math.max(0,Math.min(1,(r-n.top)/n.height));w.setView(a,l-(l-o.x)*a/o.scale,c-(c-o.y)*a/o.scale,n.width,n.height)},s=null,u=t=>{if(!l&&!o()||!t.ctrlKey&&1===M.current.scale)return;t.preventDefault(),t.stopPropagation();let i=a(t),r=1===t.deltaMode?16:2===t.deltaMode?e.clientHeight:1;t.ctrlKey?null===s&&c(M.current.scale*Math.exp(-t.deltaY*r*.01),t.clientX,t.clientY,i):i.width&&i.height&&w.setView(M.current.scale,M.current.x-t.deltaX*r/i.width,M.current.y-t.deltaY*r/i.height,i.width,i.height)},d=e=>{if(!l&&!o())return;e.preventDefault(),e.stopPropagation();let t=e;if("gesturestart"===e.type)s=M.current.scale;else if("gestureend"===e.type)s=null;else if(null!==s&&Number.isFinite(t.scale)){let i=a(e);c(s*t.scale,Number.isFinite(t.clientX)?t.clientX:i.left+i.width/2,Number.isFinite(t.clientY)?t.clientY:i.top+i.height/2,i)}},h=null,p=e=>{if(2!==e.touches.length)return void(h=null);let[t,i]=[e.touches[0],e.touches[1]],r=(t.clientX+i.clientX)/2,n=(t.clientY+i.clientY)/2,o=Math.hypot(t.clientX-i.clientX,t.clientY-i.clientY);if(e.preventDefault(),"touchmove"===e.type&&null===s&&h&&h.distance>0){let t=a(e);c(M.current.scale*o/h.distance,h.x,h.y,t);let i=M.current;t.width&&t.height&&w.setView(i.scale,i.x+(r-h.x)/t.width,i.y+(n-h.y)/t.height,t.width,t.height)}h={x:r,y:n,distance:o}},f=t=>{if(M.current.scale<=1||!(t.target instanceof Element)||!t.target.closest("[data-preview-zoom-content]"))return;let i=t.target.getBoundingClientRect(),r=e.getBoundingClientRect();(i.left<r.left||i.top<r.top||i.right>r.right||i.bottom>r.bottom)&&w.setScale(1)},g=["touchstart","touchmove","touchend","touchcancel"],v=m?[e,m]:[e],y=["gesturestart","gesturechange","gestureend"];for(let e of v){if(l)for(let t of g)e.addEventListener(t,p,{passive:!1,capture:!0});e.addEventListener("wheel",u,{passive:!1,capture:l});for(let t of y)e.addEventListener(t,d,{passive:!1,capture:l})}return l&&e.addEventListener("focusin",f),()=>{for(let e of v){if(l)for(let t of g)e.removeEventListener(t,p,!0);e.removeEventListener("wheel",u,l);for(let t of y)e.removeEventListener(t,d,l)}e.removeEventListener("focusin",f),r(),n?.disconnect()}},[l,w,m]),a(()=>{l&&b.current&&t(b.current)},[l,z,y]),u("div",{ref:b,"data-preview-zoom":!0,style:{position:"relative",width:"100%",aspectRatio:l?void 0:"16 / 9",height:l?"100%":void 0,touchAction:l?"none":void 0,overflow:"hidden",borderRadius:8},children:[d("div",{"data-preview-zoom-content":!0,style:{width:y?.width||"100%",height:y?.height||"100%",zoom:z.scale,transformOrigin:"0 0",transform:`translate(${100*z.x/z.scale}%, ${100*z.y/z.scale}%)`},children:e}),r,l&&!c&&d(f,{framing:w}),!l&&z.scale>1&&u(h,{children:[d("style",{children:`\n [data-preview-zoom-reset] span { color: ${g.primary}; }\n [data-preview-zoom-reset] svg { color: ${g.secondary}; }\n [data-preview-zoom-reset]:hover span, [data-preview-zoom-reset]:focus-visible span { color: ${g.secondary}; }\n [data-preview-zoom-reset]:hover svg, [data-preview-zoom-reset]:focus-visible svg { color: ${g.primary}; }\n [data-preview-zoom-reset] span, [data-preview-zoom-reset] svg { transition: color 120ms ease; }\n `}),u("button",{"data-popmelt-canvas-block":"","data-preview-zoom-reset":!0,type:"button","aria-label":"Reset preview zoom",onClick:()=>w.setScale(1),style:{position:"absolute",right:8,bottom:8,display:"inline-flex",alignItems:"center",gap:6,border:0,borderRadius:8,padding:"4px 6px 4px 10px",background:g.control,color:g.primary,fontSize:12,cursor:"pointer"},children:[u("span",{children:[Math.round(100*z.scale),"%"]}),d(s,{size:14,"aria-hidden":"true"})]})]})]})}export{p as a,f as b,g as c};