@pipeup/share 0.5.3 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -106,3 +106,10 @@ reviewer; it sends only its own comments (plus ones received from the shared cop
106
106
  - Works from `file://`, `http(s)` pages and hosted pages. The browser build refuses `http:` addresses.
107
107
  - Size: about 8 KB gzip.
108
108
  - Licence: MIT.
109
+
110
+ ## Keeping it intentional
111
+
112
+ Pin the script with its integrity hash (it is in the release notes), list the add-ons that may run on the page
113
+ (`<html data-pipeup-addons="share">`; without the attribute every add-on runs), and set a content security policy that allows
114
+ scripts only from the page and the CDN and connections only to the sharing address you name. This is best effort: it stops add-ons you didn't
115
+ choose, not a page that is already compromised. See the [guide](../../../docs/ADDONS_GUIDE.md).
package/dist/cli.js CHANGED
@@ -166,25 +166,25 @@ function n(e3) {
166
166
  }
167
167
  var a = /^[A-Za-z0-9_-]{43}$/;
168
168
  var s = /* @__PURE__ */ new Map();
169
- async function l() {
169
+ async function d() {
170
170
  let t2 = await crypto.subtle.generateKey({ name: "Ed25519" }, false, ["sign", "verify"]);
171
171
  return { publicKey: e(new Uint8Array(await crypto.subtle.exportKey("raw", t2.publicKey))), privateKey: t2.privateKey };
172
172
  }
173
- async function u(t2, r2) {
173
+ async function l(t2, r2) {
174
174
  let n2 = await crypto.subtle.sign({ name: "Ed25519" }, t2.privateKey, r2);
175
175
  return e(new Uint8Array(n2));
176
176
  }
177
- var d = 1e4;
178
- var c = 2 ** 40;
179
- var h = 2 ** 47;
177
+ var u = 1e4;
178
+ var h = 2 ** 40;
179
+ var c = 2 ** 47;
180
180
  var p = 1e4;
181
181
  var f = /^[0-9a-f]{8}$/;
182
182
  var m = /^[A-Za-z0-9_-]{43}$/;
183
183
  var y = /^[A-Za-z0-9_-]{43}$/;
184
- var g = /* @__PURE__ */ new Set(["create", "reply", "edit", "delete", "resolve", "reopen"]);
184
+ var g = /* @__PURE__ */ new Set(["create", "reply", "edit", "delete", "resolve", "reopen", "addressed"]);
185
185
  async function w(e3, t2) {
186
186
  if (e3.author !== t2.publicKey) throw new Error("pipeup: an op must be signed by its author");
187
- return { body: e3, sig: await u(t2, r(n(e3))) };
187
+ return { body: e3, sig: await l(t2, r(n(e3))) };
188
188
  }
189
189
  var b = (e3, t2) => "string" == typeof e3 && e3.length <= t2;
190
190
  var x = (e3) => !!e3 && "object" == typeof e3;
@@ -200,14 +200,14 @@ function A(e3) {
200
200
  }
201
201
  return true;
202
202
  }
203
- function E(e3) {
203
+ function k(e3) {
204
204
  if (!x(e3)) return false;
205
205
  let { body: t2, sig: r2 } = e3;
206
206
  if ("string" != typeof r2 || !x(t2) || JSON.stringify({ body: t2, sig: r2 }).length > 262144) return false;
207
207
  let n2 = t2;
208
- return !(1 !== n2.v || "string" != typeof n2.id || !m.test(n2.id) || !g.has(n2.kind) || !b(n2.doc, 64) || "" === n2.doc || "string" != typeof n2.thread || !m.test(n2.thread) || "string" != typeof n2.author || !y.test(n2.author) || "string" != typeof n2.name || n2.name.length > 80 || n2.name !== n2.name.trim() || "number" != typeof n2.clock || !Number.isSafeInteger(n2.clock) || n2.clock < 1 || n2.clock > c || "number" != typeof n2.at || !Number.isSafeInteger(n2.at) || n2.at < 0 || n2.at > h || void 0 !== n2.text && (!b(n2.text, d) || n2.text !== n2.text.trim()) || void 0 !== n2.target && ("string" != typeof n2.target || !m.test(n2.target)) || ("create" === n2.kind || "reply" === n2.kind || "edit" === n2.kind) && !n2.text || ("reply" === n2.kind || "edit" === n2.kind || "delete" === n2.kind) && !n2.target || "create" === n2.kind && (n2.id !== n2.thread || !A(n2.anchor)));
208
+ return !(1 !== n2.v || "string" != typeof n2.id || !m.test(n2.id) || !g.has(n2.kind) || !b(n2.doc, 64) || "" === n2.doc || "string" != typeof n2.thread || !m.test(n2.thread) || "string" != typeof n2.author || !y.test(n2.author) || "string" != typeof n2.name || n2.name.length > 80 || n2.name !== n2.name.trim() || "number" != typeof n2.clock || !Number.isSafeInteger(n2.clock) || n2.clock < 1 || n2.clock > h || "number" != typeof n2.at || !Number.isSafeInteger(n2.at) || n2.at < 0 || n2.at > c || void 0 !== n2.text && (!b(n2.text, u) || n2.text !== n2.text.trim()) || void 0 !== n2.target && ("string" != typeof n2.target || !m.test(n2.target)) || ("create" === n2.kind || "reply" === n2.kind || "edit" === n2.kind || "addressed" === n2.kind) && !n2.text || ("reply" === n2.kind || "edit" === n2.kind || "delete" === n2.kind) && !n2.target || "create" === n2.kind && (n2.id !== n2.thread || !A(n2.anchor)));
209
209
  }
210
- function k(i) {
210
+ function E(i) {
211
211
  return (async function(r2, n2, i2) {
212
212
  if (!a.test(r2)) return false;
213
213
  try {
@@ -263,7 +263,11 @@ var C = class {
263
263
  let e4 = t2.get(i.thread);
264
264
  if (!e4) continue;
265
265
  if ("resolve" === i.kind || "reopen" === i.kind) {
266
- e4.resolved = "resolve" === i.kind;
266
+ e4.resolved = "resolve" === i.kind, "reopen" === i.kind && delete e4.addressed;
267
+ continue;
268
+ }
269
+ if ("addressed" === i.kind) {
270
+ void 0 !== i.text && (e4.addressed = { text: i.text, author: i.author, name: i.name, at: i.at });
267
271
  continue;
268
272
  }
269
273
  let o = i.target ? r2.get(i.target) : void 0;
@@ -284,14 +288,14 @@ var C = class {
284
288
  async add(e3) {
285
289
  let t2 = [];
286
290
  for (let r2 of e3) {
287
- if (!E(r2) || r2.body.doc !== this.doc || this.ops.has(r2.body.id) || r2.body.id !== await S(r2.body) || !await k(r2)) continue;
291
+ if (!k(r2) || r2.body.doc !== this.doc || this.ops.has(r2.body.id) || r2.body.id !== await S(r2.body) || !await E(r2)) continue;
288
292
  let e4 = { body: r2.body, sig: r2.sig };
289
293
  this.ops.set(e4.body.id, e4), this.clock = Math.max(this.clock, e4.body.clock), "create" === e4.body.kind && this.createAt.set(e4.body.author, Math.max(this.createAt.get(e4.body.author) ?? 0, e4.body.at)), this.threadAt.set(e4.body.thread, Math.max(this.threadAt.get(e4.body.thread) ?? 0, e4.body.at)), t2.push(e4);
290
294
  }
291
295
  return t2;
292
296
  }
293
297
  async append(e3, t2, r2) {
294
- let n2 = { v: 1, ...r2, id: "", thread: "create" === r2.kind ? "" : r2.thread, doc: this.doc, author: e3.publicKey, name: t2, clock: Math.min(this.clock + 1, c), at: Math.min(Math.max(Date.now(), "create" === r2.kind ? (this.createAt.get(e3.publicKey) ?? 0) + 1 : (this.threadAt.get(r2.thread) ?? 0) + 1), h) };
298
+ let n2 = { v: 1, ...r2, id: "", thread: "create" === r2.kind ? "" : r2.thread, doc: this.doc, author: e3.publicKey, name: t2, clock: Math.min(this.clock + 1, h), at: Math.min(Math.max(Date.now(), "create" === r2.kind ? (this.createAt.get(e3.publicKey) ?? 0) + 1 : (this.threadAt.get(r2.thread) ?? 0) + 1), c) };
295
299
  n2.id = await S(n2);
296
300
  let i = this.ops.get(n2.id);
297
301
  if (i) return i;
@@ -393,7 +397,7 @@ var K = class e2 {
393
397
  }
394
398
  sign(e3, t2) {
395
399
  if (!L.test(e3)) throw new Error('pipeup: a signing purpose looks like "<add-on id>/<name>"');
396
- return u(this.options.identity, r(`pipeup:${e3}
400
+ return l(this.options.identity, r(`pipeup:${e3}
397
401
  ${t2}`));
398
402
  }
399
403
  flush() {
@@ -502,7 +506,7 @@ ${t2}`));
502
506
  function _(e3) {
503
507
  let t2 = e3.trim();
504
508
  if (!t2) throw new Error("pipeup: a comment needs some words");
505
- if (t2.length > d) throw new Error(`pipeup: comments are limited to ${d} characters`);
509
+ if (t2.length > u) throw new Error(`pipeup: comments are limited to ${u} characters`);
506
510
  return t2;
507
511
  }
508
512
  function B(e3) {
@@ -985,7 +989,7 @@ async function feedbackOps(file, docAttr, io) {
985
989
  doc: id,
986
990
  key,
987
991
  store: new G(),
988
- identity: await l(),
992
+ identity: await d(),
989
993
  name: ""
990
994
  });
991
995
  try {
@@ -1,2 +1,2 @@
1
- "use strict";var Pipeup=(()=>{var e=Object.defineProperty,t=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,i={};function r(e){let t="";for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function a(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 l(e){return(new TextEncoder).encode(e)}function s(e){if(null===e||"object"!=typeof e)return JSON.stringify(e);if(Array.isArray(e))return"["+e.map(s).join(",")+"]";let t=e;return"{"+Object.keys(t).filter(e=>void 0!==t[e]).sort().map(e=>JSON.stringify(e)+":"+s(t[e])).join(",")+"}"}function d(e){return e.replace(/\s+/g," ").trim()}function c(e){let t=d(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")}((t,n)=>{for(var o in n)e(t,o,{get:n[o],enumerable:!0})})(i,{ADDON_API:()=>Ct,AI_NAME:()=>B,ANIMALS:()=>q,COLOURS:()=>O,DEFAULT_PROFILE_NAME:()=>Q,IndexedDbStore:()=>ne,MemoryStore:()=>Z,PipeupDocument:()=>G,UnsavedChangeError:()=>_,VERSION:()=>Ue,addons:()=>Rt,animalName:()=>F,computeOpId:()=>P,copyAll:()=>He,copyThread:()=>Be,createIdentity:()=>h,describeElement:()=>we,describeRange:()=>ge,formatAgo:()=>Ie,isAiName:()=>H,labelOf:()=>Oe,loadOrCreateProfile:()=>te,locate:()=>ze,mount:()=>Ro,nameOf:()=>I,newDocumentAttribute:()=>W,onReveal:()=>oo,parseDocumentAttribute:()=>K,resolveAnchor:()=>Me,setViewState:()=>no,signOp:()=>k,use:()=>Dt});var u=/^[A-Za-z0-9_-]{43}$/,p=new Map;async function h(){let e=await crypto.subtle.generateKey({name:"Ed25519"},!1,["sign","verify"]);return{publicKey:r(new Uint8Array(await crypto.subtle.exportKey("raw",e.publicKey))),privateKey:e.privateKey}}async function f(e,t){let n=await crypto.subtle.sign({name:"Ed25519"},e.privateKey,t);return r(new Uint8Array(n))}var m=2**40,v=2**47,g={doc:64,path:2e3,snapshot:500,anchorId:200,quote:1e4,context:64,viewEntries:16,viewKey:64,viewValue:200},w=/^[0-9a-f]{8}$/,y=/^[A-Za-z0-9_-]{43}$/,b=/^[A-Za-z0-9_-]{43}$/,x=new Set(["create","reply","edit","delete","resolve","reopen"]);async function k(e,t){if(e.author!==t.publicKey)throw new Error("pipeup: an op must be signed by its author");return{body:e,sig:await f(t,l(s(e)))}}var E=(e,t)=>"string"==typeof e&&e.length<=t,S=e=>!!e&&"object"==typeof e,$=e=>"number"==typeof e&&Number.isFinite(e)&&e>=0&&e<=1;function L(e){if(!S(e))return!1;let{id:t,path:n,fingerprint:o,snapshot:i,quote:r,point:a,view:l}=e;if(!(E(n,g.path)&&E(i,g.snapshot)&&"string"==typeof o&&w.test(o)&&(void 0===t||E(t,g.anchorId)&&""!==t)&&(void 0===r||S(r)&&E(r.exact,g.quote)&&""!==r.exact&&E(r.prefix,g.context)&&E(r.suffix,g.context))&&(void 0===a||S(a)&&$(a.x)&&$(a.y))))return!1;if(void 0!==l){if(!S(l)||Array.isArray(l))return!1;let e=Object.entries(l);if(e.length>g.viewEntries||!e.every(([e,t])=>e.length<=g.viewKey&&E(t,g.viewValue)))return!1}return!0}function M(e){if(!S(e))return!1;let{body:t,sig:n}=e;if("string"!=typeof n||!S(t)||JSON.stringify({body:t,sig:n}).length>262144)return!1;let o=t;return!(1!==o.v||"string"!=typeof o.id||!y.test(o.id)||!x.has(o.kind)||!E(o.doc,g.doc)||""===o.doc||"string"!=typeof o.thread||!y.test(o.thread)||"string"!=typeof o.author||!b.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>m||"number"!=typeof o.at||!Number.isSafeInteger(o.at)||o.at<0||o.at>v||void 0!==o.text&&(!E(o.text,1e4)||o.text!==o.text.trim())||void 0!==o.target&&("string"!=typeof o.target||!y.test(o.target))||("create"===o.kind||"reply"===o.kind||"edit"===o.kind)&&!o.text||("reply"===o.kind||"edit"===o.kind||"delete"===o.kind)&&!o.target||"create"===o.kind&&(o.id!==o.thread||!L(o.anchor)))}function C(e){return async function(e,t,n){if(!u.test(e))return!1;try{if(r(a(e))!==e)return!1;let o=p.get(e);if(!o){p.size>=512&&p.delete(p.keys().next().value),o=crypto.subtle.importKey("raw",a(e),{name:"Ed25519"},!0,["verify"]),p.set(e,o);let t=o;t.catch(()=>{p.get(e)===t&&p.delete(e)})}return await crypto.subtle.verify({name:"Ed25519"},await o,a(n),t)}catch{return!1}}(e.body.author,l(s(e.body)),e.sig)}function A(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 T(e,t,n,o,i){return{id:e,author:t,name:n,text:o,at:i,edited:!1,deleted:!1,replies:[]}}async function P(e){let t={...e,id:void 0,thread:"create"===e.kind?void 0:e.thread},n=await crypto.subtle.digest("SHA-256",l(s(t)));return r(new Uint8Array(n))}var N=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:i}of[...e].sort(A)){if(i.name&&o.set(i.author,i.name),"create"===i.kind){if(t.has(i.id)||!i.anchor||void 0===i.text)continue;let e=T(i.id,i.author,i.name,i.text,i.at);t.set(i.id,{id:i.id,anchor:i.anchor,root:e,resolved:!1}),n.set(i.id,{comment:e,thread:i.id});continue}let e=t.get(i.thread);if(!e)continue;if("resolve"===i.kind||"reopen"===i.kind){e.resolved="resolve"===i.kind;continue}let r=i.target?n.get(i.target):void 0;if(r&&r.thread===i.thread){if("reply"===i.kind){if(n.has(i.id)||void 0===i.text)continue;let t=T(i.id,i.author,i.name,i.text,i.at);e.root.replies.push(t),n.set(i.id,{comment:t,thread:i.thread});continue}i.author!==r.comment.author||r.comment.deleted||("edit"===i.kind&&void 0!==i.text&&(r.comment.text=i.text,r.comment.edited=!0),"delete"===i.kind&&(r.comment.text="",r.comment.deleted=!0))}}for(let{comment:e}of n.values())e.name||(e.unnamed=!0,e.name=o.get(e.author)??"");return[...t.values()]}(this.ops.values())}async add(e){let t=[];for(let n of e){if(!M(n)||n.body.doc!==this.doc||this.ops.has(n.body.id)||n.body.id!==await P(n.body)||!await C(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,m),at:Math.min(Math.max(Date.now(),"create"===n.kind?(this.createAt.get(e.publicKey)??0)+1:(this.threadAt.get(n.thread)??0)+1),v)};o.id=await P(o);let i=this.ops.get(o.id);if(i)return i;"create"===o.kind&&(o.thread=o.id);let[r]=await this.add([await k(o,e)]);if(!r)throw new Error("pipeup: could not record this change");return r}},q=["Otter","Fox","Owl","Bear","Rabbit"],O=["Red","Orange","Yellow","Green","Teal","Blue","Purple","Pink","Brown","Grey"];function z(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 R=e=>z(e)%q.length,D=e=>Math.floor(z(e)/q.length)%O.length,F=e=>`${O[D(e)]} ${q[R(e)]}`,I=e=>e.name||F(e.author),B="AI assistant",H=e=>e===B||e.startsWith(`${B} `),j=/^([A-Za-z0-9_-]{16}):([A-Za-z0-9_-]{43})$/;function W(){return`${function(e=16){return r(crypto.getRandomValues(new Uint8Array(e)))}(12)}:${r(crypto.getRandomValues(new Uint8Array(32)))}`}async function K(e){let t=j.exec(e.trim()),n=t?.[1],o=t?.[2];if(!n||!o)throw new Error('pipeup: data-pipeup-doc must look like "<id>:<key>", as made by newDocumentAttribute()');return{id:n,key:await crypto.subtle.importKey("raw",a(o),{name:"AES-GCM"},!1,["encrypt","decrypt"])}}async function V(e,t,n){let o=crypto.getRandomValues(new Uint8Array(12)),i=await crypto.subtle.encrypt({name:"AES-GCM",iv:o,additionalData:l(n)},e,l(t));return{iv:r(o),data:r(new Uint8Array(i))}}var U=e=>`pipeup-file:${e}`;var Y=/^[a-z][a-z0-9-]{1,23}\/[a-z][a-z0-9-]{0,31}$/,_=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"}},G=class e{constructor(e,t){this.log=e,this.options=t,this.displayName=t.name.trim()?X(t.name):""}listeners=new Set;cache=[];comments=new Map;displayName;le=Promise.resolve();unsaved=[];static async open(t){if("string"!=typeof t.doc||""===t.doc||t.doc.length>g.doc)throw new Error(`pipeup: the document id must be 1 to ${g.doc} characters`);let n=new N(t.doc),o=await t.store.load(t.doc),i=o.length-(await n.add(o)).length;i&&console.warn(`pipeup: ${i} saved change${1===i?"":"s"} on this page couldn't be read; kept as saved`);let r=new e(n,t);return r.refresh(!1),r}get id(){return this.options.doc}get me(){return this.options.identity.publicKey}get name(){return this.displayName}set name(e){this.displayName=X(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){return this.enqueue(()=>this.write({kind:"create",anchor:e,text:J(t)}))}reply(e,t){return this.enqueue(()=>this.write({kind:"reply",thread:this.find(e).thread,target:e,text:J(t)}))}edit(e,t){return this.enqueue(async()=>{let{thread:n}=this.mine(e);await this.write({kind:"edit",thread:n,target:e,text:J(t)})})}remove(e){return this.enqueue(async()=>{let{thread:t}=this.mine(e);await this.write({kind:"delete",thread:t,target:e})})}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 f(this.options.identity,l(`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 V(n,JSON.stringify(t),U(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 async function(e,t,n){if(e.length>5e6)throw new Error("pipeup: this feedback file is too large");let o,i,r;try{o=JSON.parse(e)}catch{throw new Error("pipeup: this is not an Pipeup feedback file")}if(!o||"object"!=typeof o||1!==o.pipeup||"string"!=typeof o.doc)throw new Error("pipeup: this is not an Pipeup feedback file");if(o.doc!==t)throw new Error("pipeup: this feedback is for a different document");if(!o.sealed)return Array.isArray(o.ops)?o.ops:[];if(!n)throw new Error("pipeup: this feedback is sealed, and this page has no document key");if("string"!=typeof o.iv||"string"!=typeof o.data)throw new Error("pipeup: this is not an Pipeup feedback file");try{i=await async function(e,t,n){try{let o=await crypto.subtle.decrypt({name:"AES-GCM",iv:a(t.iv),additionalData:l(n)},e,a(t.data));return(new TextDecoder).decode(o)}catch{throw new Error("pipeup: this feedback could not be opened with this document")}}(n,{iv:o.iv,data:o.data},U(t))}catch{throw new Error("pipeup: this feedback could not be opened with this document's key")}try{r=JSON.parse(i)}catch{throw new Error("pipeup: this is not an Pipeup feedback file")}return Array.isArray(r)?r:[]}(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 _(n[0].body.id,e,n.length):e}return n.length})}enqueue(e){let t=this.le.then(e);return this.le=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 _(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 J(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 X(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(H(t))throw new Error("pipeup: that name is kept for AI replies; choose another");return t}var Z=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}},Q="",ee="Reviewer";async function te(e,t=Q){let n=await e.loadProfile();if(n)return n.name===ee?{...n,name:""}:n;let o={identity:await h(),name:t};return e.saveProfileIfAbsent(o)}var ne=class e{constructor(e){this.db=e}static open(t="pipeup"){return new Promise((n,o)=>{let i=indexedDB.open(t,1);i.onupgradeneeded=()=>{let e=i.result;e.createObjectStore("ops",{keyPath:["doc","id"]}).createIndex("doc","doc"),e.createObjectStore("meta")},i.onsuccess=()=>{let t=i.result;t.onversionchange=()=>t.close(),n(new e(t))},i.onerror=()=>o(i.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"),i=oe(n);try{for(let n of t)o.put({doc:e,id:n.body.id,op:n})}catch(e){throw n.abort(),i.catch(()=>{}),e}await i}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=oe(t),i=e,r=n.get("profile");return r.onsuccess=()=>{r.result?i=r.result:n.put(e,"profile")},await o,i}request(e,t,n){return new Promise((o,i)=>{let r=n(this.db.transaction(e,t).objectStore(e));r.onsuccess=()=>o(r.result),r.onerror=()=>i(r.error??new Error("pipeup: local storage request failed"))})}};function oe(e){return new Promise((t,n)=>{e.oncomplete=()=>t(),e.onerror=()=>n(e.error??new Error("pipeup: local storage write failed")),e.onabort=()=>n(e.error??new Error("pipeup: local storage write aborted"))})}function ie(e){let t=(e.ownerDocument??e).createTreeWalker(e,NodeFilter.SHOW_TEXT),n=[],o="";for(let e=t.nextNode();e;e=t.nextNode())n.push({node:e,start:o.length}),o+=e.data;return{text:o,nodes:n}}function re(e,t,n){let o=(e.ownerDocument??e).createRange();return o.setStart(e,0),o.setEnd(t,n),o.toString().length}function ae(e,t,n){let o=le(e,t,!1),i=le(e,n,!0);if(!o||!i||n<t)return null;let r=o.node.ownerDocument.createRange();return r.setStart(o.node,o.offset),r.setEnd(i.node,i.offset),r}function le(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}}var se=32,de=200,ce="p,li,h1,h2,h3,h4,h5,h6,td,th,blockquote,pre,figcaption,dt,dd,summary,caption";function ue(e){return e.nodeType===Node.ELEMENT_NODE?e:e.parentElement}function pe(e,t){for(let n=ue(e)?.closest("[data-pipeup-id]")??null;n;){if(!t.contains(n))return null;let e=n.getAttribute("data-pipeup-id")??"";if(""!==e&&e.length<=g.anchorId)return n;n=n.parentElement?.closest("[data-pipeup-id]")??null}return null}function he(e,t,n){return e.slice(t,n).replace(/^[\uDC00-\uDFFF]|[\uD800-\uDBFF]$/g,"")}function fe(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>g.path)throw new Error("pipeup: this element is nested too deeply to comment on — give a nearby container a data-pipeup-id");return n}function me(e){if(!L(e))throw new Error("pipeup: could not describe this place on the page");return e}function ve(e,t){let n=ue(e),o=n?.closest(ce)??null;return o&&t.contains(o)?o:n&&t.contains(n)?n:t}function ge(e,t,n){if(!t.contains(e.commonAncestorContainer))throw new Error("pipeup: the selection is outside the commentable area");let o=pe(e.commonAncestorContainer,t),i=o??t,{text:r}=ie(i),a=re(i,e.startContainer,e.startOffset),l=re(i,e.endContainer,e.endOffset),s=r.slice(a,l);if(""===s)throw new Error("pipeup: select some text to comment on");if(s.length>g.quote)throw new Error(`pipeup: selections are limited to ${g.quote} characters`);let u=he(r,Math.max(0,a-se),a),p=he(r,l,l+se);return me({...o?{id:o.getAttribute("data-pipeup-id")??""}:{},path:"",quote:{exact:s,prefix:u,suffix:p},...n?{view:n}:{},fingerprint:c(ve(e.startContainer,t).textContent??""),snapshot:he(d(u+s+p),0,de)})}function we(e,t,n,o){let i=pe(e,t);return me({...i?{id:i.getAttribute("data-pipeup-id")??""}:{},path:fe(i??t,e),...n?{point:{x:ye(n.x),y:ye(n.y)}}:{},...o?{view:o}:{},fingerprint:c(e.textContent??""),snapshot:he(d(e.textContent??""),0,de)})}function ye(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):0}function be(e,t,n){let o=Array.from({length:t.length+1},(e,t)=>t),i=[...o],r=[t.length];for(let a=1;a<=e.length;a++){i[0]=n?0:a;for(let n=1;n<=t.length;n++){let r=e.charCodeAt(a-1)===t.charCodeAt(n-1)?0:1;i[n]=Math.min(o[n]+1,i[n-1]+1,o[n-1]+r)}r.push(i[t.length]),[o,i]=[i,o]}return r}var xe=(e,t)=>be(e,t,!1).pop(),ke={state:"orphaned",element:null,range:null},Ee=5e4,Se=300,$e=12,Le=":scope > ";function Me(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,i){let r=n??o,a=ie(r),l=function(e,t){if(!t.exact)return-1;let n=-1,o=-1;for(let i=e.indexOf(t.exact);-1!==i;i=e.indexOf(t.exact,i+1)){let r=e.slice(Math.max(0,i-t.prefix.length),i),a=e.slice(i+t.exact.length,i+t.exact.length+t.suffix.length),l=Ae(r,t.prefix)+Ce(a,t.suffix);l>o&&(n=i,o=l)}return n}(a.text,t);if(l>=0){let i=ae(a,l,l+t.exact.length);if(i){let t=ve(i.startContainer,o);return{state:null!==n&&c(t.textContent??"")===e.fingerprint?"attached":"moved",element:t,range:i}}}if(i){let e=r===o?a:ie(o);if(e.text.length<=Ee&&t.exact.length>=$e&&t.exact.length<=Se){let n=function(e,t,n){let o=t.length;if(0===o)return null;let i=-1,r=1/0;if(be(e,t,!0).forEach((e,t)=>{t&&e<r&&(r=e,i=t)}),r>n)return null;let a=Math.max(0,i-o),l=1/0;for(let r=Math.max(0,i-o-n);r<=Math.min(i,i-o+n);r++){let n=xe(e.slice(r,i),t);n<l&&(l=n,a=r)}return{start:a,end:i,distance:l}}(e.text,t.exact,Math.floor(t.exact.length/4)),i=n?ae(e,n.start,n.end):null;if(i)return{state:"moved",element:ve(i.startContainer,o),range:i}}}return ke}(e,e.quote,o,t,!1!==n.fuzzy):function(e,t){if(!t)return ke;let n=t;if(e.path){if(!e.path.startsWith(Le))return ke;try{n=t.querySelector(e.path)}catch{return ke}}return n?{state:c(n.textContent??"")===e.fingerprint?"attached":"moved",element:n,range:null}:ke}(e,o)}function Ce(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;return n}function Ae(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 Te={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"},Pe=40;function Ne(e){return e.getAttribute("data-pipeup-label")||Te[e.tagName.toUpperCase()]||"Block"}function qe(e){return De(d(e.getAttribute("aria-label")??e.getAttribute("alt")??e.innerText??e.textContent??""),Pe)}function Oe(e){let t=e.getAttribute("data-pipeup-label");if(t)return t;let n=qe(e);return n?`${Ne(e)} · ${n}`:Ne(e)}function ze(e,t,n){let o=e.id??null,i=e.quote?.exact??null,r=e.point?`${Math.round(100*e.point.x)}% across, ${Math.round(100*e.point.y)}% down the element`:null,a=t.element;if("orphaned"===t.state||!a)return{where:`No longer on the page (it read: "${e.snapshot}")`,element:null,id:o,quote:i,pin:r};let l=[],s=e.view?.slide;if(s){let e=a.closest("[data-pipeup-slide]")?.querySelector("h1,h2,h3")?.textContent;l.push(`Slide ${s}`+(e?` "${De(d(e))}"`:""))}else{let t=Re(e.view);t&&l.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}(a,n);o&&l.push(`Section "${De(d(o.textContent??""))}"`)}let c=Oe(a);return l.push(c),{where:l.join(" › "),element:c,id:o,quote:i,pin:r}}function Re(e){return e?e.label||Object.entries(e).filter(([e,t])=>t&&"slide"!==e).map(([,e])=>e).join(" · "):""}function De(e,t=60){return e.length>t?e.slice(0,t-1)+"…":e}var Fe="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.";function Ie(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 i=Math.round(o/60);return i<48?`${i}h ago`:`${Math.round(i/24)}d ago`}function Be(e,t,n,o){return"ai"===t?We(e,"## Comment thread",o,n):Ke(e)}function He(e,t,n){let o=e.filter(e=>!e.thread.resolved);if("text"===t)return o.map(Ke).join("\n");let i=e.length-o.length,r=[`# Review comments: ${je(n.title)}`,"",`- **Page:** ${je(n.url)}`,`- **Exported:** ${n.exportedAt.toISOString()}`,`- **Open threads:** ${o.length}${i?` (${i} resolved, not included)`:""}`,"",Fe,"",""].join("\n"),a=n.exportedAt.getTime();return r+o.map((e,t)=>We(e,`## Thread ${t+1}`,a)).join("\n")}function je(e){return e.replace(/\s+/g," ").trim()}function We(e,t,n,o){let{thread:i,location:r}=e,a=i.root.replies.length,l=[`${t} · ${i.resolved?"resolved":"open"}`];if(l.push(`- **Thread:** ${i.id}`),o&&l.push(`- **Page:** ${je(o)}`),l.push(`- **Where:** ${je(r.where)}`),r.id){let e=je(r.id.replace(/`/g,""));l.push(`- **Element:** \`[data-pipeup-id="${e}"]\`${r.element?` (${je(r.element)})`:""}`)}r.quote&&l.push(`- **Quoted text:** "${je(r.quote)}"`),r.pin&&l.push(`- **Pin:** ${je(r.pin)}`),l.push(`- **Started by:** ${je(I(i.root))}, ${Ie(i.root.at,n)}${a?` · ${a} ${1===a?"reply":"replies"}`:""}`,"",`**${je(I(i.root))}** (${Ie(i.root.at,n)}): ${Ve(i.root," ")}`);for(let e of i.root.replies)l.push(`- **${je(I(e))}** (${Ie(e.at,n)}): ${Ve(e," ")} \x3c!-- comment:${e.id} --\x3e`);return l.join("\n")+"\n"}function Ke(e){let{thread:t,location:n}=e,o=[je(n.where)+(n.quote?`, on the text "${je(n.quote)}"`:""),`${je(I(t.root))}: ${Ve(t.root," ")}`];for(let e of t.root.replies)o.push(` ${je(I(e))}: ${Ve(e," ")}`);return o.join("\n")+"\n"}function Ve(e,t){return e.deleted?"(deleted)":e.text.replace(/\r\n|\r|\n/g,"\n"+t)+(e.edited?" (edited)":"")}var Ue="0.5.3",Ye=new Map,_e=new Map,Ge=new Map,Je={},Xe=e=>`${Ye.get(e)??""}|${_e.get(e)??""}`;function Ze(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 Qe(e,t){let n=e.getRootNode().activeElement;t&&n instanceof HTMLElement&&e.contains(n)&&n.blur(),e.inert=t}function et(e,t,n=null){let o=e.getRootNode().activeElement,i=!1;for(let o=t.length;o--;n=t[o])t[o].nextSibling!==n&&(i=!!e.insertBefore(t[o],n));return i&&o&&t.some(e=>e.contains(o))&&o.focus({preventScroll:!0}),i}var tt=()=>{let e=window.getSelection();return e&&!e.isCollapsed&&e.toString().trim()?e:null};function nt(e,t){return e.length>t?e.slice(0,t-1)+"…":e}function ot(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 it=/\bhttps?:\/\/[^\s<>"'`]+/gi,rt=".,;:!?'\"]}",at=2048,lt=/[\u202A-\u202E\u2066-\u2069]/;function st(e){let t=0,n=0;for(let o of e)"("===o?t++:")"===o&&n++;let o=e.length;for(;o>0;){let i=e[o-1];if(")"===i&&n>t)n--;else if(!rt.includes(i))break;o--}return e.slice(0,o)}function dt(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>at||lt.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 ct(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?Ze("i",{class:"sl"}):null,Ze("span",{},t||""===e.label?n:`[${e.n}] ${n}`),e.says?Ze("span",{class:"rc",role:"tooltip"},e.says):null];if(/^https?:/.test(e.to)){let t=Ze("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 i=Ze("button",{class:"ref",type:"button",title:e.says?void 0:t?n:`Show where: ${n}`},...o);return i.addEventListener("click",t=>{t.stopPropagation(),Je.go?.(e.to)}),i});return[...ct(n),Ze("div",{class:"refs"},...o)]}function ct(e){let t=[],n=0;for(let o of e.matchAll(it)){if(o[0].length>at||lt.test(o[0]))continue;let i,r=st(o[0]),a=o.index??0;try{let e=new URL(r);if("http:"!==e.protocol&&"https:"!==e.protocol)continue;i=e.href}catch{continue}a>n&&t.push(e.slice(n,a));let l=Ze("a",{href:i,target:"_blank",rel:"noopener noreferrer"},r);l.addEventListener("click",e=>e.stopPropagation()),t.push(l),n=a+r.length}return n<e.length&&t.push(e.slice(n)),t}var ut="http://www.w3.org/2000/svg",pt={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"],edit:["M4 20h4L19 9l-4-4L4 16z"]};function ht(e,t=15,n){let o=ft(pt[e],t);return n&&o.setAttribute("stroke-width",String(n)),o}function ft(e,t){let n=document.createElementNS(ut,"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(ut,"path");e.setAttribute("d",t),n.append(e)}return n}var mt=(e,t,n)=>`M${e} ${t}a${n} ${n} 0 1 0 ${2*n} 0a${n} ${n} 0 1 0 -${2*n} 0`,vt={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${mt(7.4,11.5,1.9)}${mt(12.8,11.5,1.9)}M11.3 14.6l.7 1 .7-1`,Bear:`${mt(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:`${mt(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 gt(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 wt=(e,t)=>gt(t)||F(e);function yt(e,t,n=!1){return H(t)?Ze("span",{class:n?"av ai busy":"av ai","aria-hidden":"true"},"AI"):Ze("span",{class:`av c${D(e)}`,"aria-hidden":"true","data-animal":F(e)},gt(t)||ft([vt[q[R(e)]]],24))}var bt=320;function xt(e,t){setTimeout(()=>{e.remove(),t?.()},bt)}function kt(e){return requestAnimationFrame(()=>{e.offsetWidth,e.classList.add("in")}),e}var Et=null,St=e=>{Et=e},$t=()=>Et?.note()??null,Lt="pu-source";function Mt(e){let t=Ze("textarea",{class:"input",rows:"1","aria-label":e.label}),n=Ze("button",{class:"send",type:"button","aria-label":"Send",title:"Send",inert:!0},ht("send")),o=Ze("span",{class:"tools"});o.hidden=!0;let i=Ze("div",{class:"row"},e.before,t,o,n),r=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,i)=>{e<0&&(e=t.selectionStart,n=0);let r=t.value.slice(0,e),a=o&&r&&!/\s$/.test(r)&&!/^\s/.test(o)?" ":"";t.setRangeText(a+o,e,e+n,"end"),n=a.length+o.length,i&&(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()}}},u=new Map,p=()=>{let n=(Et?.tools()??[]).filter(e=>!1!==e.available?.());for(let[e,t]of u)n.some(t=>t.id===e)||(t.remove(),u.delete(e));for(let a of n){if(u.has(a.id))continue;let n=Ze("button",{class:"ib tool",type:"button","aria-label":a.label,title:a.label,"aria-pressed":"false"},ft(a.icon,15));n.addEventListener("mousedown",e=>e.preventDefault()),n.addEventListener("click",o=>{o.stopPropagation();try{a.press({kind:r,thread:e.thread?.()??null,text:()=>t.value,focus:()=>t.focus({preventScroll:!0}),connected:()=>i.isConnected,setPressed:e=>n.setAttribute("aria-pressed",String(e)),dictate:c,onEnd:e=>(l.add(e),()=>l.delete(e))})}catch(e){globalThis.reportError?.(e)}}),u.set(a.id,n),o.append(n)}o.hidden=0===u.size};p(),i.addEventListener(Lt,p);let h=async()=>{let o=t.value.trim();if(o&&!a){a=!0;try{await e._(o),n.matches(":focus")&&t.focus(),t.value="",d(),s()}catch{}finally{a=!1}}};return i.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),t.addEventListener("keydown",n=>{n.stopPropagation(),"Enter"!==n.key||n.shiftKey||n.isComposing?"Escape"===n.key&&(n.preventDefault(),t.value="",d(),t.blur(),s(),e.q?.()):(n.preventDefault(),h())}),n.addEventListener("click",e=>{e.stopPropagation(),h()}),{element:i,input:t,focus:()=>t.focus({preventScroll:!0})}}var Ct=1,At=["sync","menu","notify","note","composer","panel","styles","status","overlay","here","sign"],Tt=/^[a-z][a-z0-9-]{1,23}$/,Pt=new Set(["local","file","page","user","pipeup","presence","sync"]),Nt=class{constructor(e,t,n){this.ctx=e,this.shadow=t,this.after=n,St({tools:()=>this.U,note:()=>[...this.j.values()].at(-1)??null})}Y=0;$=[];j=new Map;writing=new Map;marked=new Map;paint=0;G=new Map;U=[];X=new Set;I=new Set;K=new Set;z=new Map;S=new Map;W=new Map;remote={n:0,who:new Set};last=0;timer=0;ce="";subscribe(e){return this.K.add(e),()=>{this.K.delete(e)}}changed(e){e&&this.Y++;for(let t of[...this.K])t(e);for(let e of this.ctx.t.querySelectorAll(".row, .draft"))e.dispatchEvent(new Event(Lt))}N(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}de(){return[...this.G.values()].map(e=>e.text).join(" · ")}Ae(e,t){return this.$.push(t),this.changed(!0),{update:()=>this.changed(!1),remove:this.N(e,()=>{this.$.splice(this.$.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?(Ye.delete(t),o.delete(t)):(Ye.set(t,n),o.add(t)),this.repaint()}setMark(e,t,n,o){let i=this.marked.get(e)??this.marked.set(e,new Set).get(e);if(null===n){if(Ge.delete(t),!_e.delete(t))return;i.delete(t)}else{if(_e.get(t)===n&&!!Ge.get(t)==!!o)return;_e.set(t,n),o?Ge.set(t,o):Ge.delete(t),i.add(t)}this.repaint()}repaint(){this.paint||(this.paint=window.requestAnimationFrame(()=>{this.paint=0,this.ctx.m()}))}pe(e,t,n){n?e.set(t,n):e.delete(t),this.changed(!1)}Me(e,t){return this.U.push(t),this.changed(!1),this.N(e,()=>{this.U.splice(this.U.indexOf(t),1),this.changed(!1)})}closed(){return this.ctx.state.hidden&&!this.ctx.state.c}Le(e,t){this.closed()?this.S.set(e,t):this.ctx.J(t)}flush(){if(this.closed()||0===this.S.size)return;let e=[...this.S.values()].at(-1);this.S.clear(),this.ctx.J(e)}Ce(){return this.shadow.activeElement instanceof HTMLTextAreaElement||[...this.ctx.t.querySelectorAll("textarea")].some(e=>""!==e.value.trim())}Pe(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||F(t.author)));this.ue()}}ue(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.Ce())return this.ue(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))}$e(e){let t=this.z.get(e);return t||(t=Ze("div",{class:"ov","aria-hidden":"true","data-addon":e}),this.ctx.t.insertBefore(t,this.after.nextSibling),this.z.set(e,t)),t}Ie(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 i=o??this.shadow.appendChild(Ze("style",{},t));return this.N(e,()=>o?this.shadow.adoptedStyleSheets=this.shadow.adoptedStyleSheets.filter(e=>e!==o):i.remove())}fe(e,t,n){return t.add(n),this.N(e,()=>t.delete(n))}Ne(e,t){return this.fe(e,this.X,t)}Re(e,t){let n=this.fe(e,this.I,t);return this.call(this.I,t,this.he()),n}he(){let{state:e}=this.ctx,t=this.shadow.activeElement;return{shown:!e.hidden,commentMode:e.l,allOpen:e.d,dark:this.ctx.t.classList.contains("dark"),view:this.ctx.p.view(),writing:t instanceof HTMLTextAreaElement?t.closest("[data-thread]")?.dataset.thread??"":null}}T(){for(let e of[...this.X])this.call(this.X,e);if(0===this.I.size)return;let e=this.he(),t=JSON.stringify(e);if(t!==this.ce){this.ce=t;for(let t of[...this.I])this.call(this.I,t,e)}}call(e,t,...n){try{t(...n)}catch(n){e.delete(t),globalThis.reportError?.(n)}}He(e,t,n){let o=this.ctx.t,i=this.shadow.activeElement,r=Ze("button",{class:"ib",type:"button","aria-label":"Close"},ft(["M6 6l12 12M18 6L6 18"],15)),a=Ze("div",{class:"xp",role:"dialog","aria-label":n.label,"data-addon":e},Ze("div",{class:"hd"},Ze("span",{},n.label),r),Ze("div",{class:"xb"},t)),l=[...o.children].filter(e=>e instanceof HTMLElement&&!e.inert);for(let e of l)e.inert=!0;o.append(a),a.offsetWidth,a.classList.add("show");let s=e=>{"Escape"===e.key&&(e.stopPropagation(),e.preventDefault(),d())},d=this.N(e,()=>{window.removeEventListener("keydown",s,!0);for(let e of l)e.inert=!1;a.classList.remove("show"),a.inert=!0,window.setTimeout(()=>a.remove(),300),i?.focus?.({preventScroll:!0});try{n.onClose?.()}catch(e){globalThis.reportError?.(e)}});return r.addEventListener("click",d),window.addEventListener("keydown",s,!0),(a.querySelector("button, input, textarea, select, a[href]")??a).focus?.({preventScroll:!0}),{close:d}}clear(e){for(let t of[...this.W.get(e)??[]])t();this.W.delete(e),this.z.get(e)?.remove(),this.z.delete(e);for(let t of[this.j,this.G,this.S])t.delete(e);for(let t of this.writing.get(e)??[])Ye.delete(t);this.writing.delete(e);for(let t of this.marked.get(e)??[])_e.delete(t),Ge.delete(t);this.marked.delete(e),this.repaint(),this.changed(!0)}destroy(){window.clearTimeout(this.timer),St(null),this.K.clear()}},qt=new Map,Ot=null,zt=(()=>{let e=globalThis.Pipeup;return e?.VERSION?e:null})();function Rt(){return zt?zt.addons():[...qt.values()].map(e=>({...e.info}))}function Dt(e){if(zt)return zt.use(e);let t=e=>console.warn(`pipeup: ${e}`),n=e;if(!n||"object"!=typeof n||"string"!=typeof n.id||!Tt.test(n.id)||Pt.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(qt.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"},i=(n.needs??[]).find(e=>!At.includes(e));n.api!==Ct?(o.state="off",o.reason=`needs add-on API ${String(n.api)}; this Pipeup has ${Ct}`):i&&(o.state="off",o.reason=`this Pipeup has no ${i} slot`);let r={addon:e,info:o};qt.set(n.id,r),Ot?.i&&"waiting"===o.state&&It(r,Ot)}function Ft(){if(zt)return!0;let e=globalThis,t=e.pipeupAddons;if(Array.isArray(t))for(let e of t)Dt(e);else if(t&&"object"==typeof t&&t.push!==Dt)return!1;return e.pipeupAddons={push:Dt},!0}async function It(e,t){let n,o,{addon:i,info:r}=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(),onChange:e=>{let t=d.onChange(e);return l.add(t),()=>{t(),l.delete(t)}}},f=i.id,m={api:Ct,version:t.version,document:h,root:t.root,ephemeral:t.ephemeral,signal:a.signal,has:e=>At.includes(e),off:e=>{o=String(e)},merge:e=>c()?d.merge(e,f):Promise.resolve(0),addMenuItem:p(e=>s.Ae(f,e)),notify:p(e=>s.Le(f,e)),announce:p(e=>s.Pe(e)),setComposerNote:p(e=>s.pe(s.j,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.Me(f,e)),openPanel:p((e,t)=>s.He(f,e,t)),addStyles:p(e=>s.Ie(f,e)),setStatus:p(e=>s.pe(s.G,f,e)),overlay:()=>s.$e(f),onFrame:p(e=>s.Ne(f,e)),where:e=>s.ctx.p.view(e),isHere:e=>s.ctx.p.u(e),go:e=>s.ctx.p.R(e),onUi:p(e=>s.Re(f,e)),avatar:(e,t)=>{let n=yt(e,t);return n.classList.add("in"),n},sign:(e,t)=>d.sign(`${f}/${e}`,t)},v=()=>{if(c()){a.abort();for(let e of[...l])e();try{n?.()}catch(e){globalThis.reportError?.(e)}s.clear(f),"on"===r.state&&(r.state="waiting")}};e.stop=v;try{if(n=await i.setup(m),!c())return void n?.();if(void 0!==o)return v(),r.state="off",void(r.reason=o);r.state="on",delete r.reason}catch(e){r.state="failed",r.reason=function(e){return e instanceof Error?e.message:String(e)}(e),v(),r.state="failed",globalThis.reportError?.(e)}}var Bt={code:"KeyC"},Ht=typeof navigator<"u"&&/Mac|iP(hone|ad|od)/.test(navigator.platform)?"⇧⌥C":"Shift+Alt+C",jt="Shift+Alt+C";function Wt(e,t){let n=function(e){let t=Ze("button",{class:"me",type:"button",tabindex:"-1","aria-hidden":"true"});t.addEventListener("mousedown",e=>e.preventDefault());let n=Mt({label:"Comment",kind:"comment",before:t,_:e._,q:e.q}),o=Ze("div",{class:"note"}),i=()=>{let e=$t();o.textContent=e??"",o.hidden=!e};i();let r=Ze("div",{class:"say"}),a=Ze("input",{class:"input",type:"text",maxlength:"80","aria-label":"Your name"}),l=Ze("div",{class:"nf"},a),s=Ze("div",{class:"you"},r,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=yt(e.me,n),i=t.lastChild;i?(kt(o),xt(i)):o.classList.add("in"),t.append(o),d=n}let i=Ze("button",{type:"button"},o);i.addEventListener("click",h),r.replaceChildren(Ze("span",{class:"nm"},n||`You're ${F(e.me)}`)," · ",i)},p=e=>{s.classList.toggle("naming",e),Qe(r,e),Qe(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 m=Ze("div",{class:"ctx"},e.label),v=Ze("div",{class:"draft"},m,o,n.element,s);return v.addEventListener(Lt,i),{element:v,ge:()=>{let{selectionStart:e,selectionEnd:t}=n.input;return()=>{n.focus(),n.input.setSelectionRange(e,t)}},Q:e=>{m.hidden=e},ve:e=>{m.textContent=e},focus:()=>n.focus(),De:()=>""===n.input.value.trim()}}({label:t.label,me:e.doc.me,name:()=>e.c.name(),rename:t=>e.c.rename(t),_:t=>e.Be(t),q:()=>e.Fe()});return e.H(n),n}function Kt(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 i=o.getBoundingClientRect();return{x:i.width?Math.min(n.right-8,i.right+6):n.right-8,y:(i.height?i.top:n.top)+8}}function Vt(e){return e.range?[...e.range.getClientRects()]:[]}function Ut(e,t){let n=Vt(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 Yt(e,t){let n=Vt(t).at(-1);if(n)return{x:n.left,y:n.bottom,below:!0};let o=Kt(e,t);return o?{...o,below:!1}:null}function _t(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 Gt=320,Jt=()=>window.innerWidth>=900?400:300,Xt=()=>window.innerWidth<=480;function Zt(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 Qt(e,t){let n=e.resolved.get(t.id);return n?.range?.startContainer??n?.element??null}var en=e=>(t,n)=>{let o=Qt(e,t),i=Qt(e,n),r=e=>e.anchor.point??{x:0,y:-1};return o!==i?!i||o&&4&o.compareDocumentPosition(i)?-1:1:r(t).y-r(n).y||r(t).x-r(n).x},tn=e=>`${e} ${1===e?"reply":"replies"}`;function nn(e,t,n){let o={...n},i=e.id,r=Ze("div",{class:"rbox always"},Ze("div",{},Mt({label:"Reply",kind:"reply",thread:()=>i,_:e=>t.reply(i,e),q:t.close}).element)),a=Ze("div",{}),l=Ze("span",{class:"note"},"This thread was resolved. Your words are kept until you send or clear them.");l.hidden=!0,r.prepend(l);let s=Ze("div",{}),d=null,c=null,u=Ze("div",{},s,Ze("div",{class:"more"},a)),p=new Map,h=new Map,f=new Map,m=e=>{let t=wt(e.author,e.name),n=p.get(e.id),o=n?.e;if((!o||n.key!==t)&&(o=kt(yt(e.author,e.name)),n)){let t=n.e;f.set(e.id,t),xt(t,()=>f.get(e.id)===t&&f.delete(e.id))}o.title=I(e),h.set(e.id,{key:t,e:o});let i=f.get(e.id);return i?[i,o]:[o]},v=(e,t,n)=>{let o=Ze("button",{class:"ib",type:"button","aria-label":t,title:t},ht(e));return o.addEventListener("click",e=>{e.stopPropagation(),n()}),o};function g(e,n={}){Object.assign(o,n),i=e.id;let f=(o.now??Date.now)(),g=e.root.replies.length,w=e=>Ze("span",{class:"who"},`${I(e)} · ${Ie(e.at,f)}`),y=e=>Ze("div",{class:e.deleted?"tx del":"tx"},...e.deleted?["Deleted"]:[...H(e.name)?dt(e.text):ct(e.text),e.edited?" (edited)":""]),b=e.resolved?"Resolved"+(g?` · ${tn(g)}`:""):g?tn(g):"",x=Ze("div",{class:"column"===o.D?b?"ft has-rest":"ft":"ft open"},"column"===o.D&&b?Ze("span",{class:"rest"},b):null,Ze("span",{class:"hover"},w(e.root),Ze("span",{class:"acts"},v("copy","Copy thread",()=>t.copy(e.id)),e.resolved?v("reopen","Reopen",()=>{t.reopen(e.id)}):v("resolve","Resolve",()=>{t.resolve(e.id)})))),k=o.lost?Ze("div",{class:"ctx"},`${o.place||"No longer on the page"} — it read “${nt(o.lost,120)}”`):o.quote?Ze("div",{class:"ctx"},`“${nt(o.quote,80)}”`):null;h=new Map;let E=Ze("div",{class:"root"},...m(e.root),k,y(e.root),x);s.replaceWith(E),s=E,d?.remove();let S=Ye.get(e.id);d=g||void 0!==S?Ze("div",{class:"rps"},...e.root.replies.map(e=>Ze("div",{class:"it"},...m(e),y(e),Ze("div",{class:"column"===o.D?"rft":"rft open"},w(e)))),void 0===S?null:Ze("div",{class:"it ghost"},yt("",B,!0),Ze("div",{class:"tx"},S,Ze("span",{class:"dots"},Ze("i"),Ze("i"),Ze("i"))),Ze("div",{class:"rft open"},Ze("span",{class:"who"},`${B} · writing now`)))):null,d&&a.prepend(d),c?.remove();let $=_e.get(e.id),L=Ge.get(e.id);if(c=void 0===$?null:Ze("div",{class:"seen"},Ze("i"),$),c&&L){let e=Ze("button",{type:"button"},"Check again");e.addEventListener("click",e=>{e.stopPropagation(),L()}),c.append(e)}c&&a.insertBefore(c,r.parentNode===a?r:null),p=h;let M=""!==r.querySelector("textarea").value.trim();l.hidden=!(e.resolved&&M),e.resolved&&!M?r.remove():r.parentNode!==a&&a.append(r),u.className=e.resolved?"thread resolved":"thread",u.setAttribute("data-thread",e.id)}return g(e),{element:u,update:g}}var on="a,button,input,select,textarea,label,summary,[role=button],[contenteditable]",rn=400;function an(e,t){let n=new Map,o=Ze("div",{class:"tip",role:"tooltip"}),i=Ze("div",{class:"mark"}),r=Ze("div",{class:"pop",role:"dialog","aria-label":"Comment thread"});o.inert=r.inert=!0,e.t.append(i,o,r);let a,l=Ze("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,g=0,w=e=>s.find(t=>t.id===e)??null,y=()=>t.Z||e.state.d,b=!1,x=t=>{let n=e.resolved.get(t.id);return n?Yt(t.anchor,n):null};function k(t,n,o){let{left:i,top:r}=function(e,t,n,o=12){let i,r;return e.below?(i=Math.min(e.x,n.width-t.width-o),r=e.y+8,r+t.height>n.height-o&&(r=e.y-t.height-40)):(i=e.x+14,i+t.width>n.width-o&&(i=e.x-t.width-28),r=Math.min(e.y-12,n.height-t.height-o)),{left:Math.max(o,i),top:Math.max(o,r)}}(n,{width:t.offsetWidth||o,height:t.offsetHeight},function(e){let t=window.innerWidth;return{width:e&&!Xt()?t-Gt:t,height:window.innerHeight}}(e.state.d));t.style.left=`${i}px`,t.style.top=`${r}px`}function E(t){let n=t&&y()&&e.state.i!==t?w(t):null,i=n?x(n):null;if(!n||!i)return v=null,o.classList.remove("show"),void Qe(o,!0);if(v!==n.id){let e=n.root.replies.length;o.replaceChildren(Ze("div",{class:"tx clamp"},...n.root.deleted?["Deleted"]:ct(n.root.text)),Ze("div",{class:"who"},`${I(n.root)}${e?` · ${e} ${1===e?"reply":"replies"}`:""}`)),v=n.id}k(o,i,260),o.classList.contains("show")||o.offsetWidth,o.classList.add("show"),o.inert=!1}function S(t){f=t,E(t),e.f(t)}function $(e){window.clearTimeout(g),null===e?g=window.setTimeout(()=>S(null),y()?rn:0):S(e)}function L(t){let o=n.get(t.id);if(o)return o;let r=Ze("button",{class:"bub",type:"button","data-thread":t.id});return r.addEventListener("mouseenter",()=>$(t.id)),r.addEventListener("mouseleave",()=>$(null)),r.addEventListener("click",n=>{n.stopPropagation(),E(null),e.open(t.id)}),e.t.insertBefore(r,i),n.set(t.id,r),r}o.addEventListener("mouseenter",()=>window.clearTimeout(g)),o.addEventListener("mouseleave",()=>$(null)),o.addEventListener("click",t=>{t.stopPropagation();let n=v;n&&(window.clearTimeout(g),S(null),e.open(n))});let M=!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}=function(e,t,n,o=12,i=44){let r=e.top-i>=8,a=e.top+e.height+8+(r?0:i),l=e.top-8-(r?i: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:r.offsetWidth||Jt(),height:r.offsetHeight},{width:window.innerWidth,height:window.innerHeight}),i=null!==u?.above&&u?.above!==o;if(u&&(u.above=o),i&&T())return;return r.style.left=`${e}px`,void(r.style.top=`${t}px`)}let o=u&&t?Yt(t.anchor,t.resolved):d?x(d):null;o&&k(r,o,Jt())}let A=t=>e.state.l&&!t.anchor.quote&&!t.anchor.point;function T(e=()=>{}){return window.clearTimeout(h),p?(r.classList.remove("show"),h=window.setTimeout(()=>{e(),C(),r.classList.add("show")},220),!0):(e(),r.classList.add("glide"),h=window.setTimeout(()=>r.classList.remove("glide"),450),!1)}let P=t=>{if(e.w(t)){let e=t.composedPath()[0];return null!==m&&!(e instanceof Element&&e.closest(".tip,.bub"))&&$(null),void(m=null)}let n=e.te(t.clientX,t.clientY)?.id??null;n!==m&&(m=n,$(n))},N=t=>{if(e.w(t))return;let n=window.getSelection();if(n&&!n.isCollapsed||(e.state.l?t.altKey:t.target instanceof Element&&t.target.closest(on)))return;let o=e.te(t.clientX,t.clientY);o&&(e.ye(t),E(null),e.open(o.id))};return window.addEventListener("pointermove",P,{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.B(t)||t.anchor.quote)continue;let n=e.resolved.get(t.id);if(!n||"orphaned"===n.state)continue;l.add(t.id);let o=L(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 i=`Comment on ${Oe(n.element)}: ${nt(t.root.text,60)}`;o.getAttribute("aria-label")!==i&&o.setAttribute("aria-label",i)}et(e.t,o.filter(e=>l.has(e.id)).sort(en(e)).map(e=>n.get(e.id)),i);for(let[e,t]of n)l.has(e)||(t.classList.remove("in"),n.delete(e),window.setTimeout(()=>t.remove(),300));E(f),b!==e.state.d&&r.classList.contains("show")&&!p&&T(),b=e.state.d;let m=t.Z?e.state.o:null;if(m){let t=m.anchor.point??m.resolved.element;u?.of!==m?(window.clearTimeout(h),r.classList.remove("glide"),u={s:Wt(e,m),of:m,at:t,above:null},u.s.Q(A(m)),r.replaceChildren(u.s.element),r.inert=!1,u.s.focus(),d=null,c=null,C(),r.classList.add("show")):u&&(u.at!==t&&(u.at=t,u.above=null,T(()=>u?.s.ve(m.label))),u.s.Q(A(m)));let n=!e.p.u(m.anchor.view);return void(n!==M&&(M=n,r.classList.toggle("show",!n),r.inert=n,n||C()))}u&&(window.clearTimeout(h),r.classList.remove("glide"),u=null,M=!1,e.H(null));let v=y()&&e.state.i?w(e.state.i):null;if(!v||!e.B(v))return d=null,c=null,r.classList.remove("show"),void Qe(r,!0);let g=v.anchor.quote?.exact??null;d&&c&&d.id===v.id?(d!==v||a!==Xe(v.id))&&(c.update(v,{quote:g}),d=v,a=Xe(v.id)):(c=nn(v,e.ee,{D:"popover",quote:g}),r.replaceChildren(c.element),d=v,a=Xe(v.id),C(),r.classList.add("show"),r.inert=!1)},T:function(){for(let[t,o]of n){let n=w(t),i=e.resolved.get(t),r=n&&i?Kt(n.anchor,i):null;!r||r.y<-40||r.y>window.innerHeight+40?o.style.visibility="hidden":(o.style.visibility="",o.style.left=`${r.x}px`,o.style.top=`${r.y}px`,o.classList.contains("in")||(o.offsetWidth,o.classList.add("in")))}let t=e.state.o,o=t?.anchor.point&&e.p.u(t.anchor.view)?Kt(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,i),l.offsetWidth,l.classList.add("in"))):l.classList.contains("in")&&(l.classList.remove("in"),window.setTimeout(()=>l.classList.contains("in")||l.remove(),300)),r.classList.contains("show")&&C();let a=function(){if(!y())return null;let t=e.state.o;return t?t.anchor.quote||t.anchor.point||e.state.l?null:t.resolved.element:!d||d.anchor.quote||d.anchor.point?null:e.resolved.get(d.id)?.element??null}();i.classList.toggle("show",null!==a),a&&ot(i,a.getBoundingClientRect(),4)},destroy(){window.clearTimeout(g),window.clearTimeout(h),window.removeEventListener("pointermove",P,!0),window.removeEventListener("click",N,!0),e.H(null);for(let e of n.values())e.remove();l.remove(),o.remove(),i.remove(),r.remove()}}}var ln={display:"block",position:"static",clips:!1,off:!1},sn=48,dn="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}]`),cn=["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",...dn].join(","),un="a,button,label,summary,[role=button],[role=link],[role=tab],[role=option],[role=menuitem]",pn=`${un},input,select,textarea,img,svg,canvas,video,picture,[role=img]`,hn=24,fn=.6,mn=(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 vn(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.ne();return n.width*n.height<=fn*o.width*o.height&&(e.matches(cn)||t.Ve(e)||e.childElementCount>1&&!e.parentElement?.closest(un)&&t._e(e))}function gn(e,t,n){if(e===t||!t.contains(e)||e.closest("[data-pipeup-ignore]"))return null;let o=null;for(let i=e;i&&i!==t&&!o;i=i.parentElement)vn(i,n)&&(o=i);if(!o||o.hasAttribute("data-pipeup-id"))return o;let i=n.s(o);for(let e=o.parentElement;e&&e!==t&&mn(n.s(e),i);e=e.parentElement)if(e.hasAttribute("data-pipeup-id"))return e;return o}function wn(e,t,n){let o=n.s(e);for(let i=e.parentElement;i&&i!==t;){let e=gn(i,t,n);if(!e)return null;if(!mn(n.s(e),o))return e;i=e.parentElement}return null}var yn=(e,t)=>e.left<t.left+t.width&&t.left<e.left+e.width&&e.top<t.top+t.height&&t.top<e.top+e.height,bn=(e,t)=>{let n=Math.max(e.left,t.left),o=Math.max(e.top,t.top);return{left:n,top:o,width:Math.max(0,Math.min(e.left+e.width,t.left+t.width)-n),height:Math.max(0,Math.min(e.top+e.height,t.top+t.height)-o)}};function xn(e,t,n=()=>!0){let o=[],i=(e,r,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)??ln,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&&!yn(f,h))continue;let v=c.matches(un),g=(e.display.startsWith("inline")||d)&&!c.matches(pn)&&("inline"===e.display||f.height<=sn),w=f.width<=hn&&f.height<=hn,y=r;(c.hasAttribute("data-pipeup-id")||!s&&!e.off&&!g&&(!w||v))&&vn(c,t)&&(r&&mn(t.s(r.e),f)?(c.hasAttribute("data-pipeup-id")||!r.e.hasAttribute("data-pipeup-id"))&&(r.e=c):o.push(y={e:c,O:r,k:0}));let b=e.clips&&m;i(c,y,b?h?bn(h,f):f:h,b?c:p?null:l,s||v,/^inline-(flex|grid)$/.test(e.display)||d&&/(flex|grid)$/.test(e.display))}};i(e,null,null,null,!1,!1);for(let e=o.length-1;e>=0;e--){let t=o[e];t.O&&(t.O.k=Math.max(t.O.k,t.k+1))}return o}var kn=(e,t)=>e.filter(e=>e.k<=t&&(!e.O||e.O.k>t)),En=(e,t)=>e.filter(e=>e.O===t),Sn="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]",$n=`${Sn},input,select,textarea,[contenteditable]:not([contenteditable=false]),[tabindex]:not([tabindex="-1"])`,Ln=["click","dblclick","auxclick","submit","contextmenu","dragstart"],Mn=[...["over","out","enter","leave","down","up"].flatMap(e=>[`pointer${e}`,`mouse${e}`]),"mousemove","touchstart","touchmove","touchend","touchcancel"],Cn=400,An="Tab moves between blocks · ↑ ↓ change level · Enter comments · Esc to finish · F7 selects text",Tn=4,Pn=150;function Nn(e){let t={s: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}},ne:()=>({width:innerWidth,height:innerHeight})},n=Ze("span",{hidden:!0},An),o=Ze("div",{class:"pick"},n),i=[0,1].map(()=>{let e=Ze("div",{class:"km",tabindex:"-1",role:"button"},Ze("span",{hidden:!0}),Ze("span",{hidden:!0}));return e.inert=!0,e.addEventListener("keydown",ue),e.addEventListener("click",e=>{e.stopPropagation(),ce()}),e.addEventListener("focus",()=>o.classList.add("kf")),e.addEventListener("blur",()=>o.classList.remove("kf")),e}),r=Ze("span",{class:"lbl"}),a=(e,t,n,o)=>{let i=Ze("button",{class:"nb",type:"button","aria-label":e,title:t},ht(n,16));return i.addEventListener("click",e=>{e.stopPropagation(),o()}),i},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.we(()=>j(f??x,{x:.5,y:.5}))),c=Ze("div",{class:"namebar",role:"group","aria-label":"Chosen block"},r,l,s,d);c.inert=!0;let u=e.t.querySelector(".launch");for(let t of[o,...i,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,v=null,g=0,w=()=>{},y=null,b=()=>{},x=null,k=0,E=0,S=!1,$=null,L=null,M=null,C=0,A=-1,T=!0,P=null,N=null,q=t=>!(e.w(t)||t.target instanceof Element&&t.target.closest("[data-pipeup-ignore]"));function O(){v&&(o.classList.toggle("glide",performance.now()<g),ot(o,v.getBoundingClientRect(),4))}function z(){if(!y)return;c.classList.toggle("glide",performance.now()<g&&c.classList.contains("show"));let{left:e,top:t}=Zt(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 R(e,t){v=e,g=t?performance.now()+Cn:0,O(),o.classList.add("show")}function D(e,t){let n=getComputedStyle(e);if("0"===n.opacity)return t(),()=>{};let o=0,i=()=>{window.clearTimeout(o),e.removeEventListener("transitionend",a)},r=()=>{i(),t()},a=t=>{t.target===e&&"opacity"===t.propertyName&&r()},l=Math.max(...n.transitionDuration.split(",").map(e=>1e3*parseFloat(e)||0));return o=window.setTimeout(r,l+100),e.addEventListener("transitionend",a),i}function F(e){if(e!==h){if(h=e,w(),!e)return void o.classList.remove("show");"0"===getComputedStyle(o).opacity?R(e,!1):p?(o.classList.remove("show"),w=D(o,()=>R(e,!1))):R(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=D(c,()=>H(e))):H(e):(c.classList.remove("show"),y=null)}function H(n){r.textContent=r.title=Oe(n),l.hidden=null===wn(n,e.root,t),s.hidden=0===(x?ae(n).length:xn(n,t,Z).length);let o=c.classList.contains("show");y=n,z(),o||(c.offsetWidth,c.classList.add("show"))}function j(t,n){let o;try{o=we(t,e.root,n,e.p.view(t))}catch(t){return void e.oe(t)}let i={anchor:o,label:n?`Pin on ${Oe(t).replace(/^[A-Z](?=[a-z])/,e=>e.toLowerCase())}`:Oe(t),ranges:[],resolved:{state:"attached",element:t,range:null}},r=e.state.o;x&&(x=t,A=-1),I(n?null:t),m=r??i,e.qe(i),e.E(n?i.label:`Commenting on ${i.label}`)}function W(t){e.we(()=>j(t))}let K=n=>{if(e.w(n))return;if(!q(n))return void(f||F(null));if(n.stopPropagation(),f||e.state.o)return;let o=!tt()&&n.target instanceof Element?gn(n.target,e.root,t):null;if(x){if(!o||o===x||(C+=Math.abs(n.movementX)+Math.abs(n.movementY),C<=Tn))return;re()}o&&($=o),F(o)},V=()=>{tt()&&(x&&re(),f||F(null))},U=e=>{q(e)&&(e.stopPropagation(),("pointerdown"===e.type||"mousedown"===e.type)&&e.target instanceof Element&&e.target.closest($n)&&e.preventDefault())},Y=n=>{if(!q(n))return;let o=n.target;!(o===N||o.form&&o.form===N?.form)||"submit"!==n.type&&("click"!==n.type||n.detail)?(n.preventDefault(),n.stopPropagation(),"click"===n.type&&!e.state.c&&!e.Ue(n)&&function(n){let o=window.getSelection();if(o&&!o.isCollapsed)return;if(e.state.o&&(n.altKey||!e.L()))return void e.F();if(!n.altKey&&e.te(n.clientX,n.clientY))return;if(e.state.i&&e.open(null),x&&n.detail&&re(),n.altKey)return void function(n){let o=(n.target instanceof Element?gn(n.target,e.root,t):null)??e.root;o!==e.root&&($=o);let i=o.getBoundingClientRect();i.width&&i.height&&j(o,{x:(n.clientX-i.left)/i.width,y:(n.clientY-i.top)/i.height})}(n);let i=n.target instanceof Element?gn(n.target,e.root,t):null;i&&($=i),i?j(i):(e.F(),I(null))}(n)):N="click"===n.type&&"submit"===o.type?o.form:null},_=t=>{if(N=null,he="","Tab"===t.key&&G(t))return t.preventDefault(),t.stopPropagation(),he=t.key,e.F(),e.state.i&&e.open(null),e.state.c&&(e.state.c=!1,e.m()),function(t){if(x)return le(t);P=null;let n=document.activeElement;L=J()??n;let o,i=$?.isConnected?$:null,r=i&&ee(i);if(r){k=r.k;let e=kn(Q(),k),n=e.indexOf(r);o=e[(n+t+e.length)%e.length]}else if(i){k=0;let e=kn(Q(),0),n=e=>0!==(i.compareDocumentPosition(e.e)&Node.DOCUMENT_POSITION_FOLLOWING),r=e=>e.e.contains(i);o=t>0?e.find(e=>n(e)&&!r(e))??e[0]:e.filter(e=>!n(e)&&!r(e)).pop()??e[e.length-1]}else o=ne(),o&&(k=o.k);if(!o)return e.E("Nothing here to comment on");S=!0,ie(o.e)}(t.shiftKey?-1:1);if(q(t)&&t.target instanceof Element)if("Enter"!==t.key&&" "!==t.key||!t.target.closest(Sn))"Enter"===t.key&&!x&&t.target.form&&(N=t.target);else{if(!x)return void(N=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&&!i.some(e=>e===n)&&(e.w(t)?!!n.closest(".launch,.menu")&&!n.closest("input,textarea,select,[contenteditable]"):!t.composedPath().some(e=>e instanceof Element&&e.hasAttribute("data-pipeup-ignore")))},J=()=>e.t.getRootNode().activeElement,X=()=>i.some(e=>e===J()),Z=t=>(!1!==t.checkVisibility?.({opacityProperty:!0,visibilityProperty:!0})||"contents"===getComputedStyle(t).display)&&e.p.u(e.p.view(t)),Q=()=>(P?.some(e=>!e.e.isConnected)&&(P=null),P??=xn(e.root,t,Z)),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=kn(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.B(n)&&t.contains(Qt(e,n))).sort(en(e));function ie(t,o=!0){C=0;let r=Q(),a=r.find(e=>e.e===t);if(a&&!kn(r,k).includes(a)&&(k=a.k),t!==x&&(A=-1),t!==f&&(f=null),x=t,F(t),B(t),t.scrollIntoView({block:"nearest",inline:"nearest",behavior:p?"auto":"smooth"}),!o)return;e.Ke();let l=i[E^=1];(function(e,t){let[o,i]=e.children,r=kn(Q(),k),a=oe(t).length;o.textContent=`${Ne(t)}, ${r.findIndex(e=>e.e===t)+1} of ${r.length}${a?`, has ${a} comment${1===a?"":"s"}`:""}`;let l=(t.innerText??t.textContent??"").length<=Pn;i.textContent=qe(t);let s=T?[n]:[];T=!1,void 0!==e.ariaLabelledByElements?(e.ariaLabelledByElements=l?[o,t]:[o,i],e.ariaDescribedByElements=l?s:[...s,t]):e.setAttribute("aria-label",`${o.textContent}, ${i.textContent}`)})(l,t),ot(l,t.getBoundingClientRect(),4),l.inert=!1,l.focus({preventScroll:!0}),i[1^E].inert=!0}function re(){let e=X();$=x,x=null,F(null),B(null);for(let e of i)Qe(e,!0);return e}function ae(e){let t=ee(e);return t?En(Q(),t):[]}function le(e){let t=kn(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&&ie(o.e)}function se(){let n=f??x,o=n&&wn(n,e.root,t);return o?((!M||!n.contains(M))&&(M=n),f?W(o):void ie(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):ie(o.e)}function ce(t=!1){if(!x)return;if(e.state.o&&!e.L())return e.ze();if(!t)return j(x);let n=oe(x);if(!n.length)return e.E("No comments on this block");A=(A+1)%n.length,e.open(n[A].id),n.length>1&&e.E(`Comment ${A+1} of ${n.length} on this block`)}function ue(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(),he=t.key,"Escape"===t.key)return void e.re();if("Enter"===t.key||" "===t.key)return ce(t.shiftKey&&"Enter"===t.key);"Tab"===t.key&&e.F(),e.state.i&&e.open(null),"Tab"===t.key?le(t.shiftKey?-1:1):"ArrowUp"===t.key?se():de()}}let pe=()=>{let e=J();return e?!!e.closest("[inert]"):!document.activeElement||document.activeElement===document.body},he="",fe=!1,me=e=>{fe&&window.removeEventListener("keyup",me,!0),e.key===he&&(he="",e.preventDefault(),e.stopPropagation())};window.addEventListener("keyup",me,!0),window.addEventListener("pointermove",K,!0),document.addEventListener("selectionchange",V);for(let e of Mn)window.addEventListener(e,U,!0);for(let e of Ln)window.addEventListener(e,Y,!0);return window.addEventListener("keydown",_,!0),{re:()=>!!f&&(I(null),!0),ie:()=>null!==x,We:()=>S&&!x,be:function(){P=null;let t=document.activeElement;L=J()??t;let n=ee($),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.k),S=!0,ie(o.e),!0)},se(){x&&!X()&&ie(x)},m(){if(P=null,x&&(!x.isConnected||!Z(x))){let e=ne();e?ie(e.e,X()||pe()):re()}let t=e.t.querySelector(".launch");if(t&&c.nextElementSibling!==t&&!X()&&!c.contains(J()))for(let n of[o,...i,c])e.t.insertBefore(n,t);let n=e.state.o;m&&n!==m?(m=null,I(null),x&&ie(x,pe())):(n||e.state.i)&&!m&&(h||f)&&I(null)},T(){O(),z(),x&&ot(i[E],x.getBoundingClientRect(),4)},destroy(){re()&&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 i)e.remove();w(),b(),fe=!0,he||window.removeEventListener("keyup",me,!0),window.removeEventListener("pointermove",K,!0),document.removeEventListener("selectionchange",V);for(let e of Mn)window.removeEventListener(e,U,!0);for(let e of Ln)window.removeEventListener(e,Y,!0);window.removeEventListener("keydown",_,!0),o.classList.remove("show"),c.classList.remove("show"),Qe(c,!0),D(o,()=>o.remove()),D(c,()=>c.remove())}}}var qn=300,On=32,zn=220,Rn=320,Dn=24,Fn=24;function In(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 i=e.querySelector("article, main, [role=main]")??("column"===o?e:null);if(!i)return null;if(n.hasAttribute("data-pipeup-reserve")){let e,r=n.clientWidth,a=getComputedStyle(i).maxWidth;return e=a.endsWith("px")?parseFloat(a):a.endsWith("%")?parseFloat(a)/100*r:i.getBoundingClientRect().width,"column"!==o&&r<e+Rn-(t?Dn:0)?null:{x:r-Rn+Fn,width:Rn-2*Fn}}let r=i.getBoundingClientRect().right;if(window.innerWidth-r<qn&&"column"!==o)return null;let a=r+On;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.S.has(t.id)}function Hn(e){let t=Ze("div",{class:"col"});e.t.append(t);let n=new Map,o=null,i=new ResizeObserver(()=>l()),r=t=>Bn(e,t);function a(t){let n=e.resolved.get(t.id),o=n?Ut(t.anchor,n):null;return null===o?Number.POSITIVE_INFINITY:o+window.scrollY-4}function l(){let t=[],i=[];for(let[o,r]of n){let n=a(r.thread);if(Number.isFinite(n))r.placed=n;else if(e.S.has(o)){if(null===r.placed){r.e.classList.add("wait");continue}n=r.placed}Number.isFinite(n)?t.push({id:o,M:n,height:r.e.offsetHeight}):i.push({id:o,height:r.e.offsetHeight})}let r=e.state.o,l=r?Ut(r.anchor,r.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),i=new Array(o.length).fill(0),r=o.findIndex(e=>e.id===t),a=e=>o[e];if(r<0)o.forEach((e,t)=>{i[t]=0===t?e.M:Math.max(e.M,(i[t-1]??0)+a(t-1).height+n)});else{i[r]=a(r).M;for(let e=r+1;e<o.length;e++)i[e]=Math.max(a(e).M,(i[e-1]??0)+a(e-1).height+n);for(let e=r-1;e>=0;e--)i[e]=Math.min(a(e).M,(i[e+1]??0)-a(e).height-n)}return new Map(o.map((e,t)=>[e.id,i[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 i)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=Xe(t.id),e.lost=r(t),e.view.update(t,{lost:e.lost?t.anchor.snapshot:null})}function d(n){let o=r(n),a=nn(n,e.ee,{D:"column",lost:o?n.anchor.snapshot:null}),l=Ze("div",{class:"th","data-thread":n.id},Ze("button",{class:"opn sr",type:"button","data-thread":n.id}),a.element);return l.style.transition="none",l.addEventListener("mouseenter",()=>e.f(n.id)),l.addEventListener("mouseleave",()=>e.f(null)),l.addEventListener("click",()=>e.open(n.id)),t.append(l),i.observe(l),{e:l,thread:n,lost:o,placed:null,view:a}}function c(e){i.unobserve(e),e.classList.add("out"),window.setTimeout(()=>e.remove(),zn)}return{m:function(a){Qe(t,e.state.d);let u=new Set,p=[],h=null!==e.state.i||null!==e.state.o;for(let t of a){if(!e.B(t))continue;u.add(t.id);let o=n.get(t.id);o?(o.thread!==t||o.lost!==r(t)||o.note!==Xe(t.id))&&s(o,t):(o=d(t),n.set(t.id,o),p.push(o.e));let i=o.e,a=e.state.i===t.id;i.classList.toggle("on",a);let l=i.firstElementChild,c=t.root.replies.length;l.setAttribute("aria-label",`Open thread: ${nt(t.root.text,60)}, ${tn(c)}`),l.setAttribute("aria-expanded",String(a)),Qe(l,a);let f=i.querySelector(".more");f&&Qe(f,!a),i.classList.toggle("dim",h&&!a),i.classList.toggle("hot",e.state.f===t.id&&!a),i.classList.toggle("resolved",t.resolved),i.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.o;if(o&&o.of!==n&&(c(o.e),o=null,n||e.H(null)),!n)return;let r=!o;if(o)o.s.ve(n.label);else{let r=Wt(e,n),a=Ze("div",{class:"th on"},r.element);a.style.transition="none",t.append(a),i.observe(a),o={e:a,s:r,of:n}}o.s.Q(e.state.l&&!n.anchor.quote&&!n.anchor.point),r&&o.s.focus()})(),et(t,a.filter(e=>u.has(e.id)).sort(en(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=""},T:function(){let n=In(e.root,!0);n&&(t.style.width=`${n.width}px`,t.style.transform=`translate(${n.x}px, ${-window.scrollY}px)`)},destroy(){i.disconnect(),e.H(null),t.remove()}}}var jn="[data-pipeup-ignore],input,textarea,select,[contenteditable]:not([contenteditable=false])";function Wn(e){let t=Ze("button",{type:"button","aria-label":"Comment",title:"Comment"},ht("comment",17)),n=Ze("div",{class:"selbar"},t);n.inert=!0,e.t.append(n);let o=null,i=0,r=!1,a=t=>{let n=t&&(t.nodeType===Node.ELEMENT_NODE?t:t.parentElement);return!!n&&e.root.contains(n)&&!n.closest(jn)};function l(){if(!o)return;let{left:e,top:t}=Zt(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 i=tt();e.state.l&&i&&a(i.anchorNode)&&a(i.focusNode)?(!o&&!t&&e.E("Enter comments on the selected words"),o=i.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.L())return e.F();let n,i=o;if(!i)return;try{n=ge(i,e.root,e.p.view(i.commonAncestorContainer))}catch(t){return e.oe(t),void s()}let r=nt(i.toString().replace(/\s+/g," ").trim(),60);window.getSelection()?.removeAllRanges(),s(),e.Ye({anchor:n,label:`“${r}”`,ranges:[i],resolved:{state:"attached",element:null,range:i}})});let c=()=>{window.clearTimeout(i),i=window.setTimeout(()=>r||d(),250),o&&(tt()||s())};document.addEventListener("selectionchange",c);let u=t=>{"keyup"!==t.type&&(r="mousedown"===t.type),!r&&!e.w(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.w(n)||n.target instanceof Element&&n.target.closest(`${jn},${Sn}`)||(n.preventDefault(),n.stopPropagation(),t.click())};return window.addEventListener("keydown",p,!0),{m(){!e.state.l&&o&&s()},T(){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(i),document.removeEventListener("selectionchange",c),n.remove()}}}async function Kn(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 Vn=3e3,Un="Hidden on the page";function Yn(e){let t=[Ze("span",{class:"n"}),Ze("span",{class:"n"})],n=ht("comment",20,1.4);n.lastElementChild.setAttribute("stroke-width","1.6");let o=Ze("button",{class:"mode",type:"button","aria-label":"Comment","aria-keyshortcuts":jt,"aria-haspopup":"menu","aria-expanded":"false"},Ze("span",{class:"plus"},n),Ze("span",{class:"cnt"},ht("bubble",34,1.4),...t),Ze("span",{class:"dot"})),i=document.createTextNode("Comment"),r=Ze("span",{class:"ttip","aria-hidden":"true"},i,Ze("small",{},Ht)),a=Ze("div",{class:"launch"},o,r),l=Ze("div",{class:"menu",role:"menu","aria-label":"Comments"}),s=Ze("div",{class:"list",role:"menu","aria-label":"All comments"}),d=Ze("span",{class:"pn"}),c=Ze("button",{class:"ib",type:"button","aria-label":"Close"},ht("close")),u=Ze("button",{class:"hs",type:"button",role:"switch","aria-checked":"false"},"Show resolved",Ze("span",{class:"sw","aria-hidden":"true"}));u.addEventListener("click",t=>{t.stopPropagation(),e.c.je()});let p=Ze("div",{class:"all",role:"dialog","aria-label":"All comments"},Ze("div",{class:"hd"},Ze("span",{},"All comments"),d,u,c),s),h=document.createElementNS("http://www.w3.org/2000/svg","svg");h.setAttribute("class","cx"),h.setAttribute("aria-hidden","true");let f=document.createElementNS("http://www.w3.org/2000/svg","path"),m=document.createElementNS("http://www.w3.org/2000/svg","circle");m.setAttribute("r","4"),h.append(f,m),l.inert=p.inert=!0,e.t.append(l,a,h,p);let v=!1,g=null,w=0,y=[],b=0,x=null,k=null,E=!0===window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,S=t=>{v=e.state.c=t,t&&e.addons.flush(),window.clearTimeout(w),w=0,t||g?.(!0),l.classList.toggle("show",t),Qe(l,!t),o.setAttribute("aria-expanded",String(t))},$=(t,n=!1)=>{e.state.d!==t&&(e.state.d=t,e.m(),t?(L(s)[0]??c).focus({preventScroll:!0}):n&&o.focus({preventScroll:!0}))},L=(e=l)=>[...e.querySelectorAll(".mi")],M=()=>l.getRootNode().activeElement,C=()=>{S(!1),o.focus({preventScroll:!0})},A=e=>{let t=L(e.currentTarget);if(0===t.length)return;let n=M(),o=t.indexOf(n),i=n=>{e.preventDefault(),t[(n+t.length)%t.length]?.focus({preventScroll:!0})};"ArrowDown"===e.key?i(o+1):"ArrowUp"===e.key?i(o<0?t.length-1:o-1):"Home"===e.key?i(0):"End"===e.key&&i(t.length-1)};l.addEventListener("keydown",A),s.addEventListener("keydown",A),c.addEventListener("click",e=>{e.stopPropagation(),$(!1,!0)});let T=t=>Bn(e,t),P=t=>y.filter(n=>!n.resolved&&(void 0===t||e.V(n)===t)).length,N=()=>P(),q=t=>{let n=t.anchor.view?.slide,o=e.p.u(t.anchor.view)?"":Re(t.anchor.view);return n&&null!==e.p.slide()?`On slide ${n}`:o?`In ${o}`:Un},O=(e,t,n="")=>Ze("div",{role:"group","aria-label":n?`${e} · ${n}`:e},Ze("div",{class:"sec","aria-hidden":"true"},e,n&&Ze("b",{},n)),...t);function z(){let t=M(),n=t?.dataset.thread,o=null!==k&&k.element.contains(t),i=e.c.all().filter(t=>!t.thread.resolved||e.state.C||t.thread.id===x),r=t=>{let n=t.thread,o=n.id===x,i=yt(n.root.author,n.root.name);i.classList.add("in");let r=Ze("button",{class:`mi${n.resolved?" done":""}${o?" open":""}`,type:"button",role:"menuitem","aria-expanded":String(o),"data-thread":n.id},i,Ze("span",{},Ze("span",{class:"clamp"},n.root.deleted?"Deleted":n.root.text),Ze("small",{},T(n)?`“${nt(n.anchor.snapshot,80)}”`:t.location.where)));r.addEventListener("click",t=>{t.stopPropagation(),function(t){if(x===t)return I(!0);let n=y.find(e=>e.id===t);if(n){if(x=D=t,k=nn(n,{...e.ee,close:()=>I(!0)},R(n)),z(),k.element.querySelector("textarea")?.focus({preventScroll:!0}),!e.V(n))return B(n);e.state.o&&!e.L()||e.p.R(n.anchor.view??{}).then(()=>{e.xe();let n=y.find(e=>e.id===t);n&&D===t&&x===t&&B(n)})}}(n.id)});let a=document.createDocumentFragment();return a.append(r),o&&k&&(k.update(n,R(n)),a.append(Ze("div",{class:"xr",role:"region","aria-label":"Comment thread"},k.element))),a},a=i.filter(e=>T(e.thread));d.textContent=String(N()),u.setAttribute("aria-checked",String(e.state.C)),s.replaceChildren(i.length?"":Ze("div",{class:"sec",role:"presentation"},"No open comments"),...function(t,n){let o=e.p.slide(),i=new Map;for(let n of t){let t=n.thread,r=null!==o?t.anchor.view?.slide??o:e.V(t)?e.p.u(t.anchor.view)?"":Re(t.anchor.view):null;i.set(r,[...i.get(r)??[],n])}if(null===o){let e=i.get(null)??[];return i.delete(null),[...e.map(n),...[...i].map(([e,t])=>O(e||Un,t.map(n)))]}return[...i].sort(([e],[t])=>Number(e)-Number(t)||0).map(([e,t])=>O(`Slide ${e} · ${t.filter(e=>!e.thread.resolved).length} open`,t.map(n),e===o?"This slide":""))}(i.filter(e=>!T(e.thread)),r),a.length?O("No longer on the page",a.map(r)):""),o?k.element.querySelector("textarea")?.focus({preventScroll:!0}):n&&L(s).find(e=>e.dataset.thread===n)?.focus({preventScroll:!0})}function R(t){let n=!T(t)&&e.V(t);return{D:"popover",quote:t.anchor.quote?.exact??null,lost:T(t)||n?t.anchor.snapshot:null,place:n?q(t):null}}let D="";function I(t=!1){if(!x)return;let n=x;x=k=null,e.f(null),z(),t&&L(s).find(e=>e.dataset.thread===n)?.focus({preventScroll:!0})}function B(t){let n=e.resolved.get(t.id),o=n&&!T(t)?n.element??n.range?.startContainer.parentElement??null:null;o?.scrollIntoView({block:"center",inline:"nearest",behavior:E?"auto":"smooth"}),o&&e.f(t.id)}function H(e,t,n=!1,...o){let i=Ze("button",{class:"mi",type:"button",role:n?"menuitemcheckbox":"menuitem"},e,Ze("span",{class:"lb"}),...o,n&&Ze("span",{class:"sw","aria-hidden":"true"}),Ze("span",{class:"tt","aria-hidden":"true"}));return i.addEventListener("click",e=>{e.stopPropagation(),t(e)}),i}let j=(e,t,n,o)=>{let i=e.querySelector(".lb");i.textContent!==t&&(i.textContent=t),e.querySelector(".tt").textContent=n,e.setAttribute("aria-description",n),void 0!==o&&e.setAttribute("aria-checked",String(o))},W=()=>Ze("div",{class:"sep",role:"separator"}),K=Ze("span",{class:"ma"}),V=Ze("span",{class:"kc"}),U="",Y=H(K,function(){let t=Ze("input",{class:"input",type:"text",maxlength:"80","aria-label":"Your name"});t.value=e.c.name();let n=Ze("div",{class:"ed"},K.cloneNode(!0),t),o=(i,r=!1)=>{if(g!==o)return;g=null;let a=t.value.trim();i&&a&&a!==e.c.name()&&e.c.rename(a).then(ae),n.replaceWith(Y),r&&Y.focus({preventScroll:!0})};g=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)),Y.replaceWith(n),t.focus({preventScroll:!0})},!1,V);Y.dataset.item="name";let _=H(ht("copy"),()=>{C(),e.c.copyAll("ai")}),G=H(ht("lines"),()=>{C(),e.c.copyAll("text")}),J=Ze("span",{class:"kc"}),X=H(ht("list"),()=>{S(!1),$(!0)},!1,J),Z=H(ht("comment"),t=>{let n=!e.state.l&&0===t.detail;e.Ge(!e.state.l,n),n&&S(!1)},!0,Ze("span",{class:"kc","aria-hidden":"true"},Ht));Z.dataset.item="comment",Z.setAttribute("aria-keyshortcuts",jt);let Q=Ze("div",{class:"sec",role:"presentation"}),ee=W(),te=W(),ne=new Map,oe=t=>{let n=ne.get(t);return n||(n=H(ft(t.icon,15),()=>{t.checked||C(),Promise.resolve().then(()=>t.select()).catch(t=>e.oe(t)).finally(()=>v&&ae())},!!t.checked,Ze("span",{class:"kc"})),ne.set(t,n)),n},ie=-1,re=e=>{try{return e()}catch(e){return globalThis.reportError?.(e),""}};function ae(){let t=N(),n=e.c.name(),o=n||F(e.doc.me);if(j(Y,o,n?"The name on your comments":"Add a name to show on your comments"),Y.setAttribute("aria-label",`${o}, ${n?"edit":"add"} your name`),V.replaceChildren(n?ht("edit",13):"Add name"),wt(e.doc.me,n)!==U){U=wt(e.doc.me,n);let t=yt(e.doc.me,n);t.classList.add("in"),K.replaceChildren(t)}j(_,"Copy as Markdown","Markdown, with where each thread is"),j(G,"Copy as Text","Just the words"),j(X,"All comments","Every thread, and where it is"),J.textContent=t?String(t):"";let i=e.addons.de();Q.textContent=i,i?!Q.isConnected&&l.contains(Y)&&l.prepend(Q):Q.remove();for(let t of e.addons.$){let e,n=ne.get(t);if(n){try{e=t.checked?.()}catch(e){globalThis.reportError?.(e)}j(n,re(t.label),re(t.hint),e),n.querySelector(".kc").textContent=t.count?re(t.count):""}}j(Z,"Start commenting",e.state.l?"Turn off to hide the comments again":"Shows the comments; choose any part of the page to comment on it",e.state.l)}function le(){ae(),(ie!==e.addons.Y||!l.contains(Y))&&(l.replaceChildren(Y,ee,_,G,X,...e.addons.$.map(oe),te,Z),ie=e.addons.Y,ae())}o.addEventListener("click",e=>{e.stopPropagation(),v?S(!1):(le(),S(!0),0===e.detail&&L().at(-1)?.focus({preventScroll:!0}))});let se=!1,de=()=>{se=p.contains(M())},ce=t=>{let n=t.composedPath();v&&!n.includes(l)&&!n.includes(o)&&(S(!1),e.state.l&&!e.w(t)&&(e.ye(t),t.preventDefault(),t.stopPropagation())),e.state.d&&!e.w(t)&&$(!1,se&&(!document.activeElement||document.activeElement===document.body))},ue=e=>{if(!v||"touch"===e.pointerType||"pointerout"===e.type&&e.relatedTarget)return;let t=e.composedPath();"pointerover"===e.type&&(t.includes(l)||t.includes(o))?(window.clearTimeout(w),w=0):w||(w=window.setTimeout(()=>{w=0,g||S(!1)},Vn))},pe={n:0,label:""},he=()=>{let{n:t,label:n}=pe,r=e.addons.de(),a=`Comment${e.state.l?", comment mode on":""}${n?`, ${n}`:t?`, ${t} open`:""}${r?`, ${r}`:""}`;o.getAttribute("aria-label")!==a&&o.setAttribute("aria-label",a);let l=(n||"Comment")+(r?` · ${r}`:"");i.data!==l&&(i.data=l)},fe=e.addons.subscribe(e=>{he(),v&&!g&&(e?le():ae())});window.addEventListener("pointerdown",de,!0),window.addEventListener("click",ce,!0),window.addEventListener("pointerover",ue,!0),window.addEventListener("pointerout",ue,!0);let me=t=>{if("Escape"!==t.key||g)return;let n=t.composedPath()[0];if(v)C();else{if(!e.state.d||n instanceof HTMLTextAreaElement&&!p.contains(n))return;x?I(!0):$(!1,!0)}t.stopPropagation()};return window.addEventListener("keydown",me,!0),{m(n){y=n;let i=P(!1);if(i!==b){if(i){let[e,n]=t[0].classList.contains("on")?t:[t[1],t[0]];n.textContent=i>99?"99+":String(i),n.classList.toggle("s",i>99),e.classList.remove("on"),n.classList.add("on")}o.classList.toggle("has",i>0),b=i}let r=P(!0),a=r?`${i} here · ${r} ${null!==e.p.slide()?"on other slides":"in other views"}`:"";o.classList.toggle("else",r>0),pe={n:i,label:a},he(),o.classList.toggle("on",e.state.l),v&&!e.state.c&&S(!1),v&&ae();let l=e.state.d;p.classList.toggle("full",Xt()),p.classList.contains("show")!==l&&(p.classList.toggle("show",l),Qe(p,!l)),x&&(!l||!n.some(e=>e.id===x))&&(x=k=null,e.state.f=null),l&&z()},T:function(){let t=x?y.find(e=>e.id===x):null,n=x?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||Xt()||T(t)||e.V(t)||!1===o?.checkVisibility?.({visibilityProperty:!0}))return null;let i=n.range?Vt(n).at(-1):void 0,r=o?.closest("p,li,h1,h2,h3,h4,h5,h6,blockquote,td,th,figcaption,div")?.getBoundingClientRect().right,a=n.element?.getBoundingClientRect(),l=Yt(t.anchor,n),s=i?{x:Math.max(i.right,r??0)+4,y:(i.top+i.bottom)/2,from:"right"}:a?{x:a.left+a.width/2,y:a.top,from:"top"}:l&&{x:l.x,y:l.y,from:"right"};return s&&s.x>=0&&s.x<=window.innerWidth-Gt&&s.y>=0&&s.y<=window.innerHeight?s:null}(t),i=n?.getBoundingClientRect(),r=s.getBoundingClientRect();if(!o||!i||i.top+12<r.top||i.top+12>r.bottom)return void h.classList.remove("show");let a,l=i.left,d=i.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,i=Math.min(20,Math.abs(e-d)/2);a=`M${l} ${d}C${l-20} ${d} ${t} ${d} ${t} ${d+n*i}L${t} ${e-n*i}C${t} ${e} ${t} ${e} ${t-i} ${e}L${o.x+8} ${e}C${o.x} ${e} ${o.x} ${e} ${o.x} ${o.y}`}f.setAttribute("d",a),m.setAttribute("cx",String(o.x)),m.setAttribute("cy",String(o.y)),h.classList.add("show")},destroy(){fe(),window.removeEventListener("pointerdown",de,!0),window.removeEventListener("click",ce,!0),window.removeEventListener("pointerover",ue,!0),window.removeEventListener("pointerout",ue,!0),window.clearTimeout(w),window.removeEventListener("keydown",me,!0),l.remove(),p.remove(),h.remove(),a.remove()}}}var _n="[data-pipeup-slide]",Gn=1e3,Jn=["scroll","resize","keyup","click","transitionend","slidechanged"],Xn=null,Zn=null,Qn=new Set,eo=new Set,to=e=>{try{e()}catch(e){globalThis.reportError?.(e)}};function no(e){let t=null;if(e){t={};let n=0;for(let[o,i]of Object.entries(e))if(!("string"!=typeof i||"slide"===o||o.length>g.viewKey||i.length>g.viewValue)){if(++n>=g.viewEntries)break;t[o]=i}}Xn=t;for(let e of eo)e()}function oo(e){return Qn.add(e),()=>{Qn.delete(e)}}function io(e){Zn="function"==typeof e?.current&&"function"==typeof e.go?e:null}var ro=()=>{let e=window.Reveal;return"function"==typeof e?.getIndices&&"function"==typeof e.slide?e:null};var ao=["pipeup-quote","pipeup-on","pipeup-done"],lo={"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]]},so=(e,t)=>ao.map(n=>{let[o,i,r,a]=lo[n][e?1:0];return`::highlight(${n}){background-color:rgba(${o},${i},${r},${+(a*t).toFixed(3)})}`}).join("");function co(){return typeof CSS<"u"&&"highlights"in CSS&&typeof Highlight<"u"}var uo=`: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 po(){if(co())for(let e of ao)CSS.highlights.delete(e)}var ho=':host{all:initial}*{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;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:#888780;--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.dark{--k:#ECEBE6;--mu:#B4B2A9;--fa:#8D8B84;--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{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,.av.ai:after{content:"";position:absolute;inset:3px;border-radius:50%;border:1.5px solid var(--pu-accent);pointer-events:none}.av.ai:after{animation:pu-pulse-ring 3s var(--eo) infinite}.av.ai.busy:after{animation-duration:1.6s}.root>.av.ai,.it>.av.ai{position:absolute}@keyframes pu-pulse-ring{0%{opacity:.7;transform:scale(1)}80%,to{opacity:0;transform:scale(1.375)}}.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}.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}.ghost .dots{display:inline-flex;gap:3px;margin-left:4px;vertical-align:middle}.ghost .dots i{width:4px;height:4px;border-radius:50%;background:var(--fa);animation:pu-dot 1.6s var(--eio) infinite}.ghost .dots i:nth-child(2){animation-delay:.2s}.ghost .dots i:nth-child(3){animation-delay:.4s}@keyframes pu-dot{0%,to{opacity:.25}50%{opacity:1}}.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{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;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{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)}.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(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){.bub,.bub.in,.bub.in:hover,.bub.on,.tip,.pop,.selbar,.menu,.all,.xp,.ttip,.tt,.toast,.ref .rc{transform:none!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}.av.ai:after{animation:none;opacity:0}.ghost .dots i{animation:none;opacity:.6}@keyframes pu-pulse{0%{opacity:0}35%{opacity:.85}to{opacity:0}}}',fo="#534AB7",mo="#9A94EE",vo="rgb(0, 0, 238)";function go(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}}function wo(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 yo=(e,t)=>(Math.max(e,t)+.05)/(Math.min(e,t)+.05);function bo(e){let t=e.ownerDocument,n=t.defaultView;if(!n)return{font:"system-ui, sans-serif",accent:fo,dark:!1,on:"#fff"};let o=t.documentElement,i=n.getComputedStyle(e).fontFamily||"system-ui, sans-serif",r=(n.getComputedStyle(o).getPropertyValue("--pipeup-accent")||o.style.getPropertyValue("--pipeup-accent")).trim(),a=e.querySelector("a[href]"),l=a?n.getComputedStyle(a).color:"",s=go(n.getComputedStyle(t.body).backgroundColor);(!s||0===s.a)&&(s=go(n.getComputedStyle(o).backgroundColor));let d=!!(s&&s.a>0?wo(s)<.2:!0===n.matchMedia?.("(prefers-color-scheme: dark)").matches&&/dark/.test(n.getComputedStyle(o).colorScheme||"")),c=l&&l!==vo?go(l):null,u=c&&yo(wo(c),d?.011:1)>=3,p=r||(u?l:d?mo:fo),h=go(p);return{font:i,accent:p,dark:d,on:h&&yo(wo(h),1)<3?"#111":"#fff"}}function xo(e,t){e.style.setProperty("--pu-font",t.font),e.style.setProperty("--pu-accent",t.accent),e.style.setProperty("--pu-on",t.on),e.classList.toggle("dark",t.dark)}var ko=40,Eo=250,So=120,$o=2400,Lo=4e3,Mo=1e4;function Co(e,t=!1){return In(e,t)?"column":"bubbles"}var Ao=1e3,To="Shown here, but not saved yet — it will be saved with your next change",Po=e=>e instanceof Error?e.message.replace(/^pipeup: /,""):"Something went wrong";function No(e){let t=bo(e.root),n=function(e,t=document){let n=t.createElement("pipeup-root");n.setAttribute("data-pipeup-ignore",""),n.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 o=n.attachShadow({mode:"open"}),i=t.defaultView?.CSSStyleSheet;if(i&&"replaceSync"in i.prototype&&"adoptedStyleSheets"in o){let e=new i;e.replaceSync(ho),o.adoptedStyleSheets=[e]}else{let e=t.createElement("style");e.textContent=ho,o.append(e)}let r=t.createElement("div");return r.className="layer",r.style.setProperty("--pu-panel",`${Gt}px`),r.style.setProperty("--pu-pop",`${Jt()}px`),xo(r,e),o.append(r),t.documentElement.append(n),{element:n,shadow:o,t:r,destroy:()=>n.remove()}}(t),o=function(e=document,t=!1){let n=e.defaultView?.CSSStyleSheet;if(!n||!("replaceSync"in n.prototype)||!("adoptedStyleSheets"in e))return{Ee(){},ke(){},ae(){},Se(){},remove:()=>po()};let o=new n,i=null,r=!1,a=1,l=0,s="",d=0,c=()=>o.replaceSync(so(t,a)+(null===i?"":`:root{--pipeup-gutter:${i}px}`)+(r?uo:"")+(l||s?`html{--pipeup-panel:${l}px;${l?`margin-right:${l}px!important;`:""}${s}}`:""));return c(),e.adoptedStyleSheets=[...e.adoptedStyleSheets,o],{Ee(e){e!==i&&(i=e,c())},ke(e){e!==r&&(r=e,c())},ae(e){a=e,c()},Se(e,t){e!==l&&(l=e,s=t?"":"transition:margin-right .34s cubic-bezier(.4,0,.2,1)!important",clearTimeout(d),!e&&s&&(d=window.setTimeout(()=>{s="",c()},400)),c())},remove(){clearTimeout(d),e.adoptedStyleSheets=e.adoptedStyleSheets.filter(e=>e!==o),po()}}}(document,t.dark);o.ae(0);let i=!0===window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,r=document.documentElement.hasAttribute("data-pipeup-reserve"),a=new Map,l=new Set,s=new WeakSet,d={i:null,f:null,C:!1,hidden:!0,mode:Co(e.root),o:null,l:!1,d:!1,Te:!1,c:!1},c=Ze("div",{class:"toast",role:"status","aria-live":"polite"}),u=Ze("div",{class:"sr","aria-live":"polite"});n.t.append(c,u);let p=null,h=[],f=null,m=!1,v=0,w=0,y=0,b=0,x=0,k=new Set,E="",S=new Map,$=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,ne:()=>({width:window.innerWidth,height:window.innerHeight})}}()){let o=!0===window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,i=null,r=null,a=0,l=!1,s=()=>[...e.querySelectorAll(_n)],d=()=>[...e.querySelectorAll(".slides > section")],c=e=>"string"==typeof e&&e.length>0&&e.length<=g.viewValue?e:null,u=e=>c(e?.getAttribute("data-pipeup-slide"));function p(){if(Zn){let e=null;if(to(()=>{let t=Zn.current();Number.isInteger(t)&&t>0&&(e=String(t))}),null!==e)return e}let e=ro();if(e){let t=null;if(to(()=>{let n=e.getIndices().h,o=d()[n];t=u(o?.matches(_n)?o:o?.querySelector(_n))??c(String(n+1))}),null!==t)return t}return i&&!i.isConnected&&(i=null),i=function(e,t,n){let o=t.ne(),i=null,r=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>r||c===r&&(u>a||u===a&&l===n))&&(i=l,r=c,a=u)}return i}(s(),n,i)??i,u(i)}function h(){a=0,r=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,r,Xn),v=new MutationObserver(e=>{e.some(e=>e.target instanceof Element&&e.target.matches(_n))&&f()});v.observe(e,{subtree:!0,attributes:!0,attributeFilter:["class","style","hidden"]});for(let e of Jn)window.addEventListener(e,f,{capture:!0,passive:!0});return eo.add(f),r=p(),{slide:()=>r,view(e){let t=e instanceof Element?e:e?.parentElement,n=u(t?.closest(_n))??r,o={...null!==n?{slide:n}:{},...Xn};return Object.keys(o).length?o:void 0},u:m,R:function(e){if(m(e))return Promise.resolve(!0);let t=e.slide,n=ro(),i=s().find(e=>u(e)===t),a=/^[1-9]\d{0,5}$/.test(t??"");if(a&&Zn)to(()=>Zn.go(Number(t)));else if(a&&n){let e=i?d().findIndex(e=>e===i||e.contains(i)):-1;to(()=>n.slide(e>=0?e:Number(t)-1))}else if(Qn.size)for(let t of Qn)to(()=>t({...e}));else{if(!i)return Promise.resolve(!1);i.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),Gn),i=()=>l?n(!1):(r=p(),m(e)?n(!0):performance.now()-c>=Gn?n(!1):void requestAnimationFrame(i));requestAnimationFrame(i)})},destroy(){l=!0,cancelAnimationFrame(a),v.disconnect();for(let e of Jn)window.removeEventListener(e,f,!0);eo.delete(f)}}}(e.root,()=>{!m&&B()&&U()}),L=!1,M=0;function C(e,t=$o,n=!1,o=!1){m||(L=n,c.textContent=e,o?c.setAttribute("aria-hidden","true"):c.removeAttribute("aria-hidden"),c.classList.add("show"),window.clearTimeout(v),v=window.setTimeout(()=>c.classList.remove("show"),t))}function A(){L&&(L=!1,window.clearTimeout(v),c.classList.remove("show"))}function T(e){u.textContent="",cancelAnimationFrame(M),M=requestAnimationFrame(()=>u.textContent=e)}function P(e){C(Po(e))}function N(e){throw P(e),e}let q=t=>({thread:t,location:ze(t.anchor,a.get(t.id)??Me(t.anchor,e.root),e.root)}),O={reply:async(t,n)=>{try{await e.doc.reply(t,n)}catch(e){e instanceof _?C(To):N(e)}},resolve:async t=>{try{await e.doc.resolve(t),C("Resolved · Show resolved brings it back")}catch(e){C(e instanceof _?`Resolved · ${To}`:Po(e))}(e=>d.i===e&&!d.C&&(f?.ie()?f.se():n.t.querySelector(".launch .mode")?.focus({preventScroll:!0}),!0))(t)&&(d.i=null)},reopen:async t=>{try{await e.doc.reopen(t),C("Reopened")}catch(e){C(e instanceof _?`Reopened · ${To}`:Po(e))}},close:()=>{ee(null);let e=Y&&n.t.querySelector(Y);e?e.focus({preventScroll:!0}):f?.se(),Y=""},copy:t=>{try{let o=e.doc.threads().find(e=>e.id===t);if(!o)return;Kn(Be(q(o),"ai",location.href,Date.now()),n.t).then(()=>C("Thread copied as Markdown for AI"),e=>C(Po(e)))}catch(e){C(Po(e))}}},z={copyAll:async e=>{let t=z.all(),o=He(t,e,{title:document.title,url:location.href,exportedAt:new Date});try{await Kn(o,n.t);let i=t.filter(e=>!e.thread.resolved).length;C(`Copied ${i} thread${1===i?"":"s"}${"ai"===e?" as Markdown for AI":""}`)}catch(e){C(Po(e))}},je:()=>{d.C=!d.C,U()},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)?C(`New comments will say ${n}, but this browser couldn't remember it`):C(`New comments will say ${n}`)}catch(e){C(Po(e))}},name:()=>e.doc.name,all:()=>[...e.doc.threads()].sort(en(D)).map(q)},R={},D={get addons(){return R.surface},doc:e.doc,root:e.root,t:n.t,host:n.element,state:d,resolved:a,S:l,ee:O,c:z,p:$,V:e=>k.has(e.id),xe:()=>{B()&&U()},B:e=>!d.hidden&&(!e.resolved||d.C||(e=>""!==(n.t.querySelector(`[data-thread="${e}"] .rbox textarea`)?.value.trim()??""))(e.id))&&!k.has(e.id),Xe:(t,n)=>{for(let o of e.doc.threads()){let e=a.get(o.id);if(o.anchor.quote&&D.B(o)&&e?.range&&_t(t,n,Vt(e)))return o}return null},te:(e,t)=>D.L()?D.Xe(e,t):null,w:e=>e.composedPath().includes(n.element),ye:e=>{s.add(e)},Ue:e=>s.has(e),open:ee,Je:e=>Z(e),f:function(e){d.f!==e&&(d.f=e,e&&e!==d.i&&ae(e),U())},Ye:te,qe:function(e){if(!d.o)return te(e);Object.assign(d.o,e),U()},L:()=>!p||p.De(),we:e=>{let t=p?.ge();e(),t?.()},ze:()=>{let e=d.o?.anchor.view,t=p?.ge();Promise.resolve($.u(e)||$.R(e??{}).then(()=>D.xe())).then(t)},Be:async function(t){let n=d.o;if(n)try{let o=await e.doc.comment(n.anchor,t);d.o=null,I(new Set([o])),ee(o,!0)}catch(e){if(e instanceof _)return d.o=null,I(new Set([e.id])),ee(e.id,!0),void C(To);N(e)}},Fe:ne,Ge:oe,F:re,H:e=>{p=e},J:C,E:T,Ke:A,oe:P,Qe:ae,m:U,re:ie},F=R.surface=new Nt(D,n.shadow,u);function I(t){let n=performance.now(),o=e.doc.threads();for(let i of o){if(t&&!t.has(i.id))continue;let o=performance.now()-n<ko,r=Me(i.anchor,e.root,{fuzzy:o});a.set(i.id,r),o||"orphaned"!==r.state?l.delete(i.id):l.add(i.id)}for(let e of[...a.keys()])o.some(t=>t.id===e)||a.delete(e);0===l.size?(window.clearTimeout(b),b=0):0===b&&(b=window.setTimeout(()=>{b=0,!m&&(I(new Set(l)),U())},Eo))}function B(){let t=new Set,n=null!==$.slide(),o=new Set;for(let i of e.doc.threads()){o.add(i.id);let e=a.get(i.id)?.element;(!$.u(i.anchor.view)||!n&&!1===e?.checkVisibility?.({visibilityProperty:!0}))&&t.add(i.id)}k=t;for(let e of S.keys())o.has(e)||S.delete(e);let i=`${$.slide()}|${[...t].join()}`;return i!==E&&(E=i,!0)}let H=0,j=0,W=0,K=0,V=0;function U(){if(m)return;let t=e.doc.threads();if(B(),d.i&&k.has(d.i)){let e=n.t.querySelector(`[data-thread="${d.i}"] .rbox textarea`)?.value;e&&S.set(d.i,e),d.i=null}d.hidden=!(d.l||d.d||d.Te||d.o),d.hidden&&(d.i=null),function(e){if(e===j)return;j=e,cancelAnimationFrame(W);let t=H,n=performance.now(),i=e?260:200,r=a=>{let l=Math.min(1,(a-n)/i);H=t+(e-t)*(e?1-(1-l)**3:l*l),o.ae(H),l<1&&(W=requestAnimationFrame(r))};W=requestAnimationFrame(r)}(d.hidden?0:1),n.t.classList.toggle("hidden",d.hidden),n.t.classList.toggle("listing",d.d);let l=d.d&&!Xt();(function(e){e!==K&&(K=e,o.Se(e,i),window.clearTimeout(V),V=window.setTimeout(()=>{I(),U()},i?0:400))})(l?Gt:0),o.Ee(r?"column"!==d.mode||d.hidden||l?0:Rn:null),function(e){let t=[],n=[],o=[];for(let i of e){let e=a.get(i.id);i.resolved&&!d.C||!e?.range||k.has(i.id)||(i.id===d.i||i.id===d.f?n.push(e.range):i.resolved?o.push(e.range):t.push(e.range))}d.o&&$.u(d.o.anchor.view)&&n.push(...d.o.ranges),function(e){if(co())for(let t of ao)CSS.highlights.set(t,new Highlight(...e[t.slice(7)]))}({quote:t,on:n,done:o})}(t);for(let e of h)e.m(t);f?.m(t),d.hidden||F.flush()}let Y="",G=()=>n.t.getRootNode().activeElement,J="input,textarea,select,[contenteditable]:not([contenteditable=false])",X=()=>{let e=G();return e instanceof HTMLTextAreaElement&&""!==e.value||!!document.activeElement?.matches(J)};function Z(e,t=X(),o=G()){let i=[...n.t.querySelectorAll(`[data-thread="${e}"] .rbox textarea`)].find(e=>!e.closest("[inert]")),r=o?.getAttribute("data-thread");Y=r?`.${o.classList[0]}[data-thread="${r}"]`:"",!t&&i&&i.focus({preventScroll:!0})}function Q(){let e=d.o;return!(!e||D.L()||($.u(e.anchor.view)||$.R(e.anchor.view??{}),0))}function ee(e,t=!1){if(e&&Q())return;if(d.i===e&&!d.o)return e?Z(e):void 0;let o=!t&&X(),i=G();if(e||(d.Te=!1),d.i=e,e&&(d.o=null,ae(e)),U(),e){let r=S.get(e),a=r&&n.t.querySelector(`[data-thread="${e}"] .rbox textarea`);a&&!a.value&&(a.value=r,a.dispatchEvent(new Event("input",{bubbles:!0}))),S.delete(e),t&&f?.ie()?f.se():Z(e,o,i)}}function te(e){A(),d.d=!1,d.o=e,d.i=null,U()}function ne(){d.o&&(d.o=null,U())}function oe(e,t=!1){d.l!==e&&(d.l=e,o.ke(e),e?(d.i=null,d.d=!1,f=Nn(D)):(A(),f?.destroy(),f=null,T("Comment mode off")),U(),f&&(t&&f.be(),t?f.ie()?C(An,Mo,!0,!0):C("Nothing here to comment on"):C(`Click anything to comment, or Tab between blocks · Option-click (Alt-click) to pin · ${Ht} or Esc to finish`,Lo,!0)))}function ie(){d.o&&($.u(d.o.anchor.view)||D.L())?ne():d.i?ee(null):f&&!f.re()&&oe(!1)}function re(){d.o?Q()||ne():d.i&&ee(null)}function ae(e){let t=a.get(e);!t||"orphaned"===t.state||le(t.range?Vt(t):t.element?[t.element.getBoundingClientRect()]:[])}function le(e){for(let t of e.slice(0,6)){let e=Ze("div",{class:"pulse"});ot(e,t,4),n.t.prepend(e),window.setTimeout(()=>e.remove(),1300)}}function se(){for(let e of h)e.destroy();h=function(e){return[..."column"===e.state.mode?[Hn(e),an(e,{Z:!1})]:[an(e,{Z:!0})],Wn(e),Yn(e)]}(D),U()}Je.go=t=>{if(t.startsWith("slide:"))return void $.R({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:i?"auto":"smooth"}),window.setTimeout(()=>le([o.getBoundingClientRect()]),i?0:450))};let de=()=>{if(!m){for(let e of h)e.T();f?.T(),F.T(),x=requestAnimationFrame(de)}},ce=e=>{if("Escape"===e.key)return ie();if(function(e){return e.code===Bt.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(J)})(e)){if(e.preventDefault(),f?.We()&&f.be())return;oe(!d.l,!0)}},ue=e=>{if(D.w(e)||s.has(e))return;let t=window.getSelection();t&&!t.isCollapsed||re()},pe=()=>{n.t.style.setProperty("--pu-pop",`${Jt()}px`);let t=Co(e.root,"column"===d.mode);t!==d.mode?(d.mode=t,se()):U()};function he(){let e=performance.now();0===w&&(y=e),window.clearTimeout(w);let t=Math.min(So,Math.max(0,y+Ao-e));w=window.setTimeout(()=>{w=0,I(),U()},t)}let fe=new MutationObserver(e=>{e.every(e=>n.element.contains(e.target))||he()});window.addEventListener("keydown",ce),window.addEventListener("click",ue),window.addEventListener("resize",pe),fe.observe(e.root,{subtree:!0,childList:!0,characterData:!0});let me=new MutationObserver(()=>xo(n.t,bo(e.root)));for(let e of[document.documentElement,document.body])me.observe(e,{attributes:!0});let ve=new ResizeObserver(he);ve.observe(e.root);let ge=e.doc.onChange((e,t,n)=>{F.Oe(t,n),I(),U()});return I(),se(),x=requestAnimationFrame(de),{ctx:D,destroy(){m=!0,cancelAnimationFrame(x),cancelAnimationFrame(W),cancelAnimationFrame(M),$.destroy(),window.clearTimeout(V),window.clearTimeout(v),window.clearTimeout(w),window.clearTimeout(b),fe.disconnect(),Je.go=void 0,ve.disconnect(),me.disconnect(),ge(),window.removeEventListener("keydown",ce),window.removeEventListener("click",ue),window.removeEventListener("resize",pe),f?.destroy();for(let e of h)e.destroy();F.destroy(),o.remove(),n.destroy()}}}var qo,Oo=null,zo=4e3;function Ro(e={}){if(zt)return zt.mount(e);if(!Ft())return Promise.reject(new Error("pipeup: another copy of Pipeup owns the add-on queue. Remove one script."));if(Oo)return Oo;let t=async function(e,t){let n,o,i=document.documentElement.getAttribute("data-pipeup-doc"),{id:r,key:a}=i?await K(i):{id:`page-${c(location.origin+location.pathname)}`,key:null},l=!1;if(e.store)n=e.store,o=await te(n);else try{let e=ne.open();n=await function(e,t){return new Promise((n,o)=>{let i=setTimeout(()=>o(new Error("timed out")),t);e.then(n,o).finally(()=>clearTimeout(i))})}(e,zo).catch(t=>{throw e.then(e=>e.close(),()=>{}),t}),o=await te(n)}catch{n=new Z,l=!0,o=await te(n)}let s=e.name?.trim();s&&s!==o.name&&(o={...o,name:s},await n.saveProfile(o));let d,u=await G.open({doc:r,key:a,store:n,identity:o.identity,name:o.name});io(e.slides??null);try{d=No({doc:u,root:e.root??document.body,onName:async e=>{u.name=e,o={...o,name:e},await n.saveProfile(o)}})}catch(e){throw io(null),e}l&&d.ctx.J("This browser can't keep comments for this page — copy the comments (Copy as Markdown) to keep them");let p=()=>{u.flush().catch(e=>globalThis.reportError?.(e))},h=function(e){let t={...e,i:!0};Ot=t;for(let e of qt.values())"waiting"===e.info.state&&It(e,t);return()=>{t.i=!1,Ot===t&&(Ot=null);for(let e of[...qt.values()].reverse())e.stop?.(),delete e.stop;e.surface.destroy()}}({surface:d.ctx.addons,doc:u,root:e.root??document.body,ephemeral:l,version:Ue}),f=!1;return window.addEventListener("pagehide",p),{document:u,flush:()=>u.flush(),unmount:()=>{f||(f=!0,window.removeEventListener("pagehide",p),h(),d.destroy(),io(null),Oo===t()&&(Oo=null))}}}(e,()=>t).catch(e=>{throw Oo===t&&(Oo=null),e});return Oo=t,t}return typeof document<"u"&&(zt?console.warn(`pipeup: Pipeup is on this page twice (${zt.VERSION} and ${Ue}); the first one is used. Remove one script.`):(Ft(),function(){let e=document.documentElement;if(!e.hasAttribute("data-pipeup-doc")||"off"===e.getAttribute("data-pipeup-auto"))return;let t=()=>{Ro().catch(e=>console.error(e))};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",t,{once:!0}):t()}())),qo=i,((i,r,a,l)=>{if(r&&"object"==typeof r||"function"==typeof r)for(let a of n(r))!o.call(i,a)&&void 0!==a&&e(i,a,{get:()=>r[a],enumerable:!(l=t(r,a))||l.enumerable});return i})(e({},"__esModule",{value:!0}),qo)})();
1
+ "use strict";var Pipeup=(()=>{var e=Object.defineProperty,t=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,r={};function i(e){let t="";for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function a(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 l(e){return(new TextEncoder).encode(e)}function s(e){if(null===e||"object"!=typeof e)return JSON.stringify(e);if(Array.isArray(e))return"["+e.map(s).join(",")+"]";let t=e;return"{"+Object.keys(t).filter(e=>void 0!==t[e]).sort().map(e=>JSON.stringify(e)+":"+s(t[e])).join(",")+"}"}function d(e){return e.replace(/\s+/g," ").trim()}function c(e){let t=d(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")}((t,n)=>{for(var o in n)e(t,o,{get:n[o],enumerable:!0})})(r,{ADDON_API:()=>Mt,AI_NAME:()=>B,ANIMALS:()=>q,COLOURS:()=>O,DEFAULT_PROFILE_NAME:()=>Q,IndexedDbStore:()=>ne,MemoryStore:()=>Z,PipeupDocument:()=>G,UnsavedChangeError:()=>_,VERSION:()=>Ye,addons:()=>Rt,animalName:()=>I,comments:()=>Ko,computeOpId:()=>P,copyAll:()=>He,copyThread:()=>Be,createIdentity:()=>h,describeElement:()=>we,describeRange:()=>ge,formatAgo:()=>Fe,isAiName:()=>H,labelOf:()=>Oe,loadOrCreateProfile:()=>te,locate:()=>ze,mount:()=>Wo,nameOf:()=>F,newDocumentAttribute:()=>W,onReveal:()=>ro,parseDocumentAttribute:()=>K,resolveAnchor:()=>Ae,setViewState:()=>oo,signOp:()=>k,use:()=>Dt});var p=/^[A-Za-z0-9_-]{43}$/,u=new Map;async function h(){let e=await crypto.subtle.generateKey({name:"Ed25519"},!1,["sign","verify"]);return{publicKey:i(new Uint8Array(await crypto.subtle.exportKey("raw",e.publicKey))),privateKey:e.privateKey}}async function f(e,t){let n=await crypto.subtle.sign({name:"Ed25519"},e.privateKey,t);return i(new Uint8Array(n))}var m=2**40,v=2**47,g={doc:64,path:2e3,snapshot:500,anchorId:200,quote:1e4,context:64,viewEntries:16,viewKey:64,viewValue:200},w=/^[0-9a-f]{8}$/,y=/^[A-Za-z0-9_-]{43}$/,b=/^[A-Za-z0-9_-]{43}$/,x=new Set(["create","reply","edit","delete","resolve","reopen","addressed"]);async function k(e,t){if(e.author!==t.publicKey)throw new Error("pipeup: an op must be signed by its author");return{body:e,sig:await f(t,l(s(e)))}}var E=(e,t)=>"string"==typeof e&&e.length<=t,$=e=>!!e&&"object"==typeof e,S=e=>"number"==typeof e&&Number.isFinite(e)&&e>=0&&e<=1;function L(e){if(!$(e))return!1;let{id:t,path:n,fingerprint:o,snapshot:r,quote:i,point:a,view:l}=e;if(!(E(n,g.path)&&E(r,g.snapshot)&&"string"==typeof o&&w.test(o)&&(void 0===t||E(t,g.anchorId)&&""!==t)&&(void 0===i||$(i)&&E(i.exact,g.quote)&&""!==i.exact&&E(i.prefix,g.context)&&E(i.suffix,g.context))&&(void 0===a||$(a)&&S(a.x)&&S(a.y))))return!1;if(void 0!==l){if(!$(l)||Array.isArray(l))return!1;let e=Object.entries(l);if(e.length>g.viewEntries||!e.every(([e,t])=>e.length<=g.viewKey&&E(t,g.viewValue)))return!1}return!0}function A(e){if(!$(e))return!1;let{body:t,sig:n}=e;if("string"!=typeof n||!$(t)||JSON.stringify({body:t,sig:n}).length>262144)return!1;let o=t;return!(1!==o.v||"string"!=typeof o.id||!y.test(o.id)||!x.has(o.kind)||!E(o.doc,g.doc)||""===o.doc||"string"!=typeof o.thread||!y.test(o.thread)||"string"!=typeof o.author||!b.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>m||"number"!=typeof o.at||!Number.isSafeInteger(o.at)||o.at<0||o.at>v||void 0!==o.text&&(!E(o.text,1e4)||o.text!==o.text.trim())||void 0!==o.target&&("string"!=typeof o.target||!y.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||"create"===o.kind&&(o.id!==o.thread||!L(o.anchor)))}function M(e){return async function(e,t,n){if(!p.test(e))return!1;try{if(i(a(e))!==e)return!1;let o=u.get(e);if(!o){u.size>=512&&u.delete(u.keys().next().value),o=crypto.subtle.importKey("raw",a(e),{name:"Ed25519"},!0,["verify"]),u.set(e,o);let t=o;t.catch(()=>{u.get(e)===t&&u.delete(e)})}return await crypto.subtle.verify({name:"Ed25519"},await o,a(n),t)}catch{return!1}}(e.body.author,l(s(e.body)),e.sig)}function C(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 T(e,t,n,o,r){return{id:e,author:t,name:n,text:o,at:r,edited:!1,deleted:!1,replies:[]}}async function P(e){let t={...e,id:void 0,thread:"create"===e.kind?void 0:e.thread},n=await crypto.subtle.digest("SHA-256",l(s(t)));return i(new Uint8Array(n))}var N=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(C)){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=T(r.id,r.author,r.name,r.text,r.at);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=T(r.id,r.author,r.name,r.text,r.at);e.root.replies.push(t),n.set(r.id,{comment:t,thread:r.thread});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),"delete"===r.kind&&(i.comment.text="",i.comment.deleted=!0))}}for(let{comment:e}of n.values())e.name||(e.unnamed=!0,e.name=o.get(e.author)??"");return[...t.values()]}(this.ops.values())}async add(e){let t=[];for(let n of e){if(!A(n)||n.body.doc!==this.doc||this.ops.has(n.body.id)||n.body.id!==await P(n.body)||!await M(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,m),at:Math.min(Math.max(Date.now(),"create"===n.kind?(this.createAt.get(e.publicKey)??0)+1:(this.threadAt.get(n.thread)??0)+1),v)};o.id=await P(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 k(o,e)]);if(!i)throw new Error("pipeup: could not record this change");return i}},q=["Otter","Fox","Owl","Bear","Rabbit"],O=["Red","Orange","Yellow","Green","Teal","Blue","Purple","Pink","Brown","Grey"];function z(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 R=e=>z(e)%q.length,D=e=>Math.floor(z(e)/q.length)%O.length,I=e=>`${O[D(e)]} ${q[R(e)]}`,F=e=>e.name.replace(/^AI assistant · /,"")||I(e.author),B="AI assistant",H=e=>e===B||e.startsWith(`${B} `),j=/^([A-Za-z0-9_-]{16}):([A-Za-z0-9_-]{43})$/;function W(){return`${function(e=16){return i(crypto.getRandomValues(new Uint8Array(e)))}(12)}:${i(crypto.getRandomValues(new Uint8Array(32)))}`}async function K(e){let t=j.exec(e.trim()),n=t?.[1],o=t?.[2];if(!n||!o)throw new Error('pipeup: data-pipeup-doc must look like "<id>:<key>", as made by newDocumentAttribute()');return{id:n,key:await crypto.subtle.importKey("raw",a(o),{name:"AES-GCM"},!1,["encrypt","decrypt"])}}async function V(e,t,n){let o=crypto.getRandomValues(new Uint8Array(12)),r=await crypto.subtle.encrypt({name:"AES-GCM",iv:o,additionalData:l(n)},e,l(t));return{iv:i(o),data:i(new Uint8Array(r))}}var Y=e=>`pipeup-file:${e}`;var U=/^[a-z][a-z0-9-]{1,23}\/[a-z][a-z0-9-]{0,31}$/,_=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"}},G=class e{constructor(e,t){this.log=e,this.options=t,this.displayName=t.name.trim()?X(t.name):""}listeners=new Set;cache=[];comments=new Map;displayName;le=Promise.resolve();unsaved=[];static async open(t){if("string"!=typeof t.doc||""===t.doc||t.doc.length>g.doc)throw new Error(`pipeup: the document id must be 1 to ${g.doc} characters`);let n=new N(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=X(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){return this.enqueue(()=>this.write({kind:"create",anchor:e,text:J(t)}))}reply(e,t){return this.enqueue(()=>this.write({kind:"reply",thread:this.find(e).thread,target:e,text:J(t)}))}edit(e,t){return this.enqueue(async()=>{let{thread:n}=this.mine(e);await this.write({kind:"edit",thread:n,target:e,text:J(t)})})}remove(e){return this.enqueue(async()=>{let{thread:t}=this.mine(e);await this.write({kind:"delete",thread:t,target:e})})}resolve(e){return this.enqueue(async()=>{await this.write({kind:"resolve",thread:this.thread(e)})})}reopen(e){return this.enqueue(async()=>{await this.write({kind:"reopen",thread:this.thread(e)})})}sign(e,t){if(!U.test(e))throw new Error('pipeup: a signing purpose looks like "<add-on id>/<name>"');return f(this.options.identity,l(`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 V(n,JSON.stringify(t),Y(e))}:{pipeup:1,doc:e,sealed:!1,ops:t};return JSON.stringify(o,null,2)}(this.options.doc,this.log.all(),this.options.key)}async importFile(e){return this.merge(await async function(e,t,n){if(e.length>5e6)throw new Error("pipeup: this feedback file is too large");let o,r,i;try{o=JSON.parse(e)}catch{throw new Error("pipeup: this is not an Pipeup feedback file")}if(!o||"object"!=typeof o||1!==o.pipeup||"string"!=typeof o.doc)throw new Error("pipeup: this is not an Pipeup feedback file");if(o.doc!==t)throw new Error("pipeup: this feedback is for a different document");if(!o.sealed)return Array.isArray(o.ops)?o.ops:[];if(!n)throw new Error("pipeup: this feedback is sealed, and this page has no document key");if("string"!=typeof o.iv||"string"!=typeof o.data)throw new Error("pipeup: this is not an Pipeup feedback file");try{r=await async function(e,t,n){try{let o=await crypto.subtle.decrypt({name:"AES-GCM",iv:a(t.iv),additionalData:l(n)},e,a(t.data));return(new TextDecoder).decode(o)}catch{throw new Error("pipeup: this feedback could not be opened with this document")}}(n,{iv:o.iv,data:o.data},Y(t))}catch{throw new Error("pipeup: this feedback could not be opened with this document's key")}try{i=JSON.parse(r)}catch{throw new Error("pipeup: this is not an Pipeup feedback file")}return Array.isArray(i)?i:[]}(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 _(n[0].body.id,e,n.length):e}return n.length})}enqueue(e){let t=this.le.then(e);return this.le=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 _(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 J(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 X(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(H(t))throw new Error("pipeup: that name is kept for AI replies; choose another");return t}var Z=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}},Q="",ee="Reviewer";async function te(e,t=Q){let n=await e.loadProfile();if(n)return n.name===ee?{...n,name:""}:n;let o={identity:await h(),name:t};return e.saveProfileIfAbsent(o)}var ne=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=oe(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=oe(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 oe(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 re(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 ie(e,t,n){let o=(e.ownerDocument??e).createRange();return o.setStart(e,0),o.setEnd(t,n),o.toString().length}function ae(e,t,n){let o=le(e,t,!1),r=le(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 le(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}}var se=32,de=200,ce="p,li,h1,h2,h3,h4,h5,h6,td,th,blockquote,pre,figcaption,dt,dd,summary,caption";function pe(e){return e.nodeType===Node.ELEMENT_NODE?e:e.parentElement}function ue(e,t){for(let n=pe(e)?.closest("[data-pipeup-id]")??null;n;){if(!t.contains(n))return null;let e=n.getAttribute("data-pipeup-id")??"";if(""!==e&&e.length<=g.anchorId)return n;n=n.parentElement?.closest("[data-pipeup-id]")??null}return null}function he(e,t,n){return e.slice(t,n).replace(/^[\uDC00-\uDFFF]|[\uD800-\uDBFF]$/g,"")}function fe(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>g.path)throw new Error("pipeup: this element is nested too deeply to comment on — give a nearby container a data-pipeup-id");return n}function me(e){if(!L(e))throw new Error("pipeup: could not describe this place on the page");return e}function ve(e,t){let n=pe(e),o=n?.closest(ce)??null;return o&&t.contains(o)?o:n&&t.contains(n)?n:t}function ge(e,t,n){if(!t.contains(e.commonAncestorContainer))throw new Error("pipeup: the selection is outside the commentable area");let o=ue(e.commonAncestorContainer,t),r=o??t,{text:i}=re(r),a=ie(r,e.startContainer,e.startOffset),l=ie(r,e.endContainer,e.endOffset),s=i.slice(a,l);if(""===s)throw new Error("pipeup: select some text to comment on");if(s.length>g.quote)throw new Error(`pipeup: selections are limited to ${g.quote} characters`);let p=he(i,Math.max(0,a-se),a),u=he(i,l,l+se);return me({...o?{id:o.getAttribute("data-pipeup-id")??""}:{},path:"",quote:{exact:s,prefix:p,suffix:u},...n?{view:n}:{},fingerprint:c(ve(e.startContainer,t).textContent??""),snapshot:he(d(p+s+u),0,de)})}function we(e,t,n,o){let r=ue(e,t);return me({...r?{id:r.getAttribute("data-pipeup-id")??""}:{},path:fe(r??t,e),...n?{point:{x:ye(n.x),y:ye(n.y)}}:{},...o?{view:o}:{},fingerprint:c(e.textContent??""),snapshot:he(d(e.textContent??""),0,de)})}function ye(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):0}function be(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 xe=(e,t)=>be(e,t,!1).pop(),ke={state:"orphaned",element:null,range:null},Ee=5e4,$e=300,Se=12,Le=":scope > ";function Ae(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 i=n??o,a=re(i),l=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=Ce(i,t.prefix)+Me(a,t.suffix);l>o&&(n=r,o=l)}return n}(a.text,t);if(l>=0){let r=ae(a,l,l+t.exact.length);if(r){let t=ve(r.startContainer,o);return{state:null!==n&&c(t.textContent??"")===e.fingerprint?"attached":"moved",element:t,range:r}}}if(r){let e=i===o?a:re(o);if(e.text.length<=Ee&&t.exact.length>=Se&&t.exact.length<=$e){let n=function(e,t,n){let o=t.length;if(0===o)return null;let r=-1,i=1/0;if(be(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=xe(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?ae(e,n.start,n.end):null;if(r)return{state:"moved",element:ve(r.startContainer,o),range:r}}}return ke}(e,e.quote,o,t,!1!==n.fuzzy):function(e,t){if(!t)return ke;let n=t;if(e.path){if(!e.path.startsWith(Le))return ke;try{n=t.querySelector(e.path)}catch{return ke}}return n?{state:c(n.textContent??"")===e.fingerprint?"attached":"moved",element:n,range:null}:ke}(e,o)}function Me(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;return n}function Ce(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 Te={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"},Pe=40;function Ne(e){return e.getAttribute("data-pipeup-label")||Te[e.tagName.toUpperCase()]||"Block"}function qe(e){return De(d(e.getAttribute("aria-label")??e.getAttribute("alt")??e.innerText??e.textContent??""),Pe)}function Oe(e){let t=e.getAttribute("data-pipeup-label");if(t)return t;let n=qe(e);return n?`${Ne(e)} · ${n}`:Ne(e)}function ze(e,t,n){let o=e.id??null,r=e.quote?.exact??null,i=e.point?`${Math.round(100*e.point.x)}% across, ${Math.round(100*e.point.y)}% down the element`:null,a=t.element;if("orphaned"===t.state||!a)return{where:`No longer on the page (it read: "${e.snapshot}")`,element:null,id:o,quote:r,pin:i};let l=[],s=e.view?.slide;if(s){let e=a.closest("[data-pipeup-slide]")?.querySelector("h1,h2,h3")?.textContent;l.push(`Slide ${s}`+(e?` "${De(d(e))}"`:""))}else{let t=Re(e.view);t&&l.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}(a,n);o&&l.push(`Section "${De(d(o.textContent??""))}"`)}let c=Oe(a);return l.push(c),{where:l.join(" › "),element:c,id:o,quote:r,pin:i}}function Re(e){return e?e.label||Object.entries(e).filter(([e,t])=>t&&"slide"!==e).map(([,e])=>e).join(" · "):""}function De(e,t=60){return e.length>t?e.slice(0,t-1)+"…":e}var Ie="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 Fe(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 Be(e,t,n,o){return"ai"===t?We(e,"## Comment thread",o,n):Ke(e)}function He(e,t,n){let o=n.all?e:e.filter(e=>!e.thread.resolved);if("text"===t)return o.map(Ke).join("\n");let r=n.all?0:e.length-o.length,i=[`# Review comments: ${je(n.title)}`,"",`- **Page:** ${je(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)":""}`,"",Ie,"",""].join("\n"),a=n.exportedAt.getTime();return i+o.map((e,t)=>We(e,`## Thread ${t+1}`,a)).join("\n")}function je(e){return e.replace(/\s+/g," ").trim()}function We(e,t,n,o){let{thread:r,location:i}=e,a=r.root.replies.length,l=[`${t} · ${r.resolved?"resolved":r.addressed?"open, addressed":"open"}`];if(l.push(`- **Thread:** ${r.id}`),o&&l.push(`- **Page:** ${je(o)}`),l.push(`- **Where:** ${je(i.where)}`),i.id){let e=je(i.id.replace(/`/g,""));l.push(`- **Element:** \`[data-pipeup-id="${e}"]\`${i.element?` (${je(i.element)})`:""}`)}i.quote&&l.push(`- **Quoted text:** "${je(i.quote)}"`),i.pin&&l.push(`- **Pin:** ${je(i.pin)}`),r.addressed&&!r.resolved&&l.push(`- **Addressed:** ${je(r.addressed.text)} (${je(F(r.addressed))}, ${Fe(r.addressed.at,n)})`),l.push(`- **Started by:** ${je(F(r.root))}, ${Fe(r.root.at,n)}${a?` · ${a} ${1===a?"reply":"replies"}`:""}`,"",`**${je(F(r.root))}** (${Fe(r.root.at,n)}): ${Ve(r.root," ")}`);for(let e of r.root.replies)l.push(`- **${je(F(e))}** (${Fe(e.at,n)}): ${Ve(e," ")} \x3c!-- comment:${e.id} --\x3e`);return l.join("\n")+"\n"}function Ke(e){let{thread:t,location:n}=e,o=[je(n.where)+(n.quote?`, on the text "${je(n.quote)}"`:""),`${je(F(t.root))}: ${Ve(t.root," ")}`];for(let e of t.root.replies)o.push(` ${je(F(e))}: ${Ve(e," ")}`);return o.join("\n")+"\n"}function Ve(e,t){return e.deleted?"(deleted)":e.text.replace(/\r\n|\r|\n/g,"\n"+t)+(e.edited?" (edited)":"")}var Ye="0.6.0",Ue=new Map,_e=new Map,Ge=new Map,Je={},Xe=e=>`${Ue.get(e)??""}|${_e.get(e)??""}`;function Ze(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 Qe(e,t){let n=e.getRootNode().activeElement;t&&n instanceof HTMLElement&&e.contains(n)&&n.blur(),e.inert=t}function et(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 tt=()=>{let e=window.getSelection();return e&&!e.isCollapsed&&e.toString().trim()?e:null};function nt(e,t){return e.length>t?e.slice(0,t-1)+"…":e}function ot(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 rt=/\bhttps?:\/\/[^\s<>"'`]+/gi,it=".,;:!?'\"]}",at=2048,lt=/[\u202A-\u202E\u2066-\u2069]/;function st(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(!it.includes(r))break;o--}return e.slice(0,o)}function dt(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>at||lt.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 ct(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?Ze("i",{class:"sl"}):null,Ze("span",{},t||""===e.label?n:`[${e.n}] ${n}`),e.says?Ze("span",{class:"rc",role:"tooltip"},e.says):null];if(/^https?:/.test(e.to)){let t=Ze("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=Ze("button",{class:"ref",type:"button",title:e.says?void 0:t?n:`Show where: ${n}`},...o);return r.addEventListener("click",t=>{t.stopPropagation(),Je.go?.(e.to)}),r});return[...ct(n),Ze("div",{class:"refs"},...o)]}function ct(e){let t=[],n=0;for(let o of e.matchAll(rt)){if(o[0].length>at||lt.test(o[0]))continue;let r,i=st(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=Ze("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 pt="http://www.w3.org/2000/svg",ut={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"],edit:["M4 20h4L19 9l-4-4L4 16z"]};function ht(e,t=15,n){let o=ft(ut[e],t);return n&&o.setAttribute("stroke-width",String(n)),o}function ft(e,t){let n=document.createElementNS(pt,"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(pt,"path");e.setAttribute("d",t),n.append(e)}return n}var mt=(e,t,n)=>`M${e} ${t}a${n} ${n} 0 1 0 ${2*n} 0a${n} ${n} 0 1 0 -${2*n} 0`,vt={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${mt(7.4,11.5,1.9)}${mt(12.8,11.5,1.9)}M11.3 14.6l.7 1 .7-1`,Bear:`${mt(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:`${mt(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 gt(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 wt=(e,t)=>gt(t)||I(e);function yt(e,t,n=!1){return H(t)?Ze("span",{class:n?"av ai busy":"av ai","aria-hidden":"true"},"AI"):Ze("span",{class:`av c${D(e)}`,"aria-hidden":"true","data-animal":I(e)},gt(t)||ft([vt[q[R(e)]]],24))}var bt=320;function xt(e,t){setTimeout(()=>{e.remove(),t?.()},bt)}function kt(e){return requestAnimationFrame(()=>{e.offsetWidth,e.classList.add("in")}),e}var Et=null,$t=e=>{Et=e},St=()=>Et?.note()??null,Lt="pu-source";function At(e){let t=Ze("textarea",{class:"input",rows:"1","aria-label":e.label}),n=Ze("button",{class:"send",type:"button","aria-label":"Send",title:"Send",inert:!0},ht("send")),o=Ze("span",{class:"tools"});o.hidden=!0;let r=Ze("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=(Et?.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=Ze("button",{class:"ib tool",type:"button","aria-label":a.label,title:a.label,"aria-pressed":"false"},ft(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(Lt,u);let h=async()=>{let o=t.value.trim();if(o&&!a){a=!0;try{await e.q(o),n.matches(":focus")&&t.focus(),t.value="",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),t.addEventListener("keydown",n=>{n.stopPropagation(),"Enter"!==n.key||n.shiftKey||n.isComposing?"Escape"===n.key&&(n.preventDefault(),t.value="",d(),t.blur(),s(),e.U?.()):(n.preventDefault(),h())}),n.addEventListener("click",e=>{e.stopPropagation(),h()}),{element:r,input:t,focus:()=>t.focus({preventScroll:!0})}}var Mt=1,Ct=["sync","menu","notify","note","composer","panel","styles","status","overlay","here","sign"],Tt=/^[a-z][a-z0-9-]{1,23}$/,Pt=new Set(["local","file","page","user","pipeup","presence","sync"]),Nt=class{constructor(e,t,n){this.ctx=e,this.shadow=t,this.after=n,$t({tools:()=>this.K,note:()=>[...this.X.values()].at(-1)??null})}G=0;$=[];X=new Map;writing=new Map;marked=new Map;paint=0;J=new Map;K=[];Q=new Set;I=new Set;z=new Set;W=new Map;S=new Map;j=new Map;remote={n:0,who:new Set};last=0;timer=0;de="";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(Lt))}N(e,t){let n=this.j.get(e)??this.j.set(e,new Set).get(e),o=()=>{n.delete(o)&&t()};return n.add(o),o}ce(){return[...this.J.values()].map(e=>e.text).join(" · ")}Ae(e,t){return this.$.push(t),this.changed(!0),{update:()=>this.changed(!1),remove:this.N(e,()=>{this.$.splice(this.$.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?(Ue.delete(t),o.delete(t)):(Ue.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(Ge.delete(t),!_e.delete(t))return;r.delete(t)}else{if(_e.get(t)===n&&!!Ge.get(t)==!!o)return;_e.set(t,n),o?Ge.set(t,o):Ge.delete(t),r.add(t)}this.repaint()}repaint(){this.paint||(this.paint=window.requestAnimationFrame(()=>{this.paint=0,this.ctx.u()}))}pe(e,t,n){n?e.set(t,n):e.delete(t),this.changed(!1)}Me(e,t){return this.K.push(t),this.changed(!1),this.N(e,()=>{this.K.splice(this.K.indexOf(t),1),this.changed(!1)})}closed(){return this.ctx.state.hidden&&!this.ctx.state.s}Le(e,t){this.closed()?this.S.set(e,t):this.ctx.Y(t)}flush(){if(this.closed()||0===this.S.size)return;let e=[...this.S.values()].at(-1);this.S.clear(),this.ctx.Y(e)}Ce(){return this.shadow.activeElement instanceof HTMLTextAreaElement||[...this.ctx.t.querySelectorAll("textarea")].some(e=>""!==e.value.trim())}Pe(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||I(t.author)));this.ue()}}ue(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.Ce())return this.ue(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))}$e(e){let t=this.W.get(e);return t||(t=Ze("div",{class:"ov","aria-hidden":"true","data-addon":e}),this.ctx.t.insertBefore(t,this.after.nextSibling),this.W.set(e,t)),t}Ie(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(Ze("style",{},t));return this.N(e,()=>o?this.shadow.adoptedStyleSheets=this.shadow.adoptedStyleSheets.filter(e=>e!==o):r.remove())}fe(e,t,n){return t.add(n),this.N(e,()=>t.delete(n))}Ne(e,t){return this.fe(e,this.Q,t)}Re(e,t){let n=this.fe(e,this.I,t);return this.call(this.I,t,this.he()),n}he(){let{state:e}=this.ctx,t=this.shadow.activeElement;return{shown:!e.hidden,commentMode:e.d,allOpen:e.c,dark:this.ctx.t.classList.contains("dark"),view:this.ctx.p.view(),writing:t instanceof HTMLTextAreaElement?t.closest("[data-thread]")?.dataset.thread??"":null}}T(){for(let e of[...this.Q])this.call(this.Q,e);if(0===this.I.size)return;let e=this.he(),t=JSON.stringify(e);if(t!==this.de){this.de=t;for(let t of[...this.I])this.call(this.I,t,e)}}call(e,t,...n){try{t(...n)}catch(n){e.delete(t),globalThis.reportError?.(n)}}He(e,t,n){let o=this.ctx.t,r=this.shadow.activeElement,i=Ze("button",{class:"ib",type:"button","aria-label":"Close"},ft(["M6 6l12 12M18 6L6 18"],15)),a=Ze("div",{class:"xp",role:"dialog","aria-label":n.label,"data-addon":e},Ze("div",{class:"hd"},Ze("span",{},n.label),i),Ze("div",{class:"xb"},t)),l=[...o.children].filter(e=>e instanceof HTMLElement&&!e.inert);for(let e of l)e.inert=!0;o.append(a),a.offsetWidth,a.classList.add("show");let s=e=>{"Escape"===e.key&&(e.stopPropagation(),e.preventDefault(),d())},d=this.N(e,()=>{window.removeEventListener("keydown",s,!0);for(let e of l)e.inert=!1;a.classList.remove("show"),a.inert=!0,window.setTimeout(()=>a.remove(),300),r?.focus?.({preventScroll:!0});try{n.onClose?.()}catch(e){globalThis.reportError?.(e)}});return i.addEventListener("click",d),window.addEventListener("keydown",s,!0),(a.querySelector("button, input, textarea, select, a[href]")??a).focus?.({preventScroll:!0}),{close:d}}clear(e){for(let t of[...this.j.get(e)??[]])t();this.j.delete(e),this.W.get(e)?.remove(),this.W.delete(e);for(let t of[this.X,this.J,this.S])t.delete(e);for(let t of this.writing.get(e)??[])Ue.delete(t);this.writing.delete(e);for(let t of this.marked.get(e)??[])_e.delete(t),Ge.delete(t);this.marked.delete(e),this.repaint(),this.changed(!0)}destroy(){window.clearTimeout(this.timer),$t(null),this.z.clear()}},qt=new Map,Ot=null,zt=(()=>{let e=globalThis.Pipeup;return e?.VERSION?e:null})();function Rt(){return zt?zt.addons():[...qt.values()].map(e=>({...e.info}))}function Dt(e){if(zt)return zt.use(e);let t=e=>console.warn(`pipeup: ${e}`),n=e;if(!n||"object"!=typeof n||"string"!=typeof n.id||!Tt.test(n.id)||Pt.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(qt.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=>!Ct.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`)):n.api!==Mt?(o.state="off",o.reason=`needs add-on API ${String(n.api)}; this Pipeup has ${Mt}`):r&&(o.state="off",o.reason=`this Pipeup has no ${r} slot`);let i={addon:e,info:o};qt.set(n.id,i),Ot?.i&&"waiting"===o.state&&Ft(i,Ot)}function It(){if(zt)return!0;let e=globalThis,t=e.pipeupAddons;if(Array.isArray(t))for(let e of t)Dt(e);else if(t&&"object"==typeof t&&t.push!==Dt)return!1;return e.pipeupAddons={push:Dt},!0}async function Ft(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(),onChange:e=>{let t=d.onChange(e);return l.add(t),()=>{t(),l.delete(t)}}},f=r.id,m={api:Mt,version:t.version,document:h,root:t.root,ephemeral:t.ephemeral,signal:a.signal,has:e=>Ct.includes(e),off:e=>{o=String(e)},merge:e=>c()?d.merge(e,f):Promise.resolve(0),addMenuItem:u(e=>s.Ae(f,e)),notify:u(e=>s.Le(f,e)),announce:u(e=>s.Pe(e)),setComposerNote:u(e=>s.pe(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.He(f,e,t)),addStyles:u(e=>s.Ie(f,e)),setStatus:u(e=>s.pe(s.J,f,e)),overlay:()=>s.$e(f),onFrame:u(e=>s.Ne(f,e)),where:e=>s.ctx.p.view(e),isHere:e=>s.ctx.p.f(e),go:e=>s.ctx.p.R(e),onUi:u(e=>s.Re(f,e)),avatar:(e,t)=>{let n=yt(e,t);return n.classList.add("in"),n},sign:(e,t)=>d.sign(`${f}/${e}`,t)},v=()=>{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=v;try{if(n=await r.setup(m),!c())return void n?.();if(void 0!==o)return v(),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),v(),i.state="failed",globalThis.reportError?.(e)}}function Bt(e,t){return{markdown:He(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:F(e),agent:H(e.name),at:new Date(e.at).toISOString(),text:e.deleted?"":e.text}))};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:F(e.addressed)}),n})}}var Ht={code:"KeyC"},jt=typeof navigator<"u"&&/Mac|iP(hone|ad|od)/.test(navigator.platform)?"⇧⌥C":"Shift+Alt+C",Wt="Shift+Alt+C";function Kt(e,t){let n=function(e){let t=Ze("button",{class:"me",type:"button",tabindex:"-1","aria-hidden":"true"});t.addEventListener("mousedown",e=>e.preventDefault());let n=At({label:"Comment",kind:"comment",before:t,q:e.q,U:e.U}),o=Ze("div",{class:"note"}),r=()=>{let e=St();o.textContent=e??"",o.hidden=!e};r();let i=Ze("div",{class:"say"}),a=Ze("input",{class:"input",type:"text",maxlength:"80","aria-label":"Your name"}),l=Ze("div",{class:"nf"},a),s=Ze("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=yt(e.me,n),r=t.lastChild;r?(kt(o),xt(r)):o.classList.add("in"),t.append(o),d=n}let r=Ze("button",{type:"button"},o);r.addEventListener("click",h),i.replaceChildren(Ze("span",{class:"nm"},n||`You're ${I(e.me)}`)," · ",r)},u=e=>{s.classList.toggle("naming",e),Qe(i,e),Qe(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 m=Ze("div",{class:"ctx"},e.label),v=Ze("div",{class:"draft"},m,o,n.element,s);return v.addEventListener(Lt,r),{element:v,ge:()=>{let{selectionStart:e,selectionEnd:t}=n.input;return()=>{n.focus(),n.input.setSelectionRange(e,t)}},Z:e=>{m.hidden=e},ve:e=>{m.textContent=e},focus:()=>n.focus(),De:()=>""===n.input.value.trim()}}({label:t.label,me:e.doc.me,name:()=>e.s.name(),rename:t=>e.s.rename(t),q:t=>e.Be(t),U:()=>e.Fe()});return e.H(n),n}function Vt(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 Yt(e){return e.range?[...e.range.getClientRects()]:[]}function Ut(e,t){let n=Yt(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 _t(e,t){let n=Yt(t).at(-1);if(n)return{x:n.left,y:n.bottom,below:!0};let o=Vt(e,t);return o?{...o,below:!1}:null}function Gt(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 Jt=320,Xt=()=>window.innerWidth>=900?400:300,Zt=()=>window.innerWidth<=480;function Qt(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 en(e,t){let n=e.resolved.get(t.id);return n?.range?.startContainer??n?.element??null}var tn=e=>(t,n)=>{let o=en(e,t),r=en(e,n),i=e=>e.anchor.point??{x:0,y:-1};return o!==r?!r||o&&4&o.compareDocumentPosition(r)?-1:1:i(t).y-i(n).y||i(t).x-i(n).x},nn=e=>`${e} ${1===e?"reply":"replies"}`;function on(e,t,n){let o={...n},r=e.id,i=Ze("div",{class:"rbox always"},Ze("div",{},At({label:"Reply",kind:"reply",thread:()=>r,q:e=>t.reply(r,e),U:t.close}).element)),a=Ze("div",{}),l=Ze("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=Ze("div",{}),d=null,c=null,p=null,u="",h=Ze("div",{},s,Ze("div",{class:"more"},a)),f=new Map,m=new Map,v=new Map,g=e=>{let t=wt(e.author,e.name),n=f.get(e.id),o=n?.e;if((!o||n.key!==t)&&(o=kt(yt(e.author,e.name)),n)){let t=n.e;v.set(e.id,t),xt(t,()=>v.get(e.id)===t&&v.delete(e.id))}o.title=F(e),m.set(e.id,{key:t,e:o});let r=v.get(e.id);return r?[r,o]:[o]},w=(e,t,n)=>{let o=Ze("button",{class:"ib",type:"button","aria-label":t,title:t},ht(e));return o.addEventListener("click",e=>{e.stopPropagation(),n()}),o};function y(e,n={}){Object.assign(o,n),r=e.id;let v=(o.now??Date.now)(),y=e.root.replies.length,b=e=>Ze("span",{class:"who"},`${F(e)} · ${Fe(e.at,v)}`),x=e=>Ze("div",{class:e.deleted?"tx del":"tx"},...e.deleted?["Deleted"]:[...H(e.name)?dt(e.text):ct(e.text),e.edited?" (edited)":""]),k=e.resolved?"Resolved"+(y?` · ${nn(y)}`:""):e.addressed?"Addressed"+(y?` · ${nn(y)}`:""):y?nn(y):"",E=Ze("div",{class:"column"===o.D?k?"ft has-rest":"ft":"ft open"},"column"===o.D&&k?Ze("span",{class:"rest"},k):null,Ze("span",{class:"hover"},b(e.root),Ze("span",{class:"acts"},w("copy","Copy thread",()=>t.copy(e.id)),e.resolved?w("reopen","Reopen",()=>{t.reopen(e.id)}):w("resolve","Resolve",()=>{t.resolve(e.id)})))),$=o.lost?Ze("div",{class:"ctx"},`${o.place||"No longer on the page"} — it read “${nt(o.lost,120)}”`):o.quote?Ze("div",{class:"ctx"},`“${nt(o.quote,80)}”`):null;m=new Map;let S=Ze("div",{class:"root"},...g(e.root),$,x(e.root),E);s.replaceWith(S),s=S,d?.remove();let L=Ue.get(e.id);d=y||void 0!==L?Ze("div",{class:"rps"},...e.root.replies.map(e=>Ze("div",{class:"it"},...g(e),x(e),Ze("div",{class:"column"===o.D?"rft":"rft open"},b(e)))),void 0===L?null:Ze("div",{class:"it ghost"},yt("",B,!0),Ze("div",{class:"tx"},L,Ze("span",{class:"dots"},Ze("i"),Ze("i"),Ze("i"))),Ze("div",{class:"rft open"},Ze("span",{class:"who"},`${B} · writing now`)))):null,d&&a.prepend(d);let A=e.addressed&&!e.resolved?e.addressed:null,M=A?`${A.text}|${A.author}|${A.at}`:"";if(M!==u&&(p?.remove(),p=null,u=M,A)){let n=(e,t)=>{let n=Ze("button",{type:"button"},e);return n.addEventListener("click",e=>{e.stopPropagation(),t()}),n};p=Ze("div",{class:"adr"},Ze("small",{},`Addressed · ${F(A)} · ${Fe(A.at,v)}`),A.text,Ze("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 C=_e.get(e.id),T=Ge.get(e.id);if(c=void 0===C?null:Ze("div",{class:"seen"},Ze("i"),C),c&&T){let e=Ze("button",{type:"button"},"Check again");e.addEventListener("click",e=>{e.stopPropagation(),T()}),c.append(e)}c&&a.insertBefore(c,i.parentNode===a?i:null),f=m;let P=""!==i.querySelector("textarea").value.trim();l.hidden=!(e.resolved&&P),e.resolved&&!P?i.remove():i.parentNode!==a&&a.append(i),h.className=e.resolved?"thread resolved":"thread",h.setAttribute("data-thread",e.id)}return y(e),{element:h,update:y}}var rn="a,button,input,select,textarea,label,summary,[role=button],[contenteditable]",an=400;function ln(e,t){let n=new Map,o=Ze("div",{class:"tip",role:"tooltip"}),r=Ze("div",{class:"mark"}),i=Ze("div",{class:"pop",role:"dialog","aria-label":"Comment thread"});o.inert=i.inert=!0,e.t.append(r,o,i);let a,l=Ze("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,g=0,w=e=>s.find(t=>t.id===e)??null,y=()=>t.ee||e.state.c,b=!1,x=t=>{let n=e.resolved.get(t.id);return n?_t(t.anchor,n):null};function k(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&&!Zt()?t-Jt:t,height:window.innerHeight}}(e.state.c));t.style.left=`${r}px`,t.style.top=`${i}px`}function E(t){let n=t&&y()&&e.state.i!==t?w(t):null,r=n?x(n):null;if(!n||!r)return v=null,o.classList.remove("show"),void Qe(o,!0);if(v!==n.id){let e=n.root.replies.length;o.replaceChildren(Ze("div",{class:"tx clamp"},...n.root.deleted?["Deleted"]:ct(n.root.text)),Ze("div",{class:"who"},`${F(n.root)}${e?` · ${e} ${1===e?"reply":"replies"}`:""}`)),v=n.id}k(o,r,260),o.classList.contains("show")||o.offsetWidth,o.classList.add("show"),o.inert=!1}function $(t){f=t,E(t),e.m(t)}function S(e){window.clearTimeout(g),null===e?g=window.setTimeout(()=>$(null),y()?an:0):$(e)}function L(t){let o=n.get(t.id);if(o)return o;let i=Ze("button",{class:"bub",type:"button","data-thread":t.id});return i.addEventListener("mouseenter",()=>S(t.id)),i.addEventListener("mouseleave",()=>S(null)),i.addEventListener("click",n=>{n.stopPropagation(),E(null),e.open(t.id)}),e.t.insertBefore(i,r),n.set(t.id,i),i}o.addEventListener("mouseenter",()=>window.clearTimeout(g)),o.addEventListener("mouseleave",()=>S(null)),o.addEventListener("click",t=>{t.stopPropagation();let n=v;n&&(window.clearTimeout(g),$(null),e.open(n))});let A=!1;function M(){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||Xt(),height:i.offsetHeight},{width:window.innerWidth,height:window.innerHeight}),r=null!==p?.above&&p?.above!==o;if(p&&(p.above=o),r&&T())return;return i.style.left=`${e}px`,void(i.style.top=`${t}px`)}let o=p&&t?_t(t.anchor,t.resolved):d?x(d):null;o&&k(i,o,Xt())}let C=t=>e.state.d&&!t.anchor.quote&&!t.anchor.point;function T(e=()=>{}){return window.clearTimeout(h),u?(i.classList.remove("show"),h=window.setTimeout(()=>{e(),M(),i.classList.add("show")},220),!0):(e(),i.classList.add("glide"),h=window.setTimeout(()=>i.classList.remove("glide"),450),!1)}let P=t=>{if(e.w(t)){let e=t.composedPath()[0];return null!==m&&!(e instanceof Element&&e.closest(".tip,.bub"))&&S(null),void(m=null)}let n=e.ne(t.clientX,t.clientY)?.id??null;n!==m&&(m=n,S(n))},N=t=>{if(e.w(t))return;let n=window.getSelection();if(n&&!n.isCollapsed||(e.state.d?t.altKey:t.target instanceof Element&&t.target.closest(rn)))return;let o=e.ne(t.clientX,t.clientY);o&&(e.ye(t),E(null),e.open(o.id))};return window.addEventListener("pointermove",P,{capture:!0,passive:!0}),window.addEventListener("click",N,!0),{u:function(o){s=o;let l=new Set;for(let t of o){if(!e.B(t)||t.anchor.quote)continue;let n=e.resolved.get(t.id);if(!n||"orphaned"===n.state)continue;l.add(t.id);let o=L(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 ${Oe(n.element)}: ${nt(t.root.text,60)}`;o.getAttribute("aria-label")!==r&&o.setAttribute("aria-label",r)}et(e.t,o.filter(e=>l.has(e.id)).sort(tn(e)).map(e=>n.get(e.id)),r);for(let[e,t]of n)l.has(e)||(t.classList.remove("in"),n.delete(e),window.setTimeout(()=>t.remove(),300));E(f),b!==e.state.c&&i.classList.contains("show")&&!u&&T(),b=e.state.c;let m=t.ee?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:Kt(e,m),of:m,at:t,above:null},p.l.Z(C(m)),i.replaceChildren(p.l.element),i.inert=!1,p.l.focus(),d=null,c=null,M(),i.classList.add("show")):p&&(p.at!==t&&(p.at=t,p.above=null,T(()=>p?.l.ve(m.label))),p.l.Z(C(m)));let n=!e.p.f(m.anchor.view);return void(n!==A&&(A=n,i.classList.toggle("show",!n),i.inert=n,n||M()))}p&&(window.clearTimeout(h),i.classList.remove("glide"),p=null,A=!1,e.H(null));let v=y()&&e.state.i?w(e.state.i):null;if(!v||!e.B(v))return d=null,c=null,i.classList.remove("show"),void Qe(i,!0);let g=v.anchor.quote?.exact??null;d&&c&&d.id===v.id?(d!==v||a!==Xe(v.id))&&(c.update(v,{quote:g}),d=v,a=Xe(v.id)):(c=on(v,e.te,{D:"popover",quote:g}),i.replaceChildren(c.element),d=v,a=Xe(v.id),M(),i.classList.add("show"),i.inert=!1)},T:function(){for(let[t,o]of n){let n=w(t),r=e.resolved.get(t),i=n&&r?Vt(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.p.f(t.anchor.view)?Vt(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")&&M();let a=function(){if(!y())return null;let t=e.state.o;return t?t.anchor.quote||t.anchor.point||e.state.d?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&&ot(r,a.getBoundingClientRect(),4)},destroy(){window.clearTimeout(g),window.clearTimeout(h),window.removeEventListener("pointermove",P,!0),window.removeEventListener("click",N,!0),e.H(null);for(let e of n.values())e.remove();l.remove(),o.remove(),r.remove(),i.remove()}}}var sn={display:"block",position:"static",clips:!1,off:!1},dn=48,cn="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}]`),pn=["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",...cn].join(","),un="a,button,label,summary,[role=button],[role=link],[role=tab],[role=option],[role=menuitem]",hn=`${un},input,select,textarea,img,svg,canvas,video,picture,[role=img]`,fn=24,mn=.6,vn=(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 gn(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.oe();return n.width*n.height<=mn*o.width*o.height&&(e.matches(pn)||t.Ve(e)||e.childElementCount>1&&!e.parentElement?.closest(un)&&t._e(e))}function wn(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)gn(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&&vn(n.l(e),r);e=e.parentElement)if(e.hasAttribute("data-pipeup-id"))return e;return o}function yn(e,t,n){let o=n.l(e);for(let r=e.parentElement;r&&r!==t;){let e=wn(r,t,n);if(!e)return null;if(!vn(n.l(e),o))return e;r=e.parentElement}return null}var bn=(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,xn=(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 kn(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)??sn,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&&!bn(f,h))continue;let v=c.matches(un),g=(e.display.startsWith("inline")||d)&&!c.matches(hn)&&("inline"===e.display||f.height<=dn),w=f.width<=fn&&f.height<=fn,y=i;(c.hasAttribute("data-pipeup-id")||!s&&!e.off&&!g&&(!w||v))&&gn(c,t)&&(i&&vn(t.l(i.e),f)?(c.hasAttribute("data-pipeup-id")||!i.e.hasAttribute("data-pipeup-id"))&&(i.e=c):o.push(y={e:c,O:i,k:0}));let b=e.clips&&m;r(c,y,b?h?xn(h,f):f:h,b?c:u?null:l,s||v,/^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.O&&(t.O.k=Math.max(t.O.k,t.k+1))}return o}var En=(e,t)=>e.filter(e=>e.k<=t&&(!e.O||e.O.k>t)),$n=(e,t)=>e.filter(e=>e.O===t),Sn="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]",Ln=`${Sn},input,select,textarea,[contenteditable]:not([contenteditable=false]),[tabindex]:not([tabindex="-1"])`,An=["click","dblclick","auxclick","submit","contextmenu","dragstart"],Mn=[...["over","out","enter","leave","down","up"].flatMap(e=>[`pointer${e}`,`mouse${e}`]),"mousemove","touchstart","touchmove","touchend","touchcancel"],Cn=400,Tn="Tab moves between blocks · ↑ ↓ change level · Enter comments · Esc to finish · F7 selects text",Pn=4,Nn=150;function qn(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}},oe:()=>({width:innerWidth,height:innerHeight})},n=Ze("span",{hidden:!0},Tn),o=Ze("div",{class:"pick"},n),r=[0,1].map(()=>{let e=Ze("div",{class:"km",tabindex:"-1",role:"button"},Ze("span",{hidden:!0}),Ze("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=Ze("span",{class:"lbl"}),a=(e,t,n,o)=>{let r=Ze("button",{class:"nb",type:"button","aria-label":e,title:t},ht(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.we(()=>j(f??x,{x:.5,y:.5}))),c=Ze("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,v=null,g=0,w=()=>{},y=null,b=()=>{},x=null,k=0,E=0,$=!1,S=null,L=null,A=null,M=0,C=-1,T=!0,P=null,N=null,q=t=>!(e.w(t)||t.target instanceof Element&&t.target.closest("[data-pipeup-ignore]"));function O(){v&&(o.classList.toggle("glide",performance.now()<g),ot(o,v.getBoundingClientRect(),4))}function z(){if(!y)return;c.classList.toggle("glide",performance.now()<g&&c.classList.contains("show"));let{left:e,top:t}=Qt(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 R(e,t){v=e,g=t?performance.now()+Cn:0,O(),o.classList.add("show")}function D(e,t){let n=getComputedStyle(e);if("0"===n.opacity)return t(),()=>{};let o=0,r=()=>{window.clearTimeout(o),e.removeEventListener("transitionend",a)},i=()=>{r(),t()},a=t=>{t.target===e&&"opacity"===t.propertyName&&i()},l=Math.max(...n.transitionDuration.split(",").map(e=>1e3*parseFloat(e)||0));return o=window.setTimeout(i,l+100),e.addEventListener("transitionend",a),r}function I(e){if(e!==h){if(h=e,w(),!e)return void o.classList.remove("show");"0"===getComputedStyle(o).opacity?R(e,!1):u?(o.classList.remove("show"),w=D(o,()=>R(e,!1))):R(e,!0)}}function F(e){f=e,o.classList.toggle("on",null!==e),I(e),B(e)}function B(e){b(),c.inert=!e,e?u?(c.classList.remove("show"),b=D(c,()=>H(e))):H(e):(c.classList.remove("show"),y=null)}function H(n){i.textContent=i.title=Oe(n),l.hidden=null===yn(n,e.root,t),s.hidden=0===(x?ae(n).length:kn(n,t,Z).length);let o=c.classList.contains("show");y=n,z(),o||(c.offsetWidth,c.classList.add("show"))}function j(t,n){let o;try{o=we(t,e.root,n,e.p.view(t))}catch(t){return void e.F(t)}let r={anchor:o,label:n?`Pin on ${Oe(t).replace(/^[A-Z](?=[a-z])/,e=>e.toLowerCase())}`:Oe(t),ranges:[],resolved:{state:"attached",element:t,range:null}},i=e.state.o;x&&(x=t,C=-1),F(n?null:t),m=i??r,e.qe(r),e.E(n?r.label:`Commenting on ${r.label}`)}function W(t){e.we(()=>j(t))}let K=n=>{if(e.w(n))return;if(!q(n))return void(f||I(null));if(n.stopPropagation(),f||e.state.o)return;let o=!tt()&&n.target instanceof Element?wn(n.target,e.root,t):null;if(x){if(!o||o===x||(M+=Math.abs(n.movementX)+Math.abs(n.movementY),M<=Pn))return;ie()}o&&(S=o),I(o)},V=()=>{tt()&&(x&&ie(),f||I(null))},Y=e=>{q(e)&&(e.stopPropagation(),("pointerdown"===e.type||"mousedown"===e.type)&&e.target instanceof Element&&e.target.closest(Ln)&&e.preventDefault())},U=n=>{if(!q(n))return;let o=n.target;!(o===N||o.form&&o.form===N?.form)||"submit"!==n.type&&("click"!==n.type||n.detail)?(n.preventDefault(),n.stopPropagation(),"click"===n.type&&!e.state.s&&!e.Ue(n)&&function(n){let o=window.getSelection();if(o&&!o.isCollapsed)return;if(e.state.o&&(n.altKey||!e.L()))return void e.V();if(!n.altKey&&e.ne(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?wn(n.target,e.root,t):null)??e.root;o!==e.root&&(S=o);let r=o.getBoundingClientRect();r.width&&r.height&&j(o,{x:(n.clientX-r.left)/r.width,y:(n.clientY-r.top)/r.height})}(n);let r=n.target instanceof Element?wn(n.target,e.root,t):null;r&&(S=r),r?j(r):(e.V(),F(null))}(n)):N="click"===n.type&&"submit"===o.type?o.form:null},_=t=>{if(N=null,he="","Tab"===t.key&&G(t))return t.preventDefault(),t.stopPropagation(),he=t.key,e.V(),e.state.i&&e.open(null),e.state.s&&(e.state.s=!1,e.u()),function(t){if(x)return le(t);P=null;let n=document.activeElement;L=J()??n;let o,r=S?.isConnected?S:null,i=r&&ee(r);if(i){k=i.k;let e=En(Q(),k),n=e.indexOf(i);o=e[(n+t+e.length)%e.length]}else if(r){k=0;let e=En(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.k);if(!o)return e.E("Nothing here to comment on");$=!0,re(o.e)}(t.shiftKey?-1:1);if(q(t)&&t.target instanceof Element)if("Enter"!==t.key&&" "!==t.key||!t.target.closest(Sn))"Enter"===t.key&&!x&&t.target.form&&(N=t.target);else{if(!x)return void(N=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.w(t)?!!n.closest(".launch,.menu")&&!n.closest("input,textarea,select,[contenteditable]"):!t.composedPath().some(e=>e instanceof Element&&e.hasAttribute("data-pipeup-ignore")))},J=()=>e.t.getRootNode().activeElement,X=()=>r.some(e=>e===J()),Z=t=>(!1!==t.checkVisibility?.({opacityProperty:!0,visibilityProperty:!0})||"contents"===getComputedStyle(t).display)&&e.p.f(e.p.view(t)),Q=()=>(P?.some(e=>!e.e.isConnected)&&(P=null),P??=kn(e.root,t,Z)),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=En(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.B(n)&&t.contains(en(e,n))).sort(tn(e));function re(t,o=!0){M=0;let i=Q(),a=i.find(e=>e.e===t);if(a&&!En(i,k).includes(a)&&(k=a.k),t!==x&&(C=-1),t!==f&&(f=null),x=t,I(t),B(t),t.scrollIntoView({block:"nearest",inline:"nearest",behavior:u?"auto":"smooth"}),!o)return;e.Ke();let l=r[E^=1];(function(e,t){let[o,r]=e.children,i=En(Q(),k),a=oe(t).length;o.textContent=`${Ne(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<=Nn;r.textContent=qe(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),ot(l,t.getBoundingClientRect(),4),l.inert=!1,l.focus({preventScroll:!0}),r[1^E].inert=!0}function ie(){let e=X();S=x,x=null,I(null),B(null);for(let e of r)Qe(e,!0);return e}function ae(e){let t=ee(e);return t?$n(Q(),t):[]}function le(e){let t=En(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&&yn(n,e.root,t);return o?((!A||!n.contains(A))&&(A=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=>A&&e.e.contains(A))??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.L())return e.ze();if(!t)return j(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(),he=t.key,"Escape"===t.key)return void e.re();if("Enter"===t.key||" "===t.key)return ce(t.shiftKey&&"Enter"===t.key);"Tab"===t.key&&e.V(),e.state.i&&e.open(null),"Tab"===t.key?le(t.shiftKey?-1:1):"ArrowUp"===t.key?se():de()}}let ue=()=>{let e=J();return e?!!e.closest("[inert]"):!document.activeElement||document.activeElement===document.body},he="",fe=!1,me=e=>{fe&&window.removeEventListener("keyup",me,!0),e.key===he&&(he="",e.preventDefault(),e.stopPropagation())};window.addEventListener("keyup",me,!0),window.addEventListener("pointermove",K,!0),document.addEventListener("selectionchange",V);for(let e of Mn)window.addEventListener(e,Y,!0);for(let e of An)window.addEventListener(e,U,!0);return window.addEventListener("keydown",_,!0),{re:()=>!!f&&(F(null),!0),ie:()=>null!==x,We:()=>$&&!x,be:function(){P=null;let t=document.activeElement;L=J()??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.k),$=!0,re(o.e),!0)},se(){x&&!X()&&re(x)},u(){if(P=null,x&&(!x.isConnected||!Z(x))){let e=ne();e?re(e.e,X()||ue()):ie()}let t=e.t.querySelector(".launch");if(t&&c.nextElementSibling!==t&&!X()&&!c.contains(J()))for(let n of[o,...r,c])e.t.insertBefore(n,t);let n=e.state.o;m&&n!==m?(m=null,F(null),x&&re(x,ue())):(n||e.state.i)&&!m&&(h||f)&&F(null)},T(){O(),z(),x&&ot(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(),fe=!0,he||window.removeEventListener("keyup",me,!0),window.removeEventListener("pointermove",K,!0),document.removeEventListener("selectionchange",V);for(let e of Mn)window.removeEventListener(e,Y,!0);for(let e of An)window.removeEventListener(e,U,!0);window.removeEventListener("keydown",_,!0),o.classList.remove("show"),c.classList.remove("show"),Qe(c,!0),D(o,()=>o.remove()),D(c,()=>c.remove())}}}var On=300,zn=32,Rn=220,Dn=320,In=24,Fn=24;function Bn(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+Dn-(t?In:0)?null:{x:i-Dn+Fn,width:Dn-2*Fn}}let i=r.getBoundingClientRect().right;if(window.innerWidth-i<On&&"column"!==o)return null;let a=i+zn;return{x:a,width:Math.max(220,Math.min(300,window.innerWidth-a-16))}}function Hn(e,t){let n=e.resolved.get(t.id);return!n||"orphaned"===n.state&&!e.S.has(t.id)}function jn(e){let t=Ze("div",{class:"col"});e.t.append(t);let n=new Map,o=null,r=new ResizeObserver(()=>l()),i=t=>Hn(e,t);function a(t){let n=e.resolved.get(t.id),o=n?Ut(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.S.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?Ut(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=Xe(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=on(n,e.te,{D:"column",lost:o?n.anchor.snapshot:null}),l=Ze("div",{class:"th","data-thread":n.id},Ze("button",{class:"opn sr",type:"button","data-thread":n.id}),a.element);return l.style.transition="none",l.addEventListener("mouseenter",()=>e.m(n.id)),l.addEventListener("mouseleave",()=>e.m(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(),Rn)}return{u:function(a){Qe(t,e.state.c);let p=new Set,u=[],h=null!==e.state.i||null!==e.state.o;for(let t of a){if(!e.B(t))continue;p.add(t.id);let o=n.get(t.id);o?(o.thread!==t||o.lost!==i(t)||o.note!==Xe(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: ${nt(t.root.text,60)}, ${nn(c)}`),l.setAttribute("aria-expanded",String(a)),Qe(l,a);let f=r.querySelector(".more");f&&Qe(f,!a),r.classList.toggle("dim",h&&!a),r.classList.toggle("hot",e.state.m===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.H(null)),!n)return;let i=!o;if(o)o.l.ve(n.label);else{let i=Kt(e,n),a=Ze("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.Z(e.state.d&&!n.anchor.quote&&!n.anchor.point),i&&o.l.focus()})(),et(t,a.filter(e=>p.has(e.id)).sort(tn(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=""},T:function(){let n=Bn(e.root,!0);n&&(t.style.width=`${n.width}px`,t.style.transform=`translate(${n.x}px, ${-window.scrollY}px)`)},destroy(){r.disconnect(),e.H(null),t.remove()}}}var Wn="[data-pipeup-ignore],input,textarea,select,[contenteditable]:not([contenteditable=false])";function Kn(e){let t=Ze("button",{type:"button","aria-label":"Comment",title:"Comment"},ht("comment",17)),n=Ze("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(Wn)};function l(){if(!o)return;let{left:e,top:t}=Qt(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=tt();e.state.d&&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.L())return e.V();let n,r=o;if(!r)return;try{n=ge(r,e.root,e.p.view(r.commonAncestorContainer))}catch(t){return e.F(t),void s()}let i=nt(r.toString().replace(/\s+/g," ").trim(),60);window.getSelection()?.removeAllRanges(),s(),e.je({anchor:n,label:`“${i}”`,ranges:[r],resolved:{state:"attached",element:null,range:r}})});let c=()=>{window.clearTimeout(r),r=window.setTimeout(()=>i||d(),250),o&&(tt()||s())};document.addEventListener("selectionchange",c);let p=t=>{"keyup"!==t.type&&(i="mousedown"===t.type),!i&&!e.w(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.w(n)||n.target instanceof Element&&n.target.closest(`${Wn},${Sn}`)||(n.preventDefault(),n.stopPropagation(),t.click())};return window.addEventListener("keydown",u,!0),{u(){!e.state.d&&o&&s()},T(){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 Vn(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 Yn=3e3,Un="Hidden on the page";function _n(e){let t=[Ze("span",{class:"n"}),Ze("span",{class:"n"})],n=ht("comment",20,1.4);n.lastElementChild.setAttribute("stroke-width","1.6");let o=Ze("button",{class:"mode",type:"button","aria-label":"Comment","aria-keyshortcuts":Wt,"aria-haspopup":"menu","aria-expanded":"false"},Ze("span",{class:"plus"},n),Ze("span",{class:"cnt"},ht("bubble",34,1.4),...t),Ze("span",{class:"dot"})),r=document.createTextNode("Comment"),i=Ze("span",{class:"ttip","aria-hidden":"true"},r,Ze("small",{},jt)),a=Ze("div",{class:"launch"},o,i),l=Ze("div",{class:"menu",role:"menu","aria-label":"Comments"}),s=Ze("div",{class:"list",role:"menu","aria-label":"All comments"}),d=Ze("span",{class:"pn"}),c=Ze("button",{class:"ib",type:"button","aria-label":"Close"},ht("close")),p=Ze("button",{class:"hs",type:"button",role:"switch","aria-checked":"false"},"Show resolved",Ze("span",{class:"sw","aria-hidden":"true"}));p.addEventListener("click",t=>{t.stopPropagation(),e.s.Ye()});let u=Ze("span",{}),h=Ze("button",{type:"button"},"Check for replies"),f=Ze("div",{class:"ag"},u,h);f.hidden=!e.replies.enabled,h.addEventListener("click",t=>{t.stopPropagation(),h.disabled=!0,e.replies.check().then(t=>e.Y(t?`${t} new ${1===t?"reply":"replies"}`:"No new replies"),t=>e.F(t)).finally(()=>{h.disabled=!1,e.u()})});let m=Ze("div",{class:"all",role:"dialog","aria-label":"All comments"},Ze("div",{class:"hd"},Ze("span",{},"All comments"),d,p,c),f,s),v=document.createElementNS("http://www.w3.org/2000/svg","svg");v.setAttribute("class","cx"),v.setAttribute("aria-hidden","true");let g=document.createElementNS("http://www.w3.org/2000/svg","path"),w=document.createElementNS("http://www.w3.org/2000/svg","circle");w.setAttribute("r","4"),v.append(g,w),l.inert=m.inert=!0,e.t.append(l,a,v,m);let y=!1,b=null,x=0,k=[],E=0,$=null,S=null,L=!0===window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,A=t=>{y=e.state.s=t,t&&e.addons.flush(),window.clearTimeout(x),x=0,t||b?.(!0),l.classList.toggle("show",t),Qe(l,!t),o.setAttribute("aria-expanded",String(t))},M=(t,n=!1)=>{e.state.c!==t&&(e.state.c=t,e.u(),t?(C(s)[0]??c).focus({preventScroll:!0}):n&&o.focus({preventScroll:!0}))},C=(e=l)=>[...e.querySelectorAll(".mi")],T=()=>l.getRootNode().activeElement,P=()=>{A(!1),o.focus({preventScroll:!0})},N=e=>{let t=C(e.currentTarget);if(0===t.length)return;let n=T(),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(),M(!1,!0)});let q=t=>Hn(e,t),O=t=>k.filter(n=>!n.resolved&&(void 0===t||e._(n)===t)).length,z=()=>O(),R=t=>{let n=t.anchor.view?.slide,o=e.p.f(t.anchor.view)?"":Re(t.anchor.view);return n&&null!==e.p.slide()?`On slide ${n}`:o?`In ${o}`:Un},D=(e,t,n="")=>Ze("div",{role:"group","aria-label":n?`${e} · ${n}`:e},Ze("div",{class:"sec","aria-hidden":"true"},e,n&&Ze("b",{},n)),...t);function F(){let t=T(),n=t?.dataset.thread,o=null!==S&&S.element.contains(t),r=e.s.all().filter(t=>!t.thread.resolved||e.state.C||t.thread.id===$),i=t=>{let n=t.thread,o=n.id===$,r=yt(n.root.author,n.root.name);r.classList.add("in");let i=Ze("button",{class:`mi${n.resolved?" done":""}${o?" open":""}`,type:"button",role:"menuitem","aria-expanded":String(o),"data-thread":n.id},r,Ze("span",{},Ze("span",{class:"clamp"},n.root.deleted?"Deleted":n.root.text),Ze("small",{},q(n)?`“${nt(n.anchor.snapshot,80)}”`:t.location.where)));i.addEventListener("click",t=>{t.stopPropagation(),function(t){if($===t)return j(!0);let n=k.find(e=>e.id===t);if(n){if($=H=t,S=on(n,{...e.te,close:()=>j(!0)},B(n)),F(),S.element.querySelector("textarea")?.focus({preventScroll:!0}),!e._(n))return W(n);e.state.o&&!e.L()||e.p.R(n.anchor.view??{}).then(()=>{e.xe();let n=k.find(e=>e.id===t);n&&H===t&&$===t&&W(n)})}}(n.id)});let a=document.createDocumentFragment();return a.append(i),o&&S&&(S.update(n,B(n)),a.append(Ze("div",{class:"xr",role:"region","aria-label":"Comment thread"},S.element))),a},a=r.filter(e=>q(e.thread));d.textContent=String(z()),p.setAttribute("aria-checked",String(e.state.C)),s.replaceChildren(r.length?"":Ze("div",{class:"sec",role:"presentation"},"No open comments"),...function(t,n){let o=e.p.slide(),r=new Map;for(let n of t){let t=n.thread,i=null!==o?t.anchor.view?.slide??o:e._(t)?e.p.f(t.anchor.view)?"":Re(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||Un,t.map(n)))]}return[...r].sort(([e],[t])=>Number(e)-Number(t)||0).map(([e,t])=>D(`Slide ${e} · ${t.filter(e=>!e.thread.resolved).length} open`,t.map(n),e===o?"This slide":""))}(r.filter(e=>!q(e.thread)),i),a.length?D("No longer on the page",a.map(i)):""),o?S.element.querySelector("textarea")?.focus({preventScroll:!0}):n&&C(s).find(e=>e.dataset.thread===n)?.focus({preventScroll:!0})}function B(t){let n=!q(t)&&e._(t);return{D:"popover",quote:t.anchor.quote?.exact??null,lost:q(t)||n?t.anchor.snapshot:null,place:n?R(t):null}}let H="";function j(t=!1){if(!$)return;let n=$;$=S=null,e.m(null),F(),t&&C(s).find(e=>e.dataset.thread===n)?.focus({preventScroll:!0})}function W(t){let n=e.resolved.get(t.id),o=n&&!q(t)?n.element??n.range?.startContainer.parentElement??null:null;o?.scrollIntoView({block:"center",inline:"nearest",behavior:L?"auto":"smooth"}),o&&e.m(t.id)}function K(e,t,n=!1,...o){let r=Ze("button",{class:"mi",type:"button",role:n?"menuitemcheckbox":"menuitem"},e,Ze("span",{class:"lb"}),...o,n&&Ze("span",{class:"sw","aria-hidden":"true"}),Ze("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=()=>Ze("div",{class:"sep",role:"separator"}),U=Ze("span",{class:"ma"}),_=Ze("span",{class:"kc"}),G="",J=K(U,function(){let t=Ze("input",{class:"input",type:"text",maxlength:"80","aria-label":"Your name"});t.value=e.s.name();let n=Ze("div",{class:"ed"},U.cloneNode(!0),t),o=(r,i=!1)=>{if(b!==o)return;b=null;let a=t.value.trim();r&&a&&a!==e.s.name()&&e.s.rename(a).then(ue),n.replaceWith(J),i&&J.focus({preventScroll:!0})};b=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)),J.replaceWith(n),t.focus({preventScroll:!0})},!1,_);J.dataset.item="name";let X=K(ht("copy"),()=>{P(),e.s.copyAll("ai")}),Z=K(ht("lines"),()=>{P(),e.s.copyAll("text")}),Q=K(ht("copy"),()=>{P(),e.s.copyPrompt()}),ee=K(ht("send"),()=>{e.link.set(!e.link.on()).then(ue,t=>e.F(t))},!0),te=Ze("div",{class:"sec",role:"presentation"}),ne=Ze("span",{class:"kc"}),oe=K(ht("list"),()=>{A(!1),M(!0)},!1,ne),re=K(ht("comment"),t=>{let n=!e.state.d&&0===t.detail;e.Ge(!e.state.d,n),n&&A(!1)},!0,Ze("span",{class:"kc","aria-hidden":"true"},jt));re.dataset.item="comment",re.setAttribute("aria-keyshortcuts",Wt);let ie=Ze("div",{class:"sec",role:"presentation"}),ae=Y(),le=Y(),se=new Map,de=t=>{let n=se.get(t);return n||(n=K(ft(t.icon,15),()=>{t.checked||P(),Promise.resolve().then(()=>t.select()).catch(t=>e.F(t)).finally(()=>y&&ue())},!!t.checked,Ze("span",{class:"kc"})),se.set(t,n)),n},ce=-1,pe=e=>{try{return e()}catch(e){return globalThis.reportError?.(e),""}};function ue(){let t=z(),n=e.s.name(),o=n||I(e.doc.me);if(V(J,o,n?"The name on your comments":"Add a name to show on your comments"),J.setAttribute("aria-label",`${o}, ${n?"edit":"add"} your name`),_.replaceChildren(n?ht("edit",13):"Add name"),wt(e.doc.me,n)!==G){G=wt(e.doc.me,n);let t=yt(e.doc.me,n);t.classList.add("in"),U.replaceChildren(t)}V(X,"Copy as Markdown","Markdown, with where each thread is"),V(Z,"Copy as Text","Just the words"),V(Q,"Copy a prompt for my agent","Tells an AI agent where the comments are and how to answer them");let r=e.replies.who()||e.link.agent;te.textContent=e.link.on()?`Sharing comments with ${r||"your agent"}`:`${r||"An AI agent"} can answer comments here`,V(ee,"Share with my agent","Sends this page's comments to the program running on this computer, and nothing else",e.link.on()),V(oe,"All comments","Every thread, and where it is"),ne.textContent=t?String(t):"";let i=e.addons.ce();ie.textContent=i,i?!ie.isConnected&&l.contains(J)&&l.prepend(ie):ie.remove();for(let t of e.addons.$){let e,n=se.get(t);if(n){try{e=t.checked?.()}catch(e){globalThis.reportError?.(e)}V(n,pe(t.label),pe(t.hint),e),n.querySelector(".kc").textContent=t.count?pe(t.count):""}}V(re,"Start commenting",e.state.d?"Turn off to hide the comments again":"Shows the comments; choose any part of the page to comment on it",e.state.d)}function he(){ue(),(ce!==e.addons.G||!l.contains(J))&&(l.replaceChildren(J,ae,...e.replies.enabled||e.link.enabled?[te]:[],X,Z,Q,...e.link.enabled?[ee]:[],oe,...e.addons.$.map(de),le,re),ce=e.addons.G,ue())}o.addEventListener("click",e=>{e.stopPropagation(),y?A(!1):(he(),A(!0),0===e.detail&&C().at(-1)?.focus({preventScroll:!0}))});let fe=!1,me=()=>{fe=m.contains(T())},ve=t=>{let n=t.composedPath();y&&!n.includes(l)&&!n.includes(o)&&(A(!1),e.state.d&&!e.w(t)&&(e.ye(t),t.preventDefault(),t.stopPropagation())),e.state.c&&!e.w(t)&&M(!1,fe&&(!document.activeElement||document.activeElement===document.body))},ge=e=>{if(!y||"touch"===e.pointerType||"pointerout"===e.type&&e.relatedTarget)return;let t=e.composedPath();"pointerover"===e.type&&(t.includes(l)||t.includes(o))?(window.clearTimeout(x),x=0):x||(x=window.setTimeout(()=>{x=0,b||A(!1)},Yn))},we={n:0,label:""},ye=()=>{let{n:t,label:n}=we,i=e.addons.ce(),a=`Comment${e.state.d?", 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?` · ${i}`:"");r.data!==l&&(r.data=l)},be=e.addons.subscribe(e=>{ye(),y&&!b&&(e?he():ue())});window.addEventListener("pointerdown",me,!0),window.addEventListener("click",ve,!0),window.addEventListener("pointerover",ge,!0),window.addEventListener("pointerout",ge,!0);let xe=t=>{if("Escape"!==t.key||b)return;let n=t.composedPath()[0];if(y)P();else{if(!e.state.c||n instanceof HTMLTextAreaElement&&!m.contains(n))return;$?j(!0):M(!1,!0)}t.stopPropagation()};return window.addEventListener("keydown",xe,!0),{u(n){k=n;let r=O(!1);if(r!==E){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),E=r}let i=O(!0),a=i?`${r} here · ${i} ${null!==e.p.slide()?"on other slides":"in other views"}`:"";if(o.classList.toggle("else",i>0),we={n:r,label:a},ye(),o.classList.toggle("on",e.state.d),y&&!e.state.s&&A(!1),y&&ue(),e.replies.enabled){let t=e.replies.tally(n),o=e.replies.who()||e.link.agent||"An agent",r=t.answered?`${o} has answered ${t.answered} of ${t.open} open comments${t.addressed?`; ${t.addressed} ${1===t.addressed?"is":"are"} marked addressed`:""}`:"No replies from an agent yet",i=e.replies.ignored(),a=(e.link.on()?`Sharing with ${e.link.agent||"your agent"} · `:"")+r+(i?` · ${i} from other writers ignored`:"")+(t.stray?` · replies for ${t.stray} comment${1===t.stray?"":"s"} this page doesn't have`:"");u.textContent!==a&&(u.textContent=a)}let l=e.state.c;m.classList.toggle("full",Zt()),m.classList.contains("show")!==l&&(m.classList.toggle("show",l),Qe(m,!l)),$&&(!l||!n.some(e=>e.id===$))&&($=S=null,e.state.m=null),l&&F()},T:function(){let t=$?k.find(e=>e.id===$):null,n=$?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||Zt()||q(t)||e._(t)||!1===o?.checkVisibility?.({visibilityProperty:!0}))return null;let r=e.t.querySelector(`.bub[data-thread="${t.id}"]`)?.getBoundingClientRect(),i=n.range?Yt(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=_t(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-Jt&&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}`}g.setAttribute("d",a),w.setAttribute("r",o.bubble?"0":"4"),w.setAttribute("cx",String(o.x)),w.setAttribute("cy",String(o.y)),v.classList.add("show")},destroy(){be(),window.removeEventListener("pointerdown",me,!0),window.removeEventListener("click",ve,!0),window.removeEventListener("pointerover",ge,!0),window.removeEventListener("pointerout",ge,!0),window.clearTimeout(x),window.removeEventListener("keydown",xe,!0),l.remove(),m.remove(),v.remove(),a.remove()}}}var Gn="[data-pipeup-slide]",Jn=1e3,Xn=["scroll","resize","keyup","click","transitionend","slidechanged"],Zn=null,Qn=null,eo=new Set,to=new Set,no=e=>{try{e()}catch(e){globalThis.reportError?.(e)}};function oo(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>g.viewKey||r.length>g.viewValue)){if(++n>=g.viewEntries)break;t[o]=r}}Zn=t;for(let e of to)e()}function ro(e){return eo.add(e),()=>{eo.delete(e)}}function io(e){Qn="function"==typeof e?.current&&"function"==typeof e.go?e:null}var ao=()=>{let e=window.Reveal;return"function"==typeof e?.getIndices&&"function"==typeof e.slide?e:null};var lo=["pipeup-quote","pipeup-on","pipeup-done"],so={"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]]},co=(e,t)=>lo.map(n=>{let[o,r,i,a]=so[n][e?1:0];return`::highlight(${n}){background-color:rgba(${o},${r},${i},${+(a*t).toFixed(3)})}`}).join("");function po(){return typeof CSS<"u"&&"highlights"in CSS&&typeof Highlight<"u"}var uo=`: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 ho(){if(po())for(let e of lo)CSS.highlights.delete(e)}var fo=':host{all:initial}*{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;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:#888780;--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.dark{--k:#ECEBE6;--mu:#B4B2A9;--fa:#8D8B84;--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{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,.av.ai:after{content:"";position:absolute;inset:3px;border-radius:50%;border:1.5px solid var(--pu-accent);pointer-events:none}.av.ai:after{animation:pu-pulse-ring 3s var(--eo) infinite}.av.ai.busy:after{animation-duration:1.6s}.root>.av.ai,.it>.av.ai{position:absolute}@keyframes pu-pulse-ring{0%{opacity:.7;transform:scale(1)}80%,to{opacity:0;transform:scale(1.375)}}.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}.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}.ghost .dots{display:inline-flex;gap:3px;margin-left:4px;vertical-align:middle}.ghost .dots i{width:4px;height:4px;border-radius:50%;background:var(--fa);animation:pu-dot 1.6s var(--eio) infinite}.ghost .dots i:nth-child(2){animation-delay:.2s}.ghost .dots i:nth-child(3){animation-delay:.4s}@keyframes pu-dot{0%,to{opacity:.25}50%{opacity:1}}.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{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;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{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}.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(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){@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{transform:none!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}.av.ai:after{animation:none;opacity:0}.ghost .dots i{animation:none;opacity:.6}@keyframes pu-pulse{0%{opacity:0}35%{opacity:.85}to{opacity:0}}}',mo="#534AB7",vo="#9A94EE",go="rgb(0, 0, 238)";function wo(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}}function yo(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 bo=(e,t)=>(Math.max(e,t)+.05)/(Math.min(e,t)+.05);function xo(e){let t=e.ownerDocument,n=t.defaultView;if(!n)return{font:"system-ui, sans-serif",accent:mo,dark:!1,on:"#fff"};let o=t.documentElement,r=n.getComputedStyle(e).fontFamily||"system-ui, sans-serif",i=(n.getComputedStyle(o).getPropertyValue("--pipeup-accent")||o.style.getPropertyValue("--pipeup-accent")).trim(),a=e.querySelector("a[href]"),l=a?n.getComputedStyle(a).color:"",s=wo(n.getComputedStyle(t.body).backgroundColor);(!s||0===s.a)&&(s=wo(n.getComputedStyle(o).backgroundColor));let d=!!(s&&s.a>0?yo(s)<.2:!0===n.matchMedia?.("(prefers-color-scheme: dark)").matches&&/dark/.test(n.getComputedStyle(o).colorScheme||"")),c=l&&l!==go?wo(l):null,p=c&&bo(yo(c),d?.011:1)>=3,u=i||(p?l:d?vo:mo),h=wo(u);return{font:r,accent:u,dark:d,on:h&&bo(yo(h),1)<3?"#111":"#fff"}}function ko(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=/^\/__pipeup\/[A-Za-z0-9_-]{16,}$/,$o=/^[A-Za-z0-9_-]{43}$/,So="pipeupReplies",Lo=4e3,Ao=4e3;function Mo(){let e=document.documentElement.getAttribute("data-pipeup-replies");try{let t=location.href.split(/[?#]/)[0],n=new URL(e??(/\/$/.test(t)?`${t}index.replies.js`:t.replace(/\.[^./]*$/,"")+".replies.js"),location.href),o="file:"===n.protocol?"file:"===location.protocol:n.origin===location.origin;return o||console.warn("pipeup: the replies file must be on this site or this computer; ignoring it"),o?n.href:null}catch{return null}}var Co=40,To=250,Po=120,No=2400,qo=4e3,Oo=1e4;function zo(e,t=!1){return Bn(e,t)?"column":"bubbles"}var Ro=1e3,Do="Shown here, but not saved yet — it will be saved with your next change",Io=e=>e instanceof Error?e.message.replace(/^pipeup: /,""):"Something went wrong";function Fo(e){let t=xo(e.root),n=function(e,t=document){let n=t.createElement("pipeup-root");n.setAttribute("data-pipeup-ignore",""),n.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 o=n.attachShadow({mode:"open"}),r=t.defaultView?.CSSStyleSheet;if(r&&"replaceSync"in r.prototype&&"adoptedStyleSheets"in o){let e=new r;e.replaceSync(fo),o.adoptedStyleSheets=[e]}else{let e=t.createElement("style");e.textContent=fo,o.append(e)}let i=t.createElement("div");return i.className="layer",i.style.setProperty("--pu-panel",`${Jt}px`),i.style.setProperty("--pu-pop",`${Xt()}px`),ko(i,e),o.append(i),t.documentElement.append(n),{element:n,shadow:o,t:i,destroy:()=>n.remove()}}(t),o=function(e=document,t=!1){let n=e.defaultView?.CSSStyleSheet;if(!n||!("replaceSync"in n.prototype)||!("adoptedStyleSheets"in e))return{Ee(){},ke(){},ae(){},Se(){},remove:()=>ho()};let o=new n,r=null,i=!1,a=1,l=0,s="",d=0,c=()=>o.replaceSync(co(t,a)+(null===r?"":`:root{--pipeup-gutter:${r}px}`)+(i?uo:"")+(l||s?`html{--pipeup-panel:${l}px;${l?`margin-right:${l}px!important;`:""}${s}}`:""));return c(),e.adoptedStyleSheets=[...e.adoptedStyleSheets,o],{Ee(e){e!==r&&(r=e,c())},ke(e){e!==i&&(i=e,c())},ae(e){a=e,c()},Se(e,t){e!==l&&(l=e,s=t?"":"transition:margin-right .34s cubic-bezier(.4,0,.2,1)!important",clearTimeout(d),!e&&s&&(d=window.setTimeout(()=>{s="",c()},400)),c())},remove(){clearTimeout(d),e.adoptedStyleSheets=e.adoptedStyleSheets.filter(e=>e!==o),ho()}}}(document,t.dark);o.ae(0);let r=!0===window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,i=document.documentElement.hasAttribute("data-pipeup-reserve"),a=new Map,l=new Set,s=new WeakSet,d={i:null,m:null,C:!1,hidden:!0,mode:zo(e.root),o:null,d:!1,c:!1,Te:!1,s:!1},c=Ze("div",{class:"toast",role:"status","aria-live":"polite"}),p=Ze("div",{class:"sr","aria-live":"polite"});n.t.append(c,p);let u=null,h=[],f=null,m=!1,v=0,w=0,y=0,b=0,x=0,k=new Set,E="",$=new Map,S=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,oe:()=>({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(Gn)],d=()=>[...e.querySelectorAll(".slides > section")],c=e=>"string"==typeof e&&e.length>0&&e.length<=g.viewValue?e:null,p=e=>c(e?.getAttribute("data-pipeup-slide"));function u(){if(Qn){let e=null;if(no(()=>{let t=Qn.current();Number.isInteger(t)&&t>0&&(e=String(t))}),null!==e)return e}let e=ao();if(e){let t=null;if(no(()=>{let n=e.getIndices().h,o=d()[n];t=p(o?.matches(Gn)?o:o?.querySelector(Gn))??c(String(n+1))}),null!==t)return t}return r&&!r.isConnected&&(r=null),r=function(e,t,n){let o=t.oe(),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,Zn),v=new MutationObserver(e=>{e.some(e=>e.target instanceof Element&&e.target.matches(Gn))&&f()});v.observe(e,{subtree:!0,attributes:!0,attributeFilter:["class","style","hidden"]});for(let e of Xn)window.addEventListener(e,f,{capture:!0,passive:!0});return to.add(f),i=u(),{slide:()=>i,view(e){let t=e instanceof Element?e:e?.parentElement,n=p(t?.closest(Gn))??i,o={...null!==n?{slide:n}:{},...Zn};return Object.keys(o).length?o:void 0},f:m,R:function(e){if(m(e))return Promise.resolve(!0);let t=e.slide,n=ao(),r=s().find(e=>p(e)===t),a=/^[1-9]\d{0,5}$/.test(t??"");if(a&&Qn)no(()=>Qn.go(Number(t)));else if(a&&n){let e=r?d().findIndex(e=>e===r||e.contains(r)):-1;no(()=>n.slide(e>=0?e:Number(t)-1))}else if(eo.size)for(let t of eo)no(()=>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),Jn),r=()=>l?n(!1):(i=u(),m(e)?n(!0):performance.now()-c>=Jn?n(!1):void requestAnimationFrame(r));requestAnimationFrame(r)})},destroy(){l=!0,cancelAnimationFrame(a),v.disconnect();for(let e of Xn)window.removeEventListener(e,f,!0);to.delete(f)}}}(e.root,()=>{!m&&W()&&J()}),L=!1,A=0;function M(e,t=No,n=!1,o=!1){m||(L=n,c.textContent=e,o?c.setAttribute("aria-hidden","true"):c.removeAttribute("aria-hidden"),c.classList.add("show"),window.clearTimeout(v),v=window.setTimeout(()=>c.classList.remove("show"),t))}function C(){L&&(L=!1,window.clearTimeout(v),c.classList.remove("show"))}function T(e){p.textContent="",cancelAnimationFrame(A),A=requestAnimationFrame(()=>p.textContent=e)}function P(e){M(Io(e))}function N(e){throw P(e),e}let q=t=>({thread:t,location:ze(t.anchor,a.get(t.id)??Ae(t.anchor,e.root),e.root)}),O={reply:async(t,n)=>{try{await e.doc.reply(t,n)}catch(e){e instanceof _?M(Do):N(e)}},resolve:async t=>{try{await e.doc.resolve(t),M("Resolved · Show resolved brings it back")}catch(e){M(e instanceof _?`Resolved · ${Do}`:Io(e))}(e=>d.i===e&&!d.C&&(f?.ie()?f.se():n.t.querySelector(".launch .mode")?.focus({preventScroll:!0}),!0))(t)&&(d.i=null)},reopen:async t=>{try{await e.doc.reopen(t),M("Reopened")}catch(e){M(e instanceof _?`Reopened · ${Do}`:Io(e))}},notRight:async t=>{try{await e.doc.reopen(t)}catch(e){M(e instanceof _?`Reopened · ${Do}`:Io(e))}te(t)},close:()=>{oe(null);let e=X&&n.t.querySelector(X);e?e.focus({preventScroll:!0}):f?.se(),X=""},copy:t=>{try{let o=e.doc.threads().find(e=>e.id===t);if(!o)return;Vn(Be(q(o),"ai",location.href,Date.now()),n.t).then(()=>M("Thread copied as Markdown for AI"),e=>M(Io(e)))}catch(e){M(Io(e))}}},z=function(e){let t=function(){let e=document.documentElement.getAttribute("data-pipeup-agents")??"";return[...new Set(e.split(/[\s,]+/).filter(e=>$o.test(e)))]}(),n=0,o="",r=null;async function i(){let r=globalThis[So];if(!Array.isArray(r))return 0;let i=r.splice(0),a=[];for(let r of i){let i=r;if("pipeup-replies"===i?.format&&i.doc===e.doc.id&&Array.isArray(i.ops))for(let e of i.ops){let r=e?.body;r&&t.includes(r.author)&&("reply"===r.kind||"addressed"===r.kind)?(a.push(e),H(r.name)&&(o=r.name.replace(/^AI assistant\s*·?\s*/,""))):n++}}return a.length?e.doc.merge(a,"agent"):0}async function a(){if(!t.length)return 0;let n=await i();return await function(){let t=Mo();return t?(r?.remove(),new Promise((n,o)=>{let i=document.createElement("script");r=i,i.src=`${t}?${Date.now()}`;let a=e=>{window.clearTimeout(l),i.remove(),r===i&&(r=null),e?o(new Error(`pipeup: ${e}`)):n()},l=window.setTimeout(()=>a("the replies file didn't answer"),Lo);i.addEventListener("load",()=>a()),i.addEventListener("error",()=>a("there is no replies file yet")),e.t.append(i)})):Promise.reject(new Error("pipeup: the replies file can't be read from here"))}(),n+await i()}let l=!1,s=()=>{l||document.hidden||(l=!0,a().catch(()=>{}).finally(()=>l=!1))},d=0;return t.length?(s(),d=window.setInterval(s,Ao),document.addEventListener("visibilitychange",s)):i(),{enabled:t.length>0,ignored:()=>n,who:()=>o,check:a,tally:n=>{let o=n.filter(e=>!e.resolved),r=new Set(n.map(e=>e.id));return{stray:new Set(e.doc.ops().filter(e=>t.includes(e.body.author)&&!r.has(e.body.thread)).map(e=>e.body.thread)).size,open:o.length,answered:o.filter(e=>e.root.replies.some(e=>t.includes(e.author))).length,addressed:o.filter(e=>e.addressed).length}},destroy:()=>{window.clearInterval(d),document.removeEventListener("visibilitychange",s),r?.remove()}}}({doc:e.doc,t:n.t}),R=function(e){let t=document.documentElement,n=t.getAttribute("data-pipeup-link")??"",o=Eo.test(n),r=!1,i=0,a=()=>{};async function l(){let t=!1;try{t=(await fetch(`${n}/comments`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e.snapshot())})).ok}catch{}if(!t)throw new Error("pipeup: the link to your agent isn't reachable; your comments are safe here")}let s=()=>{window.clearTimeout(i),a(),a=()=>{},r=!1};return{enabled:o,agent:t.getAttribute("data-pipeup-link-agent")??"",file:t.getAttribute("data-pipeup-link-file")??"",on:()=>r,set:async t=>{if(o){if(!t)return s(),void e.refresh();await l(),r=!0,a=e.changes(()=>{window.clearTimeout(i),i=window.setTimeout(()=>{l().catch(t=>{s(),e.refresh(),globalThis.reportError?.(t)})},300)}),e.refresh()}},destroy:s}}({snapshot:()=>{let e=D.all(),t={title:document.title,url:location.href,exportedAt:new Date};return{v:1,at:t.exportedAt.toISOString(),title:t.title,open:Bt(e,t),all:Bt(e,{...t,all:!0})}},changes:t=>e.doc.onChange(t),refresh:()=>J()}),D={copyAll:async e=>{let t=D.all(),o=He(t,e,{title:document.title,url:location.href,exportedAt:new Date});try{await Vn(o,n.t);let r=t.filter(e=>!e.thread.resolved).length;M(`Copied ${r} thread${1===r?"":"s"}${"ai"===e?" as Markdown for AI":""}`)}catch(e){M(Io(e))}},copyPrompt:async()=>{try{await Vn(function(e){let t=e=>e.replace(/\s+/g," ").trim();return[`Act on the review comments on this page, which uses Pipeup: ${t(e.title)} (${t(e.url)}).`,"",e.file?`1. Read the comments: \`npx pipeup comments ${e.file}\` (add --all for resolved ones). If it says nothing is shared, ask me to switch on Share with my agent.`:"1. Read the comments. Open the page in a browser and run `await Pipeup.comments()`, then read `.markdown`. If you can't run the page, ask me to paste its Copy as Markdown.","2. Work through the open threads in order. For each, make the change I approved, or say why you didn't. Ask me before changing anything I haven't approved, and answer a question with an answer.",e.replies?`3. Answer in each thread: \`npx pipeup reply --page ${e.file||"<the page's file>"} --thread <Thread id> "what you changed and where" --addressed "short note"\`. That writes ${t(e.replies)}.`+(e.listed?"":" The page doesn't list your key yet: run `npx pipeup agent --name <your name>` and tell me the attribute to add."):"3. Tell me what you would reply in each thread, in words I can paste.","4. Only mark a thread addressed. Never resolve, reopen, edit or delete: I close threads. Keep your key out of the page and its folder, and never answer as me.","","Guide: https://pipeup-ai.github.io/pipeup/skills/pipeup-apply/SKILL.md"].join("\n")}({title:document.title,url:location.href,replies:Mo(),file:R.enabled?R.file:"",listed:z.enabled}),n.t),M("Copied a prompt for your agent")}catch(e){M(Io(e))}},Ye:()=>{d.C=!d.C,J()},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)?M(`New comments will say ${n}, but this browser couldn't remember it`):M(`New comments will say ${n}`)}catch(e){M(Io(e))}},name:()=>e.doc.name,all:()=>[...e.doc.threads()].sort(tn(F)).map(q)},I={},F={get addons(){return I.surface},doc:e.doc,root:e.root,t:n.t,host:n.element,state:d,resolved:a,S:l,te:O,s:D,replies:z,link:R,p:S,_:e=>k.has(e.id),xe:()=>{W()&&J()},B:e=>!d.hidden&&(!e.resolved||d.C||(e=>""!==(n.t.querySelector(`[data-thread="${e}"] .rbox textarea`)?.value.trim()??""))(e.id))&&!k.has(e.id),Xe:(t,n)=>{for(let o of e.doc.threads()){let e=a.get(o.id);if(o.anchor.quote&&F.B(o)&&e?.range&&Gt(t,n,Yt(e)))return o}return null},ne:(e,t)=>F.L()?F.Xe(e,t):null,w:e=>e.composedPath().includes(n.element),ye:e=>{s.add(e)},Ue:e=>s.has(e),open:oe,Je:e=>te(e),m:function(e){d.m!==e&&(d.m=e,e&&e!==d.i&&de(e),J())},je:re,qe:function(e){if(!d.o)return re(e);Object.assign(d.o,e),J()},L:()=>!u||u.De(),we:e=>{let t=u?.ge();e(),t?.()},ze:()=>{let e=d.o?.anchor.view,t=u?.ge();Promise.resolve(S.f(e)||S.R(e??{}).then(()=>F.xe())).then(t)},Be:async function(t){let n=d.o;if(n)try{let o=await e.doc.comment(n.anchor,t);d.o=null,j(new Set([o])),oe(o,!0)}catch(e){if(e instanceof _)return d.o=null,j(new Set([e.id])),oe(e.id,!0),void M(Do);N(e)}},Fe:ie,Ge:ae,V:se,H:e=>{u=e},Y:M,E:T,Ke:C,F:P,Qe:de,u:J,re:le},B=I.surface=new Nt(F,n.shadow,p);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<Co,i=Ae(r.anchor,e.root,{fuzzy:o});a.set(r.id,i),o||"orphaned"!==i.state?l.delete(r.id):l.add(r.id)}for(let e of[...a.keys()])o.some(t=>t.id===e)||a.delete(e);0===l.size?(window.clearTimeout(b),b=0):0===b&&(b=window.setTimeout(()=>{b=0,!m&&(j(new Set(l)),J())},To))}function W(){let t=new Set,n=null!==S.slide(),o=new Set;for(let r of e.doc.threads()){o.add(r.id);let e=a.get(r.id)?.element;(!S.f(r.anchor.view)||!n&&!1===e?.checkVisibility?.({visibilityProperty:!0}))&&t.add(r.id)}k=t;for(let e of $.keys())o.has(e)||$.delete(e);let r=`${S.slide()}|${[...t].join()}`;return r!==E&&(E=r,!0)}let K=0,V=0,Y=0,U=0,G=0;function J(){if(m)return;let t=e.doc.threads();if(W(),d.i&&k.has(d.i)){let e=n.t.querySelector(`[data-thread="${d.i}"] .rbox textarea`)?.value;e&&$.set(d.i,e),d.i=null}d.hidden=!(d.d||d.c||d.Te||d.o),d.hidden&&(d.i=null),function(e){if(e===V)return;V=e,cancelAnimationFrame(Y);let t=K,n=performance.now(),r=e?260:200,i=a=>{let l=Math.min(1,(a-n)/r);K=t+(e-t)*(e?1-(1-l)**3:l*l),o.ae(K),l<1&&(Y=requestAnimationFrame(i))};Y=requestAnimationFrame(i)}(d.hidden?0:1),n.t.classList.toggle("hidden",d.hidden),n.t.classList.toggle("listing",d.c);let l=d.c&&!Zt();(function(e){e!==U&&(U=e,o.Se(e,r),window.clearTimeout(G),G=window.setTimeout(()=>{j(),J()},r?0:400))})(l?Jt:0),o.Ee(i?"column"!==d.mode||d.hidden||l?0:Dn:null),function(e){let t=[],n=[],o=[];for(let r of e){let e=a.get(r.id);r.resolved&&!d.C||!e?.range||k.has(r.id)||(r.id===d.i||r.id===d.m?n.push(e.range):r.resolved?o.push(e.range):t.push(e.range))}d.o&&S.f(d.o.anchor.view)&&n.push(...d.o.ranges),function(e){if(po())for(let t of lo)CSS.highlights.set(t,new Highlight(...e[t.slice(7)]))}({quote:t,on:n,done:o})}(t);for(let e of h)e.u(t);f?.u(t),d.hidden||B.flush()}let X="",Z=()=>n.t.getRootNode().activeElement,Q="input,textarea,select,[contenteditable]:not([contenteditable=false])",ee=()=>{let e=Z();return e instanceof HTMLTextAreaElement&&""!==e.value||!!document.activeElement?.matches(Q)};function te(e,t=ee(),o=Z()){let r=[...n.t.querySelectorAll(`[data-thread="${e}"] .rbox textarea`)].find(e=>!e.closest("[inert]")),i=o?.getAttribute("data-thread");X=i?`.${o.classList[0]}[data-thread="${i}"]`:"",!t&&r&&r.focus({preventScroll:!0})}function ne(){let e=d.o;return!(!e||F.L()||(S.f(e.anchor.view)||S.R(e.anchor.view??{}),0))}function oe(e,t=!1){if(e&&ne())return;if(d.i===e&&!d.o)return e?te(e):void 0;let o=!t&&ee(),r=Z();if(e||(d.Te=!1),d.i=e,e&&(d.o=null,de(e)),J(),e){let i=$.get(e),a=i&&n.t.querySelector(`[data-thread="${e}"] .rbox textarea`);a&&!a.value&&(a.value=i,a.dispatchEvent(new Event("input",{bubbles:!0}))),$.delete(e),t&&f?.ie()?f.se():te(e,o,r)}}function re(e){C(),d.c=!1,d.o=e,d.i=null,J()}function ie(){d.o&&(d.o=null,J())}function ae(e,t=!1){d.d!==e&&(d.d=e,o.ke(e),e?(d.i=null,d.c=!1,f=qn(F)):(C(),f?.destroy(),f=null,T("Comment mode off")),J(),f&&(t&&f.be(),t?f.ie()?M(Tn,Oo,!0,!0):M("Nothing here to comment on"):M(`Click anything to comment, or Tab between blocks · Option-click (Alt-click) to pin · ${jt} or Esc to finish`,qo,!0)))}function le(){d.o&&(S.f(d.o.anchor.view)||F.L())?ie():d.i?oe(null):f&&!f.re()&&ae(!1)}function se(){d.o?ne()||ie():d.i&&oe(null)}function de(e){let t=a.get(e);!t||"orphaned"===t.state||ce(t.range?Yt(t):t.element?[t.element.getBoundingClientRect()]:[])}function ce(e){for(let t of e.slice(0,6)){let e=Ze("div",{class:"pulse"});ot(e,t,4),n.t.prepend(e),window.setTimeout(()=>e.remove(),1300)}}function pe(){for(let e of h)e.destroy();h=function(e){return[..."column"===e.state.mode?[jn(e),ln(e,{ee:!1})]:[ln(e,{ee:!0})],Kn(e),_n(e)]}(F),J()}Je.go=t=>{if(t.startsWith("slide:"))return void S.R({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:r?"auto":"smooth"}),window.setTimeout(()=>ce([o.getBoundingClientRect()]),r?0:450))};let ue=()=>{if(!m){for(let e of h)e.T();f?.T(),B.T(),x=requestAnimationFrame(ue)}},he=e=>{if("Escape"===e.key)return le();if(function(e){return e.code===Ht.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(Q)})(e)){if(e.preventDefault(),f?.We()&&f.be())return;ae(!d.d,!0)}},fe=e=>{if(F.w(e)||s.has(e))return;let t=window.getSelection();t&&!t.isCollapsed||se()},me=()=>{n.t.style.setProperty("--pu-pop",`${Xt()}px`);let t=zo(e.root,"column"===d.mode);t!==d.mode?(d.mode=t,pe()):J()};function ve(){let e=performance.now();0===w&&(y=e),window.clearTimeout(w);let t=Math.min(Po,Math.max(0,y+Ro-e));w=window.setTimeout(()=>{w=0,j(),J()},t)}let ge=new MutationObserver(e=>{e.every(e=>n.element.contains(e.target))||ve()});window.addEventListener("keydown",he),window.addEventListener("click",fe),window.addEventListener("resize",me),ge.observe(e.root,{subtree:!0,childList:!0,characterData:!0});let we=new MutationObserver(()=>ko(n.t,xo(e.root)));for(let e of[document.documentElement,document.body])we.observe(e,{attributes:!0});let ye=new ResizeObserver(ve);ye.observe(e.root);let be=e.doc.onChange((e,t,n)=>{B.Oe(t,n),j(),J()});return j(),pe(),x=requestAnimationFrame(ue),{ctx:F,destroy(){m=!0,cancelAnimationFrame(x),cancelAnimationFrame(Y),cancelAnimationFrame(A),S.destroy(),window.clearTimeout(G),window.clearTimeout(v),window.clearTimeout(w),window.clearTimeout(b),ge.disconnect(),Je.go=void 0,ye.disconnect(),we.disconnect(),be(),window.removeEventListener("keydown",he),window.removeEventListener("click",fe),window.removeEventListener("resize",me),f?.destroy();for(let e of h)e.destroy();B.destroy(),z.destroy(),R.destroy(),o.remove(),n.destroy()}}}var Bo,Ho=null,jo=4e3;function Wo(e={}){if(zt)return zt.mount(e);if(!It())return Promise.reject(new Error("pipeup: another copy of Pipeup owns the add-on queue. Remove one script."));if(Ho)return Ho;let t=async function(e,t){let n,o,r=document.documentElement.getAttribute("data-pipeup-doc"),{id:i,key:a}=r?await K(r):{id:`page-${c(location.origin+location.pathname)}`,key:null},l=!1;if(e.store)n=e.store,o=await te(n);else try{let e=ne.open();n=await function(e,t){return new Promise((n,o)=>{let r=setTimeout(()=>o(new Error("timed out")),t);e.then(n,o).finally(()=>clearTimeout(r))})}(e,jo).catch(t=>{throw e.then(e=>e.close(),()=>{}),t}),o=await te(n)}catch{n=new Z,l=!0,o=await te(n)}let s=e.name?.trim();s&&s!==o.name&&(o={...o,name:s},await n.saveProfile(o));let d,p=await G.open({doc:i,key:a,store:n,identity:o.identity,name:o.name});io(e.slides??null);try{d=Fo({doc:p,root:e.root??document.body,onName:async e=>{p.name=e,o={...o,name:e},await n.saveProfile(o)}})}catch(e){throw io(null),e}l&&d.ctx.Y("This browser can't keep comments for this page — 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};Ot=t;for(let e of qt.values())"waiting"===e.info.state&&Ft(e,t);return()=>{t.i=!1,Ot===t&&(Ot=null);for(let e of[...qt.values()].reverse())e.stop?.(),delete e.stop;e.surface.destroy()}}({surface:d.ctx.addons,doc:p,root:e.root??document.body,ephemeral:l,version:Ye}),f=!1;return window.addEventListener("pagehide",u),{document:p,comments:({all:e=!1}={})=>Bt(d.ctx.s.all(),{title:document.title,url:location.href,exportedAt:new Date,all:e}),flush:()=>p.flush(),unmount:()=>{f||(f=!0,window.removeEventListener("pagehide",u),h(),d.destroy(),io(null),Ho===t()&&(Ho=null))}}}(e,()=>t).catch(e=>{throw Ho===t&&(Ho=null),e});return Ho=t,t}async function Ko(e){if(!Ho)throw new Error("pipeup: Pipeup hasn't started on this page");return(await Ho).comments(e)}return typeof document<"u"&&(zt?console.warn(`pipeup: Pipeup is on this page twice (${zt.VERSION} and ${Ye}); the first one is used. Remove one script.`):(It(),function(){let e=document.documentElement;if(!e.hasAttribute("data-pipeup-doc")||"off"===e.getAttribute("data-pipeup-auto"))return;let t=()=>{Wo().catch(e=>console.error(e))};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",t,{once:!0}):t()}())),Bo=r,((r,i,a,l)=>{if(i&&"object"==typeof i||"function"==typeof i)for(let a of n(i))!o.call(r,a)&&void 0!==a&&e(r,a,{get:()=>i[a],enumerable:!(l=t(i,a))||l.enumerable});return r})(e({},"__esModule",{value:!0}),Bo)})();
2
2
  "use strict";(()=>{function X(n){let t=globalThis;(t.pipeupAddons||=[]).push(n),typeof addEventListener=="function"&&addEventListener("load",()=>{t.Pipeup||console.error(`pipeup: the "${n.id}" add-on needs Pipeup on the page too; load pipeup.min.js.`)},{once:!0})}var f=n=>new TextEncoder().encode(n),Y=n=>new TextDecoder().decode(n);function v(n){let t="";for(let e=0;e<n.length;e+=32768)t+=String.fromCharCode(...n.subarray(e,e+32768));return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function y(n){let t=n.replace(/-/g,"+").replace(/_/g,"/"),e=atob(t+"=".repeat((4-t.length%4)%4));return Uint8Array.from(e,r=>r.charCodeAt(0))}function S(n){let t="";for(let e=0;e<n.length;e+=32768)t+=String.fromCharCode(...n.subarray(e,e+32768));return btoa(t)}function V(n){return Uint8Array.from(atob(n),t=>t.charCodeAt(0))}var P=n=>crypto.getRandomValues(new Uint8Array(n));async function L(n){return new Uint8Array(await crypto.subtle.digest("SHA-256",n))}var xe=/^([A-Za-z0-9_-]{16}):([A-Za-z0-9_-]{43})$/;function W(n,t=document){let e=xe.exec(t.documentElement.getAttribute("data-pipeup-doc")?.trim()??"");return e&&e[1]===n?y(e[2]):null}var Se=n=>f(`pipeup/v1/doc:${n}`);async function ce(n,t,e,r){let i=await crypto.subtle.importKey("raw",n,"HKDF",!1,["deriveBits"]);return crypto.subtle.deriveBits({name:"HKDF",hash:"SHA-256",salt:Se(t),info:f(e)},i,r)}function Q(n,t){return{docId:n,key:async e=>crypto.subtle.importKey("raw",await ce(t,n,`pipeup/v1/${e}/key`,256),"AES-GCM",!1,["encrypt","decrypt"]),addr:async e=>v(new Uint8Array(await ce(t,n,`pipeup/v1/${e}/address`,128))),aad:e=>`pipeup/v1/${e}:${n}`}}var Pe=1e6,Te=1e3;async function le(n,t,e=1/0){let r=new Blob([n]).stream().pipeThrough(t).getReader(),i=[],o=0;for(;;){let{done:d,value:c}=await r.read();if(d)break;if(o+=c.length,o>e)throw r.cancel(),new Error("too large");i.push(c)}let s=new Uint8Array(o),a=0;for(let d of i)s.set(d,a),a+=d.length;return s}var A=(n,t,e)=>D(n,t,{pipeup:1,doc:n.docId,sealed:!1,ops:e});async function D(n,t,e){let r=f(JSON.stringify(e)),i=P(12),o=await crypto.subtle.encrypt({name:"AES-GCM",iv:i,additionalData:f(n.aad(t))},await n.key(t),await le(r,new CompressionStream("deflate-raw"))),s=new Uint8Array(13+o.byteLength);return s[0]=1,s.set(i,1),s.set(new Uint8Array(o),13),s}async function I(n,t,e){try{if(e.length<29||e[0]!==1)return null;let r=await crypto.subtle.decrypt({name:"AES-GCM",iv:e.slice(1,13),additionalData:f(n.aad(t))},await n.key(t),e.slice(13));return JSON.parse(Y(await le(new Uint8Array(r),new DecompressionStream("deflate-raw"),Pe)))}catch{return null}}function C(n,t){let e=t;if(e?.pipeup!==1||e.doc!==n.docId||!Array.isArray(e.ops)||e.ops.length>Te)return null;let r=0;for(let i of e.ops){let o=i?.body?.v;typeof o=="number"&&o!==1&&r++}return{ops:e.ops,newer:r}}async function ee(n,t,e){return C(n,await I(n,t,e))}var te=n=>`pu1.${v(n)}`,ne=n=>{if(!/^pu1\.[A-Za-z0-9_-]+$/.test(n))return null;try{return y(n.slice(4))}catch{return null}};async function re(n,t={}){let e=new Map,r={get:async i=>e.get(i),set:async(i,o)=>void e.set(i,o),lasting:!1};if(t.memory||typeof indexedDB>"u")return r;try{let i=await new Promise((s,a)=>{let d=setTimeout(()=>a(new Error("timed out")),4e3),c=indexedDB.open(`pipeup-addon-${n}`,1);c.onupgradeneeded=()=>c.result.createObjectStore("kv"),c.onsuccess=()=>{clearTimeout(d),s(c.result)},c.onerror=c.onblocked=()=>{clearTimeout(d),a(c.error??new Error("blocked"))}}),o=(s,a)=>new Promise((d,c)=>{let m=a(i.transaction("kv",s).objectStore("kv"));m.onsuccess=()=>d(m.result),m.onerror=()=>c(m.error)});return{get:s=>o("readonly",a=>a.get(s)),set:async(s,a)=>void await o("readwrite",d=>d.put(a,s)),lasting:!0}}catch{return r}}var h=class extends Error{constructor(e,r=!1){super(`try again in ${e} s`);this.seconds=e;this.limit=r;this.name="RetryAfter"}};var Oe=100,pe=5e3,Be=5e3,Ue=3e5,_e=3600,E=class{constructor(t){this.o=t}state="idle";lastOk=0;known=new Set;outbox=new Map;rejected=new Set;inbound=[];inboundTimer=0;sendTimer=0;lastSend=0;backoff=0;off=null;listeners=new Set;stopped=!1;get waiting(){return this.outbox.size}pending(){return[...this.outbox.values()]}onState(t){return this.listeners.add(t),()=>this.listeners.delete(t)}emit(t){t&&(this.state=t);for(let e of[...this.listeners])e()}async start(){let{document:t,transport:e,signal:r}=this.o;this.off=t.onChange((o,s,a)=>{if(a===this.o.id)return;let d=!1;for(let c of s)this.want(c)&&(d=this.outbox.set(c.body.id,c).size>0||d);d&&this.schedule(),this.emit()}),r.addEventListener("abort",()=>this.stop(),{once:!0}),await e.start(o=>this.deliver(o));let i=await e.remoteIds?.();if(i)for(let o of i)this.known.add(o);this.rescan()}stop(){this.stopped||(this.stopped=!0,this.off?.(),clearTimeout(this.inboundTimer),clearTimeout(this.sendTimer),this.o.transport.stop())}want(t){return!this.known.has(t.body.id)&&!this.rejected.has(t.body.id)&&this.o.sendable(t)}rescan(){this.outbox.clear();for(let t of this.o.document.ops())this.want(t)&&this.outbox.set(t.body.id,t);this.schedule(),this.emit()}deliver(t){this.inbound.push(...t),this.inboundTimer||(this.inboundTimer=setTimeout(()=>void this.drain(),Oe))}async drain(){this.inboundTimer=0;let t=this.inbound.splice(0),e=t.map(i=>i?.body?.id).filter(i=>typeof i=="string");for(let i=0;i<t.length;i+=pe)try{await this.o.merge(t.slice(i,i+pe))}catch(o){o?.name!=="UnsavedChangeError"&&globalThis.reportError?.(o)}let r=new Set(this.o.document.ops().map(i=>i.body.id));for(let i of e)r.has(i)?(this.known.add(i),this.outbox.delete(i)):this.rejected.add(i);this.lastOk=Date.now(),this.emit()}schedule(t=this.o.delay??0){if(this.stopped||this.sendTimer||this.outbox.size===0)return;let e=typeof this.o.gap=="function"?this.o.gap():this.o.gap??0,r=Math.max(t,this.lastSend+e-Date.now(),this.backoff);this.sendTimer=setTimeout(()=>void this.send(),r)}async send(){if(this.sendTimer=0,this.stopped||this.o.signal.aborted||this.outbox.size===0)return;let t=[...this.outbox.values()].slice(0,this.o.batch??500);this.emit("sending");try{await this.o.transport.send(t);for(let e of t)this.known.add(e.body.id),this.outbox.delete(e.body.id);this.lastSend=Date.now(),this.lastOk=this.lastSend,this.backoff=0,this.emit("idle")}catch(e){e instanceof h?(this.backoff=Math.min(e.seconds,_e)*1e3*(1+Math.random()*.2),this.emit("limited")):(this.backoff=Math.min(Ue,this.backoff?this.backoff*2:Be),this.emit("offline"))}this.schedule()}};var dt=2n**256n-2n**32n-977n;var Me="sharing isn't set up for this page",M="data-pipeup-share isn't a sharing address",$e=/^(localhost|127\.0\.0\.1|\[::1\])$/,he=/^[A-Za-z0-9_-]{43}$/,T=n=>({kind:"off",reason:n});function ue(n,t=!1){let e=n?.trim();if(!e)return T(Me);let r;try{r=new URL(e)}catch{return T(M)}if(r.protocol!=="https:"&&!(t&&r.protocol==="http:"&&$e.test(r.hostname)))return T(M);let i=r.origin+r.pathname,o=r.hash.slice(1);if(o.startsWith("pm1.")){let[a,d,...c]=o.slice(4).split(".");return!he.test(a??"")||c.length||d!==void 0&&!/^[A-Za-z0-9_-]+$/.test(d)||r.search||!/\/m\/[A-Za-z0-9_-]{22,64}$/.test(i)?T(M):{kind:"mailbox",mailbox:i,key:y(a),...d?{token:d}:{}}}let s=/^\?([A-Za-z0-9_-]{8,64})$/.exec(r.search)?.[1];return!s||!he.test(o)?T(M):{kind:"privatebin",base:i,paste:s,key:y(o)}}var g=class extends Error{constructor(e){super(e);this.kind=e;this.name="Problem"}},fe={Accept:"application/json"},N=(n,t,e)=>n(t,{headers:fe,credentials:"omit",signal:e}),O=n=>({method:"POST",headers:fe,credentials:"omit",body:JSON.stringify(n)}),me=n=>{let t={403:"closed",404:"gone",507:"full"}[n];return t&&new g(t)};async function B(n){let t=await n.text(),e=t.length<1e7&&JSON.parse(t);if(!e||typeof e!="object")throw new Error("the answer was not usable");return[e,t.length]}function $(n,t=9e5){let e=[],r=0;for(let i of n)r+=JSON.stringify(i).length,(!e.length||r>t||e.at(-1).length>=500)&&(e.push([]),r=JSON.stringify(i).length),e.at(-1).push(i);return e}var U=(n,t)=>new Promise(e=>{let r=setTimeout(e,n);t?.addEventListener("abort",()=>{clearTimeout(r),e()},{once:!0})}),z=(n,t=10)=>{let e=Number(n.headers.get("Retry-After"));return e>0?Math.min(e,3600):t},_=n=>n.map(t=>t?.body?.id).filter(t=>typeof t=="string");var Re=524288,Le=1e3,De=async n=>v(await L(f(n))).slice(0,22),j=class{constructor(t,e,r,i){this.a=t;this.l=e;this.f=r;this.signal=i}ids=new Set;expires=null;moved=!1;big=!1;cursor="";seen=new Set;memo=null;async read(){let t=[],e=0;for(let r=0;r<Le;){let i=`${this.a.mailbox}/ops${this.cursor?`?since=${encodeURIComponent(this.cursor)}`:""}`,o=await N(this.f,i,this.signal);if(o.status===404)throw new g("gone");if(o.status===409&&e++<2){this.cursor="";continue}if(!o.ok)throw new Error(`HTTP ${o.status}`);r++;let[s]=await B(o);for(let a of Array.isArray(s.batches)?s.batches:[]){if(typeof a?.id!="string"||typeof a.ct!="string"||this.seen.has(a.id))continue;this.seen.add(a.id);let d=ne(a.ct),c=d&&await ee(this.l,"share",d);if(c){t.push(c);for(let m of _(c.ops))this.ids.add(m)}}if(typeof s.next=="string"&&(this.cursor=s.next),this.expires=typeof s.expires=="string"&&Date.parse(s.expires)||null,s.more!==!0)break}return t}async req(t){let e=t.map(o=>o.body.id).join();if(this.memo?.key!==e){let o=te(await A(this.l,"share",t));this.memo={key:e,ct:o,id:await De(o)}}let{ct:r,id:i}=this.memo;return[`${this.a.mailbox}/ops`,O({id:i,ct:r,token:this.a.token})]}async post(t){for(let e of $(t))await this.one(e)}async one(t){let[e,r]=await this.req(t),i=async()=>{let d=t.length>>1;await this.one(t.slice(0,d)),await this.one(t.slice(d))};if(r.body.length>Re&&t.length>1)return i();let o=await this.f(e,{...r,signal:this.signal}),s=o.status;if(s===200||s===201||s===400)return;if(s===413&&t.length>1)return i();let a=me(s);if(a)throw a;if(s===429){let[d]=await B(o).catch(()=>[{}]),c=Number(d.retryAfter);throw new h(o.headers.get("Retry-After")?z(o):c>0?Math.min(c,3600):10)}throw new Error(`HTTP ${s}`)}};var H=class{constructor(t,e){this.me=t;this.held=new Set(e?.held),this.kept=new Set(e?.kept),this.recv=new Set(e?.recv),this.send=e?.send??!0,this.noted=e?.noted??!1,this.gen=e?.gen??null,this.init=e?.init??!1}held;kept;recv;send;noted;gen;init;hold(t){if(!this.init){this.init=!0;for(let{body:e}of t)e.author===this.me&&this.held.add(e.id)}}sendable(t){let e=t.body;if(this.recv.has(e.id))return!0;if(e.author!==this.me||this.held.has(e.id)||this.kept.has(e.id))return!1;let r=[e.target,e.thread].find(i=>i&&(this.held.has(i)||this.kept.has(i)));if(r)(this.held.has(r)?this.held:this.kept).add(e.id);else if(!this.send)this.kept.add(e.id);else return(e.kind==="create"||e.kind==="reply")&&(this.noted=!0),!0;return!1}decide(t){if(!t)for(let e of this.held)this.kept.add(e);this.held.clear()}};var Ie=256e3,Ce=16,Ne=/^[A-Za-z0-9_-]{8,64}$/,ge=()=>[S(P(16)),S(P(8)),1e5,256,128,"aes","gcm","none"],ze=(n,t)=>({v:2,adata:ge(),ct:S(t),pasteid:n,parentid:n});async function q(n){if(n.status===429)throw new h(z(n));if(!n.ok)throw new Error(`HTTP ${n.status}`);let[t]=await B(n);if(t.status===0)return t;let e=Number(/\d+/.exec(String(t.message??""))?.[0]);throw new h(e>=1&&e<=3600?e:30,!0)}async function je(n,t,e,r="never",i){let o=S(await A(e,"share",[])),s=await q(await n(t,{...O({v:2,adata:[ge(),"plaintext",1,0],ct:o,meta:{expire:r}}),signal:i}));if(typeof s.id!="string"||typeof s.deletetoken!="string")throw new Error("the answer had no paste id");return{id:s.id,deleteToken:s.deletetoken}}async function He(n,t,e,r){return n(t,O({pasteid:e,deletetoken:r}))}async function qe(n,t,e,r){let i=await N(n,`${t}?${e}`,r);if(i.status===404)return null;if(!i.ok)throw new Error(`HTTP ${i.status}`);let[o,s]=await B(i);if(o.status!==0)return null;let a=o.meta?.time_to_live;return{j:o,size:s,ttl:typeof a=="number"&&a>0?a*1e3:null}}var F=class{constructor(t,e,r,i,o,s=()=>{}){this.a=t;this.l=e;this.f=r;this.signal=i;this.onGen=s;this.head=o||t.paste,this.trail.push(t.paste)}ids=new Set;expires=null;moved=!1;big=!1;head;trail=[];seen=new Map;async scan(t,e){let r;for(let i of Array.isArray(t)?t:[]){if(typeof i?.id!="string"||typeof i.ct!="string")continue;let o=this.seen.get(i.id);if(o===void 0){o=null;let s=null;try{i.ct.length<14e5&&(s=V(i.ct))}catch{}let a=s&&await I(this.l,"share",s),d=a?.next,c=typeof d=="string"?null:C(this.l,a);if(typeof d=="string"&&Ne.test(d))o=d;else if(c){e.push(c);for(let m of _(c.ops))this.ids.add(m)}this.seen.set(i.id,o)}r??=o??void 0}return r}async read(){let t=[],e=this.head,r=!1,i=!1;for(let o=0;;){let s=await qe(this.f,this.a.base,e,this.signal);if(!s){if(i)break;if(!r&&e!==this.a.paste){r=!0,e=this.a.paste;continue}throw new g("gone")}i=!0,e!==this.head&&(this.head=e,this.trail.push(e),this.ids.clear(),this.moved=!0,this.onGen(e));let a=s.j.comments,d=await this.scan(a,t);this.expires=s.ttl&&Date.now()+s.ttl;let c=(Array.isArray(a)?a[0]?.ct?.length:0)??0;if(this.big=!d&&s.size>Ie&&s.size>2*c,!d||++o>=Ce)break;e=d}return t}ask(t,e){return[this.a.base,O(ze(t,e))]}async req(t){return this.ask(this.head,await A(this.l,"share",t))}go(t,e){return this.f(t,{...e,signal:this.signal})}async post(t){for(let e of $(t))await q(await this.go(...await this.req(e)))}async roll(t){let e=async s=>{for(let a=0;;a++)try{return await s()}catch(d){if(!(d instanceof h)||a>5||this.signal?.aborted)throw d;await U(d.seconds*1e3*(1+Math.random()*.2),this.signal)}},r=this.head,i=await e(()=>je(this.f,this.a.base,this.l,"never",this.signal));for(let s of $(t))await e(async()=>q(await this.go(...this.ask(i.id,await A(this.l,"share",s)))));await e(async()=>q(await this.go(...this.ask(r,await D(this.l,"share",{next:i.id})))));let o=await this.read();return this.head!==i.id&&await He(this.f,this.a.base,i.id,i.deleteToken).catch(()=>{}),o}};function Fe(n,t,e,r=Math.random()){let i=t?3e5:n<6e5?25e3+r*1e4:n<18e5?12e4:3e5;return Math.min(3e5,i*2**e)}var K=class{constructor(t,e){this.b=t;this.o=e}id="share";problem=null;offline=!1;newer=0;deliver=()=>{};active=Date.now();errors=0;ok=!1;timer;busy=null;again=!1;limit=0;rolling=!1;ready=null;stopped=!1;off=[];async start(t){this.deliver=t;let e=(i,o,s)=>{i&&(i.addEventListener(o,s),this.off.push(()=>i.removeEventListener(o,s)))},r=globalThis;r.addEventListener&&(e(globalThis,"focus",()=>void this.poll()),e(globalThis,"online",()=>void this.poll()),e(globalThis,"pagehide",()=>this.flush()),e(r.document,"visibilitychange",()=>r.document?.visibilityState==="visible"&&void this.poll())),await this.poll()}stop(){this.stopped=!0,clearTimeout(this.timer);for(let t of this.off.splice(0))t()}async remoteIds(){return this.ok?this.b.ids:null}poll(){if(this.busy)return this.again=!0,this.busy;let t=async()=>{do this.again=!1,await this.read();while(this.again&&!this.stopped)};return this.busy=t().finally(()=>this.busy=null)}bump(){this.active=Date.now()}async read(){clearTimeout(this.timer);try{let t=await this.b.read();this.offline=!1,this.errors=0,this.ok=!0,this.newer+=t.reduce((r,i)=>r+i.newer,0);let e=t.flatMap(r=>r.ops);if(e.length&&(this.active=Date.now(),this.deliver(e)),this.b.moved){this.b.moved=!1;let r=this.o.allowed().filter(i=>!this.b.ids.has(i.body.id));r.length&&await this.b.post(r).catch(()=>{})}this.b.big&&!this.rolling&&this.roll()}catch(t){t instanceof g?this.problem=t.kind:(this.offline=!0,this.errors++)}if(this.o.changed(),!this.stopped&&this.problem!=="gone"){let t=globalThis.document?.visibilityState==="hidden";this.timer=setTimeout(()=>void this.poll(),Fe(Date.now()-this.active,t,this.errors))}}lock(t,e=0){let r=this.o.lock,i=globalThis.navigator?.locks;return r?i?new Promise((o,s)=>{i.request(r,{signal:this.o.signal},async()=>{try{o(await t())}catch(a){s(a)}await U(e,this.o.signal)}).catch(s)}):U(Math.random()*5e3,this.o.signal).then(t):t()}get gap(){return Math.max(this.o.gap,this.limit)}async guarded(t){try{await this.lock(t,this.gap),this.offline=!1}catch(e){throw e instanceof h?(e.limit&&(this.limit=Math.max(this.limit,e.seconds*1e3)),e):e instanceof g?(this.problem=e.kind,this.o.changed(),new h(3600)):(this.offline=!0,this.o.changed(),e)}}async send(t){if(this.problem)throw new h(3600);this.bump(),await this.guarded(async()=>{await this.poll();let e=t.filter(r=>!this.b.ids.has(r.body.id));if(e.length){await this.b.post(e);for(let r of e)this.b.ids.add(r.body.id)}})}async prepare(t){try{this.ready=t.length&&JSON.stringify(t).length<4e4?await this.b.req(t):null}catch{this.ready=null}}flush(){let t=this.ready;this.ready=null,!(!t||this.problem||typeof t[1].body!="string"||t[1].body.length>64e3)&&(this.o.fetch??fetch)(t[0],{...t[1],keepalive:!0}).catch(()=>{})}async roll(){this.rolling=!0;try{await U(Math.random()*3e4,this.o.signal),await this.guarded(async()=>{if(await this.poll(),!this.b.big||!this.b.roll)return;let e=(await this.b.roll(this.o.allowed())).flatMap(r=>r.ops);e.length&&this.deliver(e)})}catch{}finally{this.rolling=!1}}};var Ke="Comments here are shared with everyone who has this page.",Ge=7*864e5,ye=["M12 16V4M7 9l5-5 5 5M5 20h14"],Je=["M7 11V8a5 5 0 0 1 10 0v3M6 11h12v9H6z"];function be(n={}){return{id:"share",api:1,version:"0.4.1",needs:["sync","menu","notify","note"],network:{when:"page-configured",to:["page"],says:"Sends the comments you choose to share, sealed so only people with this page can read them, to the sharing service the page names. That service sees when and how much is sent, and your network address."},async setup(t){let e=t.document,r=ue(n.share??document.documentElement.getAttribute("data-pipeup-share"),!0);if(r.kind==="off")return t.off(r.reason);if(!W(e.id))return t.off("needs a document identity");let i=Q(e.id,r.key),o=await re("share",{memory:t.ephemeral}),s=await o.get(`doc:${e.id}`),a=new H(e.me,s);a.hold(e.ops());let d=Promise.resolve(),c=()=>{d=d.then(()=>o.set(`doc:${e.id}`,{...a})).catch(()=>{})};c();let m={gone:"The shared copy is gone",closed:"This page can't send to the shared copy; ask the author for the current file",full:"The shared copy is full; the author can start it again"},ie=new Set,oe=(l,u)=>ie.has(l)||(ie.add(l),t.notify(u)),x=()=>{for(let l of R)l.update();t.setStatus({text:de()}),t.setComposerNote(a.send&&!a.noted&&p.problem!=="gone"?Ke:null),p.newer&&oe("newer",`${p.newer} comments come from a newer version of Pipeup; this page can't show them yet.`),p.problem&&oe(p.problem,m[p.problem]+(p.problem==="gone"?". Your comments stay on this machine.":"."))},se=(l,u)=>fetch(l,u),ae=r.kind==="mailbox"?new j(r,i,se,t.signal):new F(r,i,se,t.signal,a.gen,l=>{a.gen=l,c()}),p=new K(ae,{signal:t.signal,gap:1e4,lock:`pipeup-share:${e.id}`,allowed:()=>e.ops().filter(l=>a.sendable(l)),changed:x}),b=new E({id:"share",document:e,merge:async l=>{let u=await t.merge(l),k=new Set(e.ops().map(w=>w.body.id));for(let w of _(l))k.has(w)&&a.recv.add(w);return c(),u},transport:p,sendable:l=>{let u=a.sendable(l);return a.noted!==s?.noted&&c(),u},signal:t.signal,delay:2e3,gap:()=>p.gap}),G;b.onState(()=>{x(),clearTimeout(G),G=setTimeout(()=>void p.prepare(b.pending()),1e3)});let we=new URL(r.kind==="mailbox"?r.mailbox:r.base).host,de=()=>{let l=b.waiting;return p.problem?m[p.problem]:a.send?p.offline||b.state==="offline"?"Shared \xB7 offline, sends when back":l?`Shared \xB7 ${l} change${l===1?"":"s"} waiting`:"Shared \xB7 up to date":"Shared \xB7 not sending your comments"},ve=()=>{let l=ae.expires;return p.problem==="gone"?"Your comments stay on this machine. The author can start sharing again.":[`Your comments are encrypted and sent to ${we} so others with this page see them. The service can't read them. People who already have your comments, by file or live, could pass them on.`,t.ephemeral&&"This browser can't keep comments; the shared copy keeps the ones you send.",!o.lasting&&"This browser won't remember this choice.",l&&l-Date.now()<Ge&&`The shared copy expires on ${new Date(l).toLocaleDateString("en-GB",{day:"numeric",month:"long"})}.`].filter(Boolean).join(" ")},R=[],J=(l,u,k,w,ke,Ae)=>R[R.push(t.addMenuItem({id:l,icon:u,label:k,hint:w,select:ke,checked:Ae}))-1],Z=e.ops().filter(l=>a.held.has(l.body.id)&&(l.body.kind==="create"||l.body.kind==="reply")).length;if(J("send",ye,()=>a.send||p.problem?de():"Send my comments",ve,()=>{a.send=!a.send,c(),b.rescan(),x()},()=>a.send),Z){let l=o.lasting?"":" This browser won't remember this choice.",u=k=>()=>{a.decide(k),c();for(let w of R.splice(1))w.remove();b.rescan(),x()};J("share-earlier",ye,()=>`Share my ${Z} earlier comment${Z===1?"":"s"}`,()=>`Send the comments you wrote before this page was shared.${l}`,u(!0)),J("keep-earlier",Je,()=>"Keep them on this machine",()=>`Never send the comments you wrote before this page was shared.${l}`,u(!1))}return x(),b.start().then(x,l=>globalThis.reportError?.(l)),e.onChange((l,u,k)=>{k==="local"&&u.length&&p.bump()}),()=>{clearTimeout(G),b.stop()}}}}X(be());})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipeup/share",
3
- "version": "0.5.3",
3
+ "version": "0.6.0",
4
4
  "description": "Share Pipeup comments through an encrypted service (PrivateBin or your own HTTP mailbox).",
5
5
  "license": "MIT",
6
6
  "author": "Pipeup contributors",
@@ -30,7 +30,7 @@
30
30
  "LICENSE"
31
31
  ],
32
32
  "peerDependencies": {
33
- "pipeup": "0.5.3"
33
+ "pipeup": "0.6.0"
34
34
  },
35
35
  "pipeup": {
36
36
  "network": {