@uselay/sdk 1.1.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var Fo=Object.create;var Ge=Object.defineProperty;var zo=Object.getOwnPropertyDescriptor;var Go=Object.getOwnPropertyNames;var Bo=Object.getPrototypeOf,Wo=Object.prototype.hasOwnProperty;var $o=(e,t)=>{for(var o in t)Ge(e,o,{get:t[o],enumerable:!0})},Mt=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Go(t))!Wo.call(e,r)&&r!==o&&Ge(e,r,{get:()=>t[r],enumerable:!(n=zo(t,r))||n.enumerable});return e};var It=(e,t,o)=>(o=e!=null?Fo(Bo(e)):{},Mt(t||!e||!e.__esModule?Ge(o,"default",{value:e,enumerable:!0}):o,e)),Uo=e=>Mt(Ge({},"__esModule",{value:!0}),e);var Vn={};$o(Vn,{AIContextCard:()=>Oo,ArchivedThreadsPanel:()=>Ue,CommentActions:()=>ot,CommentAnchor:()=>Qe,CommentDot:()=>at,CommentDots:()=>it,CommentItem:()=>He,CommentLayer:()=>et,CommentThread:()=>nt,DetachedCommentsPanel:()=>Xe,ElementHighlighter:()=>qe,LayProvider:()=>ko,LayToggle:()=>Ve,ReplyInput:()=>rt,captureElementMetadata:()=>Oe,computeContrastRatio:()=>xt,createHostedAdapter:()=>Be,createMemoryAdapter:()=>Ho,findByFingerprint:()=>je,formatRelativeTime:()=>ce,generateDomPath:()=>Ee,generateFingerprint:()=>Ye,getGuestAuthor:()=>ye,isAIContextReview:()=>ze,isAIContextSupport:()=>Do,isCommentable:()=>xe,isGeneratedClassName:()=>vt,parseUserAgent:()=>Rt,persistGuestName:()=>Pe,resolveAuthor:()=>me,resolveEffectiveBackground:()=>Et,resolveElement:()=>st,saveGuestAuthor:()=>Je,scoreFingerprintMatch:()=>bt,summarizeDomPath:()=>Ke,useCommentMode:()=>$e,useComments:()=>ae,useElementSelector:()=>Ze,useLayContext:()=>E});module.exports=Uo(Vn);var T=require("react");var Ko="https://uselay.com",Xo="Lay:";function ct(e){console.warn(`${Xo} ${e}`)}var Le=class extends Error{constructor(t,o){super(t),this.name="ApiError",this.status=o}};function Be(e){let t=typeof e=="string"?{apiUrl:e}:e??{},o=(t.apiUrl??Ko).replace(/\/$/,""),n=t.ai!==!1;function r(s){return s?{Authorization:`Bearer ${s}`}:{}}async function a(s,c,m){let i;try{i=await fetch(`${o}${s}`,{...c,headers:{"Content-Type":"application/json",...r(m),...c?.headers??{}}})}catch{throw ct("Unable to reach API. Comments won't persist."),new Error("Network error")}if(!i.ok){let l=(await i.json().catch(()=>({}))).error??`API error: ${i.status}`;throw i.status===403?ct("This domain is not authorized for this project."):i.status===404&&ct("Invalid project ID. Comments won't persist."),new Le(l,i.status)}return i.json()}return{async getConfig(s){let c=new URLSearchParams({projectId:s});return a(`/api/v1/config?${c.toString()}`)},async getComments(s,c,m){let i=new URLSearchParams({projectId:s,urlPath:c});return a(`/api/v1/comments?${i.toString()}`,void 0,m?.sessionToken)},async addComment(s,c){return a("/api/v1/comments",{method:"POST",body:JSON.stringify(s),...n?{}:{headers:{"X-FL-AI":"false"}}},c?.sessionToken)},async updateComment(s,c,m){return a(`/api/v1/comments/${s}`,{method:"PATCH",body:JSON.stringify(c)},m?.sessionToken)},async uploadScreenshot(s,c,m,i,d){let l=new FormData,u=m.type==="image/png"?"png":"webp";l.append("file",m,`${c}.${u}`),l.append("projectId",s),l.append("commentId",c),l.append("elementBounds",JSON.stringify(i));let f={};d?.sessionToken&&(f.Authorization=`Bearer ${d.sessionToken}`);let v;try{v=await fetch(`${o}/api/v1/screenshots`,{method:"POST",headers:f,body:l})}catch{return}v.ok},subscribe(s,c,m){let i=new URLSearchParams({projectId:s});m?.sessionToken&&i.set("token",m.sessionToken);let d=`${o}/api/v1/stream?${i.toString()}`,l=new EventSource(d);return l.onmessage=u=>{try{let f=JSON.parse(u.data);(f.type==="INSERT"||f.type==="UPDATE")&&c(f)}catch{}},l.onerror=()=>{},()=>{l.close()}}}}var L={BASE:1e5,HIGHLIGHT:100001,DOT:100002,POPOVER:100003,TOGGLE:100004};var q={PARTICLE_COUNT:5,PARTICLE_SIZE_MIN:3,PARTICLE_SIZE_MAX:4,DURATION:450,SPREAD_ANGLE:120,DISTANCE_MIN:14,DISTANCE_MAX:28},H={MARKER_HEIGHT:22,MARKER_MIN_WIDTH:20,MARKER_POINTER:4,MARKER_FONT_SIZE:11,MARKER_MAX_COUNT:99,TOGGLE_SIZE:36,BORDER_RADIUS:8,BORDER_RADIUS_SM:6,HIGHLIGHT_OUTLINE:2},Lt={TOGGLE_COMMENT_MODE:"c"},ne={ROOT:"data-fl-root",IGNORE:"data-fl-ignore"},dt={ANCESTOR_DEPTH:4,PROXIMITY_THRESHOLD:30},kt={MAX_SEGMENTS:3,MAX_LENGTH:50},Ae={WIDTH:320,COLLAPSED_HEIGHT:40,GAP:8,EXPAND_DURATION:150},Dt=[{label:"Visual bug",value:"Visual bug"},{label:"Copy issue",value:"Copy issue"},{label:"Love this",value:"Love this"}],We={HOVER_DELAY:300,MAX_CONTENT_LENGTH:60},mt={WIDTH:280,Z_INDEX:100005},Nt="https://uselay.com/dashboard";function Ot(){if(typeof window>"u")return!1;let e=window.location.hostname;return e==="localhost"||e==="127.0.0.1"}var Ht={id:null,name:"Anonymous",avatar:null};var ut="lay_session_";function Ft(e){try{return localStorage.getItem(`${ut}${e}`)}catch{return null}}function zt(e,t){try{localStorage.setItem(`${ut}${e}`,t)}catch{}}function Gt(e){try{localStorage.removeItem(`${ut}${e}`)}catch{}}var K=require("react"),qt=require("react-dom");var ke=require("react");var Bt=require("react");function E(){let e=(0,Bt.useContext)(ft);if(!e)throw new Error("useLayContext must be used within a <LayProvider />. Wrap your app in <LayProvider> to use uselay.");return e}function $e(){let{isCommentMode:e,projectStatus:t,dispatch:o}=E(),n=(0,ke.useCallback)(()=>{t!=="not_found"&&o({type:"TOGGLE_COMMENT_MODE"})},[o,t]),r=(0,ke.useCallback)(a=>{o({type:"SET_COMMENT_MODE",payload:a})},[o]);return(0,ke.useEffect)(()=>{function a(s){let c=s.target;c.tagName==="INPUT"||c.tagName==="TEXTAREA"||c.tagName==="SELECT"||c.isContentEditable||s.key.toLowerCase()===Lt.TOGGLE_COMMENT_MODE&&!s.metaKey&&!s.ctrlKey&&!s.altKey&&(s.preventDefault(),n())}return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[n]),{isCommentMode:e,toggleCommentMode:n,setCommentMode:r}}var Ce=require("react");function ae(){let{comments:e,detachedDomPaths:t}=E(),o=(0,Ce.useMemo)(()=>{let d=new Map;for(let l of e){let u=d.get(l.dom_path);u?u.push(l):d.set(l.dom_path,[l])}return Array.from(d,([l,u])=>({domPath:l,comments:u}))},[e]),n=(0,Ce.useMemo)(()=>{let d=new Map;for(let l of e){let u=d.get(l.dom_path);u?u.push(l):d.set(l.dom_path,[l])}return Array.from(d,([l,u])=>{let f=[],v=new Map;for(let S of u)if(S.thread_id===null)f.push(S);else{let y=v.get(S.thread_id);y?y.push(S):v.set(S.thread_id,[S])}f.sort((S,y)=>new Date(S.created_at).getTime()-new Date(y.created_at).getTime());let A=f.map(S=>{let y=v.get(S.id)??[];return y.sort((N,B)=>new Date(N.created_at).getTime()-new Date(B.created_at).getTime()),{root:S,replies:y}});return{domPath:l,threads:A,allComments:u}})},[e]),r=(0,Ce.useMemo)(()=>e.filter(l=>l.thread_id===null&&l.status==="archived").map(l=>{let u=e.filter(f=>f.thread_id===l.id).sort((f,v)=>new Date(f.created_at).getTime()-new Date(v.created_at).getTime());return{root:l,replies:u}}),[e]),a=r.length,s=(0,Ce.useMemo)(()=>t.size===0?[]:e.filter(l=>l.thread_id===null&&t.has(l.dom_path)&&l.status!=="archived").map(l=>{let u=e.filter(f=>f.thread_id===l.id).sort((f,v)=>new Date(f.created_at).getTime()-new Date(v.created_at).getTime());return{root:l,replies:u}}),[e,t]),c=s.length,m=(0,Ce.useMemo)(()=>{let d=new Map;for(let l of e)l.thread_id!==null||d.get(l.dom_path)===!1||d.set(l.dom_path,l.status==="resolved"||l.status==="archived");return l=>d.get(l)??!1},[e]),i=(0,Ce.useMemo)(()=>{let d=new Map;for(let l of e)l.thread_id!==null||d.get(l.dom_path)===!1||d.set(l.dom_path,l.status==="archived");return l=>d.get(l)??!1},[e]);return{comments:e,groupedByDomPath:o,threadsByDomPath:n,archivedThreads:r,archivedCount:a,detachedThreads:s,detachedCount:c,isDomPathFullyResolved:m,isDomPathFullyArchived:i}}var le=require("react"),Wt=require("react-dom");var J=require("react/jsx-runtime"),Vo={position:"fixed",top:"50%",right:60,transform:"translateY(-50%)",width:300,maxHeight:320,backgroundColor:"var(--fl-surface-raised)",border:"1px solid var(--fl-border)",borderRadius:"var(--fl-border-radius)",boxShadow:"var(--fl-shadow-lg)",fontFamily:"var(--fl-font-family)",fontSize:"var(--fl-font-size-base)",color:"var(--fl-text-primary)",display:"flex",flexDirection:"column",overflow:"hidden",zIndex:L.POPOVER},Yo={padding:"10px 12px",fontSize:"var(--fl-font-size-sm)",fontWeight:"var(--fl-font-weight-medium)",color:"var(--fl-text-secondary)",fontFamily:"var(--fl-font-family)",borderBottom:"1px solid var(--fl-border)",flexShrink:0},jo={overflowY:"auto",flexGrow:1,minHeight:0},Zo={padding:"20px 12px",textAlign:"center",fontSize:"var(--fl-font-size-sm)",color:"var(--fl-text-tertiary)",fontFamily:"var(--fl-font-family)"},qo={padding:"10px 12px",borderBottom:"1px solid var(--fl-border)",fontFamily:"var(--fl-font-family)"},Jo={fontSize:"var(--fl-font-size-sm)",color:"var(--fl-text-primary)",fontFamily:"var(--fl-font-family)",lineHeight:"var(--fl-line-height)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},Qo={display:"flex",alignItems:"center",justifyContent:"space-between",marginTop:4},er={fontSize:"var(--fl-font-size-sm)",color:"var(--fl-text-tertiary)",fontFamily:"var(--fl-font-family)"},$t={display:"inline-flex",alignItems:"center",padding:"2px 8px",border:"none",borderRadius:"var(--fl-border-radius-sm)",backgroundColor:"transparent",color:"var(--fl-text-tertiary)",cursor:"pointer",fontFamily:"var(--fl-font-family)",fontSize:"var(--fl-font-size-sm)",fontWeight:"var(--fl-font-weight-medium)",transition:"color var(--fl-duration-fast) ease-out"},tr={...$t,color:"var(--fl-accent)"};function or({thread:e,onRestore:t}){let[o,n]=(0,le.useState)(!1);return(0,J.jsxs)("div",{style:qo,children:[(0,J.jsxs)("div",{style:Jo,children:["\u201C",e.root.content,"\u201D"]}),(0,J.jsxs)("div",{style:Qo,children:[(0,J.jsx)("span",{style:er,children:e.root.author.name}),(0,J.jsx)("button",{type:"button",style:o?tr:$t,onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),onClick:()=>t(e.root),children:"Restore"})]})]})}function Ue({onClose:e}){let{portalRoot:t,adapter:o,config:n,dispatch:r}=E(),{archivedThreads:a}=ae(),s=(0,le.useRef)(null),c=(0,le.useCallback)(m=>{let i={...m,status:"open",resolved_by:null,resolved_at:null,archived_at:null};r({type:"UPDATE_COMMENT",payload:i}),o.updateComment(m.id,{status:"open",resolved_by:null,resolved_at:null,archived_at:null}).catch(()=>{r({type:"UPDATE_COMMENT",payload:m})})},[o,r]);return(0,le.useEffect)(()=>{function m(i){i.key==="Escape"&&(i.preventDefault(),e())}return document.addEventListener("keydown",m,!0),()=>document.removeEventListener("keydown",m,!0)},[e]),(0,le.useEffect)(()=>{function m(d){let l=d.target;s.current?.contains(l)||l.closest("[data-fl-ignore]")||e()}let i=setTimeout(()=>{document.addEventListener("mousedown",m,!0)},50);return()=>{clearTimeout(i),document.removeEventListener("mousedown",m,!0)}},[e]),t?(0,Wt.createPortal)((0,J.jsxs)("div",{ref:s,style:Vo,"data-fl-ignore":"",children:[(0,J.jsx)("div",{style:Yo,children:"Archived Threads"}),(0,J.jsx)("div",{style:jo,children:a.length===0?(0,J.jsx)("div",{style:Zo,children:"No archived threads on this page."}):a.map(m=>(0,J.jsx)(or,{thread:m,onRestore:c},m.root.id))})]}),t):null}var De=require("react"),Vt=require("react-dom");function ce(e){let t=new Date(e),o=new Date,n=o.getTime()-t.getTime(),r=Math.floor(n/1e3),a=Math.floor(r/60),s=Math.floor(a/60),c=Math.floor(s/24);if(r<60)return"just now";if(a<60)return`${a} min ago`;if(s<24)return`${s} hr ago`;if(c===1)return"Yesterday";let m=t.toLocaleString("en-US",{month:"short"}),i=t.getDate();return t.getFullYear()===o.getFullYear()?`${m} ${i}`:`${m} ${i}, ${t.getFullYear()}`}var Ut={nav:"navigation",main:"main",header:"header",footer:"footer",section:"section",article:"article",aside:"sidebar",form:"form",table:"table",ul:"list",ol:"list",li:"item",h1:"heading",h2:"heading",h3:"heading",h4:"heading",h5:"heading",h6:"heading",p:"text",img:"image",figure:"figure",video:"video",picture:"image",button:"button",a:"link",input:"input",select:"dropdown",textarea:"text input"};function rr(e){let t=e.tagName.toLowerCase();if(e.id)return`#${e.id}`;let o=e.getAttribute("aria-label");if(o)return`"${pt(o,20)}"`;if(["button","a","h1","h2","h3","h4","h5","h6"].includes(t)){let r=e.textContent?.trim();if(r&&r.length<=25)return`"${pt(r,20)}" ${Ut[t]??t}`}let n=e.getAttribute("data-testid")??e.getAttribute("data-feedback-id");return n||(Ut[t]??t)}function Xt(e){let t=[],o=e;for(;o&&o!==document.body&&(t.unshift(rr(o)),!o.id);)o=o.parentElement;return e.closest("[id]")||t.unshift("page"),t.slice(-kt.MAX_SEGMENTS)}function Ke(e){let t=e.split(/\s*>\s*/);if(t.length===0)return e;let o=Kt(t[t.length-1]),n="";for(let a=t.length-2;a>=0;a--){let s=t[a];if(s.includes("#")||s.includes("[data-feedback-id")||s.includes("[data-testid")){n=Kt(s);break}let c=s.split(/[.:[\s]/)[0];if(["main","nav","header","footer","section","article","aside","form"].includes(c)){n=c;break}}let r=n?`${o} in ${n}`:o;return pt(r,30)}function Kt(e){let t=e.match(/\[data-(?:feedback-id|testid)="([^"]+)"\]/);if(t)return t[1];let o=e.match(/#([a-zA-Z0-9_-]+)/);if(o)return`#${o[1]}`;let n=e.match(/^([a-z]+)\.([a-zA-Z0-9_-]+)/);if(n)return`${n[1]}.${n[2]}`;let r=e.match(/^([a-z]+):nth-child\(\d+\)/);return r?r[1]:e}function pt(e,t){return e.length>t?e.slice(0,t-1)+"\u2026":e}var U=require("react/jsx-runtime"),nr={position:"fixed",top:"50%",right:60,transform:"translateY(-50%)",width:300,maxHeight:320,backgroundColor:"var(--fl-surface-raised)",borderWidth:1,borderStyle:"solid",borderColor:"var(--fl-border)",borderRadius:"var(--fl-border-radius)",boxShadow:"var(--fl-shadow-lg)",fontFamily:"var(--fl-font-family)",fontSize:"var(--fl-font-size-base)",color:"var(--fl-text-primary)",display:"flex",flexDirection:"column",overflow:"hidden",zIndex:L.POPOVER},ar={padding:"10px 12px",fontSize:"var(--fl-font-size-sm)",fontWeight:"var(--fl-font-weight-medium)",color:"var(--fl-text-secondary)",fontFamily:"var(--fl-font-family)",borderBottomWidth:1,borderBottomStyle:"solid",borderBottomColor:"var(--fl-border)",flexShrink:0},sr={padding:"6px 12px 8px",fontSize:11,color:"var(--fl-text-tertiary)",fontFamily:"var(--fl-font-family)",lineHeight:1.4},ir={overflowY:"auto",flexGrow:1,minHeight:0},lr={padding:"20px 12px",textAlign:"center",fontSize:"var(--fl-font-size-sm)",color:"var(--fl-text-tertiary)",fontFamily:"var(--fl-font-family)"},cr={padding:"10px 12px",borderBottomWidth:1,borderBottomStyle:"solid",borderBottomColor:"var(--fl-border)",fontFamily:"var(--fl-font-family)"},dr={fontSize:"var(--fl-font-size-sm)",color:"var(--fl-text-primary)",fontFamily:"var(--fl-font-family)",lineHeight:"var(--fl-line-height)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},mr={display:"flex",alignItems:"center",justifyContent:"space-between",marginTop:4},ur={fontSize:"var(--fl-font-size-sm)",color:"var(--fl-text-tertiary)",fontFamily:"var(--fl-font-family)"},fr={fontSize:11,color:"var(--fl-text-tertiary)",fontFamily:"var(--fl-font-family)"},pr={marginTop:4,fontSize:11,color:"var(--fl-text-tertiary)",fontFamily:"var(--fl-font-family)",fontStyle:"italic"};function hr({thread:e}){let t=Ke(e.root.dom_path);return(0,U.jsxs)("div",{style:cr,children:[(0,U.jsxs)("div",{style:dr,children:["\u201C",e.root.content,"\u201D"]}),(0,U.jsxs)("div",{style:mr,children:[(0,U.jsx)("span",{style:ur,children:e.root.author.name}),(0,U.jsx)("span",{style:fr,children:ce(e.root.created_at)})]}),(0,U.jsxs)("div",{style:pr,children:["Was on: ",t]})]})}function Xe({onClose:e}){let{portalRoot:t}=E(),{detachedThreads:o}=ae(),n=(0,De.useRef)(null);return(0,De.useEffect)(()=>{function r(a){a.key==="Escape"&&(a.preventDefault(),e())}return document.addEventListener("keydown",r,!0),()=>document.removeEventListener("keydown",r,!0)},[e]),(0,De.useEffect)(()=>{function r(s){let c=s.target;n.current?.contains(c)||c.closest("[data-fl-ignore]")||e()}let a=setTimeout(()=>{document.addEventListener("mousedown",r,!0)},50);return()=>{clearTimeout(a),document.removeEventListener("mousedown",r,!0)}},[e]),t?(0,Vt.createPortal)((0,U.jsxs)("div",{ref:n,style:nr,"data-fl-ignore":"",children:[(0,U.jsx)("div",{style:ar,children:"Detached Comments"}),(0,U.jsx)("div",{style:sr,children:"These comments can't find their original element."}),(0,U.jsx)("div",{style:ir,children:o.length===0?(0,U.jsx)("div",{style:lr,children:"No detached comments on this page."}):o.map(r=>(0,U.jsx)(hr,{thread:r},r.root.id))})]}),t):null}var Ne=require("react");var F=require("react/jsx-runtime"),yr={heading:"Lay is installed.",body:"Create a free project to start collecting feedback on your site.",cta:"Get started"},gr={heading:"Project not found.",body:"Check your project ID, or create a new project from the dashboard.",cta:"Open dashboard"},vr={position:"fixed",inset:0,zIndex:L.TOGGLE-1},br={position:"fixed",right:60,top:"50%",transform:"translateY(-50%)",width:mt.WIDTH,zIndex:mt.Z_INDEX,backgroundColor:"var(--fl-surface-raised)",borderWidth:1,borderStyle:"solid",borderColor:"var(--fl-border)",borderRadius:"var(--fl-border-radius)",boxShadow:"var(--fl-shadow-popover)",padding:"20px 18px 16px",fontFamily:"var(--fl-font-family)",opacity:0,animation:"fl-welcome-fade-in var(--fl-duration-normal) ease-out forwards"},Sr={position:"absolute",top:10,right:10,width:20,height:20,display:"flex",alignItems:"center",justifyContent:"center",background:"none",border:"none",cursor:"pointer",color:"var(--fl-text-tertiary)",padding:0,borderRadius:4,transition:"color var(--fl-duration-fast) ease-out"},Cr={fontSize:"var(--fl-font-size-base)",fontWeight:"var(--fl-font-weight-medium)",color:"var(--fl-text-primary)",margin:"0 0 6px",lineHeight:"var(--fl-line-height)",paddingRight:16},Er={fontSize:"var(--fl-font-size-sm)",color:"var(--fl-text-secondary)",lineHeight:1.5,margin:"0 0 16px"},xr={display:"inline-flex",alignItems:"center",gap:4,fontSize:"var(--fl-font-size-sm)",fontWeight:"var(--fl-font-weight-medium)",fontFamily:"var(--fl-font-family)",color:"var(--fl-accent)",background:"none",border:"none",cursor:"pointer",padding:0,transition:"opacity var(--fl-duration-fast) ease-out",textDecoration:"none"},Rr="@keyframes fl-welcome-fade-in{0%{opacity:0;transform:translateY(-50%) translateX(6px)}100%{opacity:1;transform:translateY(-50%) translateX(0)}}";function Yt({hasProjectId:e,onDismiss:t}){let o=(0,Ne.useRef)(null),n=e?gr:yr;return(0,Ne.useEffect)(()=>{function r(a){o.current&&!o.current.contains(a.target)&&t()}return document.addEventListener("pointerdown",r,!0),()=>document.removeEventListener("pointerdown",r,!0)},[t]),(0,Ne.useEffect)(()=>{function r(a){a.key==="Escape"&&t()}return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[t]),(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)("style",{dangerouslySetInnerHTML:{__html:Rr}}),(0,F.jsx)("div",{style:vr,[ne.IGNORE]:""}),(0,F.jsxs)("div",{ref:o,role:"dialog","aria-label":n.heading,style:br,[ne.IGNORE]:"",children:[(0,F.jsx)("button",{type:"button",style:Sr,onClick:t,"aria-label":"Dismiss",onMouseEnter:r=>{r.currentTarget.style.color="var(--fl-text-primary)"},onMouseLeave:r=>{r.currentTarget.style.color="var(--fl-text-tertiary)"},children:(0,F.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:(0,F.jsx)("path",{d:"M2 2l8 8M10 2l-8 8"})})}),(0,F.jsx)("p",{style:Cr,children:n.heading}),(0,F.jsx)("p",{style:Er,children:n.body}),(0,F.jsxs)("a",{href:Nt,target:"_blank",rel:"noopener noreferrer",style:xr,onMouseEnter:r=>{r.currentTarget.style.opacity="0.8"},onMouseLeave:r=>{r.currentTarget.style.opacity="1"},children:[n.cta,(0,F.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,F.jsx)("path",{d:"M5 12h14M12 5l7 7-7 7"})})]})]})]})}var D=require("react/jsx-runtime"),gt={position:"fixed",right:16,top:"50%",transform:"translateY(-50%)",width:"var(--fl-toggle-size)",height:"var(--fl-toggle-size)",borderRadius:"50%",borderWidth:1.5,borderStyle:"solid",borderColor:"var(--fl-border)",backgroundColor:"var(--fl-surface-raised)",color:"var(--fl-text-secondary)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",zIndex:L.TOGGLE,boxShadow:"var(--fl-shadow)",animation:"fl-toggle-beam 2s ease-out 1s infinite",transition:"all var(--fl-duration-normal) ease-in-out",padding:0,outline:"none",fontFamily:"var(--fl-font-family)"},wr={...gt,transform:"translateY(-50%) translateX(-4px)",borderColor:"var(--fl-border-strong)",color:"var(--fl-text-primary)",boxShadow:"var(--fl-shadow-lg)"},ht={...gt,backgroundColor:"var(--fl-accent)",borderColor:"var(--fl-accent)",color:"#FFFFFF",boxShadow:"var(--fl-shadow-lg)",animation:"none"},jt={...ht,transform:"translateY(-50%) translateX(-4px)"},Jt={position:"absolute",right:"100%",top:"50%",transform:"translateY(-50%)",marginRight:8,padding:"4px 8px",backgroundColor:"var(--fl-text-primary)",color:"var(--fl-surface)",fontSize:"var(--fl-font-size-sm)",fontFamily:"var(--fl-font-family)",fontWeight:"var(--fl-font-weight-medium)",borderRadius:"var(--fl-border-radius-sm)",whiteSpace:"nowrap",pointerEvents:"none",opacity:0,transition:"opacity var(--fl-duration-fast) ease-out"},Tr={...Jt,opacity:1},yt={position:"absolute",right:"100%",top:"100%",marginRight:8,marginTop:4,padding:"3px 8px",backgroundColor:"var(--fl-surface-raised)",borderWidth:1,borderStyle:"solid",borderColor:"var(--fl-border)",borderRadius:10,fontSize:"var(--fl-font-size-sm)",fontFamily:"var(--fl-font-family)",fontWeight:"var(--fl-font-weight-medium)",color:"var(--fl-text-secondary)",whiteSpace:"nowrap",cursor:"pointer",lineHeight:1.3,transition:"color var(--fl-duration-fast) ease-out, border-color var(--fl-duration-fast) ease-out"},Zt={...yt,color:"var(--fl-text-primary)",borderColor:"var(--fl-border-strong)"};function Ar({active:e}){return(0,D.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:e?"#FFFFFF":"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,D.jsx)("path",{d:"M3 7V5a2 2 0 0 1 2-2h2"}),(0,D.jsx)("path",{d:"M17 3h2a2 2 0 0 1 2 2v2"}),(0,D.jsx)("path",{d:"M21 17v2a2 2 0 0 1-2 2h-2"}),(0,D.jsx)("path",{d:"M7 21H5a2 2 0 0 1-2-2v-2"})]})}function Ve(){let{isCommentMode:e,toggleCommentMode:t}=$e(),{portalRoot:o,mode:n,projectStatus:r,config:a}=E(),{archivedCount:s,detachedCount:c}=ae(),m=r==="not_found",i=n!=="support"&&!m,[d,l]=(0,K.useState)(!1),[u,f]=(0,K.useState)(!1),[v,A]=(0,K.useState)(!1),[S,y]=(0,K.useState)(!1),[N,B]=(0,K.useState)(!1),[h,x]=(0,K.useState)(!1),_=(0,K.useCallback)(M=>{M.stopPropagation(),y(O=>!O),B(!1)},[]),b=(0,K.useCallback)(M=>{M.stopPropagation(),B(O=>!O),y(!1)},[]),W=(0,K.useCallback)(()=>{y(!1)},[]),$=(0,K.useCallback)(()=>{B(!1)},[]),j=(0,K.useCallback)(()=>{m?x(M=>!M):t()},[m,t]),ie=(0,K.useCallback)(()=>{x(!1)},[]);if(!o)return null;let ee;return m&&h||e?ee=d?jt:ht:ee=d?wr:gt,(0,qt.createPortal)((0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)("button",{type:"button",onClick:j,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),style:ee,"aria-label":m?"Set up Lay":e?"Exit comment mode":"Enter comment mode",[ne.IGNORE]:"",children:[(0,D.jsx)(Ar,{active:e||m&&h}),(0,D.jsx)("span",{style:d?Tr:Jt,children:m?"Set up Lay":"Comment mode (C)"}),i&&s>0&&(0,D.jsxs)("span",{role:"button",tabIndex:0,style:u?Zt:yt,onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),onClick:_,onKeyDown:M=>{(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),_(M))},children:[s," archived"]}),i&&c>0&&(0,D.jsxs)("span",{role:"button",tabIndex:0,style:{...v?Zt:yt,top:s>0?"calc(100% + 28px)":"100%"},onMouseEnter:()=>A(!0),onMouseLeave:()=>A(!1),onClick:b,onKeyDown:M=>{(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),b(M))},children:[c," detached"]})]}),i&&S&&(0,D.jsx)(Ue,{onClose:W}),i&&N&&(0,D.jsx)(Xe,{onClose:$}),m&&h&&(0,D.jsx)(Yt,{hasProjectId:!!a.projectId,onDismiss:ie})]}),o)}var he=require("react");function Ee(e){let t=[],o=e;for(;o&&o!==document.documentElement;){if(o===document.body){t.unshift("body");break}let n=o.getAttribute("data-feedback-id");if(n){t.unshift(`[data-feedback-id="${n}"]`);break}let r=o.getAttribute("data-testid");if(r){t.unshift(`[data-testid="${r}"]`);break}if(o.id){t.unshift(`#${o.id}`);break}let a=o.tagName.toLowerCase(),s=Pr(o);if(s.length>0){a+=`.${CSS.escape(s[0])}`;let i=o.parentElement;if(i)try{if(Array.from(i.children).filter(l=>l.matches(a)).length===1){t.unshift(a),o=o.parentElement;continue}}catch{}}if(!o)break;let c=o;a=c.tagName.toLowerCase();let m=c.parentElement;if(m){let i=Array.from(m.children);if(i.filter(l=>l.tagName===c.tagName).length>1){let l=i.indexOf(c)+1;a=`${c.tagName.toLowerCase()}:nth-child(${l})`}}t.unshift(a),o=o.parentElement}return t.join(" > ")}function Pr(e){return Array.from(e.classList).filter(o=>!vt(o))}function vt(e){return!!(e.length<=2||e.startsWith("_")||/^[a-zA-Z]+_[a-zA-Z0-9]{5,}$/.test(e)||/^css-[a-z0-9]+$/i.test(e)||/^sc-[a-zA-Z0-9]+$/.test(e)||/^[a-z]{1,3}[A-Z][a-zA-Z0-9]{4,}$/.test(e)||e.includes(":")||e.includes("[")||e.includes("]")||e.includes("."))}function xe(e){let t=e.tagName.toLowerCase();return!(["html","head","script","style","link","meta","noscript","br"].includes(t)||e.closest("[data-fl-root]")||e.hasAttribute("data-fl-ignore"))}var _r=["id","class","role","type","name","href","src","data-testid","data-feedback-id"];function Ye(e){let t=e.tagName.toLowerCase(),o=(e.textContent?.trim()??"").slice(0,80),n={};for(let i of _r){let d=e.getAttribute(i);d!==null&&d!==""&&(n[i]=d)}let r=e.parentElement,a=0,s=1;if(r){let i=Array.from(r.children).filter(d=>d.tagName===e.tagName);s=i.length,a=i.indexOf(e)}let c=r?.tagName.toLowerCase()??"",m=r?.parentElement?.tagName.toLowerCase()??"";return{tag:t,textContent:o,attributes:n,siblingIndex:a,siblingCount:s,parentTag:c,grandparentTag:m}}function bt(e,t){if(t.tagName.toLowerCase()!==e.tag)return 0;let o=20,n=(t.textContent?.trim()??"").slice(0,80);n===e.textContent&&n.length>0?o+=25:e.textContent.length>0&&n.length>0&&(n.includes(e.textContent)||e.textContent.includes(n))&&(o+=15);let r=e.attributes;r["data-feedback-id"]&&t.getAttribute("data-feedback-id")===r["data-feedback-id"]&&(o+=30),r["data-testid"]&&t.getAttribute("data-testid")===r["data-testid"]&&(o+=25),r.id&&t.id===r.id&&(o+=20),r.role&&t.getAttribute("role")===r.role&&(o+=5),r.type&&t.getAttribute("type")===r.type&&(o+=5),r.href&&t.getAttribute("href")===r.href&&(o+=10),r.name&&t.getAttribute("name")===r.name&&(o+=5);let a=t.parentElement;a&&a.tagName.toLowerCase()===e.parentTag&&(o+=10);let s=a?.parentElement;return s&&s.tagName.toLowerCase()===e.grandparentTag&&(o+=5),Math.min(o,100)}function je(e,t=40){let o=document.querySelectorAll(e.tag),n=null,r=0;for(let a of o){if(a.closest("[data-fl-root]")||a.hasAttribute("data-fl-ignore"))continue;let s=bt(e,a);s>r&&(r=s,n=a)}return r>=t?{element:n,score:r}:{element:null,score:r}}var Mr=["font-family","font-size","font-weight","color","background-color","padding","margin","width","height","border-radius","display","position","line-height","letter-spacing","text-align","opacity"];function Qt(e){let t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?{r:Number(t[1]),g:Number(t[2]),b:Number(t[3])}:null}function Ct(e){if(e==="transparent"||e==="rgba(0, 0, 0, 0)")return!0;let t=e.match(/rgba\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*([\d.]+)\s*\)/);return t?Number(t[1])===0:!1}function to(e){let t=window.getComputedStyle(e),o=t.getPropertyValue("background-color");if(o&&!Ct(o))return!0;let n=t.getPropertyValue("background-image");if(n&&n!=="none")return!0;let r=t.getPropertyValue("box-shadow");if(r&&r!=="none")return!0;for(let a of["top","right","bottom","left"]){let s=t.getPropertyValue(`border-${a}-width`),c=t.getPropertyValue(`border-${a}-style`);if(s!=="0px"&&c!=="none")return!0}return!1}function Et(e){let t=e;for(;t&&t!==document.documentElement;){let o=window.getComputedStyle(t).backgroundColor;if(o&&!Ct(o))return o;t=t.parentElement}if(document.documentElement){let o=window.getComputedStyle(document.documentElement).backgroundColor;if(o&&!Ct(o))return o}return"rgb(255, 255, 255)"}function St(e){let t=e/255;return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function eo(e){return .2126*St(e.r)+.7152*St(e.g)+.0722*St(e.b)}function xt(e,t){let o=Qt(e),n=Qt(t);if(!o||!n)return{ratio:0,passesAA:!1};let r=eo(o),a=eo(n),s=Math.max(r,a),c=Math.min(r,a),m=Math.round((s+.05)/(c+.05)*100)/100;return{ratio:m,passesAA:m>=4.5}}function Rt(e){if(/iPhone/i.test(e))return"iPhone";if(/iPad/i.test(e))return"iPad";if(/Android/i.test(e))return/Mobile/i.test(e)?"Android Phone":"Android Tablet";let t="Browser";/Edg\//i.test(e)?t="Edge":/Chrome\//i.test(e)?t="Chrome":/Firefox\//i.test(e)?t="Firefox":/Safari\//i.test(e)&&!/Chrome/i.test(e)&&(t="Safari");let o="";return/Macintosh|Mac OS/i.test(e)?o="macOS":/Windows/i.test(e)?o="Windows":/Linux/i.test(e)?o="Linux":/CrOS/i.test(e)&&(o="ChromeOS"),o?`${t} on ${o}`:t}function Oe(e){let t=window.getComputedStyle(e),o={};for(let u of Mr)o[u]=t.getPropertyValue(u);let n=e.getAttribute("role"),r=e.getAttribute("aria-label"),a=o.color,s=Et(e);s!==o["background-color"]&&(o["effective-background-color"]=s);let{ratio:c,passesAA:m}=xt(a,s),i={width:window.innerWidth,height:window.innerHeight},d=Rt(navigator.userAgent),l;try{l=Ye(e)}catch{}return{computed_styles:o,accessibility:{role:n,aria_label:r,contrast_ratio:c,contrast_passes_aa:m},viewport:i,device:d,fingerprint:l}}function oo(e){let t=e.tagName.toLowerCase();return["button","a","input","select","textarea"].includes(t)||e.getAttribute("role")==="button"||e.getAttribute("role")==="link"||e.hasAttribute("data-feedback-id")||e.hasAttribute("data-testid")?3:["h1","h2","h3","h4","h5","h6","p","img","figure","figcaption","picture","video","section","article","nav","header","footer","main","aside","form","table","ul","ol","li","blockquote","details"].includes(t)?2:1}var Ir='button,a,input,select,textarea,h1,h2,h3,h4,h5,h6,p,img,figure,nav,section,article,header,footer,main,[role="button"],[role="link"],[data-feedback-id],[data-testid]';function wt(e,t){let o=oo(t);if(o>=2||to(t))return null;let n=null,r=o,a=t.parentElement,s=0;for(;a&&a!==document.body&&s<dt.ANCESTOR_DEPTH&&a.getAttribute("data-fl-magnet")!=="off";){let l=oo(a);l>r&&(n=a,r=l),a=a.parentElement,s++}if(n)return n;let c={x:e.clientX,y:e.clientY},m=t.parentElement;if(!m)return null;let i=m.querySelectorAll(Ir),d=null;for(let l of i){if(l===t||l.getAttribute("data-fl-magnet")==="off"||!xe(l))continue;let u=l.getBoundingClientRect(),f=Lr(c,u);f<=dt.PROXIMITY_THRESHOLD&&(!d||f<d.dist)&&(d={el:l,dist:f})}return d?.el??null}function Lr(e,t){let o=Math.max(t.left-e.x,0,e.x-t.right),n=Math.max(t.top-e.y,0,e.y-t.bottom);return Math.sqrt(o*o+n*n)}function Ze(){let{isCommentMode:e}=E(),[t,o]=(0,he.useState)({hoveredElement:null,selectedElement:null}),n=(0,he.useRef)(t);n.current=t;let r=(0,he.useCallback)(()=>{o(a=>({...a,selectedElement:null}))},[]);return(0,he.useEffect)(()=>{if(!e){o({hoveredElement:null,selectedElement:null});return}function a(i){let d=i.target;if(!d||!xe(d)){o(u=>u.hoveredElement!==null?{...u,hoveredElement:null}:u);return}let l=wt(i,d)??d;o(u=>u.hoveredElement!==l?{...u,hoveredElement:l}:u)}function s(i){let d=i.relatedTarget;(!d||d===document.documentElement)&&o(l=>l.hoveredElement!==null?{...l,hoveredElement:null}:l)}function c(i){let d=i.target;if(!d||!xe(d))return;i.preventDefault(),i.stopPropagation();let l=wt(i,d)??d;o(u=>({...u,selectedElement:l,hoveredElement:null}))}document.body.addEventListener("mouseover",a,!0),document.body.addEventListener("mouseout",s,!0),document.body.addEventListener("click",c,!0);let m=document.body.style.cursor;return document.body.style.cursor="crosshair",()=>{document.body.removeEventListener("mouseover",a,!0),document.body.removeEventListener("mouseout",s,!0),document.body.removeEventListener("click",c,!0),document.body.style.cursor=m}},[e]),{hoveredElement:t.hoveredElement,selectedElement:t.selectedElement,clearSelection:r}}var de=require("react"),ro=require("react-dom");var no=require("react/jsx-runtime"),kr={position:"fixed",pointerEvents:"none",border:"2px solid var(--fl-accent)",borderRadius:"var(--fl-border-radius-sm)",transition:"all var(--fl-duration-instant) ease-out",zIndex:L.HIGHLIGHT,boxSizing:"border-box"};function qe({hoveredElement:e,selectedElement:t}){let{isCommentMode:o,portalRoot:n}=E(),[r,a]=(0,de.useState)(null),s=(0,de.useRef)(0),c=(0,de.useCallback)(()=>{let m=t?null:e;if(!m){a(null);return}let i=m.getBoundingClientRect();a({top:i.top,left:i.left,width:i.width,height:i.height})},[e,t]);return(0,de.useEffect)(()=>{c()},[c]),(0,de.useEffect)(()=>{if(!o||!e&&!t)return;function m(){cancelAnimationFrame(s.current),s.current=requestAnimationFrame(()=>{c()})}return window.addEventListener("scroll",m,!0),window.addEventListener("resize",m),()=>{window.removeEventListener("scroll",m,!0),window.removeEventListener("resize",m),cancelAnimationFrame(s.current)}},[o,e,t,c]),!o||!n||!r?null:(0,ro.createPortal)((0,no.jsx)("div",{style:{...kr,top:r.top,left:r.left,width:r.width,height:r.height},"data-fl-ignore":""}),n)}var se=require("react"),ao=require("react-dom");var io=require("react/jsx-runtime"),Dr={position:"fixed",pointerEvents:"none",padding:"2px 8px",backgroundColor:"var(--fl-surface)",border:"1px solid var(--fl-border)",borderRadius:4,fontSize:11,fontFamily:"var(--fl-font-family)",color:"var(--fl-text-secondary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:320,zIndex:L.HIGHLIGHT,boxShadow:"0 1px 3px rgba(26,26,24,0.06)",transition:"all var(--fl-duration-instant) ease-out"};function so({hoveredElement:e,selectedElement:t}){let{isCommentMode:o,portalRoot:n}=E(),[r,a]=(0,se.useState)(null),[s,c]=(0,se.useState)(""),m=(0,se.useRef)(0),i=t?null:e,d=(0,se.useCallback)(()=>{if(!i){a(null);return}let l=i.getBoundingClientRect(),u=Xt(i);c(u.join(" \u203A "));let f=Math.max(4,l.top-28),v=Math.max(4,Math.min(l.left,window.innerWidth-328));a({top:f,left:v})},[i]);return(0,se.useEffect)(()=>{d()},[d]),(0,se.useEffect)(()=>{if(!o||!i)return;function l(){cancelAnimationFrame(m.current),m.current=requestAnimationFrame(()=>{d()})}return window.addEventListener("scroll",l,!0),window.addEventListener("resize",l),()=>{window.removeEventListener("scroll",l,!0),window.removeEventListener("resize",l),cancelAnimationFrame(m.current)}},[o,i,d]),!o||!n||!r?null:(0,ao.createPortal)((0,io.jsx)("div",{style:{...Dr,top:r.top,left:r.left},"data-fl-ignore":"",children:s}),n)}var C=require("react"),fo=require("react-dom");var lo="fl-author";function ye(){try{let e=localStorage.getItem(lo);if(!e)return null;let t=JSON.parse(e);return t&&typeof t.name=="string"&&t.name.trim()?{name:t.name.trim()}:null}catch{return null}}function Je(e){try{let t=e.trim();if(!t)return;localStorage.setItem(lo,JSON.stringify({name:t}))}catch{}}function me(e,t){if(e.user)return e.user;let o=t.trim();return o?{id:null,name:o,avatar:null}:{...Ht}}function Pe(e){let t=e.trim();t&&Je(t)}var Nr=.65;async function co(e){let t=e.getBoundingClientRect(),o={x:Math.round(t.x),y:Math.round(t.y),width:Math.round(t.width),height:Math.round(t.height)},n;try{n=(await import("html-to-image")).toCanvas}catch{return console.info("Lay: Screenshot capture unavailable. This may be caused by a CSP restriction or bundler issue."),null}let r;try{let a=await n(document.body,{filter:c=>!c.hasAttribute?.(ne.IGNORE),pixelRatio:1});r=document.createElement("canvas"),r.width=window.innerWidth,r.height=window.innerHeight;let s=r.getContext("2d");if(!s)return null;s.drawImage(a,window.scrollX,window.scrollY,window.innerWidth,window.innerHeight,0,0,window.innerWidth,window.innerHeight)}catch{return null}return new Promise(a=>{r.toBlob(s=>{if(!s){a(null);return}a({blob:s,bounds:o})},"image/webp",Nr)})}var Q=require("react/jsx-runtime"),po={position:"fixed",zIndex:L.POPOVER,width:Ae.WIDTH,backgroundColor:"var(--fl-surface-raised)",border:"1px solid var(--fl-border)",borderRadius:"var(--fl-border-radius)",boxShadow:"var(--fl-shadow-popover)",fontFamily:"var(--fl-font-family)",fontSize:"var(--fl-font-size-base)",color:"var(--fl-text-primary)",overflow:"hidden",opacity:0,transform:"translateY(4px)",transition:`opacity var(--fl-duration-fast) ease-out, transform var(--fl-duration-fast) ease-out, max-height ${Ae.EXPAND_DURATION}ms ease-out`},Or={...po,opacity:1,transform:"translateY(0)"},Hr={display:"flex",flexDirection:"column",gap:8,padding:12},Fr={width:"100%",padding:"6px 8px",border:"1px solid var(--fl-border)",borderRadius:"var(--fl-border-radius-sm)",backgroundColor:"var(--fl-surface)",color:"var(--fl-text-primary)",fontFamily:"var(--fl-font-family)",fontSize:"var(--fl-font-size-sm)",lineHeight:"var(--fl-line-height)",outline:"none",boxSizing:"border-box",transition:"border-color var(--fl-duration-fast) ease-out"},mo={width:"100%",minHeight:64,padding:8,borderWidth:1,borderStyle:"solid",borderColor:"var(--fl-border)",borderRadius:"var(--fl-border-radius-sm)",backgroundColor:"var(--fl-surface)",color:"var(--fl-text-primary)",fontFamily:"var(--fl-font-family)",fontSize:"var(--fl-font-size-base)",lineHeight:"var(--fl-line-height)",resize:"vertical",outline:"none",boxSizing:"border-box",transition:"border-color var(--fl-duration-fast) ease-out"},zr={display:"flex",alignItems:"center",justifyContent:"flex-end",gap:8},ho={padding:"4px 12px",backgroundColor:"var(--fl-accent)",color:"#FFFFFF",border:"none",borderRadius:"var(--fl-border-radius-sm)",fontFamily:"var(--fl-font-family)",fontSize:"var(--fl-font-size-sm)",fontWeight:"var(--fl-font-weight-medium)",cursor:"pointer",outline:"none",transition:"background-color var(--fl-duration-fast) ease-out"},Gr={...ho,opacity:.4,cursor:"default"},Br={fontSize:"var(--fl-font-size-sm)",color:"var(--fl-text-tertiary)",fontFamily:"var(--fl-font-family)"},Wr={display:"flex",alignItems:"center",gap:6,padding:"6px 8px"},yo={padding:"4px 10px",borderWidth:1,borderStyle:"solid",borderColor:"var(--fl-border)",borderRadius:12,backgroundColor:"var(--fl-surface)",color:"var(--fl-text-secondary)",fontSize:"var(--fl-font-size-sm)",fontFamily:"var(--fl-font-family)",fontWeight:"var(--fl-font-weight-medium)",cursor:"pointer",outline:"none",whiteSpace:"nowrap",transition:"background-color var(--fl-duration-fast) ease-out, border-color var(--fl-duration-fast) ease-out, color var(--fl-duration-fast) ease-out",lineHeight:1,flexShrink:0},$r={...yo,backgroundColor:"var(--fl-accent-subtle)",borderColor:"var(--fl-accent)",color:"var(--fl-accent)"},Ur={flex:1,padding:"4px 8px",color:"var(--fl-text-tertiary)",fontSize:"var(--fl-font-size-sm)",fontFamily:"var(--fl-font-family)",cursor:"text",minWidth:0},Re=8,uo=120;function Kr(e){let t=window.innerWidth,o=window.innerHeight,n=e.bottom+Re,r=e.left;return n+uo>o&&(n=e.top-uo-Re),r+Ae.WIDTH>t&&(r=t-Ae.WIDTH-Re),r<Re&&(r=Re),n<Re&&(n=Re),{top:n,left:r}}function Qe({selectedElement:e,onClearSelection:t}){let{portalRoot:o,adapter:n,config:r,dispatch:a,onCommentAddedRef:s}=E(),[c,m]=(0,C.useState)(""),[i,d]=(0,C.useState)(""),[l,u]=(0,C.useState)(null),[f,v]=(0,C.useState)(!1),[A,S]=(0,C.useState)(!1),[y,N]=(0,C.useState)(null),B=(0,C.useRef)(null),h=(0,C.useRef)(null),x=(0,C.useRef)(null),_=(0,C.useRef)(0),b=!!r.user,W=r.starterChips??Dt,$=(0,C.useCallback)(()=>{if(!e){u(null);return}let p=e.getBoundingClientRect();u(Kr(p))},[e]);(0,C.useEffect)(()=>{if(e){if(d(""),S(!1),N(null),$(),!b){let p=ye();m(p?.name??"")}requestAnimationFrame(()=>{v(!0)})}else v(!1),u(null)},[e,$,b]),(0,C.useEffect)(()=>{if(!e)return;function p(){cancelAnimationFrame(_.current),_.current=requestAnimationFrame(()=>{$()})}return window.addEventListener("scroll",p,!0),window.addEventListener("resize",p),()=>{window.removeEventListener("scroll",p,!0),window.removeEventListener("resize",p),cancelAnimationFrame(_.current)}},[e,$]);let j=(0,C.useRef)(A);j.current=A,(0,C.useEffect)(()=>{if(!e)return;function p(P){P.key==="Escape"&&(P.preventDefault(),P.stopPropagation(),j.current?(S(!1),d("")):t())}return document.addEventListener("keydown",p,!0),()=>document.removeEventListener("keydown",p,!0)},[e,t]),(0,C.useEffect)(()=>{if(!e||A)return;function p(P){P.key.length===1&&!P.ctrlKey&&!P.metaKey&&(P.preventDefault(),S(!0),d(P.key),setTimeout(()=>{h.current?.focus(),h.current&&(h.current.selectionStart=h.current.value.length)},10))}return document.addEventListener("keydown",p,!0),()=>document.removeEventListener("keydown",p,!0)},[e,A]),(0,C.useEffect)(()=>{if(!e)return;function p(Z){let re=Z.target;x.current?.contains(re)||re.closest("[data-fl-root]")||t()}let P=setTimeout(()=>{document.addEventListener("mousedown",p,!0)},50);return()=>{clearTimeout(P),document.removeEventListener("mousedown",p,!0)}},[e,t]);let[ie,ee]=(0,C.useState)(!1),M=r.screenshots!==!1,O=(0,C.useCallback)((p,P)=>{M&&co(p).then(Z=>{Z&&n.uploadScreenshot(r.projectId,P,Z.blob,Z.bounds).catch(()=>{})})},[M,n,r.projectId]),Se=(0,C.useCallback)(async p=>{if(!e)return;let P=e,Z=Ee(P),re=window.location.pathname,Te=ye(),Ie=me(r,Te?.name??""),g=null;try{g=Oe(P)}catch{}let z={project_id:r.projectId,thread_id:null,author:Ie,content:p.value??p.label,status:"open",dom_path:Z,url_path:re,element_metadata:g,resolved_by:null,resolved_at:null,archived_at:null,ai_context:null,screenshot_url:null,element_bounds:null},pe;try{pe=await n.addComment(z),O(P,pe.id),a({type:"SET_COMMENT_MODE",payload:!1}),t()}catch{d(p.value??p.label),S(!0),setTimeout(()=>h.current?.focus(),10)}if(pe)try{s.current?.(pe)}catch{}},[e,r,n,t,O,a,s]),V=(0,C.useCallback)(async()=>{if(!i.trim()||!e)return;let p=e,P=Ee(p),Z=window.location.pathname,re=me(r,c);b||Pe(c);let Te=null;try{Te=Oe(p)}catch{console.warn("Lay: Could not capture element metadata.")}let Ie={project_id:r.projectId,thread_id:null,author:re,content:i.trim(),status:"open",dom_path:P,url_path:Z,element_metadata:Te,resolved_by:null,resolved_at:null,archived_at:null,ai_context:null,screenshot_url:null,element_bounds:null},g;try{g=await n.addComment(Ie),d(""),O(p,g.id),a({type:"SET_COMMENT_MODE",payload:!1}),t()}catch{ee(!0),setTimeout(()=>ee(!1),1200)}if(g)try{s.current?.(g)}catch{}},[i,c,e,r,n,t,b,O,a,s]),R=(0,C.useCallback)(()=>{S(!0),setTimeout(()=>h.current?.focus(),10)},[]),fe=(0,C.useCallback)(p=>{p.key==="Enter"&&!p.shiftKey&&(p.preventDefault(),V())},[V]),Me=(0,C.useCallback)(p=>{p.key==="Enter"&&(p.preventDefault(),h.current?.focus())},[]);if((0,C.useEffect)(()=>{A&&e&&!i&&setTimeout(()=>{if(!b&&!ye()?.name){B.current?.focus();return}h.current?.focus()},10)},[A,e,b,i]),!o||!e||!l)return null;let oe=i.trim();return(0,fo.createPortal)((0,Q.jsx)("div",{ref:x,style:{...f?Or:po,top:l.top,left:l.left,maxHeight:A?400:Ae.COLLAPSED_HEIGHT},"data-fl-ignore":"",children:A?(0,Q.jsxs)("div",{style:Hr,children:[b?null:(0,Q.jsx)("input",{ref:B,type:"text",value:c,onChange:p=>m(p.target.value),onKeyDown:Me,placeholder:"Your name (optional)",style:Fr}),(0,Q.jsx)("textarea",{ref:h,value:i,onChange:p=>d(p.target.value),onKeyDown:fe,placeholder:"Leave feedback...",style:ie?{...mo,borderColor:"#D32F2F"}:mo,rows:3}),(0,Q.jsxs)("div",{style:zr,children:[(0,Q.jsx)("span",{style:Br,children:"Esc \u21A9 collapse"}),(0,Q.jsx)("button",{type:"button",onClick:V,disabled:!oe,style:oe?ho:Gr,children:"Submit"})]})]}):(0,Q.jsxs)("div",{style:Wr,children:[W.map((p,P)=>(0,Q.jsx)("button",{type:"button",onClick:()=>Se(p),onMouseEnter:()=>N(P),onMouseLeave:()=>N(null),style:y===P?$r:yo,children:p.label},p.label)),(0,Q.jsx)("span",{style:Ur,onClick:R,role:"button",tabIndex:0,children:"Type..."})]})}),o)}var ge=require("react/jsx-runtime");function et(){let{hoveredElement:e,selectedElement:t,clearSelection:o}=Ze();return(0,ge.jsxs)(ge.Fragment,{children:[(0,ge.jsx)(qe,{hoveredElement:e,selectedElement:t}),(0,ge.jsx)(so,{hoveredElement:e,selectedElement:t}),(0,ge.jsx)(Qe,{selectedElement:t,onClearSelection:o})]})}var ue=require("react");var w=require("react"),Ao=require("react-dom");var I=It(require("react")),Ro=require("react-dom");var te=require("react/jsx-runtime"),go={padding:"10px 0",fontFamily:"var(--fl-font-family)"},Xr={...go,marginLeft:16,paddingLeft:12,borderLeft:"2px solid var(--fl-border)"},Vr={display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:4},Yr={display:"flex",alignItems:"center",gap:6,minWidth:0},jr={fontSize:"var(--fl-font-size-sm)",fontWeight:"var(--fl-font-weight-medium)",color:"var(--fl-text-secondary)",fontFamily:"var(--fl-font-family)"},Zr={fontSize:"var(--fl-font-size-sm)",color:"var(--fl-text-tertiary)",fontFamily:"var(--fl-font-family)"},qr={fontSize:"var(--fl-font-size-base)",lineHeight:"var(--fl-line-height)",color:"var(--fl-text-primary)",fontFamily:"var(--fl-font-family)",whiteSpace:"pre-wrap",wordBreak:"break-word"},Jr={display:"flex",alignItems:"center",gap:4,marginTop:6,fontSize:"var(--fl-font-size-sm)",color:"var(--fl-text-tertiary)",fontFamily:"var(--fl-font-family)"},Qr={color:"var(--fl-accent)",fontSize:12};function He({comment:e,isReply:t=!1,actions:o}){return(0,te.jsxs)("div",{style:t?Xr:go,children:[(0,te.jsxs)("div",{style:Vr,children:[(0,te.jsxs)("div",{style:Yr,children:[(0,te.jsx)("span",{style:jr,children:e.author.name}),(0,te.jsx)("span",{style:Zr,children:ce(e.created_at)})]}),o]}),(0,te.jsx)("div",{style:qr,children:e.content}),e.status==="resolved"&&e.resolved_by&&!t&&(0,te.jsxs)("div",{style:Jr,children:[(0,te.jsx)("span",{style:Qr,children:"\u2713"}),(0,te.jsxs)("span",{children:["Resolved by ",e.resolved_by.name,e.resolved_at?` \xB7 ${ce(e.resolved_at)}`:""]})]})]})}var tt=require("react"),we=require("react/jsx-runtime"),vo={display:"flex",alignItems:"center",gap:4},Tt={display:"flex",alignItems:"center",justifyContent:"center",width:24,height:24,padding:0,border:"none",borderRadius:"var(--fl-border-radius-sm)",backgroundColor:"transparent",color:"var(--fl-text-tertiary)",cursor:"pointer",fontFamily:"var(--fl-font-family)",fontSize:14,lineHeight:1,transition:"color var(--fl-duration-fast) ease-out, background-color var(--fl-duration-fast) ease-out"},bo={...Tt,color:"var(--fl-accent)",backgroundColor:"var(--fl-accent-subtle)"},So={display:"inline-flex",alignItems:"center",padding:"2px 6px",border:"none",borderRadius:"var(--fl-border-radius-sm)",backgroundColor:"transparent",color:"var(--fl-text-tertiary)",cursor:"pointer",fontFamily:"var(--fl-font-family)",fontSize:"var(--fl-font-size-sm)",fontWeight:"var(--fl-font-weight-medium)",lineHeight:1,transition:"color var(--fl-duration-fast) ease-out"},en={...So,color:"var(--fl-text-secondary)"};function ot({comment:e,onResolve:t,onReopen:o,onArchive:n}){let[r,a]=(0,tt.useState)(!1),[s,c]=(0,tt.useState)(!1),[m,i]=(0,tt.useState)(!1);return e.status==="open"?(0,we.jsx)("div",{style:vo,children:(0,we.jsx)("button",{type:"button",title:"Resolve",style:r?bo:Tt,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),onClick:d=>{d.stopPropagation(),t(e)},children:"\u2713"})}):e.status==="resolved"?(0,we.jsxs)("div",{style:vo,children:[(0,we.jsx)("button",{type:"button",title:"Reopen",style:s?bo:Tt,onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),onClick:d=>{d.stopPropagation(),o(e)},children:"\u21A9"}),(0,we.jsx)("button",{type:"button",title:"Archive",style:m?en:So,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),onClick:d=>{d.stopPropagation(),n(e)},children:"Archive"})]}):null}var Y=require("react");var ve=require("react/jsx-runtime"),tn={display:"flex",flexDirection:"column",gap:6,padding:12},on={width:"100%",padding:"4px 8px",border:"1px solid var(--fl-border)",borderRadius:"var(--fl-border-radius-sm)",backgroundColor:"var(--fl-surface)",color:"var(--fl-text-primary)",fontFamily:"var(--fl-font-family)",fontSize:"var(--fl-font-size-sm)",lineHeight:"var(--fl-line-height)",outline:"none",boxSizing:"border-box",transition:"border-color var(--fl-duration-fast) ease-out"},Co={width:"100%",minHeight:48,padding:"6px 8px",borderWidth:1,borderStyle:"solid",borderColor:"var(--fl-border)",borderRadius:"var(--fl-border-radius-sm)",backgroundColor:"var(--fl-surface)",color:"var(--fl-text-primary)",fontFamily:"var(--fl-font-family)",fontSize:"var(--fl-font-size-base)",lineHeight:"var(--fl-line-height)",resize:"vertical",outline:"none",boxSizing:"border-box",transition:"border-color var(--fl-duration-fast) ease-out"},rn={display:"flex",alignItems:"center",justifyContent:"flex-end",gap:8},Eo={padding:"4px 12px",backgroundColor:"var(--fl-accent)",color:"#FFFFFF",border:"none",borderRadius:"var(--fl-border-radius-sm)",fontFamily:"var(--fl-font-family)",fontSize:"var(--fl-font-size-sm)",fontWeight:"var(--fl-font-weight-medium)",cursor:"pointer",outline:"none",transition:"background-color var(--fl-duration-fast) ease-out"},nn={...Eo,opacity:.4,cursor:"default"},an={fontSize:"var(--fl-font-size-sm)",color:"var(--fl-text-tertiary)",fontFamily:"var(--fl-font-family)"};function rt({rootComment:e,onReplySubmitted:t}){let{adapter:o,config:n}=E(),[r,a]=(0,Y.useState)(""),[s,c]=(0,Y.useState)(""),[m,i]=(0,Y.useState)(!1),d=(0,Y.useRef)(null),l=(0,Y.useRef)(null),u=!!n.user;(0,Y.useEffect)(()=>{if(!u){let y=ye();a(y?.name??"")}},[u]);let f=(0,Y.useCallback)(async()=>{if(!s.trim())return;let y=me(n,r);u||Pe(r);let N={project_id:n.projectId,thread_id:e.id,author:y,content:s.trim(),status:"open",dom_path:e.dom_path,url_path:e.url_path,element_metadata:null,resolved_by:null,resolved_at:null,archived_at:null,ai_context:null,screenshot_url:null,element_bounds:null};try{await o.addComment(N),c(""),t?.(),setTimeout(()=>{l.current?.focus()},10)}catch{i(!0),setTimeout(()=>i(!1),1200)}},[s,r,n,o,e,u,t]),v=(0,Y.useCallback)(y=>{y.key==="Enter"&&!y.shiftKey&&(y.preventDefault(),f())},[f]),A=(0,Y.useCallback)(y=>{y.key==="Enter"&&(y.preventDefault(),l.current?.focus())},[]),S=s.trim();return(0,ve.jsxs)("div",{style:tn,children:[u?null:(0,ve.jsx)("input",{ref:d,type:"text",value:r,onChange:y=>a(y.target.value),onKeyDown:A,placeholder:"Your name (optional)",style:on}),(0,ve.jsx)("textarea",{ref:l,value:s,onChange:y=>c(y.target.value),onKeyDown:v,placeholder:"Reply...",style:m?{...Co,borderColor:"#D32F2F"}:Co,rows:2}),(0,ve.jsxs)("div",{style:rn,children:[(0,ve.jsx)("span",{style:an,children:"Esc"}),(0,ve.jsx)("button",{type:"button",onClick:f,disabled:!S,style:S?Eo:nn,children:"Reply"})]})]})}var X=require("react/jsx-runtime"),wo={position:"fixed",zIndex:L.POPOVER,width:320,maxHeight:400,backgroundColor:"var(--fl-surface-raised)",border:"1px solid var(--fl-border)",borderRadius:"var(--fl-border-radius)",boxShadow:"var(--fl-shadow-popover)",fontFamily:"var(--fl-font-family)",fontSize:"var(--fl-font-size-base)",color:"var(--fl-text-primary)",display:"flex",flexDirection:"column",overflow:"hidden",opacity:0,transform:"translateY(4px)",transition:"opacity var(--fl-duration-fast) ease-out, transform var(--fl-duration-fast) ease-out"},sn={...wo,opacity:1,transform:"translateY(0)"},ln={overflowY:"auto",padding:12,flexGrow:1,minHeight:0},To={height:1,backgroundColor:"var(--fl-border)",margin:"0",border:"none",flexShrink:0},cn={...To,backgroundColor:"var(--fl-border-strong)"},be=8,At=320,xo=200;function dn(e){let t=window.innerWidth,o=window.innerHeight,n=e.bottom+be,r=e.right-At;return n+xo>o&&(n=e.top-xo-be),r<be&&(r=be),r+At>t-be&&(r=t-At-be),n<be&&(n=be),{top:n,left:r}}function mn(e){let t=[],o=new Map;for(let n of e)if(n.thread_id===null)t.push(n);else{let r=o.get(n.thread_id);r?r.push(n):o.set(n.thread_id,[n])}return t.sort((n,r)=>new Date(n.created_at).getTime()-new Date(r.created_at).getTime()),t.map(n=>{let r=o.get(n.id)??[];return r.sort((a,s)=>new Date(a.created_at).getTime()-new Date(s.created_at).getTime()),{root:n,replies:r}})}function nt({comments:e,dotRect:t,onClose:o,onDidResolve:n}){let{portalRoot:r,adapter:a,config:s,dispatch:c}=E(),m=(0,I.useRef)(null),i=(0,I.useRef)(null),[d,l]=I.default.useState(!1),u=dn(t),f=(0,I.useMemo)(()=>mn(e),[e]),v=f.length>0?f[0].root:null,A=(0,I.useCallback)(h=>{let x=me(s,""),_=new Date().toISOString(),b={...h,status:"resolved",resolved_by:x,resolved_at:_};c({type:"UPDATE_COMMENT",payload:b}),n?.(),o(),a.updateComment(h.id,{status:"resolved",resolved_by:x,resolved_at:_}).catch(()=>{c({type:"UPDATE_COMMENT",payload:h})})},[a,s,c,n,o]),S=(0,I.useCallback)(h=>{let x={...h,status:"open",resolved_by:null,resolved_at:null};c({type:"UPDATE_COMMENT",payload:x}),a.updateComment(h.id,{status:"open",resolved_by:null,resolved_at:null}).catch(()=>{c({type:"UPDATE_COMMENT",payload:h})})},[a,c]),y=(0,I.useCallback)(h=>{let x=new Date().toISOString(),_={...h,status:"archived",archived_at:x};c({type:"UPDATE_COMMENT",payload:_}),a.updateComment(h.id,{status:"archived",archived_at:x}).catch(()=>{c({type:"UPDATE_COMMENT",payload:h})})},[a,c]);(0,I.useEffect)(()=>{requestAnimationFrame(()=>{l(!0)})},[]),(0,I.useEffect)(()=>{d&&i.current&&(i.current.scrollTop=i.current.scrollHeight)},[d]);let N=(0,I.useRef)(e.length);(0,I.useEffect)(()=>{e.length>N.current&&i.current&&(i.current.scrollTop=i.current.scrollHeight),N.current=e.length},[e.length]);let B=(0,I.useCallback)(()=>{},[]);return(0,I.useEffect)(()=>{function h(x){x.key==="Escape"&&(x.preventDefault(),o())}return document.addEventListener("keydown",h,!0),()=>document.removeEventListener("keydown",h,!0)},[o]),(0,I.useEffect)(()=>{function h(_){let b=_.target;m.current?.contains(b)||b.closest("[data-fl-ignore]")||o()}let x=setTimeout(()=>{document.addEventListener("mousedown",h,!0)},50);return()=>{clearTimeout(x),document.removeEventListener("mousedown",h,!0)}},[o]),r?(0,Ro.createPortal)((0,X.jsxs)("div",{ref:m,style:{...d?sn:wo,top:u.top,left:u.left},"data-fl-ignore":"",children:[(0,X.jsx)("div",{ref:i,style:ln,children:f.map((h,x)=>(0,X.jsxs)(I.default.Fragment,{children:[x>0?(0,X.jsx)("hr",{style:To}):null,(0,X.jsx)(He,{comment:h.root,actions:(0,X.jsx)(ot,{comment:h.root,onResolve:A,onReopen:S,onArchive:y})}),h.replies.map(_=>(0,X.jsx)(He,{comment:_,isReply:!0},_.id))]},h.root.id))}),v?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)("hr",{style:cn}),(0,X.jsx)(rt,{rootComment:v,onReplySubmitted:B})]}):null]}),r):null}var G=require("react/jsx-runtime");function un(e){let t=[],n=q.SPREAD_ANGLE/2;for(let r=0;r<e;r++){let s=90-n+q.SPREAD_ANGLE/(e-1)*r+(Math.random()-.5)*15,c=q.DISTANCE_MIN+Math.random()*(q.DISTANCE_MAX-q.DISTANCE_MIN),m=s*Math.PI/180,i=Math.cos(m)*c,d=-Math.sin(m)*c,l=q.PARTICLE_SIZE_MIN+Math.random()*(q.PARTICLE_SIZE_MAX-q.PARTICLE_SIZE_MIN),u=["var(--fl-accent)","var(--fl-accent-hover)","#F4A261"],f=u[r%u.length];t.push({endX:i,endY:d,size:l,color:f,delay:r*20})}return t}var Pt={position:"fixed",minWidth:H.MARKER_MIN_WIDTH,height:H.MARKER_HEIGHT,padding:"0 5px",borderRadius:4,border:"none",backgroundColor:"var(--fl-accent)",color:"#FFFFFF",fontSize:H.MARKER_FONT_SIZE,fontFamily:"var(--fl-font-family)",fontWeight:600,lineHeight:`${H.MARKER_HEIGHT}px`,textAlign:"center",cursor:"pointer",zIndex:L.DOT,outline:"none",display:"flex",alignItems:"center",justifyContent:"center",animation:"fl-marker-enter var(--fl-duration-marker-enter) ease-out",transition:"transform var(--fl-duration-fast) ease-out",boxSizing:"border-box"},fn={...Pt,transform:"scale(1.15)"},Po={...Pt,backgroundColor:"var(--fl-resolved)"},pn={...Po,transform:"scale(1.15)"},_o={position:"absolute",bottom:-H.MARKER_POINTER,left:"50%",transform:"translateX(-50%)",width:0,height:0,borderLeft:`${H.MARKER_POINTER}px solid transparent`,borderRight:`${H.MARKER_POINTER}px solid transparent`,borderTopWidth:H.MARKER_POINTER,borderTopStyle:"solid",borderTopColor:"var(--fl-accent)",pointerEvents:"none"},hn={..._o,borderTopColor:"var(--fl-resolved)"},Mo={position:"absolute",top:`calc(100% + ${H.MARKER_POINTER+6}px)`,left:"50%",transform:"translateX(-50%)",backgroundColor:"var(--fl-text-primary)",color:"var(--fl-surface)",padding:"6px 10px",borderRadius:"var(--fl-border-radius-sm)",fontFamily:"var(--fl-font-family)",fontSize:"var(--fl-font-size-sm)",lineHeight:1.4,whiteSpace:"nowrap",pointerEvents:"none",zIndex:L.POPOVER,boxShadow:"var(--fl-shadow)",maxWidth:260,opacity:0,transition:"opacity var(--fl-duration-fast) ease-out"},yn={...Mo,opacity:1},gn={display:"flex",gap:6,alignItems:"baseline"},vn={fontWeight:"var(--fl-font-weight-medium)",color:"var(--fl-surface)"},bn={color:"rgba(255, 255, 255, 0.55)"},Sn={color:"rgba(255, 255, 255, 0.8)",whiteSpace:"normal",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:1,WebkitBoxOrient:"vertical"};function Cn(e){return e.length<=We.MAX_CONTENT_LENGTH?e:e.slice(0,We.MAX_CONTENT_LENGTH).trimEnd()+"\u2026"}function En(e){let t=e.getBoundingClientRect(),o=window.innerWidth,n=window.innerHeight;if(t.bottom<0||t.top>n||t.right<0||t.left>o)return{top:0,left:0,visible:!1};let r=t.top-H.MARKER_HEIGHT-H.MARKER_POINTER,a=t.right-H.MARKER_MIN_WIDTH/2;return{top:r,left:a,visible:!0}}var at=(0,w.memo)(function({domPath:t,comments:o,isResolved:n=!1,isNew:r=!1,resolvedElement:a}){let{portalRoot:s}=E(),[c,m]=(0,w.useState)(null),[i,d]=(0,w.useState)(!1),[l,u]=(0,w.useState)(!1),[f,v]=(0,w.useState)(!1),[A,S]=(0,w.useState)(r),[y,N]=(0,w.useState)(!1),[B,h]=(0,w.useState)([]),x=(0,w.useRef)(null),_=(0,w.useRef)(0),b=(0,w.useRef)(null),W=(0,w.useCallback)(()=>{let R=a??document.querySelector(t);if(!R){m(null);return}m(En(R))},[t,a]);(0,w.useEffect)(()=>{W()},[W]),(0,w.useEffect)(()=>{function R(){cancelAnimationFrame(_.current),_.current=requestAnimationFrame(()=>{W()})}return window.addEventListener("scroll",R,!0),window.addEventListener("resize",R),()=>{window.removeEventListener("scroll",R,!0),window.removeEventListener("resize",R),cancelAnimationFrame(_.current)}},[W]),(0,w.useEffect)(()=>{if(!A)return;let R=setTimeout(()=>S(!1),q.DURATION);return()=>clearTimeout(R)},[A]);let $=(0,w.useCallback)(()=>{h(un(q.PARTICLE_COUNT)),N(!0);let R=setTimeout(()=>{N(!1),h([])},q.DURATION+100);return()=>clearTimeout(R)},[]),j=(0,w.useCallback)(()=>{d(!0),b.current=setTimeout(()=>{u(!0)},We.HOVER_DELAY)},[]),ie=(0,w.useCallback)(()=>{d(!1),b.current&&(clearTimeout(b.current),b.current=null),u(!1)},[]);(0,w.useEffect)(()=>()=>{b.current&&clearTimeout(b.current)},[]);let ee=(0,w.useCallback)(R=>{R.stopPropagation(),u(!1),b.current&&(clearTimeout(b.current),b.current=null),v(fe=>!fe)},[]),M=(0,w.useCallback)(()=>{v(!1)},[]);if(!s||!c||!c.visible)return null;let O=o.length,Se;O===1?Se=o[o.length-1].author.name.charAt(0).toUpperCase():Se=O>H.MARKER_MAX_COUNT?"99+":`${O}`;let V;return n?V=i?pn:Po:V=i?fn:Pt,(0,Ao.createPortal)((0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)("button",{ref:x,type:"button",onClick:ee,onMouseEnter:j,onMouseLeave:ie,style:{...V,top:c.top,left:c.left},"aria-label":`${O} comment${O>1?"s":""}${n?" (resolved)":""}`,"data-fl-ignore":"",children:[Se,(0,G.jsx)("span",{style:n?hn:_o}),A?(0,G.jsx)("span",{style:{position:"absolute",top:"50%",left:"50%",width:H.MARKER_HEIGHT,height:H.MARKER_HEIGHT,borderRadius:"50%",border:"2px solid var(--fl-accent)",animation:"fl-marker-ripple var(--fl-duration-marker-ripple) ease-out forwards",pointerEvents:"none"}}):null,y?B.map((R,fe)=>(0,G.jsx)("span",{style:{position:"absolute",top:"50%",left:"50%",width:R.size,height:R.size,borderRadius:"50%",backgroundColor:R.color,pointerEvents:"none","--fl-end-dx":`${R.endX}px`,"--fl-end-dy":`${R.endY}px`,"--fl-dx":"0px","--fl-dy":"0px",animation:`fl-resolve-particle var(--fl-duration-resolve-burst) ease-out ${R.delay}ms forwards`}},fe)):null,!f&&o.length>0&&(0,G.jsxs)("span",{style:l?yn:Mo,children:[(0,G.jsxs)("span",{style:gn,children:[(0,G.jsx)("span",{style:vn,children:o[0].author.name}),(0,G.jsx)("span",{style:bn,children:ce(o[0].created_at)})]}),(0,G.jsx)("div",{style:Sn,children:Cn(o[0].content)})]})]}),f&&x.current?(0,G.jsx)(nt,{comments:o,dotRect:x.current.getBoundingClientRect(),onClose:M,onDidResolve:$}):null]}),s)});function st(e,t){let o=e.match(/\[data-feedback-id="([^"]+)"\]/);if(o){let n=document.querySelector(`[data-feedback-id="${o[1]}"]`);if(n)return{element:n,method:"feedback-id"}}try{let n=document.querySelector(e);if(n)return{element:n,method:"selector"}}catch{}if(t){let n=je(t);if(n.element)return{element:n.element,method:"fingerprint",score:n.score}}return{element:null,method:"detached"}}var Fe=require("react/jsx-runtime"),xn=60;function it(){let{groupedByDomPath:e,isDomPathFullyResolved:t,isDomPathFullyArchived:o}=ae(),{adapter:n,setDetachedDomPaths:r}=E(),a=(0,ue.useRef)(null);a.current===null&&(a.current=new Set(e.map(i=>i.domPath)));let s=(0,ue.useRef)(new Set),c=(0,ue.useMemo)(()=>e.filter(i=>!o(i.domPath)),[e,o]),m=(0,ue.useMemo)(()=>{let i=new Map;for(let d of c){let l=null;for(let f of d.comments){let v=f.element_metadata?.fingerprint;if(v){l=v;break}}let u=st(d.domPath,l);i.set(d.domPath,u)}return i},[c]);return(0,ue.useEffect)(()=>{let i=new Set;for(let[d,l]of m)l.method==="detached"&&i.add(d);r(i)},[m,r]),(0,ue.useEffect)(()=>{for(let i of c){let d=m.get(i.domPath);if(d&&d.method==="fingerprint"&&d.element&&d.score!==void 0&&d.score>=xn&&!s.current.has(i.domPath)){s.current.add(i.domPath);let l=Ee(d.element);for(let u of i.comments)u.thread_id===null&&n.updateComment(u.id,{dom_path:l}).catch(()=>{})}}},[c,m,n]),c.length===0?null:(0,Fe.jsx)(Fe.Fragment,{children:c.map(i=>{let d=m.get(i.domPath);return!d||d.method==="detached"?null:(0,Fe.jsx)(at,{domPath:i.domPath,comments:i.comments,isResolved:t(i.domPath),isNew:!a.current.has(i.domPath),resolvedElement:d.element},i.domPath)})})}var _e=require("react/jsx-runtime");function Rn(e,t){switch(t.type){case"TOGGLE_COMMENT_MODE":return{...e,isCommentMode:!e.isCommentMode};case"SET_COMMENT_MODE":return{...e,isCommentMode:t.payload};case"SET_COMMENTS":return{...e,comments:t.payload};case"ADD_COMMENT":return{...e,comments:[...e.comments,t.payload]};case"UPDATE_COMMENT":return{...e,comments:e.comments.map(o=>o.id===t.payload.id?t.payload:o)};default:return e}}var wn={isCommentMode:!1,comments:[]},ft=(0,T.createContext)(null),Tn="[data-fl-root]{--fl-accent:#E8611A;--fl-accent-hover:#C85215;--fl-accent-subtle:rgba(232,97,26,0.1);--fl-accent-glow:rgba(232,97,26,0.2);--fl-surface:#FAFAF7;--fl-surface-raised:#FFFFFF;--fl-border:#E8E5DF;--fl-border-strong:#D4CFC6;--fl-text-primary:#1A1A18;--fl-text-secondary:#6B6860;--fl-text-tertiary:#9C978E;--fl-resolved:#9C978E;--fl-z-base:100000;--fl-duration-instant:80ms;--fl-duration-fast:120ms;--fl-duration-normal:150ms;--fl-duration-marker-enter:280ms;--fl-duration-marker-ripple:400ms;--fl-duration-resolve-burst:450ms;--fl-marker-height:22px;--fl-marker-min-width:20px;--fl-marker-pointer-size:4px;--fl-marker-font-size:11px;--fl-toggle-size:36px;--fl-border-radius:8px;--fl-border-radius-sm:6px;--fl-shadow:0 2px 8px rgba(26,26,24,0.08),0 1px 2px rgba(26,26,24,0.04);--fl-shadow-lg:0 4px 16px rgba(26,26,24,0.12),0 2px 4px rgba(26,26,24,0.06);--fl-shadow-popover:0 8px 30px rgba(26,26,24,0.16),0 2px 6px rgba(26,26,24,0.08);--fl-font-family:'Instrument Sans',-apple-system,BlinkMacSystemFont,sans-serif;--fl-font-size-sm:12px;--fl-font-size-base:14px;--fl-font-size-lg:16px;--fl-line-height:1.5;--fl-font-weight-normal:400;--fl-font-weight-medium:500;font-family:var(--fl-font-family);font-size:var(--fl-font-size-base);line-height:var(--fl-line-height);color:var(--fl-text-primary);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}",An="@keyframes fl-marker-enter{0%{opacity:0;transform:scale(0.4)}50%{opacity:1;transform:scale(1.08)}72%{transform:scale(0.97)}100%{transform:scale(1.0)}}@keyframes fl-marker-ripple{0%{transform:translate(-50%,-50%) scale(0.6);opacity:0.35}100%{transform:translate(-50%,-50%) scale(2.4);opacity:0}}@keyframes fl-resolve-particle{0%{opacity:0.9;transform:translate(var(--fl-dx),var(--fl-dy)) scale(1)}100%{opacity:0;transform:translate(var(--fl-end-dx),var(--fl-end-dy)) scale(0.3)}}@keyframes fl-toggle-beam{0%{box-shadow:0 2px 8px rgba(26,26,24,0.08),0 1px 2px rgba(26,26,24,0.04),0 0 0 0 rgba(232,97,26,0.25)}70%{box-shadow:0 2px 8px rgba(26,26,24,0.08),0 1px 2px rgba(26,26,24,0.04),0 0 0 10px transparent}100%{box-shadow:0 2px 8px rgba(26,26,24,0.08),0 1px 2px rgba(26,26,24,0.04),0 0 0 0 transparent}}",Pn="@font-face{font-family:'Instrument Sans';font-style:normal;font-weight:400;font-display:swap;src:url('https://fonts.gstatic.com/s/instrumentsans/v1/pximypc9vsFDm051Uf6KVwgkfoSxQ0GsQv8To18.woff2') format('woff2')}@font-face{font-family:'Instrument Sans';font-style:normal;font-weight:500;font-display:swap;src:url('https://fonts.gstatic.com/s/instrumentsans/v1/pximypc9vsFDm051Uf6KVwgkfoSxQ0GsQv8To18.woff2') format('woff2')}@font-face{font-family:'Instrument Sans';font-style:normal;font-weight:600;font-display:swap;src:url('https://fonts.gstatic.com/s/instrumentsans/v1/pximypc9vsFDm051Uf6KVwgkfoSxQ0GsQv8To18.woff2') format('woff2')}";function _n(e,t){function o(){let n=t();return n?{sessionToken:n}:void 0}return{getConfig:n=>e.getConfig(n),getComments:(n,r)=>e.getComments(n,r,o()),addComment:n=>e.addComment(n,o()),updateComment:(n,r)=>e.updateComment(n,r,o()),uploadScreenshot:(n,r,a,s)=>e.uploadScreenshot(n,r,a,s,o()),subscribe:(n,r)=>e.subscribe(n,r,o())}}var Io="Lay:";async function Mn(e,t,o,n){if(o?.id&&n){let a=await fetch(`${e}/api/v1/sessions/identify`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:t,userId:o.id,userHash:n,userName:o.name??null})});if(!a.ok){let s=await a.json().catch(()=>({}));throw new Error(s.error??`Session error: ${a.status}`)}return a.json()}let r=await fetch(`${e}/api/v1/sessions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:t})});if(!r.ok){let a=await r.json().catch(()=>({}));throw new Error(a.error??`Session error: ${r.status}`)}return r.json()}function In(e,t,o,n){return e||Be({apiUrl:o??Lo,ai:n})}var Lo="https://uselay.com";function Ln(e){return(e??Lo).replace(/\/$/,"")}function ko({children:e,projectId:t,user:o,userHash:n,adapter:r,apiUrl:a,version:s,ai:c,mode:m,active:i,starterChips:d,screenshots:l,onCommentAdded:u}){let[f,v]=(0,T.useReducer)(Rn,wn),A=(0,T.useRef)(u);A.current=u;let S=(0,T.useRef)(In(r,t,a,c)),[y,N]=(0,T.useState)(null),[B,h]=(0,T.useState)(new Set),[x,_]=(0,T.useState)(null),b=(0,T.useRef)(null),[W,$]=(0,T.useState)(!1),j=(0,T.useCallback)(g=>{b.current=g,_(g),g?zt(t,g):Gt(t)},[t]),ie=(0,T.useRef)(_n(S.current,()=>b.current)),[ee,M]=(0,T.useState)("review"),[O,Se]=(0,T.useState)(!0),[V,R]=(0,T.useState)(!1),[fe,Me]=(0,T.useState)("loading"),oe=m??ee,p=i??O;(0,T.useEffect)(()=>{S.current.getConfig(t).then(g=>{M(g.mode),Se(g.active),Me(g.active?"valid":"inactive"),R(!0)},g=>{g instanceof Le&&g.status===404?Me("not_found"):Me("valid"),R(!0)})},[t]),(0,T.useEffect)(()=>{if(oe!=="support"){$(!0);return}if(!V)return;o?.id&&!n&&console.warn(`${Io} user.id provided without userHash in support mode. Comments will be anonymous. Use identifyUser() from @uselay/sdk/server for verified identity.`);let g=Ft(t);if(g){j(g),$(!0);return}let z=Ln(a);Mn(z,t,o,n).then(pe=>{j(pe.token),$(!0)},pe=>{console.warn(`${Io} Failed to create session:`,pe),$(!0)})},[t,oe,V,o,n,a,j]),(0,T.useEffect)(()=>{let g=document.createElement("div");g.setAttribute(ne.ROOT,""),g.setAttribute(ne.IGNORE,""),document.body.appendChild(g);let z=document.createElement("style");return z.textContent=Pn+Tn+An,g.appendChild(z),N(g),()=>{document.body.removeChild(g)}},[]),(0,T.useEffect)(()=>{if(!W||oe==="support"&&!b.current)return;let g=window.location.pathname;ie.current.getComments(t,g).then(z=>{v({type:"SET_COMMENTS",payload:z})},z=>{if(z instanceof Error&&z.message.includes("401")){j(null),$(!1);return}})},[t,W,x,oe,j]),(0,T.useEffect)(()=>{if(!W||oe==="support"&&!b.current)return;let g;try{g=ie.current.subscribe(t,z=>{switch(z.type){case"INSERT":v({type:"ADD_COMMENT",payload:z.comment});break;case"UPDATE":v({type:"UPDATE_COMMENT",payload:z.comment});break}})}catch{}return()=>g?.()},[t,W,x,oe]);let P={projectId:t,user:o,userHash:n,apiUrl:a,version:s,ai:c,mode:m,active:i,starterChips:d,screenshots:l},Z=fe==="not_found",re=y&&V&&W&&p&&!Z,Te=y&&V&&Z&&Ot(),Ie={isCommentMode:f.isCommentMode,comments:f.comments,adapter:ie.current,config:P,dispatch:v,portalRoot:y,mode:oe,projectStatus:fe,remoteConfigLoaded:V,detachedDomPaths:B,setDetachedDomPaths:h,onCommentAddedRef:A};return(0,_e.jsxs)(ft.Provider,{value:Ie,children:[e,(re||Te)&&(0,_e.jsx)(Ve,{}),re&&(0,_e.jsx)(et,{}),re&&(0,_e.jsx)(it,{})]})}var No=require("react");function ze(e){return e.mode==="review"}function Do(e){return e.mode==="support"}var k=require("react/jsx-runtime"),kn={marginTop:6,border:"1px solid var(--fl-border)",borderRadius:"var(--fl-border-radius-sm)",backgroundColor:"var(--fl-surface)",fontFamily:"var(--fl-font-family)",fontSize:12,overflow:"hidden"},Dn={display:"flex",alignItems:"flex-start",gap:6,padding:"6px 8px",cursor:"pointer",userSelect:"none",color:"var(--fl-text-secondary)",lineHeight:1.4},Nn={flexShrink:0,fontSize:10,lineHeight:"16.8px",color:"var(--fl-text-tertiary)"},On={minWidth:0,wordBreak:"break-word"},Hn={padding:"0 8px 8px",display:"flex",flexDirection:"column",gap:6},Fn={fontSize:11,fontWeight:600,color:"var(--fl-text-tertiary)",textTransform:"uppercase",letterSpacing:.5,marginBottom:2,fontFamily:"var(--fl-font-family)"},lt={display:"inline-block",fontSize:11,fontWeight:500,padding:"1px 6px",borderRadius:3,backgroundColor:"var(--fl-border)",color:"var(--fl-text-secondary)",fontFamily:"var(--fl-font-family)"},zn={...lt,backgroundColor:"#D32F2F",color:"#FFFFFF"},Gn={...lt,backgroundColor:"#F9A825",color:"#1A1A18"},_t={fontSize:12,lineHeight:1.5,color:"var(--fl-text-primary)",fontFamily:"var(--fl-font-family)"},Bn={fontSize:12,color:"var(--fl-text-tertiary)",fontFamily:"var(--fl-font-family)",fontStyle:"italic",animation:"fl-analyzing-pulse 1.5s ease-in-out infinite"},Wn={display:"flex",gap:6,flexWrap:"wrap",marginBottom:4},$n="@keyframes fl-analyzing-pulse{0%,100%{opacity:0.4}50%{opacity:1}}";function Un(e){return e?ze(e)?e.category:`${e.intent.replace("_"," ")} \xB7 ${e.urgency} urgency`:"Analyzing..."}function Kn(e){return e==="high"?zn:e==="medium"?Gn:lt}function Oo({elementMetadata:e,aiContext:t,aiEnabled:o=!0}){let[n,r]=(0,No.useState)(!1);if(!e||!o||t&&!("mode"in t))return null;let a=Un(t),s=!t;return(0,k.jsxs)("div",{style:kn,children:[s&&(0,k.jsx)("style",{children:$n}),(0,k.jsxs)("div",{style:Dn,onClick:()=>r(c=>!c),role:"button",tabIndex:0,onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),r(m=>!m))},children:[(0,k.jsx)("span",{style:Nn,children:n?"\u25BE":"\u25B8"}),(0,k.jsx)("span",{style:On,children:n?"AI Interpretation":a})]}),n&&(0,k.jsx)("div",{style:Hn,children:s?(0,k.jsxs)("div",{children:[(0,k.jsx)("div",{style:Fn,children:"AI Interpretation"}),(0,k.jsx)("div",{style:Bn,children:"Analyzing..."})]}):t&&ze(t)?(0,k.jsx)("div",{children:t.interpretation?(0,k.jsx)("div",{style:_t,children:t.interpretation}):(0,k.jsx)("div",{style:_t,children:t.category})}):t?(0,k.jsxs)("div",{children:[(0,k.jsxs)("div",{style:Wn,children:[(0,k.jsx)("span",{style:lt,children:t.intent.replace("_"," ")}),(0,k.jsxs)("span",{style:Kn(t.urgency),children:[t.urgency," urgency"]})]}),(0,k.jsx)("div",{style:_t,children:t.summary})]}):null})]})}function Xn(){return`${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function Ho(){let e=[],t=new Set;function o(n){t.forEach(r=>r(n))}return{async getConfig(){return{mode:"review",active:!0}},async getComments(n,r,a){let s=e.filter(c=>c.project_id===n&&c.url_path===r);return a?.sessionToken&&(s=s.filter(c=>c.author.id===a.sessionToken)),s},async addComment(n){let r=new Date().toISOString(),a={...n,id:Xn(),created_at:r,updated_at:r};return e.push(a),o({type:"INSERT",comment:a}),a},async updateComment(n,r){let a=e.findIndex(c=>c.id===n);if(a===-1)throw new Error(`Comment not found: ${n}`);let s={...e[a],...r,updated_at:new Date().toISOString()};return e[a]=s,o({type:"UPDATE",comment:s}),s},async uploadScreenshot(){},subscribe(n,r){return t.add(r),()=>{t.delete(r)}}}}0&&(module.exports={AIContextCard,ArchivedThreadsPanel,CommentActions,CommentAnchor,CommentDot,CommentDots,CommentItem,CommentLayer,CommentThread,DetachedCommentsPanel,ElementHighlighter,LayProvider,LayToggle,ReplyInput,captureElementMetadata,computeContrastRatio,createHostedAdapter,createMemoryAdapter,findByFingerprint,formatRelativeTime,generateDomPath,generateFingerprint,getGuestAuthor,isAIContextReview,isAIContextSupport,isCommentable,isGeneratedClassName,parseUserAgent,persistGuestName,resolveAuthor,resolveEffectiveBackground,resolveElement,saveGuestAuthor,scoreFingerprintMatch,summarizeDomPath,useCommentMode,useComments,useElementSelector,useLayContext});
1
+ "use strict";var Fo=Object.create;var Ge=Object.defineProperty;var zo=Object.getOwnPropertyDescriptor;var Go=Object.getOwnPropertyNames;var Bo=Object.getPrototypeOf,Wo=Object.prototype.hasOwnProperty;var $o=(e,t)=>{for(var o in t)Ge(e,o,{get:t[o],enumerable:!0})},Mt=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Go(t))!Wo.call(e,r)&&r!==o&&Ge(e,r,{get:()=>t[r],enumerable:!(n=zo(t,r))||n.enumerable});return e};var It=(e,t,o)=>(o=e!=null?Fo(Bo(e)):{},Mt(t||!e||!e.__esModule?Ge(o,"default",{value:e,enumerable:!0}):o,e)),Uo=e=>Mt(Ge({},"__esModule",{value:!0}),e);var Vn={};$o(Vn,{AIContextCard:()=>Oo,ArchivedThreadsPanel:()=>Ue,CommentActions:()=>ot,CommentAnchor:()=>Qe,CommentDot:()=>at,CommentDots:()=>it,CommentItem:()=>He,CommentLayer:()=>et,CommentThread:()=>nt,DetachedCommentsPanel:()=>Xe,ElementHighlighter:()=>qe,LayProvider:()=>ko,LayToggle:()=>Ve,ReplyInput:()=>rt,captureElementMetadata:()=>Oe,computeContrastRatio:()=>xt,createHostedAdapter:()=>Be,createMemoryAdapter:()=>Ho,findByFingerprint:()=>je,formatRelativeTime:()=>ce,generateDomPath:()=>Ee,generateFingerprint:()=>Ye,getGuestAuthor:()=>ye,isAIContextReview:()=>ze,isAIContextSupport:()=>Do,isCommentable:()=>xe,isGeneratedClassName:()=>vt,parseUserAgent:()=>Rt,persistGuestName:()=>Pe,resolveAuthor:()=>me,resolveEffectiveBackground:()=>Et,resolveElement:()=>st,saveGuestAuthor:()=>Je,scoreFingerprintMatch:()=>bt,summarizeDomPath:()=>Ke,useCommentMode:()=>$e,useComments:()=>ae,useElementSelector:()=>Ze,useLayContext:()=>E});module.exports=Uo(Vn);var T=require("react");var Ko="https://www.uselay.com",Xo="Lay:";function ct(e){console.warn(`${Xo} ${e}`)}var Le=class extends Error{constructor(t,o){super(t),this.name="ApiError",this.status=o}};function Be(e){let t=typeof e=="string"?{apiUrl:e}:e??{},o=(t.apiUrl??Ko).replace(/\/$/,""),n=t.ai!==!1;function r(s){return s?{Authorization:`Bearer ${s}`}:{}}async function a(s,c,m){let i;try{i=await fetch(`${o}${s}`,{...c,headers:{"Content-Type":"application/json",...r(m),...c?.headers??{}}})}catch{throw ct("Unable to reach API. Comments won't persist."),new Error("Network error")}if(!i.ok){let l=(await i.json().catch(()=>({}))).error??`API error: ${i.status}`;throw i.status===403?ct("This domain is not authorized for this project."):i.status===404&&ct("Invalid project ID. Comments won't persist."),new Le(l,i.status)}return i.json()}return{async getConfig(s){let c=new URLSearchParams({projectId:s});return a(`/api/v1/config?${c.toString()}`)},async getComments(s,c,m){let i=new URLSearchParams({projectId:s,urlPath:c});return a(`/api/v1/comments?${i.toString()}`,void 0,m?.sessionToken)},async addComment(s,c){return a("/api/v1/comments",{method:"POST",body:JSON.stringify(s),...n?{}:{headers:{"X-FL-AI":"false"}}},c?.sessionToken)},async updateComment(s,c,m){return a(`/api/v1/comments/${s}`,{method:"PATCH",body:JSON.stringify(c)},m?.sessionToken)},async uploadScreenshot(s,c,m,i,d){let l=new FormData,u=m.type==="image/png"?"png":"webp";l.append("file",m,`${c}.${u}`),l.append("projectId",s),l.append("commentId",c),l.append("elementBounds",JSON.stringify(i));let f={};d?.sessionToken&&(f.Authorization=`Bearer ${d.sessionToken}`);let v;try{v=await fetch(`${o}/api/v1/screenshots`,{method:"POST",headers:f,body:l})}catch{return}v.ok},subscribe(s,c,m){let i=new URLSearchParams({projectId:s});m?.sessionToken&&i.set("token",m.sessionToken);let d=`${o}/api/v1/stream?${i.toString()}`,l=new EventSource(d);return l.onmessage=u=>{try{let f=JSON.parse(u.data);(f.type==="INSERT"||f.type==="UPDATE")&&c(f)}catch{}},l.onerror=()=>{},()=>{l.close()}}}}var L={BASE:1e5,HIGHLIGHT:100001,DOT:100002,POPOVER:100003,TOGGLE:100004};var q={PARTICLE_COUNT:5,PARTICLE_SIZE_MIN:3,PARTICLE_SIZE_MAX:4,DURATION:450,SPREAD_ANGLE:120,DISTANCE_MIN:14,DISTANCE_MAX:28},H={MARKER_HEIGHT:22,MARKER_MIN_WIDTH:20,MARKER_POINTER:4,MARKER_FONT_SIZE:11,MARKER_MAX_COUNT:99,TOGGLE_SIZE:36,BORDER_RADIUS:8,BORDER_RADIUS_SM:6,HIGHLIGHT_OUTLINE:2},Lt={TOGGLE_COMMENT_MODE:"c"},ne={ROOT:"data-fl-root",IGNORE:"data-fl-ignore"},dt={ANCESTOR_DEPTH:4,PROXIMITY_THRESHOLD:30},kt={MAX_SEGMENTS:3,MAX_LENGTH:50},Ae={WIDTH:320,COLLAPSED_HEIGHT:40,GAP:8,EXPAND_DURATION:150},Dt=[{label:"Visual bug",value:"Visual bug"},{label:"Copy issue",value:"Copy issue"},{label:"Love this",value:"Love this"}],We={HOVER_DELAY:300,MAX_CONTENT_LENGTH:60},mt={WIDTH:280,Z_INDEX:100005},Nt="https://www.uselay.com/dashboard";function Ot(){if(typeof window>"u")return!1;let e=window.location.hostname;return e==="localhost"||e==="127.0.0.1"}var Ht={id:null,name:"Anonymous",avatar:null};var ut="lay_session_";function Ft(e){try{return localStorage.getItem(`${ut}${e}`)}catch{return null}}function zt(e,t){try{localStorage.setItem(`${ut}${e}`,t)}catch{}}function Gt(e){try{localStorage.removeItem(`${ut}${e}`)}catch{}}var K=require("react"),qt=require("react-dom");var ke=require("react");var Bt=require("react");function E(){let e=(0,Bt.useContext)(ft);if(!e)throw new Error("useLayContext must be used within a <LayProvider />. Wrap your app in <LayProvider> to use uselay.");return e}function $e(){let{isCommentMode:e,projectStatus:t,dispatch:o}=E(),n=(0,ke.useCallback)(()=>{t!=="not_found"&&o({type:"TOGGLE_COMMENT_MODE"})},[o,t]),r=(0,ke.useCallback)(a=>{o({type:"SET_COMMENT_MODE",payload:a})},[o]);return(0,ke.useEffect)(()=>{function a(s){let c=s.target;c.tagName==="INPUT"||c.tagName==="TEXTAREA"||c.tagName==="SELECT"||c.isContentEditable||s.key.toLowerCase()===Lt.TOGGLE_COMMENT_MODE&&!s.metaKey&&!s.ctrlKey&&!s.altKey&&(s.preventDefault(),n())}return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[n]),{isCommentMode:e,toggleCommentMode:n,setCommentMode:r}}var Ce=require("react");function ae(){let{comments:e,detachedDomPaths:t}=E(),o=(0,Ce.useMemo)(()=>{let d=new Map;for(let l of e){let u=d.get(l.dom_path);u?u.push(l):d.set(l.dom_path,[l])}return Array.from(d,([l,u])=>({domPath:l,comments:u}))},[e]),n=(0,Ce.useMemo)(()=>{let d=new Map;for(let l of e){let u=d.get(l.dom_path);u?u.push(l):d.set(l.dom_path,[l])}return Array.from(d,([l,u])=>{let f=[],v=new Map;for(let S of u)if(S.thread_id===null)f.push(S);else{let y=v.get(S.thread_id);y?y.push(S):v.set(S.thread_id,[S])}f.sort((S,y)=>new Date(S.created_at).getTime()-new Date(y.created_at).getTime());let A=f.map(S=>{let y=v.get(S.id)??[];return y.sort((N,B)=>new Date(N.created_at).getTime()-new Date(B.created_at).getTime()),{root:S,replies:y}});return{domPath:l,threads:A,allComments:u}})},[e]),r=(0,Ce.useMemo)(()=>e.filter(l=>l.thread_id===null&&l.status==="archived").map(l=>{let u=e.filter(f=>f.thread_id===l.id).sort((f,v)=>new Date(f.created_at).getTime()-new Date(v.created_at).getTime());return{root:l,replies:u}}),[e]),a=r.length,s=(0,Ce.useMemo)(()=>t.size===0?[]:e.filter(l=>l.thread_id===null&&t.has(l.dom_path)&&l.status!=="archived").map(l=>{let u=e.filter(f=>f.thread_id===l.id).sort((f,v)=>new Date(f.created_at).getTime()-new Date(v.created_at).getTime());return{root:l,replies:u}}),[e,t]),c=s.length,m=(0,Ce.useMemo)(()=>{let d=new Map;for(let l of e)l.thread_id!==null||d.get(l.dom_path)===!1||d.set(l.dom_path,l.status==="resolved"||l.status==="archived");return l=>d.get(l)??!1},[e]),i=(0,Ce.useMemo)(()=>{let d=new Map;for(let l of e)l.thread_id!==null||d.get(l.dom_path)===!1||d.set(l.dom_path,l.status==="archived");return l=>d.get(l)??!1},[e]);return{comments:e,groupedByDomPath:o,threadsByDomPath:n,archivedThreads:r,archivedCount:a,detachedThreads:s,detachedCount:c,isDomPathFullyResolved:m,isDomPathFullyArchived:i}}var le=require("react"),Wt=require("react-dom");var J=require("react/jsx-runtime"),Vo={position:"fixed",top:"50%",right:60,transform:"translateY(-50%)",width:300,maxHeight:320,backgroundColor:"var(--fl-surface-raised)",border:"1px solid var(--fl-border)",borderRadius:"var(--fl-border-radius)",boxShadow:"var(--fl-shadow-lg)",fontFamily:"var(--fl-font-family)",fontSize:"var(--fl-font-size-base)",color:"var(--fl-text-primary)",display:"flex",flexDirection:"column",overflow:"hidden",zIndex:L.POPOVER},Yo={padding:"10px 12px",fontSize:"var(--fl-font-size-sm)",fontWeight:"var(--fl-font-weight-medium)",color:"var(--fl-text-secondary)",fontFamily:"var(--fl-font-family)",borderBottom:"1px solid var(--fl-border)",flexShrink:0},jo={overflowY:"auto",flexGrow:1,minHeight:0},Zo={padding:"20px 12px",textAlign:"center",fontSize:"var(--fl-font-size-sm)",color:"var(--fl-text-tertiary)",fontFamily:"var(--fl-font-family)"},qo={padding:"10px 12px",borderBottom:"1px solid var(--fl-border)",fontFamily:"var(--fl-font-family)"},Jo={fontSize:"var(--fl-font-size-sm)",color:"var(--fl-text-primary)",fontFamily:"var(--fl-font-family)",lineHeight:"var(--fl-line-height)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},Qo={display:"flex",alignItems:"center",justifyContent:"space-between",marginTop:4},er={fontSize:"var(--fl-font-size-sm)",color:"var(--fl-text-tertiary)",fontFamily:"var(--fl-font-family)"},$t={display:"inline-flex",alignItems:"center",padding:"2px 8px",border:"none",borderRadius:"var(--fl-border-radius-sm)",backgroundColor:"transparent",color:"var(--fl-text-tertiary)",cursor:"pointer",fontFamily:"var(--fl-font-family)",fontSize:"var(--fl-font-size-sm)",fontWeight:"var(--fl-font-weight-medium)",transition:"color var(--fl-duration-fast) ease-out"},tr={...$t,color:"var(--fl-accent)"};function or({thread:e,onRestore:t}){let[o,n]=(0,le.useState)(!1);return(0,J.jsxs)("div",{style:qo,children:[(0,J.jsxs)("div",{style:Jo,children:["\u201C",e.root.content,"\u201D"]}),(0,J.jsxs)("div",{style:Qo,children:[(0,J.jsx)("span",{style:er,children:e.root.author.name}),(0,J.jsx)("button",{type:"button",style:o?tr:$t,onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),onClick:()=>t(e.root),children:"Restore"})]})]})}function Ue({onClose:e}){let{portalRoot:t,adapter:o,config:n,dispatch:r}=E(),{archivedThreads:a}=ae(),s=(0,le.useRef)(null),c=(0,le.useCallback)(m=>{let i={...m,status:"open",resolved_by:null,resolved_at:null,archived_at:null};r({type:"UPDATE_COMMENT",payload:i}),o.updateComment(m.id,{status:"open",resolved_by:null,resolved_at:null,archived_at:null}).catch(()=>{r({type:"UPDATE_COMMENT",payload:m})})},[o,r]);return(0,le.useEffect)(()=>{function m(i){i.key==="Escape"&&(i.preventDefault(),e())}return document.addEventListener("keydown",m,!0),()=>document.removeEventListener("keydown",m,!0)},[e]),(0,le.useEffect)(()=>{function m(d){let l=d.target;s.current?.contains(l)||l.closest("[data-fl-ignore]")||e()}let i=setTimeout(()=>{document.addEventListener("mousedown",m,!0)},50);return()=>{clearTimeout(i),document.removeEventListener("mousedown",m,!0)}},[e]),t?(0,Wt.createPortal)((0,J.jsxs)("div",{ref:s,style:Vo,"data-fl-ignore":"",children:[(0,J.jsx)("div",{style:Yo,children:"Archived Threads"}),(0,J.jsx)("div",{style:jo,children:a.length===0?(0,J.jsx)("div",{style:Zo,children:"No archived threads on this page."}):a.map(m=>(0,J.jsx)(or,{thread:m,onRestore:c},m.root.id))})]}),t):null}var De=require("react"),Vt=require("react-dom");function ce(e){let t=new Date(e),o=new Date,n=o.getTime()-t.getTime(),r=Math.floor(n/1e3),a=Math.floor(r/60),s=Math.floor(a/60),c=Math.floor(s/24);if(r<60)return"just now";if(a<60)return`${a} min ago`;if(s<24)return`${s} hr ago`;if(c===1)return"Yesterday";let m=t.toLocaleString("en-US",{month:"short"}),i=t.getDate();return t.getFullYear()===o.getFullYear()?`${m} ${i}`:`${m} ${i}, ${t.getFullYear()}`}var Ut={nav:"navigation",main:"main",header:"header",footer:"footer",section:"section",article:"article",aside:"sidebar",form:"form",table:"table",ul:"list",ol:"list",li:"item",h1:"heading",h2:"heading",h3:"heading",h4:"heading",h5:"heading",h6:"heading",p:"text",img:"image",figure:"figure",video:"video",picture:"image",button:"button",a:"link",input:"input",select:"dropdown",textarea:"text input"};function rr(e){let t=e.tagName.toLowerCase();if(e.id)return`#${e.id}`;let o=e.getAttribute("aria-label");if(o)return`"${pt(o,20)}"`;if(["button","a","h1","h2","h3","h4","h5","h6"].includes(t)){let r=e.textContent?.trim();if(r&&r.length<=25)return`"${pt(r,20)}" ${Ut[t]??t}`}let n=e.getAttribute("data-testid")??e.getAttribute("data-feedback-id");return n||(Ut[t]??t)}function Xt(e){let t=[],o=e;for(;o&&o!==document.body&&(t.unshift(rr(o)),!o.id);)o=o.parentElement;return e.closest("[id]")||t.unshift("page"),t.slice(-kt.MAX_SEGMENTS)}function Ke(e){let t=e.split(/\s*>\s*/);if(t.length===0)return e;let o=Kt(t[t.length-1]),n="";for(let a=t.length-2;a>=0;a--){let s=t[a];if(s.includes("#")||s.includes("[data-feedback-id")||s.includes("[data-testid")){n=Kt(s);break}let c=s.split(/[.:[\s]/)[0];if(["main","nav","header","footer","section","article","aside","form"].includes(c)){n=c;break}}let r=n?`${o} in ${n}`:o;return pt(r,30)}function Kt(e){let t=e.match(/\[data-(?:feedback-id|testid)="([^"]+)"\]/);if(t)return t[1];let o=e.match(/#([a-zA-Z0-9_-]+)/);if(o)return`#${o[1]}`;let n=e.match(/^([a-z]+)\.([a-zA-Z0-9_-]+)/);if(n)return`${n[1]}.${n[2]}`;let r=e.match(/^([a-z]+):nth-child\(\d+\)/);return r?r[1]:e}function pt(e,t){return e.length>t?e.slice(0,t-1)+"\u2026":e}var U=require("react/jsx-runtime"),nr={position:"fixed",top:"50%",right:60,transform:"translateY(-50%)",width:300,maxHeight:320,backgroundColor:"var(--fl-surface-raised)",borderWidth:1,borderStyle:"solid",borderColor:"var(--fl-border)",borderRadius:"var(--fl-border-radius)",boxShadow:"var(--fl-shadow-lg)",fontFamily:"var(--fl-font-family)",fontSize:"var(--fl-font-size-base)",color:"var(--fl-text-primary)",display:"flex",flexDirection:"column",overflow:"hidden",zIndex:L.POPOVER},ar={padding:"10px 12px",fontSize:"var(--fl-font-size-sm)",fontWeight:"var(--fl-font-weight-medium)",color:"var(--fl-text-secondary)",fontFamily:"var(--fl-font-family)",borderBottomWidth:1,borderBottomStyle:"solid",borderBottomColor:"var(--fl-border)",flexShrink:0},sr={padding:"6px 12px 8px",fontSize:11,color:"var(--fl-text-tertiary)",fontFamily:"var(--fl-font-family)",lineHeight:1.4},ir={overflowY:"auto",flexGrow:1,minHeight:0},lr={padding:"20px 12px",textAlign:"center",fontSize:"var(--fl-font-size-sm)",color:"var(--fl-text-tertiary)",fontFamily:"var(--fl-font-family)"},cr={padding:"10px 12px",borderBottomWidth:1,borderBottomStyle:"solid",borderBottomColor:"var(--fl-border)",fontFamily:"var(--fl-font-family)"},dr={fontSize:"var(--fl-font-size-sm)",color:"var(--fl-text-primary)",fontFamily:"var(--fl-font-family)",lineHeight:"var(--fl-line-height)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},mr={display:"flex",alignItems:"center",justifyContent:"space-between",marginTop:4},ur={fontSize:"var(--fl-font-size-sm)",color:"var(--fl-text-tertiary)",fontFamily:"var(--fl-font-family)"},fr={fontSize:11,color:"var(--fl-text-tertiary)",fontFamily:"var(--fl-font-family)"},pr={marginTop:4,fontSize:11,color:"var(--fl-text-tertiary)",fontFamily:"var(--fl-font-family)",fontStyle:"italic"};function hr({thread:e}){let t=Ke(e.root.dom_path);return(0,U.jsxs)("div",{style:cr,children:[(0,U.jsxs)("div",{style:dr,children:["\u201C",e.root.content,"\u201D"]}),(0,U.jsxs)("div",{style:mr,children:[(0,U.jsx)("span",{style:ur,children:e.root.author.name}),(0,U.jsx)("span",{style:fr,children:ce(e.root.created_at)})]}),(0,U.jsxs)("div",{style:pr,children:["Was on: ",t]})]})}function Xe({onClose:e}){let{portalRoot:t}=E(),{detachedThreads:o}=ae(),n=(0,De.useRef)(null);return(0,De.useEffect)(()=>{function r(a){a.key==="Escape"&&(a.preventDefault(),e())}return document.addEventListener("keydown",r,!0),()=>document.removeEventListener("keydown",r,!0)},[e]),(0,De.useEffect)(()=>{function r(s){let c=s.target;n.current?.contains(c)||c.closest("[data-fl-ignore]")||e()}let a=setTimeout(()=>{document.addEventListener("mousedown",r,!0)},50);return()=>{clearTimeout(a),document.removeEventListener("mousedown",r,!0)}},[e]),t?(0,Vt.createPortal)((0,U.jsxs)("div",{ref:n,style:nr,"data-fl-ignore":"",children:[(0,U.jsx)("div",{style:ar,children:"Detached Comments"}),(0,U.jsx)("div",{style:sr,children:"These comments can't find their original element."}),(0,U.jsx)("div",{style:ir,children:o.length===0?(0,U.jsx)("div",{style:lr,children:"No detached comments on this page."}):o.map(r=>(0,U.jsx)(hr,{thread:r},r.root.id))})]}),t):null}var Ne=require("react");var F=require("react/jsx-runtime"),yr={heading:"Lay is installed.",body:"Create a free project to start collecting feedback on your site.",cta:"Get started"},gr={heading:"Project not found.",body:"Check your project ID, or create a new project from the dashboard.",cta:"Open dashboard"},vr={position:"fixed",inset:0,zIndex:L.TOGGLE-1},br={position:"fixed",right:60,top:"50%",transform:"translateY(-50%)",width:mt.WIDTH,zIndex:mt.Z_INDEX,backgroundColor:"var(--fl-surface-raised)",borderWidth:1,borderStyle:"solid",borderColor:"var(--fl-border)",borderRadius:"var(--fl-border-radius)",boxShadow:"var(--fl-shadow-popover)",padding:"20px 18px 16px",fontFamily:"var(--fl-font-family)",opacity:0,animation:"fl-welcome-fade-in var(--fl-duration-normal) ease-out forwards"},Sr={position:"absolute",top:10,right:10,width:20,height:20,display:"flex",alignItems:"center",justifyContent:"center",background:"none",border:"none",cursor:"pointer",color:"var(--fl-text-tertiary)",padding:0,borderRadius:4,transition:"color var(--fl-duration-fast) ease-out"},Cr={fontSize:"var(--fl-font-size-base)",fontWeight:"var(--fl-font-weight-medium)",color:"var(--fl-text-primary)",margin:"0 0 6px",lineHeight:"var(--fl-line-height)",paddingRight:16},Er={fontSize:"var(--fl-font-size-sm)",color:"var(--fl-text-secondary)",lineHeight:1.5,margin:"0 0 16px"},xr={display:"inline-flex",alignItems:"center",gap:4,fontSize:"var(--fl-font-size-sm)",fontWeight:"var(--fl-font-weight-medium)",fontFamily:"var(--fl-font-family)",color:"var(--fl-accent)",background:"none",border:"none",cursor:"pointer",padding:0,transition:"opacity var(--fl-duration-fast) ease-out",textDecoration:"none"},Rr="@keyframes fl-welcome-fade-in{0%{opacity:0;transform:translateY(-50%) translateX(6px)}100%{opacity:1;transform:translateY(-50%) translateX(0)}}";function Yt({hasProjectId:e,onDismiss:t}){let o=(0,Ne.useRef)(null),n=e?gr:yr;return(0,Ne.useEffect)(()=>{function r(a){o.current&&!o.current.contains(a.target)&&t()}return document.addEventListener("pointerdown",r,!0),()=>document.removeEventListener("pointerdown",r,!0)},[t]),(0,Ne.useEffect)(()=>{function r(a){a.key==="Escape"&&t()}return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[t]),(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)("style",{dangerouslySetInnerHTML:{__html:Rr}}),(0,F.jsx)("div",{style:vr,[ne.IGNORE]:""}),(0,F.jsxs)("div",{ref:o,role:"dialog","aria-label":n.heading,style:br,[ne.IGNORE]:"",children:[(0,F.jsx)("button",{type:"button",style:Sr,onClick:t,"aria-label":"Dismiss",onMouseEnter:r=>{r.currentTarget.style.color="var(--fl-text-primary)"},onMouseLeave:r=>{r.currentTarget.style.color="var(--fl-text-tertiary)"},children:(0,F.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:(0,F.jsx)("path",{d:"M2 2l8 8M10 2l-8 8"})})}),(0,F.jsx)("p",{style:Cr,children:n.heading}),(0,F.jsx)("p",{style:Er,children:n.body}),(0,F.jsxs)("a",{href:Nt,target:"_blank",rel:"noopener noreferrer",style:xr,onMouseEnter:r=>{r.currentTarget.style.opacity="0.8"},onMouseLeave:r=>{r.currentTarget.style.opacity="1"},children:[n.cta,(0,F.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,F.jsx)("path",{d:"M5 12h14M12 5l7 7-7 7"})})]})]})]})}var D=require("react/jsx-runtime"),gt={position:"fixed",right:16,top:"50%",transform:"translateY(-50%)",width:"var(--fl-toggle-size)",height:"var(--fl-toggle-size)",borderRadius:"50%",borderWidth:1.5,borderStyle:"solid",borderColor:"var(--fl-border)",backgroundColor:"var(--fl-surface-raised)",color:"var(--fl-text-secondary)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",zIndex:L.TOGGLE,boxShadow:"var(--fl-shadow)",animation:"fl-toggle-beam 2s ease-out 1s infinite",transition:"all var(--fl-duration-normal) ease-in-out",padding:0,outline:"none",fontFamily:"var(--fl-font-family)"},wr={...gt,transform:"translateY(-50%) translateX(-4px)",borderColor:"var(--fl-border-strong)",color:"var(--fl-text-primary)",boxShadow:"var(--fl-shadow-lg)"},ht={...gt,backgroundColor:"var(--fl-accent)",borderColor:"var(--fl-accent)",color:"#FFFFFF",boxShadow:"var(--fl-shadow-lg)",animation:"none"},jt={...ht,transform:"translateY(-50%) translateX(-4px)"},Jt={position:"absolute",right:"100%",top:"50%",transform:"translateY(-50%)",marginRight:8,padding:"4px 8px",backgroundColor:"var(--fl-text-primary)",color:"var(--fl-surface)",fontSize:"var(--fl-font-size-sm)",fontFamily:"var(--fl-font-family)",fontWeight:"var(--fl-font-weight-medium)",borderRadius:"var(--fl-border-radius-sm)",whiteSpace:"nowrap",pointerEvents:"none",opacity:0,transition:"opacity var(--fl-duration-fast) ease-out"},Tr={...Jt,opacity:1},yt={position:"absolute",right:"100%",top:"100%",marginRight:8,marginTop:4,padding:"3px 8px",backgroundColor:"var(--fl-surface-raised)",borderWidth:1,borderStyle:"solid",borderColor:"var(--fl-border)",borderRadius:10,fontSize:"var(--fl-font-size-sm)",fontFamily:"var(--fl-font-family)",fontWeight:"var(--fl-font-weight-medium)",color:"var(--fl-text-secondary)",whiteSpace:"nowrap",cursor:"pointer",lineHeight:1.3,transition:"color var(--fl-duration-fast) ease-out, border-color var(--fl-duration-fast) ease-out"},Zt={...yt,color:"var(--fl-text-primary)",borderColor:"var(--fl-border-strong)"};function Ar({active:e}){return(0,D.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:e?"#FFFFFF":"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,D.jsx)("path",{d:"M3 7V5a2 2 0 0 1 2-2h2"}),(0,D.jsx)("path",{d:"M17 3h2a2 2 0 0 1 2 2v2"}),(0,D.jsx)("path",{d:"M21 17v2a2 2 0 0 1-2 2h-2"}),(0,D.jsx)("path",{d:"M7 21H5a2 2 0 0 1-2-2v-2"})]})}function Ve(){let{isCommentMode:e,toggleCommentMode:t}=$e(),{portalRoot:o,mode:n,projectStatus:r,config:a}=E(),{archivedCount:s,detachedCount:c}=ae(),m=r==="not_found",i=n!=="support"&&!m,[d,l]=(0,K.useState)(!1),[u,f]=(0,K.useState)(!1),[v,A]=(0,K.useState)(!1),[S,y]=(0,K.useState)(!1),[N,B]=(0,K.useState)(!1),[h,x]=(0,K.useState)(!1),_=(0,K.useCallback)(M=>{M.stopPropagation(),y(O=>!O),B(!1)},[]),b=(0,K.useCallback)(M=>{M.stopPropagation(),B(O=>!O),y(!1)},[]),W=(0,K.useCallback)(()=>{y(!1)},[]),$=(0,K.useCallback)(()=>{B(!1)},[]),j=(0,K.useCallback)(()=>{m?x(M=>!M):t()},[m,t]),ie=(0,K.useCallback)(()=>{x(!1)},[]);if(!o)return null;let ee;return m&&h||e?ee=d?jt:ht:ee=d?wr:gt,(0,qt.createPortal)((0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)("button",{type:"button",onClick:j,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),style:ee,"aria-label":m?"Set up Lay":e?"Exit comment mode":"Enter comment mode",[ne.IGNORE]:"",children:[(0,D.jsx)(Ar,{active:e||m&&h}),(0,D.jsx)("span",{style:d?Tr:Jt,children:m?"Set up Lay":"Comment mode (C)"}),i&&s>0&&(0,D.jsxs)("span",{role:"button",tabIndex:0,style:u?Zt:yt,onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),onClick:_,onKeyDown:M=>{(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),_(M))},children:[s," archived"]}),i&&c>0&&(0,D.jsxs)("span",{role:"button",tabIndex:0,style:{...v?Zt:yt,top:s>0?"calc(100% + 28px)":"100%"},onMouseEnter:()=>A(!0),onMouseLeave:()=>A(!1),onClick:b,onKeyDown:M=>{(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),b(M))},children:[c," detached"]})]}),i&&S&&(0,D.jsx)(Ue,{onClose:W}),i&&N&&(0,D.jsx)(Xe,{onClose:$}),m&&h&&(0,D.jsx)(Yt,{hasProjectId:!!a.projectId,onDismiss:ie})]}),o)}var he=require("react");function Ee(e){let t=[],o=e;for(;o&&o!==document.documentElement;){if(o===document.body){t.unshift("body");break}let n=o.getAttribute("data-feedback-id");if(n){t.unshift(`[data-feedback-id="${n}"]`);break}let r=o.getAttribute("data-testid");if(r){t.unshift(`[data-testid="${r}"]`);break}if(o.id){t.unshift(`#${o.id}`);break}let a=o.tagName.toLowerCase(),s=Pr(o);if(s.length>0){a+=`.${CSS.escape(s[0])}`;let i=o.parentElement;if(i)try{if(Array.from(i.children).filter(l=>l.matches(a)).length===1){t.unshift(a),o=o.parentElement;continue}}catch{}}if(!o)break;let c=o;a=c.tagName.toLowerCase();let m=c.parentElement;if(m){let i=Array.from(m.children);if(i.filter(l=>l.tagName===c.tagName).length>1){let l=i.indexOf(c)+1;a=`${c.tagName.toLowerCase()}:nth-child(${l})`}}t.unshift(a),o=o.parentElement}return t.join(" > ")}function Pr(e){return Array.from(e.classList).filter(o=>!vt(o))}function vt(e){return!!(e.length<=2||e.startsWith("_")||/^[a-zA-Z]+_[a-zA-Z0-9]{5,}$/.test(e)||/^css-[a-z0-9]+$/i.test(e)||/^sc-[a-zA-Z0-9]+$/.test(e)||/^[a-z]{1,3}[A-Z][a-zA-Z0-9]{4,}$/.test(e)||e.includes(":")||e.includes("[")||e.includes("]")||e.includes("."))}function xe(e){let t=e.tagName.toLowerCase();return!(["html","head","script","style","link","meta","noscript","br"].includes(t)||e.closest("[data-fl-root]")||e.hasAttribute("data-fl-ignore"))}var _r=["id","class","role","type","name","href","src","data-testid","data-feedback-id"];function Ye(e){let t=e.tagName.toLowerCase(),o=(e.textContent?.trim()??"").slice(0,80),n={};for(let i of _r){let d=e.getAttribute(i);d!==null&&d!==""&&(n[i]=d)}let r=e.parentElement,a=0,s=1;if(r){let i=Array.from(r.children).filter(d=>d.tagName===e.tagName);s=i.length,a=i.indexOf(e)}let c=r?.tagName.toLowerCase()??"",m=r?.parentElement?.tagName.toLowerCase()??"";return{tag:t,textContent:o,attributes:n,siblingIndex:a,siblingCount:s,parentTag:c,grandparentTag:m}}function bt(e,t){if(t.tagName.toLowerCase()!==e.tag)return 0;let o=20,n=(t.textContent?.trim()??"").slice(0,80);n===e.textContent&&n.length>0?o+=25:e.textContent.length>0&&n.length>0&&(n.includes(e.textContent)||e.textContent.includes(n))&&(o+=15);let r=e.attributes;r["data-feedback-id"]&&t.getAttribute("data-feedback-id")===r["data-feedback-id"]&&(o+=30),r["data-testid"]&&t.getAttribute("data-testid")===r["data-testid"]&&(o+=25),r.id&&t.id===r.id&&(o+=20),r.role&&t.getAttribute("role")===r.role&&(o+=5),r.type&&t.getAttribute("type")===r.type&&(o+=5),r.href&&t.getAttribute("href")===r.href&&(o+=10),r.name&&t.getAttribute("name")===r.name&&(o+=5);let a=t.parentElement;a&&a.tagName.toLowerCase()===e.parentTag&&(o+=10);let s=a?.parentElement;return s&&s.tagName.toLowerCase()===e.grandparentTag&&(o+=5),Math.min(o,100)}function je(e,t=40){let o=document.querySelectorAll(e.tag),n=null,r=0;for(let a of o){if(a.closest("[data-fl-root]")||a.hasAttribute("data-fl-ignore"))continue;let s=bt(e,a);s>r&&(r=s,n=a)}return r>=t?{element:n,score:r}:{element:null,score:r}}var Mr=["font-family","font-size","font-weight","color","background-color","padding","margin","width","height","border-radius","display","position","line-height","letter-spacing","text-align","opacity"];function Qt(e){let t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?{r:Number(t[1]),g:Number(t[2]),b:Number(t[3])}:null}function Ct(e){if(e==="transparent"||e==="rgba(0, 0, 0, 0)")return!0;let t=e.match(/rgba\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*([\d.]+)\s*\)/);return t?Number(t[1])===0:!1}function to(e){let t=window.getComputedStyle(e),o=t.getPropertyValue("background-color");if(o&&!Ct(o))return!0;let n=t.getPropertyValue("background-image");if(n&&n!=="none")return!0;let r=t.getPropertyValue("box-shadow");if(r&&r!=="none")return!0;for(let a of["top","right","bottom","left"]){let s=t.getPropertyValue(`border-${a}-width`),c=t.getPropertyValue(`border-${a}-style`);if(s!=="0px"&&c!=="none")return!0}return!1}function Et(e){let t=e;for(;t&&t!==document.documentElement;){let o=window.getComputedStyle(t).backgroundColor;if(o&&!Ct(o))return o;t=t.parentElement}if(document.documentElement){let o=window.getComputedStyle(document.documentElement).backgroundColor;if(o&&!Ct(o))return o}return"rgb(255, 255, 255)"}function St(e){let t=e/255;return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function eo(e){return .2126*St(e.r)+.7152*St(e.g)+.0722*St(e.b)}function xt(e,t){let o=Qt(e),n=Qt(t);if(!o||!n)return{ratio:0,passesAA:!1};let r=eo(o),a=eo(n),s=Math.max(r,a),c=Math.min(r,a),m=Math.round((s+.05)/(c+.05)*100)/100;return{ratio:m,passesAA:m>=4.5}}function Rt(e){if(/iPhone/i.test(e))return"iPhone";if(/iPad/i.test(e))return"iPad";if(/Android/i.test(e))return/Mobile/i.test(e)?"Android Phone":"Android Tablet";let t="Browser";/Edg\//i.test(e)?t="Edge":/Chrome\//i.test(e)?t="Chrome":/Firefox\//i.test(e)?t="Firefox":/Safari\//i.test(e)&&!/Chrome/i.test(e)&&(t="Safari");let o="";return/Macintosh|Mac OS/i.test(e)?o="macOS":/Windows/i.test(e)?o="Windows":/Linux/i.test(e)?o="Linux":/CrOS/i.test(e)&&(o="ChromeOS"),o?`${t} on ${o}`:t}function Oe(e){let t=window.getComputedStyle(e),o={};for(let u of Mr)o[u]=t.getPropertyValue(u);let n=e.getAttribute("role"),r=e.getAttribute("aria-label"),a=o.color,s=Et(e);s!==o["background-color"]&&(o["effective-background-color"]=s);let{ratio:c,passesAA:m}=xt(a,s),i={width:window.innerWidth,height:window.innerHeight},d=Rt(navigator.userAgent),l;try{l=Ye(e)}catch{}return{computed_styles:o,accessibility:{role:n,aria_label:r,contrast_ratio:c,contrast_passes_aa:m},viewport:i,device:d,fingerprint:l}}function oo(e){let t=e.tagName.toLowerCase();return["button","a","input","select","textarea"].includes(t)||e.getAttribute("role")==="button"||e.getAttribute("role")==="link"||e.hasAttribute("data-feedback-id")||e.hasAttribute("data-testid")?3:["h1","h2","h3","h4","h5","h6","p","img","figure","figcaption","picture","video","section","article","nav","header","footer","main","aside","form","table","ul","ol","li","blockquote","details"].includes(t)?2:1}var Ir='button,a,input,select,textarea,h1,h2,h3,h4,h5,h6,p,img,figure,nav,section,article,header,footer,main,[role="button"],[role="link"],[data-feedback-id],[data-testid]';function wt(e,t){let o=oo(t);if(o>=2||to(t))return null;let n=null,r=o,a=t.parentElement,s=0;for(;a&&a!==document.body&&s<dt.ANCESTOR_DEPTH&&a.getAttribute("data-fl-magnet")!=="off";){let l=oo(a);l>r&&(n=a,r=l),a=a.parentElement,s++}if(n)return n;let c={x:e.clientX,y:e.clientY},m=t.parentElement;if(!m)return null;let i=m.querySelectorAll(Ir),d=null;for(let l of i){if(l===t||l.getAttribute("data-fl-magnet")==="off"||!xe(l))continue;let u=l.getBoundingClientRect(),f=Lr(c,u);f<=dt.PROXIMITY_THRESHOLD&&(!d||f<d.dist)&&(d={el:l,dist:f})}return d?.el??null}function Lr(e,t){let o=Math.max(t.left-e.x,0,e.x-t.right),n=Math.max(t.top-e.y,0,e.y-t.bottom);return Math.sqrt(o*o+n*n)}function Ze(){let{isCommentMode:e}=E(),[t,o]=(0,he.useState)({hoveredElement:null,selectedElement:null}),n=(0,he.useRef)(t);n.current=t;let r=(0,he.useCallback)(()=>{o(a=>({...a,selectedElement:null}))},[]);return(0,he.useEffect)(()=>{if(!e){o({hoveredElement:null,selectedElement:null});return}function a(i){let d=i.target;if(!d||!xe(d)){o(u=>u.hoveredElement!==null?{...u,hoveredElement:null}:u);return}let l=wt(i,d)??d;o(u=>u.hoveredElement!==l?{...u,hoveredElement:l}:u)}function s(i){let d=i.relatedTarget;(!d||d===document.documentElement)&&o(l=>l.hoveredElement!==null?{...l,hoveredElement:null}:l)}function c(i){let d=i.target;if(!d||!xe(d))return;i.preventDefault(),i.stopPropagation();let l=wt(i,d)??d;o(u=>({...u,selectedElement:l,hoveredElement:null}))}document.body.addEventListener("mouseover",a,!0),document.body.addEventListener("mouseout",s,!0),document.body.addEventListener("click",c,!0);let m=document.body.style.cursor;return document.body.style.cursor="crosshair",()=>{document.body.removeEventListener("mouseover",a,!0),document.body.removeEventListener("mouseout",s,!0),document.body.removeEventListener("click",c,!0),document.body.style.cursor=m}},[e]),{hoveredElement:t.hoveredElement,selectedElement:t.selectedElement,clearSelection:r}}var de=require("react"),ro=require("react-dom");var no=require("react/jsx-runtime"),kr={position:"fixed",pointerEvents:"none",border:"2px solid var(--fl-accent)",borderRadius:"var(--fl-border-radius-sm)",transition:"all var(--fl-duration-instant) ease-out",zIndex:L.HIGHLIGHT,boxSizing:"border-box"};function qe({hoveredElement:e,selectedElement:t}){let{isCommentMode:o,portalRoot:n}=E(),[r,a]=(0,de.useState)(null),s=(0,de.useRef)(0),c=(0,de.useCallback)(()=>{let m=t?null:e;if(!m){a(null);return}let i=m.getBoundingClientRect();a({top:i.top,left:i.left,width:i.width,height:i.height})},[e,t]);return(0,de.useEffect)(()=>{c()},[c]),(0,de.useEffect)(()=>{if(!o||!e&&!t)return;function m(){cancelAnimationFrame(s.current),s.current=requestAnimationFrame(()=>{c()})}return window.addEventListener("scroll",m,!0),window.addEventListener("resize",m),()=>{window.removeEventListener("scroll",m,!0),window.removeEventListener("resize",m),cancelAnimationFrame(s.current)}},[o,e,t,c]),!o||!n||!r?null:(0,ro.createPortal)((0,no.jsx)("div",{style:{...kr,top:r.top,left:r.left,width:r.width,height:r.height},"data-fl-ignore":""}),n)}var se=require("react"),ao=require("react-dom");var io=require("react/jsx-runtime"),Dr={position:"fixed",pointerEvents:"none",padding:"2px 8px",backgroundColor:"var(--fl-surface)",border:"1px solid var(--fl-border)",borderRadius:4,fontSize:11,fontFamily:"var(--fl-font-family)",color:"var(--fl-text-secondary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:320,zIndex:L.HIGHLIGHT,boxShadow:"0 1px 3px rgba(26,26,24,0.06)",transition:"all var(--fl-duration-instant) ease-out"};function so({hoveredElement:e,selectedElement:t}){let{isCommentMode:o,portalRoot:n}=E(),[r,a]=(0,se.useState)(null),[s,c]=(0,se.useState)(""),m=(0,se.useRef)(0),i=t?null:e,d=(0,se.useCallback)(()=>{if(!i){a(null);return}let l=i.getBoundingClientRect(),u=Xt(i);c(u.join(" \u203A "));let f=Math.max(4,l.top-28),v=Math.max(4,Math.min(l.left,window.innerWidth-328));a({top:f,left:v})},[i]);return(0,se.useEffect)(()=>{d()},[d]),(0,se.useEffect)(()=>{if(!o||!i)return;function l(){cancelAnimationFrame(m.current),m.current=requestAnimationFrame(()=>{d()})}return window.addEventListener("scroll",l,!0),window.addEventListener("resize",l),()=>{window.removeEventListener("scroll",l,!0),window.removeEventListener("resize",l),cancelAnimationFrame(m.current)}},[o,i,d]),!o||!n||!r?null:(0,ao.createPortal)((0,io.jsx)("div",{style:{...Dr,top:r.top,left:r.left},"data-fl-ignore":"",children:s}),n)}var C=require("react"),fo=require("react-dom");var lo="fl-author";function ye(){try{let e=localStorage.getItem(lo);if(!e)return null;let t=JSON.parse(e);return t&&typeof t.name=="string"&&t.name.trim()?{name:t.name.trim()}:null}catch{return null}}function Je(e){try{let t=e.trim();if(!t)return;localStorage.setItem(lo,JSON.stringify({name:t}))}catch{}}function me(e,t){if(e.user)return e.user;let o=t.trim();return o?{id:null,name:o,avatar:null}:{...Ht}}function Pe(e){let t=e.trim();t&&Je(t)}var Nr=.65;async function co(e){let t=e.getBoundingClientRect(),o={x:Math.round(t.x),y:Math.round(t.y),width:Math.round(t.width),height:Math.round(t.height)},n;try{n=(await import("html-to-image")).toCanvas}catch{return console.info("Lay: Screenshot capture unavailable. This may be caused by a CSP restriction or bundler issue."),null}let r;try{let a=await n(document.body,{filter:c=>!c.hasAttribute?.(ne.IGNORE),pixelRatio:1});r=document.createElement("canvas"),r.width=window.innerWidth,r.height=window.innerHeight;let s=r.getContext("2d");if(!s)return null;s.drawImage(a,window.scrollX,window.scrollY,window.innerWidth,window.innerHeight,0,0,window.innerWidth,window.innerHeight)}catch{return null}return new Promise(a=>{r.toBlob(s=>{if(!s){a(null);return}a({blob:s,bounds:o})},"image/webp",Nr)})}var Q=require("react/jsx-runtime"),po={position:"fixed",zIndex:L.POPOVER,width:Ae.WIDTH,backgroundColor:"var(--fl-surface-raised)",border:"1px solid var(--fl-border)",borderRadius:"var(--fl-border-radius)",boxShadow:"var(--fl-shadow-popover)",fontFamily:"var(--fl-font-family)",fontSize:"var(--fl-font-size-base)",color:"var(--fl-text-primary)",overflow:"hidden",opacity:0,transform:"translateY(4px)",transition:`opacity var(--fl-duration-fast) ease-out, transform var(--fl-duration-fast) ease-out, max-height ${Ae.EXPAND_DURATION}ms ease-out`},Or={...po,opacity:1,transform:"translateY(0)"},Hr={display:"flex",flexDirection:"column",gap:8,padding:12},Fr={width:"100%",padding:"6px 8px",border:"1px solid var(--fl-border)",borderRadius:"var(--fl-border-radius-sm)",backgroundColor:"var(--fl-surface)",color:"var(--fl-text-primary)",fontFamily:"var(--fl-font-family)",fontSize:"var(--fl-font-size-sm)",lineHeight:"var(--fl-line-height)",outline:"none",boxSizing:"border-box",transition:"border-color var(--fl-duration-fast) ease-out"},mo={width:"100%",minHeight:64,padding:8,borderWidth:1,borderStyle:"solid",borderColor:"var(--fl-border)",borderRadius:"var(--fl-border-radius-sm)",backgroundColor:"var(--fl-surface)",color:"var(--fl-text-primary)",fontFamily:"var(--fl-font-family)",fontSize:"var(--fl-font-size-base)",lineHeight:"var(--fl-line-height)",resize:"vertical",outline:"none",boxSizing:"border-box",transition:"border-color var(--fl-duration-fast) ease-out"},zr={display:"flex",alignItems:"center",justifyContent:"flex-end",gap:8},ho={padding:"4px 12px",backgroundColor:"var(--fl-accent)",color:"#FFFFFF",border:"none",borderRadius:"var(--fl-border-radius-sm)",fontFamily:"var(--fl-font-family)",fontSize:"var(--fl-font-size-sm)",fontWeight:"var(--fl-font-weight-medium)",cursor:"pointer",outline:"none",transition:"background-color var(--fl-duration-fast) ease-out"},Gr={...ho,opacity:.4,cursor:"default"},Br={fontSize:"var(--fl-font-size-sm)",color:"var(--fl-text-tertiary)",fontFamily:"var(--fl-font-family)"},Wr={display:"flex",alignItems:"center",gap:6,padding:"6px 8px"},yo={padding:"4px 10px",borderWidth:1,borderStyle:"solid",borderColor:"var(--fl-border)",borderRadius:12,backgroundColor:"var(--fl-surface)",color:"var(--fl-text-secondary)",fontSize:"var(--fl-font-size-sm)",fontFamily:"var(--fl-font-family)",fontWeight:"var(--fl-font-weight-medium)",cursor:"pointer",outline:"none",whiteSpace:"nowrap",transition:"background-color var(--fl-duration-fast) ease-out, border-color var(--fl-duration-fast) ease-out, color var(--fl-duration-fast) ease-out",lineHeight:1,flexShrink:0},$r={...yo,backgroundColor:"var(--fl-accent-subtle)",borderColor:"var(--fl-accent)",color:"var(--fl-accent)"},Ur={flex:1,padding:"4px 8px",color:"var(--fl-text-tertiary)",fontSize:"var(--fl-font-size-sm)",fontFamily:"var(--fl-font-family)",cursor:"text",minWidth:0},Re=8,uo=120;function Kr(e){let t=window.innerWidth,o=window.innerHeight,n=e.bottom+Re,r=e.left;return n+uo>o&&(n=e.top-uo-Re),r+Ae.WIDTH>t&&(r=t-Ae.WIDTH-Re),r<Re&&(r=Re),n<Re&&(n=Re),{top:n,left:r}}function Qe({selectedElement:e,onClearSelection:t}){let{portalRoot:o,adapter:n,config:r,dispatch:a,onCommentAddedRef:s}=E(),[c,m]=(0,C.useState)(""),[i,d]=(0,C.useState)(""),[l,u]=(0,C.useState)(null),[f,v]=(0,C.useState)(!1),[A,S]=(0,C.useState)(!1),[y,N]=(0,C.useState)(null),B=(0,C.useRef)(null),h=(0,C.useRef)(null),x=(0,C.useRef)(null),_=(0,C.useRef)(0),b=!!r.user,W=r.starterChips??Dt,$=(0,C.useCallback)(()=>{if(!e){u(null);return}let p=e.getBoundingClientRect();u(Kr(p))},[e]);(0,C.useEffect)(()=>{if(e){if(d(""),S(!1),N(null),$(),!b){let p=ye();m(p?.name??"")}requestAnimationFrame(()=>{v(!0)})}else v(!1),u(null)},[e,$,b]),(0,C.useEffect)(()=>{if(!e)return;function p(){cancelAnimationFrame(_.current),_.current=requestAnimationFrame(()=>{$()})}return window.addEventListener("scroll",p,!0),window.addEventListener("resize",p),()=>{window.removeEventListener("scroll",p,!0),window.removeEventListener("resize",p),cancelAnimationFrame(_.current)}},[e,$]);let j=(0,C.useRef)(A);j.current=A,(0,C.useEffect)(()=>{if(!e)return;function p(P){P.key==="Escape"&&(P.preventDefault(),P.stopPropagation(),j.current?(S(!1),d("")):t())}return document.addEventListener("keydown",p,!0),()=>document.removeEventListener("keydown",p,!0)},[e,t]),(0,C.useEffect)(()=>{if(!e||A)return;function p(P){P.key.length===1&&!P.ctrlKey&&!P.metaKey&&(P.preventDefault(),S(!0),d(P.key),setTimeout(()=>{h.current?.focus(),h.current&&(h.current.selectionStart=h.current.value.length)},10))}return document.addEventListener("keydown",p,!0),()=>document.removeEventListener("keydown",p,!0)},[e,A]),(0,C.useEffect)(()=>{if(!e)return;function p(Z){let re=Z.target;x.current?.contains(re)||re.closest("[data-fl-root]")||t()}let P=setTimeout(()=>{document.addEventListener("mousedown",p,!0)},50);return()=>{clearTimeout(P),document.removeEventListener("mousedown",p,!0)}},[e,t]);let[ie,ee]=(0,C.useState)(!1),M=r.screenshots!==!1,O=(0,C.useCallback)((p,P)=>{M&&co(p).then(Z=>{Z&&n.uploadScreenshot(r.projectId,P,Z.blob,Z.bounds).catch(()=>{})})},[M,n,r.projectId]),Se=(0,C.useCallback)(async p=>{if(!e)return;let P=e,Z=Ee(P),re=window.location.pathname,Te=ye(),Ie=me(r,Te?.name??""),g=null;try{g=Oe(P)}catch{}let z={project_id:r.projectId,thread_id:null,author:Ie,content:p.value??p.label,status:"open",dom_path:Z,url_path:re,element_metadata:g,resolved_by:null,resolved_at:null,archived_at:null,ai_context:null,screenshot_url:null,element_bounds:null},pe;try{pe=await n.addComment(z),O(P,pe.id),a({type:"SET_COMMENT_MODE",payload:!1}),t()}catch{d(p.value??p.label),S(!0),setTimeout(()=>h.current?.focus(),10)}if(pe)try{s.current?.(pe)}catch{}},[e,r,n,t,O,a,s]),V=(0,C.useCallback)(async()=>{if(!i.trim()||!e)return;let p=e,P=Ee(p),Z=window.location.pathname,re=me(r,c);b||Pe(c);let Te=null;try{Te=Oe(p)}catch{console.warn("Lay: Could not capture element metadata.")}let Ie={project_id:r.projectId,thread_id:null,author:re,content:i.trim(),status:"open",dom_path:P,url_path:Z,element_metadata:Te,resolved_by:null,resolved_at:null,archived_at:null,ai_context:null,screenshot_url:null,element_bounds:null},g;try{g=await n.addComment(Ie),d(""),O(p,g.id),a({type:"SET_COMMENT_MODE",payload:!1}),t()}catch{ee(!0),setTimeout(()=>ee(!1),1200)}if(g)try{s.current?.(g)}catch{}},[i,c,e,r,n,t,b,O,a,s]),R=(0,C.useCallback)(()=>{S(!0),setTimeout(()=>h.current?.focus(),10)},[]),fe=(0,C.useCallback)(p=>{p.key==="Enter"&&!p.shiftKey&&(p.preventDefault(),V())},[V]),Me=(0,C.useCallback)(p=>{p.key==="Enter"&&(p.preventDefault(),h.current?.focus())},[]);if((0,C.useEffect)(()=>{A&&e&&!i&&setTimeout(()=>{if(!b&&!ye()?.name){B.current?.focus();return}h.current?.focus()},10)},[A,e,b,i]),!o||!e||!l)return null;let oe=i.trim();return(0,fo.createPortal)((0,Q.jsx)("div",{ref:x,style:{...f?Or:po,top:l.top,left:l.left,maxHeight:A?400:Ae.COLLAPSED_HEIGHT},"data-fl-ignore":"",children:A?(0,Q.jsxs)("div",{style:Hr,children:[b?null:(0,Q.jsx)("input",{ref:B,type:"text",value:c,onChange:p=>m(p.target.value),onKeyDown:Me,placeholder:"Your name (optional)",style:Fr}),(0,Q.jsx)("textarea",{ref:h,value:i,onChange:p=>d(p.target.value),onKeyDown:fe,placeholder:"Leave feedback...",style:ie?{...mo,borderColor:"#D32F2F"}:mo,rows:3}),(0,Q.jsxs)("div",{style:zr,children:[(0,Q.jsx)("span",{style:Br,children:"Esc \u21A9 collapse"}),(0,Q.jsx)("button",{type:"button",onClick:V,disabled:!oe,style:oe?ho:Gr,children:"Submit"})]})]}):(0,Q.jsxs)("div",{style:Wr,children:[W.map((p,P)=>(0,Q.jsx)("button",{type:"button",onClick:()=>Se(p),onMouseEnter:()=>N(P),onMouseLeave:()=>N(null),style:y===P?$r:yo,children:p.label},p.label)),(0,Q.jsx)("span",{style:Ur,onClick:R,role:"button",tabIndex:0,children:"Type..."})]})}),o)}var ge=require("react/jsx-runtime");function et(){let{hoveredElement:e,selectedElement:t,clearSelection:o}=Ze();return(0,ge.jsxs)(ge.Fragment,{children:[(0,ge.jsx)(qe,{hoveredElement:e,selectedElement:t}),(0,ge.jsx)(so,{hoveredElement:e,selectedElement:t}),(0,ge.jsx)(Qe,{selectedElement:t,onClearSelection:o})]})}var ue=require("react");var w=require("react"),Ao=require("react-dom");var I=It(require("react")),Ro=require("react-dom");var te=require("react/jsx-runtime"),go={padding:"10px 0",fontFamily:"var(--fl-font-family)"},Xr={...go,marginLeft:16,paddingLeft:12,borderLeft:"2px solid var(--fl-border)"},Vr={display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:4},Yr={display:"flex",alignItems:"center",gap:6,minWidth:0},jr={fontSize:"var(--fl-font-size-sm)",fontWeight:"var(--fl-font-weight-medium)",color:"var(--fl-text-secondary)",fontFamily:"var(--fl-font-family)"},Zr={fontSize:"var(--fl-font-size-sm)",color:"var(--fl-text-tertiary)",fontFamily:"var(--fl-font-family)"},qr={fontSize:"var(--fl-font-size-base)",lineHeight:"var(--fl-line-height)",color:"var(--fl-text-primary)",fontFamily:"var(--fl-font-family)",whiteSpace:"pre-wrap",wordBreak:"break-word"},Jr={display:"flex",alignItems:"center",gap:4,marginTop:6,fontSize:"var(--fl-font-size-sm)",color:"var(--fl-text-tertiary)",fontFamily:"var(--fl-font-family)"},Qr={color:"var(--fl-accent)",fontSize:12};function He({comment:e,isReply:t=!1,actions:o}){return(0,te.jsxs)("div",{style:t?Xr:go,children:[(0,te.jsxs)("div",{style:Vr,children:[(0,te.jsxs)("div",{style:Yr,children:[(0,te.jsx)("span",{style:jr,children:e.author.name}),(0,te.jsx)("span",{style:Zr,children:ce(e.created_at)})]}),o]}),(0,te.jsx)("div",{style:qr,children:e.content}),e.status==="resolved"&&e.resolved_by&&!t&&(0,te.jsxs)("div",{style:Jr,children:[(0,te.jsx)("span",{style:Qr,children:"\u2713"}),(0,te.jsxs)("span",{children:["Resolved by ",e.resolved_by.name,e.resolved_at?` \xB7 ${ce(e.resolved_at)}`:""]})]})]})}var tt=require("react"),we=require("react/jsx-runtime"),vo={display:"flex",alignItems:"center",gap:4},Tt={display:"flex",alignItems:"center",justifyContent:"center",width:24,height:24,padding:0,border:"none",borderRadius:"var(--fl-border-radius-sm)",backgroundColor:"transparent",color:"var(--fl-text-tertiary)",cursor:"pointer",fontFamily:"var(--fl-font-family)",fontSize:14,lineHeight:1,transition:"color var(--fl-duration-fast) ease-out, background-color var(--fl-duration-fast) ease-out"},bo={...Tt,color:"var(--fl-accent)",backgroundColor:"var(--fl-accent-subtle)"},So={display:"inline-flex",alignItems:"center",padding:"2px 6px",border:"none",borderRadius:"var(--fl-border-radius-sm)",backgroundColor:"transparent",color:"var(--fl-text-tertiary)",cursor:"pointer",fontFamily:"var(--fl-font-family)",fontSize:"var(--fl-font-size-sm)",fontWeight:"var(--fl-font-weight-medium)",lineHeight:1,transition:"color var(--fl-duration-fast) ease-out"},en={...So,color:"var(--fl-text-secondary)"};function ot({comment:e,onResolve:t,onReopen:o,onArchive:n}){let[r,a]=(0,tt.useState)(!1),[s,c]=(0,tt.useState)(!1),[m,i]=(0,tt.useState)(!1);return e.status==="open"?(0,we.jsx)("div",{style:vo,children:(0,we.jsx)("button",{type:"button",title:"Resolve",style:r?bo:Tt,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),onClick:d=>{d.stopPropagation(),t(e)},children:"\u2713"})}):e.status==="resolved"?(0,we.jsxs)("div",{style:vo,children:[(0,we.jsx)("button",{type:"button",title:"Reopen",style:s?bo:Tt,onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),onClick:d=>{d.stopPropagation(),o(e)},children:"\u21A9"}),(0,we.jsx)("button",{type:"button",title:"Archive",style:m?en:So,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),onClick:d=>{d.stopPropagation(),n(e)},children:"Archive"})]}):null}var Y=require("react");var ve=require("react/jsx-runtime"),tn={display:"flex",flexDirection:"column",gap:6,padding:12},on={width:"100%",padding:"4px 8px",border:"1px solid var(--fl-border)",borderRadius:"var(--fl-border-radius-sm)",backgroundColor:"var(--fl-surface)",color:"var(--fl-text-primary)",fontFamily:"var(--fl-font-family)",fontSize:"var(--fl-font-size-sm)",lineHeight:"var(--fl-line-height)",outline:"none",boxSizing:"border-box",transition:"border-color var(--fl-duration-fast) ease-out"},Co={width:"100%",minHeight:48,padding:"6px 8px",borderWidth:1,borderStyle:"solid",borderColor:"var(--fl-border)",borderRadius:"var(--fl-border-radius-sm)",backgroundColor:"var(--fl-surface)",color:"var(--fl-text-primary)",fontFamily:"var(--fl-font-family)",fontSize:"var(--fl-font-size-base)",lineHeight:"var(--fl-line-height)",resize:"vertical",outline:"none",boxSizing:"border-box",transition:"border-color var(--fl-duration-fast) ease-out"},rn={display:"flex",alignItems:"center",justifyContent:"flex-end",gap:8},Eo={padding:"4px 12px",backgroundColor:"var(--fl-accent)",color:"#FFFFFF",border:"none",borderRadius:"var(--fl-border-radius-sm)",fontFamily:"var(--fl-font-family)",fontSize:"var(--fl-font-size-sm)",fontWeight:"var(--fl-font-weight-medium)",cursor:"pointer",outline:"none",transition:"background-color var(--fl-duration-fast) ease-out"},nn={...Eo,opacity:.4,cursor:"default"},an={fontSize:"var(--fl-font-size-sm)",color:"var(--fl-text-tertiary)",fontFamily:"var(--fl-font-family)"};function rt({rootComment:e,onReplySubmitted:t}){let{adapter:o,config:n}=E(),[r,a]=(0,Y.useState)(""),[s,c]=(0,Y.useState)(""),[m,i]=(0,Y.useState)(!1),d=(0,Y.useRef)(null),l=(0,Y.useRef)(null),u=!!n.user;(0,Y.useEffect)(()=>{if(!u){let y=ye();a(y?.name??"")}},[u]);let f=(0,Y.useCallback)(async()=>{if(!s.trim())return;let y=me(n,r);u||Pe(r);let N={project_id:n.projectId,thread_id:e.id,author:y,content:s.trim(),status:"open",dom_path:e.dom_path,url_path:e.url_path,element_metadata:null,resolved_by:null,resolved_at:null,archived_at:null,ai_context:null,screenshot_url:null,element_bounds:null};try{await o.addComment(N),c(""),t?.(),setTimeout(()=>{l.current?.focus()},10)}catch{i(!0),setTimeout(()=>i(!1),1200)}},[s,r,n,o,e,u,t]),v=(0,Y.useCallback)(y=>{y.key==="Enter"&&!y.shiftKey&&(y.preventDefault(),f())},[f]),A=(0,Y.useCallback)(y=>{y.key==="Enter"&&(y.preventDefault(),l.current?.focus())},[]),S=s.trim();return(0,ve.jsxs)("div",{style:tn,children:[u?null:(0,ve.jsx)("input",{ref:d,type:"text",value:r,onChange:y=>a(y.target.value),onKeyDown:A,placeholder:"Your name (optional)",style:on}),(0,ve.jsx)("textarea",{ref:l,value:s,onChange:y=>c(y.target.value),onKeyDown:v,placeholder:"Reply...",style:m?{...Co,borderColor:"#D32F2F"}:Co,rows:2}),(0,ve.jsxs)("div",{style:rn,children:[(0,ve.jsx)("span",{style:an,children:"Esc"}),(0,ve.jsx)("button",{type:"button",onClick:f,disabled:!S,style:S?Eo:nn,children:"Reply"})]})]})}var X=require("react/jsx-runtime"),wo={position:"fixed",zIndex:L.POPOVER,width:320,maxHeight:400,backgroundColor:"var(--fl-surface-raised)",border:"1px solid var(--fl-border)",borderRadius:"var(--fl-border-radius)",boxShadow:"var(--fl-shadow-popover)",fontFamily:"var(--fl-font-family)",fontSize:"var(--fl-font-size-base)",color:"var(--fl-text-primary)",display:"flex",flexDirection:"column",overflow:"hidden",opacity:0,transform:"translateY(4px)",transition:"opacity var(--fl-duration-fast) ease-out, transform var(--fl-duration-fast) ease-out"},sn={...wo,opacity:1,transform:"translateY(0)"},ln={overflowY:"auto",padding:12,flexGrow:1,minHeight:0},To={height:1,backgroundColor:"var(--fl-border)",margin:"0",border:"none",flexShrink:0},cn={...To,backgroundColor:"var(--fl-border-strong)"},be=8,At=320,xo=200;function dn(e){let t=window.innerWidth,o=window.innerHeight,n=e.bottom+be,r=e.right-At;return n+xo>o&&(n=e.top-xo-be),r<be&&(r=be),r+At>t-be&&(r=t-At-be),n<be&&(n=be),{top:n,left:r}}function mn(e){let t=[],o=new Map;for(let n of e)if(n.thread_id===null)t.push(n);else{let r=o.get(n.thread_id);r?r.push(n):o.set(n.thread_id,[n])}return t.sort((n,r)=>new Date(n.created_at).getTime()-new Date(r.created_at).getTime()),t.map(n=>{let r=o.get(n.id)??[];return r.sort((a,s)=>new Date(a.created_at).getTime()-new Date(s.created_at).getTime()),{root:n,replies:r}})}function nt({comments:e,dotRect:t,onClose:o,onDidResolve:n}){let{portalRoot:r,adapter:a,config:s,dispatch:c}=E(),m=(0,I.useRef)(null),i=(0,I.useRef)(null),[d,l]=I.default.useState(!1),u=dn(t),f=(0,I.useMemo)(()=>mn(e),[e]),v=f.length>0?f[0].root:null,A=(0,I.useCallback)(h=>{let x=me(s,""),_=new Date().toISOString(),b={...h,status:"resolved",resolved_by:x,resolved_at:_};c({type:"UPDATE_COMMENT",payload:b}),n?.(),o(),a.updateComment(h.id,{status:"resolved",resolved_by:x,resolved_at:_}).catch(()=>{c({type:"UPDATE_COMMENT",payload:h})})},[a,s,c,n,o]),S=(0,I.useCallback)(h=>{let x={...h,status:"open",resolved_by:null,resolved_at:null};c({type:"UPDATE_COMMENT",payload:x}),a.updateComment(h.id,{status:"open",resolved_by:null,resolved_at:null}).catch(()=>{c({type:"UPDATE_COMMENT",payload:h})})},[a,c]),y=(0,I.useCallback)(h=>{let x=new Date().toISOString(),_={...h,status:"archived",archived_at:x};c({type:"UPDATE_COMMENT",payload:_}),a.updateComment(h.id,{status:"archived",archived_at:x}).catch(()=>{c({type:"UPDATE_COMMENT",payload:h})})},[a,c]);(0,I.useEffect)(()=>{requestAnimationFrame(()=>{l(!0)})},[]),(0,I.useEffect)(()=>{d&&i.current&&(i.current.scrollTop=i.current.scrollHeight)},[d]);let N=(0,I.useRef)(e.length);(0,I.useEffect)(()=>{e.length>N.current&&i.current&&(i.current.scrollTop=i.current.scrollHeight),N.current=e.length},[e.length]);let B=(0,I.useCallback)(()=>{},[]);return(0,I.useEffect)(()=>{function h(x){x.key==="Escape"&&(x.preventDefault(),o())}return document.addEventListener("keydown",h,!0),()=>document.removeEventListener("keydown",h,!0)},[o]),(0,I.useEffect)(()=>{function h(_){let b=_.target;m.current?.contains(b)||b.closest("[data-fl-ignore]")||o()}let x=setTimeout(()=>{document.addEventListener("mousedown",h,!0)},50);return()=>{clearTimeout(x),document.removeEventListener("mousedown",h,!0)}},[o]),r?(0,Ro.createPortal)((0,X.jsxs)("div",{ref:m,style:{...d?sn:wo,top:u.top,left:u.left},"data-fl-ignore":"",children:[(0,X.jsx)("div",{ref:i,style:ln,children:f.map((h,x)=>(0,X.jsxs)(I.default.Fragment,{children:[x>0?(0,X.jsx)("hr",{style:To}):null,(0,X.jsx)(He,{comment:h.root,actions:(0,X.jsx)(ot,{comment:h.root,onResolve:A,onReopen:S,onArchive:y})}),h.replies.map(_=>(0,X.jsx)(He,{comment:_,isReply:!0},_.id))]},h.root.id))}),v?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)("hr",{style:cn}),(0,X.jsx)(rt,{rootComment:v,onReplySubmitted:B})]}):null]}),r):null}var G=require("react/jsx-runtime");function un(e){let t=[],n=q.SPREAD_ANGLE/2;for(let r=0;r<e;r++){let s=90-n+q.SPREAD_ANGLE/(e-1)*r+(Math.random()-.5)*15,c=q.DISTANCE_MIN+Math.random()*(q.DISTANCE_MAX-q.DISTANCE_MIN),m=s*Math.PI/180,i=Math.cos(m)*c,d=-Math.sin(m)*c,l=q.PARTICLE_SIZE_MIN+Math.random()*(q.PARTICLE_SIZE_MAX-q.PARTICLE_SIZE_MIN),u=["var(--fl-accent)","var(--fl-accent-hover)","#F4A261"],f=u[r%u.length];t.push({endX:i,endY:d,size:l,color:f,delay:r*20})}return t}var Pt={position:"fixed",minWidth:H.MARKER_MIN_WIDTH,height:H.MARKER_HEIGHT,padding:"0 5px",borderRadius:4,border:"none",backgroundColor:"var(--fl-accent)",color:"#FFFFFF",fontSize:H.MARKER_FONT_SIZE,fontFamily:"var(--fl-font-family)",fontWeight:600,lineHeight:`${H.MARKER_HEIGHT}px`,textAlign:"center",cursor:"pointer",zIndex:L.DOT,outline:"none",display:"flex",alignItems:"center",justifyContent:"center",animation:"fl-marker-enter var(--fl-duration-marker-enter) ease-out",transition:"transform var(--fl-duration-fast) ease-out",boxSizing:"border-box"},fn={...Pt,transform:"scale(1.15)"},Po={...Pt,backgroundColor:"var(--fl-resolved)"},pn={...Po,transform:"scale(1.15)"},_o={position:"absolute",bottom:-H.MARKER_POINTER,left:"50%",transform:"translateX(-50%)",width:0,height:0,borderLeft:`${H.MARKER_POINTER}px solid transparent`,borderRight:`${H.MARKER_POINTER}px solid transparent`,borderTopWidth:H.MARKER_POINTER,borderTopStyle:"solid",borderTopColor:"var(--fl-accent)",pointerEvents:"none"},hn={..._o,borderTopColor:"var(--fl-resolved)"},Mo={position:"absolute",top:`calc(100% + ${H.MARKER_POINTER+6}px)`,left:"50%",transform:"translateX(-50%)",backgroundColor:"var(--fl-text-primary)",color:"var(--fl-surface)",padding:"6px 10px",borderRadius:"var(--fl-border-radius-sm)",fontFamily:"var(--fl-font-family)",fontSize:"var(--fl-font-size-sm)",lineHeight:1.4,whiteSpace:"nowrap",pointerEvents:"none",zIndex:L.POPOVER,boxShadow:"var(--fl-shadow)",maxWidth:260,opacity:0,transition:"opacity var(--fl-duration-fast) ease-out"},yn={...Mo,opacity:1},gn={display:"flex",gap:6,alignItems:"baseline"},vn={fontWeight:"var(--fl-font-weight-medium)",color:"var(--fl-surface)"},bn={color:"rgba(255, 255, 255, 0.55)"},Sn={color:"rgba(255, 255, 255, 0.8)",whiteSpace:"normal",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:1,WebkitBoxOrient:"vertical"};function Cn(e){return e.length<=We.MAX_CONTENT_LENGTH?e:e.slice(0,We.MAX_CONTENT_LENGTH).trimEnd()+"\u2026"}function En(e){let t=e.getBoundingClientRect(),o=window.innerWidth,n=window.innerHeight;if(t.bottom<0||t.top>n||t.right<0||t.left>o)return{top:0,left:0,visible:!1};let r=t.top-H.MARKER_HEIGHT-H.MARKER_POINTER,a=t.right-H.MARKER_MIN_WIDTH/2;return{top:r,left:a,visible:!0}}var at=(0,w.memo)(function({domPath:t,comments:o,isResolved:n=!1,isNew:r=!1,resolvedElement:a}){let{portalRoot:s}=E(),[c,m]=(0,w.useState)(null),[i,d]=(0,w.useState)(!1),[l,u]=(0,w.useState)(!1),[f,v]=(0,w.useState)(!1),[A,S]=(0,w.useState)(r),[y,N]=(0,w.useState)(!1),[B,h]=(0,w.useState)([]),x=(0,w.useRef)(null),_=(0,w.useRef)(0),b=(0,w.useRef)(null),W=(0,w.useCallback)(()=>{let R=a??document.querySelector(t);if(!R){m(null);return}m(En(R))},[t,a]);(0,w.useEffect)(()=>{W()},[W]),(0,w.useEffect)(()=>{function R(){cancelAnimationFrame(_.current),_.current=requestAnimationFrame(()=>{W()})}return window.addEventListener("scroll",R,!0),window.addEventListener("resize",R),()=>{window.removeEventListener("scroll",R,!0),window.removeEventListener("resize",R),cancelAnimationFrame(_.current)}},[W]),(0,w.useEffect)(()=>{if(!A)return;let R=setTimeout(()=>S(!1),q.DURATION);return()=>clearTimeout(R)},[A]);let $=(0,w.useCallback)(()=>{h(un(q.PARTICLE_COUNT)),N(!0);let R=setTimeout(()=>{N(!1),h([])},q.DURATION+100);return()=>clearTimeout(R)},[]),j=(0,w.useCallback)(()=>{d(!0),b.current=setTimeout(()=>{u(!0)},We.HOVER_DELAY)},[]),ie=(0,w.useCallback)(()=>{d(!1),b.current&&(clearTimeout(b.current),b.current=null),u(!1)},[]);(0,w.useEffect)(()=>()=>{b.current&&clearTimeout(b.current)},[]);let ee=(0,w.useCallback)(R=>{R.stopPropagation(),u(!1),b.current&&(clearTimeout(b.current),b.current=null),v(fe=>!fe)},[]),M=(0,w.useCallback)(()=>{v(!1)},[]);if(!s||!c||!c.visible)return null;let O=o.length,Se;O===1?Se=o[o.length-1].author.name.charAt(0).toUpperCase():Se=O>H.MARKER_MAX_COUNT?"99+":`${O}`;let V;return n?V=i?pn:Po:V=i?fn:Pt,(0,Ao.createPortal)((0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)("button",{ref:x,type:"button",onClick:ee,onMouseEnter:j,onMouseLeave:ie,style:{...V,top:c.top,left:c.left},"aria-label":`${O} comment${O>1?"s":""}${n?" (resolved)":""}`,"data-fl-ignore":"",children:[Se,(0,G.jsx)("span",{style:n?hn:_o}),A?(0,G.jsx)("span",{style:{position:"absolute",top:"50%",left:"50%",width:H.MARKER_HEIGHT,height:H.MARKER_HEIGHT,borderRadius:"50%",border:"2px solid var(--fl-accent)",animation:"fl-marker-ripple var(--fl-duration-marker-ripple) ease-out forwards",pointerEvents:"none"}}):null,y?B.map((R,fe)=>(0,G.jsx)("span",{style:{position:"absolute",top:"50%",left:"50%",width:R.size,height:R.size,borderRadius:"50%",backgroundColor:R.color,pointerEvents:"none","--fl-end-dx":`${R.endX}px`,"--fl-end-dy":`${R.endY}px`,"--fl-dx":"0px","--fl-dy":"0px",animation:`fl-resolve-particle var(--fl-duration-resolve-burst) ease-out ${R.delay}ms forwards`}},fe)):null,!f&&o.length>0&&(0,G.jsxs)("span",{style:l?yn:Mo,children:[(0,G.jsxs)("span",{style:gn,children:[(0,G.jsx)("span",{style:vn,children:o[0].author.name}),(0,G.jsx)("span",{style:bn,children:ce(o[0].created_at)})]}),(0,G.jsx)("div",{style:Sn,children:Cn(o[0].content)})]})]}),f&&x.current?(0,G.jsx)(nt,{comments:o,dotRect:x.current.getBoundingClientRect(),onClose:M,onDidResolve:$}):null]}),s)});function st(e,t){let o=e.match(/\[data-feedback-id="([^"]+)"\]/);if(o){let n=document.querySelector(`[data-feedback-id="${o[1]}"]`);if(n)return{element:n,method:"feedback-id"}}try{let n=document.querySelector(e);if(n)return{element:n,method:"selector"}}catch{}if(t){let n=je(t);if(n.element)return{element:n.element,method:"fingerprint",score:n.score}}return{element:null,method:"detached"}}var Fe=require("react/jsx-runtime"),xn=60;function it(){let{groupedByDomPath:e,isDomPathFullyResolved:t,isDomPathFullyArchived:o}=ae(),{adapter:n,setDetachedDomPaths:r}=E(),a=(0,ue.useRef)(null);a.current===null&&(a.current=new Set(e.map(i=>i.domPath)));let s=(0,ue.useRef)(new Set),c=(0,ue.useMemo)(()=>e.filter(i=>!o(i.domPath)),[e,o]),m=(0,ue.useMemo)(()=>{let i=new Map;for(let d of c){let l=null;for(let f of d.comments){let v=f.element_metadata?.fingerprint;if(v){l=v;break}}let u=st(d.domPath,l);i.set(d.domPath,u)}return i},[c]);return(0,ue.useEffect)(()=>{let i=new Set;for(let[d,l]of m)l.method==="detached"&&i.add(d);r(i)},[m,r]),(0,ue.useEffect)(()=>{for(let i of c){let d=m.get(i.domPath);if(d&&d.method==="fingerprint"&&d.element&&d.score!==void 0&&d.score>=xn&&!s.current.has(i.domPath)){s.current.add(i.domPath);let l=Ee(d.element);for(let u of i.comments)u.thread_id===null&&n.updateComment(u.id,{dom_path:l}).catch(()=>{})}}},[c,m,n]),c.length===0?null:(0,Fe.jsx)(Fe.Fragment,{children:c.map(i=>{let d=m.get(i.domPath);return!d||d.method==="detached"?null:(0,Fe.jsx)(at,{domPath:i.domPath,comments:i.comments,isResolved:t(i.domPath),isNew:!a.current.has(i.domPath),resolvedElement:d.element},i.domPath)})})}var _e=require("react/jsx-runtime");function Rn(e,t){switch(t.type){case"TOGGLE_COMMENT_MODE":return{...e,isCommentMode:!e.isCommentMode};case"SET_COMMENT_MODE":return{...e,isCommentMode:t.payload};case"SET_COMMENTS":return{...e,comments:t.payload};case"ADD_COMMENT":return{...e,comments:[...e.comments,t.payload]};case"UPDATE_COMMENT":return{...e,comments:e.comments.map(o=>o.id===t.payload.id?t.payload:o)};default:return e}}var wn={isCommentMode:!1,comments:[]},ft=(0,T.createContext)(null),Tn="[data-fl-root]{--fl-accent:#E8611A;--fl-accent-hover:#C85215;--fl-accent-subtle:rgba(232,97,26,0.1);--fl-accent-glow:rgba(232,97,26,0.2);--fl-surface:#FAFAF7;--fl-surface-raised:#FFFFFF;--fl-border:#E8E5DF;--fl-border-strong:#D4CFC6;--fl-text-primary:#1A1A18;--fl-text-secondary:#6B6860;--fl-text-tertiary:#9C978E;--fl-resolved:#9C978E;--fl-z-base:100000;--fl-duration-instant:80ms;--fl-duration-fast:120ms;--fl-duration-normal:150ms;--fl-duration-marker-enter:280ms;--fl-duration-marker-ripple:400ms;--fl-duration-resolve-burst:450ms;--fl-marker-height:22px;--fl-marker-min-width:20px;--fl-marker-pointer-size:4px;--fl-marker-font-size:11px;--fl-toggle-size:36px;--fl-border-radius:8px;--fl-border-radius-sm:6px;--fl-shadow:0 2px 8px rgba(26,26,24,0.08),0 1px 2px rgba(26,26,24,0.04);--fl-shadow-lg:0 4px 16px rgba(26,26,24,0.12),0 2px 4px rgba(26,26,24,0.06);--fl-shadow-popover:0 8px 30px rgba(26,26,24,0.16),0 2px 6px rgba(26,26,24,0.08);--fl-font-family:'Instrument Sans',-apple-system,BlinkMacSystemFont,sans-serif;--fl-font-size-sm:12px;--fl-font-size-base:14px;--fl-font-size-lg:16px;--fl-line-height:1.5;--fl-font-weight-normal:400;--fl-font-weight-medium:500;font-family:var(--fl-font-family);font-size:var(--fl-font-size-base);line-height:var(--fl-line-height);color:var(--fl-text-primary);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}",An="@keyframes fl-marker-enter{0%{opacity:0;transform:scale(0.4)}50%{opacity:1;transform:scale(1.08)}72%{transform:scale(0.97)}100%{transform:scale(1.0)}}@keyframes fl-marker-ripple{0%{transform:translate(-50%,-50%) scale(0.6);opacity:0.35}100%{transform:translate(-50%,-50%) scale(2.4);opacity:0}}@keyframes fl-resolve-particle{0%{opacity:0.9;transform:translate(var(--fl-dx),var(--fl-dy)) scale(1)}100%{opacity:0;transform:translate(var(--fl-end-dx),var(--fl-end-dy)) scale(0.3)}}@keyframes fl-toggle-beam{0%{box-shadow:0 2px 8px rgba(26,26,24,0.08),0 1px 2px rgba(26,26,24,0.04),0 0 0 0 rgba(232,97,26,0.25)}70%{box-shadow:0 2px 8px rgba(26,26,24,0.08),0 1px 2px rgba(26,26,24,0.04),0 0 0 10px transparent}100%{box-shadow:0 2px 8px rgba(26,26,24,0.08),0 1px 2px rgba(26,26,24,0.04),0 0 0 0 transparent}}",Pn="@font-face{font-family:'Instrument Sans';font-style:normal;font-weight:400;font-display:swap;src:url('https://fonts.gstatic.com/s/instrumentsans/v1/pximypc9vsFDm051Uf6KVwgkfoSxQ0GsQv8To18.woff2') format('woff2')}@font-face{font-family:'Instrument Sans';font-style:normal;font-weight:500;font-display:swap;src:url('https://fonts.gstatic.com/s/instrumentsans/v1/pximypc9vsFDm051Uf6KVwgkfoSxQ0GsQv8To18.woff2') format('woff2')}@font-face{font-family:'Instrument Sans';font-style:normal;font-weight:600;font-display:swap;src:url('https://fonts.gstatic.com/s/instrumentsans/v1/pximypc9vsFDm051Uf6KVwgkfoSxQ0GsQv8To18.woff2') format('woff2')}";function _n(e,t){function o(){let n=t();return n?{sessionToken:n}:void 0}return{getConfig:n=>e.getConfig(n),getComments:(n,r)=>e.getComments(n,r,o()),addComment:n=>e.addComment(n,o()),updateComment:(n,r)=>e.updateComment(n,r,o()),uploadScreenshot:(n,r,a,s)=>e.uploadScreenshot(n,r,a,s,o()),subscribe:(n,r)=>e.subscribe(n,r,o())}}var Io="Lay:";async function Mn(e,t,o,n){if(o?.id&&n){let a=await fetch(`${e}/api/v1/sessions/identify`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:t,userId:o.id,userHash:n,userName:o.name??null})});if(!a.ok){let s=await a.json().catch(()=>({}));throw new Error(s.error??`Session error: ${a.status}`)}return a.json()}let r=await fetch(`${e}/api/v1/sessions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:t})});if(!r.ok){let a=await r.json().catch(()=>({}));throw new Error(a.error??`Session error: ${r.status}`)}return r.json()}function In(e,t,o,n){return e||Be({apiUrl:o??Lo,ai:n})}var Lo="https://www.uselay.com";function Ln(e){return(e??Lo).replace(/\/$/,"")}function ko({children:e,projectId:t,user:o,userHash:n,adapter:r,apiUrl:a,version:s,ai:c,mode:m,active:i,starterChips:d,screenshots:l,onCommentAdded:u}){let[f,v]=(0,T.useReducer)(Rn,wn),A=(0,T.useRef)(u);A.current=u;let S=(0,T.useRef)(In(r,t,a,c)),[y,N]=(0,T.useState)(null),[B,h]=(0,T.useState)(new Set),[x,_]=(0,T.useState)(null),b=(0,T.useRef)(null),[W,$]=(0,T.useState)(!1),j=(0,T.useCallback)(g=>{b.current=g,_(g),g?zt(t,g):Gt(t)},[t]),ie=(0,T.useRef)(_n(S.current,()=>b.current)),[ee,M]=(0,T.useState)("review"),[O,Se]=(0,T.useState)(!0),[V,R]=(0,T.useState)(!1),[fe,Me]=(0,T.useState)("loading"),oe=m??ee,p=i??O;(0,T.useEffect)(()=>{S.current.getConfig(t).then(g=>{M(g.mode),Se(g.active),Me(g.active?"valid":"inactive"),R(!0)},g=>{g instanceof Le&&g.status===404?Me("not_found"):Me("valid"),R(!0)})},[t]),(0,T.useEffect)(()=>{if(oe!=="support"){$(!0);return}if(!V)return;o?.id&&!n&&console.warn(`${Io} user.id provided without userHash in support mode. Comments will be anonymous. Use identifyUser() from @uselay/sdk/server for verified identity.`);let g=Ft(t);if(g){j(g),$(!0);return}let z=Ln(a);Mn(z,t,o,n).then(pe=>{j(pe.token),$(!0)},pe=>{console.warn(`${Io} Failed to create session:`,pe),$(!0)})},[t,oe,V,o,n,a,j]),(0,T.useEffect)(()=>{let g=document.createElement("div");g.setAttribute(ne.ROOT,""),g.setAttribute(ne.IGNORE,""),document.body.appendChild(g);let z=document.createElement("style");return z.textContent=Pn+Tn+An,g.appendChild(z),N(g),()=>{document.body.removeChild(g)}},[]),(0,T.useEffect)(()=>{if(!W||oe==="support"&&!b.current)return;let g=window.location.pathname;ie.current.getComments(t,g).then(z=>{v({type:"SET_COMMENTS",payload:z})},z=>{if(z instanceof Error&&z.message.includes("401")){j(null),$(!1);return}})},[t,W,x,oe,j]),(0,T.useEffect)(()=>{if(!W||oe==="support"&&!b.current)return;let g;try{g=ie.current.subscribe(t,z=>{switch(z.type){case"INSERT":v({type:"ADD_COMMENT",payload:z.comment});break;case"UPDATE":v({type:"UPDATE_COMMENT",payload:z.comment});break}})}catch{}return()=>g?.()},[t,W,x,oe]);let P={projectId:t,user:o,userHash:n,apiUrl:a,version:s,ai:c,mode:m,active:i,starterChips:d,screenshots:l},Z=fe==="not_found",re=y&&V&&W&&p&&!Z,Te=y&&V&&Z&&Ot(),Ie={isCommentMode:f.isCommentMode,comments:f.comments,adapter:ie.current,config:P,dispatch:v,portalRoot:y,mode:oe,projectStatus:fe,remoteConfigLoaded:V,detachedDomPaths:B,setDetachedDomPaths:h,onCommentAddedRef:A};return(0,_e.jsxs)(ft.Provider,{value:Ie,children:[e,(re||Te)&&(0,_e.jsx)(Ve,{}),re&&(0,_e.jsx)(et,{}),re&&(0,_e.jsx)(it,{})]})}var No=require("react");function ze(e){return e.mode==="review"}function Do(e){return e.mode==="support"}var k=require("react/jsx-runtime"),kn={marginTop:6,border:"1px solid var(--fl-border)",borderRadius:"var(--fl-border-radius-sm)",backgroundColor:"var(--fl-surface)",fontFamily:"var(--fl-font-family)",fontSize:12,overflow:"hidden"},Dn={display:"flex",alignItems:"flex-start",gap:6,padding:"6px 8px",cursor:"pointer",userSelect:"none",color:"var(--fl-text-secondary)",lineHeight:1.4},Nn={flexShrink:0,fontSize:10,lineHeight:"16.8px",color:"var(--fl-text-tertiary)"},On={minWidth:0,wordBreak:"break-word"},Hn={padding:"0 8px 8px",display:"flex",flexDirection:"column",gap:6},Fn={fontSize:11,fontWeight:600,color:"var(--fl-text-tertiary)",textTransform:"uppercase",letterSpacing:.5,marginBottom:2,fontFamily:"var(--fl-font-family)"},lt={display:"inline-block",fontSize:11,fontWeight:500,padding:"1px 6px",borderRadius:3,backgroundColor:"var(--fl-border)",color:"var(--fl-text-secondary)",fontFamily:"var(--fl-font-family)"},zn={...lt,backgroundColor:"#D32F2F",color:"#FFFFFF"},Gn={...lt,backgroundColor:"#F9A825",color:"#1A1A18"},_t={fontSize:12,lineHeight:1.5,color:"var(--fl-text-primary)",fontFamily:"var(--fl-font-family)"},Bn={fontSize:12,color:"var(--fl-text-tertiary)",fontFamily:"var(--fl-font-family)",fontStyle:"italic",animation:"fl-analyzing-pulse 1.5s ease-in-out infinite"},Wn={display:"flex",gap:6,flexWrap:"wrap",marginBottom:4},$n="@keyframes fl-analyzing-pulse{0%,100%{opacity:0.4}50%{opacity:1}}";function Un(e){return e?ze(e)?e.category:`${e.intent.replace("_"," ")} \xB7 ${e.urgency} urgency`:"Analyzing..."}function Kn(e){return e==="high"?zn:e==="medium"?Gn:lt}function Oo({elementMetadata:e,aiContext:t,aiEnabled:o=!0}){let[n,r]=(0,No.useState)(!1);if(!e||!o||t&&!("mode"in t))return null;let a=Un(t),s=!t;return(0,k.jsxs)("div",{style:kn,children:[s&&(0,k.jsx)("style",{children:$n}),(0,k.jsxs)("div",{style:Dn,onClick:()=>r(c=>!c),role:"button",tabIndex:0,onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),r(m=>!m))},children:[(0,k.jsx)("span",{style:Nn,children:n?"\u25BE":"\u25B8"}),(0,k.jsx)("span",{style:On,children:n?"AI Interpretation":a})]}),n&&(0,k.jsx)("div",{style:Hn,children:s?(0,k.jsxs)("div",{children:[(0,k.jsx)("div",{style:Fn,children:"AI Interpretation"}),(0,k.jsx)("div",{style:Bn,children:"Analyzing..."})]}):t&&ze(t)?(0,k.jsx)("div",{children:t.interpretation?(0,k.jsx)("div",{style:_t,children:t.interpretation}):(0,k.jsx)("div",{style:_t,children:t.category})}):t?(0,k.jsxs)("div",{children:[(0,k.jsxs)("div",{style:Wn,children:[(0,k.jsx)("span",{style:lt,children:t.intent.replace("_"," ")}),(0,k.jsxs)("span",{style:Kn(t.urgency),children:[t.urgency," urgency"]})]}),(0,k.jsx)("div",{style:_t,children:t.summary})]}):null})]})}function Xn(){return`${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function Ho(){let e=[],t=new Set;function o(n){t.forEach(r=>r(n))}return{async getConfig(){return{mode:"review",active:!0}},async getComments(n,r,a){let s=e.filter(c=>c.project_id===n&&c.url_path===r);return a?.sessionToken&&(s=s.filter(c=>c.author.id===a.sessionToken)),s},async addComment(n){let r=new Date().toISOString(),a={...n,id:Xn(),created_at:r,updated_at:r};return e.push(a),o({type:"INSERT",comment:a}),a},async updateComment(n,r){let a=e.findIndex(c=>c.id===n);if(a===-1)throw new Error(`Comment not found: ${n}`);let s={...e[a],...r,updated_at:new Date().toISOString()};return e[a]=s,o({type:"UPDATE",comment:s}),s},async uploadScreenshot(){},subscribe(n,r){return t.add(r),()=>{t.delete(r)}}}}0&&(module.exports={AIContextCard,ArchivedThreadsPanel,CommentActions,CommentAnchor,CommentDot,CommentDots,CommentItem,CommentLayer,CommentThread,DetachedCommentsPanel,ElementHighlighter,LayProvider,LayToggle,ReplyInput,captureElementMetadata,computeContrastRatio,createHostedAdapter,createMemoryAdapter,findByFingerprint,formatRelativeTime,generateDomPath,generateFingerprint,getGuestAuthor,isAIContextReview,isAIContextSupport,isCommentable,isGeneratedClassName,parseUserAgent,persistGuestName,resolveAuthor,resolveEffectiveBackground,resolveElement,saveGuestAuthor,scoreFingerprintMatch,summarizeDomPath,useCommentMode,useComments,useElementSelector,useLayContext});
2
2
  //# sourceMappingURL=index.js.map