@pipeup/identity 0.9.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,5 +8,5 @@
8
8
  .dlg-btn:hover,.dlg-btn:focus-visible{background:var(--ho);outline:none}
9
9
  .dlg-btn.primary{border-color:var(--pu-accent);color:var(--pu-accent)}
10
10
  .dlg-h{margin:12px 0 4px;font-size:13px;font-weight:600}
11
- @media (pointer:coarse){.dlg-btn{min-height:40px}}`;var x="0123456789ABCDEFGHJKMNPQRSTVWXYZ";var P=Uint8Array.from([48,46,2,1,0,48,5,6,3,43,101,112,4,34,4,32]);function L(t){let e=0,o=0,r="";for(let p of t)for(o=o<<8|p,e+=8;e>=5;)r+=x[o>>>e-5&31],e-=5;return e&&(r+=x[o<<5-e&31]),r}function Z(t){let e=0,o=0,r=[];for(let p of t){let c=x.indexOf(p);if(c<0)return null;o=o<<5|c,e+=5,e>=8&&(r.push(o>>>e-8&255),e-=8)}return Uint8Array.from(r)}function I(t){let e=2166136261;for(let r of t)e=Math.imul(e^r,16777619);e=Math.imul(e^e>>>15,739982445);let o="";for(let r=0;r<4;r++,e>>>=5)o+=x[e&31];return o}function U(t){return`PU1-${(L(t)+I(t)).match(/.{1,4}/g).join("-")}`}function D(t){let e=new Uint8Array(P.length+t.length);return e.set(P),e.set(t,P.length),crypto.subtle.importKey("pkcs8",e,{name:"Ed25519"},!0,["sign"])}async function R(){let t=crypto.getRandomValues(new Uint8Array(32));return{key:await D(t),code:U(t)}}async function K(t){let e=t.toUpperCase().replace(/[\s-]+/g,"");if(!e.startsWith("PU1")||e.length!==59)return{problem:"shape"};let o=e.slice(3).replace(/O/g,"0").replace(/[IL]/g,"1").replace(/U/g,"V"),r=Z(o.slice(0,52));if(!r||r.length<32)return{problem:"shape"};let p=r.slice(0,32);return I(p)!==o.slice(52)||L(p)!==o.slice(0,52)?{problem:"mistake"}:{key:await D(p)}}var q={shape:"That doesn't look like a recovery code. It starts with PU1 and is about 60 characters long.",mistake:"The code has a mistake in it. Check it against where you kept it, character by character."};function s(t,e={},...o){let r=document.createElement(t);for(let[p,c]of Object.entries(e))r.setAttribute(p,c);return r.append(...o),r}function H(t){let e=t.identity,o=t.document,r=e.portable,p=o.threads().some(n=>[n.root,...n.root.replies].some(i=>i.author===o.me)),c=s("h2",{class:"dlg-t"}),u=s("div",{class:"dlg-b"}),C=s("p",{class:"dlg-m",role:"status"}),y=s("div",{class:"dlg-a"}),T={close(){}},m=(n=!1)=>{T.close(),n&&location.reload()},a=(n,i,l=!1)=>{let b=s("button",{class:l?"dlg-btn primary":"dlg-btn",type:"button"},n);return b.addEventListener("click",()=>void i()),b},f=(...n)=>n.map(i=>s("p",{},i)),d=n=>C.textContent=n,B=(n,i)=>{c.textContent=i?"Your portable identity":"Back up my identity";let l=s("code",{class:"dlg-c"},n);l.tabIndex=0,u.replaceChildren(...f("This code is you. Keep it somewhere safe, like a password manager. Anyone who has it can write as you, and Pipeup never sends it anywhere. Without it, a cleared browser starts you over as someone new."),l);let b=()=>{let O=URL.createObjectURL(new Blob([`${n}
12
- `],{type:"text/plain"})),v=s("a",{href:O,download:"pipeup-identity.pipeup-id"});u.append(v),v.click(),v.remove(),window.setTimeout(()=>URL.revokeObjectURL(O),1e3),d("Saved. Keep the file somewhere safe.")};y.replaceChildren(a("Copy code",()=>navigator.clipboard.writeText(n).then(()=>d("Copied."),()=>d("Your browser blocked copying; select the code and copy it by hand."))),a("Save as a file",b),a(i?"Done, and use it now":"Done",()=>m(i),!0)),i&&d("It is kept in this browser now. Reload to use it; your earlier comments stay as they are.")},$=()=>{d(""),r?(c.textContent="Back up my identity",u.replaceChildren(...f("One moment\u2026")),e.seed().then(n=>n?B(U(n),!1):d("This identity can't be backed up."))):(c.textContent="Make my identity portable",u.replaceChildren(...f("Your identity stays in this browser, and can't be taken out of it. To use it on another browser or computer, Pipeup makes you a new one that you can back up with a recovery code.",p?"Comments you wrote before stay as they are, and show as written by an earlier you.":"You haven't written comments here yet, so nothing is left behind.")),y.replaceChildren(a("Not now",()=>m()),a("Make it portable",async()=>{try{let n=await R();await e.use(n.key),B(n.code,!0)}catch{d("Something went wrong. Nothing was changed.")}},!0)))},z=()=>{d(""),c.textContent="Use my identity";let n=s("textarea",{class:"dlg-f",rows:"3","aria-label":"Recovery code",spellcheck:"false"}),i=s("input",{type:"file",accept:".pipeup-id,text/plain","aria-label":"Choose a recovery file"});i.addEventListener("change",async()=>{let l=await i.files?.[0]?.text();l&&(n.value=l.trim())}),u.replaceChildren(...f("Paste the recovery code you backed up, or choose its file. This replaces the identity in this browser."),n,i),y.replaceChildren(a("Cancel",()=>m()),a("Use this identity",async()=>{let l=await K(n.value);if("problem"in l)return d(q[l.problem]);await e.use(l.key),d(""),c.textContent="Done",u.replaceChildren(...f("Your identity is back. Comments you wrote on this page before stay as they are, and show as written by an earlier you.")),y.replaceChildren(a("Reload",()=>m(!0),!0))},!0)),n.focus({preventScroll:!0})};c.textContent="My identity",u.replaceChildren(...f(r?"Your identity is portable: you have a recovery code for it.":"Your identity stays in this browser, so a cleared browser, or another computer, starts you over as someone new."));let E=o.contacts().get(o.me)??"",h=s("input",{class:"dlg-f",type:"text",maxlength:"120","aria-label":"Email or GitHub name",spellcheck:"false",placeholder:"you@example.org or gh:yourname"});h.value=E;let F=a("Share",async()=>{let n=await e.share(h.value);n&&(g.hidden=!1),d(n?"Shared with everyone who has this page's comments.":"That isn't an email address or a GitHub name (gh:yourname).")}),g=a("Stop sharing",async()=>{await e.unshare(),h.value="",g.hidden=!0,d("Stopped. People who see this page's comments from now on won't see it.")});g.hidden=!E,u.append(s("h3",{class:"dlg-h"},"Let people reach you"),...f("If you share an email address or a GitHub name, people who mention you can offer to let you know. Everyone who has this page's comments can see it."),h,s("div",{class:"dlg-a"},g,F)),y.replaceChildren(a("Close",()=>m()),a("Use a recovery code",z),a(r?"Back up my identity":"Make it portable",$,!0));let N=s("div",{},c,u,C,y);T=t.openDialog(N,"Your identity")}var W=["M4 20h4L19 9l-4-4L4 16z"];function _(){return{id:"identity",api:1,version:"0.8.0",needs:["menu","styles","dialog","identity"],network:{when:"never",to:[],says:"Nothing. Your recovery code stays on this device unless you copy it or save it as a file yourself."},setup(t){t.addStyles(M),t.addMenuItem({id:"identity",icon:W,label:()=>"My identity",hint:()=>"Back it up, or use one you backed up",select:()=>H(t)})}}}A(_());})();
11
+ @media (pointer:coarse){.dlg-btn{min-height:40px}}`;var x="0123456789ABCDEFGHJKMNPQRSTVWXYZ";var P=Uint8Array.from([48,46,2,1,0,48,5,6,3,43,101,112,4,34,4,32]);function L(t){let e=0,o=0,r="";for(let p of t)for(o=o<<8|p,e+=8;e>=5;)r+=x[o>>>e-5&31],e-=5;return e&&(r+=x[o<<5-e&31]),r}function Z(t){let e=0,o=0,r=[];for(let p of t){let c=x.indexOf(p);if(c<0)return null;o=o<<5|c,e+=5,e>=8&&(r.push(o>>>e-8&255),e-=8)}return Uint8Array.from(r)}function I(t){let e=2166136261;for(let r of t)e=Math.imul(e^r,16777619);e=Math.imul(e^e>>>15,739982445);let o="";for(let r=0;r<4;r++,e>>>=5)o+=x[e&31];return o}function U(t){return`PU1-${(L(t)+I(t)).match(/.{1,4}/g).join("-")}`}function D(t){let e=new Uint8Array(P.length+t.length);return e.set(P),e.set(t,P.length),crypto.subtle.importKey("pkcs8",e,{name:"Ed25519"},!0,["sign"])}async function K(){let t=crypto.getRandomValues(new Uint8Array(32));return{key:await D(t),code:U(t)}}async function R(t){let e=t.toUpperCase().replace(/[\s-]+/g,"");if(!e.startsWith("PU1")||e.length!==59)return{problem:"shape"};let o=e.slice(3).replace(/O/g,"0").replace(/[IL]/g,"1").replace(/U/g,"V"),r=Z(o.slice(0,52));if(!r||r.length<32)return{problem:"shape"};let p=r.slice(0,32);return I(p)!==o.slice(52)||L(p)!==o.slice(0,52)?{problem:"mistake"}:{key:await D(p)}}var q={shape:"That doesn't look like a recovery code. It starts with PU1 and is about 60 characters long.",mistake:"The code has a mistake in it. Check it against where you kept it, character by character."};function s(t,e={},...o){let r=document.createElement(t);for(let[p,c]of Object.entries(e))r.setAttribute(p,c);return r.append(...o),r}function H(t){let e=t.identity,o=t.document,r=e.portable,p=o.threads().some(n=>[n.root,...n.root.replies].some(i=>i.author===o.me)),c=s("h2",{class:"dlg-t"}),u=s("div",{class:"dlg-b"}),T=s("p",{class:"dlg-m",role:"status"}),y=s("div",{class:"dlg-a"}),C={close(){}},m=(n=!1)=>{C.close(),n&&location.reload()},a=(n,i,l=!1)=>{let b=s("button",{class:l?"dlg-btn primary":"dlg-btn",type:"button"},n);return b.addEventListener("click",()=>void i()),b},f=(...n)=>n.map(i=>s("p",{},i)),d=n=>T.textContent=n,B=(n,i)=>{c.textContent=i?"Your portable identity":"Back up my identity";let l=s("code",{class:"dlg-c"},n);l.tabIndex=0,u.replaceChildren(...f("This code is you. Keep it somewhere safe, like a password manager. Anyone who has it can write as you, and Pipeup never sends it anywhere. Without it, a cleared browser starts you over as someone new."),l);let b=()=>{let O=URL.createObjectURL(new Blob([`${n}
12
+ `],{type:"text/plain"})),v=s("a",{href:O,download:"pipeup-identity.pipeup-id"});u.append(v),v.click(),v.remove(),window.setTimeout(()=>URL.revokeObjectURL(O),1e3),d("Saved. Keep the file somewhere safe.")};y.replaceChildren(a("Copy code",()=>navigator.clipboard.writeText(n).then(()=>d("Copied."),()=>d("Your browser blocked copying; select the code and copy it by hand."))),a("Save as a file",b),a(i?"Done, and use it now":"Done",()=>m(i),!0)),i&&d("It is kept in this browser now. Reload to use it; your earlier comments stay as they are.")},$=()=>{d(""),r?(c.textContent="Back up my identity",u.replaceChildren(...f("One moment\u2026")),e.seed().then(n=>n?B(U(n),!1):d("This identity can't be backed up."))):(c.textContent="Make my identity portable",u.replaceChildren(...f("Your identity stays in this browser, and can't be taken out of it. To use it on another browser or computer, Pipeup makes you a new one that you can back up with a recovery code.",p?"Comments you wrote before stay as they are, and show as written by an earlier you.":"You haven't written comments here yet, so nothing is left behind.")),y.replaceChildren(a("Not now",()=>m()),a("Make it portable",async()=>{try{let n=await K();await e.use(n.key),B(n.code,!0)}catch{d("Something went wrong. Nothing was changed.")}},!0)))},z=()=>{d(""),c.textContent="Use my identity";let n=s("textarea",{class:"dlg-f",rows:"3","aria-label":"Recovery code",spellcheck:"false"}),i=s("input",{type:"file",accept:".pipeup-id,text/plain","aria-label":"Choose a recovery file"});i.addEventListener("change",async()=>{let l=await i.files?.[0]?.text();l&&(n.value=l.trim())}),u.replaceChildren(...f("Paste the recovery code you backed up, or choose its file. This replaces the identity in this browser."),n,i),y.replaceChildren(a("Cancel",()=>m()),a("Use this identity",async()=>{let l=await R(n.value);if("problem"in l)return d(q[l.problem]);await e.use(l.key),d(""),c.textContent="Done",u.replaceChildren(...f("Your identity is back. Comments you wrote on this page before stay as they are, and show as written by an earlier you.")),y.replaceChildren(a("Reload",()=>m(!0),!0))},!0)),n.focus({preventScroll:!0})};c.textContent="My identity",u.replaceChildren(...f(r?"Your identity is portable: you have a recovery code for it.":"Your identity stays in this browser, so a cleared browser, or another computer, starts you over as someone new."));let E=o.contacts().get(o.me)??"",h=s("input",{class:"dlg-f",type:"text",maxlength:"120","aria-label":"Email or GitHub name",spellcheck:"false",placeholder:"you@example.org or gh:yourname"});h.value=E;let F=a("Share",async()=>{let n=await e.share(h.value);n&&(g.hidden=!1),d(n?"Shared with everyone who has this page's comments.":"That isn't an email address or a GitHub name (gh:yourname).")}),g=a("Stop sharing",async()=>{await e.unshare(),h.value="",g.hidden=!0,d("Stopped. People who see this page's comments from now on won't see it.")});g.hidden=!E,u.append(s("h3",{class:"dlg-h"},"Let people reach you"),...f("If you share an email address or a GitHub name, people who mention you can offer to let you know. Everyone who has this page's comments can see it."),h,s("div",{class:"dlg-a"},g,F)),y.replaceChildren(a("Close",()=>m()),a("Use a recovery code",z),a(r?"Back up my identity":"Make it portable",$,!0));let N=s("div",{},c,u,T,y);C=t.openDialog(N,"Your identity")}var W=["M4 20h4L19 9l-4-4L4 16z"];function _(){return{id:"identity",api:1,version:"0.8.0",needs:["menu","styles","dialog","identity"],network:{when:"never",to:[],says:"Nothing. Your recovery code stays on this device unless you copy it or save it as a file yourself."},setup(t){t.addStyles(M),t.addMenuItem({id:"identity",icon:W,label:()=>"My identity",hint:()=>"Back it up, or use one you backed up",select:()=>H(t)})}}}A(_());})();
@@ -1,4 +1,4 @@
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"],p=["Red","Orange","Yellow","Green","Teal","Blue","Purple","Pink","Brown","Grey"];function u(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=>u(e)%c.length,f=e=>Math.floor(u(e)/c.length)%p.length,m=e=>`${p[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=u(`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=e=>`${v} \xb7 ${e.replace(/\s+/g," ").trim()||"Agent"}`.slice(0,80).trim(),b=(e,t)=>e.name.startsWith(`${v} \xb7 `)&&!t.includes(e.author),x=2**40,k=2**47,E=1e4,S=200,$=/^[0-9a-f]{8}$/,L=/^[A-Za-z0-9_-]{43}$/,M=/^(?:[^\s@<>"]{1,64}@[^\s@<>"]{1,190}\.[^\s@<>"]{2,24}|gh:[A-Za-z0-9-]{1,39})$/,C=/^(?:[A-Za-z0-9_-]{43}|(?:host|gh):[A-Za-z0-9._@-]{1,64})$/,A=/^[A-Za-z0-9_-]{43}$/,T=new Set(["create","reply","edit","delete","resolve","reopen","addressed","react","unreact","seen","contact","uncontact"]),P=/^(?:\p{Regional_Indicator}{2}|[#*0-9]\uFE0F?\u20E3|\p{Extended_Pictographic}(?:\uFE0F|\p{Emoji_Modifier})?(?:\u200D\p{Extended_Pictographic}(?:\uFE0F|\p{Emoji_Modifier})?)*)$/u,q=e=>"string"==typeof e&&P.test(e)&&[...e].length<=16;async function N(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 R=(e,t)=>"string"==typeof e&&e.length<=t,D=e=>!!e&&"object"==typeof e,z=e=>"number"==typeof e&&Number.isFinite(e)&&e>=0&&e<=1;function O(e){if(!D(e))return!1;let{id:t,path:n,fingerprint:o,snapshot:r,quote:i,point:a,view:l}=e;if(!(R(n,2e3)&&R(r,500)&&"string"==typeof o&&$.test(o)&&(void 0===t||R(t,200)&&""!==t)&&(void 0===i||D(i)&&R(i.exact,E)&&""!==i.exact&&R(i.prefix,64)&&R(i.suffix,64))&&(void 0===a||D(a)&&z(a.x)&&z(a.y))))return!1;if(void 0!==l){if(!D(l)||Array.isArray(l))return!1;let e=Object.entries(l);if(e.length>16||!e.every(([e,t])=>e.length<=64&&R(t,S)))return!1}return!0}function H(e){if(!D(e))return!1;let{body:t,sig:n}=e;if("string"!=typeof n||!D(t)||JSON.stringify({body:t,sig:n}).length>262144)return!1;let o=t;if(1!==o.v||"string"!=typeof o.id||!L.test(o.id)||!T.has(o.kind)||!R(o.doc,64)||""===o.doc||"string"!=typeof o.thread||!L.test(o.thread)||"string"!=typeof o.author||!A.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>x||"number"!=typeof o.at||!Number.isSafeInteger(o.at)||o.at<0||o.at>k||void 0!==o.text&&(!R(o.text,1e4)||o.text!==o.text.trim())||void 0!==o.target&&("string"!=typeof o.target||!L.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(!D(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||!C.test(r))return!1}}return!(!("contact"!==o.kind||"string"==typeof o.text&&M.test(o.text))||"seen"===o.kind&&!o.target||!("react"!==o.kind&&"unreact"!==o.kind||o.target&&q(o.text))||!("create"!==o.kind||o.id===o.thread&&O(o.anchor)))}function F(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 I(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 B(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 j(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 W=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(I)){if(r.name&&!w(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=B(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=B(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)=>!w(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(!H(n)||n.body.doc!==this.doc||this.ops.has(n.body.id)||n.body.id!==await j(n.body)||!await F(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,x),at:Math.min(Math.max(Date.now(),"create"===n.kind?(this.createAt.get(e.publicKey)??0)+1:(this.threadAt.get(n.thread)??0)+1),k)};o.id=await j(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 N(o,e)]);if(!i)throw new Error("pipeup: could not record this change");return i}},K=/^([A-Za-z0-9_-]{16}):([A-Za-z0-9_-]{43})$/;async function V(e){let n=K.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 U(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 Y=e=>`pipeup-file:${e}`;async function _(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},Y(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 G=/^[a-z][a-z0-9-]{1,23}\/[a-z][a-z0-9-]{0,31}$/,Z=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"}},J=class e{constructor(e,t){this.log=e,this.options=t,this.displayName=t.name.trim()?ee(t.name):""}listeners=new Set;cache=[];comments=new Map;displayName;Ee=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 W(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=ee(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:X(t),...n?.length?{mentions:n}:{}}))}reply(e,t,n){return this.enqueue(()=>this.write({kind:"reply",thread:this.find(e).thread,target:e,text:X(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:X(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 M.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(I))"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:Q(t)})})}unreact(e,t){return this.enqueue(async()=>{await this.write({kind:"unreact",thread:this.find(e).thread,target:e,text:Q(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)})})}paste(e,t,n,o){return this.enqueue(async()=>{let r=this.thread(e),i=y(t),a=this.cache.find(e=>e.id===r).root.id;await this.write({kind:"reply",thread:r,target:a,text:X(n)},i),o?.trim()&&await this.write({kind:"addressed",thread:r,text:X(o)},i)})}sign(e,t){if(!G.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 U(n,JSON.stringify(t),Y(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 _(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 Z(n[0].body.id,e,n.length):e}return n.length})}enqueue(e){let t=this.Ee.then(e);return this.Ee=t.catch(()=>{}),t}async write(e,t=this.displayName){let n=await this.log.append(this.options.identity,t,e);this.unsaved.push(n),this.refresh(!0,[n],"local");try{await this.persist()}catch(e){throw new Z(n.body.id,e)}return n.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 X(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 Q(e){if(!q(e))throw new Error("pipeup: a reaction is one emoji");return e}function ee(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 te=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 ne(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 oe=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=re(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=re(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 re(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 ie(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 ae(e,t,n){let o=(e.ownerDocument??e).createRange();return o.setStart(e,0),o.setEnd(t,n),o.toString().length}function le(e,t,n){let o=se(e,t,!1),r=se(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 se(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 de(e){return e.nodeType===Node.ELEMENT_NODE?e:e.parentElement}function ce(e,t){for(let n=de(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 pe(e,t,n){return e.slice(t,n).replace(/^[\uDC00-\uDFFF]|[\uD800-\uDBFF]$/g,"")}function ue(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 he(e){if(!O(e))throw new Error("pipeup: could not describe this place on the page");return e}function fe(e,t){let n=de(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 me(e,t,n){if(!t.contains(e.commonAncestorContainer))throw new Error("pipeup: the selection is outside the commentable area");let o=ce(e.commonAncestorContainer,t),a=o??t,{text:l}=ie(a),s=ae(a,e.startContainer,e.startOffset),d=ae(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>E)throw new Error("pipeup: selections are limited to 10000 characters");let p=pe(l,Math.max(0,s-32),s),u=pe(l,d,d+32);return he({...o?{id:o.getAttribute("data-pipeup-id")??""}:{},path:"",quote:{exact:c,prefix:p,suffix:u},...n?{view:n}:{},fingerprint:i(fe(e.startContainer,t).textContent??""),snapshot:pe(r(p+c+u),0,200)})}function ge(e,t,n,o){let a=ce(e,t);return he({...a?{id:a.getAttribute("data-pipeup-id")??""}:{},path:ue(a??t,e),...n?{point:{x:ve(n.x),y:ve(n.y)}}:{},...o?{view:o}:{},fingerprint:i(e.textContent??""),snapshot:pe(r(e.textContent??""),0,200)})}function ve(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):0}function we(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 ye=(e,t)=>we(e,t,!1).pop(),be={state:"orphaned",element:null,range:null};function xe(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=ie(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=Ee(i,t.prefix)+ke(a,t.suffix);l>o&&(n=r,o=l)}return n}(l.text,t);if(s>=0){let r=le(l,s,s+t.exact.length);if(r){let t=fe(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:ie(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(we(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=ye(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?le(e,n.start,n.end):null;if(r)return{state:"moved",element:fe(r.startContainer,o),range:r}}}return be}(e,e.quote,o,t,!1!==n.fuzzy):function(e,t){if(!t)return be;let n=t;if(e.path){if(!e.path.startsWith(":scope > "))return be;try{n=t.querySelector(e.path)}catch{return be}}return n?{state:i(n.textContent??"")===e.fingerprint?"attached":"moved",element:n,range:null}:be}(e,o)}function ke(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;return n}function Ee(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 Se={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 $e(e){let t=e.getAttribute("role")??("INPUT"===e.tagName?e.type:""),n=e.getAttribute("data-pipeup-label")||Object.hasOwn(Se,t)&&Se[t]||Se[e.tagName.toUpperCase()];if(n)return n;if(Me(e))return"Block";let o=e.getBoundingClientRect(),r=o.width/o.height;return r>1.4||r<.7?"Bar":"Shape"}var Le=e=>e.innerText||e.textContent||"";function Me(e){let t=e,n=t.labels?.[0];return Ne(r(e.getAttribute("aria-label")??e.getAttribute("alt")??(n&&Le(n))??("SELECT"===e.tagName?t.selectedOptions[0]?.text:null)??(t.placeholder||Le(e))),40)}function Ce(e){let t=e.getAttribute("data-pipeup-label");if(t)return t;let n=e.getAttribute("data-pipeup-ask");if(n)return`Ask "${n}"`;let o=Me(e);return o?`${$e(e)} \xb7 ${o}`:$e(e)}function Ae(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(qe)?.textContent;s.push(`Slide ${d}`+(e?` "${Ne(r(e))}"`:""))}else{let t=Pe(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(qe)?e:[...e.querySelectorAll(qe)].pop();if(t&&i(e)===i(t)&&(!o||n(t)))return t}return null}(l,n);o&&s.push(`Section "${Ne(r(o.textContent??""))}"`)}let c=Ce(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}}var Te="pipeup-edition";function Pe(e){return e?e.label||Object.entries(e).filter(([e,t])=>t&&"slide"!==e&&e!==Te).map(([,e])=>e).join(" \xb7 "):""}var qe="h1,h2,h3";function Ne(e,t=60){return e.length>t?e.slice(0,t-1)+"\u2026":e}function Re(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 De(e,t,n,o){return"ai"===t?Fe(e,"## ",o,n):Ie(e)}function ze(e,t,n){let o=n.all?e:e.filter(e=>!e.thread.resolved);if("text"===t)return o.map(Ie).join("\n");let r=e.filter(e=>e.thread.resolved).length,i=e.length-r,a=function(e){let t=[...new Set(e.flatMap(({thread:e})=>[e.root,...e.root.replies].map(e=>He(g(e)))))],n=t.length>3?[...t.slice(0,2),t.length-2+" others"]:t;return n.length>1?`${n.slice(0,-1).join(", ")} and ${n.at(-1)}`:n[0]??""}(o),l=n.exportedAt.toUTCString(),s=[`# Comments on ${He(n.title)}`,"",`${i||"No"} open comment${1===i?"":"s"}${n.all&&r?` and ${r} resolved`:""}${a?` from ${a}`:""}, copied ${l.slice(5,16).replace(/^0/,"")}, ${l.slice(17,22)} UTC.`+(n.all||!r?"":` ${r} resolved comment${1===r?" is":"s are"} left out.`),"",`Page: ${He(n.url)}`,"",""].join("\n"),d=n.exportedAt.getTime();return s+o.map((e,t)=>Fe(e,`## ${t+1}. `,d)).join("\n")+(o.length?"\n---\n\nFor an AI assistant: work through the open comments in order and say what you changed, or why you didn't. Each one's last line gives the thread to answer and the element's data-pipeup-id in the page's HTML. Answer in the thread with Pipeup (its pipeup-apply skill says how) and mark it addressed; never resolve it, the author does.\n":"")}function Oe(e){return e.reactions.map(e=>`${e.emoji} ${e.by.length} (${e.by.map(e=>He(g(e))).join(", ")})`).join(" \xb7 ")}function He(e){return e.replace(/\s+/g," ").trim()}function Fe(e,t,n,o){let{thread:r,location:i}=e,a=[t+He(i.where),""];o&&a.push(`Page: ${He(o)}`,""),i.quote&&a.push(`On the words "${He(i.quote)}".`,""),i.pin&&a.push(`Pinned ${He(i.pin)}.`,""),a.push(`**${He(g(r.root))}** (${Re(r.root.at,n)}): ${Be(r.root," ")}`),r.root.reactions.length&&a.push(`Reactions: ${Oe(r.root)}`);for(let e of r.root.replies)a.push(`- **${He(g(e))}** (${Re(e.at,n)}): ${Be(e," ")}`),e.reactions.length&&a.push(` - Reactions: ${Oe(e)}`);r.addressed&&!r.resolved&&a.push("",`**${He(g(r.addressed))}** marked it addressed (${Re(r.addressed.at,n)}): ${He(r.addressed.text)}`);let l=i.id?` \xb7 ${i.within?"in":"on"} \`data-pipeup-id="${He(i.id.replace(/`/g,""))}"\``:"";return a.push("",`${r.resolved?"Resolved":r.addressed?"Open, addressed":"Open"} \xb7 thread \`${r.id}\`${l}`),a.join("\n")+"\n"}function Ie(e){let{thread:t,location:n}=e,o=[He(n.where)+(n.quote?`, on the text "${He(n.quote)}"`:""),`${He(g(t.root))}: ${Be(t.root," ")}`];t.root.reactions.length&&o.push(` Reactions: ${Oe(t.root)}`);for(let e of t.root.replies)o.push(` ${He(g(e))}: ${Be(e," ")}`),e.reactions.length&&o.push(` Reactions: ${Oe(e)}`);return o.join("\n")+"\n"}function Be(e,t){return e.deleted?"(deleted)":e.text.replace(/\r\n|\r|\n/g,"\n"+t)+(e.edited?" (edited)":"")}function je(e,t){return{markdown:ze(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 We="0.9.1",Ke="2026-11-01",Ve=new Map,Ue=new Map,Ye=new Map,_e=new Map,Ge={},Ze=e=>{let t=`${Ve.get(e.id)??""}|${Ue.get(e.id)??""}`;for(let n of[e.root,...e.root.replies]){let e=_e.get(n.id);e&&(t+=`|${n.id}:${e.text}:${e.tip??""}`)}return t};function Je(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 Xe(e,t){let n=e.getRootNode().activeElement;t&&n instanceof HTMLElement&&e.contains(n)&&n.blur(),e.inert=t}function Qe(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 et=()=>{let e=window.getSelection();return e&&!e.isCollapsed&&e.toString().trim()?e:null};function tt(e,t){return e.length>t?e.slice(0,t-1)+"\u2026":e}function nt(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 ot=/\bhttps?:\/\/[^\s<>"'`]+/gi,rt=/[\u202A-\u202E\u2066-\u2069]/;function it(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 at(e){let t=[],n=0;for(let o of e.matchAll(ot)){if(o[0].length>2048||rt.test(o[0]))continue;let r,i=it(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=Je("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 lt="http://www.w3.org/2000/svg",st={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"],browser:["M4 7a3 3 0 0 1 3-3h10a3 3 0 0 1 3 3v10a3 3 0 0 1-3 3H7a3 3 0 0 1-3-3z","M4 9.5h16M7.5 6.8h.01"],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 dt(e,t=15,n){let o=ct(st[e],t);return n&&o.setAttribute("stroke-width",String(n)),o}function ct(e,t){let n=document.createElementNS(lt,"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(lt,"path");e.setAttribute("d",t),n.append(e)}return n}var pt=(e,t,n)=>`M${e} ${t}a${n} ${n} 0 1 0 ${2*n} 0a${n} ${n} 0 1 0 -${2*n} 0`,ut={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${pt(7.4,11.5,1.9)}${pt(12.8,11.5,1.9)}M11.3 14.6l.7 1 .7-1`,Bear:`${pt(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:`${pt(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 ht(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 ft=(e,t)=>ht(t)||m(e);function mt(e,t){return w(t)?Je("span",{class:"av ai","data-pipeup-ai":"","aria-hidden":"true"},"AI"):Je("span",{class:`av c${f(e)}`,"aria-hidden":"true","data-animal":m(e)},ht(t)||ct([ut[c[h(e)]]],24))}function gt(e,t){setTimeout(()=>{e.remove(),t?.()},320)}function vt(e){return requestAnimationFrame(()=>{e.offsetWidth,e.classList.add("in")}),e}var wt=new Map;function yt(e){wt.clear();for(let[t,n]of Object.entries(e??{}))void 0!==n&&wt.set(t,n)}function bt(e){return wt.has(e)?wt.get(e):typeof document>"u"?null:document.querySelector(`script[${e}]`)?.getAttribute(e)??document.documentElement.getAttribute(e)}var xt=e=>null!==bt(e),kt=/^[A-Za-z0-9_-]{43}$/,Et=/^(?:host|gh):[A-Za-z0-9._@-]{1,64}$/,St=[],$t=new Set,Lt=()=>(bt("data-pipeup-agents")??"").split(/[\s,]+/).filter(e=>kt.test(e));function Mt(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 Lt())o({ref:e,name:"AI agent",agent:!0});for(let e of St)o(e);return[...n.values()].sort((e,t)=>e.name.localeCompare(t.name))}var Ct=(e,t)=>!!e.mentions?.some(e=>t.includes(e.ref)),At=[],Tt=e=>[e,...At],Pt=null,qt=e=>{Pt=e},Nt="pu-source";function Rt(e){let t=Je("textarea",{class:"input",dir:"auto",rows:"1",autocomplete:"off","aria-label":e.name??e.label,placeholder:e.placeholder??""}),n=Je("button",{class:"send",type:"button",inert:!0},e.label),o=Je("button",{class:"cnl",type:"button"},"Cancel"),r=Je("span",{class:"tools"});r.hidden=!0;let i=Je("div",{class:"line"},t,r),a=Je("div",{class:"row"},i,Je("div",{class:"bts"},e.lead??null,o,n)),l=e.kind??"comment",s=!1,d=new Set,c=()=>{for(let e of[...d])e()},p=()=>{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`},u=()=>{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),p()};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,p()}}},h=new Map,f=()=>{let n=(Pt?.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=Je("button",{class:"ib tool",type:"button","aria-label":o.label,title:o.label,"aria-pressed":"false"},ct(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:u,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(Nt,f);let m=[],g=Je("ul",{class:"mnl",role:"listbox","aria-label":"People"}),v=Je("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(),p()},$=async()=>{let o=t.value.trim();if(o&&!s){s=!0;try{await e.K(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(),p(),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",()=>{p(),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=Je("li",{role:"option",id:`${w}-${t}`,class:e.agent?"agent":""},Je("span",{},e.name),e.agent?Je("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="",p(),(!n||"reply"!==l)&&t.blur(),c(),e._?.(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(p)),{element:a,input:t,focus:()=>t.focus({preventScroll:!0})}}var Dt=["sync","menu","notify","note","composer","panel","styles","status","overlay","here","sign","listnote","commentmark","reactions","identity","dialog","paste","place","post"],zt=/^[a-z][a-z0-9-]{1,23}$/,Ot=["text","muted","faint","line","surface","soft","hover","shadow","ease"],Ht=["pointerdown","pointerup","keydown","click"],Ft=new Set(["local","file","page","user","pipeup","presence","sync"]),It="data-pipeup-placed",Bt=`[data-pipeup-ask][${It}]>:not(pipeup-place){display:none}`,jt=class{constructor(e,t,n){this.ctx=e,this.shadow=t,this.after=n,qt({tools:()=>this.Z,note:()=>[...this.ae.values()].at(-1)??null,reporting:()=>this.X.size>0});for(let e of Ht)window.addEventListener(e,this.Te,!0)}se=0;z=[];ae=new Map;writing=new Map;marked=new Map;paint=0;X=new Map;listNotes=new Map;picker=null;pickerOwner="";Z=[];le=new Set;U=new Set;J=new Set;Q=new Map;O=new Map;H=new Map;remote={n:0,who:new Set};last=0;timer=0;ke="";R=new Map;de=null;Se=!1;Le=[];Te=e=>{e.isTrusted&&(this.Le=e.composedPath())};subscribe(e){return this.J.add(e),()=>{this.J.delete(e)}}changed(e){e&&this.se++;for(let t of[...this.J])t(e);for(let e of this.ctx.e.querySelectorAll(".row, .draft"))e.dispatchEvent(new Event(Nt))}D(e,t){let n=this.H.get(e)??this.H.set(e,new Set).get(e),o=()=>{n.delete(o)&&t()};return n.add(o),o}Me(){return[...this.X.values()].map(e=>e.text).join(" \xb7 ")}qe(e,t){return this.z.push(t),this.changed(!0),{update:()=>this.changed(!1),remove:this.D(e,()=>{this.z.splice(this.z.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?(Ve.delete(t),o.delete(t)):(Ve.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(Ye.delete(t),!Ue.delete(t))return;r.delete(t)}else{if(Ue.get(t)===n&&!!Ye.get(t)==!!o)return;Ue.set(t,n),o?Ye.set(t,o):Ye.delete(t),r.add(t)}this.repaint()}setCommentMark(e,t,n){let o=_e.get(t);if(null===n){if(o?.by!==e)return;_e.delete(t)}else{let r=String(n.text),i=void 0===n.tip?void 0:String(n.tip);if(o?.by===e&&o.text===r&&o.tip===i)return;_e.set(t,{text:r,tip:i,by:e})}this.repaint()}repaint(){this.paint||(this.paint=window.requestAnimationFrame(()=>{this.paint=0,this.ctx.m()}))}ce(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)}Fe(e,t){return this.Z.push(t),this.changed(!1),this.D(e,()=>{this.Z.splice(this.Z.indexOf(t),1),this.changed(!1)})}closed(){return this.ctx.state.hidden&&!this.ctx.state.l}Ve(e,t){this.closed()?this.O.set(e,t):this.ctx.pe(t)}flush(){if(this.closed()||0===this.O.size)return;let e=[...this.O.values()].at(-1);this.O.clear(),this.ctx.pe(e)}Ke(){return this.shadow.activeElement instanceof HTMLTextAreaElement||[...this.ctx.e.querySelectorAll("textarea")].some(e=>""!==e.value.trim())}_e(e){this.ctx.state.hidden||this.ctx.T(e)}ze(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.Ae()}}Ae(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.Ke())return this.Ae(1e3);let{n:e,who:t}=this.remote;this.remote={n:0,who:new Set},this.last=Date.now(),this.ctx.T(`${e} new comment${1===e?"":"s"} from ${1===t.size?[...t][0]:`${t.size} people`}`)},e))}Ue(e){let t=this.Q.get(e);return t||(t=Je("div",{class:"ov","aria-hidden":"true","data-addon":e}),this.ctx.e.insertBefore(t,this.after.nextSibling),this.Q.set(e,t)),t}je(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(Je("style",{},t));return this.D(e,()=>o?this.shadow.adoptedStyleSheets=this.shadow.adoptedStyleSheets.filter(e=>e!==o):r.remove())}Ce(e,t,n){return t.add(n),this.D(e,()=>t.delete(n))}We(e,t){return this.Ce(e,this.le,t)}Ye(e,t){let n=this.Ce(e,this.U,t);return this.call(this.U,t,this.Pe()),n}Pe(){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}}Ge(){let e=new Set;for(let t of this.R.values())for(let n of t.keys())e.add(n.getAttribute("data-pipeup-id")??"");return e}place(e,t){let n=this.R.get(e)??this.R.set(e,new Map).get(e),o=n.get(t);if(o)return o.shadowRoot;if(!(t instanceof Element)||!t.matches("[data-pipeup-ask],[data-pipeup-inline]")||!this.ctx.root.contains(t)||t.closest(`[${It}]`))throw new Error("pipeup: not an element marked for add-ons");let r=t.ownerDocument;this.de??=this.Xe(r,Bt);let i=r.createElement("pipeup-place"),a=i.attachShadow({mode:"open"}),l=":host{all:initial;display:block;font:14px/1.5 var(--pu-font,system-ui,sans-serif);color:var(--pu-text)}",s=r.defaultView?.CSSStyleSheet;if(s&&"adoptedStyleSheets"in a){let e=new s;e.replaceSync(l),a.adoptedStyleSheets=[e]}else a.append(Je("style",{},l));return this.$e(i),t.setAttribute(It,""),t.append(i),n.set(t,i),this.D(e,()=>{i.remove(),t.removeAttribute(It),n.delete(t),[...this.R.values()].some(e=>e.size)||(this.de?.(),this.de=null),this.repaint()}),this.repaint(),a}$e(e){let t=getComputedStyle(this.ctx.e);for(let n of Ot)e.style.setProperty(`--pu-${n}`,t.getPropertyValue(`--pu-${n}`))}Xe(e,t){let n=e.defaultView?.CSSStyleSheet;if(n&&"adoptedStyleSheets"in e){let o=new n;return o.replaceSync(t),e.adoptedStyleSheets=[...e.adoptedStyleSheets,o],()=>{e.adoptedStyleSheets=e.adoptedStyleSheets.filter(e=>e!==o)}}let o=e.head.appendChild(Je("style",{},t));return()=>o.remove()}Ze(e){let t=[...this.R.get(e)?.values()??[]];return!1!==navigator.userActivation?.isActive&&this.Le.some(n=>t.includes(n)||n instanceof HTMLElement&&n.dataset.addon===e)}async post(e,t){if(!this.Ze(e))throw new Error("pipeup: not sent by the reviewer here");let{doc:n,root:o,f:i}=this.ctx;if(t.remove)return await n.remove(t.remove),t.remove;let a=String(t.text??"");if(t.edit)return await n.edit(t.edit,a),t.edit;if(t.replyTo)return n.reply(t.replyTo,a);let l=t.anchor;if(!l||!this.R.get(e)?.has(l)||!l.getAttribute("data-pipeup-id"))throw new Error("pipeup: not a marked block with a data-pipeup-id");let s=ge(l,o,void 0,i.view(l));return t.excerpt&&(s.snapshot=r(t.excerpt).slice(0,200)),n.comment(s,a)}N(){let e=this.ctx.e.classList.contains("dark");if(e!==this.Se){this.Se=e;for(let e of this.R.values())for(let t of e.values())this.$e(t)}for(let e of[...this.le])this.call(this.le,e);if(0===this.U.size)return;let t=this.Pe(),n=JSON.stringify(t);if(n!==this.ke){this.ke=n;for(let e of[...this.U])this.call(this.U,e,t)}}call(e,t,...n){try{t(...n)}catch(n){e.delete(t),globalThis.reportError?.(n)}}Je(e,t,n){let o=this.ctx.e,r=this.shadow.activeElement,i=Je("button",{class:"ib",type:"button","aria-label":"Close"},ct(["M6 6l12 12M18 6L6 18"],15)),a=Je("div",{class:"xp",role:"dialog","aria-label":n.label,"data-addon":e},Je("div",{class:"hd"},Je("span",{},n.label),i),Je("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.D(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=Je("div",{class:"dlg",role:"dialog","aria-label":n,"data-addon":e},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.D(e,()=>o.remove()),{close:i}}clear(e){for(let t of[...this.H.get(e)??[]])t();this.H.delete(e),this.Q.get(e)?.remove(),this.Q.delete(e);for(let t of[this.ae,this.X,this.listNotes,this.O])t.delete(e);this.setPicker(e,null);for(let t of this.writing.get(e)??[])Ve.delete(t);this.writing.delete(e);for(let t of this.marked.get(e)??[])Ue.delete(t),Ye.delete(t);this.marked.delete(e),this.R.delete(e);for(let[t,n]of _e)n.by===e&&_e.delete(t);this.repaint(),this.changed(!0)}destroy(){for(let e of Ht)window.removeEventListener(e,this.Te,!0);window.clearTimeout(this.timer),qt(null),this.J.clear()}},Wt=new Map,Kt=null,Vt=(()=>{let e=globalThis.Pipeup;return e?.VERSION?e:null})();function Ut(){return Vt?Vt.addons():[...Wt.values()].map(e=>({...e.info}))}function Yt(e){if(Vt)return Vt.use(e);let t=e=>console.warn(`pipeup: ${e}`),n=e;if(!n||"object"!=typeof n||"string"!=typeof n.id||!zt.test(n.id)||Ft.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(Wt.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=>!Dt.includes(e));!function(e){let t=bt("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};Wt.set(n.id,i),Kt?.i&&"waiting"===o.state&&Gt(i,Kt)}function _t(){if(Vt)return!0;let e=globalThis,t=e.pipeupAddons;if(Array.isArray(t))for(let e of t)Yt(e);else if(t&&"object"==typeof t&&t.push!==Yt)return!1;return e.pipeupAddons={push:Yt},!0}async function Gt(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,p=Object.assign(()=>{},{update(){},remove(){},close(){}}),u=e=>(...t)=>c()?e(...t):p,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=>Dt.includes(e),off:e=>{o=String(e)},merge:e=>c()?d.merge(e,f):Promise.resolve(0),addMenuItem:u(e=>s.qe(f,e)),notify:u(e=>s.Ve(f,e)),announce:u(e=>s._e(e)),setComposerNote:u(e=>s.ce(s.ae,f,e)),setThreadNote:u((e,t)=>s.setThread(f,e,t)),setThreadMark:u((e,t,n)=>s.setMark(f,e,t,n)),setCommentMark:u((e,t)=>s.setCommentMark(f,e,t)),addComposerTool:u(e=>s.Fe(f,e)),openPanel:u((e,t)=>s.Je(f,e,t)),addStyles:u(e=>s.je(f,e)),setStatus:u(e=>s.ce(s.X,f,e)),setListNote:u(e=>s.ce(s.listNotes,f,e)),setReactionPicker:u(e=>s.setPicker(f,e)),overlay:()=>s.Ue(f),onFrame:u(e=>s.We(f,e)),where:e=>s.ctx.f.view(e),isHere:e=>s.ctx.f.E(e),go:e=>s.ctx.f.ee(e),onUi:u(e=>s.Ye(f,e)),avatar:(e,t)=>{let n=mt(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:u((e,t)=>s.dialog(f,e,t)),paste:(e,t,n,o)=>c()?d.paste(e,t,n,o):Promise.reject(new Error("pipeup: this add-on is off")),place:e=>{if(!c())throw new Error("pipeup: this add-on is off");return s.place(f,e)},post:e=>c()?s.post(f,e):Promise.reject(new Error("pipeup: this add-on is off"))},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",i.reason=o,void console.warn(`pipeup: the add-on "${f}" is off: ${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 Zt=typeof navigator<"u"&&/Mac|iP(hone|ad|od)/.test(navigator.platform)?"\u21e7\u2325C":"Shift+Alt+C",Jt=" ",Xt="Shift+Alt+C",Qt="Comments stay in this browser until you send them.";var en=new WeakMap;function tn(e,t){let n=en.get(t)??function(e){let t=Je("button",{class:"me",type:"button",tabindex:"-1","aria-hidden":"true"});t.addEventListener("mousedown",e=>e.preventDefault());let n=Je("span",{class:"here",role:"img","aria-label":Qt,title:Qt},dt("browser",14)),o=Rt({label:"Comment",placeholder:"Comment or add others with @",kind:"comment",K:e.K,_:e._,people:e.people,lead:n}),r=Je("div",{class:"note"}),i=()=>{let e=Pt?.note()??null;r.textContent=e??"",r.hidden=!e;let t=!!e||(Pt?.reporting()??!1);n.classList.toggle("off",t),n.setAttribute("aria-hidden",String(t))};i();let a=Je("div",{class:"say"}),l=Je("input",{class:"input",type:"text",maxlength:"80","aria-label":"Your name"}),s=Je("div",{class:"nf"},l),d=Je("div",{class:"you"},a,s),c="",p=!1,u=!1,h=()=>{let n=e.name(),o=n?"change":"add your name";if(t.title=n?"Change your name":"Add your name",!t.lastChild||c!==n){let o=mt(e.me,n),r=t.lastChild;r?(vt(o),gt(r)):o.classList.add("in"),t.append(o),c=n}let r=Je("button",{type:"button"},o);r.addEventListener("click",g),a.replaceChildren(Je("span",{class:"nm"},n||`You're ${m(e.me)}`)," \xb7 ",r)},f=e=>{u=e,d.classList.toggle("naming",e),Xe(a,e),Xe(s,!e)};function g(t){t.stopPropagation(),l.value=e.name(),f(!0),l.focus({preventScroll:!0}),l.select()}let v=(e=!0)=>{f(!1),e&&o.focus()},w=t=>{let n=l.value.trim();if(!n||n===e.name())return v(t);p||(p=!0,e.rename(n).finally(()=>{p=!1,h(),v(t)}))};t.addEventListener("click",g),l.addEventListener("keydown",e=>{e.stopPropagation(),"Escape"!==e.key||e.isComposing?"Enter"===e.key&&(e.preventDefault(),w(!0)):(e.preventDefault(),v())}),l.addEventListener("blur",()=>{u&&!p&&w(!1)}),h(),f(!1);let y=Je("div",{class:"ctx"},e.label),b=Je("div",{class:"draft"},Je("div",{class:"hdr"},t,d),y,r,o.element);return b.addEventListener(Nt,i),{element:b,ue:()=>{let{selectionStart:e,selectionEnd:t}=o.input;return()=>{o.focus(),o.input.setSelectionRange(e,t)}},te:e=>{y.hidden=e},fe:e=>{y.textContent=e},focus:()=>o.focus(),Qe:()=>""===o.input.value.trim(),fill:e=>{o.input.value=e,o.input.dispatchEvent(new Event("input")),o.focus(),o.input.setSelectionRange(e.length,e.length)}}}({label:t.label,me:e.doc.me,name:()=>e.l.name(),rename:t=>e.l.rename(t),K:(t,n)=>e.et(t,n),people:()=>e.people(),_:t=>e.he(t)});return en.set(t,n),e.B(n),n}var nn="a,button,input,select,textarea,label,summary,[role=button],[contenteditable]";function on(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(nn))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 rn(e){return e.range?[...e.range.getClientRects()]:[]}function an(e,t){let n=rn(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 ln(e,t){let n=rn(t).at(-1);if(n)return{x:n.left,y:n.bottom,below:!0,p:n};let o=on(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 sn(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 dn=()=>window.innerWidth>=900?400:300,cn=()=>window.innerWidth<=480,pn=()=>!0===window.matchMedia?.("(pointer: coarse)").matches,un=0;function hn(){let e=window.visualViewport,t=e?Math.max(0,e.offsetTop-un):0;return{top:t,bottom:e?Math.min(window.innerHeight,t+e.height):window.innerHeight}}var fn=(e,t,n,o)=>n.keep&&e+t>n.keep.left?Math.min(n.height-o,n.keep.top-8):n.height-o;function mn(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<=fn(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 p=fn(s,t.width,n,o),u=(n.top??0)+o,h=a+t.height<=p||l<u;return{above:!h,left:s,top:Math.max(u,Math.min(h?a:l,p-t.height))}}function gn(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 vn(e,t){let n=e.resolved.get(t.id);return n?.range?.startContainer??n?.element??null}var wn=e=>(t,n)=>{let o=vn(e,t),r=vn(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},yn=["\u{1f44d}","\u2764\ufe0f","\u{1f602}","\u{1f389}","\u{1f62e}","\u{1f64f}"],bn={"\u{1f44d}":"Thumbs up","\u2764\ufe0f":"Heart","\u{1f602}":"Laughing","\u{1f389}":"Party popper","\u{1f62e}":"Surprised","\u{1f64f}":"Thanks"};var xn=e=>`${e} ${1===e?"reply":"replies"}`,kn=e=>e.root.replies.filter(e=>!e.deleted);function En(e,t,n){let o={...n},r="card"===o.q,i=e.id,a=Je("div",{class:"rbox always"},Je("div",{},Rt({label:"Reply",placeholder:"Reply or add others with @",kind:"reply",thread:()=>i,people:()=>t.people(),K:(e,n)=>t.reply(i,e,n),_:e=>e?t.drop(i,e):t.close()}).element)),l=Je("div",{}),s=Je("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=Je("div",{}),c=null,p=null,u=null,h="",f=Je("div",{},d,r?null:Je("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=new Map,T=new Map,P=(e,t,n)=>{let o=Je("button",{class:"ib",type:"button","aria-label":t,title:t},dt(e,18,"more"===e?2.6:void 0));return o.addEventListener("click",e=>{e.stopPropagation(),n()}),o},q=e=>f.querySelector(e)?.focus({preventScroll:!0});function N(e,n={}){let R=f.getRootNode().activeElement,D=R&&f.contains(R)?R.dataset.k:void 0;(function(e,n){Object.assign(o,n);let R=b;b=y,i=e.id,$=e;let D=(o.now??Date.now)(),z=kn(e),O=z.length,H=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||rt.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 at(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?Je("i",{class:"sl"}):null,Je("span",{},t||""===e.label?n:`[${e.n}] ${n}`),e.says?Je("span",{class:"rc",role:"tooltip"},e.says):null];if(/^https?:/.test(e.to)){let t=Je("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=Je("button",{class:"ref",type:"button",title:e.says?void 0:t?n:`Show where: ${n}`},...o);return r.addEventListener("click",t=>{t.stopPropagation(),Ge.go?.(e.to)}),r});return[...at(n),Je("div",{class:"refs"},...o)]}(t):at(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(Je("span",{class:Ct(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))]},F=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=Je("button",{class:`ref rx${r?" mine":""}${t.seen.has(l)?"":" new"}`,type:"button","aria-pressed":String(r),"aria-label":`${t.picker?.name(o.emoji)??bn[o.emoji]??"Reaction"}, ${i} ${1===i?"person":"people"}${r?", including you":""}`,"data-k":`x${e.id}${o.emoji}`},Je("span",{},o.emoji),Je("span",{class:"n"},String(i)),Je("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?Je("div",{class:"rxq"+(t.seen.has(`${e.id}|quick`)?"":" new"),role:"group","aria-label":"React","data-q":e.id},...yn.map(o=>{let r=Je("button",{class:"rxo",type:"button","aria-label":bn[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=Je("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=Je("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)||p()},p=()=>{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(),p())}),d.off=t.fill(l,e=>{p(),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`),Je("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),N($),q(`[data-r="${n.id}"]`)}}),I=e.resolved?"Resolved"+(O?` \xb7 ${xn(O)}`:""):e.addressed?"Addressed"+(O?` \xb7 ${xn(O)}`:""):O?xn(O):"",B=(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,N($),q(`[data-c="${e.id}"]`)},o=Rt({label:"Save",name:"Edit comment",kind:"comment",value:e.text,people:()=>t.people(),K:async(o,r)=>{await t.edit(e.id,o,r),n()},_:n});E={id:e.id,o:Je("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=Je("div",{class:R===n.id?"pm":"pm in",role:"menu","data-m":n.id},...r.map(([e,t],o)=>{let r=Je("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=""),N($);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="",N($),q(`[data-c="${n.id}"]`)}e.preventDefault(),e.stopPropagation()}),i},j=(n,o)=>{let i=B(n,o),a=i?P("more","More",()=>{y=y===n.id?"":n.id,x="",N($),f.querySelector(y?".pm button":`[data-c="${n.id}"]`)?.focus()}):null;return a&&(a.setAttribute("aria-expanded",String(y===n.id)),a.dataset.c=n.id,a.dataset.k=`m${n.id}`),Je("div",{class:"hdr"},...(e=>{let t=ft(e.author,e.name),n=L.get(e.id),o=n?.o;if((!o||n.key!==t)&&(o=vt(mt(e.author,e.name)),n)){let t=n.o;T.set(e.id,t),gt(t,()=>T.get(e.id)===t&&T.delete(e.id))}o.title=g(e),M.set(e.id,{key:t,o});let r=T.get(e.id);return r?[r,o]:[o]})(n),Je("span",{class:"who"},g(n)),t.pasted?.(n)?Je("span",{class:"ago pst"},t.pasted(n)):null,Je("span",{class:"ago",title:new Date(n.at).toLocaleString()},Re(n.at,D)),r?K(n,!0):null,Je("span",{class:"acts"},(t=>{if(e.resolved||t.deleted)return null;let n=P("smile","React",()=>{let e=!m.delete(t.id);e&&m.add(t.id),N($),q(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?P("reopen","Reopen",()=>{t.reopen(e.id)}):P("resolve","Resolve",()=>{t.resolve(e.id)}):null,a),y===n.id?i:null)},W=e=>E?.id===e.id?E.o:(e=>Je("div",{class:e.deleted?"tx del":"tx",dir:"auto"},...e.deleted?["Deleted"]:[...H(e),e.edited?" (edited)":""]))(e),K=(e,t=!1)=>{let n=_e.get(e.id),o=C.get(e.id),r=n??o;if(!r)return null;n&&A.set(e.id,n);let i="cm"+(n?o?"":" new":" out");return t?Je("span",{class:i,role:"img","aria-label":r.text,title:r.tip??r.text},dt("browser",13)):Je("div",{class:i,title:r.tip},dt("browser",13),r.text)},V=o.quote?`\u201c${tt(o.quote,80)}\u201d`:"",U=o.note&&!o.moved?o.note:o.lost?`${o.place||"No longer on the page"} \u2014 it read \u201c${tt(o.lost,120)}\u201d`:o.moved?`Moved \xb7 ${V||`it read \u201c${tt(e.anchor.snapshot,80)}\u201d`}`:V,Y=r?o.rest:"column"===o.q&&I;M=new Map,A=new Map;let _=Je("div",{class:"root"},j(e.root,!0),U?Je("div",{class:"ctx"},U):null,W(e.root),"column"===o.q&&Je("div",{class:"mr","aria-hidden":"true"},Je("span",{},"more")),r?null:K(e.root),F(e.root),Y?Je("div",{class:"rest"},Y):null);if(d.replaceWith(_),d=_,f.className=e.resolved?"thread resolved":"thread",f.setAttribute("data-thread",e.id),r)return L=M,void(C=A);c?.remove();let G=Ve.get(e.id);c=O||void 0!==G?Je("div",{class:"rps"},...z.map(e=>Je("div",{class:"it"},j(e,!1),W(e),K(e),F(e))),void 0===G?null:Je("div",{class:"it ghost","data-pipeup-writing":"row"},Je("div",{class:"hdr"},mt("",v),Je("span",{class:"who"},v),Je("span",{class:"ago"},"writing now")),Je("div",{class:"tx",dir:"auto","data-pipeup-writing":"words"},G))):null,c&&l.prepend(c);let Z=e.addressed&&!e.resolved?e.addressed:null,J=Z?`${Z.text}|${Z.author}|${Z.at}`:"";if(J!==h&&(u?.remove(),u=null,h=J,Z)){let n=(e,t)=>{let n=Je("button",{type:"button"},e);return n.addEventListener("click",e=>{e.stopPropagation(),t()}),n};u=Je("div",{class:"adr"},Je("small",{},["Addressed",g(Z),t.pasted?.(Z),Re(Z.at,D)].filter(Boolean).join(" \xb7 ")),Z.text,Je("div",{class:"go"},n("Resolve",()=>{t.resolve(e.id)}),n("Still not right",()=>{t.notRight(e.id)})))}u&&l.insertBefore(u,p??(a.parentNode===l?a:null)),p?.remove();let X=Ue.get(e.id),Q=Ye.get(e.id);if(p=void 0===X?null:Je("div",{class:"seen"},Je("i"),X),p&&Q){let e=Je("button",{type:"button"},"Check again");e.addEventListener("click",e=>{e.stopPropagation(),Q()}),p.append(e)}p&&l.insertBefore(p,a.parentNode===l?a:null),L=M,C=A;let ee=""!==a.querySelector("textarea").value.trim();s.hidden=!(e.resolved&&ee),e.resolved&&!ee?a.remove():a.parentNode!==l&&l.append(a)})(e,n),D&&!f.contains(f.getRootNode().activeElement)&&f.querySelector(`[data-k="${CSS.escape(D)}"]`)?.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(),N($))})}),N(e),{element:f,update:N}}function Sn(e,t=!1){let n=e.ownerDocument.documentElement,o=bt("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(xt("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 $n(e,t){if(e.w(t))return!1;let n=e.resolved.get(t.id);return!n||"orphaned"===n.state&&!e.O.has(t.id)}var Ln=(e,t)=>!e.w(t)&&"moved"===e.resolved.get(t.id)?.state;function Mn(e){let t=Je("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=>$n(e,t);function l(t){let n=e.resolved.get(t.id),o=n?an(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.O.has(t)){if(null===o.placed){o.o.classList.add("wait");continue}n=o.placed}Number.isFinite(n)?r.push({id:t,M:n,height:o.o.offsetHeight}):i.push({id:t,height:o.o.offsetHeight})}let a=e.state.t,s=a?an(a.anchor,a.resolved):null;o&&null!==s&&r.push({id:"draft",M:s+window.scrollY-4,height:o.o.offsetHeight});let c=o?"draft":e.state.i,p=r.find(e=>e.id===c),u=t.getBoundingClientRect().right>window.innerWidth-44?44:0;p&&(u||o)&&(p.M=Math.max(window.scrollY+8,Math.min(p.M,window.scrollY+window.innerHeight-u-10-p.height)));let h=function(e,t,n=10){let o=[...e].sort((e,t)=>e.M-t.M),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.M:Math.max(e.M,(r[t-1]??0)+a(t-1).height+n)});else{r[i]=a(i).M;for(let e=i+1;e<o.length;e++)r[e]=Math.max(a(e).M,(r[e-1]??0)+a(e-1).height+n);for(let e=i-1;e>=0;e--)r[e]=Math.min(a(e).M,(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 p(t,n){t.thread=n,t.note=Ze(n),t.lost=a(n),t.moved=Ln(e,n),t.view.update(n,{lost:t.lost?n.anchor.snapshot:null,moved:t.moved})}function u(n){let o=a(n),i=En(n,e.F,{q:"column",lost:o?n.anchor.snapshot:null,moved:Ln(e,n)}),l=Je("div",{class:"th wait","data-thread":n.id},Je("button",{class:"opn sr",type:"button","data-thread":n.id}),i.element);return l.addEventListener("mouseenter",()=>e.L(n.id)),l.addEventListener("mouseleave",()=>e.L(null)),l.addEventListener("click",()=>e.open(n.id)),t.append(l),r.observe(l),{o:l,thread:n,lost:o,moved:Ln(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){Xe(t,e.state.u);let l=new Set,s=null!==e.state.i||null!==e.state.t;for(let t of i){if(!e.j(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!==Ln(e,t)||o.note!==Ze(t))&&p(o,t):(o=u(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=kn(t).length;d.setAttribute("aria-label",`Open thread: ${tt(t.root.text,60)}, ${xn(c)}`),d.setAttribute("aria-expanded",String(i)),Xe(d,i);let h=r.querySelector(".more");h&&Xe(h,!i),r.classList.toggle("dim",s&&!i),r.classList.toggle("hot",e.state.L===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.B(null)),!n)return;let i=!o;if(o)o.p.fe(n.label);else{let i=tn(e,n),a=Je("div",{class:"th on wait"},i.element);t.append(a),r.observe(a),o={o:a,p:i,of:n}}o.p.te(e.state.s&&!n.anchor.quote&&!n.anchor.point),i&&o.p.focus()})(),Qe(t,i.filter(e=>l.has(e.id)).sort(wn(e)).map(e=>n.get(e.id).o),o?.o??null)&&t.offsetWidth,c()},N: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.B(null),t.remove()}}}var Cn=22;function An(e,t){let n=new Map,o=Je("div",{class:"tip",role:"tooltip"}),r=Je("div",{class:"mark"}),i=Je("div",{class:"pop",role:"dialog","aria-label":"Comment thread"});o.inert=i.inert=!0,e.e.append(r,o,i);let a,l=Je("div",{class:"bub pin ghost","aria-hidden":"true"}),s=[],d=null,c=null,p=!1,u=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.ge||e.state.u,k=!1,E=t=>{let n=e.resolved.get(t.id);return n?ln(t.anchor,n):null},S=()=>{let t=function(e){let t=window.innerWidth,n=hn();return{width:e&&!cn()?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&&pn()?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 mn(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=fn(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 Xe(o,!0);if(w!==n.id){let e=kn(n).length;o.replaceChildren(Je("div",{class:"tx clamp",dir:"auto"},...n.root.deleted?["Deleted"]:at(n.root.text)),Je("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.L(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=Je("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=u&&t&&!t.anchor.quote&&!t.anchor.point?t.resolved.element:null;if(n){let{left:e,top:t,above:o}=mn(n.getBoundingClientRect(),{width:i.offsetWidth||dn(),height:i.offsetHeight},S(),12,pn()?60:44),r=null!==u?.above&&u?.above!==o;if(u&&(u.above=o),r&&N())return;return i.style.left=`${e}px`,void(i.style.top=`${t}px`)}let o=u&&t?ln(t.anchor,t.resolved):d?E(d):null;o&&$(i,o,dn())}let q=t=>e.state.s&&!t.anchor.quote&&!t.anchor.point;function N(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 R=e=>Math.min(Math.max(e,20),window.innerWidth-30),D=t=>{if(e.C(t)){let e=t.composedPath()[0];return null!==v&&!(e instanceof Element&&e.closest(".tip,.bub"))&&C(null),void(v=null)}let n=e.ve(t.clientX,t.clientY)?.id??null;n!==v&&(v=n,C(n))},z=t=>{if(e.C(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(nn)))return;let o=e.ve(t.clientX,t.clientY);o&&(e.ye(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.j(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 ${Ce(n.element)}: ${tt(t.root.text,60)}`;o.getAttribute("aria-label")!==r&&o.setAttribute("aria-label",r)}Qe(e.e,o.filter(e=>l.has(e.id)).sort(wn(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&&N(),k=e.state.u;let g=t.ge&&!e.state.u?e.state.t:null;if(g){let t=g.anchor.point??g.resolved.element;u?.of!==g?(window.clearTimeout(f),i.classList.remove("glide"),u={p:tn(e,g),of:g,at:t,above:null},u.p.te(q(g)),i.replaceChildren(u.p.element),i.inert=!1,u.p.focus(),d=null,c=null,P(),i.classList.add("show")):u&&(u.at!==t&&(u.at=t,u.above=null,N(()=>u?.p.fe(g.label))),u.p.te(q(g)));let n=!e.f.E(g.anchor.view);return void(n!==T&&(T=n,i.classList.toggle("show",!n),i.inert=n,n||P()))}u&&(window.clearTimeout(f),i.classList.remove("glide"),u=null,T=!1,e.B(null));let v=x()&&!e.state.u&&e.state.i?b(e.state.i):null;if(!v||!e.j(v))return d=null,c=null,i.classList.remove("show"),void Xe(i,!0);let w={q:"popover",quote:v.anchor.quote?.exact??null,moved:Ln(e,v)};d&&c&&d.id===v.id?(d!==v||a!==Ze(v)||p!==w.moved)&&(c.update(v,w),d=v,a=Ze(v),p=w.moved):(c=En(v,e.F,w),i.replaceChildren(c.element),d=v,a=Ze(v),p=w.moved,P(),i.classList.add("show"),i.inert=!1)},N: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?on(n.anchor,a):null;if(!l||l.y<-40||l.y>window.innerHeight+40){i.style.visibility="hidden";continue}let s=l.x=R(l.x),d=Math.max(s,(o?o.x:window.innerWidth)-30),c=Cn;for(;t.some(e=>Math.abs(e.x-l.x)<Cn&&Math.abs(e.y-l.y)<Cn);)l.x+=c,l.x>d&&(c=-22,l.x=s-Cn),l.x<20&&(c=Cn,l.x=s,l.y+=Cn);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.E(a.anchor.view)?on(a.anchor,a.resolved):null;s?(l.style.left=`${R(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&&nt(r,c.getBoundingClientRect(),4)},destroy(){window.clearTimeout(y),window.clearTimeout(f),window.removeEventListener("pointermove",D,!0),window.removeEventListener("click",z,!0),e.B(null);for(let e of n.values())e.remove();l.remove(),o.remove(),r.remove(),i.remove()}}}var Tn={display:"block",position:"static",clips:!1,off:!1},Pn="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}]`),qn="[data-pipeup-ignore],pipeup-place,.reveal>:is(.controls,.progress,.slide-number)",Nn=["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",...Pn].join(","),Rn="a,button,label,summary,[role=button],[role=link],[role=tab],[role=option],[role=menuitem]",Dn=`${Rn},input,select,textarea,img,svg,canvas,video,picture,[role=img]`,zn=(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 On(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.ne();return n.width*n.height<=.6*o.width*o.height&&(e.matches(Nn)||t.tt(e)||e.childElementCount>1&&!e.parentElement?.closest(Rn)&&t.nt(e))}function Hn(e,t,n){if(e===t||!t.contains(e)||e.closest(qn))return null;let o=null;for(let r=e;r&&r!==t&&!o;r=r.parentElement)On(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&&zn(n.p(e),r);e=e.parentElement)if(e.hasAttribute("data-pipeup-id"))return e;return o}function Fn(e,t,n){let o=n.p(e);for(let r=e.parentElement;r&&r!==t;){let e=Hn(r,t,n);if(!e)return null;if(!zn(n.p(e),o))return e;r=e.parentElement}return null}var In=(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,Bn=(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 jn(e,t,n=()=>!0){let o=[],r=(e,i,a,l,s,d)=>{for(let c of e.children){if(c.matches(qn)||"true"===c.getAttribute("aria-hidden")||!n(c))continue;let e=t.flow?.(c)??Tn,p=c.offsetParent,u="fixed"===e.position||"absolute"===e.position&&!!l&&!(p&&l.contains(p)),h=u?null:a,f=t.p(c),m=f.width>0&&f.height>0;if(h&&m&&!In(f,h))continue;let g=c.matches(Rn),v=(e.display.startsWith("inline")||d)&&!c.matches(Dn)&&("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))&&On(c,t)&&(i&&zn(t.p(i.o),f)?(c.hasAttribute("data-pipeup-id")||!i.o.hasAttribute("data-pipeup-id"))&&(i.o=c):o.push(y={o:c,V:i,$:0}));let b=e.clips&&m;r(c,y,b?h?Bn(h,f):f:h,b?c:u?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.V&&(t.V.$=Math.max(t.V.$,t.$+1))}return o}var Wn=(e,t)=>e.filter(e=>e.$<=t&&(!e.V||e.V.$>t)),Kn="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]",Vn=`${Kn},input,select,textarea,[contenteditable]:not([contenteditable=false]),[tabindex]:not([tabindex="-1"])`,Un=["click","dblclick","auxclick","submit","contextmenu","dragstart"],Yn=[...["over","out","enter","leave","down","up"].flatMap(e=>[`pointer${e}`,`mouse${e}`]),"mousemove","touchstart","touchmove","touchend","touchcancel"],_n=["pointerup","pointercancel"],Gn="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=`${qn},input,textarea,select,[contenteditable]:not([contenteditable=false])`;function Jn(e){let t=Je("button",{type:"button","aria-label":"Comment",title:"Comment"},dt("comment",17)),n=Je("div",{class:"selbar"},t);n.inert=!0,e.e.append(n);let o=null,r=0,i=!1,a=()=>e.state.s||"comment-mode"!==bt("data-pipeup-select"),l=t=>{let n=t&&(t.nodeType===Node.ELEMENT_NODE?t:t.parentElement);return!!n&&e.root.contains(n)&&!n.closest(Zn)};function s(){if(!o)return;let t=o.cloneRange();t.selectNodeContents(fe(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?gn(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},pn());n.style.left=`${i}px`,n.style.top=`${a}px`}function d(){o=null,n.inert=!0,n.classList.remove("show")}function c(t=!1){let r=et();a()&&r&&l(r.anchorNode)&&l(r.focusNode)?(!o&&!t&&e.state.s&&e.T("Enter comments on the selected words"),o=r.getRangeAt(0).cloneRange(),s(),n.inert=!1,n.classList.add("show")):d()}t.addEventListener("mousedown",e=>e.preventDefault()),t.addEventListener("click",t=>{if(t.stopPropagation(),e.state.t&&!e.S())return e.re();let n,r=o;if(!r)return;try{n=me(r,e.root,e.f.view(r.commonAncestorContainer))}catch(t){return e.oe(t),void d()}let i=tt(r.toString().replace(/\s+/g," ").trim(),60);window.getSelection()?.removeAllRanges(),d(),e.lt({anchor:n,label:`\u201c${i}\u201d`,ranges:[r],resolved:{state:"attached",element:null,range:r}})});let p=()=>{window.clearTimeout(r),r=window.setTimeout(()=>i||c(),250),o&&(et()||d())};document.addEventListener("selectionchange",p);let u=t=>{"keyup"!==t.type&&(i="mousedown"===t.type),!i&&!e.C(t)&&window.setTimeout(()=>c("mouseup"===t.type),0)};window.addEventListener("mousedown",u,!0),window.addEventListener("mouseup",u,!0),window.addEventListener("keyup",u,!0);let h=n=>{"Enter"!==n.key||!o||!e.state.s||e.C(n)||n.target instanceof Element&&n.target.closest(`${Zn},${Kn}`)||(n.preventDefault(),n.stopPropagation(),t.click())};return window.addEventListener("keydown",h,!0),{m(){o&&!a()&&d()},N(){o&&s()},destroy(){window.removeEventListener("mousedown",u,!0),window.removeEventListener("mouseup",u,!0),window.removeEventListener("keyup",u,!0),window.removeEventListener("keydown",h,!0),window.clearTimeout(r),document.removeEventListener("selectionchange",p),n.remove()}}}async function Xn(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 Qn="Hidden on the page",eo=["auto","light","dark"];function to(e){let t=[Je("span",{class:"n"}),Je("span",{class:"n"})],n=dt("comment",22,1.4);n.lastElementChild.setAttribute("stroke-width","1.6");let o=Je("span",{class:"cnt"},dt("bubble",28,1.4),dt("wide",28,1.4),...t),r=Je("button",{class:"mode",type:"button","aria-label":"Comment","aria-keyshortcuts":Xt,"aria-pressed":"false"},Je("span",{class:"plus"},n),o,Je("span",{class:"dot"})),i=document.createTextNode(""),a=Je("span",{class:"ttip","aria-hidden":"true"},Je("span",{},i,Je("small",{},Zt))),l=Je("button",{class:"mm",type:"button","aria-label":"More","aria-haspopup":"menu","aria-expanded":"false"},dt("more",15,3)),s=Je("div",{class:"launch"},r,a,l),d="off"===bt("data-pipeup-control");d&&s.classList.add("off");let c=null,p=()=>{if(!d)return r.focus({preventScroll:!0});c?.focus({preventScroll:!0}),c=null},u=Je("div",{class:"menu",role:"menu","aria-label":"Comments"}),h=Je("div",{class:"list",role:"list","aria-label":"Comments"}),f=Je("button",{class:"ib",type:"button","aria-label":"Close"},dt("close")),v=(e,t,n,o)=>{let r=Je("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},w=v("For you","Only comments that mention you",dt("at",16,1.8),()=>e.l.toggleMine()),y=v("Resolved","Show resolved comments too",dt("resolve",22,1.7),()=>e.l.dt()),b=Je("div",{class:"lns"}),x=new Map,k=Je("span",{class:"ma"}),E=Je("span",{class:"lb"}),S=Je("button",{class:"fs",type:"button",role:"switch","aria-checked":"false","aria-keyshortcuts":Xt},"Comment",Je("small",{class:"ks","aria-hidden":"true"},Zt),Je("span",{class:"sw","aria-hidden":"true"}));S.addEventListener("click",t=>{t.stopPropagation(),e.ie(!e.state.s,!e.state.s&&0===t.detail)});let $=Je("button",{class:"ib",type:"button","aria-label":"More","aria-haspopup":"menu","aria-expanded":"false"},dt("more",15,3)),L="",M=Je("div",{class:"all",role:"dialog","aria-label":"All comments"},Je("div",{class:"hh",role:"heading","aria-level":"2"},"All comments"),Je("div",{class:"hd"},w,y,Je("span",{class:"sp"}),f),b,h,Je("div",{class:"pf"},k,E,S,$)),C=document.createElementNS("http://www.w3.org/2000/svg","svg");C.setAttribute("class","cx"),C.setAttribute("aria-hidden","true");let A=document.createElementNS("http://www.w3.org/2000/svg","path"),T=document.createElementNS("http://www.w3.org/2000/svg","circle");T.setAttribute("r","4"),C.append(A,T),u.inert=M.inert=!0,e.e.append(u,s,C,M);let P=!1,q=null,N=0,R=[],D=0,z=null,O=null,H=null,F=!0===window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,I=()=>{},B=t=>{P=e.state.l=t,e.taps(),t&&e.addons.flush(),window.clearTimeout(N),N=0,t||q?.(!0),t?u.classList.toggle("inp",e.state.u):I(),u.classList.toggle("show",t),Xe(u,!t),l.setAttribute("aria-expanded",String(t)),$.setAttribute("aria-expanded",String(t))},j=(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&&R.some(e=>e.id===o)?ye(o,!0):t&&e.state.t?e.focusDraft():t?(W(h)[0]??f).focus({preventScroll:!0}):n&&p()},W=(e=u)=>[...e.querySelectorAll(".mi")].filter(e=>e.offsetParent&&!e.closest("[inert]")),K=()=>u.getRootNode().activeElement,V=()=>{B(!1),p()},U=e=>{let t=W(e.currentTarget);if(0===t.length)return;let n=K(),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)};u.addEventListener("keydown",U),h.addEventListener("keydown",U),f.addEventListener("click",e=>{e.stopPropagation(),j(!1,!0)});let Y=t=>$n(e,t),_=t=>Ln(e,t),G=t=>R.filter(n=>!(n.resolved||void 0!==t&&(e.G(n)!==t||t&&e.w(n)))).length,Z=t=>{if(e.w(t)){let e=t.anchor.view?.[Te];return e?`In the ${e} edition`:"From before editions"}let n=t.anchor.view?.slide,o=e.f.E(t.anchor.view)?"":Pe(t.anchor.view);return n&&null!==e.f.slide()?`On slide ${n}`:o?`In ${o}`:Qn},J=(e,t,n=!1)=>{let o=new Set(t),r=new Set(e.childNodes),i=new Map,a=new Set(t.map(X));for(let e of r){if(o.has(e))continue;let t=X(e);t&&a.has(t)&&i.set(t,e.offsetHeight),n&&ee&&e instanceof HTMLElement&&!i.has(t)?te(e):e.remove()}let l=e.firstChild;for(let n of t){for(;l&&l!==n&&Q.has(l);)l=l.nextSibling;l===n?l=n.nextSibling:e.insertBefore(n,l)}if(n&&ee)for(let e of t)e instanceof HTMLElement&&(r.has(e)?Q.delete(e)&&ne(e,e.offsetHeight):ne(e,i.get(X(e))??0))},X=e=>e instanceof HTMLElement?e.firstElementChild?.dataset.thread:void 0,Q=new WeakSet,ee=!1,te=e=>{if(!Q.has(e)){if(e.classList.contains("out"))return e.remove();Q.add(e),e.style.height=`${e.offsetHeight}px`,e.offsetHeight,e.classList.add("out"),F||(e.style.height="0"),setTimeout(()=>Q.delete(e)&&e.remove(),340)}},ne=(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";(F||!t)&&e.classList.add("out"),F||(n.overflow="hidden",n[r]=`${t}px`),e.offsetHeight,n.transition="",e.classList.remove("out"),!F&&(n[r]=`${o>t?o+40:o}px`,setTimeout(()=>n[r]=n.overflow="",360))},oe=new Map,re=(e,t,n="",o=e)=>{let[r,i,a]=oe.get(o)??[];return(!r||!i||!a)&&oe.set(o,[r=Je("div",{role:"listitem"}),i=Je("div",{class:"sec","aria-hidden":"true"}),a=Je("div",{role:"list"})]),a.setAttribute("aria-label",n?`${e} \xb7 ${n}`:e),i.replaceChildren(e,n&&Je("b",{},n)),J(r,[i,a]),J(a,t,!0),r},ie=Je("div",{class:"sec",role:"listitem"}),ae=!1,le=Je("button",{class:"sec fold",type:"button"});le.addEventListener("click",e=>{e.stopPropagation(),ae=!ae,ge()});let se=Je("div",{role:"listitem"}),de=Je("div",{role:"list","aria-label":"Earlier editions"}),ce=(e,t,n)=>(le.setAttribute("aria-expanded",String(n)),le.replaceChildren(`Earlier editions \xb7 ${t} open`,dt("chev",12)),J(se,n?[le,de]:[le]),J(de,n?e:[],!0),se);function pe(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.G(t)?e.f.E(t.anchor.view)?"":Pe(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])=>re(e||Qn,t.flatMap(n)))]}return[...r].sort(([e],[t])=>Number(e)-Number(t)||0).map(([e,t])=>re(`Slide ${e} \xb7 ${t.filter(e=>!e.thread.resolved).length} open`,t.flatMap(n),e===o?"This slide":"",`slide:${e}`))}let ue=null,he=new Map,fe=new Set,me={...e.F,get me(){return e.F.me},resolve:async t=>{let n=he.get(t)?.card;n&&!e.state.I&&!F&&(fe.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.F.resolve(t),fe.delete(t),n?.style.removeProperty("height"),e.m()}};function ge(){let t=K(),n=t?.dataset.thread,o=null!==O&&O.element.contains(t),r=[...he.values()].find(e=>e.view.element.contains(t)),i=()=>[...r.view.element.querySelectorAll("button,textarea")],a=r?i().indexOf(t):-1,l=r?W(h).indexOf(r.card.firstChild):-1,s=e.l.all(),d=s.filter(t=>!t.thread.resolved||e.state.I||t.thread.id===z).filter(t=>!e.state.mine||((e,t)=>[e.root,...e.root.replies].some(e=>e.author!==t&&!e.deleted&&Ct(e,Tt(t))))(t.thread,e.doc.me));y.setAttribute("aria-pressed",String(e.state.I)),w.setAttribute("aria-pressed",String(e.state.mine));let c=e.l.name();if(E.textContent=c||m(e.doc.me),ft(e.doc.me,c)!==L){L=ft(e.doc.me,c);let t=mt(e.doc.me,c);t.classList.add("in"),k.replaceChildren(t)}S.setAttribute("aria-checked",String(e.state.s));let p=e.state.t;H&&H.of!==p&&(H=null,p||e.B(null));let u=p&&!H;if(p&&!H){z=O=null;let t=tn(e,p);H={of:p,p:t,card:Je("div",{class:"cd open new",role:"listitem"},t.element)}}H&&(H.p.fe(p.label),H.p.te(!1)),ue&&ue.id!==z&&(ue=null);let f=p&&(p.resolved.range?.startContainer??p.resolved.element),v=f?d.find(t=>{let n=vn(e,t.thread);return n&&4&f.compareDocumentPosition(n)})?.thread.id??null:null,b=t=>{let n,o=t.thread,r=o.id===z,i=kn(o).length,a=[i?xn(i):"",...o.root.reactions.map(e=>`${e.emoji} ${e.by.length}`)].filter(Boolean).join(" \xb7 "),l=e.w(o)?`${Z(o)} \xb7 \u201c${tt(o.anchor.snapshot,80)}\u201d`:Y(o)?`\u201c${tt(o.anchor.snapshot,80)}\u201d`:o.anchor.quote?`\u201c${tt(o.anchor.quote.exact,80)}\u201d`:t.location.where,s=Je("button",{class:"mi",type:"button","aria-expanded":String(r),"data-thread":o.id},Je("span",{class:"sr"},[g(o.root),Re(o.root.at,Date.now()),_(o)&&"Moved",l,o.root.text,a].filter(Boolean).join(", ")));if(s.addEventListener("click",e=>{e.stopPropagation(),ye(o.id)}),r&&O){if(O.update(o,ve(o,l)),!ue){let e=Je("div",{class:"xr",role:"region","aria-label":"Comment thread"},O.element);e.addEventListener("click",e=>{let t=e.target;t.closest(".root>.hdr")&&!t.closest("button")&&be(!0)}),ue={id:o.id,card:Je("div",{role:"listitem"}),xr:e}}n=ue.card,n.className="cd open"+(o.resolved?" done":""),J(n,[s,ue.xr])}else{let e={q:"card",note:l,rest:a,quote:o.anchor.quote?.exact,moved:_(o)},t=he.get(o.id);t?t.view.update(o,e):he.set(o.id,t={card:Je("div",{role:"listitem"}),view:En(o,me,e)}),n=t.card,n.className=`cd${o.resolved?" done":""}${fe.has(o.id)?" out":""}`,J(n,[s,t.view.element])}return H&&o.id===v?[H.card,n]:[n]},x=d.filter(e=>Y(e.thread)),$=d.filter(t=>e.w(t.thread)),M=d.filter(t=>!e.w(t.thread)),C=ae||$.some(e=>e.thread.id===z);ie.textContent=e.state.mine?"No comments mention you":$.length?"No open comments on this edition":"No open comments",J(h,[...M.length||H?[]:[ie],...pe(M.filter(e=>!Y(e.thread)),b),...H&&null===v?[H.card]:[],...x.length?[re("No longer on the page",x.flatMap(b))]:[],...$.length?[ce(C?$.flatMap(b):[],s.filter(t=>e.w(t.thread)&&!t.thread.resolved).length,C)]:[]],!0),ee=!0;for(let e of he.keys())d.some(t=>t.thread.id===e)||he.delete(e);let A=K();u?H.p.focus():H?.card.contains(t)&&!H.card.contains(A)?H.p.ue()():o&&!O.element.contains(A)?O.element.querySelector("textarea")?.focus({preventScroll:!0}):r&&A!==t?(r.card.isConnected?i()[a]:W(h)[Math.min(l,W(h).length-1)])?.focus({preventScroll:!0}):n&&A!==t&&W(h).find(e=>e.dataset.thread===n)?.focus({preventScroll:!0})}function ve(t,n){let o=!Y(t)&&e.G(t);return{q:"popover",quote:t.anchor.quote?.exact??null,lost:Y(t)||o?t.anchor.snapshot:null,place:o?Z(t):null,moved:_(t),note:!cn()||Y(t)||o||t.anchor.quote?null:n}}let we="";function ye(t,n=!1){if(z===t)return be(!0);let o=R.find(e=>e.id===t);if(o){if(e.keepReplies(),z=we=t,O=En(o,{...e.F,close:()=>be(!0)},ve(o)),e.seen(o),ge(),e.putReply(t),pn()||O.element.querySelector("textarea")?.focus({preventScroll:!0}),n&&h.querySelector(".mi.open")?.scrollIntoView({block:"nearest"}),!e.G(o))return xe(o,!n);e.state.t&&!e.S()||e.f.ee(o.anchor.view??{}).then(()=>{e.Ne();let n=R.find(e=>e.id===t);n&&we===t&&z===t&&xe(n)})}}function be(t=!1){if(!z)return;let n=z;e.keepReplies(),z=O=null,e.L(null),ge(),t&&W(h).find(e=>e.dataset.thread===n)?.focus({preventScroll:!0})}function xe(t,n=!0){let o=e.resolved.get(t.id),r=o&&!Y(t)?o.element??o.range?.startContainer.parentElement??null:null;n&&r?.scrollIntoView({block:"center",inline:"nearest",behavior:F?"auto":"smooth"}),r&&e.L(t.id)}function ke(t,n){let o=n?n.resolved:e.resolved.get(t.id),r=o?.element??o?.range?.startContainer.parentElement;if(!o||cn()||t&&(Y(t)||e.G(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?rn(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=ln(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 Ee(e,t,n=!1,...o){let r=Je("button",{class:"mi",type:"button",role:n?"menuitemcheckbox":"menuitem"},e,Je("span",{class:"lb"}),...o,n&&Je("span",{class:"sw","aria-hidden":"true"}),Je("span",{class:"tt","aria-hidden":"true"}));return r.addEventListener("click",e=>{e.stopPropagation(),t(e)}),r}let Se=(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))},$e=()=>Je("div",{class:"sep",role:"separator"}),Le=Je("span",{class:"ma"}),Me=Je("span",{class:"kc"}),Ce="",Ae=Ee(Le,function(){let t=Je("input",{class:"input",type:"text",maxlength:"80","aria-label":"Your name"});t.value=e.l.name();let n=Je("div",{class:"ed"},Le.cloneNode(!0),t),o=(r,i=!1)=>{if(q!==o)return;q=null;let a=t.value.trim();r&&a&&a!==e.l.name()&&e.l.rename(a).then(et),n.replaceWith(Ae),i&&Ae.focus({preventScroll:!0})};q=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)),Ae.replaceWith(n),t.focus({preventScroll:!0})},!1,Me);Ae.dataset.item="name";let qe=Ee(dt("copy"),()=>{V(),e.l.copyAll("ai")}),Ne=Ee(dt("lines"),()=>{V(),e.l.copyAll("text")}),De=Je("div",{class:"subs",role:"group"},Je("div",{},qe,Ne)),ze=Ee(dt("copy"),()=>Oe("true"!==ze.getAttribute("aria-expanded")),!1,Je("span",{class:"chev"},dt("chev",13))),Oe=(e,t=!0)=>{ze.setAttribute("aria-expanded",String(e)),De.classList.toggle("open",e),Xe(De,!e),t&&(e?qe:ze).focus({preventScroll:!0})};I=()=>Oe(!1,!1),I(),ze.addEventListener("keydown",e=>{"ArrowRight"===e.key&&"true"!==ze.getAttribute("aria-expanded")&&(e.preventDefault(),Oe(!0))}),De.addEventListener("keydown",e=>{"ArrowLeft"===e.key&&(e.preventDefault(),Oe(!1))});let He=Je("span",{class:"kc"}),Fe=Ee(dt("look"),()=>{e.l.setLook(eo[(eo.indexOf(e.l.look())+1)%3]),et()},!1,He),Ie=Je("span",{class:"kc"}),Be=Ee(dt("list"),()=>{B(!1),Be.dataset.item="all",j(!0)},!1,Ie),je=Ee(dt("hide"),()=>{e.l.setHide(!e.state.hide),et()},!0),We=Ee(dt("comment"),t=>{let n=!e.state.s&&0===t.detail;e.ie(!e.state.s,n),n?B(!1):e.state.s&&pn()&&(window.clearTimeout(N),N=window.setTimeout(()=>P&&V(),600))},!0,Je("span",{class:"kc ks","aria-hidden":"true"},Zt));We.dataset.item="comment",We.setAttribute("aria-keyshortcuts",Xt);let Ke=Je("div",{class:"sec",role:"presentation"}),Ve="Only in this browser until you send them.",Ue=$e(),Ye=$e(),_e=new Map,Ge=t=>{let n=_e.get(t);return n||(n=Ee(ct(t.icon,15),()=>{t.checked||V(),Promise.resolve().then(()=>t.select()).catch(t=>e.oe(t)).finally(()=>P&&et())},!!t.checked,Je("span",{class:"kc"})),_e.set(t,n)),n},Ze=-1,Qe=e=>{try{return e()}catch(e){return globalThis.reportError?.(e),""}};function et(){let t=G(),n=e.l.name(),o=n||m(e.doc.me);if(Se(Ae,o,n?"The name on your comments":"Add a name to show on your comments"),Ae.setAttribute("aria-label",`${o}, ${n?"edit":"add"} your name`),Me.replaceChildren(n?dt("edit",13):"Add name"),ft(e.doc.me,n)!==Ce){Ce=ft(e.doc.me,n);let t=mt(e.doc.me,n);t.classList.add("in"),Le.replaceChildren(t)}Se(ze,"Copy comments","As Markdown, with where each thread is, or as text"),Se(qe,"As Markdown","With where each thread is, ready for an AI or a document"),Se(Ne,"As text","Just the words");let r=["Automatic","Light","Dark"][eo.indexOf(e.l.look())];Se(Fe,"Theme","Automatic follows the page; press to change"),He.textContent=r,Se(Be,"All comments","Every thread, and where it is"),Ie.textContent=t?String(t):"",Ke.textContent=e.addons.Me()||Ve,!Ke.isConnected&&u.contains(Ae)&&u.prepend(Ke);for(let t of e.addons.z){let e,n=_e.get(t);if(n){try{e=t.checked?.()}catch(e){globalThis.reportError?.(e)}Se(n,Qe(t.label),Qe(t.hint),e),n.querySelector(".kc").textContent=t.count?Qe(t.count):""}}Se(je,"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),Se(We,"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 nt(){et(),(Ze!==e.addons.se||!u.contains(Ae))&&(u.replaceChildren(Ae,Ue,ze,De,Fe,Be,...e.addons.z.map(Ge),Ye,je,We),Ze=e.addons.se,et())}$.addEventListener("click",e=>{if(e.stopPropagation(),P)return B(!1);nt(),B(!0),0===e.detail&&W()[0]?.focus({preventScroll:!0})});let ot=e=>{nt(),B(!0),e&&W().at(-1)?.focus({preventScroll:!0})},rt=()=>{let e=document.activeElement;return e instanceof HTMLElement&&e!==document.body?e:null};e.pageControls={l:()=>{P||(c=rt(),ot(!0))},list:()=>{e.state.u||(c=rt(),P&&B(!1),j(!0))}};let it=!1,at=0;r.addEventListener("pointerdown",e=>{it=!1,window.clearTimeout(at),"mouse"!==e.pointerType&&(at=window.setTimeout(()=>{it=!0,ot(!1)},500))});for(let e of["pointerup","pointercancel","pointerleave"])r.addEventListener(e,()=>window.clearTimeout(at));r.addEventListener("contextmenu",e=>{(it||pn())&&e.preventDefault()}),r.addEventListener("click",t=>{if(t.stopPropagation(),it)return void(it=!1);if(P)return void B(!1);let n=!e.state.s;e.ie(n,n&&0===t.detail)}),l.addEventListener("click",e=>{if(e.stopPropagation(),P)return V();ot(0===e.detail)}),r.addEventListener("keydown",e=>{P||!("ArrowUp"===e.key||"ContextMenu"===e.key||"F10"===e.key&&e.shiftKey)||(e.preventDefault(),e.stopPropagation(),ot(!0))});for(let e of[r,l,$])e.addEventListener("keydown",e=>{let t=W();!P||!t.length||"ArrowDown"!==e.key&&"ArrowUp"!==e.key||(e.preventDefault(),e.stopPropagation(),("ArrowDown"===e.key?t[0]:t.at(-1))?.focus({preventScroll:!0}))});let lt=t=>{let n=t.composedPath();P&&!n.includes(u)&&!n.includes(r)&&!n.includes(l)&&!n.includes($)&&(B(!1),e.state.s&&!e.C(t)&&(e.ye(t),t.preventDefault(),t.stopPropagation()))},st=e=>{if(!P||"touch"===e.pointerType||"pointerout"===e.type&&e.relatedTarget)return;let t=e.composedPath();"pointerover"===e.type&&(t.includes(u)||t.includes(r)||t.includes(l)||t.includes($))?(window.clearTimeout(N),N=0):N||(N=window.setTimeout(()=>{N=0,q||B(!1)},3e3))},pt={n:0,label:""},ut=()=>{let{n:t,label:n}=pt,o=e.addons.Me(),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-pressed",String(e.state.s));let l=n||(t>9?`${t} open`:""),s=[l,o].filter(Boolean).join(" \xb7 ")+(l||o?" \xb7 ":"");i.data!==s&&(i.data=s)},ht=e.addons.subscribe(t=>{ut(),(()=>{for(let[t,n]of x)e.addons.listNotes.has(t)||(x.delete(t),n.row.classList.remove("show"),setTimeout(()=>n.row.remove(),320));for(let[t,n]of e.addons.listNotes){let o=x.get(t);if(!o){let e=Je("span",{}),r=Je("div",{class:"ln"},Je("div",{class:"lw"},Je("div",{class:"ag"},e)));r.dataset.addon=t,o={row:r,words:e,btn:null,note:n},x.set(t,o),b.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=Je("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.oe(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)}})(),P&&!q&&(t?nt():et())});window.addEventListener("click",lt,!0),window.addEventListener("pointerover",st,!0),window.addEventListener("pointerout",st,!0);let gt=t=>{if("Escape"!==t.key||t.isComposing||q||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(P&&De.contains(n))Oe(!1);else if(P)V();else if(o&&n!==o.firstChild){if(n instanceof HTMLTextAreaElement)return;o.firstChild.focus({preventScroll:!0})}else{if(!e.state.u||n instanceof HTMLTextAreaElement&&!M.contains(n))return;e.state.t?e.Y():z?be(!0):j(!1,!0)}t.preventDefault(),t.stopPropagation()};return window.addEventListener("keydown",gt,!0),e.registerList(e=>{z!==e&&ye(e,!0)}),{m(n){R=n;let i=G(!1);if(i!==D){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),D=i}let a=G(!0),l=a?`${i} here \xb7 ${a} ${null!==e.f.slide()?"on other slides":"in other views"}`:"";r.classList.toggle("else",a>0),pt={n:i,label:l},ut(),r.classList.toggle("on",e.state.s),P&&!e.state.l&&B(!1),P&&et();let d=e.state.u;M.classList.toggle("full",cn()),M.classList.contains("show")!==d&&(M.classList.toggle("show",d),Xe(M,!d),Xe(s,d)),z&&(!d||!n.some(e=>e.id===z))&&(z=O=null,e.state.L=null),d?ge():ee=!1},N:function(){let t=z?R.find(e=>e.id===z):null,n=H?.card??(z?h.querySelector(".cd.open"):null),o=H?ke(null,H.of):t&&ke(t),r=n?.getBoundingClientRect(),i=h.getBoundingClientRect();if(!e.state.u||!o||!r?.width||r.top+12<i.top||r.top+12>i.bottom)return void C.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}`}A.setAttribute("d",a),T.setAttribute("r",o.bubble?"0":"4"),T.setAttribute("cx",String(o.x)),T.setAttribute("cy",String(o.y)),C.classList.add("show")},destroy(){ht(),window.removeEventListener("click",lt,!0),window.removeEventListener("pointerover",st,!0),window.removeEventListener("pointerout",st,!0),window.clearTimeout(N),window.clearTimeout(at),window.removeEventListener("keydown",gt,!0),e.registerList(null),e.pageControls=null,u.remove(),M.remove(),C.remove(),s.remove()}}}var no="[data-pipeup-slide]",oo=["scroll","resize","keyup","click","transitionend","slidechanged"],ro=null,io=null,ao=new Set,lo=new Set,so=e=>{try{e()}catch(e){globalThis.reportError?.(e)}};function co(e){io="function"==typeof e?.current&&"function"==typeof e.go?e:null}function po(){let e=bt("data-pipeup-edition")?.trim()??"";return e&&e.length<=S?e:null}var uo=(e,t)=>null!==t&&(e?.[Te]??"")!==t,ho=()=>{let e=window.Reveal;return"function"==typeof e?.getIndices&&"function"==typeof e.slide?e:null};var fo,mo="#534AB7";function go(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(fo??=t.createElement("canvas").getContext("2d",{willReadFrequently:!0})??null,!fo)return null;fo.clearRect(0,0,1,1),fo.fillStyle="#000",fo.fillStyle=e,fo.fillRect(0,0,1,1);let[n,o,r,i]=fo.getImageData(0,0,1,1).data;return{r:n,g:o,b:r,a:i/255}}catch{return null}}function vo(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 wo=[[.92,.25],[.92,.6],[.5,.45]];function yo(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?go(t.getComputedStyle(n).backgroundColor,e):null;return t&&e.body&&(!i||i.a<.5)&&(i=go(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 bo(e,t){let n=e.ownerDocument,o=n.defaultView,r="dark"===t;if(!o)return{font:"system-ui, sans-serif",accent:mo,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,p=c?go(c,n):null,[u,h,f]=r?[27,27,25]:[255,255,255],m=p&&((e,t)=>(Math.max(e,t)+.05)/(Math.min(e,t)+.05))(vo(p),vo({r:.12*p.r+.88*u,g:.12*p.g+.88*h,b:.12*p.b+.88*f}))>=4.5?c:r?"#9A94EE":mo,g=go(m,n);return{font:a,accent:m,dark:r,on:g&&vo(g)>.19?"#111":"#fff"}}function xo(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 ko=["pipeup-quote","pipeup-on","pipeup-done"],Eo={"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 So(){return typeof CSS<"u"&&"highlights"in CSS&&typeof Highlight<"u"}var $o=`:not(${qn},:is(${qn}) *){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(So())for(let e of ko)for(let t of["","-d"])CSS.highlights.delete(e+t)}var Mo={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 Ao(e,t,n){let[o,r]=Mo[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 vo({r:o,g:r,b:i})});return((e,t)=>(Math.max(e,t)+.05)/(Math.min(e,t)+.05))(o,r)}var To=["ArrowUp","ArrowDown","Home","End","PageUp","PageDown"];function Po(e,t=!1){return Sn(e,t)?"column":"bubbles"}var qo="Shown here, but not saved yet \u2014 it will be saved with your next change",No=e=>e instanceof Error?e.message.replace(/^pipeup: /,""):"Something went wrong";function Ro(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===document?bt("data-pipeup-theme"):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=vo(yo(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 wo){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=go(n.getComputedStyle(r).backgroundColor,e);if(o&&o.a>=.5){l=vo(o);break}}a+=l}let l=a/wo.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}=yo(e);return{look:t,source:n,ratio:Ao(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",`${dn()}px`),xo(a,e),r.append(a),n.documentElement.append(o),{element:o,shadow:r,e:a,destroy:()=>o.remove()}}(bo(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{Ie(){},He(){},xe(){},De(){},remove:()=>Lo()};let n=new t,o=null,r=!1,i=1,a=0,l="",s=0,d=()=>n.replaceSync((e=>ko.map(t=>Eo[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?$o:"")+(a||l?`html{--pipeup-panel:${a}px;width:auto!important;${a?`margin-right:${a}px!important;`:""}${l}}`:""));return d(),e.adoptedStyleSheets=[...e.adoptedStyleSheets,n],{Ie(e){e!==o&&(o=e,d())},He(e){e!==r&&(r=e,d())},xe(e){i=e,d()},De(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.xe(0);let c=!0===window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,p=xt("data-pipeup-reserve"),u=new Map,h=new Set,f=new WeakSet,v=`pipeup:hide:${e.doc.id}`,y=!1;try{y="1"===localStorage.getItem(v)}catch{}let x={i:null,L:null,I:!1,mine:!1,hide:y,hidden:y,mode:Po(e.root),t:null,s:!1,paused:!1,u:!1,Be:!1,l:!1,pinning:!1},k=Je("div",{class:"toast",role:"status","aria-live":"polite"}),E=null,$=Je("div",{class:"sr","aria-live":"polite"});s.e.append(k,$);let L=null,M=null,C=[],A=null,T=!1,P=0,q=0,N=0,R=0,D=0,z=new Set,O="",H=new Map,F=null,I=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,ne:()=>({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(no)],c=()=>[...e.querySelectorAll(".slides > section")],p=e=>"string"==typeof e&&e.length>0&&e.length<=S?e:null,u=e=>p(e?.getAttribute("data-pipeup-slide")),h=e=>{let t=c()[e];return u(t?.matches(no)?t:t?.querySelector(no))??p(String(e+1))};function f(){if(a=[],io){let e=null;if(so(()=>{let t=io.current();Number.isInteger(t)&&t>0&&(e=String(t))}),null!==e)return e}let e=ho();if(e){let t=null;if(so(()=>{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.ne(),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),p=t.opacity(l);(c>i||c===i&&(p>a||p===a&&l===n))&&(r=l,i=c,a=p)}return r}(t,n,r)??r;for(let e of function(e,t,n){let o=n&&t.p(n),r=t.ne().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=u(e);t&&a.push(t)}return u(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||e===Te||n[e]===t)}(e,i,ro,a)&&!uo(e,po()),w=new MutationObserver(e=>{e.some(e=>e.target instanceof Element&&e.target.matches(no))&&g()});w.observe(e,{subtree:!0,attributes:!0,attributeFilter:["class","style","hidden"]});let y=new MutationObserver(g);y.observe(document.documentElement,{attributes:!0,attributeFilter:["data-pipeup-edition"]});for(let e of oo)window.addEventListener(e,g,{capture:!0,passive:!0});return lo.add(g),i=f(),{slide:()=>i,view(e){let t=e instanceof Element?e:e?.parentElement,n=t&&ho()?c().findIndex(e=>e.contains(t)):-1,o=u(t?.closest(no))??(n>=0?h(n):i),r=po(),a={...null!==o?{slide:o}:{},...ro,...null!==r?{[Te]:r}:{}};return Object.keys(a).length?a:void 0},E:v,edition:po,w:e=>uo(e,po()),ee:function(e){if(v(e))return Promise.resolve(!0);let t=e.slide,n=ho(),r=d().find(e=>u(e)===t),a=/^[1-9]\d{0,5}$/.test(t??"");if(a&&io)so(()=>io.go(Number(t)));else if(a&&n){let e=r?c().findIndex(e=>e===r||e.contains(r)):-1;so(()=>n.slide(e>=0?e:Number(t)-1))}else if(ao.size)for(let t of ao)so(()=>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(),y.disconnect();for(let e of oo)window.removeEventListener(e,g,!0);lo.delete(g)}}}(e.root,()=>{T||(I.edition()!==F&&(F=I.edition(),fe()),me()&&He())});F=I.edition();let B=!1,j=null,W=0,K=()=>x.s&&!x.u&&pn(),V=!1,U="pipeup:held",Y=!1;function _(){if(!K()||x.l)return;let e=!1;try{e=null===localStorage.getItem(U),e&&localStorage.setItem(U,"1")}catch{e=!Y}Y=!0,J(e?"Tap what you want to comment on \xb7 Press and hold this button for more":"Tap what you want to comment on",0,!0,!1,{label:"Done",run:()=>ot(!1)}),k.classList.add("tap"),G()}function G(){k.classList.toggle("taught",V),k.querySelector(".tw")?.toggleAttribute("aria-hidden",V)}function J(e,t=2400,n=!1,o=!1,r){if(T)return;if(n&&x.l)return void(j=()=>J(e,t,!0,o));B=n,k.replaceChildren(Je("span",{class:"tw"},e)),k.classList.remove("tap","taught"),k.classList.toggle("act",!!r);let i=r?.run;if(E=i&&r.H?()=>{E=null,k.classList.remove("show"),i()}:null,r){let e=i?Je("button",{class:"ta",type:"button",...r.H?{"aria-keyshortcuts":"Meta+Z Control+Z"}:{}},r.label):Je("a",{class:"ta",href:r.href,target:"_blank",rel:"noopener noreferrer"},r.label);if(i){let t=E??(()=>{k.classList.remove("show"),i()});e.addEventListener("click",e=>{e.stopPropagation(),t()})}k.append(" ",e)}o?k.setAttribute("aria-hidden","true"):k.removeAttribute("aria-hidden"),k.classList.add("show"),window.clearTimeout(P),t&&(P=window.setTimeout(()=>{E=null,k.classList.remove("show"),P=window.setTimeout(_,320)},t))}let X=(e,t)=>J(e,6e3,!1,!1,{label:"Undo",run:t,H:!0});function Q(){K()||(j=null,B&&(B=!1,window.clearTimeout(P),k.classList.remove("show")))}function ee(e){$.textContent="",cancelAnimationFrame(W),W=requestAnimationFrame(()=>$.textContent=e)}function te(e){J(No(e))}function ne(e){throw te(e),e}let oe=()=>e.doc.threads().filter(e=>!e.root.deleted),re=t=>({thread:t,location:Ae(t.anchor,u.get(t.id)??xe(t.anchor,e.root),e.root)}),ie=e=>[...s.e.querySelectorAll(`[data-thread="${e}"] .rbox textarea`)].find(e=>!e.closest("[inert]"));function ae(){for(let e of s.e.querySelectorAll("[data-thread] .rbox textarea"))e.value.trim()&&H.set(e.closest("[data-thread]").getAttribute("data-thread"),e.value)}function le(e,t=!1){let n=H.get(e),o=ie(e);if(o){if(H.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 se(e){let t=Ie();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(A?.we())return A.be();(i&&s.e.querySelector(`${n}[data-thread="${i}"]`)||s.e.querySelector(".launch .mode"))?.focus({preventScroll:!0})}}let de={get me(){return e.doc.me},picker:()=>he.picker,people:()=>Mt(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 Z?J(qo):ne(e)}},reply:async(t,n,o)=>{try{await e.doc.reply(t,n,o),ee("Reply sent"),Ve(o,n)}catch(e){e instanceof Z?J(qo):ne(e)}},edit:async(t,n,o)=>{try{await e.doc.edit(t,n,o)}catch(e){e instanceof Z?J(qo):ne(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?se(n.id):()=>n&&ie(n.id)?.focus({preventScroll:!0});try{await e.doc.remove(t),o(),J("Deleted")}catch(e){J(e instanceof Z?`Deleted \xb7 ${qo}`:No(e))}},resolve:async t=>{let n=se(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 Z?`Resolved \xb7 ${qo}`:No(e))}x.I||(x.i===t&&(x.i=null),n())},reopen:async t=>{try{await e.doc.reopen(t),J("Reopened")}catch(e){J(e instanceof Z?`Reopened \xb7 ${qo}`:No(e))}},notRight:async t=>{try{await e.doc.reopen(t)}catch(e){J(e instanceof Z?`Reopened \xb7 ${qo}`:No(e))}We(t)},pasted:t=>{if(!b(t,Lt()))return"";if(t.author===e.doc.me)return"pasted by you";let n="",o=e=>{e.author===t.author&&e.name&&!w(e.name)&&(n=e.name),e.replies.forEach(o)};return e.doc.threads().forEach(e=>o(e.root)),`pasted by ${n||m(t.author)}`},drop:(e,t)=>X("Reply discarded",()=>{H.set(e,t),ie(e)?le(e,!0):Ze(e)}),close:()=>{Ze(null);let e=Fe&&s.e.querySelector(Fe);e?e.focus({preventScroll:!0}):A?.be(),Fe=""},copy:t=>{try{let n=e.doc.threads().find(e=>e.id===t);if(!n)return;Xn(De(re(n),"ai",location.href,Date.now()),s.e).then(()=>J("Thread copied as Markdown for AI"),e=>J(No(e)))}catch(e){J(No(e))}}},ce={look:()=>n,setLook(e){n=e;try{"auto"===e?localStorage.removeItem(t):localStorage.setItem(t,e)}catch{}Xt(l())},copyAll:async e=>{let t=ce.all(),n=ze(t,e,{title:document.title,url:location.href,exportedAt:new Date});try{await Xn(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(No(e))}},dt:()=>{x.I=!x.I,He()},toggleMine:()=>{x.mine=!x.mine,He()},setHide:e=>{x.hide=e;try{e?localStorage.setItem(v,"1"):localStorage.removeItem(v)}catch{}He()},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(No(e))}},name:()=>e.doc.name,all:()=>[...oe()].sort(wn(ue)).map(re)},pe={},ue={get addons(){return pe.surface},doc:e.doc,root:e.root,e:s.e,host:s.element,state:x,resolved:u,O:h,F:de,l:ce,f:I,G:e=>z.has(e.id),w:e=>I.w(e.anchor.view),Ne:()=>{me()&&He()},j:e=>!x.hidden&&(!e.resolved||x.I||(e=>""!==(s.e.querySelector(`[data-thread="${e}"] .rbox textarea`)?.value.trim()??""))(e.id))&&!z.has(e.id),ct:(e,t)=>{for(let n of oe()){let o=u.get(n.id);if(n.anchor.quote&&ue.j(n)&&o?.range&&sn(e,t,rn(o)))return n}return null},ve:(e,t)=>ue.S()&&!x.pinning?ue.ct(e,t):null,C:e=>e.composedPath().includes(s.element),ye:e=>{f.add(e)},rt:e=>f.has(e),open:Ze,pt:e=>We(e),keepReplies:ae,putReply:e=>le(e),L:function(e){x.L!==e&&(x.L=e,e&&e!==x.i&&at(e),He())},lt:Qe,ot:function(e){if(!x.t)return Qe(e);Object.assign(x.t,e),He()},S:()=>!L||L.Qe(),Oe:e=>{let t=L?.ue();e(),t?.()},focusDraft:_e,re:()=>{let e=x.t?.anchor.view,t=I.E(e)?void 0:e?.slide;J(t?`Finish or cancel your comment on slide ${t} first`:"Finish or cancel this comment first"),_e(()=>A?.toDraft())},et:async function(t,n){let o=x.t;if(o)try{o.sending=!0;let r=await e.doc.comment(o.anchor,t,n);ee("Comment added"),Ve(n,t),x.t=null,fe(new Set([r])),Ze(r,!0)}catch(e){if(e instanceof Z)return x.t=null,fe(new Set([e.id])),Ze(e.id,!0),void J(qo);o.sending=!1,ne(e)}},seen:Ue,people:()=>Mt(e.doc.threads(),e.doc.me),he:tt,ie:ot,W:it,B:e=>{L=e},registerList:e=>{M=e},pageControls:null,pe:J,T:ee,it:Q,taps:()=>Oe(),oe:te,ut:at,m:He,Y:rt},he=pe.surface=new jt(ue,s.shadow,$);function fe(t){let n=performance.now(),o=e.doc.threads();for(let r of o){if(t&&!t.has(r.id))continue;if(I.w(r.anchor.view)){u.set(r.id,{state:"orphaned",element:null,range:null}),h.delete(r.id);continue}let o=performance.now()-n<40,i=xe(r.anchor,e.root,{fuzzy:o});u.set(r.id,i),o||"orphaned"!==i.state?h.delete(r.id):h.add(r.id)}for(let e of[...u.keys()])o.some(t=>t.id===e)||u.delete(e);0===h.size?(window.clearTimeout(R),R=0):0===R&&(R=window.setTimeout(()=>{R=0,!T&&(fe(new Set(h)),He())},250))}function me(){let t=new Set,n=null!==I.slide(),o=new Set;for(let r of e.doc.threads()){o.add(r.id);let e=u.get(r.id),i=e?.element,a="attached"===e?.state||"moved"===e?.state;(I.w(r.anchor.view)||n?!I.E(r.anchor.view):!1===i?.checkVisibility?.({visibilityProperty:!0})||!I.E(r.anchor.view)&&(!a||i?.closest("[role=tabpanel]")))&&t.add(r.id)}z=t;for(let e of H.keys())o.has(e)||H.delete(e);let r=`${I.slide()}|${[...t].join()}`;return r!==O&&(O=r,!0)}function ve(e){let t=[],n=[],o=[];for(let r of e){let e=u.get(r.id);r.resolved&&!x.I||!e?.range||z.has(r.id)||(r.id===x.i||r.id===x.L?n.push(e.range):r.resolved?o.push(e.range):t.push(e.range))}x.t&&I.E(x.t.anchor.view)&&n.push(...x.t.ranges),function(e,t){if(So())for(let n of ko){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=we.get(e);return void 0===t&&we.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=vo(go(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=go(t.backgroundColor,r);if(n&&n.a>=.5)return i>vo(n)}return i>vo(yo(r))}(e)),t})}let we=new WeakMap,ye=0,be=0,ke=0,Ee=0,Se=0,Le=0,Pe=!1,qe=()=>{},Ne=!1,Re=!1;function Oe(){let e=!T&&(x.s||x.l||!!x.i||!!x.t||x.u||Re),t=document.body;e===Ne||!t||(Ne=e,e?t.addEventListener("click",qe):t.removeEventListener("click",qe))}function He(){if(T)return;e.onRender?.();let t=oe();if(me(),x.i&&z.has(x.i)){let e=s.e.querySelector(`[data-thread="${x.i}"] .rbox textarea`)?.value;e&&H.set(x.i,e),x.i=null}x.hidden=x.hide&&!x.s&&!x.u&&!x.Be&&!x.t,d.He(x.s&&!x.paused),x.hidden&&(x.i=null),x.hidden||function(t){let n=function(e,t){let n=Tt(t),o=[];for(let r of e)for(let e of[r.root,...r.root.replies])e.author!==t&&!e.deleted&&Ct(e,n)&&!e.seenBy?.includes(t)&&o.push({thread:r,comment:e});return o}(t,e.doc.me).filter(e=>!Ye.has(e.comment.id));if(!n.length)return;for(let e of n)Ye.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===be)return;be=e,cancelAnimationFrame(ke);let t=ye,n=performance.now(),o=e?260:200,r=i=>{let a=Math.min(1,(i-n)/o);ye=t+(e-t)*(e?1-(1-a)**3:a*a),d.xe(ye),a<1&&(ke=requestAnimationFrame(r))};ke=requestAnimationFrame(r)}(x.hidden?0:1),s.e.classList.toggle("hidden",x.hidden),s.e.classList.toggle("listing",x.u),x.t&&K()&&!V&&(V=!0,k.classList.contains("tap")&&G()),x.s&&pn()&&(x.u?Q():k.classList.contains("show")||(j??=_));let n=x.u&&!cn();(function(e){e!==Ee&&(Ee=e,d.De(e,c),null!==I.slide()&&(Le=performance.now()+450),window.clearTimeout(Se),Se=window.setTimeout(()=>{fe(),He()},c?0:400))})(n?320:0),d.Ie(p?"column"!==x.mode||x.hidden||n?0:320:null);let o=0;if(null!==I.slide())for(let t of e.root.querySelectorAll(qn)){if(t===s.element)continue;let e=t.getBoundingClientRect();e.top>innerHeight/2&&e.right>innerWidth-Ee-380&&e.bottom>innerHeight-48&&(o=Math.max(o,innerHeight-e.top+4))}s.e.style.setProperty("--pu-lift",`${o}px`),ve(t),Re=!x.hidden&&t.some(e=>!!e.anchor.quote&&!e.resolved&&!z.has(e.id)),Oe();let r=he.Ge(),i=r.size?t.filter(e=>!r.has(e.anchor.id??"")):t;for(let e of C)e.m(e===C.at(-1)?t:i);A?.m(t),x.hidden||he.flush()}let Fe="",Ie=()=>s.e.getRootNode().activeElement,Be="input,textarea,select,[contenteditable]:not([contenteditable=false])",je=()=>{let e=Ie();return e instanceof HTMLTextAreaElement&&""!==e.value||!!document.activeElement?.matches(Be)};function We(e,t=je(),n=Ie()){let o=[...s.e.querySelectorAll(`[data-thread="${e}"] .rbox textarea`)].find(e=>!e.closest("[inert]")),r=n?.getAttribute("data-thread");Fe=r?`.${n.classList[0]}[data-thread="${r}"]`:"",!t&&o&&o.focus({preventScroll:!0})}let Ke=()=>!!x.t&&!ue.S();function Ve(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 Ue(t){let n=[t.root,...t.root.replies].filter(t=>t.author!==e.doc.me&&!t.deleted&&Ct(t,Tt(e.doc.me))).map(e=>e.id);n.length&&e.doc.seen(n).catch(()=>{})}let Ye=new Set;function _e(e){let t=x.t?.anchor.view,n=L?.ue();Promise.resolve(I.E(t)||I.ee(t??{}).then(()=>ue.Ne())).then(()=>{I.E(t)&&e?.(),n?.()})}function Ze(t,n=!1){if(t&&x.t&&!ue.S())return ue.re();if(t&&x.u&&M)return M(t);if(x.i===t&&!x.t)return t?We(t):void 0;let o=!n&&je(),r=Ie();if(t||(x.Be=!1),ae(),x.i=t,t){x.t=null,at(t);let n=e.doc.threads().find(e=>e.id===t);n&&Ue(n)}He(),t&&(le(t),n&&A?.we()?A.be():We(t,o||pn(),r))}function Qe(e){Q(),x.t=e,x.i=null,He()}function tt(e=""){let t=x.t;t&&(x.t=null,He(),e&&X("Comment discarded",()=>{x.t&&!ue.S()||(Qe(t),A?.adopt(t),L?.fill(e))}))}function ot(e,t=!1){x.s!==e&&(x.s=e,x.paused=!1,j=null,e?(x.i=null,A=function(e){let t={p:e=>e.getBoundingClientRect(),tt: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},nt: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}},ne:()=>({width:innerWidth,height:innerHeight})},n=Je("span",{hidden:!0},Gn),o=Je("div",{class:"pick"},n),r=Je("div",{class:"pkw"}),i=[0,1].map(()=>{let e=Je("div",{class:"km",tabindex:"-1",role:"button"},Je("span",{hidden:!0}),Je("span",{hidden:!0}));return e.inert=!0,e.addEventListener("keydown",Se),e.addEventListener("click",e=>{e.stopPropagation(),Ee()}),e.addEventListener("focus",()=>o.classList.add("kf")),e.addEventListener("blur",()=>o.classList.remove("kf")),e}),a=Je("span",{class:"lbl"}),l=(e,t,n,o)=>{let r=Je("button",{class:"nb",type:"button","aria-label":e,title:t},dt(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",ke),c=l("Pin","Pin its centre","pin",t=>t.detail&&pn()?j(!D):e.Oe(()=>U(m??k,{x:.5,y:.5}))),p=Je("div",{class:"namebar",role:"group","aria-label":"Chosen block"},a,s,d,c);p.inert=!0;let u=e.e.querySelector(".launch");for(let t of[r,o,...i,p])e.e.insertBefore(t,u);p.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,N=null,R=!1,D=!1,z=t=>!(e.C(t)||t.target instanceof Element&&t.target.closest(qn));function O(){v&&(o.classList.toggle("glide",performance.now()<w),nt(o,v.getBoundingClientRect(),4))}function H(){if(!b)return;p.classList.toggle("glide",performance.now()<w&&p.classList.contains("show"));let t={width:p.offsetWidth||200,height:p.offsetHeight||34},n=gn(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),p.style.left=`${n.left}px`,p.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.T(a.textContent="Tap where to pin"):b&&(a.textContent=Ce(b))}function W(e){D&&j(!1),m=e,o.classList.toggle("on",null!==e),B(e),K(e)}function K(e){x(),p.inert=!e,e?h?(p.classList.remove("show"),x=I(p,()=>V(e))):V(e):(p.classList.remove("show"),b=null)}function V(n){a.textContent=a.title=Ce(n),s.hidden=null===Fn(n,e.root,t),d.hidden=0===(k?we(n).length:jn(n,t,de).length);let o=p.classList.contains("show");b=n,H(),o||(p.offsetWidth,p.classList.add("show"))}function U(t,n){let o;try{o=ge(t,e.root,n,e.f.view(t))}catch(t){return void e.oe(t)}let r={anchor:o,label:n?`Pin on ${Ce(t).replace(/^[A-Z](?=[a-z])/,e=>e.toLowerCase())}`:Ce(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.ot(r),i&&e.focusDraft(),e.T(n?r.label:`Commenting on ${r.label}`)}function Y(t){e.Oe(()=>U(t))}function _(n){let o=(n.target instanceof Element?Hn(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.C(n)||e.state.paused)return;if(!z(n))return void(m||B(null));if(n.stopPropagation(),m||e.state.t)return;let o=!et()&&n.target instanceof Element?Hn(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=()=>{et()&&(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(Vn)&&e.preventDefault())},re=n=>{if(!z(n))return;if(X())return e.ye(n);let o=n.target;!(o===N||o.form&&o.form===N?.form)||"submit"!==n.type&&("click"!==n.type||n.detail)?(n.preventDefault(),n.stopPropagation(),"click"===n.type&&!e.state.l&&!e.rt(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.S()&&e.he());let r=n.target instanceof Element?Hn(n.target,e.root,t):null;if(e.state.t&&!e.S())return r||n.altKey?e.re():e.W();if(e.state.t&&n.altKey)return e.W();if(n.altKey||!e.ve(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.W(),W(null))}}(n)):N="click"===n.type&&"submit"===o.type?o.form:null},ie=t=>{if(t.key!==Jt&&(Z=!0),(e=>{if(e.key!==Jt||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(Vn):null;return!n||!Z&&!n.matches("input,textarea,select,[contenteditable]:not([contenteditable=false])")})(t)||t.key===Jt&&e.state.paused)return t.repeat||G(!0),t.preventDefault(),void t.stopPropagation();if(N=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.Y();if("Tab"===t.key&&function(t){if(t.ctrlKey||t.metaKey||t.altKey||t.isComposing||!e.C(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(R=!0,r&&e.S())e.he();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 R=!1,!1;r||e.open(null)}return R=!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.W(),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(Kn))"Enter"===t.key&&t.target.form&&(N=t.target);else{if(!k)return void(N=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.C(t)?!!n.closest(".launch,.menu")&&!n.closest("input,textarea,select,[contenteditable]"):!t.composedPath().some(e=>e instanceof Element&&e.matches(qn)))},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.E(e.f.view(t))},ce=()=>(q?.some(e=>!e.o.isConnected)&&(q=null),q??=jn(e.root,t,de)),pe=e=>ce().find(t=>t.o===e),ue=(e,t=!1)=>{let n=e.getBoundingClientRect();return n.bottom>0&&n.top<window.innerHeight&&(!t||n.top>=0)},he=()=>{let e=Wn(ce(),0);return e.find(e=>ue(e.o,!0))??e.find(e=>ue(e.o))??e[0]},fe=t=>e.doc.threads().filter(n=>e.j(n)&&t.contains(vn(e,n))).sort(wn(e));function me(t,o=!0){A=0;let r=ce(),a=r.find(e=>e.o===t);if(a&&!Wn(r,E).includes(a)&&(E=a.$),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.it();let l=i[S^=1];(function(e,t){let[o,r]=e.children,i=Wn(ce(),E),a=fe(t).length;o.textContent=`${$e(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=Me(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),nt(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)Xe(e,!0);return e}function we(e){let t=pe(e);return t?((e,t)=>e.filter(e=>e.V===t))(ce(),t):[]}function ye(e){let t=Wn(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&&me(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&&pe(r);if(i){E=i.$;let e=Wn(ce(),E),n=e.indexOf(i);o=e[(n+t+e.length)%e.length]}else if(r){E=0;let e=Wn(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=he(),o&&(E=o.$);if(!o)return e.T("Nothing here to comment on");$=!0,me(o.o)}function xe(){let n=m??k,o=n&&Fn(n,e.root,t);return o?((!C||!n.contains(C))&&(C=n),m?Y(o):void me(o)):e.T("Nothing around it")}function ke(){let t=m??k,n=t?we(t):[],o=n.find(e=>C&&e.o.contains(C))??n.find(e=>ue(e.o))??n[0];if(!o)return e.T("Nothing inside it");m?Y(o.o):me(o.o)}function Ee(t=!1){if(!k)return;if(e.state.t&&!e.S())return e.re();if(!t)return U(k);let n=fe(k);if(!n.length)return e.T("No comments on this block");T=(T+1)%n.length,e.open(n[T].id),n.length>1&&e.T(`Comment ${T+1} of ${n.length} on this block`)}function Se(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.Y();if("Enter"===t.key)return Ee(t.shiftKey);"Tab"===t.key&&e.W(),e.state.i&&e.open(null),"Tab"===t.key?ye(t.shiftKey?-1:1):"ArrowUp"===t.key?xe():ke()}}function Le(){let t=e.state.t,n=!!k&&!!t&&!e.S(),o=n&&t===g&&t.resolved.element!==k?t.resolved.element:null;r.classList.toggle("show",!!o&&de(o)),o&&nt(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===Jt&&e.state.paused)return G(!1),t.preventDefault(),void t.stopPropagation();t.key===Te&&(Te="",t.preventDefault(),t.stopPropagation())},Ne=()=>G(!1);window.addEventListener("keyup",qe,!0),window.addEventListener("blur",Ne),window.addEventListener("pointermove",te,!0),window.addEventListener("pointerdown",Q,!0);for(let e of _n)window.addEventListener(e,ee,!0);document.addEventListener("selectionchange",ne);for(let e of Yn)window.addEventListener(e,oe,!0);for(let e of Un)window.addEventListener(e,re,!0);return window.addEventListener("keydown",ie,!0),{Y:()=>!!m&&(W(null),!0),we:()=>null!==k,st:()=>$&&!k,Re:function(){q=null;let t=document.activeElement;M=le()??t;let n=pe(L),o=n??(t&&t!==document.body&&e.root.contains(t)&&!t.closest(qn)?ce().filter(e=>e.o.contains(t)).pop():void 0)??he();return!!o&&(n||(E=o.$),$=!0,me(o.o),!0)},be(){k&&!se()&&me(k)},m(){if(q=null,k&&(!k.isConnected||!de(k))){let e=he();e?me(e.o,se()||Ae()):ve()}let t=e.e.querySelector(".launch");if(t&&p.nextElementSibling!==t&&!se()&&!p.contains(le()))for(let n of[r,o,...i,p])e.e.insertBefore(n,t);let n=e.state.t;g&&n!==g?(g=null,W(null),k&&me(k,Ae()&&!R)):(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),Le()},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)},N(){Le(),O(),H(),k&&nt(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",Ne),window.removeEventListener("pointermove",te,!0),window.removeEventListener("pointerdown",Q,!0);for(let e of _n)window.removeEventListener(e,ee,!0);document.removeEventListener("selectionchange",ne);for(let e of Yn)window.removeEventListener(e,oe,!0);for(let e of Un)window.removeEventListener(e,re,!0);window.removeEventListener("keydown",ie,!0),o.classList.remove("show"),p.classList.remove("show"),Xe(p,!0),I(o,()=>o.remove()),I(p,()=>p.remove())}}}(ue)):(Q(),A?.destroy(),A=null,ee("Comment mode off")),He(),A&&(t&&A.Re(),t?A.we()?j=()=>J(Gn,1e4,!0,!0):J("Nothing here to comment on"):j=pn()?_:()=>J(`Click anything to comment, or Tab between blocks \xb7 Option-click (Alt-click) to pin \xb7 Hold Space to use the page \xb7 This button, ${Zt} or Esc to finish`,4e3,!0)))}function rt(){let t=window.getSelection();x.s&&t&&!t.isCollapsed&&e.root.contains(t.anchorNode)?t.removeAllRanges():x.t&&ue.S()?tt():x.i?Ze(null):A&&!A.Y()&&ot(!1)}function it(){x.t?Ke()||tt():x.i&&Ze(null)}function at(e){let t=u.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;st(()=>t.range&&!n?rn(t):o?[o.getBoundingClientRect()]:[])}let lt=new Set;function st(e){let t=e().slice(0,6).map(()=>s.e.insertBefore(Je("div",{class:"pulse"}),s.e.firstChild)),n={els:t,at:e};lt.add(n),ct(n),window.setTimeout(()=>{lt.delete(n);for(let e of t)e.remove()},1300)}function ct(e){let t=e.at();e.els.forEach((e,n)=>t[n]&&nt(e,t[n],4))}function pt(){ae();let e=!!Ie()?.closest(".rbox");for(let e of C)e.destroy();C=function(e){return[..."column"===e.state.mode?[Mn(e),An(e,{ge:!1})]:[An(e,{ge:!0})],Jn(e),to(e)]}(ue),He(),x.i&&le(x.i,e)}Ge.go=t=>{if(t.startsWith("slide:"))return void I.ee({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(()=>st(()=>[o.getBoundingClientRect()]),c?0:450))};let ut={x:0,y:0};let ht=()=>{if(!T){if(function(){let e=s.e.getBoundingClientRect();!Math.round(e.left)&&!Math.round(e.top)||(ut={x:ut.x-Math.round(e.left),y:ut.y-Math.round(e.top)},s.e.style.transform=ut.x||ut.y?`translate(${ut.x}px,${ut.y}px)`:"",(e=>{un=e})(ut.y))}(),j&&!x.l&&(!k.classList.contains("show")||B)){let e=j;j=null,e()}Le&&(performance.now()>Le&&(Le=0),Pe=!0,dispatchEvent(new Event("resize")),Pe=!1);for(let e of C)e.N();for(let e of lt)ct(e);A?.N(),he.N(),D=requestAnimationFrame(ht)}},ft=e=>{let t=e.composedPath()[0];return t instanceof Element&&null!==t.closest(Be)},mt=e=>{if("Escape"===e.key)return e.isComposing?void 0:rt();if(E&&"KeyZ"===e.code&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey){let t=e.composedPath()[0];if(!ft(e)||t instanceof HTMLTextAreaElement&&t.getRootNode()===s.shadow&&""===t.value)return e.preventDefault(),E()}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&&!ft(e)){if(e.preventDefault(),A?.st()&&A.Re())return;ot(!x.s,!0)}},gt=e=>{if(ue.C(e)||f.has(e))return;let t=window.getSelection();t&&!t.isCollapsed||it()},vt=window.innerWidth,wt=0;function yt(){let e=x.i?u.get(x.i):x.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 kt=hn().bottom,Et=!1,St=0,$t=()=>{let e=window.visualViewport,t=Ie();s.e.classList.toggle("kb",!!e&&window.innerHeight-e.height>150&&(t instanceof HTMLTextAreaElement||t instanceof HTMLInputElement));let n=hn().bottom;n<kt-80&&(Et=!0),kt=n,window.clearTimeout(St),St=window.setTimeout(()=>{if(!Et)return;Et=!1;let e=hn(),t=x.i?u.get(x.i):x.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-(pn()?76:60),behavior:c?"auto":"smooth"})},250)},At=()=>{if(Pe)return;window.innerWidth!==vt&&(vt=window.innerWidth,window.clearTimeout(wt),wt=window.setTimeout(yt,200)),s.e.style.setProperty("--pu-pop",`${dn()}px`);let t=Po(e.root,"column"===x.mode);t!==x.mode?(x.mode=t,pt()):He()};function Pt(){let e=performance.now();0===q&&(N=e),window.clearTimeout(q);let t=Math.min(120,Math.max(0,N+1e3-e));q=window.setTimeout(()=>{q=0,fe(),He()},t)}let qt=[],Nt=/^(video|canvas|iframe|img|object|embed|audio)$/,Rt=new MutationObserver(()=>Ot()),Dt=null,zt=0;function Ot(){let e=function(){let e=new Set;try{for(let t of document.querySelectorAll("dialog:modal"))e.add(t);for(let t of qt)"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&&!Nt.test(t.localName)&&e.add(t),[...e]}();qt=[...qt.filter(t=>e.includes(t)),...e.filter(e=>!qt.includes(e))];let t=qt.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;Rt.disconnect();for(let e of qt)e.getRootNode()!==document&&Rt.observe(e,{attributeFilter:["open"]});if(s.element.parentNode===n)return;let o=!s.element.isConnected;n.append(s.element),o&&Dt?.isConnected&&performance.now()-zt<100&&Dt.focus({preventScroll:!0})}let Ht=new MutationObserver(e=>{e.some(e=>e.removedNodes.length)&&Ot(),!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))&&Pt()}),Ft=e=>{let t=e.key,n=t=>e.composedPath().some(e=>e instanceof Element&&e.matches(t));("Enter"===t||" "===t||To.includes(t)&&n(".menu,.all,.pm")||t.startsWith("Arrow")&&n(".menu"))&&e.stopPropagation()};for(let e of["keydown","keyup","keypress"])s.e.addEventListener(e,Ft);let It=e=>e===s.element,Bt=e=>{"focusin"===e.type&&Ot(),It(e.target)&&("focusin"===e.type&&(Dt=e.composedPath()[0]),zt="focusin"===e.type?1/0:performance.now()),("focusin"===e.type?It(e.target)&&!It(e.relatedTarget):It(e.relatedTarget)&&!It(e.target))&&e.stopImmediatePropagation()},Wt=null,Kt=!1;s.shadow.addEventListener("keydown",e=>{e===Wt&&(Kt=!0)});let Vt=e=>{if(!(e=>{let t=e.composedPath();if(!t.includes(s.element))return!1;let n=t[0];if(n instanceof Element&&n.matches(Be))return!0;let o=e.key,r=e=>t.some(t=>t instanceof Element&&t.matches(e));return["Escape","Tab","Enter"," "].includes(o)||To.includes(o)&&r(".menu,.all,.pm,.rxp")||o.startsWith("Arrow")&&r(".menu,.rxp")})(e)||(e.stopImmediatePropagation(),"keydown"!==e.type))return;let t=Wt=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),Wt=null,t.defaultPrevented&&e.preventDefault(),Kt&&mt(e)},Ut=e=>e.stopPropagation(),Yt=["pointerdown","mousedown","touchstart","click","focusin","focusout"];for(let e of["focusin","focusout"])window.addEventListener(e,Bt,!0);for(let e of Yt)s.element.addEventListener(e,Ut);for(let e of["keydown","keyup","keypress"])document.addEventListener(e,Vt,!0);document.addEventListener("fullscreenchange",Ot);let _t=()=>qt.length&&Ot();for(let e of["transitionend","animationend"])window.addEventListener(e,_t,!0);window.addEventListener("keydown",mt),window.addEventListener("click",gt),window.addEventListener("resize",At);for(let e of["resize","scroll"])window.visualViewport?.addEventListener(e,$t);Ht.observe(e.root,{subtree:!0,childList:!0,characterData:!0});let Gt=0,Xt=t=>{let n="dark"===t;s.e.classList.toggle("flip",n!==i),n!==r&&(r=n,window.clearTimeout(Gt),s.e.classList.add("fading"),Gt=window.setTimeout(()=>{xo(s.e,bo(e.root,t)),s.e.classList.remove("fading")},170))},Qt=()=>{Xt(l()),we=new WeakMap,ve(oe())},en=0,tn=()=>{en||(en=window.setTimeout(()=>{Qt(),en=window.setTimeout(()=>{en=0,Qt()},450)},150))},nn=new MutationObserver(e=>{e.some(e=>"open"===e.attributeName&&"dialog"===e.target.localName)&&Ot(),!e.every(e=>e.target===s.element)&&tn()});nn.observe(document.documentElement,{attributes:!0,subtree:!0});let on=window.matchMedia?.("(prefers-color-scheme: dark)");on?.addEventListener?.("change",tn);let an=new ResizeObserver(Pt);an.observe(e.root);let ln=e.doc.onChange((e,t,n)=>{he.ze(t,n),fe(),He()});return fe(),pt(),Ot(),D=requestAnimationFrame(ht),{ctx:ue,appearance:()=>o,destroy(){T=!0,cancelAnimationFrame(D),cancelAnimationFrame(ke),cancelAnimationFrame(W),I.destroy(),window.clearTimeout(Se),window.clearTimeout(P),window.clearTimeout(wt),window.clearTimeout(q),window.clearTimeout(R),Ht.disconnect(),Ge.go=void 0,an.disconnect(),nn.disconnect(),on?.removeEventListener?.("change",tn),window.clearTimeout(en),window.clearTimeout(Gt),ln(),window.removeEventListener("keydown",mt),window.removeEventListener("click",gt);for(let e of["focusin","focusout"])window.removeEventListener(e,Bt,!0);for(let e of["keydown","keyup","keypress"])document.removeEventListener(e,Vt,!0);document.removeEventListener("fullscreenchange",Ot);for(let e of["transitionend","animationend"])window.removeEventListener(e,_t,!0);Rt.disconnect(),window.removeEventListener("resize",At);for(let e of["resize","scroll"])window.visualViewport?.removeEventListener(e,$t);window.clearTimeout(St),document.body?.removeEventListener("click",qe),A?.destroy();for(let e of C)e.destroy();he.destroy(),d.remove(),s.destroy()}}}var Do=(e,t,n)=>Object.assign(new Error(`pipeup: ${t}`,{cause:n}),{code:e}),zo=null;function Oo(e={}){if(Vt)return Vt.mount(e);if(!_t())return Promise.reject(Do("another-copy","another copy of Pipeup owns the add-on queue. Remove one script."));if(zo)return zo;let t=async function(e,t){yt({"data-pipeup-doc":e.doc,"data-pipeup-layout":e.layout,"data-pipeup-theme":e.theme,"data-pipeup-select":e.select,"data-pipeup-control":e.control});let n,o,r=bt("data-pipeup-doc"),{id:a,key:l}=r?await V(r):{id:`page-${i(location.origin+location.pathname)}`,key:null},s=!1;if(e.store)n=e.store,o=await ne(n);else try{let e=oe.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 ne(n)}catch{n=new te,s=!0,o=await ne(n)}let d=e.name?.trim();d&&d!==o.name&&(o={...o,name:d},await n.saveProfile(o)),navigator.storage?.persist?.().catch(()=>{});let c=await J.open({doc:a,key:l,store:n,identity:o.identity,name:o.name});co(e.slides??null);let p,u=new Set,h="",f=()=>queueMicrotask(()=>{if(!p||g)return;let e={commentMode:p.ctx.state.s,name:c.name},t=JSON.stringify(e);if(t!==h){h=t;for(let t of[...u])try{t({...e})}catch(e){globalThis.reportError?.(e)}}}),m=async e=>{c.name=e,o={...o,name:e},f(),await n.saveProfile(o)},g=!1;try{p=Ro({doc:c,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)}.cm{display:flex;align-items:center;gap:6px;max-height:20px;padding-top:4px;overflow:hidden;font-size:12px;color:var(--fa)}.hdr .cm{display:inline-grid;padding:0;flex:none}.cm.new{animation:pu-in var(--mv) var(--eo) both}.cm.out{animation:cm-out var(--mv) var(--eo) forwards}@keyframes cm-out{to{opacity:0;max-height:0;padding-top:0}}.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}.launch.off{display: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:has(.mm[aria-expanded=true]) .ttip{grid-template-columns:minmax(0,0fr);opacity:0}.launch .mm{display:grid;place-items:center;width:0;height:24px;margin-left:0;border-radius:6px;overflow:hidden;opacity:0;color:inherit;transition:width var(--out) var(--ei),margin var(--out) var(--ei),opacity var(--out) var(--ei),background-color .2s var(--eo)}.launch:is(:hover,:has(.mm:focus-visible)) .mm{width:26px;margin-left:4px;opacity:1;transition:width var(--mv) var(--eo) .4s,margin var(--mv) var(--eo) .4s,opacity var(--in) var(--eo) .4s,background-color .2s var(--eo)}.launch:has(.mm:focus-visible) .mm{transition-delay:0s}.launch .mm:hover{background:color-mix(in srgb,currentColor 12%,transparent)}.launch .mm:focus-visible{outline:2px solid var(--pu-accent);outline-offset:-2px}.launch:has(.mm[aria-expanded=true]) .mm{width:0;margin-left:0;opacity:0}.launch .mode{-webkit-touch-callout:none;-webkit-user-select:none;user-select:none}.launch:has(.mm:focus-visible) .ttip{grid-template-columns:minmax(0,1fr);opacity:1}@media(hover:none){.ttip,.tt,.cd>.thread .acts,.launch .mm{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{z-index:2;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)}.bts .here{flex:none;display:grid;place-items:center;margin-right:auto;padding:0 2px;color:var(--fa);transition:opacity var(--in) var(--eo)}.here.off{opacity:0;pointer-events:none}.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)}.fold{display:flex;align-items:center;gap:4px;width:100%;margin-top:6px;border-radius:6px;text-align:left;cursor:pointer}.fold:hover,.fold:focus-visible{color:var(--mu);outline:none}.fold svg{transition:transform var(--mv) var(--eio)}.fold[aria-expanded=true] svg{transform:rotate(90deg)}.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}}@keyframes cm-out{99%{opacity:0;max-height:20px;padding-top:4px}to{opacity:0;max-height:0;padding-top:0}}.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:m,onRender:f})}catch(e){throw co(null),e}let v=p;s&&v.ctx.pe("This browser can't keep comments for this page \u2014 copy the comments (Copy comments \u203a As Markdown) to keep them");let w=()=>{c.flush().catch(e=>globalThis.reportError?.(e))},y=function(e){let t={...e,i:!0};Kt=t;for(let e of Wt.values())"waiting"===e.info.state&&Gt(e,t);return()=>{t.i=!1,Kt===t&&(Kt=null);for(let e of[...Wt.values()].reverse())e.stop?.(),delete e.stop;e.surface.destroy()}}({surface:v.ctx.addons,doc:c,root:e.root??document.body,ephemeral:s,version:We,onIdentity:async e=>{o={...o,identity:e},await n.saveProfile(o)}}),b=/\S/.test(bt("data-pipeup-agents")??"")?window.setTimeout(()=>{Ut().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;return"off"!==bt("data-pipeup-updates")&&Date.now()-Date.parse(Ke)>31536e6&&console.info(`pipeup: this is Pipeup ${We}, from ${Ke}; newer versions exist. See https://github.com/pipeup-ai/pipeup/blob/main/CHANGELOG.md`),window.addEventListener("pagehide",w),{document:c,comments:({all:e=!1,edition:t=!1}={})=>je(v.ctx.l.all().filter(e=>!t||!v.ctx.w(e.thread)),{title:document.title,url:location.href,exportedAt:new Date,all:e}),appearance:()=>({...v.appearance()}),flush:()=>c.flush(),get commentMode(){return v.ctx.state.s},setCommentMode:async e=>{g||v.ctx.ie(!!e)},openMenu:async()=>{g||v.ctx.pageControls?.l()},openAllComments:async()=>{g||v.ctx.pageControls?.list()},get name(){return c.name},setName:async e=>{let t=String(e).replace(/\s+/g," ").trim();!t||t===c.name||g||(await m(t),v.ctx.m())},on:(e,t)=>"change"!==e||"function"!=typeof t?()=>{}:(u.add(t),()=>u.delete(t)),unmount:()=>{g||(g=!0,u.clear(),yt(null),window.removeEventListener("pagehide",w),window.clearTimeout(b),y(),v.destroy(),co(null),zo===t()&&(zo=null))}}}(e,()=>t).catch(e=>{throw zo===t&&(zo=null),yt(null),e?.code?e:Do("failed",`Pipeup couldn't start: ${String(e?.message??e)}`,e)});return zo=t,t}typeof document<"u"&&(Vt?console.warn(`pipeup: Pipeup is on this page twice (${Vt.VERSION} and ${We}); the first one is used. Remove one script.`):(_t(),function(){if("off"===bt("data-pipeup-auto"))return;let e=()=>{Oo().catch(e=>console.error(e))};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e,{once:!0}):e()}()));const Ho=Object.defineProperty({},"__esModule",{value:!0});for(const[t,n]of Object.entries({ADDON_API:1,AI_NAME:v,ANIMALS:c,BUILT:Ke,COLOURS:p,DEFAULT_PROFILE_NAME:"",IndexedDbStore:oe,MemoryStore:te,PipeupDocument:J,UnsavedChangeError:Z,VERSION:We,addons:Ut,agentComments:je,agentName:y,animalName:m,checkOp:async function(e){return H(e)&&await F(e).catch(()=>!1)},comments:async function(e){if(!zo)throw new Error("pipeup: Pipeup hasn't started on this page");return(await zo).comments(e)},computeOpId:j,copyAll:ze,copyThread:De,createIdentity:s,describeElement:ge,describeRange:me,formatAgo:Re,isAiName:w,isPasted:b,labelOf:Ce,loadOrCreateProfile:ne,locate:Ae,mount:Oo,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 ao.add(e),()=>{ao.delete(e)}},parseDocumentAttribute:V,readFeedbackFile:_,resolveAnchor:xe,setPeople:function(e){St=e.filter(e=>e&&"string"==typeof e.name&&e.name.trim()&&Et.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[...$t])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===Te||o.length>64||r.length>S)){if(++n>=16)break;t[o]=r}}ro=t;for(let e of lo)e()},setting:bt,signOp:N,use:Yt}))Object.defineProperty(Ho,t,{value:n,enumerable:!0});return Ho})();
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"],p=["Red","Orange","Yellow","Green","Teal","Blue","Purple","Pink","Brown","Grey"];function u(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=>u(e)%c.length,f=e=>Math.floor(u(e)/c.length)%p.length,m=e=>`${p[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=u(`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=e=>`${v} \xb7 ${e.replace(/\s+/g," ").trim()||"Agent"}`.slice(0,80).trim(),b=(e,t)=>e.name.startsWith(`${v} \xb7 `)&&!t.includes(e.author),x=2**40,k=2**47,E=1e4,S=200,$=200,L=new Set(["h","p","img","button","link","field","media","box"]),M=new Set(["confirmed","moved","gone"]),C=/^[0-9a-f]{8}$/,A=/^[A-Za-z0-9_-]{43}$/,T=/^(?:[^\s@<>"]{1,64}@[^\s@<>"]{1,190}\.[^\s@<>"]{2,24}|gh:[A-Za-z0-9-]{1,39})$/,P=/^(?:[A-Za-z0-9_-]{43}|(?:host|gh):[A-Za-z0-9._@-]{1,64})$/,q=/^[A-Za-z0-9_-]{43}$/,N=new Set(["create","reply","edit","delete","resolve","reopen","addressed","react","unreact","seen","contact","uncontact","place"]),R=/^(?:\p{Regional_Indicator}{2}|[#*0-9]\uFE0F?\u20E3|\p{Extended_Pictographic}(?:\uFE0F|\p{Emoji_Modifier})?(?:\u200D\p{Extended_Pictographic}(?:\uFE0F|\p{Emoji_Modifier})?)*)$/u,D=e=>"string"==typeof e&&R.test(e)&&[...e].length<=16;async function z(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 O=(e,t)=>"string"==typeof e&&e.length<=t,H=e=>!!e&&"object"==typeof e,I=e=>"number"==typeof e&&Number.isFinite(e)&&e>=0&&e<=1;function B(e){if(!H(e))return!1;let{id:t,path:n,fingerprint:o,snapshot:r,quote:i,point:a,view:l,kind:s,name:d,heads:c,y:p,lost:u}=e;if(!(O(n,2e3)&&O(r,500)&&"string"==typeof o&&C.test(o)&&(void 0===t||O(t,200)&&""!==t)&&(void 0===i||H(i)&&O(i.exact,E)&&""!==i.exact&&O(i.prefix,64)&&O(i.suffix,64))&&(void 0===a||H(a)&&I(a.x)&&I(a.y))))return!1;if(void 0!==l){if(!H(l)||Array.isArray(l))return!1;let e=Object.entries(l);if(e.length>16||!e.every(([e,t])=>e.length<=64&&O(t,S)))return!1}return!(void 0!==s&&!L.has(s)||void 0!==d&&!O(d,$)||void 0!==c&&(!Array.isArray(c)||c.length>3||!c.every(e=>O(e,120)))||void 0!==p&&!I(p)||void 0!==u&&!0!==u)}function F(e){if(!H(e))return!1;let{body:t,sig:n}=e;if("string"!=typeof n||!H(t)||JSON.stringify({body:t,sig:n}).length>262144)return!1;let o=t;if(1!==o.v||"string"!=typeof o.id||!A.test(o.id)||!N.has(o.kind)||!O(o.doc,64)||""===o.doc||"string"!=typeof o.thread||!A.test(o.thread)||"string"!=typeof o.author||!q.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>x||"number"!=typeof o.at||!Number.isSafeInteger(o.at)||o.at<0||o.at>k||void 0!==o.text&&(!O(o.text,1e4)||o.text!==o.text.trim())||void 0!==o.target&&("string"!=typeof o.target||!A.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(!H(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||!P.test(r))return!1}}return!!(("contact"!==o.kind||"string"==typeof o.text&&T.test(o.text))&&("seen"!==o.kind||o.target)&&("react"!==o.kind&&"unreact"!==o.kind||o.target&&D(o.text))&&("create"!==o.kind||o.id===o.thread&&B(o.anchor))&&("place"!==o.kind||B(o.anchor)&&M.has(o.text)))}function j(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 W(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 K(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 V(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 U=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(W)){if(r.name&&!w(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=K(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("place"===r.kind){if(!r.anchor)continue;e.anchor=r.anchor,e.placed={how:r.text,author:r.author,name:r.name,at:r.at};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=K(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)=>!w(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(!F(n)||n.body.doc!==this.doc||this.ops.has(n.body.id)||n.body.id!==await V(n.body)||!await j(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,x),at:Math.min(Math.max(Date.now(),"create"===n.kind?(this.createAt.get(e.publicKey)??0)+1:(this.threadAt.get(n.thread)??0)+1),k)};o.id=await V(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 z(o,e)]);if(!i)throw new Error("pipeup: could not record this change");return i}},Y=/^([A-Za-z0-9_-]{16}):([A-Za-z0-9_-]{43})$/;async function _(e){let n=Y.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 G(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 Z=e=>`pipeup-file:${e}`;async function J(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},Z(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 X=/^[a-z][a-z0-9-]{1,23}\/[a-z][a-z0-9-]{0,31}$/,Q=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"}},ee=class e{constructor(e,t){this.log=e,this.options=t,this.displayName=t.name.trim()?oe(t.name):""}listeners=new Set;cache=[];comments=new Map;displayName;ke=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 U(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=oe(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:te(t),...n?.length?{mentions:n}:{}}))}place(e,t,n){return this.enqueue(async()=>{let{thread:o}=this.find(e),r="gone"===n?{...t,lost:!0}:t;await this.write({kind:"place",thread:o,anchor:r,text:n})})}reply(e,t,n){return this.enqueue(()=>this.write({kind:"reply",thread:this.find(e).thread,target:e,text:te(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:te(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 T.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(W))"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:ne(t)})})}unreact(e,t){return this.enqueue(async()=>{await this.write({kind:"unreact",thread:this.find(e).thread,target:e,text:ne(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)})})}paste(e,t,n,o){return this.enqueue(async()=>{let r=this.thread(e),i=y(t),a=this.cache.find(e=>e.id===r).root.id;await this.write({kind:"reply",thread:r,target:a,text:te(n)},i),o?.trim()&&await this.write({kind:"addressed",thread:r,text:te(o)},i)})}sign(e,t){if(!X.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 G(n,JSON.stringify(t),Z(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 J(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 Q(n[0].body.id,e,n.length):e}return n.length})}enqueue(e){let t=this.ke.then(e);return this.ke=t.catch(()=>{}),t}async write(e,t=this.displayName){let n=await this.log.append(this.options.identity,t,e);this.unsaved.push(n),this.refresh(!0,[n],"local");try{await this.persist()}catch(e){throw new Q(n.body.id,e)}return n.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 te(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 ne(e){if(!D(e))throw new Error("pipeup: a reaction is one emoji");return e}function oe(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 re=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 ie(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 ae=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=le(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=le(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 le(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"))})}var se=[["h","h1,h2,h3,h4,h5,h6,[role=heading]"],["img","img,svg,picture,canvas,[role=img]"],["button","button,[role=button],input[type=button],input[type=submit],input[type=reset]"],["link","a[href],[role=link]"],["field","input,select,textarea,[contenteditable=true]"],["media","video,audio,iframe,object,embed"],["p","p,li,blockquote,pre,dd,dt,figcaption,td,th,caption,summary"]];function de(e){for(let[t,n]of se)if(e.matches(n))return t;return"box"}var ce=(e,t)=>r(e).slice(0,t);function pe(e){let t=e.getAttribute("aria-label")||e.getAttribute("alt")||e.getAttribute("title")||(e.labels?.[0]?.textContent??"");if(t.trim())return ce(t,$);let n=e.getAttribute("src");if(n)return ce(function(e){let t=e.split(/[?#]/)[0]??"";return t.slice(t.lastIndexOf("/")+1)}(n),$);let o=e.getAttribute("href");return o&&!o.startsWith("javascript:")?ce(o.split("#")[0]??"",$):""}function ue(e,t){let n=[];for(let o of t.querySelectorAll("h1,h2,h3,h4,h5,h6")){if(o===e||o.contains(e)||!(o.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING))break;let t=Number(o.tagName[1]);for(;n.length&&n[n.length-1].T>=t;)n.pop();let r=ce(o.textContent??"",120);r&&n.push({T:t,text:r})}return n.slice(-3).map(e=>e.text)}function he(e,t){let n=t.getBoundingClientRect();if(!(n.height>0))return;let o=(e.getBoundingClientRect().top-n.top)/n.height;return Math.round(1e3*Math.min(1,Math.max(0,o)))/1e3}function fe(e,t){let n=pe(e),o=ue(e,t),r=he(e,t);return{kind:de(e),...n?{name:n}:{},...o.length?{heads:o}:{},...void 0!==r?{y:r}:{}}}function me(e){let t=` ${e.toLowerCase()} `,n=new Map;for(let e=0;e+3<=t.length;e++){let o=t.slice(e,e+3);n.set(o,(n.get(o)??0)+1)}return n}function ge(e,t){if(!e||!t)return e===t?1:0;let n=me(e),o=me(t),r=0,i=0;for(let e of n.values())i+=e;for(let e of o.values())i+=e;for(let[e,t]of n)r+=Math.min(t,o.get(e)??0);return i?2*r/i:0}var ve=new Map([["h","a heading"],["p","a paragraph"],["img","a picture"],["button","a button"],["link","a link"],["field","a field"],["media","a video"],["box","a box"]]),we=e=>e.kind?`it was ${e.quote?"in ":""}${ve.get(e.kind)}${e.heads?.length?` under ${e.heads.join(" \u203a ")}`:""}`:"";function ye(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 be(e,t,n){let o=(e.ownerDocument??e).createRange();return o.setStart(e,0),o.setEnd(t,n),o.toString().length}function xe(e,t,n){let o=ke(e,t,!1),r=ke(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 ke(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 Ee(e){return e.nodeType===Node.ELEMENT_NODE?e:e.parentElement}function Se(e,t){for(let n=Ee(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 $e(e,t,n){return e.slice(t,n).replace(/^[\uDC00-\uDFFF]|[\uD800-\uDBFF]$/g,"")}function Le(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 Me(e){if(!B(e))throw new Error("pipeup: could not describe this place on the page");return e}function Ce(e,t){let n=Ee(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 Ae(e,t,n){if(!t.contains(e.commonAncestorContainer))throw new Error("pipeup: the selection is outside the commentable area");let o=Se(e.commonAncestorContainer,t),a=o??t,{text:l}=ye(a),s=be(a,e.startContainer,e.startOffset),d=be(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>E)throw new Error("pipeup: selections are limited to 10000 characters");let p=$e(l,Math.max(0,s-32),s),u=$e(l,d,d+32),h=Ce(e.startContainer,t),f=ue(h,t);return Me({...o?{id:o.getAttribute("data-pipeup-id")??""}:{},path:"",quote:{exact:c,prefix:p,suffix:u},...n?{view:n}:{},fingerprint:i(h.textContent??""),snapshot:$e(r(p+c+u),0,200),kind:de(h),...f.length?{heads:f}:{}})}function Te(e,t,n,o){let a=Se(e,t);return Me({...a?{id:a.getAttribute("data-pipeup-id")??""}:{},path:Le(a??t,e),...n?{point:{x:Pe(n.x),y:Pe(n.y)}}:{},...o?{view:o}:{},fingerprint:i(e.textContent??""),snapshot:$e(r(e.textContent??""),0,200),...fe(e,t)})}function Pe(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):0}function qe(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 Ne=(e,t)=>qe(e,t,!1).pop(),Re={state:"orphaned",element:null,range:null};function De(e,t,n={}){if(e.lost)return Re;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=ye(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=Ke(i,t.prefix)+We(a,t.suffix);l>o&&(n=r,o=l)}return n}(l.text,t);if(s>=0){let r=xe(l,s,s+t.exact.length);if(r){let t=Ce(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:ye(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(qe(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=Ne(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?xe(e,n.start,n.end):null;if(r)return{state:"moved",element:Ce(r.startContainer,o),range:r}}}return Re}(e,e.quote,o,t,!1!==n.fuzzy):function(e,t,n,o){if(!t)return Re;let r=function(e,t){if(!e.path)return t;if(!e.path.startsWith(":scope > "))return null;try{return t.querySelector(e.path)}catch{return null}}(e,t);if(r&&i(r.textContent??"")===e.fingerprint)return{state:"attached",element:r,range:null};if(!e.path)return r?{state:"moved",element:r,range:null}:Re;let a=e.kind??(r?de(r):null);if(!a||!o)return Re;let{best:l,sure:s}=function(e,t,n,o,r){let i=null,a=-1,l=-1;for(let s of function(e,t){let n=se.find(([e])=>e===t)?.[1]??"*",o=[];for(let r of e.querySelectorAll(n))if(de(r)===t&&(o.push(r),o.length>=2e3))break;return o}(n,t)){let t=Ie(e,s,o,r);t>a?[i,a,l]=[s,t,a]:t>l&&(l=t)}return{best:i,sure:!!i&&a>=ze&&a-l>=Oe}}(e,a,t,n,r),d=s?l:l&&l===r?r:null;return d?d===r?{state:"moved",element:r,range:null}:{state:"moved",element:d,range:null,alike:!0}:Re}(e,o,t,!1!==n.fuzzy)}var ze=.6,Oe=.15,He=.15;function Ie(e,t,n,o){let r=t.textContent??"",a=[[.45,i(r)===e.fingerprint?1:ge(Be(r),e.snapshot)**2]];void 0!==e.name&&a.push([.25,Fe(pe(t),e.name)?1:0]),e.heads?.length&&a.push([.2,je(e.heads,ue(t,n))]);let l=void 0===e.y?void 0:he(t,n);void 0!==e.y&&void 0!==l?a.push([.1,Math.max(0,1-Math.abs(l-e.y)/He)]):void 0===e.y&&a.push([.1,t===o?1:0]);let s=0,d=0;for(let[e,t]of a)s+=e*t,d+=e;return d?s/d:0}var Be=e=>e.replace(/\s+/g," ").trim().slice(0,200),Fe=(e,t)=>e.trim().toLowerCase()===t.trim().toLowerCase();function je(e,t){return e.length===t.length&&e.every((e,n)=>Fe(e,t[n]))?1:t.length&&Fe(e[e.length-1],t[t.length-1])?.6:0}function We(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;return n}function Ke(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 Ve={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 Ue(e){let t=e.getAttribute("role")??("INPUT"===e.tagName?e.type:""),n=e.getAttribute("data-pipeup-label")||Object.hasOwn(Ve,t)&&Ve[t]||Ve[e.tagName.toUpperCase()];if(n)return n;if(_e(e))return"Block";let o=e.getBoundingClientRect(),r=o.width/o.height;return r>1.4||r<.7?"Bar":"Shape"}var Ye=e=>e.innerText||e.textContent||"";function _e(e){let t=e,n=t.labels?.[0];return et(r(e.getAttribute("aria-label")??e.getAttribute("alt")??(n&&Ye(n))??("SELECT"===e.tagName?t.selectedOptions[0]?.text:null)??(t.placeholder||Ye(e))),40)}function Ge(e){let t=e.getAttribute("data-pipeup-label");if(t)return t;let n=e.getAttribute("data-pipeup-ask");if(n)return`Ask "${n}"`;let o=_e(e);return o?`${Ue(e)} \xb7 ${o}`:Ue(e)}function Ze(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 (${[we(e),`it read: "${e.snapshot}"`].filter(Boolean).join(", ")})`,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(Qe)?.textContent;s.push(`Slide ${d}`+(e?` "${et(r(e))}"`:""))}else{let t=Xe(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(Qe)?e:[...e.querySelectorAll(Qe)].pop();if(t&&i(e)===i(t)&&(!o||n(t)))return t}return null}(l,n);o&&s.push(`Section "${et(r(o.textContent??""))}"`)}let c=Ge(l);return s.push(c),t.alike&&s.push(`Moved, not yet confirmed (${[we(e),`it read: "${e.snapshot}"`].filter(Boolean).join(", ")})`),{where:s.join(" \u203a "),element:c,id:o,within:!!o&&l.getAttribute("data-pipeup-id")!==o,quote:i,pin:a}}var Je="pipeup-edition";function Xe(e){return e?e.label||Object.entries(e).filter(([e,t])=>t&&"slide"!==e&&e!==Je).map(([,e])=>e).join(" \xb7 "):""}var Qe="h1,h2,h3";function et(e,t=60){return e.length>t?e.slice(0,t-1)+"\u2026":e}function tt(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 nt(e,t,n,o){return"ai"===t?at(e,"## ",o,n):lt(e)}function ot(e,t,n){let o=n.all?e:e.filter(e=>!e.thread.resolved);if("text"===t)return o.map(lt).join("\n");let r=e.filter(e=>e.thread.resolved).length,i=e.length-r,a=function(e){let t=[...new Set(e.flatMap(({thread:e})=>[e.root,...e.root.replies].map(e=>it(g(e)))))],n=t.length>3?[...t.slice(0,2),t.length-2+" others"]:t;return n.length>1?`${n.slice(0,-1).join(", ")} and ${n.at(-1)}`:n[0]??""}(o),l=n.exportedAt.toUTCString(),s=[`# Comments on ${it(n.title)}`,"",`${i||"No"} open comment${1===i?"":"s"}${n.all&&r?` and ${r} resolved`:""}${a?` from ${a}`:""}, copied ${l.slice(5,16).replace(/^0/,"")}, ${l.slice(17,22)} UTC.`+(n.all||!r?"":` ${r} resolved comment${1===r?" is":"s are"} left out.`),"",`Page: ${it(n.url)}`,"",""].join("\n"),d=n.exportedAt.getTime();return s+o.map((e,t)=>at(e,`## ${t+1}. `,d)).join("\n")+(o.length?"\n---\n\nFor an AI assistant: work through the open comments in order and say what you changed, or why you didn't. Each one's last line gives the thread to answer and the element's data-pipeup-id in the page's HTML. Answer in the thread with Pipeup (its pipeup-apply skill says how) and mark it addressed; never resolve it, the author does.\n":"")}function rt(e){return e.reactions.map(e=>`${e.emoji} ${e.by.length} (${e.by.map(e=>it(g(e))).join(", ")})`).join(" \xb7 ")}function it(e){return e.replace(/\s+/g," ").trim()}function at(e,t,n,o){let{thread:r,location:i}=e,a=[t+it(i.where),""];o&&a.push(`Page: ${it(o)}`,""),i.quote&&a.push(`On the words "${it(i.quote)}".`,""),i.pin&&a.push(`Pinned ${it(i.pin)}.`,""),a.push(`**${it(g(r.root))}** (${tt(r.root.at,n)}): ${st(r.root," ")}`),r.root.reactions.length&&a.push(`Reactions: ${rt(r.root)}`);for(let e of r.root.replies)a.push(`- **${it(g(e))}** (${tt(e.at,n)}): ${st(e," ")}`),e.reactions.length&&a.push(` - Reactions: ${rt(e)}`);r.addressed&&!r.resolved&&a.push("",`**${it(g(r.addressed))}** marked it addressed (${tt(r.addressed.at,n)}): ${it(r.addressed.text)}`);let l=i.id?` \xb7 ${i.within?"in":"on"} \`data-pipeup-id="${it(i.id.replace(/`/g,""))}"\``:"";return a.push("",`${r.resolved?"Resolved":r.addressed?"Open, addressed":"Open"} \xb7 thread \`${r.id}\`${l}`),a.join("\n")+"\n"}function lt(e){let{thread:t,location:n}=e,o=[it(n.where)+(n.quote?`, on the text "${it(n.quote)}"`:""),`${it(g(t.root))}: ${st(t.root," ")}`];t.root.reactions.length&&o.push(` Reactions: ${rt(t.root)}`);for(let e of t.root.replies)o.push(` ${it(g(e))}: ${st(e," ")}`),e.reactions.length&&o.push(` Reactions: ${rt(e)}`);return o.join("\n")+"\n"}function st(e,t){return e.deleted?"(deleted)":e.text.replace(/\r\n|\r|\n/g,"\n"+t)+(e.edited?" (edited)":"")}function dt(e,t){return{markdown:ot(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 ct="1.0.0",pt="2026-11-10",ut=new Map,ht=new Map,ft=new Map,mt=new Map,gt={},vt=e=>{let t=`${ut.get(e.id)??""}|${ht.get(e.id)??""}`;for(let n of[e.root,...e.root.replies]){let e=mt.get(n.id);e&&(t+=`|${n.id}:${e.text}:${e.tip??""}`)}return t};function wt(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 yt(e,t){let n=e.getRootNode().activeElement;if(t&&n instanceof HTMLElement&&e.contains(n)){let e=window.getSelection(),t=e?.rangeCount?e.getRangeAt(0):null;n.blur(),t&&!e.rangeCount&&e.addRange(t)}e.inert=t}function bt(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 xt=()=>{let e=window.getSelection();return e&&!e.isCollapsed&&e.toString().trim()?e:null};function kt(e,t){return e.length>t?e.slice(0,t-1)+"\u2026":e}function Et(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 St=/\bhttps?:\/\/[^\s<>"'`]+/gi,$t=/[\u202A-\u202E\u2066-\u2069]/;function Lt(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 Mt(e){let t=[],n=0;for(let o of e.matchAll(St)){if(o[0].length>2048||$t.test(o[0]))continue;let r,i=Lt(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=wt("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 Ct="http://www.w3.org/2000/svg",At={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"],browser:["M4 7a3 3 0 0 1 3-3h10a3 3 0 0 1 3 3v10a3 3 0 0 1-3 3H7a3 3 0 0 1-3-3z","M4 9.5h16M7.5 6.8h.01"],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 Tt(e,t=15,n){let o=Pt(At[e],t);return n&&o.setAttribute("stroke-width",String(n)),o}function Pt(e,t){let n=document.createElementNS(Ct,"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(Ct,"path");e.setAttribute("d",t),n.append(e)}return n}var qt=(e,t,n)=>`M${e} ${t}a${n} ${n} 0 1 0 ${2*n} 0a${n} ${n} 0 1 0 -${2*n} 0`,Nt={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${qt(7.4,11.5,1.9)}${qt(12.8,11.5,1.9)}M11.3 14.6l.7 1 .7-1`,Bear:`${qt(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:`${qt(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 Rt(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 Dt=(e,t)=>Rt(t)||m(e);function zt(e,t){return w(t)?wt("span",{class:"av ai","data-pipeup-ai":"","aria-hidden":"true"},"AI"):wt("span",{class:`av c${f(e)}`,"aria-hidden":"true","data-animal":m(e)},Rt(t)||Pt([Nt[c[h(e)]]],24))}function Ot(e,t){setTimeout(()=>{e.remove(),t?.()},320)}function Ht(e){return requestAnimationFrame(()=>{e.offsetWidth,e.classList.add("in")}),e}var It=new Map;function Bt(e){It.clear();for(let[t,n]of Object.entries(e??{}))void 0!==n&&It.set(t,n)}function Ft(e){return It.has(e)?It.get(e):typeof document>"u"?null:document.querySelector(`script[${e}]`)?.getAttribute(e)??document.documentElement.getAttribute(e)}var jt=e=>null!==Ft(e),Wt=/^[A-Za-z0-9_-]{43}$/,Kt=/^(?:host|gh):[A-Za-z0-9._@-]{1,64}$/,Vt=[],Ut=new Set,Yt=()=>(Ft("data-pipeup-agents")??"").split(/[\s,]+/).filter(e=>Wt.test(e));function _t(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 Yt())o({ref:e,name:"AI agent",agent:!0});for(let e of Vt)o(e);return[...n.values()].sort((e,t)=>e.name.localeCompare(t.name))}var Gt=(e,t)=>!!e.mentions?.some(e=>t.includes(e.ref)),Zt=[],Jt=e=>[e,...Zt],Xt=null,Qt=null,en=new WeakMap,tn=new WeakSet;function nn(e,t){Xt=e,Qt=t}function on(e){if(!Xt)return;let t=Xt(e,t=>{tn.add(t),e.dispatchEvent(t)});t&&(en.set(t,e),e.before(t))}function rn(e){return e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement?e:(e&&en.get(e))??null}function an(e){let t=rn(e);return t instanceof HTMLTextAreaElement?t:null}function ln(e,t,n){window.addEventListener(e,t,n);let o=Qt,r=e=>{tn.has(e)&&t(e)};return o?.addEventListener(e,r,n),()=>{window.removeEventListener(e,t,n),o?.removeEventListener(e,r,n)}}var sn=null,dn=e=>{sn=e},cn="pu-source";function pn(e){let t=wt("textarea",{class:"input",dir:"auto",rows:"1",autocomplete:"off","aria-label":e.name??e.label,placeholder:e.placeholder??""}),n=wt("button",{class:"send",type:"button",inert:!0},e.label),o=wt("button",{class:"cnl",type:"button"},"Cancel"),r=wt("span",{class:"tools"});r.hidden=!0;let i=wt("div",{class:"line"},t,r),a=wt("div",{class:"row"},i,wt("div",{class:"bts"},e.lead??null,o,n));on(t);let l=e.kind??"comment",s=!1,d=new Set,c=()=>{for(let e of[...d])e()},p=()=>{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`},u=()=>{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),p()};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,p()}}},h=new Map,f=()=>{let n=(sn?.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=wt("button",{class:"ib tool",type:"button","aria-label":o.label,title:o.label,"aria-pressed":"false"},Pt(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:u,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(cn,f);let m=[],g=wt("ul",{class:"mnl",role:"listbox","aria-label":"People"}),v=wt("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(),p()},$=async()=>{let o=t.value.trim();if(o&&!s){s=!0;try{await e.z(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(),p(),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",()=>{p(),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=wt("li",{role:"option",id:`${w}-${t}`,class:e.agent?"agent":""},wt("span",{},e.name),e.agent?wt("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="",p(),(!n||"reply"!==l)&&t.blur(),c(),e.U?.(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(p)),{element:a,input:t,focus:()=>t.focus({preventScroll:!0})}}var un=["sync","menu","notify","note","composer","panel","styles","status","overlay","here","sign","listnote","commentmark","reactions","identity","dialog","paste","place","post"],hn=/^[a-z][a-z0-9-]{1,23}$/,fn=["text","muted","faint","line","surface","soft","hover","shadow","ease"],mn=["pointerdown","pointerup","keydown","click"],gn=new Set(["local","file","page","user","pipeup","presence","sync"]),vn="data-pipeup-placed",wn=`[data-pipeup-ask][${vn}]>:not(pipeup-place){display:none}`,yn=class{constructor(e,t,n){this.ctx=e,this.shadow=t,this.after=n,dn({tools:()=>this.Q,note:()=>[...this.le.values()].at(-1)??null,reporting:()=>this.J.size>0});for(let e of mn)window.addEventListener(e,this.Me,!0)}ae=0;j=[];le=new Map;writing=new Map;marked=new Map;paint=0;J=new Map;listNotes=new Map;picker=null;pickerOwner="";Q=[];ce=new Set;W=new Set;ee=new Set;te=new Map;$=new Map;D=new Map;remote={n:0,who:new Set};last=0;timer=0;Se="";R=new Map;placeRoots=new WeakMap;de=null;Le=!1;Te=[];Me=e=>{e.isTrusted&&(this.Te=e.composedPath())};subscribe(e){return this.ee.add(e),()=>{this.ee.delete(e)}}changed(e){e&&this.ae++;for(let t of[...this.ee])t(e);for(let e of this.ctx.e.querySelectorAll(".row, .draft"))e.dispatchEvent(new Event(cn))}B(e,t){let n=this.D.get(e)??this.D.set(e,new Set).get(e),o=()=>{n.delete(o)&&t()};return n.add(o),o}Ae(){return[...this.J.values()].map(e=>e.text).join(" \xb7 ")}qe(e,t){return this.j.push(t),this.changed(!0),{update:()=>this.changed(!1),remove:this.B(e,()=>{this.j.splice(this.j.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?(ut.delete(t),o.delete(t)):(ut.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(ft.delete(t),!ht.delete(t))return;r.delete(t)}else{if(ht.get(t)===n&&!!ft.get(t)==!!o)return;ht.set(t,n),o?ft.set(t,o):ft.delete(t),r.add(t)}this.repaint()}setCommentMark(e,t,n){let o=mt.get(t);if(null===n){if(o?.by!==e)return;mt.delete(t)}else{let r=String(n.text),i=void 0===n.tip?void 0:String(n.tip);if(o?.by===e&&o.text===r&&o.tip===i)return;mt.set(t,{text:r,tip:i,by:e})}this.repaint()}repaint(){this.paint||(this.paint=window.requestAnimationFrame(()=>{this.paint=0,this.ctx.m()}))}pe(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)}Ke(e,t){return this.Q.push(t),this.changed(!1),this.B(e,()=>{this.Q.splice(this.Q.indexOf(t),1),this.changed(!1)})}closed(){return this.ctx.state.hidden&&!this.ctx.state.s}Ve(e,t){this.closed()?this.$.set(e,t):this.ctx.ue(t)}flush(){if(this.closed()||0===this.$.size)return;let e=[...this.$.values()].at(-1);this.$.clear(),this.ctx.ue(e)}_e(){return!!an(this.shadow.activeElement)||[...this.ctx.e.querySelectorAll("textarea")].some(e=>""!==e.value.trim())}ze(e){this.ctx.state.hidden||this.ctx.M(e)}Ue(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.Ce()}}Ce(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._e())return this.Ce(1e3);let{n:e,who:t}=this.remote;this.remote={n:0,who:new Set},this.last=Date.now(),this.ctx.M(`${e} new comment${1===e?"":"s"} from ${1===t.size?[...t][0]:`${t.size} people`}`)},e))}je(e){let t=this.te.get(e);return t||(t=wt("div",{class:"ov","aria-hidden":"true","data-addon":e}),this.ctx.e.insertBefore(t,this.after.nextSibling),this.te.set(e,t)),t}We(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(wt("style",{},t));return this.B(e,()=>o?this.shadow.adoptedStyleSheets=this.shadow.adoptedStyleSheets.filter(e=>e!==o):r.remove())}Pe(e,t,n){return t.add(n),this.B(e,()=>t.delete(n))}Ge(e,t){return this.Pe(e,this.ce,t)}Ye(e,t){let n=this.Pe(e,this.W,t);return this.call(this.W,t,this.Oe()),n}Oe(){let{state:e}=this.ctx,t=this.shadow.activeElement;return{shown:!e.hidden,commentMode:e.l,allOpen:e.u,dark:this.ctx.e.classList.contains("dark"),view:this.ctx.f.view(),writing:an(t)?an(t).closest("[data-thread]")?.dataset.thread??"":null}}Xe(){let e=new Set;for(let t of this.R.values())for(let n of t.keys())e.add(n.getAttribute("data-pipeup-id")??"");return e}place(e,t){let n=this.R.get(e)??this.R.set(e,new Map).get(e),o=n.get(t);if(o)return this.placeRoots.get(o);if(!(t instanceof Element)||!t.matches("[data-pipeup-ask],[data-pipeup-inline]")||!this.ctx.root.contains(t)||t.closest(`[${vn}]`))throw new Error("pipeup: not an element marked for add-ons");let r=t.ownerDocument;this.de??=this.Ze(r,wn);let i=r.createElement("pipeup-place"),a=i.attachShadow({mode:this.shadow.mode});this.placeRoots.set(i,a);let l=":host{all:initial;display:block;font:14px/1.5 var(--pu-font,system-ui,sans-serif);color:var(--pu-text)}",s=r.defaultView?.CSSStyleSheet;if(s&&"adoptedStyleSheets"in a){let e=new s;e.replaceSync(l),a.adoptedStyleSheets=[e]}else a.append(wt("style",{},l));return this.$e(i),t.setAttribute(vn,""),t.append(i),n.set(t,i),this.B(e,()=>{i.remove(),t.removeAttribute(vn),n.delete(t),[...this.R.values()].some(e=>e.size)||(this.de?.(),this.de=null),this.repaint()}),this.repaint(),a}$e(e){let t=getComputedStyle(this.ctx.e);for(let n of fn)e.style.setProperty(`--pu-${n}`,t.getPropertyValue(`--pu-${n}`))}Ze(e,t){let n=e.defaultView?.CSSStyleSheet;if(n&&"adoptedStyleSheets"in e){let o=new n;return o.replaceSync(t),e.adoptedStyleSheets=[...e.adoptedStyleSheets,o],()=>{e.adoptedStyleSheets=e.adoptedStyleSheets.filter(e=>e!==o)}}let o=e.head.appendChild(wt("style",{},t));return()=>o.remove()}Je(e){let t=[...this.R.get(e)?.values()??[]];return!1!==navigator.userActivation?.isActive&&this.Te.some(n=>t.includes(n)||n instanceof HTMLElement&&n.dataset.addon===e)}async post(e,t){if(!this.Je(e))throw new Error("pipeup: not sent by the reviewer here");let{doc:n,root:o,f:i}=this.ctx;if(t.remove)return await n.remove(t.remove),t.remove;let a=String(t.text??"");if(t.edit)return await n.edit(t.edit,a),t.edit;if(t.replyTo)return n.reply(t.replyTo,a);let l=t.anchor;if(!l||!this.R.get(e)?.has(l)||!l.getAttribute("data-pipeup-id"))throw new Error("pipeup: not a marked block with a data-pipeup-id");let s=Te(l,o,void 0,i.view(l));return t.excerpt&&(s.snapshot=r(t.excerpt).slice(0,200)),n.comment(s,a)}N(){let e=this.ctx.e.classList.contains("dark");if(e!==this.Le){this.Le=e;for(let e of this.R.values())for(let t of e.values())this.$e(t)}for(let e of[...this.ce])this.call(this.ce,e);if(0===this.W.size)return;let t=this.Oe(),n=JSON.stringify(t);if(n!==this.Se){this.Se=n;for(let e of[...this.W])this.call(this.W,e,t)}}call(e,t,...n){try{t(...n)}catch(n){e.delete(t),globalThis.reportError?.(n)}}Qe(e,t,n){let o=this.ctx.e,r=this.shadow.activeElement,i=wt("button",{class:"ib",type:"button","aria-label":"Close"},Pt(["M6 6l12 12M18 6L6 18"],15)),a=wt("div",{class:"xp",role:"dialog","aria-label":n.label,"data-addon":e},wt("div",{class:"hd"},wt("span",{},n.label),i),wt("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.B(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=wt("div",{class:"dlg",role:"dialog","aria-label":n,"data-addon":e},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.B(e,()=>o.remove()),{close:i}}clear(e){for(let t of[...this.D.get(e)??[]])t();this.D.delete(e),this.te.get(e)?.remove(),this.te.delete(e);for(let t of[this.le,this.J,this.listNotes,this.$])t.delete(e);this.setPicker(e,null);for(let t of this.writing.get(e)??[])ut.delete(t);this.writing.delete(e);for(let t of this.marked.get(e)??[])ht.delete(t),ft.delete(t);this.marked.delete(e),this.R.delete(e);for(let[t,n]of mt)n.by===e&&mt.delete(t);this.repaint(),this.changed(!0)}destroy(){for(let e of mn)window.removeEventListener(e,this.Me,!0);window.clearTimeout(this.timer),dn(null),this.ee.clear()}},bn=new Map,xn=null,kn=(()=>{let e=globalThis.Pipeup;return e?.VERSION?e:null})();function En(){return kn?kn.addons():[...bn.values()].map(e=>({...e.info}))}function Sn(e){if(kn)return kn.use(e);let t=e=>console.warn(`pipeup: ${e}`),n=e;if(!n||"object"!=typeof n||"string"!=typeof n.id||!hn.test(n.id)||gn.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(bn.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=>!un.includes(e));!function(e){let t=Ft("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};bn.set(n.id,i),xn?.i&&"waiting"===o.state&&Ln(i,xn)}function $n(){if(kn)return!0;let e=globalThis,t=e.pipeupAddons;if(Array.isArray(t))for(let e of t)Sn(e);else if(t&&"object"==typeof t&&t.push!==Sn)return!1;return e.pipeupAddons={push:Sn},!0}async function Ln(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,p=Object.assign(()=>{},{update(){},remove(){},close(){}}),u=e=>(...t)=>c()?e(...t):p,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,...t.keep?{keep:{get:e=>t.keep.get(`${f}:${e}`),set:(e,n)=>t.keep.set(`${f}:${e}`,n)}}:{},signal:a.signal,has:e=>un.includes(e),off:e=>{o=String(e)},merge:e=>c()?d.merge(e,f):Promise.resolve(0),addMenuItem:u(e=>s.qe(f,e)),notify:u(e=>s.Ve(f,e)),announce:u(e=>s.ze(e)),setComposerNote:u(e=>s.pe(s.le,f,e)),setThreadNote:u((e,t)=>s.setThread(f,e,t)),setThreadMark:u((e,t,n)=>s.setMark(f,e,t,n)),setCommentMark:u((e,t)=>s.setCommentMark(f,e,t)),addComposerTool:u(e=>s.Ke(f,e)),openPanel:u((e,t)=>s.Qe(f,e,t)),addStyles:u(e=>s.We(f,e)),setStatus:u(e=>s.pe(s.J,f,e)),setListNote:u(e=>s.pe(s.listNotes,f,e)),setReactionPicker:u(e=>s.setPicker(f,e)),overlay:()=>s.je(f),onFrame:u(e=>s.Ge(f,e)),where:e=>s.ctx.f.view(e),isHere:e=>s.ctx.f.S(e),go:e=>s.ctx.f.ne(e),onUi:u(e=>s.Ye(f,e)),avatar:(e,t)=>{let n=zt(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:u((e,t)=>s.dialog(f,e,t)),paste:(e,t,n,o)=>c()?d.paste(e,t,n,o):Promise.reject(new Error("pipeup: this add-on is off")),place:e=>{if(!c())throw new Error("pipeup: this add-on is off");return s.place(f,e)},post:e=>c()?s.post(f,e):Promise.reject(new Error("pipeup: this add-on is off"))},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",i.reason=o,void console.warn(`pipeup: the add-on "${f}" is off: ${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 Mn=typeof navigator<"u"&&/Mac|iP(hone|ad|od)/.test(navigator.platform)?"\u21e7\u2325C":"Shift+Alt+C",Cn=" ",An="Shift+Alt+C",Tn="Comments stay in this browser until you send them.";var Pn=new WeakMap;function qn(e,t){let n=Pn.get(t)??function(e){let t=wt("button",{class:"me",type:"button",tabindex:"-1","aria-hidden":"true"});t.addEventListener("mousedown",e=>e.preventDefault());let n=wt("span",{class:"here",role:"img","aria-label":Tn,title:Tn},Tt("browser",14)),o=pn({label:"Comment",placeholder:"Comment or add others with @",kind:"comment",z:e.z,U:e.U,people:e.people,lead:n}),r=wt("div",{class:"note"}),i=()=>{let e=sn?.note()??null;r.textContent=e??"",r.hidden=!e;let t=!!e||(sn?.reporting()??!1);n.classList.toggle("off",t),n.setAttribute("aria-hidden",String(t))};i();let a=wt("div",{class:"say"}),l=wt("input",{class:"input",type:"text",maxlength:"80","aria-label":"Your name"}),s=wt("div",{class:"nf"},l);on(l);let d=wt("div",{class:"you"},a,s),c="",p=!1,u=!1,h=()=>{let n=e.name(),o=n?"change":"add your name";if(t.title=n?"Change your name":"Add your name",!t.lastChild||c!==n){let o=zt(e.me,n),r=t.lastChild;r?(Ht(o),Ot(r)):o.classList.add("in"),t.append(o),c=n}let r=wt("button",{type:"button"},o);r.addEventListener("click",g),a.replaceChildren(wt("span",{class:"nm"},n||`You're ${m(e.me)}`)," \xb7 ",r)},f=e=>{u=e,d.classList.toggle("naming",e),yt(a,e),yt(s,!e)};function g(t){t.stopPropagation(),l.value=e.name(),f(!0),l.focus({preventScroll:!0}),l.select()}let v=(e=!0)=>{f(!1),e&&o.focus()},w=t=>{let n=l.value.trim();if(!n||n===e.name())return v(t);p||(p=!0,e.rename(n).finally(()=>{p=!1,h(),v(t)}))};t.addEventListener("click",g),l.addEventListener("keydown",e=>{e.stopPropagation(),"Escape"!==e.key||e.isComposing?"Enter"===e.key&&(e.preventDefault(),w(!0)):(e.preventDefault(),v())}),l.addEventListener("blur",()=>{u&&!p&&w(!1)}),h(),f(!1);let y=wt("div",{class:"ctx"},e.label),b=wt("div",{class:"draft"},wt("div",{class:"hdr"},t,d),y,r,o.element);return b.addEventListener(cn,i),{element:b,fe:()=>{let{selectionStart:e,selectionEnd:t}=o.input;return()=>{o.focus(),o.input.setSelectionRange(e,t)}},oe:e=>{y.hidden=e},he:e=>{y.textContent=e},focus:()=>o.focus(),et:()=>""===o.input.value.trim(),fill:e=>{o.input.value=e,o.input.dispatchEvent(new Event("input")),o.focus(),o.input.setSelectionRange(e.length,e.length)}}}({label:t.label,me:e.doc.me,name:()=>e.s.name(),rename:t=>e.s.rename(t),z:(t,n)=>e.tt(t,n),people:()=>e.people(),U:t=>e.ge(t)});return Pn.set(t,n),e.F(n),n}var Nn="a,button,input,select,textarea,label,summary,[role=button],[contenteditable]";function Rn(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(Nn))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 Dn(e){return e.range?[...e.range.getClientRects()]:[]}function zn(e,t){let n=Dn(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 On(e,t){let n=Dn(t).at(-1);if(n)return{x:n.left,y:n.bottom,below:!0,p:n};let o=Rn(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 Hn(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 In=()=>window.innerWidth>=900?400:300,Bn=()=>window.innerWidth<=480,Fn=()=>!0===window.matchMedia?.("(pointer: coarse)").matches,jn=0;function Wn(){let e=window.visualViewport,t=e?Math.max(0,e.offsetTop-jn):0;return{top:t,bottom:e?Math.min(window.innerHeight,t+e.height):window.innerHeight}}var Kn=(e,t,n,o)=>n.keep&&e+t>n.keep.left?Math.min(n.height-o,n.keep.top-8):n.height-o;function Vn(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<=Kn(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 p=Kn(s,t.width,n,o),u=(n.top??0)+o,h=a+t.height<=p||l<u;return{above:!h,left:s,top:Math.max(u,Math.min(h?a:l,p-t.height))}}function Un(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 Yn(e,t){let n=e.resolved.get(t.id);return n?.range?.startContainer??n?.element??null}var _n=e=>(t,n)=>{let o=Yn(e,t),r=Yn(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},Gn=["\u{1f44d}","\u2764\ufe0f","\u{1f602}","\u{1f389}","\u{1f62e}","\u{1f64f}"],Zn={"\u{1f44d}":"Thumbs up","\u2764\ufe0f":"Heart","\u{1f602}":"Laughing","\u{1f389}":"Party popper","\u{1f62e}":"Surprised","\u{1f64f}":"Thanks"};var Jn={confirmed:"confirmed the place",moved:"moved this comment",gone:"marked the place as gone"},Xn=e=>`${e} ${1===e?"reply":"replies"}`,Qn=e=>e.root.replies.filter(e=>!e.deleted);function eo(e,t,n){let o={...n},r="card"===o.q,i=e.id,a=wt("div",{class:"rbox always"},wt("div",{},pn({label:"Reply",placeholder:"Reply or add others with @",kind:"reply",thread:()=>i,people:()=>t.people(),z:(e,n)=>t.reply(i,e,n),U:e=>e?t.drop(i,e):t.close()}).element)),l=wt("div",{}),s=wt("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=wt("div",{}),c=null,p=null,u=null,h="",f=null,m="",y=wt("div",{},d,r?null:wt("div",{class:"more"},l)),b=new Set,x="",k="",E="",S=0,$=null,L=new Set,M=e,C=new Map,A=new Map,T=new Map,P=new Map,q=new Map,N=(e,t,n)=>{let o=wt("button",{class:"ib",type:"button","aria-label":t,title:t},Tt(e,18,"more"===e?2.6:void 0));return o.addEventListener("click",e=>{e.stopPropagation(),n()}),o},R=e=>y.querySelector(e)?.focus({preventScroll:!0}),D=!1,z=()=>{!D&&(x||b.size)&&!y.contains(y.getRootNode().activeElement)&&(x=E="",b.clear(),O(M))};function O(e,n={}){let D=y.getRootNode().activeElement,z=D&&y.contains(D)?D.dataset.k:void 0;(function(e,n){Object.assign(o,n);let D=k;k=x,i=e.id,M=e;let z=(o.now??Date.now)(),H=Qn(e),I=H.length,B=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||$t.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 Mt(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?wt("i",{class:"sl"}):null,wt("span",{},t||""===e.label?n:`[${e.n}] ${n}`),e.says?wt("span",{class:"rc",role:"tooltip"},e.says):null];if(/^https?:/.test(e.to)){let t=wt("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=wt("button",{class:"ref",type:"button",title:e.says?void 0:t?n:`Show where: ${n}`},...o);return r.addEventListener("click",t=>{t.stopPropagation(),gt.go?.(e.to)}),r});return[...Mt(n),wt("div",{class:"refs"},...o)]}(t):Mt(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(wt("span",{class:Gt(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))]},F=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=wt("button",{class:`ref rx${r?" mine":""}${t.seen.has(l)?"":" new"}`,type:"button","aria-pressed":String(r),"aria-label":`${t.picker?.name(o.emoji)??Zn[o.emoji]??"Reaction"}, ${i} ${1===i?"person":"people"}${r?", including you":""}`,"data-k":`x${e.id}${o.emoji}`},wt("span",{},o.emoji),wt("span",{class:"n"},String(i)),wt("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?wt("div",{class:"rxq"+(t.seen.has(`${e.id}|quick`)?"":" new"),role:"group","aria-label":"React","data-q":e.id},...Gn.map(o=>{let r=wt("button",{class:"rxo",type:"button","aria-label":Zn[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=wt("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=wt("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)||p()},p=()=>{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(),p())}),d.off=t.fill(l,e=>{p(),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`),wt("div",{class:"refs rxs"},...o,r)}(n,{me:t.me,picker:t.picker(),resolved:e.resolved,quick:b.has(n.id),bare:r,seen:L,react:(e,o)=>{b.delete(n.id),t.react(n.id,e,o),O(M),R(`[data-r="${n.id}"]`)}}),j=e.resolved?"Resolved"+(I?` \xb7 ${Xn(I)}`:""):e.addressed?"Addressed"+(I?` \xb7 ${Xn(I)}`:""):I?Xn(I):"",W=(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=()=>{$=null,O(M),R(`[data-c="${e.id}"]`)},o=pn({label:"Save",name:"Edit comment",kind:"comment",value:e.text,people:()=>t.people(),z:async(o,r)=>{await t.edit(e.id,o,r),n()},U:n});$={id:e.id,o:wt("div",{class:"edit"},o.element)},queueMicrotask(()=>o.focus())}(n),!1)],[E===n.id?"Delete for everyone":"Delete",()=>E!==n.id?(E=n.id,S=performance.now(),!0):performance.now()-S<500||(E="",t.remove(n.id),!1)]),!r.length)return null;let i=wt("div",{class:D===n.id?"pm":"pm in",role:"menu","data-m":n.id},...r.map(([e,t],o)=>{let r=wt("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()||(x=""),O(M);let r=y.querySelectorAll(".pm button")[o];r?r.focus():y.contains(y.getRootNode().activeElement)||y.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;x=E="",O(M),R(`[data-c="${n.id}"]`)}e.preventDefault(),e.stopPropagation()}),i},K=(n,o)=>{let i=W(n,o),a=i?N("more","More",()=>{x=x===n.id?"":n.id,E="",O(M),y.querySelector(x?".pm button":`[data-c="${n.id}"]`)?.focus()}):null;return a&&(a.setAttribute("aria-expanded",String(x===n.id)),a.dataset.c=n.id,a.dataset.k=`m${n.id}`),wt("div",{class:"hdr"},...(e=>{let t=Dt(e.author,e.name),n=C.get(e.id),o=n?.o;if((!o||n.key!==t)&&(o=Ht(zt(e.author,e.name)),n)){let t=n.o;q.set(e.id,t),Ot(t,()=>q.get(e.id)===t&&q.delete(e.id))}o.title=g(e),A.set(e.id,{key:t,o});let r=q.get(e.id);return r?[r,o]:[o]})(n),wt("span",{class:"who"},g(n)),t.pasted?.(n)?wt("span",{class:"ago pst"},t.pasted(n)):null,wt("span",{class:"ago",title:new Date(n.at).toLocaleString()},tt(n.at,z)),r?U(n,!0):null,wt("span",{class:"acts"},(t=>{if(e.resolved||t.deleted)return null;let n=N("smile","React",()=>{let e=!b.delete(t.id);e&&b.add(t.id),O(M),R(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?N("reopen","Reopen",()=>{t.reopen(e.id)}):N("resolve","Resolve",()=>{t.resolve(e.id)}):null,a),x===n.id?i:null)},V=e=>$?.id===e.id?$.o:(e=>wt("div",{class:e.deleted?"tx del":"tx",dir:"auto"},...e.deleted?["Deleted"]:[...B(e),e.edited?" (edited)":""]))(e),U=(e,t=!1)=>{let n=mt.get(e.id),o=T.get(e.id),r=n??o;if(!r)return null;n&&P.set(e.id,n);let i="cm"+(n?o?"":" new":" out");return t?wt("span",{class:i,role:"img","aria-label":r.text,title:r.tip??r.text},Tt("browser",13)):wt("div",{class:i,title:r.tip},Tt("browser",13),r.text)},Y=o.quote?`\u201c${kt(o.quote,80)}\u201d`:"",_=o.note&&!o.moved?o.note:o.lost?`${o.place||["No longer on the page",we(e.anchor)].filter(Boolean).join(" \xb7 ")} \u2014 it read \u201c${kt(o.lost,120)}\u201d`:o.moved?`Moved \xb7 ${Y||`it read \u201c${kt(e.anchor.snapshot,80)}\u201d`}`:Y,G=r?o.rest:"column"===o.q&&j;A=new Map,P=new Map;let Z=wt("div",{class:"root"},K(e.root,!0),_?wt("div",{class:"ctx"},_):null,V(e.root),"column"===o.q&&wt("div",{class:"mr","aria-hidden":"true"},wt("span",{},"more")),r?null:U(e.root),F(e.root),G?wt("div",{class:"rest"},G):null);if(d.replaceWith(Z),d=Z,y.className=e.resolved?"thread resolved":"thread",y.setAttribute("data-thread",e.id),r)return C=A,void(T=P);c?.remove();let J=ut.get(e.id);c=I||void 0!==J?wt("div",{class:"rps"},...H.map(e=>wt("div",{class:"it"},K(e,!1),V(e),U(e),F(e))),void 0===J?null:wt("div",{class:"it ghost","data-pipeup-writing":"row"},wt("div",{class:"hdr"},zt("",v),wt("span",{class:"who"},v),wt("span",{class:"ago"},"writing now")),wt("div",{class:"tx",dir:"auto","data-pipeup-writing":"words"},J))):null,c&&l.prepend(c);let X=e.addressed&&!e.resolved?e.addressed:null,Q=X?`${X.text}|${X.author}|${X.at}`:"";if(Q!==h&&(u?.remove(),u=null,h=Q,X)){let n=(e,t)=>{let n=wt("button",{type:"button"},e);return n.addEventListener("click",e=>{e.stopPropagation(),t()}),n};u=wt("div",{class:"adr"},wt("small",{},["Addressed",g(X),t.pasted?.(X),tt(X.at,z)].filter(Boolean).join(" \xb7 ")),X.text,wt("div",{class:"go"},n("Resolve",()=>{t.resolve(e.id)}),n("Still not right",()=>{t.notRight(e.id)})))}u&&l.insertBefore(u,p??(a.parentNode===l?a:null));let ee=!r&&!!t.place&&!!o.alike,te=!(r||!t.place||!o.lost||o.place),ne=e.placed&&!ee?`${g(e.placed)} ${Jn[e.placed.how]}`:"",oe=`${ee}|${te}|${ne}`;if(oe!==m){f?.remove(),m=oe;let n=(n,o)=>{let r=wt("button",{type:"button"},n);return r.addEventListener("click",n=>{n.stopPropagation(),t.place?.(e.id,o)}),r};f=ee||te||ne?wt("div",{class:"adr"},ne&&wt("small",{},ne),ee&&"Is this the right place?",(ee||te)&&wt("div",{class:"go"},...ee?[n("Yes","confirmed"),n("Not here","pick"),n("It's gone","gone")]:[n("Show where it belongs","pick")])):null}f&&l.insertBefore(f,u??p??(a.parentNode===l?a:null)),p?.remove();let re=ht.get(e.id),ie=ft.get(e.id);if(p=void 0===re?null:wt("div",{class:"seen"},wt("i"),re),p&&ie){let e=wt("button",{type:"button"},"Check again");e.addEventListener("click",e=>{e.stopPropagation(),ie()}),p.append(e)}p&&l.insertBefore(p,a.parentNode===l?a:null),C=A,T=P;let ae=""!==a.querySelector("textarea").value.trim();s.hidden=!(e.resolved&&ae),e.resolved&&!ae?a.remove():a.parentNode!==l&&l.append(a)})(e,n),z&&!y.contains(y.getRootNode().activeElement)&&y.querySelector(`[data-k="${CSS.escape(z)}"]`)?.focus({preventScroll:!0})}return y.addEventListener("pointerdown",()=>{D=!0;let e=()=>{removeEventListener("pointerup",e,!0),removeEventListener("pointercancel",e,!0),setTimeout(()=>{D=!1,z()})};addEventListener("pointerup",e,!0),addEventListener("pointercancel",e,!0)}),y.addEventListener("focusout",e=>{y.contains(e.relatedTarget)||setTimeout(z)}),O(e),{element:y,update:O}}function to(e,t=!1){let n=e.ownerDocument.documentElement,o=Ft("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(jt("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 no(e,t){if(e.E(t))return!1;let n=e.resolved.get(t.id);return!n||"orphaned"===n.state&&!e.$.has(t.id)}var oo=(e,t)=>!e.E(t)&&"moved"===e.resolved.get(t.id)?.state,ro=(e,t)=>oo(e,t)&&!!e.resolved.get(t.id)?.alike;function io(e){let t=wt("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=>no(e,t);function l(t){let n=e.resolved.get(t.id),o=n?zn(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,C:n,height:o.o.offsetHeight}):i.push({id:t,height:o.o.offsetHeight})}let a=e.state.t,s=a?zn(a.anchor,a.resolved):null;o&&null!==s&&r.push({id:"draft",C:s+window.scrollY-4,height:o.o.offsetHeight});let c=o?"draft":e.state.i,p=r.find(e=>e.id===c),u=t.getBoundingClientRect().right>window.innerWidth-44?44:0;p&&(u||o)&&(p.C=Math.max(window.scrollY+8,Math.min(p.C,window.scrollY+window.innerHeight-u-10-p.height)));let h=function(e,t,n=10){let o=[...e].sort((e,t)=>e.C-t.C),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.C:Math.max(e.C,(r[t-1]??0)+a(t-1).height+n)});else{r[i]=a(i).C;for(let e=i+1;e<o.length;e++)r[e]=Math.max(a(e).C,(r[e-1]??0)+a(e-1).height+n);for(let e=i-1;e>=0;e--)r[e]=Math.min(a(e).C,(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 p(t,n){t.thread=n,t.note=vt(n),t.lost=a(n),t.moved=oo(e,n),t.view.update(n,{lost:t.lost?n.anchor.snapshot:null,moved:t.moved,alike:ro(e,n)})}function u(n){let o=a(n),i=eo(n,e.K,{q:"column",lost:o?n.anchor.snapshot:null,moved:oo(e,n),alike:ro(e,n)}),l=wt("div",{class:"th wait","data-thread":n.id},wt("button",{class:"opn sr",type:"button","data-thread":n.id}),i.element);return l.addEventListener("mouseenter",()=>e.L(n.id)),l.addEventListener("mouseleave",()=>e.L(null)),l.addEventListener("click",()=>e.open(n.id)),t.append(l),r.observe(l),{o:l,thread:n,lost:o,moved:oo(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){yt(t,e.state.u);let l=new Set,s=null!==e.state.i||null!==e.state.t;for(let t of i){if(!e.G(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!==oo(e,t)||o.note!==vt(t))&&p(o,t):(o=u(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=Qn(t).length;d.setAttribute("aria-label",`Open thread: ${kt(t.root.text,60)}, ${Xn(c)}`),d.setAttribute("aria-expanded",String(i)),yt(d,i);let h=r.querySelector(".more");h&&yt(h,!i),r.classList.toggle("dim",s&&!i),r.classList.toggle("hot",e.state.L===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.F(null)),!n)return;let i=!o;if(o)o.p.he(n.label);else{let i=qn(e,n),a=wt("div",{class:"th on wait"},i.element);t.append(a),r.observe(a),o={o:a,p:i,of:n}}o.p.oe(e.state.l&&!n.anchor.quote&&!n.anchor.point),i&&o.p.focus()})(),bt(t,i.filter(e=>l.has(e.id)).sort(_n(e)).map(e=>n.get(e.id).o),o?.o??null)&&t.offsetWidth,c()},N:function(){let n=to(e.root,!0);n&&(t.style.width=`${n.width}px`,t.style.transform=`translate(${n.x}px, ${-window.scrollY}px)`)},destroy(){r.disconnect(),e.F(null),t.remove()}}}var ao=22;function lo(e,t){let n=new Map,o=wt("div",{class:"tip",role:"tooltip"}),r=wt("div",{class:"mark"}),i=wt("div",{class:"pop",role:"dialog","aria-label":"Comment thread"});o.inert=i.inert=!0,e.e.append(r,o,i);let a,l=wt("div",{class:"bub pin ghost","aria-hidden":"true"}),s=[],d=null,c=null,p=!1,u=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.ve||e.state.u,k=!1,E=t=>{let n=e.resolved.get(t.id);return n?On(t.anchor,n):null},S=()=>{let t=function(e){let t=window.innerWidth,n=Wn();return{width:e&&!Bn()?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.l&&Fn()?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 Vn(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=Kn(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 yt(o,!0);if(w!==n.id){let e=Qn(n).length;o.replaceChildren(wt("div",{class:"tx clamp",dir:"auto"},...n.root.deleted?["Deleted"]:Mt(n.root.text)),wt("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.L(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=wt("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=u&&t&&!t.anchor.quote&&!t.anchor.point?t.resolved.element:null;if(n){let{left:e,top:t,above:o}=Vn(n.getBoundingClientRect(),{width:i.offsetWidth||In(),height:i.offsetHeight},S(),12,Fn()?60:44),r=null!==u?.above&&u?.above!==o;if(u&&(u.above=o),r&&N())return;return i.style.left=`${e}px`,void(i.style.top=`${t}px`)}let o=u&&t?On(t.anchor,t.resolved):d?E(d):null;o&&$(i,o,In())}let q=t=>e.state.l&&!t.anchor.quote&&!t.anchor.point;function N(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 R=e=>Math.min(Math.max(e,20),window.innerWidth-30),D=t=>{if(e.O(t)){let e=t.composedPath()[0];return null!==v&&!(e instanceof Element&&e.closest(".tip,.bub"))&&C(null),void(v=null)}let n=e.ye(t.clientX,t.clientY)?.id??null;n!==v&&(v=n,C(n))},z=t=>{if(e.O(t))return;let n=window.getSelection();if(n&&!n.isCollapsed||(e.state.l&&!e.state.paused?t.altKey:t.target instanceof Element&&t.target.closest(Nn)))return;let o=e.ye(t.clientX,t.clientY);o&&(e.we(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.G(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 ${Ge(n.element)}: ${kt(t.root.text,60)}`;o.getAttribute("aria-label")!==r&&o.setAttribute("aria-label",r)}bt(e.e,o.filter(e=>l.has(e.id)).sort(_n(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&&N(),k=e.state.u;let g=t.ve&&!e.state.u?e.state.t:null;if(g){let t=g.anchor.point??g.resolved.element;u?.of!==g?(window.clearTimeout(f),i.classList.remove("glide"),u={p:qn(e,g),of:g,at:t,above:null},u.p.oe(q(g)),i.replaceChildren(u.p.element),i.inert=!1,u.p.focus(),d=null,c=null,P(),i.classList.add("show")):u&&(u.at!==t&&(u.at=t,u.above=null,N(()=>u?.p.he(g.label))),u.p.oe(q(g)));let n=!e.f.S(g.anchor.view);return void(n!==T&&(T=n,i.classList.toggle("show",!n),i.inert=n,n||P()))}u&&(window.clearTimeout(f),i.classList.remove("glide"),u=null,T=!1,e.F(null));let v=x()&&!e.state.u&&e.state.i?b(e.state.i):null;if(!v||!e.G(v))return d=null,c=null,i.classList.remove("show"),void yt(i,!0);let w={q:"popover",quote:v.anchor.quote?.exact??null,moved:oo(e,v),alike:ro(e,v)};d&&c&&d.id===v.id?(d!==v||a!==vt(v)||p!==w.moved)&&(c.update(v,w),d=v,a=vt(v),p=w.moved):(c=eo(v,e.K,w),i.replaceChildren(c.element),d=v,a=vt(v),p=w.moved,P(),i.classList.add("show"),i.inert=!1)},N:function(){let t=[],o=x()?null:to(e.root,!0);for(let[r,i]of n){let n=b(r),a=e.resolved.get(r),l=n&&a?Rn(n.anchor,a):null;if(!l||l.y<-40||l.y>window.innerHeight+40){i.style.visibility="hidden";continue}let s=l.x=R(l.x),d=Math.max(s,(o?o.x:window.innerWidth)-30),c=ao;for(;t.some(e=>Math.abs(e.x-l.x)<ao&&Math.abs(e.y-l.y)<ao);)l.x+=c,l.x>d&&(c=-22,l.x=s-ao),l.x<20&&(c=ao,l.x=s,l.y+=ao);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.S(a.anchor.view)?Rn(a.anchor,a.resolved):null;s?(l.style.left=`${R(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.l?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&&Et(r,c.getBoundingClientRect(),4)},destroy(){window.clearTimeout(y),window.clearTimeout(f),window.removeEventListener("pointermove",D,!0),window.removeEventListener("click",z,!0),e.F(null);for(let e of n.values())e.remove();l.remove(),o.remove(),r.remove(),i.remove()}}}var so={display:"block",position:"static",clips:!1,off:!1},co="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}]`),po="[data-pipeup-ignore],pipeup-place,.reveal>:is(.controls,.progress,.slide-number)",uo=["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",...co].join(","),ho="a,button,label,summary,[role=button],[role=link],[role=tab],[role=option],[role=menuitem]",fo=`${ho},input,select,textarea,img,svg,canvas,video,picture,[role=img]`,mo=(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 go(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.re();return n.width*n.height<=.6*o.width*o.height&&(e.matches(uo)||t.nt(e)||e.childElementCount>1&&!e.parentElement?.closest(ho)&&t.ot(e))}function vo(e,t,n){if(e===t||!t.contains(e)||e.closest(po))return null;let o=null;for(let r=e;r&&r!==t&&!o;r=r.parentElement)go(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&&mo(n.p(e),r);e=e.parentElement)if(e.hasAttribute("data-pipeup-id"))return e;return o}function wo(e,t,n){let o=n.p(e);for(let r=e.parentElement;r&&r!==t;){let e=vo(r,t,n);if(!e)return null;if(!mo(n.p(e),o))return e;r=e.parentElement}return null}var yo=(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,bo=(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 xo(e,t,n=()=>!0){let o=[],r=(e,i,a,l,s,d)=>{for(let c of e.children){if(c.matches(po)||"true"===c.getAttribute("aria-hidden")||!n(c))continue;let e=t.flow?.(c)??so,p=c.offsetParent,u="fixed"===e.position||"absolute"===e.position&&!!l&&!(p&&l.contains(p)),h=u?null:a,f=t.p(c),m=f.width>0&&f.height>0;if(h&&m&&!yo(f,h))continue;let g=c.matches(ho),v=(e.display.startsWith("inline")||d)&&!c.matches(fo)&&("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))&&go(c,t)&&(i&&mo(t.p(i.o),f)?(c.hasAttribute("data-pipeup-id")||!i.o.hasAttribute("data-pipeup-id"))&&(i.o=c):o.push(y={o:c,V:i,T:0}));let b=e.clips&&m;r(c,y,b?h?bo(h,f):f:h,b?c:u?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.V&&(t.V.T=Math.max(t.V.T,t.T+1))}return o}var ko=(e,t)=>e.filter(e=>e.T<=t&&(!e.V||e.V.T>t)),Eo="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]",So=`${Eo},input,select,textarea,[contenteditable]:not([contenteditable=false]),[tabindex]:not([tabindex="-1"])`,$o=["click","dblclick","auxclick","submit","contextmenu","dragstart"],Lo=[...["over","out","enter","leave","down","up"].flatMap(e=>[`pointer${e}`,`mouse${e}`]),"mousemove","touchstart","touchmove","touchend","touchcancel"],Mo=["pointerup","pointercancel"],Co="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";function Ao(e){let t={p:e=>e.getBoundingClientRect(),nt: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},ot: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}},re:()=>({width:innerWidth,height:innerHeight})},n=wt("span",{hidden:!0},Co),o=wt("div",{class:"pick"},n),r=wt("div",{class:"pkw"}),i=[0,1].map(()=>{let e=wt("div",{class:"km",tabindex:"-1",role:"button"},wt("span",{hidden:!0}),wt("span",{hidden:!0}));return e.inert=!0,e.addEventListener("keydown",Se),e.addEventListener("click",e=>{e.stopPropagation(),Ee()}),e.addEventListener("focus",()=>o.classList.add("kf")),e.addEventListener("blur",()=>o.classList.remove("kf")),e}),a=wt("span",{class:"lbl"}),l=(e,t,n,o)=>{let r=wt("button",{class:"nb",type:"button","aria-label":e,title:t},Tt(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",ke),c=l("Pin","Pin its centre","pin",t=>t.detail&&Fn()?W(!z):e.Re(()=>Y(m??k,{x:.5,y:.5}))),p=wt("div",{class:"namebar",role:"group","aria-label":"Chosen block"},a,s,d,c);p.inert=!0;let u=e.e.querySelector(".launch");for(let t of[r,o,...i,p])e.e.insertBefore(t,u);p.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=null,P=-1,q=!0,N=null,R=null,D=!1,z=!1,O=t=>!(e.O(t)||t.target instanceof Element&&t.target.closest(po));function H(){v&&(o.classList.toggle("glide",performance.now()<w),Et(o,v.getBoundingClientRect(),4))}function I(){if(!b)return;p.classList.toggle("glide",performance.now()<w&&p.classList.contains("show"));let t={width:p.offsetWidth||200,height:p.offsetHeight||34},n=Un(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),p.style.left=`${n.left}px`,p.style.top=`${n.top}px`}function B(e,t){v=e,w=t?performance.now()+400:0,H(),o.classList.add("show")}function F(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 j(e){if(e!==f){if(f=e,y(),!e)return void o.classList.remove("show");"0"===getComputedStyle(o).opacity?B(e,!1):h?(o.classList.remove("show"),y=F(o,()=>B(e,!1))):B(e,!0)}}function W(t){z=e.state.pinning=t,c.classList.toggle("on",t),t?e.M(a.textContent="Tap where to pin"):b&&(a.textContent=Ge(b))}function K(e){z&&W(!1),m=e,o.classList.toggle("on",null!==e),j(e),V(e)}function V(e){x(),p.inert=!e,e?h?(p.classList.remove("show"),x=F(p,()=>U(e))):U(e):(p.classList.remove("show"),b=null)}function U(n){a.textContent=a.title=Ge(n),s.hidden=null===wo(n,e.root,t),d.hidden=0===(k?we(n).length:xo(n,t,ce).length);let o=p.classList.contains("show");b=n,I(),o||(p.offsetWidth,p.classList.add("show"))}function Y(t,n){let o;try{o=Te(t,e.root,n,e.f.view(t))}catch(t){return void e.ie(t)}if(e.state.I)return e.repoint(o);let r={anchor:o,label:n?`Pin on ${Ge(t).replace(/^[A-Z](?=[a-z])/,e=>e.toLowerCase())}`:Ge(t),ranges:[],resolved:{state:"attached",element:t,range:null}},i=e.state.t;k&&(k=t,P=-1),K(n?null:t),g=i??r,e.rt(r),i&&e.focusDraft(),e.M(n?r.label:`Commenting on ${r.label}`)}function _(t){e.Re(()=>Y(t))}function G(n){let o=(n.target instanceof Element?vo(n.target,e.root,t):null)??e.root;o!==e.root&&(L=o);let r=o.getBoundingClientRect();r.width&&r.height&&Y(o,{x:(n.clientX-r.left)/r.width,y:(n.clientY-r.top)/r.height})}function Z(t){e.state.paused!==t&&(e.state.paused=t,t&&!m?j(null):!t&&k&&!m&&j(k),e.m())}let J=!1,X=null,Q=0,ee=()=>X??e.state.paused,te=()=>{J=!1,X=e.state.paused,Q++},ne=()=>{let e=Q;setTimeout(()=>{Q===e&&(X=null)})},oe=()=>!!e.state.i&&!e.state.sent,re=n=>{let o=T?Math.abs(n.clientX-T.x)+Math.abs(n.clientY-T.y):0;if(T={x:n.clientX,y:n.clientY},e.O(n)||e.state.paused)return;if(!O(n))return void(m||j(null));if(n.stopPropagation(),oe())return void(m||j(null));if(m||e.state.t)return;let r=!xt()&&n.target instanceof Element?vo(n.target,e.root,t):null;if(k){if(!r||r===k||(A+=o,A<=4))return;ve()}r&&(L=r),j(r)},ie=()=>{xt()&&(k&&ve(),m||j(null))},ae=e=>{!O(e)||ee()||(e.stopPropagation(),("pointerdown"===e.type||"mousedown"===e.type)&&e.target instanceof Element&&e.target.closest(So)&&e.preventDefault())},le=n=>{if(!O(n))return;if(ee())return e.we(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.s&&!e.it(n)&&function(n){if(z)return G(n);let o=window.getSelection();if(o&&!o.isCollapsed)return void(n.detail>1&&g&&e.state.t===g&&e.w()&&e.ge());let r=n.target instanceof Element?vo(n.target,e.root,t):null;if(e.state.t&&!e.w())return r||n.altKey?e._():e.Y();if(e.state.t&&n.altKey)return e.Y();if(n.altKey||!e.ye(n.clientX,n.clientY)){if(oe())return e.open(null);if(e.state.i&&e.open(null),k&&n.detail&&ve(),n.altKey)return void G(n);r&&(L=r),r?Y(r):(e.Y(),K(null))}}(n)):R="click"===n.type&&"submit"===o.type?o.form:null},se=()=>e.e.getRootNode().activeElement,de=()=>i.some(e=>e===se()),ce=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.S(e.f.view(t))},pe=()=>(N?.some(e=>!e.o.isConnected)&&(N=null),N??=xo(e.root,t,ce)),ue=e=>pe().find(t=>t.o===e),he=(e,t=!1)=>{let n=e.getBoundingClientRect();return n.bottom>0&&n.top<window.innerHeight&&(!t||n.top>=0)},fe=()=>{let e=ko(pe(),0);return e.find(e=>he(e.o,!0))??e.find(e=>he(e.o))??e[0]},me=t=>e.doc.threads().filter(n=>e.G(n)&&t.contains(Yn(e,n))).sort(_n(e));function ge(t,o=!0){A=0;let r=pe(),a=r.find(e=>e.o===t);if(a&&!ko(r,E).includes(a)&&(E=a.T),t!==k&&(P=-1),t!==m&&(m=null),k=t,j(t),V(t),t.scrollIntoView({block:"nearest",inline:"nearest",behavior:h?"auto":"smooth"}),!o)return;e.st();let l=i[S^=1];(function(e,t){let[o,r]=e.children,i=ko(pe(),E),a=me(t).length;o.textContent=`${Ue(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=_e(t);let s=q?[n]:[];q=!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),Et(l,t.getBoundingClientRect(),4),l.inert=!1,l.focus({preventScroll:!0}),i[1^S].inert=!0}function ve(){let e=de();L=k,k=null,j(null),V(null);for(let e of i)yt(e,!0);return e}function we(e){let t=ue(e);return t?((e,t)=>e.filter(e=>e.V===t))(pe(),t):[]}function ye(e){let t=ko(pe(),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);N=null;let n=document.activeElement;M=se()??n;let o,r=L?.isConnected?L:null,i=r&&ue(r);if(i){E=i.T;let e=ko(pe(),E),n=e.indexOf(i);o=e[(n+t+e.length)%e.length]}else if(r){E=0;let e=ko(pe(),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.T);if(!o)return e.M("Nothing here to comment on");$=!0,ge(o.o)}function xe(){let n=m??k,o=n&&wo(n,e.root,t);return o?((!C||!n.contains(C))&&(C=n),m?_(o):void ge(o)):e.M("Nothing around it")}function ke(){let t=m??k,n=t?we(t):[],o=n.find(e=>C&&e.o.contains(C))??n.find(e=>he(e.o))??n[0];if(!o)return e.M("Nothing inside it");m?_(o.o):ge(o.o)}function Ee(t=!1){if(!k)return;if(e.state.t&&!e.w())return e._();if(!t)return Y(k);let n=me(k);if(!n.length)return e.M("No comments on this block");P=(P+1)%n.length,e.open(n[P].id),n.length>1&&e.M(`Comment ${P+1} of ${n.length} on this block`)}function Se(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(),Me=t.key,"Escape"===t.key)return void e.X();if("Enter"===t.key)return Ee(t.shiftKey);"Tab"===t.key&&e.Y(),e.state.i&&e.open(null),"Tab"===t.key?ye(t.shiftKey?-1:1):"ArrowUp"===t.key?xe():ke()}}function $e(){let t=e.state.t,n=!!k&&!!t&&!e.w(),o=n&&t===g&&t.resolved.element!==k?t.resolved.element:null;r.classList.toggle("show",!!o&&ce(o)),o&&Et(r,o.getBoundingClientRect(),4),e.e.querySelector(".draft")?.classList.toggle("wait",n&&t?.resolved.element!==k)}let Le=()=>{let e=se();return e?!!e.closest("[inert]"):!document.activeElement||document.activeElement===document.body},Me="",Ce=!1,Ae=()=>Z(!1),Pe=ln("keyup",t=>{if(Ce&&Pe(),t.key===Cn&&e.state.paused)return Z(!1),t.preventDefault(),void t.stopPropagation();t.key===Me&&(Me="",t.preventDefault(),t.stopPropagation())},!0);window.addEventListener("blur",Ae),window.addEventListener("pointermove",re,!0),window.addEventListener("pointerdown",te,!0);for(let e of Mo)window.addEventListener(e,ne,!0);document.addEventListener("selectionchange",ie);for(let e of Lo)window.addEventListener(e,ae,!0);for(let e of $o)window.addEventListener(e,le,!0);let qe=ln("keydown",t=>{if(t.key!==Cn&&(J=!0),(t=>{if(t.key!==Cn||t.ctrlKey||t.metaKey||t.altKey||t.isComposing)return!1;let n=t.composedPath()[0];if(i.some(e=>e===n)||n instanceof HTMLTextAreaElement&&e.e.contains(n)&&!n.value.trim())return!0;let o=n instanceof Element?n.closest(So):null;return!o||!J&&!o.matches("input,textarea,select,[contenteditable]:not([contenteditable=false])")})(t)||t.key===Cn&&e.state.paused)return t.repeat||Z(!0),t.preventDefault(),void t.stopPropagation();if(R=null,Me="","Escape"===t.key&&O(t)&&!t.isComposing&&!t.defaultPrevented&&!e.state.s&&!e.state.u)return t.preventDefault(),t.stopPropagation(),Me=t.key,e.X();if("Tab"===t.key&&function(t){if(t.ctrlKey||t.metaKey||t.altKey||t.isComposing||!e.O(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(D=!0,r&&e.w())e.ge();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 D=!1,!1;r||e.open(null)}return D=!1,be(i),!0}(t))return t.preventDefault(),t.stopPropagation(),void(Me=t.key);if("Tab"===t.key&&(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.O(t)?!!n.closest(".launch,.menu")&&!n.closest("input,textarea,select,[contenteditable]"):!t.composedPath().some(e=>e instanceof Element&&e.matches(po)))})(t))return t.preventDefault(),t.stopPropagation(),Me=t.key,e.Y(),e.state.i&&e.open(null),e.state.s&&(e.state.s=!1,e.m()),be(t.shiftKey?-1:1);if(O(t)&&t.target instanceof Element)if("Enter"!==t.key&&" "!==t.key||!t.target.closest(Eo))"Enter"===t.key&&t.target.form&&(R=t.target);else{if(!k)return void(R=t.target);t.preventDefault(),t.stopPropagation()}},!0);return{X:()=>!!m&&(K(null),!0),be:()=>null!==k,lt:()=>$&&!k,Ne:function(){N=null;let t=document.activeElement;M=se()??t;let n=ue(L),o=n??(t&&t!==document.body&&e.root.contains(t)&&!t.closest(po)?pe().filter(e=>e.o.contains(t)).pop():void 0)??fe();return!!o&&(n||(E=o.T),$=!0,ge(o.o),!0)},xe(){k&&!de()&&ge(k)},m(){if(N=null,k&&(!k.isConnected||!ce(k))){let e=fe();e?ge(e.o,de()||Le()):ve()}let t=e.e.querySelector(".launch");if(t&&p.nextElementSibling!==t&&!de()&&!p.contains(se()))for(let n of[r,o,...i,p])e.e.insertBefore(n,t);let n=e.state.t;g&&n!==g?(g=null,K(null),k&&ge(k,Le()&&!D)):(n||e.state.i)&&!g&&(f||m)&&K(null);let a=g?.anchor.point?null:g?.resolved.element;m&&!ce(m)?K(null):!m&&!k&&a&&n===g&&ce(a)&&K(a),$e()},toDraft(){let t=g,n=t?.resolved.element;!t||!n||e.state.t!==t||(k&&(k=n,P=-1),L=n,K(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),K(e.anchor.point?null:t)},N(){$e(),H(),I(),k&&Et(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,Ce=!0,Me||Pe(),window.removeEventListener("blur",Ae),window.removeEventListener("pointermove",re,!0),window.removeEventListener("pointerdown",te,!0);for(let e of Mo)window.removeEventListener(e,ne,!0);document.removeEventListener("selectionchange",ie);for(let e of Lo)window.removeEventListener(e,ae,!0);for(let e of $o)window.removeEventListener(e,le,!0);qe(),o.classList.remove("show"),p.classList.remove("show"),yt(p,!0),F(o,()=>o.remove()),F(p,()=>p.remove())}}}var To=`${po},input,textarea,select,[contenteditable]:not([contenteditable=false])`;function Po(e){let t=wt("button",{type:"button","aria-label":"Comment",title:"Comment"},Tt("comment",17)),n=wt("div",{class:"selbar"},t);n.inert=!0,e.e.append(n);let o=null,r=0,i=!1,a=()=>e.state.l||"comment-mode"!==Ft("data-pipeup-select"),l=t=>{let n=t&&(t.nodeType===Node.ELEMENT_NODE?t:t.parentElement);return!!n&&e.root.contains(n)&&!n.closest(To)};function s(){if(!o)return;let t=o.cloneRange();t.selectNodeContents(Ce(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?Un(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},Fn());n.style.left=`${i}px`,n.style.top=`${a}px`}function d(){o=null,n.inert=!0,n.classList.remove("show")}function c(t=!1){let r=xt();a()&&r&&l(r.anchorNode)&&l(r.focusNode)?(!o&&!t&&e.state.l&&e.M("Enter comments on the selected words"),o=r.getRangeAt(0).cloneRange(),s(),n.inert=!1,n.classList.add("show")):d()}t.addEventListener("mousedown",e=>e.preventDefault()),t.addEventListener("click",t=>{if(t.stopPropagation(),e.state.t&&!e.w())return e._();let n,r=o;if(!r)return;try{n=Ae(r,e.root,e.f.view(r.commonAncestorContainer))}catch(t){return e.ie(t),void d()}let i=kt(r.toString().replace(/\s+/g," ").trim(),60);window.getSelection()?.removeAllRanges(),d(),e.Ie({anchor:n,label:`\u201c${i}\u201d`,ranges:[r],resolved:{state:"attached",element:null,range:r}})});let p=()=>{window.clearTimeout(r),r=window.setTimeout(()=>i||c(),250),o&&(xt()||d())};document.addEventListener("selectionchange",p);let u=t=>{"keyup"!==t.type&&(i="mousedown"===t.type),!i&&!e.O(t)&&window.setTimeout(()=>c("mouseup"===t.type),0)};window.addEventListener("mousedown",u,!0),window.addEventListener("mouseup",u,!0),window.addEventListener("keyup",u,!0);let h=n=>{"Enter"!==n.key||!o||!e.state.l||e.O(n)||n.target instanceof Element&&n.target.closest(`${To},${Eo}`)||(n.preventDefault(),n.stopPropagation(),t.click())};return window.addEventListener("keydown",h,!0),{m(){o&&!a()&&d()},N(){o&&s()},destroy(){window.removeEventListener("mousedown",u,!0),window.removeEventListener("mouseup",u,!0),window.removeEventListener("keyup",u,!0),window.removeEventListener("keydown",h,!0),window.clearTimeout(r),document.removeEventListener("selectionchange",p),n.remove()}}}async function qo(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 No="Hidden on the page",Ro=["auto","light","dark"];function Do(e){let t=[wt("span",{class:"n"}),wt("span",{class:"n"})],n=Tt("comment",22,1.4);n.lastElementChild.setAttribute("stroke-width","1.6");let o=wt("span",{class:"cnt"},Tt("bubble",28,1.4),Tt("wide",28,1.4),...t),r=wt("button",{class:"mode",type:"button","aria-label":"Comment","aria-keyshortcuts":An,"aria-pressed":"false"},wt("span",{class:"plus"},n),o,wt("span",{class:"dot"})),i=document.createTextNode(""),a=wt("span",{class:"ttip","aria-hidden":"true"},wt("span",{},i,wt("small",{},Mn))),l=wt("button",{class:"mm",type:"button","aria-label":"More","aria-haspopup":"menu","aria-expanded":"false"},Tt("more",15,3)),s=wt("div",{class:"launch"},r,l,a),d="off"===Ft("data-pipeup-control");d&&s.classList.add("off");let c=null,p=()=>{if(!d)return r.focus({preventScroll:!0});c?.focus({preventScroll:!0}),c=null},u=wt("div",{class:"menu",role:"menu","aria-label":"Comments"}),h=wt("div",{class:"list",role:"list","aria-label":"Comments"}),f=wt("button",{class:"ib",type:"button","aria-label":"Close"},Tt("close")),v=(e,t,n,o)=>{let r=wt("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},w=v("For you","Only comments that mention you",Tt("at",16,1.8),()=>e.s.toggleMine()),y=v("Resolved","Show resolved comments too",Tt("resolve",22,1.7),()=>e.s.ct()),b=wt("div",{class:"lns"}),x=new Map,k=wt("span",{class:"ma"}),E=wt("span",{class:"lb"}),S=wt("button",{class:"fs",type:"button",role:"switch","aria-checked":"false","aria-keyshortcuts":An},"Comment",wt("small",{class:"ks","aria-hidden":"true"},Mn),wt("span",{class:"sw","aria-hidden":"true"}));S.addEventListener("click",t=>{t.stopPropagation(),e.se(!e.state.l,!e.state.l&&0===t.detail)});let $=wt("button",{class:"ib",type:"button","aria-label":"More","aria-haspopup":"menu","aria-expanded":"false"},Tt("more",15,3)),L="",M=wt("div",{class:"all",role:"dialog","aria-label":"All comments"},wt("div",{class:"hh",role:"heading","aria-level":"2"},"All comments"),wt("div",{class:"hd"},w,y,wt("span",{class:"sp"}),f),b,h,wt("div",{class:"pf"},k,E,S,$)),C=document.createElementNS("http://www.w3.org/2000/svg","svg");C.setAttribute("class","cx"),C.setAttribute("aria-hidden","true");let A=document.createElementNS("http://www.w3.org/2000/svg","path"),T=document.createElementNS("http://www.w3.org/2000/svg","circle");T.setAttribute("r","4"),C.append(A,T),u.inert=M.inert=!0,e.e.append(u,s,C,M);let P=!1,q=null,N=0,R=[],D=0,z=null,O=null,H=null,I=!0===window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,B=()=>{},F=t=>{P=e.state.s=t,e.taps(),t&&e.addons.flush(),window.clearTimeout(N),N=0,t||q?.(!0),t?u.classList.toggle("inp",e.state.u):B(),u.classList.toggle("show",t),yt(u,!t),l.setAttribute("aria-expanded",String(t)),$.setAttribute("aria-expanded",String(t))},j=(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&&R.some(e=>e.id===o)?xe(o,!0):t&&e.state.t?e.focusDraft():t?(W(h)[0]??f).focus({preventScroll:!0}):n&&p()},W=(e=u)=>[...e.querySelectorAll(".mi")].filter(e=>e.offsetParent&&!e.closest("[inert]")),K=()=>u.getRootNode().activeElement,V=()=>{F(!1),p()},U=e=>{let t=W(e.currentTarget);if(0===t.length)return;let n=K(),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)};u.addEventListener("keydown",U),h.addEventListener("keydown",U),f.addEventListener("click",e=>{e.stopPropagation(),j(!1,!0)});let Y=t=>no(e,t),_=t=>oo(e,t),G=t=>R.filter(n=>!(n.resolved||void 0!==t&&(e.Z(n)!==t||t&&e.E(n)))).length,Z=t=>{if(e.E(t)){let e=t.anchor.view?.[Je];return e?`In the ${e} edition`:"From before editions"}let n=t.anchor.view?.slide,o=e.f.S(t.anchor.view)?"":Xe(t.anchor.view);return n&&null!==e.f.slide()?`On slide ${n}`:o?`In ${o}`:No},J=(e,t,n=!1)=>{let o=new Set(t),r=new Set(e.childNodes),i=new Map,a=new Set(t.map(Q));for(let e of r){if(o.has(e))continue;let t=Q(e);t&&a.has(t)&&i.set(t,e.offsetHeight),n&&te&&e instanceof HTMLElement&&!i.has(t)?ne(e):e.remove()}let l=e.firstChild;for(let n of t){for(;l&&l!==n&&ee.has(l);)l=l.nextSibling;l===n?l=n.nextSibling:e.insertBefore(n,l)}if(n&&te)for(let e of t)e instanceof HTMLElement&&(r.has(e)?ee.delete(e)&&oe(e,e.offsetHeight):oe(e,i.get(Q(e))??0))},X=new WeakMap,Q=e=>X.get(e),ee=new WeakSet,te=!1,ne=e=>{if(!ee.has(e)){if(e.classList.contains("out"))return e.remove();ee.add(e),e.style.height=`${e.offsetHeight}px`,e.offsetHeight,e.classList.add("out"),I||(e.style.height="0"),setTimeout(()=>ee.delete(e)&&e.remove(),340)}},oe=(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";(I||!t)&&e.classList.add("out"),I||(n.overflow="hidden",n[r]=`${t}px`),e.offsetHeight,n.transition="",e.classList.remove("out"),!I&&(n[r]=`${o>t?o+40:o}px`,setTimeout(()=>n[r]=n.overflow="",360))},re=new Map,ie=(e,t,n="",o=e)=>{let[r,i,a]=re.get(o)??[];return(!r||!i||!a)&&re.set(o,[r=wt("div",{role:"listitem"}),i=wt("div",{class:"sec","aria-hidden":"true"}),a=wt("div",{role:"list"})]),a.setAttribute("aria-label",n?`${e} \xb7 ${n}`:e),i.replaceChildren(e,n&&wt("b",{},n)),J(r,[i,a]),J(a,t,!0),r},ae=wt("div",{class:"sec",role:"listitem"}),le=!1,se=wt("button",{class:"sec fold",type:"button"});se.addEventListener("click",e=>{e.stopPropagation(),le=!le,we()});let de=wt("div",{role:"listitem"}),ce=wt("div",{role:"list","aria-label":"Earlier editions"}),pe=(e,t,n)=>(se.setAttribute("aria-expanded",String(n)),se.replaceChildren(`Earlier editions \xb7 ${t} open`,Tt("chev",12)),J(de,n?[se,ce]:[se]),J(ce,n?e:[],!0),de);function ue(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.Z(t)?e.f.S(t.anchor.view)?"":Xe(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])=>ie(e||No,t.flatMap(n)))]}return[...r].sort(([e],[t])=>Number(e)-Number(t)||0).map(([e,t])=>ie(`Slide ${e} \xb7 ${t.filter(e=>!e.thread.resolved).length} open`,t.flatMap(n),e===o?"This slide":"",`slide:${e}`))}let he=null,fe=new Map,me=new Map,ge=new Set,ve={...e.K,get me(){return e.K.me},resolve:async t=>{let n=fe.get(t)?.card;n&&!e.state.H&&!I&&(ge.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.K.resolve(t),ge.delete(t),n?.style.removeProperty("height"),e.m()}};function we(){let t=K(),n=t?.dataset.thread,o=null!==O&&O.element.contains(t),r=[...fe.values()].find(e=>e.view.element.contains(t)),i=()=>[...r.view.element.querySelectorAll("button,textarea")],a=r?i().indexOf(t):-1,l=r?W(h).indexOf(r.card.firstChild):-1,s=e.s.all(),d=s.filter(t=>!t.thread.resolved||e.state.H||t.thread.id===z).filter(t=>!e.state.mine||((e,t)=>[e.root,...e.root.replies].some(e=>e.author!==t&&!e.deleted&&Gt(e,Jt(t))))(t.thread,e.doc.me));y.setAttribute("aria-pressed",String(e.state.H)),w.setAttribute("aria-pressed",String(e.state.mine));let c=e.s.name();if(E.textContent=c||m(e.doc.me),Dt(e.doc.me,c)!==L){L=Dt(e.doc.me,c);let t=zt(e.doc.me,c);t.classList.add("in"),k.replaceChildren(t)}S.setAttribute("aria-checked",String(e.state.l));let p=e.state.t;H&&H.of!==p&&(H=null,p||e.F(null));let u=p&&!H;if(p&&!H){z=O=null;let t=qn(e,p);H={of:p,p:t,card:wt("div",{class:"cd open new",role:"listitem"},t.element)}}H&&(H.p.he(p.label),H.p.oe(!1)),he&&he.id!==z&&(he=null);let f=p&&(p.resolved.range?.startContainer??p.resolved.element),v=f?d.find(t=>{let n=Yn(e,t.thread);return n&&4&f.compareDocumentPosition(n)})?.thread.id??null:null,b=t=>{let n=t.thread,o=n.id===z,r=Qn(n).length,i=[r?Xn(r):"",...n.root.reactions.map(e=>`${e.emoji} ${e.by.length}`)].filter(Boolean).join(" \xb7 "),a=e.E(n)?`${Z(n)} \xb7 \u201c${kt(n.anchor.snapshot,80)}\u201d`:Y(n)?`\u201c${kt(n.anchor.snapshot,80)}\u201d`:n.anchor.quote?`\u201c${kt(n.anchor.quote.exact,80)}\u201d`:t.location.where,l=me.get(n.id);if(!l){let e=wt("span",{class:"sr"}),t=wt("button",{class:"mi",type:"button","data-thread":n.id},e);t.addEventListener("click",e=>{e.stopPropagation(),xe(n.id)}),me.set(n.id,l={b:t,sr:e})}let s,d=l.b,c=[g(n.root),tt(n.root.at,Date.now()),_(n)&&"Moved",a,n.root.text,i].filter(Boolean).join(", ");if(l.sr.textContent!==c&&(l.sr.textContent=c),d.setAttribute("aria-expanded",String(o)),o&&O){if(O.update(n,ye(n,a)),!he){let e=wt("div",{class:"xr",role:"region","aria-label":"Comment thread"},O.element);e.addEventListener("click",e=>{let t=e.target;t.closest(".root>.hdr")&&!t.closest("button")&&ke(!0)}),he={id:n.id,card:wt("div",{role:"listitem"}),xr:e}}s=he.card,s.className="cd open"+(n.resolved?" done":""),J(s,[d,he.xr])}else{let t={q:"card",note:a,rest:i,quote:n.anchor.quote?.exact,moved:_(n),alike:ro(e,n)},o=fe.get(n.id);o?o.view.update(n,t):fe.set(n.id,o={card:wt("div",{role:"listitem"}),view:eo(n,ve,t)}),s=o.card,s.className=`cd${n.resolved?" done":""}${ge.has(n.id)?" out":""}`,J(s,[d,o.view.element])}return X.set(s,n.id),H&&n.id===v?[H.card,s]:[s]},x=d.filter(e=>Y(e.thread)),$=d.filter(t=>e.E(t.thread)),M=d.filter(t=>!e.E(t.thread)),C=le||$.some(e=>e.thread.id===z);ae.textContent=e.state.mine?"No comments mention you":$.length?"No open comments on this edition":"No open comments",J(h,[...M.length||H?[]:[ae],...ue(M.filter(e=>!Y(e.thread)),b),...H&&null===v?[H.card]:[],...x.length?[ie("No longer on the page",x.flatMap(b))]:[],...$.length?[pe(C?$.flatMap(b):[],s.filter(t=>e.E(t.thread)&&!t.thread.resolved).length,C)]:[]],!0),te=!0;for(let e of[fe,me])for(let t of e.keys())d.some(e=>e.thread.id===t)||e.delete(t);let A=K();u?H.p.focus():H?.card.contains(t)&&!H.card.contains(A)?H.p.fe()():o&&!O.element.contains(A)?O.element.querySelector("textarea")?.focus({preventScroll:!0}):r&&A!==t?(r.card.isConnected?i()[a]:W(h)[Math.min(l,W(h).length-1)])?.focus({preventScroll:!0}):n&&A!==t&&W(h).find(e=>e.dataset.thread===n)?.focus({preventScroll:!0})}function ye(t,n){let o=!Y(t)&&e.Z(t);return{q:"popover",quote:t.anchor.quote?.exact??null,lost:Y(t)||o?t.anchor.snapshot:null,place:o?Z(t):null,moved:_(t),alike:ro(e,t),note:!Bn()||Y(t)||o||t.anchor.quote?null:n}}let be="";function xe(t,n=!1){if(z===t)return ke(!0);let o=R.find(e=>e.id===t);if(o){if(e.keepReplies(),z=be=t,O=eo(o,{...e.K,close:()=>ke(!0)},ye(o)),e.seen(o),we(),e.putReply(t),Fn()||O.element.querySelector("textarea")?.focus({preventScroll:!0}),n&&h.querySelector(".mi.open")?.scrollIntoView({block:"nearest"}),!e.Z(o))return Ee(o,!n);e.state.t&&!e.w()||e.f.ne(o.anchor.view??{}).then(()=>{e.He();let n=R.find(e=>e.id===t);n&&be===t&&z===t&&Ee(n)})}}function ke(t=!1){if(!z)return;let n=z;e.keepReplies(),z=O=null,e.L(null),we(),t&&W(h).find(e=>e.dataset.thread===n)?.focus({preventScroll:!0})}function Ee(t,n=!0){let o=e.resolved.get(t.id),r=o&&!Y(t)?o.element??o.range?.startContainer.parentElement??null:null;n&&r?.scrollIntoView({block:"center",inline:"nearest",behavior:I?"auto":"smooth"}),r&&e.L(t.id)}function Se(t,n){let o=n?n.resolved:e.resolved.get(t.id),r=o?.element??o?.range?.startContainer.parentElement;if(!o||Bn()||t&&(Y(t)||e.Z(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?Dn(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=On(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 $e(e,t,n=!1,...o){let r=wt("button",{class:"mi",type:"button",role:n?"menuitemcheckbox":"menuitem"},e,wt("span",{class:"lb"}),...o,n&&wt("span",{class:"sw","aria-hidden":"true"}),wt("span",{class:"tt","aria-hidden":"true"}));return r.addEventListener("click",e=>{e.stopPropagation(),t(e)}),r}let Le=(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))},Me=()=>wt("div",{class:"sep",role:"separator"}),Ce=wt("span",{class:"ma"}),Ae=wt("span",{class:"kc"}),Te="",Pe=$e(Ce,function(){let t=wt("input",{class:"input",type:"text",maxlength:"80","aria-label":"Your name"});t.value=e.s.name();let n=wt("div",{class:"ed"},Ce.cloneNode(!0),t),o=(r,i=!1)=>{if(q!==o)return;q=null;let a=t.value.trim();r&&a&&a!==e.s.name()&&e.s.rename(a).then(Qe),n.replaceWith(Pe),i&&Pe.focus({preventScroll:!0})};q=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)),Pe.replaceWith(n),t.focus({preventScroll:!0})},!1,Ae);Pe.dataset.item="name";let qe=$e(Tt("copy"),()=>{V(),e.s.copyAll("ai")}),Ne=$e(Tt("lines"),()=>{V(),e.s.copyAll("text")}),Re=wt("div",{class:"subs",role:"group"},wt("div",{},qe,Ne)),De=$e(Tt("copy"),()=>ze("true"!==De.getAttribute("aria-expanded")),!1,wt("span",{class:"chev"},Tt("chev",13))),ze=(e,t=!0)=>{De.setAttribute("aria-expanded",String(e)),Re.classList.toggle("open",e),yt(Re,!e),t&&(e?qe:De).focus({preventScroll:!0})};B=()=>ze(!1,!1),B(),De.addEventListener("keydown",e=>{"ArrowRight"===e.key&&"true"!==De.getAttribute("aria-expanded")&&(e.preventDefault(),ze(!0))}),Re.addEventListener("keydown",e=>{"ArrowLeft"===e.key&&(e.preventDefault(),ze(!1))});let Oe=wt("span",{class:"kc"}),He=$e(Tt("look"),()=>{e.s.setLook(Ro[(Ro.indexOf(e.s.look())+1)%3]),Qe()},!1,Oe),Ie=wt("span",{class:"kc"}),Be=$e(Tt("list"),()=>{F(!1),Be.dataset.item="all",j(!0)},!1,Ie),Fe=$e(Tt("hide"),()=>{e.s.setHide(!e.state.hide),Qe()},!0),je=$e(Tt("comment"),t=>{let n=!e.state.l&&0===t.detail;e.se(!e.state.l,n),n?F(!1):e.state.l&&Fn()&&(window.clearTimeout(N),N=window.setTimeout(()=>P&&V(),600))},!0,wt("span",{class:"kc ks","aria-hidden":"true"},Mn));je.dataset.item="comment",je.setAttribute("aria-keyshortcuts",An);let We=wt("div",{class:"sec",role:"presentation"}),Ke="Only in this browser until you send them.",Ve=Me(),Ue=Me(),Ye=new Map,_e=t=>{let n=Ye.get(t);return n||(n=$e(Pt(t.icon,15),()=>{t.checked||V(),Promise.resolve().then(()=>t.select()).catch(t=>e.ie(t)).finally(()=>P&&Qe())},!!t.checked,wt("span",{class:"kc"})),Ye.set(t,n)),n},Ge=-1,Ze=e=>{try{return e()}catch(e){return globalThis.reportError?.(e),""}};function Qe(){let t=G(),n=e.s.name(),o=n||m(e.doc.me);if(Le(Pe,o,n?"The name on your comments":"Add a name to show on your comments"),Pe.setAttribute("aria-label",`${o}, ${n?"edit":"add"} your name`),Ae.replaceChildren(n?Tt("edit",13):"Add name"),Dt(e.doc.me,n)!==Te){Te=Dt(e.doc.me,n);let t=zt(e.doc.me,n);t.classList.add("in"),Ce.replaceChildren(t)}Le(De,"Copy comments","As Markdown, with where each thread is, or as text"),Le(qe,"As Markdown","With where each thread is, ready for an AI or a document"),Le(Ne,"As text","Just the words");let r=["Automatic","Light","Dark"][Ro.indexOf(e.s.look())];Le(He,"Theme","Automatic follows the page; press to change"),Oe.textContent=r,Le(Be,"All comments","Every thread, and where it is"),Ie.textContent=t?String(t):"",We.textContent=e.addons.Ae()||Ke,!We.isConnected&&u.contains(Pe)&&u.prepend(We);for(let t of e.addons.j){let e,n=Ye.get(t);if(n){try{e=t.checked?.()}catch(e){globalThis.reportError?.(e)}Le(n,Ze(t.label),Ze(t.hint),e),n.querySelector(".kc").textContent=t.count?Ze(t.count):""}}Le(Fe,"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),Le(je,"Start commenting",e.state.l?"Turn off to use the page as normal":"Choose any part of the page to comment on it",e.state.l)}function et(){Qe(),(Ge!==e.addons.ae||!u.contains(Pe))&&(u.replaceChildren(Pe,Ve,De,Re,He,Be,...e.addons.j.map(_e),Ue,Fe,je),Ge=e.addons.ae,Qe())}$.addEventListener("click",e=>{if(e.stopPropagation(),P)return F(!1);et(),F(!0),0===e.detail&&W()[0]?.focus({preventScroll:!0})});let nt=e=>{et(),F(!0),e&&W().at(-1)?.focus({preventScroll:!0})},ot=()=>{let e=document.activeElement;return e instanceof HTMLElement&&e!==document.body?e:null};e.pageControls={s:()=>{P||(c=ot(),nt(!0))},list:()=>{e.state.u||(c=ot(),P&&F(!1),j(!0))}};let rt=!1,it=0;r.addEventListener("pointerdown",e=>{rt=!1,window.clearTimeout(it),"mouse"!==e.pointerType&&(it=window.setTimeout(()=>{rt=!0,nt(!1)},500))});for(let e of["pointerup","pointercancel","pointerleave"])r.addEventListener(e,()=>window.clearTimeout(it));r.addEventListener("contextmenu",e=>{(rt||Fn())&&e.preventDefault()}),r.addEventListener("click",t=>{if(t.stopPropagation(),rt)return void(rt=!1);if(P)return void F(!1);let n=!e.state.l;e.se(n,n&&0===t.detail)}),l.addEventListener("click",e=>{if(e.stopPropagation(),P)return V();nt(0===e.detail)}),r.addEventListener("keydown",e=>{P||!("ArrowUp"===e.key||"ContextMenu"===e.key||"F10"===e.key&&e.shiftKey)||(e.preventDefault(),e.stopPropagation(),nt(!0))});for(let e of[r,l,$])e.addEventListener("keydown",e=>{let t=W();!P||!t.length||"ArrowDown"!==e.key&&"ArrowUp"!==e.key||(e.preventDefault(),e.stopPropagation(),("ArrowDown"===e.key?t[0]:t.at(-1))?.focus({preventScroll:!0}))});let at=t=>{let n=t.composedPath();P&&!n.includes(u)&&!n.includes(r)&&!n.includes(l)&&!n.includes($)&&(F(!1),e.state.l&&!e.O(t)&&(e.we(t),t.preventDefault(),t.stopPropagation()))},lt=e=>{if(!P||"touch"===e.pointerType||"pointerout"===e.type&&e.relatedTarget)return;let t=e.composedPath();"pointerover"===e.type&&(t.includes(u)||t.includes(r)||t.includes(l)||t.includes($))?(window.clearTimeout(N),N=0):N||(N=window.setTimeout(()=>{N=0,q||F(!1)},3e3))},st={n:0,label:""},dt=()=>{let{n:t,label:n}=st,o=e.addons.Ae(),a=`Comment${e.state.l?", comment mode on":""}${n?`, ${n}`:t?`, ${t} open`:""}${o?`, ${o}`:""}`;r.getAttribute("aria-label")!==a&&r.setAttribute("aria-label",a),r.setAttribute("aria-pressed",String(e.state.l));let l=n||(t>9?`${t} open`:""),s=[l,o].filter(Boolean).join(" \xb7 ")+(l||o?" \xb7 ":"");i.data!==s&&(i.data=s)},ct=e.addons.subscribe(t=>{dt(),(()=>{for(let[t,n]of x)e.addons.listNotes.has(t)||(x.delete(t),n.row.classList.remove("show"),setTimeout(()=>n.row.remove(),320));for(let[t,n]of e.addons.listNotes){let o=x.get(t);if(!o){let e=wt("span",{}),r=wt("div",{class:"ln"},wt("div",{class:"lw"},wt("div",{class:"ag"},e)));r.dataset.addon=t,o={row:r,words:e,btn:null,note:n},x.set(t,o),b.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=wt("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.ie(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)}})(),P&&!q&&(t?et():Qe())});window.addEventListener("click",at,!0),window.addEventListener("pointerover",lt,!0),window.addEventListener("pointerout",lt,!0);let pt=ln("keydown",t=>{if("Escape"!==t.key||t.isComposing||q||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(P&&Re.contains(n))ze(!1);else if(P)V();else if(o&&n!==o.firstChild){if(n instanceof HTMLTextAreaElement)return;o.firstChild.focus({preventScroll:!0})}else{if(!e.state.u||n instanceof HTMLTextAreaElement&&!M.contains(n))return;e.state.t?e.X():z?ke(!0):j(!1,!0)}t.preventDefault(),t.stopPropagation()},!0);return e.registerList(e=>{z!==e&&xe(e,!0)}),{m(n){R=n;let i=G(!1);if(i!==D){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),D=i}let a=G(!0),l=a?`${i} here \xb7 ${a} ${null!==e.f.slide()?"on other slides":"in other views"}`:"";r.classList.toggle("else",a>0),st={n:i,label:l},dt(),r.classList.toggle("on",e.state.l),P&&!e.state.s&&F(!1),P&&Qe();let d=e.state.u;M.classList.toggle("full",Bn()),M.classList.contains("show")!==d&&(M.classList.toggle("show",d),yt(M,!d),yt(s,d)),z&&(!d||!n.some(e=>e.id===z))&&(z=O=null,e.state.L=null),d?we():te=!1},N:function(){let t=z?R.find(e=>e.id===z):null,n=H?.card??(z?h.querySelector(".cd.open"):null),o=H?Se(null,H.of):t&&Se(t),r=n?.getBoundingClientRect(),i=h.getBoundingClientRect();if(!e.state.u||!o||!r?.width||r.top+12<i.top||r.top+12>i.bottom)return void C.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}`}A.setAttribute("d",a),T.setAttribute("r",o.bubble?"0":"4"),T.setAttribute("cx",String(o.x)),T.setAttribute("cy",String(o.y)),C.classList.add("show")},destroy(){ct(),window.removeEventListener("click",at,!0),window.removeEventListener("pointerover",lt,!0),window.removeEventListener("pointerout",lt,!0),window.clearTimeout(N),window.clearTimeout(it),pt(),e.registerList(null),e.pageControls=null,u.remove(),M.remove(),C.remove(),s.remove()}}}var zo="[data-pipeup-slide]",Oo=["scroll","resize","keyup","click","transitionend","slidechanged"],Ho=null,Io=null,Bo=new Set,Fo=new Set,jo=e=>{try{e()}catch(e){globalThis.reportError?.(e)}};function Wo(e){Io="function"==typeof e?.current&&"function"==typeof e.go?e:null}function Ko(){let e=Ft("data-pipeup-edition")?.trim()??"";return e&&e.length<=S?e:null}var Vo=(e,t)=>null!==t&&(e?.[Je]??"")!==t,Uo=()=>{let e=window.Reveal;return"function"==typeof e?.getIndices&&"function"==typeof e.slide?e:null};var Yo,_o="#534AB7";function Go(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(Yo??=t.createElement("canvas").getContext("2d",{willReadFrequently:!0})??null,!Yo)return null;Yo.clearRect(0,0,1,1),Yo.fillStyle="#000",Yo.fillStyle=e,Yo.fillRect(0,0,1,1);let[n,o,r,i]=Yo.getImageData(0,0,1,1).data;return{r:n,g:o,b:r,a:i/255}}catch{return null}}function Zo(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 Jo=[[.92,.25],[.92,.6],[.5,.45]];function Xo(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?Go(t.getComputedStyle(n).backgroundColor,e):null;return t&&e.body&&(!i||i.a<.5)&&(i=Go(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 Qo(e,t){let n=e.ownerDocument,o=n.defaultView,r="dark"===t;if(!o)return{font:"system-ui, sans-serif",accent:_o,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,p=c?Go(c,n):null,[u,h,f]=r?[27,27,25]:[255,255,255],m=p&&((e,t)=>(Math.max(e,t)+.05)/(Math.min(e,t)+.05))(Zo(p),Zo({r:.12*p.r+.88*u,g:.12*p.g+.88*h,b:.12*p.b+.88*f}))>=4.5?c:r?"#9A94EE":_o,g=Go(m,n);return{font:a,accent:m,dark:r,on:g&&Zo(g)>.19?"#111":"#fff"}}function er(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 tr=["pipeup-quote","pipeup-on","pipeup-done"],nr={"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 or(){return typeof CSS<"u"&&"highlights"in CSS&&typeof Highlight<"u"}var rr=`:not(${po},:is(${po}) *){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 ir(){if(or())for(let e of tr)for(let t of["","-d"])CSS.highlights.delete(e+t)}var ar={light:["#2C2C2A","#FFFFFF"],dark:["#ECEBE6","#1B1B19"]},lr=[["opacity","1"],["filter","none"],["backdrop-filter","none"],["mix-blend-mode","normal"],["transform","none"],["clip-path","none"],["mask-image","none"],["zoom","1"]];function sr(e,t,n){let[o,r]=ar[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 Zo({r:o,g:r,b:i})});return((e,t)=>(Math.max(e,t)+.05)/(Math.min(e,t)+.05))(o,r)}var dr=4e3,cr="Click where this comment belongs \xb7 Esc to cancel",pr=["ArrowUp","ArrowDown","Home","End","PageUp","PageDown"];function ur(e,t=!1){return to(e,t)?"column":"bubbles"}var hr="Shown here, but not saved yet \u2014 it will be saved with your next change",fr=e=>e instanceof Error?e.message.replace(/^pipeup: /,""):"Something went wrong";function mr(e){let t=e.prefs??localStorage,n="pipeup:look",o="auto";try{let e=t.getItem(n);("light"===e||"dark"===e)&&(o=e)}catch{}let r,i=!1,a=!1,l="",s=()=>{let e="auto"!==o?o:function(e){let t=(e===document?Ft("data-pipeup-theme"):e.documentElement.getAttribute("data-pipeup-theme"))??e.body?.getAttribute("data-pipeup-theme");return"light"===t||"dark"===t?t:null}(document);a=function(e,t=!1){let n=e.defaultView;if(!n)return!1;let o=e.documentElement,r=Zo(Xo(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 Jo){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=Go(n.getComputedStyle(r).backgroundColor,e);if(o&&o.a>=.5){l=Zo(o);break}}a+=l}let l=a/Jo.length;return l<.18||!(l>.32)&&t}(document,a);let t=e??(a?"dark":"light");r=function(e,t,n){let o=e.defaultView?.getComputedStyle(e.documentElement),r=lr.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}=Xo(e);return{look:t,source:n,ratio:sr(t,i,[a,l,s]),effects:r}}(document,t,"auto"!==o?"reviewer":e?"author":"page");let n=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."}(r);return n&&n!==l&&console.warn(l=n),t};i="dark"===s();let d=function(e,t,n=document,o=!1){let r=n.createElement("pipeup-root");r.setAttribute("data-pipeup-ignore",""),r.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 i=r.attachShadow({mode:o?"closed":"open"}),a=n.defaultView?.CSSStyleSheet;if(a&&"replaceSync"in a.prototype&&"adoptedStyleSheets"in i){let e=new a;e.replaceSync(t),i.adoptedStyleSheets=[e]}else{let e=n.createElement("style");e.textContent=t,i.append(e)}let l=n.createElement("div");return l.className="layer",l.style.setProperty("--pu-panel","320px"),l.style.setProperty("--pu-pop",`${In()}px`),er(l,e),i.append(l),i.addEventListener("mousedown",e=>{let t=e.target.closest("button:not(:disabled),[tabindex]");if(!t||e.defaultPrevented)return;let n=i.activeElement,o=!1,r=()=>o=!0;t.addEventListener("focus",r,{once:!0}),setTimeout(()=>{t.removeEventListener("focus",r);let e=i.activeElement;!o&&t.isConnected&&e!==t&&(!e||e===n)&&t.focus({preventScroll:!0})})}),n.documentElement.append(r),{element:r,shadow:i,e:l,destroy:()=>r.remove()}}(Qo(e.root,i?"dark":"light"),e.styles,document,e.closed);nn(e.field??null,d.shadow),d.e.classList.toggle("flip",i!==a);let c=function(e=document){let t=e.defaultView?.CSSStyleSheet;if(!t||!("replaceSync"in t.prototype)||!("adoptedStyleSheets"in e))return{De(){},I(){},Ee(){},Be(){},remove:()=>ir()};let n=new t,o=null,r=!1,i=1,a=0,l="",s=0,d=()=>n.replaceSync((e=>tr.map(t=>nr[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?rr:"")+(a||l?`html{--pipeup-panel:${a}px;width:auto!important;${a?`margin-right:${a}px!important;`:""}${l}}`:""));return d(),e.adoptedStyleSheets=[...e.adoptedStyleSheets,n],{De(e){e!==o&&(o=e,d())},I(e){e!==r&&(r=e,d())},Ee(e){i=e,d()},Be(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),ir()}}}(document);c.Ee(0);let p=!0===window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,u=jt("data-pipeup-reserve"),h=new Map,f=new Set,v=new WeakSet,y=`pipeup:hide:${e.doc.id}`,x=!1;try{x="1"===t.getItem(y)}catch{}let k={i:null,L:null,H:!1,mine:!1,hide:x,hidden:x,mode:e.host?"bubbles":ur(e.root),t:null,l:!1,paused:!1,u:!1,Fe:!1,s:!1,pinning:!1,I:null,sent:!1},E=wt("div",{class:"toast",role:"status","aria-live":"polite"}),$=null,L=wt("div",{class:"sr","aria-live":"polite"});d.e.append(E,L);let M=null,C=null,A=[],T=null,P=!1,q=0,N=0,R=0,D=0,z=0,O=new Set,H="",I=new Map,B=null,F=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,re:()=>({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(zo)],c=()=>[...e.querySelectorAll(".slides > section")],p=e=>"string"==typeof e&&e.length>0&&e.length<=S?e:null,u=e=>p(e?.getAttribute("data-pipeup-slide")),h=e=>{let t=c()[e];return u(t?.matches(zo)?t:t?.querySelector(zo))??p(String(e+1))};function f(){if(a=[],Io){let e=null;if(jo(()=>{let t=Io.current();Number.isInteger(t)&&t>0&&(e=String(t))}),null!==e)return e}let e=Uo();if(e){let t=null;if(jo(()=>{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.re(),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),p=t.opacity(l);(c>i||c===i&&(p>a||p===a&&l===n))&&(r=l,i=c,a=p)}return r}(t,n,r)??r;for(let e of function(e,t,n){let o=n&&t.p(n),r=t.re().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=u(e);t&&a.push(t)}return u(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||e===Je||n[e]===t)}(e,i,Ho,a)&&!Vo(e,Ko()),w=new MutationObserver(e=>{e.some(e=>e.target instanceof Element&&e.target.matches(zo))&&g()});w.observe(e,{subtree:!0,attributes:!0,attributeFilter:["class","style","hidden"]});let y=new MutationObserver(g);y.observe(document.documentElement,{attributes:!0,attributeFilter:["data-pipeup-edition"]});for(let e of Oo)window.addEventListener(e,g,{capture:!0,passive:!0});return Fo.add(g),i=f(),{slide:()=>i,view(e){let t=e instanceof Element?e:e?.parentElement,n=t&&Uo()?c().findIndex(e=>e.contains(t)):-1,o=u(t?.closest(zo))??(n>=0?h(n):i),r=Ko(),a={...null!==o?{slide:o}:{},...Ho,...null!==r?{[Je]:r}:{}};return Object.keys(a).length?a:void 0},S:v,edition:Ko,E:e=>Vo(e,Ko()),ne:function(e){if(v(e))return Promise.resolve(!0);let t=e.slide,n=Uo(),r=d().find(e=>u(e)===t),a=/^[1-9]\d{0,5}$/.test(t??"");if(a&&Io)jo(()=>Io.go(Number(t)));else if(a&&n){let e=r?c().findIndex(e=>e===r||e.contains(r)):-1;jo(()=>n.slide(e>=0?e:Number(t)-1))}else if(Bo.size)for(let t of Bo)jo(()=>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(),y.disconnect();for(let e of Oo)window.removeEventListener(e,g,!0);Fo.delete(g)}}}(e.root,()=>{P||(F.edition()!==B&&(B=F.edition(),me()),ge()&&Pe())});B=F.edition();let j=!1,W=null,K=0,V=()=>k.l&&!k.u&&Fn(),U=!1,Y="pipeup:held",_=!1;function G(){if(!V()||k.s)return;let e=!1;try{e=null===t.getItem(Y),e&&t.setItem(Y,"1")}catch{e=!_}_=!0,J(e?"Tap what you want to comment on \xb7 Press and hold this button for more":"Tap what you want to comment on",0,!0,!1,{label:"Done",run:()=>_e(!1)}),E.classList.add("tap"),Z()}function Z(){E.classList.toggle("taught",U),E.querySelector(".tw")?.toggleAttribute("aria-hidden",U)}function J(e,t=2400,n=!1,o=!1,r){if(P)return;if(n&&k.s)return void(W=()=>J(e,t,!0,o));j=n,E.replaceChildren(wt("span",{class:"tw"},e)),E.classList.remove("tap","taught"),E.classList.toggle("act",!!r);let i=r?.run;if($=i&&r.D?()=>{$=null,E.classList.remove("show"),i()}:null,r){let e=i?wt("button",{class:"ta",type:"button",...r.D?{"aria-keyshortcuts":"Meta+Z Control+Z"}:{}},r.label):wt("a",{class:"ta",href:r.href,target:"_blank",rel:"noopener noreferrer"},r.label);if(i){let t=$??(()=>{E.classList.remove("show"),i()});e.addEventListener("click",e=>{e.stopPropagation(),t()})}E.append(" ",e)}o?E.setAttribute("aria-hidden","true"):E.removeAttribute("aria-hidden"),E.classList.add("show"),window.clearTimeout(q),t&&(q=window.setTimeout(()=>{$=null,E.classList.remove("show"),q=window.setTimeout(G,320)},t))}let X=(e,t)=>J(e,6e3,!1,!1,{label:"Undo",run:t,D:!0});function ee(){V()||(W=null,j&&(j=!1,window.clearTimeout(q),E.classList.remove("show")))}function te(e){L.textContent="",cancelAnimationFrame(K),K=requestAnimationFrame(()=>L.textContent=e)}function ne(e){J(fr(e))}function oe(e){throw ne(e),e}let re=()=>e.doc.threads().filter(e=>!e.root.deleted),ie=t=>({thread:t,location:Ze(t.anchor,h.get(t.id)??De(t.anchor,e.root),e.root)}),ae=e=>[...d.e.querySelectorAll(`[data-thread="${e}"] .rbox textarea`)].find(e=>!e.closest("[inert]"));function le(){for(let e of d.e.querySelectorAll("[data-thread] .rbox textarea"))e.value.trim()&&I.set(e.closest("[data-thread]").getAttribute("data-thread"),e.value)}function se(e,t=!1){let n=I.get(e),o=ae(e);if(o){if(I.delete(e),n&&!o.value){o.value=n,o.dispatchEvent(new Event("input",{bubbles:!0}));for(let t of d.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 de(e){let t=Ne();if(!t?.closest(`[data-thread="${e}"]`))return()=>{};let n=t.closest(".cd")?".mi":t.closest(".th")?".opn":".bub",o=[...d.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(T?.be())return T.xe();(i&&d.e.querySelector(`${n}[data-thread="${i}"]`)||d.e.querySelector(".launch .mode"))?.focus({preventScroll:!0})}}let ce={get me(){return e.doc.me},picker:()=>fe.picker,people:()=>_t(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 Q?J(hr):oe(e)}},reply:async(t,n,o)=>{try{await e.doc.reply(t,n,o),te("Reply sent"),Ie(o,n)}catch(e){e instanceof Q?J(hr):oe(e)}},edit:async(t,n,o)=>{try{await e.doc.edit(t,n,o)}catch(e){e instanceof Q?J(hr):oe(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?de(n.id):()=>n&&ae(n.id)?.focus({preventScroll:!0});try{await e.doc.remove(t),o(),J("Deleted")}catch(e){J(e instanceof Q?`Deleted \xb7 ${hr}`:fr(e))}},resolve:async t=>{let n=de(t);d.e.classList.add("still"),window.addEventListener("pointermove",()=>d.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 Q?`Resolved \xb7 ${hr}`:fr(e))}k.H||(k.i===t&&(k.i=null),n())},reopen:async t=>{try{await e.doc.reopen(t),J("Reopened")}catch(e){J(e instanceof Q?`Reopened \xb7 ${hr}`:fr(e))}},notRight:async t=>{try{await e.doc.reopen(t)}catch(e){J(e instanceof Q?`Reopened \xb7 ${hr}`:fr(e))}Oe(t)},pasted:t=>{if(!b(t,Yt()))return"";if(t.author===e.doc.me)return"pasted by you";let n="",o=e=>{e.author===t.author&&e.name&&!w(e.name)&&(n=e.name),e.replies.forEach(o)};return e.doc.threads().forEach(e=>o(e.root)),`pasted by ${n||m(t.author)}`},drop:(e,t)=>X("Reply discarded",()=>{I.set(e,t),ae(e)?se(e,!0):We(e)}),close:()=>{We(null);let e=qe&&d.e.querySelector(qe);e?e.focus({preventScroll:!0}):T?.xe(),qe=""},place:(t,n)=>{let o=e.doc.threads().find(e=>e.id===t);if(!o)return;if("pick"===n)return We(null),k.I=t,void(k.l?J(cr,dr,!0):_e(!0));let r=h.get(t)?.element,i=o.anchor;if("confirmed"===n&&r)try{i=Te(r,e.root,void 0,F.view(r))}catch{}Ye(e.doc.place(t,i,n),"gone"===n?"Marked as gone":"Place confirmed")},copy:t=>{try{let n=e.doc.threads().find(e=>e.id===t);if(!n)return;qo(nt(ie(n),"ai",location.href,Date.now()),d.e).then(()=>J("Thread copied as Markdown for AI"),e=>J(fr(e)))}catch(e){J(fr(e))}}},pe={look:()=>o,setLook(e){o=e;try{"auto"===e?t.removeItem(n):t.setItem(n,e)}catch{}Bt(s())},copyAll:async e=>{let t=pe.all(),n=ot(t,e,{title:document.title,url:location.href,exportedAt:new Date});try{await qo(n,d.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(fr(e))}},ct:()=>{k.H=!k.H,Pe()},toggleMine:()=>{k.mine=!k.mine,Pe()},setHide:e=>{k.hide=e;try{e?t.setItem(y,"1"):t.removeItem(y)}catch{}Pe()},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(fr(e))}},name:()=>e.doc.name,all:()=>[...re()].sort(_n(he)).map(ie)},ue={},he={get addons(){return ue.surface},doc:e.doc,root:e.root,e:d.e,host:d.element,state:k,resolved:h,$:f,K:ce,s:pe,f:F,Z:e=>O.has(e.id),E:e=>F.E(e.anchor.view),He:()=>{ge()&&Pe()},G:e=>!k.hidden&&(!e.resolved||k.H||(e=>""!==(d.e.querySelector(`[data-thread="${e}"] .rbox textarea`)?.value.trim()??""))(e.id))&&!O.has(e.id),dt:(e,t)=>{for(let n of re()){let o=h.get(n.id);if(n.anchor.quote&&he.G(n)&&o?.range&&Hn(e,t,Dn(o)))return n}return null},ye:(e,t)=>he.w()&&!k.pinning?he.dt(e,t):null,O:e=>{let t=e.composedPath();return t.includes(d.element)||t.includes(d.shadow)},we:e=>{v.add(e)},it:e=>v.has(e),open:We,pt:e=>Oe(e),keepReplies:le,putReply:e=>se(e),L:Ke,Ie:Ve,rt:function(e){if(!k.t)return Ve(e);Object.assign(k.t,e),Pe()},repoint:t=>{let n=k.I;n&&(_e(!1),Ye(e.doc.place(n,t,"moved"),"Comment moved"))},w:()=>!M||M.et(),Re:e=>{let t=M?.fe();e(),t?.()},focusDraft:je,_:()=>{let e=k.t?.anchor.view,t=F.S(e)?void 0:e?.slide;J(t?`Finish or cancel your comment on slide ${t} first`:"Finish or cancel this comment first"),je(()=>T?.toDraft())},tt:async function(t,n){let o=k.t;if(o)try{o.sending=!0;let r=await e.doc.comment(o.anchor,t,n);te("Comment added"),Ie(n,t),k.t=null,me(new Set([r])),We(r,!0)}catch(e){if(e instanceof Q)return k.t=null,me(new Set([e.id])),We(e.id,!0),void J(hr);o.sending=!1,oe(e)}},seen:Be,people:()=>_t(e.doc.threads(),e.doc.me),ge:Ue,se:_e,Y:Xe,F:e=>{M=e},registerList:e=>{C=e},pageControls:null,ue:J,M:te,st:ee,taps:()=>Ae(),ie:ne,ut:Qe,m:Pe,X:Ge},fe=ue.surface=new yn(he,d.shadow,L);function me(t){let n=performance.now(),o=e.doc.threads();for(let r of o){if(t&&!t.has(r.id))continue;if(F.E(r.anchor.view)){h.set(r.id,{state:"orphaned",element:null,range:null}),f.delete(r.id);continue}let o=performance.now()-n<40,i=De(r.anchor,e.root,{fuzzy:o});h.set(r.id,i),o||"orphaned"!==i.state?f.delete(r.id):f.add(r.id)}for(let e of[...h.keys()])o.some(t=>t.id===e)||h.delete(e);0===f.size?(window.clearTimeout(D),D=0):0===D&&(D=window.setTimeout(()=>{D=0,!P&&(me(new Set(f)),Pe())},250))}function ge(){let t=new Set,n=null!==F.slide(),o=new Set;for(let r of e.doc.threads()){o.add(r.id);let e=h.get(r.id),i=e?.element,a="attached"===e?.state||"moved"===e?.state;(F.E(r.anchor.view)||n?!F.S(r.anchor.view):!1===i?.checkVisibility?.({visibilityProperty:!0})||!F.S(r.anchor.view)&&(!a||i?.closest("[role=tabpanel]")))&&t.add(r.id)}O=t;for(let e of I.keys())o.has(e)||I.delete(e);let r=`${F.slide()}|${[...t].join()}`;return r!==H&&(H=r,!0)}function ve(e){let t=[],n=[],o=[];for(let r of e){let e=h.get(r.id);r.resolved&&!k.H||!e?.range||O.has(r.id)||(r.id===k.i||r.id===k.L?n.push(e.range):r.resolved?o.push(e.range):t.push(e.range))}k.t&&F.S(k.t.anchor.view)&&n.push(...k.t.ranges),function(e,t){if(or())for(let n of tr){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=we.get(e);return void 0===t&&we.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=Zo(Go(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=Go(t.backgroundColor,r);if(n&&n.a>=.5)return i>Zo(n)}return i>Zo(Xo(r))}(e)),t})}let we=new WeakMap,ye=0,be=0,xe=0,ke=0,Ee=0,Se=0,$e=!1,Le=()=>{},Me=!1,Ce=!1;function Ae(){let e=!P&&(k.l||k.s||!!k.i||!!k.t||k.u||Ce),t=document.body;e===Me||!t||(Me=e,e?t.addEventListener("click",Le):t.removeEventListener("click",Le))}function Pe(){if(P)return;e.onRender?.();let t=re();if(ge(),k.i&&O.has(k.i)){let e=d.e.querySelector(`[data-thread="${k.i}"] .rbox textarea`)?.value;e&&I.set(k.i,e),k.i=null}k.hidden=k.hide&&!k.l&&!k.u&&!k.Fe&&!k.t,c.I(k.l&&!k.paused),k.hidden&&(k.i=null),k.hidden||function(t){let n=function(e,t){let n=Jt(t),o=[];for(let r of e)for(let e of[r.root,...r.root.replies])e.author!==t&&!e.deleted&&Gt(e,n)&&!e.seenBy?.includes(t)&&o.push({thread:r,comment:e});return o}(t,e.doc.me).filter(e=>!Fe.has(e.comment.id));if(!n.length)return;for(let e of n)Fe.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===be)return;be=e,cancelAnimationFrame(xe);let t=ye,n=performance.now(),o=e?260:200,r=i=>{let a=Math.min(1,(i-n)/o);ye=t+(e-t)*(e?1-(1-a)**3:a*a),c.Ee(ye),a<1&&(xe=requestAnimationFrame(r))};xe=requestAnimationFrame(r)}(k.hidden?0:1),d.e.classList.toggle("hidden",k.hidden),d.e.classList.toggle("listing",k.u),k.t&&V()&&!U&&(U=!0,E.classList.contains("tap")&&Z()),k.l&&Fn()&&(k.u?ee():E.classList.contains("show")||(W??=G));let n=k.u&&!Bn();(function(e){e!==ke&&(ke=e,c.Be(e,p),null!==F.slide()&&(Se=performance.now()+450),window.clearTimeout(Ee),Ee=window.setTimeout(()=>{me(),Pe()},p?0:400))})(n?320:0),c.De(u?"column"!==k.mode||k.hidden||n?0:320:null);let o=0;if(null!==F.slide())for(let t of e.root.querySelectorAll(po)){if(t===d.element)continue;let e=t.getBoundingClientRect();e.top>innerHeight/2&&e.right>innerWidth-ke-380&&e.bottom>innerHeight-48&&(o=Math.max(o,innerHeight-e.top+4))}d.e.style.setProperty("--pu-lift",`${o}px`),ve(t),Ce=!k.hidden&&t.some(e=>!!e.anchor.quote&&!e.resolved&&!O.has(e.id)),Ae();let r=fe.Xe(),i=r.size?t.filter(e=>!r.has(e.anchor.id??"")):t;for(let e of A)e.m(e===A.at(-1)?t:i);T?.m(t),k.hidden||fe.flush()}let qe="",Ne=()=>d.e.getRootNode().activeElement,Re="input,textarea,select,[contenteditable]:not([contenteditable=false])",ze=()=>{let e=an(Ne());return!!e&&""!==e.value||!!document.activeElement?.matches(Re)};function Oe(e,t=ze(),n=Ne()){let o=[...d.e.querySelectorAll(`[data-thread="${e}"] .rbox textarea`)].find(e=>!e.closest("[inert]")),r=n?.getAttribute("data-thread");qe=r?`.${n.classList[0]}[data-thread="${r}"]`:"",!t&&o&&o.focus({preventScroll:!0})}let He=()=>!!k.t&&!he.w();function Ie(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 Be(t){let n=[t.root,...t.root.replies].filter(t=>t.author!==e.doc.me&&!t.deleted&&Gt(t,Jt(e.doc.me))).map(e=>e.id);n.length&&e.doc.seen(n).catch(()=>{})}let Fe=new Set;function je(e){let t=k.t?.anchor.view,n=M?.fe();Promise.resolve(F.S(t)||F.ne(t??{}).then(()=>he.He())).then(()=>{F.S(t)&&e?.(),n?.()})}function We(t,n=!1){if(e.host&&t)return k.t&&!he.w()?he._():(k.t=null,k.L=t,Pe(),Qe(t),e.host.open(t));if(t&&k.t&&!he.w())return he._();if(t&&k.u&&C)return C(t);if(k.i===t&&!k.t)return t?Oe(t):void 0;let o=!n&&ze(),r=Ne();if(t||(k.Fe=!1),le(),k.i=t,k.sent=!!t&&n,t){k.t=null,Qe(t);let n=e.doc.threads().find(e=>e.id===t);n&&Be(n)}Pe(),t&&(se(t),n&&T?.be()?T.xe():Oe(t,o||Fn(),r))}function Ke(e){k.L!==e&&(k.L=e,e&&e!==k.i&&Qe(e),Pe())}function Ve(e){ee(),k.t=e,k.i=null,Pe()}function Ue(e=""){let t=k.t;t&&(k.t=null,Pe(),e&&X("Comment discarded",()=>{k.t&&!he.w()||(Ve(t),T?.adopt(t),M?.fill(e))}))}function Ye(e,t){e.then(()=>te(t),e=>e instanceof Q?J(hr):oe(e))}function _e(e,t=!1){k.l!==e&&(k.l=e,e||(k.I=null),k.paused=!1,W=null,e?(k.i=null,T=Ao(he)):(ee(),T?.destroy(),T=null,te("Comment mode off")),Pe(),T&&(t&&T.Ne(),k.I?W=()=>J(cr,dr,!0):t?T.be()?W=()=>J(Co,1e4,!0,!0):J("Nothing here to comment on"):W=Fn()?G:()=>J(`Click anything to comment, or Tab between blocks \xb7 Option-click (Alt-click) to pin \xb7 Hold Space to use the page \xb7 This button, ${Mn} or Esc to finish`,dr,!0)))}function Ge(){let t=window.getSelection();k.l&&t&&!t.isCollapsed&&e.root.contains(t.anchorNode)?t.removeAllRanges():k.t&&he.w()?Ue():k.i?We(null):T&&!T.X()&&_e(!1)}function Xe(){k.t?He()||Ue():k.i&&We(null)}function Qe(e){let t=h.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?Dn(t):o?[o.getBoundingClientRect()]:[])}let et=new Set;function tt(e){let t=e().slice(0,6).map(()=>d.e.insertBefore(wt("div",{class:"pulse"}),d.e.firstChild)),n={els:t,at:e};et.add(n),rt(n),window.setTimeout(()=>{et.delete(n);for(let e of t)e.remove()},1300)}function rt(e){let t=e.at();e.els.forEach((e,n)=>t[n]&&Et(e,t[n],4))}function it(){le();let e=!!Ne()?.closest(".rbox");for(let e of A)e.destroy();A=function(e){return[..."column"===e.state.mode?[io(e),lo(e,{ve:!1})]:[lo(e,{ve:!0})],Po(e),Do(e)]}(he),Pe(),k.i&&se(k.i,e)}gt.go=t=>{if(t.startsWith("slide:"))return void F.ne({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:p?"auto":"smooth"}),window.setTimeout(()=>tt(()=>[o.getBoundingClientRect()]),p?0:450))};let at={x:0,y:0};let lt=()=>{if(!P){if(function(){let e=d.e.getBoundingClientRect();!Math.round(e.left)&&!Math.round(e.top)||(at={x:at.x-Math.round(e.left),y:at.y-Math.round(e.top)},d.e.style.transform=at.x||at.y?`translate(${at.x}px,${at.y}px)`:"",(e=>{jn=e})(at.y))}(),W&&!k.s&&(!E.classList.contains("show")||j)){let e=W;W=null,e()}Se&&(performance.now()>Se&&(Se=0),$e=!0,dispatchEvent(new Event("resize")),$e=!1);for(let e of A)e.N();for(let e of et)rt(e);T?.N(),fe.N(),z=requestAnimationFrame(lt)}},st=e=>{let t=e.composedPath()[0];return t instanceof Element&&null!==t.closest(Re)},dt=e=>{if("Escape"===e.key)return e.isComposing?void 0:Ge();if($&&"KeyZ"===e.code&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey){let t=e.composedPath()[0];if(!st(e)||t instanceof HTMLTextAreaElement&&t.getRootNode()===d.shadow&&""===t.value)return e.preventDefault(),$()}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&&!st(e)){if(e.preventDefault(),T?.lt()&&T.Ne())return;_e(!k.l,!0)}},ct=e=>{if(he.O(e)||v.has(e))return;let t=window.getSelection();t&&!t.isCollapsed||Xe()},pt=window.innerWidth,ut=0;function ht(){let e=k.i?h.get(k.i):k.t?.resolved,t=(e?.range??e?.element)?.getBoundingClientRect();t&&(t.top<0||t.bottom>window.innerHeight)&&window.scrollBy({top:t.top-16,behavior:p?"auto":"smooth"})}let ft=Wn().bottom,mt=!1,vt=0,yt=()=>{let e=window.visualViewport,t=Ne();d.e.classList.toggle("kb",!!e&&window.innerHeight-e.height>150&&!!rn(t));let n=Wn().bottom;n<ft-80&&(mt=!0),ft=n,window.clearTimeout(vt),vt=window.setTimeout(()=>{if(!mt)return;mt=!1;let e=Wn(),t=k.i?h.get(k.i):k.t?.resolved,n=(t?.range??t?.element)?.getBoundingClientRect(),o=d.e.querySelector(".pop.show")?.offsetHeight??0;n&&(n.top<e.top||n.bottom+o+24>e.bottom)&&window.scrollBy({top:n.top-e.top-(Fn()?76:60),behavior:p?"auto":"smooth"})},250)},bt=()=>{if($e)return;window.innerWidth!==pt&&(pt=window.innerWidth,window.clearTimeout(ut),ut=window.setTimeout(ht,200)),d.e.style.setProperty("--pu-pop",`${In()}px`);let t=e.host?"bubbles":ur(e.root,"column"===k.mode);t!==k.mode?(k.mode=t,it()):Pe()};function xt(){let e=performance.now();0===N&&(R=e),window.clearTimeout(N);let t=Math.min(120,Math.max(0,R+1e3-e));N=window.setTimeout(()=>{N=0,me(),Pe()},t)}let kt=[],St=/^(video|canvas|iframe|img|object|embed|audio)$/,$t=new MutationObserver(()=>Ct()),Lt=null,Mt=0;function Ct(){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&&!St.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;$t.disconnect();for(let e of kt)e.getRootNode()!==document&&$t.observe(e,{attributeFilter:["open"]});if(d.element.parentNode===n)return;let o=!d.element.isConnected;n.append(d.element),o&&Lt?.isConnected&&performance.now()-Mt<100&&Lt.focus({preventScroll:!0})}let At=new MutationObserver(e=>{e.some(e=>e.removedNodes.length)&&Ct(),!e.every(e=>d.element.contains(e.target)||(e=>"childList"===e.type&&e.addedNodes.length+e.removedNodes.length>0&&[...e.addedNodes,...e.removedNodes].every(e=>e===d.element))(e))&&xt()}),Tt=e=>{let t=e.key,n=t=>e.composedPath().some(e=>e instanceof Element&&e.matches(t));("Enter"===t||" "===t||pr.includes(t)&&n(".menu,.all,.pm")||t.startsWith("Arrow")&&n(".menu"))&&e.stopPropagation()};for(let e of["keydown","keyup","keypress"])d.e.addEventListener(e,Tt);let Pt=e=>e===d.element,qt=e=>{"focusin"===e.type&&Ct(),Pt(e.target)&&("focusin"===e.type&&(Lt=e.composedPath()[0]),Mt="focusin"===e.type?1/0:performance.now()),("focusin"===e.type?Pt(e.target)&&!Pt(e.relatedTarget):Pt(e.relatedTarget)&&!Pt(e.target))&&e.stopImmediatePropagation()},Nt=null,Rt=!1;d.shadow.addEventListener("keydown",e=>{e===Nt&&(Rt=!0)});let Dt=e=>{if(e===Nt||!(e=>{let t=e.composedPath();if(!t.includes(d.element))return!1;let n=t[0];if(n instanceof Element&&n.matches(Re))return!0;let o=e.key,r=e=>t.some(t=>t instanceof Element&&t.matches(e));return["Escape","Tab","Enter"," "].includes(o)||pr.includes(o)&&r(".menu,.all,.pm,.rxp")||o.startsWith("Arrow")&&r(".menu,.rxp")})(e)||(e.stopImmediatePropagation(),"keydown"!==e.type))return;let t=Nt=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,composed:!1});Rt=!1,e.composedPath()[0].dispatchEvent(t),Nt=null,t.defaultPrevented&&e.preventDefault(),Rt&&dt(e)},zt=e=>e.stopPropagation(),Ot=["pointerdown","mousedown","touchstart","click","focusin","focusout"];for(let e of["focusin","focusout"])window.addEventListener(e,qt,!0);for(let e of Ot)d.element.addEventListener(e,zt);for(let e of["keydown","keyup","keypress"])document.addEventListener(e,Dt,!0);document.addEventListener("fullscreenchange",Ct);let Ht=()=>kt.length&&Ct();for(let e of["transitionend","animationend"])window.addEventListener(e,Ht,!0);window.addEventListener("keydown",dt),window.addEventListener("click",ct),window.addEventListener("resize",bt);for(let e of["resize","scroll"])window.visualViewport?.addEventListener(e,yt);At.observe(e.root,{subtree:!0,childList:!0,characterData:!0});let It=0,Bt=t=>{let n="dark"===t;d.e.classList.toggle("flip",n!==a),n!==i&&(i=n,window.clearTimeout(It),d.e.classList.add("fading"),It=window.setTimeout(()=>{er(d.e,Qo(e.root,t)),d.e.classList.remove("fading")},170))},Wt=()=>{Bt(s()),we=new WeakMap,ve(re())},Kt=0,Vt=()=>{Kt||(Kt=window.setTimeout(()=>{Wt(),Kt=window.setTimeout(()=>{Kt=0,Wt()},450)},150))},Ut=new MutationObserver(e=>{e.some(e=>"open"===e.attributeName&&"dialog"===e.target.localName)&&Ct(),!e.every(e=>e.target===d.element)&&Vt()});Ut.observe(document.documentElement,{attributes:!0,subtree:!0});let Zt=window.matchMedia?.("(prefers-color-scheme: dark)");Zt?.addEventListener?.("change",Vt);let Xt=new ResizeObserver(xt);Xt.observe(e.root);let Qt=e.doc.onChange((e,t,n)=>{fe.Ue(t,n),me(),Pe()});return me(),it(),Ct(),z=requestAnimationFrame(lt),{ctx:he,appearance:()=>r,goTo(e){let t=h.get(e);(t?.element??t?.range?.startContainer.parentElement)?.scrollIntoView({block:"center",behavior:p?"auto":"smooth"}),Ke(e)},destroy(){P=!0,cancelAnimationFrame(z),cancelAnimationFrame(xe),cancelAnimationFrame(K),F.destroy(),window.clearTimeout(Ee),window.clearTimeout(q),window.clearTimeout(ut),window.clearTimeout(N),window.clearTimeout(D),At.disconnect(),gt.go=void 0,Xt.disconnect(),Ut.disconnect(),Zt?.removeEventListener?.("change",Vt),window.clearTimeout(Kt),window.clearTimeout(It),Qt(),window.removeEventListener("keydown",dt),nn(null,null),window.removeEventListener("click",ct);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",Ct);for(let e of["transitionend","animationend"])window.removeEventListener(e,Ht,!0);$t.disconnect(),window.removeEventListener("resize",bt);for(let e of["resize","scroll"])window.visualViewport?.removeEventListener(e,yt);window.clearTimeout(vt),document.body?.removeEventListener("click",Le),T?.destroy();for(let e of A)e.destroy();fe.destroy(),c.remove(),d.destroy()}}}var gr=(e,t,n)=>Object.assign(new Error(`pipeup: ${t}`,{cause:n}),{code:e}),vr=null;function wr(e={}){if(kn)return kn.mount(e);if(!$n())return Promise.reject(gr("another-copy","another copy of Pipeup owns the add-on queue. Remove one script."));if(vr)return vr;let t=async function(e,t){Bt({...Object.fromEntries(Object.entries(e.settings??{}).filter(([e])=>e.startsWith("data-pipeup-"))),"data-pipeup-doc":e.doc,"data-pipeup-layout":e.layout,"data-pipeup-theme":e.theme,"data-pipeup-select":e.select,"data-pipeup-control":e.control});let n,o,r=Ft("data-pipeup-doc"),{id:a,key:l}=r?await _(r):{id:`page-${i(location.origin+location.pathname)}`,key:null},s=!1;if(e.store)n=e.store,o=await ie(n);else try{let e=ae.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 ie(n)}catch{n=new re,s=!0,o=await ie(n)}let d=e.name?.trim();d&&d!==o.name&&(o={...o,name:d},await n.saveProfile(o)),e.store||navigator.storage?.persist?.().catch(()=>{});let c=await ee.open({doc:a,key:l,store:n,identity:o.identity,name:o.name});Wo(e.slides??null);let p,u=new Set,h=new Set,f="",m=()=>queueMicrotask(()=>{if(!p||v)return;let e={commentMode:p.ctx.state.l,name:c.name},t=JSON.stringify(e);if(t!==f){f=t;for(let t of[...u])try{t({...e})}catch(e){globalThis.reportError?.(e)}}}),g=async e=>{c.name=e,o={...o,name:e},m(),await n.saveProfile(o)},v=!1;try{p=mr({doc:c,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)}.cm{display:flex;align-items:center;gap:6px;max-height:20px;padding-top:4px;overflow:hidden;font-size:12px;color:var(--fa)}.hdr .cm{display:inline-grid;padding:0;flex:none}.cm.new{animation:pu-in var(--mv) var(--eo) both}.cm.out{animation:cm-out var(--mv) var(--eo) forwards}@keyframes cm-out{to{opacity:0;max-height:0;padding-top:0}}.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}.launch.off{display: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:has(.mm[aria-expanded=true]) .ttip{grid-template-columns:minmax(0,0fr);opacity:0}.launch .mm{display:grid;place-items:center;width:0;height:24px;margin-left:0;border-radius:6px;overflow:hidden;opacity:0;color:inherit;transition:width var(--out) var(--ei),margin var(--out) var(--ei),opacity var(--out) var(--ei),background-color .2s var(--eo)}.launch:is(:hover,:has(.mm:focus-visible)) .mm{width:26px;margin-left:4px;opacity:1;transition:width var(--mv) var(--eo) .4s,margin var(--mv) var(--eo) .4s,opacity var(--in) var(--eo) .4s,background-color .2s var(--eo)}.launch:has(.mm:focus-visible) .mm{transition-delay:0s}.launch .mm:hover{background:color-mix(in srgb,currentColor 12%,transparent)}.launch .mm:focus-visible{outline:2px solid var(--pu-accent);outline-offset:-2px}.launch:has(.mm[aria-expanded=true]) .mm{width:0;margin-left:0;opacity:0}.launch .mode{-webkit-touch-callout:none;-webkit-user-select:none;user-select:none}.launch:has(.mm:focus-visible) .ttip{grid-template-columns:minmax(0,1fr);opacity:1}@media(hover:none){.ttip,.tt,.cd>.thread .acts,.launch .mm{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{z-index:2;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)}.bts .here{flex:none;display:grid;place-items:center;margin-right:auto;padding:0 2px;color:var(--fa);transition:opacity var(--in) var(--eo)}.here.off{opacity:0;pointer-events:none}.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)}.fold{display:flex;align-items:center;gap:4px;width:100%;margin-top:6px;border-radius:6px;text-align:left;cursor:pointer}.fold:hover,.fold:focus-visible{color:var(--mu);outline:none}.fold svg{transition:transform var(--mv) var(--eio)}.fold[aria-expanded=true] svg{transform:rotate(90deg)}.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}}@keyframes cm-out{99%{opacity:0;max-height:20px;padding-top:4px}to{opacity:0;max-height:0;padding-top:0}}.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:g,onRender:m,..."host"===e.ui?{host:{open:e=>{for(let t of[...h])try{t(e)}catch(e){globalThis.reportError?.(e)}}}}:{},...e.prefs?{prefs:e.prefs}:{},...e.closed?{closed:!0}:{},...e.field?{field:e.field}:{}})}catch(e){throw Wo(null),e}let w=p;s&&w.ctx.ue("This browser can't keep comments for this page \u2014 copy the comments (Copy comments \u203a As Markdown) to keep them");let y=()=>{c.flush().catch(e=>globalThis.reportError?.(e))},b=function(e){let t={...e,i:!0};xn=t;for(let e of bn.values())"waiting"===e.info.state&&Ln(e,t);return()=>{t.i=!1,xn===t&&(xn=null);for(let e of[...bn.values()].reverse())e.stop?.(),delete e.stop;e.surface.destroy()}}({surface:w.ctx.addons,doc:c,root:e.root??document.body,ephemeral:s,...e.keep?{keep:e.keep}:{},version:ct,onIdentity:async e=>{o={...o,identity:e},await n.saveProfile(o)}}),x=/\S/.test(Ft("data-pipeup-agents")??"")?window.setTimeout(()=>{En().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;return"off"!==Ft("data-pipeup-updates")&&Date.now()-Date.parse(pt)>31536e6&&console.info(`pipeup: this is Pipeup ${ct}, from ${pt}; newer versions exist. See https://github.com/pipeup-ai/pipeup/blob/main/CHANGELOG.md`),window.addEventListener("pagehide",y),{document:c,comments:({all:e=!1,edition:t=!1}={})=>dt(w.ctx.s.all().filter(e=>!t||!w.ctx.E(e.thread)),{title:document.title,url:location.href,exportedAt:new Date,all:e}),appearance:()=>({...w.appearance()}),flush:()=>c.flush(),get commentMode(){return w.ctx.state.l},setCommentMode:async e=>{v||w.ctx.se(!!e)},openMenu:async()=>{v||w.ctx.pageControls?.s()},openAllComments:async()=>{v||w.ctx.pageControls?.list()},get name(){return c.name},setName:async e=>{let t=String(e).replace(/\s+/g," ").trim();!t||t===c.name||v||(await g(t),w.ctx.m())},on:(e,t)=>{if("function"!=typeof t)return()=>{};let n="change"===e?u:"open"===e?h:null;return n?(n.add(t),()=>n.delete(t)):()=>{}},commentsAs:(e,{all:t=!1}={})=>ot(w.ctx.s.all(),"text"===e?"text":"ai",{title:document.title,url:location.href,exportedAt:new Date,all:t}),get look(){return w.ctx.s.look()},setLook:async e=>{!v&&("auto"===e||"light"===e||"dark"===e)&&w.ctx.s.setLook(e)},get hidden(){return w.ctx.state.hide},setHidden:async e=>{v||w.ctx.s.setHide(!!e)},startComment:async t=>{if(v)return;let n=w.ctx;if(n.state.t&&!n.w())return n._();let o=e.root??document.body,r=t instanceof Range;n.Ie({anchor:r?Ae(t,o,n.f.view(t.commonAncestorContainer)):Te(t,o,void 0,n.f.view(t)),label:r?`\u201c${t.toString().replace(/\s+/g," ").trim().slice(0,60)}\u201d`:Ge(t),ranges:r?[t]:[],resolved:{state:"attached",element:r?null:t,range:r?t:null}})},openThread:async t=>{v||("host"===e.ui?w.goTo(String(t)):w.ctx.open(String(t)))},unmount:()=>{v||(v=!0,u.clear(),h.clear(),Bt(null),window.removeEventListener("pagehide",y),window.clearTimeout(x),b(),w.destroy(),Wo(null),vr===t()&&(vr=null))}}}(e,()=>t).catch(e=>{throw vr===t&&(vr=null),Bt(null),e?.code?e:gr("failed",`Pipeup couldn't start: ${String(e?.message??e)}`,e)});return vr=t,t}typeof document<"u"&&(kn?console.warn(`pipeup: Pipeup is on this page twice (${kn.VERSION} and ${ct}); the first one is used. Remove one script.`):($n(),function(){if("off"===Ft("data-pipeup-auto"))return;let e=()=>{wr().catch(e=>console.error(e))};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e,{once:!0}):e()}()));const yr=Object.defineProperty({},"__esModule",{value:!0});for(const[t,n]of Object.entries({ADDON_API:1,AI_NAME:v,ANIMALS:c,BUILT:pt,COLOURS:p,DEFAULT_PROFILE_NAME:"",IndexedDbStore:ae,MemoryStore:re,PipeupDocument:ee,UnsavedChangeError:Q,VERSION:ct,addons:En,agentComments:dt,agentName:y,animalName:m,checkOp:async function(e){return F(e)&&await j(e).catch(()=>!1)},comments:async function(e){if(!vr)throw new Error("pipeup: Pipeup hasn't started on this page");return(await vr).comments(e)},computeOpId:V,copyAll:ot,copyThread:nt,createIdentity:s,describeElement:Te,describeRange:Ae,formatAgo:tt,isAiName:w,isPasted:b,labelOf:Ge,loadOrCreateProfile:ie,locate:Ze,mount:wr,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 Bo.add(e),()=>{Bo.delete(e)}},parseDocumentAttribute:_,readFeedbackFile:J,resolveAnchor:De,setPeople:function(e){Vt=e.filter(e=>e&&"string"==typeof e.name&&e.name.trim()&&Kt.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[...Ut])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===Je||o.length>64||r.length>S)){if(++n>=16)break;t[o]=r}}Ho=t;for(let e of Fo)e()},setting:Ft,signOp:z,use:Sn}))Object.defineProperty(yr,t,{value:n,enumerable:!0});return yr})();
2
2
  "use strict";(()=>{function A(t){let e=globalThis;(e.pipeupAddons||=[]).push(t),typeof addEventListener=="function"&&addEventListener("load",()=>{e.Pipeup||console.error(`pipeup: the "${t.id}" add-on needs Pipeup on the page too; load pipeup.min.js.`)},{once:!0})}var me=2n**256n-2n**32n-977n;var M=`.dlg-t{margin:0 0 8px;font-size:15px;font-weight:600}
3
3
  .dlg-b p{margin:0 0 8px;font-size:13px;line-height:1.5;color:var(--mu)}
4
4
  .dlg-c{display:block;margin:8px 0;padding:8px 10px;border-radius:8px;background:var(--so);font:12px/1.6 ui-monospace,monospace;word-break:break-all;user-select:all}
@@ -9,5 +9,5 @@
9
9
  .dlg-btn:hover,.dlg-btn:focus-visible{background:var(--ho);outline:none}
10
10
  .dlg-btn.primary{border-color:var(--pu-accent);color:var(--pu-accent)}
11
11
  .dlg-h{margin:12px 0 4px;font-size:13px;font-weight:600}
12
- @media (pointer:coarse){.dlg-btn{min-height:40px}}`;var x="0123456789ABCDEFGHJKMNPQRSTVWXYZ";var P=Uint8Array.from([48,46,2,1,0,48,5,6,3,43,101,112,4,34,4,32]);function L(t){let e=0,o=0,r="";for(let p of t)for(o=o<<8|p,e+=8;e>=5;)r+=x[o>>>e-5&31],e-=5;return e&&(r+=x[o<<5-e&31]),r}function Z(t){let e=0,o=0,r=[];for(let p of t){let c=x.indexOf(p);if(c<0)return null;o=o<<5|c,e+=5,e>=8&&(r.push(o>>>e-8&255),e-=8)}return Uint8Array.from(r)}function I(t){let e=2166136261;for(let r of t)e=Math.imul(e^r,16777619);e=Math.imul(e^e>>>15,739982445);let o="";for(let r=0;r<4;r++,e>>>=5)o+=x[e&31];return o}function U(t){return`PU1-${(L(t)+I(t)).match(/.{1,4}/g).join("-")}`}function D(t){let e=new Uint8Array(P.length+t.length);return e.set(P),e.set(t,P.length),crypto.subtle.importKey("pkcs8",e,{name:"Ed25519"},!0,["sign"])}async function R(){let t=crypto.getRandomValues(new Uint8Array(32));return{key:await D(t),code:U(t)}}async function K(t){let e=t.toUpperCase().replace(/[\s-]+/g,"");if(!e.startsWith("PU1")||e.length!==59)return{problem:"shape"};let o=e.slice(3).replace(/O/g,"0").replace(/[IL]/g,"1").replace(/U/g,"V"),r=Z(o.slice(0,52));if(!r||r.length<32)return{problem:"shape"};let p=r.slice(0,32);return I(p)!==o.slice(52)||L(p)!==o.slice(0,52)?{problem:"mistake"}:{key:await D(p)}}var q={shape:"That doesn't look like a recovery code. It starts with PU1 and is about 60 characters long.",mistake:"The code has a mistake in it. Check it against where you kept it, character by character."};function s(t,e={},...o){let r=document.createElement(t);for(let[p,c]of Object.entries(e))r.setAttribute(p,c);return r.append(...o),r}function H(t){let e=t.identity,o=t.document,r=e.portable,p=o.threads().some(n=>[n.root,...n.root.replies].some(i=>i.author===o.me)),c=s("h2",{class:"dlg-t"}),u=s("div",{class:"dlg-b"}),C=s("p",{class:"dlg-m",role:"status"}),y=s("div",{class:"dlg-a"}),T={close(){}},m=(n=!1)=>{T.close(),n&&location.reload()},a=(n,i,l=!1)=>{let b=s("button",{class:l?"dlg-btn primary":"dlg-btn",type:"button"},n);return b.addEventListener("click",()=>void i()),b},f=(...n)=>n.map(i=>s("p",{},i)),d=n=>C.textContent=n,B=(n,i)=>{c.textContent=i?"Your portable identity":"Back up my identity";let l=s("code",{class:"dlg-c"},n);l.tabIndex=0,u.replaceChildren(...f("This code is you. Keep it somewhere safe, like a password manager. Anyone who has it can write as you, and Pipeup never sends it anywhere. Without it, a cleared browser starts you over as someone new."),l);let b=()=>{let O=URL.createObjectURL(new Blob([`${n}
13
- `],{type:"text/plain"})),v=s("a",{href:O,download:"pipeup-identity.pipeup-id"});u.append(v),v.click(),v.remove(),window.setTimeout(()=>URL.revokeObjectURL(O),1e3),d("Saved. Keep the file somewhere safe.")};y.replaceChildren(a("Copy code",()=>navigator.clipboard.writeText(n).then(()=>d("Copied."),()=>d("Your browser blocked copying; select the code and copy it by hand."))),a("Save as a file",b),a(i?"Done, and use it now":"Done",()=>m(i),!0)),i&&d("It is kept in this browser now. Reload to use it; your earlier comments stay as they are.")},$=()=>{d(""),r?(c.textContent="Back up my identity",u.replaceChildren(...f("One moment\u2026")),e.seed().then(n=>n?B(U(n),!1):d("This identity can't be backed up."))):(c.textContent="Make my identity portable",u.replaceChildren(...f("Your identity stays in this browser, and can't be taken out of it. To use it on another browser or computer, Pipeup makes you a new one that you can back up with a recovery code.",p?"Comments you wrote before stay as they are, and show as written by an earlier you.":"You haven't written comments here yet, so nothing is left behind.")),y.replaceChildren(a("Not now",()=>m()),a("Make it portable",async()=>{try{let n=await R();await e.use(n.key),B(n.code,!0)}catch{d("Something went wrong. Nothing was changed.")}},!0)))},z=()=>{d(""),c.textContent="Use my identity";let n=s("textarea",{class:"dlg-f",rows:"3","aria-label":"Recovery code",spellcheck:"false"}),i=s("input",{type:"file",accept:".pipeup-id,text/plain","aria-label":"Choose a recovery file"});i.addEventListener("change",async()=>{let l=await i.files?.[0]?.text();l&&(n.value=l.trim())}),u.replaceChildren(...f("Paste the recovery code you backed up, or choose its file. This replaces the identity in this browser."),n,i),y.replaceChildren(a("Cancel",()=>m()),a("Use this identity",async()=>{let l=await K(n.value);if("problem"in l)return d(q[l.problem]);await e.use(l.key),d(""),c.textContent="Done",u.replaceChildren(...f("Your identity is back. Comments you wrote on this page before stay as they are, and show as written by an earlier you.")),y.replaceChildren(a("Reload",()=>m(!0),!0))},!0)),n.focus({preventScroll:!0})};c.textContent="My identity",u.replaceChildren(...f(r?"Your identity is portable: you have a recovery code for it.":"Your identity stays in this browser, so a cleared browser, or another computer, starts you over as someone new."));let E=o.contacts().get(o.me)??"",h=s("input",{class:"dlg-f",type:"text",maxlength:"120","aria-label":"Email or GitHub name",spellcheck:"false",placeholder:"you@example.org or gh:yourname"});h.value=E;let F=a("Share",async()=>{let n=await e.share(h.value);n&&(g.hidden=!1),d(n?"Shared with everyone who has this page's comments.":"That isn't an email address or a GitHub name (gh:yourname).")}),g=a("Stop sharing",async()=>{await e.unshare(),h.value="",g.hidden=!0,d("Stopped. People who see this page's comments from now on won't see it.")});g.hidden=!E,u.append(s("h3",{class:"dlg-h"},"Let people reach you"),...f("If you share an email address or a GitHub name, people who mention you can offer to let you know. Everyone who has this page's comments can see it."),h,s("div",{class:"dlg-a"},g,F)),y.replaceChildren(a("Close",()=>m()),a("Use a recovery code",z),a(r?"Back up my identity":"Make it portable",$,!0));let N=s("div",{},c,u,C,y);T=t.openDialog(N,"Your identity")}var W=["M4 20h4L19 9l-4-4L4 16z"];function _(){return{id:"identity",api:1,version:"0.8.0",needs:["menu","styles","dialog","identity"],network:{when:"never",to:[],says:"Nothing. Your recovery code stays on this device unless you copy it or save it as a file yourself."},setup(t){t.addStyles(M),t.addMenuItem({id:"identity",icon:W,label:()=>"My identity",hint:()=>"Back it up, or use one you backed up",select:()=>H(t)})}}}A(_());})();
12
+ @media (pointer:coarse){.dlg-btn{min-height:40px}}`;var x="0123456789ABCDEFGHJKMNPQRSTVWXYZ";var P=Uint8Array.from([48,46,2,1,0,48,5,6,3,43,101,112,4,34,4,32]);function L(t){let e=0,o=0,r="";for(let p of t)for(o=o<<8|p,e+=8;e>=5;)r+=x[o>>>e-5&31],e-=5;return e&&(r+=x[o<<5-e&31]),r}function Z(t){let e=0,o=0,r=[];for(let p of t){let c=x.indexOf(p);if(c<0)return null;o=o<<5|c,e+=5,e>=8&&(r.push(o>>>e-8&255),e-=8)}return Uint8Array.from(r)}function I(t){let e=2166136261;for(let r of t)e=Math.imul(e^r,16777619);e=Math.imul(e^e>>>15,739982445);let o="";for(let r=0;r<4;r++,e>>>=5)o+=x[e&31];return o}function U(t){return`PU1-${(L(t)+I(t)).match(/.{1,4}/g).join("-")}`}function D(t){let e=new Uint8Array(P.length+t.length);return e.set(P),e.set(t,P.length),crypto.subtle.importKey("pkcs8",e,{name:"Ed25519"},!0,["sign"])}async function K(){let t=crypto.getRandomValues(new Uint8Array(32));return{key:await D(t),code:U(t)}}async function R(t){let e=t.toUpperCase().replace(/[\s-]+/g,"");if(!e.startsWith("PU1")||e.length!==59)return{problem:"shape"};let o=e.slice(3).replace(/O/g,"0").replace(/[IL]/g,"1").replace(/U/g,"V"),r=Z(o.slice(0,52));if(!r||r.length<32)return{problem:"shape"};let p=r.slice(0,32);return I(p)!==o.slice(52)||L(p)!==o.slice(0,52)?{problem:"mistake"}:{key:await D(p)}}var q={shape:"That doesn't look like a recovery code. It starts with PU1 and is about 60 characters long.",mistake:"The code has a mistake in it. Check it against where you kept it, character by character."};function s(t,e={},...o){let r=document.createElement(t);for(let[p,c]of Object.entries(e))r.setAttribute(p,c);return r.append(...o),r}function H(t){let e=t.identity,o=t.document,r=e.portable,p=o.threads().some(n=>[n.root,...n.root.replies].some(i=>i.author===o.me)),c=s("h2",{class:"dlg-t"}),u=s("div",{class:"dlg-b"}),T=s("p",{class:"dlg-m",role:"status"}),y=s("div",{class:"dlg-a"}),C={close(){}},m=(n=!1)=>{C.close(),n&&location.reload()},a=(n,i,l=!1)=>{let b=s("button",{class:l?"dlg-btn primary":"dlg-btn",type:"button"},n);return b.addEventListener("click",()=>void i()),b},f=(...n)=>n.map(i=>s("p",{},i)),d=n=>T.textContent=n,B=(n,i)=>{c.textContent=i?"Your portable identity":"Back up my identity";let l=s("code",{class:"dlg-c"},n);l.tabIndex=0,u.replaceChildren(...f("This code is you. Keep it somewhere safe, like a password manager. Anyone who has it can write as you, and Pipeup never sends it anywhere. Without it, a cleared browser starts you over as someone new."),l);let b=()=>{let O=URL.createObjectURL(new Blob([`${n}
13
+ `],{type:"text/plain"})),v=s("a",{href:O,download:"pipeup-identity.pipeup-id"});u.append(v),v.click(),v.remove(),window.setTimeout(()=>URL.revokeObjectURL(O),1e3),d("Saved. Keep the file somewhere safe.")};y.replaceChildren(a("Copy code",()=>navigator.clipboard.writeText(n).then(()=>d("Copied."),()=>d("Your browser blocked copying; select the code and copy it by hand."))),a("Save as a file",b),a(i?"Done, and use it now":"Done",()=>m(i),!0)),i&&d("It is kept in this browser now. Reload to use it; your earlier comments stay as they are.")},$=()=>{d(""),r?(c.textContent="Back up my identity",u.replaceChildren(...f("One moment\u2026")),e.seed().then(n=>n?B(U(n),!1):d("This identity can't be backed up."))):(c.textContent="Make my identity portable",u.replaceChildren(...f("Your identity stays in this browser, and can't be taken out of it. To use it on another browser or computer, Pipeup makes you a new one that you can back up with a recovery code.",p?"Comments you wrote before stay as they are, and show as written by an earlier you.":"You haven't written comments here yet, so nothing is left behind.")),y.replaceChildren(a("Not now",()=>m()),a("Make it portable",async()=>{try{let n=await K();await e.use(n.key),B(n.code,!0)}catch{d("Something went wrong. Nothing was changed.")}},!0)))},z=()=>{d(""),c.textContent="Use my identity";let n=s("textarea",{class:"dlg-f",rows:"3","aria-label":"Recovery code",spellcheck:"false"}),i=s("input",{type:"file",accept:".pipeup-id,text/plain","aria-label":"Choose a recovery file"});i.addEventListener("change",async()=>{let l=await i.files?.[0]?.text();l&&(n.value=l.trim())}),u.replaceChildren(...f("Paste the recovery code you backed up, or choose its file. This replaces the identity in this browser."),n,i),y.replaceChildren(a("Cancel",()=>m()),a("Use this identity",async()=>{let l=await R(n.value);if("problem"in l)return d(q[l.problem]);await e.use(l.key),d(""),c.textContent="Done",u.replaceChildren(...f("Your identity is back. Comments you wrote on this page before stay as they are, and show as written by an earlier you.")),y.replaceChildren(a("Reload",()=>m(!0),!0))},!0)),n.focus({preventScroll:!0})};c.textContent="My identity",u.replaceChildren(...f(r?"Your identity is portable: you have a recovery code for it.":"Your identity stays in this browser, so a cleared browser, or another computer, starts you over as someone new."));let E=o.contacts().get(o.me)??"",h=s("input",{class:"dlg-f",type:"text",maxlength:"120","aria-label":"Email or GitHub name",spellcheck:"false",placeholder:"you@example.org or gh:yourname"});h.value=E;let F=a("Share",async()=>{let n=await e.share(h.value);n&&(g.hidden=!1),d(n?"Shared with everyone who has this page's comments.":"That isn't an email address or a GitHub name (gh:yourname).")}),g=a("Stop sharing",async()=>{await e.unshare(),h.value="",g.hidden=!0,d("Stopped. People who see this page's comments from now on won't see it.")});g.hidden=!E,u.append(s("h3",{class:"dlg-h"},"Let people reach you"),...f("If you share an email address or a GitHub name, people who mention you can offer to let you know. Everyone who has this page's comments can see it."),h,s("div",{class:"dlg-a"},g,F)),y.replaceChildren(a("Close",()=>m()),a("Use a recovery code",z),a(r?"Back up my identity":"Make it portable",$,!0));let N=s("div",{},c,u,T,y);C=t.openDialog(N,"Your identity")}var W=["M4 20h4L19 9l-4-4L4 16z"];function _(){return{id:"identity",api:1,version:"0.8.0",needs:["menu","styles","dialog","identity"],network:{when:"never",to:[],says:"Nothing. Your recovery code stays on this device unless you copy it or save it as a file yourself."},setup(t){t.addStyles(M),t.addMenuItem({id:"identity",icon:W,label:()=>"My identity",hint:()=>"Back it up, or use one you backed up",select:()=>H(t)})}}}A(_());})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipeup/identity",
3
- "version": "0.9.1",
3
+ "version": "1.0.0",
4
4
  "description": "Makes a reviewer's identity portable: a recovery code or file to back it up, and using it on another browser or computer; and sharing a way to be reached.",
5
5
  "license": "MIT",
6
6
  "author": "Pipeup contributors",
@@ -24,7 +24,7 @@
24
24
  "LICENSE"
25
25
  ],
26
26
  "peerDependencies": {
27
- "pipeup": "0.9.1"
27
+ "pipeup": "1.0.0"
28
28
  },
29
29
  "pipeup": {
30
30
  "network": {