@usepatch/widget 0.3.0 → 0.3.2

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 (3) hide show
  1. package/dist/index.cjs +116 -86
  2. package/dist/index.js +116 -86
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
- import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEffect,use,createElement,useId}from'react';import {AnimatePresence,useReducedMotion,motion}from'motion/react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {createPortal}from'react-dom';function Ne(e){if(e.length<=1||!e.endsWith("/"))return e;try{let t=new URL(e);if(t.pathname==="/"&&e.endsWith("/"))return `${t.origin}${t.search}${t.hash}`}catch{}return e.slice(0,-1)}function ae(e){try{let t=new URL(e);return Ne(`${t.origin}${t.pathname}`)}catch{return Ne(e)}}var mr="patch:locationchange",Gr="__patchHistoryPatched";function ea(e){let t=e.history;if(t[Gr])return;t[Gr]=true;let r=()=>e.dispatchEvent(new Event(mr)),{pushState:n,replaceState:o}=t;try{t.pushState=function(...s){let i=n.apply(this,s);return r(),i},t.replaceState=function(...s){let i=o.apply(this,s);return r(),i};}catch{}}function Kr(e,t){ea(e);let r=()=>t();return e.addEventListener("popstate",r),e.addEventListener("hashchange",r),e.addEventListener(mr,r),()=>{e.removeEventListener("popstate",r),e.removeEventListener("hashchange",r),e.removeEventListener(mr,r);}}var we={desktop:{viewport:"desktop",label:"Desktop",width:null,height:null,glyph:"desktop"},tablet:{viewport:"tablet",label:"Tablet",width:834,height:1194,glyph:"tablet"},mobile:{viewport:"mobile",label:"Mobile",width:390,height:844,glyph:"mobile"}},qr=["desktop","tablet","mobile"];function Ke(e){let t=we[e];return t.width===null||t.height===null?t.label:`${t.label} (${t.width}px \xD7 ${t.height}px)`}function Zr(e,t){let r=we[e];return {width:r.width??t.width,height:r.height??t.height}}var ra=32,na=32,oa=3e3,Qr="cubic-bezier(0.16, 1, 0.3, 1)",Pt=[.22,.61,.36,1],en=.3,tn=.5,ia=.34,aa=.5,sa=.24,la=.22,rn=.12,ca=.42,nn=.2,da=200,ua=260,pa=70,ma=180,ga=260,fa=8,ha=4,ba="#d9d9dd",va=30,xa=["0 2px 8px rgba(0,0,0,0.20)","0 30px 60px -18px rgba(0,0,0,0.55)","0 70px 130px -52px rgba(0,0,0,0.55)"].join(", ");function Mt(e,t,r){let n=Math.max(320,e.innerWidth-ra*2),o=Math.max(320,e.innerHeight-na*2);return Math.min(1,n/t,o/r)}function wa(e){try{return !!(e.contentWindow&&e.contentDocument?.body)}catch{return false}}function on({src:e,viewport:t,overlayWindow:r,onFrameElement:n,onReadyChange:o,onBlockedChange:s}){let i=useReducedMotion(),a=t.width??r.innerWidth,l=t.height??r.innerHeight,c=t.viewport,d=`${c}:${a}:${l}`,m=!!r.happyDOM?.settings?.disableIframePageLoading,[u,h]=useState(()=>({viewport:c,width:a,height:l,scale:Mt(r,a,l)})),[v,x]=useState("stable"),[T,w]=useState(false),[g,p]=useState(false),b=useRef(false),C=useRef(null),f=`${u.viewport}:${u.width}:${u.height}`!==d,Q=T&&!g&&!(f||v==="cover"||v==="resize"),Z=T&&!g&&v==="stable"&&!f,be=useCallback(E=>{C.current=E,n(E);},[n]),pe=useCallback(()=>{let E=C.current;if(!E||!wa(E)){b.current=false,w(false),p(true);return}b.current=true,w(true),p(false);},[]),oe=useCallback(()=>{h(E=>{let te=Mt(r,E.width,E.height);return E.scale===te?E:{...E,scale:te}});},[r]);useEffect(()=>(oe(),r.addEventListener("resize",oe),()=>r.removeEventListener("resize",oe)),[r,oe]),useEffect(()=>{b.current=false,w(false),p(false);let E=r.setTimeout(()=>{b.current||p(true);},oa);return ()=>r.clearTimeout(E)},[e,r]),useEffect(()=>{if(i){f&&h({viewport:c,width:a,height:l,scale:Mt(r,a,l)}),v!=="stable"&&x("stable");return}switch(v){case "stable":{f&&x("cover");return}case "cover":{let E=r.setTimeout(()=>x("resize"),pa);return ()=>r.clearTimeout(E)}case "resize":{f&&h({viewport:c,width:a,height:l,scale:Mt(r,a,l)});let E=r.setTimeout(()=>x("reveal"),ma);return ()=>r.clearTimeout(E)}case "reveal":{let E=r.setTimeout(()=>x("stable"),ga);return ()=>r.clearTimeout(E)}}},[v,f,i,r,c,a,l]),useEffect(()=>{o(Z);},[Z,o]),useEffect(()=>{s(g);},[g,s]);let ee=i?{duration:0}:{duration:sa,ease:Pt},U=i?{duration:0}:{duration:la,ease:Pt,delay:nn*.5},k=i?{duration:0}:{duration:nn,ease:Pt},N=i?{duration:0}:{opacity:{duration:ca,ease:Pt,delay:rn},scale:{type:"spring",bounce:ia,duration:aa,delay:rn},width:{type:"spring",bounce:en,duration:tn},height:{type:"spring",bounce:en,duration:tn}},_=(Q?ua:da)/1e3,S=i?void 0:`opacity ${_}s ${Qr}, filter ${_}s ${Qr}`,L=u.width*u.scale,H=u.height*u.scale;return jsx(motion.div,{"data-patch-preview-backdrop":"",initial:{opacity:0},animate:{opacity:1,transition:ee},exit:{opacity:0,transition:U},className:"fixed inset-0 z-[2147483643] grid place-items-center p-8",style:{backgroundColor:"#0C0C0E",backgroundImage:"radial-gradient(120% 75% at 50% 30%, rgba(255,255,255,0.055), rgba(0,0,0,0) 58%)"},children:jsxs(motion.div,{initial:i?{opacity:0,width:L,height:H}:{opacity:0,scale:.8,width:L,height:H},animate:{opacity:1,scale:1,width:L,height:H},exit:i?{opacity:0}:{opacity:0,scale:.92,transition:k},transition:N,"data-patch-preview-shell":"",className:"relative overflow-hidden bg-white",style:{boxSizing:"content-box",border:`${ha}px solid ${ba}`,borderRadius:va,boxShadow:xa,willChange:"width, height"},children:[jsx("div",{"aria-hidden":!Q,className:"absolute top-0 left-0 origin-top-left",style:{width:u.width,height:u.height,transform:`scale(${u.scale})`,opacity:Q?1:0,filter:i||Q?"none":`blur(${fa}px)`,transition:S,pointerEvents:Q?"auto":"none",willChange:"opacity, filter"},children:jsx("iframe",{ref:be,"data-patch-preview-frame":"","data-patch-preview-src":e,title:`${t.label} preview`,tabIndex:Q?0:-1,src:m?void 0:e,srcDoc:m?"<!doctype html><html><body></body></html>":void 0,onLoad:pe,className:"block bg-white",style:{width:u.width,height:u.height,border:0}})}),jsx(ya,{visible:g})]})})}function ya({visible:e}){return e?jsx("div",{className:"absolute inset-0 grid place-items-center p-8",children:jsx("div",{className:"max-w-[320px] rounded-[20px] bg-white px-5 py-4 text-center text-[13px] leading-[1.45] text-foreground shadow-[0_18px_44px_-18px_rgba(0,0,0,0.28)]",children:"This site blocks embedding. Add X-Frame-Options: SAMEORIGIN or frame-ancestors 'self' to enable viewport previews."})}):null}var cn=createContext(null),dn=createContext(null),un="__patch_preview";function pn(){return typeof window>"u"||typeof document>"u"?null:{targetWindow:window,targetDocument:document,overlayWindow:window,overlayDocument:document,getTargetViewport:()=>({width:window.innerWidth,height:window.innerHeight}),getOverlayViewport:()=>({width:window.innerWidth,height:window.innerHeight}),getTargetScrollY:()=>window.scrollY,getPageUrl:()=>Ne(`${window.location.origin}${window.location.pathname}`),targetPointToOverlay:e=>({...e}),targetRectToOverlay:e=>({...e}),eventTargetElement:e=>e instanceof window.Element?e:null}}function Sa(e){let t=new URL(e.location.href);return t.searchParams.set(un,"1"),t.toString()}function mn(e=window){try{return new URL(e.location.href).searchParams.get(un)==="1"}catch{return false}}function Ta(e,t,r){let n=t.contentWindow,o=t.contentDocument;if(!n||!o)return null;function s(){return t.getBoundingClientRect()}function i(){let l=s();return r.width>0?l.width/r.width:1}function a(l){if(!l)return null;let c=n.Element;return l instanceof c?l:null}return {targetWindow:n,targetDocument:o,overlayWindow:e.overlayWindow,overlayDocument:e.overlayDocument,getTargetViewport:()=>r,getOverlayViewport:e.getOverlayViewport,getTargetScrollY:()=>n.scrollY,getPageUrl:()=>Ne(`${n.location.origin}${n.location.pathname}`),targetPointToOverlay:l=>{let c=s(),d=i();return {viewportX:c.left+l.viewportX*d,viewportY:c.top+l.viewportY*d}},targetRectToOverlay:l=>{let c=s(),d=i();return {x:c.left+l.x*d,y:c.top+l.y*d,width:l.width*d,height:l.height*d}},eventTargetElement:a}}function gn(e,t){let r=e.ResizeObserver??ResizeObserver;return new r(t)}function fn({children:e}){let t=useMemo(()=>pn(),[]),[r,n]=useState("desktop"),[o,s]=useState(null),[i,a]=useState(false),[l,c]=useState(false),[d,m]=useState(false),u=r!=="desktop",h=u||d,v=we[r],x=v.width&&v.height?{width:v.width,height:v.height}:null;useEffect(()=>{a(false),c(false);},[r]);let T=useRef(u);useEffect(()=>{T.current&&!u?m(true):!T.current&&u&&m(false),T.current=u;},[u]);let w=useMemo(()=>t?!u||!i||l||!o||!x?t:Ta(t,o,x)??t:null,[l,o,i,u,x,t]),g=useMemo(()=>({activeViewport:r,setActiveViewport:n,isPreviewing:h,previewReady:h?u&&i&&!l:true,previewBlocked:u&&l}),[r,l,i,u,h]),p=useMemo(()=>t?Sa(t.targetWindow):"",[t]);return !w||!t?null:jsx(dn.Provider,{value:g,children:jsxs(cn.Provider,{value:w,children:[e,jsx(AnimatePresence,{onExitComplete:()=>m(false),children:u&&x?jsx(on,{src:p,viewport:v,overlayWindow:t.overlayWindow,onFrameElement:s,onReadyChange:a,onBlockedChange:c}):null})]})})}function ce(){let e=use(cn),t=useMemo(()=>pn(),[]);if(e)return e;if(t)return t;throw new Error("useTargetSurface must run in a browser document")}function Je(){let e=use(dn),[t,r]=useState("desktop"),n=useMemo(()=>({activeViewport:t,setActiveViewport:r,isPreviewing:false,previewReady:true,previewBlocked:false}),[t]);return e??n}var Ra="X-Patch-Client-Id";function ve(e,t){return {...t?{"Content-Type":"application/json"}:{},Authorization:`Bearer ${e.token}`,...e.clientUserId?{[Ra]:e.clientUserId}:{}}}async function ye(e,t){try{let r=await fetch(e,t);if(!r.ok)return null;let n=await r.text();return n?JSON.parse(n):{}}catch{return null}}async function Ia(e,t){try{let r=await fetch(e,t),n=await r.text(),o=n?JSON.parse(n):null;return r.ok?o??{ok:!0}:{ok:!1,error:o&&typeof o=="object"&&typeof o.error=="string"?o.error:"Request failed."}}catch{return null}}function hn(e){return {async listAnnotations(t){let r=t?`?viewport=${encodeURIComponent(t)}`:"";return (await ye(`${e.apiBase}/api/widget/annotations${r}`,{method:"GET",credentials:"include",headers:ve(e,false)}))?.annotations??[]},async listRoster(){return (await ye(`${e.apiBase}/api/widget/roster`,{method:"GET",credentials:"include",headers:ve(e,false)}))?.entries??[]},async fetchMe(){return ye(`${e.apiBase}/api/widget/me`,{method:"GET",credentials:"include",headers:ve(e,false)})},async postIdentity(t){let r=await ye(`${e.apiBase}/api/widget/identity`,{method:"POST",credentials:"include",headers:ve(e,true),body:JSON.stringify(t)});return r?{clientUserId:r.id,name:r.name,email:r.email,avatarSeed:r.avatarSeed??r.id}:null},async createAnnotation(t){return ye(`${e.apiBase}/api/widget/annotations`,{method:"POST",credentials:"include",headers:ve(e,true),body:JSON.stringify(t)})},async reply(t,r){return ye(`${e.apiBase}/api/widget/annotations/${t}/reply`,{method:"POST",credentials:"include",headers:ve(e,true),body:JSON.stringify(r)})},async deleteAnnotation(t){return ye(`${e.apiBase}/api/widget/annotations/${t}`,{method:"DELETE",credentials:"include",headers:ve(e,false)})},async deleteMessage(t,r){return ye(`${e.apiBase}/api/widget/annotations/${t}/messages/${r}`,{method:"DELETE",credentials:"include",headers:ve(e,false)})},async kickoff(t,r){return Ia(`${e.apiBase}/api/widget/annotations/${t}/kickoff`,{method:"POST",credentials:"include",headers:ve(e,true),body:JSON.stringify(r)})},async resolve(t){return ye(`${e.apiBase}/api/widget/annotations/${t}/resolve`,{method:"POST",credentials:"include",headers:ve(e,true)})},async reopen(t){return ye(`${e.apiBase}/api/widget/annotations/${t}/reopen`,{method:"POST",credentials:"include",headers:ve(e,true)})},async reportAnchorStatuses(t){t.length!==0&&await ye(`${e.apiBase}/api/widget/anchor-report`,{method:"POST",credentials:"include",headers:ve(e,true),body:JSON.stringify({reports:t})});}}}var br="patch.clientIdentity",bn="patch.clientAvatarSeed";function vr(){if(typeof window>"u")return {};try{let e=window.localStorage.getItem(br);if(!e)return {};let t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return {}}}function vn(e){return vr()[e]??null}function xr(e,t){if(!(typeof window>"u"))try{let r=vr();r[e]=t,window.localStorage.setItem(br,JSON.stringify(r));}catch{}}function xn(e){if(!(typeof window>"u"))try{let t=vr();delete t[e],window.localStorage.setItem(br,JSON.stringify(t));}catch{}}function Na(){if(typeof window>"u")return {};try{let e=window.localStorage.getItem(bn);if(!e)return {};let t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return {}}}function hr(){let e=globalThis.crypto;return `client-avatar:${typeof e?.randomUUID=="function"?e.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}`}function wn(e){if(typeof window>"u")return hr();try{let t=Na(),r=t[e];if(r)return r;let n=hr();return t[e]=n,window.localStorage.setItem(bn,JSON.stringify(t)),n}catch{return hr()}}var _a=2e4,kn=createContext(null);function Da(e,t){let r=new Map(e.map(i=>[i.id,i])),n=new Set(t.map(i=>i.id)),o=t.map(i=>{let a=r.get(i.id);if(!a)return i;let l=new Set(i.thread.map(m=>m.id)),c=a.thread.filter(m=>m.deliveryStatus&&!l.has(m.id)),d=c.length>0?{...i,thread:[...i.thread,...c]}:i;if(a.optimisticAction==="resolve-pending"&&i.status!=="resolved"&&(d={...d,status:a.status,resolvedBy:a.resolvedBy,resolvedAt:a.resolvedAt,optimisticAction:a.optimisticAction}),a.optimisticAction==="reopen-pending"&&i.status==="resolved"&&(d={...d,status:a.status,resolvedBy:a.resolvedBy,resolvedAt:a.resolvedAt,optimisticAction:a.optimisticAction}),a.optimisticAction==="run-pending"&&a.latestRun?.id.startsWith("tmp-run")){let m=i.latestRun?Date.parse(i.latestRun.createdAt):Number.NaN,u=Date.parse(a.latestRun.createdAt);i.latestRun!=null&&(Number.isNaN(u)||Number.isNaN(m)||m>=u)||(d={...d,latestRun:a.latestRun,optimisticAction:a.optimisticAction});}return d}),s=e.filter(i=>(i.deliveryStatus||i.optimisticAction)&&!n.has(i.id));return [...o,...s]}function Cn({projectToken:e,apiBase:t,children:r}){let n=ce(),{activeViewport:o,setActiveViewport:s}=Je(),[i,a]=useState(()=>typeof window>"u"?null:vn(e)),[l]=useState(()=>typeof window>"u"?"client-avatar:ssr":wn(e)),[c,d]=useState(null),[m,u]=useState("client"),[h,v]=useState(null),[x,T]=useState([]),[w,g]=useState(null),[p,b]=useState([]),[C,A]=useState(false),[f,I]=useState(null),Q=useRef(f);Q.current=f;let Z=useRef(o);Z.current=o;let be=w===o,pe=useMemo(()=>hn({apiBase:t,token:e,clientUserId:i?.clientUserId}),[t,e,i?.clientUserId]),oe=useRef(pe);oe.current=pe;let ee=useRef(0),U=useCallback(async()=>{let P=o,D=++ee.current,$=await oe.current.listAnnotations(P==="desktop"?void 0:P);if(D!==ee.current||P!==Z.current)return;let K=n.getPageUrl(),Ae=$.filter(ge=>ae(ge.payload.url)===K);T(ge=>Da(ge,Ae)),g(P);},[o,n]),k=useRef(U);k.current=U,useEffect(()=>{let P=false;return (async()=>{let D=await oe.current.fetchMe();if(!P){if(D?.active===false){I(false),A(true);return}if(I(true),D?.studio)d(D.studio),u("studio"),v(D.agentRunReadiness??{ready:true,message:null});else if(d(null),u("client"),v(null),D?.client){let $={clientUserId:D.client.id,name:D.client.name,email:D.client.email,avatarSeed:D.client.avatarSeed};a($),xr(e,$);}await k.current(),P||A(true);}})(),()=>{P=true;}},[e]),useEffect(()=>{!C||!f||U();},[C,f,U]),useEffect(()=>{if(!f)return;let{overlayDocument:P,overlayWindow:D}=n,$=D.setInterval(()=>{P.visibilityState==="visible"&&U();},_a),K=()=>{P.visibilityState==="visible"&&U();};return P.addEventListener("visibilitychange",K),()=>{D.clearInterval($),P.removeEventListener("visibilitychange",K);}},[f,U,n]),useEffect(()=>{if(f)return Kr(n.targetWindow,()=>{let P=n.getPageUrl();T(D=>D.filter($=>ae($.payload.url)===P)),k.current();})},[f,n]);let N=useCallback(async P=>(xr(e,P),a(P),P),[e]),_=useCallback(()=>{a(null),xn(e);},[e]),S=useCallback(P=>{b(D=>[...D.filter($=>$.tempId!==P.tempId),P]);},[]),L=useCallback(P=>{b(D=>D.filter($=>$.tempId!==P));},[]),H=useCallback(P=>{T(D=>{let $=D.findIndex(Ae=>Ae.id===P.id);if($===-1)return [...D,P];let K=D.slice();return K[$]=P,K});},[]),E=useCallback((P,D)=>{T($=>{let K=false,Ae=$.flatMap(ge=>{if(ge.id!==P)return [ge];K=true;let Ve=D(ge);return Ve?[Ve]:[]});return K?Ae:$});},[]),te=useCallback((P,D)=>{T($=>$.map(K=>K.id===P?{...K,id:D,deliveryStatus:"sent"}:K));},[]),me=useMemo(()=>({apiClient:pe,active:f,ready:C,viewerKind:m,agentRunReadiness:h,activeViewport:o,clientAvatarSeed:l,identity:i,studio:c,annotations:x,annotationsReady:be,ephemerals:p,refresh:U,setActiveViewport:s,setIdentity:N,signOut:_,addEphemeral:S,removeEphemeral:L,applyAnnotationUpdate:H,updateAnnotation:E,replaceAnnotationId:te}),[pe,f,C,m,h,o,l,i,c,x,be,p,U,s,N,_,S,L,H,E,te]);return jsx(kn.Provider,{value:me,children:r})}function re(){let e=use(kn);if(!e)throw new Error("useAnnotationsStore must be used inside <AnnotationsProvider>");return e}var An=createContext(null);function Sn({children:e}){let[t,r]=useState(null),[n,o]=useState(""),[s,i]=useState(0),[a,l]=useState(false),c=useCallback(()=>{r(null),o(""),l(false);},[]),d=useCallback(x=>{r({kind:"existing",annotationId:x}),o(""),l(false);},[]),m=useCallback(x=>{r({kind:"composer",...x}),o(""),l(false);},[]),u=useCallback(()=>{if(n.trim().length>0){i(x=>x+1);return}c();},[n,c]),h=useCallback(()=>{c();},[c]),v=useMemo(()=>({active:t,draftText:n,shakeNonce:s,confirmDiscardOpen:a,openExisting:d,openComposer:m,setDraftText:o,attemptClose:u,forceClose:h,setConfirmDiscardOpen:l}),[t,n,s,a,d,m,u,h]);return jsx(An.Provider,{value:v,children:e})}function xe(){let e=use(An);if(!e)throw new Error("usePopoverStore must be used inside <PopoverProvider>");return e}var Rn=new Set(["p","span","h1","h2","h3","h4","h5","h6","li","td","th","label","blockquote","figcaption","code","pre","strong","em","i","b","u","mark","small","sub","sup","abbr","cite","q","dt","dd"]),$a=new Set(["a","button","input","select","textarea"]),In={a:"link",button:"button",input:"input",select:"select",textarea:"textarea",img:"img",svg:"icon",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",p:"paragraph",li:"list item",td:"cell",th:"header cell",label:"label",blockquote:"quote",figcaption:"caption",code:"code",pre:"code block"},We=40,Va=1500,Tn=200,Ba=5,Wa=10;function wr(e){return Rn.has(e.tagName.toLowerCase())}function Pe(e,t){let r=e.replace(/\s+/g," ").trim();return r.length<=t?r:`${r.slice(0,t-1)}\u2026`}function Qe(e){return `"${e}"`}function Ya(e){let t="";for(let r of Array.from(e.childNodes))r.nodeType===3&&(t+=r.textContent??"");return t.replace(/\s+/g," ").trim()}function Lt(e){return (e.textContent??"").replace(/\s+/g," ").trim()}function Ua(e){return !(!e||e.length>40||/__[A-Za-z0-9]{4,}$/.test(e)||/_[a-z0-9]{4,}$/i.test(e)&&/[0-9]/.test(e)||/_[A-Za-z0-9]{5,}_/.test(e)||/^(sc-|css-)[A-Za-z0-9]{4,}$/.test(e)||/^[a-z]{2,}:[\w-]+$/.test(e)||/^-?(p|m|w|h|min|max|gap|space|inset|top|right|bottom|left)[trblxy]?-/.test(e)||/^-?(text|bg|border|ring|shadow|font|leading|tracking|rounded|opacity|z|flex|grid|col|row|order|justify|items|self|content|place|object)-/.test(e)||(e.match(/\d/g)?.length??0)/e.length>.4)}function Ye(e){let t=Array.from(e.classList),r=t.filter(Ua).slice(0,Wa);return r.length>0?r:t.length>0?["container"]:[]}function Nn(e){let t=e.getAttribute("role")??void 0,r=e.getAttribute("aria-label")??void 0,n=e.getAttribute("tabindex"),o=n!==null&&n!==""?Number(n):void 0,s=e.tagName.toLowerCase(),i=$a.has(s)||o!==void 0&&Number.isFinite(o)&&o>=0;if(t===void 0&&r===void 0&&o===void 0&&!i)return;let a={focusable:i};return t!==void 0&&(a.role=t),r!==void 0&&(a.ariaLabel=r),o!==void 0&&Number.isFinite(o)&&(a.tabIndex=o),a}function Xa(e){let t=e.tagName.toLowerCase(),r=In[t]??t,n=e.getAttribute("aria-label");if(n)return `${r} ${Qe(Pe(n,We))}`;let o=e.placeholder;if(o)return `${r} ${Qe(Pe(o,We))}`;let s=e.getAttribute("name");if(s)return `${r}[name="${s}"]`;if(t==="input"){let i=e.type||"text";return `${r}[type=${i}]`}return r}function Ga(e){let t=e.alt?.trim();return t?`img ${Qe(Pe(t,We))}`:"img"}function ht(e){let t=e.tagName.toLowerCase();if(t==="img")return Ga(e);if(t==="input"||t==="textarea"||t==="select")return Xa(e);let r=In[t]??t,n=e.getAttribute("aria-label");if(n)return `${r} ${Qe(Pe(n,We))}`;if(t==="a"||t==="button"||Rn.has(t)||t==="label"){let s=Lt(e);if(s)return `${r} ${Qe(Pe(s,We))}`;if(t==="a"||t==="button"){let i=e.querySelector("svg");if(i){let l=i.getAttribute("aria-label");return l?`${r} ${Qe(Pe(l,We))}`:`${r} (icon)`}let a=e.getAttribute("href");if(t==="a"&&a)return `link[href="${Pe(a,We)}"]`}return r}if(e.id)return `${t}#${e.id}`;let o=Ye(e);return o.length>0?`${t}.${o[0]}`:t}function Pn(e){let t=[],r=e,n=0;for(;r&&r.tagName.toLowerCase()!=="body"&&n<6;)t.unshift(ht(r)),r=r.parentElement,n++;return r&&r.tagName.toLowerCase()==="body"&&t.unshift("body"),t.join(" > ").slice(0,Va)}function Mn(e){let t=Lt(e),r=e.parentElement;if(!r)return;let n=Lt(r);if(n){if(t&&n===t){let o=r.parentElement;if(!o)return;let s=Lt(o);return !s||s===t?void 0:Pe(s,Tn)}return Pe(n,Tn)}}function _n(e){let t=e.parentElement;if(!t)return [];let r=[];for(let n of Array.from(t.children))if(n!==e&&n.tagName.toLowerCase()!=="script"&&(r.push(ht(n)),r.length>=Ba))break;return r}var Ka=["role","aria-label","name"],qa=10,En=100;function Ot(e){let t={};for(let r of Ka){let n=e.getAttribute(r);n!==null&&n!==""&&(t[r]=n.slice(0,En));}for(let r of Array.from(e.attributes)){if(Object.keys(t).length>=qa)break;r.name.startsWith("data-")&&r.value!==""&&(t[r.name]=r.value.slice(0,En));}return t}function zt(e){return Ya(e)}function Dn(e){let t=e;for(;t&&t.nodeType!==1;)t=t.parentNode;return t}function Ht(e,t){return e.closest(`[${t}]`)!==null}var Za=new Set(["p","span","li","td","th","label","blockquote","figcaption","code","pre","strong","em","i","b","u","mark","small","sub","sup","abbr","cite","q","dt","dd"]),ja={article:"Article",aside:"Sidebar",dialog:"Dialog",fieldset:"Form section",figure:"Image",footer:"Footer",form:"Form",header:"Header",main:"Main content",nav:"Navigation",section:"Section",summary:"Summary"},Ja={a:"Link",article:"Article",aside:"Sidebar",blockquote:"Text",button:"Button",code:"Text",div:"Area",figcaption:"Text",figure:"Image",footer:"Footer",form:"Form",header:"Header",img:"Image",input:"Field",label:"Text",li:"Text",main:"Main content",nav:"Navigation",p:"Text",pre:"Text",section:"Section",select:"Field",span:"Text",svg:"Icon",textarea:"Field"},Qa={caption:"Text",cell:"Text","code block":"Text",icon:"Icon",input:"Field",label:"Text",link:"Link","list item":"Text",paragraph:"Text",quote:"Text",select:"Field",textarea:"Field"};function On(e,t){let r=e.replace(/\s+/g," ").trim();return r.length<=t?r:`${r.slice(0,t-1).trim()}\u2026`}function es(e){return `"${e}"`}function Ft(e){return (e.textContent??"").replace(/\s+/g," ").trim()}function Ln(e){let t=e.replace(/[_-]+/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").trim();return t?t.charAt(0).toUpperCase()+t.slice(1):""}function se(e,t){let r=t?.trim();return r?`${e}: ${es(On(r,48))}`:e}function ts(e){let t=e.trim(),r=t.match(/^(.+?)\s+"(.+)"$/);return r?{base:r[1]??t,text:r[2]}:{base:t}}function rs(e){let t=e.toLowerCase().replace(/\[[\s\S]*$/,"").trim(),r=Qa[t];if(r)return r;let n=e.match(/^[a-z][\w-]*/i)?.[0]?.toLowerCase();return n?/^h[1-6]$/.test(n)?"Heading":Ja[n]??"Area":"Area"}function ns(e){let t=e.getAttribute("aria-label");if(t)return se("Field",t);let r=e.placeholder;if(r)return se("Field",r);let n=e.getAttribute("name");if(n)return se("Field",Ln(n));if(e.tagName.toLowerCase()==="input"){let o=e.type||"text";if(o!=="text")return se("Field",Ln(o))}return "Field"}function bt(e,t){if(t?.trim())return se("Selected text",t);let r=e.tagName.toLowerCase(),n=e.getAttribute("aria-label");if(r==="button")return se("Button",n??Ft(e));if(r==="a")return se("Link",n??Ft(e));if(r==="input"||r==="textarea"||r==="select")return ns(e);if(r==="img"){let s=e.alt;return se("Image",s)}if(r==="svg")return se("Icon",n);if(/^h[1-6]$/.test(r))return se("Heading",Ft(e));if(Za.has(r))return se("Text",Ft(e));let o=ja[r];return se(o||"Area",n)}function $t(e){return e===1?"1 item selected":`${e} items selected`}function Vt(){return "Selected area"}function zn(e){if(e.targetLabel?.trim())return On(e.targetLabel,120);if(e.selectedText?.trim())return se("Selected text",e.selectedText);let t=e.element?.trim()||e.elementPath?.trim();if(!t)return "Annotation";let r=t.match(/^(\d+)\s+elements?:/i);if(r)return $t(Number(r[1]));if(/^region\b/i.test(t))return Vt();let n=ts(t.split(">").at(-1)??t);return se(rs(n.base),n.text)}function Vn(e){let{clickTarget:t,selection:r}=e,n=r&&!r.isCollapsed?r.toString().trim():"";if(n&&r&&r.rangeCount>0){let o=r.getRangeAt(0),s=Dn(o.commonAncestorContainer);if(s)return {kind:"element",element:s,rect:s.getBoundingClientRect(),selectedText:n,clickTarget:t}}return {kind:"element",element:t,rect:t.getBoundingClientRect(),clickTarget:t}}var Hn=20,Bn=7,Fn=10,os=.8,is=.5,as=new Set(["html","body","head","script","style","meta","link","title","br","noscript"]),ss=new Set(["section","article","aside","header","footer","nav","main","figure","form","fieldset","dialog","details","summary"]),Bt=24;function Wn(e){let t=e.tagName.toLowerCase();if(ss.has(t))return true;if(t==="div"||t==="span"){if(e.id)return true;let r=Ye(e);if(r.length>0&&r[0]!=="container")return true}return false}var ls=["a","button","input","select","textarea","img","svg","h1","h2","h3","h4","h5","h6","p","span","li","td","th","label","blockquote","figcaption","code","pre","strong","em","div","section","article","aside","header","footer","nav","main","figure","form","fieldset","dialog","details"].join(",");function $n(e){return {x:e.x,y:e.y,width:e.width,height:e.height}}function cs(e,t){return !(e.x+e.width<t.x||t.x+t.width<e.x||e.y+e.height<t.y||t.y+t.height<e.y)}function ds(e,t,r){if(Ht(e,r))return false;let n=e.tagName.toLowerCase();if(as.has(n))return false;let o=e.getBoundingClientRect();if(o.width<Fn||o.height<Fn||o.width>t.width*os||o.height>t.height*is)return false;if(n==="div"||n==="span"){let s=Array.from(e.childNodes).some(l=>l.nodeType===3&&(l.textContent??"").trim().length>0),i=e.getAttribute("role"),a=i!==null&&i.length>0;if(!s&&!a&&!Wn(e))return false}return true}function us(e){return e.filter(t=>!e.some(r=>r!==t&&t.contains(r)))}function ps(e,t){let r=[...e].sort((n,o)=>{let s=n.getBoundingClientRect(),i=o.getBoundingClientRect();return s.width*s.height-i.width*i.height});for(let n of r){if(!Wn(n)||!e.every(a=>a===n||n.contains(a)))continue;let s=n.getBoundingClientRect();if(s.left>=t.x-Bt&&s.top>=t.y-Bt&&s.right<=t.x+t.width+Bt&&s.bottom<=t.y+t.height+Bt)return n}return null}function ms(e){let t=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY;for(let s of e)s.x<t&&(t=s.x),s.y<r&&(r=s.y),s.x+s.width>n&&(n=s.x+s.width),s.y+s.height>o&&(o=s.y+s.height);return {x:t,y:r,width:n-t,height:o-r}}function gs(e){let t=e.x+e.width/2,r=e.y+e.height/2,n=e.x+e.width,o=e.y+e.height;return [{x:e.x,y:e.y},{x:t,y:e.y},{x:n,y:e.y},{x:e.x,y:r},{x:t,y:r},{x:n,y:r},{x:e.x,y:o},{x:t,y:o},{x:n,y:o}]}function Yn(e){let{rect:t,viewport:r,internalAttr:n}=e,o=e.doc??document,s=new Set;for(let c of gs(t)){let d=o.elementsFromPoint(c.x,c.y);for(let m of d)s.add(m);}for(let c of Array.from(o.querySelectorAll(ls)))cs($n(c.getBoundingClientRect()),t)&&s.add(c);let i=Array.from(s).filter(c=>ds(c,r,n)),a=ps(i,t),l=a?[a]:us(i);if(l.length>0){let c=l.map(d=>$n(d.getBoundingClientRect()));return {kind:"multi",elements:l,rects:c,union:ms(c)}}return t.width>=Hn&&t.height>=Hn?{kind:"area",rect:t}:null}var Un="patch-capture-cursor-style";function fs(e){let t=`:not([${e}]):not([${e}] *)`,r=["p","span","h1","h2","h3","h4","h5","h6","li","td","th","label","blockquote","figcaption","code","pre","strong","em","i","b","u","mark","small","sub","sup","abbr","cite","q","dt","dd"].map(n=>`body ${n}${t}`).join(`,
2
+ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEffect,use,createElement,useId}from'react';import {AnimatePresence,useReducedMotion,motion}from'motion/react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {createPortal}from'react-dom';function Ne(e){if(e.length<=1||!e.endsWith("/"))return e;try{let t=new URL(e);if(t.pathname==="/"&&e.endsWith("/"))return `${t.origin}${t.search}${t.hash}`}catch{}return e.slice(0,-1)}function ae(e){try{let t=new URL(e);return Ne(`${t.origin}${t.pathname}`)}catch{return Ne(e)}}var fr="patch:locationchange",Gr="__patchHistoryPatched";function Qi(e){let t=e.history;if(t[Gr])return;t[Gr]=true;let r=()=>e.dispatchEvent(new Event(fr)),{pushState:n,replaceState:o}=t;try{t.pushState=function(...a){let i=n.apply(this,a);return r(),i},t.replaceState=function(...a){let i=o.apply(this,a);return r(),i};}catch{}}function Kr(e,t){Qi(e);let r=()=>t();return e.addEventListener("popstate",r),e.addEventListener("hashchange",r),e.addEventListener(fr,r),()=>{e.removeEventListener("popstate",r),e.removeEventListener("hashchange",r),e.removeEventListener(fr,r);}}var we={desktop:{viewport:"desktop",label:"Desktop",width:null,height:null,glyph:"desktop"},tablet:{viewport:"tablet",label:"Tablet",width:834,height:1194,glyph:"tablet"},mobile:{viewport:"mobile",label:"Mobile",width:390,height:844,glyph:"mobile"}},qr=["desktop","tablet","mobile"];function je(e){let t=we[e];return t.width===null||t.height===null?t.label:`${t.label} (${t.width}px \xD7 ${t.height}px)`}function jr(e,t){let r=we[e];return {width:r.width??t.width,height:r.height??t.height}}var ta=32,ra=32,na=3e3,Qr="cubic-bezier(0.16, 1, 0.3, 1)",Dt=[.22,.61,.36,1],en=.3,tn=.5,oa=.34,ia=.5,aa=.24,sa=.22,rn=.12,la=.42,nn=.2,ca=200,da=260,ua=70,pa=180,ma=260,ga=8,fa=4,ha="#d9d9dd",ba=30,va=["0 2px 8px rgba(0,0,0,0.20)","0 30px 60px -18px rgba(0,0,0,0.55)","0 70px 130px -52px rgba(0,0,0,0.55)"].join(", ");function Lt(e,t,r){let n=Math.max(320,e.innerWidth-ta*2),o=Math.max(320,e.innerHeight-ra*2);return Math.min(1,n/t,o/r)}function xa(e){try{return !!(e.contentWindow&&e.contentDocument?.body)}catch{return false}}function on({src:e,viewport:t,overlayWindow:r,onFrameElement:n,onReadyChange:o,onBlockedChange:a}){let i=useReducedMotion(),s=t.width??r.innerWidth,c=t.height??r.innerHeight,l=t.viewport,d=`${l}:${s}:${c}`,p=!!r.happyDOM?.settings?.disableIframePageLoading,[u,m]=useState(()=>({viewport:l,width:s,height:c,scale:Lt(r,s,c)})),[h,v]=useState("stable"),[w,x]=useState(false),[b,g]=useState(false),k=useRef(false),z=useRef(null),f=`${u.viewport}:${u.width}:${u.height}`!==d,Q=w&&!b&&!(f||h==="cover"||h==="resize"),Z=w&&!b&&h==="stable"&&!f,be=useCallback(S=>{z.current=S,n(S);},[n]),pe=useCallback(()=>{let S=z.current;if(!S||!xa(S)){k.current=false,x(false),g(true);return}k.current=true,x(true),g(false);},[]),oe=useCallback(()=>{m(S=>{let te=Lt(r,S.width,S.height);return S.scale===te?S:{...S,scale:te}});},[r]);useEffect(()=>(oe(),r.addEventListener("resize",oe),()=>r.removeEventListener("resize",oe)),[r,oe]),useEffect(()=>{k.current=false,x(false),g(false);let S=r.setTimeout(()=>{k.current||g(true);},na);return ()=>r.clearTimeout(S)},[e,r]),useEffect(()=>{if(i){f&&m({viewport:l,width:s,height:c,scale:Lt(r,s,c)}),h!=="stable"&&v("stable");return}switch(h){case "stable":{f&&v("cover");return}case "cover":{let S=r.setTimeout(()=>v("resize"),ua);return ()=>r.clearTimeout(S)}case "resize":{f&&m({viewport:l,width:s,height:c,scale:Lt(r,s,c)});let S=r.setTimeout(()=>v("reveal"),pa);return ()=>r.clearTimeout(S)}case "reveal":{let S=r.setTimeout(()=>v("stable"),ma);return ()=>r.clearTimeout(S)}}},[h,f,i,r,l,s,c]),useEffect(()=>{o(Z);},[Z,o]),useEffect(()=>{a(b);},[b,a]);let ee=i?{duration:0}:{duration:aa,ease:Dt},X=i?{duration:0}:{duration:sa,ease:Dt,delay:nn*.5},C=i?{duration:0}:{duration:nn,ease:Dt},I=i?{duration:0}:{opacity:{duration:la,ease:Dt,delay:rn},scale:{type:"spring",bounce:oa,duration:ia,delay:rn},width:{type:"spring",bounce:en,duration:tn},height:{type:"spring",bounce:en,duration:tn}},M=(Q?da:ca)/1e3,A=i?void 0:`opacity ${M}s ${Qr}, filter ${M}s ${Qr}`,D=u.width*u.scale,H=u.height*u.scale;return jsx(motion.div,{"data-patch-preview-backdrop":"",initial:{opacity:0},animate:{opacity:1,transition:ee},exit:{opacity:0,transition:X},className:"fixed inset-0 z-[2147483643] grid place-items-center p-8",style:{backgroundColor:"#0C0C0E",backgroundImage:"radial-gradient(120% 75% at 50% 30%, rgba(255,255,255,0.055), rgba(0,0,0,0) 58%)"},children:jsxs(motion.div,{initial:i?{opacity:0,width:D,height:H}:{opacity:0,scale:.8,width:D,height:H},animate:{opacity:1,scale:1,width:D,height:H},exit:i?{opacity:0}:{opacity:0,scale:.92,transition:C},transition:I,"data-patch-preview-shell":"",className:"relative overflow-hidden bg-white",style:{boxSizing:"content-box",border:`${fa}px solid ${ha}`,borderRadius:ba,boxShadow:va,willChange:"width, height"},children:[jsx("div",{"aria-hidden":!Q,className:"absolute top-0 left-0 origin-top-left",style:{width:u.width,height:u.height,transform:`scale(${u.scale})`,opacity:Q?1:0,filter:i||Q?"none":`blur(${ga}px)`,transition:A,pointerEvents:Q?"auto":"none",willChange:"opacity, filter"},children:jsx("iframe",{ref:be,"data-patch-preview-frame":"","data-patch-preview-src":e,title:`${t.label} preview`,tabIndex:Q?0:-1,src:p?void 0:e,srcDoc:p?"<!doctype html><html><body></body></html>":void 0,onLoad:pe,className:"block bg-white",style:{width:u.width,height:u.height,border:0}})}),jsx(wa,{visible:b})]})})}function wa({visible:e}){return e?jsx("div",{className:"absolute inset-0 grid place-items-center p-8",children:jsx("div",{className:"max-w-[320px] rounded-xl bg-white px-5 py-4 text-center text-[13px] leading-[1.45] text-foreground shadow-[0_18px_44px_-18px_rgba(0,0,0,0.28)]",children:"This site blocks embedding. Add X-Frame-Options: SAMEORIGIN or frame-ancestors 'self' to enable viewport previews."})}):null}var cn=createContext(null),dn=createContext(null),un="__patch_preview";function pn(){return typeof window>"u"||typeof document>"u"?null:{targetWindow:window,targetDocument:document,overlayWindow:window,overlayDocument:document,getTargetViewport:()=>({width:window.innerWidth,height:window.innerHeight}),getOverlayViewport:()=>({width:window.innerWidth,height:window.innerHeight}),getTargetScrollY:()=>window.scrollY,getPageUrl:()=>Ne(`${window.location.origin}${window.location.pathname}`),targetPointToOverlay:e=>({...e}),targetRectToOverlay:e=>({...e}),eventTargetElement:e=>e instanceof window.Element?e:null}}function Aa(e){let t=new URL(e.location.href);return t.searchParams.set(un,"1"),t.toString()}function mn(e=window){try{return new URL(e.location.href).searchParams.get(un)==="1"}catch{return false}}function Sa(e,t,r){let n=t.contentWindow,o=t.contentDocument;if(!n||!o)return null;function a(){return t.getBoundingClientRect()}function i(){let c=a();return r.width>0?c.width/r.width:1}function s(c){if(!c)return null;let l=n.Element;return c instanceof l?c:null}return {targetWindow:n,targetDocument:o,overlayWindow:e.overlayWindow,overlayDocument:e.overlayDocument,getTargetViewport:()=>r,getOverlayViewport:e.getOverlayViewport,getTargetScrollY:()=>n.scrollY,getPageUrl:()=>Ne(`${n.location.origin}${n.location.pathname}`),targetPointToOverlay:c=>{let l=a(),d=i();return {viewportX:l.left+c.viewportX*d,viewportY:l.top+c.viewportY*d}},targetRectToOverlay:c=>{let l=a(),d=i();return {x:l.left+c.x*d,y:l.top+c.y*d,width:c.width*d,height:c.height*d}},eventTargetElement:s}}function gn(e,t){let r=e.ResizeObserver??ResizeObserver;return new r(t)}function fn({children:e}){let t=useMemo(()=>pn(),[]),[r,n]=useState("desktop"),[o,a]=useState(null),[i,s]=useState(false),[c,l]=useState(false),[d,p]=useState(false),u=r!=="desktop",m=u||d,h=we[r],v=h.width&&h.height?{width:h.width,height:h.height}:null;useEffect(()=>{s(false),l(false);},[r]);let w=useRef(u);useEffect(()=>{w.current&&!u?p(true):!w.current&&u&&p(false),w.current=u;},[u]);let x=useMemo(()=>t?!u||!i||c||!o||!v?t:Sa(t,o,v)??t:null,[c,o,i,u,v,t]),b=useMemo(()=>({activeViewport:r,setActiveViewport:n,isPreviewing:m,previewReady:m?u&&i&&!c:true,previewBlocked:u&&c}),[r,c,i,u,m]),g=useMemo(()=>t?Aa(t.targetWindow):"",[t]);return !x||!t?null:jsx(dn.Provider,{value:b,children:jsxs(cn.Provider,{value:x,children:[e,jsx(AnimatePresence,{onExitComplete:()=>p(false),children:u&&v?jsx(on,{src:g,viewport:h,overlayWindow:t.overlayWindow,onFrameElement:a,onReadyChange:s,onBlockedChange:l}):null})]})})}function ce(){let e=use(cn),t=useMemo(()=>pn(),[]);if(e)return e;if(t)return t;throw new Error("useTargetSurface must run in a browser document")}function et(){let e=use(dn),[t,r]=useState("desktop"),n=useMemo(()=>({activeViewport:t,setActiveViewport:r,isPreviewing:false,previewReady:true,previewBlocked:false}),[t]);return e??n}var Ea="X-Patch-Client-Id";function ve(e,t){return {...t?{"Content-Type":"application/json"}:{},Authorization:`Bearer ${e.token}`,...e.clientUserId?{[Ea]:e.clientUserId}:{}}}async function ye(e,t){try{let r=await fetch(e,t);if(!r.ok)return null;let n=await r.text();return n?JSON.parse(n):{}}catch{return null}}async function Ra(e,t){try{let r=await fetch(e,t),n=await r.text(),o=n?JSON.parse(n):null;return r.ok?o??{ok:!0}:{ok:!1,error:o&&typeof o=="object"&&typeof o.error=="string"?o.error:"Request failed."}}catch{return null}}function hn(e){return {async listAnnotations(t){let r=t?`?viewport=${encodeURIComponent(t)}`:"";return (await ye(`${e.apiBase}/api/widget/annotations${r}`,{method:"GET",credentials:"include",headers:ve(e,false)}))?.annotations??[]},async listRoster(){return (await ye(`${e.apiBase}/api/widget/roster`,{method:"GET",credentials:"include",headers:ve(e,false)}))?.entries??[]},async fetchMe(){return ye(`${e.apiBase}/api/widget/me`,{method:"GET",credentials:"include",headers:ve(e,false)})},async postIdentity(t){let r=await ye(`${e.apiBase}/api/widget/identity`,{method:"POST",credentials:"include",headers:ve(e,true),body:JSON.stringify(t)});return r?{clientUserId:r.id,name:r.name,email:r.email,avatarSeed:r.avatarSeed??r.id}:null},async createAnnotation(t){return ye(`${e.apiBase}/api/widget/annotations`,{method:"POST",credentials:"include",headers:ve(e,true),body:JSON.stringify(t)})},async reply(t,r){return ye(`${e.apiBase}/api/widget/annotations/${t}/reply`,{method:"POST",credentials:"include",headers:ve(e,true),body:JSON.stringify(r)})},async deleteAnnotation(t){return ye(`${e.apiBase}/api/widget/annotations/${t}`,{method:"DELETE",credentials:"include",headers:ve(e,false)})},async deleteMessage(t,r){return ye(`${e.apiBase}/api/widget/annotations/${t}/messages/${r}`,{method:"DELETE",credentials:"include",headers:ve(e,false)})},async kickoff(t,r){return Ra(`${e.apiBase}/api/widget/annotations/${t}/kickoff`,{method:"POST",credentials:"include",headers:ve(e,true),body:JSON.stringify(r)})},async resolve(t){return ye(`${e.apiBase}/api/widget/annotations/${t}/resolve`,{method:"POST",credentials:"include",headers:ve(e,true)})},async reopen(t){return ye(`${e.apiBase}/api/widget/annotations/${t}/reopen`,{method:"POST",credentials:"include",headers:ve(e,true)})},async reportAnchorStatuses(t){t.length!==0&&await ye(`${e.apiBase}/api/widget/anchor-report`,{method:"POST",credentials:"include",headers:ve(e,true),body:JSON.stringify({reports:t})});}}}var xr="patch.clientIdentity",bn="patch.clientAvatarSeed";function wr(){if(typeof window>"u")return {};try{let e=window.localStorage.getItem(xr);if(!e)return {};let t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return {}}}function vn(e){return wr()[e]??null}function yr(e,t){if(!(typeof window>"u"))try{let r=wr();r[e]=t,window.localStorage.setItem(xr,JSON.stringify(r));}catch{}}function xn(e){if(!(typeof window>"u"))try{let t=wr();delete t[e],window.localStorage.setItem(xr,JSON.stringify(t));}catch{}}function Ia(){if(typeof window>"u")return {};try{let e=window.localStorage.getItem(bn);if(!e)return {};let t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return {}}}function vr(){let e=globalThis.crypto;return `client-avatar:${typeof e?.randomUUID=="function"?e.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}`}function wn(e){if(typeof window>"u")return vr();try{let t=Ia(),r=t[e];if(r)return r;let n=vr();return t[e]=n,window.localStorage.setItem(bn,JSON.stringify(t)),n}catch{return vr()}}var Ma=2e4,kn=createContext(null);function _a(e,t){let r=new Map(e.map(i=>[i.id,i])),n=new Set(t.map(i=>i.id)),o=t.map(i=>{let s=r.get(i.id);if(!s)return i;let c=new Set(i.thread.map(p=>p.id)),l=s.thread.filter(p=>p.deliveryStatus&&!c.has(p.id)),d=l.length>0?{...i,thread:[...i.thread,...l]}:i;if(s.optimisticAction==="resolve-pending"&&i.status!=="resolved"&&(d={...d,status:s.status,resolvedBy:s.resolvedBy,resolvedAt:s.resolvedAt,optimisticAction:s.optimisticAction}),s.optimisticAction==="reopen-pending"&&i.status==="resolved"&&(d={...d,status:s.status,resolvedBy:s.resolvedBy,resolvedAt:s.resolvedAt,optimisticAction:s.optimisticAction}),s.optimisticAction==="run-pending"&&s.latestRun?.id.startsWith("tmp-run")){let p=i.latestRun?Date.parse(i.latestRun.createdAt):Number.NaN,u=Date.parse(s.latestRun.createdAt);i.latestRun!=null&&(Number.isNaN(u)||Number.isNaN(p)||p>=u)||(d={...d,latestRun:s.latestRun,optimisticAction:s.optimisticAction});}return d}),a=e.filter(i=>(i.deliveryStatus||i.optimisticAction)&&!n.has(i.id));return [...o,...a]}function Cn({projectToken:e,apiBase:t,children:r}){let n=ce(),{activeViewport:o,setActiveViewport:a}=et(),[i,s]=useState(()=>typeof window>"u"?null:vn(e)),[c]=useState(()=>typeof window>"u"?"client-avatar:ssr":wn(e)),[l,d]=useState(null),[p,u]=useState("client"),[m,h]=useState(null),[v,w]=useState([]),[x,b]=useState(null),[g,k]=useState([]),[z,N]=useState(false),[f,E]=useState(null),Q=useRef(f);Q.current=f;let Z=useRef(o);Z.current=o;let be=x===o,pe=useMemo(()=>hn({apiBase:t,token:e,clientUserId:i?.clientUserId}),[t,e,i?.clientUserId]),oe=useRef(pe);oe.current=pe;let ee=useRef(0),X=useCallback(async()=>{let P=o,_=++ee.current,F=await oe.current.listAnnotations(P==="desktop"?void 0:P);if(_!==ee.current||P!==Z.current)return;let q=n.getPageUrl(),Se=F.filter(ge=>ae(ge.payload.url)===q);w(ge=>_a(ge,Se)),b(P);},[o,n]),C=useRef(X);C.current=X,useEffect(()=>{let P=false;return (async()=>{let _=await oe.current.fetchMe();if(!P){if(_?.active===false){E(false),N(true);return}if(E(true),_?.studio)d(_.studio),u("studio"),h(_.agentRunReadiness??{ready:true,message:null});else if(d(null),u("client"),h(null),_?.client){let F={clientUserId:_.client.id,name:_.client.name,email:_.client.email,avatarSeed:_.client.avatarSeed};s(F),yr(e,F);}await C.current(),P||N(true);}})(),()=>{P=true;}},[e]),useEffect(()=>{!z||!f||X();},[z,f,X]),useEffect(()=>{if(!f)return;let{overlayDocument:P,overlayWindow:_}=n,F=_.setInterval(()=>{P.visibilityState==="visible"&&X();},Ma),q=()=>{P.visibilityState==="visible"&&X();};return P.addEventListener("visibilitychange",q),()=>{_.clearInterval(F),P.removeEventListener("visibilitychange",q);}},[f,X,n]),useEffect(()=>{if(f)return Kr(n.targetWindow,()=>{let P=n.getPageUrl();w(_=>_.filter(F=>ae(F.payload.url)===P)),C.current();})},[f,n]);let I=useCallback(async P=>(yr(e,P),s(P),P),[e]),M=useCallback(()=>{s(null),xn(e);},[e]),A=useCallback(P=>{k(_=>[..._.filter(F=>F.tempId!==P.tempId),P]);},[]),D=useCallback(P=>{k(_=>_.filter(F=>F.tempId!==P));},[]),H=useCallback(P=>{w(_=>{let F=_.findIndex(Se=>Se.id===P.id);if(F===-1)return [..._,P];let q=_.slice();return q[F]=P,q});},[]),S=useCallback((P,_)=>{w(F=>{let q=false,Se=F.flatMap(ge=>{if(ge.id!==P)return [ge];q=true;let Be=_(ge);return Be?[Be]:[]});return q?Se:F});},[]),te=useCallback((P,_)=>{w(F=>F.map(q=>q.id===P?{...q,id:_,deliveryStatus:"sent"}:q));},[]),me=useMemo(()=>({apiClient:pe,active:f,ready:z,viewerKind:p,agentRunReadiness:m,activeViewport:o,clientAvatarSeed:c,identity:i,studio:l,annotations:v,annotationsReady:be,ephemerals:g,refresh:X,setActiveViewport:a,setIdentity:I,signOut:M,addEphemeral:A,removeEphemeral:D,applyAnnotationUpdate:H,updateAnnotation:S,replaceAnnotationId:te}),[pe,f,z,p,m,o,c,i,l,v,be,g,X,a,I,M,A,D,H,S,te]);return jsx(kn.Provider,{value:me,children:r})}function re(){let e=use(kn);if(!e)throw new Error("useAnnotationsStore must be used inside <AnnotationsProvider>");return e}var An=createContext(null);function Sn({children:e}){let[t,r]=useState(null),[n,o]=useState(""),[a,i]=useState(0),[s,c]=useState(false),l=useCallback(()=>{r(null),o(""),c(false);},[]),d=useCallback(v=>{r({kind:"existing",annotationId:v}),o(""),c(false);},[]),p=useCallback(v=>{r({kind:"composer",...v}),o(""),c(false);},[]),u=useCallback(()=>{if(n.trim().length>0){i(v=>v+1);return}l();},[n,l]),m=useCallback(()=>{l();},[l]),h=useMemo(()=>({active:t,draftText:n,shakeNonce:a,confirmDiscardOpen:s,openExisting:d,openComposer:p,setDraftText:o,attemptClose:u,forceClose:m,setConfirmDiscardOpen:c}),[t,n,a,s,d,p,u,m]);return jsx(An.Provider,{value:h,children:e})}function xe(){let e=use(An);if(!e)throw new Error("usePopoverStore must be used inside <PopoverProvider>");return e}var Rn=new Set(["p","span","h1","h2","h3","h4","h5","h6","li","td","th","label","blockquote","figcaption","code","pre","strong","em","i","b","u","mark","small","sub","sup","abbr","cite","q","dt","dd"]),Ha=new Set(["a","button","input","select","textarea"]),In={a:"link",button:"button",input:"input",select:"select",textarea:"textarea",img:"img",svg:"icon",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",p:"paragraph",li:"list item",td:"cell",th:"header cell",label:"label",blockquote:"quote",figcaption:"caption",code:"code",pre:"code block"},Ye=40,Fa=1500,Tn=200,Va=5,Ba=10;function kr(e){return Rn.has(e.tagName.toLowerCase())}function Me(e,t){let r=e.replace(/\s+/g," ").trim();return r.length<=t?r:`${r.slice(0,t-1)}\u2026`}function tt(e){return `"${e}"`}function Wa(e){let t="";for(let r of Array.from(e.childNodes))r.nodeType===3&&(t+=r.textContent??"");return t.replace(/\s+/g," ").trim()}function $t(e){return (e.textContent??"").replace(/\s+/g," ").trim()}function Ya(e){return !(!e||e.length>40||/__[A-Za-z0-9]{4,}$/.test(e)||/_[a-z0-9]{4,}$/i.test(e)&&/[0-9]/.test(e)||/_[A-Za-z0-9]{5,}_/.test(e)||/^(sc-|css-)[A-Za-z0-9]{4,}$/.test(e)||/^[a-z]{2,}:[\w-]+$/.test(e)||/^-?(p|m|w|h|min|max|gap|space|inset|top|right|bottom|left)[trblxy]?-/.test(e)||/^-?(text|bg|border|ring|shadow|font|leading|tracking|rounded|opacity|z|flex|grid|col|row|order|justify|items|self|content|place|object)-/.test(e)||(e.match(/\d/g)?.length??0)/e.length>.4)}function Ue(e){let t=Array.from(e.classList),r=t.filter(Ya).slice(0,Ba);return r.length>0?r:t.length>0?["container"]:[]}function Pn(e){let t=e.getAttribute("role")??void 0,r=e.getAttribute("aria-label")??void 0,n=e.getAttribute("tabindex"),o=n!==null&&n!==""?Number(n):void 0,a=e.tagName.toLowerCase(),i=Ha.has(a)||o!==void 0&&Number.isFinite(o)&&o>=0;if(t===void 0&&r===void 0&&o===void 0&&!i)return;let s={focusable:i};return t!==void 0&&(s.role=t),r!==void 0&&(s.ariaLabel=r),o!==void 0&&Number.isFinite(o)&&(s.tabIndex=o),s}function Ua(e){let t=e.tagName.toLowerCase(),r=In[t]??t,n=e.getAttribute("aria-label");if(n)return `${r} ${tt(Me(n,Ye))}`;let o=e.placeholder;if(o)return `${r} ${tt(Me(o,Ye))}`;let a=e.getAttribute("name");if(a)return `${r}[name="${a}"]`;if(t==="input"){let i=e.type||"text";return `${r}[type=${i}]`}return r}function Xa(e){let t=e.alt?.trim();return t?`img ${tt(Me(t,Ye))}`:"img"}function vt(e){let t=e.tagName.toLowerCase();if(t==="img")return Xa(e);if(t==="input"||t==="textarea"||t==="select")return Ua(e);let r=In[t]??t,n=e.getAttribute("aria-label");if(n)return `${r} ${tt(Me(n,Ye))}`;if(t==="a"||t==="button"||Rn.has(t)||t==="label"){let a=$t(e);if(a)return `${r} ${tt(Me(a,Ye))}`;if(t==="a"||t==="button"){let i=e.querySelector("svg");if(i){let c=i.getAttribute("aria-label");return c?`${r} ${tt(Me(c,Ye))}`:`${r} (icon)`}let s=e.getAttribute("href");if(t==="a"&&s)return `link[href="${Me(s,Ye)}"]`}return r}if(e.id)return `${t}#${e.id}`;let o=Ue(e);return o.length>0?`${t}.${o[0]}`:t}function Nn(e){let t=[],r=e,n=0;for(;r&&r.tagName.toLowerCase()!=="body"&&n<6;)t.unshift(vt(r)),r=r.parentElement,n++;return r&&r.tagName.toLowerCase()==="body"&&t.unshift("body"),t.join(" > ").slice(0,Fa)}function Mn(e){let t=$t(e),r=e.parentElement;if(!r)return;let n=$t(r);if(n){if(t&&n===t){let o=r.parentElement;if(!o)return;let a=$t(o);return !a||a===t?void 0:Me(a,Tn)}return Me(n,Tn)}}function _n(e){let t=e.parentElement;if(!t)return [];let r=[];for(let n of Array.from(t.children))if(n!==e&&n.tagName.toLowerCase()!=="script"&&(r.push(vt(n)),r.length>=Va))break;return r}var Ga=["role","aria-label","name"],Ka=10,En=100;function Ht(e){let t={};for(let r of Ga){let n=e.getAttribute(r);n!==null&&n!==""&&(t[r]=n.slice(0,En));}for(let r of Array.from(e.attributes)){if(Object.keys(t).length>=Ka)break;r.name.startsWith("data-")&&r.value!==""&&(t[r.name]=r.value.slice(0,En));}return t}function Ft(e){return Wa(e)}function Dn(e){let t=e;for(;t&&t.nodeType!==1;)t=t.parentNode;return t}function Vt(e,t){return e.closest(`[${t}]`)!==null}var qa=new Set(["p","span","li","td","th","label","blockquote","figcaption","code","pre","strong","em","i","b","u","mark","small","sub","sup","abbr","cite","q","dt","dd"]),ja={article:"Article",aside:"Sidebar",dialog:"Dialog",fieldset:"Form section",figure:"Image",footer:"Footer",form:"Form",header:"Header",main:"Main content",nav:"Navigation",section:"Section",summary:"Summary"},Za={a:"Link",article:"Article",aside:"Sidebar",blockquote:"Text",button:"Button",code:"Text",div:"Area",figcaption:"Text",figure:"Image",footer:"Footer",form:"Form",header:"Header",img:"Image",input:"Field",label:"Text",li:"Text",main:"Main content",nav:"Navigation",p:"Text",pre:"Text",section:"Section",select:"Field",span:"Text",svg:"Icon",textarea:"Field"},Ja={caption:"Text",cell:"Text","code block":"Text",icon:"Icon",input:"Field",label:"Text",link:"Link","list item":"Text",paragraph:"Text",quote:"Text",select:"Field",textarea:"Field"};function On(e,t){let r=e.replace(/\s+/g," ").trim();return r.length<=t?r:`${r.slice(0,t-1).trim()}\u2026`}function Qa(e){return `"${e}"`}function Bt(e){return (e.textContent??"").replace(/\s+/g," ").trim()}function Ln(e){let t=e.replace(/[_-]+/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").trim();return t?t.charAt(0).toUpperCase()+t.slice(1):""}function se(e,t){let r=t?.trim();return r?`${e}: ${Qa(On(r,48))}`:e}function es(e){let t=e.trim(),r=t.match(/^(.+?)\s+"(.+)"$/);return r?{base:r[1]??t,text:r[2]}:{base:t}}function ts(e){let t=e.toLowerCase().replace(/\[[\s\S]*$/,"").trim(),r=Ja[t];if(r)return r;let n=e.match(/^[a-z][\w-]*/i)?.[0]?.toLowerCase();return n?/^h[1-6]$/.test(n)?"Heading":Za[n]??"Area":"Area"}function rs(e){let t=e.getAttribute("aria-label");if(t)return se("Field",t);let r=e.placeholder;if(r)return se("Field",r);let n=e.getAttribute("name");if(n)return se("Field",Ln(n));if(e.tagName.toLowerCase()==="input"){let o=e.type||"text";if(o!=="text")return se("Field",Ln(o))}return "Field"}function xt(e,t){if(t?.trim())return se("Selected text",t);let r=e.tagName.toLowerCase(),n=e.getAttribute("aria-label");if(r==="button")return se("Button",n??Bt(e));if(r==="a")return se("Link",n??Bt(e));if(r==="input"||r==="textarea"||r==="select")return rs(e);if(r==="img"){let a=e.alt;return se("Image",a)}if(r==="svg")return se("Icon",n);if(/^h[1-6]$/.test(r))return se("Heading",Bt(e));if(qa.has(r))return se("Text",Bt(e));let o=ja[r];return se(o||"Area",n)}function Wt(e){return e===1?"1 item selected":`${e} items selected`}function Yt(){return "Selected area"}function zn(e){if(e.targetLabel?.trim())return On(e.targetLabel,120);if(e.selectedText?.trim())return se("Selected text",e.selectedText);let t=e.element?.trim()||e.elementPath?.trim();if(!t)return "Annotation";let r=t.match(/^(\d+)\s+elements?:/i);if(r)return Wt(Number(r[1]));if(/^region\b/i.test(t))return Yt();let n=es(t.split(">").at(-1)??t);return se(ts(n.base),n.text)}function Vn(e){let{clickTarget:t,selection:r}=e,n=r&&!r.isCollapsed?r.toString().trim():"";if(n&&r&&r.rangeCount>0){let o=r.getRangeAt(0),a=Dn(o.commonAncestorContainer);if(a)return {kind:"element",element:a,rect:a.getBoundingClientRect(),selectedText:n,clickTarget:t}}return {kind:"element",element:t,rect:t.getBoundingClientRect(),clickTarget:t}}var $n=20,Bn=7,Hn=10,ns=.8,os=.5,is=new Set(["html","body","head","script","style","meta","link","title","br","noscript"]),as=new Set(["section","article","aside","header","footer","nav","main","figure","form","fieldset","dialog","details","summary"]),Ut=24;function Wn(e){let t=e.tagName.toLowerCase();if(as.has(t))return true;if(t==="div"||t==="span"){if(e.id)return true;let r=Ue(e);if(r.length>0&&r[0]!=="container")return true}return false}var ss=["a","button","input","select","textarea","img","svg","h1","h2","h3","h4","h5","h6","p","span","li","td","th","label","blockquote","figcaption","code","pre","strong","em","div","section","article","aside","header","footer","nav","main","figure","form","fieldset","dialog","details"].join(",");function Fn(e){return {x:e.x,y:e.y,width:e.width,height:e.height}}function ls(e,t){return !(e.x+e.width<t.x||t.x+t.width<e.x||e.y+e.height<t.y||t.y+t.height<e.y)}function cs(e,t,r){if(Vt(e,r))return false;let n=e.tagName.toLowerCase();if(is.has(n))return false;let o=e.getBoundingClientRect();if(o.width<Hn||o.height<Hn||o.width>t.width*ns||o.height>t.height*os)return false;if(n==="div"||n==="span"){let a=Array.from(e.childNodes).some(c=>c.nodeType===3&&(c.textContent??"").trim().length>0),i=e.getAttribute("role"),s=i!==null&&i.length>0;if(!a&&!s&&!Wn(e))return false}return true}function ds(e){return e.filter(t=>!e.some(r=>r!==t&&t.contains(r)))}function us(e,t){let r=[...e].sort((n,o)=>{let a=n.getBoundingClientRect(),i=o.getBoundingClientRect();return a.width*a.height-i.width*i.height});for(let n of r){if(!Wn(n)||!e.every(s=>s===n||n.contains(s)))continue;let a=n.getBoundingClientRect();if(a.left>=t.x-Ut&&a.top>=t.y-Ut&&a.right<=t.x+t.width+Ut&&a.bottom<=t.y+t.height+Ut)return n}return null}function ps(e){let t=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY;for(let a of e)a.x<t&&(t=a.x),a.y<r&&(r=a.y),a.x+a.width>n&&(n=a.x+a.width),a.y+a.height>o&&(o=a.y+a.height);return {x:t,y:r,width:n-t,height:o-r}}function ms(e){let t=e.x+e.width/2,r=e.y+e.height/2,n=e.x+e.width,o=e.y+e.height;return [{x:e.x,y:e.y},{x:t,y:e.y},{x:n,y:e.y},{x:e.x,y:r},{x:t,y:r},{x:n,y:r},{x:e.x,y:o},{x:t,y:o},{x:n,y:o}]}function Yn(e){let{rect:t,viewport:r,internalAttr:n}=e,o=e.doc??document,a=new Set;for(let l of ms(t)){let d=o.elementsFromPoint(l.x,l.y);for(let p of d)a.add(p);}for(let l of Array.from(o.querySelectorAll(ss)))ls(Fn(l.getBoundingClientRect()),t)&&a.add(l);let i=Array.from(a).filter(l=>cs(l,r,n)),s=us(i,t),c=s?[s]:ds(i);if(c.length>0){let l=c.map(d=>Fn(d.getBoundingClientRect()));return {kind:"multi",elements:c,rects:l,union:ps(l)}}return t.width>=$n&&t.height>=$n?{kind:"area",rect:t}:null}var Un="patch-capture-cursor-style";function gs(e){let t=`:not([${e}]):not([${e}] *)`,r=["p","span","h1","h2","h3","h4","h5","h6","li","td","th","label","blockquote","figcaption","code","pre","strong","em","i","b","u","mark","small","sub","sup","abbr","cite","q","dt","dd"].map(n=>`body ${n}${t}`).join(`,
3
3
  `);return ["html, body { cursor: crosshair !important; }",`body *${t} { cursor: crosshair !important; }`,`${r} { cursor: text !important; }`].join(`
4
- `)}function hs(e,t){let r=e.targetDocument,n=r.getElementById(Un);n&&n.remove();let o=r.createElement("style");return o.id=Un,o.setAttribute(t,""),o.textContent=fs(t),r.head.appendChild(o),o}function Wt(e,t,r){let n=e.eventTargetElement(t);return n?n.closest(`[${r}]`)!==null:false}var Ue=1.5,Gn="#0287FE",Kn="rgba(2, 135, 254, 0.032)";function bs(e){let t=e.split(" ")[0]??"",r=Number.parseFloat(t);return Number.isFinite(r)?Math.min(8,Math.max(3,r)):6}function vs(e,t){let r=e.targetDocument,n=r.createElement("div");n.setAttribute(t,""),Object.assign(n.style,{position:"fixed",pointerEvents:"none",border:`${Ue}px solid ${Gn}`,background:Kn,boxSizing:"border-box",zIndex:"2147483645",display:"none",borderRadius:"6px",transition:"top 80ms ease-out, left 80ms ease-out, width 80ms ease-out, height 80ms ease-out, border-radius 80ms ease-out"});let o=r.createElement("div");o.setAttribute(t,""),Object.assign(o.style,{position:"fixed",pointerEvents:"none",background:"#111",color:"#fff",fontFamily:"system-ui, sans-serif",fontSize:"12px",fontWeight:"500",padding:"6px 10px",borderRadius:"6px",zIndex:"2147483646",maxWidth:"240px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"none",boxShadow:"0 10px 24px -12px rgba(0, 0, 0, 0.36), 0 0 0 1px rgba(255, 255, 255, 0.08)"}),r.body.appendChild(n),r.body.appendChild(o);let s=null;return {update(i){let a=i.getBoundingClientRect();if(a.width===0&&a.height===0){this.hide();return}n.style.display="block",n.style.top=`${a.top-Ue}px`,n.style.left=`${a.left-Ue}px`,n.style.width=`${a.width+Ue*2}px`,n.style.height=`${a.height+Ue*2}px`,n.style.borderRadius=`${bs(e.targetWindow.getComputedStyle(i).borderRadius)+Ue}px`,i!==s&&(o.textContent=bt(i),s=i),o.style.display="block";let l=a.right+8,c=Math.max(8,a.top),d=e.getTargetViewport().width-8;l+240<=d?(o.style.left=`${l}px`,o.style.top=`${c}px`):(o.style.left=`${Math.max(8,a.right-240)}px`,o.style.top=`${Math.max(8,a.top-24)}px`);},hide(){n.style.display="none",o.style.display="none";},destroy(){n.remove(),o.remove();}}}function xs(e,t){let r=e.targetDocument.createElement("div");return r.setAttribute(t,""),Object.assign(r.style,{position:"fixed",pointerEvents:"none",border:`${Ue}px solid ${Gn}`,background:Kn,boxSizing:"border-box",zIndex:"2147483645",borderRadius:"8px"}),e.targetDocument.body.appendChild(r),{update(n){r.style.left=`${n.x}px`,r.style.top=`${n.y}px`,r.style.width=`${n.width}px`,r.style.height=`${n.height}px`;},destroy(){r.remove();}}}function Xn(e,t){return {x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),width:Math.abs(t.x-e.x),height:Math.abs(t.y-e.y)}}function qn(e){let{internalAttr:t,onClick:r,onDrag:n,surface:o}=e,s=o.targetDocument,i=hs(o,t),a=vs(o,t),l=false,c=null,d=null;function m(){c?.rectOverlay&&c.rectOverlay.destroy(),c=null;}function u(){d&&(d.destroy(),d=null);}let h=g=>{let p=g,b=o.eventTargetElement(p.target);Wt(o,p.target,t)||b&&wr(b)||(p.preventDefault(),p.stopPropagation(),!l&&(u(),c={startX:p.clientX,startY:p.clientY,isDragging:false,rectOverlay:null}));},v=g=>{let p=g;if(c?.isDragging){p.preventDefault(),p.stopPropagation();let C=Xn({x:c.startX,y:c.startY},{x:p.clientX,y:p.clientY});d=c.rectOverlay,c=null,n?.(C,p);return}m();let b=o.eventTargetElement(p.target);Wt(o,p.target,t)||b&&wr(b)||(p.preventDefault(),p.stopPropagation());},x=g=>{let p=g;Wt(o,p.target,t)||(p.preventDefault(),p.stopPropagation(),!l&&r(p));},T=g=>{let p=g;if(c){if(!c.isDragging){let A=p.clientX-c.startX,f=p.clientY-c.startY;if(Math.hypot(A,f)<Bn)return;c.isDragging=true,a.hide(),c.rectOverlay=xs(o,t);}c.rectOverlay?.update(Xn({x:c.startX,y:c.startY},{x:p.clientX,y:p.clientY}));return}if(l)return;let b=o.eventTargetElement(p.target);if(!b){a.hide();return}if(Wt(o,b,t)){a.hide();return}let C=b.tagName.toLowerCase();if(C==="html"||C==="body"){a.hide();return}a.update(b);},w=g=>{g.relatedTarget||a.hide();};return s.addEventListener("mousedown",h,true),s.addEventListener("mouseup",v,true),s.addEventListener("click",x,true),s.addEventListener("mousemove",T,true),s.addEventListener("mouseout",w,true),{exit(){i.remove(),a.destroy(),m(),u(),s.removeEventListener("mousedown",h,true),s.removeEventListener("mouseup",v,true),s.removeEventListener("click",x,true),s.removeEventListener("mousemove",T,true),s.removeEventListener("mouseout",w,true);},pause(){l=true,a.hide(),m();},resume(){l=false;},dismissDragOverlay(){u();}}}var Zn="data-patch-internal",Qn=createContext(null),jn=0;function Jn(){return jn+=1,`tmp-${Date.now().toString(36)}-${jn}`}function eo({children:e}){let t=xe(),r=re(),n=ce(),{isPreviewing:o,previewReady:s}=Je(),[i,a]=useState(false),l=useRef(null),c=useRef(t),d=useRef(r);c.current=t,d.current=r;let m=useCallback(g=>{let p=c.current;if(p.active&&p.draftText.trim().length>0){p.attemptClose();return}let b=n.eventTargetElement(g.target)??n.targetDocument.body,C=n.targetWindow.getSelection(),A=Vn({clickTarget:b,selection:C}),f=Jn(),I={viewportX:g.clientX,viewportY:g.clientY,documentY:g.clientY+n.getTargetScrollY()};d.current.addEphemeral({tempId:f,viewportX:I.viewportX,viewportY:I.viewportY,documentY:I.documentY}),c.current.openComposer({tempId:f,target:A,anchor:I}),l.current?.pause();},[n]),u=useCallback((g,p)=>{let b=c.current;if(b.active&&b.draftText.trim().length>0){b.attemptClose(),l.current?.dismissDragOverlay();return}let C=n.getTargetViewport(),A=Yn({rect:g,viewport:C,internalAttr:Zn,doc:n.targetDocument});if(!A){l.current?.dismissDragOverlay();return}let f=Jn(),I={viewportX:p.viewportX,viewportY:p.viewportY,documentY:p.viewportY+n.getTargetScrollY()};d.current.addEphemeral({tempId:f,viewportX:I.viewportX,viewportY:I.viewportY,documentY:I.documentY}),c.current.openComposer({tempId:f,target:A,anchor:I}),l.current?.pause();},[n]),h=r.annotationsReady&&(!o||s);useEffect(()=>{if(!i||!h){l.current?.exit(),l.current=null;return}return l.current?.exit(),l.current=qn({internalAttr:Zn,surface:n,onClick:m,onDrag:(g,p)=>u(g,{viewportX:p.clientX,viewportY:p.clientY})}),()=>{l.current?.exit(),l.current=null;}},[i,m,u,n,h]);let v=useCallback(()=>{i||a(true);},[i]),x=useCallback(()=>{a(false);},[]),T=useRef(null);useEffect(()=>{let g=T.current,p=t.active;g?.kind==="composer"&&p?.kind!=="composer"&&(d.current.removeEphemeral(g.tempId),l.current?.dismissDragOverlay(),l.current?.resume()),g?.kind==="composer"&&p?.kind==="composer"&&g.tempId!==p.tempId&&d.current.removeEphemeral(g.tempId),T.current=p;},[t.active]),useEffect(()=>()=>{l.current?.exit(),l.current=null;},[]);let w=useMemo(()=>({isCapturing:i,enter:v,exit:x}),[i,v,x]);return jsx(Qn.Provider,{value:w,children:e})}function to(){let e=use(Qn);if(!e)throw new Error("useCaptureControls must be used inside <CaptureProvider>");return e}var Es="patch:focus-intent";function Ar(e){return `${Es}:${e}`}function Rs(e){try{let t=window.sessionStorage.getItem(Ar(e));if(!t)return null;window.sessionStorage.removeItem(Ar(e));let r=JSON.parse(t);return typeof r.id!="string"||typeof r.url!="string"?null:{id:r.id,url:r.url,viewport:r.viewport??"desktop"}}catch{return null}}function Is(e,t){try{window.sessionStorage.setItem(Ar(e),JSON.stringify(t));}catch{}}var oo=createContext(null);function Ns(e){return e==="pending"||e==="acknowledged"}function io({projectToken:e,children:t}){let{apiClient:r,active:n,viewerKind:o,annotations:s}=re(),i=o==="studio",[a,l]=useState([]),[c,d]=useState(false),[m,u]=useState(null),h=useRef(r);h.current=r;let v=useCallback(async()=>{if(!i){l([]),d(true);return}let f=await h.current.listRoster();l(f),d(true);},[i]);useEffect(()=>{if(!n||!i)return;let f=Rs(e);f&&ae(f.url)===ae(window.location.href)&&u(f),v();},[n,i,e,v]);let x=useMemo(()=>s.map(f=>`${f.id}:${f.status}`).sort().join(","),[s]),T=useRef(null);useEffect(()=>{if(!(!n||!i)){if(T.current===null){T.current=x;return}T.current!==x&&(T.current=x,v());}},[x,n,i,v]);let w=useCallback(f=>{let I={id:f.id,url:f.url,viewport:f.viewport};if(ae(f.url)===ae(window.location.href)){u(I);return}Is(e,I),window.location.assign(f.url);},[e]),g=useCallback(()=>u(null),[]),p=useMemo(()=>{let f=new Map;for(let I of s)f.set(I.id,I.status);return f},[s]),b=useMemo(()=>a.map(f=>{let I=p.get(f.id);return I&&I!==f.status?{...f,status:I}:f}),[a,p]),C=useMemo(()=>b.filter(f=>Ns(f.status)).length,[b]),A=useMemo(()=>({entries:b,ready:c,unresolvedCount:C,refresh:v,focusPin:w,pendingFocus:m,clearFocus:g}),[b,c,C,v,w,m,g]);return jsx(oo.Provider,{value:A,children:t})}function et(){let e=use(oo);if(!e)throw new Error("useRosterStore must be used inside <RosterProvider>");return e}var so=createContext(null);function lo({children:e}){let[t,r]=useState(false),[n,o]=useState(false),s=useMemo(()=>({dockOpen:t,hideResolvedAnnotations:n,setDockOpen:r,setHideResolvedAnnotations:o}),[t,n]);return jsx(so.Provider,{value:s,children:e})}function De(){let e=use(so);if(!e)throw new Error("useWidgetUiStore must be used inside <WidgetUiProvider>");return e}var co="[Patch] No project token found, widget disabled. Pass `projectToken` as a prop, or set NEXT_PUBLIC_PATCH_TOKEN (Next.js), VITE_PATCH_TOKEN (Vite / React Router), or PUBLIC_PATCH_TOKEN (Astro) in your env.";function uo(e){let t=e.prop?.trim();if(t)return t;let r=e.processEnv?.NEXT_PUBLIC_PATCH_TOKEN?.trim();if(r)return r;let n=e.importMetaEnv?.VITE_PATCH_TOKEN?.trim();if(n)return n;let o=e.importMetaEnv?.PUBLIC_PATCH_TOKEN?.trim();return o||null}function po(){try{return typeof import.meta>"u"?void 0:import.meta.env}catch{return}}function mo(){try{return typeof process>"u"||!process.env?void 0:{NEXT_PUBLIC_PATCH_TOKEN:process.env.NEXT_PUBLIC_PATCH_TOKEN}}catch{return}}var Os=new Set(["AmpStateContext","AppRouter","AppRouterContext","ClientPageRoot","ClientSegmentRoot","ErrorBoundary","ForbiddenBoundary","GlobalLayoutRouterContext","HTTPAccessFallbackBoundary","HTTPAccessFallbackErrorBoundary","HeadManagerContext","HotReload","ImageConfigContext","InnerLayoutRouter","InnerScrollAndFocusHandler","InnerScrollAndFocusHandlerOld","LayoutRouterContext","LoadingBoundary","NavigationPromisesContext","NotFoundBoundary","OuterLayoutRouter","PathParamsContext","PathnameContext","ReactDevOverlay","RedirectBoundary","RedirectErrorBoundary","RenderFromTemplateContext","RouterContext","ScrollAndMaybeFocusHandler","SearchParamsContext","SegmentStateProvider","SegmentViewNode","ServerInsertedHTMLContext","Suspense","TemplateContext","UnauthorizedBoundary","AwaitContext","BrowserRouter","DataRouterContext","DataRouterStateContext","DataRoutes","FetchersContext","HashRouter","LocationContext","MemoryRouter","NavigationContext","Outlet","RenderErrorBoundary","RenderedRoute","Route","RouteContext","RouteErrorContext","Router","RouterProvider","Routes","StaticRouter","StaticRouterProvider","ViewTransitionContext"]);function zs(e,t){return e.length<=t?e:`${e.slice(0,t-1).trim()}\u2026`}function go(e){return e.replace(/\s+/g," ").trim()}function Sr(e){return Os.has(go(e))}function fo(e){if(!e)return null;let t=[],r=e.matchAll(/<([^<>]+)>/g);for(let n of r){let o=go(n[1]??"");!o||Sr(o)||t[t.length-1]!==o&&t.push(o);}return t.length===0?null:zs(t.map(n=>`<${n}>`).join(" "),1e3)}var ho="seed:";function Xt(e){return e?e.startsWith(ho)?{url:null,seed:e.slice(ho.length)||null}:/^https?:\/\//i.test(e)?{url:e,seed:null}:{url:null,seed:e}:{url:null,seed:null}}var Tr=[6,20,34,92,120,140,158,174,190,206,220,234,252,270,286,300,318,336,350],bo=[{hue:"near",sat:[88,98],light:[68,82],r:[.44,.62],opacity:[.9,1],reach:[.14,.32]},{hue:"base",sat:[85,96],light:[44,56],r:[.5,.74],opacity:[.85,1],reach:[.2,.42]},{hue:"accent",sat:[84,97],light:[50,66],r:[.42,.64],opacity:[.8,.98],reach:[.26,.48]},{hue:"accent2",sat:[82,95],light:[30,46],r:[.44,.66],opacity:[.72,.94],reach:[.24,.46]}],vo=Math.PI*2;function Hs(e){let t=2166136261;for(let r=0;r<e.length;r++)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return t>>>0}function Fs(e){return ()=>{e+=1831565813;let t=e;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}}function X(e,t,r){return t+e()*(r-t)}function de(e,t=3){let r=10**t;return Math.round(e*r)/r}function xo(e,t,r){return `hsl(${de((e%360+360)%360,1)} ${de(t,1)}% ${de(r,1)}%)`}function wo(e){let t=Hs(e?.trim()||"patch-client"),r=Fs(t),n=t.toString(36),o=(Tr[t%Tr.length]??Tr[0])+X(r,-10,10),s=r()<.5?-1:1,i=r()<.5?-1:1,a=o+i*X(r,52,116),l=o-i*X(r,26,66),c=o+s*X(r,12,38),d=xo(o+s*X(r,0,14),X(r,80,92),X(r,44,54)),m=X(r,0,vo),u=bo.map((h,v)=>{let T=(h.hue==="accent"?a:h.hue==="accent2"?l:h.hue==="near"?c:o)+X(r,-11,11),w=m+v/bo.length*vo+X(r,-0.6,.6),g=X(r,h.reach[0],h.reach[1]),p=de(.5+Math.cos(w)*g),b=de(.5+Math.sin(w)*g),C=de(X(r,0,180),1),A=de(X(r,.62,1.5),3),f=de(X(r,.62,1.5),3);return {id:`cav-${n}-${v}`,cx:p,cy:b,r:de(X(r,h.r[0],h.r[1])),color:xo(T,X(r,h.sat[0],h.sat[1]),X(r,h.light[0],h.light[1])),opacity:de(X(r,h.opacity[0],h.opacity[1]),2),gradientTransform:`rotate(${C} ${p} ${b}) translate(${p} ${b}) scale(${A} ${f}) translate(${de(-p)} ${de(-b)})`}});return {id:n,background:d,spots:u,blur:de(X(r,3.4,5.4),2),grain:de(X(r,.09,.15),2)}}function xt(e){let t=e.gap??12,r=e.margin??16,n=Math.min(e.popover.width,Math.max(0,e.viewport.width-r*2)),o="right",s=e.anchor.x+e.anchor.width+t;s+n>e.viewport.width-r&&(o="left",s=e.anchor.x-n-t),s<r&&(s=r);let i=e.anchor.y;return i+e.popover.height>e.viewport.height-r&&(i=e.viewport.height-r-e.popover.height),i<r&&(i=r),{x:s,y:i,width:n,placement:o}}function M(...e){return e.filter(Boolean).join(" ")}function Kt({seed:e,className:t,style:r}){let n=wo(e),o=useId().replace(/[^a-zA-Z0-9_-]/g,""),s=`${n.id}-${o}`,i=`cav-blur-${s}`,a=`cav-grain-${s}`;return jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 64 64",className:M("absolute inset-0 size-full! overflow-hidden rounded-full",t),style:r,children:[jsxs("defs",{children:[jsx("filter",{id:i,x:"-20%",y:"-20%",width:"140%",height:"140%",children:jsx("feGaussianBlur",{stdDeviation:n.blur})}),jsxs("filter",{id:a,x:"0%",y:"0%",width:"100%",height:"100%",children:[jsx("feTurbulence",{type:"fractalNoise",baseFrequency:"0.9",numOctaves:"2",stitchTiles:"stitch"}),jsx("feColorMatrix",{type:"saturate",values:"0"})]}),n.spots.map(l=>jsxs("radialGradient",{id:`${s}-${l.id}`,cx:l.cx,cy:l.cy,r:l.r,gradientTransform:l.gradientTransform,children:[jsx("stop",{offset:"0%",stopColor:l.color,stopOpacity:l.opacity}),jsx("stop",{offset:"100%",stopColor:l.color,stopOpacity:0})]},l.id))]}),jsx("rect",{width:"64",height:"64",fill:n.background}),jsx("g",{filter:`url(#${i})`,children:n.spots.map(l=>jsx("rect",{width:"64",height:"64",fill:`url(#${s}-${l.id})`},l.id))}),jsx("rect",{width:"64",height:"64",filter:`url(#${a})`,opacity:n.grain,style:{mixBlendMode:"overlay"}})]})}var Le=28,yo=[.22,.61,.36,1],qt=["var(--color-avatar-tint-1)","var(--color-avatar-tint-2)","var(--color-avatar-tint-3)","var(--color-avatar-tint-4)","var(--color-avatar-tint-5)"];function tt(e){if(!e)return "?";let t=e.trim().split(/\s+/),r=t[0],n=t[t.length-1];if(!r||!n)return "?";if(t.length===1)return r.slice(0,2).toUpperCase();let o=r[0]??"",s=n[0]??"";return (o+s).toUpperCase()||"?"}function rt(e){if(!e)return qt[0];let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t|=0;return qt[Math.abs(t)%qt.length]??qt[0]}var Bs={right:"50% 50% 3px 50%",left:"50% 50% 50% 3px"},Ws={right:"50% 50% 2px 50%",left:"50% 50% 50% 2px"};function nt(e,t){let{placement:r}=xt({anchor:{x:e.viewportX-Le/2,y:e.viewportY-Le/2,width:Le,height:Le},popover:{width:332,height:200},viewport:t});return r==="right"?"left":"right"}function Zt(e,t){return {x:t==="left"?e.viewportX:e.viewportX-Le,y:e.viewportY-Le,width:Le,height:Le}}function Er({ref:e,...t}){let r=t.pointSide??"right",n=!t.resolved&&t.attention?Ys[t.attention]:null,{url:o,seed:s}=Xt(t.avatarSrc),i=s??t.generatedSeed,a=t.orphan?"grayscale(1)":t.resolved?"saturate(0.55) brightness(1.04) contrast(0.92)":"",l=t.orphan?.55:1,c=r==="right"?"-bottom-0.5 -left-0.5":"-bottom-0.5 -right-0.5";return jsx(motion.button,{ref:e,type:"button",onClick:t.onClick,"aria-label":t.ariaLabel??"Open annotation","data-patch-ephemeral":t.ephemeral?"":void 0,"data-patch-pin-id":t.pinId,className:"patch-pin-button fixed z-[2147483645] size-7 border-0 bg-transparent p-0",initial:t.ephemeral?{opacity:0,scale:.45}:false,animate:t.ephemeral?{opacity:1,scale:1,transition:{type:"spring",stiffness:620,damping:30,mass:.65}}:{opacity:1,scale:1},exit:t.ephemeral?{opacity:0,scale:.45,transition:{delay:.16,duration:.14,ease:yo}}:{opacity:0,scale:.9,transition:{duration:.12,ease:yo}},children:jsxs("span",{className:"patch-pin relative grid size-full place-items-center","data-patch-point-side":r,style:{borderRadius:Bs[r]},children:[jsxs("span",{"data-patch-avatar":"",className:"absolute inset-[2px] overflow-hidden",style:{borderRadius:Ws[r],background:"var(--color-muted-foreground)",filter:t.orphan?"grayscale(1)":"none",opacity:t.orphan?.55:1},children:[i?jsx(Kt,{seed:i,style:{borderRadius:0,filter:a||"none",opacity:l}}):null,o?jsx("img",{src:o,alt:t.avatarAlt??"",referrerPolicy:"no-referrer",className:"absolute inset-0 size-full object-cover",draggable:false,style:{filter:a||"none",opacity:l},onError:d=>{d.currentTarget.remove();}}):null]}),t.resolved&&jsx("span",{className:`absolute ${c} grid size-[13px] place-items-center rounded-full bg-brand-green text-[8px] font-bold leading-none text-white`,children:"\u2713"}),n&&jsx("span",{"data-patch-attention":t.attention,"aria-hidden":"true",className:`absolute -top-0.5 -right-0.5 size-[9px] rounded-full border-[1.5px] border-white ${n}`})]})})}var Ys={"review-pr":"bg-brand","patch-failed":"bg-destructive","rerun-after-closed":"bg-muted-foreground"};function jt(e){let t=new Date(e).getTime(),r=Date.now()-t,n=Math.round(r/6e4);if(Number.isNaN(n))return "";if(n<1)return "just now";if(n<60)return `${n}m ago`;let o=Math.round(n/60);return o<24?`${o}h ago`:`${Math.round(o/24)}d ago`}function Co(e){let t=e.composedPath();for(let r of t)if(r instanceof Element&&r.tagName?.toLowerCase()==="patch-widget-root")return true;return false}function Ao(e){let t=e.match(/\/pull\/(\d+)/);return t?`#${t[1]}`:"PR"}var So={"arrow-up":[["path",{d:"M12 5.5V19"}],["path",{d:"M18 11C18 11 13.5811 5.00001 12 5C10.4188 4.99999 6 11 6 11"}]],check:[["path",{d:"M5 14L8.5 17.5L19 6.5"}]],cursor:[["path",{d:"M12.669 8.35811L17.6969 10.3256C20.5969 11.4604 22.0469 12.0277 21.9988 12.9278C21.9508 13.8278 20.4375 14.2405 17.4111 15.0659C16.5099 15.3117 16.0593 15.4346 15.7469 15.7469C15.4346 16.0593 15.3117 16.5099 15.0659 17.4111C14.2405 20.4375 13.8278 21.9508 12.9278 21.9988C12.0277 22.0469 11.4604 20.5969 10.3256 17.6969L8.35811 12.669C7.17004 9.63279 6.57601 8.1147 7.34535 7.34535C8.1147 6.57601 9.63279 7.17004 12.669 8.35811Z"}],["path",{d:"M9 4V2M5 5L3.5 3.5M4 9H2M5 13L3.5 14.5M14.5 3.5L13 5"}]],desktop:[["path",{d:"M14 21H16M14 21C13.1716 21 12.5 20.3284 12.5 19.5V17L12 17M14 21H10M10 21H8M10 21C10.8284 21 11.5 20.3284 11.5 19.5V17L12 17M12 17V21"}],["path",{d:"M16 3H8C5.17157 3 3.75736 3 2.87868 3.87868C2 4.75736 2 6.17157 2 9V11C2 13.8284 2 15.2426 2.87868 16.1213C3.75736 17 5.17157 17 8 17H16C18.8284 17 20.2426 17 21.1213 16.1213C22 15.2426 22 13.8284 22 11V9C22 6.17157 22 4.75736 21.1213 3.87868C20.2426 3 18.8284 3 16 3Z"}]],globe:[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"M8 12C8 18 12 22 12 22C12 22 16 18 16 12C16 6 12 2 12 2C12 2 8 6 8 12Z"}],["path",{d:"M21 15H3"}],["path",{d:"M21 9H3"}]],list:[["path",{d:"M8 5.5L20 5.5"}],["path",{d:"M8 12.5L20 12.5"}],["path",{d:"M8 19.5L20 19.5"}],["path",{d:"M4.375 5.5H4.25M4.5 5.5C4.5 5.63807 4.38807 5.75 4.25 5.75C4.11193 5.75 4 5.63807 4 5.5C4 5.36193 4.11193 5.25 4.25 5.25C4.38807 5.25 4.5 5.36193 4.5 5.5Z"}],["path",{d:"M4.375 12.5H4.25M4.5 12.5C4.5 12.6381 4.38807 12.75 4.25 12.75C4.11193 12.75 4 12.6381 4 12.5C4 12.3619 4.11193 12.25 4.25 12.25C4.38807 12.25 4.5 12.3619 4.5 12.5Z"}],["path",{d:"M4.375 19.5H4.25M4.5 19.5C4.5 19.6381 4.38807 19.75 4.25 19.75C4.11193 19.75 4 19.6381 4 19.5C4 19.3619 4.11193 19.25 4.25 19.25C4.38807 19.25 4.5 19.3619 4.5 19.5Z"}]],lock:[["path",{d:"M4.26781 18.8447C4.49269 20.515 5.87613 21.8235 7.55966 21.9009C8.97627 21.966 10.4153 22 12 22C13.5847 22 15.0237 21.966 16.4403 21.9009C18.1239 21.8235 19.5073 20.515 19.7322 18.8447C19.879 17.7547 20 16.6376 20 15.5C20 14.3624 19.879 13.2453 19.7322 12.1553C19.5073 10.485 18.1239 9.17649 16.4403 9.09909C15.0237 9.03397 13.5847 9 12 9C10.4153 9 8.97627 9.03397 7.55966 9.09909C5.87613 9.17649 4.49269 10.485 4.26781 12.1553C4.12104 13.2453 4 14.3624 4 15.5C4 16.6376 4.12104 17.7547 4.26781 18.8447Z"}],["path",{d:"M7.5 9V6.5C7.5 4.01472 9.51472 2 12 2C14.4853 2 16.5 4.01472 16.5 6.5V9"}],["path",{d:"M12.125 15.5H12M12.25 15.5C12.25 15.6381 12.1381 15.75 12 15.75C11.8619 15.75 11.75 15.6381 11.75 15.5C11.75 15.3619 11.8619 15.25 12 15.25C12.1381 15.25 12.25 15.3619 12.25 15.5Z"}]],maximize:[["path",{d:"M16.4999 3.26621C17.3443 3.25421 20.1408 2.67328 20.7337 3.26621C21.3266 3.85913 20.7457 6.65559 20.7337 7.5M20.5059 3.49097L13.5021 10.4961"}],["path",{d:"M3.26636 16.5001C3.25436 17.3445 2.67343 20.141 3.26636 20.7339C3.85928 21.3268 6.65574 20.7459 7.50015 20.7339M10.502 13.4976L3.49824 20.5027"}]],minimize:[["path",{d:"M6.5023 10.7365C7.34671 10.7485 10.1432 11.3294 10.7361 10.7365C11.329 10.1436 10.7481 7.34708 10.7361 6.50267M13.2685 17.5027C13.2565 16.6583 12.6756 13.8618 13.2685 13.2689C13.8614 12.676 16.6579 13.2569 17.5023 13.2689M20.9991 21.001L13.6102 13.6188M10.3691 10.3763L2.99998 2.99902"}]],mobile:[["path",{d:"M13.5 2H10.5C8.14298 2 6.96447 2 6.23223 2.73223C5.5 3.46447 5.5 4.64298 5.5 7V17C5.5 19.357 5.5 20.5355 6.23223 21.2678C6.96447 22 8.14298 22 10.5 22H13.5C15.857 22 17.0355 22 17.7678 21.2678C18.5 20.5355 18.5 19.357 18.5 17V7C18.5 4.64298 18.5 3.46447 17.7678 2.73223C17.0355 2 15.857 2 13.5 2Z"}],["path",{d:"M12.125 19H12M12.25 19C12.25 19.1381 12.1381 19.25 12 19.25C11.8619 19.25 11.75 19.1381 11.75 19C11.75 18.8619 11.8619 18.75 12 18.75C12.1381 18.75 12.25 18.8619 12.25 19Z"}]],more:[["path",{d:"M12 12.002H12.5M19 12.002H19.5M5 12.002H5.5M12 13.002C12.5523 13.002 13 12.5542 13 12.002C13 11.4497 12.5523 11.002 12 11.002C11.4477 11.002 11 11.4497 11 12.002C11 12.5542 11.4477 13.002 12 13.002ZM19 13.002C19.5523 13.002 20 12.5542 20 12.002C20 11.4497 19.5523 11.002 19 11.002C18.4477 11.002 18 11.4497 18 12.002C18 12.5542 18.4477 13.002 19 13.002ZM5 13.002C5.55228 13.002 6 12.5542 6 12.002C6 11.4497 5.55228 11.002 5 11.002C4.44772 11.002 4 11.4497 4 12.002C4 12.5542 4.44772 13.002 5 13.002Z"}]],play:[["path",{d:"M18.8906 12.846C18.5371 14.189 16.8667 15.138 13.5257 17.0361C10.296 18.8709 8.6812 19.7884 7.37983 19.4196C6.8418 19.2671 6.35159 18.9776 5.95624 18.5787C5 17.6139 5 15.7426 5 12C5 8.2574 5 6.3861 5.95624 5.42132C6.35159 5.02245 6.8418 4.73288 7.37983 4.58042C8.6812 4.21165 10.296 5.12907 13.5257 6.96393C16.8667 8.86197 18.5371 9.811 18.8906 11.154C19.0365 11.7084 19.0365 12.2916 18.8906 12.846Z"}]],pr:[["path",{d:"M6 8L6 16"}],["path",{d:"M18 16V12C18 9.17156 18 7.75735 17.1213 6.87867C16.2426 5.99999 14.8284 5.99999 12 5.99999L11 5.99999M11 5.99999C11 5.29976 12.9943 3.99152 13.5 3.49999M11 5.99999C11 6.70022 12.9943 8.00846 13.5 8.49999"}],["circle",{cx:"6",cy:"18",r:"2"}],["circle",{cx:"6",cy:"6",r:"2"}],["circle",{cx:"18",cy:"18",r:"2"}]],refresh:[["path",{d:"M20.0092 2V5.13219C20.0092 5.42605 19.6418 5.55908 19.4537 5.33333C17.6226 3.2875 14.9617 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22C17.5228 22 22 17.5228 22 12"}]],robot:[["path",{d:"M19 16V14C19 11.1716 19 9.75736 18.1213 8.87868C17.2426 8 15.8284 8 13 8H11C8.17157 8 6.75736 8 5.87868 8.87868C5 9.75736 5 11.1716 5 14V16C5 18.8284 5 20.2426 5.87868 21.1213C6.75736 22 8.17157 22 11 22H13C15.8284 22 17.2426 22 18.1213 21.1213C19 20.2426 19 18.8284 19 16Z"}],["path",{d:"M19 18C20.4142 18 21.1213 18 21.5607 17.5607C22 17.1213 22 16.4142 22 15C22 13.5858 22 12.8787 21.5607 12.4393C21.1213 12 20.4142 12 19 12"}],["path",{d:"M5 18C3.58579 18 2.87868 18 2.43934 17.5607C2 17.1213 2 16.4142 2 15C2 13.5858 2 12.8787 2.43934 12.4393C2.87868 12 3.58579 12 5 12"}],["path",{d:"M13.5 3.5C13.5 4.32843 12.8284 5 12 5C11.1716 5 10.5 4.32843 10.5 3.5C10.5 2.67157 11.1716 2 12 2C12.8284 2 13.5 2.67157 13.5 3.5Z"}],["path",{d:"M12 5V8"}],["path",{d:"M9 13V14"}],["path",{d:"M15 13V14"}],["path",{d:"M10 17.5C10 17.5 10.6667 18 12 18C13.3333 18 14 17.5 14 17.5"}]],settings:[["path",{d:"M15.5 12C15.5 13.933 13.933 15.5 12 15.5C10.067 15.5 8.5 13.933 8.5 12C8.5 10.067 10.067 8.5 12 8.5C13.933 8.5 15.5 10.067 15.5 12Z"}],["path",{d:"M21.011 14.0965C21.5329 13.9558 21.7939 13.8854 21.8969 13.7508C22 13.6163 22 13.3998 22 12.9669V11.0332C22 10.6003 22 10.3838 21.8969 10.2493C21.7938 10.1147 21.5329 10.0443 21.011 9.90358C19.0606 9.37759 17.8399 7.33851 18.3433 5.40087C18.4817 4.86799 18.5509 4.60156 18.4848 4.44529C18.4187 4.28902 18.2291 4.18134 17.8497 3.96596L16.125 2.98673C15.7528 2.77539 15.5667 2.66972 15.3997 2.69222C15.2326 2.71472 15.0442 2.90273 14.6672 3.27873C13.208 4.73448 10.7936 4.73442 9.33434 3.27864C8.95743 2.90263 8.76898 2.71463 8.60193 2.69212C8.43489 2.66962 8.24877 2.77529 7.87653 2.98663L6.15184 3.96587C5.77253 4.18123 5.58287 4.28891 5.51678 4.44515C5.45068 4.6014 5.51987 4.86787 5.65825 5.4008C6.16137 7.3385 4.93972 9.37763 2.98902 9.9036C2.46712 10.0443 2.20617 10.1147 2.10308 10.2492C2 10.3838 2 10.6003 2 11.0332V12.9669C2 13.3998 2 13.6163 2.10308 13.7508C2.20615 13.8854 2.46711 13.9558 2.98902 14.0965C4.9394 14.6225 6.16008 16.6616 5.65672 18.5992C5.51829 19.1321 5.44907 19.3985 5.51516 19.5548C5.58126 19.7111 5.77092 19.8188 6.15025 20.0341L7.87495 21.0134C8.24721 21.2247 8.43334 21.3304 8.6004 21.3079C8.76746 21.2854 8.95588 21.0973 9.33271 20.7213C10.7927 19.2644 13.2088 19.2643 14.6689 20.7212C15.0457 21.0973 15.2341 21.2853 15.4012 21.3078C15.5682 21.3303 15.7544 21.2246 16.1266 21.0133L17.8513 20.034C18.2307 19.8187 18.4204 19.711 18.4864 19.5547C18.5525 19.3984 18.4833 19.132 18.3448 18.5991C17.8412 16.6616 19.0609 14.6226 21.011 14.0965Z"}]],tablet:[["path",{d:"M14.5 2H9.5C6.67157 2 5.25736 2 4.37868 2.87868C3.5 3.75736 3.5 5.17157 3.5 8V16C3.5 18.8284 3.5 20.2426 4.37868 21.1213C5.25736 22 6.67157 22 9.5 22H14.5C17.3284 22 18.7426 22 19.6213 21.1213C20.5 20.2426 20.5 18.8284 20.5 16V8C20.5 5.17157 20.5 3.75736 19.6213 2.87868C18.7426 2 17.3284 2 14.5 2Z"}],["path",{d:"M12.125 19H12M12.25 19C12.25 19.1381 12.1381 19.25 12 19.25C11.8619 19.25 11.75 19.1381 11.75 19C11.75 18.8619 11.8619 18.75 12 18.75C12.1381 18.75 12.25 18.8619 12.25 19Z"}]],trash:[["path",{d:"M19.5 5.5L18.8803 15.5251C18.7219 18.0864 18.6428 19.3671 18.0008 20.2879C17.6833 20.7431 17.2747 21.1273 16.8007 21.416C15.8421 22 14.559 22 11.9927 22C9.42312 22 8.1383 22 7.17905 21.4149C6.7048 21.1257 6.296 20.7408 5.97868 20.2848C5.33688 19.3626 5.25945 18.0801 5.10461 15.5152L4.5 5.5"}],["path",{d:"M3 5.5H21M16.0557 5.5L15.3731 4.09173C14.9196 3.15626 14.6928 2.68852 14.3017 2.39681C14.215 2.3321 14.1231 2.27454 14.027 2.2247C13.5939 2 13.0741 2 12.0345 2C10.9688 2 10.436 2 9.99568 2.23412C9.8981 2.28601 9.80498 2.3459 9.71729 2.41317C9.32164 2.7167 9.10063 3.20155 8.65861 4.17126L8.05292 5.5"}],["path",{d:"M9.5 16.5L9.5 10.5"}],["path",{d:"M14.5 16.5L14.5 10.5"}]],unlink:[["path",{d:"M12.1434 10.691L12.3503 10.4841C14.329 8.50532 17.5372 8.50532 19.5159 10.4841C21.4947 12.4628 21.4947 15.671 19.5159 17.6497L16.6497 20.5159C14.671 22.4947 11.4628 22.4947 9.48405 20.5159C7.50532 18.5372 7.50532 15.329 9.48405 13.3503L9.9484 12.886"}],["path",{d:"M20.0516 11.114L20.5159 10.6497C22.4947 8.67095 22.4947 5.46279 20.5159 3.48405C18.5372 1.50532 15.329 1.50532 13.3503 3.48405L10.4841 6.35031C8.50532 8.32904 8.50532 11.5372 10.4841 13.5159C12.4628 15.4947 15.671 15.4947 17.6497 13.5159L17.8566 13.309"}],["path",{d:"M4.5 4L6 6M2 8L5 9M3 13.5L5 12"}]],x:[["path",{d:"M18 6L6.00081 17.9992M17.9992 18L6 6.00085"}]]};function F({name:e,size:t=16,stroke:r=2,color:n,className:o}){return jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n??"currentColor",strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",className:o,children:So[e].map(([s,i],a)=>createElement(s,{key:a,...i}))})}var Eo=[.16,1,.3,1];function Ks(e){try{let r=new URL(e).pathname.replace(/\/$/,"");return r===""?"/":r}catch{return e}}function Jt(e){return e==="pending"||e==="acknowledged"}function Ro({onClose:e}){let t=et(),{hideResolvedAnnotations:r}=De(),n=t.focusPin,o=typeof window>"u"?"":ae(window.location.href),s=useMemo(()=>[...r?t.entries.filter(d=>d.status!=="resolved"):t.entries].sort((d,m)=>(Jt(d.status)?0:1)-(Jt(m.status)?0:1)),[t.entries,r]),i=useMemo(()=>{let c=t.entries.filter(m=>Jt(m.status)&&ae(m.url)===o).length,d=t.entries.filter(m=>Jt(m.status)).length;return {here:c,elsewhere:d-c,total:d}},[t.entries,o]);function a(){if(i.total===0)return "No open feedback";let c=[`${i.total} open`];return i.here>0&&c.push(`${i.here} here`),i.elsewhere>0&&c.push(`${i.elsewhere} elsewhere`),c.join(" \xB7 ")}function l(c){e(),n(c);}return jsxs(motion.div,{initial:{opacity:0,y:6,scale:.98},animate:{opacity:1,y:0,scale:1,transition:{duration:.18,ease:Eo}},exit:{opacity:0,y:4,scale:.985,transition:{duration:.12,ease:Eo}},"data-patch-fab-dock":"","data-patch-roster-panel":"",className:"absolute right-0 bottom-[54px] z-[2147483647] flex max-h-[min(480px,calc(100vh-120px))] w-[min(360px,calc(100vw-40px))] flex-col overflow-hidden rounded-[22px] border border-black/6 bg-popover font-sans text-popover-foreground shadow-[0_20px_56px_-16px_rgba(0,0,0,0.2),0_8px_18px_-6px_rgba(0,0,0,0.08)]",style:{transformOrigin:"100% 100%"},children:[jsxs("div",{className:"flex items-baseline justify-between gap-2 px-4 pt-3.5 pb-2.5",children:[jsx("span",{className:"text-[13px] font-semibold",children:"Feedback"}),jsx("span",{className:"text-[11.5px] font-medium text-popover-foreground/50",children:a()})]}),s.length===0?jsx("div",{className:"px-4 pt-2 pb-6 text-center text-[12.5px] text-popover-foreground/50",children:"No feedback yet."}):jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-1.5 pb-2",children:s.map(c=>jsx(qs,{entry:c,onCurrentPage:ae(c.url)===o,onClick:()=>l(c)},c.id))})]})}function qs({entry:e,onCurrentPage:t,onClick:r}){let n=e.status==="resolved",o=e.anchorStatus==="detached";return jsxs("button",{type:"button","data-patch-fab-dock":"","data-patch-roster-row":e.id,onClick:r,className:"flex w-full items-start gap-2.5 rounded-[14px] px-2.5 py-2 text-left transition-colors hover:bg-black/[0.04]",children:[jsx("span",{className:"mt-0.5 grid size-4 shrink-0 place-items-center",children:n?jsx("span",{className:"grid size-4 place-items-center rounded-full bg-brand-green text-white",children:jsx(F,{name:"check",size:10,stroke:2.6})}):e.status==="dismissed"?jsx("span",{className:"size-2 rounded-full border border-black/20"}):jsx("span",{className:"size-2 rounded-full bg-brand"})}),jsxs("span",{className:"min-w-0 flex-1",children:[jsx("span",{className:M("block truncate text-[12.5px] leading-snug",n?"text-popover-foreground/45 line-through":"text-popover-foreground"),children:e.label}),jsxs("span",{className:"mt-0.5 flex items-center gap-1.5 text-[11px] text-popover-foreground/50",children:[jsx(F,{name:we[e.viewport].glyph,size:11,className:"shrink-0 opacity-80"}),jsx("span",{className:"truncate",children:t?"This page":Ks(e.url)}),jsx("span",{"aria-hidden":"true",children:"\xB7"}),jsx("span",{className:"shrink-0",children:jt(e.createdAt)}),o?jsxs("span",{className:"ml-0.5 inline-flex shrink-0 items-center gap-1 rounded-full bg-black/[0.05] px-1.5 py-px text-[10px] font-medium text-popover-foreground/55",children:[jsx(F,{name:"unlink",size:10}),"element gone"]}):null]})]})]})}var Zs="relative inline-grid shrink-0 overflow-hidden place-items-center rounded-full text-white font-semibold tracking-[-0.01em]",js={sm:"size-[22px] text-[9.5px]",md:"size-7 text-[10.5px]"};function Oe({initials:e,tint:t,src:r,generatedSeed:n,alt:o="",size:s="md",className:i,style:a}){let{url:l,seed:c}=Xt(r),d=c??n;return jsxs("span",{className:M(Zs,js[s],i),style:{background:t,...a},children:[jsx("span",{children:e}),!l&&d?jsx(Kt,{seed:d}):null,l?jsx("img",{src:l,alt:o,referrerPolicy:"no-referrer",className:"absolute inset-0 size-full rounded-full object-cover",draggable:false,onError:m=>{m.currentTarget.remove();}}):null]})}var Qs="M48 0C67.8823 0 84 16.1178 84 36V63C84 67.9706 79.9706 72 75 72H48C42.2522 72 36.8201 70.6505 32 68.2549V87C32 91.9706 27.9706 96 23 96H14C12.8954 96 12 95.1046 12 94V36C12 16.1178 28.1178 0 48 0ZM48 18C38.0589 18 30 26.0589 30 36C30 45.9411 38.0589 54 48 54C57.9411 54 66 45.9411 66 36C66 26.0589 57.9411 18 48 18Z",el="M12 2A10 10 0 0 1 22 12V20.6A1.4 1.4 0 0 1 20.6 22H12A10 10 0 0 1 2 12A10 10 0 0 1 12 2Z";function kt({size:e=16,className:t}){return jsx("svg",{width:e,height:e,viewBox:"0 0 96 96",fill:"currentColor","aria-hidden":"true",focusable:"false",className:t,children:jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:Qs})})}function Io({size:e=16,variant:t="filled",stroke:r=2,className:n}){let o=t==="outline";return jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:o?"none":"currentColor",stroke:o?"currentColor":"none",strokeWidth:o?r:void 0,strokeLinejoin:o?"round":void 0,strokeLinecap:o?"round":void 0,"aria-hidden":"true",focusable:"false",className:n,children:jsx("path",{d:el})})}var Ir=false,Xe=null,er=null,ke={openDelay:700,isInstant(){return Ir},onOpen(e){er&&er!==e&&er(),er=e??null,Ir=true,Xe&&(clearTimeout(Xe),Xe=null);},onClose(){Xe&&clearTimeout(Xe),Xe=setTimeout(()=>{Ir=false,Xe=null;},300);}};var Mo="easeOut";function Re({text:e,children:t,className:r,tone:n="default",placement:o="top"}){let[s,i]=useState(false),[a,l]=useState(false),c=useRef(null),d=useRef(false);useEffect(()=>()=>{c.current&&clearTimeout(c.current),d.current&&ke.onClose();},[]);let m=b=>{l(b),i(true),d.current=true,ke.onOpen();},u=()=>{if(c.current&&(clearTimeout(c.current),c.current=null),ke.isInstant()){m(true);return}c.current=setTimeout(()=>{c.current=null,m(false);},ke.openDelay);},h=()=>{c.current&&(clearTimeout(c.current),c.current=null),d.current&&(d.current=false,ke.onClose()),i(false);},v=n==="warning"?"pointer-events-none absolute bottom-[calc(100%+8px)] left-0 z-[1]":o==="bottom"?"pointer-events-none absolute top-[calc(100%+8px)] left-1/2 z-[1] -translate-x-1/2":"pointer-events-none absolute -top-[38px] left-1/2 z-[1] -translate-x-1/2",x="shadow-[0_10px_30px_-10px_rgba(0,0,0,0.45),0_3px_8px_-3px_rgba(0,0,0,0.3)] ring-1 ring-white/10",T=n==="warning"?`relative flex w-[200px] items-start gap-1.5 rounded-[14px] bg-foreground px-3 py-2.5 text-left text-[11px] leading-[1.35] font-medium text-white ${x}`:`relative block whitespace-nowrap rounded-[10px] bg-foreground px-2.5 py-[6px] text-[11px] font-medium tracking-[0.01em] text-white ${x}`,w=n==="warning"?"absolute -bottom-1 left-6 size-2 rotate-45 rounded-[2px] border-r border-b border-white/10 bg-foreground":o==="bottom"?"absolute -top-1 left-1/2 size-2 -translate-x-1/2 rotate-45 rounded-[2px] border-l border-t border-white/10 bg-foreground":"absolute -bottom-1 left-1/2 size-2 -translate-x-1/2 rotate-45 rounded-[2px] border-r border-b border-white/10 bg-foreground",g=o==="bottom"&&n!=="warning"?-3:3,p=o==="bottom"&&n!=="warning"?-2:2;return jsxs("span",{className:M("relative inline-flex items-center justify-center",r),onMouseEnter:u,onMouseLeave:h,onMouseDown:h,children:[jsx("span",{className:v,children:jsx(AnimatePresence,{children:s&&jsxs(motion.span,{initial:a?false:{opacity:0,y:g,scale:.98},animate:{opacity:1,y:0,scale:1,transition:a?{duration:0}:{duration:.1,ease:Mo}},exit:{opacity:0,y:p,scale:.98,transition:{duration:.08,ease:Mo}},className:T,children:[n==="warning"?jsxs("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:"mt-px size-3.5 shrink-0",children:[jsx("path",{d:"M10.3 3.9 1.8 18.6A2 2 0 0 0 3.5 21.6h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0Z",fill:"#fbbf24"}),jsx("path",{d:"M12 9v4.5M12 17h.01",fill:"none",stroke:"#fff",strokeWidth:"2",strokeLinecap:"round"})]}):null,jsx("span",{className:"min-w-0 flex-1",children:e}),jsx("span",{className:w})]})})}),t]})}var Do=44,Ie=[.16,1,.3,1],Lo="easeOut",il=.08,al=60,sl="calc(100% - 64px) calc(100% + 4px)",st="pkey pkey-dock grid size-8 place-items-center rounded-full border-0 bg-transparent";function Oo(){let e=to(),t=xe(),r=re(),n=et(),{dockOpen:o,hideResolvedAnnotations:s,setDockOpen:i,setHideResolvedAnnotations:a}=De(),l=!!r.studio,c=n.unresolvedCount,[d,m]=useState(false),[u,h]=useState(false),[v,x]=useState(false),[T,w]=useState(false),[g,p]=useState(false),[b,C]=useState(false),A=useRef(null),f=useRef(null),I=useRef(false),[Q,Z]=useState(false),be=useRef(null),[pe,oe]=useState(Do);useLayoutEffect(()=>{let z=be.current;if(!z)return;let ie=()=>oe(z.offsetWidth);ie();let Se=new ResizeObserver(ie);return Se.observe(z),()=>Se.disconnect()},[]);let ee=r.studio?r.studio.name:r.identity?.name??null,U=tt(ee),k=r.studio?.image??null,N=r.identity?.avatarSeed??r.clientAvatarSeed,_=r.studio?.userId??N,S=r.studio?"var(--color-foreground)":rt(N),L=r.studio&&!k?"#FFFFFF":S,H=r.studio&&!k?"text-foreground":"text-white",E=we[r.activeViewport];function te(){A.current!==null&&(window.clearTimeout(A.current),A.current=null);}function me(){f.current!==null&&(window.clearTimeout(f.current),f.current=null);}let P=useRef(()=>{});P.current=()=>{!I.current&&A.current===null||(te(),me(),I.current=false,C(true));};let D=useRef(()=>P.current()).current;useEffect(()=>{b&&d&&m(false);},[b,d]);function $(z){h(false),x(false),w(false),te(),me(),I.current=true,C(false),p(z),ke.onOpen(D),m(true);}function K(){$(false);}function Ae(){if(te(),!(I.current||f.current!==null)){if(ke.isInstant()){$(true);return}f.current=window.setTimeout(()=>{f.current=null,$(false);},ke.openDelay);}}function ge(){me(),te(),I.current&&(I.current=false,ke.onClose()),A.current=window.setTimeout(()=>{m(false),A.current=null;},120);}function Ve(){Z(true),i(true);}function Rt(){h(false),x(false),w(false),me(),I.current=false,m(false),e.isCapturing?e.exit():e.enter();}function It(){h(false),x(false),me(),I.current=false,m(false),w(z=>{let ie=!z;return ie&&n.refresh(),ie});}function dr(){Z(true),i(false),h(false),x(false),w(false),me(),I.current=false,m(false),e.exit(),t.active&&t.forceClose();}useEffect(()=>()=>{A.current!==null&&window.clearTimeout(A.current),f.current!==null&&window.clearTimeout(f.current);},[]);let R=()=>{r.signOut(),m(false);};function O(){x(false),w(false),me(),I.current=false,m(false),h(z=>!z);}function V(z){h(false),r.activeViewport!==z&&(t.active&&t.forceClose(),r.setActiveViewport(z));}function B(){h(false),w(false),me(),I.current=false,m(false),x(z=>!z);}function Y(){a(!s);}function ur(z){let ie=z.relatedTarget;ie instanceof Node&&z.currentTarget.contains(ie)||ge();}return jsxs("div",{"data-patch-fab-dock":"",className:"fixed right-5 bottom-5 z-[2147483647] flex justify-end",children:[jsxs(motion.div,{initial:false,animate:{width:o?pe:Do},transition:{duration:.36,ease:Ie},onAnimationComplete:()=>Z(false),whileHover:o?void 0:{scale:1.03,transition:{duration:.15,ease:Ie}},whileTap:o?void 0:{scale:.97,transition:{duration:.1,ease:Ie}},"data-patch-fab-dock":"",className:M("pkey-fab relative h-11 rounded-full",Q?"overflow-hidden":"overflow-visible"),children:[jsx(motion.div,{animate:{opacity:o?0:1,scale:o?.7:1},transition:{duration:.18,ease:Ie},className:M("absolute inset-0",o?"pointer-events-none":"pointer-events-auto"),children:jsx("button",{type:"button",onClick:Ve,"data-patch-fab-dock":"","aria-label":l&&c>0?`Leave feedback \u2014 ${c} open`:"Leave feedback",className:"grid size-full place-items-center border-0 bg-transparent text-white",children:jsx(kt,{size:18})})}),jsxs("div",{ref:be,"data-patch-fab-dock":"",className:M("absolute inset-y-0 left-0 flex w-max items-center gap-1.5 px-1.5",o?"pointer-events-auto":"pointer-events-none"),children:[jsx(lt,{visible:o,index:0,children:jsx(Re,{text:e.isCapturing?"Stop commenting":"Add comment",children:jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":e.isCapturing?"Stop commenting":"Add comment","aria-pressed":e.isCapturing,onClick:Rt,className:M(st,"transition-colors",e.isCapturing?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:jsx(Io,{variant:"outline",size:16})})})}),l?jsx(lt,{visible:o,index:1,children:jsx(Re,{text:"Feedback",children:jsxs("button",{type:"button","data-patch-fab-dock":"","data-patch-roster-btn":"","aria-label":c>0?`Feedback \u2014 ${c} open`:"Feedback","aria-expanded":T,onClick:It,className:M(st,"relative transition-colors",T||c>0?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:[jsx(F,{name:"list",size:15}),c>0?jsx("span",{className:"pointer-events-none absolute -top-0.5 -right-0.5 grid h-[15px] min-w-[15px] place-items-center rounded-full bg-brand px-1 text-[9px] font-semibold text-white",children:c>99?"99+":c}):null]})})}):null,jsx(lt,{visible:o,index:2,children:jsxs("div",{className:"relative flex items-center",children:[jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":`Viewport: ${E.label}`,"aria-expanded":u,onClick:O,className:M(st,"transition-colors",r.activeViewport==="desktop"&&!u?"text-white/70 hover:bg-white/[0.08] hover:text-white":"bg-brand/15 text-brand"),children:jsx(F,{name:E.glyph,size:15})}),jsx(AnimatePresence,{children:u?jsxs(motion.div,{initial:{opacity:0,y:4,scale:.97},animate:{opacity:1,y:0,scale:1,transition:{duration:.16,ease:Ie}},exit:{opacity:0,y:3,scale:.98,transition:{duration:.12,ease:Ie}},"data-patch-fab-dock":"","data-patch-viewport-menu":"",className:"pkey-fab absolute bottom-[46px] left-[-42px] z-[2147483647] flex items-center gap-1 rounded-full p-1.5 text-white",style:{transformOrigin:"50% calc(100% + 8px)"},children:[jsx("span",{className:"pointer-events-none absolute -bottom-1 left-1/2 size-2 -translate-x-1/2 rotate-45 rounded-[2px] border-r border-b border-white/10 bg-foreground"}),qr.map(z=>{let ie=we[z],Se=r.activeViewport===z;return jsx(Re,{text:Ke(z),children:jsx("button",{type:"button","data-patch-viewport-option":z,"aria-label":Ke(z),"aria-pressed":Se,onClick:()=>V(z),className:M("grid size-8 place-items-center rounded-full border-0 bg-transparent transition-colors",Se?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:jsx(F,{name:ie.glyph,size:15})})},z)})]}):null})]})}),jsx(lt,{visible:o,index:3,children:jsxs("div",{className:"relative flex items-center",children:[jsx(Re,{text:"Settings",children:jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":"Settings","aria-expanded":v,onClick:B,className:M(st,"transition-colors",v||s?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:jsx(F,{name:"settings",size:15})})}),jsx(AnimatePresence,{children:v?jsxs(motion.div,{initial:{opacity:0,y:4,scale:.97},animate:{opacity:1,y:0,scale:1,transition:{duration:.16,ease:Ie}},exit:{opacity:0,y:3,scale:.98,transition:{duration:.12,ease:Ie}},"data-patch-fab-dock":"","data-patch-settings-menu":"",className:"pkey-fab absolute bottom-[46px] left-[-84px] z-[2147483647] w-[200px] rounded-[18px] p-1.5 text-white",style:{transformOrigin:"50% calc(100% + 8px)"},children:[jsx("span",{className:"pointer-events-none absolute -bottom-1 left-1/2 size-2 -translate-x-1/2 rotate-45 rounded-[2px] border-r border-b border-white/10 bg-foreground"}),jsxs("label",{"data-patch-hide-resolved-toggle":"",className:"flex h-9 w-full cursor-pointer items-center gap-2 rounded-xl px-2.5 text-left font-sans text-[12px] font-medium text-white transition-colors hover:bg-white/[0.08]",children:[jsx("input",{type:"checkbox",checked:s,"aria-label":"Hide resolved annotations",onChange:Y,className:"peer sr-only"}),jsx("span",{"aria-hidden":"true",className:M("grid size-4 shrink-0 place-items-center rounded-[5px] border transition-colors",s?"border-brand bg-brand text-white":"border-white/25 bg-white/[0.06] text-transparent"),children:jsx(F,{name:"check",size:10,stroke:2.4})}),jsx("span",{className:"min-w-0 flex-1 whitespace-nowrap",children:"Hide resolved annotations"})]})]}):null})]})}),jsx(lt,{visible:o,index:4,children:jsxs("span",{"data-patch-identity-hover":"",className:"relative inline-flex items-center justify-center",onMouseEnter:Ae,onMouseLeave:ge,onFocus:K,onBlur:ur,children:[jsx("button",{type:"button","data-patch-fab-dock":"","data-patch-person-btn":"","aria-label":ee?`Account: ${ee}`:"Identify",className:M(st,"text-white"),children:ee?jsx(Oe,{initials:U,tint:L,src:k,generatedSeed:_,alt:ee,size:"sm",className:M("size-[22px] text-[9.5px] ring-1 ring-white/20",H)}):jsx("span",{className:"grid size-[22px] place-items-center rounded-full border border-white/30 text-[9.5px] font-semibold text-white/70",children:"?"})}),jsx(AnimatePresence,{children:d?jsxs(motion.div,{initial:g?false:{opacity:0,y:3,scale:.98},animate:{opacity:1,y:0,scale:1,transition:g?{duration:0}:{duration:.12,delay:il,ease:Lo}},exit:{opacity:0,y:2,scale:.98,transition:b?{duration:0}:{duration:.08,ease:Lo}},"data-patch-fab-dock":"","data-patch-identity-popover":"",className:"fixed right-8 bottom-[72px] z-[2147483647] w-[min(272px,calc(100vw-40px))] min-w-[220px] rounded-2xl bg-foreground p-3.5 font-sans text-[13px] text-white shadow-[0_18px_44px_-14px_rgba(0,0,0,0.5),0_6px_14px_-6px_rgba(0,0,0,0.45)] ring-1 ring-white/10",style:{transformOrigin:sl},children:[jsx("span",{className:"absolute bottom-[-4px] size-2 rotate-45 border-r border-b border-white/10 bg-foreground",style:{right:al}}),r.studio?jsxs("div",{className:"flex items-center gap-2.5",children:[jsx(Oe,{initials:U,tint:S,src:k,generatedSeed:_,alt:r.studio.name,size:"md"}),jsxs("div",{className:"min-w-0",children:[jsx("div",{className:"truncate font-medium text-white",children:r.studio.name}),jsx("div",{className:"truncate text-xs text-white/55",children:r.studio.email})]})]}):r.identity?jsxs(Fragment,{children:[jsxs("div",{className:"flex items-center gap-2.5",children:[jsx(Oe,{initials:U,tint:S,generatedSeed:_,size:"md"}),jsxs("div",{className:"min-w-0",children:[jsx("div",{className:"truncate font-medium text-white",children:r.identity.name}),jsx("div",{className:"truncate text-xs text-white/55",children:r.identity.email})]})]}),jsx("div",{className:"my-3 h-px bg-white/10"}),jsx("button",{type:"button",onClick:R,className:"w-full rounded-full bg-white/[0.08] px-2.5 py-[7px] text-[12.5px] font-medium text-white transition-colors hover:bg-white/[0.13]",children:"Sign out"})]}):jsx("div",{className:"text-[12.5px] text-white/60",children:"Not signed in. Drop a pin to introduce yourself."})]}):null})]})}),jsx(lt,{visible:o,index:5,children:jsxs("div",{className:"flex items-center gap-1.5",children:[jsx("span",{className:"h-5 w-px shrink-0 bg-white/12"}),jsx(Re,{text:"Close",children:jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":"Close",onClick:dr,className:M(st,"text-white/70"),children:jsx(F,{name:"x",size:14})})})]})})]})]}),l&&!o&&c>0?jsx("span",{"data-patch-fab-dock":"","data-patch-roster-badge":"","aria-hidden":"true",className:"pointer-events-none absolute -top-1 -right-1 grid h-[18px] min-w-[18px] place-items-center rounded-full bg-brand px-1 text-[10.5px] font-semibold text-white shadow-[0_1px_3px_rgba(0,0,0,0.3)]",children:c>99?"99+":c}):null,jsx(AnimatePresence,{children:T?jsx(Ro,{onClose:()=>w(false)}):null})]})}function lt({children:e,visible:t,index:r}){return jsx(motion.div,{initial:{opacity:0,x:6},animate:t?{opacity:1,x:0,transition:{duration:.2,delay:.12+r*.035,ease:Ie}}:{opacity:0,x:6,transition:{duration:.12,ease:Ie}},children:e})}function zo(e,t){return t.width<=0||t.height<=0?{fx:0,fy:0}:{fx:(e.viewportX-t.x)/t.width,fy:(e.viewportY-t.y)/t.height}}function Ho(e,t){return {viewportX:t.x+e.fx*t.width,viewportY:t.y+e.fy*t.height}}var cl=.6,dl=.5,rr={text:.4,attrs:.3,classes:.2,position:.1},ul=5e3,pl=.08,ml=.12;function gl(e,t){return t===void 0||t===""?.5:e===t?1:e&&(e.includes(t)||t.includes(e))?.5:0}function fl(e,t){if(!t)return .5;let r=Object.keys(t);if(r.length===0)return .5;let n=0;for(let o of r)e[o]===t[o]&&n++;return n/r.length}function hl(e,t){let r=new Set(e),n=new Set(t??[]);if(r.size===0&&n.size===0)return .5;let o=0;for(let i of r)n.has(i)&&o++;let s=r.size+n.size-o;return s===0?0:o/s}function $o(e){let t=e.payload.boundingBox;if(!t)return null;let r=e.payload.coordinates.documentY-e.payload.coordinates.viewportY;return {x:t.x+t.width/2,y:t.y+t.height/2+r}}function Pr(e,t,r){if(!t)return .5;let n=e.left+e.width/2,o=e.top+r.scrollY+e.height/2,s=(n-t.x)/Math.max(1,r.viewport.width),i=(o-t.y)/Math.max(1,r.viewport.height);return Math.max(0,1-Math.sqrt(s*s+i*i))}function bl(e,t){let r=zt(e),n=Ot(e),o=Ye(e),s=e.getBoundingClientRect(),i=gl(r,t.payload.domHints?.textSignature),a=fl(n,t.payload.domHints?.attributeSignature),l=hl(o,t.payload.cssClasses),c=Pr(s,$o(t),t);return rr.text*i+rr.attrs*a+rr.classes*l+rr.position*c}function vl(e){let t=e.getBoundingClientRect();return t.width<1&&t.height<1}function Fo(e,t,r){let n=null,o=null,s=0;for(let i=0;i<e.length&&!(s>=ul);i++){let a=e[i];if(!a||(s++,Ht(a,t.internalAttr)))continue;let l=a.tagName.toLowerCase();if(l==="html"||l==="head"||l==="script"||l==="style"||vl(a))continue;let c=bl(a,t);!n||c>n.score?(o=n,n={el:a,score:c}):(!o||c>o.score)&&(o={el:a,score:c});}if(!n||n.score<r)return null;if(o&&n.score-o.score<pl){let i=$o(t),a=Pr(n.el.getBoundingClientRect(),i,t),l=Pr(o.el.getBoundingClientRect(),i,t);if(a-l<ml)return null}return n.el}function xl(e){return {viewportX:e.payload.coordinates.viewportX,viewportY:e.payload.coordinates.documentY-e.scrollY}}function wl(e,t){let r=e.getBoundingClientRect();if(!t.payload.boundingBox)return {viewportX:r.x,viewportY:r.y};let n=zo({viewportX:t.payload.coordinates.viewportX,viewportY:t.payload.coordinates.viewportY},t.payload.boundingBox);return Ho(n,{x:r.x,y:r.y,width:r.width,height:r.height})}function yl(e){let t=e.payload.domHints?.cssSelector;if(!t)return [];try{return Array.from(e.doc.querySelectorAll(t))}catch{return []}}function nr(e){if(!e.payload.domHints)return {kind:"positional",el:null};let t=yl(e);if(t.length>0){let n=Fo(t,e,dl);if(n)return {kind:"anchored",tier:1,el:n}}let r=Fo(e.doc.querySelectorAll("*"),e,cl);return r?{kind:"anchored",tier:2,el:r}:{kind:"detached",el:null}}function Mr(e,t){return e.kind==="anchored"&&e.el?wl(e.el,t):xl(t)}function Vo(e){let t=nr(e);return {kind:t.kind,tier:t.tier,el:t.el,position:Mr(t,e)}}function Bo(e){if(e.status==="resolved")return null;let t=e.latestRun;return t?t.status==="failed"?"patch-failed":t.status!=="succeeded"?null:t.prClosedUnmerged?"rerun-after-closed":t.prUrl?"review-pr":null:null}var Cl="data-patch-internal";function or(e,t,r){let n=nt(r,t.getOverlayViewport()),o=Zt(r,n);e.style.top=`${o.y}px`,e.style.left=`${o.x}px`;}function Uo(e,t){return Math.abs(e.viewportX-t.viewportX)<.5&&Math.abs(e.viewportY-t.viewportY)<.5}function Al(e){let t=e.getBoundingClientRect();return t.width<1&&t.height<1}function Lr(e,t){return {payload:t.payload,doc:e.targetDocument,scrollY:e.getTargetScrollY(),viewport:e.getTargetViewport(),internalAttr:Cl}}function Xo(e,t,r){let n=Lr(e,t);return {kind:r.kind,position:e.targetPointToOverlay(Mr(r,n))}}function Sl(e,t){return e.targetPointToOverlay({viewportX:t.viewportX,viewportY:t.documentY-e.getTargetScrollY()})}function Go(){let{annotations:e,annotationsReady:t,ephemerals:r,identity:n,studio:o,clientAvatarSeed:s,apiClient:i}=re(),a=xe(),{dockOpen:l,hideResolvedAnnotations:c}=De(),d=ce(),{isPreviewing:m,previewReady:u}=Je(),h=useReducedMotion(),v=a.active,x=a.forceClose,T=t&&(!m||u),w=useMemo(()=>l&&t?e.filter(k=>!c||k.status!=="resolved"):[],[l,t,e,c]),g=useMemo(()=>l&&t?r:[],[l,t,r]);useEffect(()=>{if(!c||v?.kind!=="existing")return;e.find(N=>N.id===v.annotationId)?.status==="resolved"&&x();},[v,e,x,c]);let p=useRef(new Map),b=useRef(new Map),C=useRef(new Map),A=useRef(new Map),f=useMemo(()=>{let k=A.current,N=new Set,_=new Map;for(let S of w){N.add(S.id);let L=k.get(S.id),E=L?.kind==="positional"||L?.kind==="anchored"&&L.el?.isConnected?L:nr(Lr(d,S));k.set(S.id,E),_.set(S.id,Xo(d,S,E));}for(let S of k.keys())N.has(S)||k.delete(S);return _},[d,w]),I=useCallback(()=>{let k=A.current,N=C.current,_=new Set;for(let S of w){let L=p.current.get(S.id);if(!L)continue;_.add(S.id);let H=k.get(S.id);if((!H||H.kind==="anchored"&&H.el&&!H.el.isConnected)&&(H=nr(Lr(d,S)),k.set(S.id,H)),H.kind==="detached"||H.kind==="anchored"&&H.el&&Al(H.el)){L.style.visibility!=="hidden"&&(L.style.visibility="hidden"),N.delete(S.id);continue}L.style.visibility==="hidden"&&(L.style.visibility="");let E=Xo(d,S,H).position,te=N.get(S.id);te&&Uo(te,E)||(N.set(S.id,E),or(L,d,E));}for(let S of g){let L=b.current.get(S.tempId);if(!L)continue;_.add(S.tempId);let H=Sl(d,S),E=N.get(S.tempId);E&&Uo(E,H)||(N.set(S.tempId,H),or(L,d,H));}for(let S of N.keys())_.has(S)||N.delete(S);},[d,w,g]),Q=w.length>0||g.length>0;useEffect(()=>{if(!Q)return;let k=d.overlayWindow,N=k.requestAnimationFrame(function _(){I(),N=k.requestAnimationFrame(_);});return ()=>k.cancelAnimationFrame(N)},[Q,I,d]);let Z=useRef(new Map);useEffect(()=>{if(!t||w.length===0)return;let k=setTimeout(()=>{let N=[];for(let _ of w){let S=f.get(_.id);if(!S)continue;let L=S.kind!=="detached";Z.current.get(_.id)!==L&&(Z.current.set(_.id,L),N.push({id:_.id,present:L}));}i.reportAnchorStatuses(N);},1500);return ()=>clearTimeout(k)},[f,w,t,i]);let be=useCallback(k=>{if(a.active&&a.draftText.trim().length>0){a.attemptClose();return}a.openExisting(k);},[a]),pe=o?o.name:n?.name??null,oe=o?.image??null,ee=n?.avatarSeed??s,U=o?.userId??ee;return jsxs("div",{"data-patch-pin-layer":"",style:{opacity:T?1:0,transition:h||!T?void 0:"opacity 0.2s cubic-bezier(0.22, 0.61, 0.36, 1)",pointerEvents:T?void 0:"none"},children:[jsx(AnimatePresence,{initial:false,children:w.map(k=>{let N=f.get(k.id);if(N?.kind==="detached")return null;let _=Tl(k),S=!o&&!!n?.clientUserId&&k.payload.authorRole==="client"&&k.payload.authorId===n.clientUserId,L=o?Bo(k):null,H=N?nt(N.position,d.getOverlayViewport()):"right";return jsx(Er,{ref:E=>{E?(p.current.set(k.id,E),N&&or(E,d,N.position)):p.current.delete(k.id);},avatarSrc:_.image,generatedSeed:S?ee:_.generatedSeed,avatarAlt:_.name??"",resolved:k.status==="resolved",attention:L,orphan:N?.kind==="positional",pointSide:H,ariaLabel:`Annotation by ${k.authorName??"someone"}`,onClick:()=>be(k.id),pinId:k.id},k.id)})}),jsx(AnimatePresence,{initial:false,children:g.map(k=>{let N=d.targetPointToOverlay({viewportX:k.viewportX,viewportY:k.viewportY});return jsx(Er,{ref:_=>{_?(b.current.set(k.tempId,_),or(_,d,N)):b.current.delete(k.tempId);},avatarSrc:oe,generatedSeed:U,avatarAlt:pe??"",resolved:false,pointSide:nt(N,d.getOverlayViewport()),ephemeral:true},k.tempId)})})]})}function Tl(e){let t=e.authorAvatarSeed??e.payload.authorId??(e.authorName?`annotation-author:${e.authorName}`:null);if(e.authorImage||t||e.authorName)return {name:e.authorName,image:e.authorImage??null,generatedSeed:t??e.id,key:e.payload.authorId??e.authorName??e.id};let r=e.thread.find(n=>n.authorImage||n.authorId||n.authorName);if(r){let n=r.authorAvatarSeed??r.authorId??(r.authorName?`thread-author:${r.authorName}`:null);return {name:r.authorName,image:r.authorImage??null,generatedSeed:n??e.id,key:r.authorId??r.authorName??e.id}}return {name:e.authorName,image:e.authorImage??null,generatedSeed:e.id,key:e.id}}var Pl=5e3;function qo(){let e=et(),t=re(),r=xe(),n=De(),o=ce(),s=useReducedMotion(),i=e.pendingFocus,a=useRef(null),l=useCallback(()=>{a.current!==null&&(window.clearTimeout(a.current),a.current=null);},[]);return useEffect(()=>{if(!i)return;if(ae(window.location.href)!==ae(i.url)){e.clearFocus();return}if(n.dockOpen||n.setDockOpen(true),t.activeViewport!==i.viewport){t.setActiveViewport(i.viewport);return}if(!t.annotationsReady)return;let c=t.annotations.find(m=>m.id===i.id);if(!c){a.current===null&&(a.current=window.setTimeout(()=>{a.current=null,e.clearFocus();},Pl));return}l();let d=c.payload.coordinates?.documentY;if(typeof d=="number"){let m=o.getTargetViewport().height;o.targetWindow.scrollTo({top:Math.max(0,d-m/3),behavior:s?"auto":"smooth"});}r.openExisting(i.id),e.clearFocus();},[i,t,n,o,s,r,e,l]),useEffect(()=>()=>l(),[l]),null}var Zo=`/*! tailwindcss v4.2.4 | MIT License | https://tailwindcss.com */
4
+ `)}function fs(e,t){let r=e.targetDocument,n=r.getElementById(Un);n&&n.remove();let o=r.createElement("style");return o.id=Un,o.setAttribute(t,""),o.textContent=gs(t),r.head.appendChild(o),o}function Xt(e,t,r){let n=e.eventTargetElement(t);return n?n.closest(`[${r}]`)!==null:false}var Xe=1.5,Gn="#0287FE",Kn="rgba(2, 135, 254, 0.032)";function hs(e){let t=e.split(" ")[0]??"",r=Number.parseFloat(t);return Number.isFinite(r)?Math.min(8,Math.max(3,r)):6}function bs(e,t){let r=e.targetDocument,n=r.createElement("div");n.setAttribute(t,""),Object.assign(n.style,{position:"fixed",pointerEvents:"none",border:`${Xe}px solid ${Gn}`,background:Kn,boxSizing:"border-box",zIndex:"2147483645",display:"none",borderRadius:"6px",transition:"top 80ms ease-out, left 80ms ease-out, width 80ms ease-out, height 80ms ease-out, border-radius 80ms ease-out"});let o=r.createElement("div");o.setAttribute(t,""),Object.assign(o.style,{position:"fixed",pointerEvents:"none",background:"#111",color:"#fff",fontFamily:"system-ui, sans-serif",fontSize:"12px",fontWeight:"500",padding:"6px 10px",borderRadius:"6px",zIndex:"2147483646",maxWidth:"240px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"none",boxShadow:"0 10px 24px -12px rgba(0, 0, 0, 0.36), 0 0 0 1px rgba(255, 255, 255, 0.08)"}),r.body.appendChild(n),r.body.appendChild(o);let a=null;return {update(i){let s=i.getBoundingClientRect();if(s.width===0&&s.height===0){this.hide();return}n.style.display="block",n.style.top=`${s.top-Xe}px`,n.style.left=`${s.left-Xe}px`,n.style.width=`${s.width+Xe*2}px`,n.style.height=`${s.height+Xe*2}px`,n.style.borderRadius=`${hs(e.targetWindow.getComputedStyle(i).borderRadius)+Xe}px`,i!==a&&(o.textContent=xt(i),a=i),o.style.display="block";let c=s.right+8,l=Math.max(8,s.top),d=e.getTargetViewport().width-8;c+240<=d?(o.style.left=`${c}px`,o.style.top=`${l}px`):(o.style.left=`${Math.max(8,s.right-240)}px`,o.style.top=`${Math.max(8,s.top-24)}px`);},hide(){n.style.display="none",o.style.display="none";},destroy(){n.remove(),o.remove();}}}function vs(e,t){let r=e.targetDocument.createElement("div");return r.setAttribute(t,""),Object.assign(r.style,{position:"fixed",pointerEvents:"none",border:`${Xe}px solid ${Gn}`,background:Kn,boxSizing:"border-box",zIndex:"2147483645",borderRadius:"8px"}),e.targetDocument.body.appendChild(r),{update(n){r.style.left=`${n.x}px`,r.style.top=`${n.y}px`,r.style.width=`${n.width}px`,r.style.height=`${n.height}px`;},destroy(){r.remove();}}}function Xn(e,t){return {x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),width:Math.abs(t.x-e.x),height:Math.abs(t.y-e.y)}}function qn(e){let{internalAttr:t,onClick:r,onDrag:n,surface:o}=e,a=o.targetDocument,i=fs(o,t),s=bs(o,t),c=false,l=null,d=null;function p(){l?.rectOverlay&&l.rectOverlay.destroy(),l=null;}function u(){d&&(d.destroy(),d=null);}let m=b=>{let g=b,k=o.eventTargetElement(g.target);Xt(o,g.target,t)||k&&kr(k)||(g.preventDefault(),g.stopPropagation(),!c&&(u(),l={startX:g.clientX,startY:g.clientY,isDragging:false,rectOverlay:null}));},h=b=>{let g=b;if(l?.isDragging){g.preventDefault(),g.stopPropagation();let z=Xn({x:l.startX,y:l.startY},{x:g.clientX,y:g.clientY});d=l.rectOverlay,l=null,n?.(z,g);return}p();let k=o.eventTargetElement(g.target);Xt(o,g.target,t)||k&&kr(k)||(g.preventDefault(),g.stopPropagation());},v=b=>{let g=b;Xt(o,g.target,t)||(g.preventDefault(),g.stopPropagation(),!c&&r(g));},w=b=>{let g=b;if(l){if(!l.isDragging){let N=g.clientX-l.startX,f=g.clientY-l.startY;if(Math.hypot(N,f)<Bn)return;l.isDragging=true,s.hide(),l.rectOverlay=vs(o,t);}l.rectOverlay?.update(Xn({x:l.startX,y:l.startY},{x:g.clientX,y:g.clientY}));return}if(c)return;let k=o.eventTargetElement(g.target);if(!k){s.hide();return}if(Xt(o,k,t)){s.hide();return}let z=k.tagName.toLowerCase();if(z==="html"||z==="body"){s.hide();return}s.update(k);},x=b=>{b.relatedTarget||s.hide();};return a.addEventListener("mousedown",m,true),a.addEventListener("mouseup",h,true),a.addEventListener("click",v,true),a.addEventListener("mousemove",w,true),a.addEventListener("mouseout",x,true),{exit(){i.remove(),s.destroy(),p(),u(),a.removeEventListener("mousedown",m,true),a.removeEventListener("mouseup",h,true),a.removeEventListener("click",v,true),a.removeEventListener("mousemove",w,true),a.removeEventListener("mouseout",x,true);},pause(){c=true,s.hide(),p();},resume(){c=false;},dismissDragOverlay(){u();}}}var jn="data-patch-internal",Qn=createContext(null),Zn=0;function Jn(){return Zn+=1,`tmp-${Date.now().toString(36)}-${Zn}`}function eo({children:e}){let t=xe(),r=re(),n=ce(),{isPreviewing:o,previewReady:a}=et(),[i,s]=useState(false),c=useRef(null),l=useRef(t),d=useRef(r);l.current=t,d.current=r;let p=useCallback(b=>{let g=l.current;if(g.active&&g.draftText.trim().length>0){g.attemptClose();return}let k=n.eventTargetElement(b.target)??n.targetDocument.body,z=n.targetWindow.getSelection(),N=Vn({clickTarget:k,selection:z}),f=Jn(),E={viewportX:b.clientX,viewportY:b.clientY,documentY:b.clientY+n.getTargetScrollY()};d.current.addEphemeral({tempId:f,viewportX:E.viewportX,viewportY:E.viewportY,documentY:E.documentY}),l.current.openComposer({tempId:f,target:N,anchor:E}),c.current?.pause();},[n]),u=useCallback((b,g)=>{let k=l.current;if(k.active&&k.draftText.trim().length>0){k.attemptClose(),c.current?.dismissDragOverlay();return}let z=n.getTargetViewport(),N=Yn({rect:b,viewport:z,internalAttr:jn,doc:n.targetDocument});if(!N){c.current?.dismissDragOverlay();return}let f=Jn(),E={viewportX:g.viewportX,viewportY:g.viewportY,documentY:g.viewportY+n.getTargetScrollY()};d.current.addEphemeral({tempId:f,viewportX:E.viewportX,viewportY:E.viewportY,documentY:E.documentY}),l.current.openComposer({tempId:f,target:N,anchor:E}),c.current?.pause();},[n]),m=r.annotationsReady&&(!o||a);useEffect(()=>{if(!i||!m){c.current?.exit(),c.current=null;return}return c.current?.exit(),c.current=qn({internalAttr:jn,surface:n,onClick:p,onDrag:(b,g)=>u(b,{viewportX:g.clientX,viewportY:g.clientY})}),()=>{c.current?.exit(),c.current=null;}},[i,p,u,n,m]);let h=useCallback(()=>{i||s(true);},[i]),v=useCallback(()=>{s(false);},[]),w=useRef(null);useEffect(()=>{let b=w.current,g=t.active;b?.kind==="composer"&&g?.kind!=="composer"&&(d.current.removeEphemeral(b.tempId),c.current?.dismissDragOverlay(),c.current?.resume()),b?.kind==="composer"&&g?.kind==="composer"&&b.tempId!==g.tempId&&d.current.removeEphemeral(b.tempId),w.current=g;},[t.active]),useEffect(()=>()=>{c.current?.exit(),c.current=null;},[]);let x=useMemo(()=>({isCapturing:i,enter:h,exit:v}),[i,h,v]);return jsx(Qn.Provider,{value:x,children:e})}function to(){let e=use(Qn);if(!e)throw new Error("useCaptureControls must be used inside <CaptureProvider>");return e}var Ts="patch:focus-intent";function Tr(e){return `${Ts}:${e}`}function Es(e){try{let t=window.sessionStorage.getItem(Tr(e));if(!t)return null;window.sessionStorage.removeItem(Tr(e));let r=JSON.parse(t);return typeof r.id!="string"||typeof r.url!="string"?null:{id:r.id,url:r.url,viewport:r.viewport??"desktop"}}catch{return null}}function Rs(e,t){try{window.sessionStorage.setItem(Tr(e),JSON.stringify(t));}catch{}}var oo=createContext(null);function Is(e){return e==="pending"||e==="acknowledged"}function io({projectToken:e,children:t}){let{apiClient:r,active:n,viewerKind:o,annotations:a}=re(),i=o==="studio",[s,c]=useState([]),[l,d]=useState(false),[p,u]=useState(null),m=useRef(r);m.current=r;let h=useCallback(async()=>{if(!i){c([]),d(true);return}let f=await m.current.listRoster();c(f),d(true);},[i]);useEffect(()=>{if(!n||!i)return;let f=Es(e);f&&ae(f.url)===ae(window.location.href)&&u(f),h();},[n,i,e,h]);let v=useMemo(()=>a.map(f=>`${f.id}:${f.status}`).sort().join(","),[a]),w=useRef(null);useEffect(()=>{if(!(!n||!i)){if(w.current===null){w.current=v;return}w.current!==v&&(w.current=v,h());}},[v,n,i,h]);let x=useCallback(f=>{let E={id:f.id,url:f.url,viewport:f.viewport};if(ae(f.url)===ae(window.location.href)){u(E);return}Rs(e,E),window.location.assign(f.url);},[e]),b=useCallback(()=>u(null),[]),g=useMemo(()=>{let f=new Map;for(let E of a)f.set(E.id,E.status);return f},[a]),k=useMemo(()=>s.map(f=>{let E=g.get(f.id);return E&&E!==f.status?{...f,status:E}:f}),[s,g]),z=useMemo(()=>k.filter(f=>Is(f.status)).length,[k]),N=useMemo(()=>({entries:k,ready:l,unresolvedCount:z,refresh:h,focusPin:x,pendingFocus:p,clearFocus:b}),[k,l,z,h,x,p,b]);return jsx(oo.Provider,{value:N,children:t})}function rt(){let e=use(oo);if(!e)throw new Error("useRosterStore must be used inside <RosterProvider>");return e}var so=createContext(null);function lo({children:e}){let[t,r]=useState(false),[n,o]=useState(false),a=useMemo(()=>({dockOpen:t,hideResolvedAnnotations:n,setDockOpen:r,setHideResolvedAnnotations:o}),[t,n]);return jsx(so.Provider,{value:a,children:e})}function ze(){let e=use(so);if(!e)throw new Error("useWidgetUiStore must be used inside <WidgetUiProvider>");return e}var co="[Patch] No project token found, widget disabled. Pass `projectToken` as a prop, or set NEXT_PUBLIC_PATCH_TOKEN (Next.js), VITE_PATCH_TOKEN (Vite / React Router), or PUBLIC_PATCH_TOKEN (Astro) in your env.";function uo(e){let t=e.prop?.trim();if(t)return t;let r=e.processEnv?.NEXT_PUBLIC_PATCH_TOKEN?.trim();if(r)return r;let n=e.importMetaEnv?.VITE_PATCH_TOKEN?.trim();if(n)return n;let o=e.importMetaEnv?.PUBLIC_PATCH_TOKEN?.trim();return o||null}function po(){try{return typeof import.meta>"u"?void 0:import.meta.env}catch{return}}function mo(){try{return typeof process>"u"||!process.env?void 0:{NEXT_PUBLIC_PATCH_TOKEN:process.env.NEXT_PUBLIC_PATCH_TOKEN}}catch{return}}var Ls=new Set(["AmpStateContext","AppRouter","AppRouterContext","ClientPageRoot","ClientSegmentRoot","ErrorBoundary","ForbiddenBoundary","GlobalLayoutRouterContext","HTTPAccessFallbackBoundary","HTTPAccessFallbackErrorBoundary","HeadManagerContext","HotReload","ImageConfigContext","InnerLayoutRouter","InnerScrollAndFocusHandler","InnerScrollAndFocusHandlerOld","LayoutRouterContext","LoadingBoundary","NavigationPromisesContext","NotFoundBoundary","OuterLayoutRouter","PathParamsContext","PathnameContext","ReactDevOverlay","RedirectBoundary","RedirectErrorBoundary","RenderFromTemplateContext","RouterContext","ScrollAndMaybeFocusHandler","SearchParamsContext","SegmentStateProvider","SegmentViewNode","ServerInsertedHTMLContext","Suspense","TemplateContext","UnauthorizedBoundary","AwaitContext","BrowserRouter","DataRouterContext","DataRouterStateContext","DataRoutes","FetchersContext","HashRouter","LocationContext","MemoryRouter","NavigationContext","Outlet","RenderErrorBoundary","RenderedRoute","Route","RouteContext","RouteErrorContext","Router","RouterProvider","Routes","StaticRouter","StaticRouterProvider","ViewTransitionContext"]);function Os(e,t){return e.length<=t?e:`${e.slice(0,t-1).trim()}\u2026`}function go(e){return e.replace(/\s+/g," ").trim()}function Er(e){return Ls.has(go(e))}function fo(e){if(!e)return null;let t=[],r=e.matchAll(/<([^<>]+)>/g);for(let n of r){let o=go(n[1]??"");!o||Er(o)||t[t.length-1]!==o&&t.push(o);}return t.length===0?null:Os(t.map(n=>`<${n}>`).join(" "),1e3)}var ho="seed:";function qt(e){return e?e.startsWith(ho)?{url:null,seed:e.slice(ho.length)||null}:/^https?:\/\//i.test(e)?{url:e,seed:null}:{url:null,seed:e}:{url:null,seed:null}}var Rr=[6,20,34,92,120,140,158,174,190,206,220,234,252,270,286,300,318,336,350],bo=[{hue:"near",sat:[88,98],light:[68,82],r:[.44,.62],opacity:[.9,1],reach:[.14,.32]},{hue:"base",sat:[85,96],light:[44,56],r:[.5,.74],opacity:[.85,1],reach:[.2,.42]},{hue:"accent",sat:[84,97],light:[50,66],r:[.42,.64],opacity:[.8,.98],reach:[.26,.48]},{hue:"accent2",sat:[82,95],light:[30,46],r:[.44,.66],opacity:[.72,.94],reach:[.24,.46]}],vo=Math.PI*2;function zs(e){let t=2166136261;for(let r=0;r<e.length;r++)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return t>>>0}function $s(e){return ()=>{e+=1831565813;let t=e;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}}function G(e,t,r){return t+e()*(r-t)}function de(e,t=3){let r=10**t;return Math.round(e*r)/r}function xo(e,t,r){return `hsl(${de((e%360+360)%360,1)} ${de(t,1)}% ${de(r,1)}%)`}function wo(e){let t=zs(e?.trim()||"patch-client"),r=$s(t),n=t.toString(36),o=(Rr[t%Rr.length]??Rr[0])+G(r,-10,10),a=r()<.5?-1:1,i=r()<.5?-1:1,s=o+i*G(r,52,116),c=o-i*G(r,26,66),l=o+a*G(r,12,38),d=xo(o+a*G(r,0,14),G(r,80,92),G(r,44,54)),p=G(r,0,vo),u=bo.map((m,h)=>{let w=(m.hue==="accent"?s:m.hue==="accent2"?c:m.hue==="near"?l:o)+G(r,-11,11),x=p+h/bo.length*vo+G(r,-0.6,.6),b=G(r,m.reach[0],m.reach[1]),g=de(.5+Math.cos(x)*b),k=de(.5+Math.sin(x)*b),z=de(G(r,0,180),1),N=de(G(r,.62,1.5),3),f=de(G(r,.62,1.5),3);return {id:`cav-${n}-${h}`,cx:g,cy:k,r:de(G(r,m.r[0],m.r[1])),color:xo(w,G(r,m.sat[0],m.sat[1]),G(r,m.light[0],m.light[1])),opacity:de(G(r,m.opacity[0],m.opacity[1]),2),gradientTransform:`rotate(${z} ${g} ${k}) translate(${g} ${k}) scale(${N} ${f}) translate(${de(-g)} ${de(-k)})`}});return {id:n,background:d,spots:u,blur:de(G(r,3.4,5.4),2),grain:de(G(r,.09,.15),2)}}function yt(e){let t=e.gap??12,r=e.margin??16,n=Math.min(e.popover.width,Math.max(0,e.viewport.width-r*2)),o="right",a=e.anchor.x+e.anchor.width+t;a+n>e.viewport.width-r&&(o="left",a=e.anchor.x-n-t),a<r&&(a=r);let i=e.anchor.y;return i+e.popover.height>e.viewport.height-r&&(i=e.viewport.height-r-e.popover.height),i<r&&(i=r),{x:a,y:i,width:n,placement:o}}function R(...e){return e.filter(Boolean).join(" ")}function Zt({seed:e,className:t,style:r}){let n=wo(e),o=useId().replace(/[^a-zA-Z0-9_-]/g,""),a=`${n.id}-${o}`,i=`cav-blur-${a}`,s=`cav-grain-${a}`;return jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 64 64",className:R("absolute inset-0 size-full! overflow-hidden rounded-full",t),style:r,children:[jsxs("defs",{children:[jsx("filter",{id:i,x:"-20%",y:"-20%",width:"140%",height:"140%",children:jsx("feGaussianBlur",{stdDeviation:n.blur})}),jsxs("filter",{id:s,x:"0%",y:"0%",width:"100%",height:"100%",children:[jsx("feTurbulence",{type:"fractalNoise",baseFrequency:"0.9",numOctaves:"2",stitchTiles:"stitch"}),jsx("feColorMatrix",{type:"saturate",values:"0"})]}),n.spots.map(c=>jsxs("radialGradient",{id:`${a}-${c.id}`,cx:c.cx,cy:c.cy,r:c.r,gradientTransform:c.gradientTransform,children:[jsx("stop",{offset:"0%",stopColor:c.color,stopOpacity:c.opacity}),jsx("stop",{offset:"100%",stopColor:c.color,stopOpacity:0})]},c.id))]}),jsx("rect",{width:"64",height:"64",fill:n.background}),jsx("g",{filter:`url(#${i})`,children:n.spots.map(c=>jsx("rect",{width:"64",height:"64",fill:`url(#${a}-${c.id})`},c.id))}),jsx("rect",{width:"64",height:"64",filter:`url(#${s})`,opacity:n.grain,style:{mixBlendMode:"overlay"}})]})}var Ie=32,yo=[.22,.61,.36,1],Jt=["var(--color-avatar-tint-1)","var(--color-avatar-tint-2)","var(--color-avatar-tint-3)","var(--color-avatar-tint-4)","var(--color-avatar-tint-5)"];function nt(e){if(!e)return "?";let t=e.trim().split(/\s+/),r=t[0],n=t[t.length-1];if(!r||!n)return "?";if(t.length===1)return r.slice(0,2).toUpperCase();let o=r[0]??"",a=n[0]??"";return (o+a).toUpperCase()||"?"}function ot(e){if(!e)return Jt[0];let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t|=0;return Jt[Math.abs(t)%Jt.length]??Jt[0]}var Vs={right:"50% 50% 3px 50%",left:"50% 50% 50% 3px"},Bs={right:"50% 50% 2px 50%",left:"50% 50% 50% 2px"};function it(e,t){let{placement:r}=yt({anchor:{x:e.viewportX-Ie/2,y:e.viewportY-Ie/2,width:Ie,height:Ie},popover:{width:332,height:200},viewport:t});return r==="right"?"left":"right"}function Qt(e,t){return {x:t==="left"?e.viewportX:e.viewportX-Ie,y:e.viewportY-Ie,width:Ie,height:Ie}}function Ir({ref:e,...t}){let r=t.pointSide??"right",n=!t.resolved&&t.attention?Ws[t.attention]:null,{url:o,seed:a}=qt(t.avatarSrc),i=a??t.generatedSeed,s=t.orphan?"grayscale(1)":t.resolved?"saturate(0.55) brightness(1.04) contrast(0.92)":"",c=t.orphan?.55:1,l=r==="right"?"-bottom-0.5 -left-0.5":"-bottom-0.5 -right-0.5";return jsx(motion.button,{ref:e,type:"button",onClick:t.onClick,"aria-label":t.ariaLabel??"Open annotation","data-patch-ephemeral":t.ephemeral?"":void 0,"data-patch-pin-id":t.pinId,className:"patch-pin-button fixed z-[2147483645] border-0 bg-transparent p-0",style:{width:Ie,height:Ie},initial:t.ephemeral?{opacity:0,scale:.45}:false,animate:t.ephemeral?{opacity:1,scale:1,transition:{type:"spring",stiffness:620,damping:30,mass:.65}}:{opacity:1,scale:1},exit:t.ephemeral?{opacity:0,scale:.45,transition:{delay:.16,duration:.14,ease:yo}}:{opacity:0,scale:.9,transition:{duration:.12,ease:yo}},children:jsxs("span",{className:"patch-pin relative grid size-full place-items-center","data-patch-point-side":r,style:{borderRadius:Vs[r]},children:[jsxs("span",{"data-patch-avatar":"",className:"absolute inset-[2px] overflow-hidden",style:{borderRadius:Bs[r],background:"var(--color-muted-foreground)",filter:t.orphan?"grayscale(1)":"none",opacity:t.orphan?.55:1},children:[i?jsx(Zt,{seed:i,style:{borderRadius:0,filter:s||"none",opacity:c}}):null,o?jsx("img",{src:o,alt:t.avatarAlt??"",referrerPolicy:"no-referrer",className:"absolute inset-0 size-full object-cover",draggable:false,style:{filter:s||"none",opacity:c},onError:d=>{d.currentTarget.remove();}}):null]}),t.resolved&&jsx("span",{className:`absolute ${l} grid size-[14px] place-items-center rounded-full bg-brand-green text-[9px] font-bold leading-none text-white`,children:"\u2713"}),n&&jsx("span",{"data-patch-attention":t.attention,"aria-hidden":"true",className:`absolute -top-0.5 -right-0.5 size-[10px] rounded-full border-[1.5px] border-white ${n}`})]})})}var Ws={"review-pr":"bg-brand","patch-failed":"bg-destructive","rerun-after-closed":"bg-muted-foreground"};function er(e){let t=new Date(e).getTime(),r=Date.now()-t,n=Math.round(r/6e4);if(Number.isNaN(n))return "";if(n<1)return "just now";if(n<60)return `${n}m ago`;let o=Math.round(n/60);return o<24?`${o}h ago`:`${Math.round(o/24)}d ago`}function Co(e){let t=e.composedPath();for(let r of t)if(r instanceof Element&&r.tagName?.toLowerCase()==="patch-widget-root")return true;return false}function Ao(e){let t=e.match(/\/pull\/(\d+)/);return t?`#${t[1]}`:"PR"}var So={"arrow-up":[["path",{d:"M12 5.5V19"}],["path",{d:"M18 11C18 11 13.5811 5.00001 12 5C10.4188 4.99999 6 11 6 11"}]],check:[["path",{d:"M5 14L8.5 17.5L19 6.5"}]],copy:[["path",{d:"M9 15C9 12.1716 9 10.7574 9.87868 9.87868C10.7574 9 12.1716 9 15 9L16 9C18.8284 9 20.2426 9 21.1213 9.87868C22 10.7574 22 12.1716 22 15V16C22 18.8284 22 20.2426 21.1213 21.1213C20.2426 22 18.8284 22 16 22H15C12.1716 22 10.7574 22 9.87868 21.1213C9 20.2426 9 18.8284 9 16L9 15Z"}],["path",{d:"M16.9999 9C16.9975 6.04291 16.9528 4.51121 16.092 3.46243C15.9258 3.25989 15.7401 3.07418 15.5376 2.90796C14.4312 2 12.7875 2 9.5 2C6.21252 2 4.56878 2 3.46243 2.90796C3.25989 3.07417 3.07418 3.25989 2.90796 3.46243C2 4.56878 2 6.21252 2 9.5C2 12.7875 2 14.4312 2.90796 15.5376C3.07417 15.7401 3.25989 15.9258 3.46243 16.092C4.51121 16.9528 6.04291 16.9975 9 16.9999"}]],cursor:[["path",{d:"M12.669 8.35811L17.6969 10.3256C20.5969 11.4604 22.0469 12.0277 21.9988 12.9278C21.9508 13.8278 20.4375 14.2405 17.4111 15.0659C16.5099 15.3117 16.0593 15.4346 15.7469 15.7469C15.4346 16.0593 15.3117 16.5099 15.0659 17.4111C14.2405 20.4375 13.8278 21.9508 12.9278 21.9988C12.0277 22.0469 11.4604 20.5969 10.3256 17.6969L8.35811 12.669C7.17004 9.63279 6.57601 8.1147 7.34535 7.34535C8.1147 6.57601 9.63279 7.17004 12.669 8.35811Z"}],["path",{d:"M9 4V2M5 5L3.5 3.5M4 9H2M5 13L3.5 14.5M14.5 3.5L13 5"}]],desktop:[["path",{d:"M14 21H16M14 21C13.1716 21 12.5 20.3284 12.5 19.5V17L12 17M14 21H10M10 21H8M10 21C10.8284 21 11.5 20.3284 11.5 19.5V17L12 17M12 17V21"}],["path",{d:"M16 3H8C5.17157 3 3.75736 3 2.87868 3.87868C2 4.75736 2 6.17157 2 9V11C2 13.8284 2 15.2426 2.87868 16.1213C3.75736 17 5.17157 17 8 17H16C18.8284 17 20.2426 17 21.1213 16.1213C22 15.2426 22 13.8284 22 11V9C22 6.17157 22 4.75736 21.1213 3.87868C20.2426 3 18.8284 3 16 3Z"}]],globe:[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"M8 12C8 18 12 22 12 22C12 22 16 18 16 12C16 6 12 2 12 2C12 2 8 6 8 12Z"}],["path",{d:"M21 15H3"}],["path",{d:"M21 9H3"}]],list:[["path",{d:"M8 5.5L20 5.5"}],["path",{d:"M8 12.5L20 12.5"}],["path",{d:"M8 19.5L20 19.5"}],["path",{d:"M4.375 5.5H4.25M4.5 5.5C4.5 5.63807 4.38807 5.75 4.25 5.75C4.11193 5.75 4 5.63807 4 5.5C4 5.36193 4.11193 5.25 4.25 5.25C4.38807 5.25 4.5 5.36193 4.5 5.5Z"}],["path",{d:"M4.375 12.5H4.25M4.5 12.5C4.5 12.6381 4.38807 12.75 4.25 12.75C4.11193 12.75 4 12.6381 4 12.5C4 12.3619 4.11193 12.25 4.25 12.25C4.38807 12.25 4.5 12.3619 4.5 12.5Z"}],["path",{d:"M4.375 19.5H4.25M4.5 19.5C4.5 19.6381 4.38807 19.75 4.25 19.75C4.11193 19.75 4 19.6381 4 19.5C4 19.3619 4.11193 19.25 4.25 19.25C4.38807 19.25 4.5 19.3619 4.5 19.5Z"}]],lock:[["path",{d:"M4.26781 18.8447C4.49269 20.515 5.87613 21.8235 7.55966 21.9009C8.97627 21.966 10.4153 22 12 22C13.5847 22 15.0237 21.966 16.4403 21.9009C18.1239 21.8235 19.5073 20.515 19.7322 18.8447C19.879 17.7547 20 16.6376 20 15.5C20 14.3624 19.879 13.2453 19.7322 12.1553C19.5073 10.485 18.1239 9.17649 16.4403 9.09909C15.0237 9.03397 13.5847 9 12 9C10.4153 9 8.97627 9.03397 7.55966 9.09909C5.87613 9.17649 4.49269 10.485 4.26781 12.1553C4.12104 13.2453 4 14.3624 4 15.5C4 16.6376 4.12104 17.7547 4.26781 18.8447Z"}],["path",{d:"M7.5 9V6.5C7.5 4.01472 9.51472 2 12 2C14.4853 2 16.5 4.01472 16.5 6.5V9"}],["path",{d:"M12.125 15.5H12M12.25 15.5C12.25 15.6381 12.1381 15.75 12 15.75C11.8619 15.75 11.75 15.6381 11.75 15.5C11.75 15.3619 11.8619 15.25 12 15.25C12.1381 15.25 12.25 15.3619 12.25 15.5Z"}]],mobile:[["path",{d:"M13.5 2H10.5C8.14298 2 6.96447 2 6.23223 2.73223C5.5 3.46447 5.5 4.64298 5.5 7V17C5.5 19.357 5.5 20.5355 6.23223 21.2678C6.96447 22 8.14298 22 10.5 22H13.5C15.857 22 17.0355 22 17.7678 21.2678C18.5 20.5355 18.5 19.357 18.5 17V7C18.5 4.64298 18.5 3.46447 17.7678 2.73223C17.0355 2 15.857 2 13.5 2Z"}],["path",{d:"M12.125 19H12M12.25 19C12.25 19.1381 12.1381 19.25 12 19.25C11.8619 19.25 11.75 19.1381 11.75 19C11.75 18.8619 11.8619 18.75 12 18.75C12.1381 18.75 12.25 18.8619 12.25 19Z"}]],more:[["path",{d:"M12 12.002H12.5M19 12.002H19.5M5 12.002H5.5M12 13.002C12.5523 13.002 13 12.5542 13 12.002C13 11.4497 12.5523 11.002 12 11.002C11.4477 11.002 11 11.4497 11 12.002C11 12.5542 11.4477 13.002 12 13.002ZM19 13.002C19.5523 13.002 20 12.5542 20 12.002C20 11.4497 19.5523 11.002 19 11.002C18.4477 11.002 18 11.4497 18 12.002C18 12.5542 18.4477 13.002 19 13.002ZM5 13.002C5.55228 13.002 6 12.5542 6 12.002C6 11.4497 5.55228 11.002 5 11.002C4.44772 11.002 4 11.4497 4 12.002C4 12.5542 4.44772 13.002 5 13.002Z"}]],play:[["path",{d:"M18.8906 12.846C18.5371 14.189 16.8667 15.138 13.5257 17.0361C10.296 18.8709 8.6812 19.7884 7.37983 19.4196C6.8418 19.2671 6.35159 18.9776 5.95624 18.5787C5 17.6139 5 15.7426 5 12C5 8.2574 5 6.3861 5.95624 5.42132C6.35159 5.02245 6.8418 4.73288 7.37983 4.58042C8.6812 4.21165 10.296 5.12907 13.5257 6.96393C16.8667 8.86197 18.5371 9.811 18.8906 11.154C19.0365 11.7084 19.0365 12.2916 18.8906 12.846Z"}]],pr:[["path",{d:"M6 8L6 16"}],["path",{d:"M18 16V12C18 9.17156 18 7.75735 17.1213 6.87867C16.2426 5.99999 14.8284 5.99999 12 5.99999L11 5.99999M11 5.99999C11 5.29976 12.9943 3.99152 13.5 3.49999M11 5.99999C11 6.70022 12.9943 8.00846 13.5 8.49999"}],["circle",{cx:"6",cy:"18",r:"2"}],["circle",{cx:"6",cy:"6",r:"2"}],["circle",{cx:"18",cy:"18",r:"2"}]],refresh:[["path",{d:"M20.0092 2V5.13219C20.0092 5.42605 19.6418 5.55908 19.4537 5.33333C17.6226 3.2875 14.9617 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22C17.5228 22 22 17.5228 22 12"}]],robot:[["path",{d:"M19 16V14C19 11.1716 19 9.75736 18.1213 8.87868C17.2426 8 15.8284 8 13 8H11C8.17157 8 6.75736 8 5.87868 8.87868C5 9.75736 5 11.1716 5 14V16C5 18.8284 5 20.2426 5.87868 21.1213C6.75736 22 8.17157 22 11 22H13C15.8284 22 17.2426 22 18.1213 21.1213C19 20.2426 19 18.8284 19 16Z"}],["path",{d:"M19 18C20.4142 18 21.1213 18 21.5607 17.5607C22 17.1213 22 16.4142 22 15C22 13.5858 22 12.8787 21.5607 12.4393C21.1213 12 20.4142 12 19 12"}],["path",{d:"M5 18C3.58579 18 2.87868 18 2.43934 17.5607C2 17.1213 2 16.4142 2 15C2 13.5858 2 12.8787 2.43934 12.4393C2.87868 12 3.58579 12 5 12"}],["path",{d:"M13.5 3.5C13.5 4.32843 12.8284 5 12 5C11.1716 5 10.5 4.32843 10.5 3.5C10.5 2.67157 11.1716 2 12 2C12.8284 2 13.5 2.67157 13.5 3.5Z"}],["path",{d:"M12 5V8"}],["path",{d:"M9 13V14"}],["path",{d:"M15 13V14"}],["path",{d:"M10 17.5C10 17.5 10.6667 18 12 18C13.3333 18 14 17.5 14 17.5"}]],settings:[["path",{d:"M15.5 12C15.5 13.933 13.933 15.5 12 15.5C10.067 15.5 8.5 13.933 8.5 12C8.5 10.067 10.067 8.5 12 8.5C13.933 8.5 15.5 10.067 15.5 12Z"}],["path",{d:"M21.011 14.0965C21.5329 13.9558 21.7939 13.8854 21.8969 13.7508C22 13.6163 22 13.3998 22 12.9669V11.0332C22 10.6003 22 10.3838 21.8969 10.2493C21.7938 10.1147 21.5329 10.0443 21.011 9.90358C19.0606 9.37759 17.8399 7.33851 18.3433 5.40087C18.4817 4.86799 18.5509 4.60156 18.4848 4.44529C18.4187 4.28902 18.2291 4.18134 17.8497 3.96596L16.125 2.98673C15.7528 2.77539 15.5667 2.66972 15.3997 2.69222C15.2326 2.71472 15.0442 2.90273 14.6672 3.27873C13.208 4.73448 10.7936 4.73442 9.33434 3.27864C8.95743 2.90263 8.76898 2.71463 8.60193 2.69212C8.43489 2.66962 8.24877 2.77529 7.87653 2.98663L6.15184 3.96587C5.77253 4.18123 5.58287 4.28891 5.51678 4.44515C5.45068 4.6014 5.51987 4.86787 5.65825 5.4008C6.16137 7.3385 4.93972 9.37763 2.98902 9.9036C2.46712 10.0443 2.20617 10.1147 2.10308 10.2492C2 10.3838 2 10.6003 2 11.0332V12.9669C2 13.3998 2 13.6163 2.10308 13.7508C2.20615 13.8854 2.46711 13.9558 2.98902 14.0965C4.9394 14.6225 6.16008 16.6616 5.65672 18.5992C5.51829 19.1321 5.44907 19.3985 5.51516 19.5548C5.58126 19.7111 5.77092 19.8188 6.15025 20.0341L7.87495 21.0134C8.24721 21.2247 8.43334 21.3304 8.6004 21.3079C8.76746 21.2854 8.95588 21.0973 9.33271 20.7213C10.7927 19.2644 13.2088 19.2643 14.6689 20.7212C15.0457 21.0973 15.2341 21.2853 15.4012 21.3078C15.5682 21.3303 15.7544 21.2246 16.1266 21.0133L17.8513 20.034C18.2307 19.8187 18.4204 19.711 18.4864 19.5547C18.5525 19.3984 18.4833 19.132 18.3448 18.5991C17.8412 16.6616 19.0609 14.6226 21.011 14.0965Z"}]],tablet:[["path",{d:"M14.5 2H9.5C6.67157 2 5.25736 2 4.37868 2.87868C3.5 3.75736 3.5 5.17157 3.5 8V16C3.5 18.8284 3.5 20.2426 4.37868 21.1213C5.25736 22 6.67157 22 9.5 22H14.5C17.3284 22 18.7426 22 19.6213 21.1213C20.5 20.2426 20.5 18.8284 20.5 16V8C20.5 5.17157 20.5 3.75736 19.6213 2.87868C18.7426 2 17.3284 2 14.5 2Z"}],["path",{d:"M12.125 19H12M12.25 19C12.25 19.1381 12.1381 19.25 12 19.25C11.8619 19.25 11.75 19.1381 11.75 19C11.75 18.8619 11.8619 18.75 12 18.75C12.1381 18.75 12.25 18.8619 12.25 19Z"}]],trash:[["path",{d:"M19.5 5.5L18.8803 15.5251C18.7219 18.0864 18.6428 19.3671 18.0008 20.2879C17.6833 20.7431 17.2747 21.1273 16.8007 21.416C15.8421 22 14.559 22 11.9927 22C9.42312 22 8.1383 22 7.17905 21.4149C6.7048 21.1257 6.296 20.7408 5.97868 20.2848C5.33688 19.3626 5.25945 18.0801 5.10461 15.5152L4.5 5.5"}],["path",{d:"M3 5.5H21M16.0557 5.5L15.3731 4.09173C14.9196 3.15626 14.6928 2.68852 14.3017 2.39681C14.215 2.3321 14.1231 2.27454 14.027 2.2247C13.5939 2 13.0741 2 12.0345 2C10.9688 2 10.436 2 9.99568 2.23412C9.8981 2.28601 9.80498 2.3459 9.71729 2.41317C9.32164 2.7167 9.10063 3.20155 8.65861 4.17126L8.05292 5.5"}],["path",{d:"M9.5 16.5L9.5 10.5"}],["path",{d:"M14.5 16.5L14.5 10.5"}]],unlink:[["path",{d:"M12.1434 10.691L12.3503 10.4841C14.329 8.50532 17.5372 8.50532 19.5159 10.4841C21.4947 12.4628 21.4947 15.671 19.5159 17.6497L16.6497 20.5159C14.671 22.4947 11.4628 22.4947 9.48405 20.5159C7.50532 18.5372 7.50532 15.329 9.48405 13.3503L9.9484 12.886"}],["path",{d:"M20.0516 11.114L20.5159 10.6497C22.4947 8.67095 22.4947 5.46279 20.5159 3.48405C18.5372 1.50532 15.329 1.50532 13.3503 3.48405L10.4841 6.35031C8.50532 8.32904 8.50532 11.5372 10.4841 13.5159C12.4628 15.4947 15.671 15.4947 17.6497 13.5159L17.8566 13.309"}],["path",{d:"M4.5 4L6 6M2 8L5 9M3 13.5L5 12"}]],x:[["path",{d:"M18 6L6.00081 17.9992M17.9992 18L6 6.00085"}]]};function $({name:e,size:t=16,stroke:r=2,color:n,className:o}){return jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n??"currentColor",strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",className:o,children:So[e].map(([a,i],s)=>createElement(a,{key:s,...i}))})}var Eo=[.16,1,.3,1];function Gs(e){try{let r=new URL(e).pathname.replace(/\/$/,"");return r===""?"/":r}catch{return e}}function tr(e){return e==="pending"||e==="acknowledged"}function Ro({onClose:e}){let t=rt(),{hideResolvedAnnotations:r}=ze(),n=t.focusPin,o=typeof window>"u"?"":ae(window.location.href),a=useMemo(()=>[...r?t.entries.filter(d=>d.status!=="resolved"):t.entries].sort((d,p)=>(tr(d.status)?0:1)-(tr(p.status)?0:1)),[t.entries,r]),i=useMemo(()=>{let l=t.entries.filter(p=>tr(p.status)&&ae(p.url)===o).length,d=t.entries.filter(p=>tr(p.status)).length;return {here:l,elsewhere:d-l,total:d}},[t.entries,o]);function s(){if(i.total===0)return "No open feedback";let l=[`${i.total} open`];return i.here>0&&l.push(`${i.here} here`),i.elsewhere>0&&l.push(`${i.elsewhere} elsewhere`),l.join(" \xB7 ")}function c(l){e(),n(l);}return jsxs(motion.div,{initial:{opacity:0,y:6,scale:.98},animate:{opacity:1,y:0,scale:1,transition:{duration:.18,ease:Eo}},exit:{opacity:0,y:4,scale:.985,transition:{duration:.12,ease:Eo}},"data-patch-fab-dock":"","data-patch-roster-panel":"",className:"absolute right-0 bottom-[54px] z-[2147483647] flex max-h-[min(480px,calc(100vh-120px))] w-[min(360px,calc(100vw-40px))] flex-col overflow-hidden rounded-xl border border-black/6 bg-popover font-sans text-popover-foreground shadow-[0_20px_56px_-16px_rgba(0,0,0,0.2),0_8px_18px_-6px_rgba(0,0,0,0.08)]",style:{transformOrigin:"100% 100%"},children:[jsxs("div",{className:"flex items-baseline justify-between gap-2 px-4 pt-3.5 pb-2.5",children:[jsx("span",{className:"text-[13px] font-semibold",children:"Feedback"}),jsx("span",{className:"text-[11.5px] font-medium text-popover-foreground/50",children:s()})]}),a.length===0?jsx("div",{className:"px-4 pt-2 pb-6 text-center text-[12.5px] text-popover-foreground/50",children:"No feedback yet."}):jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-1.5 pb-2",children:a.map(l=>jsx(Ks,{entry:l,onCurrentPage:ae(l.url)===o,onClick:()=>c(l)},l.id))})]})}function Ks({entry:e,onCurrentPage:t,onClick:r}){let n=e.status==="resolved",o=e.anchorStatus==="detached";return jsxs("button",{type:"button","data-patch-fab-dock":"","data-patch-roster-row":e.id,onClick:r,className:"flex w-full items-start gap-2.5 rounded-lg px-2.5 py-2 text-left transition-colors hover:bg-black/[0.04]",children:[jsx("span",{className:"mt-0.5 grid size-4 shrink-0 place-items-center",children:n?jsx("span",{className:"grid size-4 place-items-center rounded-full bg-brand-green text-white",children:jsx($,{name:"check",size:10,stroke:2.6})}):e.status==="dismissed"?jsx("span",{className:"size-2 rounded-full border border-black/20"}):jsx("span",{className:"size-2 rounded-full bg-brand"})}),jsxs("span",{className:"min-w-0 flex-1",children:[jsx("span",{className:R("block truncate text-[12.5px] leading-snug",n?"text-popover-foreground/45 line-through":"text-popover-foreground"),children:e.label}),jsxs("span",{className:"mt-0.5 flex items-center gap-1.5 text-[11px] text-popover-foreground/50",children:[jsx($,{name:we[e.viewport].glyph,size:11,className:"shrink-0 opacity-80"}),jsx("span",{className:"truncate",children:t?"This page":Gs(e.url)}),jsx("span",{"aria-hidden":"true",children:"\xB7"}),jsx("span",{className:"shrink-0",children:er(e.createdAt)}),o?jsxs("span",{className:"ml-0.5 inline-flex shrink-0 items-center gap-1 rounded-full bg-black/[0.05] px-1.5 py-px text-[10px] font-medium text-popover-foreground/55",children:[jsx($,{name:"unlink",size:10}),"element gone"]}):null]})]})]})}var qs="relative inline-grid shrink-0 overflow-hidden place-items-center rounded-full text-white font-semibold tracking-[-0.01em]",js={sm:"size-[22px] text-[9.5px]",md:"size-7 text-[10.5px]"};function $e({initials:e,tint:t,src:r,generatedSeed:n,alt:o="",size:a="md",className:i,style:s}){let{url:c,seed:l}=qt(r),d=l??n;return jsxs("span",{className:R(qs,js[a],i),style:{background:t,...s},children:[jsx("span",{children:e}),!c&&d?jsx(Zt,{seed:d}):null,c?jsx("img",{src:c,alt:o,referrerPolicy:"no-referrer",className:"absolute inset-0 size-full rounded-full object-cover",draggable:false,onError:p=>{p.currentTarget.remove();}}):null]})}var Js="M48 0C67.8823 0 84 16.1178 84 36V63C84 67.9706 79.9706 72 75 72H48C42.2522 72 36.8201 70.6505 32 68.2549V87C32 91.9706 27.9706 96 23 96H14C12.8954 96 12 95.1046 12 94V36C12 16.1178 28.1178 0 48 0ZM48 18C38.0589 18 30 26.0589 30 36C30 45.9411 38.0589 54 48 54C57.9411 54 66 45.9411 66 36C66 26.0589 57.9411 18 48 18Z",Qs="M12 2A10 10 0 0 1 22 12V20.6A1.4 1.4 0 0 1 20.6 22H12A10 10 0 0 1 2 12A10 10 0 0 1 12 2Z";function At({size:e=16,className:t}){return jsx("svg",{width:e,height:e,viewBox:"0 0 96 96",fill:"currentColor","aria-hidden":"true",focusable:"false",className:t,children:jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:Js})})}function Io({size:e=16,variant:t="filled",stroke:r=2,className:n}){let o=t==="outline";return jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:o?"none":"currentColor",stroke:o?"currentColor":"none",strokeWidth:o?r:void 0,strokeLinejoin:o?"round":void 0,strokeLinecap:o?"round":void 0,"aria-hidden":"true",focusable:"false",className:n,children:jsx("path",{d:Qs})})}var Nr=false,Ge=null,nr=null,ke={openDelay:700,isInstant(){return Nr},onOpen(e){nr&&nr!==e&&nr(),nr=e??null,Nr=true,Ge&&(clearTimeout(Ge),Ge=null);},onClose(){Ge&&clearTimeout(Ge),Ge=setTimeout(()=>{Nr=false,Ge=null;},300);}};var Mo="easeOut";function Ce({text:e,children:t,className:r,tone:n="default",placement:o="top"}){let[a,i]=useState(false),[s,c]=useState(false),l=useRef(null),d=useRef(false);useEffect(()=>()=>{l.current&&clearTimeout(l.current),d.current&&ke.onClose();},[]);let p=k=>{c(k),i(true),d.current=true,ke.onOpen();},u=()=>{if(l.current&&(clearTimeout(l.current),l.current=null),ke.isInstant()){p(true);return}l.current=setTimeout(()=>{l.current=null,p(false);},ke.openDelay);},m=()=>{l.current&&(clearTimeout(l.current),l.current=null),d.current&&(d.current=false,ke.onClose()),i(false);},h=n==="warning"?"pointer-events-none absolute bottom-[calc(100%+8px)] left-0 z-[1]":o==="bottom"?"pointer-events-none absolute top-[calc(100%+8px)] left-1/2 z-[1] -translate-x-1/2":"pointer-events-none absolute -top-[38px] left-1/2 z-[1] -translate-x-1/2",v="shadow-[0_10px_30px_-10px_rgba(0,0,0,0.45),0_3px_8px_-3px_rgba(0,0,0,0.3)] ring-1 ring-white/10",w=n==="warning"?`relative flex w-[200px] items-start gap-1.5 rounded-lg bg-foreground px-3 py-2.5 text-left text-[11px] leading-[1.35] font-medium text-white ${v}`:`relative block whitespace-nowrap rounded-md bg-foreground px-2.5 py-[6px] text-[11px] font-medium tracking-[0.01em] text-white ${v}`,x=n==="warning"?"absolute -bottom-1 left-6 size-2 rotate-45 rounded-[2px] border-r border-b border-white/10 bg-foreground":o==="bottom"?"absolute -top-1 left-1/2 size-2 -translate-x-1/2 rotate-45 rounded-[2px] border-l border-t border-white/10 bg-foreground":"absolute -bottom-1 left-1/2 size-2 -translate-x-1/2 rotate-45 rounded-[2px] border-r border-b border-white/10 bg-foreground",b=o==="bottom"&&n!=="warning"?-3:3,g=o==="bottom"&&n!=="warning"?-2:2;return jsxs("span",{className:R("relative inline-flex items-center justify-center",r),onMouseEnter:u,onMouseLeave:m,onMouseDown:m,children:[jsx("span",{className:h,children:jsx(AnimatePresence,{children:a&&jsxs(motion.span,{initial:s?false:{opacity:0,y:b,scale:.98},animate:{opacity:1,y:0,scale:1,transition:s?{duration:0}:{duration:.1,ease:Mo}},exit:{opacity:0,y:g,scale:.98,transition:{duration:.08,ease:Mo}},className:w,children:[n==="warning"?jsxs("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:"mt-px size-3.5 shrink-0",children:[jsx("path",{d:"M10.3 3.9 1.8 18.6A2 2 0 0 0 3.5 21.6h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0Z",fill:"#fbbf24"}),jsx("path",{d:"M12 9v4.5M12 17h.01",fill:"none",stroke:"#fff",strokeWidth:"2",strokeLinecap:"round"})]}):null,jsx("span",{className:"min-w-0 flex-1",children:e}),jsx("span",{className:x})]})})}),t]})}var Do=44,Pe=[.16,1,.3,1],Lo="easeOut",ol=.08,il=60,al="calc(100% - 64px) calc(100% + 4px)",ct="pkey pkey-dock grid size-8 place-items-center rounded-full border-0 bg-transparent";function Oo(){let e=to(),t=xe(),r=re(),n=rt(),{dockOpen:o,hideResolvedAnnotations:a,setDockOpen:i,setHideResolvedAnnotations:s}=ze(),c=!!r.studio,l=n.unresolvedCount,[d,p]=useState(false),[u,m]=useState(false),[h,v]=useState(false),[w,x]=useState(false),[b,g]=useState(false),[k,z]=useState(false),N=useRef(null),f=useRef(null),E=useRef(false),[Q,Z]=useState(false),be=useRef(null),[pe,oe]=useState(Do);useLayoutEffect(()=>{let O=be.current;if(!O)return;let ie=()=>oe(O.offsetWidth);ie();let Te=new ResizeObserver(ie);return Te.observe(O),()=>Te.disconnect()},[]);let ee=r.studio?r.studio.name:r.identity?.name??null,X=nt(ee),C=r.studio?.image??null,I=r.identity?.avatarSeed??r.clientAvatarSeed,M=r.studio?.userId??I,A=r.studio?"var(--color-foreground)":ot(I),D=r.studio&&!C?"#FFFFFF":A,H=r.studio&&!C?"text-foreground":"text-white",S=we[r.activeViewport];function te(){N.current!==null&&(window.clearTimeout(N.current),N.current=null);}function me(){f.current!==null&&(window.clearTimeout(f.current),f.current=null);}let P=useRef(()=>{});P.current=()=>{!E.current&&N.current===null||(te(),me(),E.current=false,z(true));};let _=useRef(()=>P.current()).current;useEffect(()=>{k&&d&&p(false);},[k,d]);function F(O){m(false),v(false),x(false),te(),me(),E.current=true,z(false),g(O),ke.onOpen(_),p(true);}function q(){F(false);}function Se(){if(te(),!(E.current||f.current!==null)){if(ke.isInstant()){F(true);return}f.current=window.setTimeout(()=>{f.current=null,F(false);},ke.openDelay);}}function ge(){me(),te(),E.current&&(E.current=false,ke.onClose()),N.current=window.setTimeout(()=>{p(false),N.current=null;},120);}function Be(){Z(true),i(true);}function Nt(){m(false),v(false),x(false),me(),E.current=false,p(false),e.isCapturing?e.exit():e.enter();}function Mt(){m(false),v(false),me(),E.current=false,p(false),x(O=>{let ie=!O;return ie&&n.refresh(),ie});}function pr(){Z(true),i(false),m(false),v(false),x(false),me(),E.current=false,p(false),e.exit(),t.active&&t.forceClose();}useEffect(()=>()=>{N.current!==null&&window.clearTimeout(N.current),f.current!==null&&window.clearTimeout(f.current);},[]);let T=()=>{r.signOut(),p(false);};function L(){v(false),x(false),me(),E.current=false,p(false),m(O=>!O);}function V(O){m(false),r.activeViewport!==O&&(t.active&&t.forceClose(),r.setActiveViewport(O));}function B(){m(false),x(false),me(),E.current=false,p(false),v(O=>!O);}function Y(){s(!a);}function mr(O){let ie=O.relatedTarget;ie instanceof Node&&O.currentTarget.contains(ie)||ge();}return jsxs("div",{"data-patch-fab-dock":"",className:"fixed right-5 bottom-5 z-[2147483647] flex justify-end",children:[jsxs(motion.div,{initial:false,animate:{width:o?pe:Do},transition:{duration:.36,ease:Pe},onAnimationComplete:()=>Z(false),whileHover:o?void 0:{scale:1.03,transition:{duration:.15,ease:Pe}},whileTap:o?void 0:{scale:.97,transition:{duration:.1,ease:Pe}},"data-patch-fab-dock":"",className:R("pkey-fab relative h-11 rounded-full",Q?"overflow-hidden":"overflow-visible"),children:[jsx(motion.div,{animate:{opacity:o?0:1,scale:o?.7:1},transition:{duration:.18,ease:Pe},className:R("absolute inset-0",o?"pointer-events-none":"pointer-events-auto"),children:jsx("button",{type:"button",onClick:Be,"data-patch-fab-dock":"","aria-label":c&&l>0?`Leave feedback \u2014 ${l} open`:"Leave feedback",className:"grid size-full place-items-center border-0 bg-transparent text-white",children:jsx(At,{size:18})})}),jsxs("div",{ref:be,"data-patch-fab-dock":"",className:R("absolute inset-y-0 left-0 flex w-max items-center gap-1.5 px-1.5",o?"pointer-events-auto":"pointer-events-none"),children:[jsx(dt,{visible:o,index:0,children:jsx(Ce,{text:e.isCapturing?"Stop commenting":"Add comment",children:jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":e.isCapturing?"Stop commenting":"Add comment","aria-pressed":e.isCapturing,onClick:Nt,className:R(ct,"transition-colors",e.isCapturing?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:jsx(Io,{variant:"outline",size:16})})})}),c?jsx(dt,{visible:o,index:1,children:jsx(Ce,{text:"Feedback",children:jsxs("button",{type:"button","data-patch-fab-dock":"","data-patch-roster-btn":"","aria-label":l>0?`Feedback \u2014 ${l} open`:"Feedback","aria-expanded":w,onClick:Mt,className:R(ct,"relative transition-colors",w||l>0?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:[jsx($,{name:"list",size:15}),l>0?jsx("span",{className:"pointer-events-none absolute -top-0.5 -right-0.5 grid h-[15px] min-w-[15px] place-items-center rounded-full bg-brand px-1 text-[9px] font-semibold text-white",children:l>99?"99+":l}):null]})})}):null,jsx(dt,{visible:o,index:2,children:jsxs("div",{className:"relative flex items-center",children:[jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":`Viewport: ${S.label}`,"aria-expanded":u,onClick:L,className:R(ct,"transition-colors",r.activeViewport==="desktop"&&!u?"text-white/70 hover:bg-white/[0.08] hover:text-white":"bg-brand/15 text-brand"),children:jsx($,{name:S.glyph,size:15})}),jsx(AnimatePresence,{children:u?jsxs(motion.div,{initial:{opacity:0,y:4,scale:.97},animate:{opacity:1,y:0,scale:1,transition:{duration:.16,ease:Pe}},exit:{opacity:0,y:3,scale:.98,transition:{duration:.12,ease:Pe}},"data-patch-fab-dock":"","data-patch-viewport-menu":"",className:"pkey-fab absolute bottom-[46px] left-[-42px] z-[2147483647] flex items-center gap-1 rounded-full p-1.5 text-white",style:{transformOrigin:"50% calc(100% + 8px)"},children:[jsx("span",{className:"pointer-events-none absolute -bottom-1 left-1/2 size-2 -translate-x-1/2 rotate-45 rounded-[2px] border-r border-b border-white/10 bg-foreground"}),qr.map(O=>{let ie=we[O],Te=r.activeViewport===O;return jsx(Ce,{text:je(O),children:jsx("button",{type:"button","data-patch-viewport-option":O,"aria-label":je(O),"aria-pressed":Te,onClick:()=>V(O),className:R("grid size-8 place-items-center rounded-full border-0 bg-transparent transition-colors",Te?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:jsx($,{name:ie.glyph,size:15})})},O)})]}):null})]})}),jsx(dt,{visible:o,index:3,children:jsxs("div",{className:"relative flex items-center",children:[jsx(Ce,{text:"Settings",children:jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":"Settings","aria-expanded":h,onClick:B,className:R(ct,"transition-colors",h||a?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:jsx($,{name:"settings",size:15})})}),jsx(AnimatePresence,{children:h?jsxs(motion.div,{initial:{opacity:0,y:4,scale:.97},animate:{opacity:1,y:0,scale:1,transition:{duration:.16,ease:Pe}},exit:{opacity:0,y:3,scale:.98,transition:{duration:.12,ease:Pe}},"data-patch-fab-dock":"","data-patch-settings-menu":"",className:"pkey-fab absolute bottom-[46px] left-[-84px] z-[2147483647] w-[200px] rounded-xl p-1.5 text-white",style:{transformOrigin:"50% calc(100% + 8px)"},children:[jsx("span",{className:"pointer-events-none absolute -bottom-1 left-1/2 size-2 -translate-x-1/2 rotate-45 rounded-[2px] border-r border-b border-white/10 bg-foreground"}),jsxs("label",{"data-patch-hide-resolved-toggle":"",className:"flex h-9 w-full cursor-pointer items-center gap-2 rounded-lg px-2.5 text-left font-sans text-[12px] font-medium text-white transition-colors hover:bg-white/[0.08]",children:[jsx("input",{type:"checkbox",checked:a,"aria-label":"Hide resolved annotations",onChange:Y,className:"peer sr-only"}),jsx("span",{"aria-hidden":"true",className:R("grid size-4 shrink-0 place-items-center rounded-[5px] border transition-colors",a?"border-brand bg-brand text-white":"border-white/25 bg-white/[0.06] text-transparent"),children:jsx($,{name:"check",size:10,stroke:2.4})}),jsx("span",{className:"min-w-0 flex-1 whitespace-nowrap",children:"Hide resolved annotations"})]})]}):null})]})}),jsx(dt,{visible:o,index:4,children:jsxs("span",{"data-patch-identity-hover":"",className:"relative inline-flex items-center justify-center",onMouseEnter:Se,onMouseLeave:ge,onFocus:q,onBlur:mr,children:[jsx("button",{type:"button","data-patch-fab-dock":"","data-patch-person-btn":"","aria-label":ee?`Account: ${ee}`:"Identify",className:R(ct,"text-white"),children:ee?jsx($e,{initials:X,tint:D,src:C,generatedSeed:M,alt:ee,size:"sm",className:R("size-[22px] text-[9.5px] ring-1 ring-white/20",H)}):jsx("span",{className:"grid size-[22px] place-items-center rounded-full border border-white/30 text-[9.5px] font-semibold text-white/70",children:"?"})}),jsx(AnimatePresence,{children:d?jsxs(motion.div,{initial:b?false:{opacity:0,y:3,scale:.98},animate:{opacity:1,y:0,scale:1,transition:b?{duration:0}:{duration:.12,delay:ol,ease:Lo}},exit:{opacity:0,y:2,scale:.98,transition:k?{duration:0}:{duration:.08,ease:Lo}},"data-patch-fab-dock":"","data-patch-identity-popover":"",className:"fixed right-8 bottom-[72px] z-[2147483647] w-[min(272px,calc(100vw-40px))] min-w-[220px] rounded-xl bg-foreground p-3.5 font-sans text-[13px] text-white shadow-[0_18px_44px_-14px_rgba(0,0,0,0.5),0_6px_14px_-6px_rgba(0,0,0,0.45)] ring-1 ring-white/10",style:{transformOrigin:al},children:[jsx("span",{className:"absolute bottom-[-4px] size-2 rotate-45 border-r border-b border-white/10 bg-foreground",style:{right:il}}),r.studio?jsxs("div",{className:"flex items-center gap-2.5",children:[jsx($e,{initials:X,tint:A,src:C,generatedSeed:M,alt:r.studio.name,size:"md"}),jsxs("div",{className:"min-w-0",children:[jsx("div",{className:"truncate font-medium text-white",children:r.studio.name}),jsx("div",{className:"truncate text-xs text-white/55",children:r.studio.email})]})]}):r.identity?jsxs(Fragment,{children:[jsxs("div",{className:"flex items-center gap-2.5",children:[jsx($e,{initials:X,tint:A,generatedSeed:M,size:"md"}),jsxs("div",{className:"min-w-0",children:[jsx("div",{className:"truncate font-medium text-white",children:r.identity.name}),jsx("div",{className:"truncate text-xs text-white/55",children:r.identity.email})]})]}),jsx("div",{className:"my-3 h-px bg-white/10"}),jsx("button",{type:"button",onClick:T,className:"w-full rounded-full bg-white/[0.08] px-2.5 py-[7px] text-[12.5px] font-medium text-white transition-colors hover:bg-white/[0.13]",children:"Sign out"})]}):jsx("div",{className:"text-[12.5px] text-white/60",children:"Not signed in. Drop a pin to introduce yourself."})]}):null})]})}),jsx(dt,{visible:o,index:5,children:jsxs("div",{className:"flex items-center gap-1.5",children:[jsx("span",{className:"h-5 w-px shrink-0 bg-white/12"}),jsx(Ce,{text:"Close",children:jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":"Close",onClick:pr,className:R(ct,"text-white/70"),children:jsx($,{name:"x",size:14})})})]})})]})]}),c&&!o&&l>0?jsx("span",{"data-patch-fab-dock":"","data-patch-roster-badge":"","aria-hidden":"true",className:"pointer-events-none absolute -top-1 -right-1 grid h-[18px] min-w-[18px] place-items-center rounded-full bg-brand px-1 text-[10.5px] font-semibold text-white shadow-[0_1px_3px_rgba(0,0,0,0.3)]",children:l>99?"99+":l}):null,jsx(AnimatePresence,{children:w?jsx(Ro,{onClose:()=>x(false)}):null})]})}function dt({children:e,visible:t,index:r}){return jsx(motion.div,{initial:{opacity:0,x:6},animate:t?{opacity:1,x:0,transition:{duration:.2,delay:.12+r*.035,ease:Pe}}:{opacity:0,x:6,transition:{duration:.12,ease:Pe}},children:e})}function zo(e,t){return t.width<=0||t.height<=0?{fx:0,fy:0}:{fx:(e.viewportX-t.x)/t.width,fy:(e.viewportY-t.y)/t.height}}function $o(e,t){return {viewportX:t.x+e.fx*t.width,viewportY:t.y+e.fy*t.height}}var ll=.6,cl=.5,ir={text:.4,attrs:.3,classes:.2,position:.1},dl=5e3,ul=.08,pl=.12;function ml(e,t){return t===void 0||t===""?.5:e===t?1:e&&(e.includes(t)||t.includes(e))?.5:0}function gl(e,t){if(!t)return .5;let r=Object.keys(t);if(r.length===0)return .5;let n=0;for(let o of r)e[o]===t[o]&&n++;return n/r.length}function fl(e,t){let r=new Set(e),n=new Set(t??[]);if(r.size===0&&n.size===0)return .5;let o=0;for(let i of r)n.has(i)&&o++;let a=r.size+n.size-o;return a===0?0:o/a}function Fo(e){let t=e.payload.boundingBox;if(!t)return null;let r=e.payload.coordinates.documentY-e.payload.coordinates.viewportY;return {x:t.x+t.width/2,y:t.y+t.height/2+r}}function _r(e,t,r){if(!t)return .5;let n=e.left+e.width/2,o=e.top+r.scrollY+e.height/2,a=(n-t.x)/Math.max(1,r.viewport.width),i=(o-t.y)/Math.max(1,r.viewport.height);return Math.max(0,1-Math.sqrt(a*a+i*i))}function hl(e,t){let r=Ft(e),n=Ht(e),o=Ue(e),a=e.getBoundingClientRect(),i=ml(r,t.payload.domHints?.textSignature),s=gl(n,t.payload.domHints?.attributeSignature),c=fl(o,t.payload.cssClasses),l=_r(a,Fo(t),t);return ir.text*i+ir.attrs*s+ir.classes*c+ir.position*l}function bl(e){let t=e.getBoundingClientRect();return t.width<1&&t.height<1}function Ho(e,t,r){let n=null,o=null,a=0;for(let i=0;i<e.length&&!(a>=dl);i++){let s=e[i];if(!s||(a++,Vt(s,t.internalAttr)))continue;let c=s.tagName.toLowerCase();if(c==="html"||c==="head"||c==="script"||c==="style"||bl(s))continue;let l=hl(s,t);!n||l>n.score?(o=n,n={el:s,score:l}):(!o||l>o.score)&&(o={el:s,score:l});}if(!n||n.score<r)return null;if(o&&n.score-o.score<ul){let i=Fo(t),s=_r(n.el.getBoundingClientRect(),i,t),c=_r(o.el.getBoundingClientRect(),i,t);if(s-c<pl)return null}return n.el}function vl(e){return {viewportX:e.payload.coordinates.viewportX,viewportY:e.payload.coordinates.documentY-e.scrollY}}function xl(e,t){let r=e.getBoundingClientRect();if(!t.payload.boundingBox)return {viewportX:r.x,viewportY:r.y};let n=zo({viewportX:t.payload.coordinates.viewportX,viewportY:t.payload.coordinates.viewportY},t.payload.boundingBox);return $o(n,{x:r.x,y:r.y,width:r.width,height:r.height})}function wl(e){let t=e.payload.domHints?.cssSelector;if(!t)return [];try{return Array.from(e.doc.querySelectorAll(t))}catch{return []}}function ar(e){if(!e.payload.domHints)return {kind:"positional",el:null};let t=wl(e);if(t.length>0){let n=Ho(t,e,cl);if(n)return {kind:"anchored",tier:1,el:n}}let r=Ho(e.doc.querySelectorAll("*"),e,ll);return r?{kind:"anchored",tier:2,el:r}:{kind:"detached",el:null}}function Dr(e,t){return e.kind==="anchored"&&e.el?xl(e.el,t):vl(t)}function Vo(e){let t=ar(e);return {kind:t.kind,tier:t.tier,el:t.el,position:Dr(t,e)}}function Bo(e){if(e.status==="resolved")return null;let t=e.latestRun;return t?t.status==="failed"?"patch-failed":t.status!=="succeeded"?null:t.prClosedUnmerged?"rerun-after-closed":t.prUrl?"review-pr":null:null}var kl="data-patch-internal";function sr(e,t,r){let n=it(r,t.getOverlayViewport()),o=Qt(r,n);e.style.top=`${o.y}px`,e.style.left=`${o.x}px`;}function Uo(e,t){return Math.abs(e.viewportX-t.viewportX)<.5&&Math.abs(e.viewportY-t.viewportY)<.5}function Cl(e){let t=e.getBoundingClientRect();return t.width<1&&t.height<1}function zr(e,t){return {payload:t.payload,doc:e.targetDocument,scrollY:e.getTargetScrollY(),viewport:e.getTargetViewport(),internalAttr:kl}}function Xo(e,t,r){let n=zr(e,t);return {kind:r.kind,position:e.targetPointToOverlay(Dr(r,n))}}function Al(e,t){return e.targetPointToOverlay({viewportX:t.viewportX,viewportY:t.documentY-e.getTargetScrollY()})}function Go(){let{annotations:e,annotationsReady:t,ephemerals:r,identity:n,studio:o,clientAvatarSeed:a,apiClient:i}=re(),s=xe(),{dockOpen:c,hideResolvedAnnotations:l}=ze(),d=ce(),{isPreviewing:p,previewReady:u}=et(),m=useReducedMotion(),h=s.active,v=s.forceClose,w=t&&(!p||u),x=useMemo(()=>c&&t?e.filter(C=>!l||C.status!=="resolved"):[],[c,t,e,l]),b=useMemo(()=>c&&t?r:[],[c,t,r]);useEffect(()=>{if(!l||h?.kind!=="existing")return;e.find(I=>I.id===h.annotationId)?.status==="resolved"&&v();},[h,e,v,l]);let g=useRef(new Map),k=useRef(new Map),z=useRef(new Map),N=useRef(new Map),f=useMemo(()=>{let C=N.current,I=new Set,M=new Map;for(let A of x){I.add(A.id);let D=C.get(A.id),S=D?.kind==="positional"||D?.kind==="anchored"&&D.el?.isConnected?D:ar(zr(d,A));C.set(A.id,S),M.set(A.id,Xo(d,A,S));}for(let A of C.keys())I.has(A)||C.delete(A);return M},[d,x]),E=useCallback(()=>{let C=N.current,I=z.current,M=new Set;for(let A of x){let D=g.current.get(A.id);if(!D)continue;M.add(A.id);let H=C.get(A.id);if((!H||H.kind==="anchored"&&H.el&&!H.el.isConnected)&&(H=ar(zr(d,A)),C.set(A.id,H)),H.kind==="detached"||H.kind==="anchored"&&H.el&&Cl(H.el)){D.style.visibility!=="hidden"&&(D.style.visibility="hidden"),I.delete(A.id);continue}D.style.visibility==="hidden"&&(D.style.visibility="");let S=Xo(d,A,H).position,te=I.get(A.id);te&&Uo(te,S)||(I.set(A.id,S),sr(D,d,S));}for(let A of b){let D=k.current.get(A.tempId);if(!D)continue;M.add(A.tempId);let H=Al(d,A),S=I.get(A.tempId);S&&Uo(S,H)||(I.set(A.tempId,H),sr(D,d,H));}for(let A of I.keys())M.has(A)||I.delete(A);},[d,x,b]),Q=x.length>0||b.length>0;useEffect(()=>{if(!Q)return;let C=d.overlayWindow,I=C.requestAnimationFrame(function M(){E(),I=C.requestAnimationFrame(M);});return ()=>C.cancelAnimationFrame(I)},[Q,E,d]);let Z=useRef(new Map);useEffect(()=>{if(!t||x.length===0)return;let C=setTimeout(()=>{let I=[];for(let M of x){let A=f.get(M.id);if(!A)continue;let D=A.kind!=="detached";Z.current.get(M.id)!==D&&(Z.current.set(M.id,D),I.push({id:M.id,present:D}));}i.reportAnchorStatuses(I);},1500);return ()=>clearTimeout(C)},[f,x,t,i]);let be=useCallback(C=>{if(s.active&&s.draftText.trim().length>0){s.attemptClose();return}s.openExisting(C);},[s]),pe=o?o.name:n?.name??null,oe=o?.image??null,ee=n?.avatarSeed??a,X=o?.userId??ee;return jsxs("div",{"data-patch-pin-layer":"",style:{opacity:w?1:0,transition:m||!w?void 0:"opacity 0.2s cubic-bezier(0.22, 0.61, 0.36, 1)",pointerEvents:w?void 0:"none"},children:[jsx(AnimatePresence,{initial:false,children:x.map(C=>{let I=f.get(C.id);if(I?.kind==="detached")return null;let M=Sl(C),A=!o&&!!n?.clientUserId&&C.payload.authorRole==="client"&&C.payload.authorId===n.clientUserId,D=o?Bo(C):null,H=I?it(I.position,d.getOverlayViewport()):"right";return jsx(Ir,{ref:S=>{S?(g.current.set(C.id,S),I&&sr(S,d,I.position)):g.current.delete(C.id);},avatarSrc:M.image,generatedSeed:A?ee:M.generatedSeed,avatarAlt:M.name??"",resolved:C.status==="resolved",attention:D,orphan:I?.kind==="positional",pointSide:H,ariaLabel:`Annotation by ${C.authorName??"someone"}`,onClick:()=>be(C.id),pinId:C.id},C.id)})}),jsx(AnimatePresence,{initial:false,children:b.map(C=>{let I=d.targetPointToOverlay({viewportX:C.viewportX,viewportY:C.viewportY});return jsx(Ir,{ref:M=>{M?(k.current.set(C.tempId,M),sr(M,d,I)):k.current.delete(C.tempId);},avatarSrc:oe,generatedSeed:X,avatarAlt:pe??"",resolved:false,pointSide:it(I,d.getOverlayViewport()),ephemeral:true},C.tempId)})})]})}function Sl(e){let t=e.authorAvatarSeed??e.payload.authorId??(e.authorName?`annotation-author:${e.authorName}`:null);if(e.authorImage||t||e.authorName)return {name:e.authorName,image:e.authorImage??null,generatedSeed:t??e.id,key:e.payload.authorId??e.authorName??e.id};let r=e.thread.find(n=>n.authorImage||n.authorId||n.authorName);if(r){let n=r.authorAvatarSeed??r.authorId??(r.authorName?`thread-author:${r.authorName}`:null);return {name:r.authorName,image:r.authorImage??null,generatedSeed:n??e.id,key:r.authorId??r.authorName??e.id}}return {name:e.authorName,image:e.authorImage??null,generatedSeed:e.id,key:e.id}}var Pl=5e3;function qo(){let e=rt(),t=re(),r=xe(),n=ze(),o=ce(),a=useReducedMotion(),i=e.pendingFocus,s=useRef(null),c=useCallback(()=>{s.current!==null&&(window.clearTimeout(s.current),s.current=null);},[]);return useEffect(()=>{if(!i)return;if(ae(window.location.href)!==ae(i.url)){e.clearFocus();return}if(n.dockOpen||n.setDockOpen(true),t.activeViewport!==i.viewport){t.setActiveViewport(i.viewport);return}if(!t.annotationsReady)return;let l=t.annotations.find(p=>p.id===i.id);if(!l){s.current===null&&(s.current=window.setTimeout(()=>{s.current=null,e.clearFocus();},Pl));return}c();let d=l.payload.coordinates?.documentY;if(typeof d=="number"){let p=o.getTargetViewport().height;o.targetWindow.scrollTo({top:Math.max(0,d-p/3),behavior:a?"auto":"smooth"});}r.openExisting(i.id),e.clearFocus();},[i,t,n,o,a,r,e,c]),useEffect(()=>()=>c(),[c]),null}var jo=`/*! tailwindcss v4.2.4 | MIT License | https://tailwindcss.com */
5
5
  @layer properties;
6
6
  @layer theme, base, components, utilities;
7
7
  @layer theme {
@@ -23,9 +23,9 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
23
23
  --font-weight-bold: 700;
24
24
  --leading-snug: 1.375;
25
25
  --leading-normal: 1.5;
26
- --radius-lg: 1.25rem;
27
- --radius-xl: 0.75rem;
28
- --radius-2xl: 1rem;
26
+ --radius-md: 0.5rem;
27
+ --radius-lg: 0.75rem;
28
+ --radius-xl: 1rem;
29
29
  --ease-out: cubic-bezier(0.22, 0.61, 0.36, 1);
30
30
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
31
31
  --default-transition-duration: 150ms;
@@ -33,14 +33,12 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
33
33
  --default-font-family: var(--font-sans);
34
34
  --default-mono-font-family: var(--font-mono);
35
35
  --radius: var(--radius-lg);
36
- --color-foreground: oklch(0.18 0 0);
37
- --color-popover: oklch(1 0 0);
38
- --color-popover-foreground: oklch(0.18 0 0);
39
- --color-primary: oklch(0.18 0 0);
40
- --color-primary-foreground: oklch(1 0 0);
41
- --color-muted-foreground: oklch(0.62 0 0);
36
+ --color-foreground: oklch(0.19 0.005 265);
37
+ --color-popover: oklch(0.998 0.0015 265);
38
+ --color-popover-foreground: oklch(0.19 0.005 265);
39
+ --color-muted-foreground: oklch(0.6 0.008 265);
42
40
  --color-destructive: oklch(0.55 0.2 27);
43
- --color-border: oklch(0.92 0 0);
41
+ --color-border: oklch(0.925 0.005 265);
44
42
  --color-ring: oklch(0.60 0.21 250 / 0.40);
45
43
  --color-brand: #0287FE;
46
44
  --color-brand-tint: rgba(2, 135, 254, 0.10);
@@ -423,13 +421,13 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
423
421
  width: 7px;
424
422
  height: 7px;
425
423
  }
426
- .size-\\[9px\\] {
427
- width: 9px;
428
- height: 9px;
424
+ .size-\\[10px\\] {
425
+ width: 10px;
426
+ height: 10px;
429
427
  }
430
- .size-\\[13px\\] {
431
- width: 13px;
432
- height: 13px;
428
+ .size-\\[14px\\] {
429
+ width: 14px;
430
+ height: 14px;
433
431
  }
434
432
  .size-\\[22px\\] {
435
433
  width: 22px;
@@ -534,6 +532,18 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
534
532
  --tw-translate-x: calc(calc(1 / 2 * 100%) * -1);
535
533
  translate: var(--tw-translate-x) var(--tw-translate-y);
536
534
  }
535
+ .scale-50 {
536
+ --tw-scale-x: 50%;
537
+ --tw-scale-y: 50%;
538
+ --tw-scale-z: 50%;
539
+ scale: var(--tw-scale-x) var(--tw-scale-y);
540
+ }
541
+ .scale-100 {
542
+ --tw-scale-x: 100%;
543
+ --tw-scale-y: 100%;
544
+ --tw-scale-z: 100%;
545
+ scale: var(--tw-scale-x) var(--tw-scale-y);
546
+ }
537
547
  .rotate-45 {
538
548
  rotate: 45deg;
539
549
  }
@@ -632,45 +642,27 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
632
642
  .rounded {
633
643
  border-radius: var(--radius);
634
644
  }
635
- .rounded-2xl {
636
- border-radius: var(--radius-2xl);
637
- }
638
645
  .rounded-\\[2px\\] {
639
646
  border-radius: 2px;
640
647
  }
641
648
  .rounded-\\[5px\\] {
642
649
  border-radius: 5px;
643
650
  }
644
- .rounded-\\[10px\\] {
645
- border-radius: 10px;
646
- }
647
- .rounded-\\[14px\\] {
648
- border-radius: 14px;
649
- }
650
- .rounded-\\[16px\\] {
651
- border-radius: 16px;
652
- }
653
- .rounded-\\[18px\\] {
654
- border-radius: 18px;
655
- }
656
- .rounded-\\[20px\\] {
657
- border-radius: 20px;
658
- }
659
- .rounded-\\[22px\\] {
660
- border-radius: 22px;
661
- }
662
651
  .rounded-full {
663
652
  border-radius: calc(infinity * 1px);
664
653
  }
665
654
  .rounded-lg {
666
655
  border-radius: var(--radius-lg);
667
656
  }
657
+ .rounded-md {
658
+ border-radius: var(--radius-md);
659
+ }
668
660
  .rounded-xl {
669
661
  border-radius: var(--radius-xl);
670
662
  }
671
- .rounded-b-\\[22px\\] {
672
- border-bottom-right-radius: 22px;
673
- border-bottom-left-radius: 22px;
663
+ .rounded-b-xl {
664
+ border-bottom-right-radius: var(--radius-xl);
665
+ border-bottom-left-radius: var(--radius-xl);
674
666
  }
675
667
  .border {
676
668
  border-style: var(--tw-border-style);
@@ -860,9 +852,6 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
860
852
  .bg-popover {
861
853
  background-color: var(--color-popover);
862
854
  }
863
- .bg-primary {
864
- background-color: var(--color-primary);
865
- }
866
855
  .bg-transparent {
867
856
  background-color: transparent;
868
857
  }
@@ -944,9 +933,6 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
944
933
  .py-1 {
945
934
  padding-block: calc(var(--spacing) * 1);
946
935
  }
947
- .py-1\\.5 {
948
- padding-block: calc(var(--spacing) * 1.5);
949
- }
950
936
  .py-2 {
951
937
  padding-block: calc(var(--spacing) * 2);
952
938
  }
@@ -1011,9 +997,6 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
1011
997
  font-size: var(--text-xs);
1012
998
  line-height: var(--tw-leading, var(--text-xs--line-height));
1013
999
  }
1014
- .text-\\[8px\\] {
1015
- font-size: 8px;
1016
- }
1017
1000
  .text-\\[9\\.5px\\] {
1018
1001
  font-size: 9.5px;
1019
1002
  }
@@ -1122,26 +1105,23 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
1122
1105
  color: var(--color-popover-foreground);
1123
1106
  }
1124
1107
  .text-popover-foreground\\/45 {
1125
- color: color-mix(in srgb, oklch(0.18 0 0) 45%, transparent);
1108
+ color: color-mix(in srgb, oklch(0.19 0.005 265) 45%, transparent);
1126
1109
  @supports (color: color-mix(in lab, red, red)) {
1127
1110
  color: color-mix(in oklab, var(--color-popover-foreground) 45%, transparent);
1128
1111
  }
1129
1112
  }
1130
1113
  .text-popover-foreground\\/50 {
1131
- color: color-mix(in srgb, oklch(0.18 0 0) 50%, transparent);
1114
+ color: color-mix(in srgb, oklch(0.19 0.005 265) 50%, transparent);
1132
1115
  @supports (color: color-mix(in lab, red, red)) {
1133
1116
  color: color-mix(in oklab, var(--color-popover-foreground) 50%, transparent);
1134
1117
  }
1135
1118
  }
1136
1119
  .text-popover-foreground\\/55 {
1137
- color: color-mix(in srgb, oklch(0.18 0 0) 55%, transparent);
1120
+ color: color-mix(in srgb, oklch(0.19 0.005 265) 55%, transparent);
1138
1121
  @supports (color: color-mix(in lab, red, red)) {
1139
1122
  color: color-mix(in oklab, var(--color-popover-foreground) 55%, transparent);
1140
1123
  }
1141
1124
  }
1142
- .text-primary-foreground {
1143
- color: var(--color-primary-foreground);
1144
- }
1145
1125
  .text-transparent {
1146
1126
  color: transparent;
1147
1127
  }
@@ -1184,6 +1164,9 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
1184
1164
  .opacity-80 {
1185
1165
  opacity: 80%;
1186
1166
  }
1167
+ .opacity-100 {
1168
+ opacity: 100%;
1169
+ }
1187
1170
  .shadow {
1188
1171
  --tw-shadow: 0 1px 3px 0 var(--tw-shadow-color, rgb(0 0 0 / 0.1)), 0 1px 2px -1px var(--tw-shadow-color, rgb(0 0 0 / 0.1));
1189
1172
  box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
@@ -1246,6 +1229,10 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
1246
1229
  outline-style: var(--tw-outline-style);
1247
1230
  outline-width: 1px;
1248
1231
  }
1232
+ .blur-\\[2px\\] {
1233
+ --tw-blur: blur(2px);
1234
+ filter: var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,);
1235
+ }
1249
1236
  .grayscale {
1250
1237
  --tw-grayscale: grayscale(100%);
1251
1238
  filter: var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,);
@@ -1263,6 +1250,11 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
1263
1250
  transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
1264
1251
  transition-duration: var(--tw-duration, var(--default-transition-duration));
1265
1252
  }
1253
+ .transition-all {
1254
+ transition-property: all;
1255
+ transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
1256
+ transition-duration: var(--tw-duration, var(--default-transition-duration));
1257
+ }
1266
1258
  .transition-colors {
1267
1259
  transition-property: color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to;
1268
1260
  transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
@@ -1273,6 +1265,14 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
1273
1265
  transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
1274
1266
  transition-duration: var(--tw-duration, var(--default-transition-duration));
1275
1267
  }
1268
+ .duration-200 {
1269
+ --tw-duration: 200ms;
1270
+ transition-duration: 200ms;
1271
+ }
1272
+ .ease-out {
1273
+ --tw-ease: var(--ease-out);
1274
+ transition-timing-function: var(--ease-out);
1275
+ }
1276
1276
  .outline-none {
1277
1277
  --tw-outline-style: none;
1278
1278
  outline-style: none;
@@ -1374,16 +1374,6 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
1374
1374
  }
1375
1375
  }
1376
1376
  }
1377
- .hover\\:bg-primary\\/90 {
1378
- &:hover {
1379
- @media (hover: hover) {
1380
- background-color: color-mix(in srgb, oklch(0.18 0 0) 90%, transparent);
1381
- @supports (color: color-mix(in lab, red, red)) {
1382
- background-color: color-mix(in oklab, var(--color-primary) 90%, transparent);
1383
- }
1384
- }
1385
- }
1386
- }
1387
1377
  .hover\\:bg-white\\/\\[0\\.08\\] {
1388
1378
  &:hover {
1389
1379
  @media (hover: hover) {
@@ -1490,23 +1480,23 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
1490
1480
  font-feature-settings: "cv11", "ss01";
1491
1481
  letter-spacing: -0.011em;
1492
1482
  cursor: auto;
1493
- --color-background: oklch(0.985 0 0);
1494
- --color-foreground: oklch(0.18 0 0);
1495
- --color-card: oklch(1 0 0);
1496
- --color-card-foreground: oklch(0.18 0 0);
1497
- --color-popover: oklch(1 0 0);
1498
- --color-popover-foreground: oklch(0.18 0 0);
1499
- --color-primary: oklch(0.18 0 0);
1500
- --color-primary-foreground: oklch(1 0 0);
1501
- --color-secondary: oklch(0.945 0 0);
1502
- --color-secondary-foreground: oklch(0.18 0 0);
1503
- --color-muted: oklch(0.945 0 0);
1504
- --color-muted-foreground: oklch(0.62 0 0);
1483
+ --color-background: oklch(0.985 0.003 265);
1484
+ --color-foreground: oklch(0.19 0.005 265);
1485
+ --color-card: oklch(0.998 0.0015 265);
1486
+ --color-card-foreground: oklch(0.19 0.005 265);
1487
+ --color-popover: oklch(0.998 0.0015 265);
1488
+ --color-popover-foreground: oklch(0.19 0.005 265);
1489
+ --color-primary: oklch(0.19 0.005 265);
1490
+ --color-primary-foreground: oklch(0.99 0.0015 265);
1491
+ --color-secondary: oklch(0.948 0.004 265);
1492
+ --color-secondary-foreground: oklch(0.19 0.005 265);
1493
+ --color-muted: oklch(0.948 0.004 265);
1494
+ --color-muted-foreground: oklch(0.6 0.008 265);
1505
1495
  --color-accent: oklch(0.60 0.21 250);
1506
1496
  --color-accent-foreground: oklch(1 0 0);
1507
1497
  --color-destructive: oklch(0.55 0.2 27);
1508
- --color-border: oklch(0.92 0 0);
1509
- --color-input: oklch(0.92 0 0);
1498
+ --color-border: oklch(0.925 0.005 265);
1499
+ --color-input: oklch(0.905 0.006 265);
1510
1500
  --color-ring: oklch(0.60 0.21 250 / 0.40);
1511
1501
  --color-brand: #0287FE;
1512
1502
  --color-brand-hover: #0173D6;
@@ -1519,9 +1509,10 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
1519
1509
  --color-avatar-tint-4: #525252;
1520
1510
  --color-avatar-tint-5: #3D3D3D;
1521
1511
  --radius-pill: 9999px;
1522
- --radius-sm: 0.625rem;
1523
- --radius-md: 1rem;
1524
- --radius-lg: 1.25rem;
1512
+ --radius-sm: 0.375rem;
1513
+ --radius-md: 0.5rem;
1514
+ --radius-lg: 0.75rem;
1515
+ --radius-xl: 1rem;
1525
1516
  --radius: var(--radius-lg);
1526
1517
  --shadow-subtle: 0 1px 2px 0 oklch(0 0 0 / 0.04);
1527
1518
  --shadow-card: 0 2px 8px -2px oklch(0 0 0 / 0.06), 0 4px 12px -4px oklch(0 0 0 / 0.04);
@@ -1745,6 +1736,21 @@ button:not(:disabled):not(.pkey):active {
1745
1736
  inherits: false;
1746
1737
  initial-value: 0;
1747
1738
  }
1739
+ @property --tw-scale-x {
1740
+ syntax: "*";
1741
+ inherits: false;
1742
+ initial-value: 1;
1743
+ }
1744
+ @property --tw-scale-y {
1745
+ syntax: "*";
1746
+ inherits: false;
1747
+ initial-value: 1;
1748
+ }
1749
+ @property --tw-scale-z {
1750
+ syntax: "*";
1751
+ inherits: false;
1752
+ initial-value: 1;
1753
+ }
1748
1754
  @property --tw-rotate-x {
1749
1755
  syntax: "*";
1750
1756
  inherits: false;
@@ -1941,12 +1947,23 @@ button:not(:disabled):not(.pkey):active {
1941
1947
  syntax: "*";
1942
1948
  inherits: false;
1943
1949
  }
1950
+ @property --tw-duration {
1951
+ syntax: "*";
1952
+ inherits: false;
1953
+ }
1954
+ @property --tw-ease {
1955
+ syntax: "*";
1956
+ inherits: false;
1957
+ }
1944
1958
  @layer properties {
1945
1959
  @supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))) {
1946
1960
  *, ::before, ::after, ::backdrop {
1947
1961
  --tw-translate-x: 0;
1948
1962
  --tw-translate-y: 0;
1949
1963
  --tw-translate-z: 0;
1964
+ --tw-scale-x: 1;
1965
+ --tw-scale-y: 1;
1966
+ --tw-scale-z: 1;
1950
1967
  --tw-rotate-x: initial;
1951
1968
  --tw-rotate-y: initial;
1952
1969
  --tw-rotate-z: initial;
@@ -1993,8 +2010,21 @@ button:not(:disabled):not(.pkey):active {
1993
2010
  --tw-backdrop-opacity: initial;
1994
2011
  --tw-backdrop-saturate: initial;
1995
2012
  --tw-backdrop-sepia: initial;
2013
+ --tw-duration: initial;
2014
+ --tw-ease: initial;
1996
2015
  }
1997
2016
  }
1998
2017
  }
1999
- `;var jo="patch-widget-root";function Jo({children:e}){let[t,r]=useState(null),n=useRef(null);return useEffect(()=>{if(typeof document>"u")return;let o=document.querySelector(jo);o||(o=document.createElement(jo),o.setAttribute("data-patch-internal",""),document.body.appendChild(o)),n.current=o;let s=o.shadowRoot??o.attachShadow({mode:"open"});if(!s.querySelector("style[data-patch-css]")){let a=document.createElement("style");a.setAttribute("data-patch-css",""),a.textContent=Zo,s.appendChild(a);}let i=s.querySelector("div[data-patch-mount]");return i||(i=document.createElement("div"),i.setAttribute("data-patch-mount",""),s.appendChild(i)),r(i),()=>{}},[]),t?createPortal(e,t):null}var Ol=/[\s#.:[\]()>+~,\\]/;function zl(e){return !(!e||Ol.test(e)||/^\d/.test(e))}function Hl(e){let t=1,r=e.previousElementSibling,n=e.tagName;for(;r;)r.tagName===n&&t++,r=r.previousElementSibling;return t}function Qo(e,t,r){try{let n=e.querySelectorAll(t);return n.length===1&&n[0]===r}catch{return false}}function Fl(e,t){return e.id&&zl(e.id)&&(!t||Qo(t,`#${e.id}`,e))?`#${e.id}`:`${e.tagName.toLowerCase()}:nth-of-type(${Hl(e)})`}function ei(e,t){if(!e.tagName)return "";let r=e.ownerDocument??null,n=[],o=e,s=0;for(;o&&s<12;){let i=Fl(o,r);if(n.unshift(i),i.startsWith("#"))break;let a=n.join(" > ");if(r&&Qo(r,a,e))return a;if(o.tagName.toLowerCase()==="html")break;o=o.parentElement,s++;}return n.join(" > ")}var $l=80,Vl=500;function ri(e){return e!==null&&typeof e=="object"}function Bl(e){return ri(e)?"return"in e||"type"in e||"elementType"in e||"_debugOwner"in e:false}function ar(e){if(typeof e=="function")return e.displayName||e.name||null;if(!ri(e))return null;let t=e.displayName;if(typeof t=="string"&&t)return t;let r=ar(e.render);if(r)return r;let n=ar(e.type);return n||null}function ni(e){return e.replace(/\s+/g," ").trim()}function oi(e,t){return e.length<=t?e:`${e.slice(0,t-1).trim()}\u2026`}function Wl(e){let t=ni(e).replace(/[<>]/g,"");return !t||/^[a-z]/.test(t)?null:oi(t,$l)}function Yl(e){let t=ar(e.elementType)??ar(e.type);return t?Wl(t):null}function ti(e){return oi(ni(e),Vl)}function Ul(e){let t=e.replace(/\\/g,"/");return t.includes("/.next/")||t.includes("/node_modules/next/")||t.includes("/node_modules/react/")||t.includes("/node_modules/react-dom/")||t.includes("/node_modules/react-router/")||t.includes("/node_modules/react-router-dom/")||t.includes("/node_modules/@remix-run/")||t.includes("/node_modules/.vite/")||/(^|\/)next\/dist\//.test(t)}function Xl(e){let t=e.replace(/^webpack:\/\/[^/]+\//,"").replace(/^file:\/\//,"").replace(/\\/g,"/").replace(/\/\.\//g,"/").replace(/^\.\//,"");for(let n of ["/apps/","/packages/","/src/"]){let o=t.lastIndexOf(n);if(o>=0)return ti(t.slice(o+1))}let r=t.split("/").filter(Boolean);return ti(r.slice(-3).join("/"))}function Gl(e){let t=e._debugSource?.fileName;return typeof t!="string"||!t.trim()||Ul(t)?null:Xl(t)}function Kl(e){let t=e;for(let r of Object.getOwnPropertyNames(e)){if(!r.startsWith("__reactFiber$")&&!r.startsWith("__reactInternalInstance$"))continue;let n=t[r];if(Bl(n))return n}return null}function Or(e){let t=Kl(e);if(!t)return null;let r=[],n=null,o=0;for(;t&&o<30;){let a=Yl(t),l=a?Sr(a):false;a&&!l&&r[r.length-1]!==a&&r.push(a),l||(n??=Gl(t)),t=t.return??t._debugOwner??null,o+=1;}let s=r.length>0?fo(r.reverse().map(a=>`<${a}>`).join(" ")):null,i={};return s&&(i.reactComponents=s),n&&(i.sourceFile=n),Object.keys(i).length>0?i:null}var ii=500,ai=3;function ql(e){return e.length<=ii?e:e.slice(0,ii)}function zr(e){return {viewportX:e.viewportX,viewportY:e.viewportY,documentY:e.viewportY+e.scrollY,isFixed:false}}function sr(e){return {x:e.x,y:e.y,width:e.width,height:e.height}}function si(e){let t={cssSelector:ei(e)},r=zt(e);r&&(t.textSignature=r);let n=Ot(e);return Object.keys(n).length>0&&(t.attributeSignature=n),t}function li(e){return e.kind==="element"?bt(e.element,e.selectedText):e.kind==="multi"?$t(e.elements.length):Vt()}function ci(e){let{target:t,click:r,comment:n,url:o}=e,s=t.element,i=t.rect,a=Nn(s),l=Mn(s),c=Ye(s),d=_n(s),m=Or(s),u={comment:n,element:ht(s),elementPath:Pn(s),targetLabel:bt(s,t.selectedText),timestamp:Date.now(),url:Ne(o),kind:"feedback",coordinates:zr(r),boundingBox:sr(i),domHints:si(s)};return t.selectedText&&(u.selectedText=ql(t.selectedText)),l&&(u.nearbyText=l),c.length>0&&(u.cssClasses=c),d.length>0&&(u.nearbyElements=d),a&&(u.accessibility=a),m?.reactComponents&&(u.reactComponents=m.reactComponents),m?.sourceFile&&(u.sourceFile=m.sourceFile),u}function di(e){let{target:t,click:r,comment:n,url:o}=e,s=t.elements.slice(0,ai).map(d=>ht(d)),i=t.elements.length>ai?"\u2026":"",a=`${t.elements.length} elements: ${s.join(", ")}${i}`,l=t.elements[0],c=l?Or(l):null;return {comment:n,element:a,elementPath:a,targetLabel:$t(t.elements.length),timestamp:Date.now(),url:Ne(o),kind:"feedback",coordinates:zr(r),boundingBox:sr(t.union),isMultiSelect:true,elementBoundingBoxes:t.rects.map(sr),...c?.reactComponents?{reactComponents:c.reactComponents}:{},...c?.sourceFile?{sourceFile:c.sourceFile}:{},...l?{domHints:si(l)}:{}}}function ui(e){let{target:t,click:r,comment:n,url:o}=e,s=Math.round(t.rect.width),i=Math.round(t.rect.height),a=Math.round(t.rect.x),l=Math.round(t.rect.y);return {comment:n,element:`region ${s}\xD7${i}`,elementPath:`region at (${a}, ${l}) ${s}\xD7${i}`,targetLabel:Vt(),timestamp:Date.now(),url:Ne(o),kind:"feedback",coordinates:zr(r),boundingBox:sr(t.rect)}}async function At(e,t){return e.kind==="composer"?t.createAnnotation(e.payload):t.reply(e.annotationId,{content:e.content})}async function pi(e,t){return t.resolve(e)}async function mi(e,t){return t.deleteAnnotation(e)}async function gi(e,t){return t.deleteMessage(e.annotationId,e.messageId)}async function fi(e,t){return e.viewerKind!=="studio"?null:t.reopen(e.annotationId)}async function hi(e,t){return e.viewerKind!=="studio"?null:t.kickoff(e.annotationId,{guidance:e.guidance})}async function bi(e,t){return t.postIdentity(e)}var wi=createContext(null),xi=0;function Fr(e){return xi+=1,`${e}-${Date.now().toString(36)}-${xi}`}function $r(e){return e.deliveryStatus==="sending"||e.deliveryStatus==="failed"}function yi({annotation:e,draftTargetLabel:t,children:r}){let n=re(),o=xe(),s=ce(),[i,a]=useState(false),[l,c]=useState(null),[d,m]=useState(null),u=useRef(false),h=e?.thread??[],v=e?.latestRun??null,x=e?.status==="resolved",T=e?$r(e):false,w=n.viewerKind,g=useCallback(()=>w==="studio"?{role:"studio",authorId:n.studio?.userId??null,authorName:n.studio?.name??null,authorImage:n.studio?.image??null}:{role:"client",authorId:n.identity?.clientUserId??null,authorName:n.identity?.name??null,authorImage:null},[n.identity,n.studio,w]),p=useMemo(()=>g(),[g]),b=!!e&&e.deliveryStatus!=="sending"&&e.deliveryStatus!=="failed"&&!!p.authorId&&e.payload.authorRole===p.role&&e.payload.authorId===p.authorId,C=useCallback(R=>{let O=g();return {id:Fr("tmp-msg"),role:O.role,authorId:O.authorId,authorName:O.authorName,authorImage:O.authorImage,content:R,createdAt:new Date().toISOString(),deliveryStatus:"sending"}},[g]),A=useCallback(async R=>{if(u.current)return Promise.reject(new Error("busy"));u.current=true,a(true);try{return await R()}finally{u.current=false,a(false);}},[]),f=useCallback(async()=>{let R=o.draftText.trim();if(!R)return;if(e){if(x||$r(e))return;let pt=C(R);o.setDraftText(""),n.updateAnnotation(e.id,Me=>({...Me,thread:[...Me.thread,pt]}));let Xr=await At({kind:"reply",annotationId:e.id,content:R},n.apiClient);if(Xr){n.updateAnnotation(e.id,Me=>({...Me,thread:Me.thread.map(Be=>Be.id===pt.id?{...Be,id:Xr.id,deliveryStatus:"sent"}:Be)})),n.refresh();return}n.updateAnnotation(e.id,Me=>({...Me,thread:Me.thread.map(Be=>Be.id===pt.id?{...Be,deliveryStatus:"failed"}:Be)}));return}let O=o.active;if(!O||O.kind!=="composer")return;let V=O.target,B={viewportX:O.anchor.viewportX,viewportY:O.anchor.viewportY,scrollY:O.anchor.documentY-O.anchor.viewportY},Y=s.getPageUrl(),ur=Zr(n.activeViewport,s.getTargetViewport()),z=V.kind==="element"?ci({target:V,click:B,comment:R,url:Y}):V.kind==="multi"?di({target:V,click:B,comment:R,url:Y}):ui({target:V,click:B,comment:R,url:Y});z.viewport=n.activeViewport,z.viewportSize=ur;let ie=g(),Se=Fr("tmp-ann");n.applyAnnotationUpdate({id:Se,status:"pending",resolvedBy:null,resolvedAt:null,createdAt:new Date().toISOString(),authorName:ie.authorName,authorImage:ie.authorImage,payload:{...z,authorRole:ie.role,authorId:ie.authorId},thread:[],latestRun:null,deliveryStatus:"sending"}),o.setDraftText(""),o.openExisting(Se);let pr=await At({kind:"composer",payload:z},n.apiClient);if(pr){n.replaceAnnotationId(Se,pr.id),o.openExisting(pr.id),n.refresh();return}n.updateAnnotation(Se,pt=>({...pt,deliveryStatus:"failed"}));},[e,g,x,C,n,o,s]),I=useCallback(async R=>{if(!e||$r(e))return;let O=e.thread.find(B=>B.id===R);if(!O||O.deliveryStatus!=="failed")return;n.updateAnnotation(e.id,B=>({...B,thread:B.thread.map(Y=>Y.id===R?{...Y,deliveryStatus:"sending"}:Y)}));let V=await At({kind:"reply",annotationId:e.id,content:O.content},n.apiClient);if(V){n.updateAnnotation(e.id,B=>({...B,thread:B.thread.map(Y=>Y.id===R?{...Y,id:V.id,deliveryStatus:"sent"}:Y)})),n.refresh();return}n.updateAnnotation(e.id,B=>({...B,thread:B.thread.map(Y=>Y.id===R?{...Y,deliveryStatus:"failed"}:Y)}));},[e,n]),Q=useCallback(async()=>{if(!e||e.deliveryStatus!=="failed")return;let R=e.id;n.updateAnnotation(R,V=>({...V,deliveryStatus:"sending"}));let O=await At({kind:"composer",payload:e.payload},n.apiClient);if(O){n.replaceAnnotationId(R,O.id),o.openExisting(O.id),n.refresh();return}n.updateAnnotation(R,V=>({...V,deliveryStatus:"failed"}));},[e,n,o]),Z=useCallback(R=>!p.authorId||R.deliveryStatus&&R.deliveryStatus!=="sent"?false:R.role===p.role&&R.authorId===p.authorId,[p]),be=useCallback(()=>{b&&(c(null),m({kind:"annotation"}));},[b]),pe=useCallback(R=>{Z(R)&&(c(null),m({kind:"message",messageId:R.id}));},[Z]),oe=useCallback(()=>{c(null),m(null);},[]),ee=useCallback(async R=>{if(!e)return false;let O=e.thread;return A(async()=>(c(null),n.updateAnnotation(e.id,B=>({...B,thread:B.thread.filter(Y=>Y.id!==R)})),await gi({annotationId:e.id,messageId:R},n.apiClient)?(n.refresh(),true):(n.updateAnnotation(e.id,B=>({...B,thread:O})),c("Couldn't delete message. Try again."),false)))},[e,n,A]),U=useCallback(async()=>!e||!b?false:A(async()=>(c(null),await mi(e.id,n.apiClient)?(n.updateAnnotation(e.id,()=>null),o.forceClose(),n.refresh(),true):(c("Couldn't delete annotation. Try again."),false))),[e,b,n,o,A]),k=useCallback(async()=>{if(d)try{(d.kind==="annotation"?await U():await ee(d.messageId))&&m(null);}catch{c("Couldn't delete. Try again.");}},[d,U,ee]),N=useCallback(async()=>{e&&await A(async()=>{c(null);let R={status:e.status,resolvedBy:e.resolvedBy,resolvedAt:e.resolvedAt,optimisticAction:e.optimisticAction};if(n.updateAnnotation(e.id,V=>({...V,status:"resolved",resolvedBy:"dev",resolvedAt:new Date().toISOString(),optimisticAction:"resolve-pending"})),!await pi(e.id,n.apiClient)){n.updateAnnotation(e.id,V=>({...V,...R})),c("Couldn't resolve. Try again.");return}n.refresh();});},[e,n,A]),_=useCallback(async()=>{e&&await A(async()=>{c(null);let R={status:e.status,resolvedBy:e.resolvedBy,resolvedAt:e.resolvedAt,optimisticAction:e.optimisticAction};if(n.updateAnnotation(e.id,V=>({...V,status:"pending",resolvedBy:null,resolvedAt:null,optimisticAction:"reopen-pending"})),!await fi({annotationId:e.id,viewerKind:w},n.apiClient)){n.updateAnnotation(e.id,V=>({...V,...R})),c("Couldn't reopen. Try again.");return}n.refresh();});},[e,w,n,A]),S=useCallback(async R=>{e&&await A(async()=>{c(null);let O=e.latestRun,V=e.optimisticAction;n.updateAnnotation(e.id,Y=>({...Y,latestRun:{id:Fr("tmp-run"),status:"queued",prUrl:null,createdAt:new Date().toISOString(),completedAt:null,prClosedUnmerged:false},optimisticAction:"run-pending"}));let B=await hi({annotationId:e.id,viewerKind:w,guidance:R},n.apiClient);if(!B?.ok){n.updateAnnotation(e.id,Y=>({...Y,latestRun:O,optimisticAction:V})),c(B?.error??"Couldn't start Patch. Try again.");return}n.refresh();});},[e,w,n,A]),L=useCallback(async R=>{let O=await bi({...R,avatarSeed:n.clientAvatarSeed},n.apiClient);return O&&await n.setIdentity(O),O},[n]),E=w==="client"&&!n.identity&&h.length===0,te=!!e||h.length>0,me=n.agentRunReadiness?.ready??true,P=n.agentRunReadiness?.message??null,D=useCallback(()=>{if(o.draftText.trim().length>0){o.setConfirmDiscardOpen(true);return}o.forceClose();},[o]),$=e?zn(e.payload):t||"annotation",K=e?.payload.viewport??n.activeViewport,Ae=n.studio?n.studio.name:n.identity?.name??null,ge=n.identity?.avatarSeed??n.clientAvatarSeed,Ve=n.studio?.userId??ge,Rt=n.studio?.image??null,It=n.studio?.userId??ge,dr=useMemo(()=>({state:{annotation:e,messages:h,runState:v,draftText:o.draftText,busy:i,actionError:l,confirmDiscardOpen:o.confirmDiscardOpen,confirmDelete:d,showDevFooter:w==="studio",agentRunReady:me,agentRunSetupMessage:P,needsIdentity:E,isResolved:x,initialMessageLocked:T,threadVisible:te,canDeleteAnnotation:b},actions:{setDraftText:o.setDraftText,submit:f,retryMessage:I,retryInitialMessage:Q,requestDeleteAnnotation:be,requestDeleteMessage:pe,canDeleteMessage:Z,cancelDelete:oe,confirmDelete:k,markResolved:N,reopen:_,runPatch:S,setIdentity:L,attemptClose:o.attemptClose,requestClose:D,forceClose:o.forceClose,setConfirmDiscardOpen:o.setConfirmDiscardOpen},meta:{targetLabel:$,viewport:K,shakeNonce:o.shakeNonce,viewer:{kind:w,authorId:p.authorId,name:Ae,avatarKey:Ve,avatarSrc:Rt,generatedSeed:It}}}),[e,h,v,o.draftText,o.confirmDiscardOpen,o.setDraftText,o.attemptClose,o.forceClose,o.setConfirmDiscardOpen,o.shakeNonce,i,l,d,f,I,Q,be,pe,Z,oe,k,N,_,S,L,w,me,P,E,x,T,te,b,D,$,K,p.authorId,Ae,Ve,Rt,It]);return jsx(wi.Provider,{value:dr,children:r})}function G(){let e=use(wi);if(!e)throw new Error("useThreadContext must be used inside <ThreadProvider>");return e}var tc="inline-flex shrink-0 items-center justify-center gap-1.5 h-8 px-3.5 rounded-full whitespace-nowrap text-[13px] font-semibold transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none",rc={brand:"pkey pkey-brand text-white",brandTint:"bg-brand-tint text-brand hover:bg-brand-tint/70",destructive:"pkey pkey-destructive text-white",destructiveTint:"bg-destructive/10 text-destructive hover:bg-destructive/15",successTint:"bg-brand-green/10 text-brand-green hover:bg-brand-green/15",warn:"pkey pkey-warn text-white",warnTint:"bg-brand-orange/10 text-brand-orange hover:bg-brand-orange/15",neutral:"pkey pkey-outline text-foreground",subtle:"bg-black/8 text-muted-foreground"};function Vr(e="brand",t){return M(tc,rc[e],t)}function fe({variant:e="brand",className:t,type:r="button",ref:n,...o}){return jsx("button",{ref:n,type:r,className:Vr(e,t),...o})}function Ci(){let{state:e,actions:t}=G(),r=e.confirmDelete;if(!r)return null;let n=r.kind==="annotation",o=n?"Delete annotation?":"Delete message?",s=n?"This removes the annotation and its thread for everyone.":"This removes your message from the thread.",i=n?"Delete annotation":"Delete message";return jsx("div",{className:"absolute inset-0 z-40 flex items-start justify-end bg-black/25 p-3 backdrop-blur-[2px]",children:jsxs("div",{role:"dialog","aria-label":o,className:"patch-fade-in flex w-full max-w-[286px] flex-col gap-2 rounded-2xl bg-popover p-4 shadow-dialog",children:[jsx("div",{className:"text-[13.5px] font-medium text-foreground",children:o}),jsx("div",{className:"text-xs text-muted-foreground",children:s}),e.actionError?jsx("div",{className:"text-[11px] font-medium text-destructive",children:e.actionError}):null,jsxs("div",{className:"mt-1 flex justify-end gap-2",children:[jsx(fe,{variant:"neutral",disabled:e.busy,onClick:t.cancelDelete,children:"Cancel"}),jsx(fe,{variant:"destructive",disabled:e.busy,onClick:t.confirmDelete,children:e.busy?"Deleting\u2026":i})]})]})})}function Si(){let{state:e,actions:t}=G();return e.confirmDiscardOpen?jsx("div",{className:"absolute inset-0 z-20 flex items-start justify-end bg-black/25 p-3 backdrop-blur-[2px]",children:jsxs("div",{role:"dialog","aria-label":"Discard draft",className:"patch-fade-in flex w-full max-w-[280px] flex-col gap-2 rounded-2xl bg-popover p-4 shadow-dialog",children:[jsx("div",{className:"text-[13.5px] font-medium text-foreground",children:"Discard draft?"}),jsx("div",{className:"text-xs text-muted-foreground",children:"You'll lose what you've typed."}),jsxs("div",{className:"mt-1 flex justify-end gap-2",children:[jsx(fe,{variant:"neutral",onClick:()=>t.setConfirmDiscardOpen(false),children:"Keep editing"}),jsx(fe,{variant:"destructive",onClick:()=>t.forceClose(),children:"Discard"})]})]})}):null}var oc="inline-grid place-items-center rounded-full transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",ic={sm:"size-7",md:"size-8"},ac={default:"text-muted-foreground hover:bg-black/6 hover:text-foreground",warn:"bg-amber-500/15 text-amber-700"};function He({size:e="sm",tone:t="default",className:r,type:n="button",ref:o,...s}){return jsx("button",{ref:o,type:n,className:M(oc,ic[e],ac[t],r),...s})}function Ti(){let{state:e}=G();return !e.showDevFooter||!e.annotation?null:jsxs("div",{className:"-mt-[22px] flex flex-col gap-2 bg-neutral-100/50 px-3 pt-[2.125rem] pb-3",children:[jsxs("div",{className:"flex items-start justify-between gap-2",children:[jsx(lc,{}),jsx("div",{className:"flex shrink-0 items-center gap-1",children:jsx(dc,{})})]}),e.actionError?jsx("div",{className:"px-1 text-[11px] font-medium text-destructive",children:e.actionError}):null]})}function lc(){let{state:e,actions:t}=G(),[r,n]=useState(false),[o,s]=useState(""),[i,a]=useState(false),l=e.runState,c=l?.status;if(e.annotation?.status==="resolved")return jsx("div",{className:"min-w-0 flex-1"});let m=c==="queued"||c==="running",u=c==="succeeded"&&!!l?.prUrl&&!l.prClosedUnmerged,h=l?"Run Patch again":"Run Patch",v=c==="failed"?"destructiveTint":"brand",x=!e.agentRunReady,T=async()=>{try{a(!0),await t.runPatch(o.trim()||void 0),s(""),n(!1);}finally{a(false);}};if(m)return jsx("div",{className:"min-w-0 flex-1",children:jsxs(fe,{variant:"brandTint",disabled:true,children:[jsx("span",{className:"patch-fade-in size-[7px] rounded-full bg-brand"}),"Patch is working\u2026"]})});if(u){let g=Ao(l.prUrl);return jsx("div",{className:"min-w-0 flex-1",children:jsxs("a",{href:l.prUrl,target:"_blank",rel:"noopener noreferrer",className:Vr("brand","no-underline"),children:[jsx(F,{name:"pr",size:12}),g==="PR"?"View PR":`View PR ${g}`]})})}let w=jsxs(fe,{variant:v,disabled:e.busy||x,className:x?"opacity-60":void 0,onClick:()=>n(true),children:[jsx(kt,{size:12})," ",h]});return jsxs("div",{className:"min-w-0 flex-1",children:[x&&e.agentRunSetupMessage?jsx(Re,{text:e.agentRunSetupMessage,tone:"warning",children:w}):w,r?jsx(cc,{title:h,guidance:o,submitting:i||e.busy,onGuidanceChange:s,onCancel:()=>n(false),onSubmit:T}):null]})}function cc({title:e,guidance:t,submitting:r,onGuidanceChange:n,onCancel:o,onSubmit:s}){return jsxs("div",{className:"absolute inset-0 z-30 flex items-center justify-center p-4",children:[jsx("button",{type:"button","aria-label":"Close guidance",className:"absolute inset-0 cursor-default bg-black/25 backdrop-blur-[2px]",onClick:o}),jsxs("form",{role:"dialog","aria-label":e,className:"patch-fade-in relative flex w-full max-w-[280px] flex-col gap-3 rounded-[20px] bg-popover p-4 shadow-dialog",onSubmit:i=>{i.preventDefault(),s();},children:[jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[jsx("span",{className:"grid size-7 shrink-0 place-items-center rounded-xl bg-brand text-white",children:jsx(kt,{size:13})}),jsx("span",{className:"truncate text-[13.5px] font-medium text-foreground",children:e})]}),jsx(He,{size:"sm",title:"Close",onClick:o,children:jsx(F,{name:"x",size:12})})]}),jsxs("label",{className:"flex flex-col gap-1.5",children:[jsx("span",{className:"text-[12px] font-medium text-muted-foreground",children:"Guidance"}),jsx("textarea",{value:t,onChange:i=>n(i.target.value),maxLength:5e3,rows:3,placeholder:"Optional run guidance",className:"min-h-20 resize-none rounded-[16px] border border-black/10 bg-black/[0.03] px-3 py-2 text-[13px] leading-[1.4] text-foreground outline-none placeholder:text-muted-foreground focus:border-brand/50 focus:ring-2 focus:ring-brand/20"})]}),jsxs("div",{className:"flex justify-end gap-2",children:[jsx(fe,{variant:"neutral",disabled:r,onClick:o,children:"Cancel"}),jsx(fe,{type:"submit",variant:"brand",disabled:r,children:r?"Starting\u2026":"Start run"})]})]})]})}function dc(){let{state:e,actions:t}=G();return e.annotation?e.annotation.status==="resolved"?jsxs(fe,{variant:"neutral",disabled:e.busy,onClick:()=>t.reopen(),children:[jsx(F,{name:"refresh",size:12}),"Reopen"]}):jsxs(fe,{variant:"neutral",disabled:e.busy,onClick:()=>t.markResolved(),children:[jsx(F,{name:"check",size:12}),"Resolve"]}):null}var Wr=createContext({expanded:false,onToggleExpand:()=>{}});function Ei(){return use(Wr)}function Ri(){let{state:e,meta:t}=G(),{expanded:r,onToggleExpand:n}=Ei(),o=e.annotation,s=we[t.viewport],i=o?.payload.selectedText;return jsxs("div",{className:"relative z-10 flex flex-col gap-2.5 border-b border-black/[0.07] bg-neutral-100/60 px-4 py-3",children:[jsxs("div",{className:"flex items-center justify-between gap-3",children:[jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[jsx("span",{title:t.targetLabel,className:"min-w-0 overflow-hidden text-ellipsis whitespace-nowrap text-[12.5px] font-medium text-foreground",children:t.targetLabel}),jsx(Re,{text:Ke(t.viewport),placement:"bottom",children:jsx("span",{"data-patch-thread-viewport":t.viewport,role:"img","aria-label":Ke(t.viewport),className:"inline-flex shrink-0 items-center text-brand",children:jsx(F,{name:s.glyph,size:15,stroke:1.8})})})]}),jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.isResolved?jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-brand-green px-2 py-[3px] text-[11px] font-medium text-white",children:[jsx(F,{name:"check",size:10})," Resolved"]}):null,jsxs("div",{className:"ml-0.5 flex items-center gap-0.5",children:[jsx(fc,{}),jsx(He,{onClick:n,title:r?"Collapse":"Expand",children:jsx(F,{name:r?"minimize":"maximize",size:13})}),jsx(gc,{})]})]})]}),i?jsx("div",{className:"rounded-xl bg-white px-3 py-2 shadow-[0_0_0_1px_rgba(0,0,0,0.06)]",children:jsx("div",{className:"border-l-[2.5px] border-black/16 pl-2.5 text-[12.5px] leading-[1.45] text-muted-foreground",children:i.length>200?`${i.slice(0,199).trim()}\u2026`:i})}):null]})}function gc(){let{actions:e}=G();return jsx(He,{onClick:e.requestClose,title:"Close",children:jsx(F,{name:"x",size:14})})}function fc(){let{state:e,actions:t}=G(),[r,n]=useState(false);return e.canDeleteAnnotation?jsxs("div",{className:"relative",children:[jsx(He,{title:"Annotation actions","aria-label":"Annotation actions","aria-expanded":r,"aria-haspopup":"menu",onClick:()=>n(o=>!o),children:jsx(F,{name:"more",size:14})}),r?jsx("div",{role:"menu",className:"patch-fade-in absolute top-full right-0 z-[5] mt-1 min-w-40 rounded-xl bg-popover p-1 shadow-dialog ring-1 ring-black/6",children:jsxs("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-[12.5px] font-medium text-destructive hover:bg-destructive/10 focus:bg-destructive/10 focus:outline-none",onClick:()=>{n(false),t.requestDeleteAnnotation();},children:[jsx(F,{name:"trash",size:13}),"Delete annotation"]})}):null]}):null}function _i(){let{state:e,actions:t,meta:r}=G(),n=useRef(null),o=r.viewer.kind==="client"?r.viewer.generatedSeed:null,s=r.viewer.kind==="client"?r.viewer.authorId:null;return useEffect(()=>{let a=n.current;a&&(a.scrollTop=a.scrollHeight);}),e.threadVisible?jsxs("div",{ref:n,"data-patch-thread-scroller":"",className:M("flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto bg-white px-4 pt-3.5 pb-3",e.showDevFooter&&e.isResolved&&"relative z-[1] rounded-b-[22px] shadow-[0_6px_12px_-5px_rgba(0,0,0,0.16)]"),children:[e.annotation?jsx(Pi,{name:e.annotation.authorName??"Someone",createdAt:e.annotation.createdAt,content:e.annotation.payload.comment,authorKey:e.annotation.payload.authorId??e.annotation.authorName??e.annotation.id,avatarSrc:e.annotation.authorImage,generatedSeed:e.annotation.payload.authorRole==="client"&&e.annotation.payload.authorId===s?o:e.annotation.authorAvatarSeed??e.annotation.payload.authorId??null,deliveryStatus:e.annotation.deliveryStatus,onRetry:e.annotation.deliveryStatus==="failed"?t.retryInitialMessage:void 0}):null,e.messages.map(a=>jsx(Pi,{name:a.authorName??a.role,createdAt:a.createdAt,content:a.content,authorKey:a.authorId??a.authorName??a.role,avatarSrc:a.authorImage,generatedSeed:a.role==="client"&&a.authorId===s?o:a.authorAvatarSeed??a.authorId,deliveryStatus:a.deliveryStatus,canDelete:t.canDeleteMessage(a),onDelete:()=>t.requestDeleteMessage(a),onRetry:a.deliveryStatus==="failed"?()=>{t.retryMessage(a.id);}:void 0},a.id))]}):null}function Pi(e){let t=tt(e.name),r=rt(e.authorKey),n=e.deliveryStatus==="failed";return jsxs("div",{className:"group/message flex gap-2.5",children:[jsx(Oe,{initials:t,tint:r,src:e.avatarSrc,generatedSeed:e.generatedSeed,alt:e.name}),jsxs("div",{className:"relative min-w-0 flex-1 pr-8",children:[jsxs("div",{className:"flex items-baseline gap-1.5",children:[jsx("span",{className:"text-[12.5px] font-medium text-foreground",children:e.name}),jsx("span",{className:"text-[11px] text-muted-foreground",children:jt(e.createdAt)})]}),e.canDelete&&e.onDelete?jsx(xc,{onDelete:e.onDelete}):null,jsx("p",{className:"mt-0.5 whitespace-pre-wrap text-[13px] leading-[1.45] text-foreground",children:e.content}),n?jsxs("div",{className:"mt-1 flex items-center gap-2 text-[11px] leading-none",children:[jsx("span",{className:"text-destructive",children:"Failed to send"}),e.onRetry?jsx("button",{type:"button",onClick:e.onRetry,className:"rounded-full bg-black/8 px-2 py-1 font-medium text-foreground transition-colors hover:bg-black/12",children:"Retry"}):null]}):null]})]})}var bc=44,vc=8;function xc({onDelete:e}){let[t,r]=useState(false),[n,o]=useState("down"),s=useRef(null),i=useCallback(()=>{let l=s.current,c=l?.closest("[data-patch-thread-scroller]");if(!l||!c){o("down");return}let d=l.getBoundingClientRect(),m=c.getBoundingClientRect(),u=m.bottom-d.bottom,h=d.top-m.top;o(u<bc+vc&&h>u?"up":"down");},[]),a=useCallback(()=>{r(l=>{let c=!l;return c&&i(),c});},[i]);return jsxs("div",{className:"absolute top-[-5px] right-0 opacity-0 transition-opacity group-focus-within/message:opacity-100 group-hover/message:opacity-100",children:[jsx(He,{ref:s,size:"sm",title:"Message actions","aria-label":"Message actions","aria-expanded":t,"aria-haspopup":"menu",onClick:a,children:jsx(F,{name:"more",size:14})}),t?jsx("div",{role:"menu",className:M("patch-fade-in absolute right-0 z-[5] min-w-36 rounded-xl bg-popover p-1 shadow-dialog ring-1 ring-black/6",n==="up"?"bottom-full mb-1":"top-full mt-1"),children:jsxs("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-[12.5px] font-medium text-destructive hover:bg-destructive/10 focus:bg-destructive/10 focus:outline-none",onClick:()=>{r(false),e();},children:[jsx(F,{name:"trash",size:13}),"Delete"]})}):null]})}var wc={default:"w-full min-h-[60px] resize-y rounded-2xl border border-border bg-popover px-3 py-2 text-[13px] leading-[1.45] text-foreground outline-none transition-colors placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",bare:"w-full resize-none self-center overflow-y-auto bg-transparent border-0 outline-none text-[13px] leading-normal text-foreground placeholder:text-muted-foreground"};function Di({variant:e="default",className:t,ref:r,...n}){return jsx("textarea",{ref:r,className:M(wc[e],t),...n})}var Ac=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Li="w-full rounded-[10px] border border-border bg-popover px-2 py-2 text-[13px] text-foreground outline-none transition-colors focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring";function Oi(){let{actions:e}=G(),[t,r]=useState(""),[n,o]=useState(""),[s,i]=useState(null),[a,l]=useState(false),c=useRef(null);return useEffect(()=>{setTimeout(()=>c.current?.focus(),0);},[]),jsxs("form",{onSubmit:async m=>{m.preventDefault();let u=t.trim(),h=n.trim();if(!u){i("Name is required.");return}if(!Ac.test(h)){i("Enter a valid email.");return}i(null),l(true);let v=await e.setIdentity({name:u,email:h});l(false),v||i("Could not save identity. Try again.");},className:"flex flex-col gap-2",children:[jsx("div",{className:"text-xs text-muted-foreground",children:"Tell us who you are so the team can reply."}),jsx("input",{ref:c,type:"text",placeholder:"Name",value:t,onChange:m=>r(m.target.value),className:Li}),jsx("input",{type:"email",placeholder:"Email",value:n,onChange:m=>o(m.target.value),className:Li}),s?jsx("div",{className:"text-xs text-destructive",children:s}):null,jsx("button",{type:"submit",disabled:a,className:M("self-end rounded-[10px] bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90",a&&"cursor-not-allowed opacity-60"),children:a?"Saving\u2026":"Continue"})]})}function Hi(){let{state:e,actions:t,meta:r}=G(),n=useRef(null),[o,s]=useState(false);if(useEffect(()=>{e.needsIdentity||setTimeout(()=>n.current?.focus(),0);},[e.needsIdentity]),useEffect(()=>{let u=n.current;if(!u)return;u.style.height="0px";let h=Math.min(u.scrollHeight,140);u.style.height=`${h}px`,s(h>28);},[e.draftText]),e.isResolved||e.initialMessageLocked)return null;if(e.needsIdentity)return jsx("div",{className:M("bg-white px-4 py-3",e.threadVisible&&"border-t border-black/6"),children:jsx(Oi,{})});let i=e.draftText.trim().length>0,a=r.viewer.name,l=tt(a),c=r.viewer.kind==="studio"?"var(--color-foreground)":rt(r.viewer.avatarKey),d=u=>{u.preventDefault(),t.submit();},m=u=>{u.key==="Enter"&&!u.shiftKey&&(u.preventDefault(),t.submit());};return jsx("form",{onSubmit:d,className:M("bg-white p-3",e.threadVisible&&"border-t border-black/6",e.showDevFooter&&"relative z-[1] rounded-b-[22px] shadow-[0_6px_12px_-5px_rgba(0,0,0,0.16)]"),children:jsxs("div",{className:M("flex items-end gap-2 bg-black/4 px-3 py-2.5 transition-colors",o?"rounded-[18px]":"rounded-full"),children:[jsx(Oe,{initials:l,tint:c,src:r.viewer.avatarSrc,generatedSeed:r.viewer.generatedSeed,alt:a??"",className:"self-start"}),jsx(Di,{ref:n,variant:"bare",value:e.draftText,onChange:u=>t.setDraftText(u.target.value),onKeyDown:m,rows:1,placeholder:e.annotation?"Reply\u2026":"What should change?",style:{maxHeight:"140px"}}),jsx(Rc,{enabled:i})]})})}function Rc({enabled:e}){return jsx("button",{type:"submit",disabled:!e,"aria-label":"Send",className:M("grid size-7 shrink-0 place-items-center rounded-full text-white",e?"pkey pkey-brand":"bg-black/16 transition-colors"),children:jsx(F,{name:"arrow-up",size:13})})}var _c=440,Vi=88,cr=16,Dc=[.22,.61,.36,1],Lc=[.4,0,.2,1],Oc={x:-8,y:-8,origin:"top left"},Bi=200;function Wi(e,t,r){return Math.max(t,Math.min(r,e))}function Ui(e,t,r){let n={x:e.x+e.width/2,y:e.y+e.height/2},o={x:t.x+t.width/2,y:t.y+r/2};return {x:Wi((n.x-o.x)*.08,-12,12),y:Wi((n.y-o.y)*.12,-10,10),origin:`${n.y<o.y?"top":"bottom"} ${n.x<o.x?"left":"right"}`}}function zc(e,t){if(!t)return Oc;let r=xt({anchor:t,popover:{width:332,height:Bi},viewport:e.getOverlayViewport()});return Ui(t,r,Bi)}function Hc(e,t){return e.x===t.x&&e.y===t.y&&e.origin===t.origin}function Xi({getAnchorRect:e,initialAnchorRect:t,expanded:r,entryDelay:n=0,onToggleExpand:o,children:s}){let{actions:{attemptClose:i},meta:{shakeNonce:a}}=G(),l=ce(),c=useRef(null),[d,m]=useState(600),[u,h]=useState(()=>zc(l,t??e())),v=useCallback(()=>{let g=c.current;if(!g||r)return;let p=e();if(!p)return;let b=g.offsetHeight||200,C=xt({anchor:p,popover:{width:332,height:b},viewport:l.getOverlayViewport()});g.style.left=`${C.x}px`,g.style.top=`${C.y}px`,g.style.right="auto";let A=Ui(p,C,b);h(f=>Hc(f,A)?f:A);},[e,r,l]);useLayoutEffect(()=>{r||v(),m(l.getOverlayViewport().height-cr-Vi);}),useEffect(()=>{let g=null,p=()=>{g===null&&(g=l.overlayWindow.requestAnimationFrame(()=>{g=null,r||v(),m(l.getOverlayViewport().height-cr-Vi);}));},b=new Set([l.targetWindow,l.overlayWindow]);for(let A of b)A.addEventListener("resize",p),A.addEventListener("scroll",p,{passive:true});let C=gn(l.overlayWindow,p);return C.observe(l.overlayDocument.body),l.targetDocument.body!==l.overlayDocument.body&&C.observe(l.targetDocument.body),c.current&&C.observe(c.current),()=>{g!==null&&l.overlayWindow.cancelAnimationFrame(g);for(let A of b)A.removeEventListener("resize",p),A.removeEventListener("scroll",p);C.disconnect();}},[v,r,l]),useEffect(()=>{let g=C=>{Co(C)||i();},p=C=>{C.key==="Escape"&&i();},b=new Set([l.targetDocument,l.overlayDocument]);for(let C of b)C.addEventListener("mousedown",g,true),C.addEventListener("keydown",p);return ()=>{for(let C of b)C.removeEventListener("mousedown",g,true),C.removeEventListener("keydown",p);}},[i,l]);let x=useRef(a);useEffect(()=>{if(a===x.current)return;x.current=a;let g=c.current;g&&(g.classList.remove("patch-shake"),g.offsetWidth,g.classList.add("patch-shake"));},[a]);let T={left:"auto",right:`${cr}px`,top:`${cr}px`,width:`${_c}px`,height:`${d}px`},w={width:`${332}px`,height:"auto",transformOrigin:u.origin};return jsx(motion.div,{ref:c,layout:true,initial:{opacity:0,x:u.x,y:u.y,scale:.985},animate:{opacity:1,x:0,y:0,scale:1,transition:{type:"spring",stiffness:560,damping:34,mass:.7,delay:n}},exit:{opacity:0,x:u.x,y:u.y,scale:.985,transition:{duration:.16,ease:Lc}},transition:{layout:{duration:.42,ease:Dc}},onLayoutAnimationComplete:v,"data-patch-popover":"",role:"dialog","aria-label":"Annotation thread",className:"fixed z-[2147483646] flex flex-col overflow-hidden rounded-[22px] border border-black/6 bg-popover font-sans text-popover-foreground shadow-[0_20px_56px_-16px_rgba(0,0,0,0.2),0_8px_18px_-6px_rgba(0,0,0,0.08)]",style:r?T:w,children:jsx(Wr.Provider,{value:{expanded:r,onToggleExpand:o},children:s})})}var le={Root:Xi,Header:Ri,Messages:_i,Reply:Hi,DevFooter:Ti,ConfirmDiscard:Si,ConfirmDelete:Ci};function Gi({getAnchorRect:e,initialAnchorRect:t,expanded:r,entryDelay:n,onToggleExpand:o}){return jsxs(le.Root,{getAnchorRect:e,initialAnchorRect:t,expanded:r,entryDelay:n,onToggleExpand:o,children:[jsx(le.Header,{}),jsx(le.Messages,{}),jsx(le.Reply,{}),jsx(le.ConfirmDiscard,{}),jsx(le.ConfirmDelete,{})]})}function Ki({getAnchorRect:e,initialAnchorRect:t,expanded:r,entryDelay:n,onToggleExpand:o}){return jsxs(le.Root,{getAnchorRect:e,initialAnchorRect:t,expanded:r,entryDelay:n,onToggleExpand:o,children:[jsx(le.Header,{}),jsx(le.Messages,{}),jsx(le.Reply,{}),jsx(le.DevFooter,{}),jsx(le.ConfirmDiscard,{}),jsx(le.ConfirmDelete,{})]})}var Uc="data-patch-internal";function ji(e,t,r){let n={viewportX:t,viewportY:r},o=nt(n,e.getOverlayViewport());return Zt(n,o)}function Xc(e,t){return e.overlayDocument.querySelector("patch-widget-root")?.shadowRoot?.querySelector(t)??null}function Gc(e,t){let r=Xc(e,`[data-patch-pin-id="${t}"]`);if(!r)return null;let n=r.getBoundingClientRect();return {x:n.x,y:n.y,width:n.width,height:n.height}}function Kc(e,t){if(!t)return null;let r=Vo({payload:t.payload,doc:e.targetDocument,scrollY:e.getTargetScrollY(),viewport:e.getTargetViewport(),internalAttr:Uc}),n=e.targetPointToOverlay(r.position);return ji(e,n.viewportX,n.viewportY)}function Zi(e,t,r){if(!t)return null;if(t.kind==="existing")return Gc(e,t.annotationId)??Kc(e,r);let n=e.targetPointToOverlay({viewportX:t.anchor.viewportX,viewportY:t.anchor.documentY-e.getTargetScrollY()});return ji(e,n.viewportX,n.viewportY)}function Ji(){let e=xe(),t=re(),r=ce(),n=e.active,o=useMemo(()=>!n||n.kind!=="existing"?null:t.annotations.find(v=>v.id===n.annotationId)??null,[n,t.annotations]),s=useCallback(()=>Zi(r,n,o),[n,o,r]),[i,a]=useState(false),l=e.active?e.active.kind==="existing"?e.active.annotationId:"composer":null;useEffect(()=>{a(false);},[l]);let c=t.viewerKind==="studio"?Ki:Gi,d=n&&(n.kind==="composer"||!!o),m=n?.kind==="composer"?.04:0,u=n?.kind==="composer"?li(n.target):null,h=useMemo(()=>Zi(r,n,o),[n,o,r]);return jsx(AnimatePresence,{children:d?jsx(yi,{annotation:o,draftTargetLabel:u,children:jsx(c,{getAnchorRect:s,initialAnchorRect:h,expanded:i,entryDelay:m,onToggleExpand:()=>a(v=>!v)})},"active-popover"):null})}var jc="https://app.usepatch.dev";function Jc({children:e}){let{active:t}=re();return t?e:null}function Qi(e){let t=typeof window<"u"&&mn(window),r=useMemo(()=>uo({prop:e.projectToken,processEnv:mo(),importMetaEnv:po()}),[e.projectToken]),n=e.apiBase??jc;return useEffect(()=>{r||console.warn(co);},[r]),t||!r?null:jsx(Jo,{children:jsx(fn,{children:jsx(Cn,{projectToken:r,apiBase:n,children:jsx(Jc,{children:jsx(Sn,{children:jsx(lo,{children:jsx(io,{projectToken:r,children:jsxs(eo,{children:[jsx(Go,{}),jsx(Ji,{}),jsx(qo,{}),jsx(Oo,{})]})})})})})})})})}var Qc=Qi;
2000
- export{Qi as Patch,Qc as default};
2018
+ `;var Zo="patch-widget-root";function Jo({children:e}){let[t,r]=useState(null),n=useRef(null);return useEffect(()=>{if(typeof document>"u")return;let o=document.querySelector(Zo);o||(o=document.createElement(Zo),o.setAttribute("data-patch-internal",""),document.body.appendChild(o)),n.current=o;let a=o.shadowRoot??o.attachShadow({mode:"open"});if(!a.querySelector("style[data-patch-css]")){let s=document.createElement("style");s.setAttribute("data-patch-css",""),s.textContent=jo,a.appendChild(s);}let i=a.querySelector("div[data-patch-mount]");return i||(i=document.createElement("div"),i.setAttribute("data-patch-mount",""),a.appendChild(i)),r(i),()=>{}},[]),t?createPortal(e,t):null}var Ll=/[\s#.:[\]()>+~,\\]/;function Ol(e){return !(!e||Ll.test(e)||/^\d/.test(e))}function zl(e){let t=1,r=e.previousElementSibling,n=e.tagName;for(;r;)r.tagName===n&&t++,r=r.previousElementSibling;return t}function Qo(e,t,r){try{let n=e.querySelectorAll(t);return n.length===1&&n[0]===r}catch{return false}}function $l(e,t){return e.id&&Ol(e.id)&&(!t||Qo(t,`#${e.id}`,e))?`#${e.id}`:`${e.tagName.toLowerCase()}:nth-of-type(${zl(e)})`}function ei(e,t){if(!e.tagName)return "";let r=e.ownerDocument??null,n=[],o=e,a=0;for(;o&&a<12;){let i=$l(o,r);if(n.unshift(i),i.startsWith("#"))break;let s=n.join(" > ");if(r&&Qo(r,s,e))return s;if(o.tagName.toLowerCase()==="html")break;o=o.parentElement,a++;}return n.join(" > ")}var Hl=80,Fl=500;function ri(e){return e!==null&&typeof e=="object"}function Vl(e){return ri(e)?"return"in e||"type"in e||"elementType"in e||"_debugOwner"in e:false}function cr(e){if(typeof e=="function")return e.displayName||e.name||null;if(!ri(e))return null;let t=e.displayName;if(typeof t=="string"&&t)return t;let r=cr(e.render);if(r)return r;let n=cr(e.type);return n||null}function ni(e){return e.replace(/\s+/g," ").trim()}function oi(e,t){return e.length<=t?e:`${e.slice(0,t-1).trim()}\u2026`}function Bl(e){let t=ni(e).replace(/[<>]/g,"");return !t||/^[a-z]/.test(t)?null:oi(t,Hl)}function Wl(e){let t=cr(e.elementType)??cr(e.type);return t?Bl(t):null}function ti(e){return oi(ni(e),Fl)}function Yl(e){let t=e.replace(/\\/g,"/");return t.includes("/.next/")||t.includes("/node_modules/next/")||t.includes("/node_modules/react/")||t.includes("/node_modules/react-dom/")||t.includes("/node_modules/react-router/")||t.includes("/node_modules/react-router-dom/")||t.includes("/node_modules/@remix-run/")||t.includes("/node_modules/.vite/")||/(^|\/)next\/dist\//.test(t)}function Ul(e){let t=e.replace(/^webpack:\/\/[^/]+\//,"").replace(/^file:\/\//,"").replace(/\\/g,"/").replace(/\/\.\//g,"/").replace(/^\.\//,"");for(let n of ["/apps/","/packages/","/src/"]){let o=t.lastIndexOf(n);if(o>=0)return ti(t.slice(o+1))}let r=t.split("/").filter(Boolean);return ti(r.slice(-3).join("/"))}function Xl(e){let t=e._debugSource?.fileName;return typeof t!="string"||!t.trim()||Yl(t)?null:Ul(t)}function Gl(e){let t=e;for(let r of Object.getOwnPropertyNames(e)){if(!r.startsWith("__reactFiber$")&&!r.startsWith("__reactInternalInstance$"))continue;let n=t[r];if(Vl(n))return n}return null}function $r(e){let t=Gl(e);if(!t)return null;let r=[],n=null,o=0;for(;t&&o<30;){let s=Wl(t),c=s?Er(s):false;s&&!c&&r[r.length-1]!==s&&r.push(s),c||(n??=Xl(t)),t=t.return??t._debugOwner??null,o+=1;}let a=r.length>0?fo(r.reverse().map(s=>`<${s}>`).join(" ")):null,i={};return a&&(i.reactComponents=a),n&&(i.sourceFile=n),Object.keys(i).length>0?i:null}var ii=500,ai=3;function Kl(e){return e.length<=ii?e:e.slice(0,ii)}function Hr(e){return {viewportX:e.viewportX,viewportY:e.viewportY,documentY:e.viewportY+e.scrollY,isFixed:false}}function dr(e){return {x:e.x,y:e.y,width:e.width,height:e.height}}function si(e){let t={cssSelector:ei(e)},r=Ft(e);r&&(t.textSignature=r);let n=Ht(e);return Object.keys(n).length>0&&(t.attributeSignature=n),t}function li(e){return e.kind==="element"?xt(e.element,e.selectedText):e.kind==="multi"?Wt(e.elements.length):Yt()}function ci(e){let{target:t,click:r,comment:n,url:o}=e,a=t.element,i=t.rect,s=Pn(a),c=Mn(a),l=Ue(a),d=_n(a),p=$r(a),u={comment:n,element:vt(a),elementPath:Nn(a),targetLabel:xt(a,t.selectedText),timestamp:Date.now(),url:Ne(o),kind:"feedback",coordinates:Hr(r),boundingBox:dr(i),domHints:si(a)};return t.selectedText&&(u.selectedText=Kl(t.selectedText)),c&&(u.nearbyText=c),l.length>0&&(u.cssClasses=l),d.length>0&&(u.nearbyElements=d),s&&(u.accessibility=s),p?.reactComponents&&(u.reactComponents=p.reactComponents),p?.sourceFile&&(u.sourceFile=p.sourceFile),u}function di(e){let{target:t,click:r,comment:n,url:o}=e,a=t.elements.slice(0,ai).map(d=>vt(d)),i=t.elements.length>ai?"\u2026":"",s=`${t.elements.length} elements: ${a.join(", ")}${i}`,c=t.elements[0],l=c?$r(c):null;return {comment:n,element:s,elementPath:s,targetLabel:Wt(t.elements.length),timestamp:Date.now(),url:Ne(o),kind:"feedback",coordinates:Hr(r),boundingBox:dr(t.union),isMultiSelect:true,elementBoundingBoxes:t.rects.map(dr),...l?.reactComponents?{reactComponents:l.reactComponents}:{},...l?.sourceFile?{sourceFile:l.sourceFile}:{},...c?{domHints:si(c)}:{}}}function ui(e){let{target:t,click:r,comment:n,url:o}=e,a=Math.round(t.rect.width),i=Math.round(t.rect.height),s=Math.round(t.rect.x),c=Math.round(t.rect.y);return {comment:n,element:`region ${a}\xD7${i}`,elementPath:`region at (${s}, ${c}) ${a}\xD7${i}`,targetLabel:Yt(),timestamp:Date.now(),url:Ne(o),kind:"feedback",coordinates:Hr(r),boundingBox:dr(t.rect)}}async function Tt(e,t){return e.kind==="composer"?t.createAnnotation(e.payload):t.reply(e.annotationId,{content:e.content})}async function pi(e,t){return t.resolve(e)}async function mi(e,t){return t.deleteAnnotation(e)}async function gi(e,t){return t.deleteMessage(e.annotationId,e.messageId)}async function fi(e,t){return e.viewerKind!=="studio"?null:t.reopen(e.annotationId)}async function hi(e,t){return e.viewerKind!=="studio"?null:t.kickoff(e.annotationId,{guidance:e.guidance})}async function bi(e,t){return t.postIdentity(e)}var wi=createContext(null),xi=0;function Vr(e){return xi+=1,`${e}-${Date.now().toString(36)}-${xi}`}function Br(e){return e.deliveryStatus==="sending"||e.deliveryStatus==="failed"}function yi({annotation:e,draftTargetLabel:t,children:r}){let n=re(),o=xe(),a=ce(),[i,s]=useState(false),[c,l]=useState(null),[d,p]=useState(null),u=useRef(false),m=e?.thread??[],h=e?.latestRun??null,v=e?.status==="resolved",w=e?Br(e):false,x=n.viewerKind,b=useCallback(()=>x==="studio"?{role:"studio",authorId:n.studio?.userId??null,authorName:n.studio?.name??null,authorImage:n.studio?.image??null}:{role:"client",authorId:n.identity?.clientUserId??null,authorName:n.identity?.name??null,authorImage:null},[n.identity,n.studio,x]),g=useMemo(()=>b(),[b]),k=!!e&&e.deliveryStatus!=="sending"&&e.deliveryStatus!=="failed"&&!!g.authorId&&e.payload.authorRole===g.role&&e.payload.authorId===g.authorId,z=useCallback(T=>{let L=b();return {id:Vr("tmp-msg"),role:L.role,authorId:L.authorId,authorName:L.authorName,authorImage:L.authorImage,content:T,createdAt:new Date().toISOString(),deliveryStatus:"sending"}},[b]),N=useCallback(async T=>{if(u.current)return Promise.reject(new Error("busy"));u.current=true,s(true);try{return await T()}finally{u.current=false,s(false);}},[]),f=useCallback(async()=>{let T=o.draftText.trim();if(!T)return;if(e){if(v||Br(e))return;let gt=z(T);o.setDraftText(""),n.updateAnnotation(e.id,Le=>({...Le,thread:[...Le.thread,gt]}));let Xr=await Tt({kind:"reply",annotationId:e.id,content:T},n.apiClient);if(Xr){n.updateAnnotation(e.id,Le=>({...Le,thread:Le.thread.map(We=>We.id===gt.id?{...We,id:Xr.id,deliveryStatus:"sent"}:We)})),n.refresh();return}n.updateAnnotation(e.id,Le=>({...Le,thread:Le.thread.map(We=>We.id===gt.id?{...We,deliveryStatus:"failed"}:We)}));return}let L=o.active;if(!L||L.kind!=="composer")return;let V=L.target,B={viewportX:L.anchor.viewportX,viewportY:L.anchor.viewportY,scrollY:L.anchor.documentY-L.anchor.viewportY},Y=a.getPageUrl(),mr=jr(n.activeViewport,a.getTargetViewport()),O=V.kind==="element"?ci({target:V,click:B,comment:T,url:Y}):V.kind==="multi"?di({target:V,click:B,comment:T,url:Y}):ui({target:V,click:B,comment:T,url:Y});O.viewport=n.activeViewport,O.viewportSize=mr;let ie=b(),Te=Vr("tmp-ann");n.applyAnnotationUpdate({id:Te,status:"pending",resolvedBy:null,resolvedAt:null,createdAt:new Date().toISOString(),authorName:ie.authorName,authorImage:ie.authorImage,payload:{...O,authorRole:ie.role,authorId:ie.authorId},thread:[],latestRun:null,deliveryStatus:"sending"}),o.setDraftText(""),o.openExisting(Te);let gr=await Tt({kind:"composer",payload:O},n.apiClient);if(gr){n.replaceAnnotationId(Te,gr.id),o.openExisting(gr.id),n.refresh();return}n.updateAnnotation(Te,gt=>({...gt,deliveryStatus:"failed"}));},[e,b,v,z,n,o,a]),E=useCallback(async T=>{if(!e||Br(e))return;let L=e.thread.find(B=>B.id===T);if(!L||L.deliveryStatus!=="failed")return;n.updateAnnotation(e.id,B=>({...B,thread:B.thread.map(Y=>Y.id===T?{...Y,deliveryStatus:"sending"}:Y)}));let V=await Tt({kind:"reply",annotationId:e.id,content:L.content},n.apiClient);if(V){n.updateAnnotation(e.id,B=>({...B,thread:B.thread.map(Y=>Y.id===T?{...Y,id:V.id,deliveryStatus:"sent"}:Y)})),n.refresh();return}n.updateAnnotation(e.id,B=>({...B,thread:B.thread.map(Y=>Y.id===T?{...Y,deliveryStatus:"failed"}:Y)}));},[e,n]),Q=useCallback(async()=>{if(!e||e.deliveryStatus!=="failed")return;let T=e.id;n.updateAnnotation(T,V=>({...V,deliveryStatus:"sending"}));let L=await Tt({kind:"composer",payload:e.payload},n.apiClient);if(L){n.replaceAnnotationId(T,L.id),o.openExisting(L.id),n.refresh();return}n.updateAnnotation(T,V=>({...V,deliveryStatus:"failed"}));},[e,n,o]),Z=useCallback(T=>!g.authorId||T.deliveryStatus&&T.deliveryStatus!=="sent"?false:T.role===g.role&&T.authorId===g.authorId,[g]),be=useCallback(()=>{k&&(l(null),p({kind:"annotation"}));},[k]),pe=useCallback(T=>{Z(T)&&(l(null),p({kind:"message",messageId:T.id}));},[Z]),oe=useCallback(()=>{l(null),p(null);},[]),ee=useCallback(async T=>{if(!e)return false;let L=e.thread;return N(async()=>(l(null),n.updateAnnotation(e.id,B=>({...B,thread:B.thread.filter(Y=>Y.id!==T)})),await gi({annotationId:e.id,messageId:T},n.apiClient)?(n.refresh(),true):(n.updateAnnotation(e.id,B=>({...B,thread:L})),l("Couldn't delete message. Try again."),false)))},[e,n,N]),X=useCallback(async()=>!e||!k?false:N(async()=>(l(null),await mi(e.id,n.apiClient)?(n.updateAnnotation(e.id,()=>null),o.forceClose(),n.refresh(),true):(l("Couldn't delete annotation. Try again."),false))),[e,k,n,o,N]),C=useCallback(async()=>{if(d)try{(d.kind==="annotation"?await X():await ee(d.messageId))&&p(null);}catch{l("Couldn't delete. Try again.");}},[d,X,ee]),I=useCallback(async()=>{e&&await N(async()=>{l(null);let T={status:e.status,resolvedBy:e.resolvedBy,resolvedAt:e.resolvedAt,optimisticAction:e.optimisticAction};if(n.updateAnnotation(e.id,V=>({...V,status:"resolved",resolvedBy:"dev",resolvedAt:new Date().toISOString(),optimisticAction:"resolve-pending"})),!await pi(e.id,n.apiClient)){n.updateAnnotation(e.id,V=>({...V,...T})),l("Couldn't resolve. Try again.");return}n.refresh();});},[e,n,N]),M=useCallback(async()=>{e&&await N(async()=>{l(null);let T={status:e.status,resolvedBy:e.resolvedBy,resolvedAt:e.resolvedAt,optimisticAction:e.optimisticAction};if(n.updateAnnotation(e.id,V=>({...V,status:"pending",resolvedBy:null,resolvedAt:null,optimisticAction:"reopen-pending"})),!await fi({annotationId:e.id,viewerKind:x},n.apiClient)){n.updateAnnotation(e.id,V=>({...V,...T})),l("Couldn't reopen. Try again.");return}n.refresh();});},[e,x,n,N]),A=useCallback(async T=>{e&&await N(async()=>{l(null);let L=e.latestRun,V=e.optimisticAction;n.updateAnnotation(e.id,Y=>({...Y,latestRun:{id:Vr("tmp-run"),status:"queued",prUrl:null,createdAt:new Date().toISOString(),completedAt:null,prClosedUnmerged:false},optimisticAction:"run-pending"}));let B=await hi({annotationId:e.id,viewerKind:x,guidance:T},n.apiClient);if(!B?.ok){n.updateAnnotation(e.id,Y=>({...Y,latestRun:L,optimisticAction:V})),l(B?.error??"Couldn't start Patch. Try again.");return}n.refresh();});},[e,x,n,N]),D=useCallback(async T=>{let L=await bi({...T,avatarSeed:n.clientAvatarSeed},n.apiClient);return L&&await n.setIdentity(L),L},[n]),S=x==="client"&&!n.identity&&m.length===0,te=!!e||m.length>0,me=n.agentRunReadiness?.ready??true,P=n.agentRunReadiness?.message??null,_=useCallback(()=>{if(o.draftText.trim().length>0){o.setConfirmDiscardOpen(true);return}o.forceClose();},[o]),F=e?zn(e.payload):t||"annotation",q=e?.payload.viewport??n.activeViewport,Se=n.studio?n.studio.name:n.identity?.name??null,ge=n.identity?.avatarSeed??n.clientAvatarSeed,Be=n.studio?.userId??ge,Nt=n.studio?.image??null,Mt=n.studio?.userId??ge,pr=useMemo(()=>({state:{annotation:e,messages:m,runState:h,draftText:o.draftText,busy:i,actionError:c,confirmDiscardOpen:o.confirmDiscardOpen,confirmDelete:d,showDevFooter:x==="studio",agentRunReady:me,agentRunSetupMessage:P,needsIdentity:S,isResolved:v,initialMessageLocked:w,threadVisible:te,canDeleteAnnotation:k},actions:{setDraftText:o.setDraftText,submit:f,retryMessage:E,retryInitialMessage:Q,requestDeleteAnnotation:be,requestDeleteMessage:pe,canDeleteMessage:Z,cancelDelete:oe,confirmDelete:C,markResolved:I,reopen:M,runPatch:A,setIdentity:D,attemptClose:o.attemptClose,requestClose:_,forceClose:o.forceClose,setConfirmDiscardOpen:o.setConfirmDiscardOpen},meta:{targetLabel:F,viewport:q,shakeNonce:o.shakeNonce,viewer:{kind:x,authorId:g.authorId,name:Se,avatarKey:Be,avatarSrc:Nt,generatedSeed:Mt}}}),[e,m,h,o.draftText,o.confirmDiscardOpen,o.setDraftText,o.attemptClose,o.forceClose,o.setConfirmDiscardOpen,o.shakeNonce,i,c,d,f,E,Q,be,pe,Z,oe,C,I,M,A,D,x,me,P,S,v,w,te,k,_,F,q,g.authorId,Se,Be,Nt,Mt]);return jsx(wi.Provider,{value:pr,children:r})}function K(){let e=use(wi);if(!e)throw new Error("useThreadContext must be used inside <ThreadProvider>");return e}var ec="inline-flex shrink-0 items-center justify-center gap-1.5 h-8 px-3.5 rounded-lg whitespace-nowrap text-[13px] font-semibold transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none",tc={brand:"pkey pkey-brand text-white",brandTint:"bg-brand-tint text-brand hover:bg-brand-tint/70",destructive:"pkey pkey-destructive text-white",destructiveTint:"bg-destructive/10 text-destructive hover:bg-destructive/15",successTint:"bg-brand-green/10 text-brand-green hover:bg-brand-green/15",warn:"pkey pkey-warn text-white",warnTint:"bg-brand-orange/10 text-brand-orange hover:bg-brand-orange/15",neutral:"pkey pkey-outline text-foreground",subtle:"bg-black/8 text-muted-foreground"};function Et(e="brand",t){return R(ec,tc[e],t)}function fe({variant:e="brand",className:t,type:r="button",ref:n,...o}){return jsx("button",{ref:n,type:r,className:Et(e,t),...o})}function Ci(){let{state:e,actions:t}=K(),r=e.confirmDelete;if(!r)return null;let n=r.kind==="annotation",o=n?"Delete annotation?":"Delete message?",a=n?"This removes the annotation and its thread for everyone.":"This removes your message from the thread.",i=n?"Delete annotation":"Delete message";return jsx("div",{className:"absolute inset-0 z-40 flex items-start justify-end bg-black/25 p-3 backdrop-blur-[2px]",children:jsxs("div",{role:"dialog","aria-label":o,className:"patch-fade-in flex w-full max-w-[286px] flex-col gap-2 rounded-xl bg-popover p-4 shadow-dialog",children:[jsx("div",{className:"text-[13.5px] font-medium text-foreground",children:o}),jsx("div",{className:"text-xs text-muted-foreground",children:a}),e.actionError?jsx("div",{className:"text-[11px] font-medium text-destructive",children:e.actionError}):null,jsxs("div",{className:"mt-1 flex justify-end gap-2",children:[jsx(fe,{variant:"neutral",disabled:e.busy,onClick:t.cancelDelete,children:"Cancel"}),jsx(fe,{variant:"destructive",disabled:e.busy,onClick:t.confirmDelete,children:e.busy?"Deleting\u2026":i})]})]})})}function Si(){let{state:e,actions:t}=K();return e.confirmDiscardOpen?jsx("div",{className:"absolute inset-0 z-20 flex items-start justify-end bg-black/25 p-3 backdrop-blur-[2px]",children:jsxs("div",{role:"dialog","aria-label":"Discard draft",className:"patch-fade-in flex w-full max-w-[280px] flex-col gap-2 rounded-xl bg-popover p-4 shadow-dialog",children:[jsx("div",{className:"text-[13.5px] font-medium text-foreground",children:"Discard draft?"}),jsx("div",{className:"text-xs text-muted-foreground",children:"You'll lose what you've typed."}),jsxs("div",{className:"mt-1 flex justify-end gap-2",children:[jsx(fe,{variant:"neutral",onClick:()=>t.setConfirmDiscardOpen(false),children:"Keep editing"}),jsx(fe,{variant:"destructive",onClick:()=>t.forceClose(),children:"Discard"})]})]})}):null}var nc="inline-grid place-items-center rounded-full transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",oc={sm:"size-7",md:"size-8"},ic={default:"text-muted-foreground hover:bg-black/6 hover:text-foreground",warn:"bg-amber-500/15 text-amber-700"};function Fe({size:e="sm",tone:t="default",className:r,type:n="button",ref:o,...a}){return jsx("button",{ref:o,type:n,className:R(nc,oc[e],ic[t],r),...a})}function Ti(){let{state:e}=K();return !e.showDevFooter||!e.annotation?null:jsxs("div",{className:"-mt-[22px] flex flex-col gap-2 bg-neutral-100/50 px-3 pt-[2.125rem] pb-3",children:[jsxs("div",{className:"flex items-start justify-between gap-2",children:[jsx(sc,{}),jsx("div",{className:"flex shrink-0 items-center gap-1",children:jsx(cc,{})})]}),e.actionError?jsx("div",{className:"px-1 text-[11px] font-medium text-destructive",children:e.actionError}):null]})}function sc(){let{state:e,actions:t}=K(),[r,n]=useState(false),[o,a]=useState(""),[i,s]=useState(false),c=e.runState,l=c?.status;if(e.annotation?.status==="resolved")return jsx("div",{className:"min-w-0 flex-1"});let p=l==="queued"||l==="running",u=l==="succeeded"&&!!c?.prUrl&&!c.prClosedUnmerged,m=c?"Run Patch again":"Run Patch",h=l==="failed"?"destructiveTint":"brand",v=!e.agentRunReady,w=async()=>{try{s(!0),await t.runPatch(o.trim()||void 0),a(""),n(!1);}finally{s(false);}};if(p)return jsx("div",{className:"min-w-0 flex-1",children:jsxs(fe,{variant:"brandTint",disabled:true,children:[jsx("span",{className:"patch-fade-in size-[7px] rounded-full bg-brand"}),"Patch is working\u2026"]})});if(u){let b=Ao(c.prUrl);return jsx("div",{className:"min-w-0 flex-1",children:jsxs("a",{href:c.prUrl,target:"_blank",rel:"noopener noreferrer",className:Et("brand","no-underline"),children:[jsx($,{name:"pr",size:12}),b==="PR"?"View PR":`View PR ${b}`]})})}let x=jsxs(fe,{variant:h,disabled:e.busy||v,className:v?"opacity-60":void 0,onClick:()=>n(true),children:[jsx(At,{size:12})," ",m]});return jsxs("div",{className:"min-w-0 flex-1",children:[v&&e.agentRunSetupMessage?jsx(Ce,{text:e.agentRunSetupMessage,tone:"warning",children:x}):x,r?jsx(lc,{title:m,guidance:o,submitting:i||e.busy,onGuidanceChange:a,onCancel:()=>n(false),onSubmit:w}):null]})}function lc({title:e,guidance:t,submitting:r,onGuidanceChange:n,onCancel:o,onSubmit:a}){return jsxs("div",{className:"absolute inset-0 z-30 flex items-center justify-center p-4",children:[jsx("button",{type:"button","aria-label":"Close guidance",className:"absolute inset-0 cursor-default bg-black/25 backdrop-blur-[2px]",onClick:o}),jsxs("form",{role:"dialog","aria-label":e,className:"patch-fade-in relative flex w-full max-w-[280px] flex-col gap-3 rounded-xl bg-popover p-4 shadow-dialog",onSubmit:i=>{i.preventDefault(),a();},children:[jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[jsx("span",{className:"grid size-7 shrink-0 place-items-center rounded-lg bg-brand text-white",children:jsx(At,{size:13})}),jsx("span",{className:"truncate text-[13.5px] font-medium text-foreground",children:e})]}),jsx(Fe,{size:"sm",title:"Close",onClick:o,children:jsx($,{name:"x",size:12})})]}),jsxs("label",{className:"flex flex-col gap-1.5",children:[jsx("span",{className:"text-[12px] font-medium text-muted-foreground",children:"Guidance"}),jsx("textarea",{value:t,onChange:i=>n(i.target.value),maxLength:5e3,rows:3,placeholder:"Optional run guidance",className:"min-h-20 resize-none rounded-md border border-black/10 bg-black/[0.03] px-3 py-2 text-[13px] leading-[1.4] text-foreground outline-none placeholder:text-muted-foreground focus:border-brand/50 focus:ring-2 focus:ring-brand/20"})]}),jsxs("div",{className:"flex justify-end gap-2",children:[jsx(fe,{variant:"neutral",disabled:r,onClick:o,children:"Cancel"}),jsx(fe,{type:"submit",variant:"brand",disabled:r,children:r?"Starting\u2026":"Start run"})]})]})]})}function cc(){let{state:e,actions:t}=K();return e.annotation?e.annotation.status==="resolved"?jsxs(fe,{variant:"neutral",disabled:e.busy,onClick:()=>t.reopen(),children:[jsx($,{name:"refresh",size:12}),"Reopen"]}):jsxs(fe,{variant:"neutral",disabled:e.busy,onClick:()=>t.markResolved(),children:[jsx($,{name:"check",size:12}),"Resolve"]}):null}var dc={desktop:"Desktop",tablet:"Tablet",mobile:"Mobile"};function _e(e,t){let r=e?.replace(/\s+/g," ").trim();return r?r.length<=t?r:`${r.slice(0,t-1)}...`:null}function Ei(e){let t=e?.trim();return t||null}function Ke(e){return Number.isInteger(e)?String(e):e.toFixed(1)}function uc(e){let t=e.viewport??"desktop",r=dc[t],n=e.viewportSize;return n?`${r} (${n.width}x${n.height})`:r}function pc(e){let t=e.coordinates,r=[`viewport (${Ke(t.viewportX)}, ${Ke(t.viewportY)})`,`documentY ${Ke(t.documentY)}`];return t.isFixed&&r.push("fixed"),r.join(", ")}function mc(e){let t=e.boundingBox;return t?`x ${Ke(t.x)}, y ${Ke(t.y)}, ${Ke(t.width)}x${Ke(t.height)}`:null}function gc(e){let t=e.domHints?.attributeSignature;if(!t)return null;let r=Object.entries(t).slice(0,12).map(([n,o])=>`${n}="${_e(o,120)??""}"`);return r.length>0?r.join(", "):null}function fc(e){let t=[`- Page: ${e.url}`,`- Element: ${_e(e.elementPath||e.element,500)??"unknown"}`,`- Viewport: ${uc(e)}`,`- Anchor: ${pc(e)}`],r=_e(e.targetLabel,160),n=mc(e);return r&&t.push(`- Visible target: ${r}`),n&&t.push(`- Bounding box: ${n}`),`## Target
2019
+ ${t.join(`
2020
+ `)}`}function hc(e){let t=_e(e.selectedText,1500);return t?`## Selected text
2021
+ ${t}`:null}function bc(e){let t=e.role==="studio"?"workspace":"client",r=_e(e.authorName,80),n=r?`${t} (${r})`:t,o=Ei(e.content)??"(empty)";return `- ${n}: ${o.replace(/\n/g,`
2022
+ `)}`}function vc(e){return e.length===0?null:`## Thread
2023
+ ${e.map(bc).join(`
2024
+ `)}`}function xc(e){let t=[],r=_e(e.reactComponents,1e3),n=_e(e.sourceFile,500),o=_e(e.domHints?.cssSelector,500),a=_e(e.domHints?.textSignature,300),i=gc(e),s=e.cssClasses?.slice(0,20).join(" ");return r&&t.push(`- React components: ${r}`),n&&t.push(`- Source file hint: ${n}`),o&&t.push(`- CSS selector: ${o}`),a&&t.push(`- Text signature: ${a}`),i&&t.push(`- Attributes: ${i}`),s&&t.push(`- CSS classes: ${s}`),e.isMultiSelect&&t.push("- Selection: multiple elements"),t.length>0?`## Implementation hints
2025
+ ${t.join(`
2026
+ `)}`:null}function Ri(e){return ["Address this feedback in the repository.",`## Feedback
2027
+ ${Ei(e.payload.comment)??"(no feedback text)"}`,fc(e.payload),hc(e.payload),vc(e.thread),xc(e.payload)].filter(Boolean).join(`
2028
+
2029
+ `)}function Pi(){let{state:e,meta:t}=K(),r=e.annotation,n=we[t.viewport],o=r?.payload.selectedText;return jsxs("div",{className:"relative z-10 flex flex-col gap-2.5 border-b border-black/[0.07] bg-neutral-100/60 px-4 py-3",children:[jsxs("div",{className:"flex items-center justify-between gap-3",children:[jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[jsx("span",{title:t.targetLabel,className:"min-w-0 overflow-hidden text-ellipsis whitespace-nowrap text-[12.5px] font-medium text-foreground",children:t.targetLabel}),jsx(Ce,{text:je(t.viewport),placement:"bottom",children:jsx("span",{"data-patch-thread-viewport":t.viewport,role:"img","aria-label":je(t.viewport),className:"inline-flex shrink-0 items-center text-brand",children:jsx($,{name:n.glyph,size:15,stroke:1.8})})})]}),jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.isResolved?jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-brand-green px-2 py-[3px] text-[11px] font-medium text-white",children:[jsx($,{name:"check",size:10})," Resolved"]}):null,jsxs("div",{className:"ml-0.5 flex items-center gap-0.5",children:[e.showDevFooter&&r?jsx(Cc,{annotation:r}):null,jsx(Sc,{}),jsx(Ac,{})]})]})]}),o?jsx("div",{className:"rounded-lg bg-white px-3 py-2 shadow-[0_0_0_1px_rgba(0,0,0,0.06)]",children:jsx("div",{className:"border-l-[2.5px] border-black/16 pl-2.5 text-[12.5px] leading-[1.45] text-muted-foreground",children:o.length>200?`${o.slice(0,199).trim()}\u2026`:o})}):null]})}async function kc(e,t){try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}let r=t.createElement("textarea");r.value=e,r.setAttribute("readonly",""),r.style.position="fixed",r.style.top="-9999px",r.style.left="-9999px",t.body.appendChild(r),r.select();try{return t.execCommand("copy")}catch{return false}finally{r.remove();}}function Cc({annotation:e}){let[t,r]=useState(false),n=useRef(null);useEffect(()=>()=>{n.current&&clearTimeout(n.current);},[]);let o=async a=>{await kc(Ri(e),a)&&(r(true),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>r(false),1500));};return jsx(Ce,{text:t?"Copied":"Copy agent prompt",placement:"bottom",children:jsx(Fe,{"aria-label":t?"Copied agent prompt":"Copy agent prompt",onClick:a=>{o(a.currentTarget.ownerDocument);},children:jsxs("span",{className:"relative block",style:{width:14,height:14},children:[jsx("span",{className:R("absolute inset-0 grid place-items-center transition-all duration-200 ease-out",t?"scale-50 opacity-0 blur-[2px]":"scale-100 opacity-100 blur-0"),children:jsx($,{name:"copy",size:14})}),jsx("span",{className:R("absolute inset-0 grid place-items-center text-brand-green transition-all duration-200 ease-out",t?"scale-100 opacity-100 blur-0":"scale-50 opacity-0 blur-[2px]"),children:jsx($,{name:"check",size:13})})]})})})}function Ac(){let{actions:e}=K();return jsx(Fe,{onClick:e.requestClose,title:"Close",children:jsx($,{name:"x",size:14})})}function Sc(){let{state:e,actions:t}=K(),[r,n]=useState(false);return e.canDeleteAnnotation?jsxs("div",{className:"relative",children:[jsx(Fe,{title:"Annotation actions","aria-label":"Annotation actions","aria-expanded":r,"aria-haspopup":"menu",onClick:()=>n(o=>!o),children:jsx($,{name:"more",size:14})}),r?jsx("div",{role:"menu",className:"patch-fade-in absolute top-full right-0 z-[5] mt-1 min-w-40 rounded-xl bg-popover p-1 shadow-dialog ring-1 ring-black/6",children:jsxs("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-[12.5px] font-medium text-destructive hover:bg-destructive/10 focus:bg-destructive/10 focus:outline-none",onClick:()=>{n(false),t.requestDeleteAnnotation();},children:[jsx($,{name:"trash",size:13}),"Delete annotation"]})}):null]}):null}function Li(){let{state:e,actions:t,meta:r}=K(),n=useRef(null),o=r.viewer.kind==="client"?r.viewer.generatedSeed:null,a=r.viewer.kind==="client"?r.viewer.authorId:null;return useEffect(()=>{let s=n.current;s&&(s.scrollTop=s.scrollHeight);}),e.threadVisible?jsxs("div",{ref:n,"data-patch-thread-scroller":"",className:R("flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto bg-white px-4 pt-3.5 pb-3",e.showDevFooter&&e.isResolved&&"relative z-[1] rounded-b-xl shadow-[0_6px_12px_-5px_rgba(0,0,0,0.16)]"),children:[e.annotation?jsx(_i,{name:e.annotation.authorName??"Someone",createdAt:e.annotation.createdAt,content:e.annotation.payload.comment,authorKey:e.annotation.payload.authorId??e.annotation.authorName??e.annotation.id,avatarSrc:e.annotation.authorImage,generatedSeed:e.annotation.payload.authorRole==="client"&&e.annotation.payload.authorId===a?o:e.annotation.authorAvatarSeed??e.annotation.payload.authorId??null,deliveryStatus:e.annotation.deliveryStatus,onRetry:e.annotation.deliveryStatus==="failed"?t.retryInitialMessage:void 0}):null,e.messages.map(s=>jsx(_i,{name:s.authorName??s.role,createdAt:s.createdAt,content:s.content,authorKey:s.authorId??s.authorName??s.role,avatarSrc:s.authorImage,generatedSeed:s.role==="client"&&s.authorId===a?o:s.authorAvatarSeed??s.authorId,deliveryStatus:s.deliveryStatus,canDelete:t.canDeleteMessage(s),onDelete:()=>t.requestDeleteMessage(s),onRetry:s.deliveryStatus==="failed"?()=>{t.retryMessage(s.id);}:void 0},s.id))]}):null}function _i(e){let t=nt(e.name),r=ot(e.authorKey),n=e.deliveryStatus==="failed";return jsxs("div",{className:"group/message flex gap-2.5",children:[jsx($e,{initials:t,tint:r,src:e.avatarSrc,generatedSeed:e.generatedSeed,alt:e.name}),jsxs("div",{className:"relative min-w-0 flex-1 pr-8",children:[jsxs("div",{className:"flex items-baseline gap-1.5",children:[jsx("span",{className:"text-[12.5px] font-medium text-foreground",children:e.name}),jsx("span",{className:"text-[11px] text-muted-foreground",children:er(e.createdAt)})]}),e.canDelete&&e.onDelete?jsx(Ic,{onDelete:e.onDelete}):null,jsx("p",{className:"mt-0.5 whitespace-pre-wrap text-[13px] leading-[1.45] text-foreground",children:e.content}),n?jsxs("div",{className:"mt-1 flex items-center gap-2 text-[11px] leading-none",children:[jsx("span",{className:"text-destructive",children:"Failed to send"}),e.onRetry?jsx("button",{type:"button",onClick:e.onRetry,className:"rounded-full bg-black/8 px-2 py-1 font-medium text-foreground transition-colors hover:bg-black/12",children:"Retry"}):null]}):null]})]})}var Ec=44,Rc=8;function Ic({onDelete:e}){let[t,r]=useState(false),[n,o]=useState("down"),a=useRef(null),i=useCallback(()=>{let c=a.current,l=c?.closest("[data-patch-thread-scroller]");if(!c||!l){o("down");return}let d=c.getBoundingClientRect(),p=l.getBoundingClientRect(),u=p.bottom-d.bottom,m=d.top-p.top;o(u<Ec+Rc&&m>u?"up":"down");},[]),s=useCallback(()=>{r(c=>{let l=!c;return l&&i(),l});},[i]);return jsxs("div",{className:"absolute top-[-5px] right-0 opacity-0 transition-opacity group-focus-within/message:opacity-100 group-hover/message:opacity-100",children:[jsx(Fe,{ref:a,size:"sm",title:"Message actions","aria-label":"Message actions","aria-expanded":t,"aria-haspopup":"menu",onClick:s,children:jsx($,{name:"more",size:14})}),t?jsx("div",{role:"menu",className:R("patch-fade-in absolute right-0 z-[5] min-w-36 rounded-xl bg-popover p-1 shadow-dialog ring-1 ring-black/6",n==="up"?"bottom-full mb-1":"top-full mt-1"),children:jsxs("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-[12.5px] font-medium text-destructive hover:bg-destructive/10 focus:bg-destructive/10 focus:outline-none",onClick:()=>{r(false),e();},children:[jsx($,{name:"trash",size:13}),"Delete"]})}):null]})}var Pc={default:"w-full min-h-[60px] resize-y rounded-md border border-border bg-popover px-3 py-2 text-[13px] leading-[1.45] text-foreground outline-none transition-colors placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",bare:"w-full resize-none self-center overflow-y-auto bg-transparent border-0 outline-none text-[13px] leading-normal text-foreground placeholder:text-muted-foreground"};function Oi({variant:e="default",className:t,ref:r,...n}){return jsx("textarea",{ref:r,className:R(Pc[e],t),...n})}var Dc=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,zi="w-full rounded-md border border-border bg-popover px-2.5 py-2 text-[13px] text-foreground outline-none transition-colors focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring";function $i(){let{actions:e}=K(),[t,r]=useState(""),[n,o]=useState(""),[a,i]=useState(null),[s,c]=useState(false),l=useRef(null);return useEffect(()=>{setTimeout(()=>l.current?.focus(),0);},[]),jsxs("form",{onSubmit:async p=>{p.preventDefault();let u=t.trim(),m=n.trim();if(!u){i("Name is required.");return}if(!Dc.test(m)){i("Enter a valid email.");return}i(null),c(true);let h=await e.setIdentity({name:u,email:m});c(false),h||i("Could not save identity. Try again.");},className:"flex flex-col gap-2",children:[jsx("div",{className:"text-xs text-muted-foreground",children:"Tell us who you are so the team can reply."}),jsx("input",{ref:l,type:"text",placeholder:"Name",value:t,onChange:p=>r(p.target.value),className:zi}),jsx("input",{type:"email",placeholder:"Email",value:n,onChange:p=>o(p.target.value),className:zi}),a?jsx("div",{className:"text-xs text-destructive",children:a}):null,jsx("button",{type:"submit",disabled:s,className:R(Et("brand"),"self-end",s&&"cursor-not-allowed opacity-60"),children:s?"Saving\u2026":"Continue"})]})}function Fi(){let{state:e,actions:t,meta:r}=K(),n=useRef(null),[o,a]=useState(false);if(useEffect(()=>{e.needsIdentity||setTimeout(()=>n.current?.focus(),0);},[e.needsIdentity]),useEffect(()=>{let u=n.current;if(!u)return;u.style.height="0px";let m=Math.min(u.scrollHeight,140);u.style.height=`${m}px`,a(m>28);},[e.draftText]),e.isResolved||e.initialMessageLocked)return null;if(e.needsIdentity)return jsx("div",{className:R("bg-white px-4 py-3",e.threadVisible&&"border-t border-black/6"),children:jsx($i,{})});let i=e.draftText.trim().length>0,s=r.viewer.name,c=nt(s),l=r.viewer.kind==="studio"?"var(--color-foreground)":ot(r.viewer.avatarKey),d=u=>{u.preventDefault(),t.submit();},p=u=>{u.key==="Enter"&&!u.shiftKey&&(u.preventDefault(),t.submit());};return jsx("form",{onSubmit:d,className:R("bg-white p-3",e.threadVisible&&"border-t border-black/6",e.showDevFooter&&"relative z-[1] rounded-b-xl shadow-[0_6px_12px_-5px_rgba(0,0,0,0.16)]"),children:jsxs("div",{className:R("flex items-end gap-2 bg-black/4 px-3 py-2.5 transition-colors",o?"rounded-xl":"rounded-full"),children:[jsx($e,{initials:c,tint:l,src:r.viewer.avatarSrc,generatedSeed:r.viewer.generatedSeed,alt:s??"",className:"self-start"}),jsx(Oi,{ref:n,variant:"bare",value:e.draftText,onChange:u=>t.setDraftText(u.target.value),onKeyDown:p,rows:1,placeholder:e.annotation?"Reply\u2026":"What should change?",style:{maxHeight:"140px"}}),jsx($c,{enabled:i})]})})}function $c({enabled:e}){return jsx("button",{type:"submit",disabled:!e,"aria-label":"Send",className:R("grid size-7 shrink-0 place-items-center rounded-full text-white",e?"pkey pkey-brand":"bg-black/16 transition-colors"),children:jsx($,{name:"arrow-up",size:13})})}var Yc=[.4,0,.2,1],Uc=[.22,.61,.36,1],Xc={x:-8,y:-8,origin:"top left"},Bi=200;function Wi(e,t,r){return Math.max(t,Math.min(r,e))}function Yi(e,t,r){let n={x:e.x+e.width/2,y:e.y+e.height/2},o={x:t.x+t.width/2,y:t.y+r/2};return {x:Wi((n.x-o.x)*.08,-12,12),y:Wi((n.y-o.y)*.12,-10,10),origin:`${n.y<o.y?"top":"bottom"} ${n.x<o.x?"left":"right"}`}}function Gc(e,t){if(!t)return Xc;let r=yt({anchor:t,popover:{width:332,height:Bi},viewport:e.getOverlayViewport()});return Yi(t,r,Bi)}function Kc(e,t){return e.x===t.x&&e.y===t.y&&e.origin===t.origin}function Ui({getAnchorRect:e,initialAnchorRect:t,entryDelay:r=0,children:n}){let{actions:{attemptClose:o},meta:{shakeNonce:a}}=K(),i=ce(),s=useRef(null),[c,l]=useState(()=>Gc(i,t??e())),d=useCallback(()=>{let m=s.current;if(!m)return;let h=e();if(!h)return;let v=m.offsetHeight||200,w=yt({anchor:h,popover:{width:332,height:v},viewport:i.getOverlayViewport()});m.style.left=`${w.x}px`,m.style.top=`${w.y}px`,m.style.right="auto";let x=Yi(h,w,v);l(b=>Kc(b,x)?b:x);},[e,i]);useLayoutEffect(()=>{d();}),useEffect(()=>{let m=null,h=()=>{m===null&&(m=i.overlayWindow.requestAnimationFrame(()=>{m=null,d();}));},v=new Set([i.targetWindow,i.overlayWindow]);for(let x of v)x.addEventListener("resize",h),x.addEventListener("scroll",h,{passive:true});let w=gn(i.overlayWindow,h);return w.observe(i.overlayDocument.body),i.targetDocument.body!==i.overlayDocument.body&&w.observe(i.targetDocument.body),s.current&&w.observe(s.current),()=>{m!==null&&i.overlayWindow.cancelAnimationFrame(m);for(let x of v)x.removeEventListener("resize",h),x.removeEventListener("scroll",h);w.disconnect();}},[d,i]),useEffect(()=>{let m=w=>{Co(w)||o();},h=w=>{w.key==="Escape"&&o();},v=new Set([i.targetDocument,i.overlayDocument]);for(let w of v)w.addEventListener("mousedown",m,true),w.addEventListener("keydown",h);return ()=>{for(let w of v)w.removeEventListener("mousedown",m,true),w.removeEventListener("keydown",h);}},[o,i]);let p=useRef(a);useEffect(()=>{if(a===p.current)return;p.current=a;let m=s.current;m&&(m.classList.remove("patch-shake"),m.offsetWidth,m.classList.add("patch-shake"));},[a]);let u={width:`${332}px`,height:"auto",transformOrigin:c.origin};return jsx(motion.div,{ref:s,layout:true,initial:{opacity:0,x:c.x,y:c.y,scale:.985},animate:{opacity:1,x:0,y:0,scale:1,transition:{type:"spring",stiffness:560,damping:34,mass:.7,delay:r}},exit:{opacity:0,x:c.x,y:c.y,scale:.985,transition:{duration:.16,ease:Yc}},transition:{layout:{duration:.42,ease:Uc}},onLayoutAnimationComplete:d,"data-patch-popover":"",role:"dialog","aria-label":"Annotation thread",className:"fixed z-[2147483646] flex flex-col overflow-hidden rounded-xl border border-black/6 bg-popover font-sans text-popover-foreground shadow-[0_20px_56px_-16px_rgba(0,0,0,0.2),0_8px_18px_-6px_rgba(0,0,0,0.08)]",style:u,children:n})}var le={Root:Ui,Header:Pi,Messages:Li,Reply:Fi,DevFooter:Ti,ConfirmDiscard:Si,ConfirmDelete:Ci};function Xi({getAnchorRect:e,initialAnchorRect:t,entryDelay:r}){return jsxs(le.Root,{getAnchorRect:e,initialAnchorRect:t,entryDelay:r,children:[jsx(le.Header,{}),jsx(le.Messages,{}),jsx(le.Reply,{}),jsx(le.ConfirmDiscard,{}),jsx(le.ConfirmDelete,{})]})}function Gi({getAnchorRect:e,initialAnchorRect:t,entryDelay:r}){return jsxs(le.Root,{getAnchorRect:e,initialAnchorRect:t,entryDelay:r,children:[jsx(le.Header,{}),jsx(le.Messages,{}),jsx(le.Reply,{}),jsx(le.DevFooter,{}),jsx(le.ConfirmDiscard,{}),jsx(le.ConfirmDelete,{})]})}var ed="data-patch-internal";function ji(e,t,r){let n={viewportX:t,viewportY:r},o=it(n,e.getOverlayViewport());return Qt(n,o)}function td(e,t){return e.overlayDocument.querySelector("patch-widget-root")?.shadowRoot?.querySelector(t)??null}function rd(e,t){let r=td(e,`[data-patch-pin-id="${t}"]`);if(!r)return null;let n=r.getBoundingClientRect();return {x:n.x,y:n.y,width:n.width,height:n.height}}function nd(e,t){if(!t)return null;let r=Vo({payload:t.payload,doc:e.targetDocument,scrollY:e.getTargetScrollY(),viewport:e.getTargetViewport(),internalAttr:ed}),n=e.targetPointToOverlay(r.position);return ji(e,n.viewportX,n.viewportY)}function qi(e,t,r){if(!t)return null;if(t.kind==="existing")return rd(e,t.annotationId)??nd(e,r);let n=e.targetPointToOverlay({viewportX:t.anchor.viewportX,viewportY:t.anchor.documentY-e.getTargetScrollY()});return ji(e,n.viewportX,n.viewportY)}function Zi(){let e=xe(),t=re(),r=ce(),n=e.active,o=useMemo(()=>!n||n.kind!=="existing"?null:t.annotations.find(p=>p.id===n.annotationId)??null,[n,t.annotations]),a=useCallback(()=>qi(r,n,o),[n,o,r]),i=t.viewerKind==="studio"?Gi:Xi,s=n&&(n.kind==="composer"||!!o),c=n?.kind==="composer"?.04:0,l=n?.kind==="composer"?li(n.target):null,d=useMemo(()=>qi(r,n,o),[n,o,r]);return jsx(AnimatePresence,{children:s?jsx(yi,{annotation:o,draftTargetLabel:l,children:jsx(i,{getAnchorRect:a,initialAnchorRect:d,entryDelay:c})},"active-popover"):null})}var ad="https://app.usepatch.dev";function sd({children:e}){let{active:t}=re();return t?e:null}function Ji(e){let t=typeof window<"u"&&mn(window),r=useMemo(()=>uo({prop:e.projectToken,processEnv:mo(),importMetaEnv:po()}),[e.projectToken]),n=e.apiBase??ad;return useEffect(()=>{r||console.warn(co);},[r]),t||!r?null:jsx(Jo,{children:jsx(fn,{children:jsx(Cn,{projectToken:r,apiBase:n,children:jsx(sd,{children:jsx(Sn,{children:jsx(lo,{children:jsx(io,{projectToken:r,children:jsxs(eo,{children:[jsx(Go,{}),jsx(Zi,{}),jsx(qo,{}),jsx(Oo,{})]})})})})})})})})}var ld=Ji;
2030
+ export{Ji as Patch,ld as default};