@usepatch/widget 0.3.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +12 -16
- package/dist/index.js +12 -16
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var react=require('react'),react$1=require('motion/react'),jsxRuntime=require('react/jsx-runtime'),reactDom=require('react-dom');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;function Ne(e){if(e.length<=1||!e.endsWith("/"))return e;try{let t=new URL(e);if(t.pathname==="/"&&e.endsWith("/"))return `${t.origin}${t.search}${t.hash}`}catch{}return e.slice(0,-1)}function ae(e){try{let t=new URL(e);return Ne(`${t.origin}${t.pathname}`)}catch{return Ne(e)}}var fr="patch:locationchange",Gr="__patchHistoryPatched";function Qi(e){let t=e.history;if(t[Gr])return;t[Gr]=true;let r=()=>e.dispatchEvent(new Event(fr)),{pushState:n,replaceState:o}=t;try{t.pushState=function(...a){let i=n.apply(this,a);return r(),i},t.replaceState=function(...a){let i=o.apply(this,a);return r(),i};}catch{}}function Kr(e,t){Qi(e);let r=()=>t();return e.addEventListener("popstate",r),e.addEventListener("hashchange",r),e.addEventListener(fr,r),()=>{e.removeEventListener("popstate",r),e.removeEventListener("hashchange",r),e.removeEventListener(fr,r);}}var we={desktop:{viewport:"desktop",label:"Desktop",width:null,height:null,glyph:"desktop"},tablet:{viewport:"tablet",label:"Tablet",width:834,height:1194,glyph:"tablet"},mobile:{viewport:"mobile",label:"Mobile",width:390,height:844,glyph:"mobile"}},qr=["desktop","tablet","mobile"];function je(e){let t=we[e];return t.width===null||t.height===null?t.label:`${t.label} (${t.width}px \xD7 ${t.height}px)`}function jr(e,t){let r=we[e];return {width:r.width??t.width,height:r.height??t.height}}var ta=32,ra=32,na=3e3,Qr="cubic-bezier(0.16, 1, 0.3, 1)",Dt=[.22,.61,.36,1],en=.3,tn=.5,oa=.34,ia=.5,aa=.24,sa=.22,rn=.12,la=.42,nn=.2,ca=200,da=260,ua=70,pa=180,ma=260,ga=8,fa=4,ha="#d9d9dd",ba=30,va=["0 2px 8px rgba(0,0,0,0.20)","0 30px 60px -18px rgba(0,0,0,0.55)","0 70px 130px -52px rgba(0,0,0,0.55)"].join(", ");function Lt(e,t,r){let n=Math.max(320,e.innerWidth-ta*2),o=Math.max(320,e.innerHeight-ra*2);return Math.min(1,n/t,o/r)}function xa(e){try{return !!(e.contentWindow&&e.contentDocument?.body)}catch{return false}}function on({src:e,viewport:t,overlayWindow:r,onFrameElement:n,onReadyChange:o,onBlockedChange:a}){let i=react$1.useReducedMotion(),s=t.width??r.innerWidth,c=t.height??r.innerHeight,l=t.viewport,d=`${l}:${s}:${c}`,p=!!r.happyDOM?.settings?.disableIframePageLoading,[u,m]=react.useState(()=>({viewport:l,width:s,height:c,scale:Lt(r,s,c)})),[h,v]=react.useState("stable"),[w,x]=react.useState(false),[b,g]=react.useState(false),k=react.useRef(false),z=react.useRef(null),f=`${u.viewport}:${u.width}:${u.height}`!==d,Q=w&&!b&&!(f||h==="cover"||h==="resize"),Z=w&&!b&&h==="stable"&&!f,be=react.useCallback(S=>{z.current=S,n(S);},[n]),pe=react.useCallback(()=>{let S=z.current;if(!S||!xa(S)){k.current=false,x(false),g(true);return}k.current=true,x(true),g(false);},[]),oe=react.useCallback(()=>{m(S=>{let te=Lt(r,S.width,S.height);return S.scale===te?S:{...S,scale:te}});},[r]);react.useEffect(()=>(oe(),r.addEventListener("resize",oe),()=>r.removeEventListener("resize",oe)),[r,oe]),react.useEffect(()=>{k.current=false,x(false),g(false);let S=r.setTimeout(()=>{k.current||g(true);},na);return ()=>r.clearTimeout(S)},[e,r]),react.useEffect(()=>{if(i){f&&m({viewport:l,width:s,height:c,scale:Lt(r,s,c)}),h!=="stable"&&v("stable");return}switch(h){case "stable":{f&&v("cover");return}case "cover":{let S=r.setTimeout(()=>v("resize"),ua);return ()=>r.clearTimeout(S)}case "resize":{f&&m({viewport:l,width:s,height:c,scale:Lt(r,s,c)});let S=r.setTimeout(()=>v("reveal"),pa);return ()=>r.clearTimeout(S)}case "reveal":{let S=r.setTimeout(()=>v("stable"),ma);return ()=>r.clearTimeout(S)}}},[h,f,i,r,l,s,c]),react.useEffect(()=>{o(Z);},[Z,o]),react.useEffect(()=>{a(b);},[b,a]);let ee=i?{duration:0}:{duration:aa,ease:Dt},X=i?{duration:0}:{duration:sa,ease:Dt,delay:nn*.5},C=i?{duration:0}:{duration:nn,ease:Dt},I=i?{duration:0}:{opacity:{duration:la,ease:Dt,delay:rn},scale:{type:"spring",bounce:oa,duration:ia,delay:rn},width:{type:"spring",bounce:en,duration:tn},height:{type:"spring",bounce:en,duration:tn}},M=(Q?da:ca)/1e3,A=i?void 0:`opacity ${M}s ${Qr}, filter ${M}s ${Qr}`,D=u.width*u.scale,H=u.height*u.scale;return jsxRuntime.jsx(react$1.motion.div,{"data-patch-preview-backdrop":"",initial:{opacity:0},animate:{opacity:1,transition:ee},exit:{opacity:0,transition:X},className:"fixed inset-0 z-[2147483643] grid place-items-center p-8",style:{backgroundColor:"#0C0C0E",backgroundImage:"radial-gradient(120% 75% at 50% 30%, rgba(255,255,255,0.055), rgba(0,0,0,0) 58%)"},children:jsxRuntime.jsxs(react$1.motion.div,{initial:i?{opacity:0,width:D,height:H}:{opacity:0,scale:.8,width:D,height:H},animate:{opacity:1,scale:1,width:D,height:H},exit:i?{opacity:0}:{opacity:0,scale:.92,transition:C},transition:I,"data-patch-preview-shell":"",className:"relative overflow-hidden bg-white",style:{boxSizing:"content-box",border:`${fa}px solid ${ha}`,borderRadius:ba,boxShadow:va,willChange:"width, height"},children:[jsxRuntime.jsx("div",{"aria-hidden":!Q,className:"absolute top-0 left-0 origin-top-left",style:{width:u.width,height:u.height,transform:`scale(${u.scale})`,opacity:Q?1:0,filter:i||Q?"none":`blur(${ga}px)`,transition:A,pointerEvents:Q?"auto":"none",willChange:"opacity, filter"},children:jsxRuntime.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}})}),jsxRuntime.jsx(wa,{visible:b})]})})}function wa({visible:e}){return e?jsxRuntime.jsx("div",{className:"absolute inset-0 grid place-items-center p-8",children:jsxRuntime.jsx("div",{className:"max-w-[320px] rounded-xl bg-white px-5 py-4 text-center text-[13px] leading-[1.45] text-foreground shadow-[0_18px_44px_-18px_rgba(0,0,0,0.28)]",children:"This site blocks embedding. Add X-Frame-Options: SAMEORIGIN or frame-ancestors 'self' to enable viewport previews."})}):null}var cn=react.createContext(null),dn=react.createContext(null),un="__patch_preview";function pn(){return typeof window>"u"||typeof document>"u"?null:{targetWindow:window,targetDocument:document,overlayWindow:window,overlayDocument:document,getTargetViewport:()=>({width:window.innerWidth,height:window.innerHeight}),getOverlayViewport:()=>({width:window.innerWidth,height:window.innerHeight}),getTargetScrollY:()=>window.scrollY,getPageUrl:()=>Ne(`${window.location.origin}${window.location.pathname}`),targetPointToOverlay:e=>({...e}),targetRectToOverlay:e=>({...e}),eventTargetElement:e=>e instanceof window.Element?e:null}}function Aa(e){let t=new URL(e.location.href);return t.searchParams.set(un,"1"),t.toString()}function mn(e=window){try{return new URL(e.location.href).searchParams.get(un)==="1"}catch{return false}}function Sa(e,t,r){let n=t.contentWindow,o=t.contentDocument;if(!n||!o)return null;function a(){return t.getBoundingClientRect()}function i(){let c=a();return r.width>0?c.width/r.width:1}function s(c){if(!c)return null;let l=n.Element;return c instanceof l?c:null}return {targetWindow:n,targetDocument:o,overlayWindow:e.overlayWindow,overlayDocument:e.overlayDocument,getTargetViewport:()=>r,getOverlayViewport:e.getOverlayViewport,getTargetScrollY:()=>n.scrollY,getPageUrl:()=>Ne(`${n.location.origin}${n.location.pathname}`),targetPointToOverlay:c=>{let l=a(),d=i();return {viewportX:l.left+c.viewportX*d,viewportY:l.top+c.viewportY*d}},targetRectToOverlay:c=>{let l=a(),d=i();return {x:l.left+c.x*d,y:l.top+c.y*d,width:c.width*d,height:c.height*d}},eventTargetElement:s}}function gn(e,t){let r=e.ResizeObserver??ResizeObserver;return new r(t)}function fn({children:e}){let t=react.useMemo(()=>pn(),[]),[r,n]=react.useState("desktop"),[o,a]=react.useState(null),[i,s]=react.useState(false),[c,l]=react.useState(false),[d,p]=react.useState(false),u=r!=="desktop",m=u||d,h=we[r],v=h.width&&h.height?{width:h.width,height:h.height}:null;react.useEffect(()=>{s(false),l(false);},[r]);let w=react.useRef(u);react.useEffect(()=>{w.current&&!u?p(true):!w.current&&u&&p(false),w.current=u;},[u]);let x=react.useMemo(()=>t?!u||!i||c||!o||!v?t:Sa(t,o,v)??t:null,[c,o,i,u,v,t]),b=react.useMemo(()=>({activeViewport:r,setActiveViewport:n,isPreviewing:m,previewReady:m?u&&i&&!c:true,previewBlocked:u&&c}),[r,c,i,u,m]),g=react.useMemo(()=>t?Aa(t.targetWindow):"",[t]);return !x||!t?null:jsxRuntime.jsx(dn.Provider,{value:b,children:jsxRuntime.jsxs(cn.Provider,{value:x,children:[e,jsxRuntime.jsx(react$1.AnimatePresence,{onExitComplete:()=>p(false),children:u&&v?jsxRuntime.jsx(on,{src:g,viewport:h,overlayWindow:t.overlayWindow,onFrameElement:a,onReadyChange:s,onBlockedChange:l}):null})]})})}function ce(){let e=react.use(cn),t=react.useMemo(()=>pn(),[]);if(e)return e;if(t)return t;throw new Error("useTargetSurface must run in a browser document")}function et(){let e=react.use(dn),[t,r]=react.useState("desktop"),n=react.useMemo(()=>({activeViewport:t,setActiveViewport:r,isPreviewing:false,previewReady:true,previewBlocked:false}),[t]);return e??n}var Ea="X-Patch-Client-Id";function ve(e,t){return {...t?{"Content-Type":"application/json"}:{},Authorization:`Bearer ${e.token}`,...e.clientUserId?{[Ea]:e.clientUserId}:{}}}async function ye(e,t){try{let r=await fetch(e,t);if(!r.ok)return null;let n=await r.text();return n?JSON.parse(n):{}}catch{return null}}async function Ra(e,t){try{let r=await fetch(e,t),n=await r.text(),o=n?JSON.parse(n):null;return r.ok?o??{ok:!0}:{ok:!1,error:o&&typeof o=="object"&&typeof o.error=="string"?o.error:"Request failed."}}catch{return null}}function hn(e){return {async listAnnotations(t){let r=t?`?viewport=${encodeURIComponent(t)}`:"";return (await ye(`${e.apiBase}/api/widget/annotations${r}`,{method:"GET",credentials:"include",headers:ve(e,false)}))?.annotations??[]},async listRoster(){return (await ye(`${e.apiBase}/api/widget/roster`,{method:"GET",credentials:"include",headers:ve(e,false)}))?.entries??[]},async fetchMe(){return ye(`${e.apiBase}/api/widget/me`,{method:"GET",credentials:"include",headers:ve(e,false)})},async postIdentity(t){let r=await ye(`${e.apiBase}/api/widget/identity`,{method:"POST",credentials:"include",headers:ve(e,true),body:JSON.stringify(t)});return r?{clientUserId:r.id,name:r.name,email:r.email,avatarSeed:r.avatarSeed??r.id}:null},async createAnnotation(t){return ye(`${e.apiBase}/api/widget/annotations`,{method:"POST",credentials:"include",headers:ve(e,true),body:JSON.stringify(t)})},async reply(t,r){return ye(`${e.apiBase}/api/widget/annotations/${t}/reply`,{method:"POST",credentials:"include",headers:ve(e,true),body:JSON.stringify(r)})},async deleteAnnotation(t){return ye(`${e.apiBase}/api/widget/annotations/${t}`,{method:"DELETE",credentials:"include",headers:ve(e,false)})},async deleteMessage(t,r){return ye(`${e.apiBase}/api/widget/annotations/${t}/messages/${r}`,{method:"DELETE",credentials:"include",headers:ve(e,false)})},async kickoff(t,r){return Ra(`${e.apiBase}/api/widget/annotations/${t}/kickoff`,{method:"POST",credentials:"include",headers:ve(e,true),body:JSON.stringify(r)})},async resolve(t){return ye(`${e.apiBase}/api/widget/annotations/${t}/resolve`,{method:"POST",credentials:"include",headers:ve(e,true)})},async reopen(t){return ye(`${e.apiBase}/api/widget/annotations/${t}/reopen`,{method:"POST",credentials:"include",headers:ve(e,true)})},async reportAnchorStatuses(t){t.length!==0&&await ye(`${e.apiBase}/api/widget/anchor-report`,{method:"POST",credentials:"include",headers:ve(e,true),body:JSON.stringify({reports:t})});}}}var xr="patch.clientIdentity",bn="patch.clientAvatarSeed";function wr(){if(typeof window>"u")return {};try{let e=window.localStorage.getItem(xr);if(!e)return {};let t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return {}}}function vn(e){return wr()[e]??null}function yr(e,t){if(!(typeof window>"u"))try{let r=wr();r[e]=t,window.localStorage.setItem(xr,JSON.stringify(r));}catch{}}function xn(e){if(!(typeof window>"u"))try{let t=wr();delete t[e],window.localStorage.setItem(xr,JSON.stringify(t));}catch{}}function Ia(){if(typeof window>"u")return {};try{let e=window.localStorage.getItem(bn);if(!e)return {};let t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return {}}}function vr(){let e=globalThis.crypto;return `client-avatar:${typeof e?.randomUUID=="function"?e.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}`}function wn(e){if(typeof window>"u")return vr();try{let t=Ia(),r=t[e];if(r)return r;let n=vr();return t[e]=n,window.localStorage.setItem(bn,JSON.stringify(t)),n}catch{return vr()}}var Ma=2e4,kn=react.createContext(null);function _a(e,t){let r=new Map(e.map(i=>[i.id,i])),n=new Set(t.map(i=>i.id)),o=t.map(i=>{let s=r.get(i.id);if(!s)return i;let c=new Set(i.thread.map(p=>p.id)),l=s.thread.filter(p=>p.deliveryStatus&&!c.has(p.id)),d=l.length>0?{...i,thread:[...i.thread,...l]}:i;if(s.optimisticAction==="resolve-pending"&&i.status!=="resolved"&&(d={...d,status:s.status,resolvedBy:s.resolvedBy,resolvedAt:s.resolvedAt,optimisticAction:s.optimisticAction}),s.optimisticAction==="reopen-pending"&&i.status==="resolved"&&(d={...d,status:s.status,resolvedBy:s.resolvedBy,resolvedAt:s.resolvedAt,optimisticAction:s.optimisticAction}),s.optimisticAction==="run-pending"&&s.latestRun?.id.startsWith("tmp-run")){let p=i.latestRun?Date.parse(i.latestRun.createdAt):Number.NaN,u=Date.parse(s.latestRun.createdAt);i.latestRun!=null&&(Number.isNaN(u)||Number.isNaN(p)||p>=u)||(d={...d,latestRun:s.latestRun,optimisticAction:s.optimisticAction});}return d}),a=e.filter(i=>(i.deliveryStatus||i.optimisticAction)&&!n.has(i.id));return [...o,...a]}function Cn({projectToken:e,apiBase:t,children:r}){let n=ce(),{activeViewport:o,setActiveViewport:a}=et(),[i,s]=react.useState(()=>typeof window>"u"?null:vn(e)),[c]=react.useState(()=>typeof window>"u"?"client-avatar:ssr":wn(e)),[l,d]=react.useState(null),[p,u]=react.useState("client"),[m,h]=react.useState(null),[v,w]=react.useState([]),[x,b]=react.useState(null),[g,k]=react.useState([]),[z,N]=react.useState(false),[f,E]=react.useState(null),Q=react.useRef(f);Q.current=f;let Z=react.useRef(o);Z.current=o;let be=x===o,pe=react.useMemo(()=>hn({apiBase:t,token:e,clientUserId:i?.clientUserId}),[t,e,i?.clientUserId]),oe=react.useRef(pe);oe.current=pe;let ee=react.useRef(0),X=react.useCallback(async()=>{let P=o,_=++ee.current,F=await oe.current.listAnnotations(P==="desktop"?void 0:P);if(_!==ee.current||P!==Z.current)return;let q=n.getPageUrl(),Se=F.filter(ge=>ae(ge.payload.url)===q);w(ge=>_a(ge,Se)),b(P);},[o,n]),C=react.useRef(X);C.current=X,react.useEffect(()=>{let P=false;return (async()=>{let _=await oe.current.fetchMe();if(!P){if(_?.active===false){E(false),N(true);return}if(E(true),_?.studio)d(_.studio),u("studio"),h(_.agentRunReadiness??{ready:true,message:null});else if(d(null),u("client"),h(null),_?.client){let F={clientUserId:_.client.id,name:_.client.name,email:_.client.email,avatarSeed:_.client.avatarSeed};s(F),yr(e,F);}await C.current(),P||N(true);}})(),()=>{P=true;}},[e]),react.useEffect(()=>{!z||!f||X();},[z,f,X]),react.useEffect(()=>{if(!f)return;let{overlayDocument:P,overlayWindow:_}=n,F=_.setInterval(()=>{P.visibilityState==="visible"&&X();},Ma),q=()=>{P.visibilityState==="visible"&&X();};return P.addEventListener("visibilitychange",q),()=>{_.clearInterval(F),P.removeEventListener("visibilitychange",q);}},[f,X,n]),react.useEffect(()=>{if(f)return Kr(n.targetWindow,()=>{let P=n.getPageUrl();w(_=>_.filter(F=>ae(F.payload.url)===P)),C.current();})},[f,n]);let I=react.useCallback(async P=>(yr(e,P),s(P),P),[e]),M=react.useCallback(()=>{s(null),xn(e);},[e]),A=react.useCallback(P=>{k(_=>[..._.filter(F=>F.tempId!==P.tempId),P]);},[]),D=react.useCallback(P=>{k(_=>_.filter(F=>F.tempId!==P));},[]),H=react.useCallback(P=>{w(_=>{let F=_.findIndex(Se=>Se.id===P.id);if(F===-1)return [..._,P];let q=_.slice();return q[F]=P,q});},[]),S=react.useCallback((P,_)=>{w(F=>{let q=false,Se=F.flatMap(ge=>{if(ge.id!==P)return [ge];q=true;let Be=_(ge);return Be?[Be]:[]});return q?Se:F});},[]),te=react.useCallback((P,_)=>{w(F=>F.map(q=>q.id===P?{...q,id:_,deliveryStatus:"sent"}:q));},[]),me=react.useMemo(()=>({apiClient:pe,active:f,ready:z,viewerKind:p,agentRunReadiness:m,activeViewport:o,clientAvatarSeed:c,identity:i,studio:l,annotations:v,annotationsReady:be,ephemerals:g,refresh:X,setActiveViewport:a,setIdentity:I,signOut:M,addEphemeral:A,removeEphemeral:D,applyAnnotationUpdate:H,updateAnnotation:S,replaceAnnotationId:te}),[pe,f,z,p,m,o,c,i,l,v,be,g,X,a,I,M,A,D,H,S,te]);return jsxRuntime.jsx(kn.Provider,{value:me,children:r})}function re(){let e=react.use(kn);if(!e)throw new Error("useAnnotationsStore must be used inside <AnnotationsProvider>");return e}var An=react.createContext(null);function Sn({children:e}){let[t,r]=react.useState(null),[n,o]=react.useState(""),[a,i]=react.useState(0),[s,c]=react.useState(false),l=react.useCallback(()=>{r(null),o(""),c(false);},[]),d=react.useCallback(v=>{r({kind:"existing",annotationId:v}),o(""),c(false);},[]),p=react.useCallback(v=>{r({kind:"composer",...v}),o(""),c(false);},[]),u=react.useCallback(()=>{if(n.trim().length>0){i(v=>v+1);return}l();},[n,l]),m=react.useCallback(()=>{l();},[l]),h=react.useMemo(()=>({active:t,draftText:n,shakeNonce:a,confirmDiscardOpen:s,openExisting:d,openComposer:p,setDraftText:o,attemptClose:u,forceClose:m,setConfirmDiscardOpen:c}),[t,n,a,s,d,p,u,m]);return jsxRuntime.jsx(An.Provider,{value:h,children:e})}function xe(){let e=react.use(An);if(!e)throw new Error("usePopoverStore must be used inside <PopoverProvider>");return e}var Rn=new Set(["p","span","h1","h2","h3","h4","h5","h6","li","td","th","label","blockquote","figcaption","code","pre","strong","em","i","b","u","mark","small","sub","sup","abbr","cite","q","dt","dd"]),Ha=new Set(["a","button","input","select","textarea"]),In={a:"link",button:"button",input:"input",select:"select",textarea:"textarea",img:"img",svg:"icon",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",p:"paragraph",li:"list item",td:"cell",th:"header cell",label:"label",blockquote:"quote",figcaption:"caption",code:"code",pre:"code block"},Ye=40,Fa=1500,Tn=200,Va=5,Ba=10;function kr(e){return Rn.has(e.tagName.toLowerCase())}function Me(e,t){let r=e.replace(/\s+/g," ").trim();return r.length<=t?r:`${r.slice(0,t-1)}\u2026`}function tt(e){return `"${e}"`}function Wa(e){let t="";for(let r of Array.from(e.childNodes))r.nodeType===3&&(t+=r.textContent??"");return t.replace(/\s+/g," ").trim()}function $t(e){return (e.textContent??"").replace(/\s+/g," ").trim()}function Ya(e){return !(!e||e.length>40||/__[A-Za-z0-9]{4,}$/.test(e)||/_[a-z0-9]{4,}$/i.test(e)&&/[0-9]/.test(e)||/_[A-Za-z0-9]{5,}_/.test(e)||/^(sc-|css-)[A-Za-z0-9]{4,}$/.test(e)||/^[a-z]{2,}:[\w-]+$/.test(e)||/^-?(p|m|w|h|min|max|gap|space|inset|top|right|bottom|left)[trblxy]?-/.test(e)||/^-?(text|bg|border|ring|shadow|font|leading|tracking|rounded|opacity|z|flex|grid|col|row|order|justify|items|self|content|place|object)-/.test(e)||(e.match(/\d/g)?.length??0)/e.length>.4)}function Ue(e){let t=Array.from(e.classList),r=t.filter(Ya).slice(0,Ba);return r.length>0?r:t.length>0?["container"]:[]}function Pn(e){let t=e.getAttribute("role")??void 0,r=e.getAttribute("aria-label")??void 0,n=e.getAttribute("tabindex"),o=n!==null&&n!==""?Number(n):void 0,a=e.tagName.toLowerCase(),i=Ha.has(a)||o!==void 0&&Number.isFinite(o)&&o>=0;if(t===void 0&&r===void 0&&o===void 0&&!i)return;let s={focusable:i};return t!==void 0&&(s.role=t),r!==void 0&&(s.ariaLabel=r),o!==void 0&&Number.isFinite(o)&&(s.tabIndex=o),s}function Ua(e){let t=e.tagName.toLowerCase(),r=In[t]??t,n=e.getAttribute("aria-label");if(n)return `${r} ${tt(Me(n,Ye))}`;let o=e.placeholder;if(o)return `${r} ${tt(Me(o,Ye))}`;let a=e.getAttribute("name");if(a)return `${r}[name="${a}"]`;if(t==="input"){let i=e.type||"text";return `${r}[type=${i}]`}return r}function Xa(e){let t=e.alt?.trim();return t?`img ${tt(Me(t,Ye))}`:"img"}function vt(e){let t=e.tagName.toLowerCase();if(t==="img")return Xa(e);if(t==="input"||t==="textarea"||t==="select")return Ua(e);let r=In[t]??t,n=e.getAttribute("aria-label");if(n)return `${r} ${tt(Me(n,Ye))}`;if(t==="a"||t==="button"||Rn.has(t)||t==="label"){let a=$t(e);if(a)return `${r} ${tt(Me(a,Ye))}`;if(t==="a"||t==="button"){let i=e.querySelector("svg");if(i){let c=i.getAttribute("aria-label");return c?`${r} ${tt(Me(c,Ye))}`:`${r} (icon)`}let s=e.getAttribute("href");if(t==="a"&&s)return `link[href="${Me(s,Ye)}"]`}return r}if(e.id)return `${t}#${e.id}`;let o=Ue(e);return o.length>0?`${t}.${o[0]}`:t}function Nn(e){let t=[],r=e,n=0;for(;r&&r.tagName.toLowerCase()!=="body"&&n<6;)t.unshift(vt(r)),r=r.parentElement,n++;return r&&r.tagName.toLowerCase()==="body"&&t.unshift("body"),t.join(" > ").slice(0,Fa)}function Mn(e){let t=$t(e),r=e.parentElement;if(!r)return;let n=$t(r);if(n){if(t&&n===t){let o=r.parentElement;if(!o)return;let a=$t(o);return !a||a===t?void 0:Me(a,Tn)}return Me(n,Tn)}}function _n(e){let t=e.parentElement;if(!t)return [];let r=[];for(let n of Array.from(t.children))if(n!==e&&n.tagName.toLowerCase()!=="script"&&(r.push(vt(n)),r.length>=Va))break;return r}var Ga=["role","aria-label","name"],Ka=10,En=100;function Ht(e){let t={};for(let r of Ga){let n=e.getAttribute(r);n!==null&&n!==""&&(t[r]=n.slice(0,En));}for(let r of Array.from(e.attributes)){if(Object.keys(t).length>=Ka)break;r.name.startsWith("data-")&&r.value!==""&&(t[r.name]=r.value.slice(0,En));}return t}function Ft(e){return Wa(e)}function Dn(e){let t=e;for(;t&&t.nodeType!==1;)t=t.parentNode;return t}function Vt(e,t){return e.closest(`[${t}]`)!==null}var qa=new Set(["p","span","li","td","th","label","blockquote","figcaption","code","pre","strong","em","i","b","u","mark","small","sub","sup","abbr","cite","q","dt","dd"]),ja={article:"Article",aside:"Sidebar",dialog:"Dialog",fieldset:"Form section",figure:"Image",footer:"Footer",form:"Form",header:"Header",main:"Main content",nav:"Navigation",section:"Section",summary:"Summary"},Za={a:"Link",article:"Article",aside:"Sidebar",blockquote:"Text",button:"Button",code:"Text",div:"Area",figcaption:"Text",figure:"Image",footer:"Footer",form:"Form",header:"Header",img:"Image",input:"Field",label:"Text",li:"Text",main:"Main content",nav:"Navigation",p:"Text",pre:"Text",section:"Section",select:"Field",span:"Text",svg:"Icon",textarea:"Field"},Ja={caption:"Text",cell:"Text","code block":"Text",icon:"Icon",input:"Field",label:"Text",link:"Link","list item":"Text",paragraph:"Text",quote:"Text",select:"Field",textarea:"Field"};function On(e,t){let r=e.replace(/\s+/g," ").trim();return r.length<=t?r:`${r.slice(0,t-1).trim()}\u2026`}function Qa(e){return `"${e}"`}function Bt(e){return (e.textContent??"").replace(/\s+/g," ").trim()}function Ln(e){let t=e.replace(/[_-]+/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").trim();return t?t.charAt(0).toUpperCase()+t.slice(1):""}function se(e,t){let r=t?.trim();return r?`${e}: ${Qa(On(r,48))}`:e}function es(e){let t=e.trim(),r=t.match(/^(.+?)\s+"(.+)"$/);return r?{base:r[1]??t,text:r[2]}:{base:t}}function ts(e){let t=e.toLowerCase().replace(/\[[\s\S]*$/,"").trim(),r=Ja[t];if(r)return r;let n=e.match(/^[a-z][\w-]*/i)?.[0]?.toLowerCase();return n?/^h[1-6]$/.test(n)?"Heading":Za[n]??"Area":"Area"}function rs(e){let t=e.getAttribute("aria-label");if(t)return se("Field",t);let r=e.placeholder;if(r)return se("Field",r);let n=e.getAttribute("name");if(n)return se("Field",Ln(n));if(e.tagName.toLowerCase()==="input"){let o=e.type||"text";if(o!=="text")return se("Field",Ln(o))}return "Field"}function xt(e,t){if(t?.trim())return se("Selected text",t);let r=e.tagName.toLowerCase(),n=e.getAttribute("aria-label");if(r==="button")return se("Button",n??Bt(e));if(r==="a")return se("Link",n??Bt(e));if(r==="input"||r==="textarea"||r==="select")return rs(e);if(r==="img"){let a=e.alt;return se("Image",a)}if(r==="svg")return se("Icon",n);if(/^h[1-6]$/.test(r))return se("Heading",Bt(e));if(qa.has(r))return se("Text",Bt(e));let o=ja[r];return se(o||"Area",n)}function Wt(e){return e===1?"1 item selected":`${e} items selected`}function Yt(){return "Selected area"}function zn(e){if(e.targetLabel?.trim())return On(e.targetLabel,120);if(e.selectedText?.trim())return se("Selected text",e.selectedText);let t=e.element?.trim()||e.elementPath?.trim();if(!t)return "Annotation";let r=t.match(/^(\d+)\s+elements?:/i);if(r)return Wt(Number(r[1]));if(/^region\b/i.test(t))return Yt();let n=es(t.split(">").at(-1)??t);return se(ts(n.base),n.text)}function Vn(e){let{clickTarget:t,selection:r}=e,n=r&&!r.isCollapsed?r.toString().trim():"";if(n&&r&&r.rangeCount>0){let o=r.getRangeAt(0),a=Dn(o.commonAncestorContainer);if(a)return {kind:"element",element:a,rect:a.getBoundingClientRect(),selectedText:n,clickTarget:t}}return {kind:"element",element:t,rect:t.getBoundingClientRect(),clickTarget:t}}var $n=20,Bn=7,Hn=10,ns=.8,os=.5,is=new Set(["html","body","head","script","style","meta","link","title","br","noscript"]),as=new Set(["section","article","aside","header","footer","nav","main","figure","form","fieldset","dialog","details","summary"]),Ut=24;function Wn(e){let t=e.tagName.toLowerCase();if(as.has(t))return true;if(t==="div"||t==="span"){if(e.id)return true;let r=Ue(e);if(r.length>0&&r[0]!=="container")return true}return false}var ss=["a","button","input","select","textarea","img","svg","h1","h2","h3","h4","h5","h6","p","span","li","td","th","label","blockquote","figcaption","code","pre","strong","em","div","section","article","aside","header","footer","nav","main","figure","form","fieldset","dialog","details"].join(",");function Fn(e){return {x:e.x,y:e.y,width:e.width,height:e.height}}function ls(e,t){return !(e.x+e.width<t.x||t.x+t.width<e.x||e.y+e.height<t.y||t.y+t.height<e.y)}function cs(e,t,r){if(Vt(e,r))return false;let n=e.tagName.toLowerCase();if(is.has(n))return false;let o=e.getBoundingClientRect();if(o.width<Hn||o.height<Hn||o.width>t.width*ns||o.height>t.height*os)return false;if(n==="div"||n==="span"){let a=Array.from(e.childNodes).some(c=>c.nodeType===3&&(c.textContent??"").trim().length>0),i=e.getAttribute("role"),s=i!==null&&i.length>0;if(!a&&!s&&!Wn(e))return false}return true}function ds(e){return e.filter(t=>!e.some(r=>r!==t&&t.contains(r)))}function us(e,t){let r=[...e].sort((n,o)=>{let a=n.getBoundingClientRect(),i=o.getBoundingClientRect();return a.width*a.height-i.width*i.height});for(let n of r){if(!Wn(n)||!e.every(s=>s===n||n.contains(s)))continue;let a=n.getBoundingClientRect();if(a.left>=t.x-Ut&&a.top>=t.y-Ut&&a.right<=t.x+t.width+Ut&&a.bottom<=t.y+t.height+Ut)return n}return null}function ps(e){let t=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY;for(let a of e)a.x<t&&(t=a.x),a.y<r&&(r=a.y),a.x+a.width>n&&(n=a.x+a.width),a.y+a.height>o&&(o=a.y+a.height);return {x:t,y:r,width:n-t,height:o-r}}function ms(e){let t=e.x+e.width/2,r=e.y+e.height/2,n=e.x+e.width,o=e.y+e.height;return [{x:e.x,y:e.y},{x:t,y:e.y},{x:n,y:e.y},{x:e.x,y:r},{x:t,y:r},{x:n,y:r},{x:e.x,y:o},{x:t,y:o},{x:n,y:o}]}function Yn(e){let{rect:t,viewport:r,internalAttr:n}=e,o=e.doc??document,a=new Set;for(let l of ms(t)){let d=o.elementsFromPoint(l.x,l.y);for(let p of d)a.add(p);}for(let l of Array.from(o.querySelectorAll(ss)))ls(Fn(l.getBoundingClientRect()),t)&&a.add(l);let i=Array.from(a).filter(l=>cs(l,r,n)),s=us(i,t),c=s?[s]:ds(i);if(c.length>0){let l=c.map(d=>Fn(d.getBoundingClientRect()));return {kind:"multi",elements:c,rects:l,union:ps(l)}}return t.width>=$n&&t.height>=$n?{kind:"area",rect:t}:null}var Un="patch-capture-cursor-style";function gs(e){let t=`:not([${e}]):not([${e}] *)`,r=["p","span","h1","h2","h3","h4","h5","h6","li","td","th","label","blockquote","figcaption","code","pre","strong","em","i","b","u","mark","small","sub","sup","abbr","cite","q","dt","dd"].map(n=>`body ${n}${t}`).join(`,
|
|
2
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var react=require('react'),react$1=require('motion/react'),jsxRuntime=require('react/jsx-runtime'),reactDom=require('react-dom');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;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,ji="#d9d9dd",Zi=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 jr({src:e,viewport:t,overlayWindow:r,onFrameElement:n,onReadyChange:o,onBlockedChange:s}){let i=react$1.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]=react.useState(()=>({viewport:c,width:a,height:l,scale:Lt(r,a,l)})),[h,f]=react.useState("stable"),[v,g]=react.useState(false),[y,R]=react.useState(false),I=react.useRef(false),V=react.useRef(null),b=`${u.viewport}:${u.width}:${u.height}`!==d,Q=v&&!y&&!(b||h==="cover"||h==="resize"),Z=v&&!y&&h==="stable"&&!b,be=react.useCallback(C=>{V.current=C,n(C);},[n]),pe=react.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=react.useCallback(()=>{m(C=>{let te=Lt(r,C.width,C.height);return C.scale===te?C:{...C,scale:te}});},[r]);react.useEffect(()=>(oe(),r.addEventListener("resize",oe),()=>r.removeEventListener("resize",oe)),[r,oe]),react.useEffect(()=>{I.current=false,g(false),R(false);let C=r.setTimeout(()=>{I.current||R(true);},zi);return ()=>r.clearTimeout(C)},[e,r]),react.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]),react.useEffect(()=>{o(Z);},[Z,o]),react.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 jsxRuntime.jsx(react$1.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:jsxRuntime.jsxs(react$1.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 ${ji}`,borderRadius:Zi,boxShadow:Ji,willChange:"width, height"},children:[jsxRuntime.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:jsxRuntime.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}})}),jsxRuntime.jsx(ea,{visible:y})]})})}function ea({visible:e}){return e?jsxRuntime.jsx("div",{className:"absolute inset-0 grid place-items-center p-8",children:jsxRuntime.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=react.createContext(null),tn=react.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=react.useMemo(()=>nn(),[]),[r,n]=react.useState("desktop"),[o,s]=react.useState(null),[i,a]=react.useState(false),[l,c]=react.useState(false),[d,p]=react.useState(false),u=r!=="desktop",m=u||d,h=we[r],f=h.width&&h.height?{width:h.width,height:h.height}:null;react.useEffect(()=>{a(false),c(false);},[r]);let v=react.useRef(u);react.useEffect(()=>{v.current&&!u?p(true):!v.current&&u&&p(false),v.current=u;},[u]);let g=react.useMemo(()=>t?!u||!i||l||!o||!f?t:ia(t,o,f)??t:null,[l,o,i,u,f,t]),y=react.useMemo(()=>({activeViewport:r,setActiveViewport:n,isPreviewing:m,previewReady:m?u&&i&&!l:true,previewBlocked:u&&l}),[r,l,i,u,m]),R=react.useMemo(()=>t?oa(t.targetWindow):"",[t]);return !g||!t?null:jsxRuntime.jsx(tn.Provider,{value:y,children:jsxRuntime.jsxs(en.Provider,{value:g,children:[e,jsxRuntime.jsx(react$1.AnimatePresence,{onExitComplete:()=>p(false),children:u&&f?jsxRuntime.jsx(jr,{src:R,viewport:h,overlayWindow:t.overlayWindow,onFrameElement:s,onReadyChange:a,onBlockedChange:c}):null})]})})}function ce(){let e=react.use(en),t=react.useMemo(()=>nn(),[]);if(e)return e;if(t)return t;throw new Error("useTargetSurface must run in a browser document")}function Je(){let e=react.use(tn),[t,r]=react.useState("desktop"),n=react.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=react.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]=react.useState(()=>typeof window>"u"?null:dn(e)),[l]=react.useState(()=>typeof window>"u"?"client-avatar:ssr":pn(e)),[c,d]=react.useState(null),[p,u]=react.useState("client"),[m,h]=react.useState(null),[f,v]=react.useState([]),[g,y]=react.useState(null),[R,I]=react.useState([]),[V,N]=react.useState(false),[b,L]=react.useState(null),Q=react.useRef(b);Q.current=b;let Z=react.useRef(o);Z.current=o;let be=g===o,pe=react.useMemo(()=>ln({apiBase:t,token:e,clientUserId:i?.clientUserId}),[t,e,i?.clientUserId]),oe=react.useRef(pe);oe.current=pe;let ee=react.useRef(0),G=react.useCallback(async()=>{let E=o,M=++ee.current,$=await oe.current.listAnnotations(E==="desktop"?void 0:E);if(M!==ee.current||E!==Z.current)return;let q=n.getPageUrl(),Ae=$.filter(fe=>ae(fe.payload.url)===q);v(fe=>ma(fe,Ae)),y(E);},[o,n]),w=react.useRef(G);w.current=G,react.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]),react.useEffect(()=>{!V||!b||G();},[V,b,G]),react.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]),react.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=react.useCallback(async E=>(fr(e,E),a(E),E),[e]),P=react.useCallback(()=>{a(null),un(e);},[e]),k=react.useCallback(E=>{I(M=>[...M.filter($=>$.tempId!==E.tempId),E]);},[]),D=react.useCallback(E=>{I(M=>M.filter($=>$.tempId!==E));},[]),H=react.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=react.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=react.useCallback((E,M)=>{v($=>$.map(q=>q.id===E?{...q,id:M,deliveryStatus:"sent"}:q));},[]),me=react.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 jsxRuntime.jsx(fn.Provider,{value:me,children:r})}function re(){let e=react.use(fn);if(!e)throw new Error("useAnnotationsStore must be used inside <AnnotationsProvider>");return e}var hn=react.createContext(null);function bn({children:e}){let[t,r]=react.useState(null),[n,o]=react.useState(""),[s,i]=react.useState(0),[a,l]=react.useState(false),c=react.useCallback(()=>{r(null),o(""),l(false);},[]),d=react.useCallback(f=>{r({kind:"existing",annotationId:f}),o(""),l(false);},[]),p=react.useCallback(f=>{r({kind:"composer",...f}),o(""),l(false);},[]),u=react.useCallback(()=>{if(n.trim().length>0){i(f=>f+1);return}c();},[n,c]),m=react.useCallback(()=>{c();},[c]),h=react.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 jsxRuntime.jsx(hn.Provider,{value:h,children:e})}function xe(){let e=react.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
3
|
`);return ["html, body { cursor: crosshair !important; }",`body *${t} { cursor: crosshair !important; }`,`${r} { cursor: text !important; }`].join(`
|
|
4
|
-
`)}function fs(e,t){let r=e.targetDocument,n=r.getElementById(Un);n&&n.remove();let o=r.createElement("style");return o.id=Un,o.setAttribute(t,""),o.textContent=gs(t),r.head.appendChild(o),o}function Xt(e,t,r){let n=e.eventTargetElement(t);return n?n.closest(`[${r}]`)!==null:false}var Xe=1.5,Gn="#0287FE",Kn="rgba(2, 135, 254, 0.032)";function hs(e){let t=e.split(" ")[0]??"",r=Number.parseFloat(t);return Number.isFinite(r)?Math.min(8,Math.max(3,r)):6}function bs(e,t){let r=e.targetDocument,n=r.createElement("div");n.setAttribute(t,""),Object.assign(n.style,{position:"fixed",pointerEvents:"none",border:`${Xe}px solid ${Gn}`,background:Kn,boxSizing:"border-box",zIndex:"2147483645",display:"none",borderRadius:"6px",transition:"top 80ms ease-out, left 80ms ease-out, width 80ms ease-out, height 80ms ease-out, border-radius 80ms ease-out"});let o=r.createElement("div");o.setAttribute(t,""),Object.assign(o.style,{position:"fixed",pointerEvents:"none",background:"#111",color:"#fff",fontFamily:"system-ui, sans-serif",fontSize:"12px",fontWeight:"500",padding:"6px 10px",borderRadius:"6px",zIndex:"2147483646",maxWidth:"240px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"none",boxShadow:"0 10px 24px -12px rgba(0, 0, 0, 0.36), 0 0 0 1px rgba(255, 255, 255, 0.08)"}),r.body.appendChild(n),r.body.appendChild(o);let a=null;return {update(i){let s=i.getBoundingClientRect();if(s.width===0&&s.height===0){this.hide();return}n.style.display="block",n.style.top=`${s.top-Xe}px`,n.style.left=`${s.left-Xe}px`,n.style.width=`${s.width+Xe*2}px`,n.style.height=`${s.height+Xe*2}px`,n.style.borderRadius=`${hs(e.targetWindow.getComputedStyle(i).borderRadius)+Xe}px`,i!==a&&(o.textContent=xt(i),a=i),o.style.display="block";let c=s.right+8,l=Math.max(8,s.top),d=e.getTargetViewport().width-8;c+240<=d?(o.style.left=`${c}px`,o.style.top=`${l}px`):(o.style.left=`${Math.max(8,s.right-240)}px`,o.style.top=`${Math.max(8,s.top-24)}px`);},hide(){n.style.display="none",o.style.display="none";},destroy(){n.remove(),o.remove();}}}function vs(e,t){let r=e.targetDocument.createElement("div");return r.setAttribute(t,""),Object.assign(r.style,{position:"fixed",pointerEvents:"none",border:`${Xe}px solid ${Gn}`,background:Kn,boxSizing:"border-box",zIndex:"2147483645",borderRadius:"8px"}),e.targetDocument.body.appendChild(r),{update(n){r.style.left=`${n.x}px`,r.style.top=`${n.y}px`,r.style.width=`${n.width}px`,r.style.height=`${n.height}px`;},destroy(){r.remove();}}}function Xn(e,t){return {x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),width:Math.abs(t.x-e.x),height:Math.abs(t.y-e.y)}}function qn(e){let{internalAttr:t,onClick:r,onDrag:n,surface:o}=e,a=o.targetDocument,i=fs(o,t),s=bs(o,t),c=false,l=null,d=null;function p(){l?.rectOverlay&&l.rectOverlay.destroy(),l=null;}function u(){d&&(d.destroy(),d=null);}let m=b=>{let g=b,k=o.eventTargetElement(g.target);Xt(o,g.target,t)||k&&kr(k)||(g.preventDefault(),g.stopPropagation(),!c&&(u(),l={startX:g.clientX,startY:g.clientY,isDragging:false,rectOverlay:null}));},h=b=>{let g=b;if(l?.isDragging){g.preventDefault(),g.stopPropagation();let z=Xn({x:l.startX,y:l.startY},{x:g.clientX,y:g.clientY});d=l.rectOverlay,l=null,n?.(z,g);return}p();let k=o.eventTargetElement(g.target);Xt(o,g.target,t)||k&&kr(k)||(g.preventDefault(),g.stopPropagation());},v=b=>{let g=b;Xt(o,g.target,t)||(g.preventDefault(),g.stopPropagation(),!c&&r(g));},w=b=>{let g=b;if(l){if(!l.isDragging){let N=g.clientX-l.startX,f=g.clientY-l.startY;if(Math.hypot(N,f)<Bn)return;l.isDragging=true,s.hide(),l.rectOverlay=vs(o,t);}l.rectOverlay?.update(Xn({x:l.startX,y:l.startY},{x:g.clientX,y:g.clientY}));return}if(c)return;let k=o.eventTargetElement(g.target);if(!k){s.hide();return}if(Xt(o,k,t)){s.hide();return}let z=k.tagName.toLowerCase();if(z==="html"||z==="body"){s.hide();return}s.update(k);},x=b=>{b.relatedTarget||s.hide();};return a.addEventListener("mousedown",m,true),a.addEventListener("mouseup",h,true),a.addEventListener("click",v,true),a.addEventListener("mousemove",w,true),a.addEventListener("mouseout",x,true),{exit(){i.remove(),s.destroy(),p(),u(),a.removeEventListener("mousedown",m,true),a.removeEventListener("mouseup",h,true),a.removeEventListener("click",v,true),a.removeEventListener("mousemove",w,true),a.removeEventListener("mouseout",x,true);},pause(){c=true,s.hide(),p();},resume(){c=false;},dismissDragOverlay(){u();}}}var jn="data-patch-internal",Qn=react.createContext(null),Zn=0;function Jn(){return Zn+=1,`tmp-${Date.now().toString(36)}-${Zn}`}function eo({children:e}){let t=xe(),r=re(),n=ce(),{isPreviewing:o,previewReady:a}=et(),[i,s]=react.useState(false),c=react.useRef(null),l=react.useRef(t),d=react.useRef(r);l.current=t,d.current=r;let p=react.useCallback(b=>{let g=l.current;if(g.active&&g.draftText.trim().length>0){g.attemptClose();return}let k=n.eventTargetElement(b.target)??n.targetDocument.body,z=n.targetWindow.getSelection(),N=Vn({clickTarget:k,selection:z}),f=Jn(),E={viewportX:b.clientX,viewportY:b.clientY,documentY:b.clientY+n.getTargetScrollY()};d.current.addEphemeral({tempId:f,viewportX:E.viewportX,viewportY:E.viewportY,documentY:E.documentY}),l.current.openComposer({tempId:f,target:N,anchor:E}),c.current?.pause();},[n]),u=react.useCallback((b,g)=>{let k=l.current;if(k.active&&k.draftText.trim().length>0){k.attemptClose(),c.current?.dismissDragOverlay();return}let z=n.getTargetViewport(),N=Yn({rect:b,viewport:z,internalAttr:jn,doc:n.targetDocument});if(!N){c.current?.dismissDragOverlay();return}let f=Jn(),E={viewportX:g.viewportX,viewportY:g.viewportY,documentY:g.viewportY+n.getTargetScrollY()};d.current.addEphemeral({tempId:f,viewportX:E.viewportX,viewportY:E.viewportY,documentY:E.documentY}),l.current.openComposer({tempId:f,target:N,anchor:E}),c.current?.pause();},[n]),m=r.annotationsReady&&(!o||a);react.useEffect(()=>{if(!i||!m){c.current?.exit(),c.current=null;return}return c.current?.exit(),c.current=qn({internalAttr:jn,surface:n,onClick:p,onDrag:(b,g)=>u(b,{viewportX:g.clientX,viewportY:g.clientY})}),()=>{c.current?.exit(),c.current=null;}},[i,p,u,n,m]);let h=react.useCallback(()=>{i||s(true);},[i]),v=react.useCallback(()=>{s(false);},[]),w=react.useRef(null);react.useEffect(()=>{let b=w.current,g=t.active;b?.kind==="composer"&&g?.kind!=="composer"&&(d.current.removeEphemeral(b.tempId),c.current?.dismissDragOverlay(),c.current?.resume()),b?.kind==="composer"&&g?.kind==="composer"&&b.tempId!==g.tempId&&d.current.removeEphemeral(b.tempId),w.current=g;},[t.active]),react.useEffect(()=>()=>{c.current?.exit(),c.current=null;},[]);let x=react.useMemo(()=>({isCapturing:i,enter:h,exit:v}),[i,h,v]);return jsxRuntime.jsx(Qn.Provider,{value:x,children:e})}function to(){let e=react.use(Qn);if(!e)throw new Error("useCaptureControls must be used inside <CaptureProvider>");return e}var Ts="patch:focus-intent";function Tr(e){return `${Ts}:${e}`}function Es(e){try{let t=window.sessionStorage.getItem(Tr(e));if(!t)return null;window.sessionStorage.removeItem(Tr(e));let r=JSON.parse(t);return typeof r.id!="string"||typeof r.url!="string"?null:{id:r.id,url:r.url,viewport:r.viewport??"desktop"}}catch{return null}}function Rs(e,t){try{window.sessionStorage.setItem(Tr(e),JSON.stringify(t));}catch{}}var oo=react.createContext(null);function Is(e){return e==="pending"||e==="acknowledged"}function io({projectToken:e,children:t}){let{apiClient:r,active:n,viewerKind:o,annotations:a}=re(),i=o==="studio",[s,c]=react.useState([]),[l,d]=react.useState(false),[p,u]=react.useState(null),m=react.useRef(r);m.current=r;let h=react.useCallback(async()=>{if(!i){c([]),d(true);return}let f=await m.current.listRoster();c(f),d(true);},[i]);react.useEffect(()=>{if(!n||!i)return;let f=Es(e);f&&ae(f.url)===ae(window.location.href)&&u(f),h();},[n,i,e,h]);let v=react.useMemo(()=>a.map(f=>`${f.id}:${f.status}`).sort().join(","),[a]),w=react.useRef(null);react.useEffect(()=>{if(!(!n||!i)){if(w.current===null){w.current=v;return}w.current!==v&&(w.current=v,h());}},[v,n,i,h]);let x=react.useCallback(f=>{let E={id:f.id,url:f.url,viewport:f.viewport};if(ae(f.url)===ae(window.location.href)){u(E);return}Rs(e,E),window.location.assign(f.url);},[e]),b=react.useCallback(()=>u(null),[]),g=react.useMemo(()=>{let f=new Map;for(let E of a)f.set(E.id,E.status);return f},[a]),k=react.useMemo(()=>s.map(f=>{let E=g.get(f.id);return E&&E!==f.status?{...f,status:E}:f}),[s,g]),z=react.useMemo(()=>k.filter(f=>Is(f.status)).length,[k]),N=react.useMemo(()=>({entries:k,ready:l,unresolvedCount:z,refresh:h,focusPin:x,pendingFocus:p,clearFocus:b}),[k,l,z,h,x,p,b]);return jsxRuntime.jsx(oo.Provider,{value:N,children:t})}function rt(){let e=react.use(oo);if(!e)throw new Error("useRosterStore must be used inside <RosterProvider>");return e}var so=react.createContext(null);function lo({children:e}){let[t,r]=react.useState(false),[n,o]=react.useState(false),a=react.useMemo(()=>({dockOpen:t,hideResolvedAnnotations:n,setDockOpen:r,setHideResolvedAnnotations:o}),[t,n]);return jsxRuntime.jsx(so.Provider,{value:a,children:e})}function ze(){let e=react.use(so);if(!e)throw new Error("useWidgetUiStore must be used inside <WidgetUiProvider>");return e}var co="[Patch] No project token found, widget disabled. Pass `projectToken` as a prop, or set NEXT_PUBLIC_PATCH_TOKEN (Next.js), VITE_PATCH_TOKEN (Vite / React Router), or PUBLIC_PATCH_TOKEN (Astro) in your env.";function uo(e){let t=e.prop?.trim();if(t)return t;let r=e.processEnv?.NEXT_PUBLIC_PATCH_TOKEN?.trim();if(r)return r;let n=e.importMetaEnv?.VITE_PATCH_TOKEN?.trim();if(n)return n;let o=e.importMetaEnv?.PUBLIC_PATCH_TOKEN?.trim();return o||null}function po(){try{return typeof ({ url: (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)) })>"u"?void 0:undefined}catch{return}}function mo(){try{return typeof process>"u"||!process.env?void 0:{NEXT_PUBLIC_PATCH_TOKEN:process.env.NEXT_PUBLIC_PATCH_TOKEN}}catch{return}}var Ls=new Set(["AmpStateContext","AppRouter","AppRouterContext","ClientPageRoot","ClientSegmentRoot","ErrorBoundary","ForbiddenBoundary","GlobalLayoutRouterContext","HTTPAccessFallbackBoundary","HTTPAccessFallbackErrorBoundary","HeadManagerContext","HotReload","ImageConfigContext","InnerLayoutRouter","InnerScrollAndFocusHandler","InnerScrollAndFocusHandlerOld","LayoutRouterContext","LoadingBoundary","NavigationPromisesContext","NotFoundBoundary","OuterLayoutRouter","PathParamsContext","PathnameContext","ReactDevOverlay","RedirectBoundary","RedirectErrorBoundary","RenderFromTemplateContext","RouterContext","ScrollAndMaybeFocusHandler","SearchParamsContext","SegmentStateProvider","SegmentViewNode","ServerInsertedHTMLContext","Suspense","TemplateContext","UnauthorizedBoundary","AwaitContext","BrowserRouter","DataRouterContext","DataRouterStateContext","DataRoutes","FetchersContext","HashRouter","LocationContext","MemoryRouter","NavigationContext","Outlet","RenderErrorBoundary","RenderedRoute","Route","RouteContext","RouteErrorContext","Router","RouterProvider","Routes","StaticRouter","StaticRouterProvider","ViewTransitionContext"]);function Os(e,t){return e.length<=t?e:`${e.slice(0,t-1).trim()}\u2026`}function go(e){return e.replace(/\s+/g," ").trim()}function Er(e){return Ls.has(go(e))}function fo(e){if(!e)return null;let t=[],r=e.matchAll(/<([^<>]+)>/g);for(let n of r){let o=go(n[1]??"");!o||Er(o)||t[t.length-1]!==o&&t.push(o);}return t.length===0?null:Os(t.map(n=>`<${n}>`).join(" "),1e3)}var ho="seed:";function qt(e){return e?e.startsWith(ho)?{url:null,seed:e.slice(ho.length)||null}:/^https?:\/\//i.test(e)?{url:e,seed:null}:{url:null,seed:e}:{url:null,seed:null}}var Rr=[6,20,34,92,120,140,158,174,190,206,220,234,252,270,286,300,318,336,350],bo=[{hue:"near",sat:[88,98],light:[68,82],r:[.44,.62],opacity:[.9,1],reach:[.14,.32]},{hue:"base",sat:[85,96],light:[44,56],r:[.5,.74],opacity:[.85,1],reach:[.2,.42]},{hue:"accent",sat:[84,97],light:[50,66],r:[.42,.64],opacity:[.8,.98],reach:[.26,.48]},{hue:"accent2",sat:[82,95],light:[30,46],r:[.44,.66],opacity:[.72,.94],reach:[.24,.46]}],vo=Math.PI*2;function zs(e){let t=2166136261;for(let r=0;r<e.length;r++)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return t>>>0}function $s(e){return ()=>{e+=1831565813;let t=e;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}}function G(e,t,r){return t+e()*(r-t)}function de(e,t=3){let r=10**t;return Math.round(e*r)/r}function xo(e,t,r){return `hsl(${de((e%360+360)%360,1)} ${de(t,1)}% ${de(r,1)}%)`}function wo(e){let t=zs(e?.trim()||"patch-client"),r=$s(t),n=t.toString(36),o=(Rr[t%Rr.length]??Rr[0])+G(r,-10,10),a=r()<.5?-1:1,i=r()<.5?-1:1,s=o+i*G(r,52,116),c=o-i*G(r,26,66),l=o+a*G(r,12,38),d=xo(o+a*G(r,0,14),G(r,80,92),G(r,44,54)),p=G(r,0,vo),u=bo.map((m,h)=>{let w=(m.hue==="accent"?s:m.hue==="accent2"?c:m.hue==="near"?l:o)+G(r,-11,11),x=p+h/bo.length*vo+G(r,-0.6,.6),b=G(r,m.reach[0],m.reach[1]),g=de(.5+Math.cos(x)*b),k=de(.5+Math.sin(x)*b),z=de(G(r,0,180),1),N=de(G(r,.62,1.5),3),f=de(G(r,.62,1.5),3);return {id:`cav-${n}-${h}`,cx:g,cy:k,r:de(G(r,m.r[0],m.r[1])),color:xo(w,G(r,m.sat[0],m.sat[1]),G(r,m.light[0],m.light[1])),opacity:de(G(r,m.opacity[0],m.opacity[1]),2),gradientTransform:`rotate(${z} ${g} ${k}) translate(${g} ${k}) scale(${N} ${f}) translate(${de(-g)} ${de(-k)})`}});return {id:n,background:d,spots:u,blur:de(G(r,3.4,5.4),2),grain:de(G(r,.09,.15),2)}}function yt(e){let t=e.gap??12,r=e.margin??16,n=Math.min(e.popover.width,Math.max(0,e.viewport.width-r*2)),o="right",a=e.anchor.x+e.anchor.width+t;a+n>e.viewport.width-r&&(o="left",a=e.anchor.x-n-t),a<r&&(a=r);let i=e.anchor.y;return i+e.popover.height>e.viewport.height-r&&(i=e.viewport.height-r-e.popover.height),i<r&&(i=r),{x:a,y:i,width:n,placement:o}}function R(...e){return e.filter(Boolean).join(" ")}function Zt({seed:e,className:t,style:r}){let n=wo(e),o=react.useId().replace(/[^a-zA-Z0-9_-]/g,""),a=`${n.id}-${o}`,i=`cav-blur-${a}`,s=`cav-grain-${a}`;return jsxRuntime.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 64 64",className:R("absolute inset-0 size-full! overflow-hidden rounded-full",t),style:r,children:[jsxRuntime.jsxs("defs",{children:[jsxRuntime.jsx("filter",{id:i,x:"-20%",y:"-20%",width:"140%",height:"140%",children:jsxRuntime.jsx("feGaussianBlur",{stdDeviation:n.blur})}),jsxRuntime.jsxs("filter",{id:s,x:"0%",y:"0%",width:"100%",height:"100%",children:[jsxRuntime.jsx("feTurbulence",{type:"fractalNoise",baseFrequency:"0.9",numOctaves:"2",stitchTiles:"stitch"}),jsxRuntime.jsx("feColorMatrix",{type:"saturate",values:"0"})]}),n.spots.map(c=>jsxRuntime.jsxs("radialGradient",{id:`${a}-${c.id}`,cx:c.cx,cy:c.cy,r:c.r,gradientTransform:c.gradientTransform,children:[jsxRuntime.jsx("stop",{offset:"0%",stopColor:c.color,stopOpacity:c.opacity}),jsxRuntime.jsx("stop",{offset:"100%",stopColor:c.color,stopOpacity:0})]},c.id))]}),jsxRuntime.jsx("rect",{width:"64",height:"64",fill:n.background}),jsxRuntime.jsx("g",{filter:`url(#${i})`,children:n.spots.map(c=>jsxRuntime.jsx("rect",{width:"64",height:"64",fill:`url(#${a}-${c.id})`},c.id))}),jsxRuntime.jsx("rect",{width:"64",height:"64",filter:`url(#${s})`,opacity:n.grain,style:{mixBlendMode:"overlay"}})]})}var Ie=32,yo=[.22,.61,.36,1],Jt=["var(--color-avatar-tint-1)","var(--color-avatar-tint-2)","var(--color-avatar-tint-3)","var(--color-avatar-tint-4)","var(--color-avatar-tint-5)"];function nt(e){if(!e)return "?";let t=e.trim().split(/\s+/),r=t[0],n=t[t.length-1];if(!r||!n)return "?";if(t.length===1)return r.slice(0,2).toUpperCase();let o=r[0]??"",a=n[0]??"";return (o+a).toUpperCase()||"?"}function ot(e){if(!e)return Jt[0];let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t|=0;return Jt[Math.abs(t)%Jt.length]??Jt[0]}var Vs={right:"50% 50% 3px 50%",left:"50% 50% 50% 3px"},Bs={right:"50% 50% 2px 50%",left:"50% 50% 50% 2px"};function it(e,t){let{placement:r}=yt({anchor:{x:e.viewportX-Ie/2,y:e.viewportY-Ie/2,width:Ie,height:Ie},popover:{width:332,height:200},viewport:t});return r==="right"?"left":"right"}function Qt(e,t){return {x:t==="left"?e.viewportX:e.viewportX-Ie,y:e.viewportY-Ie,width:Ie,height:Ie}}function Ir({ref:e,...t}){let r=t.pointSide??"right",n=!t.resolved&&t.attention?Ws[t.attention]:null,{url:o,seed:a}=qt(t.avatarSrc),i=a??t.generatedSeed,s=t.orphan?"grayscale(1)":t.resolved?"saturate(0.55) brightness(1.04) contrast(0.92)":"",c=t.orphan?.55:1,l=r==="right"?"-bottom-0.5 -left-0.5":"-bottom-0.5 -right-0.5";return jsxRuntime.jsx(react$1.motion.button,{ref:e,type:"button",onClick:t.onClick,"aria-label":t.ariaLabel??"Open annotation","data-patch-ephemeral":t.ephemeral?"":void 0,"data-patch-pin-id":t.pinId,className:"patch-pin-button fixed z-[2147483645] border-0 bg-transparent p-0",style:{width:Ie,height:Ie},initial:t.ephemeral?{opacity:0,scale:.45}:false,animate:t.ephemeral?{opacity:1,scale:1,transition:{type:"spring",stiffness:620,damping:30,mass:.65}}:{opacity:1,scale:1},exit:t.ephemeral?{opacity:0,scale:.45,transition:{delay:.16,duration:.14,ease:yo}}:{opacity:0,scale:.9,transition:{duration:.12,ease:yo}},children:jsxRuntime.jsxs("span",{className:"patch-pin relative grid size-full place-items-center","data-patch-point-side":r,style:{borderRadius:Vs[r]},children:[jsxRuntime.jsxs("span",{"data-patch-avatar":"",className:"absolute inset-[2px] overflow-hidden",style:{borderRadius:Bs[r],background:"var(--color-muted-foreground)",filter:t.orphan?"grayscale(1)":"none",opacity:t.orphan?.55:1},children:[i?jsxRuntime.jsx(Zt,{seed:i,style:{borderRadius:0,filter:s||"none",opacity:c}}):null,o?jsxRuntime.jsx("img",{src:o,alt:t.avatarAlt??"",referrerPolicy:"no-referrer",className:"absolute inset-0 size-full object-cover",draggable:false,style:{filter:s||"none",opacity:c},onError:d=>{d.currentTarget.remove();}}):null]}),t.resolved&&jsxRuntime.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&&jsxRuntime.jsx("span",{"data-patch-attention":t.attention,"aria-hidden":"true",className:`absolute -top-0.5 -right-0.5 size-[10px] rounded-full border-[1.5px] border-white ${n}`})]})})}var Ws={"review-pr":"bg-brand","patch-failed":"bg-destructive","rerun-after-closed":"bg-muted-foreground"};function er(e){let t=new Date(e).getTime(),r=Date.now()-t,n=Math.round(r/6e4);if(Number.isNaN(n))return "";if(n<1)return "just now";if(n<60)return `${n}m ago`;let o=Math.round(n/60);return o<24?`${o}h ago`:`${Math.round(o/24)}d ago`}function Co(e){let t=e.composedPath();for(let r of t)if(r instanceof Element&&r.tagName?.toLowerCase()==="patch-widget-root")return true;return false}function Ao(e){let t=e.match(/\/pull\/(\d+)/);return t?`#${t[1]}`:"PR"}var So={"arrow-up":[["path",{d:"M12 5.5V19"}],["path",{d:"M18 11C18 11 13.5811 5.00001 12 5C10.4188 4.99999 6 11 6 11"}]],check:[["path",{d:"M5 14L8.5 17.5L19 6.5"}]],copy:[["path",{d:"M9 15C9 12.1716 9 10.7574 9.87868 9.87868C10.7574 9 12.1716 9 15 9L16 9C18.8284 9 20.2426 9 21.1213 9.87868C22 10.7574 22 12.1716 22 15V16C22 18.8284 22 20.2426 21.1213 21.1213C20.2426 22 18.8284 22 16 22H15C12.1716 22 10.7574 22 9.87868 21.1213C9 20.2426 9 18.8284 9 16L9 15Z"}],["path",{d:"M16.9999 9C16.9975 6.04291 16.9528 4.51121 16.092 3.46243C15.9258 3.25989 15.7401 3.07418 15.5376 2.90796C14.4312 2 12.7875 2 9.5 2C6.21252 2 4.56878 2 3.46243 2.90796C3.25989 3.07417 3.07418 3.25989 2.90796 3.46243C2 4.56878 2 6.21252 2 9.5C2 12.7875 2 14.4312 2.90796 15.5376C3.07417 15.7401 3.25989 15.9258 3.46243 16.092C4.51121 16.9528 6.04291 16.9975 9 16.9999"}]],cursor:[["path",{d:"M12.669 8.35811L17.6969 10.3256C20.5969 11.4604 22.0469 12.0277 21.9988 12.9278C21.9508 13.8278 20.4375 14.2405 17.4111 15.0659C16.5099 15.3117 16.0593 15.4346 15.7469 15.7469C15.4346 16.0593 15.3117 16.5099 15.0659 17.4111C14.2405 20.4375 13.8278 21.9508 12.9278 21.9988C12.0277 22.0469 11.4604 20.5969 10.3256 17.6969L8.35811 12.669C7.17004 9.63279 6.57601 8.1147 7.34535 7.34535C8.1147 6.57601 9.63279 7.17004 12.669 8.35811Z"}],["path",{d:"M9 4V2M5 5L3.5 3.5M4 9H2M5 13L3.5 14.5M14.5 3.5L13 5"}]],desktop:[["path",{d:"M14 21H16M14 21C13.1716 21 12.5 20.3284 12.5 19.5V17L12 17M14 21H10M10 21H8M10 21C10.8284 21 11.5 20.3284 11.5 19.5V17L12 17M12 17V21"}],["path",{d:"M16 3H8C5.17157 3 3.75736 3 2.87868 3.87868C2 4.75736 2 6.17157 2 9V11C2 13.8284 2 15.2426 2.87868 16.1213C3.75736 17 5.17157 17 8 17H16C18.8284 17 20.2426 17 21.1213 16.1213C22 15.2426 22 13.8284 22 11V9C22 6.17157 22 4.75736 21.1213 3.87868C20.2426 3 18.8284 3 16 3Z"}]],globe:[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"M8 12C8 18 12 22 12 22C12 22 16 18 16 12C16 6 12 2 12 2C12 2 8 6 8 12Z"}],["path",{d:"M21 15H3"}],["path",{d:"M21 9H3"}]],list:[["path",{d:"M8 5.5L20 5.5"}],["path",{d:"M8 12.5L20 12.5"}],["path",{d:"M8 19.5L20 19.5"}],["path",{d:"M4.375 5.5H4.25M4.5 5.5C4.5 5.63807 4.38807 5.75 4.25 5.75C4.11193 5.75 4 5.63807 4 5.5C4 5.36193 4.11193 5.25 4.25 5.25C4.38807 5.25 4.5 5.36193 4.5 5.5Z"}],["path",{d:"M4.375 12.5H4.25M4.5 12.5C4.5 12.6381 4.38807 12.75 4.25 12.75C4.11193 12.75 4 12.6381 4 12.5C4 12.3619 4.11193 12.25 4.25 12.25C4.38807 12.25 4.5 12.3619 4.5 12.5Z"}],["path",{d:"M4.375 19.5H4.25M4.5 19.5C4.5 19.6381 4.38807 19.75 4.25 19.75C4.11193 19.75 4 19.6381 4 19.5C4 19.3619 4.11193 19.25 4.25 19.25C4.38807 19.25 4.5 19.3619 4.5 19.5Z"}]],lock:[["path",{d:"M4.26781 18.8447C4.49269 20.515 5.87613 21.8235 7.55966 21.9009C8.97627 21.966 10.4153 22 12 22C13.5847 22 15.0237 21.966 16.4403 21.9009C18.1239 21.8235 19.5073 20.515 19.7322 18.8447C19.879 17.7547 20 16.6376 20 15.5C20 14.3624 19.879 13.2453 19.7322 12.1553C19.5073 10.485 18.1239 9.17649 16.4403 9.09909C15.0237 9.03397 13.5847 9 12 9C10.4153 9 8.97627 9.03397 7.55966 9.09909C5.87613 9.17649 4.49269 10.485 4.26781 12.1553C4.12104 13.2453 4 14.3624 4 15.5C4 16.6376 4.12104 17.7547 4.26781 18.8447Z"}],["path",{d:"M7.5 9V6.5C7.5 4.01472 9.51472 2 12 2C14.4853 2 16.5 4.01472 16.5 6.5V9"}],["path",{d:"M12.125 15.5H12M12.25 15.5C12.25 15.6381 12.1381 15.75 12 15.75C11.8619 15.75 11.75 15.6381 11.75 15.5C11.75 15.3619 11.8619 15.25 12 15.25C12.1381 15.25 12.25 15.3619 12.25 15.5Z"}]],mobile:[["path",{d:"M13.5 2H10.5C8.14298 2 6.96447 2 6.23223 2.73223C5.5 3.46447 5.5 4.64298 5.5 7V17C5.5 19.357 5.5 20.5355 6.23223 21.2678C6.96447 22 8.14298 22 10.5 22H13.5C15.857 22 17.0355 22 17.7678 21.2678C18.5 20.5355 18.5 19.357 18.5 17V7C18.5 4.64298 18.5 3.46447 17.7678 2.73223C17.0355 2 15.857 2 13.5 2Z"}],["path",{d:"M12.125 19H12M12.25 19C12.25 19.1381 12.1381 19.25 12 19.25C11.8619 19.25 11.75 19.1381 11.75 19C11.75 18.8619 11.8619 18.75 12 18.75C12.1381 18.75 12.25 18.8619 12.25 19Z"}]],more:[["path",{d:"M12 12.002H12.5M19 12.002H19.5M5 12.002H5.5M12 13.002C12.5523 13.002 13 12.5542 13 12.002C13 11.4497 12.5523 11.002 12 11.002C11.4477 11.002 11 11.4497 11 12.002C11 12.5542 11.4477 13.002 12 13.002ZM19 13.002C19.5523 13.002 20 12.5542 20 12.002C20 11.4497 19.5523 11.002 19 11.002C18.4477 11.002 18 11.4497 18 12.002C18 12.5542 18.4477 13.002 19 13.002ZM5 13.002C5.55228 13.002 6 12.5542 6 12.002C6 11.4497 5.55228 11.002 5 11.002C4.44772 11.002 4 11.4497 4 12.002C4 12.5542 4.44772 13.002 5 13.002Z"}]],play:[["path",{d:"M18.8906 12.846C18.5371 14.189 16.8667 15.138 13.5257 17.0361C10.296 18.8709 8.6812 19.7884 7.37983 19.4196C6.8418 19.2671 6.35159 18.9776 5.95624 18.5787C5 17.6139 5 15.7426 5 12C5 8.2574 5 6.3861 5.95624 5.42132C6.35159 5.02245 6.8418 4.73288 7.37983 4.58042C8.6812 4.21165 10.296 5.12907 13.5257 6.96393C16.8667 8.86197 18.5371 9.811 18.8906 11.154C19.0365 11.7084 19.0365 12.2916 18.8906 12.846Z"}]],pr:[["path",{d:"M6 8L6 16"}],["path",{d:"M18 16V12C18 9.17156 18 7.75735 17.1213 6.87867C16.2426 5.99999 14.8284 5.99999 12 5.99999L11 5.99999M11 5.99999C11 5.29976 12.9943 3.99152 13.5 3.49999M11 5.99999C11 6.70022 12.9943 8.00846 13.5 8.49999"}],["circle",{cx:"6",cy:"18",r:"2"}],["circle",{cx:"6",cy:"6",r:"2"}],["circle",{cx:"18",cy:"18",r:"2"}]],refresh:[["path",{d:"M20.0092 2V5.13219C20.0092 5.42605 19.6418 5.55908 19.4537 5.33333C17.6226 3.2875 14.9617 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22C17.5228 22 22 17.5228 22 12"}]],robot:[["path",{d:"M19 16V14C19 11.1716 19 9.75736 18.1213 8.87868C17.2426 8 15.8284 8 13 8H11C8.17157 8 6.75736 8 5.87868 8.87868C5 9.75736 5 11.1716 5 14V16C5 18.8284 5 20.2426 5.87868 21.1213C6.75736 22 8.17157 22 11 22H13C15.8284 22 17.2426 22 18.1213 21.1213C19 20.2426 19 18.8284 19 16Z"}],["path",{d:"M19 18C20.4142 18 21.1213 18 21.5607 17.5607C22 17.1213 22 16.4142 22 15C22 13.5858 22 12.8787 21.5607 12.4393C21.1213 12 20.4142 12 19 12"}],["path",{d:"M5 18C3.58579 18 2.87868 18 2.43934 17.5607C2 17.1213 2 16.4142 2 15C2 13.5858 2 12.8787 2.43934 12.4393C2.87868 12 3.58579 12 5 12"}],["path",{d:"M13.5 3.5C13.5 4.32843 12.8284 5 12 5C11.1716 5 10.5 4.32843 10.5 3.5C10.5 2.67157 11.1716 2 12 2C12.8284 2 13.5 2.67157 13.5 3.5Z"}],["path",{d:"M12 5V8"}],["path",{d:"M9 13V14"}],["path",{d:"M15 13V14"}],["path",{d:"M10 17.5C10 17.5 10.6667 18 12 18C13.3333 18 14 17.5 14 17.5"}]],settings:[["path",{d:"M15.5 12C15.5 13.933 13.933 15.5 12 15.5C10.067 15.5 8.5 13.933 8.5 12C8.5 10.067 10.067 8.5 12 8.5C13.933 8.5 15.5 10.067 15.5 12Z"}],["path",{d:"M21.011 14.0965C21.5329 13.9558 21.7939 13.8854 21.8969 13.7508C22 13.6163 22 13.3998 22 12.9669V11.0332C22 10.6003 22 10.3838 21.8969 10.2493C21.7938 10.1147 21.5329 10.0443 21.011 9.90358C19.0606 9.37759 17.8399 7.33851 18.3433 5.40087C18.4817 4.86799 18.5509 4.60156 18.4848 4.44529C18.4187 4.28902 18.2291 4.18134 17.8497 3.96596L16.125 2.98673C15.7528 2.77539 15.5667 2.66972 15.3997 2.69222C15.2326 2.71472 15.0442 2.90273 14.6672 3.27873C13.208 4.73448 10.7936 4.73442 9.33434 3.27864C8.95743 2.90263 8.76898 2.71463 8.60193 2.69212C8.43489 2.66962 8.24877 2.77529 7.87653 2.98663L6.15184 3.96587C5.77253 4.18123 5.58287 4.28891 5.51678 4.44515C5.45068 4.6014 5.51987 4.86787 5.65825 5.4008C6.16137 7.3385 4.93972 9.37763 2.98902 9.9036C2.46712 10.0443 2.20617 10.1147 2.10308 10.2492C2 10.3838 2 10.6003 2 11.0332V12.9669C2 13.3998 2 13.6163 2.10308 13.7508C2.20615 13.8854 2.46711 13.9558 2.98902 14.0965C4.9394 14.6225 6.16008 16.6616 5.65672 18.5992C5.51829 19.1321 5.44907 19.3985 5.51516 19.5548C5.58126 19.7111 5.77092 19.8188 6.15025 20.0341L7.87495 21.0134C8.24721 21.2247 8.43334 21.3304 8.6004 21.3079C8.76746 21.2854 8.95588 21.0973 9.33271 20.7213C10.7927 19.2644 13.2088 19.2643 14.6689 20.7212C15.0457 21.0973 15.2341 21.2853 15.4012 21.3078C15.5682 21.3303 15.7544 21.2246 16.1266 21.0133L17.8513 20.034C18.2307 19.8187 18.4204 19.711 18.4864 19.5547C18.5525 19.3984 18.4833 19.132 18.3448 18.5991C17.8412 16.6616 19.0609 14.6226 21.011 14.0965Z"}]],tablet:[["path",{d:"M14.5 2H9.5C6.67157 2 5.25736 2 4.37868 2.87868C3.5 3.75736 3.5 5.17157 3.5 8V16C3.5 18.8284 3.5 20.2426 4.37868 21.1213C5.25736 22 6.67157 22 9.5 22H14.5C17.3284 22 18.7426 22 19.6213 21.1213C20.5 20.2426 20.5 18.8284 20.5 16V8C20.5 5.17157 20.5 3.75736 19.6213 2.87868C18.7426 2 17.3284 2 14.5 2Z"}],["path",{d:"M12.125 19H12M12.25 19C12.25 19.1381 12.1381 19.25 12 19.25C11.8619 19.25 11.75 19.1381 11.75 19C11.75 18.8619 11.8619 18.75 12 18.75C12.1381 18.75 12.25 18.8619 12.25 19Z"}]],trash:[["path",{d:"M19.5 5.5L18.8803 15.5251C18.7219 18.0864 18.6428 19.3671 18.0008 20.2879C17.6833 20.7431 17.2747 21.1273 16.8007 21.416C15.8421 22 14.559 22 11.9927 22C9.42312 22 8.1383 22 7.17905 21.4149C6.7048 21.1257 6.296 20.7408 5.97868 20.2848C5.33688 19.3626 5.25945 18.0801 5.10461 15.5152L4.5 5.5"}],["path",{d:"M3 5.5H21M16.0557 5.5L15.3731 4.09173C14.9196 3.15626 14.6928 2.68852 14.3017 2.39681C14.215 2.3321 14.1231 2.27454 14.027 2.2247C13.5939 2 13.0741 2 12.0345 2C10.9688 2 10.436 2 9.99568 2.23412C9.8981 2.28601 9.80498 2.3459 9.71729 2.41317C9.32164 2.7167 9.10063 3.20155 8.65861 4.17126L8.05292 5.5"}],["path",{d:"M9.5 16.5L9.5 10.5"}],["path",{d:"M14.5 16.5L14.5 10.5"}]],unlink:[["path",{d:"M12.1434 10.691L12.3503 10.4841C14.329 8.50532 17.5372 8.50532 19.5159 10.4841C21.4947 12.4628 21.4947 15.671 19.5159 17.6497L16.6497 20.5159C14.671 22.4947 11.4628 22.4947 9.48405 20.5159C7.50532 18.5372 7.50532 15.329 9.48405 13.3503L9.9484 12.886"}],["path",{d:"M20.0516 11.114L20.5159 10.6497C22.4947 8.67095 22.4947 5.46279 20.5159 3.48405C18.5372 1.50532 15.329 1.50532 13.3503 3.48405L10.4841 6.35031C8.50532 8.32904 8.50532 11.5372 10.4841 13.5159C12.4628 15.4947 15.671 15.4947 17.6497 13.5159L17.8566 13.309"}],["path",{d:"M4.5 4L6 6M2 8L5 9M3 13.5L5 12"}]],x:[["path",{d:"M18 6L6.00081 17.9992M17.9992 18L6 6.00085"}]]};function $({name:e,size:t=16,stroke:r=2,color:n,className:o}){return jsxRuntime.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n??"currentColor",strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",className:o,children:So[e].map(([a,i],s)=>react.createElement(a,{key:s,...i}))})}var Eo=[.16,1,.3,1];function Gs(e){try{let r=new URL(e).pathname.replace(/\/$/,"");return r===""?"/":r}catch{return e}}function tr(e){return e==="pending"||e==="acknowledged"}function Ro({onClose:e}){let t=rt(),{hideResolvedAnnotations:r}=ze(),n=t.focusPin,o=typeof window>"u"?"":ae(window.location.href),a=react.useMemo(()=>[...r?t.entries.filter(d=>d.status!=="resolved"):t.entries].sort((d,p)=>(tr(d.status)?0:1)-(tr(p.status)?0:1)),[t.entries,r]),i=react.useMemo(()=>{let l=t.entries.filter(p=>tr(p.status)&&ae(p.url)===o).length,d=t.entries.filter(p=>tr(p.status)).length;return {here:l,elsewhere:d-l,total:d}},[t.entries,o]);function s(){if(i.total===0)return "No open feedback";let l=[`${i.total} open`];return i.here>0&&l.push(`${i.here} here`),i.elsewhere>0&&l.push(`${i.elsewhere} elsewhere`),l.join(" \xB7 ")}function c(l){e(),n(l);}return jsxRuntime.jsxs(react$1.motion.div,{initial:{opacity:0,y:6,scale:.98},animate:{opacity:1,y:0,scale:1,transition:{duration:.18,ease:Eo}},exit:{opacity:0,y:4,scale:.985,transition:{duration:.12,ease:Eo}},"data-patch-fab-dock":"","data-patch-roster-panel":"",className:"absolute right-0 bottom-[54px] z-[2147483647] flex max-h-[min(480px,calc(100vh-120px))] w-[min(360px,calc(100vw-40px))] flex-col overflow-hidden rounded-xl border border-black/6 bg-popover font-sans text-popover-foreground shadow-[0_20px_56px_-16px_rgba(0,0,0,0.2),0_8px_18px_-6px_rgba(0,0,0,0.08)]",style:{transformOrigin:"100% 100%"},children:[jsxRuntime.jsxs("div",{className:"flex items-baseline justify-between gap-2 px-4 pt-3.5 pb-2.5",children:[jsxRuntime.jsx("span",{className:"text-[13px] font-semibold",children:"Feedback"}),jsxRuntime.jsx("span",{className:"text-[11.5px] font-medium text-popover-foreground/50",children:s()})]}),a.length===0?jsxRuntime.jsx("div",{className:"px-4 pt-2 pb-6 text-center text-[12.5px] text-popover-foreground/50",children:"No feedback yet."}):jsxRuntime.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-1.5 pb-2",children:a.map(l=>jsxRuntime.jsx(Ks,{entry:l,onCurrentPage:ae(l.url)===o,onClick:()=>c(l)},l.id))})]})}function Ks({entry:e,onCurrentPage:t,onClick:r}){let n=e.status==="resolved",o=e.anchorStatus==="detached";return jsxRuntime.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:[jsxRuntime.jsx("span",{className:"mt-0.5 grid size-4 shrink-0 place-items-center",children:n?jsxRuntime.jsx("span",{className:"grid size-4 place-items-center rounded-full bg-brand-green text-white",children:jsxRuntime.jsx($,{name:"check",size:10,stroke:2.6})}):e.status==="dismissed"?jsxRuntime.jsx("span",{className:"size-2 rounded-full border border-black/20"}):jsxRuntime.jsx("span",{className:"size-2 rounded-full bg-brand"})}),jsxRuntime.jsxs("span",{className:"min-w-0 flex-1",children:[jsxRuntime.jsx("span",{className:R("block truncate text-[12.5px] leading-snug",n?"text-popover-foreground/45 line-through":"text-popover-foreground"),children:e.label}),jsxRuntime.jsxs("span",{className:"mt-0.5 flex items-center gap-1.5 text-[11px] text-popover-foreground/50",children:[jsxRuntime.jsx($,{name:we[e.viewport].glyph,size:11,className:"shrink-0 opacity-80"}),jsxRuntime.jsx("span",{className:"truncate",children:t?"This page":Gs(e.url)}),jsxRuntime.jsx("span",{"aria-hidden":"true",children:"\xB7"}),jsxRuntime.jsx("span",{className:"shrink-0",children:er(e.createdAt)}),o?jsxRuntime.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:[jsxRuntime.jsx($,{name:"unlink",size:10}),"element gone"]}):null]})]})]})}var qs="relative inline-grid shrink-0 overflow-hidden place-items-center rounded-full text-white font-semibold tracking-[-0.01em]",js={sm:"size-[22px] text-[9.5px]",md:"size-7 text-[10.5px]"};function $e({initials:e,tint:t,src:r,generatedSeed:n,alt:o="",size:a="md",className:i,style:s}){let{url:c,seed:l}=qt(r),d=l??n;return jsxRuntime.jsxs("span",{className:R(qs,js[a],i),style:{background:t,...s},children:[jsxRuntime.jsx("span",{children:e}),!c&&d?jsxRuntime.jsx(Zt,{seed:d}):null,c?jsxRuntime.jsx("img",{src:c,alt:o,referrerPolicy:"no-referrer",className:"absolute inset-0 size-full rounded-full object-cover",draggable:false,onError:p=>{p.currentTarget.remove();}}):null]})}var Js="M48 0C67.8823 0 84 16.1178 84 36V63C84 67.9706 79.9706 72 75 72H48C42.2522 72 36.8201 70.6505 32 68.2549V87C32 91.9706 27.9706 96 23 96H14C12.8954 96 12 95.1046 12 94V36C12 16.1178 28.1178 0 48 0ZM48 18C38.0589 18 30 26.0589 30 36C30 45.9411 38.0589 54 48 54C57.9411 54 66 45.9411 66 36C66 26.0589 57.9411 18 48 18Z",Qs="M12 2A10 10 0 0 1 22 12V20.6A1.4 1.4 0 0 1 20.6 22H12A10 10 0 0 1 2 12A10 10 0 0 1 12 2Z";function At({size:e=16,className:t}){return jsxRuntime.jsx("svg",{width:e,height:e,viewBox:"0 0 96 96",fill:"currentColor","aria-hidden":"true",focusable:"false",className:t,children:jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:Js})})}function Io({size:e=16,variant:t="filled",stroke:r=2,className:n}){let o=t==="outline";return jsxRuntime.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:jsxRuntime.jsx("path",{d:Qs})})}var Nr=false,Ge=null,nr=null,ke={openDelay:700,isInstant(){return Nr},onOpen(e){nr&&nr!==e&&nr(),nr=e??null,Nr=true,Ge&&(clearTimeout(Ge),Ge=null);},onClose(){Ge&&clearTimeout(Ge),Ge=setTimeout(()=>{Nr=false,Ge=null;},300);}};var Mo="easeOut";function Ce({text:e,children:t,className:r,tone:n="default",placement:o="top"}){let[a,i]=react.useState(false),[s,c]=react.useState(false),l=react.useRef(null),d=react.useRef(false);react.useEffect(()=>()=>{l.current&&clearTimeout(l.current),d.current&&ke.onClose();},[]);let p=k=>{c(k),i(true),d.current=true,ke.onOpen();},u=()=>{if(l.current&&(clearTimeout(l.current),l.current=null),ke.isInstant()){p(true);return}l.current=setTimeout(()=>{l.current=null,p(false);},ke.openDelay);},m=()=>{l.current&&(clearTimeout(l.current),l.current=null),d.current&&(d.current=false,ke.onClose()),i(false);},h=n==="warning"?"pointer-events-none absolute bottom-[calc(100%+8px)] left-0 z-[1]":o==="bottom"?"pointer-events-none absolute top-[calc(100%+8px)] left-1/2 z-[1] -translate-x-1/2":"pointer-events-none absolute -top-[38px] left-1/2 z-[1] -translate-x-1/2",v="shadow-[0_10px_30px_-10px_rgba(0,0,0,0.45),0_3px_8px_-3px_rgba(0,0,0,0.3)] ring-1 ring-white/10",w=n==="warning"?`relative flex w-[200px] items-start gap-1.5 rounded-lg bg-foreground px-3 py-2.5 text-left text-[11px] leading-[1.35] font-medium text-white ${v}`:`relative block whitespace-nowrap rounded-md bg-foreground px-2.5 py-[6px] text-[11px] font-medium tracking-[0.01em] text-white ${v}`,x=n==="warning"?"absolute -bottom-1 left-6 size-2 rotate-45 rounded-[2px] border-r border-b border-white/10 bg-foreground":o==="bottom"?"absolute -top-1 left-1/2 size-2 -translate-x-1/2 rotate-45 rounded-[2px] border-l border-t border-white/10 bg-foreground":"absolute -bottom-1 left-1/2 size-2 -translate-x-1/2 rotate-45 rounded-[2px] border-r border-b border-white/10 bg-foreground",b=o==="bottom"&&n!=="warning"?-3:3,g=o==="bottom"&&n!=="warning"?-2:2;return jsxRuntime.jsxs("span",{className:R("relative inline-flex items-center justify-center",r),onMouseEnter:u,onMouseLeave:m,onMouseDown:m,children:[jsxRuntime.jsx("span",{className:h,children:jsxRuntime.jsx(react$1.AnimatePresence,{children:a&&jsxRuntime.jsxs(react$1.motion.span,{initial:s?false:{opacity:0,y:b,scale:.98},animate:{opacity:1,y:0,scale:1,transition:s?{duration:0}:{duration:.1,ease:Mo}},exit:{opacity:0,y:g,scale:.98,transition:{duration:.08,ease:Mo}},className:w,children:[n==="warning"?jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:"mt-px size-3.5 shrink-0",children:[jsxRuntime.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"}),jsxRuntime.jsx("path",{d:"M12 9v4.5M12 17h.01",fill:"none",stroke:"#fff",strokeWidth:"2",strokeLinecap:"round"})]}):null,jsxRuntime.jsx("span",{className:"min-w-0 flex-1",children:e}),jsxRuntime.jsx("span",{className:x})]})})}),t]})}var Do=44,Pe=[.16,1,.3,1],Lo="easeOut",ol=.08,il=60,al="calc(100% - 64px) calc(100% + 4px)",ct="pkey pkey-dock grid size-8 place-items-center rounded-full border-0 bg-transparent";function Oo(){let e=to(),t=xe(),r=re(),n=rt(),{dockOpen:o,hideResolvedAnnotations:a,setDockOpen:i,setHideResolvedAnnotations:s}=ze(),c=!!r.studio,l=n.unresolvedCount,[d,p]=react.useState(false),[u,m]=react.useState(false),[h,v]=react.useState(false),[w,x]=react.useState(false),[b,g]=react.useState(false),[k,z]=react.useState(false),N=react.useRef(null),f=react.useRef(null),E=react.useRef(false),[Q,Z]=react.useState(false),be=react.useRef(null),[pe,oe]=react.useState(Do);react.useLayoutEffect(()=>{let O=be.current;if(!O)return;let ie=()=>oe(O.offsetWidth);ie();let Te=new ResizeObserver(ie);return Te.observe(O),()=>Te.disconnect()},[]);let ee=r.studio?r.studio.name:r.identity?.name??null,X=nt(ee),C=r.studio?.image??null,I=r.identity?.avatarSeed??r.clientAvatarSeed,M=r.studio?.userId??I,A=r.studio?"var(--color-foreground)":ot(I),D=r.studio&&!C?"#FFFFFF":A,H=r.studio&&!C?"text-foreground":"text-white",S=we[r.activeViewport];function te(){N.current!==null&&(window.clearTimeout(N.current),N.current=null);}function me(){f.current!==null&&(window.clearTimeout(f.current),f.current=null);}let P=react.useRef(()=>{});P.current=()=>{!E.current&&N.current===null||(te(),me(),E.current=false,z(true));};let _=react.useRef(()=>P.current()).current;react.useEffect(()=>{k&&d&&p(false);},[k,d]);function F(O){m(false),v(false),x(false),te(),me(),E.current=true,z(false),g(O),ke.onOpen(_),p(true);}function q(){F(false);}function Se(){if(te(),!(E.current||f.current!==null)){if(ke.isInstant()){F(true);return}f.current=window.setTimeout(()=>{f.current=null,F(false);},ke.openDelay);}}function ge(){me(),te(),E.current&&(E.current=false,ke.onClose()),N.current=window.setTimeout(()=>{p(false),N.current=null;},120);}function Be(){Z(true),i(true);}function Nt(){m(false),v(false),x(false),me(),E.current=false,p(false),e.isCapturing?e.exit():e.enter();}function Mt(){m(false),v(false),me(),E.current=false,p(false),x(O=>{let ie=!O;return ie&&n.refresh(),ie});}function pr(){Z(true),i(false),m(false),v(false),x(false),me(),E.current=false,p(false),e.exit(),t.active&&t.forceClose();}react.useEffect(()=>()=>{N.current!==null&&window.clearTimeout(N.current),f.current!==null&&window.clearTimeout(f.current);},[]);let T=()=>{r.signOut(),p(false);};function L(){v(false),x(false),me(),E.current=false,p(false),m(O=>!O);}function V(O){m(false),r.activeViewport!==O&&(t.active&&t.forceClose(),r.setActiveViewport(O));}function B(){m(false),x(false),me(),E.current=false,p(false),v(O=>!O);}function Y(){s(!a);}function mr(O){let ie=O.relatedTarget;ie instanceof Node&&O.currentTarget.contains(ie)||ge();}return jsxRuntime.jsxs("div",{"data-patch-fab-dock":"",className:"fixed right-5 bottom-5 z-[2147483647] flex justify-end",children:[jsxRuntime.jsxs(react$1.motion.div,{initial:false,animate:{width:o?pe:Do},transition:{duration:.36,ease:Pe},onAnimationComplete:()=>Z(false),whileHover:o?void 0:{scale:1.03,transition:{duration:.15,ease:Pe}},whileTap:o?void 0:{scale:.97,transition:{duration:.1,ease:Pe}},"data-patch-fab-dock":"",className:R("pkey-fab relative h-11 rounded-full",Q?"overflow-hidden":"overflow-visible"),children:[jsxRuntime.jsx(react$1.motion.div,{animate:{opacity:o?0:1,scale:o?.7:1},transition:{duration:.18,ease:Pe},className:R("absolute inset-0",o?"pointer-events-none":"pointer-events-auto"),children:jsxRuntime.jsx("button",{type:"button",onClick:Be,"data-patch-fab-dock":"","aria-label":c&&l>0?`Leave feedback \u2014 ${l} open`:"Leave feedback",className:"grid size-full place-items-center border-0 bg-transparent text-white",children:jsxRuntime.jsx(At,{size:18})})}),jsxRuntime.jsxs("div",{ref:be,"data-patch-fab-dock":"",className:R("absolute inset-y-0 left-0 flex w-max items-center gap-1.5 px-1.5",o?"pointer-events-auto":"pointer-events-none"),children:[jsxRuntime.jsx(dt,{visible:o,index:0,children:jsxRuntime.jsx(Ce,{text:e.isCapturing?"Stop commenting":"Add comment",children:jsxRuntime.jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":e.isCapturing?"Stop commenting":"Add comment","aria-pressed":e.isCapturing,onClick:Nt,className:R(ct,"transition-colors",e.isCapturing?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:jsxRuntime.jsx(Io,{variant:"outline",size:16})})})}),c?jsxRuntime.jsx(dt,{visible:o,index:1,children:jsxRuntime.jsx(Ce,{text:"Feedback",children:jsxRuntime.jsxs("button",{type:"button","data-patch-fab-dock":"","data-patch-roster-btn":"","aria-label":l>0?`Feedback \u2014 ${l} open`:"Feedback","aria-expanded":w,onClick:Mt,className:R(ct,"relative transition-colors",w||l>0?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:[jsxRuntime.jsx($,{name:"list",size:15}),l>0?jsxRuntime.jsx("span",{className:"pointer-events-none absolute -top-0.5 -right-0.5 grid h-[15px] min-w-[15px] place-items-center rounded-full bg-brand px-1 text-[9px] font-semibold text-white",children:l>99?"99+":l}):null]})})}):null,jsxRuntime.jsx(dt,{visible:o,index:2,children:jsxRuntime.jsxs("div",{className:"relative flex items-center",children:[jsxRuntime.jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":`Viewport: ${S.label}`,"aria-expanded":u,onClick:L,className:R(ct,"transition-colors",r.activeViewport==="desktop"&&!u?"text-white/70 hover:bg-white/[0.08] hover:text-white":"bg-brand/15 text-brand"),children:jsxRuntime.jsx($,{name:S.glyph,size:15})}),jsxRuntime.jsx(react$1.AnimatePresence,{children:u?jsxRuntime.jsxs(react$1.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:[jsxRuntime.jsx("span",{className:"pointer-events-none absolute -bottom-1 left-1/2 size-2 -translate-x-1/2 rotate-45 rounded-[2px] border-r border-b border-white/10 bg-foreground"}),qr.map(O=>{let ie=we[O],Te=r.activeViewport===O;return jsxRuntime.jsx(Ce,{text:je(O),children:jsxRuntime.jsx("button",{type:"button","data-patch-viewport-option":O,"aria-label":je(O),"aria-pressed":Te,onClick:()=>V(O),className:R("grid size-8 place-items-center rounded-full border-0 bg-transparent transition-colors",Te?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:jsxRuntime.jsx($,{name:ie.glyph,size:15})})},O)})]}):null})]})}),jsxRuntime.jsx(dt,{visible:o,index:3,children:jsxRuntime.jsxs("div",{className:"relative flex items-center",children:[jsxRuntime.jsx(Ce,{text:"Settings",children:jsxRuntime.jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":"Settings","aria-expanded":h,onClick:B,className:R(ct,"transition-colors",h||a?"bg-brand/15 text-brand":"text-white/70 hover:bg-white/[0.08] hover:text-white"),children:jsxRuntime.jsx($,{name:"settings",size:15})})}),jsxRuntime.jsx(react$1.AnimatePresence,{children:h?jsxRuntime.jsxs(react$1.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:[jsxRuntime.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"}),jsxRuntime.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:[jsxRuntime.jsx("input",{type:"checkbox",checked:a,"aria-label":"Hide resolved annotations",onChange:Y,className:"peer sr-only"}),jsxRuntime.jsx("span",{"aria-hidden":"true",className:R("grid size-4 shrink-0 place-items-center rounded-[5px] border transition-colors",a?"border-brand bg-brand text-white":"border-white/25 bg-white/[0.06] text-transparent"),children:jsxRuntime.jsx($,{name:"check",size:10,stroke:2.4})}),jsxRuntime.jsx("span",{className:"min-w-0 flex-1 whitespace-nowrap",children:"Hide resolved annotations"})]})]}):null})]})}),jsxRuntime.jsx(dt,{visible:o,index:4,children:jsxRuntime.jsxs("span",{"data-patch-identity-hover":"",className:"relative inline-flex items-center justify-center",onMouseEnter:Se,onMouseLeave:ge,onFocus:q,onBlur:mr,children:[jsxRuntime.jsx("button",{type:"button","data-patch-fab-dock":"","data-patch-person-btn":"","aria-label":ee?`Account: ${ee}`:"Identify",className:R(ct,"text-white"),children:ee?jsxRuntime.jsx($e,{initials:X,tint:D,src:C,generatedSeed:M,alt:ee,size:"sm",className:R("size-[22px] text-[9.5px] ring-1 ring-white/20",H)}):jsxRuntime.jsx("span",{className:"grid size-[22px] place-items-center rounded-full border border-white/30 text-[9.5px] font-semibold text-white/70",children:"?"})}),jsxRuntime.jsx(react$1.AnimatePresence,{children:d?jsxRuntime.jsxs(react$1.motion.div,{initial:b?false:{opacity:0,y:3,scale:.98},animate:{opacity:1,y:0,scale:1,transition:b?{duration:0}:{duration:.12,delay:ol,ease:Lo}},exit:{opacity:0,y:2,scale:.98,transition:k?{duration:0}:{duration:.08,ease:Lo}},"data-patch-fab-dock":"","data-patch-identity-popover":"",className:"fixed right-8 bottom-[72px] z-[2147483647] w-[min(272px,calc(100vw-40px))] min-w-[220px] rounded-xl bg-foreground p-3.5 font-sans text-[13px] text-white shadow-[0_18px_44px_-14px_rgba(0,0,0,0.5),0_6px_14px_-6px_rgba(0,0,0,0.45)] ring-1 ring-white/10",style:{transformOrigin:al},children:[jsxRuntime.jsx("span",{className:"absolute bottom-[-4px] size-2 rotate-45 border-r border-b border-white/10 bg-foreground",style:{right:il}}),r.studio?jsxRuntime.jsxs("div",{className:"flex items-center gap-2.5",children:[jsxRuntime.jsx($e,{initials:X,tint:A,src:C,generatedSeed:M,alt:r.studio.name,size:"md"}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("div",{className:"truncate font-medium text-white",children:r.studio.name}),jsxRuntime.jsx("div",{className:"truncate text-xs text-white/55",children:r.studio.email})]})]}):r.identity?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2.5",children:[jsxRuntime.jsx($e,{initials:X,tint:A,generatedSeed:M,size:"md"}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("div",{className:"truncate font-medium text-white",children:r.identity.name}),jsxRuntime.jsx("div",{className:"truncate text-xs text-white/55",children:r.identity.email})]})]}),jsxRuntime.jsx("div",{className:"my-3 h-px bg-white/10"}),jsxRuntime.jsx("button",{type:"button",onClick:T,className:"w-full rounded-full bg-white/[0.08] px-2.5 py-[7px] text-[12.5px] font-medium text-white transition-colors hover:bg-white/[0.13]",children:"Sign out"})]}):jsxRuntime.jsx("div",{className:"text-[12.5px] text-white/60",children:"Not signed in. Drop a pin to introduce yourself."})]}):null})]})}),jsxRuntime.jsx(dt,{visible:o,index:5,children:jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx("span",{className:"h-5 w-px shrink-0 bg-white/12"}),jsxRuntime.jsx(Ce,{text:"Close",children:jsxRuntime.jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":"Close",onClick:pr,className:R(ct,"text-white/70"),children:jsxRuntime.jsx($,{name:"x",size:14})})})]})})]})]}),c&&!o&&l>0?jsxRuntime.jsx("span",{"data-patch-fab-dock":"","data-patch-roster-badge":"","aria-hidden":"true",className:"pointer-events-none absolute -top-1 -right-1 grid h-[18px] min-w-[18px] place-items-center rounded-full bg-brand px-1 text-[10.5px] font-semibold text-white shadow-[0_1px_3px_rgba(0,0,0,0.3)]",children:l>99?"99+":l}):null,jsxRuntime.jsx(react$1.AnimatePresence,{children:w?jsxRuntime.jsx(Ro,{onClose:()=>x(false)}):null})]})}function dt({children:e,visible:t,index:r}){return jsxRuntime.jsx(react$1.motion.div,{initial:{opacity:0,x:6},animate:t?{opacity:1,x:0,transition:{duration:.2,delay:.12+r*.035,ease:Pe}}:{opacity:0,x:6,transition:{duration:.12,ease:Pe}},children:e})}function zo(e,t){return t.width<=0||t.height<=0?{fx:0,fy:0}:{fx:(e.viewportX-t.x)/t.width,fy:(e.viewportY-t.y)/t.height}}function $o(e,t){return {viewportX:t.x+e.fx*t.width,viewportY:t.y+e.fy*t.height}}var ll=.6,cl=.5,ir={text:.4,attrs:.3,classes:.2,position:.1},dl=5e3,ul=.08,pl=.12;function ml(e,t){return t===void 0||t===""?.5:e===t?1:e&&(e.includes(t)||t.includes(e))?.5:0}function gl(e,t){if(!t)return .5;let r=Object.keys(t);if(r.length===0)return .5;let n=0;for(let o of r)e[o]===t[o]&&n++;return n/r.length}function fl(e,t){let r=new Set(e),n=new Set(t??[]);if(r.size===0&&n.size===0)return .5;let o=0;for(let i of r)n.has(i)&&o++;let a=r.size+n.size-o;return a===0?0:o/a}function Fo(e){let t=e.payload.boundingBox;if(!t)return null;let r=e.payload.coordinates.documentY-e.payload.coordinates.viewportY;return {x:t.x+t.width/2,y:t.y+t.height/2+r}}function _r(e,t,r){if(!t)return .5;let n=e.left+e.width/2,o=e.top+r.scrollY+e.height/2,a=(n-t.x)/Math.max(1,r.viewport.width),i=(o-t.y)/Math.max(1,r.viewport.height);return Math.max(0,1-Math.sqrt(a*a+i*i))}function hl(e,t){let r=Ft(e),n=Ht(e),o=Ue(e),a=e.getBoundingClientRect(),i=ml(r,t.payload.domHints?.textSignature),s=gl(n,t.payload.domHints?.attributeSignature),c=fl(o,t.payload.cssClasses),l=_r(a,Fo(t),t);return ir.text*i+ir.attrs*s+ir.classes*c+ir.position*l}function bl(e){let t=e.getBoundingClientRect();return t.width<1&&t.height<1}function Ho(e,t,r){let n=null,o=null,a=0;for(let i=0;i<e.length&&!(a>=dl);i++){let s=e[i];if(!s||(a++,Vt(s,t.internalAttr)))continue;let c=s.tagName.toLowerCase();if(c==="html"||c==="head"||c==="script"||c==="style"||bl(s))continue;let l=hl(s,t);!n||l>n.score?(o=n,n={el:s,score:l}):(!o||l>o.score)&&(o={el:s,score:l});}if(!n||n.score<r)return null;if(o&&n.score-o.score<ul){let i=Fo(t),s=_r(n.el.getBoundingClientRect(),i,t),c=_r(o.el.getBoundingClientRect(),i,t);if(s-c<pl)return null}return n.el}function vl(e){return {viewportX:e.payload.coordinates.viewportX,viewportY:e.payload.coordinates.documentY-e.scrollY}}function xl(e,t){let r=e.getBoundingClientRect();if(!t.payload.boundingBox)return {viewportX:r.x,viewportY:r.y};let n=zo({viewportX:t.payload.coordinates.viewportX,viewportY:t.payload.coordinates.viewportY},t.payload.boundingBox);return $o(n,{x:r.x,y:r.y,width:r.width,height:r.height})}function wl(e){let t=e.payload.domHints?.cssSelector;if(!t)return [];try{return Array.from(e.doc.querySelectorAll(t))}catch{return []}}function ar(e){if(!e.payload.domHints)return {kind:"positional",el:null};let t=wl(e);if(t.length>0){let n=Ho(t,e,cl);if(n)return {kind:"anchored",tier:1,el:n}}let r=Ho(e.doc.querySelectorAll("*"),e,ll);return r?{kind:"anchored",tier:2,el:r}:{kind:"detached",el:null}}function Dr(e,t){return e.kind==="anchored"&&e.el?xl(e.el,t):vl(t)}function Vo(e){let t=ar(e);return {kind:t.kind,tier:t.tier,el:t.el,position:Dr(t,e)}}function Bo(e){if(e.status==="resolved")return null;let t=e.latestRun;return t?t.status==="failed"?"patch-failed":t.status!=="succeeded"?null:t.prClosedUnmerged?"rerun-after-closed":t.prUrl?"review-pr":null:null}var kl="data-patch-internal";function sr(e,t,r){let n=it(r,t.getOverlayViewport()),o=Qt(r,n);e.style.top=`${o.y}px`,e.style.left=`${o.x}px`;}function Uo(e,t){return Math.abs(e.viewportX-t.viewportX)<.5&&Math.abs(e.viewportY-t.viewportY)<.5}function Cl(e){let t=e.getBoundingClientRect();return t.width<1&&t.height<1}function zr(e,t){return {payload:t.payload,doc:e.targetDocument,scrollY:e.getTargetScrollY(),viewport:e.getTargetViewport(),internalAttr:kl}}function Xo(e,t,r){let n=zr(e,t);return {kind:r.kind,position:e.targetPointToOverlay(Dr(r,n))}}function Al(e,t){return e.targetPointToOverlay({viewportX:t.viewportX,viewportY:t.documentY-e.getTargetScrollY()})}function Go(){let{annotations:e,annotationsReady:t,ephemerals:r,identity:n,studio:o,clientAvatarSeed:a,apiClient:i}=re(),s=xe(),{dockOpen:c,hideResolvedAnnotations:l}=ze(),d=ce(),{isPreviewing:p,previewReady:u}=et(),m=react$1.useReducedMotion(),h=s.active,v=s.forceClose,w=t&&(!p||u),x=react.useMemo(()=>c&&t?e.filter(C=>!l||C.status!=="resolved"):[],[c,t,e,l]),b=react.useMemo(()=>c&&t?r:[],[c,t,r]);react.useEffect(()=>{if(!l||h?.kind!=="existing")return;e.find(I=>I.id===h.annotationId)?.status==="resolved"&&v();},[h,e,v,l]);let g=react.useRef(new Map),k=react.useRef(new Map),z=react.useRef(new Map),N=react.useRef(new Map),f=react.useMemo(()=>{let C=N.current,I=new Set,M=new Map;for(let A of x){I.add(A.id);let D=C.get(A.id),S=D?.kind==="positional"||D?.kind==="anchored"&&D.el?.isConnected?D:ar(zr(d,A));C.set(A.id,S),M.set(A.id,Xo(d,A,S));}for(let A of C.keys())I.has(A)||C.delete(A);return M},[d,x]),E=react.useCallback(()=>{let C=N.current,I=z.current,M=new Set;for(let A of x){let D=g.current.get(A.id);if(!D)continue;M.add(A.id);let H=C.get(A.id);if((!H||H.kind==="anchored"&&H.el&&!H.el.isConnected)&&(H=ar(zr(d,A)),C.set(A.id,H)),H.kind==="detached"||H.kind==="anchored"&&H.el&&Cl(H.el)){D.style.visibility!=="hidden"&&(D.style.visibility="hidden"),I.delete(A.id);continue}D.style.visibility==="hidden"&&(D.style.visibility="");let S=Xo(d,A,H).position,te=I.get(A.id);te&&Uo(te,S)||(I.set(A.id,S),sr(D,d,S));}for(let A of b){let D=k.current.get(A.tempId);if(!D)continue;M.add(A.tempId);let H=Al(d,A),S=I.get(A.tempId);S&&Uo(S,H)||(I.set(A.tempId,H),sr(D,d,H));}for(let A of I.keys())M.has(A)||I.delete(A);},[d,x,b]),Q=x.length>0||b.length>0;react.useEffect(()=>{if(!Q)return;let C=d.overlayWindow,I=C.requestAnimationFrame(function M(){E(),I=C.requestAnimationFrame(M);});return ()=>C.cancelAnimationFrame(I)},[Q,E,d]);let Z=react.useRef(new Map);react.useEffect(()=>{if(!t||x.length===0)return;let C=setTimeout(()=>{let I=[];for(let M of x){let A=f.get(M.id);if(!A)continue;let D=A.kind!=="detached";Z.current.get(M.id)!==D&&(Z.current.set(M.id,D),I.push({id:M.id,present:D}));}i.reportAnchorStatuses(I);},1500);return ()=>clearTimeout(C)},[f,x,t,i]);let be=react.useCallback(C=>{if(s.active&&s.draftText.trim().length>0){s.attemptClose();return}s.openExisting(C);},[s]),pe=o?o.name:n?.name??null,oe=o?.image??null,ee=n?.avatarSeed??a,X=o?.userId??ee;return jsxRuntime.jsxs("div",{"data-patch-pin-layer":"",style:{opacity:w?1:0,transition:m||!w?void 0:"opacity 0.2s cubic-bezier(0.22, 0.61, 0.36, 1)",pointerEvents:w?void 0:"none"},children:[jsxRuntime.jsx(react$1.AnimatePresence,{initial:false,children:x.map(C=>{let I=f.get(C.id);if(I?.kind==="detached")return null;let M=Sl(C),A=!o&&!!n?.clientUserId&&C.payload.authorRole==="client"&&C.payload.authorId===n.clientUserId,D=o?Bo(C):null,H=I?it(I.position,d.getOverlayViewport()):"right";return jsxRuntime.jsx(Ir,{ref:S=>{S?(g.current.set(C.id,S),I&&sr(S,d,I.position)):g.current.delete(C.id);},avatarSrc:M.image,generatedSeed:A?ee:M.generatedSeed,avatarAlt:M.name??"",resolved:C.status==="resolved",attention:D,orphan:I?.kind==="positional",pointSide:H,ariaLabel:`Annotation by ${C.authorName??"someone"}`,onClick:()=>be(C.id),pinId:C.id},C.id)})}),jsxRuntime.jsx(react$1.AnimatePresence,{initial:false,children:b.map(C=>{let I=d.targetPointToOverlay({viewportX:C.viewportX,viewportY:C.viewportY});return jsxRuntime.jsx(Ir,{ref:M=>{M?(k.current.set(C.tempId,M),sr(M,d,I)):k.current.delete(C.tempId);},avatarSrc:oe,generatedSeed:X,avatarAlt:pe??"",resolved:false,pointSide:it(I,d.getOverlayViewport()),ephemeral:true},C.tempId)})})]})}function Sl(e){let t=e.authorAvatarSeed??e.payload.authorId??(e.authorName?`annotation-author:${e.authorName}`:null);if(e.authorImage||t||e.authorName)return {name:e.authorName,image:e.authorImage??null,generatedSeed:t??e.id,key:e.payload.authorId??e.authorName??e.id};let r=e.thread.find(n=>n.authorImage||n.authorId||n.authorName);if(r){let n=r.authorAvatarSeed??r.authorId??(r.authorName?`thread-author:${r.authorName}`:null);return {name:r.authorName,image:r.authorImage??null,generatedSeed:n??e.id,key:r.authorId??r.authorName??e.id}}return {name:e.authorName,image:e.authorImage??null,generatedSeed:e.id,key:e.id}}var Pl=5e3;function qo(){let e=rt(),t=re(),r=xe(),n=ze(),o=ce(),a=react$1.useReducedMotion(),i=e.pendingFocus,s=react.useRef(null),c=react.useCallback(()=>{s.current!==null&&(window.clearTimeout(s.current),s.current=null);},[]);return react.useEffect(()=>{if(!i)return;if(ae(window.location.href)!==ae(i.url)){e.clearFocus();return}if(n.dockOpen||n.setDockOpen(true),t.activeViewport!==i.viewport){t.setActiveViewport(i.viewport);return}if(!t.annotationsReady)return;let l=t.annotations.find(p=>p.id===i.id);if(!l){s.current===null&&(s.current=window.setTimeout(()=>{s.current=null,e.clearFocus();},Pl));return}c();let d=l.payload.coordinates?.documentY;if(typeof d=="number"){let p=o.getTargetViewport().height;o.targetWindow.scrollTo({top:Math.max(0,d-p/3),behavior:a?"auto":"smooth"});}r.openExisting(i.id),e.clearFocus();},[i,t,n,o,a,r,e,c]),react.useEffect(()=>()=>c(),[c]),null}var jo=`/*! tailwindcss v4.2.4 | MIT License | https://tailwindcss.com */
|
|
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=react.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]=react.useState(false),l=react.useRef(null),c=react.useRef(t),d=react.useRef(r);c.current=t,d.current=r;let p=react.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);react.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=react.useCallback(()=>{i||a(true);},[i]),h=react.useCallback(()=>{a(false);},[]),f=react.useRef(null);react.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]),react.useEffect(()=>()=>{l.current?.exit(),l.current=null;},[]);let v=react.useMemo(()=>({isCapturing:i,enter:m,exit:h}),[i,m,h]);return jsxRuntime.jsx(On.Provider,{value:v,children:e})}function Hn(){let e=react.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=react.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]=react.useState([]),[c,d]=react.useState(false),[p,u]=react.useState(null),m=react.useRef(r);m.current=r;let h=react.useCallback(async()=>{if(!i){l([]),d(true);return}let b=await m.current.listRoster();l(b),d(true);},[i]);react.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=react.useMemo(()=>s.map(b=>`${b.id}:${b.status}`).sort().join(","),[s]),v=react.useRef(null);react.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=react.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=react.useCallback(()=>u(null),[]),R=react.useMemo(()=>{let b=new Map;for(let L of s)b.set(L.id,L.status);return b},[s]),I=react.useMemo(()=>a.map(b=>{let L=R.get(b.id);return L&&L!==b.status?{...b,status:L}:b}),[a,R]),V=react.useMemo(()=>I.filter(b=>ts(b.status)).length,[I]),N=react.useMemo(()=>({entries:I,ready:c,unresolvedCount:V,refresh:h,focusPin:g,pendingFocus:p,clearFocus:y}),[I,c,V,h,g,p,y]);return jsxRuntime.jsx(Vn.Provider,{value:N,children:t})}function tt(){let e=react.use(Vn);if(!e)throw new Error("useRosterStore must be used inside <RosterProvider>");return e}var Un=react.createContext(null);function Yn({children:e}){let[t,r]=react.useState(false),[n,o]=react.useState(false),s=react.useMemo(()=>({dockOpen:t,hideResolvedAnnotations:n,setDockOpen:r,setHideResolvedAnnotations:o}),[t,n]);return jsxRuntime.jsx(Un.Provider,{value:s,children:e})}function Oe(){let e=react.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 ({ url: (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)) })>"u"?void 0:undefined}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 jn(e){return e.replace(/\s+/g," ").trim()}function yr(e){return ss.has(jn(e))}function Zn(e){if(!e)return null;let t=[],r=e.matchAll(/<([^<>]+)>/g);for(let n of r){let o=jn(n[1]??"");!o||yr(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 cs(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 ds(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=cs(e?.trim()||"patch-client"),r=ds(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=react.useId().replace(/[^a-zA-Z0-9_-]/g,""),s=`${n.id}-${o}`,i=`cav-blur-${s}`,a=`cav-grain-${s}`;return jsxRuntime.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:[jsxRuntime.jsxs("defs",{children:[jsxRuntime.jsx("filter",{id:i,x:"-20%",y:"-20%",width:"140%",height:"140%",children:jsxRuntime.jsx("feGaussianBlur",{stdDeviation:n.blur})}),jsxRuntime.jsxs("filter",{id:a,x:"0%",y:"0%",width:"100%",height:"100%",children:[jsxRuntime.jsx("feTurbulence",{type:"fractalNoise",baseFrequency:"0.9",numOctaves:"2",stitchTiles:"stitch"}),jsxRuntime.jsx("feColorMatrix",{type:"saturate",values:"0"})]}),n.spots.map(l=>jsxRuntime.jsxs("radialGradient",{id:`${s}-${l.id}`,cx:l.cx,cy:l.cy,r:l.r,gradientTransform:l.gradientTransform,children:[jsxRuntime.jsx("stop",{offset:"0%",stopColor:l.color,stopOpacity:l.opacity}),jsxRuntime.jsx("stop",{offset:"100%",stopColor:l.color,stopOpacity:0})]},l.id))]}),jsxRuntime.jsx("rect",{width:"64",height:"64",fill:n.background}),jsxRuntime.jsx("g",{filter:`url(#${i})`,children:n.spots.map(l=>jsxRuntime.jsx("rect",{width:"64",height:"64",fill:`url(#${s}-${l.id})`},l.id))}),jsxRuntime.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 ms={right:"50% 50% 3px 50%",left:"50% 50% 50% 3px"},fs={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?gs[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 jsxRuntime.jsx(react$1.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:jsxRuntime.jsxs("span",{className:"patch-pin relative grid size-full place-items-center","data-patch-point-side":r,style:{borderRadius:ms[r]},children:[jsxRuntime.jsxs("span",{"data-patch-avatar":"",className:"absolute inset-[2px] overflow-hidden",style:{borderRadius:fs[r],background:"var(--color-muted-foreground)"},children:[i?jsxRuntime.jsx(Yt,{seed:i,style:{borderRadius:0,filter:a||"none"}}):null,o?jsxRuntime.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&&jsxRuntime.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&&jsxRuntime.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 gs={"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 jsxRuntime.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)=>react.createElement(s,{key:a,...i}))})}var co=[.16,1,.3,1];function xs(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=react.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=react.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 jsxRuntime.jsxs(react$1.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:[jsxRuntime.jsxs("div",{className:"flex items-baseline justify-between gap-2 px-4 pt-3.5 pb-2.5",children:[jsxRuntime.jsx("span",{className:"text-[13px] font-semibold",children:"Feedback"}),jsxRuntime.jsx("span",{className:"text-[11.5px] font-medium text-popover-foreground/50",children:a()})]}),s.length===0?jsxRuntime.jsx("div",{className:"px-4 pt-2 pb-6 text-center text-[12.5px] text-popover-foreground/50",children:"No feedback yet."}):jsxRuntime.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-1.5 pb-2",children:s.map(c=>jsxRuntime.jsx(ws,{entry:c,onCurrentPage:ae(c.url)===o,onClick:()=>l(c)},c.id))})]})}function ws({entry:e,onCurrentPage:t,onClick:r}){let n=e.status==="resolved",o=e.anchorStatus==="detached";return jsxRuntime.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:[jsxRuntime.jsx("span",{className:"mt-0.5 grid size-4 shrink-0 place-items-center",children:n?jsxRuntime.jsx("span",{className:"grid size-4 place-items-center rounded-full bg-brand-green text-white",children:jsxRuntime.jsx(z,{name:"check",size:10,stroke:2.6})}):e.status==="dismissed"?jsxRuntime.jsx("span",{className:"size-2 rounded-full border border-black/20"}):jsxRuntime.jsx("span",{className:"size-2 rounded-full bg-brand"})}),jsxRuntime.jsxs("span",{className:"min-w-0 flex-1",children:[jsxRuntime.jsx("span",{className:A("block truncate text-[12.5px] leading-snug",n?"text-popover-foreground/45 line-through":"text-popover-foreground"),children:e.label}),jsxRuntime.jsxs("span",{className:"mt-0.5 flex items-center gap-1.5 text-[11px] text-popover-foreground/50",children:[jsxRuntime.jsx(z,{name:we[e.viewport].glyph,size:11,className:"shrink-0 opacity-80"}),jsxRuntime.jsx("span",{className:"truncate",children:t?"This page":xs(e.url)}),jsxRuntime.jsx("span",{"aria-hidden":"true",children:"\xB7"}),jsxRuntime.jsx("span",{className:"shrink-0",children:Kt(e.createdAt)}),o?jsxRuntime.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:[jsxRuntime.jsx(z,{name:"unlink",size:10}),"element gone"]}):null]})]})]})}var ys="relative inline-grid shrink-0 overflow-hidden place-items-center rounded-full text-white font-semibold tracking-[-0.01em]",ks={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 jsxRuntime.jsxs("span",{className:A(ys,ks[s],i),style:{background:t,...a},children:[jsxRuntime.jsx("span",{children:e}),!l&&d?jsxRuntime.jsx(Yt,{seed:d}):null,l?jsxRuntime.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 Ss="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",As="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 jsxRuntime.jsx("svg",{width:e,height:e,viewBox:"0 0 96 96",fill:"currentColor","aria-hidden":"true",focusable:"false",className:t,children:jsxRuntime.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:Ss})})}function po({size:e=16,variant:t="filled",stroke:r=2,className:n}){let o=t==="outline";return jsxRuntime.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:jsxRuntime.jsx("path",{d:As})})}var Ar=false,Ye=null,Zt=null,ke={openDelay:700,isInstant(){return Ar},onOpen(e){Zt&&Zt!==e&&Zt(),Zt=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]=react.useState(false),[a,l]=react.useState(false),c=react.useRef(null),d=react.useRef(false);react.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 jsxRuntime.jsxs("span",{className:A("relative inline-flex items-center justify-center",r),onMouseEnter:u,onMouseLeave:m,onMouseDown:m,children:[jsxRuntime.jsx("span",{className:h,children:jsxRuntime.jsx(react$1.AnimatePresence,{children:s&&jsxRuntime.jsxs(react$1.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"?jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:"mt-px size-3.5 shrink-0",children:[jsxRuntime.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"}),jsxRuntime.jsx("path",{d:"M12 9v4.5M12 17h.01",fill:"none",stroke:"#fff",strokeWidth:"2",strokeLinecap:"round"})]}):null,jsxRuntime.jsx("span",{className:"min-w-0 flex-1",children:e}),jsxRuntime.jsx("span",{className:g})]})})}),t]})}var bo=44,Pe=[.16,1,.3,1],vo="easeOut",Ps=.08,Ns=60,Ms="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]=react.useState(false),[u,m]=react.useState(false),[h,f]=react.useState(false),[v,g]=react.useState(false),[y,R]=react.useState(false),[I,V]=react.useState(false),N=react.useRef(null),b=react.useRef(null),L=react.useRef(false),[Q,Z]=react.useState(false),be=react.useRef(null),[pe,oe]=react.useState(bo);react.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=react.useRef(()=>{});E.current=()=>{!L.current&&N.current===null||(te(),me(),L.current=false,V(true));};let M=react.useRef(()=>E.current()).current;react.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(){Z(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(){Z(true),i(false),m(false),f(false),g(false),me(),L.current=false,p(false),e.exit(),t.active&&t.forceClose();}react.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 jsxRuntime.jsxs("div",{"data-patch-fab-dock":"",className:"fixed right-5 bottom-5 z-[2147483647] flex justify-end",children:[jsxRuntime.jsxs(react$1.motion.div,{initial:false,animate:{width:o?pe:bo},transition:{duration:.36,ease:Pe},onAnimationComplete:()=>Z(false),whileHover:o?void 0:{scale:1.03,transition:{duration:.15,ease:Pe}},whileTap:o?void 0:{scale:.97,transition:{duration:.1,ease:Pe}},"data-patch-fab-dock":"",className:A("pkey-fab relative h-11 rounded-full",Q?"overflow-hidden":"overflow-visible"),children:[jsxRuntime.jsx(react$1.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:jsxRuntime.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:jsxRuntime.jsx(Ct,{size:18})})}),jsxRuntime.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:[jsxRuntime.jsx(ct,{visible:o,index:0,children:jsxRuntime.jsx(Ce,{text:e.isCapturing?"Stop commenting":"Add comment",children:jsxRuntime.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:jsxRuntime.jsx(po,{variant:"outline",size:16})})})}),l?jsxRuntime.jsx(ct,{visible:o,index:1,children:jsxRuntime.jsx(Ce,{text:"Feedback",children:jsxRuntime.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:[jsxRuntime.jsx(z,{name:"list",size:15}),c>0?jsxRuntime.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,jsxRuntime.jsx(ct,{visible:o,index:2,children:jsxRuntime.jsxs("div",{className:"relative flex items-center",children:[jsxRuntime.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:jsxRuntime.jsx(z,{name:C.glyph,size:15})}),jsxRuntime.jsx(react$1.AnimatePresence,{children:u?jsxRuntime.jsxs(react$1.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:[jsxRuntime.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 jsxRuntime.jsx(Ce,{text:Ke(O),children:jsxRuntime.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:jsxRuntime.jsx(z,{name:ie.glyph,size:15})})},O)})]}):null})]})}),jsxRuntime.jsx(ct,{visible:o,index:3,children:jsxRuntime.jsxs("div",{className:"relative flex items-center",children:[jsxRuntime.jsx(Ce,{text:"Settings",children:jsxRuntime.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:jsxRuntime.jsx(z,{name:"settings",size:15})})}),jsxRuntime.jsx(react$1.AnimatePresence,{children:h?jsxRuntime.jsxs(react$1.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:[jsxRuntime.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"}),jsxRuntime.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:[jsxRuntime.jsx("input",{type:"checkbox",checked:s,"aria-label":"Hide resolved annotations",onChange:Y,className:"peer sr-only"}),jsxRuntime.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:jsxRuntime.jsx(z,{name:"check",size:10,stroke:2.4})}),jsxRuntime.jsx("span",{className:"min-w-0 flex-1 whitespace-nowrap",children:"Hide resolved annotations"})]})]}):null})]})}),jsxRuntime.jsx(ct,{visible:o,index:4,children:jsxRuntime.jsxs("span",{"data-patch-identity-hover":"",className:"relative inline-flex items-center justify-center",onMouseEnter:Ae,onMouseLeave:fe,onFocus:q,onBlur:ar,children:[jsxRuntime.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?jsxRuntime.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)}):jsxRuntime.jsx("span",{className:"grid size-[22px] place-items-center rounded-full border border-white/30 text-[9.5px] font-semibold text-white/70",children:"?"})}),jsxRuntime.jsx(react$1.AnimatePresence,{children:d?jsxRuntime.jsxs(react$1.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:Ps,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:Ms},children:[jsxRuntime.jsx("span",{className:"absolute bottom-[-4px] size-2 rotate-45 border-r border-b border-white/10 bg-foreground",style:{right:Ns}}),r.studio?jsxRuntime.jsxs("div",{className:"flex items-center gap-2.5",children:[jsxRuntime.jsx(ze,{initials:G,tint:k,src:w,generatedSeed:P,alt:r.studio.name,size:"md"}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("div",{className:"truncate font-medium text-white",children:r.studio.name}),jsxRuntime.jsx("div",{className:"truncate text-xs text-white/55",children:r.studio.email})]})]}):r.identity?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2.5",children:[jsxRuntime.jsx(ze,{initials:G,tint:k,generatedSeed:P,size:"md"}),jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("div",{className:"truncate font-medium text-white",children:r.identity.name}),jsxRuntime.jsx("div",{className:"truncate text-xs text-white/55",children:r.identity.email})]})]}),jsxRuntime.jsx("div",{className:"my-3 h-px bg-white/10"}),jsxRuntime.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"})]}):jsxRuntime.jsx("div",{className:"text-[12.5px] text-white/60",children:"Not signed in. Drop a pin to introduce yourself."})]}):null})]})}),jsxRuntime.jsx(ct,{visible:o,index:5,children:jsxRuntime.jsxs("div",{className:"flex items-center gap-1.5",children:[jsxRuntime.jsx("span",{className:"h-5 w-px shrink-0 bg-white/12"}),jsxRuntime.jsx(Ce,{text:"Close",children:jsxRuntime.jsx("button",{type:"button","data-patch-fab-dock":"","aria-label":"Close",onClick:ir,className:A(lt,"text-white/70"),children:jsxRuntime.jsx(z,{name:"x",size:14})})})]})})]})]}),l&&!o&&c>0?jsxRuntime.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,jsxRuntime.jsx(react$1.AnimatePresence,{children:v?jsxRuntime.jsx(uo,{onClose:()=>g(false)}):null})]})}function ct({children:e,visible:t,index:r}){return jsxRuntime.jsx(react$1.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 Ls=.6,Ds=.5,Qt={text:.4,attrs:.3,classes:.2,position:.1},Os=5e3,zs=.08,Hs=.12;function $s(e,t){return t===void 0||t===""?.5:e===t?1:e&&(e.includes(t)||t.includes(e))?.5:0}function Fs(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 Vs(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 Bs(e,t){let r=Ft(e),n=$t(e),o=bt(e),s=e.getBoundingClientRect(),i=$s(r,t.payload.domHints?.textSignature),a=Fs(n,t.payload.domHints?.attributeSignature),l=Vs(o,t.payload.cssClasses),c=Er(s,Co(t),t);return Qt.text*i+Qt.attrs*a+Qt.classes*l+Qt.position*c}function Ws(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>=Os);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"||Ws(a))continue;let c=Bs(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<zs){let i=Co(t),a=Er(n.el.getBoundingClientRect(),i,t),l=Er(o.el.getBoundingClientRect(),i,t);if(a-l<Hs)return null}return n.el}function Us(e){return {viewportX:e.payload.coordinates.viewportX,viewportY:e.payload.coordinates.documentY-e.scrollY}}function Ys(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 Gs(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=Gs(e);if(t.length>0){let n=ko(t,e,Ds);if(n)return {kind:"anchored",tier:1,el:n}}let r=ko(e.doc.querySelectorAll("*"),e,Ls);return r?{kind:"anchored",tier:2,el:r}:{kind:"detached",el:null}}function Rr(e,t){return e.kind==="anchored"&&e.el?Ys(e.el,t):Us(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 Ks="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 qs(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:Ks}}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=react$1.useReducedMotion(),h=a.active,f=a.forceClose,v=t&&(!p||u),g=react.useMemo(()=>l&&t?e.filter(w=>!c||w.status!=="resolved"):[],[l,t,e,c]),y=react.useMemo(()=>l&&t?r:[],[l,t,r]);react.useEffect(()=>{if(!c||h?.kind!=="existing")return;e.find(T=>T.id===h.annotationId)?.status==="resolved"&&f();},[h,e,f,c]);let R=react.useRef(new Map),I=react.useRef(new Map),V=react.useRef(new Map),N=react.useRef(new Map),b=react.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=react.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&&qs(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;react.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 Z=react.useRef(new Map);react.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";Z.current.get(P.id)!==D&&(Z.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=react.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 jsxRuntime.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:[jsxRuntime.jsx(react$1.AnimatePresence,{initial:false,children:g.map(w=>{let T=b.get(w.id);if(T?.kind==="detached")return null;let P=Zs(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 jsxRuntime.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)})}),jsxRuntime.jsx(react$1.AnimatePresence,{initial:false,children:y.map(w=>{let T=d.targetPointToOverlay({viewportX:w.viewportX,viewportY:w.viewportY});return jsxRuntime.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 Zs(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 rl=5e3;function Mo(){let e=tt(),t=re(),r=xe(),n=Oe(),o=ce(),s=react$1.useReducedMotion(),i=e.pendingFocus,a=react.useRef(null),l=react.useCallback(()=>{a.current!==null&&(window.clearTimeout(a.current),a.current=null);},[]);return react.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();},rl));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]),react.useEffect(()=>()=>l(),[l]),null}var _o=`/*! tailwindcss v4.2.4 | MIT License | https://tailwindcss.com */
|
|
5
5
|
@layer properties;
|
|
6
6
|
@layer theme, base, components, utilities;
|
|
7
7
|
@layer theme {
|
|
@@ -1233,10 +1233,6 @@
|
|
|
1233
1233
|
--tw-blur: blur(2px);
|
|
1234
1234
|
filter: var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,);
|
|
1235
1235
|
}
|
|
1236
|
-
.grayscale {
|
|
1237
|
-
--tw-grayscale: grayscale(100%);
|
|
1238
|
-
filter: var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,);
|
|
1239
|
-
}
|
|
1240
1236
|
.filter {
|
|
1241
1237
|
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,);
|
|
1242
1238
|
}
|
|
@@ -2015,16 +2011,16 @@ button:not(:disabled):not(.pkey):active {
|
|
|
2015
2011
|
}
|
|
2016
2012
|
}
|
|
2017
2013
|
}
|
|
2018
|
-
`;var Zo="patch-widget-root";function Jo({children:e}){let[t,r]=react.useState(null),n=react.useRef(null);return react.useEffect(()=>{if(typeof document>"u")return;let o=document.querySelector(Zo);o||(o=document.createElement(Zo),o.setAttribute("data-patch-internal",""),document.body.appendChild(o)),n.current=o;let a=o.shadowRoot??o.attachShadow({mode:"open"});if(!a.querySelector("style[data-patch-css]")){let s=document.createElement("style");s.setAttribute("data-patch-css",""),s.textContent=jo,a.appendChild(s);}let i=a.querySelector("div[data-patch-mount]");return i||(i=document.createElement("div"),i.setAttribute("data-patch-mount",""),a.appendChild(i)),r(i),()=>{}},[]),t?reactDom.createPortal(e,t):null}var Ll=/[\s#.:[\]()>+~,\\]/;function Ol(e){return !(!e||Ll.test(e)||/^\d/.test(e))}function zl(e){let t=1,r=e.previousElementSibling,n=e.tagName;for(;r;)r.tagName===n&&t++,r=r.previousElementSibling;return t}function Qo(e,t,r){try{let n=e.querySelectorAll(t);return n.length===1&&n[0]===r}catch{return false}}function $l(e,t){return e.id&&Ol(e.id)&&(!t||Qo(t,`#${e.id}`,e))?`#${e.id}`:`${e.tagName.toLowerCase()}:nth-of-type(${zl(e)})`}function ei(e,t){if(!e.tagName)return "";let r=e.ownerDocument??null,n=[],o=e,a=0;for(;o&&a<12;){let i=$l(o,r);if(n.unshift(i),i.startsWith("#"))break;let s=n.join(" > ");if(r&&Qo(r,s,e))return s;if(o.tagName.toLowerCase()==="html")break;o=o.parentElement,a++;}return n.join(" > ")}var Hl=80,Fl=500;function ri(e){return e!==null&&typeof e=="object"}function Vl(e){return ri(e)?"return"in e||"type"in e||"elementType"in e||"_debugOwner"in e:false}function cr(e){if(typeof e=="function")return e.displayName||e.name||null;if(!ri(e))return null;let t=e.displayName;if(typeof t=="string"&&t)return t;let r=cr(e.render);if(r)return r;let n=cr(e.type);return n||null}function ni(e){return e.replace(/\s+/g," ").trim()}function oi(e,t){return e.length<=t?e:`${e.slice(0,t-1).trim()}\u2026`}function Bl(e){let t=ni(e).replace(/[<>]/g,"");return !t||/^[a-z]/.test(t)?null:oi(t,Hl)}function Wl(e){let t=cr(e.elementType)??cr(e.type);return t?Bl(t):null}function ti(e){return oi(ni(e),Fl)}function Yl(e){let t=e.replace(/\\/g,"/");return t.includes("/.next/")||t.includes("/node_modules/next/")||t.includes("/node_modules/react/")||t.includes("/node_modules/react-dom/")||t.includes("/node_modules/react-router/")||t.includes("/node_modules/react-router-dom/")||t.includes("/node_modules/@remix-run/")||t.includes("/node_modules/.vite/")||/(^|\/)next\/dist\//.test(t)}function Ul(e){let t=e.replace(/^webpack:\/\/[^/]+\//,"").replace(/^file:\/\//,"").replace(/\\/g,"/").replace(/\/\.\//g,"/").replace(/^\.\//,"");for(let n of ["/apps/","/packages/","/src/"]){let o=t.lastIndexOf(n);if(o>=0)return ti(t.slice(o+1))}let r=t.split("/").filter(Boolean);return ti(r.slice(-3).join("/"))}function Xl(e){let t=e._debugSource?.fileName;return typeof t!="string"||!t.trim()||Yl(t)?null:Ul(t)}function Gl(e){let t=e;for(let r of Object.getOwnPropertyNames(e)){if(!r.startsWith("__reactFiber$")&&!r.startsWith("__reactInternalInstance$"))continue;let n=t[r];if(Vl(n))return n}return null}function $r(e){let t=Gl(e);if(!t)return null;let r=[],n=null,o=0;for(;t&&o<30;){let s=Wl(t),c=s?Er(s):false;s&&!c&&r[r.length-1]!==s&&r.push(s),c||(n??=Xl(t)),t=t.return??t._debugOwner??null,o+=1;}let a=r.length>0?fo(r.reverse().map(s=>`<${s}>`).join(" ")):null,i={};return a&&(i.reactComponents=a),n&&(i.sourceFile=n),Object.keys(i).length>0?i:null}var ii=500,ai=3;function Kl(e){return e.length<=ii?e:e.slice(0,ii)}function Hr(e){return {viewportX:e.viewportX,viewportY:e.viewportY,documentY:e.viewportY+e.scrollY,isFixed:false}}function dr(e){return {x:e.x,y:e.y,width:e.width,height:e.height}}function si(e){let t={cssSelector:ei(e)},r=Ft(e);r&&(t.textSignature=r);let n=Ht(e);return Object.keys(n).length>0&&(t.attributeSignature=n),t}function li(e){return e.kind==="element"?xt(e.element,e.selectedText):e.kind==="multi"?Wt(e.elements.length):Yt()}function ci(e){let{target:t,click:r,comment:n,url:o}=e,a=t.element,i=t.rect,s=Pn(a),c=Mn(a),l=Ue(a),d=_n(a),p=$r(a),u={comment:n,element:vt(a),elementPath:Nn(a),targetLabel:xt(a,t.selectedText),timestamp:Date.now(),url:Ne(o),kind:"feedback",coordinates:Hr(r),boundingBox:dr(i),domHints:si(a)};return t.selectedText&&(u.selectedText=Kl(t.selectedText)),c&&(u.nearbyText=c),l.length>0&&(u.cssClasses=l),d.length>0&&(u.nearbyElements=d),s&&(u.accessibility=s),p?.reactComponents&&(u.reactComponents=p.reactComponents),p?.sourceFile&&(u.sourceFile=p.sourceFile),u}function di(e){let{target:t,click:r,comment:n,url:o}=e,a=t.elements.slice(0,ai).map(d=>vt(d)),i=t.elements.length>ai?"\u2026":"",s=`${t.elements.length} elements: ${a.join(", ")}${i}`,c=t.elements[0],l=c?$r(c):null;return {comment:n,element:s,elementPath:s,targetLabel:Wt(t.elements.length),timestamp:Date.now(),url:Ne(o),kind:"feedback",coordinates:Hr(r),boundingBox:dr(t.union),isMultiSelect:true,elementBoundingBoxes:t.rects.map(dr),...l?.reactComponents?{reactComponents:l.reactComponents}:{},...l?.sourceFile?{sourceFile:l.sourceFile}:{},...c?{domHints:si(c)}:{}}}function ui(e){let{target:t,click:r,comment:n,url:o}=e,a=Math.round(t.rect.width),i=Math.round(t.rect.height),s=Math.round(t.rect.x),c=Math.round(t.rect.y);return {comment:n,element:`region ${a}\xD7${i}`,elementPath:`region at (${s}, ${c}) ${a}\xD7${i}`,targetLabel:Yt(),timestamp:Date.now(),url:Ne(o),kind:"feedback",coordinates:Hr(r),boundingBox:dr(t.rect)}}async function Tt(e,t){return e.kind==="composer"?t.createAnnotation(e.payload):t.reply(e.annotationId,{content:e.content})}async function pi(e,t){return t.resolve(e)}async function mi(e,t){return t.deleteAnnotation(e)}async function gi(e,t){return t.deleteMessage(e.annotationId,e.messageId)}async function fi(e,t){return e.viewerKind!=="studio"?null:t.reopen(e.annotationId)}async function hi(e,t){return e.viewerKind!=="studio"?null:t.kickoff(e.annotationId,{guidance:e.guidance})}async function bi(e,t){return t.postIdentity(e)}var wi=react.createContext(null),xi=0;function Vr(e){return xi+=1,`${e}-${Date.now().toString(36)}-${xi}`}function Br(e){return e.deliveryStatus==="sending"||e.deliveryStatus==="failed"}function yi({annotation:e,draftTargetLabel:t,children:r}){let n=re(),o=xe(),a=ce(),[i,s]=react.useState(false),[c,l]=react.useState(null),[d,p]=react.useState(null),u=react.useRef(false),m=e?.thread??[],h=e?.latestRun??null,v=e?.status==="resolved",w=e?Br(e):false,x=n.viewerKind,b=react.useCallback(()=>x==="studio"?{role:"studio",authorId:n.studio?.userId??null,authorName:n.studio?.name??null,authorImage:n.studio?.image??null}:{role:"client",authorId:n.identity?.clientUserId??null,authorName:n.identity?.name??null,authorImage:null},[n.identity,n.studio,x]),g=react.useMemo(()=>b(),[b]),k=!!e&&e.deliveryStatus!=="sending"&&e.deliveryStatus!=="failed"&&!!g.authorId&&e.payload.authorRole===g.role&&e.payload.authorId===g.authorId,z=react.useCallback(T=>{let L=b();return {id:Vr("tmp-msg"),role:L.role,authorId:L.authorId,authorName:L.authorName,authorImage:L.authorImage,content:T,createdAt:new Date().toISOString(),deliveryStatus:"sending"}},[b]),N=react.useCallback(async T=>{if(u.current)return Promise.reject(new Error("busy"));u.current=true,s(true);try{return await T()}finally{u.current=false,s(false);}},[]),f=react.useCallback(async()=>{let T=o.draftText.trim();if(!T)return;if(e){if(v||Br(e))return;let gt=z(T);o.setDraftText(""),n.updateAnnotation(e.id,Le=>({...Le,thread:[...Le.thread,gt]}));let Xr=await Tt({kind:"reply",annotationId:e.id,content:T},n.apiClient);if(Xr){n.updateAnnotation(e.id,Le=>({...Le,thread:Le.thread.map(We=>We.id===gt.id?{...We,id:Xr.id,deliveryStatus:"sent"}:We)})),n.refresh();return}n.updateAnnotation(e.id,Le=>({...Le,thread:Le.thread.map(We=>We.id===gt.id?{...We,deliveryStatus:"failed"}:We)}));return}let L=o.active;if(!L||L.kind!=="composer")return;let V=L.target,B={viewportX:L.anchor.viewportX,viewportY:L.anchor.viewportY,scrollY:L.anchor.documentY-L.anchor.viewportY},Y=a.getPageUrl(),mr=jr(n.activeViewport,a.getTargetViewport()),O=V.kind==="element"?ci({target:V,click:B,comment:T,url:Y}):V.kind==="multi"?di({target:V,click:B,comment:T,url:Y}):ui({target:V,click:B,comment:T,url:Y});O.viewport=n.activeViewport,O.viewportSize=mr;let ie=b(),Te=Vr("tmp-ann");n.applyAnnotationUpdate({id:Te,status:"pending",resolvedBy:null,resolvedAt:null,createdAt:new Date().toISOString(),authorName:ie.authorName,authorImage:ie.authorImage,payload:{...O,authorRole:ie.role,authorId:ie.authorId},thread:[],latestRun:null,deliveryStatus:"sending"}),o.setDraftText(""),o.openExisting(Te);let gr=await Tt({kind:"composer",payload:O},n.apiClient);if(gr){n.replaceAnnotationId(Te,gr.id),o.openExisting(gr.id),n.refresh();return}n.updateAnnotation(Te,gt=>({...gt,deliveryStatus:"failed"}));},[e,b,v,z,n,o,a]),E=react.useCallback(async T=>{if(!e||Br(e))return;let L=e.thread.find(B=>B.id===T);if(!L||L.deliveryStatus!=="failed")return;n.updateAnnotation(e.id,B=>({...B,thread:B.thread.map(Y=>Y.id===T?{...Y,deliveryStatus:"sending"}:Y)}));let V=await Tt({kind:"reply",annotationId:e.id,content:L.content},n.apiClient);if(V){n.updateAnnotation(e.id,B=>({...B,thread:B.thread.map(Y=>Y.id===T?{...Y,id:V.id,deliveryStatus:"sent"}:Y)})),n.refresh();return}n.updateAnnotation(e.id,B=>({...B,thread:B.thread.map(Y=>Y.id===T?{...Y,deliveryStatus:"failed"}:Y)}));},[e,n]),Q=react.useCallback(async()=>{if(!e||e.deliveryStatus!=="failed")return;let T=e.id;n.updateAnnotation(T,V=>({...V,deliveryStatus:"sending"}));let L=await Tt({kind:"composer",payload:e.payload},n.apiClient);if(L){n.replaceAnnotationId(T,L.id),o.openExisting(L.id),n.refresh();return}n.updateAnnotation(T,V=>({...V,deliveryStatus:"failed"}));},[e,n,o]),Z=react.useCallback(T=>!g.authorId||T.deliveryStatus&&T.deliveryStatus!=="sent"?false:T.role===g.role&&T.authorId===g.authorId,[g]),be=react.useCallback(()=>{k&&(l(null),p({kind:"annotation"}));},[k]),pe=react.useCallback(T=>{Z(T)&&(l(null),p({kind:"message",messageId:T.id}));},[Z]),oe=react.useCallback(()=>{l(null),p(null);},[]),ee=react.useCallback(async T=>{if(!e)return false;let L=e.thread;return N(async()=>(l(null),n.updateAnnotation(e.id,B=>({...B,thread:B.thread.filter(Y=>Y.id!==T)})),await gi({annotationId:e.id,messageId:T},n.apiClient)?(n.refresh(),true):(n.updateAnnotation(e.id,B=>({...B,thread:L})),l("Couldn't delete message. Try again."),false)))},[e,n,N]),X=react.useCallback(async()=>!e||!k?false:N(async()=>(l(null),await mi(e.id,n.apiClient)?(n.updateAnnotation(e.id,()=>null),o.forceClose(),n.refresh(),true):(l("Couldn't delete annotation. Try again."),false))),[e,k,n,o,N]),C=react.useCallback(async()=>{if(d)try{(d.kind==="annotation"?await X():await ee(d.messageId))&&p(null);}catch{l("Couldn't delete. Try again.");}},[d,X,ee]),I=react.useCallback(async()=>{e&&await N(async()=>{l(null);let T={status:e.status,resolvedBy:e.resolvedBy,resolvedAt:e.resolvedAt,optimisticAction:e.optimisticAction};if(n.updateAnnotation(e.id,V=>({...V,status:"resolved",resolvedBy:"dev",resolvedAt:new Date().toISOString(),optimisticAction:"resolve-pending"})),!await pi(e.id,n.apiClient)){n.updateAnnotation(e.id,V=>({...V,...T})),l("Couldn't resolve. Try again.");return}n.refresh();});},[e,n,N]),M=react.useCallback(async()=>{e&&await N(async()=>{l(null);let T={status:e.status,resolvedBy:e.resolvedBy,resolvedAt:e.resolvedAt,optimisticAction:e.optimisticAction};if(n.updateAnnotation(e.id,V=>({...V,status:"pending",resolvedBy:null,resolvedAt:null,optimisticAction:"reopen-pending"})),!await fi({annotationId:e.id,viewerKind:x},n.apiClient)){n.updateAnnotation(e.id,V=>({...V,...T})),l("Couldn't reopen. Try again.");return}n.refresh();});},[e,x,n,N]),A=react.useCallback(async T=>{e&&await N(async()=>{l(null);let L=e.latestRun,V=e.optimisticAction;n.updateAnnotation(e.id,Y=>({...Y,latestRun:{id:Vr("tmp-run"),status:"queued",prUrl:null,createdAt:new Date().toISOString(),completedAt:null,prClosedUnmerged:false},optimisticAction:"run-pending"}));let B=await hi({annotationId:e.id,viewerKind:x,guidance:T},n.apiClient);if(!B?.ok){n.updateAnnotation(e.id,Y=>({...Y,latestRun:L,optimisticAction:V})),l(B?.error??"Couldn't start Patch. Try again.");return}n.refresh();});},[e,x,n,N]),D=react.useCallback(async T=>{let L=await bi({...T,avatarSeed:n.clientAvatarSeed},n.apiClient);return L&&await n.setIdentity(L),L},[n]),S=x==="client"&&!n.identity&&m.length===0,te=!!e||m.length>0,me=n.agentRunReadiness?.ready??true,P=n.agentRunReadiness?.message??null,_=react.useCallback(()=>{if(o.draftText.trim().length>0){o.setConfirmDiscardOpen(true);return}o.forceClose();},[o]),F=e?zn(e.payload):t||"annotation",q=e?.payload.viewport??n.activeViewport,Se=n.studio?n.studio.name:n.identity?.name??null,ge=n.identity?.avatarSeed??n.clientAvatarSeed,Be=n.studio?.userId??ge,Nt=n.studio?.image??null,Mt=n.studio?.userId??ge,pr=react.useMemo(()=>({state:{annotation:e,messages:m,runState:h,draftText:o.draftText,busy:i,actionError:c,confirmDiscardOpen:o.confirmDiscardOpen,confirmDelete:d,showDevFooter:x==="studio",agentRunReady:me,agentRunSetupMessage:P,needsIdentity:S,isResolved:v,initialMessageLocked:w,threadVisible:te,canDeleteAnnotation:k},actions:{setDraftText:o.setDraftText,submit:f,retryMessage:E,retryInitialMessage:Q,requestDeleteAnnotation:be,requestDeleteMessage:pe,canDeleteMessage:Z,cancelDelete:oe,confirmDelete:C,markResolved:I,reopen:M,runPatch:A,setIdentity:D,attemptClose:o.attemptClose,requestClose:_,forceClose:o.forceClose,setConfirmDiscardOpen:o.setConfirmDiscardOpen},meta:{targetLabel:F,viewport:q,shakeNonce:o.shakeNonce,viewer:{kind:x,authorId:g.authorId,name:Se,avatarKey:Be,avatarSrc:Nt,generatedSeed:Mt}}}),[e,m,h,o.draftText,o.confirmDiscardOpen,o.setDraftText,o.attemptClose,o.forceClose,o.setConfirmDiscardOpen,o.shakeNonce,i,c,d,f,E,Q,be,pe,Z,oe,C,I,M,A,D,x,me,P,S,v,w,te,k,_,F,q,g.authorId,Se,Be,Nt,Mt]);return jsxRuntime.jsx(wi.Provider,{value:pr,children:r})}function K(){let e=react.use(wi);if(!e)throw new Error("useThreadContext must be used inside <ThreadProvider>");return e}var ec="inline-flex shrink-0 items-center justify-center gap-1.5 h-8 px-3.5 rounded-lg whitespace-nowrap text-[13px] font-semibold transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none",tc={brand:"pkey pkey-brand text-white",brandTint:"bg-brand-tint text-brand hover:bg-brand-tint/70",destructive:"pkey pkey-destructive text-white",destructiveTint:"bg-destructive/10 text-destructive hover:bg-destructive/15",successTint:"bg-brand-green/10 text-brand-green hover:bg-brand-green/15",warn:"pkey pkey-warn text-white",warnTint:"bg-brand-orange/10 text-brand-orange hover:bg-brand-orange/15",neutral:"pkey pkey-outline text-foreground",subtle:"bg-black/8 text-muted-foreground"};function Et(e="brand",t){return R(ec,tc[e],t)}function fe({variant:e="brand",className:t,type:r="button",ref:n,...o}){return jsxRuntime.jsx("button",{ref:n,type:r,className:Et(e,t),...o})}function Ci(){let{state:e,actions:t}=K(),r=e.confirmDelete;if(!r)return null;let n=r.kind==="annotation",o=n?"Delete annotation?":"Delete message?",a=n?"This removes the annotation and its thread for everyone.":"This removes your message from the thread.",i=n?"Delete annotation":"Delete message";return jsxRuntime.jsx("div",{className:"absolute inset-0 z-40 flex items-start justify-end bg-black/25 p-3 backdrop-blur-[2px]",children:jsxRuntime.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:[jsxRuntime.jsx("div",{className:"text-[13.5px] font-medium text-foreground",children:o}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:a}),e.actionError?jsxRuntime.jsx("div",{className:"text-[11px] font-medium text-destructive",children:e.actionError}):null,jsxRuntime.jsxs("div",{className:"mt-1 flex justify-end gap-2",children:[jsxRuntime.jsx(fe,{variant:"neutral",disabled:e.busy,onClick:t.cancelDelete,children:"Cancel"}),jsxRuntime.jsx(fe,{variant:"destructive",disabled:e.busy,onClick:t.confirmDelete,children:e.busy?"Deleting\u2026":i})]})]})})}function Si(){let{state:e,actions:t}=K();return e.confirmDiscardOpen?jsxRuntime.jsx("div",{className:"absolute inset-0 z-20 flex items-start justify-end bg-black/25 p-3 backdrop-blur-[2px]",children:jsxRuntime.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:[jsxRuntime.jsx("div",{className:"text-[13.5px] font-medium text-foreground",children:"Discard draft?"}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:"You'll lose what you've typed."}),jsxRuntime.jsxs("div",{className:"mt-1 flex justify-end gap-2",children:[jsxRuntime.jsx(fe,{variant:"neutral",onClick:()=>t.setConfirmDiscardOpen(false),children:"Keep editing"}),jsxRuntime.jsx(fe,{variant:"destructive",onClick:()=>t.forceClose(),children:"Discard"})]})]})}):null}var nc="inline-grid place-items-center rounded-full transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",oc={sm:"size-7",md:"size-8"},ic={default:"text-muted-foreground hover:bg-black/6 hover:text-foreground",warn:"bg-amber-500/15 text-amber-700"};function Fe({size:e="sm",tone:t="default",className:r,type:n="button",ref:o,...a}){return jsxRuntime.jsx("button",{ref:o,type:n,className:R(nc,oc[e],ic[t],r),...a})}function Ti(){let{state:e}=K();return !e.showDevFooter||!e.annotation?null:jsxRuntime.jsxs("div",{className:"-mt-[22px] flex flex-col gap-2 bg-neutral-100/50 px-3 pt-[2.125rem] pb-3",children:[jsxRuntime.jsxs("div",{className:"flex items-start justify-between gap-2",children:[jsxRuntime.jsx(sc,{}),jsxRuntime.jsx("div",{className:"flex shrink-0 items-center gap-1",children:jsxRuntime.jsx(cc,{})})]}),e.actionError?jsxRuntime.jsx("div",{className:"px-1 text-[11px] font-medium text-destructive",children:e.actionError}):null]})}function sc(){let{state:e,actions:t}=K(),[r,n]=react.useState(false),[o,a]=react.useState(""),[i,s]=react.useState(false),c=e.runState,l=c?.status;if(e.annotation?.status==="resolved")return jsxRuntime.jsx("div",{className:"min-w-0 flex-1"});let p=l==="queued"||l==="running",u=l==="succeeded"&&!!c?.prUrl&&!c.prClosedUnmerged,m=c?"Run Patch again":"Run Patch",h=l==="failed"?"destructiveTint":"brand",v=!e.agentRunReady,w=async()=>{try{s(!0),await t.runPatch(o.trim()||void 0),a(""),n(!1);}finally{s(false);}};if(p)return jsxRuntime.jsx("div",{className:"min-w-0 flex-1",children:jsxRuntime.jsxs(fe,{variant:"brandTint",disabled:true,children:[jsxRuntime.jsx("span",{className:"patch-fade-in size-[7px] rounded-full bg-brand"}),"Patch is working\u2026"]})});if(u){let b=Ao(c.prUrl);return jsxRuntime.jsx("div",{className:"min-w-0 flex-1",children:jsxRuntime.jsxs("a",{href:c.prUrl,target:"_blank",rel:"noopener noreferrer",className:Et("brand","no-underline"),children:[jsxRuntime.jsx($,{name:"pr",size:12}),b==="PR"?"View PR":`View PR ${b}`]})})}let x=jsxRuntime.jsxs(fe,{variant:h,disabled:e.busy||v,className:v?"opacity-60":void 0,onClick:()=>n(true),children:[jsxRuntime.jsx(At,{size:12})," ",m]});return jsxRuntime.jsxs("div",{className:"min-w-0 flex-1",children:[v&&e.agentRunSetupMessage?jsxRuntime.jsx(Ce,{text:e.agentRunSetupMessage,tone:"warning",children:x}):x,r?jsxRuntime.jsx(lc,{title:m,guidance:o,submitting:i||e.busy,onGuidanceChange:a,onCancel:()=>n(false),onSubmit:w}):null]})}function lc({title:e,guidance:t,submitting:r,onGuidanceChange:n,onCancel:o,onSubmit:a}){return jsxRuntime.jsxs("div",{className:"absolute inset-0 z-30 flex items-center justify-center p-4",children:[jsxRuntime.jsx("button",{type:"button","aria-label":"Close guidance",className:"absolute inset-0 cursor-default bg-black/25 backdrop-blur-[2px]",onClick:o}),jsxRuntime.jsxs("form",{role:"dialog","aria-label":e,className:"patch-fade-in relative flex w-full max-w-[280px] flex-col gap-3 rounded-xl bg-popover p-4 shadow-dialog",onSubmit:i=>{i.preventDefault(),a();},children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsxRuntime.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[jsxRuntime.jsx("span",{className:"grid size-7 shrink-0 place-items-center rounded-lg bg-brand text-white",children:jsxRuntime.jsx(At,{size:13})}),jsxRuntime.jsx("span",{className:"truncate text-[13.5px] font-medium text-foreground",children:e})]}),jsxRuntime.jsx(Fe,{size:"sm",title:"Close",onClick:o,children:jsxRuntime.jsx($,{name:"x",size:12})})]}),jsxRuntime.jsxs("label",{className:"flex flex-col gap-1.5",children:[jsxRuntime.jsx("span",{className:"text-[12px] font-medium text-muted-foreground",children:"Guidance"}),jsxRuntime.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"})]}),jsxRuntime.jsxs("div",{className:"flex justify-end gap-2",children:[jsxRuntime.jsx(fe,{variant:"neutral",disabled:r,onClick:o,children:"Cancel"}),jsxRuntime.jsx(fe,{type:"submit",variant:"brand",disabled:r,children:r?"Starting\u2026":"Start run"})]})]})]})}function cc(){let{state:e,actions:t}=K();return e.annotation?e.annotation.status==="resolved"?jsxRuntime.jsxs(fe,{variant:"neutral",disabled:e.busy,onClick:()=>t.reopen(),children:[jsxRuntime.jsx($,{name:"refresh",size:12}),"Reopen"]}):jsxRuntime.jsxs(fe,{variant:"neutral",disabled:e.busy,onClick:()=>t.markResolved(),children:[jsxRuntime.jsx($,{name:"check",size:12}),"Resolve"]}):null}var dc={desktop:"Desktop",tablet:"Tablet",mobile:"Mobile"};function _e(e,t){let r=e?.replace(/\s+/g," ").trim();return r?r.length<=t?r:`${r.slice(0,t-1)}...`:null}function Ei(e){let t=e?.trim();return t||null}function Ke(e){return Number.isInteger(e)?String(e):e.toFixed(1)}function uc(e){let t=e.viewport??"desktop",r=dc[t],n=e.viewportSize;return n?`${r} (${n.width}x${n.height})`:r}function pc(e){let t=e.coordinates,r=[`viewport (${Ke(t.viewportX)}, ${Ke(t.viewportY)})`,`documentY ${Ke(t.documentY)}`];return t.isFixed&&r.push("fixed"),r.join(", ")}function mc(e){let t=e.boundingBox;return t?`x ${Ke(t.x)}, y ${Ke(t.y)}, ${Ke(t.width)}x${Ke(t.height)}`:null}function gc(e){let t=e.domHints?.attributeSignature;if(!t)return null;let r=Object.entries(t).slice(0,12).map(([n,o])=>`${n}="${_e(o,120)??""}"`);return r.length>0?r.join(", "):null}function fc(e){let t=[`- Page: ${e.url}`,`- Element: ${_e(e.elementPath||e.element,500)??"unknown"}`,`- Viewport: ${uc(e)}`,`- Anchor: ${pc(e)}`],r=_e(e.targetLabel,160),n=mc(e);return r&&t.push(`- Visible target: ${r}`),n&&t.push(`- Bounding box: ${n}`),`## Target
|
|
2014
|
+
`;var Lo="patch-widget-root";function Do({children:e}){let[t,r]=react.useState(null),n=react.useRef(null);return react.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?reactDom.createPortal(e,t):null}var sl=/[\s#.:[\]()>+~,\\]/;function ll(e){return !(!e||sl.test(e)||/^\d/.test(e))}function cl(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 dl(e,t){return e.id&&ll(e.id)&&(!t||Oo(t,`#${e.id}`,e))?`#${e.id}`:`${e.tagName.toLowerCase()}:nth-of-type(${cl(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=dl(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 ul=80,pl=500;function $o(e){return e!==null&&typeof e=="object"}function ml(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 fl(e){let t=Fo(e).replace(/[<>]/g,"");return !t||/^[a-z]/.test(t)?null:Vo(t,ul)}function gl(e){let t=nr(e.elementType)??nr(e.type);return t?fl(t):null}function Ho(e){return Vo(Fo(e),pl)}function hl(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 bl(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 vl(e){let t=e._debugSource?.fileName;return typeof t!="string"||!t.trim()||hl(t)?null:bl(t)}function xl(e){let t=e;for(let r of Object.getOwnPropertyNames(e)){if(!r.startsWith("__reactFiber$")&&!r.startsWith("__reactInternalInstance$"))continue;let n=t[r];if(ml(n))return n}return null}function Bo(e){let t=xl(e);if(!t)return null;let r=[],n=null,o=0;for(;t&&o<30;){let a=gl(t),l=a?yr(a):false;a&&!l&&r[r.length-1]!==a&&r.push(a),l||(n??=vl(t)),t=t.return??t._debugOwner??null,o+=1;}let s=r.length>0?Zn(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 wl(e){return e.length<=Wo?e:e.slice(0,Wo)}function yl(e){return {viewportX:e.viewportX,viewportY:e.viewportY,documentY:e.viewportY+e.scrollY,isFixed:false}}function kl(e){return {x:e.x,y:e.y,width:e.width,height:e.height}}function Cl(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:yl(r),boundingBox:kl(i),domHints:Cl(s)};return t.selectedText&&(u.selectedText=wl(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 jo(e,t){return e.viewerKind!=="studio"?null:t.kickoff(e.annotationId,{guidance:e.guidance})}async function Zo(e,t){return t.postIdentity(e)}var ei=react.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]=react.useState(false),[l,c]=react.useState(null),[d,p]=react.useState(null),u=react.useRef(false),m=e?.thread??[],h=e?.latestRun??null,f=e?.status==="resolved",v=e?Lr(e):false,g=n.viewerKind,y=react.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=react.useMemo(()=>y(),[y]),I=!!e&&e.deliveryStatus!=="sending"&&e.deliveryStatus!=="failed"&&!!R.authorId&&e.payload.authorRole===R.role&&e.payload.authorId===R.authorId,V=react.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=react.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=react.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=react.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=react.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]),Z=react.useCallback(S=>!R.authorId||S.deliveryStatus&&S.deliveryStatus!=="sent"?false:S.role===R.role&&S.authorId===R.authorId,[R]),be=react.useCallback(()=>{I&&(c(null),p({kind:"annotation"}));},[I]),pe=react.useCallback(S=>{Z(S)&&(c(null),p({kind:"message",messageId:S.id}));},[Z]),oe=react.useCallback(()=>{c(null),p(null);},[]),ee=react.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=react.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=react.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=react.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=react.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=react.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 jo({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=react.useCallback(async S=>{let _=await Zo({...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=react.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=react.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:Z,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,Z,oe,w,T,P,k,D,g,me,E,C,f,v,te,I,M,$,q,R.authorId,Ae,Ve,Pt,Nt]);return jsxRuntime.jsx(ei.Provider,{value:ir,children:r})}function K(){let e=react.use(ei);if(!e)throw new Error("useThreadContext must be used inside <ThreadProvider>");return e}var Il="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",Pl={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(Il,Pl[e],t)}function ge({variant:e="brand",className:t,type:r="button",ref:n,...o}){return jsxRuntime.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 jsxRuntime.jsx("div",{className:"absolute inset-0 z-40 flex items-start justify-end bg-black/25 p-3 backdrop-blur-[2px]",children:jsxRuntime.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:[jsxRuntime.jsx("div",{className:"text-[13.5px] font-medium text-foreground",children:o}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:s}),e.actionError?jsxRuntime.jsx("div",{className:"text-[11px] font-medium text-destructive",children:e.actionError}):null,jsxRuntime.jsxs("div",{className:"mt-1 flex justify-end gap-2",children:[jsxRuntime.jsx(ge,{variant:"neutral",disabled:e.busy,onClick:t.cancelDelete,children:"Cancel"}),jsxRuntime.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?jsxRuntime.jsx("div",{className:"absolute inset-0 z-20 flex items-start justify-end bg-black/25 p-3 backdrop-blur-[2px]",children:jsxRuntime.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:[jsxRuntime.jsx("div",{className:"text-[13.5px] font-medium text-foreground",children:"Discard draft?"}),jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:"You'll lose what you've typed."}),jsxRuntime.jsxs("div",{className:"mt-1 flex justify-end gap-2",children:[jsxRuntime.jsx(ge,{variant:"neutral",onClick:()=>t.setConfirmDiscardOpen(false),children:"Keep editing"}),jsxRuntime.jsx(ge,{variant:"destructive",onClick:()=>t.forceClose(),children:"Discard"})]})]})}):null}var Ml="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",_l={sm:"size-7",md:"size-8"},Ll={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 jsxRuntime.jsx("button",{ref:o,type:n,className:A(Ml,_l[e],Ll[t],r),...s})}function ai(){let{state:e}=K();return !e.showDevFooter||!e.annotation?null:jsxRuntime.jsxs("div",{className:"-mt-[22px] flex flex-col gap-2 bg-neutral-100/50 px-3 pt-[2.125rem] pb-3",children:[jsxRuntime.jsxs("div",{className:"flex items-start justify-between gap-2",children:[jsxRuntime.jsx(Ol,{}),jsxRuntime.jsx("div",{className:"flex shrink-0 items-center gap-1",children:jsxRuntime.jsx(Hl,{})})]}),e.actionError?jsxRuntime.jsx("div",{className:"px-1 text-[11px] font-medium text-destructive",children:e.actionError}):null]})}function Ol(){let{state:e,actions:t}=K(),[r,n]=react.useState(false),[o,s]=react.useState(""),[i,a]=react.useState(false),l=e.runState,c=l?.status;if(e.annotation?.status==="resolved")return jsxRuntime.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 jsxRuntime.jsx("div",{className:"min-w-0 flex-1",children:jsxRuntime.jsxs(ge,{variant:"brandTint",disabled:true,children:[jsxRuntime.jsx("span",{className:"patch-fade-in size-[7px] rounded-full bg-brand"}),"Patch is working\u2026"]})});if(u){let y=ao(l.prUrl);return jsxRuntime.jsx("div",{className:"min-w-0 flex-1",children:jsxRuntime.jsxs("a",{href:l.prUrl,target:"_blank",rel:"noopener noreferrer",className:Tt("brand","no-underline"),children:[jsxRuntime.jsx(z,{name:"pr",size:12}),y==="PR"?"View PR":`View PR ${y}`]})})}let g=jsxRuntime.jsxs(ge,{variant:h,disabled:e.busy||f,className:f?"opacity-60":void 0,onClick:()=>n(true),children:[jsxRuntime.jsx(Ct,{size:12})," ",m]});return jsxRuntime.jsxs("div",{className:"min-w-0 flex-1",children:[f&&e.agentRunSetupMessage?jsxRuntime.jsx(Ce,{text:e.agentRunSetupMessage,tone:"warning",children:g}):g,r?jsxRuntime.jsx(zl,{title:m,guidance:o,submitting:i||e.busy,onGuidanceChange:s,onCancel:()=>n(false),onSubmit:v}):null]})}function zl({title:e,guidance:t,submitting:r,onGuidanceChange:n,onCancel:o,onSubmit:s}){return jsxRuntime.jsxs("div",{className:"absolute inset-0 z-30 flex items-center justify-center p-4",children:[jsxRuntime.jsx("button",{type:"button","aria-label":"Close guidance",className:"absolute inset-0 cursor-default bg-black/25 backdrop-blur-[2px]",onClick:o}),jsxRuntime.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:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-2",children:[jsxRuntime.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[jsxRuntime.jsx("span",{className:"grid size-7 shrink-0 place-items-center rounded-lg bg-brand text-white",children:jsxRuntime.jsx(Ct,{size:13})}),jsxRuntime.jsx("span",{className:"truncate text-[13.5px] font-medium text-foreground",children:e})]}),jsxRuntime.jsx($e,{size:"sm",title:"Close",onClick:o,children:jsxRuntime.jsx(z,{name:"x",size:12})})]}),jsxRuntime.jsxs("label",{className:"flex flex-col gap-1.5",children:[jsxRuntime.jsx("span",{className:"text-[12px] font-medium text-muted-foreground",children:"Guidance"}),jsxRuntime.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"})]}),jsxRuntime.jsxs("div",{className:"flex justify-end gap-2",children:[jsxRuntime.jsx(ge,{variant:"neutral",disabled:r,onClick:o,children:"Cancel"}),jsxRuntime.jsx(ge,{type:"submit",variant:"brand",disabled:r,children:r?"Starting\u2026":"Start run"})]})]})]})}function Hl(){let{state:e,actions:t}=K();return e.annotation?e.annotation.status==="resolved"?jsxRuntime.jsxs(ge,{variant:"neutral",disabled:e.busy,onClick:()=>t.reopen(),children:[jsxRuntime.jsx(z,{name:"refresh",size:12}),"Reopen"]}):jsxRuntime.jsxs(ge,{variant:"neutral",disabled:e.busy,onClick:()=>t.markResolved(),children:[jsxRuntime.jsx(z,{name:"check",size:12}),"Resolve"]}):null}var $l={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 Fl(e){let t=e.viewport??"desktop",r=$l[t],n=e.viewportSize;return n?`${r} (${n.width}x${n.height})`:r}function Vl(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 Bl(e){let t=e.boundingBox;return t?`x ${Ge(t.x)}, y ${Ge(t.y)}, ${Ge(t.width)}x${Ge(t.height)}`:null}function Wl(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 Ul(e){let t=[`- Page: ${e.url}`,`- Element: ${Me(e.elementPath||e.element,500)??"unknown"}`,`- Viewport: ${Fl(e)}`,`- Anchor: ${Vl(e)}`],r=Me(e.targetLabel,160),n=Bl(e);return r&&t.push(`- Visible target: ${r}`),n&&t.push(`- Bounding box: ${n}`),`## Target
|
|
2019
2015
|
${t.join(`
|
|
2020
|
-
`)}`}function
|
|
2021
|
-
${t}`:null}function
|
|
2022
|
-
`)}`}function
|
|
2023
|
-
${e.map(
|
|
2024
|
-
`)}`}function
|
|
2016
|
+
`)}`}function Yl(e){let t=Me(e.selectedText,1500);return t?`## Selected text
|
|
2017
|
+
${t}`:null}function Gl(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 Xl(e){return e.length===0?null:`## Thread
|
|
2019
|
+
${e.map(Gl).join(`
|
|
2020
|
+
`)}`}function Kl(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=Wl(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
|
|
2025
2021
|
${t.join(`
|
|
2026
|
-
`)}`:null}function
|
|
2027
|
-
${
|
|
2022
|
+
`)}`:null}function li(e){return ["Address this feedback in the repository.",`## Feedback
|
|
2023
|
+
${si(e.payload.comment)??"(no feedback text)"}`,Ul(e.payload),Yl(e.payload),Xl(e.thread),Kl(e.payload)].filter(Boolean).join(`
|
|
2028
2024
|
|
|
2029
|
-
`)}function Pi(){let{state:e,meta:t}=K(),r=e.annotation,n=we[t.viewport],o=r?.payload.selectedText;return jsxRuntime.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:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-3",children:[jsxRuntime.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[jsxRuntime.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}),jsxRuntime.jsx(Ce,{text:je(t.viewport),placement:"bottom",children:jsxRuntime.jsx("span",{"data-patch-thread-viewport":t.viewport,role:"img","aria-label":je(t.viewport),className:"inline-flex shrink-0 items-center text-brand",children:jsxRuntime.jsx($,{name:n.glyph,size:15,stroke:1.8})})})]}),jsxRuntime.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.isResolved?jsxRuntime.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:[jsxRuntime.jsx($,{name:"check",size:10})," Resolved"]}):null,jsxRuntime.jsxs("div",{className:"ml-0.5 flex items-center gap-0.5",children:[e.showDevFooter&&r?jsxRuntime.jsx(Cc,{annotation:r}):null,jsxRuntime.jsx(Sc,{}),jsxRuntime.jsx(Ac,{})]})]})]}),o?jsxRuntime.jsx("div",{className:"rounded-lg bg-white px-3 py-2 shadow-[0_0_0_1px_rgba(0,0,0,0.06)]",children:jsxRuntime.jsx("div",{className:"border-l-[2.5px] border-black/16 pl-2.5 text-[12.5px] leading-[1.45] text-muted-foreground",children:o.length>200?`${o.slice(0,199).trim()}\u2026`:o})}):null]})}async function kc(e,t){try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}let r=t.createElement("textarea");r.value=e,r.setAttribute("readonly",""),r.style.position="fixed",r.style.top="-9999px",r.style.left="-9999px",t.body.appendChild(r),r.select();try{return t.execCommand("copy")}catch{return false}finally{r.remove();}}function Cc({annotation:e}){let[t,r]=react.useState(false),n=react.useRef(null);react.useEffect(()=>()=>{n.current&&clearTimeout(n.current);},[]);let o=async a=>{await kc(Ri(e),a)&&(r(true),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>r(false),1500));};return jsxRuntime.jsx(Ce,{text:t?"Copied":"Copy agent prompt",placement:"bottom",children:jsxRuntime.jsx(Fe,{"aria-label":t?"Copied agent prompt":"Copy agent prompt",onClick:a=>{o(a.currentTarget.ownerDocument);},children:jsxRuntime.jsxs("span",{className:"relative block",style:{width:14,height:14},children:[jsxRuntime.jsx("span",{className:R("absolute inset-0 grid place-items-center transition-all duration-200 ease-out",t?"scale-50 opacity-0 blur-[2px]":"scale-100 opacity-100 blur-0"),children:jsxRuntime.jsx($,{name:"copy",size:14})}),jsxRuntime.jsx("span",{className:R("absolute inset-0 grid place-items-center text-brand-green transition-all duration-200 ease-out",t?"scale-100 opacity-100 blur-0":"scale-50 opacity-0 blur-[2px]"),children:jsxRuntime.jsx($,{name:"check",size:13})})]})})})}function Ac(){let{actions:e}=K();return jsxRuntime.jsx(Fe,{onClick:e.requestClose,title:"Close",children:jsxRuntime.jsx($,{name:"x",size:14})})}function Sc(){let{state:e,actions:t}=K(),[r,n]=react.useState(false);return e.canDeleteAnnotation?jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx(Fe,{title:"Annotation actions","aria-label":"Annotation actions","aria-expanded":r,"aria-haspopup":"menu",onClick:()=>n(o=>!o),children:jsxRuntime.jsx($,{name:"more",size:14})}),r?jsxRuntime.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:jsxRuntime.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:[jsxRuntime.jsx($,{name:"trash",size:13}),"Delete annotation"]})}):null]}):null}function Li(){let{state:e,actions:t,meta:r}=K(),n=react.useRef(null),o=r.viewer.kind==="client"?r.viewer.generatedSeed:null,a=r.viewer.kind==="client"?r.viewer.authorId:null;return react.useEffect(()=>{let s=n.current;s&&(s.scrollTop=s.scrollHeight);}),e.threadVisible?jsxRuntime.jsxs("div",{ref:n,"data-patch-thread-scroller":"",className:R("flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto bg-white px-4 pt-3.5 pb-3",e.showDevFooter&&e.isResolved&&"relative z-[1] rounded-b-xl shadow-[0_6px_12px_-5px_rgba(0,0,0,0.16)]"),children:[e.annotation?jsxRuntime.jsx(_i,{name:e.annotation.authorName??"Someone",createdAt:e.annotation.createdAt,content:e.annotation.payload.comment,authorKey:e.annotation.payload.authorId??e.annotation.authorName??e.annotation.id,avatarSrc:e.annotation.authorImage,generatedSeed:e.annotation.payload.authorRole==="client"&&e.annotation.payload.authorId===a?o:e.annotation.authorAvatarSeed??e.annotation.payload.authorId??null,deliveryStatus:e.annotation.deliveryStatus,onRetry:e.annotation.deliveryStatus==="failed"?t.retryInitialMessage:void 0}):null,e.messages.map(s=>jsxRuntime.jsx(_i,{name:s.authorName??s.role,createdAt:s.createdAt,content:s.content,authorKey:s.authorId??s.authorName??s.role,avatarSrc:s.authorImage,generatedSeed:s.role==="client"&&s.authorId===a?o:s.authorAvatarSeed??s.authorId,deliveryStatus:s.deliveryStatus,canDelete:t.canDeleteMessage(s),onDelete:()=>t.requestDeleteMessage(s),onRetry:s.deliveryStatus==="failed"?()=>{t.retryMessage(s.id);}:void 0},s.id))]}):null}function _i(e){let t=nt(e.name),r=ot(e.authorKey),n=e.deliveryStatus==="failed";return jsxRuntime.jsxs("div",{className:"group/message flex gap-2.5",children:[jsxRuntime.jsx($e,{initials:t,tint:r,src:e.avatarSrc,generatedSeed:e.generatedSeed,alt:e.name}),jsxRuntime.jsxs("div",{className:"relative min-w-0 flex-1 pr-8",children:[jsxRuntime.jsxs("div",{className:"flex items-baseline gap-1.5",children:[jsxRuntime.jsx("span",{className:"text-[12.5px] font-medium text-foreground",children:e.name}),jsxRuntime.jsx("span",{className:"text-[11px] text-muted-foreground",children:er(e.createdAt)})]}),e.canDelete&&e.onDelete?jsxRuntime.jsx(Ic,{onDelete:e.onDelete}):null,jsxRuntime.jsx("p",{className:"mt-0.5 whitespace-pre-wrap text-[13px] leading-[1.45] text-foreground",children:e.content}),n?jsxRuntime.jsxs("div",{className:"mt-1 flex items-center gap-2 text-[11px] leading-none",children:[jsxRuntime.jsx("span",{className:"text-destructive",children:"Failed to send"}),e.onRetry?jsxRuntime.jsx("button",{type:"button",onClick:e.onRetry,className:"rounded-full bg-black/8 px-2 py-1 font-medium text-foreground transition-colors hover:bg-black/12",children:"Retry"}):null]}):null]})]})}var Ec=44,Rc=8;function Ic({onDelete:e}){let[t,r]=react.useState(false),[n,o]=react.useState("down"),a=react.useRef(null),i=react.useCallback(()=>{let c=a.current,l=c?.closest("[data-patch-thread-scroller]");if(!c||!l){o("down");return}let d=c.getBoundingClientRect(),p=l.getBoundingClientRect(),u=p.bottom-d.bottom,m=d.top-p.top;o(u<Ec+Rc&&m>u?"up":"down");},[]),s=react.useCallback(()=>{r(c=>{let l=!c;return l&&i(),l});},[i]);return jsxRuntime.jsxs("div",{className:"absolute top-[-5px] right-0 opacity-0 transition-opacity group-focus-within/message:opacity-100 group-hover/message:opacity-100",children:[jsxRuntime.jsx(Fe,{ref:a,size:"sm",title:"Message actions","aria-label":"Message actions","aria-expanded":t,"aria-haspopup":"menu",onClick:s,children:jsxRuntime.jsx($,{name:"more",size:14})}),t?jsxRuntime.jsx("div",{role:"menu",className:R("patch-fade-in absolute right-0 z-[5] min-w-36 rounded-xl bg-popover p-1 shadow-dialog ring-1 ring-black/6",n==="up"?"bottom-full mb-1":"top-full mt-1"),children:jsxRuntime.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:[jsxRuntime.jsx($,{name:"trash",size:13}),"Delete"]})}):null]})}var Pc={default:"w-full min-h-[60px] resize-y rounded-md border border-border bg-popover px-3 py-2 text-[13px] leading-[1.45] text-foreground outline-none transition-colors placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",bare:"w-full resize-none self-center overflow-y-auto bg-transparent border-0 outline-none text-[13px] leading-normal text-foreground placeholder:text-muted-foreground"};function Oi({variant:e="default",className:t,ref:r,...n}){return jsxRuntime.jsx("textarea",{ref:r,className:R(Pc[e],t),...n})}var Dc=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,zi="w-full rounded-md border border-border bg-popover px-2.5 py-2 text-[13px] text-foreground outline-none transition-colors focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring";function $i(){let{actions:e}=K(),[t,r]=react.useState(""),[n,o]=react.useState(""),[a,i]=react.useState(null),[s,c]=react.useState(false),l=react.useRef(null);return react.useEffect(()=>{setTimeout(()=>l.current?.focus(),0);},[]),jsxRuntime.jsxs("form",{onSubmit:async p=>{p.preventDefault();let u=t.trim(),m=n.trim();if(!u){i("Name is required.");return}if(!Dc.test(m)){i("Enter a valid email.");return}i(null),c(true);let h=await e.setIdentity({name:u,email:m});c(false),h||i("Could not save identity. Try again.");},className:"flex flex-col gap-2",children:[jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:"Tell us who you are so the team can reply."}),jsxRuntime.jsx("input",{ref:l,type:"text",placeholder:"Name",value:t,onChange:p=>r(p.target.value),className:zi}),jsxRuntime.jsx("input",{type:"email",placeholder:"Email",value:n,onChange:p=>o(p.target.value),className:zi}),a?jsxRuntime.jsx("div",{className:"text-xs text-destructive",children:a}):null,jsxRuntime.jsx("button",{type:"submit",disabled:s,className:R(Et("brand"),"self-end",s&&"cursor-not-allowed opacity-60"),children:s?"Saving\u2026":"Continue"})]})}function Fi(){let{state:e,actions:t,meta:r}=K(),n=react.useRef(null),[o,a]=react.useState(false);if(react.useEffect(()=>{e.needsIdentity||setTimeout(()=>n.current?.focus(),0);},[e.needsIdentity]),react.useEffect(()=>{let u=n.current;if(!u)return;u.style.height="0px";let m=Math.min(u.scrollHeight,140);u.style.height=`${m}px`,a(m>28);},[e.draftText]),e.isResolved||e.initialMessageLocked)return null;if(e.needsIdentity)return jsxRuntime.jsx("div",{className:R("bg-white px-4 py-3",e.threadVisible&&"border-t border-black/6"),children:jsxRuntime.jsx($i,{})});let i=e.draftText.trim().length>0,s=r.viewer.name,c=nt(s),l=r.viewer.kind==="studio"?"var(--color-foreground)":ot(r.viewer.avatarKey),d=u=>{u.preventDefault(),t.submit();},p=u=>{u.key==="Enter"&&!u.shiftKey&&(u.preventDefault(),t.submit());};return jsxRuntime.jsx("form",{onSubmit:d,className:R("bg-white p-3",e.threadVisible&&"border-t border-black/6",e.showDevFooter&&"relative z-[1] rounded-b-xl shadow-[0_6px_12px_-5px_rgba(0,0,0,0.16)]"),children:jsxRuntime.jsxs("div",{className:R("flex items-end gap-2 bg-black/4 px-3 py-2.5 transition-colors",o?"rounded-xl":"rounded-full"),children:[jsxRuntime.jsx($e,{initials:c,tint:l,src:r.viewer.avatarSrc,generatedSeed:r.viewer.generatedSeed,alt:s??"",className:"self-start"}),jsxRuntime.jsx(Oi,{ref:n,variant:"bare",value:e.draftText,onChange:u=>t.setDraftText(u.target.value),onKeyDown:p,rows:1,placeholder:e.annotation?"Reply\u2026":"What should change?",style:{maxHeight:"140px"}}),jsxRuntime.jsx($c,{enabled:i})]})})}function $c({enabled:e}){return jsxRuntime.jsx("button",{type:"submit",disabled:!e,"aria-label":"Send",className:R("grid size-7 shrink-0 place-items-center rounded-full text-white",e?"pkey pkey-brand":"bg-black/16 transition-colors"),children:jsxRuntime.jsx($,{name:"arrow-up",size:13})})}var Yc=[.4,0,.2,1],Uc=[.22,.61,.36,1],Xc={x:-8,y:-8,origin:"top left"},Bi=200;function Wi(e,t,r){return Math.max(t,Math.min(r,e))}function Yi(e,t,r){let n={x:e.x+e.width/2,y:e.y+e.height/2},o={x:t.x+t.width/2,y:t.y+r/2};return {x:Wi((n.x-o.x)*.08,-12,12),y:Wi((n.y-o.y)*.12,-10,10),origin:`${n.y<o.y?"top":"bottom"} ${n.x<o.x?"left":"right"}`}}function Gc(e,t){if(!t)return Xc;let r=yt({anchor:t,popover:{width:332,height:Bi},viewport:e.getOverlayViewport()});return Yi(t,r,Bi)}function Kc(e,t){return e.x===t.x&&e.y===t.y&&e.origin===t.origin}function Ui({getAnchorRect:e,initialAnchorRect:t,entryDelay:r=0,children:n}){let{actions:{attemptClose:o},meta:{shakeNonce:a}}=K(),i=ce(),s=react.useRef(null),[c,l]=react.useState(()=>Gc(i,t??e())),d=react.useCallback(()=>{let m=s.current;if(!m)return;let h=e();if(!h)return;let v=m.offsetHeight||200,w=yt({anchor:h,popover:{width:332,height:v},viewport:i.getOverlayViewport()});m.style.left=`${w.x}px`,m.style.top=`${w.y}px`,m.style.right="auto";let x=Yi(h,w,v);l(b=>Kc(b,x)?b:x);},[e,i]);react.useLayoutEffect(()=>{d();}),react.useEffect(()=>{let m=null,h=()=>{m===null&&(m=i.overlayWindow.requestAnimationFrame(()=>{m=null,d();}));},v=new Set([i.targetWindow,i.overlayWindow]);for(let x of v)x.addEventListener("resize",h),x.addEventListener("scroll",h,{passive:true});let w=gn(i.overlayWindow,h);return w.observe(i.overlayDocument.body),i.targetDocument.body!==i.overlayDocument.body&&w.observe(i.targetDocument.body),s.current&&w.observe(s.current),()=>{m!==null&&i.overlayWindow.cancelAnimationFrame(m);for(let x of v)x.removeEventListener("resize",h),x.removeEventListener("scroll",h);w.disconnect();}},[d,i]),react.useEffect(()=>{let m=w=>{Co(w)||o();},h=w=>{w.key==="Escape"&&o();},v=new Set([i.targetDocument,i.overlayDocument]);for(let w of v)w.addEventListener("mousedown",m,true),w.addEventListener("keydown",h);return ()=>{for(let w of v)w.removeEventListener("mousedown",m,true),w.removeEventListener("keydown",h);}},[o,i]);let p=react.useRef(a);react.useEffect(()=>{if(a===p.current)return;p.current=a;let m=s.current;m&&(m.classList.remove("patch-shake"),m.offsetWidth,m.classList.add("patch-shake"));},[a]);let u={width:`${332}px`,height:"auto",transformOrigin:c.origin};return jsxRuntime.jsx(react$1.motion.div,{ref:s,layout:true,initial:{opacity:0,x:c.x,y:c.y,scale:.985},animate:{opacity:1,x:0,y:0,scale:1,transition:{type:"spring",stiffness:560,damping:34,mass:.7,delay:r}},exit:{opacity:0,x:c.x,y:c.y,scale:.985,transition:{duration:.16,ease:Yc}},transition:{layout:{duration:.42,ease:Uc}},onLayoutAnimationComplete:d,"data-patch-popover":"",role:"dialog","aria-label":"Annotation thread",className:"fixed z-[2147483646] flex flex-col overflow-hidden rounded-xl border border-black/6 bg-popover font-sans text-popover-foreground shadow-[0_20px_56px_-16px_rgba(0,0,0,0.2),0_8px_18px_-6px_rgba(0,0,0,0.08)]",style:u,children:n})}var le={Root:Ui,Header:Pi,Messages:Li,Reply:Fi,DevFooter:Ti,ConfirmDiscard:Si,ConfirmDelete:Ci};function Xi({getAnchorRect:e,initialAnchorRect:t,entryDelay:r}){return jsxRuntime.jsxs(le.Root,{getAnchorRect:e,initialAnchorRect:t,entryDelay:r,children:[jsxRuntime.jsx(le.Header,{}),jsxRuntime.jsx(le.Messages,{}),jsxRuntime.jsx(le.Reply,{}),jsxRuntime.jsx(le.ConfirmDiscard,{}),jsxRuntime.jsx(le.ConfirmDelete,{})]})}function Gi({getAnchorRect:e,initialAnchorRect:t,entryDelay:r}){return jsxRuntime.jsxs(le.Root,{getAnchorRect:e,initialAnchorRect:t,entryDelay:r,children:[jsxRuntime.jsx(le.Header,{}),jsxRuntime.jsx(le.Messages,{}),jsxRuntime.jsx(le.Reply,{}),jsxRuntime.jsx(le.DevFooter,{}),jsxRuntime.jsx(le.ConfirmDiscard,{}),jsxRuntime.jsx(le.ConfirmDelete,{})]})}var ed="data-patch-internal";function ji(e,t,r){let n={viewportX:t,viewportY:r},o=it(n,e.getOverlayViewport());return Qt(n,o)}function td(e,t){return e.overlayDocument.querySelector("patch-widget-root")?.shadowRoot?.querySelector(t)??null}function rd(e,t){let r=td(e,`[data-patch-pin-id="${t}"]`);if(!r)return null;let n=r.getBoundingClientRect();return {x:n.x,y:n.y,width:n.width,height:n.height}}function nd(e,t){if(!t)return null;let r=Vo({payload:t.payload,doc:e.targetDocument,scrollY:e.getTargetScrollY(),viewport:e.getTargetViewport(),internalAttr:ed}),n=e.targetPointToOverlay(r.position);return ji(e,n.viewportX,n.viewportY)}function qi(e,t,r){if(!t)return null;if(t.kind==="existing")return rd(e,t.annotationId)??nd(e,r);let n=e.targetPointToOverlay({viewportX:t.anchor.viewportX,viewportY:t.anchor.documentY-e.getTargetScrollY()});return ji(e,n.viewportX,n.viewportY)}function Zi(){let e=xe(),t=re(),r=ce(),n=e.active,o=react.useMemo(()=>!n||n.kind!=="existing"?null:t.annotations.find(p=>p.id===n.annotationId)??null,[n,t.annotations]),a=react.useCallback(()=>qi(r,n,o),[n,o,r]),i=t.viewerKind==="studio"?Gi:Xi,s=n&&(n.kind==="composer"||!!o),c=n?.kind==="composer"?.04:0,l=n?.kind==="composer"?li(n.target):null,d=react.useMemo(()=>qi(r,n,o),[n,o,r]);return jsxRuntime.jsx(react$1.AnimatePresence,{children:s?jsxRuntime.jsx(yi,{annotation:o,draftTargetLabel:l,children:jsxRuntime.jsx(i,{getAnchorRect:a,initialAnchorRect:d,entryDelay:c})},"active-popover"):null})}var ad="https://app.usepatch.dev";function sd({children:e}){let{active:t}=re();return t?e:null}function Ji(e){let t=typeof window<"u"&&mn(window),r=react.useMemo(()=>uo({prop:e.projectToken,processEnv:mo(),importMetaEnv:po()}),[e.projectToken]),n=e.apiBase??ad;return react.useEffect(()=>{r||console.warn(co);},[r]),t||!r?null:jsxRuntime.jsx(Jo,{children:jsxRuntime.jsx(fn,{children:jsxRuntime.jsx(Cn,{projectToken:r,apiBase:n,children:jsxRuntime.jsx(sd,{children:jsxRuntime.jsx(Sn,{children:jsxRuntime.jsx(lo,{children:jsxRuntime.jsx(io,{projectToken:r,children:jsxRuntime.jsxs(eo,{children:[jsxRuntime.jsx(Go,{}),jsxRuntime.jsx(Zi,{}),jsxRuntime.jsx(qo,{}),jsxRuntime.jsx(Oo,{})]})})})})})})})})}var ld=Ji;
|
|
2030
|
-
exports.Patch=
|
|
2025
|
+
`)}function di(){let{state:e,meta:t}=K(),r=e.annotation,n=we[t.viewport],o=r?.payload.selectedText;return jsxRuntime.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:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between gap-3",children:[jsxRuntime.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[jsxRuntime.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}),jsxRuntime.jsx(Ce,{text:Ke(t.viewport),placement:"bottom",children:jsxRuntime.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:jsxRuntime.jsx(z,{name:n.glyph,size:15,stroke:1.8})})})]}),jsxRuntime.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.isResolved?jsxRuntime.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:[jsxRuntime.jsx(z,{name:"check",size:10})," Resolved"]}):null,jsxRuntime.jsxs("div",{className:"ml-0.5 flex items-center gap-0.5",children:[e.showDevFooter&&r?jsxRuntime.jsx(Jl,{annotation:r}):null,jsxRuntime.jsx(ec,{}),jsxRuntime.jsx(Ql,{})]})]})]}),o?jsxRuntime.jsx("div",{className:"rounded-lg bg-white px-3 py-2 shadow-[0_0_0_1px_rgba(0,0,0,0.06)]",children:jsxRuntime.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 Zl(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 Jl({annotation:e}){let[t,r]=react.useState(false),n=react.useRef(null);react.useEffect(()=>()=>{n.current&&clearTimeout(n.current);},[]);let o=async s=>{await Zl(li(e),s)&&(r(true),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>r(false),1500));};return jsxRuntime.jsx(Ce,{text:t?"Copied":"Copy agent prompt",placement:"bottom",children:jsxRuntime.jsx($e,{"aria-label":t?"Copied agent prompt":"Copy agent prompt",onClick:s=>{o(s.currentTarget.ownerDocument);},children:jsxRuntime.jsxs("span",{className:"relative block",style:{width:14,height:14},children:[jsxRuntime.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:jsxRuntime.jsx(z,{name:"copy",size:14})}),jsxRuntime.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:jsxRuntime.jsx(z,{name:"check",size:13})})]})})})}function Ql(){let{actions:e}=K();return jsxRuntime.jsx($e,{onClick:e.requestClose,title:"Close",children:jsxRuntime.jsx(z,{name:"x",size:14})})}function ec(){let{state:e,actions:t}=K(),[r,n]=react.useState(false);return e.canDeleteAnnotation?jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx($e,{title:"Annotation actions","aria-label":"Annotation actions","aria-expanded":r,"aria-haspopup":"menu",onClick:()=>n(o=>!o),children:jsxRuntime.jsx(z,{name:"more",size:14})}),r?jsxRuntime.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:jsxRuntime.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:[jsxRuntime.jsx(z,{name:"trash",size:13}),"Delete annotation"]})}):null]}):null}function gi(){let{state:e,actions:t,meta:r}=K(),n=react.useRef(null),o=r.viewer.kind==="client"?r.viewer.generatedSeed:null,s=r.viewer.kind==="client"?r.viewer.authorId:null;return react.useEffect(()=>{let a=n.current;a&&(a.scrollTop=a.scrollHeight);}),e.threadVisible?jsxRuntime.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?jsxRuntime.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=>jsxRuntime.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 jsxRuntime.jsxs("div",{className:"group/message flex gap-2.5",children:[jsxRuntime.jsx(ze,{initials:t,tint:r,src:e.avatarSrc,generatedSeed:e.generatedSeed,alt:e.name}),jsxRuntime.jsxs("div",{className:"relative min-w-0 flex-1 pr-8",children:[jsxRuntime.jsxs("div",{className:"flex items-baseline gap-1.5",children:[jsxRuntime.jsx("span",{className:"text-[12.5px] font-medium text-foreground",children:e.name}),jsxRuntime.jsx("span",{className:"text-[11px] text-muted-foreground",children:Kt(e.createdAt)})]}),e.canDelete&&e.onDelete?jsxRuntime.jsx(oc,{onDelete:e.onDelete}):null,jsxRuntime.jsx("p",{className:"mt-0.5 whitespace-pre-wrap text-[13px] leading-[1.45] text-foreground",children:e.content}),n?jsxRuntime.jsxs("div",{className:"mt-1 flex items-center gap-2 text-[11px] leading-none",children:[jsxRuntime.jsx("span",{className:"text-destructive",children:"Failed to send"}),e.onRetry?jsxRuntime.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 rc=44,nc=8;function oc({onDelete:e}){let[t,r]=react.useState(false),[n,o]=react.useState("down"),s=react.useRef(null),i=react.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<rc+nc&&m>u?"up":"down");},[]),a=react.useCallback(()=>{r(l=>{let c=!l;return c&&i(),c});},[i]);return jsxRuntime.jsxs("div",{className:"absolute top-[-5px] right-0 opacity-0 transition-opacity group-focus-within/message:opacity-100 group-hover/message:opacity-100",children:[jsxRuntime.jsx($e,{ref:s,size:"sm",title:"Message actions","aria-label":"Message actions","aria-expanded":t,"aria-haspopup":"menu",onClick:a,children:jsxRuntime.jsx(z,{name:"more",size:14})}),t?jsxRuntime.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:jsxRuntime.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:[jsxRuntime.jsx(z,{name:"trash",size:13}),"Delete"]})}):null]})}var ic={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 jsxRuntime.jsx("textarea",{ref:r,className:A(ic[e],t),...n})}var cc=/^[^\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]=react.useState(""),[n,o]=react.useState(""),[s,i]=react.useState(null),[a,l]=react.useState(false),c=react.useRef(null);return react.useEffect(()=>{setTimeout(()=>c.current?.focus(),0);},[]),jsxRuntime.jsxs("form",{onSubmit:async p=>{p.preventDefault();let u=t.trim(),m=n.trim();if(!u){i("Name is required.");return}if(!cc.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:[jsxRuntime.jsx("div",{className:"text-xs text-muted-foreground",children:"Tell us who you are so the team can reply."}),jsxRuntime.jsx("input",{ref:c,type:"text",placeholder:"Name",value:t,onChange:p=>r(p.target.value),className:bi}),jsxRuntime.jsx("input",{type:"email",placeholder:"Email",value:n,onChange:p=>o(p.target.value),className:bi}),s?jsxRuntime.jsx("div",{className:"text-xs text-destructive",children:s}):null,jsxRuntime.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=react.useRef(null),[o,s]=react.useState(false);if(react.useEffect(()=>{e.needsIdentity||setTimeout(()=>n.current?.focus(),0);},[e.needsIdentity]),react.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 jsxRuntime.jsx("div",{className:A("bg-white px-4 py-3",e.threadVisible&&"border-t border-black/6"),children:jsxRuntime.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 jsxRuntime.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:jsxRuntime.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:[jsxRuntime.jsx(ze,{initials:l,tint:c,src:r.viewer.avatarSrc,generatedSeed:r.viewer.generatedSeed,alt:a??"",className:"self-start"}),jsxRuntime.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"}}),jsxRuntime.jsx(mc,{enabled:i})]})})}function mc({enabled:e}){return jsxRuntime.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:jsxRuntime.jsx(z,{name:"arrow-up",size:13})})}var xc=[.4,0,.2,1],wc=[.22,.61,.36,1],yc={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 kc(e,t){if(!t)return yc;let r=wt({anchor:t,popover:{width:332,height:ki},viewport:e.getOverlayViewport()});return Si(t,r,ki)}function Cc(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=react.useRef(null),[l,c]=react.useState(()=>kc(i,t??e())),d=react.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=>Cc(y,g)?y:g);},[e,i]);react.useLayoutEffect(()=>{d();}),react.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]),react.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=react.useRef(s);react.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 jsxRuntime.jsx(react$1.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:xc}},transition:{layout:{duration:.42,ease:wc}},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 jsxRuntime.jsxs(le.Root,{getAnchorRect:e,initialAnchorRect:t,entryDelay:r,children:[jsxRuntime.jsx(le.Header,{}),jsxRuntime.jsx(le.Messages,{}),jsxRuntime.jsx(le.Reply,{}),jsxRuntime.jsx(le.ConfirmDiscard,{}),jsxRuntime.jsx(le.ConfirmDelete,{})]})}function Ei({getAnchorRect:e,initialAnchorRect:t,entryDelay:r}){return jsxRuntime.jsxs(le.Root,{getAnchorRect:e,initialAnchorRect:t,entryDelay:r,children:[jsxRuntime.jsx(le.Header,{}),jsxRuntime.jsx(le.Messages,{}),jsxRuntime.jsx(le.Reply,{}),jsxRuntime.jsx(le.DevFooter,{}),jsxRuntime.jsx(le.ConfirmDiscard,{}),jsxRuntime.jsx(le.ConfirmDelete,{})]})}var Ic="data-patch-internal";function Pi(e,t,r){let n={viewportX:t,viewportY:r},o=ot(n,e.getOverlayViewport());return Xt(n,o)}function Pc(e,t){return e.overlayDocument.querySelector("patch-widget-root")?.shadowRoot?.querySelector(t)??null}function Nc(e,t){let r=Pc(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 Mc(e,t){if(!t)return null;let r=So({payload:t.payload,doc:e.targetDocument,scrollY:e.getTargetScrollY(),viewport:e.getTargetViewport(),internalAttr:Ic}),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 Nc(e,t.annotationId)??Mc(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=react.useMemo(()=>!n||n.kind!=="existing"?null:t.annotations.find(p=>p.id===n.annotationId)??null,[n,t.annotations]),s=react.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=react.useMemo(()=>Ii(r,n,o),[n,o,r]);return jsxRuntime.jsx(react$1.AnimatePresence,{children:a?jsxRuntime.jsx(ti,{annotation:o,draftTargetLabel:c,children:jsxRuntime.jsx(i,{getAnchorRect:s,initialAnchorRect:d,entryDelay:l})},"active-popover"):null})}var Dc="https://app.usepatch.dev";function Oc({children:e}){let{active:t}=re();return t?e:null}function Mi(e){let t=typeof window<"u"&&on(window),r=react.useMemo(()=>Xn({prop:e.projectToken,processEnv:qn(),importMetaEnv:Kn()}),[e.projectToken]),n=e.apiBase??Dc;return react.useEffect(()=>{r||console.warn(Gn);},[r]),t||!r?null:jsxRuntime.jsx(Do,{children:jsxRuntime.jsx(sn,{children:jsxRuntime.jsx(gn,{projectToken:r,apiBase:n,children:jsxRuntime.jsx(Oc,{children:jsxRuntime.jsx(bn,{children:jsxRuntime.jsx(Yn,{children:jsxRuntime.jsx(Bn,{projectToken:r,children:jsxRuntime.jsxs(zn,{children:[jsxRuntime.jsx(Po,{}),jsxRuntime.jsx(Ni,{}),jsxRuntime.jsx(Mo,{}),jsxRuntime.jsx(xo,{})]})})})})})})})})}var zc=Mi;
|
|
2026
|
+
exports.Patch=Mi;exports.default=zc;
|