@pipeup/agents 0.8.0 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- var E=/^\/__pipeup\/[A-Za-z0-9_-]{16,}$/;function k(e){let n=document.documentElement,t=n.getAttribute("data-pipeup-link")??"",s=E.test(t),r=!1,p=0,f=()=>{};async function o(){let l=!1;try{l=(await fetch(`${t}/comments`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(await e.snapshot())})).ok}catch{}if(!l)throw new Error("pipeup: the link to your agent isn't reachable; your comments are safe here")}let u=()=>{window.clearTimeout(p),f(),f=()=>{},r=!1};return{enabled:s,agent:n.getAttribute("data-pipeup-link-agent")??"",file:n.getAttribute("data-pipeup-link-file")??"",on:()=>r,set:async l=>{if(s){if(!l){u(),e.refresh();return}await o(),r=!0,f=e.changes(()=>{window.clearTimeout(p),p=window.setTimeout(()=>{o().catch(g=>{u(),e.refresh(),globalThis.reportError?.(g)})},300)}),e.refresh()}},destroy:u}}function A(e){let n=r=>r.replace(/\s+/g," ").trim(),t=e.version?`npx pipeup@${e.version}`:"npx pipeup",s=`https://pipeup-ai.github.io/pipeup/${e.version?.includes("-")?"next/":""}`;return[`Act on the review comments on this page, which uses Pipeup: ${n(e.title)} (${n(e.url)}).`,"",e.file?`1. Read the comments: \`${t} comments ${e.file}\` (add --all for resolved ones). If it says nothing is shared, ask me to switch on Share with my agent.`:"1. Read the comments. Open the page in a browser and run `await Pipeup.comments()`, then read `.markdown`. If you can't run the page, ask me to paste its comments (Copy comments \u203A As Markdown).","2. Work through the open threads in order. For each, make the change I approved, or say why you didn't. Ask me before changing anything I haven't approved, and answer a question with an answer.",e.replies?`3. Answer in each thread: \`${t} reply --page ${e.file||"<the page's file>"} --thread <Thread id> "what you changed and where" --addressed "short note"\`. That writes ${n(e.replies)}.`+(e.listed?"":` The page doesn't list your key yet: run \`${t} agent --name <your name>\` and tell me the attribute to add.`):"3. Tell me what you would reply in each thread, in words I can paste.","4. Only mark a thread addressed. Never resolve, reopen, edit or delete: I close threads. Keep your key out of the page and its folder, and never answer as me.","",`Guide: ${s}skills/pipeup-apply/SKILL.md`].join(`
2
- `)}var S=/^[A-Za-z0-9_-]{43}$/,P="pipeupReplies";var T=/^AI assistant\s*·?\s*/;function w(e=document.documentElement){let n=e.getAttribute("data-pipeup-agents")??"";return[...new Set(n.split(/[\s,]+/).filter(t=>S.test(t)))]}function b(e=location,n=document.documentElement){let t=n.getAttribute("data-pipeup-replies");try{let s=e.href.split(/[?#]/)[0],r=new URL(t??(/\/$/.test(s)?`${s}index.replies.js`:s.replace(/\.[^./]*$/,"")+".replies.js"),e.href),p=r.protocol==="file:"?e.protocol==="file:":r.origin===e.origin;return p||console.warn("pipeup: the replies file must be on this site or this computer; ignoring it"),p?r.href:null}catch{return null}}function $(e){let n=w(),t=0,s="",r=null;async function p(){let c=globalThis[P];if(!Array.isArray(c))return 0;let d=c.splice(0),y=[];for(let m of d){let h=m;if(!(h?.format!=="pipeup-replies"||h.doc!==e.document.id||!Array.isArray(h.ops)))for(let i of h.ops){let a=i?.body;a&&n.includes(a.author)&&(a.kind==="reply"||a.kind==="addressed"||a.kind==="react"||a.kind==="unreact")?(y.push(i),(a.name==="AI assistant"||a.name.startsWith("AI assistant "))&&(s=a.name.replace(T,""))):t++}}return y.length?e.merge(y):0}function f(){let c=b();return c?(r?.remove(),new Promise((d,y)=>{let m=document.createElement("script");r=m,m.src=`${c}?${Date.now()}`;let h=a=>{window.clearTimeout(i),m.remove(),r===m&&(r=null),a?y(new Error(`pipeup: ${a}`)):d()},i=window.setTimeout(()=>h("the replies file didn't answer"),4e3);m.addEventListener("load",()=>h()),m.addEventListener("error",()=>h("there is no replies file yet")),e.overlay().append(m)})):Promise.reject(new Error("pipeup: the replies file can't be read from here"))}async function o(){if(!n.length)return 0;let c=await p();return await f(),c+await p()}let u=!1,l=()=>{u||document.hidden||(u=!0,o().catch(()=>{}).finally(()=>u=!1))},g=0;return n.length?(l(),g=window.setInterval(l,4e3),document.addEventListener("visibilitychange",l)):p(),{enabled:n.length>0,ignored:()=>t,who:()=>s,check:o,tally:c=>{let d=c.filter(i=>!i.resolved),y=i=>i.root.replies.some(a=>n.includes(a.author)),m=new Set(c.map(i=>i.id));return{stray:new Set(e.document.ops().filter(i=>n.includes(i.body.author)&&!m.has(i.body.thread)).map(i=>i.body.thread)).size,open:d.length,answered:d.filter(y).length,addressed:d.filter(i=>i.addressed).length}},destroy:()=>{window.clearInterval(g),document.removeEventListener("visibilitychange",l),r?.remove()}}}var I=()=>globalThis.Pipeup??{},x=["M10 8h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-8a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2z","M16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2"],L=["M21 12L3.5 4.5 6.2 12l-2.7 7.5zM6.2 12H13"],M="Reads a replies file next to this page. When the page is shown through pipeup watch, and only after you switch it on, it sends this page's comments to the program running on this computer. Nothing leaves this computer.",v=e=>e instanceof Error?e.message.replace(/^pipeup: /,""):"Something went wrong";async function R(e,n){try{await navigator.clipboard.writeText(e);return}catch{}let t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.cssText="position:fixed;opacity:0;pointer-events:none",n.append(t),t.select();let s=document.execCommand("copy");if(t.remove(),!s)throw new Error("pipeup: your browser blocked copying")}function C(){return{id:"agents",api:1,version:"0.6.0",needs:["menu","status","notify","listnote"],network:{when:"page-configured",to:["page"],says:M},setup(e){let n=$(e),t=k({snapshot:async()=>{let o=I();if(!o.comments)throw new Error("pipeup: this page has no Pipeup to read comments from");let[u,l]=await Promise.all([o.comments(),o.comments({all:!0})]);return{v:1,at:new Date().toISOString(),title:document.title,open:u,all:l}},changes:o=>e.document.onChange(o),refresh:()=>r()}),s=()=>n.who()||t.agent,r=()=>{if(e.setStatus(n.enabled||t.enabled?{text:t.on()?`Sharing comments with ${s()||"your agent"}`:`${s()||"An AI agent"} can answer comments here`}:null),!n.enabled)return e.setListNote(null);let o=n.tally(e.document.threads()),u=s()||"An agent",l=o.answered?`${u} has answered ${o.answered} of ${o.open} open comments${o.addressed?`; ${o.addressed} ${o.addressed===1?"is":"are"} marked addressed`:""}`:"No replies from an agent yet",g=n.ignored(),c=(t.on()?`Sharing with ${t.agent||"your agent"} \xB7 `:"")+l+(g?` \xB7 ${g} from other writers ignored`:"")+(o.stray?` \xB7 replies for ${o.stray} comment${o.stray===1?"":"s"} this page doesn't have`:"");e.setListNote({text:c,action:{label:"Check for replies",run:async()=>{try{let d=await n.check();e.notify(d?`${d} new ${d===1?"reply":"replies"}`:"No new replies")}catch(d){e.notify(v(d))}finally{r()}}}})},p=[e.addMenuItem({id:"prompt",icon:x,label:()=>"Copy a prompt for my agent",hint:()=>"Tells an AI agent where the comments are and how to answer them",select:async()=>{try{await R(A({title:document.title,url:location.href,replies:b(),file:t.enabled?t.file:"",listed:w().length>0,version:globalThis.Pipeup?.VERSION}),e.overlay()),e.notify("Copied a prompt for your agent")}catch(o){e.notify(v(o))}}})];t.enabled&&p.push(e.addMenuItem({id:"link",icon:L,label:()=>"Share with my agent",hint:()=>"Sends this page's comments to the program running on this computer, and nothing else",checked:()=>t.on(),select:async()=>{try{await t.set(!t.on())}catch(o){e.notify(v(o))}r()}}));let f=e.document.onChange(r);return r(),()=>{f(),n.destroy(),t.destroy()}}}}export{C as default};
1
+ var E=/^\/__pipeup\/[A-Za-z0-9_-]{16,}$/;function v(e){let n=document.documentElement,t=n.getAttribute("data-pipeup-link")??"",o=E.test(t),s=!1,i=0,h=()=>{};async function r(){let c=!1;try{c=(await fetch(`${t}/comments`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(await e.snapshot())})).ok}catch{}if(!c)throw new Error("pipeup: the link to your agent isn't reachable; your comments are safe here")}let p=()=>{window.clearTimeout(i),h(),h=()=>{},s=!1};return{enabled:o,agent:n.getAttribute("data-pipeup-link-agent")??"",file:n.getAttribute("data-pipeup-link-file")??"",on:()=>s,set:async c=>{if(o){if(!c){p(),e.refresh();return}await r(),s=!0,h=e.changes(()=>{window.clearTimeout(i),i=window.setTimeout(()=>{r().catch(g=>{p(),e.refresh(),globalThis.reportError?.(g)})},300)}),e.refresh()}},destroy:p}}function P(e){if(!e)return{cli:"npx --yes pipeup@0",fallback:null};let t=`npx --yes pipeup@${e.split(".")[0]??"0"}`;return e.includes("-")?{cli:`npx --yes pipeup@${e}`,fallback:t}:{cli:t,fallback:null}}function S(e,n=""){if(n)return{page:n,served:!1};try{let t=new URL(e),o=decodeURIComponent(t.pathname);return o.endsWith("/")&&(o+="index.html"),t.protocol==="file:"?{page:/^\/[A-Za-z]:\//.test(o)?o.slice(1):o,served:!1}:{page:o,served:!0}}catch{return{page:"<the page's HTML file>",served:!1}}}var T=e=>{try{let n=new URL(e);return n.protocol==="file:"?decodeURIComponent(n.pathname).replace(/^\/([A-Za-z]:\/)/,"$1"):n.href}catch{return e}};function A(e){let n=p=>p.replace(/\s+/g," ").trim(),{cli:t,fallback:o}=P(e.version),s=`https://pipeup-ai.github.io/pipeup/${e.version?.includes("-")?"next/":""}`,{page:i,served:h}=S(e.url,e.file),r=h?`<the HTML file your site serves at ${i}>`:i;return[`Act on the review comments on this page, which uses Pipeup: ${n(e.title)} (${n(e.url)}).`,"",e.file?`1. Read the comments: \`${t} comments ${e.file}\` (add --all for resolved ones). If it says nothing is shared, ask me to switch on Share with my agent.`:"1. Read the comments. Open the page in a browser and run `await Pipeup.comments()`, then read `.markdown`. If you can't run the page, ask me to paste its comments (Copy comments \u203A As Markdown).","2. Work through the open threads in order. For each, make the change I approved, or say why you didn't. Ask me before changing anything I haven't approved, and answer a question with an answer.",e.replies?`3. Answer in each thread: \`${t} reply --page ${r} --thread <Thread id> "what you changed and where" --addressed "short note"\`. Pass that file, the one that runs Pipeup, not a file it shows. It writes ${n(T(e.replies))}, which the page reads by itself.`+(e.listed?"":` The page doesn't list you yet. Ask me first; after my yes, run \`${t} agent --name <your name> --page ${r} --yes\`.`)+(o?` If npm refuses ${t.split(" ").at(-1)}, use ${o.split(" ").at(-1)}: it answers these commands the same way.`:""):"3. Tell me what you would reply in each thread, in words I can paste.","4. Only mark a thread addressed. Never resolve, reopen, edit or delete: I close threads. Keep your key out of the page and its folder, and never answer as me.","",`Guide: ${s}skills/pipeup-apply/SKILL.md`].join(`
2
+ `)}var I=/^[A-Za-z0-9_-]{43}$/,x="pipeupReplies";var L=/^AI assistant\s*·?\s*/;function w(e=document.documentElement){let n=e.getAttribute("data-pipeup-agents")??"";return[...new Set(n.split(/[\s,]+/).filter(t=>I.test(t)))]}function b(e=location,n=document.documentElement){let t=n.getAttribute("data-pipeup-replies");try{let o=e.href.split(/[?#]/)[0],s=new URL(t??(/\/$/.test(o)?`${o}index.replies.js`:o.replace(/\.[^./]*$/,"")+".replies.js"),e.href),i=s.protocol==="file:"?e.protocol==="file:":s.origin===e.origin;return i||console.warn("pipeup: the replies file must be on this site or this computer; ignoring it"),i?s.href:null}catch{return null}}function $(e){let n=w(),t=0,o="",s=null;async function i(){let u=globalThis[x];if(!Array.isArray(u))return 0;let d=u.splice(0),y=[];for(let m of d){let f=m;if(!(f?.format!=="pipeup-replies"||f.doc!==e.document.id||!Array.isArray(f.ops)))for(let a of f.ops){let l=a?.body;l&&n.includes(l.author)&&(l.kind==="reply"||l.kind==="addressed"||l.kind==="react"||l.kind==="unreact")?(y.push(a),(l.name==="AI assistant"||l.name.startsWith("AI assistant "))&&(o=l.name.replace(L,""))):t++}}return y.length?e.merge(y):0}function h(){let u=b();return u?(s?.remove(),new Promise((d,y)=>{let m=document.createElement("script");s=m,m.src=`${u}?${Date.now()}`;let f=l=>{window.clearTimeout(a),m.remove(),s===m&&(s=null),l?y(new Error(`pipeup: ${l}`)):d()},a=window.setTimeout(()=>f("the replies file didn't answer"),4e3);m.addEventListener("load",()=>f()),m.addEventListener("error",()=>f("there is no replies file yet")),e.overlay().append(m)})):Promise.reject(new Error("pipeup: the replies file can't be read from here"))}async function r(){if(!n.length)return 0;let u=await i();return await h(),u+await i()}let p=!1,c=()=>{p||document.hidden||(p=!0,r().catch(()=>{}).finally(()=>p=!1))},g=0;return n.length?(c(),g=window.setInterval(c,4e3),document.addEventListener("visibilitychange",c)):i(),{enabled:n.length>0,ignored:()=>t,who:()=>o,check:r,tally:u=>{let d=u.filter(a=>!a.resolved),y=a=>a.root.replies.some(l=>n.includes(l.author)),m=new Set(u.map(a=>a.id));return{stray:new Set(e.document.ops().filter(a=>n.includes(a.body.author)&&!m.has(a.body.thread)).map(a=>a.body.thread)).size,open:d.length,answered:d.filter(y).length,addressed:d.filter(a=>a.addressed).length}},destroy:()=>{window.clearInterval(g),document.removeEventListener("visibilitychange",c),s?.remove()}}}var M=()=>globalThis.Pipeup??{},R=["M10 8h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-8a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2z","M16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2"],C=["M21 12L3.5 4.5 6.2 12l-2.7 7.5zM6.2 12H13"],H="Reads a replies file next to this page. When the page is shown through pipeup watch, and only after you switch it on, it sends this page's comments to the program running on this computer. Nothing leaves this computer.",k=e=>e instanceof Error?e.message.replace(/^pipeup: /,""):"Something went wrong";async function O(e,n){try{await navigator.clipboard.writeText(e);return}catch{}let t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.cssText="position:fixed;opacity:0;pointer-events:none",n.append(t),t.select();let o=document.execCommand("copy");if(t.remove(),!o)throw new Error("pipeup: your browser blocked copying")}function N(){return{id:"agents",api:1,version:"0.6.0",needs:["menu","status","notify","listnote"],network:{when:"page-configured",to:["page"],says:H},setup(e){let n=$(e),t=v({snapshot:async()=>{let r=M();if(!r.comments)throw new Error("pipeup: this page has no Pipeup to read comments from");let[p,c]=await Promise.all([r.comments(),r.comments({all:!0})]);return{v:1,at:new Date().toISOString(),title:document.title,open:p,all:c}},changes:r=>e.document.onChange(r),refresh:()=>s()}),o=()=>n.who()||t.agent,s=()=>{if(e.setStatus(n.enabled||t.enabled?{text:t.on()?`Sharing comments with ${o()||"your agent"}`:`${o()||"An AI agent"} can answer comments here`}:null),!n.enabled)return e.setListNote(null);let r=n.tally(e.document.threads()),p=o()||"An agent",c=r.answered?`${p} has answered ${r.answered} of ${r.open} open comments${r.addressed?`; ${r.addressed} ${r.addressed===1?"is":"are"} marked addressed`:""}`:"No replies from an agent yet",g=n.ignored(),u=(t.on()?`Sharing with ${t.agent||"your agent"} \xB7 `:"")+c+(g?` \xB7 ${g} from other writers ignored`:"")+(r.stray?` \xB7 replies for ${r.stray} comment${r.stray===1?"":"s"} this page doesn't have`:"");e.setListNote({text:u,action:{label:"Check for replies",run:async()=>{try{let d=await n.check();e.notify(d?`${d} new ${d===1?"reply":"replies"}`:"No new replies")}catch(d){e.notify(k(d))}finally{s()}}}})},i=[e.addMenuItem({id:"prompt",icon:R,label:()=>"Copy a prompt for my agent",hint:()=>"Tells an AI agent where the comments are and how to answer them",select:async()=>{try{await O(A({title:document.title,url:location.href,replies:b(),file:t.enabled?t.file:"",listed:w().length>0,version:globalThis.Pipeup?.VERSION}),e.overlay()),e.notify("Copied a prompt for your agent")}catch(r){e.notify(k(r))}}})];t.enabled&&i.push(e.addMenuItem({id:"link",icon:C,label:()=>"Share with my agent",hint:()=>"Sends this page's comments to the program running on this computer, and nothing else",checked:()=>t.on(),select:async()=>{try{await t.set(!t.on())}catch(r){e.notify(k(r))}s()}}));let h=e.document.onChange(s);return s(),()=>{h(),n.destroy(),t.destroy()}}}}export{N as default};
@@ -1,2 +1,2 @@
1
- "use strict";(()=>{function b(e){let n=globalThis;(n.pipeupAddons||=[]).push(e),typeof addEventListener=="function"&&addEventListener("load",()=>{n.Pipeup||console.error(`pipeup: the "${e.id}" add-on needs Pipeup on the page too; load pipeup.min.js.`)},{once:!0})}var re=2n**256n-2n**32n-977n;var L=/^\/__pipeup\/[A-Za-z0-9_-]{16,}$/;function P(e){let n=document.documentElement,t=n.getAttribute("data-pipeup-link")??"",i=L.test(t),o=!1,c=0,y=()=>{};async function r(){let d=!1;try{d=(await fetch(`${t}/comments`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(await e.snapshot())})).ok}catch{}if(!d)throw new Error("pipeup: the link to your agent isn't reachable; your comments are safe here")}let u=()=>{window.clearTimeout(c),y(),y=()=>{},o=!1};return{enabled:i,agent:n.getAttribute("data-pipeup-link-agent")??"",file:n.getAttribute("data-pipeup-link-file")??"",on:()=>o,set:async d=>{if(i){if(!d){u(),e.refresh();return}await r(),o=!0,y=e.changes(()=>{window.clearTimeout(c),c=window.setTimeout(()=>{r().catch(h=>{u(),e.refresh(),globalThis.reportError?.(h)})},300)}),e.refresh()}},destroy:u}}function T(e){let n=o=>o.replace(/\s+/g," ").trim(),t=e.version?`npx pipeup@${e.version}`:"npx pipeup",i=`https://pipeup-ai.github.io/pipeup/${e.version?.includes("-")?"next/":""}`;return[`Act on the review comments on this page, which uses Pipeup: ${n(e.title)} (${n(e.url)}).`,"",e.file?`1. Read the comments: \`${t} comments ${e.file}\` (add --all for resolved ones). If it says nothing is shared, ask me to switch on Share with my agent.`:"1. Read the comments. Open the page in a browser and run `await Pipeup.comments()`, then read `.markdown`. If you can't run the page, ask me to paste its comments (Copy comments \u203A As Markdown).","2. Work through the open threads in order. For each, make the change I approved, or say why you didn't. Ask me before changing anything I haven't approved, and answer a question with an answer.",e.replies?`3. Answer in each thread: \`${t} reply --page ${e.file||"<the page's file>"} --thread <Thread id> "what you changed and where" --addressed "short note"\`. That writes ${n(e.replies)}.`+(e.listed?"":` The page doesn't list your key yet: run \`${t} agent --name <your name>\` and tell me the attribute to add.`):"3. Tell me what you would reply in each thread, in words I can paste.","4. Only mark a thread addressed. Never resolve, reopen, edit or delete: I close threads. Keep your key out of the page and its folder, and never answer as me.","",`Guide: ${i}skills/pipeup-apply/SKILL.md`].join(`
2
- `)}var C=/^[A-Za-z0-9_-]{43}$/,_="pipeupReplies";var D=/^AI assistant\s*·?\s*/;function x(e=document.documentElement){let n=e.getAttribute("data-pipeup-agents")??"";return[...new Set(n.split(/[\s,]+/).filter(t=>C.test(t)))]}function k(e=location,n=document.documentElement){let t=n.getAttribute("data-pipeup-replies");try{let i=e.href.split(/[?#]/)[0],o=new URL(t??(/\/$/.test(i)?`${i}index.replies.js`:i.replace(/\.[^./]*$/,"")+".replies.js"),e.href),c=o.protocol==="file:"?e.protocol==="file:":o.origin===e.origin;return c||console.warn("pipeup: the replies file must be on this site or this computer; ignoring it"),c?o.href:null}catch{return null}}function E(e){let n=x(),t=0,i="",o=null;async function c(){let l=globalThis[_];if(!Array.isArray(l))return 0;let p=l.splice(0),g=[];for(let f of p){let m=f;if(!(m?.format!=="pipeup-replies"||m.doc!==e.document.id||!Array.isArray(m.ops)))for(let s of m.ops){let a=s?.body;a&&n.includes(a.author)&&(a.kind==="reply"||a.kind==="addressed"||a.kind==="react"||a.kind==="unreact")?(g.push(s),(a.name==="AI assistant"||a.name.startsWith("AI assistant "))&&(i=a.name.replace(D,""))):t++}}return g.length?e.merge(g):0}function y(){let l=k();return l?(o?.remove(),new Promise((p,g)=>{let f=document.createElement("script");o=f,f.src=`${l}?${Date.now()}`;let m=a=>{window.clearTimeout(s),f.remove(),o===f&&(o=null),a?g(new Error(`pipeup: ${a}`)):p()},s=window.setTimeout(()=>m("the replies file didn't answer"),4e3);f.addEventListener("load",()=>m()),f.addEventListener("error",()=>m("there is no replies file yet")),e.overlay().append(f)})):Promise.reject(new Error("pipeup: the replies file can't be read from here"))}async function r(){if(!n.length)return 0;let l=await c();return await y(),l+await c()}let u=!1,d=()=>{u||document.hidden||(u=!0,r().catch(()=>{}).finally(()=>u=!1))},h=0;return n.length?(d(),h=window.setInterval(d,4e3),document.addEventListener("visibilitychange",d)):c(),{enabled:n.length>0,ignored:()=>t,who:()=>i,check:r,tally:l=>{let p=l.filter(s=>!s.resolved),g=s=>s.root.replies.some(a=>n.includes(a.author)),f=new Set(l.map(s=>s.id));return{stray:new Set(e.document.ops().filter(s=>n.includes(s.body.author)&&!f.has(s.body.thread)).map(s=>s.body.thread)).size,open:p.length,answered:p.filter(g).length,addressed:p.filter(s=>s.addressed).length}},destroy:()=>{window.clearInterval(h),document.removeEventListener("visibilitychange",d),o?.remove()}}}var R=()=>globalThis.Pipeup??{},N=["M10 8h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-8a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2z","M16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2"],H=["M21 12L3.5 4.5 6.2 12l-2.7 7.5zM6.2 12H13"],z="Reads a replies file next to this page. When the page is shown through pipeup watch, and only after you switch it on, it sends this page's comments to the program running on this computer. Nothing leaves this computer.",S=e=>e instanceof Error?e.message.replace(/^pipeup: /,""):"Something went wrong";async function K(e,n){try{await navigator.clipboard.writeText(e);return}catch{}let t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.cssText="position:fixed;opacity:0;pointer-events:none",n.append(t),t.select();let i=document.execCommand("copy");if(t.remove(),!i)throw new Error("pipeup: your browser blocked copying")}function U(){return{id:"agents",api:1,version:"0.6.0",needs:["menu","status","notify","listnote"],network:{when:"page-configured",to:["page"],says:z},setup(e){let n=E(e),t=P({snapshot:async()=>{let r=R();if(!r.comments)throw new Error("pipeup: this page has no Pipeup to read comments from");let[u,d]=await Promise.all([r.comments(),r.comments({all:!0})]);return{v:1,at:new Date().toISOString(),title:document.title,open:u,all:d}},changes:r=>e.document.onChange(r),refresh:()=>o()}),i=()=>n.who()||t.agent,o=()=>{if(e.setStatus(n.enabled||t.enabled?{text:t.on()?`Sharing comments with ${i()||"your agent"}`:`${i()||"An AI agent"} can answer comments here`}:null),!n.enabled)return e.setListNote(null);let r=n.tally(e.document.threads()),u=i()||"An agent",d=r.answered?`${u} has answered ${r.answered} of ${r.open} open comments${r.addressed?`; ${r.addressed} ${r.addressed===1?"is":"are"} marked addressed`:""}`:"No replies from an agent yet",h=n.ignored(),l=(t.on()?`Sharing with ${t.agent||"your agent"} \xB7 `:"")+d+(h?` \xB7 ${h} from other writers ignored`:"")+(r.stray?` \xB7 replies for ${r.stray} comment${r.stray===1?"":"s"} this page doesn't have`:"");e.setListNote({text:l,action:{label:"Check for replies",run:async()=>{try{let p=await n.check();e.notify(p?`${p} new ${p===1?"reply":"replies"}`:"No new replies")}catch(p){e.notify(S(p))}finally{o()}}}})},c=[e.addMenuItem({id:"prompt",icon:N,label:()=>"Copy a prompt for my agent",hint:()=>"Tells an AI agent where the comments are and how to answer them",select:async()=>{try{await K(T({title:document.title,url:location.href,replies:k(),file:t.enabled?t.file:"",listed:x().length>0,version:globalThis.Pipeup?.VERSION}),e.overlay()),e.notify("Copied a prompt for your agent")}catch(r){e.notify(S(r))}}})];t.enabled&&c.push(e.addMenuItem({id:"link",icon:H,label:()=>"Share with my agent",hint:()=>"Sends this page's comments to the program running on this computer, and nothing else",checked:()=>t.on(),select:async()=>{try{await t.set(!t.on())}catch(r){e.notify(S(r))}o()}}));let y=e.document.onChange(o);return o(),()=>{y(),n.destroy(),t.destroy()}}}}b(U());})();
1
+ "use strict";(()=>{function b(e){let n=globalThis;(n.pipeupAddons||=[]).push(e),typeof addEventListener=="function"&&addEventListener("load",()=>{n.Pipeup||console.error(`pipeup: the "${e.id}" add-on needs Pipeup on the page too; load pipeup.min.js.`)},{once:!0})}var se=2n**256n-2n**32n-977n;var L=/^\/__pipeup\/[A-Za-z0-9_-]{16,}$/;function P(e){let n=document.documentElement,t=n.getAttribute("data-pipeup-link")??"",o=L.test(t),i=!1,a=0,m=()=>{};async function r(){let c=!1;try{c=(await fetch(`${t}/comments`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(await e.snapshot())})).ok}catch{}if(!c)throw new Error("pipeup: the link to your agent isn't reachable; your comments are safe here")}let d=()=>{window.clearTimeout(a),m(),m=()=>{},i=!1};return{enabled:o,agent:n.getAttribute("data-pipeup-link-agent")??"",file:n.getAttribute("data-pipeup-link-file")??"",on:()=>i,set:async c=>{if(o){if(!c){d(),e.refresh();return}await r(),i=!0,m=e.changes(()=>{window.clearTimeout(a),a=window.setTimeout(()=>{r().catch(y=>{d(),e.refresh(),globalThis.reportError?.(y)})},300)}),e.refresh()}},destroy:d}}function C(e){if(!e)return{cli:"npx --yes pipeup@0",fallback:null};let t=`npx --yes pipeup@${e.split(".")[0]??"0"}`;return e.includes("-")?{cli:`npx --yes pipeup@${e}`,fallback:t}:{cli:t,fallback:null}}function R(e,n=""){if(n)return{page:n,served:!1};try{let t=new URL(e),o=decodeURIComponent(t.pathname);return o.endsWith("/")&&(o+="index.html"),t.protocol==="file:"?{page:/^\/[A-Za-z]:\//.test(o)?o.slice(1):o,served:!1}:{page:o,served:!0}}catch{return{page:"<the page's HTML file>",served:!1}}}var _=e=>{try{let n=new URL(e);return n.protocol==="file:"?decodeURIComponent(n.pathname).replace(/^\/([A-Za-z]:\/)/,"$1"):n.href}catch{return e}};function T(e){let n=d=>d.replace(/\s+/g," ").trim(),{cli:t,fallback:o}=C(e.version),i=`https://pipeup-ai.github.io/pipeup/${e.version?.includes("-")?"next/":""}`,{page:a,served:m}=R(e.url,e.file),r=m?`<the HTML file your site serves at ${a}>`:a;return[`Act on the review comments on this page, which uses Pipeup: ${n(e.title)} (${n(e.url)}).`,"",e.file?`1. Read the comments: \`${t} comments ${e.file}\` (add --all for resolved ones). If it says nothing is shared, ask me to switch on Share with my agent.`:"1. Read the comments. Open the page in a browser and run `await Pipeup.comments()`, then read `.markdown`. If you can't run the page, ask me to paste its comments (Copy comments \u203A As Markdown).","2. Work through the open threads in order. For each, make the change I approved, or say why you didn't. Ask me before changing anything I haven't approved, and answer a question with an answer.",e.replies?`3. Answer in each thread: \`${t} reply --page ${r} --thread <Thread id> "what you changed and where" --addressed "short note"\`. Pass that file, the one that runs Pipeup, not a file it shows. It writes ${n(_(e.replies))}, which the page reads by itself.`+(e.listed?"":` The page doesn't list you yet. Ask me first; after my yes, run \`${t} agent --name <your name> --page ${r} --yes\`.`)+(o?` If npm refuses ${t.split(" ").at(-1)}, use ${o.split(" ").at(-1)}: it answers these commands the same way.`:""):"3. Tell me what you would reply in each thread, in words I can paste.","4. Only mark a thread addressed. Never resolve, reopen, edit or delete: I close threads. Keep your key out of the page and its folder, and never answer as me.","",`Guide: ${i}skills/pipeup-apply/SKILL.md`].join(`
2
+ `)}var D=/^[A-Za-z0-9_-]{43}$/,H="pipeupReplies";var N=/^AI assistant\s*·?\s*/;function x(e=document.documentElement){let n=e.getAttribute("data-pipeup-agents")??"";return[...new Set(n.split(/[\s,]+/).filter(t=>D.test(t)))]}function k(e=location,n=document.documentElement){let t=n.getAttribute("data-pipeup-replies");try{let o=e.href.split(/[?#]/)[0],i=new URL(t??(/\/$/.test(o)?`${o}index.replies.js`:o.replace(/\.[^./]*$/,"")+".replies.js"),e.href),a=i.protocol==="file:"?e.protocol==="file:":i.origin===e.origin;return a||console.warn("pipeup: the replies file must be on this site or this computer; ignoring it"),a?i.href:null}catch{return null}}function U(e){let n=x(),t=0,o="",i=null;async function a(){let u=globalThis[H];if(!Array.isArray(u))return 0;let l=u.splice(0),g=[];for(let f of l){let h=f;if(!(h?.format!=="pipeup-replies"||h.doc!==e.document.id||!Array.isArray(h.ops)))for(let s of h.ops){let p=s?.body;p&&n.includes(p.author)&&(p.kind==="reply"||p.kind==="addressed"||p.kind==="react"||p.kind==="unreact")?(g.push(s),(p.name==="AI assistant"||p.name.startsWith("AI assistant "))&&(o=p.name.replace(N,""))):t++}}return g.length?e.merge(g):0}function m(){let u=k();return u?(i?.remove(),new Promise((l,g)=>{let f=document.createElement("script");i=f,f.src=`${u}?${Date.now()}`;let h=p=>{window.clearTimeout(s),f.remove(),i===f&&(i=null),p?g(new Error(`pipeup: ${p}`)):l()},s=window.setTimeout(()=>h("the replies file didn't answer"),4e3);f.addEventListener("load",()=>h()),f.addEventListener("error",()=>h("there is no replies file yet")),e.overlay().append(f)})):Promise.reject(new Error("pipeup: the replies file can't be read from here"))}async function r(){if(!n.length)return 0;let u=await a();return await m(),u+await a()}let d=!1,c=()=>{d||document.hidden||(d=!0,r().catch(()=>{}).finally(()=>d=!1))},y=0;return n.length?(c(),y=window.setInterval(c,4e3),document.addEventListener("visibilitychange",c)):a(),{enabled:n.length>0,ignored:()=>t,who:()=>o,check:r,tally:u=>{let l=u.filter(s=>!s.resolved),g=s=>s.root.replies.some(p=>n.includes(p.author)),f=new Set(u.map(s=>s.id));return{stray:new Set(e.document.ops().filter(s=>n.includes(s.body.author)&&!f.has(s.body.thread)).map(s=>s.body.thread)).size,open:l.length,answered:l.filter(g).length,addressed:l.filter(s=>s.addressed).length}},destroy:()=>{window.clearInterval(y),document.removeEventListener("visibilitychange",c),i?.remove()}}}var z=()=>globalThis.Pipeup??{},K=["M10 8h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-8a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2z","M16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2"],j=["M21 12L3.5 4.5 6.2 12l-2.7 7.5zM6.2 12H13"],F="Reads a replies file next to this page. When the page is shown through pipeup watch, and only after you switch it on, it sends this page's comments to the program running on this computer. Nothing leaves this computer.",S=e=>e instanceof Error?e.message.replace(/^pipeup: /,""):"Something went wrong";async function Z(e,n){try{await navigator.clipboard.writeText(e);return}catch{}let t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.cssText="position:fixed;opacity:0;pointer-events:none",n.append(t),t.select();let o=document.execCommand("copy");if(t.remove(),!o)throw new Error("pipeup: your browser blocked copying")}function E(){return{id:"agents",api:1,version:"0.6.0",needs:["menu","status","notify","listnote"],network:{when:"page-configured",to:["page"],says:F},setup(e){let n=U(e),t=P({snapshot:async()=>{let r=z();if(!r.comments)throw new Error("pipeup: this page has no Pipeup to read comments from");let[d,c]=await Promise.all([r.comments(),r.comments({all:!0})]);return{v:1,at:new Date().toISOString(),title:document.title,open:d,all:c}},changes:r=>e.document.onChange(r),refresh:()=>i()}),o=()=>n.who()||t.agent,i=()=>{if(e.setStatus(n.enabled||t.enabled?{text:t.on()?`Sharing comments with ${o()||"your agent"}`:`${o()||"An AI agent"} can answer comments here`}:null),!n.enabled)return e.setListNote(null);let r=n.tally(e.document.threads()),d=o()||"An agent",c=r.answered?`${d} has answered ${r.answered} of ${r.open} open comments${r.addressed?`; ${r.addressed} ${r.addressed===1?"is":"are"} marked addressed`:""}`:"No replies from an agent yet",y=n.ignored(),u=(t.on()?`Sharing with ${t.agent||"your agent"} \xB7 `:"")+c+(y?` \xB7 ${y} from other writers ignored`:"")+(r.stray?` \xB7 replies for ${r.stray} comment${r.stray===1?"":"s"} this page doesn't have`:"");e.setListNote({text:u,action:{label:"Check for replies",run:async()=>{try{let l=await n.check();e.notify(l?`${l} new ${l===1?"reply":"replies"}`:"No new replies")}catch(l){e.notify(S(l))}finally{i()}}}})},a=[e.addMenuItem({id:"prompt",icon:K,label:()=>"Copy a prompt for my agent",hint:()=>"Tells an AI agent where the comments are and how to answer them",select:async()=>{try{await Z(T({title:document.title,url:location.href,replies:k(),file:t.enabled?t.file:"",listed:x().length>0,version:globalThis.Pipeup?.VERSION}),e.overlay()),e.notify("Copied a prompt for your agent")}catch(r){e.notify(S(r))}}})];t.enabled&&a.push(e.addMenuItem({id:"link",icon:j,label:()=>"Share with my agent",hint:()=>"Sends this page's comments to the program running on this computer, and nothing else",checked:()=>t.on(),select:async()=>{try{await t.set(!t.on())}catch(r){e.notify(S(r))}i()}}));let m=e.document.onChange(i);return i(),()=>{m(),n.destroy(),t.destroy()}}}}b(E());})();
@@ -1,3 +1,3 @@
1
- "use strict";var Pipeup=(()=>{function e(e){let t="";for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function t(e){let t=atob(e.replace(/-/g,"+").replace(/_/g,"/")),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function n(e){return(new TextEncoder).encode(e)}function o(e){if(null===e||"object"!=typeof e)return JSON.stringify(e);if(Array.isArray(e))return"["+e.map(o).join(",")+"]";let t=e;return"{"+Object.keys(t).filter(e=>void 0!==t[e]).sort().map(e=>JSON.stringify(e)+":"+o(t[e])).join(",")+"}"}function r(e){return e.replace(/\s+/g," ").trim()}function i(e){let t=r(e),n=2166136261;for(let e=0;e<t.length;e++)n^=t.charCodeAt(e),n=Math.imul(n,16777619)>>>0;return n.toString(16).padStart(8,"0")}var a=/^[A-Za-z0-9_-]{43}$/,l=new Map;async function s(){let t=await crypto.subtle.generateKey({name:"Ed25519"},!1,["sign","verify"]);return{publicKey:e(new Uint8Array(await crypto.subtle.exportKey("raw",t.publicKey))),privateKey:t.privateKey}}async function d(t,n){let o=await crypto.subtle.sign({name:"Ed25519"},t.privateKey,n);return e(new Uint8Array(o))}var c=["Otter","Fox","Owl","Bear","Rabbit"],u=["Red","Orange","Yellow","Green","Teal","Blue","Purple","Pink","Brown","Grey"];function p(e){let t=2166136261;for(let n=0;n<e.length;n++)t=Math.imul(t^e.charCodeAt(n),16777619);return t=Math.imul(t^t>>>16,2246822507),t=Math.imul(t^t>>>13,3266489909),(t^t>>>16)>>>0}var h=e=>p(e)%c.length,f=e=>Math.floor(p(e)/c.length)%u.length,m=e=>`${u[f(e)]} ${c[h(e)]}`,g=e=>{let t=e.name.replace(/^AI assistant \xb7 /,"")||m(e.author);return e.alike?`${t} \xb7 ${function(e){let t=p(`id:${e}`),n="";for(let e=0;e<4;e++,t>>>=5)n+="0123456789ABCDEFGHJKMNPQRSTVWXYZ"[31&t];return n}(e.author)}`:t},v="AI assistant",w=e=>e===v||e.startsWith(`${v} `),y=2**40,b=2**47,x=1e4,k=/^[0-9a-f]{8}$/,E=/^[A-Za-z0-9_-]{43}$/,S=/^(?:[^\s@<>"]{1,64}@[^\s@<>"]{1,190}\.[^\s@<>"]{2,24}|gh:[A-Za-z0-9-]{1,39})$/,$=/^(?:[A-Za-z0-9_-]{43}|(?:host|gh):[A-Za-z0-9._@-]{1,64})$/,L=/^[A-Za-z0-9_-]{43}$/,M=new Set(["create","reply","edit","delete","resolve","reopen","addressed","react","unreact","seen","contact","uncontact"]),C=/^(?:\p{Regional_Indicator}{2}|[#*0-9]\uFE0F?\u20E3|\p{Extended_Pictographic}(?:\uFE0F|\p{Emoji_Modifier})?(?:\u200D\p{Extended_Pictographic}(?:\uFE0F|\p{Emoji_Modifier})?)*)$/u,A=e=>"string"==typeof e&&C.test(e)&&[...e].length<=16;async function T(e,t){if(e.author!==t.publicKey)throw new Error("pipeup: an op must be signed by its author");return{body:e,sig:await d(t,n(o(e)))}}var P=(e,t)=>"string"==typeof e&&e.length<=t,q=e=>!!e&&"object"==typeof e,R=e=>"number"==typeof e&&Number.isFinite(e)&&e>=0&&e<=1;function N(e){if(!q(e))return!1;let{id:t,path:n,fingerprint:o,snapshot:r,quote:i,point:a,view:l}=e;if(!(P(n,2e3)&&P(r,500)&&"string"==typeof o&&k.test(o)&&(void 0===t||P(t,200)&&""!==t)&&(void 0===i||q(i)&&P(i.exact,x)&&""!==i.exact&&P(i.prefix,64)&&P(i.suffix,64))&&(void 0===a||q(a)&&R(a.x)&&R(a.y))))return!1;if(void 0!==l){if(!q(l)||Array.isArray(l))return!1;let e=Object.entries(l);if(e.length>16||!e.every(([e,t])=>e.length<=64&&P(t,200)))return!1}return!0}function D(e){if(!q(e))return!1;let{body:t,sig:n}=e;if("string"!=typeof n||!q(t)||JSON.stringify({body:t,sig:n}).length>262144)return!1;let o=t;if(1!==o.v||"string"!=typeof o.id||!E.test(o.id)||!M.has(o.kind)||!P(o.doc,64)||""===o.doc||"string"!=typeof o.thread||!E.test(o.thread)||"string"!=typeof o.author||!L.test(o.author)||"string"!=typeof o.name||o.name.length>80||o.name!==o.name.trim()||"number"!=typeof o.clock||!Number.isSafeInteger(o.clock)||o.clock<1||o.clock>y||"number"!=typeof o.at||!Number.isSafeInteger(o.at)||o.at<0||o.at>b||void 0!==o.text&&(!P(o.text,1e4)||o.text!==o.text.trim())||void 0!==o.target&&("string"!=typeof o.target||!E.test(o.target))||("create"===o.kind||"reply"===o.kind||"edit"===o.kind||"addressed"===o.kind)&&!o.text||("reply"===o.kind||"edit"===o.kind||"delete"===o.kind)&&!o.target)return!1;if(void 0!==o.mentions){if("create"!==o.kind&&"reply"!==o.kind&&"edit"!==o.kind||!Array.isArray(o.mentions)||o.mentions.length>20)return!1;let e=o.text?.length??0;for(let t of o.mentions){if(!q(t)||!Number.isSafeInteger(t.start)||!Number.isSafeInteger(t.end))return!1;let{start:n,end:o,ref:r}=t;if(n<0||o<=n||o>e||"string"!=typeof r||!$.test(r))return!1}}return!(!("contact"!==o.kind||"string"==typeof o.text&&S.test(o.text))||"seen"===o.kind&&!o.target||!("react"!==o.kind&&"unreact"!==o.kind||o.target&&A(o.text))||!("create"!==o.kind||o.id===o.thread&&N(o.anchor)))}function z(r){return async function(n,o,r){if(!a.test(n))return!1;try{if(e(t(n))!==n)return!1;let i=l.get(n);if(!i){l.size>=512&&l.delete(l.keys().next().value),i=crypto.subtle.importKey("raw",t(n),{name:"Ed25519"},!0,["verify"]),l.set(n,i);let e=i;e.catch(()=>{l.get(n)===e&&l.delete(n)})}return await crypto.subtle.verify({name:"Ed25519"},await i,t(r),o)}catch{return!1}}(r.body.author,n(o(r.body)),r.sig)}function O(e,t){return e.body.clock!==t.body.clock?e.body.clock-t.body.clock:e.body.at!==t.body.at?e.body.at-t.body.at:e.body.author!==t.body.author?e.body.author<t.body.author?-1:1:e.body.id!==t.body.id?e.body.id<t.body.id?-1:1:0}function H(e,t,n,o,r,i){let a={id:e,author:t,name:n,text:o,at:r,edited:!1,deleted:!1,replies:[],reactions:[]};return i?.length&&(a.mentions=i),a}async function F(t){let r={...t,id:void 0,thread:"create"===t.kind?void 0:t.thread},i=await crypto.subtle.digest("SHA-256",n(o(r)));return e(new Uint8Array(i))}var I=class{constructor(e){this.doc=e}ops=new Map;clock=0;createAt=new Map;threadAt=new Map;get size(){return this.ops.size}all(){return[...this.ops.values()]}threads(){return function(e){let t=new Map,n=new Map,o=new Map;for(let{body:r}of[...e].sort(O)){if(r.name&&o.set(r.author,r.name),"create"===r.kind){if(t.has(r.id)||!r.anchor||void 0===r.text)continue;let e=H(r.id,r.author,r.name,r.text,r.at,r.mentions);t.set(r.id,{id:r.id,anchor:r.anchor,root:e,resolved:!1}),n.set(r.id,{comment:e,thread:r.id});continue}let e=t.get(r.thread);if(!e)continue;if("resolve"===r.kind||"reopen"===r.kind){e.resolved="resolve"===r.kind,"reopen"===r.kind&&delete e.addressed;continue}if("addressed"===r.kind){void 0!==r.text&&(e.addressed={text:r.text,author:r.author,name:r.name,at:r.at});continue}let i=r.target?n.get(r.target):void 0;if(i&&i.thread===r.thread){if("reply"===r.kind){if(n.has(r.id)||void 0===r.text)continue;let t=H(r.id,r.author,r.name,r.text,r.at,r.mentions);e.root.replies.push(t),n.set(r.id,{comment:t,thread:r.thread});continue}if("seen"===r.kind){let e=i.comment.seenBy??=[];e.includes(r.author)||e.push(r.author);continue}if("react"===r.kind||"unreact"===r.kind){if(void 0===r.text||i.comment.deleted)continue;let e=i.comment.reactions,t=e.find(e=>e.emoji===r.text);if("react"===r.kind){let n={author:r.author,name:r.name};t?t.by.some(e=>e.author===r.author)||t.by.push(n):e.length<12&&e.push({emoji:r.text,by:[n]})}else t&&(t.by=t.by.filter(e=>e.author!==r.author),t.by.length||e.splice(e.indexOf(t),1));continue}r.author!==i.comment.author||i.comment.deleted||("edit"===r.kind&&void 0!==r.text&&(i.comment.text=r.text,i.comment.edited=!0,r.mentions?i.comment.mentions=r.mentions:delete i.comment.mentions),"delete"===r.kind&&(i.comment.text="",i.comment.deleted=!0,i.comment.reactions=[],delete i.comment.mentions))}}for(let{comment:e}of n.values()){e.name||(e.unnamed=!0,e.name=o.get(e.author)??"");for(let t of e.reactions)for(let e of t.by)e.name||=o.get(e.author)??""}let r=new Map,i=(e,t)=>{let n=g({author:e,name:t}).toLowerCase();(r.get(n)??r.set(n,new Set).get(n)).add(e)};for(let{comment:e}of n.values()){i(e.author,e.name);for(let t of e.reactions)for(let e of t.by)i(e.author,e.name)}let a=(e,t)=>(r.get(g({author:e,name:t}).toLowerCase())?.size??0)>1;for(let{comment:e}of n.values()){a(e.author,e.name)&&(e.alike=!0);for(let t of e.reactions)for(let e of t.by)a(e.author,e.name)&&(e.alike=!0)}return[...t.values()]}(this.ops.values())}async add(e){let t=[];for(let n of e){if(!D(n)||n.body.doc!==this.doc||this.ops.has(n.body.id)||n.body.id!==await F(n.body)||!await z(n))continue;let e={body:n.body,sig:n.sig};this.ops.set(e.body.id,e),this.clock=Math.max(this.clock,e.body.clock),"create"===e.body.kind&&this.createAt.set(e.body.author,Math.max(this.createAt.get(e.body.author)??0,e.body.at)),this.threadAt.set(e.body.thread,Math.max(this.threadAt.get(e.body.thread)??0,e.body.at)),t.push(e)}return t}async append(e,t,n){let o={v:1,...n,id:"",thread:"create"===n.kind?"":n.thread,doc:this.doc,author:e.publicKey,name:t,clock:Math.min(this.clock+1,y),at:Math.min(Math.max(Date.now(),"create"===n.kind?(this.createAt.get(e.publicKey)??0)+1:(this.threadAt.get(n.thread)??0)+1),b)};o.id=await F(o);let r=this.ops.get(o.id);if(r)return r;"create"===o.kind&&(o.thread=o.id);let[i]=await this.add([await T(o,e)]);if(!i)throw new Error("pipeup: could not record this change");return i}},B=/^([A-Za-z0-9_-]{16}):([A-Za-z0-9_-]{43})$/;async function j(e){let n=B.exec(e.trim()),o=n?.[1],r=n?.[2];if(!o||!r)throw new Error('pipeup: data-pipeup-doc must look like "<id>:<key>", as made by newDocumentAttribute()');return{id:o,key:await crypto.subtle.importKey("raw",t(r),{name:"AES-GCM"},!1,["encrypt","decrypt"])}}async function W(t,o,r){let i=crypto.getRandomValues(new Uint8Array(12)),a=await crypto.subtle.encrypt({name:"AES-GCM",iv:i,additionalData:n(r)},t,n(o));return{iv:e(i),data:e(new Uint8Array(a))}}var K=e=>`pipeup-file:${e}`;async function V(e,o,r){if(e.length>5e6)throw new Error("pipeup: this feedback file is too large");let i,a,l;try{i=JSON.parse(e)}catch{throw new Error("pipeup: this is not an Pipeup feedback file")}if(!i||"object"!=typeof i||1!==i.pipeup||"string"!=typeof i.doc)throw new Error("pipeup: this is not an Pipeup feedback file");if(i.doc!==o)throw new Error("pipeup: this feedback is for a different document");if(!i.sealed)return Array.isArray(i.ops)?i.ops:[];if(!r)throw new Error("pipeup: this feedback is sealed, and this page has no document key");if("string"!=typeof i.iv||"string"!=typeof i.data)throw new Error("pipeup: this is not an Pipeup feedback file");try{a=await async function(e,o,r){try{let i=await crypto.subtle.decrypt({name:"AES-GCM",iv:t(o.iv),additionalData:n(r)},e,t(o.data));return(new TextDecoder).decode(i)}catch{throw new Error("pipeup: this feedback could not be opened with this document")}}(r,{iv:i.iv,data:i.data},K(o))}catch{throw new Error("pipeup: this feedback could not be opened with this document's key")}try{l=JSON.parse(a)}catch{throw new Error("pipeup: this is not an Pipeup feedback file")}return Array.isArray(l)?l:[]}var U=/^[a-z][a-z0-9-]{1,23}\/[a-z][a-z0-9-]{0,31}$/,Y=class extends Error{constructor(e,t,n=1){super("pipeup: shown here, but not saved yet"),this.id=e,this.cause=t,this.count=n,this.name="UnsavedChangeError"}},_=class e{constructor(e,t){this.log=e,this.options=t,this.displayName=t.name.trim()?J(t.name):""}listeners=new Set;cache=[];comments=new Map;displayName;ye=Promise.resolve();unsaved=[];static async open(t){if("string"!=typeof t.doc||""===t.doc||t.doc.length>64)throw new Error("pipeup: the document id must be 1 to 64 characters");let n=new I(t.doc),o=await t.store.load(t.doc),r=o.length-(await n.add(o)).length;r&&console.warn(`pipeup: ${r} saved change${1===r?"":"s"} on this page couldn't be read; kept as saved`);let i=new e(n,t);return i.refresh(!1),i}get id(){return this.options.doc}get me(){return this.options.identity.publicKey}get name(){return this.displayName}set name(e){this.displayName=J(e),this.refresh(!0,[],"")}threads(){return this.cache}ops(){return this.log.all()}onChange(e){return this.listeners.add(e),()=>this.listeners.delete(e)}comment(e,t,n){return this.enqueue(()=>this.write({kind:"create",anchor:e,text:G(t),...n?.length?{mentions:n}:{}}))}reply(e,t,n){return this.enqueue(()=>this.write({kind:"reply",thread:this.find(e).thread,target:e,text:G(t),...n?.length?{mentions:n}:{}}))}edit(e,t,n){return this.enqueue(async()=>{let{thread:o}=this.mine(e);await this.write({kind:"edit",thread:o,target:e,text:G(t),...n?.length?{mentions:n}:{}})})}remove(e){return this.enqueue(async()=>{let{thread:t}=this.mine(e);await this.write({kind:"delete",thread:t,target:e})})}contact(e){let t=e.trim();return S.test(t)?this.enqueue(async()=>{await this.write({kind:"contact",thread:this.me,text:t})}):Promise.reject(new Error("pipeup: that isn't an email address or a GitHub name"))}uncontact(){return this.enqueue(async()=>{await this.write({kind:"uncontact",thread:this.me})})}contacts(){let e=new Map;for(let{body:t}of[...this.log.all()].sort(O))"contact"===t.kind&&t.text?e.set(t.author,t.text):"uncontact"===t.kind&&e.delete(t.author);return e}get portable(){return this.options.identity.privateKey.extractable}async seed(){let e=this.options.identity.privateKey;if(!e.extractable)return null;let{d:n}=await crypto.subtle.exportKey("jwk",e);return n?t(n):null}seen(e){return this.enqueue(async()=>{for(let t of e){let e=this.comments.get(t);e&&!e.comment.seenBy?.includes(this.me)&&await this.write({kind:"seen",thread:e.thread,target:t})}})}react(e,t){return this.enqueue(async()=>{await this.write({kind:"react",thread:this.find(e).thread,target:e,text:Z(t)})})}unreact(e,t){return this.enqueue(async()=>{await this.write({kind:"unreact",thread:this.find(e).thread,target:e,text:Z(t)})})}resolve(e){return this.enqueue(async()=>{await this.write({kind:"resolve",thread:this.thread(e)})})}reopen(e){return this.enqueue(async()=>{await this.write({kind:"reopen",thread:this.thread(e)})})}sign(e,t){if(!U.test(e))throw new Error('pipeup: a signing purpose looks like "<add-on id>/<name>"');return d(this.options.identity,n(`pipeup:${e}\n${t}`))}flush(){return this.enqueue(()=>this.persist())}exportFile(){return async function(e,t,n){let o=n?{pipeup:1,doc:e,sealed:!0,...await W(n,JSON.stringify(t),K(e))}:{pipeup:1,doc:e,sealed:!1,ops:t};return JSON.stringify(o,null,2)}(this.options.doc,this.log.all(),this.options.key)}async importFile(e){return this.merge(await V(e,this.options.doc,this.options.key),"file")}merge(e,t){return e.length>5e3?Promise.reject(new RangeError("pipeup: too many changes to merge at once")):this.enqueue(async()=>{let n=await this.log.add([...e]);this.unsaved.push(...n),n.length>0&&this.refresh(!0,n,t);try{await this.persist()}catch(e){throw n.length>0?new Y(n[0].body.id,e,n.length):e}return n.length})}enqueue(e){let t=this.ye.then(e);return this.ye=t.catch(()=>{}),t}async write(e){let t=await this.log.append(this.options.identity,this.displayName,e);this.unsaved.push(t),this.refresh(!0,[t],"local");try{await this.persist()}catch(e){throw new Y(t.body.id,e)}return t.body.id}async persist(){if(0===this.unsaved.length)return;let e=[...this.unsaved];await this.options.store.append(this.options.doc,e),this.unsaved=this.unsaved.filter(t=>!e.includes(t))}refresh(e,t=[],n=""){this.cache=this.log.threads(),this.comments.clear();let o=(e,t)=>{e.unnamed&&e.author===this.me&&this.displayName&&(e.name=this.displayName),this.comments.set(e.id,{comment:e,thread:t});for(let n of e.replies)o(n,t)};for(let e of this.cache)o(e.root,e.id);if(e)for(let e of this.listeners)try{e(this.cache,t,n)}catch(e){globalThis.reportError?.(e)}}find(e){let t=this.comments.get(e);if(!t)throw new Error("pipeup: there is no comment with that id");return t}mine(e){let t=this.find(e);if(t.comment.author!==this.me)throw new Error("pipeup: only the writer can change a comment");return t}thread(e){if(!this.cache.some(t=>t.id===e))throw new Error("pipeup: there is no thread with that id");return e}};function G(e){let t=e.trim();if(!t)throw new Error("pipeup: a comment needs some words");if(t.length>1e4)throw new Error("pipeup: comments are limited to 10000 characters");return t}function Z(e){if(!A(e))throw new Error("pipeup: a reaction is one emoji");return e}function J(e){let t=e.replace(/\s+/g," ").trim();if(!t||t.length>80)throw new Error("pipeup: choose a name of 1 to 80 characters");if(w(t))throw new Error("pipeup: that name is kept for AI replies; choose another");return t}var X=class{docs=new Map;profile=null;async load(e){return[...this.docs.get(e)?.values()??[]]}async append(e,t){let n=this.docs.get(e);n||this.docs.set(e,n=new Map);for(let e of t)n.set(e.body.id,e)}async loadProfile(){return this.profile}async saveProfile(e){this.profile=e}async saveProfileIfAbsent(e){return this.profile||(this.profile=e),this.profile}};async function Q(e,t=""){let n=await e.loadProfile();if(n)return"Reviewer"===n.name?{...n,name:""}:n;let o={identity:await s(),name:t};return e.saveProfileIfAbsent(o)}var ee=class e{constructor(e){this.db=e}static open(t="pipeup"){return new Promise((n,o)=>{let r=indexedDB.open(t,1);r.onupgradeneeded=()=>{let e=r.result;e.createObjectStore("ops",{keyPath:["doc","id"]}).createIndex("doc","doc"),e.createObjectStore("meta")},r.onsuccess=()=>{let t=r.result;t.onversionchange=()=>t.close(),n(new e(t))},r.onerror=()=>o(r.error??new Error("pipeup: could not open local storage"))})}close(){this.db.close()}async load(e){return(await this.request("ops","readonly",t=>t.index("doc").getAll(e))).map(e=>e.op)}async append(e,t){if(0===t.length)return;let n=this.db.transaction("ops","readwrite"),o=n.objectStore("ops"),r=te(n);try{for(let n of t)o.put({doc:e,id:n.body.id,op:n})}catch(e){throw n.abort(),r.catch(()=>{}),e}await r}async loadProfile(){return await this.request("meta","readonly",e=>e.get("profile"))??null}async saveProfile(e){await this.request("meta","readwrite",t=>t.put(e,"profile"))}async saveProfileIfAbsent(e){let t=this.db.transaction("meta","readwrite"),n=t.objectStore("meta"),o=te(t),r=e,i=n.get("profile");return i.onsuccess=()=>{i.result?r=i.result:n.put(e,"profile")},await o,r}request(e,t,n){return new Promise((o,r)=>{let i=n(this.db.transaction(e,t).objectStore(e));i.onsuccess=()=>o(i.result),i.onerror=()=>r(i.error??new Error("pipeup: local storage request failed"))})}};function te(e){return new Promise((t,n)=>{e.oncomplete=()=>t(),e.onerror=()=>n(e.error??new Error("pipeup: local storage write failed")),e.onabort=()=>n(e.error??new Error("pipeup: local storage write aborted"))})}function ne(e){let t=(e.ownerDocument??e).createTreeWalker(e,NodeFilter.SHOW_TEXT),n=[],o="";for(let e=t.nextNode();e;e=t.nextNode())n.push({node:e,start:o.length}),o+=e.data;return{text:o,nodes:n}}function oe(e,t,n){let o=(e.ownerDocument??e).createRange();return o.setStart(e,0),o.setEnd(t,n),o.toString().length}function re(e,t,n){let o=ie(e,t,!1),r=ie(e,n,!0);if(!o||!r||n<t)return null;let i=o.node.ownerDocument.createRange();return i.setStart(o.node,o.offset),i.setEnd(r.node,r.offset),i}function ie(e,t,n){let o=e.nodes.find(e=>t>=e.start&&t<e.start+e.node.data.length+Number(n));return o&&{node:o.node,offset:t-o.start}}function ae(e){return e.nodeType===Node.ELEMENT_NODE?e:e.parentElement}function le(e,t){for(let n=ae(e)?.closest("[data-pipeup-id]")??null;n;){if(!t.contains(n))return null;let e=n.getAttribute("data-pipeup-id")??"";if(""!==e&&e.length<=200)return n;n=n.parentElement?.closest("[data-pipeup-id]")??null}return null}function se(e,t,n){return e.slice(t,n).replace(/^[\uDC00-\uDFFF]|[\uD800-\uDBFF]$/g,"")}function de(e,t){let n=function(e,t){if(e===t)return"";let n=[];for(let o=t;o&&o!==e;o=o.parentElement){let e=1;for(let t=o.previousElementSibling;t;t=t.previousElementSibling)t.tagName===o.tagName&&e++;n.unshift(`${o.tagName.toLowerCase()}:nth-of-type(${e})`)}return":scope > "+n.join(" > ")}(e,t);if(n.length>2e3)throw new Error("pipeup: this element is nested too deeply to comment on \u2014 give a nearby container a data-pipeup-id");return n}function ce(e){if(!N(e))throw new Error("pipeup: could not describe this place on the page");return e}function ue(e,t){let n=ae(e),o=n?.closest("p,li,h1,h2,h3,h4,h5,h6,td,th,blockquote,pre,figcaption,dt,dd,summary,caption")??null;return o&&t.contains(o)?o:n&&t.contains(n)?n:t}function pe(e,t,n){if(!t.contains(e.commonAncestorContainer))throw new Error("pipeup: the selection is outside the commentable area");let o=le(e.commonAncestorContainer,t),a=o??t,{text:l}=ne(a),s=oe(a,e.startContainer,e.startOffset),d=oe(a,e.endContainer,e.endOffset),c=l.slice(s,d);if(""===c)throw new Error("pipeup: select some text to comment on");if(c.length>x)throw new Error("pipeup: selections are limited to 10000 characters");let u=se(l,Math.max(0,s-32),s),p=se(l,d,d+32);return ce({...o?{id:o.getAttribute("data-pipeup-id")??""}:{},path:"",quote:{exact:c,prefix:u,suffix:p},...n?{view:n}:{},fingerprint:i(ue(e.startContainer,t).textContent??""),snapshot:se(r(u+c+p),0,200)})}function he(e,t,n,o){let a=le(e,t);return ce({...a?{id:a.getAttribute("data-pipeup-id")??""}:{},path:de(a??t,e),...n?{point:{x:fe(n.x),y:fe(n.y)}}:{},...o?{view:o}:{},fingerprint:i(e.textContent??""),snapshot:se(r(e.textContent??""),0,200)})}function fe(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):0}function me(e,t,n){let o=Array.from({length:t.length+1},(e,t)=>t),r=[...o],i=[t.length];for(let a=1;a<=e.length;a++){r[0]=n?0:a;for(let n=1;n<=t.length;n++){let i=e.charCodeAt(a-1)===t.charCodeAt(n-1)?0:1;r[n]=Math.min(o[n]+1,r[n-1]+1,o[n-1]+i)}i.push(r[t.length]),[o,r]=[r,o]}return i}var ge=(e,t)=>me(e,t,!1).pop(),ve={state:"orphaned",element:null,range:null};function we(e,t,n={}){let o=e.id?function(e,t){for(let n of e.querySelectorAll("[data-pipeup-id]"))if(n.getAttribute("data-pipeup-id")===t)return n;return null}(t,e.id):t;return e.quote?function(e,t,n,o,r){let a=n??o,l=ne(a),s=function(e,t){if(!t.exact)return-1;let n=-1,o=-1;for(let r=e.indexOf(t.exact);-1!==r;r=e.indexOf(t.exact,r+1)){let i=e.slice(Math.max(0,r-t.prefix.length),r),a=e.slice(r+t.exact.length,r+t.exact.length+t.suffix.length),l=be(i,t.prefix)+ye(a,t.suffix);l>o&&(n=r,o=l)}return n}(l.text,t);if(s>=0){let r=re(l,s,s+t.exact.length);if(r){let t=ue(r.startContainer,o);return{state:null!==n&&i(t.textContent??"")===e.fingerprint?"attached":"moved",element:t,range:r}}}if(r){let e=a===o?l:ne(o);if(e.text.length<=5e4&&t.exact.length>=12&&t.exact.length<=300){let n=function(e,t,n){let o=t.length;if(0===o)return null;let r=-1,i=1/0;if(me(e,t,!0).forEach((e,t)=>{t&&e<i&&(i=e,r=t)}),i>n)return null;let a=Math.max(0,r-o),l=1/0;for(let i=Math.max(0,r-o-n);i<=Math.min(r,r-o+n);i++){let n=ge(e.slice(i,r),t);n<l&&(l=n,a=i)}return{start:a,end:r,distance:l}}(e.text,t.exact,Math.floor(t.exact.length/4)),r=n?re(e,n.start,n.end):null;if(r)return{state:"moved",element:ue(r.startContainer,o),range:r}}}return ve}(e,e.quote,o,t,!1!==n.fuzzy):function(e,t){if(!t)return ve;let n=t;if(e.path){if(!e.path.startsWith(":scope > "))return ve;try{n=t.querySelector(e.path)}catch{return ve}}return n?{state:i(n.textContent??"")===e.fingerprint?"attached":"moved",element:n,range:null}:ve}(e,o)}function ye(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;return n}function be(e,t){let n=0;for(;n<e.length&&n<t.length&&e[e.length-1-n]===t[t.length-1-n];)n++;return n}var xe={A:"Link",BUTTON:"Button",P:"Paragraph",LI:"List item",UL:"List",OL:"List",IMG:"Image",TABLE:"Table",TD:"Cell",TH:"Cell",FIGURE:"Figure",SVG:"Graphic",CANVAS:"Graphic",LABEL:"Label",INPUT:"Field",SELECT:"Dropdown",TEXTAREA:"Field",SUMMARY:"Disclosure",BLOCKQUOTE:"Quote",SECTION:"Section",ARTICLE:"Article",H1:"Heading",H2:"Heading",H3:"Heading",H4:"Heading",H5:"Heading",H6:"Heading",switch:"Switch",tab:"Tab",checkbox:"Checkbox",radio:"Radio button",button:"Button",submit:"Button",link:"Link"};function ke(e){let t=e.getAttribute("role")??("INPUT"===e.tagName?e.type:""),n=e.getAttribute("data-pipeup-label")||Object.hasOwn(xe,t)&&xe[t]||xe[e.tagName.toUpperCase()];if(n)return n;if(Se(e))return"Block";let o=e.getBoundingClientRect(),r=o.width/o.height;return r>1.4||r<.7?"Bar":"Shape"}var Ee=e=>e.innerText||e.textContent||"";function Se(e){let t=e,n=t.labels?.[0];return Ae(r(e.getAttribute("aria-label")??e.getAttribute("alt")??(n&&Ee(n))??("SELECT"===e.tagName?t.selectedOptions[0]?.text:null)??(t.placeholder||Ee(e))),40)}function $e(e){let t=e.getAttribute("data-pipeup-label");if(t)return t;let n=Se(e);return n?`${ke(e)} \xb7 ${n}`:ke(e)}function Le(e,t,n){let o=e.id??null,i=e.quote?.exact??null,a=e.point?`${Math.round(100*e.point.x)}% across, ${Math.round(100*e.point.y)}% down the element`:null,l=t.element;if("orphaned"===t.state||!l)return{where:`No longer on the page (it read: "${e.snapshot}")`,element:null,id:o,quote:i,pin:a};let s=[],d=e.view?.slide;if(d){let e=l.closest("[data-pipeup-slide],.reveal .slides section")?.querySelector(Ce)?.textContent;s.push(`Slide ${d}`+(e?` "${Ae(r(e))}"`:""))}else{let t=Me(e.view);t&&s.push(t);let o=function(e,t){let n=e=>!1!==e.checkVisibility?.(),o=n(e),i=e=>r(e.textContent??"");for(let r=e;r&&r!==t;r=r.parentElement)for(let e=r.previousElementSibling;e;e=e.previousElementSibling){let t=e.matches(Ce)?e:[...e.querySelectorAll(Ce)].pop();if(t&&i(e)===i(t)&&(!o||n(t)))return t}return null}(l,n);o&&s.push(`Section "${Ae(r(o.textContent??""))}"`)}let c=$e(l);return s.push(c),{where:s.join(" \u203a "),element:c,id:o,within:!!o&&l.getAttribute("data-pipeup-id")!==o,quote:i,pin:a}}function Me(e){return e?e.label||Object.entries(e).filter(([e,t])=>t&&"slide"!==e).map(([,e])=>e).join(" \xb7 "):""}var Ce="h1,h2,h3";function Ae(e,t=60){return e.length>t?e.slice(0,t-1)+"\u2026":e}var Te="Each thread says where it is: the slide or section, the element (its data-pipeup-id attribute in the HTML), and the exact quoted text or pin position. Work through the open threads in order, and for each one say what you changed or why you did not. Answer in the thread (the Pipeup skill says how) and mark it addressed; never resolve it, the author does.";function Pe(e,t){let n=Math.max(0,Math.round((t-e)/1e3));if(n<60)return"just now";let o=Math.round(n/60);if(o<60)return`${o}m ago`;let r=Math.round(o/60);return r<48?`${r}h ago`:`${Math.round(r/24)}d ago`}function qe(e,t,n,o){return"ai"===t?ze(e,"## Comment thread",o,n):Oe(e)}function Re(e,t,n){let o=n.all?e:e.filter(e=>!e.thread.resolved);if("text"===t)return o.map(Oe).join("\n");let r=n.all?0:e.length-o.length,i=[`# Review comments: ${De(n.title)}`,"",`- **Page:** ${De(n.url)}`,`- **Exported:** ${n.exportedAt.toISOString()}`,`- **Open threads:** ${e.length-e.filter(e=>e.thread.resolved).length}${r?` (${r} resolved, not included)`:n.all?" (resolved ones included)":""}`,"",Te,"",""].join("\n"),a=n.exportedAt.getTime();return i+o.map((e,t)=>ze(e,`## Thread ${t+1}`,a)).join("\n")}function Ne(e){return e.reactions.map(e=>`${e.emoji} ${e.by.length} (${e.by.map(e=>De(g(e))).join(", ")})`).join(" \xb7 ")}function De(e){return e.replace(/\s+/g," ").trim()}function ze(e,t,n,o){let{thread:r,location:i}=e,a=r.root.replies.length,l=[`${t} \xb7 ${r.resolved?"resolved":r.addressed?"open, addressed":"open"}`];if(l.push(`- **Thread:** ${r.id}`),o&&l.push(`- **Page:** ${De(o)}`),l.push(`- **Where:** ${De(i.where)}`),i.id){let e=`\`[data-pipeup-id="${De(i.id.replace(/`/g,""))}"]\``;l.push("- **Element:** "+(i.within&&i.element?`${De(i.element)} in ${e}`:`${e}${i.element?` (${De(i.element)})`:""}`))}i.quote&&l.push(`- **Quoted text:** "${De(i.quote)}"`),i.pin&&l.push(`- **Pin:** ${De(i.pin)}`),r.addressed&&!r.resolved&&l.push(`- **Addressed:** ${De(r.addressed.text)} (${De(g(r.addressed))}, ${Pe(r.addressed.at,n)})`),l.push(`- **Started by:** ${De(g(r.root))}, ${Pe(r.root.at,n)}${a?` \xb7 ${a} ${1===a?"reply":"replies"}`:""}`,"",`**${De(g(r.root))}** (${Pe(r.root.at,n)}): ${He(r.root," ")}`),r.root.reactions.length&&l.push(`Reactions: ${Ne(r.root)}`);for(let e of r.root.replies)l.push(`- **${De(g(e))}** (${Pe(e.at,n)}): ${He(e," ")} \x3c!-- comment:${e.id} --\x3e`),e.reactions.length&&l.push(` - Reactions: ${Ne(e)}`);return l.join("\n")+"\n"}function Oe(e){let{thread:t,location:n}=e,o=[De(n.where)+(n.quote?`, on the text "${De(n.quote)}"`:""),`${De(g(t.root))}: ${He(t.root," ")}`];t.root.reactions.length&&o.push(` Reactions: ${Ne(t.root)}`);for(let e of t.root.replies)o.push(` ${De(g(e))}: ${He(e," ")}`),e.reactions.length&&o.push(` Reactions: ${Ne(e)}`);return o.join("\n")+"\n"}function He(e,t){return e.deleted?"(deleted)":e.text.replace(/\r\n|\r|\n/g,"\n"+t)+(e.edited?" (edited)":"")}function Fe(e,t){return{markdown:Re(e,"ai",t),threads:e.filter(e=>t.all||!e.thread.resolved).map(({thread:e,location:t})=>{let n={id:e.id,state:e.resolved?"resolved":e.addressed?"addressed":"open",where:t.where,comments:[e.root,...e.root.replies].map(e=>({id:e.id,by:g(e),agent:w(e.name),at:new Date(e.at).toISOString(),text:e.deleted?"":e.text,...e.reactions.length?{reactions:e.reactions.map(e=>({emoji:e.emoji,by:e.by.map(g)}))}:{}}))};return t.id&&(n.element=t.id),t.quote&&(n.quote=t.quote),t.pin&&(n.pin=t.pin),e.addressed&&!e.resolved&&(n.addressed={note:e.addressed.text,by:g(e.addressed)}),n})}}var Ie="0.8.0",Be="2026-10-18",je=new Map,We=new Map,Ke=new Map,Ve={},Ue=e=>`${je.get(e)??""}|${We.get(e)??""}`;function Ye(e,t={},...n){let o=document.createElement(e);for(let[e,n]of Object.entries(t))void 0===n||!1===n||("class"===e?o.className=String(n):o.setAttribute(e,!0===n?"":n));for(let e of n)null!=e&&!1!==e&&o.append(e);return o}function _e(e,t){let n=e.getRootNode().activeElement;t&&n instanceof HTMLElement&&e.contains(n)&&n.blur(),e.inert=t}function Ge(e,t,n=null){let o=e.getRootNode().activeElement,r=!1;for(let o=t.length;o--;n=t[o])t[o].nextSibling!==n&&(r=!!e.insertBefore(t[o],n));return r&&o&&t.some(e=>e.contains(o))&&o.focus({preventScroll:!0}),r}var Ze=()=>{let e=window.getSelection();return e&&!e.isCollapsed&&e.toString().trim()?e:null};function Je(e,t){return e.length>t?e.slice(0,t-1)+"\u2026":e}function Xe(e,t,n=4){e.style.left=t.left-n+"px",e.style.top=t.top-n+"px",e.style.width=`${t.width+2*n}px`,e.style.height=`${t.height+2*n}px`}var Qe=/\bhttps?:\/\/[^\s<>"'`]+/gi,et=/[\u202A-\u202E\u2066-\u2069]/;function tt(e){let t=0,n=0;for(let o of e)"("===o?t++:")"===o&&n++;let o=e.length;for(;o>0;){let r=e[o-1];if(")"===r&&n>t)n--;else if(!".,;:!?'\"]}".includes(r))break;o--}return e.slice(0,o)}function nt(e){let t=[],n=0;for(let o of e.matchAll(Qe)){if(o[0].length>2048||et.test(o[0]))continue;let r,i=tt(o[0]),a=o.index??0;try{let e=new URL(i);if("http:"!==e.protocol&&"https:"!==e.protocol)continue;r=e.href}catch{continue}a>n&&t.push(e.slice(n,a));let l=Ye("a",{href:r,target:"_blank",rel:"noopener noreferrer"},i);l.addEventListener("click",e=>e.stopPropagation()),t.push(l),n=a+i.length}return n<e.length&&t.push(e.slice(n)),t}var ot="http://www.w3.org/2000/svg",rt={comment:["M20.5 11.5a8 8 0 0 1-11.7 7.1L4 19.8l1.2-4.4A8 8 0 1 1 20.5 11.5z","M12.3 8.2v6.6M9 11.5h6.6"],copy:["M10 8h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-8a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2z","M16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2"],resolve:["M5 12.5l4.5 4.5L19 7.5"],reopen:["M3 12a9 9 0 1 0 3-6.7","M3 4v5h5"],lines:["M4 7h16M4 12h10M4 17h7"],list:["M3 6.5a1.5 1.5 0 1 0 3 0a1.5 1.5 0 1 0-3 0M3 12a1.5 1.5 0 1 0 3 0a1.5 1.5 0 1 0-3 0M3 17.5a1.5 1.5 0 1 0 3 0a1.5 1.5 0 1 0-3 0M9 6.5h11M9 12h11M9 17.5h7"],expand:["M5.5 10h7a1.5 1.5 0 0 1 1.5 1.5v7a1.5 1.5 0 0 1-1.5 1.5h-7A1.5 1.5 0 0 1 4 18.5v-7A1.5 1.5 0 0 1 5.5 10z","M14 10l6-6M15 4h5v5"],pin:["M12 21c-4-4-7-7.5-7-11a7 7 0 0 1 14 0c0 3.5-3 7-7 11z","M12 7.5a2.5 2.5 0 1 0 0 5a2.5 2.5 0 0 0 0-5z"],at:["M9.1 12a2.9 2.9 0 1 0 5.8 0a2.9 2.9 0 1 0-5.8 0","M14.9 12v1.1a1.8 1.8 0 0 0 3.6 0V12a6.5 6.5 0 1 0-3.97 5.98"],chev:["M9 6l6 6-6 6"],shrink:["M7 4h10a3 3 0 0 1 3 3v10a3 3 0 0 1-3 3H7a3 3 0 0 1-3-3V7a3 3 0 0 1 3-3z","M16 8l-7 7M9 10v5h5"],bubble:["M20.5 11.5a8 8 0 0 1-11.7 7.1L4 19.8l1.2-4.4A8 8 0 1 1 20.5 11.5z"],wide:["M23.2 11.2a10.8 8.2 0 0 1-14.85 7.6L2.6 21l.45-5.7A10.8 8.2 0 1 1 23.2 11.2z"],close:["M6 6l12 12M18 6L6 18"],smile:["M12 3a9 9 0 1 0 0 18a9 9 0 0 0 0-18z","M8.6 14.2c1.9 2.1 4.9 2.1 6.8 0","M9.6 9.8a.6.6 0 1 1-1.2 0a.6.6 0 1 1 1.2 0M15.6 9.8a.6.6 0 1 1-1.2 0a.6.6 0 1 1 1.2 0"],edit:["M4 20h4L19 9l-4-4L4 16z"],hide:["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 12z","M12 9.5a2.5 2.5 0 1 0 0 5a2.5 2.5 0 0 0 0-5z","M4 4l16 16"],more:["M5.5 12h.01M12 12h.01M18.5 12h.01"],look:["M12 3a9 9 0 1 0 0 18a9 9 0 0 0 0-18z","M12 3v18"]};function it(e,t=15,n){let o=at(rt[e],t);return n&&o.setAttribute("stroke-width",String(n)),o}function at(e,t){let n=document.createElementNS(ot,"svg"),o={width:String(t),height:String(t),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"};for(let[e,t]of Object.entries(o))n.setAttribute(e,t);for(let t of e){let e=document.createElementNS(ot,"path");e.setAttribute("d",t),n.append(e)}return n}var lt=(e,t,n)=>`M${e} ${t}a${n} ${n} 0 1 0 ${2*n} 0a${n} ${n} 0 1 0 -${2*n} 0`,st={Otter:"M4 13.2C4 9.2 7.6 6.5 12 6.5s8 2.7 8 6.7-3.6 6.3-8 6.3-8-2.3-8-6.3zM5.6 9.6a1.8 1.8 0 1 1 2.7-2.3M18.4 9.6a1.8 1.8 0 1 0-2.7-2.3M9.2 11.6h.01M14.8 11.6h.01M11 14h2l-1 1zM9.8 15.8l-3.2.4M9.9 17l-2.7 1.1M14.2 15.8l3.2.4M14.1 17l2.7 1.1",Fox:"M3.5 4l5 3.5h7l5-3.5-1.5 8.5L12 20l-7-7.5zM9 12h.01M15 12h.01M12 17h.01",Owl:`M5 4.5l3 2.5h8l3-2.5V14a7 7 0 0 1-14 0z${lt(7.4,11.5,1.9)}${lt(12.8,11.5,1.9)}M11.3 14.6l.7 1 .7-1`,Bear:`${lt(5,13.5,7)}M8.9 7.22A2.8 2.8 0 1 0 5.89 10.09M18.11 10.09A2.8 2.8 0 1 0 15.1 7.22M9.4 12.6h.01M14.6 12.6h.01M10.3 16.4c0-1 .8-1.6 1.7-1.6s1.7.6 1.7 1.6-.8 1.6-1.7 1.6-1.7-.6-1.7-1.6z`,Rabbit:`${lt(6.5,15.5,5.5)}M9.6 10.5C8.2 6.5 8.4 2.5 9.8 2.5s2.4 3.5 1.6 7.5M14.4 10.5c1.4-4 1.2-8-.2-8s-2.4 3.5-1.6 7.5M10 15h.01M14 15h.01M11.3 17.3l.7.5.7-.5`};function dt(e){let t=/[\p{L}\p{N}]/u.exec(e);if(!t)return"";let n=t[0].toUpperCase();return 1===[...n].length?n:t[0]}var ct=(e,t)=>dt(t)||m(e);function ut(e,t){return w(t)?Ye("span",{class:"av ai","data-pipeup-ai":"","aria-hidden":"true"},"AI"):Ye("span",{class:`av c${f(e)}`,"aria-hidden":"true","data-animal":m(e)},dt(t)||at([st[c[h(e)]]],24))}function pt(e,t){setTimeout(()=>{e.remove(),t?.()},320)}function ht(e){return requestAnimationFrame(()=>{e.offsetWidth,e.classList.add("in")}),e}var ft=/^[A-Za-z0-9_-]{43}$/,mt=/^(?:host|gh):[A-Za-z0-9._@-]{1,64}$/,gt=[],vt=new Set;function wt(e,t){let n=new Map,o=e=>{e.ref!==t&&!n.has(e.ref)&&n.set(e.ref,e)},r=e=>o({ref:e.author,name:g(e),...w(e.name)?{agent:!0}:{}});for(let t of e)for(let e of[t.root,...t.root.replies])if(!e.deleted){r(e);for(let t of e.reactions)for(let e of t.by)r({...e})}for(let e of(document.documentElement.getAttribute("data-pipeup-agents")??"").split(/[\s,]+/).filter(e=>ft.test(e)))o({ref:e,name:"AI agent",agent:!0});for(let e of gt)o(e);return[...n.values()].sort((e,t)=>e.name.localeCompare(t.name))}var yt=(e,t)=>!!e.mentions?.some(e=>t.includes(e.ref)),bt=[],xt=e=>[e,...bt],kt=null,Et=e=>{kt=e},St="pu-source";function $t(e){let t=Ye("textarea",{class:"input",dir:"auto",rows:"1","aria-label":e.name??e.label,placeholder:e.placeholder??""}),n=Ye("button",{class:"send",type:"button",inert:!0},e.label),o=Ye("button",{class:"cnl",type:"button"},"Cancel"),r=Ye("span",{class:"tools"});r.hidden=!0;let i=Ye("div",{class:"line"},t,r),a=Ye("div",{class:"row"},i,Ye("div",{class:"bts"},o,n)),l=e.kind??"comment",s=!1,d=new Set,c=()=>{for(let e of[...d])e()},u=()=>{let e=""!==t.value.trim();n.classList.toggle("show",e),a.classList.toggle("has",e),n.inert=!e,t.style.height="auto",t.style.height=`${Math.max(27,t.scrollHeight)}px`},p=()=>{let e=-1,n=0,o=(o,r)=>{e<0&&(e=t.selectionStart,n=0);let i=t.value.slice(0,e),a=o&&i&&!/\s$/.test(i)&&!/^\s/.test(o)?" ":"";t.setRangeText(a+o,e,e+n,"end"),n=a.length+o.length,r&&(e=-1),u()};return{update:e=>o(e,!1),commit:e=>o(e,!0),cancel:()=>{e>=0&&n&&t.setRangeText("",e,e+n,"end"),e=-1,n=0,u()}}},h=new Map,f=()=>{let n=(kt?.tools()??[]).filter(e=>!1!==e.available?.());for(let[e,t]of h)n.some(t=>t.id===e)||(t.remove(),h.delete(e));for(let o of n){if(h.has(o.id))continue;let n=Ye("button",{class:"ib tool",type:"button","aria-label":o.label,title:o.label,"aria-pressed":"false"},at(o.icon,15));n.addEventListener("mousedown",e=>e.preventDefault()),n.addEventListener("click",r=>{r.stopPropagation();try{o.press({kind:l,thread:e.thread?.()??null,text:()=>t.value,focus:()=>t.focus({preventScroll:!0}),connected:()=>a.isConnected,setPressed:e=>n.setAttribute("aria-pressed",String(e)),dictate:p,onEnd:e=>(d.add(e),()=>d.delete(e))})}catch(e){globalThis.reportError?.(e)}}),h.set(o.id,n),r.append(n)}r.hidden=0===h.size};f(),a.addEventListener(St,f);let m=[],g=Ye("ul",{class:"mnl",role:"listbox","aria-label":"People"}),v=Ye("span",{class:"mn-sr","aria-live":"polite"}),w=`mn-${Math.random().toString(36).slice(2,8)}`;g.id=w;let y=[],b=0,x=null;e.people&&(t.setAttribute("aria-autocomplete","list"),t.setAttribute("aria-haspopup","listbox"),t.setAttribute("aria-controls",w),a.append(g,v));let k=()=>{y=[],g.classList.remove("show"),t.removeAttribute("aria-activedescendant"),window.setTimeout(()=>!y.length&&g.replaceChildren(),220)},E=()=>{for(let[e,n]of[...g.children].entries()){let o=e===b;n.setAttribute("aria-selected",String(o)),n.classList.toggle("on",o),o&&t.setAttribute("aria-activedescendant",n.id)}},S=e=>{let n=y[e];if(!n||!x)return;let o=t.selectionStart;t.setRangeText(`@${n.name} `,x.start,o,"end"),m.push({label:n.name,ref:n.ref}),k(),u()},$=async()=>{let o=t.value.trim();if(o&&!s){s=!0;try{await e.q(o,m.length?function(e,t){let n=[];for(let o of t){let t=`@${o.label}`,r=0;for(;;){let i=e.indexOf(t,r);if(i<0)break;let a=i+t.length;if((0===i||/\s/.test(e[i-1]))&&(a===e.length||!/[\p{L}\p{N}_]/u.test(e[a]))&&!n.some(e=>i<e.end&&a>e.start)){n.push({start:i,end:a,ref:o.ref});break}r=i+1}}return n.sort((e,t)=>e.start-t.start).slice(0,20)}(o,m):[]),n.matches(":focus")&&t.focus(),t.value="",m.length=0,k(),u(),c()}catch{}finally{s=!1}}};i.addEventListener("mousedown",e=>{e.target===t||r.contains(e.target)||(e.preventDefault(),t.focus({preventScroll:!0}),t.setSelectionRange(t.value.length,t.value.length))}),t.addEventListener("input",()=>{u(),e.people&&(()=>{if(x=t.selectionStart===t.selectionEnd?function(e){let t=/(^|\s)@([^\s@]*(?:\s[^\s@]*)?)$/.exec(e);return t?{start:t.index+t[1].length,query:t[2]}:null}(t.value.slice(0,t.selectionStart)):null,y=x&&e.people?function(e,t){let n=t.trim().toLowerCase(),o=e.filter(e=>e.name.toLowerCase().startsWith(n)),r=n?e.filter(e=>!o.includes(e)&&e.name.toLowerCase().includes(n)):[];return[...o,...r].slice(0,8)}(e.people(),x.query):[],!y.length)return k();b=Math.min(b,y.length-1),g.replaceChildren(...y.map((e,t)=>{let n=Ye("li",{role:"option",id:`${w}-${t}`,class:e.agent?"agent":""},Ye("span",{},e.name),e.agent?Ye("small",{},"AI agent"):null);return n.addEventListener("mousedown",e=>{e.preventDefault(),S(t)}),n})),g.classList.add("show"),v.textContent=`${y.length} ${1===y.length?"person":"people"}`,E()})()}),t.addEventListener("blur",()=>y.length&&k()),t.addEventListener("mousedown",e=>e.defaultPrevented&&t.focus({preventScroll:!0}));for(let e of["keyup","keypress"])t.addEventListener(e,e=>e.stopPropagation());t.addEventListener("keydown",e=>{if(e.stopPropagation(),y.length&&!e.isComposing){if("ArrowDown"===e.key||"ArrowUp"===e.key)return e.preventDefault(),b=(b+("ArrowDown"===e.key?1:y.length-1))%y.length,E();if("Enter"===e.key||"Tab"===e.key)return e.preventDefault(),S(b);if("Escape"===e.key)return e.preventDefault(),k()}"Enter"!==e.key||e.shiftKey||e.isComposing?"Escape"===e.key&&!e.isComposing&&(e.preventDefault(),L()):(e.preventDefault(),$())});let L=()=>{let n=t.value.trim()?t.value:"";t.value="",u(),(!n||"reply"!==l)&&t.blur(),c(),e.F?.(n)};for(let e of[n,o])e.addEventListener("mousedown",e=>e.preventDefault());return n.addEventListener("click",e=>{e.stopPropagation(),$()}),o.addEventListener("click",e=>{e.stopPropagation(),L()}),e.value&&(t.value=e.value,queueMicrotask(u)),{element:a,input:t,focus:()=>t.focus({preventScroll:!0})}}var Lt=["sync","menu","notify","note","composer","panel","styles","status","overlay","here","sign","listnote","reactions","identity","dialog"],Mt=/^[a-z][a-z0-9-]{1,23}$/,Ct=new Set(["local","file","page","user","pipeup","presence","sync"]),At=class{constructor(e,t,n){this.ctx=e,this.shadow=t,this.after=n,Et({tools:()=>this.j,note:()=>[...this.oe.values()].at(-1)??null})}ne=0;V=[];oe=new Map;writing=new Map;marked=new Map;paint=0;re=new Map;listNotes=new Map;picker=null;pickerOwner="";j=[];ie=new Set;K=new Set;Y=new Set;G=new Map;$=new Map;X=new Map;remote={n:0,who:new Set};last=0;timer=0;we="";subscribe(e){return this.Y.add(e),()=>{this.Y.delete(e)}}changed(e){e&&this.ne++;for(let t of[...this.Y])t(e);for(let e of this.ctx.e.querySelectorAll(".row, .draft"))e.dispatchEvent(new Event(St))}N(e,t){let n=this.X.get(e)??this.X.set(e,new Set).get(e),o=()=>{n.delete(o)&&t()};return n.add(o),o}be(){return[...this.re.values()].map(e=>e.text).join(" \xb7 ")}Oe(e,t){return this.V.push(t),this.changed(!0),{update:()=>this.changed(!1),remove:this.N(e,()=>{this.V.splice(this.V.indexOf(t),1),this.changed(!0)})}}setThread(e,t,n){let o=this.writing.get(e)??this.writing.set(e,new Set).get(e);null===n?(je.delete(t),o.delete(t)):(je.set(t,n),o.add(t)),this.repaint()}setMark(e,t,n,o){let r=this.marked.get(e)??this.marked.set(e,new Set).get(e);if(null===n){if(Ke.delete(t),!We.delete(t))return;r.delete(t)}else{if(We.get(t)===n&&!!Ke.get(t)==!!o)return;We.set(t,n),o?Ke.set(t,o):Ke.delete(t),r.add(t)}this.repaint()}repaint(){this.paint||(this.paint=window.requestAnimationFrame(()=>{this.paint=0,this.ctx.m()}))}se(e,t,n){n?e.set(t,n):e.delete(t),this.changed(!1)}setPicker(e,t){t?(this.picker=t,this.pickerOwner=e):this.pickerOwner===e&&(this.picker=null,this.pickerOwner=""),this.changed(!1)}Re(e,t){return this.j.push(t),this.changed(!1),this.N(e,()=>{this.j.splice(this.j.indexOf(t),1),this.changed(!1)})}closed(){return this.ctx.state.hidden&&!this.ctx.state.l}Ne(e,t){this.closed()?this.$.set(e,t):this.ctx.ae(t)}flush(){if(this.closed()||0===this.$.size)return;let e=[...this.$.values()].at(-1);this.$.clear(),this.ctx.ae(e)}Ie(){return this.shadow.activeElement instanceof HTMLTextAreaElement||[...this.ctx.e.querySelectorAll("textarea")].some(e=>""!==e.value.trim())}He(e){this.ctx.state.hidden||this.ctx.L(e)}De(e,t){if("local"!==t&&""!==t){for(let{body:t}of e)t.author===this.ctx.doc.me||"create"!==t.kind&&"reply"!==t.kind||(this.remote.n++,this.remote.who.add(t.name||m(t.author)));this.xe()}}xe(e=Math.max(0,this.last+1e4-Date.now())){this.timer||!this.remote.n||(this.timer=window.setTimeout(()=>{if(this.timer=0,this.ctx.state.hidden||this.Ie())return this.xe(1e3);let{n:e,who:t}=this.remote;this.remote={n:0,who:new Set},this.last=Date.now(),this.ctx.L(`${e} new comment${1===e?"":"s"} from ${1===t.size?[...t][0]:`${t.size} people`}`)},e))}Be(e){let t=this.G.get(e);return t||(t=Ye("div",{class:"ov","aria-hidden":"true","data-addon":e}),this.ctx.e.insertBefore(t,this.after.nextSibling),this.G.set(e,t)),t}qe(e,t){let n=this.ctx.host.ownerDocument.defaultView?.CSSStyleSheet,o=n&&"replaceSync"in n.prototype&&"adoptedStyleSheets"in this.shadow?new n:null;o&&(o.replaceSync(t),this.shadow.adoptedStyleSheets=[...this.shadow.adoptedStyleSheets,o]);let r=o??this.shadow.appendChild(Ye("style",{},t));return this.N(e,()=>o?this.shadow.adoptedStyleSheets=this.shadow.adoptedStyleSheets.filter(e=>e!==o):r.remove())}Ee(e,t,n){return t.add(n),this.N(e,()=>t.delete(n))}Fe(e,t){return this.Ee(e,this.ie,t)}Ve(e,t){let n=this.Ee(e,this.K,t);return this.call(this.K,t,this.ke()),n}ke(){let{state:e}=this.ctx,t=this.shadow.activeElement;return{shown:!e.hidden,commentMode:e.p,allOpen:e.u,dark:this.ctx.e.classList.contains("dark"),view:this.ctx.f.view(),writing:t instanceof HTMLTextAreaElement?t.closest("[data-thread]")?.dataset.thread??"":null}}O(){for(let e of[...this.ie])this.call(this.ie,e);if(0===this.K.size)return;let e=this.ke(),t=JSON.stringify(e);if(t!==this.we){this.we=t;for(let t of[...this.K])this.call(this.K,t,e)}}call(e,t,...n){try{t(...n)}catch(n){e.delete(t),globalThis.reportError?.(n)}}Ke(e,t,n){let o=this.ctx.e,r=this.shadow.activeElement,i=Ye("button",{class:"ib",type:"button","aria-label":"Close"},at(["M6 6l12 12M18 6L6 18"],15)),a=Ye("div",{class:"xp",role:"dialog","aria-label":n.label,"data-addon":e},Ye("div",{class:"hd"},Ye("span",{},n.label),i),Ye("div",{class:"xb"},t)),l=[...o.children].filter(e=>e instanceof HTMLElement&&!e.inert);for(let e of l)e.inert=!0;o.append(a),a.offsetWidth,a.classList.add("show");let s=e=>{"Escape"===e.key&&(e.stopPropagation(),e.preventDefault(),d())},d=this.N(e,()=>{window.removeEventListener("keydown",s,!0);for(let e of l)e.inert=!1;a.classList.remove("show"),a.inert=!0,window.setTimeout(()=>a.remove(),300),r?.focus?.({preventScroll:!0});try{n.onClose?.()}catch(e){globalThis.reportError?.(e)}});return i.addEventListener("click",d),window.addEventListener("keydown",s,!0),(a.querySelector("button, input, textarea, select, a[href]")??a).focus?.({preventScroll:!0}),{close:d}}dialog(e,t,n){this.ctx.e.querySelector(".dlg")?.remove();let o=Ye("div",{class:"dlg",role:"dialog","aria-label":n},t),r=()=>{},i=()=>{o.classList.remove("show"),o.inert=!0,window.setTimeout(r,260)};return o.addEventListener("keydown",e=>{e.stopPropagation(),"Escape"===e.key&&(e.preventDefault(),i())}),this.ctx.e.append(o),o.offsetWidth,o.classList.add("show"),o.querySelector("textarea, button.primary, button")?.focus({preventScroll:!0}),r=this.N(e,()=>o.remove()),{close:i}}clear(e){for(let t of[...this.X.get(e)??[]])t();this.X.delete(e),this.G.get(e)?.remove(),this.G.delete(e);for(let t of[this.oe,this.re,this.listNotes,this.$])t.delete(e);this.setPicker(e,null);for(let t of this.writing.get(e)??[])je.delete(t);this.writing.delete(e);for(let t of this.marked.get(e)??[])We.delete(t),Ke.delete(t);this.marked.delete(e),this.repaint(),this.changed(!0)}destroy(){window.clearTimeout(this.timer),Et(null),this.Y.clear()}},Tt=new Map,Pt=null,qt=(()=>{let e=globalThis.Pipeup;return e?.VERSION?e:null})();function Rt(){return qt?qt.addons():[...Tt.values()].map(e=>({...e.info}))}function Nt(e){if(qt)return qt.use(e);let t=e=>console.warn(`pipeup: ${e}`),n=e;if(!n||"object"!=typeof n||"string"!=typeof n.id||!Mt.test(n.id)||Ct.has(n.id)||"function"!=typeof n.setup||"string"!=typeof n.network?.says)return t("an add-on needs an id of 2 to 24 lowercase letters, digits and dashes (not a reserved one), a setup function and a network statement");if(Tt.has(n.id))return t(`the add-on "${n.id}" is already registered; the second is ignored`);let o={id:n.id,version:String(n.version??""),network:n.network,state:"waiting"},r=(n.needs??[]).find(e=>!Lt.includes(e));!function(e){let t=typeof document>"u"?null:document.documentElement.getAttribute("data-pipeup-addons");return null===t||t.toLowerCase().split(/[\s,]+/).includes(e)}(n.id)?(o.state="off",o.reason="this page doesn't allow it",t(`the add-on "${n.id}" is not in this page's data-pipeup-addons list, so it is off`)):1!==n.api?(o.state="off",o.reason=`needs add-on API ${String(n.api)}; this Pipeup has 1`):r&&(o.state="off",o.reason=`this Pipeup has no ${r} slot`);let i={addon:e,info:o};Tt.set(n.id,i),Pt?.i&&"waiting"===o.state&&zt(i,Pt)}function Dt(){if(qt)return!0;let e=globalThis,t=e.pipeupAddons;if(Array.isArray(t))for(let e of t)Nt(e);else if(t&&"object"==typeof t&&t.push!==Nt)return!1;return e.pipeupAddons={push:Nt},!0}async function zt(e,t){let n,o,{addon:r,info:i}=e,a=new AbortController,l=new Set,{surface:s,doc:d}=t,c=()=>!a.signal.aborted,u=Object.assign(()=>{},{update(){},remove(){},close(){}}),p=e=>(...t)=>c()?e(...t):u,h={id:d.id,me:d.me,get name(){return d.name},threads:()=>d.threads(),ops:()=>d.ops(),contacts:()=>d.contacts(),onChange:e=>{let t=d.onChange(e);return l.add(t),()=>{t(),l.delete(t)}}},f=r.id,m={api:1,version:t.version,document:h,root:t.root,ephemeral:t.ephemeral,signal:a.signal,has:e=>Lt.includes(e),off:e=>{o=String(e)},merge:e=>c()?d.merge(e,f):Promise.resolve(0),addMenuItem:p(e=>s.Oe(f,e)),notify:p(e=>s.Ne(f,e)),announce:p(e=>s.He(e)),setComposerNote:p(e=>s.se(s.oe,f,e)),setThreadNote:p((e,t)=>s.setThread(f,e,t)),setThreadMark:p((e,t,n)=>s.setMark(f,e,t,n)),addComposerTool:p(e=>s.Re(f,e)),openPanel:p((e,t)=>s.Ke(f,e,t)),addStyles:p(e=>s.qe(f,e)),setStatus:p(e=>s.se(s.re,f,e)),setListNote:p(e=>s.se(s.listNotes,f,e)),setReactionPicker:p(e=>s.setPicker(f,e)),overlay:()=>s.Be(f),onFrame:p(e=>s.Fe(f,e)),where:e=>s.ctx.f.view(e),isHere:e=>s.ctx.f.w(e),go:e=>s.ctx.f.Z(e),onUi:p(e=>s.Ve(f,e)),avatar:(e,t)=>{let n=ut(e,t);return n.classList.add("in"),n},sign:(e,t)=>d.sign(`${f}/${e}`,t),identity:{portable:d.portable,seed:()=>d.seed(),use:async e=>{if("private"!==e.type||"Ed25519"!==e.algorithm.name||!e.extractable)throw new Error("pipeup: an identity is an extractable Ed25519 private key");let{x:n}=await crypto.subtle.exportKey("jwk",e);await t.onIdentity({publicKey:n,privateKey:e})},share:e=>d.contact(e).then(()=>!0,()=>!1),unshare:()=>d.uncontact()},openDialog:p((e,t)=>s.dialog(f,e,t))},g=()=>{if(c()){a.abort();for(let e of[...l])e();try{n?.()}catch(e){globalThis.reportError?.(e)}s.clear(f),"on"===i.state&&(i.state="waiting")}};e.stop=g;try{if(n=await r.setup(m),!c())return void n?.();if(void 0!==o)return g(),i.state="off",void(i.reason=o);i.state="on",delete i.reason}catch(e){i.state="failed",i.reason=function(e){return e instanceof Error?e.message:String(e)}(e),g(),i.state="failed",globalThis.reportError?.(e)}}var Ot=typeof navigator<"u"&&/Mac|iP(hone|ad|od)/.test(navigator.platform)?"\u21e7\u2325C":"Shift+Alt+C",Ht=" ",Ft="Shift+Alt+C";var It=new WeakMap;function Bt(e,t){let n=It.get(t)??function(e){let t=Ye("button",{class:"me",type:"button",tabindex:"-1","aria-hidden":"true"});t.addEventListener("mousedown",e=>e.preventDefault());let n=$t({label:"Comment",placeholder:"Comment or add others with @",kind:"comment",q:e.q,F:e.F,people:e.people}),o=Ye("div",{class:"note"}),r=()=>{let e=kt?.note()??null;o.textContent=e??"",o.hidden=!e};r();let i=Ye("div",{class:"say"}),a=Ye("input",{class:"input",type:"text",maxlength:"80","aria-label":"Your name"}),l=Ye("div",{class:"nf"},a),s=Ye("div",{class:"you"},i,l),d="",c=!1,u=()=>{let n=e.name(),o=n?"change":"add your name";if(t.title=n?"Change your name":"Add your name",!t.lastChild||d!==n){let o=ut(e.me,n),r=t.lastChild;r?(ht(o),pt(r)):o.classList.add("in"),t.append(o),d=n}let r=Ye("button",{type:"button"},o);r.addEventListener("click",h),i.replaceChildren(Ye("span",{class:"nm"},n||`You're ${m(e.me)}`)," \xb7 ",r)},p=e=>{s.classList.toggle("naming",e),_e(i,e),_e(l,!e)};function h(t){t.stopPropagation(),a.value=e.name(),p(!0),a.focus({preventScroll:!0}),a.select()}let f=()=>{p(!1),n.focus()};t.addEventListener("click",h),a.addEventListener("keydown",t=>{if(t.stopPropagation(),"Escape"!==t.key||t.isComposing){if("Enter"===t.key){t.preventDefault();let n=a.value.trim();if(!n||n===e.name())return f();if(c)return;c=!0,e.rename(n).finally(()=>{c=!1,u(),f()})}}else t.preventDefault(),f()}),u(),p(!1);let g=Ye("div",{class:"ctx"},e.label),v=Ye("div",{class:"draft"},Ye("div",{class:"hdr"},t,s),g,o,n.element);return v.addEventListener(St,r),{element:v,le:()=>{let{selectionStart:e,selectionEnd:t}=n.input;return()=>{n.focus(),n.input.setSelectionRange(e,t)}},J:e=>{g.hidden=e},de:e=>{g.textContent=e},focus:()=>n.focus(),_e:()=>""===n.input.value.trim(),fill:e=>{n.input.value=e,n.input.dispatchEvent(new Event("input")),n.focus(),n.input.setSelectionRange(e.length,e.length)}}}({label:t.label,me:e.doc.me,name:()=>e.l.name(),rename:t=>e.l.rename(t),q:(t,n)=>e.Ue(t,n),people:()=>e.people(),F:t=>e.ce(t)});return It.set(t,n),e.I(n),n}var jt="a,button,input,select,textarea,label,summary,[role=button],[contenteditable]";function Wt(e,t){if("orphaned"===t.state||!t.element||e.quote)return null;let n=t.element.getBoundingClientRect();if(!n.width&&!n.height)return null;if(e.point)return{x:n.left+e.point.x*n.width,y:n.top+e.point.y*n.height};if(t.element.matches(jt))return{x:n.right+4,y:n.top+14};let o=t.element.ownerDocument.createRange();o.selectNodeContents(t.element);let r=o.getBoundingClientRect();return{x:r.width?Math.min(n.right-8,r.right+6):n.right-8,y:(r.height?r.top:n.top)+8}}function Kt(e){return e.range?[...e.range.getClientRects()]:[]}function Vt(e,t){let n=Kt(t)[0];if(n)return n.top;if("orphaned"===t.state||!t.element)return null;let o=t.element.getBoundingClientRect();return e.point?o.top+e.point.y*o.height:o.top}function Ut(e,t){let n=Kt(t).at(-1);if(n)return{x:n.left,y:n.bottom,below:!0,s:n};let o=Wt(e,t);if(!o)return null;let r=e.point?new DOMRect(o.x-12,o.y-12,24,24):t.element.getBoundingClientRect();return{...o,below:!1,s:r}}function Yt(e,t,n){for(let o of n)if(e>=o.left&&e<=o.right&&t>=o.top&&t<=o.bottom)return!0;return!1}var _t=()=>window.innerWidth>=900?400:300,Gt=()=>window.innerWidth<=480,Zt=()=>!0===window.matchMedia?.("(pointer: coarse)").matches,Jt=(e,t,n,o)=>n.keep&&e+t>n.keep.left?Math.min(n.height-o,n.keep.top-8):n.height-o;function Xt(e,t,n,o=12,r=44){let i=e.top-r>=8,a=e.top+e.height+8+(i?0:r),l=e.top-8-(i?r:0)-t.height,s=Math.max(o,Math.min(e.left,n.width-t.width-o)),d=e=>a+t.height<=Jt(e,t.width,n,o),c=n.keep?n.keep.left-8-t.width:-1;!d(s)&&c>=o&&d(c)&&(s=Math.min(s,c));let u=Jt(s,t.width,n,o),p=a+t.height<=u||l<o;return{above:!p,left:s,top:Math.max(o,p?Math.min(a,u-t.height):l)}}function Qt(e,t,n){let o=e.top-t.height-10,r=o<8?e.top+e.height+10:o;return r+t.height>n.height-8&&(r=Math.max(8,o)),{left:Math.max(8,Math.min(e.left+e.width/2-t.width/2,n.width-t.width-8)),top:r}}function en(e,t){let n=e.resolved.get(t.id);return n?.range?.startContainer??n?.element??null}var tn=e=>(t,n)=>{let o=en(e,t),r=en(e,n),i=e=>e.anchor.point??{x:0,y:-1};return o!==r?!r||o&&4&o.compareDocumentPosition(r)?-1:1:i(t).y-i(n).y||i(t).x-i(n).x},nn=["\u{1f44d}","\u2764\ufe0f","\u{1f602}","\u{1f389}","\u{1f62e}","\u{1f64f}"],on={"\u{1f44d}":"Thumbs up","\u2764\ufe0f":"Heart","\u{1f602}":"Laughing","\u{1f389}":"Party popper","\u{1f62e}":"Surprised","\u{1f64f}":"Thanks"};var rn=e=>`${e} ${1===e?"reply":"replies"}`,an=e=>e.root.replies.filter(e=>!e.deleted);function ln(e,t,n){let o={...n},r="card"===o.H,i=e.id,a=Ye("div",{class:"rbox always"},Ye("div",{},$t({label:"Reply",placeholder:"Reply or add others with @",kind:"reply",thread:()=>i,people:()=>t.people(),q:(e,n)=>t.reply(i,e,n),F:e=>e?t.drop(i,e):t.close()}).element)),l=Ye("div",{}),s=Ye("span",{class:"note"},"This thread was resolved. Your words are kept until you send or clear them.");s.hidden=!0,a.prepend(s);let d=Ye("div",{}),c=null,u=null,p=null,h="",f=Ye("div",{},d,r?null:Ye("div",{class:"more"},l)),m=new Set,y="",b="",x="",k=0,E=null,S=new Set,$=e,L=new Map,M=new Map,C=new Map,A=(e,t,n)=>{let o=Ye("button",{class:"ib",type:"button","aria-label":t,title:t},it(e,18,"more"===e?2.6:void 0));return o.addEventListener("click",e=>{e.stopPropagation(),n()}),o},T=e=>f.querySelector(e)?.focus({preventScroll:!0});function P(e,n={}){let q=f.getRootNode().activeElement,R=q&&f.contains(q)?q.dataset.k:void 0;(function(e,n){Object.assign(o,n);let q=b;b=y,i=e.id,$=e;let R=(o.now??Date.now)(),N=an(e),D=N.length,z=e=>{let n=t=>w(e.name)?function(e){let t=[],n=e.split("\n").filter(e=>{let n=/^\[(\d{1,2})\]:?\s+(\S+)(?:\s+([^|]{1,40}?))?(?:\s*\|\s*(.{1,300}))?$/.exec(e.trim()),o=n?.[2]?function(e){return/^slide:\d{1,4}$/.test(e)||/^quote:\S{1,300}$/.test(e)?e:function(e){if(e.length>2048||et.test(e))return null;try{let t=new URL(e);return"http:"===t.protocol||"https:"===t.protocol?t.href:null}catch{return null}}(e)}(n[2]):null;return n?.[1]&&o&&t.push({n:n[1],to:o,label:n[3]?.trim()??"",says:n[4]?.trim()??""}),!(n?.[1]&&o)}).join("\n").replace(/\s*\[\d{1,2}\]/g,"").trim();if(!t.length)return nt(e);let o=t.slice(0,4).map(e=>{let t=e.to.startsWith("slide:"),n=e.label||(t?`Slide ${e.to.slice(6)}`:`[${e.n}]`),o=[t?Ye("i",{class:"sl"}):null,Ye("span",{},t||""===e.label?n:`[${e.n}] ${n}`),e.says?Ye("span",{class:"rc",role:"tooltip"},e.says):null];if(/^https?:/.test(e.to)){let t=Ye("a",{class:"ref",href:e.to,target:"_blank",rel:"noopener noreferrer",title:e.says?void 0:e.to},...o);return t.addEventListener("click",e=>e.stopPropagation()),t}let r=Ye("button",{class:"ref",type:"button",title:e.says?void 0:t?n:`Show where: ${n}`},...o);return r.addEventListener("click",t=>{t.stopPropagation(),Ve.go?.(e.to)}),r});return[...nt(n),Ye("div",{class:"refs"},...o)]}(t):nt(t);if(!e.mentions?.length)return n(e.text);let o=[],r=0;for(let i of e.mentions)i.start<r||(o.push(...n(e.text.slice(r,i.start))),o.push(Ye("span",{class:yt(e,[t.me])&&i.ref===t.me?"mn me":"mn"},e.text.slice(i.start,i.end))),r=i.end);return[...o,...n(e.text.slice(r))]},O=n=>function(e,t){if(e.deleted||(t.bare||!e.reactions.length)&&!t.quick)return null;let n=n=>e.reactions.find(e=>e.emoji===n)?.by.some(e=>e.author===t.me)??!1,o=(t.bare?[]:e.reactions).map(o=>{let r=n(o.emoji),i=o.by.length,a=[...r?["You"]:[],...o.by.filter(e=>e.author!==t.me).map(e=>g(e))],l=`${e.id}|${o.emoji}`,s=Ye("button",{class:`ref rx${r?" mine":""}${t.seen.has(l)?"":" new"}`,type:"button","aria-pressed":String(r),"aria-label":`${t.picker?.name(o.emoji)??on[o.emoji]??"Reaction"}, ${i} ${1===i?"person":"people"}${r?", including you":""}`,"data-k":`x${e.id}${o.emoji}`},Ye("span",{},o.emoji),Ye("span",{class:"n"},String(i)),Ye("span",{class:"rc"},a.join(", ")));t.seen.add(l),s.disabled=t.resolved;let d=0,c=!1;s.addEventListener("pointerdown",e=>{c=!1,"touch"===e.pointerType&&(d=window.setTimeout(()=>{c=!0,s.classList.add("held"),window.addEventListener("pointerdown",()=>s.classList.remove("held"),{capture:!0,once:!0})},450))});for(let e of["pointerup","pointercancel"])s.addEventListener(e,()=>window.clearTimeout(d));return s.addEventListener("contextmenu",e=>e.preventDefault()),s.addEventListener("click",e=>{e.stopPropagation(),c?c=!1:t.react(o.emoji,!r)}),s}),r=t.quick&&!t.resolved?Ye("div",{class:"rxq"+(t.seen.has(`${e.id}|quick`)?"":" new"),role:"group","aria-label":"React","data-q":e.id},...nn.map(o=>{let r=Ye("button",{class:"rxo",type:"button","aria-label":on[o],"aria-pressed":String(n(o)),"data-k":`q${e.id}${o}`},o);return r.addEventListener("click",e=>{e.stopPropagation(),t.react(o,!n(o))}),r}),t.picker?function(e,t){let n=Ye("button",{class:"rxo",type:"button","aria-label":"More reactions","aria-haspopup":"dialog"},"\u2026");return n.addEventListener("click",o=>{o.stopPropagation(),function(e,t,n){let o=e.closest(".layer");if(!o)return;o.querySelector(".rxp")?.remove();let r=e.getBoundingClientRect(),i=Math.max(8,Math.min(r.left,window.innerWidth-320-8)),a=r.bottom+6+340<=window.innerHeight-8?r.bottom+6:Math.max(8,r.top-340-6),l=Ye("div",{class:"rxp",role:"dialog","aria-label":"Choose a reaction"});l.style.cssText=`left:${i}px;top:${a}px`;let s=!1,d={},c=e=>{e.composedPath().includes(l)||u()},u=()=>{s||(s=!0,window.removeEventListener("pointerdown",c,!0),d.off?.(),l.classList.remove("show"),l.inert=!0,window.setTimeout(()=>l.remove(),260),e.focus({preventScroll:!0}))};l.addEventListener("keydown",e=>{"Escape"===e.key&&(e.stopPropagation(),e.preventDefault(),u())}),d.off=t.fill(l,e=>{u(),n(e)}),window.addEventListener("pointerdown",c,!0),o.append(l),l.offsetWidth,l.classList.add("show"),l.querySelector("input,button")?.focus({preventScroll:!0})}(n,e,t)}),n}(t.picker,e=>t.react(e,!n(e))):null):null;return r?t.seen.add(`${e.id}|quick`):t.seen.delete(`${e.id}|quick`),Ye("div",{class:"refs rxs"},...o,r)}(n,{me:t.me,picker:t.picker(),resolved:e.resolved,quick:m.has(n.id),bare:r,seen:S,react:(e,o)=>{m.delete(n.id),t.react(n.id,e,o),P($),T(`[data-r="${n.id}"]`)}}),H=e.resolved?"Resolved"+(D?` \xb7 ${rn(D)}`:""):e.addressed?"Addressed"+(D?` \xb7 ${rn(D)}`:""):D?rn(D):"",F=(n,o)=>{let r=[];if(o&&r.push(["Copy thread",()=>(t.copy(e.id),!1)]),(e=>e.author===t.me&&!e.deleted)(n)&&r.push(["Edit",()=>(function(e){let n=()=>{E=null,P($),T(`[data-c="${e.id}"]`)},o=$t({label:"Save",name:"Edit comment",kind:"comment",value:e.text,people:()=>t.people(),q:async(o,r)=>{await t.edit(e.id,o,r),n()},F:n});E={id:e.id,o:Ye("div",{class:"edit"},o.element)},queueMicrotask(()=>o.focus())}(n),!1)],[x===n.id?"Delete for everyone":"Delete",()=>x!==n.id?(x=n.id,k=performance.now(),!0):performance.now()-k<500||(x="",t.remove(n.id),!1)]),!r.length)return null;let i=Ye("div",{class:q===n.id?"pm":"pm in",role:"menu","data-m":n.id},...r.map(([e,t],o)=>{let r=Ye("button",{type:"button",role:"menuitem",class:"Delete for everyone"===e?"dl":"","data-k":`p${n.id}${o}`},e);return r.addEventListener("click",e=>{e.stopPropagation(),t()||(y=""),P($);let r=f.querySelectorAll(".pm button")[o];r?r.focus():f.contains(f.getRootNode().activeElement)||f.querySelector(`[data-c="${n.id}"]`)?.focus()}),r}));return i.addEventListener("keydown",e=>{let t=[...i.querySelectorAll("button")],o=t.indexOf(e.target),r={ArrowDown:o+1,ArrowUp:o-1,Home:0,End:t.length-1}[e.key];if(void 0!==r)t[(r+t.length)%t.length]?.focus();else{if("Escape"!==e.key)return;y=x="",P($),T(`[data-c="${n.id}"]`)}e.preventDefault(),e.stopPropagation()}),i},I=(n,o)=>{let r=F(n,o),i=r?A("more","More",()=>{y=y===n.id?"":n.id,x="",P($),f.querySelector(y?".pm button":`[data-c="${n.id}"]`)?.focus()}):null;return i&&(i.setAttribute("aria-expanded",String(y===n.id)),i.dataset.c=n.id,i.dataset.k=`m${n.id}`),Ye("div",{class:"hdr"},...(e=>{let t=ct(e.author,e.name),n=L.get(e.id),o=n?.o;if((!o||n.key!==t)&&(o=ht(ut(e.author,e.name)),n)){let t=n.o;C.set(e.id,t),pt(t,()=>C.get(e.id)===t&&C.delete(e.id))}o.title=g(e),M.set(e.id,{key:t,o});let r=C.get(e.id);return r?[r,o]:[o]})(n),Ye("span",{class:"who"},g(n)),Ye("span",{class:"ago",title:new Date(n.at).toLocaleString()},Pe(n.at,R)),Ye("span",{class:"acts"},(t=>{if(e.resolved||t.deleted)return null;let n=A("smile","React",()=>{let e=!m.delete(t.id);e&&m.add(t.id),P($),T(e?`[data-q="${t.id}"] button`:`[data-r="${t.id}"]`)});return n.dataset.r=t.id,n.dataset.k=`r${t.id}`,n})(n),o?e.resolved?A("reopen","Reopen",()=>{t.reopen(e.id)}):A("resolve","Resolve",()=>{t.resolve(e.id)}):null,i),y===n.id?r:null)},B=e=>E?.id===e.id?E.o:(e=>Ye("div",{class:e.deleted?"tx del":"tx",dir:"auto"},...e.deleted?["Deleted"]:[...z(e),e.edited?" (edited)":""]))(e),j=o.quote?`\u201c${Je(o.quote,80)}\u201d`:"",W=o.note&&!o.moved?o.note:o.lost?`${o.place||"No longer on the page"} \u2014 it read \u201c${Je(o.lost,120)}\u201d`:o.moved?`Moved \xb7 ${j||`it read \u201c${Je(e.anchor.snapshot,80)}\u201d`}`:j,K=r?o.rest:"column"===o.H&&H;M=new Map;let V=Ye("div",{class:"root"},I(e.root,!0),W?Ye("div",{class:"ctx"},W):null,B(e.root),"column"===o.H&&Ye("div",{class:"mr","aria-hidden":"true"},Ye("span",{},"more")),O(e.root),K?Ye("div",{class:"rest"},K):null);if(d.replaceWith(V),d=V,f.className=e.resolved?"thread resolved":"thread",f.setAttribute("data-thread",e.id),r)return void(L=M);c?.remove();let U=je.get(e.id);c=D||void 0!==U?Ye("div",{class:"rps"},...N.map(e=>Ye("div",{class:"it"},I(e,!1),B(e),O(e))),void 0===U?null:Ye("div",{class:"it ghost","data-pipeup-writing":"row"},Ye("div",{class:"hdr"},ut("",v),Ye("span",{class:"who"},v),Ye("span",{class:"ago"},"writing now")),Ye("div",{class:"tx",dir:"auto","data-pipeup-writing":"words"},U))):null,c&&l.prepend(c);let Y=e.addressed&&!e.resolved?e.addressed:null,_=Y?`${Y.text}|${Y.author}|${Y.at}`:"";if(_!==h&&(p?.remove(),p=null,h=_,Y)){let n=(e,t)=>{let n=Ye("button",{type:"button"},e);return n.addEventListener("click",e=>{e.stopPropagation(),t()}),n};p=Ye("div",{class:"adr"},Ye("small",{},`Addressed \xb7 ${g(Y)} \xb7 ${Pe(Y.at,R)}`),Y.text,Ye("div",{class:"go"},n("Resolve",()=>{t.resolve(e.id)}),n("Still not right",()=>{t.notRight(e.id)})))}p&&l.insertBefore(p,u??(a.parentNode===l?a:null)),u?.remove();let G=We.get(e.id),Z=Ke.get(e.id);if(u=void 0===G?null:Ye("div",{class:"seen"},Ye("i"),G),u&&Z){let e=Ye("button",{type:"button"},"Check again");e.addEventListener("click",e=>{e.stopPropagation(),Z()}),u.append(e)}u&&l.insertBefore(u,a.parentNode===l?a:null),L=M;let J=""!==a.querySelector("textarea").value.trim();s.hidden=!(e.resolved&&J),e.resolved&&!J?a.remove():a.parentNode!==l&&l.append(a)})(e,n),R&&!f.contains(f.getRootNode().activeElement)&&f.querySelector(`[data-k="${CSS.escape(R)}"]`)?.focus({preventScroll:!0})}return f.addEventListener("focusout",e=>{f.contains(e.relatedTarget)||setTimeout(()=>{(y||m.size)&&!f.contains(f.getRootNode().activeElement)&&(y=x="",m.clear(),P($))})}),P(e),{element:f,update:P}}function sn(e,t=!1){let n=e.ownerDocument.documentElement,o=n.getAttribute("data-pipeup-layout");if("bubbles"===o||e.querySelector("[data-pipeup-slide]"))return null;let r=e.querySelector("article, main, [role=main]")??("column"===o?e:null);if(!r)return null;if(n.hasAttribute("data-pipeup-reserve")){let e,i=n.clientWidth,a=getComputedStyle(r).maxWidth;return e=a.endsWith("px")?parseFloat(a):a.endsWith("%")?parseFloat(a)/100*i:r.getBoundingClientRect().width,"column"!==o&&i<e+320-(t?24:0)?null:{x:i-320+24,width:272}}let i=r.getBoundingClientRect().right;if(window.innerWidth-i<300&&"column"!==o)return null;let a=i+32;return{x:a,width:Math.max(220,Math.min(300,window.innerWidth-a-16))}}function dn(e,t){let n=e.resolved.get(t.id);return!n||"orphaned"===n.state&&!e.$.has(t.id)}var cn=(e,t)=>"moved"===e.resolved.get(t.id)?.state;function un(e){let t=Ye("div",{class:"col"});e.e.append(t);let n=new Map,o=null,r=new ResizeObserver(()=>c()),i=!0===window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,a=t=>dn(e,t);function l(t){let n=e.resolved.get(t.id),o=n?Vt(t.anchor,n):null;return null===o?Number.POSITIVE_INFINITY:o+window.scrollY-4}let s=new WeakMap;function d(e,t=0){let n=`translateY(${Math.round(t)}px)`;if(i&&e.style.transform){if(e.style.transform!==n||s.has(e)){if(!s.has(e)){e.classList.add("hop");let t=()=>{+getComputedStyle(e).opacity>.01?requestAnimationFrame(t):(e.style.transform=s.get(e),s.delete(e),e.classList.remove("hop"))};window.setTimeout(t,200)}s.set(e,n)}}else e.style.transform=n}function c(){let r=[],i=[];for(let{o:e}of n.values()){let t=e.querySelector(".root>.tx");t&&(t.style.setProperty("--full",`${t.scrollHeight}px`),e.classList.toggle("long",t.scrollHeight>88))}for(let[t,o]of n){let n=l(o.thread);if(Number.isFinite(n))o.placed=n;else if(e.$.has(t)){if(null===o.placed){o.o.classList.add("wait");continue}n=o.placed}Number.isFinite(n)?r.push({id:t,T:n,height:o.o.offsetHeight}):i.push({id:t,height:o.o.offsetHeight})}let a=e.state.t,s=a?Vt(a.anchor,a.resolved):null;o&&null!==s&&r.push({id:"draft",T:s+window.scrollY-4,height:o.o.offsetHeight});let c=o?"draft":e.state.i,u=r.find(e=>e.id===c),p=t.getBoundingClientRect().right>window.innerWidth-44?44:0;u&&(p||o)&&(u.T=Math.max(window.scrollY+8,Math.min(u.T,window.scrollY+window.innerHeight-p-10-u.height)));let h=function(e,t,n=10){let o=[...e].sort((e,t)=>e.T-t.T),r=new Array(o.length).fill(0),i=o.findIndex(e=>e.id===t),a=e=>o[e];if(i<0)o.forEach((e,t)=>{r[t]=0===t?e.T:Math.max(e.T,(r[t-1]??0)+a(t-1).height+n)});else{r[i]=a(i).T;for(let e=i+1;e<o.length;e++)r[e]=Math.max(a(e).T,(r[e-1]??0)+a(e-1).height+n);for(let e=i-1;e>=0;e--)r[e]=Math.min(a(e).T,(r[e+1]??0)-a(e).height-n)}return new Map(o.map((e,t)=>[e.id,r[t]??0]))}(r,c),f=Math.max(0,...r.map(e=>(h.get(e.id)??0)+e.height))+24;for(let e of i)h.set(e.id,f),f+=e.height+10;for(let[e,t]of[...[...n].map(([e,t])=>[e,t.o]),["draft",o?.o]])if(t){if(t.classList.contains("wait")){if(!h.has(e)&&t!==o?.o)continue;t.style.transition="none",t.style.transform=`translateY(${Math.round(h.get(e)??0)}px)`,t.offsetWidth,t.style.transition="",t.classList.remove("wait");continue}d(t,h.get(e))}}function u(t,n){t.thread=n,t.note=Ue(n.id),t.lost=a(n),t.moved=cn(e,n),t.view.update(n,{lost:t.lost?n.anchor.snapshot:null,moved:t.moved})}function p(n){let o=a(n),i=ln(n,e.D,{H:"column",lost:o?n.anchor.snapshot:null,moved:cn(e,n)}),l=Ye("div",{class:"th wait","data-thread":n.id},Ye("button",{class:"opn sr",type:"button","data-thread":n.id}),i.element);return l.addEventListener("mouseenter",()=>e.S(n.id)),l.addEventListener("mouseleave",()=>e.S(null)),l.addEventListener("click",()=>e.open(n.id)),t.append(l),r.observe(l),{o:l,thread:n,lost:o,moved:cn(e,n),placed:null,view:i}}function h(e){r.unobserve(e),e.classList.add("out"),window.setTimeout(()=>e.remove(),220)}return{m:function(i){_e(t,e.state.u);let l=new Set,s=null!==e.state.i||null!==e.state.t;for(let t of i){if(!e._(t))continue;let o=n.get(t.id);if(!o&&e.state.t?.sending)continue;l.add(t.id),o?(o.thread!==t||o.lost!==a(t)||o.moved!==cn(e,t)||o.note!==Ue(t.id))&&u(o,t):(o=p(t),n.set(t.id,o));let r=o.o,i=e.state.i===t.id;r.classList.toggle("on",i);let d=r.firstElementChild,c=an(t).length;d.setAttribute("aria-label",`Open thread: ${Je(t.root.text,60)}, ${rn(c)}`),d.setAttribute("aria-expanded",String(i)),_e(d,i);let h=r.querySelector(".more");h&&_e(h,!i),r.classList.toggle("dim",s&&!i),r.classList.toggle("hot",e.state.S===t.id&&!i),r.classList.toggle("resolved",t.resolved),r.classList.toggle("lost",o.lost)}for(let[e,t]of n)l.has(e)||(n.delete(e),h(t.o));(function(){let n=e.state.u?null:e.state.t;if(o&&o.of!==n&&(h(o.o),o=null,n||e.I(null)),!n)return;let i=!o;if(o)o.s.de(n.label);else{let i=Bt(e,n),a=Ye("div",{class:"th on wait"},i.element);t.append(a),r.observe(a),o={o:a,s:i,of:n}}o.s.J(e.state.p&&!n.anchor.quote&&!n.anchor.point),i&&o.s.focus()})(),Ge(t,i.filter(e=>l.has(e.id)).sort(tn(e)).map(e=>n.get(e.id).o),o?.o??null)&&t.offsetWidth,c()},O:function(){let n=sn(e.root,!0);n&&(t.style.width=`${n.width}px`,t.style.transform=`translate(${n.x}px, ${-window.scrollY}px)`)},destroy(){r.disconnect(),e.I(null),t.remove()}}}var pn=22;function hn(e,t){let n=new Map,o=Ye("div",{class:"tip",role:"tooltip"}),r=Ye("div",{class:"mark"}),i=Ye("div",{class:"pop",role:"dialog","aria-label":"Comment thread"});o.inert=i.inert=!0,e.e.append(r,o,i);let a,l=Ye("div",{class:"bub pin ghost","aria-hidden":"true"}),s=[],d=null,c=null,u=!1,p=null,h=!0===window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,f=0,m=null,v=null,w=null,y=0,b=e=>s.find(t=>t.id===e)??null,x=()=>t.pe||e.state.u,k=!1,E=t=>{let n=e.resolved.get(t.id);return n?Ut(t.anchor,n):null},S=()=>{let t=function(e){let t=window.innerWidth;return{width:e&&!Gt()?t-320:t,height:window.innerHeight}}(e.state.u),n=e.state.u?null:e.e.querySelector(".launch .mode")?.getBoundingClientRect();return n?.width&&(t.keep={left:e.state.p&&Zt()?0:n.left,top:n.top}),t};function $(e,t,n){let{left:o,top:r}=function(e,t,n,o=12){if(!e.below&&e.x+14+t.width>n.width-o)return Xt(e.s,t,n,o,0);let r=Math.max(o,e.below?Math.min(e.x,n.width-t.width-o):e.x+14),i=Jt(r,t.width,n,o),a=e.below?e.y+8:e.y-12;return e.below&&a+t.height>i&&(a=e.y-t.height-40),{left:r,top:Math.max(o,Math.min(a,i-t.height))}}(t,{width:e.offsetWidth||n,height:e.offsetHeight},S());e.style.left=`${o}px`,e.style.top=`${r}px`}function L(t){let n=t&&x()&&e.state.i!==t?b(t):null,r=n?E(n):null;if(!n||!r)return w=null,o.classList.remove("show"),void _e(o,!0);if(w!==n.id){let e=an(n).length;o.replaceChildren(Ye("div",{class:"tx clamp",dir:"auto"},...n.root.deleted?["Deleted"]:nt(n.root.text)),Ye("div",{class:"who"},`${g(n.root)}${e?` \xb7 ${e} ${1===e?"reply":"replies"}`:""}`)),w=n.id}$(o,r,260),o.classList.contains("show")||o.offsetWidth,o.classList.add("show"),o.inert=!1}function M(t){m=t,L(t),e.S(t)}function C(e){window.clearTimeout(y),null===e?y=window.setTimeout(()=>M(null),x()?400:0):M(e)}function A(t){let o=n.get(t.id);if(o)return o;let i=Ye("button",{class:"bub",type:"button","data-thread":t.id});return i.addEventListener("mouseenter",()=>C(t.id)),i.addEventListener("mouseleave",()=>C(null)),i.addEventListener("click",n=>{n.stopPropagation(),L(null),e.open(t.id)}),e.e.insertBefore(i,r),n.set(t.id,i),i}o.addEventListener("mouseenter",()=>window.clearTimeout(y)),o.addEventListener("mouseleave",()=>C(null)),o.addEventListener("click",t=>{t.stopPropagation();let n=w;n&&(window.clearTimeout(y),M(null),e.open(n))});let T=!1;function P(){let t=e.state.t,n=p&&t&&!t.anchor.quote&&!t.anchor.point?t.resolved.element:null;if(n){let{left:e,top:t,above:o}=Xt(n.getBoundingClientRect(),{width:i.offsetWidth||_t(),height:i.offsetHeight},S(),12,Zt()?60:44),r=null!==p?.above&&p?.above!==o;if(p&&(p.above=o),r&&R())return;return i.style.left=`${e}px`,void(i.style.top=`${t}px`)}let o=p&&t?Ut(t.anchor,t.resolved):d?E(d):null;o&&$(i,o,_t())}let q=t=>e.state.p&&!t.anchor.quote&&!t.anchor.point;function R(e=()=>{}){return window.clearTimeout(f),h?(i.classList.remove("show"),f=window.setTimeout(()=>{e(),P(),i.classList.add("show")},220),!0):(e(),i.classList.add("glide"),f=window.setTimeout(()=>i.classList.remove("glide"),450),!1)}let N=e=>Math.min(Math.max(e,20),window.innerWidth-30),D=t=>{if(e.M(t)){let e=t.composedPath()[0];return null!==v&&!(e instanceof Element&&e.closest(".tip,.bub"))&&C(null),void(v=null)}let n=e.ue(t.clientX,t.clientY)?.id??null;n!==v&&(v=n,C(n))},z=t=>{if(e.M(t))return;let n=window.getSelection();if(n&&!n.isCollapsed||(e.state.p&&!e.state.paused?t.altKey:t.target instanceof Element&&t.target.closest(jt)))return;let o=e.ue(t.clientX,t.clientY);o&&(e.fe(t),L(null),e.open(o.id))};return window.addEventListener("pointermove",D,{capture:!0,passive:!0}),window.addEventListener("click",z,!0),{m:function(o){s=o;let l=new Set;for(let t of o){if(!e._(t)||t.anchor.quote)continue;let n=e.resolved.get(t.id);if(!n||"orphaned"===n.state)continue;l.add(t.id);let o=A(t);o.classList.toggle("done",t.resolved),o.classList.toggle("on",e.state.i===t.id),o.classList.toggle("pin",void 0!==t.anchor.point);let r=`Comment on ${$e(n.element)}: ${Je(t.root.text,60)}`;o.getAttribute("aria-label")!==r&&o.setAttribute("aria-label",r)}Ge(e.e,o.filter(e=>l.has(e.id)).sort(tn(e)).map(e=>n.get(e.id)),r);for(let[e,t]of n)l.has(e)||(t.classList.remove("in"),n.delete(e),window.setTimeout(()=>t.remove(),300));L(m),k!==e.state.u&&i.classList.contains("show")&&!h&&R(),k=e.state.u;let g=t.pe&&!e.state.u?e.state.t:null;if(g){let t=g.anchor.point??g.resolved.element;p?.of!==g?(window.clearTimeout(f),i.classList.remove("glide"),p={s:Bt(e,g),of:g,at:t,above:null},p.s.J(q(g)),i.replaceChildren(p.s.element),i.inert=!1,p.s.focus(),d=null,c=null,P(),i.classList.add("show")):p&&(p.at!==t&&(p.at=t,p.above=null,R(()=>p?.s.de(g.label))),p.s.J(q(g)));let n=!e.f.w(g.anchor.view);return void(n!==T&&(T=n,i.classList.toggle("show",!n),i.inert=n,n||P()))}p&&(window.clearTimeout(f),i.classList.remove("glide"),p=null,T=!1,e.I(null));let v=x()&&!e.state.u&&e.state.i?b(e.state.i):null;if(!v||!e._(v))return d=null,c=null,i.classList.remove("show"),void _e(i,!0);let w={H:"popover",quote:v.anchor.quote?.exact??null,moved:cn(e,v)};d&&c&&d.id===v.id?(d!==v||a!==Ue(v.id)||u!==w.moved)&&(c.update(v,w),d=v,a=Ue(v.id),u=w.moved):(c=ln(v,e.D,w),i.replaceChildren(c.element),d=v,a=Ue(v.id),u=w.moved,P(),i.classList.add("show"),i.inert=!1)},O:function(){let t=[],o=x()?null:sn(e.root,!0);for(let[r,i]of n){let n=b(r),a=e.resolved.get(r),l=n&&a?Wt(n.anchor,a):null;if(!l||l.y<-40||l.y>window.innerHeight+40){i.style.visibility="hidden";continue}let s=l.x=N(l.x),d=Math.max(s,(o?o.x:window.innerWidth)-30),c=pn;for(;t.some(e=>Math.abs(e.x-l.x)<pn&&Math.abs(e.y-l.y)<pn);)l.x+=c,l.x>d&&(c=-22,l.x=s-pn),l.x<20&&(c=pn,l.x=s,l.y+=pn);t.push(l),i.style.visibility="",i.style.left=`${l.x}px`,i.style.top=`${l.y}px`,i.classList.contains("in")||(i.offsetWidth,i.classList.add("in"))}let a=e.state.t,s=a?.anchor.point&&e.f.w(a.anchor.view)?Wt(a.anchor,a.resolved):null;s?(l.style.left=`${N(s.x)}px`,l.style.top=`${s.y}px`,l.classList.contains("in")||(e.e.insertBefore(l,r),l.offsetWidth,l.classList.add("in"))):l.classList.contains("in")&&(l.classList.remove("in"),window.setTimeout(()=>l.classList.contains("in")||l.remove(),300)),i.classList.contains("show")&&P();let c=function(){if(!x())return null;let t=e.state.t;return t?t.anchor.quote||t.anchor.point||e.state.p?null:t.resolved.element:!d||d.anchor.quote||d.anchor.point?null:e.resolved.get(d.id)?.element??null}();r.classList.toggle("show",null!==c),c&&Xe(r,c.getBoundingClientRect(),4)},destroy(){window.clearTimeout(y),window.clearTimeout(f),window.removeEventListener("pointermove",D,!0),window.removeEventListener("click",z,!0),e.I(null);for(let e of n.values())e.remove();l.remove(),o.remove(),r.remove(),i.remove()}}}var fn={display:"block",position:"static",clips:!1,off:!1},mn="button link img figure region list listitem tab tabpanel article navigation complementary banner contentinfo form search group dialog menu menuitem checkbox switch radio slider textbox combobox option row cell heading table".split(" ").map(e=>`[role=${e}]`),gn="[data-pipeup-ignore],.reveal>:is(.controls,.progress,.slide-number)",vn=["button,a,input,select,textarea,label,summary,details,img,svg,canvas,video,picture,figure,figcaption,table,th,td","li,ul,ol,dl,dt,dd,p,h1,h2,h3,h4,h5,h6,blockquote,pre","section,article,aside,nav,header,footer,main,form,fieldset",...mn].join(","),wn="a,button,label,summary,[role=button],[role=link],[role=tab],[role=option],[role=menuitem]",yn=`${wn},input,select,textarea,img,svg,canvas,video,picture,[role=img]`,bn=(e,t)=>Math.abs(e.left-t.left)<=2&&Math.abs(e.top-t.top)<=2&&Math.abs(e.width-t.width)<=2&&Math.abs(e.height-t.height)<=2;function xn(e,t){let n=t.s(e);if(n.width<2||n.height<2)return!1;if(e.hasAttribute("data-pipeup-id"))return!0;let o=t.Q();return n.width*n.height<=.6*o.width*o.height&&(e.matches(vn)||t.ze(e)||e.childElementCount>1&&!e.parentElement?.closest(wn)&&t.We(e))}function kn(e,t,n){if(e===t||!t.contains(e)||e.closest(gn))return null;let o=null;for(let r=e;r&&r!==t&&!o;r=r.parentElement)xn(r,n)&&(o=r);if(!o||o.hasAttribute("data-pipeup-id"))return o;let r=n.s(o);for(let e=o.parentElement;e&&e!==t&&bn(n.s(e),r);e=e.parentElement)if(e.hasAttribute("data-pipeup-id"))return e;return o}function En(e,t,n){let o=n.s(e);for(let r=e.parentElement;r&&r!==t;){let e=kn(r,t,n);if(!e)return null;if(!bn(n.s(e),o))return e;r=e.parentElement}return null}var Sn=(e,t)=>e.left<t.left+t.width&&t.left<e.left+e.width&&e.top<t.top+t.height&&t.top<e.top+e.height,$n=(e,t)=>{let n=Math.max(e.left,t.left),o=Math.max(e.top,t.top);return{left:n,top:o,width:Math.max(0,Math.min(e.left+e.width,t.left+t.width)-n),height:Math.max(0,Math.min(e.top+e.height,t.top+t.height)-o)}};function Ln(e,t,n=()=>!0){let o=[],r=(e,i,a,l,s,d)=>{for(let c of e.children){if(c.matches(gn)||"true"===c.getAttribute("aria-hidden")||!n(c))continue;let e=t.flow?.(c)??fn,u=c.offsetParent,p="fixed"===e.position||"absolute"===e.position&&!!l&&!(u&&l.contains(u)),h=p?null:a,f=t.s(c),m=f.width>0&&f.height>0;if(h&&m&&!Sn(f,h))continue;let g=c.matches(wn),v=(e.display.startsWith("inline")||d)&&!c.matches(yn)&&("inline"===e.display||f.height<=48),w=f.width<=24&&f.height<=24,y=i;(c.hasAttribute("data-pipeup-id")||!s&&!e.off&&!v&&(!w||g))&&xn(c,t)&&(i&&bn(t.s(i.o),f)?(c.hasAttribute("data-pipeup-id")||!i.o.hasAttribute("data-pipeup-id"))&&(i.o=c):o.push(y={o:c,B:i,C:0}));let b=e.clips&&m;r(c,y,b?h?$n(h,f):f:h,b?c:p?null:l,s||g,/^inline-(flex|grid)$/.test(e.display)||d&&/(flex|grid)$/.test(e.display))}};r(e,null,null,null,!1,!1);for(let e=o.length-1;e>=0;e--){let t=o[e];t.B&&(t.B.C=Math.max(t.B.C,t.C+1))}return o}var Mn=(e,t)=>e.filter(e=>e.C<=t&&(!e.B||e.B.C>t)),Cn="a,button,summary,[role=button],[role=link],[role=switch],[role=tab],[role=checkbox],input[type=checkbox],input[type=radio],input[type=submit],input[type=button],input[type=reset]",An=`${Cn},input,select,textarea,[contenteditable]:not([contenteditable=false]),[tabindex]:not([tabindex="-1"])`,Tn=["click","dblclick","auxclick","submit","contextmenu","dragstart"],Pn=[...["over","out","enter","leave","down","up"].flatMap(e=>[`pointer${e}`,`mouse${e}`]),"mousemove","touchstart","touchmove","touchend","touchcancel"],qn=["pointerup","pointercancel"],Rn="Tab moves between blocks \xb7 \u2191 \u2193 change level \xb7 Enter comments \xb7 Hold Space to use the page \xb7 Esc to finish \xb7 F7 selects text";var Nn=`${gn},input,textarea,select,[contenteditable]:not([contenteditable=false])`;function Dn(e){let t=Ye("button",{type:"button","aria-label":"Comment",title:"Comment"},it("comment",17)),n=Ye("div",{class:"selbar"},t);n.inert=!0,e.e.append(n);let o=null,r=0,i=!1,a=t=>{let n=t&&(t.nodeType===Node.ELEMENT_NODE?t:t.parentElement);return!!n&&e.root.contains(n)&&!n.closest(Nn)};function l(){if(!o)return;let t=o.cloneRange();t.selectNodeContents(ue(o.commonAncestorContainer,e.root));let r=o.getBoundingClientRect(),{left:i,top:a}=function(e,t,n,o,r,i=!1){let a=n+8;if(i){let t=Qt(e,o,r),n=e.top+e.height+20;return{left:t.left,top:n+o.height<=r.height-8?n:t.top}}return a+o.width>r.width-8?Qt(e,o,r):{left:a,top:t.top+t.height/2-o.height/2}}(r,[...o.getClientRects()].filter(e=>e.width).at(-1)??r,t.getBoundingClientRect().right,{width:n.offsetWidth||36,height:n.offsetHeight||34},{width:window.innerWidth,height:window.innerHeight},Zt());n.style.left=`${i}px`,n.style.top=`${a}px`}function s(){o=null,n.inert=!0,n.classList.remove("show")}function d(t=!1){let r=Ze();e.state.p&&r&&a(r.anchorNode)&&a(r.focusNode)?(!o&&!t&&e.L("Enter comments on the selected words"),o=r.getRangeAt(0).cloneRange(),l(),n.inert=!1,n.classList.add("show")):s()}t.addEventListener("mousedown",e=>e.preventDefault()),t.addEventListener("click",t=>{if(t.stopPropagation(),e.state.t&&!e.E())return e.te();let n,r=o;if(!r)return;try{n=pe(r,e.root,e.f.view(r.commonAncestorContainer))}catch(t){return e.ee(t),void s()}let i=Je(r.toString().replace(/\s+/g," ").trim(),60);window.getSelection()?.removeAllRanges(),s(),e.Ze({anchor:n,label:`\u201c${i}\u201d`,ranges:[r],resolved:{state:"attached",element:null,range:r}})});let c=()=>{window.clearTimeout(r),r=window.setTimeout(()=>i||d(),250),o&&(Ze()||s())};document.addEventListener("selectionchange",c);let u=t=>{"keyup"!==t.type&&(i="mousedown"===t.type),!i&&!e.M(t)&&window.setTimeout(()=>d("mouseup"===t.type),0)};window.addEventListener("mousedown",u,!0),window.addEventListener("mouseup",u,!0),window.addEventListener("keyup",u,!0);let p=n=>{"Enter"!==n.key||!o||e.M(n)||n.target instanceof Element&&n.target.closest(`${Nn},${Cn}`)||(n.preventDefault(),n.stopPropagation(),t.click())};return window.addEventListener("keydown",p,!0),{m(){!e.state.p&&o&&s()},O(){o&&l()},destroy(){window.removeEventListener("mousedown",u,!0),window.removeEventListener("mouseup",u,!0),window.removeEventListener("keyup",u,!0),window.removeEventListener("keydown",p,!0),window.clearTimeout(r),document.removeEventListener("selectionchange",c),n.remove()}}}async function zn(e,t){try{return void await navigator.clipboard.writeText(e)}catch{}let n=t.getRootNode().activeElement??document.activeElement,o=document.createElement("textarea");o.value=e,o.setAttribute("readonly",""),o.style.cssText="position:fixed;opacity:0;pointer-events:none",t.append(o),o.select();let r=document.execCommand("copy");if(o.remove(),n instanceof HTMLElement&&n.focus({preventScroll:!0}),!r)throw new Error("pipeup: your browser blocked copying")}var On="Hidden on the page",Hn=["auto","light","dark"];function Fn(e){let t=[Ye("span",{class:"n"}),Ye("span",{class:"n"})],n=it("comment",22,1.4);n.lastElementChild.setAttribute("stroke-width","1.6");let o=Ye("span",{class:"cnt"},it("bubble",28,1.4),it("wide",28,1.4),...t),r=Ye("button",{class:"mode",type:"button","aria-label":"Comment","aria-keyshortcuts":Ft,"aria-haspopup":"menu","aria-expanded":"false"},Ye("span",{class:"plus"},n),o,Ye("span",{class:"dot"})),i=document.createTextNode(""),a=Ye("span",{class:"ttip","aria-hidden":"true"},Ye("span",{},i,Ye("small",{},Ot))),l=Ye("div",{class:"launch"},r,a),s=Ye("div",{class:"menu",role:"menu","aria-label":"Comments"}),d=Ye("div",{class:"list",role:"list","aria-label":"Comments"}),c=Ye("button",{class:"ib",type:"button","aria-label":"Close"},it("close")),u=(e,t,n,o)=>{let r=Ye("button",{class:"tg",type:"button","aria-label":e,"aria-description":t,"data-tip":t,"aria-pressed":"false"},n,e);return r.addEventListener("click",e=>{e.stopPropagation(),o()}),r},p=u("For you","Only comments that mention you",it("at",16,1.8),()=>e.l.toggleMine()),h=u("Resolved","Show resolved comments too",it("resolve",22,1.7),()=>e.l.Je()),f=Ye("div",{class:"lns"}),v=new Map,w=Ye("span",{class:"ma"}),y=Ye("span",{class:"lb"}),b=Ye("button",{class:"fs",type:"button",role:"switch","aria-checked":"false","aria-keyshortcuts":Ft},"Comment",Ye("small",{class:"ks","aria-hidden":"true"},Ot),Ye("span",{class:"sw","aria-hidden":"true"}));b.addEventListener("click",t=>{t.stopPropagation(),e.Te(!e.state.p,!e.state.p&&0===t.detail)});let x=Ye("button",{class:"ib",type:"button","aria-label":"More","aria-haspopup":"menu","aria-expanded":"false"},it("more",15,3)),k="",E=Ye("div",{class:"all",role:"dialog","aria-label":"All comments"},Ye("div",{class:"hh",role:"heading","aria-level":"2"},"All comments"),Ye("div",{class:"hd"},p,h,Ye("span",{class:"sp"}),c),f,d,Ye("div",{class:"pf"},w,y,b,x)),S=document.createElementNS("http://www.w3.org/2000/svg","svg");S.setAttribute("class","cx"),S.setAttribute("aria-hidden","true");let $=document.createElementNS("http://www.w3.org/2000/svg","path"),L=document.createElementNS("http://www.w3.org/2000/svg","circle");L.setAttribute("r","4"),S.append($,L),s.inert=E.inert=!0,e.e.append(s,l,S,E);let M=!1,C=null,A=0,T=[],P=0,q=null,R=null,N=null,D=!0===window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,z=()=>{},O=t=>{M=e.state.l=t,t&&e.addons.flush(),window.clearTimeout(A),A=0,t||C?.(!0),t?s.classList.toggle("inp",e.state.u):z(),s.classList.toggle("show",t),_e(s,!t),r.setAttribute("aria-expanded",String(t)),x.setAttribute("aria-expanded",String(t))},H=(t,n=!1)=>{if(e.state.u===t)return;e.keepReplies();let o=t?e.state.i:null;o&&(e.state.i=null),e.state.u=t,e.m(),o&&T.some(e=>e.id===o)?ce(o,!0):t&&e.state.t?e.focusDraft():t?(F(d)[0]??c).focus({preventScroll:!0}):n&&r.focus({preventScroll:!0})},F=(e=s)=>[...e.querySelectorAll(".mi")].filter(e=>e.offsetParent&&!e.closest("[inert]")),I=()=>s.getRootNode().activeElement,B=()=>{O(!1),r.focus({preventScroll:!0})},j=e=>{let t=F(e.currentTarget);if(0===t.length)return;let n=I(),o=t.indexOf(n),r=n=>{e.preventDefault(),t[(n+t.length)%t.length]?.focus({preventScroll:!0})};"ArrowDown"===e.key?r(o+1):"ArrowUp"===e.key?r(o<0?t.length-1:o-1):"Home"===e.key?r(0):"End"===e.key&&r(t.length-1)};s.addEventListener("keydown",j),d.addEventListener("keydown",j),c.addEventListener("click",e=>{e.stopPropagation(),H(!1,!0)});let W=t=>dn(e,t),K=t=>cn(e,t),V=t=>T.filter(n=>!n.resolved&&(void 0===t||e.W(n)===t)).length,U=t=>{let n=t.anchor.view?.slide,o=e.f.w(t.anchor.view)?"":Me(t.anchor.view);return n&&null!==e.f.slide()?`On slide ${n}`:o?`In ${o}`:On},Y=(e,t,n=!1)=>{let o=new Set(t),r=new Set(e.childNodes),i=new Map,a=new Set(t.map(_));for(let e of r){if(o.has(e))continue;let t=_(e);t&&a.has(t)&&i.set(t,e.offsetHeight),n&&Z&&e instanceof HTMLElement&&!i.has(t)?J(e):e.remove()}let l=e.firstChild;for(let n of t){for(;l&&l!==n&&G.has(l);)l=l.nextSibling;l===n?l=n.nextSibling:e.insertBefore(n,l)}if(n&&Z)for(let e of t)e instanceof HTMLElement&&(r.has(e)?G.delete(e)&&X(e,e.offsetHeight):X(e,i.get(_(e))??0))},_=e=>e instanceof HTMLElement?e.firstElementChild?.dataset.thread:void 0,G=new WeakSet,Z=!1,J=e=>{if(!G.has(e)){if(e.classList.contains("out"))return e.remove();G.add(e),e.style.height=`${e.offsetHeight}px`,e.offsetHeight,e.classList.add("out"),D||(e.style.height="0"),setTimeout(()=>G.delete(e)&&e.remove(),340)}},X=(e,t)=>{let n=e.style;n.transition="none",e.classList.remove("out"),n.height=n.maxHeight=n.overflow="";let o=e.offsetHeight,r=o>t?"maxHeight":"height";(D||!t)&&e.classList.add("out"),D||(n.overflow="hidden",n[r]=`${t}px`),e.offsetHeight,n.transition="",e.classList.remove("out"),!D&&(n[r]=`${o>t?o+40:o}px`,setTimeout(()=>n[r]=n.overflow="",360))},Q=new Map,ee=(e,t,n="",o=e)=>{let[r,i,a]=Q.get(o)??[];return(!r||!i||!a)&&Q.set(o,[r=Ye("div",{role:"listitem"}),i=Ye("div",{class:"sec","aria-hidden":"true"}),a=Ye("div",{role:"list"})]),a.setAttribute("aria-label",n?`${e} \xb7 ${n}`:e),i.replaceChildren(e,n&&Ye("b",{},n)),Y(r,[i,a]),Y(a,t,!0),r},te=Ye("div",{class:"sec",role:"listitem"});function ne(t,n){let o=e.f.slide(),r=new Map;for(let n of t){let t=n.thread,i=null!==o?t.anchor.view?.slide??o:e.W(t)?e.f.w(t.anchor.view)?"":Me(t.anchor.view):null;r.set(i,[...r.get(i)??[],n])}if(null===o){let e=r.get(null)??[];return r.delete(null),[...e.flatMap(n),...[...r].map(([e,t])=>ee(e||On,t.flatMap(n)))]}return[...r].sort(([e],[t])=>Number(e)-Number(t)||0).map(([e,t])=>ee(`Slide ${e} \xb7 ${t.filter(e=>!e.thread.resolved).length} open`,t.flatMap(n),e===o?"This slide":"",`slide:${e}`))}let oe=null,re=new Map,ie=new Set,ae={...e.D,get me(){return e.D.me},resolve:async t=>{let n=re.get(t)?.card;n&&!e.state.R&&!D&&(ie.add(t),n.style.height=`${n.offsetHeight}px`,n.offsetHeight,n.classList.add("out"),n.style.height="0",await new Promise(e=>setTimeout(e,340))),await e.D.resolve(t),ie.delete(t),n?.style.removeProperty("height"),e.m()}};function le(){let t=I(),n=t?.dataset.thread,o=null!==R&&R.element.contains(t),r=[...re.values()].find(e=>e.view.element.contains(t)),i=()=>[...r.view.element.querySelectorAll("button,textarea")],a=r?i().indexOf(t):-1,l=r?F(d).indexOf(r.card.firstChild):-1,s=e.l.all().filter(t=>!t.thread.resolved||e.state.R||t.thread.id===q).filter(t=>!e.state.mine||((e,t)=>[e.root,...e.root.replies].some(e=>e.author!==t&&!e.deleted&&yt(e,xt(t))))(t.thread,e.doc.me));h.setAttribute("aria-pressed",String(e.state.R)),p.setAttribute("aria-pressed",String(e.state.mine));let c=e.l.name();if(y.textContent=c||m(e.doc.me),ct(e.doc.me,c)!==k){k=ct(e.doc.me,c);let t=ut(e.doc.me,c);t.classList.add("in"),w.replaceChildren(t)}b.setAttribute("aria-checked",String(e.state.p));let u=e.state.t;N&&N.of!==u&&(N=null,u||e.I(null));let f=u&&!N;if(u&&!N){q=R=null;let t=Bt(e,u);N={of:u,s:t,card:Ye("div",{class:"cd open new",role:"listitem"},t.element)}}N&&(N.s.de(u.label),N.s.J(!1)),oe&&oe.id!==q&&(oe=null);let v=u&&(u.resolved.range?.startContainer??u.resolved.element),x=v?s.find(t=>{let n=en(e,t.thread);return n&&4&v.compareDocumentPosition(n)})?.thread.id??null:null,E=e=>{let t,n=e.thread,o=n.id===q,r=an(n).length,i=[r?rn(r):"",...n.root.reactions.map(e=>`${e.emoji} ${e.by.length}`)].filter(Boolean).join(" \xb7 "),a=W(n)?`\u201c${Je(n.anchor.snapshot,80)}\u201d`:n.anchor.quote?`\u201c${Je(n.anchor.quote.exact,80)}\u201d`:e.location.where,l=Ye("button",{class:"mi",type:"button","aria-expanded":String(o),"data-thread":n.id},Ye("span",{class:"sr"},[g(n.root),Pe(n.root.at,Date.now()),K(n)&&"Moved",a,n.root.text,i].filter(Boolean).join(", ")));if(l.addEventListener("click",e=>{e.stopPropagation(),ce(n.id)}),o&&R){if(R.update(n,se(n,a)),!oe){let e=Ye("div",{class:"xr",role:"region","aria-label":"Comment thread"},R.element);e.addEventListener("click",e=>{let t=e.target;t.closest(".root>.hdr")&&!t.closest("button")&&ue(!0)}),oe={id:n.id,card:Ye("div",{role:"listitem"}),xr:e}}t=oe.card,t.className="cd open"+(n.resolved?" done":""),Y(t,[l,oe.xr])}else{let e={H:"card",note:a,rest:i,quote:n.anchor.quote?.exact,moved:K(n)},o=re.get(n.id);o?o.view.update(n,e):re.set(n.id,o={card:Ye("div",{role:"listitem"}),view:ln(n,ae,e)}),t=o.card,t.className=`cd${n.resolved?" done":""}${ie.has(n.id)?" out":""}`,Y(t,[l,o.view.element])}return N&&n.id===x?[N.card,t]:[t]},S=s.filter(e=>W(e.thread));te.textContent=e.state.mine?"No comments mention you":"No open comments",Y(d,[...s.length||N?[]:[te],...ne(s.filter(e=>!W(e.thread)),E),...N&&null===x?[N.card]:[],...S.length?[ee("No longer on the page",S.flatMap(E))]:[]],!0),Z=!0;for(let e of re.keys())s.some(t=>t.thread.id===e)||re.delete(e);let $=I();f?N.s.focus():N?.card.contains(t)&&!N.card.contains($)?N.s.le()():o&&!R.element.contains($)?R.element.querySelector("textarea")?.focus({preventScroll:!0}):r&&$!==t?(r.card.isConnected?i()[a]:F(d)[Math.min(l,F(d).length-1)])?.focus({preventScroll:!0}):n&&$!==t&&F(d).find(e=>e.dataset.thread===n)?.focus({preventScroll:!0})}function se(t,n){let o=!W(t)&&e.W(t);return{H:"popover",quote:t.anchor.quote?.exact??null,lost:W(t)||o?t.anchor.snapshot:null,place:o?U(t):null,moved:K(t),note:!Gt()||W(t)||o||t.anchor.quote?null:n}}let de="";function ce(t,n=!1){if(q===t)return ue(!0);let o=T.find(e=>e.id===t);if(o){if(e.keepReplies(),q=de=t,R=ln(o,{...e.D,close:()=>ue(!0)},se(o)),e.seen(o),le(),e.putReply(t),Zt()||R.element.querySelector("textarea")?.focus({preventScroll:!0}),n&&d.querySelector(".mi.open")?.scrollIntoView({block:"nearest"}),!e.W(o))return pe(o,!n);e.state.t&&!e.E()||e.f.Z(o.anchor.view??{}).then(()=>{e.Ae();let n=T.find(e=>e.id===t);n&&de===t&&q===t&&pe(n)})}}function ue(t=!1){if(!q)return;let n=q;e.keepReplies(),q=R=null,e.S(null),le(),t&&F(d).find(e=>e.dataset.thread===n)?.focus({preventScroll:!0})}function pe(t,n=!0){let o=e.resolved.get(t.id),r=o&&!W(t)?o.element??o.range?.startContainer.parentElement??null:null;n&&r?.scrollIntoView({block:"center",inline:"nearest",behavior:D?"auto":"smooth"}),r&&e.S(t.id)}function he(t,n){let o=n?n.resolved:e.resolved.get(t.id),r=o?.element??o?.range?.startContainer.parentElement;if(!o||Gt()||t&&(W(t)||e.W(t))||!1===r?.checkVisibility?.({visibilityProperty:!0}))return null;let i=t?e.e.querySelector(`.bub[data-thread="${t.id}"]`)?.getBoundingClientRect():void 0,a=o.range?Kt(o).at(-1):void 0,l=r?.closest("p,li,h1,h2,h3,h4,h5,h6,blockquote,td,th,figcaption,div")?.getBoundingClientRect().right,s=o.element?.getBoundingClientRect(),d=Ut(n?n.anchor:t.anchor,o),c=i?.width?{x:i.right+1,y:i.top+i.height/2,from:"right",bubble:!0}:a?{x:Math.max(a.right,l??0)+4,y:(a.top+a.bottom)/2,from:"right"}:s?{x:s.left+s.width/2,y:s.top,from:"top"}:d&&{x:d.x,y:d.y,from:"right"};return c&&c.x>=0&&c.x<=window.innerWidth-320&&c.y>=0&&c.y<=window.innerHeight?c:null}function fe(e,t,n=!1,...o){let r=Ye("button",{class:"mi",type:"button",role:n?"menuitemcheckbox":"menuitem"},e,Ye("span",{class:"lb"}),...o,n&&Ye("span",{class:"sw","aria-hidden":"true"}),Ye("span",{class:"tt","aria-hidden":"true"}));return r.addEventListener("click",e=>{e.stopPropagation(),t(e)}),r}let me=(e,t,n,o)=>{let r=e.querySelector(".lb");r.textContent!==t&&(r.textContent=t),e.querySelector(".tt").textContent=n,e.setAttribute("aria-description",n),void 0!==o&&e.setAttribute("aria-checked",String(o))},ge=()=>Ye("div",{class:"sep",role:"separator"}),ve=Ye("span",{class:"ma"}),we=Ye("span",{class:"kc"}),ye="",be=fe(ve,function(){let t=Ye("input",{class:"input",type:"text",maxlength:"80","aria-label":"Your name"});t.value=e.l.name();let n=Ye("div",{class:"ed"},ve.cloneNode(!0),t),o=(r,i=!1)=>{if(C!==o)return;C=null;let a=t.value.trim();r&&a&&a!==e.l.name()&&e.l.rename(a).then(Be),n.replaceWith(be),i&&be.focus({preventScroll:!0})};C=o,t.addEventListener("keydown",e=>{e.stopPropagation(),("Enter"===e.key||"Escape"===e.key)&&(e.preventDefault(),o("Enter"===e.key,!0))}),t.addEventListener("blur",()=>o(!0)),be.replaceWith(n),t.focus({preventScroll:!0})},!1,we);be.dataset.item="name";let xe=fe(it("copy"),()=>{B(),e.l.copyAll("ai")}),ke=fe(it("lines"),()=>{B(),e.l.copyAll("text")}),Ee=Ye("div",{class:"subs",role:"group"},Ye("div",{},xe,ke)),Se=fe(it("copy"),()=>$e("true"!==Se.getAttribute("aria-expanded")),!1,Ye("span",{class:"chev"},it("chev",13))),$e=(e,t=!0)=>{Se.setAttribute("aria-expanded",String(e)),Ee.classList.toggle("open",e),_e(Ee,!e),t&&(e?xe:Se).focus({preventScroll:!0})};z=()=>$e(!1,!1),z(),Se.addEventListener("keydown",e=>{"ArrowRight"===e.key&&"true"!==Se.getAttribute("aria-expanded")&&(e.preventDefault(),$e(!0))}),Ee.addEventListener("keydown",e=>{"ArrowLeft"===e.key&&(e.preventDefault(),$e(!1))});let Le=Ye("span",{class:"kc"}),Ce=fe(it("look"),()=>{e.l.setLook(Hn[(Hn.indexOf(e.l.look())+1)%3]),Be()},!1,Le),Ae=Ye("span",{class:"kc"}),Te=fe(it("list"),()=>{O(!1),Te.dataset.item="all",H(!0)},!1,Ae),qe=fe(it("hide"),()=>{e.l.setHide(!e.state.hide),Be()},!0),Re=fe(it("comment"),t=>{let n=!e.state.p&&0===t.detail;e.Te(!e.state.p,n),n&&O(!1)},!0,Ye("span",{class:"kc ks","aria-hidden":"true"},Ot));Re.dataset.item="comment",Re.setAttribute("aria-keyshortcuts",Ft);let Ne=Ye("div",{class:"sec",role:"presentation"}),De=ge(),ze=ge(),Oe=new Map,He=t=>{let n=Oe.get(t);return n||(n=fe(at(t.icon,15),()=>{t.checked||B(),Promise.resolve().then(()=>t.select()).catch(t=>e.ee(t)).finally(()=>M&&Be())},!!t.checked,Ye("span",{class:"kc"})),Oe.set(t,n)),n},Fe=-1,Ie=e=>{try{return e()}catch(e){return globalThis.reportError?.(e),""}};function Be(){let t=V(),n=e.l.name(),o=n||m(e.doc.me);if(me(be,o,n?"The name on your comments":"Add a name to show on your comments"),be.setAttribute("aria-label",`${o}, ${n?"edit":"add"} your name`),we.replaceChildren(n?it("edit",13):"Add name"),ct(e.doc.me,n)!==ye){ye=ct(e.doc.me,n);let t=ut(e.doc.me,n);t.classList.add("in"),ve.replaceChildren(t)}me(Se,"Copy comments","As Markdown, with where each thread is, or as text"),me(xe,"As Markdown","With where each thread is, ready for an AI or a document"),me(ke,"As text","Just the words");let r=["Automatic","Light","Dark"][Hn.indexOf(e.l.look())];me(Ce,"Theme","Automatic follows the page; press to change"),Le.textContent=r,me(Te,"All comments","Every thread, and where it is"),Ae.textContent=t?String(t):"";let i=e.addons.be();Ne.textContent=i,i?!Ne.isConnected&&s.contains(be)&&s.prepend(Ne):Ne.remove();for(let t of e.addons.V){let e,n=Oe.get(t);if(n){try{e=t.checked?.()}catch(e){globalThis.reportError?.(e)}me(n,Ie(t.label),Ie(t.hint),e),n.querySelector(".kc").textContent=t.count?Ie(t.count):""}}me(qe,"Hide comments",e.state.hide?"Comments are hidden on this page until you turn this off":"Hides the comments on this page until you turn this off",e.state.hide),me(Re,"Start commenting",e.state.p?"Turn off to use the page as normal":"Choose any part of the page to comment on it",e.state.p)}function je(){Be(),(Fe!==e.addons.ne||!s.contains(be))&&(s.replaceChildren(be,De,Se,Ee,Ce,Te,...e.addons.V.map(He),ze,qe,Re),Fe=e.addons.ne,Be())}x.addEventListener("click",e=>{if(e.stopPropagation(),M)return O(!1);je(),O(!0),0===e.detail&&F()[0]?.focus({preventScroll:!0})}),r.addEventListener("click",t=>{if(t.stopPropagation(),!M)return e.state.p?H(!0):(je(),O(!0),void(0===t.detail&&F().at(-1)?.focus({preventScroll:!0})));O(!1)});for(let e of[r,x])e.addEventListener("keydown",e=>{let t=F();!M||!t.length||"ArrowDown"!==e.key&&"ArrowUp"!==e.key||(e.preventDefault(),e.stopPropagation(),("ArrowDown"===e.key?t[0]:t.at(-1))?.focus({preventScroll:!0}))});let We=t=>{let n=t.composedPath();M&&!n.includes(s)&&!n.includes(r)&&!n.includes(x)&&(O(!1),e.state.p&&!e.M(t)&&(e.fe(t),t.preventDefault(),t.stopPropagation()))},Ke=e=>{if(!M||"touch"===e.pointerType||"pointerout"===e.type&&e.relatedTarget)return;let t=e.composedPath();"pointerover"===e.type&&(t.includes(s)||t.includes(r)||t.includes(x))?(window.clearTimeout(A),A=0):A||(A=window.setTimeout(()=>{A=0,C||O(!1)},3e3))},Ve={n:0,label:""},Ue=()=>{let{n:t,label:n}=Ve,o=e.addons.be(),a=`Comment${e.state.p?", comment mode on":""}${n?`, ${n}`:t?`, ${t} open`:""}${o?`, ${o}`:""}`;r.getAttribute("aria-label")!==a&&r.setAttribute("aria-label",a),r.setAttribute("aria-haspopup",e.state.p?"dialog":"menu");let l=n||(t>9?`${t} open`:""),s=[l,o].filter(Boolean).join(" \xb7 ")+(l||o?" \xb7 ":"");i.data!==s&&(i.data=s)},Ge=e.addons.subscribe(t=>{Ue(),(()=>{for(let[t,n]of v)e.addons.listNotes.has(t)||(v.delete(t),n.row.classList.remove("show"),setTimeout(()=>n.row.remove(),320));for(let[t,n]of e.addons.listNotes){let o=v.get(t);if(!o){let e=Ye("span",{}),r=Ye("div",{class:"ln"},Ye("div",{class:"lw"},Ye("div",{class:"ag"},e)));r.dataset.addon=t,o={row:r,words:e,btn:null,note:n},v.set(t,o),f.append(r),requestAnimationFrame(()=>{r.offsetWidth,r.classList.add("show")})}if(o.note=n,o.words.textContent!==n.text&&(o.words.textContent=n.text),n.action&&!o.btn){let t=Ye("button",{type:"button"}),n=o;t.addEventListener("click",o=>{o.stopPropagation();let r=n.note.action;r&&(t.disabled=!0,r.run().catch(t=>e.ee(t)).finally(()=>{t.disabled=!1,e.m()}))}),o.btn=t,o.words.after(t)}else!n.action&&o.btn&&(o.btn.remove(),o.btn=null);o.btn&&n.action&&o.btn.textContent!==n.action.label&&(o.btn.textContent=n.action.label)}})(),M&&!C&&(t?je():Be())});window.addEventListener("click",We,!0),window.addEventListener("pointerover",Ke,!0),window.addEventListener("pointerout",Ke,!0);let Ze=t=>{if("Escape"!==t.key||t.isComposing||C||t.composedPath().some(e=>e instanceof Element&&e.matches(".rxp,.pm")))return;let n=t.composedPath()[0];if(n instanceof HTMLTextAreaElement&&n.value.trim())return;let o=n instanceof Element&&n.closest(".cd:not(.open,.new)");if(M&&Ee.contains(n))$e(!1);else if(M)B();else if(o&&n!==o.firstChild){if(n instanceof HTMLTextAreaElement)return;o.firstChild.focus({preventScroll:!0})}else{if(!e.state.u||n instanceof HTMLTextAreaElement&&!E.contains(n))return;e.state.t?e.z():q?ue(!0):H(!1,!0)}t.preventDefault(),t.stopPropagation()};return window.addEventListener("keydown",Ze,!0),e.registerList(e=>{q!==e&&ce(e,!0)}),{m(n){T=n;let i=V(!1);if(i!==P){if(i){let[e,n]=t[0].classList.contains("on")?t:[t[1],t[0]];n.textContent=i>9?"9+":String(i),o.classList.toggle("w",i>9),e.classList.remove("on"),n.classList.add("on")}r.classList.toggle("has",i>0),P=i}let a=V(!0),s=a?`${i} here \xb7 ${a} ${null!==e.f.slide()?"on other slides":"in other views"}`:"";r.classList.toggle("else",a>0),Ve={n:i,label:s},Ue(),r.classList.toggle("on",e.state.p),M&&!e.state.l&&O(!1),M&&Be();let d=e.state.u;E.classList.toggle("full",Gt()),E.classList.contains("show")!==d&&(E.classList.toggle("show",d),_e(E,!d),_e(l,d)),q&&(!d||!n.some(e=>e.id===q))&&(q=R=null,e.state.S=null),d?le():Z=!1},O:function(){let t=q?T.find(e=>e.id===q):null,n=N?.card??(q?d.querySelector(".cd.open"):null),o=N?he(null,N.of):t&&he(t),r=n?.getBoundingClientRect(),i=d.getBoundingClientRect();if(!e.state.u||!o||!r?.width||r.top+12<i.top||r.top+12>i.bottom)return void S.classList.remove("show");let a,l=r.left,s=r.top+14;if("right"===o.from&&l-o.x>60){let e=o.x+28,t=o.y>=s?1:-1,n=Math.min(24,Math.abs(o.y-s)/2);a=`M${l} ${s}C${l-24} ${s} ${e} ${s} ${e} ${s+t*n}L${e} ${o.y-t*n}C${e} ${o.y} ${e} ${o.y} ${o.x} ${o.y}`}else{let e=o.y-8,t=l-40,n=e>=s?1:-1,r=Math.min(20,Math.abs(e-s)/2);a=`M${l} ${s}C${l-20} ${s} ${t} ${s} ${t} ${s+n*r}L${t} ${e-n*r}C${t} ${e} ${t} ${e} ${t-r} ${e}L${o.x+8} ${e}C${o.x} ${e} ${o.x} ${e} ${o.x} ${o.y}`}$.setAttribute("d",a),L.setAttribute("r",o.bubble?"0":"4"),L.setAttribute("cx",String(o.x)),L.setAttribute("cy",String(o.y)),S.classList.add("show")},destroy(){Ge(),window.removeEventListener("click",We,!0),window.removeEventListener("pointerover",Ke,!0),window.removeEventListener("pointerout",Ke,!0),window.clearTimeout(A),window.removeEventListener("keydown",Ze,!0),e.registerList(null),s.remove(),E.remove(),S.remove(),l.remove()}}}var In="[data-pipeup-slide]",Bn=["scroll","resize","keyup","click","transitionend","slidechanged"],jn=null,Wn=null,Kn=new Set,Vn=new Set,Un=e=>{try{e()}catch(e){globalThis.reportError?.(e)}};function Yn(e){Wn="function"==typeof e?.current&&"function"==typeof e.go?e:null}var _n=()=>{let e=window.Reveal;return"function"==typeof e?.getIndices&&"function"==typeof e.slide?e:null};var Gn,Zn="#534AB7";function Jn(e,t){let n=function(e){let t=/rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)(?:\s*[,/]\s*([\d.]+%?))?\s*\)/.exec(e);if(!t||void 0===t[1]||void 0===t[2]||void 0===t[3])return null;let n=void 0===t[4]?1:t[4].endsWith("%")?parseFloat(t[4])/100:parseFloat(t[4]);return{r:Number(t[1]),g:Number(t[2]),b:Number(t[3]),a:n}}(e);if(n||!e||"transparent"===e)return n;try{if(Gn??=t.createElement("canvas").getContext("2d",{willReadFrequently:!0})??null,!Gn)return null;Gn.clearRect(0,0,1,1),Gn.fillStyle="#000",Gn.fillStyle=e,Gn.fillRect(0,0,1,1);let[n,o,r,i]=Gn.getImageData(0,0,1,1).data;return{r:n,g:o,b:r,a:i/255}}catch{return null}}function Xn(e){let t=e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4};return.2126*t(e.r)+.7152*t(e.g)+.0722*t(e.b)}var Qn=[[.92,.25],[.92,.6],[.5,.45]];function eo(e){let t=e.defaultView,n=e.documentElement,o=t?.getComputedStyle(n).colorScheme||"",r=/dark/.test(o)&&(!/light/.test(o)||!0===t?.matchMedia?.("(prefers-color-scheme: dark)").matches),i=t?Jn(t.getComputedStyle(n).backgroundColor,e):null;return t&&e.body&&(!i||i.a<.5)&&(i=Jn(t.getComputedStyle(e.body).backgroundColor,e)),i&&i.a>=.5?i:r?{r:0,g:0,b:0}:{r:255,g:255,b:255}}function to(e,t){let n=e.ownerDocument,o=n.defaultView,r="dark"===t;if(!o)return{font:"system-ui, sans-serif",accent:Zn,dark:r,on:"#fff"};let i=n.documentElement,a=o.getComputedStyle(e).fontFamily||"system-ui, sans-serif",l=(o.getComputedStyle(i).getPropertyValue("--pipeup-accent")||i.style.getPropertyValue("--pipeup-accent")).trim(),s=e.querySelector("a[href]"),d=s?o.getComputedStyle(s).color:"",c=l||"rgb(0, 0, 238)"!==d&&d,u=c?Jn(c,n):null,[p,h,f]=r?[27,27,25]:[255,255,255],m=u&&((e,t)=>(Math.max(e,t)+.05)/(Math.min(e,t)+.05))(Xn(u),Xn({r:.12*u.r+.88*p,g:.12*u.g+.88*h,b:.12*u.b+.88*f}))>=4.5?c:r?"#9A94EE":Zn,g=Jn(m,n);return{font:a,accent:m,dark:r,on:g&&Xn(g)>.19?"#111":"#fff"}}function no(e,t){e.style.setProperty("--pu-font",t.font),e.style.setProperty("--pu-accent",t.accent),e.style.setProperty("--pu-on",t.on),e.classList.toggle("dark",t.dark)}var oo=["pipeup-quote","pipeup-on","pipeup-done"],ro={"pipeup-quote":[[250,227,188,.75],[180,120,0,.35]],"pipeup-on":[[247,212,154,.95],[180,120,0,.5]],"pipeup-done":[[180,178,169,.22],[140,138,130,.2]]};function io(){return typeof CSS<"u"&&"highlights"in CSS&&typeof Highlight<"u"}var ao=`:not(${gn},:is(${gn}) *){cursor:url("data:image/svg+xml,${encodeURIComponent("<svg xmlns='http://www.w3.org/2000/svg' width='32' height='32'><rect x='7' y='7' width='23' height='23' rx='4' fill='none' stroke='#534AB7' stroke-width='2' stroke-dasharray='4 3'/><path d='M3 2v15l4-3.5 3 6.5 2.5-1.2-3-6.3H15z' fill='#fff' stroke='#2C2C2A' stroke-width='1.2' stroke-linejoin='round'/></svg>")}") 3 2,crosshair!important}`;function lo(){if(io())for(let e of oo)for(let t of["","-d"])CSS.highlights.delete(e+t)}var so={light:["#2C2C2A","#FFFFFF"],dark:["#ECEBE6","#1B1B19"]},co=[["opacity","1"],["filter","none"],["backdrop-filter","none"],["mix-blend-mode","normal"],["transform","none"],["clip-path","none"],["mask-image","none"],["zoom","1"]];function uo(e,t,n){let[o,r]=so[e].map(e=>{let[o,r,i]=(e=>[1,3,5].map(t=>parseInt(e.slice(t,t+2),16)))(e).map((e,o)=>t*e+(1-t)*n[o]);return Xn({r:o,g:r,b:i})});return((e,t)=>(Math.max(e,t)+.05)/(Math.min(e,t)+.05))(o,r)}var po=["ArrowUp","ArrowDown","Home","End","PageUp","PageDown"];function ho(e,t=!1){return sn(e,t)?"column":"bubbles"}var fo="Shown here, but not saved yet \u2014 it will be saved with your next change",mo=e=>e instanceof Error?e.message.replace(/^pipeup: /,""):"Something went wrong";function go(e){let t="pipeup:look",n="auto";try{let e=localStorage.getItem(t);("light"===e||"dark"===e)&&(n=e)}catch{}let o,r=!1,i=!1,a="",l=()=>{let e="auto"!==n?n:function(e){let t=e.documentElement.getAttribute("data-pipeup-theme")??e.body?.getAttribute("data-pipeup-theme");return"light"===t||"dark"===t?t:null}(document);i=function(e,t=!1){let n=e.defaultView;if(!n)return!1;let o=e.documentElement,r=Xn(eo(e)),i=(t,n)=>{try{if(e.elementsFromPoint)return e.elementsFromPoint(t,n)}catch{}return e.body?[e.body,o]:[o]},a=0;for(let[t,o]of Qn){let l=r;for(let r of i(n.innerWidth*t,n.innerHeight*o)){if(r.closest("[data-pipeup-ignore]"))continue;let t=r.getBoundingClientRect();if(t.width*t.height<.25*n.innerWidth*n.innerHeight)continue;let o=Jn(n.getComputedStyle(r).backgroundColor,e);if(o&&o.a>=.5){l=Xn(o);break}}a+=l}let l=a/Qn.length;return l<.18||!(l>.32)&&t}(document,i);let t=e??(i?"dark":"light");o=function(e,t,n){let o=e.defaultView?.getComputedStyle(e.documentElement),r=co.flatMap(([e,t])=>{let n=o?.getPropertyValue(e).trim();return n&&n!==t?[`${e}: ${n}`]:[]}),i=Math.min(1,Math.max(0,parseFloat(o?.opacity??"1")||1)),{r:a,g:l,b:s}=eo(e);return{look:t,source:n,ratio:uo(t,i,[a,l,s]),effects:r}}(document,t,"auto"!==n?"reviewer":e?"author":"page");let r=function(e){return!e.effects.length&&e.ratio>=3?null:`pipeup: the page's styles on <html> (${e.effects.join("; ")||"none"}) change how everything on the page looks, Pipeup included, and can't be undone from inside it. `+(e.ratio<3?"Pipeup's words may be hard to read. ":"")+"Move those styles to <body> or a wrapper."}(o);return r&&r!==a&&console.warn(a=r),t};r="dark"===l();let s=function(e,t,n=document){let o=n.createElement("pipeup-root");o.setAttribute("data-pipeup-ignore",""),o.style.cssText="position:fixed!important;inset:0!important;pointer-events:none!important;z-index:2147483647!important;display:block!important;margin:0!important;visibility:visible!important;opacity:1!important;transform:none!important;translate:none!important;scale:none!important;rotate:none!important;filter:none!important;clip-path:none!important;mask:none!important;zoom:1!important;";let r=o.attachShadow({mode:"open"}),i=n.defaultView?.CSSStyleSheet;if(i&&"replaceSync"in i.prototype&&"adoptedStyleSheets"in r){let e=new i;e.replaceSync(t),r.adoptedStyleSheets=[e]}else{let e=n.createElement("style");e.textContent=t,r.append(e)}let a=n.createElement("div");return a.className="layer",a.style.setProperty("--pu-panel","320px"),a.style.setProperty("--pu-pop",`${_t()}px`),no(a,e),r.append(a),n.documentElement.append(o),{element:o,shadow:r,e:a,destroy:()=>o.remove()}}(to(e.root,r?"dark":"light"),e.styles);s.e.classList.toggle("flip",r!==i);let d=function(e=document){let t=e.defaultView?.CSSStyleSheet;if(!t||!("replaceSync"in t.prototype)||!("adoptedStyleSheets"in e))return{Me(){},Ce(){},ve(){},Pe(){},remove:()=>lo()};let n=new t,o=null,r=!1,i=1,a=0,l="",s=0,d=()=>n.replaceSync((e=>oo.map(t=>ro[t].map(([n,o,r,i],a)=>`::highlight(${t}${a?"-d":""}){background-color:rgba(${n},${o},${r},${+(i*e).toFixed(3)})}`).join("")).join(""))(i)+(null===o?"":`:root{--pipeup-gutter:${o}px}`)+(r?ao:"")+(a||l?`html{--pipeup-panel:${a}px;width:auto!important;${a?`margin-right:${a}px!important;`:""}${l}}`:""));return d(),e.adoptedStyleSheets=[...e.adoptedStyleSheets,n],{Me(e){e!==o&&(o=e,d())},Ce(e){e!==r&&(r=e,d())},ve(e){i=e,d()},Pe(e,t){e!==a&&(a=e,l=t?"":"transition:margin-right .34s cubic-bezier(.4,0,.2,1)!important",clearTimeout(s),!e&&l&&(s=window.setTimeout(()=>{l="",d()},400)),d())},remove(){clearTimeout(s),e.adoptedStyleSheets=e.adoptedStyleSheets.filter(e=>e!==n),lo()}}}(document);d.ve(0);let c=!0===window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,u=document.documentElement.hasAttribute("data-pipeup-reserve"),p=new Map,h=new Set,f=new WeakSet,v=`pipeup:hide:${e.doc.id}`,w=!1;try{w="1"===localStorage.getItem(v)}catch{}let y={i:null,S:null,R:!1,mine:!1,hide:w,hidden:w,mode:ho(e.root),t:null,p:!1,paused:!1,u:!1,$e:!1,l:!1,pinning:!1},b=Ye("div",{class:"toast",role:"status","aria-live":"polite"}),x=null,k=Ye("div",{class:"sr","aria-live":"polite"});s.e.append(b,k);let E=null,S=null,$=[],L=null,M=!1,C=0,A=0,T=0,P=0,q=0,R=new Set,N="",D=new Map,z=function(e,t,n=function(){return{s:e=>e.getBoundingClientRect(),shown:e=>!1!==e.checkVisibility?.({opacityProperty:!0,visibilityProperty:!0}),opacity:e=>parseFloat(getComputedStyle(e).opacity)||0,Q:()=>({width:window.innerWidth,height:window.innerHeight})}}()){let o=!0===window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,r=null,i=null,a=[],l=0,s=!1,d=()=>[...e.querySelectorAll(In)],c=()=>[...e.querySelectorAll(".slides > section")],u=e=>"string"==typeof e&&e.length>0&&e.length<=200?e:null,p=e=>u(e?.getAttribute("data-pipeup-slide")),h=e=>{let t=c()[e];return p(t?.matches(In)?t:t?.querySelector(In))??u(String(e+1))};function f(){if(a=[],Wn){let e=null;if(Un(()=>{let t=Wn.current();Number.isInteger(t)&&t>0&&(e=String(t))}),null!==e)return e}let e=_n();if(e){let t=null;if(Un(()=>{t=h(e.getIndices().h)}),null!==t)return t}r&&!r.isConnected&&(r=null);let t=d();r=function(e,t,n){let o=t.Q(),r=null,i=0,a=0;for(let l of e){if(!t.shown(l))continue;let e=t.s(l),s=Math.min(e.left+e.width,o.width)-Math.max(e.left,0),d=Math.min(e.top+e.height,o.height)-Math.max(e.top,0);if(s<=0||d<=0)continue;let c=Math.round(s*d),u=t.opacity(l);(c>i||c===i&&(u>a||u===a&&l===n))&&(r=l,i=c,a=u)}return r}(t,n,r)??r;for(let e of function(e,t,n){let o=n&&t.s(n),r=t.Q().height;return e.filter(e=>{let n=t.s(e);return!!o&&t.shown(e)&&n.top<r&&n.top+n.height>0&&(n.top>=o.top+o.height||n.top+n.height<=o.top)})}(t,n,r)){let t=p(e);t&&a.push(t)}return p(r)}function m(){l=0,i=f(),t()}let g=()=>{!l&&!s&&(l=requestAnimationFrame(m))},v=e=>function(e,t,n,o=[]){return null!==t?void 0===e?.slide||e.slide===t||o.includes(e.slide):!e||!n||Object.entries(e).every(([e,t])=>"label"===e||"slide"===e||n[e]===t)}(e,i,jn,a),w=new MutationObserver(e=>{e.some(e=>e.target instanceof Element&&e.target.matches(In))&&g()});w.observe(e,{subtree:!0,attributes:!0,attributeFilter:["class","style","hidden"]});for(let e of Bn)window.addEventListener(e,g,{capture:!0,passive:!0});return Vn.add(g),i=f(),{slide:()=>i,view(e){let t=e instanceof Element?e:e?.parentElement,n=t&&_n()?c().findIndex(e=>e.contains(t)):-1,o=p(t?.closest(In))??(n>=0?h(n):i),r={...null!==o?{slide:o}:{},...jn};return Object.keys(r).length?r:void 0},w:v,Z:function(e){if(v(e))return Promise.resolve(!0);let t=e.slide,n=_n(),r=d().find(e=>p(e)===t),a=/^[1-9]\d{0,5}$/.test(t??"");if(a&&Wn)Un(()=>Wn.go(Number(t)));else if(a&&n){let e=r?c().findIndex(e=>e===r||e.contains(r)):-1;Un(()=>n.slide(e>=0?e:Number(t)-1))}else if(Kn.size)for(let t of Kn)Un(()=>t({...e}));else{if(!r)return Promise.resolve(!1);r.scrollIntoView({block:"start",behavior:o?"auto":"smooth"})}let l=performance.now();return new Promise(t=>{let n=e=>{clearTimeout(o),t(e)},o=setTimeout(()=>n(!1),1e3),r=()=>s?n(!1):(i=f(),v(e)?n(!0):performance.now()-l>=1e3?n(!1):void requestAnimationFrame(r));requestAnimationFrame(r)})},destroy(){s=!0,cancelAnimationFrame(l),w.disconnect();for(let e of Bn)window.removeEventListener(e,g,!0);Vn.delete(g)}}}(e.root,()=>{!M&&le()&&ye()}),O=!1,H=null,F=0,I=()=>y.p&&!y.u&&Zt();function B(){I()&&!y.l&&j("Tap what you want to comment on",0,!0,!1,{label:"Done",run:()=>Fe(!1)})}function j(e,t=2400,n=!1,o=!1,r){if(M)return;if(n&&y.l)return void(H=()=>j(e,t,!0,o));O=n,b.textContent=e,b.classList.toggle("act",!!r);let i=r?.run;if(x=i?()=>{x=null,b.classList.remove("show"),i()}:null,r){let e=i?Ye("button",{class:"ta",type:"button","aria-keyshortcuts":"Meta+Z Control+Z"},r.label):Ye("a",{class:"ta",href:r.href,target:"_blank",rel:"noopener noreferrer"},r.label);if(x){let t=x;e.addEventListener("click",e=>{e.stopPropagation(),t()})}b.append(" ",e)}o?b.setAttribute("aria-hidden","true"):b.removeAttribute("aria-hidden"),b.classList.add("show"),window.clearTimeout(C),t&&(C=window.setTimeout(()=>{x=null,b.classList.remove("show"),C=window.setTimeout(B,320)},t))}let W=(e,t)=>j(e,6e3,!1,!1,{label:"Undo",run:t});function K(){I()||(H=null,O&&(O=!1,window.clearTimeout(C),b.classList.remove("show")))}function V(e){k.textContent="",cancelAnimationFrame(F),F=requestAnimationFrame(()=>k.textContent=e)}function U(e){j(mo(e))}function _(e){throw U(e),e}let G=()=>e.doc.threads().filter(e=>!e.root.deleted),Z=t=>({thread:t,location:Le(t.anchor,p.get(t.id)??we(t.anchor,e.root),e.root)}),J=e=>[...s.e.querySelectorAll(`[data-thread="${e}"] .rbox textarea`)].find(e=>!e.closest("[inert]"));function X(){for(let e of s.e.querySelectorAll("[data-thread] .rbox textarea"))e.value.trim()&&D.set(e.closest("[data-thread]").getAttribute("data-thread"),e.value)}function Q(e,t=!1){let n=D.get(e),o=J(e);if(o){if(D.delete(e),n&&!o.value){o.value=n,o.dispatchEvent(new Event("input",{bubbles:!0}));for(let t of s.e.querySelectorAll(`[data-thread="${e}"] .rbox textarea`))t!==o&&t.value&&(t.value="",t.dispatchEvent(new Event("input",{bubbles:!0})))}t&&o.focus({preventScroll:!0})}}function ee(e){let t=xe();if(!t?.closest(`[data-thread="${e}"]`))return()=>{};let n=t.closest(".cd")?".mi":t.closest(".th")?".opn":".bub",o=[...s.e.querySelectorAll(`${n}[data-thread]`)],r=o.findIndex(t=>t.getAttribute("data-thread")===e),i=r<0?null:(o[r+1]??o[r-1])?.getAttribute("data-thread");return()=>{if(L?.he())return L.ge();(i&&s.e.querySelector(`${n}[data-thread="${i}"]`)||s.e.querySelector(".launch .mode"))?.focus({preventScroll:!0})}}let te={get me(){return e.doc.me},picker:()=>ie.picker,people:()=>wt(e.doc.threads(),e.doc.me),react:async(t,n,o)=>{try{await(o?e.doc.react(t,n):e.doc.unreact(t,n))}catch(e){e instanceof Y?j(fo):_(e)}},reply:async(t,n,o)=>{try{await e.doc.reply(t,n,o),V("Reply sent"),Te(o,n)}catch(e){e instanceof Y?j(fo):_(e)}},edit:async(t,n,o)=>{try{await e.doc.edit(t,n,o)}catch(e){e instanceof Y?j(fo):_(e)}},remove:async t=>{let n=e.doc.threads().find(e=>e.id===t||e.root.replies.some(e=>e.id===t)),o=n&&n.root.id===t?ee(n.id):()=>n&&J(n.id)?.focus({preventScroll:!0});try{await e.doc.remove(t),o(),j("Deleted")}catch(e){j(e instanceof Y?`Deleted \xb7 ${fo}`:mo(e))}},resolve:async t=>{let n=ee(t);s.e.classList.add("still"),window.addEventListener("pointermove",()=>s.e.classList.remove("still"),{once:!0});try{await e.doc.resolve(t),j("Resolved \xb7 \u2713 Resolved in All comments shows it again")}catch(e){j(e instanceof Y?`Resolved \xb7 ${fo}`:mo(e))}y.R||(y.i===t&&(y.i=null),n())},reopen:async t=>{try{await e.doc.reopen(t),j("Reopened")}catch(e){j(e instanceof Y?`Reopened \xb7 ${fo}`:mo(e))}},notRight:async t=>{try{await e.doc.reopen(t)}catch(e){j(e instanceof Y?`Reopened \xb7 ${fo}`:mo(e))}Ce(t)},drop:(e,t)=>W("Reply discarded",()=>{D.set(e,t),J(e)?Q(e,!0):ze(e)}),close:()=>{ze(null);let e=be&&s.e.querySelector(be);e?e.focus({preventScroll:!0}):L?.ge(),be=""},copy:t=>{try{let n=e.doc.threads().find(e=>e.id===t);if(!n)return;zn(qe(Z(n),"ai",location.href,Date.now()),s.e).then(()=>j("Thread copied as Markdown for AI"),e=>j(mo(e)))}catch(e){j(mo(e))}}},ne={look:()=>n,setLook(e){n=e;try{"auto"===e?localStorage.removeItem(t):localStorage.setItem(t,e)}catch{}Ct(l())},copyAll:async e=>{let t=ne.all(),n=Re(t,e,{title:document.title,url:location.href,exportedAt:new Date});try{await zn(n,s.e);let o=t.filter(e=>!e.thread.resolved).length;j(`Copied ${o} thread${1===o?"":"s"}${"ai"===e?" as Markdown for AI":""}`)}catch(e){j(mo(e))}},Je:()=>{y.R=!y.R,ye()},toggleMine:()=>{y.mine=!y.mine,ye()},setHide:e=>{y.hide=e;try{e?localStorage.setItem(v,"1"):localStorage.removeItem(v)}catch{}ye()},rename:async t=>{let n=t.replace(/\s+/g," ").trim();try{await async function(t){try{return await e.onName(t),!1}catch(n){if(e.doc.name!==t)throw n;return!0}}(n)?j(`New comments will say ${n}, but this browser couldn't remember it`):j(`New comments will say ${n}`)}catch(e){j(mo(e))}},name:()=>e.doc.name,all:()=>[...G()].sort(tn(re)).map(Z)},oe={},re={get addons(){return oe.surface},doc:e.doc,root:e.root,e:s.e,host:s.element,state:y,resolved:p,$:h,D:te,l:ne,f:z,W:e=>R.has(e.id),Ae:()=>{le()&&ye()},_:e=>!y.hidden&&(!e.resolved||y.R||(e=>""!==(s.e.querySelector(`[data-thread="${e}"] .rbox textarea`)?.value.trim()??""))(e.id))&&!R.has(e.id),Qe:(e,t)=>{for(let n of G()){let o=p.get(n.id);if(n.anchor.quote&&re._(n)&&o?.range&&Yt(e,t,Kt(o)))return n}return null},ue:(e,t)=>re.E()&&!y.pinning?re.Qe(e,t):null,M:e=>e.composedPath().includes(s.element),fe:e=>{f.add(e)},Ye:e=>f.has(e),open:ze,et:e=>Ce(e),keepReplies:X,putReply:e=>Q(e),S:function(e){y.S!==e&&(y.S=e,e&&e!==y.i&&je(e),ye())},Ze:Oe,je:function(e){if(!y.t)return Oe(e);Object.assign(y.t,e),ye()},E:()=>!E||E._e(),Se:e=>{let t=E?.le();e(),t?.()},focusDraft:De,te:()=>{let e=y.t?.anchor.view,t=z.w(e)?void 0:e?.slide;j(t?`Finish or cancel your comment on slide ${t} first`:"Finish or cancel this comment first"),De(()=>L?.toDraft())},Ue:async function(t,n){let o=y.t;if(o)try{o.sending=!0;let r=await e.doc.comment(o.anchor,t,n);V("Comment added"),Te(n,t),y.t=null,ae(new Set([r])),ze(r,!0)}catch(e){if(e instanceof Y)return y.t=null,ae(new Set([e.id])),ze(e.id,!0),void j(fo);o.sending=!1,_(e)}},seen:Pe,people:()=>wt(e.doc.threads(),e.doc.me),ce:He,Te:Fe,U:Be,I:e=>{E=e},registerList:e=>{S=e},ae:j,L:V,Ge:K,ee:U,tt:je,m:ye,z:Ie},ie=oe.surface=new At(re,s.shadow,k);function ae(t){let n=performance.now(),o=e.doc.threads();for(let r of o){if(t&&!t.has(r.id))continue;let o=performance.now()-n<40,i=we(r.anchor,e.root,{fuzzy:o});p.set(r.id,i),o||"orphaned"!==i.state?h.delete(r.id):h.add(r.id)}for(let e of[...p.keys()])o.some(t=>t.id===e)||p.delete(e);0===h.size?(window.clearTimeout(P),P=0):0===P&&(P=window.setTimeout(()=>{P=0,!M&&(ae(new Set(h)),ye())},250))}function le(){let t=new Set,n=null!==z.slide(),o=new Set;for(let r of e.doc.threads()){o.add(r.id);let e=p.get(r.id),i=e?.element,a="attached"===e?.state||"moved"===e?.state;(n?!z.w(r.anchor.view):!1===i?.checkVisibility?.({visibilityProperty:!0})||!z.w(r.anchor.view)&&(!a||i?.closest("[role=tabpanel]")))&&t.add(r.id)}R=t;for(let e of D.keys())o.has(e)||D.delete(e);let r=`${z.slide()}|${[...t].join()}`;return r!==N&&(N=r,!0)}function se(e){let t=[],n=[],o=[];for(let r of e){let e=p.get(r.id);r.resolved&&!y.R||!e?.range||R.has(r.id)||(r.id===y.i||r.id===y.S?n.push(e.range):r.resolved?o.push(e.range):t.push(e.range))}y.t&&z.w(y.t.anchor.view)&&n.push(...y.t.ranges),function(e,t){if(io())for(let n of oo){let o=e[n.slice(7)];CSS.highlights.set(n,new Highlight(...o.filter(e=>!t(e)))),CSS.highlights.set(`${n}-d`,new Highlight(...o.filter(t)))}}({quote:t,on:n,done:o},e=>{let t=de.get(e);return void 0===t&&de.set(e,t=function(e){let t=e.startContainer,n=t instanceof Element?t:t.parentElement,o=n?.ownerDocument.defaultView;if(!n||!o)return!1;let r=n.ownerDocument,i=Xn(Jn(o.getComputedStyle(n).color,r)??{r:0,g:0,b:0});for(let e=n;e;e=e.parentElement){let t=o.getComputedStyle(e);if("none"!==t.backgroundImage)return i>.4;let n=Jn(t.backgroundColor,r);if(n&&n.a>=.5)return i>Xn(n)}return i>Xn(eo(r))}(e)),t})}let de=new WeakMap,ce=0,ue=0,pe=0,fe=0,me=0,ge=0,ve=!1;function ye(){if(M)return;let t=G();if(le(),y.i&&R.has(y.i)){let e=s.e.querySelector(`[data-thread="${y.i}"] .rbox textarea`)?.value;e&&D.set(y.i,e),y.i=null}y.hidden=y.hide&&!y.p&&!y.u&&!y.$e&&!y.t,d.Ce(y.p&&!y.paused),y.hidden&&(y.i=null),y.hidden||function(t){let n=function(e,t){let n=xt(t),o=[];for(let r of e)for(let e of[r.root,...r.root.replies])e.author!==t&&!e.deleted&&yt(e,n)&&!e.seenBy?.includes(t)&&o.push({thread:r,comment:e});return o}(t,e.doc.me).filter(e=>!Ne.has(e.comment.id));if(!n.length)return;for(let e of n)Ne.add(e.comment.id);let o=[...new Set(n.map(e=>g(e.comment)))];j(`${1===o.length?o[0]:`${o.length} people`} mentioned you in ${n.length} comment${1===n.length?"":"s"}`)}(t),function(e){if(e===ue)return;ue=e,cancelAnimationFrame(pe);let t=ce,n=performance.now(),o=e?260:200,r=i=>{let a=Math.min(1,(i-n)/o);ce=t+(e-t)*(e?1-(1-a)**3:a*a),d.ve(ce),a<1&&(pe=requestAnimationFrame(r))};pe=requestAnimationFrame(r)}(y.hidden?0:1),s.e.classList.toggle("hidden",y.hidden),s.e.classList.toggle("listing",y.u),y.p&&Zt()&&(y.u?K():b.classList.contains("show")||(H??=B));let n=y.u&&!Gt();(function(e){e!==fe&&(fe=e,d.Pe(e,c),null!==z.slide()&&(ge=performance.now()+450),window.clearTimeout(me),me=window.setTimeout(()=>{ae(),ye()},c?0:400))})(n?320:0),d.Me(u?"column"!==y.mode||y.hidden||n?0:320:null);let o=0;if(null!==z.slide())for(let t of e.root.querySelectorAll(gn)){if(t===s.element)continue;let e=t.getBoundingClientRect();e.top>innerHeight/2&&e.right>innerWidth-fe-380&&e.bottom>innerHeight-48&&(o=Math.max(o,innerHeight-e.top+4))}s.e.style.setProperty("--pu-lift",`${o}px`),se(t);for(let e of $)e.m(t);L?.m(t),y.hidden||ie.flush()}let be="",xe=()=>s.e.getRootNode().activeElement,Ee="input,textarea,select,[contenteditable]:not([contenteditable=false])",Me=()=>{let e=xe();return e instanceof HTMLTextAreaElement&&""!==e.value||!!document.activeElement?.matches(Ee)};function Ce(e,t=Me(),n=xe()){let o=[...s.e.querySelectorAll(`[data-thread="${e}"] .rbox textarea`)].find(e=>!e.closest("[inert]")),r=n?.getAttribute("data-thread");be=r?`.${n.classList[0]}[data-thread="${r}"]`:"",!t&&o&&o.focus({preventScroll:!0})}let Ae=()=>!!y.t&&!re.E();function Te(t,n){let o=e.doc.contacts(),r=new Map;for(let e of t??[]){let t=o.get(e.ref);t?.includes("@")&&r.set(t,n.slice(e.start+1,e.end))}if(!r.size)return;let i=e.doc.name||m(e.doc.me),a=`${i} mentioned you on ${document.title}`,l=`${i} mentioned you in a comment on "${document.title}":\n\n${n}\n\n${location.href}`,s=[...r.values()];j(`Let ${1===s.length?s[0]:`${s.length} people`} know?`,9e3,!1,!1,{label:"Open my email",href:`mailto:${[...r.keys()].join(",")}?subject=${encodeURIComponent(a)}&body=${encodeURIComponent(l)}`})}function Pe(t){let n=[t.root,...t.root.replies].filter(t=>t.author!==e.doc.me&&!t.deleted&&yt(t,xt(e.doc.me))).map(e=>e.id);n.length&&e.doc.seen(n).catch(()=>{})}let Ne=new Set;function De(e){let t=y.t?.anchor.view,n=E?.le();Promise.resolve(z.w(t)||z.Z(t??{}).then(()=>re.Ae())).then(()=>{z.w(t)&&e?.(),n?.()})}function ze(t,n=!1){if(t&&y.t&&!re.E())return re.te();if(t&&y.u&&S)return S(t);if(y.i===t&&!y.t)return t?Ce(t):void 0;let o=!n&&Me(),r=xe();if(t||(y.$e=!1),X(),y.i=t,t){y.t=null,je(t);let n=e.doc.threads().find(e=>e.id===t);n&&Pe(n)}ye(),t&&(Q(t),n&&L?.he()?L.ge():Ce(t,o||Zt(),r))}function Oe(e){K(),y.t=e,y.i=null,ye()}function He(e=""){let t=y.t;t&&(y.t=null,ye(),e&&W("Comment discarded",()=>{y.t&&!re.E()||(Oe(t),L?.adopt(t),E?.fill(e))}))}function Fe(e,t=!1){y.p!==e&&(y.p=e,y.paused=!1,H=null,e?(y.i=null,L=function(e){let t={s:e=>e.getBoundingClientRect(),ze:e=>{let t=getComputedStyle(e),n="transparent"!==t.backgroundColor&&!/,\s*0\)$/.test(t.backgroundColor),o=["top","right","bottom","left"].some(e=>parseFloat(t.getPropertyValue(`border-${e}-width`))>0);return n||o||"none"!==t.backgroundImage||"none"!==t.boxShadow},We:e=>/^(inline-)?(flex|grid)$/.test(getComputedStyle(e).display),flow:e=>{let t=getComputedStyle(e),n=[t.overflowX,t.overflowY];return{display:t.display,position:t.position,clips:n.some(e=>"hidden"===e||"clip"===e)&&!n.some(e=>"auto"===e||"scroll"===e)&&e!==document.documentElement&&e!==document.body,off:"none"===t.pointerEvents}},Q:()=>({width:innerWidth,height:innerHeight})},n=Ye("span",{hidden:!0},Rn),o=Ye("div",{class:"pick"},n),r=Ye("div",{class:"pkw"}),i=[0,1].map(()=>{let e=Ye("div",{class:"km",tabindex:"-1",role:"button"},Ye("span",{hidden:!0}),Ye("span",{hidden:!0}));return e.inert=!0,e.addEventListener("keydown",Me),e.addEventListener("click",e=>{e.stopPropagation(),Le()}),e.addEventListener("focus",()=>o.classList.add("kf")),e.addEventListener("blur",()=>o.classList.remove("kf")),e}),a=Ye("span",{class:"lbl"}),l=(e,t,n,o)=>{let r=Ye("button",{class:"nb",type:"button","aria-label":e,title:t},it(n,16));return r.addEventListener("click",e=>{e.stopPropagation(),o(e)}),r},s=l("Around it","Select the block around it","expand",xe),d=l("Inside it","Select a block inside it","shrink",Ee),c=l("Pin","Pin its centre","pin",t=>t.detail&&Zt()?j(!D):e.Se(()=>U(m??k,{x:.5,y:.5}))),u=Ye("div",{class:"namebar",role:"group","aria-label":"Chosen block"},a,s,d,c);u.inert=!0;let p=e.e.querySelector(".launch");for(let t of[r,o,...i,u])e.e.insertBefore(t,p);u.addEventListener("mousedown",e=>e.preventDefault());let h=!0===window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,f=null,m=null,g=null,v=null,w=0,y=()=>{},b=null,x=()=>{},k=null,E=0,S=0,$=!1,L=null,M=null,C=null,A=0,T=-1,P=!0,q=null,R=null,N=!1,D=!1,z=t=>!(e.M(t)||t.target instanceof Element&&t.target.closest(gn));function O(){v&&(o.classList.toggle("glide",performance.now()<w),Xe(o,v.getBoundingClientRect(),4))}function H(){if(!b)return;u.classList.toggle("glide",performance.now()<w&&u.classList.contains("show"));let t={width:u.offsetWidth||200,height:u.offsetHeight||34},n=Qt(b.getBoundingClientRect(),t,{width:innerWidth,height:innerHeight}),o=e.e.querySelector(".pop.show")?.getBoundingClientRect(),r=t.height;o&&n.top<o.bottom&&n.top+r>o.top&&n.left<o.right&&n.left+t.width>o.left&&(n.top=o.top-r-8>=8?o.top-r-8:o.bottom+8),u.style.left=`${n.left}px`,u.style.top=`${n.top}px`}function F(e,t){v=e,w=t?performance.now()+400:0,O(),o.classList.add("show")}function I(e,t){let n=getComputedStyle(e);if("0"===n.opacity)return t(),()=>{};let o=0,r=()=>{window.clearTimeout(o),e.removeEventListener("transitionend",a)},i=()=>{r(),t()},a=t=>{t.target===e&&"opacity"===t.propertyName&&i()},l=Math.max(...n.transitionDuration.split(",").map(e=>1e3*parseFloat(e)||0));return o=window.setTimeout(i,l+100),e.addEventListener("transitionend",a),r}function B(e){if(e!==f){if(f=e,y(),!e)return void o.classList.remove("show");"0"===getComputedStyle(o).opacity?F(e,!1):h?(o.classList.remove("show"),y=I(o,()=>F(e,!1))):F(e,!0)}}function j(t){D=e.state.pinning=t,c.classList.toggle("on",t),t?e.L(a.textContent="Tap where to pin"):b&&(a.textContent=$e(b))}function W(e){D&&j(!1),m=e,o.classList.toggle("on",null!==e),B(e),K(e)}function K(e){x(),u.inert=!e,e?h?(u.classList.remove("show"),x=I(u,()=>V(e))):V(e):(u.classList.remove("show"),b=null)}function V(n){a.textContent=a.title=$e(n),s.hidden=null===En(n,e.root,t),d.hidden=0===(k?we(n).length:Ln(n,t,de).length);let o=u.classList.contains("show");b=n,H(),o||(u.offsetWidth,u.classList.add("show"))}function U(t,n){let o;try{o=he(t,e.root,n,e.f.view(t))}catch(t){return void e.ee(t)}let r={anchor:o,label:n?`Pin on ${$e(t).replace(/^[A-Z](?=[a-z])/,e=>e.toLowerCase())}`:$e(t),ranges:[],resolved:{state:"attached",element:t,range:null}},i=e.state.t;k&&(k=t,T=-1),W(n?null:t),g=i??r,e.je(r),i&&e.focusDraft(),e.L(n?r.label:`Commenting on ${r.label}`)}function Y(t){e.Se(()=>U(t))}function _(n){let o=(n.target instanceof Element?kn(n.target,e.root,t):null)??e.root;o!==e.root&&(L=o);let r=o.getBoundingClientRect();r.width&&r.height&&U(o,{x:(n.clientX-r.left)/r.width,y:(n.clientY-r.top)/r.height})}function G(t){e.state.paused!==t&&(e.state.paused=t,t&&!m?B(null):!t&&k&&!m&&B(k),e.m())}let Z=!1,J=null,X=()=>J??e.state.paused,Q=()=>{Z=!1,J=e.state.paused},ee=()=>setTimeout(()=>J=null),te=n=>{if(e.M(n)||e.state.paused)return;if(!z(n))return void(m||B(null));if(n.stopPropagation(),m||e.state.t)return;let o=!Ze()&&n.target instanceof Element?kn(n.target,e.root,t):null;if(k){if(!o||o===k||(A+=Math.abs(n.movementX)+Math.abs(n.movementY),A<=4))return;ve()}o&&(L=o),B(o)},ne=()=>{Ze()&&(k&&ve(),m||B(null))},oe=e=>{!z(e)||X()||(e.stopPropagation(),("pointerdown"===e.type||"mousedown"===e.type)&&e.target instanceof Element&&e.target.closest(An)&&e.preventDefault())},re=n=>{if(!z(n))return;if(X())return e.fe(n);let o=n.target;!(o===R||o.form&&o.form===R?.form)||"submit"!==n.type&&("click"!==n.type||n.detail)?(n.preventDefault(),n.stopPropagation(),"click"===n.type&&!e.state.l&&!e.Ye(n)&&function(n){if(D)return _(n);let o=window.getSelection();if(o&&!o.isCollapsed)return void(n.detail>1&&g&&e.state.t===g&&e.E()&&e.ce());let r=n.target instanceof Element?kn(n.target,e.root,t):null;if(e.state.t&&!e.E())return r||n.altKey?e.te():e.U();if(e.state.t&&n.altKey)return e.U();if(n.altKey||!e.ue(n.clientX,n.clientY)){if(e.state.i&&e.open(null),k&&n.detail&&ve(),n.altKey)return void _(n);r&&(L=r),r?U(r):(e.U(),W(null))}}(n)):R="click"===n.type&&"submit"===o.type?o.form:null},ie=t=>{if(t.key!==Ht&&(Z=!0),(e=>{if(e.key!==Ht||e.ctrlKey||e.metaKey||e.altKey||e.isComposing)return!1;let t=e.composedPath()[0];if(i.some(e=>e===t))return!0;let n=t instanceof Element?t.closest(An):null;return!n||!Z&&!n.matches("input,textarea,select,[contenteditable]:not([contenteditable=false])")})(t)||t.key===Ht&&e.state.paused)return t.repeat||G(!0),t.preventDefault(),void t.stopPropagation();if(R=null,Te="","Escape"===t.key&&z(t)&&!t.isComposing&&!t.defaultPrevented&&!e.state.l&&!e.state.u)return t.preventDefault(),t.stopPropagation(),Te=t.key,e.z();if("Tab"===t.key&&function(t){if(t.ctrlKey||t.metaKey||t.altKey||t.isComposing||!e.M(t))return!1;let n=t.composedPath()[0],o=n instanceof Element?n.closest(".draft,.thread"):null,r=!!o?.classList.contains("draft");if(!o||!r&&o.closest(".all")||o.querySelector(".mnl.show")||o.querySelector(".nf :focus"))return!1;let i=t.shiftKey?-1:1;if(N=!0,r&&e.E())e.ce();else{let t=[...o.querySelectorAll("button,textarea,input,a[href]")].filter(e=>e.tabIndex>=0&&!e.closest("[inert],[hidden]")&&e.getClientRects().length>0),a=t.indexOf(n);if(a>=0&&(i>0?a<t.length-1:a>0))return N=!1,!1;r||e.open(null)}return N=!1,be(i),!0}(t))return t.preventDefault(),t.stopPropagation(),void(Te=t.key);if("Tab"===t.key&&ae(t))return t.preventDefault(),t.stopPropagation(),Te=t.key,e.U(),e.state.i&&e.open(null),e.state.l&&(e.state.l=!1,e.m()),be(t.shiftKey?-1:1);if(z(t)&&t.target instanceof Element)if("Enter"!==t.key&&" "!==t.key||!t.target.closest(Cn))"Enter"===t.key&&t.target.form&&(R=t.target);else{if(!k)return void(R=t.target);t.preventDefault(),t.stopPropagation()}},ae=t=>{if(t.ctrlKey||t.metaKey||t.altKey||t.isComposing)return!1;let n=t.composedPath()[0];return n instanceof Element&&!i.some(e=>e===n)&&(e.M(t)?!!n.closest(".launch,.menu")&&!n.closest("input,textarea,select,[contenteditable]"):!t.composedPath().some(e=>e instanceof Element&&e.matches(gn)))},le=()=>e.e.getRootNode().activeElement,se=()=>i.some(e=>e===le()),de=t=>{let n=e.e.getRootNode().host?.parentElement;return(!1!==t.checkVisibility?.({opacityProperty:!0,visibilityProperty:!0})||"contents"===getComputedStyle(t).display)&&!t.closest("[inert]")&&(!n||n===document.documentElement||n.contains(t))&&e.f.w(e.f.view(t))},ce=()=>(q?.some(e=>!e.o.isConnected)&&(q=null),q??=Ln(e.root,t,de)),ue=e=>ce().find(t=>t.o===e),pe=(e,t=!1)=>{let n=e.getBoundingClientRect();return n.bottom>0&&n.top<window.innerHeight&&(!t||n.top>=0)},fe=()=>{let e=Mn(ce(),0);return e.find(e=>pe(e.o,!0))??e.find(e=>pe(e.o))??e[0]},me=t=>e.doc.threads().filter(n=>e._(n)&&t.contains(en(e,n))).sort(tn(e));function ge(t,o=!0){A=0;let r=ce(),a=r.find(e=>e.o===t);if(a&&!Mn(r,E).includes(a)&&(E=a.C),t!==k&&(T=-1),t!==m&&(m=null),k=t,B(t),K(t),t.scrollIntoView({block:"nearest",inline:"nearest",behavior:h?"auto":"smooth"}),!o)return;e.Ge();let l=i[S^=1];(function(e,t){let[o,r]=e.children,i=Mn(ce(),E),a=me(t).length;o.textContent=`${ke(t)}, ${i.findIndex(e=>e.o===t)+1} of ${i.length}${a?`, has ${a} comment${1===a?"":"s"}`:""}`;let l=(t.innerText??t.textContent??"").length<=150;r.textContent=Se(t);let s=P?[n]:[];P=!1,void 0!==e.ariaLabelledByElements?(e.ariaLabelledByElements=l?[o,t]:[o,r],e.ariaDescribedByElements=l?s:[...s,t]):e.setAttribute("aria-label",`${o.textContent}, ${r.textContent}`)})(l,t),Xe(l,t.getBoundingClientRect(),4),l.inert=!1,l.focus({preventScroll:!0}),i[1^S].inert=!0}function ve(){let e=se();L=k,k=null,B(null),K(null);for(let e of i)_e(e,!0);return e}function we(e){let t=ue(e);return t?((e,t)=>e.filter(e=>e.B===t))(ce(),t):[]}function ye(e){let t=Mn(ce(),E),n=t.findIndex(e=>e.o===k),o=t[n<0?e>0?0:t.length-1:(n+e+t.length)%t.length];o&&ge(o.o)}function be(t){if(k)return ye(t);q=null;let n=document.activeElement;M=le()??n;let o,r=L?.isConnected?L:null,i=r&&ue(r);if(i){E=i.C;let e=Mn(ce(),E),n=e.indexOf(i);o=e[(n+t+e.length)%e.length]}else if(r){E=0;let e=Mn(ce(),0),n=e=>0!==(r.compareDocumentPosition(e.o)&Node.DOCUMENT_POSITION_FOLLOWING),i=e=>e.o.contains(r);o=t>0?e.find(e=>n(e)&&!i(e))??e[0]:e.filter(e=>!n(e)&&!i(e)).pop()??e[e.length-1]}else o=fe(),o&&(E=o.C);if(!o)return e.L("Nothing here to comment on");$=!0,ge(o.o)}function xe(){let n=m??k,o=n&&En(n,e.root,t);return o?((!C||!n.contains(C))&&(C=n),m?Y(o):void ge(o)):e.L("Nothing around it")}function Ee(){let t=m??k,n=t?we(t):[],o=n.find(e=>C&&e.o.contains(C))??n.find(e=>pe(e.o))??n[0];if(!o)return e.L("Nothing inside it");m?Y(o.o):ge(o.o)}function Le(t=!1){if(!k)return;if(e.state.t&&!e.E())return e.te();if(!t)return U(k);let n=me(k);if(!n.length)return e.L("No comments on this block");T=(T+1)%n.length,e.open(n[T].id),n.length>1&&e.L(`Comment ${T+1} of ${n.length} on this block`)}function Me(t){if(["Tab","ArrowUp","ArrowDown","Enter","Escape"].includes(t.key)&&(!t.key.startsWith("Arrow")||!(t.metaKey||t.ctrlKey||t.altKey))){if(t.preventDefault(),t.stopPropagation(),Te=t.key,"Escape"===t.key)return void e.z();if("Enter"===t.key)return Le(t.shiftKey);"Tab"===t.key&&e.U(),e.state.i&&e.open(null),"Tab"===t.key?ye(t.shiftKey?-1:1):"ArrowUp"===t.key?xe():Ee()}}function Ce(){let t=e.state.t,n=!!k&&!!t&&!e.E(),o=n&&t===g&&t.resolved.element!==k?t.resolved.element:null;r.classList.toggle("show",!!o&&de(o)),o&&Xe(r,o.getBoundingClientRect(),4),e.e.querySelector(".draft")?.classList.toggle("wait",n&&t?.resolved.element!==k)}let Ae=()=>{let e=le();return e?!!e.closest("[inert]"):!document.activeElement||document.activeElement===document.body},Te="",Pe=!1,qe=t=>{if(Pe&&window.removeEventListener("keyup",qe,!0),t.key===Ht&&e.state.paused)return G(!1),t.preventDefault(),void t.stopPropagation();t.key===Te&&(Te="",t.preventDefault(),t.stopPropagation())},Re=()=>G(!1);window.addEventListener("keyup",qe,!0),window.addEventListener("blur",Re),window.addEventListener("pointermove",te,!0),window.addEventListener("pointerdown",Q,!0);for(let e of qn)window.addEventListener(e,ee,!0);document.addEventListener("selectionchange",ne);for(let e of Pn)window.addEventListener(e,oe,!0);for(let e of Tn)window.addEventListener(e,re,!0);return window.addEventListener("keydown",ie,!0),{z:()=>!!m&&(W(null),!0),he:()=>null!==k,Xe:()=>$&&!k,Le:function(){q=null;let t=document.activeElement;M=le()??t;let n=ue(L),o=n??(t&&t!==document.body&&e.root.contains(t)&&!t.closest(gn)?ce().filter(e=>e.o.contains(t)).pop():void 0)??fe();return!!o&&(n||(E=o.C),$=!0,ge(o.o),!0)},ge(){k&&!se()&&ge(k)},m(){if(q=null,k&&(!k.isConnected||!de(k))){let e=fe();e?ge(e.o,se()||Ae()):ve()}let t=e.e.querySelector(".launch");if(t&&u.nextElementSibling!==t&&!se()&&!u.contains(le()))for(let n of[r,o,...i,u])e.e.insertBefore(n,t);let n=e.state.t;g&&n!==g?(g=null,W(null),k&&ge(k,Ae()&&!N)):(n||e.state.i)&&!g&&(f||m)&&W(null);let a=g?.anchor.point?null:g?.resolved.element;m&&!de(m)?W(null):!m&&!k&&a&&n===g&&de(a)&&W(a),Ce()},toDraft(){let t=g,n=t?.resolved.element;!t||!n||e.state.t!==t||(k&&(k=n,T=-1),L=n,W(t.anchor.point?null:n),n.scrollIntoView({block:"nearest",inline:"nearest",behavior:h?"auto":"smooth"}))},adopt(e){g=e;let t=e.resolved.element;k&&t&&(k=t),W(e.anchor.point?null:t)},O(){Ce(),O(),H(),k&&Xe(i[S],k.getBoundingClientRect(),4)},destroy(){ve()&&function(){let t=M;t&&t!==document.body&&t.isConnected&&t.focus?.({preventScroll:!0}),(!t||t===document.body||!t.matches?.(":focus"))&&e.e.querySelector(".launch .mode")?.focus({preventScroll:!0})}();for(let e of i)e.remove();r.remove(),e.e.querySelector(".draft")?.classList.remove("wait"),y(),x(),e.state.pinning=!1,Pe=!0,Te||window.removeEventListener("keyup",qe,!0),window.removeEventListener("blur",Re),window.removeEventListener("pointermove",te,!0),window.removeEventListener("pointerdown",Q,!0);for(let e of qn)window.removeEventListener(e,ee,!0);document.removeEventListener("selectionchange",ne);for(let e of Pn)window.removeEventListener(e,oe,!0);for(let e of Tn)window.removeEventListener(e,re,!0);window.removeEventListener("keydown",ie,!0),o.classList.remove("show"),u.classList.remove("show"),_e(u,!0),I(o,()=>o.remove()),I(u,()=>u.remove())}}}(re)):(K(),L?.destroy(),L=null,V("Comment mode off")),ye(),L&&(t&&L.Le(),t?L.he()?H=()=>j(Rn,1e4,!0,!0):j("Nothing here to comment on"):H=Zt()?B:()=>j(`Click anything to comment, or Tab between blocks \xb7 Option-click (Alt-click) to pin \xb7 Hold Space to use the page \xb7 ${Ot} or Esc to finish`,4e3,!0)))}function Ie(){let t=window.getSelection();y.p&&t&&!t.isCollapsed&&e.root.contains(t.anchorNode)?t.removeAllRanges():y.t&&re.E()?He():y.i?ze(null):L&&!L.z()&&Fe(!1)}function Be(){y.t?Ae()||He():y.i&&ze(null)}function je(e){let t=p.get(e);if(!t||"orphaned"===t.state)return;let n=!1===t.element?.checkVisibility?.(),o=n?t.element.closest("details:not([open])")?.querySelector("summary"):t.element;Ke(()=>t.range&&!n?Kt(t):o?[o.getBoundingClientRect()]:[])}let We=new Set;function Ke(e){let t=e().slice(0,6).map(()=>s.e.insertBefore(Ye("div",{class:"pulse"}),s.e.firstChild)),n={els:t,at:e};We.add(n),Ue(n),window.setTimeout(()=>{We.delete(n);for(let e of t)e.remove()},1300)}function Ue(e){let t=e.at();e.els.forEach((e,n)=>t[n]&&Xe(e,t[n],4))}function Ge(){X();let e=!!xe()?.closest(".rbox");for(let e of $)e.destroy();$=function(e){return[..."column"===e.state.mode?[un(e),hn(e,{pe:!1})]:[hn(e,{pe:!0})],Dn(e),Fn(e)]}(re),ye(),y.i&&Q(y.i,e)}Ve.go=t=>{if(t.startsWith("slide:"))return void z.Z({slide:t.slice(6)});let n=decodeURIComponent(t.slice(6)).replace(/\s+/g," ").toLowerCase(),o=[...e.root.querySelectorAll("p,li,h1,h2,h3,h4,h5,h6,td,th,blockquote,figcaption,dt,dd")].find(e=>(e.textContent??"").replace(/\s+/g," ").toLowerCase().includes(n));o&&(o.scrollIntoView({block:"center",behavior:c?"auto":"smooth"}),window.setTimeout(()=>Ke(()=>[o.getBoundingClientRect()]),c?0:450))};let Je=()=>{if(!M){if(H&&!y.l&&(!b.classList.contains("show")||O)){let e=H;H=null,e()}ge&&(performance.now()>ge&&(ge=0),ve=!0,dispatchEvent(new Event("resize")),ve=!1);for(let e of $)e.O();for(let e of We)Ue(e);L?.O(),ie.O(),q=requestAnimationFrame(Je)}},Qe=e=>{let t=e.composedPath()[0];return t instanceof Element&&null!==t.closest(Ee)},et=e=>{if("Escape"===e.key)return e.isComposing?void 0:Ie();if(x&&"KeyZ"===e.code&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey){let t=e.composedPath()[0];if(!Qe(e)||t instanceof HTMLTextAreaElement&&t.getRootNode()===s.shadow&&""===t.value)return e.preventDefault(),x()}if(function(e){return"KeyC"===e.code&&e.shiftKey&&e.altKey&&!e.metaKey&&!e.ctrlKey&&!e.repeat&&!e.getModifierState("AltGraph")}(e)&&!e.isComposing&&!e.defaultPrevented&&!Qe(e)){if(e.preventDefault(),L?.Xe()&&L.Le())return;Fe(!y.p,!0)}},tt=e=>{if(re.M(e)||f.has(e))return;let t=window.getSelection();t&&!t.isCollapsed||Be()},nt=window.innerWidth,ot=0;function rt(){let e=y.i?p.get(y.i):y.t?.resolved,t=(e?.range??e?.element)?.getBoundingClientRect();t&&(t.top<0||t.bottom>window.innerHeight)&&window.scrollBy({top:t.top-16,behavior:c?"auto":"smooth"})}let at=()=>{if(ve)return;window.innerWidth!==nt&&(nt=window.innerWidth,window.clearTimeout(ot),ot=window.setTimeout(rt,200)),s.e.style.setProperty("--pu-pop",`${_t()}px`);let t=ho(e.root,"column"===y.mode);t!==y.mode?(y.mode=t,Ge()):ye()};function lt(){let e=performance.now();0===A&&(T=e),window.clearTimeout(A);let t=Math.min(120,Math.max(0,T+1e3-e));A=window.setTimeout(()=>{A=0,ae(),ye()},t)}let st=[],dt=/^(video|canvas|iframe|img|object|embed|audio)$/,ct=new MutationObserver(()=>ht()),ut=null,pt=0;function ht(){let e=function(){let e=new Set;try{for(let t of document.querySelectorAll("dialog:modal"))e.add(t);for(let t of st)"dialog"===t.localName&&t.isConnected&&t.matches(":modal")&&e.add(t);let t=document.activeElement;for(;t?.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;for(;t;){let n=t.closest("dialog");n?.matches(":modal")&&e.add(n);let o=t.getRootNode();t=o instanceof ShadowRoot?o.host:null}}catch{}let t=document.fullscreenElement;for(;t?.shadowRoot?.fullscreenElement;)t=t.shadowRoot.fullscreenElement;return t&&t!==document.documentElement&&t!==document.body&&!dt.test(t.localName)&&e.add(t),[...e]}();st=[...st.filter(t=>e.includes(t)),...e.filter(e=>!st.includes(e))];let t=st.at(-1),n=t&&!(e=>{let t=getComputedStyle(e),n=(e,n="none")=>![n,""].includes(t.getPropertyValue(e));return["transform","translate","scale","rotate","perspective","filter","backdrop-filter"].some(e=>n(e))||n("container-type","normal")||/paint|layout|strict|content/.test(t.contain)||/transform|translate|scale|rotate|perspective|filter/.test(t.willChange)})(t)?t:document.documentElement;ct.disconnect();for(let e of st)e.getRootNode()!==document&&ct.observe(e,{attributeFilter:["open"]});if(s.element.parentNode===n)return;let o=!s.element.isConnected;n.append(s.element),o&&ut?.isConnected&&performance.now()-pt<100&&ut.focus({preventScroll:!0})}let ft=new MutationObserver(e=>{e.some(e=>e.removedNodes.length)&&ht(),!e.every(e=>s.element.contains(e.target)||(e=>"childList"===e.type&&e.addedNodes.length+e.removedNodes.length>0&&[...e.addedNodes,...e.removedNodes].every(e=>e===s.element))(e))&&lt()}),mt=e=>{let t=e.key,n=t=>e.composedPath().some(e=>e instanceof Element&&e.matches(t));("Enter"===t||" "===t||po.includes(t)&&n(".menu,.all,.pm")||t.startsWith("Arrow")&&n(".menu"))&&e.stopPropagation()};for(let e of["keydown","keyup","keypress"])s.e.addEventListener(e,mt);let gt=e=>e===s.element,vt=e=>{"focusin"===e.type&&ht(),gt(e.target)&&("focusin"===e.type&&(ut=e.composedPath()[0]),pt="focusin"===e.type?1/0:performance.now()),("focusin"===e.type?gt(e.target)&&!gt(e.relatedTarget):gt(e.relatedTarget)&&!gt(e.target))&&e.stopImmediatePropagation()},bt=null,kt=!1;s.shadow.addEventListener("keydown",e=>{e===bt&&(kt=!0)});let Et=e=>{if(!(e=>{let t=e.composedPath();if(!t.includes(s.element))return!1;let n=t[0];if(n instanceof Element&&n.matches(Ee))return!0;let o=e.key,r=e=>t.some(t=>t instanceof Element&&t.matches(e));return["Escape","Tab","Enter"," "].includes(o)||po.includes(o)&&r(".menu,.all,.pm,.rxp")||o.startsWith("Arrow")&&r(".menu,.rxp")})(e)||(e.stopImmediatePropagation(),"keydown"!==e.type))return;let t=bt=new KeyboardEvent("keydown",{key:e.key,code:e.code,location:e.location,repeat:e.repeat,isComposing:e.isComposing,ctrlKey:e.ctrlKey,shiftKey:e.shiftKey,altKey:e.altKey,metaKey:e.metaKey,bubbles:!0,cancelable:!0});kt=!1,e.composedPath()[0].dispatchEvent(t),bt=null,t.defaultPrevented&&e.preventDefault(),kt&&et(e)},St=e=>e.stopPropagation(),$t=["pointerdown","mousedown","touchstart","click","focusin","focusout"];for(let e of["focusin","focusout"])window.addEventListener(e,vt,!0);for(let e of $t)s.element.addEventListener(e,St);for(let e of["keydown","keyup","keypress"])document.addEventListener(e,Et,!0);document.addEventListener("fullscreenchange",ht);let Lt=()=>st.length&&ht();for(let e of["transitionend","animationend"])window.addEventListener(e,Lt,!0);window.addEventListener("keydown",et),window.addEventListener("click",tt),window.addEventListener("resize",at),ft.observe(e.root,{subtree:!0,childList:!0,characterData:!0});let Mt=0,Ct=t=>{let n="dark"===t;s.e.classList.toggle("flip",n!==i),n!==r&&(r=n,window.clearTimeout(Mt),s.e.classList.add("fading"),Mt=window.setTimeout(()=>{no(s.e,to(e.root,t)),s.e.classList.remove("fading")},170))},Tt=()=>{Ct(l()),de=new WeakMap,se(G())},Pt=0,qt=()=>{Pt||(Pt=window.setTimeout(()=>{Tt(),Pt=window.setTimeout(()=>{Pt=0,Tt()},450)},150))},Rt=new MutationObserver(e=>{e.some(e=>"open"===e.attributeName&&"dialog"===e.target.localName)&&ht(),!e.every(e=>e.target===s.element)&&qt()});Rt.observe(document.documentElement,{attributes:!0,subtree:!0});let Nt=window.matchMedia?.("(prefers-color-scheme: dark)");Nt?.addEventListener?.("change",qt);let Dt=new ResizeObserver(lt);Dt.observe(e.root);let zt=e.doc.onChange((e,t,n)=>{ie.De(t,n),ae(),ye()});return ae(),Ge(),ht(),q=requestAnimationFrame(Je),{ctx:re,appearance:()=>o,destroy(){M=!0,cancelAnimationFrame(q),cancelAnimationFrame(pe),cancelAnimationFrame(F),z.destroy(),window.clearTimeout(me),window.clearTimeout(C),window.clearTimeout(ot),window.clearTimeout(A),window.clearTimeout(P),ft.disconnect(),Ve.go=void 0,Dt.disconnect(),Rt.disconnect(),Nt?.removeEventListener?.("change",qt),window.clearTimeout(Pt),window.clearTimeout(Mt),zt(),window.removeEventListener("keydown",et),window.removeEventListener("click",tt);for(let e of["focusin","focusout"])window.removeEventListener(e,vt,!0);for(let e of["keydown","keyup","keypress"])document.removeEventListener(e,Et,!0);document.removeEventListener("fullscreenchange",ht);for(let e of["transitionend","animationend"])window.removeEventListener(e,Lt,!0);ct.disconnect(),window.removeEventListener("resize",at),L?.destroy();for(let e of $)e.destroy();ie.destroy(),d.remove(),s.destroy()}}}var vo=null;function wo(e={}){if(qt)return qt.mount(e);if(!Dt())return Promise.reject(new Error("pipeup: another copy of Pipeup owns the add-on queue. Remove one script."));if(vo)return vo;let t=async function(e,t){let n,o,r=document.documentElement.getAttribute("data-pipeup-doc"),{id:a,key:l}=r?await j(r):{id:`page-${i(location.origin+location.pathname)}`,key:null},s=!1;if(e.store)n=e.store,o=await Q(n);else try{let e=ee.open();n=await function(e){return new Promise((t,n)=>{let o=setTimeout(()=>n(new Error("timed out")),4e3);e.then(t,n).finally(()=>clearTimeout(o))})}(e).catch(t=>{throw e.then(e=>e.close(),()=>{}),t}),o=await Q(n)}catch{n=new X,s=!0,o=await Q(n)}let d=e.name?.trim();d&&d!==o.name&&(o={...o,name:d},await n.saveProfile(o)),navigator.storage?.persist?.().catch(()=>{});let c,u=await _.open({doc:a,key:l,store:n,identity:o.identity,name:o.name});Yn(e.slides??null);try{c=go({doc:u,styles:':host{all:initial;direction:ltr;unicode-bidi:normal}*{box-sizing:border-box}button{appearance:none;font:inherit;color:inherit;background:none;border:0;padding:0;cursor:pointer}svg{display:block}.layer{all:initial;direction:ltr;unicode-bidi:normal;display:block;position:fixed;inset:0;pointer-events:none;font:13px/1.5 var(--pu-font,system-ui,sans-serif);color:var(--k);--k:#2C2C2A;--mu:#5F5E5A;--fa:#6B6A64;--ln:#E5E3DA;--ru:#ECEAE2;--so:#FAFAF7;--su:#FFFFFF;--ho:#F1EFE8;--as:color-mix(in srgb,var(--pu-accent,#534AB7) 12%,transparent);--sh:0 8px 28px rgba(44,44,42,.1);--in:.26s;--mv:.34s;--out:.2s;--pl:1.2s;--eo:cubic-bezier(.22,.61,.36,1);--eio:cubic-bezier(.4,0,.2,1);--ei:cubic-bezier(.4,0,1,1);--pu-text:var(--k);--pu-muted:var(--mu);--pu-faint:var(--fa);--pu-line:var(--ln);--pu-surface:var(--su);--pu-soft:var(--so);--pu-hover:var(--ho);--pu-shadow:var(--sh);--pu-ease:var(--eo)}.layer{transition:opacity .24s var(--eo)}.layer.fading{opacity:0;transition-duration:.16s;transition-timing-function:var(--ei)}.layer.dark{--k:#ECEBE6;--mu:#B4B2A9;--fa:#9A9892;--ln:#3A3936;--ru:#34332F;--so:#22221F;--su:#1B1B19;--ho:#2C2C29;--sh:0 8px 28px rgba(0,0,0,.45)}.layer.hidden .bub,.layer.hidden .col,.layer.hidden .pop,.layer.hidden .tip,.layer.hidden .mark,.layer.hidden .selbar{opacity:0!important;pointer-events:none!important}.tx{font-size:14px;line-height:1.5;color:var(--k);white-space:pre-wrap;overflow-wrap:anywhere}.tx.del,.rest,.ctx,.ago{color:var(--fa)}.rest,.ago{font-size:12px}.rest{display:block;margin-top:3px}.hdr{position:relative;display:flex;align-items:center;gap:7px;min-height:22px}.who{min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-weight:600;color:var(--k)}.ago{flex:none;white-space:nowrap}.ago:before{content:"\\b7";margin-right:6px}.root>.tx,.it>.tx,.root>.ctx{margin-top:2px}.ctx[hidden]{display:none}.ctx{font-size:12px;margin-bottom:3px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.cd>.thread .tx,.clamp{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.th.long .root>.tx{max-height:var(--full);overflow:hidden;transition:max-height var(--mv) var(--eio)}.th.long:not(.on) .root>.tx{max-height:84px;mask-image:linear-gradient(#000 calc(100% - 21px),transparent)}.mr{display:grid;grid-template-rows:0fr;opacity:0;font-size:12px;color:var(--pu-accent);text-align:end;transition:grid-template-rows var(--mv) var(--eio),opacity var(--in) var(--eo)}.mr>span{min-height:0;overflow:hidden}.th.long:not(.on) .mr{grid-template-rows:1fr;opacity:1}.tx a{color:var(--pu-accent);text-decoration:underline;text-decoration-thickness:1px;text-underline-offset:2px}.acts{margin-left:auto;display:flex;flex:none;transition:opacity var(--in) var(--eo)}.th:not(.on):not(:hover):not(:focus-within) .acts,.cd:not(.open):not(:hover):not(:has(:focus-visible,.pm)) .acts,.still .th:not(.on):not(:has(:focus-visible)) .acts,.still .cd:not(.open):not(:has(:focus-visible,.pm)) .acts{opacity:0;pointer-events:none}.th:not(.on) .acts,.cd:not(.open) .acts{position:absolute;right:0;padding-left:16px;background:linear-gradient(90deg,transparent,var(--bg) 14px);transition:opacity var(--in) var(--eo),pointer-events 0s var(--in);transition-behavior:allow-discrete}.th.on .rest{display:none}.pm{position:absolute;right:0;top:100%;z-index:5;display:flex;flex-direction:column;min-width:150px;padding:4px;border:1px solid var(--ln);border-radius:10px;background:var(--su);box-shadow:var(--sh)}.pm.in{animation:pu-in var(--in) var(--eo) both}.pm button{padding:6px 10px;border-radius:7px;text-align:left;font-size:13px;transition:background-color .2s var(--eo),color .2s var(--eo)}.pm button:hover,.pm button:focus-visible{background:var(--ho)}.pm .dl{color:#c9402f}.dark .pm .dl{color:#f08a7e}.edit{margin-top:2px}.ib{width:24px;height:22px;display:grid;place-items:center;border-radius:6px;color:var(--mu);transition:background-color .2s var(--eo),color .2s var(--eo)}.ib:hover,.ib:focus-visible{background:var(--ho);color:var(--k)}.rps,.rbox{padding-left:14px}.rps .it{padding-top:8px}.more{display:grid;grid-template-rows:1fr;transition:grid-template-rows var(--mv) var(--eio)}.more>div{overflow:hidden;min-height:0}.th:not(.on) .more{grid-template-rows:0fr}.row{position:relative;padding-top:6px}.line{display:flex;align-items:center;gap:6px;padding:3px 12px;border:1px solid var(--ln);border-radius:16px;cursor:text;transition:border-color var(--in) var(--eo),box-shadow var(--in) var(--eo)}.line:hover{border-color:var(--mu)}.line:focus-within{border-color:var(--pu-accent);box-shadow:0 0 0 1px var(--pu-accent)}.input{flex:1;min-width:0;height:24px;display:block;border:0;outline:none;resize:none;overflow:hidden;font:inherit;font-size:14px;line-height:1.5;padding:1px 0;color:var(--k);background:transparent}.input::placeholder{color:var(--fa);opacity:1}.bts{display:flex;justify-content:flex-end;gap:4px;max-height:0;opacity:0;overflow:hidden;transition:max-height var(--in) var(--eo),opacity var(--in) var(--eo),padding var(--in) var(--eo)}.row:focus-within .bts,.row.has .bts{max-height:40px;opacity:1;padding-top:4px}.bts button{padding:2px 10px;border-radius:14px;font-size:13px;font-weight:600;color:var(--pu-accent);transition:background-color .2s var(--eo),color .2s var(--eo)}.cnl:hover,.cnl:focus-visible{background:var(--as)}.send{background:var(--pu-accent);color:var(--pu-on,#fff)!important}.send:not(.show){background:var(--ru);color:var(--fa)!important;cursor:default}.ed{display:flex;gap:10px;align-items:center;min-height:34px;padding:6px 10px}.ed .input,.nf .input{font-size:13px;height:22px;border-bottom:1px solid var(--ln)}.ed .input:focus,.nf .input:focus{border-bottom-color:var(--pu-accent)}.av{flex:none;display:grid;place-items:center;width:22px;height:22px;border-radius:32%;font-size:12px;font-weight:600;line-height:1;opacity:0;transform:scale(.85);transition:opacity var(--in) var(--eo),transform var(--in) var(--eo)}.av.in{opacity:1;transform:none}.av svg{width:122%;height:122%;stroke-width:1.3}.av{--av-l:92%;--av-d:30%;--s:60%;background:hsl(var(--h) var(--s) var(--av-l));color:hsl(var(--h) var(--s) var(--av-d))}.dark .av{--av-l:20%;--av-d:78%}.av.ai{position:relative;border-radius:50%;background:var(--su);color:var(--pu-accent);font-size:9px;letter-spacing:.02em}.av.ai:before{content:"";position:absolute;inset:3px;border-radius:50%;border:1.5px solid var(--pu-accent);pointer-events:none}.refs{display:flex;flex-wrap:wrap;gap:4px;margin-top:6px;white-space:normal}.refs .ref{display:inline-flex;align-items:center;gap:5px;max-width:160px;padding:1px 9px;border:1px solid var(--ln);border-radius:999px;background:var(--so);color:var(--mu);font:inherit;font-size:11.5px;line-height:1.6;text-decoration:none;cursor:pointer;transition:background-color .2s var(--eo),color .2s var(--eo),border-color .2s var(--eo)}.refs .ref:hover,.refs .ref:focus-visible{background:var(--as);color:var(--pu-accent);border-color:var(--pu-accent)}.ref span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.rxp{position:fixed;width:320px;height:340px;border-radius:12px;overflow:hidden;pointer-events:none;opacity:0;transform:translateY(4px);transition:opacity var(--in) var(--eo),transform var(--in) var(--eo)}.rxp.show{opacity:1;transform:none;pointer-events:auto}.mn{border-radius:4px;padding:0 2px;background:var(--as);color:var(--pu-accent)}.mn.me{font-weight:600}.mnl{position:absolute;left:0;bottom:100%;margin:0 0 4px;padding:4px;list-style:none;min-width:180px;max-width:100%;border:1px solid var(--ln);border-radius:10px;background:var(--su);box-shadow:var(--sh);opacity:0;transform:translateY(4px);pointer-events:none;z-index:4;transition:opacity var(--in) var(--eo),transform var(--in) var(--eo)}.mnl.show{opacity:1;transform:none;pointer-events:auto}.mnl li{display:flex;align-items:baseline;gap:8px;padding:5px 8px;border-radius:6px;font-size:13px;color:var(--k);cursor:pointer}.mnl li small{font-size:11px;color:var(--fa)}.mnl li.on,.mnl li:hover{background:var(--as);color:var(--pu-accent)}.dlg{position:fixed;left:50%;top:18vh;width:min(380px,calc(100vw - 32px));padding:16px 18px;border:1px solid var(--ln);border-radius:14px;background:var(--su);box-shadow:var(--sh);color:var(--k);opacity:0;transform:translate(-50%,6px);pointer-events:none;transition:opacity var(--in) var(--eo),transform var(--in) var(--eo)}.dlg.show{opacity:1;transform:translate(-50%);pointer-events:auto}.toast.act{display:flex;align-items:center}.toast.show .ta{pointer-events:auto}.toast .ta{transition:visibility 0s .3s}.toast:not(.show) .ta{visibility:hidden}.toast.show .ta{transition-delay:0s}.ta{margin-left:4px;color:var(--pu-accent);text-decoration:underline;text-underline-offset:2px}.rx .n{font-size:11px;font-variant-numeric:tabular-nums}.rx.mine{background:var(--as);color:var(--pu-accent);border-color:var(--pu-accent)}.rx:disabled{cursor:default;opacity:.7}.rx{-webkit-touch-callout:none;-webkit-user-select:none}.rx.new,.rxq.new{animation:pu-in var(--mv) var(--eo) backwards}.rxs{align-items:center}.rxq{display:inline-flex;gap:2px}.rxo{padding:2px 5px;border-radius:8px;font-size:16px;line-height:1.3;transition:background-color .2s var(--eo)}.rxo:hover,.rxo:focus-visible,.rxo[aria-pressed=true]{background:var(--as)}.refs .ref{position:relative}.ref .rc{position:absolute;left:0;top:calc(100% + 6px);z-index:3;width:max-content;max-width:min(240px,70vw);padding:6px 9px;border:1px solid var(--ln);border-radius:8px;background:var(--su);box-shadow:var(--sh);color:var(--k);font-size:12px;line-height:1.45;white-space:normal;text-align:left;overflow:visible;opacity:0;visibility:hidden;transform:translateY(-3px);pointer-events:none;transition:opacity .2s var(--eo),transform .2s var(--eo),visibility 0s .2s}.ref:hover .rc,.ref:focus-visible .rc,.ref.held .rc{opacity:1;visibility:visible;transform:none;transition-delay:0s}.ref .sl{width:10px;height:7px;border:1.3px solid currentColor;border-radius:2px;flex:none}.seen{display:flex;align-items:center;gap:6px;padding:6px 0 0 14px;font-size:12px;color:var(--fa)}.seen button{margin-left:auto;padding:0 6px;border:0;border-radius:6px;background:none;color:var(--fa);font:inherit;cursor:pointer;transition:color .2s var(--eo),background-color .2s var(--eo)}.seen button:hover,.seen button:focus-visible{color:var(--pu-accent);background:var(--as)}.seen i{width:12px;height:12px;border-radius:50%;border:1.5px solid var(--pu-accent);flex:none}.c0{--h:0}.c1{--h:25}.c2{--h:50}.c3{--h:130}.c4{--h:175}.c5{--h:215}.c6{--h:270}.c7{--h:330}.c8{--h:28;--s:35%}.c9{--h:220;--s:8%}button.me{flex:none;display:grid;place-items:center}button.me>.av{grid-area:1/1}.you{flex:1;display:grid;min-width:0;min-height:22px;font-size:12px;color:var(--fa)}.you .nm{font-size:13px;font-weight:600;color:var(--k)}.you>*{grid-area:1/1;display:flex;align-items:center;min-width:0;transition:opacity var(--in) var(--eo),transform var(--in) var(--eo)}.say{white-space:pre;overflow:hidden}.nm{min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.say button{flex:none}.say button{color:var(--mu);text-decoration:underline;text-decoration-color:var(--ln);text-underline-offset:2px;transition:color .2s var(--eo)}.say button:hover,.say button:focus-visible{color:var(--pu-accent)}.nf{opacity:0;transform:translateY(-4px);pointer-events:none}.nf .input{font-size:13px;height:24px}.you.naming .nf{opacity:1;transform:none;pointer-events:auto}.you.naming .say{opacity:0;pointer-events:none}.bub{position:fixed;left:0;top:0;width:20px;height:20px;margin:-20px 0 0 -2px;border-radius:50% 50% 50% 0;background:var(--pu-accent);border:2px solid var(--su);box-shadow:0 1px 4px #0003;pointer-events:auto;opacity:0;transform:translateY(-6px) scale(.9);transform-origin:2px 20px;transition:opacity var(--out) var(--ei),transform var(--out) var(--ei)}.bub.in{opacity:1;transform:none;transition:opacity var(--in) var(--eo),transform var(--in) var(--eo)}.bub.in:hover,.bub.on{transform:scale(1.18)}.bub.done{background:var(--fa)}.bub.ghost{pointer-events:none}.tip,.pop,.menu,.all,.xp,.toast,.selbar,.namebar,.tt,.rxp{background:var(--su);border:1px solid var(--ln);box-shadow:var(--sh)}.tip{position:fixed;max-width:260px;border-radius:10px;padding:7px 10px;opacity:0;transform:translateY(3px);transition:opacity .22s var(--eo),transform .26s var(--eo)}.tip.show{opacity:1;transform:none;pointer-events:auto;cursor:pointer;transition:opacity .22s var(--eo),transform .26s var(--eo),left var(--mv) var(--eio),top var(--mv) var(--eio)}.pop{position:fixed;width:var(--pu-pop);border-radius:12px;padding:8px 10px 10px;pointer-events:none;opacity:0;transform:translateY(6px) scale(.98);transition:opacity var(--out) var(--ei),transform var(--out) var(--ei)}.pop.show{opacity:1;transform:none;pointer-events:auto;transition:opacity var(--in) var(--eo),transform var(--mv) var(--eo)}.pop.show.glide{transition:opacity var(--in) var(--eo),transform var(--mv) var(--eo),left var(--mv) var(--eio),top var(--mv) var(--eio)}.mark{position:fixed;border:2px solid color-mix(in srgb,var(--pu-accent) 50%,transparent);background:var(--as);border-radius:8px;opacity:0;transition:opacity .3s var(--eo)}.mark.show{opacity:1}.pulse{position:fixed;border:2px solid var(--pu-accent);border-radius:8px;background:var(--as);animation:pu-pulse var(--pl) var(--eio) forwards}@keyframes pu-pulse{0%{opacity:0;transform:scale(.985)}35%{opacity:.85;transform:scale(1)}to{opacity:0;transform:scale(1.02)}}.col{position:fixed;left:0;top:0;pointer-events:none;transition:opacity var(--in) var(--eo)}.th,.cd{--bg:var(--su);background:var(--bg);opacity:var(--o,1)}.th{position:absolute;left:0;right:0;top:0;padding:8px 10px 10px;border:1px solid var(--ln);border-radius:10px;pointer-events:auto;cursor:pointer;transition:transform var(--mv) var(--eio),box-shadow var(--in) var(--eo),border-color var(--in) var(--eo),opacity var(--in) var(--eo)}.th.hot{border-color:var(--mu)}.th.on{border-color:transparent;box-shadow:var(--sh);cursor:default}.th.dim{--o:.45}.th.resolved:not(.on):not(.hot){--o:.6}.th.lost .ctx{white-space:normal}.th.wait{opacity:0!important;pointer-events:none}.th:is(.out,.hop){opacity:0!important;pointer-events:none;transition:opacity var(--out) var(--ei)}.th:has(.opn:focus-visible){outline:2px solid var(--pu-accent);outline-offset:2px}.selbar{position:fixed;display:flex;border-radius:10px;padding:2px;opacity:0;transform:translateY(4px);pointer-events:none;transition:opacity var(--in) var(--eo),transform .3s var(--eo)}.selbar.show{opacity:1;transform:none;pointer-events:auto}.selbar button{width:32px;height:30px;display:grid;place-items:center;border-radius:8px;color:var(--pu-accent);transition:background-color .2s var(--eo)}.selbar button:hover,.selbar button:focus-visible{background:var(--as)}.pick{position:fixed;left:0;top:0;border:2px solid color-mix(in srgb,var(--pu-accent) 70%,transparent);background:color-mix(in srgb,var(--pu-accent) 6%,transparent);border-radius:8px;pointer-events:none;opacity:0;transition:opacity var(--out) var(--ei),border-color var(--out) var(--ei),border-width var(--out) var(--ei),box-shadow var(--out) var(--ei)}.pick.show{opacity:1;transition-duration:var(--in);transition-timing-function:var(--eo)}.pick.show.glide{transition-property:all;transition-duration:var(--mv);transition-timing-function:var(--eio)}.pick.on{border-color:var(--pu-accent)}.pkw{position:fixed;left:0;top:0;border:2px dashed color-mix(in srgb,var(--pu-accent) 70%,transparent);border-radius:8px;pointer-events:none;opacity:0;transition:opacity var(--out) var(--ei)}.pkw.show{opacity:.6;transition:opacity var(--in) var(--eo)}.draft{transition:opacity var(--in) var(--eo)}.draft.wait:not(:focus-within){opacity:.6}.pick.kf{border:3px solid var(--pu-accent);box-shadow:0 0 0 2px var(--su)}.km{position:fixed;left:0;top:0;pointer-events:none;outline:none}.sr,.mn-sr,.hh{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}.namebar{position:fixed;left:0;top:0;display:flex;align-items:center;gap:2px;max-width:calc(100% - 16px);padding:2px 2px 2px 10px;border-radius:10px;font-size:12px;color:var(--mu);white-space:nowrap;pointer-events:none;opacity:0;transform:translateY(4px);transition:opacity var(--out) var(--ei),transform var(--out) var(--ei)}.namebar.show{opacity:1;transform:none;pointer-events:auto;transition:opacity var(--in) var(--eo),transform .3s var(--eo)}.namebar.show.glide{transition-property:all;transition-duration:var(--mv);transition-timing-function:var(--eio)}.namebar:hover:not(:has(.nb:hover)){opacity:.15}.namebar .lbl{margin-right:6px;max-width:260px;overflow:hidden;text-overflow:ellipsis}.namebar .nb{padding:4px;display:grid;place-items:center;border-radius:7px;transition:background-color .2s var(--eo),color .2s var(--eo)}.namebar .nb:hover,.namebar .nb:focus-visible{background:var(--ho);color:var(--k)}.namebar .nb.on{background:var(--as);color:var(--pu-accent)}.namebar .nb[hidden]{display:none}.launch{position:fixed;right:0;bottom:var(--pu-lift);display:flex;flex-direction:row-reverse;align-items:center;border-top-left-radius:10px;pointer-events:auto;transform-origin:100% 100%;background:color-mix(in srgb,var(--su) 62%,transparent);-webkit-backdrop-filter:blur(10px) saturate(1.5);backdrop-filter:blur(10px) saturate(1.5);transition:opacity var(--in) var(--eo),transform var(--mv) var(--eo),background-color .3s var(--eo),color .3s var(--eo),bottom var(--mv) var(--eio)}.launch:has(.mode.on){background:color-mix(in srgb,var(--pu-accent) 90%,transparent);color:var(--pu-on,#fff)}.layer.listing .launch{opacity:0;transform:scale(.6);pointer-events:none}.menu.inp{--b:60px;right:8px;z-index:1}.menu.inp :is([data-item=comment],[data-item=all]){display:none}.launch .mode{position:relative;display:grid;place-items:center;width:32px;height:32px;border-radius:10px 0 0}.mode>*,.cnt>*{grid-area:1/1}.mode>*{display:grid;place-items:center;transition:opacity var(--in) var(--eo)}.cnt,.has>.plus{opacity:0}.has>.cnt{opacity:1}.cnt>.n{font-size:11px;font-weight:500;line-height:1;margin:-1.2px 0 0 1.2px;font-variant-numeric:tabular-nums lining-nums;opacity:0;transition:opacity var(--in) var(--eo)}.w>.n{margin-top:-3.4px}.cnt>svg{transition:opacity var(--in) var(--eo)}.cnt>svg+svg,.cnt.w>svg{opacity:0}.cnt.w>svg+svg{opacity:1}.n.on{opacity:1}.launch .mode:focus-visible{outline:2px solid var(--pu-accent);outline-offset:-2px}.mode>.dot{position:absolute;top:2px;right:2px;width:8px;height:8px;border-radius:50%;background:var(--pu-accent);opacity:0;transition:opacity var(--in) var(--eo),background-color .3s var(--eo)}.mode.else>.dot{opacity:1}.mode.on>.dot{background:var(--pu-on,#fff)}.ttip{display:grid;grid-template-columns:minmax(0,0fr);overflow:hidden;font-size:12px;color:var(--mu);pointer-events:none;opacity:0;transition:grid-template-columns var(--out) var(--ei),opacity var(--out) var(--ei)}.ttip>span{min-width:0;white-space:nowrap;padding-left:10px}.ttip small{font-size:12px}.ttip small,.mi .kc{color:var(--fa)}.launch:has(.mode.on) :is(.ttip,.ttip small){color:inherit}.launch:hover .ttip{grid-template-columns:minmax(0,1fr);opacity:1;transition:grid-template-columns var(--mv) var(--eo) .4s,opacity var(--in) var(--eo) .4s}.launch .mode[aria-expanded=true]+.ttip{grid-template-columns:minmax(0,0fr);opacity:0}@media(hover:none){.ttip,.tt,.cd>.thread .acts{display:none}}.menu{--b:calc(40px + var(--pu-lift));position:fixed;right:8px;bottom:var(--b);width:290px;border-radius:12px;padding:4px;pointer-events:none;opacity:0;transform:translateY(6px);transition:opacity var(--out) var(--ei),transform var(--out) var(--ei)}.menu.show{opacity:1;transform:none;pointer-events:auto;transition:opacity var(--in) var(--eo),transform var(--mv) var(--eo)}@media(max-height:600px){.menu{max-height:calc(100% - var(--b) - 8px);overflow-y:auto;overscroll-behavior:contain}}.mi{position:relative;display:flex;gap:10px;align-items:center;width:100%;min-height:34px;text-align:left;padding:6px 10px;border-radius:8px;transition:background-color .2s var(--eo)}.mi:hover,.mi:focus-visible{background:var(--so)}.mi svg{color:var(--mu);flex:none}.mi small{display:block;color:var(--fa);font-size:12px}.lb{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ma{flex:none;display:grid;margin:-2px 0}.ma .av{width:20px;height:20px;font-size:11px}.mi .av svg{color:inherit}.sep{height:1px;margin:4px 10px;background:var(--ru)}.subs{display:grid;grid-template-rows:0fr;opacity:0;transition:grid-template-rows var(--in) var(--eo),opacity var(--in) var(--eo)}.subs.open{grid-template-rows:1fr;opacity:1}.subs>div{min-height:0;overflow:hidden}.subs .mi{padding-left:30px}.chev{display:grid;transition:transform var(--in) var(--eo)}[aria-expanded=true]>.chev{transform:rotate(90deg)}.tt{position:absolute;right:calc(100% + 14px);top:50%;translate:0 -50%;width:max-content;max-width:220px;padding:4px 9px;border-radius:8px;font-size:12px;line-height:1.4;color:var(--mu);pointer-events:none;opacity:0;transform:translate(3px);transition:opacity var(--out) var(--ei),transform var(--out) var(--ei)}.mi:hover>.tt,.mi:focus-visible>.tt{opacity:1;transform:none;transition:opacity var(--in) var(--eo) .5s,transform var(--in) var(--eo) .5s}@media(max-width:600px){.tt{right:8px;top:auto;bottom:100%;translate:none;transform:translateY(3px)}}.sw{position:relative;flex:none;width:26px;height:16px;border-radius:8px;background:var(--ln);transition:background-color var(--mv) var(--eio)}.sw:before,.sw:after{content:"";position:absolute;top:2px;left:2px;width:12px;height:12px;border-radius:50%;background:#fff;box-shadow:0 1px 2px #00000040;transition:transform var(--mv) var(--eio),opacity var(--mv) var(--eio)}.sw:before{opacity:0;transform:translate(10px)}[aria-checked=true]>.sw{background:var(--pu-accent)}[aria-checked=true]>.sw:after{transform:translate(10px)}.tools{display:flex;flex:none;gap:2px}.tools[hidden]{display:none}.tool[aria-pressed=true]{background:var(--as);color:var(--pu-accent)}.note{display:block;padding:0 0 4px;font-size:12px;color:var(--fa)}.note[hidden]{display:none}.ov{position:absolute;inset:0;pointer-events:none;overflow:hidden}.xb{flex:1;overflow-y:auto;overscroll-behavior:contain;padding:4px 16px 16px;font-size:13px}.xb p{margin:0 0 10px}.all,.xp{position:fixed;top:0;right:0;bottom:0;width:var(--pu-panel);display:flex;flex-direction:column;border-width:0 0 0 1px;opacity:0;transform:translate(100%);transition:transform var(--out) var(--ei),opacity var(--out) var(--ei)}.all.show,.xp.show{opacity:1;transform:none;pointer-events:auto;transition:transform var(--mv) var(--eo),opacity var(--in) var(--eo)}.all.full{width:100%}.hd{display:flex;align-items:center;gap:4px;padding:8px 8px 6px}.sp{flex:1}.tg{position:relative;display:flex;align-items:center;gap:5px;height:28px;padding:0 11px 0 9px;border-radius:99px;white-space:nowrap;line-height:1;color:var(--mu);transition:background-color .2s var(--eo),color .2s var(--eo)}.tg:hover{background:var(--ho);color:var(--k)}.tg[aria-pressed=true]{background:var(--as);color:var(--pu-accent)}.tg[aria-pressed=true]:hover{background:color-mix(in srgb,var(--pu-accent) 20%,transparent)}.tg:focus-visible{outline:2px solid var(--pu-accent);outline-offset:1px}.tg:after{content:attr(data-tip);position:absolute;left:0;top:calc(100% + 4px);z-index:3;width:max-content;max-width:220px;padding:4px 9px;border:1px solid var(--ln);border-radius:8px;background:var(--su);box-shadow:var(--sh);font-size:12px;line-height:1.4;color:var(--mu);pointer-events:none;opacity:0;transform:translateY(-3px);transition:opacity var(--out) var(--ei),transform var(--out) var(--ei)}.tg:not([aria-pressed=true]):is(:hover,:focus-visible):after{opacity:1;transform:none;transition:opacity var(--in) var(--eo) .4s,transform var(--in) var(--eo) .4s}.list{flex:1;overflow-y:auto;overscroll-behavior:contain;padding:4px 8px 8px;background:var(--so)}.cd{position:relative;margin-top:6px;border:1px solid var(--ln);border-radius:10px}.list :is(.cd,[role=listitem],.sec){transition:all var(--mv) var(--eio)}.list .out{opacity:0!important;margin-top:0;padding-block:0;border-width:0;overflow:hidden}.cd.open{border-color:transparent;box-shadow:var(--sh)}.cd.done{--o:.6}.cd>.mi{position:absolute;inset:0;border-radius:10px;background:none}.cd>.thread :is(.acts,.refs,.edit){position:relative;z-index:1}.cd:not(.open,.new):is(:hover,:has(>.mi:focus-visible)){--bg:var(--so)}.cd.open>.mi{display:none}.cd.open .root>.hdr{cursor:pointer}.cd.new,.xr,.cd>.thread{padding:8px 10px 10px}.pf{display:flex;align-items:center;gap:8px;min-height:52px;padding:0 8px 0 14px;border-top:1px solid var(--ln)}.fs{display:flex;align-items:center;gap:6px;padding:4px 6px;border-radius:8px;font-size:13px;transition:background-color .2s var(--eo)}.fs:hover,.fs:focus-visible{background:var(--ho)}.fs small{font-size:12px;color:var(--fa)}.pf .ib{width:30px;height:30px}.cx{position:fixed;inset:0;width:100%;height:100%;overflow:visible;pointer-events:none;opacity:0;transition:opacity var(--in) var(--eo)}.cx.show{opacity:1}.cx path{fill:none;stroke:var(--pu-accent);stroke-width:1.5;stroke-linecap:round;opacity:.7}.cx circle{fill:var(--pu-accent)}.layer.listing .col{opacity:0;transition:opacity var(--out) var(--ei)}.sec{padding:8px 10px 2px;font-size:12px;color:var(--fa)}.ag{display:flex;align-items:center;gap:8px;padding:6px 14px;font-size:12px;color:var(--fa);border-bottom:1px solid var(--ln)}.ag[hidden]{display:none}.lns{display:flex;flex-direction:column}.ln{display:grid;grid-template-rows:0fr;opacity:0;transition:grid-template-rows var(--in) var(--eo),opacity var(--in) var(--eo)}.ln.show{grid-template-rows:1fr;opacity:1}.ln>.lw{overflow:hidden;min-height:0}.ag button{margin-left:auto;flex:none;padding:0 6px;border-radius:6px;color:var(--fa);transition:color .2s var(--eo),background-color .2s var(--eo)}.ag button:hover:not(:disabled),.ag button:focus-visible{color:var(--pu-accent);background:var(--as)}.ag button:disabled{opacity:.5;cursor:default}.adr{margin:8px 0 0 14px;padding:8px 10px;border-radius:8px;background:var(--so);font-size:13px;color:var(--k);animation:pu-in var(--mv) var(--eo) both}.adr small{display:block;font-size:12px;color:var(--fa)}.adr .go{display:flex;gap:6px;margin-top:6px}.adr .go button{padding:2px 8px;border-radius:6px;font-size:12px;color:var(--mu);transition:color .2s var(--eo),background-color .2s var(--eo)}.adr .go button:hover,.adr .go button:focus-visible{color:var(--pu-accent);background:var(--as)}@keyframes pu-in{0%{opacity:0;transform:translateY(3px)}to{opacity:1;transform:none}}.sec b{margin-left:6px;font-weight:500;color:var(--pu-accent)}.toast{--r:40px;position:fixed;right:var(--r);bottom:calc(4px + var(--pu-lift));max-width:min(320px,calc(100vw - var(--r) - 16px));border-radius:10px;padding:8px 14px;font-size:13px;opacity:0;transform:translateY(6px);transition:.3s var(--eo)}.toast.show{opacity:1;transform:none}.layer:is(.listing,:has(.xp.show)) .toast{--r:12px;bottom:64px;max-width:min(320px,calc(var(--pu-panel) - 24px));z-index:2}.layer:not(.listing):has(.menu.show) .toast{--r:314px}@media(max-width:640px){.layer:not(.listing):has(.menu.show) .toast{--r:12px;bottom:auto;top:12px}}@media(pointer:coarse){.mi,.ib,.rxo,.refs .ref,.mnl li,.bts button,.tg,.fs,.pm button,.ta,.nb,.selbar button,button.me,.say button,.line,.seen button,.ag button,.go button{min-height:44px}.ib,.rxo,.refs .ref,.nb,.selbar button,button.me,.ta{min-width:44px}.bub:before{content:"";position:absolute;inset:-14px;border-radius:50%}.row:focus-within .bts,.row.has .bts{max-height:52px}.hd{padding:4px 8px}.toast{--r:52px;display:flex;align-items:center;min-height:44px;padding:4px 14px;line-height:1.25}.ta{display:grid;place-items:center;margin:-5px -10px -5px 6px;padding:0 10px}.launch .mode{width:44px;height:44px}.menu{--b:calc(52px + var(--pu-lift))}}@media(pointer:coarse)and (hover:none){.ks{display:none}}.layer :is(button,a):not(.mi,.opn,.mode,.tg):focus-visible{outline:2px solid var(--pu-accent);outline-offset:1px}.layer .mi:focus-visible{outline:2px solid var(--pu-accent);outline-offset:-2px}.flip .launch{background:var(--su)}.flip :is(.th,.cd){opacity:1}.flip :is(.th,.cd)>*{opacity:var(--o,1);transition:opacity var(--in) var(--eo)}@media(forced-colors:active){.pick.kf{border:3px solid Highlight}.layer :is(.ib,.mi,.nb,.tg,.fs,.selbar button,.say button,.xb button):focus-visible{outline:2px solid Highlight}.sw{forced-color-adjust:none;border:1px solid CanvasText;background:Canvas}.sw:before,.sw:after{top:1px;left:1px;background:CanvasText}[aria-checked=true]>.sw{background:Highlight;border-color:Highlight}[aria-checked=true]>.sw:before,[aria-checked=true]>.sw:after{background:HighlightText}.layer :is(.tg,.rxo,.rx)[aria-pressed=true],.launch:has(.mode.on){forced-color-adjust:none;background:Highlight;color:HighlightText;border-color:Highlight}}@media(prefers-reduced-motion:reduce){.ln,.subs{transition-property:opacity}@keyframes pu-in{0%{opacity:0}to{opacity:1}}.bub,.bub.in,.bub.in:hover,.bub.on,.tip,.pop,.selbar,.menu,.all,.xp,.tt,.toast,.ref .rc,.rxp,.mnl{transform:none!important}.ttip{transition-property:opacity!important}.dlg{transform:translate(-50%)!important}.sw:after{transform:none!important;transition-property:opacity}[aria-checked=true]>.sw:after{opacity:0}[aria-checked=true]>.sw:before{opacity:1}.th,.th.long .root>.tx,.mr,.list :is(.cd,[role=listitem],.sec){transition-property:opacity,box-shadow}.tip.show,.toast{transition-property:opacity}.pick,.pick.show{transition:opacity .16s ease-in-out}.all,.all.show,.xp,.xp.show{transition-property:opacity}.namebar,.namebar.show{transform:none!important;transition:opacity .16s ease-in-out}.av,.nf,.launch{transform:none!important}@keyframes pu-pulse{0%{opacity:0}35%{opacity:.85}to{opacity:0}}}',root:e.root??document.body,onName:async e=>{u.name=e,o={...o,name:e},await n.saveProfile(o)}})}catch(e){throw Yn(null),e}s&&c.ctx.ae("This browser can't keep comments for this page \u2014 copy the comments (Copy comments \u203a As Markdown) to keep them");let p=()=>{u.flush().catch(e=>globalThis.reportError?.(e))},h=function(e){let t={...e,i:!0};Pt=t;for(let e of Tt.values())"waiting"===e.info.state&&zt(e,t);return()=>{t.i=!1,Pt===t&&(Pt=null);for(let e of[...Tt.values()].reverse())e.stop?.(),delete e.stop;e.surface.destroy()}}({surface:c.ctx.addons,doc:u,root:e.root??document.body,ephemeral:s,version:Ie,onIdentity:async e=>{o={...o,identity:e},await n.saveProfile(o)}}),f=/\S/.test(document.documentElement.getAttribute("data-pipeup-agents")??"")?window.setTimeout(()=>{Rt().some(e=>"agents"===e.id)||console.warn("pipeup: this page lists an agent (data-pipeup-agents), but the agents add-on isn't on the page, so replies won't show. Add @pipeup/agents (see the Add-ons page).")},1e3):0;"off"!==document.documentElement.getAttribute("data-pipeup-updates")&&Date.now()-Date.parse(Be)>31536e6&&console.info(`pipeup: this is Pipeup ${Ie}, from ${Be}; newer versions exist. See https://github.com/pipeup-ai/pipeup/blob/main/CHANGELOG.md`);let m=!1;return window.addEventListener("pagehide",p),{document:u,comments:({all:e=!1}={})=>Fe(c.ctx.l.all(),{title:document.title,url:location.href,exportedAt:new Date,all:e}),appearance:()=>({...c.appearance()}),flush:()=>u.flush(),unmount:()=>{m||(m=!0,window.removeEventListener("pagehide",p),window.clearTimeout(f),h(),c.destroy(),Yn(null),vo===t()&&(vo=null))}}}(e,()=>t).catch(e=>{throw vo===t&&(vo=null),e});return vo=t,t}typeof document<"u"&&(qt?console.warn(`pipeup: Pipeup is on this page twice (${qt.VERSION} and ${Ie}); the first one is used. Remove one script.`):(Dt(),function(){let e=document.documentElement;if(!e.hasAttribute("data-pipeup-doc")||"off"===e.getAttribute("data-pipeup-auto"))return;let t=()=>{wo().catch(e=>console.error(e))};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",t,{once:!0}):t()}()));const yo=Object.defineProperty({},"__esModule",{value:!0});for(const[t,n]of Object.entries({ADDON_API:1,AI_NAME:v,ANIMALS:c,BUILT:Be,COLOURS:u,DEFAULT_PROFILE_NAME:"",IndexedDbStore:ee,MemoryStore:X,PipeupDocument:_,UnsavedChangeError:Y,VERSION:Ie,addons:Rt,agentComments:Fe,animalName:m,comments:async function(e){if(!vo)throw new Error("pipeup: Pipeup hasn't started on this page");return(await vo).comments(e)},computeOpId:F,copyAll:Re,copyThread:qe,createIdentity:s,describeElement:he,describeRange:pe,formatAgo:Pe,isAiName:w,labelOf:$e,loadOrCreateProfile:Q,locate:Le,mount:wo,nameOf:g,newDocumentAttribute:function(){return`${function(t=16){return e(crypto.getRandomValues(new Uint8Array(t)))}(12)}:${e(crypto.getRandomValues(new Uint8Array(32)))}`},onReveal:function(e){return Kn.add(e),()=>{Kn.delete(e)}},parseDocumentAttribute:j,readFeedbackFile:V,resolveAnchor:we,setPeople:function(e){gt=e.filter(e=>e&&"string"==typeof e.name&&e.name.trim()&&mt.test(e.ref)).slice(0,500).map(e=>({ref:e.ref,name:e.name.trim().slice(0,80),...e.agent?{agent:!0}:{}}));for(let e of[...vt])e()},setViewState:function(e){let t=null;if(e){t={};let n=0;for(let[o,r]of Object.entries(e))if(!("string"!=typeof r||"slide"===o||o.length>64||r.length>200)){if(++n>=16)break;t[o]=r}}jn=t;for(let e of Vn)e()},signOp:T,use:Nt}))Object.defineProperty(yo,t,{value:n,enumerable:!0});return yo})();
2
- "use strict";(()=>{function b(e){let n=globalThis;(n.pipeupAddons||=[]).push(e),typeof addEventListener=="function"&&addEventListener("load",()=>{n.Pipeup||console.error(`pipeup: the "${e.id}" add-on needs Pipeup on the page too; load pipeup.min.js.`)},{once:!0})}var re=2n**256n-2n**32n-977n;var L=/^\/__pipeup\/[A-Za-z0-9_-]{16,}$/;function P(e){let n=document.documentElement,t=n.getAttribute("data-pipeup-link")??"",i=L.test(t),o=!1,c=0,y=()=>{};async function r(){let d=!1;try{d=(await fetch(`${t}/comments`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(await e.snapshot())})).ok}catch{}if(!d)throw new Error("pipeup: the link to your agent isn't reachable; your comments are safe here")}let u=()=>{window.clearTimeout(c),y(),y=()=>{},o=!1};return{enabled:i,agent:n.getAttribute("data-pipeup-link-agent")??"",file:n.getAttribute("data-pipeup-link-file")??"",on:()=>o,set:async d=>{if(i){if(!d){u(),e.refresh();return}await r(),o=!0,y=e.changes(()=>{window.clearTimeout(c),c=window.setTimeout(()=>{r().catch(h=>{u(),e.refresh(),globalThis.reportError?.(h)})},300)}),e.refresh()}},destroy:u}}function T(e){let n=o=>o.replace(/\s+/g," ").trim(),t=e.version?`npx pipeup@${e.version}`:"npx pipeup",i=`https://pipeup-ai.github.io/pipeup/${e.version?.includes("-")?"next/":""}`;return[`Act on the review comments on this page, which uses Pipeup: ${n(e.title)} (${n(e.url)}).`,"",e.file?`1. Read the comments: \`${t} comments ${e.file}\` (add --all for resolved ones). If it says nothing is shared, ask me to switch on Share with my agent.`:"1. Read the comments. Open the page in a browser and run `await Pipeup.comments()`, then read `.markdown`. If you can't run the page, ask me to paste its comments (Copy comments \u203A As Markdown).","2. Work through the open threads in order. For each, make the change I approved, or say why you didn't. Ask me before changing anything I haven't approved, and answer a question with an answer.",e.replies?`3. Answer in each thread: \`${t} reply --page ${e.file||"<the page's file>"} --thread <Thread id> "what you changed and where" --addressed "short note"\`. That writes ${n(e.replies)}.`+(e.listed?"":` The page doesn't list your key yet: run \`${t} agent --name <your name>\` and tell me the attribute to add.`):"3. Tell me what you would reply in each thread, in words I can paste.","4. Only mark a thread addressed. Never resolve, reopen, edit or delete: I close threads. Keep your key out of the page and its folder, and never answer as me.","",`Guide: ${i}skills/pipeup-apply/SKILL.md`].join(`
3
- `)}var C=/^[A-Za-z0-9_-]{43}$/,_="pipeupReplies";var D=/^AI assistant\s*·?\s*/;function x(e=document.documentElement){let n=e.getAttribute("data-pipeup-agents")??"";return[...new Set(n.split(/[\s,]+/).filter(t=>C.test(t)))]}function k(e=location,n=document.documentElement){let t=n.getAttribute("data-pipeup-replies");try{let i=e.href.split(/[?#]/)[0],o=new URL(t??(/\/$/.test(i)?`${i}index.replies.js`:i.replace(/\.[^./]*$/,"")+".replies.js"),e.href),c=o.protocol==="file:"?e.protocol==="file:":o.origin===e.origin;return c||console.warn("pipeup: the replies file must be on this site or this computer; ignoring it"),c?o.href:null}catch{return null}}function E(e){let n=x(),t=0,i="",o=null;async function c(){let l=globalThis[_];if(!Array.isArray(l))return 0;let p=l.splice(0),g=[];for(let f of p){let m=f;if(!(m?.format!=="pipeup-replies"||m.doc!==e.document.id||!Array.isArray(m.ops)))for(let s of m.ops){let a=s?.body;a&&n.includes(a.author)&&(a.kind==="reply"||a.kind==="addressed"||a.kind==="react"||a.kind==="unreact")?(g.push(s),(a.name==="AI assistant"||a.name.startsWith("AI assistant "))&&(i=a.name.replace(D,""))):t++}}return g.length?e.merge(g):0}function y(){let l=k();return l?(o?.remove(),new Promise((p,g)=>{let f=document.createElement("script");o=f,f.src=`${l}?${Date.now()}`;let m=a=>{window.clearTimeout(s),f.remove(),o===f&&(o=null),a?g(new Error(`pipeup: ${a}`)):p()},s=window.setTimeout(()=>m("the replies file didn't answer"),4e3);f.addEventListener("load",()=>m()),f.addEventListener("error",()=>m("there is no replies file yet")),e.overlay().append(f)})):Promise.reject(new Error("pipeup: the replies file can't be read from here"))}async function r(){if(!n.length)return 0;let l=await c();return await y(),l+await c()}let u=!1,d=()=>{u||document.hidden||(u=!0,r().catch(()=>{}).finally(()=>u=!1))},h=0;return n.length?(d(),h=window.setInterval(d,4e3),document.addEventListener("visibilitychange",d)):c(),{enabled:n.length>0,ignored:()=>t,who:()=>i,check:r,tally:l=>{let p=l.filter(s=>!s.resolved),g=s=>s.root.replies.some(a=>n.includes(a.author)),f=new Set(l.map(s=>s.id));return{stray:new Set(e.document.ops().filter(s=>n.includes(s.body.author)&&!f.has(s.body.thread)).map(s=>s.body.thread)).size,open:p.length,answered:p.filter(g).length,addressed:p.filter(s=>s.addressed).length}},destroy:()=>{window.clearInterval(h),document.removeEventListener("visibilitychange",d),o?.remove()}}}var R=()=>globalThis.Pipeup??{},N=["M10 8h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-8a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2z","M16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2"],H=["M21 12L3.5 4.5 6.2 12l-2.7 7.5zM6.2 12H13"],z="Reads a replies file next to this page. When the page is shown through pipeup watch, and only after you switch it on, it sends this page's comments to the program running on this computer. Nothing leaves this computer.",S=e=>e instanceof Error?e.message.replace(/^pipeup: /,""):"Something went wrong";async function K(e,n){try{await navigator.clipboard.writeText(e);return}catch{}let t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.cssText="position:fixed;opacity:0;pointer-events:none",n.append(t),t.select();let i=document.execCommand("copy");if(t.remove(),!i)throw new Error("pipeup: your browser blocked copying")}function U(){return{id:"agents",api:1,version:"0.6.0",needs:["menu","status","notify","listnote"],network:{when:"page-configured",to:["page"],says:z},setup(e){let n=E(e),t=P({snapshot:async()=>{let r=R();if(!r.comments)throw new Error("pipeup: this page has no Pipeup to read comments from");let[u,d]=await Promise.all([r.comments(),r.comments({all:!0})]);return{v:1,at:new Date().toISOString(),title:document.title,open:u,all:d}},changes:r=>e.document.onChange(r),refresh:()=>o()}),i=()=>n.who()||t.agent,o=()=>{if(e.setStatus(n.enabled||t.enabled?{text:t.on()?`Sharing comments with ${i()||"your agent"}`:`${i()||"An AI agent"} can answer comments here`}:null),!n.enabled)return e.setListNote(null);let r=n.tally(e.document.threads()),u=i()||"An agent",d=r.answered?`${u} has answered ${r.answered} of ${r.open} open comments${r.addressed?`; ${r.addressed} ${r.addressed===1?"is":"are"} marked addressed`:""}`:"No replies from an agent yet",h=n.ignored(),l=(t.on()?`Sharing with ${t.agent||"your agent"} \xB7 `:"")+d+(h?` \xB7 ${h} from other writers ignored`:"")+(r.stray?` \xB7 replies for ${r.stray} comment${r.stray===1?"":"s"} this page doesn't have`:"");e.setListNote({text:l,action:{label:"Check for replies",run:async()=>{try{let p=await n.check();e.notify(p?`${p} new ${p===1?"reply":"replies"}`:"No new replies")}catch(p){e.notify(S(p))}finally{o()}}}})},c=[e.addMenuItem({id:"prompt",icon:N,label:()=>"Copy a prompt for my agent",hint:()=>"Tells an AI agent where the comments are and how to answer them",select:async()=>{try{await K(T({title:document.title,url:location.href,replies:k(),file:t.enabled?t.file:"",listed:x().length>0,version:globalThis.Pipeup?.VERSION}),e.overlay()),e.notify("Copied a prompt for your agent")}catch(r){e.notify(S(r))}}})];t.enabled&&c.push(e.addMenuItem({id:"link",icon:H,label:()=>"Share with my agent",hint:()=>"Sends this page's comments to the program running on this computer, and nothing else",checked:()=>t.on(),select:async()=>{try{await t.set(!t.on())}catch(r){e.notify(S(r))}o()}}));let y=e.document.onChange(o);return o(),()=>{y(),n.destroy(),t.destroy()}}}}b(U());})();
1
+ "use strict";var Pipeup=(()=>{function e(e){let t="";for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function t(e){let t=atob(e.replace(/-/g,"+").replace(/_/g,"/")),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function n(e){return(new TextEncoder).encode(e)}function o(e){if(null===e||"object"!=typeof e)return JSON.stringify(e);if(Array.isArray(e))return"["+e.map(o).join(",")+"]";let t=e;return"{"+Object.keys(t).filter(e=>void 0!==t[e]).sort().map(e=>JSON.stringify(e)+":"+o(t[e])).join(",")+"}"}function r(e){return e.replace(/\s+/g," ").trim()}function i(e){let t=r(e),n=2166136261;for(let e=0;e<t.length;e++)n^=t.charCodeAt(e),n=Math.imul(n,16777619)>>>0;return n.toString(16).padStart(8,"0")}var a=/^[A-Za-z0-9_-]{43}$/,l=new Map;async function s(){let t=await crypto.subtle.generateKey({name:"Ed25519"},!1,["sign","verify"]);return{publicKey:e(new Uint8Array(await crypto.subtle.exportKey("raw",t.publicKey))),privateKey:t.privateKey}}async function d(t,n){let o=await crypto.subtle.sign({name:"Ed25519"},t.privateKey,n);return e(new Uint8Array(o))}var c=["Otter","Fox","Owl","Bear","Rabbit"],u=["Red","Orange","Yellow","Green","Teal","Blue","Purple","Pink","Brown","Grey"];function p(e){let t=2166136261;for(let n=0;n<e.length;n++)t=Math.imul(t^e.charCodeAt(n),16777619);return t=Math.imul(t^t>>>16,2246822507),t=Math.imul(t^t>>>13,3266489909),(t^t>>>16)>>>0}var h=e=>p(e)%c.length,f=e=>Math.floor(p(e)/c.length)%u.length,m=e=>`${u[f(e)]} ${c[h(e)]}`,g=e=>{let t=e.name.replace(/^AI assistant \xb7 /,"")||m(e.author);return e.alike?`${t} \xb7 ${function(e){let t=p(`id:${e}`),n="";for(let e=0;e<4;e++,t>>>=5)n+="0123456789ABCDEFGHJKMNPQRSTVWXYZ"[31&t];return n}(e.author)}`:t},v="AI assistant",w=e=>e===v||e.startsWith(`${v} `),y=2**40,b=2**47,x=1e4,k=/^[0-9a-f]{8}$/,E=/^[A-Za-z0-9_-]{43}$/,S=/^(?:[^\s@<>"]{1,64}@[^\s@<>"]{1,190}\.[^\s@<>"]{2,24}|gh:[A-Za-z0-9-]{1,39})$/,$=/^(?:[A-Za-z0-9_-]{43}|(?:host|gh):[A-Za-z0-9._@-]{1,64})$/,L=/^[A-Za-z0-9_-]{43}$/,M=new Set(["create","reply","edit","delete","resolve","reopen","addressed","react","unreact","seen","contact","uncontact"]),C=/^(?:\p{Regional_Indicator}{2}|[#*0-9]\uFE0F?\u20E3|\p{Extended_Pictographic}(?:\uFE0F|\p{Emoji_Modifier})?(?:\u200D\p{Extended_Pictographic}(?:\uFE0F|\p{Emoji_Modifier})?)*)$/u,A=e=>"string"==typeof e&&C.test(e)&&[...e].length<=16;async function T(e,t){if(e.author!==t.publicKey)throw new Error("pipeup: an op must be signed by its author");return{body:e,sig:await d(t,n(o(e)))}}var P=(e,t)=>"string"==typeof e&&e.length<=t,q=e=>!!e&&"object"==typeof e,R=e=>"number"==typeof e&&Number.isFinite(e)&&e>=0&&e<=1;function N(e){if(!q(e))return!1;let{id:t,path:n,fingerprint:o,snapshot:r,quote:i,point:a,view:l}=e;if(!(P(n,2e3)&&P(r,500)&&"string"==typeof o&&k.test(o)&&(void 0===t||P(t,200)&&""!==t)&&(void 0===i||q(i)&&P(i.exact,x)&&""!==i.exact&&P(i.prefix,64)&&P(i.suffix,64))&&(void 0===a||q(a)&&R(a.x)&&R(a.y))))return!1;if(void 0!==l){if(!q(l)||Array.isArray(l))return!1;let e=Object.entries(l);if(e.length>16||!e.every(([e,t])=>e.length<=64&&P(t,200)))return!1}return!0}function D(e){if(!q(e))return!1;let{body:t,sig:n}=e;if("string"!=typeof n||!q(t)||JSON.stringify({body:t,sig:n}).length>262144)return!1;let o=t;if(1!==o.v||"string"!=typeof o.id||!E.test(o.id)||!M.has(o.kind)||!P(o.doc,64)||""===o.doc||"string"!=typeof o.thread||!E.test(o.thread)||"string"!=typeof o.author||!L.test(o.author)||"string"!=typeof o.name||o.name.length>80||o.name!==o.name.trim()||"number"!=typeof o.clock||!Number.isSafeInteger(o.clock)||o.clock<1||o.clock>y||"number"!=typeof o.at||!Number.isSafeInteger(o.at)||o.at<0||o.at>b||void 0!==o.text&&(!P(o.text,1e4)||o.text!==o.text.trim())||void 0!==o.target&&("string"!=typeof o.target||!E.test(o.target))||("create"===o.kind||"reply"===o.kind||"edit"===o.kind||"addressed"===o.kind)&&!o.text||("reply"===o.kind||"edit"===o.kind||"delete"===o.kind)&&!o.target)return!1;if(void 0!==o.mentions){if("create"!==o.kind&&"reply"!==o.kind&&"edit"!==o.kind||!Array.isArray(o.mentions)||o.mentions.length>20)return!1;let e=o.text?.length??0;for(let t of o.mentions){if(!q(t)||!Number.isSafeInteger(t.start)||!Number.isSafeInteger(t.end))return!1;let{start:n,end:o,ref:r}=t;if(n<0||o<=n||o>e||"string"!=typeof r||!$.test(r))return!1}}return!(!("contact"!==o.kind||"string"==typeof o.text&&S.test(o.text))||"seen"===o.kind&&!o.target||!("react"!==o.kind&&"unreact"!==o.kind||o.target&&A(o.text))||!("create"!==o.kind||o.id===o.thread&&N(o.anchor)))}function z(r){return async function(n,o,r){if(!a.test(n))return!1;try{if(e(t(n))!==n)return!1;let i=l.get(n);if(!i){l.size>=512&&l.delete(l.keys().next().value),i=crypto.subtle.importKey("raw",t(n),{name:"Ed25519"},!0,["verify"]),l.set(n,i);let e=i;e.catch(()=>{l.get(n)===e&&l.delete(n)})}return await crypto.subtle.verify({name:"Ed25519"},await i,t(r),o)}catch{return!1}}(r.body.author,n(o(r.body)),r.sig)}function H(e,t){return e.body.clock!==t.body.clock?e.body.clock-t.body.clock:e.body.at!==t.body.at?e.body.at-t.body.at:e.body.author!==t.body.author?e.body.author<t.body.author?-1:1:e.body.id!==t.body.id?e.body.id<t.body.id?-1:1:0}function O(e,t,n,o,r,i){let a={id:e,author:t,name:n,text:o,at:r,edited:!1,deleted:!1,replies:[],reactions:[]};return i?.length&&(a.mentions=i),a}async function F(t){let r={...t,id:void 0,thread:"create"===t.kind?void 0:t.thread},i=await crypto.subtle.digest("SHA-256",n(o(r)));return e(new Uint8Array(i))}var B=class{constructor(e){this.doc=e}ops=new Map;clock=0;createAt=new Map;threadAt=new Map;get size(){return this.ops.size}all(){return[...this.ops.values()]}threads(){return function(e){let t=new Map,n=new Map,o=new Map;for(let{body:r}of[...e].sort(H)){if(r.name&&o.set(r.author,r.name),"create"===r.kind){if(t.has(r.id)||!r.anchor||void 0===r.text)continue;let e=O(r.id,r.author,r.name,r.text,r.at,r.mentions);t.set(r.id,{id:r.id,anchor:r.anchor,root:e,resolved:!1}),n.set(r.id,{comment:e,thread:r.id});continue}let e=t.get(r.thread);if(!e)continue;if("resolve"===r.kind||"reopen"===r.kind){e.resolved="resolve"===r.kind,"reopen"===r.kind&&delete e.addressed;continue}if("addressed"===r.kind){void 0!==r.text&&(e.addressed={text:r.text,author:r.author,name:r.name,at:r.at});continue}let i=r.target?n.get(r.target):void 0;if(i&&i.thread===r.thread){if("reply"===r.kind){if(n.has(r.id)||void 0===r.text)continue;let t=O(r.id,r.author,r.name,r.text,r.at,r.mentions);e.root.replies.push(t),n.set(r.id,{comment:t,thread:r.thread});continue}if("seen"===r.kind){let e=i.comment.seenBy??=[];e.includes(r.author)||e.push(r.author);continue}if("react"===r.kind||"unreact"===r.kind){if(void 0===r.text||i.comment.deleted)continue;let e=i.comment.reactions,t=e.find(e=>e.emoji===r.text);if("react"===r.kind){let n={author:r.author,name:r.name};t?t.by.some(e=>e.author===r.author)||t.by.push(n):e.length<12&&e.push({emoji:r.text,by:[n]})}else t&&(t.by=t.by.filter(e=>e.author!==r.author),t.by.length||e.splice(e.indexOf(t),1));continue}r.author!==i.comment.author||i.comment.deleted||("edit"===r.kind&&void 0!==r.text&&(i.comment.text=r.text,i.comment.edited=!0,r.mentions?i.comment.mentions=r.mentions:delete i.comment.mentions),"delete"===r.kind&&(i.comment.text="",i.comment.deleted=!0,i.comment.reactions=[],delete i.comment.mentions))}}for(let{comment:e}of n.values()){e.name||(e.unnamed=!0,e.name=o.get(e.author)??"");for(let t of e.reactions)for(let e of t.by)e.name||=o.get(e.author)??""}let r=new Map,i=(e,t)=>{let n=g({author:e,name:t}).toLowerCase();(r.get(n)??r.set(n,new Set).get(n)).add(e)};for(let{comment:e}of n.values()){i(e.author,e.name);for(let t of e.reactions)for(let e of t.by)i(e.author,e.name)}let a=(e,t)=>(r.get(g({author:e,name:t}).toLowerCase())?.size??0)>1;for(let{comment:e}of n.values()){a(e.author,e.name)&&(e.alike=!0);for(let t of e.reactions)for(let e of t.by)a(e.author,e.name)&&(e.alike=!0)}return[...t.values()]}(this.ops.values())}async add(e){let t=[];for(let n of e){if(!D(n)||n.body.doc!==this.doc||this.ops.has(n.body.id)||n.body.id!==await F(n.body)||!await z(n))continue;let e={body:n.body,sig:n.sig};this.ops.set(e.body.id,e),this.clock=Math.max(this.clock,e.body.clock),"create"===e.body.kind&&this.createAt.set(e.body.author,Math.max(this.createAt.get(e.body.author)??0,e.body.at)),this.threadAt.set(e.body.thread,Math.max(this.threadAt.get(e.body.thread)??0,e.body.at)),t.push(e)}return t}async append(e,t,n){let o={v:1,...n,id:"",thread:"create"===n.kind?"":n.thread,doc:this.doc,author:e.publicKey,name:t,clock:Math.min(this.clock+1,y),at:Math.min(Math.max(Date.now(),"create"===n.kind?(this.createAt.get(e.publicKey)??0)+1:(this.threadAt.get(n.thread)??0)+1),b)};o.id=await F(o);let r=this.ops.get(o.id);if(r)return r;"create"===o.kind&&(o.thread=o.id);let[i]=await this.add([await T(o,e)]);if(!i)throw new Error("pipeup: could not record this change");return i}},I=/^([A-Za-z0-9_-]{16}):([A-Za-z0-9_-]{43})$/;async function j(e){let n=I.exec(e.trim()),o=n?.[1],r=n?.[2];if(!o||!r)throw new Error('pipeup: data-pipeup-doc must look like "<id>:<key>", as made by newDocumentAttribute()');return{id:o,key:await crypto.subtle.importKey("raw",t(r),{name:"AES-GCM"},!1,["encrypt","decrypt"])}}async function W(t,o,r){let i=crypto.getRandomValues(new Uint8Array(12)),a=await crypto.subtle.encrypt({name:"AES-GCM",iv:i,additionalData:n(r)},t,n(o));return{iv:e(i),data:e(new Uint8Array(a))}}var K=e=>`pipeup-file:${e}`;async function V(e,o,r){if(e.length>5e6)throw new Error("pipeup: this feedback file is too large");let i,a,l;try{i=JSON.parse(e)}catch{throw new Error("pipeup: this is not an Pipeup feedback file")}if(!i||"object"!=typeof i||1!==i.pipeup||"string"!=typeof i.doc)throw new Error("pipeup: this is not an Pipeup feedback file");if(i.doc!==o)throw new Error("pipeup: this feedback is for a different document");if(!i.sealed)return Array.isArray(i.ops)?i.ops:[];if(!r)throw new Error("pipeup: this feedback is sealed, and this page has no document key");if("string"!=typeof i.iv||"string"!=typeof i.data)throw new Error("pipeup: this is not an Pipeup feedback file");try{a=await async function(e,o,r){try{let i=await crypto.subtle.decrypt({name:"AES-GCM",iv:t(o.iv),additionalData:n(r)},e,t(o.data));return(new TextDecoder).decode(i)}catch{throw new Error("pipeup: this feedback could not be opened with this document")}}(r,{iv:i.iv,data:i.data},K(o))}catch{throw new Error("pipeup: this feedback could not be opened with this document's key")}try{l=JSON.parse(a)}catch{throw new Error("pipeup: this is not an Pipeup feedback file")}return Array.isArray(l)?l:[]}var U=/^[a-z][a-z0-9-]{1,23}\/[a-z][a-z0-9-]{0,31}$/,Y=class extends Error{constructor(e,t,n=1){super("pipeup: shown here, but not saved yet"),this.id=e,this.cause=t,this.count=n,this.name="UnsavedChangeError"}},_=class e{constructor(e,t){this.log=e,this.options=t,this.displayName=t.name.trim()?J(t.name):""}listeners=new Set;cache=[];comments=new Map;displayName;we=Promise.resolve();unsaved=[];static async open(t){if("string"!=typeof t.doc||""===t.doc||t.doc.length>64)throw new Error("pipeup: the document id must be 1 to 64 characters");let n=new B(t.doc),o=await t.store.load(t.doc),r=o.length-(await n.add(o)).length;r&&console.warn(`pipeup: ${r} saved change${1===r?"":"s"} on this page couldn't be read; kept as saved`);let i=new e(n,t);return i.refresh(!1),i}get id(){return this.options.doc}get me(){return this.options.identity.publicKey}get name(){return this.displayName}set name(e){this.displayName=J(e),this.refresh(!0,[],"")}threads(){return this.cache}ops(){return this.log.all()}onChange(e){return this.listeners.add(e),()=>this.listeners.delete(e)}comment(e,t,n){return this.enqueue(()=>this.write({kind:"create",anchor:e,text:G(t),...n?.length?{mentions:n}:{}}))}reply(e,t,n){return this.enqueue(()=>this.write({kind:"reply",thread:this.find(e).thread,target:e,text:G(t),...n?.length?{mentions:n}:{}}))}edit(e,t,n){return this.enqueue(async()=>{let{thread:o}=this.mine(e);await this.write({kind:"edit",thread:o,target:e,text:G(t),...n?.length?{mentions:n}:{}})})}remove(e){return this.enqueue(async()=>{let{thread:t}=this.mine(e);await this.write({kind:"delete",thread:t,target:e})})}contact(e){let t=e.trim();return S.test(t)?this.enqueue(async()=>{await this.write({kind:"contact",thread:this.me,text:t})}):Promise.reject(new Error("pipeup: that isn't an email address or a GitHub name"))}uncontact(){return this.enqueue(async()=>{await this.write({kind:"uncontact",thread:this.me})})}contacts(){let e=new Map;for(let{body:t}of[...this.log.all()].sort(H))"contact"===t.kind&&t.text?e.set(t.author,t.text):"uncontact"===t.kind&&e.delete(t.author);return e}get portable(){return this.options.identity.privateKey.extractable}async seed(){let e=this.options.identity.privateKey;if(!e.extractable)return null;let{d:n}=await crypto.subtle.exportKey("jwk",e);return n?t(n):null}seen(e){return this.enqueue(async()=>{for(let t of e){let e=this.comments.get(t);e&&!e.comment.seenBy?.includes(this.me)&&await this.write({kind:"seen",thread:e.thread,target:t})}})}react(e,t){return this.enqueue(async()=>{await this.write({kind:"react",thread:this.find(e).thread,target:e,text:Z(t)})})}unreact(e,t){return this.enqueue(async()=>{await this.write({kind:"unreact",thread:this.find(e).thread,target:e,text:Z(t)})})}resolve(e){return this.enqueue(async()=>{await this.write({kind:"resolve",thread:this.thread(e)})})}reopen(e){return this.enqueue(async()=>{await this.write({kind:"reopen",thread:this.thread(e)})})}sign(e,t){if(!U.test(e))throw new Error('pipeup: a signing purpose looks like "<add-on id>/<name>"');return d(this.options.identity,n(`pipeup:${e}\n${t}`))}flush(){return this.enqueue(()=>this.persist())}exportFile(){return async function(e,t,n){let o=n?{pipeup:1,doc:e,sealed:!0,...await W(n,JSON.stringify(t),K(e))}:{pipeup:1,doc:e,sealed:!1,ops:t};return JSON.stringify(o,null,2)}(this.options.doc,this.log.all(),this.options.key)}async importFile(e){return this.merge(await V(e,this.options.doc,this.options.key),"file")}merge(e,t){return e.length>5e3?Promise.reject(new RangeError("pipeup: too many changes to merge at once")):this.enqueue(async()=>{let n=await this.log.add([...e]);this.unsaved.push(...n),n.length>0&&this.refresh(!0,n,t);try{await this.persist()}catch(e){throw n.length>0?new Y(n[0].body.id,e,n.length):e}return n.length})}enqueue(e){let t=this.we.then(e);return this.we=t.catch(()=>{}),t}async write(e){let t=await this.log.append(this.options.identity,this.displayName,e);this.unsaved.push(t),this.refresh(!0,[t],"local");try{await this.persist()}catch(e){throw new Y(t.body.id,e)}return t.body.id}async persist(){if(0===this.unsaved.length)return;let e=[...this.unsaved];await this.options.store.append(this.options.doc,e),this.unsaved=this.unsaved.filter(t=>!e.includes(t))}refresh(e,t=[],n=""){this.cache=this.log.threads(),this.comments.clear();let o=(e,t)=>{e.unnamed&&e.author===this.me&&this.displayName&&(e.name=this.displayName),this.comments.set(e.id,{comment:e,thread:t});for(let n of e.replies)o(n,t)};for(let e of this.cache)o(e.root,e.id);if(e)for(let e of this.listeners)try{e(this.cache,t,n)}catch(e){globalThis.reportError?.(e)}}find(e){let t=this.comments.get(e);if(!t)throw new Error("pipeup: there is no comment with that id");return t}mine(e){let t=this.find(e);if(t.comment.author!==this.me)throw new Error("pipeup: only the writer can change a comment");return t}thread(e){if(!this.cache.some(t=>t.id===e))throw new Error("pipeup: there is no thread with that id");return e}};function G(e){let t=e.trim();if(!t)throw new Error("pipeup: a comment needs some words");if(t.length>1e4)throw new Error("pipeup: comments are limited to 10000 characters");return t}function Z(e){if(!A(e))throw new Error("pipeup: a reaction is one emoji");return e}function J(e){let t=e.replace(/\s+/g," ").trim();if(!t||t.length>80)throw new Error("pipeup: choose a name of 1 to 80 characters");if(w(t))throw new Error("pipeup: that name is kept for AI replies; choose another");return t}var X=class{docs=new Map;profile=null;async load(e){return[...this.docs.get(e)?.values()??[]]}async append(e,t){let n=this.docs.get(e);n||this.docs.set(e,n=new Map);for(let e of t)n.set(e.body.id,e)}async loadProfile(){return this.profile}async saveProfile(e){this.profile=e}async saveProfileIfAbsent(e){return this.profile||(this.profile=e),this.profile}};async function Q(e,t=""){let n=await e.loadProfile();if(n)return"Reviewer"===n.name?{...n,name:""}:n;let o={identity:await s(),name:t};return e.saveProfileIfAbsent(o)}var ee=class e{constructor(e){this.db=e}static open(t="pipeup"){return new Promise((n,o)=>{let r=indexedDB.open(t,1);r.onupgradeneeded=()=>{let e=r.result;e.createObjectStore("ops",{keyPath:["doc","id"]}).createIndex("doc","doc"),e.createObjectStore("meta")},r.onsuccess=()=>{let t=r.result;t.onversionchange=()=>t.close(),n(new e(t))},r.onerror=()=>o(r.error??new Error("pipeup: could not open local storage"))})}close(){this.db.close()}async load(e){return(await this.request("ops","readonly",t=>t.index("doc").getAll(e))).map(e=>e.op)}async append(e,t){if(0===t.length)return;let n=this.db.transaction("ops","readwrite"),o=n.objectStore("ops"),r=te(n);try{for(let n of t)o.put({doc:e,id:n.body.id,op:n})}catch(e){throw n.abort(),r.catch(()=>{}),e}await r}async loadProfile(){return await this.request("meta","readonly",e=>e.get("profile"))??null}async saveProfile(e){await this.request("meta","readwrite",t=>t.put(e,"profile"))}async saveProfileIfAbsent(e){let t=this.db.transaction("meta","readwrite"),n=t.objectStore("meta"),o=te(t),r=e,i=n.get("profile");return i.onsuccess=()=>{i.result?r=i.result:n.put(e,"profile")},await o,r}request(e,t,n){return new Promise((o,r)=>{let i=n(this.db.transaction(e,t).objectStore(e));i.onsuccess=()=>o(i.result),i.onerror=()=>r(i.error??new Error("pipeup: local storage request failed"))})}};function te(e){return new Promise((t,n)=>{e.oncomplete=()=>t(),e.onerror=()=>n(e.error??new Error("pipeup: local storage write failed")),e.onabort=()=>n(e.error??new Error("pipeup: local storage write aborted"))})}function ne(e){let t=(e.ownerDocument??e).createTreeWalker(e,NodeFilter.SHOW_TEXT),n=[],o="";for(let e=t.nextNode();e;e=t.nextNode())n.push({node:e,start:o.length}),o+=e.data;return{text:o,nodes:n}}function oe(e,t,n){let o=(e.ownerDocument??e).createRange();return o.setStart(e,0),o.setEnd(t,n),o.toString().length}function re(e,t,n){let o=ie(e,t,!1),r=ie(e,n,!0);if(!o||!r||n<t)return null;let i=o.node.ownerDocument.createRange();return i.setStart(o.node,o.offset),i.setEnd(r.node,r.offset),i}function ie(e,t,n){let o=e.nodes.find(e=>t>=e.start&&t<e.start+e.node.data.length+Number(n));return o&&{node:o.node,offset:t-o.start}}function ae(e){return e.nodeType===Node.ELEMENT_NODE?e:e.parentElement}function le(e,t){for(let n=ae(e)?.closest("[data-pipeup-id]")??null;n;){if(!t.contains(n))return null;let e=n.getAttribute("data-pipeup-id")??"";if(""!==e&&e.length<=200)return n;n=n.parentElement?.closest("[data-pipeup-id]")??null}return null}function se(e,t,n){return e.slice(t,n).replace(/^[\uDC00-\uDFFF]|[\uD800-\uDBFF]$/g,"")}function de(e,t){let n=function(e,t){if(e===t)return"";let n=[];for(let o=t;o&&o!==e;o=o.parentElement){let e=1;for(let t=o.previousElementSibling;t;t=t.previousElementSibling)t.tagName===o.tagName&&e++;n.unshift(`${o.tagName.toLowerCase()}:nth-of-type(${e})`)}return":scope > "+n.join(" > ")}(e,t);if(n.length>2e3)throw new Error("pipeup: this element is nested too deeply to comment on \u2014 give a nearby container a data-pipeup-id");return n}function ce(e){if(!N(e))throw new Error("pipeup: could not describe this place on the page");return e}function ue(e,t){let n=ae(e),o=n?.closest("p,li,h1,h2,h3,h4,h5,h6,td,th,blockquote,pre,figcaption,dt,dd,summary,caption")??null;return o&&t.contains(o)?o:n&&t.contains(n)?n:t}function pe(e,t,n){if(!t.contains(e.commonAncestorContainer))throw new Error("pipeup: the selection is outside the commentable area");let o=le(e.commonAncestorContainer,t),a=o??t,{text:l}=ne(a),s=oe(a,e.startContainer,e.startOffset),d=oe(a,e.endContainer,e.endOffset),c=l.slice(s,d);if(""===c)throw new Error("pipeup: select some text to comment on");if(c.length>x)throw new Error("pipeup: selections are limited to 10000 characters");let u=se(l,Math.max(0,s-32),s),p=se(l,d,d+32);return ce({...o?{id:o.getAttribute("data-pipeup-id")??""}:{},path:"",quote:{exact:c,prefix:u,suffix:p},...n?{view:n}:{},fingerprint:i(ue(e.startContainer,t).textContent??""),snapshot:se(r(u+c+p),0,200)})}function he(e,t,n,o){let a=le(e,t);return ce({...a?{id:a.getAttribute("data-pipeup-id")??""}:{},path:de(a??t,e),...n?{point:{x:fe(n.x),y:fe(n.y)}}:{},...o?{view:o}:{},fingerprint:i(e.textContent??""),snapshot:se(r(e.textContent??""),0,200)})}function fe(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):0}function me(e,t,n){let o=Array.from({length:t.length+1},(e,t)=>t),r=[...o],i=[t.length];for(let a=1;a<=e.length;a++){r[0]=n?0:a;for(let n=1;n<=t.length;n++){let i=e.charCodeAt(a-1)===t.charCodeAt(n-1)?0:1;r[n]=Math.min(o[n]+1,r[n-1]+1,o[n-1]+i)}i.push(r[t.length]),[o,r]=[r,o]}return i}var ge=(e,t)=>me(e,t,!1).pop(),ve={state:"orphaned",element:null,range:null};function we(e,t,n={}){let o=e.id?function(e,t){for(let n of e.querySelectorAll("[data-pipeup-id]"))if(n.getAttribute("data-pipeup-id")===t)return n;return null}(t,e.id):t;return e.quote?function(e,t,n,o,r){let a=n??o,l=ne(a),s=function(e,t){if(!t.exact)return-1;let n=-1,o=-1;for(let r=e.indexOf(t.exact);-1!==r;r=e.indexOf(t.exact,r+1)){let i=e.slice(Math.max(0,r-t.prefix.length),r),a=e.slice(r+t.exact.length,r+t.exact.length+t.suffix.length),l=be(i,t.prefix)+ye(a,t.suffix);l>o&&(n=r,o=l)}return n}(l.text,t);if(s>=0){let r=re(l,s,s+t.exact.length);if(r){let t=ue(r.startContainer,o);return{state:null!==n&&i(t.textContent??"")===e.fingerprint?"attached":"moved",element:t,range:r}}}if(r){let e=a===o?l:ne(o);if(e.text.length<=5e4&&t.exact.length>=12&&t.exact.length<=300){let n=function(e,t,n){let o=t.length;if(0===o)return null;let r=-1,i=1/0;if(me(e,t,!0).forEach((e,t)=>{t&&e<i&&(i=e,r=t)}),i>n)return null;let a=Math.max(0,r-o),l=1/0;for(let i=Math.max(0,r-o-n);i<=Math.min(r,r-o+n);i++){let n=ge(e.slice(i,r),t);n<l&&(l=n,a=i)}return{start:a,end:r,distance:l}}(e.text,t.exact,Math.floor(t.exact.length/4)),r=n?re(e,n.start,n.end):null;if(r)return{state:"moved",element:ue(r.startContainer,o),range:r}}}return ve}(e,e.quote,o,t,!1!==n.fuzzy):function(e,t){if(!t)return ve;let n=t;if(e.path){if(!e.path.startsWith(":scope > "))return ve;try{n=t.querySelector(e.path)}catch{return ve}}return n?{state:i(n.textContent??"")===e.fingerprint?"attached":"moved",element:n,range:null}:ve}(e,o)}function ye(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;return n}function be(e,t){let n=0;for(;n<e.length&&n<t.length&&e[e.length-1-n]===t[t.length-1-n];)n++;return n}var xe={A:"Link",BUTTON:"Button",P:"Paragraph",LI:"List item",UL:"List",OL:"List",IMG:"Image",TABLE:"Table",TD:"Cell",TH:"Cell",FIGURE:"Figure",SVG:"Graphic",CANVAS:"Graphic",LABEL:"Label",INPUT:"Field",SELECT:"Dropdown",TEXTAREA:"Field",SUMMARY:"Disclosure",BLOCKQUOTE:"Quote",SECTION:"Section",ARTICLE:"Article",H1:"Heading",H2:"Heading",H3:"Heading",H4:"Heading",H5:"Heading",H6:"Heading",switch:"Switch",tab:"Tab",checkbox:"Checkbox",radio:"Radio button",button:"Button",submit:"Button",link:"Link"};function ke(e){let t=e.getAttribute("role")??("INPUT"===e.tagName?e.type:""),n=e.getAttribute("data-pipeup-label")||Object.hasOwn(xe,t)&&xe[t]||xe[e.tagName.toUpperCase()];if(n)return n;if(Se(e))return"Block";let o=e.getBoundingClientRect(),r=o.width/o.height;return r>1.4||r<.7?"Bar":"Shape"}var Ee=e=>e.innerText||e.textContent||"";function Se(e){let t=e,n=t.labels?.[0];return Ae(r(e.getAttribute("aria-label")??e.getAttribute("alt")??(n&&Ee(n))??("SELECT"===e.tagName?t.selectedOptions[0]?.text:null)??(t.placeholder||Ee(e))),40)}function $e(e){let t=e.getAttribute("data-pipeup-label");if(t)return t;let n=Se(e);return n?`${ke(e)} \xb7 ${n}`:ke(e)}function Le(e,t,n){let o=e.id??null,i=e.quote?.exact??null,a=e.point?`${Math.round(100*e.point.x)}% across, ${Math.round(100*e.point.y)}% down the element`:null,l=t.element;if("orphaned"===t.state||!l)return{where:`No longer on the page (it read: "${e.snapshot}")`,element:null,id:o,quote:i,pin:a};let s=[],d=e.view?.slide;if(d){let e=l.closest("[data-pipeup-slide],.reveal .slides section")?.querySelector(Ce)?.textContent;s.push(`Slide ${d}`+(e?` "${Ae(r(e))}"`:""))}else{let t=Me(e.view);t&&s.push(t);let o=function(e,t){let n=e=>!1!==e.checkVisibility?.(),o=n(e),i=e=>r(e.textContent??"");for(let r=e;r&&r!==t;r=r.parentElement)for(let e=r.previousElementSibling;e;e=e.previousElementSibling){let t=e.matches(Ce)?e:[...e.querySelectorAll(Ce)].pop();if(t&&i(e)===i(t)&&(!o||n(t)))return t}return null}(l,n);o&&s.push(`Section "${Ae(r(o.textContent??""))}"`)}let c=$e(l);return s.push(c),{where:s.join(" \u203a "),element:c,id:o,within:!!o&&l.getAttribute("data-pipeup-id")!==o,quote:i,pin:a}}function Me(e){return e?e.label||Object.entries(e).filter(([e,t])=>t&&"slide"!==e).map(([,e])=>e).join(" \xb7 "):""}var Ce="h1,h2,h3";function Ae(e,t=60){return e.length>t?e.slice(0,t-1)+"\u2026":e}var Te="Each thread says where it is: the slide or section, the element (its data-pipeup-id attribute in the HTML), and the exact quoted text or pin position. Work through the open threads in order, and for each one say what you changed or why you did not. Answer in the thread (the Pipeup skill says how) and mark it addressed; never resolve it, the author does.";function Pe(e,t){let n=Math.max(0,Math.round((t-e)/1e3));if(n<60)return"just now";let o=Math.round(n/60);if(o<60)return`${o}m ago`;let r=Math.round(o/60);return r<48?`${r}h ago`:`${Math.round(r/24)}d ago`}function qe(e,t,n,o){return"ai"===t?ze(e,"## Comment thread",o,n):He(e)}function Re(e,t,n){let o=n.all?e:e.filter(e=>!e.thread.resolved);if("text"===t)return o.map(He).join("\n");let r=n.all?0:e.length-o.length,i=[`# Review comments: ${De(n.title)}`,"",`- **Page:** ${De(n.url)}`,`- **Exported:** ${n.exportedAt.toISOString()}`,`- **Open threads:** ${e.length-e.filter(e=>e.thread.resolved).length}${r?` (${r} resolved, not included)`:n.all?" (resolved ones included)":""}`,"",Te,"",""].join("\n"),a=n.exportedAt.getTime();return i+o.map((e,t)=>ze(e,`## Thread ${t+1}`,a)).join("\n")}function Ne(e){return e.reactions.map(e=>`${e.emoji} ${e.by.length} (${e.by.map(e=>De(g(e))).join(", ")})`).join(" \xb7 ")}function De(e){return e.replace(/\s+/g," ").trim()}function ze(e,t,n,o){let{thread:r,location:i}=e,a=r.root.replies.length,l=[`${t} \xb7 ${r.resolved?"resolved":r.addressed?"open, addressed":"open"}`];if(l.push(`- **Thread:** ${r.id}`),o&&l.push(`- **Page:** ${De(o)}`),l.push(`- **Where:** ${De(i.where)}`),i.id){let e=`\`[data-pipeup-id="${De(i.id.replace(/`/g,""))}"]\``;l.push("- **Element:** "+(i.within&&i.element?`${De(i.element)} in ${e}`:`${e}${i.element?` (${De(i.element)})`:""}`))}i.quote&&l.push(`- **Quoted text:** "${De(i.quote)}"`),i.pin&&l.push(`- **Pin:** ${De(i.pin)}`),r.addressed&&!r.resolved&&l.push(`- **Addressed:** ${De(r.addressed.text)} (${De(g(r.addressed))}, ${Pe(r.addressed.at,n)})`),l.push(`- **Started by:** ${De(g(r.root))}, ${Pe(r.root.at,n)}${a?` \xb7 ${a} ${1===a?"reply":"replies"}`:""}`,"",`**${De(g(r.root))}** (${Pe(r.root.at,n)}): ${Oe(r.root," ")}`),r.root.reactions.length&&l.push(`Reactions: ${Ne(r.root)}`);for(let e of r.root.replies)l.push(`- **${De(g(e))}** (${Pe(e.at,n)}): ${Oe(e," ")} \x3c!-- comment:${e.id} --\x3e`),e.reactions.length&&l.push(` - Reactions: ${Ne(e)}`);return l.join("\n")+"\n"}function He(e){let{thread:t,location:n}=e,o=[De(n.where)+(n.quote?`, on the text "${De(n.quote)}"`:""),`${De(g(t.root))}: ${Oe(t.root," ")}`];t.root.reactions.length&&o.push(` Reactions: ${Ne(t.root)}`);for(let e of t.root.replies)o.push(` ${De(g(e))}: ${Oe(e," ")}`),e.reactions.length&&o.push(` Reactions: ${Ne(e)}`);return o.join("\n")+"\n"}function Oe(e,t){return e.deleted?"(deleted)":e.text.replace(/\r\n|\r|\n/g,"\n"+t)+(e.edited?" (edited)":"")}function Fe(e,t){return{markdown:Re(e,"ai",t),threads:e.filter(e=>t.all||!e.thread.resolved).map(({thread:e,location:t})=>{let n={id:e.id,state:e.resolved?"resolved":e.addressed?"addressed":"open",where:t.where,comments:[e.root,...e.root.replies].map(e=>({id:e.id,by:g(e),agent:w(e.name),at:new Date(e.at).toISOString(),text:e.deleted?"":e.text,...e.reactions.length?{reactions:e.reactions.map(e=>({emoji:e.emoji,by:e.by.map(g)}))}:{}}))};return t.id&&(n.element=t.id),t.quote&&(n.quote=t.quote),t.pin&&(n.pin=t.pin),e.addressed&&!e.resolved&&(n.addressed={note:e.addressed.text,by:g(e.addressed)}),n})}}var Be="0.8.2",Ie="2026-10-19",je=new Map,We=new Map,Ke=new Map,Ve={},Ue=e=>`${je.get(e)??""}|${We.get(e)??""}`;function Ye(e,t={},...n){let o=document.createElement(e);for(let[e,n]of Object.entries(t))void 0===n||!1===n||("class"===e?o.className=String(n):o.setAttribute(e,!0===n?"":n));for(let e of n)null!=e&&!1!==e&&o.append(e);return o}function _e(e,t){let n=e.getRootNode().activeElement;t&&n instanceof HTMLElement&&e.contains(n)&&n.blur(),e.inert=t}function Ge(e,t,n=null){let o=e.getRootNode().activeElement,r=!1;for(let o=t.length;o--;n=t[o])t[o].nextSibling!==n&&(r=!!e.insertBefore(t[o],n));return r&&o&&t.some(e=>e.contains(o))&&o.focus({preventScroll:!0}),r}var Ze=()=>{let e=window.getSelection();return e&&!e.isCollapsed&&e.toString().trim()?e:null};function Je(e,t){return e.length>t?e.slice(0,t-1)+"\u2026":e}function Xe(e,t,n=4){e.style.left=t.left-n+"px",e.style.top=t.top-n+"px",e.style.width=`${t.width+2*n}px`,e.style.height=`${t.height+2*n}px`}var Qe=/\bhttps?:\/\/[^\s<>"'`]+/gi,et=/[\u202A-\u202E\u2066-\u2069]/;function tt(e){let t=0,n=0;for(let o of e)"("===o?t++:")"===o&&n++;let o=e.length;for(;o>0;){let r=e[o-1];if(")"===r&&n>t)n--;else if(!".,;:!?'\"]}".includes(r))break;o--}return e.slice(0,o)}function nt(e){let t=[],n=0;for(let o of e.matchAll(Qe)){if(o[0].length>2048||et.test(o[0]))continue;let r,i=tt(o[0]),a=o.index??0;try{let e=new URL(i);if("http:"!==e.protocol&&"https:"!==e.protocol)continue;r=e.href}catch{continue}a>n&&t.push(e.slice(n,a));let l=Ye("a",{href:r,target:"_blank",rel:"noopener noreferrer"},i);l.addEventListener("click",e=>e.stopPropagation()),t.push(l),n=a+i.length}return n<e.length&&t.push(e.slice(n)),t}var ot="http://www.w3.org/2000/svg",rt={comment:["M20.5 11.5a8 8 0 0 1-11.7 7.1L4 19.8l1.2-4.4A8 8 0 1 1 20.5 11.5z","M12.3 8.2v6.6M9 11.5h6.6"],copy:["M10 8h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-8a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2z","M16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2"],resolve:["M5 12.5l4.5 4.5L19 7.5"],reopen:["M3 12a9 9 0 1 0 3-6.7","M3 4v5h5"],lines:["M4 7h16M4 12h10M4 17h7"],list:["M3 6.5a1.5 1.5 0 1 0 3 0a1.5 1.5 0 1 0-3 0M3 12a1.5 1.5 0 1 0 3 0a1.5 1.5 0 1 0-3 0M3 17.5a1.5 1.5 0 1 0 3 0a1.5 1.5 0 1 0-3 0M9 6.5h11M9 12h11M9 17.5h7"],expand:["M5.5 10h7a1.5 1.5 0 0 1 1.5 1.5v7a1.5 1.5 0 0 1-1.5 1.5h-7A1.5 1.5 0 0 1 4 18.5v-7A1.5 1.5 0 0 1 5.5 10z","M14 10l6-6M15 4h5v5"],pin:["M12 21c-4-4-7-7.5-7-11a7 7 0 0 1 14 0c0 3.5-3 7-7 11z","M12 7.5a2.5 2.5 0 1 0 0 5a2.5 2.5 0 0 0 0-5z"],at:["M9.1 12a2.9 2.9 0 1 0 5.8 0a2.9 2.9 0 1 0-5.8 0","M14.9 12v1.1a1.8 1.8 0 0 0 3.6 0V12a6.5 6.5 0 1 0-3.97 5.98"],chev:["M9 6l6 6-6 6"],shrink:["M7 4h10a3 3 0 0 1 3 3v10a3 3 0 0 1-3 3H7a3 3 0 0 1-3-3V7a3 3 0 0 1 3-3z","M16 8l-7 7M9 10v5h5"],bubble:["M20.5 11.5a8 8 0 0 1-11.7 7.1L4 19.8l1.2-4.4A8 8 0 1 1 20.5 11.5z"],wide:["M23.2 11.2a10.8 8.2 0 0 1-14.85 7.6L2.6 21l.45-5.7A10.8 8.2 0 1 1 23.2 11.2z"],close:["M6 6l12 12M18 6L6 18"],smile:["M12 3a9 9 0 1 0 0 18a9 9 0 0 0 0-18z","M8.6 14.2c1.9 2.1 4.9 2.1 6.8 0","M9.6 9.8a.6.6 0 1 1-1.2 0a.6.6 0 1 1 1.2 0M15.6 9.8a.6.6 0 1 1-1.2 0a.6.6 0 1 1 1.2 0"],edit:["M4 20h4L19 9l-4-4L4 16z"],hide:["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 12z","M12 9.5a2.5 2.5 0 1 0 0 5a2.5 2.5 0 0 0 0-5z","M4 4l16 16"],more:["M5.5 12h.01M12 12h.01M18.5 12h.01"],look:["M12 3a9 9 0 1 0 0 18a9 9 0 0 0 0-18z","M12 3v18"]};function it(e,t=15,n){let o=at(rt[e],t);return n&&o.setAttribute("stroke-width",String(n)),o}function at(e,t){let n=document.createElementNS(ot,"svg"),o={width:String(t),height:String(t),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"};for(let[e,t]of Object.entries(o))n.setAttribute(e,t);for(let t of e){let e=document.createElementNS(ot,"path");e.setAttribute("d",t),n.append(e)}return n}var lt=(e,t,n)=>`M${e} ${t}a${n} ${n} 0 1 0 ${2*n} 0a${n} ${n} 0 1 0 -${2*n} 0`,st={Otter:"M4 13.2C4 9.2 7.6 6.5 12 6.5s8 2.7 8 6.7-3.6 6.3-8 6.3-8-2.3-8-6.3zM5.6 9.6a1.8 1.8 0 1 1 2.7-2.3M18.4 9.6a1.8 1.8 0 1 0-2.7-2.3M9.2 11.6h.01M14.8 11.6h.01M11 14h2l-1 1zM9.8 15.8l-3.2.4M9.9 17l-2.7 1.1M14.2 15.8l3.2.4M14.1 17l2.7 1.1",Fox:"M3.5 4l5 3.5h7l5-3.5-1.5 8.5L12 20l-7-7.5zM9 12h.01M15 12h.01M12 17h.01",Owl:`M5 4.5l3 2.5h8l3-2.5V14a7 7 0 0 1-14 0z${lt(7.4,11.5,1.9)}${lt(12.8,11.5,1.9)}M11.3 14.6l.7 1 .7-1`,Bear:`${lt(5,13.5,7)}M8.9 7.22A2.8 2.8 0 1 0 5.89 10.09M18.11 10.09A2.8 2.8 0 1 0 15.1 7.22M9.4 12.6h.01M14.6 12.6h.01M10.3 16.4c0-1 .8-1.6 1.7-1.6s1.7.6 1.7 1.6-.8 1.6-1.7 1.6-1.7-.6-1.7-1.6z`,Rabbit:`${lt(6.5,15.5,5.5)}M9.6 10.5C8.2 6.5 8.4 2.5 9.8 2.5s2.4 3.5 1.6 7.5M14.4 10.5c1.4-4 1.2-8-.2-8s-2.4 3.5-1.6 7.5M10 15h.01M14 15h.01M11.3 17.3l.7.5.7-.5`};function dt(e){let t=/[\p{L}\p{N}]/u.exec(e);if(!t)return"";let n=t[0].toUpperCase();return 1===[...n].length?n:t[0]}var ct=(e,t)=>dt(t)||m(e);function ut(e,t){return w(t)?Ye("span",{class:"av ai","data-pipeup-ai":"","aria-hidden":"true"},"AI"):Ye("span",{class:`av c${f(e)}`,"aria-hidden":"true","data-animal":m(e)},dt(t)||at([st[c[h(e)]]],24))}function pt(e,t){setTimeout(()=>{e.remove(),t?.()},320)}function ht(e){return requestAnimationFrame(()=>{e.offsetWidth,e.classList.add("in")}),e}var ft=/^[A-Za-z0-9_-]{43}$/,mt=/^(?:host|gh):[A-Za-z0-9._@-]{1,64}$/,gt=[],vt=new Set;function wt(e,t){let n=new Map,o=e=>{e.ref!==t&&!n.has(e.ref)&&n.set(e.ref,e)},r=e=>o({ref:e.author,name:g(e),...w(e.name)?{agent:!0}:{}});for(let t of e)for(let e of[t.root,...t.root.replies])if(!e.deleted){r(e);for(let t of e.reactions)for(let e of t.by)r({...e})}for(let e of(document.documentElement.getAttribute("data-pipeup-agents")??"").split(/[\s,]+/).filter(e=>ft.test(e)))o({ref:e,name:"AI agent",agent:!0});for(let e of gt)o(e);return[...n.values()].sort((e,t)=>e.name.localeCompare(t.name))}var yt=(e,t)=>!!e.mentions?.some(e=>t.includes(e.ref)),bt=[],xt=e=>[e,...bt],kt=null,Et=e=>{kt=e},St="pu-source";function $t(e){let t=Ye("textarea",{class:"input",dir:"auto",rows:"1",autocomplete:"off","aria-label":e.name??e.label,placeholder:e.placeholder??""}),n=Ye("button",{class:"send",type:"button",inert:!0},e.label),o=Ye("button",{class:"cnl",type:"button"},"Cancel"),r=Ye("span",{class:"tools"});r.hidden=!0;let i=Ye("div",{class:"line"},t,r),a=Ye("div",{class:"row"},i,Ye("div",{class:"bts"},o,n)),l=e.kind??"comment",s=!1,d=new Set,c=()=>{for(let e of[...d])e()},u=()=>{let e=""!==t.value.trim();n.classList.toggle("show",e),a.classList.toggle("has",e),n.inert=!e,t.style.height="auto",t.style.height=`${Math.max(27,t.scrollHeight)}px`},p=()=>{let e=-1,n=0,o=(o,r)=>{e<0&&(e=t.selectionStart,n=0);let i=t.value.slice(0,e),a=o&&i&&!/\s$/.test(i)&&!/^\s/.test(o)?" ":"";t.setRangeText(a+o,e,e+n,"end"),n=a.length+o.length,r&&(e=-1),u()};return{update:e=>o(e,!1),commit:e=>o(e,!0),cancel:()=>{e>=0&&n&&t.setRangeText("",e,e+n,"end"),e=-1,n=0,u()}}},h=new Map,f=()=>{let n=(kt?.tools()??[]).filter(e=>!1!==e.available?.());for(let[e,t]of h)n.some(t=>t.id===e)||(t.remove(),h.delete(e));for(let o of n){if(h.has(o.id))continue;let n=Ye("button",{class:"ib tool",type:"button","aria-label":o.label,title:o.label,"aria-pressed":"false"},at(o.icon,15));n.addEventListener("mousedown",e=>e.preventDefault()),n.addEventListener("click",r=>{r.stopPropagation();try{o.press({kind:l,thread:e.thread?.()??null,text:()=>t.value,focus:()=>t.focus({preventScroll:!0}),connected:()=>a.isConnected,setPressed:e=>n.setAttribute("aria-pressed",String(e)),dictate:p,onEnd:e=>(d.add(e),()=>d.delete(e))})}catch(e){globalThis.reportError?.(e)}}),h.set(o.id,n),r.append(n)}r.hidden=0===h.size};f(),a.addEventListener(St,f);let m=[],g=Ye("ul",{class:"mnl",role:"listbox","aria-label":"People"}),v=Ye("span",{class:"mn-sr","aria-live":"polite"}),w=`mn-${Math.random().toString(36).slice(2,8)}`;g.id=w;let y=[],b=0,x=null;e.people&&(t.setAttribute("aria-autocomplete","list"),t.setAttribute("aria-haspopup","listbox"),t.setAttribute("aria-controls",w),a.append(g,v));let k=()=>{y=[],g.classList.remove("show"),t.removeAttribute("aria-activedescendant"),window.setTimeout(()=>!y.length&&g.replaceChildren(),220)},E=()=>{for(let[e,n]of[...g.children].entries()){let o=e===b;n.setAttribute("aria-selected",String(o)),n.classList.toggle("on",o),o&&t.setAttribute("aria-activedescendant",n.id)}},S=e=>{let n=y[e];if(!n||!x)return;let o=t.selectionStart;t.setRangeText(`@${n.name} `,x.start,o,"end"),m.push({label:n.name,ref:n.ref}),k(),u()},$=async()=>{let o=t.value.trim();if(o&&!s){s=!0;try{await e.F(o,m.length?function(e,t){let n=[];for(let o of t){let t=`@${o.label}`,r=0;for(;;){let i=e.indexOf(t,r);if(i<0)break;let a=i+t.length;if((0===i||/\s/.test(e[i-1]))&&(a===e.length||!/[\p{L}\p{N}_]/u.test(e[a]))&&!n.some(e=>i<e.end&&a>e.start)){n.push({start:i,end:a,ref:o.ref});break}r=i+1}}return n.sort((e,t)=>e.start-t.start).slice(0,20)}(o,m):[]),n.matches(":focus")&&t.focus(),t.value="",m.length=0,k(),u(),c()}catch{}finally{s=!1}}};i.addEventListener("mousedown",e=>{e.target===t||r.contains(e.target)||(e.preventDefault(),t.focus({preventScroll:!0}),t.setSelectionRange(t.value.length,t.value.length))}),t.addEventListener("input",()=>{u(),e.people&&(()=>{if(x=t.selectionStart===t.selectionEnd?function(e){let t=/(^|\s)@([^\s@]*(?:\s[^\s@]*)?)$/.exec(e);return t?{start:t.index+t[1].length,query:t[2]}:null}(t.value.slice(0,t.selectionStart)):null,y=x&&e.people?function(e,t){let n=t.trim().toLowerCase(),o=e.filter(e=>e.name.toLowerCase().startsWith(n)),r=n?e.filter(e=>!o.includes(e)&&e.name.toLowerCase().includes(n)):[];return[...o,...r].slice(0,8)}(e.people(),x.query):[],!y.length)return k();b=Math.min(b,y.length-1),g.replaceChildren(...y.map((e,t)=>{let n=Ye("li",{role:"option",id:`${w}-${t}`,class:e.agent?"agent":""},Ye("span",{},e.name),e.agent?Ye("small",{},"AI agent"):null);return n.addEventListener("mousedown",e=>{e.preventDefault(),S(t)}),n})),g.classList.add("show"),v.textContent=`${y.length} ${1===y.length?"person":"people"}`,E()})()}),t.addEventListener("blur",()=>y.length&&k()),t.addEventListener("mousedown",e=>e.defaultPrevented&&t.focus({preventScroll:!0}));for(let e of["keyup","keypress"])t.addEventListener(e,e=>e.stopPropagation());t.addEventListener("keydown",e=>{if(e.stopPropagation(),y.length&&!e.isComposing){if("ArrowDown"===e.key||"ArrowUp"===e.key)return e.preventDefault(),b=(b+("ArrowDown"===e.key?1:y.length-1))%y.length,E();if("Enter"===e.key||"Tab"===e.key)return e.preventDefault(),S(b);if("Escape"===e.key)return e.preventDefault(),k()}"Enter"!==e.key||e.shiftKey||e.isComposing?"Escape"===e.key&&!e.isComposing&&(e.preventDefault(),L()):(e.preventDefault(),$())});let L=()=>{let n=t.value.trim()?t.value:"";t.value="",u(),(!n||"reply"!==l)&&t.blur(),c(),e.V?.(n)};for(let e of[n,o])e.addEventListener("mousedown",e=>e.preventDefault());return n.addEventListener("click",e=>{e.stopPropagation(),$()}),o.addEventListener("click",e=>{e.stopPropagation(),L()}),e.value&&(t.value=e.value,queueMicrotask(u)),{element:a,input:t,focus:()=>t.focus({preventScroll:!0})}}var Lt=["sync","menu","notify","note","composer","panel","styles","status","overlay","here","sign","listnote","reactions","identity","dialog"],Mt=/^[a-z][a-z0-9-]{1,23}$/,Ct=new Set(["local","file","page","user","pipeup","presence","sync"]),At=class{constructor(e,t,n){this.ctx=e,this.shadow=t,this.after=n,Et({tools:()=>this.Y,note:()=>[...this.oe.values()].at(-1)??null})}ne=0;K=[];oe=new Map;writing=new Map;marked=new Map;paint=0;re=new Map;listNotes=new Map;picker=null;pickerOwner="";Y=[];ie=new Set;_=new Set;G=new Set;X=new Map;$=new Map;N=new Map;remote={n:0,who:new Set};last=0;timer=0;ye="";subscribe(e){return this.G.add(e),()=>{this.G.delete(e)}}changed(e){e&&this.ne++;for(let t of[...this.G])t(e);for(let e of this.ctx.e.querySelectorAll(".row, .draft"))e.dispatchEvent(new Event(St))}I(e,t){let n=this.N.get(e)??this.N.set(e,new Set).get(e),o=()=>{n.delete(o)&&t()};return n.add(o),o}be(){return[...this.re.values()].map(e=>e.text).join(" \xb7 ")}Oe(e,t){return this.K.push(t),this.changed(!0),{update:()=>this.changed(!1),remove:this.I(e,()=>{this.K.splice(this.K.indexOf(t),1),this.changed(!0)})}}setThread(e,t,n){let o=this.writing.get(e)??this.writing.set(e,new Set).get(e);null===n?(je.delete(t),o.delete(t)):(je.set(t,n),o.add(t)),this.repaint()}setMark(e,t,n,o){let r=this.marked.get(e)??this.marked.set(e,new Set).get(e);if(null===n){if(Ke.delete(t),!We.delete(t))return;r.delete(t)}else{if(We.get(t)===n&&!!Ke.get(t)==!!o)return;We.set(t,n),o?Ke.set(t,o):Ke.delete(t),r.add(t)}this.repaint()}repaint(){this.paint||(this.paint=window.requestAnimationFrame(()=>{this.paint=0,this.ctx.m()}))}se(e,t,n){n?e.set(t,n):e.delete(t),this.changed(!1)}setPicker(e,t){t?(this.picker=t,this.pickerOwner=e):this.pickerOwner===e&&(this.picker=null,this.pickerOwner=""),this.changed(!1)}Re(e,t){return this.Y.push(t),this.changed(!1),this.I(e,()=>{this.Y.splice(this.Y.indexOf(t),1),this.changed(!1)})}closed(){return this.ctx.state.hidden&&!this.ctx.state.l}Ne(e,t){this.closed()?this.$.set(e,t):this.ctx.ae(t)}flush(){if(this.closed()||0===this.$.size)return;let e=[...this.$.values()].at(-1);this.$.clear(),this.ctx.ae(e)}Ie(){return this.shadow.activeElement instanceof HTMLTextAreaElement||[...this.ctx.e.querySelectorAll("textarea")].some(e=>""!==e.value.trim())}He(e){this.ctx.state.hidden||this.ctx.L(e)}De(e,t){if("local"!==t&&""!==t){for(let{body:t}of e)t.author===this.ctx.doc.me||"create"!==t.kind&&"reply"!==t.kind||(this.remote.n++,this.remote.who.add(t.name||m(t.author)));this.xe()}}xe(e=Math.max(0,this.last+1e4-Date.now())){this.timer||!this.remote.n||(this.timer=window.setTimeout(()=>{if(this.timer=0,this.ctx.state.hidden||this.Ie())return this.xe(1e3);let{n:e,who:t}=this.remote;this.remote={n:0,who:new Set},this.last=Date.now(),this.ctx.L(`${e} new comment${1===e?"":"s"} from ${1===t.size?[...t][0]:`${t.size} people`}`)},e))}Be(e){let t=this.X.get(e);return t||(t=Ye("div",{class:"ov","aria-hidden":"true","data-addon":e}),this.ctx.e.insertBefore(t,this.after.nextSibling),this.X.set(e,t)),t}qe(e,t){let n=this.ctx.host.ownerDocument.defaultView?.CSSStyleSheet,o=n&&"replaceSync"in n.prototype&&"adoptedStyleSheets"in this.shadow?new n:null;o&&(o.replaceSync(t),this.shadow.adoptedStyleSheets=[...this.shadow.adoptedStyleSheets,o]);let r=o??this.shadow.appendChild(Ye("style",{},t));return this.I(e,()=>o?this.shadow.adoptedStyleSheets=this.shadow.adoptedStyleSheets.filter(e=>e!==o):r.remove())}Ee(e,t,n){return t.add(n),this.I(e,()=>t.delete(n))}Fe(e,t){return this.Ee(e,this.ie,t)}Ve(e,t){let n=this.Ee(e,this._,t);return this.call(this._,t,this.ke()),n}ke(){let{state:e}=this.ctx,t=this.shadow.activeElement;return{shown:!e.hidden,commentMode:e.s,allOpen:e.u,dark:this.ctx.e.classList.contains("dark"),view:this.ctx.f.view(),writing:t instanceof HTMLTextAreaElement?t.closest("[data-thread]")?.dataset.thread??"":null}}O(){for(let e of[...this.ie])this.call(this.ie,e);if(0===this._.size)return;let e=this.ke(),t=JSON.stringify(e);if(t!==this.ye){this.ye=t;for(let t of[...this._])this.call(this._,t,e)}}call(e,t,...n){try{t(...n)}catch(n){e.delete(t),globalThis.reportError?.(n)}}Ke(e,t,n){let o=this.ctx.e,r=this.shadow.activeElement,i=Ye("button",{class:"ib",type:"button","aria-label":"Close"},at(["M6 6l12 12M18 6L6 18"],15)),a=Ye("div",{class:"xp",role:"dialog","aria-label":n.label,"data-addon":e},Ye("div",{class:"hd"},Ye("span",{},n.label),i),Ye("div",{class:"xb"},t)),l=[...o.children].filter(e=>e instanceof HTMLElement&&!e.inert);for(let e of l)e.inert=!0;o.append(a),a.offsetWidth,a.classList.add("show");let s=e=>{"Escape"===e.key&&(e.stopPropagation(),e.preventDefault(),d())},d=this.I(e,()=>{window.removeEventListener("keydown",s,!0);for(let e of l)e.inert=!1;a.classList.remove("show"),a.inert=!0,window.setTimeout(()=>a.remove(),300),r?.focus?.({preventScroll:!0});try{n.onClose?.()}catch(e){globalThis.reportError?.(e)}});return i.addEventListener("click",d),window.addEventListener("keydown",s,!0),(a.querySelector("button, input, textarea, select, a[href]")??a).focus?.({preventScroll:!0}),{close:d}}dialog(e,t,n){this.ctx.e.querySelector(".dlg")?.remove();let o=Ye("div",{class:"dlg",role:"dialog","aria-label":n},t),r=()=>{},i=()=>{o.classList.remove("show"),o.inert=!0,window.setTimeout(r,260)};return o.addEventListener("keydown",e=>{e.stopPropagation(),"Escape"===e.key&&(e.preventDefault(),i())}),this.ctx.e.append(o),o.offsetWidth,o.classList.add("show"),o.querySelector("textarea, button.primary, button")?.focus({preventScroll:!0}),r=this.I(e,()=>o.remove()),{close:i}}clear(e){for(let t of[...this.N.get(e)??[]])t();this.N.delete(e),this.X.get(e)?.remove(),this.X.delete(e);for(let t of[this.oe,this.re,this.listNotes,this.$])t.delete(e);this.setPicker(e,null);for(let t of this.writing.get(e)??[])je.delete(t);this.writing.delete(e);for(let t of this.marked.get(e)??[])We.delete(t),Ke.delete(t);this.marked.delete(e),this.repaint(),this.changed(!0)}destroy(){window.clearTimeout(this.timer),Et(null),this.G.clear()}},Tt=new Map,Pt=null,qt=(()=>{let e=globalThis.Pipeup;return e?.VERSION?e:null})();function Rt(){return qt?qt.addons():[...Tt.values()].map(e=>({...e.info}))}function Nt(e){if(qt)return qt.use(e);let t=e=>console.warn(`pipeup: ${e}`),n=e;if(!n||"object"!=typeof n||"string"!=typeof n.id||!Mt.test(n.id)||Ct.has(n.id)||"function"!=typeof n.setup||"string"!=typeof n.network?.says)return t("an add-on needs an id of 2 to 24 lowercase letters, digits and dashes (not a reserved one), a setup function and a network statement");if(Tt.has(n.id))return t(`the add-on "${n.id}" is already registered; the second is ignored`);let o={id:n.id,version:String(n.version??""),network:n.network,state:"waiting"},r=(n.needs??[]).find(e=>!Lt.includes(e));!function(e){let t=typeof document>"u"?null:document.documentElement.getAttribute("data-pipeup-addons");return null===t||t.toLowerCase().split(/[\s,]+/).includes(e)}(n.id)?(o.state="off",o.reason="this page doesn't allow it",t(`the add-on "${n.id}" is not in this page's data-pipeup-addons list, so it is off`)):1!==n.api?(o.state="off",o.reason=`needs add-on API ${String(n.api)}; this Pipeup has 1`):r&&(o.state="off",o.reason=`this Pipeup has no ${r} slot`);let i={addon:e,info:o};Tt.set(n.id,i),Pt?.i&&"waiting"===o.state&&zt(i,Pt)}function Dt(){if(qt)return!0;let e=globalThis,t=e.pipeupAddons;if(Array.isArray(t))for(let e of t)Nt(e);else if(t&&"object"==typeof t&&t.push!==Nt)return!1;return e.pipeupAddons={push:Nt},!0}async function zt(e,t){let n,o,{addon:r,info:i}=e,a=new AbortController,l=new Set,{surface:s,doc:d}=t,c=()=>!a.signal.aborted,u=Object.assign(()=>{},{update(){},remove(){},close(){}}),p=e=>(...t)=>c()?e(...t):u,h={id:d.id,me:d.me,get name(){return d.name},threads:()=>d.threads(),ops:()=>d.ops(),contacts:()=>d.contacts(),onChange:e=>{let t=d.onChange(e);return l.add(t),()=>{t(),l.delete(t)}}},f=r.id,m={api:1,version:t.version,document:h,root:t.root,ephemeral:t.ephemeral,signal:a.signal,has:e=>Lt.includes(e),off:e=>{o=String(e)},merge:e=>c()?d.merge(e,f):Promise.resolve(0),addMenuItem:p(e=>s.Oe(f,e)),notify:p(e=>s.Ne(f,e)),announce:p(e=>s.He(e)),setComposerNote:p(e=>s.se(s.oe,f,e)),setThreadNote:p((e,t)=>s.setThread(f,e,t)),setThreadMark:p((e,t,n)=>s.setMark(f,e,t,n)),addComposerTool:p(e=>s.Re(f,e)),openPanel:p((e,t)=>s.Ke(f,e,t)),addStyles:p(e=>s.qe(f,e)),setStatus:p(e=>s.se(s.re,f,e)),setListNote:p(e=>s.se(s.listNotes,f,e)),setReactionPicker:p(e=>s.setPicker(f,e)),overlay:()=>s.Be(f),onFrame:p(e=>s.Fe(f,e)),where:e=>s.ctx.f.view(e),isHere:e=>s.ctx.f.w(e),go:e=>s.ctx.f.Z(e),onUi:p(e=>s.Ve(f,e)),avatar:(e,t)=>{let n=ut(e,t);return n.classList.add("in"),n},sign:(e,t)=>d.sign(`${f}/${e}`,t),identity:{portable:d.portable,seed:()=>d.seed(),use:async e=>{if("private"!==e.type||"Ed25519"!==e.algorithm.name||!e.extractable)throw new Error("pipeup: an identity is an extractable Ed25519 private key");let{x:n}=await crypto.subtle.exportKey("jwk",e);await t.onIdentity({publicKey:n,privateKey:e})},share:e=>d.contact(e).then(()=>!0,()=>!1),unshare:()=>d.uncontact()},openDialog:p((e,t)=>s.dialog(f,e,t))},g=()=>{if(c()){a.abort();for(let e of[...l])e();try{n?.()}catch(e){globalThis.reportError?.(e)}s.clear(f),"on"===i.state&&(i.state="waiting")}};e.stop=g;try{if(n=await r.setup(m),!c())return void n?.();if(void 0!==o)return g(),i.state="off",void(i.reason=o);i.state="on",delete i.reason}catch(e){i.state="failed",i.reason=function(e){return e instanceof Error?e.message:String(e)}(e),g(),i.state="failed",globalThis.reportError?.(e)}}var Ht=typeof navigator<"u"&&/Mac|iP(hone|ad|od)/.test(navigator.platform)?"\u21e7\u2325C":"Shift+Alt+C",Ot=" ",Ft="Shift+Alt+C";var Bt=new WeakMap;function It(e,t){let n=Bt.get(t)??function(e){let t=Ye("button",{class:"me",type:"button",tabindex:"-1","aria-hidden":"true"});t.addEventListener("mousedown",e=>e.preventDefault());let n=$t({label:"Comment",placeholder:"Comment or add others with @",kind:"comment",F:e.F,V:e.V,people:e.people}),o=Ye("div",{class:"note"}),r=()=>{let e=kt?.note()??null;o.textContent=e??"",o.hidden=!e};r();let i=Ye("div",{class:"say"}),a=Ye("input",{class:"input",type:"text",maxlength:"80","aria-label":"Your name"}),l=Ye("div",{class:"nf"},a),s=Ye("div",{class:"you"},i,l),d="",c=!1,u=()=>{let n=e.name(),o=n?"change":"add your name";if(t.title=n?"Change your name":"Add your name",!t.lastChild||d!==n){let o=ut(e.me,n),r=t.lastChild;r?(ht(o),pt(r)):o.classList.add("in"),t.append(o),d=n}let r=Ye("button",{type:"button"},o);r.addEventListener("click",h),i.replaceChildren(Ye("span",{class:"nm"},n||`You're ${m(e.me)}`)," \xb7 ",r)},p=e=>{s.classList.toggle("naming",e),_e(i,e),_e(l,!e)};function h(t){t.stopPropagation(),a.value=e.name(),p(!0),a.focus({preventScroll:!0}),a.select()}let f=()=>{p(!1),n.focus()};t.addEventListener("click",h),a.addEventListener("keydown",t=>{if(t.stopPropagation(),"Escape"!==t.key||t.isComposing){if("Enter"===t.key){t.preventDefault();let n=a.value.trim();if(!n||n===e.name())return f();if(c)return;c=!0,e.rename(n).finally(()=>{c=!1,u(),f()})}}else t.preventDefault(),f()}),u(),p(!1);let g=Ye("div",{class:"ctx"},e.label),v=Ye("div",{class:"draft"},Ye("div",{class:"hdr"},t,s),g,o,n.element);return v.addEventListener(St,r),{element:v,le:()=>{let{selectionStart:e,selectionEnd:t}=n.input;return()=>{n.focus(),n.input.setSelectionRange(e,t)}},J:e=>{g.hidden=e},de:e=>{g.textContent=e},focus:()=>n.focus(),_e:()=>""===n.input.value.trim(),fill:e=>{n.input.value=e,n.input.dispatchEvent(new Event("input")),n.focus(),n.input.setSelectionRange(e.length,e.length)}}}({label:t.label,me:e.doc.me,name:()=>e.l.name(),rename:t=>e.l.rename(t),F:(t,n)=>e.Ue(t,n),people:()=>e.people(),V:t=>e.ce(t)});return Bt.set(t,n),e.H(n),n}var jt="a,button,input,select,textarea,label,summary,[role=button],[contenteditable]";function Wt(e,t){if("orphaned"===t.state||!t.element||e.quote)return null;let n=t.element.getBoundingClientRect();if(!n.width&&!n.height)return null;if(e.point)return{x:n.left+e.point.x*n.width,y:n.top+e.point.y*n.height};if(t.element.matches(jt))return{x:n.right+4,y:n.top+14};let o=t.element.ownerDocument.createRange();o.selectNodeContents(t.element);let r=o.getBoundingClientRect();return{x:r.width?Math.min(n.right-8,r.right+6):n.right-8,y:(r.height?r.top:n.top)+8}}function Kt(e){return e.range?[...e.range.getClientRects()]:[]}function Vt(e,t){let n=Kt(t)[0];if(n)return n.top;if("orphaned"===t.state||!t.element)return null;let o=t.element.getBoundingClientRect();return e.point?o.top+e.point.y*o.height:o.top}function Ut(e,t){let n=Kt(t).at(-1);if(n)return{x:n.left,y:n.bottom,below:!0,p:n};let o=Wt(e,t);if(!o)return null;let r=e.point?new DOMRect(o.x-12,o.y-12,24,24):t.element.getBoundingClientRect();return{...o,below:!1,p:r}}function Yt(e,t,n){for(let o of n)if(e>=o.left&&e<=o.right&&t>=o.top&&t<=o.bottom)return!0;return!1}var _t=()=>window.innerWidth>=900?400:300,Gt=()=>window.innerWidth<=480,Zt=()=>!0===window.matchMedia?.("(pointer: coarse)").matches,Jt=0;function Xt(){let e=window.visualViewport,t=e?Math.max(0,e.offsetTop-Jt):0;return{top:t,bottom:e?Math.min(window.innerHeight,t+e.height):window.innerHeight}}var Qt=(e,t,n,o)=>n.keep&&e+t>n.keep.left?Math.min(n.height-o,n.keep.top-8):n.height-o;function en(e,t,n,o=12,r=44){let i=e.top-r>=8,a=e.top+e.height+8+(i?0:r),l=e.top-8-(i?r:0)-t.height,s=Math.max(o,Math.min(e.left,n.width-t.width-o)),d=e=>a+t.height<=Qt(e,t.width,n,o),c=n.keep?n.keep.left-8-t.width:-1;!d(s)&&c>=o&&d(c)&&(s=Math.min(s,c));let u=Qt(s,t.width,n,o),p=(n.top??0)+o,h=a+t.height<=u||l<p;return{above:!h,left:s,top:Math.max(p,Math.min(h?a:l,u-t.height))}}function tn(e,t,n){let o=e.top-t.height-10,r=o<8?e.top+e.height+10:o;return r+t.height>n.height-8&&(r=Math.max(8,o)),{left:Math.max(8,Math.min(e.left+e.width/2-t.width/2,n.width-t.width-8)),top:r}}function nn(e,t){let n=e.resolved.get(t.id);return n?.range?.startContainer??n?.element??null}var on=e=>(t,n)=>{let o=nn(e,t),r=nn(e,n),i=e=>e.anchor.point??{x:0,y:-1};return o!==r?!r||o&&4&o.compareDocumentPosition(r)?-1:1:i(t).y-i(n).y||i(t).x-i(n).x},rn=["\u{1f44d}","\u2764\ufe0f","\u{1f602}","\u{1f389}","\u{1f62e}","\u{1f64f}"],an={"\u{1f44d}":"Thumbs up","\u2764\ufe0f":"Heart","\u{1f602}":"Laughing","\u{1f389}":"Party popper","\u{1f62e}":"Surprised","\u{1f64f}":"Thanks"};var ln=e=>`${e} ${1===e?"reply":"replies"}`,sn=e=>e.root.replies.filter(e=>!e.deleted);function dn(e,t,n){let o={...n},r="card"===o.D,i=e.id,a=Ye("div",{class:"rbox always"},Ye("div",{},$t({label:"Reply",placeholder:"Reply or add others with @",kind:"reply",thread:()=>i,people:()=>t.people(),F:(e,n)=>t.reply(i,e,n),V:e=>e?t.drop(i,e):t.close()}).element)),l=Ye("div",{}),s=Ye("span",{class:"note"},"This thread was resolved. Your words are kept until you send or clear them.");s.hidden=!0,a.prepend(s);let d=Ye("div",{}),c=null,u=null,p=null,h="",f=Ye("div",{},d,r?null:Ye("div",{class:"more"},l)),m=new Set,y="",b="",x="",k=0,E=null,S=new Set,$=e,L=new Map,M=new Map,C=new Map,A=(e,t,n)=>{let o=Ye("button",{class:"ib",type:"button","aria-label":t,title:t},it(e,18,"more"===e?2.6:void 0));return o.addEventListener("click",e=>{e.stopPropagation(),n()}),o},T=e=>f.querySelector(e)?.focus({preventScroll:!0});function P(e,n={}){let q=f.getRootNode().activeElement,R=q&&f.contains(q)?q.dataset.k:void 0;(function(e,n){Object.assign(o,n);let q=b;b=y,i=e.id,$=e;let R=(o.now??Date.now)(),N=sn(e),D=N.length,z=e=>{let n=t=>w(e.name)?function(e){let t=[],n=e.split("\n").filter(e=>{let n=/^\[(\d{1,2})\]:?\s+(\S+)(?:\s+([^|]{1,40}?))?(?:\s*\|\s*(.{1,300}))?$/.exec(e.trim()),o=n?.[2]?function(e){return/^slide:\d{1,4}$/.test(e)||/^quote:\S{1,300}$/.test(e)?e:function(e){if(e.length>2048||et.test(e))return null;try{let t=new URL(e);return"http:"===t.protocol||"https:"===t.protocol?t.href:null}catch{return null}}(e)}(n[2]):null;return n?.[1]&&o&&t.push({n:n[1],to:o,label:n[3]?.trim()??"",says:n[4]?.trim()??""}),!(n?.[1]&&o)}).join("\n").replace(/\s*\[\d{1,2}\]/g,"").trim();if(!t.length)return nt(e);let o=t.slice(0,4).map(e=>{let t=e.to.startsWith("slide:"),n=e.label||(t?`Slide ${e.to.slice(6)}`:`[${e.n}]`),o=[t?Ye("i",{class:"sl"}):null,Ye("span",{},t||""===e.label?n:`[${e.n}] ${n}`),e.says?Ye("span",{class:"rc",role:"tooltip"},e.says):null];if(/^https?:/.test(e.to)){let t=Ye("a",{class:"ref",href:e.to,target:"_blank",rel:"noopener noreferrer",title:e.says?void 0:e.to},...o);return t.addEventListener("click",e=>e.stopPropagation()),t}let r=Ye("button",{class:"ref",type:"button",title:e.says?void 0:t?n:`Show where: ${n}`},...o);return r.addEventListener("click",t=>{t.stopPropagation(),Ve.go?.(e.to)}),r});return[...nt(n),Ye("div",{class:"refs"},...o)]}(t):nt(t);if(!e.mentions?.length)return n(e.text);let o=[],r=0;for(let i of e.mentions)i.start<r||(o.push(...n(e.text.slice(r,i.start))),o.push(Ye("span",{class:yt(e,[t.me])&&i.ref===t.me?"mn me":"mn"},e.text.slice(i.start,i.end))),r=i.end);return[...o,...n(e.text.slice(r))]},H=n=>function(e,t){if(e.deleted||(t.bare||!e.reactions.length)&&!t.quick)return null;let n=n=>e.reactions.find(e=>e.emoji===n)?.by.some(e=>e.author===t.me)??!1,o=(t.bare?[]:e.reactions).map(o=>{let r=n(o.emoji),i=o.by.length,a=[...r?["You"]:[],...o.by.filter(e=>e.author!==t.me).map(e=>g(e))],l=`${e.id}|${o.emoji}`,s=Ye("button",{class:`ref rx${r?" mine":""}${t.seen.has(l)?"":" new"}`,type:"button","aria-pressed":String(r),"aria-label":`${t.picker?.name(o.emoji)??an[o.emoji]??"Reaction"}, ${i} ${1===i?"person":"people"}${r?", including you":""}`,"data-k":`x${e.id}${o.emoji}`},Ye("span",{},o.emoji),Ye("span",{class:"n"},String(i)),Ye("span",{class:"rc"},a.join(", ")));t.seen.add(l),s.disabled=t.resolved;let d=0,c=!1;s.addEventListener("pointerdown",e=>{c=!1,"touch"===e.pointerType&&(d=window.setTimeout(()=>{c=!0,s.classList.add("held"),window.addEventListener("pointerdown",()=>s.classList.remove("held"),{capture:!0,once:!0})},450))});for(let e of["pointerup","pointercancel"])s.addEventListener(e,()=>window.clearTimeout(d));return s.addEventListener("contextmenu",e=>e.preventDefault()),s.addEventListener("click",e=>{e.stopPropagation(),c?c=!1:t.react(o.emoji,!r)}),s}),r=t.quick&&!t.resolved?Ye("div",{class:"rxq"+(t.seen.has(`${e.id}|quick`)?"":" new"),role:"group","aria-label":"React","data-q":e.id},...rn.map(o=>{let r=Ye("button",{class:"rxo",type:"button","aria-label":an[o],"aria-pressed":String(n(o)),"data-k":`q${e.id}${o}`},o);return r.addEventListener("click",e=>{e.stopPropagation(),t.react(o,!n(o))}),r}),t.picker?function(e,t){let n=Ye("button",{class:"rxo",type:"button","aria-label":"More reactions","aria-haspopup":"dialog"},"\u2026");return n.addEventListener("click",o=>{o.stopPropagation(),function(e,t,n){let o=e.closest(".layer");if(!o)return;o.querySelector(".rxp")?.remove();let r=e.getBoundingClientRect(),i=Math.max(8,Math.min(r.left,window.innerWidth-320-8)),a=r.bottom+6+340<=window.innerHeight-8?r.bottom+6:Math.max(8,r.top-340-6),l=Ye("div",{class:"rxp",role:"dialog","aria-label":"Choose a reaction"});l.style.cssText=`left:${i}px;top:${a}px`;let s=!1,d={},c=e=>{e.composedPath().includes(l)||u()},u=()=>{s||(s=!0,window.removeEventListener("pointerdown",c,!0),d.off?.(),l.classList.remove("show"),l.inert=!0,window.setTimeout(()=>l.remove(),260),e.focus({preventScroll:!0}))};l.addEventListener("keydown",e=>{"Escape"===e.key&&(e.stopPropagation(),e.preventDefault(),u())}),d.off=t.fill(l,e=>{u(),n(e)}),window.addEventListener("pointerdown",c,!0),o.append(l),l.offsetWidth,l.classList.add("show"),l.querySelector("input,button")?.focus({preventScroll:!0})}(n,e,t)}),n}(t.picker,e=>t.react(e,!n(e))):null):null;return r?t.seen.add(`${e.id}|quick`):t.seen.delete(`${e.id}|quick`),Ye("div",{class:"refs rxs"},...o,r)}(n,{me:t.me,picker:t.picker(),resolved:e.resolved,quick:m.has(n.id),bare:r,seen:S,react:(e,o)=>{m.delete(n.id),t.react(n.id,e,o),P($),T(`[data-r="${n.id}"]`)}}),O=e.resolved?"Resolved"+(D?` \xb7 ${ln(D)}`:""):e.addressed?"Addressed"+(D?` \xb7 ${ln(D)}`:""):D?ln(D):"",F=(n,o)=>{let r=[];if(o&&r.push(["Copy thread",()=>(t.copy(e.id),!1)]),(e=>e.author===t.me&&!e.deleted)(n)&&r.push(["Edit",()=>(function(e){let n=()=>{E=null,P($),T(`[data-c="${e.id}"]`)},o=$t({label:"Save",name:"Edit comment",kind:"comment",value:e.text,people:()=>t.people(),F:async(o,r)=>{await t.edit(e.id,o,r),n()},V:n});E={id:e.id,o:Ye("div",{class:"edit"},o.element)},queueMicrotask(()=>o.focus())}(n),!1)],[x===n.id?"Delete for everyone":"Delete",()=>x!==n.id?(x=n.id,k=performance.now(),!0):performance.now()-k<500||(x="",t.remove(n.id),!1)]),!r.length)return null;let i=Ye("div",{class:q===n.id?"pm":"pm in",role:"menu","data-m":n.id},...r.map(([e,t],o)=>{let r=Ye("button",{type:"button",role:"menuitem",class:"Delete for everyone"===e?"dl":"","data-k":`p${n.id}${o}`},e);return r.addEventListener("click",e=>{e.stopPropagation(),t()||(y=""),P($);let r=f.querySelectorAll(".pm button")[o];r?r.focus():f.contains(f.getRootNode().activeElement)||f.querySelector(`[data-c="${n.id}"]`)?.focus()}),r}));return i.addEventListener("keydown",e=>{let t=[...i.querySelectorAll("button")],o=t.indexOf(e.target),r={ArrowDown:o+1,ArrowUp:o-1,Home:0,End:t.length-1}[e.key];if(void 0!==r)t[(r+t.length)%t.length]?.focus();else{if("Escape"!==e.key)return;y=x="",P($),T(`[data-c="${n.id}"]`)}e.preventDefault(),e.stopPropagation()}),i},B=(n,o)=>{let r=F(n,o),i=r?A("more","More",()=>{y=y===n.id?"":n.id,x="",P($),f.querySelector(y?".pm button":`[data-c="${n.id}"]`)?.focus()}):null;return i&&(i.setAttribute("aria-expanded",String(y===n.id)),i.dataset.c=n.id,i.dataset.k=`m${n.id}`),Ye("div",{class:"hdr"},...(e=>{let t=ct(e.author,e.name),n=L.get(e.id),o=n?.o;if((!o||n.key!==t)&&(o=ht(ut(e.author,e.name)),n)){let t=n.o;C.set(e.id,t),pt(t,()=>C.get(e.id)===t&&C.delete(e.id))}o.title=g(e),M.set(e.id,{key:t,o});let r=C.get(e.id);return r?[r,o]:[o]})(n),Ye("span",{class:"who"},g(n)),Ye("span",{class:"ago",title:new Date(n.at).toLocaleString()},Pe(n.at,R)),Ye("span",{class:"acts"},(t=>{if(e.resolved||t.deleted)return null;let n=A("smile","React",()=>{let e=!m.delete(t.id);e&&m.add(t.id),P($),T(e?`[data-q="${t.id}"] button`:`[data-r="${t.id}"]`)});return n.dataset.r=t.id,n.dataset.k=`r${t.id}`,n})(n),o?e.resolved?A("reopen","Reopen",()=>{t.reopen(e.id)}):A("resolve","Resolve",()=>{t.resolve(e.id)}):null,i),y===n.id?r:null)},I=e=>E?.id===e.id?E.o:(e=>Ye("div",{class:e.deleted?"tx del":"tx",dir:"auto"},...e.deleted?["Deleted"]:[...z(e),e.edited?" (edited)":""]))(e),j=o.quote?`\u201c${Je(o.quote,80)}\u201d`:"",W=o.note&&!o.moved?o.note:o.lost?`${o.place||"No longer on the page"} \u2014 it read \u201c${Je(o.lost,120)}\u201d`:o.moved?`Moved \xb7 ${j||`it read \u201c${Je(e.anchor.snapshot,80)}\u201d`}`:j,K=r?o.rest:"column"===o.D&&O;M=new Map;let V=Ye("div",{class:"root"},B(e.root,!0),W?Ye("div",{class:"ctx"},W):null,I(e.root),"column"===o.D&&Ye("div",{class:"mr","aria-hidden":"true"},Ye("span",{},"more")),H(e.root),K?Ye("div",{class:"rest"},K):null);if(d.replaceWith(V),d=V,f.className=e.resolved?"thread resolved":"thread",f.setAttribute("data-thread",e.id),r)return void(L=M);c?.remove();let U=je.get(e.id);c=D||void 0!==U?Ye("div",{class:"rps"},...N.map(e=>Ye("div",{class:"it"},B(e,!1),I(e),H(e))),void 0===U?null:Ye("div",{class:"it ghost","data-pipeup-writing":"row"},Ye("div",{class:"hdr"},ut("",v),Ye("span",{class:"who"},v),Ye("span",{class:"ago"},"writing now")),Ye("div",{class:"tx",dir:"auto","data-pipeup-writing":"words"},U))):null,c&&l.prepend(c);let Y=e.addressed&&!e.resolved?e.addressed:null,_=Y?`${Y.text}|${Y.author}|${Y.at}`:"";if(_!==h&&(p?.remove(),p=null,h=_,Y)){let n=(e,t)=>{let n=Ye("button",{type:"button"},e);return n.addEventListener("click",e=>{e.stopPropagation(),t()}),n};p=Ye("div",{class:"adr"},Ye("small",{},`Addressed \xb7 ${g(Y)} \xb7 ${Pe(Y.at,R)}`),Y.text,Ye("div",{class:"go"},n("Resolve",()=>{t.resolve(e.id)}),n("Still not right",()=>{t.notRight(e.id)})))}p&&l.insertBefore(p,u??(a.parentNode===l?a:null)),u?.remove();let G=We.get(e.id),Z=Ke.get(e.id);if(u=void 0===G?null:Ye("div",{class:"seen"},Ye("i"),G),u&&Z){let e=Ye("button",{type:"button"},"Check again");e.addEventListener("click",e=>{e.stopPropagation(),Z()}),u.append(e)}u&&l.insertBefore(u,a.parentNode===l?a:null),L=M;let J=""!==a.querySelector("textarea").value.trim();s.hidden=!(e.resolved&&J),e.resolved&&!J?a.remove():a.parentNode!==l&&l.append(a)})(e,n),R&&!f.contains(f.getRootNode().activeElement)&&f.querySelector(`[data-k="${CSS.escape(R)}"]`)?.focus({preventScroll:!0})}return f.addEventListener("focusout",e=>{f.contains(e.relatedTarget)||setTimeout(()=>{(y||m.size)&&!f.contains(f.getRootNode().activeElement)&&(y=x="",m.clear(),P($))})}),P(e),{element:f,update:P}}function cn(e,t=!1){let n=e.ownerDocument.documentElement,o=n.getAttribute("data-pipeup-layout");if("bubbles"===o||e.querySelector("[data-pipeup-slide]"))return null;let r=e.querySelector("article, main, [role=main]")??("column"===o?e:null);if(!r)return null;if(n.hasAttribute("data-pipeup-reserve")){let e,i=n.clientWidth,a=getComputedStyle(r).maxWidth;return e=a.endsWith("px")?parseFloat(a):a.endsWith("%")?parseFloat(a)/100*i:r.getBoundingClientRect().width,"column"!==o&&i<e+320-(t?24:0)?null:{x:i-320+24,width:272}}let i=r.getBoundingClientRect().right;if(window.innerWidth-i<300&&"column"!==o)return null;let a=i+32;return{x:a,width:Math.max(220,Math.min(300,window.innerWidth-a-16))}}function un(e,t){let n=e.resolved.get(t.id);return!n||"orphaned"===n.state&&!e.$.has(t.id)}var pn=(e,t)=>"moved"===e.resolved.get(t.id)?.state;function hn(e){let t=Ye("div",{class:"col"});e.e.append(t);let n=new Map,o=null,r=new ResizeObserver(()=>c()),i=!0===window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,a=t=>un(e,t);function l(t){let n=e.resolved.get(t.id),o=n?Vt(t.anchor,n):null;return null===o?Number.POSITIVE_INFINITY:o+window.scrollY-4}let s=new WeakMap;function d(e,t=0){let n=`translateY(${Math.round(t)}px)`;if(i&&e.style.transform){if(e.style.transform!==n||s.has(e)){if(!s.has(e)){e.classList.add("hop");let t=()=>{+getComputedStyle(e).opacity>.01?requestAnimationFrame(t):(e.style.transform=s.get(e),s.delete(e),e.classList.remove("hop"))};window.setTimeout(t,200)}s.set(e,n)}}else e.style.transform=n}function c(){let r=[],i=[];for(let{o:e}of n.values()){let t=e.querySelector(".root>.tx");t&&(t.style.setProperty("--full",`${t.scrollHeight}px`),e.classList.toggle("long",t.scrollHeight>88))}for(let[t,o]of n){let n=l(o.thread);if(Number.isFinite(n))o.placed=n;else if(e.$.has(t)){if(null===o.placed){o.o.classList.add("wait");continue}n=o.placed}Number.isFinite(n)?r.push({id:t,T:n,height:o.o.offsetHeight}):i.push({id:t,height:o.o.offsetHeight})}let a=e.state.t,s=a?Vt(a.anchor,a.resolved):null;o&&null!==s&&r.push({id:"draft",T:s+window.scrollY-4,height:o.o.offsetHeight});let c=o?"draft":e.state.i,u=r.find(e=>e.id===c),p=t.getBoundingClientRect().right>window.innerWidth-44?44:0;u&&(p||o)&&(u.T=Math.max(window.scrollY+8,Math.min(u.T,window.scrollY+window.innerHeight-p-10-u.height)));let h=function(e,t,n=10){let o=[...e].sort((e,t)=>e.T-t.T),r=new Array(o.length).fill(0),i=o.findIndex(e=>e.id===t),a=e=>o[e];if(i<0)o.forEach((e,t)=>{r[t]=0===t?e.T:Math.max(e.T,(r[t-1]??0)+a(t-1).height+n)});else{r[i]=a(i).T;for(let e=i+1;e<o.length;e++)r[e]=Math.max(a(e).T,(r[e-1]??0)+a(e-1).height+n);for(let e=i-1;e>=0;e--)r[e]=Math.min(a(e).T,(r[e+1]??0)-a(e).height-n)}return new Map(o.map((e,t)=>[e.id,r[t]??0]))}(r,c),f=Math.max(0,...r.map(e=>(h.get(e.id)??0)+e.height))+24;for(let e of i)h.set(e.id,f),f+=e.height+10;for(let[e,t]of[...[...n].map(([e,t])=>[e,t.o]),["draft",o?.o]])if(t){if(t.classList.contains("wait")){if(!h.has(e)&&t!==o?.o)continue;t.style.transition="none",t.style.transform=`translateY(${Math.round(h.get(e)??0)}px)`,t.offsetWidth,t.style.transition="",t.classList.remove("wait");continue}d(t,h.get(e))}}function u(t,n){t.thread=n,t.note=Ue(n.id),t.lost=a(n),t.moved=pn(e,n),t.view.update(n,{lost:t.lost?n.anchor.snapshot:null,moved:t.moved})}function p(n){let o=a(n),i=dn(n,e.B,{D:"column",lost:o?n.anchor.snapshot:null,moved:pn(e,n)}),l=Ye("div",{class:"th wait","data-thread":n.id},Ye("button",{class:"opn sr",type:"button","data-thread":n.id}),i.element);return l.addEventListener("mouseenter",()=>e.S(n.id)),l.addEventListener("mouseleave",()=>e.S(null)),l.addEventListener("click",()=>e.open(n.id)),t.append(l),r.observe(l),{o:l,thread:n,lost:o,moved:pn(e,n),placed:null,view:i}}function h(e){r.unobserve(e),e.classList.add("out"),window.setTimeout(()=>e.remove(),220)}return{m:function(i){_e(t,e.state.u);let l=new Set,s=null!==e.state.i||null!==e.state.t;for(let t of i){if(!e.U(t))continue;let o=n.get(t.id);if(!o&&e.state.t?.sending)continue;l.add(t.id),o?(o.thread!==t||o.lost!==a(t)||o.moved!==pn(e,t)||o.note!==Ue(t.id))&&u(o,t):(o=p(t),n.set(t.id,o));let r=o.o,i=e.state.i===t.id;r.classList.toggle("on",i);let d=r.firstElementChild,c=sn(t).length;d.setAttribute("aria-label",`Open thread: ${Je(t.root.text,60)}, ${ln(c)}`),d.setAttribute("aria-expanded",String(i)),_e(d,i);let h=r.querySelector(".more");h&&_e(h,!i),r.classList.toggle("dim",s&&!i),r.classList.toggle("hot",e.state.S===t.id&&!i),r.classList.toggle("resolved",t.resolved),r.classList.toggle("lost",o.lost)}for(let[e,t]of n)l.has(e)||(n.delete(e),h(t.o));(function(){let n=e.state.u?null:e.state.t;if(o&&o.of!==n&&(h(o.o),o=null,n||e.H(null)),!n)return;let i=!o;if(o)o.p.de(n.label);else{let i=It(e,n),a=Ye("div",{class:"th on wait"},i.element);t.append(a),r.observe(a),o={o:a,p:i,of:n}}o.p.J(e.state.s&&!n.anchor.quote&&!n.anchor.point),i&&o.p.focus()})(),Ge(t,i.filter(e=>l.has(e.id)).sort(on(e)).map(e=>n.get(e.id).o),o?.o??null)&&t.offsetWidth,c()},O:function(){let n=cn(e.root,!0);n&&(t.style.width=`${n.width}px`,t.style.transform=`translate(${n.x}px, ${-window.scrollY}px)`)},destroy(){r.disconnect(),e.H(null),t.remove()}}}var fn=22;function mn(e,t){let n=new Map,o=Ye("div",{class:"tip",role:"tooltip"}),r=Ye("div",{class:"mark"}),i=Ye("div",{class:"pop",role:"dialog","aria-label":"Comment thread"});o.inert=i.inert=!0,e.e.append(r,o,i);let a,l=Ye("div",{class:"bub pin ghost","aria-hidden":"true"}),s=[],d=null,c=null,u=!1,p=null,h=!0===window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,f=0,m=null,v=null,w=null,y=0,b=e=>s.find(t=>t.id===e)??null,x=()=>t.pe||e.state.u,k=!1,E=t=>{let n=e.resolved.get(t.id);return n?Ut(t.anchor,n):null},S=()=>{let t=function(e){let t=window.innerWidth,n=Xt();return{width:e&&!Gt()?t-320:t,height:n.bottom,top:n.top}}(e.state.u),n=e.state.u||e.e.classList.contains("kb")?null:e.e.querySelector(".launch .mode")?.getBoundingClientRect();return n?.width&&(t.keep={left:e.state.s&&Zt()?0:n.left,top:n.top}),t};function $(e,t,n){let{left:o,top:r}=function(e,t,n,o=12){if(!e.below&&e.x+14+t.width>n.width-o)return en(e.p,t,n,o,0);let r=Math.max(o,e.below?Math.min(e.x,n.width-t.width-o):e.x+14),i=Qt(r,t.width,n,o),a=e.below?e.y+8:e.y-12;return e.below&&a+t.height>i&&(a=e.y-t.height-40),{left:r,top:Math.max((n.top??0)+o,Math.min(a,i-t.height))}}(t,{width:e.offsetWidth||n,height:e.offsetHeight},S());e.style.left=`${o}px`,e.style.top=`${r}px`}function L(t){let n=t&&x()&&e.state.i!==t?b(t):null,r=n?E(n):null;if(!n||!r)return w=null,o.classList.remove("show"),void _e(o,!0);if(w!==n.id){let e=sn(n).length;o.replaceChildren(Ye("div",{class:"tx clamp",dir:"auto"},...n.root.deleted?["Deleted"]:nt(n.root.text)),Ye("div",{class:"who"},`${g(n.root)}${e?` \xb7 ${e} ${1===e?"reply":"replies"}`:""}`)),w=n.id}$(o,r,260),o.classList.contains("show")||o.offsetWidth,o.classList.add("show"),o.inert=!1}function M(t){m=t,L(t),e.S(t)}function C(e){window.clearTimeout(y),null===e?y=window.setTimeout(()=>M(null),x()?400:0):M(e)}function A(t){let o=n.get(t.id);if(o)return o;let i=Ye("button",{class:"bub",type:"button","data-thread":t.id});return i.addEventListener("mouseenter",()=>C(t.id)),i.addEventListener("mouseleave",()=>C(null)),i.addEventListener("click",n=>{n.stopPropagation(),L(null),e.open(t.id)}),e.e.insertBefore(i,r),n.set(t.id,i),i}o.addEventListener("mouseenter",()=>window.clearTimeout(y)),o.addEventListener("mouseleave",()=>C(null)),o.addEventListener("click",t=>{t.stopPropagation();let n=w;n&&(window.clearTimeout(y),M(null),e.open(n))});let T=!1;function P(){let t=e.state.t,n=p&&t&&!t.anchor.quote&&!t.anchor.point?t.resolved.element:null;if(n){let{left:e,top:t,above:o}=en(n.getBoundingClientRect(),{width:i.offsetWidth||_t(),height:i.offsetHeight},S(),12,Zt()?60:44),r=null!==p?.above&&p?.above!==o;if(p&&(p.above=o),r&&R())return;return i.style.left=`${e}px`,void(i.style.top=`${t}px`)}let o=p&&t?Ut(t.anchor,t.resolved):d?E(d):null;o&&$(i,o,_t())}let q=t=>e.state.s&&!t.anchor.quote&&!t.anchor.point;function R(e=()=>{}){return window.clearTimeout(f),h?(i.classList.remove("show"),f=window.setTimeout(()=>{e(),P(),i.classList.add("show")},220),!0):(e(),i.classList.add("glide"),f=window.setTimeout(()=>i.classList.remove("glide"),450),!1)}let N=e=>Math.min(Math.max(e,20),window.innerWidth-30),D=t=>{if(e.M(t)){let e=t.composedPath()[0];return null!==v&&!(e instanceof Element&&e.closest(".tip,.bub"))&&C(null),void(v=null)}let n=e.ue(t.clientX,t.clientY)?.id??null;n!==v&&(v=n,C(n))},z=t=>{if(e.M(t))return;let n=window.getSelection();if(n&&!n.isCollapsed||(e.state.s&&!e.state.paused?t.altKey:t.target instanceof Element&&t.target.closest(jt)))return;let o=e.ue(t.clientX,t.clientY);o&&(e.fe(t),L(null),e.open(o.id))};return window.addEventListener("pointermove",D,{capture:!0,passive:!0}),window.addEventListener("click",z,!0),{m:function(o){s=o;let l=new Set;for(let t of o){if(!e.U(t)||t.anchor.quote)continue;let n=e.resolved.get(t.id);if(!n||"orphaned"===n.state)continue;l.add(t.id);let o=A(t);o.classList.toggle("done",t.resolved),o.classList.toggle("on",e.state.i===t.id),o.classList.toggle("pin",void 0!==t.anchor.point);let r=`Comment on ${$e(n.element)}: ${Je(t.root.text,60)}`;o.getAttribute("aria-label")!==r&&o.setAttribute("aria-label",r)}Ge(e.e,o.filter(e=>l.has(e.id)).sort(on(e)).map(e=>n.get(e.id)),r);for(let[e,t]of n)l.has(e)||(t.classList.remove("in"),n.delete(e),window.setTimeout(()=>t.remove(),300));L(m),k!==e.state.u&&i.classList.contains("show")&&!h&&R(),k=e.state.u;let g=t.pe&&!e.state.u?e.state.t:null;if(g){let t=g.anchor.point??g.resolved.element;p?.of!==g?(window.clearTimeout(f),i.classList.remove("glide"),p={p:It(e,g),of:g,at:t,above:null},p.p.J(q(g)),i.replaceChildren(p.p.element),i.inert=!1,p.p.focus(),d=null,c=null,P(),i.classList.add("show")):p&&(p.at!==t&&(p.at=t,p.above=null,R(()=>p?.p.de(g.label))),p.p.J(q(g)));let n=!e.f.w(g.anchor.view);return void(n!==T&&(T=n,i.classList.toggle("show",!n),i.inert=n,n||P()))}p&&(window.clearTimeout(f),i.classList.remove("glide"),p=null,T=!1,e.H(null));let v=x()&&!e.state.u&&e.state.i?b(e.state.i):null;if(!v||!e.U(v))return d=null,c=null,i.classList.remove("show"),void _e(i,!0);let w={D:"popover",quote:v.anchor.quote?.exact??null,moved:pn(e,v)};d&&c&&d.id===v.id?(d!==v||a!==Ue(v.id)||u!==w.moved)&&(c.update(v,w),d=v,a=Ue(v.id),u=w.moved):(c=dn(v,e.B,w),i.replaceChildren(c.element),d=v,a=Ue(v.id),u=w.moved,P(),i.classList.add("show"),i.inert=!1)},O:function(){let t=[],o=x()?null:cn(e.root,!0);for(let[r,i]of n){let n=b(r),a=e.resolved.get(r),l=n&&a?Wt(n.anchor,a):null;if(!l||l.y<-40||l.y>window.innerHeight+40){i.style.visibility="hidden";continue}let s=l.x=N(l.x),d=Math.max(s,(o?o.x:window.innerWidth)-30),c=fn;for(;t.some(e=>Math.abs(e.x-l.x)<fn&&Math.abs(e.y-l.y)<fn);)l.x+=c,l.x>d&&(c=-22,l.x=s-fn),l.x<20&&(c=fn,l.x=s,l.y+=fn);t.push(l),i.style.visibility="",i.style.left=`${l.x}px`,i.style.top=`${l.y}px`,i.classList.contains("in")||(i.offsetWidth,i.classList.add("in"))}let a=e.state.t,s=a?.anchor.point&&e.f.w(a.anchor.view)?Wt(a.anchor,a.resolved):null;s?(l.style.left=`${N(s.x)}px`,l.style.top=`${s.y}px`,l.classList.contains("in")||(e.e.insertBefore(l,r),l.offsetWidth,l.classList.add("in"))):l.classList.contains("in")&&(l.classList.remove("in"),window.setTimeout(()=>l.classList.contains("in")||l.remove(),300)),i.classList.contains("show")&&P();let c=function(){if(!x())return null;let t=e.state.t;return t?t.anchor.quote||t.anchor.point||e.state.s?null:t.resolved.element:!d||d.anchor.quote||d.anchor.point?null:e.resolved.get(d.id)?.element??null}();r.classList.toggle("show",null!==c),c&&Xe(r,c.getBoundingClientRect(),4)},destroy(){window.clearTimeout(y),window.clearTimeout(f),window.removeEventListener("pointermove",D,!0),window.removeEventListener("click",z,!0),e.H(null);for(let e of n.values())e.remove();l.remove(),o.remove(),r.remove(),i.remove()}}}var gn={display:"block",position:"static",clips:!1,off:!1},vn="button link img figure region list listitem tab tabpanel article navigation complementary banner contentinfo form search group dialog menu menuitem checkbox switch radio slider textbox combobox option row cell heading table".split(" ").map(e=>`[role=${e}]`),wn="[data-pipeup-ignore],.reveal>:is(.controls,.progress,.slide-number)",yn=["button,a,input,select,textarea,label,summary,details,img,svg,canvas,video,picture,figure,figcaption,table,th,td","li,ul,ol,dl,dt,dd,p,h1,h2,h3,h4,h5,h6,blockquote,pre","section,article,aside,nav,header,footer,main,form,fieldset",...vn].join(","),bn="a,button,label,summary,[role=button],[role=link],[role=tab],[role=option],[role=menuitem]",xn=`${bn},input,select,textarea,img,svg,canvas,video,picture,[role=img]`,kn=(e,t)=>Math.abs(e.left-t.left)<=2&&Math.abs(e.top-t.top)<=2&&Math.abs(e.width-t.width)<=2&&Math.abs(e.height-t.height)<=2;function En(e,t){let n=t.p(e);if(n.width<2||n.height<2)return!1;if(e.hasAttribute("data-pipeup-id"))return!0;let o=t.Q();return n.width*n.height<=.6*o.width*o.height&&(e.matches(yn)||t.ze(e)||e.childElementCount>1&&!e.parentElement?.closest(bn)&&t.We(e))}function Sn(e,t,n){if(e===t||!t.contains(e)||e.closest(wn))return null;let o=null;for(let r=e;r&&r!==t&&!o;r=r.parentElement)En(r,n)&&(o=r);if(!o||o.hasAttribute("data-pipeup-id"))return o;let r=n.p(o);for(let e=o.parentElement;e&&e!==t&&kn(n.p(e),r);e=e.parentElement)if(e.hasAttribute("data-pipeup-id"))return e;return o}function $n(e,t,n){let o=n.p(e);for(let r=e.parentElement;r&&r!==t;){let e=Sn(r,t,n);if(!e)return null;if(!kn(n.p(e),o))return e;r=e.parentElement}return null}var Ln=(e,t)=>e.left<t.left+t.width&&t.left<e.left+e.width&&e.top<t.top+t.height&&t.top<e.top+e.height,Mn=(e,t)=>{let n=Math.max(e.left,t.left),o=Math.max(e.top,t.top);return{left:n,top:o,width:Math.max(0,Math.min(e.left+e.width,t.left+t.width)-n),height:Math.max(0,Math.min(e.top+e.height,t.top+t.height)-o)}};function Cn(e,t,n=()=>!0){let o=[],r=(e,i,a,l,s,d)=>{for(let c of e.children){if(c.matches(wn)||"true"===c.getAttribute("aria-hidden")||!n(c))continue;let e=t.flow?.(c)??gn,u=c.offsetParent,p="fixed"===e.position||"absolute"===e.position&&!!l&&!(u&&l.contains(u)),h=p?null:a,f=t.p(c),m=f.width>0&&f.height>0;if(h&&m&&!Ln(f,h))continue;let g=c.matches(bn),v=(e.display.startsWith("inline")||d)&&!c.matches(xn)&&("inline"===e.display||f.height<=48),w=f.width<=24&&f.height<=24,y=i;(c.hasAttribute("data-pipeup-id")||!s&&!e.off&&!v&&(!w||g))&&En(c,t)&&(i&&kn(t.p(i.o),f)?(c.hasAttribute("data-pipeup-id")||!i.o.hasAttribute("data-pipeup-id"))&&(i.o=c):o.push(y={o:c,q:i,C:0}));let b=e.clips&&m;r(c,y,b?h?Mn(h,f):f:h,b?c:p?null:l,s||g,/^inline-(flex|grid)$/.test(e.display)||d&&/(flex|grid)$/.test(e.display))}};r(e,null,null,null,!1,!1);for(let e=o.length-1;e>=0;e--){let t=o[e];t.q&&(t.q.C=Math.max(t.q.C,t.C+1))}return o}var An=(e,t)=>e.filter(e=>e.C<=t&&(!e.q||e.q.C>t)),Tn="a,button,summary,[role=button],[role=link],[role=switch],[role=tab],[role=checkbox],input[type=checkbox],input[type=radio],input[type=submit],input[type=button],input[type=reset]",Pn=`${Tn},input,select,textarea,[contenteditable]:not([contenteditable=false]),[tabindex]:not([tabindex="-1"])`,qn=["click","dblclick","auxclick","submit","contextmenu","dragstart"],Rn=[...["over","out","enter","leave","down","up"].flatMap(e=>[`pointer${e}`,`mouse${e}`]),"mousemove","touchstart","touchmove","touchend","touchcancel"],Nn=["pointerup","pointercancel"],Dn="Tab moves between blocks \xb7 \u2191 \u2193 change level \xb7 Enter comments \xb7 Hold Space to use the page \xb7 Esc to finish \xb7 F7 selects text";var zn=`${wn},input,textarea,select,[contenteditable]:not([contenteditable=false])`;function Hn(e){let t=Ye("button",{type:"button","aria-label":"Comment",title:"Comment"},it("comment",17)),n=Ye("div",{class:"selbar"},t);n.inert=!0,e.e.append(n);let o=null,r=0,i=!1,a=t=>{let n=t&&(t.nodeType===Node.ELEMENT_NODE?t:t.parentElement);return!!n&&e.root.contains(n)&&!n.closest(zn)};function l(){if(!o)return;let t=o.cloneRange();t.selectNodeContents(ue(o.commonAncestorContainer,e.root));let r=o.getBoundingClientRect(),{left:i,top:a}=function(e,t,n,o,r,i=!1){let a=n+8;if(i){let n=r.width-o.width-4,i=t.left+t.width<n-8?t.top+t.height/2:e.top+t.height/2;return{left:n,top:Math.max((r.top??0)+8,Math.min(i-o.height/2,r.height-o.height-8))}}return a+o.width>r.width-8?tn(e,o,r):{left:a,top:t.top+t.height/2-o.height/2}}(r,[...o.getClientRects()].filter(e=>e.width).at(-1)??r,t.getBoundingClientRect().right,{width:n.offsetWidth||36,height:n.offsetHeight||34},{width:window.innerWidth,height:window.innerHeight},Zt());n.style.left=`${i}px`,n.style.top=`${a}px`}function s(){o=null,n.inert=!0,n.classList.remove("show")}function d(t=!1){let r=Ze();e.state.s&&r&&a(r.anchorNode)&&a(r.focusNode)?(!o&&!t&&e.L("Enter comments on the selected words"),o=r.getRangeAt(0).cloneRange(),l(),n.inert=!1,n.classList.add("show")):s()}t.addEventListener("mousedown",e=>e.preventDefault()),t.addEventListener("click",t=>{if(t.stopPropagation(),e.state.t&&!e.E())return e.te();let n,r=o;if(!r)return;try{n=pe(r,e.root,e.f.view(r.commonAncestorContainer))}catch(t){return e.ee(t),void s()}let i=Je(r.toString().replace(/\s+/g," ").trim(),60);window.getSelection()?.removeAllRanges(),s(),e.Ze({anchor:n,label:`\u201c${i}\u201d`,ranges:[r],resolved:{state:"attached",element:null,range:r}})});let c=()=>{window.clearTimeout(r),r=window.setTimeout(()=>i||d(),250),o&&(Ze()||s())};document.addEventListener("selectionchange",c);let u=t=>{"keyup"!==t.type&&(i="mousedown"===t.type),!i&&!e.M(t)&&window.setTimeout(()=>d("mouseup"===t.type),0)};window.addEventListener("mousedown",u,!0),window.addEventListener("mouseup",u,!0),window.addEventListener("keyup",u,!0);let p=n=>{"Enter"!==n.key||!o||e.M(n)||n.target instanceof Element&&n.target.closest(`${zn},${Tn}`)||(n.preventDefault(),n.stopPropagation(),t.click())};return window.addEventListener("keydown",p,!0),{m(){!e.state.s&&o&&s()},O(){o&&l()},destroy(){window.removeEventListener("mousedown",u,!0),window.removeEventListener("mouseup",u,!0),window.removeEventListener("keyup",u,!0),window.removeEventListener("keydown",p,!0),window.clearTimeout(r),document.removeEventListener("selectionchange",c),n.remove()}}}async function On(e,t){try{return void await navigator.clipboard.writeText(e)}catch{}let n=t.getRootNode().activeElement??document.activeElement,o=document.createElement("textarea");o.value=e,o.setAttribute("readonly",""),o.style.cssText="position:fixed;opacity:0;pointer-events:none",t.append(o),o.select();let r=document.execCommand("copy");if(o.remove(),n instanceof HTMLElement&&n.focus({preventScroll:!0}),!r)throw new Error("pipeup: your browser blocked copying")}var Fn="Hidden on the page",Bn=["auto","light","dark"];function In(e){let t=[Ye("span",{class:"n"}),Ye("span",{class:"n"})],n=it("comment",22,1.4);n.lastElementChild.setAttribute("stroke-width","1.6");let o=Ye("span",{class:"cnt"},it("bubble",28,1.4),it("wide",28,1.4),...t),r=Ye("button",{class:"mode",type:"button","aria-label":"Comment","aria-keyshortcuts":Ft,"aria-haspopup":"menu","aria-expanded":"false"},Ye("span",{class:"plus"},n),o,Ye("span",{class:"dot"})),i=document.createTextNode(""),a=Ye("span",{class:"ttip","aria-hidden":"true"},Ye("span",{},i,Ye("small",{},Ht))),l=Ye("div",{class:"launch"},r,a),s=Ye("div",{class:"menu",role:"menu","aria-label":"Comments"}),d=Ye("div",{class:"list",role:"list","aria-label":"Comments"}),c=Ye("button",{class:"ib",type:"button","aria-label":"Close"},it("close")),u=(e,t,n,o)=>{let r=Ye("button",{class:"tg",type:"button","aria-label":e,"aria-description":t,"data-tip":t,"aria-pressed":"false"},n,e);return r.addEventListener("click",e=>{e.stopPropagation(),o()}),r},p=u("For you","Only comments that mention you",it("at",16,1.8),()=>e.l.toggleMine()),h=u("Resolved","Show resolved comments too",it("resolve",22,1.7),()=>e.l.Je()),f=Ye("div",{class:"lns"}),v=new Map,w=Ye("span",{class:"ma"}),y=Ye("span",{class:"lb"}),b=Ye("button",{class:"fs",type:"button",role:"switch","aria-checked":"false","aria-keyshortcuts":Ft},"Comment",Ye("small",{class:"ks","aria-hidden":"true"},Ht),Ye("span",{class:"sw","aria-hidden":"true"}));b.addEventListener("click",t=>{t.stopPropagation(),e.Te(!e.state.s,!e.state.s&&0===t.detail)});let x=Ye("button",{class:"ib",type:"button","aria-label":"More","aria-haspopup":"menu","aria-expanded":"false"},it("more",15,3)),k="",E=Ye("div",{class:"all",role:"dialog","aria-label":"All comments"},Ye("div",{class:"hh",role:"heading","aria-level":"2"},"All comments"),Ye("div",{class:"hd"},p,h,Ye("span",{class:"sp"}),c),f,d,Ye("div",{class:"pf"},w,y,b,x)),S=document.createElementNS("http://www.w3.org/2000/svg","svg");S.setAttribute("class","cx"),S.setAttribute("aria-hidden","true");let $=document.createElementNS("http://www.w3.org/2000/svg","path"),L=document.createElementNS("http://www.w3.org/2000/svg","circle");L.setAttribute("r","4"),S.append($,L),s.inert=E.inert=!0,e.e.append(s,l,S,E);let M=!1,C=null,A=0,T=[],P=0,q=null,R=null,N=null,D=!0===window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,z=()=>{},H=t=>{M=e.state.l=t,e.taps(),t&&e.addons.flush(),window.clearTimeout(A),A=0,t||C?.(!0),t?s.classList.toggle("inp",e.state.u):z(),s.classList.toggle("show",t),_e(s,!t),r.setAttribute("aria-expanded",String(t)),x.setAttribute("aria-expanded",String(t))},O=(t,n=!1)=>{if(e.state.u===t)return;e.keepReplies();let o=t?e.state.i:null;o&&(e.state.i=null),e.state.u=t,e.m(),o&&T.some(e=>e.id===o)?ce(o,!0):t&&e.state.t?e.focusDraft():t?(F(d)[0]??c).focus({preventScroll:!0}):n&&r.focus({preventScroll:!0})},F=(e=s)=>[...e.querySelectorAll(".mi")].filter(e=>e.offsetParent&&!e.closest("[inert]")),B=()=>s.getRootNode().activeElement,I=()=>{H(!1),r.focus({preventScroll:!0})},j=e=>{let t=F(e.currentTarget);if(0===t.length)return;let n=B(),o=t.indexOf(n),r=n=>{e.preventDefault(),t[(n+t.length)%t.length]?.focus({preventScroll:!0})};"ArrowDown"===e.key?r(o+1):"ArrowUp"===e.key?r(o<0?t.length-1:o-1):"Home"===e.key?r(0):"End"===e.key&&r(t.length-1)};s.addEventListener("keydown",j),d.addEventListener("keydown",j),c.addEventListener("click",e=>{e.stopPropagation(),O(!1,!0)});let W=t=>un(e,t),K=t=>pn(e,t),V=t=>T.filter(n=>!n.resolved&&(void 0===t||e.j(n)===t)).length,U=t=>{let n=t.anchor.view?.slide,o=e.f.w(t.anchor.view)?"":Me(t.anchor.view);return n&&null!==e.f.slide()?`On slide ${n}`:o?`In ${o}`:Fn},Y=(e,t,n=!1)=>{let o=new Set(t),r=new Set(e.childNodes),i=new Map,a=new Set(t.map(_));for(let e of r){if(o.has(e))continue;let t=_(e);t&&a.has(t)&&i.set(t,e.offsetHeight),n&&Z&&e instanceof HTMLElement&&!i.has(t)?J(e):e.remove()}let l=e.firstChild;for(let n of t){for(;l&&l!==n&&G.has(l);)l=l.nextSibling;l===n?l=n.nextSibling:e.insertBefore(n,l)}if(n&&Z)for(let e of t)e instanceof HTMLElement&&(r.has(e)?G.delete(e)&&X(e,e.offsetHeight):X(e,i.get(_(e))??0))},_=e=>e instanceof HTMLElement?e.firstElementChild?.dataset.thread:void 0,G=new WeakSet,Z=!1,J=e=>{if(!G.has(e)){if(e.classList.contains("out"))return e.remove();G.add(e),e.style.height=`${e.offsetHeight}px`,e.offsetHeight,e.classList.add("out"),D||(e.style.height="0"),setTimeout(()=>G.delete(e)&&e.remove(),340)}},X=(e,t)=>{let n=e.style;n.transition="none",e.classList.remove("out"),n.height=n.maxHeight=n.overflow="";let o=e.offsetHeight,r=o>t?"maxHeight":"height";(D||!t)&&e.classList.add("out"),D||(n.overflow="hidden",n[r]=`${t}px`),e.offsetHeight,n.transition="",e.classList.remove("out"),!D&&(n[r]=`${o>t?o+40:o}px`,setTimeout(()=>n[r]=n.overflow="",360))},Q=new Map,ee=(e,t,n="",o=e)=>{let[r,i,a]=Q.get(o)??[];return(!r||!i||!a)&&Q.set(o,[r=Ye("div",{role:"listitem"}),i=Ye("div",{class:"sec","aria-hidden":"true"}),a=Ye("div",{role:"list"})]),a.setAttribute("aria-label",n?`${e} \xb7 ${n}`:e),i.replaceChildren(e,n&&Ye("b",{},n)),Y(r,[i,a]),Y(a,t,!0),r},te=Ye("div",{class:"sec",role:"listitem"});function ne(t,n){let o=e.f.slide(),r=new Map;for(let n of t){let t=n.thread,i=null!==o?t.anchor.view?.slide??o:e.j(t)?e.f.w(t.anchor.view)?"":Me(t.anchor.view):null;r.set(i,[...r.get(i)??[],n])}if(null===o){let e=r.get(null)??[];return r.delete(null),[...e.flatMap(n),...[...r].map(([e,t])=>ee(e||Fn,t.flatMap(n)))]}return[...r].sort(([e],[t])=>Number(e)-Number(t)||0).map(([e,t])=>ee(`Slide ${e} \xb7 ${t.filter(e=>!e.thread.resolved).length} open`,t.flatMap(n),e===o?"This slide":"",`slide:${e}`))}let oe=null,re=new Map,ie=new Set,ae={...e.B,get me(){return e.B.me},resolve:async t=>{let n=re.get(t)?.card;n&&!e.state.R&&!D&&(ie.add(t),n.style.height=`${n.offsetHeight}px`,n.offsetHeight,n.classList.add("out"),n.style.height="0",await new Promise(e=>setTimeout(e,340))),await e.B.resolve(t),ie.delete(t),n?.style.removeProperty("height"),e.m()}};function le(){let t=B(),n=t?.dataset.thread,o=null!==R&&R.element.contains(t),r=[...re.values()].find(e=>e.view.element.contains(t)),i=()=>[...r.view.element.querySelectorAll("button,textarea")],a=r?i().indexOf(t):-1,l=r?F(d).indexOf(r.card.firstChild):-1,s=e.l.all().filter(t=>!t.thread.resolved||e.state.R||t.thread.id===q).filter(t=>!e.state.mine||((e,t)=>[e.root,...e.root.replies].some(e=>e.author!==t&&!e.deleted&&yt(e,xt(t))))(t.thread,e.doc.me));h.setAttribute("aria-pressed",String(e.state.R)),p.setAttribute("aria-pressed",String(e.state.mine));let c=e.l.name();if(y.textContent=c||m(e.doc.me),ct(e.doc.me,c)!==k){k=ct(e.doc.me,c);let t=ut(e.doc.me,c);t.classList.add("in"),w.replaceChildren(t)}b.setAttribute("aria-checked",String(e.state.s));let u=e.state.t;N&&N.of!==u&&(N=null,u||e.H(null));let f=u&&!N;if(u&&!N){q=R=null;let t=It(e,u);N={of:u,p:t,card:Ye("div",{class:"cd open new",role:"listitem"},t.element)}}N&&(N.p.de(u.label),N.p.J(!1)),oe&&oe.id!==q&&(oe=null);let v=u&&(u.resolved.range?.startContainer??u.resolved.element),x=v?s.find(t=>{let n=nn(e,t.thread);return n&&4&v.compareDocumentPosition(n)})?.thread.id??null:null,E=e=>{let t,n=e.thread,o=n.id===q,r=sn(n).length,i=[r?ln(r):"",...n.root.reactions.map(e=>`${e.emoji} ${e.by.length}`)].filter(Boolean).join(" \xb7 "),a=W(n)?`\u201c${Je(n.anchor.snapshot,80)}\u201d`:n.anchor.quote?`\u201c${Je(n.anchor.quote.exact,80)}\u201d`:e.location.where,l=Ye("button",{class:"mi",type:"button","aria-expanded":String(o),"data-thread":n.id},Ye("span",{class:"sr"},[g(n.root),Pe(n.root.at,Date.now()),K(n)&&"Moved",a,n.root.text,i].filter(Boolean).join(", ")));if(l.addEventListener("click",e=>{e.stopPropagation(),ce(n.id)}),o&&R){if(R.update(n,se(n,a)),!oe){let e=Ye("div",{class:"xr",role:"region","aria-label":"Comment thread"},R.element);e.addEventListener("click",e=>{let t=e.target;t.closest(".root>.hdr")&&!t.closest("button")&&ue(!0)}),oe={id:n.id,card:Ye("div",{role:"listitem"}),xr:e}}t=oe.card,t.className="cd open"+(n.resolved?" done":""),Y(t,[l,oe.xr])}else{let e={D:"card",note:a,rest:i,quote:n.anchor.quote?.exact,moved:K(n)},o=re.get(n.id);o?o.view.update(n,e):re.set(n.id,o={card:Ye("div",{role:"listitem"}),view:dn(n,ae,e)}),t=o.card,t.className=`cd${n.resolved?" done":""}${ie.has(n.id)?" out":""}`,Y(t,[l,o.view.element])}return N&&n.id===x?[N.card,t]:[t]},S=s.filter(e=>W(e.thread));te.textContent=e.state.mine?"No comments mention you":"No open comments",Y(d,[...s.length||N?[]:[te],...ne(s.filter(e=>!W(e.thread)),E),...N&&null===x?[N.card]:[],...S.length?[ee("No longer on the page",S.flatMap(E))]:[]],!0),Z=!0;for(let e of re.keys())s.some(t=>t.thread.id===e)||re.delete(e);let $=B();f?N.p.focus():N?.card.contains(t)&&!N.card.contains($)?N.p.le()():o&&!R.element.contains($)?R.element.querySelector("textarea")?.focus({preventScroll:!0}):r&&$!==t?(r.card.isConnected?i()[a]:F(d)[Math.min(l,F(d).length-1)])?.focus({preventScroll:!0}):n&&$!==t&&F(d).find(e=>e.dataset.thread===n)?.focus({preventScroll:!0})}function se(t,n){let o=!W(t)&&e.j(t);return{D:"popover",quote:t.anchor.quote?.exact??null,lost:W(t)||o?t.anchor.snapshot:null,place:o?U(t):null,moved:K(t),note:!Gt()||W(t)||o||t.anchor.quote?null:n}}let de="";function ce(t,n=!1){if(q===t)return ue(!0);let o=T.find(e=>e.id===t);if(o){if(e.keepReplies(),q=de=t,R=dn(o,{...e.B,close:()=>ue(!0)},se(o)),e.seen(o),le(),e.putReply(t),Zt()||R.element.querySelector("textarea")?.focus({preventScroll:!0}),n&&d.querySelector(".mi.open")?.scrollIntoView({block:"nearest"}),!e.j(o))return pe(o,!n);e.state.t&&!e.E()||e.f.Z(o.anchor.view??{}).then(()=>{e.Me();let n=T.find(e=>e.id===t);n&&de===t&&q===t&&pe(n)})}}function ue(t=!1){if(!q)return;let n=q;e.keepReplies(),q=R=null,e.S(null),le(),t&&F(d).find(e=>e.dataset.thread===n)?.focus({preventScroll:!0})}function pe(t,n=!0){let o=e.resolved.get(t.id),r=o&&!W(t)?o.element??o.range?.startContainer.parentElement??null:null;n&&r?.scrollIntoView({block:"center",inline:"nearest",behavior:D?"auto":"smooth"}),r&&e.S(t.id)}function he(t,n){let o=n?n.resolved:e.resolved.get(t.id),r=o?.element??o?.range?.startContainer.parentElement;if(!o||Gt()||t&&(W(t)||e.j(t))||!1===r?.checkVisibility?.({visibilityProperty:!0}))return null;let i=t?e.e.querySelector(`.bub[data-thread="${t.id}"]`)?.getBoundingClientRect():void 0,a=o.range?Kt(o).at(-1):void 0,l=r?.closest("p,li,h1,h2,h3,h4,h5,h6,blockquote,td,th,figcaption,div")?.getBoundingClientRect().right,s=o.element?.getBoundingClientRect(),d=Ut(n?n.anchor:t.anchor,o),c=i?.width?{x:i.right+1,y:i.top+i.height/2,from:"right",bubble:!0}:a?{x:Math.max(a.right,l??0)+4,y:(a.top+a.bottom)/2,from:"right"}:s?{x:s.left+s.width/2,y:s.top,from:"top"}:d&&{x:d.x,y:d.y,from:"right"};return c&&c.x>=0&&c.x<=window.innerWidth-320&&c.y>=0&&c.y<=window.innerHeight?c:null}function fe(e,t,n=!1,...o){let r=Ye("button",{class:"mi",type:"button",role:n?"menuitemcheckbox":"menuitem"},e,Ye("span",{class:"lb"}),...o,n&&Ye("span",{class:"sw","aria-hidden":"true"}),Ye("span",{class:"tt","aria-hidden":"true"}));return r.addEventListener("click",e=>{e.stopPropagation(),t(e)}),r}let me=(e,t,n,o)=>{let r=e.querySelector(".lb");r.textContent!==t&&(r.textContent=t),e.querySelector(".tt").textContent=n,e.setAttribute("aria-description",n),void 0!==o&&e.setAttribute("aria-checked",String(o))},ge=()=>Ye("div",{class:"sep",role:"separator"}),ve=Ye("span",{class:"ma"}),we=Ye("span",{class:"kc"}),ye="",be=fe(ve,function(){let t=Ye("input",{class:"input",type:"text",maxlength:"80","aria-label":"Your name"});t.value=e.l.name();let n=Ye("div",{class:"ed"},ve.cloneNode(!0),t),o=(r,i=!1)=>{if(C!==o)return;C=null;let a=t.value.trim();r&&a&&a!==e.l.name()&&e.l.rename(a).then(Ie),n.replaceWith(be),i&&be.focus({preventScroll:!0})};C=o,t.addEventListener("keydown",e=>{e.stopPropagation(),("Enter"===e.key||"Escape"===e.key)&&(e.preventDefault(),o("Enter"===e.key,!0))}),t.addEventListener("blur",()=>o(!0)),be.replaceWith(n),t.focus({preventScroll:!0})},!1,we);be.dataset.item="name";let xe=fe(it("copy"),()=>{I(),e.l.copyAll("ai")}),ke=fe(it("lines"),()=>{I(),e.l.copyAll("text")}),Ee=Ye("div",{class:"subs",role:"group"},Ye("div",{},xe,ke)),Se=fe(it("copy"),()=>$e("true"!==Se.getAttribute("aria-expanded")),!1,Ye("span",{class:"chev"},it("chev",13))),$e=(e,t=!0)=>{Se.setAttribute("aria-expanded",String(e)),Ee.classList.toggle("open",e),_e(Ee,!e),t&&(e?xe:Se).focus({preventScroll:!0})};z=()=>$e(!1,!1),z(),Se.addEventListener("keydown",e=>{"ArrowRight"===e.key&&"true"!==Se.getAttribute("aria-expanded")&&(e.preventDefault(),$e(!0))}),Ee.addEventListener("keydown",e=>{"ArrowLeft"===e.key&&(e.preventDefault(),$e(!1))});let Le=Ye("span",{class:"kc"}),Ce=fe(it("look"),()=>{e.l.setLook(Bn[(Bn.indexOf(e.l.look())+1)%3]),Ie()},!1,Le),Ae=Ye("span",{class:"kc"}),Te=fe(it("list"),()=>{H(!1),Te.dataset.item="all",O(!0)},!1,Ae),qe=fe(it("hide"),()=>{e.l.setHide(!e.state.hide),Ie()},!0),Re=fe(it("comment"),t=>{let n=!e.state.s&&0===t.detail;e.Te(!e.state.s,n),n?H(!1):e.state.s&&Zt()&&(window.clearTimeout(A),A=window.setTimeout(()=>M&&I(),600))},!0,Ye("span",{class:"kc ks","aria-hidden":"true"},Ht));Re.dataset.item="comment",Re.setAttribute("aria-keyshortcuts",Ft);let Ne=Ye("div",{class:"sec",role:"presentation"}),De=ge(),ze=ge(),He=new Map,Oe=t=>{let n=He.get(t);return n||(n=fe(at(t.icon,15),()=>{t.checked||I(),Promise.resolve().then(()=>t.select()).catch(t=>e.ee(t)).finally(()=>M&&Ie())},!!t.checked,Ye("span",{class:"kc"})),He.set(t,n)),n},Fe=-1,Be=e=>{try{return e()}catch(e){return globalThis.reportError?.(e),""}};function Ie(){let t=V(),n=e.l.name(),o=n||m(e.doc.me);if(me(be,o,n?"The name on your comments":"Add a name to show on your comments"),be.setAttribute("aria-label",`${o}, ${n?"edit":"add"} your name`),we.replaceChildren(n?it("edit",13):"Add name"),ct(e.doc.me,n)!==ye){ye=ct(e.doc.me,n);let t=ut(e.doc.me,n);t.classList.add("in"),ve.replaceChildren(t)}me(Se,"Copy comments","As Markdown, with where each thread is, or as text"),me(xe,"As Markdown","With where each thread is, ready for an AI or a document"),me(ke,"As text","Just the words");let r=["Automatic","Light","Dark"][Bn.indexOf(e.l.look())];me(Ce,"Theme","Automatic follows the page; press to change"),Le.textContent=r,me(Te,"All comments","Every thread, and where it is"),Ae.textContent=t?String(t):"";let i=e.addons.be();Ne.textContent=i,i?!Ne.isConnected&&s.contains(be)&&s.prepend(Ne):Ne.remove();for(let t of e.addons.K){let e,n=He.get(t);if(n){try{e=t.checked?.()}catch(e){globalThis.reportError?.(e)}me(n,Be(t.label),Be(t.hint),e),n.querySelector(".kc").textContent=t.count?Be(t.count):""}}me(qe,"Hide comments",e.state.hide?"Comments are hidden on this page until you turn this off":"Hides the comments on this page until you turn this off",e.state.hide),me(Re,"Start commenting",e.state.s?"Turn off to use the page as normal":"Choose any part of the page to comment on it",e.state.s)}function je(){Ie(),(Fe!==e.addons.ne||!s.contains(be))&&(s.replaceChildren(be,De,Se,Ee,Ce,Te,...e.addons.K.map(Oe),ze,qe,Re),Fe=e.addons.ne,Ie())}x.addEventListener("click",e=>{if(e.stopPropagation(),M)return H(!1);je(),H(!0),0===e.detail&&F()[0]?.focus({preventScroll:!0})}),r.addEventListener("click",t=>{if(t.stopPropagation(),!M)return e.state.s?O(!0):(je(),H(!0),void(0===t.detail&&F().at(-1)?.focus({preventScroll:!0})));H(!1)});for(let e of[r,x])e.addEventListener("keydown",e=>{let t=F();!M||!t.length||"ArrowDown"!==e.key&&"ArrowUp"!==e.key||(e.preventDefault(),e.stopPropagation(),("ArrowDown"===e.key?t[0]:t.at(-1))?.focus({preventScroll:!0}))});let We=t=>{let n=t.composedPath();M&&!n.includes(s)&&!n.includes(r)&&!n.includes(x)&&(H(!1),e.state.s&&!e.M(t)&&(e.fe(t),t.preventDefault(),t.stopPropagation()))},Ke=e=>{if(!M||"touch"===e.pointerType||"pointerout"===e.type&&e.relatedTarget)return;let t=e.composedPath();"pointerover"===e.type&&(t.includes(s)||t.includes(r)||t.includes(x))?(window.clearTimeout(A),A=0):A||(A=window.setTimeout(()=>{A=0,C||H(!1)},3e3))},Ve={n:0,label:""},Ue=()=>{let{n:t,label:n}=Ve,o=e.addons.be(),a=`Comment${e.state.s?", comment mode on":""}${n?`, ${n}`:t?`, ${t} open`:""}${o?`, ${o}`:""}`;r.getAttribute("aria-label")!==a&&r.setAttribute("aria-label",a),r.setAttribute("aria-haspopup",e.state.s?"dialog":"menu");let l=n||(t>9?`${t} open`:""),s=[l,o].filter(Boolean).join(" \xb7 ")+(l||o?" \xb7 ":"");i.data!==s&&(i.data=s)},Ge=e.addons.subscribe(t=>{Ue(),(()=>{for(let[t,n]of v)e.addons.listNotes.has(t)||(v.delete(t),n.row.classList.remove("show"),setTimeout(()=>n.row.remove(),320));for(let[t,n]of e.addons.listNotes){let o=v.get(t);if(!o){let e=Ye("span",{}),r=Ye("div",{class:"ln"},Ye("div",{class:"lw"},Ye("div",{class:"ag"},e)));r.dataset.addon=t,o={row:r,words:e,btn:null,note:n},v.set(t,o),f.append(r),requestAnimationFrame(()=>{r.offsetWidth,r.classList.add("show")})}if(o.note=n,o.words.textContent!==n.text&&(o.words.textContent=n.text),n.action&&!o.btn){let t=Ye("button",{type:"button"}),n=o;t.addEventListener("click",o=>{o.stopPropagation();let r=n.note.action;r&&(t.disabled=!0,r.run().catch(t=>e.ee(t)).finally(()=>{t.disabled=!1,e.m()}))}),o.btn=t,o.words.after(t)}else!n.action&&o.btn&&(o.btn.remove(),o.btn=null);o.btn&&n.action&&o.btn.textContent!==n.action.label&&(o.btn.textContent=n.action.label)}})(),M&&!C&&(t?je():Ie())});window.addEventListener("click",We,!0),window.addEventListener("pointerover",Ke,!0),window.addEventListener("pointerout",Ke,!0);let Ze=t=>{if("Escape"!==t.key||t.isComposing||C||t.composedPath().some(e=>e instanceof Element&&e.matches(".rxp,.pm")))return;let n=t.composedPath()[0];if(n instanceof HTMLTextAreaElement&&n.value.trim())return;let o=n instanceof Element&&n.closest(".cd:not(.open,.new)");if(M&&Ee.contains(n))$e(!1);else if(M)I();else if(o&&n!==o.firstChild){if(n instanceof HTMLTextAreaElement)return;o.firstChild.focus({preventScroll:!0})}else{if(!e.state.u||n instanceof HTMLTextAreaElement&&!E.contains(n))return;e.state.t?e.W():q?ue(!0):O(!1,!0)}t.preventDefault(),t.stopPropagation()};return window.addEventListener("keydown",Ze,!0),e.registerList(e=>{q!==e&&ce(e,!0)}),{m(n){T=n;let i=V(!1);if(i!==P){if(i){let[e,n]=t[0].classList.contains("on")?t:[t[1],t[0]];n.textContent=i>9?"9+":String(i),o.classList.toggle("w",i>9),e.classList.remove("on"),n.classList.add("on")}r.classList.toggle("has",i>0),P=i}let a=V(!0),s=a?`${i} here \xb7 ${a} ${null!==e.f.slide()?"on other slides":"in other views"}`:"";r.classList.toggle("else",a>0),Ve={n:i,label:s},Ue(),r.classList.toggle("on",e.state.s),M&&!e.state.l&&H(!1),M&&Ie();let d=e.state.u;E.classList.toggle("full",Gt()),E.classList.contains("show")!==d&&(E.classList.toggle("show",d),_e(E,!d),_e(l,d)),q&&(!d||!n.some(e=>e.id===q))&&(q=R=null,e.state.S=null),d?le():Z=!1},O:function(){let t=q?T.find(e=>e.id===q):null,n=N?.card??(q?d.querySelector(".cd.open"):null),o=N?he(null,N.of):t&&he(t),r=n?.getBoundingClientRect(),i=d.getBoundingClientRect();if(!e.state.u||!o||!r?.width||r.top+12<i.top||r.top+12>i.bottom)return void S.classList.remove("show");let a,l=r.left,s=r.top+14;if("right"===o.from&&l-o.x>60){let e=o.x+28,t=o.y>=s?1:-1,n=Math.min(24,Math.abs(o.y-s)/2);a=`M${l} ${s}C${l-24} ${s} ${e} ${s} ${e} ${s+t*n}L${e} ${o.y-t*n}C${e} ${o.y} ${e} ${o.y} ${o.x} ${o.y}`}else{let e=o.y-8,t=l-40,n=e>=s?1:-1,r=Math.min(20,Math.abs(e-s)/2);a=`M${l} ${s}C${l-20} ${s} ${t} ${s} ${t} ${s+n*r}L${t} ${e-n*r}C${t} ${e} ${t} ${e} ${t-r} ${e}L${o.x+8} ${e}C${o.x} ${e} ${o.x} ${e} ${o.x} ${o.y}`}$.setAttribute("d",a),L.setAttribute("r",o.bubble?"0":"4"),L.setAttribute("cx",String(o.x)),L.setAttribute("cy",String(o.y)),S.classList.add("show")},destroy(){Ge(),window.removeEventListener("click",We,!0),window.removeEventListener("pointerover",Ke,!0),window.removeEventListener("pointerout",Ke,!0),window.clearTimeout(A),window.removeEventListener("keydown",Ze,!0),e.registerList(null),s.remove(),E.remove(),S.remove(),l.remove()}}}var jn="[data-pipeup-slide]",Wn=["scroll","resize","keyup","click","transitionend","slidechanged"],Kn=null,Vn=null,Un=new Set,Yn=new Set,_n=e=>{try{e()}catch(e){globalThis.reportError?.(e)}};function Gn(e){Vn="function"==typeof e?.current&&"function"==typeof e.go?e:null}var Zn=()=>{let e=window.Reveal;return"function"==typeof e?.getIndices&&"function"==typeof e.slide?e:null};var Jn,Xn="#534AB7";function Qn(e,t){let n=function(e){let t=/rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)(?:\s*[,/]\s*([\d.]+%?))?\s*\)/.exec(e);if(!t||void 0===t[1]||void 0===t[2]||void 0===t[3])return null;let n=void 0===t[4]?1:t[4].endsWith("%")?parseFloat(t[4])/100:parseFloat(t[4]);return{r:Number(t[1]),g:Number(t[2]),b:Number(t[3]),a:n}}(e);if(n||!e||"transparent"===e)return n;try{if(Jn??=t.createElement("canvas").getContext("2d",{willReadFrequently:!0})??null,!Jn)return null;Jn.clearRect(0,0,1,1),Jn.fillStyle="#000",Jn.fillStyle=e,Jn.fillRect(0,0,1,1);let[n,o,r,i]=Jn.getImageData(0,0,1,1).data;return{r:n,g:o,b:r,a:i/255}}catch{return null}}function eo(e){let t=e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4};return.2126*t(e.r)+.7152*t(e.g)+.0722*t(e.b)}var to=[[.92,.25],[.92,.6],[.5,.45]];function no(e){let t=e.defaultView,n=e.documentElement,o=t?.getComputedStyle(n).colorScheme||"",r=/dark/.test(o)&&(!/light/.test(o)||!0===t?.matchMedia?.("(prefers-color-scheme: dark)").matches),i=t?Qn(t.getComputedStyle(n).backgroundColor,e):null;return t&&e.body&&(!i||i.a<.5)&&(i=Qn(t.getComputedStyle(e.body).backgroundColor,e)),i&&i.a>=.5?i:r?{r:0,g:0,b:0}:{r:255,g:255,b:255}}function oo(e,t){let n=e.ownerDocument,o=n.defaultView,r="dark"===t;if(!o)return{font:"system-ui, sans-serif",accent:Xn,dark:r,on:"#fff"};let i=n.documentElement,a=o.getComputedStyle(e).fontFamily||"system-ui, sans-serif",l=(o.getComputedStyle(i).getPropertyValue("--pipeup-accent")||i.style.getPropertyValue("--pipeup-accent")).trim(),s=e.querySelector("a[href]"),d=s?o.getComputedStyle(s).color:"",c=l||"rgb(0, 0, 238)"!==d&&d,u=c?Qn(c,n):null,[p,h,f]=r?[27,27,25]:[255,255,255],m=u&&((e,t)=>(Math.max(e,t)+.05)/(Math.min(e,t)+.05))(eo(u),eo({r:.12*u.r+.88*p,g:.12*u.g+.88*h,b:.12*u.b+.88*f}))>=4.5?c:r?"#9A94EE":Xn,g=Qn(m,n);return{font:a,accent:m,dark:r,on:g&&eo(g)>.19?"#111":"#fff"}}function ro(e,t){e.style.setProperty("--pu-font",t.font),e.style.setProperty("--pu-accent",t.accent),e.style.setProperty("--pu-on",t.on),e.classList.toggle("dark",t.dark)}var io=["pipeup-quote","pipeup-on","pipeup-done"],ao={"pipeup-quote":[[250,227,188,.75],[180,120,0,.35]],"pipeup-on":[[247,212,154,.95],[180,120,0,.5]],"pipeup-done":[[180,178,169,.22],[140,138,130,.2]]};function lo(){return typeof CSS<"u"&&"highlights"in CSS&&typeof Highlight<"u"}var so=`:not(${wn},:is(${wn}) *){cursor:url("data:image/svg+xml,${encodeURIComponent("<svg xmlns='http://www.w3.org/2000/svg' width='32' height='32'><rect x='7' y='7' width='23' height='23' rx='4' fill='none' stroke='#534AB7' stroke-width='2' stroke-dasharray='4 3'/><path d='M3 2v15l4-3.5 3 6.5 2.5-1.2-3-6.3H15z' fill='#fff' stroke='#2C2C2A' stroke-width='1.2' stroke-linejoin='round'/></svg>")}") 3 2,crosshair!important}`;function co(){if(lo())for(let e of io)for(let t of["","-d"])CSS.highlights.delete(e+t)}var uo={light:["#2C2C2A","#FFFFFF"],dark:["#ECEBE6","#1B1B19"]},po=[["opacity","1"],["filter","none"],["backdrop-filter","none"],["mix-blend-mode","normal"],["transform","none"],["clip-path","none"],["mask-image","none"],["zoom","1"]];function ho(e,t,n){let[o,r]=uo[e].map(e=>{let[o,r,i]=(e=>[1,3,5].map(t=>parseInt(e.slice(t,t+2),16)))(e).map((e,o)=>t*e+(1-t)*n[o]);return eo({r:o,g:r,b:i})});return((e,t)=>(Math.max(e,t)+.05)/(Math.min(e,t)+.05))(o,r)}var fo=["ArrowUp","ArrowDown","Home","End","PageUp","PageDown"];function mo(e,t=!1){return cn(e,t)?"column":"bubbles"}var go="Shown here, but not saved yet \u2014 it will be saved with your next change",vo=e=>e instanceof Error?e.message.replace(/^pipeup: /,""):"Something went wrong";function wo(e){let t="pipeup:look",n="auto";try{let e=localStorage.getItem(t);("light"===e||"dark"===e)&&(n=e)}catch{}let o,r=!1,i=!1,a="",l=()=>{let e="auto"!==n?n:function(e){let t=e.documentElement.getAttribute("data-pipeup-theme")??e.body?.getAttribute("data-pipeup-theme");return"light"===t||"dark"===t?t:null}(document);i=function(e,t=!1){let n=e.defaultView;if(!n)return!1;let o=e.documentElement,r=eo(no(e)),i=(t,n)=>{try{if(e.elementsFromPoint)return e.elementsFromPoint(t,n)}catch{}return e.body?[e.body,o]:[o]},a=0;for(let[t,o]of to){let l=r;for(let r of i(n.innerWidth*t,n.innerHeight*o)){if(r.closest("[data-pipeup-ignore]"))continue;let t=r.getBoundingClientRect();if(t.width*t.height<.25*n.innerWidth*n.innerHeight)continue;let o=Qn(n.getComputedStyle(r).backgroundColor,e);if(o&&o.a>=.5){l=eo(o);break}}a+=l}let l=a/to.length;return l<.18||!(l>.32)&&t}(document,i);let t=e??(i?"dark":"light");o=function(e,t,n){let o=e.defaultView?.getComputedStyle(e.documentElement),r=po.flatMap(([e,t])=>{let n=o?.getPropertyValue(e).trim();return n&&n!==t?[`${e}: ${n}`]:[]}),i=Math.min(1,Math.max(0,parseFloat(o?.opacity??"1")||1)),{r:a,g:l,b:s}=no(e);return{look:t,source:n,ratio:ho(t,i,[a,l,s]),effects:r}}(document,t,"auto"!==n?"reviewer":e?"author":"page");let r=function(e){return!e.effects.length&&e.ratio>=3?null:`pipeup: the page's styles on <html> (${e.effects.join("; ")||"none"}) change how everything on the page looks, Pipeup included, and can't be undone from inside it. `+(e.ratio<3?"Pipeup's words may be hard to read. ":"")+"Move those styles to <body> or a wrapper."}(o);return r&&r!==a&&console.warn(a=r),t};r="dark"===l();let s=function(e,t,n=document){let o=n.createElement("pipeup-root");o.setAttribute("data-pipeup-ignore",""),o.style.cssText="position:fixed!important;inset:0!important;pointer-events:none!important;z-index:2147483647!important;display:block!important;margin:0!important;visibility:visible!important;opacity:1!important;transform:none!important;translate:none!important;scale:none!important;rotate:none!important;filter:none!important;clip-path:none!important;mask:none!important;zoom:1!important;";let r=o.attachShadow({mode:"open"}),i=n.defaultView?.CSSStyleSheet;if(i&&"replaceSync"in i.prototype&&"adoptedStyleSheets"in r){let e=new i;e.replaceSync(t),r.adoptedStyleSheets=[e]}else{let e=n.createElement("style");e.textContent=t,r.append(e)}let a=n.createElement("div");return a.className="layer",a.style.setProperty("--pu-panel","320px"),a.style.setProperty("--pu-pop",`${_t()}px`),ro(a,e),r.append(a),n.documentElement.append(o),{element:o,shadow:r,e:a,destroy:()=>o.remove()}}(oo(e.root,r?"dark":"light"),e.styles);s.e.classList.toggle("flip",r!==i);let d=function(e=document){let t=e.defaultView?.CSSStyleSheet;if(!t||!("replaceSync"in t.prototype)||!("adoptedStyleSheets"in e))return{Ae(){},Ce(){},ve(){},Pe(){},remove:()=>co()};let n=new t,o=null,r=!1,i=1,a=0,l="",s=0,d=()=>n.replaceSync((e=>io.map(t=>ao[t].map(([n,o,r,i],a)=>`::highlight(${t}${a?"-d":""}){background-color:rgba(${n},${o},${r},${+(i*e).toFixed(3)})}`).join("")).join(""))(i)+(null===o?"":`:root{--pipeup-gutter:${o}px}`)+(r?so:"")+(a||l?`html{--pipeup-panel:${a}px;width:auto!important;${a?`margin-right:${a}px!important;`:""}${l}}`:""));return d(),e.adoptedStyleSheets=[...e.adoptedStyleSheets,n],{Ae(e){e!==o&&(o=e,d())},Ce(e){e!==r&&(r=e,d())},ve(e){i=e,d()},Pe(e,t){e!==a&&(a=e,l=t?"":"transition:margin-right .34s cubic-bezier(.4,0,.2,1)!important",clearTimeout(s),!e&&l&&(s=window.setTimeout(()=>{l="",d()},400)),d())},remove(){clearTimeout(s),e.adoptedStyleSheets=e.adoptedStyleSheets.filter(e=>e!==n),co()}}}(document);d.ve(0);let c=!0===window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,u=document.documentElement.hasAttribute("data-pipeup-reserve"),p=new Map,h=new Set,f=new WeakSet,v=`pipeup:hide:${e.doc.id}`,w=!1;try{w="1"===localStorage.getItem(v)}catch{}let y={i:null,S:null,R:!1,mine:!1,hide:w,hidden:w,mode:mo(e.root),t:null,s:!1,paused:!1,u:!1,$e:!1,l:!1,pinning:!1},b=Ye("div",{class:"toast",role:"status","aria-live":"polite"}),x=null,k=Ye("div",{class:"sr","aria-live":"polite"});s.e.append(b,k);let E=null,S=null,$=[],L=null,M=!1,C=0,A=0,T=0,P=0,q=0,R=new Set,N="",D=new Map,z=function(e,t,n=function(){return{p:e=>e.getBoundingClientRect(),shown:e=>!1!==e.checkVisibility?.({opacityProperty:!0,visibilityProperty:!0}),opacity:e=>parseFloat(getComputedStyle(e).opacity)||0,Q:()=>({width:window.innerWidth,height:window.innerHeight})}}()){let o=!0===window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,r=null,i=null,a=[],l=0,s=!1,d=()=>[...e.querySelectorAll(jn)],c=()=>[...e.querySelectorAll(".slides > section")],u=e=>"string"==typeof e&&e.length>0&&e.length<=200?e:null,p=e=>u(e?.getAttribute("data-pipeup-slide")),h=e=>{let t=c()[e];return p(t?.matches(jn)?t:t?.querySelector(jn))??u(String(e+1))};function f(){if(a=[],Vn){let e=null;if(_n(()=>{let t=Vn.current();Number.isInteger(t)&&t>0&&(e=String(t))}),null!==e)return e}let e=Zn();if(e){let t=null;if(_n(()=>{t=h(e.getIndices().h)}),null!==t)return t}r&&!r.isConnected&&(r=null);let t=d();r=function(e,t,n){let o=t.Q(),r=null,i=0,a=0;for(let l of e){if(!t.shown(l))continue;let e=t.p(l),s=Math.min(e.left+e.width,o.width)-Math.max(e.left,0),d=Math.min(e.top+e.height,o.height)-Math.max(e.top,0);if(s<=0||d<=0)continue;let c=Math.round(s*d),u=t.opacity(l);(c>i||c===i&&(u>a||u===a&&l===n))&&(r=l,i=c,a=u)}return r}(t,n,r)??r;for(let e of function(e,t,n){let o=n&&t.p(n),r=t.Q().height;return e.filter(e=>{let n=t.p(e);return!!o&&t.shown(e)&&n.top<r&&n.top+n.height>0&&(n.top>=o.top+o.height||n.top+n.height<=o.top)})}(t,n,r)){let t=p(e);t&&a.push(t)}return p(r)}function m(){l=0,i=f(),t()}let g=()=>{!l&&!s&&(l=requestAnimationFrame(m))},v=e=>function(e,t,n,o=[]){return null!==t?void 0===e?.slide||e.slide===t||o.includes(e.slide):!e||!n||Object.entries(e).every(([e,t])=>"label"===e||"slide"===e||n[e]===t)}(e,i,Kn,a),w=new MutationObserver(e=>{e.some(e=>e.target instanceof Element&&e.target.matches(jn))&&g()});w.observe(e,{subtree:!0,attributes:!0,attributeFilter:["class","style","hidden"]});for(let e of Wn)window.addEventListener(e,g,{capture:!0,passive:!0});return Yn.add(g),i=f(),{slide:()=>i,view(e){let t=e instanceof Element?e:e?.parentElement,n=t&&Zn()?c().findIndex(e=>e.contains(t)):-1,o=p(t?.closest(jn))??(n>=0?h(n):i),r={...null!==o?{slide:o}:{},...Kn};return Object.keys(r).length?r:void 0},w:v,Z:function(e){if(v(e))return Promise.resolve(!0);let t=e.slide,n=Zn(),r=d().find(e=>p(e)===t),a=/^[1-9]\d{0,5}$/.test(t??"");if(a&&Vn)_n(()=>Vn.go(Number(t)));else if(a&&n){let e=r?c().findIndex(e=>e===r||e.contains(r)):-1;_n(()=>n.slide(e>=0?e:Number(t)-1))}else if(Un.size)for(let t of Un)_n(()=>t({...e}));else{if(!r)return Promise.resolve(!1);r.scrollIntoView({block:"start",behavior:o?"auto":"smooth"})}let l=performance.now();return new Promise(t=>{let n=e=>{clearTimeout(o),t(e)},o=setTimeout(()=>n(!1),1e3),r=()=>s?n(!1):(i=f(),v(e)?n(!0):performance.now()-l>=1e3?n(!1):void requestAnimationFrame(r));requestAnimationFrame(r)})},destroy(){s=!0,cancelAnimationFrame(l),w.disconnect();for(let e of Wn)window.removeEventListener(e,g,!0);Yn.delete(g)}}}(e.root,()=>{!M&&de()&&Ae()}),H=!1,O=null,F=0,B=()=>y.s&&!y.u&&Zt(),I=!1;function j(){!B()||y.l||(K("Tap what you want to comment on",0,!0,!1,{label:"Done",run:()=>Ue(!1)}),b.classList.add("tap"),W())}function W(){b.classList.toggle("taught",I),b.querySelector(".tw")?.toggleAttribute("aria-hidden",I)}function K(e,t=2400,n=!1,o=!1,r){if(M)return;if(n&&y.l)return void(O=()=>K(e,t,!0,o));H=n,b.replaceChildren(Ye("span",{class:"tw"},e)),b.classList.remove("tap","taught"),b.classList.toggle("act",!!r);let i=r?.run;if(x=i&&r.N?()=>{x=null,b.classList.remove("show"),i()}:null,r){let e=i?Ye("button",{class:"ta",type:"button",...r.N?{"aria-keyshortcuts":"Meta+Z Control+Z"}:{}},r.label):Ye("a",{class:"ta",href:r.href,target:"_blank",rel:"noopener noreferrer"},r.label);if(i){let t=x??(()=>{b.classList.remove("show"),i()});e.addEventListener("click",e=>{e.stopPropagation(),t()})}b.append(" ",e)}o?b.setAttribute("aria-hidden","true"):b.removeAttribute("aria-hidden"),b.classList.add("show"),window.clearTimeout(C),t&&(C=window.setTimeout(()=>{x=null,b.classList.remove("show"),C=window.setTimeout(j,320)},t))}let V=(e,t)=>K(e,6e3,!1,!1,{label:"Undo",run:t,N:!0});function U(){B()||(O=null,H&&(H=!1,window.clearTimeout(C),b.classList.remove("show")))}function _(e){k.textContent="",cancelAnimationFrame(F),F=requestAnimationFrame(()=>k.textContent=e)}function G(e){K(vo(e))}function Z(e){throw G(e),e}let J=()=>e.doc.threads().filter(e=>!e.root.deleted),X=t=>({thread:t,location:Le(t.anchor,p.get(t.id)??we(t.anchor,e.root),e.root)}),Q=e=>[...s.e.querySelectorAll(`[data-thread="${e}"] .rbox textarea`)].find(e=>!e.closest("[inert]"));function ee(){for(let e of s.e.querySelectorAll("[data-thread] .rbox textarea"))e.value.trim()&&D.set(e.closest("[data-thread]").getAttribute("data-thread"),e.value)}function te(e,t=!1){let n=D.get(e),o=Q(e);if(o){if(D.delete(e),n&&!o.value){o.value=n,o.dispatchEvent(new Event("input",{bubbles:!0}));for(let t of s.e.querySelectorAll(`[data-thread="${e}"] .rbox textarea`))t!==o&&t.value&&(t.value="",t.dispatchEvent(new Event("input",{bubbles:!0})))}t&&o.focus({preventScroll:!0})}}function ne(e){let t=Pe();if(!t?.closest(`[data-thread="${e}"]`))return()=>{};let n=t.closest(".cd")?".mi":t.closest(".th")?".opn":".bub",o=[...s.e.querySelectorAll(`${n}[data-thread]`)],r=o.findIndex(t=>t.getAttribute("data-thread")===e),i=r<0?null:(o[r+1]??o[r-1])?.getAttribute("data-thread");return()=>{if(L?.he())return L.ge();(i&&s.e.querySelector(`${n}[data-thread="${i}"]`)||s.e.querySelector(".launch .mode"))?.focus({preventScroll:!0})}}let oe={get me(){return e.doc.me},picker:()=>le.picker,people:()=>wt(e.doc.threads(),e.doc.me),react:async(t,n,o)=>{try{await(o?e.doc.react(t,n):e.doc.unreact(t,n))}catch(e){e instanceof Y?K(go):Z(e)}},reply:async(t,n,o)=>{try{await e.doc.reply(t,n,o),_("Reply sent"),Oe(o,n)}catch(e){e instanceof Y?K(go):Z(e)}},edit:async(t,n,o)=>{try{await e.doc.edit(t,n,o)}catch(e){e instanceof Y?K(go):Z(e)}},remove:async t=>{let n=e.doc.threads().find(e=>e.id===t||e.root.replies.some(e=>e.id===t)),o=n&&n.root.id===t?ne(n.id):()=>n&&Q(n.id)?.focus({preventScroll:!0});try{await e.doc.remove(t),o(),K("Deleted")}catch(e){K(e instanceof Y?`Deleted \xb7 ${go}`:vo(e))}},resolve:async t=>{let n=ne(t);s.e.classList.add("still"),window.addEventListener("pointermove",()=>s.e.classList.remove("still"),{once:!0});try{await e.doc.resolve(t),K("Resolved \xb7 \u2713 Resolved in All comments shows it again")}catch(e){K(e instanceof Y?`Resolved \xb7 ${go}`:vo(e))}y.R||(y.i===t&&(y.i=null),n())},reopen:async t=>{try{await e.doc.reopen(t),K("Reopened")}catch(e){K(e instanceof Y?`Reopened \xb7 ${go}`:vo(e))}},notRight:async t=>{try{await e.doc.reopen(t)}catch(e){K(e instanceof Y?`Reopened \xb7 ${go}`:vo(e))}ze(t)},drop:(e,t)=>V("Reply discarded",()=>{D.set(e,t),Q(e)?te(e,!0):je(e)}),close:()=>{je(null);let e=Te&&s.e.querySelector(Te);e?e.focus({preventScroll:!0}):L?.ge(),Te=""},copy:t=>{try{let n=e.doc.threads().find(e=>e.id===t);if(!n)return;On(qe(X(n),"ai",location.href,Date.now()),s.e).then(()=>K("Thread copied as Markdown for AI"),e=>K(vo(e)))}catch(e){K(vo(e))}}},re={look:()=>n,setLook(e){n=e;try{"auto"===e?localStorage.removeItem(t):localStorage.setItem(t,e)}catch{}jt(l())},copyAll:async e=>{let t=re.all(),n=Re(t,e,{title:document.title,url:location.href,exportedAt:new Date});try{await On(n,s.e);let o=t.filter(e=>!e.thread.resolved).length;K(`Copied ${o} thread${1===o?"":"s"}${"ai"===e?" as Markdown for AI":""}`)}catch(e){K(vo(e))}},Je:()=>{y.R=!y.R,Ae()},toggleMine:()=>{y.mine=!y.mine,Ae()},setHide:e=>{y.hide=e;try{e?localStorage.setItem(v,"1"):localStorage.removeItem(v)}catch{}Ae()},rename:async t=>{let n=t.replace(/\s+/g," ").trim();try{await async function(t){try{return await e.onName(t),!1}catch(n){if(e.doc.name!==t)throw n;return!0}}(n)?K(`New comments will say ${n}, but this browser couldn't remember it`):K(`New comments will say ${n}`)}catch(e){K(vo(e))}},name:()=>e.doc.name,all:()=>[...J()].sort(on(ae)).map(X)},ie={},ae={get addons(){return ie.surface},doc:e.doc,root:e.root,e:s.e,host:s.element,state:y,resolved:p,$:h,B:oe,l:re,f:z,j:e=>R.has(e.id),Me:()=>{de()&&Ae()},U:e=>!y.hidden&&(!e.resolved||y.R||(e=>""!==(s.e.querySelector(`[data-thread="${e}"] .rbox textarea`)?.value.trim()??""))(e.id))&&!R.has(e.id),Qe:(e,t)=>{for(let n of J()){let o=p.get(n.id);if(n.anchor.quote&&ae.U(n)&&o?.range&&Yt(e,t,Kt(o)))return n}return null},ue:(e,t)=>ae.E()&&!y.pinning?ae.Qe(e,t):null,M:e=>e.composedPath().includes(s.element),fe:e=>{f.add(e)},Ye:e=>f.has(e),open:je,et:e=>ze(e),keepReplies:ee,putReply:e=>te(e),S:function(e){y.S!==e&&(y.S=e,e&&e!==y.i&&Qe(e),Ae())},Ze:We,je:function(e){if(!y.t)return We(e);Object.assign(y.t,e),Ae()},E:()=>!E||E._e(),Se:e=>{let t=E?.le();e(),t?.()},focusDraft:Ie,te:()=>{let e=y.t?.anchor.view,t=z.w(e)?void 0:e?.slide;K(t?`Finish or cancel your comment on slide ${t} first`:"Finish or cancel this comment first"),Ie(()=>L?.toDraft())},Ue:async function(t,n){let o=y.t;if(o)try{o.sending=!0;let r=await e.doc.comment(o.anchor,t,n);_("Comment added"),Oe(n,t),y.t=null,se(new Set([r])),je(r,!0)}catch(e){if(e instanceof Y)return y.t=null,se(new Set([e.id])),je(e.id,!0),void K(go);o.sending=!1,Z(e)}},seen:Fe,people:()=>wt(e.doc.threads(),e.doc.me),ce:Ke,Te:Ue,z:Je,H:e=>{E=e},registerList:e=>{S=e},ae:K,L:_,Ge:U,taps:()=>Ce(),ee:G,tt:Qe,m:Ae,W:Ge},le=ie.surface=new At(ae,s.shadow,k);function se(t){let n=performance.now(),o=e.doc.threads();for(let r of o){if(t&&!t.has(r.id))continue;let o=performance.now()-n<40,i=we(r.anchor,e.root,{fuzzy:o});p.set(r.id,i),o||"orphaned"!==i.state?h.delete(r.id):h.add(r.id)}for(let e of[...p.keys()])o.some(t=>t.id===e)||p.delete(e);0===h.size?(window.clearTimeout(P),P=0):0===P&&(P=window.setTimeout(()=>{P=0,!M&&(se(new Set(h)),Ae())},250))}function de(){let t=new Set,n=null!==z.slide(),o=new Set;for(let r of e.doc.threads()){o.add(r.id);let e=p.get(r.id),i=e?.element,a="attached"===e?.state||"moved"===e?.state;(n?!z.w(r.anchor.view):!1===i?.checkVisibility?.({visibilityProperty:!0})||!z.w(r.anchor.view)&&(!a||i?.closest("[role=tabpanel]")))&&t.add(r.id)}R=t;for(let e of D.keys())o.has(e)||D.delete(e);let r=`${z.slide()}|${[...t].join()}`;return r!==N&&(N=r,!0)}function ce(e){let t=[],n=[],o=[];for(let r of e){let e=p.get(r.id);r.resolved&&!y.R||!e?.range||R.has(r.id)||(r.id===y.i||r.id===y.S?n.push(e.range):r.resolved?o.push(e.range):t.push(e.range))}y.t&&z.w(y.t.anchor.view)&&n.push(...y.t.ranges),function(e,t){if(lo())for(let n of io){let o=e[n.slice(7)];CSS.highlights.set(n,new Highlight(...o.filter(e=>!t(e)))),CSS.highlights.set(`${n}-d`,new Highlight(...o.filter(t)))}}({quote:t,on:n,done:o},e=>{let t=ue.get(e);return void 0===t&&ue.set(e,t=function(e){let t=e.startContainer,n=t instanceof Element?t:t.parentElement,o=n?.ownerDocument.defaultView;if(!n||!o)return!1;let r=n.ownerDocument,i=eo(Qn(o.getComputedStyle(n).color,r)??{r:0,g:0,b:0});for(let e=n;e;e=e.parentElement){let t=o.getComputedStyle(e);if("none"!==t.backgroundImage)return i>.4;let n=Qn(t.backgroundColor,r);if(n&&n.a>=.5)return i>eo(n)}return i>eo(no(r))}(e)),t})}let ue=new WeakMap,pe=0,fe=0,me=0,ge=0,ve=0,ye=0,be=!1,xe=()=>{},Ee=!1,Me=!1;function Ce(){let e=!M&&(y.s||y.l||!!y.i||!!y.t||y.u||Me),t=document.body;e===Ee||!t||(Ee=e,e?t.addEventListener("click",xe):t.removeEventListener("click",xe))}function Ae(){if(M)return;let t=J();if(de(),y.i&&R.has(y.i)){let e=s.e.querySelector(`[data-thread="${y.i}"] .rbox textarea`)?.value;e&&D.set(y.i,e),y.i=null}y.hidden=y.hide&&!y.s&&!y.u&&!y.$e&&!y.t,d.Ce(y.s&&!y.paused),y.hidden&&(y.i=null),y.hidden||function(t){let n=function(e,t){let n=xt(t),o=[];for(let r of e)for(let e of[r.root,...r.root.replies])e.author!==t&&!e.deleted&&yt(e,n)&&!e.seenBy?.includes(t)&&o.push({thread:r,comment:e});return o}(t,e.doc.me).filter(e=>!Be.has(e.comment.id));if(!n.length)return;for(let e of n)Be.add(e.comment.id);let o=[...new Set(n.map(e=>g(e.comment)))];K(`${1===o.length?o[0]:`${o.length} people`} mentioned you in ${n.length} comment${1===n.length?"":"s"}`)}(t),function(e){if(e===fe)return;fe=e,cancelAnimationFrame(me);let t=pe,n=performance.now(),o=e?260:200,r=i=>{let a=Math.min(1,(i-n)/o);pe=t+(e-t)*(e?1-(1-a)**3:a*a),d.ve(pe),a<1&&(me=requestAnimationFrame(r))};me=requestAnimationFrame(r)}(y.hidden?0:1),s.e.classList.toggle("hidden",y.hidden),s.e.classList.toggle("listing",y.u),y.t&&B()&&!I&&(I=!0,b.classList.contains("tap")&&W()),y.s&&Zt()&&(y.u?U():b.classList.contains("show")||(O??=j));let n=y.u&&!Gt();(function(e){e!==ge&&(ge=e,d.Pe(e,c),null!==z.slide()&&(ye=performance.now()+450),window.clearTimeout(ve),ve=window.setTimeout(()=>{se(),Ae()},c?0:400))})(n?320:0),d.Ae(u?"column"!==y.mode||y.hidden||n?0:320:null);let o=0;if(null!==z.slide())for(let t of e.root.querySelectorAll(wn)){if(t===s.element)continue;let e=t.getBoundingClientRect();e.top>innerHeight/2&&e.right>innerWidth-ge-380&&e.bottom>innerHeight-48&&(o=Math.max(o,innerHeight-e.top+4))}s.e.style.setProperty("--pu-lift",`${o}px`),ce(t),Me=!y.hidden&&t.some(e=>!!e.anchor.quote&&!e.resolved&&!R.has(e.id)),Ce();for(let e of $)e.m(t);L?.m(t),y.hidden||le.flush()}let Te="",Pe=()=>s.e.getRootNode().activeElement,Ne="input,textarea,select,[contenteditable]:not([contenteditable=false])",De=()=>{let e=Pe();return e instanceof HTMLTextAreaElement&&""!==e.value||!!document.activeElement?.matches(Ne)};function ze(e,t=De(),n=Pe()){let o=[...s.e.querySelectorAll(`[data-thread="${e}"] .rbox textarea`)].find(e=>!e.closest("[inert]")),r=n?.getAttribute("data-thread");Te=r?`.${n.classList[0]}[data-thread="${r}"]`:"",!t&&o&&o.focus({preventScroll:!0})}let He=()=>!!y.t&&!ae.E();function Oe(t,n){let o=e.doc.contacts(),r=new Map;for(let e of t??[]){let t=o.get(e.ref);t?.includes("@")&&r.set(t,n.slice(e.start+1,e.end))}if(!r.size)return;let i=e.doc.name||m(e.doc.me),a=`${i} mentioned you on ${document.title}`,l=`${i} mentioned you in a comment on "${document.title}":\n\n${n}\n\n${location.href}`,s=[...r.values()];K(`Let ${1===s.length?s[0]:`${s.length} people`} know?`,9e3,!1,!1,{label:"Open my email",href:`mailto:${[...r.keys()].join(",")}?subject=${encodeURIComponent(a)}&body=${encodeURIComponent(l)}`})}function Fe(t){let n=[t.root,...t.root.replies].filter(t=>t.author!==e.doc.me&&!t.deleted&&yt(t,xt(e.doc.me))).map(e=>e.id);n.length&&e.doc.seen(n).catch(()=>{})}let Be=new Set;function Ie(e){let t=y.t?.anchor.view,n=E?.le();Promise.resolve(z.w(t)||z.Z(t??{}).then(()=>ae.Me())).then(()=>{z.w(t)&&e?.(),n?.()})}function je(t,n=!1){if(t&&y.t&&!ae.E())return ae.te();if(t&&y.u&&S)return S(t);if(y.i===t&&!y.t)return t?ze(t):void 0;let o=!n&&De(),r=Pe();if(t||(y.$e=!1),ee(),y.i=t,t){y.t=null,Qe(t);let n=e.doc.threads().find(e=>e.id===t);n&&Fe(n)}Ae(),t&&(te(t),n&&L?.he()?L.ge():ze(t,o||Zt(),r))}function We(e){U(),y.t=e,y.i=null,Ae()}function Ke(e=""){let t=y.t;t&&(y.t=null,Ae(),e&&V("Comment discarded",()=>{y.t&&!ae.E()||(We(t),L?.adopt(t),E?.fill(e))}))}function Ue(e,t=!1){y.s!==e&&(y.s=e,y.paused=!1,O=null,e?(y.i=null,L=function(e){let t={p:e=>e.getBoundingClientRect(),ze:e=>{let t=getComputedStyle(e),n="transparent"!==t.backgroundColor&&!/,\s*0\)$/.test(t.backgroundColor),o=["top","right","bottom","left"].some(e=>parseFloat(t.getPropertyValue(`border-${e}-width`))>0);return n||o||"none"!==t.backgroundImage||"none"!==t.boxShadow},We:e=>/^(inline-)?(flex|grid)$/.test(getComputedStyle(e).display),flow:e=>{let t=getComputedStyle(e),n=[t.overflowX,t.overflowY];return{display:t.display,position:t.position,clips:n.some(e=>"hidden"===e||"clip"===e)&&!n.some(e=>"auto"===e||"scroll"===e)&&e!==document.documentElement&&e!==document.body,off:"none"===t.pointerEvents}},Q:()=>({width:innerWidth,height:innerHeight})},n=Ye("span",{hidden:!0},Dn),o=Ye("div",{class:"pick"},n),r=Ye("div",{class:"pkw"}),i=[0,1].map(()=>{let e=Ye("div",{class:"km",tabindex:"-1",role:"button"},Ye("span",{hidden:!0}),Ye("span",{hidden:!0}));return e.inert=!0,e.addEventListener("keydown",Me),e.addEventListener("click",e=>{e.stopPropagation(),Le()}),e.addEventListener("focus",()=>o.classList.add("kf")),e.addEventListener("blur",()=>o.classList.remove("kf")),e}),a=Ye("span",{class:"lbl"}),l=(e,t,n,o)=>{let r=Ye("button",{class:"nb",type:"button","aria-label":e,title:t},it(n,16));return r.addEventListener("click",e=>{e.stopPropagation(),o(e)}),r},s=l("Around it","Select the block around it","expand",xe),d=l("Inside it","Select a block inside it","shrink",Ee),c=l("Pin","Pin its centre","pin",t=>t.detail&&Zt()?j(!D):e.Se(()=>U(m??k,{x:.5,y:.5}))),u=Ye("div",{class:"namebar",role:"group","aria-label":"Chosen block"},a,s,d,c);u.inert=!0;let p=e.e.querySelector(".launch");for(let t of[r,o,...i,u])e.e.insertBefore(t,p);u.addEventListener("mousedown",e=>e.preventDefault());let h=!0===window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,f=null,m=null,g=null,v=null,w=0,y=()=>{},b=null,x=()=>{},k=null,E=0,S=0,$=!1,L=null,M=null,C=null,A=0,T=-1,P=!0,q=null,R=null,N=!1,D=!1,z=t=>!(e.M(t)||t.target instanceof Element&&t.target.closest(wn));function H(){v&&(o.classList.toggle("glide",performance.now()<w),Xe(o,v.getBoundingClientRect(),4))}function O(){if(!b)return;u.classList.toggle("glide",performance.now()<w&&u.classList.contains("show"));let t={width:u.offsetWidth||200,height:u.offsetHeight||34},n=tn(b.getBoundingClientRect(),t,{width:innerWidth,height:innerHeight}),o=e.e.querySelector(".pop.show")?.getBoundingClientRect(),r=t.height;o&&n.top<o.bottom&&n.top+r>o.top&&n.left<o.right&&n.left+t.width>o.left&&(n.top=o.top-r-8>=8?o.top-r-8:o.bottom+8),u.style.left=`${n.left}px`,u.style.top=`${n.top}px`}function F(e,t){v=e,w=t?performance.now()+400:0,H(),o.classList.add("show")}function B(e,t){let n=getComputedStyle(e);if("0"===n.opacity)return t(),()=>{};let o=0,r=()=>{window.clearTimeout(o),e.removeEventListener("transitionend",a)},i=()=>{r(),t()},a=t=>{t.target===e&&"opacity"===t.propertyName&&i()},l=Math.max(...n.transitionDuration.split(",").map(e=>1e3*parseFloat(e)||0));return o=window.setTimeout(i,l+100),e.addEventListener("transitionend",a),r}function I(e){if(e!==f){if(f=e,y(),!e)return void o.classList.remove("show");"0"===getComputedStyle(o).opacity?F(e,!1):h?(o.classList.remove("show"),y=B(o,()=>F(e,!1))):F(e,!0)}}function j(t){D=e.state.pinning=t,c.classList.toggle("on",t),t?e.L(a.textContent="Tap where to pin"):b&&(a.textContent=$e(b))}function W(e){D&&j(!1),m=e,o.classList.toggle("on",null!==e),I(e),K(e)}function K(e){x(),u.inert=!e,e?h?(u.classList.remove("show"),x=B(u,()=>V(e))):V(e):(u.classList.remove("show"),b=null)}function V(n){a.textContent=a.title=$e(n),s.hidden=null===$n(n,e.root,t),d.hidden=0===(k?we(n).length:Cn(n,t,de).length);let o=u.classList.contains("show");b=n,O(),o||(u.offsetWidth,u.classList.add("show"))}function U(t,n){let o;try{o=he(t,e.root,n,e.f.view(t))}catch(t){return void e.ee(t)}let r={anchor:o,label:n?`Pin on ${$e(t).replace(/^[A-Z](?=[a-z])/,e=>e.toLowerCase())}`:$e(t),ranges:[],resolved:{state:"attached",element:t,range:null}},i=e.state.t;k&&(k=t,T=-1),W(n?null:t),g=i??r,e.je(r),i&&e.focusDraft(),e.L(n?r.label:`Commenting on ${r.label}`)}function Y(t){e.Se(()=>U(t))}function _(n){let o=(n.target instanceof Element?Sn(n.target,e.root,t):null)??e.root;o!==e.root&&(L=o);let r=o.getBoundingClientRect();r.width&&r.height&&U(o,{x:(n.clientX-r.left)/r.width,y:(n.clientY-r.top)/r.height})}function G(t){e.state.paused!==t&&(e.state.paused=t,t&&!m?I(null):!t&&k&&!m&&I(k),e.m())}let Z=!1,J=null,X=()=>J??e.state.paused,Q=()=>{Z=!1,J=e.state.paused},ee=()=>setTimeout(()=>J=null),te=n=>{if(e.M(n)||e.state.paused)return;if(!z(n))return void(m||I(null));if(n.stopPropagation(),m||e.state.t)return;let o=!Ze()&&n.target instanceof Element?Sn(n.target,e.root,t):null;if(k){if(!o||o===k||(A+=Math.abs(n.movementX)+Math.abs(n.movementY),A<=4))return;ve()}o&&(L=o),I(o)},ne=()=>{Ze()&&(k&&ve(),m||I(null))},oe=e=>{!z(e)||X()||(e.stopPropagation(),("pointerdown"===e.type||"mousedown"===e.type)&&e.target instanceof Element&&e.target.closest(Pn)&&e.preventDefault())},re=n=>{if(!z(n))return;if(X())return e.fe(n);let o=n.target;!(o===R||o.form&&o.form===R?.form)||"submit"!==n.type&&("click"!==n.type||n.detail)?(n.preventDefault(),n.stopPropagation(),"click"===n.type&&!e.state.l&&!e.Ye(n)&&function(n){if(D)return _(n);let o=window.getSelection();if(o&&!o.isCollapsed)return void(n.detail>1&&g&&e.state.t===g&&e.E()&&e.ce());let r=n.target instanceof Element?Sn(n.target,e.root,t):null;if(e.state.t&&!e.E())return r||n.altKey?e.te():e.z();if(e.state.t&&n.altKey)return e.z();if(n.altKey||!e.ue(n.clientX,n.clientY)){if(e.state.i&&e.open(null),k&&n.detail&&ve(),n.altKey)return void _(n);r&&(L=r),r?U(r):(e.z(),W(null))}}(n)):R="click"===n.type&&"submit"===o.type?o.form:null},ie=t=>{if(t.key!==Ot&&(Z=!0),(e=>{if(e.key!==Ot||e.ctrlKey||e.metaKey||e.altKey||e.isComposing)return!1;let t=e.composedPath()[0];if(i.some(e=>e===t))return!0;let n=t instanceof Element?t.closest(Pn):null;return!n||!Z&&!n.matches("input,textarea,select,[contenteditable]:not([contenteditable=false])")})(t)||t.key===Ot&&e.state.paused)return t.repeat||G(!0),t.preventDefault(),void t.stopPropagation();if(R=null,Te="","Escape"===t.key&&z(t)&&!t.isComposing&&!t.defaultPrevented&&!e.state.l&&!e.state.u)return t.preventDefault(),t.stopPropagation(),Te=t.key,e.W();if("Tab"===t.key&&function(t){if(t.ctrlKey||t.metaKey||t.altKey||t.isComposing||!e.M(t))return!1;let n=t.composedPath()[0],o=n instanceof Element?n.closest(".draft,.thread"):null,r=!!o?.classList.contains("draft");if(!o||!r&&o.closest(".all")||o.querySelector(".mnl.show")||o.querySelector(".nf :focus"))return!1;let i=t.shiftKey?-1:1;if(N=!0,r&&e.E())e.ce();else{let t=[...o.querySelectorAll("button,textarea,input,a[href]")].filter(e=>e.tabIndex>=0&&!e.closest("[inert],[hidden]")&&e.getClientRects().length>0),a=t.indexOf(n);if(a>=0&&(i>0?a<t.length-1:a>0))return N=!1,!1;r||e.open(null)}return N=!1,be(i),!0}(t))return t.preventDefault(),t.stopPropagation(),void(Te=t.key);if("Tab"===t.key&&ae(t))return t.preventDefault(),t.stopPropagation(),Te=t.key,e.z(),e.state.i&&e.open(null),e.state.l&&(e.state.l=!1,e.m()),be(t.shiftKey?-1:1);if(z(t)&&t.target instanceof Element)if("Enter"!==t.key&&" "!==t.key||!t.target.closest(Tn))"Enter"===t.key&&t.target.form&&(R=t.target);else{if(!k)return void(R=t.target);t.preventDefault(),t.stopPropagation()}},ae=t=>{if(t.ctrlKey||t.metaKey||t.altKey||t.isComposing)return!1;let n=t.composedPath()[0];return n instanceof Element&&!i.some(e=>e===n)&&(e.M(t)?!!n.closest(".launch,.menu")&&!n.closest("input,textarea,select,[contenteditable]"):!t.composedPath().some(e=>e instanceof Element&&e.matches(wn)))},le=()=>e.e.getRootNode().activeElement,se=()=>i.some(e=>e===le()),de=t=>{let n=e.e.getRootNode().host?.parentElement;return(!1!==t.checkVisibility?.({opacityProperty:!0,visibilityProperty:!0})||"contents"===getComputedStyle(t).display)&&!t.closest("[inert]")&&(!n||n===document.documentElement||n.contains(t))&&e.f.w(e.f.view(t))},ce=()=>(q?.some(e=>!e.o.isConnected)&&(q=null),q??=Cn(e.root,t,de)),ue=e=>ce().find(t=>t.o===e),pe=(e,t=!1)=>{let n=e.getBoundingClientRect();return n.bottom>0&&n.top<window.innerHeight&&(!t||n.top>=0)},fe=()=>{let e=An(ce(),0);return e.find(e=>pe(e.o,!0))??e.find(e=>pe(e.o))??e[0]},me=t=>e.doc.threads().filter(n=>e.U(n)&&t.contains(nn(e,n))).sort(on(e));function ge(t,o=!0){A=0;let r=ce(),a=r.find(e=>e.o===t);if(a&&!An(r,E).includes(a)&&(E=a.C),t!==k&&(T=-1),t!==m&&(m=null),k=t,I(t),K(t),t.scrollIntoView({block:"nearest",inline:"nearest",behavior:h?"auto":"smooth"}),!o)return;e.Ge();let l=i[S^=1];(function(e,t){let[o,r]=e.children,i=An(ce(),E),a=me(t).length;o.textContent=`${ke(t)}, ${i.findIndex(e=>e.o===t)+1} of ${i.length}${a?`, has ${a} comment${1===a?"":"s"}`:""}`;let l=(t.innerText??t.textContent??"").length<=150;r.textContent=Se(t);let s=P?[n]:[];P=!1,void 0!==e.ariaLabelledByElements?(e.ariaLabelledByElements=l?[o,t]:[o,r],e.ariaDescribedByElements=l?s:[...s,t]):e.setAttribute("aria-label",`${o.textContent}, ${r.textContent}`)})(l,t),Xe(l,t.getBoundingClientRect(),4),l.inert=!1,l.focus({preventScroll:!0}),i[1^S].inert=!0}function ve(){let e=se();L=k,k=null,I(null),K(null);for(let e of i)_e(e,!0);return e}function we(e){let t=ue(e);return t?((e,t)=>e.filter(e=>e.q===t))(ce(),t):[]}function ye(e){let t=An(ce(),E),n=t.findIndex(e=>e.o===k),o=t[n<0?e>0?0:t.length-1:(n+e+t.length)%t.length];o&&ge(o.o)}function be(t){if(k)return ye(t);q=null;let n=document.activeElement;M=le()??n;let o,r=L?.isConnected?L:null,i=r&&ue(r);if(i){E=i.C;let e=An(ce(),E),n=e.indexOf(i);o=e[(n+t+e.length)%e.length]}else if(r){E=0;let e=An(ce(),0),n=e=>0!==(r.compareDocumentPosition(e.o)&Node.DOCUMENT_POSITION_FOLLOWING),i=e=>e.o.contains(r);o=t>0?e.find(e=>n(e)&&!i(e))??e[0]:e.filter(e=>!n(e)&&!i(e)).pop()??e[e.length-1]}else o=fe(),o&&(E=o.C);if(!o)return e.L("Nothing here to comment on");$=!0,ge(o.o)}function xe(){let n=m??k,o=n&&$n(n,e.root,t);return o?((!C||!n.contains(C))&&(C=n),m?Y(o):void ge(o)):e.L("Nothing around it")}function Ee(){let t=m??k,n=t?we(t):[],o=n.find(e=>C&&e.o.contains(C))??n.find(e=>pe(e.o))??n[0];if(!o)return e.L("Nothing inside it");m?Y(o.o):ge(o.o)}function Le(t=!1){if(!k)return;if(e.state.t&&!e.E())return e.te();if(!t)return U(k);let n=me(k);if(!n.length)return e.L("No comments on this block");T=(T+1)%n.length,e.open(n[T].id),n.length>1&&e.L(`Comment ${T+1} of ${n.length} on this block`)}function Me(t){if(["Tab","ArrowUp","ArrowDown","Enter","Escape"].includes(t.key)&&(!t.key.startsWith("Arrow")||!(t.metaKey||t.ctrlKey||t.altKey))){if(t.preventDefault(),t.stopPropagation(),Te=t.key,"Escape"===t.key)return void e.W();if("Enter"===t.key)return Le(t.shiftKey);"Tab"===t.key&&e.z(),e.state.i&&e.open(null),"Tab"===t.key?ye(t.shiftKey?-1:1):"ArrowUp"===t.key?xe():Ee()}}function Ce(){let t=e.state.t,n=!!k&&!!t&&!e.E(),o=n&&t===g&&t.resolved.element!==k?t.resolved.element:null;r.classList.toggle("show",!!o&&de(o)),o&&Xe(r,o.getBoundingClientRect(),4),e.e.querySelector(".draft")?.classList.toggle("wait",n&&t?.resolved.element!==k)}let Ae=()=>{let e=le();return e?!!e.closest("[inert]"):!document.activeElement||document.activeElement===document.body},Te="",Pe=!1,qe=t=>{if(Pe&&window.removeEventListener("keyup",qe,!0),t.key===Ot&&e.state.paused)return G(!1),t.preventDefault(),void t.stopPropagation();t.key===Te&&(Te="",t.preventDefault(),t.stopPropagation())},Re=()=>G(!1);window.addEventListener("keyup",qe,!0),window.addEventListener("blur",Re),window.addEventListener("pointermove",te,!0),window.addEventListener("pointerdown",Q,!0);for(let e of Nn)window.addEventListener(e,ee,!0);document.addEventListener("selectionchange",ne);for(let e of Rn)window.addEventListener(e,oe,!0);for(let e of qn)window.addEventListener(e,re,!0);return window.addEventListener("keydown",ie,!0),{W:()=>!!m&&(W(null),!0),he:()=>null!==k,Xe:()=>$&&!k,Le:function(){q=null;let t=document.activeElement;M=le()??t;let n=ue(L),o=n??(t&&t!==document.body&&e.root.contains(t)&&!t.closest(wn)?ce().filter(e=>e.o.contains(t)).pop():void 0)??fe();return!!o&&(n||(E=o.C),$=!0,ge(o.o),!0)},ge(){k&&!se()&&ge(k)},m(){if(q=null,k&&(!k.isConnected||!de(k))){let e=fe();e?ge(e.o,se()||Ae()):ve()}let t=e.e.querySelector(".launch");if(t&&u.nextElementSibling!==t&&!se()&&!u.contains(le()))for(let n of[r,o,...i,u])e.e.insertBefore(n,t);let n=e.state.t;g&&n!==g?(g=null,W(null),k&&ge(k,Ae()&&!N)):(n||e.state.i)&&!g&&(f||m)&&W(null);let a=g?.anchor.point?null:g?.resolved.element;m&&!de(m)?W(null):!m&&!k&&a&&n===g&&de(a)&&W(a),Ce()},toDraft(){let t=g,n=t?.resolved.element;!t||!n||e.state.t!==t||(k&&(k=n,T=-1),L=n,W(t.anchor.point?null:n),n.scrollIntoView({block:"nearest",inline:"nearest",behavior:h?"auto":"smooth"}))},adopt(e){g=e;let t=e.resolved.element;k&&t&&(k=t),W(e.anchor.point?null:t)},O(){Ce(),H(),O(),k&&Xe(i[S],k.getBoundingClientRect(),4)},destroy(){ve()&&function(){let t=M;t&&t!==document.body&&t.isConnected&&t.focus?.({preventScroll:!0}),(!t||t===document.body||!t.matches?.(":focus"))&&e.e.querySelector(".launch .mode")?.focus({preventScroll:!0})}();for(let e of i)e.remove();r.remove(),e.e.querySelector(".draft")?.classList.remove("wait"),y(),x(),e.state.pinning=!1,Pe=!0,Te||window.removeEventListener("keyup",qe,!0),window.removeEventListener("blur",Re),window.removeEventListener("pointermove",te,!0),window.removeEventListener("pointerdown",Q,!0);for(let e of Nn)window.removeEventListener(e,ee,!0);document.removeEventListener("selectionchange",ne);for(let e of Rn)window.removeEventListener(e,oe,!0);for(let e of qn)window.removeEventListener(e,re,!0);window.removeEventListener("keydown",ie,!0),o.classList.remove("show"),u.classList.remove("show"),_e(u,!0),B(o,()=>o.remove()),B(u,()=>u.remove())}}}(ae)):(U(),L?.destroy(),L=null,_("Comment mode off")),Ae(),L&&(t&&L.Le(),t?L.he()?O=()=>K(Dn,1e4,!0,!0):K("Nothing here to comment on"):O=Zt()?j:()=>K(`Click anything to comment, or Tab between blocks \xb7 Option-click (Alt-click) to pin \xb7 Hold Space to use the page \xb7 ${Ht} or Esc to finish`,4e3,!0)))}function Ge(){let t=window.getSelection();y.s&&t&&!t.isCollapsed&&e.root.contains(t.anchorNode)?t.removeAllRanges():y.t&&ae.E()?Ke():y.i?je(null):L&&!L.W()&&Ue(!1)}function Je(){y.t?He()||Ke():y.i&&je(null)}function Qe(e){let t=p.get(e);if(!t||"orphaned"===t.state)return;let n=!1===t.element?.checkVisibility?.(),o=n?t.element.closest("details:not([open])")?.querySelector("summary"):t.element;tt(()=>t.range&&!n?Kt(t):o?[o.getBoundingClientRect()]:[])}let et=new Set;function tt(e){let t=e().slice(0,6).map(()=>s.e.insertBefore(Ye("div",{class:"pulse"}),s.e.firstChild)),n={els:t,at:e};et.add(n),nt(n),window.setTimeout(()=>{et.delete(n);for(let e of t)e.remove()},1300)}function nt(e){let t=e.at();e.els.forEach((e,n)=>t[n]&&Xe(e,t[n],4))}function ot(){ee();let e=!!Pe()?.closest(".rbox");for(let e of $)e.destroy();$=function(e){return[..."column"===e.state.mode?[hn(e),mn(e,{pe:!1})]:[mn(e,{pe:!0})],Hn(e),In(e)]}(ae),Ae(),y.i&&te(y.i,e)}Ve.go=t=>{if(t.startsWith("slide:"))return void z.Z({slide:t.slice(6)});let n=decodeURIComponent(t.slice(6)).replace(/\s+/g," ").toLowerCase(),o=[...e.root.querySelectorAll("p,li,h1,h2,h3,h4,h5,h6,td,th,blockquote,figcaption,dt,dd")].find(e=>(e.textContent??"").replace(/\s+/g," ").toLowerCase().includes(n));o&&(o.scrollIntoView({block:"center",behavior:c?"auto":"smooth"}),window.setTimeout(()=>tt(()=>[o.getBoundingClientRect()]),c?0:450))};let rt={x:0,y:0};let at=()=>{if(!M){if(function(){let e=s.e.getBoundingClientRect();!Math.round(e.left)&&!Math.round(e.top)||(rt={x:rt.x-Math.round(e.left),y:rt.y-Math.round(e.top)},s.e.style.transform=rt.x||rt.y?`translate(${rt.x}px,${rt.y}px)`:"",(e=>{Jt=e})(rt.y))}(),O&&!y.l&&(!b.classList.contains("show")||H)){let e=O;O=null,e()}ye&&(performance.now()>ye&&(ye=0),be=!0,dispatchEvent(new Event("resize")),be=!1);for(let e of $)e.O();for(let e of et)nt(e);L?.O(),le.O(),q=requestAnimationFrame(at)}},lt=e=>{let t=e.composedPath()[0];return t instanceof Element&&null!==t.closest(Ne)},st=e=>{if("Escape"===e.key)return e.isComposing?void 0:Ge();if(x&&"KeyZ"===e.code&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey){let t=e.composedPath()[0];if(!lt(e)||t instanceof HTMLTextAreaElement&&t.getRootNode()===s.shadow&&""===t.value)return e.preventDefault(),x()}if(function(e){return"KeyC"===e.code&&e.shiftKey&&e.altKey&&!e.metaKey&&!e.ctrlKey&&!e.repeat&&!e.getModifierState("AltGraph")}(e)&&!e.isComposing&&!e.defaultPrevented&&!lt(e)){if(e.preventDefault(),L?.Xe()&&L.Le())return;Ue(!y.s,!0)}},dt=e=>{if(ae.M(e)||f.has(e))return;let t=window.getSelection();t&&!t.isCollapsed||Je()},ct=window.innerWidth,ut=0;function pt(){let e=y.i?p.get(y.i):y.t?.resolved,t=(e?.range??e?.element)?.getBoundingClientRect();t&&(t.top<0||t.bottom>window.innerHeight)&&window.scrollBy({top:t.top-16,behavior:c?"auto":"smooth"})}let ht=Xt().bottom,ft=!1,mt=0,gt=()=>{let e=window.visualViewport,t=Pe();s.e.classList.toggle("kb",!!e&&window.innerHeight-e.height>150&&(t instanceof HTMLTextAreaElement||t instanceof HTMLInputElement));let n=Xt().bottom;n<ht-80&&(ft=!0),ht=n,window.clearTimeout(mt),mt=window.setTimeout(()=>{if(!ft)return;ft=!1;let e=Xt(),t=y.i?p.get(y.i):y.t?.resolved,n=(t?.range??t?.element)?.getBoundingClientRect(),o=s.e.querySelector(".pop.show")?.offsetHeight??0;n&&(n.top<e.top||n.bottom+o+24>e.bottom)&&window.scrollBy({top:n.top-e.top-(Zt()?76:60),behavior:c?"auto":"smooth"})},250)},vt=()=>{if(be)return;window.innerWidth!==ct&&(ct=window.innerWidth,window.clearTimeout(ut),ut=window.setTimeout(pt,200)),s.e.style.setProperty("--pu-pop",`${_t()}px`);let t=mo(e.root,"column"===y.mode);t!==y.mode?(y.mode=t,ot()):Ae()};function bt(){let e=performance.now();0===A&&(T=e),window.clearTimeout(A);let t=Math.min(120,Math.max(0,T+1e3-e));A=window.setTimeout(()=>{A=0,se(),Ae()},t)}let kt=[],Et=/^(video|canvas|iframe|img|object|embed|audio)$/,St=new MutationObserver(()=>Mt()),$t=null,Lt=0;function Mt(){let e=function(){let e=new Set;try{for(let t of document.querySelectorAll("dialog:modal"))e.add(t);for(let t of kt)"dialog"===t.localName&&t.isConnected&&t.matches(":modal")&&e.add(t);let t=document.activeElement;for(;t?.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;for(;t;){let n=t.closest("dialog");n?.matches(":modal")&&e.add(n);let o=t.getRootNode();t=o instanceof ShadowRoot?o.host:null}}catch{}let t=document.fullscreenElement;for(;t?.shadowRoot?.fullscreenElement;)t=t.shadowRoot.fullscreenElement;return t&&t!==document.documentElement&&t!==document.body&&!Et.test(t.localName)&&e.add(t),[...e]}();kt=[...kt.filter(t=>e.includes(t)),...e.filter(e=>!kt.includes(e))];let t=kt.at(-1),n=t&&!(e=>{let t=getComputedStyle(e),n=(e,n="none")=>![n,""].includes(t.getPropertyValue(e));return["transform","translate","scale","rotate","perspective","filter","backdrop-filter"].some(e=>n(e))||n("container-type","normal")||/paint|layout|strict|content/.test(t.contain)||/transform|translate|scale|rotate|perspective|filter/.test(t.willChange)})(t)?t:document.documentElement;St.disconnect();for(let e of kt)e.getRootNode()!==document&&St.observe(e,{attributeFilter:["open"]});if(s.element.parentNode===n)return;let o=!s.element.isConnected;n.append(s.element),o&&$t?.isConnected&&performance.now()-Lt<100&&$t.focus({preventScroll:!0})}let Ct=new MutationObserver(e=>{e.some(e=>e.removedNodes.length)&&Mt(),!e.every(e=>s.element.contains(e.target)||(e=>"childList"===e.type&&e.addedNodes.length+e.removedNodes.length>0&&[...e.addedNodes,...e.removedNodes].every(e=>e===s.element))(e))&&bt()}),Tt=e=>{let t=e.key,n=t=>e.composedPath().some(e=>e instanceof Element&&e.matches(t));("Enter"===t||" "===t||fo.includes(t)&&n(".menu,.all,.pm")||t.startsWith("Arrow")&&n(".menu"))&&e.stopPropagation()};for(let e of["keydown","keyup","keypress"])s.e.addEventListener(e,Tt);let Pt=e=>e===s.element,qt=e=>{"focusin"===e.type&&Mt(),Pt(e.target)&&("focusin"===e.type&&($t=e.composedPath()[0]),Lt="focusin"===e.type?1/0:performance.now()),("focusin"===e.type?Pt(e.target)&&!Pt(e.relatedTarget):Pt(e.relatedTarget)&&!Pt(e.target))&&e.stopImmediatePropagation()},Rt=null,Nt=!1;s.shadow.addEventListener("keydown",e=>{e===Rt&&(Nt=!0)});let Dt=e=>{if(!(e=>{let t=e.composedPath();if(!t.includes(s.element))return!1;let n=t[0];if(n instanceof Element&&n.matches(Ne))return!0;let o=e.key,r=e=>t.some(t=>t instanceof Element&&t.matches(e));return["Escape","Tab","Enter"," "].includes(o)||fo.includes(o)&&r(".menu,.all,.pm,.rxp")||o.startsWith("Arrow")&&r(".menu,.rxp")})(e)||(e.stopImmediatePropagation(),"keydown"!==e.type))return;let t=Rt=new KeyboardEvent("keydown",{key:e.key,code:e.code,location:e.location,repeat:e.repeat,isComposing:e.isComposing,ctrlKey:e.ctrlKey,shiftKey:e.shiftKey,altKey:e.altKey,metaKey:e.metaKey,bubbles:!0,cancelable:!0});Nt=!1,e.composedPath()[0].dispatchEvent(t),Rt=null,t.defaultPrevented&&e.preventDefault(),Nt&&st(e)},zt=e=>e.stopPropagation(),Ft=["pointerdown","mousedown","touchstart","click","focusin","focusout"];for(let e of["focusin","focusout"])window.addEventListener(e,qt,!0);for(let e of Ft)s.element.addEventListener(e,zt);for(let e of["keydown","keyup","keypress"])document.addEventListener(e,Dt,!0);document.addEventListener("fullscreenchange",Mt);let Bt=()=>kt.length&&Mt();for(let e of["transitionend","animationend"])window.addEventListener(e,Bt,!0);window.addEventListener("keydown",st),window.addEventListener("click",dt),window.addEventListener("resize",vt);for(let e of["resize","scroll"])window.visualViewport?.addEventListener(e,gt);Ct.observe(e.root,{subtree:!0,childList:!0,characterData:!0});let It=0,jt=t=>{let n="dark"===t;s.e.classList.toggle("flip",n!==i),n!==r&&(r=n,window.clearTimeout(It),s.e.classList.add("fading"),It=window.setTimeout(()=>{ro(s.e,oo(e.root,t)),s.e.classList.remove("fading")},170))},Wt=()=>{jt(l()),ue=new WeakMap,ce(J())},Vt=0,Ut=()=>{Vt||(Vt=window.setTimeout(()=>{Wt(),Vt=window.setTimeout(()=>{Vt=0,Wt()},450)},150))},Qt=new MutationObserver(e=>{e.some(e=>"open"===e.attributeName&&"dialog"===e.target.localName)&&Mt(),!e.every(e=>e.target===s.element)&&Ut()});Qt.observe(document.documentElement,{attributes:!0,subtree:!0});let en=window.matchMedia?.("(prefers-color-scheme: dark)");en?.addEventListener?.("change",Ut);let rn=new ResizeObserver(bt);rn.observe(e.root);let an=e.doc.onChange((e,t,n)=>{le.De(t,n),se(),Ae()});return se(),ot(),Mt(),q=requestAnimationFrame(at),{ctx:ae,appearance:()=>o,destroy(){M=!0,cancelAnimationFrame(q),cancelAnimationFrame(me),cancelAnimationFrame(F),z.destroy(),window.clearTimeout(ve),window.clearTimeout(C),window.clearTimeout(ut),window.clearTimeout(A),window.clearTimeout(P),Ct.disconnect(),Ve.go=void 0,rn.disconnect(),Qt.disconnect(),en?.removeEventListener?.("change",Ut),window.clearTimeout(Vt),window.clearTimeout(It),an(),window.removeEventListener("keydown",st),window.removeEventListener("click",dt);for(let e of["focusin","focusout"])window.removeEventListener(e,qt,!0);for(let e of["keydown","keyup","keypress"])document.removeEventListener(e,Dt,!0);document.removeEventListener("fullscreenchange",Mt);for(let e of["transitionend","animationend"])window.removeEventListener(e,Bt,!0);St.disconnect(),window.removeEventListener("resize",vt);for(let e of["resize","scroll"])window.visualViewport?.removeEventListener(e,gt);window.clearTimeout(mt),document.body?.removeEventListener("click",xe),L?.destroy();for(let e of $)e.destroy();le.destroy(),d.remove(),s.destroy()}}}var yo=null;function bo(e={}){if(qt)return qt.mount(e);if(!Dt())return Promise.reject(new Error("pipeup: another copy of Pipeup owns the add-on queue. Remove one script."));if(yo)return yo;let t=async function(e,t){let n,o,r=document.documentElement.getAttribute("data-pipeup-doc"),{id:a,key:l}=r?await j(r):{id:`page-${i(location.origin+location.pathname)}`,key:null},s=!1;if(e.store)n=e.store,o=await Q(n);else try{let e=ee.open();n=await function(e){return new Promise((t,n)=>{let o=setTimeout(()=>n(new Error("timed out")),4e3);e.then(t,n).finally(()=>clearTimeout(o))})}(e).catch(t=>{throw e.then(e=>e.close(),()=>{}),t}),o=await Q(n)}catch{n=new X,s=!0,o=await Q(n)}let d=e.name?.trim();d&&d!==o.name&&(o={...o,name:d},await n.saveProfile(o)),navigator.storage?.persist?.().catch(()=>{});let c,u=await _.open({doc:a,key:l,store:n,identity:o.identity,name:o.name});Gn(e.slides??null);try{c=wo({doc:u,styles:':host{all:initial;direction:ltr;unicode-bidi:normal}*{box-sizing:border-box}button{appearance:none;font:inherit;color:inherit;background:none;border:0;padding:0;cursor:pointer}svg{display:block}.layer{all:initial;direction:ltr;unicode-bidi:normal;display:block;position:fixed;inset:0;pointer-events:none;font:13px/1.5 var(--pu-font,system-ui,sans-serif);color:var(--k);--k:#2C2C2A;--mu:#5F5E5A;--fa:#6B6A64;--ln:#E5E3DA;--ru:#ECEAE2;--so:#FAFAF7;--su:#FFFFFF;--ho:#F1EFE8;--as:color-mix(in srgb,var(--pu-accent,#534AB7) 12%,transparent);--sh:0 8px 28px rgba(44,44,42,.1);--in:.26s;--mv:.34s;--out:.2s;--pl:1.2s;--eo:cubic-bezier(.22,.61,.36,1);--eio:cubic-bezier(.4,0,.2,1);--ei:cubic-bezier(.4,0,1,1);--pu-text:var(--k);--pu-muted:var(--mu);--pu-faint:var(--fa);--pu-line:var(--ln);--pu-surface:var(--su);--pu-soft:var(--so);--pu-hover:var(--ho);--pu-shadow:var(--sh);--pu-ease:var(--eo)}.layer{transition:opacity .24s var(--eo)}.layer.fading{opacity:0;transition-duration:.16s;transition-timing-function:var(--ei)}.layer.dark{--k:#ECEBE6;--mu:#B4B2A9;--fa:#9A9892;--ln:#3A3936;--ru:#34332F;--so:#22221F;--su:#1B1B19;--ho:#2C2C29;--sh:0 8px 28px rgba(0,0,0,.45)}.layer.hidden .bub,.layer.hidden .col,.layer.hidden .pop,.layer.hidden .tip,.layer.hidden .mark,.layer.hidden .selbar{opacity:0!important;pointer-events:none!important}.layer.kb :is(.launch,.toast){opacity:0!important;pointer-events:none!important;transition:opacity var(--out) var(--ei)!important}.tx{font-size:14px;line-height:1.5;color:var(--k);white-space:pre-wrap;overflow-wrap:anywhere}.tx.del,.rest,.ctx,.ago{color:var(--fa)}.rest,.ago{font-size:12px}.rest{display:block;margin-top:3px}.hdr{position:relative;display:flex;align-items:center;gap:7px;min-height:22px}.who{min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-weight:600;color:var(--k)}.ago{flex:none;white-space:nowrap}.ago:before{content:"\\b7";margin-right:6px}.root>.tx,.it>.tx,.root>.ctx{margin-top:2px}.ctx[hidden]{display:none}.ctx{font-size:12px;margin-bottom:3px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.cd>.thread .tx,.clamp{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.th.long .root>.tx{max-height:var(--full);overflow:hidden;transition:max-height var(--mv) var(--eio)}.th.long:not(.on) .root>.tx{max-height:84px;mask-image:linear-gradient(#000 calc(100% - 21px),transparent)}.mr{display:grid;grid-template-rows:0fr;opacity:0;font-size:12px;color:var(--pu-accent);text-align:end;transition:grid-template-rows var(--mv) var(--eio),opacity var(--in) var(--eo)}.mr>span{min-height:0;overflow:hidden}.th.long:not(.on) .mr{grid-template-rows:1fr;opacity:1}.tx a{color:var(--pu-accent);text-decoration:underline;text-decoration-thickness:1px;text-underline-offset:2px}.acts{margin-left:auto;display:flex;flex:none;transition:opacity var(--in) var(--eo)}.th:not(.on):not(:hover):not(:focus-within) .acts,.cd:not(.open):not(:hover):not(:has(:focus-visible,.pm)) .acts,.still .th:not(.on):not(:has(:focus-visible)) .acts,.still .cd:not(.open):not(:has(:focus-visible,.pm)) .acts{opacity:0;pointer-events:none}.th:not(.on) .acts,.cd:not(.open) .acts{position:absolute;right:0;padding-left:16px;background:linear-gradient(90deg,transparent,var(--bg) 14px);transition:opacity var(--in) var(--eo),pointer-events 0s var(--in);transition-behavior:allow-discrete}.th.on .rest{display:none}.pm{position:absolute;right:0;top:100%;z-index:5;display:flex;flex-direction:column;min-width:150px;padding:4px;border:1px solid var(--ln);border-radius:10px;background:var(--su);box-shadow:var(--sh)}.pm.in{animation:pu-in var(--in) var(--eo) both}.pm button{padding:6px 10px;border-radius:7px;text-align:left;font-size:13px;transition:background-color .2s var(--eo),color .2s var(--eo)}.pm button:hover,.pm button:focus-visible{background:var(--ho)}.pm .dl{color:#c9402f}.dark .pm .dl{color:#f08a7e}.edit{margin-top:2px}.ib{width:24px;height:22px;display:grid;place-items:center;border-radius:6px;color:var(--mu);transition:background-color .2s var(--eo),color .2s var(--eo)}.ib:hover,.ib:focus-visible{background:var(--ho);color:var(--k)}.rps,.rbox{padding-left:14px}.rps .it{padding-top:8px}.more{display:grid;grid-template-rows:1fr;transition:grid-template-rows var(--mv) var(--eio)}.more>div{overflow:hidden;min-height:0}.th:not(.on) .more{grid-template-rows:0fr}.row{position:relative;padding-top:6px}.line{display:flex;align-items:center;gap:6px;padding:3px 12px;border:1px solid var(--ln);border-radius:16px;cursor:text;transition:border-color var(--in) var(--eo),box-shadow var(--in) var(--eo)}.line:hover{border-color:var(--mu)}.line:focus-within{border-color:var(--pu-accent);box-shadow:0 0 0 1px var(--pu-accent)}.input{flex:1;min-width:0;height:24px;display:block;border:0;outline:none;resize:none;overflow:hidden;font:inherit;font-size:14px;line-height:1.5;padding:1px 0;color:var(--k);background:transparent}.input::placeholder{color:var(--fa);opacity:1}.bts{display:flex;justify-content:flex-end;gap:4px;max-height:0;opacity:0;overflow:hidden;transition:max-height var(--in) var(--eo),opacity var(--in) var(--eo),padding var(--in) var(--eo)}.row:focus-within .bts,.row.has .bts{max-height:40px;opacity:1;padding-top:4px}.bts button{padding:2px 10px;border-radius:14px;font-size:13px;font-weight:600;color:var(--pu-accent);transition:background-color .2s var(--eo),color .2s var(--eo)}.cnl:hover,.cnl:focus-visible{background:var(--as)}.send{background:var(--pu-accent);color:var(--pu-on,#fff)!important}.send:not(.show){background:var(--ru);color:var(--fa)!important;cursor:default}.ed{display:flex;gap:10px;align-items:center;min-height:34px;padding:6px 10px}.ed .input,.nf .input{font-size:13px;height:22px;border-bottom:1px solid var(--ln)}.ed .input:focus,.nf .input:focus{border-bottom-color:var(--pu-accent)}.av{flex:none;display:grid;place-items:center;width:22px;height:22px;border-radius:32%;font-size:12px;font-weight:600;line-height:1;opacity:0;transform:scale(.85);transition:opacity var(--in) var(--eo),transform var(--in) var(--eo)}.av.in{opacity:1;transform:none}.av svg{width:122%;height:122%;stroke-width:1.3}.av{--av-l:92%;--av-d:30%;--s:60%;background:hsl(var(--h) var(--s) var(--av-l));color:hsl(var(--h) var(--s) var(--av-d))}.dark .av{--av-l:20%;--av-d:78%}.av.ai{position:relative;border-radius:50%;background:var(--su);color:var(--pu-accent);font-size:9px;letter-spacing:.02em}.av.ai:before{content:"";position:absolute;inset:3px;border-radius:50%;border:1.5px solid var(--pu-accent);pointer-events:none}.refs{display:flex;flex-wrap:wrap;gap:4px;margin-top:6px;white-space:normal}.refs .ref{display:inline-flex;align-items:center;gap:5px;max-width:160px;padding:1px 9px;border:1px solid var(--ln);border-radius:999px;background:var(--so);color:var(--mu);font:inherit;font-size:11.5px;line-height:1.6;text-decoration:none;cursor:pointer;transition:background-color .2s var(--eo),color .2s var(--eo),border-color .2s var(--eo)}.refs .ref:hover,.refs .ref:focus-visible{background:var(--as);color:var(--pu-accent);border-color:var(--pu-accent)}.ref span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.rxp{position:fixed;width:320px;height:340px;border-radius:12px;overflow:hidden;pointer-events:none;opacity:0;transform:translateY(4px);transition:opacity var(--in) var(--eo),transform var(--in) var(--eo)}.rxp.show{opacity:1;transform:none;pointer-events:auto}.mn{border-radius:4px;padding:0 2px;background:var(--as);color:var(--pu-accent)}.mn.me{font-weight:600}.mnl{position:absolute;left:0;bottom:100%;margin:0 0 4px;padding:4px;list-style:none;min-width:180px;max-width:100%;border:1px solid var(--ln);border-radius:10px;background:var(--su);box-shadow:var(--sh);opacity:0;transform:translateY(4px);pointer-events:none;z-index:4;transition:opacity var(--in) var(--eo),transform var(--in) var(--eo)}.mnl.show{opacity:1;transform:none;pointer-events:auto}.mnl li{display:flex;align-items:baseline;gap:8px;padding:5px 8px;border-radius:6px;font-size:13px;color:var(--k);cursor:pointer}.mnl li small{font-size:11px;color:var(--fa)}.mnl li.on,.mnl li:hover{background:var(--as);color:var(--pu-accent)}.dlg{position:fixed;left:50%;top:18vh;width:min(380px,calc(100vw - 32px));padding:16px 18px;border:1px solid var(--ln);border-radius:14px;background:var(--su);box-shadow:var(--sh);color:var(--k);opacity:0;transform:translate(-50%,6px);pointer-events:none;transition:opacity var(--in) var(--eo),transform var(--in) var(--eo)}.dlg.show{opacity:1;transform:translate(-50%);pointer-events:auto}.toast.act{display:flex;align-items:center}.toast.show .ta{pointer-events:auto}.toast .ta{transition:visibility 0s .3s}.toast:not(.show) .ta{visibility:hidden}.toast.show .ta{transition-delay:0s}.toast.tap{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;background:var(--pu-accent);border-color:var(--pu-accent);color:var(--pu-on,#fff);font-size:15px;font-weight:500;transition:opacity .3s var(--eo),transform .3s var(--eo),grid-template-columns var(--mv) var(--eio),padding var(--mv) var(--eio)}.toast.tap .tw{min-width:0;max-height:4em;overflow:hidden;text-wrap:balance;transition:opacity var(--out) var(--ei),max-height var(--mv) var(--eio)}.toast.tap .ta{color:inherit;font-weight:600}.toast.tap.taught{grid-template-columns:minmax(0,0fr) auto;padding-left:4px}.toast.tap.taught .tw{opacity:0;max-height:0}.ta{margin-left:4px;color:var(--pu-accent);text-decoration:underline;text-underline-offset:2px}.rx .n{font-size:11px;font-variant-numeric:tabular-nums}.rx.mine{background:var(--as);color:var(--pu-accent);border-color:var(--pu-accent)}.rx:disabled{cursor:default;opacity:.7}.rx{-webkit-touch-callout:none;-webkit-user-select:none}.rx.new,.rxq.new{animation:pu-in var(--mv) var(--eo) backwards}.rxs{align-items:center}.rxq{display:inline-flex;gap:2px}.rxo{padding:2px 5px;border-radius:8px;font-size:16px;line-height:1.3;transition:background-color .2s var(--eo)}.rxo:hover,.rxo:focus-visible,.rxo[aria-pressed=true]{background:var(--as)}.refs .ref{position:relative}.ref .rc{position:absolute;left:0;top:calc(100% + 6px);z-index:3;width:max-content;max-width:min(240px,70vw);padding:6px 9px;border:1px solid var(--ln);border-radius:8px;background:var(--su);box-shadow:var(--sh);color:var(--k);font-size:12px;line-height:1.45;white-space:normal;text-align:left;overflow:visible;opacity:0;visibility:hidden;transform:translateY(-3px);pointer-events:none;transition:opacity .2s var(--eo),transform .2s var(--eo),visibility 0s .2s}.ref:hover .rc,.ref:focus-visible .rc,.ref.held .rc{opacity:1;visibility:visible;transform:none;transition-delay:0s}.ref .sl{width:10px;height:7px;border:1.3px solid currentColor;border-radius:2px;flex:none}.seen{display:flex;align-items:center;gap:6px;padding:6px 0 0 14px;font-size:12px;color:var(--fa)}.seen button{margin-left:auto;padding:0 6px;border:0;border-radius:6px;background:none;color:var(--fa);font:inherit;cursor:pointer;transition:color .2s var(--eo),background-color .2s var(--eo)}.seen button:hover,.seen button:focus-visible{color:var(--pu-accent);background:var(--as)}.seen i{width:12px;height:12px;border-radius:50%;border:1.5px solid var(--pu-accent);flex:none}.c0{--h:0}.c1{--h:25}.c2{--h:50}.c3{--h:130}.c4{--h:175}.c5{--h:215}.c6{--h:270}.c7{--h:330}.c8{--h:28;--s:35%}.c9{--h:220;--s:8%}button.me{flex:none;display:grid;place-items:center}button.me>.av{grid-area:1/1}.you{flex:1;display:grid;min-width:0;min-height:22px;font-size:12px;color:var(--fa)}.you .nm{font-size:13px;font-weight:600;color:var(--k)}.you>*{grid-area:1/1;display:flex;align-items:center;min-width:0;transition:opacity var(--in) var(--eo),transform var(--in) var(--eo)}.say{white-space:pre;overflow:hidden}.nm{min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.say button{flex:none}.say button{color:var(--mu);text-decoration:underline;text-decoration-color:var(--ln);text-underline-offset:2px;transition:color .2s var(--eo)}.say button:hover,.say button:focus-visible{color:var(--pu-accent)}.nf{opacity:0;transform:translateY(-4px);pointer-events:none}.nf .input{font-size:13px;height:24px}.you.naming .nf{opacity:1;transform:none;pointer-events:auto}.you.naming .say{opacity:0;pointer-events:none}.bub{position:fixed;left:0;top:0;width:20px;height:20px;margin:-20px 0 0 -2px;border-radius:50% 50% 50% 0;background:var(--pu-accent);border:2px solid var(--su);box-shadow:0 1px 4px #0003;pointer-events:auto;opacity:0;transform:translateY(-6px) scale(.9);transform-origin:2px 20px;transition:opacity var(--out) var(--ei),transform var(--out) var(--ei)}.bub.in{opacity:1;transform:none;transition:opacity var(--in) var(--eo),transform var(--in) var(--eo)}.bub.in:hover,.bub.on{transform:scale(1.18)}.bub.done{background:var(--fa)}.bub.ghost{pointer-events:none}.tip,.pop,.menu,.all,.xp,.toast,.selbar,.namebar,.tt,.rxp{background:var(--su);border:1px solid var(--ln);box-shadow:var(--sh)}.tip{position:fixed;max-width:260px;border-radius:10px;padding:7px 10px;opacity:0;transform:translateY(3px);transition:opacity .22s var(--eo),transform .26s var(--eo)}.tip.show{opacity:1;transform:none;pointer-events:auto;cursor:pointer;transition:opacity .22s var(--eo),transform .26s var(--eo),left var(--mv) var(--eio),top var(--mv) var(--eio)}.pop{position:fixed;width:var(--pu-pop);border-radius:12px;padding:8px 10px 10px;pointer-events:none;opacity:0;transform:translateY(6px) scale(.98);transition:opacity var(--out) var(--ei),transform var(--out) var(--ei)}.pop.show{opacity:1;transform:none;pointer-events:auto;transition:opacity var(--in) var(--eo),transform var(--mv) var(--eo)}.pop.show.glide{transition:opacity var(--in) var(--eo),transform var(--mv) var(--eo),left var(--mv) var(--eio),top var(--mv) var(--eio)}.mark{position:fixed;border:2px solid color-mix(in srgb,var(--pu-accent) 50%,transparent);background:var(--as);border-radius:8px;opacity:0;transition:opacity .3s var(--eo)}.mark.show{opacity:1}.pulse{position:fixed;border:2px solid var(--pu-accent);border-radius:8px;background:var(--as);animation:pu-pulse var(--pl) var(--eio) forwards}@keyframes pu-pulse{0%{opacity:0;transform:scale(.985)}35%{opacity:.85;transform:scale(1)}to{opacity:0;transform:scale(1.02)}}.col{position:fixed;left:0;top:0;pointer-events:none;transition:opacity var(--in) var(--eo)}.th,.cd{--bg:var(--su);background:var(--bg);opacity:var(--o,1)}.th{position:absolute;left:0;right:0;top:0;padding:8px 10px 10px;border:1px solid var(--ln);border-radius:10px;pointer-events:auto;cursor:pointer;transition:transform var(--mv) var(--eio),box-shadow var(--in) var(--eo),border-color var(--in) var(--eo),opacity var(--in) var(--eo)}.th.hot{border-color:var(--mu)}.th.on{border-color:transparent;box-shadow:var(--sh);cursor:default}.th.dim{--o:.45}.th.resolved:not(.on):not(.hot){--o:.6}.th.lost .ctx{white-space:normal}.th.wait{opacity:0!important;pointer-events:none}.th:is(.out,.hop){opacity:0!important;pointer-events:none;transition:opacity var(--out) var(--ei)}.th:has(.opn:focus-visible){outline:2px solid var(--pu-accent);outline-offset:2px}.selbar{position:fixed;display:flex;border-radius:10px;padding:2px;opacity:0;transform:translateY(4px);pointer-events:none;transition:opacity var(--in) var(--eo),transform .3s var(--eo)}.selbar.show{opacity:1;transform:none;pointer-events:auto}.selbar button{width:32px;height:30px;display:grid;place-items:center;border-radius:8px;color:var(--pu-accent);transition:background-color .2s var(--eo)}.selbar button:hover,.selbar button:focus-visible{background:var(--as)}.pick{position:fixed;left:0;top:0;border:2px solid color-mix(in srgb,var(--pu-accent) 70%,transparent);background:color-mix(in srgb,var(--pu-accent) 6%,transparent);border-radius:8px;pointer-events:none;opacity:0;transition:opacity var(--out) var(--ei),border-color var(--out) var(--ei),border-width var(--out) var(--ei),box-shadow var(--out) var(--ei)}.pick.show{opacity:1;transition-duration:var(--in);transition-timing-function:var(--eo)}.pick.show.glide{transition-property:all;transition-duration:var(--mv);transition-timing-function:var(--eio)}.pick.on{border-color:var(--pu-accent)}.pkw{position:fixed;left:0;top:0;border:2px dashed color-mix(in srgb,var(--pu-accent) 70%,transparent);border-radius:8px;pointer-events:none;opacity:0;transition:opacity var(--out) var(--ei)}.pkw.show{opacity:.6;transition:opacity var(--in) var(--eo)}.draft{transition:opacity var(--in) var(--eo)}.draft.wait:not(:focus-within){opacity:.6}.pick.kf{border:3px solid var(--pu-accent);box-shadow:0 0 0 2px var(--su)}.km{position:fixed;left:0;top:0;pointer-events:none;outline:none}.sr,.mn-sr,.hh{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}.namebar{position:fixed;left:0;top:0;display:flex;align-items:center;gap:2px;max-width:calc(100% - 16px);padding:2px 2px 2px 10px;border-radius:10px;font-size:12px;color:var(--mu);white-space:nowrap;pointer-events:none;opacity:0;transform:translateY(4px);transition:opacity var(--out) var(--ei),transform var(--out) var(--ei)}.namebar.show{opacity:1;transform:none;pointer-events:auto;transition:opacity var(--in) var(--eo),transform .3s var(--eo)}.namebar.show.glide{transition-property:all;transition-duration:var(--mv);transition-timing-function:var(--eio)}.namebar:hover:not(:has(.nb:hover)){opacity:.15}.namebar .lbl{margin-right:6px;max-width:260px;overflow:hidden;text-overflow:ellipsis}.namebar .nb{padding:4px;display:grid;place-items:center;border-radius:7px;transition:background-color .2s var(--eo),color .2s var(--eo)}.namebar .nb:hover,.namebar .nb:focus-visible{background:var(--ho);color:var(--k)}.namebar .nb.on{background:var(--as);color:var(--pu-accent)}.namebar .nb[hidden]{display:none}.launch{position:fixed;right:0;bottom:var(--pu-lift);display:flex;flex-direction:row-reverse;align-items:center;border-top-left-radius:10px;pointer-events:auto;transform-origin:100% 100%;background:color-mix(in srgb,var(--su) 62%,transparent);-webkit-backdrop-filter:blur(10px) saturate(1.5);backdrop-filter:blur(10px) saturate(1.5);transition:opacity var(--in) var(--eo),transform var(--mv) var(--eo),background-color .3s var(--eo),color .3s var(--eo),bottom var(--mv) var(--eio)}.launch:has(.mode.on){background:color-mix(in srgb,var(--pu-accent) 90%,transparent);color:var(--pu-on,#fff)}.layer.listing .launch{opacity:0;transform:scale(.6);pointer-events:none}.menu.inp{--b:60px;right:8px;z-index:1}.menu.inp :is([data-item=comment],[data-item=all]){display:none}.launch .mode{position:relative;display:grid;place-items:center;width:32px;height:32px;border-radius:10px 0 0}.mode>*,.cnt>*{grid-area:1/1}.mode>*{display:grid;place-items:center;transition:opacity var(--in) var(--eo)}.cnt,.has>.plus{opacity:0}.has>.cnt{opacity:1}.cnt>.n{font-size:11px;font-weight:500;line-height:1;margin:-1.2px 0 0 1.2px;font-variant-numeric:tabular-nums lining-nums;opacity:0;transition:opacity var(--in) var(--eo)}.w>.n{margin-top:-3.4px}.cnt>svg{transition:opacity var(--in) var(--eo)}.cnt>svg+svg,.cnt.w>svg{opacity:0}.cnt.w>svg+svg{opacity:1}.n.on{opacity:1}.launch .mode:focus-visible{outline:2px solid var(--pu-accent);outline-offset:-2px}.mode>.dot{position:absolute;top:2px;right:2px;width:8px;height:8px;border-radius:50%;background:var(--pu-accent);opacity:0;transition:opacity var(--in) var(--eo),background-color .3s var(--eo)}.mode.else>.dot{opacity:1}.mode.on>.dot{background:var(--pu-on,#fff)}.ttip{display:grid;grid-template-columns:minmax(0,0fr);overflow:hidden;font-size:12px;color:var(--mu);pointer-events:none;opacity:0;transition:grid-template-columns var(--out) var(--ei),opacity var(--out) var(--ei)}.ttip>span{min-width:0;white-space:nowrap;padding-left:10px}.ttip small{font-size:12px}.ttip small,.mi .kc{color:var(--fa)}.launch:has(.mode.on) :is(.ttip,.ttip small){color:inherit}.launch:hover .ttip{grid-template-columns:minmax(0,1fr);opacity:1;transition:grid-template-columns var(--mv) var(--eo) .4s,opacity var(--in) var(--eo) .4s}.launch .mode[aria-expanded=true]+.ttip{grid-template-columns:minmax(0,0fr);opacity:0}@media(hover:none){.ttip,.tt,.cd>.thread .acts{display:none}}.menu{--b:calc(40px + var(--pu-lift));position:fixed;right:8px;bottom:var(--b);width:290px;border-radius:12px;padding:4px;pointer-events:none;opacity:0;transform:translateY(6px);transition:opacity var(--out) var(--ei),transform var(--out) var(--ei)}.menu.show{opacity:1;transform:none;pointer-events:auto;transition:opacity var(--in) var(--eo),transform var(--mv) var(--eo)}@media(max-height:600px){.menu{max-height:calc(100% - var(--b) - 8px);overflow-y:auto;overscroll-behavior:contain}}.mi{position:relative;display:flex;gap:10px;align-items:center;width:100%;min-height:34px;text-align:left;padding:6px 10px;border-radius:8px;transition:background-color .2s var(--eo)}.mi:hover,.mi:focus-visible{background:var(--so)}.mi svg{color:var(--mu);flex:none}.mi small{display:block;color:var(--fa);font-size:12px}.lb{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ma{flex:none;display:grid;margin:-2px 0}.ma .av{width:20px;height:20px;font-size:11px}.mi .av svg{color:inherit}.sep{height:1px;margin:4px 10px;background:var(--ru)}.subs{display:grid;grid-template-rows:0fr;opacity:0;transition:grid-template-rows var(--in) var(--eo),opacity var(--in) var(--eo)}.subs.open{grid-template-rows:1fr;opacity:1}.subs>div{min-height:0;overflow:hidden}.subs .mi{padding-left:30px}.chev{display:grid;transition:transform var(--in) var(--eo)}[aria-expanded=true]>.chev{transform:rotate(90deg)}.tt{position:absolute;right:calc(100% + 14px);top:50%;translate:0 -50%;width:max-content;max-width:220px;padding:4px 9px;border-radius:8px;font-size:12px;line-height:1.4;color:var(--mu);pointer-events:none;opacity:0;transform:translate(3px);transition:opacity var(--out) var(--ei),transform var(--out) var(--ei)}.mi:hover>.tt,.mi:focus-visible>.tt{opacity:1;transform:none;transition:opacity var(--in) var(--eo) .5s,transform var(--in) var(--eo) .5s}@media(max-width:600px){.tt{right:8px;top:auto;bottom:100%;translate:none;transform:translateY(3px)}}.sw{position:relative;flex:none;width:26px;height:16px;border-radius:8px;background:var(--ln);transition:background-color var(--mv) var(--eio)}.sw:before,.sw:after{content:"";position:absolute;top:2px;left:2px;width:12px;height:12px;border-radius:50%;background:#fff;box-shadow:0 1px 2px #00000040;transition:transform var(--mv) var(--eio),opacity var(--mv) var(--eio)}.sw:before{opacity:0;transform:translate(10px)}[aria-checked=true]>.sw{background:var(--pu-accent)}[aria-checked=true]>.sw:after{transform:translate(10px)}.tools{display:flex;flex:none;gap:2px}.tools[hidden]{display:none}.tool[aria-pressed=true]{background:var(--as);color:var(--pu-accent)}.note{display:block;padding:0 0 4px;font-size:12px;color:var(--fa)}.note[hidden]{display:none}.ov{position:absolute;inset:0;pointer-events:none;overflow:hidden}.xb{flex:1;overflow-y:auto;overscroll-behavior:contain;padding:4px 16px 16px;font-size:13px}.xb p{margin:0 0 10px}.all,.xp{position:fixed;top:0;right:0;bottom:0;width:var(--pu-panel);display:flex;flex-direction:column;border-width:0 0 0 1px;opacity:0;transform:translate(100%);transition:transform var(--out) var(--ei),opacity var(--out) var(--ei)}.all.show,.xp.show{opacity:1;transform:none;pointer-events:auto;transition:transform var(--mv) var(--eo),opacity var(--in) var(--eo)}.all.full{width:100%}.hd{display:flex;align-items:center;gap:4px;padding:8px 8px 6px}.sp{flex:1}.tg{position:relative;display:flex;align-items:center;gap:5px;height:28px;padding:0 11px 0 9px;border-radius:99px;white-space:nowrap;line-height:1;color:var(--mu);transition:background-color .2s var(--eo),color .2s var(--eo)}.tg:hover{background:var(--ho);color:var(--k)}.tg[aria-pressed=true]{background:var(--as);color:var(--pu-accent)}.tg[aria-pressed=true]:hover{background:color-mix(in srgb,var(--pu-accent) 20%,transparent)}.tg:focus-visible{outline:2px solid var(--pu-accent);outline-offset:1px}.tg:after{content:attr(data-tip);position:absolute;left:0;top:calc(100% + 4px);z-index:3;width:max-content;max-width:220px;padding:4px 9px;border:1px solid var(--ln);border-radius:8px;background:var(--su);box-shadow:var(--sh);font-size:12px;line-height:1.4;color:var(--mu);pointer-events:none;opacity:0;transform:translateY(-3px);transition:opacity var(--out) var(--ei),transform var(--out) var(--ei)}.tg:not([aria-pressed=true]):is(:hover,:focus-visible):after{opacity:1;transform:none;transition:opacity var(--in) var(--eo) .4s,transform var(--in) var(--eo) .4s}.list{flex:1;overflow-y:auto;overscroll-behavior:contain;padding:4px 8px 8px;background:var(--so)}.cd{position:relative;margin-top:6px;border:1px solid var(--ln);border-radius:10px}.list :is(.cd,[role=listitem],.sec){transition:all var(--mv) var(--eio)}.list .out{opacity:0!important;margin-top:0;padding-block:0;border-width:0;overflow:hidden}.cd.open{border-color:transparent;box-shadow:var(--sh)}.cd.done{--o:.6}.cd>.mi{position:absolute;inset:0;border-radius:10px;background:none}.cd>.thread :is(.acts,.refs,.edit){position:relative;z-index:1}.cd:not(.open,.new):is(:hover,:has(>.mi:focus-visible)){--bg:var(--so)}.cd.open>.mi{display:none}.cd.open .root>.hdr{cursor:pointer}.cd.new,.xr,.cd>.thread{padding:8px 10px 10px}.pf{display:flex;align-items:center;gap:8px;min-height:52px;padding:0 8px 0 14px;border-top:1px solid var(--ln)}.fs{display:flex;align-items:center;gap:6px;padding:4px 6px;border-radius:8px;font-size:13px;transition:background-color .2s var(--eo)}.fs:hover,.fs:focus-visible{background:var(--ho)}.fs small{font-size:12px;color:var(--fa)}.pf .ib{width:30px;height:30px}.cx{position:fixed;inset:0;width:100%;height:100%;overflow:visible;pointer-events:none;opacity:0;transition:opacity var(--in) var(--eo)}.cx.show{opacity:1}.cx path{fill:none;stroke:var(--pu-accent);stroke-width:1.5;stroke-linecap:round;opacity:.7}.cx circle{fill:var(--pu-accent)}.layer.listing .col{opacity:0;transition:opacity var(--out) var(--ei)}.sec{padding:8px 10px 2px;font-size:12px;color:var(--fa)}.ag{display:flex;align-items:center;gap:8px;padding:6px 14px;font-size:12px;color:var(--fa);border-bottom:1px solid var(--ln)}.ag[hidden]{display:none}.lns{display:flex;flex-direction:column}.ln{display:grid;grid-template-rows:0fr;opacity:0;transition:grid-template-rows var(--in) var(--eo),opacity var(--in) var(--eo)}.ln.show{grid-template-rows:1fr;opacity:1}.ln>.lw{overflow:hidden;min-height:0}.ag button{margin-left:auto;flex:none;padding:0 6px;border-radius:6px;color:var(--fa);transition:color .2s var(--eo),background-color .2s var(--eo)}.ag button:hover:not(:disabled),.ag button:focus-visible{color:var(--pu-accent);background:var(--as)}.ag button:disabled{opacity:.5;cursor:default}.adr{margin:8px 0 0 14px;padding:8px 10px;border-radius:8px;background:var(--so);font-size:13px;color:var(--k);animation:pu-in var(--mv) var(--eo) both}.adr small{display:block;font-size:12px;color:var(--fa)}.adr .go{display:flex;gap:6px;margin-top:6px}.adr .go button{padding:2px 8px;border-radius:6px;font-size:12px;color:var(--mu);transition:color .2s var(--eo),background-color .2s var(--eo)}.adr .go button:hover,.adr .go button:focus-visible{color:var(--pu-accent);background:var(--as)}@keyframes pu-in{0%{opacity:0;transform:translateY(3px)}to{opacity:1;transform:none}}.sec b{margin-left:6px;font-weight:500;color:var(--pu-accent)}.toast{--r:40px;position:fixed;right:var(--r);bottom:calc(4px + var(--pu-lift));max-width:min(320px,calc(100vw - var(--r) - 16px));border-radius:10px;padding:8px 14px;font-size:13px;opacity:0;transform:translateY(6px);transition:.3s var(--eo)}.toast.show{opacity:1;transform:none}.layer:is(.listing,:has(.xp.show)) .toast{--r:12px;bottom:64px;max-width:min(320px,calc(var(--pu-panel) - 24px));z-index:2}.layer:not(.listing):has(.menu.show) .toast{--r:314px}@media(max-width:640px){.layer:not(.listing):has(.menu.show) .toast{--r:12px;bottom:auto;top:12px}}@media(pointer:coarse){.mi,.ib,.rxo,.refs .ref,.mnl li,.bts button,.tg,.fs,.pm button,.ta,.nb,.selbar button,button.me,.say button,.line,.seen button,.ag button,.go button{min-height:44px}.ib,.rxo,.refs .ref,.nb,.selbar button,button.me,.ta{min-width:44px}.bub:before{content:"";position:absolute;inset:-14px;border-radius:50%}.row:focus-within .bts,.row.has .bts{max-height:52px}.hd{padding:4px 8px}.toast{--r:52px;display:flex;align-items:center;min-height:44px;padding:4px 14px;line-height:1.25}.ta{display:grid;place-items:center;margin:-5px -10px -5px 6px;padding:0 10px}.launch .mode{width:44px;height:44px}.menu{--b:calc(52px + var(--pu-lift))}}@media(pointer:coarse)and (hover:none){.ks{display:none}}.layer :is(button,a):not(.mi,.opn,.mode,.tg):focus-visible{outline:2px solid var(--pu-accent);outline-offset:1px}.layer .mi:focus-visible{outline:2px solid var(--pu-accent);outline-offset:-2px}.flip .launch{background:var(--su)}.flip :is(.th,.cd){opacity:1}.flip :is(.th,.cd)>*{opacity:var(--o,1);transition:opacity var(--in) var(--eo)}@media(forced-colors:active){.pick.kf{border:3px solid Highlight}.layer :is(.ib,.mi,.nb,.tg,.fs,.selbar button,.say button,.xb button):focus-visible{outline:2px solid Highlight}.sw{forced-color-adjust:none;border:1px solid CanvasText;background:Canvas}.sw:before,.sw:after{top:1px;left:1px;background:CanvasText}[aria-checked=true]>.sw{background:Highlight;border-color:Highlight}[aria-checked=true]>.sw:before,[aria-checked=true]>.sw:after{background:HighlightText}.layer :is(.tg,.rxo,.rx)[aria-pressed=true],.launch:has(.mode.on){forced-color-adjust:none;background:Highlight;color:HighlightText;border-color:Highlight}}@media(prefers-reduced-motion:reduce){.ln,.subs{transition-property:opacity}@keyframes pu-in{0%{opacity:0}to{opacity:1}}.bub,.bub.in,.bub.in:hover,.bub.on,.tip,.pop,.selbar,.menu,.all,.xp,.tt,.toast,.ref .rc,.rxp,.mnl{transform:none!important}.ttip{transition-property:opacity!important}.dlg{transform:translate(-50%)!important}.sw:after{transform:none!important;transition-property:opacity}[aria-checked=true]>.sw:after{opacity:0}[aria-checked=true]>.sw:before{opacity:1}.th,.th.long .root>.tx,.mr,.list :is(.cd,[role=listitem],.sec){transition-property:opacity,box-shadow}.tip.show,.toast{transition-property:opacity}.pick,.pick.show{transition:opacity .16s ease-in-out}.all,.all.show,.xp,.xp.show{transition-property:opacity}.namebar,.namebar.show{transform:none!important;transition:opacity .16s ease-in-out}.av,.nf,.launch{transform:none!important}@keyframes pu-pulse{0%{opacity:0}35%{opacity:.85}to{opacity:0}}}',root:e.root??document.body,onName:async e=>{u.name=e,o={...o,name:e},await n.saveProfile(o)}})}catch(e){throw Gn(null),e}s&&c.ctx.ae("This browser can't keep comments for this page \u2014 copy the comments (Copy comments \u203a As Markdown) to keep them");let p=()=>{u.flush().catch(e=>globalThis.reportError?.(e))},h=function(e){let t={...e,i:!0};Pt=t;for(let e of Tt.values())"waiting"===e.info.state&&zt(e,t);return()=>{t.i=!1,Pt===t&&(Pt=null);for(let e of[...Tt.values()].reverse())e.stop?.(),delete e.stop;e.surface.destroy()}}({surface:c.ctx.addons,doc:u,root:e.root??document.body,ephemeral:s,version:Be,onIdentity:async e=>{o={...o,identity:e},await n.saveProfile(o)}}),f=/\S/.test(document.documentElement.getAttribute("data-pipeup-agents")??"")?window.setTimeout(()=>{Rt().some(e=>"agents"===e.id)||console.warn("pipeup: this page lists an agent (data-pipeup-agents), but the agents add-on isn't on the page, so replies won't show. Add @pipeup/agents (see the Add-ons page).")},1e3):0;"off"!==document.documentElement.getAttribute("data-pipeup-updates")&&Date.now()-Date.parse(Ie)>31536e6&&console.info(`pipeup: this is Pipeup ${Be}, from ${Ie}; newer versions exist. See https://github.com/pipeup-ai/pipeup/blob/main/CHANGELOG.md`);let m=!1;return window.addEventListener("pagehide",p),{document:u,comments:({all:e=!1}={})=>Fe(c.ctx.l.all(),{title:document.title,url:location.href,exportedAt:new Date,all:e}),appearance:()=>({...c.appearance()}),flush:()=>u.flush(),unmount:()=>{m||(m=!0,window.removeEventListener("pagehide",p),window.clearTimeout(f),h(),c.destroy(),Gn(null),yo===t()&&(yo=null))}}}(e,()=>t).catch(e=>{throw yo===t&&(yo=null),e});return yo=t,t}typeof document<"u"&&(qt?console.warn(`pipeup: Pipeup is on this page twice (${qt.VERSION} and ${Be}); the first one is used. Remove one script.`):(Dt(),function(){let e=document.documentElement;if(!e.hasAttribute("data-pipeup-doc")||"off"===e.getAttribute("data-pipeup-auto"))return;let t=()=>{bo().catch(e=>console.error(e))};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",t,{once:!0}):t()}()));const xo=Object.defineProperty({},"__esModule",{value:!0});for(const[t,n]of Object.entries({ADDON_API:1,AI_NAME:v,ANIMALS:c,BUILT:Ie,COLOURS:u,DEFAULT_PROFILE_NAME:"",IndexedDbStore:ee,MemoryStore:X,PipeupDocument:_,UnsavedChangeError:Y,VERSION:Be,addons:Rt,agentComments:Fe,animalName:m,comments:async function(e){if(!yo)throw new Error("pipeup: Pipeup hasn't started on this page");return(await yo).comments(e)},computeOpId:F,copyAll:Re,copyThread:qe,createIdentity:s,describeElement:he,describeRange:pe,formatAgo:Pe,isAiName:w,labelOf:$e,loadOrCreateProfile:Q,locate:Le,mount:bo,nameOf:g,newDocumentAttribute:function(){return`${function(t=16){return e(crypto.getRandomValues(new Uint8Array(t)))}(12)}:${e(crypto.getRandomValues(new Uint8Array(32)))}`},onReveal:function(e){return Un.add(e),()=>{Un.delete(e)}},parseDocumentAttribute:j,readFeedbackFile:V,resolveAnchor:we,setPeople:function(e){gt=e.filter(e=>e&&"string"==typeof e.name&&e.name.trim()&&mt.test(e.ref)).slice(0,500).map(e=>({ref:e.ref,name:e.name.trim().slice(0,80),...e.agent?{agent:!0}:{}}));for(let e of[...vt])e()},setViewState:function(e){let t=null;if(e){t={};let n=0;for(let[o,r]of Object.entries(e))if(!("string"!=typeof r||"slide"===o||o.length>64||r.length>200)){if(++n>=16)break;t[o]=r}}Kn=t;for(let e of Yn)e()},signOp:T,use:Nt}))Object.defineProperty(xo,t,{value:n,enumerable:!0});return xo})();
2
+ "use strict";(()=>{function b(e){let n=globalThis;(n.pipeupAddons||=[]).push(e),typeof addEventListener=="function"&&addEventListener("load",()=>{n.Pipeup||console.error(`pipeup: the "${e.id}" add-on needs Pipeup on the page too; load pipeup.min.js.`)},{once:!0})}var se=2n**256n-2n**32n-977n;var L=/^\/__pipeup\/[A-Za-z0-9_-]{16,}$/;function P(e){let n=document.documentElement,t=n.getAttribute("data-pipeup-link")??"",o=L.test(t),i=!1,a=0,m=()=>{};async function r(){let c=!1;try{c=(await fetch(`${t}/comments`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(await e.snapshot())})).ok}catch{}if(!c)throw new Error("pipeup: the link to your agent isn't reachable; your comments are safe here")}let d=()=>{window.clearTimeout(a),m(),m=()=>{},i=!1};return{enabled:o,agent:n.getAttribute("data-pipeup-link-agent")??"",file:n.getAttribute("data-pipeup-link-file")??"",on:()=>i,set:async c=>{if(o){if(!c){d(),e.refresh();return}await r(),i=!0,m=e.changes(()=>{window.clearTimeout(a),a=window.setTimeout(()=>{r().catch(y=>{d(),e.refresh(),globalThis.reportError?.(y)})},300)}),e.refresh()}},destroy:d}}function C(e){if(!e)return{cli:"npx --yes pipeup@0",fallback:null};let t=`npx --yes pipeup@${e.split(".")[0]??"0"}`;return e.includes("-")?{cli:`npx --yes pipeup@${e}`,fallback:t}:{cli:t,fallback:null}}function R(e,n=""){if(n)return{page:n,served:!1};try{let t=new URL(e),o=decodeURIComponent(t.pathname);return o.endsWith("/")&&(o+="index.html"),t.protocol==="file:"?{page:/^\/[A-Za-z]:\//.test(o)?o.slice(1):o,served:!1}:{page:o,served:!0}}catch{return{page:"<the page's HTML file>",served:!1}}}var _=e=>{try{let n=new URL(e);return n.protocol==="file:"?decodeURIComponent(n.pathname).replace(/^\/([A-Za-z]:\/)/,"$1"):n.href}catch{return e}};function T(e){let n=d=>d.replace(/\s+/g," ").trim(),{cli:t,fallback:o}=C(e.version),i=`https://pipeup-ai.github.io/pipeup/${e.version?.includes("-")?"next/":""}`,{page:a,served:m}=R(e.url,e.file),r=m?`<the HTML file your site serves at ${a}>`:a;return[`Act on the review comments on this page, which uses Pipeup: ${n(e.title)} (${n(e.url)}).`,"",e.file?`1. Read the comments: \`${t} comments ${e.file}\` (add --all for resolved ones). If it says nothing is shared, ask me to switch on Share with my agent.`:"1. Read the comments. Open the page in a browser and run `await Pipeup.comments()`, then read `.markdown`. If you can't run the page, ask me to paste its comments (Copy comments \u203A As Markdown).","2. Work through the open threads in order. For each, make the change I approved, or say why you didn't. Ask me before changing anything I haven't approved, and answer a question with an answer.",e.replies?`3. Answer in each thread: \`${t} reply --page ${r} --thread <Thread id> "what you changed and where" --addressed "short note"\`. Pass that file, the one that runs Pipeup, not a file it shows. It writes ${n(_(e.replies))}, which the page reads by itself.`+(e.listed?"":` The page doesn't list you yet. Ask me first; after my yes, run \`${t} agent --name <your name> --page ${r} --yes\`.`)+(o?` If npm refuses ${t.split(" ").at(-1)}, use ${o.split(" ").at(-1)}: it answers these commands the same way.`:""):"3. Tell me what you would reply in each thread, in words I can paste.","4. Only mark a thread addressed. Never resolve, reopen, edit or delete: I close threads. Keep your key out of the page and its folder, and never answer as me.","",`Guide: ${i}skills/pipeup-apply/SKILL.md`].join(`
3
+ `)}var D=/^[A-Za-z0-9_-]{43}$/,H="pipeupReplies";var N=/^AI assistant\s*·?\s*/;function x(e=document.documentElement){let n=e.getAttribute("data-pipeup-agents")??"";return[...new Set(n.split(/[\s,]+/).filter(t=>D.test(t)))]}function k(e=location,n=document.documentElement){let t=n.getAttribute("data-pipeup-replies");try{let o=e.href.split(/[?#]/)[0],i=new URL(t??(/\/$/.test(o)?`${o}index.replies.js`:o.replace(/\.[^./]*$/,"")+".replies.js"),e.href),a=i.protocol==="file:"?e.protocol==="file:":i.origin===e.origin;return a||console.warn("pipeup: the replies file must be on this site or this computer; ignoring it"),a?i.href:null}catch{return null}}function U(e){let n=x(),t=0,o="",i=null;async function a(){let u=globalThis[H];if(!Array.isArray(u))return 0;let l=u.splice(0),g=[];for(let f of l){let h=f;if(!(h?.format!=="pipeup-replies"||h.doc!==e.document.id||!Array.isArray(h.ops)))for(let s of h.ops){let p=s?.body;p&&n.includes(p.author)&&(p.kind==="reply"||p.kind==="addressed"||p.kind==="react"||p.kind==="unreact")?(g.push(s),(p.name==="AI assistant"||p.name.startsWith("AI assistant "))&&(o=p.name.replace(N,""))):t++}}return g.length?e.merge(g):0}function m(){let u=k();return u?(i?.remove(),new Promise((l,g)=>{let f=document.createElement("script");i=f,f.src=`${u}?${Date.now()}`;let h=p=>{window.clearTimeout(s),f.remove(),i===f&&(i=null),p?g(new Error(`pipeup: ${p}`)):l()},s=window.setTimeout(()=>h("the replies file didn't answer"),4e3);f.addEventListener("load",()=>h()),f.addEventListener("error",()=>h("there is no replies file yet")),e.overlay().append(f)})):Promise.reject(new Error("pipeup: the replies file can't be read from here"))}async function r(){if(!n.length)return 0;let u=await a();return await m(),u+await a()}let d=!1,c=()=>{d||document.hidden||(d=!0,r().catch(()=>{}).finally(()=>d=!1))},y=0;return n.length?(c(),y=window.setInterval(c,4e3),document.addEventListener("visibilitychange",c)):a(),{enabled:n.length>0,ignored:()=>t,who:()=>o,check:r,tally:u=>{let l=u.filter(s=>!s.resolved),g=s=>s.root.replies.some(p=>n.includes(p.author)),f=new Set(u.map(s=>s.id));return{stray:new Set(e.document.ops().filter(s=>n.includes(s.body.author)&&!f.has(s.body.thread)).map(s=>s.body.thread)).size,open:l.length,answered:l.filter(g).length,addressed:l.filter(s=>s.addressed).length}},destroy:()=>{window.clearInterval(y),document.removeEventListener("visibilitychange",c),i?.remove()}}}var z=()=>globalThis.Pipeup??{},K=["M10 8h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-8a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2z","M16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2"],j=["M21 12L3.5 4.5 6.2 12l-2.7 7.5zM6.2 12H13"],F="Reads a replies file next to this page. When the page is shown through pipeup watch, and only after you switch it on, it sends this page's comments to the program running on this computer. Nothing leaves this computer.",S=e=>e instanceof Error?e.message.replace(/^pipeup: /,""):"Something went wrong";async function Z(e,n){try{await navigator.clipboard.writeText(e);return}catch{}let t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.cssText="position:fixed;opacity:0;pointer-events:none",n.append(t),t.select();let o=document.execCommand("copy");if(t.remove(),!o)throw new Error("pipeup: your browser blocked copying")}function E(){return{id:"agents",api:1,version:"0.6.0",needs:["menu","status","notify","listnote"],network:{when:"page-configured",to:["page"],says:F},setup(e){let n=U(e),t=P({snapshot:async()=>{let r=z();if(!r.comments)throw new Error("pipeup: this page has no Pipeup to read comments from");let[d,c]=await Promise.all([r.comments(),r.comments({all:!0})]);return{v:1,at:new Date().toISOString(),title:document.title,open:d,all:c}},changes:r=>e.document.onChange(r),refresh:()=>i()}),o=()=>n.who()||t.agent,i=()=>{if(e.setStatus(n.enabled||t.enabled?{text:t.on()?`Sharing comments with ${o()||"your agent"}`:`${o()||"An AI agent"} can answer comments here`}:null),!n.enabled)return e.setListNote(null);let r=n.tally(e.document.threads()),d=o()||"An agent",c=r.answered?`${d} has answered ${r.answered} of ${r.open} open comments${r.addressed?`; ${r.addressed} ${r.addressed===1?"is":"are"} marked addressed`:""}`:"No replies from an agent yet",y=n.ignored(),u=(t.on()?`Sharing with ${t.agent||"your agent"} \xB7 `:"")+c+(y?` \xB7 ${y} from other writers ignored`:"")+(r.stray?` \xB7 replies for ${r.stray} comment${r.stray===1?"":"s"} this page doesn't have`:"");e.setListNote({text:u,action:{label:"Check for replies",run:async()=>{try{let l=await n.check();e.notify(l?`${l} new ${l===1?"reply":"replies"}`:"No new replies")}catch(l){e.notify(S(l))}finally{i()}}}})},a=[e.addMenuItem({id:"prompt",icon:K,label:()=>"Copy a prompt for my agent",hint:()=>"Tells an AI agent where the comments are and how to answer them",select:async()=>{try{await Z(T({title:document.title,url:location.href,replies:k(),file:t.enabled?t.file:"",listed:x().length>0,version:globalThis.Pipeup?.VERSION}),e.overlay()),e.notify("Copied a prompt for your agent")}catch(r){e.notify(S(r))}}})];t.enabled&&a.push(e.addMenuItem({id:"link",icon:j,label:()=>"Share with my agent",hint:()=>"Sends this page's comments to the program running on this computer, and nothing else",checked:()=>t.on(),select:async()=>{try{await t.set(!t.on())}catch(r){e.notify(S(r))}i()}}));let m=e.document.onChange(i);return i(),()=>{m(),n.destroy(),t.destroy()}}}}b(E());})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipeup/agents",
3
- "version": "0.8.0",
3
+ "version": "0.8.2",
4
4
  "description": "Lets an AI agent read and answer a page's comments: its replies file, the live link on this computer and the prompt for an agent.",
5
5
  "license": "MIT",
6
6
  "author": "Pipeup contributors",
@@ -24,7 +24,7 @@
24
24
  "LICENSE"
25
25
  ],
26
26
  "peerDependencies": {
27
- "pipeup": "0.8.0"
27
+ "pipeup": "0.8.2"
28
28
  },
29
29
  "pipeup": {
30
30
  "network": {