@usepatch/widget 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.cjs +273 -15
  2. package/dist/index.js +273 -15
  3. package/package.json +2 -1
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
- import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEffect,use,createElement,useId}from'react';import {AnimatePresence,useReducedMotion,motion}from'motion/react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {createPortal}from'react-dom';function We(e){if(e.length<=1||!e.endsWith("/"))return e;try{let t=new URL(e);if(t.pathname==="/"&&e.endsWith("/"))return `${t.origin}${t.search}${t.hash}`}catch{}return e.slice(0,-1)}function ae(e){try{let t=new URL(e);return We(`${t.origin}${t.pathname}`)}catch{return We(e)}}var lr="patch:locationchange",$r="__patchHistoryPatched";function _i(e){let t=e.history;if(t[$r])return;t[$r]=true;let r=()=>e.dispatchEvent(new Event(lr)),{pushState:n,replaceState:o}=t;try{t.pushState=function(...s){let i=n.apply(this,s);return r(),i},t.replaceState=function(...s){let i=o.apply(this,s);return r(),i};}catch{}}function Fr(e,t){_i(e);let r=()=>t();return e.addEventListener("popstate",r),e.addEventListener("hashchange",r),e.addEventListener(lr,r),()=>{e.removeEventListener("popstate",r),e.removeEventListener("hashchange",r),e.removeEventListener(lr,r);}}var we={desktop:{viewport:"desktop",label:"Desktop",width:null,height:null,glyph:"desktop"},tablet:{viewport:"tablet",label:"Tablet",width:834,height:1194,glyph:"tablet"},mobile:{viewport:"mobile",label:"Mobile",width:390,height:844,glyph:"mobile"}},Vr=["desktop","tablet","mobile"];function Ke(e){let t=we[e];return t.width===null||t.height===null?t.label:`${t.label} (${t.width}px \xD7 ${t.height}px)`}function Br(e,t){let r=we[e];return {width:r.width??t.width,height:r.height??t.height}}var Di=32,Oi=32,zi=3e3,Yr="cubic-bezier(0.16, 1, 0.3, 1)",_t=[.22,.61,.36,1],Gr=.3,Xr=.5,Hi=.34,$i=.5,Fi=.24,Vi=.22,Kr=.12,Bi=.42,qr=.2,Wi=200,Ui=260,Yi=70,Gi=180,Xi=260,Ki=8,qi=4,Zi="#d9d9dd",ji=30,Ji=["0 2px 8px rgba(0,0,0,0.20)","0 30px 60px -18px rgba(0,0,0,0.55)","0 70px 130px -52px rgba(0,0,0,0.55)"].join(", ");function Lt(e,t,r){let n=Math.max(320,e.innerWidth-Di*2),o=Math.max(320,e.innerHeight-Oi*2);return Math.min(1,n/t,o/r)}function Qi(e){try{return !!(e.contentWindow&&e.contentDocument?.body)}catch{return false}}function Zr({src:e,viewport:t,overlayWindow:r,onFrameElement:n,onReadyChange:o,onBlockedChange:s}){let i=useReducedMotion(),a=t.width??r.innerWidth,l=t.height??r.innerHeight,c=t.viewport,d=`${c}:${a}:${l}`,p=!!r.happyDOM?.settings?.disableIframePageLoading,[u,m]=useState(()=>({viewport:c,width:a,height:l,scale:Lt(r,a,l)})),[h,f]=useState("stable"),[v,g]=useState(false),[y,R]=useState(false),I=useRef(false),V=useRef(null),b=`${u.viewport}:${u.width}:${u.height}`!==d,Q=v&&!y&&!(b||h==="cover"||h==="resize"),j=v&&!y&&h==="stable"&&!b,be=useCallback(C=>{V.current=C,n(C);},[n]),pe=useCallback(()=>{let C=V.current;if(!C||!Qi(C)){I.current=false,g(false),R(true);return}I.current=true,g(true),R(false);},[]),oe=useCallback(()=>{m(C=>{let te=Lt(r,C.width,C.height);return C.scale===te?C:{...C,scale:te}});},[r]);useEffect(()=>(oe(),r.addEventListener("resize",oe),()=>r.removeEventListener("resize",oe)),[r,oe]),useEffect(()=>{I.current=false,g(false),R(false);let C=r.setTimeout(()=>{I.current||R(true);},zi);return ()=>r.clearTimeout(C)},[e,r]),useEffect(()=>{if(i){b&&m({viewport:c,width:a,height:l,scale:Lt(r,a,l)}),h!=="stable"&&f("stable");return}switch(h){case "stable":{b&&f("cover");return}case "cover":{let C=r.setTimeout(()=>f("resize"),Yi);return ()=>r.clearTimeout(C)}case "resize":{b&&m({viewport:c,width:a,height:l,scale:Lt(r,a,l)});let C=r.setTimeout(()=>f("reveal"),Gi);return ()=>r.clearTimeout(C)}case "reveal":{let C=r.setTimeout(()=>f("stable"),Xi);return ()=>r.clearTimeout(C)}}},[h,b,i,r,c,a,l]),useEffect(()=>{o(j);},[j,o]),useEffect(()=>{s(y);},[y,s]);let ee=i?{duration:0}:{duration:Fi,ease:_t},G=i?{duration:0}:{duration:Vi,ease:_t,delay:qr*.5},w=i?{duration:0}:{duration:qr,ease:_t},T=i?{duration:0}:{opacity:{duration:Bi,ease:_t,delay:Kr},scale:{type:"spring",bounce:Hi,duration:$i,delay:Kr},width:{type:"spring",bounce:Gr,duration:Xr},height:{type:"spring",bounce:Gr,duration:Xr}},P=(Q?Ui:Wi)/1e3,k=i?void 0:`opacity ${P}s ${Yr}, filter ${P}s ${Yr}`,D=u.width*u.scale,H=u.height*u.scale;return jsx(motion.div,{"data-patch-preview-backdrop":"",initial:{opacity:0},animate:{opacity:1,transition:ee},exit:{opacity:0,transition:G},className:"fixed inset-0 z-[2147483643] grid place-items-center p-8",style:{backgroundColor:"#0C0C0E",backgroundImage:"radial-gradient(120% 75% at 50% 30%, rgba(255,255,255,0.055), rgba(0,0,0,0) 58%)"},children:jsxs(motion.div,{initial:i?{opacity:0,width:D,height:H}:{opacity:0,scale:.8,width:D,height:H},animate:{opacity:1,scale:1,width:D,height:H},exit:i?{opacity:0}:{opacity:0,scale:.92,transition:w},transition:T,"data-patch-preview-shell":"",className:"relative overflow-hidden bg-white",style:{boxSizing:"content-box",border:`${qi}px solid ${Zi}`,borderRadius:ji,boxShadow:Ji,willChange:"width, height"},children:[jsx("div",{"aria-hidden":!Q,className:"absolute top-0 left-0 origin-top-left",style:{width:u.width,height:u.height,transform:`scale(${u.scale})`,opacity:Q?1:0,filter:i||Q?"none":`blur(${Ki}px)`,transition:k,pointerEvents:Q?"auto":"none",willChange:"opacity, filter"},children:jsx("iframe",{ref:be,"data-patch-preview-frame":"","data-patch-preview-src":e,title:`${t.label} preview`,tabIndex:Q?0:-1,src:p?void 0:e,srcDoc:p?"<!doctype html><html><body></body></html>":void 0,onLoad:pe,className:"block bg-white",style:{width:u.width,height:u.height,border:0}})}),jsx(ea,{visible:y})]})})}function ea({visible:e}){return e?jsx("div",{className:"absolute inset-0 grid place-items-center p-8",children:jsx("div",{className:"max-w-[320px] rounded-xl bg-white px-5 py-4 text-center text-[13px] leading-[1.45] text-foreground shadow-[0_18px_44px_-18px_rgba(0,0,0,0.28)]",children:"This site blocks embedding. Add X-Frame-Options: SAMEORIGIN or frame-ancestors 'self' to enable viewport previews."})}):null}var en=createContext(null),tn=createContext(null),rn="__patch_preview";function nn(){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:()=>We(`${window.location.origin}${window.location.pathname}`),targetPointToOverlay:e=>({...e}),targetRectToOverlay:e=>({...e}),eventTargetElement:e=>e instanceof window.Element?e:null}}function oa(e){let t=new URL(e.location.href);return t.searchParams.set(rn,"1"),t.toString()}function on(e=window){try{return new URL(e.location.href).searchParams.get(rn)==="1"}catch{return false}}function ia(e,t,r){let n=t.contentWindow,o=t.contentDocument;if(!n||!o)return null;function s(){return t.getBoundingClientRect()}function i(){let l=s();return r.width>0?l.width/r.width:1}function a(l){if(!l)return null;let c=n.Element;return l instanceof c?l:null}return {targetWindow:n,targetDocument:o,overlayWindow:e.overlayWindow,overlayDocument:e.overlayDocument,getTargetViewport:()=>r,getOverlayViewport:e.getOverlayViewport,getTargetScrollY:()=>n.scrollY,getPageUrl:()=>We(`${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 an(e,t){let r=e.ResizeObserver??ResizeObserver;return new r(t)}function sn({children:e}){let t=useMemo(()=>nn(),[]),[r,n]=useState("desktop"),[o,s]=useState(null),[i,a]=useState(false),[l,c]=useState(false),[d,p]=useState(false),u=r!=="desktop",m=u||d,h=we[r],f=h.width&&h.height?{width:h.width,height:h.height}:null;useEffect(()=>{a(false),c(false);},[r]);let v=useRef(u);useEffect(()=>{v.current&&!u?p(true):!v.current&&u&&p(false),v.current=u;},[u]);let g=useMemo(()=>t?!u||!i||l||!o||!f?t:ia(t,o,f)??t:null,[l,o,i,u,f,t]),y=useMemo(()=>({activeViewport:r,setActiveViewport:n,isPreviewing:m,previewReady:m?u&&i&&!l:true,previewBlocked:u&&l}),[r,l,i,u,m]),R=useMemo(()=>t?oa(t.targetWindow):"",[t]);return !g||!t?null:jsx(tn.Provider,{value:y,children:jsxs(en.Provider,{value:g,children:[e,jsx(AnimatePresence,{onExitComplete:()=>p(false),children:u&&f?jsx(Zr,{src:R,viewport:h,overlayWindow:t.overlayWindow,onFrameElement:s,onReadyChange:a,onBlockedChange:c}):null})]})})}function ce(){let e=use(en),t=useMemo(()=>nn(),[]);if(e)return e;if(t)return t;throw new Error("useTargetSurface must run in a browser document")}function Je(){let e=use(tn),[t,r]=useState("desktop"),n=useMemo(()=>({activeViewport:t,setActiveViewport:r,isPreviewing:false,previewReady:true,previewBlocked:false}),[t]);return e??n}var sa="X-Patch-Client-Id";function ve(e,t){return {...t?{"Content-Type":"application/json"}:{},Authorization:`Bearer ${e.token}`,...e.clientUserId?{[sa]:e.clientUserId}:{}}}async function ye(e,t){try{let r=await fetch(e,t);if(!r.ok)return null;let n=await r.text();return n?JSON.parse(n):{}}catch{return null}}async function la(e,t){try{let r=await fetch(e,t),n=await r.text(),o=n?JSON.parse(n):null;return r.ok?o??{ok:!0}:{ok:!1,error:o&&typeof o=="object"&&typeof o.error=="string"?o.error:"Request failed."}}catch{return null}}function ln(e){return {async listAnnotations(t){let r=t?`?viewport=${encodeURIComponent(t)}`:"";return (await ye(`${e.apiBase}/api/widget/annotations${r}`,{method:"GET",credentials:"include",headers:ve(e,false)}))?.annotations??[]},async listRoster(){return (await ye(`${e.apiBase}/api/widget/roster`,{method:"GET",credentials:"include",headers:ve(e,false)}))?.entries??[]},async fetchMe(){return ye(`${e.apiBase}/api/widget/me`,{method:"GET",credentials:"include",headers:ve(e,false)})},async postIdentity(t){let r=await ye(`${e.apiBase}/api/widget/identity`,{method:"POST",credentials:"include",headers:ve(e,true),body:JSON.stringify(t)});return r?{clientUserId:r.id,name:r.name,email:r.email,avatarSeed:r.avatarSeed??r.id}:null},async createAnnotation(t){return ye(`${e.apiBase}/api/widget/annotations`,{method:"POST",credentials:"include",headers:ve(e,true),body:JSON.stringify(t)})},async reply(t,r){return ye(`${e.apiBase}/api/widget/annotations/${t}/reply`,{method:"POST",credentials:"include",headers:ve(e,true),body:JSON.stringify(r)})},async deleteAnnotation(t){return ye(`${e.apiBase}/api/widget/annotations/${t}`,{method:"DELETE",credentials:"include",headers:ve(e,false)})},async deleteMessage(t,r){return ye(`${e.apiBase}/api/widget/annotations/${t}/messages/${r}`,{method:"DELETE",credentials:"include",headers:ve(e,false)})},async kickoff(t,r){return la(`${e.apiBase}/api/widget/annotations/${t}/kickoff`,{method:"POST",credentials:"include",headers:ve(e,true),body:JSON.stringify(r)})},async resolve(t){return ye(`${e.apiBase}/api/widget/annotations/${t}/resolve`,{method:"POST",credentials:"include",headers:ve(e,true)})},async reopen(t){return ye(`${e.apiBase}/api/widget/annotations/${t}/reopen`,{method:"POST",credentials:"include",headers:ve(e,true)})},async reportAnchorStatuses(t){t.length!==0&&await ye(`${e.apiBase}/api/widget/anchor-report`,{method:"POST",credentials:"include",headers:ve(e,true),body:JSON.stringify({reports:t})});}}}var pr="patch.clientIdentity",cn="patch.clientAvatarSeed";function mr(){if(typeof window>"u")return {};try{let e=window.localStorage.getItem(pr);if(!e)return {};let t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return {}}}function dn(e){return mr()[e]??null}function fr(e,t){if(!(typeof window>"u"))try{let r=mr();r[e]=t,window.localStorage.setItem(pr,JSON.stringify(r));}catch{}}function un(e){if(!(typeof window>"u"))try{let t=mr();delete t[e],window.localStorage.setItem(pr,JSON.stringify(t));}catch{}}function ca(){if(typeof window>"u")return {};try{let e=window.localStorage.getItem(cn);if(!e)return {};let t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return {}}}function ur(){let e=globalThis.crypto;return `client-avatar:${typeof e?.randomUUID=="function"?e.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}`}function pn(e){if(typeof window>"u")return ur();try{let t=ca(),r=t[e];if(r)return r;let n=ur();return t[e]=n,window.localStorage.setItem(cn,JSON.stringify(t)),n}catch{return ur()}}var pa=2e4,fn=createContext(null);function ma(e,t){let r=new Map(e.map(i=>[i.id,i])),n=new Set(t.map(i=>i.id)),o=t.map(i=>{let a=r.get(i.id);if(!a)return i;let l=new Set(i.thread.map(p=>p.id)),c=a.thread.filter(p=>p.deliveryStatus&&!l.has(p.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 p=i.latestRun?Date.parse(i.latestRun.createdAt):Number.NaN,u=Date.parse(a.latestRun.createdAt);i.latestRun!=null&&(Number.isNaN(u)||Number.isNaN(p)||p>=u)||(d={...d,latestRun:a.latestRun,optimisticAction:a.optimisticAction});}return d}),s=e.filter(i=>(i.deliveryStatus||i.optimisticAction)&&!n.has(i.id));return [...o,...s]}function gn({projectToken:e,apiBase:t,children:r}){let n=ce(),{activeViewport:o,setActiveViewport:s}=Je(),[i,a]=useState(()=>typeof window>"u"?null:dn(e)),[l]=useState(()=>typeof window>"u"?"client-avatar:ssr":pn(e)),[c,d]=useState(null),[p,u]=useState("client"),[m,h]=useState(null),[f,v]=useState([]),[g,y]=useState(null),[R,I]=useState([]),[V,N]=useState(false),[b,L]=useState(null),Q=useRef(b);Q.current=b;let j=useRef(o);j.current=o;let be=g===o,pe=useMemo(()=>ln({apiBase:t,token:e,clientUserId:i?.clientUserId}),[t,e,i?.clientUserId]),oe=useRef(pe);oe.current=pe;let ee=useRef(0),G=useCallback(async()=>{let E=o,M=++ee.current,$=await oe.current.listAnnotations(E==="desktop"?void 0:E);if(M!==ee.current||E!==j.current)return;let q=n.getPageUrl(),Ae=$.filter(fe=>ae(fe.payload.url)===q);v(fe=>ma(fe,Ae)),y(E);},[o,n]),w=useRef(G);w.current=G,useEffect(()=>{let E=false;return (async()=>{let M=await oe.current.fetchMe();if(!E){if(M?.active===false){L(false),N(true);return}if(L(true),M?.studio)d(M.studio),u("studio"),h(M.agentRunReadiness??{ready:true,message:null});else if(d(null),u("client"),h(null),M?.client){let $={clientUserId:M.client.id,name:M.client.name,email:M.client.email,avatarSeed:M.client.avatarSeed};a($),fr(e,$);}await w.current(),E||N(true);}})(),()=>{E=true;}},[e]),useEffect(()=>{!V||!b||G();},[V,b,G]),useEffect(()=>{if(!b)return;let{overlayDocument:E,overlayWindow:M}=n,$=M.setInterval(()=>{E.visibilityState==="visible"&&G();},pa),q=()=>{E.visibilityState==="visible"&&G();};return E.addEventListener("visibilitychange",q),()=>{M.clearInterval($),E.removeEventListener("visibilitychange",q);}},[b,G,n]),useEffect(()=>{if(b)return Fr(n.targetWindow,()=>{let E=n.getPageUrl();v(M=>M.filter($=>ae($.payload.url)===E)),w.current();})},[b,n]);let T=useCallback(async E=>(fr(e,E),a(E),E),[e]),P=useCallback(()=>{a(null),un(e);},[e]),k=useCallback(E=>{I(M=>[...M.filter($=>$.tempId!==E.tempId),E]);},[]),D=useCallback(E=>{I(M=>M.filter($=>$.tempId!==E));},[]),H=useCallback(E=>{v(M=>{let $=M.findIndex(Ae=>Ae.id===E.id);if($===-1)return [...M,E];let q=M.slice();return q[$]=E,q});},[]),C=useCallback((E,M)=>{v($=>{let q=false,Ae=$.flatMap(fe=>{if(fe.id!==E)return [fe];q=true;let Ve=M(fe);return Ve?[Ve]:[]});return q?Ae:$});},[]),te=useCallback((E,M)=>{v($=>$.map(q=>q.id===E?{...q,id:M,deliveryStatus:"sent"}:q));},[]),me=useMemo(()=>({apiClient:pe,active:b,ready:V,viewerKind:p,agentRunReadiness:m,activeViewport:o,clientAvatarSeed:l,identity:i,studio:c,annotations:f,annotationsReady:be,ephemerals:R,refresh:G,setActiveViewport:s,setIdentity:T,signOut:P,addEphemeral:k,removeEphemeral:D,applyAnnotationUpdate:H,updateAnnotation:C,replaceAnnotationId:te}),[pe,b,V,p,m,o,l,i,c,f,be,R,G,s,T,P,k,D,H,C,te]);return jsx(fn.Provider,{value:me,children:r})}function re(){let e=use(fn);if(!e)throw new Error("useAnnotationsStore must be used inside <AnnotationsProvider>");return e}var hn=createContext(null);function bn({children:e}){let[t,r]=useState(null),[n,o]=useState(""),[s,i]=useState(0),[a,l]=useState(false),c=useCallback(()=>{r(null),o(""),l(false);},[]),d=useCallback(f=>{r({kind:"existing",annotationId:f}),o(""),l(false);},[]),p=useCallback(f=>{r({kind:"composer",...f}),o(""),l(false);},[]),u=useCallback(()=>{if(n.trim().length>0){i(f=>f+1);return}c();},[n,c]),m=useCallback(()=>{c();},[c]),h=useMemo(()=>({active:t,draftText:n,shakeNonce:s,confirmDiscardOpen:a,openExisting:d,openComposer:p,setDraftText:o,attemptClose:u,forceClose:m,setConfirmDiscardOpen:l}),[t,n,s,a,d,p,u,m]);return jsx(hn.Provider,{value:h,children:e})}function xe(){let e=use(hn);if(!e)throw new Error("usePopoverStore must be used inside <PopoverProvider>");return e}var wn=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"]),xa=new Set(["a","button","input","select","textarea"]),yn={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"},Ue=40,wa=1500,vn=200,ya=5,ka=10;function kn(e){return wn.has(e.tagName.toLowerCase())}function Ne(e,t){let r=e.replace(/\s+/g," ").trim();return r.length<=t?r:`${r.slice(0,t-1)}\u2026`}function Qe(e){return `"${e}"`}function Ca(e){let t="";for(let r of Array.from(e.childNodes))r.nodeType===3&&(t+=r.textContent??"");return t.replace(/\s+/g," ").trim()}function zt(e){return (e.textContent??"").replace(/\s+/g," ").trim()}function Sa(e){return !(!e||e.length>40||/__[A-Za-z0-9]{4,}$/.test(e)||/_[a-z0-9]{4,}$/i.test(e)&&/[0-9]/.test(e)||/_[A-Za-z0-9]{5,}_/.test(e)||/^(sc-|css-)[A-Za-z0-9]{4,}$/.test(e)||/^[a-z]{2,}:[\w-]+$/.test(e)||/^-?(p|m|w|h|min|max|gap|space|inset|top|right|bottom|left)[trblxy]?-/.test(e)||/^-?(text|bg|border|ring|shadow|font|leading|tracking|rounded|opacity|z|flex|grid|col|row|order|justify|items|self|content|place|object)-/.test(e)||(e.match(/\d/g)?.length??0)/e.length>.4)}function bt(e){let t=Array.from(e.classList),r=t.filter(Sa).slice(0,ka);return r.length>0?r:t.length>0?["container"]:[]}function Cn(e){let t=e.getAttribute("role")??void 0,r=e.getAttribute("aria-label")??void 0,n=e.getAttribute("tabindex"),o=n!==null&&n!==""?Number(n):void 0,s=e.tagName.toLowerCase(),i=xa.has(s)||o!==void 0&&Number.isFinite(o)&&o>=0;if(t===void 0&&r===void 0&&o===void 0&&!i)return;let a={focusable:i};return t!==void 0&&(a.role=t),r!==void 0&&(a.ariaLabel=r),o!==void 0&&Number.isFinite(o)&&(a.tabIndex=o),a}function Aa(e){let t=e.tagName.toLowerCase(),r=yn[t]??t,n=e.getAttribute("aria-label");if(n)return `${r} ${Qe(Ne(n,Ue))}`;let o=e.placeholder;if(o)return `${r} ${Qe(Ne(o,Ue))}`;let s=e.getAttribute("name");if(s)return `${r}[name="${s}"]`;if(t==="input"){let i=e.type||"text";return `${r}[type=${i}]`}return r}function Ta(e){let t=e.alt?.trim();return t?`img ${Qe(Ne(t,Ue))}`:"img"}function Ht(e){let t=e.tagName.toLowerCase();if(t==="img")return Ta(e);if(t==="input"||t==="textarea"||t==="select")return Aa(e);let r=yn[t]??t,n=e.getAttribute("aria-label");if(n)return `${r} ${Qe(Ne(n,Ue))}`;if(t==="a"||t==="button"||wn.has(t)||t==="label"){let s=zt(e);if(s)return `${r} ${Qe(Ne(s,Ue))}`;if(t==="a"||t==="button"){let i=e.querySelector("svg");if(i){let l=i.getAttribute("aria-label");return l?`${r} ${Qe(Ne(l,Ue))}`:`${r} (icon)`}let a=e.getAttribute("href");if(t==="a"&&a)return `link[href="${Ne(a,Ue)}"]`}return r}if(e.id)return `${t}#${e.id}`;let o=bt(e);return o.length>0?`${t}.${o[0]}`:t}function Sn(e){let t=[],r=e,n=0;for(;r&&r.tagName.toLowerCase()!=="body"&&n<6;)t.unshift(Ht(r)),r=r.parentElement,n++;return r&&r.tagName.toLowerCase()==="body"&&t.unshift("body"),t.join(" > ").slice(0,wa)}function An(e){let t=zt(e),r=e.parentElement;if(!r)return;let n=zt(r);if(n){if(t&&n===t){let o=r.parentElement;if(!o)return;let s=zt(o);return !s||s===t?void 0:Ne(s,vn)}return Ne(n,vn)}}function Tn(e){let t=e.parentElement;if(!t)return [];let r=[];for(let n of Array.from(t.children))if(n!==e&&n.tagName.toLowerCase()!=="script"&&(r.push(Ht(n)),r.length>=ya))break;return r}var Ea=["role","aria-label","name"],Ra=10,xn=100;function $t(e){let t={};for(let r of Ea){let n=e.getAttribute(r);n!==null&&n!==""&&(t[r]=n.slice(0,xn));}for(let r of Array.from(e.attributes)){if(Object.keys(t).length>=Ra)break;r.name.startsWith("data-")&&r.value!==""&&(t[r.name]=r.value.slice(0,xn));}return t}function Ft(e){return Ca(e)}function En(e){let t=e;for(;t&&t.nodeType!==1;)t=t.parentNode;return t}function Rn(e,t){return e.closest(`[${t}]`)!==null}var Ia=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"]),Pa={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"},Na={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"},Ma={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 Pn(e,t){let r=e.replace(/\s+/g," ").trim();return r.length<=t?r:`${r.slice(0,t-1).trim()}\u2026`}function _a(e){return `"${e}"`}function Vt(e){return (e.textContent??"").replace(/\s+/g," ").trim()}function In(e){let t=e.replace(/[_-]+/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").trim();return t?t.charAt(0).toUpperCase()+t.slice(1):""}function se(e,t){let r=t?.trim();return r?`${e}: ${_a(Pn(r,48))}`:e}function La(e){let t=e.trim(),r=t.match(/^(.+?)\s+"(.+)"$/);return r?{base:r[1]??t,text:r[2]}:{base:t}}function Da(e){let t=e.toLowerCase().replace(/\[[\s\S]*$/,"").trim(),r=Ma[t];if(r)return r;let n=e.match(/^[a-z][\w-]*/i)?.[0]?.toLowerCase();return n?/^h[1-6]$/.test(n)?"Heading":Na[n]??"Area":"Area"}function Oa(e){let t=e.getAttribute("aria-label");if(t)return se("Field",t);let r=e.placeholder;if(r)return se("Field",r);let n=e.getAttribute("name");if(n)return se("Field",In(n));if(e.tagName.toLowerCase()==="input"){let o=e.type||"text";if(o!=="text")return se("Field",In(o))}return "Field"}function vt(e,t){if(t?.trim())return se("Selected text",t);let r=e.tagName.toLowerCase(),n=e.getAttribute("aria-label");if(r==="button")return se("Button",n??Vt(e));if(r==="a")return se("Link",n??Vt(e));if(r==="input"||r==="textarea"||r==="select")return Oa(e);if(r==="img"){let s=e.alt;return se("Image",s)}if(r==="svg")return se("Icon",n);if(/^h[1-6]$/.test(r))return se("Heading",Vt(e));if(Ia.has(r))return se("Text",Vt(e));let o=Pa[r];return se(o||"Area",n)}function Nn(e){if(e.targetLabel?.trim())return Pn(e.targetLabel,120);if(e.selectedText?.trim())return se("Selected text",e.selectedText);let t=e.element?.trim()||e.elementPath?.trim();if(!t)return "Annotation";let r=La(t.split(">").at(-1)??t);return se(Da(r.base),r.text)}var Mn="patch-capture-cursor-style";function za(e){let t=`:not([${e}]):not([${e}] *)`,r=["p","span","h1","h2","h3","h4","h5","h6","li","td","th","label","blockquote","figcaption","code","pre","strong","em","i","b","u","mark","small","sub","sup","abbr","cite","q","dt","dd"].map(n=>`body ${n}${t}`).join(`,
3
- `);return ["html, body { cursor: crosshair !important; }",`body *${t} { cursor: crosshair !important; }`,`${r} { cursor: text !important; }`].join(`
4
- `)}function Ha(e,t){let r=e.targetDocument,n=r.getElementById(Mn);n&&n.remove();let o=r.createElement("style");return o.id=Mn,o.setAttribute(t,""),o.textContent=za(t),r.head.appendChild(o),o}function gr(e,t,r){let n=e.eventTargetElement(t);return n?n.closest(`[${r}]`)!==null:false}var et=1.5,$a="#0287FE",Fa="rgba(2, 135, 254, 0.032)";function Va(e){let t=e.split(" ")[0]??"",r=Number.parseFloat(t);return Number.isFinite(r)?Math.min(8,Math.max(3,r)):6}function Ba(e,t){let r=e.targetDocument,n=r.createElement("div");n.setAttribute(t,""),Object.assign(n.style,{position:"fixed",pointerEvents:"none",border:`${et}px solid ${$a}`,background:Fa,boxSizing:"border-box",zIndex:"2147483645",display:"none",borderRadius:"6px",transition:"top 80ms ease-out, left 80ms ease-out, width 80ms ease-out, height 80ms ease-out, border-radius 80ms ease-out"});let o=r.createElement("div");o.setAttribute(t,""),Object.assign(o.style,{position:"fixed",pointerEvents:"none",background:"#111",color:"#fff",fontFamily:"system-ui, sans-serif",fontSize:"12px",fontWeight:"500",padding:"6px 10px",borderRadius:"6px",zIndex:"2147483646",maxWidth:"240px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"none",boxShadow:"0 10px 24px -12px rgba(0, 0, 0, 0.36), 0 0 0 1px rgba(255, 255, 255, 0.08)"}),r.body.appendChild(n),r.body.appendChild(o);let s=null;return {update(i){let a=i.getBoundingClientRect();if(a.width===0&&a.height===0){this.hide();return}n.style.display="block",n.style.top=`${a.top-et}px`,n.style.left=`${a.left-et}px`,n.style.width=`${a.width+et*2}px`,n.style.height=`${a.height+et*2}px`,n.style.borderRadius=`${Va(e.targetWindow.getComputedStyle(i).borderRadius)+et}px`,i!==s&&(o.textContent=vt(i),s=i),o.style.display="block";let l=a.right+8,c=Math.max(8,a.top),d=e.getTargetViewport().width-8;l+240<=d?(o.style.left=`${l}px`,o.style.top=`${c}px`):(o.style.left=`${Math.max(8,a.right-240)}px`,o.style.top=`${Math.max(8,a.top-24)}px`);},hide(){n.style.display="none",o.style.display="none";},destroy(){n.remove(),o.remove();}}}function _n(e){let{internalAttr:t,onClick:r,surface:n}=e,o=n.targetDocument,s=Ha(n,t),i=Ba(n,t),a=false,l=h=>{let f=h;if(gr(n,f.target,t))return;let v=n.eventTargetElement(f.target);v&&kn(v)||(f.preventDefault(),f.stopPropagation());},c=l,d=l,p=h=>{let f=h;gr(n,f.target,t)||(f.preventDefault(),f.stopPropagation(),!a&&r(f));},u=h=>{let f=h;if(a)return;let v=n.eventTargetElement(f.target);if(!v){i.hide();return}if(gr(n,v,t)){i.hide();return}let g=v.tagName.toLowerCase();if(g==="html"||g==="body"){i.hide();return}i.update(v);},m=h=>{h.relatedTarget||i.hide();};return o.addEventListener("mousedown",c,true),o.addEventListener("mouseup",d,true),o.addEventListener("click",p,true),o.addEventListener("mousemove",u,true),o.addEventListener("mouseout",m,true),{exit(){s.remove(),i.destroy(),o.removeEventListener("mousedown",c,true),o.removeEventListener("mouseup",d,true),o.removeEventListener("click",p,true),o.removeEventListener("mousemove",u,true),o.removeEventListener("mouseout",m,true);},pause(){a=true,i.hide();},resume(){a=false;}}}function Ln(e){let{clickTarget:t,selection:r}=e,n=r&&!r.isCollapsed?r.toString().trim():"";if(n&&r&&r.rangeCount>0){let o=r.getRangeAt(0),s=En(o.commonAncestorContainer);if(s)return {kind:"element",element:s,rect:s.getBoundingClientRect(),selectedText:n,clickTarget:t}}return {kind:"element",element:t,rect:t.getBoundingClientRect(),clickTarget:t}}var Xa="data-patch-internal",On=createContext(null),Dn=0;function Ka(){return Dn+=1,`tmp-${Date.now().toString(36)}-${Dn}`}function zn({children:e}){let t=xe(),r=re(),n=ce(),{isPreviewing:o,previewReady:s}=Je(),[i,a]=useState(false),l=useRef(null),c=useRef(t),d=useRef(r);c.current=t,d.current=r;let p=useCallback(g=>{let y=c.current;if(y.active&&y.draftText.trim().length>0){y.attemptClose();return}let R=n.eventTargetElement(g.target)??n.targetDocument.body,I=n.targetWindow.getSelection(),V=Ln({clickTarget:R,selection:I}),N=Ka(),b={viewportX:g.clientX,viewportY:g.clientY,documentY:g.clientY+n.getTargetScrollY()};d.current.addEphemeral({tempId:N,viewportX:b.viewportX,viewportY:b.viewportY,documentY:b.documentY}),c.current.openComposer({tempId:N,target:V,anchor:b}),l.current?.pause();},[n]),u=r.annotationsReady&&(!o||s);useEffect(()=>{if(!i||!u){l.current?.exit(),l.current=null;return}return l.current?.exit(),l.current=_n({internalAttr:Xa,surface:n,onClick:p}),()=>{l.current?.exit(),l.current=null;}},[i,p,n,u]);let m=useCallback(()=>{i||a(true);},[i]),h=useCallback(()=>{a(false);},[]),f=useRef(null);useEffect(()=>{let g=f.current,y=t.active;g?.kind==="composer"&&y?.kind!=="composer"&&(d.current.removeEphemeral(g.tempId),l.current?.resume()),g?.kind==="composer"&&y?.kind==="composer"&&g.tempId!==y.tempId&&d.current.removeEphemeral(g.tempId),f.current=y;},[t.active]),useEffect(()=>()=>{l.current?.exit(),l.current=null;},[]);let v=useMemo(()=>({isCapturing:i,enter:m,exit:h}),[i,m,h]);return jsx(On.Provider,{value:v,children:e})}function Hn(){let e=use(On);if(!e)throw new Error("useCaptureControls must be used inside <CaptureProvider>");return e}var Ja="patch:focus-intent";function wr(e){return `${Ja}:${e}`}function Qa(e){try{let t=window.sessionStorage.getItem(wr(e));if(!t)return null;window.sessionStorage.removeItem(wr(e));let r=JSON.parse(t);return typeof r.id!="string"||typeof r.url!="string"?null:{id:r.id,url:r.url,viewport:r.viewport??"desktop"}}catch{return null}}function es(e,t){try{window.sessionStorage.setItem(wr(e),JSON.stringify(t));}catch{}}var Vn=createContext(null);function ts(e){return e==="pending"||e==="acknowledged"}function Bn({projectToken:e,children:t}){let{apiClient:r,active:n,viewerKind:o,annotations:s}=re(),i=o==="studio",[a,l]=useState([]),[c,d]=useState(false),[p,u]=useState(null),m=useRef(r);m.current=r;let h=useCallback(async()=>{if(!i){l([]),d(true);return}let b=await m.current.listRoster();l(b),d(true);},[i]);useEffect(()=>{if(!n||!i)return;let b=Qa(e);b&&ae(b.url)===ae(window.location.href)&&u(b),h();},[n,i,e,h]);let f=useMemo(()=>s.map(b=>`${b.id}:${b.status}`).sort().join(","),[s]),v=useRef(null);useEffect(()=>{if(!(!n||!i)){if(v.current===null){v.current=f;return}v.current!==f&&(v.current=f,h());}},[f,n,i,h]);let g=useCallback(b=>{let L={id:b.id,url:b.url,viewport:b.viewport};if(ae(b.url)===ae(window.location.href)){u(L);return}es(e,L),window.location.assign(b.url);},[e]),y=useCallback(()=>u(null),[]),R=useMemo(()=>{let b=new Map;for(let L of s)b.set(L.id,L.status);return b},[s]),I=useMemo(()=>a.map(b=>{let L=R.get(b.id);return L&&L!==b.status?{...b,status:L}:b}),[a,R]),V=useMemo(()=>I.filter(b=>ts(b.status)).length,[I]),N=useMemo(()=>({entries:I,ready:c,unresolvedCount:V,refresh:h,focusPin:g,pendingFocus:p,clearFocus:y}),[I,c,V,h,g,p,y]);return jsx(Vn.Provider,{value:N,children:t})}function tt(){let e=use(Vn);if(!e)throw new Error("useRosterStore must be used inside <RosterProvider>");return e}var Un=createContext(null);function Yn({children:e}){let[t,r]=useState(false),[n,o]=useState(false),s=useMemo(()=>({dockOpen:t,hideResolvedAnnotations:n,setDockOpen:r,setHideResolvedAnnotations:o}),[t,n]);return jsx(Un.Provider,{value:s,children:e})}function Oe(){let e=use(Un);if(!e)throw new Error("useWidgetUiStore must be used inside <WidgetUiProvider>");return e}var Gn="[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 Xn(e){let t=e.prop?.trim();if(t)return t;let r=e.processEnv?.NEXT_PUBLIC_PATCH_TOKEN?.trim();if(r)return r;let n=e.importMetaEnv?.VITE_PATCH_TOKEN?.trim();if(n)return n;let o=e.importMetaEnv?.PUBLIC_PATCH_TOKEN?.trim();return o||null}function Kn(){try{return typeof import.meta>"u"?void 0:import.meta.env}catch{return}}function qn(){try{return typeof process>"u"||!process.env?void 0:{NEXT_PUBLIC_PATCH_TOKEN:process.env.NEXT_PUBLIC_PATCH_TOKEN}}catch{return}}var ss=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 ls(e,t){return e.length<=t?e:`${e.slice(0,t-1).trim()}\u2026`}function Zn(e){return e.replace(/\s+/g," ").trim()}function yr(e){return ss.has(Zn(e))}function cs(e){return e.length<2||e.startsWith("_")?false:/^[A-Z]/.test(e)}function jn(e){if(!e)return null;let t=[],r=e.matchAll(/<([^<>]+)>/g);for(let n of r){let o=Zn(n[1]??"");!o||yr(o)||cs(o)&&t[t.length-1]!==o&&t.push(o);}return t.length===0?null:ls(t.map(n=>`<${n}>`).join(" "),1e3)}var Jn="seed:";function Wt(e){return e?e.startsWith(Jn)?{url:null,seed:e.slice(Jn.length)||null}:/^https?:\/\//i.test(e)?{url:e,seed:null}:{url:null,seed:e}:{url:null,seed:null}}var kr=[6,20,34,92,120,140,158,174,190,206,220,234,252,270,286,300,318,336,350],Qn=[{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]}],eo=Math.PI*2;function ds(e){let t=2166136261;for(let r=0;r<e.length;r++)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return t>>>0}function us(e){return ()=>{e+=1831565813;let t=e;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}}function X(e,t,r){return t+e()*(r-t)}function de(e,t=3){let r=10**t;return Math.round(e*r)/r}function to(e,t,r){return `hsl(${de((e%360+360)%360,1)} ${de(t,1)}% ${de(r,1)}%)`}function ro(e){let t=ds(e?.trim()||"patch-client"),r=us(t),n=t.toString(36),o=(kr[t%kr.length]??kr[0])+X(r,-10,10),s=r()<.5?-1:1,i=r()<.5?-1:1,a=o+i*X(r,52,116),l=o-i*X(r,26,66),c=o+s*X(r,12,38),d=to(o+s*X(r,0,14),X(r,80,92),X(r,44,54)),p=X(r,0,eo),u=Qn.map((m,h)=>{let v=(m.hue==="accent"?a:m.hue==="accent2"?l:m.hue==="near"?c:o)+X(r,-11,11),g=p+h/Qn.length*eo+X(r,-0.6,.6),y=X(r,m.reach[0],m.reach[1]),R=de(.5+Math.cos(g)*y),I=de(.5+Math.sin(g)*y),V=de(X(r,0,180),1),N=de(X(r,.62,1.5),3),b=de(X(r,.62,1.5),3);return {id:`cav-${n}-${h}`,cx:R,cy:I,r:de(X(r,m.r[0],m.r[1])),color:to(v,X(r,m.sat[0],m.sat[1]),X(r,m.light[0],m.light[1])),opacity:de(X(r,m.opacity[0],m.opacity[1]),2),gradientTransform:`rotate(${V} ${R} ${I}) translate(${R} ${I}) scale(${N} ${b}) translate(${de(-R)} ${de(-I)})`}});return {id:n,background:d,spots:u,blur:de(X(r,3.4,5.4),2),grain:de(X(r,.09,.15),2)}}function wt(e){let t=e.gap??12,r=e.margin??16,n=Math.min(e.popover.width,Math.max(0,e.viewport.width-r*2)),o="right",s=e.anchor.x+e.anchor.width+t;s+n>e.viewport.width-r&&(o="left",s=e.anchor.x-n-t),s<r&&(s=r);let i=e.anchor.y;return i+e.popover.height>e.viewport.height-r&&(i=e.viewport.height-r-e.popover.height),i<r&&(i=r),{x:s,y:i,width:n,placement:o}}function A(...e){return e.filter(Boolean).join(" ")}function Yt({seed:e,className:t,style:r}){let n=ro(e),o=useId().replace(/[^a-zA-Z0-9_-]/g,""),s=`${n.id}-${o}`,i=`cav-blur-${s}`,a=`cav-grain-${s}`;return jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 64 64",className:A("absolute inset-0 size-full! overflow-hidden rounded-full",t),style:r,children:[jsxs("defs",{children:[jsx("filter",{id:i,x:"-20%",y:"-20%",width:"140%",height:"140%",children:jsx("feGaussianBlur",{stdDeviation:n.blur})}),jsxs("filter",{id:a,x:"0%",y:"0%",width:"100%",height:"100%",children:[jsx("feTurbulence",{type:"fractalNoise",baseFrequency:"0.9",numOctaves:"2",stitchTiles:"stitch"}),jsx("feColorMatrix",{type:"saturate",values:"0"})]}),n.spots.map(l=>jsxs("radialGradient",{id:`${s}-${l.id}`,cx:l.cx,cy:l.cy,r:l.r,gradientTransform:l.gradientTransform,children:[jsx("stop",{offset:"0%",stopColor:l.color,stopOpacity:l.opacity}),jsx("stop",{offset:"100%",stopColor:l.color,stopOpacity:0})]},l.id))]}),jsx("rect",{width:"64",height:"64",fill:n.background}),jsx("g",{filter:`url(#${i})`,children:n.spots.map(l=>jsx("rect",{width:"64",height:"64",fill:`url(#${s}-${l.id})`},l.id))}),jsx("rect",{width:"64",height:"64",filter:`url(#${a})`,opacity:n.grain,style:{mixBlendMode:"overlay"}})]})}var Ie=32,no=[.22,.61,.36,1],Gt=["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 rt(e){if(!e)return "?";let t=e.trim().split(/\s+/),r=t[0],n=t[t.length-1];if(!r||!n)return "?";if(t.length===1)return r.slice(0,2).toUpperCase();let o=r[0]??"",s=n[0]??"";return (o+s).toUpperCase()||"?"}function nt(e){if(!e)return Gt[0];let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t|=0;return Gt[Math.abs(t)%Gt.length]??Gt[0]}var fs={right:"50% 50% 3px 50%",left:"50% 50% 50% 3px"},gs={right:"50% 50% 2px 50%",left:"50% 50% 50% 2px"};function ot(e,t){let{placement:r}=wt({anchor:{x:e.viewportX-Ie/2,y:e.viewportY-Ie/2,width:Ie,height:Ie},popover:{width:332,height:200},viewport:t});return r==="right"?"left":"right"}function Xt(e,t){return {x:t==="left"?e.viewportX:e.viewportX-Ie,y:e.viewportY-Ie,width:Ie,height:Ie}}function Cr({ref:e,...t}){let r=t.pointSide??"right",n=!t.resolved&&t.attention?hs[t.attention]:null,{url:o,seed:s}=Wt(t.avatarSrc),i=s??t.generatedSeed,a=t.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:e,type:"button",onClick:t.onClick,"aria-label":t.ariaLabel??"Open annotation","data-patch-ephemeral":t.ephemeral?"":void 0,"data-patch-pin-id":t.pinId,className:"patch-pin-button fixed z-[2147483645] border-0 bg-transparent p-0",style:{width:Ie,height:Ie},initial:t.ephemeral?{opacity:0,scale:.45}:false,animate:t.ephemeral?{opacity:1,scale:1,transition:{type:"spring",stiffness:620,damping:30,mass:.65}}:{opacity:1,scale:1},exit:t.ephemeral?{opacity:0,scale:.45,transition:{delay:.16,duration:.14,ease:no}}:{opacity:0,scale:.9,transition:{duration:.12,ease:no}},children:jsxs("span",{className:"patch-pin relative grid size-full place-items-center","data-patch-point-side":r,style:{borderRadius:fs[r]},children:[jsxs("span",{"data-patch-avatar":"",className:"absolute inset-[2px] overflow-hidden",style:{borderRadius:gs[r],background:"var(--color-muted-foreground)"},children:[i?jsx(Yt,{seed:i,style:{borderRadius:0,filter:a||"none"}}):null,o?jsx("img",{src:o,alt:t.avatarAlt??"",referrerPolicy:"no-referrer",className:"absolute inset-0 size-full object-cover",draggable:false,style:{filter:a||"none"},onError:c=>{c.currentTarget.remove();}}):null]}),t.resolved&&jsx("span",{className:`absolute ${l} grid size-[14px] place-items-center rounded-full bg-brand-green text-[9px] font-bold leading-none text-white`,children:"\u2713"}),n&&jsx("span",{"data-patch-attention":t.attention,"aria-hidden":"true",className:`absolute -top-0.5 -right-0.5 size-[10px] rounded-full border-[1.5px] border-white ${n}`})]})})}var hs={"review-pr":"bg-brand","patch-failed":"bg-destructive","rerun-after-closed":"bg-muted-foreground"};function Kt(e){let t=new Date(e).getTime(),r=Date.now()-t,n=Math.round(r/6e4);if(Number.isNaN(n))return "";if(n<1)return "just now";if(n<60)return `${n}m ago`;let o=Math.round(n/60);return o<24?`${o}h ago`:`${Math.round(o/24)}d ago`}function io(e){let t=e.composedPath();for(let r of t)if(r instanceof Element&&r.tagName?.toLowerCase()==="patch-widget-root")return true;return false}function ao(e){let t=e.match(/\/pull\/(\d+)/);return t?`#${t[1]}`:"PR"}var so={"arrow-up":[["path",{d:"M12 5.5V19"}],["path",{d:"M18 11C18 11 13.5811 5.00001 12 5C10.4188 4.99999 6 11 6 11"}]],check:[["path",{d:"M5 14L8.5 17.5L19 6.5"}]],copy:[["path",{d:"M9 15C9 12.1716 9 10.7574 9.87868 9.87868C10.7574 9 12.1716 9 15 9L16 9C18.8284 9 20.2426 9 21.1213 9.87868C22 10.7574 22 12.1716 22 15V16C22 18.8284 22 20.2426 21.1213 21.1213C20.2426 22 18.8284 22 16 22H15C12.1716 22 10.7574 22 9.87868 21.1213C9 20.2426 9 18.8284 9 16L9 15Z"}],["path",{d:"M16.9999 9C16.9975 6.04291 16.9528 4.51121 16.092 3.46243C15.9258 3.25989 15.7401 3.07418 15.5376 2.90796C14.4312 2 12.7875 2 9.5 2C6.21252 2 4.56878 2 3.46243 2.90796C3.25989 3.07417 3.07418 3.25989 2.90796 3.46243C2 4.56878 2 6.21252 2 9.5C2 12.7875 2 14.4312 2.90796 15.5376C3.07417 15.7401 3.25989 15.9258 3.46243 16.092C4.51121 16.9528 6.04291 16.9975 9 16.9999"}]],cursor:[["path",{d:"M12.669 8.35811L17.6969 10.3256C20.5969 11.4604 22.0469 12.0277 21.9988 12.9278C21.9508 13.8278 20.4375 14.2405 17.4111 15.0659C16.5099 15.3117 16.0593 15.4346 15.7469 15.7469C15.4346 16.0593 15.3117 16.5099 15.0659 17.4111C14.2405 20.4375 13.8278 21.9508 12.9278 21.9988C12.0277 22.0469 11.4604 20.5969 10.3256 17.6969L8.35811 12.669C7.17004 9.63279 6.57601 8.1147 7.34535 7.34535C8.1147 6.57601 9.63279 7.17004 12.669 8.35811Z"}],["path",{d:"M9 4V2M5 5L3.5 3.5M4 9H2M5 13L3.5 14.5M14.5 3.5L13 5"}]],desktop:[["path",{d:"M14 21H16M14 21C13.1716 21 12.5 20.3284 12.5 19.5V17L12 17M14 21H10M10 21H8M10 21C10.8284 21 11.5 20.3284 11.5 19.5V17L12 17M12 17V21"}],["path",{d:"M16 3H8C5.17157 3 3.75736 3 2.87868 3.87868C2 4.75736 2 6.17157 2 9V11C2 13.8284 2 15.2426 2.87868 16.1213C3.75736 17 5.17157 17 8 17H16C18.8284 17 20.2426 17 21.1213 16.1213C22 15.2426 22 13.8284 22 11V9C22 6.17157 22 4.75736 21.1213 3.87868C20.2426 3 18.8284 3 16 3Z"}]],globe:[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"M8 12C8 18 12 22 12 22C12 22 16 18 16 12C16 6 12 2 12 2C12 2 8 6 8 12Z"}],["path",{d:"M21 15H3"}],["path",{d:"M21 9H3"}]],list:[["path",{d:"M8 5.5L20 5.5"}],["path",{d:"M8 12.5L20 12.5"}],["path",{d:"M8 19.5L20 19.5"}],["path",{d:"M4.375 5.5H4.25M4.5 5.5C4.5 5.63807 4.38807 5.75 4.25 5.75C4.11193 5.75 4 5.63807 4 5.5C4 5.36193 4.11193 5.25 4.25 5.25C4.38807 5.25 4.5 5.36193 4.5 5.5Z"}],["path",{d:"M4.375 12.5H4.25M4.5 12.5C4.5 12.6381 4.38807 12.75 4.25 12.75C4.11193 12.75 4 12.6381 4 12.5C4 12.3619 4.11193 12.25 4.25 12.25C4.38807 12.25 4.5 12.3619 4.5 12.5Z"}],["path",{d:"M4.375 19.5H4.25M4.5 19.5C4.5 19.6381 4.38807 19.75 4.25 19.75C4.11193 19.75 4 19.6381 4 19.5C4 19.3619 4.11193 19.25 4.25 19.25C4.38807 19.25 4.5 19.3619 4.5 19.5Z"}]],lock:[["path",{d:"M4.26781 18.8447C4.49269 20.515 5.87613 21.8235 7.55966 21.9009C8.97627 21.966 10.4153 22 12 22C13.5847 22 15.0237 21.966 16.4403 21.9009C18.1239 21.8235 19.5073 20.515 19.7322 18.8447C19.879 17.7547 20 16.6376 20 15.5C20 14.3624 19.879 13.2453 19.7322 12.1553C19.5073 10.485 18.1239 9.17649 16.4403 9.09909C15.0237 9.03397 13.5847 9 12 9C10.4153 9 8.97627 9.03397 7.55966 9.09909C5.87613 9.17649 4.49269 10.485 4.26781 12.1553C4.12104 13.2453 4 14.3624 4 15.5C4 16.6376 4.12104 17.7547 4.26781 18.8447Z"}],["path",{d:"M7.5 9V6.5C7.5 4.01472 9.51472 2 12 2C14.4853 2 16.5 4.01472 16.5 6.5V9"}],["path",{d:"M12.125 15.5H12M12.25 15.5C12.25 15.6381 12.1381 15.75 12 15.75C11.8619 15.75 11.75 15.6381 11.75 15.5C11.75 15.3619 11.8619 15.25 12 15.25C12.1381 15.25 12.25 15.3619 12.25 15.5Z"}]],mobile:[["path",{d:"M13.5 2H10.5C8.14298 2 6.96447 2 6.23223 2.73223C5.5 3.46447 5.5 4.64298 5.5 7V17C5.5 19.357 5.5 20.5355 6.23223 21.2678C6.96447 22 8.14298 22 10.5 22H13.5C15.857 22 17.0355 22 17.7678 21.2678C18.5 20.5355 18.5 19.357 18.5 17V7C18.5 4.64298 18.5 3.46447 17.7678 2.73223C17.0355 2 15.857 2 13.5 2Z"}],["path",{d:"M12.125 19H12M12.25 19C12.25 19.1381 12.1381 19.25 12 19.25C11.8619 19.25 11.75 19.1381 11.75 19C11.75 18.8619 11.8619 18.75 12 18.75C12.1381 18.75 12.25 18.8619 12.25 19Z"}]],more:[["path",{d:"M12 12.002H12.5M19 12.002H19.5M5 12.002H5.5M12 13.002C12.5523 13.002 13 12.5542 13 12.002C13 11.4497 12.5523 11.002 12 11.002C11.4477 11.002 11 11.4497 11 12.002C11 12.5542 11.4477 13.002 12 13.002ZM19 13.002C19.5523 13.002 20 12.5542 20 12.002C20 11.4497 19.5523 11.002 19 11.002C18.4477 11.002 18 11.4497 18 12.002C18 12.5542 18.4477 13.002 19 13.002ZM5 13.002C5.55228 13.002 6 12.5542 6 12.002C6 11.4497 5.55228 11.002 5 11.002C4.44772 11.002 4 11.4497 4 12.002C4 12.5542 4.44772 13.002 5 13.002Z"}]],play:[["path",{d:"M18.8906 12.846C18.5371 14.189 16.8667 15.138 13.5257 17.0361C10.296 18.8709 8.6812 19.7884 7.37983 19.4196C6.8418 19.2671 6.35159 18.9776 5.95624 18.5787C5 17.6139 5 15.7426 5 12C5 8.2574 5 6.3861 5.95624 5.42132C6.35159 5.02245 6.8418 4.73288 7.37983 4.58042C8.6812 4.21165 10.296 5.12907 13.5257 6.96393C16.8667 8.86197 18.5371 9.811 18.8906 11.154C19.0365 11.7084 19.0365 12.2916 18.8906 12.846Z"}]],pr:[["path",{d:"M6 8L6 16"}],["path",{d:"M18 16V12C18 9.17156 18 7.75735 17.1213 6.87867C16.2426 5.99999 14.8284 5.99999 12 5.99999L11 5.99999M11 5.99999C11 5.29976 12.9943 3.99152 13.5 3.49999M11 5.99999C11 6.70022 12.9943 8.00846 13.5 8.49999"}],["circle",{cx:"6",cy:"18",r:"2"}],["circle",{cx:"6",cy:"6",r:"2"}],["circle",{cx:"18",cy:"18",r:"2"}]],refresh:[["path",{d:"M20.0092 2V5.13219C20.0092 5.42605 19.6418 5.55908 19.4537 5.33333C17.6226 3.2875 14.9617 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22C17.5228 22 22 17.5228 22 12"}]],robot:[["path",{d:"M19 16V14C19 11.1716 19 9.75736 18.1213 8.87868C17.2426 8 15.8284 8 13 8H11C8.17157 8 6.75736 8 5.87868 8.87868C5 9.75736 5 11.1716 5 14V16C5 18.8284 5 20.2426 5.87868 21.1213C6.75736 22 8.17157 22 11 22H13C15.8284 22 17.2426 22 18.1213 21.1213C19 20.2426 19 18.8284 19 16Z"}],["path",{d:"M19 18C20.4142 18 21.1213 18 21.5607 17.5607C22 17.1213 22 16.4142 22 15C22 13.5858 22 12.8787 21.5607 12.4393C21.1213 12 20.4142 12 19 12"}],["path",{d:"M5 18C3.58579 18 2.87868 18 2.43934 17.5607C2 17.1213 2 16.4142 2 15C2 13.5858 2 12.8787 2.43934 12.4393C2.87868 12 3.58579 12 5 12"}],["path",{d:"M13.5 3.5C13.5 4.32843 12.8284 5 12 5C11.1716 5 10.5 4.32843 10.5 3.5C10.5 2.67157 11.1716 2 12 2C12.8284 2 13.5 2.67157 13.5 3.5Z"}],["path",{d:"M12 5V8"}],["path",{d:"M9 13V14"}],["path",{d:"M15 13V14"}],["path",{d:"M10 17.5C10 17.5 10.6667 18 12 18C13.3333 18 14 17.5 14 17.5"}]],settings:[["path",{d:"M15.5 12C15.5 13.933 13.933 15.5 12 15.5C10.067 15.5 8.5 13.933 8.5 12C8.5 10.067 10.067 8.5 12 8.5C13.933 8.5 15.5 10.067 15.5 12Z"}],["path",{d:"M21.011 14.0965C21.5329 13.9558 21.7939 13.8854 21.8969 13.7508C22 13.6163 22 13.3998 22 12.9669V11.0332C22 10.6003 22 10.3838 21.8969 10.2493C21.7938 10.1147 21.5329 10.0443 21.011 9.90358C19.0606 9.37759 17.8399 7.33851 18.3433 5.40087C18.4817 4.86799 18.5509 4.60156 18.4848 4.44529C18.4187 4.28902 18.2291 4.18134 17.8497 3.96596L16.125 2.98673C15.7528 2.77539 15.5667 2.66972 15.3997 2.69222C15.2326 2.71472 15.0442 2.90273 14.6672 3.27873C13.208 4.73448 10.7936 4.73442 9.33434 3.27864C8.95743 2.90263 8.76898 2.71463 8.60193 2.69212C8.43489 2.66962 8.24877 2.77529 7.87653 2.98663L6.15184 3.96587C5.77253 4.18123 5.58287 4.28891 5.51678 4.44515C5.45068 4.6014 5.51987 4.86787 5.65825 5.4008C6.16137 7.3385 4.93972 9.37763 2.98902 9.9036C2.46712 10.0443 2.20617 10.1147 2.10308 10.2492C2 10.3838 2 10.6003 2 11.0332V12.9669C2 13.3998 2 13.6163 2.10308 13.7508C2.20615 13.8854 2.46711 13.9558 2.98902 14.0965C4.9394 14.6225 6.16008 16.6616 5.65672 18.5992C5.51829 19.1321 5.44907 19.3985 5.51516 19.5548C5.58126 19.7111 5.77092 19.8188 6.15025 20.0341L7.87495 21.0134C8.24721 21.2247 8.43334 21.3304 8.6004 21.3079C8.76746 21.2854 8.95588 21.0973 9.33271 20.7213C10.7927 19.2644 13.2088 19.2643 14.6689 20.7212C15.0457 21.0973 15.2341 21.2853 15.4012 21.3078C15.5682 21.3303 15.7544 21.2246 16.1266 21.0133L17.8513 20.034C18.2307 19.8187 18.4204 19.711 18.4864 19.5547C18.5525 19.3984 18.4833 19.132 18.3448 18.5991C17.8412 16.6616 19.0609 14.6226 21.011 14.0965Z"}]],tablet:[["path",{d:"M14.5 2H9.5C6.67157 2 5.25736 2 4.37868 2.87868C3.5 3.75736 3.5 5.17157 3.5 8V16C3.5 18.8284 3.5 20.2426 4.37868 21.1213C5.25736 22 6.67157 22 9.5 22H14.5C17.3284 22 18.7426 22 19.6213 21.1213C20.5 20.2426 20.5 18.8284 20.5 16V8C20.5 5.17157 20.5 3.75736 19.6213 2.87868C18.7426 2 17.3284 2 14.5 2Z"}],["path",{d:"M12.125 19H12M12.25 19C12.25 19.1381 12.1381 19.25 12 19.25C11.8619 19.25 11.75 19.1381 11.75 19C11.75 18.8619 11.8619 18.75 12 18.75C12.1381 18.75 12.25 18.8619 12.25 19Z"}]],trash:[["path",{d:"M19.5 5.5L18.8803 15.5251C18.7219 18.0864 18.6428 19.3671 18.0008 20.2879C17.6833 20.7431 17.2747 21.1273 16.8007 21.416C15.8421 22 14.559 22 11.9927 22C9.42312 22 8.1383 22 7.17905 21.4149C6.7048 21.1257 6.296 20.7408 5.97868 20.2848C5.33688 19.3626 5.25945 18.0801 5.10461 15.5152L4.5 5.5"}],["path",{d:"M3 5.5H21M16.0557 5.5L15.3731 4.09173C14.9196 3.15626 14.6928 2.68852 14.3017 2.39681C14.215 2.3321 14.1231 2.27454 14.027 2.2247C13.5939 2 13.0741 2 12.0345 2C10.9688 2 10.436 2 9.99568 2.23412C9.8981 2.28601 9.80498 2.3459 9.71729 2.41317C9.32164 2.7167 9.10063 3.20155 8.65861 4.17126L8.05292 5.5"}],["path",{d:"M9.5 16.5L9.5 10.5"}],["path",{d:"M14.5 16.5L14.5 10.5"}]],unlink:[["path",{d:"M12.1434 10.691L12.3503 10.4841C14.329 8.50532 17.5372 8.50532 19.5159 10.4841C21.4947 12.4628 21.4947 15.671 19.5159 17.6497L16.6497 20.5159C14.671 22.4947 11.4628 22.4947 9.48405 20.5159C7.50532 18.5372 7.50532 15.329 9.48405 13.3503L9.9484 12.886"}],["path",{d:"M20.0516 11.114L20.5159 10.6497C22.4947 8.67095 22.4947 5.46279 20.5159 3.48405C18.5372 1.50532 15.329 1.50532 13.3503 3.48405L10.4841 6.35031C8.50532 8.32904 8.50532 11.5372 10.4841 13.5159C12.4628 15.4947 15.671 15.4947 17.6497 13.5159L17.8566 13.309"}],["path",{d:"M4.5 4L6 6M2 8L5 9M3 13.5L5 12"}]],x:[["path",{d:"M18 6L6.00081 17.9992M17.9992 18L6 6.00085"}]]};function z({name:e,size:t=16,stroke:r=2,color:n,className:o}){return jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n??"currentColor",strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",className:o,children:so[e].map(([s,i],a)=>createElement(s,{key:a,...i}))})}var co=[.16,1,.3,1];function ws(e){try{let r=new URL(e).pathname.replace(/\/$/,"");return r===""?"/":r}catch{return e}}function qt(e){return e==="pending"||e==="acknowledged"}function uo({onClose:e}){let t=tt(),{hideResolvedAnnotations:r}=Oe(),n=t.focusPin,o=typeof window>"u"?"":ae(window.location.href),s=useMemo(()=>[...r?t.entries.filter(d=>d.status!=="resolved"):t.entries].sort((d,p)=>(qt(d.status)?0:1)-(qt(p.status)?0:1)),[t.entries,r]),i=useMemo(()=>{let c=t.entries.filter(p=>qt(p.status)&&ae(p.url)===o).length,d=t.entries.filter(p=>qt(p.status)).length;return {here:c,elsewhere:d-c,total:d}},[t.entries,o]);function a(){if(i.total===0)return "No open feedback";let c=[`${i.total} open`];return i.here>0&&c.push(`${i.here} here`),i.elsewhere>0&&c.push(`${i.elsewhere} elsewhere`),c.join(" \xB7 ")}function l(c){e(),n(c);}return jsxs(motion.div,{initial:{opacity:0,y:6,scale:.98},animate:{opacity:1,y:0,scale:1,transition:{duration:.18,ease: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(ys,{entry:c,onCurrentPage:ae(c.url)===o,onClick:()=>l(c)},c.id))})]})}function ys({entry:e,onCurrentPage:t,onClick:r}){let n=e.status==="resolved",o=e.anchorStatus==="detached";return jsxs("button",{type:"button","data-patch-fab-dock":"","data-patch-roster-row":e.id,onClick:r,className:"flex w-full items-start gap-2.5 rounded-lg px-2.5 py-2 text-left transition-colors hover:bg-black/[0.04]",children:[jsx("span",{className:"mt-0.5 grid size-4 shrink-0 place-items-center",children:n?jsx("span",{className:"grid size-4 place-items-center rounded-full bg-brand-green text-white",children:jsx(z,{name:"check",size:10,stroke:2.6})}):e.status==="dismissed"?jsx("span",{className:"size-2 rounded-full border border-black/20"}):jsx("span",{className:"size-2 rounded-full bg-brand"})}),jsxs("span",{className:"min-w-0 flex-1",children:[jsx("span",{className:A("block truncate text-[12.5px] leading-snug",n?"text-popover-foreground/45 line-through":"text-popover-foreground"),children:e.label}),jsxs("span",{className:"mt-0.5 flex items-center gap-1.5 text-[11px] text-popover-foreground/50",children:[jsx(z,{name:we[e.viewport].glyph,size:11,className:"shrink-0 opacity-80"}),jsx("span",{className:"truncate",children:t?"This page":ws(e.url)}),jsx("span",{"aria-hidden":"true",children:"\xB7"}),jsx("span",{className:"shrink-0",children:Kt(e.createdAt)}),o?jsxs("span",{className:"ml-0.5 inline-flex shrink-0 items-center gap-1 rounded-full bg-black/[0.05] px-1.5 py-px text-[10px] font-medium text-popover-foreground/55",children:[jsx(z,{name:"unlink",size:10}),"element gone"]}):null]})]})]})}var ks="relative inline-grid shrink-0 overflow-hidden place-items-center rounded-full text-white font-semibold tracking-[-0.01em]",Cs={sm:"size-[22px] text-[9.5px]",md:"size-7 text-[10.5px]"};function ze({initials:e,tint:t,src:r,generatedSeed:n,alt:o="",size:s="md",className:i,style:a}){let{url:l,seed:c}=Wt(r),d=c??n;return jsxs("span",{className:A(ks,Cs[s],i),style:{background:t,...a},children:[jsx("span",{children:e}),!l&&d?jsx(Yt,{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:p=>{p.currentTarget.remove();}}):null]})}var As="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",Ts="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 Ct({size:e=16,className:t}){return jsx("svg",{width:e,height:e,viewBox:"0 0 96 96",fill:"currentColor","aria-hidden":"true",focusable:"false",className:t,children:jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:As})})}function po({size:e=16,variant:t="filled",stroke:r=2,className:n}){let o=t==="outline";return jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:o?"none":"currentColor",stroke:o?"currentColor":"none",strokeWidth:o?r:void 0,strokeLinejoin:o?"round":void 0,strokeLinecap:o?"round":void 0,"aria-hidden":"true",focusable:"false",className:n,children:jsx("path",{d:Ts})})}var Ar=false,Ye=null,jt=null,ke={openDelay:700,isInstant(){return Ar},onOpen(e){jt&&jt!==e&&jt(),jt=e??null,Ar=true,Ye&&(clearTimeout(Ye),Ye=null);},onClose(){Ye&&clearTimeout(Ye),Ye=setTimeout(()=>{Ar=false,Ye=null;},300);}};var go="easeOut";function Ce({text:e,children:t,className:r,tone:n="default",placement:o="top"}){let[s,i]=useState(false),[a,l]=useState(false),c=useRef(null),d=useRef(false);useEffect(()=>()=>{c.current&&clearTimeout(c.current),d.current&&ke.onClose();},[]);let p=I=>{l(I),i(true),d.current=true,ke.onOpen();},u=()=>{if(c.current&&(clearTimeout(c.current),c.current=null),ke.isInstant()){p(true);return}c.current=setTimeout(()=>{c.current=null,p(false);},ke.openDelay);},m=()=>{c.current&&(clearTimeout(c.current),c.current=null),d.current&&(d.current=false,ke.onClose()),i(false);},h=n==="warning"?"pointer-events-none absolute bottom-[calc(100%+8px)] left-0 z-[1]":o==="bottom"?"pointer-events-none absolute top-[calc(100%+8px)] left-1/2 z-[1] -translate-x-1/2":"pointer-events-none absolute -top-[38px] left-1/2 z-[1] -translate-x-1/2",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",v=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}`,g=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,R=o==="bottom"&&n!=="warning"?-2:2;return jsxs("span",{className:A("relative inline-flex items-center justify-center",r),onMouseEnter:u,onMouseLeave:m,onMouseDown:m,children:[jsx("span",{className:h,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:go}},exit:{opacity:0,y:R,scale:.98,transition:{duration:.08,ease:go}},className:v,children:[n==="warning"?jsxs("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:"mt-px size-3.5 shrink-0",children:[jsx("path",{d:"M10.3 3.9 1.8 18.6A2 2 0 0 0 3.5 21.6h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0Z",fill:"#fbbf24"}),jsx("path",{d:"M12 9v4.5M12 17h.01",fill:"none",stroke:"#fff",strokeWidth:"2",strokeLinecap:"round"})]}):null,jsx("span",{className:"min-w-0 flex-1",children:e}),jsx("span",{className:g})]})})}),t]})}var bo=44,Pe=[.16,1,.3,1],vo="easeOut",Ns=.08,Ms=60,_s="calc(100% - 64px) calc(100% + 4px)",lt="pkey pkey-dock grid size-8 place-items-center rounded-full border-0 bg-transparent";function xo(){let e=Hn(),t=xe(),r=re(),n=tt(),{dockOpen:o,hideResolvedAnnotations:s,setDockOpen:i,setHideResolvedAnnotations:a}=Oe(),l=!!r.studio,c=n.unresolvedCount,[d,p]=useState(false),[u,m]=useState(false),[h,f]=useState(false),[v,g]=useState(false),[y,R]=useState(false),[I,V]=useState(false),N=useRef(null),b=useRef(null),L=useRef(false),[Q,j]=useState(false),be=useRef(null),[pe,oe]=useState(bo);useLayoutEffect(()=>{let O=be.current;if(!O)return;let ie=()=>oe(O.offsetWidth);ie();let Te=new ResizeObserver(ie);return Te.observe(O),()=>Te.disconnect()},[]);let ee=r.studio?r.studio.name:r.identity?.name??null,G=rt(ee),w=r.studio?.image??null,T=r.identity?.avatarSeed??r.clientAvatarSeed,P=r.studio?.userId??T,k=r.studio?"var(--color-foreground)":nt(T),D=r.studio&&!w?"#FFFFFF":k,H=r.studio&&!w?"text-foreground":"text-white",C=we[r.activeViewport];function te(){N.current!==null&&(window.clearTimeout(N.current),N.current=null);}function me(){b.current!==null&&(window.clearTimeout(b.current),b.current=null);}let E=useRef(()=>{});E.current=()=>{!L.current&&N.current===null||(te(),me(),L.current=false,V(true));};let M=useRef(()=>E.current()).current;useEffect(()=>{I&&d&&p(false);},[I,d]);function $(O){m(false),f(false),g(false),te(),me(),L.current=true,V(false),R(O),ke.onOpen(M),p(true);}function q(){$(false);}function Ae(){if(te(),!(L.current||b.current!==null)){if(ke.isInstant()){$(true);return}b.current=window.setTimeout(()=>{b.current=null,$(false);},ke.openDelay);}}function fe(){me(),te(),L.current&&(L.current=false,ke.onClose()),N.current=window.setTimeout(()=>{p(false),N.current=null;},120);}function Ve(){j(true),i(true);}function Pt(){m(false),f(false),g(false),me(),L.current=false,p(false),e.isCapturing?e.exit():e.enter();}function Nt(){m(false),f(false),me(),L.current=false,p(false),g(O=>{let ie=!O;return ie&&n.refresh(),ie});}function ir(){j(true),i(false),m(false),f(false),g(false),me(),L.current=false,p(false),e.exit(),t.active&&t.forceClose();}useEffect(()=>()=>{N.current!==null&&window.clearTimeout(N.current),b.current!==null&&window.clearTimeout(b.current);},[]);let S=()=>{r.signOut(),p(false);};function _(){f(false),g(false),me(),L.current=false,p(false),m(O=>!O);}function U(O){m(false),r.activeViewport!==O&&(t.active&&t.forceClose(),r.setActiveViewport(O));}function B(){m(false),g(false),me(),L.current=false,p(false),f(O=>!O);}function Y(){a(!s);}function ar(O){let ie=O.relatedTarget;ie instanceof Node&&O.currentTarget.contains(ie)||fe();}return jsxs("div",{"data-patch-fab-dock":"",className:"fixed right-5 bottom-5 z-[2147483647] flex justify-end",children:[jsxs(motion.div,{initial:false,animate:{width:o?pe:bo},transition:{duration:.36,ease:Pe},onAnimationComplete:()=>j(false),whileHover:o?void 0:{scale:1.03,transition:{duration:.15,ease:Pe}},whileTap:o?void 0:{scale:.97,transition:{duration:.1,ease:Pe}},"data-patch-fab-dock":"",className:A("pkey-fab relative h-11 rounded-full",Q?"overflow-hidden":"overflow-visible"),children:[jsx(motion.div,{animate:{opacity:o?0:1,scale:o?.7:1},transition:{duration:.18,ease:Pe},className:A("absolute inset-0",o?"pointer-events-none":"pointer-events-auto"),children:jsx("button",{type:"button",onClick:Ve,"data-patch-fab-dock":"","aria-label":l&&c>0?`Leave feedback \u2014 ${c} open`:"Leave feedback",className:"grid size-full place-items-center border-0 bg-transparent text-white",children:jsx(Ct,{size:18})})}),jsxs("div",{ref:be,"data-patch-fab-dock":"",className:A("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(ct,{visible:o,index:0,children:jsx(Ce,{text:e.isCapturing?"Stop commenting":"Add comment",children:jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":e.isCapturing?"Stop commenting":"Add comment","aria-pressed":e.isCapturing,onClick:Pt,className:A(lt,"transition-colors",e.isCapturing?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:jsx(po,{variant:"outline",size:16})})})}),l?jsx(ct,{visible:o,index:1,children:jsx(Ce,{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":v,onClick:Nt,className:A(lt,"relative transition-colors",v||c>0?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:[jsx(z,{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(ct,{visible:o,index:2,children:jsxs("div",{className:"relative flex items-center",children:[jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":`Viewport: ${C.label}`,"aria-expanded":u,onClick:_,className:A(lt,"transition-colors",r.activeViewport==="desktop"&&!u?"text-white/70 hover:bg-white/[0.08] hover:text-white":"bg-brand/15 text-brand"),children:jsx(z,{name:C.glyph,size:15})}),jsx(AnimatePresence,{children:u?jsxs(motion.div,{initial:{opacity:0,y:4,scale:.97},animate:{opacity:1,y:0,scale:1,transition:{duration:.16,ease:Pe}},exit:{opacity:0,y:3,scale:.98,transition:{duration:.12,ease:Pe}},"data-patch-fab-dock":"","data-patch-viewport-menu":"",className:"pkey-fab absolute bottom-[46px] left-[-42px] z-[2147483647] flex items-center gap-1 rounded-full p-1.5 text-white",style:{transformOrigin:"50% calc(100% + 8px)"},children:[jsx("span",{className:"pointer-events-none absolute -bottom-1 left-1/2 size-2 -translate-x-1/2 rotate-45 rounded-[2px] border-r border-b border-white/10 bg-foreground"}),Vr.map(O=>{let ie=we[O],Te=r.activeViewport===O;return jsx(Ce,{text:Ke(O),children:jsx("button",{type:"button","data-patch-viewport-option":O,"aria-label":Ke(O),"aria-pressed":Te,onClick:()=>U(O),className:A("grid size-8 place-items-center rounded-full border-0 bg-transparent transition-colors",Te?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:jsx(z,{name:ie.glyph,size:15})})},O)})]}):null})]})}),jsx(ct,{visible:o,index:3,children:jsxs("div",{className:"relative flex items-center",children:[jsx(Ce,{text:"Settings",children:jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":"Settings","aria-expanded":h,onClick:B,className:A(lt,"transition-colors",h||s?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:jsx(z,{name:"settings",size:15})})}),jsx(AnimatePresence,{children:h?jsxs(motion.div,{initial:{opacity:0,y:4,scale:.97},animate:{opacity:1,y:0,scale:1,transition:{duration:.16,ease:Pe}},exit:{opacity:0,y:3,scale:.98,transition:{duration:.12,ease:Pe}},"data-patch-fab-dock":"","data-patch-settings-menu":"",className:"pkey-fab absolute bottom-[46px] left-[-84px] z-[2147483647] w-[200px] rounded-xl p-1.5 text-white",style:{transformOrigin:"50% calc(100% + 8px)"},children:[jsx("span",{className:"pointer-events-none absolute -bottom-1 left-1/2 size-2 -translate-x-1/2 rotate-45 rounded-[2px] border-r border-b border-white/10 bg-foreground"}),jsxs("label",{"data-patch-hide-resolved-toggle":"",className:"flex h-9 w-full cursor-pointer items-center gap-2 rounded-lg px-2.5 text-left font-sans text-[12px] font-medium text-white transition-colors hover:bg-white/[0.08]",children:[jsx("input",{type:"checkbox",checked:s,"aria-label":"Hide resolved annotations",onChange:Y,className:"peer sr-only"}),jsx("span",{"aria-hidden":"true",className:A("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(z,{name:"check",size:10,stroke:2.4})}),jsx("span",{className:"min-w-0 flex-1 whitespace-nowrap",children:"Hide resolved annotations"})]})]}):null})]})}),jsx(ct,{visible:o,index:4,children:jsxs("span",{"data-patch-identity-hover":"",className:"relative inline-flex items-center justify-center",onMouseEnter:Ae,onMouseLeave:fe,onFocus:q,onBlur:ar,children:[jsx("button",{type:"button","data-patch-fab-dock":"","data-patch-person-btn":"","aria-label":ee?`Account: ${ee}`:"Identify",className:A(lt,"text-white"),children:ee?jsx(ze,{initials:G,tint:D,src:w,generatedSeed:P,alt:ee,size:"sm",className:A("size-[22px] text-[9.5px] ring-1 ring-white/20",H)}):jsx("span",{className:"grid size-[22px] place-items-center rounded-full border border-white/30 text-[9.5px] font-semibold text-white/70",children:"?"})}),jsx(AnimatePresence,{children:d?jsxs(motion.div,{initial:y?false:{opacity:0,y:3,scale:.98},animate:{opacity:1,y:0,scale:1,transition:y?{duration:0}:{duration:.12,delay:Ns,ease:vo}},exit:{opacity:0,y:2,scale:.98,transition:I?{duration:0}:{duration:.08,ease:vo}},"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:_s},children:[jsx("span",{className:"absolute bottom-[-4px] size-2 rotate-45 border-r border-b border-white/10 bg-foreground",style:{right:Ms}}),r.studio?jsxs("div",{className:"flex items-center gap-2.5",children:[jsx(ze,{initials:G,tint:k,src:w,generatedSeed:P,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(ze,{initials:G,tint:k,generatedSeed:P,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:S,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(ct,{visible:o,index:5,children:jsxs("div",{className:"flex items-center gap-1.5",children:[jsx("span",{className:"h-5 w-px shrink-0 bg-white/12"}),jsx(Ce,{text:"Close",children:jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":"Close",onClick:ir,className:A(lt,"text-white/70"),children:jsx(z,{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:v?jsx(uo,{onClose:()=>g(false)}):null})]})}function ct({children:e,visible:t,index:r}){return jsx(motion.div,{initial:{opacity:0,x:6},animate:t?{opacity:1,x:0,transition:{duration:.2,delay:.12+r*.035,ease:Pe}}:{opacity:0,x:6,transition:{duration:.12,ease:Pe}},children:e})}function wo(e,t){return t.width<=0||t.height<=0?{fx:0,fy:0}:{fx:(e.viewportX-t.x)/t.width,fy:(e.viewportY-t.y)/t.height}}function yo(e,t){return {viewportX:t.x+e.fx*t.width,viewportY:t.y+e.fy*t.height}}var Ds=.6,Os=.5,Qt={text:.4,attrs:.3,classes:.2,position:.1},zs=5e3,Hs=.08,$s=.12;function Fs(e,t){return t===void 0||t===""?.5:e===t?1:e&&(e.includes(t)||t.includes(e))?.5:0}function Vs(e,t){if(!t)return .5;let r=Object.keys(t);if(r.length===0)return .5;let n=0;for(let o of r)e[o]===t[o]&&n++;return n/r.length}function Bs(e,t){let r=new Set(e),n=new Set(t??[]);if(r.size===0&&n.size===0)return .5;let o=0;for(let i of r)n.has(i)&&o++;let s=r.size+n.size-o;return s===0?0:o/s}function Co(e){let t=e.payload.boundingBox;if(!t)return null;let r=e.payload.coordinates.documentY-e.payload.coordinates.viewportY;return {x:t.x+t.width/2,y:t.y+t.height/2+r}}function Er(e,t,r){if(!t)return .5;let n=e.left+e.width/2,o=e.top+r.scrollY+e.height/2,s=(n-t.x)/Math.max(1,r.viewport.width),i=(o-t.y)/Math.max(1,r.viewport.height);return Math.max(0,1-Math.sqrt(s*s+i*i))}function Ws(e,t){let r=Ft(e),n=$t(e),o=bt(e),s=e.getBoundingClientRect(),i=Fs(r,t.payload.domHints?.textSignature),a=Vs(n,t.payload.domHints?.attributeSignature),l=Bs(o,t.payload.cssClasses),c=Er(s,Co(t),t);return Qt.text*i+Qt.attrs*a+Qt.classes*l+Qt.position*c}function Us(e){let t=e.getBoundingClientRect();return t.width<1&&t.height<1}function ko(e,t,r){let n=null,o=null,s=0;for(let i=0;i<e.length&&!(s>=zs);i++){let a=e[i];if(!a||(s++,Rn(a,t.internalAttr)))continue;let l=a.tagName.toLowerCase();if(l==="html"||l==="head"||l==="script"||l==="style"||Us(a))continue;let c=Ws(a,t);!n||c>n.score?(o=n,n={el:a,score:c}):(!o||c>o.score)&&(o={el:a,score:c});}if(!n||n.score<r)return null;if(o&&n.score-o.score<Hs){let i=Co(t),a=Er(n.el.getBoundingClientRect(),i,t),l=Er(o.el.getBoundingClientRect(),i,t);if(a-l<$s)return null}return n.el}function Ys(e){return {viewportX:e.payload.coordinates.viewportX,viewportY:e.payload.coordinates.documentY-e.scrollY}}function Gs(e,t){let r=e.getBoundingClientRect();if(!t.payload.boundingBox)return {viewportX:r.x,viewportY:r.y};let n=wo({viewportX:t.payload.coordinates.viewportX,viewportY:t.payload.coordinates.viewportY},t.payload.boundingBox);return yo(n,{x:r.x,y:r.y,width:r.width,height:r.height})}function Xs(e){let t=e.payload.domHints?.cssSelector;if(!t)return [];try{return Array.from(e.doc.querySelectorAll(t))}catch{return []}}function er(e){if(!e.payload.domHints)return {kind:"detached",el:null};let t=Xs(e);if(t.length>0){let n=ko(t,e,Os);if(n)return {kind:"anchored",tier:1,el:n}}let r=ko(e.doc.querySelectorAll("*"),e,Ds);return r?{kind:"anchored",tier:2,el:r}:{kind:"detached",el:null}}function Rr(e,t){return e.kind==="anchored"&&e.el?Gs(e.el,t):Ys(t)}function So(e){let t=er(e);return {kind:t.kind,tier:t.tier,el:t.el,position:Rr(t,e)}}function Ao(e){if(e.status==="resolved")return null;let t=e.latestRun;return t?t.status==="failed"?"patch-failed":t.status!=="succeeded"?null:t.prClosedUnmerged?"rerun-after-closed":t.prUrl?"review-pr":null:null}var qs="data-patch-internal";function tr(e,t,r){let n=ot(r,t.getOverlayViewport()),o=Xt(r,n);e.style.top=`${o.y}px`,e.style.left=`${o.x}px`;}function Ro(e,t){return Math.abs(e.viewportX-t.viewportX)<.5&&Math.abs(e.viewportY-t.viewportY)<.5}function Zs(e){let t=e.getBoundingClientRect();return t.width<1&&t.height<1}function Nr(e,t){return {payload:t.payload,doc:e.targetDocument,scrollY:e.getTargetScrollY(),viewport:e.getTargetViewport(),internalAttr:qs}}function Io(e,t,r){let n=Nr(e,t);return {kind:r.kind,position:e.targetPointToOverlay(Rr(r,n))}}function js(e,t){return e.targetPointToOverlay({viewportX:t.viewportX,viewportY:t.documentY-e.getTargetScrollY()})}function Po(){let{annotations:e,annotationsReady:t,ephemerals:r,identity:n,studio:o,clientAvatarSeed:s,apiClient:i}=re(),a=xe(),{dockOpen:l,hideResolvedAnnotations:c}=Oe(),d=ce(),{isPreviewing:p,previewReady:u}=Je(),m=useReducedMotion(),h=a.active,f=a.forceClose,v=t&&(!p||u),g=useMemo(()=>l&&t?e.filter(w=>!c||w.status!=="resolved"):[],[l,t,e,c]),y=useMemo(()=>l&&t?r:[],[l,t,r]);useEffect(()=>{if(!c||h?.kind!=="existing")return;e.find(T=>T.id===h.annotationId)?.status==="resolved"&&f();},[h,e,f,c]);let R=useRef(new Map),I=useRef(new Map),V=useRef(new Map),N=useRef(new Map),b=useMemo(()=>{let w=N.current,T=new Set,P=new Map;for(let k of g){T.add(k.id);let D=w.get(k.id),C=D?.kind==="anchored"&&D.el?.isConnected?D:er(Nr(d,k));w.set(k.id,C),P.set(k.id,Io(d,k,C));}for(let k of w.keys())T.has(k)||w.delete(k);return P},[d,g]),L=useCallback(()=>{let w=N.current,T=V.current,P=new Set;for(let k of g){let D=R.current.get(k.id);if(!D)continue;P.add(k.id);let H=w.get(k.id);if((!H||H.kind==="anchored"&&H.el&&!H.el.isConnected)&&(H=er(Nr(d,k)),w.set(k.id,H)),H.kind==="detached"||H.kind==="anchored"&&H.el&&Zs(H.el)){D.style.visibility!=="hidden"&&(D.style.visibility="hidden"),T.delete(k.id);continue}D.style.visibility==="hidden"&&(D.style.visibility="");let C=Io(d,k,H).position,te=T.get(k.id);te&&Ro(te,C)||(T.set(k.id,C),tr(D,d,C));}for(let k of y){let D=I.current.get(k.tempId);if(!D)continue;P.add(k.tempId);let H=js(d,k),C=T.get(k.tempId);C&&Ro(C,H)||(T.set(k.tempId,H),tr(D,d,H));}for(let k of T.keys())P.has(k)||T.delete(k);},[d,g,y]),Q=g.length>0||y.length>0;useEffect(()=>{if(!Q)return;let w=d.overlayWindow,T=w.requestAnimationFrame(function P(){L(),T=w.requestAnimationFrame(P);});return ()=>w.cancelAnimationFrame(T)},[Q,L,d]);let j=useRef(new Map);useEffect(()=>{if(!t||g.length===0)return;let w=setTimeout(()=>{let T=[];for(let P of g){let k=b.get(P.id);if(!k)continue;let D=k.kind!=="detached";j.current.get(P.id)!==D&&(j.current.set(P.id,D),T.push({id:P.id,present:D}));}i.reportAnchorStatuses(T);},1500);return ()=>clearTimeout(w)},[b,g,t,i]);let be=useCallback(w=>{if(a.active&&a.draftText.trim().length>0){a.attemptClose();return}a.openExisting(w);},[a]),pe=o?o.name:n?.name??null,oe=o?.image??null,ee=n?.avatarSeed??s,G=o?.userId??ee;return jsxs("div",{"data-patch-pin-layer":"",style:{opacity:v?1:0,transition:m||!v?void 0:"opacity 0.2s cubic-bezier(0.22, 0.61, 0.36, 1)",pointerEvents:v?void 0:"none"},children:[jsx(AnimatePresence,{initial:false,children:g.map(w=>{let T=b.get(w.id);if(T?.kind==="detached")return null;let P=Js(w),k=!o&&!!n?.clientUserId&&w.payload.authorRole==="client"&&w.payload.authorId===n.clientUserId,D=o?Ao(w):null,H=T?ot(T.position,d.getOverlayViewport()):"right";return jsx(Cr,{ref:C=>{C?(R.current.set(w.id,C),T&&tr(C,d,T.position)):R.current.delete(w.id);},avatarSrc:P.image,generatedSeed:k?ee:P.generatedSeed,avatarAlt:P.name??"",resolved:w.status==="resolved",attention:D,pointSide:H,ariaLabel:`Annotation by ${w.authorName??"someone"}`,onClick:()=>be(w.id),pinId:w.id},w.id)})}),jsx(AnimatePresence,{initial:false,children:y.map(w=>{let T=d.targetPointToOverlay({viewportX:w.viewportX,viewportY:w.viewportY});return jsx(Cr,{ref:P=>{P?(I.current.set(w.tempId,P),tr(P,d,T)):I.current.delete(w.tempId);},avatarSrc:oe,generatedSeed:G,avatarAlt:pe??"",resolved:false,pointSide:ot(T,d.getOverlayViewport()),ephemeral:true},w.tempId)})})]})}function Js(e){let t=e.authorAvatarSeed??e.payload.authorId??(e.authorName?`annotation-author:${e.authorName}`:null);if(e.authorImage||t||e.authorName)return {name:e.authorName,image:e.authorImage??null,generatedSeed:t??e.id,key:e.payload.authorId??e.authorName??e.id};let r=e.thread.find(n=>n.authorImage||n.authorId||n.authorName);if(r){let n=r.authorAvatarSeed??r.authorId??(r.authorName?`thread-author:${r.authorName}`:null);return {name:r.authorName,image:r.authorImage??null,generatedSeed:n??e.id,key:r.authorId??r.authorName??e.id}}return {name:e.authorName,image:e.authorImage??null,generatedSeed:e.id,key:e.id}}var nl=5e3;function Mo(){let e=tt(),t=re(),r=xe(),n=Oe(),o=ce(),s=useReducedMotion(),i=e.pendingFocus,a=useRef(null),l=useCallback(()=>{a.current!==null&&(window.clearTimeout(a.current),a.current=null);},[]);return useEffect(()=>{if(!i)return;if(ae(window.location.href)!==ae(i.url)){e.clearFocus();return}if(n.dockOpen||n.setDockOpen(true),t.activeViewport!==i.viewport){t.setActiveViewport(i.viewport);return}if(!t.annotationsReady)return;let c=t.annotations.find(p=>p.id===i.id);if(!c){a.current===null&&(a.current=window.setTimeout(()=>{a.current=null,e.clearFocus();},nl));return}l();let d=c.payload.coordinates?.documentY;if(typeof d=="number"){let p=o.getTargetViewport().height;o.targetWindow.scrollTo({top:Math.max(0,d-p/3),behavior:s?"auto":"smooth"});}r.openExisting(i.id),e.clearFocus();},[i,t,n,o,s,r,e,l]),useEffect(()=>()=>l(),[l]),null}var _o=`/*! tailwindcss v4.2.4 | MIT License | https://tailwindcss.com */
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(`,
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 */
5
5
  @layer properties;
6
6
  @layer theme, base, components, utilities;
7
7
  @layer theme {
@@ -28,6 +28,7 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
28
28
  --radius-xl: 1rem;
29
29
  --ease-out: cubic-bezier(0.22, 0.61, 0.36, 1);
30
30
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
31
+ --animate-spin: spin 1s linear infinite;
31
32
  --default-transition-duration: 150ms;
32
33
  --default-transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
33
34
  --default-font-family: var(--font-sans);
@@ -247,21 +248,36 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
247
248
  .start {
248
249
  inset-inline-start: var(--spacing);
249
250
  }
251
+ .end {
252
+ inset-inline-end: var(--spacing);
253
+ }
250
254
  .-top-0\\.5 {
251
255
  top: calc(var(--spacing) * -0.5);
252
256
  }
253
257
  .-top-1 {
254
258
  top: calc(var(--spacing) * -1);
255
259
  }
260
+ .-top-1\\.5 {
261
+ top: calc(var(--spacing) * -1.5);
262
+ }
256
263
  .-top-\\[38px\\] {
257
264
  top: calc(38px * -1);
258
265
  }
259
266
  .top-0 {
260
267
  top: calc(var(--spacing) * 0);
261
268
  }
269
+ .top-1\\/2 {
270
+ top: calc(1 / 2 * 100%);
271
+ }
272
+ .top-4 {
273
+ top: calc(var(--spacing) * 4);
274
+ }
262
275
  .top-\\[-5px\\] {
263
276
  top: -5px;
264
277
  }
278
+ .top-\\[calc\\(100\\%\\+6px\\)\\] {
279
+ top: calc(100% + 6px);
280
+ }
265
281
  .top-\\[calc\\(100\\%\\+8px\\)\\] {
266
282
  top: calc(100% + 8px);
267
283
  }
@@ -274,9 +290,15 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
274
290
  .-right-1 {
275
291
  right: calc(var(--spacing) * -1);
276
292
  }
293
+ .-right-1\\.5 {
294
+ right: calc(var(--spacing) * -1.5);
295
+ }
277
296
  .right-0 {
278
297
  right: calc(var(--spacing) * 0);
279
298
  }
299
+ .right-4 {
300
+ right: calc(var(--spacing) * 4);
301
+ }
280
302
  .right-5 {
281
303
  right: calc(var(--spacing) * 5);
282
304
  }
@@ -289,6 +311,9 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
289
311
  .-bottom-1 {
290
312
  bottom: calc(var(--spacing) * -1);
291
313
  }
314
+ .bottom-4 {
315
+ bottom: calc(var(--spacing) * 4);
316
+ }
292
317
  .bottom-5 {
293
318
  bottom: calc(var(--spacing) * 5);
294
319
  }
@@ -304,6 +329,9 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
304
329
  .bottom-\\[72px\\] {
305
330
  bottom: 72px;
306
331
  }
332
+ .bottom-\\[calc\\(100\\%\\+6px\\)\\] {
333
+ bottom: calc(100% + 6px);
334
+ }
307
335
  .bottom-\\[calc\\(100\\%\\+8px\\)\\] {
308
336
  bottom: calc(100% + 8px);
309
337
  }
@@ -319,6 +347,9 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
319
347
  .left-1\\/2 {
320
348
  left: calc(1 / 2 * 100%);
321
349
  }
350
+ .left-4 {
351
+ left: calc(var(--spacing) * 4);
352
+ }
322
353
  .left-6 {
323
354
  left: calc(var(--spacing) * 6);
324
355
  }
@@ -358,6 +389,9 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
358
389
  .z-\\[2147483647\\] {
359
390
  z-index: 2147483647;
360
391
  }
392
+ .mx-2 {
393
+ margin-inline: calc(var(--spacing) * 2);
394
+ }
361
395
  .my-3 {
362
396
  margin-block: calc(var(--spacing) * 3);
363
397
  }
@@ -370,15 +404,24 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
370
404
  .mt-1 {
371
405
  margin-top: calc(var(--spacing) * 1);
372
406
  }
407
+ .mt-1\\.5 {
408
+ margin-top: calc(var(--spacing) * 1.5);
409
+ }
373
410
  .mt-px {
374
411
  margin-top: 1px;
375
412
  }
376
413
  .mb-1 {
377
414
  margin-bottom: calc(var(--spacing) * 1);
378
415
  }
416
+ .mb-2 {
417
+ margin-bottom: calc(var(--spacing) * 2);
418
+ }
379
419
  .ml-0\\.5 {
380
420
  margin-left: calc(var(--spacing) * 0.5);
381
421
  }
422
+ .ml-1\\.5 {
423
+ margin-left: calc(var(--spacing) * 1.5);
424
+ }
382
425
  .block {
383
426
  display: block;
384
427
  }
@@ -401,6 +444,10 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
401
444
  width: calc(var(--spacing) * 2);
402
445
  height: calc(var(--spacing) * 2);
403
446
  }
447
+ .size-2\\.5 {
448
+ width: calc(var(--spacing) * 2.5);
449
+ height: calc(var(--spacing) * 2.5);
450
+ }
404
451
  .size-3\\.5 {
405
452
  width: calc(var(--spacing) * 3.5);
406
453
  height: calc(var(--spacing) * 3.5);
@@ -417,6 +464,18 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
417
464
  width: calc(var(--spacing) * 8);
418
465
  height: calc(var(--spacing) * 8);
419
466
  }
467
+ .size-9 {
468
+ width: calc(var(--spacing) * 9);
469
+ height: calc(var(--spacing) * 9);
470
+ }
471
+ .size-14 {
472
+ width: calc(var(--spacing) * 14);
473
+ height: calc(var(--spacing) * 14);
474
+ }
475
+ .size-20 {
476
+ width: calc(var(--spacing) * 20);
477
+ height: calc(var(--spacing) * 20);
478
+ }
420
479
  .size-\\[7px\\] {
421
480
  width: 7px;
422
481
  height: 7px;
@@ -429,6 +488,10 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
429
488
  width: 14px;
430
489
  height: 14px;
431
490
  }
491
+ .size-\\[18px\\] {
492
+ width: 18px;
493
+ height: 18px;
494
+ }
432
495
  .size-\\[22px\\] {
433
496
  width: 22px;
434
497
  height: 22px;
@@ -459,9 +522,18 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
459
522
  .h-\\[18px\\] {
460
523
  height: 18px;
461
524
  }
525
+ .h-full {
526
+ height: 100%;
527
+ }
462
528
  .h-px {
463
529
  height: 1px;
464
530
  }
531
+ .max-h-40 {
532
+ max-height: calc(var(--spacing) * 40);
533
+ }
534
+ .max-h-\\[86vh\\] {
535
+ max-height: 86vh;
536
+ }
465
537
  .max-h-\\[min\\(480px\\,calc\\(100vh-120px\\)\\)\\] {
466
538
  max-height: min(480px, calc(100vh - 120px));
467
539
  }
@@ -492,6 +564,12 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
492
564
  .w-px {
493
565
  width: 1px;
494
566
  }
567
+ .max-w-\\[92vw\\] {
568
+ max-width: 92vw;
569
+ }
570
+ .max-w-\\[230px\\] {
571
+ max-width: 230px;
572
+ }
495
573
  .max-w-\\[280px\\] {
496
574
  max-width: 280px;
497
575
  }
@@ -532,6 +610,10 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
532
610
  --tw-translate-x: calc(calc(1 / 2 * 100%) * -1);
533
611
  translate: var(--tw-translate-x) var(--tw-translate-y);
534
612
  }
613
+ .-translate-y-1\\/2 {
614
+ --tw-translate-y: calc(calc(1 / 2 * 100%) * -1);
615
+ translate: var(--tw-translate-x) var(--tw-translate-y);
616
+ }
535
617
  .scale-50 {
536
618
  --tw-scale-x: 50%;
537
619
  --tw-scale-y: 50%;
@@ -550,6 +632,9 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
550
632
  .transform {
551
633
  transform: var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,);
552
634
  }
635
+ .animate-spin {
636
+ animation: var(--animate-spin);
637
+ }
553
638
  .cursor-default {
554
639
  cursor: default;
555
640
  }
@@ -559,6 +644,9 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
559
644
  .cursor-pointer {
560
645
  cursor: pointer;
561
646
  }
647
+ .cursor-zoom-in {
648
+ cursor: zoom-in;
649
+ }
562
650
  .resize {
563
651
  resize: both;
564
652
  }
@@ -571,6 +659,9 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
571
659
  .flex-col {
572
660
  flex-direction: column;
573
661
  }
662
+ .flex-wrap {
663
+ flex-wrap: wrap;
664
+ }
574
665
  .place-items-center {
575
666
  place-items: center;
576
667
  }
@@ -645,6 +736,9 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
645
736
  .rounded-\\[2px\\] {
646
737
  border-radius: 2px;
647
738
  }
739
+ .rounded-\\[3px\\] {
740
+ border-radius: 3px;
741
+ }
648
742
  .rounded-\\[5px\\] {
649
743
  border-radius: 5px;
650
744
  }
@@ -753,6 +847,15 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
753
847
  border-color: color-mix(in oklab, var(--color-white) 30%, transparent);
754
848
  }
755
849
  }
850
+ .border-white\\/40 {
851
+ border-color: color-mix(in srgb, #fff 40%, transparent);
852
+ @supports (color: color-mix(in lab, red, red)) {
853
+ border-color: color-mix(in oklab, var(--color-white) 40%, transparent);
854
+ }
855
+ }
856
+ .border-t-white {
857
+ border-top-color: var(--color-white);
858
+ }
756
859
  .bg-amber-500\\/15 {
757
860
  background-color: color-mix(in srgb, oklch(76.9% 0.188 70.08) 15%, transparent);
758
861
  @supports (color: color-mix(in lab, red, red)) {
@@ -783,6 +886,18 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
783
886
  background-color: color-mix(in oklab, var(--color-black) 25%, transparent);
784
887
  }
785
888
  }
889
+ .bg-black\\/28 {
890
+ background-color: color-mix(in srgb, #000 28%, transparent);
891
+ @supports (color: color-mix(in lab, red, red)) {
892
+ background-color: color-mix(in oklab, var(--color-black) 28%, transparent);
893
+ }
894
+ }
895
+ .bg-black\\/78 {
896
+ background-color: color-mix(in srgb, #000 78%, transparent);
897
+ @supports (color: color-mix(in lab, red, red)) {
898
+ background-color: color-mix(in oklab, var(--color-black) 78%, transparent);
899
+ }
900
+ }
786
901
  .bg-black\\/\\[0\\.03\\] {
787
902
  background-color: color-mix(in srgb, #000 3%, transparent);
788
903
  @supports (color: color-mix(in lab, red, red)) {
@@ -816,6 +931,12 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
816
931
  .bg-brand-tint {
817
932
  background-color: var(--color-brand-tint);
818
933
  }
934
+ .bg-brand\\/10 {
935
+ background-color: color-mix(in srgb, #0287FE 10%, transparent);
936
+ @supports (color: color-mix(in lab, red, red)) {
937
+ background-color: color-mix(in oklab, var(--color-brand) 10%, transparent);
938
+ }
939
+ }
819
940
  .bg-brand\\/15 {
820
941
  background-color: color-mix(in srgb, #0287FE 15%, transparent);
821
942
  @supports (color: color-mix(in lab, red, red)) {
@@ -834,6 +955,12 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
834
955
  .bg-foreground {
835
956
  background-color: var(--color-foreground);
836
957
  }
958
+ .bg-foreground\\/90 {
959
+ background-color: color-mix(in srgb, oklch(0.19 0.005 265) 90%, transparent);
960
+ @supports (color: color-mix(in lab, red, red)) {
961
+ background-color: color-mix(in oklab, var(--color-foreground) 90%, transparent);
962
+ }
963
+ }
837
964
  .bg-muted-foreground {
838
965
  background-color: var(--color-muted-foreground);
839
966
  }
@@ -870,6 +997,12 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
870
997
  background-color: color-mix(in oklab, var(--color-white) 12%, transparent);
871
998
  }
872
999
  }
1000
+ .bg-white\\/16 {
1001
+ background-color: color-mix(in srgb, #fff 16%, transparent);
1002
+ @supports (color: color-mix(in lab, red, red)) {
1003
+ background-color: color-mix(in oklab, var(--color-white) 16%, transparent);
1004
+ }
1005
+ }
873
1006
  .bg-white\\/\\[0\\.06\\] {
874
1007
  background-color: color-mix(in srgb, #fff 6%, transparent);
875
1008
  @supports (color: color-mix(in lab, red, red)) {
@@ -882,6 +1015,9 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
882
1015
  background-color: color-mix(in oklab, var(--color-white) 8%, transparent);
883
1016
  }
884
1017
  }
1018
+ .object-contain {
1019
+ object-fit: contain;
1020
+ }
885
1021
  .object-cover {
886
1022
  object-fit: cover;
887
1023
  }
@@ -930,6 +1066,9 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
930
1066
  .px-5 {
931
1067
  padding-inline: calc(var(--spacing) * 5);
932
1068
  }
1069
+ .py-0\\.5 {
1070
+ padding-block: calc(var(--spacing) * 0.5);
1071
+ }
933
1072
  .py-1 {
934
1073
  padding-block: calc(var(--spacing) * 1);
935
1074
  }
@@ -1149,6 +1288,10 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
1149
1288
  .lowercase {
1150
1289
  text-transform: lowercase;
1151
1290
  }
1291
+ .tabular-nums {
1292
+ --tw-numeric-spacing: tabular-nums;
1293
+ font-variant-numeric: var(--tw-ordinal,) var(--tw-slashed-zero,) var(--tw-numeric-figure,) var(--tw-numeric-spacing,) var(--tw-numeric-fraction,);
1294
+ }
1152
1295
  .line-through {
1153
1296
  text-decoration-line: line-through;
1154
1297
  }
@@ -1158,9 +1301,15 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
1158
1301
  .opacity-0 {
1159
1302
  opacity: 0%;
1160
1303
  }
1304
+ .opacity-40 {
1305
+ opacity: 40%;
1306
+ }
1161
1307
  .opacity-60 {
1162
1308
  opacity: 60%;
1163
1309
  }
1310
+ .opacity-70 {
1311
+ opacity: 70%;
1312
+ }
1164
1313
  .opacity-80 {
1165
1314
  opacity: 80%;
1166
1315
  }
@@ -1175,10 +1324,22 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
1175
1324
  --tw-shadow: 0 0 0 1px var(--tw-shadow-color, rgba(0,0,0,0.06));
1176
1325
  box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
1177
1326
  }
1327
+ .shadow-\\[0_0_0_1px_rgba\\(255\\,255\\,255\\,0\\.55\\)\\] {
1328
+ --tw-shadow: 0 0 0 1px var(--tw-shadow-color, rgba(255,255,255,0.55));
1329
+ box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
1330
+ }
1178
1331
  .shadow-\\[0_1px_3px_rgba\\(0\\,0\\,0\\,0\\.3\\)\\] {
1179
1332
  --tw-shadow: 0 1px 3px var(--tw-shadow-color, rgba(0,0,0,0.3));
1180
1333
  box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
1181
1334
  }
1335
+ .shadow-\\[0_1px_4px_rgba\\(0\\,0\\,0\\,0\\.3\\)\\] {
1336
+ --tw-shadow: 0 1px 4px var(--tw-shadow-color, rgba(0,0,0,0.3));
1337
+ box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
1338
+ }
1339
+ .shadow-\\[0_3px_8px_-3px_rgba\\(0\\,0\\,0\\,0\\.3\\)\\] {
1340
+ --tw-shadow: 0 3px 8px -3px var(--tw-shadow-color, rgba(0,0,0,0.3));
1341
+ box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
1342
+ }
1182
1343
  .shadow-\\[0_6px_12px_-5px_rgba\\(0\\,0\\,0\\,0\\.16\\)\\] {
1183
1344
  --tw-shadow: 0 6px 12px -5px var(--tw-shadow-color, rgba(0,0,0,0.16));
1184
1345
  box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
@@ -1187,6 +1348,10 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
1187
1348
  --tw-shadow: 0 10px 30px -10px var(--tw-shadow-color, rgba(0,0,0,0.45)), 0 3px 8px -3px var(--tw-shadow-color, rgba(0,0,0,0.3));
1188
1349
  box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
1189
1350
  }
1351
+ .shadow-\\[0_10px_30px_-10px_rgba\\(0\\,0\\,0\\,0\\.45\\)\\] {
1352
+ --tw-shadow: 0 10px 30px -10px var(--tw-shadow-color, rgba(0,0,0,0.45));
1353
+ box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
1354
+ }
1190
1355
  .shadow-\\[0_18px_44px_-14px_rgba\\(0\\,0\\,0\\,0\\.5\\)\\,0_6px_14px_-6px_rgba\\(0\\,0\\,0\\,0\\.45\\)\\] {
1191
1356
  --tw-shadow: 0 18px 44px -14px var(--tw-shadow-color, rgba(0,0,0,0.5)), 0 6px 14px -6px var(--tw-shadow-color, rgba(0,0,0,0.45));
1192
1357
  box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
@@ -1199,6 +1364,10 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
1199
1364
  --tw-shadow: 0 20px 56px -16px var(--tw-shadow-color, rgba(0,0,0,0.2)), 0 8px 18px -6px var(--tw-shadow-color, rgba(0,0,0,0.08));
1200
1365
  box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
1201
1366
  }
1367
+ .shadow-\\[0_32px_80px_-24px_rgba\\(0\\,0\\,0\\,0\\.6\\)\\] {
1368
+ --tw-shadow: 0 32px 80px -24px var(--tw-shadow-color, rgba(0,0,0,0.6));
1369
+ box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
1370
+ }
1202
1371
  .shadow-dialog {
1203
1372
  --tw-shadow: 0 12px 32px -8px var(--tw-shadow-color, oklch(0 0 0 / 0.12)), 0 4px 12px -4px var(--tw-shadow-color, oklch(0 0 0 / 0.06));
1204
1373
  box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
@@ -1213,6 +1382,18 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
1213
1382
  --tw-ring-color: color-mix(in oklab, var(--color-black) 6%, transparent);
1214
1383
  }
1215
1384
  }
1385
+ .ring-black\\/8 {
1386
+ --tw-ring-color: color-mix(in srgb, #000 8%, transparent);
1387
+ @supports (color: color-mix(in lab, red, red)) {
1388
+ --tw-ring-color: color-mix(in oklab, var(--color-black) 8%, transparent);
1389
+ }
1390
+ }
1391
+ .ring-destructive\\/60 {
1392
+ --tw-ring-color: color-mix(in srgb, oklch(0.55 0.2 27) 60%, transparent);
1393
+ @supports (color: color-mix(in lab, red, red)) {
1394
+ --tw-ring-color: color-mix(in oklab, var(--color-destructive) 60%, transparent);
1395
+ }
1396
+ }
1216
1397
  .ring-white\\/10 {
1217
1398
  --tw-ring-color: color-mix(in srgb, #fff 10%, transparent);
1218
1399
  @supports (color: color-mix(in lab, red, red)) {
@@ -1246,6 +1427,11 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
1246
1427
  transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
1247
1428
  transition-duration: var(--tw-duration, var(--default-transition-duration));
1248
1429
  }
1430
+ .transition-\\[filter\\] {
1431
+ transition-property: filter;
1432
+ transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
1433
+ transition-duration: var(--tw-duration, var(--default-transition-duration));
1434
+ }
1249
1435
  .transition-all {
1250
1436
  transition-property: all;
1251
1437
  transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
@@ -1273,11 +1459,27 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
1273
1459
  --tw-outline-style: none;
1274
1460
  outline-style: none;
1275
1461
  }
1462
+ .select-none {
1463
+ -webkit-user-select: none;
1464
+ user-select: none;
1465
+ }
1466
+ .group-focus-within\\/attachment\\:opacity-100 {
1467
+ &:is(:where(.group\\/attachment):focus-within *) {
1468
+ opacity: 100%;
1469
+ }
1470
+ }
1276
1471
  .group-focus-within\\/message\\:opacity-100 {
1277
1472
  &:is(:where(.group\\/message):focus-within *) {
1278
1473
  opacity: 100%;
1279
1474
  }
1280
1475
  }
1476
+ .group-hover\\/attachment\\:opacity-100 {
1477
+ &:is(:where(.group\\/attachment):hover *) {
1478
+ @media (hover: hover) {
1479
+ opacity: 100%;
1480
+ }
1481
+ }
1482
+ }
1281
1483
  .group-hover\\/message\\:opacity-100 {
1282
1484
  &:is(:where(.group\\/message):hover *) {
1283
1485
  @media (hover: hover) {
@@ -1370,6 +1572,16 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
1370
1572
  }
1371
1573
  }
1372
1574
  }
1575
+ .hover\\:bg-white\\/20 {
1576
+ &:hover {
1577
+ @media (hover: hover) {
1578
+ background-color: color-mix(in srgb, #fff 20%, transparent);
1579
+ @supports (color: color-mix(in lab, red, red)) {
1580
+ background-color: color-mix(in oklab, var(--color-white) 20%, transparent);
1581
+ }
1582
+ }
1583
+ }
1584
+ }
1373
1585
  .hover\\:bg-white\\/\\[0\\.08\\] {
1374
1586
  &:hover {
1375
1587
  @media (hover: hover) {
@@ -1404,6 +1616,14 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
1404
1616
  }
1405
1617
  }
1406
1618
  }
1619
+ .hover\\:brightness-\\[0\\.96\\] {
1620
+ &:hover {
1621
+ @media (hover: hover) {
1622
+ --tw-brightness: brightness(0.96);
1623
+ filter: var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,);
1624
+ }
1625
+ }
1626
+ }
1407
1627
  .focus\\:border-brand\\/50 {
1408
1628
  &:focus {
1409
1629
  border-color: color-mix(in srgb, #0287FE 50%, transparent);
@@ -1445,6 +1665,11 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
1445
1665
  border-color: var(--color-ring);
1446
1666
  }
1447
1667
  }
1668
+ .focus-visible\\:opacity-100 {
1669
+ &:focus-visible {
1670
+ opacity: 100%;
1671
+ }
1672
+ }
1448
1673
  .focus-visible\\:ring-2 {
1449
1674
  &:focus-visible {
1450
1675
  --tw-ring-shadow: var(--tw-ring-inset,) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color, currentcolor);
@@ -1784,6 +2009,26 @@ button:not(:disabled):not(.pkey):active {
1784
2009
  syntax: "*";
1785
2010
  inherits: false;
1786
2011
  }
2012
+ @property --tw-ordinal {
2013
+ syntax: "*";
2014
+ inherits: false;
2015
+ }
2016
+ @property --tw-slashed-zero {
2017
+ syntax: "*";
2018
+ inherits: false;
2019
+ }
2020
+ @property --tw-numeric-figure {
2021
+ syntax: "*";
2022
+ inherits: false;
2023
+ }
2024
+ @property --tw-numeric-spacing {
2025
+ syntax: "*";
2026
+ inherits: false;
2027
+ }
2028
+ @property --tw-numeric-fraction {
2029
+ syntax: "*";
2030
+ inherits: false;
2031
+ }
1787
2032
  @property --tw-shadow {
1788
2033
  syntax: "*";
1789
2034
  inherits: false;
@@ -1951,6 +2196,11 @@ button:not(:disabled):not(.pkey):active {
1951
2196
  syntax: "*";
1952
2197
  inherits: false;
1953
2198
  }
2199
+ @keyframes spin {
2200
+ to {
2201
+ transform: rotate(360deg);
2202
+ }
2203
+ }
1954
2204
  @layer properties {
1955
2205
  @supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))) {
1956
2206
  *, ::before, ::after, ::backdrop {
@@ -1969,6 +2219,11 @@ button:not(:disabled):not(.pkey):active {
1969
2219
  --tw-leading: initial;
1970
2220
  --tw-font-weight: initial;
1971
2221
  --tw-tracking: initial;
2222
+ --tw-ordinal: initial;
2223
+ --tw-slashed-zero: initial;
2224
+ --tw-numeric-figure: initial;
2225
+ --tw-numeric-spacing: initial;
2226
+ --tw-numeric-fraction: initial;
1972
2227
  --tw-shadow: 0 0 #0000;
1973
2228
  --tw-shadow-color: initial;
1974
2229
  --tw-shadow-alpha: 100%;
@@ -2011,16 +2266,19 @@ button:not(:disabled):not(.pkey):active {
2011
2266
  }
2012
2267
  }
2013
2268
  }
2014
- `;var Lo="patch-widget-root";function Do({children:e}){let[t,r]=useState(null),n=useRef(null);return useEffect(()=>{if(typeof document>"u")return;let o=document.querySelector(Lo);o||(o=document.createElement(Lo),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=_o,s.appendChild(a);}let i=s.querySelector("div[data-patch-mount]");return i||(i=document.createElement("div"),i.setAttribute("data-patch-mount",""),s.appendChild(i)),r(i),()=>{}},[]),t?createPortal(e,t):null}var ll=/[\s#.:[\]()>+~,\\]/;function cl(e){return !(!e||ll.test(e)||/^\d/.test(e))}function dl(e){let t=1,r=e.previousElementSibling,n=e.tagName;for(;r;)r.tagName===n&&t++,r=r.previousElementSibling;return t}function Oo(e,t,r){try{let n=e.querySelectorAll(t);return n.length===1&&n[0]===r}catch{return false}}function ul(e,t){return e.id&&cl(e.id)&&(!t||Oo(t,`#${e.id}`,e))?`#${e.id}`:`${e.tagName.toLowerCase()}:nth-of-type(${dl(e)})`}function zo(e,t){if(!e.tagName)return "";let r=e.ownerDocument??null,n=[],o=e,s=0;for(;o&&s<12;){let i=ul(o,r);if(n.unshift(i),i.startsWith("#"))break;let a=n.join(" > ");if(r&&Oo(r,a,e))return a;if(o.tagName.toLowerCase()==="html")break;o=o.parentElement,s++;}return n.join(" > ")}var pl=80,ml=500;function $o(e){return e!==null&&typeof e=="object"}function fl(e){return $o(e)?"return"in e||"type"in e||"elementType"in e||"_debugOwner"in e:false}function nr(e){if(typeof e=="function")return e.displayName||e.name||null;if(!$o(e))return null;let t=e.displayName;if(typeof t=="string"&&t)return t;let r=nr(e.render);if(r)return r;let n=nr(e.type);return n||null}function Fo(e){return e.replace(/\s+/g," ").trim()}function Vo(e,t){return e.length<=t?e:`${e.slice(0,t-1).trim()}\u2026`}function gl(e){let t=Fo(e).replace(/[<>]/g,"");return !t||/^[a-z]/.test(t)?null:Vo(t,pl)}function hl(e){let t=nr(e.elementType)??nr(e.type);return t?gl(t):null}function Ho(e){return Vo(Fo(e),ml)}function bl(e){let t=e.replace(/\\/g,"/");return t.includes("/.next/")||t.includes("/node_modules/next/")||t.includes("/node_modules/react/")||t.includes("/node_modules/react-dom/")||t.includes("/node_modules/react-router/")||t.includes("/node_modules/react-router-dom/")||t.includes("/node_modules/@remix-run/")||t.includes("/node_modules/.vite/")||/(^|\/)next\/dist\//.test(t)}function vl(e){let t=e.replace(/^webpack:\/\/[^/]+\//,"").replace(/^file:\/\//,"").replace(/\\/g,"/").replace(/\/\.\//g,"/").replace(/^\.\//,"");for(let n of ["/apps/","/packages/","/src/"]){let o=t.lastIndexOf(n);if(o>=0)return Ho(t.slice(o+1))}let r=t.split("/").filter(Boolean);return Ho(r.slice(-3).join("/"))}function xl(e){let t=e._debugSource?.fileName;return typeof t!="string"||!t.trim()||bl(t)?null:vl(t)}function wl(e){let t=e;for(let r of Object.getOwnPropertyNames(e)){if(!r.startsWith("__reactFiber$")&&!r.startsWith("__reactInternalInstance$"))continue;let n=t[r];if(fl(n))return n}return null}function Bo(e){let t=wl(e);if(!t)return null;let r=[],n=null,o=0;for(;t&&o<30;){let a=hl(t),l=a?yr(a):false;a&&!l&&r[r.length-1]!==a&&r.push(a),l||(n??=xl(t)),t=t.return??t._debugOwner??null,o+=1;}let s=r.length>0?jn(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 Wo=500;function yl(e){return e.length<=Wo?e:e.slice(0,Wo)}function kl(e){return {viewportX:e.viewportX,viewportY:e.viewportY,documentY:e.viewportY+e.scrollY,isFixed:false}}function Cl(e){return {x:e.x,y:e.y,width:e.width,height:e.height}}function Sl(e){let t={cssSelector:zo(e)},r=Ft(e);r&&(t.textSignature=r);let n=$t(e);return Object.keys(n).length>0&&(t.attributeSignature=n),t}function Uo(e){return vt(e.element,e.selectedText)}function Yo(e){let{target:t,click:r,comment:n,url:o}=e,s=t.element,i=t.rect,a=Cn(s),l=An(s),c=bt(s),d=Tn(s),p=Bo(s),u={comment:n,element:Ht(s),elementPath:Sn(s),targetLabel:vt(s,t.selectedText),timestamp:Date.now(),url:We(o),kind:"feedback",coordinates:kl(r),boundingBox:Cl(i),domHints:Sl(s)};return t.selectedText&&(u.selectedText=yl(t.selectedText)),l&&(u.nearbyText=l),c.length>0&&(u.cssClasses=c),d.length>0&&(u.nearbyElements=d),a&&(u.accessibility=a),p?.reactComponents&&(u.reactComponents=p.reactComponents),p?.sourceFile&&(u.sourceFile=p.sourceFile),u}async function At(e,t){return e.kind==="composer"?t.createAnnotation(e.payload):t.reply(e.annotationId,{content:e.content})}async function Go(e,t){return t.resolve(e)}async function Xo(e,t){return t.deleteAnnotation(e)}async function Ko(e,t){return t.deleteMessage(e.annotationId,e.messageId)}async function qo(e,t){return e.viewerKind!=="studio"?null:t.reopen(e.annotationId)}async function Zo(e,t){return e.viewerKind!=="studio"?null:t.kickoff(e.annotationId,{guidance:e.guidance})}async function jo(e,t){return t.postIdentity(e)}var ei=createContext(null),Qo=0;function _r(e){return Qo+=1,`${e}-${Date.now().toString(36)}-${Qo}`}function Lr(e){return e.deliveryStatus==="sending"||e.deliveryStatus==="failed"}function ti({annotation:e,draftTargetLabel:t,children:r}){let n=re(),o=xe(),s=ce(),[i,a]=useState(false),[l,c]=useState(null),[d,p]=useState(null),u=useRef(false),m=e?.thread??[],h=e?.latestRun??null,f=e?.status==="resolved",v=e?Lr(e):false,g=n.viewerKind,y=useCallback(()=>g==="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,g]),R=useMemo(()=>y(),[y]),I=!!e&&e.deliveryStatus!=="sending"&&e.deliveryStatus!=="failed"&&!!R.authorId&&e.payload.authorRole===R.role&&e.payload.authorId===R.authorId,V=useCallback(S=>{let _=y();return {id:_r("tmp-msg"),role:_.role,authorId:_.authorId,authorName:_.authorName,authorImage:_.authorImage,content:S,createdAt:new Date().toISOString(),deliveryStatus:"sending"}},[y]),N=useCallback(async S=>{if(u.current)return Promise.reject(new Error("busy"));u.current=true,a(true);try{return await S()}finally{u.current=false,a(false);}},[]),b=useCallback(async()=>{let S=o.draftText.trim();if(!S)return;if(e){if(f||Lr(e))return;let mt=V(S);o.setDraftText(""),n.updateAnnotation(e.id,Le=>({...Le,thread:[...Le.thread,mt]}));let Hr=await At({kind:"reply",annotationId:e.id,content:S},n.apiClient);if(Hr){n.updateAnnotation(e.id,Le=>({...Le,thread:Le.thread.map(Be=>Be.id===mt.id?{...Be,id:Hr.id,deliveryStatus:"sent"}:Be)})),n.refresh();return}n.updateAnnotation(e.id,Le=>({...Le,thread:Le.thread.map(Be=>Be.id===mt.id?{...Be,deliveryStatus:"failed"}:Be)}));return}let _=o.active;if(!_||_.kind!=="composer")return;let U=_.target,B={viewportX:_.anchor.viewportX,viewportY:_.anchor.viewportY,scrollY:_.anchor.documentY-_.anchor.viewportY},Y=s.getPageUrl(),ar=Br(n.activeViewport,s.getTargetViewport()),O=Yo({target:U,click:B,comment:S,url:Y});O.viewport=n.activeViewport,O.viewportSize=ar;let ie=y(),Te=_r("tmp-ann");n.applyAnnotationUpdate({id:Te,status:"pending",resolvedBy:null,resolvedAt:null,createdAt:new Date().toISOString(),authorName:ie.authorName,authorImage:ie.authorImage,payload:{...O,authorRole:ie.role,authorId:ie.authorId},thread:[],latestRun:null,deliveryStatus:"sending"}),o.setDraftText(""),o.openExisting(Te);let sr=await At({kind:"composer",payload:O},n.apiClient);if(sr){n.replaceAnnotationId(Te,sr.id),o.openExisting(sr.id),n.refresh();return}n.updateAnnotation(Te,mt=>({...mt,deliveryStatus:"failed"}));},[e,y,f,V,n,o,s]),L=useCallback(async S=>{if(!e||Lr(e))return;let _=e.thread.find(B=>B.id===S);if(!_||_.deliveryStatus!=="failed")return;n.updateAnnotation(e.id,B=>({...B,thread:B.thread.map(Y=>Y.id===S?{...Y,deliveryStatus:"sending"}:Y)}));let U=await At({kind:"reply",annotationId:e.id,content:_.content},n.apiClient);if(U){n.updateAnnotation(e.id,B=>({...B,thread:B.thread.map(Y=>Y.id===S?{...Y,id:U.id,deliveryStatus:"sent"}:Y)})),n.refresh();return}n.updateAnnotation(e.id,B=>({...B,thread:B.thread.map(Y=>Y.id===S?{...Y,deliveryStatus:"failed"}:Y)}));},[e,n]),Q=useCallback(async()=>{if(!e||e.deliveryStatus!=="failed")return;let S=e.id;n.updateAnnotation(S,U=>({...U,deliveryStatus:"sending"}));let _=await At({kind:"composer",payload:e.payload},n.apiClient);if(_){n.replaceAnnotationId(S,_.id),o.openExisting(_.id),n.refresh();return}n.updateAnnotation(S,U=>({...U,deliveryStatus:"failed"}));},[e,n,o]),j=useCallback(S=>!R.authorId||S.deliveryStatus&&S.deliveryStatus!=="sent"?false:S.role===R.role&&S.authorId===R.authorId,[R]),be=useCallback(()=>{I&&(c(null),p({kind:"annotation"}));},[I]),pe=useCallback(S=>{j(S)&&(c(null),p({kind:"message",messageId:S.id}));},[j]),oe=useCallback(()=>{c(null),p(null);},[]),ee=useCallback(async S=>{if(!e)return false;let _=e.thread;return N(async()=>(c(null),n.updateAnnotation(e.id,B=>({...B,thread:B.thread.filter(Y=>Y.id!==S)})),await Ko({annotationId:e.id,messageId:S},n.apiClient)?(n.refresh(),true):(n.updateAnnotation(e.id,B=>({...B,thread:_})),c("Couldn't delete message. Try again."),false)))},[e,n,N]),G=useCallback(async()=>!e||!I?false:N(async()=>(c(null),await Xo(e.id,n.apiClient)?(n.updateAnnotation(e.id,()=>null),o.forceClose(),n.refresh(),true):(c("Couldn't delete annotation. Try again."),false))),[e,I,n,o,N]),w=useCallback(async()=>{if(d)try{(d.kind==="annotation"?await G():await ee(d.messageId))&&p(null);}catch{c("Couldn't delete. Try again.");}},[d,G,ee]),T=useCallback(async()=>{e&&await N(async()=>{c(null);let S={status:e.status,resolvedBy:e.resolvedBy,resolvedAt:e.resolvedAt,optimisticAction:e.optimisticAction};if(n.updateAnnotation(e.id,U=>({...U,status:"resolved",resolvedBy:"dev",resolvedAt:new Date().toISOString(),optimisticAction:"resolve-pending"})),!await Go(e.id,n.apiClient)){n.updateAnnotation(e.id,U=>({...U,...S})),c("Couldn't resolve. Try again.");return}n.refresh();});},[e,n,N]),P=useCallback(async()=>{e&&await N(async()=>{c(null);let S={status:e.status,resolvedBy:e.resolvedBy,resolvedAt:e.resolvedAt,optimisticAction:e.optimisticAction};if(n.updateAnnotation(e.id,U=>({...U,status:"pending",resolvedBy:null,resolvedAt:null,optimisticAction:"reopen-pending"})),!await qo({annotationId:e.id,viewerKind:g},n.apiClient)){n.updateAnnotation(e.id,U=>({...U,...S})),c("Couldn't reopen. Try again.");return}n.refresh();});},[e,g,n,N]),k=useCallback(async S=>{e&&await N(async()=>{c(null);let _=e.latestRun,U=e.optimisticAction;n.updateAnnotation(e.id,Y=>({...Y,latestRun:{id:_r("tmp-run"),status:"queued",prUrl:null,createdAt:new Date().toISOString(),completedAt:null,prClosedUnmerged:false},optimisticAction:"run-pending"}));let B=await Zo({annotationId:e.id,viewerKind:g,guidance:S},n.apiClient);if(!B?.ok){n.updateAnnotation(e.id,Y=>({...Y,latestRun:_,optimisticAction:U})),c(B?.error??"Couldn't start Patch. Try again.");return}n.refresh();});},[e,g,n,N]),D=useCallback(async S=>{let _=await jo({...S,avatarSeed:n.clientAvatarSeed},n.apiClient);return _&&await n.setIdentity(_),_},[n]),C=g==="client"&&!n.identity&&m.length===0,te=!!e||m.length>0,me=n.agentRunReadiness?.ready??true,E=n.agentRunReadiness?.message??null,M=useCallback(()=>{if(o.draftText.trim().length>0){o.setConfirmDiscardOpen(true);return}o.forceClose();},[o]),$=e?Nn(e.payload):t||"annotation",q=e?.payload.viewport??n.activeViewport,Ae=n.studio?n.studio.name:n.identity?.name??null,fe=n.identity?.avatarSeed??n.clientAvatarSeed,Ve=n.studio?.userId??fe,Pt=n.studio?.image??null,Nt=n.studio?.userId??fe,ir=useMemo(()=>({state:{annotation:e,messages:m,runState:h,draftText:o.draftText,busy:i,actionError:l,confirmDiscardOpen:o.confirmDiscardOpen,confirmDelete:d,showDevFooter:g==="studio",agentRunReady:me,agentRunSetupMessage:E,needsIdentity:C,isResolved:f,initialMessageLocked:v,threadVisible:te,canDeleteAnnotation:I},actions:{setDraftText:o.setDraftText,submit:b,retryMessage:L,retryInitialMessage:Q,requestDeleteAnnotation:be,requestDeleteMessage:pe,canDeleteMessage:j,cancelDelete:oe,confirmDelete:w,markResolved:T,reopen:P,runPatch:k,setIdentity:D,attemptClose:o.attemptClose,requestClose:M,forceClose:o.forceClose,setConfirmDiscardOpen:o.setConfirmDiscardOpen},meta:{targetLabel:$,viewport:q,shakeNonce:o.shakeNonce,viewer:{kind:g,authorId:R.authorId,name:Ae,avatarKey:Ve,avatarSrc:Pt,generatedSeed:Nt}}}),[e,m,h,o.draftText,o.confirmDiscardOpen,o.setDraftText,o.attemptClose,o.forceClose,o.setConfirmDiscardOpen,o.shakeNonce,i,l,d,b,L,Q,be,pe,j,oe,w,T,P,k,D,g,me,E,C,f,v,te,I,M,$,q,R.authorId,Ae,Ve,Pt,Nt]);return jsx(ei.Provider,{value:ir,children:r})}function K(){let e=use(ei);if(!e)throw new Error("useThreadContext must be used inside <ThreadProvider>");return e}var Pl="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",Nl={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 Tt(e="brand",t){return A(Pl,Nl[e],t)}function ge({variant:e="brand",className:t,type:r="button",ref:n,...o}){return jsx("button",{ref:n,type:r,className:Tt(e,t),...o})}function ni(){let{state:e,actions:t}=K(),r=e.confirmDelete;if(!r)return null;let n=r.kind==="annotation",o=n?"Delete annotation?":"Delete message?",s=n?"This removes the annotation and its thread for everyone.":"This removes your message from the thread.",i=n?"Delete annotation":"Delete message";return jsx("div",{className:"absolute inset-0 z-40 flex items-start justify-end bg-black/25 p-3 backdrop-blur-[2px]",children:jsxs("div",{role:"dialog","aria-label":o,className:"patch-fade-in flex w-full max-w-[286px] flex-col gap-2 rounded-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}),e.actionError?jsx("div",{className:"text-[11px] font-medium text-destructive",children:e.actionError}):null,jsxs("div",{className:"mt-1 flex justify-end gap-2",children:[jsx(ge,{variant:"neutral",disabled:e.busy,onClick:t.cancelDelete,children:"Cancel"}),jsx(ge,{variant:"destructive",disabled:e.busy,onClick:t.confirmDelete,children:e.busy?"Deleting\u2026":i})]})]})})}function ii(){let{state:e,actions:t}=K();return e.confirmDiscardOpen?jsx("div",{className:"absolute inset-0 z-20 flex items-start justify-end bg-black/25 p-3 backdrop-blur-[2px]",children:jsxs("div",{role:"dialog","aria-label":"Discard draft",className:"patch-fade-in flex w-full max-w-[280px] flex-col gap-2 rounded-xl bg-popover p-4 shadow-dialog",children:[jsx("div",{className:"text-[13.5px] font-medium text-foreground",children:"Discard draft?"}),jsx("div",{className:"text-xs text-muted-foreground",children:"You'll lose what you've typed."}),jsxs("div",{className:"mt-1 flex justify-end gap-2",children:[jsx(ge,{variant:"neutral",onClick:()=>t.setConfirmDiscardOpen(false),children:"Keep editing"}),jsx(ge,{variant:"destructive",onClick:()=>t.forceClose(),children:"Discard"})]})]})}):null}var _l="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",Ll={sm:"size-7",md:"size-8"},Dl={default:"text-muted-foreground hover:bg-black/6 hover:text-foreground",warn:"bg-amber-500/15 text-amber-700"};function $e({size:e="sm",tone:t="default",className:r,type:n="button",ref:o,...s}){return jsx("button",{ref:o,type:n,className:A(_l,Ll[e],Dl[t],r),...s})}function ai(){let{state:e}=K();return !e.showDevFooter||!e.annotation?null:jsxs("div",{className:"-mt-[22px] flex flex-col gap-2 bg-neutral-100/50 px-3 pt-[2.125rem] pb-3",children:[jsxs("div",{className:"flex items-start justify-between gap-2",children:[jsx(zl,{}),jsx("div",{className:"flex shrink-0 items-center gap-1",children:jsx($l,{})})]}),e.actionError?jsx("div",{className:"px-1 text-[11px] font-medium text-destructive",children:e.actionError}):null]})}function zl(){let{state:e,actions:t}=K(),[r,n]=useState(false),[o,s]=useState(""),[i,a]=useState(false),l=e.runState,c=l?.status;if(e.annotation?.status==="resolved")return jsx("div",{className:"min-w-0 flex-1"});let p=c==="queued"||c==="running",u=c==="succeeded"&&!!l?.prUrl&&!l.prClosedUnmerged,m=l?"Run Patch again":"Run Patch",h=c==="failed"?"destructiveTint":"brand",f=!e.agentRunReady,v=async()=>{try{a(!0),await t.runPatch(o.trim()||void 0),s(""),n(!1);}finally{a(false);}};if(p)return jsx("div",{className:"min-w-0 flex-1",children:jsxs(ge,{variant:"brandTint",disabled:true,children:[jsx("span",{className:"patch-fade-in size-[7px] rounded-full bg-brand"}),"Patch is working\u2026"]})});if(u){let y=ao(l.prUrl);return jsx("div",{className:"min-w-0 flex-1",children:jsxs("a",{href:l.prUrl,target:"_blank",rel:"noopener noreferrer",className:Tt("brand","no-underline"),children:[jsx(z,{name:"pr",size:12}),y==="PR"?"View PR":`View PR ${y}`]})})}let g=jsxs(ge,{variant:h,disabled:e.busy||f,className:f?"opacity-60":void 0,onClick:()=>n(true),children:[jsx(Ct,{size:12})," ",m]});return jsxs("div",{className:"min-w-0 flex-1",children:[f&&e.agentRunSetupMessage?jsx(Ce,{text:e.agentRunSetupMessage,tone:"warning",children:g}):g,r?jsx(Hl,{title:m,guidance:o,submitting:i||e.busy,onGuidanceChange:s,onCancel:()=>n(false),onSubmit:v}):null]})}function Hl({title:e,guidance:t,submitting:r,onGuidanceChange:n,onCancel:o,onSubmit:s}){return jsxs("div",{className:"absolute inset-0 z-30 flex items-center justify-center p-4",children:[jsx("button",{type:"button","aria-label":"Close guidance",className:"absolute inset-0 cursor-default bg-black/25 backdrop-blur-[2px]",onClick:o}),jsxs("form",{role:"dialog","aria-label":e,className:"patch-fade-in relative flex w-full max-w-[280px] flex-col gap-3 rounded-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(Ct,{size:13})}),jsx("span",{className:"truncate text-[13.5px] font-medium text-foreground",children:e})]}),jsx($e,{size:"sm",title:"Close",onClick:o,children:jsx(z,{name:"x",size:12})})]}),jsxs("label",{className:"flex flex-col gap-1.5",children:[jsx("span",{className:"text-[12px] font-medium text-muted-foreground",children:"Guidance"}),jsx("textarea",{value:t,onChange:i=>n(i.target.value),maxLength:5e3,rows:3,placeholder:"Optional run guidance",className:"min-h-20 resize-none rounded-md border border-black/10 bg-black/[0.03] px-3 py-2 text-[13px] leading-[1.4] text-foreground outline-none placeholder:text-muted-foreground focus:border-brand/50 focus:ring-2 focus:ring-brand/20"})]}),jsxs("div",{className:"flex justify-end gap-2",children:[jsx(ge,{variant:"neutral",disabled:r,onClick:o,children:"Cancel"}),jsx(ge,{type:"submit",variant:"brand",disabled:r,children:r?"Starting\u2026":"Start run"})]})]})]})}function $l(){let{state:e,actions:t}=K();return e.annotation?e.annotation.status==="resolved"?jsxs(ge,{variant:"neutral",disabled:e.busy,onClick:()=>t.reopen(),children:[jsx(z,{name:"refresh",size:12}),"Reopen"]}):jsxs(ge,{variant:"neutral",disabled:e.busy,onClick:()=>t.markResolved(),children:[jsx(z,{name:"check",size:12}),"Resolve"]}):null}var Fl={desktop:"Desktop",tablet:"Tablet",mobile:"Mobile"};function Me(e,t){let r=e?.replace(/\s+/g," ").trim();return r?r.length<=t?r:`${r.slice(0,t-1)}...`:null}function si(e){let t=e?.trim();return t||null}function Ge(e){return Number.isInteger(e)?String(e):e.toFixed(1)}function Vl(e){let t=e.viewport??"desktop",r=Fl[t],n=e.viewportSize;return n?`${r} (${n.width}x${n.height})`:r}function Bl(e){let t=e.coordinates,r=[`viewport (${Ge(t.viewportX)}, ${Ge(t.viewportY)})`,`documentY ${Ge(t.documentY)}`];return t.isFixed&&r.push("fixed"),r.join(", ")}function Wl(e){let t=e.boundingBox;return t?`x ${Ge(t.x)}, y ${Ge(t.y)}, ${Ge(t.width)}x${Ge(t.height)}`:null}function Ul(e){let t=e.domHints?.attributeSignature;if(!t)return null;let r=Object.entries(t).slice(0,12).map(([n,o])=>`${n}="${Me(o,120)??""}"`);return r.length>0?r.join(", "):null}function Yl(e){let t=[`- Page: ${e.url}`,`- Element: ${Me(e.elementPath||e.element,500)??"unknown"}`,`- Viewport: ${Vl(e)}`,`- Anchor: ${Bl(e)}`],r=Me(e.targetLabel,160),n=Wl(e);return r&&t.push(`- Visible target: ${r}`),n&&t.push(`- Bounding box: ${n}`),`## Target
2015
- ${t.join(`
2016
- `)}`}function Gl(e){let t=Me(e.selectedText,1500);return t?`## Selected text
2017
- ${t}`:null}function Xl(e){let t=e.role==="studio"?"workspace":"client",r=Me(e.authorName,80),n=r?`${t} (${r})`:t,o=si(e.content)??"(empty)";return `- ${n}: ${o.replace(/\n/g,`
2018
- `)}`}function Kl(e){return e.length===0?null:`## Thread
2019
- ${e.map(Xl).join(`
2020
- `)}`}function ql(e){let t=[],r=Me(e.reactComponents,1e3),n=Me(e.sourceFile,500),o=Me(e.domHints?.cssSelector,500),s=Me(e.domHints?.textSignature,300),i=Ul(e),a=e.cssClasses?.slice(0,20).join(" ");return r&&t.push(`- React components: ${r}`),n&&t.push(`- Source file hint: ${n}`),o&&t.push(`- CSS selector: ${o}`),s&&t.push(`- Text signature: ${s}`),i&&t.push(`- Attributes: ${i}`),a&&t.push(`- CSS classes: ${a}`),t.length>0?`## Implementation hints
2021
- ${t.join(`
2022
- `)}`:null}function li(e){return ["Address this feedback in the repository.",`## Feedback
2023
- ${si(e.payload.comment)??"(no feedback text)"}`,Yl(e.payload),Gl(e.payload),Kl(e.thread),ql(e.payload)].filter(Boolean).join(`
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
2270
+ ${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
+ View these images before making changes \u2014 they usually show the exact visual issue being reported.
2275
+ ${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
+ ${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(`
2024
2282
 
2025
- `)}function di(){let{state:e,meta:t}=K(),r=e.annotation,n=we[t.viewport],o=r?.payload.selectedText;return jsxs("div",{className:"relative z-10 flex flex-col gap-2.5 border-b border-black/[0.07] bg-neutral-100/60 px-4 py-3",children:[jsxs("div",{className:"flex items-center justify-between gap-3",children:[jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[jsx("span",{title:t.targetLabel,className:"min-w-0 overflow-hidden text-ellipsis whitespace-nowrap text-[12.5px] font-medium text-foreground",children:t.targetLabel}),jsx(Ce,{text:Ke(t.viewport),placement:"bottom",children:jsx("span",{"data-patch-thread-viewport":t.viewport,role:"img","aria-label":Ke(t.viewport),className:"inline-flex shrink-0 items-center text-brand",children:jsx(z,{name:n.glyph,size:15,stroke:1.8})})})]}),jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.isResolved?jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-brand-green px-2 py-[3px] text-[11px] font-medium text-white",children:[jsx(z,{name:"check",size:10})," Resolved"]}):null,jsxs("div",{className:"ml-0.5 flex items-center gap-0.5",children:[e.showDevFooter&&r?jsx(Ql,{annotation:r}):null,jsx(tc,{}),jsx(ec,{})]})]})]}),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 Jl(e,t){try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}let r=t.createElement("textarea");r.value=e,r.setAttribute("readonly",""),r.style.position="fixed",r.style.top="-9999px",r.style.left="-9999px",t.body.appendChild(r),r.select();try{return t.execCommand("copy")}catch{return false}finally{r.remove();}}function Ql({annotation:e}){let[t,r]=useState(false),n=useRef(null);useEffect(()=>()=>{n.current&&clearTimeout(n.current);},[]);let o=async s=>{await Jl(li(e),s)&&(r(true),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>r(false),1500));};return jsx(Ce,{text:t?"Copied":"Copy agent prompt",placement:"bottom",children:jsx($e,{"aria-label":t?"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:A("absolute inset-0 grid place-items-center transition-all duration-200 ease-out",t?"scale-50 opacity-0 blur-[2px]":"scale-100 opacity-100 blur-0"),children:jsx(z,{name:"copy",size:14})}),jsx("span",{className:A("absolute inset-0 grid place-items-center text-brand-green transition-all duration-200 ease-out",t?"scale-100 opacity-100 blur-0":"scale-50 opacity-0 blur-[2px]"),children:jsx(z,{name:"check",size:13})})]})})})}function ec(){let{actions:e}=K();return jsx($e,{onClick:e.requestClose,title:"Close",children:jsx(z,{name:"x",size:14})})}function tc(){let{state:e,actions:t}=K(),[r,n]=useState(false);return e.canDeleteAnnotation?jsxs("div",{className:"relative",children:[jsx($e,{title:"Annotation actions","aria-label":"Annotation actions","aria-expanded":r,"aria-haspopup":"menu",onClick:()=>n(o=>!o),children:jsx(z,{name:"more",size:14})}),r?jsx("div",{role:"menu",className:"patch-fade-in absolute top-full right-0 z-[5] mt-1 min-w-40 rounded-xl bg-popover p-1 shadow-dialog ring-1 ring-black/6",children:jsxs("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-[12.5px] font-medium text-destructive hover:bg-destructive/10 focus:bg-destructive/10 focus:outline-none",onClick:()=>{n(false),t.requestDeleteAnnotation();},children:[jsx(z,{name:"trash",size:13}),"Delete annotation"]})}):null]}):null}function gi(){let{state:e,actions:t,meta:r}=K(),n=useRef(null),o=r.viewer.kind==="client"?r.viewer.generatedSeed:null,s=r.viewer.kind==="client"?r.viewer.authorId:null;return useEffect(()=>{let a=n.current;a&&(a.scrollTop=a.scrollHeight);}),e.threadVisible?jsxs("div",{ref:n,"data-patch-thread-scroller":"",className:A("flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto bg-white px-4 pt-3.5 pb-3",e.showDevFooter&&e.isResolved&&"relative z-[1] rounded-b-xl shadow-[0_6px_12px_-5px_rgba(0,0,0,0.16)]"),children:[e.annotation?jsx(mi,{name:e.annotation.authorName??"Someone",createdAt:e.annotation.createdAt,content:e.annotation.payload.comment,authorKey:e.annotation.payload.authorId??e.annotation.authorName??e.annotation.id,avatarSrc:e.annotation.authorImage,generatedSeed:e.annotation.payload.authorRole==="client"&&e.annotation.payload.authorId===s?o:e.annotation.authorAvatarSeed??e.annotation.payload.authorId??null,deliveryStatus:e.annotation.deliveryStatus,onRetry:e.annotation.deliveryStatus==="failed"?t.retryInitialMessage:void 0}):null,e.messages.map(a=>jsx(mi,{name:a.authorName??a.role,createdAt:a.createdAt,content:a.content,authorKey:a.authorId??a.authorName??a.role,avatarSrc:a.authorImage,generatedSeed:a.role==="client"&&a.authorId===s?o:a.authorAvatarSeed??a.authorId,deliveryStatus:a.deliveryStatus,canDelete:t.canDeleteMessage(a),onDelete:()=>t.requestDeleteMessage(a),onRetry:a.deliveryStatus==="failed"?()=>{t.retryMessage(a.id);}:void 0},a.id))]}):null}function mi(e){let t=rt(e.name),r=nt(e.authorKey),n=e.deliveryStatus==="failed";return jsxs("div",{className:"group/message flex gap-2.5",children:[jsx(ze,{initials:t,tint:r,src:e.avatarSrc,generatedSeed:e.generatedSeed,alt:e.name}),jsxs("div",{className:"relative min-w-0 flex-1 pr-8",children:[jsxs("div",{className:"flex items-baseline gap-1.5",children:[jsx("span",{className:"text-[12.5px] font-medium text-foreground",children:e.name}),jsx("span",{className:"text-[11px] text-muted-foreground",children:Kt(e.createdAt)})]}),e.canDelete&&e.onDelete?jsx(ic,{onDelete:e.onDelete}):null,jsx("p",{className:"mt-0.5 whitespace-pre-wrap text-[13px] leading-[1.45] text-foreground",children:e.content}),n?jsxs("div",{className:"mt-1 flex items-center gap-2 text-[11px] leading-none",children:[jsx("span",{className:"text-destructive",children:"Failed to send"}),e.onRetry?jsx("button",{type:"button",onClick:e.onRetry,className:"rounded-full bg-black/8 px-2 py-1 font-medium text-foreground transition-colors hover:bg-black/12",children:"Retry"}):null]}):null]})]})}var nc=44,oc=8;function ic({onDelete:e}){let[t,r]=useState(false),[n,o]=useState("down"),s=useRef(null),i=useCallback(()=>{let l=s.current,c=l?.closest("[data-patch-thread-scroller]");if(!l||!c){o("down");return}let d=l.getBoundingClientRect(),p=c.getBoundingClientRect(),u=p.bottom-d.bottom,m=d.top-p.top;o(u<nc+oc&&m>u?"up":"down");},[]),a=useCallback(()=>{r(l=>{let c=!l;return c&&i(),c});},[i]);return jsxs("div",{className:"absolute top-[-5px] right-0 opacity-0 transition-opacity group-focus-within/message:opacity-100 group-hover/message:opacity-100",children:[jsx($e,{ref:s,size:"sm",title:"Message actions","aria-label":"Message actions","aria-expanded":t,"aria-haspopup":"menu",onClick:a,children:jsx(z,{name:"more",size:14})}),t?jsx("div",{role:"menu",className:A("patch-fade-in absolute right-0 z-[5] min-w-36 rounded-xl bg-popover p-1 shadow-dialog ring-1 ring-black/6",n==="up"?"bottom-full mb-1":"top-full mt-1"),children:jsxs("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-[12.5px] font-medium text-destructive hover:bg-destructive/10 focus:bg-destructive/10 focus:outline-none",onClick:()=>{r(false),e();},children:[jsx(z,{name:"trash",size:13}),"Delete"]})}):null]})}var ac={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 hi({variant:e="default",className:t,ref:r,...n}){return jsx("textarea",{ref:r,className:A(ac[e],t),...n})}var dc=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,bi="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 vi(){let{actions:e}=K(),[t,r]=useState(""),[n,o]=useState(""),[s,i]=useState(null),[a,l]=useState(false),c=useRef(null);return useEffect(()=>{setTimeout(()=>c.current?.focus(),0);},[]),jsxs("form",{onSubmit:async p=>{p.preventDefault();let u=t.trim(),m=n.trim();if(!u){i("Name is required.");return}if(!dc.test(m)){i("Enter a valid email.");return}i(null),l(true);let h=await e.setIdentity({name:u,email:m});l(false),h||i("Could not save identity. Try again.");},className:"flex flex-col gap-2",children:[jsx("div",{className:"text-xs text-muted-foreground",children:"Tell us who you are so the team can reply."}),jsx("input",{ref:c,type:"text",placeholder:"Name",value:t,onChange:p=>r(p.target.value),className:bi}),jsx("input",{type:"email",placeholder:"Email",value:n,onChange:p=>o(p.target.value),className:bi}),s?jsx("div",{className:"text-xs text-destructive",children:s}):null,jsx("button",{type:"submit",disabled:a,className:A(Tt("brand"),"self-end",a&&"cursor-not-allowed opacity-60"),children:a?"Saving\u2026":"Continue"})]})}function wi(){let{state:e,actions:t,meta:r}=K(),n=useRef(null),[o,s]=useState(false);if(useEffect(()=>{e.needsIdentity||setTimeout(()=>n.current?.focus(),0);},[e.needsIdentity]),useEffect(()=>{let u=n.current;if(!u)return;u.style.height="0px";let m=Math.min(u.scrollHeight,140);u.style.height=`${m}px`,s(m>28);},[e.draftText]),e.isResolved||e.initialMessageLocked)return null;if(e.needsIdentity)return jsx("div",{className:A("bg-white px-4 py-3",e.threadVisible&&"border-t border-black/6"),children:jsx(vi,{})});let i=e.draftText.trim().length>0,a=r.viewer.name,l=rt(a),c=r.viewer.kind==="studio"?"var(--color-foreground)":nt(r.viewer.avatarKey),d=u=>{u.preventDefault(),t.submit();},p=u=>{u.key==="Enter"&&!u.shiftKey&&(u.preventDefault(),t.submit());};return jsx("form",{onSubmit:d,className:A("bg-white p-3",e.threadVisible&&"border-t border-black/6",e.showDevFooter&&"relative z-[1] rounded-b-xl shadow-[0_6px_12px_-5px_rgba(0,0,0,0.16)]"),children:jsxs("div",{className:A("flex items-end gap-2 bg-black/4 px-3 py-2.5 transition-colors",o?"rounded-xl":"rounded-full"),children:[jsx(ze,{initials:l,tint:c,src:r.viewer.avatarSrc,generatedSeed:r.viewer.generatedSeed,alt:a??"",className:"self-start"}),jsx(hi,{ref:n,variant:"bare",value:e.draftText,onChange:u=>t.setDraftText(u.target.value),onKeyDown:p,rows:1,placeholder:e.annotation?"Reply\u2026":"What should change?",style:{maxHeight:"140px"}}),jsx(fc,{enabled:i})]})})}function fc({enabled:e}){return jsx("button",{type:"submit",disabled:!e,"aria-label":"Send",className:A("grid size-7 shrink-0 place-items-center rounded-full text-white",e?"pkey pkey-brand":"bg-black/16 transition-colors"),children:jsx(z,{name:"arrow-up",size:13})})}var wc=[.4,0,.2,1],yc=[.22,.61,.36,1],kc={x:-8,y:-8,origin:"top left"},ki=200;function Ci(e,t,r){return Math.max(t,Math.min(r,e))}function Si(e,t,r){let n={x:e.x+e.width/2,y:e.y+e.height/2},o={x:t.x+t.width/2,y:t.y+r/2};return {x:Ci((n.x-o.x)*.08,-12,12),y:Ci((n.y-o.y)*.12,-10,10),origin:`${n.y<o.y?"top":"bottom"} ${n.x<o.x?"left":"right"}`}}function Cc(e,t){if(!t)return kc;let r=wt({anchor:t,popover:{width:332,height:ki},viewport:e.getOverlayViewport()});return Si(t,r,ki)}function Sc(e,t){return e.x===t.x&&e.y===t.y&&e.origin===t.origin}function Ai({getAnchorRect:e,initialAnchorRect:t,entryDelay:r=0,children:n}){let{actions:{attemptClose:o},meta:{shakeNonce:s}}=K(),i=ce(),a=useRef(null),[l,c]=useState(()=>Cc(i,t??e())),d=useCallback(()=>{let m=a.current;if(!m)return;let h=e();if(!h)return;let f=m.offsetHeight||200,v=wt({anchor:h,popover:{width:332,height:f},viewport:i.getOverlayViewport()});m.style.left=`${v.x}px`,m.style.top=`${v.y}px`,m.style.right="auto";let g=Si(h,v,f);c(y=>Sc(y,g)?y:g);},[e,i]);useLayoutEffect(()=>{d();}),useEffect(()=>{let m=null,h=()=>{m===null&&(m=i.overlayWindow.requestAnimationFrame(()=>{m=null,d();}));},f=new Set([i.targetWindow,i.overlayWindow]);for(let g of f)g.addEventListener("resize",h),g.addEventListener("scroll",h,{passive:true});let v=an(i.overlayWindow,h);return v.observe(i.overlayDocument.body),i.targetDocument.body!==i.overlayDocument.body&&v.observe(i.targetDocument.body),a.current&&v.observe(a.current),()=>{m!==null&&i.overlayWindow.cancelAnimationFrame(m);for(let g of f)g.removeEventListener("resize",h),g.removeEventListener("scroll",h);v.disconnect();}},[d,i]),useEffect(()=>{let m=v=>{io(v)||o();},h=v=>{v.key==="Escape"&&o();},f=new Set([i.targetDocument,i.overlayDocument]);for(let v of f)v.addEventListener("mousedown",m,true),v.addEventListener("keydown",h);return ()=>{for(let v of f)v.removeEventListener("mousedown",m,true),v.removeEventListener("keydown",h);}},[o,i]);let p=useRef(s);useEffect(()=>{if(s===p.current)return;p.current=s;let m=a.current;m&&(m.classList.remove("patch-shake"),m.offsetWidth,m.classList.add("patch-shake"));},[s]);let u={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:wc}},transition:{layout:{duration:.42,ease:yc}},onLayoutAnimationComplete:d,"data-patch-popover":"",role:"dialog","aria-label":"Annotation thread",className:"fixed z-[2147483646] flex flex-col overflow-hidden rounded-xl border border-black/6 bg-popover font-sans text-popover-foreground shadow-[0_20px_56px_-16px_rgba(0,0,0,0.2),0_8px_18px_-6px_rgba(0,0,0,0.08)]",style:u,children:n})}var le={Root:Ai,Header:di,Messages:gi,Reply:wi,DevFooter:ai,ConfirmDiscard:ii,ConfirmDelete:ni};function Ti({getAnchorRect:e,initialAnchorRect:t,entryDelay:r}){return jsxs(le.Root,{getAnchorRect:e,initialAnchorRect:t,entryDelay:r,children:[jsx(le.Header,{}),jsx(le.Messages,{}),jsx(le.Reply,{}),jsx(le.ConfirmDiscard,{}),jsx(le.ConfirmDelete,{})]})}function Ei({getAnchorRect:e,initialAnchorRect:t,entryDelay:r}){return jsxs(le.Root,{getAnchorRect:e,initialAnchorRect:t,entryDelay:r,children:[jsx(le.Header,{}),jsx(le.Messages,{}),jsx(le.Reply,{}),jsx(le.DevFooter,{}),jsx(le.ConfirmDiscard,{}),jsx(le.ConfirmDelete,{})]})}var Pc="data-patch-internal";function Pi(e,t,r){let n={viewportX:t,viewportY:r},o=ot(n,e.getOverlayViewport());return Xt(n,o)}function Nc(e,t){return e.overlayDocument.querySelector("patch-widget-root")?.shadowRoot?.querySelector(t)??null}function Mc(e,t){let r=Nc(e,`[data-patch-pin-id="${t}"]`);if(!r)return null;let n=r.getBoundingClientRect();return {x:n.x,y:n.y,width:n.width,height:n.height}}function _c(e,t){if(!t)return null;let r=So({payload:t.payload,doc:e.targetDocument,scrollY:e.getTargetScrollY(),viewport:e.getTargetViewport(),internalAttr:Pc}),n=e.targetPointToOverlay(r.position);return Pi(e,n.viewportX,n.viewportY)}function Ii(e,t,r){if(!t)return null;if(t.kind==="existing")return Mc(e,t.annotationId)??_c(e,r);let n=e.targetPointToOverlay({viewportX:t.anchor.viewportX,viewportY:t.anchor.documentY-e.getTargetScrollY()});return Pi(e,n.viewportX,n.viewportY)}function Ni(){let e=xe(),t=re(),r=ce(),n=e.active,o=useMemo(()=>!n||n.kind!=="existing"?null:t.annotations.find(p=>p.id===n.annotationId)??null,[n,t.annotations]),s=useCallback(()=>Ii(r,n,o),[n,o,r]),i=t.viewerKind==="studio"?Ei:Ti,a=n&&(n.kind==="composer"||!!o),l=n?.kind==="composer"?.04:0,c=n?.kind==="composer"?Uo(n.target):null,d=useMemo(()=>Ii(r,n,o),[n,o,r]);return jsx(AnimatePresence,{children:a?jsx(ti,{annotation:o,draftTargetLabel:c,children:jsx(i,{getAnchorRect:s,initialAnchorRect:d,entryDelay:l})},"active-popover"):null})}var Oc="https://app.usepatch.dev";function zc({children:e}){let{active:t}=re();return t?e:null}function Mi(e){let t=typeof window<"u"&&on(window),r=useMemo(()=>Xn({prop:e.projectToken,processEnv:qn(),importMetaEnv:Kn()}),[e.projectToken]),n=e.apiBase??Oc;return useEffect(()=>{r||console.warn(Gn);},[r]),t||!r?null:jsx(Do,{children:jsx(sn,{children:jsx(gn,{projectToken:r,apiBase:n,children:jsx(zc,{children:jsx(bn,{children:jsx(Yn,{children:jsx(Bn,{projectToken:r,children:jsxs(zn,{children:[jsx(Po,{}),jsx(Ni,{}),jsx(Mo,{}),jsx(xo,{})]})})})})})})})})}var Hc=Mi;
2026
- export{Mi as Patch,Hc as default};
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};