@usepatch/widget 0.4.1 → 0.6.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 +276 -15
  2. package/dist/index.js +276 -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,Component,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 br="patch:locationchange",Qr="__patchHistoryPatched";function fa(t){let e=t.history;if(e[Qr])return;e[Qr]=true;let r=()=>t.dispatchEvent(new Event(br)),{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 tn(t,e){fa(t);let r=()=>e();return t.addEventListener("popstate",r),t.addEventListener("hashchange",r),t.addEventListener(br,r),()=>{t.removeEventListener("popstate",r),t.removeEventListener("hashchange",r),t.removeEventListener(br,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"}},en=["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 rn(t,e){let r=Tt[t];return {width:r.width??e.width,height:r.height??e.height}}var ba=32,va=32,xa=3e3,an="cubic-bezier(0.16, 1, 0.3, 1)",Ve=[.22,.61,.36,1],sn=.3,ln=.5,wa=.34,ya=.5,ka=.24,Ca=.22,cn=.12,Aa=.42,dn=.2,Sa=200,Ta=260,Ea=70,Ra=180,Pa=260,Ia=8,Na=4,Ma="#d9d9dd",_a=30,La=["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-ba*2),o=Math.max(320,t.innerHeight-va*2);return Math.min(1,n/e,o/r)}function Da(t){try{return !!(t.contentWindow&&t.contentDocument?.body)}catch{return false}}function un({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||!Da(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);},xa);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"),Ea);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"),Ra);return ()=>r.clearTimeout(E)}case "reveal":{let E=r.setTimeout(()=>f("stable"),Pa);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:ka,ease:Ve},K=i?{duration:0}:{duration:Ca,ease:Ve,delay:dn*.5},k=i?{duration:0}:{duration:dn,ease:Ve},R=i?{duration:0}:{opacity:{duration:Aa,ease:Ve,delay:cn},scale:{type:"spring",bounce:wa,duration:ya,delay:cn},width:{type:"spring",bounce:sn,duration:ln},height:{type:"spring",bounce:sn,duration:ln}},M=(U?Ta:Sa)/1e3,A=i?void 0:`opacity ${M}s ${an}, filter ${M}s ${an}`,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:K},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:`${Na}px solid ${Ma}`,borderRadius:_a,boxShadow:La,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(${Ia}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(Oa,{visible:y})]})})}function Oa({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 fn=createContext(null),hn=createContext(null),bn="__patch_preview";function vn(){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 $a(t){let e=new URL(t.location.href);return e.searchParams.set(bn,"1"),e.toString()}function xn(t=window){try{return new URL(t.location.href).searchParams.get(bn)==="1"}catch{return false}}function Ba(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 wn(t,e){let r=t.ResizeObserver??ResizeObserver;return new r(e)}function yn({children:t}){let e=useMemo(()=>vn(),[]),[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:Ba(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?$a(e.targetWindow):"",[e]);return !h||!e?null:jsx(hn.Provider,{value:y,children:jsxs(fn.Provider,{value:h,children:[t,jsx(AnimatePresence,{onExitComplete:()=>u(false),children:p&&f?jsx(un,{src:T,viewport:v,overlayWindow:e.overlayWindow,onFrameElement:s,onReadyChange:a,onBlockedChange:c}):null})]})})}function mt(){let t=use(fn),e=useMemo(()=>vn(),[]);if(t)return t;if(e)return e;throw new Error("useTargetSurface must run in a browser document")}function ne(){let t=use(hn),[e,r]=useState("desktop"),n=useMemo(()=>({activeViewport:e,setActiveViewport:r,isPreviewing:false,previewReady:true,previewBlocked:false}),[e]);return t??n}var Wa="X-Patch-Client-Id",Ua="X-Patch-Client-Secret";function kt(t,e){return {...e?{"Content-Type":"application/json"}:{},Authorization:`Bearer ${t.token}`,...t.clientUserId?{[Wa]:t.clientUserId}:{},...t.clientSecret?{[Ua]:t.clientSecret}:{}}}async function Et(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 Ya(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 kn(t){return {async listAnnotations(e){let r=e?`?viewport=${encodeURIComponent(e)}`:"";return (await Et(`${t.apiBase}/api/widget/annotations${r}`,{method:"GET",credentials:"include",headers:kt(t,false)}))?.annotations??[]},async listRoster(){return (await Et(`${t.apiBase}/api/widget/roster`,{method:"GET",credentials:"include",headers:kt(t,false)}))?.entries??[]},async fetchMe(){try{let e=await fetch(`${t.apiBase}/api/widget/me`,{method:"GET",credentials:"include",headers:kt(t,!1)});if(e.status===401||e.status===403)return {status:"unauthorized"};if(!e.ok)return {status:"error"};let r=await e.text();return {status:"ok",me:r?JSON.parse(r):{}}}catch{return {status:"error"}}},async postIdentity(e){let r=await Et(`${t.apiBase}/api/widget/identity`,{method:"POST",credentials:"include",headers:kt(t,true),body:JSON.stringify(e)});if(!r)return null;let n=r.secret??t.clientSecret;return n?{clientUserId:r.id,name:r.name,email:r.email,avatarSeed:r.avatarSeed??r.id,secret:n}:null},async createAnnotation(e){return Et(`${t.apiBase}/api/widget/annotations`,{method:"POST",credentials:"include",headers:kt(t,true),body:JSON.stringify(e)})},async reply(e,r){return Et(`${t.apiBase}/api/widget/annotations/${e}/reply`,{method:"POST",credentials:"include",headers:kt(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 Et(`${t.apiBase}/api/widget/uploads?${n}`,{method:"POST",credentials:"include",headers:{...kt(t,false),"Content-Type":e.type},body:e}))?.attachment??null},async deleteAnnotation(e){return Et(`${t.apiBase}/api/widget/annotations/${e}`,{method:"DELETE",credentials:"include",headers:kt(t,false)})},async deleteMessage(e,r){return Et(`${t.apiBase}/api/widget/annotations/${e}/messages/${r}`,{method:"DELETE",credentials:"include",headers:kt(t,false)})},async kickoff(e,r){return Ya(`${t.apiBase}/api/widget/annotations/${e}/kickoff`,{method:"POST",credentials:"include",headers:kt(t,true),body:JSON.stringify(r)})},async resolve(e){return Et(`${t.apiBase}/api/widget/annotations/${e}/resolve`,{method:"POST",credentials:"include",headers:kt(t,true)})},async reopen(e){return Et(`${t.apiBase}/api/widget/annotations/${e}/reopen`,{method:"POST",credentials:"include",headers:kt(t,true)})},async reportAnchorStatuses(e){e.length!==0&&await Et(`${t.apiBase}/api/widget/anchor-report`,{method:"POST",credentials:"include",headers:kt(t,true),body:JSON.stringify({reports:e})});}}}var yr="patch.clientIdentity",Cn="patch.clientAvatarSeed";function kr(){if(typeof window>"u")return {};try{let t=window.localStorage.getItem(yr);if(!t)return {};let e=JSON.parse(t);return e&&typeof e=="object"?e:{}}catch{return {}}}function Cr(t){let e=kr()[t];return e?.secret?e:null}function Ar(t,e){if(!(typeof window>"u"))try{let r=kr();r[t]=e,window.localStorage.setItem(yr,JSON.stringify(r));}catch{}}function An(t){if(!(typeof window>"u"))try{let e=kr();delete e[t],window.localStorage.setItem(yr,JSON.stringify(e));}catch{}}function Ga(){if(typeof window>"u")return {};try{let t=window.localStorage.getItem(Cn);if(!t)return {};let e=JSON.parse(t);return e&&typeof e=="object"?e:{}}catch{return {}}}function wr(){let t=globalThis.crypto;return `client-avatar:${typeof t?.randomUUID=="function"?t.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}`}function Sn(t){if(typeof window>"u")return wr();try{let e=Ga(),r=e[t];if(r)return r;let n=wr();return e[t]=n,window.localStorage.setItem(Cn,JSON.stringify(e)),n}catch{return wr()}}var qa=2e4,En=createContext(null);function ja(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 Rn({projectToken:t,apiBase:e,children:r}){let n=mt(),{activeViewport:o,setActiveViewport:s}=ne(),[i,a]=useState(()=>typeof window>"u"?null:Cr(t)),[l]=useState(()=>typeof window>"u"?"client-avatar:ssr":Sn(t)),[c,d]=useState(null),[u,p]=useState("client"),[m,v]=useState(null),[f,b]=useState([]),[h,y]=useState(null),[T,x]=useState([]),[z,D]=useState(false),[g,I]=useState(null),U=useRef(g);U.current=g;let at=useRef(o);at.current=o;let pt=h===o,vt=useMemo(()=>kn({apiBase:e,token:t,clientUserId:i?.clientUserId,clientSecret:i?.secret}),[e,t,i?.clientUserId,i?.secret]),st=useRef(vt);st.current=vt;let Q=useRef(0),K=useCallback(async()=>{let P=o,W=++Q.current,_=await st.current.listAnnotations(P==="desktop"?void 0:P);if(W!==Q.current||P!==at.current)return;let G=n.getPageUrl(),wt=_.filter(yt=>ct(yt.payload.url)===G);b(yt=>ja(yt,wt)),y(P);},[o,n]),k=useRef(K);k.current=K,useEffect(()=>{let P=false;return (async()=>{let W=await st.current.fetchMe();if(P)return;if(W.status==="unauthorized"){I(false),D(true);return}let _=W.status==="ok"?W.me:null;if(_?.active===false){I(false),D(true);return}if(I(true),_?.studio)d(_.studio),p("studio"),v(_.agentRunReadiness??{ready:true,message:null});else if(d(null),p("client"),v(null),_?.client){let G=Cr(t);if(G?.secret){let wt={clientUserId:_.client.id,name:_.client.name,email:_.client.email,avatarSeed:_.client.avatarSeed,secret:G.secret};a(wt),Ar(t,wt);}}await k.current(),P||D(true);})(),()=>{P=true;}},[t]),useEffect(()=>{!z||!g||K();},[z,g,K]),useEffect(()=>{if(!g)return;let{overlayDocument:P,overlayWindow:W}=n,_=W.setInterval(()=>{P.visibilityState==="visible"&&K();},qa),G=()=>{P.visibilityState==="visible"&&K();};return P.addEventListener("visibilitychange",G),()=>{W.clearInterval(_),P.removeEventListener("visibilitychange",G);}},[g,K,n]),useEffect(()=>{if(g)return tn(n.targetWindow,()=>{let P=n.getPageUrl();b(W=>W.filter(_=>ct(_.payload.url)===P)),k.current();})},[g,n]);let R=useCallback(async P=>(Ar(t,P),a(P),P),[t]),M=useCallback(()=>{a(null),An(t);},[t]),A=useCallback(P=>{x(W=>[...W.filter(_=>_.tempId!==P.tempId),P]);},[]),H=useCallback(P=>{x(W=>W.filter(_=>_.tempId!==P));},[]),F=useCallback(P=>{b(W=>{let _=W.findIndex(wt=>wt.id===P.id);if(_===-1)return [...W,P];let G=W.slice();return G[_]=P,G});},[]),E=useCallback((P,W)=>{b(_=>{let G=false,wt=_.flatMap(yt=>{if(yt.id!==P)return [yt];G=true;let Ut=W(yt);return Ut?[Ut]:[]});return G?wt:_});},[]),tt=useCallback((P,W)=>{b(_=>_.map(G=>G.id===P?{...G,id:W,deliveryStatus:"sent"}:G));},[]),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:K,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,K,s,R,M,A,H,F,E,tt]);return jsx(En.Provider,{value:xt,children:r})}function rt(){let t=use(En);if(!t)throw new Error("useAnnotationsStore must be used inside <AnnotationsProvider>");return t}function Pn(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 Qa(t,e){return t.length<=e?t:`${t.slice(0,e-1).trim()}\u2026`}function In(t){return t.replace(/\s+/g," ").trim()}function Sr(t){return Ja.has(In(t))}function ts(t){return t.length<2||t.startsWith("_")?false:/^[A-Z]/.test(t)}function Nn(t){if(!t)return null;let e=[],r=t.matchAll(/<([^<>]+)>/g);for(let n of r){let o=In(n[1]??"");!o||Sr(o)||ts(o)&&e[e.length-1]!==o&&e.push(o);}return e.length===0?null:Qa(e.map(n=>`<${n}>`).join(" "),1e3)}var Mn="seed:";function Ye(t){return t?t.startsWith(Mn)?{url:null,seed:t.slice(Mn.length)||null}:/^https?:\/\//i.test(t)?{url:t,seed:null}:{url:null,seed:t}:{url:null,seed:null}}var Tr=[6,20,34,92,120,140,158,174,190,206,220,234,252,270,286,300,318,336,350],_n=[{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]}],Ln=Math.PI*2;function es(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 rs(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 q(t,e,r){return e+t()*(r-e)}function gt(t,e=3){let r=10**e;return Math.round(t*r)/r}function Dn(t,e,r){return `hsl(${gt((t%360+360)%360,1)} ${gt(e,1)}% ${gt(r,1)}%)`}function On(t){let e=es(t?.trim()||"patch-client"),r=rs(e),n=e.toString(36),o=(Tr[e%Tr.length]??Tr[0])+q(r,-10,10),s=r()<.5?-1:1,i=r()<.5?-1:1,a=o+i*q(r,52,116),l=o-i*q(r,26,66),c=o+s*q(r,12,38),d=Dn(o+s*q(r,0,14),q(r,80,92),q(r,44,54)),u=q(r,0,Ln),p=_n.map((m,v)=>{let b=(m.hue==="accent"?a:m.hue==="accent2"?l:m.hue==="near"?c:o)+q(r,-11,11),h=u+v/_n.length*Ln+q(r,-0.6,.6),y=q(r,m.reach[0],m.reach[1]),T=gt(.5+Math.cos(h)*y),x=gt(.5+Math.sin(h)*y),z=gt(q(r,0,180),1),D=gt(q(r,.62,1.5),3),g=gt(q(r,.62,1.5),3);return {id:`cav-${n}-${v}`,cx:T,cy:x,r:gt(q(r,m.r[0],m.r[1])),color:Dn(b,q(r,m.sat[0],m.sat[1]),q(r,m.light[0],m.light[1])),opacity:gt(q(r,m.opacity[0],m.opacity[1]),2),gradientTransform:`rotate(${z} ${T} ${x}) translate(${T} ${x}) scale(${D} ${g}) translate(${gt(-T)} ${gt(-x)})`}});return {id:n,background:d,spots:p,blur:gt(q(r,3.4,5.4),2),grain:gt(q(r,.09,.15),2)}}var zn=createContext(null);function Hn({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,I)=>{u.current=u.current.map(U=>U.localId===g?{...U,...I}:U),i(u.current);},[]),y=useCallback(g=>{let I=u.current.find(U=>U.localId===g);I&&URL.revokeObjectURL(I.previewUrl),u.current=u.current.filter(U=>U.localId!==g),i(u.current);},[]),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,D=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(zn.Provider,{value:D,children:t})}function ft(){let t=use(zn);if(!t)throw new Error("usePopoverStore must be used inside <PopoverProvider>");return t}var Bn=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"]),ls=new Set(["a","button","input","select","textarea"]),Vn={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,cs=1500,Fn=200,ds=5,us=10;function Wn(t){return Bn.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 ps(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 ms(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(ms).slice(0,us);return r.length>0?r:e.length>0?["container"]:[]}function Un(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=ls.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 gs(t){let e=t.tagName.toLowerCase(),r=Vn[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 fs(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 fs(t);if(e==="input"||e==="textarea"||e==="select")return gs(t);let r=Vn[e]??e,n=t.getAttribute("aria-label");if(n)return `${r} ${oe(zt(n,Xt))}`;if(e==="a"||e==="button"||Bn.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 Yn(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,cs)}function Gn(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,Fn)}return zt(n,Fn)}}function Xn(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>=ds))break;return r}var hs=["role","aria-label","name"],bs=10,$n=100;function Ke(t){let e={};for(let r of hs){let n=t.getAttribute(r);n!==null&&n!==""&&(e[r]=n.slice(0,$n));}for(let r of Array.from(t.attributes)){if(Object.keys(e).length>=bs)break;r.name.startsWith("data-")&&r.value!==""&&(e[r.name]=r.value.slice(0,$n));}return e}function qe(t){return ps(t)}function Kn(t){let e=t;for(;e&&e.nodeType!==1;)e=e.parentNode;return e}function qn(t,e){return t.closest(`[${e}]`)!==null}var vs=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"]),xs={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"},ws={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"},ys={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 Zn(t,e){let r=t.replace(/\s+/g," ").trim();return r.length<=e?r:`${r.slice(0,e-1).trim()}\u2026`}function ks(t){return `"${t}"`}function je(t){return (t.textContent??"").replace(/\s+/g," ").trim()}function jn(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}: ${ks(Zn(r,48))}`:t}function Cs(t){let e=t.trim(),r=e.match(/^(.+?)\s+"(.+)"$/);return r?{base:r[1]??e,text:r[2]}:{base:e}}function As(t){let e=t.toLowerCase().replace(/\[[\s\S]*$/,"").trim(),r=ys[e];if(r)return r;let n=t.match(/^[a-z][\w-]*/i)?.[0]?.toLowerCase();return n?/^h[1-6]$/.test(n)?"Heading":ws[n]??"Area":"Area"}function Ss(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",jn(n));if(t.tagName.toLowerCase()==="input"){let o=t.type||"text";if(o!=="text")return dt("Field",jn(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 Ss(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(vs.has(r))return dt("Text",je(t));let o=xs[r];return dt(o||"Area",n)}function Jn(t){if(t.targetLabel?.trim())return Zn(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=Cs(e.split(">").at(-1)??e);return dt(As(r.base),r.text)}var Qn="patch-capture-cursor-style";function Ts(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 Es(t,e){let r=t.targetDocument,n=r.getElementById(Qn);n&&n.remove();let o=r.createElement("style");return o.id=Qn,o.setAttribute(e,""),o.textContent=Ts(e),r.head.appendChild(o),o}function Er(t,e,r){let n=t.eventTargetElement(e);return n?n.closest(`[${r}]`)!==null:false}var ie=1.5,Rs="#0287FE",Ps="rgba(2, 135, 254, 0.032)";function Is(t){let e=t.split(" ")[0]??"",r=Number.parseFloat(e);return Number.isFinite(r)?Math.min(8,Math.max(3,r)):6}function Ns(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 ${Rs}`,background:Ps,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=`${Is(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 to(t){let{internalAttr:e,onClick:r,surface:n}=t,o=n.targetDocument,s=Es(n,e),i=Ns(n,e),a=false,l=v=>{let f=v;if(Er(n,f.target,e))return;let b=n.eventTargetElement(f.target);b&&Wn(b)||(f.preventDefault(),f.stopPropagation());},c=l,d=l,u=v=>{let f=v;Er(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(Er(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 eo(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=Kn(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 Os="data-patch-internal",no=createContext(null),ro=0;function zs(){return ro+=1,`tmp-${Date.now().toString(36)}-${ro}`}function oo({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=eo({clickTarget:T,selection:x}),D=zs(),g={viewportX:h.clientX,viewportY:h.clientY,documentY:h.clientY+n.getTargetScrollY()};d.current.addEphemeral({tempId:D,viewportX:g.viewportX,viewportY:g.viewportY,documentY:g.documentY}),c.current.openComposer({tempId:D,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=to({internalAttr:Os,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(no.Provider,{value:b,children:t})}function io(){let t=use(no);if(!t)throw new Error("useCaptureControls must be used inside <CaptureProvider>");return t}var Bs="patch:focus-intent";function Mr(t){return `${Bs}:${t}`}function Vs(t){try{let e=window.sessionStorage.getItem(Mr(t));if(!e)return null;window.sessionStorage.removeItem(Mr(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 Ws(t,e){try{window.sessionStorage.setItem(Mr(t),JSON.stringify(e));}catch{}}var lo=createContext(null);function Us(t){return t==="pending"||t==="acknowledged"}function co({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=Vs(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 I={id:g.id,url:g.url,viewport:g.viewport};if(ct(g.url)===ct(window.location.href)){p(I);return}Ws(t,I),window.location.assign(g.url);},[t]),y=useCallback(()=>p(null),[]),T=useMemo(()=>{let g=new Map;for(let I of s)g.set(I.id,I.status);return g},[s]),x=useMemo(()=>a.map(g=>{let I=T.get(g.id);return I&&I!==g.status?{...g,status:I}:g}),[a,T]),z=useMemo(()=>x.filter(g=>Us(g.status)).length,[x]),D=useMemo(()=>({entries:x,ready:c,unresolvedCount:z,refresh:v,focusPin:h,pendingFocus:u,clearFocus:y}),[x,c,z,v,h,u,y]);return jsx(lo.Provider,{value:D,children:e})}function ae(){let t=use(lo);if(!t)throw new Error("useRosterStore must be used inside <RosterProvider>");return t}var po=createContext(null);function mo({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(po.Provider,{value:s,children:t})}function Bt(){let t=use(po);if(!t)throw new Error("useWidgetUiStore must be used inside <WidgetUiProvider>");return t}var go="[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 fo(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 ho(){try{return typeof import.meta>"u"?void 0:import.meta.env}catch{return}}function bo(){try{return typeof process>"u"||!process.env?void 0:{NEXT_PUBLIC_PATCH_TOKEN:process.env.NEXT_PUBLIC_PATCH_TOKEN}}catch{return}}var Je=class extends Component{state={failed:false};static getDerivedStateFromError(){return {failed:true}}componentDidCatch(e,r){console.error("[patch] widget crashed and was unmounted",e,r.componentStack);}render(){return this.state.failed?null:this.props.children}};function 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 tr({seed:t,className:e,style:r}){let n=On(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,vo=[.22,.61,.36,1],er=["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 er[0];let e=0;for(let r=0;r<t.length;r++)e=(e<<5)-e+t.charCodeAt(r),e|=0;return er[Math.abs(e)%er.length]??er[0]}var Qs={right:"50% 50% 3px 50%",left:"50% 50% 50% 3px"},tl={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 rr(t,e){return {x:e==="left"?t.viewportX:t.viewportX-_t,y:t.viewportY-_t,width:_t,height:_t}}function _r({ref:t,...e}){let r=e.pointSide??"right",n=!e.resolved&&e.attention?el[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:vo}}:{opacity:0,scale:.9,transition:{duration:.12,ease:vo}},children:jsxs("span",{className:"patch-pin relative grid size-full place-items-center","data-patch-point-side":r,style:{borderRadius:Qs[r]},children:[jsxs("span",{"data-patch-avatar":"",className:"absolute inset-[2px] overflow-hidden",style:{borderRadius:tl[r],background:"var(--color-muted-foreground)"},children:[i?jsx(tr,{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 el={"review-pr":"bg-brand","patch-failed":"bg-destructive","rerun-after-closed":"bg-muted-foreground"};function nr(t){let e=new Date(t).getTime(),r=Date.now()-e,n=Math.round(r/6e4);if(Number.isNaN(n))return "";if(n<1)return "just now";if(n<60)return `${n}m ago`;let o=Math.round(n/60);return o<24?`${o}h ago`:`${Math.round(o/24)}d ago`}function wo(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 yo(t){let e=t.match(/\/pull\/(\d+)/);return e?`#${e[1]}`:"PR"}var ko={"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 N({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:ko[t].map(([s,i],a)=>createElement(s,{key:a,...i}))})}var Ao=[.16,1,.3,1];function il(t){try{let r=new URL(t).pathname.replace(/\/$/,"");return r===""?"/":r}catch{return t}}function or(t){return t==="pending"||t==="acknowledged"}function So({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)=>(or(d.status)?0:1)-(or(u.status)?0:1)),[e.entries,r]),i=useMemo(()=>{let c=e.entries.filter(u=>or(u.status)&&ct(u.url)===o).length,d=e.entries.filter(u=>or(u.status)).length;return {here:c,elsewhere:d-c,total:d}},[e.entries,o]);function a(){if(i.total===0)return "No open feedback";let c=[`${i.total} open`];return i.here>0&&c.push(`${i.here} here`),i.elsewhere>0&&c.push(`${i.elsewhere} elsewhere`),c.join(" \xB7 ")}function l(c){t(),n(c);}return jsxs(motion.div,{initial:{opacity:0,y:6,scale:.98},animate:{opacity:1,y:0,scale:1,transition:{duration:.18,ease:Ao}},exit:{opacity:0,y:4,scale:.985,transition:{duration:.12,ease:Ao}},"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(al,{entry:c,onCurrentPage:ct(c.url)===o,onClick:()=>l(c)},c.id))})]})}function al({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(N,{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(N,{name:Tt[t.viewport].glyph,size:11,className:"shrink-0 opacity-80"}),jsx("span",{className:"truncate",children:e?"This page":il(t.url)}),jsx("span",{"aria-hidden":"true",children:"\xB7"}),jsx("span",{className:"shrink-0",children:nr(t.createdAt)}),o?jsxs("span",{className:"ml-0.5 inline-flex shrink-0 items-center gap-1 rounded-full bg-black/[0.05] px-1.5 py-px text-[10px] font-medium text-popover-foreground/55",children:[jsx(N,{name:"unlink",size:10}),"element gone"]}):null]})]})]})}var sl="relative inline-grid shrink-0 overflow-hidden place-items-center rounded-full text-white font-semibold tracking-[-0.01em]",ll={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(sl,ll[s],i),style:{background:e,...a},children:[jsx("span",{children:t}),!l&&d?jsx(tr,{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 dl="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",ul="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:dl})})}function To({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:ul})})}var Dr=false,Kt=null,ar=null,Rt={openDelay:700,isInstant(){return Dr},onOpen(t){ar&&ar!==t&&ar(),ar=t??null,Dr=true,Kt&&(clearTimeout(Kt),Kt=null);},onClose(){Kt&&clearTimeout(Kt),Kt=setTimeout(()=>{Dr=false,Kt=null;},300);}};var Po="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&&Rt.onClose();},[]);let u=x=>{l(x),i(true),d.current=true,Rt.onOpen();},p=()=>{if(c.current&&(clearTimeout(c.current),c.current=null),Rt.isInstant()){u(true);return}c.current=setTimeout(()=>{c.current=null,u(false);},Rt.openDelay);},m=()=>{c.current&&(clearTimeout(c.current),c.current=null),d.current&&(d.current=false,Rt.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:Po}},exit:{opacity:0,y:T,scale:.98,transition:{duration:.08,ease:Po}},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 No=44,Lt=[.16,1,.3,1],Mo="easeOut",hl=.08,bl=60,vl="calc(100% - 64px) calc(100% + 4px)",me="pkey pkey-dock grid size-8 place-items-center rounded-full border-0 bg-transparent";function _o(){let t=io(),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),D=useRef(null),g=useRef(null),I=useRef(false),[U,at]=useState(false),pt=useRef(null),[vt,st]=useState(No);useLayoutEffect(()=>{let $=pt.current;if(!$)return;let lt=()=>st($.offsetWidth);lt();let St=new ResizeObserver(lt);return St.observe($),()=>St.disconnect()},[]);let Q=r.studio?r.studio.name:r.identity?.name??null,K=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(){D.current!==null&&(window.clearTimeout(D.current),D.current=null);}function xt(){g.current!==null&&(window.clearTimeout(g.current),g.current=null);}let P=useRef(()=>{});P.current=()=>{!I.current&&D.current===null||(tt(),xt(),I.current=false,z(true));};let W=useRef(()=>P.current()).current;useEffect(()=>{x&&d&&u(false);},[x,d]);function _($){m(false),f(false),h(false),tt(),xt(),I.current=true,z(false),T($),Rt.onOpen(W),u(true);}function G(){_(false);}function wt(){if(tt(),!(I.current||g.current!==null)){if(Rt.isInstant()){_(true);return}g.current=window.setTimeout(()=>{g.current=null,_(false);},Rt.openDelay);}}function yt(){xt(),tt(),I.current&&(I.current=false,Rt.onClose()),D.current=window.setTimeout(()=>{u(false),D.current=null;},120);}function Ut(){at(true),i(true);}function ze(){m(false),f(false),h(false),xt(),I.current=false,u(false),t.isCapturing?t.exit():t.enter();}function He(){m(false),f(false),xt(),I.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(),I.current=false,u(false),t.exit(),e.active&&e.forceClose();}useEffect(()=>()=>{D.current!==null&&window.clearTimeout(D.current),g.current!==null&&window.clearTimeout(g.current);},[]);let fr=()=>{r.signOut(),u(false);};function S(){f(false),h(false),xt(),I.current=false,u(false),m($=>!$);}function O($){m(false),r.activeViewport!==$&&(e.active&&e.forceClose(),r.setActiveViewport($));}function L(){m(false),h(false),xt(),I.current=false,u(false),f($=>!$);}function V(){a(!s);}function B($){let lt=$.relatedTarget;lt instanceof Node&&$.currentTarget.contains(lt)||yt();}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:No},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(To,{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(N,{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(N,{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"}),en.map($=>{let lt=Tt[$],St=r.activeViewport===$;return jsx(ot,{text:Qt($),children:jsx("button",{type:"button","data-patch-viewport-option":$,"aria-label":Qt($),"aria-pressed":St,onClick:()=>O($),className:C("grid size-8 place-items-center rounded-full border-0 bg-transparent transition-colors",St?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:jsx(N,{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:L,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(N,{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(N,{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:wt,onMouseLeave:yt,onFocus:G,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:K,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:hl,ease:Mo}},exit:{opacity:0,y:2,scale:.98,transition:x?{duration:0}:{duration:.08,ease:Mo}},"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:vl},children:[jsx("span",{className:"absolute bottom-[-4px] size-2 rotate-45 border-r border-b border-white/10 bg-foreground",style:{right:bl}}),r.studio?jsxs("div",{className:"flex items-center gap-2.5",children:[jsx(Vt,{initials:K,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:K,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:fr,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(N,{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(So,{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 Lo(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 Do(t,e){return {viewportX:e.x+t.fx*e.width,viewportY:e.y+t.fy*e.height}}var wl=.6,yl=.5,lr={text:.4,attrs:.3,classes:.2,position:.1},kl=5e3,Cl=.08,Al=.12;function Sl(t,e){return e===void 0||e===""?.5:t===e?1:t&&(t.includes(e)||e.includes(t))?.5:0}function Tl(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 El(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 zo(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 zr(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 Rl(t,e){let r=qe(t),n=Ke(t),o=Ae(t),s=t.getBoundingClientRect(),i=Sl(r,e.payload.domHints?.textSignature),a=Tl(n,e.payload.domHints?.attributeSignature),l=El(o,e.payload.cssClasses),c=zr(s,zo(e),e);return lr.text*i+lr.attrs*a+lr.classes*l+lr.position*c}function Pl(t){let e=t.getBoundingClientRect();return e.width<1&&e.height<1}function Oo(t,e,r){let n=null,o=null,s=0;for(let i=0;i<t.length&&!(s>=kl);i++){let a=t[i];if(!a||(s++,qn(a,e.internalAttr)))continue;let l=a.tagName.toLowerCase();if(l==="html"||l==="head"||l==="script"||l==="style"||Pl(a))continue;let c=Rl(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<Cl){let i=zo(e),a=zr(n.el.getBoundingClientRect(),i,e),l=zr(o.el.getBoundingClientRect(),i,e);if(a-l<Al)return null}return n.el}function Il(t){return {viewportX:t.payload.coordinates.viewportX,viewportY:t.payload.coordinates.documentY-t.scrollY}}function Nl(t,e){let r=t.getBoundingClientRect();if(!e.payload.boundingBox)return {viewportX:r.x,viewportY:r.y};let n=Lo({viewportX:e.payload.coordinates.viewportX,viewportY:e.payload.coordinates.viewportY},e.payload.boundingBox);return Do(n,{x:r.x,y:r.y,width:r.width,height:r.height})}function Ml(t){let e=t.payload.domHints?.cssSelector;if(!e)return [];try{return Array.from(t.doc.querySelectorAll(e))}catch{return []}}function cr(t){if(!t.payload.domHints)return {kind:"detached",el:null};let e=Ml(t);if(e.length>0){let n=Oo(e,t,yl);if(n)return {kind:"anchored",tier:1,el:n}}let r=Oo(t.doc.querySelectorAll("*"),t,wl);return r?{kind:"anchored",tier:2,el:r}:{kind:"detached",el:null}}function Hr(t,e){return t.kind==="anchored"&&t.el?Nl(t.el,e):Il(e)}function Ho(t){let e=cr(t);return {kind:e.kind,tier:e.tier,el:e.el,position:Hr(e,t)}}function Fo(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 Ll="data-patch-internal";function dr(t,e,r){let n=ce(r,e.getOverlayViewport()),o=rr(r,n);t.style.top=`${o.y}px`,t.style.left=`${o.x}px`;}function Vo(t,e){return Math.abs(t.viewportX-e.viewportX)<.5&&Math.abs(t.viewportY-e.viewportY)<.5}function Dl(t){let e=t.getBoundingClientRect();return e.width<1&&e.height<1}function Br(t,e){return {payload:e.payload,doc:t.targetDocument,scrollY:t.getTargetScrollY(),viewport:t.getTargetViewport(),internalAttr:Ll}}function Wo(t,e,r){let n=Br(t,e);return {kind:r.kind,position:t.targetPointToOverlay(Hr(r,n))}}function Ol(t,e){return t.targetPointToOverlay({viewportX:e.viewportX,viewportY:e.documentY-t.getTargetScrollY()})}function Uo(){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),D=useRef(new Map),g=useMemo(()=>{let k=D.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:cr(Br(d,A));k.set(A.id,E),M.set(A.id,Wo(d,A,E));}for(let A of k.keys())R.has(A)||k.delete(A);return M},[d,h]),I=useCallback(()=>{let k=D.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=cr(Br(d,A)),k.set(A.id,F)),F.kind==="detached"||F.kind==="anchored"&&F.el&&Dl(F.el)){H.style.visibility!=="hidden"&&(H.style.visibility="hidden"),R.delete(A.id);continue}H.style.visibility==="hidden"&&(H.style.visibility="");let E=Wo(d,A,F).position,tt=R.get(A.id);tt&&Vo(tt,E)||(R.set(A.id,E),dr(H,d,E));}for(let A of y){let H=x.current.get(A.tempId);if(!H)continue;M.add(A.tempId);let F=Ol(d,A),E=R.get(A.tempId);E&&Vo(E,F)||(R.set(A.tempId,F),dr(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(){I(),R=k.requestAnimationFrame(M);});return ()=>k.cancelAnimationFrame(R)},[U,I,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,K=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=zl(k),A=!o&&!!n?.clientUserId&&k.payload.authorRole==="client"&&k.payload.authorId===n.clientUserId,H=o?Fo(k):null,F=R?ce(R.position,d.getOverlayViewport()):"right";return jsx(_r,{ref:E=>{E?(T.current.set(k.id,E),R&&dr(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(_r,{ref:M=>{M?(x.current.set(k.tempId,M),dr(M,d,R)):x.current.delete(k.tempId);},avatarSrc:st,generatedSeed:K,avatarAlt:vt??"",resolved:false,pointSide:ce(R,d.getOverlayViewport()),ephemeral:true},k.tempId)})})]})}function zl(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 Vl=5e3;function Go(){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();},Vl));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 Wl(){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 Xo(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=Wl(),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 Gl='<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>',Xl=`url("data:image/svg+xml,${encodeURIComponent(Gl)}") 12 12, crosshair`,Wr=4;function jo(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 Zo({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=jo(f,b);s(null),a(null),!(h.width<Wr||h.height<Wr)&&(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?jo(o,i):null),m=!!p&&p.width>=Wr/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":Xl},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 ti=createContext(null);function ei({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 Xo(u),m=o.current;i(),p&&m&&m(p);},[i]),d=useMemo(()=>({supported:true,active:r!=="idle",begin:l}),[r,l]);return jsxs(ti.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(Zo,{capturing:r==="capturing",onSelect:u=>{c(u);},onCancel:i}):null]})}var Ql={supported:false,active:false,begin:async()=>{}};function ri(){return use(ti)??Ql}var ni=`/*! 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);
@@ -235,6 +236,9 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
235
236
  .relative {
236
237
  position: relative;
237
238
  }
239
+ .static {
240
+ position: static;
241
+ }
238
242
  .inset-0 {
239
243
  inset: calc(var(--spacing) * 0);
240
244
  }
@@ -247,21 +251,36 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
247
251
  .start {
248
252
  inset-inline-start: var(--spacing);
249
253
  }
254
+ .end {
255
+ inset-inline-end: var(--spacing);
256
+ }
250
257
  .-top-0\\.5 {
251
258
  top: calc(var(--spacing) * -0.5);
252
259
  }
253
260
  .-top-1 {
254
261
  top: calc(var(--spacing) * -1);
255
262
  }
263
+ .-top-1\\.5 {
264
+ top: calc(var(--spacing) * -1.5);
265
+ }
256
266
  .-top-\\[38px\\] {
257
267
  top: calc(38px * -1);
258
268
  }
259
269
  .top-0 {
260
270
  top: calc(var(--spacing) * 0);
261
271
  }
272
+ .top-1\\/2 {
273
+ top: calc(1 / 2 * 100%);
274
+ }
275
+ .top-4 {
276
+ top: calc(var(--spacing) * 4);
277
+ }
262
278
  .top-\\[-5px\\] {
263
279
  top: -5px;
264
280
  }
281
+ .top-\\[calc\\(100\\%\\+6px\\)\\] {
282
+ top: calc(100% + 6px);
283
+ }
265
284
  .top-\\[calc\\(100\\%\\+8px\\)\\] {
266
285
  top: calc(100% + 8px);
267
286
  }
@@ -274,9 +293,15 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
274
293
  .-right-1 {
275
294
  right: calc(var(--spacing) * -1);
276
295
  }
296
+ .-right-1\\.5 {
297
+ right: calc(var(--spacing) * -1.5);
298
+ }
277
299
  .right-0 {
278
300
  right: calc(var(--spacing) * 0);
279
301
  }
302
+ .right-4 {
303
+ right: calc(var(--spacing) * 4);
304
+ }
280
305
  .right-5 {
281
306
  right: calc(var(--spacing) * 5);
282
307
  }
@@ -289,6 +314,9 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
289
314
  .-bottom-1 {
290
315
  bottom: calc(var(--spacing) * -1);
291
316
  }
317
+ .bottom-4 {
318
+ bottom: calc(var(--spacing) * 4);
319
+ }
292
320
  .bottom-5 {
293
321
  bottom: calc(var(--spacing) * 5);
294
322
  }
@@ -304,6 +332,9 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
304
332
  .bottom-\\[72px\\] {
305
333
  bottom: 72px;
306
334
  }
335
+ .bottom-\\[calc\\(100\\%\\+6px\\)\\] {
336
+ bottom: calc(100% + 6px);
337
+ }
307
338
  .bottom-\\[calc\\(100\\%\\+8px\\)\\] {
308
339
  bottom: calc(100% + 8px);
309
340
  }
@@ -319,6 +350,9 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
319
350
  .left-1\\/2 {
320
351
  left: calc(1 / 2 * 100%);
321
352
  }
353
+ .left-4 {
354
+ left: calc(var(--spacing) * 4);
355
+ }
322
356
  .left-6 {
323
357
  left: calc(var(--spacing) * 6);
324
358
  }
@@ -358,6 +392,9 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
358
392
  .z-\\[2147483647\\] {
359
393
  z-index: 2147483647;
360
394
  }
395
+ .mx-2 {
396
+ margin-inline: calc(var(--spacing) * 2);
397
+ }
361
398
  .my-3 {
362
399
  margin-block: calc(var(--spacing) * 3);
363
400
  }
@@ -370,15 +407,24 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
370
407
  .mt-1 {
371
408
  margin-top: calc(var(--spacing) * 1);
372
409
  }
410
+ .mt-1\\.5 {
411
+ margin-top: calc(var(--spacing) * 1.5);
412
+ }
373
413
  .mt-px {
374
414
  margin-top: 1px;
375
415
  }
376
416
  .mb-1 {
377
417
  margin-bottom: calc(var(--spacing) * 1);
378
418
  }
419
+ .mb-2 {
420
+ margin-bottom: calc(var(--spacing) * 2);
421
+ }
379
422
  .ml-0\\.5 {
380
423
  margin-left: calc(var(--spacing) * 0.5);
381
424
  }
425
+ .ml-1\\.5 {
426
+ margin-left: calc(var(--spacing) * 1.5);
427
+ }
382
428
  .block {
383
429
  display: block;
384
430
  }
@@ -401,6 +447,10 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
401
447
  width: calc(var(--spacing) * 2);
402
448
  height: calc(var(--spacing) * 2);
403
449
  }
450
+ .size-2\\.5 {
451
+ width: calc(var(--spacing) * 2.5);
452
+ height: calc(var(--spacing) * 2.5);
453
+ }
404
454
  .size-3\\.5 {
405
455
  width: calc(var(--spacing) * 3.5);
406
456
  height: calc(var(--spacing) * 3.5);
@@ -417,6 +467,18 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
417
467
  width: calc(var(--spacing) * 8);
418
468
  height: calc(var(--spacing) * 8);
419
469
  }
470
+ .size-9 {
471
+ width: calc(var(--spacing) * 9);
472
+ height: calc(var(--spacing) * 9);
473
+ }
474
+ .size-14 {
475
+ width: calc(var(--spacing) * 14);
476
+ height: calc(var(--spacing) * 14);
477
+ }
478
+ .size-20 {
479
+ width: calc(var(--spacing) * 20);
480
+ height: calc(var(--spacing) * 20);
481
+ }
420
482
  .size-\\[7px\\] {
421
483
  width: 7px;
422
484
  height: 7px;
@@ -429,6 +491,10 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
429
491
  width: 14px;
430
492
  height: 14px;
431
493
  }
494
+ .size-\\[18px\\] {
495
+ width: 18px;
496
+ height: 18px;
497
+ }
432
498
  .size-\\[22px\\] {
433
499
  width: 22px;
434
500
  height: 22px;
@@ -459,9 +525,18 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
459
525
  .h-\\[18px\\] {
460
526
  height: 18px;
461
527
  }
528
+ .h-full {
529
+ height: 100%;
530
+ }
462
531
  .h-px {
463
532
  height: 1px;
464
533
  }
534
+ .max-h-40 {
535
+ max-height: calc(var(--spacing) * 40);
536
+ }
537
+ .max-h-\\[86vh\\] {
538
+ max-height: 86vh;
539
+ }
465
540
  .max-h-\\[min\\(480px\\,calc\\(100vh-120px\\)\\)\\] {
466
541
  max-height: min(480px, calc(100vh - 120px));
467
542
  }
@@ -492,6 +567,12 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
492
567
  .w-px {
493
568
  width: 1px;
494
569
  }
570
+ .max-w-\\[92vw\\] {
571
+ max-width: 92vw;
572
+ }
573
+ .max-w-\\[230px\\] {
574
+ max-width: 230px;
575
+ }
495
576
  .max-w-\\[280px\\] {
496
577
  max-width: 280px;
497
578
  }
@@ -532,6 +613,10 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
532
613
  --tw-translate-x: calc(calc(1 / 2 * 100%) * -1);
533
614
  translate: var(--tw-translate-x) var(--tw-translate-y);
534
615
  }
616
+ .-translate-y-1\\/2 {
617
+ --tw-translate-y: calc(calc(1 / 2 * 100%) * -1);
618
+ translate: var(--tw-translate-x) var(--tw-translate-y);
619
+ }
535
620
  .scale-50 {
536
621
  --tw-scale-x: 50%;
537
622
  --tw-scale-y: 50%;
@@ -550,6 +635,9 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
550
635
  .transform {
551
636
  transform: var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,);
552
637
  }
638
+ .animate-spin {
639
+ animation: var(--animate-spin);
640
+ }
553
641
  .cursor-default {
554
642
  cursor: default;
555
643
  }
@@ -559,6 +647,9 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
559
647
  .cursor-pointer {
560
648
  cursor: pointer;
561
649
  }
650
+ .cursor-zoom-in {
651
+ cursor: zoom-in;
652
+ }
562
653
  .resize {
563
654
  resize: both;
564
655
  }
@@ -571,6 +662,9 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
571
662
  .flex-col {
572
663
  flex-direction: column;
573
664
  }
665
+ .flex-wrap {
666
+ flex-wrap: wrap;
667
+ }
574
668
  .place-items-center {
575
669
  place-items: center;
576
670
  }
@@ -645,6 +739,9 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
645
739
  .rounded-\\[2px\\] {
646
740
  border-radius: 2px;
647
741
  }
742
+ .rounded-\\[3px\\] {
743
+ border-radius: 3px;
744
+ }
648
745
  .rounded-\\[5px\\] {
649
746
  border-radius: 5px;
650
747
  }
@@ -753,6 +850,15 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
753
850
  border-color: color-mix(in oklab, var(--color-white) 30%, transparent);
754
851
  }
755
852
  }
853
+ .border-white\\/40 {
854
+ border-color: color-mix(in srgb, #fff 40%, transparent);
855
+ @supports (color: color-mix(in lab, red, red)) {
856
+ border-color: color-mix(in oklab, var(--color-white) 40%, transparent);
857
+ }
858
+ }
859
+ .border-t-white {
860
+ border-top-color: var(--color-white);
861
+ }
756
862
  .bg-amber-500\\/15 {
757
863
  background-color: color-mix(in srgb, oklch(76.9% 0.188 70.08) 15%, transparent);
758
864
  @supports (color: color-mix(in lab, red, red)) {
@@ -783,6 +889,18 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
783
889
  background-color: color-mix(in oklab, var(--color-black) 25%, transparent);
784
890
  }
785
891
  }
892
+ .bg-black\\/28 {
893
+ background-color: color-mix(in srgb, #000 28%, transparent);
894
+ @supports (color: color-mix(in lab, red, red)) {
895
+ background-color: color-mix(in oklab, var(--color-black) 28%, transparent);
896
+ }
897
+ }
898
+ .bg-black\\/78 {
899
+ background-color: color-mix(in srgb, #000 78%, transparent);
900
+ @supports (color: color-mix(in lab, red, red)) {
901
+ background-color: color-mix(in oklab, var(--color-black) 78%, transparent);
902
+ }
903
+ }
786
904
  .bg-black\\/\\[0\\.03\\] {
787
905
  background-color: color-mix(in srgb, #000 3%, transparent);
788
906
  @supports (color: color-mix(in lab, red, red)) {
@@ -816,6 +934,12 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
816
934
  .bg-brand-tint {
817
935
  background-color: var(--color-brand-tint);
818
936
  }
937
+ .bg-brand\\/10 {
938
+ background-color: color-mix(in srgb, #0287FE 10%, transparent);
939
+ @supports (color: color-mix(in lab, red, red)) {
940
+ background-color: color-mix(in oklab, var(--color-brand) 10%, transparent);
941
+ }
942
+ }
819
943
  .bg-brand\\/15 {
820
944
  background-color: color-mix(in srgb, #0287FE 15%, transparent);
821
945
  @supports (color: color-mix(in lab, red, red)) {
@@ -834,6 +958,12 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
834
958
  .bg-foreground {
835
959
  background-color: var(--color-foreground);
836
960
  }
961
+ .bg-foreground\\/90 {
962
+ background-color: color-mix(in srgb, oklch(0.19 0.005 265) 90%, transparent);
963
+ @supports (color: color-mix(in lab, red, red)) {
964
+ background-color: color-mix(in oklab, var(--color-foreground) 90%, transparent);
965
+ }
966
+ }
837
967
  .bg-muted-foreground {
838
968
  background-color: var(--color-muted-foreground);
839
969
  }
@@ -870,6 +1000,12 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
870
1000
  background-color: color-mix(in oklab, var(--color-white) 12%, transparent);
871
1001
  }
872
1002
  }
1003
+ .bg-white\\/16 {
1004
+ background-color: color-mix(in srgb, #fff 16%, transparent);
1005
+ @supports (color: color-mix(in lab, red, red)) {
1006
+ background-color: color-mix(in oklab, var(--color-white) 16%, transparent);
1007
+ }
1008
+ }
873
1009
  .bg-white\\/\\[0\\.06\\] {
874
1010
  background-color: color-mix(in srgb, #fff 6%, transparent);
875
1011
  @supports (color: color-mix(in lab, red, red)) {
@@ -882,6 +1018,9 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
882
1018
  background-color: color-mix(in oklab, var(--color-white) 8%, transparent);
883
1019
  }
884
1020
  }
1021
+ .object-contain {
1022
+ object-fit: contain;
1023
+ }
885
1024
  .object-cover {
886
1025
  object-fit: cover;
887
1026
  }
@@ -930,6 +1069,9 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
930
1069
  .px-5 {
931
1070
  padding-inline: calc(var(--spacing) * 5);
932
1071
  }
1072
+ .py-0\\.5 {
1073
+ padding-block: calc(var(--spacing) * 0.5);
1074
+ }
933
1075
  .py-1 {
934
1076
  padding-block: calc(var(--spacing) * 1);
935
1077
  }
@@ -1149,6 +1291,10 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
1149
1291
  .lowercase {
1150
1292
  text-transform: lowercase;
1151
1293
  }
1294
+ .tabular-nums {
1295
+ --tw-numeric-spacing: tabular-nums;
1296
+ font-variant-numeric: var(--tw-ordinal,) var(--tw-slashed-zero,) var(--tw-numeric-figure,) var(--tw-numeric-spacing,) var(--tw-numeric-fraction,);
1297
+ }
1152
1298
  .line-through {
1153
1299
  text-decoration-line: line-through;
1154
1300
  }
@@ -1158,9 +1304,15 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
1158
1304
  .opacity-0 {
1159
1305
  opacity: 0%;
1160
1306
  }
1307
+ .opacity-40 {
1308
+ opacity: 40%;
1309
+ }
1161
1310
  .opacity-60 {
1162
1311
  opacity: 60%;
1163
1312
  }
1313
+ .opacity-70 {
1314
+ opacity: 70%;
1315
+ }
1164
1316
  .opacity-80 {
1165
1317
  opacity: 80%;
1166
1318
  }
@@ -1175,10 +1327,22 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
1175
1327
  --tw-shadow: 0 0 0 1px var(--tw-shadow-color, rgba(0,0,0,0.06));
1176
1328
  box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
1177
1329
  }
1330
+ .shadow-\\[0_0_0_1px_rgba\\(255\\,255\\,255\\,0\\.55\\)\\] {
1331
+ --tw-shadow: 0 0 0 1px var(--tw-shadow-color, rgba(255,255,255,0.55));
1332
+ box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
1333
+ }
1178
1334
  .shadow-\\[0_1px_3px_rgba\\(0\\,0\\,0\\,0\\.3\\)\\] {
1179
1335
  --tw-shadow: 0 1px 3px var(--tw-shadow-color, rgba(0,0,0,0.3));
1180
1336
  box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
1181
1337
  }
1338
+ .shadow-\\[0_1px_4px_rgba\\(0\\,0\\,0\\,0\\.3\\)\\] {
1339
+ --tw-shadow: 0 1px 4px var(--tw-shadow-color, rgba(0,0,0,0.3));
1340
+ box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
1341
+ }
1342
+ .shadow-\\[0_3px_8px_-3px_rgba\\(0\\,0\\,0\\,0\\.3\\)\\] {
1343
+ --tw-shadow: 0 3px 8px -3px var(--tw-shadow-color, rgba(0,0,0,0.3));
1344
+ box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
1345
+ }
1182
1346
  .shadow-\\[0_6px_12px_-5px_rgba\\(0\\,0\\,0\\,0\\.16\\)\\] {
1183
1347
  --tw-shadow: 0 6px 12px -5px var(--tw-shadow-color, rgba(0,0,0,0.16));
1184
1348
  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 +1351,10 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
1187
1351
  --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
1352
  box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
1189
1353
  }
1354
+ .shadow-\\[0_10px_30px_-10px_rgba\\(0\\,0\\,0\\,0\\.45\\)\\] {
1355
+ --tw-shadow: 0 10px 30px -10px var(--tw-shadow-color, rgba(0,0,0,0.45));
1356
+ box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
1357
+ }
1190
1358
  .shadow-\\[0_18px_44px_-14px_rgba\\(0\\,0\\,0\\,0\\.5\\)\\,0_6px_14px_-6px_rgba\\(0\\,0\\,0\\,0\\.45\\)\\] {
1191
1359
  --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
1360
  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 +1367,10 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
1199
1367
  --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
1368
  box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
1201
1369
  }
1370
+ .shadow-\\[0_32px_80px_-24px_rgba\\(0\\,0\\,0\\,0\\.6\\)\\] {
1371
+ --tw-shadow: 0 32px 80px -24px var(--tw-shadow-color, rgba(0,0,0,0.6));
1372
+ box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
1373
+ }
1202
1374
  .shadow-dialog {
1203
1375
  --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
1376
  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 +1385,18 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
1213
1385
  --tw-ring-color: color-mix(in oklab, var(--color-black) 6%, transparent);
1214
1386
  }
1215
1387
  }
1388
+ .ring-black\\/8 {
1389
+ --tw-ring-color: color-mix(in srgb, #000 8%, transparent);
1390
+ @supports (color: color-mix(in lab, red, red)) {
1391
+ --tw-ring-color: color-mix(in oklab, var(--color-black) 8%, transparent);
1392
+ }
1393
+ }
1394
+ .ring-destructive\\/60 {
1395
+ --tw-ring-color: color-mix(in srgb, oklch(0.55 0.2 27) 60%, transparent);
1396
+ @supports (color: color-mix(in lab, red, red)) {
1397
+ --tw-ring-color: color-mix(in oklab, var(--color-destructive) 60%, transparent);
1398
+ }
1399
+ }
1216
1400
  .ring-white\\/10 {
1217
1401
  --tw-ring-color: color-mix(in srgb, #fff 10%, transparent);
1218
1402
  @supports (color: color-mix(in lab, red, red)) {
@@ -1246,6 +1430,11 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
1246
1430
  transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
1247
1431
  transition-duration: var(--tw-duration, var(--default-transition-duration));
1248
1432
  }
1433
+ .transition-\\[filter\\] {
1434
+ transition-property: filter;
1435
+ transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
1436
+ transition-duration: var(--tw-duration, var(--default-transition-duration));
1437
+ }
1249
1438
  .transition-all {
1250
1439
  transition-property: all;
1251
1440
  transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
@@ -1273,11 +1462,27 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
1273
1462
  --tw-outline-style: none;
1274
1463
  outline-style: none;
1275
1464
  }
1465
+ .select-none {
1466
+ -webkit-user-select: none;
1467
+ user-select: none;
1468
+ }
1469
+ .group-focus-within\\/attachment\\:opacity-100 {
1470
+ &:is(:where(.group\\/attachment):focus-within *) {
1471
+ opacity: 100%;
1472
+ }
1473
+ }
1276
1474
  .group-focus-within\\/message\\:opacity-100 {
1277
1475
  &:is(:where(.group\\/message):focus-within *) {
1278
1476
  opacity: 100%;
1279
1477
  }
1280
1478
  }
1479
+ .group-hover\\/attachment\\:opacity-100 {
1480
+ &:is(:where(.group\\/attachment):hover *) {
1481
+ @media (hover: hover) {
1482
+ opacity: 100%;
1483
+ }
1484
+ }
1485
+ }
1281
1486
  .group-hover\\/message\\:opacity-100 {
1282
1487
  &:is(:where(.group\\/message):hover *) {
1283
1488
  @media (hover: hover) {
@@ -1370,6 +1575,16 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
1370
1575
  }
1371
1576
  }
1372
1577
  }
1578
+ .hover\\:bg-white\\/20 {
1579
+ &:hover {
1580
+ @media (hover: hover) {
1581
+ background-color: color-mix(in srgb, #fff 20%, transparent);
1582
+ @supports (color: color-mix(in lab, red, red)) {
1583
+ background-color: color-mix(in oklab, var(--color-white) 20%, transparent);
1584
+ }
1585
+ }
1586
+ }
1587
+ }
1373
1588
  .hover\\:bg-white\\/\\[0\\.08\\] {
1374
1589
  &:hover {
1375
1590
  @media (hover: hover) {
@@ -1404,6 +1619,14 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
1404
1619
  }
1405
1620
  }
1406
1621
  }
1622
+ .hover\\:brightness-\\[0\\.96\\] {
1623
+ &:hover {
1624
+ @media (hover: hover) {
1625
+ --tw-brightness: brightness(0.96);
1626
+ 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,);
1627
+ }
1628
+ }
1629
+ }
1407
1630
  .focus\\:border-brand\\/50 {
1408
1631
  &:focus {
1409
1632
  border-color: color-mix(in srgb, #0287FE 50%, transparent);
@@ -1445,6 +1668,11 @@ import {createContext,useMemo,useEffect,useState,useRef,useCallback,useLayoutEff
1445
1668
  border-color: var(--color-ring);
1446
1669
  }
1447
1670
  }
1671
+ .focus-visible\\:opacity-100 {
1672
+ &:focus-visible {
1673
+ opacity: 100%;
1674
+ }
1675
+ }
1448
1676
  .focus-visible\\:ring-2 {
1449
1677
  &:focus-visible {
1450
1678
  --tw-ring-shadow: var(--tw-ring-inset,) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color, currentcolor);
@@ -1784,6 +2012,26 @@ button:not(:disabled):not(.pkey):active {
1784
2012
  syntax: "*";
1785
2013
  inherits: false;
1786
2014
  }
2015
+ @property --tw-ordinal {
2016
+ syntax: "*";
2017
+ inherits: false;
2018
+ }
2019
+ @property --tw-slashed-zero {
2020
+ syntax: "*";
2021
+ inherits: false;
2022
+ }
2023
+ @property --tw-numeric-figure {
2024
+ syntax: "*";
2025
+ inherits: false;
2026
+ }
2027
+ @property --tw-numeric-spacing {
2028
+ syntax: "*";
2029
+ inherits: false;
2030
+ }
2031
+ @property --tw-numeric-fraction {
2032
+ syntax: "*";
2033
+ inherits: false;
2034
+ }
1787
2035
  @property --tw-shadow {
1788
2036
  syntax: "*";
1789
2037
  inherits: false;
@@ -1951,6 +2199,11 @@ button:not(:disabled):not(.pkey):active {
1951
2199
  syntax: "*";
1952
2200
  inherits: false;
1953
2201
  }
2202
+ @keyframes spin {
2203
+ to {
2204
+ transform: rotate(360deg);
2205
+ }
2206
+ }
1954
2207
  @layer properties {
1955
2208
  @supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))) {
1956
2209
  *, ::before, ::after, ::backdrop {
@@ -1969,6 +2222,11 @@ button:not(:disabled):not(.pkey):active {
1969
2222
  --tw-leading: initial;
1970
2223
  --tw-font-weight: initial;
1971
2224
  --tw-tracking: initial;
2225
+ --tw-ordinal: initial;
2226
+ --tw-slashed-zero: initial;
2227
+ --tw-numeric-figure: initial;
2228
+ --tw-numeric-spacing: initial;
2229
+ --tw-numeric-fraction: initial;
1972
2230
  --tw-shadow: 0 0 #0000;
1973
2231
  --tw-shadow-color: initial;
1974
2232
  --tw-shadow-alpha: 100%;
@@ -2011,16 +2269,19 @@ button:not(:disabled):not(.pkey):active {
2011
2269
  }
2012
2270
  }
2013
2271
  }
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(`
2272
+ `;var oi="patch-widget-root";function ii({children:t}){let[e,r]=useState(null),n=useRef(null);return useEffect(()=>{if(typeof document>"u")return;let o=document.querySelector(oi);o||(o=document.createElement(oi),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=ni,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 ic=/[\s#.:[\]()>+~,\\]/;function ac(t){return !(!t||ic.test(t)||/^\d/.test(t))}function sc(t){let e=1,r=t.previousElementSibling,n=t.tagName;for(;r;)r.tagName===n&&e++,r=r.previousElementSibling;return e}function ai(t,e,r){try{let n=t.querySelectorAll(e);return n.length===1&&n[0]===r}catch{return false}}function lc(t,e){return t.id&&ac(t.id)&&(!e||ai(e,`#${t.id}`,t))?`#${t.id}`:`${t.tagName.toLowerCase()}:nth-of-type(${sc(t)})`}function si(t,e){if(!t.tagName)return "";let r=t.ownerDocument??null,n=[],o=t,s=0;for(;o&&s<12;){let i=lc(o,r);if(n.unshift(i),i.startsWith("#"))break;let a=n.join(" > ");if(r&&ai(r,a,t))return a;if(o.tagName.toLowerCase()==="html")break;o=o.parentElement,s++;}return n.join(" > ")}var cc=80,dc=500;function ci(t){return t!==null&&typeof t=="object"}function uc(t){return ci(t)?"return"in t||"type"in t||"elementType"in t||"_debugOwner"in t:false}function pr(t){if(typeof t=="function")return t.displayName||t.name||null;if(!ci(t))return null;let e=t.displayName;if(typeof e=="string"&&e)return e;let r=pr(t.render);if(r)return r;let n=pr(t.type);return n||null}function di(t){return t.replace(/\s+/g," ").trim()}function ui(t,e){return t.length<=e?t:`${t.slice(0,e-1).trim()}\u2026`}function pc(t){let e=di(t).replace(/[<>]/g,"");return !e||/^[a-z]/.test(e)?null:ui(e,cc)}function mc(t){let e=pr(t.elementType)??pr(t.type);return e?pc(e):null}function li(t){return ui(di(t),dc)}function gc(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 fc(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 li(e.slice(o+1))}let r=e.split("/").filter(Boolean);return li(r.slice(-3).join("/"))}function hc(t){let e=t._debugSource?.fileName;return typeof e!="string"||!e.trim()||gc(e)?null:fc(e)}function bc(t){let e=t;for(let r of Object.getOwnPropertyNames(t)){if(!r.startsWith("__reactFiber$")&&!r.startsWith("__reactInternalInstance$"))continue;let n=e[r];if(uc(n))return n}return null}function pi(t){let e=bc(t);if(!e)return null;let r=[],n=null,o=0;for(;e&&o<30;){let a=mc(e),l=a?Sr(a):false;a&&!l&&r[r.length-1]!==a&&r.push(a),l||(n??=hc(e)),e=e.return??e._debugOwner??null,o+=1;}let s=r.length>0?Nn(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 mi=500;function vc(t){return t.length<=mi?t:t.slice(0,mi)}function xc(t){return {viewportX:t.viewportX,viewportY:t.viewportY,documentY:t.viewportY+t.scrollY,isFixed:false}}function wc(t){return {x:t.x,y:t.y,width:t.width,height:t.height}}function yc(t){let e={cssSelector:si(t)},r=qe(t);r&&(e.textSignature=r);let n=Ke(t);return Object.keys(n).length>0&&(e.attributeSignature=n),e}function gi(t){return Se(t.element,t.selectedText)}function fi(t){let{target:e,click:r,comment:n,url:o}=t,s=e.element,i=e.rect,a=Un(s),l=Gn(s),c=Ae(s),d=Xn(s),u=pi(s),p={comment:n,element:Xe(s),elementPath:Yn(s),targetLabel:Se(s,e.selectedText),timestamp:Date.now(),url:Gt(o),kind:"feedback",coordinates:xc(r),boundingBox:wc(i),domHints:yc(s)};return e.selectedText&&(p.selectedText=vc(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 kc=2e3,Cc=.82,Ac=.85;function bi(t,e,r){return new Promise(n=>t.toBlob(n,e,r))}function vi(t){return t.startsWith("image/")&&t!=="image/gif"}async function xi(t){let e;try{e=await createImageBitmap(t);}catch{return null}try{let r=Math.min(1,kc/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=Pn(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 bi(s,"image/webp",Cc);return (!a||a.type!=="image/webp")&&(a=await bi(s,"image/jpeg",Ac)),!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 wi(t,e){return e.resolve(t)}async function yi(t,e){return e.deleteAnnotation(t)}async function ki(t,e){return e.deleteMessage(t.annotationId,t.messageId)}async function Ci(t,e){return t.viewerKind!=="studio"?null:e.reopen(t.annotationId)}async function Ai(t,e){return t.viewerKind!=="studio"?null:e.kickoff(t.annotationId,{guidance:t.guidance})}async function Si(t,e){return e.postIdentity(t)}var Ri=createContext(null),Ei=0;function mr(t){return Ei+=1,`${t}-${Date.now().toString(36)}-${Ei}`}function Xr(t){return t.deliveryStatus==="sending"||t.deliveryStatus==="failed"}function Pi({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?Xr(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,O)=>{let L=y();return {id:mr("tmp-msg"),role:L.role,authorId:L.authorId,authorName:L.authorName,authorImage:L.authorImage,content:S,createdAt:new Date().toISOString(),deliveryStatus:"sending",attachments:O}},[y]),D=useCallback(async(S,O="upload")=>{let L=Array.from(S).filter(V=>vi(V.type));await Promise.all(L.map(async V=>{let B=await xi(V);if(!B)return;let $=mr("tmp-att"),lt=URL.createObjectURL(B.blob);if(!o.addDraftAttachment({localId:$,status:"uploading",previewUrl:lt,width:B.width,height:B.height,kind:O,attachment:null})){URL.revokeObjectURL(lt);return}let Yt=await n.apiClient.uploadAttachment(B.blob,{kind:O,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);}},[]),I=useCallback(async()=>{let S=o.draftText.trim(),O=o.draftAttachments.flatMap(et=>et.status==="uploaded"&&et.attachment?[et.attachment]:[]);if(o.draftAttachments.some(et=>et.status!=="uploaded"))return;if(t){if(!S&&O.length===0||f||Xr(t))return;let et=z(S,O);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:O.map(It=>It.id)},n.apiClient);if(we){let It=we.attachments??[];n.updateAnnotation(t.id,Jt=>({...Jt,thread:Jt.thread.map(hr=>hr.id===et.id?{...hr,id:we.id,deliveryStatus:"sent",attachments:It}:hr)})),It.length<O.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 L=o.active;if(!L||L.kind!=="composer")return;let V=L.target,B={viewportX:L.anchor.viewportX,viewportY:L.anchor.viewportY,scrollY:L.anchor.documentY-L.anchor.viewportY},$=s.getPageUrl(),lt=rn(n.activeViewport,s.getTargetViewport()),St=fi({target:V,click:B,comment:S,url:$});St.viewport=n.activeViewport,St.viewportSize=lt,St.attachmentIds=O.map(et=>et.id);let Yt=y(),$e=mr("tmp-ann");n.applyAnnotationUpdate({id:$e,status:"pending",resolvedBy:null,resolvedAt:null,createdAt:new Date().toISOString(),authorName:Yt.authorName,authorImage:Yt.authorImage,payload:{...St,authorRole:Yt.role,authorId:Yt.authorId},attachments:O,thread:[],latestRun:null,deliveryStatus:"sending"}),o.setDraftText(""),o.openExisting($e);let xe=await Me({kind:"composer",payload:St},n.apiClient);if(xe){let et=xe.attachments??[];n.replaceAnnotationId($e,xe.id),n.updateAnnotation(xe.id,we=>({...we,attachments:et})),et.length<O.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||Xr(t))return;let O=t.thread.find(V=>V.id===S);if(!O||O.deliveryStatus!=="failed")return;n.updateAnnotation(t.id,V=>({...V,thread:V.thread.map(B=>B.id===S?{...B,deliveryStatus:"sending"}:B)}));let L=await Me({kind:"reply",annotationId:t.id,content:O.content,attachmentIds:(O.attachments??[]).map(V=>V.id)},n.apiClient);if(L){n.updateAnnotation(t.id,V=>({...V,thread:V.thread.map(B=>B.id===S?{...B,id:L.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,L=>({...L,deliveryStatus:"sending"}));let O=await Me({kind:"composer",payload:t.payload},n.apiClient);if(O){n.replaceAnnotationId(S,O.id),o.openExisting(O.id),n.refresh();return}n.updateAnnotation(S,L=>({...L,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);},[]),K=useCallback(async S=>{if(!t)return false;let O=t.thread;return g(async()=>(c(null),n.updateAnnotation(t.id,V=>({...V,thread:V.thread.filter(B=>B.id!==S)})),await ki({annotationId:t.id,messageId:S},n.apiClient)?(n.refresh(),true):(n.updateAnnotation(t.id,V=>({...V,thread:O})),c("Couldn't delete message. Try again."),false)))},[t,n,g]),k=useCallback(async()=>!t||!x?false:g(async()=>(c(null),await yi(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 K(d.messageId))&&u(null);}catch{c("Couldn't delete. Try again.");}},[d,k,K]),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,L=>({...L,status:"resolved",resolvedBy:"dev",resolvedAt:new Date().toISOString(),optimisticAction:"resolve-pending"})),!await wi(t.id,n.apiClient)){n.updateAnnotation(t.id,L=>({...L,...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,L=>({...L,status:"pending",resolvedBy:null,resolvedAt:null,optimisticAction:"reopen-pending"})),!await Ci({annotationId:t.id,viewerKind:h},n.apiClient)){n.updateAnnotation(t.id,L=>({...L,...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 O=t.latestRun,L=t.optimisticAction;n.updateAnnotation(t.id,B=>({...B,latestRun:{id:mr("tmp-run"),status:"queued",prUrl:null,createdAt:new Date().toISOString(),completedAt:null,prClosedUnmerged:false},optimisticAction:"run-pending"}));let V=await Ai({annotationId:t.id,viewerKind:h,guidance:S},n.apiClient);if(!V?.ok){n.updateAnnotation(t.id,B=>({...B,latestRun:O,optimisticAction:L})),c(V?.error??"Couldn't start Patch. Try again.");return}n.refresh();});},[t,h,n,g]),F=useCallback(async S=>{let O=await Si({...S,avatarSeed:n.clientAvatarSeed},n.apiClient);return O&&await n.setIdentity(O),O},[n]),tt=h==="client"&&!n.identity&&m.length===0,xt=!!t||m.length>0,P=n.agentRunReadiness?.ready??true,W=n.agentRunReadiness?.message??null,_=useCallback(()=>{if(o.hasDraft){o.setConfirmDiscardOpen(true);return}o.forceClose();},[o]),G=t?Jn(t.payload):e||"annotation",wt=t?.payload.viewport??n.activeViewport,yt=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,fr=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:W,needsIdentity:tt,isResolved:f,initialMessageLocked:b,threadVisible:xt,canDeleteAnnotation:x},actions:{setDraftText:o.setDraftText,attachFiles:D,removeDraftAttachment:o.removeDraftAttachment,submit:I,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:_,forceClose:o.forceClose,setConfirmDiscardOpen:o.setConfirmDiscardOpen},meta:{targetLabel:G,viewport:wt,shakeNonce:o.shakeNonce,viewer:{kind:h,authorId:T.authorId,name:yt,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,D,I,U,at,vt,st,pt,Q,R,M,A,H,F,h,P,W,tt,f,b,xt,x,_,G,wt,T.authorId,yt,ze,He,Fe]);return jsx(Ri.Provider,{value:fr,children:r})}function j(){let t=use(Ri);if(!t)throw new Error("useThreadContext must be used inside <ThreadProvider>");return t}var Ic="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",Nc={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(Ic,Nc[t],e)}function Ct({variant:t="brand",className:e,type:r="button",ref:n,...o}){return jsx("button",{ref:n,type:r,className:_e(t,e),...o})}function Ni(){let{state:t,actions:e}=j(),r=t.confirmDelete;if(!r)return null;let n=r.kind==="annotation",o=n?"Delete annotation?":"Delete message?",s=n?"This removes the annotation and its thread for everyone.":"This removes your message from the thread.",i=n?"Delete annotation":"Delete message";return jsx("div",{className:"absolute inset-0 z-40 flex items-start justify-end bg-black/25 p-3 backdrop-blur-[2px]",children:jsxs("div",{role:"dialog","aria-label":o,className:"patch-fade-in flex w-full max-w-[286px] flex-col gap-2 rounded-xl bg-popover p-4 shadow-dialog",children:[jsx("div",{className:"text-[13.5px] font-medium text-foreground",children:o}),jsx("div",{className:"text-xs text-muted-foreground",children:s}),t.actionError?jsx("div",{className:"text-[11px] font-medium text-destructive",children:t.actionError}):null,jsxs("div",{className:"mt-1 flex justify-end gap-2",children:[jsx(Ct,{variant:"neutral",disabled:t.busy,onClick:e.cancelDelete,children:"Cancel"}),jsx(Ct,{variant:"destructive",disabled:t.busy,onClick:e.confirmDelete,children:t.busy?"Deleting\u2026":i})]})]})})}function _i(){let{state:t,actions:e}=j();return t.confirmDiscardOpen?jsx("div",{className:"absolute inset-0 z-20 flex items-start justify-end bg-black/25 p-3 backdrop-blur-[2px]",children:jsxs("div",{role:"dialog","aria-label":"Discard draft",className:"patch-fade-in flex w-full max-w-[280px] flex-col gap-2 rounded-xl bg-popover p-4 shadow-dialog",children:[jsx("div",{className:"text-[13.5px] font-medium text-foreground",children:"Discard draft?"}),jsx("div",{className:"text-xs text-muted-foreground",children:"You'll lose what you've typed."}),jsxs("div",{className:"mt-1 flex justify-end gap-2",children:[jsx(Ct,{variant:"neutral",onClick:()=>e.setConfirmDiscardOpen(false),children:"Keep editing"}),jsx(Ct,{variant:"destructive",onClick:()=>e.forceClose(),children:"Discard"})]})]})}):null}var _c="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",Lc={sm:"size-7",md:"size-8"},Dc={default:"text-muted-foreground hover:bg-black/6 hover:text-foreground",warn:"bg-amber-500/15 text-amber-700"};function Pt({size:t="sm",tone:e="default",className:r,type:n="button",ref:o,...s}){return jsx("button",{ref:o,type:n,className:C(_c,Lc[t],Dc[e],r),...s})}function Li(){let{state:t}=j();return !t.showDevFooter||!t.annotation?null:jsxs("div",{className:"-mt-[22px] flex flex-col gap-2 bg-neutral-100/50 px-3 pt-[2.125rem] pb-3",children:[jsxs("div",{className:"flex items-start justify-between gap-2",children:[jsx(zc,{}),jsx("div",{className:"flex shrink-0 items-center gap-1",children:jsx(Fc,{})})]}),t.actionError?jsx("div",{className:"px-1 text-[11px] font-medium text-destructive",children:t.actionError}):null]})}function zc(){let{state:t,actions:e}=j(),[r,n]=useState(false),[o,s]=useState(""),[i,a]=useState(false),l=t.runState,c=l?.status;if(t.annotation?.status==="resolved")return jsx("div",{className:"min-w-0 flex-1"});let u=c==="queued"||c==="running",p=c==="succeeded"&&!!l?.prUrl&&!l.prClosedUnmerged,m=l?"Run Patch again":"Run Patch",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(Ct,{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=yo(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(N,{name:"pr",size:12}),y==="PR"?"View PR":`View PR ${y}`]})})}let h=jsxs(Ct,{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(Hc,{title:m,guidance:o,submitting:i||t.busy,onGuidanceChange:s,onCancel:()=>n(false),onSubmit:b}):null]})}function Hc({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(Pt,{size:"sm",title:"Close",onClick:o,children:jsx(N,{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(Ct,{variant:"neutral",disabled:r,onClick:o,children:"Cancel"}),jsx(Ct,{type:"submit",variant:"brand",disabled:r,children:r?"Starting\u2026":"Start run"})]})]})]})}function Fc(){let{state:t,actions:e}=j();return t.annotation?t.annotation.status==="resolved"?jsxs(Ct,{variant:"neutral",disabled:t.busy,onClick:()=>e.reopen(),children:[jsx(N,{name:"refresh",size:12}),"Reopen"]}):jsxs(Ct,{variant:"neutral",disabled:t.busy,onClick:()=>e.markResolved(),children:[jsx(N,{name:"check",size:12}),"Resolve"]}):null}var $c={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 Oi(t){let e=t?.trim();return e||null}function qt(t){return Number.isInteger(t)?String(t):t.toFixed(1)}function Bc(t){let e=t.viewport??"desktop",r=$c[e],n=t.viewportSize;return n?`${r} (${n.width}x${n.height})`:r}function Vc(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 Wc(t){let e=t.boundingBox;return e?`x ${qt(e.x)}, y ${qt(e.y)}, ${qt(e.width)}x${qt(e.height)}`:null}function Uc(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 Yc(t){let e=[`- Page: ${t.url}`,`- Element: ${Ht(t.elementPath||t.element,500)??"unknown"}`,`- Viewport: ${Bc(t)}`,`- Anchor: ${Vc(t)}`],r=Ht(t.targetLabel,160),n=Wc(t);return r&&e.push(`- Visible target: ${r}`),n&&e.push(`- Bounding box: ${n}`),`## Target
2273
+ ${e.join(`
2274
+ `)}`}function Gc(t){let e=Ht(t.selectedText,1500);return e?`## Selected text
2275
+ ${e}`:null}function Xc(t){let e=t.role==="studio"?"workspace":"client",r=Ht(t.authorName,80),n=r?`${e} (${r})`:e,o=Oi(t.content)??"(empty)",s=t.attachments?.length??0,i=s>0?` [${s} attached image${s===1?"":"s"}, see Attached images]`:"";return `- ${n}: ${o.replace(/\n/g,`
2276
+ `)}${i}`}function Di(t,e){return `- ${t.kind==="screenshot"?"Screenshot":"Image"} ${e} (${t.width}\xD7${t.height}): ${t.url}`}function Kc(t){let e=[...(t.attachments??[]).map(r=>Di(r,"attached to the feedback")),...t.thread.flatMap(r=>(r.attachments??[]).map(n=>Di(n,"attached to a thread reply")))];return e.length===0?null:`## Attached images
2277
+ View these images before making changes \u2014 they usually show the exact visual issue being reported.
2278
+ ${e.join(`
2279
+ `)}`}function qc(t){return t.length===0?null:`## Thread
2280
+ ${t.map(Xc).join(`
2281
+ `)}`}function jc(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=Uc(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
2282
+ ${e.join(`
2283
+ `)}`:null}function zi(t){return ["Address this feedback in the repository.",`## Feedback
2284
+ ${Oi(t.payload.comment)??"(no feedback text)"}`,Yc(t.payload),Gc(t.payload),Kc(t),qc(t.thread),jc(t.payload)].filter(Boolean).join(`
2024
2285
 
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};
2286
+ `)}function Fi(){let{state:t,meta:e}=j(),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(N,{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(N,{name:"check",size:10})," Resolved"]}):null,jsxs("div",{className:"ml-0.5 flex items-center gap-0.5",children:[t.showDevFooter&&r?jsx(td,{annotation:r}):null,jsx(rd,{}),jsx(ed,{})]})]})]}),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 Qc(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 td({annotation:t}){let[e,r]=useState(false),n=useRef(null);useEffect(()=>()=>{n.current&&clearTimeout(n.current);},[]);let o=async s=>{await Qc(zi(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(Pt,{"aria-label":e?"Copied agent prompt":"Copy agent prompt",onClick:s=>{o(s.currentTarget.ownerDocument);},children:jsxs("span",{className:"relative block",style:{width:14,height:14},children:[jsx("span",{className:C("absolute inset-0 grid place-items-center transition-all duration-200 ease-out",e?"scale-50 opacity-0 blur-[2px]":"scale-100 opacity-100 blur-0"),children:jsx(N,{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(N,{name:"check",size:13})})]})})})}function ed(){let{actions:t}=j();return jsx(Pt,{onClick:t.requestClose,title:"Close",children:jsx(N,{name:"x",size:14})})}function rd(){let{state:t,actions:e}=j(),[r,n]=useState(false);return t.canDeleteAnnotation?jsxs("div",{className:"relative",children:[jsx(Pt,{title:"Annotation actions","aria-label":"Annotation actions","aria-expanded":r,"aria-haspopup":"menu",onClick:()=>n(o=>!o),children:jsx(N,{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(N,{name:"trash",size:13}),"Delete annotation"]})}):null]}):null}function ad(){return document.querySelector("patch-widget-root")?.shadowRoot?.querySelector("[data-patch-mount]")??null}function Vi({attachments:t,index:e,onClose:r,onNavigate:n}){let o=useReducedMotion(),s=ad(),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(N,{name:"x",size:15})}),a?jsxs(Fragment,{children:[jsx(Bi,{side:"left",label:"Previous image",onClick:()=>n((e-1+t.length)%t.length)}),jsx(Bi,{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 Bi({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(N,{name:t==="left"?"chevron-left":"chevron-right",size:16})})}function Wi({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(Vi,{attachments:t,index:e,onClose:()=>r(null),onNavigate:r}):null]})}function Ki(){let{state:t,actions:e,meta:r}=j(),n=useRef(null),o=r.viewer.kind==="client"?r.viewer.generatedSeed:null,s=r.viewer.kind==="client"?r.viewer.authorId:null;return useEffect(()=>{let a=n.current;a&&(a.scrollTop=a.scrollHeight);}),t.threadVisible?jsxs("div",{ref:n,"data-patch-thread-scroller":"",className:C("flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto bg-white px-4 pt-3.5 pb-3",t.showDevFooter&&t.isResolved&&"relative z-[1] rounded-b-xl shadow-[0_6px_12px_-5px_rgba(0,0,0,0.16)]"),children:[t.annotation?jsx(Gi,{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(Gi,{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 Gi(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:nr(t.createdAt)})]}),t.canDelete&&t.onDelete?jsx(md,{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(Wi,{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 ud=44,pd=8;function md({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<ud+pd&&m>p?"up":"down");},[]),a=useCallback(()=>{r(l=>{let c=!l;return c&&i(),c});},[i]);return jsxs("div",{className:"absolute top-[-5px] right-0 opacity-0 transition-opacity group-focus-within/message:opacity-100 group-hover/message:opacity-100",children:[jsx(Pt,{ref:s,size:"sm",title:"Message actions","aria-label":"Message actions","aria-expanded":e,"aria-haspopup":"menu",onClick:a,children:jsx(N,{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(N,{name:"trash",size:13}),"Delete"]})}):null]})}function qi({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(N,{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(N,{name:"x",size:9,stroke:2.4})})]},n.localId))})})}var vd={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 ji({variant:t="default",className:e,ref:r,...n}){return jsx("textarea",{ref:r,className:C(vd[t],e),...n})}var kd=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Zi="w-full rounded-md border border-border bg-popover px-2.5 py-2 text-[13px] text-foreground outline-none transition-colors focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring";function Ji(){let{actions:t}=j(),[e,r]=useState(""),[n,o]=useState(""),[s,i]=useState(null),[a,l]=useState(false),c=useRef(null);return useEffect(()=>{setTimeout(()=>c.current?.focus(),0);},[]),jsxs("form",{onSubmit:async u=>{u.preventDefault();let p=e.trim(),m=n.trim();if(!p){i("Name is required.");return}if(!kd.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:Zi}),jsx("input",{type:"email",placeholder:"Email",value:n,onChange:u=>o(u.target.value),className:Zi}),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 Sd="image/jpeg,image/png,image/webp";function ra(){let{state:t,actions:e,meta:r}=j(),n=ri(),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(Ji,{})});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(D=>D.kind==="file"&&D.type.startsWith("image/")).flatMap(D=>{let g=D.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(qi,{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(ji,{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:Sd,multiple:true,className:"hidden",onChange:x=>y(x.target.files)}),n.supported?jsx(ot,{text:"Capture screenshot",placement:"top",children:jsx(Pt,{"aria-label":"Capture screenshot",disabled:n.active,onClick:T,children:jsx(N,{name:"camera",size:15})})}):null,jsx(ot,{text:"Attach image",placement:"top",children:jsx(Pt,{"aria-label":"Attach image",onClick:()=>s.current?.click(),children:jsx(N,{name:"paperclip",size:15})})}),jsx(Td,{enabled:u})]})]})})}function Td({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(N,{name:"arrow-up",size:13})})}var Nd=[.4,0,.2,1],Md=[.22,.61,.36,1],_d={x:-8,y:-8,origin:"top left"},oa=200;function ia(t,e,r){return Math.max(e,Math.min(r,t))}function aa(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:ia((n.x-o.x)*.08,-12,12),y:ia((n.y-o.y)*.12,-10,10),origin:`${n.y<o.y?"top":"bottom"} ${n.x<o.x?"left":"right"}`}}function Ld(t,e){if(!e)return _d;let r=Ee({anchor:e,popover:{width:332,height:oa},viewport:t.getOverlayViewport()});return aa(e,r,oa)}function Dd(t,e){return t.x===e.x&&t.y===e.y&&t.origin===e.origin}function sa({getAnchorRect:t,initialAnchorRect:e,entryDelay:r=0,children:n}){let{actions:{attemptClose:o},meta:{shakeNonce:s}}=j(),i=mt(),a=useRef(null),[l,c]=useState(()=>Ld(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=aa(v,b,f);c(y=>Dd(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=wn(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=>{wo(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:Nd}},transition:{layout:{duration:.42,ease:Md}},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:sa,Header:Fi,Messages:Ki,Reply:ra,DevFooter:Li,ConfirmDiscard:_i,ConfirmDelete:Ni};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.ConfirmDiscard,{}),jsx(ut.ConfirmDelete,{})]})}function ca({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 Bd="data-patch-internal";function pa(t,e,r){let n={viewportX:e,viewportY:r},o=ce(n,t.getOverlayViewport());return rr(n,o)}function Vd(t,e){return t.overlayDocument.querySelector("patch-widget-root")?.shadowRoot?.querySelector(e)??null}function Wd(t,e){let r=Vd(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 Ud(t,e){if(!e)return null;let r=Ho({payload:e.payload,doc:t.targetDocument,scrollY:t.getTargetScrollY(),viewport:t.getTargetViewport(),internalAttr:Bd}),n=t.targetPointToOverlay(r.position);return pa(t,n.viewportX,n.viewportY)}function ua(t,e,r){if(!e)return null;if(e.kind==="existing")return Wd(t,e.annotationId)??Ud(t,r);let n=t.targetPointToOverlay({viewportX:e.anchor.viewportX,viewportY:e.anchor.documentY-t.getTargetScrollY()});return pa(t,n.viewportX,n.viewportY)}function ma(){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(()=>ua(r,n,o),[n,o,r]),i=e.viewerKind==="studio"?ca:la,a=n&&(n.kind==="composer"||!!o),l=n?.kind==="composer"?.04:0,c=n?.kind==="composer"?gi(n.target):null,d=useMemo(()=>ua(r,n,o),[n,o,r]);return jsx(AnimatePresence,{children:a?jsx(Pi,{annotation:o,draftTargetLabel:c,children:jsx(i,{getAnchorRect:s,initialAnchorRect:d,entryDelay:l})},"active-popover"):null})}var Xd="https://app.usepatch.dev";function Kd({children:t}){let{active:e}=rt();return e?t:null}function ga(t){let e=typeof window<"u"&&xn(window),r=useMemo(()=>fo({prop:t.projectToken,processEnv:bo(),importMetaEnv:ho()}),[t.projectToken]),n=t.apiBase??Xd;return useEffect(()=>{r||console.warn(go);},[r]),e||!r?null:jsx(Je,{children:jsx(ii,{children:jsx(yn,{children:jsx(Rn,{projectToken:r,apiBase:n,children:jsx(Kd,{children:jsx(Hn,{children:jsx(mo,{children:jsx(co,{projectToken:r,children:jsx(oo,{children:jsxs(ei,{children:[jsx(Uo,{}),jsx(ma,{}),jsx(Go,{}),jsx(_o,{})]})})})})})})})})})})}var qd=ga;
2287
+ export{ga as Patch,qd as default};