@pipeup/identity 0.7.0 → 0.8.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,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=2**40,b=2**47,x=1e4,k=/^[0-9a-f]{8}$/,E=/^[A-Za-z0-9_-]{43}$/,$=/^(?:[^\s@<>"]{1,64}@[^\s@<>"]{1,190}\.[^\s@<>"]{2,24}|gh:[A-Za-z0-9-]{1,39})$/,S=/^(?:[A-Za-z0-9_-]{43}|(?:host|gh):[A-Za-z0-9._@-]{1,64})$/,L=/^[A-Za-z0-9_-]{43}$/,M=new Set(["create","reply","edit","delete","resolve","reopen","addressed","react","unreact","seen","contact","uncontact"]),A=/^(?:\p{Regional_Indicator}{2}|[#*0-9]\uFE0F?\u20E3|\p{Extended_Pictographic}(?:\uFE0F|\p{Emoji_Modifier})?(?:\u200D\p{Extended_Pictographic}(?:\uFE0F|\p{Emoji_Modifier})?)*)$/u,C=e=>"string"==typeof e&&A.test(e)&&[...e].length<=16;async function T(e,t){if(e.author!==t.publicKey)throw new Error("pipeup: an op must be signed by its author");return{body:e,sig:await d(t,n(o(e)))}}var P=(e,t)=>"string"==typeof e&&e.length<=t,q=e=>!!e&&"object"==typeof e,N=e=>"number"==typeof e&&Number.isFinite(e)&&e>=0&&e<=1;function R(e){if(!q(e))return!1;let{id:t,path:n,fingerprint:o,snapshot:r,quote:i,point:a,view:l}=e;if(!(P(n,2e3)&&P(r,500)&&"string"==typeof o&&k.test(o)&&(void 0===t||P(t,200)&&""!==t)&&(void 0===i||q(i)&&P(i.exact,x)&&""!==i.exact&&P(i.prefix,64)&&P(i.suffix,64))&&(void 0===a||q(a)&&N(a.x)&&N(a.y))))return!1;if(void 0!==l){if(!q(l)||Array.isArray(l))return!1;let e=Object.entries(l);if(e.length>16||!e.every(([e,t])=>e.length<=64&&P(t,200)))return!1}return!0}function z(e){if(!q(e))return!1;let{body:t,sig:n}=e;if("string"!=typeof n||!q(t)||JSON.stringify({body:t,sig:n}).length>262144)return!1;let o=t;if(1!==o.v||"string"!=typeof o.id||!E.test(o.id)||!M.has(o.kind)||!P(o.doc,64)||""===o.doc||"string"!=typeof o.thread||!E.test(o.thread)||"string"!=typeof o.author||!L.test(o.author)||"string"!=typeof o.name||o.name.length>80||o.name!==o.name.trim()||"number"!=typeof o.clock||!Number.isSafeInteger(o.clock)||o.clock<1||o.clock>y||"number"!=typeof o.at||!Number.isSafeInteger(o.at)||o.at<0||o.at>b||void 0!==o.text&&(!P(o.text,1e4)||o.text!==o.text.trim())||void 0!==o.target&&("string"!=typeof o.target||!E.test(o.target))||("create"===o.kind||"reply"===o.kind||"edit"===o.kind||"addressed"===o.kind)&&!o.text||("reply"===o.kind||"edit"===o.kind||"delete"===o.kind)&&!o.target)return!1;if(void 0!==o.mentions){if("create"!==o.kind&&"reply"!==o.kind&&"edit"!==o.kind||!Array.isArray(o.mentions)||o.mentions.length>20)return!1;let e=o.text?.length??0;for(let t of o.mentions){if(!q(t)||!Number.isSafeInteger(t.start)||!Number.isSafeInteger(t.end))return!1;let{start:n,end:o,ref:r}=t;if(n<0||o<=n||o>e||"string"!=typeof r||!S.test(r))return!1}}return!(!("contact"!==o.kind||"string"==typeof o.text&&$.test(o.text))||"seen"===o.kind&&!o.target||!("react"!==o.kind&&"unreact"!==o.kind||o.target&&C(o.text))||!("create"!==o.kind||o.id===o.thread&&R(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 O(e,t){return e.body.clock!==t.body.clock?e.body.clock-t.body.clock:e.body.at!==t.body.at?e.body.at-t.body.at:e.body.author!==t.body.author?e.body.author<t.body.author?-1:1:e.body.id!==t.body.id?e.body.id<t.body.id?-1:1:0}function D(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 I(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 j=class{constructor(e){this.doc=e}ops=new Map;clock=0;createAt=new Map;threadAt=new Map;get size(){return this.ops.size}all(){return[...this.ops.values()]}threads(){return function(e){let t=new Map,n=new Map,o=new Map;for(let{body:r}of[...e].sort(O)){if(r.name&&o.set(r.author,r.name),"create"===r.kind){if(t.has(r.id)||!r.anchor||void 0===r.text)continue;let e=D(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=D(r.id,r.author,r.name,r.text,r.at,r.mentions);e.root.replies.push(t),n.set(r.id,{comment:t,thread:r.thread});continue}if("seen"===r.kind){let e=i.comment.seenBy??=[];e.includes(r.author)||e.push(r.author);continue}if("react"===r.kind||"unreact"===r.kind){if(void 0===r.text||i.comment.deleted)continue;let e=i.comment.reactions,t=e.find(e=>e.emoji===r.text);if("react"===r.kind){let n={author:r.author,name:r.name};t?t.by.some(e=>e.author===r.author)||t.by.push(n):e.length<12&&e.push({emoji:r.text,by:[n]})}else t&&(t.by=t.by.filter(e=>e.author!==r.author),t.by.length||e.splice(e.indexOf(t),1));continue}r.author!==i.comment.author||i.comment.deleted||("edit"===r.kind&&void 0!==r.text&&(i.comment.text=r.text,i.comment.edited=!0,r.mentions?i.comment.mentions=r.mentions:delete i.comment.mentions),"delete"===r.kind&&(i.comment.text="",i.comment.deleted=!0,i.comment.reactions=[],delete i.comment.mentions))}}for(let{comment:e}of n.values()){e.name||(e.unnamed=!0,e.name=o.get(e.author)??"");for(let t of e.reactions)for(let e of t.by)e.name||=o.get(e.author)??""}let r=new Map,i=(e,t)=>{let n=g({author:e,name:t}).toLowerCase();(r.get(n)??r.set(n,new Set).get(n)).add(e)};for(let{comment:e}of n.values()){i(e.author,e.name);for(let t of e.reactions)for(let e of t.by)i(e.author,e.name)}let a=(e,t)=>(r.get(g({author:e,name:t}).toLowerCase())?.size??0)>1;for(let{comment:e}of n.values()){a(e.author,e.name)&&(e.alike=!0);for(let t of e.reactions)for(let e of t.by)a(e.author,e.name)&&(e.alike=!0)}return[...t.values()]}(this.ops.values())}async add(e){let t=[];for(let n of e){if(!z(n)||n.body.doc!==this.doc||this.ops.has(n.body.id)||n.body.id!==await I(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,y),at:Math.min(Math.max(Date.now(),"create"===n.kind?(this.createAt.get(e.publicKey)??0)+1:(this.threadAt.get(n.thread)??0)+1),b)};o.id=await I(o);let r=this.ops.get(o.id);if(r)return r;"create"===o.kind&&(o.thread=o.id);let[i]=await this.add([await T(o,e)]);if(!i)throw new Error("pipeup: could not record this change");return i}},B=/^([A-Za-z0-9_-]{16}):([A-Za-z0-9_-]{43})$/;async function H(e){let n=B.exec(e.trim()),o=n?.[1],r=n?.[2];if(!o||!r)throw new Error('pipeup: data-pipeup-doc must look like "<id>:<key>", as made by newDocumentAttribute()');return{id:o,key:await crypto.subtle.importKey("raw",t(r),{name:"AES-GCM"},!1,["encrypt","decrypt"])}}async function W(t,o,r){let i=crypto.getRandomValues(new Uint8Array(12)),a=await crypto.subtle.encrypt({name:"AES-GCM",iv:i,additionalData:n(r)},t,n(o));return{iv:e(i),data:e(new Uint8Array(a))}}var K=e=>`pipeup-file:${e}`;async function V(e,o,r){if(e.length>5e6)throw new Error("pipeup: this feedback file is too large");let i,a,l;try{i=JSON.parse(e)}catch{throw new Error("pipeup: this is not an Pipeup feedback file")}if(!i||"object"!=typeof i||1!==i.pipeup||"string"!=typeof i.doc)throw new Error("pipeup: this is not an Pipeup feedback file");if(i.doc!==o)throw new Error("pipeup: this feedback is for a different document");if(!i.sealed)return Array.isArray(i.ops)?i.ops:[];if(!r)throw new Error("pipeup: this feedback is sealed, and this page has no document key");if("string"!=typeof i.iv||"string"!=typeof i.data)throw new Error("pipeup: this is not an Pipeup feedback file");try{a=await async function(e,o,r){try{let i=await crypto.subtle.decrypt({name:"AES-GCM",iv:t(o.iv),additionalData:n(r)},e,t(o.data));return(new TextDecoder).decode(i)}catch{throw new Error("pipeup: this feedback could not be opened with this document")}}(r,{iv:i.iv,data:i.data},K(o))}catch{throw new Error("pipeup: this feedback could not be opened with this document's key")}try{l=JSON.parse(a)}catch{throw new Error("pipeup: this is not an Pipeup feedback file")}return Array.isArray(l)?l:[]}var Y=/^[a-z][a-z0-9-]{1,23}\/[a-z][a-z0-9-]{0,31}$/,U=class extends Error{constructor(e,t,n=1){super("pipeup: shown here, but not saved yet"),this.id=e,this.cause=t,this.count=n,this.name="UnsavedChangeError"}},_=class e{constructor(e,t){this.log=e,this.options=t,this.displayName=t.name.trim()?J(t.name):""}listeners=new Set;cache=[];comments=new Map;displayName;de=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 j(t.doc),o=await t.store.load(t.doc),r=o.length-(await n.add(o)).length;r&&console.warn(`pipeup: ${r} saved change${1===r?"":"s"} on this page couldn't be read; kept as saved`);let i=new e(n,t);return i.refresh(!1),i}get id(){return this.options.doc}get me(){return this.options.identity.publicKey}get name(){return this.displayName}set name(e){this.displayName=J(e),this.refresh(!0,[],"")}threads(){return this.cache}ops(){return this.log.all()}onChange(e){return this.listeners.add(e),()=>this.listeners.delete(e)}comment(e,t,n){return this.enqueue(()=>this.write({kind:"create",anchor:e,text:G(t),...n?.length?{mentions:n}:{}}))}reply(e,t,n){return this.enqueue(()=>this.write({kind:"reply",thread:this.find(e).thread,target:e,text:G(t),...n?.length?{mentions:n}:{}}))}edit(e,t,n){return this.enqueue(async()=>{let{thread:o}=this.mine(e);await this.write({kind:"edit",thread:o,target:e,text:G(t),...n?.length?{mentions:n}:{}})})}remove(e){return this.enqueue(async()=>{let{thread:t}=this.mine(e);await this.write({kind:"delete",thread:t,target:e})})}contact(e){let t=e.trim();return $.test(t)?this.enqueue(async()=>{await this.write({kind:"contact",thread:this.me,text:t})}):Promise.reject(new Error("pipeup: that isn't an email address or a GitHub name"))}uncontact(){return this.enqueue(async()=>{await this.write({kind:"uncontact",thread:this.me})})}contacts(){let e=new Map;for(let{body:t}of[...this.log.all()].sort(O))"contact"===t.kind&&t.text?e.set(t.author,t.text):"uncontact"===t.kind&&e.delete(t.author);return e}get portable(){return this.options.identity.privateKey.extractable}async seed(){let e=this.options.identity.privateKey;if(!e.extractable)return null;let{d:n}=await crypto.subtle.exportKey("jwk",e);return n?t(n):null}seen(e){return this.enqueue(async()=>{for(let t of e){let e=this.comments.get(t);e&&!e.comment.seenBy?.includes(this.me)&&await this.write({kind:"seen",thread:e.thread,target:t})}})}react(e,t){return this.enqueue(async()=>{await this.write({kind:"react",thread:this.find(e).thread,target:e,text:Z(t)})})}unreact(e,t){return this.enqueue(async()=>{await this.write({kind:"unreact",thread:this.find(e).thread,target:e,text:Z(t)})})}resolve(e){return this.enqueue(async()=>{await this.write({kind:"resolve",thread:this.thread(e)})})}reopen(e){return this.enqueue(async()=>{await this.write({kind:"reopen",thread:this.thread(e)})})}sign(e,t){if(!Y.test(e))throw new Error('pipeup: a signing purpose looks like "<add-on id>/<name>"');return d(this.options.identity,n(`pipeup:${e}\n${t}`))}flush(){return this.enqueue(()=>this.persist())}exportFile(){return async function(e,t,n){let o=n?{pipeup:1,doc:e,sealed:!0,...await W(n,JSON.stringify(t),K(e))}:{pipeup:1,doc:e,sealed:!1,ops:t};return JSON.stringify(o,null,2)}(this.options.doc,this.log.all(),this.options.key)}async importFile(e){return this.merge(await V(e,this.options.doc,this.options.key),"file")}merge(e,t){return e.length>5e3?Promise.reject(new RangeError("pipeup: too many changes to merge at once")):this.enqueue(async()=>{let n=await this.log.add([...e]);this.unsaved.push(...n),n.length>0&&this.refresh(!0,n,t);try{await this.persist()}catch(e){throw n.length>0?new U(n[0].body.id,e,n.length):e}return n.length})}enqueue(e){let t=this.de.then(e);return this.de=t.catch(()=>{}),t}async write(e){let t=await this.log.append(this.options.identity,this.displayName,e);this.unsaved.push(t),this.refresh(!0,[t],"local");try{await this.persist()}catch(e){throw new U(t.body.id,e)}return t.body.id}async persist(){if(0===this.unsaved.length)return;let e=[...this.unsaved];await this.options.store.append(this.options.doc,e),this.unsaved=this.unsaved.filter(t=>!e.includes(t))}refresh(e,t=[],n=""){this.cache=this.log.threads(),this.comments.clear();let o=(e,t)=>{e.unnamed&&e.author===this.me&&this.displayName&&(e.name=this.displayName),this.comments.set(e.id,{comment:e,thread:t});for(let n of e.replies)o(n,t)};for(let e of this.cache)o(e.root,e.id);if(e)for(let e of this.listeners)try{e(this.cache,t,n)}catch(e){globalThis.reportError?.(e)}}find(e){let t=this.comments.get(e);if(!t)throw new Error("pipeup: there is no comment with that id");return t}mine(e){let t=this.find(e);if(t.comment.author!==this.me)throw new Error("pipeup: only the writer can change a comment");return t}thread(e){if(!this.cache.some(t=>t.id===e))throw new Error("pipeup: there is no thread with that id");return e}};function G(e){let t=e.trim();if(!t)throw new Error("pipeup: a comment needs some words");if(t.length>1e4)throw new Error("pipeup: comments are limited to 10000 characters");return t}function Z(e){if(!C(e))throw new Error("pipeup: a reaction is one emoji");return e}function J(e){let t=e.replace(/\s+/g," ").trim();if(!t||t.length>80)throw new Error("pipeup: choose a name of 1 to 80 characters");if(w(t))throw new Error("pipeup: that name is kept for AI replies; choose another");return t}var X=class{docs=new Map;profile=null;async load(e){return[...this.docs.get(e)?.values()??[]]}async append(e,t){let n=this.docs.get(e);n||this.docs.set(e,n=new Map);for(let e of t)n.set(e.body.id,e)}async loadProfile(){return this.profile}async saveProfile(e){this.profile=e}async saveProfileIfAbsent(e){return this.profile||(this.profile=e),this.profile}};async function Q(e,t=""){let n=await e.loadProfile();if(n)return"Reviewer"===n.name?{...n,name:""}:n;let o={identity:await s(),name:t};return e.saveProfileIfAbsent(o)}var ee=class e{constructor(e){this.db=e}static open(t="pipeup"){return new Promise((n,o)=>{let r=indexedDB.open(t,1);r.onupgradeneeded=()=>{let e=r.result;e.createObjectStore("ops",{keyPath:["doc","id"]}).createIndex("doc","doc"),e.createObjectStore("meta")},r.onsuccess=()=>{let t=r.result;t.onversionchange=()=>t.close(),n(new e(t))},r.onerror=()=>o(r.error??new Error("pipeup: could not open local storage"))})}close(){this.db.close()}async load(e){return(await this.request("ops","readonly",t=>t.index("doc").getAll(e))).map(e=>e.op)}async append(e,t){if(0===t.length)return;let n=this.db.transaction("ops","readwrite"),o=n.objectStore("ops"),r=te(n);try{for(let n of t)o.put({doc:e,id:n.body.id,op:n})}catch(e){throw n.abort(),r.catch(()=>{}),e}await r}async loadProfile(){return await this.request("meta","readonly",e=>e.get("profile"))??null}async saveProfile(e){await this.request("meta","readwrite",t=>t.put(e,"profile"))}async saveProfileIfAbsent(e){let t=this.db.transaction("meta","readwrite"),n=t.objectStore("meta"),o=te(t),r=e,i=n.get("profile");return i.onsuccess=()=>{i.result?r=i.result:n.put(e,"profile")},await o,r}request(e,t,n){return new Promise((o,r)=>{let i=n(this.db.transaction(e,t).objectStore(e));i.onsuccess=()=>o(i.result),i.onerror=()=>r(i.error??new Error("pipeup: local storage request failed"))})}};function te(e){return new Promise((t,n)=>{e.oncomplete=()=>t(),e.onerror=()=>n(e.error??new Error("pipeup: local storage write failed")),e.onabort=()=>n(e.error??new Error("pipeup: local storage write aborted"))})}function ne(e){let t=(e.ownerDocument??e).createTreeWalker(e,NodeFilter.SHOW_TEXT),n=[],o="";for(let e=t.nextNode();e;e=t.nextNode())n.push({node:e,start:o.length}),o+=e.data;return{text:o,nodes:n}}function oe(e,t,n){let o=(e.ownerDocument??e).createRange();return o.setStart(e,0),o.setEnd(t,n),o.toString().length}function re(e,t,n){let o=ie(e,t,!1),r=ie(e,n,!0);if(!o||!r||n<t)return null;let i=o.node.ownerDocument.createRange();return i.setStart(o.node,o.offset),i.setEnd(r.node,r.offset),i}function ie(e,t,n){let o=e.nodes.find(e=>t>=e.start&&t<e.start+e.node.data.length+Number(n));return o&&{node:o.node,offset:t-o.start}}function ae(e){return e.nodeType===Node.ELEMENT_NODE?e:e.parentElement}function le(e,t){for(let n=ae(e)?.closest("[data-pipeup-id]")??null;n;){if(!t.contains(n))return null;let e=n.getAttribute("data-pipeup-id")??"";if(""!==e&&e.length<=200)return n;n=n.parentElement?.closest("[data-pipeup-id]")??null}return null}function se(e,t,n){return e.slice(t,n).replace(/^[\uDC00-\uDFFF]|[\uD800-\uDBFF]$/g,"")}function de(e,t){let n=function(e,t){if(e===t)return"";let n=[];for(let o=t;o&&o!==e;o=o.parentElement){let e=1;for(let t=o.previousElementSibling;t;t=t.previousElementSibling)t.tagName===o.tagName&&e++;n.unshift(`${o.tagName.toLowerCase()}:nth-of-type(${e})`)}return":scope > "+n.join(" > ")}(e,t);if(n.length>2e3)throw new Error("pipeup: this element is nested too deeply to comment on \u2014 give a nearby container a data-pipeup-id");return n}function ce(e){if(!R(e))throw new Error("pipeup: could not describe this place on the page");return e}function pe(e,t){let n=ae(e),o=n?.closest("p,li,h1,h2,h3,h4,h5,h6,td,th,blockquote,pre,figcaption,dt,dd,summary,caption")??null;return o&&t.contains(o)?o:n&&t.contains(n)?n:t}function ue(e,t,n){if(!t.contains(e.commonAncestorContainer))throw new Error("pipeup: the selection is outside the commentable area");let o=le(e.commonAncestorContainer,t),a=o??t,{text:l}=ne(a),s=oe(a,e.startContainer,e.startOffset),d=oe(a,e.endContainer,e.endOffset),c=l.slice(s,d);if(""===c)throw new Error("pipeup: select some text to comment on");if(c.length>x)throw new Error("pipeup: selections are limited to 10000 characters");let p=se(l,Math.max(0,s-32),s),u=se(l,d,d+32);return ce({...o?{id:o.getAttribute("data-pipeup-id")??""}:{},path:"",quote:{exact:c,prefix:p,suffix:u},...n?{view:n}:{},fingerprint:i(pe(e.startContainer,t).textContent??""),snapshot:se(r(p+c+u),0,200)})}function he(e,t,n,o){let a=le(e,t);return ce({...a?{id:a.getAttribute("data-pipeup-id")??""}:{},path:de(a??t,e),...n?{point:{x:fe(n.x),y:fe(n.y)}}:{},...o?{view:o}:{},fingerprint:i(e.textContent??""),snapshot:se(r(e.textContent??""),0,200)})}function fe(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):0}function me(e,t,n){let o=Array.from({length:t.length+1},(e,t)=>t),r=[...o],i=[t.length];for(let a=1;a<=e.length;a++){r[0]=n?0:a;for(let n=1;n<=t.length;n++){let i=e.charCodeAt(a-1)===t.charCodeAt(n-1)?0:1;r[n]=Math.min(o[n]+1,r[n-1]+1,o[n-1]+i)}i.push(r[t.length]),[o,r]=[r,o]}return i}var ge=(e,t)=>me(e,t,!1).pop(),ve={state:"orphaned",element:null,range:null};function we(e,t,n={}){let o=e.id?function(e,t){for(let n of e.querySelectorAll("[data-pipeup-id]"))if(n.getAttribute("data-pipeup-id")===t)return n;return null}(t,e.id):t;return e.quote?function(e,t,n,o,r){let a=n??o,l=ne(a),s=function(e,t){if(!t.exact)return-1;let n=-1,o=-1;for(let r=e.indexOf(t.exact);-1!==r;r=e.indexOf(t.exact,r+1)){let i=e.slice(Math.max(0,r-t.prefix.length),r),a=e.slice(r+t.exact.length,r+t.exact.length+t.suffix.length),l=be(i,t.prefix)+ye(a,t.suffix);l>o&&(n=r,o=l)}return n}(l.text,t);if(s>=0){let r=re(l,s,s+t.exact.length);if(r){let t=pe(r.startContainer,o);return{state:null!==n&&i(t.textContent??"")===e.fingerprint?"attached":"moved",element:t,range:r}}}if(r){let e=a===o?l:ne(o);if(e.text.length<=5e4&&t.exact.length>=12&&t.exact.length<=300){let n=function(e,t,n){let o=t.length;if(0===o)return null;let r=-1,i=1/0;if(me(e,t,!0).forEach((e,t)=>{t&&e<i&&(i=e,r=t)}),i>n)return null;let a=Math.max(0,r-o),l=1/0;for(let i=Math.max(0,r-o-n);i<=Math.min(r,r-o+n);i++){let n=ge(e.slice(i,r),t);n<l&&(l=n,a=i)}return{start:a,end:r,distance:l}}(e.text,t.exact,Math.floor(t.exact.length/4)),r=n?re(e,n.start,n.end):null;if(r)return{state:"moved",element:pe(r.startContainer,o),range:r}}}return ve}(e,e.quote,o,t,!1!==n.fuzzy):function(e,t){if(!t)return ve;let n=t;if(e.path){if(!e.path.startsWith(":scope > "))return ve;try{n=t.querySelector(e.path)}catch{return ve}}return n?{state:i(n.textContent??"")===e.fingerprint?"attached":"moved",element:n,range:null}:ve}(e,o)}function ye(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;return n}function be(e,t){let n=0;for(;n<e.length&&n<t.length&&e[e.length-1-n]===t[t.length-1-n];)n++;return n}var xe={A:"Link",BUTTON:"Button",P:"Paragraph",LI:"List item",IMG:"Image",TABLE:"Table",TD:"Cell",TH:"Cell",FIGURE:"Figure",SVG:"Graphic",CANVAS:"Graphic",LABEL:"Label",INPUT:"Field",SELECT:"Field",TEXTAREA:"Field",SUMMARY:"Question",BLOCKQUOTE:"Quote",SECTION:"Section",H1:"Heading",H2:"Heading",H3:"Heading",H4:"Heading",H5:"Heading",H6:"Heading"};function ke(e){return e.getAttribute("data-pipeup-label")||xe[e.tagName.toUpperCase()]||"Block"}function Ee(e){return Me(r(e.getAttribute("aria-label")??e.getAttribute("alt")??e.innerText??e.textContent??""),40)}function $e(e){let t=e.getAttribute("data-pipeup-label");if(t)return t;let n=Ee(e);return n?`${ke(e)} \xb7 ${n}`:ke(e)}function Se(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]")?.querySelector("h1,h2,h3")?.textContent;s.push(`Slide ${d}`+(e?` "${Me(r(e))}"`:""))}else{let t=Le(e.view);t&&s.push(t);let o=function(e,t){let n=null;for(let o of t.querySelectorAll("h1,h2,h3")){if(o===e||o.contains(e))break;if(!(4&o.compareDocumentPosition(e)))break;n=o}return n}(l,n);o&&s.push(`Section "${Me(r(o.textContent??""))}"`)}let c=$e(l);return s.push(c),{where:s.join(" \u203a "),element:c,id:o,quote:i,pin:a}}function Le(e){return e?e.label||Object.entries(e).filter(([e,t])=>t&&"slide"!==e).map(([,e])=>e).join(" \xb7 "):""}function Me(e,t=60){return e.length>t?e.slice(0,t-1)+"\u2026":e}var Ae="Each thread says where it is: the slide or section, the element (its data-pipeup-id attribute in the HTML), and the exact quoted text or pin position. Work through the open threads in order, and for each one say what you changed or why you did not. Answer in the thread (the Pipeup skill says how) and mark it addressed; never resolve it, the author does.";function Ce(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 Te(e,t,n,o){return"ai"===t?Re(e,"## Comment thread",o,n):ze(e)}function Pe(e,t,n){let o=n.all?e:e.filter(e=>!e.thread.resolved);if("text"===t)return o.map(ze).join("\n");let r=n.all?0:e.length-o.length,i=[`# Review comments: ${Ne(n.title)}`,"",`- **Page:** ${Ne(n.url)}`,`- **Exported:** ${n.exportedAt.toISOString()}`,`- **Open threads:** ${e.length-e.filter(e=>e.thread.resolved).length}${r?` (${r} resolved, not included)`:n.all?" (resolved ones included)":""}`,"",Ae,"",""].join("\n"),a=n.exportedAt.getTime();return i+o.map((e,t)=>Re(e,`## Thread ${t+1}`,a)).join("\n")}function qe(e){return e.reactions.map(e=>`${e.emoji} ${e.by.length} (${e.by.map(e=>Ne(g(e))).join(", ")})`).join(" \xb7 ")}function Ne(e){return e.replace(/\s+/g," ").trim()}function Re(e,t,n,o){let{thread:r,location:i}=e,a=r.root.replies.length,l=[`${t} \xb7 ${r.resolved?"resolved":r.addressed?"open, addressed":"open"}`];if(l.push(`- **Thread:** ${r.id}`),o&&l.push(`- **Page:** ${Ne(o)}`),l.push(`- **Where:** ${Ne(i.where)}`),i.id){let e=Ne(i.id.replace(/`/g,""));l.push(`- **Element:** \`[data-pipeup-id="${e}"]\`${i.element?` (${Ne(i.element)})`:""}`)}i.quote&&l.push(`- **Quoted text:** "${Ne(i.quote)}"`),i.pin&&l.push(`- **Pin:** ${Ne(i.pin)}`),r.addressed&&!r.resolved&&l.push(`- **Addressed:** ${Ne(r.addressed.text)} (${Ne(g(r.addressed))}, ${Ce(r.addressed.at,n)})`),l.push(`- **Started by:** ${Ne(g(r.root))}, ${Ce(r.root.at,n)}${a?` \xb7 ${a} ${1===a?"reply":"replies"}`:""}`,"",`**${Ne(g(r.root))}** (${Ce(r.root.at,n)}): ${Fe(r.root," ")}`),r.root.reactions.length&&l.push(`Reactions: ${qe(r.root)}`);for(let e of r.root.replies)l.push(`- **${Ne(g(e))}** (${Ce(e.at,n)}): ${Fe(e," ")} \x3c!-- comment:${e.id} --\x3e`),e.reactions.length&&l.push(` - Reactions: ${qe(e)}`);return l.join("\n")+"\n"}function ze(e){let{thread:t,location:n}=e,o=[Ne(n.where)+(n.quote?`, on the text "${Ne(n.quote)}"`:""),`${Ne(g(t.root))}: ${Fe(t.root," ")}`];t.root.reactions.length&&o.push(` Reactions: ${qe(t.root)}`);for(let e of t.root.replies)o.push(` ${Ne(g(e))}: ${Fe(e," ")}`),e.reactions.length&&o.push(` Reactions: ${qe(e)}`);return o.join("\n")+"\n"}function Fe(e,t){return e.deleted?"(deleted)":e.text.replace(/\r\n|\r|\n/g,"\n"+t)+(e.edited?" (edited)":"")}function Oe(e,t){return{markdown:Pe(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 De="0.7.0",Ie="2026-10-13",je=new Map,Be=new Map,He=new Map,We={},Ke=e=>`${je.get(e)??""}|${Be.get(e)??""}`;function Ve(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 Ye(e,t){let n=e.getRootNode().activeElement;t&&n instanceof HTMLElement&&e.contains(n)&&n.blur(),e.inert=t}function Ue(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 _e=()=>{let e=window.getSelection();return e&&!e.isCollapsed&&e.toString().trim()?e:null};function Ge(e,t){return e.length>t?e.slice(0,t-1)+"\u2026":e}function Ze(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 Je=/\bhttps?:\/\/[^\s<>"'`]+/gi,Xe=/[\u202A-\u202E\u2066-\u2069]/;function Qe(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 et(e){let t=[],n=0;for(let o of e.matchAll(Je)){if(o[0].length>2048||Xe.test(o[0]))continue;let r,i=Qe(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=Ve("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 tt="http://www.w3.org/2000/svg",nt={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"],send:["M21 12L3.5 4.5 6.2 12l-2.7 7.5zM6.2 12H13"],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:["M14 4h6v6M20 4l-6 6M10 20H4v-6M4 20l6-6M20 14v6h-6M20 20l-6-6M4 10V4h6M4 4l6 6"],pin:["M6 18v-6a6 6 0 1 1 6 6z"],shrink:["M20 10h-6V4M14 10l6-6M4 14h6v6M10 14l-6 6M14 20v-6h6M14 14l6 6M10 4v6H4M10 10L4 4"],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"],close:["M6 6l12 12M18 6L6 18"],smile:["M12 3a9 9 0 1 0 0 18a9 9 0 0 0 0-18z","M8.5 14a4.5 4.5 0 0 0 7 0","M9 9.6h.01M15 9.6h.01"],edit:["M4 20h4L19 9l-4-4L4 16z"],look:["M12 3a9 9 0 1 0 0 18a9 9 0 0 0 0-18z","M12 3v18"]};function ot(e,t=15,n){let o=rt(nt[e],t);return n&&o.setAttribute("stroke-width",String(n)),o}function rt(e,t){let n=document.createElementNS(tt,"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(tt,"path");e.setAttribute("d",t),n.append(e)}return n}var it=(e,t,n)=>`M${e} ${t}a${n} ${n} 0 1 0 ${2*n} 0a${n} ${n} 0 1 0 -${2*n} 0`,at={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${it(7.4,11.5,1.9)}${it(12.8,11.5,1.9)}M11.3 14.6l.7 1 .7-1`,Bear:`${it(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:`${it(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 lt(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 st=(e,t)=>lt(t)||m(e);function dt(e,t){return w(t)?Ve("span",{class:"av ai","data-pipeup-ai":"","aria-hidden":"true"},"AI"):Ve("span",{class:`av c${f(e)}`,"aria-hidden":"true","data-animal":m(e)},lt(t)||rt([at[c[h(e)]]],24))}function ct(e,t){setTimeout(()=>{e.remove(),t?.()},320)}function pt(e){return requestAnimationFrame(()=>{e.offsetWidth,e.classList.add("in")}),e}var ut=/^[A-Za-z0-9_-]{43}$/,ht=/^(?:host|gh):[A-Za-z0-9._@-]{1,64}$/,ft=[],mt=new Set;function gt(e,t){let n=new Map,o=e=>{e.ref!==t&&!n.has(e.ref)&&n.set(e.ref,e)},r=e=>o({ref:e.author,name:g(e),...w(e.name)?{agent:!0}:{}});for(let t of e)for(let e of[t.root,...t.root.replies])if(!e.deleted){r(e);for(let t of e.reactions)for(let e of t.by)r({...e})}for(let e of(document.documentElement.getAttribute("data-pipeup-agents")??"").split(/[\s,]+/).filter(e=>ut.test(e)))o({ref:e,name:"AI agent",agent:!0});for(let e of ft)o(e);return[...n.values()].sort((e,t)=>e.name.localeCompare(t.name))}var vt=(e,t)=>!!e.mentions?.some(e=>t.includes(e.ref)),wt=[],yt=e=>[e,...wt],bt=(e,t)=>[e.root,...e.root.replies].some(e=>e.author!==t&&!e.deleted&&vt(e,yt(t))),xt=null,kt=e=>{xt=e},Et="pu-source";function $t(e){let t=Ve("textarea",{class:"input",rows:"1","aria-label":e.label}),n=Ve("button",{class:"send",type:"button","aria-label":"Send",title:"Send",inert:!0},ot("send")),o=Ve("span",{class:"tools"});o.hidden=!0;let r=Ve("div",{class:"row"},e.before,t,o,n),i=e.kind??"comment",a=!1,l=new Set,s=()=>{for(let e of[...l])e()},d=()=>{let e=""!==t.value.trim();n.classList.toggle("show",e),n.inert=!e,t.style.height="auto",t.style.height=`${Math.max(27,t.scrollHeight)}px`},c=()=>{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),d()};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,d()}}},p=new Map,u=()=>{let n=(xt?.tools()??[]).filter(e=>!1!==e.available?.());for(let[e,t]of p)n.some(t=>t.id===e)||(t.remove(),p.delete(e));for(let a of n){if(p.has(a.id))continue;let n=Ve("button",{class:"ib tool",type:"button","aria-label":a.label,title:a.label,"aria-pressed":"false"},rt(a.icon,15));n.addEventListener("mousedown",e=>e.preventDefault()),n.addEventListener("click",o=>{o.stopPropagation();try{a.press({kind:i,thread:e.thread?.()??null,text:()=>t.value,focus:()=>t.focus({preventScroll:!0}),connected:()=>r.isConnected,setPressed:e=>n.setAttribute("aria-pressed",String(e)),dictate:c,onEnd:e=>(l.add(e),()=>l.delete(e))})}catch(e){globalThis.reportError?.(e)}}),p.set(a.id,n),o.append(n)}o.hidden=0===p.size};u(),r.addEventListener(Et,u);let h=[],f=Ve("ul",{class:"mnl",role:"listbox","aria-label":"People"}),m=Ve("span",{class:"mn-sr","aria-live":"polite"}),g=`mn-${Math.random().toString(36).slice(2,8)}`;f.id=g;let v=[],w=0,y=null;e.people&&(t.setAttribute("aria-autocomplete","list"),t.setAttribute("aria-haspopup","listbox"),t.setAttribute("aria-controls",g),r.append(f,m));let b=()=>{v=[],f.classList.remove("show"),t.removeAttribute("aria-activedescendant"),window.setTimeout(()=>!v.length&&f.replaceChildren(),220)},x=()=>{for(let[e,n]of[...f.children].entries()){let o=e===w;n.setAttribute("aria-selected",String(o)),n.classList.toggle("on",o),o&&t.setAttribute("aria-activedescendant",n.id)}},k=e=>{let n=v[e];if(!n||!y)return;let o=t.selectionStart;t.setRangeText(`@${n.name} `,y.start,o,"end"),h.push({label:n.name,ref:n.ref}),b(),d()},E=async()=>{let o=t.value.trim();if(o&&!a){a=!0;try{await e._(o,h.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,h):[]),n.matches(":focus")&&t.focus(),t.value="",h.length=0,b(),d(),s()}catch{}finally{a=!1}}};return r.addEventListener("mousedown",e=>{e.target===t||n.contains(e.target)||o.contains(e.target)||(e.preventDefault(),t.focus({preventScroll:!0}),t.setSelectionRange(t.value.length,t.value.length))}),t.addEventListener("input",()=>{d(),e.people&&(()=>{if(y=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,v=y&&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(),y.query):[],!v.length)return b();w=Math.min(w,v.length-1),f.replaceChildren(...v.map((e,t)=>{let n=Ve("li",{role:"option",id:`${g}-${t}`,class:e.agent?"agent":""},Ve("span",{},e.name),e.agent?Ve("small",{},"AI agent"):null);return n.addEventListener("mousedown",e=>{e.preventDefault(),k(t)}),n})),f.classList.add("show"),m.textContent=`${v.length} ${1===v.length?"person":"people"}`,x()})()}),t.addEventListener("blur",()=>v.length&&b()),t.addEventListener("keydown",n=>{if(n.stopPropagation(),v.length&&!n.isComposing){if("ArrowDown"===n.key||"ArrowUp"===n.key)return n.preventDefault(),w=(w+("ArrowDown"===n.key?1:v.length-1))%v.length,x();if("Enter"===n.key||"Tab"===n.key)return n.preventDefault(),k(w);if("Escape"===n.key)return n.preventDefault(),b()}"Enter"!==n.key||n.shiftKey||n.isComposing?"Escape"===n.key&&(n.preventDefault(),t.value="",d(),t.blur(),s(),e.K?.()):(n.preventDefault(),E())}),n.addEventListener("click",e=>{e.stopPropagation(),E()}),{element:r,input:t,focus:()=>t.focus({preventScroll:!0})}}var St=["sync","menu","notify","note","composer","panel","styles","status","overlay","here","sign","listnote","reactions","identity","dialog"],Lt=/^[a-z][a-z0-9-]{1,23}$/,Mt=new Set(["local","file","page","user","pipeup","presence","sync"]),At=class{constructor(e,t,n){this.ctx=e,this.shadow=t,this.after=n,kt({tools:()=>this.U,note:()=>[...this.X.values()].at(-1)??null})}G=0;R=[];X=new Map;writing=new Map;marked=new Map;paint=0;J=new Map;listNotes=new Map;picker=null;pickerOwner="";U=[];Z=new Set;N=new Set;z=new Set;j=new Map;T=new Map;W=new Map;remote={n:0,who:new Set};last=0;timer=0;pe="";subscribe(e){return this.z.add(e),()=>{this.z.delete(e)}}changed(e){e&&this.G++;for(let t of[...this.z])t(e);for(let e of this.ctx.t.querySelectorAll(".row, .draft"))e.dispatchEvent(new Event(Et))}O(e,t){let n=this.W.get(e)??this.W.set(e,new Set).get(e),o=()=>{n.delete(o)&&t()};return n.add(o),o}ue(){return[...this.J.values()].map(e=>e.text).join(" \xb7 ")}Le(e,t){return this.R.push(t),this.changed(!0),{update:()=>this.changed(!1),remove:this.O(e,()=>{this.R.splice(this.R.indexOf(t),1),this.changed(!0)})}}setThread(e,t,n){let o=this.writing.get(e)??this.writing.set(e,new Set).get(e);null===n?(je.delete(t),o.delete(t)):(je.set(t,n),o.add(t)),this.repaint()}setMark(e,t,n,o){let r=this.marked.get(e)??this.marked.set(e,new Set).get(e);if(null===n){if(He.delete(t),!Be.delete(t))return;r.delete(t)}else{if(Be.get(t)===n&&!!He.get(t)==!!o)return;Be.set(t,n),o?He.set(t,o):He.delete(t),r.add(t)}this.repaint()}repaint(){this.paint||(this.paint=window.requestAnimationFrame(()=>{this.paint=0,this.ctx.f()}))}Q(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)}Me(e,t){return this.U.push(t),this.changed(!1),this.O(e,()=>{this.U.splice(this.U.indexOf(t),1),this.changed(!1)})}closed(){return this.ctx.state.hidden&&!this.ctx.state.s}Ce(e,t){this.closed()?this.T.set(e,t):this.ctx.ee(t)}flush(){if(this.closed()||0===this.T.size)return;let e=[...this.T.values()].at(-1);this.T.clear(),this.ctx.ee(e)}Pe(){return this.shadow.activeElement instanceof HTMLTextAreaElement||[...this.ctx.t.querySelectorAll("textarea")].some(e=>""!==e.value.trim())}$e(e){this.ctx.state.hidden||this.ctx.E(e)}Oe(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.fe()}}fe(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.Pe())return this.fe(1e3);let{n:e,who:t}=this.remote;this.remote={n:0,who:new Set},this.last=Date.now(),this.ctx.E(`${e} new comment${1===e?"":"s"} from ${1===t.size?[...t][0]:`${t.size} people`}`)},e))}Ie(e){let t=this.j.get(e);return t||(t=Ve("div",{class:"ov","aria-hidden":"true","data-addon":e}),this.ctx.t.insertBefore(t,this.after.nextSibling),this.j.set(e,t)),t}Re(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(Ve("style",{},t));return this.O(e,()=>o?this.shadow.adoptedStyleSheets=this.shadow.adoptedStyleSheets.filter(e=>e!==o):r.remove())}he(e,t,n){return t.add(n),this.O(e,()=>t.delete(n))}Ne(e,t){return this.he(e,this.Z,t)}He(e,t){let n=this.he(e,this.N,t);return this.call(this.N,t,this.ge()),n}ge(){let{state:e}=this.ctx,t=this.shadow.activeElement;return{shown:!e.hidden,commentMode:e.c,allOpen:e.p,dark:this.ctx.t.classList.contains("dark"),view:this.ctx.u.view(),writing:t instanceof HTMLTextAreaElement?t.closest("[data-thread]")?.dataset.thread??"":null}}L(){for(let e of[...this.Z])this.call(this.Z,e);if(0===this.N.size)return;let e=this.ge(),t=JSON.stringify(e);if(t!==this.pe){this.pe=t;for(let t of[...this.N])this.call(this.N,t,e)}}call(e,t,...n){try{t(...n)}catch(n){e.delete(t),globalThis.reportError?.(n)}}De(e,t,n){let o=this.ctx.t,r=this.shadow.activeElement,i=Ve("button",{class:"ib",type:"button","aria-label":"Close"},rt(["M6 6l12 12M18 6L6 18"],15)),a=Ve("div",{class:"xp",role:"dialog","aria-label":n.label,"data-addon":e},Ve("div",{class:"hd"},Ve("span",{},n.label),i),Ve("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.O(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.t.querySelector(".dlg")?.remove();let o=Ve("div",{class:"dlg",role:"dialog","aria-label":n},t),r=()=>{},i=()=>{o.classList.remove("show"),o.inert=!0,window.setTimeout(r,260)};return o.addEventListener("keydown",e=>{e.stopPropagation(),"Escape"===e.key&&(e.preventDefault(),i())}),this.ctx.t.append(o),o.offsetWidth,o.classList.add("show"),o.querySelector("textarea, button.primary, button")?.focus({preventScroll:!0}),r=this.O(e,()=>o.remove()),{close:i}}clear(e){for(let t of[...this.W.get(e)??[]])t();this.W.delete(e),this.j.get(e)?.remove(),this.j.delete(e);for(let t of[this.X,this.J,this.listNotes,this.T])t.delete(e);this.setPicker(e,null);for(let t of this.writing.get(e)??[])je.delete(t);this.writing.delete(e);for(let t of this.marked.get(e)??[])Be.delete(t),He.delete(t);this.marked.delete(e),this.repaint(),this.changed(!0)}destroy(){window.clearTimeout(this.timer),kt(null),this.z.clear()}},Ct=new Map,Tt=null,Pt=(()=>{let e=globalThis.Pipeup;return e?.VERSION?e:null})();function qt(){return Pt?Pt.addons():[...Ct.values()].map(e=>({...e.info}))}function Nt(e){if(Pt)return Pt.use(e);let t=e=>console.warn(`pipeup: ${e}`),n=e;if(!n||"object"!=typeof n||"string"!=typeof n.id||!Lt.test(n.id)||Mt.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(Ct.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=>!St.includes(e));!function(e){let t=typeof document>"u"?null:document.documentElement.getAttribute("data-pipeup-addons");return null===t||t.toLowerCase().split(/[\s,]+/).includes(e)}(n.id)?(o.state="off",o.reason="this page doesn't allow it",t(`the add-on "${n.id}" is not in this page's data-pipeup-addons list, so it is off`)):1!==n.api?(o.state="off",o.reason=`needs add-on API ${String(n.api)}; this Pipeup has 1`):r&&(o.state="off",o.reason=`this Pipeup has no ${r} slot`);let i={addon:e,info:o};Ct.set(n.id,i),Tt?.i&&"waiting"===o.state&&zt(i,Tt)}function Rt(){if(Pt)return!0;let e=globalThis,t=e.pipeupAddons;if(Array.isArray(t))for(let e of t)Nt(e);else if(t&&"object"==typeof t&&t.push!==Nt)return!1;return e.pipeupAddons={push:Nt},!0}async function zt(e,t){let n,o,{addon:r,info:i}=e,a=new AbortController,l=new Set,{surface:s,doc:d}=t,c=()=>!a.signal.aborted,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=>St.includes(e),off:e=>{o=String(e)},merge:e=>c()?d.merge(e,f):Promise.resolve(0),addMenuItem:u(e=>s.Le(f,e)),notify:u(e=>s.Ce(f,e)),announce:u(e=>s.$e(e)),setComposerNote:u(e=>s.Q(s.X,f,e)),setThreadNote:u((e,t)=>s.setThread(f,e,t)),setThreadMark:u((e,t,n)=>s.setMark(f,e,t,n)),addComposerTool:u(e=>s.Me(f,e)),openPanel:u((e,t)=>s.De(f,e,t)),addStyles:u(e=>s.Re(f,e)),setStatus:u(e=>s.Q(s.J,f,e)),setListNote:u(e=>s.Q(s.listNotes,f,e)),setReactionPicker:u(e=>s.setPicker(f,e)),overlay:()=>s.Ie(f),onFrame:u(e=>s.Ne(f,e)),where:e=>s.ctx.u.view(e),isHere:e=>s.ctx.u.m(e),go:e=>s.ctx.u.H(e),onUi:u(e=>s.He(f,e)),avatar:(e,t)=>{let n=dt(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))},g=()=>{if(c()){a.abort();for(let e of[...l])e();try{n?.()}catch(e){globalThis.reportError?.(e)}s.clear(f),"on"===i.state&&(i.state="waiting")}};e.stop=g;try{if(n=await r.setup(m),!c())return void n?.();if(void 0!==o)return g(),i.state="off",void(i.reason=o);i.state="on",delete i.reason}catch(e){i.state="failed",i.reason=function(e){return e instanceof Error?e.message:String(e)}(e),g(),i.state="failed",globalThis.reportError?.(e)}}var Ft=typeof navigator<"u"&&/Mac|iP(hone|ad|od)/.test(navigator.platform)?"\u21e7\u2325C":"Shift+Alt+C",Ot="Shift+Alt+C";function Dt(e,t){let n=function(e){let t=Ve("button",{class:"me",type:"button",tabindex:"-1","aria-hidden":"true"});t.addEventListener("mousedown",e=>e.preventDefault());let n=$t({label:"Comment",kind:"comment",before:t,_:e._,K:e.K,people:e.people}),o=Ve("div",{class:"note"}),r=()=>{let e=xt?.note()??null;o.textContent=e??"",o.hidden=!e};r();let i=Ve("div",{class:"say"}),a=Ve("input",{class:"input",type:"text",maxlength:"80","aria-label":"Your name"}),l=Ve("div",{class:"nf"},a),s=Ve("div",{class:"you"},i,l),d="",c=!1,p=()=>{let n=e.name(),o=n?"change":"add your name";if(t.title=n?"Change your name":"Add your name",!t.lastChild||d!==n){let o=dt(e.me,n),r=t.lastChild;r?(pt(o),ct(r)):o.classList.add("in"),t.append(o),d=n}let r=Ve("button",{type:"button"},o);r.addEventListener("click",h),i.replaceChildren(Ve("span",{class:"nm"},n||`You're ${m(e.me)}`)," \xb7 ",r)},u=e=>{s.classList.toggle("naming",e),Ye(i,e),Ye(l,!e)};function h(t){t.stopPropagation(),a.value=e.name(),u(!0),a.focus({preventScroll:!0}),a.select()}let f=()=>{u(!1),n.focus()};t.addEventListener("click",h),a.addEventListener("keydown",t=>{if(t.stopPropagation(),"Escape"===t.key)t.preventDefault(),f();else if("Enter"===t.key){t.preventDefault();let n=a.value.trim();if(!n||n===e.name())return f();if(c)return;c=!0,e.rename(n).finally(()=>{c=!1,p(),f()})}}),p(),u(!1);let g=Ve("div",{class:"ctx"},e.label),v=Ve("div",{class:"draft"},g,o,n.element,s);return v.addEventListener(Et,r),{element:v,ve:()=>{let{selectionStart:e,selectionEnd:t}=n.input;return()=>{n.focus(),n.input.setSelectionRange(e,t)}},te:e=>{g.hidden=e},ye:e=>{g.textContent=e},focus:()=>n.focus(),Be:()=>""===n.input.value.trim()}}({label:t.label,me:e.doc.me,name:()=>e.s.name(),rename:t=>e.s.rename(t),_:(t,n)=>e.Fe(t,n),people:()=>e.people(),K:()=>e.qe()});return e.D(n),n}function It(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};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 jt(e){return e.range?[...e.range.getClientRects()]:[]}function Bt(e,t){let n=jt(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 Ht(e,t){let n=jt(t).at(-1);if(n)return{x:n.left,y:n.bottom,below:!0};let o=It(e,t);return o?{...o,below:!1}:null}function Wt(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 Kt=()=>window.innerWidth>=900?400:300,Vt=()=>window.innerWidth<=480;function Yt(e,t,n){let o=e.top-t.height-10;return o<8&&(o=e.top+e.height+10),{left:Math.max(8,Math.min(e.left+e.width/2-t.width/2,n.width-t.width-8)),top:o}}function Ut(e,t){let n=e.resolved.get(t.id);return n?.range?.startContainer??n?.element??null}var _t=e=>(t,n)=>{let o=Ut(e,t),r=Ut(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},Gt=["\u{1f44d}","\u2764\ufe0f","\u{1f602}","\u{1f389}","\u{1f62e}","\u{1f64f}"],Zt={"\u{1f44d}":"Thumbs up","\u2764\ufe0f":"Heart","\u{1f602}":"Laughing","\u{1f389}":"Party popper","\u{1f62e}":"Surprised","\u{1f64f}":"Thanks"};var Jt=e=>`${e} ${1===e?"reply":"replies"}`;function Xt(e,t,n){let o={...n},r=e.id,i=Ve("div",{class:"rbox always"},Ve("div",{},$t({label:"Reply",kind:"reply",thread:()=>r,people:()=>t.people(),_:(e,n)=>t.reply(r,e,n),K:t.close}).element)),a=Ve("div",{}),l=Ve("span",{class:"note"},"This thread was resolved. Your words are kept until you send or clear them.");l.hidden=!0,i.prepend(l);let s=Ve("div",{}),d=null,c=null,p=null,u="",h=Ve("div",{},s,Ve("div",{class:"more"},a)),f=new Set,m=new Set,y=e,b=new Map,x=new Map,k=new Map,E=e=>{let t=st(e.author,e.name),n=b.get(e.id),o=n?.e;if((!o||n.key!==t)&&(o=pt(dt(e.author,e.name)),n)){let t=n.e;k.set(e.id,t),ct(t,()=>k.get(e.id)===t&&k.delete(e.id))}o.title=g(e),x.set(e.id,{key:t,e:o});let r=k.get(e.id);return r?[r,o]:[o]},$=(e,t,n)=>{let o=Ve("button",{class:"ib",type:"button","aria-label":t,title:t},ot(e));return o.addEventListener("click",e=>{e.stopPropagation(),n()}),o};function S(e,n={}){Object.assign(o,n),r=e.id,y=e;let k=(o.now??Date.now)(),L=e.root.replies.length,M=e=>Ve("span",{class:"who"},`${g(e)} \xb7 ${Ce(e.at,k)}`),A=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||Xe.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 et(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?Ve("i",{class:"sl"}):null,Ve("span",{},t||""===e.label?n:`[${e.n}] ${n}`),e.says?Ve("span",{class:"rc",role:"tooltip"},e.says):null];if(/^https?:/.test(e.to)){let t=Ve("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=Ve("button",{class:"ref",type:"button",title:e.says?void 0:t?n:`Show where: ${n}`},...o);return r.addEventListener("click",t=>{t.stopPropagation(),We.go?.(e.to)}),r});return[...et(n),Ve("div",{class:"refs"},...o)]}(t):et(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(Ve("span",{class:vt(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))]},C=e=>Ve("div",{class:e.deleted?"tx del":"tx"},...e.deleted?["Deleted"]:[...A(e),e.edited?" (edited)":""]),T=n=>function(e,t){if(e.deleted||!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=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=Ve("button",{class:`ref rx${r?" mine":""}${t.seen.has(l)?"":" new"}`,type:"button","aria-pressed":String(r),"aria-label":`${t.picker?.name(o.emoji)??Zt[o.emoji]??"Reaction"}, ${i} ${1===i?"person":"people"}${r?", including you":""}`},Ve("span",{},o.emoji),Ve("span",{class:"n"},String(i)),Ve("span",{class:"rc"},a.join(", ")));return t.seen.add(l),s.disabled=t.resolved,s.addEventListener("click",e=>{e.stopPropagation(),t.react(o.emoji,!r)}),s}),r=t.quick&&!t.resolved?Ve("div",{class:"rxq"+(t.seen.has(`${e.id}|quick`)?"":" new"),role:"group","aria-label":"React"},...Gt.map(e=>{let o=Ve("button",{class:"rxo",type:"button","aria-label":Zt[e],"aria-pressed":String(n(e))},e);return o.addEventListener("click",o=>{o.stopPropagation(),t.react(e,!n(e))}),o}),t.picker?function(e,t){let n=Ve("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=Ve("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`),Ve("div",{class:"refs rxs"},...o,r)}(n,{me:t.me,picker:t.picker(),resolved:e.resolved,quick:f.has(n.id),seen:m,react:(e,o)=>{f.delete(n.id),t.react(n.id,e,o),S(y)}}),P=t=>e.resolved||t.deleted?null:$("smile","React",()=>{f.delete(t.id)||f.add(t.id),S(y)}),q=e.resolved?"Resolved"+(L?` \xb7 ${Jt(L)}`:""):e.addressed?"Addressed"+(L?` \xb7 ${Jt(L)}`:""):L?Jt(L):"",N=Ve("div",{class:"column"===o.B?q?"ft has-rest":"ft":"ft open"},"column"===o.B&&q?Ve("span",{class:"rest"},q):null,Ve("span",{class:"hover"},M(e.root),Ve("span",{class:"acts"},P(e.root),$("copy","Copy thread",()=>t.copy(e.id)),e.resolved?$("reopen","Reopen",()=>{t.reopen(e.id)}):$("resolve","Resolve",()=>{t.resolve(e.id)})))),R=o.lost?Ve("div",{class:"ctx"},`${o.place||"No longer on the page"} \u2014 it read \u201c${Ge(o.lost,120)}\u201d`):o.quote?Ve("div",{class:"ctx"},`\u201c${Ge(o.quote,80)}\u201d`):null;x=new Map;let z=Ve("div",{class:"root"},...E(e.root),R,C(e.root),T(e.root),N);s.replaceWith(z),s=z,d?.remove();let F=je.get(e.id);d=L||void 0!==F?Ve("div",{class:"rps"},...e.root.replies.map(e=>Ve("div",{class:"it"},...E(e),C(e),T(e),Ve("div",{class:"column"===o.B?"rft":"rft open"},Ve("span",{class:"rrow"},M(e),Ve("span",{class:"acts"},P(e)))))),void 0===F?null:Ve("div",{class:"it ghost","data-pipeup-writing":"row"},dt("",v),Ve("div",{class:"tx","data-pipeup-writing":"words"},F),Ve("div",{class:"rft open"},Ve("span",{class:"who"},`${v} \xb7 writing now`)))):null,d&&a.prepend(d);let O=e.addressed&&!e.resolved?e.addressed:null,D=O?`${O.text}|${O.author}|${O.at}`:"";if(D!==u&&(p?.remove(),p=null,u=D,O)){let n=(e,t)=>{let n=Ve("button",{type:"button"},e);return n.addEventListener("click",e=>{e.stopPropagation(),t()}),n};p=Ve("div",{class:"adr"},Ve("small",{},`Addressed \xb7 ${g(O)} \xb7 ${Ce(O.at,k)}`),O.text,Ve("div",{class:"go"},n("Resolve",()=>{t.resolve(e.id)}),n("Still not right",()=>{t.notRight(e.id)})))}p&&a.insertBefore(p,c??(i.parentNode===a?i:null)),c?.remove();let I=Be.get(e.id),j=He.get(e.id);if(c=void 0===I?null:Ve("div",{class:"seen"},Ve("i"),I),c&&j){let e=Ve("button",{type:"button"},"Check again");e.addEventListener("click",e=>{e.stopPropagation(),j()}),c.append(e)}c&&a.insertBefore(c,i.parentNode===a?i:null),b=x;let B=""!==i.querySelector("textarea").value.trim();l.hidden=!(e.resolved&&B),e.resolved&&!B?i.remove():i.parentNode!==a&&a.append(i),h.className=e.resolved?"thread resolved":"thread",h.setAttribute("data-thread",e.id)}return S(e),{element:h,update:S}}function Qt(e,t){let n=new Map,o=Ve("div",{class:"tip",role:"tooltip"}),r=Ve("div",{class:"mark"}),i=Ve("div",{class:"pop",role:"dialog","aria-label":"Comment thread"});o.inert=i.inert=!0,e.t.append(r,o,i);let a,l=Ve("div",{class:"bub pin ghost","aria-hidden":"true"}),s=[],d=null,c=null,p=null,u=!0===window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,h=0,f=null,m=null,v=null,w=0,y=e=>s.find(t=>t.id===e)??null,b=()=>t.ne||e.state.p,x=!1,k=t=>{let n=e.resolved.get(t.id);return n?Ht(t.anchor,n):null};function E(t,n,o){let{left:r,top:i}=function(e,t,n,o=12){let r,i;return e.below?(r=Math.min(e.x,n.width-t.width-o),i=e.y+8,i+t.height>n.height-o&&(i=e.y-t.height-40)):(r=e.x+14,r+t.width>n.width-o&&(r=e.x-t.width-28),i=Math.min(e.y-12,n.height-t.height-o)),{left:Math.max(o,r),top:Math.max(o,i)}}(n,{width:t.offsetWidth||o,height:t.offsetHeight},function(e){let t=window.innerWidth;return{width:e&&!Vt()?t-320:t,height:window.innerHeight}}(e.state.p));t.style.left=`${r}px`,t.style.top=`${i}px`}function $(t){let n=t&&b()&&e.state.i!==t?y(t):null,r=n?k(n):null;if(!n||!r)return v=null,o.classList.remove("show"),void Ye(o,!0);if(v!==n.id){let e=n.root.replies.length;o.replaceChildren(Ve("div",{class:"tx clamp"},...n.root.deleted?["Deleted"]:et(n.root.text)),Ve("div",{class:"who"},`${g(n.root)}${e?` \xb7 ${e} ${1===e?"reply":"replies"}`:""}`)),v=n.id}E(o,r,260),o.classList.contains("show")||o.offsetWidth,o.classList.add("show"),o.inert=!1}function S(t){f=t,$(t),e.w(t)}function L(e){window.clearTimeout(w),null===e?w=window.setTimeout(()=>S(null),b()?400:0):S(e)}function M(t){let o=n.get(t.id);if(o)return o;let i=Ve("button",{class:"bub",type:"button","data-thread":t.id});return i.addEventListener("mouseenter",()=>L(t.id)),i.addEventListener("mouseleave",()=>L(null)),i.addEventListener("click",n=>{n.stopPropagation(),$(null),e.open(t.id)}),e.t.insertBefore(i,r),n.set(t.id,i),i}o.addEventListener("mouseenter",()=>window.clearTimeout(w)),o.addEventListener("mouseleave",()=>L(null)),o.addEventListener("click",t=>{t.stopPropagation();let n=v;n&&(window.clearTimeout(w),S(null),e.open(n))});let A=!1;function C(){let t=e.state.o,n=p&&t&&!t.anchor.quote&&!t.anchor.point?t.resolved.element:null;if(n){let{left:e,top:t,above:o}=function(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=a+t.height<=n.height-o||l<o,d=s?a:l;return{above:!s,left:Math.max(o,Math.min(e.left,n.width-t.width-o)),top:Math.max(o,d)}}(n.getBoundingClientRect(),{width:i.offsetWidth||Kt(),height:i.offsetHeight},{width:window.innerWidth,height:window.innerHeight}),r=null!==p?.above&&p?.above!==o;if(p&&(p.above=o),r&&P())return;return i.style.left=`${e}px`,void(i.style.top=`${t}px`)}let o=p&&t?Ht(t.anchor,t.resolved):d?k(d):null;o&&E(i,o,Kt())}let T=t=>e.state.c&&!t.anchor.quote&&!t.anchor.point;function P(e=()=>{}){return window.clearTimeout(h),u?(i.classList.remove("show"),h=window.setTimeout(()=>{e(),C(),i.classList.add("show")},220),!0):(e(),i.classList.add("glide"),h=window.setTimeout(()=>i.classList.remove("glide"),450),!1)}let q=t=>{if(e.k(t)){let e=t.composedPath()[0];return null!==m&&!(e instanceof Element&&e.closest(".tip,.bub"))&&L(null),void(m=null)}let n=e.re(t.clientX,t.clientY)?.id??null;n!==m&&(m=n,L(n))},N=t=>{if(e.k(t))return;let n=window.getSelection();if(n&&!n.isCollapsed||(e.state.c?t.altKey:t.target instanceof Element&&t.target.closest("a,button,input,select,textarea,label,summary,[role=button],[contenteditable]")))return;let o=e.re(t.clientX,t.clientY);o&&(e.we(t),$(null),e.open(o.id))};return window.addEventListener("pointermove",q,{capture:!0,passive:!0}),window.addEventListener("click",N,!0),{f:function(o){s=o;let l=new Set;for(let t of o){if(!e.F(t)||t.anchor.quote)continue;let n=e.resolved.get(t.id);if(!n||"orphaned"===n.state)continue;l.add(t.id);let o=M(t);o.classList.toggle("done",t.resolved),o.classList.toggle("on",e.state.i===t.id),o.classList.toggle("pin",void 0!==t.anchor.point);let r=`Comment on ${$e(n.element)}: ${Ge(t.root.text,60)}`;o.getAttribute("aria-label")!==r&&o.setAttribute("aria-label",r)}Ue(e.t,o.filter(e=>l.has(e.id)).sort(_t(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));$(f),x!==e.state.p&&i.classList.contains("show")&&!u&&P(),x=e.state.p;let m=t.ne?e.state.o:null;if(m){let t=m.anchor.point??m.resolved.element;p?.of!==m?(window.clearTimeout(h),i.classList.remove("glide"),p={l:Dt(e,m),of:m,at:t,above:null},p.l.te(T(m)),i.replaceChildren(p.l.element),i.inert=!1,p.l.focus(),d=null,c=null,C(),i.classList.add("show")):p&&(p.at!==t&&(p.at=t,p.above=null,P(()=>p?.l.ye(m.label))),p.l.te(T(m)));let n=!e.u.m(m.anchor.view);return void(n!==A&&(A=n,i.classList.toggle("show",!n),i.inert=n,n||C()))}p&&(window.clearTimeout(h),i.classList.remove("glide"),p=null,A=!1,e.D(null));let g=b()&&e.state.i?y(e.state.i):null;if(!g||!e.F(g))return d=null,c=null,i.classList.remove("show"),void Ye(i,!0);let v=g.anchor.quote?.exact??null;d&&c&&d.id===g.id?(d!==g||a!==Ke(g.id))&&(c.update(g,{quote:v}),d=g,a=Ke(g.id)):(c=Xt(g,e.oe,{B:"popover",quote:v}),i.replaceChildren(c.element),d=g,a=Ke(g.id),C(),i.classList.add("show"),i.inert=!1)},L:function(){for(let[t,o]of n){let n=y(t),r=e.resolved.get(t),i=n&&r?It(n.anchor,r):null;!i||i.y<-40||i.y>window.innerHeight+40?o.style.visibility="hidden":(o.style.visibility="",o.style.left=`${i.x}px`,o.style.top=`${i.y}px`,o.classList.contains("in")||(o.offsetWidth,o.classList.add("in")))}let t=e.state.o,o=t?.anchor.point&&e.u.m(t.anchor.view)?It(t.anchor,t.resolved):null;o?(l.style.left=`${o.x}px`,l.style.top=`${o.y}px`,l.classList.contains("in")||(e.t.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")&&C();let a=function(){if(!b())return null;let t=e.state.o;return t?t.anchor.quote||t.anchor.point||e.state.c?null:t.resolved.element:!d||d.anchor.quote||d.anchor.point?null:e.resolved.get(d.id)?.element??null}();r.classList.toggle("show",null!==a),a&&Ze(r,a.getBoundingClientRect(),4)},destroy(){window.clearTimeout(w),window.clearTimeout(h),window.removeEventListener("pointermove",q,!0),window.removeEventListener("click",N,!0),e.D(null);for(let e of n.values())e.remove();l.remove(),o.remove(),r.remove(),i.remove()}}}var en={display:"block",position:"static",clips:!1,off:!1},tn=["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",..."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}]`)].join(","),nn="a,button,label,summary,[role=button],[role=link],[role=tab],[role=option],[role=menuitem]",on=`${nn},input,select,textarea,img,svg,canvas,video,picture,[role=img]`,rn=(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 an(e,t){let n=t.l(e);if(n.width<2||n.height<2)return!1;if(e.hasAttribute("data-pipeup-id"))return!0;let o=t.ie();return n.width*n.height<=.6*o.width*o.height&&(e.matches(tn)||t.Ve(e)||e.childElementCount>1&&!e.parentElement?.closest(nn)&&t._e(e))}function ln(e,t,n){if(e===t||!t.contains(e)||e.closest("[data-pipeup-ignore]"))return null;let o=null;for(let r=e;r&&r!==t&&!o;r=r.parentElement)an(r,n)&&(o=r);if(!o||o.hasAttribute("data-pipeup-id"))return o;let r=n.l(o);for(let e=o.parentElement;e&&e!==t&&rn(n.l(e),r);e=e.parentElement)if(e.hasAttribute("data-pipeup-id"))return e;return o}function sn(e,t,n){let o=n.l(e);for(let r=e.parentElement;r&&r!==t;){let e=ln(r,t,n);if(!e)return null;if(!rn(n.l(e),o))return e;r=e.parentElement}return null}var dn=(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,cn=(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 pn(e,t,n=()=>!0){let o=[],r=(e,i,a,l,s,d)=>{for(let c of e.children){if(c.hasAttribute("data-pipeup-ignore")||"true"===c.getAttribute("aria-hidden")||!n(c))continue;let e=t.flow?.(c)??en,p=c.offsetParent,u="fixed"===e.position||"absolute"===e.position&&!!l&&!(p&&l.contains(p)),h=u?null:a,f=t.l(c),m=f.width>0&&f.height>0;if(h&&m&&!dn(f,h))continue;let g=c.matches(nn),v=(e.display.startsWith("inline")||d)&&!c.matches(on)&&("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))&&an(c,t)&&(i&&rn(t.l(i.e),f)?(c.hasAttribute("data-pipeup-id")||!i.e.hasAttribute("data-pipeup-id"))&&(i.e=c):o.push(y={e:c,I:i,S:0}));let b=e.clips&&m;r(c,y,b?h?cn(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.I&&(t.I.S=Math.max(t.I.S,t.S+1))}return o}var un=(e,t)=>e.filter(e=>e.S<=t&&(!e.I||e.I.S>t)),hn="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]",fn=`${hn},input,select,textarea,[contenteditable]:not([contenteditable=false]),[tabindex]:not([tabindex="-1"])`,mn=["click","dblclick","auxclick","submit","contextmenu","dragstart"],gn=[...["over","out","enter","leave","down","up"].flatMap(e=>[`pointer${e}`,`mouse${e}`]),"mousemove","touchstart","touchmove","touchend","touchcancel"],vn="Tab moves between blocks \xb7 \u2191 \u2193 change level \xb7 Enter comments \xb7 Esc to finish \xb7 F7 selects text";function wn(e){let t={l:e=>e.getBoundingClientRect(),Ve: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},_e: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}},ie:()=>({width:innerWidth,height:innerHeight})},n=Ve("span",{hidden:!0},vn),o=Ve("div",{class:"pick"},n),r=[0,1].map(()=>{let e=Ve("div",{class:"km",tabindex:"-1",role:"button"},Ve("span",{hidden:!0}),Ve("span",{hidden:!0}));return e.inert=!0,e.addEventListener("keydown",pe),e.addEventListener("click",e=>{e.stopPropagation(),ce()}),e.addEventListener("focus",()=>o.classList.add("kf")),e.addEventListener("blur",()=>o.classList.remove("kf")),e}),i=Ve("span",{class:"lbl"}),a=(e,t,n,o)=>{let r=Ve("button",{class:"nb",type:"button","aria-label":e,title:t},ot(n,16));return r.addEventListener("click",e=>{e.stopPropagation(),o()}),r},l=a("Around it","Select the block around it","expand",se),s=a("Inside it","Select a block inside it","shrink",de),d=a("Pin","Pin its centre","pin",()=>e.be(()=>H(f??x,{x:.5,y:.5}))),c=Ve("div",{class:"namebar",role:"group","aria-label":"Chosen block"},i,l,s,d);c.inert=!0;let p=e.t.querySelector(".launch");for(let t of[o,...r,c])e.t.insertBefore(t,p);c.addEventListener("mousedown",e=>e.preventDefault());let u=!0===window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,h=null,f=null,m=null,g=null,v=0,w=()=>{},y=null,b=()=>{},x=null,k=0,E=0,$=!1,S=null,L=null,M=null,A=0,C=-1,T=!0,P=null,q=null,N=t=>!(e.k(t)||t.target instanceof Element&&t.target.closest("[data-pipeup-ignore]"));function R(){g&&(o.classList.toggle("glide",performance.now()<v),Ze(o,g.getBoundingClientRect(),4))}function z(){if(!y)return;c.classList.toggle("glide",performance.now()<v&&c.classList.contains("show"));let{left:e,top:t}=Yt(y.getBoundingClientRect(),{width:c.offsetWidth||200,height:c.offsetHeight||34},{width:window.innerWidth,height:window.innerHeight});c.style.left=`${e}px`,c.style.top=`${t}px`}function F(e,t){g=e,v=t?performance.now()+400:0,R(),o.classList.add("show")}function O(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 D(e){if(e!==h){if(h=e,w(),!e)return void o.classList.remove("show");"0"===getComputedStyle(o).opacity?F(e,!1):u?(o.classList.remove("show"),w=O(o,()=>F(e,!1))):F(e,!0)}}function I(e){f=e,o.classList.toggle("on",null!==e),D(e),j(e)}function j(e){b(),c.inert=!e,e?u?(c.classList.remove("show"),b=O(c,()=>B(e))):B(e):(c.classList.remove("show"),y=null)}function B(n){i.textContent=i.title=$e(n),l.hidden=null===sn(n,e.root,t),s.hidden=0===(x?ae(n).length:pn(n,t,X).length);let o=c.classList.contains("show");y=n,z(),o||(c.offsetWidth,c.classList.add("show"))}function H(t,n){let o;try{o=he(t,e.root,n,e.u.view(t))}catch(t){return void e.Y(t)}let r={anchor:o,label:n?`Pin on ${$e(t).replace(/^[A-Z](?=[a-z])/,e=>e.toLowerCase())}`:$e(t),ranges:[],resolved:{state:"attached",element:t,range:null}},i=e.state.o;x&&(x=t,C=-1),I(n?null:t),m=i??r,e.Ke(r),e.E(n?r.label:`Commenting on ${r.label}`)}function W(t){e.be(()=>H(t))}let K=n=>{if(e.k(n))return;if(!N(n))return void(f||D(null));if(n.stopPropagation(),f||e.state.o)return;let o=!_e()&&n.target instanceof Element?ln(n.target,e.root,t):null;if(x){if(!o||o===x||(A+=Math.abs(n.movementX)+Math.abs(n.movementY),A<=4))return;ie()}o&&(S=o),D(o)},V=()=>{_e()&&(x&&ie(),f||D(null))},Y=e=>{N(e)&&(e.stopPropagation(),("pointerdown"===e.type||"mousedown"===e.type)&&e.target instanceof Element&&e.target.closest(fn)&&e.preventDefault())},U=n=>{if(!N(n))return;let o=n.target;!(o===q||o.form&&o.form===q?.form)||"submit"!==n.type&&("click"!==n.type||n.detail)?(n.preventDefault(),n.stopPropagation(),"click"===n.type&&!e.state.s&&!e.Ue(n)&&function(n){let o=window.getSelection();if(o&&!o.isCollapsed)return;if(e.state.o&&(n.altKey||!e.C()))return void e.q();if(!n.altKey&&e.re(n.clientX,n.clientY))return;if(e.state.i&&e.open(null),x&&n.detail&&ie(),n.altKey)return void function(n){let o=(n.target instanceof Element?ln(n.target,e.root,t):null)??e.root;o!==e.root&&(S=o);let r=o.getBoundingClientRect();r.width&&r.height&&H(o,{x:(n.clientX-r.left)/r.width,y:(n.clientY-r.top)/r.height})}(n);let r=n.target instanceof Element?ln(n.target,e.root,t):null;r&&(S=r),r?H(r):(e.q(),I(null))}(n)):q="click"===n.type&&"submit"===o.type?o.form:null},_=t=>{if(q=null,fe="","Tab"===t.key&&G(t))return t.preventDefault(),t.stopPropagation(),fe=t.key,e.q(),e.state.i&&e.open(null),e.state.s&&(e.state.s=!1,e.f()),function(t){if(x)return le(t);P=null;let n=document.activeElement;L=Z()??n;let o,r=S?.isConnected?S:null,i=r&&ee(r);if(i){k=i.S;let e=un(Q(),k),n=e.indexOf(i);o=e[(n+t+e.length)%e.length]}else if(r){k=0;let e=un(Q(),0),n=e=>0!==(r.compareDocumentPosition(e.e)&Node.DOCUMENT_POSITION_FOLLOWING),i=e=>e.e.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=ne(),o&&(k=o.S);if(!o)return e.E("Nothing here to comment on");$=!0,re(o.e)}(t.shiftKey?-1:1);if(N(t)&&t.target instanceof Element)if("Enter"!==t.key&&" "!==t.key||!t.target.closest(hn))"Enter"===t.key&&!x&&t.target.form&&(q=t.target);else{if(!x)return void(q=t.target);t.preventDefault(),t.stopPropagation()}},G=t=>{if(t.ctrlKey||t.metaKey||t.altKey||t.isComposing)return!1;let n=t.composedPath()[0];return n instanceof Element&&!r.some(e=>e===n)&&(e.k(t)?!!n.closest(".launch,.menu")&&!n.closest("input,textarea,select,[contenteditable]"):!t.composedPath().some(e=>e instanceof Element&&e.hasAttribute("data-pipeup-ignore")))},Z=()=>e.t.getRootNode().activeElement,J=()=>r.some(e=>e===Z()),X=t=>(!1!==t.checkVisibility?.({opacityProperty:!0,visibilityProperty:!0})||"contents"===getComputedStyle(t).display)&&e.u.m(e.u.view(t)),Q=()=>(P?.some(e=>!e.e.isConnected)&&(P=null),P??=pn(e.root,t,X)),ee=e=>Q().find(t=>t.e===e),te=(e,t=!1)=>{let n=e.getBoundingClientRect();return n.bottom>0&&n.top<window.innerHeight&&(!t||n.top>=0)},ne=()=>{let e=un(Q(),0);return e.find(e=>te(e.e,!0))??e.find(e=>te(e.e))??e[0]},oe=t=>e.doc.threads().filter(n=>e.F(n)&&t.contains(Ut(e,n))).sort(_t(e));function re(t,o=!0){A=0;let i=Q(),a=i.find(e=>e.e===t);if(a&&!un(i,k).includes(a)&&(k=a.S),t!==x&&(C=-1),t!==f&&(f=null),x=t,D(t),j(t),t.scrollIntoView({block:"nearest",inline:"nearest",behavior:u?"auto":"smooth"}),!o)return;e.ze();let l=r[E^=1];(function(e,t){let[o,r]=e.children,i=un(Q(),k),a=oe(t).length;o.textContent=`${ke(t)}, ${i.findIndex(e=>e.e===t)+1} of ${i.length}${a?`, has ${a} comment${1===a?"":"s"}`:""}`;let l=(t.innerText??t.textContent??"").length<=150;r.textContent=Ee(t);let s=T?[n]:[];T=!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),Ze(l,t.getBoundingClientRect(),4),l.inert=!1,l.focus({preventScroll:!0}),r[1^E].inert=!0}function ie(){let e=J();S=x,x=null,D(null),j(null);for(let e of r)Ye(e,!0);return e}function ae(e){let t=ee(e);return t?((e,t)=>e.filter(e=>e.I===t))(Q(),t):[]}function le(e){let t=un(Q(),k),n=t.findIndex(e=>e.e===x),o=t[n<0?e>0?0:t.length-1:(n+e+t.length)%t.length];o&&re(o.e)}function se(){let n=f??x,o=n&&sn(n,e.root,t);return o?((!M||!n.contains(M))&&(M=n),f?W(o):void re(o)):e.E("Nothing around it")}function de(){let t=f??x,n=t?ae(t):[],o=n.find(e=>M&&e.e.contains(M))??n.find(e=>te(e.e))??n[0];if(!o)return e.E("Nothing inside it");f?W(o.e):re(o.e)}function ce(t=!1){if(!x)return;if(e.state.o&&!e.C())return e.je();if(!t)return H(x);let n=oe(x);if(!n.length)return e.E("No comments on this block");C=(C+1)%n.length,e.open(n[C].id),n.length>1&&e.E(`Comment ${C+1} of ${n.length} on this block`)}function pe(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(),fe=t.key,"Escape"===t.key)return void e.se();if("Enter"===t.key||" "===t.key)return ce(t.shiftKey&&"Enter"===t.key);"Tab"===t.key&&e.q(),e.state.i&&e.open(null),"Tab"===t.key?le(t.shiftKey?-1:1):"ArrowUp"===t.key?se():de()}}let ue=()=>{let e=Z();return e?!!e.closest("[inert]"):!document.activeElement||document.activeElement===document.body},fe="",me=!1,ge=e=>{me&&window.removeEventListener("keyup",ge,!0),e.key===fe&&(fe="",e.preventDefault(),e.stopPropagation())};window.addEventListener("keyup",ge,!0),window.addEventListener("pointermove",K,!0),document.addEventListener("selectionchange",V);for(let e of gn)window.addEventListener(e,Y,!0);for(let e of mn)window.addEventListener(e,U,!0);return window.addEventListener("keydown",_,!0),{se:()=>!!f&&(I(null),!0),ae:()=>null!==x,We:()=>$&&!x,xe:function(){P=null;let t=document.activeElement;L=Z()??t;let n=ee(S),o=n??(t&&t!==document.body&&e.root.contains(t)&&!t.closest("[data-pipeup-ignore]")?Q().filter(e=>e.e.contains(t)).pop():void 0)??ne();return!!o&&(n||(k=o.S),$=!0,re(o.e),!0)},le(){x&&!J()&&re(x)},f(){if(P=null,x&&(!x.isConnected||!X(x))){let e=ne();e?re(e.e,J()||ue()):ie()}let t=e.t.querySelector(".launch");if(t&&c.nextElementSibling!==t&&!J()&&!c.contains(Z()))for(let n of[o,...r,c])e.t.insertBefore(n,t);let n=e.state.o;m&&n!==m?(m=null,I(null),x&&re(x,ue())):(n||e.state.i)&&!m&&(h||f)&&I(null)},L(){R(),z(),x&&Ze(r[E],x.getBoundingClientRect(),4)},destroy(){ie()&&function(){let t=L;t&&t!==document.body&&t.isConnected&&t.focus?.({preventScroll:!0}),(!t||t===document.body||!t.matches?.(":focus"))&&e.t.querySelector(".launch .mode")?.focus({preventScroll:!0})}();for(let e of r)e.remove();w(),b(),me=!0,fe||window.removeEventListener("keyup",ge,!0),window.removeEventListener("pointermove",K,!0),document.removeEventListener("selectionchange",V);for(let e of gn)window.removeEventListener(e,Y,!0);for(let e of mn)window.removeEventListener(e,U,!0);window.removeEventListener("keydown",_,!0),o.classList.remove("show"),c.classList.remove("show"),Ye(c,!0),O(o,()=>o.remove()),O(c,()=>c.remove())}}}function yn(e,t=!1){let n=e.ownerDocument.documentElement,o=n.getAttribute("data-pipeup-layout");if("bubbles"===o||e.querySelector("[data-pipeup-slide]"))return null;let r=e.querySelector("article, main, [role=main]")??("column"===o?e:null);if(!r)return null;if(n.hasAttribute("data-pipeup-reserve")){let e,i=n.clientWidth,a=getComputedStyle(r).maxWidth;return e=a.endsWith("px")?parseFloat(a):a.endsWith("%")?parseFloat(a)/100*i:r.getBoundingClientRect().width,"column"!==o&&i<e+320-(t?24:0)?null:{x:i-320+24,width:272}}let i=r.getBoundingClientRect().right;if(window.innerWidth-i<300&&"column"!==o)return null;let a=i+32;return{x:a,width:Math.max(220,Math.min(300,window.innerWidth-a-16))}}function bn(e,t){let n=e.resolved.get(t.id);return!n||"orphaned"===n.state&&!e.T.has(t.id)}function xn(e){let t=Ve("div",{class:"col"});e.t.append(t);let n=new Map,o=null,r=new ResizeObserver(()=>l()),i=t=>bn(e,t);function a(t){let n=e.resolved.get(t.id),o=n?Bt(t.anchor,n):null;return null===o?Number.POSITIVE_INFINITY:o+window.scrollY-4}function l(){let t=[],r=[];for(let[o,i]of n){let n=a(i.thread);if(Number.isFinite(n))i.placed=n;else if(e.T.has(o)){if(null===i.placed){i.e.classList.add("wait");continue}n=i.placed}Number.isFinite(n)?t.push({id:o,M:n,height:i.e.offsetHeight}):r.push({id:o,height:i.e.offsetHeight})}let i=e.state.o,l=i?Bt(i.anchor,i.resolved):null;o&&null!==l&&t.push({id:"draft",M:l+window.scrollY-4,height:o.e.offsetHeight});let s=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]))}(t,o?"draft":e.state.i),d=Math.max(0,...t.map(e=>(s.get(e.id)??0)+e.height))+24;for(let e of r)s.set(e.id,d),d+=e.height+10;for(let[e,t]of n)if(t.e.classList.contains("wait")){if(!s.has(e))continue;t.e.style.transition="none",t.e.style.transform=`translateY(${Math.round(s.get(e))}px)`,t.e.offsetWidth,t.e.style.transition="",t.e.classList.remove("wait")}else t.e.style.transform=`translateY(${Math.round(s.get(e)??0)}px)`;o&&(o.e.style.transform=`translateY(${Math.round(s.get("draft")??0)}px)`)}function s(e,t){e.thread=t,e.note=Ke(t.id),e.lost=i(t),e.view.update(t,{lost:e.lost?t.anchor.snapshot:null})}function d(n){let o=i(n),a=Xt(n,e.oe,{B:"column",lost:o?n.anchor.snapshot:null}),l=Ve("div",{class:"th","data-thread":n.id},Ve("button",{class:"opn sr",type:"button","data-thread":n.id}),a.element);return l.style.transition="none",l.addEventListener("mouseenter",()=>e.w(n.id)),l.addEventListener("mouseleave",()=>e.w(null)),l.addEventListener("click",()=>e.open(n.id)),t.append(l),r.observe(l),{e:l,thread:n,lost:o,placed:null,view:a}}function c(e){r.unobserve(e),e.classList.add("out"),window.setTimeout(()=>e.remove(),220)}return{f:function(a){Ye(t,e.state.p);let p=new Set,u=[],h=null!==e.state.i||null!==e.state.o;for(let t of a){if(!e.F(t))continue;p.add(t.id);let o=n.get(t.id);o?(o.thread!==t||o.lost!==i(t)||o.note!==Ke(t.id))&&s(o,t):(o=d(t),n.set(t.id,o),u.push(o.e));let r=o.e,a=e.state.i===t.id;r.classList.toggle("on",a);let l=r.firstElementChild,c=t.root.replies.length;l.setAttribute("aria-label",`Open thread: ${Ge(t.root.text,60)}, ${Jt(c)}`),l.setAttribute("aria-expanded",String(a)),Ye(l,a);let f=r.querySelector(".more");f&&Ye(f,!a),r.classList.toggle("dim",h&&!a),r.classList.toggle("hot",e.state.w===t.id&&!a),r.classList.toggle("resolved",t.resolved),r.classList.toggle("lost",o.lost)}for(let[e,t]of n)p.has(e)||(n.delete(e),c(t.e));(function(){let n=e.state.o;if(o&&o.of!==n&&(c(o.e),o=null,n||e.D(null)),!n)return;let i=!o;if(o)o.l.ye(n.label);else{let i=Dt(e,n),a=Ve("div",{class:"th on"},i.element);a.style.transition="none",t.append(a),r.observe(a),o={e:a,l:i,of:n}}o.l.te(e.state.c&&!n.anchor.quote&&!n.anchor.point),i&&o.l.focus()})(),Ue(t,a.filter(e=>p.has(e.id)).sort(_t(e)).map(e=>n.get(e.id).e),o?.e??null)&&t.offsetWidth,l(),o&&u.push(o.e);for(let e of u)e.offsetWidth,e.style.transition=""},L:function(){let n=yn(e.root,!0);n&&(t.style.width=`${n.width}px`,t.style.transform=`translate(${n.x}px, ${-window.scrollY}px)`)},destroy(){r.disconnect(),e.D(null),t.remove()}}}var kn="[data-pipeup-ignore],input,textarea,select,[contenteditable]:not([contenteditable=false])";function En(e){let t=Ve("button",{type:"button","aria-label":"Comment",title:"Comment"},ot("comment",17)),n=Ve("div",{class:"selbar"},t);n.inert=!0,e.t.append(n);let o=null,r=0,i=!1,a=t=>{let n=t&&(t.nodeType===Node.ELEMENT_NODE?t:t.parentElement);return!!n&&e.root.contains(n)&&!n.closest(kn)};function l(){if(!o)return;let{left:e,top:t}=Yt(o.getBoundingClientRect(),{width:n.offsetWidth||36,height:n.offsetHeight||34},{width:window.innerWidth,height:window.innerHeight});n.style.left=`${e}px`,n.style.top=`${t}px`}function s(){o=null,n.inert=!0,n.classList.remove("show")}function d(t=!1){let r=_e();e.state.c&&r&&a(r.anchorNode)&&a(r.focusNode)?(!o&&!t&&e.E("Enter comments on the selected words"),o=r.getRangeAt(0).cloneRange(),l(),n.inert=!1,n.classList.add("show")):s()}t.addEventListener("mousedown",e=>e.preventDefault()),t.addEventListener("click",t=>{if(t.stopPropagation(),e.state.o&&!e.C())return e.q();let n,r=o;if(!r)return;try{n=ue(r,e.root,e.u.view(r.commonAncestorContainer))}catch(t){return e.Y(t),void s()}let i=Ge(r.toString().replace(/\s+/g," ").trim(),60);window.getSelection()?.removeAllRanges(),s(),e.Ye({anchor:n,label:`\u201c${i}\u201d`,ranges:[r],resolved:{state:"attached",element:null,range:r}})});let c=()=>{window.clearTimeout(r),r=window.setTimeout(()=>i||d(),250),o&&(_e()||s())};document.addEventListener("selectionchange",c);let p=t=>{"keyup"!==t.type&&(i="mousedown"===t.type),!i&&!e.k(t)&&window.setTimeout(()=>d("mouseup"===t.type),0)};window.addEventListener("mousedown",p,!0),window.addEventListener("mouseup",p,!0),window.addEventListener("keyup",p,!0);let u=n=>{"Enter"!==n.key||!o||e.k(n)||n.target instanceof Element&&n.target.closest(`${kn},${hn}`)||(n.preventDefault(),n.stopPropagation(),t.click())};return window.addEventListener("keydown",u,!0),{f(){!e.state.c&&o&&s()},L(){o&&l()},destroy(){window.removeEventListener("mousedown",p,!0),window.removeEventListener("mouseup",p,!0),window.removeEventListener("keyup",p,!0),window.removeEventListener("keydown",u,!0),window.clearTimeout(r),document.removeEventListener("selectionchange",c),n.remove()}}}async function $n(e,t){try{return void await navigator.clipboard.writeText(e)}catch{}let n=document.createElement("textarea");n.value=e,n.setAttribute("readonly",""),n.style.cssText="position:fixed;opacity:0;pointer-events:none",t.append(n),n.select();let o=document.execCommand("copy");if(n.remove(),!o)throw new Error("pipeup: your browser blocked copying")}var Sn="Hidden on the page",Ln=["auto","light","dark"];function Mn(e){let t=[Ve("span",{class:"n"}),Ve("span",{class:"n"})],n=ot("comment",20,1.4);n.lastElementChild.setAttribute("stroke-width","1.6");let o=Ve("button",{class:"mode",type:"button","aria-label":"Comment","aria-keyshortcuts":Ot,"aria-haspopup":"menu","aria-expanded":"false"},Ve("span",{class:"plus"},n),Ve("span",{class:"cnt"},ot("bubble",34,1.4),...t),Ve("span",{class:"dot"})),r=document.createTextNode("Comment"),i=Ve("span",{class:"ttip","aria-hidden":"true"},r,Ve("small",{},Ft)),a=Ve("div",{class:"launch"},o,i),l=Ve("div",{class:"menu",role:"menu","aria-label":"Comments"}),s=Ve("div",{class:"list",role:"menu","aria-label":"All comments"}),d=Ve("span",{class:"pn"}),c=Ve("button",{class:"ib",type:"button","aria-label":"Close"},ot("close")),p=Ve("button",{class:"hs",type:"button",role:"switch","aria-checked":"false"},"Show resolved",Ve("span",{class:"sw","aria-hidden":"true"}));p.addEventListener("click",t=>{t.stopPropagation(),e.s.Ge()});let u=Ve("button",{class:"hs",type:"button",role:"switch","aria-checked":"false"},"Mentions of me",Ve("span",{class:"sw","aria-hidden":"true"}));u.hidden=!0,u.addEventListener("click",t=>{t.stopPropagation(),e.s.toggleMine()});let h=Ve("div",{class:"lns"}),f=new Map,g=Ve("div",{class:"all",role:"dialog","aria-label":"All comments"},Ve("div",{class:"hd"},Ve("span",{},"All comments"),d,u,p,c),h,s),v=document.createElementNS("http://www.w3.org/2000/svg","svg");v.setAttribute("class","cx"),v.setAttribute("aria-hidden","true");let w=document.createElementNS("http://www.w3.org/2000/svg","path"),y=document.createElementNS("http://www.w3.org/2000/svg","circle");y.setAttribute("r","4"),v.append(w,y),l.inert=g.inert=!0,e.t.append(l,a,v,g);let b=!1,x=null,k=0,E=[],$=0,S=null,L=null,M=!0===window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,A=t=>{b=e.state.s=t,t&&e.addons.flush(),window.clearTimeout(k),k=0,t||x?.(!0),l.classList.toggle("show",t),Ye(l,!t),o.setAttribute("aria-expanded",String(t))},C=(t,n=!1)=>{e.state.p!==t&&(e.state.p=t,e.f(),t?(T(s)[0]??c).focus({preventScroll:!0}):n&&o.focus({preventScroll:!0}))},T=(e=l)=>[...e.querySelectorAll(".mi")],P=()=>l.getRootNode().activeElement,q=()=>{A(!1),o.focus({preventScroll:!0})},N=e=>{let t=T(e.currentTarget);if(0===t.length)return;let n=P(),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)};l.addEventListener("keydown",N),s.addEventListener("keydown",N),c.addEventListener("click",e=>{e.stopPropagation(),C(!1,!0)});let R=t=>bn(e,t),z=t=>E.filter(n=>!n.resolved&&(void 0===t||e.V(n)===t)).length,F=()=>z(),O=t=>{let n=t.anchor.view?.slide,o=e.u.m(t.anchor.view)?"":Le(t.anchor.view);return n&&null!==e.u.slide()?`On slide ${n}`:o?`In ${o}`:Sn},D=(e,t,n="")=>Ve("div",{role:"group","aria-label":n?`${e} \xb7 ${n}`:e},Ve("div",{class:"sec","aria-hidden":"true"},e,n&&Ve("b",{},n)),...t);function I(){let t=P(),n=t?.dataset.thread,o=null!==L&&L.element.contains(t),r=e.s.all(),i=r.some(t=>bt(t.thread,e.doc.me)),a=r.filter(t=>!t.thread.resolved||e.state.$||t.thread.id===S).filter(t=>!(e.state.mine&&i)||bt(t.thread,e.doc.me)),l=t=>{let n=t.thread,o=n.id===S,r=dt(n.root.author,n.root.name);r.classList.add("in");let i=Ve("button",{class:`mi${n.resolved?" done":""}${o?" open":""}`,type:"button",role:"menuitem","aria-expanded":String(o),"data-thread":n.id},r,Ve("span",{},Ve("span",{class:"clamp"},n.root.deleted?"Deleted":n.root.text),Ve("small",{},(R(n)?`\u201c${Ge(n.anchor.snapshot,80)}\u201d`:t.location.where)+(n.root.reactions.length?` \xb7 ${n.root.reactions.map(e=>`${e.emoji} ${e.by.length}`).join(" ")}`:""))));i.addEventListener("click",t=>{t.stopPropagation(),function(t){if(S===t)return H(!0);let n=E.find(e=>e.id===t);if(n){if(S=B=t,L=Xt(n,{...e.oe,close:()=>H(!0)},j(n)),e.seen(n),I(),L.element.querySelector("textarea")?.focus({preventScroll:!0}),!e.V(n))return W(n);e.state.o&&!e.C()||e.u.H(n.anchor.view??{}).then(()=>{e.ke();let n=E.find(e=>e.id===t);n&&B===t&&S===t&&W(n)})}}(n.id)});let a=document.createDocumentFragment();return a.append(i),o&&L&&(L.update(n,j(n)),a.append(Ve("div",{class:"xr",role:"region","aria-label":"Comment thread"},L.element))),a},c=a.filter(e=>R(e.thread));d.textContent=String(F()),p.setAttribute("aria-checked",String(e.state.$)),u.hidden=!i,u.setAttribute("aria-checked",String(e.state.mine&&i)),s.replaceChildren(a.length?"":Ve("div",{class:"sec",role:"presentation"},"No open comments"),...function(t,n){let o=e.u.slide(),r=new Map;for(let n of t){let t=n.thread,i=null!==o?t.anchor.view?.slide??o:e.V(t)?e.u.m(t.anchor.view)?"":Le(t.anchor.view):null;r.set(i,[...r.get(i)??[],n])}if(null===o){let e=r.get(null)??[];return r.delete(null),[...e.map(n),...[...r].map(([e,t])=>D(e||Sn,t.map(n)))]}return[...r].sort(([e],[t])=>Number(e)-Number(t)||0).map(([e,t])=>D(`Slide ${e} \xb7 ${t.filter(e=>!e.thread.resolved).length} open`,t.map(n),e===o?"This slide":""))}(a.filter(e=>!R(e.thread)),l),c.length?D("No longer on the page",c.map(l)):""),o?L.element.querySelector("textarea")?.focus({preventScroll:!0}):n&&T(s).find(e=>e.dataset.thread===n)?.focus({preventScroll:!0})}function j(t){let n=!R(t)&&e.V(t);return{B:"popover",quote:t.anchor.quote?.exact??null,lost:R(t)||n?t.anchor.snapshot:null,place:n?O(t):null}}let B="";function H(t=!1){if(!S)return;let n=S;S=L=null,e.w(null),I(),t&&T(s).find(e=>e.dataset.thread===n)?.focus({preventScroll:!0})}function W(t){let n=e.resolved.get(t.id),o=n&&!R(t)?n.element??n.range?.startContainer.parentElement??null:null;o?.scrollIntoView({block:"center",inline:"nearest",behavior:M?"auto":"smooth"}),o&&e.w(t.id)}function K(e,t,n=!1,...o){let r=Ve("button",{class:"mi",type:"button",role:n?"menuitemcheckbox":"menuitem"},e,Ve("span",{class:"lb"}),...o,n&&Ve("span",{class:"sw","aria-hidden":"true"}),Ve("span",{class:"tt","aria-hidden":"true"}));return r.addEventListener("click",e=>{e.stopPropagation(),t(e)}),r}let V=(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))},Y=()=>Ve("div",{class:"sep",role:"separator"}),U=Ve("span",{class:"ma"}),_=Ve("span",{class:"kc"}),G="",Z=K(U,function(){let t=Ve("input",{class:"input",type:"text",maxlength:"80","aria-label":"Your name"});t.value=e.s.name();let n=Ve("div",{class:"ed"},U.cloneNode(!0),t),o=(r,i=!1)=>{if(x!==o)return;x=null;let a=t.value.trim();r&&a&&a!==e.s.name()&&e.s.rename(a).then(pe),n.replaceWith(Z),i&&Z.focus({preventScroll:!0})};x=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)),Z.replaceWith(n),t.focus({preventScroll:!0})},!1,_);Z.dataset.item="name";let J=K(ot("copy"),()=>{q(),e.s.copyAll("ai")}),X=K(ot("lines"),()=>{q(),e.s.copyAll("text")}),Q=Ve("span",{class:"kc"}),ee=K(ot("look"),()=>{e.s.setLook(Ln[(Ln.indexOf(e.s.look())+1)%3]),pe()},!1,Q),te=Ve("span",{class:"kc"}),ne=K(ot("list"),()=>{A(!1),C(!0)},!1,te),oe=K(ot("comment"),t=>{let n=!e.state.c&&0===t.detail;e.Xe(!e.state.c,n),n&&A(!1)},!0,Ve("span",{class:"kc","aria-hidden":"true"},Ft));oe.dataset.item="comment",oe.setAttribute("aria-keyshortcuts",Ot);let re=Ve("div",{class:"sec",role:"presentation"}),ie=Y(),ae=Y(),le=new Map,se=t=>{let n=le.get(t);return n||(n=K(rt(t.icon,15),()=>{t.checked||q(),Promise.resolve().then(()=>t.select()).catch(t=>e.Y(t)).finally(()=>b&&pe())},!!t.checked,Ve("span",{class:"kc"})),le.set(t,n)),n},de=-1,ce=e=>{try{return e()}catch(e){return globalThis.reportError?.(e),""}};function pe(){let t=F(),n=e.s.name(),o=n||m(e.doc.me);if(V(Z,o,n?"The name on your comments":"Add a name to show on your comments"),Z.setAttribute("aria-label",`${o}, ${n?"edit":"add"} your name`),_.replaceChildren(n?ot("edit",13):"Add name"),st(e.doc.me,n)!==G){G=st(e.doc.me,n);let t=dt(e.doc.me,n);t.classList.add("in"),U.replaceChildren(t)}V(J,"Copy as Markdown","Markdown, with where each thread is"),V(X,"Copy as Text","Just the words");let r=["Automatic","Light","Dark"][Ln.indexOf(e.s.look())];V(ee,"Look",`${r}. Automatic follows the page; press to change`),Q.textContent=r,V(ne,"All comments","Every thread, and where it is"),te.textContent=t?String(t):"";let i=e.addons.ue();re.textContent=i,i?!re.isConnected&&l.contains(Z)&&l.prepend(re):re.remove();for(let t of e.addons.R){let e,n=le.get(t);if(n){try{e=t.checked?.()}catch(e){globalThis.reportError?.(e)}V(n,ce(t.label),ce(t.hint),e),n.querySelector(".kc").textContent=t.count?ce(t.count):""}}V(oe,"Start commenting",e.state.c?"Turn off to hide the comments again":"Shows the comments; choose any part of the page to comment on it",e.state.c)}function ue(){pe(),(de!==e.addons.G||!l.contains(Z))&&(l.replaceChildren(Z,ie,J,X,ee,ne,...e.addons.R.map(se),ae,oe),de=e.addons.G,pe())}o.addEventListener("click",e=>{e.stopPropagation(),b?A(!1):(ue(),A(!0),0===e.detail&&T().at(-1)?.focus({preventScroll:!0}))});let he=!1,fe=()=>{he=g.contains(P())},me=t=>{let n=t.composedPath();b&&!n.includes(l)&&!n.includes(o)&&(A(!1),e.state.c&&!e.k(t)&&(e.we(t),t.preventDefault(),t.stopPropagation())),e.state.p&&!e.k(t)&&C(!1,he&&(!document.activeElement||document.activeElement===document.body))},ge=e=>{if(!b||"touch"===e.pointerType||"pointerout"===e.type&&e.relatedTarget)return;let t=e.composedPath();"pointerover"===e.type&&(t.includes(l)||t.includes(o))?(window.clearTimeout(k),k=0):k||(k=window.setTimeout(()=>{k=0,x||A(!1)},3e3))},ve={n:0,label:""},we=()=>{let{n:t,label:n}=ve,i=e.addons.ue(),a=`Comment${e.state.c?", comment mode on":""}${n?`, ${n}`:t?`, ${t} open`:""}${i?`, ${i}`:""}`;o.getAttribute("aria-label")!==a&&o.setAttribute("aria-label",a);let l=(n||"Comment")+(i?` \xb7 ${i}`:"");r.data!==l&&(r.data=l)},ye=e.addons.subscribe(t=>{we(),(()=>{for(let[t,n]of f)e.addons.listNotes.has(t)||(f.delete(t),n.row.classList.remove("show"),setTimeout(()=>n.row.remove(),320));for(let[t,n]of e.addons.listNotes){let o=f.get(t);if(!o){let e=Ve("span",{}),r=Ve("div",{class:"ln"},Ve("div",{class:"lw"},Ve("div",{class:"ag"},e)));r.dataset.addon=t,o={row:r,words:e,btn:null,note:n},f.set(t,o),h.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=Ve("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.Y(t)).finally(()=>{t.disabled=!1,e.f()}))}),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)}})(),b&&!x&&(t?ue():pe())});window.addEventListener("pointerdown",fe,!0),window.addEventListener("click",me,!0),window.addEventListener("pointerover",ge,!0),window.addEventListener("pointerout",ge,!0);let be=t=>{if("Escape"!==t.key||x||t.composedPath().some(e=>e instanceof Element&&e.classList.contains("rxp")))return;let n=t.composedPath()[0];if(b)q();else{if(!e.state.p||n instanceof HTMLTextAreaElement&&!g.contains(n))return;S?H(!0):C(!1,!0)}t.stopPropagation()};return window.addEventListener("keydown",be,!0),{f(n){E=n;let r=z(!1);if(r!==$){if(r){let[e,n]=t[0].classList.contains("on")?t:[t[1],t[0]];n.textContent=r>99?"99+":String(r),n.classList.toggle("s",r>99),e.classList.remove("on"),n.classList.add("on")}o.classList.toggle("has",r>0),$=r}let i=z(!0),a=i?`${r} here \xb7 ${i} ${null!==e.u.slide()?"on other slides":"in other views"}`:"";o.classList.toggle("else",i>0),ve={n:r,label:a},we(),o.classList.toggle("on",e.state.c),b&&!e.state.s&&A(!1),b&&pe();let l=e.state.p;g.classList.toggle("full",Vt()),g.classList.contains("show")!==l&&(g.classList.toggle("show",l),Ye(g,!l)),S&&(!l||!n.some(e=>e.id===S))&&(S=L=null,e.state.w=null),l&&I()},L:function(){let t=S?E.find(e=>e.id===S):null,n=S?s.querySelector(".mi.open"):null,o=t&&function(t){let n=e.resolved.get(t.id),o=n?.element??n?.range?.startContainer.parentElement;if(!n||Vt()||R(t)||e.V(t)||!1===o?.checkVisibility?.({visibilityProperty:!0}))return null;let r=e.t.querySelector(`.bub[data-thread="${t.id}"]`)?.getBoundingClientRect(),i=n.range?jt(n).at(-1):void 0,a=o?.closest("p,li,h1,h2,h3,h4,h5,h6,blockquote,td,th,figcaption,div")?.getBoundingClientRect().right,l=n.element?.getBoundingClientRect(),s=Ht(t.anchor,n),d=r?.width?{x:r.right+1,y:r.top+r.height/2,from:"right",bubble:!0}:i?{x:Math.max(i.right,a??0)+4,y:(i.top+i.bottom)/2,from:"right"}:l?{x:l.left+l.width/2,y:l.top,from:"top"}:s&&{x:s.x,y:s.y,from:"right"};return d&&d.x>=0&&d.x<=window.innerWidth-320&&d.y>=0&&d.y<=window.innerHeight?d:null}(t),r=n?.getBoundingClientRect(),i=s.getBoundingClientRect();if(!o||!r||r.top+12<i.top||r.top+12>i.bottom)return void v.classList.remove("show");let a,l=r.left,d=r.top+14;if("right"===o.from&&l-o.x>60){let e=o.x+28,t=o.y>=d?1:-1,n=Math.min(24,Math.abs(o.y-d)/2);a=`M${l} ${d}C${l-24} ${d} ${e} ${d} ${e} ${d+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>=d?1:-1,r=Math.min(20,Math.abs(e-d)/2);a=`M${l} ${d}C${l-20} ${d} ${t} ${d} ${t} ${d+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}`}w.setAttribute("d",a),y.setAttribute("r",o.bubble?"0":"4"),y.setAttribute("cx",String(o.x)),y.setAttribute("cy",String(o.y)),v.classList.add("show")},destroy(){ye(),window.removeEventListener("pointerdown",fe,!0),window.removeEventListener("click",me,!0),window.removeEventListener("pointerover",ge,!0),window.removeEventListener("pointerout",ge,!0),window.clearTimeout(k),window.removeEventListener("keydown",be,!0),l.remove(),g.remove(),v.remove(),a.remove()}}}var An="[data-pipeup-slide]",Cn=["scroll","resize","keyup","click","transitionend","slidechanged"],Tn=null,Pn=null,qn=new Set,Nn=new Set,Rn=e=>{try{e()}catch(e){globalThis.reportError?.(e)}};function zn(e){Pn="function"==typeof e?.current&&"function"==typeof e.go?e:null}var Fn=()=>{let e=window.Reveal;return"function"==typeof e?.getIndices&&"function"==typeof e.slide?e:null};var On=["pipeup-quote","pipeup-on","pipeup-done"],Dn={"pipeup-quote":[[250,227,188,.75],[250,200,100,.28]],"pipeup-on":[[247,212,154,.95],[250,200,100,.42]],"pipeup-done":[[180,178,169,.22],[180,178,169,.2]]};function In(){return typeof CSS<"u"&&"highlights"in CSS&&typeof Highlight<"u"}var jn=`:not([data-pipeup-ignore],[data-pipeup-ignore] *){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 Bn(){if(In())for(let e of On)CSS.highlights.delete(e)}var Hn,Wn="#534AB7";function Kn(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(Hn??=t.createElement("canvas").getContext("2d",{willReadFrequently:!0})??null,!Hn)return null;Hn.clearRect(0,0,1,1),Hn.fillStyle="#000",Hn.fillStyle=e,Hn.fillRect(0,0,1,1);let[n,o,r,i]=Hn.getImageData(0,0,1,1).data;return{r:n,g:o,b:r,a:i/255}}catch{return null}}function Vn(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 Yn=(e,t)=>(Math.max(e,t)+.05)/(Math.min(e,t)+.05),Un=[[.92,.25],[.92,.6],[.5,.45]];function _n(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?Kn(t.getComputedStyle(n).backgroundColor,e):null;return t&&e.body&&(!i||i.a<.5)&&(i=Kn(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 Gn(e,t){let n=e.ownerDocument,o=n.defaultView,r="dark"===t;if(!o)return{font:"system-ui, sans-serif",accent:Wn,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=d&&"rgb(0, 0, 238)"!==d?Kn(d,n):null,p=c&&Yn(Vn(c),r?.011:1)>=3,u=l||(p?d:r?"#9A94EE":Wn),h=Kn(u,n);return{font:a,accent:u,dark:r,on:h&&Yn(Vn(h),1)<3?"#111":"#fff"}}function Zn(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 Jn={light:["#2C2C2A","#FFFFFF"],dark:["#ECEBE6","#1B1B19"]},Xn=[["opacity","1"],["filter","none"],["backdrop-filter","none"],["mix-blend-mode","normal"],["transform","none"],["clip-path","none"],["mask-image","none"],["zoom","1"]];function Qn(e,t,n){let[o,r]=Jn[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 Vn({r:o,g:r,b:i})});return((e,t)=>(Math.max(e,t)+.05)/(Math.min(e,t)+.05))(o,r)}function eo(e,t=!1){return yn(e,t)?"column":"bubbles"}var to="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 oo(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="",a=()=>{let e="auto"!==n?n:function(e){let t=e.documentElement.getAttribute("data-pipeup-theme")??e.body?.getAttribute("data-pipeup-theme");return"light"===t||"dark"===t?t:null}(document),t=e??(function(e,t=!1){let n=e.defaultView;if(!n)return!1;let o=e.documentElement,r=Vn(_n(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 Un){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=Kn(n.getComputedStyle(r).backgroundColor,e);if(o&&o.a>=.5){l=Vn(o);break}}a+=l}let l=a/Un.length;return l<.18||!(l>.32)&&t}(document,r)?"dark":"light");o=function(e,t,n){let o=e.defaultView?.getComputedStyle(e.documentElement),r=Xn.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}=_n(e);return{look:t,source:n,ratio:Qn(t,i,[a,l,s]),effects:r}}(document,t,"auto"!==n?"reviewer":e?"author":"page");let a=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 a&&a!==i&&console.warn(i=a),t};r="dark"===a();let l=Gn(e.root,r?"dark":"light"),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:2147483000!important;display:block!important;margin:0!important;visibility:visible!important;opacity:1!important;transform:none!important;filter:none!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",`${Kt()}px`),Zn(a,e),r.append(a),n.documentElement.append(o),{element:o,shadow:r,t:a,destroy:()=>o.remove()}}(l,e.styles),d=function(e=document,t=!1){let n=e.defaultView?.CSSStyleSheet;if(!n||!("replaceSync"in n.prototype)||!("adoptedStyleSheets"in e))return{Ee(){},Se(){},ce(){},dark(){},Te(){},remove:()=>Bn()};let o=new n,r=null,i=!1,a=1,l=t,s=0,d="",c=0,p=()=>o.replaceSync(((e,t)=>On.map(n=>{let[o,r,i,a]=Dn[n][e?1:0];return`::highlight(${n}){background-color:rgba(${o},${r},${i},${+(a*t).toFixed(3)})}`}).join(""))(l,a)+(null===r?"":`:root{--pipeup-gutter:${r}px}`)+(i?jn:"")+(s||d?`html{--pipeup-panel:${s}px;${s?`margin-right:${s}px!important;`:""}${d}}`:""));return p(),e.adoptedStyleSheets=[...e.adoptedStyleSheets,o],{Ee(e){e!==r&&(r=e,p())},Se(e){e!==i&&(i=e,p())},ce(e){a=e,p()},dark(e){e!==l&&(l=e,p())},Te(e,t){e!==s&&(s=e,d=t?"":"transition:margin-right .34s cubic-bezier(.4,0,.2,1)!important",clearTimeout(c),!e&&d&&(c=window.setTimeout(()=>{d="",p()},400)),p())},remove(){clearTimeout(c),e.adoptedStyleSheets=e.adoptedStyleSheets.filter(e=>e!==o),Bn()}}}(document,l.dark);d.ce(0);let c=!0===window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,p=document.documentElement.hasAttribute("data-pipeup-reserve"),u=new Map,h=new Set,f=new WeakSet,v={i:null,w:null,$:!1,mine:!1,hidden:!0,mode:eo(e.root),o:null,c:!1,p:!1,Ae:!1,s:!1},w=Ve("div",{class:"toast",role:"status","aria-live":"polite"}),y=Ve("div",{class:"sr","aria-live":"polite"});s.t.append(w,y);let b=null,x=[],k=null,E=!1,$=0,S=0,L=0,M=0,A=0,C=new Set,T="",P=new Map,q=function(e,t,n=function(){return{l:e=>e.getBoundingClientRect(),shown:e=>!1!==e.checkVisibility?.({opacityProperty:!0,visibilityProperty:!0}),opacity:e=>parseFloat(getComputedStyle(e).opacity)||0,ie:()=>({width:window.innerWidth,height:window.innerHeight})}}()){let o=!0===window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,r=null,i=null,a=0,l=!1,s=()=>[...e.querySelectorAll(An)],d=()=>[...e.querySelectorAll(".slides > section")],c=e=>"string"==typeof e&&e.length>0&&e.length<=200?e:null,p=e=>c(e?.getAttribute("data-pipeup-slide"));function u(){if(Pn){let e=null;if(Rn(()=>{let t=Pn.current();Number.isInteger(t)&&t>0&&(e=String(t))}),null!==e)return e}let e=Fn();if(e){let t=null;if(Rn(()=>{let n=e.getIndices().h,o=d()[n];t=p(o?.matches(An)?o:o?.querySelector(An))??c(String(n+1))}),null!==t)return t}return r&&!r.isConnected&&(r=null),r=function(e,t,n){let o=t.ie(),r=null,i=0,a=0;for(let l of e){if(!t.shown(l))continue;let e=t.l(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}(s(),n,r)??r,p(r)}function h(){a=0,i=u(),t()}let f=()=>{!a&&!l&&(a=requestAnimationFrame(h))},m=e=>function(e,t,n){return null!==t?void 0===e?.slide||e.slide===t:!e||!n||Object.entries(e).every(([e,t])=>"label"===e||"slide"===e||n[e]===t)}(e,i,Tn),g=new MutationObserver(e=>{e.some(e=>e.target instanceof Element&&e.target.matches(An))&&f()});g.observe(e,{subtree:!0,attributes:!0,attributeFilter:["class","style","hidden"]});for(let e of Cn)window.addEventListener(e,f,{capture:!0,passive:!0});return Nn.add(f),i=u(),{slide:()=>i,view(e){let t=e instanceof Element?e:e?.parentElement,n=p(t?.closest(An))??i,o={...null!==n?{slide:n}:{},...Tn};return Object.keys(o).length?o:void 0},m,H:function(e){if(m(e))return Promise.resolve(!0);let t=e.slide,n=Fn(),r=s().find(e=>p(e)===t),a=/^[1-9]\d{0,5}$/.test(t??"");if(a&&Pn)Rn(()=>Pn.go(Number(t)));else if(a&&n){let e=r?d().findIndex(e=>e===r||e.contains(r)):-1;Rn(()=>n.slide(e>=0?e:Number(t)-1))}else if(qn.size)for(let t of qn)Rn(()=>t({...e}));else{if(!r)return Promise.resolve(!1);r.scrollIntoView({block:"start",behavior:o?"auto":"smooth"})}let c=performance.now();return new Promise(t=>{let n=e=>{clearTimeout(o),t(e)},o=setTimeout(()=>n(!1),1e3),r=()=>l?n(!1):(i=u(),m(e)?n(!0):performance.now()-c>=1e3?n(!1):void requestAnimationFrame(r));requestAnimationFrame(r)})},destroy(){l=!0,cancelAnimationFrame(a),g.disconnect();for(let e of Cn)window.removeEventListener(e,f,!0);Nn.delete(f)}}}(e.root,()=>{!E&&_()&&ee()}),N=!1,R=0;function z(e,t=2400,n=!1,o=!1,r){E||(N=n,w.textContent=e,w.classList.toggle("act",!!r),r&&w.append(" ",Ve("a",{class:"ta",href:r.href,target:"_blank",rel:"noopener noreferrer"},r.label)),o?w.setAttribute("aria-hidden","true"):w.removeAttribute("aria-hidden"),w.classList.add("show"),window.clearTimeout($),$=window.setTimeout(()=>w.classList.remove("show"),t))}function F(){N&&(N=!1,window.clearTimeout($),w.classList.remove("show"))}function O(e){y.textContent="",cancelAnimationFrame(R),R=requestAnimationFrame(()=>y.textContent=e)}function D(e){z(no(e))}function I(e){throw D(e),e}let j=t=>({thread:t,location:Se(t.anchor,u.get(t.id)??we(t.anchor,e.root),e.root)}),B={me:e.doc.me,picker:()=>V.picker,people:()=>gt(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 U?z(to):I(e)}},reply:async(t,n,o)=>{try{await e.doc.reply(t,n,o),le(o,n)}catch(e){e instanceof U?z(to):I(e)}},resolve:async t=>{try{await e.doc.resolve(t),z("Resolved \xb7 Show resolved brings it back")}catch(e){z(e instanceof U?`Resolved \xb7 ${to}`:no(e))}(e=>v.i===e&&!v.$&&(k?.ae()?k.le():s.t.querySelector(".launch .mode")?.focus({preventScroll:!0}),!0))(t)&&(v.i=null)},reopen:async t=>{try{await e.doc.reopen(t),z("Reopened")}catch(e){z(e instanceof U?`Reopened \xb7 ${to}`:no(e))}},notRight:async t=>{try{await e.doc.reopen(t)}catch(e){z(e instanceof U?`Reopened \xb7 ${to}`:no(e))}ie(t)},close:()=>{ce(null);let e=te&&s.t.querySelector(te);e?e.focus({preventScroll:!0}):k?.le(),te=""},copy:t=>{try{let n=e.doc.threads().find(e=>e.id===t);if(!n)return;$n(Te(j(n),"ai",location.href,Date.now()),s.t).then(()=>z("Thread copied as Markdown for AI"),e=>z(no(e)))}catch(e){z(no(e))}}},H={look:()=>n,setLook(e){n=e;try{"auto"===e?localStorage.removeItem(t):localStorage.setItem(t,e)}catch{}Ae(a())},copyAll:async e=>{let t=H.all(),n=Pe(t,e,{title:document.title,url:location.href,exportedAt:new Date});try{await $n(n,s.t);let o=t.filter(e=>!e.thread.resolved).length;z(`Copied ${o} thread${1===o?"":"s"}${"ai"===e?" as Markdown for AI":""}`)}catch(e){z(no(e))}},Ge:()=>{v.$=!v.$,ee()},toggleMine:()=>{v.mine=!v.mine,ee()},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)?z(`New comments will say ${n}, but this browser couldn't remember it`):z(`New comments will say ${n}`)}catch(e){z(no(e))}},name:()=>e.doc.name,all:()=>[...e.doc.threads()].sort(_t(K)).map(j)},W={},K={get addons(){return W.surface},doc:e.doc,root:e.root,t:s.t,host:s.element,state:v,resolved:u,T:h,oe:B,s:H,u:q,V:e=>C.has(e.id),ke:()=>{_()&&ee()},F:e=>!v.hidden&&(!e.resolved||v.$||(e=>""!==(s.t.querySelector(`[data-thread="${e}"] .rbox textarea`)?.value.trim()??""))(e.id))&&!C.has(e.id),Je:(t,n)=>{for(let o of e.doc.threads()){let e=u.get(o.id);if(o.anchor.quote&&K.F(o)&&e?.range&&Wt(t,n,jt(e)))return o}return null},re:(e,t)=>K.C()?K.Je(e,t):null,k:e=>e.composedPath().includes(s.element),we:e=>{f.add(e)},Ue:e=>f.has(e),open:ce,Ze:e=>ie(e),w:function(e){v.w!==e&&(v.w=e,e&&e!==v.i&&ge(e),ee())},Ye:pe,Ke:function(e){if(!v.o)return pe(e);Object.assign(v.o,e),ee()},C:()=>!b||b.Be(),be:e=>{let t=b?.ve();e(),t?.()},je:()=>{let e=v.o?.anchor.view,t=b?.ve();Promise.resolve(q.m(e)||q.H(e??{}).then(()=>K.ke())).then(t)},Fe:async function(t,n){let o=v.o;if(o)try{let r=await e.doc.comment(o.anchor,t,n);le(n,t),v.o=null,Y(new Set([r])),ce(r,!0)}catch(e){if(e instanceof U)return v.o=null,Y(new Set([e.id])),ce(e.id,!0),void z(to);I(e)}},seen:se,people:()=>gt(e.doc.threads(),e.doc.me),qe:ue,Xe:he,q:me,D:e=>{b=e},ee:z,E:O,ze:F,Y:D,Qe:ge,f:ee,se:fe},V=W.surface=new At(K,s.shadow,y);function Y(t){let n=performance.now(),o=e.doc.threads();for(let r of o){if(t&&!t.has(r.id))continue;let o=performance.now()-n<40,i=we(r.anchor,e.root,{fuzzy:o});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(M),M=0):0===M&&(M=window.setTimeout(()=>{M=0,!E&&(Y(new Set(h)),ee())},250))}function _(){let t=new Set,n=null!==q.slide(),o=new Set;for(let r of e.doc.threads()){o.add(r.id);let e=u.get(r.id)?.element;(!q.m(r.anchor.view)||!n&&!1===e?.checkVisibility?.({visibilityProperty:!0}))&&t.add(r.id)}C=t;for(let e of P.keys())o.has(e)||P.delete(e);let r=`${q.slide()}|${[...t].join()}`;return r!==T&&(T=r,!0)}let G=0,Z=0,J=0,X=0,Q=0;function ee(){if(E)return;let t=e.doc.threads();if(_(),v.i&&C.has(v.i)){let e=s.t.querySelector(`[data-thread="${v.i}"] .rbox textarea`)?.value;e&&P.set(v.i,e),v.i=null}v.hidden=!(v.c||v.p||v.Ae||v.o),v.hidden&&(v.i=null),v.hidden||function(t){let n=function(e,t){let n=yt(t),o=[];for(let r of e)for(let e of[r.root,...r.root.replies])e.author!==t&&!e.deleted&&vt(e,n)&&!e.seenBy?.includes(t)&&o.push({thread:r,comment:e});return o}(t,e.doc.me).filter(e=>!de.has(e.comment.id));if(!n.length)return;for(let e of n)de.add(e.comment.id);let o=[...new Set(n.map(e=>g(e.comment)))];z(`${1===o.length?o[0]:`${o.length} people`} mentioned you in ${n.length} comment${1===n.length?"":"s"}`)}(t),function(e){if(e===Z)return;Z=e,cancelAnimationFrame(J);let t=G,n=performance.now(),o=e?260:200,r=i=>{let a=Math.min(1,(i-n)/o);G=t+(e-t)*(e?1-(1-a)**3:a*a),d.ce(G),a<1&&(J=requestAnimationFrame(r))};J=requestAnimationFrame(r)}(v.hidden?0:1),s.t.classList.toggle("hidden",v.hidden),s.t.classList.toggle("listing",v.p);let n=v.p&&!Vt();(function(e){e!==X&&(X=e,d.Te(e,c),window.clearTimeout(Q),Q=window.setTimeout(()=>{Y(),ee()},c?0:400))})(n?320:0),d.Ee(p?"column"!==v.mode||v.hidden||n?0:320:null),function(e){let t=[],n=[],o=[];for(let r of e){let e=u.get(r.id);r.resolved&&!v.$||!e?.range||C.has(r.id)||(r.id===v.i||r.id===v.w?n.push(e.range):r.resolved?o.push(e.range):t.push(e.range))}v.o&&q.m(v.o.anchor.view)&&n.push(...v.o.ranges),function(e){if(In())for(let t of On)CSS.highlights.set(t,new Highlight(...e[t.slice(7)]))}({quote:t,on:n,done:o})}(t);for(let e of x)e.f(t);k?.f(t),v.hidden||V.flush()}let te="",ne=()=>s.t.getRootNode().activeElement,oe="input,textarea,select,[contenteditable]:not([contenteditable=false])",re=()=>{let e=ne();return e instanceof HTMLTextAreaElement&&""!==e.value||!!document.activeElement?.matches(oe)};function ie(e,t=re(),n=ne()){let o=[...s.t.querySelectorAll(`[data-thread="${e}"] .rbox textarea`)].find(e=>!e.closest("[inert]")),r=n?.getAttribute("data-thread");te=r?`.${n.classList[0]}[data-thread="${r}"]`:"",!t&&o&&o.focus({preventScroll:!0})}function ae(){let e=v.o;return!(!e||K.C()||(q.m(e.anchor.view)||q.H(e.anchor.view??{}),0))}function le(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()];z(`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 se(t){let n=[t.root,...t.root.replies].filter(t=>t.author!==e.doc.me&&!t.deleted&&vt(t,yt(e.doc.me))).map(e=>e.id);n.length&&e.doc.seen(n).catch(()=>{})}let de=new Set;function ce(t,n=!1){if(t&&ae())return;if(v.i===t&&!v.o)return t?ie(t):void 0;let o=!n&&re(),r=ne();if(t||(v.Ae=!1),v.i=t,t){v.o=null,ge(t);let n=e.doc.threads().find(e=>e.id===t);n&&se(n)}if(ee(),t){let e=P.get(t),i=e&&s.t.querySelector(`[data-thread="${t}"] .rbox textarea`);i&&!i.value&&(i.value=e,i.dispatchEvent(new Event("input",{bubbles:!0}))),P.delete(t),n&&k?.ae()?k.le():ie(t,o,r)}}function pe(e){F(),v.p=!1,v.o=e,v.i=null,ee()}function ue(){v.o&&(v.o=null,ee())}function he(e,t=!1){v.c!==e&&(v.c=e,d.Se(e),e?(v.i=null,v.p=!1,k=wn(K)):(F(),k?.destroy(),k=null,O("Comment mode off")),ee(),k&&(t&&k.xe(),t?k.ae()?z(vn,1e4,!0,!0):z("Nothing here to comment on"):z(`Click anything to comment, or Tab between blocks \xb7 Option-click (Alt-click) to pin \xb7 ${Ft} or Esc to finish`,4e3,!0)))}function fe(){v.o&&(q.m(v.o.anchor.view)||K.C())?ue():v.i?ce(null):k&&!k.se()&&he(!1)}function me(){v.o?ae()||ue():v.i&&ce(null)}function ge(e){let t=u.get(e);!t||"orphaned"===t.state||ve(t.range?jt(t):t.element?[t.element.getBoundingClientRect()]:[])}function ve(e){for(let t of e.slice(0,6)){let e=Ve("div",{class:"pulse"});Ze(e,t,4),s.t.prepend(e),window.setTimeout(()=>e.remove(),1300)}}function ye(){for(let e of x)e.destroy();x=function(e){return[..."column"===e.state.mode?[xn(e),Qt(e,{ne:!1})]:[Qt(e,{ne:!0})],En(e),Mn(e)]}(K),ee()}We.go=t=>{if(t.startsWith("slide:"))return void q.H({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(()=>ve([o.getBoundingClientRect()]),c?0:450))};let be=()=>{if(!E){for(let e of x)e.L();k?.L(),V.L(),A=requestAnimationFrame(be)}},xe=e=>{if("Escape"===e.key)return fe();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&&!(e=>{let t=e.composedPath()[0];return t instanceof Element&&null!==t.closest(oe)})(e)){if(e.preventDefault(),k?.We()&&k.xe())return;he(!v.c,!0)}},ke=e=>{if(K.k(e)||f.has(e))return;let t=window.getSelection();t&&!t.isCollapsed||me()},Ee=()=>{s.t.style.setProperty("--pu-pop",`${Kt()}px`);let t=eo(e.root,"column"===v.mode);t!==v.mode?(v.mode=t,ye()):ee()};function $e(){let e=performance.now();0===S&&(L=e),window.clearTimeout(S);let t=Math.min(120,Math.max(0,L+1e3-e));S=window.setTimeout(()=>{S=0,Y(),ee()},t)}let Le=new MutationObserver(e=>{e.every(e=>s.element.contains(e.target))||$e()});window.addEventListener("keydown",xe),window.addEventListener("click",ke),window.addEventListener("resize",Ee),Le.observe(e.root,{subtree:!0,childList:!0,characterData:!0});let Me=0,Ae=t=>{let n="dark"===t;n!==r&&(r=n,window.clearTimeout(Me),s.t.classList.add("sw"),Me=window.setTimeout(()=>{Zn(s.t,Gn(e.root,t)),d.dark(n),s.t.classList.remove("sw")},170))},Ce=()=>Ae(a()),qe=0,Ne=()=>{qe||(qe=window.setTimeout(()=>{Ce(),qe=window.setTimeout(()=>{qe=0,Ce()},450)},150))},Re=new MutationObserver(e=>{e.every(e=>e.target===s.element)||Ne()});Re.observe(document.documentElement,{attributes:!0,subtree:!0});let ze=window.matchMedia?.("(prefers-color-scheme: dark)");ze?.addEventListener?.("change",Ne);let Fe=new ResizeObserver($e);Fe.observe(e.root);let Oe=e.doc.onChange((e,t,n)=>{V.Oe(t,n),Y(),ee()});return Y(),ye(),A=requestAnimationFrame(be),{ctx:K,appearance:()=>o,destroy(){E=!0,cancelAnimationFrame(A),cancelAnimationFrame(J),cancelAnimationFrame(R),q.destroy(),window.clearTimeout(Q),window.clearTimeout($),window.clearTimeout(S),window.clearTimeout(M),Le.disconnect(),We.go=void 0,Fe.disconnect(),Re.disconnect(),ze?.removeEventListener?.("change",Ne),window.clearTimeout(qe),window.clearTimeout(Me),Oe(),window.removeEventListener("keydown",xe),window.removeEventListener("click",ke),window.removeEventListener("resize",Ee),k?.destroy();for(let e of x)e.destroy();V.destroy(),d.remove(),s.destroy()}}}var ro=null;function io(e={}){if(Pt)return Pt.mount(e);if(!Rt())return Promise.reject(new Error("pipeup: another copy of Pipeup owns the add-on queue. Remove one script."));if(ro)return ro;let t=async function(e,t){let n,o,r=document.documentElement.getAttribute("data-pipeup-doc"),{id:a,key:l}=r?await H(r):{id:`page-${i(location.origin+location.pathname)}`,key:null},s=!1;if(e.store)n=e.store,o=await Q(n);else try{let e=ee.open();n=await function(e){return new Promise((t,n)=>{let o=setTimeout(()=>n(new Error("timed out")),4e3);e.then(t,n).finally(()=>clearTimeout(o))})}(e).catch(t=>{throw e.then(e=>e.close(),()=>{}),t}),o=await Q(n)}catch{n=new X,s=!0,o=await Q(n)}let d=e.name?.trim();d&&d!==o.name&&(o={...o,name:d},await n.saveProfile(o)),navigator.storage?.persist?.().catch(()=>{});let c,p=await _.open({doc:a,key:l,store:n,identity:o.identity,name:o.name});zn(e.slides??null);try{c=oo({doc:p,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.sw{opacity:0;transition-duration:.16s;transition-timing-function:var(--ei)}.layer.dark{--k:#ECEBE6;--mu:#B4B2A9;--fa:#9A9892;--ln:#3A3936;--ru:#34332F;--so:#22221F;--su:#1B1B19;--ho:#2C2C29;--sh:0 8px 28px rgba(0,0,0,.45)}.layer.hidden .bub,.layer.hidden .col,.layer.hidden .pop,.layer.hidden .tip,.layer.hidden .mark,.layer.hidden .selbar{opacity:0!important;pointer-events:none!important}.tx{font-size:14px;line-height:1.5;color:var(--k);white-space:pre-wrap;overflow-wrap:anywhere}.tx.del,.who,.rest,.ctx{color:var(--fa)}.who,.rest{font-size:12px}.who{min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.rft>.who{display:block}.ctx[hidden]{display:none}.ctx{font-size:12px;margin-bottom:3px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.clamp{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.tx a{color:var(--pu-accent);text-decoration:underline;text-decoration-thickness:1px;text-underline-offset:2px}.ft,.rft{display:grid;grid-template-rows:0fr;opacity:0;transition:grid-template-rows var(--in) var(--eo),opacity var(--in) var(--eo)}.ft>*,.rft>*{overflow:hidden;min-height:0;display:flex;align-items:center}.root:hover>.ft,.root:focus-within>.ft,.it:hover>.rft,.it:focus-within>.rft{grid-template-rows:1fr;opacity:1}.ft.has-rest,.ft.open,.rft.open{grid-template-rows:1fr;opacity:1}.ft.has-rest>*{grid-area:1/1}.ft .hover{opacity:0;transition:opacity var(--in) var(--eo)}.ft .rest{transition:opacity var(--in) var(--eo)}.root:hover>.ft .hover,.root:focus-within>.ft .hover,.ft:not(.has-rest) .hover{opacity:1}.root:hover>.ft .rest,.root:focus-within>.ft .rest{opacity:0}.acts{margin-left:6px;display:flex;flex:none}.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);outline:none}.rps,.rbox{padding-left:14px}.rps .it{padding-top:6px}.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;display:flex;align-items:center;gap:8px;padding:8px 0 2px;cursor:text}.input{flex:1;min-width:0;height:27px;display:block;border:0;border-bottom:1px solid var(--ln);outline:none;resize:none;overflow:hidden;font:inherit;font-size:14px;line-height:1.5;padding:3px 0;color:var(--k);background:transparent;transition:border-color var(--in) var(--eo)}.row:hover .input,.input:hover{border-bottom-color:var(--mu)}.input:focus{border-bottom-color:var(--pu-accent)}.ed{display:flex;gap:10px;align-items:center;min-height:34px;padding:6px 10px}.ed .input{font-size:13px;height:22px}.root,.it{position:relative;padding-right:30px}.av{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:80%;height:80%}.root>.av,.it>.av{position:absolute;top:0;right:0}.it>.av{top:6px}.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}.root>.av.ai,.it>.av.ai{position:absolute}.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);outline:none}.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{pointer-events:auto}.ta{margin-left:4px;color:var(--pu-accent);text-decoration:underline;text-underline-offset:2px}.rx .n{font-size:11px}.rx.mine{background:var(--as);color:var(--pu-accent);border-color:var(--pu-accent)}.rx:disabled{cursor:default;opacity:.7}.rx.new,.rxq.new{animation:pu-in var(--mv) var(--eo) both}.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);outline:none}.rrow{min-width:0;flex:1;display:flex;align-items:center}.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{opacity:1;visibility:visible;transform:none;transition-delay:0s}.ref .sl{width:10px;height:7px;border:1.3px solid currentColor;border-radius:2px;flex:none}.seen{display:flex;align-items:center;gap:6px;padding:6px 0 0 14px;font-size:12px;color:var(--fa)}.seen button{margin-left:auto;padding:0 6px;border:0;border-radius:6px;background:none;color:var(--fa);font:inherit;cursor:pointer;transition:color .2s var(--eo),background-color .2s var(--eo)}.seen button:hover,.seen button:focus-visible{color:var(--pu-accent);background:var(--as);outline:none}.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%}.me{flex:none;display:grid}.me>.av{grid-area:1/1;width:26px;height:26px;font-size:13px}.you{display:grid;padding:0 34px;min-height:24px;font-size:12px;color:var(--fa)}.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);outline:none}.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}.send{width:26px;height:26px;border-radius:50%;display:grid;place-items:center;color:var(--pu-accent);flex:none;opacity:0;pointer-events:none;transition:opacity var(--in) var(--eo),background-color .2s var(--eo)}.send.show{opacity:1;pointer-events:auto}.send:hover{background:var(--as)}.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,.ttip,.tt,.mode,.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:10px 12px 8px;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{position:absolute;left:0;right:0;top:0;padding:4px 4px 4px 12px;background:var(--su);border-radius:8px;pointer-events:auto;cursor:pointer;box-shadow:inset 2px 0 0 transparent;transition:transform var(--mv) var(--eio),box-shadow var(--in) var(--eo),opacity var(--in) var(--eo)}.th.hot{box-shadow:inset 2px 0 0 var(--ln)}.th.on{box-shadow:inset 2px 0 0 var(--pu-accent);cursor:default}.th.dim{opacity:.45}.th.resolved:not(.on):not(.hot){opacity:.6}.th.lost .ctx{white-space:normal}.th.wait{opacity:0!important;pointer-events:none}.th.out{opacity:0!important;pointer-events:none;transition:opacity var(--out) var(--ei)}.th:has(.opn:focus-visible){box-shadow:inset 2px 0 0 var(--ln);outline:2px solid var(--pu-accent);outline-offset:2px;border-radius:4px}.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);outline:none}.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)}.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{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;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 .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);outline:none}.namebar .nb[hidden]{display:none}.launch{position:fixed;right:20px;bottom:20px;pointer-events:auto}.launch .mode{position:relative;display:grid;place-items:center;width:46px;height:46px;border-radius:50%;transition:background-color .3s var(--eo),color .3s var(--eo)}.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}.n{font-size:12px;font-weight:500;line-height:1;margin:-1.4px 0 0 1.4px;font-variant-numeric:tabular-nums;opacity:0;transition:opacity var(--in) var(--eo)}.n.s{font-size:9.5px;letter-spacing:-.04em}.n.on{opacity:1}.launch .mode:hover,.launch .mode[aria-expanded=true]{background:var(--ho)}.launch .mode.on{background:var(--pu-accent);color:var(--pu-on,#fff)}.mode>.dot{position:absolute;top:3px;right:3px;width:9px;height:9px;border-radius:50%;background:var(--pu-accent);border:2px solid var(--su);opacity:0}.mode.else>.dot{opacity:1}.ttip{position:absolute;right:0;bottom:54px;white-space:nowrap;border-radius:8px;padding:4px 9px;font-size:12px;pointer-events:none;opacity:0;transform:translateY(3px);transition:opacity var(--out) var(--ei),transform var(--out) var(--ei)}.ttip small{margin-left:8px}.ttip small,.mi .kc{font-size:12px;color:var(--fa)}.mode:hover+.ttip,.mode:focus-visible+.ttip{opacity:1;transform:none;transition:opacity var(--in) var(--eo) .5s,transform var(--in) var(--eo) .5s}.launch .mode[aria-expanded=true]+.ttip{opacity:0;transition:opacity var(--out) var(--ei)}@media(hover:none){.ttip,.tt{display:none}}.menu{position:fixed;right:20px;bottom:76px;width:290px;border-radius:12px;padding:4px;pointer-events:none;opacity:0;transform:translateY(6px);transition:opacity var(--out) var(--ei),transform var(--out) var(--ei)}.menu.show{opacity:1;transform:none;pointer-events:auto;transition:opacity var(--in) var(--eo),transform var(--mv) var(--eo)}.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);outline:none}.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)}.tt{position:absolute;right:calc(100% + 14px);top:50%;translate:0 -50%;width:max-content;max-width:220px;padding:4px 9px;border-radius:8px;font-size:12px;line-height:1.4;color:var(--mu);pointer-events:none;opacity:0;transform:translate(3px);transition:opacity var(--out) var(--ei),transform var(--out) var(--ei)}.mi:hover>.tt,.mi:focus-visible>.tt{opacity:1;transform:none;transition:opacity var(--in) var(--eo) .5s,transform var(--in) var(--eo) .5s}@media(max-width:600px){.tt{right:8px;top:auto;bottom:100%;translate:none;transform:translateY(3px)}}.sw{position:relative;flex:none;width:26px;height:16px;border-radius:8px;background:var(--ln);transition:background-color var(--mv) var(--eio)}.sw:before,.sw:after{content:"";position:absolute;top:2px;left:2px;width:12px;height:12px;border-radius:50%;background:#fff;box-shadow:0 1px 2px #00000040;transition:transform var(--mv) var(--eio),opacity var(--mv) var(--eio)}.sw:before{opacity:0;transform:translate(10px)}[aria-checked=true]>.sw{background:var(--pu-accent)}[aria-checked=true]>.sw:after{transform:translate(10px)}.tools{display:flex;flex:none;gap:2px}.tools[hidden]{display:none}.tool[aria-pressed=true]{background:var(--as);color:var(--pu-accent)}.note{display:block;padding:0 0 4px;font-size:12px;color:var(--fa)}.note[hidden]{display:none}.ov{position:absolute;inset:0;pointer-events:none;overflow:hidden}.xb{flex:1;overflow-y:auto;overscroll-behavior:contain;padding:4px 16px 16px;font-size:13px}.xb p{margin:0 0 10px}.all,.xp{position:fixed;top:0;right:0;bottom:0;width:var(--pu-panel);display:flex;flex-direction:column;border-width:0 0 0 1px;opacity:0;transform:translate(100%);transition:transform var(--out) var(--ei),opacity var(--out) var(--ei)}.all.show,.xp.show{opacity:1;transform:none;pointer-events:auto;transition:transform var(--mv) var(--eo),opacity var(--in) var(--eo)}.all.full{width:100%}.hd{display:flex;align-items:center;gap:8px;padding:12px 10px 8px 16px;font-weight:600}.pn{font-weight:400;color:var(--fa)}.hs{margin-left:auto;display:flex;align-items:center;gap:6px;padding:3px 4px 3px 6px;border-radius:6px;font-size:12px;font-weight:400;color:var(--mu);transition:background-color .2s var(--eo)}.hs:hover,.hs:focus-visible{background:var(--ho);outline:none}.list{flex:1;overflow-y:auto;overscroll-behavior:contain;padding:4px}.all .mi{align-items:flex-start}.all .mi>.av{flex:none}.all .mi>span:last-child{flex:1;min-width:0}.all .mi small{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.all .mi.done{opacity:.6}.all .mi.open{background:var(--so)}.all .mi.open>.av,.all .mi.open .clamp{display:none}.xr{padding:2px 12px 10px 16px}.cx{position:fixed;inset:0;width:100%;height:100%;overflow:visible;pointer-events:none;opacity:0;transition:opacity var(--in) var(--eo)}.cx.show{opacity:1}.cx path{fill:none;stroke:var(--pu-accent);stroke-width:1.5;stroke-linecap:round;opacity:.7}.cx circle{fill:var(--pu-accent)}.layer.listing .col{opacity:0;transition:opacity var(--out) var(--ei)}.sec{padding:8px 10px 2px;font-size:12px;color:var(--fa)}.ag{display:flex;align-items:center;gap:8px;padding:6px 14px;font-size:12px;color:var(--fa);border-bottom:1px solid var(--ln)}.ag[hidden]{display:none}.lns{display:flex;flex-direction:column}.ln{display:grid;grid-template-rows:0fr;opacity:0;transition:grid-template-rows var(--in) var(--eo),opacity var(--in) var(--eo)}.ln.show{grid-template-rows:1fr;opacity:1}.ln>.lw{overflow:hidden;min-height:0}.ag button{margin-left:auto;flex:none;padding:0 6px;border-radius:6px;color:var(--fa);transition:color .2s var(--eo),background-color .2s var(--eo)}.ag button:hover:not(:disabled),.ag button:focus-visible{color:var(--pu-accent);background:var(--as);outline:none}.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);outline:none}@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{position:fixed;left:50%;bottom:28px;border-radius:10px;padding:8px 14px;font-size:13px;opacity:0;transform:translate(-50%,6px);transition:opacity .3s var(--eo),transform .36s var(--eo)}.toast.show{opacity:1;transform:translate(-50%)}@media(pointer:coarse){.mi{min-height:44px}.ib{min-width:36px;min-height:36px}.rxo{min-width:40px;min-height:40px}.refs .ref{min-height:34px}.mnl li{min-height:40px}.send{min-width:36px;min-height:36px}}@media(forced-colors:active){.pick.kf{border:3px solid Highlight}.layer :is(.ib,.mi,.nb,.hs,.selbar button,.say button,.xb button):focus-visible{outline:2px solid Highlight}}@media(prefers-reduced-motion:reduce){.ln{transition-property:opacity}@keyframes pu-in{0%{opacity:0}to{opacity:1}}.bub,.bub.in,.bub.in:hover,.bub.on,.tip,.pop,.selbar,.menu,.all,.xp,.ttip,.tt,.toast,.ref .rc,.rxp,.mnl{transform:none!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{transition-property:opacity,box-shadow}.tip.show{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{transform:none!important}@keyframes pu-pulse{0%{opacity:0}35%{opacity:.85}to{opacity:0}}}',root:e.root??document.body,onName:async e=>{p.name=e,o={...o,name:e},await n.saveProfile(o)}})}catch(e){throw zn(null),e}s&&c.ctx.ee("This browser can't keep comments for this page \u2014 copy the comments (Copy as Markdown) to keep them");let u=()=>{p.flush().catch(e=>globalThis.reportError?.(e))},h=function(e){let t={...e,i:!0};Tt=t;for(let e of Ct.values())"waiting"===e.info.state&&zt(e,t);return()=>{t.i=!1,Tt===t&&(Tt=null);for(let e of[...Ct.values()].reverse())e.stop?.(),delete e.stop;e.surface.destroy()}}({surface:c.ctx.addons,doc:p,root:e.root??document.body,ephemeral:s,version:De,onIdentity:async e=>{o={...o,identity:e},await n.saveProfile(o)}}),f=/\S/.test(document.documentElement.getAttribute("data-pipeup-agents")??"")?window.setTimeout(()=>{qt().some(e=>"agents"===e.id)||console.warn("pipeup: this page lists an agent (data-pipeup-agents), but the agents add-on isn't on the page, so replies won't show. Add @pipeup/agents (see the Add-ons page).")},1e3):0;"off"!==document.documentElement.getAttribute("data-pipeup-updates")&&Date.now()-Date.parse(Ie)>31536e6&&console.info(`pipeup: this is Pipeup ${De}, from ${Ie}; newer versions exist. See https://github.com/pipeup-ai/pipeup/blob/main/CHANGELOG.md`);let m=!1;return window.addEventListener("pagehide",u),{document:p,comments:({all:e=!1}={})=>Oe(c.ctx.s.all(),{title:document.title,url:location.href,exportedAt:new Date,all:e}),appearance:()=>({...c.appearance()}),flush:()=>p.flush(),unmount:()=>{m||(m=!0,window.removeEventListener("pagehide",u),window.clearTimeout(f),h(),c.destroy(),zn(null),ro===t()&&(ro=null))}}}(e,()=>t).catch(e=>{throw ro===t&&(ro=null),e});return ro=t,t}typeof document<"u"&&(Pt?console.warn(`pipeup: Pipeup is on this page twice (${Pt.VERSION} and ${De}); the first one is used. Remove one script.`):(Rt(),function(){let e=document.documentElement;if(!e.hasAttribute("data-pipeup-doc")||"off"===e.getAttribute("data-pipeup-auto"))return;let t=()=>{io().catch(e=>console.error(e))};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",t,{once:!0}):t()}()));const ao=Object.defineProperty({},"__esModule",{value:!0});for(const[t,n]of Object.entries({ADDON_API:1,AI_NAME:v,ANIMALS:c,BUILT:Ie,COLOURS:p,DEFAULT_PROFILE_NAME:"",IndexedDbStore:ee,MemoryStore:X,PipeupDocument:_,UnsavedChangeError:U,VERSION:De,addons:qt,agentComments:Oe,animalName:m,comments:async function(e){if(!ro)throw new Error("pipeup: Pipeup hasn't started on this page");return(await ro).comments(e)},computeOpId:I,copyAll:Pe,copyThread:Te,createIdentity:s,describeElement:he,describeRange:ue,formatAgo:Ce,isAiName:w,labelOf:$e,loadOrCreateProfile:Q,locate:Se,mount:io,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 qn.add(e),()=>{qn.delete(e)}},parseDocumentAttribute:H,readFeedbackFile:V,resolveAnchor:we,setPeople:function(e){ft=e.filter(e=>e&&"string"==typeof e.name&&e.name.trim()&&ht.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[...mt])e()},setViewState:function(e){let t=null;if(e){t={};let n=0;for(let[o,r]of Object.entries(e))if(!("string"!=typeof r||"slide"===o||o.length>64||r.length>200)){if(++n>=16)break;t[o]=r}}Tn=t;for(let e of Nn)e()},signOp:T,use:Nt}))Object.defineProperty(ao,t,{value:n,enumerable:!0});return ao})();
|
|
1
|
+
"use strict";var Pipeup=(()=>{function e(e){let t="";for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function t(e){let t=atob(e.replace(/-/g,"+").replace(/_/g,"/")),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function n(e){return(new TextEncoder).encode(e)}function o(e){if(null===e||"object"!=typeof e)return JSON.stringify(e);if(Array.isArray(e))return"["+e.map(o).join(",")+"]";let t=e;return"{"+Object.keys(t).filter(e=>void 0!==t[e]).sort().map(e=>JSON.stringify(e)+":"+o(t[e])).join(",")+"}"}function r(e){return e.replace(/\s+/g," ").trim()}function i(e){let t=r(e),n=2166136261;for(let e=0;e<t.length;e++)n^=t.charCodeAt(e),n=Math.imul(n,16777619)>>>0;return n.toString(16).padStart(8,"0")}var a=/^[A-Za-z0-9_-]{43}$/,l=new Map;async function s(){let t=await crypto.subtle.generateKey({name:"Ed25519"},!1,["sign","verify"]);return{publicKey:e(new Uint8Array(await crypto.subtle.exportKey("raw",t.publicKey))),privateKey:t.privateKey}}async function d(t,n){let o=await crypto.subtle.sign({name:"Ed25519"},t.privateKey,n);return e(new Uint8Array(o))}var c=["Otter","Fox","Owl","Bear","Rabbit"],u=["Red","Orange","Yellow","Green","Teal","Blue","Purple","Pink","Brown","Grey"];function p(e){let t=2166136261;for(let n=0;n<e.length;n++)t=Math.imul(t^e.charCodeAt(n),16777619);return t=Math.imul(t^t>>>16,2246822507),t=Math.imul(t^t>>>13,3266489909),(t^t>>>16)>>>0}var h=e=>p(e)%c.length,f=e=>Math.floor(p(e)/c.length)%u.length,m=e=>`${u[f(e)]} ${c[h(e)]}`,g=e=>{let t=e.name.replace(/^AI assistant \xb7 /,"")||m(e.author);return e.alike?`${t} \xb7 ${function(e){let t=p(`id:${e}`),n="";for(let e=0;e<4;e++,t>>>=5)n+="0123456789ABCDEFGHJKMNPQRSTVWXYZ"[31&t];return n}(e.author)}`:t},v="AI assistant",w=e=>e===v||e.startsWith(`${v} `),y=2**40,b=2**47,x=1e4,k=/^[0-9a-f]{8}$/,E=/^[A-Za-z0-9_-]{43}$/,$=/^(?:[^\s@<>"]{1,64}@[^\s@<>"]{1,190}\.[^\s@<>"]{2,24}|gh:[A-Za-z0-9-]{1,39})$/,S=/^(?:[A-Za-z0-9_-]{43}|(?:host|gh):[A-Za-z0-9._@-]{1,64})$/,L=/^[A-Za-z0-9_-]{43}$/,M=new Set(["create","reply","edit","delete","resolve","reopen","addressed","react","unreact","seen","contact","uncontact"]),A=/^(?:\p{Regional_Indicator}{2}|[#*0-9]\uFE0F?\u20E3|\p{Extended_Pictographic}(?:\uFE0F|\p{Emoji_Modifier})?(?:\u200D\p{Extended_Pictographic}(?:\uFE0F|\p{Emoji_Modifier})?)*)$/u,C=e=>"string"==typeof e&&A.test(e)&&[...e].length<=16;async function T(e,t){if(e.author!==t.publicKey)throw new Error("pipeup: an op must be signed by its author");return{body:e,sig:await d(t,n(o(e)))}}var P=(e,t)=>"string"==typeof e&&e.length<=t,q=e=>!!e&&"object"==typeof e,N=e=>"number"==typeof e&&Number.isFinite(e)&&e>=0&&e<=1;function R(e){if(!q(e))return!1;let{id:t,path:n,fingerprint:o,snapshot:r,quote:i,point:a,view:l}=e;if(!(P(n,2e3)&&P(r,500)&&"string"==typeof o&&k.test(o)&&(void 0===t||P(t,200)&&""!==t)&&(void 0===i||q(i)&&P(i.exact,x)&&""!==i.exact&&P(i.prefix,64)&&P(i.suffix,64))&&(void 0===a||q(a)&&N(a.x)&&N(a.y))))return!1;if(void 0!==l){if(!q(l)||Array.isArray(l))return!1;let e=Object.entries(l);if(e.length>16||!e.every(([e,t])=>e.length<=64&&P(t,200)))return!1}return!0}function z(e){if(!q(e))return!1;let{body:t,sig:n}=e;if("string"!=typeof n||!q(t)||JSON.stringify({body:t,sig:n}).length>262144)return!1;let o=t;if(1!==o.v||"string"!=typeof o.id||!E.test(o.id)||!M.has(o.kind)||!P(o.doc,64)||""===o.doc||"string"!=typeof o.thread||!E.test(o.thread)||"string"!=typeof o.author||!L.test(o.author)||"string"!=typeof o.name||o.name.length>80||o.name!==o.name.trim()||"number"!=typeof o.clock||!Number.isSafeInteger(o.clock)||o.clock<1||o.clock>y||"number"!=typeof o.at||!Number.isSafeInteger(o.at)||o.at<0||o.at>b||void 0!==o.text&&(!P(o.text,1e4)||o.text!==o.text.trim())||void 0!==o.target&&("string"!=typeof o.target||!E.test(o.target))||("create"===o.kind||"reply"===o.kind||"edit"===o.kind||"addressed"===o.kind)&&!o.text||("reply"===o.kind||"edit"===o.kind||"delete"===o.kind)&&!o.target)return!1;if(void 0!==o.mentions){if("create"!==o.kind&&"reply"!==o.kind&&"edit"!==o.kind||!Array.isArray(o.mentions)||o.mentions.length>20)return!1;let e=o.text?.length??0;for(let t of o.mentions){if(!q(t)||!Number.isSafeInteger(t.start)||!Number.isSafeInteger(t.end))return!1;let{start:n,end:o,ref:r}=t;if(n<0||o<=n||o>e||"string"!=typeof r||!S.test(r))return!1}}return!(!("contact"!==o.kind||"string"==typeof o.text&&$.test(o.text))||"seen"===o.kind&&!o.target||!("react"!==o.kind&&"unreact"!==o.kind||o.target&&C(o.text))||!("create"!==o.kind||o.id===o.thread&&R(o.anchor)))}function D(r){return async function(n,o,r){if(!a.test(n))return!1;try{if(e(t(n))!==n)return!1;let i=l.get(n);if(!i){l.size>=512&&l.delete(l.keys().next().value),i=crypto.subtle.importKey("raw",t(n),{name:"Ed25519"},!0,["verify"]),l.set(n,i);let e=i;e.catch(()=>{l.get(n)===e&&l.delete(n)})}return await crypto.subtle.verify({name:"Ed25519"},await i,t(r),o)}catch{return!1}}(r.body.author,n(o(r.body)),r.sig)}function O(e,t){return e.body.clock!==t.body.clock?e.body.clock-t.body.clock:e.body.at!==t.body.at?e.body.at-t.body.at:e.body.author!==t.body.author?e.body.author<t.body.author?-1:1:e.body.id!==t.body.id?e.body.id<t.body.id?-1:1:0}function F(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 I(t){let r={...t,id:void 0,thread:"create"===t.kind?void 0:t.thread},i=await crypto.subtle.digest("SHA-256",n(o(r)));return e(new Uint8Array(i))}var B=class{constructor(e){this.doc=e}ops=new Map;clock=0;createAt=new Map;threadAt=new Map;get size(){return this.ops.size}all(){return[...this.ops.values()]}threads(){return function(e){let t=new Map,n=new Map,o=new Map;for(let{body:r}of[...e].sort(O)){if(r.name&&o.set(r.author,r.name),"create"===r.kind){if(t.has(r.id)||!r.anchor||void 0===r.text)continue;let e=F(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=F(r.id,r.author,r.name,r.text,r.at,r.mentions);e.root.replies.push(t),n.set(r.id,{comment:t,thread:r.thread});continue}if("seen"===r.kind){let e=i.comment.seenBy??=[];e.includes(r.author)||e.push(r.author);continue}if("react"===r.kind||"unreact"===r.kind){if(void 0===r.text||i.comment.deleted)continue;let e=i.comment.reactions,t=e.find(e=>e.emoji===r.text);if("react"===r.kind){let n={author:r.author,name:r.name};t?t.by.some(e=>e.author===r.author)||t.by.push(n):e.length<12&&e.push({emoji:r.text,by:[n]})}else t&&(t.by=t.by.filter(e=>e.author!==r.author),t.by.length||e.splice(e.indexOf(t),1));continue}r.author!==i.comment.author||i.comment.deleted||("edit"===r.kind&&void 0!==r.text&&(i.comment.text=r.text,i.comment.edited=!0,r.mentions?i.comment.mentions=r.mentions:delete i.comment.mentions),"delete"===r.kind&&(i.comment.text="",i.comment.deleted=!0,i.comment.reactions=[],delete i.comment.mentions))}}for(let{comment:e}of n.values()){e.name||(e.unnamed=!0,e.name=o.get(e.author)??"");for(let t of e.reactions)for(let e of t.by)e.name||=o.get(e.author)??""}let r=new Map,i=(e,t)=>{let n=g({author:e,name:t}).toLowerCase();(r.get(n)??r.set(n,new Set).get(n)).add(e)};for(let{comment:e}of n.values()){i(e.author,e.name);for(let t of e.reactions)for(let e of t.by)i(e.author,e.name)}let a=(e,t)=>(r.get(g({author:e,name:t}).toLowerCase())?.size??0)>1;for(let{comment:e}of n.values()){a(e.author,e.name)&&(e.alike=!0);for(let t of e.reactions)for(let e of t.by)a(e.author,e.name)&&(e.alike=!0)}return[...t.values()]}(this.ops.values())}async add(e){let t=[];for(let n of e){if(!z(n)||n.body.doc!==this.doc||this.ops.has(n.body.id)||n.body.id!==await I(n.body)||!await D(n))continue;let e={body:n.body,sig:n.sig};this.ops.set(e.body.id,e),this.clock=Math.max(this.clock,e.body.clock),"create"===e.body.kind&&this.createAt.set(e.body.author,Math.max(this.createAt.get(e.body.author)??0,e.body.at)),this.threadAt.set(e.body.thread,Math.max(this.threadAt.get(e.body.thread)??0,e.body.at)),t.push(e)}return t}async append(e,t,n){let o={v:1,...n,id:"",thread:"create"===n.kind?"":n.thread,doc:this.doc,author:e.publicKey,name:t,clock:Math.min(this.clock+1,y),at:Math.min(Math.max(Date.now(),"create"===n.kind?(this.createAt.get(e.publicKey)??0)+1:(this.threadAt.get(n.thread)??0)+1),b)};o.id=await I(o);let r=this.ops.get(o.id);if(r)return r;"create"===o.kind&&(o.thread=o.id);let[i]=await this.add([await T(o,e)]);if(!i)throw new Error("pipeup: could not record this change");return i}},j=/^([A-Za-z0-9_-]{16}):([A-Za-z0-9_-]{43})$/;async function H(e){let n=j.exec(e.trim()),o=n?.[1],r=n?.[2];if(!o||!r)throw new Error('pipeup: data-pipeup-doc must look like "<id>:<key>", as made by newDocumentAttribute()');return{id:o,key:await crypto.subtle.importKey("raw",t(r),{name:"AES-GCM"},!1,["encrypt","decrypt"])}}async function W(t,o,r){let i=crypto.getRandomValues(new Uint8Array(12)),a=await crypto.subtle.encrypt({name:"AES-GCM",iv:i,additionalData:n(r)},t,n(o));return{iv:e(i),data:e(new Uint8Array(a))}}var K=e=>`pipeup-file:${e}`;async function Y(e,o,r){if(e.length>5e6)throw new Error("pipeup: this feedback file is too large");let i,a,l;try{i=JSON.parse(e)}catch{throw new Error("pipeup: this is not an Pipeup feedback file")}if(!i||"object"!=typeof i||1!==i.pipeup||"string"!=typeof i.doc)throw new Error("pipeup: this is not an Pipeup feedback file");if(i.doc!==o)throw new Error("pipeup: this feedback is for a different document");if(!i.sealed)return Array.isArray(i.ops)?i.ops:[];if(!r)throw new Error("pipeup: this feedback is sealed, and this page has no document key");if("string"!=typeof i.iv||"string"!=typeof i.data)throw new Error("pipeup: this is not an Pipeup feedback file");try{a=await async function(e,o,r){try{let i=await crypto.subtle.decrypt({name:"AES-GCM",iv:t(o.iv),additionalData:n(r)},e,t(o.data));return(new TextDecoder).decode(i)}catch{throw new Error("pipeup: this feedback could not be opened with this document")}}(r,{iv:i.iv,data:i.data},K(o))}catch{throw new Error("pipeup: this feedback could not be opened with this document's key")}try{l=JSON.parse(a)}catch{throw new Error("pipeup: this is not an Pipeup feedback file")}return Array.isArray(l)?l:[]}var V=/^[a-z][a-z0-9-]{1,23}\/[a-z][a-z0-9-]{0,31}$/,U=class extends Error{constructor(e,t,n=1){super("pipeup: shown here, but not saved yet"),this.id=e,this.cause=t,this.count=n,this.name="UnsavedChangeError"}},_=class e{constructor(e,t){this.log=e,this.options=t,this.displayName=t.name.trim()?J(t.name):""}listeners=new Set;cache=[];comments=new Map;displayName;fe=Promise.resolve();unsaved=[];static async open(t){if("string"!=typeof t.doc||""===t.doc||t.doc.length>64)throw new Error("pipeup: the document id must be 1 to 64 characters");let n=new B(t.doc),o=await t.store.load(t.doc),r=o.length-(await n.add(o)).length;r&&console.warn(`pipeup: ${r} saved change${1===r?"":"s"} on this page couldn't be read; kept as saved`);let i=new e(n,t);return i.refresh(!1),i}get id(){return this.options.doc}get me(){return this.options.identity.publicKey}get name(){return this.displayName}set name(e){this.displayName=J(e),this.refresh(!0,[],"")}threads(){return this.cache}ops(){return this.log.all()}onChange(e){return this.listeners.add(e),()=>this.listeners.delete(e)}comment(e,t,n){return this.enqueue(()=>this.write({kind:"create",anchor:e,text:G(t),...n?.length?{mentions:n}:{}}))}reply(e,t,n){return this.enqueue(()=>this.write({kind:"reply",thread:this.find(e).thread,target:e,text:G(t),...n?.length?{mentions:n}:{}}))}edit(e,t,n){return this.enqueue(async()=>{let{thread:o}=this.mine(e);await this.write({kind:"edit",thread:o,target:e,text:G(t),...n?.length?{mentions:n}:{}})})}remove(e){return this.enqueue(async()=>{let{thread:t}=this.mine(e);await this.write({kind:"delete",thread:t,target:e})})}contact(e){let t=e.trim();return $.test(t)?this.enqueue(async()=>{await this.write({kind:"contact",thread:this.me,text:t})}):Promise.reject(new Error("pipeup: that isn't an email address or a GitHub name"))}uncontact(){return this.enqueue(async()=>{await this.write({kind:"uncontact",thread:this.me})})}contacts(){let e=new Map;for(let{body:t}of[...this.log.all()].sort(O))"contact"===t.kind&&t.text?e.set(t.author,t.text):"uncontact"===t.kind&&e.delete(t.author);return e}get portable(){return this.options.identity.privateKey.extractable}async seed(){let e=this.options.identity.privateKey;if(!e.extractable)return null;let{d:n}=await crypto.subtle.exportKey("jwk",e);return n?t(n):null}seen(e){return this.enqueue(async()=>{for(let t of e){let e=this.comments.get(t);e&&!e.comment.seenBy?.includes(this.me)&&await this.write({kind:"seen",thread:e.thread,target:t})}})}react(e,t){return this.enqueue(async()=>{await this.write({kind:"react",thread:this.find(e).thread,target:e,text:Z(t)})})}unreact(e,t){return this.enqueue(async()=>{await this.write({kind:"unreact",thread:this.find(e).thread,target:e,text:Z(t)})})}resolve(e){return this.enqueue(async()=>{await this.write({kind:"resolve",thread:this.thread(e)})})}reopen(e){return this.enqueue(async()=>{await this.write({kind:"reopen",thread:this.thread(e)})})}sign(e,t){if(!V.test(e))throw new Error('pipeup: a signing purpose looks like "<add-on id>/<name>"');return d(this.options.identity,n(`pipeup:${e}\n${t}`))}flush(){return this.enqueue(()=>this.persist())}exportFile(){return async function(e,t,n){let o=n?{pipeup:1,doc:e,sealed:!0,...await W(n,JSON.stringify(t),K(e))}:{pipeup:1,doc:e,sealed:!1,ops:t};return JSON.stringify(o,null,2)}(this.options.doc,this.log.all(),this.options.key)}async importFile(e){return this.merge(await Y(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 U(n[0].body.id,e,n.length):e}return n.length})}enqueue(e){let t=this.fe.then(e);return this.fe=t.catch(()=>{}),t}async write(e){let t=await this.log.append(this.options.identity,this.displayName,e);this.unsaved.push(t),this.refresh(!0,[t],"local");try{await this.persist()}catch(e){throw new U(t.body.id,e)}return t.body.id}async persist(){if(0===this.unsaved.length)return;let e=[...this.unsaved];await this.options.store.append(this.options.doc,e),this.unsaved=this.unsaved.filter(t=>!e.includes(t))}refresh(e,t=[],n=""){this.cache=this.log.threads(),this.comments.clear();let o=(e,t)=>{e.unnamed&&e.author===this.me&&this.displayName&&(e.name=this.displayName),this.comments.set(e.id,{comment:e,thread:t});for(let n of e.replies)o(n,t)};for(let e of this.cache)o(e.root,e.id);if(e)for(let e of this.listeners)try{e(this.cache,t,n)}catch(e){globalThis.reportError?.(e)}}find(e){let t=this.comments.get(e);if(!t)throw new Error("pipeup: there is no comment with that id");return t}mine(e){let t=this.find(e);if(t.comment.author!==this.me)throw new Error("pipeup: only the writer can change a comment");return t}thread(e){if(!this.cache.some(t=>t.id===e))throw new Error("pipeup: there is no thread with that id");return e}};function G(e){let t=e.trim();if(!t)throw new Error("pipeup: a comment needs some words");if(t.length>1e4)throw new Error("pipeup: comments are limited to 10000 characters");return t}function Z(e){if(!C(e))throw new Error("pipeup: a reaction is one emoji");return e}function J(e){let t=e.replace(/\s+/g," ").trim();if(!t||t.length>80)throw new Error("pipeup: choose a name of 1 to 80 characters");if(w(t))throw new Error("pipeup: that name is kept for AI replies; choose another");return t}var X=class{docs=new Map;profile=null;async load(e){return[...this.docs.get(e)?.values()??[]]}async append(e,t){let n=this.docs.get(e);n||this.docs.set(e,n=new Map);for(let e of t)n.set(e.body.id,e)}async loadProfile(){return this.profile}async saveProfile(e){this.profile=e}async saveProfileIfAbsent(e){return this.profile||(this.profile=e),this.profile}};async function Q(e,t=""){let n=await e.loadProfile();if(n)return"Reviewer"===n.name?{...n,name:""}:n;let o={identity:await s(),name:t};return e.saveProfileIfAbsent(o)}var ee=class e{constructor(e){this.db=e}static open(t="pipeup"){return new Promise((n,o)=>{let r=indexedDB.open(t,1);r.onupgradeneeded=()=>{let e=r.result;e.createObjectStore("ops",{keyPath:["doc","id"]}).createIndex("doc","doc"),e.createObjectStore("meta")},r.onsuccess=()=>{let t=r.result;t.onversionchange=()=>t.close(),n(new e(t))},r.onerror=()=>o(r.error??new Error("pipeup: could not open local storage"))})}close(){this.db.close()}async load(e){return(await this.request("ops","readonly",t=>t.index("doc").getAll(e))).map(e=>e.op)}async append(e,t){if(0===t.length)return;let n=this.db.transaction("ops","readwrite"),o=n.objectStore("ops"),r=te(n);try{for(let n of t)o.put({doc:e,id:n.body.id,op:n})}catch(e){throw n.abort(),r.catch(()=>{}),e}await r}async loadProfile(){return await this.request("meta","readonly",e=>e.get("profile"))??null}async saveProfile(e){await this.request("meta","readwrite",t=>t.put(e,"profile"))}async saveProfileIfAbsent(e){let t=this.db.transaction("meta","readwrite"),n=t.objectStore("meta"),o=te(t),r=e,i=n.get("profile");return i.onsuccess=()=>{i.result?r=i.result:n.put(e,"profile")},await o,r}request(e,t,n){return new Promise((o,r)=>{let i=n(this.db.transaction(e,t).objectStore(e));i.onsuccess=()=>o(i.result),i.onerror=()=>r(i.error??new Error("pipeup: local storage request failed"))})}};function te(e){return new Promise((t,n)=>{e.oncomplete=()=>t(),e.onerror=()=>n(e.error??new Error("pipeup: local storage write failed")),e.onabort=()=>n(e.error??new Error("pipeup: local storage write aborted"))})}function ne(e){let t=(e.ownerDocument??e).createTreeWalker(e,NodeFilter.SHOW_TEXT),n=[],o="";for(let e=t.nextNode();e;e=t.nextNode())n.push({node:e,start:o.length}),o+=e.data;return{text:o,nodes:n}}function oe(e,t,n){let o=(e.ownerDocument??e).createRange();return o.setStart(e,0),o.setEnd(t,n),o.toString().length}function re(e,t,n){let o=ie(e,t,!1),r=ie(e,n,!0);if(!o||!r||n<t)return null;let i=o.node.ownerDocument.createRange();return i.setStart(o.node,o.offset),i.setEnd(r.node,r.offset),i}function ie(e,t,n){let o=e.nodes.find(e=>t>=e.start&&t<e.start+e.node.data.length+Number(n));return o&&{node:o.node,offset:t-o.start}}function ae(e){return e.nodeType===Node.ELEMENT_NODE?e:e.parentElement}function le(e,t){for(let n=ae(e)?.closest("[data-pipeup-id]")??null;n;){if(!t.contains(n))return null;let e=n.getAttribute("data-pipeup-id")??"";if(""!==e&&e.length<=200)return n;n=n.parentElement?.closest("[data-pipeup-id]")??null}return null}function se(e,t,n){return e.slice(t,n).replace(/^[\uDC00-\uDFFF]|[\uD800-\uDBFF]$/g,"")}function de(e,t){let n=function(e,t){if(e===t)return"";let n=[];for(let o=t;o&&o!==e;o=o.parentElement){let e=1;for(let t=o.previousElementSibling;t;t=t.previousElementSibling)t.tagName===o.tagName&&e++;n.unshift(`${o.tagName.toLowerCase()}:nth-of-type(${e})`)}return":scope > "+n.join(" > ")}(e,t);if(n.length>2e3)throw new Error("pipeup: this element is nested too deeply to comment on \u2014 give a nearby container a data-pipeup-id");return n}function ce(e){if(!R(e))throw new Error("pipeup: could not describe this place on the page");return e}function ue(e,t){let n=ae(e),o=n?.closest("p,li,h1,h2,h3,h4,h5,h6,td,th,blockquote,pre,figcaption,dt,dd,summary,caption")??null;return o&&t.contains(o)?o:n&&t.contains(n)?n:t}function pe(e,t,n){if(!t.contains(e.commonAncestorContainer))throw new Error("pipeup: the selection is outside the commentable area");let o=le(e.commonAncestorContainer,t),a=o??t,{text:l}=ne(a),s=oe(a,e.startContainer,e.startOffset),d=oe(a,e.endContainer,e.endOffset),c=l.slice(s,d);if(""===c)throw new Error("pipeup: select some text to comment on");if(c.length>x)throw new Error("pipeup: selections are limited to 10000 characters");let u=se(l,Math.max(0,s-32),s),p=se(l,d,d+32);return ce({...o?{id:o.getAttribute("data-pipeup-id")??""}:{},path:"",quote:{exact:c,prefix:u,suffix:p},...n?{view:n}:{},fingerprint:i(ue(e.startContainer,t).textContent??""),snapshot:se(r(u+c+p),0,200)})}function he(e,t,n,o){let a=le(e,t);return ce({...a?{id:a.getAttribute("data-pipeup-id")??""}:{},path:de(a??t,e),...n?{point:{x:fe(n.x),y:fe(n.y)}}:{},...o?{view:o}:{},fingerprint:i(e.textContent??""),snapshot:se(r(e.textContent??""),0,200)})}function fe(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):0}function me(e,t,n){let o=Array.from({length:t.length+1},(e,t)=>t),r=[...o],i=[t.length];for(let a=1;a<=e.length;a++){r[0]=n?0:a;for(let n=1;n<=t.length;n++){let i=e.charCodeAt(a-1)===t.charCodeAt(n-1)?0:1;r[n]=Math.min(o[n]+1,r[n-1]+1,o[n-1]+i)}i.push(r[t.length]),[o,r]=[r,o]}return i}var ge=(e,t)=>me(e,t,!1).pop(),ve={state:"orphaned",element:null,range:null};function we(e,t,n={}){let o=e.id?function(e,t){for(let n of e.querySelectorAll("[data-pipeup-id]"))if(n.getAttribute("data-pipeup-id")===t)return n;return null}(t,e.id):t;return e.quote?function(e,t,n,o,r){let a=n??o,l=ne(a),s=function(e,t){if(!t.exact)return-1;let n=-1,o=-1;for(let r=e.indexOf(t.exact);-1!==r;r=e.indexOf(t.exact,r+1)){let i=e.slice(Math.max(0,r-t.prefix.length),r),a=e.slice(r+t.exact.length,r+t.exact.length+t.suffix.length),l=be(i,t.prefix)+ye(a,t.suffix);l>o&&(n=r,o=l)}return n}(l.text,t);if(s>=0){let r=re(l,s,s+t.exact.length);if(r){let t=ue(r.startContainer,o);return{state:null!==n&&i(t.textContent??"")===e.fingerprint?"attached":"moved",element:t,range:r}}}if(r){let e=a===o?l:ne(o);if(e.text.length<=5e4&&t.exact.length>=12&&t.exact.length<=300){let n=function(e,t,n){let o=t.length;if(0===o)return null;let r=-1,i=1/0;if(me(e,t,!0).forEach((e,t)=>{t&&e<i&&(i=e,r=t)}),i>n)return null;let a=Math.max(0,r-o),l=1/0;for(let i=Math.max(0,r-o-n);i<=Math.min(r,r-o+n);i++){let n=ge(e.slice(i,r),t);n<l&&(l=n,a=i)}return{start:a,end:r,distance:l}}(e.text,t.exact,Math.floor(t.exact.length/4)),r=n?re(e,n.start,n.end):null;if(r)return{state:"moved",element:ue(r.startContainer,o),range:r}}}return ve}(e,e.quote,o,t,!1!==n.fuzzy):function(e,t){if(!t)return ve;let n=t;if(e.path){if(!e.path.startsWith(":scope > "))return ve;try{n=t.querySelector(e.path)}catch{return ve}}return n?{state:i(n.textContent??"")===e.fingerprint?"attached":"moved",element:n,range:null}:ve}(e,o)}function ye(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;return n}function be(e,t){let n=0;for(;n<e.length&&n<t.length&&e[e.length-1-n]===t[t.length-1-n];)n++;return n}var xe={A:"Link",BUTTON:"Button",P:"Paragraph",LI:"List item",IMG:"Image",TABLE:"Table",TD:"Cell",TH:"Cell",FIGURE:"Figure",SVG:"Graphic",CANVAS:"Graphic",LABEL:"Label",INPUT:"Field",SELECT:"Field",TEXTAREA:"Field",SUMMARY:"Question",BLOCKQUOTE:"Quote",SECTION:"Section",H1:"Heading",H2:"Heading",H3:"Heading",H4:"Heading",H5:"Heading",H6:"Heading"};function ke(e){return e.getAttribute("data-pipeup-label")||xe[e.tagName.toUpperCase()]||"Block"}function Ee(e){return Me(r(e.getAttribute("aria-label")??e.getAttribute("alt")??e.innerText??e.textContent??""),40)}function $e(e){let t=e.getAttribute("data-pipeup-label");if(t)return t;let n=Ee(e);return n?`${ke(e)} \xb7 ${n}`:ke(e)}function Se(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]")?.querySelector("h1,h2,h3")?.textContent;s.push(`Slide ${d}`+(e?` "${Me(r(e))}"`:""))}else{let t=Le(e.view);t&&s.push(t);let o=function(e,t){let n=null;for(let o of t.querySelectorAll("h1,h2,h3")){if(o===e||o.contains(e))break;if(!(4&o.compareDocumentPosition(e)))break;n=o}return n}(l,n);o&&s.push(`Section "${Me(r(o.textContent??""))}"`)}let c=$e(l);return s.push(c),{where:s.join(" \u203a "),element:c,id:o,quote:i,pin:a}}function Le(e){return e?e.label||Object.entries(e).filter(([e,t])=>t&&"slide"!==e).map(([,e])=>e).join(" \xb7 "):""}function Me(e,t=60){return e.length>t?e.slice(0,t-1)+"\u2026":e}var Ae="Each thread says where it is: the slide or section, the element (its data-pipeup-id attribute in the HTML), and the exact quoted text or pin position. Work through the open threads in order, and for each one say what you changed or why you did not. Answer in the thread (the Pipeup skill says how) and mark it addressed; never resolve it, the author does.";function Ce(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 Te(e,t,n,o){return"ai"===t?Re(e,"## Comment thread",o,n):ze(e)}function Pe(e,t,n){let o=n.all?e:e.filter(e=>!e.thread.resolved);if("text"===t)return o.map(ze).join("\n");let r=n.all?0:e.length-o.length,i=[`# Review comments: ${Ne(n.title)}`,"",`- **Page:** ${Ne(n.url)}`,`- **Exported:** ${n.exportedAt.toISOString()}`,`- **Open threads:** ${e.length-e.filter(e=>e.thread.resolved).length}${r?` (${r} resolved, not included)`:n.all?" (resolved ones included)":""}`,"",Ae,"",""].join("\n"),a=n.exportedAt.getTime();return i+o.map((e,t)=>Re(e,`## Thread ${t+1}`,a)).join("\n")}function qe(e){return e.reactions.map(e=>`${e.emoji} ${e.by.length} (${e.by.map(e=>Ne(g(e))).join(", ")})`).join(" \xb7 ")}function Ne(e){return e.replace(/\s+/g," ").trim()}function Re(e,t,n,o){let{thread:r,location:i}=e,a=r.root.replies.length,l=[`${t} \xb7 ${r.resolved?"resolved":r.addressed?"open, addressed":"open"}`];if(l.push(`- **Thread:** ${r.id}`),o&&l.push(`- **Page:** ${Ne(o)}`),l.push(`- **Where:** ${Ne(i.where)}`),i.id){let e=Ne(i.id.replace(/`/g,""));l.push(`- **Element:** \`[data-pipeup-id="${e}"]\`${i.element?` (${Ne(i.element)})`:""}`)}i.quote&&l.push(`- **Quoted text:** "${Ne(i.quote)}"`),i.pin&&l.push(`- **Pin:** ${Ne(i.pin)}`),r.addressed&&!r.resolved&&l.push(`- **Addressed:** ${Ne(r.addressed.text)} (${Ne(g(r.addressed))}, ${Ce(r.addressed.at,n)})`),l.push(`- **Started by:** ${Ne(g(r.root))}, ${Ce(r.root.at,n)}${a?` \xb7 ${a} ${1===a?"reply":"replies"}`:""}`,"",`**${Ne(g(r.root))}** (${Ce(r.root.at,n)}): ${De(r.root," ")}`),r.root.reactions.length&&l.push(`Reactions: ${qe(r.root)}`);for(let e of r.root.replies)l.push(`- **${Ne(g(e))}** (${Ce(e.at,n)}): ${De(e," ")} \x3c!-- comment:${e.id} --\x3e`),e.reactions.length&&l.push(` - Reactions: ${qe(e)}`);return l.join("\n")+"\n"}function ze(e){let{thread:t,location:n}=e,o=[Ne(n.where)+(n.quote?`, on the text "${Ne(n.quote)}"`:""),`${Ne(g(t.root))}: ${De(t.root," ")}`];t.root.reactions.length&&o.push(` Reactions: ${qe(t.root)}`);for(let e of t.root.replies)o.push(` ${Ne(g(e))}: ${De(e," ")}`),e.reactions.length&&o.push(` Reactions: ${qe(e)}`);return o.join("\n")+"\n"}function De(e,t){return e.deleted?"(deleted)":e.text.replace(/\r\n|\r|\n/g,"\n"+t)+(e.edited?" (edited)":"")}function Oe(e,t){return{markdown:Pe(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 Fe="0.8.0-beta.2",Ie="2026-10-15",Be=new Map,je=new Map,He=new Map,We={},Ke=e=>`${Be.get(e)??""}|${je.get(e)??""}`;function Ye(e,t={},...n){let o=document.createElement(e);for(let[e,n]of Object.entries(t))void 0===n||!1===n||("class"===e?o.className=String(n):o.setAttribute(e,!0===n?"":n));for(let e of n)null!=e&&!1!==e&&o.append(e);return o}function Ve(e,t){let n=e.getRootNode().activeElement;t&&n instanceof HTMLElement&&e.contains(n)&&n.blur(),e.inert=t}function Ue(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 _e=()=>{let e=window.getSelection();return e&&!e.isCollapsed&&e.toString().trim()?e:null};function Ge(e,t){return e.length>t?e.slice(0,t-1)+"\u2026":e}function Ze(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 Je=/\bhttps?:\/\/[^\s<>"'`]+/gi,Xe=/[\u202A-\u202E\u2066-\u2069]/;function Qe(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 et(e){let t=[],n=0;for(let o of e.matchAll(Je)){if(o[0].length>2048||Xe.test(o[0]))continue;let r,i=Qe(o[0]),a=o.index??0;try{let e=new URL(i);if("http:"!==e.protocol&&"https:"!==e.protocol)continue;r=e.href}catch{continue}a>n&&t.push(e.slice(n,a));let l=Ye("a",{href:r,target:"_blank",rel:"noopener noreferrer"},i);l.addEventListener("click",e=>e.stopPropagation()),t.push(l),n=a+i.length}return n<e.length&&t.push(e.slice(n)),t}var tt="http://www.w3.org/2000/svg",nt={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:["M4 20v-8a8 8 0 1 1 8 8z"],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"],close:["M6 6l12 12M18 6L6 18"],smile:["M12 3a9 9 0 1 0 0 18a9 9 0 0 0 0-18z","M8.6 14.2c1.9 2.1 4.9 2.1 6.8 0","M9.6 9.8a.6.6 0 1 1-1.2 0a.6.6 0 1 1 1.2 0M15.6 9.8a.6.6 0 1 1-1.2 0a.6.6 0 1 1 1.2 0"],edit:["M4 20h4L19 9l-4-4L4 16z"],hide:["M2.5 12S6 5.5 12 5.5 21.5 12 21.5 12 18 18.5 12 18.5 2.5 12 2.5 12z","M12 9.5a2.5 2.5 0 1 0 0 5a2.5 2.5 0 0 0 0-5z","M4 4l16 16"],more:["M5.5 12h.01M12 12h.01M18.5 12h.01"],look:["M12 3a9 9 0 1 0 0 18a9 9 0 0 0 0-18z","M12 3v18"]};function ot(e,t=15,n){let o=rt(nt[e],t);return n&&o.setAttribute("stroke-width",String(n)),o}function rt(e,t){let n=document.createElementNS(tt,"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(tt,"path");e.setAttribute("d",t),n.append(e)}return n}var it=(e,t,n)=>`M${e} ${t}a${n} ${n} 0 1 0 ${2*n} 0a${n} ${n} 0 1 0 -${2*n} 0`,at={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${it(7.4,11.5,1.9)}${it(12.8,11.5,1.9)}M11.3 14.6l.7 1 .7-1`,Bear:`${it(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:`${it(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 lt(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 st=(e,t)=>lt(t)||m(e);function dt(e,t){return w(t)?Ye("span",{class:"av ai","data-pipeup-ai":"","aria-hidden":"true"},"AI"):Ye("span",{class:`av c${f(e)}`,"aria-hidden":"true","data-animal":m(e)},lt(t)||rt([at[c[h(e)]]],24))}function ct(e,t){setTimeout(()=>{e.remove(),t?.()},320)}function ut(e){return requestAnimationFrame(()=>{e.offsetWidth,e.classList.add("in")}),e}var pt=/^[A-Za-z0-9_-]{43}$/,ht=/^(?:host|gh):[A-Za-z0-9._@-]{1,64}$/,ft=[],mt=new Set;function gt(e,t){let n=new Map,o=e=>{e.ref!==t&&!n.has(e.ref)&&n.set(e.ref,e)},r=e=>o({ref:e.author,name:g(e),...w(e.name)?{agent:!0}:{}});for(let t of e)for(let e of[t.root,...t.root.replies])if(!e.deleted){r(e);for(let t of e.reactions)for(let e of t.by)r({...e})}for(let e of(document.documentElement.getAttribute("data-pipeup-agents")??"").split(/[\s,]+/).filter(e=>pt.test(e)))o({ref:e,name:"AI agent",agent:!0});for(let e of ft)o(e);return[...n.values()].sort((e,t)=>e.name.localeCompare(t.name))}var vt=(e,t)=>!!e.mentions?.some(e=>t.includes(e.ref)),wt=[],yt=e=>[e,...wt],bt=null,xt=e=>{bt=e},kt="pu-source";function Et(e){let t=Ye("textarea",{class:"input",rows:"1","aria-label":e.label,placeholder:e.placeholder??""}),n=Ye("button",{class:"send",type:"button",inert:!0},e.label),o=Ye("button",{class:"cnl",type:"button"},"Cancel"),r=Ye("span",{class:"tools"});r.hidden=!0;let i=Ye("div",{class:"line"},t,r),a=Ye("div",{class:"row"},i,Ye("div",{class:"bts"},o,n)),l=e.kind??"comment",s=!1,d=new Set,c=()=>{for(let e of[...d])e()},u=()=>{let e=""!==t.value.trim();n.classList.toggle("show",e),a.classList.toggle("has",e),n.inert=!e,t.style.height="auto",t.style.height=`${Math.max(27,t.scrollHeight)}px`},p=()=>{let e=-1,n=0,o=(o,r)=>{e<0&&(e=t.selectionStart,n=0);let i=t.value.slice(0,e),a=o&&i&&!/\s$/.test(i)&&!/^\s/.test(o)?" ":"";t.setRangeText(a+o,e,e+n,"end"),n=a.length+o.length,r&&(e=-1),u()};return{update:e=>o(e,!1),commit:e=>o(e,!0),cancel:()=>{e>=0&&n&&t.setRangeText("",e,e+n,"end"),e=-1,n=0,u()}}},h=new Map,f=()=>{let n=(bt?.tools()??[]).filter(e=>!1!==e.available?.());for(let[e,t]of h)n.some(t=>t.id===e)||(t.remove(),h.delete(e));for(let o of n){if(h.has(o.id))continue;let n=Ye("button",{class:"ib tool",type:"button","aria-label":o.label,title:o.label,"aria-pressed":"false"},rt(o.icon,15));n.addEventListener("mousedown",e=>e.preventDefault()),n.addEventListener("click",r=>{r.stopPropagation();try{o.press({kind:l,thread:e.thread?.()??null,text:()=>t.value,focus:()=>t.focus({preventScroll:!0}),connected:()=>a.isConnected,setPressed:e=>n.setAttribute("aria-pressed",String(e)),dictate:p,onEnd:e=>(d.add(e),()=>d.delete(e))})}catch(e){globalThis.reportError?.(e)}}),h.set(o.id,n),r.append(n)}r.hidden=0===h.size};f(),a.addEventListener(kt,f);let m=[],g=Ye("ul",{class:"mnl",role:"listbox","aria-label":"People"}),v=Ye("span",{class:"mn-sr","aria-live":"polite"}),w=`mn-${Math.random().toString(36).slice(2,8)}`;g.id=w;let y=[],b=0,x=null;e.people&&(t.setAttribute("aria-autocomplete","list"),t.setAttribute("aria-haspopup","listbox"),t.setAttribute("aria-controls",w),a.append(g,v));let k=()=>{y=[],g.classList.remove("show"),t.removeAttribute("aria-activedescendant"),window.setTimeout(()=>!y.length&&g.replaceChildren(),220)},E=()=>{for(let[e,n]of[...g.children].entries()){let o=e===b;n.setAttribute("aria-selected",String(o)),n.classList.toggle("on",o),o&&t.setAttribute("aria-activedescendant",n.id)}},$=e=>{let n=y[e];if(!n||!x)return;let o=t.selectionStart;t.setRangeText(`@${n.name} `,x.start,o,"end"),m.push({label:n.name,ref:n.ref}),k(),u()},S=async()=>{let o=t.value.trim();if(o&&!s){s=!0;try{await e.D(o,m.length?function(e,t){let n=[];for(let o of t){let t=`@${o.label}`,r=0;for(;;){let i=e.indexOf(t,r);if(i<0)break;let a=i+t.length;if((0===i||/\s/.test(e[i-1]))&&(a===e.length||!/[\p{L}\p{N}_]/u.test(e[a]))&&!n.some(e=>i<e.end&&a>e.start)){n.push({start:i,end:a,ref:o.ref});break}r=i+1}}return n.sort((e,t)=>e.start-t.start).slice(0,20)}(o,m):[]),n.matches(":focus")&&t.focus(),t.value="",m.length=0,k(),u(),c()}catch{}finally{s=!1}}};i.addEventListener("mousedown",e=>{e.target===t||r.contains(e.target)||(e.preventDefault(),t.focus({preventScroll:!0}),t.setSelectionRange(t.value.length,t.value.length))}),t.addEventListener("input",()=>{u(),e.people&&(()=>{if(x=t.selectionStart===t.selectionEnd?function(e){let t=/(^|\s)@([^\s@]*(?:\s[^\s@]*)?)$/.exec(e);return t?{start:t.index+t[1].length,query:t[2]}:null}(t.value.slice(0,t.selectionStart)):null,y=x&&e.people?function(e,t){let n=t.trim().toLowerCase(),o=e.filter(e=>e.name.toLowerCase().startsWith(n)),r=n?e.filter(e=>!o.includes(e)&&e.name.toLowerCase().includes(n)):[];return[...o,...r].slice(0,8)}(e.people(),x.query):[],!y.length)return k();b=Math.min(b,y.length-1),g.replaceChildren(...y.map((e,t)=>{let n=Ye("li",{role:"option",id:`${w}-${t}`,class:e.agent?"agent":""},Ye("span",{},e.name),e.agent?Ye("small",{},"AI agent"):null);return n.addEventListener("mousedown",e=>{e.preventDefault(),$(t)}),n})),g.classList.add("show"),v.textContent=`${y.length} ${1===y.length?"person":"people"}`,E()})()}),t.addEventListener("blur",()=>y.length&&k()),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(),$(b);if("Escape"===e.key)return e.preventDefault(),k()}"Enter"!==e.key||e.shiftKey||e.isComposing?"Escape"===e.key&&(e.preventDefault(),L()):(e.preventDefault(),S())});let L=()=>{t.value="",u(),t.blur(),c(),e.B?.()};for(let e of[n,o])e.addEventListener("mousedown",e=>e.preventDefault());return n.addEventListener("click",e=>{e.stopPropagation(),S()}),o.addEventListener("click",e=>{e.stopPropagation(),L()}),e.value&&(t.value=e.value,queueMicrotask(u)),{element:a,input:t,focus:()=>t.focus({preventScroll:!0})}}var $t=["sync","menu","notify","note","composer","panel","styles","status","overlay","here","sign","listnote","reactions","identity","dialog"],St=/^[a-z][a-z0-9-]{1,23}$/,Lt=new Set(["local","file","page","user","pipeup","presence","sync"]),Mt=class{constructor(e,t,n){this.ctx=e,this.shadow=t,this.after=n,xt({tools:()=>this.j,note:()=>[...this.Q.values()].at(-1)??null})}Z=0;F=[];Q=new Map;writing=new Map;marked=new Map;paint=0;ee=new Map;listNotes=new Map;picker=null;pickerOwner="";j=[];te=new Set;q=new Set;W=new Set;Y=new Map;M=new Map;G=new Map;remote={n:0,who:new Set};last=0;timer=0;he="";subscribe(e){return this.W.add(e),()=>{this.W.delete(e)}}changed(e){e&&this.Z++;for(let t of[...this.W])t(e);for(let e of this.ctx.t.querySelectorAll(".row, .draft"))e.dispatchEvent(new Event(kt))}R(e,t){let n=this.G.get(e)??this.G.set(e,new Set).get(e),o=()=>{n.delete(o)&&t()};return n.add(o),o}ge(){return[...this.ee.values()].map(e=>e.text).join(" \xb7 ")}Ce(e,t){return this.F.push(t),this.changed(!0),{update:()=>this.changed(!1),remove:this.R(e,()=>{this.F.splice(this.F.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?(Be.delete(t),o.delete(t)):(Be.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(He.delete(t),!je.delete(t))return;r.delete(t)}else{if(je.get(t)===n&&!!He.get(t)==!!o)return;je.set(t,n),o?He.set(t,o):He.delete(t),r.add(t)}this.repaint()}repaint(){this.paint||(this.paint=window.requestAnimationFrame(()=>{this.paint=0,this.ctx.m()}))}ne(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)}Pe(e,t){return this.j.push(t),this.changed(!1),this.R(e,()=>{this.j.splice(this.j.indexOf(t),1),this.changed(!1)})}closed(){return this.ctx.state.hidden&&!this.ctx.state.l}Oe(e,t){this.closed()?this.M.set(e,t):this.ctx.oe(t)}flush(){if(this.closed()||0===this.M.size)return;let e=[...this.M.values()].at(-1);this.M.clear(),this.ctx.oe(e)}$e(){return this.shadow.activeElement instanceof HTMLTextAreaElement||[...this.ctx.t.querySelectorAll("textarea")].some(e=>""!==e.value.trim())}Re(e){this.ctx.state.hidden||this.ctx.S(e)}Ie(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.ve()}}ve(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.ve(1e3);let{n:e,who:t}=this.remote;this.remote={n:0,who:new Set},this.last=Date.now(),this.ctx.S(`${e} new comment${1===e?"":"s"} from ${1===t.size?[...t][0]:`${t.size} people`}`)},e))}Ne(e){let t=this.Y.get(e);return t||(t=Ye("div",{class:"ov","aria-hidden":"true","data-addon":e}),this.ctx.t.insertBefore(t,this.after.nextSibling),this.Y.set(e,t)),t}He(e,t){let n=this.ctx.host.ownerDocument.defaultView?.CSSStyleSheet,o=n&&"replaceSync"in n.prototype&&"adoptedStyleSheets"in this.shadow?new n:null;o&&(o.replaceSync(t),this.shadow.adoptedStyleSheets=[...this.shadow.adoptedStyleSheets,o]);let r=o??this.shadow.appendChild(Ye("style",{},t));return this.R(e,()=>o?this.shadow.adoptedStyleSheets=this.shadow.adoptedStyleSheets.filter(e=>e!==o):r.remove())}ye(e,t,n){return t.add(n),this.R(e,()=>t.delete(n))}De(e,t){return this.ye(e,this.te,t)}Be(e,t){let n=this.ye(e,this.q,t);return this.call(this.q,t,this.be()),n}be(){let{state:e}=this.ctx,t=this.shadow.activeElement;return{shown:!e.hidden,commentMode:e.p,allOpen:e.u,dark:this.ctx.t.classList.contains("dark"),view:this.ctx.f.view(),writing:t instanceof HTMLTextAreaElement?t.closest("[data-thread]")?.dataset.thread??"":null}}C(){for(let e of[...this.te])this.call(this.te,e);if(0===this.q.size)return;let e=this.be(),t=JSON.stringify(e);if(t!==this.he){this.he=t;for(let t of[...this.q])this.call(this.q,t,e)}}call(e,t,...n){try{t(...n)}catch(n){e.delete(t),globalThis.reportError?.(n)}}Fe(e,t,n){let o=this.ctx.t,r=this.shadow.activeElement,i=Ye("button",{class:"ib",type:"button","aria-label":"Close"},rt(["M6 6l12 12M18 6L6 18"],15)),a=Ye("div",{class:"xp",role:"dialog","aria-label":n.label,"data-addon":e},Ye("div",{class:"hd"},Ye("span",{},n.label),i),Ye("div",{class:"xb"},t)),l=[...o.children].filter(e=>e instanceof HTMLElement&&!e.inert);for(let e of l)e.inert=!0;o.append(a),a.offsetWidth,a.classList.add("show");let s=e=>{"Escape"===e.key&&(e.stopPropagation(),e.preventDefault(),d())},d=this.R(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.t.querySelector(".dlg")?.remove();let o=Ye("div",{class:"dlg",role:"dialog","aria-label":n},t),r=()=>{},i=()=>{o.classList.remove("show"),o.inert=!0,window.setTimeout(r,260)};return o.addEventListener("keydown",e=>{e.stopPropagation(),"Escape"===e.key&&(e.preventDefault(),i())}),this.ctx.t.append(o),o.offsetWidth,o.classList.add("show"),o.querySelector("textarea, button.primary, button")?.focus({preventScroll:!0}),r=this.R(e,()=>o.remove()),{close:i}}clear(e){for(let t of[...this.G.get(e)??[]])t();this.G.delete(e),this.Y.get(e)?.remove(),this.Y.delete(e);for(let t of[this.Q,this.ee,this.listNotes,this.M])t.delete(e);this.setPicker(e,null);for(let t of this.writing.get(e)??[])Be.delete(t);this.writing.delete(e);for(let t of this.marked.get(e)??[])je.delete(t),He.delete(t);this.marked.delete(e),this.repaint(),this.changed(!0)}destroy(){window.clearTimeout(this.timer),xt(null),this.W.clear()}},At=new Map,Ct=null,Tt=(()=>{let e=globalThis.Pipeup;return e?.VERSION?e:null})();function Pt(){return Tt?Tt.addons():[...At.values()].map(e=>({...e.info}))}function qt(e){if(Tt)return Tt.use(e);let t=e=>console.warn(`pipeup: ${e}`),n=e;if(!n||"object"!=typeof n||"string"!=typeof n.id||!St.test(n.id)||Lt.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(At.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=>!$t.includes(e));!function(e){let t=typeof document>"u"?null:document.documentElement.getAttribute("data-pipeup-addons");return null===t||t.toLowerCase().split(/[\s,]+/).includes(e)}(n.id)?(o.state="off",o.reason="this page doesn't allow it",t(`the add-on "${n.id}" is not in this page's data-pipeup-addons list, so it is off`)):1!==n.api?(o.state="off",o.reason=`needs add-on API ${String(n.api)}; this Pipeup has 1`):r&&(o.state="off",o.reason=`this Pipeup has no ${r} slot`);let i={addon:e,info:o};At.set(n.id,i),Ct?.i&&"waiting"===o.state&&Rt(i,Ct)}function Nt(){if(Tt)return!0;let e=globalThis,t=e.pipeupAddons;if(Array.isArray(t))for(let e of t)qt(e);else if(t&&"object"==typeof t&&t.push!==qt)return!1;return e.pipeupAddons={push:qt},!0}async function Rt(e,t){let n,o,{addon:r,info:i}=e,a=new AbortController,l=new Set,{surface:s,doc:d}=t,c=()=>!a.signal.aborted,u=Object.assign(()=>{},{update(){},remove(){},close(){}}),p=e=>(...t)=>c()?e(...t):u,h={id:d.id,me:d.me,get name(){return d.name},threads:()=>d.threads(),ops:()=>d.ops(),contacts:()=>d.contacts(),onChange:e=>{let t=d.onChange(e);return l.add(t),()=>{t(),l.delete(t)}}},f=r.id,m={api:1,version:t.version,document:h,root:t.root,ephemeral:t.ephemeral,signal:a.signal,has:e=>$t.includes(e),off:e=>{o=String(e)},merge:e=>c()?d.merge(e,f):Promise.resolve(0),addMenuItem:p(e=>s.Ce(f,e)),notify:p(e=>s.Oe(f,e)),announce:p(e=>s.Re(e)),setComposerNote:p(e=>s.ne(s.Q,f,e)),setThreadNote:p((e,t)=>s.setThread(f,e,t)),setThreadMark:p((e,t,n)=>s.setMark(f,e,t,n)),addComposerTool:p(e=>s.Pe(f,e)),openPanel:p((e,t)=>s.Fe(f,e,t)),addStyles:p(e=>s.He(f,e)),setStatus:p(e=>s.ne(s.ee,f,e)),setListNote:p(e=>s.ne(s.listNotes,f,e)),setReactionPicker:p(e=>s.setPicker(f,e)),overlay:()=>s.Ne(f),onFrame:p(e=>s.De(f,e)),where:e=>s.ctx.f.view(e),isHere:e=>s.ctx.f.w(e),go:e=>s.ctx.f.V(e),onUi:p(e=>s.Be(f,e)),avatar:(e,t)=>{let n=dt(e,t);return n.classList.add("in"),n},sign:(e,t)=>d.sign(`${f}/${e}`,t),identity:{portable:d.portable,seed:()=>d.seed(),use:async e=>{if("private"!==e.type||"Ed25519"!==e.algorithm.name||!e.extractable)throw new Error("pipeup: an identity is an extractable Ed25519 private key");let{x:n}=await crypto.subtle.exportKey("jwk",e);await t.onIdentity({publicKey:n,privateKey:e})},share:e=>d.contact(e).then(()=>!0,()=>!1),unshare:()=>d.uncontact()},openDialog:p((e,t)=>s.dialog(f,e,t))},g=()=>{if(c()){a.abort();for(let e of[...l])e();try{n?.()}catch(e){globalThis.reportError?.(e)}s.clear(f),"on"===i.state&&(i.state="waiting")}};e.stop=g;try{if(n=await r.setup(m),!c())return void n?.();if(void 0!==o)return g(),i.state="off",void(i.reason=o);i.state="on",delete i.reason}catch(e){i.state="failed",i.reason=function(e){return e instanceof Error?e.message:String(e)}(e),g(),i.state="failed",globalThis.reportError?.(e)}}var zt=typeof navigator<"u"&&/Mac|iP(hone|ad|od)/.test(navigator.platform)?"\u21e7\u2325C":"Shift+Alt+C",Dt=" ",Ot="Shift+Alt+C";var Ft=new WeakMap;function It(e,t){let n=Ft.get(t)??function(e){let t=Ye("button",{class:"me",type:"button",tabindex:"-1","aria-hidden":"true"});t.addEventListener("mousedown",e=>e.preventDefault());let n=Et({label:"Comment",placeholder:"Comment or add others with @",kind:"comment",D:e.D,B:e.B,people:e.people}),o=Ye("div",{class:"note"}),r=()=>{let e=bt?.note()??null;o.textContent=e??"",o.hidden=!e};r();let i=Ye("div",{class:"say"}),a=Ye("input",{class:"input",type:"text",maxlength:"80","aria-label":"Your name"}),l=Ye("div",{class:"nf"},a),s=Ye("div",{class:"you"},i,l),d="",c=!1,u=()=>{let n=e.name(),o=n?"change":"add your name";if(t.title=n?"Change your name":"Add your name",!t.lastChild||d!==n){let o=dt(e.me,n),r=t.lastChild;r?(ut(o),ct(r)):o.classList.add("in"),t.append(o),d=n}let r=Ye("button",{type:"button"},o);r.addEventListener("click",h),i.replaceChildren(Ye("span",{class:"nm"},n||`You're ${m(e.me)}`)," \xb7 ",r)},p=e=>{s.classList.toggle("naming",e),Ve(i,e),Ve(l,!e)};function h(t){t.stopPropagation(),a.value=e.name(),p(!0),a.focus({preventScroll:!0}),a.select()}let f=()=>{p(!1),n.focus()};t.addEventListener("click",h),a.addEventListener("keydown",t=>{if(t.stopPropagation(),"Escape"===t.key)t.preventDefault(),f();else if("Enter"===t.key){t.preventDefault();let n=a.value.trim();if(!n||n===e.name())return f();if(c)return;c=!0,e.rename(n).finally(()=>{c=!1,u(),f()})}}),u(),p(!1);let g=Ye("div",{class:"ctx"},e.label),v=Ye("div",{class:"draft"},Ye("div",{class:"hdr"},t,s),g,o,n.element);return v.addEventListener(kt,r),{element:v,re:()=>{let{selectionStart:e,selectionEnd:t}=n.input;return()=>{n.focus(),n.input.setSelectionRange(e,t)}},ie:e=>{g.hidden=e},se:e=>{g.textContent=e},focus:()=>n.focus(),qe:()=>""===n.input.value.trim()}}({label:t.label,me:e.doc.me,name:()=>e.l.name(),rename:t=>e.l.rename(t),D:(t,n)=>e.Ve(t,n),people:()=>e.people(),B:()=>e._e()});return Ft.set(t,n),e.I(n),n}function Bt(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};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 jt(e){return e.range?[...e.range.getClientRects()]:[]}function Ht(e,t){let n=jt(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 Wt(e,t){let n=jt(t).at(-1);if(n)return{x:n.left,y:n.bottom,below:!0,s:n};let o=Bt(e,t);if(!o)return null;let r=e.point?new DOMRect(o.x-12,o.y-12,24,24):t.element.getBoundingClientRect();return{...o,below:!1,s:r}}function Kt(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 Yt=()=>window.innerWidth>=900?400:300,Vt=()=>window.innerWidth<=480;function Ut(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=a+t.height<=n.height-o||l<o,d=s?a:l;return{above:!s,left:Math.max(o,Math.min(e.left,n.width-t.width-o)),top:Math.max(o,s?Math.min(d,n.height-t.height-o):d)}}function _t(e,t,n){let o=e.top-t.height-10;return o<8&&(o=e.top+e.height+10),{left:Math.max(8,Math.min(e.left+e.width/2-t.width/2,n.width-t.width-8)),top:o}}function Gt(e,t){let n=e.resolved.get(t.id);return n?.range?.startContainer??n?.element??null}var Zt=e=>(t,n)=>{let o=Gt(e,t),r=Gt(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},Jt=["\u{1f44d}","\u2764\ufe0f","\u{1f602}","\u{1f389}","\u{1f62e}","\u{1f64f}"],Xt={"\u{1f44d}":"Thumbs up","\u2764\ufe0f":"Heart","\u{1f602}":"Laughing","\u{1f389}":"Party popper","\u{1f62e}":"Surprised","\u{1f64f}":"Thanks"};var Qt=e=>`${e} ${1===e?"reply":"replies"}`,en=e=>e.root.replies.filter(e=>!e.deleted);function tn(e,t,n){let o={...n},r="card"===o._,i=e.id,a=Ye("div",{class:"rbox always"},Ye("div",{},Et({label:"Reply",placeholder:"Reply or add others with @",kind:"reply",thread:()=>i,people:()=>t.people(),D:(e,n)=>t.reply(i,e,n),B:t.close}).element)),l=Ye("div",{}),s=Ye("span",{class:"note"},"This thread was resolved. Your words are kept until you send or clear them.");s.hidden=!0,a.prepend(s);let d=Ye("div",{}),c=null,u=null,p=null,h="",f=Ye("div",{},d,r?null:Ye("div",{class:"more"},l)),m=new Set,y="",b="",x=null,k=new Set,E=e,$=new Map,S=new Map,L=new Map,M=(e,t,n)=>{let o=Ye("button",{class:"ib",type:"button","aria-label":t,title:t},ot(e,18,"more"===e?2.6:void 0));return o.addEventListener("click",e=>{e.stopPropagation(),n()}),o};function A(e,n={}){Object.assign(o,n),i=e.id,E=e;let C=(o.now??Date.now)(),T=en(e),P=T.length,q=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||Xe.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 et(e);let o=t.slice(0,4).map(e=>{let t=e.to.startsWith("slide:"),n=e.label||(t?`Slide ${e.to.slice(6)}`:`[${e.n}]`),o=[t?Ye("i",{class:"sl"}):null,Ye("span",{},t||""===e.label?n:`[${e.n}] ${n}`),e.says?Ye("span",{class:"rc",role:"tooltip"},e.says):null];if(/^https?:/.test(e.to)){let t=Ye("a",{class:"ref",href:e.to,target:"_blank",rel:"noopener noreferrer",title:e.says?void 0:e.to},...o);return t.addEventListener("click",e=>e.stopPropagation()),t}let r=Ye("button",{class:"ref",type:"button",title:e.says?void 0:t?n:`Show where: ${n}`},...o);return r.addEventListener("click",t=>{t.stopPropagation(),We.go?.(e.to)}),r});return[...et(n),Ye("div",{class:"refs"},...o)]}(t):et(t);if(!e.mentions?.length)return n(e.text);let o=[],r=0;for(let i of e.mentions)i.start<r||(o.push(...n(e.text.slice(r,i.start))),o.push(Ye("span",{class:vt(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))]},N=n=>function(e,t){if(e.deleted||(t.bare||!e.reactions.length)&&!t.quick)return null;let n=n=>e.reactions.find(e=>e.emoji===n)?.by.some(e=>e.author===t.me)??!1,o=(t.bare?[]:e.reactions).map(o=>{let r=n(o.emoji),i=o.by.length,a=[...r?["You"]:[],...o.by.filter(e=>e.author!==t.me).map(e=>g(e))],l=`${e.id}|${o.emoji}`,s=Ye("button",{class:`ref rx${r?" mine":""}${t.seen.has(l)?"":" new"}`,type:"button","aria-pressed":String(r),"aria-label":`${t.picker?.name(o.emoji)??Xt[o.emoji]??"Reaction"}, ${i} ${1===i?"person":"people"}${r?", including you":""}`},Ye("span",{},o.emoji),Ye("span",{class:"n"},String(i)),Ye("span",{class:"rc"},a.join(", ")));return t.seen.add(l),s.disabled=t.resolved,s.addEventListener("click",e=>{e.stopPropagation(),t.react(o.emoji,!r)}),s}),r=t.quick&&!t.resolved?Ye("div",{class:"rxq"+(t.seen.has(`${e.id}|quick`)?"":" new"),role:"group","aria-label":"React"},...Jt.map(e=>{let o=Ye("button",{class:"rxo",type:"button","aria-label":Xt[e],"aria-pressed":String(n(e))},e);return o.addEventListener("click",o=>{o.stopPropagation(),t.react(e,!n(e))}),o}),t.picker?function(e,t){let n=Ye("button",{class:"rxo",type:"button","aria-label":"More reactions","aria-haspopup":"dialog"},"\u2026");return n.addEventListener("click",o=>{o.stopPropagation(),function(e,t,n){let o=e.closest(".layer");if(!o)return;o.querySelector(".rxp")?.remove();let r=e.getBoundingClientRect(),i=Math.max(8,Math.min(r.left,window.innerWidth-320-8)),a=r.bottom+6+340<=window.innerHeight-8?r.bottom+6:Math.max(8,r.top-340-6),l=Ye("div",{class:"rxp",role:"dialog","aria-label":"Choose a reaction"});l.style.cssText=`left:${i}px;top:${a}px`;let s=!1,d={},c=e=>{e.composedPath().includes(l)||u()},u=()=>{s||(s=!0,window.removeEventListener("pointerdown",c,!0),d.off?.(),l.classList.remove("show"),l.inert=!0,window.setTimeout(()=>l.remove(),260),e.focus({preventScroll:!0}))};l.addEventListener("keydown",e=>{"Escape"===e.key&&(e.stopPropagation(),e.preventDefault(),u())}),d.off=t.fill(l,e=>{u(),n(e)}),window.addEventListener("pointerdown",c,!0),o.append(l),l.offsetWidth,l.classList.add("show"),l.querySelector("input,button")?.focus({preventScroll:!0})}(n,e,t)}),n}(t.picker,e=>t.react(e,!n(e))):null):null;return r?t.seen.add(`${e.id}|quick`):t.seen.delete(`${e.id}|quick`),Ye("div",{class:"refs rxs"},...o,r)}(n,{me:t.me,picker:t.picker(),resolved:e.resolved,quick:m.has(n.id),bare:r,seen:k,react:(e,o)=>{m.delete(n.id),t.react(n.id,e,o),A(E)}}),R=e.resolved?"Resolved"+(P?` \xb7 ${Qt(P)}`:""):e.addressed?"Addressed"+(P?` \xb7 ${Qt(P)}`:""):P?Qt(P):"",z=(n,o)=>{let r=((n,o)=>{let r=[];return o&&r.push(["Copy thread",()=>t.copy(e.id)]),(e=>e.author===t.me&&!e.deleted)(n)&&r.push(["Edit",()=>function(e){let n=()=>{x=null,A(E)},o=Et({label:"Save",kind:"comment",value:e.text,people:()=>t.people(),D:async(o,r)=>{await t.edit(e.id,o,r),n()},B:n});x={id:e.id,e:Ye("div",{class:"edit"},o.element)},queueMicrotask(()=>o.focus())}(n)],[b===n.id?"Delete for everyone":"Delete",()=>{b===n.id?(b=y="",t.remove(n.id)):b=n.id}]),r.length?Ye("div",{class:"pm",role:"menu"},...r.map(([e,t],n)=>{let o=Ye("button",{type:"button",role:"menuitem",class:"Delete for everyone"===e?"dl":""},e);return o.addEventListener("click",o=>{o.stopPropagation(),"Delete"!==e&&(y=""),t(),A(E),f.querySelectorAll(".pm button")[n]?.focus()}),o})):null})(n,o),i=r?M("more","More",()=>{y=y===n.id?"":n.id,b="",A(E),f.querySelector(y?".pm button":`[data-c="${n.id}"]`)?.focus()}):null;return i&&(i.setAttribute("aria-expanded",String(y===n.id)),i.dataset.c=n.id),Ye("div",{class:"hdr"},...(e=>{let t=st(e.author,e.name),n=$.get(e.id),o=n?.e;if((!o||n.key!==t)&&(o=ut(dt(e.author,e.name)),n)){let t=n.e;L.set(e.id,t),ct(t,()=>L.get(e.id)===t&&L.delete(e.id))}o.title=g(e),S.set(e.id,{key:t,e:o});let r=L.get(e.id);return r?[r,o]:[o]})(n),Ye("span",{class:"who"},g(n)),Ye("span",{class:"ago",title:new Date(n.at).toLocaleString()},Ce(n.at,C)),Ye("span",{class:"acts"},(t=>e.resolved||t.deleted?null:M("smile","React",()=>{m.delete(t.id)||m.add(t.id),A(E)}))(n),o?e.resolved?M("reopen","Reopen",()=>{t.reopen(e.id)}):M("resolve","Resolve",()=>{t.resolve(e.id)}):null,i),y===n.id?r:null)},D=e=>x?.id===e.id?x.e:(e=>Ye("div",{class:e.deleted?"tx del":"tx"},...e.deleted?["Deleted"]:[...q(e),e.edited?" (edited)":""]))(e),O=o.note?o.note:o.lost?`${o.place||"No longer on the page"} \u2014 it read \u201c${Ge(o.lost,120)}\u201d`:o.quote?`\u201c${Ge(o.quote,80)}\u201d`:"",F=r?o.rest:"column"===o._&&R;S=new Map;let I=Ye("div",{class:"root"},z(e.root,!0),O?Ye("div",{class:"ctx"},O):null,D(e.root),N(e.root),F?Ye("div",{class:"rest"},F):null);if(d.replaceWith(I),d=I,f.className=e.resolved?"thread resolved":"thread",f.setAttribute("data-thread",e.id),r)return void($=S);c?.remove();let B=Be.get(e.id);c=P||void 0!==B?Ye("div",{class:"rps"},...T.map(e=>Ye("div",{class:"it"},z(e,!1),D(e),N(e))),void 0===B?null:Ye("div",{class:"it ghost","data-pipeup-writing":"row"},Ye("div",{class:"hdr"},dt("",v),Ye("span",{class:"who"},v),Ye("span",{class:"ago"},"writing now")),Ye("div",{class:"tx","data-pipeup-writing":"words"},B))):null,c&&l.prepend(c);let j=e.addressed&&!e.resolved?e.addressed:null,H=j?`${j.text}|${j.author}|${j.at}`:"";if(H!==h&&(p?.remove(),p=null,h=H,j)){let n=(e,t)=>{let n=Ye("button",{type:"button"},e);return n.addEventListener("click",e=>{e.stopPropagation(),t()}),n};p=Ye("div",{class:"adr"},Ye("small",{},`Addressed \xb7 ${g(j)} \xb7 ${Ce(j.at,C)}`),j.text,Ye("div",{class:"go"},n("Resolve",()=>{t.resolve(e.id)}),n("Still not right",()=>{t.notRight(e.id)})))}p&&l.insertBefore(p,u??(a.parentNode===l?a:null)),u?.remove();let W=je.get(e.id),K=He.get(e.id);if(u=void 0===W?null:Ye("div",{class:"seen"},Ye("i"),W),u&&K){let e=Ye("button",{type:"button"},"Check again");e.addEventListener("click",e=>{e.stopPropagation(),K()}),u.append(e)}u&&l.insertBefore(u,a.parentNode===l?a:null),$=S;let Y=""!==a.querySelector("textarea").value.trim();s.hidden=!(e.resolved&&Y),e.resolved&&!Y?a.remove():a.parentNode!==l&&l.append(a)}return f.addEventListener("focusout",e=>{f.contains(e.relatedTarget)||setTimeout(()=>{y&&!f.contains(f.getRootNode().activeElement)&&(y=b="",A(E))})}),A(e),{element:f,update:A}}function nn(e,t){let n=new Map,o=Ye("div",{class:"tip",role:"tooltip"}),r=Ye("div",{class:"mark"}),i=Ye("div",{class:"pop",role:"dialog","aria-label":"Comment thread"});o.inert=i.inert=!0,e.t.append(r,o,i);let a,l=Ye("div",{class:"bub pin ghost","aria-hidden":"true"}),s=[],d=null,c=null,u=null,p=!0===window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,h=0,f=null,m=null,v=null,w=0,y=e=>s.find(t=>t.id===e)??null,b=()=>t.ae||e.state.u,x=!1,k=t=>{let n=e.resolved.get(t.id);return n?Wt(t.anchor,n):null};function E(t,n,o){let{left:r,top:i}=function(e,t,n,o=12){let r,i;if(e.below)r=Math.min(e.x,n.width-t.width-o),i=e.y+8,i+t.height>n.height-o&&(i=e.y-t.height-40);else{if(r=e.x+14,r+t.width>n.width-o)return Ut(e.s,t,n,o,0);i=Math.min(e.y-12,n.height-t.height-o)}return{left:Math.max(o,r),top:Math.max(o,i)}}(n,{width:t.offsetWidth||o,height:t.offsetHeight},function(e){let t=window.innerWidth;return{width:e&&!Vt()?t-320:t,height:window.innerHeight}}(e.state.u));t.style.left=`${r}px`,t.style.top=`${i}px`}function $(t){let n=t&&b()&&e.state.i!==t?y(t):null,r=n?k(n):null;if(!n||!r)return v=null,o.classList.remove("show"),void Ve(o,!0);if(v!==n.id){let e=en(n).length;o.replaceChildren(Ye("div",{class:"tx clamp"},...n.root.deleted?["Deleted"]:et(n.root.text)),Ye("div",{class:"who"},`${g(n.root)}${e?` \xb7 ${e} ${1===e?"reply":"replies"}`:""}`)),v=n.id}E(o,r,260),o.classList.contains("show")||o.offsetWidth,o.classList.add("show"),o.inert=!1}function S(t){f=t,$(t),e.E(t)}function L(e){window.clearTimeout(w),null===e?w=window.setTimeout(()=>S(null),b()?400:0):S(e)}function M(t){let o=n.get(t.id);if(o)return o;let i=Ye("button",{class:"bub",type:"button","data-thread":t.id});return i.addEventListener("mouseenter",()=>L(t.id)),i.addEventListener("mouseleave",()=>L(null)),i.addEventListener("click",n=>{n.stopPropagation(),$(null),e.open(t.id)}),e.t.insertBefore(i,r),n.set(t.id,i),i}o.addEventListener("mouseenter",()=>window.clearTimeout(w)),o.addEventListener("mouseleave",()=>L(null)),o.addEventListener("click",t=>{t.stopPropagation();let n=v;n&&(window.clearTimeout(w),S(null),e.open(n))});let A=!1;function C(){let t=e.state.o,n=u&&t&&!t.anchor.quote&&!t.anchor.point?t.resolved.element:null;if(n){let{left:e,top:t,above:o}=Ut(n.getBoundingClientRect(),{width:i.offsetWidth||Yt(),height:i.offsetHeight},{width:window.innerWidth,height:window.innerHeight}),r=null!==u?.above&&u?.above!==o;if(u&&(u.above=o),r&&P())return;return i.style.left=`${e}px`,void(i.style.top=`${t}px`)}let o=u&&t?Wt(t.anchor,t.resolved):d?k(d):null;o&&E(i,o,Yt())}let T=t=>e.state.p&&!t.anchor.quote&&!t.anchor.point;function P(e=()=>{}){return window.clearTimeout(h),p?(i.classList.remove("show"),h=window.setTimeout(()=>{e(),C(),i.classList.add("show")},220),!0):(e(),i.classList.add("glide"),h=window.setTimeout(()=>i.classList.remove("glide"),450),!1)}let q=t=>{if(e.T(t)){let e=t.composedPath()[0];return null!==m&&!(e instanceof Element&&e.closest(".tip,.bub"))&&L(null),void(m=null)}let n=e.le(t.clientX,t.clientY)?.id??null;n!==m&&(m=n,L(n))},N=t=>{if(e.T(t))return;let n=window.getSelection();if(n&&!n.isCollapsed||(e.state.p&&!e.state.paused?t.altKey:t.target instanceof Element&&t.target.closest("a,button,input,select,textarea,label,summary,[role=button],[contenteditable]")))return;let o=e.le(t.clientX,t.clientY);o&&(e.we(t),$(null),e.open(o.id))};return window.addEventListener("pointermove",q,{capture:!0,passive:!0}),window.addEventListener("click",N,!0),{m:function(o){s=o;let l=new Set;for(let t of o){if(!e.K(t)||t.anchor.quote)continue;let n=e.resolved.get(t.id);if(!n||"orphaned"===n.state)continue;l.add(t.id);let o=M(t);o.classList.toggle("done",t.resolved),o.classList.toggle("on",e.state.i===t.id),o.classList.toggle("pin",void 0!==t.anchor.point);let r=`Comment on ${$e(n.element)}: ${Ge(t.root.text,60)}`;o.getAttribute("aria-label")!==r&&o.setAttribute("aria-label",r)}Ue(e.t,o.filter(e=>l.has(e.id)).sort(Zt(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));$(f),x!==e.state.u&&i.classList.contains("show")&&!p&&P(),x=e.state.u;let m=t.ae&&!e.state.u?e.state.o:null;if(m){let t=m.anchor.point??m.resolved.element;u?.of!==m?(window.clearTimeout(h),i.classList.remove("glide"),u={s:It(e,m),of:m,at:t,above:null},u.s.ie(T(m)),i.replaceChildren(u.s.element),i.inert=!1,u.s.focus(),d=null,c=null,C(),i.classList.add("show")):u&&(u.at!==t&&(u.at=t,u.above=null,P(()=>u?.s.se(m.label))),u.s.ie(T(m)));let n=!e.f.w(m.anchor.view);return void(n!==A&&(A=n,i.classList.toggle("show",!n),i.inert=n,n||C()))}u&&(window.clearTimeout(h),i.classList.remove("glide"),u=null,A=!1,e.I(null));let g=b()&&!e.state.u&&e.state.i?y(e.state.i):null;if(!g||!e.K(g))return d=null,c=null,i.classList.remove("show"),void Ve(i,!0);let v=g.anchor.quote?.exact??null;d&&c&&d.id===g.id?(d!==g||a!==Ke(g.id))&&(c.update(g,{quote:v}),d=g,a=Ke(g.id)):(c=tn(g,e.N,{_:"popover",quote:v}),i.replaceChildren(c.element),d=g,a=Ke(g.id),C(),i.classList.add("show"),i.inert=!1)},C:function(){for(let[t,o]of n){let n=y(t),r=e.resolved.get(t),i=n&&r?Bt(n.anchor,r):null;!i||i.y<-40||i.y>window.innerHeight+40?o.style.visibility="hidden":(o.style.visibility="",o.style.left=`${i.x}px`,o.style.top=`${i.y}px`,o.classList.contains("in")||(o.offsetWidth,o.classList.add("in")))}let t=e.state.o,o=t?.anchor.point&&e.f.w(t.anchor.view)?Bt(t.anchor,t.resolved):null;o?(l.style.left=`${o.x}px`,l.style.top=`${o.y}px`,l.classList.contains("in")||(e.t.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")&&C();let a=function(){if(!b())return null;let t=e.state.o;return t?t.anchor.quote||t.anchor.point||e.state.p?null:t.resolved.element:!d||d.anchor.quote||d.anchor.point?null:e.resolved.get(d.id)?.element??null}();r.classList.toggle("show",null!==a),a&&Ze(r,a.getBoundingClientRect(),4)},destroy(){window.clearTimeout(w),window.clearTimeout(h),window.removeEventListener("pointermove",q,!0),window.removeEventListener("click",N,!0),e.I(null);for(let e of n.values())e.remove();l.remove(),o.remove(),r.remove(),i.remove()}}}var on={display:"block",position:"static",clips:!1,off:!1},rn=["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",..."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}]`)].join(","),an="a,button,label,summary,[role=button],[role=link],[role=tab],[role=option],[role=menuitem]",ln=`${an},input,select,textarea,img,svg,canvas,video,picture,[role=img]`,sn=(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 dn(e,t){let n=t.s(e);if(n.width<2||n.height<2)return!1;if(e.hasAttribute("data-pipeup-id"))return!0;let o=t.de();return n.width*n.height<=.6*o.width*o.height&&(e.matches(rn)||t.Ke(e)||e.childElementCount>1&&!e.parentElement?.closest(an)&&t.ze(e))}function cn(e,t,n){if(e===t||!t.contains(e)||e.closest("[data-pipeup-ignore]"))return null;let o=null;for(let r=e;r&&r!==t&&!o;r=r.parentElement)dn(r,n)&&(o=r);if(!o||o.hasAttribute("data-pipeup-id"))return o;let r=n.s(o);for(let e=o.parentElement;e&&e!==t&&sn(n.s(e),r);e=e.parentElement)if(e.hasAttribute("data-pipeup-id"))return e;return o}function un(e,t,n){let o=n.s(e);for(let r=e.parentElement;r&&r!==t;){let e=cn(r,t,n);if(!e)return null;if(!sn(n.s(e),o))return e;r=e.parentElement}return null}var pn=(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,hn=(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 fn(e,t,n=()=>!0){let o=[],r=(e,i,a,l,s,d)=>{for(let c of e.children){if(c.hasAttribute("data-pipeup-ignore")||"true"===c.getAttribute("aria-hidden")||!n(c))continue;let e=t.flow?.(c)??on,u=c.offsetParent,p="fixed"===e.position||"absolute"===e.position&&!!l&&!(u&&l.contains(u)),h=p?null:a,f=t.s(c),m=f.width>0&&f.height>0;if(h&&m&&!pn(f,h))continue;let g=c.matches(an),v=(e.display.startsWith("inline")||d)&&!c.matches(ln)&&("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))&&dn(c,t)&&(i&&sn(t.s(i.e),f)?(c.hasAttribute("data-pipeup-id")||!i.e.hasAttribute("data-pipeup-id"))&&(i.e=c):o.push(y={e:c,H:i,L:0}));let b=e.clips&&m;r(c,y,b?h?hn(h,f):f:h,b?c:p?null:l,s||g,/^inline-(flex|grid)$/.test(e.display)||d&&/(flex|grid)$/.test(e.display))}};r(e,null,null,null,!1,!1);for(let e=o.length-1;e>=0;e--){let t=o[e];t.H&&(t.H.L=Math.max(t.H.L,t.L+1))}return o}var mn=(e,t)=>e.filter(e=>e.L<=t&&(!e.H||e.H.L>t)),gn="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=`${gn},input,select,textarea,[contenteditable]:not([contenteditable=false]),[tabindex]:not([tabindex="-1"])`,wn=["click","dblclick","auxclick","submit","contextmenu","dragstart"],yn=[...["over","out","enter","leave","down","up"].flatMap(e=>[`pointer${e}`,`mouse${e}`]),"mousemove","touchstart","touchmove","touchend","touchcancel"],bn="Tab moves between blocks \xb7 \u2191 \u2193 change level \xb7 Enter comments \xb7 Esc to finish \xb7 F7 selects text";function xn(e){let t={s:e=>e.getBoundingClientRect(),Ke: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},ze: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}},de:()=>({width:innerWidth,height:innerHeight})},n=Ye("span",{hidden:!0},bn),o=Ye("div",{class:"pick"},n),r=[0,1].map(()=>{let e=Ye("div",{class:"km",tabindex:"-1",role:"button"},Ye("span",{hidden:!0}),Ye("span",{hidden:!0}));return e.inert=!0,e.addEventListener("keydown",me),e.addEventListener("click",e=>{e.stopPropagation(),fe()}),e.addEventListener("focus",()=>o.classList.add("kf")),e.addEventListener("blur",()=>o.classList.remove("kf")),e}),i=Ye("span",{class:"lbl"}),a=(e,t,n,o)=>{let r=Ye("button",{class:"nb",type:"button","aria-label":e,title:t},ot(n,16));return r.addEventListener("click",e=>{e.stopPropagation(),o()}),r},l=a("Around it","Select the block around it","expand",ue),s=a("Inside it","Select a block inside it","shrink",pe),d=a("Pin","Pin its centre","pin",()=>e.xe(()=>H(f??x,{x:.5,y:.5}))),c=Ye("div",{class:"namebar",role:"group","aria-label":"Chosen block"},i,l,s,d);c.inert=!0;let u=e.t.querySelector(".launch");for(let t of[o,...r,c])e.t.insertBefore(t,u);c.addEventListener("mousedown",e=>e.preventDefault());let p=!0===window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,h=null,f=null,m=null,g=null,v=0,w=()=>{},y=null,b=()=>{},x=null,k=0,E=0,$=!1,S=null,L=null,M=null,A=0,C=-1,T=!0,P=null,q=null,N=t=>!(e.T(t)||t.target instanceof Element&&t.target.closest("[data-pipeup-ignore]"));function R(){g&&(o.classList.toggle("glide",performance.now()<v),Ze(o,g.getBoundingClientRect(),4))}function z(){if(!y)return;c.classList.toggle("glide",performance.now()<v&&c.classList.contains("show"));let{left:e,top:t}=_t(y.getBoundingClientRect(),{width:c.offsetWidth||200,height:c.offsetHeight||34},{width:window.innerWidth,height:window.innerHeight});c.style.left=`${e}px`,c.style.top=`${t}px`}function D(e,t){g=e,v=t?performance.now()+400:0,R(),o.classList.add("show")}function O(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 F(e){if(e!==h){if(h=e,w(),!e)return void o.classList.remove("show");"0"===getComputedStyle(o).opacity?D(e,!1):p?(o.classList.remove("show"),w=O(o,()=>D(e,!1))):D(e,!0)}}function I(e){f=e,o.classList.toggle("on",null!==e),F(e),B(e)}function B(e){b(),c.inert=!e,e?p?(c.classList.remove("show"),b=O(c,()=>j(e))):j(e):(c.classList.remove("show"),y=null)}function j(n){i.textContent=i.title=$e(n),l.hidden=null===un(n,e.root,t),s.hidden=0===(x?de(n).length:fn(n,t,te).length);let o=c.classList.contains("show");y=n,z(),o||(c.offsetWidth,c.classList.add("show"))}function H(t,n){let o;try{o=he(t,e.root,n,e.f.view(t))}catch(t){return void e.X(t)}let r={anchor:o,label:n?`Pin on ${$e(t).replace(/^[A-Z](?=[a-z])/,e=>e.toLowerCase())}`:$e(t),ranges:[],resolved:{state:"attached",element:t,range:null}},i=e.state.o;x&&(x=t,C=-1),I(n?null:t),m=i??r,e.Ue(r),e.S(n?r.label:`Commenting on ${r.label}`)}function W(t){e.xe(()=>H(t))}function K(t){e.state.paused!==t&&(e.state.paused=t,t&&!f&&F(null),e.m())}let Y=!1,V=()=>Y=!1,U=n=>{if(e.T(n)||e.state.paused)return;if(!N(n))return void(f||F(null));if(n.stopPropagation(),f||e.state.o)return;let o=!_e()&&n.target instanceof Element?cn(n.target,e.root,t):null;if(x){if(!o||o===x||(A+=Math.abs(n.movementX)+Math.abs(n.movementY),A<=4))return;se()}o&&(S=o),F(o)},_=()=>{_e()&&(x&&se(),f||F(null))},G=t=>{!N(t)||e.state.paused||(t.stopPropagation(),("pointerdown"===t.type||"mousedown"===t.type)&&t.target instanceof Element&&t.target.closest(vn)&&t.preventDefault())},Z=n=>{if(!N(n)||e.state.paused)return;let o=n.target;!(o===q||o.form&&o.form===q?.form)||"submit"!==n.type&&("click"!==n.type||n.detail)?(n.preventDefault(),n.stopPropagation(),"click"===n.type&&!e.state.l&&!e.je(n)&&function(n){let o=window.getSelection();if(o&&!o.isCollapsed)return;if(e.state.o&&(n.altKey||!e.$()))return void e.z();if(!n.altKey&&e.le(n.clientX,n.clientY))return;if(e.state.i&&e.open(null),x&&n.detail&&se(),n.altKey)return void function(n){let o=(n.target instanceof Element?cn(n.target,e.root,t):null)??e.root;o!==e.root&&(S=o);let r=o.getBoundingClientRect();r.width&&r.height&&H(o,{x:(n.clientX-r.left)/r.width,y:(n.clientY-r.top)/r.height})}(n);let r=n.target instanceof Element?cn(n.target,e.root,t):null;r&&(S=r),r?H(r):(e.z(),I(null))}(n)):q="click"===n.type&&"submit"===o.type?o.form:null},J=t=>{if(t.key!==Dt&&(Y=!0),(e=>{if(e.key!==Dt||e.ctrlKey||e.metaKey||e.altKey||e.isComposing)return!1;let t=e.composedPath()[0];if(r.some(e=>e===t))return!0;let n=t instanceof Element?t.closest(vn):null;return!n||!Y&&!n.matches("input,textarea,select,[contenteditable]:not([contenteditable=false])")})(t)||t.key===Dt&&e.state.paused)return t.repeat||K(!0),t.preventDefault(),void t.stopPropagation();if(q=null,ve="","Tab"===t.key&&X(t))return t.preventDefault(),t.stopPropagation(),ve=t.key,e.z(),e.state.i&&e.open(null),e.state.l&&(e.state.l=!1,e.m()),function(t){if(x)return ce(t);P=null;let n=document.activeElement;L=Q()??n;let o,r=S?.isConnected?S:null,i=r&&oe(r);if(i){k=i.L;let e=mn(ne(),k),n=e.indexOf(i);o=e[(n+t+e.length)%e.length]}else if(r){k=0;let e=mn(ne(),0),n=e=>0!==(r.compareDocumentPosition(e.e)&Node.DOCUMENT_POSITION_FOLLOWING),i=e=>e.e.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=ie(),o&&(k=o.L);if(!o)return e.S("Nothing here to comment on");$=!0,le(o.e)}(t.shiftKey?-1:1);if(N(t)&&t.target instanceof Element)if("Enter"!==t.key&&" "!==t.key||!t.target.closest(gn))"Enter"===t.key&&!x&&t.target.form&&(q=t.target);else{if(!x)return void(q=t.target);t.preventDefault(),t.stopPropagation()}},X=t=>{if(t.ctrlKey||t.metaKey||t.altKey||t.isComposing)return!1;let n=t.composedPath()[0];return n instanceof Element&&!r.some(e=>e===n)&&(e.T(t)?!!n.closest(".launch,.menu")&&!n.closest("input,textarea,select,[contenteditable]"):!t.composedPath().some(e=>e instanceof Element&&e.hasAttribute("data-pipeup-ignore")))},Q=()=>e.t.getRootNode().activeElement,ee=()=>r.some(e=>e===Q()),te=t=>(!1!==t.checkVisibility?.({opacityProperty:!0,visibilityProperty:!0})||"contents"===getComputedStyle(t).display)&&e.f.w(e.f.view(t)),ne=()=>(P?.some(e=>!e.e.isConnected)&&(P=null),P??=fn(e.root,t,te)),oe=e=>ne().find(t=>t.e===e),re=(e,t=!1)=>{let n=e.getBoundingClientRect();return n.bottom>0&&n.top<window.innerHeight&&(!t||n.top>=0)},ie=()=>{let e=mn(ne(),0);return e.find(e=>re(e.e,!0))??e.find(e=>re(e.e))??e[0]},ae=t=>e.doc.threads().filter(n=>e.K(n)&&t.contains(Gt(e,n))).sort(Zt(e));function le(t,o=!0){A=0;let i=ne(),a=i.find(e=>e.e===t);if(a&&!mn(i,k).includes(a)&&(k=a.L),t!==x&&(C=-1),t!==f&&(f=null),x=t,F(t),B(t),t.scrollIntoView({block:"nearest",inline:"nearest",behavior:p?"auto":"smooth"}),!o)return;e.We();let l=r[E^=1];(function(e,t){let[o,r]=e.children,i=mn(ne(),k),a=ae(t).length;o.textContent=`${ke(t)}, ${i.findIndex(e=>e.e===t)+1} of ${i.length}${a?`, has ${a} comment${1===a?"":"s"}`:""}`;let l=(t.innerText??t.textContent??"").length<=150;r.textContent=Ee(t);let s=T?[n]:[];T=!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),Ze(l,t.getBoundingClientRect(),4),l.inert=!1,l.focus({preventScroll:!0}),r[1^E].inert=!0}function se(){let e=ee();S=x,x=null,F(null),B(null);for(let e of r)Ve(e,!0);return e}function de(e){let t=oe(e);return t?((e,t)=>e.filter(e=>e.H===t))(ne(),t):[]}function ce(e){let t=mn(ne(),k),n=t.findIndex(e=>e.e===x),o=t[n<0?e>0?0:t.length-1:(n+e+t.length)%t.length];o&&le(o.e)}function ue(){let n=f??x,o=n&&un(n,e.root,t);return o?((!M||!n.contains(M))&&(M=n),f?W(o):void le(o)):e.S("Nothing around it")}function pe(){let t=f??x,n=t?de(t):[],o=n.find(e=>M&&e.e.contains(M))??n.find(e=>re(e.e))??n[0];if(!o)return e.S("Nothing inside it");f?W(o.e):le(o.e)}function fe(t=!1){if(!x)return;if(e.state.o&&!e.$())return e.Ye();if(!t)return H(x);let n=ae(x);if(!n.length)return e.S("No comments on this block");C=(C+1)%n.length,e.open(n[C].id),n.length>1&&e.S(`Comment ${C+1} of ${n.length} on this block`)}function me(t){if(["Tab","ArrowUp","ArrowDown","Enter","Escape"].includes(t.key)&&(!t.key.startsWith("Arrow")||!(t.metaKey||t.ctrlKey||t.altKey))){if(t.preventDefault(),t.stopPropagation(),ve=t.key,"Escape"===t.key)return void e.J();if("Enter"===t.key)return fe(t.shiftKey);"Tab"===t.key&&e.z(),e.state.i&&e.open(null),"Tab"===t.key?ce(t.shiftKey?-1:1):"ArrowUp"===t.key?ue():pe()}}let ge=()=>{let e=Q();return e?!!e.closest("[inert]"):!document.activeElement||document.activeElement===document.body},ve="",we=!1,ye=t=>{if(we&&window.removeEventListener("keyup",ye,!0),t.key===Dt&&e.state.paused)return K(!1),t.preventDefault(),void t.stopPropagation();t.key===ve&&(ve="",t.preventDefault(),t.stopPropagation())},be=()=>K(!1);window.addEventListener("keyup",ye,!0),window.addEventListener("blur",be),window.addEventListener("pointermove",U,!0),window.addEventListener("pointerdown",V,!0),document.addEventListener("selectionchange",_);for(let e of yn)window.addEventListener(e,G,!0);for(let e of wn)window.addEventListener(e,Z,!0);return window.addEventListener("keydown",J,!0),{J:()=>!!f&&(I(null),!0),ce:()=>null!==x,Ge:()=>$&&!x,Ee:function(){P=null;let t=document.activeElement;L=Q()??t;let n=oe(S),o=n??(t&&t!==document.body&&e.root.contains(t)&&!t.closest("[data-pipeup-ignore]")?ne().filter(e=>e.e.contains(t)).pop():void 0)??ie();return!!o&&(n||(k=o.L),$=!0,le(o.e),!0)},pe(){x&&!ee()&&le(x)},m(){if(P=null,x&&(!x.isConnected||!te(x))){let e=ie();e?le(e.e,ee()||ge()):se()}let t=e.t.querySelector(".launch");if(t&&c.nextElementSibling!==t&&!ee()&&!c.contains(Q()))for(let n of[o,...r,c])e.t.insertBefore(n,t);let n=e.state.o;m&&n!==m?(m=null,I(null),x&&le(x,ge())):(n||e.state.i)&&!m&&(h||f)&&I(null)},C(){R(),z(),x&&Ze(r[E],x.getBoundingClientRect(),4)},destroy(){se()&&function(){let t=L;t&&t!==document.body&&t.isConnected&&t.focus?.({preventScroll:!0}),(!t||t===document.body||!t.matches?.(":focus"))&&e.t.querySelector(".launch .mode")?.focus({preventScroll:!0})}();for(let e of r)e.remove();w(),b(),we=!0,ve||window.removeEventListener("keyup",ye,!0),window.removeEventListener("blur",be),window.removeEventListener("pointermove",U,!0),window.removeEventListener("pointerdown",V,!0),document.removeEventListener("selectionchange",_);for(let e of yn)window.removeEventListener(e,G,!0);for(let e of wn)window.removeEventListener(e,Z,!0);window.removeEventListener("keydown",J,!0),o.classList.remove("show"),c.classList.remove("show"),Ve(c,!0),O(o,()=>o.remove()),O(c,()=>c.remove())}}}function kn(e,t=!1){let n=e.ownerDocument.documentElement,o=n.getAttribute("data-pipeup-layout");if("bubbles"===o||e.querySelector("[data-pipeup-slide]"))return null;let r=e.querySelector("article, main, [role=main]")??("column"===o?e:null);if(!r)return null;if(n.hasAttribute("data-pipeup-reserve")){let e,i=n.clientWidth,a=getComputedStyle(r).maxWidth;return e=a.endsWith("px")?parseFloat(a):a.endsWith("%")?parseFloat(a)/100*i:r.getBoundingClientRect().width,"column"!==o&&i<e+320-(t?24:0)?null:{x:i-320+24,width:272}}let i=r.getBoundingClientRect().right;if(window.innerWidth-i<300&&"column"!==o)return null;let a=i+32;return{x:a,width:Math.max(220,Math.min(300,window.innerWidth-a-16))}}function En(e,t){let n=e.resolved.get(t.id);return!n||"orphaned"===n.state&&!e.M.has(t.id)}function $n(e){let t=Ye("div",{class:"col"});e.t.append(t);let n=new Map,o=null,r=new ResizeObserver(()=>l()),i=t=>En(e,t);function a(t){let n=e.resolved.get(t.id),o=n?Ht(t.anchor,n):null;return null===o?Number.POSITIVE_INFINITY:o+window.scrollY-4}function l(){let r=[],i=[];for(let[t,o]of n){let n=a(o.thread);if(Number.isFinite(n))o.placed=n;else if(e.M.has(t)){if(null===o.placed){o.e.classList.add("wait");continue}n=o.placed}Number.isFinite(n)?r.push({id:t,k:n,height:o.e.offsetHeight}):i.push({id:t,height:o.e.offsetHeight})}let l=e.state.o,s=l?Ht(l.anchor,l.resolved):null;o&&null!==s&&r.push({id:"draft",k:s+window.scrollY-4,height:o.e.offsetHeight});let d=o?"draft":e.state.i,c=r.find(e=>e.id===d);c&&t.getBoundingClientRect().right>window.innerWidth-44&&(c.k=Math.max(window.scrollY+8,Math.min(c.k,window.scrollY+window.innerHeight-44-10-c.height)));let u=function(e,t,n=10){let o=[...e].sort((e,t)=>e.k-t.k),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.k:Math.max(e.k,(r[t-1]??0)+a(t-1).height+n)});else{r[i]=a(i).k;for(let e=i+1;e<o.length;e++)r[e]=Math.max(a(e).k,(r[e-1]??0)+a(e-1).height+n);for(let e=i-1;e>=0;e--)r[e]=Math.min(a(e).k,(r[e+1]??0)-a(e).height-n)}return new Map(o.map((e,t)=>[e.id,r[t]??0]))}(r,d),p=Math.max(0,...r.map(e=>(u.get(e.id)??0)+e.height))+24;for(let e of i)u.set(e.id,p),p+=e.height+10;for(let[e,t]of n)if(t.e.classList.contains("wait")){if(!u.has(e))continue;t.e.style.transition="none",t.e.style.transform=`translateY(${Math.round(u.get(e))}px)`,t.e.offsetWidth,t.e.style.transition="",t.e.classList.remove("wait")}else t.e.style.transform=`translateY(${Math.round(u.get(e)??0)}px)`;o&&(o.e.style.transform=`translateY(${Math.round(u.get("draft")??0)}px)`)}function s(e,t){e.thread=t,e.note=Ke(t.id),e.lost=i(t),e.view.update(t,{lost:e.lost?t.anchor.snapshot:null})}function d(n){let o=i(n),a=tn(n,e.N,{_:"column",lost:o?n.anchor.snapshot:null}),l=Ye("div",{class:"th","data-thread":n.id},Ye("button",{class:"opn sr",type:"button","data-thread":n.id}),a.element);return l.style.transition="none",l.addEventListener("mouseenter",()=>e.E(n.id)),l.addEventListener("mouseleave",()=>e.E(null)),l.addEventListener("click",()=>e.open(n.id)),t.append(l),r.observe(l),{e:l,thread:n,lost:o,placed:null,view:a}}function c(e){r.unobserve(e),e.classList.add("out"),window.setTimeout(()=>e.remove(),220)}return{m:function(a){Ve(t,e.state.u);let u=new Set,p=[],h=null!==e.state.i||null!==e.state.o;for(let t of a){if(!e.K(t))continue;u.add(t.id);let o=n.get(t.id);o?(o.thread!==t||o.lost!==i(t)||o.note!==Ke(t.id))&&s(o,t):(o=d(t),n.set(t.id,o),p.push(o.e));let r=o.e,a=e.state.i===t.id;r.classList.toggle("on",a);let l=r.firstElementChild,c=en(t).length;l.setAttribute("aria-label",`Open thread: ${Ge(t.root.text,60)}, ${Qt(c)}`),l.setAttribute("aria-expanded",String(a)),Ve(l,a);let f=r.querySelector(".more");f&&Ve(f,!a),r.classList.toggle("dim",h&&!a),r.classList.toggle("hot",e.state.E===t.id&&!a),r.classList.toggle("resolved",t.resolved),r.classList.toggle("lost",o.lost)}for(let[e,t]of n)u.has(e)||(n.delete(e),c(t.e));(function(){let n=e.state.u?null:e.state.o;if(o&&o.of!==n&&(c(o.e),o=null,n||e.I(null)),!n)return;let i=!o;if(o)o.s.se(n.label);else{let i=It(e,n),a=Ye("div",{class:"th on"},i.element);a.style.transition="none",t.append(a),r.observe(a),o={e:a,s:i,of:n}}o.s.ie(e.state.p&&!n.anchor.quote&&!n.anchor.point),i&&o.s.focus()})(),Ue(t,a.filter(e=>u.has(e.id)).sort(Zt(e)).map(e=>n.get(e.id).e),o?.e??null)&&t.offsetWidth,l(),o&&p.push(o.e);for(let e of p)e.offsetWidth,e.style.transition=""},C:function(){let n=kn(e.root,!0);n&&(t.style.width=`${n.width}px`,t.style.transform=`translate(${n.x}px, ${-window.scrollY}px)`)},destroy(){r.disconnect(),e.I(null),t.remove()}}}var Sn="[data-pipeup-ignore],input,textarea,select,[contenteditable]:not([contenteditable=false])";function Ln(e){let t=Ye("button",{type:"button","aria-label":"Comment",title:"Comment"},ot("comment",17)),n=Ye("div",{class:"selbar"},t);n.inert=!0,e.t.append(n);let o=null,r=0,i=!1,a=t=>{let n=t&&(t.nodeType===Node.ELEMENT_NODE?t:t.parentElement);return!!n&&e.root.contains(n)&&!n.closest(Sn)};function l(){if(!o)return;let t=o.cloneRange();t.selectNodeContents(ue(o.commonAncestorContainer,e.root));let r=o.getBoundingClientRect(),{left:i,top:a}=function(e,t,n,o,r){let i=n+8;return i+o.width>r.width-8?_t(e,o,r):{left:i,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});n.style.left=`${i}px`,n.style.top=`${a}px`}function s(){o=null,n.inert=!0,n.classList.remove("show")}function d(t=!1){let r=_e();e.state.p&&r&&a(r.anchorNode)&&a(r.focusNode)?(!o&&!t&&e.S("Enter comments on the selected words"),o=r.getRangeAt(0).cloneRange(),l(),n.inert=!1,n.classList.add("show")):s()}t.addEventListener("mousedown",e=>e.preventDefault()),t.addEventListener("click",t=>{if(t.stopPropagation(),e.state.o&&!e.$())return e.z();let n,r=o;if(!r)return;try{n=pe(r,e.root,e.f.view(r.commonAncestorContainer))}catch(t){return e.X(t),void s()}let i=Ge(r.toString().replace(/\s+/g," ").trim(),60);window.getSelection()?.removeAllRanges(),s(),e.Xe({anchor:n,label:`\u201c${i}\u201d`,ranges:[r],resolved:{state:"attached",element:null,range:r}})});let c=()=>{window.clearTimeout(r),r=window.setTimeout(()=>i||d(),250),o&&(_e()||s())};document.addEventListener("selectionchange",c);let u=t=>{"keyup"!==t.type&&(i="mousedown"===t.type),!i&&!e.T(t)&&window.setTimeout(()=>d("mouseup"===t.type),0)};window.addEventListener("mousedown",u,!0),window.addEventListener("mouseup",u,!0),window.addEventListener("keyup",u,!0);let p=n=>{"Enter"!==n.key||!o||e.T(n)||n.target instanceof Element&&n.target.closest(`${Sn},${gn}`)||(n.preventDefault(),n.stopPropagation(),t.click())};return window.addEventListener("keydown",p,!0),{m(){!e.state.p&&o&&s()},C(){o&&l()},destroy(){window.removeEventListener("mousedown",u,!0),window.removeEventListener("mouseup",u,!0),window.removeEventListener("keyup",u,!0),window.removeEventListener("keydown",p,!0),window.clearTimeout(r),document.removeEventListener("selectionchange",c),n.remove()}}}async function Mn(e,t){try{return void await navigator.clipboard.writeText(e)}catch{}let n=document.createElement("textarea");n.value=e,n.setAttribute("readonly",""),n.style.cssText="position:fixed;opacity:0;pointer-events:none",t.append(n),n.select();let o=document.execCommand("copy");if(n.remove(),!o)throw new Error("pipeup: your browser blocked copying")}var An="Hidden on the page",Cn=["auto","light","dark"];function Tn(e){let t=[Ye("span",{class:"n"}),Ye("span",{class:"n"})],n=ot("comment",22,1.4);n.lastElementChild.setAttribute("stroke-width","1.6");let o=Ye("button",{class:"mode",type:"button","aria-label":"Comment","aria-keyshortcuts":Ot,"aria-haspopup":"menu","aria-expanded":"false"},Ye("span",{class:"plus"},n),Ye("span",{class:"cnt"},ot("bubble",28,1.4),...t),Ye("span",{class:"dot"})),r=document.createTextNode(""),i=Ye("span",{class:"ttip","aria-hidden":"true"},Ye("span",{},r,Ye("small",{},zt))),a=Ye("div",{class:"launch"},o,i),l=Ye("div",{class:"menu",role:"menu","aria-label":"Comments"}),s=Ye("div",{class:"list",role:"menu","aria-label":"All comments"}),d=Ye("button",{class:"ib",type:"button","aria-label":"Close"},ot("close")),c=(e,t,n,o)=>{let r=Ye("button",{class:"tg",type:"button","aria-label":e,"aria-description":t,"data-tip":t,"aria-pressed":"false"},n,e);return r.addEventListener("click",e=>{e.stopPropagation(),o()}),r},u=c("For you","Only comments that mention you",ot("at",16,1.8),()=>e.l.toggleMine()),p=c("Resolved","Show resolved comments too",ot("resolve",22,1.7),()=>e.l.Je()),h=Ye("div",{class:"lns"}),f=new Map,v=Ye("span",{class:"ma"}),w=Ye("span",{class:"lb"}),y=Ye("button",{class:"fs",type:"button",role:"switch","aria-checked":"false","aria-keyshortcuts":Ot},"Comment",Ye("small",{"aria-hidden":"true"},zt),Ye("span",{class:"sw","aria-hidden":"true"}));y.addEventListener("click",t=>{t.stopPropagation(),e.ke(!e.state.p,!e.state.p&&0===t.detail)});let b=Ye("button",{class:"ib",type:"button","aria-label":"More","aria-haspopup":"menu","aria-expanded":"false"},ot("more",15,3)),x="",k=Ye("div",{class:"all",role:"dialog","aria-label":"All comments"},Ye("div",{class:"hd"},u,p,Ye("span",{class:"sp"}),d),h,s,Ye("div",{class:"pf"},v,w,y,b)),E=document.createElementNS("http://www.w3.org/2000/svg","svg");E.setAttribute("class","cx"),E.setAttribute("aria-hidden","true");let $=document.createElementNS("http://www.w3.org/2000/svg","path"),S=document.createElementNS("http://www.w3.org/2000/svg","circle");S.setAttribute("r","4"),E.append($,S),l.inert=k.inert=!0,e.t.append(l,a,E,k);let L=!1,M=null,A=0,C=[],T=0,P=null,q=null,N=null,R=!0===window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,z=()=>{},D=t=>{L=e.state.l=t,t&&e.addons.flush(),window.clearTimeout(A),A=0,t||M?.(!0),t||z(),l.classList.toggle("show",t),Ve(l,!t),o.setAttribute("aria-expanded",String(t)),b.setAttribute("aria-expanded",String(t))},O=(t,n=!1)=>{if(e.state.u===t)return;let r=t?e.state.i:null;r&&(e.state.i=null),e.state.u=t,e.m(),r&&C.some(e=>e.id===r)?ne(r,!0):t?(F(s)[0]??d).focus({preventScroll:!0}):n&&o.focus({preventScroll:!0})},F=(e=l)=>[...e.querySelectorAll(".mi")].filter(e=>e.offsetParent&&!e.closest("[inert]")),I=()=>l.getRootNode().activeElement,B=()=>{D(!1),o.focus({preventScroll:!0})},j=e=>{let t=F(e.currentTarget);if(0===t.length)return;let n=I(),o=t.indexOf(n),r=n=>{e.preventDefault(),t[(n+t.length)%t.length]?.focus({preventScroll:!0})};"ArrowDown"===e.key?r(o+1):"ArrowUp"===e.key?r(o<0?t.length-1:o-1):"Home"===e.key?r(0):"End"===e.key&&r(t.length-1)};l.addEventListener("keydown",j),s.addEventListener("keydown",j),d.addEventListener("click",e=>{e.stopPropagation(),O(!1,!0)});let H=t=>En(e,t),W=t=>C.filter(n=>!n.resolved&&(void 0===t||e.U(n)===t)).length,K=t=>{let n=t.anchor.view?.slide,o=e.f.w(t.anchor.view)?"":Le(t.anchor.view);return n&&null!==e.f.slide()?`On slide ${n}`:o?`In ${o}`:An},Y=(e,t)=>{let n=new Set(t);for(let t of[...e.childNodes])n.has(t)||t.remove();t.forEach((t,n)=>{e.childNodes[n]!==t&&e.insertBefore(t,e.childNodes[n]??null)})},V=new Map,U=(e,t,n="",o=e)=>{let r=V.get(o);return r||V.set(o,r=Ye("div",{role:"group"})),r.setAttribute("aria-label",n?`${e} \xb7 ${n}`:e),Y(r,[Ye("div",{class:"sec","aria-hidden":"true"},e,n&&Ye("b",{},n)),...t]),r};function _(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.U(t)?e.f.w(t.anchor.view)?"":Le(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])=>U(e||An,t.flatMap(n)))]}return[...r].sort(([e],[t])=>Number(e)-Number(t)||0).map(([e,t])=>U(`Slide ${e} \xb7 ${t.filter(e=>!e.thread.resolved).length} open`,t.flatMap(n),e===o?"This slide":"",`slide:${e}`))}let G=null,Z=new Map,J=new Set,X={...e.N,get me(){return e.N.me},resolve:async t=>{let n=Z.get(t)?.card;n&&!e.state.O&&!R&&(J.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.N.resolve(t),J.delete(t),n?.style.removeProperty("height"),e.m()}};function Q(){let t=I(),n=t?.dataset.thread,o=null!==q&&q.element.contains(t),r=[...Z.values()].find(e=>e.view.element.contains(t)),i=()=>[...r.view.element.querySelectorAll("button,textarea")],a=r?i().indexOf(t):-1,l=r?F(s).indexOf(r.card.firstChild):-1,d=e.l.all().filter(t=>!t.thread.resolved||e.state.O||t.thread.id===P).filter(t=>!e.state.mine||((e,t)=>[e.root,...e.root.replies].some(e=>e.author!==t&&!e.deleted&&vt(e,yt(t))))(t.thread,e.doc.me));p.setAttribute("aria-pressed",String(e.state.O)),u.setAttribute("aria-pressed",String(e.state.mine));let c=e.l.name();if(w.textContent=c||m(e.doc.me),st(e.doc.me,c)!==x){x=st(e.doc.me,c);let t=dt(e.doc.me,c);t.classList.add("in"),v.replaceChildren(t)}y.setAttribute("aria-checked",String(e.state.p));let h=e.state.o;N&&N.of!==h&&(N=null,h||e.I(null));let f=h&&!N;if(h&&!N){P=q=null;let t=It(e,h);N={of:h,s:t,card:Ye("div",{class:"cd open new"},t.element)}}N&&N.s.se(h.label),G&&G.id!==P&&(G=null);let b=h&&(h.resolved.range?.startContainer??h.resolved.element),k=b?d.find(t=>{let n=Gt(e,t.thread);return n&&4&b.compareDocumentPosition(n)})?.thread.id??null:null,E=e=>{let t,n=e.thread,o=n.id===P,r=en(n).length,i=[r?Qt(r):"",...n.root.reactions.map(e=>`${e.emoji} ${e.by.length}`)].filter(Boolean).join(" \xb7 "),a=H(n)?`\u201c${Ge(n.anchor.snapshot,80)}\u201d`:n.anchor.quote?`\u201c${Ge(n.anchor.quote.exact,80)}\u201d`:e.location.where,l=Ye("button",{class:"mi",type:"button",role:"menuitem","aria-expanded":String(o),"data-thread":n.id},Ye("span",{class:"sr"},[g(n.root),Ce(n.root.at,Date.now()),a,n.root.text,i].filter(Boolean).join(", ")));if(l.addEventListener("click",e=>{e.stopPropagation(),ne(n.id)}),o&&q){if(q.update(n,ee(n)),!G){let e=Ye("div",{class:"xr",role:"region","aria-label":"Comment thread"},q.element);e.addEventListener("click",e=>{let t=e.target;t.closest(".root>.hdr")&&!t.closest("button")&&oe(!0)}),G={id:n.id,card:Ye("div",{}),xr:e}}t=G.card,t.className="cd open"+(n.resolved?" done":""),Y(t,[l,G.xr])}else{let e={_:"card",note:a,rest:i},o=Z.get(n.id);o?o.view.update(n,e):Z.set(n.id,o={card:Ye("div",{}),view:tn(n,X,e)}),t=o.card,t.className=`cd${n.resolved?" done":""}${J.has(n.id)?" out":""}`,Y(t,[l,o.view.element])}return N&&n.id===k?[N.card,t]:[t]},$=d.filter(e=>H(e.thread));Y(s,[...d.length||N?[]:[Ye("div",{class:"sec",role:"presentation"},e.state.mine?"No comments mention you":"No open comments")],..._(d.filter(e=>!H(e.thread)),E),...N&&null===k?[N.card]:[],...$.length?[U("No longer on the page",$.flatMap(E))]:[]]);for(let e of Z.keys())d.some(t=>t.thread.id===e)||Z.delete(e);let S=I();f?N.s.focus():N?.card.contains(t)&&!N.card.contains(S)?N.s.re()():o&&!q.element.contains(S)?q.element.querySelector("textarea")?.focus({preventScroll:!0}):r&&S!==t?(r.card.isConnected?i()[a]:F(s)[Math.min(l,F(s).length-1)])?.focus({preventScroll:!0}):n&&S!==t&&F(s).find(e=>e.dataset.thread===n)?.focus({preventScroll:!0})}function ee(t){let n=!H(t)&&e.U(t);return{_:"popover",quote:t.anchor.quote?.exact??null,lost:H(t)||n?t.anchor.snapshot:null,place:n?K(t):null}}let te="";function ne(t,n=!1){if(P===t)return oe(!0);let o=C.find(e=>e.id===t);if(o){if(P=te=t,q=tn(o,{...e.N,close:()=>oe(!0)},ee(o)),e.seen(o),Q(),q.element.querySelector("textarea")?.focus({preventScroll:!0}),n&&s.querySelector(".mi.open")?.scrollIntoView({block:"nearest"}),!e.U(o))return re(o,!n);e.state.o&&!e.$()||e.f.V(o.anchor.view??{}).then(()=>{e.Se();let n=C.find(e=>e.id===t);n&&te===t&&P===t&&re(n)})}}function oe(t=!1){if(!P)return;let n=P;P=q=null,e.E(null),Q(),t&&F(s).find(e=>e.dataset.thread===n)?.focus({preventScroll:!0})}function re(t,n=!0){let o=e.resolved.get(t.id),r=o&&!H(t)?o.element??o.range?.startContainer.parentElement??null:null;n&&r?.scrollIntoView({block:"center",inline:"nearest",behavior:R?"auto":"smooth"}),r&&e.E(t.id)}function ie(t,n){let o=n?n.resolved:e.resolved.get(t.id),r=o?.element??o?.range?.startContainer.parentElement;if(!o||Vt()||t&&(H(t)||e.U(t))||!1===r?.checkVisibility?.({visibilityProperty:!0}))return null;let i=t?e.t.querySelector(`.bub[data-thread="${t.id}"]`)?.getBoundingClientRect():void 0,a=o.range?jt(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=Wt(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 ae(e,t,n=!1,...o){let r=Ye("button",{class:"mi",type:"button",role:n?"menuitemcheckbox":"menuitem"},e,Ye("span",{class:"lb"}),...o,n&&Ye("span",{class:"sw","aria-hidden":"true"}),Ye("span",{class:"tt","aria-hidden":"true"}));return r.addEventListener("click",e=>{e.stopPropagation(),t(e)}),r}let 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))},se=()=>Ye("div",{class:"sep",role:"separator"}),de=Ye("span",{class:"ma"}),ce=Ye("span",{class:"kc"}),ue="",pe=ae(de,function(){let t=Ye("input",{class:"input",type:"text",maxlength:"80","aria-label":"Your name"});t.value=e.l.name();let n=Ye("div",{class:"ed"},de.cloneNode(!0),t),o=(r,i=!1)=>{if(M!==o)return;M=null;let a=t.value.trim();r&&a&&a!==e.l.name()&&e.l.rename(a).then(Ne),n.replaceWith(pe),i&&pe.focus({preventScroll:!0})};M=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,ce);pe.dataset.item="name";let he=ae(ot("copy"),()=>{B(),e.l.copyAll("ai")}),fe=ae(ot("lines"),()=>{B(),e.l.copyAll("text")}),me=Ye("div",{class:"subs",role:"group"},Ye("div",{},he,fe)),ge=ae(ot("copy"),()=>ve("true"!==ge.getAttribute("aria-expanded")),!1,Ye("span",{class:"chev"},ot("chev",13))),ve=(e,t=!0)=>{ge.setAttribute("aria-expanded",String(e)),me.classList.toggle("open",e),Ve(me,!e),t&&(e?he:ge).focus({preventScroll:!0})};z=()=>ve(!1,!1),z(),ge.addEventListener("keydown",e=>{"ArrowRight"===e.key&&"true"!==ge.getAttribute("aria-expanded")&&(e.preventDefault(),ve(!0))}),me.addEventListener("keydown",e=>{"ArrowLeft"===e.key&&(e.preventDefault(),ve(!1))});let we=Ye("span",{class:"kc"}),ye=ae(ot("look"),()=>{e.l.setLook(Cn[(Cn.indexOf(e.l.look())+1)%3]),Ne()},!1,we),be=Ye("span",{class:"kc"}),xe=ae(ot("list"),()=>{D(!1),xe.dataset.item="all",O(!0)},!1,be),ke=ae(ot("hide"),()=>{e.l.setHide(!e.state.hide),Ne()},!0),Ee=ae(ot("comment"),t=>{let n=!e.state.p&&0===t.detail;e.ke(!e.state.p,n),n&&D(!1)},!0,Ye("span",{class:"kc","aria-hidden":"true"},zt));Ee.dataset.item="comment",Ee.setAttribute("aria-keyshortcuts",Ot);let $e=Ye("div",{class:"sec",role:"presentation"}),Se=se(),Me=se(),Ae=new Map,Te=t=>{let n=Ae.get(t);return n||(n=ae(rt(t.icon,15),()=>{t.checked||B(),Promise.resolve().then(()=>t.select()).catch(t=>e.X(t)).finally(()=>L&&Ne())},!!t.checked,Ye("span",{class:"kc"})),Ae.set(t,n)),n},Pe=-1,qe=e=>{try{return e()}catch(e){return globalThis.reportError?.(e),""}};function Ne(){let t=W(),n=e.l.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`),ce.replaceChildren(n?ot("edit",13):"Add name"),st(e.doc.me,n)!==ue){ue=st(e.doc.me,n);let t=dt(e.doc.me,n);t.classList.add("in"),de.replaceChildren(t)}le(ge,"Copy comments","As Markdown, with where each thread is, or as text"),le(he,"As Markdown","With where each thread is, ready for an AI or a document"),le(fe,"As text","Just the words");let r=["Automatic","Light","Dark"][Cn.indexOf(e.l.look())];le(ye,"Theme",`${r}. Automatic follows the page; press to change`),we.textContent=r,le(xe,"All comments","Every thread, and where it is"),be.textContent=t?String(t):"";let i=e.addons.ge();$e.textContent=i,i?!$e.isConnected&&l.contains(pe)&&l.prepend($e):$e.remove();for(let t of e.addons.F){let e,n=Ae.get(t);if(n){try{e=t.checked?.()}catch(e){globalThis.reportError?.(e)}le(n,qe(t.label),qe(t.hint),e),n.querySelector(".kc").textContent=t.count?qe(t.count):""}}le(ke,"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(Ee,"Start commenting",e.state.p?"Turn off to use the page as normal":"Choose any part of the page to comment on it",e.state.p)}function Re(){Ne(),(Pe!==e.addons.Z||!l.contains(pe))&&(l.replaceChildren(pe,Se,ge,me,ye,xe,...e.addons.F.map(Te),Me,ke,Ee),Pe=e.addons.Z,Ne())}b.addEventListener("click",e=>{if(e.stopPropagation(),L)return D(!1);Re(),D(!0),0===e.detail&&F()[0]?.focus({preventScroll:!0})}),o.addEventListener("click",t=>{if(t.stopPropagation(),!L)return e.state.p?O(!0):(Re(),D(!0),void(0===t.detail&&F().at(-1)?.focus({preventScroll:!0})));D(!1)});let ze=t=>{let n=t.composedPath();L&&!n.includes(l)&&!n.includes(o)&&!n.includes(b)&&(D(!1),e.state.p&&!e.T(t)&&(e.we(t),t.preventDefault(),t.stopPropagation()))},De=e=>{if(!L||"touch"===e.pointerType||"pointerout"===e.type&&e.relatedTarget)return;let t=e.composedPath();"pointerover"===e.type&&(t.includes(l)||t.includes(o)||t.includes(b))?(window.clearTimeout(A),A=0):A||(A=window.setTimeout(()=>{A=0,M||D(!1)},3e3))},Oe={n:0,label:""},Fe=()=>{let{n:t,label:n}=Oe,i=e.addons.ge(),a=`Comment${e.state.p?", comment mode on":""}${n?`, ${n}`:t?`, ${t} open`:""}${i?`, ${i}`:""}`;o.getAttribute("aria-label")!==a&&o.setAttribute("aria-label",a),o.setAttribute("aria-haspopup",e.state.p?"dialog":"menu");let l=[n,i].filter(Boolean).join(" \xb7 ")+(n||i?" \xb7 ":"");r.data!==l&&(r.data=l)},Ie=e.addons.subscribe(t=>{Fe(),(()=>{for(let[t,n]of f)e.addons.listNotes.has(t)||(f.delete(t),n.row.classList.remove("show"),setTimeout(()=>n.row.remove(),320));for(let[t,n]of e.addons.listNotes){let o=f.get(t);if(!o){let e=Ye("span",{}),r=Ye("div",{class:"ln"},Ye("div",{class:"lw"},Ye("div",{class:"ag"},e)));r.dataset.addon=t,o={row:r,words:e,btn:null,note:n},f.set(t,o),h.append(r),requestAnimationFrame(()=>{r.offsetWidth,r.classList.add("show")})}if(o.note=n,o.words.textContent!==n.text&&(o.words.textContent=n.text),n.action&&!o.btn){let t=Ye("button",{type:"button"}),n=o;t.addEventListener("click",o=>{o.stopPropagation();let r=n.note.action;r&&(t.disabled=!0,r.run().catch(t=>e.X(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)}})(),L&&!M&&(t?Re():Ne())});window.addEventListener("click",ze,!0),window.addEventListener("pointerover",De,!0),window.addEventListener("pointerout",De,!0);let Be=t=>{if("Escape"!==t.key||M||t.composedPath().some(e=>e instanceof Element&&e.classList.contains("rxp")))return;let n=t.composedPath()[0],o=n instanceof Element&&n.closest(".cd:not(.open,.new)");if(L)B();else if(o&&n!==o.firstChild){if(n instanceof HTMLTextAreaElement)return;o.firstChild.focus({preventScroll:!0})}else{if(!e.state.u||n instanceof HTMLTextAreaElement&&!k.contains(n))return;e.state.o?e.J():P?oe(!0):O(!1,!0)}t.stopPropagation()};return window.addEventListener("keydown",Be,!0),e.registerList(e=>{P!==e&&ne(e,!0)}),{m(n){C=n;let r=W(!1);if(r!==T){if(r){let[e,n]=t[0].classList.contains("on")?t:[t[1],t[0]];n.textContent=r>99?"99+":String(r),n.classList.toggle("s",r>99),e.classList.remove("on"),n.classList.add("on")}o.classList.toggle("has",r>0),T=r}let i=W(!0),l=i?`${r} here \xb7 ${i} ${null!==e.f.slide()?"on other slides":"in other views"}`:"";o.classList.toggle("else",i>0),Oe={n:r,label:l},Fe(),o.classList.toggle("on",e.state.p),L&&!e.state.l&&D(!1),L&&Ne();let s=e.state.u;k.classList.toggle("full",Vt()),k.classList.contains("show")!==s&&(k.classList.toggle("show",s),Ve(k,!s),Ve(a,s)),P&&(!s||!n.some(e=>e.id===P))&&(P=q=null,e.state.E=null),s&&Q()},C:function(){let e=P?C.find(e=>e.id===P):null,t=N?.card??(P?s.querySelector(".cd.open"):null),n=N?ie(null,N.of):e&&ie(e),o=t?.getBoundingClientRect(),r=s.getBoundingClientRect();if(!n||!o||o.top+12<r.top||o.top+12>r.bottom)return void E.classList.remove("show");let i,a=o.left,l=o.top+14;if("right"===n.from&&a-n.x>60){let e=n.x+28,t=n.y>=l?1:-1,o=Math.min(24,Math.abs(n.y-l)/2);i=`M${a} ${l}C${a-24} ${l} ${e} ${l} ${e} ${l+t*o}L${e} ${n.y-t*o}C${e} ${n.y} ${e} ${n.y} ${n.x} ${n.y}`}else{let e=n.y-8,t=a-40,o=e>=l?1:-1,r=Math.min(20,Math.abs(e-l)/2);i=`M${a} ${l}C${a-20} ${l} ${t} ${l} ${t} ${l+o*r}L${t} ${e-o*r}C${t} ${e} ${t} ${e} ${t-r} ${e}L${n.x+8} ${e}C${n.x} ${e} ${n.x} ${e} ${n.x} ${n.y}`}$.setAttribute("d",i),S.setAttribute("r",n.bubble?"0":"4"),S.setAttribute("cx",String(n.x)),S.setAttribute("cy",String(n.y)),E.classList.add("show")},destroy(){Ie(),window.removeEventListener("click",ze,!0),window.removeEventListener("pointerover",De,!0),window.removeEventListener("pointerout",De,!0),window.clearTimeout(A),window.removeEventListener("keydown",Be,!0),e.registerList(null),l.remove(),k.remove(),E.remove(),a.remove()}}}var Pn="[data-pipeup-slide]",qn=["scroll","resize","keyup","click","transitionend","slidechanged"],Nn=null,Rn=null,zn=new Set,Dn=new Set,On=e=>{try{e()}catch(e){globalThis.reportError?.(e)}};function Fn(e){Rn="function"==typeof e?.current&&"function"==typeof e.go?e:null}var In=()=>{let e=window.Reveal;return"function"==typeof e?.getIndices&&"function"==typeof e.slide?e:null};var Bn=["pipeup-quote","pipeup-on","pipeup-done"],jn={"pipeup-quote":[[250,227,188,.75],[250,200,100,.28]],"pipeup-on":[[247,212,154,.95],[250,200,100,.42]],"pipeup-done":[[180,178,169,.22],[180,178,169,.2]]};function Hn(){return typeof CSS<"u"&&"highlights"in CSS&&typeof Highlight<"u"}var Wn=`:not([data-pipeup-ignore],[data-pipeup-ignore] *){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 Kn(){if(Hn())for(let e of Bn)CSS.highlights.delete(e)}var Yn,Vn="#534AB7";function Un(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(Yn??=t.createElement("canvas").getContext("2d",{willReadFrequently:!0})??null,!Yn)return null;Yn.clearRect(0,0,1,1),Yn.fillStyle="#000",Yn.fillStyle=e,Yn.fillRect(0,0,1,1);let[n,o,r,i]=Yn.getImageData(0,0,1,1).data;return{r:n,g:o,b:r,a:i/255}}catch{return null}}function _n(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 Gn=(e,t)=>(Math.max(e,t)+.05)/(Math.min(e,t)+.05),Zn=[[.92,.25],[.92,.6],[.5,.45]];function Jn(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?Un(t.getComputedStyle(n).backgroundColor,e):null;return t&&e.body&&(!i||i.a<.5)&&(i=Un(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 Xn(e,t){let n=e.ownerDocument,o=n.defaultView,r="dark"===t;if(!o)return{font:"system-ui, sans-serif",accent:Vn,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=d&&"rgb(0, 0, 238)"!==d?Un(d,n):null,u=c&&Gn(_n(c),r?.011:1)>=3,p=l||(u?d:r?"#9A94EE":Vn),h=Un(p,n);return{font:a,accent:p,dark:r,on:h&&Gn(_n(h),1)<3?"#111":"#fff"}}function Qn(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 eo={light:["#2C2C2A","#FFFFFF"],dark:["#ECEBE6","#1B1B19"]},to=[["opacity","1"],["filter","none"],["backdrop-filter","none"],["mix-blend-mode","normal"],["transform","none"],["clip-path","none"],["mask-image","none"],["zoom","1"]];function no(e,t,n){let[o,r]=eo[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 _n({r:o,g:r,b:i})});return((e,t)=>(Math.max(e,t)+.05)/(Math.min(e,t)+.05))(o,r)}function oo(e,t=!1){return kn(e,t)?"column":"bubbles"}var ro="Shown here, but not saved yet \u2014 it will be saved with your next change",io=e=>e instanceof Error?e.message.replace(/^pipeup: /,""):"Something went wrong";function ao(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="",a=()=>{let e="auto"!==n?n:function(e){let t=e.documentElement.getAttribute("data-pipeup-theme")??e.body?.getAttribute("data-pipeup-theme");return"light"===t||"dark"===t?t:null}(document),t=e??(function(e,t=!1){let n=e.defaultView;if(!n)return!1;let o=e.documentElement,r=_n(Jn(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 Zn){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=Un(n.getComputedStyle(r).backgroundColor,e);if(o&&o.a>=.5){l=_n(o);break}}a+=l}let l=a/Zn.length;return l<.18||!(l>.32)&&t}(document,r)?"dark":"light");o=function(e,t,n){let o=e.defaultView?.getComputedStyle(e.documentElement),r=to.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}=Jn(e);return{look:t,source:n,ratio:no(t,i,[a,l,s]),effects:r}}(document,t,"auto"!==n?"reviewer":e?"author":"page");let a=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 a&&a!==i&&console.warn(i=a),t};r="dark"===a();let l=Xn(e.root,r?"dark":"light"),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:2147483000!important;display:block!important;margin:0!important;visibility:visible!important;opacity:1!important;transform:none!important;filter:none!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",`${Yt()}px`),Qn(a,e),r.append(a),n.documentElement.append(o),{element:o,shadow:r,t:a,destroy:()=>o.remove()}}(l,e.styles),d=function(e=document,t=!1){let n=e.defaultView?.CSSStyleSheet;if(!n||!("replaceSync"in n.prototype)||!("adoptedStyleSheets"in e))return{Te(){},Ae(){},ue(){},dark(){},Le(){},remove:()=>Kn()};let o=new n,r=null,i=!1,a=1,l=t,s=0,d="",c=0,u=()=>o.replaceSync(((e,t)=>Bn.map(n=>{let[o,r,i,a]=jn[n][e?1:0];return`::highlight(${n}){background-color:rgba(${o},${r},${i},${+(a*t).toFixed(3)})}`}).join(""))(l,a)+(null===r?"":`:root{--pipeup-gutter:${r}px}`)+(i?Wn:"")+(s||d?`html{--pipeup-panel:${s}px;${s?`margin-right:${s}px!important;`:""}${d}}`:""));return u(),e.adoptedStyleSheets=[...e.adoptedStyleSheets,o],{Te(e){e!==r&&(r=e,u())},Ae(e){e!==i&&(i=e,u())},ue(e){a=e,u()},dark(e){e!==l&&(l=e,u())},Le(e,t){e!==s&&(s=e,d=t?"":"transition:margin-right .34s cubic-bezier(.4,0,.2,1)!important",clearTimeout(c),!e&&d&&(c=window.setTimeout(()=>{d="",u()},400)),u())},remove(){clearTimeout(c),e.adoptedStyleSheets=e.adoptedStyleSheets.filter(e=>e!==o),Kn()}}}(document,l.dark);d.ue(0);let c=!0===window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,u=document.documentElement.hasAttribute("data-pipeup-reserve"),p=new Map,h=new Set,f=new WeakSet,v=`pipeup:hide:${e.doc.id}`,w=!1;try{w="1"===localStorage.getItem(v)}catch{}let y={i:null,E:null,O:!1,mine:!1,hide:w,hidden:w,mode:oo(e.root),o:null,p:!1,paused:!1,u:!1,Me:!1,l:!1},b=Ye("div",{class:"toast",role:"status","aria-live":"polite"}),x=Ye("div",{class:"sr","aria-live":"polite"});s.t.append(b,x);let k=null,E=null,$=[],S=null,L=!1,M=0,A=0,C=0,T=0,P=0,q=new Set,N="",R=new Map,z=function(e,t,n=function(){return{s:e=>e.getBoundingClientRect(),shown:e=>!1!==e.checkVisibility?.({opacityProperty:!0,visibilityProperty:!0}),opacity:e=>parseFloat(getComputedStyle(e).opacity)||0,de:()=>({width:window.innerWidth,height:window.innerHeight})}}()){let o=!0===window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,r=null,i=null,a=0,l=!1,s=()=>[...e.querySelectorAll(Pn)],d=()=>[...e.querySelectorAll(".slides > section")],c=e=>"string"==typeof e&&e.length>0&&e.length<=200?e:null,u=e=>c(e?.getAttribute("data-pipeup-slide"));function p(){if(Rn){let e=null;if(On(()=>{let t=Rn.current();Number.isInteger(t)&&t>0&&(e=String(t))}),null!==e)return e}let e=In();if(e){let t=null;if(On(()=>{let n=e.getIndices().h,o=d()[n];t=u(o?.matches(Pn)?o:o?.querySelector(Pn))??c(String(n+1))}),null!==t)return t}return r&&!r.isConnected&&(r=null),r=function(e,t,n){let o=t.de(),r=null,i=0,a=0;for(let l of e){if(!t.shown(l))continue;let e=t.s(l),s=Math.min(e.left+e.width,o.width)-Math.max(e.left,0),d=Math.min(e.top+e.height,o.height)-Math.max(e.top,0);if(s<=0||d<=0)continue;let c=Math.round(s*d),u=t.opacity(l);(c>i||c===i&&(u>a||u===a&&l===n))&&(r=l,i=c,a=u)}return r}(s(),n,r)??r,u(r)}function h(){a=0,i=p(),t()}let f=()=>{!a&&!l&&(a=requestAnimationFrame(h))},m=e=>function(e,t,n){return null!==t?void 0===e?.slide||e.slide===t:!e||!n||Object.entries(e).every(([e,t])=>"label"===e||"slide"===e||n[e]===t)}(e,i,Nn),g=new MutationObserver(e=>{e.some(e=>e.target instanceof Element&&e.target.matches(Pn))&&f()});g.observe(e,{subtree:!0,attributes:!0,attributeFilter:["class","style","hidden"]});for(let e of qn)window.addEventListener(e,f,{capture:!0,passive:!0});return Dn.add(f),i=p(),{slide:()=>i,view(e){let t=e instanceof Element?e:e?.parentElement,n=u(t?.closest(Pn))??i,o={...null!==n?{slide:n}:{},...Nn};return Object.keys(o).length?o:void 0},w:m,V:function(e){if(m(e))return Promise.resolve(!0);let t=e.slide,n=In(),r=s().find(e=>u(e)===t),a=/^[1-9]\d{0,5}$/.test(t??"");if(a&&Rn)On(()=>Rn.go(Number(t)));else if(a&&n){let e=r?d().findIndex(e=>e===r||e.contains(r)):-1;On(()=>n.slide(e>=0?e:Number(t)-1))}else if(zn.size)for(let t of zn)On(()=>t({...e}));else{if(!r)return Promise.resolve(!1);r.scrollIntoView({block:"start",behavior:o?"auto":"smooth"})}let c=performance.now();return new Promise(t=>{let n=e=>{clearTimeout(o),t(e)},o=setTimeout(()=>n(!1),1e3),r=()=>l?n(!1):(i=p(),m(e)?n(!0):performance.now()-c>=1e3?n(!1):void requestAnimationFrame(r));requestAnimationFrame(r)})},destroy(){l=!0,cancelAnimationFrame(a),g.disconnect();for(let e of qn)window.removeEventListener(e,f,!0);Dn.delete(f)}}}(e.root,()=>{!L&&X()&&re()}),D=!1,O=0;function F(e,t=2400,n=!1,o=!1,r){L||(D=n,b.textContent=e,b.classList.toggle("act",!!r),r&&b.append(" ",Ye("a",{class:"ta",href:r.href,target:"_blank",rel:"noopener noreferrer"},r.label)),o?b.setAttribute("aria-hidden","true"):b.removeAttribute("aria-hidden"),b.classList.add("show"),window.clearTimeout(M),M=window.setTimeout(()=>b.classList.remove("show"),t))}function I(){D&&(D=!1,window.clearTimeout(M),b.classList.remove("show"))}function B(e){x.textContent="",cancelAnimationFrame(O),O=requestAnimationFrame(()=>x.textContent=e)}function j(e){F(io(e))}function H(e){throw j(e),e}let W=()=>e.doc.threads().filter(e=>!e.root.deleted),K=t=>({thread:t,location:Se(t.anchor,p.get(t.id)??we(t.anchor,e.root),e.root)}),Y={get me(){return e.doc.me},picker:()=>Z.picker,people:()=>gt(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 U?F(ro):H(e)}},reply:async(t,n,o)=>{try{await e.doc.reply(t,n,o),ue(o,n)}catch(e){e instanceof U?F(ro):H(e)}},edit:async(t,n,o)=>{try{await e.doc.edit(t,n,o)}catch(e){e instanceof U?F(ro):H(e)}},remove:async t=>{try{await e.doc.remove(t),F("Deleted")}catch(e){F(e instanceof U?`Deleted \xb7 ${ro}`:io(e))}},resolve:async t=>{try{await e.doc.resolve(t),F("Resolved \xb7 Show resolved brings it back")}catch(e){F(e instanceof U?`Resolved \xb7 ${ro}`:io(e))}(e=>y.i===e&&!y.O&&(S?.ce()?S.pe():s.t.querySelector(".launch .mode")?.focus({preventScroll:!0}),!0))(t)&&(y.i=null)},reopen:async t=>{try{await e.doc.reopen(t),F("Reopened")}catch(e){F(e instanceof U?`Reopened \xb7 ${ro}`:io(e))}},notRight:async t=>{try{await e.doc.reopen(t)}catch(e){F(e instanceof U?`Reopened \xb7 ${ro}`:io(e))}de(t)},close:()=>{fe(null);let e=ie&&s.t.querySelector(ie);e?e.focus({preventScroll:!0}):S?.pe(),ie=""},copy:t=>{try{let n=e.doc.threads().find(e=>e.id===t);if(!n)return;Mn(Te(K(n),"ai",location.href,Date.now()),s.t).then(()=>F("Thread copied as Markdown for AI"),e=>F(io(e)))}catch(e){F(io(e))}}},V={look:()=>n,setLook(e){n=e;try{"auto"===e?localStorage.removeItem(t):localStorage.setItem(t,e)}catch{}De(a())},copyAll:async e=>{let t=V.all(),n=Pe(t,e,{title:document.title,url:location.href,exportedAt:new Date});try{await Mn(n,s.t);let o=t.filter(e=>!e.thread.resolved).length;F(`Copied ${o} thread${1===o?"":"s"}${"ai"===e?" as Markdown for AI":""}`)}catch(e){F(io(e))}},Je:()=>{y.O=!y.O,re()},toggleMine:()=>{y.mine=!y.mine,re()},setHide:e=>{y.hide=e;try{e?localStorage.setItem(v,"1"):localStorage.removeItem(v)}catch{}re()},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)?F(`New comments will say ${n}, but this browser couldn't remember it`):F(`New comments will say ${n}`)}catch(e){F(io(e))}},name:()=>e.doc.name,all:()=>[...W()].sort(Zt(G)).map(K)},_={},G={get addons(){return _.surface},doc:e.doc,root:e.root,t:s.t,host:s.element,state:y,resolved:p,M:h,N:Y,l:V,f:z,U:e=>q.has(e.id),Se:()=>{X()&&re()},K:e=>!y.hidden&&(!e.resolved||y.O||(e=>""!==(s.t.querySelector(`[data-thread="${e}"] .rbox textarea`)?.value.trim()??""))(e.id))&&!q.has(e.id),Ze:(e,t)=>{for(let n of W()){let o=p.get(n.id);if(n.anchor.quote&&G.K(n)&&o?.range&&Kt(e,t,jt(o)))return n}return null},le:(e,t)=>G.$()?G.Ze(e,t):null,T:e=>e.composedPath().includes(s.element),we:e=>{f.add(e)},je:e=>f.has(e),open:fe,Qe:e=>de(e),E:function(e){y.E!==e&&(y.E=e,e&&e!==y.i&&xe(e),re())},Xe:me,Ue:function(e){if(!y.o)return me(e);Object.assign(y.o,e),re()},$:()=>!k||k.qe(),xe:e=>{let t=k?.re();e(),t?.()},Ye:()=>{let e=y.o?.anchor.view,t=k?.re();Promise.resolve(z.w(e)||z.V(e??{}).then(()=>G.Se())).then(t)},Ve:async function(t,n){let o=y.o;if(o)try{let r=await e.doc.comment(o.anchor,t,n);ue(n,t),y.o=null,J(new Set([r])),fe(r,!0)}catch(e){if(e instanceof U)return y.o=null,J(new Set([e.id])),fe(e.id,!0),void F(ro);H(e)}},seen:pe,people:()=>gt(e.doc.threads(),e.doc.me),_e:ge,ke:ve,z:be,I:e=>{k=e},registerList:e=>{E=e},oe:F,S:B,We:I,X:j,et:xe,m:re,J:ye},Z=_.surface=new Mt(G,s.shadow,x);function J(t){let n=performance.now(),o=e.doc.threads();for(let r of o){if(t&&!t.has(r.id))continue;let o=performance.now()-n<40,i=we(r.anchor,e.root,{fuzzy:o});p.set(r.id,i),o||"orphaned"!==i.state?h.delete(r.id):h.add(r.id)}for(let e of[...p.keys()])o.some(t=>t.id===e)||p.delete(e);0===h.size?(window.clearTimeout(T),T=0):0===T&&(T=window.setTimeout(()=>{T=0,!L&&(J(new Set(h)),re())},250))}function X(){let t=new Set,n=null!==z.slide(),o=new Set;for(let r of e.doc.threads()){o.add(r.id);let e=p.get(r.id)?.element;(!z.w(r.anchor.view)||!n&&!1===e?.checkVisibility?.({visibilityProperty:!0}))&&t.add(r.id)}q=t;for(let e of R.keys())o.has(e)||R.delete(e);let r=`${z.slide()}|${[...t].join()}`;return r!==N&&(N=r,!0)}let Q=0,ee=0,te=0,ne=0,oe=0;function re(){if(L)return;let t=W();if(X(),y.i&&q.has(y.i)){let e=s.t.querySelector(`[data-thread="${y.i}"] .rbox textarea`)?.value;e&&R.set(y.i,e),y.i=null}y.hidden=y.hide&&!y.p&&!y.u&&!y.Me&&!y.o,d.Ae(y.p&&!y.paused),y.hidden&&(y.i=null),y.hidden||function(t){let n=function(e,t){let n=yt(t),o=[];for(let r of e)for(let e of[r.root,...r.root.replies])e.author!==t&&!e.deleted&&vt(e,n)&&!e.seenBy?.includes(t)&&o.push({thread:r,comment:e});return o}(t,e.doc.me).filter(e=>!he.has(e.comment.id));if(!n.length)return;for(let e of n)he.add(e.comment.id);let o=[...new Set(n.map(e=>g(e.comment)))];F(`${1===o.length?o[0]:`${o.length} people`} mentioned you in ${n.length} comment${1===n.length?"":"s"}`)}(t),function(e){if(e===ee)return;ee=e,cancelAnimationFrame(te);let t=Q,n=performance.now(),o=e?260:200,r=i=>{let a=Math.min(1,(i-n)/o);Q=t+(e-t)*(e?1-(1-a)**3:a*a),d.ue(Q),a<1&&(te=requestAnimationFrame(r))};te=requestAnimationFrame(r)}(y.hidden?0:1),s.t.classList.toggle("hidden",y.hidden),s.t.classList.toggle("listing",y.u);let n=y.u&&!Vt();(function(e){e!==ne&&(ne=e,d.Le(e,c),window.clearTimeout(oe),oe=window.setTimeout(()=>{J(),re()},c?0:400))})(n?320:0),d.Te(u?"column"!==y.mode||y.hidden||n?0:320:null),function(e){let t=[],n=[],o=[];for(let r of e){let e=p.get(r.id);r.resolved&&!y.O||!e?.range||q.has(r.id)||(r.id===y.i||r.id===y.E?n.push(e.range):r.resolved?o.push(e.range):t.push(e.range))}y.o&&z.w(y.o.anchor.view)&&n.push(...y.o.ranges),function(e){if(Hn())for(let t of Bn)CSS.highlights.set(t,new Highlight(...e[t.slice(7)]))}({quote:t,on:n,done:o})}(t);for(let e of $)e.m(t);S?.m(t),y.hidden||Z.flush()}let ie="",ae=()=>s.t.getRootNode().activeElement,le="input,textarea,select,[contenteditable]:not([contenteditable=false])",se=()=>{let e=ae();return e instanceof HTMLTextAreaElement&&""!==e.value||!!document.activeElement?.matches(le)};function de(e,t=se(),n=ae()){let o=[...s.t.querySelectorAll(`[data-thread="${e}"] .rbox textarea`)].find(e=>!e.closest("[inert]")),r=n?.getAttribute("data-thread");ie=r?`.${n.classList[0]}[data-thread="${r}"]`:"",!t&&o&&o.focus({preventScroll:!0})}function ce(){let e=y.o;return!(!e||G.$()||(z.w(e.anchor.view)||z.V(e.anchor.view??{}),0))}function ue(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()];F(`Let ${1===s.length?s[0]:`${s.length} people`} know?`,9e3,!1,!1,{label:"Open my email",href:`mailto:${[...r.keys()].join(",")}?subject=${encodeURIComponent(a)}&body=${encodeURIComponent(l)}`})}function pe(t){let n=[t.root,...t.root.replies].filter(t=>t.author!==e.doc.me&&!t.deleted&&vt(t,yt(e.doc.me))).map(e=>e.id);n.length&&e.doc.seen(n).catch(()=>{})}let he=new Set;function fe(t,n=!1){if(t&&ce())return;if(t&&y.u&&E)return E(t);if(y.i===t&&!y.o)return t?de(t):void 0;let o=!n&&se(),r=ae();if(t||(y.Me=!1),y.i=t,t){y.o=null,xe(t);let n=e.doc.threads().find(e=>e.id===t);n&&pe(n)}if(re(),t){let e=R.get(t),i=e&&s.t.querySelector(`[data-thread="${t}"] .rbox textarea`);i&&!i.value&&(i.value=e,i.dispatchEvent(new Event("input",{bubbles:!0}))),R.delete(t),n&&S?.ce()?S.pe():de(t,o,r)}}function me(e){I(),y.o=e,y.i=null,re()}function ge(){y.o&&(y.o=null,re())}function ve(e,t=!1){y.p!==e&&(y.p=e,y.paused=!1,e?(y.i=null,S=xn(G)):(I(),S?.destroy(),S=null,B("Comment mode off")),re(),S&&(t&&S.Ee(),t?S.ce()?F(bn,1e4,!0,!0):F("Nothing here to comment on"):F(`Click anything to comment, or Tab between blocks \xb7 Option-click (Alt-click) to pin \xb7 Hold Space to use the page \xb7 ${zt} or Esc to finish`,4e3,!0)))}function ye(){y.o&&(z.w(y.o.anchor.view)||G.$())?ge():y.i?fe(null):S&&!S.J()&&ve(!1)}function be(){y.o?ce()||ge():y.i&&fe(null)}function xe(e){let t=p.get(e);!t||"orphaned"===t.state||Ee(()=>t.range?jt(t):t.element?[t.element.getBoundingClientRect()]:[])}let ke=new Set;function Ee(e){let t=e().slice(0,6).map(()=>s.t.insertBefore(Ye("div",{class:"pulse"}),s.t.firstChild)),n={els:t,at:e};ke.add(n),$e(n),window.setTimeout(()=>{ke.delete(n);for(let e of t)e.remove()},1300)}function $e(e){let t=e.at();e.els.forEach((e,n)=>t[n]&&Ze(e,t[n],4))}function Le(){for(let e of $)e.destroy();$=function(e){return[..."column"===e.state.mode?[$n(e),nn(e,{ae:!1})]:[nn(e,{ae:!0})],Ln(e),Tn(e)]}(G),re()}We.go=t=>{if(t.startsWith("slide:"))return void z.V({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(()=>Ee(()=>[o.getBoundingClientRect()]),c?0:450))};let Me=()=>{if(!L){for(let e of $)e.C();for(let e of ke)$e(e);S?.C(),Z.C(),P=requestAnimationFrame(Me)}},Ae=e=>{if("Escape"===e.key)return ye();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&&!(e=>{let t=e.composedPath()[0];return t instanceof Element&&null!==t.closest(le)})(e)){if(e.preventDefault(),S?.Ge()&&S.Ee())return;ve(!y.p,!0)}},Ce=e=>{if(G.T(e)||f.has(e))return;let t=window.getSelection();t&&!t.isCollapsed||be()},qe=()=>{s.t.style.setProperty("--pu-pop",`${Yt()}px`);let t=oo(e.root,"column"===y.mode);t!==y.mode?(y.mode=t,Le()):re()};function Ne(){let e=performance.now();0===A&&(C=e),window.clearTimeout(A);let t=Math.min(120,Math.max(0,C+1e3-e));A=window.setTimeout(()=>{A=0,J(),re()},t)}let Re=new MutationObserver(e=>{e.every(e=>s.element.contains(e.target))||Ne()});window.addEventListener("keydown",Ae),window.addEventListener("click",Ce),window.addEventListener("resize",qe),Re.observe(e.root,{subtree:!0,childList:!0,characterData:!0});let ze=0,De=t=>{let n="dark"===t;n!==r&&(r=n,window.clearTimeout(ze),s.t.classList.add("sw"),ze=window.setTimeout(()=>{Qn(s.t,Xn(e.root,t)),d.dark(n),s.t.classList.remove("sw")},170))},Oe=()=>De(a()),Fe=0,Ie=()=>{Fe||(Fe=window.setTimeout(()=>{Oe(),Fe=window.setTimeout(()=>{Fe=0,Oe()},450)},150))},Be=new MutationObserver(e=>{e.every(e=>e.target===s.element)||Ie()});Be.observe(document.documentElement,{attributes:!0,subtree:!0});let je=window.matchMedia?.("(prefers-color-scheme: dark)");je?.addEventListener?.("change",Ie);let He=new ResizeObserver(Ne);He.observe(e.root);let Ke=e.doc.onChange((e,t,n)=>{Z.Ie(t,n),J(),re()});return J(),Le(),P=requestAnimationFrame(Me),{ctx:G,appearance:()=>o,destroy(){L=!0,cancelAnimationFrame(P),cancelAnimationFrame(te),cancelAnimationFrame(O),z.destroy(),window.clearTimeout(oe),window.clearTimeout(M),window.clearTimeout(A),window.clearTimeout(T),Re.disconnect(),We.go=void 0,He.disconnect(),Be.disconnect(),je?.removeEventListener?.("change",Ie),window.clearTimeout(Fe),window.clearTimeout(ze),Ke(),window.removeEventListener("keydown",Ae),window.removeEventListener("click",Ce),window.removeEventListener("resize",qe),S?.destroy();for(let e of $)e.destroy();Z.destroy(),d.remove(),s.destroy()}}}var lo=null;function so(e={}){if(Tt)return Tt.mount(e);if(!Nt())return Promise.reject(new Error("pipeup: another copy of Pipeup owns the add-on queue. Remove one script."));if(lo)return lo;let t=async function(e,t){let n,o,r=document.documentElement.getAttribute("data-pipeup-doc"),{id:a,key:l}=r?await H(r):{id:`page-${i(location.origin+location.pathname)}`,key:null},s=!1;if(e.store)n=e.store,o=await Q(n);else try{let e=ee.open();n=await function(e){return new Promise((t,n)=>{let o=setTimeout(()=>n(new Error("timed out")),4e3);e.then(t,n).finally(()=>clearTimeout(o))})}(e).catch(t=>{throw e.then(e=>e.close(),()=>{}),t}),o=await Q(n)}catch{n=new X,s=!0,o=await Q(n)}let d=e.name?.trim();d&&d!==o.name&&(o={...o,name:d},await n.saveProfile(o)),navigator.storage?.persist?.().catch(()=>{});let c,u=await _.open({doc:a,key:l,store:n,identity:o.identity,name:o.name});Fn(e.slides??null);try{c=ao({doc:u,styles:':host{all:initial;direction:ltr;unicode-bidi:normal}*{box-sizing:border-box}button{appearance:none;font:inherit;color:inherit;background:none;border:0;padding:0;cursor:pointer}svg{display:block}.layer{all:initial;direction:ltr;unicode-bidi:normal;display:block;position:fixed;inset:0;pointer-events:none;font:13px/1.5 var(--pu-font,system-ui,sans-serif);color:var(--k);--k:#2C2C2A;--mu:#5F5E5A;--fa:#6B6A64;--ln:#E5E3DA;--ru:#ECEAE2;--so:#FAFAF7;--su:#FFFFFF;--ho:#F1EFE8;--as:color-mix(in srgb,var(--pu-accent,#534AB7) 12%,transparent);--sh:0 8px 28px rgba(44,44,42,.1);--in:.26s;--mv:.34s;--out:.2s;--pl:1.2s;--eo:cubic-bezier(.22,.61,.36,1);--eio:cubic-bezier(.4,0,.2,1);--ei:cubic-bezier(.4,0,1,1);--pu-text:var(--k);--pu-muted:var(--mu);--pu-faint:var(--fa);--pu-line:var(--ln);--pu-surface:var(--su);--pu-soft:var(--so);--pu-hover:var(--ho);--pu-shadow:var(--sh);--pu-ease:var(--eo)}.layer{transition:opacity .24s var(--eo)}.layer.sw{opacity:0;transition-duration:.16s;transition-timing-function:var(--ei)}.layer.dark{--k:#ECEBE6;--mu:#B4B2A9;--fa:#9A9892;--ln:#3A3936;--ru:#34332F;--so:#22221F;--su:#1B1B19;--ho:#2C2C29;--sh:0 8px 28px rgba(0,0,0,.45)}.layer.hidden .bub,.layer.hidden .col,.layer.hidden .pop,.layer.hidden .tip,.layer.hidden .mark,.layer.hidden .selbar{opacity:0!important;pointer-events:none!important}.tx{font-size:14px;line-height:1.5;color:var(--k);white-space:pre-wrap;overflow-wrap:anywhere}.tx.del,.rest,.ctx,.ago{color:var(--fa)}.rest,.ago{font-size:12px}.rest{display:block;margin-top:3px}.hdr{position:relative;display:flex;align-items:center;gap:7px;min-height:22px}.who{min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-weight:600;color:var(--k)}.ago{flex:none;white-space:nowrap}.ago:before{content:"\\b7";margin-right:6px}.root>.tx,.it>.tx,.root>.ctx{margin-top:2px}.ctx[hidden]{display:none}.ctx{font-size:12px;margin-bottom:3px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.cd>.thread .tx{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.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{opacity:0}.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);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)}.pm button:hover,.pm button:focus-visible{background:var(--ho);outline:none}.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);outline:none}.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);outline:none}.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);outline:none}.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{pointer-events:auto}.ta{margin-left:4px;color:var(--pu-accent);text-decoration:underline;text-underline-offset:2px}.rx .n{font-size:11px}.rx.mine{background:var(--as);color:var(--pu-accent);border-color:var(--pu-accent)}.rx:disabled{cursor:default;opacity:.7}.rx.new,.rxq.new{animation:pu-in var(--mv) var(--eo) both}.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);outline:none}.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{opacity:1;visibility:visible;transform:none;transition-delay:0s}.ref .sl{width:10px;height:7px;border:1.3px solid currentColor;border-radius:2px;flex:none}.seen{display:flex;align-items:center;gap:6px;padding:6px 0 0 14px;font-size:12px;color:var(--fa)}.seen button{margin-left:auto;padding:0 6px;border:0;border-radius:6px;background:none;color:var(--fa);font:inherit;cursor:pointer;transition:color .2s var(--eo),background-color .2s var(--eo)}.seen button:hover,.seen button:focus-visible{color:var(--pu-accent);background:var(--as);outline:none}.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}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);outline:none}.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{position:absolute;left:0;right:0;top:0;padding:8px 10px 10px;background:var(--su);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{opacity:.45}.th.resolved:not(.on):not(.hot){opacity:.6}.th.lost .ctx{white-space:normal}.th.wait{opacity:0!important;pointer-events:none}.th.out{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);outline:none}.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)}.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{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;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 .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);outline:none}.namebar .nb[hidden]{display:none}.launch{position:fixed;right:0;bottom:0;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)}.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}.layer.listing .menu{right:8px;bottom:60px;z-index:1}.layer.listing .menu :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}.n{font-size:11px;font-weight:500;line-height:1;margin:-1.2px 0 0 1.2px;font-variant-numeric:tabular-nums;opacity:0;transition:opacity var(--in) var(--eo)}.n.s{font-size:8.5px;letter-spacing:-.04em}.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}.mode.else>.dot{opacity:1}.ttip{display:grid;grid-template-columns:minmax(0,0fr);overflow:hidden;font-size:12px;color:var(--mu);pointer-events:none;opacity:0;transition:grid-template-columns var(--out) var(--ei),opacity var(--out) var(--ei)}.ttip>span{min-width:0;white-space:nowrap;padding-left:10px}.ttip small{font-size:12px}.ttip small,.mi .kc{color:var(--fa)}.launch:has(.mode.on) :is(.ttip,.ttip small){color:inherit}.launch:hover .ttip{grid-template-columns:minmax(0,1fr);opacity:1;transition:grid-template-columns var(--mv) var(--eo) .4s,opacity var(--in) var(--eo) .4s}.launch .mode[aria-expanded=true]+.ttip{grid-template-columns:minmax(0,0fr);opacity:0}@media(hover:none){.ttip,.tt,.cd>.thread .acts{display:none}}.menu{position:fixed;right:8px;bottom:40px;width:290px;border-radius:12px;padding:4px;pointer-events:none;opacity:0;transform:translateY(6px);transition:opacity var(--out) var(--ei),transform var(--out) var(--ei)}.menu.show{opacity:1;transform:none;pointer-events:auto;transition:opacity var(--in) var(--eo),transform var(--mv) var(--eo)}.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);outline:none}.mi svg{color:var(--mu);flex:none}.mi small{display:block;color:var(--fa);font-size:12px}.lb{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ma{flex:none;display:grid;margin:-2px 0}.ma .av{width:20px;height:20px;font-size:11px}.mi .av svg{color:inherit}.sep{height:1px;margin:4px 10px;background:var(--ru)}.subs{display:grid;grid-template-rows:0fr;opacity:0;transition:grid-template-rows var(--in) var(--eo),opacity var(--in) var(--eo)}.subs.open{grid-template-rows:1fr;opacity:1}.subs>div{min-height:0;overflow:hidden}.subs .mi{padding-left:30px}.chev{display:grid;transition:transform var(--in) var(--eo)}[aria-expanded=true]>.chev{transform:rotate(90deg)}.tt{position:absolute;right:calc(100% + 14px);top:50%;translate:0 -50%;width:max-content;max-width:220px;padding:4px 9px;border-radius:8px;font-size:12px;line-height:1.4;color:var(--mu);pointer-events:none;opacity:0;transform:translate(3px);transition:opacity var(--out) var(--ei),transform var(--out) var(--ei)}.mi:hover>.tt,.mi:focus-visible>.tt{opacity:1;transform:none;transition:opacity var(--in) var(--eo) .5s,transform var(--in) var(--eo) .5s}@media(max-width:600px){.tt{right:8px;top:auto;bottom:100%;translate:none;transform:translateY(3px)}}.sw{position:relative;flex:none;width:26px;height:16px;border-radius:8px;background:var(--ln);transition:background-color var(--mv) var(--eio)}.sw:before,.sw:after{content:"";position:absolute;top:2px;left:2px;width:12px;height:12px;border-radius:50%;background:#fff;box-shadow:0 1px 2px #00000040;transition:transform var(--mv) var(--eio),opacity var(--mv) var(--eio)}.sw:before{opacity:0;transform:translate(10px)}[aria-checked=true]>.sw{background:var(--pu-accent)}[aria-checked=true]>.sw:after{transform:translate(10px)}.tools{display:flex;flex:none;gap:2px}.tools[hidden]{display:none}.tool[aria-pressed=true]{background:var(--as);color:var(--pu-accent)}.note{display:block;padding:0 0 4px;font-size:12px;color:var(--fa)}.note[hidden]{display:none}.ov{position:absolute;inset:0;pointer-events:none;overflow:hidden}.xb{flex:1;overflow-y:auto;overscroll-behavior:contain;padding:4px 16px 16px;font-size:13px}.xb p{margin:0 0 10px}.all,.xp{position:fixed;top:0;right:0;bottom:0;width:var(--pu-panel);display:flex;flex-direction:column;border-width:0 0 0 1px;opacity:0;transform:translate(100%);transition:transform var(--out) var(--ei),opacity var(--out) var(--ei)}.all.show,.xp.show{opacity:1;transform:none;pointer-events:auto;transition:transform var(--mv) var(--eo),opacity var(--in) var(--eo)}.all.full{width:100%}.hd{display:flex;align-items:center;gap:4px;padding:8px 8px 6px}.sp{flex:1}.tg{position:relative;display:flex;align-items:center;gap:5px;height:28px;padding:0 11px 0 9px;border-radius:99px;white-space:nowrap;line-height:1;color:var(--mu);transition:background-color .2s var(--eo),color .2s var(--eo)}.tg:hover{background:var(--ho);color:var(--k)}.tg[aria-pressed=true]{background:var(--as);color:var(--pu-accent)}.tg[aria-pressed=true]:hover{background:color-mix(in srgb,var(--pu-accent) 20%,transparent)}.tg:focus-visible{outline:2px solid var(--pu-accent);outline-offset:1px}.tg:after{content:attr(data-tip);position:absolute;left:0;top:calc(100% + 4px);z-index:3;width:max-content;max-width:220px;padding:4px 9px;border:1px solid var(--ln);border-radius:8px;background:var(--su);box-shadow:var(--sh);font-size:12px;line-height:1.4;color:var(--mu);pointer-events:none;opacity:0;transform:translateY(-3px);transition:opacity var(--out) var(--ei),transform var(--out) var(--ei)}.tg:hover:after,.tg: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;background:var(--su);border:1px solid var(--ln);border-radius:10px;transition:box-shadow var(--in) var(--eo),border-color var(--in) var(--eo),background-color .2s var(--eo)}.cd.open{border-color:transparent;box-shadow:var(--sh)}.cd.done{opacity:.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)){background:var(--so)}.cd.out{opacity:0;margin-top:0;border-width:0;overflow:hidden;transition:height var(--mv) var(--eio),margin var(--mv) var(--eio),border-width var(--mv) var(--eio),opacity var(--out) var(--ei)}.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);outline:none}.fs small{font-size:12px;color:var(--fa)}.pf .ib{width:30px;height:30px}.cx{position:fixed;inset:0;width:100%;height:100%;overflow:visible;pointer-events:none;opacity:0;transition:opacity var(--in) var(--eo)}.cx.show{opacity:1}.cx path{fill:none;stroke:var(--pu-accent);stroke-width:1.5;stroke-linecap:round;opacity:.7}.cx circle{fill:var(--pu-accent)}.layer.listing .col{opacity:0;transition:opacity var(--out) var(--ei)}.sec{padding:8px 10px 2px;font-size:12px;color:var(--fa)}.ag{display:flex;align-items:center;gap:8px;padding:6px 14px;font-size:12px;color:var(--fa);border-bottom:1px solid var(--ln)}.ag[hidden]{display:none}.lns{display:flex;flex-direction:column}.ln{display:grid;grid-template-rows:0fr;opacity:0;transition:grid-template-rows var(--in) var(--eo),opacity var(--in) var(--eo)}.ln.show{grid-template-rows:1fr;opacity:1}.ln>.lw{overflow:hidden;min-height:0}.ag button{margin-left:auto;flex:none;padding:0 6px;border-radius:6px;color:var(--fa);transition:color .2s var(--eo),background-color .2s var(--eo)}.ag button:hover:not(:disabled),.ag button:focus-visible{color:var(--pu-accent);background:var(--as);outline:none}.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);outline:none}@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:4px;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:calc(var(--pu-panel) + 16px)}@media(max-width:480px){.layer:is(.listing,:has(.xp.show)) .toast{--r:12px;bottom:64px}}@media(pointer:coarse){.mi{min-height:44px}.ib{min-width:36px;min-height:36px}.rxo{min-width:40px;min-height:40px}.refs .ref{min-height:34px}.mnl li{min-height:40px}.bts button,.tg{min-height:36px}.launch .mode{width:44px;height:44px}}@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}.tg[aria-pressed=true]{background:Highlight;color:HighlightText}}@media(prefers-reduced-motion:reduce){.ln,.subs{transition-property:opacity}@keyframes pu-in{0%{opacity:0}to{opacity:1}}.bub,.bub.in,.bub.in:hover,.bub.on,.tip,.pop,.selbar,.menu,.all,.xp,.tt,.toast,.ref .rc,.rxp,.mnl{transform:none!important}.ttip{transition-property:opacity!important}.dlg{transform:translate(-50%)!important}.sw:after{transform:none!important;transition-property:opacity}[aria-checked=true]>.sw:after{opacity:0}[aria-checked=true]>.sw:before{opacity:1}.th{transition-property:opacity,box-shadow}.tip.show,.toast{transition-property:opacity}.pick,.pick.show{transition:opacity .16s ease-in-out}.all,.all.show,.xp,.xp.show{transition-property:opacity}.namebar,.namebar.show{transform:none!important;transition:opacity .16s ease-in-out}.av,.nf,.launch{transform:none!important}@keyframes pu-pulse{0%{opacity:0}35%{opacity:.85}to{opacity:0}}}',root:e.root??document.body,onName:async e=>{u.name=e,o={...o,name:e},await n.saveProfile(o)}})}catch(e){throw Fn(null),e}s&&c.ctx.oe("This browser can't keep comments for this page \u2014 copy the comments (Copy comments \u203a As Markdown) to keep them");let p=()=>{u.flush().catch(e=>globalThis.reportError?.(e))},h=function(e){let t={...e,i:!0};Ct=t;for(let e of At.values())"waiting"===e.info.state&&Rt(e,t);return()=>{t.i=!1,Ct===t&&(Ct=null);for(let e of[...At.values()].reverse())e.stop?.(),delete e.stop;e.surface.destroy()}}({surface:c.ctx.addons,doc:u,root:e.root??document.body,ephemeral:s,version:Fe,onIdentity:async e=>{o={...o,identity:e},await n.saveProfile(o)}}),f=/\S/.test(document.documentElement.getAttribute("data-pipeup-agents")??"")?window.setTimeout(()=>{Pt().some(e=>"agents"===e.id)||console.warn("pipeup: this page lists an agent (data-pipeup-agents), but the agents add-on isn't on the page, so replies won't show. Add @pipeup/agents (see the Add-ons page).")},1e3):0;"off"!==document.documentElement.getAttribute("data-pipeup-updates")&&Date.now()-Date.parse(Ie)>31536e6&&console.info(`pipeup: this is Pipeup ${Fe}, from ${Ie}; newer versions exist. See https://github.com/pipeup-ai/pipeup/blob/main/CHANGELOG.md`);let m=!1;return window.addEventListener("pagehide",p),{document:u,comments:({all:e=!1}={})=>Oe(c.ctx.l.all(),{title:document.title,url:location.href,exportedAt:new Date,all:e}),appearance:()=>({...c.appearance()}),flush:()=>u.flush(),unmount:()=>{m||(m=!0,window.removeEventListener("pagehide",p),window.clearTimeout(f),h(),c.destroy(),Fn(null),lo===t()&&(lo=null))}}}(e,()=>t).catch(e=>{throw lo===t&&(lo=null),e});return lo=t,t}typeof document<"u"&&(Tt?console.warn(`pipeup: Pipeup is on this page twice (${Tt.VERSION} and ${Fe}); the first one is used. Remove one script.`):(Nt(),function(){let e=document.documentElement;if(!e.hasAttribute("data-pipeup-doc")||"off"===e.getAttribute("data-pipeup-auto"))return;let t=()=>{so().catch(e=>console.error(e))};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",t,{once:!0}):t()}()));const co=Object.defineProperty({},"__esModule",{value:!0});for(const[t,n]of Object.entries({ADDON_API:1,AI_NAME:v,ANIMALS:c,BUILT:Ie,COLOURS:u,DEFAULT_PROFILE_NAME:"",IndexedDbStore:ee,MemoryStore:X,PipeupDocument:_,UnsavedChangeError:U,VERSION:Fe,addons:Pt,agentComments:Oe,animalName:m,comments:async function(e){if(!lo)throw new Error("pipeup: Pipeup hasn't started on this page");return(await lo).comments(e)},computeOpId:I,copyAll:Pe,copyThread:Te,createIdentity:s,describeElement:he,describeRange:pe,formatAgo:Ce,isAiName:w,labelOf:$e,loadOrCreateProfile:Q,locate:Se,mount:so,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 zn.add(e),()=>{zn.delete(e)}},parseDocumentAttribute:H,readFeedbackFile:Y,resolveAnchor:we,setPeople:function(e){ft=e.filter(e=>e&&"string"==typeof e.name&&e.name.trim()&&ht.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[...mt])e()},setViewState:function(e){let t=null;if(e){t={};let n=0;for(let[o,r]of Object.entries(e))if(!("string"!=typeof r||"slide"===o||o.length>64||r.length>200)){if(++n>=16)break;t[o]=r}}Nn=t;for(let e of Dn)e()},signOp:T,use:qt}))Object.defineProperty(co,t,{value:n,enumerable:!0});return co})();
|
|
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 ue=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}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pipeup/identity",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0-beta.2",
|
|
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.
|
|
27
|
+
"pipeup": "0.8.0-beta.2"
|
|
28
28
|
},
|
|
29
29
|
"pipeup": {
|
|
30
30
|
"network": {
|