UNPKG

@solarpunkltd/comment-system

Version:

A library for writing and reading comments from the Swarm network.

10 lines 76.3 kB
(function(x,w){typeof exports=="object"&&typeof module<"u"?w(exports,require("@ethersphere/bee-js")):typeof define=="function"&&define.amd?define(["exports","@ethersphere/bee-js"],w):(x=typeof globalThis<"u"?globalThis:x||self,w(x["swarm-comment-system"]={},x.BeeJS))})(this,function(x,w){"use strict";function ii(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var Wt={},Er;function oi(){return Er||(Er=1,function(s){var l;Object.defineProperty(s,"__esModule",{value:!0}),s.Vector=s.Cache=s.Assertions=s.Strings=s.Types=s.Objects=s.Dates=s.Promises=s.Numbers=s.System=s.Arrays=s.Random=s.Elliptic=s.Binary=s.TrieRouter=s.AsyncQueue=s.PubSubChannel=s.FixedPointNumber=s.MerkleTree=s.Chunk=s.Uint8ArrayWriter=s.Uint8ArrayReader=s.AsyncLazy=s.Lazy=s.Optional=void 0;async function h(t){return new Promise((e,r)=>t.then(r,e))}async function f(t){return h(Promise.all(t.map(h)))}async function b(t,e=1){const r=In(t,e),n=[],i=r.map(async o=>{for(const a of o)n.push(await a())});return await Promise.all(i),n}async function g(t){return new Promise(e=>setTimeout(()=>{e(!0)},t))}function p(t,e=Math.random){for(let r=t.length-1;r>0;r--){const n=Math.floor(e()*(r+1)),i=t[r];t[r]=t[n],t[n]=i}return t}function y(t){if(t.length===1)return t[0];throw Error(`Expected exactly one element, actual: ${t.length}`)}function m(t){return t.length===1?t[0]:null}function A(t){return t.length>0?t[0]:null}function C(t){if(!t.length)throw Error("Received empty array");return t[0]}function D(t,e){const r=[];for(let n=0;n<t;n++)r.push(e(n));return r}function j(t){const e=[];for(let r=0;r<t[0].length;r++){e.push([]);for(let n=0;n<t.length;n++)e[r].push(t[n][r])}return e}function R(t,e,r){const n=[];for(let i=0;i<t;i++){n.push([]);for(let o=0;o<e;o++)n[i].push(r)}return n}function S(t,e,r,n){if(r<0||n<0||n+e[0].length>t[0].length||r+e.length>t.length)return!1;for(let i=0;i<e.length;i++)for(let o=0;o<e[i].length;o++)if(e[i][o]!==void 0&&t[r+i][n+o]!==e[i][o])return!1;return!0}function T(t,e,r=Math.random){return p(Xr(0,t.length-1),r).slice(0,e)}function K(t,e){return t.map(r=>r[e])}function _t(t){let e=t,r=3405648695,n=3735928559;return function(){return e+=r,r^=e<<7,e*=n,n^=e<<13,e^=r^n,(e>>>0)/4294967296}}function Gt(t,e,r=Math.random){return Math.floor(r()*(e-t+1))+t}function Oi(t,e,r=Math.random){return r()*(e-t)+t}function Mi(){return Math.random()*2-1}function Ii(t,e,r){return e>=t.x&&e<t.x+t.width&&r>=t.y&&r<t.y+t.height}function ki(t,e,r,n=Math.random){let i,o;do i=Gt(0,t-1,n),o=Gt(0,e-1,n);while(r&&Ii(r,i,o));return[i,o]}function Ui(t,e=Math.random){const r=Math.floor(t),n=t-r;return jr(n,e)?r+1:r}function jr(t,e=Math.random){return e()<t}function Yt(t,e=Math.random){return t[Math.floor(t.length*e())]}function Bi(t,e,r=Math.random){if(e>t.length)throw new Error(`Count (${e}) is greater than array length (${t.length})`);return T(t,e,r).map(n=>t[n])}function Ci(t,e,r,n=Math.random){if(e>t.length)throw new Error(`Count (${e}) is greater than array length (${t.length})`);const i=[];for(;i.length<e;){const o=Yt(t,n);i.some(a=>r(a,o))||i.push(o)}return i}function Di(t,e,r,n,i,o=Math.random){const a=t.filter(u=>u!==e&&u!==r),c=[];for(e!==null&&c.push(e);a.length&&c.length<n;){const u=s.Random.intBetween(0,a.length-1,o);i(a[u],c)&&c.push(a[u]),a.splice(u,1)}return p(c,o),{values:c,indexOfGuaranteed:e!==null?c.indexOf(e):-1}}function ut(t){if(!t.length)throw Error("Received empty array");return t[t.length-1]}function Nr(t,e,r){return r(e.reduce((n,i)=>i(n),t))}function ji(t,e){return r=>Nr(r,t,e)}function Ni(t,e,r){if(r===void 0&&(r=Math.random()),t.length!==e.length)throw new Error("Array length mismatch");let n=e.reduce((o,a)=>o+a,0);const i=r*n;for(let o=0;o<t.length-1;o++)if(n-=e[o],i>=n)return t[o];return ut(t)}function Pi(t,e,r=Math.random){const n=e.map(o=>r()*o),i=[];for(let o=0;o<t.length;o++)i.push([t[o],n[o]]);return i.sort((o,a)=>a[1]-o[1]).map(o=>o[0])}function H(t,e){if(t==null)return null;const r=e.split(".");let n=t;for(const i of r){if(n[i]===null||n[i]===void 0)return null;n=n[i]}return n}function Z(t,e,r){const n=e.split(/\.|\[/);let i=t;for(let o=0;o<n.length;o++){const a=n[o],c=o<n.length-1&&n[o+1].includes("]"),u=a.includes("]")?a.replace(/\[|\]/g,""):a;if(o===n.length-1)return i[u]=r,r;F(i[u])||(c?i[u]=[]:i[u]={}),i=i[u]}return r}function Ri(t,e,r=1){const n=H(t,e)||0;return Z(t,e,n+r),n}function Fi(t,e,r){return H(t,e)||Z(t,e,r)}function Li(t,e){const r=se(e,"."),n=_r(e,".");if(!r||!n)return;const i=H(t,r);i&&delete i[n]}function zi(t,e,r){const n=H(t,e);if(!n)throw new Error("Key '"+e+"' does not exist.");return Z(t,e,r),n}function Wi(t,e,r){for(const n of e){const i=H(t,n);if(i)return i}if(r){const n=Object.values(t);if(n.length)return n[0]}return null}async function Vi(t,e,r){for(;;){try{await t()}catch(n){r&&r("Error in forever",n)}await g(e)}}function qi(t,e){t();const r=setInterval(()=>{t()},e);return()=>clearInterval(r)}function Ki(){const t=globalThis.process;return t?t.browser===!0?"browser":"node":"browser"}function Hi(t){return t/1024/1024}function Zi(t,e=1024){return t>=e*e*e*e?(t/e/e/e/e).toFixed(3)+" TB":t>=e*e*e?(t/e/e/e).toFixed(3)+" GB":t>=e*e?(t/e/e).toFixed(3)+" MB":t>=e?(t/e).toFixed(3)+" KB":t+" B"}function Qi(t){const e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t.toLowerCase());if(!e)throw new Error("Invalid hex color: "+t);return[parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16)]}function Xi(t){return"#"+t.map(e=>e.toString(16).padStart(2,"0")).join("")}function _i(t,e,r,n){const i=t*Math.PI/180,o=r*Math.PI/180,a=(r-t)*Math.PI/180,c=(n-e)*Math.PI/180,u=Math.sin(a/2)*Math.sin(a/2)+Math.cos(i)*Math.cos(o)*Math.sin(c/2)*Math.sin(c/2);return 6371e3*(2*Math.atan2(Math.sqrt(u),Math.sqrt(1-u)))}function Ot(t,e){return Math.round(t/e)*e}function Gi(t){return t>1e3?(t/1e3).toFixed(0)+" km":t>=500?Ot(t,100)+" m":t>=100?Ot(t,50)+" m":Ot(t,10)+" m"}function Yi(t){return t*(t+1)/2}function Ji(t){const e=t.match(/-?\d+(\.\d+)?/);if(!e)throw Error("No float found in "+t);return parseFloat(e[0])}function F(t,e=!0){return!t||e&&!Jt(t._readableState)||e&&t.constructor&&(t.constructor.isBuffer||t.constructor.name=="Uint8Array"||t.constructor.name==="ArrayBuffer"||t.constructor.name==="ReadableStream")?!1:typeof t=="object"}function tt(t){return F(t)&&!Array.isArray(t)}function Pr(t){return Array.isArray(t)&&t.length===0}function to(t){return tt(t)&&Object.keys(t).length===0}function Jt(t){return t===void 0}function Mt(t){return Object.prototype.toString.call(t)==="[object Function]"||Object.prototype.toString.call(t)==="[object AsyncFunction]"}function U(t){return Object.prototype.toString.call(t)==="[object String]"}function L(t){return typeof t=="number"&&isFinite(t)}function Rr(t){return t===!0||t===!1}function et(t){return Object.prototype.toString.call(t)==="[object Date]"}function It(t){return!U(t)||t.trim().length===0}function te(t){return L(t)&&Number.isInteger(t)&&t>=1}function Fr(t){return U(t)&&t.match(/^-?\d+$/)!==null}function Lr(t){return U(t)&&t.match(/^(0x)?[0-9a-f]+$/i)!==null}const eo="!@#$%^&*()_+-=[]{}|;:<>?,./",ro="!@#$%^&*()_+-=[]{}|;:<>?,./".split(""),ee="abcdefghijklmnopqrstuvwxyz",no="ABCDEFGHIJKLMNOPQRSTUVWXYZ",io="1234567890",re=ee+no+io,zr=re+eo,Wr=["—","\\","東","京","都","𝖆","𝖇","𝖈","👾","🙇","💁","🙅","ᚠ","ᛇ","ᚻ","ᛦ"],Vr="0123456789abcdef";function oo(t,e=Math.random){let r="";for(let n=0;n<t;n++)r+=ee[Math.floor(e()*ee.length)];return r}function so(t,e=Math.random){let r="";for(let n=0;n<t;n++)r+=re[Math.floor(e()*re.length)];return r}function ao(t,e=Math.random){let r="";for(let n=0;n<t;n++)r+=zr[Math.floor(e()*zr.length)];return r}function uo(t,e=Math.random){let r="";for(let n=0;n<t;n++)r+=Wr[Math.floor(e()*Wr.length)];return r}function co(t,e){const r=new RegExp(`[0-9a-f]{${e}}`,"i"),n=t.match(r);return n?n[0]:null}function lo(t,e,r=ro){const n=Gr(t,r);for(const i of n)if(e(i))return i;return null}function fo(t,e=Math.random){let r="";for(let n=0;n<t;n++)r+=Vr[Math.floor(e()*Vr.length)];return r}function ho(t,e){if(!Fr(t))throw new TypeError(`Expected integer string${e?.name?` for ${e.name}`:""}, got: `+t);const r=BigInt(t);if(e&&(e.min&&r<e.min||e.max&&r>e.max))throw RangeError(`Expected integer string${e?.name?` for ${e.name}`:""} in range: ${e.min??"-inf"}..${e.max??"inf"}; got: `+r);return t}function qr(t,e){if(It(t))throw new TypeError(`Expected string${e?.name?` for ${e.name}`:""}, got: `+t);if(e&&(e.min!==void 0&&t.length<e.min||e.max!==void 0&&t.length>e.max))throw RangeError(`Expected string${e?.name?` for ${e.name}`:""} length in range: ${e.min??"-inf"}..${e.max??"inf"}; got: ${t.length}`);return t}function go(t,e){if(!Lr(t))throw new TypeError(`Expected hex string${e?.name?` for ${e.name}`:""}, got: `+t);const r=t.replace(/^0x/,"");if(r.length%2!==0)throw RangeError(`Expected even number of hex digits${e?.name?` for ${e.name}`:""}; got: `+t);if(e&&e.byteLength&&r.length!==e.byteLength*2)throw RangeError(`Expected hex string${e?.name?` for ${e.name}`:""} of byte length ${e.byteLength}; got: `+r);return r}function mo(t,e){if(!qr(t,e).split("").every(r=>r==="_"||ft(r)))throw new TypeError(`Expected safe string${e?.name?` for ${e.name}`:""}, got: `+t);return t}function Kr(t,e){if(e.min!==void 0&&t<e.min||e.max!==void 0&&t>e.max)throw RangeError(`Expected value${e?.name?` for ${e.name}`:""} in range: ${e.min??"-inf"}..${e.max??"inf"}; got: ${t}`)}function po(t,e){if(!Mt(t))throw new TypeError(`Expected function${e?.name?` for ${e.name}`:""}, got: `+t);return t}function kt(t,e){if(L(t))return e&&Kr(t,e),t;if(!U(t)||!t.match(/^-?\d+(\.\d+)?$/))throw new TypeError(`Expected number${e?.name?` for ${e.name}`:""}, got: `+t);const r=parseFloat(t);return e&&Kr(r,e),r}function ne(t,e){return kt(t,e)|0}function yo(t,e){if(t==="true")return!0;if(t==="false")return!1;if(!Rr(t))throw new TypeError(`Expected boolean${e?.name?` for ${e.name}`:""}, got: `+t);return t}function wo(t,e){if(!et(t))throw new TypeError(`Expected date${e?.name?` for ${e.name}`:""}, got: `+t);return t}function bo(t){return It(t)?null:t}function Ao(t,e){if(!U(t))throw new TypeError(`Expected string${e?.name?` for ${e.name}`:""}, got: `+t);return t}function xo(t,e){if(te(t))return t;const r=parseInt(t,10);if(!te(r))throw new TypeError(`Expected id${e?.name?` for ${e.name}`:""}, got: `+t);return r}function Eo(t,e){if(!U(t))throw new TypeError(`Expected time${e?.name?` for ${e.name}`:""}, got: `+t);const r=t.split(":");if(r.length!==2)throw new TypeError(`Expected time${e?.name?` for ${e.name}`:""}, got: `+t);const n=parseInt(r[0],10),i=parseInt(r[1],10);if(!L(n)||!L(i)||n<0||n>23||i<0||i>59)throw new TypeError(`Expected time, got${e?.name?` for ${e.name}`:""}: `+t);return`${String(n).padStart(2,"0")}:${String(i).padStart(2,"0")}`}function vo(t,e){if(!Array.isArray(t))throw new TypeError(`Expected array${e?.name?` for ${e.name}`:""}, got: `+t);return t}function Ut(t,e){if(!tt(t))throw new TypeError(`Expected object${e?.name?` for ${e.name}`:""}, got: `+t);return t}function $o(t,e){return t===null?null:Ut(t,e)}function So(t,e){const r=Ut(t,e);for(const n of Object.keys(r))if(!U(r[n]))throw new TypeError(`Expected string map${e?.name?` for ${e.name}`:""}, got: `+t);return r}function To(t,e){const r=Ut(t),n=Object.keys(r),i=Object.values(r);if(!n.every(U)||!i.every(L))throw new TypeError(`Expected numeric dictionary${e?.name?` for ${e.name}`:""}, got: `+t);return r}function Hr(t){return U(t)&&t.match(/^https?:\/\/.+/)!==null}function Oo(t,e){if(!Hr(t))throw new TypeError(`Expected url${e?.name?` for ${e.name}`:""}, got: `+t);return t}function Mo(t,e){return e==null?!0:t(e)}function Io(t,e){return e==null?null:t(e)}function ko(t,e){return e===""?void 0:t(e)}function Uo(t,e){return e==null?void 0:t(e)}function Zr(t,e){for(const[r,n]of Object.entries(e))if(!n(t[r]))throw TypeError(`${r} in value does not exist or match shape`);for(const r of Object.keys(t))if(!e[r])throw TypeError(`${r} exists in value but not in shape`);return!0}function Bo(t,e){return t.every(r=>Zr(r,e))}function ct(t,e="json",r=0){if(t&&Mt(t.represent)){const n=t.represent();if(U(n))return e==="json"&&r===0?JSON.stringify(n):n}if(F(t,!1)){if(r>1)return"[object Object]";if(e==="json"){if(Array.isArray(t)){const i=t.map(o=>ct(o,"json",r+1));return r===0?JSON.stringify(i):i}const n={};t.message&&(n.message=ct(t.message,"json",r+1));for(const[i,o]of Object.entries(t))n[i]=ct(o,"json",r+1);return r===0?JSON.stringify(n):n}else if(e==="key-value"){const n=Object.keys(t);return t.message&&!n.includes("message")&&n.unshift("message"),n.map(i=>`${i}=${JSON.stringify(ct(t[i],"json",r+1))}`).join(" ")}}return Jt(t)&&(t="undefined"),r===0?JSON.stringify(t):t}function Co(t,e){if(U(t))return t;const r=Object.keys(t);t.message&&!r.includes("message")&&r.push("message");const n=r.map(i=>`${i}: ${t[i]}`).join("; ");return e&&t.stack?n+` `+t.stack:n}function Q(t,e){if(tt(t)&&tt(e))for(const r in e)tt(e[r])?(t[r]||(t[r]={}),Q(t[r],e[r])):Array.isArray(e[r])?t[r]=[...e[r]]:(e[r]!==null&&e[r]!==void 0||t[r]===null||t[r]===void 0)&&(t[r]=e[r]);return t}function Do(t,e){const r={};return Q(r,t),Q(r,e),r}function jo(t,e,r){const n={};return Q(n,t),Q(n,e),Q(n,r),n}function Qr(t,e){const r={};for(const n of t)for(const i of Object.keys(n))r[i]?r[i]=e(r[i],n[i]):r[i]=n[i];return r}function No(t){return Qr(t,(e,r)=>e+r)}function Po(t,e,r){t[e]||(t[e]=[]),t[e].push(r)}function Ro(t,e,r){for(t.unshift(e);t.length>r;)t.pop()}function Fo(t,e){let r=e%t.length;return r<0&&(r+=t.length),t[r]}function Bt(t,e){Array.prototype.push.apply(t,e)}function Lo(t,e){Array.prototype.unshift.apply(t,e)}async function zo(t,e){const r=[];for(const n of t)r.push(await e(n));return r}function Wo(t,e){const r=[];for(let n=0;n<t.length;n++)r.push(t[n]),n<t.length-1&&(Mt(e)?r.push(e()):r.push(e));return r}function Vo(t,e){if(t!==e)throw Error(`Expected [${t}] to equal [${e}]`);return[t,e]}function qo(t){if(t!==!0)throw Error(`Expected [true], got: [${t}]`);return t}function Ko(t){if(!t)throw Error(`Expected truthy value, got: [${t}]`);return t}function Ho(t){if(t!==!1)throw Error(`Expected [false], got: [${t}]`);return t}function Zo(t){if(t)throw Error(`Expected falsy value, got: [${t}]`);return t}function Qo(t,e){if(!e.includes(t))throw Error(`Expected any of [${e.join(", ")}], got: [${t}]`);return t}function Xo(t,e){for(let r=0;r<t.length;r++){const n=t[r],i=e[r],o=Math.max(0,i.getTime()-Date.now());setTimeout(n,o)}}function _o(t,e,r){return t+(e-t)*r}function Go(t){return t.reduce((e,r)=>e+r,0)}function Yo(t){return t.reduce((e,r)=>e+r,0)/t.length}function Jo(t){const e=[...t].sort((n,i)=>n-i),r=Math.floor(e.length/2);return e.length%2===0?(e[r]+e[r-1])/2:e[r]}function ts(t,e){return t-(e-1)/2}function Xr(t,e){const r=[];for(let n=t;n<=e;n++)r.push(n);return r}function es(t,e){return e.some(r=>t.includes(r))}function rs(t){return/^[\u4E00-\u9FA5]+$/.test(t)}function ie(t,e=()=>!1){return t.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").split("").map(r=>/[a-z0-9]/.test(r)||e(r)?r:"-").join("").replace(/-+/g,"-").replace(/^-|-$/g,"")}function ns(t){return ie(t).replaceAll("-","")}function is(t){return jt(t.replace(/([A-Z])/g," $1"))}function os(t){return t.split("-").map(jt).join(" ")}function ss(t){return Jr(t.split("-").map(jt).join(""))}function as(t,e=", ",r=" and "){return!t||!t.length?"":t.length===1?t[0]:t.length===2?`${t[0]}${r}${t[1]}`:`${t.slice(0,t.length-1).join(e)}${r}${t[t.length-1]}`}function us(t,e){return e+t.split("").join(e)+e}function cs(t){return ie(t).replace(/-/g,"_").toUpperCase()}function Ct(t,e){if(e.length===0)return 0;const r=t.toLowerCase(),n=e.toLowerCase();return t===e?1e4:r.startsWith(n)?1e4-t.length:r.includes(n)?5e3-t.length:new RegExp(".*"+n.split("").join(".*")+".*").test(r)?1e3-t.length:0}function ls(t,e){return t.filter(r=>Ct(r,e)).sort((r,n)=>Ct(n,e)-Ct(r,e))}function fs(t){return t.replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}const hs={"&amp;":"&","&quot;":'"',"&apos;":"'","&gt;":">","&lt;":"<"};function ds(t){let e=t.replace(/&#(\d+);/g,(r,n)=>String.fromCharCode(n)).replace(/&#x(\d+);/g,(r,n)=>String.fromCharCode(parseInt(n,16)));for(const[r,n]of Object.entries(hs))e=e.replaceAll(r,n);return e}function oe(t,e){const r=t.indexOf(e);return r===-1?null:t.slice(0,r)}function Dt(t,e){const r=t.indexOf(e);return r===-1?null:t.slice(r+e.length)}function se(t,e){const r=t.lastIndexOf(e);return r===-1?null:t.slice(0,r)}function _r(t,e){const r=t.lastIndexOf(e);return r===-1?null:t.slice(r+e.length)}function gs(t,e,r){const n=se(t,r);return n?Dt(n,e):null}function ms(t,e,r){const n=Dt(t,e);return n?oe(n,r):null}function ae(t,e,r=!1){const n=r?t.lastIndexOf(e):t.indexOf(e);return n===-1?r?[null,t]:[t,null]:[t.slice(0,n),t.slice(n+e.length)]}function Gr(t,e){let r=[t];for(const n of e)r=r.flatMap(i=>i.split(n));return r.filter(n=>n)}function ue(t){const e=ut(t.split(/\\|\//g)),r=e.lastIndexOf(".",e.length-1);return r<=0?"":e.slice(r+1)}function ce(t){const e=ut(t.split(/\\|\//g)),r=e.lastIndexOf(".",e.length-1);return r<=0?e:e.slice(0,r)}function ps(t){let[e,r]=t.split("@");e=lt(e.replaceAll(".","").toLowerCase()).replaceAll(" ","");const[n]=e.split("+");if(!n||!r||r.indexOf(".")===-1||r.indexOf(".")===r.length-1)throw new Error("Invalid email");return r=lt(r.toLowerCase()).replaceAll(" ",""),`${n}@${r}`}function ys(t){const e=ce(t),r=ue(t);return r?`${e}.${r}`:e}function ws(t){const e=ce(t),r=ue(t);return{basename:e,extension:r,filename:r?`${e}.${r}`:e}}function bs(t,e=Math.random){return t.replace(/\{(.+?)\}/g,(r,n)=>Yt(n.split("|"),e))}function Yr(t){const e=/\{(.+?)\}/,r=t.match(e);if(!r||!r.index)return[t];const n=r[1].split(","),i=t.slice(0,r.index),o=t.slice(r.index+r[0].length);let a=[];for(const c of n){const u=Yr(i+c+o);a=a.concat(u)}return a}function lt(t){return t.split(` `).map(e=>e.trim().replace(/\s+/g," ")).filter(e=>e.length>0).join(` `)}function jt(t){return t.charAt(0).toUpperCase()+t.slice(1)}function Jr(t){return t.charAt(0).toLowerCase()+t.slice(1)}function tn(t){if(!t)return!1;const e=t.charCodeAt(0);return e>=65&&e<=90||e>=97&&e<=122}function en(t){if(!t)return!1;const e=t.charCodeAt(0);return e>=48&&e<=57}function ft(t){return tn(t)||en(t)}const As=` \r.,?!:;"'\`(){}[]~@#$%^&*-+=|<>/\\`.split("");function xs(t){return As.includes(t)}function Es(t){return ft(t)||t==="."||t==="["||t==="]"||t==="_"}function vs(t,e,r,n,i){return t.slice(0,e)+n+t.slice(e,e+r)+i+t.slice(e+r)}function rn(t,e,r=0){const n=e.exec(t.slice(r));return n?{index:n.index,match:n[0]}:null}function nn(t,e,r=!0){if(!r)return e.every(i=>i instanceof RegExp?i.test(t):t.indexOf(i,0)!==-1);let n=0;for(const i of e)if(i instanceof RegExp){const o=rn(t,i,n);if(!o)return!1;n=o.index+o.match.length}else{const o=t.indexOf(i,n);if(o===-1)return!1;n=o+i.length}return!0}function $s(t,e,r=!0){let n=0;for(const i of e){let o=!1;for(;!o&&n<t.length;)nn(t[n],i,r)&&(o=!0),n++;if(!o)return!1}return!0}function Ss(t){return t.match(/"|,/)?`"${t.replace(/"/g,'""')}"`:t}function on(t,e,r=0){const n=[];let i=t.indexOf(e,r);for(;i!==-1;)n.push(i),i=t.indexOf(e,i+e.length);return n}function rt(t,e,r=0){let n=-1;for(const i of e){const o=t.indexOf(i,r);o!==-1&&(n===-1||o<n)&&(n=o)}return n}function Ts(t,e=0){for(let r=e;r<t.length;r++)if(xs(t[r]))return r;return-1}function Os(t,e=0){for(let r=e;r<t.length;r++)if(t[r]==="#"&&ft(t[r+1]))return r;return-1}function sn(t,e,r=0){return t.slice(0,r).lastIndexOf(e)}function an(t,e=0,r="{",n="}"){let i=1;for(let o=e;o<t.length;o++)if(t.slice(o,o+n.length)===n){if(--i===0)return o}else t.slice(o,o+r.length)===r&&i++;return-1}function un(t,e){const r=e.wordBoundary?rt(t,[`${e.opening} `,`${e.opening} `],e.start||0):t.indexOf(e.opening,e.start||0);if(r===-1)return null;const n=an(t,r+e.opening.length,e.opening,e.closing);return n===-1?null:e.exclusive?t.slice(r+e.opening.length,n):t.slice(r,n+e.closing.length)}function Ms(t,e){const r=[];let n=e.wordBoundary?rt(t,[`${e.opening} `,`${e.opening} `],e.start||0):t.indexOf(e.opening,e.start||0);for(;;){if(n===-1)return r;const i=un(t,{...e,start:n});if(!i)return r;r.push(i),n=e.wordBoundary?rt(t,[`${e.opening} `,`${e.opening} `],n+i.length):t.indexOf(e.opening,n+i.length)}}function Is(t,e,r){let n=0;for(;;){const i=s.Strings.extractBlock(t,{...r,start:n});if(!i)return t;const o=e(i);n=t.indexOf(i,n)+o.length,t=t.replace(i,o)}}function ks(t,e){const r=[];let n=0;for(;n<t.length;){const i=t.indexOf(e,n);if(i===-1){r.push({string:t.slice(n),symbol:null});break}const o=t.indexOf(e,i+e.length);if(i>n&&o!==-1&&r.push({string:t.slice(n,i),symbol:null}),o===-1){r.push({string:t.slice(n),symbol:null});break}r.push({string:t.slice(i+e.length,o),symbol:e}),n=o+e.length}return r}function Us(t){const e=[];let r=0;for(;r<t.length;){const n=Os(t,r);if(n===-1){e.push({string:t.slice(r),symbol:null});break}const i=Ts(t,n+1);if(i===-1){e.push({string:t.slice(r,n),symbol:null}),e.push({string:t.slice(n+1),symbol:"#"});break}n>r&&e.push({string:t.slice(r,n),symbol:null}),e.push({string:t.slice(n+1,i),symbol:"#"}),r=i}return e}function Bs(t){const e=[];let r=0;for(;r<t.length;){const n=rt(t,["http://","https://"],r);if(n===-1){e.push({string:t.slice(r),symbol:null});break}const i=rt(t,[" ",` `],n);if(i===-1){n>r&&e.push({string:t.slice(r,n),symbol:null}),e.push({string:t.slice(n),symbol:"http"});break}n>r&&e.push({string:t.slice(r,n),symbol:null}),e.push({string:t.slice(n,i),symbol:"http"}),r=i}return e}const cn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ln="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function Cs(t){return fn(t,cn)}function Ds(t){return hn(t,cn)}function js(t){return fn(t,ln)}function Ns(t){return hn(t,ln)}function fn(t,e){const r="=",n=e.length;let i=0,o=0;const a=[];for(let c=0;c<t.length;c++){const u=t[c];if(u===r)break;const d=e.indexOf(u);if(d===-1)throw new Error(`Invalid character: ${u}`);o=o<<Math.log2(n)|d,i+=Math.log2(n),i>=8&&(i-=8,a.push(o>>i&255))}return new Uint8Array(a)}function hn(t,e){const r=e.length;let n=0,i=0,o="";for(let a=0;a<t.length;a++)for(i=i<<8|t[a],n+=8;n>=Math.log2(r);)n-=Math.log2(r),o+=e[i>>n&r-1];return n>0&&(o+=e[i<<Math.log2(r)-n&r-1]),o.length%4!==0&&(o+="=".repeat(4-o.length%4)),o}function Ps(t){(t.startsWith("0x")||t.startsWith("0X"))&&(t=t.slice(2));const e=t.length/2,r=new Uint8Array(e);for(let n=0;n<e;n++){const i=parseInt(t.slice(n*2,n*2+2),16);r[n]=i}return r}function Rs(t){return Array.from(t).map(e=>e.toString(16).padStart(2,"0")).join("")}function Fs(t){return Array.from(t).map(e=>e.toString(2).padStart(8,"0")).join("")}function Ls(t){const e=Math.ceil(t.length/8),r=new Uint8Array(e);for(let n=0;n<e;n++){const i=parseInt(t.slice(n*8,n*8+8),2);r[n]=i}return r}function zs(t,e){const r=t.split("/").filter(o=>o),n=e.split("/").filter(o=>o);if(r.length!==n.length)return null;const i={};for(let o=0;o<r.length;o++){const a=r[o];if(a.startsWith(":"))i[a.slice(1)]=n[o];else if(a!==n[o])return null}return i}function le(t,e,r){const n=[];for(const i of r)i!==e&&n.push(t.replace(e,i));return n}function Ws(t,e,r,n=Math.random){const i=s.Arrays.shuffle(e.map(a=>({variants:s.Arrays.shuffle(a.variants.map(c=>c),n),avoid:a.avoid})),n),o=[];for(const a of i){const c=a.variants.filter(d=>d!==a.avoid),u=c.find(d=>t.includes(d));if(u&&(Bt(o,le(t,u,c)),o.length>=r))break}if(o.length<r)for(const a of i){const c=a.variants.find(u=>t.includes(u));if(c&&(Bt(o,le(t,c,a.variants)),o.length>=r))break}return o.slice(0,r)}function Vs(t,e,r,n=!1){const i=new RegExp(n?`(?<=\\s|^)${e}(?=\\s|$)`:`\\b${e}\\b`,"g");return t.replace(i,r)}function qs(t,e){const r=/\b[A-Z][a-zA-Z0-9]*\b/g;return t.replace(r,n=>n.toUpperCase()===n?n:e(n))}function Ks(t){return t.replace(/<[^>]*>/g,"")}function dn(t){const e=t.lastIndexOf(" ");if(e===-1)return{line:t,rest:""};const r=t.slice(0,e),n=t.slice(e+1);return{line:r,rest:n}}function Hs(t,e={}){return[...t].reduce((r,n)=>r+(e[n]||1),0)}function Zs(t,e,r={}){const n=[];let i="",o=0;for(let a=0;a<t.length;a++){const c=t[a],u=r[c]||1;if(i+=c,o+=u,o>e){const{line:d,rest:O}=dn(i);n.push(d),i=O,o=O.split("").map(B=>r[B]||1).reduce((B,st)=>B+st,0)}}return i&&n.push(i),n}function Qs(t,e){const r=[];for(let n=0;n<=t.length;n++)r[n]=[n];for(let n=0;n<=e.length;n++)r[0][n]=n;for(let n=1;n<=t.length;n++)for(let i=1;i<=e.length;i++){const o=t[n-1]===e[i-1]?0:1;r[n][i]=Math.min(r[n-1][i]+1,r[n][i-1]+1,r[n-1][i-1]+o)}return r[t.length][e.length]}function gn(t){const e=t.reduce((n,i)=>n.length<i.length?n:i);let r="";for(let n=0;n<e.length;n++){const i=e[n];if(t.every(o=>o[n]===i))r+=i;else break}return r}function Xs(t){const e=gn(t),r=e.lastIndexOf("/");return r===-1?"":e.slice(0,r+1)}function fe(t,e){return new RegExp(`\\b${e}\\b`).test(t)}function _s(t,e,r){return r==="any"?e.some(n=>fe(t,n)):e.every(n=>fe(t,n))}function Gs(t){const e={},r=t.match(/([a-z\-]+)="([^"]+)"/g);if(r)for(const n of r){const[i,o]=ae(n,"=");e[i]=o.slice(1,o.length-1)}return e}function ht(t,e,r=[]){let n="";for(;e<t.length&&(ft(t[e])||r.includes(t[e]));)n+=t[e++];return n}function Ys(t,e,r=[]){const n=on(t,e),i=[];for(const o of n)i.push(ht(t,o+e.length,r));return i}function Js(t,e,r="$",n=":"){for(const i in e)t=mn(t,i,e[i],r,n);return t=pn(t),t}function mn(t,e,r,n="$",i=":"){if(r==="")return t;let o=t.indexOf(`${n}${e}`);for(;o!==-1;){if(t[o+e.length+1]===i)if(t[o+e.length+2]===i)t=t.replace(`${n}${e}${i}${i}`,r);else{const a=ht(t,o+e.length+2,["_"]);t=t.replace(`${n}${e}${i}${a}`,r)}else t=t.replace(`${n}${e}`,r);o=t.indexOf(`${n}${e}`,o+r.length)}return t}function pn(t,e="$",r=":"){let n=t.indexOf(e);for(;n!==-1;){const i=ht(t,n+1);if(t[n+i.length+1]===r)if(t[n+i.length+2]===r)t=t.replace(`${e}${i}${r}${r}`,"");else{const o=ht(t,n+i.length+2);t=t.replace(`${e}${i}${r}${o}`,o)}n=t.indexOf(e,n+1)}return t}function ta(t,e){let r=t.indexOf("](");for(;r!==-1;){const n=sn(t,"[",r),i=t.indexOf(")",r);if(n!==-1&&i!==-1){const[o,a]=t.slice(n+1,i).split("]("),c=e(o,a);t=t.slice(0,n)+c+t.slice(i+1)}r=t.indexOf("](",r+1)}return t}function yn(t,e=!0){const r=Object.entries(t).filter(([n,i])=>i!=null).map(([n,i])=>`${n}=${encodeURIComponent(i)}`).join("&");return r?(e?"?":"")+r:""}function ea(t){const e={},r=t.split("&");for(const n of r){const[i,o]=n.split("=");i&&o&&(e[i]=decodeURIComponent(o))}return e}function ra(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function na(t,e){let r=null,n=-1/0;for(const[i,o]of Object.entries(t)){const a=e(o);a>n&&(n=a,r=i)}return r?[r,t[r]]:null}function ia(t,e,r,n){const i=t.find(a=>a[e]===r),o=t.find(a=>a[e]===r+n);i&&o?(i[e]=r+n,o[e]=r):i&&(i[e]=r+n),t.sort((a,c)=>kt(a[e])-kt(c[e])),t.forEach((a,c)=>a[e]=c+1)}function oa(t){const e=Object.keys(t);if(e.length===1)return t[e[0]];throw new Error("Expected object to have a single key")}function sa(t,e=":"){return Object.fromEntries(t.map(r=>ae(r,e)).map(r=>r[0]&&r[1]?[lt(r[0]),lt(r[1])]:null).filter(r=>r))}function aa(t,e,r){return xn([t,e])+yn(r||{})}function ua(t,e=",",r='"'){const n=[];let i="",o=!1;const a=t.split("");for(const c of a)c===e&&!o?(n.push(i),i=""):c===r&&(!i&&!o||o)?o=!o:i+=c;return n.push(i),n}function ca(t){return`[${Math.floor(t.progress*100)}%] ${Nt(t.deltaMs)} out of ${Nt(t.totalTimeMs)} (${Nt(t.remainingTimeMs)} left) [${Math.round(t.baseTimeMs)} ms each]`}async function la(t,e){let r=e.requiredConsecutivePasses||1,n=0;for(let i=0;i<e.attempts;i++){try{if(await t()){if(n++,n>=r)return}else n=0}catch{n=0}i<e.attempts-1&&await g(e.waitMillis)}throw Error("Timed out waiting for predicate")}function fa(t,e){const r=[];for(let n=t.length-1;n>=0;n--)e(t[n])&&r.push(t.splice(n,1)[0]);return r}function ha(t){return JSON.parse(JSON.stringify(t))}function da(t){return Math.ceil((t||Date.now())/1e3)}function ga(t){return(t||new Date).toISOString().slice(0,10)}function ma(t){return(t||new Date).toISOString().slice(0,19).replace(/T|:/g,"-")}function pa(t){const e=new Date(t);return new Date(e.getTime()-e.getTimezoneOffset()*6e4)}function ya(t){return new Date(t)}function N(t){return String(Math.floor(t)).padStart(2,"0")}function wa(t){let[e,r]=t.split(":");L(parseInt(e,10))||(e="0"),L(parseInt(r,10))||(r="0");let n=pe(ne(e),0,23),i=pe(ne(r),0,59);return`${N(n)}:${N(i)}`}function Nt(t){const e=Math.floor(t/36e5);t=t%36e5;const r=Math.floor(t/6e4);t=t%6e4;const n=Math.floor(t/1e3);return e?`${N(e)}:${N(r)}:${N(n)}`:`${N(r)}:${N(n)}`}function X(t){return Math.floor((et(t)?t.getTime():t)/864e5)}const ba={today:(t,e)=>N(t)+":"+N(e),yesterday:()=>"Yesterday",monday:()=>"Mon",tuesday:()=>"Tue",wednesday:()=>"Wed",thursday:()=>"Thu",friday:()=>"Fri",saturday:()=>"Sat",sunday:()=>"Sun",weeks:t=>`${t}w`};function Aa(t,e){const r=new Date(e?.now||Date.now()),n=e?.labels||ba,i=et(t)?t:new Date(t);if(X(r)===X(i))return n.today(i.getUTCHours(),i.getUTCMinutes(),i.getUTCHours()>12);if(X(r)-X(i)===1)return n.yesterday();const o=de(i);return X(r)-X(i)<7?n[o.day]():n.weeks(Math.round((r.getTime()-i.getTime())/6048e5))}const wn={now:()=>"A few seconds",seconds:t=>`${t} seconds`,minutes:t=>`${t} minutes`,hours:t=>`${t} hours`,days:t=>`${t} days`,weeks:t=>`${t} weeks`};function bn(t,e){const r=e?.now??Date.now(),n=e?.labels||wn,i=s.Types.isDate(t)?t.getTime():t;let o=(r-i)/1e3;return o<10?n.now():o<120?n.seconds(Math.floor(o)):(o/=60,o<120?n.minutes(Math.floor(o)):(o/=60,o<48?n.hours(Math.floor(o)):(o/=24,o<14?n.days(Math.floor(o)):(o/=7,n.weeks(Math.floor(o))))))}function xa(t,e=wn){return bn(0,{now:t*1e3,labels:e})}function Ea(t,e,r){const n=(r?.now??Date.now())-t,i=Math.floor(n/e),o=e/(r?.precision??1)-Math.ceil(n%e/(r?.precision??1));return{cycles:i,remaining:o}}const he={};function va(t,e){return!he[t]||Date.now()>he[t]?(he[t]=Date.now()+e,!0):!1}const $a={s:1e3,m:6e4,h:36e5,d:864e5};function Sa(t,e,r){return e=et(e)?e.getTime():e,r=r?et(r)?r.getTime():r:Date.now(),(r-e)/$a[t]}function Ta(t,e,r,n){n||(n=Date.now());const i=e/r,o=n-t,a=o/e,c=a*r,u=c-o;return{deltaMs:o,progress:i,baseTimeMs:a,totalTimeMs:c,remainingTimeMs:u}}const Oa={0:"sunday",1:"monday",2:"tuesday",3:"wednesday",4:"thursday",5:"friday",6:"saturday"};function An(t){return{zeroBasedIndex:t,day:Oa[t]}}function de(t){return An(t.getDay())}function Ma(t){return de(new Date(t))}function Ia(t){return t*1e3}function ka(t){return t*6e4}function Ua(t){return t*36e5}function Ba(t){return t*864e5}const Ca={ms:1,milli:1,millis:1,millisecond:1,milliseconds:1,s:1e3,sec:1e3,second:1e3,seconds:1e3,m:6e4,min:6e4,minute:6e4,minutes:6e4,h:36e5,hour:36e5,hours:36e5,d:864e5,day:864e5,days:864e5,w:6048e5,week:6048e5,weeks:6048e5,month:2592e6,months:2592e6,y:31536e6,year:31536e6,years:31536e6};function Da(t){const e=parseFloat(t);if(isNaN(e))throw Error("makeDate got NaN for input");const r=t.replace(/^-?[0-9.]+/,"").trim().toLowerCase(),n=Ca[r];if(!n)throw Error(`Unknown unit: "${r}"`);return e*n}const ja={b:1,byte:1,bytes:1,kb:1024,kilobyte:1024,kilobytes:1024,mb:1024**2,megabyte:1024**2,megabytes:1024**2,gb:1024**3,gigabyte:1024**3,gigabytes:1024**3,tb:1024**4,terabyte:1024**4,terabytes:1024**4};function Na(t){const e=parseFloat(t);if(isNaN(e))throw Error("makeDate got NaN for input");const r=t.replace(/^-?[0-9.]+/,"").trim().toLowerCase(),n=ja[r];if(!n)throw Error(`Unknown unit: "${r}"`);return e*n}function Pa(t){return t.replace(/ +/g," ").replace(/^ /gm,"")}const ge={};async function Ra(t,e,r){const n=Date.now(),i=ge[t];if(i&&i.validUntil>n)return i.value;const o=await r(),a=n+e;return ge[t]={value:o,validUntil:a},o}function Fa(t){delete ge[t]}function xn(t,e=!1){t=t.filter(o=>o),e&&U(t[1])&&(t[1]="../"+t[1]);let r="";U(t[0])&&t[0].includes("://")&&(r=oe(t[0],"://")??"",t[0]=Dt(t[0],"://")??"");const n=t.map(o=>String(o)).flatMap(o=>o.split("/")),i=[];for(let o=0;o<n.length;o++)n[o]!=="."&&(n[o]===".."?(!r||i.length>1)&&i.pop():i.push(n[o]));return(r?r+"://":"")+i.join("/").replaceAll(/\/{2,}/g,"/")}function La(t,e,r,n,i=!0){const o=t.indexOf(e),a=t.indexOf(r,o+e.length);if(o===-1||a===-1)throw Error("Start or end not found");return i?t.substring(0,o+e.length)+n+t.substring(a):t.substring(0,o)+n+t.substring(a+r.length)}function za(t){let e="p";t.startsWith("#")?(e="h1",t=t.slice(1).trim()):t.startsWith("-")&&(e="li",t=t.slice(1).trim());const r=t[0]===t[0].toUpperCase(),n=/[.?!]$/.test(t),i=/:$/.test(t);return{type:e,isCapitalized:r,hasPunctuation:n,endsWithColon:i}}function Wa(t,e="(",r=")"){let n=0,i=0;for(;i<t.length;)if(t.startsWith(e,i)?(n++,i+=e.length):t.startsWith(r,i)?(n--,i+=r.length):i++,n<0)return!1;return e===r?n%2===0:n===0}function Va(t){t=t.normalize("NFD").replace(/[\u0300-\u036f]/g,"");let e=t.length;for(;t=t.replace(/(\w+)[\s,']+\w+/g,"$1"),t.length!==e;)e=t.length;return t=t.replaceAll(/[A-Z][a-zA-Z0-9]*/g,"A"),t=t.replaceAll(/[a-z][a-zA-Z0-9]*/g,"a"),t=t.replaceAll(/[\u4E00-\u9FA5]+/g,"Z"),t}function En(t){const e=Object.keys(t).sort((n,i)=>n.localeCompare(i)),r={};for(const n of e)r[n]=_(t[n]);return r}function vn(t){const e=[];return t.sort((r,n)=>JSON.stringify(_(r)).localeCompare(JSON.stringify(_(n)))).forEach(r=>e.push(_(r))),e}function _(t){return Array.isArray(t)?vn(t):F(t)?En(t):t}function $n(t,e){return JSON.stringify(_(t))===JSON.stringify(_(e))}function qa(...t){for(let e=1;e<t.length;e++)if(!$n(t[e-1],t[e]))return!1;return!0}function Ka(t){try{return JSON.parse(t)}catch{return null}}function Ha(){let t=0;return{next:()=>t++}}function Za(t){let e=0;return{next:()=>t[e++%t.length]}}function Qa(t){let e;return r=>{const n=r===t&&e!==t;return e=r,n}}function Xa(t,e,r,n,i){const o={};for(const a of Object.keys(e))o[a]=[];o[n]=[],i&&(t=t.sort(i));for(const a of t){const c=a[r],u=e[c]?c:n;o[u].length>=e[u]?o[n].push(a):o[u].push(a)}return o}function _a(t,e){const r=Object.keys(t),n=Object.keys(e);return{uniqueToA:r.filter(i=>!n.includes(i)),uniqueToB:n.filter(i=>!r.includes(i))}}function Sn(t){const e=Object.keys(t);return e[Math.floor(Math.random()*e.length)]}function Ga(t,e){const r=Sn(t);return t[r]=e(t[r]),r}function Ya(t){return t=t.replace(/\r\n/g,` `),t=t.replace(/(\w+)\((.+)\)/g,(e,r,n)=>`${r}(${n.replaceAll(",","&comma;")})`),t=t.replace(/(,)(\s+})/g,"$2"),t=t.replace(/\.\.\..+?,/g,""),t=t.replace(/({\s+)([a-zA-Z]\w+),/g,"$1$2: '$2',"),t=t.replace(/(,\s+)([a-zA-Z]\w+),/g,"$1$2: '$2',"),t=t.replace(/:(.+)\?(.+):/g,(e,r,n)=>`: (${r.trim()} && ${n.trim()}) ||`),t=t.replace(/([a-zA-Z0-9]+)( ?: ?{)/g,'"$1"$2'),t=t.replace(/([a-zA-Z0-9]+) ?: ?(.+?)(,|\n|})/g,(e,r,n,i)=>`"${r}":"${n.trim()}"${i}`),t=t.replace(/("'|'")/g,'"'),t=t.replaceAll("&comma;",","),JSON.parse(t)}const z=[1e3,1e6,1e9,1e12,1e15,1e18,1e21,1e24,1e27,1e30,1e9,1e16,1e18,1e18,1e18,1e33],Ja=["thousand","million","billion","trillion","quadrillion","quintillion","sextillion","septillion","octillion","nonillion","gwei","bzz","btc","eth","dai","decillion"],Tn=["K","M","B","T","Qa","Qi","Sx","Sp","O","N","gwei","bzz","eth","btc","dai","D"];function tu(t,e,r){let n=t.length-e;if(n<=0)return"0."+"0".repeat(-n)+t+(r?" "+r:"");let i=t.substring(0,n),o=t.substring(n);return i===""&&(i="0"),i+"."+o+(r?" "+r:"")}function eu(t,e){const r=e?.longForm??!1,n=e?.unit?` ${e.unit}`:"",i=r?Ja:Tn,o=e?.precision??1;if(t<z[0])return`${t}${n}`;for(let a=0;a<z.length-1;a++)if(t<z[a+1])return`${(t/z[a]).toFixed(o)}${r?" ":""}${i[a]}${n}`;return`${(t/z[z.length-1]).toFixed(o)}${r?" ":""}${i[z.length-1]}${n}`}function me(t){const e=parseFloat(t);if(isNaN(e))throw Error("makeNumber got NaN for input");const r=t.replace(/^-?[0-9.]+/,"").trim(),n=Tn.findIndex(i=>i.toLowerCase()===r.toLowerCase());return n===-1?e:e*z[n]}function pe(t,e,r){return t<e?e:t>r?r:t}function ru(t,e,r){const n=t+e;return n>r?r:n}function nu(t,e,r){const n=t-e;return n<r?r:n}function iu(t,e){return e(t),t}function ou(t,e){t&&e(t)}function su(t,e){const r=Object.keys(e);for(const n of r)Array.isArray(e[n])&&Array.isArray(t[n])&&Bt(t[n],e[n])}function au(t){return t.splice(0,t.length),t}function uu(t){for(const e of Object.keys(t))(Pr(t[e])||Array.isArray(t[e])&&t[e].every(r=>r==null))&&delete t[e];return t}function cu(t){for(const e of Object.entries(t))(e[1]===null||e[1]===void 0||U(e[1])&&It(e[1]))&&delete t[e[0]];return t}function lu(t,e){const r={};for(const[n,i]of Object.entries(t))e(n)&&(r[n]=i);return r}function fu(t,e){const r={};for(const[n,i]of Object.entries(t))e(i)&&(r[n]=i);return r}function hu(t,e){const r={};for(const n of Object.entries(t))r[n[0]]=e(n[1]);return r}function du(t,e){const r=[];let n=0;for(const i of t)r.push(e(i,n++));return r}async function gu(t,e){try{return await t()}catch{throw e}}function mu(t,e,r){r!=null&&(t[e]=r)}function pu(t,e,r,n){const i=H(r,n);i!=null&&Z(t,e,i)}function yu(t){const e={};for(const[r,n]of Object.entries(t))e[n]=r;return e}function wu(t){const e=Object.keys(t),r=e.map(c=>t[c].length),n=r.reduce((c,u)=>c*=u);let i=1;const o=[1];for(let c=0;c<r.length-1;c++)i*=r[c],o.push(i);const a=[];for(let c=0;c<n;c++){const u={};for(let d=0;d<e.length;d++){const O=t[e[d]],B=Math.floor(c/o[d])%O.length;u[e[d]]=O[B]}a.push(u)}return a}function bu(t){return Object.values(t).filter(e=>e).length}function Au(t,e,r){return t+(r?"["+e+"]":(t.length?".":"")+e)}function Pt(t,e,r,n,i){if(!F(e))return e;for(const[o,a]of Object.entries(e)){const c=Au(r,o,n);Array.isArray(a)?i?Pt(t,a,c,!0,i):t[c]=a.map(u=>Pt(Array.isArray(u)?[]:{},u,"",!1,i)):F(a)?Pt(t,a,c,!1,i):t[c]=a}return t}function xu(t,e=!1,r){return Pt({},t,r||"",!1,e)}function On(t){if(!F(t))return t;const e=Array.isArray(t)?[]:{};for(const[r,n]of Object.entries(t))Array.isArray(n)?Z(e,r,n.map(i=>On(i))):Z(e,r,n);return e}function Eu(t,e,r){return e[t]?e[t]:r}function Mn(t,e){const r={};for(const n of t){const i=e(n);r[i]=n}return r}function vu(t,e){const r={};for(const n of t){const i=e(n);r[i]||(r[i]=[]),r[i].push(n)}return r}function $u(t,e){const r=[];for(let n=0;n<t.length;n+=e)r.push(t.slice(n,n+e));return r}function In(t,e){const r=Math.ceil(t.length/e),n=[];for(let i=0;i<t.length;i+=r)n.push(t.slice(i,i+r));return n}function kn(t,e){const r=[],n=Math.ceil(t.length/e);for(let i=0;i<n;i++)r.push(t.slice(i*e,i*e+e));return r}function Su(t,e){const r=Math.ceil(t.length/e);return kn(t,r)}function Tu(t,e){return Object.values(Mn(t,e))}function Ou(t,e,r,n,i){const o=e?t.map(e):t,a={};for(const u of o)a[u]=(a[u]||0)+1;const c=n?Un(a,i?(u,d)=>u[1]-d[1]:(u,d)=>d[1]-u[1]):a;return r?Object.keys(c):c}function Un(t,e){return Object.fromEntries(Object.entries(t).sort(e))}function Mu(t){const e=[],r=Object.keys(t),n=t[r[0]].length;for(let i=0;i<n;i++){const o={};for(const a of r)o[a]=t[a][i];e.push(o)}return e}function Iu(t,e,r=1){for(const n of t)n[e]+=r}function ku(t,e,r){for(const n of t)n[e]=r}function ye(t,e){const r=[];let n=[];return t.forEach((i,o)=>{(o===0||!e(i,t[o-1]))&&(n=[],r.push(n)),n.push(i)}),r}function Uu(){return{map:new Map,keys:[]}}function Bu(){return{map:new Map,keys:[]}}function Bn(t,e,r,n=100){if(t.map.has(e)){const i=t.keys.indexOf(e);t.keys.splice(i,1)}if(t.map.set(e,r),t.keys.push(e),t.keys.length>n){const i=t.keys.shift();i&&t.map.delete(i)}}function Cu(t,e,r,n=100){if(t.map.has(e)){const i=t.keys.indexOf(e);t.keys.splice(i,1)}if(t.map.set(e,r),t.keys.unshift(e),t.keys.length>n){const i=t.keys.shift();i&&t.map.delete(i)}}function Du(t,e,r,n,i=100){Bn(t,e,{validUntil:Date.now()+n,data:r},i)}function ju(t,e){const r=t.map.get(e);return r&&r.validUntil>Date.now()?r.data:null}class W{constructor(e){this.value=e}static of(e){return new W(e)}static empty(){return new W(null)}map(e){return new W(this.value!==null&&this.value!==void 0?e(this.value):null)}mapAsync(e){return this.value!==null&&this.value!==void 0?e(this.value).then(r=>W.of(r)):Promise.resolve(W.empty())}ifPresent(e){return this.value!==null&&this.value!==void 0&&e(this.value),this}ifPresentAsync(e){return this.value!==null&&this.value!==void 0?e(this.value).then(()=>this):Promise.resolve(this)}ifAbsent(e){return(this.value===null||this.value===void 0)&&e(),this}ifAbsentAsync(e){return this.value===null||this.value===void 0?e().then(()=>this):Promise.resolve(this)}getOrFallback(e){return this.value??e()}getOrFallbackAsync(e){return this.value!==null&&this.value!==void 0?Promise.resolve(this.value):e()}getOrThrow(){if(this.value===null||this.value===void 0)throw Error("Optional.value is empty");return this.value}}s.Optional=W;class Nu{constructor(e){this.supplier=e,this.value=null}get(){return this.value||(this.value=this.supplier()),this.value}}s.Lazy=Nu;class Pu{constructor(e){this.supplier=e,this.value=null}async get(){return this.value||(this.value=await this.supplier()),this.value}}s.AsyncLazy=Pu;function Ru(t){return()=>t.forEach(e=>e())}function Fu(t,e){return t.reduce((r,n)=>e(r)>e(n)?r:n)}function Lu(t,e){const r=t.find(n=>n instanceof e);return W.of(r)}function zu(t,e){return t.filter(r=>r instanceof e)}function Wu(t,e){const r=[],n=Math.max(t.length,e.length);for(let i=0;i<n;i++)t[i]&&r.push(t[i]),e[i]&&r.push(e[i]);return r}function Vu(t,e){return t.includes(e)?t.filter(r=>r!==e):[...t,e]}class qu{constructor(e){this.value=e,this.children=[]}}function Ku(t,e,r,n,i=!1){const o=new Map,a=[];t.forEach(u=>{const d=new qu(u);o.set(u[e],d)}),t.forEach(u=>{const d=o.get(u[e]);if(!d)return;const O=u[r];if(O){const B=o.get(O);B&&B.children.push(d)}else a.push(d)});const c=u=>{u.children.sort((d,O)=>{const B=d.value[n],st=O.value[n];return i?st-B:B-st}),u.children.forEach(c)};return a.forEach(c),a}function Cn(t,e){if(Math.log2(t.length)%1!==0)throw new Error("Array length must be a power of 2");let r=[...t];for(;r.length>1;){const n=[];for(let i=0;i<r.length;i+=2){const o=r[i+1];n.push(e(r[i],o))}r=n}return r[0]}function nt(...t){const e=t.reduce((i,o)=>i+o.length,0),r=new Uint8Array(e);let n=0;return t.forEach(i=>{r.set(i,n),n+=i.length}),r}function Dn(t){return t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71}function jn(t){return t[0]===255&&t[1]===216}function Nn(t){return t[8]===87&&t[9]===69&&t[10]===66&&t[11]===80}function Hu(t){return Dn(t)||jn(t)||Nn(t)}function Zu(t){return new Uint8Array([t])}function Qu(t){return t[0]}function Xu(t,e){const r=new ArrayBuffer(2);return new DataView(r).setUint16(0,t,e==="LE"),new Uint8Array(r)}function _u(t,e){return new DataView(t.buffer).getUint16(t.byteOffset,e==="LE")}function Gu(t,e){const r=new ArrayBuffer(4);return new DataView(r).setUint32(0,t,e==="LE"),new Uint8Array(r)}function Yu(t,e){return new DataView(t.buffer).getUint32(t.byteOffset,e==="LE")}function we(t,e){const r=new ArrayBuffer(8);return new DataView(r).setBigUint64(0,BigInt(t),e==="LE"),new Uint8Array(r)}function Ju(t,e){return new DataView(t.buffer).getBigUint64(t.byteOffset,e==="LE")}function it(t,e){const r=new Uint8Array(32);let n=t;if(e==="LE"){for(let i=0;i<32;i++)r[i]=Number(n&0xffn),n>>=8n;return r}for(let i=31;i>=0;i--)r[i]=Number(n&0xffn),n>>=8n;return r}function ot(t,e){let r=0n;if(e==="LE"){for(let n=31;n>=0;n--)r=r<<8n|BigInt(t[n]);return r}for(let n=0;n<32;n++)r=r<<8n|BigInt(t[n]);return r}function tc(t,e){const r=[];let n=0;for(const i of e)r.push(t.subarray(n,n+i)),n+=i;return r}function be(t,e){const r=[];for(let n=0;n<t.length;n+=e)r.push(t.subarray(n,n+e));return r}const Pn=[0,1,0,32898,2147483648,32906,2147483648,2147516416,0,32907,0,2147483649,2147483648,2147516545,2147483648,32777,0,138,0,136,0,2147516425,0,2147483658,0,2147516555,2147483648,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,0,32778,2147483648,2147483658,2147483648,2147516545,2147483648,32896,0,2147483649,2147483648,2147516424];function ec(t){for(let e=0;e<24;e++){const r=t[0]^t[10]^t[20]^t[30]^t[40],n=t[1]^t[11]^t[21]^t[31]^t[41],i=t[2]^t[12]^t[22]^t[32]^t[42],o=t[3]^t[13]^t[23]^t[33]^t[43],a=t[4]^t[14]^t[24]^t[34]^t[44],c=t[5]^t[15]^t[25]^t[35]^t[45],u=t[6]^t[16]^t[26]^t[36]^t[46],d=t[7]^t[17]^t[27]^t[37]^t[47],O=t[8]^t[18]^t[28]^t[38]^t[48],B=t[9]^t[19]^t[29]^t[39]^t[49],st=i<<1|o>>>31,Rc=o<<1|i>>>31,mt=O^st,pt=B^Rc,Fc=a<<1|c>>>31,Lc=c<<1|a>>>31,yt=r^Fc,wt=n^Lc,zc=u<<1|d>>>31,Wc=d<<1|u>>>31,bt=i^zc,At=o^Wc,Vc=O<<1|B>>>31,qc=B<<1|O>>>31,xt=a^Vc,Et=c^qc,Kc=r<<1|n>>>31,Hc=n<<1|r>>>31,vt=u^Kc,$t=d^Hc;t[0]^=mt,t[1]^=pt,t[2]^=yt,t[3]^=wt,t[4]^=bt,t[5]^=At,t[6]^=xt,t[7]^=Et,t[8]^=vt,t[9]^=$t,t[10]^=mt,t[11]^=pt,t[12]^=yt,t[13]^=wt,t[14]^=bt,t[15]^=At,t[16]^=xt,t[17]^=Et,t[18]^=vt,t[19]^=$t,t[20]^=mt,t[21]^=pt,t[22]^=yt,t[23]^=wt,t[24]^=bt,t[25]^=At,t[26]^=xt,t[27]^=Et,t[28]^=vt,t[29]^=$t,t[30]^=mt,t[31]^=pt,t[32]^=yt,t[33]^=wt,t[34]^=bt,t[35]^=At,t[36]^=xt,t[37]^=Et,t[38]^=vt,t[39]^=$t,t[40]^=mt,t[41]^=pt,t[42]^=yt,t[43]^=wt,t[44]^=bt,t[45]^=At,t[46]^=xt,t[47]^=Et,t[48]^=vt,t[49]^=$t;const Te=t[0],Oe=t[1],Me=t[2]<<1|t[3]>>>31,Ie=t[3]<<1|t[2]>>>31,ke=t[5]<<30|t[4]>>>2,Ue=t[4]<<30|t[5]>>>2,Be=t[6]<<28|t[7]>>>4,Ce=t[7]<<28|t[6]>>>4,De=t[8]<<27|t[9]>>>5,je=t[9]<<27|t[8]>>>5,Ne=t[11]<<4|t[10]>>>28,Pe=t[10]<<4|t[11]>>>28,Re=t[13]<<12|t[12]>>>20,Fe=t[12]<<12|t[13]>>>20,Le=t[14]<<6|t[15]>>>26,ze=t[15]<<6|t[14]>>>26,We=t[17]<<23|t[16]>>>9,Ve=t[16]<<23|t[17]>>>9,qe=t[18]<<20|t[19]>>>12,Ke=t[19]<<20|t[18]>>>12,He=t[20]<<3|t[21]>>>29,Ze=t[21]<<3|t[20]>>>29,Qe=t[22]<<10|t[23]>>>22,Xe=t[23]<<10|t[22]>>>22,_e=t[25]<<11|t[24]>>>21,Ge=t[24]<<11|t[25]>>>21,Ye=t[26]<<25|t[27]>>>7,Je=t[27]<<25|t[26]>>>7,tr=t[29]<<7|t[28]>>>25,er=t[28]<<7|t[29]>>>25,rr=t[31]<<9|t[30]>>>23,nr=t[30]<<9|t[31]>>>23,ir=t[33]<<13|t[32]>>>19,or=t[32]<<13|t[33]>>>19,sr=t[34]<<15|t[35]>>>17,ar=t[35]<<15|t[34]>>>17,ur=t[36]<<21|t[37]>>>11,cr=t[37]<<21|t[36]>>>11,lr=t[38]<<8|t[39]>>>24,fr=t[39]<<8|t[38]>>>24,hr=t[40]<<18|t[41]>>>14,dr=t[41]<<18|t[40]>>>14,gr=t[42]<<2|t[43]>>>30,mr=t[43]<<2|t[42]>>>30,pr=t[45]<<29|t[44]>>>3,yr=t[44]<<29|t[45]>>>3,wr=t[47]<<24|t[46]>>>8,br=t[46]<<24|t[47]>>>8,Ar=t[48]<<14|t[49]>>>18,xr=t[49]<<14|t[48]>>>18;t[0]=Te^~Re&_e,t[1]=Oe^~Fe&Ge,t[2]=Re^~_e&ur,t[3]=Fe^~Ge&cr,t[4]=_e^~ur&Ar,t[5]=Ge^~cr&xr,t[6]=ur^~Ar&Te,t[7]=cr^~xr&Oe,t[8]=Ar^~Te&Re,t[9]=xr^~Oe&Fe,t[10]=Be^~qe&He,t[11]=Ce^~Ke&Ze,t[12]=qe^~He&ir,t[13]=Ke^~Ze&or,t[14]=He^~ir&pr,t[15]=Ze^~or&yr,t[16]=ir^~pr&Be,t[17]=or^~yr&Ce,t[18]=pr^~Be&qe,t[19]=yr^~Ce&Ke,t[20]=Me^~Le&Ye,t[21]=Ie^~ze&Je,t[22]=Le^~Ye&lr,t[23]=ze^~Je&fr,t[24]=Ye^~lr&hr,t[25]=Je^~fr&dr,t[26]=lr^~hr&Me,t[27]=fr^~dr&Ie,t[28]=hr^~Me&Le,t[29]=dr^~Ie&ze,t[30]=De^~Ne&Qe,t[31]=je^~Pe&Xe,t[32]=Ne^~Qe&sr,t[33]=Pe^~Xe&ar,t[34]=Qe^~sr&wr,t[35]=Xe^~ar&br,t[36]=sr^~wr&De,t[37]=ar^~br&je,t[38]=wr^~De&Ne,t[39]=br^~je&Pe,t[40]=ke^~We&tr,t[41]=Ue^~Ve&er,t[42]=We^~tr&rr,t[43]=Ve^~er&nr,t[44]=tr^~rr&gr,t[45]=er^~nr&mr,t[46]=rr^~gr&ke,t[47]=nr^~mr&Ue,t[48]=gr^~ke&We,t[49]=mr^~Ue&Ve,t[0]^=Pn[e*2],t[1]^=Pn[e*2+1]}}function Rn(t){const e=[];for(let r=0;r<t.length;r+=4)e.push(t[r]|t[r+1]<<8|t[r+2]<<16|t[r+3]<<24);return e}function Fn(t,e){if(!t.length){const i=new Uint8Array(136);return i[0]=e,i[135]=128,[Rn(i)]}const r=be(t,136),n=r[r.length-1];if(n.length<136){const i=new Uint8Array(136);i.set(n),i[n.length]=e,i[135]|=128,r[r.length-1]=i}if(n.length===136){const i=new Uint8Array(136);i[0]=e,i[135]=128,r.push(i)}return r.map(Rn)}function Ln(t,e){for(const r of e){for(let n=0;n<34;n+=2)t[n]^=r[n+1],t[n+1]^=r[n];ec(t)}return t}function zn(t){return new Uint8Array([t[1],t[1]>>-24,t[1]>>-16,t[1]>>-8,t[0],t[0]>>8,t[0]>>16,t[0]>>24,t[3],t[3]>>-24,t[3]>>-16,t[3]>>-8,t[2],t[2]>>8,t[2]>>16,t[2]>>24,t[5],t[5]>>-24,t[5]>>-16,t[5]>>-8,t[4],t[4]>>8,t[4]>>16,t[4]>>24,t[7],t[7]>>-24,t[7]>>-16,t[7]>>-8,t[6],t[6]>>8,t[6]>>16,t[6]>>24])}function V(t){return zn(Ln(new Array(50).fill(0),Fn(t,1)))}function rc(t){return zn(Ln(new Array(50).fill(0),Fn(t,6)))}function nc(t,e){const r=Math.min(t.length,e.length);for(let n=0;n<r;n++){const i=t[n]^e[n];for(let o=0;o<8;o++)if(i>>7-o&1)return n*8+o}return Math.min(t.length,e.length)*8}function ic(t,e){const r=Math.min(t.length,e.length);for(let n=0;n<r;n++)if(t[n]!==e[n])return t.subarray(0,n);return t.subarray(0,r)}function oc(t,e,r,n){const i=Math.floor(e/8),o=e%8;r===1?t[i]|=1<<(n==="BE"?7-o:o):t[i]&=~(1<<(n==="BE"?7-o:o))}function sc(t,e,r){const n=Math.floor(e/8),i=e%8;return t[n]>>(r==="BE"?7-i:i)&1}function ac(t,e,r=0){for(let n=r;n<t.length;n++)for(let i=0;i<e.length&&t[n+i]===e[i];i++)if(i===e.length-1)return n;return-1}function Wn(t,e,r=0){if(t.length>=e)return t;const n=new Uint8Array(e);return n.fill(r),n.set(t,e-t.length),n}function uc(t,e,r=0){const n=t.length%e;return n===0?t:Wn(t,t.length+e-n,r)}function Vn(t,e,r=0){if(t.length>=e)return t;const n=new Uint8Array(e);return n.fill(r),n.set(t,0),n}function cc(t,e,r=0){const n=t.length%e;return n===0?t:Vn(t,t.length+e-n,r)}function lc(t,e){const r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t[n]^e[n%e.length];return r}function fc(t){for(let e=0;e<t.length;e++){const r=t[e];if(!(r<128))if((r&224)===192){if(e+1>=t.length||(t[e+1]&192)!==128)return!1;e+=1}else if((r&240)===224){if(e+2>=t.length||(t[e+1]&192)!==128||(t[e+2]&192)!==128)return!1;e+=2}else if((r&248)===240){if(e+3>=t.length||(t[e+1]&192)!==128||(t[e+2]&192)!==128||(t[e+3]&192)!==128)return!1;e+=3}else return!1}return!0}function hc(t,e){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0}function v(t,e){return(t%e+e)%e}function dt(t,e){t=v(t,e);let[r,n]=[0n,1n],[i,o]=[e,t];for(;o!==0n;){const a=i/o;[r,n]=[n,r-a*n],[i,o]=[o,i-a*o]}if(i>1n)throw new Error("a is not invertible");return r<0n&&(r+=e),r}function dc(t,e,r){let n=1n;for(t=v(t,r);e>0;)e%2n===1n&&(n=v(n*t,r)),t=v(t*t,r),e=e/2n;return n}function qn(t,e){return v(t,e)===0n?0n:e%4n===3n?dc(t,(e+1n)/4n,e):null}const k=0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,M=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n,Rt=0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,Ft=0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n;function Ae(t,e,r){if(e===0n)return[0n,0n];const n=v(3n*t*t*dt(2n*e,r),r),i=v(n*n-2n*t,r),o=v(n*(t-i)-e,r);return[i,o]}function Lt(t,e,r,n,i){if(t===0n&&e===0n)return[r,n];if(r===0n&&n===0n)return[t,e];if(t===r&&e===v(-n,i))return[0n,0n];if(t===r&&e===n)return Ae(t,e,i);const o=v((n-e)*dt(r-t,i),i),a=v(o*o-t-r,i),c=v(o*(t-a)-e,i);return[a,c]}function gc(t){if(t<=0n||t>=M)throw new Error("Invalid pri