@usepatch/widget 0.5.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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 Gt(t){if(t.length<=1||!t.endsWith("/"))return t;try{let e=new URL(t);if(e.pathname==="/"&&t.endsWith("/"))return `${e.origin}${e.search}${e.hash}`}catch{}return t.slice(0,-1)}function ct(t){try{let e=new URL(t);return Gt(`${e.origin}${e.pathname}`)}catch{return Gt(t)}}var hr="patch:locationchange",Zr="__patchHistoryPatched";function ga(t){let e=t.history;if(e[Zr])return;e[Zr]=true;let r=()=>t.dispatchEvent(new Event(hr)),{pushState:n,replaceState:o}=e;try{e.pushState=function(...s){let i=n.apply(this,s);return r(),i},e.replaceState=function(...s){let i=o.apply(this,s);return r(),i};}catch{}}function Jr(t,e){ga(t);let r=()=>e();return t.addEventListener("popstate",r),t.addEventListener("hashchange",r),t.addEventListener(hr,r),()=>{t.removeEventListener("popstate",r),t.removeEventListener("hashchange",r),t.removeEventListener(hr,r);}}var Tt={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 Qt(t){let e=Tt[t];return e.width===null||e.height===null?e.label:`${e.label} (${e.width}px \xD7 ${e.height}px)`}function tn(t,e){let r=Tt[t];return {width:r.width??e.width,height:r.height??e.height}}var ha=32,ba=32,va=3e3,nn="cubic-bezier(0.16, 1, 0.3, 1)",Ve=[.22,.61,.36,1],on=.3,an=.5,xa=.34,wa=.5,ya=.24,ka=.22,sn=.12,Ca=.42,ln=.2,Aa=200,Sa=260,Ta=70,Ea=180,Ra=260,Pa=8,Ia=4,Na="#d9d9dd",Ma=30,_a=["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 We(t,e,r){let n=Math.max(320,t.innerWidth-ha*2),o=Math.max(320,t.innerHeight-ba*2);return Math.min(1,n/e,o/r)}function La(t){try{return !!(t.contentWindow&&t.contentDocument?.body)}catch{return false}}function cn({src:t,viewport:e,overlayWindow:r,onFrameElement:n,onReadyChange:o,onBlockedChange:s}){let i=useReducedMotion(),a=e.width??r.innerWidth,l=e.height??r.innerHeight,c=e.viewport,d=`${c}:${a}:${l}`,u=!!r.happyDOM?.settings?.disableIframePageLoading,[p,m]=useState(()=>({viewport:c,width:a,height:l,scale:We(r,a,l)})),[v,f]=useState("stable"),[b,h]=useState(false),[y,T]=useState(false),x=useRef(false),z=useRef(null),g=`${p.viewport}:${p.width}:${p.height}`!==d,U=b&&!y&&!(g||v==="cover"||v==="resize"),at=b&&!y&&v==="stable"&&!g,pt=useCallback(E=>{z.current=E,n(E);},[n]),vt=useCallback(()=>{let E=z.current;if(!E||!La(E)){x.current=false,h(false),T(true);return}x.current=true,h(true),T(false);},[]),st=useCallback(()=>{m(E=>{let tt=We(r,E.width,E.height);return E.scale===tt?E:{...E,scale:tt}});},[r]);useEffect(()=>(st(),r.addEventListener("resize",st),()=>r.removeEventListener("resize",st)),[r,st]),useEffect(()=>{x.current=false,h(false),T(false);let E=r.setTimeout(()=>{x.current||T(true);},va);return ()=>r.clearTimeout(E)},[t,r]),useEffect(()=>{if(i){g&&m({viewport:c,width:a,height:l,scale:We(r,a,l)}),v!=="stable"&&f("stable");return}switch(v){case "stable":{g&&f("cover");return}case "cover":{let E=r.setTimeout(()=>f("resize"),Ta);return ()=>r.clearTimeout(E)}case "resize":{g&&m({viewport:c,width:a,height:l,scale:We(r,a,l)});let E=r.setTimeout(()=>f("reveal"),Ea);return ()=>r.clearTimeout(E)}case "reveal":{let E=r.setTimeout(()=>f("stable"),Ra);return ()=>r.clearTimeout(E)}}},[v,g,i,r,c,a,l]),useEffect(()=>{o(at);},[at,o]),useEffect(()=>{s(y);},[y,s]);let Q=i?{duration:0}:{duration:ya,ease:Ve},X=i?{duration:0}:{duration:ka,ease:Ve,delay:ln*.5},k=i?{duration:0}:{duration:ln,ease:Ve},R=i?{duration:0}:{opacity:{duration:Ca,ease:Ve,delay:sn},scale:{type:"spring",bounce:xa,duration:wa,delay:sn},width:{type:"spring",bounce:on,duration:an},height:{type:"spring",bounce:on,duration:an}},M=(U?Sa:Aa)/1e3,A=i?void 0:`opacity ${M}s ${nn}, filter ${M}s ${nn}`,H=p.width*p.scale,F=p.height*p.scale;return jsx(motion.div,{"data-patch-preview-backdrop":"",initial:{opacity:0},animate:{opacity:1,transition:Q},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:H,height:F}:{opacity:0,scale:.8,width:H,height:F},animate:{opacity:1,scale:1,width:H,height:F},exit:i?{opacity:0}:{opacity:0,scale:.92,transition:k},transition:R,"data-patch-preview-shell":"",className:"relative overflow-hidden bg-white",style:{boxSizing:"content-box",border:`${Ia}px solid ${Na}`,borderRadius:Ma,boxShadow:_a,willChange:"width, height"},children:[jsx("div",{"aria-hidden":!U,className:"absolute top-0 left-0 origin-top-left",style:{width:p.width,height:p.height,transform:`scale(${p.scale})`,opacity:U?1:0,filter:i||U?"none":`blur(${Pa}px)`,transition:A,pointerEvents:U?"auto":"none",willChange:"opacity, filter"},children:jsx("iframe",{ref:pt,"data-patch-preview-frame":"","data-patch-preview-src":t,title:`${e.label} preview`,tabIndex:U?0:-1,src:u?void 0:t,srcDoc:u?"<!doctype html><html><body></body></html>":void 0,onLoad:vt,className:"block bg-white",style:{width:p.width,height:p.height,border:0}})}),jsx(Da,{visible:y})]})})}function Da({visible:t}){return t?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 mn=createContext(null),gn=createContext(null),fn="__patch_preview";function hn(){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:()=>Gt(`${window.location.origin}${window.location.pathname}`),targetPointToOverlay:t=>({...t}),targetRectToOverlay:t=>({...t}),eventTargetElement:t=>t instanceof window.Element?t:null}}function Fa(t){let e=new URL(t.location.href);return e.searchParams.set(fn,"1"),e.toString()}function bn(t=window){try{return new URL(t.location.href).searchParams.get(fn)==="1"}catch{return false}}function $a(t,e,r){let n=e.contentWindow,o=e.contentDocument;if(!n||!o)return null;function s(){return e.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:t.overlayWindow,overlayDocument:t.overlayDocument,getTargetViewport:()=>r,getOverlayViewport:t.getOverlayViewport,getTargetScrollY:()=>n.scrollY,getPageUrl:()=>Gt(`${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 vn(t,e){let r=t.ResizeObserver??ResizeObserver;return new r(e)}function xn({children:t}){let e=useMemo(()=>hn(),[]),[r,n]=useState("desktop"),[o,s]=useState(null),[i,a]=useState(false),[l,c]=useState(false),[d,u]=useState(false),p=r!=="desktop",m=p||d,v=Tt[r],f=v.width&&v.height?{width:v.width,height:v.height}:null;useEffect(()=>{a(false),c(false);},[r]);let b=useRef(p);useEffect(()=>{b.current&&!p?u(true):!b.current&&p&&u(false),b.current=p;},[p]);let h=useMemo(()=>e?!p||!i||l||!o||!f?e:$a(e,o,f)??e:null,[l,o,i,p,f,e]),y=useMemo(()=>({activeViewport:r,setActiveViewport:n,isPreviewing:m,previewReady:m?p&&i&&!l:true,previewBlocked:p&&l}),[r,l,i,p,m]),T=useMemo(()=>e?Fa(e.targetWindow):"",[e]);return !h||!e?null:jsx(gn.Provider,{value:y,children:jsxs(mn.Provider,{value:h,children:[t,jsx(AnimatePresence,{onExitComplete:()=>u(false),children:p&&f?jsx(cn,{src:T,viewport:v,overlayWindow:e.overlayWindow,onFrameElement:s,onReadyChange:a,onBlockedChange:c}):null})]})})}function mt(){let t=use(mn),e=useMemo(()=>hn(),[]);if(t)return t;if(e)return e;throw new Error("useTargetSurface must run in a browser document")}function ne(){let t=use(gn),[e,r]=useState("desktop"),n=useMemo(()=>({activeViewport:e,setActiveViewport:r,isPreviewing:false,previewReady:true,previewBlocked:false}),[e]);return t??n}var Va="X-Patch-Client-Id";function yt(t,e){return {...e?{"Content-Type":"application/json"}:{},Authorization:`Bearer ${t.token}`,...t.clientUserId?{[Va]:t.clientUserId}:{}}}async function At(t,e){try{let r=await fetch(t,e);if(!r.ok)return null;let n=await r.text();return n?JSON.parse(n):{}}catch{return null}}async function Wa(t,e){try{let r=await fetch(t,e),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 wn(t){return {async listAnnotations(e){let r=e?`?viewport=${encodeURIComponent(e)}`:"";return (await At(`${t.apiBase}/api/widget/annotations${r}`,{method:"GET",credentials:"include",headers:yt(t,false)}))?.annotations??[]},async listRoster(){return (await At(`${t.apiBase}/api/widget/roster`,{method:"GET",credentials:"include",headers:yt(t,false)}))?.entries??[]},async fetchMe(){return At(`${t.apiBase}/api/widget/me`,{method:"GET",credentials:"include",headers:yt(t,false)})},async postIdentity(e){let r=await At(`${t.apiBase}/api/widget/identity`,{method:"POST",credentials:"include",headers:yt(t,true),body:JSON.stringify(e)});return r?{clientUserId:r.id,name:r.name,email:r.email,avatarSeed:r.avatarSeed??r.id}:null},async createAnnotation(e){return At(`${t.apiBase}/api/widget/annotations`,{method:"POST",credentials:"include",headers:yt(t,true),body:JSON.stringify(e)})},async reply(e,r){return At(`${t.apiBase}/api/widget/annotations/${e}/reply`,{method:"POST",credentials:"include",headers:yt(t,true),body:JSON.stringify(r)})},async uploadAttachment(e,r){let n=new URLSearchParams({kind:r.kind,width:String(r.width),height:String(r.height)});return (await At(`${t.apiBase}/api/widget/uploads?${n}`,{method:"POST",credentials:"include",headers:{...yt(t,false),"Content-Type":e.type},body:e}))?.attachment??null},async deleteAnnotation(e){return At(`${t.apiBase}/api/widget/annotations/${e}`,{method:"DELETE",credentials:"include",headers:yt(t,false)})},async deleteMessage(e,r){return At(`${t.apiBase}/api/widget/annotations/${e}/messages/${r}`,{method:"DELETE",credentials:"include",headers:yt(t,false)})},async kickoff(e,r){return Wa(`${t.apiBase}/api/widget/annotations/${e}/kickoff`,{method:"POST",credentials:"include",headers:yt(t,true),body:JSON.stringify(r)})},async resolve(e){return At(`${t.apiBase}/api/widget/annotations/${e}/resolve`,{method:"POST",credentials:"include",headers:yt(t,true)})},async reopen(e){return At(`${t.apiBase}/api/widget/annotations/${e}/reopen`,{method:"POST",credentials:"include",headers:yt(t,true)})},async reportAnchorStatuses(e){e.length!==0&&await At(`${t.apiBase}/api/widget/anchor-report`,{method:"POST",credentials:"include",headers:yt(t,true),body:JSON.stringify({reports:e})});}}}var wr="patch.clientIdentity",yn="patch.clientAvatarSeed";function yr(){if(typeof window>"u")return {};try{let t=window.localStorage.getItem(wr);if(!t)return {};let e=JSON.parse(t);return e&&typeof e=="object"?e:{}}catch{return {}}}function kn(t){return yr()[t]??null}function kr(t,e){if(!(typeof window>"u"))try{let r=yr();r[t]=e,window.localStorage.setItem(wr,JSON.stringify(r));}catch{}}function Cn(t){if(!(typeof window>"u"))try{let e=yr();delete e[t],window.localStorage.setItem(wr,JSON.stringify(e));}catch{}}function Ua(){if(typeof window>"u")return {};try{let t=window.localStorage.getItem(yn);if(!t)return {};let e=JSON.parse(t);return e&&typeof e=="object"?e:{}}catch{return {}}}function xr(){let t=globalThis.crypto;return `client-avatar:${typeof t?.randomUUID=="function"?t.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}`}function An(t){if(typeof window>"u")return xr();try{let e=Ua(),r=e[t];if(r)return r;let n=xr();return e[t]=n,window.localStorage.setItem(yn,JSON.stringify(e)),n}catch{return xr()}}var Xa=2e4,Tn=createContext(null);function Ka(t,e){let r=new Map(t.map(i=>[i.id,i])),n=new Set(e.map(i=>i.id)),o=e.map(i=>{let a=r.get(i.id);if(!a)return i;let l=new Set(i.thread.map(u=>u.id)),c=a.thread.filter(u=>u.deliveryStatus&&!l.has(u.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 u=i.latestRun?Date.parse(i.latestRun.createdAt):Number.NaN,p=Date.parse(a.latestRun.createdAt);i.latestRun!=null&&(Number.isNaN(p)||Number.isNaN(u)||u>=p)||(d={...d,latestRun:a.latestRun,optimisticAction:a.optimisticAction});}return d}),s=t.filter(i=>(i.deliveryStatus||i.optimisticAction)&&!n.has(i.id));return [...o,...s]}function En({projectToken:t,apiBase:e,children:r}){let n=mt(),{activeViewport:o,setActiveViewport:s}=ne(),[i,a]=useState(()=>typeof window>"u"?null:kn(t)),[l]=useState(()=>typeof window>"u"?"client-avatar:ssr":An(t)),[c,d]=useState(null),[u,p]=useState("client"),[m,v]=useState(null),[f,b]=useState([]),[h,y]=useState(null),[T,x]=useState([]),[z,O]=useState(false),[g,N]=useState(null),U=useRef(g);U.current=g;let at=useRef(o);at.current=o;let pt=h===o,vt=useMemo(()=>wn({apiBase:e,token:t,clientUserId:i?.clientUserId}),[e,t,i?.clientUserId]),st=useRef(vt);st.current=vt;let Q=useRef(0),X=useCallback(async()=>{let P=o,L=++Q.current,W=await st.current.listAnnotations(P==="desktop"?void 0:P);if(L!==Q.current||P!==at.current)return;let j=n.getPageUrl(),Pt=W.filter(wt=>ct(wt.payload.url)===j);b(wt=>Ka(wt,Pt)),y(P);},[o,n]),k=useRef(X);k.current=X,useEffect(()=>{let P=false;return (async()=>{let L=await st.current.fetchMe();if(!P){if(L?.active===false){N(false),O(true);return}if(N(true),L?.studio)d(L.studio),p("studio"),v(L.agentRunReadiness??{ready:true,message:null});else if(d(null),p("client"),v(null),L?.client){let W={clientUserId:L.client.id,name:L.client.name,email:L.client.email,avatarSeed:L.client.avatarSeed};a(W),kr(t,W);}await k.current(),P||O(true);}})(),()=>{P=true;}},[t]),useEffect(()=>{!z||!g||X();},[z,g,X]),useEffect(()=>{if(!g)return;let{overlayDocument:P,overlayWindow:L}=n,W=L.setInterval(()=>{P.visibilityState==="visible"&&X();},Xa),j=()=>{P.visibilityState==="visible"&&X();};return P.addEventListener("visibilitychange",j),()=>{L.clearInterval(W),P.removeEventListener("visibilitychange",j);}},[g,X,n]),useEffect(()=>{if(g)return Jr(n.targetWindow,()=>{let P=n.getPageUrl();b(L=>L.filter(W=>ct(W.payload.url)===P)),k.current();})},[g,n]);let R=useCallback(async P=>(kr(t,P),a(P),P),[t]),M=useCallback(()=>{a(null),Cn(t);},[t]),A=useCallback(P=>{x(L=>[...L.filter(W=>W.tempId!==P.tempId),P]);},[]),H=useCallback(P=>{x(L=>L.filter(W=>W.tempId!==P));},[]),F=useCallback(P=>{b(L=>{let W=L.findIndex(Pt=>Pt.id===P.id);if(W===-1)return [...L,P];let j=L.slice();return j[W]=P,j});},[]),E=useCallback((P,L)=>{b(W=>{let j=false,Pt=W.flatMap(wt=>{if(wt.id!==P)return [wt];j=true;let Ut=L(wt);return Ut?[Ut]:[]});return j?Pt:W});},[]),tt=useCallback((P,L)=>{b(W=>W.map(j=>j.id===P?{...j,id:L,deliveryStatus:"sent"}:j));},[]),xt=useMemo(()=>({apiClient:vt,active:g,ready:z,viewerKind:u,agentRunReadiness:m,activeViewport:o,clientAvatarSeed:l,identity:i,studio:c,annotations:f,annotationsReady:pt,ephemerals:T,refresh:X,setActiveViewport:s,setIdentity:R,signOut:M,addEphemeral:A,removeEphemeral:H,applyAnnotationUpdate:F,updateAnnotation:E,replaceAnnotationId:tt}),[vt,g,z,u,m,o,l,i,c,f,pt,T,X,s,R,M,A,H,F,E,tt]);return jsx(Tn.Provider,{value:xt,children:r})}function rt(){let t=use(Tn);if(!t)throw new Error("useAnnotationsStore must be used inside <AnnotationsProvider>");return t}function Rn(t){if(t.length<12)return null;if(t[0]===255&&t[1]===216&&t[2]===255)return "image/jpeg";if(t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71)return "image/png";let e=(r,n)=>n.split("").every((o,s)=>t[r+s]===o.charCodeAt(0));return e(0,"RIFF")&&e(8,"WEBP")?"image/webp":null}var ja=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 Za(t,e){return t.length<=e?t:`${t.slice(0,e-1).trim()}\u2026`}function Pn(t){return t.replace(/\s+/g," ").trim()}function Cr(t){return ja.has(Pn(t))}function Ja(t){return t.length<2||t.startsWith("_")?false:/^[A-Z]/.test(t)}function In(t){if(!t)return null;let e=[],r=t.matchAll(/<([^<>]+)>/g);for(let n of r){let o=Pn(n[1]??"");!o||Cr(o)||Ja(o)&&e[e.length-1]!==o&&e.push(o);}return e.length===0?null:Za(e.map(n=>`<${n}>`).join(" "),1e3)}var Nn="seed:";function Ye(t){return t?t.startsWith(Nn)?{url:null,seed:t.slice(Nn.length)||null}:/^https?:\/\//i.test(t)?{url:t,seed:null}:{url:null,seed:t}:{url:null,seed:null}}var Ar=[6,20,34,92,120,140,158,174,190,206,220,234,252,270,286,300,318,336,350],Mn=[{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]}],_n=Math.PI*2;function Qa(t){let e=2166136261;for(let r=0;r<t.length;r++)e^=t.charCodeAt(r),e=Math.imul(e,16777619);return e>>>0}function ts(t){return ()=>{t+=1831565813;let e=t;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}function K(t,e,r){return e+t()*(r-e)}function gt(t,e=3){let r=10**e;return Math.round(t*r)/r}function Ln(t,e,r){return `hsl(${gt((t%360+360)%360,1)} ${gt(e,1)}% ${gt(r,1)}%)`}function Dn(t){let e=Qa(t?.trim()||"patch-client"),r=ts(e),n=e.toString(36),o=(Ar[e%Ar.length]??Ar[0])+K(r,-10,10),s=r()<.5?-1:1,i=r()<.5?-1:1,a=o+i*K(r,52,116),l=o-i*K(r,26,66),c=o+s*K(r,12,38),d=Ln(o+s*K(r,0,14),K(r,80,92),K(r,44,54)),u=K(r,0,_n),p=Mn.map((m,v)=>{let b=(m.hue==="accent"?a:m.hue==="accent2"?l:m.hue==="near"?c:o)+K(r,-11,11),h=u+v/Mn.length*_n+K(r,-0.6,.6),y=K(r,m.reach[0],m.reach[1]),T=gt(.5+Math.cos(h)*y),x=gt(.5+Math.sin(h)*y),z=gt(K(r,0,180),1),O=gt(K(r,.62,1.5),3),g=gt(K(r,.62,1.5),3);return {id:`cav-${n}-${v}`,cx:T,cy:x,r:gt(K(r,m.r[0],m.r[1])),color:Ln(b,K(r,m.sat[0],m.sat[1]),K(r,m.light[0],m.light[1])),opacity:gt(K(r,m.opacity[0],m.opacity[1]),2),gradientTransform:`rotate(${z} ${T} ${x}) translate(${T} ${x}) scale(${O} ${g}) translate(${gt(-T)} ${gt(-x)})`}});return {id:n,background:d,spots:p,blur:gt(K(r,3.4,5.4),2),grain:gt(K(r,.09,.15),2)}}var On=createContext(null);function zn({children:t}){let[e,r]=useState(null),[n,o]=useState(""),[s,i]=useState([]),[a,l]=useState(0),[c,d]=useState(false),u=useRef([]),p=useCallback(()=>{for(let g of u.current)URL.revokeObjectURL(g.previewUrl);u.current=[],i([]);},[]),m=useCallback(()=>{r(null),o(""),p(),d(false);},[p]),v=useCallback(g=>{r({kind:"existing",annotationId:g}),o(""),p(),d(false);},[p]),f=useCallback(g=>{r({kind:"composer",...g}),o(""),p(),d(false);},[p]),b=useCallback(g=>u.current.length>=4?false:(u.current=[...u.current,g],i(u.current),true),[]),h=useCallback((g,N)=>{u.current=u.current.map(U=>U.localId===g?{...U,...N}:U),i(u.current);},[]),y=useCallback(g=>{let N=u.current.find(U=>U.localId===g);N&&URL.revokeObjectURL(N.previewUrl),u.current=u.current.filter(U=>U.localId!==g),i(u.current);},[]),T=useCallback(()=>{if(n.trim().length>0||u.current.length>0){l(g=>g+1);return}m();},[n,m]),x=useCallback(()=>{m();},[m]),z=n.trim().length>0||s.length>0,O=useMemo(()=>({active:e,draftText:n,draftAttachments:s,hasDraft:z,shakeNonce:a,confirmDiscardOpen:c,openExisting:v,openComposer:f,setDraftText:o,addDraftAttachment:b,updateDraftAttachment:h,removeDraftAttachment:y,clearDraftAttachments:p,attemptClose:T,forceClose:x,setConfirmDiscardOpen:d}),[e,n,s,z,a,c,v,f,b,h,y,p,T,x]);return jsx(On.Provider,{value:O,children:t})}function ft(){let t=use(On);if(!t)throw new Error("usePopoverStore must be used inside <PopoverProvider>");return t}var $n=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"]),as=new Set(["a","button","input","select","textarea"]),Bn={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"},Xt=40,ss=1500,Hn=200,ls=5,cs=10;function Vn(t){return $n.has(t.tagName.toLowerCase())}function zt(t,e){let r=t.replace(/\s+/g," ").trim();return r.length<=e?r:`${r.slice(0,e-1)}\u2026`}function oe(t){return `"${t}"`}function ds(t){let e="";for(let r of Array.from(t.childNodes))r.nodeType===3&&(e+=r.textContent??"");return e.replace(/\s+/g," ").trim()}function Ge(t){return (t.textContent??"").replace(/\s+/g," ").trim()}function us(t){return !(!t||t.length>40||/__[A-Za-z0-9]{4,}$/.test(t)||/_[a-z0-9]{4,}$/i.test(t)&&/[0-9]/.test(t)||/_[A-Za-z0-9]{5,}_/.test(t)||/^(sc-|css-)[A-Za-z0-9]{4,}$/.test(t)||/^[a-z]{2,}:[\w-]+$/.test(t)||/^-?(p|m|w|h|min|max|gap|space|inset|top|right|bottom|left)[trblxy]?-/.test(t)||/^-?(text|bg|border|ring|shadow|font|leading|tracking|rounded|opacity|z|flex|grid|col|row|order|justify|items|self|content|place|object)-/.test(t)||(t.match(/\d/g)?.length??0)/t.length>.4)}function Ae(t){let e=Array.from(t.classList),r=e.filter(us).slice(0,cs);return r.length>0?r:e.length>0?["container"]:[]}function Wn(t){let e=t.getAttribute("role")??void 0,r=t.getAttribute("aria-label")??void 0,n=t.getAttribute("tabindex"),o=n!==null&&n!==""?Number(n):void 0,s=t.tagName.toLowerCase(),i=as.has(s)||o!==void 0&&Number.isFinite(o)&&o>=0;if(e===void 0&&r===void 0&&o===void 0&&!i)return;let a={focusable:i};return e!==void 0&&(a.role=e),r!==void 0&&(a.ariaLabel=r),o!==void 0&&Number.isFinite(o)&&(a.tabIndex=o),a}function ps(t){let e=t.tagName.toLowerCase(),r=Bn[e]??e,n=t.getAttribute("aria-label");if(n)return `${r} ${oe(zt(n,Xt))}`;let o=t.placeholder;if(o)return `${r} ${oe(zt(o,Xt))}`;let s=t.getAttribute("name");if(s)return `${r}[name="${s}"]`;if(e==="input"){let i=t.type||"text";return `${r}[type=${i}]`}return r}function ms(t){let e=t.alt?.trim();return e?`img ${oe(zt(e,Xt))}`:"img"}function Xe(t){let e=t.tagName.toLowerCase();if(e==="img")return ms(t);if(e==="input"||e==="textarea"||e==="select")return ps(t);let r=Bn[e]??e,n=t.getAttribute("aria-label");if(n)return `${r} ${oe(zt(n,Xt))}`;if(e==="a"||e==="button"||$n.has(e)||e==="label"){let s=Ge(t);if(s)return `${r} ${oe(zt(s,Xt))}`;if(e==="a"||e==="button"){let i=t.querySelector("svg");if(i){let l=i.getAttribute("aria-label");return l?`${r} ${oe(zt(l,Xt))}`:`${r} (icon)`}let a=t.getAttribute("href");if(e==="a"&&a)return `link[href="${zt(a,Xt)}"]`}return r}if(t.id)return `${e}#${t.id}`;let o=Ae(t);return o.length>0?`${e}.${o[0]}`:e}function Un(t){let e=[],r=t,n=0;for(;r&&r.tagName.toLowerCase()!=="body"&&n<6;)e.unshift(Xe(r)),r=r.parentElement,n++;return r&&r.tagName.toLowerCase()==="body"&&e.unshift("body"),e.join(" > ").slice(0,ss)}function Yn(t){let e=Ge(t),r=t.parentElement;if(!r)return;let n=Ge(r);if(n){if(e&&n===e){let o=r.parentElement;if(!o)return;let s=Ge(o);return !s||s===e?void 0:zt(s,Hn)}return zt(n,Hn)}}function Gn(t){let e=t.parentElement;if(!e)return [];let r=[];for(let n of Array.from(e.children))if(n!==t&&n.tagName.toLowerCase()!=="script"&&(r.push(Xe(n)),r.length>=ls))break;return r}var gs=["role","aria-label","name"],fs=10,Fn=100;function Ke(t){let e={};for(let r of gs){let n=t.getAttribute(r);n!==null&&n!==""&&(e[r]=n.slice(0,Fn));}for(let r of Array.from(t.attributes)){if(Object.keys(e).length>=fs)break;r.name.startsWith("data-")&&r.value!==""&&(e[r.name]=r.value.slice(0,Fn));}return e}function qe(t){return ds(t)}function Xn(t){let e=t;for(;e&&e.nodeType!==1;)e=e.parentNode;return e}function Kn(t,e){return t.closest(`[${e}]`)!==null}var hs=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"]),bs={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"},vs={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"},xs={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 jn(t,e){let r=t.replace(/\s+/g," ").trim();return r.length<=e?r:`${r.slice(0,e-1).trim()}\u2026`}function ws(t){return `"${t}"`}function je(t){return (t.textContent??"").replace(/\s+/g," ").trim()}function qn(t){let e=t.replace(/[_-]+/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").trim();return e?e.charAt(0).toUpperCase()+e.slice(1):""}function dt(t,e){let r=e?.trim();return r?`${t}: ${ws(jn(r,48))}`:t}function ys(t){let e=t.trim(),r=e.match(/^(.+?)\s+"(.+)"$/);return r?{base:r[1]??e,text:r[2]}:{base:e}}function ks(t){let e=t.toLowerCase().replace(/\[[\s\S]*$/,"").trim(),r=xs[e];if(r)return r;let n=t.match(/^[a-z][\w-]*/i)?.[0]?.toLowerCase();return n?/^h[1-6]$/.test(n)?"Heading":vs[n]??"Area":"Area"}function Cs(t){let e=t.getAttribute("aria-label");if(e)return dt("Field",e);let r=t.placeholder;if(r)return dt("Field",r);let n=t.getAttribute("name");if(n)return dt("Field",qn(n));if(t.tagName.toLowerCase()==="input"){let o=t.type||"text";if(o!=="text")return dt("Field",qn(o))}return "Field"}function Se(t,e){if(e?.trim())return dt("Selected text",e);let r=t.tagName.toLowerCase(),n=t.getAttribute("aria-label");if(r==="button")return dt("Button",n??je(t));if(r==="a")return dt("Link",n??je(t));if(r==="input"||r==="textarea"||r==="select")return Cs(t);if(r==="img"){let s=t.alt;return dt("Image",s)}if(r==="svg")return dt("Icon",n);if(/^h[1-6]$/.test(r))return dt("Heading",je(t));if(hs.has(r))return dt("Text",je(t));let o=bs[r];return dt(o||"Area",n)}function Zn(t){if(t.targetLabel?.trim())return jn(t.targetLabel,120);if(t.selectedText?.trim())return dt("Selected text",t.selectedText);let e=t.element?.trim()||t.elementPath?.trim();if(!e)return "Annotation";let r=ys(e.split(">").at(-1)??e);return dt(ks(r.base),r.text)}var Jn="patch-capture-cursor-style";function As(t){let e=`:not([${t}]):not([${t}] *)`,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}${e}`).join(`,
2
+ import {LazyMotion,domAnimation,AnimatePresence,useReducedMotion,m}from'motion/react';import {createContext,useMemo,useEffect,Component,useState,useRef,useCallback,useLayoutEffect,use,createElement,useId}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {createPortal}from'react-dom';function Jr(t){if(t.length<12)return null;if(t[0]===255&&t[1]===216&&t[2]===255)return "image/jpeg";if(t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71)return "image/png";let e=(r,n)=>n.split("").every((o,s)=>t[r+s]===o.charCodeAt(0));return e(0,"RIFF")&&e(8,"WEBP")?"image/webp":null}var ha=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 ba(t,e){return t.length<=e?t:`${t.slice(0,e-1).trim()}\u2026`}function Qr(t){return t.replace(/\s+/g," ").trim()}function hr(t){return ha.has(Qr(t))}function va(t){return t.length<2||t.startsWith("_")?false:/^[A-Z]/.test(t)}function tn(t){if(!t)return null;let e=[],r=t.matchAll(/<([^<>]+)>/g);for(let n of r){let o=Qr(n[1]??"");!o||hr(o)||va(o)&&e[e.length-1]!==o&&e.push(o);}return e.length===0?null:ba(e.map(n=>`<${n}>`).join(" "),1e3)}var en="seed:";function We(t){return t?t.startsWith(en)?{url:null,seed:t.slice(en.length)||null}:/^https?:\/\//i.test(t)?{url:t,seed:null}:{url:null,seed:t}:{url:null,seed:null}}var br=[6,20,34,92,120,140,158,174,190,206,220,234,252,270,286,300,318,336,350],rn=[{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]}],nn=Math.PI*2;function xa(t){let e=2166136261;for(let r=0;r<t.length;r++)e^=t.charCodeAt(r),e=Math.imul(e,16777619);return e>>>0}function wa(t){return ()=>{t+=1831565813;let e=t;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}function Z(t,e,r){return e+t()*(r-e)}function bt(t,e=3){let r=10**e;return Math.round(t*r)/r}function on(t,e,r){return `hsl(${bt((t%360+360)%360,1)} ${bt(e,1)}% ${bt(r,1)}%)`}function an(t){let e=xa(t?.trim()||"patch-client"),r=wa(e),n=e.toString(36),o=(br[e%br.length]??br[0])+Z(r,-10,10),s=r()<.5?-1:1,i=r()<.5?-1:1,a=o+i*Z(r,52,116),l=o-i*Z(r,26,66),c=o+s*Z(r,12,38),d=on(o+s*Z(r,0,14),Z(r,80,92),Z(r,44,54)),u=Z(r,0,nn),p=rn.map((m,x)=>{let b=(m.hue==="accent"?a:m.hue==="accent2"?l:m.hue==="near"?c:o)+Z(r,-11,11),h=u+x/rn.length*nn+Z(r,-0.6,.6),k=Z(r,m.reach[0],m.reach[1]),E=bt(.5+Math.cos(h)*k),w=bt(.5+Math.sin(h)*k),H=bt(Z(r,0,180),1),L=bt(Z(r,.62,1.5),3),g=bt(Z(r,.62,1.5),3);return {id:`cav-${n}-${x}`,cx:E,cy:w,r:bt(Z(r,m.r[0],m.r[1])),color:on(b,Z(r,m.sat[0],m.sat[1]),Z(r,m.light[0],m.light[1])),opacity:bt(Z(r,m.opacity[0],m.opacity[1]),2),gradientTransform:`rotate(${H} ${E} ${w}) translate(${E} ${w}) scale(${L} ${g}) translate(${bt(-E)} ${bt(-w)})`}});return {id:n,background:d,spots:p,blur:bt(Z(r,3.4,5.4),2),grain:bt(Z(r,.09,.15),2)}}function Vt(t){if(t.length<=1||!t.endsWith("/"))return t;try{let e=new URL(t);if(e.pathname==="/"&&t.endsWith("/"))return `${e.origin}${e.search}${e.hash}`}catch{}return t.slice(0,-1)}function ot(t){try{let e=new URL(t);return Vt(`${e.origin}${e.pathname}`)}catch{return Vt(t)}}var vr="patch:locationchange",sn="__patchHistoryPatched";function ya(t){let e=t.history;if(e[sn])return;e[sn]=true;let r=()=>t.dispatchEvent(new Event(vr)),{pushState:n,replaceState:o}=e;try{e.pushState=function(...s){let i=n.apply(this,s);return r(),i},e.replaceState=function(...s){let i=o.apply(this,s);return r(),i};}catch{}}function ln(t,e){ya(t);let r=()=>e();return t.addEventListener("popstate",r),t.addEventListener("hashchange",r),t.addEventListener(vr,r),()=>{t.removeEventListener("popstate",r),t.removeEventListener("hashchange",r),t.removeEventListener(vr,r);}}var Et={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"}},cn=["desktop","tablet","mobile"];function ee(t){let e=Et[t];return e.width===null||e.height===null?e.label:`${e.label} (${e.width}px \xD7 ${e.height}px)`}function dn(t,e){let r=Et[t];return {width:r.width??e.width,height:r.height??e.height}}var Ca=32,Aa=32,Sa=3e3,mn="cubic-bezier(0.16, 1, 0.3, 1)",Ye=[.22,.61,.36,1],gn=.3,fn=.5,Ta=.34,Ea=.5,Ra=.24,Pa=.22,hn=.12,Ia=.42,bn=.2,Na=200,Ma=260,_a=70,La=180,Da=260,Oa=8,za=4,Ha="#d9d9dd",$a=30,Fa=["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 Ge(t,e,r){let n=Math.max(320,t.innerWidth-Ca*2),o=Math.max(320,t.innerHeight-Aa*2);return Math.min(1,n/e,o/r)}function Ba(t){try{return !!(t.contentWindow&&t.contentDocument?.body)}catch{return false}}function vn({src:t,viewport:e,overlayWindow:r,onFrameElement:n,onReadyChange:o,onBlockedChange:s}){let i=useReducedMotion(),a=e.width??r.innerWidth,l=e.height??r.innerHeight,c=e.viewport,d=`${c}:${a}:${l}`,u=!!r.happyDOM?.settings?.disableIframePageLoading,[p,m$1]=useState(()=>({viewport:c,width:a,height:l,scale:Ge(r,a,l)})),[x,f]=useState("stable"),[b,h]=useState(false),[k,E]=useState(false),w=useRef(false),H=useRef(null),g=`${p.viewport}:${p.width}:${p.height}`!==d,U=b&&!k&&!(g||x==="cover"||x==="resize"),ct=b&&!k&&x==="stable"&&!g,dt=useCallback(v=>{H.current=v,n(v);},[n]),ht=useCallback(()=>{let v=H.current;if(!v||!Ba(v)){w.current=false,h(false),E(true);return}w.current=true,h(true),E(false);},[]),ut=useCallback(()=>{m$1(v=>{let $=Ge(r,v.width,v.height);return v.scale===$?v:{...v,scale:$}});},[r]);useEffect(()=>(ut(),r.addEventListener("resize",ut),()=>r.removeEventListener("resize",ut)),[r,ut]),useEffect(()=>{w.current=false,h(false),E(false);let v=r.setTimeout(()=>{w.current||E(true);},Sa);return ()=>r.clearTimeout(v)},[t,r]),useEffect(()=>{if(i){g&&m$1({viewport:c,width:a,height:l,scale:Ge(r,a,l)}),x!=="stable"&&f("stable");return}switch(x){case "stable":{g&&f("cover");return}case "cover":{let v=r.setTimeout(()=>f("resize"),_a);return ()=>r.clearTimeout(v)}case "resize":{g&&m$1({viewport:c,width:a,height:l,scale:Ge(r,a,l)});let v=r.setTimeout(()=>f("reveal"),La);return ()=>r.clearTimeout(v)}case "reveal":{let v=r.setTimeout(()=>f("stable"),Da);return ()=>r.clearTimeout(v)}}},[x,g,i,r,c,a,l]),useEffect(()=>{o(ct);},[ct,o]),useEffect(()=>{s(k);},[k,s]);let pt=i?{duration:0}:{duration:Ra,ease:Ye},rt=i?{duration:0}:{duration:Pa,ease:Ye,delay:bn*.5},j=i?{duration:0}:{duration:bn,ease:Ye},A=i?{duration:0}:{opacity:{duration:Ia,ease:Ye,delay:hn},scale:{type:"spring",bounce:Ta,duration:Ea,delay:hn},width:{type:"spring",bounce:gn,duration:fn},height:{type:"spring",bounce:gn,duration:fn}},R=(U?Ma:Na)/1e3,D=i?void 0:`opacity ${R}s ${mn}, filter ${R}s ${mn}`,G=p.width*p.scale,W=p.height*p.scale;return jsx(m.div,{"data-patch-preview-backdrop":"",initial:{opacity:0},animate:{opacity:1,transition:pt},exit:{opacity:0,transition:rt},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(m.div,{initial:i?{opacity:0,width:G,height:W}:{opacity:0,scale:.8,width:G,height:W},animate:{opacity:1,scale:1,width:G,height:W},exit:i?{opacity:0}:{opacity:0,scale:.92,transition:j},transition:A,"data-patch-preview-shell":"",className:"relative overflow-hidden bg-white",style:{boxSizing:"content-box",border:`${za}px solid ${Ha}`,borderRadius:$a,boxShadow:Fa,willChange:"width, height"},children:[jsx("div",{"aria-hidden":!U,className:"absolute top-0 left-0 origin-top-left",style:{width:p.width,height:p.height,transform:`scale(${p.scale})`,opacity:U?1:0,filter:i||U?"none":`blur(${Oa}px)`,transition:D,pointerEvents:U?"auto":"none",willChange:"opacity, filter"},children:jsx("iframe",{ref:dt,"data-patch-preview-frame":"","data-patch-preview-src":t,title:`${e.label} preview`,tabIndex:U?0:-1,src:u?void 0:t,srcDoc:u?"<!doctype html><html><body></body></html>":void 0,onLoad:ht,className:"block bg-white",style:{width:p.width,height:p.height,border:0}})}),jsx(Va,{visible:k})]})})}function Va({visible:t}){return t?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 kn=createContext(null),Cn=createContext(null),An="__patch_preview";function Sn(){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:()=>Vt(`${window.location.origin}${window.location.pathname}`),targetPointToOverlay:t=>({...t}),targetRectToOverlay:t=>({...t}),eventTargetElement:t=>t instanceof window.Element?t:null}}function Ga(t){let e=new URL(t.location.href);return e.searchParams.set(An,"1"),e.toString()}function Tn(t=window){try{return new URL(t.location.href).searchParams.get(An)==="1"}catch{return false}}function Xa(t,e,r){let n=e.contentWindow,o=e.contentDocument;if(!n||!o)return null;function s(){return e.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:t.overlayWindow,overlayDocument:t.overlayDocument,getTargetViewport:()=>r,getOverlayViewport:t.getOverlayViewport,getTargetScrollY:()=>n.scrollY,getPageUrl:()=>Vt(`${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 En(t,e){let r=t.ResizeObserver??ResizeObserver;return new r(e)}function Rn({children:t}){let e=useMemo(()=>Sn(),[]),[r,n]=useState("desktop"),[o,s]=useState(null),[i,a]=useState(false),[l,c]=useState(false),[d,u]=useState(false),p=r!=="desktop",m=p||d,x=Et[r],f=x.width&&x.height?{width:x.width,height:x.height}:null;useEffect(()=>{a(false),c(false);},[r]);let b=useRef(p);useEffect(()=>{b.current&&!p?u(true):!b.current&&p&&u(false),b.current=p;},[p]);let h=useMemo(()=>e?!p||!i||l||!o||!f?e:Xa(e,o,f)??e:null,[l,o,i,p,f,e]),k=useMemo(()=>({activeViewport:r,setActiveViewport:n,isPreviewing:m,previewReady:m?p&&i&&!l:true,previewBlocked:p&&l}),[r,l,i,p,m]),E=useMemo(()=>e?Ga(e.targetWindow):"",[e]);return !h||!e?null:jsx(Cn.Provider,{value:k,children:jsxs(kn.Provider,{value:h,children:[t,jsx(AnimatePresence,{onExitComplete:()=>u(false),children:p&&f?jsx(vn,{src:E,viewport:x,overlayWindow:e.overlayWindow,onFrameElement:s,onReadyChange:a,onBlockedChange:c}):null})]})})}function vt(){let t=use(kn),e=useMemo(()=>Sn(),[]);if(t)return t;if(e)return e;throw new Error("useTargetSurface must run in a browser document")}function ie(){let t=use(Cn),[e,r]=useState("desktop"),n=useMemo(()=>({activeViewport:e,setActiveViewport:r,isPreviewing:false,previewReady:true,previewBlocked:false}),[e]);return t??n}var qa="X-Patch-Client-Id",ja="X-Patch-Client-Secret";function Ct(t,e){return {...e?{"Content-Type":"application/json"}:{},Authorization:`Bearer ${t.token}`,...t.clientUserId?{[qa]:t.clientUserId}:{},...t.clientSecret?{[ja]:t.clientSecret}:{}}}async function Mt(t,e){try{let r=await fetch(t,e);if(!r.ok)return null;let n=await r.text();return n?JSON.parse(n):{}}catch{return null}}async function Za(t,e){try{let r=await fetch(t,e),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 Pn(t){return {async listAnnotations(e){let r=new URLSearchParams;e?.viewport&&r.set("viewport",e.viewport),e?.url&&r.set("url",e.url);let n=r.toString(),o=new Headers(Ct(t,false));e?.etag&&o.set("If-None-Match",e.etag);try{let s=await fetch(`${t.apiBase}/api/widget/annotations${n?`?${n}`:""}`,{method:"GET",credentials:"include",cache:"no-store",headers:o});if(s.status===304)return {status:"not-modified"};if(!s.ok)return {status:"error"};let i=s.headers.get("ETag"),a=await s.text();return {status:"ok",annotations:(a?JSON.parse(a):{}).annotations??[],etag:i}}catch{return {status:"error"}}},async listRoster(){return (await Mt(`${t.apiBase}/api/widget/roster`,{method:"GET",credentials:"include",headers:Ct(t,false)}))?.entries??[]},async fetchMe(){try{let e=await fetch(`${t.apiBase}/api/widget/me`,{method:"GET",credentials:"include",headers:Ct(t,!1)});if(e.status===401||e.status===403)return {status:"unauthorized"};if(!e.ok)return {status:"error"};let r=await e.text();return {status:"ok",me:r?JSON.parse(r):{}}}catch{return {status:"error"}}},async postIdentity(e){let r=await Mt(`${t.apiBase}/api/widget/identity`,{method:"POST",credentials:"include",headers:Ct(t,true),body:JSON.stringify(e)});if(!r)return null;let n=r.secret??t.clientSecret;return n?{clientUserId:r.id,name:r.name,email:r.email,avatarSeed:r.avatarSeed??r.id,secret:n}:null},async createAnnotation(e){return Mt(`${t.apiBase}/api/widget/annotations`,{method:"POST",credentials:"include",headers:Ct(t,true),body:JSON.stringify(e)})},async reply(e,r){return Mt(`${t.apiBase}/api/widget/annotations/${e}/reply`,{method:"POST",credentials:"include",headers:Ct(t,true),body:JSON.stringify(r)})},async uploadAttachment(e,r){let n=new URLSearchParams({kind:r.kind,width:String(r.width),height:String(r.height)});return (await Mt(`${t.apiBase}/api/widget/uploads?${n}`,{method:"POST",credentials:"include",headers:{...Ct(t,false),"Content-Type":e.type},body:e}))?.attachment??null},async deleteAnnotation(e){return Mt(`${t.apiBase}/api/widget/annotations/${e}`,{method:"DELETE",credentials:"include",headers:Ct(t,false)})},async deleteMessage(e,r){return Mt(`${t.apiBase}/api/widget/annotations/${e}/messages/${r}`,{method:"DELETE",credentials:"include",headers:Ct(t,false)})},async kickoff(e,r){return Za(`${t.apiBase}/api/widget/annotations/${e}/kickoff`,{method:"POST",credentials:"include",headers:Ct(t,true),body:JSON.stringify(r)})},async resolve(e){return Mt(`${t.apiBase}/api/widget/annotations/${e}/resolve`,{method:"POST",credentials:"include",headers:Ct(t,true)})},async reopen(e){return Mt(`${t.apiBase}/api/widget/annotations/${e}/reopen`,{method:"POST",credentials:"include",headers:Ct(t,true)})},async reportAnchorStatuses(e){e.length!==0&&await Mt(`${t.apiBase}/api/widget/anchor-report`,{method:"POST",credentials:"include",headers:Ct(t,true),body:JSON.stringify({reports:e})});}}}var kr="patch.clientIdentity",In="patch.clientAvatarSeed";function Cr(){if(typeof window>"u")return {};try{let t=window.localStorage.getItem(kr);if(!t)return {};let e=JSON.parse(t);return e&&typeof e=="object"?e:{}}catch{return {}}}function Ar(t){let e=Cr()[t];return e?.secret?e:null}function Sr(t,e){if(!(typeof window>"u"))try{let r=Cr();r[t]=e,window.localStorage.setItem(kr,JSON.stringify(r));}catch{}}function Nn(t){if(!(typeof window>"u"))try{let e=Cr();delete e[t],window.localStorage.setItem(kr,JSON.stringify(e));}catch{}}function Ja(){if(typeof window>"u")return {};try{let t=window.localStorage.getItem(In);if(!t)return {};let e=JSON.parse(t);return e&&typeof e=="object"?e:{}}catch{return {}}}function yr(){let t=globalThis.crypto;return `client-avatar:${typeof t?.randomUUID=="function"?t.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}`}function Mn(t){if(typeof window>"u")return yr();try{let e=Ja(),r=e[t];if(r)return r;let n=yr();return e[t]=n,window.localStorage.setItem(In,JSON.stringify(e)),n}catch{return yr()}}var es=2e4,Ln=createContext(null);function rs(t,e){let r=new Map(t.map(i=>[i.id,i])),n=new Set(e.map(i=>i.id)),o=e.map(i=>{let a=r.get(i.id);if(!a)return i;let l=new Set(i.thread.map(u=>u.id)),c=a.thread.filter(u=>u.deliveryStatus&&!l.has(u.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 u=i.latestRun?Date.parse(i.latestRun.createdAt):Number.NaN,p=Date.parse(a.latestRun.createdAt);i.latestRun!=null&&(Number.isNaN(p)||Number.isNaN(u)||u>=p)||(d={...d,latestRun:a.latestRun,optimisticAction:a.optimisticAction});}return d}),s=t.filter(i=>(i.deliveryStatus||i.optimisticAction)&&!n.has(i.id));return [...o,...s]}function Dn({projectToken:t,apiBase:e,children:r}){let n=vt(),{activeViewport:o,setActiveViewport:s}=ie(),[i,a]=useState(()=>typeof window>"u"?null:Ar(t)),[l]=useState(()=>typeof window>"u"?"client-avatar:ssr":Mn(t)),[c,d]=useState(null),[u,p]=useState("client"),[m,x]=useState(null),[f,b]=useState([]),[h,k]=useState(null),[E,w]=useState([]),[H,L]=useState(false),[g,I]=useState(null),U=useRef(g);U.current=g;let ct=useRef(o);ct.current=o;let dt=h===o,ht=useMemo(()=>Pn({apiBase:e,token:t,clientUserId:i?.clientUserId,clientSecret:i?.secret}),[e,t,i?.clientUserId,i?.secret]),ut=useRef(ht);ut.current=ht;let pt=useRef(0),rt=useRef(new Map),j=useCallback(async()=>{let S=o,P=n.getPageUrl(),N=`${S}|${P}`,K=++pt.current,tt=await ut.current.listAnnotations({viewport:S==="desktop"?void 0:S,url:P,etag:rt.current.get(N)??null});if(K!==pt.current||S!==ct.current||tt.status!=="ok")return;tt.etag?rt.current.set(N,tt.etag):rt.current.delete(N);let It=tt.annotations.filter(Tt=>ot(Tt.payload.url)===P);b(Tt=>rs(Tt,It)),k(S);},[o,n]),A=useRef(j);A.current=j,useEffect(()=>{rt.current.clear();},[ht]),useEffect(()=>{let S=false;return (async()=>{let P=await ut.current.fetchMe();if(S)return;if(P.status==="unauthorized"){I(false),L(true);return}let N=P.status==="ok"?P.me:null;if(N?.active===false){I(false),L(true);return}if(I(true),N?.studio)d(N.studio),p("studio"),x(N.agentRunReadiness??{ready:true,message:null});else if(d(null),p("client"),x(null),N?.client){let K=Ar(t);if(K?.secret){let tt={clientUserId:N.client.id,name:N.client.name,email:N.client.email,avatarSeed:N.client.avatarSeed,secret:K.secret};a(tt),Sr(t,tt);}}await A.current(),S||L(true);})(),()=>{S=true;}},[t]),useEffect(()=>{!H||!g||j();},[H,g,j]),useEffect(()=>{if(!g)return;let{overlayDocument:S,overlayWindow:P}=n,N=P.setInterval(()=>{S.visibilityState==="visible"&&j();},es),K=()=>{S.visibilityState==="visible"&&j();};return S.addEventListener("visibilitychange",K),()=>{P.clearInterval(N),S.removeEventListener("visibilitychange",K);}},[g,j,n]),useEffect(()=>{if(g)return ln(n.targetWindow,()=>{let S=n.getPageUrl();b(P=>P.filter(N=>ot(N.payload.url)===S)),A.current();})},[g,n]);let R=useCallback(async S=>(Sr(t,S),a(S),S),[t]),D=useCallback(()=>{a(null),Nn(t);},[t]),G=useCallback(S=>{w(P=>[...P.filter(N=>N.tempId!==S.tempId),S]);},[]),W=useCallback(S=>{w(P=>P.filter(N=>N.tempId!==S));},[]),v=useCallback(S=>{b(P=>{let N=P.findIndex(tt=>tt.id===S.id);if(N===-1)return [...P,S];let K=P.slice();return K[N]=S,K});},[]),$=useCallback((S,P)=>{b(N=>{let K=false,tt=N.flatMap(It=>{if(It.id!==S)return [It];K=true;let Tt=P(It);return Tt?[Tt]:[]});return K?tt:N});},[]),O=useCallback((S,P)=>{b(N=>N.map(K=>K.id===S?{...K,id:P,deliveryStatus:"sent"}:K));},[]),X=useMemo(()=>({apiClient:ht,active:g,ready:H,viewerKind:u,agentRunReadiness:m,activeViewport:o,clientAvatarSeed:l,identity:i,studio:c,annotations:f,annotationsReady:dt,ephemerals:E,refresh:j,setActiveViewport:s,setIdentity:R,signOut:D,addEphemeral:G,removeEphemeral:W,applyAnnotationUpdate:v,updateAnnotation:$,replaceAnnotationId:O}),[ht,g,H,u,m,o,l,i,c,f,dt,E,j,s,R,D,G,W,v,$,O]);return jsx(Ln.Provider,{value:X,children:r})}function it(){let t=use(Ln);if(!t)throw new Error("useAnnotationsStore must be used inside <AnnotationsProvider>");return t}var On=createContext(null);function zn({children:t}){let[e,r]=useState(null),[n,o]=useState(""),[s,i]=useState([]),[a,l]=useState(0),[c,d]=useState(false),u=useRef([]),p=useCallback(()=>{for(let g of u.current)URL.revokeObjectURL(g.previewUrl);u.current=[],i([]);},[]),m=useCallback(()=>{r(null),o(""),p(),d(false);},[p]),x=useCallback(g=>{r({kind:"existing",annotationId:g}),o(""),p(),d(false);},[p]),f=useCallback(g=>{r({kind:"composer",...g}),o(""),p(),d(false);},[p]),b=useCallback(g=>u.current.length>=4?false:(u.current=[...u.current,g],i(u.current),true),[]),h=useCallback((g,I)=>{u.current=u.current.map(U=>U.localId===g?{...U,...I}:U),i(u.current);},[]),k=useCallback(g=>{let I=u.current.find(U=>U.localId===g);I&&URL.revokeObjectURL(I.previewUrl),u.current=u.current.filter(U=>U.localId!==g),i(u.current);},[]),E=useCallback(()=>{if(n.trim().length>0||u.current.length>0){l(g=>g+1);return}m();},[n,m]),w=useCallback(()=>{m();},[m]),H=n.trim().length>0||s.length>0,L=useMemo(()=>({active:e,draftText:n,draftAttachments:s,hasDraft:H,shakeNonce:a,confirmDiscardOpen:c,openExisting:x,openComposer:f,setDraftText:o,addDraftAttachment:b,updateDraftAttachment:h,removeDraftAttachment:k,clearDraftAttachments:p,attemptClose:E,forceClose:w,setConfirmDiscardOpen:d}),[e,n,s,H,a,c,x,f,b,h,k,p,E,w]);return jsx(On.Provider,{value:L,children:t})}function xt(){let t=use(On);if(!t)throw new Error("usePopoverStore must be used inside <PopoverProvider>");return t}var Fn=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"]),cs=new Set(["a","button","input","select","textarea"]),Bn={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"},qt=40,ds=1500,Hn=200,us=5,ps=10;function Vn(t){return Fn.has(t.tagName.toLowerCase())}function $t(t,e){let r=t.replace(/\s+/g," ").trim();return r.length<=e?r:`${r.slice(0,e-1)}\u2026`}function se(t){return `"${t}"`}function ms(t){let e="";for(let r of Array.from(t.childNodes))r.nodeType===3&&(e+=r.textContent??"");return e.replace(/\s+/g," ").trim()}function Xe(t){return (t.textContent??"").replace(/\s+/g," ").trim()}function gs(t){return !(!t||t.length>40||/__[A-Za-z0-9]{4,}$/.test(t)||/_[a-z0-9]{4,}$/i.test(t)&&/[0-9]/.test(t)||/_[A-Za-z0-9]{5,}_/.test(t)||/^(sc-|css-)[A-Za-z0-9]{4,}$/.test(t)||/^[a-z]{2,}:[\w-]+$/.test(t)||/^-?(p|m|w|h|min|max|gap|space|inset|top|right|bottom|left)[trblxy]?-/.test(t)||/^-?(text|bg|border|ring|shadow|font|leading|tracking|rounded|opacity|z|flex|grid|col|row|order|justify|items|self|content|place|object)-/.test(t)||(t.match(/\d/g)?.length??0)/t.length>.4)}function Re(t){let e=Array.from(t.classList),r=e.filter(gs).slice(0,ps);return r.length>0?r:e.length>0?["container"]:[]}function Wn(t){let e=t.getAttribute("role")??void 0,r=t.getAttribute("aria-label")??void 0,n=t.getAttribute("tabindex"),o=n!==null&&n!==""?Number(n):void 0,s=t.tagName.toLowerCase(),i=cs.has(s)||o!==void 0&&Number.isFinite(o)&&o>=0;if(e===void 0&&r===void 0&&o===void 0&&!i)return;let a={focusable:i};return e!==void 0&&(a.role=e),r!==void 0&&(a.ariaLabel=r),o!==void 0&&Number.isFinite(o)&&(a.tabIndex=o),a}function fs(t){let e=t.tagName.toLowerCase(),r=Bn[e]??e,n=t.getAttribute("aria-label");if(n)return `${r} ${se($t(n,qt))}`;let o=t.placeholder;if(o)return `${r} ${se($t(o,qt))}`;let s=t.getAttribute("name");if(s)return `${r}[name="${s}"]`;if(e==="input"){let i=t.type||"text";return `${r}[type=${i}]`}return r}function hs(t){let e=t.alt?.trim();return e?`img ${se($t(e,qt))}`:"img"}function Ke(t){let e=t.tagName.toLowerCase();if(e==="img")return hs(t);if(e==="input"||e==="textarea"||e==="select")return fs(t);let r=Bn[e]??e,n=t.getAttribute("aria-label");if(n)return `${r} ${se($t(n,qt))}`;if(e==="a"||e==="button"||Fn.has(e)||e==="label"){let s=Xe(t);if(s)return `${r} ${se($t(s,qt))}`;if(e==="a"||e==="button"){let i=t.querySelector("svg");if(i){let l=i.getAttribute("aria-label");return l?`${r} ${se($t(l,qt))}`:`${r} (icon)`}let a=t.getAttribute("href");if(e==="a"&&a)return `link[href="${$t(a,qt)}"]`}return r}if(t.id)return `${e}#${t.id}`;let o=Re(t);return o.length>0?`${e}.${o[0]}`:e}function Un(t){let e=[],r=t,n=0;for(;r&&r.tagName.toLowerCase()!=="body"&&n<6;)e.unshift(Ke(r)),r=r.parentElement,n++;return r&&r.tagName.toLowerCase()==="body"&&e.unshift("body"),e.join(" > ").slice(0,ds)}function Yn(t){let e=Xe(t),r=t.parentElement;if(!r)return;let n=Xe(r);if(n){if(e&&n===e){let o=r.parentElement;if(!o)return;let s=Xe(o);return !s||s===e?void 0:$t(s,Hn)}return $t(n,Hn)}}function Gn(t){let e=t.parentElement;if(!e)return [];let r=[];for(let n of Array.from(e.children))if(n!==t&&n.tagName.toLowerCase()!=="script"&&(r.push(Ke(n)),r.length>=us))break;return r}var bs=["role","aria-label","name"],vs=10,$n=100;function qe(t){let e={};for(let r of bs){let n=t.getAttribute(r);n!==null&&n!==""&&(e[r]=n.slice(0,$n));}for(let r of Array.from(t.attributes)){if(Object.keys(e).length>=vs)break;r.name.startsWith("data-")&&r.value!==""&&(e[r.name]=r.value.slice(0,$n));}return e}function je(t){return ms(t)}function Xn(t){let e=t;for(;e&&e.nodeType!==1;)e=e.parentNode;return e}function Kn(t,e){return t.closest(`[${e}]`)!==null}var xs=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"]),ws={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"},ys={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"},ks={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 jn(t,e){let r=t.replace(/\s+/g," ").trim();return r.length<=e?r:`${r.slice(0,e-1).trim()}\u2026`}function Cs(t){return `"${t}"`}function Ze(t){return (t.textContent??"").replace(/\s+/g," ").trim()}function qn(t){let e=t.replace(/[_-]+/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").trim();return e?e.charAt(0).toUpperCase()+e.slice(1):""}function gt(t,e){let r=e?.trim();return r?`${t}: ${Cs(jn(r,48))}`:t}function As(t){let e=t.trim(),r=e.match(/^(.+?)\s+"(.+)"$/);return r?{base:r[1]??e,text:r[2]}:{base:e}}function Ss(t){let e=t.toLowerCase().replace(/\[[\s\S]*$/,"").trim(),r=ks[e];if(r)return r;let n=t.match(/^[a-z][\w-]*/i)?.[0]?.toLowerCase();return n?/^h[1-6]$/.test(n)?"Heading":ys[n]??"Area":"Area"}function Ts(t){let e=t.getAttribute("aria-label");if(e)return gt("Field",e);let r=t.placeholder;if(r)return gt("Field",r);let n=t.getAttribute("name");if(n)return gt("Field",qn(n));if(t.tagName.toLowerCase()==="input"){let o=t.type||"text";if(o!=="text")return gt("Field",qn(o))}return "Field"}function Pe(t,e){if(e?.trim())return gt("Selected text",e);let r=t.tagName.toLowerCase(),n=t.getAttribute("aria-label");if(r==="button")return gt("Button",n??Ze(t));if(r==="a")return gt("Link",n??Ze(t));if(r==="input"||r==="textarea"||r==="select")return Ts(t);if(r==="img"){let s=t.alt;return gt("Image",s)}if(r==="svg")return gt("Icon",n);if(/^h[1-6]$/.test(r))return gt("Heading",Ze(t));if(xs.has(r))return gt("Text",Ze(t));let o=ws[r];return gt(o||"Area",n)}function Zn(t){if(t.targetLabel?.trim())return jn(t.targetLabel,120);if(t.selectedText?.trim())return gt("Selected text",t.selectedText);let e=t.element?.trim()||t.elementPath?.trim();if(!e)return "Annotation";let r=As(e.split(">").at(-1)??e);return gt(Ss(r.base),r.text)}var Jn="patch-capture-cursor-style";function Es(t){let e=`:not([${t}]):not([${t}] *)`,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}${e}`).join(`,
3
3
  `);return ["html, body { cursor: crosshair !important; }",`body *${e} { cursor: crosshair !important; }`,`${r} { cursor: text !important; }`].join(`
4
- `)}function Ss(t,e){let r=t.targetDocument,n=r.getElementById(Jn);n&&n.remove();let o=r.createElement("style");return o.id=Jn,o.setAttribute(e,""),o.textContent=As(e),r.head.appendChild(o),o}function Sr(t,e,r){let n=t.eventTargetElement(e);return n?n.closest(`[${r}]`)!==null:false}var ie=1.5,Ts="#0287FE",Es="rgba(2, 135, 254, 0.032)";function Rs(t){let e=t.split(" ")[0]??"",r=Number.parseFloat(e);return Number.isFinite(r)?Math.min(8,Math.max(3,r)):6}function Ps(t,e){let r=t.targetDocument,n=r.createElement("div");n.setAttribute(e,""),Object.assign(n.style,{position:"fixed",pointerEvents:"none",border:`${ie}px solid ${Ts}`,background:Es,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(e,""),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-ie}px`,n.style.left=`${a.left-ie}px`,n.style.width=`${a.width+ie*2}px`,n.style.height=`${a.height+ie*2}px`,n.style.borderRadius=`${Rs(t.targetWindow.getComputedStyle(i).borderRadius)+ie}px`,i!==s&&(o.textContent=Se(i),s=i),o.style.display="block";let l=a.right+8,c=Math.max(8,a.top),d=t.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 Qn(t){let{internalAttr:e,onClick:r,surface:n}=t,o=n.targetDocument,s=Ss(n,e),i=Ps(n,e),a=false,l=v=>{let f=v;if(Sr(n,f.target,e))return;let b=n.eventTargetElement(f.target);b&&Vn(b)||(f.preventDefault(),f.stopPropagation());},c=l,d=l,u=v=>{let f=v;Sr(n,f.target,e)||(f.preventDefault(),f.stopPropagation(),!a&&r(f));},p=v=>{let f=v;if(a)return;let b=n.eventTargetElement(f.target);if(!b){i.hide();return}if(Sr(n,b,e)){i.hide();return}let h=b.tagName.toLowerCase();if(h==="html"||h==="body"){i.hide();return}i.update(b);},m=v=>{v.relatedTarget||i.hide();};return o.addEventListener("mousedown",c,true),o.addEventListener("mouseup",d,true),o.addEventListener("click",u,true),o.addEventListener("mousemove",p,true),o.addEventListener("mouseout",m,true),{exit(){s.remove(),i.destroy(),o.removeEventListener("mousedown",c,true),o.removeEventListener("mouseup",d,true),o.removeEventListener("click",u,true),o.removeEventListener("mousemove",p,true),o.removeEventListener("mouseout",m,true);},pause(){a=true,i.hide();},resume(){a=false;}}}function to(t){let{clickTarget:e,selection:r}=t,n=r&&!r.isCollapsed?r.toString().trim():"";if(n&&r&&r.rangeCount>0){let o=r.getRangeAt(0),s=Xn(o.commonAncestorContainer);if(s)return {kind:"element",element:s,rect:s.getBoundingClientRect(),selectedText:n,clickTarget:e}}return {kind:"element",element:e,rect:e.getBoundingClientRect(),clickTarget:e}}var Ls="data-patch-internal",ro=createContext(null),eo=0;function Ds(){return eo+=1,`tmp-${Date.now().toString(36)}-${eo}`}function no({children:t}){let e=ft(),r=rt(),n=mt(),{isPreviewing:o,previewReady:s}=ne(),[i,a]=useState(false),l=useRef(null),c=useRef(e),d=useRef(r);c.current=e,d.current=r;let u=useCallback(h=>{let y=c.current;if(y.active&&y.hasDraft){y.attemptClose();return}let T=n.eventTargetElement(h.target)??n.targetDocument.body,x=n.targetWindow.getSelection(),z=to({clickTarget:T,selection:x}),O=Ds(),g={viewportX:h.clientX,viewportY:h.clientY,documentY:h.clientY+n.getTargetScrollY()};d.current.addEphemeral({tempId:O,viewportX:g.viewportX,viewportY:g.viewportY,documentY:g.documentY}),c.current.openComposer({tempId:O,target:z,anchor:g}),l.current?.pause();},[n]),p=r.annotationsReady&&(!o||s);useEffect(()=>{if(!i||!p){l.current?.exit(),l.current=null;return}return l.current?.exit(),l.current=Qn({internalAttr:Ls,surface:n,onClick:u}),()=>{l.current?.exit(),l.current=null;}},[i,u,n,p]);let m=useCallback(()=>{i||a(true);},[i]),v=useCallback(()=>{a(false);},[]),f=useRef(null);useEffect(()=>{let h=f.current,y=e.active;h?.kind==="composer"&&y?.kind!=="composer"&&(d.current.removeEphemeral(h.tempId),l.current?.resume()),h?.kind==="composer"&&y?.kind==="composer"&&h.tempId!==y.tempId&&d.current.removeEphemeral(h.tempId),f.current=y;},[e.active]),useEffect(()=>()=>{l.current?.exit(),l.current=null;},[]);let b=useMemo(()=>({isCapturing:i,enter:m,exit:v}),[i,m,v]);return jsx(ro.Provider,{value:b,children:t})}function oo(){let t=use(ro);if(!t)throw new Error("useCaptureControls must be used inside <CaptureProvider>");return t}var Fs="patch:focus-intent";function Ir(t){return `${Fs}:${t}`}function $s(t){try{let e=window.sessionStorage.getItem(Ir(t));if(!e)return null;window.sessionStorage.removeItem(Ir(t));let r=JSON.parse(e);return typeof r.id!="string"||typeof r.url!="string"?null:{id:r.id,url:r.url,viewport:r.viewport??"desktop"}}catch{return null}}function Bs(t,e){try{window.sessionStorage.setItem(Ir(t),JSON.stringify(e));}catch{}}var so=createContext(null);function Vs(t){return t==="pending"||t==="acknowledged"}function lo({projectToken:t,children:e}){let{apiClient:r,active:n,viewerKind:o,annotations:s}=rt(),i=o==="studio",[a,l]=useState([]),[c,d]=useState(false),[u,p]=useState(null),m=useRef(r);m.current=r;let v=useCallback(async()=>{if(!i){l([]),d(true);return}let g=await m.current.listRoster();l(g),d(true);},[i]);useEffect(()=>{if(!n||!i)return;let g=$s(t);g&&ct(g.url)===ct(window.location.href)&&p(g),v();},[n,i,t,v]);let f=useMemo(()=>s.map(g=>`${g.id}:${g.status}`).sort().join(","),[s]),b=useRef(null);useEffect(()=>{if(!(!n||!i)){if(b.current===null){b.current=f;return}b.current!==f&&(b.current=f,v());}},[f,n,i,v]);let h=useCallback(g=>{let N={id:g.id,url:g.url,viewport:g.viewport};if(ct(g.url)===ct(window.location.href)){p(N);return}Bs(t,N),window.location.assign(g.url);},[t]),y=useCallback(()=>p(null),[]),T=useMemo(()=>{let g=new Map;for(let N of s)g.set(N.id,N.status);return g},[s]),x=useMemo(()=>a.map(g=>{let N=T.get(g.id);return N&&N!==g.status?{...g,status:N}:g}),[a,T]),z=useMemo(()=>x.filter(g=>Vs(g.status)).length,[x]),O=useMemo(()=>({entries:x,ready:c,unresolvedCount:z,refresh:v,focusPin:h,pendingFocus:u,clearFocus:y}),[x,c,z,v,h,u,y]);return jsx(so.Provider,{value:O,children:e})}function ae(){let t=use(so);if(!t)throw new Error("useRosterStore must be used inside <RosterProvider>");return t}var uo=createContext(null);function po({children:t}){let[e,r]=useState(false),[n,o]=useState(false),s=useMemo(()=>({dockOpen:e,hideResolvedAnnotations:n,setDockOpen:r,setHideResolvedAnnotations:o}),[e,n]);return jsx(uo.Provider,{value:s,children:t})}function Bt(){let t=use(uo);if(!t)throw new Error("useWidgetUiStore must be used inside <WidgetUiProvider>");return t}var mo="[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 go(t){let e=t.prop?.trim();if(e)return e;let r=t.processEnv?.NEXT_PUBLIC_PATCH_TOKEN?.trim();if(r)return r;let n=t.importMetaEnv?.VITE_PATCH_TOKEN?.trim();if(n)return n;let o=t.importMetaEnv?.PUBLIC_PATCH_TOKEN?.trim();return o||null}function fo(){try{return typeof import.meta>"u"?void 0:import.meta.env}catch{return}}function ho(){try{return typeof process>"u"||!process.env?void 0:{NEXT_PUBLIC_PATCH_TOKEN:process.env.NEXT_PUBLIC_PATCH_TOKEN}}catch{return}}function Ee(t){let e=t.gap??12,r=t.margin??16,n=Math.min(t.popover.width,Math.max(0,t.viewport.width-r*2)),o="right",s=t.anchor.x+t.anchor.width+e;s+n>t.viewport.width-r&&(o="left",s=t.anchor.x-n-e),s<r&&(s=r);let i=t.anchor.y;return i+t.popover.height>t.viewport.height-r&&(i=t.viewport.height-r-t.popover.height),i<r&&(i=r),{x:s,y:i,width:n,placement:o}}function C(...t){return t.filter(Boolean).join(" ")}function Qe({seed:t,className:e,style:r}){let n=Dn(t),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:C("absolute inset-0 size-full! overflow-hidden rounded-full",e),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 _t=32,bo=[.22,.61,.36,1],tr=["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 se(t){if(!t)return "?";let e=t.trim().split(/\s+/),r=e[0],n=e[e.length-1];if(!r||!n)return "?";if(e.length===1)return r.slice(0,2).toUpperCase();let o=r[0]??"",s=n[0]??"";return (o+s).toUpperCase()||"?"}function le(t){if(!t)return tr[0];let e=0;for(let r=0;r<t.length;r++)e=(e<<5)-e+t.charCodeAt(r),e|=0;return tr[Math.abs(e)%tr.length]??tr[0]}var js={right:"50% 50% 3px 50%",left:"50% 50% 50% 3px"},Zs={right:"50% 50% 2px 50%",left:"50% 50% 50% 2px"};function ce(t,e){let{placement:r}=Ee({anchor:{x:t.viewportX-_t/2,y:t.viewportY-_t/2,width:_t,height:_t},popover:{width:332,height:200},viewport:e});return r==="right"?"left":"right"}function er(t,e){return {x:e==="left"?t.viewportX:t.viewportX-_t,y:t.viewportY-_t,width:_t,height:_t}}function Nr({ref:t,...e}){let r=e.pointSide??"right",n=!e.resolved&&e.attention?Js[e.attention]:null,{url:o,seed:s}=Ye(e.avatarSrc),i=s??e.generatedSeed,a=e.resolved?"saturate(0.55) brightness(1.04) contrast(0.92)":"",l=r==="right"?"-bottom-0.5 -left-0.5":"-bottom-0.5 -right-0.5";return jsx(motion.button,{ref:t,type:"button",onClick:e.onClick,"aria-label":e.ariaLabel??"Open annotation","data-patch-ephemeral":e.ephemeral?"":void 0,"data-patch-pin-id":e.pinId,className:"patch-pin-button fixed z-[2147483645] border-0 bg-transparent p-0",style:{width:_t,height:_t},initial:e.ephemeral?{opacity:0,scale:.45}:false,animate:e.ephemeral?{opacity:1,scale:1,transition:{type:"spring",stiffness:620,damping:30,mass:.65}}:{opacity:1,scale:1},exit:e.ephemeral?{opacity:0,scale:.45,transition:{delay:.16,duration:.14,ease:bo}}:{opacity:0,scale:.9,transition:{duration:.12,ease:bo}},children:jsxs("span",{className:"patch-pin relative grid size-full place-items-center","data-patch-point-side":r,style:{borderRadius:js[r]},children:[jsxs("span",{"data-patch-avatar":"",className:"absolute inset-[2px] overflow-hidden",style:{borderRadius:Zs[r],background:"var(--color-muted-foreground)"},children:[i?jsx(Qe,{seed:i,style:{borderRadius:0,filter:a||"none"}}):null,o?jsx("img",{src:o,alt:e.avatarAlt??"",referrerPolicy:"no-referrer",className:"absolute inset-0 size-full object-cover",draggable:false,style:{filter:a||"none"},onError:c=>{c.currentTarget.remove();}}):null]}),e.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":e.attention,"aria-hidden":"true",className:`absolute -top-0.5 -right-0.5 size-[10px] rounded-full border-[1.5px] border-white ${n}`})]})})}var Js={"review-pr":"bg-brand","patch-failed":"bg-destructive","rerun-after-closed":"bg-muted-foreground"};function rr(t){let e=new Date(t).getTime(),r=Date.now()-e,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 xo(t){let e=t.composedPath();for(let r of e)if(r instanceof Element&&r.tagName?.toLowerCase()==="patch-widget-root")return true;return false}function wo(t){let e=t.match(/\/pull\/(\d+)/);return e?`#${e[1]}`:"PR"}var yo={"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"}]],camera:[["path",{d:"M12.6974 3.5H11.303C10.5884 3.5 10.2311 3.5 9.91067 3.612C9.71499 3.68039 9.53113 3.77879 9.36568 3.90367C9.09474 4.10816 8.89655 4.40544 8.50018 5L8.50017 5.00001C8.29717 5.30453 7.99794 5.75337 7.87867 5.87871C7.58314 6.18927 7.19563 6.39666 6.77329 6.47029C6.60284 6.5 6.41985 6.5 6.05387 6.5C5.07379 6.5 4.58376 6.5 4.18307 6.61342C3.18074 6.89716 2.39734 7.68055 2.1136 8.68289C2.00018 9.08357 2.00018 9.57361 2.00018 10.5537V14.5C2.00018 17.3284 2.00018 18.7426 2.87886 19.6213C3.75754 20.5 5.17176 20.5 8.00018 20.5H16.0002C18.8286 20.5 20.2428 20.5 21.1215 19.6213C22.0002 18.7426 22.0002 17.3284 22.0002 14.5V10.5537C22.0002 9.57361 22.0002 9.08357 21.8868 8.68289C21.603 7.68055 20.8196 6.89716 19.8173 6.61342C19.4166 6.5 18.9266 6.5 17.9465 6.5C17.5805 6.5 17.3975 6.5 17.2271 6.47029C16.8047 6.39666 16.4172 6.18927 16.1217 5.87871C16.0024 5.75336 15.7032 5.30451 15.5002 5C15.1038 4.40544 14.9056 4.10816 14.6347 3.90367C14.4692 3.77879 14.2854 3.68039 14.0897 3.612C13.7693 3.5 13.412 3.5 12.6974 3.5Z"}],["path",{d:"M16.0002 13C16.0002 15.2091 14.2093 17 12.0002 17C9.79104 17 8.00018 15.2091 8.00018 13C8.00018 10.7909 9.79104 9 12.0002 9C14.2093 9 16.0002 10.7909 16.0002 13Z"}],["path",{d:"M19.1252 9.5H19.0002M19.2502 9.5C19.2502 9.63807 19.1383 9.75 19.0002 9.75C18.8621 9.75 18.7502 9.63807 18.7502 9.5C18.7502 9.36193 18.8621 9.25 19.0002 9.25C19.1383 9.25 19.2502 9.36193 19.2502 9.5Z"}]],check:[["path",{d:"M5 14L8.5 17.5L19 6.5"}]],"chevron-left":[["path",{d:"M15 6C15 6 9.00001 10.4189 9 12C8.99999 13.5812 15 18 15 18"}]],"chevron-right":[["path",{d:"M9.00005 6C9.00005 6 15 10.4189 15 12C15 13.5812 9 18 9 18"}]],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"}]],paperclip:[["path",{d:"M5.82338 12L4.27922 10.4558C2.57359 8.75022 2.57359 5.98485 4.27922 4.27922C5.98485 2.57359 8.75022 2.57359 10.4558 4.27922L19.7208 13.5442C21.4264 15.2498 21.4264 18.0152 19.7208 19.7208C18.0152 21.4264 15.2498 21.4264 13.5442 19.7208L10.0698 16.2464C9.00379 15.1804 9.00379 13.4521 10.0698 12.386C11.1358 11.32 12.8642 11.32 13.9302 12.386L15.8604 14.3162"}]],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 I({name:t,size:e=16,stroke:r=2,color:n,className:o}){return jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:n??"currentColor",strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",className:o,children:yo[t].map(([s,i],a)=>createElement(s,{key:a,...i}))})}var Co=[.16,1,.3,1];function rl(t){try{let r=new URL(t).pathname.replace(/\/$/,"");return r===""?"/":r}catch{return t}}function nr(t){return t==="pending"||t==="acknowledged"}function Ao({onClose:t}){let e=ae(),{hideResolvedAnnotations:r}=Bt(),n=e.focusPin,o=typeof window>"u"?"":ct(window.location.href),s=useMemo(()=>[...r?e.entries.filter(d=>d.status!=="resolved"):e.entries].sort((d,u)=>(nr(d.status)?0:1)-(nr(u.status)?0:1)),[e.entries,r]),i=useMemo(()=>{let c=e.entries.filter(u=>nr(u.status)&&ct(u.url)===o).length,d=e.entries.filter(u=>nr(u.status)).length;return {here:c,elsewhere:d-c,total:d}},[e.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){t(),n(c);}return jsxs(motion.div,{initial:{opacity:0,y:6,scale:.98},animate:{opacity:1,y:0,scale:1,transition:{duration:.18,ease:Co}},exit:{opacity:0,y:4,scale:.985,transition:{duration:.12,ease:Co}},"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: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(nl,{entry:c,onCurrentPage:ct(c.url)===o,onClick:()=>l(c)},c.id))})]})}function nl({entry:t,onCurrentPage:e,onClick:r}){let n=t.status==="resolved",o=t.anchorStatus==="detached";return jsxs("button",{type:"button","data-patch-fab-dock":"","data-patch-roster-row":t.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(I,{name:"check",size:10,stroke:2.6})}):t.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:C("block truncate text-[12.5px] leading-snug",n?"text-popover-foreground/45 line-through":"text-popover-foreground"),children:t.label}),jsxs("span",{className:"mt-0.5 flex items-center gap-1.5 text-[11px] text-popover-foreground/50",children:[jsx(I,{name:Tt[t.viewport].glyph,size:11,className:"shrink-0 opacity-80"}),jsx("span",{className:"truncate",children:e?"This page":rl(t.url)}),jsx("span",{"aria-hidden":"true",children:"\xB7"}),jsx("span",{className:"shrink-0",children:rr(t.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(I,{name:"unlink",size:10}),"element gone"]}):null]})]})]})}var ol="relative inline-grid shrink-0 overflow-hidden place-items-center rounded-full text-white font-semibold tracking-[-0.01em]",il={sm:"size-[22px] text-[9.5px]",md:"size-7 text-[10.5px]"};function Vt({initials:t,tint:e,src:r,generatedSeed:n,alt:o="",size:s="md",className:i,style:a}){let{url:l,seed:c}=Ye(r),d=c??n;return jsxs("span",{className:C(ol,il[s],i),style:{background:e,...a},children:[jsx("span",{children:t}),!l&&d?jsx(Qe,{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:u=>{u.currentTarget.remove();}}):null]})}var sl="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",ll="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 Ie({size:t=16,className:e}){return jsx("svg",{width:t,height:t,viewBox:"0 0 96 96",fill:"currentColor","aria-hidden":"true",focusable:"false",className:e,children:jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:sl})})}function So({size:t=16,variant:e="filled",stroke:r=2,className:n}){let o=e==="outline";return jsx("svg",{width:t,height:t,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:ll})})}var _r=false,Kt=null,ir=null,Et={openDelay:700,isInstant(){return _r},onOpen(t){ir&&ir!==t&&ir(),ir=t??null,_r=true,Kt&&(clearTimeout(Kt),Kt=null);},onClose(){Kt&&clearTimeout(Kt),Kt=setTimeout(()=>{_r=false,Kt=null;},300);}};var Ro="easeOut";function ot({text:t,children:e,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&&Et.onClose();},[]);let u=x=>{l(x),i(true),d.current=true,Et.onOpen();},p=()=>{if(c.current&&(clearTimeout(c.current),c.current=null),Et.isInstant()){u(true);return}c.current=setTimeout(()=>{c.current=null,u(false);},Et.openDelay);},m=()=>{c.current&&(clearTimeout(c.current),c.current=null),d.current&&(d.current=false,Et.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",f="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",b=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 ${f}`:`relative block whitespace-nowrap rounded-md bg-foreground px-2.5 py-[6px] text-[11px] font-medium tracking-[0.01em] text-white ${f}`,h=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",y=o==="bottom"&&n!=="warning"?-3:3,T=o==="bottom"&&n!=="warning"?-2:2;return jsxs("span",{className:C("relative inline-flex items-center justify-center",r),onMouseEnter:p,onMouseLeave:m,onMouseDown:m,children:[jsx("span",{className:v,children:jsx(AnimatePresence,{children:s&&jsxs(motion.span,{initial:a?false:{opacity:0,y,scale:.98},animate:{opacity:1,y:0,scale:1,transition:a?{duration:0}:{duration:.1,ease:Ro}},exit:{opacity:0,y:T,scale:.98,transition:{duration:.08,ease:Ro}},className:b,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:t}),jsx("span",{className:h})]})})}),e]})}var Io=44,Lt=[.16,1,.3,1],No="easeOut",ml=.08,gl=60,fl="calc(100% - 64px) calc(100% + 4px)",me="pkey pkey-dock grid size-8 place-items-center rounded-full border-0 bg-transparent";function Mo(){let t=oo(),e=ft(),r=rt(),n=ae(),{dockOpen:o,hideResolvedAnnotations:s,setDockOpen:i,setHideResolvedAnnotations:a}=Bt(),l=!!r.studio,c=n.unresolvedCount,[d,u]=useState(false),[p,m]=useState(false),[v,f]=useState(false),[b,h]=useState(false),[y,T]=useState(false),[x,z]=useState(false),O=useRef(null),g=useRef(null),N=useRef(false),[U,at]=useState(false),pt=useRef(null),[vt,st]=useState(Io);useLayoutEffect(()=>{let $=pt.current;if(!$)return;let lt=()=>st($.offsetWidth);lt();let Ct=new ResizeObserver(lt);return Ct.observe($),()=>Ct.disconnect()},[]);let Q=r.studio?r.studio.name:r.identity?.name??null,X=se(Q),k=r.studio?.image??null,R=r.identity?.avatarSeed??r.clientAvatarSeed,M=r.studio?.userId??R,A=r.studio?"var(--color-foreground)":le(R),H=r.studio&&!k?"#FFFFFF":A,F=r.studio&&!k?"text-foreground":"text-white",E=Tt[r.activeViewport];function tt(){O.current!==null&&(window.clearTimeout(O.current),O.current=null);}function xt(){g.current!==null&&(window.clearTimeout(g.current),g.current=null);}let P=useRef(()=>{});P.current=()=>{!N.current&&O.current===null||(tt(),xt(),N.current=false,z(true));};let L=useRef(()=>P.current()).current;useEffect(()=>{x&&d&&u(false);},[x,d]);function W($){m(false),f(false),h(false),tt(),xt(),N.current=true,z(false),T($),Et.onOpen(L),u(true);}function j(){W(false);}function Pt(){if(tt(),!(N.current||g.current!==null)){if(Et.isInstant()){W(true);return}g.current=window.setTimeout(()=>{g.current=null,W(false);},Et.openDelay);}}function wt(){xt(),tt(),N.current&&(N.current=false,Et.onClose()),O.current=window.setTimeout(()=>{u(false),O.current=null;},120);}function Ut(){at(true),i(true);}function ze(){m(false),f(false),h(false),xt(),N.current=false,u(false),t.isCapturing?t.exit():t.enter();}function He(){m(false),f(false),xt(),N.current=false,u(false),h($=>{let lt=!$;return lt&&n.refresh(),lt});}function Fe(){at(true),i(false),m(false),f(false),h(false),xt(),N.current=false,u(false),t.exit(),e.active&&e.forceClose();}useEffect(()=>()=>{O.current!==null&&window.clearTimeout(O.current),g.current!==null&&window.clearTimeout(g.current);},[]);let gr=()=>{r.signOut(),u(false);};function S(){f(false),h(false),xt(),N.current=false,u(false),m($=>!$);}function D($){m(false),r.activeViewport!==$&&(e.active&&e.forceClose(),r.setActiveViewport($));}function _(){m(false),h(false),xt(),N.current=false,u(false),f($=>!$);}function V(){a(!s);}function B($){let lt=$.relatedTarget;lt instanceof Node&&$.currentTarget.contains(lt)||wt();}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?vt:Io},transition:{duration:.36,ease:Lt},onAnimationComplete:()=>at(false),whileHover:o?void 0:{scale:1.03,transition:{duration:.15,ease:Lt}},whileTap:o?void 0:{scale:.97,transition:{duration:.1,ease:Lt}},"data-patch-fab-dock":"",className:C("pkey-fab relative h-11 rounded-full",U?"overflow-hidden":"overflow-visible"),children:[jsx(motion.div,{animate:{opacity:o?0:1,scale:o?.7:1},transition:{duration:.18,ease:Lt},className:C("absolute inset-0",o?"pointer-events-none":"pointer-events-auto"),children:jsx("button",{type:"button",onClick:Ut,"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(Ie,{size:18})})}),jsxs("div",{ref:pt,"data-patch-fab-dock":"",className:C("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(ge,{visible:o,index:0,children:jsx(ot,{text:t.isCapturing?"Stop commenting":"Add comment",children:jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":t.isCapturing?"Stop commenting":"Add comment","aria-pressed":t.isCapturing,onClick:ze,className:C(me,"transition-colors",t.isCapturing?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:jsx(So,{variant:"outline",size:16})})})}),l?jsx(ge,{visible:o,index:1,children:jsx(ot,{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":b,onClick:He,className:C(me,"relative transition-colors",b||c>0?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:[jsx(I,{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(ge,{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":p,onClick:S,className:C(me,"transition-colors",r.activeViewport==="desktop"&&!p?"text-white/70 hover:bg-white/[0.08] hover:text-white":"bg-brand/15 text-brand"),children:jsx(I,{name:E.glyph,size:15})}),jsx(AnimatePresence,{children:p?jsxs(motion.div,{initial:{opacity:0,y:4,scale:.97},animate:{opacity:1,y:0,scale:1,transition:{duration:.16,ease:Lt}},exit:{opacity:0,y:3,scale:.98,transition:{duration:.12,ease:Lt}},"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($=>{let lt=Tt[$],Ct=r.activeViewport===$;return jsx(ot,{text:Qt($),children:jsx("button",{type:"button","data-patch-viewport-option":$,"aria-label":Qt($),"aria-pressed":Ct,onClick:()=>D($),className:C("grid size-8 place-items-center rounded-full border-0 bg-transparent transition-colors",Ct?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:jsx(I,{name:lt.glyph,size:15})})},$)})]}):null})]})}),jsx(ge,{visible:o,index:3,children:jsxs("div",{className:"relative flex items-center",children:[jsx(ot,{text:"Settings",children:jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":"Settings","aria-expanded":v,onClick:_,className:C(me,"transition-colors",v||s?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:jsx(I,{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:Lt}},exit:{opacity:0,y:3,scale:.98,transition:{duration:.12,ease:Lt}},"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:s,"aria-label":"Hide resolved annotations",onChange:V,className:"peer sr-only"}),jsx("span",{"aria-hidden":"true",className:C("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(I,{name:"check",size:10,stroke:2.4})}),jsx("span",{className:"min-w-0 flex-1 whitespace-nowrap",children:"Hide resolved annotations"})]})]}):null})]})}),jsx(ge,{visible:o,index:4,children:jsxs("span",{"data-patch-identity-hover":"",className:"relative inline-flex items-center justify-center",onMouseEnter:Pt,onMouseLeave:wt,onFocus:j,onBlur:B,children:[jsx("button",{type:"button","data-patch-fab-dock":"","data-patch-person-btn":"","aria-label":Q?`Account: ${Q}`:"Identify",className:C(me,"text-white"),children:Q?jsx(Vt,{initials:X,tint:H,src:k,generatedSeed:M,alt:Q,size:"sm",className:C("size-[22px] text-[9.5px] ring-1 ring-white/20",F)}):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:y?false:{opacity:0,y:3,scale:.98},animate:{opacity:1,y:0,scale:1,transition:y?{duration:0}:{duration:.12,delay:ml,ease:No}},exit:{opacity:0,y:2,scale:.98,transition:x?{duration:0}:{duration:.08,ease:No}},"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:fl},children:[jsx("span",{className:"absolute bottom-[-4px] size-2 rotate-45 border-r border-b border-white/10 bg-foreground",style:{right:gl}}),r.studio?jsxs("div",{className:"flex items-center gap-2.5",children:[jsx(Vt,{initials:X,tint:A,src:k,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(Vt,{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:gr,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(ge,{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(ot,{text:"Close",children:jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":"Close",onClick:Fe,className:C(me,"text-white/70"),children:jsx(I,{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:b?jsx(Ao,{onClose:()=>h(false)}):null})]})}function ge({children:t,visible:e,index:r}){return jsx(motion.div,{initial:{opacity:0,x:6},animate:e?{opacity:1,x:0,transition:{duration:.2,delay:.12+r*.035,ease:Lt}}:{opacity:0,x:6,transition:{duration:.12,ease:Lt}},children:t})}function _o(t,e){return e.width<=0||e.height<=0?{fx:0,fy:0}:{fx:(t.viewportX-e.x)/e.width,fy:(t.viewportY-e.y)/e.height}}function Lo(t,e){return {viewportX:e.x+t.fx*e.width,viewportY:e.y+t.fy*e.height}}var bl=.6,vl=.5,sr={text:.4,attrs:.3,classes:.2,position:.1},xl=5e3,wl=.08,yl=.12;function kl(t,e){return e===void 0||e===""?.5:t===e?1:t&&(t.includes(e)||e.includes(t))?.5:0}function Cl(t,e){if(!e)return .5;let r=Object.keys(e);if(r.length===0)return .5;let n=0;for(let o of r)t[o]===e[o]&&n++;return n/r.length}function Al(t,e){let r=new Set(t),n=new Set(e??[]);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 Oo(t){let e=t.payload.boundingBox;if(!e)return null;let r=t.payload.coordinates.documentY-t.payload.coordinates.viewportY;return {x:e.x+e.width/2,y:e.y+e.height/2+r}}function Dr(t,e,r){if(!e)return .5;let n=t.left+t.width/2,o=t.top+r.scrollY+t.height/2,s=(n-e.x)/Math.max(1,r.viewport.width),i=(o-e.y)/Math.max(1,r.viewport.height);return Math.max(0,1-Math.sqrt(s*s+i*i))}function Sl(t,e){let r=qe(t),n=Ke(t),o=Ae(t),s=t.getBoundingClientRect(),i=kl(r,e.payload.domHints?.textSignature),a=Cl(n,e.payload.domHints?.attributeSignature),l=Al(o,e.payload.cssClasses),c=Dr(s,Oo(e),e);return sr.text*i+sr.attrs*a+sr.classes*l+sr.position*c}function Tl(t){let e=t.getBoundingClientRect();return e.width<1&&e.height<1}function Do(t,e,r){let n=null,o=null,s=0;for(let i=0;i<t.length&&!(s>=xl);i++){let a=t[i];if(!a||(s++,Kn(a,e.internalAttr)))continue;let l=a.tagName.toLowerCase();if(l==="html"||l==="head"||l==="script"||l==="style"||Tl(a))continue;let c=Sl(a,e);!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<wl){let i=Oo(e),a=Dr(n.el.getBoundingClientRect(),i,e),l=Dr(o.el.getBoundingClientRect(),i,e);if(a-l<yl)return null}return n.el}function El(t){return {viewportX:t.payload.coordinates.viewportX,viewportY:t.payload.coordinates.documentY-t.scrollY}}function Rl(t,e){let r=t.getBoundingClientRect();if(!e.payload.boundingBox)return {viewportX:r.x,viewportY:r.y};let n=_o({viewportX:e.payload.coordinates.viewportX,viewportY:e.payload.coordinates.viewportY},e.payload.boundingBox);return Lo(n,{x:r.x,y:r.y,width:r.width,height:r.height})}function Pl(t){let e=t.payload.domHints?.cssSelector;if(!e)return [];try{return Array.from(t.doc.querySelectorAll(e))}catch{return []}}function lr(t){if(!t.payload.domHints)return {kind:"detached",el:null};let e=Pl(t);if(e.length>0){let n=Do(e,t,vl);if(n)return {kind:"anchored",tier:1,el:n}}let r=Do(t.doc.querySelectorAll("*"),t,bl);return r?{kind:"anchored",tier:2,el:r}:{kind:"detached",el:null}}function Or(t,e){return t.kind==="anchored"&&t.el?Rl(t.el,e):El(e)}function zo(t){let e=lr(t);return {kind:e.kind,tier:e.tier,el:e.el,position:Or(e,t)}}function Ho(t){if(t.status==="resolved")return null;let e=t.latestRun;return e?e.status==="failed"?"patch-failed":e.status!=="succeeded"?null:e.prClosedUnmerged?"rerun-after-closed":e.prUrl?"review-pr":null:null}var Nl="data-patch-internal";function cr(t,e,r){let n=ce(r,e.getOverlayViewport()),o=er(r,n);t.style.top=`${o.y}px`,t.style.left=`${o.x}px`;}function Bo(t,e){return Math.abs(t.viewportX-e.viewportX)<.5&&Math.abs(t.viewportY-e.viewportY)<.5}function Ml(t){let e=t.getBoundingClientRect();return e.width<1&&e.height<1}function Fr(t,e){return {payload:e.payload,doc:t.targetDocument,scrollY:t.getTargetScrollY(),viewport:t.getTargetViewport(),internalAttr:Nl}}function Vo(t,e,r){let n=Fr(t,e);return {kind:r.kind,position:t.targetPointToOverlay(Or(r,n))}}function _l(t,e){return t.targetPointToOverlay({viewportX:e.viewportX,viewportY:e.documentY-t.getTargetScrollY()})}function Wo(){let{annotations:t,annotationsReady:e,ephemerals:r,identity:n,studio:o,clientAvatarSeed:s,apiClient:i}=rt(),a=ft(),{dockOpen:l,hideResolvedAnnotations:c}=Bt(),d=mt(),{isPreviewing:u,previewReady:p}=ne(),m=useReducedMotion(),v=a.active,f=a.forceClose,b=e&&(!u||p),h=useMemo(()=>l&&e?t.filter(k=>!c||k.status!=="resolved"):[],[l,e,t,c]),y=useMemo(()=>l&&e?r:[],[l,e,r]);useEffect(()=>{if(!c||v?.kind!=="existing")return;t.find(R=>R.id===v.annotationId)?.status==="resolved"&&f();},[v,t,f,c]);let T=useRef(new Map),x=useRef(new Map),z=useRef(new Map),O=useRef(new Map),g=useMemo(()=>{let k=O.current,R=new Set,M=new Map;for(let A of h){R.add(A.id);let H=k.get(A.id),E=H?.kind==="anchored"&&H.el?.isConnected?H:lr(Fr(d,A));k.set(A.id,E),M.set(A.id,Vo(d,A,E));}for(let A of k.keys())R.has(A)||k.delete(A);return M},[d,h]),N=useCallback(()=>{let k=O.current,R=z.current,M=new Set;for(let A of h){let H=T.current.get(A.id);if(!H)continue;M.add(A.id);let F=k.get(A.id);if((!F||F.kind==="anchored"&&F.el&&!F.el.isConnected)&&(F=lr(Fr(d,A)),k.set(A.id,F)),F.kind==="detached"||F.kind==="anchored"&&F.el&&Ml(F.el)){H.style.visibility!=="hidden"&&(H.style.visibility="hidden"),R.delete(A.id);continue}H.style.visibility==="hidden"&&(H.style.visibility="");let E=Vo(d,A,F).position,tt=R.get(A.id);tt&&Bo(tt,E)||(R.set(A.id,E),cr(H,d,E));}for(let A of y){let H=x.current.get(A.tempId);if(!H)continue;M.add(A.tempId);let F=_l(d,A),E=R.get(A.tempId);E&&Bo(E,F)||(R.set(A.tempId,F),cr(H,d,F));}for(let A of R.keys())M.has(A)||R.delete(A);},[d,h,y]),U=h.length>0||y.length>0;useEffect(()=>{if(!U)return;let k=d.overlayWindow,R=k.requestAnimationFrame(function M(){N(),R=k.requestAnimationFrame(M);});return ()=>k.cancelAnimationFrame(R)},[U,N,d]);let at=useRef(new Map);useEffect(()=>{if(!e||h.length===0)return;let k=setTimeout(()=>{let R=[];for(let M of h){let A=g.get(M.id);if(!A)continue;let H=A.kind!=="detached";at.current.get(M.id)!==H&&(at.current.set(M.id,H),R.push({id:M.id,present:H}));}i.reportAnchorStatuses(R);},1500);return ()=>clearTimeout(k)},[g,h,e,i]);let pt=useCallback(k=>{if(a.active&&a.hasDraft){a.attemptClose();return}a.openExisting(k);},[a]),vt=o?o.name:n?.name??null,st=o?.image??null,Q=n?.avatarSeed??s,X=o?.userId??Q;return jsxs("div",{"data-patch-pin-layer":"",style:{opacity:b?1:0,transition:m||!b?void 0:"opacity 0.2s cubic-bezier(0.22, 0.61, 0.36, 1)",pointerEvents:b?void 0:"none"},children:[jsx(AnimatePresence,{initial:false,children:h.map(k=>{let R=g.get(k.id);if(R?.kind==="detached")return null;let M=Ll(k),A=!o&&!!n?.clientUserId&&k.payload.authorRole==="client"&&k.payload.authorId===n.clientUserId,H=o?Ho(k):null,F=R?ce(R.position,d.getOverlayViewport()):"right";return jsx(Nr,{ref:E=>{E?(T.current.set(k.id,E),R&&cr(E,d,R.position)):T.current.delete(k.id);},avatarSrc:M.image,generatedSeed:A?Q:M.generatedSeed,avatarAlt:M.name??"",resolved:k.status==="resolved",attention:H,pointSide:F,ariaLabel:`Annotation by ${k.authorName??"someone"}`,onClick:()=>pt(k.id),pinId:k.id},k.id)})}),jsx(AnimatePresence,{initial:false,children:y.map(k=>{let R=d.targetPointToOverlay({viewportX:k.viewportX,viewportY:k.viewportY});return jsx(Nr,{ref:M=>{M?(x.current.set(k.tempId,M),cr(M,d,R)):x.current.delete(k.tempId);},avatarSrc:st,generatedSeed:X,avatarAlt:vt??"",resolved:false,pointSide:ce(R,d.getOverlayViewport()),ephemeral:true},k.tempId)})})]})}function Ll(t){let e=t.authorAvatarSeed??t.payload.authorId??(t.authorName?`annotation-author:${t.authorName}`:null);if(t.authorImage||e||t.authorName)return {name:t.authorName,image:t.authorImage??null,generatedSeed:e??t.id,key:t.payload.authorId??t.authorName??t.id};let r=t.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??t.id,key:r.authorId??r.authorName??t.id}}return {name:t.authorName,image:t.authorImage??null,generatedSeed:t.id,key:t.id}}var Fl=5e3;function Yo(){let t=ae(),e=rt(),r=ft(),n=Bt(),o=mt(),s=useReducedMotion(),i=t.pendingFocus,a=useRef(null),l=useCallback(()=>{a.current!==null&&(window.clearTimeout(a.current),a.current=null);},[]);return useEffect(()=>{if(!i)return;if(ct(window.location.href)!==ct(i.url)){t.clearFocus();return}if(n.dockOpen||n.setDockOpen(true),e.activeViewport!==i.viewport){e.setActiveViewport(i.viewport);return}if(!e.annotationsReady)return;let c=e.annotations.find(u=>u.id===i.id);if(!c){a.current===null&&(a.current=window.setTimeout(()=>{a.current=null,t.clearFocus();},Fl));return}l();let d=c.payload.coordinates?.documentY;if(typeof d=="number"){let u=o.getTargetViewport().height;o.targetWindow.scrollTo({top:Math.max(0,d-u/3),behavior:s?"auto":"smooth"});}r.openExisting(i.id),t.clearFocus();},[i,e,n,o,s,r,t,l]),useEffect(()=>()=>l(),[l]),null}function $l(){for(let t of [document.body,document.documentElement]){let e=window.getComputedStyle(t).backgroundColor;if(e&&e!=="transparent"&&e!=="rgba(0, 0, 0, 0)")return e}return "#ffffff"}async function Go(t){try{let{snapdom:e}=await import('@zumer/snapdom'),r=Math.min(window.devicePixelRatio||1,2),n=await e.toCanvas(document.body,{dpr:r,exclude:["[data-patch-internal]"],embedFonts:!0}),o=document.body.getBoundingClientRect(),s=n.width/Math.max(1,o.width),i=document.createElement("canvas");i.width=Math.max(1,Math.round(t.width*r)),i.height=Math.max(1,Math.round(t.height*r));let a=i.getContext("2d");return a?(a.fillStyle=$l(),a.fillRect(0,0,i.width,i.height),a.drawImage(n,(t.x-o.left)*s,(t.y-o.top)*s,t.width*s,t.height*s,0,0,i.width,i.height),await new Promise(l=>i.toBlob(l,"image/webp",.92))):null}catch{return null}}var Wl='<svg xmlns="http://www.w3.org/2000/svg" width="34" height="34" viewBox="0 0 34 34"><g stroke="#fff" stroke-width="3.5" stroke-linecap="round"><path d="M12 3v6.5M12 14.5V21M3 12h6.5M14.5 12H21"/></g><g stroke="#1F1F1F" stroke-width="1.5" stroke-linecap="round"><path d="M12 3v6.5M12 14.5V21M3 12h6.5M14.5 12H21"/></g><g><rect x="20" y="22" width="13" height="10" rx="2.5" fill="#1F1F1F" stroke="#fff"/><circle cx="26.5" cy="27" r="2.6" fill="none" stroke="#fff" stroke-width="1.4"/></g></svg>',Ul=`url("data:image/svg+xml,${encodeURIComponent(Wl)}") 12 12, crosshair`,Br=4;function qo(t,e){return {x:Math.min(t.x,e.x),y:Math.min(t.y,e.y),width:Math.abs(t.x-e.x),height:Math.abs(t.y-e.y)}}function jo({capturing:t,onSelect:e,onCancel:r}){let n=useReducedMotion(),[o,s]=useState(null),[i,a]=useState(null),[l,c]=useState(null);useEffect(()=>{let f=b=>{b.key==="Escape"&&(b.preventDefault(),b.stopPropagation(),t||r());};return document.addEventListener("keydown",f,true),()=>document.removeEventListener("keydown",f,true)},[t,r]);let d=useCallback(f=>({x:Math.min(Math.max(f.x,0),window.innerWidth),y:Math.min(Math.max(f.y,0),window.innerHeight)}),[]),u=useCallback((f,b)=>{let h=qo(f,b);s(null),a(null),!(h.width<Br||h.height<Br)&&(c(h),e(h));},[e]);useEffect(()=>{if(!o)return;let f=h=>{a(d({x:h.clientX,y:h.clientY}));},b=h=>{u(o,d({x:h.clientX,y:h.clientY}));};return window.addEventListener("mousemove",f),window.addEventListener("mouseup",b),()=>{window.removeEventListener("mousemove",f),window.removeEventListener("mouseup",b);}},[o,d,u]);let p=l??(o&&i?qo(o,i):null),m=!!p&&p.width>=Br/2,v=p?p.y+p.height+30<window.innerHeight:true;return jsxs("div",{"data-patch-screenshot-overlay":"",role:"dialog","aria-label":"Capture a screenshot",className:"fixed inset-0 z-[2147483647] select-none",style:{cursor:t?"progress":Ul},onMouseDown:f=>{if(f.button!==0||t)return;f.preventDefault();let b=d({x:f.clientX,y:f.clientY});s(b),a(b);},children:[m&&p?jsx("div",{className:"pointer-events-none absolute rounded-[3px] border-[1.5px] border-brand bg-brand/10 shadow-[0_0_0_1px_rgba(255,255,255,0.55)]",style:{left:p.x,top:p.y,width:p.width,height:p.height},children:jsx("span",{className:C("absolute right-0 whitespace-nowrap rounded-md bg-foreground px-2 py-1 font-sans text-[11px] font-medium tabular-nums text-white shadow-[0_3px_8px_-3px_rgba(0,0,0,0.3)]",v?"top-[calc(100%+6px)]":"bottom-[calc(100%+6px)]"),children:t?jsxs("span",{className:"inline-flex items-center gap-1.5",children:[jsx("span",{className:"size-2.5 animate-spin rounded-full border border-white/40 border-t-white"}),"Capturing\u2026"]}):`${Math.round(p.width)} \xD7 ${Math.round(p.height)}`})}):null,!o&&!t?jsxs(motion.div,{initial:n?false:{opacity:0,y:-4},animate:{opacity:1,y:0,transition:{duration:.15,ease:"easeOut"}},className:"pointer-events-none absolute top-4 left-1/2 -translate-x-1/2 rounded-full bg-foreground/90 px-3.5 py-2 font-sans text-[12px] font-medium text-white shadow-[0_10px_30px_-10px_rgba(0,0,0,0.45)]",children:["Drag to capture",jsx("span",{className:"mx-2 opacity-40",children:"\xB7"}),jsx("kbd",{className:"rounded bg-white/16 px-1.5 py-0.5 font-sans text-[11px]",children:"Esc"}),jsx("span",{className:"ml-1.5 opacity-70",children:"to cancel"})]}):null]})}var Qo=createContext(null);function ti({children:t}){let e=ft(),[r,n]=useState("idle"),o=useRef(null),s=useRef(false);s.current=r!=="idle";let i=useCallback(()=>{o.current=null,n("idle");},[]),a=e.active!==null;useEffect(()=>{!a&&s.current&&i();},[a,i]);let l=useCallback(async u=>{s.current||(o.current=u,n("select"));},[]),c=useCallback(async u=>{n("capturing");let p=await Go(u),m=o.current;i(),p&&m&&m(p);},[i]),d=useMemo(()=>({supported:true,active:r!=="idle",begin:l}),[r,l]);return jsxs(Qo.Provider,{value:d,children:[jsx("div",{style:r==="idle"?{transition:"opacity 150ms ease-out"}:{opacity:0,pointerEvents:"none",transition:"opacity 150ms ease-out"},children:t}),r!=="idle"?jsx(jo,{capturing:r==="capturing",onSelect:u=>{c(u);},onCancel:i}):null]})}var jl={supported:false,active:false,begin:async()=>{}};function ei(){return use(Qo)??jl}var ri=`/*! tailwindcss v4.2.4 | MIT License | https://tailwindcss.com */
4
+ `)}function Rs(t,e){let r=t.targetDocument,n=r.getElementById(Jn);n&&n.remove();let o=r.createElement("style");return o.id=Jn,o.setAttribute(e,""),o.textContent=Es(e),r.head.appendChild(o),o}function Tr(t,e,r){let n=t.eventTargetElement(e);return n?n.closest(`[${r}]`)!==null:false}var le=1.5,Ps="#0287FE",Is="rgba(2, 135, 254, 0.032)";function Ns(t){let e=t.split(" ")[0]??"",r=Number.parseFloat(e);return Number.isFinite(r)?Math.min(8,Math.max(3,r)):6}function Ms(t,e){let r=t.targetDocument,n=r.createElement("div");n.setAttribute(e,""),Object.assign(n.style,{position:"fixed",pointerEvents:"none",border:`${le}px solid ${Ps}`,background:Is,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(e,""),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-le}px`,n.style.left=`${a.left-le}px`,n.style.width=`${a.width+le*2}px`,n.style.height=`${a.height+le*2}px`,n.style.borderRadius=`${Ns(t.targetWindow.getComputedStyle(i).borderRadius)+le}px`,i!==s&&(o.textContent=Pe(i),s=i),o.style.display="block";let l=a.right+8,c=Math.max(8,a.top),d=t.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 Qn(t){let{internalAttr:e,onClick:r,surface:n}=t,o=n.targetDocument,s=Rs(n,e),i=Ms(n,e),a=false,l=x=>{let f=x;if(Tr(n,f.target,e))return;let b=n.eventTargetElement(f.target);b&&Vn(b)||(f.preventDefault(),f.stopPropagation());},c=l,d=l,u=x=>{let f=x;Tr(n,f.target,e)||(f.preventDefault(),f.stopPropagation(),!a&&r(f));},p=x=>{let f=x;if(a)return;let b=n.eventTargetElement(f.target);if(!b){i.hide();return}if(Tr(n,b,e)){i.hide();return}let h=b.tagName.toLowerCase();if(h==="html"||h==="body"){i.hide();return}i.update(b);},m=x=>{x.relatedTarget||i.hide();};return o.addEventListener("mousedown",c,true),o.addEventListener("mouseup",d,true),o.addEventListener("click",u,true),o.addEventListener("mousemove",p,true),o.addEventListener("mouseout",m,true),{exit(){s.remove(),i.destroy(),o.removeEventListener("mousedown",c,true),o.removeEventListener("mouseup",d,true),o.removeEventListener("click",u,true),o.removeEventListener("mousemove",p,true),o.removeEventListener("mouseout",m,true);},pause(){a=true,i.hide();},resume(){a=false;}}}function to(t){let{clickTarget:e,selection:r}=t,n=r&&!r.isCollapsed?r.toString().trim():"";if(n&&r&&r.rangeCount>0){let o=r.getRangeAt(0),s=Xn(o.commonAncestorContainer);if(s)return {kind:"element",element:s,rect:s.getBoundingClientRect(),selectedText:n,clickTarget:e}}return {kind:"element",element:e,rect:e.getBoundingClientRect(),clickTarget:e}}var zs="data-patch-internal",ro=createContext(null),eo=0;function Hs(){return eo+=1,`tmp-${Date.now().toString(36)}-${eo}`}function no({children:t}){let e=xt(),r=it(),n=vt(),{isPreviewing:o,previewReady:s}=ie(),[i,a]=useState(false),l=useRef(null),c=useRef(e),d=useRef(r);c.current=e,d.current=r;let u=useCallback(h=>{let k=c.current;if(k.active&&k.hasDraft){k.attemptClose();return}let E=n.eventTargetElement(h.target)??n.targetDocument.body,w=n.targetWindow.getSelection(),H=to({clickTarget:E,selection:w}),L=Hs(),g={viewportX:h.clientX,viewportY:h.clientY,documentY:h.clientY+n.getTargetScrollY()};d.current.addEphemeral({tempId:L,viewportX:g.viewportX,viewportY:g.viewportY,documentY:g.documentY}),c.current.openComposer({tempId:L,target:H,anchor:g}),l.current?.pause();},[n]),p=r.annotationsReady&&(!o||s);useEffect(()=>{if(!i||!p){l.current?.exit(),l.current=null;return}return l.current?.exit(),l.current=Qn({internalAttr:zs,surface:n,onClick:u}),()=>{l.current?.exit(),l.current=null;}},[i,u,n,p]);let m=useCallback(()=>{i||a(true);},[i]),x=useCallback(()=>{a(false);},[]),f=useRef(null);useEffect(()=>{let h=f.current,k=e.active;h?.kind==="composer"&&k?.kind!=="composer"&&(d.current.removeEphemeral(h.tempId),l.current?.resume()),h?.kind==="composer"&&k?.kind==="composer"&&h.tempId!==k.tempId&&d.current.removeEphemeral(h.tempId),f.current=k;},[e.active]),useEffect(()=>()=>{l.current?.exit(),l.current=null;},[]);let b=useMemo(()=>({isCapturing:i,enter:m,exit:x}),[i,m,x]);return jsx(ro.Provider,{value:b,children:t})}function oo(){let t=use(ro);if(!t)throw new Error("useCaptureControls must be used inside <CaptureProvider>");return t}var Vs="patch:focus-intent";function Nr(t){return `${Vs}:${t}`}function Ws(t){try{let e=window.sessionStorage.getItem(Nr(t));if(!e)return null;window.sessionStorage.removeItem(Nr(t));let r=JSON.parse(e);return typeof r.id!="string"||typeof r.url!="string"?null:{id:r.id,url:r.url,viewport:r.viewport??"desktop"}}catch{return null}}function Us(t,e){try{window.sessionStorage.setItem(Nr(t),JSON.stringify(e));}catch{}}var so=createContext(null);function Ys(t){return t==="pending"||t==="acknowledged"}function lo({projectToken:t,children:e}){let{apiClient:r,active:n,viewerKind:o,annotations:s}=it(),i=o==="studio",[a,l]=useState([]),[c,d]=useState(false),[u,p]=useState(null),m=useRef(r);m.current=r;let x=useCallback(async()=>{if(!i){l([]),d(true);return}let g=await m.current.listRoster();l(g),d(true);},[i]);useEffect(()=>{if(!n||!i)return;let g=Ws(t);g&&ot(g.url)===ot(window.location.href)&&p(g),x();},[n,i,t,x]);let f=useMemo(()=>s.map(g=>`${g.id}:${g.status}`).sort().join(","),[s]),b=useRef(null);useEffect(()=>{if(!(!n||!i)){if(b.current===null){b.current=f;return}b.current!==f&&(b.current=f,x());}},[f,n,i,x]);let h=useCallback(g=>{let I={id:g.id,url:g.url,viewport:g.viewport};if(ot(g.url)===ot(window.location.href)){p(I);return}Us(t,I),window.location.assign(g.url);},[t]),k=useCallback(()=>p(null),[]),E=useMemo(()=>{let g=new Map;for(let I of s)g.set(I.id,I.status);return g},[s]),w=useMemo(()=>a.map(g=>{let I=E.get(g.id);return I&&I!==g.status?{...g,status:I}:g}),[a,E]),H=useMemo(()=>w.filter(g=>Ys(g.status)).length,[w]),L=useMemo(()=>({entries:w,ready:c,unresolvedCount:H,refresh:x,focusPin:h,pendingFocus:u,clearFocus:k}),[w,c,H,x,h,u,k]);return jsx(so.Provider,{value:L,children:e})}function ce(){let t=use(so);if(!t)throw new Error("useRosterStore must be used inside <RosterProvider>");return t}var uo=createContext(null);function po({children:t}){let[e,r]=useState(false),[n,o]=useState(false),s=useMemo(()=>({dockOpen:e,hideResolvedAnnotations:n,setDockOpen:r,setHideResolvedAnnotations:o}),[e,n]);return jsx(uo.Provider,{value:s,children:t})}function Ut(){let t=use(uo);if(!t)throw new Error("useWidgetUiStore must be used inside <WidgetUiProvider>");return t}var mo="[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 go(t){let e=t.prop?.trim();if(e)return e;let r=t.processEnv?.NEXT_PUBLIC_PATCH_TOKEN?.trim();if(r)return r;let n=t.importMetaEnv?.VITE_PATCH_TOKEN?.trim();if(n)return n;let o=t.importMetaEnv?.PUBLIC_PATCH_TOKEN?.trim();return o||null}function fo(){try{return typeof import.meta>"u"?void 0:import.meta.env}catch{return}}function ho(){try{return typeof process>"u"||!process.env?void 0:{NEXT_PUBLIC_PATCH_TOKEN:process.env.NEXT_PUBLIC_PATCH_TOKEN}}catch{return}}var Qe=class extends Component{state={failed:false};static getDerivedStateFromError(){return {failed:true}}componentDidCatch(e,r){console.error("[patch] widget crashed and was unmounted",e,r.componentStack);}render(){return this.state.failed?null:this.props.children}};function Ne(t){let e=t.gap??12,r=t.margin??16,n=Math.min(t.popover.width,Math.max(0,t.viewport.width-r*2)),o="right",s=t.anchor.x+t.anchor.width+e;s+n>t.viewport.width-r&&(o="left",s=t.anchor.x-n-e),s<r&&(s=r);let i=t.anchor.y;return i+t.popover.height>t.viewport.height-r&&(i=t.viewport.height-r-t.popover.height),i<r&&(i=r),{x:s,y:i,width:n,placement:o}}function C(...t){return t.filter(Boolean).join(" ")}function er({seed:t,className:e,style:r}){let n=an(t),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:C("absolute inset-0 size-full! overflow-hidden rounded-full",e),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 Dt=32,bo=[.22,.61,.36,1],rr=["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 de(t){if(!t)return "?";let e=t.trim().split(/\s+/),r=e[0],n=e[e.length-1];if(!r||!n)return "?";if(e.length===1)return r.slice(0,2).toUpperCase();let o=r[0]??"",s=n[0]??"";return (o+s).toUpperCase()||"?"}function ue(t){if(!t)return rr[0];let e=0;for(let r=0;r<t.length;r++)e=(e<<5)-e+t.charCodeAt(r),e|=0;return rr[Math.abs(e)%rr.length]??rr[0]}var tl={right:"50% 50% 3px 50%",left:"50% 50% 50% 3px"},el={right:"50% 50% 2px 50%",left:"50% 50% 50% 2px"};function Yt(t,e){let{placement:r}=Ne({anchor:{x:t.viewportX-Dt/2,y:t.viewportY-Dt/2,width:Dt,height:Dt},popover:{width:332,height:200},viewport:e});return r==="right"?"left":"right"}function pe(t,e){return {x:e==="left"?t.viewportX:t.viewportX-Dt,y:t.viewportY-Dt,width:Dt,height:Dt}}function Mr({ref:t,...e}){let r=e.pointSide??"right",n=!e.resolved&&e.attention?rl[e.attention]:null,{url:o,seed:s}=We(e.avatarSrc),i=s??e.generatedSeed,a=e.resolved?"saturate(0.55) brightness(1.04) contrast(0.92)":"",l=r==="right"?"-bottom-0.5 -left-0.5":"-bottom-0.5 -right-0.5";return jsx(m.button,{ref:t,type:"button",onClick:e.onClick,"aria-label":e.ariaLabel??"Open annotation","data-patch-ephemeral":e.ephemeral?"":void 0,"data-patch-pin-id":e.pinId,className:"patch-pin-button fixed z-[2147483645] border-0 bg-transparent p-0",style:{width:Dt,height:Dt},initial:e.ephemeral?{opacity:0,scale:.45}:false,animate:e.ephemeral?{opacity:1,scale:1,transition:{type:"spring",stiffness:620,damping:30,mass:.65}}:{opacity:1,scale:1},exit:e.ephemeral?{opacity:0,scale:.45,transition:{delay:.16,duration:.14,ease:bo}}:{opacity:0,scale:.9,transition:{duration:.12,ease:bo}},children:jsxs("span",{className:"patch-pin relative grid size-full place-items-center","data-patch-point-side":r,style:{borderRadius:tl[r]},children:[jsxs("span",{"data-patch-avatar":"",className:"absolute inset-[2px] overflow-hidden",style:{borderRadius:el[r],background:"var(--color-muted-foreground)"},children:[i?jsx(er,{seed:i,style:{borderRadius:0,filter:a||"none"}}):null,o?jsx("img",{src:o,alt:e.avatarAlt??"",referrerPolicy:"no-referrer",className:"absolute inset-0 size-full object-cover",draggable:false,style:{filter:a||"none"},onError:c=>{c.currentTarget.remove();}}):null]}),e.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":e.attention,"aria-hidden":"true",className:`absolute -top-0.5 -right-0.5 size-[10px] rounded-full border-[1.5px] border-white ${n}`})]})})}var rl={"review-pr":"bg-brand","patch-failed":"bg-destructive","rerun-after-closed":"bg-muted-foreground"};function nr(t){let e=new Date(t).getTime(),r=Date.now()-e,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 xo(t){let e=t.composedPath();for(let r of e)if(r instanceof Element&&r.tagName?.toLowerCase()==="patch-widget-root")return true;return false}function wo(t){let e=t.match(/\/pull\/(\d+)/);return e?`#${e[1]}`:"PR"}var yo={"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"}]],camera:[["path",{d:"M12.6974 3.5H11.303C10.5884 3.5 10.2311 3.5 9.91067 3.612C9.71499 3.68039 9.53113 3.77879 9.36568 3.90367C9.09474 4.10816 8.89655 4.40544 8.50018 5L8.50017 5.00001C8.29717 5.30453 7.99794 5.75337 7.87867 5.87871C7.58314 6.18927 7.19563 6.39666 6.77329 6.47029C6.60284 6.5 6.41985 6.5 6.05387 6.5C5.07379 6.5 4.58376 6.5 4.18307 6.61342C3.18074 6.89716 2.39734 7.68055 2.1136 8.68289C2.00018 9.08357 2.00018 9.57361 2.00018 10.5537V14.5C2.00018 17.3284 2.00018 18.7426 2.87886 19.6213C3.75754 20.5 5.17176 20.5 8.00018 20.5H16.0002C18.8286 20.5 20.2428 20.5 21.1215 19.6213C22.0002 18.7426 22.0002 17.3284 22.0002 14.5V10.5537C22.0002 9.57361 22.0002 9.08357 21.8868 8.68289C21.603 7.68055 20.8196 6.89716 19.8173 6.61342C19.4166 6.5 18.9266 6.5 17.9465 6.5C17.5805 6.5 17.3975 6.5 17.2271 6.47029C16.8047 6.39666 16.4172 6.18927 16.1217 5.87871C16.0024 5.75336 15.7032 5.30451 15.5002 5C15.1038 4.40544 14.9056 4.10816 14.6347 3.90367C14.4692 3.77879 14.2854 3.68039 14.0897 3.612C13.7693 3.5 13.412 3.5 12.6974 3.5Z"}],["path",{d:"M16.0002 13C16.0002 15.2091 14.2093 17 12.0002 17C9.79104 17 8.00018 15.2091 8.00018 13C8.00018 10.7909 9.79104 9 12.0002 9C14.2093 9 16.0002 10.7909 16.0002 13Z"}],["path",{d:"M19.1252 9.5H19.0002M19.2502 9.5C19.2502 9.63807 19.1383 9.75 19.0002 9.75C18.8621 9.75 18.7502 9.63807 18.7502 9.5C18.7502 9.36193 18.8621 9.25 19.0002 9.25C19.1383 9.25 19.2502 9.36193 19.2502 9.5Z"}]],check:[["path",{d:"M5 14L8.5 17.5L19 6.5"}]],"chevron-left":[["path",{d:"M15 6C15 6 9.00001 10.4189 9 12C8.99999 13.5812 15 18 15 18"}]],"chevron-right":[["path",{d:"M9.00005 6C9.00005 6 15 10.4189 15 12C15 13.5812 9 18 9 18"}]],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"}]],paperclip:[["path",{d:"M5.82338 12L4.27922 10.4558C2.57359 8.75022 2.57359 5.98485 4.27922 4.27922C5.98485 2.57359 8.75022 2.57359 10.4558 4.27922L19.7208 13.5442C21.4264 15.2498 21.4264 18.0152 19.7208 19.7208C18.0152 21.4264 15.2498 21.4264 13.5442 19.7208L10.0698 16.2464C9.00379 15.1804 9.00379 13.4521 10.0698 12.386C11.1358 11.32 12.8642 11.32 13.9302 12.386L15.8604 14.3162"}]],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 M({name:t,size:e=16,stroke:r=2,color:n,className:o}){return jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:n??"currentColor",strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",className:o,children:yo[t].map(([s,i],a)=>createElement(s,{key:a,...i}))})}var Co=[.16,1,.3,1];function al(t){try{let r=new URL(t).pathname.replace(/\/$/,"");return r===""?"/":r}catch{return t}}function or(t){return t==="pending"||t==="acknowledged"}function Ao({onClose:t}){let e=ce(),{hideResolvedAnnotations:r}=Ut(),n=e.focusPin,o=typeof window>"u"?"":ot(window.location.href),s=useMemo(()=>[...r?e.entries.filter(d=>d.status!=="resolved"):e.entries].sort((d,u)=>(or(d.status)?0:1)-(or(u.status)?0:1)),[e.entries,r]),i=useMemo(()=>{let c=e.entries.filter(u=>or(u.status)&&ot(u.url)===o).length,d=e.entries.filter(u=>or(u.status)).length;return {here:c,elsewhere:d-c,total:d}},[e.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){t(),n(c);}return jsxs(m.div,{initial:{opacity:0,y:6,scale:.98},animate:{opacity:1,y:0,scale:1,transition:{duration:.18,ease:Co}},exit:{opacity:0,y:4,scale:.985,transition:{duration:.12,ease:Co}},"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: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(sl,{entry:c,onCurrentPage:ot(c.url)===o,onClick:()=>l(c)},c.id))})]})}function sl({entry:t,onCurrentPage:e,onClick:r}){let n=t.status==="resolved",o=t.anchorStatus==="detached";return jsxs("button",{type:"button","data-patch-fab-dock":"","data-patch-roster-row":t.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(M,{name:"check",size:10,stroke:2.6})}):t.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:C("block truncate text-[12.5px] leading-snug",n?"text-popover-foreground/45 line-through":"text-popover-foreground"),children:t.label}),jsxs("span",{className:"mt-0.5 flex items-center gap-1.5 text-[11px] text-popover-foreground/50",children:[jsx(M,{name:Et[t.viewport].glyph,size:11,className:"shrink-0 opacity-80"}),jsx("span",{className:"truncate",children:e?"This page":al(t.url)}),jsx("span",{"aria-hidden":"true",children:"\xB7"}),jsx("span",{className:"shrink-0",children:nr(t.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(M,{name:"unlink",size:10}),"element gone"]}):null]})]})]})}var ll="relative inline-grid shrink-0 overflow-hidden place-items-center rounded-full text-white font-semibold tracking-[-0.01em]",cl={sm:"size-[22px] text-[9.5px]",md:"size-7 text-[10.5px]"};function Gt({initials:t,tint:e,src:r,generatedSeed:n,alt:o="",size:s="md",className:i,style:a}){let{url:l,seed:c}=We(r),d=c??n;return jsxs("span",{className:C(ll,cl[s],i),style:{background:e,...a},children:[jsx("span",{children:t}),!l&&d?jsx(er,{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:u=>{u.currentTarget.remove();}}):null]})}var ul="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",pl="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 Le({size:t=16,className:e}){return jsx("svg",{width:t,height:t,viewBox:"0 0 96 96",fill:"currentColor","aria-hidden":"true",focusable:"false",className:e,children:jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:ul})})}function So({size:t=16,variant:e="filled",stroke:r=2,className:n}){let o=e==="outline";return jsx("svg",{width:t,height:t,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:pl})})}var Lr=false,jt=null,ar=null,Rt={openDelay:700,isInstant(){return Lr},onOpen(t){ar&&ar!==t&&ar(),ar=t??null,Lr=true,jt&&(clearTimeout(jt),jt=null);},onClose(){jt&&clearTimeout(jt),jt=setTimeout(()=>{Lr=false,jt=null;},300);}};var Ro="easeOut";function st({text:t,children:e,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&&Rt.onClose();},[]);let u=w=>{l(w),i(true),d.current=true,Rt.onOpen();},p=()=>{if(c.current&&(clearTimeout(c.current),c.current=null),Rt.isInstant()){u(true);return}c.current=setTimeout(()=>{c.current=null,u(false);},Rt.openDelay);},m$1=()=>{c.current&&(clearTimeout(c.current),c.current=null),d.current&&(d.current=false,Rt.onClose()),i(false);},x=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",f="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",b=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 ${f}`:`relative block whitespace-nowrap rounded-md bg-foreground px-2.5 py-[6px] text-[11px] font-medium tracking-[0.01em] text-white ${f}`,h=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",k=o==="bottom"&&n!=="warning"?-3:3,E=o==="bottom"&&n!=="warning"?-2:2;return jsxs("span",{className:C("relative inline-flex items-center justify-center",r),onMouseEnter:p,onMouseLeave:m$1,onMouseDown:m$1,children:[jsx("span",{className:x,children:jsx(AnimatePresence,{children:s&&jsxs(m.span,{initial:a?false:{opacity:0,y:k,scale:.98},animate:{opacity:1,y:0,scale:1,transition:a?{duration:0}:{duration:.1,ease:Ro}},exit:{opacity:0,y:E,scale:.98,transition:{duration:.08,ease:Ro}},className:b,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:t}),jsx("span",{className:h})]})})}),e]})}var Io=44,Ot=[.16,1,.3,1],No="easeOut",bl=.08,vl=60,xl="calc(100% - 64px) calc(100% + 4px)",he="pkey pkey-dock grid size-8 place-items-center rounded-full border-0 bg-transparent";function Mo(){let t=oo(),e=xt(),r=it(),n=ce(),{dockOpen:o,hideResolvedAnnotations:s,setDockOpen:i,setHideResolvedAnnotations:a}=Ut(),l=!!r.studio,c=n.unresolvedCount,[d,u]=useState(false),[p,m$1]=useState(false),[x,f]=useState(false),[b,h]=useState(false),[k,E]=useState(false),[w,H]=useState(false),L=useRef(null),g=useRef(null),I=useRef(false),[U,ct]=useState(false),dt=useRef(null),[ht,ut]=useState(Io);useLayoutEffect(()=>{let F=dt.current;if(!F)return;let mt=()=>ut(F.offsetWidth);mt();let St=new ResizeObserver(mt);return St.observe(F),()=>St.disconnect()},[]);let pt=r.studio?r.studio.name:r.identity?.name??null,rt=de(pt),j=r.studio?.image??null,A=r.identity?.avatarSeed??r.clientAvatarSeed,R=r.studio?.userId??A,D=r.studio?"var(--color-foreground)":ue(A),G=r.studio&&!j?"#FFFFFF":D,W=r.studio&&!j?"text-foreground":"text-white",v=Et[r.activeViewport];function $(){L.current!==null&&(window.clearTimeout(L.current),L.current=null);}function O(){g.current!==null&&(window.clearTimeout(g.current),g.current=null);}let X=useRef(()=>{});X.current=()=>{!I.current&&L.current===null||($(),O(),I.current=false,H(true));};let S=useRef(()=>X.current()).current;useEffect(()=>{w&&d&&u(false);},[w,d]);function P(F){m$1(false),f(false),h(false),$(),O(),I.current=true,H(false),E(F),Rt.onOpen(S),u(true);}function N(){P(false);}function K(){if($(),!(I.current||g.current!==null)){if(Rt.isInstant()){P(true);return}g.current=window.setTimeout(()=>{g.current=null,P(false);},Rt.openDelay);}}function tt(){O(),$(),I.current&&(I.current=false,Rt.onClose()),L.current=window.setTimeout(()=>{u(false),L.current=null;},120);}function It(){ct(true),i(true);}function Tt(){m$1(false),f(false),h(false),O(),I.current=false,u(false),t.isCapturing?t.exit():t.enter();}function Fe(){m$1(false),f(false),O(),I.current=false,u(false),h(F=>{let mt=!F;return mt&&n.refresh(),mt});}function Be(){ct(true),i(false),m$1(false),f(false),h(false),O(),I.current=false,u(false),t.exit(),e.active&&e.forceClose();}useEffect(()=>()=>{L.current!==null&&window.clearTimeout(L.current),g.current!==null&&window.clearTimeout(g.current);},[]);let gr=()=>{r.signOut(),u(false);};function T(){f(false),h(false),O(),I.current=false,u(false),m$1(F=>!F);}function z(F){m$1(false),r.activeViewport!==F&&(e.active&&e.forceClose(),r.setActiveViewport(F));}function _(){m$1(false),h(false),O(),I.current=false,u(false),f(F=>!F);}function V(){a(!s);}function B(F){let mt=F.relatedTarget;mt instanceof Node&&F.currentTarget.contains(mt)||tt();}return jsxs("div",{"data-patch-fab-dock":"",className:"fixed right-5 bottom-5 z-[2147483647] flex justify-end",children:[jsxs(m.div,{initial:false,animate:{width:o?ht:Io},transition:{duration:.36,ease:Ot},onAnimationComplete:()=>ct(false),whileHover:o?void 0:{scale:1.03,transition:{duration:.15,ease:Ot}},whileTap:o?void 0:{scale:.97,transition:{duration:.1,ease:Ot}},"data-patch-fab-dock":"",className:C("pkey-fab relative h-11 rounded-full",U?"overflow-hidden":"overflow-visible"),children:[jsx(m.div,{animate:{opacity:o?0:1,scale:o?.7:1},transition:{duration:.18,ease:Ot},className:C("absolute inset-0",o?"pointer-events-none":"pointer-events-auto"),children:jsx("button",{type:"button",onClick:It,"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(Le,{size:18})})}),jsxs("div",{ref:dt,"data-patch-fab-dock":"",className:C("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(be,{visible:o,index:0,children:jsx(st,{text:t.isCapturing?"Stop commenting":"Add comment",children:jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":t.isCapturing?"Stop commenting":"Add comment","aria-pressed":t.isCapturing,onClick:Tt,className:C(he,"transition-colors",t.isCapturing?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:jsx(So,{variant:"outline",size:16})})})}),l?jsx(be,{visible:o,index:1,children:jsx(st,{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":b,onClick:Fe,className:C(he,"relative transition-colors",b||c>0?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:[jsx(M,{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(be,{visible:o,index:2,children:jsxs("div",{className:"relative flex items-center",children:[jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":`Viewport: ${v.label}`,"aria-expanded":p,onClick:T,className:C(he,"transition-colors",r.activeViewport==="desktop"&&!p?"text-white/70 hover:bg-white/[0.08] hover:text-white":"bg-brand/15 text-brand"),children:jsx(M,{name:v.glyph,size:15})}),jsx(AnimatePresence,{children:p?jsxs(m.div,{initial:{opacity:0,y:4,scale:.97},animate:{opacity:1,y:0,scale:1,transition:{duration:.16,ease:Ot}},exit:{opacity:0,y:3,scale:.98,transition:{duration:.12,ease:Ot}},"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"}),cn.map(F=>{let mt=Et[F],St=r.activeViewport===F;return jsx(st,{text:ee(F),children:jsx("button",{type:"button","data-patch-viewport-option":F,"aria-label":ee(F),"aria-pressed":St,onClick:()=>z(F),className:C("grid size-8 place-items-center rounded-full border-0 bg-transparent transition-colors",St?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:jsx(M,{name:mt.glyph,size:15})})},F)})]}):null})]})}),jsx(be,{visible:o,index:3,children:jsxs("div",{className:"relative flex items-center",children:[jsx(st,{text:"Settings",children:jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":"Settings","aria-expanded":x,onClick:_,className:C(he,"transition-colors",x||s?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:jsx(M,{name:"settings",size:15})})}),jsx(AnimatePresence,{children:x?jsxs(m.div,{initial:{opacity:0,y:4,scale:.97},animate:{opacity:1,y:0,scale:1,transition:{duration:.16,ease:Ot}},exit:{opacity:0,y:3,scale:.98,transition:{duration:.12,ease:Ot}},"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:s,"aria-label":"Hide resolved annotations",onChange:V,className:"peer sr-only"}),jsx("span",{"aria-hidden":"true",className:C("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(M,{name:"check",size:10,stroke:2.4})}),jsx("span",{className:"min-w-0 flex-1 whitespace-nowrap",children:"Hide resolved annotations"})]})]}):null})]})}),jsx(be,{visible:o,index:4,children:jsxs("span",{"data-patch-identity-hover":"",className:"relative inline-flex items-center justify-center",onMouseEnter:K,onMouseLeave:tt,onFocus:N,onBlur:B,children:[jsx("button",{type:"button","data-patch-fab-dock":"","data-patch-person-btn":"","aria-label":pt?`Account: ${pt}`:"Identify",className:C(he,"text-white"),children:pt?jsx(Gt,{initials:rt,tint:G,src:j,generatedSeed:R,alt:pt,size:"sm",className:C("size-[22px] text-[9.5px] ring-1 ring-white/20",W)}):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(m.div,{initial:k?false:{opacity:0,y:3,scale:.98},animate:{opacity:1,y:0,scale:1,transition:k?{duration:0}:{duration:.12,delay:bl,ease:No}},exit:{opacity:0,y:2,scale:.98,transition:w?{duration:0}:{duration:.08,ease:No}},"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:xl},children:[jsx("span",{className:"absolute bottom-[-4px] size-2 rotate-45 border-r border-b border-white/10 bg-foreground",style:{right:vl}}),r.studio?jsxs("div",{className:"flex items-center gap-2.5",children:[jsx(Gt,{initials:rt,tint:D,src:j,generatedSeed:R,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(Gt,{initials:rt,tint:D,generatedSeed:R,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:gr,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(be,{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(st,{text:"Close",children:jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":"Close",onClick:Be,className:C(he,"text-white/70"),children:jsx(M,{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:b?jsx(Ao,{onClose:()=>h(false)}):null})]})}function be({children:t,visible:e,index:r}){return jsx(m.div,{initial:{opacity:0,x:6},animate:e?{opacity:1,x:0,transition:{duration:.2,delay:.12+r*.035,ease:Ot}}:{opacity:0,x:6,transition:{duration:.12,ease:Ot}},children:t})}function _o(t,e){return e.width<=0||e.height<=0?{fx:0,fy:0}:{fx:(t.viewportX-e.x)/e.width,fy:(t.viewportY-e.y)/e.height}}function Lo(t,e){return {viewportX:e.x+t.fx*e.width,viewportY:e.y+t.fy*e.height}}var yl=.6,kl=.5,lr={text:.4,attrs:.3,classes:.2,position:.1},Cl=5e3,Al=.08,Sl=.12;function Tl(t,e){return e===void 0||e===""?.5:t===e?1:t&&(t.includes(e)||e.includes(t))?.5:0}function El(t,e){if(!e)return .5;let r=Object.keys(e);if(r.length===0)return .5;let n=0;for(let o of r)t[o]===e[o]&&n++;return n/r.length}function Rl(t,e){let r=new Set(t),n=new Set(e??[]);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 Oo(t){let e=t.payload.boundingBox;if(!e)return null;let r=t.payload.coordinates.documentY-t.payload.coordinates.viewportY;return {x:e.x+e.width/2,y:e.y+e.height/2+r}}function Or(t,e,r){if(!e)return .5;let n=t.left+t.width/2,o=t.top+r.scrollY+t.height/2,s=(n-e.x)/Math.max(1,r.viewport.width),i=(o-e.y)/Math.max(1,r.viewport.height);return Math.max(0,1-Math.sqrt(s*s+i*i))}function Pl(t,e){let r=je(t),n=qe(t),o=Re(t),s=t.getBoundingClientRect(),i=Tl(r,e.payload.domHints?.textSignature),a=El(n,e.payload.domHints?.attributeSignature),l=Rl(o,e.payload.cssClasses),c=Or(s,Oo(e),e);return lr.text*i+lr.attrs*a+lr.classes*l+lr.position*c}function Il(t){let e=t.getBoundingClientRect();return e.width<1&&e.height<1}function Do(t,e,r){let n=null,o=null,s=0;for(let i=0;i<t.length&&!(s>=Cl);i++){let a=t[i];if(!a||(s++,Kn(a,e.internalAttr)))continue;let l=a.tagName.toLowerCase();if(l==="html"||l==="head"||l==="script"||l==="style"||Il(a))continue;let c=Pl(a,e);!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<Al){let i=Oo(e),a=Or(n.el.getBoundingClientRect(),i,e),l=Or(o.el.getBoundingClientRect(),i,e);if(a-l<Sl)return null}return n.el}function Nl(t){return {viewportX:t.payload.coordinates.viewportX,viewportY:t.payload.coordinates.documentY-t.scrollY}}function Ml(t,e){let r=t.getBoundingClientRect();if(!e.payload.boundingBox)return {viewportX:r.x,viewportY:r.y};let n=_o({viewportX:e.payload.coordinates.viewportX,viewportY:e.payload.coordinates.viewportY},e.payload.boundingBox);return Lo(n,{x:r.x,y:r.y,width:r.width,height:r.height})}function _l(t){let e=t.payload.domHints?.cssSelector;if(!e)return [];try{return Array.from(t.doc.querySelectorAll(e))}catch{return []}}function cr(t){if(!t.payload.domHints)return {kind:"detached",el:null};let e=_l(t);if(e.length>0){let n=Do(e,t,kl);if(n)return {kind:"anchored",tier:1,el:n}}let r=Do(t.doc.querySelectorAll("*"),t,yl);return r?{kind:"anchored",tier:2,el:r}:{kind:"detached",el:null}}function zr(t,e){return t.kind==="anchored"&&t.el?Ml(t.el,e):Nl(e)}function zo(t){let e=cr(t);return {kind:e.kind,tier:e.tier,el:e.el,position:zr(e,t)}}function Ho(t){if(t.status==="resolved")return null;let e=t.latestRun;return e?e.status==="failed"?"patch-failed":e.status!=="succeeded"?null:e.prClosedUnmerged?"rerun-after-closed":e.prUrl?"review-pr":null:null}var Dl="data-patch-internal",Bo=[2e4,6e4,3e5];function Ol(t){let e=Math.min(Math.max(1,t),Bo.length)-1;return Bo[e]??3e5}function Vo(t,e,r){let n=Yt(r,e.getOverlayViewport()),o=pe(r,n);t.style.top=`${o.y}px`,t.style.left=`${o.x}px`;}function Wo(t,e){return Math.abs(t.viewportX-e.viewportX)<.5&&Math.abs(t.viewportY-e.viewportY)<.5}function zl(t){let e=t.getBoundingClientRect();return e.width<1&&e.height<1}function Fr(t,e){return {payload:e.payload,doc:t.targetDocument,scrollY:t.getTargetScrollY(),viewport:t.getTargetViewport(),internalAttr:Dl}}function Uo(t,e,r){let n=Fr(t,e);return {kind:r.kind,position:t.targetPointToOverlay(zr(r,n))}}function Hl(t,e){return t.targetPointToOverlay({viewportX:e.viewportX,viewportY:e.documentY-t.getTargetScrollY()})}function Yo(){let{annotations:t,annotationsReady:e,ephemerals:r,identity:n,studio:o,clientAvatarSeed:s,apiClient:i}=it(),a=xt(),{dockOpen:l,hideResolvedAnnotations:c}=Ut(),d=vt(),{isPreviewing:u,previewReady:p}=ie(),m=useReducedMotion(),x=a.active,f=a.forceClose,b=e&&(!u||p),h=useMemo(()=>l&&e?t.filter(A=>!c||A.status!=="resolved"):[],[l,e,t,c]),k=useMemo(()=>l&&e?r:[],[l,e,r]);useEffect(()=>{if(!c||x?.kind!=="existing")return;t.find(R=>R.id===x.annotationId)?.status==="resolved"&&f();},[x,t,f,c]);let E=useRef(new Map),w=useRef(new Map),H=useRef(new Map),L=useRef(new Map),g=useRef(new Map),I=useMemo(()=>{let A=L.current,R=g.current,D=performance.now(),G=new Set,W=new Map;for(let v of h){G.add(v.id);let $=A.get(v.id),O=$?.kind==="anchored"&&$.el?.isConnected,X;if(O)X=$,R.delete(v.id);else {let S=R.get(v.id);if($?.kind==="detached"&&S&&D<S.nextAt)X=$;else if(X=cr(Fr(d,v)),X.kind==="detached"){let P=(S?.attempts??0)+1;R.set(v.id,{attempts:P,nextAt:D+Ol(P)});}else R.delete(v.id);}A.set(v.id,X),W.set(v.id,Uo(d,v,X));}for(let v of A.keys())G.has(v)||(A.delete(v),R.delete(v));return W},[d,h]),U=useCallback(()=>{let A=L.current,R=H.current,D=new Set,G=d.getOverlayViewport(),W=[];for(let v of h){let $=E.current.get(v.id);if(!$)continue;D.add(v.id);let O=A.get(v.id);if((!O||O.kind==="anchored"&&O.el&&!O.el.isConnected)&&(O=cr(Fr(d,v)),A.set(v.id,O)),O.kind==="detached"||O.kind==="anchored"&&O.el&&zl(O.el)){W.push({el:$,id:v.id,kind:"hide"});continue}let X=Uo(d,v,O).position,S=R.get(v.id);if(S&&Wo(S,X)&&$.style.visibility!=="hidden")continue;let P=Yt(X,G),N=pe(X,P);W.push({el:$,id:v.id,kind:"place",position:X,box:{viewportX:N.x,viewportY:N.y}});}for(let v of k){let $=w.current.get(v.tempId);if(!$)continue;D.add(v.tempId);let O=Hl(d,v),X=R.get(v.tempId);if(X&&Wo(X,O))continue;let S=Yt(O,G),P=pe(O,S);W.push({el:$,id:v.tempId,kind:"place",position:O,box:{viewportX:P.x,viewportY:P.y}});}for(let v of W){if(v.kind==="hide"){v.el.style.visibility!=="hidden"&&(v.el.style.visibility="hidden"),R.delete(v.id);continue}v.el.style.visibility==="hidden"&&(v.el.style.visibility=""),v.el.style.top=`${v.box.viewportY}px`,v.el.style.left=`${v.box.viewportX}px`,R.set(v.id,v.position);}for(let v of R.keys())D.has(v)||R.delete(v);},[d,h,k]),ct=h.length>0||k.length>0;useEffect(()=>{if(!ct)return;let A=d.overlayWindow,R=A.requestAnimationFrame(function D(){U(),R=A.requestAnimationFrame(D);});return ()=>A.cancelAnimationFrame(R)},[ct,U,d]);let dt=useRef(new Map);useEffect(()=>{if(!e||h.length===0)return;let A=setTimeout(()=>{let R=[];for(let D of h){let G=I.get(D.id);if(!G)continue;let W=G.kind!=="detached";dt.current.get(D.id)!==W&&(dt.current.set(D.id,W),R.push({id:D.id,present:W}));}i.reportAnchorStatuses(R);},1500);return ()=>clearTimeout(A)},[I,h,e,i]);let ht=useCallback(A=>{if(a.active&&a.hasDraft){a.attemptClose();return}a.openExisting(A);},[a]),ut=o?o.name:n?.name??null,pt=o?.image??null,rt=n?.avatarSeed??s,j=o?.userId??rt;return jsxs("div",{"data-patch-pin-layer":"",style:{opacity:b?1:0,transition:m||!b?void 0:"opacity 0.2s cubic-bezier(0.22, 0.61, 0.36, 1)",pointerEvents:b?void 0:"none"},children:[jsx(AnimatePresence,{initial:false,children:h.map(A=>{let R=I.get(A.id);if(R?.kind==="detached")return null;let D=$l(A),G=!o&&!!n?.clientUserId&&A.payload.authorRole==="client"&&A.payload.authorId===n.clientUserId,W=o?Ho(A):null,v=R?Yt(R.position,d.getOverlayViewport()):"right";return jsx(Mr,{ref:$=>{$?(E.current.set(A.id,$),R&&Vo($,d,R.position)):E.current.delete(A.id);},avatarSrc:D.image,generatedSeed:G?rt:D.generatedSeed,avatarAlt:D.name??"",resolved:A.status==="resolved",attention:W,pointSide:v,ariaLabel:`Annotation by ${A.authorName??"someone"}`,onClick:()=>ht(A.id),pinId:A.id},A.id)})}),jsx(AnimatePresence,{initial:false,children:k.map(A=>{let R=d.targetPointToOverlay({viewportX:A.viewportX,viewportY:A.viewportY});return jsx(Mr,{ref:D=>{D?(w.current.set(A.tempId,D),Vo(D,d,R)):w.current.delete(A.tempId);},avatarSrc:pt,generatedSeed:j,avatarAlt:ut??"",resolved:false,pointSide:Yt(R,d.getOverlayViewport()),ephemeral:true},A.tempId)})})]})}function $l(t){let e=t.authorAvatarSeed??t.payload.authorId??(t.authorName?`annotation-author:${t.authorName}`:null);if(t.authorImage||e||t.authorName)return {name:t.authorName,image:t.authorImage??null,generatedSeed:e??t.id,key:t.payload.authorId??t.authorName??t.id};let r=t.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??t.id,key:r.authorId??r.authorName??t.id}}return {name:t.authorName,image:t.authorImage??null,generatedSeed:t.id,key:t.id}}var Ul=5e3;function Xo(){let t=ce(),e=it(),r=xt(),n=Ut(),o=vt(),s=useReducedMotion(),i=t.pendingFocus,a=useRef(null),l=useCallback(()=>{a.current!==null&&(window.clearTimeout(a.current),a.current=null);},[]);return useEffect(()=>{if(!i)return;if(ot(window.location.href)!==ot(i.url)){t.clearFocus();return}if(n.dockOpen||n.setDockOpen(true),e.activeViewport!==i.viewport){e.setActiveViewport(i.viewport);return}if(!e.annotationsReady)return;let c=e.annotations.find(u=>u.id===i.id);if(!c){a.current===null&&(a.current=window.setTimeout(()=>{a.current=null,t.clearFocus();},Ul));return}l();let d=c.payload.coordinates?.documentY;if(typeof d=="number"){let u=o.getTargetViewport().height;o.targetWindow.scrollTo({top:Math.max(0,d-u/3),behavior:s?"auto":"smooth"});}r.openExisting(i.id),t.clearFocus();},[i,e,n,o,s,r,t,l]),useEffect(()=>()=>l(),[l]),null}function Yl(){for(let t of [document.body,document.documentElement]){let e=window.getComputedStyle(t).backgroundColor;if(e&&e!=="transparent"&&e!=="rgba(0, 0, 0, 0)")return e}return "#ffffff"}async function Ko(t){try{let{snapdom:e}=await import('@zumer/snapdom'),r=Math.min(window.devicePixelRatio||1,2),n=await e.toCanvas(document.body,{dpr:r,exclude:["[data-patch-internal]"],embedFonts:!0}),o=document.body.getBoundingClientRect(),s=n.width/Math.max(1,o.width),i=document.createElement("canvas");i.width=Math.max(1,Math.round(t.width*r)),i.height=Math.max(1,Math.round(t.height*r));let a=i.getContext("2d");return a?(a.fillStyle=Yl(),a.fillRect(0,0,i.width,i.height),a.drawImage(n,(t.x-o.left)*s,(t.y-o.top)*s,t.width*s,t.height*s,0,0,i.width,i.height),await new Promise(l=>i.toBlob(l,"image/webp",.92))):null}catch{return null}}var Kl='<svg xmlns="http://www.w3.org/2000/svg" width="34" height="34" viewBox="0 0 34 34"><g stroke="#fff" stroke-width="3.5" stroke-linecap="round"><path d="M12 3v6.5M12 14.5V21M3 12h6.5M14.5 12H21"/></g><g stroke="#1F1F1F" stroke-width="1.5" stroke-linecap="round"><path d="M12 3v6.5M12 14.5V21M3 12h6.5M14.5 12H21"/></g><g><rect x="20" y="22" width="13" height="10" rx="2.5" fill="#1F1F1F" stroke="#fff"/><circle cx="26.5" cy="27" r="2.6" fill="none" stroke="#fff" stroke-width="1.4"/></g></svg>',ql=`url("data:image/svg+xml,${encodeURIComponent(Kl)}") 12 12, crosshair`,Vr=4;function Zo(t,e){return {x:Math.min(t.x,e.x),y:Math.min(t.y,e.y),width:Math.abs(t.x-e.x),height:Math.abs(t.y-e.y)}}function Jo({capturing:t,onSelect:e,onCancel:r}){let n=useReducedMotion(),[o,s]=useState(null),[i,a]=useState(null),[l,c]=useState(null);useEffect(()=>{let f=b=>{b.key==="Escape"&&(b.preventDefault(),b.stopPropagation(),t||r());};return document.addEventListener("keydown",f,true),()=>document.removeEventListener("keydown",f,true)},[t,r]);let d=useCallback(f=>({x:Math.min(Math.max(f.x,0),window.innerWidth),y:Math.min(Math.max(f.y,0),window.innerHeight)}),[]),u=useCallback((f,b)=>{let h=Zo(f,b);s(null),a(null),!(h.width<Vr||h.height<Vr)&&(c(h),e(h));},[e]);useEffect(()=>{if(!o)return;let f=h=>{a(d({x:h.clientX,y:h.clientY}));},b=h=>{u(o,d({x:h.clientX,y:h.clientY}));};return window.addEventListener("mousemove",f),window.addEventListener("mouseup",b),()=>{window.removeEventListener("mousemove",f),window.removeEventListener("mouseup",b);}},[o,d,u]);let p=l??(o&&i?Zo(o,i):null),m$1=!!p&&p.width>=Vr/2,x=p?p.y+p.height+30<window.innerHeight:true;return jsxs("div",{"data-patch-screenshot-overlay":"",role:"dialog","aria-label":"Capture a screenshot",className:"fixed inset-0 z-[2147483647] select-none",style:{cursor:t?"progress":ql},onMouseDown:f=>{if(f.button!==0||t)return;f.preventDefault();let b=d({x:f.clientX,y:f.clientY});s(b),a(b);},children:[m$1&&p?jsx("div",{className:"pointer-events-none absolute rounded-[3px] border-[1.5px] border-brand bg-brand/10 shadow-[0_0_0_1px_rgba(255,255,255,0.55)]",style:{left:p.x,top:p.y,width:p.width,height:p.height},children:jsx("span",{className:C("absolute right-0 whitespace-nowrap rounded-md bg-foreground px-2 py-1 font-sans text-[11px] font-medium tabular-nums text-white shadow-[0_3px_8px_-3px_rgba(0,0,0,0.3)]",x?"top-[calc(100%+6px)]":"bottom-[calc(100%+6px)]"),children:t?jsxs("span",{className:"inline-flex items-center gap-1.5",children:[jsx("span",{className:"size-2.5 animate-spin rounded-full border border-white/40 border-t-white"}),"Capturing\u2026"]}):`${Math.round(p.width)} \xD7 ${Math.round(p.height)}`})}):null,!o&&!t?jsxs(m.div,{initial:n?false:{opacity:0,y:-4},animate:{opacity:1,y:0,transition:{duration:.15,ease:"easeOut"}},className:"pointer-events-none absolute top-4 left-1/2 -translate-x-1/2 rounded-full bg-foreground/90 px-3.5 py-2 font-sans text-[12px] font-medium text-white shadow-[0_10px_30px_-10px_rgba(0,0,0,0.45)]",children:["Drag to capture",jsx("span",{className:"mx-2 opacity-40",children:"\xB7"}),jsx("kbd",{className:"rounded bg-white/16 px-1.5 py-0.5 font-sans text-[11px]",children:"Esc"}),jsx("span",{className:"ml-1.5 opacity-70",children:"to cancel"})]}):null]})}var ei=createContext(null);function ri({children:t}){let e=xt(),[r,n]=useState("idle"),o=useRef(null),s=useRef(false);s.current=r!=="idle";let i=useCallback(()=>{o.current=null,n("idle");},[]),a=e.active!==null;useEffect(()=>{!a&&s.current&&i();},[a,i]);let l=useCallback(async u=>{s.current||(o.current=u,n("select"));},[]),c=useCallback(async u=>{n("capturing");let p=await Ko(u),m=o.current;i(),p&&m&&m(p);},[i]),d=useMemo(()=>({supported:true,active:r!=="idle",begin:l}),[r,l]);return jsxs(ei.Provider,{value:d,children:[jsx("div",{style:r==="idle"?{transition:"opacity 150ms ease-out"}:{opacity:0,pointerEvents:"none",transition:"opacity 150ms ease-out"},children:t}),r!=="idle"?jsx(Jo,{capturing:r==="capturing",onSelect:u=>{c(u);},onCancel:i}):null]})}var ec={supported:false,active:false,begin:async()=>{}};function ni(){return use(ei)??ec}var oi=`/*! tailwindcss v4.2.4 | MIT License | https://tailwindcss.com */
5
5
  @layer properties;
6
6
  @layer theme, base, components, utilities;
7
7
  @layer theme {
@@ -236,6 +236,9 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
236
236
  .relative {
237
237
  position: relative;
238
238
  }
239
+ .static {
240
+ position: static;
241
+ }
239
242
  .inset-0 {
240
243
  inset: calc(var(--spacing) * 0);
241
244
  }
@@ -2266,19 +2269,19 @@ button:not(:disabled):not(.pkey):active {
2266
2269
  }
2267
2270
  }
2268
2271
  }
2269
- `;var ni="patch-widget-root";function oi({children:t}){let[e,r]=useState(null),n=useRef(null);return useEffect(()=>{if(typeof document>"u")return;let o=document.querySelector(ni);o||(o=document.createElement(ni),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=ri,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),()=>{}},[]),e?createPortal(t,e):null}var rc=/[\s#.:[\]()>+~,\\]/;function nc(t){return !(!t||rc.test(t)||/^\d/.test(t))}function oc(t){let e=1,r=t.previousElementSibling,n=t.tagName;for(;r;)r.tagName===n&&e++,r=r.previousElementSibling;return e}function ii(t,e,r){try{let n=t.querySelectorAll(e);return n.length===1&&n[0]===r}catch{return false}}function ic(t,e){return t.id&&nc(t.id)&&(!e||ii(e,`#${t.id}`,t))?`#${t.id}`:`${t.tagName.toLowerCase()}:nth-of-type(${oc(t)})`}function ai(t,e){if(!t.tagName)return "";let r=t.ownerDocument??null,n=[],o=t,s=0;for(;o&&s<12;){let i=ic(o,r);if(n.unshift(i),i.startsWith("#"))break;let a=n.join(" > ");if(r&&ii(r,a,t))return a;if(o.tagName.toLowerCase()==="html")break;o=o.parentElement,s++;}return n.join(" > ")}var ac=80,sc=500;function li(t){return t!==null&&typeof t=="object"}function lc(t){return li(t)?"return"in t||"type"in t||"elementType"in t||"_debugOwner"in t:false}function ur(t){if(typeof t=="function")return t.displayName||t.name||null;if(!li(t))return null;let e=t.displayName;if(typeof e=="string"&&e)return e;let r=ur(t.render);if(r)return r;let n=ur(t.type);return n||null}function ci(t){return t.replace(/\s+/g," ").trim()}function di(t,e){return t.length<=e?t:`${t.slice(0,e-1).trim()}\u2026`}function cc(t){let e=ci(t).replace(/[<>]/g,"");return !e||/^[a-z]/.test(e)?null:di(e,ac)}function dc(t){let e=ur(t.elementType)??ur(t.type);return e?cc(e):null}function si(t){return di(ci(t),sc)}function uc(t){let e=t.replace(/\\/g,"/");return e.includes("/.next/")||e.includes("/node_modules/next/")||e.includes("/node_modules/react/")||e.includes("/node_modules/react-dom/")||e.includes("/node_modules/react-router/")||e.includes("/node_modules/react-router-dom/")||e.includes("/node_modules/@remix-run/")||e.includes("/node_modules/.vite/")||/(^|\/)next\/dist\//.test(e)}function pc(t){let e=t.replace(/^webpack:\/\/[^/]+\//,"").replace(/^file:\/\//,"").replace(/\\/g,"/").replace(/\/\.\//g,"/").replace(/^\.\//,"");for(let n of ["/apps/","/packages/","/src/"]){let o=e.lastIndexOf(n);if(o>=0)return si(e.slice(o+1))}let r=e.split("/").filter(Boolean);return si(r.slice(-3).join("/"))}function mc(t){let e=t._debugSource?.fileName;return typeof e!="string"||!e.trim()||uc(e)?null:pc(e)}function gc(t){let e=t;for(let r of Object.getOwnPropertyNames(t)){if(!r.startsWith("__reactFiber$")&&!r.startsWith("__reactInternalInstance$"))continue;let n=e[r];if(lc(n))return n}return null}function ui(t){let e=gc(t);if(!e)return null;let r=[],n=null,o=0;for(;e&&o<30;){let a=dc(e),l=a?Cr(a):false;a&&!l&&r[r.length-1]!==a&&r.push(a),l||(n??=mc(e)),e=e.return??e._debugOwner??null,o+=1;}let s=r.length>0?In(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 pi=500;function fc(t){return t.length<=pi?t:t.slice(0,pi)}function hc(t){return {viewportX:t.viewportX,viewportY:t.viewportY,documentY:t.viewportY+t.scrollY,isFixed:false}}function bc(t){return {x:t.x,y:t.y,width:t.width,height:t.height}}function vc(t){let e={cssSelector:ai(t)},r=qe(t);r&&(e.textSignature=r);let n=Ke(t);return Object.keys(n).length>0&&(e.attributeSignature=n),e}function mi(t){return Se(t.element,t.selectedText)}function gi(t){let{target:e,click:r,comment:n,url:o}=t,s=e.element,i=e.rect,a=Wn(s),l=Yn(s),c=Ae(s),d=Gn(s),u=ui(s),p={comment:n,element:Xe(s),elementPath:Un(s),targetLabel:Se(s,e.selectedText),timestamp:Date.now(),url:Gt(o),kind:"feedback",coordinates:hc(r),boundingBox:bc(i),domHints:vc(s)};return e.selectedText&&(p.selectedText=fc(e.selectedText)),l&&(p.nearbyText=l),c.length>0&&(p.cssClasses=c),d.length>0&&(p.nearbyElements=d),a&&(p.accessibility=a),u?.reactComponents&&(p.reactComponents=u.reactComponents),u?.sourceFile&&(p.sourceFile=u.sourceFile),p}var xc=2e3,wc=.82,yc=.85;function hi(t,e,r){return new Promise(n=>t.toBlob(n,e,r))}function bi(t){return t.startsWith("image/")&&t!=="image/gif"}async function vi(t){let e;try{e=await createImageBitmap(t);}catch{return null}try{let r=Math.min(1,xc/Math.max(e.width,e.height)),n=Math.max(1,Math.round(e.width*r)),o=Math.max(1,Math.round(e.height*r));if(r===1&&t.size<=3145728){let l=new Uint8Array(await t.slice(0,16).arrayBuffer()),c=Rn(l);if(c==="image/webp"||c==="image/jpeg")return {blob:c===t.type?t:new Blob([t],{type:c}),width:n,height:o}}let s=document.createElement("canvas");s.width=n,s.height=o;let i=s.getContext("2d");if(!i)return null;i.drawImage(e,0,0,n,o);let a=await hi(s,"image/webp",wc);return (!a||a.type!=="image/webp")&&(a=await hi(s,"image/jpeg",yc)),!a||a.size>3145728?null:{blob:a,width:n,height:o}}finally{e.close();}}async function Me(t,e){return t.kind==="composer"?e.createAnnotation(t.payload):e.reply(t.annotationId,{content:t.content,attachmentIds:t.attachmentIds})}async function xi(t,e){return e.resolve(t)}async function wi(t,e){return e.deleteAnnotation(t)}async function yi(t,e){return e.deleteMessage(t.annotationId,t.messageId)}async function ki(t,e){return t.viewerKind!=="studio"?null:e.reopen(t.annotationId)}async function Ci(t,e){return t.viewerKind!=="studio"?null:e.kickoff(t.annotationId,{guidance:t.guidance})}async function Ai(t,e){return e.postIdentity(t)}var Ei=createContext(null),Ti=0;function pr(t){return Ti+=1,`${t}-${Date.now().toString(36)}-${Ti}`}function Yr(t){return t.deliveryStatus==="sending"||t.deliveryStatus==="failed"}function Ri({annotation:t,draftTargetLabel:e,children:r}){let n=rt(),o=ft(),s=mt(),[i,a]=useState(false),[l,c]=useState(null),[d,u]=useState(null),p=useRef(false),m=t?.thread??[],v=t?.latestRun??null,f=t?.status==="resolved",b=t?Yr(t):false,h=n.viewerKind,y=useCallback(()=>h==="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,h]),T=useMemo(()=>y(),[y]),x=!!t&&t.deliveryStatus!=="sending"&&t.deliveryStatus!=="failed"&&!!T.authorId&&t.payload.authorRole===T.role&&t.payload.authorId===T.authorId,z=useCallback((S,D)=>{let _=y();return {id:pr("tmp-msg"),role:_.role,authorId:_.authorId,authorName:_.authorName,authorImage:_.authorImage,content:S,createdAt:new Date().toISOString(),deliveryStatus:"sending",attachments:D}},[y]),O=useCallback(async(S,D="upload")=>{let _=Array.from(S).filter(V=>bi(V.type));await Promise.all(_.map(async V=>{let B=await vi(V);if(!B)return;let $=pr("tmp-att"),lt=URL.createObjectURL(B.blob);if(!o.addDraftAttachment({localId:$,status:"uploading",previewUrl:lt,width:B.width,height:B.height,kind:D,attachment:null})){URL.revokeObjectURL(lt);return}let Yt=await n.apiClient.uploadAttachment(B.blob,{kind:D,width:B.width,height:B.height});o.updateDraftAttachment($,Yt?{status:"uploaded",attachment:Yt}:{status:"failed"});}));},[o,n.apiClient]),g=useCallback(async S=>{if(p.current)return Promise.reject(new Error("busy"));p.current=true,a(true);try{return await S()}finally{p.current=false,a(false);}},[]),N=useCallback(async()=>{let S=o.draftText.trim(),D=o.draftAttachments.flatMap(et=>et.status==="uploaded"&&et.attachment?[et.attachment]:[]);if(o.draftAttachments.some(et=>et.status!=="uploaded"))return;if(t){if(!S&&D.length===0||f||Yr(t))return;let et=z(S,D);o.setDraftText(""),o.clearDraftAttachments(),n.updateAnnotation(t.id,It=>({...It,thread:[...It.thread,et]}));let we=await Me({kind:"reply",annotationId:t.id,content:S,attachmentIds:D.map(It=>It.id)},n.apiClient);if(we){let It=we.attachments??[];n.updateAnnotation(t.id,Jt=>({...Jt,thread:Jt.thread.map(fr=>fr.id===et.id?{...fr,id:we.id,deliveryStatus:"sent",attachments:It}:fr)})),It.length<D.length&&c("Some images expired before sending and were removed."),n.refresh();return}n.updateAnnotation(t.id,It=>({...It,thread:It.thread.map(Jt=>Jt.id===et.id?{...Jt,deliveryStatus:"failed"}:Jt)}));return}if(!S)return;let _=o.active;if(!_||_.kind!=="composer")return;let V=_.target,B={viewportX:_.anchor.viewportX,viewportY:_.anchor.viewportY,scrollY:_.anchor.documentY-_.anchor.viewportY},$=s.getPageUrl(),lt=tn(n.activeViewport,s.getTargetViewport()),Ct=gi({target:V,click:B,comment:S,url:$});Ct.viewport=n.activeViewport,Ct.viewportSize=lt,Ct.attachmentIds=D.map(et=>et.id);let Yt=y(),$e=pr("tmp-ann");n.applyAnnotationUpdate({id:$e,status:"pending",resolvedBy:null,resolvedAt:null,createdAt:new Date().toISOString(),authorName:Yt.authorName,authorImage:Yt.authorImage,payload:{...Ct,authorRole:Yt.role,authorId:Yt.authorId},attachments:D,thread:[],latestRun:null,deliveryStatus:"sending"}),o.setDraftText(""),o.openExisting($e);let xe=await Me({kind:"composer",payload:Ct},n.apiClient);if(xe){let et=xe.attachments??[];n.replaceAnnotationId($e,xe.id),n.updateAnnotation(xe.id,we=>({...we,attachments:et})),et.length<D.length&&c("Some images expired before sending and were removed."),o.openExisting(xe.id),n.refresh();return}n.updateAnnotation($e,et=>({...et,deliveryStatus:"failed"}));},[t,y,f,z,n,o,s]),U=useCallback(async S=>{if(!t||Yr(t))return;let D=t.thread.find(V=>V.id===S);if(!D||D.deliveryStatus!=="failed")return;n.updateAnnotation(t.id,V=>({...V,thread:V.thread.map(B=>B.id===S?{...B,deliveryStatus:"sending"}:B)}));let _=await Me({kind:"reply",annotationId:t.id,content:D.content,attachmentIds:(D.attachments??[]).map(V=>V.id)},n.apiClient);if(_){n.updateAnnotation(t.id,V=>({...V,thread:V.thread.map(B=>B.id===S?{...B,id:_.id,deliveryStatus:"sent"}:B)})),n.refresh();return}n.updateAnnotation(t.id,V=>({...V,thread:V.thread.map(B=>B.id===S?{...B,deliveryStatus:"failed"}:B)}));},[t,n]),at=useCallback(async()=>{if(!t||t.deliveryStatus!=="failed")return;let S=t.id;n.updateAnnotation(S,_=>({..._,deliveryStatus:"sending"}));let D=await Me({kind:"composer",payload:t.payload},n.apiClient);if(D){n.replaceAnnotationId(S,D.id),o.openExisting(D.id),n.refresh();return}n.updateAnnotation(S,_=>({..._,deliveryStatus:"failed"}));},[t,n,o]),pt=useCallback(S=>!T.authorId||S.deliveryStatus&&S.deliveryStatus!=="sent"?false:S.role===T.role&&S.authorId===T.authorId,[T]),vt=useCallback(()=>{x&&(c(null),u({kind:"annotation"}));},[x]),st=useCallback(S=>{pt(S)&&(c(null),u({kind:"message",messageId:S.id}));},[pt]),Q=useCallback(()=>{c(null),u(null);},[]),X=useCallback(async S=>{if(!t)return false;let D=t.thread;return g(async()=>(c(null),n.updateAnnotation(t.id,V=>({...V,thread:V.thread.filter(B=>B.id!==S)})),await yi({annotationId:t.id,messageId:S},n.apiClient)?(n.refresh(),true):(n.updateAnnotation(t.id,V=>({...V,thread:D})),c("Couldn't delete message. Try again."),false)))},[t,n,g]),k=useCallback(async()=>!t||!x?false:g(async()=>(c(null),await wi(t.id,n.apiClient)?(n.updateAnnotation(t.id,()=>null),o.forceClose(),n.refresh(),true):(c("Couldn't delete annotation. Try again."),false))),[t,x,n,o,g]),R=useCallback(async()=>{if(d)try{(d.kind==="annotation"?await k():await X(d.messageId))&&u(null);}catch{c("Couldn't delete. Try again.");}},[d,k,X]),M=useCallback(async()=>{t&&await g(async()=>{c(null);let S={status:t.status,resolvedBy:t.resolvedBy,resolvedAt:t.resolvedAt,optimisticAction:t.optimisticAction};if(n.updateAnnotation(t.id,_=>({..._,status:"resolved",resolvedBy:"dev",resolvedAt:new Date().toISOString(),optimisticAction:"resolve-pending"})),!await xi(t.id,n.apiClient)){n.updateAnnotation(t.id,_=>({..._,...S})),c("Couldn't resolve. Try again.");return}n.refresh();});},[t,n,g]),A=useCallback(async()=>{t&&await g(async()=>{c(null);let S={status:t.status,resolvedBy:t.resolvedBy,resolvedAt:t.resolvedAt,optimisticAction:t.optimisticAction};if(n.updateAnnotation(t.id,_=>({..._,status:"pending",resolvedBy:null,resolvedAt:null,optimisticAction:"reopen-pending"})),!await ki({annotationId:t.id,viewerKind:h},n.apiClient)){n.updateAnnotation(t.id,_=>({..._,...S})),c("Couldn't reopen. Try again.");return}n.refresh();});},[t,h,n,g]),H=useCallback(async S=>{t&&await g(async()=>{c(null);let D=t.latestRun,_=t.optimisticAction;n.updateAnnotation(t.id,B=>({...B,latestRun:{id:pr("tmp-run"),status:"queued",prUrl:null,createdAt:new Date().toISOString(),completedAt:null,prClosedUnmerged:false},optimisticAction:"run-pending"}));let V=await Ci({annotationId:t.id,viewerKind:h,guidance:S},n.apiClient);if(!V?.ok){n.updateAnnotation(t.id,B=>({...B,latestRun:D,optimisticAction:_})),c(V?.error??"Couldn't start Patch. Try again.");return}n.refresh();});},[t,h,n,g]),F=useCallback(async S=>{let D=await Ai({...S,avatarSeed:n.clientAvatarSeed},n.apiClient);return D&&await n.setIdentity(D),D},[n]),tt=h==="client"&&!n.identity&&m.length===0,xt=!!t||m.length>0,P=n.agentRunReadiness?.ready??true,L=n.agentRunReadiness?.message??null,W=useCallback(()=>{if(o.hasDraft){o.setConfirmDiscardOpen(true);return}o.forceClose();},[o]),j=t?Zn(t.payload):e||"annotation",Pt=t?.payload.viewport??n.activeViewport,wt=n.studio?n.studio.name:n.identity?.name??null,Ut=n.identity?.avatarSeed??n.clientAvatarSeed,ze=n.studio?.userId??Ut,He=n.studio?.image??null,Fe=n.studio?.userId??Ut,gr=useMemo(()=>({state:{annotation:t,messages:m,runState:v,draftText:o.draftText,draftAttachments:o.draftAttachments,busy:i,actionError:l,confirmDiscardOpen:o.confirmDiscardOpen,confirmDelete:d,showDevFooter:h==="studio",agentRunReady:P,agentRunSetupMessage:L,needsIdentity:tt,isResolved:f,initialMessageLocked:b,threadVisible:xt,canDeleteAnnotation:x},actions:{setDraftText:o.setDraftText,attachFiles:O,removeDraftAttachment:o.removeDraftAttachment,submit:N,retryMessage:U,retryInitialMessage:at,requestDeleteAnnotation:vt,requestDeleteMessage:st,canDeleteMessage:pt,cancelDelete:Q,confirmDelete:R,markResolved:M,reopen:A,runPatch:H,setIdentity:F,attemptClose:o.attemptClose,requestClose:W,forceClose:o.forceClose,setConfirmDiscardOpen:o.setConfirmDiscardOpen},meta:{targetLabel:j,viewport:Pt,shakeNonce:o.shakeNonce,viewer:{kind:h,authorId:T.authorId,name:wt,avatarKey:ze,avatarSrc:He,generatedSeed:Fe}}}),[t,m,v,o.draftText,o.draftAttachments,o.removeDraftAttachment,o.confirmDiscardOpen,o.setDraftText,o.attemptClose,o.forceClose,o.setConfirmDiscardOpen,o.shakeNonce,i,l,d,O,N,U,at,vt,st,pt,Q,R,M,A,H,F,h,P,L,tt,f,b,xt,x,W,j,Pt,T.authorId,wt,ze,He,Fe]);return jsx(Ei.Provider,{value:gr,children:r})}function q(){let t=use(Ei);if(!t)throw new Error("useThreadContext must be used inside <ThreadProvider>");return t}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",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 _e(t="brand",e){return C(Ec,Rc[t],e)}function kt({variant:t="brand",className:e,type:r="button",ref:n,...o}){return jsx("button",{ref:n,type:r,className:_e(t,e),...o})}function Ii(){let{state:t,actions:e}=q(),r=t.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-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:s}),t.actionError?jsx("div",{className:"text-[11px] font-medium text-destructive",children:t.actionError}):null,jsxs("div",{className:"mt-1 flex justify-end gap-2",children:[jsx(kt,{variant:"neutral",disabled:t.busy,onClick:e.cancelDelete,children:"Cancel"}),jsx(kt,{variant:"destructive",disabled:t.busy,onClick:e.confirmDelete,children:t.busy?"Deleting\u2026":i})]})]})})}function Mi(){let{state:t,actions:e}=q();return t.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(kt,{variant:"neutral",onClick:()=>e.setConfirmDiscardOpen(false),children:"Keep editing"}),jsx(kt,{variant:"destructive",onClick:()=>e.forceClose(),children:"Discard"})]})]})}):null}var Ic="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",Nc={sm:"size-7",md:"size-8"},Mc={default:"text-muted-foreground hover:bg-black/6 hover:text-foreground",warn:"bg-amber-500/15 text-amber-700"};function Rt({size:t="sm",tone:e="default",className:r,type:n="button",ref:o,...s}){return jsx("button",{ref:o,type:n,className:C(Ic,Nc[t],Mc[e],r),...s})}function _i(){let{state:t}=q();return !t.showDevFooter||!t.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(Oc,{})})]}),t.actionError?jsx("div",{className:"px-1 text-[11px] font-medium text-destructive",children:t.actionError}):null]})}function Lc(){let{state:t,actions:e}=q(),[r,n]=useState(false),[o,s]=useState(""),[i,a]=useState(false),l=t.runState,c=l?.status;if(t.annotation?.status==="resolved")return jsx("div",{className:"min-w-0 flex-1"});let u=c==="queued"||c==="running",p=c==="succeeded"&&!!l?.prUrl&&!l.prClosedUnmerged,m=l?"Run Patch again":"Run Patch",v=c==="failed"?"destructiveTint":"brand",f=!t.agentRunReady,b=async()=>{try{a(!0),await e.runPatch(o.trim()||void 0),s(""),n(!1);}finally{a(false);}};if(u)return jsx("div",{className:"min-w-0 flex-1",children:jsxs(kt,{variant:"brandTint",disabled:true,children:[jsx("span",{className:"patch-fade-in size-[7px] rounded-full bg-brand"}),"Patch is working\u2026"]})});if(p){let y=wo(l.prUrl);return jsx("div",{className:"min-w-0 flex-1",children:jsxs("a",{href:l.prUrl,target:"_blank",rel:"noopener noreferrer",className:_e("brand","no-underline"),children:[jsx(I,{name:"pr",size:12}),y==="PR"?"View PR":`View PR ${y}`]})})}let h=jsxs(kt,{variant:v,disabled:t.busy||f,className:f?"opacity-60":void 0,onClick:()=>n(true),children:[jsx(Ie,{size:12})," ",m]});return jsxs("div",{className:"min-w-0 flex-1",children:[f&&t.agentRunSetupMessage?jsx(ot,{text:t.agentRunSetupMessage,tone:"warning",children:h}):h,r?jsx(Dc,{title:m,guidance:o,submitting:i||t.busy,onGuidanceChange:s,onCancel:()=>n(false),onSubmit:b}):null]})}function Dc({title:t,guidance:e,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":t,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(),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-lg bg-brand text-white",children:jsx(Ie,{size:13})}),jsx("span",{className:"truncate text-[13.5px] font-medium text-foreground",children:t})]}),jsx(Rt,{size:"sm",title:"Close",onClick:o,children:jsx(I,{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:e,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(kt,{variant:"neutral",disabled:r,onClick:o,children:"Cancel"}),jsx(kt,{type:"submit",variant:"brand",disabled:r,children:r?"Starting\u2026":"Start run"})]})]})]})}function Oc(){let{state:t,actions:e}=q();return t.annotation?t.annotation.status==="resolved"?jsxs(kt,{variant:"neutral",disabled:t.busy,onClick:()=>e.reopen(),children:[jsx(I,{name:"refresh",size:12}),"Reopen"]}):jsxs(kt,{variant:"neutral",disabled:t.busy,onClick:()=>e.markResolved(),children:[jsx(I,{name:"check",size:12}),"Resolve"]}):null}var zc={desktop:"Desktop",tablet:"Tablet",mobile:"Mobile"};function Ht(t,e){let r=t?.replace(/\s+/g," ").trim();return r?r.length<=e?r:`${r.slice(0,e-1)}...`:null}function Di(t){let e=t?.trim();return e||null}function qt(t){return Number.isInteger(t)?String(t):t.toFixed(1)}function Hc(t){let e=t.viewport??"desktop",r=zc[e],n=t.viewportSize;return n?`${r} (${n.width}x${n.height})`:r}function Fc(t){let e=t.coordinates,r=[`viewport (${qt(e.viewportX)}, ${qt(e.viewportY)})`,`documentY ${qt(e.documentY)}`];return e.isFixed&&r.push("fixed"),r.join(", ")}function $c(t){let e=t.boundingBox;return e?`x ${qt(e.x)}, y ${qt(e.y)}, ${qt(e.width)}x${qt(e.height)}`:null}function Bc(t){let e=t.domHints?.attributeSignature;if(!e)return null;let r=Object.entries(e).slice(0,12).map(([n,o])=>`${n}="${Ht(o,120)??""}"`);return r.length>0?r.join(", "):null}function Vc(t){let e=[`- Page: ${t.url}`,`- Element: ${Ht(t.elementPath||t.element,500)??"unknown"}`,`- Viewport: ${Hc(t)}`,`- Anchor: ${Fc(t)}`],r=Ht(t.targetLabel,160),n=$c(t);return r&&e.push(`- Visible target: ${r}`),n&&e.push(`- Bounding box: ${n}`),`## Target
2272
+ `;var ii="patch-widget-root";function ai({children:t}){let[e,r]=useState(null),n=useRef(null);return useEffect(()=>{if(typeof document>"u")return;let o=document.querySelector(ii);o||(o=document.createElement(ii),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=oi,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),()=>{}},[]),e?createPortal(t,e):null}var sc=/[\s#.:[\]()>+~,\\]/;function lc(t){return !(!t||sc.test(t)||/^\d/.test(t))}function cc(t){let e=1,r=t.previousElementSibling,n=t.tagName;for(;r;)r.tagName===n&&e++,r=r.previousElementSibling;return e}function si(t,e,r){try{let n=t.querySelectorAll(e);return n.length===1&&n[0]===r}catch{return false}}function dc(t,e){return t.id&&lc(t.id)&&(!e||si(e,`#${t.id}`,t))?`#${t.id}`:`${t.tagName.toLowerCase()}:nth-of-type(${cc(t)})`}function li(t,e){if(!t.tagName)return "";let r=t.ownerDocument??null,n=[],o=t,s=0;for(;o&&s<12;){let i=dc(o,r);if(n.unshift(i),i.startsWith("#"))break;let a=n.join(" > ");if(r&&si(r,a,t))return a;if(o.tagName.toLowerCase()==="html")break;o=o.parentElement,s++;}return n.join(" > ")}var uc=80,pc=500;function di(t){return t!==null&&typeof t=="object"}function mc(t){return di(t)?"return"in t||"type"in t||"elementType"in t||"_debugOwner"in t:false}function ur(t){if(typeof t=="function")return t.displayName||t.name||null;if(!di(t))return null;let e=t.displayName;if(typeof e=="string"&&e)return e;let r=ur(t.render);if(r)return r;let n=ur(t.type);return n||null}function ui(t){return t.replace(/\s+/g," ").trim()}function pi(t,e){return t.length<=e?t:`${t.slice(0,e-1).trim()}\u2026`}function gc(t){let e=ui(t).replace(/[<>]/g,"");return !e||/^[a-z]/.test(e)?null:pi(e,uc)}function fc(t){let e=ur(t.elementType)??ur(t.type);return e?gc(e):null}function ci(t){return pi(ui(t),pc)}function hc(t){let e=t.replace(/\\/g,"/");return e.includes("/.next/")||e.includes("/node_modules/next/")||e.includes("/node_modules/react/")||e.includes("/node_modules/react-dom/")||e.includes("/node_modules/react-router/")||e.includes("/node_modules/react-router-dom/")||e.includes("/node_modules/@remix-run/")||e.includes("/node_modules/.vite/")||/(^|\/)next\/dist\//.test(e)}function bc(t){let e=t.replace(/^webpack:\/\/[^/]+\//,"").replace(/^file:\/\//,"").replace(/\\/g,"/").replace(/\/\.\//g,"/").replace(/^\.\//,"");for(let n of ["/apps/","/packages/","/src/"]){let o=e.lastIndexOf(n);if(o>=0)return ci(e.slice(o+1))}let r=e.split("/").filter(Boolean);return ci(r.slice(-3).join("/"))}function vc(t){let e=t._debugSource?.fileName;return typeof e!="string"||!e.trim()||hc(e)?null:bc(e)}function xc(t){let e=t;for(let r of Object.getOwnPropertyNames(t)){if(!r.startsWith("__reactFiber$")&&!r.startsWith("__reactInternalInstance$"))continue;let n=e[r];if(mc(n))return n}return null}function mi(t){let e=xc(t);if(!e)return null;let r=[],n=null,o=0;for(;e&&o<30;){let a=fc(e),l=a?hr(a):false;a&&!l&&r[r.length-1]!==a&&r.push(a),l||(n??=vc(e)),e=e.return??e._debugOwner??null,o+=1;}let s=r.length>0?tn(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 gi=500;function wc(t){return t.length<=gi?t:t.slice(0,gi)}function yc(t){return {viewportX:t.viewportX,viewportY:t.viewportY,documentY:t.viewportY+t.scrollY,isFixed:false}}function kc(t){return {x:t.x,y:t.y,width:t.width,height:t.height}}function Cc(t){let e={cssSelector:li(t)},r=je(t);r&&(e.textSignature=r);let n=qe(t);return Object.keys(n).length>0&&(e.attributeSignature=n),e}function fi(t){return Pe(t.element,t.selectedText)}function hi(t){let{target:e,click:r,comment:n,url:o}=t,s=e.element,i=e.rect,a=Wn(s),l=Yn(s),c=Re(s),d=Gn(s),u=mi(s),p={comment:n,element:Ke(s),elementPath:Un(s),targetLabel:Pe(s,e.selectedText),timestamp:Date.now(),url:Vt(o),kind:"feedback",coordinates:yc(r),boundingBox:kc(i),domHints:Cc(s)};return e.selectedText&&(p.selectedText=wc(e.selectedText)),l&&(p.nearbyText=l),c.length>0&&(p.cssClasses=c),d.length>0&&(p.nearbyElements=d),a&&(p.accessibility=a),u?.reactComponents&&(p.reactComponents=u.reactComponents),u?.sourceFile&&(p.sourceFile=u.sourceFile),p}var Ac=2e3,Sc=.82,Tc=.85;function vi(t,e,r){return new Promise(n=>t.toBlob(n,e,r))}function xi(t){return t.startsWith("image/")&&t!=="image/gif"}async function wi(t){let e;try{e=await createImageBitmap(t);}catch{return null}try{let r=Math.min(1,Ac/Math.max(e.width,e.height)),n=Math.max(1,Math.round(e.width*r)),o=Math.max(1,Math.round(e.height*r));if(r===1&&t.size<=3145728){let l=new Uint8Array(await t.slice(0,16).arrayBuffer()),c=Jr(l);if(c==="image/webp"||c==="image/jpeg")return {blob:c===t.type?t:new Blob([t],{type:c}),width:n,height:o}}let s=document.createElement("canvas");s.width=n,s.height=o;let i=s.getContext("2d");if(!i)return null;i.drawImage(e,0,0,n,o);let a=await vi(s,"image/webp",Sc);return (!a||a.type!=="image/webp")&&(a=await vi(s,"image/jpeg",Tc)),!a||a.size>3145728?null:{blob:a,width:n,height:o}}finally{e.close();}}async function De(t,e){return t.kind==="composer"?e.createAnnotation(t.payload):e.reply(t.annotationId,{content:t.content,attachmentIds:t.attachmentIds})}async function yi(t,e){return e.resolve(t)}async function ki(t,e){return e.deleteAnnotation(t)}async function Ci(t,e){return e.deleteMessage(t.annotationId,t.messageId)}async function Ai(t,e){return t.viewerKind!=="studio"?null:e.reopen(t.annotationId)}async function Si(t,e){return t.viewerKind!=="studio"?null:e.kickoff(t.annotationId,{guidance:t.guidance})}async function Ti(t,e){return e.postIdentity(t)}var Pi=createContext(null),Ri=0;function pr(t){return Ri+=1,`${t}-${Date.now().toString(36)}-${Ri}`}function Gr(t){return t.deliveryStatus==="sending"||t.deliveryStatus==="failed"}function Ii({annotation:t,draftTargetLabel:e,children:r}){let n=it(),o=xt(),s=vt(),[i,a]=useState(false),[l,c]=useState(null),[d,u]=useState(null),p=useRef(false),m=t?.thread??[],x=t?.latestRun??null,f=t?.status==="resolved",b=t?Gr(t):false,h=n.viewerKind,k=useCallback(()=>h==="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,h]),E=useMemo(()=>k(),[k]),w=!!t&&t.deliveryStatus!=="sending"&&t.deliveryStatus!=="failed"&&!!E.authorId&&t.payload.authorRole===E.role&&t.payload.authorId===E.authorId,H=useCallback((T,z)=>{let _=k();return {id:pr("tmp-msg"),role:_.role,authorId:_.authorId,authorName:_.authorName,authorImage:_.authorImage,content:T,createdAt:new Date().toISOString(),deliveryStatus:"sending",attachments:z}},[k]),L=useCallback(async(T,z="upload")=>{let _=Array.from(T).filter(V=>xi(V.type));await Promise.all(_.map(async V=>{let B=await wi(V);if(!B)return;let F=pr("tmp-att"),mt=URL.createObjectURL(B.blob);if(!o.addDraftAttachment({localId:F,status:"uploading",previewUrl:mt,width:B.width,height:B.height,kind:z,attachment:null})){URL.revokeObjectURL(mt);return}let Kt=await n.apiClient.uploadAttachment(B.blob,{kind:z,width:B.width,height:B.height});o.updateDraftAttachment(F,Kt?{status:"uploaded",attachment:Kt}:{status:"failed"});}));},[o,n.apiClient]),g=useCallback(async T=>{if(p.current)return Promise.reject(new Error("busy"));p.current=true,a(true);try{return await T()}finally{p.current=false,a(false);}},[]),I=useCallback(async()=>{let T=o.draftText.trim(),z=o.draftAttachments.flatMap(nt=>nt.status==="uploaded"&&nt.attachment?[nt.attachment]:[]);if(o.draftAttachments.some(nt=>nt.status!=="uploaded"))return;if(t){if(!T&&z.length===0||f||Gr(t))return;let nt=H(T,z);o.setDraftText(""),o.clearDraftAttachments(),n.updateAnnotation(t.id,Nt=>({...Nt,thread:[...Nt.thread,nt]}));let Ae=await De({kind:"reply",annotationId:t.id,content:T,attachmentIds:z.map(Nt=>Nt.id)},n.apiClient);if(Ae){let Nt=Ae.attachments??[];n.updateAnnotation(t.id,te=>({...te,thread:te.thread.map(fr=>fr.id===nt.id?{...fr,id:Ae.id,deliveryStatus:"sent",attachments:Nt}:fr)})),Nt.length<z.length&&c("Some images expired before sending and were removed."),n.refresh();return}n.updateAnnotation(t.id,Nt=>({...Nt,thread:Nt.thread.map(te=>te.id===nt.id?{...te,deliveryStatus:"failed"}:te)}));return}if(!T)return;let _=o.active;if(!_||_.kind!=="composer")return;let V=_.target,B={viewportX:_.anchor.viewportX,viewportY:_.anchor.viewportY,scrollY:_.anchor.documentY-_.anchor.viewportY},F=s.getPageUrl(),mt=dn(n.activeViewport,s.getTargetViewport()),St=hi({target:V,click:B,comment:T,url:F});St.viewport=n.activeViewport,St.viewportSize=mt,St.attachmentIds=z.map(nt=>nt.id);let Kt=k(),Ve=pr("tmp-ann");n.applyAnnotationUpdate({id:Ve,status:"pending",resolvedBy:null,resolvedAt:null,createdAt:new Date().toISOString(),authorName:Kt.authorName,authorImage:Kt.authorImage,payload:{...St,authorRole:Kt.role,authorId:Kt.authorId},attachments:z,thread:[],latestRun:null,deliveryStatus:"sending"}),o.setDraftText(""),o.openExisting(Ve);let Ce=await De({kind:"composer",payload:St},n.apiClient);if(Ce){let nt=Ce.attachments??[];n.replaceAnnotationId(Ve,Ce.id),n.updateAnnotation(Ce.id,Ae=>({...Ae,attachments:nt})),nt.length<z.length&&c("Some images expired before sending and were removed."),o.openExisting(Ce.id),n.refresh();return}n.updateAnnotation(Ve,nt=>({...nt,deliveryStatus:"failed"}));},[t,k,f,H,n,o,s]),U=useCallback(async T=>{if(!t||Gr(t))return;let z=t.thread.find(V=>V.id===T);if(!z||z.deliveryStatus!=="failed")return;n.updateAnnotation(t.id,V=>({...V,thread:V.thread.map(B=>B.id===T?{...B,deliveryStatus:"sending"}:B)}));let _=await De({kind:"reply",annotationId:t.id,content:z.content,attachmentIds:(z.attachments??[]).map(V=>V.id)},n.apiClient);if(_){n.updateAnnotation(t.id,V=>({...V,thread:V.thread.map(B=>B.id===T?{...B,id:_.id,deliveryStatus:"sent"}:B)})),n.refresh();return}n.updateAnnotation(t.id,V=>({...V,thread:V.thread.map(B=>B.id===T?{...B,deliveryStatus:"failed"}:B)}));},[t,n]),ct=useCallback(async()=>{if(!t||t.deliveryStatus!=="failed")return;let T=t.id;n.updateAnnotation(T,_=>({..._,deliveryStatus:"sending"}));let z=await De({kind:"composer",payload:t.payload},n.apiClient);if(z){n.replaceAnnotationId(T,z.id),o.openExisting(z.id),n.refresh();return}n.updateAnnotation(T,_=>({..._,deliveryStatus:"failed"}));},[t,n,o]),dt=useCallback(T=>!E.authorId||T.deliveryStatus&&T.deliveryStatus!=="sent"?false:T.role===E.role&&T.authorId===E.authorId,[E]),ht=useCallback(()=>{w&&(c(null),u({kind:"annotation"}));},[w]),ut=useCallback(T=>{dt(T)&&(c(null),u({kind:"message",messageId:T.id}));},[dt]),pt=useCallback(()=>{c(null),u(null);},[]),rt=useCallback(async T=>{if(!t)return false;let z=t.thread;return g(async()=>(c(null),n.updateAnnotation(t.id,V=>({...V,thread:V.thread.filter(B=>B.id!==T)})),await Ci({annotationId:t.id,messageId:T},n.apiClient)?(n.refresh(),true):(n.updateAnnotation(t.id,V=>({...V,thread:z})),c("Couldn't delete message. Try again."),false)))},[t,n,g]),j=useCallback(async()=>!t||!w?false:g(async()=>(c(null),await ki(t.id,n.apiClient)?(n.updateAnnotation(t.id,()=>null),o.forceClose(),n.refresh(),true):(c("Couldn't delete annotation. Try again."),false))),[t,w,n,o,g]),A=useCallback(async()=>{if(d)try{(d.kind==="annotation"?await j():await rt(d.messageId))&&u(null);}catch{c("Couldn't delete. Try again.");}},[d,j,rt]),R=useCallback(async()=>{t&&await g(async()=>{c(null);let T={status:t.status,resolvedBy:t.resolvedBy,resolvedAt:t.resolvedAt,optimisticAction:t.optimisticAction};if(n.updateAnnotation(t.id,_=>({..._,status:"resolved",resolvedBy:"dev",resolvedAt:new Date().toISOString(),optimisticAction:"resolve-pending"})),!await yi(t.id,n.apiClient)){n.updateAnnotation(t.id,_=>({..._,...T})),c("Couldn't resolve. Try again.");return}n.refresh();});},[t,n,g]),D=useCallback(async()=>{t&&await g(async()=>{c(null);let T={status:t.status,resolvedBy:t.resolvedBy,resolvedAt:t.resolvedAt,optimisticAction:t.optimisticAction};if(n.updateAnnotation(t.id,_=>({..._,status:"pending",resolvedBy:null,resolvedAt:null,optimisticAction:"reopen-pending"})),!await Ai({annotationId:t.id,viewerKind:h},n.apiClient)){n.updateAnnotation(t.id,_=>({..._,...T})),c("Couldn't reopen. Try again.");return}n.refresh();});},[t,h,n,g]),G=useCallback(async T=>{t&&await g(async()=>{c(null);let z=t.latestRun,_=t.optimisticAction;n.updateAnnotation(t.id,B=>({...B,latestRun:{id:pr("tmp-run"),status:"queued",prUrl:null,createdAt:new Date().toISOString(),completedAt:null,prClosedUnmerged:false},optimisticAction:"run-pending"}));let V=await Si({annotationId:t.id,viewerKind:h,guidance:T},n.apiClient);if(!V?.ok){n.updateAnnotation(t.id,B=>({...B,latestRun:z,optimisticAction:_})),c(V?.error??"Couldn't start Patch. Try again.");return}n.refresh();});},[t,h,n,g]),W=useCallback(async T=>{let z=await Ti({...T,avatarSeed:n.clientAvatarSeed},n.apiClient);return z&&await n.setIdentity(z),z},[n]),$=h==="client"&&!n.identity&&m.length===0,O=!!t||m.length>0,X=n.agentRunReadiness?.ready??true,S=n.agentRunReadiness?.message??null,P=useCallback(()=>{if(o.hasDraft){o.setConfirmDiscardOpen(true);return}o.forceClose();},[o]),N=t?Zn(t.payload):e||"annotation",K=t?.payload.viewport??n.activeViewport,tt=n.studio?n.studio.name:n.identity?.name??null,It=n.identity?.avatarSeed??n.clientAvatarSeed,Tt=n.studio?.userId??It,Fe=n.studio?.image??null,Be=n.studio?.userId??It,gr=useMemo(()=>({state:{annotation:t,messages:m,runState:x,draftText:o.draftText,draftAttachments:o.draftAttachments,busy:i,actionError:l,confirmDiscardOpen:o.confirmDiscardOpen,confirmDelete:d,showDevFooter:h==="studio",agentRunReady:X,agentRunSetupMessage:S,needsIdentity:$,isResolved:f,initialMessageLocked:b,threadVisible:O,canDeleteAnnotation:w},actions:{setDraftText:o.setDraftText,attachFiles:L,removeDraftAttachment:o.removeDraftAttachment,submit:I,retryMessage:U,retryInitialMessage:ct,requestDeleteAnnotation:ht,requestDeleteMessage:ut,canDeleteMessage:dt,cancelDelete:pt,confirmDelete:A,markResolved:R,reopen:D,runPatch:G,setIdentity:W,attemptClose:o.attemptClose,requestClose:P,forceClose:o.forceClose,setConfirmDiscardOpen:o.setConfirmDiscardOpen},meta:{targetLabel:N,viewport:K,shakeNonce:o.shakeNonce,viewer:{kind:h,authorId:E.authorId,name:tt,avatarKey:Tt,avatarSrc:Fe,generatedSeed:Be}}}),[t,m,x,o.draftText,o.draftAttachments,o.removeDraftAttachment,o.confirmDiscardOpen,o.setDraftText,o.attemptClose,o.forceClose,o.setConfirmDiscardOpen,o.shakeNonce,i,l,d,L,I,U,ct,ht,ut,dt,pt,A,R,D,G,W,h,X,S,$,f,b,O,w,P,N,K,E.authorId,tt,Tt,Fe,Be]);return jsx(Pi.Provider,{value:gr,children:r})}function J(){let t=use(Pi);if(!t)throw new Error("useThreadContext must be used inside <ThreadProvider>");return t}var Mc="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",_c={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 Oe(t="brand",e){return C(Mc,_c[t],e)}function At({variant:t="brand",className:e,type:r="button",ref:n,...o}){return jsx("button",{ref:n,type:r,className:Oe(t,e),...o})}function Mi(){let{state:t,actions:e}=J(),r=t.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-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:s}),t.actionError?jsx("div",{className:"text-[11px] font-medium text-destructive",children:t.actionError}):null,jsxs("div",{className:"mt-1 flex justify-end gap-2",children:[jsx(At,{variant:"neutral",disabled:t.busy,onClick:e.cancelDelete,children:"Cancel"}),jsx(At,{variant:"destructive",disabled:t.busy,onClick:e.confirmDelete,children:t.busy?"Deleting\u2026":i})]})]})})}function Li(){let{state:t,actions:e}=J();return t.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(At,{variant:"neutral",onClick:()=>e.setConfirmDiscardOpen(false),children:"Keep editing"}),jsx(At,{variant:"destructive",onClick:()=>e.forceClose(),children:"Discard"})]})]})}):null}var Dc="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"},zc={default:"text-muted-foreground hover:bg-black/6 hover:text-foreground",warn:"bg-amber-500/15 text-amber-700"};function Pt({size:t="sm",tone:e="default",className:r,type:n="button",ref:o,...s}){return jsx("button",{ref:o,type:n,className:C(Dc,Oc[t],zc[e],r),...s})}function Di(){let{state:t}=J();return !t.showDevFooter||!t.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($c,{}),jsx("div",{className:"flex shrink-0 items-center gap-1",children:jsx(Bc,{})})]}),t.actionError?jsx("div",{className:"px-1 text-[11px] font-medium text-destructive",children:t.actionError}):null]})}function $c(){let{state:t,actions:e}=J(),[r,n]=useState(false),[o,s]=useState(""),[i,a]=useState(false),l=t.runState,c=l?.status;if(t.annotation?.status==="resolved")return jsx("div",{className:"min-w-0 flex-1"});let u=c==="queued"||c==="running",p=c==="succeeded"&&!!l?.prUrl&&!l.prClosedUnmerged,m=l?"Run Patch again":"Run Patch",x=c==="failed"?"destructiveTint":"brand",f=!t.agentRunReady,b=async()=>{try{a(!0),await e.runPatch(o.trim()||void 0),s(""),n(!1);}finally{a(false);}};if(u)return jsx("div",{className:"min-w-0 flex-1",children:jsxs(At,{variant:"brandTint",disabled:true,children:[jsx("span",{className:"patch-fade-in size-[7px] rounded-full bg-brand"}),"Patch is working\u2026"]})});if(p){let k=wo(l.prUrl);return jsx("div",{className:"min-w-0 flex-1",children:jsxs("a",{href:l.prUrl,target:"_blank",rel:"noopener noreferrer",className:Oe("brand","no-underline"),children:[jsx(M,{name:"pr",size:12}),k==="PR"?"View PR":`View PR ${k}`]})})}let h=jsxs(At,{variant:x,disabled:t.busy||f,className:f?"opacity-60":void 0,onClick:()=>n(true),children:[jsx(Le,{size:12})," ",m]});return jsxs("div",{className:"min-w-0 flex-1",children:[f&&t.agentRunSetupMessage?jsx(st,{text:t.agentRunSetupMessage,tone:"warning",children:h}):h,r?jsx(Fc,{title:m,guidance:o,submitting:i||t.busy,onGuidanceChange:s,onCancel:()=>n(false),onSubmit:b}):null]})}function Fc({title:t,guidance:e,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":t,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(),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-lg bg-brand text-white",children:jsx(Le,{size:13})}),jsx("span",{className:"truncate text-[13.5px] font-medium text-foreground",children:t})]}),jsx(Pt,{size:"sm",title:"Close",onClick:o,children:jsx(M,{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:e,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(At,{variant:"neutral",disabled:r,onClick:o,children:"Cancel"}),jsx(At,{type:"submit",variant:"brand",disabled:r,children:r?"Starting\u2026":"Start run"})]})]})]})}function Bc(){let{state:t,actions:e}=J();return t.annotation?t.annotation.status==="resolved"?jsxs(At,{variant:"neutral",disabled:t.busy,onClick:()=>e.reopen(),children:[jsx(M,{name:"refresh",size:12}),"Reopen"]}):jsxs(At,{variant:"neutral",disabled:t.busy,onClick:()=>e.markResolved(),children:[jsx(M,{name:"check",size:12}),"Resolve"]}):null}var Vc={desktop:"Desktop",tablet:"Tablet",mobile:"Mobile"};function Ft(t,e){let r=t?.replace(/\s+/g," ").trim();return r?r.length<=e?r:`${r.slice(0,e-1)}...`:null}function zi(t){let e=t?.trim();return e||null}function Zt(t){return Number.isInteger(t)?String(t):t.toFixed(1)}function Wc(t){let e=t.viewport??"desktop",r=Vc[e],n=t.viewportSize;return n?`${r} (${n.width}x${n.height})`:r}function Uc(t){let e=t.coordinates,r=[`viewport (${Zt(e.viewportX)}, ${Zt(e.viewportY)})`,`documentY ${Zt(e.documentY)}`];return e.isFixed&&r.push("fixed"),r.join(", ")}function Yc(t){let e=t.boundingBox;return e?`x ${Zt(e.x)}, y ${Zt(e.y)}, ${Zt(e.width)}x${Zt(e.height)}`:null}function Gc(t){let e=t.domHints?.attributeSignature;if(!e)return null;let r=Object.entries(e).slice(0,12).map(([n,o])=>`${n}="${Ft(o,120)??""}"`);return r.length>0?r.join(", "):null}function Xc(t){let e=[`- Page: ${t.url}`,`- Element: ${Ft(t.elementPath||t.element,500)??"unknown"}`,`- Viewport: ${Wc(t)}`,`- Anchor: ${Uc(t)}`],r=Ft(t.targetLabel,160),n=Yc(t);return r&&e.push(`- Visible target: ${r}`),n&&e.push(`- Bounding box: ${n}`),`## Target
2270
2273
  ${e.join(`
2271
- `)}`}function Wc(t){let e=Ht(t.selectedText,1500);return e?`## Selected text
2272
- ${e}`:null}function Uc(t){let e=t.role==="studio"?"workspace":"client",r=Ht(t.authorName,80),n=r?`${e} (${r})`:e,o=Di(t.content)??"(empty)",s=t.attachments?.length??0,i=s>0?` [${s} attached image${s===1?"":"s"}, see Attached images]`:"";return `- ${n}: ${o.replace(/\n/g,`
2273
- `)}${i}`}function Li(t,e){return `- ${t.kind==="screenshot"?"Screenshot":"Image"} ${e} (${t.width}\xD7${t.height}): ${t.url}`}function Yc(t){let e=[...(t.attachments??[]).map(r=>Li(r,"attached to the feedback")),...t.thread.flatMap(r=>(r.attachments??[]).map(n=>Li(n,"attached to a thread reply")))];return e.length===0?null:`## Attached images
2274
+ `)}`}function Kc(t){let e=Ft(t.selectedText,1500);return e?`## Selected text
2275
+ ${e}`:null}function qc(t){let e=t.role==="studio"?"workspace":"client",r=Ft(t.authorName,80),n=r?`${e} (${r})`:e,o=zi(t.content)??"(empty)",s=t.attachments?.length??0,i=s>0?` [${s} attached image${s===1?"":"s"}, see Attached images]`:"";return `- ${n}: ${o.replace(/\n/g,`
2276
+ `)}${i}`}function Oi(t,e){return `- ${t.kind==="screenshot"?"Screenshot":"Image"} ${e} (${t.width}\xD7${t.height}): ${t.url}`}function jc(t){let e=[...(t.attachments??[]).map(r=>Oi(r,"attached to the feedback")),...t.thread.flatMap(r=>(r.attachments??[]).map(n=>Oi(n,"attached to a thread reply")))];return e.length===0?null:`## Attached images
2274
2277
  View these images before making changes \u2014 they usually show the exact visual issue being reported.
2275
2278
  ${e.join(`
2276
- `)}`}function Gc(t){return t.length===0?null:`## Thread
2277
- ${t.map(Uc).join(`
2278
- `)}`}function Xc(t){let e=[],r=Ht(t.reactComponents,1e3),n=Ht(t.sourceFile,500),o=Ht(t.domHints?.cssSelector,500),s=Ht(t.domHints?.textSignature,300),i=Bc(t),a=t.cssClasses?.slice(0,20).join(" ");return r&&e.push(`- React components: ${r}`),n&&e.push(`- Source file hint: ${n}`),o&&e.push(`- CSS selector: ${o}`),s&&e.push(`- Text signature: ${s}`),i&&e.push(`- Attributes: ${i}`),a&&e.push(`- CSS classes: ${a}`),e.length>0?`## Implementation hints
2279
+ `)}`}function Zc(t){return t.length===0?null:`## Thread
2280
+ ${t.map(qc).join(`
2281
+ `)}`}function Jc(t){let e=[],r=Ft(t.reactComponents,1e3),n=Ft(t.sourceFile,500),o=Ft(t.domHints?.cssSelector,500),s=Ft(t.domHints?.textSignature,300),i=Gc(t),a=t.cssClasses?.slice(0,20).join(" ");return r&&e.push(`- React components: ${r}`),n&&e.push(`- Source file hint: ${n}`),o&&e.push(`- CSS selector: ${o}`),s&&e.push(`- Text signature: ${s}`),i&&e.push(`- Attributes: ${i}`),a&&e.push(`- CSS classes: ${a}`),e.length>0?`## Implementation hints
2279
2282
  ${e.join(`
2280
- `)}`:null}function Oi(t){return ["Address this feedback in the repository.",`## Feedback
2281
- ${Di(t.payload.comment)??"(no feedback text)"}`,Vc(t.payload),Wc(t.payload),Yc(t),Gc(t.thread),Xc(t.payload)].filter(Boolean).join(`
2283
+ `)}`:null}function Hi(t){return ["Address this feedback in the repository.",`## Feedback
2284
+ ${zi(t.payload.comment)??"(no feedback text)"}`,Xc(t.payload),Kc(t.payload),jc(t),Zc(t.thread),Jc(t.payload)].filter(Boolean).join(`
2282
2285
 
2283
- `)}function Hi(){let{state:t,meta:e}=q(),r=t.annotation,n=Tt[e.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:e.targetLabel,className:"min-w-0 overflow-hidden text-ellipsis whitespace-nowrap text-[12.5px] font-medium text-foreground",children:e.targetLabel}),jsx(ot,{text:Qt(e.viewport),placement:"bottom",children:jsx("span",{"data-patch-thread-viewport":e.viewport,role:"img","aria-label":Qt(e.viewport),className:"inline-flex shrink-0 items-center text-brand",children:jsx(I,{name:n.glyph,size:15,stroke:1.8})})})]}),jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[t.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(I,{name:"check",size:10})," Resolved"]}):null,jsxs("div",{className:"ml-0.5 flex items-center gap-0.5",children:[t.showDevFooter&&r?jsx(Zc,{annotation:r}):null,jsx(Qc,{}),jsx(Jc,{})]})]})]}),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 jc(t,e){try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(t),!0}catch{}let r=e.createElement("textarea");r.value=t,r.setAttribute("readonly",""),r.style.position="fixed",r.style.top="-9999px",r.style.left="-9999px",e.body.appendChild(r),r.select();try{return e.execCommand("copy")}catch{return false}finally{r.remove();}}function Zc({annotation:t}){let[e,r]=useState(false),n=useRef(null);useEffect(()=>()=>{n.current&&clearTimeout(n.current);},[]);let o=async s=>{await jc(Oi(t),s)&&(r(true),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>r(false),1500));};return jsx(ot,{text:e?"Copied":"Copy agent prompt",placement:"bottom",children:jsx(Rt,{"aria-label":e?"Copied agent prompt":"Copy agent prompt",onClick:s=>{o(s.currentTarget.ownerDocument);},children:jsxs("span",{className:"relative block",style:{width:14,height:14},children:[jsx("span",{className:C("absolute inset-0 grid place-items-center transition-all duration-200 ease-out",e?"scale-50 opacity-0 blur-[2px]":"scale-100 opacity-100 blur-0"),children:jsx(I,{name:"copy",size:14})}),jsx("span",{className:C("absolute inset-0 grid place-items-center text-brand-green transition-all duration-200 ease-out",e?"scale-100 opacity-100 blur-0":"scale-50 opacity-0 blur-[2px]"),children:jsx(I,{name:"check",size:13})})]})})})}function Jc(){let{actions:t}=q();return jsx(Rt,{onClick:t.requestClose,title:"Close",children:jsx(I,{name:"x",size:14})})}function Qc(){let{state:t,actions:e}=q(),[r,n]=useState(false);return t.canDeleteAnnotation?jsxs("div",{className:"relative",children:[jsx(Rt,{title:"Annotation actions","aria-label":"Annotation actions","aria-expanded":r,"aria-haspopup":"menu",onClick:()=>n(o=>!o),children:jsx(I,{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),e.requestDeleteAnnotation();},children:[jsx(I,{name:"trash",size:13}),"Delete annotation"]})}):null]}):null}function nd(){return document.querySelector("patch-widget-root")?.shadowRoot?.querySelector("[data-patch-mount]")??null}function Bi({attachments:t,index:e,onClose:r,onNavigate:n}){let o=useReducedMotion(),s=nd(),i=t[e],a=t.length>1;return useEffect(()=>{let l=c=>{if(c.key==="Escape"){c.preventDefault(),c.stopPropagation(),r();return}a&&(c.key==="ArrowRight"&&n((e+1)%t.length),c.key==="ArrowLeft"&&n((e-1+t.length)%t.length));};return document.addEventListener("keydown",l,true),()=>document.removeEventListener("keydown",l,true)},[t.length,e,a,r,n]),!s||!i?null:createPortal(jsxs(motion.div,{initial:o?false:{opacity:0},animate:{opacity:1,transition:{duration:.15,ease:"easeOut"}},role:"dialog","aria-modal":"true","aria-label":"Image preview","data-patch-lightbox":"",className:"fixed inset-0 z-[2147483647] grid place-items-center bg-black/78 font-sans",onMouseDown:l=>{l.target===l.currentTarget&&r();},children:[jsx(motion.img,{src:i.url,alt:"",width:i.width,height:i.height,initial:o?false:{opacity:0,scale:.96},animate:{opacity:1,scale:1,transition:{duration:.18,ease:"easeOut"}},className:"max-h-[86vh] max-w-[92vw] rounded-lg object-contain shadow-[0_32px_80px_-24px_rgba(0,0,0,0.6)]",draggable:false},i.id),jsx("button",{type:"button","aria-label":"Close preview",onClick:r,className:"absolute top-4 right-4 grid size-9 place-items-center rounded-full bg-white/10 text-white transition-colors hover:bg-white/20",children:jsx(I,{name:"x",size:15})}),a?jsxs(Fragment,{children:[jsx($i,{side:"left",label:"Previous image",onClick:()=>n((e-1+t.length)%t.length)}),jsx($i,{side:"right",label:"Next image",onClick:()=>n((e+1)%t.length)}),jsxs("span",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 rounded-full bg-white/10 px-2.5 py-1 text-[11px] font-medium tabular-nums text-white",children:[e+1," / ",t.length]})]}):null]}),s)}function $i({side:t,label:e,onClick:r}){return jsx("button",{type:"button","aria-label":e,onClick:r,className:C("absolute top-1/2 grid size-9 -translate-y-1/2 place-items-center rounded-full bg-white/10 text-white transition-colors hover:bg-white/20",t==="left"?"left-4":"right-4"),children:jsx(I,{name:t==="left"?"chevron-left":"chevron-right",size:16})})}function Vi({attachments:t}){let[e,r]=useState(null);if(t.length===0)return null;let n=t.length===1;return jsxs("div",{className:C("mt-1.5 flex flex-wrap gap-1.5",n&&"max-w-[230px]"),children:[t.map((o,s)=>jsx("button",{type:"button","aria-label":"View image",onClick:()=>r(s),className:C("block cursor-zoom-in overflow-hidden rounded-lg ring-1 ring-black/8 transition-[filter] hover:brightness-[0.96]",n?"w-full":"size-20"),children:jsx("img",{src:o.url,alt:"",width:o.width,height:o.height,loading:"lazy",draggable:false,className:C("block h-full w-full object-cover",n&&"max-h-40"),style:n?{aspectRatio:`${o.width} / ${o.height}`}:void 0})},o.id)),e!==null?jsx(Bi,{attachments:t,index:e,onClose:()=>r(null),onNavigate:r}):null]})}function Xi(){let{state:t,actions:e,meta:r}=q(),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);}),t.threadVisible?jsxs("div",{ref:n,"data-patch-thread-scroller":"",className:C("flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto bg-white px-4 pt-3.5 pb-3",t.showDevFooter&&t.isResolved&&"relative z-[1] rounded-b-xl shadow-[0_6px_12px_-5px_rgba(0,0,0,0.16)]"),children:[t.annotation?jsx(Yi,{name:t.annotation.authorName??"Someone",createdAt:t.annotation.createdAt,content:t.annotation.payload.comment,attachments:t.annotation.attachments,authorKey:t.annotation.payload.authorId??t.annotation.authorName??t.annotation.id,avatarSrc:t.annotation.authorImage,generatedSeed:t.annotation.payload.authorRole==="client"&&t.annotation.payload.authorId===s?o:t.annotation.authorAvatarSeed??t.annotation.payload.authorId??null,deliveryStatus:t.annotation.deliveryStatus,onRetry:t.annotation.deliveryStatus==="failed"?e.retryInitialMessage:void 0}):null,t.messages.map(a=>jsx(Yi,{name:a.authorName??a.role,createdAt:a.createdAt,content:a.content,attachments:a.attachments,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:e.canDeleteMessage(a),onDelete:()=>e.requestDeleteMessage(a),onRetry:a.deliveryStatus==="failed"?()=>{e.retryMessage(a.id);}:void 0},a.id))]}):null}function Yi(t){let e=se(t.name),r=le(t.authorKey),n=t.deliveryStatus==="failed";return jsxs("div",{className:"group/message flex gap-2.5",children:[jsx(Vt,{initials:e,tint:r,src:t.avatarSrc,generatedSeed:t.generatedSeed,alt:t.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:t.name}),jsx("span",{className:"text-[11px] text-muted-foreground",children:rr(t.createdAt)})]}),t.canDelete&&t.onDelete?jsx(dd,{onDelete:t.onDelete}):null,t.content?jsx("p",{className:"mt-0.5 whitespace-pre-wrap text-[13px] leading-[1.45] text-foreground",children:t.content}):null,jsx(Vi,{attachments:t.attachments??[]}),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"}),t.onRetry?jsx("button",{type:"button",onClick:t.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 ld=44,cd=8;function dd({onDelete:t}){let[e,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(),u=c.getBoundingClientRect(),p=u.bottom-d.bottom,m=d.top-u.top;o(p<ld+cd&&m>p?"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(Rt,{ref:s,size:"sm",title:"Message actions","aria-label":"Message actions","aria-expanded":e,"aria-haspopup":"menu",onClick:a,children:jsx(I,{name:"more",size:14})}),e?jsx("div",{role:"menu",className:C("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),t();},children:[jsx(I,{name:"trash",size:13}),"Delete"]})}):null]})}function Ki({attachments:t,onRemove:e}){let r=useReducedMotion();return t.length===0?null:jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:jsx(AnimatePresence,{initial:false,children:t.map(n=>jsxs(motion.div,{layout:true,initial:r?false:{opacity:0,scale:.95},animate:{opacity:1,scale:1,transition:{duration:.15,ease:"easeOut"}},exit:{opacity:0,scale:.95,transition:{duration:.12,ease:"easeOut"}},className:"group/attachment relative",children:[jsx("img",{src:n.previewUrl,alt:"",width:n.width,height:n.height,className:C("size-14 rounded-lg object-cover ring-1 ring-black/8",n.status==="failed"&&"opacity-60 ring-destructive/60")}),n.status==="uploading"?jsx("span",{className:"absolute inset-0 grid place-items-center rounded-lg bg-black/28",children:jsx("span",{className:"size-4 animate-spin rounded-full border-[1.5px] border-white/40 border-t-white"})}):null,n.status==="failed"?jsx(ot,{text:"Upload failed",placement:"top",children:jsx("span",{className:"absolute inset-0 grid place-items-center rounded-lg text-destructive",children:jsx(I,{name:"x",size:16,stroke:2.2})})}):null,jsx("button",{type:"button","aria-label":"Remove image",onClick:()=>e(n.localId),className:"absolute -top-1.5 -right-1.5 grid size-[18px] place-items-center rounded-full bg-foreground text-white opacity-0 shadow-[0_1px_4px_rgba(0,0,0,0.3)] transition-opacity group-focus-within/attachment:opacity-100 group-hover/attachment:opacity-100 focus-visible:opacity-100",children:jsx(I,{name:"x",size:9,stroke:2.4})})]},n.localId))})})}var fd={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 qi({variant:t="default",className:e,ref:r,...n}){return jsx("textarea",{ref:r,className:C(fd[t],e),...n})}var xd=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,ji="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 Zi(){let{actions:t}=q(),[e,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 u=>{u.preventDefault();let p=e.trim(),m=n.trim();if(!p){i("Name is required.");return}if(!xd.test(m)){i("Enter a valid email.");return}i(null),l(true);let v=await t.setIdentity({name:p,email:m});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:e,onChange:u=>r(u.target.value),className:ji}),jsx("input",{type:"email",placeholder:"Email",value:n,onChange:u=>o(u.target.value),className:ji}),s?jsx("div",{className:"text-xs text-destructive",children:s}):null,jsx("button",{type:"submit",disabled:a,className:C(_e("brand"),"self-end",a&&"cursor-not-allowed opacity-60"),children:a?"Saving\u2026":"Continue"})]})}var kd="image/jpeg,image/png,image/webp";function ea(){let{state:t,actions:e,meta:r}=q(),n=ei(),o=useRef(null),s=useRef(null),[i,a]=useState(false);if(useEffect(()=>{t.needsIdentity||setTimeout(()=>o.current?.focus(),0);},[t.needsIdentity]),useEffect(()=>{let x=o.current;if(!x)return;x.style.height="0px";let z=Math.min(x.scrollHeight,140);x.style.height=`${z}px`,a(z>28);},[t.draftText]),t.isResolved||t.initialMessageLocked)return null;if(t.needsIdentity)return jsx("div",{className:C("bg-white px-4 py-3",t.threadVisible&&"border-t border-black/6"),children:jsx(Zi,{})});let l=t.draftText.trim().length>0,c=t.draftAttachments.some(x=>x.status==="uploaded"),d=t.draftAttachments.every(x=>x.status==="uploaded"),u=(t.annotation?l||c:l)&&d,p=r.viewer.name,m=se(p),v=r.viewer.kind==="studio"?"var(--color-foreground)":le(r.viewer.avatarKey),f=x=>{x.preventDefault(),e.submit();},b=x=>{x.key==="Enter"&&!x.shiftKey&&(x.preventDefault(),e.submit());},h=x=>{let z=Array.from(x.clipboardData?.items??[]).filter(O=>O.kind==="file"&&O.type.startsWith("image/")).flatMap(O=>{let g=O.getAsFile();return g?[g]:[]});z.length!==0&&(x.preventDefault(),e.attachFiles(z));},y=x=>{!x||x.length===0||(e.attachFiles(Array.from(x)),s.current&&(s.current.value=""));},T=()=>{n.begin(x=>{e.attachFiles([x],"screenshot");});};return jsx("form",{onSubmit:f,className:C("bg-white p-3",t.threadVisible&&"border-t border-black/6",t.showDevFooter&&"relative z-[1] rounded-b-xl shadow-[0_6px_12px_-5px_rgba(0,0,0,0.16)]"),children:jsxs("div",{className:C("bg-black/4 px-3 py-2.5 transition-colors",i||t.draftAttachments.length>0?"rounded-xl":"rounded-full"),children:[jsx(Ki,{attachments:t.draftAttachments,onRemove:e.removeDraftAttachment}),jsxs("div",{className:"flex items-end gap-2",children:[jsx(Vt,{initials:m,tint:v,src:r.viewer.avatarSrc,generatedSeed:r.viewer.generatedSeed,alt:p??"",className:"self-start"}),jsx(qi,{ref:o,variant:"bare",value:t.draftText,onChange:x=>e.setDraftText(x.target.value),onKeyDown:b,onPaste:h,rows:1,placeholder:t.annotation?"Reply\u2026":"What should change?",style:{maxHeight:"140px"}}),jsx("input",{ref:s,type:"file",accept:kd,multiple:true,className:"hidden",onChange:x=>y(x.target.files)}),n.supported?jsx(ot,{text:"Capture screenshot",placement:"top",children:jsx(Rt,{"aria-label":"Capture screenshot",disabled:n.active,onClick:T,children:jsx(I,{name:"camera",size:15})})}):null,jsx(ot,{text:"Attach image",placement:"top",children:jsx(Rt,{"aria-label":"Attach image",onClick:()=>s.current?.click(),children:jsx(I,{name:"paperclip",size:15})})}),jsx(Cd,{enabled:u})]})]})})}function Cd({enabled:t}){return jsx("button",{type:"submit",disabled:!t,"aria-label":"Send",className:C("grid size-7 shrink-0 place-items-center rounded-full text-white",t?"pkey pkey-brand":"bg-black/16 transition-colors"),children:jsx(I,{name:"arrow-up",size:13})})}var Rd=[.4,0,.2,1],Pd=[.22,.61,.36,1],Id={x:-8,y:-8,origin:"top left"},na=200;function oa(t,e,r){return Math.max(e,Math.min(r,t))}function ia(t,e,r){let n={x:t.x+t.width/2,y:t.y+t.height/2},o={x:e.x+e.width/2,y:e.y+r/2};return {x:oa((n.x-o.x)*.08,-12,12),y:oa((n.y-o.y)*.12,-10,10),origin:`${n.y<o.y?"top":"bottom"} ${n.x<o.x?"left":"right"}`}}function Nd(t,e){if(!e)return Id;let r=Ee({anchor:e,popover:{width:332,height:na},viewport:t.getOverlayViewport()});return ia(e,r,na)}function Md(t,e){return t.x===e.x&&t.y===e.y&&t.origin===e.origin}function aa({getAnchorRect:t,initialAnchorRect:e,entryDelay:r=0,children:n}){let{actions:{attemptClose:o},meta:{shakeNonce:s}}=q(),i=mt(),a=useRef(null),[l,c]=useState(()=>Nd(i,e??t())),d=useCallback(()=>{let m=a.current;if(!m)return;let v=t();if(!v)return;let f=m.offsetHeight||200,b=Ee({anchor:v,popover:{width:332,height:f},viewport:i.getOverlayViewport()});m.style.left=`${b.x}px`,m.style.top=`${b.y}px`,m.style.right="auto";let h=ia(v,b,f);c(y=>Md(y,h)?y:h);},[t,i]);useLayoutEffect(()=>{d();}),useEffect(()=>{let m=null,v=()=>{m===null&&(m=i.overlayWindow.requestAnimationFrame(()=>{m=null,d();}));},f=new Set([i.targetWindow,i.overlayWindow]);for(let h of f)h.addEventListener("resize",v),h.addEventListener("scroll",v,{passive:true});let b=vn(i.overlayWindow,v);return b.observe(i.overlayDocument.body),i.targetDocument.body!==i.overlayDocument.body&&b.observe(i.targetDocument.body),a.current&&b.observe(a.current),()=>{m!==null&&i.overlayWindow.cancelAnimationFrame(m);for(let h of f)h.removeEventListener("resize",v),h.removeEventListener("scroll",v);b.disconnect();}},[d,i]),useEffect(()=>{let m=b=>{xo(b)||o();},v=b=>{b.key==="Escape"&&o();},f=new Set([i.targetDocument,i.overlayDocument]);for(let b of f)b.addEventListener("mousedown",m,true),b.addEventListener("keydown",v);return ()=>{for(let b of f)b.removeEventListener("mousedown",m,true),b.removeEventListener("keydown",v);}},[o,i]);let u=useRef(s);useEffect(()=>{if(s===u.current)return;u.current=s;let m=a.current;m&&(m.classList.remove("patch-shake"),m.offsetWidth,m.classList.add("patch-shake"));},[s]);let p={width:`${332}px`,height:"auto",transformOrigin:l.origin};return jsx(motion.div,{ref:a,layout:true,initial:{opacity:0,x:l.x,y:l.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:l.x,y:l.y,scale:.985,transition:{duration:.16,ease:Rd}},transition:{layout:{duration:.42,ease:Pd}},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:p,children:n})}var ut={Root:aa,Header:Hi,Messages:Xi,Reply:ea,DevFooter:_i,ConfirmDiscard:Mi,ConfirmDelete:Ii};function sa({getAnchorRect:t,initialAnchorRect:e,entryDelay:r}){return jsxs(ut.Root,{getAnchorRect:t,initialAnchorRect:e,entryDelay:r,children:[jsx(ut.Header,{}),jsx(ut.Messages,{}),jsx(ut.Reply,{}),jsx(ut.ConfirmDiscard,{}),jsx(ut.ConfirmDelete,{})]})}function la({getAnchorRect:t,initialAnchorRect:e,entryDelay:r}){return jsxs(ut.Root,{getAnchorRect:t,initialAnchorRect:e,entryDelay:r,children:[jsx(ut.Header,{}),jsx(ut.Messages,{}),jsx(ut.Reply,{}),jsx(ut.DevFooter,{}),jsx(ut.ConfirmDiscard,{}),jsx(ut.ConfirmDelete,{})]})}var Hd="data-patch-internal";function ua(t,e,r){let n={viewportX:e,viewportY:r},o=ce(n,t.getOverlayViewport());return er(n,o)}function Fd(t,e){return t.overlayDocument.querySelector("patch-widget-root")?.shadowRoot?.querySelector(e)??null}function $d(t,e){let r=Fd(t,`[data-patch-pin-id="${e}"]`);if(!r)return null;let n=r.getBoundingClientRect();return {x:n.x,y:n.y,width:n.width,height:n.height}}function Bd(t,e){if(!e)return null;let r=zo({payload:e.payload,doc:t.targetDocument,scrollY:t.getTargetScrollY(),viewport:t.getTargetViewport(),internalAttr:Hd}),n=t.targetPointToOverlay(r.position);return ua(t,n.viewportX,n.viewportY)}function da(t,e,r){if(!e)return null;if(e.kind==="existing")return $d(t,e.annotationId)??Bd(t,r);let n=t.targetPointToOverlay({viewportX:e.anchor.viewportX,viewportY:e.anchor.documentY-t.getTargetScrollY()});return ua(t,n.viewportX,n.viewportY)}function pa(){let t=ft(),e=rt(),r=mt(),n=t.active,o=useMemo(()=>!n||n.kind!=="existing"?null:e.annotations.find(u=>u.id===n.annotationId)??null,[n,e.annotations]),s=useCallback(()=>da(r,n,o),[n,o,r]),i=e.viewerKind==="studio"?la:sa,a=n&&(n.kind==="composer"||!!o),l=n?.kind==="composer"?.04:0,c=n?.kind==="composer"?mi(n.target):null,d=useMemo(()=>da(r,n,o),[n,o,r]);return jsx(AnimatePresence,{children:a?jsx(Ri,{annotation:o,draftTargetLabel:c,children:jsx(i,{getAnchorRect:s,initialAnchorRect:d,entryDelay:l})},"active-popover"):null})}var Ud="https://app.usepatch.dev";function Yd({children:t}){let{active:e}=rt();return e?t:null}function ma(t){let e=typeof window<"u"&&bn(window),r=useMemo(()=>go({prop:t.projectToken,processEnv:ho(),importMetaEnv:fo()}),[t.projectToken]),n=t.apiBase??Ud;return useEffect(()=>{r||console.warn(mo);},[r]),e||!r?null:jsx(oi,{children:jsx(xn,{children:jsx(En,{projectToken:r,apiBase:n,children:jsx(Yd,{children:jsx(zn,{children:jsx(po,{children:jsx(lo,{projectToken:r,children:jsx(no,{children:jsxs(ti,{children:[jsx(Wo,{}),jsx(pa,{}),jsx(Yo,{}),jsx(Mo,{})]})})})})})})})})})}var Gd=ma;
2284
- export{ma as Patch,Gd as default};
2286
+ `)}function Fi(){let{state:t,meta:e}=J(),r=t.annotation,n=Et[e.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:e.targetLabel,className:"min-w-0 overflow-hidden text-ellipsis whitespace-nowrap text-[12.5px] font-medium text-foreground",children:e.targetLabel}),jsx(st,{text:ee(e.viewport),placement:"bottom",children:jsx("span",{"data-patch-thread-viewport":e.viewport,role:"img","aria-label":ee(e.viewport),className:"inline-flex shrink-0 items-center text-brand",children:jsx(M,{name:n.glyph,size:15,stroke:1.8})})})]}),jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[t.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(M,{name:"check",size:10})," Resolved"]}):null,jsxs("div",{className:"ml-0.5 flex items-center gap-0.5",children:[t.showDevFooter&&r?jsx(rd,{annotation:r}):null,jsx(od,{}),jsx(nd,{})]})]})]}),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 ed(t,e){try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(t),!0}catch{}let r=e.createElement("textarea");r.value=t,r.setAttribute("readonly",""),r.style.position="fixed",r.style.top="-9999px",r.style.left="-9999px",e.body.appendChild(r),r.select();try{return e.execCommand("copy")}catch{return false}finally{r.remove();}}function rd({annotation:t}){let[e,r]=useState(false),n=useRef(null);useEffect(()=>()=>{n.current&&clearTimeout(n.current);},[]);let o=async s=>{await ed(Hi(t),s)&&(r(true),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>r(false),1500));};return jsx(st,{text:e?"Copied":"Copy agent prompt",placement:"bottom",children:jsx(Pt,{"aria-label":e?"Copied agent prompt":"Copy agent prompt",onClick:s=>{o(s.currentTarget.ownerDocument);},children:jsxs("span",{className:"relative block",style:{width:14,height:14},children:[jsx("span",{className:C("absolute inset-0 grid place-items-center transition-all duration-200 ease-out",e?"scale-50 opacity-0 blur-[2px]":"scale-100 opacity-100 blur-0"),children:jsx(M,{name:"copy",size:14})}),jsx("span",{className:C("absolute inset-0 grid place-items-center text-brand-green transition-all duration-200 ease-out",e?"scale-100 opacity-100 blur-0":"scale-50 opacity-0 blur-[2px]"),children:jsx(M,{name:"check",size:13})})]})})})}function nd(){let{actions:t}=J();return jsx(Pt,{onClick:t.requestClose,title:"Close",children:jsx(M,{name:"x",size:14})})}function od(){let{state:t,actions:e}=J(),[r,n]=useState(false);return t.canDeleteAnnotation?jsxs("div",{className:"relative",children:[jsx(Pt,{title:"Annotation actions","aria-label":"Annotation actions","aria-expanded":r,"aria-haspopup":"menu",onClick:()=>n(o=>!o),children:jsx(M,{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),e.requestDeleteAnnotation();},children:[jsx(M,{name:"trash",size:13}),"Delete annotation"]})}):null]}):null}function ld(){return document.querySelector("patch-widget-root")?.shadowRoot?.querySelector("[data-patch-mount]")??null}function Wi({attachments:t,index:e,onClose:r,onNavigate:n}){let o=useReducedMotion(),s=ld(),i=t[e],a=t.length>1;return useEffect(()=>{let l=c=>{if(c.key==="Escape"){c.preventDefault(),c.stopPropagation(),r();return}a&&(c.key==="ArrowRight"&&n((e+1)%t.length),c.key==="ArrowLeft"&&n((e-1+t.length)%t.length));};return document.addEventListener("keydown",l,true),()=>document.removeEventListener("keydown",l,true)},[t.length,e,a,r,n]),!s||!i?null:createPortal(jsxs(m.div,{initial:o?false:{opacity:0},animate:{opacity:1,transition:{duration:.15,ease:"easeOut"}},role:"dialog","aria-modal":"true","aria-label":"Image preview","data-patch-lightbox":"",className:"fixed inset-0 z-[2147483647] grid place-items-center bg-black/78 font-sans",onMouseDown:l=>{l.target===l.currentTarget&&r();},children:[jsx(m.img,{src:i.url,alt:"",width:i.width,height:i.height,initial:o?false:{opacity:0,scale:.96},animate:{opacity:1,scale:1,transition:{duration:.18,ease:"easeOut"}},className:"max-h-[86vh] max-w-[92vw] rounded-lg object-contain shadow-[0_32px_80px_-24px_rgba(0,0,0,0.6)]",draggable:false},i.id),jsx("button",{type:"button","aria-label":"Close preview",onClick:r,className:"absolute top-4 right-4 grid size-9 place-items-center rounded-full bg-white/10 text-white transition-colors hover:bg-white/20",children:jsx(M,{name:"x",size:15})}),a?jsxs(Fragment,{children:[jsx(Vi,{side:"left",label:"Previous image",onClick:()=>n((e-1+t.length)%t.length)}),jsx(Vi,{side:"right",label:"Next image",onClick:()=>n((e+1)%t.length)}),jsxs("span",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 rounded-full bg-white/10 px-2.5 py-1 text-[11px] font-medium tabular-nums text-white",children:[e+1," / ",t.length]})]}):null]}),s)}function Vi({side:t,label:e,onClick:r}){return jsx("button",{type:"button","aria-label":e,onClick:r,className:C("absolute top-1/2 grid size-9 -translate-y-1/2 place-items-center rounded-full bg-white/10 text-white transition-colors hover:bg-white/20",t==="left"?"left-4":"right-4"),children:jsx(M,{name:t==="left"?"chevron-left":"chevron-right",size:16})})}function Ui({attachments:t}){let[e,r]=useState(null);if(t.length===0)return null;let n=t.length===1;return jsxs("div",{className:C("mt-1.5 flex flex-wrap gap-1.5",n&&"max-w-[230px]"),children:[t.map((o,s)=>jsx("button",{type:"button","aria-label":"View image",onClick:()=>r(s),className:C("block cursor-zoom-in overflow-hidden rounded-lg ring-1 ring-black/8 transition-[filter] hover:brightness-[0.96]",n?"w-full":"size-20"),children:jsx("img",{src:o.url,alt:"",width:o.width,height:o.height,loading:"lazy",draggable:false,className:C("block h-full w-full object-cover",n&&"max-h-40"),style:n?{aspectRatio:`${o.width} / ${o.height}`}:void 0})},o.id)),e!==null?jsx(Wi,{attachments:t,index:e,onClose:()=>r(null),onNavigate:r}):null]})}function qi(){let{state:t,actions:e,meta:r}=J(),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);}),t.threadVisible?jsxs("div",{ref:n,"data-patch-thread-scroller":"",className:C("flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto bg-white px-4 pt-3.5 pb-3",t.showDevFooter&&t.isResolved&&"relative z-[1] rounded-b-xl shadow-[0_6px_12px_-5px_rgba(0,0,0,0.16)]"),children:[t.annotation?jsx(Xi,{name:t.annotation.authorName??"Someone",createdAt:t.annotation.createdAt,content:t.annotation.payload.comment,attachments:t.annotation.attachments,authorKey:t.annotation.payload.authorId??t.annotation.authorName??t.annotation.id,avatarSrc:t.annotation.authorImage,generatedSeed:t.annotation.payload.authorRole==="client"&&t.annotation.payload.authorId===s?o:t.annotation.authorAvatarSeed??t.annotation.payload.authorId??null,deliveryStatus:t.annotation.deliveryStatus,onRetry:t.annotation.deliveryStatus==="failed"?e.retryInitialMessage:void 0}):null,t.messages.map(a=>jsx(Xi,{name:a.authorName??a.role,createdAt:a.createdAt,content:a.content,attachments:a.attachments,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:e.canDeleteMessage(a),onDelete:()=>e.requestDeleteMessage(a),onRetry:a.deliveryStatus==="failed"?()=>{e.retryMessage(a.id);}:void 0},a.id))]}):null}function Xi(t){let e=de(t.name),r=ue(t.authorKey),n=t.deliveryStatus==="failed";return jsxs("div",{className:"group/message flex gap-2.5",children:[jsx(Gt,{initials:e,tint:r,src:t.avatarSrc,generatedSeed:t.generatedSeed,alt:t.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:t.name}),jsx("span",{className:"text-[11px] text-muted-foreground",children:nr(t.createdAt)})]}),t.canDelete&&t.onDelete?jsx(fd,{onDelete:t.onDelete}):null,t.content?jsx("p",{className:"mt-0.5 whitespace-pre-wrap text-[13px] leading-[1.45] text-foreground",children:t.content}):null,jsx(Ui,{attachments:t.attachments??[]}),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"}),t.onRetry?jsx("button",{type:"button",onClick:t.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 md=44,gd=8;function fd({onDelete:t}){let[e,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(),u=c.getBoundingClientRect(),p=u.bottom-d.bottom,m=d.top-u.top;o(p<md+gd&&m>p?"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(Pt,{ref:s,size:"sm",title:"Message actions","aria-label":"Message actions","aria-expanded":e,"aria-haspopup":"menu",onClick:a,children:jsx(M,{name:"more",size:14})}),e?jsx("div",{role:"menu",className:C("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),t();},children:[jsx(M,{name:"trash",size:13}),"Delete"]})}):null]})}function ji({attachments:t,onRemove:e}){let r=useReducedMotion();return t.length===0?null:jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:jsx(AnimatePresence,{initial:false,children:t.map(n=>jsxs(m.div,{layout:true,initial:r?false:{opacity:0,scale:.95},animate:{opacity:1,scale:1,transition:{duration:.15,ease:"easeOut"}},exit:{opacity:0,scale:.95,transition:{duration:.12,ease:"easeOut"}},className:"group/attachment relative",children:[jsx("img",{src:n.previewUrl,alt:"",width:n.width,height:n.height,className:C("size-14 rounded-lg object-cover ring-1 ring-black/8",n.status==="failed"&&"opacity-60 ring-destructive/60")}),n.status==="uploading"?jsx("span",{className:"absolute inset-0 grid place-items-center rounded-lg bg-black/28",children:jsx("span",{className:"size-4 animate-spin rounded-full border-[1.5px] border-white/40 border-t-white"})}):null,n.status==="failed"?jsx(st,{text:"Upload failed",placement:"top",children:jsx("span",{className:"absolute inset-0 grid place-items-center rounded-lg text-destructive",children:jsx(M,{name:"x",size:16,stroke:2.2})})}):null,jsx("button",{type:"button","aria-label":"Remove image",onClick:()=>e(n.localId),className:"absolute -top-1.5 -right-1.5 grid size-[18px] place-items-center rounded-full bg-foreground text-white opacity-0 shadow-[0_1px_4px_rgba(0,0,0,0.3)] transition-opacity group-focus-within/attachment:opacity-100 group-hover/attachment:opacity-100 focus-visible:opacity-100",children:jsx(M,{name:"x",size:9,stroke:2.4})})]},n.localId))})})}var wd={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 Zi({variant:t="default",className:e,ref:r,...n}){return jsx("textarea",{ref:r,className:C(wd[t],e),...n})}var Ad=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Ji="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 Qi(){let{actions:t}=J(),[e,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 u=>{u.preventDefault();let p=e.trim(),m=n.trim();if(!p){i("Name is required.");return}if(!Ad.test(m)){i("Enter a valid email.");return}i(null),l(true);let x=await t.setIdentity({name:p,email:m});l(false),x||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:e,onChange:u=>r(u.target.value),className:Ji}),jsx("input",{type:"email",placeholder:"Email",value:n,onChange:u=>o(u.target.value),className:Ji}),s?jsx("div",{className:"text-xs text-destructive",children:s}):null,jsx("button",{type:"submit",disabled:a,className:C(Oe("brand"),"self-end",a&&"cursor-not-allowed opacity-60"),children:a?"Saving\u2026":"Continue"})]})}var Ed="image/jpeg,image/png,image/webp";function na(){let{state:t,actions:e,meta:r}=J(),n=ni(),o=useRef(null),s=useRef(null),[i,a]=useState(false);if(useEffect(()=>{t.needsIdentity||setTimeout(()=>o.current?.focus(),0);},[t.needsIdentity]),useEffect(()=>{let w=o.current;if(!w)return;w.style.height="0px";let H=Math.min(w.scrollHeight,140);w.style.height=`${H}px`,a(H>28);},[t.draftText]),t.isResolved||t.initialMessageLocked)return null;if(t.needsIdentity)return jsx("div",{className:C("bg-white px-4 py-3",t.threadVisible&&"border-t border-black/6"),children:jsx(Qi,{})});let l=t.draftText.trim().length>0,c=t.draftAttachments.some(w=>w.status==="uploaded"),d=t.draftAttachments.every(w=>w.status==="uploaded"),u=(t.annotation?l||c:l)&&d,p=r.viewer.name,m=de(p),x=r.viewer.kind==="studio"?"var(--color-foreground)":ue(r.viewer.avatarKey),f=w=>{w.preventDefault(),e.submit();},b=w=>{w.key==="Enter"&&!w.shiftKey&&(w.preventDefault(),e.submit());},h=w=>{let H=Array.from(w.clipboardData?.items??[]).filter(L=>L.kind==="file"&&L.type.startsWith("image/")).flatMap(L=>{let g=L.getAsFile();return g?[g]:[]});H.length!==0&&(w.preventDefault(),e.attachFiles(H));},k=w=>{!w||w.length===0||(e.attachFiles(Array.from(w)),s.current&&(s.current.value=""));},E=()=>{n.begin(w=>{e.attachFiles([w],"screenshot");});};return jsx("form",{onSubmit:f,className:C("bg-white p-3",t.threadVisible&&"border-t border-black/6",t.showDevFooter&&"relative z-[1] rounded-b-xl shadow-[0_6px_12px_-5px_rgba(0,0,0,0.16)]"),children:jsxs("div",{className:C("bg-black/4 px-3 py-2.5 transition-colors",i||t.draftAttachments.length>0?"rounded-xl":"rounded-full"),children:[jsx(ji,{attachments:t.draftAttachments,onRemove:e.removeDraftAttachment}),jsxs("div",{className:"flex items-end gap-2",children:[jsx(Gt,{initials:m,tint:x,src:r.viewer.avatarSrc,generatedSeed:r.viewer.generatedSeed,alt:p??"",className:"self-start"}),jsx(Zi,{ref:o,variant:"bare",value:t.draftText,onChange:w=>e.setDraftText(w.target.value),onKeyDown:b,onPaste:h,rows:1,placeholder:t.annotation?"Reply\u2026":"What should change?",style:{maxHeight:"140px"}}),jsx("input",{ref:s,type:"file",accept:Ed,multiple:true,className:"hidden",onChange:w=>k(w.target.files)}),n.supported?jsx(st,{text:"Capture screenshot",placement:"top",children:jsx(Pt,{"aria-label":"Capture screenshot",disabled:n.active,onClick:E,children:jsx(M,{name:"camera",size:15})})}):null,jsx(st,{text:"Attach image",placement:"top",children:jsx(Pt,{"aria-label":"Attach image",onClick:()=>s.current?.click(),children:jsx(M,{name:"paperclip",size:15})})}),jsx(Rd,{enabled:u})]})]})})}function Rd({enabled:t}){return jsx("button",{type:"submit",disabled:!t,"aria-label":"Send",className:C("grid size-7 shrink-0 place-items-center rounded-full text-white",t?"pkey pkey-brand":"bg-black/16 transition-colors"),children:jsx(M,{name:"arrow-up",size:13})})}var _d=[.4,0,.2,1],Ld=[.22,.61,.36,1],Dd={x:-8,y:-8,origin:"top left"},ia=200;function aa(t,e,r){return Math.max(e,Math.min(r,t))}function sa(t,e,r){let n={x:t.x+t.width/2,y:t.y+t.height/2},o={x:e.x+e.width/2,y:e.y+r/2};return {x:aa((n.x-o.x)*.08,-12,12),y:aa((n.y-o.y)*.12,-10,10),origin:`${n.y<o.y?"top":"bottom"} ${n.x<o.x?"left":"right"}`}}function Od(t,e){if(!e)return Dd;let r=Ne({anchor:e,popover:{width:332,height:ia},viewport:t.getOverlayViewport()});return sa(e,r,ia)}function zd(t,e){return t.x===e.x&&t.y===e.y&&t.origin===e.origin}function la({getAnchorRect:t,initialAnchorRect:e,entryDelay:r=0,children:n}){let{actions:{attemptClose:o},meta:{shakeNonce:s}}=J(),i=vt(),a=useRef(null),[l,c]=useState(()=>Od(i,e??t())),d=useCallback(()=>{let m=a.current;if(!m)return;let x=t();if(!x)return;let f=m.offsetHeight||200,b=Ne({anchor:x,popover:{width:332,height:f},viewport:i.getOverlayViewport()});m.style.left=`${b.x}px`,m.style.top=`${b.y}px`,m.style.right="auto";let h=sa(x,b,f);c(k=>zd(k,h)?k:h);},[t,i]);useLayoutEffect(()=>{d();}),useEffect(()=>{let m=null,x=()=>{m===null&&(m=i.overlayWindow.requestAnimationFrame(()=>{m=null,d();}));},f=new Set([i.targetWindow,i.overlayWindow]);for(let h of f)h.addEventListener("resize",x),h.addEventListener("scroll",x,{passive:true});let b=En(i.overlayWindow,x);return b.observe(i.overlayDocument.body),i.targetDocument.body!==i.overlayDocument.body&&b.observe(i.targetDocument.body),a.current&&b.observe(a.current),()=>{m!==null&&i.overlayWindow.cancelAnimationFrame(m);for(let h of f)h.removeEventListener("resize",x),h.removeEventListener("scroll",x);b.disconnect();}},[d,i]),useEffect(()=>{let m=b=>{xo(b)||o();},x=b=>{b.key==="Escape"&&o();},f=new Set([i.targetDocument,i.overlayDocument]);for(let b of f)b.addEventListener("mousedown",m,true),b.addEventListener("keydown",x);return ()=>{for(let b of f)b.removeEventListener("mousedown",m,true),b.removeEventListener("keydown",x);}},[o,i]);let u=useRef(s);useEffect(()=>{if(s===u.current)return;u.current=s;let m=a.current;m&&(m.classList.remove("patch-shake"),m.offsetWidth,m.classList.add("patch-shake"));},[s]);let p={width:`${332}px`,height:"auto",transformOrigin:l.origin};return jsx(m.div,{ref:a,layout:true,initial:{opacity:0,x:l.x,y:l.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:l.x,y:l.y,scale:.985,transition:{duration:.16,ease:_d}},transition:{layout:{duration:.42,ease:Ld}},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:p,children:n})}var ft={Root:la,Header:Fi,Messages:qi,Reply:na,DevFooter:Di,ConfirmDiscard:Li,ConfirmDelete:Mi};function ca({getAnchorRect:t,initialAnchorRect:e,entryDelay:r}){return jsxs(ft.Root,{getAnchorRect:t,initialAnchorRect:e,entryDelay:r,children:[jsx(ft.Header,{}),jsx(ft.Messages,{}),jsx(ft.Reply,{}),jsx(ft.ConfirmDiscard,{}),jsx(ft.ConfirmDelete,{})]})}function da({getAnchorRect:t,initialAnchorRect:e,entryDelay:r}){return jsxs(ft.Root,{getAnchorRect:t,initialAnchorRect:e,entryDelay:r,children:[jsx(ft.Header,{}),jsx(ft.Messages,{}),jsx(ft.Reply,{}),jsx(ft.DevFooter,{}),jsx(ft.ConfirmDiscard,{}),jsx(ft.ConfirmDelete,{})]})}var Wd="data-patch-internal";function ma(t,e,r){let n={viewportX:e,viewportY:r},o=Yt(n,t.getOverlayViewport());return pe(n,o)}function Ud(t,e){return t.overlayDocument.querySelector("patch-widget-root")?.shadowRoot?.querySelector(e)??null}function Yd(t,e){let r=Ud(t,`[data-patch-pin-id="${e}"]`);if(!r)return null;let n=r.getBoundingClientRect();return {x:n.x,y:n.y,width:n.width,height:n.height}}function Gd(t,e){if(!e)return null;let r=zo({payload:e.payload,doc:t.targetDocument,scrollY:t.getTargetScrollY(),viewport:t.getTargetViewport(),internalAttr:Wd}),n=t.targetPointToOverlay(r.position);return ma(t,n.viewportX,n.viewportY)}function pa(t,e,r){if(!e)return null;if(e.kind==="existing")return Yd(t,e.annotationId)??Gd(t,r);let n=t.targetPointToOverlay({viewportX:e.anchor.viewportX,viewportY:e.anchor.documentY-t.getTargetScrollY()});return ma(t,n.viewportX,n.viewportY)}function ga(){let t=xt(),e=it(),r=vt(),n=t.active,o=useMemo(()=>!n||n.kind!=="existing"?null:e.annotations.find(u=>u.id===n.annotationId)??null,[n,e.annotations]),s=useCallback(()=>pa(r,n,o),[n,o,r]),i=e.viewerKind==="studio"?da:ca,a=n&&(n.kind==="composer"||!!o),l=n?.kind==="composer"?.04:0,c=n?.kind==="composer"?fi(n.target):null,d=useMemo(()=>pa(r,n,o),[n,o,r]);return jsx(AnimatePresence,{children:a?jsx(Ii,{annotation:o,draftTargetLabel:c,children:jsx(i,{getAnchorRect:s,initialAnchorRect:d,entryDelay:l})},"active-popover"):null})}var Zd="https://app.usepatch.dev";function Jd({children:t}){let{active:e}=it();return e?t:null}function fa(t){let e=typeof window<"u"&&Tn(window),r=useMemo(()=>go({prop:t.projectToken,processEnv:ho(),importMetaEnv:fo()}),[t.projectToken]),n=t.apiBase??Zd;return useEffect(()=>{r||console.warn(mo);},[r]),e||!r?null:jsx(Qe,{children:jsx(ai,{children:jsx(LazyMotion,{features:domAnimation,strict:true,children:jsx(Rn,{children:jsx(Dn,{projectToken:r,apiBase:n,children:jsx(Jd,{children:jsx(zn,{children:jsx(po,{children:jsx(lo,{projectToken:r,children:jsx(no,{children:jsxs(ri,{children:[jsx(Yo,{}),jsx(ga,{}),jsx(Xo,{}),jsx(Mo,{})]})})})})})})})})})})})}var Qd=fa;
2287
+ export{fa as Patch,Qd as default};