overplay 4.0.0 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/LICENSE +3 -0
- package/README.md +6 -3
- package/dist/overplay.esm.js +96 -30
- package/dist/overplay.esm.js.map +1 -1
- package/dist/overplay.iife.js +1 -1
- package/dist/overplay.iife.js.map +1 -1
- package/dist/overplay.umd.js +1 -1
- package/dist/overplay.umd.js.map +1 -1
- package/package.json +3 -3
package/dist/overplay.iife.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var Overplay=function(e){"use strict";var t=Object.defineProperty,i=(e,i,n)=>((e,i,n)=>i in e?t(e,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[i]=n)(e,"symbol"!=typeof i?i+"":i,n);function n(e){if(!e||"object"!=typeof e||Array.isArray(e))throw new Error("Invalid comment data.");return e}function s(e,t){if("string"!=typeof e||!e.trim())throw new Error(`Invalid ${t}.`);return e}function o(e){const t=new Date(e);if(!Number.isFinite(t.getTime()))throw new Error("Invalid comment date.");return t}function r(e){const t=n(e);return{id:s(t.id,"reply ID"),text:s(t.text,"reply text"),author:s(t.author,"author"),authorId:"string"==typeof t.authorId?t.authorId:void 0,via:"string"==typeof t.via?t.via.slice(0,60):void 0,avatarUrl:"string"==typeof t.avatarUrl?t.avatarUrl:void 0,timestamp:o(t.timestamp),commentId:s(t.commentId,"comment ID")}}function a(e){if(!Array.isArray(e))return{};const t=(e,t)=>"string"==typeof e&&e.trim()?e.trim().slice(0,t):void 0,i=e.slice(0,6).flatMap(e=>{const i=e&&"object"==typeof e?e:{},n=i.target&&"object"==typeof i.target?i.target:{},s=t(n.selector,500);if(!["press","hover","focus"].includes(i.action)||!s)return[];const o=t(n.role,40),r=t(n.name,120),a=t(n.tag,40);return[{action:i.action,target:{selector:s,...o?{role:o}:{},...r?{name:r}:{},...a?{tag:a}:{}}}]});return i.length?{reveal:i}:{}}function l(e){if(!Array.isArray(e))throw new Error("Expected a list of comments.");return e.map(e=>{const t=n(e);if("number"!=typeof t.x||"number"!=typeof t.y||!Number.isFinite(t.x)||!Number.isFinite(t.y))throw new Error("Invalid comment position.");const i=t.anchor?n(t.anchor):null,l=t.element&&"object"==typeof t.element?t.element:null,c=e=>"string"==typeof e&&e.trim()?e.trim().slice(0,120):void 0;return{id:s(t.id,"comment ID"),text:s(t.text,"comment text"),author:s(t.author,"author"),authorId:"string"==typeof t.authorId?t.authorId:void 0,via:"string"==typeof t.via?t.via.slice(0,60):void 0,revision:"number"==typeof t.revision?t.revision:void 0,updatedAt:"string"==typeof t.updatedAt?t.updatedAt:void 0,avatarUrl:"string"==typeof t.avatarUrl?t.avatarUrl:void 0,timestamp:o(t.timestamp),x:t.x,y:t.y,resolved:!0===t.resolved,pageUrl:s(t.pageUrl,"page URL"),pageTitle:"string"==typeof t.pageTitle&&t.pageTitle.trim()?t.pageTitle.trim().slice(0,300):void 0,replies:Array.isArray(t.replies)?t.replies.map(r):[],selector:"string"==typeof t.selector?t.selector:void 0,element:l&&c(l.label)?{label:c(l.label),...c(l.place)?{place:c(l.place)}:{},...a(l.reveal)}:void 0,anchor:i&&"number"==typeof i.x&&"number"==typeof i.y&&Number.isFinite(i.x)&&Number.isFinite(i.y)?{x:Math.max(0,Math.min(1,i.x)),y:Math.max(0,Math.min(1,i.y))}:void 0}})}function c(e){return l(e)}function d(e){const t=e.replace(/^\?/,"").split("&").filter(e=>{try{return"cw_comment"!==decodeURIComponent(e.split("=")[0].replace(/\+/g," "))}catch{return!0}}).join("&");return t?"?"+t:""}const h={"comments.artsvit.com":"https://overplay.app"};class p{constructor(e,t,n,s){i(this,"base"),i(this,"key"),i(this,"accessToken",""),i(this,"expiresAt",0),i(this,"initialized",!1),i(this,"pending"),i(this,"cancelSignIn"),i(this,"user"),this.projectId=t,this.page=n,this.sessionChanged=s;const o=new URL(e);if("https:"!==o.protocol&&("http:"!==o.protocol||!["localhost","127.0.0.1"].includes(o.hostname)))throw new Error("serverUrl must use HTTPS.");if(o.username||o.password||o.search||o.hash||"/"!==o.pathname)throw new Error("serverUrl must be a service origin without a path.");var r;this.base=(r=o.origin,h[new URL(r).hostname]??r),this.key=`overplay:${this.base}:${t}:session`;try{const e=JSON.parse(sessionStorage.getItem(this.key)||"null");(null==e?void 0:e.expiresAt)>Date.now()&&(this.accessToken=e.accessToken,this.expiresAt=e.expiresAt)}catch{}}get signedIn(){return!!this.user&&this.expiresAt>Date.now()}clear(){this.accessToken="",this.expiresAt=0,this.user=void 0;try{sessionStorage.removeItem(this.key)}catch{}this.sessionChanged()}async request(e,t="GET",i){const n=new URL(`/api${e}`,this.base);n.searchParams.set("projectId",this.projectId);const s=await fetch(n,{method:t,credentials:"omit",headers:{...void 0!==i?{"Content-Type":"application/json"}:{},...this.accessToken?{Authorization:`Bearer ${this.accessToken}`}:{}},body:void 0===i?void 0:JSON.stringify(i)}),o=await s.json().catch(()=>null);if(!s.ok)throw(401===s.status||403===s.status&&"GET"===t)&&this.clear(),new Error((null==o?void 0:o.error)||`Comment service returned ${s.status}.`);if(null===o)throw new Error("Comment service returned an invalid response.");return o}async initialize(){if(!this.initialized&&(this.initialized=!0,this.accessToken))try{this.user=(await this.request("/me")).user,this.sessionChanged(this.user)}catch(e){throw this.accessToken&&(this.initialized=!1),e}}signIn(){if(this.pending)return this.pending;const e=window.open("about:blank",`overplay-${this.projectId}`,"popup,width=520,height=760");return e?(this.pending=new Promise((t,i)=>{let n=!1;const s=s=>{n||(n=!0,window.removeEventListener("message",a),clearInterval(l),clearTimeout(c),e.close(),this.pending=void 0,this.cancelSignIn=void 0,s?i(s):t())},o=Array.from(crypto.getRandomValues(new Uint8Array(32)),e=>e.toString(16).padStart(2,"0")).join("");let r=!1;const a=t=>{var i;r||t.origin!==this.base||t.source!==e||"overplay:authorization"!==(null==(i=t.data)?void 0:i.type)||t.data.projectId!==this.projectId||"string"!=typeof t.data.code||(r=!0,(async()=>{const e=await this.request("/connect/token","POST",{code:t.data.code,verifier:o});if(!n)if(this.accessToken=e.accessToken,this.expiresAt=e.expiresAt,this.user=(await this.request("/me")).user,n)this.clear();else{this.initialized=!0;try{sessionStorage.setItem(this.key,JSON.stringify({accessToken:this.accessToken,expiresAt:this.expiresAt}))}catch{}this.sessionChanged(this.user),s()}})().catch(e=>{this.clear(),s(e instanceof Error?e:new Error("Sign-in failed."))}))},l=setInterval(()=>{e.closed&&!r&&s(new Error("Sign-in window was closed."))},750),c=setTimeout(()=>s(new Error("Sign-in timed out. Please try again.")),3e5);this.cancelSignIn=()=>s(new Error("Widget was closed.")),window.addEventListener("message",a),crypto.subtle.digest("SHA-256",(new TextEncoder).encode(o)).then(t=>{if(n)return;const i=btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),s=new URL("/connect",this.base);s.search=new URLSearchParams({projectId:this.projectId,origin:location.origin,challenge:i}).toString(),e.location.href=s.href}).catch(()=>s(new Error("Secure sign-in is unavailable.")))}),this.pending):Promise.reject(new Error("Allow popups to sign in to Overplay."))}async signOut(){try{this.accessToken&&await this.request("/connect/logout","POST",{})}finally{this.clear()}}destroy(){var e;null==(e=this.cancelSignIn)||e.call(this)}async loadComments(){if(await this.initialize(),this.expiresAt&&this.expiresAt<=Date.now()&&this.clear(),!this.signedIn)return[];const e=this.accessToken,t=[];let i="";do{const e=new URLSearchParams({after:i}),n=await this.request(`/comments?${e}`);t.push(...n.comments),i=n.next||""}while(i);return e===this.accessToken&&this.signedIn?l(t):[]}subscribeToChanges(e){let t=!1,i=!1;const n=async()=>{if(i||t||"hidden"===document.visibilityState||!this.user)return;t=!0;const n=this.page(),s=this.accessToken;try{const t=await this.loadComments();!i&&this.signedIn&&s===this.accessToken&&n===this.page()&&e(t)}catch{}finally{t=!1}},s=setInterval(()=>{n()},3e4),o=()=>{"visible"===document.visibilityState&&n()};return document.addEventListener("visibilitychange",o),()=>{i=!0,clearInterval(s),document.removeEventListener("visibilitychange",o)}}async saveComments(){throw new Error("Hosted storage requires individual comment mutations.")}async upsertComment(e){await this.request(`/comments/${encodeURIComponent(e.id)}`,"PUT",e)}async deleteComment(e){await this.request(`/comments/${encodeURIComponent(e)}`,"DELETE")}async addReply(e,t){await this.request(`/comments/${encodeURIComponent(e)}/replies`,"POST",t)}async setResolved(e,t){await this.request(`/comments/${encodeURIComponent(e)}`,"PATCH",{resolved:t})}}class u{constructor(e="overplay-comments"){this.storageKey=e}async loadComments(){const e=localStorage.getItem(this.storageKey);return null===e?[]:l(JSON.parse(e))}async saveComments(e){localStorage.setItem(this.storageKey,JSON.stringify(e))}async upsertComment(e){await this.change(t=>[...t.filter(t=>t.id!==e.id),e])}async deleteComment(e){await this.change(t=>t.filter(t=>t.id!==e))}async addReply(e,t){await this.change(i=>{if(!i.some(t=>t.id===e))throw new Error("This comment was removed. Refresh to see the latest notes.");return i.map(i=>i.id!==e||i.replies.some(e=>e.id===t.id)?i:{...i,replies:[...i.replies,t]})})}async setResolved(e,t){await this.change(i=>{if(!i.some(t=>t.id===e))throw new Error("This comment was removed. Refresh to see the latest notes.");return i.map(i=>i.id===e?{...i,resolved:t}:i)})}async change(e){const t=async()=>this.saveComments(e(await this.loadComments()));"undefined"!=typeof navigator&&navigator.locks?await navigator.locks.request(`overplay:${this.storageKey}`,t):await t()}subscribeToChanges(e){const t=t=>{t.storageArea!==localStorage||t.key!==this.storageKey&&null!==t.key||this.loadComments().then(e).catch(()=>{})};return window.addEventListener("storage",t),()=>window.removeEventListener("storage",t)}}function m(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();const e=crypto.getRandomValues(new Uint8Array(16));e[6]=15&e[6]|64,e[8]=63&e[8]|128;const t=Array.from(e,e=>e.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function g(e){if(!e||"string"!=typeof e.id||!e.id.trim()||"string"!=typeof e.name||!e.name.trim())throw new Error("A user needs a stable ID and a name.");const t="owner"===e.role||"admin"===e.role||"member"===e.role?{role:e.role}:{};return{id:e.id.trim(),name:e.name.trim().slice(0,80),avatarUrl:e.avatarUrl,...t}}function f(e){let t;try{const i=localStorage.getItem(e);i&&(t=g(JSON.parse(i)))}catch{}const i=t??{id:m(),name:"Guest"};return{user:i,persistent:v(e,i)}}function v(e,t){try{return localStorage.setItem(e,JSON.stringify(t)),!0}catch{return!1}}function x(e,t,i){const n=[],s=(e,s,o,r)=>{t.has(e)||(t.add(e),r.authorId!==i&&n.push({kind:s,commentId:o,author:r.author,avatarUrl:r.avatarUrl,text:r.text}))};for(const o of e){s(o.id,"comment",o.id,o);for(const e of o.replies)s(`${o.id}/${e.id}`,"reply",o.id,e)}return n}function w(e,t){return e.length===t.length&&JSON.stringify(e)===JSON.stringify(t)}const b="4.0.0",y="overplay",k=`npm install ${y}@latest`;const C={indigo:{label:"Indigo",color:"#575ce5"},violet:{label:"Violet",color:"#8048d8"},blue:{label:"Blue",color:"#0068f9"},teal:{label:"Teal",color:"#0f8a8c"},amber:{label:"Amber",color:"#b97a06"},orange:{label:"Orange",color:"#d9641e"},red:{label:"Red",color:"#d23c3c"},pink:{label:"Pink",color:"#d0427f"},graphite:{label:"Graphite",color:"#242736"}},S={theme:["light","dark","system"],pinColor:["site","indigo","violet","blue","teal","amber","orange","red","pink","graphite"],buttonColor:["default","site","indigo","violet","blue","teal","amber","orange","red","pink"],resolvedPins:["green","gray"],pinSize:["regular","small"],pinLabel:["number","initials"],pushContent:[!0,!1],notifications:[!0,!1],shortcut:[!0,!1]};function E(e,t){const i={...t};try{const t=JSON.parse(localStorage.getItem(e)||"{}");for(const e of Object.keys(S))S[e].includes(t[e])&&Object.assign(i,{[e]:t[e]})}catch{}return i}function A(e,t,i){const n=Object.fromEntries(Object.entries(t).filter(([e,t])=>i[e]!==t));try{return Object.keys(n).length?localStorage.setItem(e,JSON.stringify(n)):localStorage.removeItem(e),!0}catch{return!1}}function I(e){const t=e.trim().split(/\s+/).filter(Boolean);return(t.length>1?`${[...t[0]][0]}${[...t[t.length-1]][0]}`:[...t[0]??"?"].slice(0,2).join("")).toUpperCase()}function T(e,t="",i){const n=document.createElement(e);return t&&(n.className=t),void 0!==i&&(n.textContent=i),n}const $={comment:"M21 11.5a8.4 8.4 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.4 8.4 0 0 1-3.8-.9L3 21l1.9-5.7a8.4 8.4 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.4 8.4 0 0 1 3.8-.9h.5a8.5 8.5 0 0 1 8 8v.5Z",plus:"M12 5v14M5 12h14",close:"m6 6 12 12M6 18 18 6",check:"m5 12 4 4L19 6",back:"m12 5-7 7 7 7M5 12h14",arrow:"M12 19V5m-6 6 6-6 6 6",refresh:"M20.5 12a8.5 8.5 0 1 1-2.6-6.1L20.5 8.5M20.5 3.5v5h-5",open:"M7 17 17 7M9 7h8v8",trash:"M3 6h18M9 6V4h6v2M5 6l1 14h12l1-14M10 10v6m4-6v6",pin:"M12 21s7-6 7-13A7 7 0 0 0 5 8c0 7 7 13 7 13ZM12 6v4M10 8h4",search:"m21 21-5-5M18 10a8 8 0 1 1-16 0 8 8 0 0 1 16 0Z",eye:"M2.5 12S6 5.5 12 5.5 21.5 12 21.5 12 18 18.5 12 18.5 2.5 12 2.5 12ZM12 14.8a2.8 2.8 0 1 0 0-5.6 2.8 2.8 0 0 0 0 5.6Z",eyeOff:"M3 3l18 18M10.6 5.6A9 9 0 0 1 12 5.5c6 0 9.5 6.5 9.5 6.5a16 16 0 0 1-2.9 3.6M6.5 6.9A16 16 0 0 0 2.5 12S6 18.5 12 18.5a9 9 0 0 0 4.6-1.3M10 10a2.8 2.8 0 0 0 4 4",unlink:"M4.5 4.5h15v15h-15zM9.5 9.5l5 5M14.5 9.5l-5 5",dock:"M4 5h16v14H4zM15 5v14",settings:"M4 7h9m4 0h3M4 17h3m4 0h9M15 5v4M9 15v4",edit:"M4 20h4L19 9l-4-4L4 16v4ZM13 7l4 4",signin:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4M10 17l5-5-5-5M15 12H3",signout:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4M16 17l5-5-5-5M21 12H9",more:"M5 12h.01M12 12h.01M19 12h.01",popout:"M14 4h6v6M20 4l-8 8M18 14v5H5V6h5"};function L(e){const t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("fill","none"),t.setAttribute("stroke","currentColor"),t.setAttribute("stroke-width","1.65"),t.setAttribute("stroke-linecap","round"),t.setAttribute("stroke-linejoin","round"),t.setAttribute("aria-hidden","true");const i=document.createElementNS(t.namespaceURI,"path");return i.setAttribute("d",$[e]),t.append(i),t}function P(e,t,i,n){const s=T("button",t);return s.type="button",s.setAttribute("aria-label",e),s.title=e,n&&s.append(L(n)),t.includes("icon-button")||s.append(T("span","",e)),s.addEventListener("click",i),s}function M(e,t){const i=T("span","avatar",I(e));if(i.setAttribute("aria-hidden","true"),t)try{const e=new URL(t,location.href);if("https:"===e.protocol||"http:"===e.protocol&&e.origin===location.origin){const t=T("img");t.src=e.href,t.alt="",t.referrerPolicy="no-referrer",t.complete&&t.naturalWidth?i.replaceChildren(t):t.addEventListener("load",()=>i.replaceChildren(t))}}catch{}return i}const R={accent:"#0068f9","accent-strong":"#0055d4","accent-soft":"#eef4ff","accent-line":"#d3e3fd","accent-focus":"#99c2ff",ink:"#121722","ink-soft":"#3a3f4a",muted:"#636874",subtle:"#8a8e97",surface:"#ffffff",canvas:"#f7f7f8","surface-soft":"#f0f1f3",line:"#e8e9ec","line-strong":"#dedfe3","avatar-bg":"#e8f1ff","avatar-ink":"#2560c4",inverse:"#121722","on-inverse":"#ffffff","inverse-muted":"#b8bcc6",resolved:"#0f9a6c","resolved-text":"#0b7a55","resolved-soft":"#e7f6ef",danger:"#c43d3d","danger-soft":"#fff4f3","danger-line":"#f3cfcf",warning:"#745320","warning-soft":"#fff8e8","warning-line":"#ebd59f","radius-sm":"6px",radius:"10px","radius-md":"12px","radius-lg":"16px","radius-xl":"26px","radius-pill":"999px","shadow-sm":"0 0 0 1px #1217221a,0 1px 2px #12172229",shadow:"0 1px 3px #1217221a,0 16px 32px -12px #12172233",font:'"Inter",-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif'},z={"accent-strong":"color-mix(in srgb,var(--cw-accent) 66%,#ffffff)","accent-soft":"color-mix(in srgb,var(--cw-accent) 18%,#16181d)","accent-line":"color-mix(in srgb,var(--cw-accent) 42%,#16181d)","accent-focus":"color-mix(in srgb,var(--cw-accent) 60%,#16181d)",ink:"#eef0f3","ink-soft":"#c6c9d0",muted:"#9a9ea8",subtle:"#767a84",surface:"#16181d",canvas:"#0e0f12","surface-soft":"#1f2228",line:"#262930","line-strong":"#33373f","avatar-bg":"#1b2a45","avatar-ink":"#9cc3ff",inverse:"#23262d","inverse-muted":"#a6aab3",resolved:"#16a877","resolved-text":"#48d3a0","resolved-soft":"#13302a",danger:"#ec6a6a","danger-soft":"#341c21","danger-line":"#5b2b31",warning:"#efc56e","warning-soft":"#2f2718","warning-line":"#57472a","shadow-sm":"0 0 0 1px #ffffff14,0 1px 2px #00000066",shadow:"0 1px 3px #00000066,0 16px 40px -12px #000000b3"};function q(e=R){return Object.entries(e).map(([e,t])=>`--cw-${e}:${t};`).join("")}const O=`\n:host{all:initial;${q()}color:var(--cw-ink);font:16px/1.5 var(--cw-font);letter-spacing:normal;text-align:left;color-scheme:light}\n:host([data-theme=dark]){${q(z)}color-scheme:dark}\n@media(prefers-color-scheme:dark){:host([data-theme=system]){${q(z)}color-scheme:dark}}\n:host>div{font:16px/1.5 var(--cw-font);color:var(--cw-ink);letter-spacing:normal;text-align:left}*,*::before,*::after{box-sizing:border-box}button,input,textarea,select{font:inherit}button{cursor:pointer}button:disabled{cursor:default;opacity:.45}button:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible{outline:3px solid var(--cw-accent);outline-offset:3px}button{color:inherit}svg{width:18px;height:18px;flex-shrink:0}button{touch-action:manipulation}img{max-width:100%}[hidden]{display:none!important}\n.launcher{position:fixed;bottom:24px;right:24px;display:flex;align-items:center;justify-content:center;width:52px;height:52px;border:1px solid #ffffff24;background:var(--cw-inverse);color:var(--cw-on-inverse);padding:0;border-radius:50%;box-shadow:0 6px 24px #12172233;font-weight:600;font-size:16px;pointer-events:auto;touch-action:none;user-select:none;-webkit-user-select:none;cursor:grab;transition:transform .16s,box-shadow .16s}.launcher:hover{transform:translateY(-2px);box-shadow:0 8px 28px #20243733}.launcher.dragging{cursor:grabbing;transition:none;transform:scale(1.06);box-shadow:0 12px 32px #2024374d}.launcher[aria-expanded=true]{background:var(--cw-accent)}.launcher>svg{width:23px;height:23px}.badge{position:absolute;top:-5px;right:-5px;font-weight:650;font-size:12px;line-height:18px;min-width:22px;height:22px;border:2px solid var(--cw-surface);border-radius:999px;background:var(--cw-accent);color:#fff;text-align:center;padding:0 4px}.launcher[aria-expanded=true] .badge{background:var(--cw-inverse)}\n.panel{position:fixed;top:0;right:0;bottom:0;width:400px;max-width:100vw;display:flex;flex-direction:column;background:var(--cw-surface);border-left:1px solid var(--cw-line);box-shadow:var(--cw-shadow);pointer-events:auto;overflow:hidden}.panel.entering{animation:slide-in .2s ease-out}.panel.left{right:auto;left:0;border-left:0;border-right:1px solid var(--cw-line);--cw-slide:-24px}.detail{display:flex;flex-direction:column;flex:1;min-height:0}.detail.entering{animation:enter .16s ease-out}.detail:focus{outline:0}.head{display:flex;align-items:center;gap:10px;padding:22px 20px 16px}.brand-icon{width:34px;height:34px;display:grid;place-items:center;background:var(--cw-accent-soft);color:var(--cw-accent);border-radius:50%}.heading{flex:1;min-width:0}.heading h2{font-size:19px;line-height:1.3;letter-spacing:-.4px;margin:0;font-weight:650}.eyebrow{font-size:12px;font-weight:700;letter-spacing:1.4px;color:var(--cw-muted);text-transform:uppercase;margin:0 0 4px}.subtext{color:var(--cw-muted);font-size:14px;margin:4px 0 0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.icon-button{width:32px;height:32px;display:inline-grid;place-items:center;background:transparent;border:0;border-radius:50%;flex-shrink:0}.icon-button:hover{background:var(--cw-surface-soft)}.icon-button.danger{color:var(--cw-danger)}.icon-button svg{width:16px;height:16px}.icon-button.outlined{width:42px;height:42px;border:1px solid var(--cw-line-strong);border-radius:50%;color:var(--cw-ink-soft)}.icon-button.outlined svg{width:18px;height:18px}.icon-button.busy:disabled{opacity:1;color:var(--cw-accent)}.icon-button.busy svg{animation:spin .9s linear infinite}.toolbar{padding:0 20px 16px;display:flex;gap:10px;align-items:center}.primary{border:0;border-radius:var(--cw-radius-pill);background:var(--cw-accent);color:#fff;display:inline-flex;gap:7px;align-items:center;justify-content:center;padding:10px 16px;font-size:14px;font-weight:550;white-space:nowrap;box-shadow:inset 0 -1px 0 #12172238;transition:filter .16s}.primary:hover{filter:brightness(.94)}.toolbar .primary{flex:1}.quiet{border:1px solid var(--cw-line-strong);background:var(--cw-surface);color:var(--cw-ink);border-radius:var(--cw-radius-pill);padding:9px 16px;font-size:14px}.quiet:hover{background:var(--cw-canvas)}.quiet.update{display:inline-flex;align-items:center;gap:6px;white-space:nowrap;flex-shrink:0;color:var(--cw-accent);border-color:var(--cw-accent-line);background:var(--cw-accent-soft);font-weight:600}.quiet.update:hover{border-color:var(--cw-accent)}.quiet.update svg{width:14px;height:14px}.scope{display:grid;grid-template-columns:1fr 1fr;gap:4px;margin:0 20px 8px;padding:4px;background:var(--cw-surface-soft);border-radius:var(--cw-radius-pill)}.scope-option{display:flex;gap:7px;align-items:center;justify-content:center;border:0;background:transparent;border-radius:var(--cw-radius-pill);padding:8px 6px;font-size:14px;font-weight:550;color:var(--cw-muted);white-space:nowrap}.scope-option:hover{color:var(--cw-ink)}.scope-option[aria-pressed=true]{background:var(--cw-surface);color:var(--cw-ink);box-shadow:0 1px 3px #2024371f}.scope-option[aria-pressed=true] .count{background:var(--cw-accent-soft);color:var(--cw-accent)}.tabs{display:grid;grid-template-columns:repeat(3,1fr);gap:4px;margin:0 20px 8px;padding:4px;border:1px solid var(--cw-line);border-radius:var(--cw-radius-pill)}.tab{display:flex;gap:7px;align-items:center;justify-content:center;border:0;border-radius:var(--cw-radius-pill);background:transparent;padding:7px 6px;color:var(--cw-muted);font-size:14px;font-weight:550;white-space:nowrap}.tab[aria-pressed=true]{color:var(--cw-on-inverse);background:var(--cw-inverse)}.tab[aria-pressed=true] .count{background:#ffffff2e;color:var(--cw-on-inverse)}.count{background:var(--cw-surface-soft);padding:0 6px;border-radius:5px;font-size:12px;line-height:18px}.search{position:relative;margin:4px 20px 8px}.search>svg{position:absolute;left:11px;top:11px;width:15px;height:15px;color:var(--cw-subtle);pointer-events:none}.search input{border:1px solid var(--cw-line);border-radius:var(--cw-radius);background:var(--cw-canvas);width:100%;padding:9px 38px 9px 34px;color:var(--cw-ink);font-size:14px}.search input::placeholder{color:var(--cw-subtle)}.search input::-webkit-search-cancel-button{-webkit-appearance:none;appearance:none}.search-clear{position:absolute;right:5px;top:50%;transform:translateY(-50%);width:28px;height:28px;color:var(--cw-muted)}.search-clear svg{width:14px;height:14px}.people{display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin:0 20px 6px}.filter-chip{display:inline-flex;align-items:center;gap:6px;border:1px solid var(--cw-line);background:var(--cw-surface);color:var(--cw-ink-soft);border-radius:999px;padding:4px 6px 4px 11px;font-size:13px;font-weight:600;white-space:nowrap}.filter-chip:hover{background:var(--cw-canvas)}.filter-chip[aria-pressed=true]{background:var(--cw-accent-soft);border-color:var(--cw-accent-line);color:var(--cw-accent)}.filter-chip[aria-pressed=true] .count{background:var(--cw-surface);color:var(--cw-accent)}.select{position:relative;display:inline-flex;min-width:0;max-width:220px;color:var(--cw-muted)}.select::after{content:'';position:absolute;right:12px;top:50%;width:6px;height:6px;border:solid currentColor;border-width:0 1.5px 1.5px 0;transform:translateY(-70%) rotate(45deg);pointer-events:none}.select select{appearance:none;-webkit-appearance:none;border:1px solid var(--cw-line);background:var(--cw-surface);color:var(--cw-ink-soft);border-radius:999px;padding:5px 30px 5px 11px;font-size:13px;font-weight:600;line-height:18px;max-width:100%;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;cursor:pointer}.select select:hover{background:var(--cw-canvas)}.select.chosen{color:var(--cw-accent)}.select.chosen select{background:var(--cw-accent-soft);border-color:var(--cw-accent-line);color:var(--cw-accent)}.select option{color:var(--cw-ink);background:var(--cw-surface)}.link-button{margin-left:auto;border:0;background:transparent;color:var(--cw-accent);font-size:13px;font-weight:600;padding:4px 2px;white-space:nowrap}.link-button:hover{text-decoration:underline}mark.hit{background:color-mix(in srgb,var(--cw-accent) 22%,transparent);color:inherit;border-radius:3px;padding:0 1px;-webkit-box-decoration-break:clone;box-decoration-break:clone}.note-match{display:flex;align-items:center;gap:5px;margin:4px 0 0 31px;font-size:12.5px;line-height:1.5;color:var(--cw-muted);min-width:0}.note-match svg{width:12px;height:12px}.note-match-label{font-weight:600;color:var(--cw-ink-soft);white-space:nowrap;flex-shrink:0;max-width:45%;overflow:hidden;text-overflow:ellipsis}.note-match-text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.list{flex:1;overflow:auto;overscroll-behavior:contain;padding:8px 12px 16px;min-height:0}.list-title{display:flex;align-items:center;gap:8px;padding:12px 8px 6px;color:var(--cw-muted);font-size:12px;letter-spacing:1.15px;text-transform:uppercase;font-weight:600}.page-path{text-transform:none;letter-spacing:0;font-size:13px;color:var(--cw-ink-soft);font-family:ui-monospace,SFMono-Regular,Menlo,monospace;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.page-name{text-transform:none;letter-spacing:0;font-size:13px;font-weight:600;color:var(--cw-ink-soft);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.here{flex-shrink:0;padding:0 6px;border-radius:5px;background:var(--cw-accent-soft);color:var(--cw-accent);font-size:11px;letter-spacing:.4px;line-height:18px}.go{margin-left:auto;display:inline-flex;align-items:center;gap:4px;color:var(--cw-accent);font-weight:600}.note.current{background:var(--cw-accent-soft);border-color:var(--cw-accent-line)}.note{display:block;text-align:left;width:100%;border:1px solid transparent;background:var(--cw-surface);color:var(--cw-ink);border-radius:10px;padding:9px 10px;margin-bottom:2px}.note .note-header .via{color:var(--cw-muted);font-size:10px;max-width:110px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.note-header{margin-bottom:4px;gap:7px}.note .avatar{width:24px;height:24px;font-size:11px}.note .name{font-size:13px}.note .time{margin-left:0}.note-meta{margin-left:auto;display:inline-flex;align-items:center;gap:8px;font-size:12px;color:var(--cw-muted);white-space:nowrap;flex-shrink:0}.note-meta svg{width:12px;height:12px}.note:hover{background:var(--cw-canvas);border-color:var(--cw-line)}.note-header{display:flex;align-items:center;gap:8px;margin-bottom:9px}.avatar{display:inline-grid;place-items:center;width:29px;height:29px;border-radius:50%;background:var(--cw-avatar-bg);color:var(--cw-avatar-ink);font-size:12px;font-weight:700;flex-shrink:0;overflow:hidden}.avatar img{height:100%;width:100%;object-fit:cover}.name{font-size:14px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.time{font-size:12px;color:var(--cw-muted);margin-left:auto;white-space:nowrap}.note-text{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;margin:0 0 0 31px;line-height:1.5;font-size:14px;color:var(--cw-ink-soft);overflow-wrap:anywhere}.note-footer{display:flex;gap:6px;align-items:center;margin:6px 0 0 31px;color:var(--cw-muted);font-size:12px}.note-footer svg{width:12px;height:12px}.note-number{color:var(--cw-accent);font-weight:700}.status{display:inline-flex;align-items:center;gap:4px}.status.resolved{color:var(--cw-resolved-text)}.status-dot{width:5px;height:5px;background:var(--cw-accent);border-radius:50%;display:inline-block}.empty{height:100%;min-height:230px;display:flex;align-items:center;justify-content:center;text-align:center;padding:32px 16px}.empty-icon{position:relative;display:grid;place-items:center;margin:0 auto 18px;width:64px;height:64px;border:1px solid var(--cw-line);border-radius:21px;transform:rotate(-7deg);background:var(--cw-canvas);color:var(--cw-accent)}.empty-icon svg{width:27px;height:27px}.empty h3{font-size:17px;letter-spacing:-.25px;margin:0 0 8px}.empty p{font-size:14px;color:var(--cw-muted);line-height:1.7;margin:0 auto 18px;max-width:230px}.footer{display:flex;align-items:center;gap:9px;border-top:1px solid var(--cw-line);padding:14px 20px;background:var(--cw-canvas)}.footer .avatar{width:25px;height:25px;font-size:11px}.identity{border:0;background:transparent;text-align:left;padding:0;min-width:0;flex:1}.identity strong{display:block;font-size:13px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.identity small{font-size:12px;color:var(--cw-muted)}.storage-label{font-size:11px;color:var(--cw-muted);text-align:right;line-height:1.5;max-width:105px}.storage-dot{display:inline-block;width:5px;height:5px;background:var(--cw-resolved);border-radius:50%;margin-right:4px}.error{padding:12px 16px;margin:12px 20px;border:1px solid var(--cw-danger-line);background:var(--cw-danger-soft);color:var(--cw-danger);border-radius:10px;font-size:14px;overflow-wrap:anywhere}.error button{display:block;margin-top:8px}.notice{position:fixed;left:50%;bottom:24px;transform:translateX(-50%);z-index:1;background:var(--cw-inverse);color:var(--cw-on-inverse);border:1px solid #ffffff20;border-radius:12px;padding:12px 15px;display:flex;align-items:center;gap:12px;font-size:14px;box-shadow:0 6px 30px #0002;pointer-events:auto;max-width:calc(100vw - 32px)}.notice kbd{font-size:12px;color:var(--cw-inverse-muted);border:1px solid #ffffff30;border-radius:4px;padding:2px 5px}.notice button{color:var(--cw-on-inverse)}.notice.beside-panel{left:calc(50% - 200px)}.notice.beside-panel.left{left:calc(50% + 200px)}.pins{position:fixed;inset:0;pointer-events:none}.pin{position:absolute;width:32px;height:36px;transform:translate(-50%,-100%);border:2px solid #fff;border-radius:15px 15px 15px 4px;background:var(--cw-accent);color:#fff;box-shadow:var(--cw-shadow-sm);display:grid;place-items:center;font-size:13px;font-weight:650;pointer-events:auto;transition:scale .15s}.pin:hover,.pin[aria-pressed=true]{scale:1.12}.pin.resolved{background:var(--cw-resolved)}.pin.highlight{animation:pulse 1s ease-out 2}.pin.hovered{animation:pulse 1s ease-out infinite;scale:1.12;opacity:1!important}.focus-ring.hover-ring{animation:none;border-style:dashed}.focus-ring{position:absolute;border:2px solid var(--cw-accent);border-radius:var(--cw-radius);background:color-mix(in srgb,var(--cw-accent) 6%,transparent);pointer-events:none;animation:enter .16s ease-out}.pick-ring{border-style:dashed;animation:none;transition:left .08s,top .08s,width .08s,height .08s}.pin:focus-visible{outline-offset:3px}.pin.preview{pointer-events:none;opacity:.7}.pin.movable{cursor:grab;touch-action:none}.pins.focused .pin:not([aria-pressed=true]):not(.dragging){opacity:.3;transition:opacity .15s,scale .15s}.pins.focused .pin:hover,.pins.focused .pin:focus-visible{opacity:1}.pin.dragging{cursor:grabbing;scale:1.15;pointer-events:none;box-shadow:var(--cw-shadow);transition:none;z-index:1}.detail-hint{margin:16px 20px 12px;color:var(--cw-muted);font-size:14px;line-height:1.6}.compose{padding:0 20px 20px}.compose textarea,.reply-bar textarea{scrollbar-width:none}\n.compose textarea::-webkit-scrollbar,.reply-bar textarea::-webkit-scrollbar{display:none}\n.compose textarea{width:100%;display:block;resize:vertical;min-height:120px;max-height:40vh;border:1px solid var(--cw-line);border-radius:var(--cw-radius);padding:12px;color:var(--cw-ink);background:var(--cw-canvas);font-size:16px;line-height:1.6}.compose textarea::placeholder{color:var(--cw-subtle)}.compose-bar{display:flex;align-items:center;gap:10px;justify-content:space-between;margin-top:12px}.compose-hint{font-size:11px;color:var(--cw-muted)}.thread-body{overflow:auto;overscroll-behavior:contain;flex:1;min-height:0;padding:18px 20px 4px}.message{padding:16px 0;border-bottom:1px solid var(--cw-line)}.message:first-child{padding-top:0}.message:last-child{border:0}.message-text{font-size:16px;line-height:1.7;white-space:pre-wrap;overflow-wrap:anywhere;margin:10px 0 0 37px}.thread-actions{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:12px 20px;border-top:1px solid var(--cw-line)}.resolve{display:inline-flex;align-items:center;gap:7px;white-space:nowrap;font-weight:600}.resolve svg{width:16px;height:16px;color:var(--cw-resolved)}.resolve:hover{border-color:var(--cw-resolved);background:var(--cw-resolved-soft);color:var(--cw-resolved-text)}.resolve.done svg{color:var(--cw-muted)}.resolve.done:hover{border-color:var(--cw-line-strong);background:var(--cw-canvas);color:var(--cw-ink)}.confirm-delete{display:flex;align-items:center;gap:8px}.danger-button{display:inline-flex;align-items:center;gap:6px;border:0;border-radius:var(--cw-radius-pill);background:var(--cw-danger);color:#fff;padding:10px 12px;font-size:14px;font-weight:600;white-space:nowrap}.danger-button svg{width:15px;height:15px}.detail-head{padding:12px 20px 16px;border-bottom:1px solid var(--cw-line)}.detail-bar{display:flex;align-items:center;justify-content:space-between;margin:0 -8px 12px -10px}.back-link{display:inline-flex;align-items:center;gap:6px;border:0;background:transparent;border-radius:var(--cw-radius-sm);padding:6px 10px;font-size:14px;font-weight:600;color:var(--cw-muted)}.back-link:hover{background:var(--cw-surface-soft);color:var(--cw-ink)}.back-link svg{width:16px;height:16px}.detail-title{display:flex;align-items:center;gap:10px;flex-wrap:wrap}.detail-title h2{font-size:20px;line-height:1.3;letter-spacing:-.4px;margin:0;font-weight:650}.detail-head .subtext{white-space:normal}.chip{display:inline-flex;align-items:center;gap:6px;padding:1px 9px;border-radius:999px;background:var(--cw-accent-soft);color:var(--cw-accent);font-size:12px;font-weight:600;line-height:20px}.chip svg{width:12px;height:12px}.chip.resolved{background:var(--cw-resolved-soft);color:var(--cw-resolved-text)}.thread .compose{padding-top:12px;border-top:1px solid var(--cw-line)}.thread textarea{min-height:88px}.anchor-status{margin:0 20px 12px;padding:12px;background:var(--cw-canvas);border:1px solid var(--cw-line);border-radius:10px;color:var(--cw-muted);font-size:13px;line-height:1.55}.anchor-head{display:flex;align-items:flex-start;gap:10px;margin-bottom:8px}.anchor-icon{display:grid;place-items:center;flex-shrink:0;width:28px;height:28px;border-radius:8px;background:var(--cw-warning-soft);color:var(--cw-warning)}.anchor-status.removed .anchor-icon{background:var(--cw-danger-soft);color:var(--cw-danger)}.anchor-icon svg{width:16px;height:16px}.anchor-titles{display:flex;flex-direction:column;min-width:0}.anchor-titles strong{color:var(--cw-ink);font-size:13px;font-weight:650;line-height:1.35}.anchor-target{color:var(--cw-ink-soft);overflow-wrap:anywhere}.identity-form{padding:0 20px 20px}.identity-form label{font-size:14px;font-weight:600;display:block;margin-bottom:7px}.identity-form input{width:100%;border:1px solid var(--cw-line);background:var(--cw-canvas);color:var(--cw-ink);padding:10px;border-radius:var(--cw-radius);margin-bottom:14px}.identity-form p{font-size:13px;color:var(--cw-muted);line-height:1.7;margin:0 0 14px}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}\n@keyframes enter{from{opacity:0;translate:0 5px}to{opacity:1;translate:0 0}}@keyframes slide-in{from{opacity:0;translate:var(--cw-slide,24px) 0}to{opacity:1;translate:0 0}}@keyframes pulse{0%{box-shadow:0 0 0 0 color-mix(in srgb,var(--cw-accent) 55%,transparent)}100%{box-shadow:0 0 0 16px transparent}}@keyframes spin{to{rotate:360deg}}@keyframes toast-out{to{opacity:0;translate:0 6px}}\n.toasts{position:fixed;right:24px;bottom:88px;width:320px;max-width:calc(100vw - 32px);display:flex;flex-direction:column;gap:8px;pointer-events:none}.toasts.left{right:auto;left:24px}.toasts.top{bottom:auto;top:88px;flex-direction:column-reverse}.toasts.beside-panel{right:424px;bottom:24px;max-width:calc(100vw - 448px)}.toasts.beside-panel.left{right:auto;left:424px}.toasts.beside-panel.top{top:24px;bottom:auto}.toast{display:flex;gap:10px;align-items:flex-start;background:var(--cw-inverse);color:var(--cw-on-inverse);border:1px solid #ffffff20;border-radius:var(--cw-radius-md,12px);padding:12px 14px;box-shadow:var(--cw-shadow,var(--cw-shadow));animation:enter .18s ease-out}.toast.leaving{animation:toast-out .2s ease-in forwards}.toast-icon{background:var(--cw-accent-soft,var(--cw-accent-soft));color:var(--cw-accent)}.toast-icon svg{width:15px;height:15px}.toast-body{min-width:0;flex:1}.toast-title{margin:0;font-size:14px;line-height:1.4;color:var(--cw-inverse-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.toast-title strong{color:var(--cw-on-inverse);font-weight:600}.toast-number{margin-left:6px;padding:0 6px;border-radius:5px;background:var(--cw-accent-soft,var(--cw-accent-soft));color:var(--cw-accent);font-size:12px;font-weight:650;line-height:18px;display:inline-block}.toast-text{margin:3px 0 0;font-size:14px;line-height:1.5;color:#fff;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;overflow-wrap:anywhere}\n.popover{position:fixed;left:0;top:0;z-index:1;width:320px;max-height:min(560px,calc(100vh - 24px));display:flex;flex-direction:column;background:var(--cw-surface);border:1px solid var(--cw-line);border-radius:var(--cw-radius-lg);box-shadow:var(--cw-shadow);pointer-events:auto;color:var(--cw-ink)}.popover>.detail{min-height:0}.popover .detail.entering{animation:pop .18s cubic-bezier(.2,.9,.3,1.15)}@keyframes pop{from{opacity:0;transform:translateY(6px) scale(.97)}}.popover.sheet{left:8px;right:8px;top:auto;bottom:8px;width:auto;max-height:75vh}\n.card-head .detail-bar{margin:0;padding:12px 12px 0 10px}.pop-head{position:relative;display:flex;align-items:center;gap:10px;padding:14px 10px 12px 14px}.panel .pop-head{padding:12px 14px 12px 20px}.pop-icon{display:grid;place-items:center;flex-shrink:0;width:30px;height:30px;border-radius:50%;background:var(--cw-accent-soft);color:var(--cw-accent)}.pop-icon svg{width:15px;height:15px}.pop-title{flex:1;min-width:0}.pop-title h2{margin:0;font-size:14px;font-weight:650;letter-spacing:-.2px;line-height:1.35}.pop-sub{margin:0;font-size:12px;line-height:1.5;color:var(--cw-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.pop-head .icon-button{width:28px;height:28px;color:var(--cw-muted)}.pop-head .icon-button:hover{background:var(--cw-surface-soft);color:var(--cw-ink)}.pop-head .icon-button svg{width:16px;height:16px}.pop-head .more svg{stroke-width:3.2}\n.pop-menu{position:absolute;top:46px;right:10px;z-index:2;min-width:190px;padding:4px;background:var(--cw-surface);border:1px solid var(--cw-line);border-radius:var(--cw-radius-md);box-shadow:var(--cw-shadow)}.menu-item{display:flex;align-items:center;gap:8px;width:100%;padding:7px 10px;border:0;border-radius:8px;background:transparent;font-size:13px;text-align:left;color:var(--cw-ink)}.menu-item:hover{background:var(--cw-surface-soft)}.menu-item svg{width:15px;height:15px;color:var(--cw-muted)}.menu-item.danger,.menu-item.danger svg{color:var(--cw-danger)}\n.thread .thread-body{flex:1;min-height:0;overflow:auto;overscroll-behavior:contain;padding:0 14px}.panel .thread .thread-body{padding:0 20px}.thread .message{padding:12px 0;border-top:1px solid var(--cw-line);border-bottom:0}.thread .message:first-child{padding-top:12px}.thread .note-header{gap:8px;margin:0}.thread .avatar{width:26px;height:26px;font-size:10px}.thread .name{font-size:14px}.thread .time{font-size:12px}.thread .message-text{margin:4px 0 0 34px;font-size:14px;line-height:1.55;color:var(--cw-ink-soft)}.panel .thread .message-text{font-size:15px}\n.thread-actions{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:10px 14px;border-top:1px solid var(--cw-line)}.panel .thread-actions{padding:12px 20px}.reply-bar{flex:1;min-width:0;display:flex;align-items:flex-end;gap:8px}.reply-bar textarea{flex:1;min-width:0;min-height:32px;max-height:120px;resize:none;padding:6px 10px;border:1px solid var(--cw-line-strong);border-radius:var(--cw-radius);background:var(--cw-surface);color:var(--cw-ink);font-size:13px;line-height:1.45;overflow:auto}.reply-bar textarea:focus-visible{outline:0;border-color:var(--cw-accent);box-shadow:0 0 0 3px var(--cw-accent-line)}.reply-bar textarea::placeholder{color:var(--cw-subtle)}.thread-actions .primary{padding:7px 12px;font-size:13px;border-radius:var(--cw-radius-pill);white-space:nowrap}.thread-actions .primary svg{width:14px;height:14px}.thread-actions .primary.resolve,.thread-actions .primary.resolve:hover{border:0;background:var(--cw-accent);color:#fff}.thread-actions .primary.resolve:hover{filter:brightness(.94)}.thread-actions .primary.resolve svg{color:currentColor}.thread-actions .status{display:inline-flex;align-items:center;gap:5px;font-size:13px;font-weight:600;color:var(--cw-resolved-text)}.thread-actions .status svg{width:14px;height:14px}.thread-actions .reopen{padding:6px 12px;font-size:13px;font-weight:500}\n.popover .anchor-status,.popover .error{margin:0 14px 10px}.new-comment .compose{margin:0 14px;padding:14px 0;border-top:1px solid var(--cw-line)}.panel .new-comment .compose{margin:0 20px;padding:16px 0 20px}.popover .compose textarea:focus-visible{outline:0;border-color:var(--cw-accent);box-shadow:0 0 0 3px var(--cw-accent-line)}.popover .new-comment .compose textarea{min-height:76px;font-size:14px}.popover .compose-hint{font-size:11px}\n.pin.below{transform:translate(-50%,0);border-radius:4px 15px 15px 15px}\n.pick-ring{border-style:solid;background:transparent}.head-actions{display:flex;align-items:center;gap:2px;margin-right:-6px}\n.head-actions>.icon-button{color:var(--cw-muted)}\n.head-actions>.icon-button:hover{color:var(--cw-ink)}\n.menu-wrap{position:relative;display:flex}\n.user-button{display:grid;place-items:center;width:36px;height:36px;padding:0;border:0;border-radius:50%;background:transparent}\n.user-button .avatar{width:28px;height:28px;font-size:11px;box-shadow:0 0 0 2px var(--cw-surface),0 0 0 3px var(--cw-line)}\n.user-button:hover .avatar,.user-button[aria-expanded=true] .avatar{box-shadow:0 0 0 2px var(--cw-surface),0 0 0 3px var(--cw-accent)}\n.quiet.sign-in{display:inline-flex;align-items:center;gap:6px;padding:6px 10px;font-size:13px;font-weight:600;margin-right:2px}\n.quiet.sign-in svg{width:14px;height:14px}\n.user-menu{top:calc(100% + 8px);right:-40px;min-width:256px;padding:6px}\n.menu-user{display:flex;align-items:center;gap:10px;padding:8px 8px 10px;margin-bottom:4px;border-bottom:1px solid var(--cw-line)}\n.menu-user .avatar{width:34px;height:34px;font-size:13px}\n.menu-user-text{min-width:0}\n.menu-user-text strong{display:block;font-size:14px;font-weight:650;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n.menu-user-text small{display:block;font-size:12px;color:var(--cw-muted)}\n.menu-note{display:flex;align-items:center;gap:2px;margin:4px 0 0;padding:8px 10px 4px;border-top:1px solid var(--cw-line);font-size:12px;color:var(--cw-muted)}\n.footer{justify-content:space-between}\n.footer-note{font-size:13px;color:var(--cw-muted)}\n.settings-body{flex:1;min-height:0;overflow:auto;overscroll-behavior:contain;padding:4px 20px 12px}\n.setting-group{padding:14px 0 6px}\n.setting-group+.setting-group{border-top:1px solid var(--cw-line)}\n.setting-group h3{margin:0 0 6px;font-size:12px;font-weight:650;letter-spacing:1.1px;text-transform:uppercase;color:var(--cw-muted)}\n.setting{display:flex;align-items:center;justify-content:space-between;gap:14px;padding:9px 0}\n.setting-text{min-width:0}\n.setting-text strong{display:block;font-size:14px;font-weight:600}\n.setting-text small{display:block;font-size:12px;line-height:1.5;color:var(--cw-muted)}\n.segmented{display:inline-flex;flex-shrink:0;gap:2px;padding:3px;background:var(--cw-surface-soft);border-radius:var(--cw-radius-pill)}\n.segment{border:0;background:transparent;border-radius:var(--cw-radius-pill);padding:5px 10px;font-size:13px;font-weight:600;color:var(--cw-muted);white-space:nowrap}\n.segment:hover{color:var(--cw-ink)}\n.segment[aria-pressed=true]{background:var(--cw-surface);color:var(--cw-ink);box-shadow:0 1px 3px #2024371f}\n.switch{position:relative;flex-shrink:0;width:38px;height:22px;padding:0;border:0;border-radius:999px;background:var(--cw-line-strong);transition:background .16s}\n.switch::after{content:"";position:absolute;top:3px;left:3px;width:16px;height:16px;border-radius:50%;background:#fff;box-shadow:0 1px 3px #20243733;transition:translate .16s}\n.switch[aria-checked=true]{background:var(--cw-accent)}\n.switch[aria-checked=true]::after{translate:16px 0}\n.switch:disabled{opacity:.45;cursor:not-allowed}\n.swatches{display:flex;justify-content:space-between;gap:6px;width:100%}\n.setting.wide{flex-direction:column;align-items:stretch;gap:10px}\n.swatch{width:22px;height:22px;padding:0;border:0;border-radius:50%;background:var(--swatch);box-shadow:inset 0 0 0 1px var(--cw-line-strong)}\n.swatch[aria-pressed=true]{box-shadow:0 0 0 2px var(--cw-surface),0 0 0 4px var(--swatch)}\n.swatch:hover{scale:1.1}\n.pin-sample{display:flex;align-items:flex-end;gap:14px;height:62px;margin:2px 0 6px;padding:0 16px 12px;border:1px dashed var(--cw-line-strong);border-radius:var(--cw-radius-md);background:var(--cw-canvas)}\n.pin-sample .pin{position:static;transform:none;pointer-events:none}\n.pin-sample.small .pin{width:26px;height:30px;border-radius:13px 13px 13px 4px;font-size:11px}\n.pin-sample.resolved-gray .pin.resolved{background:var(--cw-subtle)}\n.launcher.colored,.launcher.colored[aria-expanded=true]{background:var(--cw-launcher)}.launcher.colored .badge,.launcher-mini.colored .badge{background:var(--cw-inverse)}\n.launcher-sample{display:flex;align-items:center;gap:14px;height:72px;margin:2px 0 6px;padding:0 16px;border:1px dashed var(--cw-line-strong);border-radius:var(--cw-radius-md);background:var(--cw-canvas)}\n.launcher-mini{position:relative;display:grid;place-items:center;width:42px;height:42px;border:1px solid #ffffff24;border-radius:50%;background:var(--cw-inverse);color:var(--cw-on-inverse);box-shadow:0 6px 24px #12172233}.launcher-mini.colored{background:var(--cw-launcher)}\n.launcher-mini>svg{width:19px;height:19px}\n.pin-sample-text{margin-left:auto;font-size:12px;color:var(--cw-muted)}\n.settings-foot{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:12px 20px;border-top:1px solid var(--cw-line);background:var(--cw-canvas);font-size:12px;color:var(--cw-muted)}\n.settings-foot .quiet{padding:7px 11px;font-size:13px}\n.pins.small .pin{width:26px;height:30px;border-radius:13px 13px 13px 4px;font-size:11px}\n.pins.resolved-gray .pin.resolved{background:var(--cw-subtle)}\n.pins.small .pin.below{border-radius:4px 13px 13px 13px}\n.note{display:grid;grid-template-columns:minmax(0,1fr) auto;column-gap:12px;align-items:start}\n.note-main{min-width:0}\n.note .time{margin-left:0}\n.note-meta{flex-direction:column;align-items:flex-end;gap:2px;margin:2px 0 0;min-width:64px;line-height:18px}\n.note-number,.count{font-variant-numeric:tabular-nums}\n.count{min-width:20px;text-align:center}\n.hidden-flag{display:inline-flex;align-items:center;gap:4px;max-width:100%;padding:1px 7px 1px 6px;border-radius:6px;background:var(--cw-warning-soft);color:var(--cw-warning);font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.hidden-flag.removed{background:var(--cw-danger-soft);color:var(--cw-danger)}.note-footer .hidden-flag svg{width:12px;height:12px;flex-shrink:0}\n.pin.detached{border-style:dashed;opacity:.85;background:color-mix(in srgb,var(--cw-accent) 70%,var(--cw-subtle))}\n.anchor-status p{margin:0}\n.page-path.sub{font-size:11px;color:var(--cw-subtle);flex-shrink:1}\n.anchor-status .quiet{display:inline-flex;align-items:center;gap:6px;margin-top:10px;padding:6px 11px 6px 9px;font-size:13px;font-weight:600}.anchor-status .quiet svg{width:15px;height:15px;flex-shrink:0}\n@media(max-width:600px){.panel,.panel.left{inset:0;width:auto;border:0}.panel.placing{visibility:hidden}.panel.behind{visibility:hidden}.launcher{right:16px;bottom:16px}.notice,.notice.beside-panel,.notice.beside-panel.left{left:50%;bottom:24px;width:calc(100vw - 32px);font-size:13px}.compose-hint{display:none}.compose-bar{justify-content:flex-end}.toasts,.toasts.left,.toasts.beside-panel,.toasts.beside-panel.left{left:16px;right:16px;width:auto;max-width:none;bottom:82px}.toasts.top,.toasts.beside-panel.top{top:82px;bottom:auto}.toasts.beside-panel{display:none}.head{padding-top:18px}}\n.popover.moving{visibility:hidden;pointer-events:none}\n.update-bar{display:grid;grid-template-columns:30px 1fr auto;align-items:start;gap:4px 12px;padding:14px 12px 16px 20px;background:var(--cw-accent-soft);border-top-color:var(--cw-accent-line)}.update-icon{display:grid;place-items:center;width:30px;height:30px;border-radius:9px;background:var(--cw-surface);color:var(--cw-accent);box-shadow:var(--cw-shadow-sm)}.update-icon svg{width:16px;height:16px}.update-text{display:flex;flex-direction:column;gap:1px;min-width:0;color:var(--cw-muted);font-size:12.5px;line-height:1.45}.update-text strong{color:var(--cw-ink);font-size:13px;font-weight:650}.update-command{grid-column:1/-1;display:flex;align-items:center;gap:8px;margin:8px 8px 0 0;padding:4px 4px 4px 10px;border:1px solid var(--cw-line);border-radius:9px;background:var(--cw-surface)}.update-command code{flex:1;min-width:0;color:var(--cw-ink);font:12px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.update-bar .quiet.update{padding:5px 12px;border-radius:var(--cw-radius-pill)}\n@media(max-width:600px){.search input{font-size:16px}.select{max-width:100%}}\n@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation:none!important;transition:none!important;scroll-behavior:auto!important}}\n`;function U(e){if(!e||!e.isConnected||!e.getClientRects().length)return!1;const t=e.getBoundingClientRect();if(t.width<1||t.height<1||"visible"!==getComputedStyle(e).visibility||e.closest("[inert]"))return!1;const i=e.checkVisibility;if(i&&!i.call(e,{opacityProperty:!0,visibilityProperty:!0}))return!1;let n=!1;for(let s=e;s&&s!==document.documentElement;s=s.parentElement){const o=getComputedStyle(s);if(!i&&parseFloat(o.opacity)<.05)return!1;if("fixed"===o.position&&(n=!0),s===e||s===document.body)continue;const r=/(hidden|clip)/.test(o.overflowX+o.overflowY),a=/(auto|scroll)/.test(o.overflowX+o.overflowY)&&(s.clientWidth<1||s.clientHeight<1);if(r||a){const e=s.getBoundingClientRect();if(Math.min(t.right,e.right)-Math.max(t.left,e.left)<1||Math.min(t.bottom,e.bottom)-Math.max(t.top,e.top)<1)return!1}}return!(n&&(t.right<=0||t.bottom<=0||t.left>=innerWidth||t.top>=innerHeight))}const N=(e,t=120)=>(e??"").replace(/\s+/g," ").trim().slice(0,t),D=/:|(^|[-_])(r\d+|radix|headlessui|mui|v-\d|react-aria|\d{3,})/i,F="ul,ol,[role=menu],[role=listbox],[popover],dialog,nav";function j(e){var t,i;const n=e.getAttribute("aria-labelledby");return N(e.getAttribute("aria-label"))||N(null==n?void 0:n.split(/\s+/).map(e=>{var t;return(null==(t=document.getElementById(e))?void 0:t.textContent)??""}).join(" "))||N(e.getAttribute("title"))||function(e){var t;let i="";for(const n of Array.from(e.childNodes))n.nodeType===Node.TEXT_NODE?i+=n.textContent:n instanceof Element&&!n.matches(F)&&!n.querySelector(`${F},a,button`)&&(i+=` ${n.textContent}`);return N(i)||N(null==(t=e.firstElementChild)?void 0:t.textContent)}(e)||N(null==(t=e.querySelector("img[alt]"))?void 0:t.getAttribute("alt"))||N(null==(i=e.querySelector("svg title"))?void 0:i.textContent)}const K=(e,t)=>e.toLowerCase()===t.toLowerCase(),H={BUTTON:"button",SUMMARY:"button",A:"link",LABEL:"label",INPUT:"input"};function B(e){const t=[];for(let i=e;i&&i!==document.body&&i!==document.documentElement;i=i.parentElement){for(const s of["data-overplay-anchor","data-testid","data-test","data-cy"]){const e=i.getAttribute(s),n=e&&`[${s}="${CSS.escape(e)}"]`;if(n&&1===document.querySelectorAll(n).length)return t.unshift(n),t.join(" > ")}if(i.id&&!D.test(i.id)&&1===document.querySelectorAll(`#${CSS.escape(i.id)}`).length)return t.unshift(`#${CSS.escape(i.id)}`),t.join(" > ");const e=i.tagName,n=i.parentElement?Array.from(i.parentElement.children).filter(t=>t.tagName===e):[i];t.unshift(`${e.toLowerCase()}:nth-of-type(${n.indexOf(i)+1})`)}return t.join(" > ")}function Y(e){const t=j(e);return{selector:B(e),role:e.getAttribute("role")||H[e.tagName]||e.tagName.toLowerCase(),tag:e.tagName.toLowerCase(),...t?{name:t}:{}}}function W(e){const t=[],i=(()=>{try{return document.querySelector(e.selector)}catch{return null}})();if(!i||e.name&&!K(j(i),e.name)||t.push(i),e.name){const i=[e.tag,e.role&&/^[a-z]+$/.test(e.role)?`[role="${e.role}"]`:""].filter(Boolean).join(",");try{t.push(...Array.from(document.querySelectorAll(i||"*")).filter(t=>K(j(t),e.name)))}catch{}}return!t.length&&i&&t.push(i),t.find(U)??t[0]??null}const X=/\b(delete|remove|erase|destroy|pay|buy|purchase|checkout|order|send|submit|publish|confirm|sign ?out|log ?out|unsubscribe|cancel subscription|deactivate)\b/i,V=e=>(e=>e.matches('a[href]:not([href^="#"]):not([href=""]),[type=submit],form button:not([type])')&&!e.matches("[aria-haspopup],[aria-expanded]"))(e)||!e.matches("[aria-haspopup],[aria-expanded],[aria-controls],summary,[popovertarget],[data-bs-toggle]")&&X.test(j(e)),G=["Enter"," ","ArrowDown","ArrowRight"],J=/^(display|visibility|opacity|transform|translate|max-height|height|clip|clip-path|left|top|right|bottom|inset|pointer-events)$/;function _(e){const t=e.closest('button,summary,label,[role=button],[role=tab],[role=menuitem],[aria-haspopup],[aria-expanded],[aria-controls],[popovertarget],[data-bs-toggle],a[href^="#"],input[type=checkbox],input[type=radio]');if(t)return t;let i=e;for(let n=e;n&&n!==document.body;n=n.parentElement)if("pointer"===getComputedStyle(n).cursor)i=n;else if(i!==e)break;return i}class Z{constructor(e,t=()=>!1){i(this,"actions",[]),i(this,"open",new Set),i(this,"lastHover",null),i(this,"observer",null),i(this,"onPress",e=>{if(!e.isTrusted||e instanceof KeyboardEvent&&!G.includes(e.key))return;const t=this.target(e);if(!t)return;if(this.paused())return void this.open.clear();const i=this.lastAction("press");i&&(i.el===t||i.el.control===t)&&performance.now()-i.time<500?this.keep(i):this.track("press",t)}),i(this,"onHover",e=>{if(!e.isTrusted)return;const t=this.target(e);t&&t!==this.lastHover&&(this.lastHover=t,this.actions=this.actions.filter(e=>"press"===e.kind||this.open.has(e)||e.changed.size),this.track("hover",t))}),i(this,"onState",e=>{e.target instanceof Element&&this.note(e.target,!1)}),i(this,"onMutations",e=>{if(this.open.size)for(const t of e){if("attributes"===t.type&&"style"===t.attributeName&&(t.target===document.body||t.target===document.documentElement))continue;const e="childList"===t.type?Array.from(t.addedNodes):[t.target];for(const i of e)i instanceof Element&&this.note(i,"childList"===t.type)}}),this.ignore=e,this.paused=t}start(e){const t={capture:!0,signal:e};for(const i of["pointerdown","mousedown","click","keydown"])document.addEventListener(i,this.onPress,t);document.addEventListener("mouseover",this.onHover,t),document.addEventListener("toggle",this.onState,t),document.addEventListener("change",this.onState,t),window.addEventListener("hashchange",()=>{const e=decodeURIComponent(location.hash.slice(1)),t=e&&document.getElementById(e);t&&this.note(t,!1)},{signal:e}),this.observer=new MutationObserver(this.onMutations),this.observer.observe(document,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["class","style","hidden","open","aria-expanded","aria-hidden","data-state","data-open","data-headlessui-state"]}),e.addEventListener("abort",()=>{var e;null==(e=this.observer)||e.disconnect(),this.actions=[],this.open.clear()})}track(e,t){const i={kind:e,el:t,time:performance.now(),changed:new Set,added:new Set};this.actions.push(i),this.keep(i),this.actions.length>40&&this.actions.shift()}keep(e){this.open.add(e),setTimeout(()=>this.open.delete(e),700)}target(e){const t=e.composedPath().find(e=>e instanceof Element);return t&&!this.ignore(t)?t:null}note(e,t){if(this.ignore(e))return;let i;for(const n of this.actions)this.open.has(n)&&(i=n);i&&(i.changed.add(e),t&&i.added.add(e))}lastAction(e){for(let t=this.actions.length-1;t>=0;t--)if(this.actions[t].kind===e)return this.actions[t]}capture(e){const t=performance.now(),i=[],n=[],s=new Set;let o=e;for(let a=this.actions.length-1;a>=0&&i.length<6;a--){const e=this.actions[a];if(t-e.time>12e4||s.has(e)||!e.el.isConnected||o.contains(e.el))continue;const r="press"===e.kind?_(e.el):e.el;if(!(r.contains(o)&&!r.matches("label")||V(r))&&this.opened(e,r,o)&&(("hover"!==e.kind||Array.from(e.added).some(e=>e.isConnected&&e.contains(o))||!this.actions.some(t=>"press"===t.kind&&t.time<=e.time&&e.time-t.time<800&&this.changedFor(t,o)))&&("hover"!==e.kind||n[0]!==r)&&(i.unshift({action:e.kind,target:Y(r)}),n.unshift(r),s.add(e),o=r,this.onPage(r))))break}const r=function(e){const t=[],i=e=>{for(const n of Array.from(e))n instanceof CSSStyleRule?/:(hover|focus-within)\b/.test(n.selectorText)&&Array.from(n.style).some(e=>J.test(e))&&t.push(n):"cssRules"in n&&i(n.cssRules)};for(const s of Array.from(document.styleSheets))try{i(s.cssRules)}catch{}if(!t.length)return[];const n=[];for(const s of["hover","focus-within"])for(const i of Array.from(document.querySelectorAll(`:${s}`))){if(i===document.documentElement||i===document.body||e.contains(i))continue;t.some(t=>t.selectorText.split(",").some(t=>{const n=t.indexOf(`:${s}`);if(n<0||!/^\s*[\s>~+]/.test(t.slice(n+s.length+1))||!t.slice(n+s.length+1).trim())return!1;try{return i.matches(t.slice(0,n).trim()||"*")&&Array.from(document.querySelectorAll(t.split(`:${s}`).join(""))).some(t=>t!==i&&(i.contains(t)||t.parentElement===i.parentElement)&&t.contains(e))}catch{return!1}}))&&n.push({action:"hover"===s?"hover":"focus",el:i})}return n.sort((e,t)=>e.el.contains(t.el)?-1:t.el.contains(e.el)?1:0)}(e).filter(e=>!n.includes(e.el)).map(e=>({action:e.action,target:Y(e.el)}));return[...r,...i].slice(0,6)}changedFor(e,t){for(const i of e.changed)if(i.isConnected){if(i===t||i.contains(t))return!0;if(i instanceof HTMLInputElement&&/^(checkbox|radio)$/.test(i.type))for(let e=i.nextElementSibling;e;e=e.nextElementSibling)if(e.contains(t))return!0}return!1}opened(e,t,i){var n,s,o;if(this.changedFor(e,i))return!0;if("press"!==e.kind)return!1;const r=t instanceof HTMLLabelElement?t.control:null,a=t.getAttribute("popovertarget"),l=t.matches('a[href^="#"]')?t.getAttribute("href"):"";return!(!a||!(null==(n=document.getElementById(a))?void 0:n.contains(i)))||!!(l.length>1&&location.hash===l&&(null==(s=document.getElementById(l.slice(1)))?void 0:s.contains(i)))||!!(r instanceof HTMLInputElement&&r.checked)||t.matches("summary")&&!!(null==(o=t.parentElement)?void 0:o.open)&&t.parentElement.contains(i)}onPage(e){var t;return!(null==(t=e.parentElement)?void 0:t.closest("[role=menu],[role=dialog],[role=listbox],[popover],dialog"))&&!this.actions.some(t=>t.el!==e&&!t.el.contains(e)&&Array.from(t.changed).some(t=>t.isConnected&&t!==document.body&&t!==document.documentElement&&t.contains(e)))}}const Q=()=>new Promise(e=>requestAnimationFrame(()=>e()));async function ee(e,t){const i=performance.now()+t;for(;performance.now()<i;){if(e())return!0;await Q()}return e()}function te(e,t){const i=e.getBoundingClientRect(),n={bubbles:!0,cancelable:!0,composed:!0,view:window,button:0,buttons:t.endsWith("down")?1:0,clientX:i.left+i.width/2,clientY:i.top+i.height/2};e.dispatchEvent(t.startsWith("pointer")?new PointerEvent(t,{...n,pointerId:1,pointerType:"mouse",isPrimary:!0}):new MouseEvent(t,n))}function ie(e){var t,i;for(const n of["pointerover","pointerenter","mouseover","mouseenter","pointermove","mousemove","pointerdown","mousedown"])te(e,n);null==(t=e.focus)||t.call(e,{preventScroll:!0});for(const n of["pointerup","mouseup"])te(e,n);null==(i=e.click)||i.call(e)}function ne(e,t){var i;null==(i=e.focus)||i.call(e,{preventScroll:!0});for(const n of["keydown","keyup"])e.dispatchEvent(new KeyboardEvent(n,{key:t,code:" "===t?"Space":t,bubbles:!0,cancelable:!0,composed:!0}))}const se=e=>{var t;return e.matches("[aria-expanded=true],[data-state=open],[role=tab][aria-selected=true]")||e.matches("summary")&&!!(null==(t=e.parentElement)?void 0:t.open)||e instanceof HTMLInputElement&&e.checked};const oe=new class{constructor(){i(this,"sheet",null),i(this,"marked",[])}set(e,t){const i=`data-overplay-${t}`,n="hover"===t?/:hover\b/g:/:focus-within\b/g;if(!this.sheet)try{this.sheet=new CSSStyleSheet,document.adoptedStyleSheets=[...document.adoptedStyleSheets,this.sheet]}catch{return}const s=(e,t)=>{for(const o of Array.from(e))if(o instanceof CSSStyleRule&&o.selectorText.match(n))try{this.sheet.insertRule(t(`${o.selectorText.replace(n,`[${i}]`)}{${o.style.cssText}}`),this.sheet.cssRules.length)}catch{}else o instanceof CSSMediaRule&&s(o.cssRules,e=>t(`@media ${o.media.mediaText}{${e}}`))};if(!this.marked.some(([,e])=>e===i))for(const o of Array.from(document.styleSheets))try{s(o.cssRules,e=>e)}catch{}e.setAttribute(i,""),this.marked.push([e,i])}clear(){for(const[e,t]of this.marked)e.removeAttribute(t);this.marked=[],this.sheet&&(document.adoptedStyleSheets=document.adoptedStyleSheets.filter(e=>e!==this.sheet),this.sheet=null)}};function re(){oe.clear()}const ae=new Set(["IMG","svg","VIDEO","CANVAS","IFRAME","PICTURE","INPUT","SELECT","TEXTAREA","BUTTON"]);function le(e,t){var i;const n=e=>e!==document.body&&e!==document.documentElement&&(!t||t.contains(e))&&!e.closest("[data-overplay]");if(e.closest("[data-overplay]"))return null;const s=e.closest("[data-overplay-anchor]"),o=null==s?void 0:s.getAttribute("data-overplay-anchor"),r=s&&o&&n(s)&&he(`[data-overplay-anchor="${CSS.escape(o)}"]`,t)===s?s:null;let a=e;if(a instanceof SVGElement)for(let c=a.closest("svg");c;c=(null==(i=c.parentElement)?void 0:i.closest("svg"))??null)a=c;const l=a.closest("a[href],button,label,summary,select,textarea,input,[role=button],[role=link],[role=tab],[role=menuitem],[role=checkbox],[role=switch],[role=option]");if(l&&n(l))a=l;else for(;!ae.has(a.tagName)&&a.parentElement&&n(a.parentElement)&&/^(inline|contents)$/.test(getComputedStyle(a).display);)a=a.parentElement;return r&&(a===r||!r.contains(a)||!n(a)||(e=>{const t=e.getBoundingClientRect();return t.width*t.height})(r)<=innerWidth*innerHeight/4)?r:n(a)?a:t||(document.body.getClientRects().length&&document.body.getBoundingClientRect().height?document.body:document.documentElement)}const ce=/^(radix-|headlessui-|react-aria\d*-|mui-\d|ember\d|_r_)|[:«»]|^[a-f0-9]{8}-[a-f0-9]{4}-/i,de=e=>ce.test(e);function he(e,t){try{const i=Array.from(document.querySelectorAll(e)).filter(e=>!t||t.contains(e));if(1===i.length)return i[0];const n=i.filter(e=>{const t=e.getBoundingClientRect();return e.getClientRects().length&&t.width&&t.height&&"visible"===getComputedStyle(e).visibility});return 1===n.length?n[0]:null}catch{return null}}function pe(e,t){if(!e.selector)return"shown";let i=!1;try{i=Array.from(document.querySelectorAll(e.selector)).some(e=>!t||t.contains(e))}catch{}return i?U(he(e.selector,t))?"shown":"hidden":"removed"}const ue=[["input[type=checkbox],[role=checkbox]","Checkbox"],["input[type=radio],[role=radio]","Option"],["[role=switch]","Switch"],["button,input[type=button],input[type=submit],[role=button]","Button"],["a[href],[role=link]","Link"],["[role=tab]","Tab"],["[role=menuitem]","Menu item"],["[role=option],option","Option"],["select","Menu"],["input,textarea","Field"],["img,picture,[role=img]","Image"],["svg","Icon"],["video","Video"],["canvas","Canvas"],["iframe","Frame"],["h1,h2,h3,h4,h5,h6,[role=heading]","Heading"],["label","Label"],["li","List item"],["tr","Row"],["td,th","Cell"],["table","Table"],["nav","Navigation"],["form","Form"],["p","Text"],["summary","Button"]],me=(e,t=48)=>{const i=(e??"").replace(/\s+/g," ").trim();return i.length>t?`${i.slice(0,t-1).trimEnd()}…`:i},ge=e=>me(null==e?void 0:e.split(/\s+/).map(e=>{var t;return(null==(t=document.getElementById(e))?void 0:t.textContent)??""}).join(" "));function fe(e){var t,i;const n=e,s=e.id?document.querySelector(`label[for="${CSS.escape(e.id)}"]`):null;return me(e.getAttribute("aria-label"))||ge(e.getAttribute("aria-labelledby"))||me(e.getAttribute("alt"))||me(null==s?void 0:s.textContent)||me(null==(t=e.closest("label"))?void 0:t.textContent)||me(n.placeholder)||me(e.getAttribute("title"))||me(null==(i=e.querySelector("title"))?void 0:i.textContent)||me(e.innerText??e.textContent)}const ve=e=>me(e.replace(/[-_:./]+/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase()));function xe(e){var t,i,n;const s=e.getAttribute("data-overplay-anchor"),o=s?ve(s):(null==(t=ue.find(([t])=>e.matches(t)))?void 0:t[1])??(e===document.body||e===document.documentElement?"Page":"Element"),r=s||e===document.body||e===document.documentElement?"":fe(e),a={label:r&&r!==o?`${o} “${r}”`:o};for(let l=e.parentElement;l&&l!==document.body;l=l.parentElement){const e=l.id?CSS.escape(l.id):"",t=e?document.querySelector(`[aria-controls~="${e}"]`):null,s=t?fe(t):l instanceof HTMLDetailsElement?me(null==(i=l.querySelector("summary"))?void 0:i.textContent):l instanceof HTMLFieldSetElement?me(null==(n=l.querySelector("legend"))?void 0:n.textContent):l.hasAttribute("data-overplay-anchor")?ve(l.getAttribute("data-overplay-anchor")):l.matches("[role=dialog],[role=menu],[role=listbox],[role=tabpanel],dialog,nav,section,aside,form,[popover]")?me(l.getAttribute("aria-label"))||ge(l.getAttribute("aria-labelledby")):"";if(s&&s!==r){a.place=s;break}}return a}const we=Object.freeze({status:"open",query:"",mine:!1,author:""});function be(e){return e.normalize("NFKD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function ye(e){let t="";const i=[];for(let n=0;n<e.length;){const s=e.codePointAt(n),o=String.fromCodePoint(s),r=be(o);for(let e=0;e<r.length;e++)i.push(n);t+=r,n+=o.length}return i.push(e.length),{folded:t,map:i}}function ke(e){const t=ye(e.slice(0,200)).folded.split(/\s+/).filter(Boolean);return[...new Set(t)].slice(0,8)}const Ce=(e,t)=>{const i=ye(e).folded;return t.filter(e=>i.includes(e))};function Se(e,t){if(!t.length||!e)return[];const{folded:i,map:n}=ye(e),s=[];for(const r of t)for(let t=i.indexOf(r);-1!==t;t=i.indexOf(r,t+r.length)){const i=n[t],o=n[t+r.length-1],a=n.slice(t+r.length).find(e=>e>o)??e.length;s.push([i,a])}s.sort((e,t)=>e[0]-t[0]||e[1]-t[1]);const o=[];for(const r of s){const e=o[o.length-1];e&&r[0]<=e[1]?e[1]=Math.max(e[1],r[1]):o.push([...r])}return o}function Ee(e,t,i={}){if(!t.length)return{};const n=(s=i.elementOf?i.elementOf(e):e.element)?s.place?`${s.label} in ${s.place}`:s.label:"";var s;const o=[e.text,e.author,i.includePage?`${e.pageTitle??""} ${e.pageUrl}`:""].join("\n"),r=new Set(Ce(o,t)),a={};if(r.size<t.length)for(const l of e.replies){const e=Ce(`${l.text}\n${l.author}`,t);e.some(e=>!r.has(e))&&(a.reply??(a.reply=l),e.forEach(e=>r.add(e)))}if(r.size<t.length&&n){const e=Ce(n,t);e.some(e=>!r.has(e))&&(a.element=n,e.forEach(e=>r.add(e)))}return r.size===t.length?a:null}function Ae(e){return e.authorId?`id:${e.authorId}`:`name:${e.author.trim().toLowerCase()}`}function Ie(e,t){return!!e.authorId&&e.authorId===t}function Te(e,t){return"all"===t||("resolved"===t?e.resolved:!e.resolved)}function $e(e,t,i){const n=ke(t.query);return e.filter(e=>Te(e,t.status)&&(!t.mine||Ie(e,i.userId))&&(!t.author||Ae(e)===t.author)&&!!Ee(e,n,i))}function Le(e,t,i){const n=ke(t.query),s=e.filter(e=>!!Ee(e,n,i)),o=s.filter(e=>(!t.mine||Ie(e,i.userId))&&(!t.author||Ae(e)===t.author)),r=s.filter(e=>Te(e,t.status)),a=new Map;for(const l of e){const e=Ae(l),t=a.get(e)??{key:e,name:l.author,count:0};t.name=l.author,a.set(e,t)}for(const l of r){const e=a.get(Ae(l));e&&e.count++}return{open:o.filter(e=>!e.resolved).length,resolved:o.filter(e=>e.resolved).length,all:o.length,mine:r.filter(e=>Ie(e,i.userId)).length,authors:[...a.values()].sort((e,t)=>e.name.localeCompare(t.name)||e.key.localeCompare(t.key))}}function Pe(e){return!!e.query.trim()||e.mine||!!e.author}const Me=["light","dark","system"],Re=52,ze=12,qe="overplay:update-dismissed",Oe=(e,t,i)=>Math.max(t,Math.min(Math.max(t,i),e));function Ue(e){try{return Array.from(document.querySelectorAll(e))}catch{return[]}}function Ne(e){try{const t=new URL(e,location.href);return`${t.pathname}${t.search}${t.hash}`}catch{return e}}function De(){const e=e=>(e??"").replace(/\s+/g," ").trim(),t=e(document.title),i=Array.from(document.querySelectorAll("main h1, [role=main] h1, h1")).find(e=>!e.closest("[data-overplay]")&&e.getClientRects().length),n=e(null==i?void 0:i.textContent).slice(0,120);return((!t||t.toLowerCase()===location.hostname.toLowerCase()||!/[-–—|·:]/.test(t)&&!!n&&!t.includes(n))&&n?n:t||n).slice(0,300)||void 0}function Fe(e,t,i){let n=0;for(const[s,o]of Se(t,i.filter(e=>e.length>1)))s>n&&e.append(document.createTextNode(t.slice(n,s))),e.append(T("mark","hit",t.slice(s,o))),n=o;return e.append(document.createTextNode(t.slice(n))),e}class je{constructor(e={}){var t,n,s;if(i(this,"ready"),i(this,"config"),i(this,"storage"),i(this,"host",T("div")),i(this,"shadow"),i(this,"surface",T("div")),i(this,"pins",T("div","pins")),i(this,"pickTarget",null),i(this,"live",T("div","sr-only")),i(this,"toasts",T("div","toasts")),i(this,"toastTimers",new Set),i(this,"seen",new Set),i(this,"seenKey",""),i(this,"detailKey",""),i(this,"events",new AbortController),i(this,"resizeObserver"),i(this,"mutationObserver"),i(this,"anchorObserver"),i(this,"observedAnchors",new Set),i(this,"unsubscribe"),i(this,"routeTimer"),i(this,"frame",0),i(this,"motionFrame",0),i(this,"destroyed",!1),i(this,"visible",!1),i(this,"placing",!1),i(this,"pinDrag",null),i(this,"suppressPinClick",!1),i(this,"loading",!0),i(this,"loaded",!1),i(this,"loadFailed",!1),i(this,"saving",!1),i(this,"error",""),i(this,"comments",[]),i(this,"activeId",null),i(this,"draft",null),i(this,"text",""),i(this,"replyText",""),i(this,"replyId",m()),i(this,"filters",{...we}),i(this,"scope","page"),i(this,"filterKey"),i(this,"searchTimer"),i(this,"launcherKey"),i(this,"openKey"),i(this,"launcherSpot"),i(this,"dragging",!1),i(this,"suppressClick",!1),i(this,"highlightId",null),i(this,"hoverId",null),i(this,"highlightTimer"),i(this,"sidebarOpen",!1),i(this,"docked",!1),i(this,"dockKey"),i(this,"project"),i(this,"settingsCache",null),i(this,"update",null),i(this,"updateChecked",!1),i(this,"pushed",null),i(this,"recorder",new Z(e=>e===this.host||e.getRootNode()===this.shadow,()=>this.placing||!!this.pinDrag)),i(this,"revealed",null),i(this,"replaying",!1),i(this,"editing",null),i(this,"user"),i(this,"managedUser"),i(this,"identityKey"),i(this,"persistentGuest"),i(this,"pageId"),i(this,"loadVersion",0),i(this,"queuedSnapshot",null),i(this,"returnFocus",null),i(this,"shortcut"),i(this,"composing",!1),i(this,"renderDeferred",!1),i(this,"applyQueuedSnapshot",()=>{if(this.destroyed||!this.queuedSnapshot||this.saving||this.loading||this.typing())return;const e=this.queuedSnapshot;this.queuedSnapshot=null,this.apply(e)}),i(this,"receiveSnapshot",e=>{if(!this.destroyed)try{const t=l(e);this.saving||this.loading||this.typing()?this.queuedSnapshot=t:this.apply(t)}catch(t){this.report(t),this.render()}}),i(this,"shieldPress",e=>{if(!e.isTrusted||!e.composedPath().includes(this.host))return;e.stopImmediatePropagation();const t=e.composedPath()[0];if("touchstart"===e.type||!(t instanceof Element)||t.getRootNode()!==this.shadow)return;e.composedPath().some(e=>e instanceof Element&&e.matches("[role=menu],[aria-haspopup=menu]"))||this.closeMenus();const i=e.constructor;t.dispatchEvent(new i(e.type,Object.assign({},function(e){const t=e;return{view:window,clientX:t.clientX,clientY:t.clientY,screenX:t.screenX,screenY:t.screenY,button:t.button,buttons:t.buttons,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey,pointerId:t.pointerId,pointerType:t.pointerType,isPrimary:t.isPrimary,width:t.width,height:t.height,pressure:t.pressure}}(e),{bubbles:!0,cancelable:!0,composed:!1})))}),i(this,"onRouteChange",()=>{if(this.destroyed)return;const e=this.currentPage();e!==this.pageId&&(this.pageId=e,this.activeId=null,this.draft=null,this.placing=!1,this.text="",this.replyText="",this.noticeActivity(),this.render(),this.storage instanceof p?this.refresh():this.openPending())}),i(this,"onKeyDown",e=>{if(e.defaultPrevented||e.isComposing)return;const t="Escape"===e.key?this.closeMenus():null;if(t)return e.preventDefault(),void t.focus();if("Escape"===e.key&&this.visible)return e.preventDefault(),void(this.draft||this.placing||this.activeId||this.editing?this.closePopup():this.hide());const i=e.composedPath()[0];if(this.placing&&"Enter"===e.key&&!e.composedPath().includes(this.host)){const t=i instanceof Element&&i!==document.body?i:this.config.container??document.documentElement;if(this.config.container&&!this.config.container.contains(t)&&t!==this.config.container)return;const n=t.getBoundingClientRect(),s=Math.max(16,Math.min(innerWidth-16,n.left+n.width/2)),o=Math.max(48,Math.min(innerHeight-48,n.top+Math.min(n.height/2,innerHeight/2)));return e.preventDefault(),void this.choosePoint({x:s+scrollX,y:o+scrollY},t)}i instanceof Element&&(i.closest("input,textarea,select,[contenteditable]:not([contenteditable=false])")||i.closest("[role=textbox]"))||!e.repeat&&this.settings.shortcut&&this.shortcut&&function(e,t){if(e.altKey!==t.alt||e.ctrlKey!==t.ctrl||e.metaKey!==t.meta)return!1;if(t.shift&&!e.shiftKey)return!1;const i=/^[a-z]$/.test(t.key)?`Key${t.key.toUpperCase()}`:/^\d$/.test(t.key)?`Digit${t.key}`:"";return e.key.toLowerCase()===t.key||!!i&&e.code===i}(e,this.shortcut)&&(e.preventDefault(),this.visible?this.hide():this.show())}),i(this,"onPageClick",e=>{if(e.composedPath().includes(this.host))return;if(!this.placing){if(!e.isTrusted||this.replaying)return;const t=this.activeId?!this.replyText.trim():!!this.draft&&!this.text.trim();return void(this.visible&&t&&!this.docked&&!this.saving&&this.closePopup(!1))}if(e.ctrlKey||e.metaKey||e.altKey)return;const t=e.target;t instanceof Element&&(!this.config.container||this.config.container.contains(t))&&(e.preventDefault(),e.stopPropagation(),this.choosePoint({x:e.clientX+scrollX,y:e.clientY+scrollY},t))}),i(this,"onPointerMove",e=>{const t=this.pins.querySelector(".preview");if(!t)return;const i=e.target,n=!this.config.container||i instanceof Node&&this.config.container.contains(i);t.hidden=e.composedPath().includes(this.host)||!n,t.style.left=`${e.clientX}px`,t.style.top=`${e.clientY}px`;const s=!t.hidden&&i instanceof Element?le(i,this.config.container):null;this.pickTarget=s===document.body||s===document.documentElement?null:s,this.placePickRing()}),i(this,"trackLayoutMotion",()=>{if(this.motionFrame||!this.visible||this.destroyed)return;const e=()=>{this.motionFrame=0,this.visible&&!this.destroyed&&(this.positionPins(),document.getAnimations().some(e=>"running"===e.playState)&&(this.motionFrame=requestAnimationFrame(e)))};this.motionFrame=requestAnimationFrame(e)}),i(this,"schedulePosition",()=>{this.frame||this.destroyed||!this.visible||(this.frame=requestAnimationFrame(()=>{this.frame=0,this.positionPins()}))}),i(this,"pushPage",()=>{var e;const t=document.documentElement,i=this.sidebarOpen&&this.settings.pushContent&&innerWidth>600,n=(null==(e=this.config.position)?void 0:e.endsWith("left"))?"margin-left":"margin-right";if(i&&!this.pushed)this.pushed={property:n,value:t.style.getPropertyValue(n),priority:t.style.getPropertyPriority(n)},t.style.setProperty(n,"400px","important");else if(!i&&this.pushed){const{property:e,value:i,priority:n}=this.pushed;this.pushed=null,i?t.style.setProperty(e,i,n):t.style.removeProperty(e)}}),i(this,"placeLauncher",()=>{const e=this.shadow.querySelector(".launcher");if(!e||!this.launcherSpot)return;const t=Oe(this.launcherSpot.x*innerWidth-26,ze,innerWidth-Re-ze),i=Oe(this.launcherSpot.y*innerHeight-26,ze,innerHeight-Re-ze);Object.assign(e.style,{left:`${t}px`,top:`${i}px`,right:"auto",bottom:"auto"})}),i(this,"submitComment",()=>{if(!this.draft||!this.text.trim())return;const e=this.draft,t={id:e.id,x:e.position.x,y:e.position.y,text:this.text.trim(),author:this.user.name,authorId:this.user.id,avatarUrl:this.user.avatarUrl,timestamp:e.timestamp,replies:[],resolved:!1,pageUrl:e.pageUrl,pageTitle:De(),selector:e.selector,anchor:e.anchor,element:e.element},i=[...this.getAllComments(),t];this.mutate(i,()=>this.storage.upsertComment?this.storage.upsertComment(t):this.storage.saveComments(i),()=>{this.draft=null,this.text="",this.activeId=t.id})}),i(this,"submitReply",()=>{const e=this.comments.find(e=>e.id===this.activeId);if(!e||!this.replyText.trim())return;const t={id:this.replyId,text:this.replyText.trim(),author:this.user.name,authorId:this.user.id,avatarUrl:this.user.avatarUrl,timestamp:new Date,commentId:e.id},i={...e,replies:[...e.replies,t]},n=this.getAllComments().map(t=>t.id===e.id?i:t);this.mutate(n,()=>this.storage.addReply?this.storage.addReply(e.id,t):this.storage.upsertComment?this.storage.upsertComment(i):this.storage.saveComments(n),()=>{this.replyText="",this.replyId=m()})}),this.config={primaryColor:"#0068f9",position:"bottom-right",keyboardShortcut:"alt+shift+c",enableKeyboardShortcuts:!0,...e},!/^#[0-9a-f]{3}([0-9a-f]{3})?$/i.test(this.config.primaryColor??""))throw new Error("primaryColor must be a 3- or 6-digit hex color.");if(void 0!==this.config.theme&&!Me.includes(this.config.theme))throw new Error('theme must be "light", "dark" or "system".');if(this.shortcut=function(e){const t=e.toLowerCase().split("+").map(e=>e.trim()),i=t.pop();if(!i)return null;const n={key:i,alt:!1,shift:!1,ctrl:!1,meta:!1};for(const s of t)if("alt"===s||"option"===s)n.alt=!0;else if("shift"===s)n.shift=!0;else if("ctrl"===s||"control"===s)n.ctrl=!0;else{if("meta"!==s&&"cmd"!==s)return null;n.meta=!0}return n}(this.config.keyboardShortcut??""),this.config.enableKeyboardShortcuts&&!this.shortcut)throw new Error('keyboardShortcut must be a key such as "alt+shift+c".');const o=e.projectId||location.hostname||"default";this.identityKey=`overplay:${o}:user`,this.launcherKey=`overplay:${o}:launcher`,this.openKey=`overplay:${o}:open`,this.dockKey=`overplay:${o}:docked`,this.filterKey=`overplay:${o}:filters`,this.restoreFilters(),this.project=o;try{this.docked="1"===localStorage.getItem(this.dockKey)}catch{}this.launcherSpot=function(e){try{const t=JSON.parse(localStorage.getItem(e)||"null");return t&&Number.isFinite(t.x)&&Number.isFinite(t.y)?{x:Oe(t.x,0,1),y:Oe(t.y,0,1)}:null}catch{return null}}(this.launcherKey);const r=f(this.identityKey);if(this.user=e.user?g(e.user):r.user,this.persistentGuest=r.persistent,this.managedUser=!!e.user,e.serverUrl&&(!e.projectId||e.storage||e.user))throw new Error("Hosted mode requires projectId and manages storage and user itself.");this.storage=e.serverUrl?new p(e.serverUrl,o,()=>this.currentPage(),e=>this.hostedSession(e)):e.storage??new u(`overplay:${o}:comments`),e.serverUrl&&(this.user={id:"signed-out",name:"Sign in"},this.managedUser=!0),this.pageId=this.currentPage(),this.host.dataset.overplay="root",this.host.style.cssText="all:initial;position:fixed;inset:0;pointer-events:none;z-index:2147483646;",this.shadow=this.host.attachShadow({mode:"open"});const a=T("style");a.textContent=O,e.nonce&&(a.nonce=e.nonce),this.host.style.setProperty("--cw-accent",this.config.primaryColor),this.live.setAttribute("role","status"),this.live.setAttribute("aria-live","polite"),this.toasts.setAttribute("role","status"),this.toasts.setAttribute("aria-live","polite"),this.shadow.append(a,this.pins,this.surface,this.toasts,this.live),document.body.append(this.host);const c={signal:this.events.signal};!1!==this.config.autoReveal&&this.recorder.start(this.events.signal);for(const i of["pointerdown","mousedown","pointerup","mouseup","click","touchstart","touchend","focusin","focusout"])this.host.addEventListener(i,e=>e.stopPropagation(),c);for(const i of["pointerdown","mousedown","touchstart"])window.addEventListener(i,this.shieldPress,{...c,capture:!0});window.addEventListener("focusin",e=>{e.composedPath().includes(this.host)&&e.stopImmediatePropagation()},{...c,capture:!0}),window.addEventListener("focusout",e=>{e.relatedTarget!==this.host||e.composedPath().includes(this.host)||e.stopImmediatePropagation()},{...c,capture:!0});const d=new MutationObserver(()=>{this.host.removeAttribute("aria-hidden"),this.host.removeAttribute("inert")});d.observe(this.host,{attributes:!0,attributeFilter:["aria-hidden","inert"]}),this.events.signal.addEventListener("abort",()=>d.disconnect()),this.shadow.addEventListener("compositionstart",()=>{this.composing=!0},c),this.shadow.addEventListener("compositionend",()=>{this.composing=!1,this.renderDeferred&&(this.renderDeferred=!1,this.render())},c),this.shadow.addEventListener("focusout",()=>setTimeout(this.applyQueuedSnapshot),c),document.addEventListener("keydown",this.onKeyDown,c),document.addEventListener("click",this.onPageClick,{...c,capture:!0}),document.addEventListener("pointerdown",e=>{e.composedPath().some(e=>e instanceof Element&&e.matches("[role=menu],[aria-haspopup=menu]"))||this.closeMenus()},{...c,capture:!0}),document.addEventListener("pointermove",this.onPointerMove,{...c,passive:!0}),window.addEventListener("scroll",this.schedulePosition,{...c,capture:!0,passive:!0}),window.addEventListener("resize",this.schedulePosition,c),window.addEventListener("resize",this.placeLauncher,c),window.addEventListener("resize",this.pushPage,c),null==(t=window.visualViewport)||t.addEventListener("resize",this.schedulePosition,c),null==(n=window.visualViewport)||n.addEventListener("scroll",this.schedulePosition,c),window.addEventListener("popstate",this.onRouteChange,c),window.addEventListener("hashchange",this.onRouteChange,c),this.resizeObserver=new ResizeObserver(this.schedulePosition),this.resizeObserver.observe(e.container??document.documentElement),this.anchorObserver=new ResizeObserver(this.schedulePosition),document.addEventListener("load",this.schedulePosition,{...c,capture:!0}),null==(s=document.fonts)||s.addEventListener("loadingdone",this.schedulePosition,c),document.addEventListener("transitionrun",this.trackLayoutMotion,{...c,capture:!0}),document.addEventListener("animationstart",this.trackLayoutMotion,{...c,capture:!0}),this.mutationObserver=new MutationObserver(this.schedulePosition),this.mutationObserver.observe(e.container??document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","style","id","data-overplay-anchor","hidden","open"]}),this.routeTimer=setInterval(this.onRouteChange,500),this.render(),this.ready=this.refresh().then(()=>{if(!this.destroyed&&this.storage.subscribeToChanges)try{this.unsubscribe=this.storage.subscribeToChanges(this.receiveSnapshot)}catch(e){this.report(e),this.render()}})}settingDefaults(){return{theme:this.config.theme??"light",pinColor:"site",buttonColor:"default",resolvedPins:"green",pinSize:"regular",pinLabel:"number",pushContent:!1!==this.config.pushContent,notifications:!1!==this.config.showNotifications,shortcut:!!this.config.enableKeyboardShortcuts&&!!this.shortcut}}settingsKey(){return`overplay:${this.project}:settings:${this.user.id}`}get settings(){var e;const t=this.settingsKey();return(null==(e=this.settingsCache)?void 0:e.key)!==t&&(this.settingsCache={key:t,value:E(t,this.settingDefaults())}),this.settingsCache.value}setSetting(e,t){const i=this.settingsKey(),n={...this.settings,[e]:t};this.settingsCache={key:i,value:n},A(i,n,this.settingDefaults())||this.announce("Browser storage is unavailable. This choice lasts for this page view."),this.render()}setTheme(e){if(!Me.includes(e))throw new Error('theme must be "light", "dark" or "system".');this.destroyed||this.config.theme===e||(this.config.theme=e,this.settingsCache=null,this.render())}resetSettings(){const e=this.settingsKey(),t=this.settingDefaults();A(e,t,t),this.settingsCache={key:e,value:t},this.docked=!1;try{localStorage.removeItem(this.dockKey)}catch{}this.render(),this.announce("Settings reset to the site defaults.")}currentPage(){var e,t,i;return(null==(t=(e=this.config).getPageId)?void 0:t.call(e))??`${(i=location).pathname}${d(i.search)}${/^#!?\//.test(i.hash)?i.hash:""}`}onCurrentPage(e){const t=this.currentPage();return this.config.getPageId?e===t:function(e,t){return e===t||e.replace(/#(?!!?\/).*$/,"")===t}(e,t)}typing(){const e=this.shadow.activeElement;return this.composing||e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement}announce(e){this.live.textContent=e}report(e){var t,i;const n=e instanceof Error?e:new Error("Could not save your changes.");this.error=n.message,this.announce(n.message);try{null==(i=(t=this.config).onError)||i.call(t,n)}catch{}}changed(){var e,t;try{null==(t=(e=this.config).onChange)||t.call(e,this.getAllComments())}catch{}this.host.dispatchEvent(new CustomEvent("comments-changed",{detail:this.getAllComments(),bubbles:!0,composed:!0}))}apply(e){w(e,this.comments)||(this.comments=e,this.changed(),this.noticeActivity(),this.render())}noticeActivity(){const e=`${this.user.id}\n${this.currentPage()}`;if(e!==this.seenKey)return this.seenKey=e,this.seen.clear(),void x(this.comments,this.seen,this.user.id);if(!this.settings.notifications)return void x(this.comments,this.seen,this.user.id);const t=x(this.pageComments(),this.seen,this.user.id);if(x(this.comments,this.seen,this.user.id),t.length>3)this.toast({kind:"comment",commentId:"",author:`${t.length} new comments`,text:"Open the comments panel to read them."},!0);else for(const i of t)this.toast(i)}toast(e,t=!1){var i;const n=T("div","toast"),s=T("div","toast-body"),o=T("p","toast-title");if(o.append(T("strong","",e.author)),!t){o.append(document.createTextNode("reply"===e.kind?" replied":" commented"));const t=this.pageComments().findIndex(t=>t.id===e.commentId)+1;t&&o.append(T("span","toast-number",`#${t}`))}if(s.append(o,T("p","toast-text",e.text)),t){const e=T("span","avatar toast-icon");e.append(L("comment")),n.append(e)}else n.append(M(e.author,e.avatarUrl));for(n.append(s);this.toasts.childElementCount>=3;)null==(i=this.toasts.firstElementChild)||i.remove();this.toasts.append(n);const r=(e,t)=>{const i=setTimeout(()=>{this.toastTimers.delete(i),t()},e);this.toastTimers.add(i)};r(7e3,()=>{n.classList.add("leaving"),r(this.reducedMotion()?0:200,()=>n.remove())})}async refresh(){if(this.destroyed||this.saving)return;const e=++this.loadVersion;this.loading=!0,this.render();try{const t=l(await this.storage.loadComments());if(this.destroyed||e!==this.loadVersion)return;const i=this.queuedSnapshot??t,n=!this.loaded||!w(i,this.comments);this.comments=i,this.queuedSnapshot=null,this.loadFailed=!1,this.error="",this.loaded=!0,n&&(this.changed(),this.noticeActivity())}catch(t){if(this.destroyed||e!==this.loadVersion)return;this.loadFailed=!0,this.report(t)}finally{this.destroyed||e!==this.loadVersion||(this.loading=!1,this.render(),this.loaded&&this.openPending())}}getAllComments(){return c(this.comments)}getUser(){return{...this.user}}hostedSession(e){this.destroyed||(this.comments=[],this.queuedSnapshot=null,this.loaded=!1,this.user=e??{id:"signed-out",name:"Sign in"},this.managedUser=!0,this.draft=null,this.text="",this.replyText="",this.placing=!1,this.activeId=null,this.changed(),this.render())}async signIn(){if(this.storage instanceof p)try{await this.storage.signIn(),await this.refresh()}catch(e){this.destroyed||(this.report(e),this.render())}}async signOut(){if(this.storage instanceof p&&!this.saving)try{await this.storage.signOut(),await this.refresh()}catch(e){this.report(e),this.render()}}setUser(e){if(this.storage instanceof p)throw new Error("Hosted mode manages the signed-in account. Use signIn or signOut.");if(!this.destroyed){if(this.saving)throw new Error("Wait until the current comment is saved before changing users.");this.user=e?g(e):f(this.identityKey).user,this.managedUser=!!e,this.editing=null,this.draft=null,this.text="",this.replyText="",this.placing=!1,this.render()}}show(){var e;this.destroyed||(this.visible||(this.returnFocus=document.activeElement),this.visible=!0,this.render(),this.trackLayoutMotion(),null==(e=this.shadow.querySelector(".panel button, .launcher"))||e.focus(),this.checkForUpdate())}hide(){var e;this.destroyed||(this.visible=!1,this.placing=!1,this.draft=null,this.activeId=null,this.editing=null,this.text="",this.replyText="",this.render(),this.returnFocus instanceof HTMLElement&&this.returnFocus.isConnected?this.returnFocus.focus():null==(e=this.shadow.querySelector(".launcher"))||e.focus())}startComment(e){var t;if(this.storage instanceof p&&!this.storage.signedIn)this.signIn();else if(!(this.destroyed||this.initialLoad()||this.loadFailed||this.saving)){if(this.visible=!0,this.activeId=null,this.editing=null,this.text="",e){if(!Number.isFinite(e.x)||!Number.isFinite(e.y))throw new Error("Comment coordinates must be finite.");const t=e.x-window.scrollX,i=e.y-window.scrollY,n=document.elementFromPoint(t,i);if(this.config.container&&(!n||!this.config.container.contains(n)))throw new Error("Choose a position inside the configured container.");this.draft=this.makeDraft(e,n),this.placing=!1}else this.placing=!0,this.draft=null;this.render(),this.announce(e?"Write your comment.":"Click a place on the page, or Tab to an element and press Enter. Press Escape to cancel."),null==(t=this.shadow.querySelector("textarea"))||t.focus()}}navigateToComment(e){var t;if(this.destroyed)return;const i=this.comments.find(t=>t.id===e);if(i)try{const n=function(e,t){const i=new URL(e,t);if(!["http:","https:"].includes(i.protocol)||i.origin!==new URL(t).origin)throw new Error("Comments can only link to pages on this site.");return i}(i.pageUrl,location.href);if(!this.onCurrentPage(i.pageUrl)){try{sessionStorage.setItem(this.openKey,e)}catch{}return void location.assign(n.href)}this.visible=!0,this.placing=!1,this.draft=null,this.editing=null,this.activeId=e,this.replyText="",this.replyId=m(),this.flash(e),this.render();const s=i.selector?this.elementState(i):"shown";"hidden"===s||"removed"===s&&this.canReveal(i)?this.reveal(i):this.scrollToComment(i),null==(t=this.shadow.querySelector(".detail"))||t.focus({preventScroll:!0})}catch(n){this.report(n),this.visible=!0,this.render()}}scrollToComment(e){const t=this.reducedMotion()?"instant":"smooth",i=this.anchorElement(e);i&&!this.detached(e)?i.scrollIntoView({block:"center",behavior:t}):window.scrollTo({top:Math.max(0,e.y-window.innerHeight/2),behavior:t})}detached(e){return function(e,t){return"shown"!==pe(e,t)}(e,this.config.container)}elementState(e){var t,i,n,s;const o=pe(e,this.config.container);if("removed"!==o||(null==(t=this.revealed)?void 0:t.id)===e.id&&!this.revealed.result.shown)return o;const r=!1!==this.config.autoReveal?null==(s=null==(n=null==(i=e.element)?void 0:i.reveal)?void 0:n[0])?void 0:s.target:void 0;return r&&W(r)?"hidden":o}elementInfo(e){if(e.element)return e.element;const t=this.anchorElement(e)??(e.selector?(()=>{try{return document.querySelector(e.selector)}catch{return null}})():null);return t?xe(t):void 0}anchorStatus(e,t){var i,n;const s=T("div",`anchor-status ${t}`);if(s.dataset.anchorStatus=t,s.hidden="shown"===t,"shown"===t)return s;const o=this.elementInfo(e),r="hidden"===t,a=T("div","anchor-head"),l=T("span","anchor-icon");l.append(L(r?"eyeOff":"unlink"));const c=T("div","anchor-titles");c.append(T("strong","",r?"Element hidden":"Element removed")),o&&c.append(T("span","anchor-target",o.place?`${o.label} in ${o.place}`:o.label)),a.append(l,c),s.append(a);const d=(null==(i=this.revealed)?void 0:i.id)===e.id?null==(n=this.revealed.result.failed)?void 0:n.target.name:void 0,h=d??(null==o?void 0:o.place),p=r||d?h?`Open “${h}” to see it.`:"It is on this page, but not shown now. It can be in a closed menu, tab or filter.":"Nothing on this page matches it now. It was deleted, or it shows only after an action.";return s.append(T("p","",`${p} The dashed pin shows where the note was left.${this.canMove(e)?" Drag the pin to attach it again.":""}`)),(r||this.canReveal(e))&&s.append(P("Show Element","quiet anchor-action",()=>{this.reveal(e)},"eye")),s}canReveal(e){var t,i;return!!this.config.revealComponent||!1!==this.config.autoReveal&&!!(null==(i=null==(t=e.element)?void 0:t.reveal)?void 0:i.length)}async reveal(e){var t,i,n;let s=!1;try{s=!!(await(null==(i=(t=this.config).revealComponent)?void 0:i.call(t,c([e])[0],this.anchorElement(e))))}catch(a){this.report(a)}const o=null==(n=e.element)?void 0:n.reveal;if(!s&&!1!==this.config.autoReveal&&(null==o?void 0:o.length)){let t;this.endReveal(),this.replaying=!0;try{t=await async function(e,t){var i;const n=()=>U(t());if(n())return{shown:!0};for(let s=0;s<e.length;s++){const t=e[s],o=W(t.target);if("press"===t.action&&o&&V(o))return{shown:!1};if(!o||"focus"!==t.action&&!U(o))return{shown:!1,failed:t};const r=e[s+1]?()=>U(W(e[s+1].target)):n;if("hover"===t.action){for(const e of["pointerover","pointerenter","mouseover","mouseenter","pointermove","mousemove"])te(o,e);await ee(r,500)||(oe.set(o,"hover"),await ee(r,300)||(ie(o),await ee(r,500)||ne(o,"ArrowRight")))}else if("focus"===t.action)null==(i=o.focus)||i.call(o,{preventScroll:!0}),await ee(r,200)||oe.set(o,"focus");else if(!se(o)){const e=()=>r()||se(o);if(ie(o),!(await ee(e,900))){let i=!1;for(const t of G)if(ne(o,t),await ee(e,400)){i=!0;break}if(!i)return{shown:!1,failed:t}}}await ee(r,1200)}return{shown:await ee(n,1500)}}(o,()=>this.anchorElement(e))}finally{this.replaying=!1}if(this.destroyed||this.activeId!==e.id)return void re();this.revealed={id:e.id,result:t},s=t.shown}if(!s&&!1!==this.config.autoReveal){const t=this.anchorElement(e);t&&function(e){const t=[];for(let n=e instanceof HTMLElement?e:e.parentElement;n&&n!==document.body;n=n.parentElement)t.unshift(n);let i=!1;for(const n of t){if(n instanceof HTMLDetailsElement&&!n.open&&(n.open=!0,i=!0),n.hasAttribute("popover")&&!n.matches(":popover-open"))try{n.showPopover(),i=!0}catch{}if(!n.id||!n.hidden&&"none"!==getComputedStyle(n).display)continue;const e=CSS.escape(n.id),t=document.querySelector(`[aria-controls~="${e}"][aria-expanded="false"]`)??("tabpanel"===n.getAttribute("role")?document.querySelector(`[role=tab][aria-controls~="${e}"][aria-selected="false"]`):null);t&&(t.click(),i=!0)}return i}(t)&&(s=!0,await new Promise(e=>setTimeout(e,250)))}if(this.destroyed||this.activeId!==e.id)return;this.scrollToComment(e),this.render();const r=this.elementState(e);this.announce("shown"===r?"Showing the comment’s element.":"hidden"===r?"The comment’s element is still hidden. A dashed pin shows where it was.":"The comment’s element was removed. A dashed pin shows where it was.")}syncLayer(){const e=this.activeId?this.comments.find(e=>e.id===this.activeId):null,t=this.draft?this.anchorElement(this.draft):e?this.anchorElement(e):null,i=t?[...Ue("dialog:modal"),...Ue(":popover-open")].filter(e=>e.contains(t)):[],n=i.find(e=>i.every(t=>t.contains(e)))??document.body;this.host.parentElement!==n&&n.append(this.host)}endReveal(){this.revealed&&(this.revealed=null,re())}openPending(){const e=new URL(location.href).searchParams.get("cw_comment"),t=e?this.comments.find(t=>t.id===e&&this.onCurrentPage(t.pageUrl)):null;if(t){const e=new URL(location.href);return e.search=d(e.search),history.replaceState(history.state,"",e.href),void this.navigateToComment(t.id)}let i=null;try{i=sessionStorage.getItem(this.openKey),sessionStorage.removeItem(this.openKey)}catch{return}const n=i?this.comments.find(e=>e.id===i):null;n&&this.onCurrentPage(n.pageUrl)&&this.navigateToComment(n.id)}hoverNote(e){if(this.hoverId!==e){this.hoverId=e;for(const t of this.pins.querySelectorAll(".pin[data-id]"))t.classList.toggle("hovered",t.dataset.id===e);this.positionPins()}}flash(e){this.highlightId=e,clearTimeout(this.highlightTimer),this.highlightTimer=setTimeout(()=>{var e;this.highlightId=null,null==(e=this.pins.querySelector(".highlight"))||e.classList.remove("highlight")},2400)}destroy(){var e;if(!this.destroyed){this.destroyed=!0,++this.loadVersion,clearTimeout(this.highlightTimer),clearTimeout(this.searchTimer),this.storage instanceof p&&this.storage.destroy(),this.events.abort(),this.resizeObserver.disconnect(),this.mutationObserver.disconnect(),this.anchorObserver.disconnect(),this.observedAnchors.clear(),clearInterval(this.routeTimer),cancelAnimationFrame(this.frame),cancelAnimationFrame(this.motionFrame);for(const e of this.toastTimers)clearTimeout(e);this.toastTimers.clear(),this.sidebarOpen=!1,this.pushPage(),re();try{null==(e=this.unsubscribe)||e.call(this)}finally{this.host.remove()}}}initialLoad(){return this.loading&&!this.loaded}reducedMotion(){return window.matchMedia("(prefers-reduced-motion: reduce)").matches}choosePoint(e,t){var i;let n;try{n=this.makeDraft(e,t)}catch(s){return this.report(s),void this.render()}this.placing=!1,this.draft=n,this.render(),null==(i=this.shadow.querySelector("textarea"))||i.focus()}startPinDrag(e,t){if(this.suppressPinClick=!1,0!==e.button||!e.isPrimary||this.saving||this.pinDrag)return;const i=e.currentTarget,n=e.clientX-parseFloat(i.style.left),s=e.clientY-parseFloat(i.style.top),o=e.clientX,r=e.clientY,a=new AbortController,l={signal:a.signal};this.events.signal.addEventListener("abort",()=>a.abort(),l);let c=!1;window.addEventListener("pointermove",i=>{if(i.pointerId!==e.pointerId||!c&&Math.hypot(i.clientX-o,i.clientY-r)<5)return;c=!0;const[a,l]=this.pinBounds();this.pinDrag={id:t.id,x:Oe(i.clientX-n,a,l),y:Oe(i.clientY-s,46,innerHeight-6)};const d=document.elementFromPoint(this.pinDrag.x,this.pinDrag.y),h=d&&d!==this.host?le(d,this.config.container):null;this.pickTarget=h===document.body||h===document.documentElement?null:h,this.positionPins()},l);const d=i=>{if(i.pointerId!==e.pointerId)return;if(a.abort(),this.pickTarget=null,!c)return;this.suppressPinClick=!0;const n=this.pinDrag;if("pointercancel"===i.type||!n)return this.pinDrag=null,void this.positionPins();this.movePin(t.id,n).finally(()=>{this.pinDrag=null,this.positionPins()})};window.addEventListener("pointerup",d,{...l,capture:!0}),window.addEventListener("pointercancel",d,{...l,capture:!0})}pinBounds(){var e;const t=this.sidebarOpen&&innerWidth>600?400:0,i=!!(null==(e=this.config.position)?void 0:e.endsWith("left"));return[18+(i?t:0),innerWidth-16-2-(i?0:t)]}async movePin(e,t){var i,n;const s=this.comments.find(t=>t.id===e),o=document.elementFromPoint(t.x,t.y);if(!s||!o||o===this.host||this.config.container&&!this.config.container.contains(o))return void this.announce("Drop the pin on the page to move it.");const r={x:t.x+scrollX,y:t.y+scrollY};let a;try{a=this.makeDraft(r,o)}catch(d){return this.report(d),void this.render()}a.element&&!a.element.reveal&&(null==(i=this.revealed)?void 0:i.id)===e&&(null==(n=s.element)?void 0:n.reveal)&&(a.element.reveal=s.element.reveal);const l={...s,x:r.x,y:r.y,selector:a.selector,anchor:a.anchor,element:a.element,pageTitle:De()??s.pageTitle},c=this.getAllComments().map(t=>t.id===e?l:t);this.activeId=e,await this.mutate(c,()=>this.storage.upsertComment?this.storage.upsertComment(l):this.storage.saveComments(c),()=>{})}placePickRing(){var e;const t=this.pins.querySelector(".pick-ring");if(!t)return;const i=(this.placing||this.pinDrag)&&(null==(e=this.pickTarget)?void 0:e.isConnected)?this.pickTarget.getBoundingClientRect():null;t.hidden=!i||!i.width||!i.height,i&&Object.assign(t.style,{left:i.left-3+"px",top:i.top-3+"px",width:`${i.width+6}px`,height:`${i.height+6}px`})}placePopover(){var e,t;const i=this.surface.querySelector(".popover");if(!i)return;const n=innerWidth<=600;if(i.classList.toggle("sheet",n),n)return i.style.left="",void(i.style.top="");const s=this.draft?null:this.comments.find(e=>e.id===this.activeId),o=!!s&&(null==(e=this.pinDrag)?void 0:e.id)===s.id;if(i.classList.toggle("moving",o),o)return;const r=o?this.pinDrag:this.draft?this.position({...this.draft,...this.draft.position}):s?this.position(s)??(this.detached(s)?{x:s.x-scrollX,y:s.y-scrollY}:null):null,a=o?null:this.draft?this.anchorElement(this.draft):s?this.anchorElement(s):null,l=i.offsetWidth,c=i.offsetHeight,d=this.sidebarOpen?400:0,h=!!(null==(t=this.config.position)?void 0:t.endsWith("left")),p=ze+(h?d:0),u=innerWidth-ze-(h?0:d)-l;let m=u,g=72;if(r&&r.x>=0&&r.y>=0&&r.x<=innerWidth&&r.y<=innerHeight){const e=null==a?void 0:a.getBoundingClientRect();m=e&&e.right+12<=u?e.right+12:e&&e.left-12-l>=p?e.left-12-l:r.x+24<=u?r.x+24:r.x-24-l,g=r.y-40}i.style.left=`${Oe(m,p,u)}px`,i.style.top=`${Oe(g,ze,innerHeight-ze-c)}px`}makeDraft(e,t){const i={id:m(),timestamp:new Date,position:e,pageUrl:this.currentPage()};if((t=t?le(t,this.config.container):null)&&!this.host.contains(t)){const n=t.getBoundingClientRect();if(n.width&&n.height){i.selector=function(e,t){const i=e.getAttribute("data-overplay-anchor");if(i&&he(`[data-overplay-anchor="${CSS.escape(i)}"]`,t)===e)return`[data-overplay-anchor="${CSS.escape(i)}"]`;if(e===document.body)return"body";if(e===document.documentElement)return"html";const n=[];for(let s=e;s&&s!==document.body;s=s.parentElement){if(s.id&&!de(s.id)&&1===document.querySelectorAll(`#${CSS.escape(s.id)}`).length){n.unshift(`#${CSS.escape(s.id)}`);break}const t=s!==e?s.getAttribute("data-overplay-anchor"):null;if(t&&1===document.querySelectorAll(`[data-overplay-anchor="${CSS.escape(t)}"]`).length){n.unshift(`[data-overplay-anchor="${CSS.escape(t)}"]`);break}const i=s.parentElement?Array.from(s.parentElement.children).filter(e=>e.tagName===s.tagName):[];n.unshift(`${s.tagName.toLowerCase()}:nth-of-type(${i.indexOf(s)+1})`)}return n.join(" > ")}(t,this.config.container),i.element=xe(t);const s=!1!==this.config.autoReveal?this.recorder.capture(t):[];s.length&&(i.element.reveal=s),i.anchor={x:Math.max(0,Math.min(1,(e.x-scrollX-n.left)/n.width)),y:Math.max(0,Math.min(1,(e.y-scrollY-n.top)/n.height))}}}if(!i.selector||!i.anchor)throw new Error("Choose a visible page element to attach this note.");return i}anchorElement(e){return e.selector?he(e.selector,this.config.container):null}position(e){return function(e,t){if(!e.selector)return{x:e.x-scrollX,y:e.y-scrollY};const i=he(e.selector,t);if(!i||!i.getClientRects().length)return null;const n=i.getBoundingClientRect();if(!n.width||!n.height||"visible"!==getComputedStyle(i).visibility)return null;const s=e.anchor??{x:.5,y:.5},o={x:n.left+n.width*s.x,y:n.top+n.height*s.y};for(let r=i.parentElement;r&&r!==document.body&&r!==document.documentElement;r=r.parentElement){const e=getComputedStyle(r),t=r.getBoundingClientRect(),i=t.left+r.clientLeft,n=t.top+r.clientTop;if(/(auto|scroll|hidden|clip)/.test(e.overflowX)&&(o.x<i||o.x>i+r.clientWidth))return null;if(/(auto|scroll|hidden|clip)/.test(e.overflowY)&&(o.y<n||o.y>n+r.clientHeight))return null}return o}(e,this.config.container)}observeAnchors(){var e;const t=new Set;for(const i of this.pageComments()){const e=this.anchorElement(i);e&&t.add(e)}if(null==(e=this.draft)?void 0:e.selector){const e=this.anchorElement(this.draft);e&&t.add(e)}for(const i of this.observedAnchors)t.has(i)||this.anchorObserver.unobserve(i);for(const i of t)this.observedAnchors.has(i)||this.anchorObserver.observe(i);this.observedAnchors=t}positionPins(){var e,t,i,n;this.observeAnchors();const s=this.host.parentElement;s&&s!==document.body&&![...Ue("dialog[open]"),...Ue(":popover-open")].includes(s)&&document.body.append(this.host);for(const c of this.pins.querySelectorAll("[data-id]")){const t=this.comments.find(e=>e.id===c.dataset.id);if(!t)continue;const i=(null==(e=this.pinDrag)?void 0:e.id)===t.id;c.classList.toggle("dragging",i);const n=!i&&t.id===this.activeId&&this.detached(t);c.classList.toggle("detached",n);const s=i?this.pinDrag:n?{x:t.x-scrollX,y:t.y-scrollY}:this.position(t);if(!s){c.hidden=!0;continue}const[o,r]=this.pinBounds();if(c.style.left=`${Oe(s.x,o,r)}px`,c.style.top=`${s.y}px`,c.classList.toggle("below",s.y<40),c.hidden=s.x<0||s.y<0||s.x>innerWidth||s.y>innerHeight,this.config.container){const e=this.config.container.getBoundingClientRect();c.hidden||(c.hidden=s.x<e.left||s.x>e.right||s.y<e.top||s.y>e.bottom)}}const o=this.comments.find(e=>e.id===this.activeId),r=this.pins.querySelector(".focus-ring");if(r){const e=o?null==(t=this.anchorElement(o))?void 0:t.getBoundingClientRect():void 0;r.hidden=!e||!e.width||!e.height||(null==(i=this.pinDrag)?void 0:i.id)===(null==o?void 0:o.id),e&&Object.assign(r.style,{left:e.left-4+"px",top:e.top-4+"px",width:`${e.width+8}px`,height:`${e.height+8}px`})}const a=this.pins.querySelector(".hover-ring");if(a){const e=this.hoverId?this.comments.find(e=>e.id===this.hoverId):void 0,t=e&&e.id!==this.activeId?null==(n=this.anchorElement(e))?void 0:n.getBoundingClientRect():void 0;a.hidden=!t||!t.width||!t.height,t&&Object.assign(a.style,{left:t.left-4+"px",top:t.top-4+"px",width:`${t.width+8}px`,height:`${t.height+8}px`})}this.placePickRing(),this.placePopover();const l=this.surface.querySelector("[data-anchor-status]");if(l&&o){const e=this.elementState(o);l.dataset.anchorStatus!==e&&l.replaceWith(this.anchorStatus(o,e))}}checkForUpdate(){var e;!this.updateChecked&&(this.config.updateNotice??(e=location.hostname,["localhost","127.0.0.1","[::1]","::1"].includes(e)||/\.(localhost|local|test)$/.test(e)))&&(this.updateChecked=!0,async function(e=fetch,t=Date.now()){const i="overplay:latest-version";try{const e=JSON.parse(localStorage.getItem(i)||"null");if(e&&"string"==typeof e.version&&t-e.checkedAt<432e5)return e.version}catch{}try{const n=await e(`https://registry.npmjs.org/${y}/latest`,{credentials:"omit",referrerPolicy:"no-referrer"});if(!n.ok)return null;const s=await n.json();if("string"!=typeof s.version)return null;try{localStorage.setItem(i,JSON.stringify({version:s.version,checkedAt:t}))}catch{}return s.version}catch{return null}}().then(e=>{if(!this.destroyed&&e&&function(e,t){const i=e=>{var t;return null==(t=/^(\d+)\.(\d+)\.(\d+)$/.exec(e.trim()))?void 0:t.slice(1).map(Number)},n=i(e),s=i(t);if(!n||!s)return!1;for(let o=0;o<3;o++)if(n[o]!==s[o])return n[o]>s[o];return!1}(e,b)){try{if(localStorage.getItem(qe)===e)return}catch{}this.update=e,this.render()}}))}async copyUpdate(){let e=!1;try{await navigator.clipboard.writeText(k),e=!0}catch{}this.toast({kind:"comment",commentId:"",author:e?"Update command copied":"Run this to update",text:e?`Run it in your project, then reload: ${k}`:k},!0),this.announce(e?"Update command copied.":`Run ${k} to update.`)}dismissUpdate(){try{localStorage.setItem(qe,this.update??"")}catch{}this.update=null,this.render()}startDrag(e){if(this.suppressClick=!1,0!==e.button||!e.isPrimary)return;const t=e.currentTarget.getBoundingClientRect(),i=e.clientX-t.left,n=e.clientY-t.top,s=e.clientX,o=e.clientY,r=new AbortController,a={signal:r.signal};this.events.signal.addEventListener("abort",()=>r.abort(),{signal:r.signal}),window.addEventListener("pointermove",t=>{var r;if(t.pointerId!==e.pointerId)return;if(!this.dragging&&Math.hypot(t.clientX-s,t.clientY-o)<5)return;this.dragging=!0;const a=Oe(t.clientX-i,ze,innerWidth-Re-ze),l=Oe(t.clientY-n,ze,innerHeight-Re-ze);this.launcherSpot={x:(a+26)/innerWidth,y:(l+26)/innerHeight},null==(r=this.shadow.querySelector(".launcher"))||r.classList.add("dragging"),this.placeLauncher()},a);const l=t=>{var i;if(t.pointerId===e.pointerId&&(r.abort(),this.dragging)){this.dragging=!1,this.suppressClick=!0,null==(i=this.shadow.querySelector(".launcher"))||i.classList.remove("dragging");try{localStorage.setItem(this.launcherKey,JSON.stringify(this.launcherSpot))}catch{}}};window.addEventListener("pointerup",l,{...a,capture:!0}),window.addEventListener("pointercancel",l,{...a,capture:!0})}pageComments(){return this.comments.filter(e=>this.onCurrentPage(e.pageUrl)).sort((e,t)=>e.timestamp.getTime()-t.timestamp.getTime()||e.id.localeCompare(t.id))}closePopup(e=!0){var t;this.draft=null,this.activeId=null,this.placing=!1,this.editing=null,this.text="",this.replyText="",this.render(),e&&(null==(t=this.shadow.querySelector(".panel .primary, .launcher"))||t.focus())}setDocked(e){var t;this.docked=e;try{localStorage.setItem(this.dockKey,e?"1":"0")}catch{}this.render(),null==(t=this.shadow.querySelector(".detail"))||t.focus({preventScroll:!0})}scopeComments(){return"page"===this.scope?this.pageComments():[...this.comments].sort((e,t)=>e.timestamp.getTime()-t.timestamp.getTime()||e.id.localeCompare(t.id))}noteNumbers(){const e=new Map,t=new Map;for(const i of[...this.comments].sort((e,t)=>e.timestamp.getTime()-t.timestamp.getTime()||e.id.localeCompare(t.id))){const n=this.onCurrentPage(i.pageUrl)?"":i.pageUrl,s=(e.get(n)??0)+1;e.set(n,s),t.set(i.id,s)}return t}async mutate(e,t,i){if(!(this.saving||this.initialLoad()||this.loadFailed||this.destroyed)){this.loading&&(++this.loadVersion,this.loading=!1),this.saving=!0,this.error="",this.render();try{if(await t(),this.destroyed)return;this.comments=e;try{this.comments=l(await this.storage.loadComments())}catch{this.error="Saved. Could not refresh other comments. Use Refresh to try again."}if(this.destroyed)return;this.queuedSnapshot=null,i(),this.changed(),this.noticeActivity(),this.announce(this.error||"Changes saved.")}catch(n){this.destroyed||this.report(n)}finally{this.destroyed||(this.saving=!1,this.render())}}}toggleResolved(e){const t={...e,resolved:!e.resolved},i=this.getAllComments().map(i=>i.id===e.id?t:i);this.mutate(i,()=>this.storage.setResolved?this.storage.setResolved(e.id,t.resolved):this.storage.upsertComment?this.storage.upsertComment(t):this.storage.saveComments(i),()=>{})}deleteNote(e){const t=this.getAllComments().filter(t=>t.id!==e.id);this.mutate(t,()=>this.storage.deleteComment?this.storage.deleteComment(e.id):this.storage.saveComments(t),()=>{this.activeId=null})}render(){var e,t,i,n,s,o,r;if(this.destroyed)return;if(this.composing)return void(this.renderDeferred=!0);this.revealed&&this.activeId!==this.revealed.id&&this.endReveal(),this.syncLayer(),(!this.sidebarOpen||this.activeId||this.draft)&&(this.hoverId=null);const a=this.shadow.activeElement,l=a instanceof HTMLElement?a.dataset.focus:void 0,c=a instanceof HTMLInputElement||a instanceof HTMLTextAreaElement?[a.selectionStart,a.selectionEnd]:null,d=(null==(e=this.shadow.querySelector(".list"))?void 0:e.scrollTop)??0,h=(null==(t=this.shadow.querySelector(".thread-body"))?void 0:t.scrollTop)??0,p=!!this.surface.querySelector(".panel");this.host.dataset.theme=this.settings.theme,this.surface.replaceChildren(),this.pins.replaceChildren();const u=this.visible?this.detail():null,m=!!u&&(this.docked||!!this.editing),g=this.visible&&(m||!this.config.hideSidebar);if(this.config.hideButton||g||this.surface.append(this.launcher()),this.visible){if(g&&this.surface.append(this.sidebar(m?u:null)),u&&!m){const e=T("div","popover");e.append(u),this.surface.append(e),null==(i=this.surface.querySelector(".panel"))||i.classList.add("behind")}if(this.renderPins(),this.placing){const e=T("div",`notice${g?" beside-panel":""}${(null==(n=this.config.position)?void 0:n.endsWith("left"))?" left":""}`);e.append(L("pin"),T("span","","Click anywhere to leave a note, or Tab to an element and press Enter."));const t=T("kbd","","Esc");e.append(t,P("Cancel placement","icon-button",()=>this.closePopup(),"close")),this.surface.append(e)}}null==(s=this.surface.querySelector(".panel"))||s.classList.toggle("entering",!p);const f=u?this.editing?this.editing:this.draft?`draft:${this.draft.id}`:`thread:${this.activeId}`:"";null==u||u.classList.toggle("entering",(p||!m)&&f!==this.detailKey),this.detailKey=f,this.toasts.classList.toggle("beside-panel",g),this.sidebarOpen=g,this.pushPage(),this.toasts.classList.toggle("left",!!(null==(o=this.config.position)?void 0:o.endsWith("left"))),this.toasts.classList.toggle("top",!!(null==(r=this.config.position)?void 0:r.startsWith("top")));const v=this.shadow.querySelector(".list");v&&(v.scrollTop=d);const x=this.shadow.querySelector(".thread-body");if(x&&(x.scrollTop=h),l){const e=Array.from(this.shadow.querySelectorAll("[data-focus]")).find(e=>e.dataset.focus===l);null==e||e.focus({preventScroll:!0}),c&&(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&e.setSelectionRange(c[0],c[1])}this.positionPins()}launcher(){const e=P("Comments","launcher"+(this.dragging?" dragging":""),()=>{this.suppressClick?this.suppressClick=!1:this.visible?this.hide():this.show()},"comment");e.replaceChildren(L("comment")),this.paintLauncher(e),e.dataset.focus="launcher",e.setAttribute("aria-expanded",String(this.visible)),e.title="Comments. Drag to move.",e.addEventListener("pointerdown",e=>this.startDrag(e));const t=this.pageComments().filter(e=>!e.resolved).length;e.setAttribute("aria-label",t?`Comments, ${t} open`:"Comments"),t&&e.append(T("span","badge",String(t)));const i=this.config.position??"bottom-right";return i.endsWith("left")&&(e.style.left="24px",e.style.right="auto"),i.startsWith("top")&&(e.style.top="24px",e.style.bottom="auto"),this.launcherSpot&&queueMicrotask(this.placeLauncher),e}heading(e,t){const i=T("div","head"),n=T("span","brand-icon");n.append(L("comment"));const s=T("div","heading");s.append(T("h2","",e)),t&&s.append(T("p","subtext",t));const o=T("div","head-actions"),r=P("Settings","icon-button",()=>this.openSettings(),"settings");return r.dataset.focus="settings",o.append(r,this.userMenu(),P("Close comments","icon-button",()=>this.hide(),"close")),i.append(n,s,o),i}menuItem(e,t,i,n=""){const s=P(e,`menu-item ${n}`,i,t);return s.setAttribute("role","menuitem"),s}menuToggle(e,t){t.hidden=!0,t.setAttribute("role","menu"),e.setAttribute("aria-haspopup","menu"),e.setAttribute("aria-expanded","false"),e.addEventListener("click",()=>{var i;const n=t.hidden;this.closeMenus(),t.hidden=!n,e.setAttribute("aria-expanded",String(n)),n&&(null==(i=t.querySelector("button:not(:disabled)"))||i.focus())})}closeMenus(){let e=null;for(const t of this.shadow.querySelectorAll("[role=menu]"))t.hidden=!0;for(const t of this.shadow.querySelectorAll("[aria-haspopup=menu]"))"true"===t.getAttribute("aria-expanded")&&(e=t),t.setAttribute("aria-expanded","false");return e}userMenu(){const e=this.storage instanceof p?this.storage:null;if(e&&!e.signedIn){const e=P("Sign In","quiet sign-in",()=>{this.signIn()},"signin");return e.title="Sign in to join this project",e}const t=T("div","menu-wrap"),i=T("button","user-button");i.type="button",i.dataset.focus="user",i.setAttribute("aria-label",`Account: ${this.user.name}`),i.title=this.user.name,i.append(M(this.user.name,this.user.avatarUrl));const n=T("div","pop-menu user-menu"),s=T("div","menu-user"),o=T("div","menu-user-text");if(o.append(T("strong","",this.user.name),T("small","",e?"Signed in to this project":this.managedUser?"Your project account":this.persistentGuest?"Guest in this browser":"Guest for this page view")),s.append(M(this.user.name,this.user.avatarUrl),o),n.append(s),e||this.managedUser||n.append(this.menuItem("Edit Your Name","edit",()=>{var e;this.editing="identity",this.draft=null,this.activeId=null,this.placing=!1,this.render(),null==(e=this.shadow.querySelector("#guest-name"))||e.focus()})),n.append(this.menuItem("Settings","settings",()=>this.openSettings())),e){const e=this.menuItem("Sign Out","signout",()=>{this.signOut()});e.disabled=this.saving,n.append(e)}const r=T("p","menu-note");return r.append(T("span","storage-dot"),T("span","",e?"Comments sync with your team":this.storage instanceof u?"Comments are saved in this browser":"Comments use connected storage")),n.append(r),this.menuToggle(i,n),t.append(i,n),t}openSettings(){var e;this.editing="settings",this.draft=null,this.activeId=null,this.placing=!1,this.render(),null==(e=this.shadow.querySelector(".detail"))||e.focus({preventScroll:!0})}detailHeading(e,t,i){const n=T("div","detail-head"),s=T("div","detail-bar"),o=P("Back to comments","back-link",()=>this.closePopup(),"back");o.querySelector("span").textContent="Comments",s.append(o,P("Close comments","icon-button",()=>this.hide(),"close"));const r=T("div","detail-title");return r.append(T("h2","",e)),i&&r.append(i),n.append(s,r),t&&n.append(T("p","subtext",t)),n}cardHeading(e,t,i,n="",s){const o=T("div","card-head");if(this.docked){const e=T("div","detail-bar"),t=P("Back to comments","back-link",()=>this.closePopup(),"back");t.querySelector("span").textContent="Comments",e.append(t,P("Close comments","icon-button",()=>this.hide(),"close")),o.append(e)}const r=T("div","pop-head");n&&(r.title=n);const a=T("span","pop-icon");a.append(L(i));const l=T("div","pop-title");l.append(T("h2","",e),T("p","pop-sub",t));const c=T("div","pop-menu"),d=this.menuItem.bind(this);if(s){const e=d("Delete Comment","trash",()=>{e.dataset.confirm?s():(e.dataset.confirm="1",e.querySelector("span").textContent="Click Again to Delete")},"danger");e.disabled=this.saving,c.append(e)}if(r.append(a,l),c.childElementCount){const e=P("More actions","icon-button more",()=>{},"more");this.menuToggle(e,c),r.append(e)}return this.docked||r.append(P("Close","icon-button",()=>this.closePopup(),"close")),c.childElementCount&&r.append(c),o.append(r),o}errorBox(){const e=T("div","error",this.error);return(this.loadFailed||this.error.startsWith("Saved."))&&e.append(P("Try Again","quiet",()=>{this.refresh()})),e}detail(){if("settings"===this.editing)return this.settingsView();if("identity"===this.editing)return this.identityForm();if(this.draft)return this.newCommentForm();const e=this.comments.find(e=>e.id===this.activeId&&this.onCurrentPage(e.pageUrl));return e?this.thread(e):null}sidebar(e){var t;const i=T("section",`panel${(null==(t=this.config.position)?void 0:t.endsWith("left"))?" left":""}${this.placing?" placing":""}`);if(i.setAttribute("aria-label","Comments"),e)return i.append(e),i;i.append(this.heading("Comments",""));const n=T("div","toolbar"),s=P("Add Comment","primary",()=>this.startComment(),"plus");s.disabled=this.initialLoad()||this.loadFailed||this.saving;const o=P("Refresh comments","icon-button outlined"+(this.loading?" busy":""),()=>{this.refresh()},"refresh");o.disabled=this.loading||this.saving,n.append(s,o),i.append(n),i.append(this.scopeBar());const r=this.scopeComments();r.length&&i.append(this.searchField(),this.peopleBar()),i.append(this.statusTabs()),this.error&&i.append(this.errorBox()),i.append(this.commentList(r));const a=this.footer();return a&&i.append(a),i.addEventListener("keydown",e=>{const t=e.composedPath()[0];if("/"!==e.key||e.ctrlKey||e.metaKey||e.altKey||e.isComposing)return;if(t instanceof Element&&t.closest("input,textarea,select"))return;const i=this.shadow.querySelector(".search input");i&&(e.preventDefault(),i.focus(),i.select())}),i}filterContext(e=this.scope){return{userId:this.user.id,includePage:"all"===e,elementOf:e=>this.onCurrentPage(e.pageUrl)?this.elementInfo(e):e.element}}restoreFilters(){try{const e=JSON.parse(sessionStorage.getItem(this.filterKey)||"null");if(!e)return;this.filters=function(e){const t=e&&"object"==typeof e?e:{};return{status:"resolved"===t.status||"all"===t.status?t.status:"open",query:"string"==typeof t.query?t.query.slice(0,200):"",mine:!0===t.mine,author:"string"==typeof t.author?t.author.slice(0,300):""}}(e),this.scope="all"===e.scope?"all":"page"}catch{}}saveFilters(){try{sessionStorage.setItem(this.filterKey,JSON.stringify({...this.filters,scope:this.scope}))}catch{}}setFilters(e,t){this.filters={...this.filters,...e},t&&(this.scope=t),this.saveFilters(),this.render(),this.announceResults()}announceResults(){const e=this.scopeComments();if(!this.sidebarOpen||!e.length)return;const t=$e(e,this.filters,this.filterContext()).length;this.announce(t?`${t} ${1===t?"note":"notes"} shown.`:"No notes match.")}refreshResults(){const e=this.scopeComments(),t=(e,t)=>{var i;return null==(i=this.shadow.querySelector(e))?void 0:i.replaceWith(t)};t(".scope",this.scopeBar()),t(".people",this.peopleBar()),t(".tabs",this.statusTabs()),t(".list",this.commentList(e)),this.pins.replaceChildren(),this.renderPins(),this.positionPins()}scopeBar(){const e=T("div","scope");e.setAttribute("role","group"),e.setAttribute("aria-label","Show comments from");const t={...this.filters,status:"all"};for(const[i,n]of[["page","This Page"],["all","All Pages"]]){const s=$e("page"===i?this.pageComments():this.comments,t,this.filterContext(i)).length,o=P(n,"scope-option",()=>this.setFilters({},i));o.setAttribute("aria-label",`${n}, ${s} ${1===s?"note":"notes"}`),o.setAttribute("aria-pressed",String(this.scope===i)),o.dataset.focus=`scope-${i}`,o.append(T("span","count",String(s))),e.append(o)}return e}searchField(){const e=T("div","search");e.setAttribute("role","search");const t=T("input");t.type="search",t.placeholder="Search notes, replies, people…",t.setAttribute("aria-label","Search comments"),t.value=this.filters.query,t.dataset.focus="search",t.maxLength=200,t.setAttribute("aria-keyshortcuts","/"),t.autocomplete="off",t.spellcheck=!1;const i=P("Clear search","icon-button search-clear",()=>{t.value="",n(!0),t.focus()},"close");i.hidden=!t.value;const n=e=>{clearTimeout(this.searchTimer),i.hidden=!t.value;const n=()=>{this.destroyed||this.filters.query===t.value||(this.filters={...this.filters,query:t.value},this.saveFilters(),this.refreshResults(),this.announceResults())};e?n():this.searchTimer=setTimeout(n,180)};return t.addEventListener("input",()=>n(!1)),t.addEventListener("keydown",e=>{"Escape"===e.key&&t.value&&!e.isComposing?(e.preventDefault(),t.value="",n(!0)):"Enter"!==e.key||e.isComposing||(e.preventDefault(),n(!0))}),e.append(L("search"),t,i),e}peopleBar(){const e=T("div","people");e.setAttribute("role","group"),e.setAttribute("aria-label","Filter by person");const t=Le(this.scopeComments(),this.filters,this.filterContext()),i=this.storage instanceof p?this.storage:null;if(!i||i.signedIn){const i=P("Mine","filter-chip",()=>this.setFilters({mine:!this.filters.mine,author:""}));i.title="Only notes you started",i.dataset.focus="filter-mine",i.setAttribute("aria-label",`Mine, ${t.mine} ${1===t.mine?"note":"notes"}`),i.setAttribute("aria-pressed",String(this.filters.mine)),i.append(T("span","count",String(t.mine))),e.append(i)}const n=t.authors;if(this.filters.author&&!n.some(e=>e.key===this.filters.author)&&n.push({key:this.filters.author,name:"Earlier author",count:0}),n.length>1||this.filters.author){const t=T("span","select"+(this.filters.author?" chosen":"")),i=T("select");i.setAttribute("aria-label","Author"),i.dataset.focus="filter-author",i.append(new Option("All Authors",""));for(const e of n)i.append(new Option(`${e.name} (${e.count})`,e.key));i.value=this.filters.author,i.addEventListener("change",()=>this.setFilters({author:i.value,mine:!1})),t.append(i),e.append(t)}if(Pe(this.filters)){const t=P("Clear Filters","link-button",()=>this.clearAllFilters());t.dataset.focus="filter-clear",e.append(t)}return e.hidden=!e.childElementCount,e}statusTabs(){const e=T("div","tabs");e.setAttribute("role","group"),e.setAttribute("aria-label","Filter by status");const t=Le(this.scopeComments(),this.filters,this.filterContext());for(const[i,n]of[["open","Open"],["resolved","Resolved"],["all","All"]]){const s=P(n,"tab",()=>this.setFilters({status:i}));s.setAttribute("aria-label",`${n}, ${t[i]} ${1===t[i]?"note":"notes"}`),s.setAttribute("aria-pressed",String(this.filters.status===i)),s.dataset.focus=`tab-${i}`,s.append(T("span","count",String(t[i]))),e.append(s)}return e}clearAllFilters(){var e,t;this.setFilters((t=this.scopeComments(),{...we,status:t.some(e=>!e.resolved)||!t.length?"open":"all"})),null==(e=this.shadow.querySelector(".search input, .panel .primary"))||e.focus()}commentList(e){var t;const i=T("div","list");i.setAttribute("aria-busy",String(this.loading));const n=$e(e,this.filters,this.filterContext()),s="page"===this.scope;if(this.initialLoad())i.append(this.empty("Loading your notes","Your comments will appear here in a moment."));else if(this.loadFailed)i.append(this.empty("Could not load comments","Your stored notes have not been changed. Try loading them again."));else if(e.length)if(n.length){const e=this.noteNumbers(),o=new Map;for(const t of[...n].sort((e,t)=>t.timestamp.getTime()-e.timestamp.getTime())){const e=this.onCurrentPage(t.pageUrl)?"":t.pageUrl;o.set(e,[...o.get(e)??[],t])}const r=[...o].sort(([e],[t])=>Number(""!==e)-Number(""!==t));for(const[n,a]of r){const o=T("div","list-title");if(s)o.textContent="On this page";else{const e=Ne(n||this.currentPage()),i=(n?null==(t=a.find(e=>e.pageTitle))?void 0:t.pageTitle:De())??e,s=T("span",i===e?"page-path":"page-name",i);if(s.title=e,o.append(s),i!==e){const t=T("span","page-path sub",e);t.title=e,o.append(t)}n||o.append(T("span","here","This page"))}i.append(o);for(const t of a)i.append(this.noteRow(t,e.get(t.id)??0,!!n))}}else{const e=this.filters.query.trim(),t=e?`Nothing ${s?"on this page":"on any page"} matches “${e.length>60?`${e.slice(0,60)}…`:e}”.`:Pe(this.filters)?"No notes fit these filters.":"open"===this.filters.status?"Every note here is resolved.":"No note here is resolved yet.";i.append(this.empty("No notes match",t,P("Clear Filters","quiet",()=>this.clearAllFilters())))}else i.append(this.empty("Good ideas start here",s?"Pin a thought to any part of this page. Keep the conversation in context.":"Comments from every page of this site appear here.",s?P("Leave the First Note","quiet",()=>this.startComment()):void 0));return i}noteRow(e,t,i){const n=e.pageTitle||Ne(e.pageUrl),s=P(i?`Open comment by ${e.author} on ${n}`:`Open comment by ${e.author}`,"note"+(this.activeId===e.id?" current":""),()=>this.navigateToComment(e.id));s.replaceChildren();const o=ke(this.filters.query),r=T("div","note-main");r.append(this.messageHeader(e.author,e.timestamp,e.avatarUrl,e.via,o),Fe(T("p","note-text"),e.text,o));const a=o.length?Ee(e,o,this.filterContext()):null,l=(null==a?void 0:a.reply)?[`${a.reply.author}: `,a.reply.text]:(null==a?void 0:a.element)?["Element: ",a.element]:null;if(l){const e=T("p","note-match");e.append(L((null==a?void 0:a.reply)?"comment":"pin"),T("span","note-match-label",l[0])),e.append(Fe(T("span","note-match-text"),function(e,t,i=90){var n;const s=e.replace(/\s+/g," ").trim();if(s.length<=i)return s;const o=(null==(n=Se(s,t)[0])?void 0:n[0])??0,r=Math.max(0,Math.min(o-Math.floor(i/3),s.length-i));return`${r>0?"…":""}${s.slice(r,r+i).trim()}${r+i<s.length?"…":""}`}(l[1],o),o)),r.append(e)}const c=i?"shown":this.elementState(e);if(e.replies.length||i||"shown"!==c){const t=T("div","note-footer");if(e.replies.length&&t.append(L("comment"),T("span","",`${e.replies.length} ${1===e.replies.length?"reply":"replies"}`)),"shown"!==c){const i=this.elementInfo(e),n=T("span",`hidden-flag ${c}`,"removed"===c?"Element removed":(null==i?void 0:i.place)?`Hidden in ${i.place}`:"Element hidden");n.prepend(L("removed"===c?"unlink":"eyeOff")),n.title=i?`${i.label}${i.place?` in ${i.place}`:""}. Open the comment to see where it was.`:"Open the comment to see where it was.",t.append(n)}if(i){const e=T("span","go","Go to Page");e.append(L("open")),t.append(e)}r.append(t)}const d=T("span","note-meta"),h=T("span","status"+(e.resolved?" resolved":""),e.resolved?"Resolved":"Open");return e.resolved?h.prepend(L("check")):h.prepend(T("span","status-dot")),d.append(T("span","note-number",`#${t}`),h),s.append(r,d),i||(s.addEventListener("pointerenter",()=>this.hoverNote(e.id)),s.addEventListener("pointerleave",()=>this.hoverNote(null)),s.addEventListener("focus",()=>this.hoverNote(e.id)),s.addEventListener("blur",()=>this.hoverNote(null))),s}empty(e,t,i){const n=T("div","empty"),s=T("div"),o=T("div","empty-icon");return o.append(L("No notes match"===e?"search":"comment")),s.append(o,T("h3","",e),T("p","",t)),i&&s.append(i),n.append(s),n}footer(){if(!this.update)return null;const e=T("div","footer update-bar");e.setAttribute("role","status");const t=T("span","update-icon");t.append(L("refresh"));const i=T("div","update-text");i.append(T("strong","",`Version ${this.update} is available`),T("span","",`You have ${b}. Update the package, then reload.`));const n=T("div","update-command"),s=T("code","",k);s.title=k;const o=P(`Copy the command to update to version ${this.update}`,"quiet update",()=>{this.copyUpdate()});return o.querySelector("span").textContent="Copy",n.append(s,o),e.append(t,i,P("Hide until the next version","icon-button",()=>this.dismissUpdate(),"close"),n),e}messageHeader(e,t,i,n,s=[]){const o=T("div","note-header"),r=T("time","time",function(e){const t=Math.max(0,Math.floor((Date.now()-e.getTime())/6e4));return t<1?"Just now":t<60?`${t}m ago`:t<1440?`${Math.floor(t/60)}h ago`:e.toLocaleDateString(void 0,{month:"short",day:"numeric"})}(t));if(r.dateTime=t.toISOString(),r.title=t.toLocaleString(),o.append(M(e,i),Fe(T("span","name"),e,s)),n){const e=T("span","via",`via ${n}`);e.title=`Posted through MCP by ${n}`,o.append(e)}return o.append(r),o}view(e,t=""){const i=T("div",`detail ${t}`);return i.setAttribute("role","group"),i.setAttribute("aria-label",e),i.tabIndex=-1,i}composer(e){const t=T("form","compose"),i=T("textarea");i.setAttribute("aria-label",e?"Reply":"Comment"),i.placeholder=e?"Keep the conversation going…":"What’s on your mind?",i.maxLength=1e4,i.required=!0,i.value=e?this.replyText:this.text,i.dataset.focus=e?"reply":"comment",i.disabled=this.saving;const n=T("div","compose-bar"),s=T("span","compose-hint","⌘ / Ctrl + Enter to send"),o=P(this.saving?"Saving…":e?"Send Reply":"Post Comment","primary",()=>{},"arrow");return o.type="submit",o.disabled=this.saving||!i.value.trim(),i.addEventListener("input",()=>{e?this.replyText=i.value:this.text=i.value,o.disabled=this.saving||!i.value.trim()}),i.addEventListener("keydown",e=>{!e.ctrlKey&&!e.metaKey||"Enter"!==e.key||e.isComposing||(e.preventDefault(),o.disabled||t.requestSubmit())}),t.addEventListener("submit",t=>{t.preventDefault(),this.saving||(e?this.submitReply():this.submitComment())}),n.append(s,o),t.append(i,n),t}newCommentForm(){const e=this.view("New comment","new-comment");return e.append(this.cardHeading("New comment",`Commenting as ${this.user.name}`,"plus")),this.error&&e.append(this.errorBox()),e.append(this.composer(!1)),e}thread(e){var t,i;const n=this.view("Comment thread","thread"+(e.resolved?" is-resolved":"")),s=(null==(i=(t=this.config).canDelete)?void 0:i.call(t,e,this.getUser()))??this.manages(e);n.append(this.cardHeading(`Note #${this.pageComments().indexOf(e)+1}`,e.resolved?"Resolved conversation":"Open conversation","comment",this.canMove(e)?"Drag its pin to move it.":"",s?()=>this.deleteNote(e):void 0)),this.error&&n.append(this.errorBox()),e.selector&&n.append(this.anchorStatus(e,this.elementState(e)));const o=T("div","thread-body");for(const a of[e,...e.replies]){const e=T("div","message");e.append(this.messageHeader(a.author,a.timestamp,a.avatarUrl,a.via),T("p","message-text",a.text)),o.append(e)}n.append(o);const r=T("div","thread-actions");if(e.resolved){const t=T("span","status resolved","Resolved");t.prepend(L("check"));const i=P("Reopen Conversation","quiet reopen",()=>this.toggleResolved(e));i.disabled=this.saving,r.append(t,i)}else r.append(...this.replyBar(e));return n.append(r),n}replyBar(e){const t=T("form","reply-bar"),i=T("textarea");i.rows=1,i.placeholder="Reply…",i.setAttribute("aria-label","Reply"),i.maxLength=1e4,i.value=this.replyText,i.dataset.focus="reply",i.disabled=this.saving;const n=P(this.saving?"Saving…":"Send Reply","primary send",()=>{},"arrow");n.type="submit";const s=P("Mark as Resolved","primary resolve",()=>this.toggleResolved(e),"check");s.querySelector("span").textContent="Resolve",s.disabled=this.saving,n.disabled=this.saving;const o=()=>{const e=!!i.value.trim();n.hidden=!e,s.hidden=e,i.style.height="auto",i.style.height=`${Math.min(i.scrollHeight,120)}px`};return i.addEventListener("input",()=>{this.replyText=i.value,o()}),i.addEventListener("keydown",e=>{"Enter"!==e.key||e.shiftKey||e.isComposing||(e.preventDefault(),i.value.trim()&&t.requestSubmit())}),t.addEventListener("submit",e=>{e.preventDefault(),this.saving||this.submitReply()}),t.append(i,n),queueMicrotask(o),[t,s]}manages(e){return e.authorId===this.user.id||"owner"===this.user.role||"admin"===this.user.role}canMove(e){var t,i;return(null==(i=(t=this.config).canMove)?void 0:i.call(t,e,this.getUser()))??this.manages(e)}settingsView(){var e;const t=this.view("Settings","settings");t.append(this.detailHeading("Settings","Your choices for this project. Other people keep their own."));const i=this.settings,n=T("div","settings-body"),s=e=>{const t=T("section","setting-group");return t.append(T("h3","",e)),n.append(t),t},o=(e,t,i,n)=>{const s=T("div","setting"),o=T("div","setting-text");return o.append(T("strong","",t)),i&&o.append(T("small","",i)),s.append(o,n),e.append(s),s},r=(e,t,n)=>{const s=T("div","segmented");s.setAttribute("role","group"),s.setAttribute("aria-label",t);for(const[o,r]of n){const t=P(r,"segment",()=>this.setSetting(e,o));t.setAttribute("aria-pressed",String(i[e]===o)),t.dataset.focus=`set-${e}-${o}`,s.append(t)}return s},a=(e,t,n=!1)=>{const s=!0===i[e],o=T("button","switch");return o.type="button",o.setAttribute("role","switch"),o.setAttribute("aria-checked",String(s)),o.setAttribute("aria-label",t),o.dataset.focus=`set-${e}`,o.disabled=n,o.addEventListener("click",()=>this.setSetting(e,!s)),o};o(s("Appearance"),"Theme","system"===i.theme?"Follows your device":"",r("theme","Theme",[["light","Light"],["dark","Dark"],["system","System"]]));const l=s("Pins"),c=T("div",`pin-sample${"small"===i.pinSize?" small":""}${"gray"===i.resolvedPins?" resolved-gray":""}`);c.setAttribute("aria-hidden","true"),c.style.setProperty("--cw-accent",this.pinColor());const d=e=>"initials"===i.pinLabel?I(this.user.name):String(e);c.append(T("span","pin",d(1)),T("span","pin resolved",d(2)),T("span","pin-sample-text","Open and resolved")),l.append(c);const h=T("div","swatches");h.setAttribute("role","group"),h.setAttribute("aria-label","Pin color");const p=this.config.primaryColor.toLowerCase(),u=Object.entries(C).filter(([e,t])=>t.color!==p||i.pinColor===e);for(const[C,E,A]of[["site","Site color",p],...u.map(([e,t])=>[e,t.label,t.color])]){const e=P(E,"swatch",()=>this.setSetting("pinColor",C));e.replaceChildren(),e.style.setProperty("--swatch",A),e.setAttribute("aria-pressed",String(i.pinColor===C)),e.dataset.focus=`set-pinColor-${C}`,h.append(e)}o(l,"Color","site"===i.pinColor?"The color of this site":C[i.pinColor].label,h).classList.add("wide"),o(l,"Resolved pins","",r("resolvedPins","Resolved pins",[["green","Green"],["gray","Gray"]])),o(l,"Size","",r("pinSize","Pin size",[["regular","Regular"],["small","Small"]])),o(l,"Label","",r("pinLabel","Pin label",[["number","Number"],["initials","Initials"]]));const m=s("Comments button"),g=T("div","launcher-sample");g.setAttribute("aria-hidden","true");const f=T("span","launcher-mini");f.append(L("comment"),T("span","badge","3")),this.paintLauncher(f),g.append(f,T("span","pin-sample-text","On the page")),m.append(g);const v=T("div","swatches");v.setAttribute("role","group"),v.setAttribute("aria-label","Button color");const x=Object.entries(C).filter(([e,t])=>"graphite"!==e&&(t.color!==p||i.buttonColor===e));for(const[C,E,A]of[["default","Default","var(--cw-inverse)"],["site","Site color",p],...x.map(([e,t])=>[e,t.label,t.color])]){const e=P(E,"swatch",()=>this.setSetting("buttonColor",C));e.replaceChildren(),e.style.setProperty("--swatch",A),e.setAttribute("aria-pressed",String(i.buttonColor===C)),e.dataset.focus=`set-buttonColor-${C}`,v.append(e)}o(m,"Color","default"===i.buttonColor?"Dark. Takes the site color while open.":"site"===i.buttonColor?"The color of this site":C[i.buttonColor].label,v).classList.add("wide");const w=s("Panel"),b=T("div","segmented");b.setAttribute("role","group"),b.setAttribute("aria-label","Open comments");for(const[C,E]of[[!1,"Next to Pin"],[!0,"In Sidebar"]]){const e=P(E,"segment",()=>{this.docked!==C&&this.setDocked(C)});e.setAttribute("aria-pressed",String(this.docked===C)),e.dataset.focus=`set-docked-${C}`,b.append(e)}o(w,"Open comments","",b),o(w,"Push the page aside","The open panel does not cover the page.",a("pushContent","Push the page aside"));const y=s("Notifications and keys");o(y,"New activity","Show a short notice when others comment or reply.",a("notifications","Show new activity"));const k=(null==(e=this.config.keyboardShortcut)?void 0:e.split("+").map(e=>1===e.length?e.toUpperCase():e[0].toUpperCase()+e.slice(1)).join(" + "))??"";o(y,"Keyboard shortcut",this.shortcut?`${k} opens and closes comments.`:"This site has no shortcut.",a("shortcut","Keyboard shortcut",!this.shortcut));const S=T("div","settings-foot");return S.append(T("span","","Saved in this browser"),P("Reset to Defaults","quiet",()=>this.resetSettings())),t.append(n,S),t}paintLauncher(e){const t=this.settings.buttonColor;"default"!==t&&(e.classList.add("colored"),e.style.setProperty("--cw-launcher","site"===t?this.config.primaryColor:C[t].color))}pinColor(){const e=this.settings.pinColor;return"site"===e?this.config.primaryColor:C[e].color}identityForm(){const e=this.view("Your guest profile");e.append(this.detailHeading("Your name","A name to put to your notes."));const t=T("form","identity-form"),i=T("label","","Display name");i.htmlFor="guest-name";const n=T("input");n.id="guest-name",n.value="Guest"===this.user.name?"":this.user.name,n.placeholder="Your name",n.maxLength=80,n.required=!0,n.setAttribute("autocomplete","nickname"),n.dataset.focus="guest-name";const s=T("p","",this.persistentGuest?"Your name and guest ID stay in this browser. No account or email is needed. You can change your name without changing your ID.":"Browser storage is unavailable. This guest profile lasts for this session."),o=P("Save Name","primary",()=>{});return o.type="submit",t.addEventListener("submit",e=>{e.preventDefault(),n.value.trim()&&(this.user={...this.user,name:n.value.trim()},this.persistentGuest=v(this.identityKey,this.user),this.editing=null,this.render(),this.announce("Guest name saved."))}),t.append(i,n,s,o),e.append(t),e}renderPins(){this.pins.classList.toggle("focused",!!this.activeId&&!this.draft);const e=this.settings;if(this.pins.classList.toggle("small","small"===e.pinSize),this.pins.classList.toggle("resolved-gray","gray"===e.resolvedPins),this.pins.style.setProperty("--cw-accent",this.pinColor()),this.activeId){const e=T("div","focus-ring");e.hidden=!0,this.pins.append(e)}const t=T("div","focus-ring hover-ring");t.hidden=!0,this.pins.append(t);const i=this.pageComments(),n=this.config.hideSidebar?{...we,status:this.filters.status}:this.filters,s=new Set($e(i,n,this.filterContext("page")).map(e=>e.id));for(const[r,a]of i.entries()){if(a.id!==this.activeId&&!s.has(a.id))continue;const t=!this.saving&&this.canMove(a),i=P(`Comment ${r+1} by ${a.author}: ${a.text.slice(0,100)}`,`pin${a.resolved?" resolved":""}${this.highlightId===a.id?" highlight":""}${this.hoverId===a.id?" hovered":""}${t?" movable":""}`,()=>{this.suppressPinClick?this.suppressPinClick=!1:this.navigateToComment(a.id)});t&&(i.title+=". Drag to move.",i.addEventListener("pointerdown",e=>this.startPinDrag(e,a))),i.replaceChildren(document.createTextNode("initials"===e.pinLabel?I(a.author):String(r+1))),i.dataset.id=a.id,i.setAttribute("aria-pressed",String(this.activeId===a.id)),this.pins.append(i)}const o=T("div","focus-ring pick-ring");if(o.hidden=!0,this.pins.append(o),this.placing){const e=T("span","pin preview","+");e.hidden=!0,this.pins.append(e)}if(this.draft){const e=T("span","pin","+"),t=this.position({...this.draft,...this.draft.position});t?(e.style.left=`${t.x}px`,e.style.top=`${t.y}px`):e.hidden=!0,this.pins.append(e)}}}function Ke(e={}){if("undefined"==typeof document||!document.body)throw new Error("Initialize Overplay in the browser after the page has mounted.");return new je(e)}const He=Ke;return e.APIAdapter=class{constructor(e){this.config=e}async request(e,t="GET",i){const n="function"==typeof this.config.headers?await this.config.headers():this.config.headers,s=new URL(`${this.config.baseUrl.replace(/\/$/,"")}${e}`,window.location.href);this.config.projectId&&s.searchParams.set("projectId",this.config.projectId);const o=await fetch(s,{method:t,credentials:this.config.credentials??"same-origin",headers:{...void 0!==i?{"Content-Type":"application/json"}:{},...n},body:void 0!==i?JSON.stringify(i):void 0});if(!o.ok)throw new Error(`Could not ${"GET"===t?"load":"save"} comments (${o.status}).`);if("GET"===t&&204!==o.status)return o.json()}async loadComments(){var e;return l(await this.request((null==(e=this.config.endpoints)?void 0:e.load)??"/comments"))}async saveComments(e){var t;await this.request((null==(t=this.config.endpoints)?void 0:t.save)??"/comments","POST",e)}async upsertComment(e){var t;await this.request(`${(null==(t=this.config.endpoints)?void 0:t.save)??"/comments"}/${encodeURIComponent(e.id)}`,"PUT",e)}async deleteComment(e){var t;await this.request(`${(null==(t=this.config.endpoints)?void 0:t.save)??"/comments"}/${encodeURIComponent(e)}`,"DELETE")}async addReply(e,t){var i;await this.request(`${(null==(i=this.config.endpoints)?void 0:i.save)??"/comments"}/${encodeURIComponent(e)}/replies`,"POST",t)}async setResolved(e,t){var i;await this.request(`${(null==(i=this.config.endpoints)?void 0:i.save)??"/comments"}/${encodeURIComponent(e)}`,"PATCH",{resolved:t})}},e.HostedAdapter=p,e.LocalStorageAdapter=u,e.init=He,e.initOverplay=Ke,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),e}({});
|
|
1
|
+
var Overplay=function(e){"use strict";var t=Object.defineProperty,i=(e,i,n)=>((e,i,n)=>i in e?t(e,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[i]=n)(e,"symbol"!=typeof i?i+"":i,n);function n(e){if(!e||"object"!=typeof e||Array.isArray(e))throw new Error("Invalid comment data.");return e}function s(e,t){if("string"!=typeof e||!e.trim())throw new Error(`Invalid ${t}.`);return e}function o(e){const t=new Date(e);if(!Number.isFinite(t.getTime()))throw new Error("Invalid comment date.");return t}function r(e){const t=n(e);return{id:s(t.id,"reply ID"),text:s(t.text,"reply text"),author:s(t.author,"author"),authorId:"string"==typeof t.authorId?t.authorId:void 0,via:"string"==typeof t.via?t.via.slice(0,60):void 0,avatarUrl:"string"==typeof t.avatarUrl?t.avatarUrl:void 0,timestamp:o(t.timestamp),commentId:s(t.commentId,"comment ID")}}function a(e){if(!Array.isArray(e))return{};const t=(e,t)=>"string"==typeof e&&e.trim()?e.trim().slice(0,t):void 0,i=e.slice(0,6).flatMap(e=>{const i=e&&"object"==typeof e?e:{},n=i.target&&"object"==typeof i.target?i.target:{},s=t(n.selector,500);if(!["press","hover","focus"].includes(i.action)||!s)return[];const o=t(n.role,40),r=t(n.name,120),a=t(n.tag,40);return[{action:i.action,target:{selector:s,...o?{role:o}:{},...r?{name:r}:{},...a?{tag:a}:{}}}]});return i.length?{reveal:i}:{}}function l(e){if(!Array.isArray(e))throw new Error("Expected a list of comments.");return e.map(e=>{const t=n(e);if("number"!=typeof t.x||"number"!=typeof t.y||!Number.isFinite(t.x)||!Number.isFinite(t.y))throw new Error("Invalid comment position.");const i=t.anchor?n(t.anchor):null,l=t.element&&"object"==typeof t.element?t.element:null,c=e=>"string"==typeof e&&e.trim()?e.trim().slice(0,120):void 0;return{id:s(t.id,"comment ID"),text:s(t.text,"comment text"),author:s(t.author,"author"),authorId:"string"==typeof t.authorId?t.authorId:void 0,via:"string"==typeof t.via?t.via.slice(0,60):void 0,revision:"number"==typeof t.revision?t.revision:void 0,updatedAt:"string"==typeof t.updatedAt?t.updatedAt:void 0,avatarUrl:"string"==typeof t.avatarUrl?t.avatarUrl:void 0,timestamp:o(t.timestamp),x:t.x,y:t.y,resolved:!0===t.resolved,pageUrl:s(t.pageUrl,"page URL"),pageTitle:"string"==typeof t.pageTitle&&t.pageTitle.trim()?t.pageTitle.trim().slice(0,300):void 0,replies:Array.isArray(t.replies)?t.replies.map(r):[],selector:"string"==typeof t.selector?t.selector:void 0,element:l&&c(l.label)?{label:c(l.label),...c(l.place)?{place:c(l.place)}:{},...a(l.reveal)}:void 0,anchor:i&&"number"==typeof i.x&&"number"==typeof i.y&&Number.isFinite(i.x)&&Number.isFinite(i.y)?{x:Math.max(0,Math.min(1,i.x)),y:Math.max(0,Math.min(1,i.y))}:void 0}})}function c(e){return l(e)}function d(e){const t=e.replace(/^\?/,"").split("&").filter(e=>{try{return"cw_comment"!==decodeURIComponent(e.split("=")[0].replace(/\+/g," "))}catch{return!0}}).join("&");return t?"?"+t:""}const h={"comments.artsvit.com":"https://overplay.app"};class p{constructor(e,t,n,s){i(this,"base"),i(this,"key"),i(this,"accessToken",""),i(this,"expiresAt",0),i(this,"initialized",!1),i(this,"pending"),i(this,"cancelSignIn"),i(this,"user"),this.projectId=t,this.page=n,this.sessionChanged=s;const o=new URL(e);if("https:"!==o.protocol&&("http:"!==o.protocol||!["localhost","127.0.0.1"].includes(o.hostname)))throw new Error("serverUrl must use HTTPS.");if(o.username||o.password||o.search||o.hash||"/"!==o.pathname)throw new Error("serverUrl must be a service origin without a path.");var r;this.base=(r=o.origin,h[new URL(r).hostname]??r),this.key=`overplay:${this.base}:${t}:session`;try{const e=JSON.parse(sessionStorage.getItem(this.key)||"null");(null==e?void 0:e.expiresAt)>Date.now()&&(this.accessToken=e.accessToken,this.expiresAt=e.expiresAt)}catch{}}get signedIn(){return!!this.user&&this.expiresAt>Date.now()}clear(){this.accessToken="",this.expiresAt=0,this.user=void 0;try{sessionStorage.removeItem(this.key)}catch{}this.sessionChanged()}async request(e,t="GET",i){const n=new URL(`/api${e}`,this.base);n.searchParams.set("projectId",this.projectId);const s=await fetch(n,{method:t,credentials:"omit",headers:{...void 0!==i?{"Content-Type":"application/json"}:{},...this.accessToken?{Authorization:`Bearer ${this.accessToken}`}:{}},body:void 0===i?void 0:JSON.stringify(i)}),o=await s.json().catch(()=>null);if(!s.ok)throw(401===s.status||403===s.status&&"GET"===t)&&this.clear(),new Error((null==o?void 0:o.error)||`Comment service returned ${s.status}.`);if(null===o)throw new Error("Comment service returned an invalid response.");return o}async initialize(){if(!this.initialized&&(this.initialized=!0,this.accessToken))try{this.user=(await this.request("/me")).user,this.sessionChanged(this.user)}catch(e){throw this.accessToken&&(this.initialized=!1),e}}signIn(){if(this.pending)return this.pending;const e=window.open("about:blank",`overplay-${this.projectId}`,"popup,width=520,height=760");return e?(this.pending=new Promise((t,i)=>{let n=!1;const s=s=>{n||(n=!0,window.removeEventListener("message",a),clearInterval(l),clearTimeout(c),e.close(),this.pending=void 0,this.cancelSignIn=void 0,s?i(s):t())},o=Array.from(crypto.getRandomValues(new Uint8Array(32)),e=>e.toString(16).padStart(2,"0")).join("");let r=!1;const a=t=>{var i;r||t.origin!==this.base||t.source!==e||"overplay:authorization"!==(null==(i=t.data)?void 0:i.type)||t.data.projectId!==this.projectId||"string"!=typeof t.data.code||(r=!0,(async()=>{const e=await this.request("/connect/token","POST",{code:t.data.code,verifier:o});if(!n)if(this.accessToken=e.accessToken,this.expiresAt=e.expiresAt,this.user=(await this.request("/me")).user,n)this.clear();else{this.initialized=!0;try{sessionStorage.setItem(this.key,JSON.stringify({accessToken:this.accessToken,expiresAt:this.expiresAt}))}catch{}this.sessionChanged(this.user),s()}})().catch(e=>{this.clear(),s(e instanceof Error?e:new Error("Sign-in failed."))}))},l=setInterval(()=>{e.closed&&!r&&s(new Error("Sign-in window was closed."))},750),c=setTimeout(()=>s(new Error("Sign-in timed out. Please try again.")),3e5);this.cancelSignIn=()=>s(new Error("Widget was closed.")),window.addEventListener("message",a),crypto.subtle.digest("SHA-256",(new TextEncoder).encode(o)).then(t=>{if(n)return;const i=btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),s=new URL("/connect",this.base);s.search=new URLSearchParams({projectId:this.projectId,origin:location.origin,challenge:i}).toString(),e.location.href=s.href}).catch(()=>s(new Error("Secure sign-in is unavailable.")))}),this.pending):Promise.reject(new Error("Allow popups to sign in to Overplay."))}async signOut(){try{this.accessToken&&await this.request("/connect/logout","POST",{})}finally{this.clear()}}destroy(){var e;null==(e=this.cancelSignIn)||e.call(this)}async loadComments(){if(await this.initialize(),this.expiresAt&&this.expiresAt<=Date.now()&&this.clear(),!this.signedIn)return[];const e=this.accessToken,t=[];let i="";do{const e=new URLSearchParams({after:i}),n=await this.request(`/comments?${e}`);t.push(...n.comments),i=n.next||""}while(i);return e===this.accessToken&&this.signedIn?l(t):[]}subscribeToChanges(e){let t=!1,i=!1;const n=async()=>{if(i||t||"hidden"===document.visibilityState||!this.user)return;t=!0;const n=this.page(),s=this.accessToken;try{const t=await this.loadComments();!i&&this.signedIn&&s===this.accessToken&&n===this.page()&&e(t)}catch{}finally{t=!1}},s=setInterval(()=>{n()},3e4),o=()=>{"visible"===document.visibilityState&&n()};return document.addEventListener("visibilitychange",o),()=>{i=!0,clearInterval(s),document.removeEventListener("visibilitychange",o)}}async saveComments(){throw new Error("Hosted storage requires individual comment mutations.")}async upsertComment(e){await this.request(`/comments/${encodeURIComponent(e.id)}`,"PUT",e)}async deleteComment(e){await this.request(`/comments/${encodeURIComponent(e)}`,"DELETE")}async addReply(e,t){await this.request(`/comments/${encodeURIComponent(e)}/replies`,"POST",t)}async setResolved(e,t){await this.request(`/comments/${encodeURIComponent(e)}`,"PATCH",{resolved:t})}}class u{constructor(e="overplay-comments"){this.storageKey=e}async loadComments(){const e=localStorage.getItem(this.storageKey);return null===e?[]:l(JSON.parse(e))}async saveComments(e){localStorage.setItem(this.storageKey,JSON.stringify(e))}async upsertComment(e){await this.change(t=>[...t.filter(t=>t.id!==e.id),e])}async deleteComment(e){await this.change(t=>t.filter(t=>t.id!==e))}async addReply(e,t){await this.change(i=>{if(!i.some(t=>t.id===e))throw new Error("This comment was removed. Refresh to see the latest notes.");return i.map(i=>i.id!==e||i.replies.some(e=>e.id===t.id)?i:{...i,replies:[...i.replies,t]})})}async setResolved(e,t){await this.change(i=>{if(!i.some(t=>t.id===e))throw new Error("This comment was removed. Refresh to see the latest notes.");return i.map(i=>i.id===e?{...i,resolved:t}:i)})}async change(e){const t=async()=>this.saveComments(e(await this.loadComments()));"undefined"!=typeof navigator&&navigator.locks?await navigator.locks.request(`overplay:${this.storageKey}`,t):await t()}subscribeToChanges(e){const t=t=>{t.storageArea!==localStorage||t.key!==this.storageKey&&null!==t.key||this.loadComments().then(e).catch(()=>{})};return window.addEventListener("storage",t),()=>window.removeEventListener("storage",t)}}function m(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();const e=crypto.getRandomValues(new Uint8Array(16));e[6]=15&e[6]|64,e[8]=63&e[8]|128;const t=Array.from(e,e=>e.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function g(e){if(!e||"string"!=typeof e.id||!e.id.trim()||"string"!=typeof e.name||!e.name.trim())throw new Error("A user needs a stable ID and a name.");const t="owner"===e.role||"admin"===e.role||"member"===e.role?{role:e.role}:{};return{id:e.id.trim(),name:e.name.trim().slice(0,80),avatarUrl:e.avatarUrl,...t}}function f(e){let t;try{const i=localStorage.getItem(e);i&&(t=g(JSON.parse(i)))}catch{}const i=t??{id:m(),name:"Guest"};return{user:i,persistent:v(e,i)}}function v(e,t){try{return localStorage.setItem(e,JSON.stringify(t)),!0}catch{return!1}}function x(e,t,i){const n=[],s=(e,s,o,r)=>{t.has(e)||(t.add(e),r.authorId!==i&&n.push({kind:s,commentId:o,author:r.author,avatarUrl:r.avatarUrl,text:r.text}))};for(const o of e){s(o.id,"comment",o.id,o);for(const e of o.replies)s(`${o.id}/${e.id}`,"reply",o.id,e)}return n}function w(e,t){return e.length===t.length&&JSON.stringify(e)===JSON.stringify(t)}const b="4.2.0",y="overplay";function k(e,t){return`Update the Overplay widget in this project from version ${e} to ${t}.\n\nSteps:\n1. Find the package manager (look for package-lock.json, pnpm-lock.yaml, yarn.lock or bun.lockb) and update the package "${y}" to ${t}:\n npm install ${y}@${t} (or: pnpm add ${y}@${t}, yarn add ${y}@${t}, bun add ${y}@${t})\n2. Read the release notes from ${e} to ${t}: https://github.com/artemsvit/Overplay-Community/blob/main/CHANGELOG.md\n If a release lists breaking changes, update our code to match. Keep serverUrl, projectId and the other options as they are.\n3. Stop the dev server and clear the bundler cache, so the old widget is not served again:\n - Vite: delete node_modules/.vite\n - Next.js: delete .next\n - Nuxt: delete .nuxt and node_modules/.cache\n - Other tools (webpack, Parcel, Astro, SvelteKit): delete node_modules/.cache, .parcel-cache, .astro or .svelte-kit if they exist.\n4. Start the dev server again and tell me to hard-reload the browser (Cmd+Shift+R or Ctrl+Shift+R).\n5. Run the project's type check and build, and fix any errors.\n6. When you finish, list the files you changed. The update is done when the widget no longer shows "Version ${t} is available".`}const C={indigo:{label:"Indigo",color:"#575ce5"},violet:{label:"Violet",color:"#8048d8"},blue:{label:"Blue",color:"#0068f9"},teal:{label:"Teal",color:"#0f8a8c"},amber:{label:"Amber",color:"#b97a06"},orange:{label:"Orange",color:"#d9641e"},red:{label:"Red",color:"#d23c3c"},pink:{label:"Pink",color:"#d0427f"},graphite:{label:"Graphite",color:"#242736"}},S={theme:["light","dark","system"],pinColor:["site","indigo","violet","blue","teal","amber","orange","red","pink","graphite"],buttonColor:["default","site","indigo","violet","blue","teal","amber","orange","red","pink"],resolvedPins:["green","gray"],pinSize:["regular","small"],pinLabel:["number","initials"],pushContent:[!0,!1],notifications:[!0,!1],shortcut:[!0,!1]};function E(e,t){const i={...t};try{const t=JSON.parse(localStorage.getItem(e)||"{}");for(const e of Object.keys(S))S[e].includes(t[e])&&Object.assign(i,{[e]:t[e]})}catch{}return i}function A(e,t,i){const n=Object.fromEntries(Object.entries(t).filter(([e,t])=>i[e]!==t));try{return Object.keys(n).length?localStorage.setItem(e,JSON.stringify(n)):localStorage.removeItem(e),!0}catch{return!1}}function I(e){const t=e.trim().split(/\s+/).filter(Boolean);return(t.length>1?`${[...t[0]][0]}${[...t[t.length-1]][0]}`:[...t[0]??"?"].slice(0,2).join("")).toUpperCase()}function T(e,t="",i){const n=document.createElement(e);return t&&(n.className=t),void 0!==i&&(n.textContent=i),n}const $={comment:"M21 11.5a8.4 8.4 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.4 8.4 0 0 1-3.8-.9L3 21l1.9-5.7a8.4 8.4 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.4 8.4 0 0 1 3.8-.9h.5a8.5 8.5 0 0 1 8 8v.5Z",plus:"M12 5v14M5 12h14",close:"m6 6 12 12M6 18 18 6",check:"m5 12 4 4L19 6",back:"m12 5-7 7 7 7M5 12h14",arrow:"M12 19V5m-6 6 6-6 6 6",refresh:"M20.5 12a8.5 8.5 0 1 1-2.6-6.1L20.5 8.5M20.5 3.5v5h-5",open:"M7 17 17 7M9 7h8v8",copy:"M9 9h11v11H9zM5 15H4V4h11v1",sparkle:"M10 3.5c.6 3.9 2.6 5.9 6.5 6.5-3.9.6-5.9 2.6-6.5 6.5-.6-3.9-2.6-5.9-6.5-6.5 3.9-.6 5.9-2.6 6.5-6.5ZM18 14.5c.3 1.9 1.1 2.7 3 3-1.9.3-2.7 1.1-3 3-.3-1.9-1.1-2.7-3-3 1.9-.3 2.7-1.1 3-3Z",trash:"M3 6h18M9 6V4h6v2M5 6l1 14h12l1-14M10 10v6m4-6v6",pin:"M12 21s7-6 7-13A7 7 0 0 0 5 8c0 7 7 13 7 13ZM12 6v4M10 8h4",search:"m21 21-5-5M18 10a8 8 0 1 1-16 0 8 8 0 0 1 16 0Z",eye:"M2.5 12S6 5.5 12 5.5 21.5 12 21.5 12 18 18.5 12 18.5 2.5 12 2.5 12ZM12 14.8a2.8 2.8 0 1 0 0-5.6 2.8 2.8 0 0 0 0 5.6Z",eyeOff:"M3 3l18 18M10.6 5.6A9 9 0 0 1 12 5.5c6 0 9.5 6.5 9.5 6.5a16 16 0 0 1-2.9 3.6M6.5 6.9A16 16 0 0 0 2.5 12S6 18.5 12 18.5a9 9 0 0 0 4.6-1.3M10 10a2.8 2.8 0 0 0 4 4",unlink:"M4.5 4.5h15v15h-15zM9.5 9.5l5 5M14.5 9.5l-5 5",dock:"M4 5h16v14H4zM15 5v14",settings:"M4 7h9m4 0h3M4 17h3m4 0h9M15 5v4M9 15v4",edit:"M4 20h4L19 9l-4-4L4 16v4ZM13 7l4 4",signin:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4M10 17l5-5-5-5M15 12H3",signout:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4M16 17l5-5-5-5M21 12H9",more:"M5 12h.01M12 12h.01M19 12h.01",popout:"M14 4h6v6M20 4l-8 8M18 14v5H5V6h5"};function P(e){const t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("fill","none"),t.setAttribute("stroke","currentColor"),t.setAttribute("stroke-width","1.65"),t.setAttribute("stroke-linecap","round"),t.setAttribute("stroke-linejoin","round"),t.setAttribute("aria-hidden","true");const i=document.createElementNS(t.namespaceURI,"path");return i.setAttribute("d",$[e]),t.append(i),t}function L(e,t,i,n){const s=T("button",t);return s.type="button",s.setAttribute("aria-label",e),s.title=e,n&&s.append(P(n)),t.includes("icon-button")||s.append(T("span","",e)),s.addEventListener("click",i),s}function M(e,t){const i=T("span","avatar",I(e));if(i.setAttribute("aria-hidden","true"),t)try{const e=new URL(t,location.href);if("https:"===e.protocol||"http:"===e.protocol&&e.origin===location.origin){const t=T("img");t.src=e.href,t.alt="",t.referrerPolicy="no-referrer",t.complete&&t.naturalWidth?i.replaceChildren(t):t.addEventListener("load",()=>i.replaceChildren(t))}}catch{}return i}const R={accent:"#0068f9","accent-strong":"#0055d4","accent-soft":"#eef4ff","accent-line":"#d3e3fd","accent-focus":"#99c2ff",ink:"#121722","ink-soft":"#3a3f4a",muted:"#636874",subtle:"#8a8e97",surface:"#ffffff",canvas:"#f7f7f8","surface-soft":"#f0f1f3",line:"#e8e9ec","line-strong":"#dedfe3","avatar-bg":"#e8f1ff","avatar-ink":"#2560c4",inverse:"#121722","on-inverse":"#ffffff","inverse-muted":"#b8bcc6",resolved:"#0f9a6c","resolved-text":"#0b7a55","resolved-soft":"#e7f6ef",danger:"#c43d3d","danger-soft":"#fff4f3","danger-line":"#f3cfcf",warning:"#745320","warning-soft":"#fff8e8","warning-line":"#ebd59f",ai:"#6d4fe0","ai-soft":"#f6f3ff","ai-line":"#e3dbff","radius-sm":"6px",radius:"10px","radius-md":"12px","radius-lg":"16px","radius-xl":"26px","radius-pill":"999px","shadow-sm":"0 0 0 1px #1217221a,0 1px 2px #12172229",shadow:"0 1px 3px #1217221a,0 16px 32px -12px #12172233",font:'"Inter",-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif'},z={"accent-strong":"color-mix(in srgb,var(--cw-accent) 66%,#ffffff)","accent-soft":"color-mix(in srgb,var(--cw-accent) 18%,#16181d)","accent-line":"color-mix(in srgb,var(--cw-accent) 42%,#16181d)","accent-focus":"color-mix(in srgb,var(--cw-accent) 60%,#16181d)",ink:"#eef0f3","ink-soft":"#c6c9d0",muted:"#9a9ea8",subtle:"#767a84",surface:"#16181d",canvas:"#0e0f12","surface-soft":"#1f2228",line:"#262930","line-strong":"#33373f","avatar-bg":"#1b2a45","avatar-ink":"#9cc3ff",inverse:"#23262d","inverse-muted":"#a6aab3",resolved:"#16a877","resolved-text":"#48d3a0","resolved-soft":"#13302a",danger:"#ec6a6a","danger-soft":"#341c21","danger-line":"#5b2b31",warning:"#efc56e","warning-soft":"#2f2718","warning-line":"#57472a",ai:"#a994ff","ai-soft":"#1d1a2c","ai-line":"#3b3263","shadow-sm":"0 0 0 1px #ffffff14,0 1px 2px #00000066",shadow:"0 1px 3px #00000066,0 16px 40px -12px #000000b3"};function q(e=R){return Object.entries(e).map(([e,t])=>`--cw-${e}:${t};`).join("")}const O=`\n:host{all:initial;${q()}color:var(--cw-ink);font:16px/1.5 var(--cw-font);letter-spacing:normal;text-align:left;color-scheme:light}\n:host([data-theme=dark]){${q(z)}color-scheme:dark}\n@media(prefers-color-scheme:dark){:host([data-theme=system]){${q(z)}color-scheme:dark}}\n:host>div{font:16px/1.5 var(--cw-font);color:var(--cw-ink);letter-spacing:normal;text-align:left}*,*::before,*::after{box-sizing:border-box}button,input,textarea,select{font:inherit}button{cursor:pointer}button:disabled{cursor:default;opacity:.45}button:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible{outline:3px solid var(--cw-accent);outline-offset:3px}button{color:inherit}svg{width:18px;height:18px;flex-shrink:0}button{touch-action:manipulation}img{max-width:100%}[hidden]{display:none!important}\n.launcher{position:fixed;bottom:24px;right:24px;display:flex;align-items:center;justify-content:center;width:52px;height:52px;border:1px solid #ffffff24;background:var(--cw-inverse);color:var(--cw-on-inverse);padding:0;border-radius:50%;box-shadow:0 6px 24px #12172233;font-weight:600;font-size:16px;pointer-events:auto;touch-action:none;user-select:none;-webkit-user-select:none;cursor:grab;transition:transform .16s,box-shadow .16s}.launcher:hover{transform:translateY(-2px);box-shadow:0 8px 28px #20243733}.launcher.dragging{cursor:grabbing;transition:none;transform:scale(1.06);box-shadow:0 12px 32px #2024374d}.launcher[aria-expanded=true]{background:var(--cw-accent)}.launcher>svg{width:23px;height:23px}.badge{position:absolute;top:-5px;right:-5px;font-weight:650;font-size:12px;line-height:18px;min-width:22px;height:22px;border:2px solid var(--cw-surface);border-radius:999px;background:var(--cw-accent);color:#fff;text-align:center;padding:0 4px}.launcher[aria-expanded=true] .badge{background:var(--cw-inverse)}\n.panel{position:fixed;top:0;right:0;bottom:0;width:400px;max-width:100vw;display:flex;flex-direction:column;background:var(--cw-surface);border-left:1px solid var(--cw-line);box-shadow:var(--cw-shadow);pointer-events:auto;overflow:hidden}.panel.entering{animation:slide-in .2s ease-out}.panel.left{right:auto;left:0;border-left:0;border-right:1px solid var(--cw-line);--cw-slide:-24px}.detail{display:flex;flex-direction:column;flex:1;min-height:0}.detail.entering{animation:enter .16s ease-out}.detail:focus{outline:0}.head{display:flex;align-items:center;gap:10px;padding:22px 20px 16px}.brand-icon{width:34px;height:34px;display:grid;place-items:center;background:var(--cw-accent-soft);color:var(--cw-accent);border-radius:50%}.heading{flex:1;min-width:0}.heading h2{font-size:19px;line-height:1.3;letter-spacing:-.4px;margin:0;font-weight:650}.eyebrow{font-size:12px;font-weight:700;letter-spacing:1.4px;color:var(--cw-muted);text-transform:uppercase;margin:0 0 4px}.subtext{color:var(--cw-muted);font-size:14px;margin:4px 0 0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.icon-button{width:32px;height:32px;display:inline-grid;place-items:center;background:transparent;border:0;border-radius:50%;flex-shrink:0}.icon-button:hover{background:var(--cw-surface-soft)}.icon-button.danger{color:var(--cw-danger)}.icon-button svg{width:16px;height:16px}.icon-button.outlined{width:42px;height:42px;border:1px solid var(--cw-line-strong);border-radius:50%;color:var(--cw-ink-soft)}.icon-button.outlined svg{width:18px;height:18px}.icon-button.busy:disabled{opacity:1;color:var(--cw-accent)}.icon-button.busy svg{animation:spin .9s linear infinite}.toolbar{padding:0 20px 16px;display:flex;gap:10px;align-items:center}.primary{border:0;border-radius:var(--cw-radius-pill);background:var(--cw-accent);color:#fff;display:inline-flex;gap:7px;align-items:center;justify-content:center;padding:10px 16px;font-size:14px;font-weight:550;white-space:nowrap;box-shadow:inset 0 -1px 0 #12172238;transition:filter .16s}.primary:hover{filter:brightness(.94)}.toolbar .primary{flex:1}.quiet{border:1px solid var(--cw-line-strong);background:var(--cw-surface);color:var(--cw-ink);border-radius:var(--cw-radius-pill);padding:9px 16px;font-size:14px}.quiet:hover{background:var(--cw-canvas)}.quiet.update{display:inline-flex;align-items:center;gap:6px;white-space:nowrap;flex-shrink:0;color:var(--cw-accent);border-color:var(--cw-accent-line);background:var(--cw-accent-soft);font-weight:600}.quiet.update:hover{border-color:var(--cw-accent)}.quiet.update svg{width:14px;height:14px}.scope{display:grid;grid-template-columns:1fr 1fr;gap:4px;margin:0 20px 8px;padding:4px;background:var(--cw-surface-soft);border-radius:var(--cw-radius-pill)}.scope-option{display:flex;gap:7px;align-items:center;justify-content:center;border:0;background:transparent;border-radius:var(--cw-radius-pill);padding:8px 6px;font-size:14px;font-weight:550;color:var(--cw-muted);white-space:nowrap}.scope-option:hover{color:var(--cw-ink)}.scope-option[aria-pressed=true]{background:var(--cw-surface);color:var(--cw-ink);box-shadow:0 1px 3px #2024371f}.scope-option[aria-pressed=true] .count{background:var(--cw-accent-soft);color:var(--cw-accent)}.tabs{display:grid;grid-template-columns:repeat(3,1fr);gap:4px;margin:0 20px 8px;padding:4px;border:1px solid var(--cw-line);border-radius:var(--cw-radius-pill)}.tab{display:flex;gap:7px;align-items:center;justify-content:center;border:0;border-radius:var(--cw-radius-pill);background:transparent;padding:7px 6px;color:var(--cw-muted);font-size:14px;font-weight:550;white-space:nowrap}.tab[aria-pressed=true]{color:var(--cw-on-inverse);background:var(--cw-inverse)}.tab[aria-pressed=true] .count{background:#ffffff2e;color:var(--cw-on-inverse)}.count{background:var(--cw-surface-soft);padding:0 6px;border-radius:5px;font-size:12px;line-height:18px}.search{position:relative;margin:4px 20px 8px}.search>svg{position:absolute;left:11px;top:11px;width:15px;height:15px;color:var(--cw-subtle);pointer-events:none}.search input{border:1px solid var(--cw-line);border-radius:var(--cw-radius);background:var(--cw-canvas);width:100%;padding:9px 38px 9px 34px;color:var(--cw-ink);font-size:14px}.search input::placeholder{color:var(--cw-subtle)}.search input::-webkit-search-cancel-button{-webkit-appearance:none;appearance:none}.search-clear{position:absolute;right:5px;top:50%;transform:translateY(-50%);width:28px;height:28px;color:var(--cw-muted)}.search-clear svg{width:14px;height:14px}.people{display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin:0 20px 6px}.filter-chip{display:inline-flex;align-items:center;gap:6px;border:1px solid var(--cw-line);background:var(--cw-surface);color:var(--cw-ink-soft);border-radius:999px;padding:4px 6px 4px 11px;font-size:13px;font-weight:600;white-space:nowrap}.filter-chip:hover{background:var(--cw-canvas)}.filter-chip[aria-pressed=true]{background:var(--cw-accent-soft);border-color:var(--cw-accent-line);color:var(--cw-accent)}.filter-chip[aria-pressed=true] .count{background:var(--cw-surface);color:var(--cw-accent)}.select{position:relative;display:inline-flex;min-width:0;max-width:220px;color:var(--cw-muted)}.select::after{content:'';position:absolute;right:12px;top:50%;width:6px;height:6px;border:solid currentColor;border-width:0 1.5px 1.5px 0;transform:translateY(-70%) rotate(45deg);pointer-events:none}.select select{appearance:none;-webkit-appearance:none;border:1px solid var(--cw-line);background:var(--cw-surface);color:var(--cw-ink-soft);border-radius:999px;padding:5px 30px 5px 11px;font-size:13px;font-weight:600;line-height:18px;max-width:100%;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;cursor:pointer}.select select:hover{background:var(--cw-canvas)}.select.chosen{color:var(--cw-accent)}.select.chosen select{background:var(--cw-accent-soft);border-color:var(--cw-accent-line);color:var(--cw-accent)}.select option{color:var(--cw-ink);background:var(--cw-surface)}.link-button{margin-left:auto;border:0;background:transparent;color:var(--cw-accent);font-size:13px;font-weight:600;padding:4px 2px;white-space:nowrap}.link-button:hover{text-decoration:underline}mark.hit{background:color-mix(in srgb,var(--cw-accent) 22%,transparent);color:inherit;border-radius:3px;padding:0 1px;-webkit-box-decoration-break:clone;box-decoration-break:clone}.note-match{display:flex;align-items:center;gap:5px;margin:4px 0 0 31px;font-size:12.5px;line-height:1.5;color:var(--cw-muted);min-width:0}.note-match svg{width:12px;height:12px}.note-match-label{font-weight:600;color:var(--cw-ink-soft);white-space:nowrap;flex-shrink:0;max-width:45%;overflow:hidden;text-overflow:ellipsis}.note-match-text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.list{flex:1;overflow:auto;overscroll-behavior:contain;padding:8px 12px 16px;min-height:0}.list-title{display:flex;align-items:center;gap:8px;padding:12px 8px 6px;color:var(--cw-muted);font-size:12px;letter-spacing:1.15px;text-transform:uppercase;font-weight:600}.page-path{text-transform:none;letter-spacing:0;font-size:13px;color:var(--cw-ink-soft);font-family:ui-monospace,SFMono-Regular,Menlo,monospace;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.page-name{text-transform:none;letter-spacing:0;font-size:13px;font-weight:600;color:var(--cw-ink-soft);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.here{flex-shrink:0;padding:0 6px;border-radius:5px;background:var(--cw-accent-soft);color:var(--cw-accent);font-size:11px;letter-spacing:.4px;line-height:18px}.go{margin-left:auto;display:inline-flex;align-items:center;gap:4px;color:var(--cw-accent);font-weight:600}.note.current{background:var(--cw-accent-soft);border-color:var(--cw-accent-line)}.note{display:block;text-align:left;width:100%;border:1px solid transparent;background:var(--cw-surface);color:var(--cw-ink);border-radius:10px;padding:9px 10px;margin-bottom:2px}.note .note-header .via{color:var(--cw-muted);font-size:10px;max-width:110px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.note-header{margin-bottom:4px;gap:7px}.note .avatar{width:24px;height:24px;font-size:11px}.note .name{font-size:13px}.note .time{margin-left:0}.note-meta{margin-left:auto;display:inline-flex;align-items:center;gap:8px;font-size:12px;color:var(--cw-muted);white-space:nowrap;flex-shrink:0}.note-meta svg{width:12px;height:12px}.note:hover{background:var(--cw-canvas);border-color:var(--cw-line)}.note-header{display:flex;align-items:center;gap:8px;margin-bottom:9px}.avatar{display:inline-grid;place-items:center;width:29px;height:29px;border-radius:50%;background:var(--cw-avatar-bg);color:var(--cw-avatar-ink);font-size:12px;font-weight:700;flex-shrink:0;overflow:hidden}.avatar img{height:100%;width:100%;object-fit:cover}.name{font-size:14px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.time{font-size:12px;color:var(--cw-muted);margin-left:auto;white-space:nowrap}.note-text{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;margin:0 0 0 31px;line-height:1.5;font-size:14px;color:var(--cw-ink-soft);overflow-wrap:anywhere}.note-footer{display:flex;gap:6px;align-items:center;margin:6px 0 0 31px;color:var(--cw-muted);font-size:12px}.note-footer svg{width:12px;height:12px}.note-number{color:var(--cw-accent);font-weight:700}.status{display:inline-flex;align-items:center;gap:4px}.status.resolved{color:var(--cw-resolved-text)}.status-dot{width:5px;height:5px;background:var(--cw-accent);border-radius:50%;display:inline-block}.empty{height:100%;min-height:230px;display:flex;align-items:center;justify-content:center;text-align:center;padding:32px 16px}.empty-icon{position:relative;display:grid;place-items:center;margin:0 auto 18px;width:64px;height:64px;border:1px solid var(--cw-line);border-radius:21px;transform:rotate(-7deg);background:var(--cw-canvas);color:var(--cw-accent)}.empty-icon svg{width:27px;height:27px}.empty h3{font-size:17px;letter-spacing:-.25px;margin:0 0 8px}.empty p{font-size:14px;color:var(--cw-muted);line-height:1.7;margin:0 auto 18px;max-width:230px}.footer{display:flex;align-items:center;gap:9px;border-top:1px solid var(--cw-line);padding:14px 20px;background:var(--cw-canvas)}.footer .avatar{width:25px;height:25px;font-size:11px}.identity{border:0;background:transparent;text-align:left;padding:0;min-width:0;flex:1}.identity strong{display:block;font-size:13px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.identity small{font-size:12px;color:var(--cw-muted)}.storage-label{font-size:11px;color:var(--cw-muted);text-align:right;line-height:1.5;max-width:105px}.storage-dot{display:inline-block;width:5px;height:5px;background:var(--cw-resolved);border-radius:50%;margin-right:4px}.error{padding:12px 16px;margin:12px 20px;border:1px solid var(--cw-danger-line);background:var(--cw-danger-soft);color:var(--cw-danger);border-radius:10px;font-size:14px;overflow-wrap:anywhere}.error button{display:block;margin-top:8px}.notice{position:fixed;left:50%;bottom:24px;transform:translateX(-50%);z-index:1;background:var(--cw-inverse);color:var(--cw-on-inverse);border:1px solid #ffffff20;border-radius:12px;padding:12px 15px;display:flex;align-items:center;gap:12px;font-size:14px;box-shadow:0 6px 30px #0002;pointer-events:auto;max-width:calc(100vw - 32px)}.notice kbd{font-size:12px;color:var(--cw-inverse-muted);border:1px solid #ffffff30;border-radius:4px;padding:2px 5px}.notice button{color:var(--cw-on-inverse)}.notice.beside-panel{left:calc(50% - 200px)}.notice.beside-panel.left{left:calc(50% + 200px)}.pins{position:fixed;inset:0;pointer-events:none}.pin{position:absolute;width:32px;height:36px;transform:translate(-50%,-100%);border:2px solid #fff;border-radius:15px 15px 15px 4px;background:var(--cw-accent);color:#fff;box-shadow:var(--cw-shadow-sm);display:grid;place-items:center;font-size:13px;font-weight:650;pointer-events:auto;transition:scale .15s}.pin:hover,.pin[aria-pressed=true]{scale:1.12}.pin.resolved{background:var(--cw-resolved)}.pin.highlight{animation:pulse 1s ease-out 2}.pin.hovered{animation:pulse 1s ease-out infinite;scale:1.12;opacity:1!important}.focus-ring.hover-ring{animation:none;border-style:dashed}.focus-ring{position:absolute;border:2px solid var(--cw-accent);border-radius:var(--cw-radius);background:color-mix(in srgb,var(--cw-accent) 6%,transparent);pointer-events:none;animation:enter .16s ease-out}.pick-ring{border-style:dashed;animation:none;transition:left .08s,top .08s,width .08s,height .08s}.pin:focus-visible{outline-offset:3px}.pin.preview{pointer-events:none;opacity:.7}.pin.movable{cursor:grab;touch-action:none}.pins.focused .pin:not([aria-pressed=true]):not(.dragging){opacity:.3;transition:opacity .15s,scale .15s}.pins.focused .pin:hover,.pins.focused .pin:focus-visible{opacity:1}.pin.dragging{cursor:grabbing;scale:1.15;pointer-events:none;box-shadow:var(--cw-shadow);transition:none;z-index:1}.detail-hint{margin:16px 20px 12px;color:var(--cw-muted);font-size:14px;line-height:1.6}.compose{padding:0 20px 20px}.compose textarea,.reply-bar textarea{scrollbar-width:none}\n.compose textarea::-webkit-scrollbar,.reply-bar textarea::-webkit-scrollbar{display:none}\n.compose textarea{width:100%;display:block;resize:vertical;min-height:120px;max-height:40vh;border:1px solid var(--cw-line);border-radius:var(--cw-radius);padding:12px;color:var(--cw-ink);background:var(--cw-canvas);font-size:16px;line-height:1.6}.compose textarea::placeholder{color:var(--cw-subtle)}.compose-bar{display:flex;align-items:center;gap:10px;justify-content:space-between;margin-top:12px}.compose-hint{font-size:11px;color:var(--cw-muted)}.thread-body{overflow:auto;overscroll-behavior:contain;flex:1;min-height:0;padding:18px 20px 4px}.message{padding:16px 0;border-bottom:1px solid var(--cw-line)}.message:first-child{padding-top:0}.message:last-child{border:0}.message-text{font-size:16px;line-height:1.7;white-space:pre-wrap;overflow-wrap:anywhere;margin:10px 0 0 37px}.thread-actions{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:12px 20px;border-top:1px solid var(--cw-line)}.resolve{display:inline-flex;align-items:center;gap:7px;white-space:nowrap;font-weight:600}.resolve svg{width:16px;height:16px;color:var(--cw-resolved)}.resolve:hover{border-color:var(--cw-resolved);background:var(--cw-resolved-soft);color:var(--cw-resolved-text)}.resolve.done svg{color:var(--cw-muted)}.resolve.done:hover{border-color:var(--cw-line-strong);background:var(--cw-canvas);color:var(--cw-ink)}.confirm-delete{display:flex;align-items:center;gap:8px}.danger-button{display:inline-flex;align-items:center;gap:6px;border:0;border-radius:var(--cw-radius-pill);background:var(--cw-danger);color:#fff;padding:10px 12px;font-size:14px;font-weight:600;white-space:nowrap}.danger-button svg{width:15px;height:15px}.detail-head{padding:12px 20px 16px;border-bottom:1px solid var(--cw-line)}.detail-bar{display:flex;align-items:center;justify-content:space-between;margin:0 -8px 12px -10px}.back-link{display:inline-flex;align-items:center;gap:6px;border:0;background:transparent;border-radius:var(--cw-radius-sm);padding:6px 10px;font-size:14px;font-weight:600;color:var(--cw-muted)}.back-link:hover{background:var(--cw-surface-soft);color:var(--cw-ink)}.back-link svg{width:16px;height:16px}.detail-title{display:flex;align-items:center;gap:10px;flex-wrap:wrap}.detail-title h2{font-size:20px;line-height:1.3;letter-spacing:-.4px;margin:0;font-weight:650}.detail-head .subtext{white-space:normal}.chip{display:inline-flex;align-items:center;gap:6px;padding:1px 9px;border-radius:999px;background:var(--cw-accent-soft);color:var(--cw-accent);font-size:12px;font-weight:600;line-height:20px}.chip svg{width:12px;height:12px}.chip.resolved{background:var(--cw-resolved-soft);color:var(--cw-resolved-text)}.thread .compose{padding-top:12px;border-top:1px solid var(--cw-line)}.thread textarea{min-height:88px}.anchor-status{margin:0 20px 12px;padding:12px;background:var(--cw-canvas);border:1px solid var(--cw-line);border-radius:10px;color:var(--cw-muted);font-size:13px;line-height:1.55}.anchor-head{display:flex;align-items:flex-start;gap:10px;margin-bottom:8px}.anchor-icon{display:grid;place-items:center;flex-shrink:0;width:28px;height:28px;border-radius:8px;background:var(--cw-warning-soft);color:var(--cw-warning)}.anchor-status.removed .anchor-icon{background:var(--cw-danger-soft);color:var(--cw-danger)}.anchor-icon svg{width:16px;height:16px}.anchor-titles{display:flex;flex-direction:column;min-width:0}.anchor-titles strong{color:var(--cw-ink);font-size:13px;font-weight:650;line-height:1.35}.anchor-target{color:var(--cw-ink-soft);overflow-wrap:anywhere}.identity-form{padding:0 20px 20px}.identity-form label{font-size:14px;font-weight:600;display:block;margin-bottom:7px}.identity-form input{width:100%;border:1px solid var(--cw-line);background:var(--cw-canvas);color:var(--cw-ink);padding:10px;border-radius:var(--cw-radius);margin-bottom:14px}.identity-form p{font-size:13px;color:var(--cw-muted);line-height:1.7;margin:0 0 14px}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}\n@keyframes enter{from{opacity:0;translate:0 5px}to{opacity:1;translate:0 0}}@keyframes slide-in{from{opacity:0;translate:var(--cw-slide,24px) 0}to{opacity:1;translate:0 0}}@keyframes pulse{0%{box-shadow:0 0 0 0 color-mix(in srgb,var(--cw-accent) 55%,transparent)}100%{box-shadow:0 0 0 16px transparent}}@keyframes spin{to{rotate:360deg}}@keyframes toast-out{to{opacity:0;translate:0 6px}}\n.toasts{position:fixed;right:24px;bottom:88px;width:320px;max-width:calc(100vw - 32px);display:flex;flex-direction:column;gap:8px;pointer-events:none}.toasts.left{right:auto;left:24px}.toasts.top{bottom:auto;top:88px;flex-direction:column-reverse}.toasts.beside-panel{right:424px;bottom:24px;max-width:calc(100vw - 448px)}.toasts.beside-panel.left{right:auto;left:424px}.toasts.beside-panel.top{top:24px;bottom:auto}.toast{display:flex;gap:10px;align-items:flex-start;background:var(--cw-inverse);color:var(--cw-on-inverse);border:1px solid #ffffff20;border-radius:var(--cw-radius-md,12px);padding:12px 14px;box-shadow:var(--cw-shadow,var(--cw-shadow));animation:enter .18s ease-out}.toast.leaving{animation:toast-out .2s ease-in forwards}.toast-icon{background:var(--cw-accent-soft,var(--cw-accent-soft));color:var(--cw-accent)}.toast-icon svg{width:15px;height:15px}.toast-body{min-width:0;flex:1}.toast-title{margin:0;font-size:14px;line-height:1.4;color:var(--cw-inverse-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.toast-title strong{color:var(--cw-on-inverse);font-weight:600}.toast-number{margin-left:6px;padding:0 6px;border-radius:5px;background:var(--cw-accent-soft,var(--cw-accent-soft));color:var(--cw-accent);font-size:12px;font-weight:650;line-height:18px;display:inline-block}.toast-text{margin:3px 0 0;font-size:14px;line-height:1.5;color:#fff;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;overflow-wrap:anywhere}\n.popover{position:fixed;left:0;top:0;z-index:1;width:320px;max-height:min(560px,calc(100vh - 24px));display:flex;flex-direction:column;background:var(--cw-surface);border:1px solid var(--cw-line);border-radius:var(--cw-radius-lg);box-shadow:var(--cw-shadow);pointer-events:auto;color:var(--cw-ink)}.popover>.detail{min-height:0}.popover .detail.entering{animation:pop .18s cubic-bezier(.2,.9,.3,1.15)}@keyframes pop{from{opacity:0;transform:translateY(6px) scale(.97)}}.popover.sheet{left:8px;right:8px;top:auto;bottom:8px;width:auto;max-height:75vh}\n.card-head .detail-bar{margin:0;padding:12px 12px 0 10px}.pop-head{position:relative;display:flex;align-items:center;gap:10px;padding:14px 10px 12px 14px}.panel .pop-head{padding:12px 14px 12px 20px}.pop-icon{display:grid;place-items:center;flex-shrink:0;width:30px;height:30px;border-radius:50%;background:var(--cw-accent-soft);color:var(--cw-accent)}.pop-icon svg{width:15px;height:15px}.pop-title{flex:1;min-width:0}.pop-title h2{margin:0;font-size:14px;font-weight:650;letter-spacing:-.2px;line-height:1.35}.pop-sub{margin:0;font-size:12px;line-height:1.5;color:var(--cw-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.pop-head .icon-button{width:28px;height:28px;color:var(--cw-muted)}.pop-head .icon-button:hover{background:var(--cw-surface-soft);color:var(--cw-ink)}.pop-head .icon-button svg{width:16px;height:16px}.pop-head .more svg{stroke-width:3.2}\n.pop-menu{position:absolute;top:46px;right:10px;z-index:2;min-width:190px;padding:4px;background:var(--cw-surface);border:1px solid var(--cw-line);border-radius:var(--cw-radius-md);box-shadow:var(--cw-shadow)}.menu-item{display:flex;align-items:center;gap:8px;width:100%;padding:7px 10px;border:0;border-radius:8px;background:transparent;font-size:13px;text-align:left;color:var(--cw-ink)}.menu-item:hover{background:var(--cw-surface-soft)}.menu-item svg{width:15px;height:15px;color:var(--cw-muted)}.menu-item.danger,.menu-item.danger svg{color:var(--cw-danger)}\n.thread .thread-body{flex:1;min-height:0;overflow:auto;overscroll-behavior:contain;padding:0 14px}.panel .thread .thread-body{padding:0 20px}.thread .message{padding:12px 0;border-top:1px solid var(--cw-line);border-bottom:0}.thread .message:first-child{padding-top:12px}.thread .note-header{gap:8px;margin:0}.thread .avatar{width:26px;height:26px;font-size:10px}.thread .name{font-size:14px}.thread .time{font-size:12px}.thread .message-text{margin:4px 0 0 34px;font-size:14px;line-height:1.55;color:var(--cw-ink-soft)}.panel .thread .message-text{font-size:15px}\n.thread-actions{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:10px 14px;border-top:1px solid var(--cw-line)}.panel .thread-actions{padding:12px 20px}.reply-bar{flex:1;min-width:0;display:flex;align-items:flex-end;gap:8px}.reply-bar textarea{flex:1;min-width:0;min-height:32px;max-height:120px;resize:none;padding:6px 10px;border:1px solid var(--cw-line-strong);border-radius:var(--cw-radius);background:var(--cw-surface);color:var(--cw-ink);font-size:13px;line-height:1.45;overflow:auto}.reply-bar textarea:focus-visible{outline:0;border-color:var(--cw-accent);box-shadow:0 0 0 3px var(--cw-accent-line)}.reply-bar textarea::placeholder{color:var(--cw-subtle)}.thread-actions .primary{padding:7px 12px;font-size:13px;border-radius:var(--cw-radius-pill);white-space:nowrap}.thread-actions .primary svg{width:14px;height:14px}.thread-actions .primary.resolve,.thread-actions .primary.resolve:hover{border:0;background:var(--cw-accent);color:#fff}.thread-actions .primary.resolve:hover{filter:brightness(.94)}.thread-actions .primary.resolve svg{color:currentColor}.thread-actions .status{display:inline-flex;align-items:center;gap:5px;font-size:13px;font-weight:600;color:var(--cw-resolved-text)}.thread-actions .status svg{width:14px;height:14px}.thread-actions .reopen{padding:6px 12px;font-size:13px;font-weight:500}\n.popover .anchor-status,.popover .error{margin:0 14px 10px}.new-comment .compose{margin:0 14px;padding:14px 0;border-top:1px solid var(--cw-line)}.panel .new-comment .compose{margin:0 20px;padding:16px 0 20px}.popover .compose textarea:focus-visible{outline:0;border-color:var(--cw-accent);box-shadow:0 0 0 3px var(--cw-accent-line)}.popover .new-comment .compose textarea{min-height:76px;font-size:14px}.popover .compose-hint{font-size:11px}\n.pin.below{transform:translate(-50%,0);border-radius:4px 15px 15px 15px}\n.pick-ring{border-style:solid;background:transparent}.head-actions{display:flex;align-items:center;gap:2px;margin-right:-6px}\n.head-actions>.icon-button{color:var(--cw-muted)}\n.head-actions>.icon-button:hover{color:var(--cw-ink)}\n.menu-wrap{position:relative;display:flex}\n.user-button{display:grid;place-items:center;width:36px;height:36px;padding:0;border:0;border-radius:50%;background:transparent}\n.user-button .avatar{width:28px;height:28px;font-size:11px;box-shadow:0 0 0 2px var(--cw-surface),0 0 0 3px var(--cw-line)}\n.user-button:hover .avatar,.user-button[aria-expanded=true] .avatar{box-shadow:0 0 0 2px var(--cw-surface),0 0 0 3px var(--cw-accent)}\n.quiet.sign-in{display:inline-flex;align-items:center;gap:6px;padding:6px 10px;font-size:13px;font-weight:600;margin-right:2px}\n.quiet.sign-in svg{width:14px;height:14px}\n.user-menu{top:calc(100% + 8px);right:-40px;min-width:256px;padding:6px}\n.menu-user{display:flex;align-items:center;gap:10px;padding:8px 8px 10px;margin-bottom:4px;border-bottom:1px solid var(--cw-line)}\n.menu-user .avatar{width:34px;height:34px;font-size:13px}\n.menu-user-text{min-width:0}\n.menu-user-text strong{display:block;font-size:14px;font-weight:650;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n.menu-user-text small{display:block;font-size:12px;color:var(--cw-muted)}\n.menu-note{display:flex;align-items:center;gap:2px;margin:4px 0 0;padding:8px 10px 4px;border-top:1px solid var(--cw-line);font-size:12px;color:var(--cw-muted)}\n.footer{justify-content:space-between}\n.footer-note{font-size:13px;color:var(--cw-muted)}\n.panel:focus{outline:0}.settings-tabs{grid-template-columns:1fr 1fr;margin:0 0 12px}.settings-body{flex:1;min-height:0;overflow:auto;overscroll-behavior:contain;padding:4px 20px 12px}\n.setting-group{padding:14px 0 6px}\n.setting-group+.setting-group{border-top:1px solid var(--cw-line)}\n.setting-group h3{margin:0 0 6px;font-size:12px;font-weight:650;letter-spacing:1.1px;text-transform:uppercase;color:var(--cw-muted)}\n.setting{display:flex;align-items:center;justify-content:space-between;gap:14px;padding:9px 0}\n.setting-text{min-width:0}\n.setting-text strong{display:block;font-size:14px;font-weight:600}\n.setting-text small{display:block;font-size:12px;line-height:1.5;color:var(--cw-muted)}\n.segmented{display:inline-flex;flex-shrink:0;gap:2px;padding:3px;background:var(--cw-surface-soft);border-radius:var(--cw-radius-pill)}\n.segment{border:0;background:transparent;border-radius:var(--cw-radius-pill);padding:5px 10px;font-size:13px;font-weight:600;color:var(--cw-muted);white-space:nowrap}\n.segment:hover{color:var(--cw-ink)}\n.segment[aria-pressed=true]{background:var(--cw-surface);color:var(--cw-ink);box-shadow:0 1px 3px #2024371f}\n.switch{position:relative;flex-shrink:0;width:38px;height:22px;padding:0;border:0;border-radius:999px;background:var(--cw-line-strong);transition:background .16s}\n.switch::after{content:"";position:absolute;top:3px;left:3px;width:16px;height:16px;border-radius:50%;background:#fff;box-shadow:0 1px 3px #20243733;transition:translate .16s}\n.switch[aria-checked=true]{background:var(--cw-accent)}\n.switch[aria-checked=true]::after{translate:16px 0}\n.switch:disabled{opacity:.45;cursor:not-allowed}\n.swatches{display:flex;justify-content:space-between;gap:6px;width:100%}\n.setting.wide{flex-direction:column;align-items:stretch;gap:10px}\n.swatch{width:22px;height:22px;padding:0;border:0;border-radius:50%;background:var(--swatch);box-shadow:inset 0 0 0 1px var(--cw-line-strong)}\n.swatch[aria-pressed=true]{box-shadow:0 0 0 2px var(--cw-surface),0 0 0 4px var(--swatch)}\n.swatch:hover{scale:1.1}\n.pin-sample{display:flex;align-items:flex-end;gap:14px;height:62px;margin:2px 0 6px;padding:0 16px 12px;border:1px dashed var(--cw-line-strong);border-radius:var(--cw-radius-md);background:var(--cw-canvas)}\n.pin-sample .pin{position:static;transform:none;pointer-events:none}\n.pin-sample.small .pin{width:26px;height:30px;border-radius:13px 13px 13px 4px;font-size:11px}\n.pin-sample.resolved-gray .pin.resolved{background:var(--cw-subtle)}\n.launcher.colored,.launcher.colored[aria-expanded=true]{background:var(--cw-launcher)}.launcher.colored .badge,.launcher-mini.colored .badge{background:var(--cw-inverse)}\n.launcher-sample{display:flex;align-items:center;gap:14px;height:72px;margin:2px 0 6px;padding:0 16px;border:1px dashed var(--cw-line-strong);border-radius:var(--cw-radius-md);background:var(--cw-canvas)}\n.launcher-mini{position:relative;display:grid;place-items:center;width:42px;height:42px;border:1px solid #ffffff24;border-radius:50%;background:var(--cw-inverse);color:var(--cw-on-inverse);box-shadow:0 6px 24px #12172233}.launcher-mini.colored{background:var(--cw-launcher)}\n.launcher-mini>svg{width:19px;height:19px}\n.pin-sample-text{margin-left:auto;font-size:12px;color:var(--cw-muted)}\n.settings-foot{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:12px 20px;border-top:1px solid var(--cw-line);background:var(--cw-canvas);font-size:12px;color:var(--cw-muted)}\n.settings-foot .quiet{padding:7px 11px;font-size:13px}\n.pins.small .pin{width:26px;height:30px;border-radius:13px 13px 13px 4px;font-size:11px}\n.pins.resolved-gray .pin.resolved{background:var(--cw-subtle)}\n.pins.small .pin.below{border-radius:4px 13px 13px 13px}\n.note{display:grid;grid-template-columns:minmax(0,1fr) auto;column-gap:12px;align-items:start}\n.note-main{min-width:0}\n.note .time{margin-left:0}\n.note-meta{flex-direction:column;align-items:flex-end;gap:2px;margin:2px 0 0;min-width:64px;line-height:18px}\n.note-number,.count{font-variant-numeric:tabular-nums}\n.count{min-width:20px;text-align:center}\n.hidden-flag{display:inline-flex;align-items:center;gap:4px;max-width:100%;padding:1px 7px 1px 6px;border-radius:6px;background:var(--cw-warning-soft);color:var(--cw-warning);font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.hidden-flag.removed{background:var(--cw-danger-soft);color:var(--cw-danger)}.note-footer .hidden-flag svg{width:12px;height:12px;flex-shrink:0}\n.pin.detached{border-style:dashed;opacity:.85;background:color-mix(in srgb,var(--cw-accent) 70%,var(--cw-subtle))}\n.anchor-status p{margin:0}\n.page-path.sub{font-size:11px;color:var(--cw-subtle);flex-shrink:1}\n.anchor-status .quiet{display:inline-flex;align-items:center;gap:6px;margin-top:10px;padding:6px 11px 6px 9px;font-size:13px;font-weight:600}.anchor-status .quiet svg{width:15px;height:15px;flex-shrink:0}\n@media(max-width:600px){.panel,.panel.left{inset:0;width:auto;border:0}.panel.placing{visibility:hidden}.panel.behind{visibility:hidden}.launcher{right:16px;bottom:16px}.notice,.notice.beside-panel,.notice.beside-panel.left{left:50%;bottom:24px;width:calc(100vw - 32px);font-size:13px}.compose-hint{display:none}.compose-bar{justify-content:flex-end}.toasts,.toasts.left,.toasts.beside-panel,.toasts.beside-panel.left{left:16px;right:16px;width:auto;max-width:none;bottom:82px}.toasts.top,.toasts.beside-panel.top{top:82px;bottom:auto}.toasts.beside-panel{display:none}.head{padding-top:18px}}\n.popover.moving{visibility:hidden;pointer-events:none}\n.update-bar{display:grid;grid-template-columns:30px 1fr auto;align-items:start;gap:4px 12px;padding:14px 12px 16px 20px;background:var(--cw-accent-soft);border-top-color:var(--cw-accent-line)}.update-icon{display:grid;place-items:center;width:30px;height:30px;border-radius:9px;background:var(--cw-surface);color:var(--cw-accent);box-shadow:var(--cw-shadow-sm)}.update-icon svg{width:16px;height:16px}.update-text{display:flex;flex-direction:column;gap:1px;min-width:0;color:var(--cw-muted);font-size:12.5px;line-height:1.45}.update-text strong{color:var(--cw-ink);font-size:13px;font-weight:650}.update-actions{grid-column:2/-1;display:flex;flex-wrap:wrap;gap:8px;margin:8px 8px 0 0}.update-actions .quiet{display:inline-flex;align-items:center;gap:6px;padding:6px 12px;font-size:13px;font-weight:600;border-radius:var(--cw-radius-pill)}.update-actions svg{width:14px;height:14px}.update-toggle svg{color:var(--cw-ai)}.update-prompt{grid-column:1/-1;margin:10px 8px 0 0;max-height:220px;overflow:auto;padding:10px 12px;border:1px solid var(--cw-ai-line);border-radius:10px;background:linear-gradient(135deg,var(--cw-ai-soft),var(--cw-surface));color:var(--cw-ink);font:11.5px/1.55 ui-monospace,SFMono-Regular,Menlo,monospace;white-space:pre-wrap;overflow-wrap:anywhere;user-select:text;-webkit-user-select:text}.update-prompt:focus-visible{outline:2px solid var(--cw-accent);outline-offset:2px}\n@media(max-width:600px){.search input{font-size:16px}.select{max-width:100%}}\n@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation:none!important;transition:none!important;scroll-behavior:auto!important}}\n`;function U(e){if(!e||!e.isConnected||!e.getClientRects().length)return!1;const t=e.getBoundingClientRect();if(t.width<1||t.height<1||"visible"!==getComputedStyle(e).visibility||e.closest("[inert]"))return!1;const i=e.checkVisibility;if(i&&!i.call(e,{opacityProperty:!0,visibilityProperty:!0}))return!1;let n=!1;for(let s=e;s&&s!==document.documentElement;s=s.parentElement){const o=getComputedStyle(s);if(!i&&parseFloat(o.opacity)<.05)return!1;if("fixed"===o.position&&(n=!0),s===e||s===document.body)continue;const r=/(hidden|clip)/.test(o.overflowX+o.overflowY),a=/(auto|scroll)/.test(o.overflowX+o.overflowY)&&(s.clientWidth<1||s.clientHeight<1);if(r||a){const e=s.getBoundingClientRect();if(Math.min(t.right,e.right)-Math.max(t.left,e.left)<1||Math.min(t.bottom,e.bottom)-Math.max(t.top,e.top)<1)return!1}}return!(n&&(t.right<=0||t.bottom<=0||t.left>=innerWidth||t.top>=innerHeight))}const N=(e,t=120)=>(e??"").replace(/\s+/g," ").trim().slice(0,t),D=/:|(^|[-_])(r\d+|radix|headlessui|mui|v-\d|react-aria|\d{3,})/i,j="ul,ol,[role=menu],[role=listbox],[popover],dialog,nav";function F(e){var t,i;const n=e.getAttribute("aria-labelledby");return N(e.getAttribute("aria-label"))||N(null==n?void 0:n.split(/\s+/).map(e=>{var t;return(null==(t=document.getElementById(e))?void 0:t.textContent)??""}).join(" "))||N(e.getAttribute("title"))||function(e){var t;let i="";for(const n of Array.from(e.childNodes))n.nodeType===Node.TEXT_NODE?i+=n.textContent:n instanceof Element&&!n.matches(j)&&!n.querySelector(`${j},a,button`)&&(i+=` ${n.textContent}`);return N(i)||N(null==(t=e.firstElementChild)?void 0:t.textContent)}(e)||N(null==(t=e.querySelector("img[alt]"))?void 0:t.getAttribute("alt"))||N(null==(i=e.querySelector("svg title"))?void 0:i.textContent)}const K=(e,t)=>e.toLowerCase()===t.toLowerCase(),H={BUTTON:"button",SUMMARY:"button",A:"link",LABEL:"label",INPUT:"input"};function B(e){const t=[];for(let i=e;i&&i!==document.body&&i!==document.documentElement;i=i.parentElement){for(const s of["data-overplay-anchor","data-testid","data-test","data-cy"]){const e=i.getAttribute(s),n=e&&`[${s}="${CSS.escape(e)}"]`;if(n&&1===document.querySelectorAll(n).length)return t.unshift(n),t.join(" > ")}if(i.id&&!D.test(i.id)&&1===document.querySelectorAll(`#${CSS.escape(i.id)}`).length)return t.unshift(`#${CSS.escape(i.id)}`),t.join(" > ");const e=i.tagName,n=i.parentElement?Array.from(i.parentElement.children).filter(t=>t.tagName===e):[i];t.unshift(`${e.toLowerCase()}:nth-of-type(${n.indexOf(i)+1})`)}return t.join(" > ")}function Y(e){const t=F(e);return{selector:B(e),role:e.getAttribute("role")||H[e.tagName]||e.tagName.toLowerCase(),tag:e.tagName.toLowerCase(),...t?{name:t}:{}}}function W(e){const t=[],i=(()=>{try{return document.querySelector(e.selector)}catch{return null}})();if(!i||e.name&&!K(F(i),e.name)||t.push(i),e.name){const i=[e.tag,e.role&&/^[a-z]+$/.test(e.role)?`[role="${e.role}"]`:""].filter(Boolean).join(",");try{t.push(...Array.from(document.querySelectorAll(i||"*")).filter(t=>K(F(t),e.name)))}catch{}}return!t.length&&i&&t.push(i),t.find(U)??t[0]??null}const V=/\b(delete|remove|erase|destroy|pay|buy|purchase|checkout|order|send|submit|publish|confirm|sign ?out|log ?out|unsubscribe|cancel subscription|deactivate)\b/i,X=e=>(e=>e.matches('a[href]:not([href^="#"]):not([href=""]),[type=submit],form button:not([type])')&&!e.matches("[aria-haspopup],[aria-expanded]"))(e)||!e.matches("[aria-haspopup],[aria-expanded],[aria-controls],summary,[popovertarget],[data-bs-toggle]")&&V.test(F(e)),G=["Enter"," ","ArrowDown","ArrowRight"],J=/^(display|visibility|opacity|transform|translate|max-height|height|clip|clip-path|left|top|right|bottom|inset|pointer-events)$/;function _(e){const t=e.closest('button,summary,label,[role=button],[role=tab],[role=menuitem],[aria-haspopup],[aria-expanded],[aria-controls],[popovertarget],[data-bs-toggle],a[href^="#"],input[type=checkbox],input[type=radio]');if(t)return t;let i=e;for(let n=e;n&&n!==document.body;n=n.parentElement)if("pointer"===getComputedStyle(n).cursor)i=n;else if(i!==e)break;return i}class Z{constructor(e,t=()=>!1){i(this,"actions",[]),i(this,"open",new Set),i(this,"lastHover",null),i(this,"observer",null),i(this,"onPress",e=>{if(!e.isTrusted||e instanceof KeyboardEvent&&!G.includes(e.key))return;const t=this.target(e);if(!t)return;if(this.paused())return void this.open.clear();const i=this.lastAction("press");i&&(i.el===t||i.el.control===t)&&performance.now()-i.time<500?this.keep(i):this.track("press",t)}),i(this,"onHover",e=>{if(!e.isTrusted)return;const t=this.target(e);t&&t!==this.lastHover&&(this.lastHover=t,this.actions=this.actions.filter(e=>"press"===e.kind||this.open.has(e)||e.changed.size),this.track("hover",t))}),i(this,"onState",e=>{e.target instanceof Element&&this.note(e.target,!1)}),i(this,"onMutations",e=>{if(this.open.size)for(const t of e){if("attributes"===t.type&&"style"===t.attributeName&&(t.target===document.body||t.target===document.documentElement))continue;const e="childList"===t.type?Array.from(t.addedNodes):[t.target];for(const i of e)i instanceof Element&&this.note(i,"childList"===t.type)}}),this.ignore=e,this.paused=t}start(e){const t={capture:!0,signal:e};for(const i of["pointerdown","mousedown","click","keydown"])document.addEventListener(i,this.onPress,t);document.addEventListener("mouseover",this.onHover,t),document.addEventListener("toggle",this.onState,t),document.addEventListener("change",this.onState,t),window.addEventListener("hashchange",()=>{const e=decodeURIComponent(location.hash.slice(1)),t=e&&document.getElementById(e);t&&this.note(t,!1)},{signal:e}),this.observer=new MutationObserver(this.onMutations),this.observer.observe(document,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["class","style","hidden","open","aria-expanded","aria-hidden","data-state","data-open","data-headlessui-state"]}),e.addEventListener("abort",()=>{var e;null==(e=this.observer)||e.disconnect(),this.actions=[],this.open.clear()})}track(e,t){const i={kind:e,el:t,time:performance.now(),changed:new Set,added:new Set};this.actions.push(i),this.keep(i),this.actions.length>40&&this.actions.shift()}keep(e){this.open.add(e),setTimeout(()=>this.open.delete(e),700)}target(e){const t=e.composedPath().find(e=>e instanceof Element);return t&&!this.ignore(t)?t:null}note(e,t){if(this.ignore(e))return;let i;for(const n of this.actions)this.open.has(n)&&(i=n);i&&(i.changed.add(e),t&&i.added.add(e))}lastAction(e){for(let t=this.actions.length-1;t>=0;t--)if(this.actions[t].kind===e)return this.actions[t]}capture(e){const t=performance.now(),i=[],n=[],s=new Set;let o=e;for(let a=this.actions.length-1;a>=0&&i.length<6;a--){const e=this.actions[a];if(t-e.time>12e4||s.has(e)||!e.el.isConnected||o.contains(e.el))continue;const r="press"===e.kind?_(e.el):e.el;if(!(r.contains(o)&&!r.matches("label")||X(r))&&this.opened(e,r,o)&&(("hover"!==e.kind||Array.from(e.added).some(e=>e.isConnected&&e.contains(o))||!this.actions.some(t=>"press"===t.kind&&t.time<=e.time&&e.time-t.time<800&&this.changedFor(t,o)))&&("hover"!==e.kind||n[0]!==r)&&(i.unshift({action:e.kind,target:Y(r)}),n.unshift(r),s.add(e),o=r,this.onPage(r))))break}const r=function(e){const t=[],i=e=>{for(const n of Array.from(e))n instanceof CSSStyleRule?/:(hover|focus-within)\b/.test(n.selectorText)&&Array.from(n.style).some(e=>J.test(e))&&t.push(n):"cssRules"in n&&i(n.cssRules)};for(const s of Array.from(document.styleSheets))try{i(s.cssRules)}catch{}if(!t.length)return[];const n=[];for(const s of["hover","focus-within"])for(const i of Array.from(document.querySelectorAll(`:${s}`))){if(i===document.documentElement||i===document.body||e.contains(i))continue;t.some(t=>t.selectorText.split(",").some(t=>{const n=t.indexOf(`:${s}`);if(n<0||!/^\s*[\s>~+]/.test(t.slice(n+s.length+1))||!t.slice(n+s.length+1).trim())return!1;try{return i.matches(t.slice(0,n).trim()||"*")&&Array.from(document.querySelectorAll(t.split(`:${s}`).join(""))).some(t=>t!==i&&(i.contains(t)||t.parentElement===i.parentElement)&&t.contains(e))}catch{return!1}}))&&n.push({action:"hover"===s?"hover":"focus",el:i})}return n.sort((e,t)=>e.el.contains(t.el)?-1:t.el.contains(e.el)?1:0)}(e).filter(e=>!n.includes(e.el)).map(e=>({action:e.action,target:Y(e.el)}));return[...r,...i].slice(0,6)}changedFor(e,t){for(const i of e.changed)if(i.isConnected){if(i===t||i.contains(t))return!0;if(i instanceof HTMLInputElement&&/^(checkbox|radio)$/.test(i.type))for(let e=i.nextElementSibling;e;e=e.nextElementSibling)if(e.contains(t))return!0}return!1}opened(e,t,i){var n,s,o;if(this.changedFor(e,i))return!0;if("press"!==e.kind)return!1;const r=t instanceof HTMLLabelElement?t.control:null,a=t.getAttribute("popovertarget"),l=t.matches('a[href^="#"]')?t.getAttribute("href"):"";return!(!a||!(null==(n=document.getElementById(a))?void 0:n.contains(i)))||!!(l.length>1&&location.hash===l&&(null==(s=document.getElementById(l.slice(1)))?void 0:s.contains(i)))||!!(r instanceof HTMLInputElement&&r.checked)||t.matches("summary")&&!!(null==(o=t.parentElement)?void 0:o.open)&&t.parentElement.contains(i)}onPage(e){var t;return!(null==(t=e.parentElement)?void 0:t.closest("[role=menu],[role=dialog],[role=listbox],[popover],dialog"))&&!this.actions.some(t=>t.el!==e&&!t.el.contains(e)&&Array.from(t.changed).some(t=>t.isConnected&&t!==document.body&&t!==document.documentElement&&t.contains(e)))}}const Q=()=>new Promise(e=>requestAnimationFrame(()=>e()));async function ee(e,t){const i=performance.now()+t;for(;performance.now()<i;){if(e())return!0;await Q()}return e()}function te(e,t){const i=e.getBoundingClientRect(),n={bubbles:!0,cancelable:!0,composed:!0,view:window,button:0,buttons:t.endsWith("down")?1:0,clientX:i.left+i.width/2,clientY:i.top+i.height/2};e.dispatchEvent(t.startsWith("pointer")?new PointerEvent(t,{...n,pointerId:1,pointerType:"mouse",isPrimary:!0}):new MouseEvent(t,n))}function ie(e){var t,i;for(const n of["pointerover","pointerenter","mouseover","mouseenter","pointermove","mousemove","pointerdown","mousedown"])te(e,n);null==(t=e.focus)||t.call(e,{preventScroll:!0});for(const n of["pointerup","mouseup"])te(e,n);null==(i=e.click)||i.call(e)}function ne(e,t){var i;null==(i=e.focus)||i.call(e,{preventScroll:!0});for(const n of["keydown","keyup"])e.dispatchEvent(new KeyboardEvent(n,{key:t,code:" "===t?"Space":t,bubbles:!0,cancelable:!0,composed:!0}))}const se=e=>{var t;return e.matches("[aria-expanded=true],[data-state=open],[role=tab][aria-selected=true]")||e.matches("summary")&&!!(null==(t=e.parentElement)?void 0:t.open)||e instanceof HTMLInputElement&&e.checked};const oe=new class{constructor(){i(this,"sheet",null),i(this,"marked",[])}set(e,t){const i=`data-overplay-${t}`,n="hover"===t?/:hover\b/g:/:focus-within\b/g;if(!this.sheet)try{this.sheet=new CSSStyleSheet,document.adoptedStyleSheets=[...document.adoptedStyleSheets,this.sheet]}catch{return}const s=(e,t)=>{for(const o of Array.from(e))if(o instanceof CSSStyleRule&&o.selectorText.match(n))try{this.sheet.insertRule(t(`${o.selectorText.replace(n,`[${i}]`)}{${o.style.cssText}}`),this.sheet.cssRules.length)}catch{}else o instanceof CSSMediaRule&&s(o.cssRules,e=>t(`@media ${o.media.mediaText}{${e}}`))};if(!this.marked.some(([,e])=>e===i))for(const o of Array.from(document.styleSheets))try{s(o.cssRules,e=>e)}catch{}e.setAttribute(i,""),this.marked.push([e,i])}clear(){for(const[e,t]of this.marked)e.removeAttribute(t);this.marked=[],this.sheet&&(document.adoptedStyleSheets=document.adoptedStyleSheets.filter(e=>e!==this.sheet),this.sheet=null)}};function re(){oe.clear()}const ae=new Set(["IMG","svg","VIDEO","CANVAS","IFRAME","PICTURE","INPUT","SELECT","TEXTAREA","BUTTON"]);function le(e,t){var i;const n=e=>e!==document.body&&e!==document.documentElement&&(!t||t.contains(e))&&!e.closest("[data-overplay]");if(e.closest("[data-overplay]"))return null;const s=e.closest("[data-overplay-anchor]"),o=null==s?void 0:s.getAttribute("data-overplay-anchor"),r=s&&o&&n(s)&&he(`[data-overplay-anchor="${CSS.escape(o)}"]`,t)===s?s:null;let a=e;if(a instanceof SVGElement)for(let c=a.closest("svg");c;c=(null==(i=c.parentElement)?void 0:i.closest("svg"))??null)a=c;const l=a.closest("a[href],button,label,summary,select,textarea,input,[role=button],[role=link],[role=tab],[role=menuitem],[role=checkbox],[role=switch],[role=option]");if(l&&n(l))a=l;else for(;!ae.has(a.tagName)&&a.parentElement&&n(a.parentElement)&&/^(inline|contents)$/.test(getComputedStyle(a).display);)a=a.parentElement;return r&&(a===r||!r.contains(a)||!n(a)||(e=>{const t=e.getBoundingClientRect();return t.width*t.height})(r)<=innerWidth*innerHeight/4)?r:n(a)?a:t||(document.body.getClientRects().length&&document.body.getBoundingClientRect().height?document.body:document.documentElement)}const ce=/^(radix-|headlessui-|react-aria\d*-|mui-\d|ember\d|_r_)|[:«»]|^[a-f0-9]{8}-[a-f0-9]{4}-/i,de=e=>ce.test(e);function he(e,t){try{const i=Array.from(document.querySelectorAll(e)).filter(e=>!t||t.contains(e));if(1===i.length)return i[0];const n=i.filter(e=>{const t=e.getBoundingClientRect();return e.getClientRects().length&&t.width&&t.height&&"visible"===getComputedStyle(e).visibility});return 1===n.length?n[0]:null}catch{return null}}function pe(e,t){if(!e.selector)return"shown";let i=!1;try{i=Array.from(document.querySelectorAll(e.selector)).some(e=>!t||t.contains(e))}catch{}return i?U(he(e.selector,t))?"shown":"hidden":"removed"}const ue=[["input[type=checkbox],[role=checkbox]","Checkbox"],["input[type=radio],[role=radio]","Option"],["[role=switch]","Switch"],["button,input[type=button],input[type=submit],[role=button]","Button"],["a[href],[role=link]","Link"],["[role=tab]","Tab"],["[role=menuitem]","Menu item"],["[role=option],option","Option"],["select","Menu"],["input,textarea","Field"],["img,picture,[role=img]","Image"],["svg","Icon"],["video","Video"],["canvas","Canvas"],["iframe","Frame"],["h1,h2,h3,h4,h5,h6,[role=heading]","Heading"],["label","Label"],["li","List item"],["tr","Row"],["td,th","Cell"],["table","Table"],["nav","Navigation"],["form","Form"],["p","Text"],["summary","Button"]],me=(e,t=48)=>{const i=(e??"").replace(/\s+/g," ").trim();return i.length>t?`${i.slice(0,t-1).trimEnd()}…`:i},ge=e=>me(null==e?void 0:e.split(/\s+/).map(e=>{var t;return(null==(t=document.getElementById(e))?void 0:t.textContent)??""}).join(" "));function fe(e){var t,i;const n=e,s=e.id?document.querySelector(`label[for="${CSS.escape(e.id)}"]`):null;return me(e.getAttribute("aria-label"))||ge(e.getAttribute("aria-labelledby"))||me(e.getAttribute("alt"))||me(null==s?void 0:s.textContent)||me(null==(t=e.closest("label"))?void 0:t.textContent)||me(n.placeholder)||me(e.getAttribute("title"))||me(null==(i=e.querySelector("title"))?void 0:i.textContent)||me(e.innerText??e.textContent)}const ve=e=>me(e.replace(/[-_:./]+/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase()));function xe(e){var t,i,n;const s=e.getAttribute("data-overplay-anchor"),o=s?ve(s):(null==(t=ue.find(([t])=>e.matches(t)))?void 0:t[1])??(e===document.body||e===document.documentElement?"Page":"Element"),r=s||e===document.body||e===document.documentElement?"":fe(e),a={label:r&&r!==o?`${o} “${r}”`:o};for(let l=e.parentElement;l&&l!==document.body;l=l.parentElement){const e=l.id?CSS.escape(l.id):"",t=e?document.querySelector(`[aria-controls~="${e}"]`):null,s=t?fe(t):l instanceof HTMLDetailsElement?me(null==(i=l.querySelector("summary"))?void 0:i.textContent):l instanceof HTMLFieldSetElement?me(null==(n=l.querySelector("legend"))?void 0:n.textContent):l.hasAttribute("data-overplay-anchor")?ve(l.getAttribute("data-overplay-anchor")):l.matches("[role=dialog],[role=menu],[role=listbox],[role=tabpanel],dialog,nav,section,aside,form,[popover]")?me(l.getAttribute("aria-label"))||ge(l.getAttribute("aria-labelledby")):"";if(s&&s!==r){a.place=s;break}}return a}const we=Object.freeze({status:"open",query:"",mine:!1,author:""});function be(e){return e.normalize("NFKD").replace(new RegExp("\\p{M}","gu"),"").toLowerCase()}function ye(e){let t="";const i=[];for(let n=0;n<e.length;){const s=e.codePointAt(n),o=String.fromCodePoint(s),r=be(o);for(let e=0;e<r.length;e++)i.push(n);t+=r,n+=o.length}return i.push(e.length),{folded:t,map:i}}function ke(e){const t=ye(e.slice(0,200)).folded.split(/\s+/).filter(Boolean);return[...new Set(t)].slice(0,8)}const Ce=(e,t)=>{const i=ye(e).folded;return t.filter(e=>i.includes(e))};function Se(e,t){if(!t.length||!e)return[];const{folded:i,map:n}=ye(e),s=[];for(const r of t)for(let t=i.indexOf(r);-1!==t;t=i.indexOf(r,t+r.length)){const i=n[t],o=n[t+r.length-1],a=n.slice(t+r.length).find(e=>e>o)??e.length;s.push([i,a])}s.sort((e,t)=>e[0]-t[0]||e[1]-t[1]);const o=[];for(const r of s){const e=o[o.length-1];e&&r[0]<=e[1]?e[1]=Math.max(e[1],r[1]):o.push([...r])}return o}function Ee(e,t,i={}){if(!t.length)return{};const n=(s=i.elementOf?i.elementOf(e):e.element)?s.place?`${s.label} in ${s.place}`:s.label:"";var s;const o=[e.text,e.author,i.includePage?`${e.pageTitle??""} ${e.pageUrl}`:""].join("\n"),r=new Set(Ce(o,t)),a={};if(r.size<t.length)for(const l of e.replies){const e=Ce(`${l.text}\n${l.author}`,t);e.some(e=>!r.has(e))&&(a.reply??(a.reply=l),e.forEach(e=>r.add(e)))}if(r.size<t.length&&n){const e=Ce(n,t);e.some(e=>!r.has(e))&&(a.element=n,e.forEach(e=>r.add(e)))}return r.size===t.length?a:null}function Ae(e){return e.authorId?`id:${e.authorId}`:`name:${e.author.trim().toLowerCase()}`}function Ie(e,t){return!!e.authorId&&e.authorId===t}function Te(e,t){return"all"===t||("resolved"===t?e.resolved:!e.resolved)}function $e(e,t,i){const n=ke(t.query);return e.filter(e=>Te(e,t.status)&&(!t.mine||Ie(e,i.userId))&&(!t.author||Ae(e)===t.author)&&!!Ee(e,n,i))}function Pe(e,t,i){const n=ke(t.query),s=e.filter(e=>!!Ee(e,n,i)),o=s.filter(e=>(!t.mine||Ie(e,i.userId))&&(!t.author||Ae(e)===t.author)),r=s.filter(e=>Te(e,t.status)),a=new Map;for(const l of e){const e=Ae(l),t=a.get(e)??{key:e,name:l.author,count:0};t.name=l.author,a.set(e,t)}for(const l of r){const e=a.get(Ae(l));e&&e.count++}return{open:o.filter(e=>!e.resolved).length,resolved:o.filter(e=>e.resolved).length,all:o.length,mine:r.filter(e=>Ie(e,i.userId)).length,authors:[...a.values()].sort((e,t)=>e.name.localeCompare(t.name)||e.key.localeCompare(t.key))}}function Le(e){return!!e.query.trim()||e.mine||!!e.author}const Me=["light","dark","system"],Re=52,ze=12,qe="overplay:update-dismissed",Oe=(e,t,i)=>Math.max(t,Math.min(Math.max(t,i),e));function Ue(e){try{return Array.from(document.querySelectorAll(e))}catch{return[]}}function Ne(e){try{const t=new URL(e,location.href);return`${t.pathname}${t.search}${t.hash}`}catch{return e}}function De(){const e=e=>(e??"").replace(/\s+/g," ").trim(),t=e(document.title),i=Array.from(document.querySelectorAll("main h1, [role=main] h1, h1")).find(e=>!e.closest("[data-overplay]")&&e.getClientRects().length),n=e(null==i?void 0:i.textContent).slice(0,120);return((!t||t.toLowerCase()===location.hostname.toLowerCase()||!/[-–—|·:]/.test(t)&&!!n&&!t.includes(n))&&n?n:t||n).slice(0,300)||void 0}function je(e,t,i){let n=0;for(const[s,o]of Se(t,i.filter(e=>e.length>1)))s>n&&e.append(document.createTextNode(t.slice(n,s))),e.append(T("mark","hit",t.slice(s,o))),n=o;return e.append(document.createTextNode(t.slice(n))),e}class Fe{constructor(e={}){var t,n,s;if(i(this,"ready"),i(this,"config"),i(this,"storage"),i(this,"host",T("div")),i(this,"shadow"),i(this,"surface",T("div")),i(this,"pins",T("div","pins")),i(this,"pickTarget",null),i(this,"live",T("div","sr-only")),i(this,"toasts",T("div","toasts")),i(this,"toastTimers",new Set),i(this,"seen",new Set),i(this,"seenKey",""),i(this,"detailKey",""),i(this,"events",new AbortController),i(this,"resizeObserver"),i(this,"mutationObserver"),i(this,"anchorObserver"),i(this,"observedAnchors",new Set),i(this,"unsubscribe"),i(this,"routeTimer"),i(this,"frame",0),i(this,"motionFrame",0),i(this,"destroyed",!1),i(this,"visible",!1),i(this,"placing",!1),i(this,"pinDrag",null),i(this,"suppressPinClick",!1),i(this,"loading",!0),i(this,"loaded",!1),i(this,"loadFailed",!1),i(this,"saving",!1),i(this,"error",""),i(this,"comments",[]),i(this,"activeId",null),i(this,"draft",null),i(this,"text",""),i(this,"replyText",""),i(this,"replyId",m()),i(this,"filters",{...we}),i(this,"scope","page"),i(this,"filterKey"),i(this,"searchTimer"),i(this,"launcherKey"),i(this,"openKey"),i(this,"launcherSpot"),i(this,"dragging",!1),i(this,"suppressClick",!1),i(this,"highlightId",null),i(this,"hoverId",null),i(this,"highlightTimer"),i(this,"sidebarOpen",!1),i(this,"docked",!1),i(this,"dockKey"),i(this,"project"),i(this,"settingsCache",null),i(this,"update",null),i(this,"updatePromptOpen",!1),i(this,"settingsTab","general"),i(this,"updateChecked",!1),i(this,"pushed",null),i(this,"recorder",new Z(e=>e===this.host||e.getRootNode()===this.shadow,()=>this.placing||!!this.pinDrag)),i(this,"revealed",null),i(this,"replaying",!1),i(this,"editing",null),i(this,"user"),i(this,"managedUser"),i(this,"identityKey"),i(this,"persistentGuest"),i(this,"pageId"),i(this,"loadVersion",0),i(this,"queuedSnapshot",null),i(this,"returnFocus",null),i(this,"shortcut"),i(this,"composing",!1),i(this,"renderDeferred",!1),i(this,"applyQueuedSnapshot",()=>{if(this.destroyed||!this.queuedSnapshot||this.saving||this.loading||this.typing())return;const e=this.queuedSnapshot;this.queuedSnapshot=null,this.apply(e)}),i(this,"receiveSnapshot",e=>{if(!this.destroyed)try{const t=l(e);this.saving||this.loading||this.typing()?this.queuedSnapshot=t:this.apply(t)}catch(t){this.report(t),this.render()}}),i(this,"shieldPress",e=>{if(!e.isTrusted||!e.composedPath().includes(this.host))return;e.stopImmediatePropagation();const t=e.composedPath()[0];if("touchstart"===e.type||!(t instanceof Element)||t.getRootNode()!==this.shadow)return;e.composedPath().some(e=>e instanceof Element&&e.matches("[role=menu],[aria-haspopup=menu]"))||this.closeMenus();const i=e.constructor;t.dispatchEvent(new i(e.type,Object.assign({},function(e){const t=e;return{view:window,clientX:t.clientX,clientY:t.clientY,screenX:t.screenX,screenY:t.screenY,button:t.button,buttons:t.buttons,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey,pointerId:t.pointerId,pointerType:t.pointerType,isPrimary:t.isPrimary,width:t.width,height:t.height,pressure:t.pressure}}(e),{bubbles:!0,cancelable:!0,composed:!1})))}),i(this,"onRouteChange",()=>{if(this.destroyed)return;const e=this.currentPage();e!==this.pageId&&(this.pageId=e,this.activeId=null,this.draft=null,this.placing=!1,this.text="",this.replyText="",this.noticeActivity(),this.render(),this.storage instanceof p?this.refresh():this.openPending())}),i(this,"onKeyDown",e=>{if(e.defaultPrevented||e.isComposing)return;const t="Escape"===e.key?this.closeMenus():null;if(t)return e.preventDefault(),void t.focus();if("Escape"===e.key&&this.visible)return e.preventDefault(),void(this.draft||this.placing||this.activeId||this.editing?this.closePopup():this.hide());const i=e.composedPath()[0];if(this.placing&&"Enter"===e.key&&!e.composedPath().includes(this.host)){const t=i instanceof Element&&i!==document.body?i:this.config.container??document.documentElement;if(this.config.container&&!this.config.container.contains(t)&&t!==this.config.container)return;const n=t.getBoundingClientRect(),s=Math.max(16,Math.min(innerWidth-16,n.left+n.width/2)),o=Math.max(48,Math.min(innerHeight-48,n.top+Math.min(n.height/2,innerHeight/2)));return e.preventDefault(),void this.choosePoint({x:s+scrollX,y:o+scrollY},t)}i instanceof Element&&(i.closest("input,textarea,select,[contenteditable]:not([contenteditable=false])")||i.closest("[role=textbox]"))||!e.repeat&&this.settings.shortcut&&this.shortcut&&function(e,t){if(e.altKey!==t.alt||e.ctrlKey!==t.ctrl||e.metaKey!==t.meta)return!1;if(t.shift&&!e.shiftKey)return!1;const i=/^[a-z]$/.test(t.key)?`Key${t.key.toUpperCase()}`:/^\d$/.test(t.key)?`Digit${t.key}`:"";return e.key.toLowerCase()===t.key||!!i&&e.code===i}(e,this.shortcut)&&(e.preventDefault(),this.visible?this.hide():this.show())}),i(this,"onPageClick",e=>{if(e.composedPath().includes(this.host))return;if(!this.placing){if(!e.isTrusted||this.replaying)return;const t=this.activeId?!this.replyText.trim():!!this.draft&&!this.text.trim();return void(this.visible&&t&&!this.docked&&!this.saving&&this.closePopup(!1))}if(e.ctrlKey||e.metaKey||e.altKey)return;const t=e.target;t instanceof Element&&(!this.config.container||this.config.container.contains(t))&&(e.preventDefault(),e.stopPropagation(),this.choosePoint({x:e.clientX+scrollX,y:e.clientY+scrollY},t))}),i(this,"onPointerMove",e=>{const t=this.pins.querySelector(".preview");if(!t)return;const i=e.target,n=!this.config.container||i instanceof Node&&this.config.container.contains(i);t.hidden=e.composedPath().includes(this.host)||!n,t.style.left=`${e.clientX}px`,t.style.top=`${e.clientY}px`;const s=!t.hidden&&i instanceof Element?le(i,this.config.container):null;this.pickTarget=s===document.body||s===document.documentElement?null:s,this.placePickRing()}),i(this,"trackLayoutMotion",()=>{if(this.motionFrame||!this.visible||this.destroyed)return;const e=()=>{this.motionFrame=0,this.visible&&!this.destroyed&&(this.positionPins(),document.getAnimations().some(e=>"running"===e.playState)&&(this.motionFrame=requestAnimationFrame(e)))};this.motionFrame=requestAnimationFrame(e)}),i(this,"schedulePosition",()=>{this.frame||this.destroyed||!this.visible||(this.frame=requestAnimationFrame(()=>{this.frame=0,this.positionPins()}))}),i(this,"pushPage",()=>{var e;const t=document.documentElement,i=this.sidebarOpen&&this.settings.pushContent&&innerWidth>600,n=(null==(e=this.config.position)?void 0:e.endsWith("left"))?"margin-left":"margin-right";if(i&&!this.pushed)this.pushed={property:n,value:t.style.getPropertyValue(n),priority:t.style.getPropertyPriority(n)},t.style.setProperty(n,"400px","important");else if(!i&&this.pushed){const{property:e,value:i,priority:n}=this.pushed;this.pushed=null,i?t.style.setProperty(e,i,n):t.style.removeProperty(e)}}),i(this,"placeLauncher",()=>{const e=this.shadow.querySelector(".launcher");if(!e||!this.launcherSpot)return;const t=Oe(this.launcherSpot.x*innerWidth-26,ze,innerWidth-Re-ze),i=Oe(this.launcherSpot.y*innerHeight-26,ze,innerHeight-Re-ze);Object.assign(e.style,{left:`${t}px`,top:`${i}px`,right:"auto",bottom:"auto"})}),i(this,"submitComment",()=>{if(!this.draft||!this.text.trim())return;const e=this.draft,t={id:e.id,x:e.position.x,y:e.position.y,text:this.text.trim(),author:this.user.name,authorId:this.user.id,avatarUrl:this.user.avatarUrl,timestamp:e.timestamp,replies:[],resolved:!1,pageUrl:e.pageUrl,pageTitle:De(),selector:e.selector,anchor:e.anchor,element:e.element},i=[...this.getAllComments(),t];this.mutate(i,()=>this.storage.upsertComment?this.storage.upsertComment(t):this.storage.saveComments(i),()=>{this.draft=null,this.text="",this.activeId=t.id})}),i(this,"submitReply",()=>{const e=this.comments.find(e=>e.id===this.activeId);if(!e||!this.replyText.trim())return;const t={id:this.replyId,text:this.replyText.trim(),author:this.user.name,authorId:this.user.id,avatarUrl:this.user.avatarUrl,timestamp:new Date,commentId:e.id},i={...e,replies:[...e.replies,t]},n=this.getAllComments().map(t=>t.id===e.id?i:t);this.mutate(n,()=>this.storage.addReply?this.storage.addReply(e.id,t):this.storage.upsertComment?this.storage.upsertComment(i):this.storage.saveComments(n),()=>{this.replyText="",this.replyId=m()})}),this.config={primaryColor:"#0068f9",position:"bottom-right",keyboardShortcut:"alt+c",enableKeyboardShortcuts:!0,...e},!/^#[0-9a-f]{3}([0-9a-f]{3})?$/i.test(this.config.primaryColor??""))throw new Error("primaryColor must be a 3- or 6-digit hex color.");if(void 0!==this.config.theme&&!Me.includes(this.config.theme))throw new Error('theme must be "light", "dark" or "system".');if(this.shortcut=function(e){const t=e.toLowerCase().split("+").map(e=>e.trim()),i=t.pop();if(!i)return null;const n={key:i,alt:!1,shift:!1,ctrl:!1,meta:!1};for(const s of t)if("alt"===s||"option"===s)n.alt=!0;else if("shift"===s)n.shift=!0;else if("ctrl"===s||"control"===s)n.ctrl=!0;else{if("meta"!==s&&"cmd"!==s)return null;n.meta=!0}return n}(this.config.keyboardShortcut??""),this.config.enableKeyboardShortcuts&&!this.shortcut)throw new Error('keyboardShortcut must be a key such as "alt+c".');const o=e.projectId||location.hostname||"default";this.identityKey=`overplay:${o}:user`,this.launcherKey=`overplay:${o}:launcher`,this.openKey=`overplay:${o}:open`,this.dockKey=`overplay:${o}:docked`,this.filterKey=`overplay:${o}:filters`,this.restoreFilters(),this.project=o;try{this.docked="1"===localStorage.getItem(this.dockKey)}catch{}this.launcherSpot=function(e){try{const t=JSON.parse(localStorage.getItem(e)||"null");return t&&Number.isFinite(t.x)&&Number.isFinite(t.y)?{x:Oe(t.x,0,1),y:Oe(t.y,0,1)}:null}catch{return null}}(this.launcherKey);const r=f(this.identityKey);if(this.user=e.user?g(e.user):r.user,this.persistentGuest=r.persistent,this.managedUser=!!e.user,e.serverUrl&&(!e.projectId||e.storage||e.user))throw new Error("Hosted mode requires projectId and manages storage and user itself.");this.storage=e.serverUrl?new p(e.serverUrl,o,()=>this.currentPage(),e=>this.hostedSession(e)):e.storage??new u(`overplay:${o}:comments`),e.serverUrl&&(this.user={id:"signed-out",name:"Sign in"},this.managedUser=!0),this.pageId=this.currentPage(),this.host.dataset.overplay="root",this.host.style.cssText="all:initial;position:fixed;inset:0;pointer-events:none;z-index:2147483646;",this.shadow=this.host.attachShadow({mode:"open"});const a=T("style");a.textContent=O,e.nonce&&(a.nonce=e.nonce),this.host.style.setProperty("--cw-accent",this.config.primaryColor),this.live.setAttribute("role","status"),this.live.setAttribute("aria-live","polite"),this.toasts.setAttribute("role","status"),this.toasts.setAttribute("aria-live","polite"),this.shadow.append(a,this.pins,this.surface,this.toasts,this.live),document.body.append(this.host);const c={signal:this.events.signal};!1!==this.config.autoReveal&&this.recorder.start(this.events.signal);for(const i of["pointerdown","mousedown","pointerup","mouseup","click","touchstart","touchend","focusin","focusout"])this.host.addEventListener(i,e=>e.stopPropagation(),c);for(const i of["pointerdown","mousedown","touchstart"])window.addEventListener(i,this.shieldPress,{...c,capture:!0});window.addEventListener("focusin",e=>{e.composedPath().includes(this.host)&&e.stopImmediatePropagation()},{...c,capture:!0}),window.addEventListener("focusout",e=>{e.relatedTarget!==this.host||e.composedPath().includes(this.host)||e.stopImmediatePropagation()},{...c,capture:!0});const d=new MutationObserver(()=>{this.host.removeAttribute("aria-hidden"),this.host.removeAttribute("inert")});d.observe(this.host,{attributes:!0,attributeFilter:["aria-hidden","inert"]}),this.events.signal.addEventListener("abort",()=>d.disconnect()),this.shadow.addEventListener("compositionstart",()=>{this.composing=!0},c),this.shadow.addEventListener("compositionend",()=>{this.composing=!1,this.renderDeferred&&(this.renderDeferred=!1,this.render())},c),this.shadow.addEventListener("focusout",()=>setTimeout(this.applyQueuedSnapshot),c),document.addEventListener("keydown",this.onKeyDown,c),document.addEventListener("click",this.onPageClick,{...c,capture:!0}),document.addEventListener("pointerdown",e=>{e.composedPath().some(e=>e instanceof Element&&e.matches("[role=menu],[aria-haspopup=menu]"))||this.closeMenus()},{...c,capture:!0}),document.addEventListener("pointermove",this.onPointerMove,{...c,passive:!0}),window.addEventListener("scroll",this.schedulePosition,{...c,capture:!0,passive:!0}),window.addEventListener("resize",this.schedulePosition,c),window.addEventListener("resize",this.placeLauncher,c),window.addEventListener("resize",this.pushPage,c),null==(t=window.visualViewport)||t.addEventListener("resize",this.schedulePosition,c),null==(n=window.visualViewport)||n.addEventListener("scroll",this.schedulePosition,c),window.addEventListener("popstate",this.onRouteChange,c),window.addEventListener("hashchange",this.onRouteChange,c),this.resizeObserver=new ResizeObserver(this.schedulePosition),this.resizeObserver.observe(e.container??document.documentElement),this.anchorObserver=new ResizeObserver(this.schedulePosition),document.addEventListener("load",this.schedulePosition,{...c,capture:!0}),null==(s=document.fonts)||s.addEventListener("loadingdone",this.schedulePosition,c),document.addEventListener("transitionrun",this.trackLayoutMotion,{...c,capture:!0}),document.addEventListener("animationstart",this.trackLayoutMotion,{...c,capture:!0}),this.mutationObserver=new MutationObserver(this.schedulePosition),this.mutationObserver.observe(e.container??document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","style","id","data-overplay-anchor","hidden","open"]}),this.routeTimer=setInterval(this.onRouteChange,500),this.render(),this.ready=this.refresh().then(()=>{if(!this.destroyed&&this.storage.subscribeToChanges)try{this.unsubscribe=this.storage.subscribeToChanges(this.receiveSnapshot)}catch(e){this.report(e),this.render()}})}settingDefaults(){return{theme:this.config.theme??"light",pinColor:"site",buttonColor:"default",resolvedPins:"green",pinSize:"regular",pinLabel:"number",pushContent:!1!==this.config.pushContent,notifications:!1!==this.config.showNotifications,shortcut:!!this.config.enableKeyboardShortcuts&&!!this.shortcut}}settingsKey(){return`overplay:${this.project}:settings:${this.user.id}`}get settings(){var e;const t=this.settingsKey();return(null==(e=this.settingsCache)?void 0:e.key)!==t&&(this.settingsCache={key:t,value:E(t,this.settingDefaults())}),this.settingsCache.value}setSetting(e,t){const i=this.settingsKey(),n={...this.settings,[e]:t};this.settingsCache={key:i,value:n},A(i,n,this.settingDefaults())||this.announce("Browser storage is unavailable. This choice lasts for this page view."),this.render()}setTheme(e){if(!Me.includes(e))throw new Error('theme must be "light", "dark" or "system".');this.destroyed||this.config.theme===e||(this.config.theme=e,this.settingsCache=null,this.render())}resetSettings(){const e=this.settingsKey(),t=this.settingDefaults();A(e,t,t),this.settingsCache={key:e,value:t},this.docked=!1;try{localStorage.removeItem(this.dockKey)}catch{}this.render(),this.announce("Settings reset to the site defaults.")}currentPage(){var e,t,i;return(null==(t=(e=this.config).getPageId)?void 0:t.call(e))??`${(i=location).pathname}${d(i.search)}${/^#!?\//.test(i.hash)?i.hash:""}`}onCurrentPage(e){const t=this.currentPage();return this.config.getPageId?e===t:function(e,t){return e===t||e.replace(/#(?!!?\/).*$/,"")===t}(e,t)}typing(){const e=this.shadow.activeElement;return this.composing||e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement}announce(e){this.live.textContent=e}report(e){var t,i;const n=e instanceof Error?e:new Error("Could not save your changes.");this.error=n.message,this.announce(n.message);try{null==(i=(t=this.config).onError)||i.call(t,n)}catch{}}changed(){var e,t;try{null==(t=(e=this.config).onChange)||t.call(e,this.getAllComments())}catch{}this.host.dispatchEvent(new CustomEvent("comments-changed",{detail:this.getAllComments(),bubbles:!0,composed:!0}))}apply(e){w(e,this.comments)||(this.comments=e,this.changed(),this.noticeActivity(),this.render())}noticeActivity(){const e=`${this.user.id}\n${this.currentPage()}`;if(e!==this.seenKey)return this.seenKey=e,this.seen.clear(),void x(this.comments,this.seen,this.user.id);if(!this.settings.notifications)return void x(this.comments,this.seen,this.user.id);const t=x(this.pageComments(),this.seen,this.user.id);if(x(this.comments,this.seen,this.user.id),t.length>3)this.toast({kind:"comment",commentId:"",author:`${t.length} new comments`,text:"Open the comments panel to read them."},!0);else for(const i of t)this.toast(i)}toast(e,t=!1){var i;const n=T("div","toast"),s=T("div","toast-body"),o=T("p","toast-title");if(o.append(T("strong","",e.author)),!t){o.append(document.createTextNode("reply"===e.kind?" replied":" commented"));const t=this.pageComments().findIndex(t=>t.id===e.commentId)+1;t&&o.append(T("span","toast-number",`#${t}`))}if(s.append(o,T("p","toast-text",e.text)),t){const e=T("span","avatar toast-icon");e.append(P("comment")),n.append(e)}else n.append(M(e.author,e.avatarUrl));for(n.append(s);this.toasts.childElementCount>=3;)null==(i=this.toasts.firstElementChild)||i.remove();this.toasts.append(n);const r=(e,t)=>{const i=setTimeout(()=>{this.toastTimers.delete(i),t()},e);this.toastTimers.add(i)};r(7e3,()=>{n.classList.add("leaving"),r(this.reducedMotion()?0:200,()=>n.remove())})}async refresh(){if(this.destroyed||this.saving)return;const e=++this.loadVersion;this.loading=!0,this.render();try{const t=l(await this.storage.loadComments());if(this.destroyed||e!==this.loadVersion)return;const i=this.queuedSnapshot??t,n=!this.loaded||!w(i,this.comments);this.comments=i,this.queuedSnapshot=null,this.loadFailed=!1,this.error="",this.loaded=!0,n&&(this.changed(),this.noticeActivity())}catch(t){if(this.destroyed||e!==this.loadVersion)return;this.loadFailed=!0,this.report(t)}finally{this.destroyed||e!==this.loadVersion||(this.loading=!1,this.render(),this.loaded&&this.openPending())}}getAllComments(){return c(this.comments)}getUser(){return{...this.user}}hostedSession(e){this.destroyed||(this.comments=[],this.queuedSnapshot=null,this.loaded=!1,this.user=e??{id:"signed-out",name:"Sign in"},this.managedUser=!0,this.draft=null,this.text="",this.replyText="",this.placing=!1,this.activeId=null,this.changed(),this.render())}async signIn(){if(this.storage instanceof p)try{await this.storage.signIn(),await this.refresh()}catch(e){this.destroyed||(this.report(e),this.render())}}async signOut(){if(this.storage instanceof p&&!this.saving)try{await this.storage.signOut(),await this.refresh()}catch(e){this.report(e),this.render()}}setUser(e){if(this.storage instanceof p)throw new Error("Hosted mode manages the signed-in account. Use signIn or signOut.");if(!this.destroyed){if(this.saving)throw new Error("Wait until the current comment is saved before changing users.");this.user=e?g(e):f(this.identityKey).user,this.managedUser=!!e,this.editing=null,this.draft=null,this.text="",this.replyText="",this.placing=!1,this.render()}}show(){var e;if(this.destroyed)return;this.visible||(this.returnFocus=document.activeElement),this.visible=!0,this.render(),this.trackLayoutMotion();const t=this.shadow.querySelector(".panel");t?(t.tabIndex=-1,t.focus({preventScroll:!0})):null==(e=this.shadow.querySelector(".launcher"))||e.focus(),this.checkForUpdate()}hide(){var e;this.destroyed||(this.visible=!1,this.placing=!1,this.draft=null,this.activeId=null,this.editing=null,this.text="",this.replyText="",this.render(),this.returnFocus instanceof HTMLElement&&this.returnFocus.isConnected?this.returnFocus.focus():null==(e=this.shadow.querySelector(".launcher"))||e.focus())}startComment(e){var t;if(this.storage instanceof p&&!this.storage.signedIn)this.signIn();else if(!(this.destroyed||this.initialLoad()||this.loadFailed||this.saving)){if(this.visible=!0,this.activeId=null,this.editing=null,this.text="",e){if(!Number.isFinite(e.x)||!Number.isFinite(e.y))throw new Error("Comment coordinates must be finite.");const t=e.x-window.scrollX,i=e.y-window.scrollY,n=document.elementFromPoint(t,i);if(this.config.container&&(!n||!this.config.container.contains(n)))throw new Error("Choose a position inside the configured container.");this.draft=this.makeDraft(e,n),this.placing=!1}else this.placing=!0,this.draft=null;this.render(),this.announce(e?"Write your comment.":"Click a place on the page, or Tab to an element and press Enter. Press Escape to cancel."),null==(t=this.shadow.querySelector("textarea"))||t.focus()}}navigateToComment(e){var t;if(this.destroyed)return;const i=this.comments.find(t=>t.id===e);if(i)try{const n=function(e,t){const i=new URL(e,t);if(!["http:","https:"].includes(i.protocol)||i.origin!==new URL(t).origin)throw new Error("Comments can only link to pages on this site.");return i}(i.pageUrl,location.href);if(!this.onCurrentPage(i.pageUrl)){try{sessionStorage.setItem(this.openKey,e)}catch{}return void location.assign(n.href)}this.visible=!0,this.placing=!1,this.draft=null,this.editing=null,this.activeId=e,this.replyText="",this.replyId=m(),this.flash(e),this.render();const s=i.selector?this.elementState(i):"shown";"hidden"===s||"removed"===s&&this.canReveal(i)?this.reveal(i):this.scrollToComment(i),null==(t=this.shadow.querySelector(".detail"))||t.focus({preventScroll:!0})}catch(n){this.report(n),this.visible=!0,this.render()}}scrollToComment(e){const t=this.reducedMotion()?"instant":"smooth",i=this.anchorElement(e);i&&!this.detached(e)?i.scrollIntoView({block:"center",behavior:t}):window.scrollTo({top:Math.max(0,e.y-window.innerHeight/2),behavior:t})}detached(e){return function(e,t){return"shown"!==pe(e,t)}(e,this.config.container)}elementState(e){var t,i,n,s;const o=pe(e,this.config.container);if("removed"!==o||(null==(t=this.revealed)?void 0:t.id)===e.id&&!this.revealed.result.shown)return o;const r=!1!==this.config.autoReveal?null==(s=null==(n=null==(i=e.element)?void 0:i.reveal)?void 0:n[0])?void 0:s.target:void 0;return r&&W(r)?"hidden":o}elementInfo(e){if(e.element)return e.element;const t=this.anchorElement(e)??(e.selector?(()=>{try{return document.querySelector(e.selector)}catch{return null}})():null);return t?xe(t):void 0}anchorStatus(e,t){var i,n;const s=T("div",`anchor-status ${t}`);if(s.dataset.anchorStatus=t,s.hidden="shown"===t,"shown"===t)return s;const o=this.elementInfo(e),r="hidden"===t,a=T("div","anchor-head"),l=T("span","anchor-icon");l.append(P(r?"eyeOff":"unlink"));const c=T("div","anchor-titles");c.append(T("strong","",r?"Element hidden":"Element removed")),o&&c.append(T("span","anchor-target",o.place?`${o.label} in ${o.place}`:o.label)),a.append(l,c),s.append(a);const d=(null==(i=this.revealed)?void 0:i.id)===e.id?null==(n=this.revealed.result.failed)?void 0:n.target.name:void 0,h=d??(null==o?void 0:o.place),p=r||d?h?`Open “${h}” to see it.`:"It is on this page, but not shown now. It can be in a closed menu, tab or filter.":"Nothing on this page matches it now. It was deleted, or it shows only after an action.";return s.append(T("p","",`${p} The dashed pin shows where the note was left.${this.canMove(e)?" Drag the pin to attach it again.":""}`)),(r||this.canReveal(e))&&s.append(L("Show Element","quiet anchor-action",()=>{this.reveal(e)},"eye")),s}canReveal(e){var t,i;return!!this.config.revealComponent||!1!==this.config.autoReveal&&!!(null==(i=null==(t=e.element)?void 0:t.reveal)?void 0:i.length)}async reveal(e){var t,i,n;let s=!1;try{s=!!(await(null==(i=(t=this.config).revealComponent)?void 0:i.call(t,c([e])[0],this.anchorElement(e))))}catch(a){this.report(a)}const o=null==(n=e.element)?void 0:n.reveal;if(!s&&!1!==this.config.autoReveal&&(null==o?void 0:o.length)){let t;this.endReveal(),this.replaying=!0;try{t=await async function(e,t){var i;const n=()=>U(t());if(n())return{shown:!0};for(let s=0;s<e.length;s++){const t=e[s],o=W(t.target);if("press"===t.action&&o&&X(o))return{shown:!1};if(!o||"focus"!==t.action&&!U(o))return{shown:!1,failed:t};const r=e[s+1]?()=>U(W(e[s+1].target)):n;if("hover"===t.action){for(const e of["pointerover","pointerenter","mouseover","mouseenter","pointermove","mousemove"])te(o,e);await ee(r,500)||(oe.set(o,"hover"),await ee(r,300)||(ie(o),await ee(r,500)||ne(o,"ArrowRight")))}else if("focus"===t.action)null==(i=o.focus)||i.call(o,{preventScroll:!0}),await ee(r,200)||oe.set(o,"focus");else if(!se(o)){const e=()=>r()||se(o);if(ie(o),!(await ee(e,900))){let i=!1;for(const t of G)if(ne(o,t),await ee(e,400)){i=!0;break}if(!i)return{shown:!1,failed:t}}}await ee(r,1200)}return{shown:await ee(n,1500)}}(o,()=>this.anchorElement(e))}finally{this.replaying=!1}if(this.destroyed||this.activeId!==e.id)return void re();this.revealed={id:e.id,result:t},s=t.shown}if(!s&&!1!==this.config.autoReveal){const t=this.anchorElement(e);t&&function(e){const t=[];for(let n=e instanceof HTMLElement?e:e.parentElement;n&&n!==document.body;n=n.parentElement)t.unshift(n);let i=!1;for(const n of t){if(n instanceof HTMLDetailsElement&&!n.open&&(n.open=!0,i=!0),n.hasAttribute("popover")&&!n.matches(":popover-open"))try{n.showPopover(),i=!0}catch{}if(!n.id||!n.hidden&&"none"!==getComputedStyle(n).display)continue;const e=CSS.escape(n.id),t=document.querySelector(`[aria-controls~="${e}"][aria-expanded="false"]`)??("tabpanel"===n.getAttribute("role")?document.querySelector(`[role=tab][aria-controls~="${e}"][aria-selected="false"]`):null);t&&(t.click(),i=!0)}return i}(t)&&(s=!0,await new Promise(e=>setTimeout(e,250)))}if(this.destroyed||this.activeId!==e.id)return;this.scrollToComment(e),this.render();const r=this.elementState(e);this.announce("shown"===r?"Showing the comment’s element.":"hidden"===r?"The comment’s element is still hidden. A dashed pin shows where it was.":"The comment’s element was removed. A dashed pin shows where it was.")}syncLayer(){const e=this.activeId?this.comments.find(e=>e.id===this.activeId):null,t=this.draft?this.anchorElement(this.draft):e?this.anchorElement(e):null,i=t?[...Ue("dialog:modal"),...Ue(":popover-open")].filter(e=>e.contains(t)):[],n=i.find(e=>i.every(t=>t.contains(e)))??document.body;this.host.parentElement!==n&&n.append(this.host)}endReveal(){this.revealed&&(this.revealed=null,re())}openPending(){const e=new URL(location.href).searchParams.get("cw_comment"),t=e?this.comments.find(t=>t.id===e&&this.onCurrentPage(t.pageUrl)):null;if(t){const e=new URL(location.href);return e.search=d(e.search),history.replaceState(history.state,"",e.href),void this.navigateToComment(t.id)}let i=null;try{i=sessionStorage.getItem(this.openKey),sessionStorage.removeItem(this.openKey)}catch{return}const n=i?this.comments.find(e=>e.id===i):null;n&&this.onCurrentPage(n.pageUrl)&&this.navigateToComment(n.id)}hoverNote(e){if(this.hoverId!==e){this.hoverId=e;for(const t of this.pins.querySelectorAll(".pin[data-id]"))t.classList.toggle("hovered",t.dataset.id===e);this.positionPins()}}flash(e){this.highlightId=e,clearTimeout(this.highlightTimer),this.highlightTimer=setTimeout(()=>{var e;this.highlightId=null,null==(e=this.pins.querySelector(".highlight"))||e.classList.remove("highlight")},2400)}destroy(){var e;if(!this.destroyed){this.destroyed=!0,++this.loadVersion,clearTimeout(this.highlightTimer),clearTimeout(this.searchTimer),this.storage instanceof p&&this.storage.destroy(),this.events.abort(),this.resizeObserver.disconnect(),this.mutationObserver.disconnect(),this.anchorObserver.disconnect(),this.observedAnchors.clear(),clearInterval(this.routeTimer),cancelAnimationFrame(this.frame),cancelAnimationFrame(this.motionFrame);for(const e of this.toastTimers)clearTimeout(e);this.toastTimers.clear(),this.sidebarOpen=!1,this.pushPage(),re();try{null==(e=this.unsubscribe)||e.call(this)}finally{this.host.remove()}}}initialLoad(){return this.loading&&!this.loaded}reducedMotion(){return window.matchMedia("(prefers-reduced-motion: reduce)").matches}choosePoint(e,t){var i;let n;try{n=this.makeDraft(e,t)}catch(s){return this.report(s),void this.render()}this.placing=!1,this.draft=n,this.render(),null==(i=this.shadow.querySelector("textarea"))||i.focus()}startPinDrag(e,t){if(this.suppressPinClick=!1,0!==e.button||!e.isPrimary||this.saving||this.pinDrag)return;const i=e.currentTarget,n=e.clientX-parseFloat(i.style.left),s=e.clientY-parseFloat(i.style.top),o=e.clientX,r=e.clientY,a=new AbortController,l={signal:a.signal};this.events.signal.addEventListener("abort",()=>a.abort(),l);let c=!1;window.addEventListener("pointermove",i=>{if(i.pointerId!==e.pointerId||!c&&Math.hypot(i.clientX-o,i.clientY-r)<5)return;c=!0;const[a,l]=this.pinBounds();this.pinDrag={id:t.id,x:Oe(i.clientX-n,a,l),y:Oe(i.clientY-s,46,innerHeight-6)};const d=document.elementFromPoint(this.pinDrag.x,this.pinDrag.y),h=d&&d!==this.host?le(d,this.config.container):null;this.pickTarget=h===document.body||h===document.documentElement?null:h,this.positionPins()},l);const d=i=>{if(i.pointerId!==e.pointerId)return;if(a.abort(),this.pickTarget=null,!c)return;this.suppressPinClick=!0;const n=this.pinDrag;if("pointercancel"===i.type||!n)return this.pinDrag=null,void this.positionPins();this.movePin(t.id,n).finally(()=>{this.pinDrag=null,this.positionPins()})};window.addEventListener("pointerup",d,{...l,capture:!0}),window.addEventListener("pointercancel",d,{...l,capture:!0})}pinBounds(){var e;const t=this.sidebarOpen&&innerWidth>600?400:0,i=!!(null==(e=this.config.position)?void 0:e.endsWith("left"));return[18+(i?t:0),innerWidth-16-2-(i?0:t)]}async movePin(e,t){var i,n;const s=this.comments.find(t=>t.id===e),o=document.elementFromPoint(t.x,t.y);if(!s||!o||o===this.host||this.config.container&&!this.config.container.contains(o))return void this.announce("Drop the pin on the page to move it.");const r={x:t.x+scrollX,y:t.y+scrollY};let a;try{a=this.makeDraft(r,o)}catch(d){return this.report(d),void this.render()}a.element&&!a.element.reveal&&(null==(i=this.revealed)?void 0:i.id)===e&&(null==(n=s.element)?void 0:n.reveal)&&(a.element.reveal=s.element.reveal);const l={...s,x:r.x,y:r.y,selector:a.selector,anchor:a.anchor,element:a.element,pageTitle:De()??s.pageTitle},c=this.getAllComments().map(t=>t.id===e?l:t);this.activeId=e,await this.mutate(c,()=>this.storage.upsertComment?this.storage.upsertComment(l):this.storage.saveComments(c),()=>{})}placePickRing(){var e;const t=this.pins.querySelector(".pick-ring");if(!t)return;const i=(this.placing||this.pinDrag)&&(null==(e=this.pickTarget)?void 0:e.isConnected)?this.pickTarget.getBoundingClientRect():null;t.hidden=!i||!i.width||!i.height,i&&Object.assign(t.style,{left:i.left-3+"px",top:i.top-3+"px",width:`${i.width+6}px`,height:`${i.height+6}px`})}placePopover(){var e,t;const i=this.surface.querySelector(".popover");if(!i)return;const n=innerWidth<=600;if(i.classList.toggle("sheet",n),n)return i.style.left="",void(i.style.top="");const s=this.draft?null:this.comments.find(e=>e.id===this.activeId),o=!!s&&(null==(e=this.pinDrag)?void 0:e.id)===s.id;if(i.classList.toggle("moving",o),o)return;const r=o?this.pinDrag:this.draft?this.position({...this.draft,...this.draft.position}):s?this.position(s)??(this.detached(s)?{x:s.x-scrollX,y:s.y-scrollY}:null):null,a=o?null:this.draft?this.anchorElement(this.draft):s?this.anchorElement(s):null,l=i.offsetWidth,c=i.offsetHeight,d=this.sidebarOpen?400:0,h=!!(null==(t=this.config.position)?void 0:t.endsWith("left")),p=ze+(h?d:0),u=innerWidth-ze-(h?0:d)-l;let m=u,g=72;if(r&&r.x>=0&&r.y>=0&&r.x<=innerWidth&&r.y<=innerHeight){const e=null==a?void 0:a.getBoundingClientRect();m=e&&e.right+12<=u?e.right+12:e&&e.left-12-l>=p?e.left-12-l:r.x+24<=u?r.x+24:r.x-24-l,g=r.y-40}i.style.left=`${Oe(m,p,u)}px`,i.style.top=`${Oe(g,ze,innerHeight-ze-c)}px`}makeDraft(e,t){const i={id:m(),timestamp:new Date,position:e,pageUrl:this.currentPage()};if((t=t?le(t,this.config.container):null)&&!this.host.contains(t)){const n=t.getBoundingClientRect();if(n.width&&n.height){i.selector=function(e,t){const i=e.getAttribute("data-overplay-anchor");if(i&&he(`[data-overplay-anchor="${CSS.escape(i)}"]`,t)===e)return`[data-overplay-anchor="${CSS.escape(i)}"]`;if(e===document.body)return"body";if(e===document.documentElement)return"html";const n=[];for(let s=e;s&&s!==document.body;s=s.parentElement){if(s.id&&!de(s.id)&&1===document.querySelectorAll(`#${CSS.escape(s.id)}`).length){n.unshift(`#${CSS.escape(s.id)}`);break}const t=s!==e?s.getAttribute("data-overplay-anchor"):null;if(t&&1===document.querySelectorAll(`[data-overplay-anchor="${CSS.escape(t)}"]`).length){n.unshift(`[data-overplay-anchor="${CSS.escape(t)}"]`);break}const i=s.parentElement?Array.from(s.parentElement.children).filter(e=>e.tagName===s.tagName):[];n.unshift(`${s.tagName.toLowerCase()}:nth-of-type(${i.indexOf(s)+1})`)}return n.join(" > ")}(t,this.config.container),i.element=xe(t);const s=!1!==this.config.autoReveal?this.recorder.capture(t):[];s.length&&(i.element.reveal=s),i.anchor={x:Math.max(0,Math.min(1,(e.x-scrollX-n.left)/n.width)),y:Math.max(0,Math.min(1,(e.y-scrollY-n.top)/n.height))}}}if(!i.selector||!i.anchor)throw new Error("Choose a visible page element to attach this note.");return i}anchorElement(e){return e.selector?he(e.selector,this.config.container):null}position(e){return function(e,t){if(!e.selector)return{x:e.x-scrollX,y:e.y-scrollY};const i=he(e.selector,t);if(!i||!i.getClientRects().length)return null;const n=i.getBoundingClientRect();if(!n.width||!n.height||"visible"!==getComputedStyle(i).visibility)return null;const s=e.anchor??{x:.5,y:.5},o={x:n.left+n.width*s.x,y:n.top+n.height*s.y};for(let r=i.parentElement;r&&r!==document.body&&r!==document.documentElement;r=r.parentElement){const e=getComputedStyle(r),t=r.getBoundingClientRect(),i=t.left+r.clientLeft,n=t.top+r.clientTop;if(/(auto|scroll|hidden|clip)/.test(e.overflowX)&&(o.x<i||o.x>i+r.clientWidth))return null;if(/(auto|scroll|hidden|clip)/.test(e.overflowY)&&(o.y<n||o.y>n+r.clientHeight))return null}return o}(e,this.config.container)}observeAnchors(){var e;const t=new Set;for(const i of this.pageComments()){const e=this.anchorElement(i);e&&t.add(e)}if(null==(e=this.draft)?void 0:e.selector){const e=this.anchorElement(this.draft);e&&t.add(e)}for(const i of this.observedAnchors)t.has(i)||this.anchorObserver.unobserve(i);for(const i of t)this.observedAnchors.has(i)||this.anchorObserver.observe(i);this.observedAnchors=t}positionPins(){var e,t,i,n;this.observeAnchors();const s=this.host.parentElement;s&&s!==document.body&&![...Ue("dialog[open]"),...Ue(":popover-open")].includes(s)&&document.body.append(this.host);for(const c of this.pins.querySelectorAll("[data-id]")){const t=this.comments.find(e=>e.id===c.dataset.id);if(!t)continue;const i=(null==(e=this.pinDrag)?void 0:e.id)===t.id;c.classList.toggle("dragging",i);const n=!i&&t.id===this.activeId&&this.detached(t);c.classList.toggle("detached",n);const s=i?this.pinDrag:n?{x:t.x-scrollX,y:t.y-scrollY}:this.position(t);if(!s){c.hidden=!0;continue}const[o,r]=this.pinBounds();if(c.style.left=`${Oe(s.x,o,r)}px`,c.style.top=`${s.y}px`,c.classList.toggle("below",s.y<40),c.hidden=s.x<0||s.y<0||s.x>innerWidth||s.y>innerHeight,this.config.container){const e=this.config.container.getBoundingClientRect();c.hidden||(c.hidden=s.x<e.left||s.x>e.right||s.y<e.top||s.y>e.bottom)}}const o=this.comments.find(e=>e.id===this.activeId),r=this.pins.querySelector(".focus-ring");if(r){const e=o?null==(t=this.anchorElement(o))?void 0:t.getBoundingClientRect():void 0;r.hidden=!e||!e.width||!e.height||(null==(i=this.pinDrag)?void 0:i.id)===(null==o?void 0:o.id),e&&Object.assign(r.style,{left:e.left-4+"px",top:e.top-4+"px",width:`${e.width+8}px`,height:`${e.height+8}px`})}const a=this.pins.querySelector(".hover-ring");if(a){const e=this.hoverId?this.comments.find(e=>e.id===this.hoverId):void 0,t=e&&e.id!==this.activeId?null==(n=this.anchorElement(e))?void 0:n.getBoundingClientRect():void 0;a.hidden=!t||!t.width||!t.height,t&&Object.assign(a.style,{left:t.left-4+"px",top:t.top-4+"px",width:`${t.width+8}px`,height:`${t.height+8}px`})}this.placePickRing(),this.placePopover();const l=this.surface.querySelector("[data-anchor-status]");if(l&&o){const e=this.elementState(o);l.dataset.anchorStatus!==e&&l.replaceWith(this.anchorStatus(o,e))}}checkForUpdate(){var e;const t="function"==typeof(null==(e=globalThis.Overplay)?void 0:e.init);var i;!this.updateChecked&&(this.config.updateNotice??(i=location.hostname,(["localhost","127.0.0.1","[::1]","::1"].includes(i)||/\.(localhost|local|test)$/.test(i))&&!t))&&(this.updateChecked=!0,async function(e=fetch,t=Date.now()){const i="overplay:latest-version";try{const e=JSON.parse(localStorage.getItem(i)||"null");if(e&&"string"==typeof e.version&&t-e.checkedAt<432e5)return e.version}catch{}try{const n=await e(`https://registry.npmjs.org/${y}/latest`,{credentials:"omit",referrerPolicy:"no-referrer"});if(!n.ok)return null;const s=await n.json();if("string"!=typeof s.version)return null;try{localStorage.setItem(i,JSON.stringify({version:s.version,checkedAt:t}))}catch{}return s.version}catch{return null}}().then(e=>{if(!this.destroyed&&e&&function(e,t){const i=e=>{var t;return null==(t=/^(\d+)\.(\d+)\.(\d+)$/.exec(e.trim()))?void 0:t.slice(1).map(Number)},n=i(e),s=i(t);if(!n||!s)return!1;for(let o=0;o<3;o++)if(n[o]!==s[o])return n[o]>s[o];return!1}(e,b)){try{if(localStorage.getItem(qe)===e)return}catch{}this.update=e,this.render()}}))}async copyUpdate(){const e=k(b,this.update??"latest");let t=!1;try{await navigator.clipboard.writeText(e),t=!0}catch{}t||(this.updatePromptOpen=!0,this.render()),this.toast({kind:"comment",commentId:"",author:t?"Update prompt copied":"Copy the prompt below",text:t?"Paste it into your coding agent. It updates the package, clears the cache and restarts the dev server.":"Select the prompt text and copy it."},!0),this.announce(t?"Update prompt copied.":"Select the prompt text to copy it.")}dismissUpdate(){try{localStorage.setItem(qe,this.update??"")}catch{}this.update=null,this.render()}startDrag(e){if(this.suppressClick=!1,0!==e.button||!e.isPrimary)return;const t=e.currentTarget.getBoundingClientRect(),i=e.clientX-t.left,n=e.clientY-t.top,s=e.clientX,o=e.clientY,r=new AbortController,a={signal:r.signal};this.events.signal.addEventListener("abort",()=>r.abort(),{signal:r.signal}),window.addEventListener("pointermove",t=>{var r;if(t.pointerId!==e.pointerId)return;if(!this.dragging&&Math.hypot(t.clientX-s,t.clientY-o)<5)return;this.dragging=!0;const a=Oe(t.clientX-i,ze,innerWidth-Re-ze),l=Oe(t.clientY-n,ze,innerHeight-Re-ze);this.launcherSpot={x:(a+26)/innerWidth,y:(l+26)/innerHeight},null==(r=this.shadow.querySelector(".launcher"))||r.classList.add("dragging"),this.placeLauncher()},a);const l=t=>{var i;if(t.pointerId===e.pointerId&&(r.abort(),this.dragging)){this.dragging=!1,this.suppressClick=!0,null==(i=this.shadow.querySelector(".launcher"))||i.classList.remove("dragging");try{localStorage.setItem(this.launcherKey,JSON.stringify(this.launcherSpot))}catch{}}};window.addEventListener("pointerup",l,{...a,capture:!0}),window.addEventListener("pointercancel",l,{...a,capture:!0})}pageComments(){return this.comments.filter(e=>this.onCurrentPage(e.pageUrl)).sort((e,t)=>e.timestamp.getTime()-t.timestamp.getTime()||e.id.localeCompare(t.id))}closePopup(e=!0){var t;this.draft=null,this.activeId=null,this.placing=!1,this.editing=null,this.text="",this.replyText="",this.render(),e&&(null==(t=this.shadow.querySelector(".panel .primary, .launcher"))||t.focus())}setDocked(e){var t;this.docked=e;try{localStorage.setItem(this.dockKey,e?"1":"0")}catch{}this.render(),null==(t=this.shadow.querySelector(".detail"))||t.focus({preventScroll:!0})}scopeComments(){return"page"===this.scope?this.pageComments():[...this.comments].sort((e,t)=>e.timestamp.getTime()-t.timestamp.getTime()||e.id.localeCompare(t.id))}noteNumbers(){const e=new Map,t=new Map;for(const i of[...this.comments].sort((e,t)=>e.timestamp.getTime()-t.timestamp.getTime()||e.id.localeCompare(t.id))){const n=this.onCurrentPage(i.pageUrl)?"":i.pageUrl,s=(e.get(n)??0)+1;e.set(n,s),t.set(i.id,s)}return t}async mutate(e,t,i){if(!(this.saving||this.initialLoad()||this.loadFailed||this.destroyed)){this.loading&&(++this.loadVersion,this.loading=!1),this.saving=!0,this.error="",this.render();try{if(await t(),this.destroyed)return;this.comments=e;try{this.comments=l(await this.storage.loadComments())}catch{this.error="Saved. Could not refresh other comments. Use Refresh to try again."}if(this.destroyed)return;this.queuedSnapshot=null,i(),this.changed(),this.noticeActivity(),this.announce(this.error||"Changes saved.")}catch(n){this.destroyed||this.report(n)}finally{this.destroyed||(this.saving=!1,this.render())}}}toggleResolved(e){const t={...e,resolved:!e.resolved},i=this.getAllComments().map(i=>i.id===e.id?t:i);this.mutate(i,()=>this.storage.setResolved?this.storage.setResolved(e.id,t.resolved):this.storage.upsertComment?this.storage.upsertComment(t):this.storage.saveComments(i),()=>{})}deleteNote(e){const t=this.getAllComments().filter(t=>t.id!==e.id);this.mutate(t,()=>this.storage.deleteComment?this.storage.deleteComment(e.id):this.storage.saveComments(t),()=>{this.activeId=null})}render(){var e,t,i,n,s,o,r;if(this.destroyed)return;if(this.composing)return void(this.renderDeferred=!0);this.revealed&&this.activeId!==this.revealed.id&&this.endReveal(),this.syncLayer(),(!this.sidebarOpen||this.activeId||this.draft)&&(this.hoverId=null);const a=this.shadow.activeElement,l=a instanceof HTMLElement?a.dataset.focus:void 0,c=a instanceof HTMLInputElement||a instanceof HTMLTextAreaElement?[a.selectionStart,a.selectionEnd]:null,d=(null==(e=this.shadow.querySelector(".list"))?void 0:e.scrollTop)??0,h=(null==(t=this.shadow.querySelector(".thread-body"))?void 0:t.scrollTop)??0,p=!!this.surface.querySelector(".panel");this.host.dataset.theme=this.settings.theme,this.surface.replaceChildren(),this.pins.replaceChildren();const u=this.visible?this.detail():null,m=!!u&&(this.docked||!!this.editing),g=this.visible&&(m||!this.config.hideSidebar);if(this.config.hideButton||g||this.surface.append(this.launcher()),this.visible){if(g&&this.surface.append(this.sidebar(m?u:null)),u&&!m){const e=T("div","popover");e.append(u),this.surface.append(e),null==(i=this.surface.querySelector(".panel"))||i.classList.add("behind")}if(this.renderPins(),this.placing){const e=T("div",`notice${g?" beside-panel":""}${(null==(n=this.config.position)?void 0:n.endsWith("left"))?" left":""}`);e.append(P("pin"),T("span","","Click anywhere to leave a note, or Tab to an element and press Enter."));const t=T("kbd","","Esc");e.append(t,L("Cancel placement","icon-button",()=>this.closePopup(),"close")),this.surface.append(e)}}null==(s=this.surface.querySelector(".panel"))||s.classList.toggle("entering",!p);const f=u?this.editing?this.editing:this.draft?`draft:${this.draft.id}`:`thread:${this.activeId}`:"";null==u||u.classList.toggle("entering",(p||!m)&&f!==this.detailKey),this.detailKey=f,this.toasts.classList.toggle("beside-panel",g),this.sidebarOpen=g,this.pushPage(),this.toasts.classList.toggle("left",!!(null==(o=this.config.position)?void 0:o.endsWith("left"))),this.toasts.classList.toggle("top",!!(null==(r=this.config.position)?void 0:r.startsWith("top")));const v=this.shadow.querySelector(".list");v&&(v.scrollTop=d);const x=this.shadow.querySelector(".thread-body");if(x&&(x.scrollTop=h),l){const e=Array.from(this.shadow.querySelectorAll("[data-focus]")).find(e=>e.dataset.focus===l);null==e||e.focus({preventScroll:!0}),c&&(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&e.setSelectionRange(c[0],c[1])}this.positionPins()}launcher(){const e=L("Comments","launcher"+(this.dragging?" dragging":""),()=>{this.suppressClick?this.suppressClick=!1:this.visible?this.hide():this.show()},"comment");e.replaceChildren(P("comment")),this.paintLauncher(e),e.dataset.focus="launcher",e.setAttribute("aria-expanded",String(this.visible)),e.title="Comments. Drag to move.",e.addEventListener("pointerdown",e=>this.startDrag(e));const t=this.pageComments().filter(e=>!e.resolved).length;e.setAttribute("aria-label",t?`Comments, ${t} open`:"Comments"),t&&e.append(T("span","badge",String(t)));const i=this.config.position??"bottom-right";return i.endsWith("left")&&(e.style.left="24px",e.style.right="auto"),i.startsWith("top")&&(e.style.top="24px",e.style.bottom="auto"),this.launcherSpot&&queueMicrotask(this.placeLauncher),e}heading(e,t){const i=T("div","head"),n=T("span","brand-icon");n.append(P("comment"));const s=T("div","heading");s.append(T("h2","",e)),t&&s.append(T("p","subtext",t));const o=T("div","head-actions"),r=L("Settings","icon-button",()=>this.openSettings(),"settings");return r.dataset.focus="settings",o.append(r,this.userMenu(),L("Close comments","icon-button",()=>this.hide(),"close")),i.append(n,s,o),i}menuItem(e,t,i,n=""){const s=L(e,`menu-item ${n}`,i,t);return s.setAttribute("role","menuitem"),s}menuToggle(e,t){t.hidden=!0,t.setAttribute("role","menu"),e.setAttribute("aria-haspopup","menu"),e.setAttribute("aria-expanded","false"),e.addEventListener("click",()=>{var i;const n=t.hidden;this.closeMenus(),t.hidden=!n,e.setAttribute("aria-expanded",String(n)),n&&(null==(i=t.querySelector("button:not(:disabled)"))||i.focus())})}closeMenus(){let e=null;for(const t of this.shadow.querySelectorAll("[role=menu]"))t.hidden=!0;for(const t of this.shadow.querySelectorAll("[aria-haspopup=menu]"))"true"===t.getAttribute("aria-expanded")&&(e=t),t.setAttribute("aria-expanded","false");return e}userMenu(){const e=this.storage instanceof p?this.storage:null;if(e&&!e.signedIn){const e=L("Sign In","quiet sign-in",()=>{this.signIn()},"signin");return e.title="Sign in to join this project",e}const t=T("div","menu-wrap"),i=T("button","user-button");i.type="button",i.dataset.focus="user",i.setAttribute("aria-label",`Account: ${this.user.name}`),i.title=this.user.name,i.append(M(this.user.name,this.user.avatarUrl));const n=T("div","pop-menu user-menu"),s=T("div","menu-user"),o=T("div","menu-user-text");if(o.append(T("strong","",this.user.name),T("small","",e?"Signed in to this project":this.managedUser?"Your project account":this.persistentGuest?"Guest in this browser":"Guest for this page view")),s.append(M(this.user.name,this.user.avatarUrl),o),n.append(s),e||this.managedUser||n.append(this.menuItem("Edit Your Name","edit",()=>{var e;this.editing="identity",this.draft=null,this.activeId=null,this.placing=!1,this.render(),null==(e=this.shadow.querySelector("#guest-name"))||e.focus()})),n.append(this.menuItem("Settings","settings",()=>this.openSettings())),e){const e=this.menuItem("Sign Out","signout",()=>{this.signOut()});e.disabled=this.saving,n.append(e)}const r=T("p","menu-note");return r.append(T("span","storage-dot"),T("span","",e?"Comments sync with your team":this.storage instanceof u?"Comments are saved in this browser":"Comments use connected storage")),n.append(r),this.menuToggle(i,n),t.append(i,n),t}openSettings(){var e;this.editing="settings",this.draft=null,this.activeId=null,this.placing=!1,this.render(),null==(e=this.shadow.querySelector(".detail"))||e.focus({preventScroll:!0})}detailHeading(e,t,i){const n=T("div","detail-head"),s=T("div","detail-bar"),o=L("Back to comments","back-link",()=>this.closePopup(),"back");o.querySelector("span").textContent="Comments",s.append(o,L("Close comments","icon-button",()=>this.hide(),"close"));const r=T("div","detail-title");return r.append(T("h2","",e)),i&&r.append(i),n.append(s,r),t&&n.append(T("p","subtext",t)),n}cardHeading(e,t,i,n="",s){const o=T("div","card-head");if(this.docked){const e=T("div","detail-bar"),t=L("Back to comments","back-link",()=>this.closePopup(),"back");t.querySelector("span").textContent="Comments",e.append(t,L("Close comments","icon-button",()=>this.hide(),"close")),o.append(e)}const r=T("div","pop-head");n&&(r.title=n);const a=T("span","pop-icon");a.append(P(i));const l=T("div","pop-title");l.append(T("h2","",e),T("p","pop-sub",t));const c=T("div","pop-menu"),d=this.menuItem.bind(this);if(s){const e=d("Delete Comment","trash",()=>{e.dataset.confirm?s():(e.dataset.confirm="1",e.querySelector("span").textContent="Click Again to Delete")},"danger");e.disabled=this.saving,c.append(e)}if(r.append(a,l),c.childElementCount){const e=L("More actions","icon-button more",()=>{},"more");this.menuToggle(e,c),r.append(e)}return this.docked||r.append(L("Close","icon-button",()=>this.closePopup(),"close")),c.childElementCount&&r.append(c),o.append(r),o}errorBox(){const e=T("div","error",this.error);return(this.loadFailed||this.error.startsWith("Saved."))&&e.append(L("Try Again","quiet",()=>{this.refresh()})),e}detail(){if("settings"===this.editing)return this.settingsView();if("identity"===this.editing)return this.identityForm();if(this.draft)return this.newCommentForm();const e=this.comments.find(e=>e.id===this.activeId&&this.onCurrentPage(e.pageUrl));return e?this.thread(e):null}sidebar(e){var t;const i=T("section",`panel${(null==(t=this.config.position)?void 0:t.endsWith("left"))?" left":""}${this.placing?" placing":""}`);if(i.setAttribute("aria-label","Comments"),e)return i.append(e),i;i.append(this.heading("Comments",""));const n=T("div","toolbar"),s=L("Add Comment","primary",()=>this.startComment(),"plus");s.disabled=this.initialLoad()||this.loadFailed||this.saving;const o=L("Refresh comments","icon-button outlined"+(this.loading?" busy":""),()=>{this.refresh()},"refresh");o.disabled=this.loading||this.saving,n.append(s,o),i.append(n),i.append(this.scopeBar());const r=this.scopeComments();r.length&&i.append(this.searchField(),this.peopleBar()),i.append(this.statusTabs()),this.error&&i.append(this.errorBox()),i.append(this.commentList(r));const a=this.footer();return a&&i.append(a),i.addEventListener("keydown",e=>{const t=e.composedPath()[0];if("/"!==e.key||e.ctrlKey||e.metaKey||e.altKey||e.isComposing)return;if(t instanceof Element&&t.closest("input,textarea,select"))return;const i=this.shadow.querySelector(".search input");i&&(e.preventDefault(),i.focus(),i.select())}),i}filterContext(e=this.scope){return{userId:this.user.id,includePage:"all"===e,elementOf:e=>this.onCurrentPage(e.pageUrl)?this.elementInfo(e):e.element}}restoreFilters(){try{const e=JSON.parse(sessionStorage.getItem(this.filterKey)||"null");if(!e)return;this.filters=function(e){const t=e&&"object"==typeof e?e:{};return{status:"resolved"===t.status||"all"===t.status?t.status:"open",query:"string"==typeof t.query?t.query.slice(0,200):"",mine:!0===t.mine,author:"string"==typeof t.author?t.author.slice(0,300):""}}(e),this.scope="all"===e.scope?"all":"page"}catch{}}saveFilters(){try{sessionStorage.setItem(this.filterKey,JSON.stringify({...this.filters,scope:this.scope}))}catch{}}setFilters(e,t){this.filters={...this.filters,...e},t&&(this.scope=t),this.saveFilters(),this.render(),this.announceResults()}announceResults(){const e=this.scopeComments();if(!this.sidebarOpen||!e.length)return;const t=$e(e,this.filters,this.filterContext()).length;this.announce(t?`${t} ${1===t?"note":"notes"} shown.`:"No notes match.")}refreshResults(){const e=this.scopeComments(),t=(e,t)=>{var i;return null==(i=this.shadow.querySelector(e))?void 0:i.replaceWith(t)};t(".scope",this.scopeBar()),t(".people",this.peopleBar()),t(".tabs",this.statusTabs()),t(".list",this.commentList(e)),this.pins.replaceChildren(),this.renderPins(),this.positionPins()}scopeBar(){const e=T("div","scope");e.setAttribute("role","group"),e.setAttribute("aria-label","Show comments from");const t={...this.filters,status:"all"};for(const[i,n]of[["page","This Page"],["all","All Pages"]]){const s=$e("page"===i?this.pageComments():this.comments,t,this.filterContext(i)).length,o=L(n,"scope-option",()=>this.setFilters({},i));o.setAttribute("aria-label",`${n}, ${s} ${1===s?"note":"notes"}`),o.setAttribute("aria-pressed",String(this.scope===i)),o.dataset.focus=`scope-${i}`,o.append(T("span","count",String(s))),e.append(o)}return e}searchField(){const e=T("div","search");e.setAttribute("role","search");const t=T("input");t.type="search",t.placeholder="Search notes, replies, people…",t.setAttribute("aria-label","Search comments"),t.value=this.filters.query,t.dataset.focus="search",t.maxLength=200,t.setAttribute("aria-keyshortcuts","/"),t.autocomplete="off",t.spellcheck=!1;const i=L("Clear search","icon-button search-clear",()=>{t.value="",n(!0),t.focus()},"close");i.hidden=!t.value;const n=e=>{clearTimeout(this.searchTimer),i.hidden=!t.value;const n=()=>{this.destroyed||this.filters.query===t.value||(this.filters={...this.filters,query:t.value},this.saveFilters(),this.refreshResults(),this.announceResults())};e?n():this.searchTimer=setTimeout(n,180)};return t.addEventListener("input",()=>n(!1)),t.addEventListener("keydown",e=>{"Escape"===e.key&&t.value&&!e.isComposing?(e.preventDefault(),t.value="",n(!0)):"Enter"!==e.key||e.isComposing||(e.preventDefault(),n(!0))}),e.append(P("search"),t,i),e}peopleBar(){const e=T("div","people");e.setAttribute("role","group"),e.setAttribute("aria-label","Filter by person");const t=Pe(this.scopeComments(),this.filters,this.filterContext()),i=this.storage instanceof p?this.storage:null;if(!i||i.signedIn){const i=L("Mine","filter-chip",()=>this.setFilters({mine:!this.filters.mine,author:""}));i.title="Only notes you started",i.dataset.focus="filter-mine",i.setAttribute("aria-label",`Mine, ${t.mine} ${1===t.mine?"note":"notes"}`),i.setAttribute("aria-pressed",String(this.filters.mine)),i.append(T("span","count",String(t.mine))),e.append(i)}const n=t.authors;if(this.filters.author&&!n.some(e=>e.key===this.filters.author)&&n.push({key:this.filters.author,name:"Earlier author",count:0}),n.length>1||this.filters.author){const t=T("span","select"+(this.filters.author?" chosen":"")),i=T("select");i.setAttribute("aria-label","Author"),i.dataset.focus="filter-author",i.append(new Option("All Authors",""));for(const e of n)i.append(new Option(`${e.name} (${e.count})`,e.key));i.value=this.filters.author,i.addEventListener("change",()=>this.setFilters({author:i.value,mine:!1})),t.append(i),e.append(t)}if(Le(this.filters)){const t=L("Clear Filters","link-button",()=>this.clearAllFilters());t.dataset.focus="filter-clear",e.append(t)}return e.hidden=!e.childElementCount,e}statusTabs(){const e=T("div","tabs");e.setAttribute("role","group"),e.setAttribute("aria-label","Filter by status");const t=Pe(this.scopeComments(),this.filters,this.filterContext());for(const[i,n]of[["open","Open"],["resolved","Resolved"],["all","All"]]){const s=L(n,"tab",()=>this.setFilters({status:i}));s.setAttribute("aria-label",`${n}, ${t[i]} ${1===t[i]?"note":"notes"}`),s.setAttribute("aria-pressed",String(this.filters.status===i)),s.dataset.focus=`tab-${i}`,s.append(T("span","count",String(t[i]))),e.append(s)}return e}clearAllFilters(){var e,t;this.setFilters((t=this.scopeComments(),{...we,status:t.some(e=>!e.resolved)||!t.length?"open":"all"})),null==(e=this.shadow.querySelector(".search input, .panel .primary"))||e.focus()}commentList(e){var t;const i=T("div","list");i.setAttribute("aria-busy",String(this.loading));const n=$e(e,this.filters,this.filterContext()),s="page"===this.scope;if(this.initialLoad())i.append(this.empty("Loading your notes","Your comments will appear here in a moment."));else if(this.loadFailed)i.append(this.empty("Could not load comments","Your stored notes have not been changed. Try loading them again."));else if(e.length)if(n.length){const e=this.noteNumbers(),o=new Map;for(const t of[...n].sort((e,t)=>t.timestamp.getTime()-e.timestamp.getTime())){const e=this.onCurrentPage(t.pageUrl)?"":t.pageUrl;o.set(e,[...o.get(e)??[],t])}const r=[...o].sort(([e],[t])=>Number(""!==e)-Number(""!==t));for(const[n,a]of r){const o=T("div","list-title");if(s)o.textContent="On this page";else{const e=Ne(n||this.currentPage()),i=(n?null==(t=a.find(e=>e.pageTitle))?void 0:t.pageTitle:De())??e,s=T("span",i===e?"page-path":"page-name",i);if(s.title=e,o.append(s),i!==e){const t=T("span","page-path sub",e);t.title=e,o.append(t)}n||o.append(T("span","here","This page"))}i.append(o);for(const t of a)i.append(this.noteRow(t,e.get(t.id)??0,!!n))}}else{const e=this.filters.query.trim(),t=e?`Nothing ${s?"on this page":"on any page"} matches “${e.length>60?`${e.slice(0,60)}…`:e}”.`:Le(this.filters)?"No notes fit these filters.":"open"===this.filters.status?"Every note here is resolved.":"No note here is resolved yet.";i.append(this.empty("No notes match",t,L("Clear Filters","quiet",()=>this.clearAllFilters())))}else i.append(this.empty("Good ideas start here",s?"Pin a thought to any part of this page. Keep the conversation in context.":"Comments from every page of this site appear here.",s?L("Leave the First Note","quiet",()=>this.startComment()):void 0));return i}noteRow(e,t,i){const n=e.pageTitle||Ne(e.pageUrl),s=L(i?`Open comment by ${e.author} on ${n}`:`Open comment by ${e.author}`,"note"+(this.activeId===e.id?" current":""),()=>this.navigateToComment(e.id));s.replaceChildren();const o=ke(this.filters.query),r=T("div","note-main");r.append(this.messageHeader(e.author,e.timestamp,e.avatarUrl,e.via,o),je(T("p","note-text"),e.text,o));const a=o.length?Ee(e,o,this.filterContext()):null,l=(null==a?void 0:a.reply)?[`${a.reply.author}: `,a.reply.text]:(null==a?void 0:a.element)?["Element: ",a.element]:null;if(l){const e=T("p","note-match");e.append(P((null==a?void 0:a.reply)?"comment":"pin"),T("span","note-match-label",l[0])),e.append(je(T("span","note-match-text"),function(e,t,i=90){var n;const s=e.replace(/\s+/g," ").trim();if(s.length<=i)return s;const o=(null==(n=Se(s,t)[0])?void 0:n[0])??0,r=Math.max(0,Math.min(o-Math.floor(i/3),s.length-i));return`${r>0?"…":""}${s.slice(r,r+i).trim()}${r+i<s.length?"…":""}`}(l[1],o),o)),r.append(e)}const c=i?"shown":this.elementState(e);if(e.replies.length||i||"shown"!==c){const t=T("div","note-footer");if(e.replies.length&&t.append(P("comment"),T("span","",`${e.replies.length} ${1===e.replies.length?"reply":"replies"}`)),"shown"!==c){const i=this.elementInfo(e),n=T("span",`hidden-flag ${c}`,"removed"===c?"Element removed":(null==i?void 0:i.place)?`Hidden in ${i.place}`:"Element hidden");n.prepend(P("removed"===c?"unlink":"eyeOff")),n.title=i?`${i.label}${i.place?` in ${i.place}`:""}. Open the comment to see where it was.`:"Open the comment to see where it was.",t.append(n)}if(i){const e=T("span","go","Go to Page");e.append(P("open")),t.append(e)}r.append(t)}const d=T("span","note-meta"),h=T("span","status"+(e.resolved?" resolved":""),e.resolved?"Resolved":"Open");return e.resolved?h.prepend(P("check")):h.prepend(T("span","status-dot")),d.append(T("span","note-number",`#${t}`),h),s.append(r,d),i||(s.addEventListener("pointerenter",()=>this.hoverNote(e.id)),s.addEventListener("pointerleave",()=>this.hoverNote(null)),s.addEventListener("focus",()=>this.hoverNote(e.id)),s.addEventListener("blur",()=>this.hoverNote(null))),s}empty(e,t,i){const n=T("div","empty"),s=T("div"),o=T("div","empty-icon");return o.append(P("No notes match"===e?"search":"comment")),s.append(o,T("h3","",e),T("p","",t)),i&&s.append(i),n.append(s),n}footer(){if(!this.update)return null;const e=T("div","footer update-bar");e.setAttribute("role","status");const t=T("span","update-icon");t.append(P("refresh"));const i=T("div","update-text");i.append(T("strong","",`Version ${this.update} is available`),T("span","",`You have ${b}. Give this prompt to your coding agent to update.`));const n=T("div","update-actions"),s=L(this.updatePromptOpen?"Hide Prompt":"Show Prompt","quiet update-toggle",()=>{this.updatePromptOpen=!this.updatePromptOpen,this.render()},"sparkle");s.setAttribute("aria-expanded",String(this.updatePromptOpen));const o=L("Copy Prompt","quiet update",()=>{this.copyUpdate()},"copy");if(n.append(s,o),e.append(t,i,L("Hide until the next version","icon-button",()=>this.dismissUpdate(),"close"),n),this.updatePromptOpen){const t=T("pre","update-prompt",k(b,this.update));t.tabIndex=0,t.setAttribute("aria-label","Update prompt for your coding agent"),e.append(t)}return e}messageHeader(e,t,i,n,s=[]){const o=T("div","note-header"),r=T("time","time",function(e){const t=Math.max(0,Math.floor((Date.now()-e.getTime())/6e4));return t<1?"Just now":t<60?`${t}m ago`:t<1440?`${Math.floor(t/60)}h ago`:e.toLocaleDateString(void 0,{month:"short",day:"numeric"})}(t));if(r.dateTime=t.toISOString(),r.title=t.toLocaleString(),o.append(M(e,i),je(T("span","name"),e,s)),n){const e=T("span","via",`via ${n}`);e.title=`Posted through MCP by ${n}`,o.append(e)}return o.append(r),o}view(e,t=""){const i=T("div",`detail ${t}`);return i.setAttribute("role","group"),i.setAttribute("aria-label",e),i.tabIndex=-1,i}composer(e){const t=T("form","compose"),i=T("textarea");i.setAttribute("aria-label",e?"Reply":"Comment"),i.placeholder=e?"Keep the conversation going…":"What’s on your mind?",i.maxLength=1e4,i.required=!0,i.value=e?this.replyText:this.text,i.dataset.focus=e?"reply":"comment",i.disabled=this.saving;const n=T("div","compose-bar"),s=T("span","compose-hint","⌘ / Ctrl + Enter to send"),o=L(this.saving?"Saving…":e?"Send Reply":"Post Comment","primary",()=>{},"arrow");return o.type="submit",o.disabled=this.saving||!i.value.trim(),i.addEventListener("input",()=>{e?this.replyText=i.value:this.text=i.value,o.disabled=this.saving||!i.value.trim()}),i.addEventListener("keydown",e=>{!e.ctrlKey&&!e.metaKey||"Enter"!==e.key||e.isComposing||(e.preventDefault(),o.disabled||t.requestSubmit())}),t.addEventListener("submit",t=>{t.preventDefault(),this.saving||(e?this.submitReply():this.submitComment())}),n.append(s,o),t.append(i,n),t}newCommentForm(){const e=this.view("New comment","new-comment");return e.append(this.cardHeading("New comment",`Commenting as ${this.user.name}`,"plus")),this.error&&e.append(this.errorBox()),e.append(this.composer(!1)),e}thread(e){var t,i;const n=this.view("Comment thread","thread"+(e.resolved?" is-resolved":"")),s=(null==(i=(t=this.config).canDelete)?void 0:i.call(t,e,this.getUser()))??this.manages(e);n.append(this.cardHeading(`Note #${this.pageComments().indexOf(e)+1}`,e.resolved?"Resolved conversation":"Open conversation","comment",this.canMove(e)?"Drag its pin to move it.":"",s?()=>this.deleteNote(e):void 0)),this.error&&n.append(this.errorBox()),e.selector&&n.append(this.anchorStatus(e,this.elementState(e)));const o=T("div","thread-body");for(const a of[e,...e.replies]){const e=T("div","message");e.append(this.messageHeader(a.author,a.timestamp,a.avatarUrl,a.via),T("p","message-text",a.text)),o.append(e)}n.append(o);const r=T("div","thread-actions");if(e.resolved){const t=T("span","status resolved","Resolved");t.prepend(P("check"));const i=L("Reopen Conversation","quiet reopen",()=>this.toggleResolved(e));i.disabled=this.saving,r.append(t,i)}else r.append(...this.replyBar(e));return n.append(r),n}replyBar(e){const t=T("form","reply-bar"),i=T("textarea");i.rows=1,i.placeholder="Reply…",i.setAttribute("aria-label","Reply"),i.maxLength=1e4,i.value=this.replyText,i.dataset.focus="reply",i.disabled=this.saving;const n=L(this.saving?"Saving…":"Send Reply","primary send",()=>{},"arrow");n.type="submit";const s=L("Mark as Resolved","primary resolve",()=>this.toggleResolved(e),"check");s.querySelector("span").textContent="Resolve",s.disabled=this.saving,n.disabled=this.saving;const o=()=>{const e=!!i.value.trim();n.hidden=!e,s.hidden=e,i.style.height="auto",i.style.height=`${Math.min(i.scrollHeight,120)}px`};return i.addEventListener("input",()=>{this.replyText=i.value,o()}),i.addEventListener("keydown",e=>{"Enter"!==e.key||e.shiftKey||e.isComposing||(e.preventDefault(),i.value.trim()&&t.requestSubmit())}),t.addEventListener("submit",e=>{e.preventDefault(),this.saving||this.submitReply()}),t.append(i,n),queueMicrotask(o),[t,s]}manages(e){return e.authorId===this.user.id||"owner"===this.user.role||"admin"===this.user.role}canMove(e){var t,i;return(null==(i=(t=this.config).canMove)?void 0:i.call(t,e,this.getUser()))??this.manages(e)}settingsView(){const e=this.view("Settings","settings");e.append(this.detailHeading("Settings","Your choices for this project. Other people keep their own."));const t=this.settings,i=T("div","settings-body"),n=T("div","tabs settings-tabs");n.setAttribute("role","group"),n.setAttribute("aria-label","Settings section");for(const[C,E]of[["general","General"],["appearance","Appearance"]]){const e=L(E,"tab",()=>{this.settingsTab=C,this.render()});e.setAttribute("aria-pressed",String(this.settingsTab===C)),e.dataset.focus=`settings-tab-${C}`,n.append(e)}i.append(n);const s=(e,t)=>{const n=T("section","setting-group");return n.append(T("h3","",e)),t===this.settingsTab&&i.append(n),n},o=(e,t,i,n)=>{const s=T("div","setting"),o=T("div","setting-text");return o.append(T("strong","",t)),i&&o.append(T("small","",i)),s.append(o,n),e.append(s),s},r=(e,i,n)=>{const s=T("div","segmented");s.setAttribute("role","group"),s.setAttribute("aria-label",i);for(const[o,r]of n){const i=L(r,"segment",()=>this.setSetting(e,o));i.setAttribute("aria-pressed",String(t[e]===o)),i.dataset.focus=`set-${e}-${o}`,s.append(i)}return s},a=(e,i,n=!1)=>{const s=!0===t[e],o=T("button","switch");return o.type="button",o.setAttribute("role","switch"),o.setAttribute("aria-checked",String(s)),o.setAttribute("aria-label",i),o.dataset.focus=`set-${e}`,o.disabled=n,o.addEventListener("click",()=>this.setSetting(e,!s)),o};o(s("Theme","appearance"),"Theme","system"===t.theme?"Follows your device":"",r("theme","Theme",[["light","Light"],["dark","Dark"],["system","System"]]));const l=s("Pins","appearance"),c=T("div",`pin-sample${"small"===t.pinSize?" small":""}${"gray"===t.resolvedPins?" resolved-gray":""}`);c.setAttribute("aria-hidden","true"),c.style.setProperty("--cw-accent",this.pinColor());const d=e=>"initials"===t.pinLabel?I(this.user.name):String(e);c.append(T("span","pin",d(1)),T("span","pin resolved",d(2)),T("span","pin-sample-text","Open and resolved")),l.append(c);const h=T("div","swatches");h.setAttribute("role","group"),h.setAttribute("aria-label","Pin color");const p=this.config.primaryColor.toLowerCase(),u=Object.entries(C).filter(([e,i])=>i.color!==p||t.pinColor===e);for(const[C,E,A]of[["site","Site color",p],...u.map(([e,t])=>[e,t.label,t.color])]){const e=L(E,"swatch",()=>this.setSetting("pinColor",C));e.replaceChildren(),e.style.setProperty("--swatch",A),e.setAttribute("aria-pressed",String(t.pinColor===C)),e.dataset.focus=`set-pinColor-${C}`,h.append(e)}o(l,"Color","site"===t.pinColor?"The color of this site":C[t.pinColor].label,h).classList.add("wide"),o(l,"Resolved pins","",r("resolvedPins","Resolved pins",[["green","Green"],["gray","Gray"]])),o(l,"Size","",r("pinSize","Pin size",[["regular","Regular"],["small","Small"]])),o(l,"Label","",r("pinLabel","Pin label",[["number","Number"],["initials","Initials"]]));const m=s("Comments button","appearance"),g=T("div","launcher-sample");g.setAttribute("aria-hidden","true");const f=T("span","launcher-mini");f.append(P("comment"),T("span","badge","3")),this.paintLauncher(f),g.append(f,T("span","pin-sample-text","On the page")),m.append(g);const v=T("div","swatches");v.setAttribute("role","group"),v.setAttribute("aria-label","Button color");const x=Object.entries(C).filter(([e,i])=>"graphite"!==e&&(i.color!==p||t.buttonColor===e));for(const[C,E,A]of[["default","Default","var(--cw-inverse)"],["site","Site color",p],...x.map(([e,t])=>[e,t.label,t.color])]){const e=L(E,"swatch",()=>this.setSetting("buttonColor",C));e.replaceChildren(),e.style.setProperty("--swatch",A),e.setAttribute("aria-pressed",String(t.buttonColor===C)),e.dataset.focus=`set-buttonColor-${C}`,v.append(e)}o(m,"Color","default"===t.buttonColor?"Dark. Takes the site color while open.":"site"===t.buttonColor?"The color of this site":C[t.buttonColor].label,v).classList.add("wide");const w=s("Panel","general"),b=T("div","segmented");b.setAttribute("role","group"),b.setAttribute("aria-label","Open comments");for(const[C,E]of[[!1,"Next to Pin"],[!0,"In Sidebar"]]){const e=L(E,"segment",()=>{this.docked!==C&&this.setDocked(C)});e.setAttribute("aria-pressed",String(this.docked===C)),e.dataset.focus=`set-docked-${C}`,b.append(e)}o(w,"Open comments","",b),o(w,"Push the page aside","The open panel does not cover the page.",a("pushContent","Push the page aside"));const y=s("Notifications and keys","general");o(y,"New activity","Show a short notice when others comment or reply.",a("notifications","Show new activity"));const k=function(e,t){const i=t?{alt:"Option",option:"Option",meta:"Cmd",cmd:"Cmd",ctrl:"Control",control:"Control"}:{alt:"Alt",option:"Alt",meta:"Meta",cmd:"Meta",ctrl:"Ctrl",control:"Ctrl"};return e.toLowerCase().split("+").map(e=>e.trim()).filter(Boolean).map(e=>i[e]??(1===e.length?e.toUpperCase():e[0].toUpperCase()+e.slice(1))).join(" + ")}(this.config.keyboardShortcut??"",/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent));o(y,"Keyboard shortcut",this.shortcut?`${k} opens and closes comments.`:"This site has no shortcut.",a("shortcut","Keyboard shortcut",!this.shortcut));const S=T("div","settings-foot");return S.append(T("span","","Saved in this browser"),L("Reset to Defaults","quiet",()=>this.resetSettings())),e.append(i,S),e}paintLauncher(e){const t=this.settings.buttonColor;"default"!==t&&(e.classList.add("colored"),e.style.setProperty("--cw-launcher","site"===t?this.config.primaryColor:C[t].color))}pinColor(){const e=this.settings.pinColor;return"site"===e?this.config.primaryColor:C[e].color}identityForm(){const e=this.view("Your guest profile");e.append(this.detailHeading("Your name","A name to put to your notes."));const t=T("form","identity-form"),i=T("label","","Display name");i.htmlFor="guest-name";const n=T("input");n.id="guest-name",n.value="Guest"===this.user.name?"":this.user.name,n.placeholder="Your name",n.maxLength=80,n.required=!0,n.setAttribute("autocomplete","nickname"),n.dataset.focus="guest-name";const s=T("p","",this.persistentGuest?"Your name and guest ID stay in this browser. No account or email is needed. You can change your name without changing your ID.":"Browser storage is unavailable. This guest profile lasts for this session."),o=L("Save Name","primary",()=>{});return o.type="submit",t.addEventListener("submit",e=>{e.preventDefault(),n.value.trim()&&(this.user={...this.user,name:n.value.trim()},this.persistentGuest=v(this.identityKey,this.user),this.editing=null,this.render(),this.announce("Guest name saved."))}),t.append(i,n,s,o),e.append(t),e}renderPins(){this.pins.classList.toggle("focused",!!this.activeId&&!this.draft);const e=this.settings;if(this.pins.classList.toggle("small","small"===e.pinSize),this.pins.classList.toggle("resolved-gray","gray"===e.resolvedPins),this.pins.style.setProperty("--cw-accent",this.pinColor()),this.activeId){const e=T("div","focus-ring");e.hidden=!0,this.pins.append(e)}const t=T("div","focus-ring hover-ring");t.hidden=!0,this.pins.append(t);const i=this.pageComments(),n=this.config.hideSidebar?{...we,status:this.filters.status}:this.filters,s=new Set($e(i,n,this.filterContext("page")).map(e=>e.id));for(const[r,a]of i.entries()){if(a.id!==this.activeId&&!s.has(a.id))continue;const t=!this.saving&&this.canMove(a),i=L(`Comment ${r+1} by ${a.author}: ${a.text.slice(0,100)}`,`pin${a.resolved?" resolved":""}${this.highlightId===a.id?" highlight":""}${this.hoverId===a.id?" hovered":""}${t?" movable":""}`,()=>{this.suppressPinClick?this.suppressPinClick=!1:this.navigateToComment(a.id)});t&&(i.title+=". Drag to move.",i.addEventListener("pointerdown",e=>this.startPinDrag(e,a))),i.replaceChildren(document.createTextNode("initials"===e.pinLabel?I(a.author):String(r+1))),i.dataset.id=a.id,i.setAttribute("aria-pressed",String(this.activeId===a.id)),this.pins.append(i)}const o=T("div","focus-ring pick-ring");if(o.hidden=!0,this.pins.append(o),this.placing){const e=T("span","pin preview","+");e.hidden=!0,this.pins.append(e)}if(this.draft){const e=T("span","pin","+"),t=this.position({...this.draft,...this.draft.position});t?(e.style.left=`${t.x}px`,e.style.top=`${t.y}px`):e.hidden=!0,this.pins.append(e)}}}function Ke(e={}){if("undefined"==typeof document||!document.body)throw new Error("Initialize Overplay in the browser after the page has mounted.");return new Fe(e)}const He=Ke;return e.APIAdapter=class{constructor(e){this.config=e}async request(e,t="GET",i){const n="function"==typeof this.config.headers?await this.config.headers():this.config.headers,s=new URL(`${this.config.baseUrl.replace(/\/$/,"")}${e}`,window.location.href);this.config.projectId&&s.searchParams.set("projectId",this.config.projectId);const o=await fetch(s,{method:t,credentials:this.config.credentials??"same-origin",headers:{...void 0!==i?{"Content-Type":"application/json"}:{},...n},body:void 0!==i?JSON.stringify(i):void 0});if(!o.ok)throw new Error(`Could not ${"GET"===t?"load":"save"} comments (${o.status}).`);if("GET"===t&&204!==o.status)return o.json()}async loadComments(){var e;return l(await this.request((null==(e=this.config.endpoints)?void 0:e.load)??"/comments"))}async saveComments(e){var t;await this.request((null==(t=this.config.endpoints)?void 0:t.save)??"/comments","POST",e)}async upsertComment(e){var t;await this.request(`${(null==(t=this.config.endpoints)?void 0:t.save)??"/comments"}/${encodeURIComponent(e.id)}`,"PUT",e)}async deleteComment(e){var t;await this.request(`${(null==(t=this.config.endpoints)?void 0:t.save)??"/comments"}/${encodeURIComponent(e)}`,"DELETE")}async addReply(e,t){var i;await this.request(`${(null==(i=this.config.endpoints)?void 0:i.save)??"/comments"}/${encodeURIComponent(e)}/replies`,"POST",t)}async setResolved(e,t){var i;await this.request(`${(null==(i=this.config.endpoints)?void 0:i.save)??"/comments"}/${encodeURIComponent(e)}`,"PATCH",{resolved:t})}},e.HostedAdapter=p,e.LocalStorageAdapter=u,e.init=He,e.initOverplay=Ke,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),e}({});
|
|
2
2
|
//# sourceMappingURL=overplay.iife.js.map
|