@ethersphere/bee-js 13.1.0 → 13.1.1-upcoming.g334b531

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
1
  /*! For license information please see index.browser.min.js.LICENSE.txt */
2
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.BeeJs=t():e.BeeJs=t()}(this,(()=>(()=>{var e={20(e,t){"use strict";var n;async function r(e){return new Promise(((t,n)=>e.then(n,t)))}async function o(e){return new Promise((t=>setTimeout((()=>{t(!0)}),e)))}function i(e,t=Math.random){for(let n=e.length-1;n>0;n--){const r=Math.floor(t()*(n+1)),o=e[n];e[n]=e[r],e[r]=o}return e}function s(e,t,n=Math.random){return i(H(0,e.length-1),n).slice(0,t)}function a(e,t,n=Math.random){return Math.floor(n()*(t-e+1))+e}function c(e,t,n){return t>=e.x&&t<e.x+e.width&&n>=e.y&&n<e.y+e.height}function u(e,t=Math.random){return t()<e}function l(e,t=Math.random){return e[Math.floor(e.length*t())]}function f(e){if(!e.length)throw Error("Received empty array");return e[e.length-1]}function h(e,t,n){return n(t.reduce(((e,t)=>t(e)),e))}function d(e,t){if(null==e)return null;const n=t.split(".");let r=e;for(const o of n){if(null===r[o]||void 0===r[o])return null;r=r[o]}return r}function p(e,t,n){const r=t.split(/\.|\[/);let o=e;for(let i=0;i<r.length;i++){const e=r[i],t=i<r.length-1&&r[i+1].includes("]"),s=e.includes("]")?e.replace(/\[|\]/g,""):e;if(i===r.length-1)return o[s]=n,n;g(o[s])||(o[s]=t?[]:{}),o=o[s]}return n}function m(e,t){return Math.round(e/t)*t}function g(e,t=!0){return!(!e||t&&!b(e._readableState)||t&&e.constructor&&(e.constructor.isBuffer||"AbortController"==e.constructor.name||"AbortSignal"==e.constructor.name||"Uint8Array"==e.constructor.name||"ArrayBuffer"===e.constructor.name||"ReadableStream"===e.constructor.name))&&"object"==typeof e}function y(e){return g(e)&&!Array.isArray(e)}function w(e){return Array.isArray(e)&&0===e.length}function b(e){return void 0===e}function v(e){return"[object Function]"===Object.prototype.toString.call(e)||"[object AsyncFunction]"===Object.prototype.toString.call(e)}function B(e){return"[object String]"===Object.prototype.toString.call(e)}function E(e){return"number"==typeof e&&isFinite(e)}function x(e){return!0===e||!1===e}function T(e){return"[object Date]"===Object.prototype.toString.call(e)}function R(e){return!B(e)||0===e.trim().length}function z(e){return E(e)&&Number.isInteger(e)&&e>=1}function A(e){return B(e)&&null!==e.match(/^-?\d+$/)}function k(e){return B(e)&&null!==e.match(/^(0x)?[0-9a-f]+$/i)}t.DH=t.Or=t.Rb=t.AO=t.FQ=t.iQ=t.DO=t.o8=t.yI=t.O3=t.ie=t.Xx=void 0;const O="!@#$%^&*()_+-=[]{}|;:<>?,./".split(""),S="abcdefghijklmnopqrstuvwxyz",$=S+"ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890",I=$+"!@#$%^&*()_+-=[]{}|;:<>?,./",_=["—","\\","東","京","都","𝖆","𝖇","𝖈","👾","🙇","💁","🙅","ᚠ","ᛇ","ᚻ","ᛦ"],V="0123456789abcdef";function D(e,t){if(R(e))throw new TypeError(`Expected string${t?.name?` for ${t.name}`:""}, got: `+e);if(t&&(void 0!==t.min&&e.length<t.min||void 0!==t.max&&e.length>t.max))throw RangeError(`Expected string${t?.name?` for ${t.name}`:""} length in range: ${t.min??"-inf"}..${t.max??"inf"}; got: ${e.length}`);return e}function N(e,t){if(void 0!==t.min&&e<t.min||void 0!==t.max&&e>t.max)throw RangeError(`Expected value${t?.name?` for ${t.name}`:""} in range: ${t.min??"-inf"}..${t.max??"inf"}; got: ${e}`)}function P(e,t){if(E(e))return t&&N(e,t),e;if(!B(e)||!e.match(/^-?\d+(\.\d+)?$/))throw new TypeError(`Expected number${t?.name?` for ${t.name}`:""}, got: `+e);const n=parseFloat(e);return t&&N(n,t),n}function C(e,t){return Math.trunc(P(e,t))}function F(e,t){if(!y(e))throw new TypeError(`Expected object${t?.name?` for ${t.name}`:""}, got: `+e);return e}function G(e){return B(e)&&null!==e.match(/^https?:\/\/.+/)}function U(e){return"bigint"==typeof e}function M(e,t){if(!U(e))throw new TypeError(`Expected bigint${t?.name?` for ${t.name}`:""}, got: `+e);if(void 0!==t?.min&&e<t?.min||void 0!==t?.max&&e>t?.max)throw RangeError(`Expected value${t?.name?` for ${t.name}`:""} in range: ${t.min??"-inf"}..${t.max??"inf"}; got: ${e}`);return e}function L(e,t){for(const[n,r]of Object.entries(t))if(!r(e[n]))throw TypeError(`${n} in value does not exist or match shape`);for(const n of Object.keys(e))if(!t[n])throw TypeError(`${n} exists in value but not in shape`);return!0}function j(e,t){if(y(e)&&y(t))for(const n in t)y(t[n])?(e[n]||(e[n]={}),j(e[n],t[n])):Array.isArray(t[n])?e[n]=[...t[n]]:(null!==t[n]&&void 0!==t[n]||null===e[n]||void 0===e[n])&&(e[n]=t[n]);return e}function Z(e,t){const n={};for(const r of e)for(const e of Object.keys(r))n[e]?n[e]=t(n[e],r[e]):n[e]=r[e];return n}function q(e,t){Array.prototype.push.apply(e,t)}function H(e,t){const n=[];for(let r=e;r<=t;r++)n.push(r);return n}function W(e,t=()=>!1){return e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").split("").map((e=>/[a-z0-9]/.test(e)||t(e)?e:"-")).join("").replace(/-+/g,"-").replace(/^-|-$/g,"")}function J(e,t){if(0===t.length)return 0;const n=e.toLowerCase(),r=t.toLowerCase();return e===t?1e4:n.startsWith(r)?1e4-e.length:n.includes(r)?5e3-e.length:new RegExp(".*"+r.split("").join(".*")+".*").test(n)?1e3-e.length:0}const K={"&amp;":"&","&quot;":'"',"&apos;":"'","&gt;":">","&lt;":"<"};function X(e,t){const n=e.indexOf(t);return-1===n?null:e.slice(0,n)}function Y(e,t){const n=e.indexOf(t);return-1===n?null:e.slice(n+t.length)}function Q(e,t){const n=e.lastIndexOf(t);return-1===n?null:e.slice(0,n)}function ee(e,t){const n=e.lastIndexOf(t);return-1===n?null:e.slice(n+t.length)}function te(e,t,n=!1){const r=n?e.lastIndexOf(t):e.indexOf(t);return-1===r?n?[null,e]:[e,null]:[e.slice(0,r),e.slice(r+t.length)]}function ne(e,t){let n=[e];for(const r of t)n=n.flatMap((e=>e.split(r)));return n.filter((e=>e))}function re(e){const t=f(e.split(/\\|\//g)),n=t.lastIndexOf(".",t.length-1);return n<=0?"":t.slice(n+1)}function oe(e){const t=f(e.split(/\\|\//g)),n=t.lastIndexOf(".",t.length-1);return n<=0?t:t.slice(0,n)}function ie(e){return e.split("\n").map((e=>e.trim().replace(/\s+/g," "))).filter((e=>e.length>0)).join("\n")}function se(e){return e.charAt(0).toUpperCase()+e.slice(1)}function ae(e){return e.charAt(0).toLowerCase()+e.slice(1)}function ce(e){if(!e)return!1;const t=e.charCodeAt(0);return t>=65&&t<=90||t>=97&&t<=122}function ue(e){if(!e)return!1;const t=e.charCodeAt(0);return t>=48&&t<=57}function le(e){return ce(e)||ue(e)}const fe=" \n\t\r.,?!:;\"'`(){}[]~@#$%^&*-+=|<>/\\".split("");function he(e){return fe.includes(e)}function de(e,t,n=0){const r=t.exec(e.slice(n));return r?{index:r.index,match:r[0]}:null}function pe(e,t,n=!0){if(!n)return t.every((t=>t instanceof RegExp?t.test(e):-1!==e.indexOf(t,0)));let r=0;for(const o of t)if(o instanceof RegExp){const t=de(e,o,r);if(!t)return!1;r=t.index+t.match.length}else{const t=e.indexOf(o,r);if(-1===t)return!1;r=t+o.length}return!0}function me(e,t,n=0){const r=[];let o=e.indexOf(t,n);for(;-1!==o;)r.push(o),o=e.indexOf(t,o+t.length);return r}function ge(e,t,n=0){let r=-1;for(const o of t){const t=e.indexOf(o,n);-1!==t&&(-1===r||t<r)&&(r=t)}return r}function ye(e,t=0){for(let n=t;n<e.length;n++)if(he(e[n]))return n;return-1}function we(e,t=0){for(let n=t;n<e.length;n++)if("#"===e[n]&&le(e[n+1]))return n;return-1}function be(e,t,n=0){return e.slice(0,n).lastIndexOf(t)}function ve(e,t=0,n="{",r="}"){let o=1;for(let i=t;i<e.length;i++)if(e.slice(i,i+r.length)===r){if(0==--o)return i}else e.slice(i,i+n.length)===n&&o++;return-1}function Be(e,t){const n=t.wordBoundary?ge(e,[`${t.opening} `,`${t.opening}\n`],t.start||0):e.indexOf(t.opening,t.start||0);if(-1===n)return null;const r=ve(e,n+t.opening.length,t.opening,t.closing);return-1===r?null:t.exclusive?e.slice(n+t.opening.length,r):e.slice(n,r+t.closing.length)}const Ee="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",xe="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function Te(e,t){const n=t.length;let r=0,o=0;const i=[];for(let s=0;s<e.length;s++){const a=e[s];if("="===a)break;const c=t.indexOf(a);if(-1===c)throw new Error(`Invalid character: ${a}`);o=o<<Math.log2(n)|c,r+=Math.log2(n),r>=8&&(r-=8,i.push(o>>r&255))}return new Uint8Array(i)}function Re(e,t){const n=t.length;let r=0,o=0,i="";for(let s=0;s<e.length;s++)for(o=o<<8|e[s],r+=8;r>=Math.log2(n);)r-=Math.log2(n),i+=t[o>>r&n-1];return r>0&&(i+=t[o<<Math.log2(n)-r&n-1]),i.length%4!=0&&(i+="=".repeat(4-i.length%4)),i}function ze(e,t,n){const r=[];for(const o of n)o!==t&&r.push(e.replace(t,o));return r}function Ae(e){const t=e.lastIndexOf(" ");if(-1===t)return{line:e,rest:""};return{line:e.slice(0,t),rest:e.slice(t+1)}}function ke(e){const t=e.reduce(((e,t)=>e.length<t.length?e:t));let n="";for(let r=0;r<t.length;r++){const o=t[r];if(!e.every((e=>e[r]===o)))break;n+=o}return n}function Oe(e,t){return new RegExp(`\\b${t}\\b`).test(e)}function Se(e,t,n=[]){let r="";for(;t<e.length&&(le(e[t])||n.includes(e[t]));)r+=e[t++];return r}function $e(e,t,n,r="$",o=":"){if(""===n)return e;let i=e.indexOf(`${r}${t}`);for(;-1!==i;){if(e[i+t.length+1]===o)if(e[i+t.length+2]===o)e=e.replace(`${r}${t}${o}${o}`,n);else{const s=Se(e,i+t.length+2,["_"]);e=e.replace(`${r}${t}${o}${s}`,n)}else e=e.replace(`${r}${t}`,n);i=e.indexOf(`${r}${t}`,i+n.length)}return e}function Ie(e,t="$",n=":"){let r=e.indexOf(t);for(;-1!==r;){const o=Se(e,r+1);if(e[r+o.length+1]===n)if(e[r+o.length+2]===n)e=e.replace(`${t}${o}${n}${n}`,"");else{const i=Se(e,r+o.length+2);e=e.replace(`${t}${o}${n}${i}`,i)}r=e.indexOf(t,r+1)}return e}function _e(e,t=!0){const n=Object.entries(e).filter((([e,t])=>null!=t)).map((([e,t])=>`${e}=${encodeURIComponent(t)}`)).join("&");return n?(t?"?":"")+n:""}function Ve(e){return String(Math.floor(e)).padStart(2,"0")}function De(e){const t=Math.floor(e/36e5);e%=36e5;const n=Math.floor(e/6e4);e%=6e4;const r=Math.floor(e/1e3);return t?`${Ve(t)}:${Ve(n)}:${Ve(r)}`:`${Ve(n)}:${Ve(r)}`}function Ne(e){return Math.floor((T(e)?e.getTime():e)/864e5)}const Pe={today:(e,t)=>Ve(e)+":"+Ve(t),yesterday:()=>"Yesterday",monday:()=>"Mon",tuesday:()=>"Tue",wednesday:()=>"Wed",thursday:()=>"Thu",friday:()=>"Fri",saturday:()=>"Sat",sunday:()=>"Sun",weeks:e=>`${e}w`};const Ce={now:()=>"A few seconds",seconds:e=>`${e} seconds`,minutes:e=>`${e} minutes`,hours:e=>`${e} hours`,days:e=>`${e} days`,weeks:e=>`${e} weeks`};function Fe(e,n){const r=n?.now??Date.now(),o=n?.labels||Ce;let i=(r-(t.Or.isDate(e)?e.getTime():e))/1e3;return i<10?o.now():i<120?o.seconds(Math.floor(i)):(i/=60,i<120?o.minutes(Math.floor(i)):(i/=60,i<48?o.hours(Math.floor(i)):(i/=24,i<14?o.days(Math.floor(i)):(i/=7,o.weeks(Math.floor(i))))))}const Ge={};const Ue={s:1e3,m:6e4,h:36e5,d:864e5};const Me={0:"sunday",1:"monday",2:"tuesday",3:"wednesday",4:"thursday",5:"friday",6:"saturday"};function Le(e){return{zeroBasedIndex:e,day:Me[e]}}function je(e){return Le(e.getDay())}const Ze={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};const qe={b:0,byte:0,bytes:0,kb:1,kilobyte:1,kilobytes:1,mb:2,megabyte:2,megabytes:2,gb:3,gigabyte:3,gigabytes:3,tb:4,terabyte:4,terabytes:4};const He=new Map;function We(e,t=!1){e=e.filter((e=>e)),t&&B(e[1])&&(e[1]="../"+e[1]);let n="";B(e[0])&&e[0].includes("://")&&(n=X(e[0],"://")??"",e[0]=Y(e[0],"://")??"");const r=e.map((e=>String(e))).flatMap((e=>e.split("/"))),o=[];for(let i=0;i<r.length;i++)"."!==r[i]&&(".."===r[i]?(!n||o.length>1)&&o.pop():o.push(r[i]));return(n?n+"://":"")+o.join("/").replaceAll(/\/{2,}/g,"/")}function Je(e){const t=Object.keys(e).sort(((e,t)=>e.localeCompare(t))),n={};for(const r of t)n[r]=Xe(e[r]);return n}function Ke(e){const t=[];return e.sort(((e,t)=>JSON.stringify(Xe(e)).localeCompare(JSON.stringify(Xe(t))))).forEach((e=>t.push(Xe(e)))),t}function Xe(e){return Array.isArray(e)?Ke(e):g(e)?Je(e):e}function Ye(e,t){return JSON.stringify(Xe(e))===JSON.stringify(Xe(t))}function Qe(e){const t=Object.keys(e);return t[Math.floor(Math.random()*t.length)]}const et=[1e3,1e6,1e9,1e12,1e15,1e18,1e21,1e24,1e27,1e30,1e9,1e16,1e18,1e18,1e18,1e33],tt=["thousand","million","billion","trillion","quadrillion","quintillion","sextillion","septillion","octillion","nonillion","gwei","bzz","btc","eth","dai","decillion"],nt=["K","M","B","T","Qa","Qi","Sx","Sp","O","N","gwei","bzz","eth","btc","dai","D"];function rt(e){const t=parseFloat(e);if(isNaN(t))throw Error("makeNumber got NaN for input");const n=e.replace(/^-?[0-9.]+/,"").trim(),r=nt.findIndex((e=>e.toLowerCase()===n.toLowerCase()));return-1===r?t:t*et[r]}function ot(e,t,n){return e<t?t:e>n?n:e}function it(e,t,n){return e+(n?"["+t+"]":(e.length?".":"")+t)}function st(e,t,n,r,o){if(!g(t))return t;for(const[i,s]of Object.entries(t)){const t=it(n,i,r);Array.isArray(s)?o?st(e,s,t,!0,o):e[t]=s.map((e=>st(Array.isArray(e)?[]:{},e,"",!1,o))):g(s)?st(e,s,t,!1,o):e[t]=s}return e}function at(e,t){const n={};for(const r of e){n[t(r)]=r}return n}function ct(e,t){const n=Math.ceil(e.length/t),r=[];for(let o=0;o<e.length;o+=n)r.push(e.slice(o,o+n));return r}function ut(e,t){const n=[],r=Math.ceil(e.length/t);for(let o=0;o<r;o++)n.push(e.slice(o*t,o*t+t));return n}function lt(e,t){return Object.fromEntries(Object.entries(e).sort(t))}function ft(e,t){const n=[];let r=[];return e.forEach(((o,i)=>{(0===i||!t(o,e[i-1]))&&(r=[],n.push(r)),r.push(o)})),n}function ht(e,t,n,r=100){if(e.map.has(t)){const n=e.keys.indexOf(t);e.keys.splice(n,1)}if(e.map.set(t,n),e.keys.push(t),e.keys.length>r){const t=e.keys.shift();t&&e.map.delete(t)}}class dt{constructor(e){this.value=e}static of(e){return new dt(e)}static empty(){return new dt(null)}map(e){return new dt(null!==this.value&&void 0!==this.value?e(this.value):null)}mapAsync(e){return null!==this.value&&void 0!==this.value?e(this.value).then((e=>dt.of(e))):Promise.resolve(dt.empty())}ifPresent(e){return null!==this.value&&void 0!==this.value&&e(this.value),this}ifPresentAsync(e){return null!==this.value&&void 0!==this.value?e(this.value).then((()=>this)):Promise.resolve(this)}ifAbsent(e){return(null===this.value||void 0===this.value)&&e(),this}ifAbsentAsync(e){return null===this.value||void 0===this.value?e().then((()=>this)):Promise.resolve(this)}getOrFallback(e){return this.value??e()}getOrFallbackAsync(e){return null!==this.value&&void 0!==this.value?Promise.resolve(this.value):e()}getOrThrow(){if(null===this.value||void 0===this.value)throw Error("Optional.value is empty");return this.value}}t.Xx=dt;class pt{constructor(e){this.value=e,this.children=[]}}function mt(e,t){if(Math.log2(e.length)%1!=0)throw new Error("Array length must be a power of 2");let n=[...e];for(;n.length>1;){const e=[];for(let r=0;r<n.length;r+=2){const o=n[r+1];e.push(t(n[r],o))}n=e}return n[0]}function gt(...e){const t=e.reduce(((e,t)=>e+t.length),0),n=new Uint8Array(t);let r=0;return e.forEach((e=>{n.set(e,r),r+=e.length})),n}function yt(e){return 137===e[0]&&80===e[1]&&78===e[2]&&71===e[3]}function wt(e){return 255===e[0]&&216===e[1]}function bt(e){return 87===e[8]&&69===e[9]&&66===e[10]&&80===e[11]}function vt(e,t){const n=new ArrayBuffer(8);return new DataView(n).setBigUint64(0,BigInt(e),"LE"===t),new Uint8Array(n)}function Bt(e,t){const n=new Uint8Array(32);let r=e;if("LE"===t){for(let e=0;e<32;e++)n[e]=Number(0xffn&r),r>>=8n;return n}for(let o=31;o>=0;o--)n[o]=Number(0xffn&r),r>>=8n;return n}function Et(e,t){let n=0n;if("LE"===t){for(let t=31;t>=0;t--)n=n<<8n|BigInt(e[t]);return n}for(let r=0;r<32;r++)n=n<<8n|BigInt(e[r]);return n}function xt(e,t){const n=[];for(let r=0;r<e.length;r+=t)n.push(e.subarray(r,r+t));return n}const Tt=[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 Rt(e){for(let t=0;t<24;t++){const n=e[0]^e[10]^e[20]^e[30]^e[40],r=e[1]^e[11]^e[21]^e[31]^e[41],o=e[2]^e[12]^e[22]^e[32]^e[42],i=e[3]^e[13]^e[23]^e[33]^e[43],s=e[4]^e[14]^e[24]^e[34]^e[44],a=e[5]^e[15]^e[25]^e[35]^e[45],c=e[6]^e[16]^e[26]^e[36]^e[46],u=e[7]^e[17]^e[27]^e[37]^e[47],l=e[8]^e[18]^e[28]^e[38]^e[48],f=e[9]^e[19]^e[29]^e[39]^e[49],h=l^(o<<1|i>>>31),d=f^(i<<1|o>>>31),p=n^(s<<1|a>>>31),m=r^(a<<1|s>>>31),g=o^(c<<1|u>>>31),y=i^(u<<1|c>>>31),w=s^(l<<1|f>>>31),b=a^(f<<1|l>>>31),v=c^(n<<1|r>>>31),B=u^(r<<1|n>>>31);e[0]^=h,e[1]^=d,e[2]^=p,e[3]^=m,e[4]^=g,e[5]^=y,e[6]^=w,e[7]^=b,e[8]^=v,e[9]^=B,e[10]^=h,e[11]^=d,e[12]^=p,e[13]^=m,e[14]^=g,e[15]^=y,e[16]^=w,e[17]^=b,e[18]^=v,e[19]^=B,e[20]^=h,e[21]^=d,e[22]^=p,e[23]^=m,e[24]^=g,e[25]^=y,e[26]^=w,e[27]^=b,e[28]^=v,e[29]^=B,e[30]^=h,e[31]^=d,e[32]^=p,e[33]^=m,e[34]^=g,e[35]^=y,e[36]^=w,e[37]^=b,e[38]^=v,e[39]^=B,e[40]^=h,e[41]^=d,e[42]^=p,e[43]^=m,e[44]^=g,e[45]^=y,e[46]^=w,e[47]^=b,e[48]^=v,e[49]^=B;const E=e[0],x=e[1],T=e[2]<<1|e[3]>>>31,R=e[3]<<1|e[2]>>>31,z=e[5]<<30|e[4]>>>2,A=e[4]<<30|e[5]>>>2,k=e[6]<<28|e[7]>>>4,O=e[7]<<28|e[6]>>>4,S=e[8]<<27|e[9]>>>5,$=e[9]<<27|e[8]>>>5,I=e[11]<<4|e[10]>>>28,_=e[10]<<4|e[11]>>>28,V=e[13]<<12|e[12]>>>20,D=e[12]<<12|e[13]>>>20,N=e[14]<<6|e[15]>>>26,P=e[15]<<6|e[14]>>>26,C=e[17]<<23|e[16]>>>9,F=e[16]<<23|e[17]>>>9,G=e[18]<<20|e[19]>>>12,U=e[19]<<20|e[18]>>>12,M=e[20]<<3|e[21]>>>29,L=e[21]<<3|e[20]>>>29,j=e[22]<<10|e[23]>>>22,Z=e[23]<<10|e[22]>>>22,q=e[25]<<11|e[24]>>>21,H=e[24]<<11|e[25]>>>21,W=e[26]<<25|e[27]>>>7,J=e[27]<<25|e[26]>>>7,K=e[29]<<7|e[28]>>>25,X=e[28]<<7|e[29]>>>25,Y=e[31]<<9|e[30]>>>23,Q=e[30]<<9|e[31]>>>23,ee=e[33]<<13|e[32]>>>19,te=e[32]<<13|e[33]>>>19,ne=e[34]<<15|e[35]>>>17,re=e[35]<<15|e[34]>>>17,oe=e[36]<<21|e[37]>>>11,ie=e[37]<<21|e[36]>>>11,se=e[38]<<8|e[39]>>>24,ae=e[39]<<8|e[38]>>>24,ce=e[40]<<18|e[41]>>>14,ue=e[41]<<18|e[40]>>>14,le=e[42]<<2|e[43]>>>30,fe=e[43]<<2|e[42]>>>30,he=e[45]<<29|e[44]>>>3,de=e[44]<<29|e[45]>>>3,pe=e[47]<<24|e[46]>>>8,me=e[46]<<24|e[47]>>>8,ge=e[48]<<14|e[49]>>>18,ye=e[49]<<14|e[48]>>>18;e[0]=E^~V&q,e[1]=x^~D&H,e[2]=V^~q&oe,e[3]=D^~H&ie,e[4]=q^~oe&ge,e[5]=H^~ie&ye,e[6]=oe^~ge&E,e[7]=ie^~ye&x,e[8]=ge^~E&V,e[9]=ye^~x&D,e[10]=k^~G&M,e[11]=O^~U&L,e[12]=G^~M&ee,e[13]=U^~L&te,e[14]=M^~ee&he,e[15]=L^~te&de,e[16]=ee^~he&k,e[17]=te^~de&O,e[18]=he^~k&G,e[19]=de^~O&U,e[20]=T^~N&W,e[21]=R^~P&J,e[22]=N^~W&se,e[23]=P^~J&ae,e[24]=W^~se&ce,e[25]=J^~ae&ue,e[26]=se^~ce&T,e[27]=ae^~ue&R,e[28]=ce^~T&N,e[29]=ue^~R&P,e[30]=S^~I&j,e[31]=$^~_&Z,e[32]=I^~j&ne,e[33]=_^~Z&re,e[34]=j^~ne&pe,e[35]=Z^~re&me,e[36]=ne^~pe&S,e[37]=re^~me&$,e[38]=pe^~S&I,e[39]=me^~$&_,e[40]=z^~C&K,e[41]=A^~F&X,e[42]=C^~K&Y,e[43]=F^~X&Q,e[44]=K^~Y&le,e[45]=X^~Q&fe,e[46]=Y^~le&z,e[47]=Q^~fe&A,e[48]=le^~z&C,e[49]=fe^~A&F,e[0]^=Tt[2*t],e[1]^=Tt[2*t+1]}}function zt(e){const t=[];for(let n=0;n<e.length;n+=4)t.push(e[n]|e[n+1]<<8|e[n+2]<<16|e[n+3]<<24);return t}function At(e,t){if(!e.length){const e=new Uint8Array(136);return e[0]=t,e[135]=128,[zt(e)]}const n=xt(e,136),r=n[n.length-1];if(r.length<136){const e=new Uint8Array(136);e.set(r),e[r.length]=t,e[135]|=128,n[n.length-1]=e}if(136===r.length){const e=new Uint8Array(136);e[0]=t,e[135]=128,n.push(e)}return n.map(zt)}function kt(e,t){for(const n of t){for(let t=0;t<34;t+=2)e[t]^=n[t+1],e[t+1]^=n[t];Rt(e)}return e}function Ot(e){return new Uint8Array([e[1],e[1]>>-24,e[1]>>-16,e[1]>>-8,e[0],e[0]>>8,e[0]>>16,e[0]>>24,e[3],e[3]>>-24,e[3]>>-16,e[3]>>-8,e[2],e[2]>>8,e[2]>>16,e[2]>>24,e[5],e[5]>>-24,e[5]>>-16,e[5]>>-8,e[4],e[4]>>8,e[4]>>16,e[4]>>24,e[7],e[7]>>-24,e[7]>>-16,e[7]>>-8,e[6],e[6]>>8,e[6]>>16,e[6]>>24])}function St(e){return Ot(kt(new Array(50).fill(0),At(e,1)))}function $t(e,t,n=0){if(e.length>=t)return e;const r=new Uint8Array(t);return r.fill(n),r.set(e,t-e.length),r}function It(e,t,n=0){if(e.length>=t)return e;const r=new Uint8Array(t);return r.fill(n),r.set(e,0),r}function _t(e,t){return(e%t+t)%t}function Vt(e,t){_t(e,t);let[n,r]=[0n,1n],[o,i]=[t,e];for(;0n!==i;){const e=o/i;[n,r]=[r,n-e*r],[o,i]=[i,o-e*i]}if(o>1n)throw new Error("a is not invertible");return n<0n&&t,n}function Dt(e,t){return 0n===_t(e,t)?0n:t%4n===3n?function(e,t,n){let r=1n;for(_t(e,n);t>0;)t%2n===1n&&_t(r*e,n),_t(e*e,n);return r}(e,(t+1n)/4n,t):null}const Nt=0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,Pt=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n,Ct=0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,Ft=0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n;function Gt(e,t,n){if(0n===t)return[0n,0n];const r=_t(3n*e*e*Vt(2n*t,n),n),o=_t(r*r-2n*e,n);return[o,_t(r*(e-o)-t,n)]}function Ut(e,t,n,r,o){if(0n===e&&0n===t)return[n,r];if(0n===n&&0n===r)return[e,t];if(e===n&&t===_t(-r,o))return[0n,0n];if(e===n&&t===r)return Gt(e,t,o);const i=_t((r-t)*Vt(n-e,o),o),s=_t(i*i-e-n,o);return[s,_t(i*(e-s)-t,o)]}function Mt(e,t,n,r){let o=[0n,0n],i=[e,t];const s=n.toString(2);for(const a of s)"0"===a?(Ut(o[0],o[1],i[0],i[1],r),Gt(o[0],o[1],r)):(Ut(o[0],o[1],i[0],i[1],r),Gt(i[0],i[1],r));return o}function Lt(e,t,n){if(t<=0n||t>=Pt)throw new Error("Invalid private key");if(n||_t(Et(St(gt(St(Bt(t,"BE")),Bt(e,"BE"))),"BE"),Pt),n<=0n||n>=Pt)throw new Error("Invalid nonce");const r=_t(e,Pt),o=Mt(Ct,Ft,n,Nt),i=_t(o[0],Pt);let s=_t((r+_t(i,Pt)*t)*Vt(n,Pt),Pt);if(0n===i||0n===s)throw new Error("Invalid r or s value");let a=o[1]%2n===0n?27n:28n;return s>Pt/2n&&(27n===a?28n:27n),[i,s,a]}class jt{constructor(e){this.cursor=0,this.buffer=e}read(e){const t=this.buffer.subarray(this.cursor,this.cursor+e);return this.cursor+=e,t}max(){return this.buffer.length-this.cursor}}class Zt{constructor(e){this.buffer=e,this.cursor=0}write(e){const t=Math.min(this.max(),e.max());return this.buffer.set(e.read(t),this.cursor),this.cursor+=t,t}max(){return this.buffer.length-this.cursor}}class qt{constructor(e,t=0n){this.span=t,this.writer=new Zt(new Uint8Array(e))}build(){return gt(vt(this.span,"LE"),this.writer.buffer)}hash(){const e=mt(xt(this.writer.buffer,32),((e,t)=>qt.hashFunction(gt(e,t))));return qt.hashFunction(gt(vt(this.span,"LE"),e))}}qt.hashFunction=St;class Ht{constructor(e,t=4096){this.counters=[1],this.capacity=t,this.chunks=[new qt(t)],this.onChunk=e}static async root(e,t=4096){const r=new n(n.NOOP,t);return await r.append(e),r.finalize()}async append(e,t=0,n=0n){const r=new jt(e);for(;r.max()>0;){0===this.chunks[t].writer.max()&&await this.elevate(t);const e=this.chunks[t].writer.write(r);n?this.chunks[t].span+=n:this.chunks[0].span+=BigInt(e)}}async elevate(e){this.counters[e]=++this.counters[e]%(this.capacity/32),this.chunks[e+1]||(this.chunks.push(new qt(this.capacity)),this.counters.push(1)),await this.append(this.chunks[e].hash(),e+1,this.chunks[e].span),await this.onChunk(this.chunks[e]),this.chunks[e]=new qt(this.capacity)}async finalize(e=0){return this.chunks[e+1]?1===this.counters[e]?(await this.elevate(e+1),this.chunks[e+1]=this.chunks[e],this.finalize(e+1)):(await this.elevate(e),this.finalize(e+1)):(await this.onChunk(this.chunks[e]),this.chunks[e])}}n=Ht,Ht.NOOP=async e=>{};class Wt{constructor(e,t){if(t<0)throw Error("Scale must be non-negative");this.value=BigInt(e),this.scale=t}static cast(e){if(!e)throw Error("Cannot cast falsy value to FixedPointNumber");if(e instanceof Wt)return e;const t=M(e.value),n=P(e.scale);return new Wt(t,n)}static fromDecimalString(e,t){/e\-\d+$/i.test(e)&&(e=parseFloat(e).toFixed(t));let[n,r]=e.split(".");return r=(r||"").padEnd(t,"0").slice(0,t),new Wt(BigInt(n+r),t)}static fromFloat(e,t){return Wt.fromDecimalString(e.toString(),t)}add(e){return this.assertSameScale(e),new Wt(this.value+e.value,this.scale)}subtract(e){return this.assertSameScale(e),new Wt(this.value-e.value,this.scale)}multiply(e){return new Wt(this.value*e,this.scale)}divmod(e){if(0n===e)throw new Error("Division by zero is not allowed");const t=this.value/e,n=this.value%e;return[new Wt(t,this.scale),new Wt(n,this.scale)]}exchange(e,t,n){if("*"===e){const e=this.value*t.value/10n**BigInt(this.scale);return new Wt(e,n)}this.assertSameScale(t);const r=this.value*10n**BigInt(n)/t.value;return new Wt(r,n)}compare(e){return this.assertSameScale(e),this.value>e.value?1:this.value<e.value?-1:0}toDecimalString(){if(0===this.scale)return this.value.toString();const e=this.value.toString();return`${e.slice(0,-this.scale)||"0"}.${e.slice(-this.scale).padStart(this.scale,"0")}`}toString(){return this.value.toString()}toJSON(){return this.toString()}toFloat(){return parseFloat(this.toDecimalString())}assertSameScale(e){if(this.scale!==e.scale)throw new Error(`Scale mismatch: expected ${this.scale}, but got ${e.scale}`)}}function Jt(e,t,n,r){const o=e.findIndex((e=>e===`--${t}`||e.startsWith(`--${t}=`))),i=e[o];if(!i)return(n||{})[r||t||""]||null;if(i.includes("="))return i.split("=")[1];const s=e[o+1];return s&&!s.startsWith("-")?s:(n||{})[r||t||""]||null}function Kt(e,t,n,r){const o=Jt(e,t,n,r);if(!o)throw new Error(`Missing argument ${t}`);return o}function Xt(e,t){const n=e[t];e.splice(t,1),e.unshift(n)}function Yt(e,t){return{x:e.x+t.x,y:e.y+t.y}}function Qt(e,t){return{x:e.x*t,y:e.y*t}}function en(e,t,n){return{x:e.x+Math.cos(t)*n,y:e.y+Math.sin(t)*n}}function tn(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function nn(e,t,n="row-first"){const r=[];if("column-first"===n)for(let o=0;o<e.length;o++)for(let n=0;n<e[0].length;n++)t(o,n)&&r.push({x:o,y:n});else for(let o=0;o<e[0].length;o++)for(let n=0;n<e.length;n++)t(n,o)&&r.push({x:n,y:o});return r}function rn(e,t,n){return!e[t-1]?.[n]}function on(e,t,n){return!e[t+1]?.[n]}function sn(e,t,n){return!e[t][n-1]}function an(e,t,n){return!e[t][n+1]}function cn(e,t,n){const r=[];return e[t][n]?function(e,t,n){return e[t+1]?.[n]&&e[t-1]?.[n]&&!e[t][n-1]&&!e[t][n+1]}(e,t,n)||function(e,t,n){return e[t][n+1]&&e[t][n-1]&&!e[t-1]?.[n]&&!e[t+1]?.[n]}(e,t,n)?[]:(!e[t-1]?.[n-1]&&rn(e,t,n)&&sn(e,t,n)&&r.push({x:t,y:n}),!e[t+1]?.[n-1]&&on(e,t,n)&&sn(e,t,n)&&r.push({x:t+1,y:n}),!e[t-1]?.[n+1]&&rn(e,t,n)&&an(e,t,n)&&r.push({x:t,y:n+1}),!e[t+1]?.[n+1]&&on(e,t,n)&&an(e,t,n)&&r.push({x:t+1,y:n+1}),r):(e[t-1]?.[n]&&e[t][n-1]&&r.push({x:t,y:n}),e[t+1]?.[n]&&e[t][n-1]&&r.push({x:t+1,y:n}),e[t-1]?.[n]&&e[t][n+1]&&r.push({x:t,y:n+1}),e[t+1]?.[n]&&e[t][n+1]&&r.push({x:t+1,y:n+1}),r)}function un(e,t){return t.map((t=>function(e,t){return Math.atan2(t.y-e.y,t.x-e.x)}(e,t))).sort(((e,t)=>e-t))}function ln(e,t,n,r){const o=(r.y-n.y)*(t.x-e.x)-(r.x-n.x)*(t.y-e.y);if(0===o)return null;let i=e.y-n.y,s=e.x-n.x;const a=(r.x-n.x)*i-(r.y-n.y)*s,c=(t.x-e.x)*i-(t.y-e.y)*s;return i>0&&i<1&&s>0&&s<1?{x:e.x+i*(t.x-e.x),y:e.y+i*(t.y-e.y)}:null}function fn(e,t,n){const r=[],o=en(e,n,1e4);for(const i of t){const t=ln(e,o,i.start,i.end);t&&r.push(t)}return r.length?r.reduce(((t,n)=>tn(e,n)<tn(e,t)?n:t)):null}t.ie=Wt;class hn{constructor(){this.subscribers=[]}subscribe(e){return this.subscribers.push(e),()=>{this.subscribers=this.subscribers.filter((t=>t!==e))}}publish(e){this.subscribers.forEach((t=>t(e)))}clear(){this.subscribers=[]}getSubscriberCount(){return this.subscribers.length}}t.O3=class{constructor(e,t){this.queue=[],this.running=0,this.onProcessed=new hn,this.onDrained=new hn,this.concurrency=e,this.capacity=t}process(){if(this.running>=this.concurrency)return;const e=this.queue.shift();e&&(this.running++,e().finally((()=>{this.running--,this.process(),this.onProcessed.publish(),0===this.running&&this.onDrained.publish()})))}enqueue(e){if(this.queue.length<this.capacity)return this.queue.push(e),this.process(),Promise.resolve();if(this.onProcessed.getSubscriberCount())throw Error("Queue capacity is full");return new Promise((t=>{this.onProcessed.subscribe((()=>{this.queue.length<this.capacity&&(this.queue.push(e),this.process(),this.onProcessed.clear(),t())}))}))}drain(){if(0===this.running)return Promise.resolve();if(this.onDrained.getSubscriberCount())throw Error("Already draining");return new Promise((e=>{this.onDrained.subscribe((()=>{this.onDrained.clear(),e()}))}))}};class dn{constructor(){this.forks=new Map}insert(e,t){if(0===e.length)return void(this.handler=t);const n=e[0];let r,o=n;if(n.startsWith(":")&&n.slice(1),!this.forks.has(o)){const e=new dn;r&&(e.variableName=r),this.forks.set(o,e)}this.forks.get(o).insert(e.slice(1),t)}async handle(e,t,n,r){if(0===e.length)return!!this.handler&&(await this.handler(t,n,r),!0);const o=e[0],i=this.forks.get(o);if(i)return i.handle(e.slice(1),t,n,r);const s=this.forks.get(":");if(s)return s.variableName&&r.set(s.variableName,decodeURIComponent(o)),s.handle(e.slice(1),t,n,r);const a=this.forks.get("*");return!!a&&(r.set("wildcard",e.join("/")),!!a.handler&&(await a.handler(t,n,r),!0))}}t.yI={hexToUint8Array:function(e){(e.startsWith("0x")||e.startsWith("0X"))&&(e=e.slice(2));const t=e.length/2,n=new Uint8Array(t);for(let r=0;r<t;r++){const t=parseInt(e.slice(2*r,2*r+2),16);n[r]=t}return n},uint8ArrayToHex:function(e){return Array.from(e).map((e=>e.toString(16).padStart(2,"0"))).join("")},binaryToUint8Array:function(e){const t=Math.ceil(e.length/8),n=new Uint8Array(t);for(let r=0;r<t;r++){const t=parseInt(e.slice(8*r,8*r+8),2);n[r]=t}return n},uint8ArrayToBinary:function(e){return Array.from(e).map((e=>e.toString(2).padStart(8,"0"))).join("")},base64ToUint8Array:function(e){return Te(e,Ee)},uint8ArrayToBase64:function(e){return Re(e,Ee)},base32ToUint8Array:function(e){return Te(e,xe)},uint8ArrayToBase32:function(e){return Re(e,xe)},log2Reduce:mt,partition:xt,concatBytes:gt,numberToUint8:function(e){return new Uint8Array([e])},uint8ToNumber:function(e){return e[0]},numberToUint16:function(e,t){const n=new ArrayBuffer(2);return new DataView(n).setUint16(0,e,"LE"===t),new Uint8Array(n)},uint16ToNumber:function(e,t){return new DataView(e.buffer).getUint16(e.byteOffset,"LE"===t)},numberToUint32:function(e,t){const n=new ArrayBuffer(4);return new DataView(n).setUint32(0,e,"LE"===t),new Uint8Array(n)},uint32ToNumber:function(e,t){return new DataView(e.buffer).getUint32(e.byteOffset,"LE"===t)},numberToUint64:vt,uint64ToNumber:function(e,t){return new DataView(e.buffer).getBigUint64(e.byteOffset,"LE"===t)},numberToUint256:Bt,uint256ToNumber:Et,sliceBytes:function(e,t){const n=[];let r=0;for(const o of t)n.push(e.subarray(r,r+o)),r+=o;return n},keccak256:St,sha3_256:function(e){return Ot(kt(new Array(50).fill(0),At(e,6)))},proximity:function(e,t){const n=Math.min(e.length,t.length);for(let r=0;r<n;r++){const n=e[r]^t[r];for(let e=0;e<8;e++)if(n>>7-e&1)return 8*r+e}return 8*Math.min(e.length,t.length)},commonPrefix:function(e,t){const n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e[r]!==t[r])return e.subarray(0,r);return e.subarray(0,n)},setBit:function(e,t,n,r){const o=Math.floor(t/8),i=t%8;1===n?e[o]|=1<<("BE"===r?7-i:i):e[o]&=~(1<<("BE"===r?7-i:i))},getBit:function(e,t,n){const r=t%8;return e[Math.floor(t/8)]>>("BE"===n?7-r:r)&1},indexOf:function(e,t,n=0){for(let r=n;r<e.length;r++)for(let n=0;n<t.length&&e[r+n]===t[n];n++)if(n===t.length-1)return r;return-1},equals:function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0},padStart:$t,padStartToMultiple:function(e,t,n=0){const r=e.length%t;return 0===r?e:$t(e,e.length+t-r,n)},padEnd:It,padEndToMultiple:function(e,t,n=0){const r=e.length%t;return 0===r?e:It(e,e.length+t-r,n)},xorCypher:function(e,t){const n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e[r]^t[r%t.length];return n},isUtf8:function(e){for(let t=0;t<e.length;t++){const n=e[t];if(!(n<128))if(192==(224&n)){if(t+1>=e.length||128!=(192&e[t+1]))return!1;t+=1}else if(224==(240&n)){if(t+2>=e.length||128!=(192&e[t+1])||128!=(192&e[t+2]))return!1;t+=2}else{if(240!=(248&n))return!1;if(t+3>=e.length||128!=(192&e[t+1])||128!=(192&e[t+2])||128!=(192&e[t+3]))return!1;t+=3}}return!0}},t.o8={intBetween:a,floatBetween:function(e,t,n=Math.random){return n()*(t-e)+e},chance:u,signed:function(){return 2*Math.random()-1},makeSeededRng:function(e){let t=e,n=3405648695,r=3735928559;return function(){return t+=n,n^=t<<7,t*=r,r^=t<<13,t^=n^r,(t>>>0)/4294967296}},point:function(e,t,n,r=Math.random){let o,i;do{o=a(0,e-1,r),i=a(0,t-1,r)}while(n&&c(n,o,i));return[o,i]},procs:function(e,t=Math.random){const n=Math.floor(e);return u(e-n,t)?n+1:n}},t.DO={countUnique:function(e,t,n,r,o){const i=t?e.map(t):e,s={};for(const c of i)s[c]=(s[c]||0)+1;const a=r?lt(s,o?(e,t)=>e[1]-t[1]:(e,t)=>t[1]-e[1]):s;return n?Object.keys(a):a},makeUnique:function(e,t){return Object.values(at(e,t))},splitBySize:function(e,t){const n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n},splitByCount:ct,index:at,indexCollection:function(e,t){const n={};for(const r of e){const e=t(r);n[e]||(n[e]=[]),n[e].push(r)}return n},onlyOrThrow:function(e){if(1===e.length)return e[0];throw Error(`Expected exactly one element, actual: ${e.length}`)},onlyOrNull:function(e){return 1===e.length?e[0]:null},firstOrThrow:function(e){if(!e.length)throw Error("Received empty array");return e[0]},firstOrNull:function(e){return e.length>0?e[0]:null},shuffle:i,initialize:function(e,t){const n=[];for(let r=0;r<e;r++)n.push(t(r));return n},initialize2D:function(e,t,n){const r=[];for(let o=0;o<e;o++){r.push([]);for(let e=0;e<t;e++)r[o].push(n)}return r},rotate2D:function(e){const t=[];for(let n=0;n<e[0].length;n++){t.push([]);for(let r=0;r<e.length;r++)t[n].push(e[r][n])}return t},containsShape:function(e,t,n,r){if(n<0||r<0||r+t[0].length>e[0].length||n+t.length>e.length)return!1;for(let o=0;o<t.length;o++)for(let i=0;i<t[o].length;i++)if(void 0!==t[o][i]&&e[n+o][r+i]!==t[o][i])return!1;return!0},glue:function(e,t){const n=[];for(let r=0;r<e.length;r++)n.push(e[r]),r<e.length-1&&(v(t)?n.push(t()):n.push(t));return n},pluck:function(e,t){return e.map((e=>e[t]))},pick:l,pickMany:function(e,t,n=Math.random){if(t>e.length)throw new Error(`Count (${t}) is greater than array length (${e.length})`);return s(e,t,n).map((t=>e[t]))},pickManyUnique:function(e,t,n,r=Math.random){if(t>e.length)throw new Error(`Count (${t}) is greater than array length (${e.length})`);const o=[];for(;o.length<t;){const t=l(e,r);o.some((e=>n(e,t)))||o.push(t)}return o},pickWeighted:function(e,t,n){if(void 0===n&&(n=Math.random()),e.length!==t.length)throw new Error("Array length mismatch");let r=t.reduce(((e,t)=>e+t),0);const o=n*r;for(let i=0;i<e.length-1;i++)if(r-=t[i],o>=r)return e[i];return f(e)},pickRandomIndices:s,pickGuaranteed:function(e,n,r,o,s,a=Math.random){const c=e.filter((e=>e!==n&&e!==r)),u=[];for(null!==n&&u.push(n);c.length&&u.length<o;){const e=t.o8.intBetween(0,c.length-1,a);s(c[e],u)&&u.push(c[e]),c.splice(e,1)}return i(u,a),{values:u,indexOfGuaranteed:null!==n?u.indexOf(n):-1}},last:f,pipe:h,makePipe:function(e,t){return n=>h(n,e,t)},sortWeighted:function(e,t,n=Math.random){const r=t.map((e=>n()*e)),o=[];for(let i=0;i<e.length;i++)o.push([e[i],r[i]]);return o.sort(((e,t)=>t[1]-e[1])).map((e=>e[0]))},pushAll:q,unshiftAll:function(e,t){Array.prototype.unshift.apply(e,t)},filterAndRemove:function(e,t){const n=[];for(let r=e.length-1;r>=0;r--)t(e[r])&&n.push(e.splice(r,1)[0]);return n},merge:function(e,t){const n=Object.keys(t);for(const r of n)Array.isArray(t[r])&&Array.isArray(e[r])&&q(e[r],t[r])},empty:function(e){return e.splice(0,e.length),e},pushToBucket:function(e,t,n){e[t]||(e[t]=[]),e[t].push(n)},unshiftAndLimit:function(e,t,n){for(e.unshift(t);e.length>n;)e.pop()},atRolling:function(e,t){let n=t%e.length;return n<0&&(n+=e.length),e[n]},group:ft,createOscillator:function(e){let t=0;return{next:()=>e[t++%e.length]}},organiseWithLimits:function(e,t,n,r,o){const i={};for(const s of Object.keys(t))i[s]=[];i[r]=[],o&&(e=e.sort(o));for(const s of e){const e=s[n],o=t[e]?e:r;i[o].length>=t[o]?i[r].push(s):i[o].push(s)}return i},tickPlaybook:function(e){if(0===e.length)return null;const t=e[0];return t.ttlMax?--t.ttl<=0&&e.shift():t.ttlMax=t.ttl,{progress:(t.ttlMax-t.ttl)/t.ttlMax,data:t.data}},getArgument:Jt,getBooleanArgument:function(e,t,n,r){const o=e.some((e=>e.endsWith("-"+t))),i=Jt(e,t,n,r);if(!i&&o)return!0;if(!i&&!o)return null;if(["true","1","yes","y","on"].includes(i.toLowerCase()))return!0;if(["false","0","no","n","off"].includes(i.toLowerCase()))return!1;throw Error(`Invalid boolean argument ${t}: ${i}`)},getNumberArgument:function(e,t,n,r){const o=Jt(e,t,n,r);if(!o)return null;try{return rt(o)}catch{throw new Error(`Invalid number argument ${t}: ${o}`)}},requireStringArgument:Kt,requireNumberArgument:function(e,t,n,r){const o=Kt(e,t,n,r);try{return rt(o)}catch{throw new Error(`Invalid argument ${t}: ${o}`)}},bringToFront:function(e,t){const n=[...e];return Xt(n,t),n},bringToFrontInPlace:Xt,findInstance:function(e,t){const n=e.find((e=>e instanceof t));return dt.of(n)},filterInstances:function(e,t){return e.filter((e=>e instanceof t))},interleave:function(e,t){const n=[],r=Math.max(e.length,t.length);for(let o=0;o<r;o++)e[o]&&n.push(e[o]),t[o]&&n.push(t[o]);return n},toggle:function(e,t){return e.includes(t)?e.filter((e=>e!==t)):[...e,t]},createHierarchy:function(e,t,n,r,o=!1){const i=new Map,s=[];e.forEach((e=>{const n=new pt(e);i.set(e[t],n)})),e.forEach((e=>{const r=i.get(e[t]);if(!r)return;const o=e[n];if(o){const e=i.get(o);e&&e.children.push(r)}else s.push(r)}));const a=e=>{e.children.sort(((e,t)=>{const n=e.value[r],i=t.value[r];return o?i-n:n-i})),e.children.forEach(a)};return s.forEach(a),s},multicall:function(e){return()=>e.forEach((e=>e()))},maxBy:function(e,t){return e.reduce(((e,n)=>t(e)>t(n)?e:n))},minBy:function(e,t){return e.reduce(((e,n)=>t(e)<t(n)?e:n))},allIndexOf:function(e,t){const n=[];return e.forEach(((e,r)=>{t(e)&&n.push(r)})),n}},t.iQ={sleepMillis:o,forever:async function(e,t,n){for(;;){try{await e()}catch(r){n&&n("Error in forever",r)}await o(t)}},scheduleMany:function(e,t){for(let n=0;n<e.length;n++){const r=e[n],o=t[n],i=Math.max(0,o.getTime()-Date.now());setTimeout(r,i)}},waitFor:async function(e,t){let n=t.requiredConsecutivePasses||1,r=0;for(let i=0;i<t.attempts;i++){try{if(await e()){if(r++,r>=n)return}else r=0}catch{r=0}i<t.attempts-1&&await o(t.waitMillis)}throw Error("Timed out waiting for predicate")},expandError:function(e,t){if(B(e))return e;const n=Object.keys(e);e.message&&!n.includes("message")&&n.push("message");const r=n.map((t=>`${t}: ${e[t]}`)).join("; ");return t&&e.stack?r+"\n"+e.stack:r},runAndSetInterval:function(e,t){e();const n=setInterval((()=>{e()}),t);return()=>clearInterval(n)},whereAmI:function(){const e=globalThis.process;return e?!0===e.browser?"browser":"node":"browser"},withRetries:async function(e,t,n,r,i,s){let a=null;for(let u=0;u<=t;u++)try{return await e()}catch(c){if(a=c,u===t)break;const e=n+u/(t-1)*(r-n);i&&i("Error in withRetries, retrying",{attempt:u+1,allowedFailures:t,delayMillis:e,error:c}),s&&s(),await o(e)}throw a}},t.FQ={make:rt,sum:function(e){return e.reduce(((e,t)=>e+t),0)},average:function(e){return e.reduce(((e,t)=>e+t),0)/e.length},median:function(e){const t=[...e].sort(((e,t)=>e-t)),n=Math.floor(t.length/2);return t.length%2==0?(t[n]+t[n-1])/2:t[n]},getDistanceFromMidpoint:function(e,t){return e-(t-1)/2},clamp:ot,range:H,interpolate:function(e,t,n){return e+(t-e)*n},createSequence:function(){let e=0;return{next:()=>e++}},increment:function(e,t,n){const r=e+t;return r>n?n:r},decrement:function(e,t,n){const r=e-t;return r<n?n:r},format:function(e,t){const n=t?.longForm??!1,r=t?.unit?` ${t.unit}`:"",o=n?tt:nt,i=t?.precision??1;if(e<et[0])return`${e}${r}`;for(let s=0;s<et.length-1;s++)if(e<et[s+1])return`${(e/et[s]).toFixed(i)}${n?" ":""}${o[s]}${r}`;return`${(e/et[et.length-1]).toFixed(i)}${n?" ":""}${o[et.length-1]}${r}`},fromDecimals:function(e,t,n){let r=e.length-t;if(r<=0)return"0."+"0".repeat(-r)+e+(n?" "+n:"");let o=e.substring(0,r);return""===o&&(o="0"),o+"."+e.substring(r)+(n?" "+n:"")},makeStorage:function(e,t=1024){const n=parseFloat(e);if(isNaN(n))throw Error("makeStorage got NaN for input");const r=e.replace(/^-?[0-9.]+/,"").trim().toLowerCase(),o=""===r?0:qe[r];if(null==o)throw Error(`Unknown unit: "${r}"`);return Math.ceil(n*t**o)},asMegabytes:function(e){return e/1024/1024},convertBytes:function(e,t=1024){return e>=t*t*t*t?(e/t/t/t/t).toFixed(3)+" TB":e>=t*t*t?(e/t/t/t).toFixed(3)+" GB":e>=t*t?(e/t/t).toFixed(3)+" MB":e>=t?(e/t).toFixed(3)+" KB":e+" B"},hexToRgb:function(e){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e.toLowerCase());if(!t)throw new Error("Invalid hex color: "+e);return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)]},rgbToHex:function(e){return"#"+e.map((e=>e.toString(16).padStart(2,"0"))).join("")},haversineDistanceToMeters:function(e,t,n,r){const o=e*Math.PI/180,i=n*Math.PI/180,s=(n-e)*Math.PI/180,a=(r-t)*Math.PI/180,c=Math.sin(s/2)*Math.sin(s/2)+Math.cos(o)*Math.cos(i)*Math.sin(a/2)*Math.sin(a/2);return 2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c))*6371e3},roundToNearest:m,formatDistance:function(e){return e>1e3?(e/1e3).toFixed(0)+" km":e>=500?m(e,100)+" m":e>=100?m(e,50)+" m":m(e,10)+" m"},triangularNumber:function(e){return e*(e+1)/2},searchFloat:function(e){const t=e.match(/-?\d+(\.\d+)?/);if(!t)throw Error("No float found in "+e);return parseFloat(t[0])},binomialSample:function(e,t,n=Math.random){const r=e*t,o=Math.sqrt(e*t*(1-t)),i=(n()+n()+n()+n()+n()+n()-3)*Math.SQRT2,s=Math.round(r+o*i);return Math.max(0,Math.min(e,s))},toSignificantDigits:function(e,t){if(!e.includes("."))return e;if(0===parseFloat(e))return"0";const[n,r]=e.split("."),o=n.replace("-",""),i=o.length;if(i>=t)return n;if("0"!==o){const e=t-i,o=r.slice(0,e);return/[1-9]/.test(o)?`${n}.${o.replace(/0+$/,"")}`:n}const s=t+(r.match(/^0*/)?.[0].length??0);return`${n}.${r.slice(0,s)}`}},t.AO={getTimestamp:function(e,t){const n=new Date(t?.now||Date.now()),r=t?.labels||Pe,o=T(e)?e:new Date(e);if(Ne(n)===Ne(o))return r.today(o.getUTCHours(),o.getUTCMinutes(),o.getUTCHours()>12);if(Ne(n)-Ne(o)==1)return r.yesterday();const i=je(o);return Ne(n)-Ne(o)<7?r[i.day]():r.weeks(Math.round((n.getTime()-o.getTime())/6048e5))},getTimeDelta:Fe,secondsToHumanTime:function(e,t=Ce){return Fe(0,{now:1e3*e,labels:t})},countCycles:function(e,t,n){const r=(n?.now??Date.now())-e;return{cycles:Math.floor(r/t),remaining:t/(n?.precision??1)-Math.ceil(r%t/(n?.precision??1))}},isoDate:function(e){return(e||new Date).toISOString().slice(0,10)},throttle:function(e,t){return(!Ge[e]||Date.now()>Ge[e])&&(Ge[e]=Date.now()+t,!0)},timeSince:function(e,t,n){return t=T(t)?t.getTime():t,((n=n?T(n)?n.getTime():n:Date.now())-t)/Ue[e]},dateTimeSlug:function(e){return(e||new Date).toISOString().slice(0,19).replace(/T|:/g,"-")},unixTimestamp:function(e){return Math.ceil((e||Date.now())/1e3)},fromUtcString:function(e){const t=new Date(e);return new Date(t.getTime()-6e4*t.getTimezoneOffset())},fromMillis:function(e){return new Date(e)},getProgress:function(e,t,n,r){r||(r=Date.now());const o=r-e,i=o/t,s=i*n;return{deltaMs:o,progress:t/n,baseTimeMs:i,totalTimeMs:s,remainingTimeMs:s-o}},humanizeTime:De,humanizeProgress:function(e){return`[${Math.floor(100*e.progress)}%] ${De(e.deltaMs)} out of ${De(e.totalTimeMs)} (${De(e.remainingTimeMs)} left) [${Math.round(e.baseTimeMs)} ms each]`},createTimeDigits:Ve,mapDayNumber:Le,getDayInfoFromDate:je,getDayInfoFromDateTimeString:function(e){return je(new Date(e))},seconds:function(e){return 1e3*e},minutes:function(e){return 6e4*e},hours:function(e){return 36e5*e},days:function(e){return 864e5*e},make:function(e){const t=parseFloat(e);if(isNaN(t))throw Error("makeDate got NaN for input");const n=e.replace(/^-?[0-9.]+/,"").trim().toLowerCase(),r=""===n?1:Ze[n];if(!r)throw Error(`Unknown unit: "${n}"`);return Math.ceil(t*r)},normalizeTime:function(e){let[t,n]=e.split(":");E(parseInt(t,10))||(t="0"),E(parseInt(n,10))||(n="0");let r=ot(C(t),0,23),o=ot(C(n),0,59);return`${Ve(r)}:${Ve(o)}`},absoluteDays:Ne},t.Rb={safeParse:function(e){try{return JSON.parse(e)}catch{return null}},deleteDeep:function(e,t){const n=Q(t,"."),r=ee(t,".");if(!n||!r)return;const o=d(e,n);o&&delete o[r]},getDeep:d,setDeep:p,incrementDeep:function(e,t,n=1){const r=d(e,t)||0;return p(e,t,r+n),r},ensureDeep:function(e,t,n){return d(e,t)||p(e,t,n)},replaceDeep:function(e,t,n){const r=d(e,t);if(!r)throw new Error("Key '"+t+"' does not exist.");return p(e,t,n),r},getFirstDeep:function(e,t,n){for(const r of t){const t=d(e,r);if(t)return t}if(n){const t=Object.values(e);if(t.length)return t[0]}return null},deepMergeInPlace:j,deepMerge2:function(e,t){const n={};return j(n,e),j(n,t),n},deepMerge3:function(e,t,n){const r={};return j(r,e),j(r,t),j(r,n),r},mapAllAsync:async function(e,t){const n=[];for(const r of e)n.push(await t(r));return n},cloneWithJson:function(e){return JSON.parse(JSON.stringify(e))},sortObject:Je,sortArray:Ke,sortAny:Xe,deepEquals:Ye,deepEqualsEvery:function(...e){for(let t=1;t<e.length;t++)if(!Ye(e[t-1],e[t]))return!1;return!0},runOn:function(e,t){return t(e),e},ifPresent:function(e,t){e&&t(e)},zip:Z,zipSum:function(e){return Z(e,((e,t)=>e+t))},removeEmptyArrays:function(e){for(const t of Object.keys(e))(w(e[t])||Array.isArray(e[t])&&e[t].every((e=>null==e)))&&delete e[t];return e},removeEmptyValues:function(e){for(const t of Object.entries(e))(null===t[1]||void 0===t[1]||B(t[1])&&R(t[1]))&&delete e[t[0]];return e},flatten:function(e,t=!1,n){return st({},e,n||"",!1,t)},unflatten:function e(t){if(!g(t))return t;const n=Array.isArray(t)?[]:{};for(const[r,o]of Object.entries(t))Array.isArray(o)?p(n,r,o.map((t=>e(t)))):p(n,r,o);return n},match:function(e,t,n){return t[e]?t[e]:n},sort:lt,map:function(e,t){const n={};for(const r of Object.entries(e))n[r[0]]=t(r[1]);return n},mapIterable:function(e,t){const n=[];let r=0;for(const o of e)n.push(t(o,r++));return n},filterKeys:function(e,t){const n={};for(const[r,o]of Object.entries(e))t(r)&&(n[r]=o);return n},filterValues:function(e,t){const n={};for(const[r,o]of Object.entries(e))t(o)&&(n[r]=o);return n},rethrow:async function(e,t){try{return await e()}catch{throw t}},setSomeOnObject:function(e,t,n){null!=n&&(e[t]=n)},setSomeDeep:function(e,t,n,r){const o=d(n,r);null!=o&&p(e,t,o)},flip:function(e){const t={};for(const[n,r]of Object.entries(e))t[r]=n;return t},getAllPermutations:function(e){const t=Object.keys(e),n=t.map((t=>e[t].length)),r=n.reduce(((e,t)=>e*t));let o=1;const i=[1];for(let a=0;a<n.length-1;a++)o*=n[a],i.push(o);const s=[];for(let a=0;a<r;a++){const n={};for(let r=0;r<t.length;r++){const o=e[t[r]],s=Math.floor(a/i[r])%o.length;n[t[r]]=o[s]}s.push(n)}return s},countTruthyValues:function(e){return Object.values(e).filter((e=>e)).length},transformToArray:function(e){const t=[],n=Object.keys(e),r=e[n[0]].length;for(let o=0;o<r;o++){const r={};for(const t of n)r[t]=e[t][o];t.push(r)}return t},setMulti:function(e,t,n){for(const r of e)r[t]=n},incrementMulti:function(e,t,n=1){for(const r of e)r[t]+=n},createBidirectionalMap:function(){return{map:new Map,keys:[]}},createTemporalBidirectionalMap:function(){return{map:new Map,keys:[]}},pushToBidirectionalMap:ht,unshiftToBidirectionalMap:function(e,t,n,r=100){if(e.map.has(t)){const n=e.keys.indexOf(t);e.keys.splice(n,1)}if(e.map.set(t,n),e.keys.unshift(t),e.keys.length>r){const t=e.keys.shift();t&&e.map.delete(t)}},addToTemporalBidirectionalMap:function(e,t,n,r,o=100){ht(e,t,{validUntil:Date.now()+r,data:n},o)},getFromTemporalBidirectionalMap:function(e,t){const n=e.map.get(t);return n&&n.validUntil>Date.now()?n.data:null},createStatefulToggle:function(e){let t;return n=>{const r=n===e&&t!==e;return t=n,r}},diffKeys:function(e,t){const n=Object.keys(e),r=Object.keys(t);return{uniqueToA:n.filter((e=>!r.includes(e))),uniqueToB:r.filter((e=>!n.includes(e)))}},pickRandomKey:Qe,mapRandomKey:function(e,t){const n=Qe(e);return e[n]=t(e[n]),n},fromObjectString:function(e){return e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=e.replace(/\r\n/g,"\n")).replace(/(\w+)\((.+)\)/g,((e,t,n)=>`${t}(${n.replaceAll(",","&comma;")})`))).replace(/(,)(\s+})/g,"$2")).replace(/\.\.\..+?,/g,"")).replace(/({\s+)([a-zA-Z]\w+),/g,"$1$2: '$2',")).replace(/(,\s+)([a-zA-Z]\w+),/g,"$1$2: '$2',")).replace(/:(.+)\?(.+):/g,((e,t,n)=>`: (${t.trim()} && ${n.trim()}) ||`))).replace(/([a-zA-Z0-9]+)( ?: ?{)/g,'"$1"$2')).replace(/([a-zA-Z0-9]+) ?: ?(.+?)(,|\n|})/g,((e,t,n,r)=>`"${t}":"${n.trim()}"${r}`))).replace(/("'|'")/g,'"')).replaceAll("&comma;",","),JSON.parse(e)},toQueryString:_e,parseQueryString:function(e){const t={},n=e.split("&");for(const r of n){const[e,n]=r.split("=");e&&n&&(t[e]=decodeURIComponent(n))}return t},hasKey:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},selectMax:function(e,t){let n=null,r=-1/0;for(const[o,i]of Object.entries(e)){const e=t(i);e>r&&(r=e,n=o)}return n?[n,e[n]]:null},reposition:function(e,t,n,r){const o=e.find((e=>e[t]===n)),i=e.find((e=>e[t]===n+r));o&&i?(o[t]=n+r,i[t]=n):o&&(o[t]=n+r),e.sort(((e,n)=>P(e[t])-P(n[t]))),e.forEach(((e,n)=>e[t]=n+1))},unwrapSingleKey:function(e){const t=Object.keys(e);if(1===t.length)return e[t[0]];throw new Error("Expected object to have a single key")},parseKeyValues:function(e,t=":"){return Object.fromEntries(e.map((e=>te(e,t))).map((e=>e[0]&&e[1]?[ie(e[0]),ie(e[1])]:null)).filter((e=>e)))},errorMatches:function(e,t){if(!e)return!1;const n=e.message;return"string"==typeof n&&n.includes(t)}},t.Or={isFunction:v,isObject:g,isStrictlyObject:y,isEmptyArray:w,isEmptyObject:function(e){return y(e)&&0===Object.keys(e).length},isUndefined:b,isString:B,isNumber:E,isBoolean:x,isDate:T,isBlank:R,isId:z,isIntegerString:A,isHexString:k,isUrl:G,isBigint:U,isNullable:function(e,t){return null==t||e(t)},asString:D,asHexString:function(e,t){if(!k(e))throw new TypeError(`Expected hex string${t?.name?` for ${t.name}`:""}, got: `+e);if(t?.strictPrefix&&!e.startsWith("0x")&&!e.startsWith("0X"))throw new TypeError(`Expected hex string with 0x prefix${t?.name?` for ${t.name}`:""}, got: `+e);const n=e.replace(/^0x/i,"");if(n.length%2!=0&&!t?.uneven)throw RangeError(`Expected even number of hex digits${t?.name?` for ${t.name}`:""}; got: `+e);if(t&&t.byteLength&&n.length!==2*t.byteLength)throw RangeError(`Expected hex string${t?.name?` for ${t.name}`:""} of byte length ${t.byteLength}; got: `+n);return`0x${n}`},asSafeString:function(e,t){if(!D(e,t).split("").every((e=>"_"===e||le(e))))throw new TypeError(`Expected safe string${t?.name?` for ${t.name}`:""}, got: `+e);return e},asIntegerString:function(e,t){if(!A(e))throw new TypeError(`Expected integer string${t?.name?` for ${t.name}`:""}, got: `+e);const n=BigInt(e);if(t&&(t.min&&n<t.min||t.max&&n>t.max))throw RangeError(`Expected integer string${t?.name?` for ${t.name}`:""} in range: ${t.min??"-inf"}..${t.max??"inf"}; got: `+n);return e},asNumber:P,asFunction:function(e,t){if(!v(e))throw new TypeError(`Expected function${t?.name?` for ${t.name}`:""}, got: `+e);return e},asInteger:C,asBoolean:function(e,t){if("true"===e)return!0;if("false"===e)return!1;if(!x(e))throw new TypeError(`Expected boolean${t?.name?` for ${t.name}`:""}, got: `+e);return e},asDate:function(e,t){if(!T(e))throw new TypeError(`Expected date${t?.name?` for ${t.name}`:""}, got: `+e);return e},asNullableString:function(e){return R(e)?null:e},asEmptiableString:function(e,t){if(!B(e))throw new TypeError(`Expected string${t?.name?` for ${t.name}`:""}, got: `+e);return e},asId:function(e,t){if(z(e))return e;const n=parseInt(e,10);if(!z(n))throw new TypeError(`Expected id${t?.name?` for ${t.name}`:""}, got: `+e);return n},asTime:function(e,t){if(!B(e))throw new TypeError(`Expected time${t?.name?` for ${t.name}`:""}, got: `+e);const n=e.split(":");if(2!==n.length)throw new TypeError(`Expected time${t?.name?` for ${t.name}`:""}, got: `+e);const r=parseInt(n[0],10),o=parseInt(n[1],10);if(!E(r)||!E(o)||r<0||r>23||o<0||o>59)throw new TypeError(`Expected time, got${t?.name?` for ${t.name}`:""}: `+e);return`${String(r).padStart(2,"0")}:${String(o).padStart(2,"0")}`},asArray:function(e,t){if(!Array.isArray(e))throw new TypeError(`Expected array${t?.name?` for ${t.name}`:""}, got: `+e);return e},asObject:F,asNullableObject:function(e,t){return null===e?null:F(e,t)},asStringMap:function(e,t){const n=F(e,t);for(const r of Object.keys(n))if(!B(n[r]))throw new TypeError(`Expected string map${t?.name?` for ${t.name}`:""}, got: `+e);return n},asNumericDictionary:function(e,t){const n=F(e),r=Object.keys(n),o=Object.values(n);if(!r.every(B)||!o.every(E))throw new TypeError(`Expected numeric dictionary${t?.name?` for ${t.name}`:""}, got: `+e);return n},asUrl:function(e,t){if(!G(e))throw new TypeError(`Expected url${t?.name?` for ${t.name}`:""}, got: `+e);return e},asBigint:M,asEmptiable:function(e,t){return""===t?void 0:e(t)},asNullable:function(e,t){return null==t?null:e(t)},asOptional:function(e,t){return null==t?void 0:e(t)},enforceObjectShape:L,enforceArrayShape:function(e,t){return e.every((e=>L(e,t)))},isPng:yt,isJpg:wt,isWebp:bt,isImage:function(e){return yt(e)||wt(e)||bt(e)}},t.DH={tokenizeByCount:function(e,t){return ut(e,Math.ceil(e.length/t))},tokenizeByLength:ut,searchHex:function(e,t){const n=new RegExp(`[0-9a-f]{${t}}`,"i"),r=e.match(n);return r?r[0]:null},searchSubstring:function(e,t,n=O){const r=ne(e,n);for(const o of r)if(t(o))return o;return null},randomHex:function(e,t=Math.random){let n="";for(let r=0;r<e;r++)n+=V[Math.floor(16*t())];return n},randomLetter:function(e,t=Math.random){let n="";for(let r=0;r<e;r++)n+=S[Math.floor(26*t())];return n},randomAlphanumeric:function(e,t=Math.random){let n="";for(let r=0;r<e;r++)n+=$[Math.floor(62*t())];return n},randomRichAscii:function(e,t=Math.random){let n="";for(let r=0;r<e;r++)n+=I[Math.floor(89*t())];return n},randomUnicode:function(e,t=Math.random){let n="";for(let r=0;r<e;r++)n+=_[Math.floor(t()*_.length)];return n},includesAny:function(e,t){return t.some((t=>e.includes(t)))},slugify:W,normalForm:function(e){return W(e).replaceAll("-","")},enumify:function(e){return W(e).replace(/-/g,"_").toUpperCase()},escapeHtml:function(e){return e.replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")},decodeHtmlEntities:function(e){let t=e.replace(/&#(\d+);/g,((e,t)=>String.fromCharCode(t))).replace(/&#x(\d+);/g,((e,t)=>String.fromCharCode(parseInt(t,16))));for(const[n,r]of Object.entries(K))t=t.replaceAll(n,r);return t},after:Y,afterLast:ee,before:X,beforeLast:Q,betweenWide:function(e,t,n){const r=Q(e,n);return r?Y(r,t):null},betweenNarrow:function(e,t,n){const r=Y(e,t);return r?X(r,n):null},getPreLine:function(e){return e.replace(/ +/g," ").replace(/^ /gm,"")},containsWord:Oe,containsWords:function(e,t,n){return"any"===n?t.some((t=>Oe(e,t))):t.every((t=>Oe(e,t)))},joinUrl:We,getFuzzyMatchScore:J,sortByFuzzyScore:function(e,t){return e.filter((e=>J(e,t))).sort(((e,n)=>J(n,t)-J(e,t)))},splitOnce:te,splitAll:ne,randomize:function(e,t=Math.random){return e.replace(/\{(.+?)\}/g,((e,n)=>l(n.split("|"),t)))},expand:function e(t){const n=t.match(/\{(.+?)\}/);if(!n||!n.index)return[t];const r=n[1].split(","),o=t.slice(0,n.index),i=t.slice(n.index+n[0].length);let s=[];for(const a of r){const t=e(o+a+i);s=s.concat(t)}return s},shrinkTrim:ie,capitalize:se,decapitalize:ae,csvEscape:function(e){return e.match(/"|,/)?`"${e.replace(/"/g,'""')}"`:e},parseCsv:function(e,t=",",n='"'){const r=[];let o="",i=!1;const s=e.split("");for(const a of s)a!==t||i?a!==n||(o||i)&&!i?o+=a:i=!i:(r.push(o),o="");return r.push(o),r},surroundInOut:function(e,t){return t+e.split("").join(t)+t},getExtension:re,getBasename:oe,normalizeEmail:function(e){let[t,n]=e.split("@");t=ie(t.replaceAll(".","").toLowerCase()).replaceAll(" ","");const[r]=t.split("+");if(!r||!n||-1===n.indexOf(".")||n.indexOf(".")===n.length-1)throw new Error("Invalid email");return n=ie(n.toLowerCase()).replaceAll(" ",""),`${r}@${n}`},normalizeFilename:function(e){const t=oe(e),n=re(e);return n?`${t}.${n}`:t},parseFilename:function(e){const t=oe(e),n=re(e);return{basename:t,extension:n,filename:n?`${t}.${n}`:t}},camelToTitle:function(e){return se(e.replace(/([A-Z])/g," $1"))},slugToTitle:function(e){return e.split("-").map(se).join(" ")},slugToCamel:function(e){return ae(e.split("-").map(se).join(""))},joinHumanly:function(e,t=", ",n=" and "){return e&&e.length?1===e.length?e[0]:2===e.length?`${e[0]}${n}${e[1]}`:`${e.slice(0,e.length-1).join(t)}${n}${e[e.length-1]}`:""},findWeightedPair:ve,extractBlock:Be,extractAllBlocks:function(e,t){const n=[];let r=t.wordBoundary?ge(e,[`${t.opening} `,`${t.opening}\n`],t.start||0):e.indexOf(t.opening,t.start||0);for(;;){if(-1===r)return n;const o=Be(e,{...t,start:r});if(!o)return n;n.push(o),r=t.wordBoundary?ge(e,[`${t.opening} `,`${t.opening}\n`],r+o.length):e.indexOf(t.opening,r+o.length)}},replaceBlocks:function(e,n,r){let o=0;for(;;){const i=t.DH.extractBlock(e,{...r,start:o});if(!i)return e;const s=n(i);o=e.indexOf(i,o)+s.length,e=e.replace(i,s)}},indexOfEarliest:ge,lastIndexOfBefore:be,parseHtmlAttributes:function(e){const t={},n=e.match(/([a-z\-]+)="([^"]+)"/g);if(n)for(const r of n){const[e,n]=te(r,"=");t[e]=n.slice(1,n.length-1)}return t},readNextWord:Se,readWordsAfterAll:function(e,t,n=[]){const r=me(e,t),o=[];for(const i of r)o.push(Se(e,i+t.length,n));return o},resolveVariables:function(e,t,n="$",r=":"){for(const o in t)e=$e(e,o,t[o],n,r);return e=Ie(e)},resolveVariableWithDefaultSyntax:$e,resolveRemainingVariablesWithDefaults:Ie,isLetter:ce,isDigit:ue,isLetterOrDigit:le,isValidObjectPathCharacter:function(e){return le(e)||"."===e||"["===e||"]"===e||"_"===e},insert:function(e,t,n,r,o){return e.slice(0,t)+r+e.slice(t,t+n)+o+e.slice(t+n)},indexOfRegex:de,allIndexOf:me,lineMatches:pe,linesMatchInOrder:function(e,t,n=!0){let r=0;for(const o of t){let t=!1;for(;!t&&r<e.length;)pe(e[r],o,n)&&(t=!0),r++;if(!t)return!1}return!0},represent:function e(t,n="json",r=0){if(t&&v(t.represent)){const e=t.represent();if(B(e))return"json"===n&&0===r?JSON.stringify(e):e}if(g(t,!1)){if(r>1)return"[object Object]";if("json"===n){if(Array.isArray(t)){const n=t.map((t=>e(t,"json",r+1)));return 0===r?JSON.stringify(n):n}const n={};t.message&&(n.message=e(t.message,"json",r+1));for(const[o,i]of Object.entries(t))n[o]=e(i,"json",r+1);return 0===r?JSON.stringify(n):n}if("key-value"===n){const n=Object.keys(t);return t.message&&!n.includes("message")&&n.unshift("message"),n.map((n=>`${n}=${JSON.stringify(e(t[n],"json",r+1))}`)).join(" ")}}return b(t)&&(t="undefined"),0===r?JSON.stringify(t):t},resolveMarkdownLinks:function(e,t){let n=e.indexOf("](");for(;-1!==n;){const r=be(e,"[",n),o=e.indexOf(")",n);if(-1!==r&&-1!==o){const[n,i]=e.slice(r+1,o).split("]("),s=t(n,i);e=e.slice(0,r)+s+e.slice(o+1)}n=e.indexOf("](",n+1)}return e},buildUrl:function(e,t,n){return We([e,t])+_e(n||{})},isChinese:function(e){return/^[\u4E00-\u9FA5]+$/.test(e)},replaceBetweenStrings:function(e,t,n,r,o=!0){const i=e.indexOf(t),s=e.indexOf(n,i+t.length);if(-1===i||-1===s)throw Error("Start or end not found");return o?e.substring(0,i+t.length)+r+e.substring(s):e.substring(0,i)+r+e.substring(s+n.length)},describeMarkdown:function(e){let t="p";return e.startsWith("#")?(t="h1",e=e.slice(1).trim()):e.startsWith("-")&&(t="li",e=e.slice(1).trim()),{type:t,isCapitalized:e[0]===e[0].toUpperCase(),hasPunctuation:/[.?!]$/.test(e),endsWithColon:/:$/.test(e)}},isBalanced:function(e,t="(",n=")"){let r=0,o=0;for(;o<e.length;)if(e.startsWith(t,o)?(r++,o+=t.length):e.startsWith(n,o)?(r--,o+=n.length):o++,r<0)return!1;return t===n?r%2==0:0===r},textToFormat:function(e){let t=(e=e.normalize("NFD").replace(/[\u0300-\u036f]/g,"")).length;for(;(e=e.replace(/(\w+)[\s,']+\w+/g,"$1")).length!==t;)t=e.length;return e=(e=(e=e.replaceAll(/[A-Z][a-zA-Z0-9]*/g,"A")).replaceAll(/[a-z][a-zA-Z0-9]*/g,"a")).replaceAll(/[\u4E00-\u9FA5]+/g,"Z")},splitFormatting:function(e,t){const n=[];let r=0;for(;r<e.length;){const o=e.indexOf(t,r);if(-1===o){n.push({string:e.slice(r),symbol:null});break}const i=e.indexOf(t,o+t.length);if(o>r&&-1!==i&&n.push({string:e.slice(r,o),symbol:null}),-1===i){n.push({string:e.slice(r),symbol:null});break}n.push({string:e.slice(o+t.length,i),symbol:t}),r=i+t.length}return n},splitHashtags:function(e){const t=[];let n=0;for(;n<e.length;){const r=we(e,n);if(-1===r){t.push({string:e.slice(n),symbol:null});break}const o=ye(e,r+1);if(-1===o){t.push({string:e.slice(n,r),symbol:null}),t.push({string:e.slice(r+1),symbol:"#"});break}r>n&&t.push({string:e.slice(n,r),symbol:null}),t.push({string:e.slice(r+1,o),symbol:"#"}),n=o}return t},splitUrls:function(e){const t=[];let n=0;for(;n<e.length;){const r=ge(e,["http://","https://"],n);if(-1===r){t.push({string:e.slice(n),symbol:null});break}const o=ge(e,[" ","\n"],r);if(-1===o){r>n&&t.push({string:e.slice(n,r),symbol:null}),t.push({string:e.slice(r),symbol:"http"});break}r>n&&t.push({string:e.slice(n,r),symbol:null}),t.push({string:e.slice(r,o),symbol:"http"}),n=o}return t},route:function(e,t){const n=e.split("/").filter((e=>e)),r=t.split("/").filter((e=>e));if(n.length!==r.length)return null;const o={};for(let i=0;i<n.length;i++){const e=n[i];if(e.startsWith(":"))o[e.slice(1)]=r[i];else if(e!==r[i])return null}return o},explodeReplace:ze,generateVariants:function(e,n,r,o=Math.random){const i=t.DO.shuffle(n.map((e=>({variants:t.DO.shuffle(e.variants.map((e=>e)),o),avoid:e.avoid}))),o),s=[];for(const t of i){const n=t.variants.filter((e=>e!==t.avoid)),o=n.find((t=>e.includes(t)));if(o&&(q(s,ze(e,o,n)),s.length>=r))break}if(s.length<r)for(const t of i){const n=t.variants.find((t=>e.includes(t)));if(n&&(q(s,ze(e,n,t.variants)),s.length>=r))break}return s.slice(0,r)},replaceWord:function(e,t,n,r=!1){const o=new RegExp(r?`(?<=\\s|^)${t}(?=\\s|$)`:`\\b${t}\\b`,"g");return e.replace(o,n)},replacePascalCaseWords:function(e,t){return e.replace(/\b[A-Z][a-zA-Z0-9]*\b/g,(e=>e.toUpperCase()===e?e:t(e)))},stripHtml:function(e){return e.replace(/<[^>]*>/g,"")},breakLine:Ae,measureTextWidth:function(e,t={}){return[...e].reduce(((e,n)=>e+(t[n]||1)),0)},toLines:function(e,t,n={}){const r=[];let o="",i=0;for(let s=0;s<e.length;s++){const a=e[s];if(o+=a,i+=n[a]||1,i>t){const{line:e,rest:t}=Ae(o);r.push(e),o=t,i=t.split("").map((e=>n[e]||1)).reduce(((e,t)=>e+t),0)}}return o&&r.push(o),r},levenshteinDistance:function(e,t){const n=[];for(let r=0;r<=e.length;r++)n[r]=[r];for(let r=0;r<=t.length;r++)n[0][r]=r;for(let r=1;r<=e.length;r++)for(let o=1;o<=t.length;o++){const i=e[r-1]===t[o-1]?0:1;n[r][o]=Math.min(n[r-1][o]+1,n[r][o-1]+1,n[r-1][o-1]+i)}return n[e.length][t.length]},findCommonPrefix:ke,findCommonDirectory:function(e){const t=ke(e),n=t.lastIndexOf("/");return-1===n?"":t.slice(0,n+1)}}},878(e,t,n){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0,o=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(r++,"%c"===e&&(o=r))})),t.splice(o,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(n){}},t.load=function(){let e;try{e=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch(n){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=n(945)(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}},945(e,t,n){e.exports=function(e){function t(e){let n,o,i,s=null;function a(...e){if(!a.enabled)return;const r=a,o=Number(new Date),i=o-(n||o);r.diff=i,r.prev=n,r.curr=o,n=o,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,o)=>{if("%%"===n)return"%";s++;const i=t.formatters[o];if("function"==typeof i){const t=e[s];n=i.call(r,t),e.splice(s,1),s--}return n})),t.formatArgs.call(r,e);(r.log||t.log).apply(r,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=r,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(o!==t.namespaces&&(o=t.namespaces,i=t.enabled(e)),i),set:e=>{s=e}}),"function"==typeof t.init&&t.init(a),a}function r(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function o(e,t){let n=0,r=0,o=-1,i=0;for(;n<e.length;)if(r<t.length&&(t[r]===e[n]||"*"===t[r]))"*"===t[r]?(o=r,i=n,r++):(n++,r++);else{if(-1===o)return!1;r=o+1,i++,n=i}for(;r<t.length&&"*"===t[r];)r++;return r===t.length}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names,...t.skips.map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const r of n)"-"===r[0]?t.skips.push(r.slice(1)):t.names.push(r)},t.enabled=function(e){for(const n of t.skips)if(o(e,n))return!1;for(const n of t.names)if(o(e,n))return!0;return!1},t.humanize=n(192),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((n=>{t[n]=e[n]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return t.colors[Math.abs(n)%t.colors.length]},t.enable(t.load()),t}},192(e){var t=1e3,n=60*t,r=60*n,o=24*r,i=7*o,s=365.25*o;function a(e,t,n,r){var o=t>=1.5*n;return Math.round(e/n)+" "+r+(o?"s":"")}e.exports=function(e,c){c=c||{};var u=typeof e;if("string"===u&&e.length>0)return function(e){if((e=String(e)).length>100)return;var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!a)return;var c=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*s;case"weeks":case"week":case"w":return c*i;case"days":case"day":case"d":return c*o;case"hours":case"hour":case"hrs":case"hr":case"h":return c*r;case"minutes":case"minute":case"mins":case"min":case"m":return c*n;case"seconds":case"second":case"secs":case"sec":case"s":return c*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(e);if("number"===u&&isFinite(e))return c.long?function(e){var i=Math.abs(e);if(i>=o)return a(e,i,o,"day");if(i>=r)return a(e,i,r,"hour");if(i>=n)return a(e,i,n,"minute");if(i>=t)return a(e,i,t,"second");return e+" ms"}(e):function(e){var i=Math.abs(e);if(i>=o)return Math.round(e/o)+"d";if(i>=r)return Math.round(e/r)+"h";if(i>=n)return Math.round(e/n)+"m";if(i>=t)return Math.round(e/t)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},963(e,t,n){"use strict";const r=n(527),{MAX_LENGTH:o,MAX_SAFE_INTEGER:i}=n(197),{safeRe:s,t:a}=n(423),c=n(676),{compareIdentifiers:u}=n(956);class l{constructor(e,t){if(t=c(t),e instanceof l){if(e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease)return e;e=e.version}else if("string"!=typeof e)throw new TypeError(`Invalid version. Must be a string. Got type "${typeof e}".`);if(e.length>o)throw new TypeError(`version is longer than ${o} characters`);r("SemVer",e,t),this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease;const n=e.trim().match(t.loose?s[a.LOOSE]:s[a.FULL]);if(!n)throw new TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+n[1],this.minor=+n[2],this.patch=+n[3],this.major>i||this.major<0)throw new TypeError("Invalid major version");if(this.minor>i||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>i||this.patch<0)throw new TypeError("Invalid patch version");n[4]?this.prerelease=n[4].split(".").map((e=>{if(/^[0-9]+$/.test(e)){const t=+e;if(t>=0&&t<i)return t}return e})):this.prerelease=[],this.build=n[5]?n[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(e){if(r("SemVer.compare",this.version,this.options,e),!(e instanceof l)){if("string"==typeof e&&e===this.version)return 0;e=new l(e,this.options)}return e.version===this.version?0:this.compareMain(e)||this.comparePre(e)}compareMain(e){return e instanceof l||(e=new l(e,this.options)),this.major<e.major?-1:this.major>e.major?1:this.minor<e.minor?-1:this.minor>e.minor?1:this.patch<e.patch?-1:this.patch>e.patch?1:0}comparePre(e){if(e instanceof l||(e=new l(e,this.options)),this.prerelease.length&&!e.prerelease.length)return-1;if(!this.prerelease.length&&e.prerelease.length)return 1;if(!this.prerelease.length&&!e.prerelease.length)return 0;let t=0;do{const n=this.prerelease[t],o=e.prerelease[t];if(r("prerelease compare",t,n,o),void 0===n&&void 0===o)return 0;if(void 0===o)return 1;if(void 0===n)return-1;if(n!==o)return u(n,o)}while(++t)}compareBuild(e){e instanceof l||(e=new l(e,this.options));let t=0;do{const n=this.build[t],o=e.build[t];if(r("build compare",t,n,o),void 0===n&&void 0===o)return 0;if(void 0===o)return 1;if(void 0===n)return-1;if(n!==o)return u(n,o)}while(++t)}inc(e,t,n){if(e.startsWith("pre")){if(!t&&!1===n)throw new Error("invalid increment argument: identifier is empty");if(t){const e=`-${t}`.match(this.options.loose?s[a.PRERELEASELOOSE]:s[a.PRERELEASE]);if(!e||e[1]!==t)throw new Error(`invalid identifier: ${t}`)}}switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",t,n);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",t,n);break;case"prepatch":this.prerelease.length=0,this.inc("patch",t,n),this.inc("pre",t,n);break;case"prerelease":0===this.prerelease.length&&this.inc("patch",t,n),this.inc("pre",t,n);break;case"release":if(0===this.prerelease.length)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":0===this.minor&&0===this.patch&&0!==this.prerelease.length||this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":0===this.patch&&0!==this.prerelease.length||this.minor++,this.patch=0,this.prerelease=[];break;case"patch":0===this.prerelease.length&&this.patch++,this.prerelease=[];break;case"pre":{const e=Number(n)?1:0;if(0===this.prerelease.length)this.prerelease=[e];else{let r=this.prerelease.length;for(;--r>=0;)"number"==typeof this.prerelease[r]&&(this.prerelease[r]++,r=-2);if(-1===r){if(t===this.prerelease.join(".")&&!1===n)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(e)}}if(t){let r=[t,e];if(!1===n&&(r=[t]),((e,t)=>{const n=t.split(".");if(n.length>e.length)return!1;for(let r=0;r<n.length;r++)if(0!==u(e[r],n[r]))return!1;return!0})(this.prerelease,t)){const e=this.prerelease[t.split(".").length];isNaN(e)&&(this.prerelease=r)}else this.prerelease=r}break}default:throw new Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}}e.exports=l},359(e,t,n){"use strict";const r=n(963);e.exports=(e,t)=>new r(e,t).major},197(e){"use strict";const t=Number.MAX_SAFE_INTEGER||9007199254740991;e.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:t,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:"2.0.0",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}},527(e){"use strict";const t="object"==typeof process&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};e.exports=t},956(e){"use strict";const t=/^[0-9]+$/,n=(e,n)=>{if("number"==typeof e&&"number"==typeof n)return e===n?0:e<n?-1:1;const r=t.test(e),o=t.test(n);return r&&o&&(e=+e,n=+n),e===n?0:r&&!o?-1:o&&!r?1:e<n?-1:1};e.exports={compareIdentifiers:n,rcompareIdentifiers:(e,t)=>n(t,e)}},676(e){"use strict";const t=Object.freeze({loose:!0}),n=Object.freeze({});e.exports=e=>e?"object"!=typeof e?t:e:n},423(e,t,n){"use strict";const{MAX_SAFE_COMPONENT_LENGTH:r,MAX_SAFE_BUILD_LENGTH:o,MAX_LENGTH:i}=n(197),s=n(527),a=(t=e.exports={}).re=[],c=t.safeRe=[],u=t.src=[],l=t.safeSrc=[],f=t.t={};let h=0;const d="[a-zA-Z0-9-]",p=[["\\s",1],["\\d",i],[d,o]],m=(e,t,n)=>{const r=(e=>{for(const[t,n]of p)e=e.split(`${t}*`).join(`${t}{0,${n}}`).split(`${t}+`).join(`${t}{1,${n}}`);return e})(t),o=h++;s(e,o,t),f[e]=o,u[o]=t,l[o]=r,a[o]=new RegExp(t,n?"g":void 0),c[o]=new RegExp(r,n?"g":void 0)};m("NUMERICIDENTIFIER","0|[1-9]\\d*"),m("NUMERICIDENTIFIERLOOSE","\\d+"),m("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${d}*`),m("MAINVERSION",`(${u[f.NUMERICIDENTIFIER]})\\.(${u[f.NUMERICIDENTIFIER]})\\.(${u[f.NUMERICIDENTIFIER]})`),m("MAINVERSIONLOOSE",`(${u[f.NUMERICIDENTIFIERLOOSE]})\\.(${u[f.NUMERICIDENTIFIERLOOSE]})\\.(${u[f.NUMERICIDENTIFIERLOOSE]})`),m("PRERELEASEIDENTIFIER",`(?:${u[f.NONNUMERICIDENTIFIER]}|${u[f.NUMERICIDENTIFIER]})`),m("PRERELEASEIDENTIFIERLOOSE",`(?:${u[f.NONNUMERICIDENTIFIER]}|${u[f.NUMERICIDENTIFIERLOOSE]})`),m("PRERELEASE",`(?:-(${u[f.PRERELEASEIDENTIFIER]}(?:\\.${u[f.PRERELEASEIDENTIFIER]})*))`),m("PRERELEASELOOSE",`(?:-?(${u[f.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${u[f.PRERELEASEIDENTIFIERLOOSE]})*))`),m("BUILDIDENTIFIER",`${d}+`),m("BUILD",`(?:\\+(${u[f.BUILDIDENTIFIER]}(?:\\.${u[f.BUILDIDENTIFIER]})*))`),m("FULLPLAIN",`v?${u[f.MAINVERSION]}${u[f.PRERELEASE]}?${u[f.BUILD]}?`),m("FULL",`^${u[f.FULLPLAIN]}$`),m("LOOSEPLAIN",`[v=\\s]*${u[f.MAINVERSIONLOOSE]}${u[f.PRERELEASELOOSE]}?${u[f.BUILD]}?`),m("LOOSE",`^${u[f.LOOSEPLAIN]}$`),m("GTLT","((?:<|>)?=?)"),m("XRANGEIDENTIFIERLOOSE",`${u[f.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),m("XRANGEIDENTIFIER",`${u[f.NUMERICIDENTIFIER]}|x|X|\\*`),m("XRANGEPLAIN",`[v=\\s]*(${u[f.XRANGEIDENTIFIER]})(?:\\.(${u[f.XRANGEIDENTIFIER]})(?:\\.(${u[f.XRANGEIDENTIFIER]})(?:${u[f.PRERELEASE]})?${u[f.BUILD]}?)?)?`),m("XRANGEPLAINLOOSE",`[v=\\s]*(${u[f.XRANGEIDENTIFIERLOOSE]})(?:\\.(${u[f.XRANGEIDENTIFIERLOOSE]})(?:\\.(${u[f.XRANGEIDENTIFIERLOOSE]})(?:${u[f.PRERELEASELOOSE]})?${u[f.BUILD]}?)?)?`),m("XRANGE",`^${u[f.GTLT]}\\s*${u[f.XRANGEPLAIN]}$`),m("XRANGELOOSE",`^${u[f.GTLT]}\\s*${u[f.XRANGEPLAINLOOSE]}$`),m("COERCEPLAIN",`(^|[^\\d])(\\d{1,${r}})(?:\\.(\\d{1,${r}}))?(?:\\.(\\d{1,${r}}))?`),m("COERCE",`${u[f.COERCEPLAIN]}(?:$|[^\\d])`),m("COERCEFULL",u[f.COERCEPLAIN]+`(?:${u[f.PRERELEASE]})?`+`(?:${u[f.BUILD]})?(?:$|[^\\d])`),m("COERCERTL",u[f.COERCE],!0),m("COERCERTLFULL",u[f.COERCEFULL],!0),m("LONETILDE","(?:~>?)"),m("TILDETRIM",`(\\s*)${u[f.LONETILDE]}\\s+`,!0),t.tildeTrimReplace="$1~",m("TILDE",`^${u[f.LONETILDE]}${u[f.XRANGEPLAIN]}$`),m("TILDELOOSE",`^${u[f.LONETILDE]}${u[f.XRANGEPLAINLOOSE]}$`),m("LONECARET","(?:\\^)"),m("CARETTRIM",`(\\s*)${u[f.LONECARET]}\\s+`,!0),t.caretTrimReplace="$1^",m("CARET",`^${u[f.LONECARET]}${u[f.XRANGEPLAIN]}$`),m("CARETLOOSE",`^${u[f.LONECARET]}${u[f.XRANGEPLAINLOOSE]}$`),m("COMPARATORLOOSE",`^${u[f.GTLT]}\\s*(${u[f.LOOSEPLAIN]})$|^$`),m("COMPARATOR",`^${u[f.GTLT]}\\s*(${u[f.FULLPLAIN]})$|^$`),m("COMPARATORTRIM",`(\\s*)${u[f.GTLT]}\\s*(${u[f.LOOSEPLAIN]}|${u[f.XRANGEPLAIN]})`,!0),t.comparatorTrimReplace="$1$2$3",m("HYPHENRANGE",`^\\s*(${u[f.XRANGEPLAIN]})\\s+-\\s+(${u[f.XRANGEPLAIN]})\\s*$`),m("HYPHENRANGELOOSE",`^\\s*(${u[f.XRANGEPLAINLOOSE]})\\s+-\\s+(${u[f.XRANGEPLAINLOOSE]})\\s*$`),m("STAR","(<|>)?=?\\s*\\*"),m("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),m("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")},497(){},61(){},320(){}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{"use strict";n.r(r),n.d(r,{BRANCHES:()=>du,BZZ:()=>iu,BatchId:()=>Pt,Bee:()=>Uh,BeeArgumentError:()=>tu,BeeError:()=>eu,BeeModes:()=>lu,BeeResponseError:()=>nu,Bytes:()=>Nt,CHUNK_SIZE:()=>pu,ChunkBuilder:()=>zn,ChunkSplitter:()=>An,DAI:()=>su,Duration:()=>ru,EthAddress:()=>Ut,FeedIndex:()=>Lt,Identifier:()=>Zt,MantarayNode:()=>Al,NULL_ADDRESS:()=>Zh,NULL_IDENTIFIER:()=>qh,NULL_OWNER:()=>Hh,NULL_STAMP:()=>Lh,NULL_TOPIC:()=>jh,PSS_TARGET_HEX_LENGTH_MAX:()=>mu,PeerAddress:()=>qt,PrivateKey:()=>en,PublicKey:()=>Jt,RedundancyLevel:()=>vu,RedundancyStrategy:()=>Bu,Reference:()=>nn,RollingFeedReader:()=>Hf,RollingFeedWriter:()=>qf,SECTION_SIZE:()=>hu,STAMPS_DEPTH_MAX:()=>yu,STAMPS_DEPTH_MIN:()=>gu,SUPPORTED_BEE_VERSION:()=>bh,SUPPORTED_BEE_VERSION_EXACT:()=>wh,SWARM_GATEWAY_URL:()=>Mh,Signature:()=>Qt,Size:()=>ou,Span:()=>rn,Stamper:()=>sr,TAGS_LIMIT_MAX:()=>bu,TAGS_LIMIT_MIN:()=>wu,Topic:()=>sn,TransactionId:()=>an,Utils:()=>e,capacityBreakpoints:()=>Eu,toBeeMode:()=>fu});var e={};n.r(e),n.d(e,{approximateOverheadForRedundancyLevel:()=>$n,convertEnvelopeToMarshaledStamp:()=>Hu,getAmountForDuration:()=>Zu,getCollectionSize:()=>Cl,getDepthForSize:()=>qu,getFolderSize:()=>Il,getRedundancyStat:()=>Pn,getRedundancyStats:()=>Nn,getStampCost:()=>Lu,getStampDuration:()=>ju,getStampEffectiveBytes:()=>nr,getStampEffectiveBytesBreakpoints:()=>rr,getStampTheoreticalBytes:()=>Kn,getStampUsage:()=>Jn,makeCollectionFromFileList:()=>Pl,makeMaxTarget:()=>Wh,mapPostageBatch:()=>Wu,unmapPostageBatch:()=>Ju});const t="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function o(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function i(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function s(e,...t){if(!o(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function a(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.createHasher");i(e.outputLen),i(e.blockLen)}function c(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function u(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function l(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function f(e,t){return e<<32-t|e>>>t}const h=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),d=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function p(e){if(s(e),h)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=d[e[n]];return t}const m=48,g=57,y=65,w=70,b=97,v=102;function B(e){return e>=m&&e<=g?e-m:e>=y&&e<=w?e-(y-10):e>=b&&e<=v?e-(b-10):void 0}function E(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(h)return Uint8Array.fromHex(e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let o=0,i=0;o<n;o++,i+=2){const t=B(e.charCodeAt(i)),n=B(e.charCodeAt(i+1));if(void 0===t||void 0===n){const t=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+i)}r[o]=16*t+n}return r}function x(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}function T(e){return"string"==typeof e&&(e=x(e)),s(e),e}function R(...e){let t=0;for(let r=0;r<e.length;r++){const n=e[r];s(n),t+=n.length}const n=new Uint8Array(t);for(let r=0,o=0;r<e.length;r++){const t=e[r];n.set(t,o),o+=t.length}return n}class z{}function A(e){const t=t=>e().update(T(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function k(e=32){if(t&&"function"==typeof t.getRandomValues)return t.getRandomValues(new Uint8Array(e));if(t&&"function"==typeof t.randomBytes)return Uint8Array.from(t.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}function O(e,t,n){return e&t^e&n^t&n}class S extends z{constructor(e,t,n,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=l(this.buffer)}update(e){c(this),s(e=T(e));const{view:t,buffer:n,blockLen:r}=this,o=e.length;for(let i=0;i<o;){const s=Math.min(r-this.pos,o-i);if(s!==r)n.set(e.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===r&&(this.process(t,0),this.pos=0);else{const t=l(e);for(;r<=o-i;i+=r)this.process(t,i)}}return this.length+=e.length,this.roundClean(),this}digestInto(e){c(this),function(e,t){s(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:o}=this;let{pos:i}=this;t[i++]=128,u(this.buffer.subarray(i)),this.padOffset>r-i&&(this.process(n,0),i=0);for(let s=i;s<r;s++)t[s]=0;!function(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const o=BigInt(32),i=BigInt(4294967295),s=Number(n>>o&i),a=Number(n&i),c=r?4:0,u=r?0:4;e.setUint32(t+c,s,r),e.setUint32(t+u,a,r)}(n,r-8,BigInt(8*this.length),o),this.process(n,0);const a=l(e),f=this.outputLen;if(f%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const h=f/4,d=this.get();if(h>d.length)throw new Error("_sha2: outputLen bigger than state");for(let s=0;s<h;s++)a.setUint32(4*s,d[s],o)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:r,finished:o,destroyed:i,pos:s}=this;return e.destroyed=i,e.finished=o,e.length=r,e.pos=s,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}}const $=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);const I=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),_=new Uint32Array(64);class V extends S{constructor(e=32){super(64,e,8,!1),this.A=0|$[0],this.B=0|$[1],this.C=0|$[2],this.D=0|$[3],this.E=0|$[4],this.F=0|$[5],this.G=0|$[6],this.H=0|$[7]}get(){const{A:e,B:t,C:n,D:r,E:o,F:i,G:s,H:a}=this;return[e,t,n,r,o,i,s,a]}set(e,t,n,r,o,i,s,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|o,this.F=0|i,this.G=0|s,this.H=0|a}process(e,t){for(let f=0;f<16;f++,t+=4)_[f]=e.getUint32(t,!1);for(let h=16;h<64;h++){const e=_[h-15],t=_[h-2],n=f(e,7)^f(e,18)^e>>>3,r=f(t,17)^f(t,19)^t>>>10;_[h]=r+_[h-7]+n+_[h-16]|0}let{A:n,B:r,C:o,D:i,E:s,F:a,G:c,H:u}=this;for(let h=0;h<64;h++){const e=u+(f(s,6)^f(s,11)^f(s,25))+((l=s)&a^~l&c)+I[h]+_[h]|0,t=(f(n,2)^f(n,13)^f(n,22))+O(n,r,o)|0;u=c,c=a,a=s,s=i+e|0,i=o,o=r,r=n,n=e+t|0}var l;n=n+this.A|0,r=r+this.B|0,o=o+this.C|0,i=i+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(n,r,o,i,s,a,c,u)}roundClean(){u(_)}destroy(){this.set(0,0,0,0,0,0,0,0),u(this.buffer)}}const D=A((()=>new V));class N extends z{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,a(e);const n=T(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,o=new Uint8Array(r);o.set(n.length>r?e.create().update(n).digest():n);for(let i=0;i<o.length;i++)o[i]^=54;this.iHash.update(o),this.oHash=e.create();for(let i=0;i<o.length;i++)o[i]^=106;this.oHash.update(o),u(o)}update(e){return c(this),this.iHash.update(e),this}digestInto(e){c(this),s(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:r,destroyed:o,blockLen:i,outputLen:s}=this;return e.finished=r,e.destroyed=o,e.blockLen=i,e.outputLen=s,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const P=(e,t,n)=>new N(e,t).update(n).digest();P.create=(e,t)=>new N(e,t);const C=BigInt(0),F=BigInt(1);function G(e,t=""){if("boolean"!=typeof e){throw new Error((t&&`"${t}"`)+"expected boolean, got type="+typeof e)}return e}function U(e,t,n=""){const r=o(e),i=e?.length,s=void 0!==t;if(!r||s&&i!==t){throw new Error((n&&`"${n}" `)+"expected Uint8Array"+(s?` of length ${t}`:"")+", got "+(r?`length=${i}`:"type="+typeof e))}return e}function M(e){const t=e.toString(16);return 1&t.length?"0"+t:t}function L(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return""===e?C:BigInt("0x"+e)}function j(e){return L(p(e))}function Z(e){return s(e),L(p(Uint8Array.from(e).reverse()))}function q(e,t){return E(e.toString(16).padStart(2*t,"0"))}function H(e,t){return q(e,t).reverse()}function W(e,t,n){let r;if("string"==typeof t)try{r=E(t)}catch(s){throw new Error(e+" must be hex string or Uint8Array, cause: "+s)}else{if(!o(t))throw new Error(e+" must be hex string or Uint8Array");r=Uint8Array.from(t)}const i=r.length;if("number"==typeof n&&i!==n)throw new Error(e+" of length "+n+" expected, got "+i);return r}const J=e=>"bigint"==typeof e&&C<=e;function K(e,t,n,r){if(!function(e,t,n){return J(e)&&J(t)&&J(n)&&t<=e&&e<n}(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)}function X(e){let t;for(t=0;e>C;e>>=F,t+=1);return t}const Y=e=>(F<<BigInt(e))-F;function Q(e,t,n={}){if(!e||"object"!=typeof e)throw new Error("expected valid options object");function r(t,n,r){const o=e[t];if(r&&void 0===o)return;const i=typeof o;if(i!==n||null===o)throw new Error(`param "${t}" is invalid: expected ${n}, got ${i}`)}Object.entries(t).forEach((([e,t])=>r(e,t,!1))),Object.entries(n).forEach((([e,t])=>r(e,t,!0)))}function ee(e){const t=new WeakMap;return(n,...r)=>{const o=t.get(n);if(void 0!==o)return o;const i=e(n,...r);return t.set(n,i),i}}const te=BigInt(0),ne=BigInt(1),re=BigInt(2),oe=BigInt(3),ie=BigInt(4),se=BigInt(5),ae=BigInt(7),ce=BigInt(8),ue=BigInt(9),le=BigInt(16);function fe(e,t){const n=e%t;return n>=te?n:t+n}function he(e,t,n){let r=e;for(;t-- >te;)r*=r,r%=n;return r}function de(e,t){if(e===te)throw new Error("invert: expected non-zero number");if(t<=te)throw new Error("invert: expected positive modulus, got "+t);let n=fe(e,t),r=t,o=te,i=ne,s=ne,a=te;for(;n!==te;){const e=r/n,t=r%n,c=o-s*e,u=i-a*e;r=n,n=t,o=s,i=a,s=c,a=u}if(r!==ne)throw new Error("invert: does not exist");return fe(o,t)}function pe(e,t,n){if(!e.eql(e.sqr(t),n))throw new Error("Cannot find square root")}function me(e,t){const n=(e.ORDER+ne)/ie,r=e.pow(t,n);return pe(e,r,t),r}function ge(e,t){const n=(e.ORDER-se)/ce,r=e.mul(t,re),o=e.pow(r,n),i=e.mul(t,o),s=e.mul(e.mul(i,re),o),a=e.mul(i,e.sub(s,e.ONE));return pe(e,a,t),a}function ye(e){if(e<oe)throw new Error("sqrt is not defined for small field");let t=e-ne,n=0;for(;t%re===te;)t/=re,n++;let r=re;const o=Te(e);for(;1===Ee(o,r);)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===n)return me;let i=o.pow(r,t);const s=(t+ne)/re;return function(e,r){if(e.is0(r))return r;if(1!==Ee(e,r))throw new Error("Cannot find square root");let o=n,a=e.mul(e.ONE,i),c=e.pow(r,t),u=e.pow(r,s);for(;!e.eql(c,e.ONE);){if(e.is0(c))return e.ZERO;let t=1,n=e.sqr(c);for(;!e.eql(n,e.ONE);)if(t++,n=e.sqr(n),t===o)throw new Error("Cannot find square root");const r=ne<<BigInt(o-t-1),i=e.pow(a,r);o=t,a=e.sqr(i),c=e.mul(c,a),u=e.mul(u,i)}return u}}function we(e){return e%ie===oe?me:e%ce===se?ge:e%le===ue?function(e){const t=Te(e),n=ye(e),r=n(t,t.neg(t.ONE)),o=n(t,r),i=n(t,t.neg(r)),s=(e+ae)/le;return(e,t)=>{let n=e.pow(t,s),a=e.mul(n,r);const c=e.mul(n,o),u=e.mul(n,i),l=e.eql(e.sqr(a),t),f=e.eql(e.sqr(c),t);n=e.cmov(n,a,l),a=e.cmov(u,c,f);const h=e.eql(e.sqr(a),t),d=e.cmov(n,a,h);return pe(e,d,t),d}}(e):ye(e)}const be=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function ve(e,t,n){if(n<te)throw new Error("invalid exponent, negatives unsupported");if(n===te)return e.ONE;if(n===ne)return t;let r=e.ONE,o=t;for(;n>te;)n&ne&&(r=e.mul(r,o)),o=e.sqr(o),n>>=ne;return r}function Be(e,t,n=!1){const r=new Array(t.length).fill(n?e.ZERO:void 0),o=t.reduce(((t,n,o)=>e.is0(n)?t:(r[o]=t,e.mul(t,n))),e.ONE),i=e.inv(o);return t.reduceRight(((t,n,o)=>e.is0(n)?t:(r[o]=e.mul(t,r[o]),e.mul(t,n))),i),r}function Ee(e,t){const n=(e.ORDER-ne)/re,r=e.pow(t,n),o=e.eql(r,e.ONE),i=e.eql(r,e.ZERO),s=e.eql(r,e.neg(e.ONE));if(!o&&!i&&!s)throw new Error("invalid Legendre symbol result");return o?1:i?0:-1}function xe(e,t){void 0!==t&&i(t);const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function Te(e,t,n=!1,r={}){if(e<=te)throw new Error("invalid field: expected ORDER > 0, got "+e);let o,i,s,a=!1;if("object"==typeof t&&null!=t){if(r.sqrt||n)throw new Error("cannot specify opts in two arguments");const e=t;e.BITS&&(o=e.BITS),e.sqrt&&(i=e.sqrt),"boolean"==typeof e.isLE&&(n=e.isLE),"boolean"==typeof e.modFromBytes&&(a=e.modFromBytes),s=e.allowedLengths}else"number"==typeof t&&(o=t),r.sqrt&&(i=r.sqrt);const{nBitLength:c,nByteLength:u}=xe(e,o);if(u>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let l;const f=Object.freeze({ORDER:e,isLE:n,BITS:c,BYTES:u,MASK:Y(c),ZERO:te,ONE:ne,allowedLengths:s,create:t=>fe(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("invalid field element: expected bigint, got "+typeof t);return te<=t&&t<e},is0:e=>e===te,isValidNot0:e=>!f.is0(e)&&f.isValid(e),isOdd:e=>(e&ne)===ne,neg:t=>fe(-t,e),eql:(e,t)=>e===t,sqr:t=>fe(t*t,e),add:(t,n)=>fe(t+n,e),sub:(t,n)=>fe(t-n,e),mul:(t,n)=>fe(t*n,e),pow:(e,t)=>ve(f,e,t),div:(t,n)=>fe(t*de(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>de(t,e),sqrt:i||(t=>(l||(l=we(e)),l(f,t))),toBytes:e=>n?H(e,u):q(e,u),fromBytes:(t,r=!0)=>{if(s){if(!s.includes(t.length)||t.length>u)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+t.length);const e=new Uint8Array(u);e.set(t,n?0:e.length-t.length),t=e}if(t.length!==u)throw new Error("Field.fromBytes: expected "+u+" bytes, got "+t.length);let o=n?Z(t):j(t);if(a&&(o=fe(o,e)),!r&&!f.isValid(o))throw new Error("invalid field element: outside of range 0..ORDER");return o},invertBatch:e=>Be(f,e),cmov:(e,t,n)=>n?t:e});return Object.freeze(f)}function Re(e){if("bigint"!=typeof e)throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function ze(e){const t=Re(e);return t+Math.ceil(t/2)}const Ae=BigInt(0),ke=BigInt(1);function Oe(e,t){const n=t.negate();return e?n:t}function Se(e,t){const n=Be(e.Fp,t.map((e=>e.Z)));return t.map(((t,r)=>e.fromAffine(t.toAffine(n[r]))))}function $e(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function Ie(e,t){$e(e,t);const n=2**e;return{windows:Math.ceil(t/e)+1,windowSize:2**(e-1),mask:Y(e),maxNumber:n,shiftBy:BigInt(e)}}function _e(e,t,n){const{windowSize:r,mask:o,maxNumber:i,shiftBy:s}=n;let a=Number(e&o),c=e>>s;a>r&&(a-=i,c+=ke);const u=t*r;return{nextN:c,offset:u+Math.abs(a)-1,isZero:0===a,isNeg:a<0,isNegF:t%2!=0,offsetF:u}}function Ve(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach(((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)}))}function De(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach(((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)}))}const Ne=new WeakMap,Pe=new WeakMap;function Ce(e){return Pe.get(e)||1}function Fe(e){if(e!==Ae)throw new Error("invalid wNAF")}class Ge{constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,n=this.ZERO){let r=e;for(;t>Ae;)t&ke&&(n=n.add(r)),r=r.double(),t>>=ke;return n}precomputeWindow(e,t){const{windows:n,windowSize:r}=Ie(t,this.bits),o=[];let i=e,s=i;for(let a=0;a<n;a++){s=i,o.push(s);for(let e=1;e<r;e++)s=s.add(i),o.push(s);i=s.double()}return o}wNAF(e,t,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let r=this.ZERO,o=this.BASE;const i=Ie(e,this.bits);for(let s=0;s<i.windows;s++){const{nextN:e,offset:a,isZero:c,isNeg:u,isNegF:l,offsetF:f}=_e(n,s,i);n=e,c?o=o.add(Oe(l,t[f])):r=r.add(Oe(u,t[a]))}return Fe(n),{p:r,f:o}}wNAFUnsafe(e,t,n,r=this.ZERO){const o=Ie(e,this.bits);for(let i=0;i<o.windows&&n!==Ae;i++){const{nextN:e,offset:s,isZero:a,isNeg:c}=_e(n,i,o);if(n=e,!a){const e=t[s];r=r.add(c?e.negate():e)}}return Fe(n),r}getPrecomputes(e,t,n){let r=Ne.get(t);return r||(r=this.precomputeWindow(t,e),1!==e&&("function"==typeof n&&(r=n(r)),Ne.set(t,r))),r}cached(e,t,n){const r=Ce(e);return this.wNAF(r,this.getPrecomputes(r,e,n),t)}unsafe(e,t,n,r){const o=Ce(e);return 1===o?this._unsafeLadder(e,t,r):this.wNAFUnsafe(o,this.getPrecomputes(o,e,n),t,r)}createCache(e,t){$e(t,this.bits),Pe.set(e,t),Ne.delete(e)}hasCache(e){return 1!==Ce(e)}}function Ue(e,t,n){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return function(e){const t=be.reduce(((e,t)=>(e[t]="function",e)),{ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"});Q(e,t)}(t),t}return Te(e,{isLE:n})}const Me=(e,t)=>(e+(e>=0?t:-t)/Je)/t;function Le(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function je(e,t){const n={};for(let r of Object.keys(t))n[r]=void 0===e[r]?t[r]:e[r];return G(n.lowS,"lowS"),G(n.prehash,"prehash"),void 0!==n.format&&Le(n.format),n}class Ze extends Error{constructor(e=""){super(e)}}const qe={Err:Ze,_tlv:{encode:(e,t)=>{const{Err:n}=qe;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(1&t.length)throw new n("tlv.encode: unpadded data");const r=t.length/2,o=M(r);if(o.length/2&128)throw new n("tlv.encode: long form length too big");const i=r>127?M(o.length/2|128):"";return M(e)+i+o+t},decode(e,t){const{Err:n}=qe;let r=0;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length<2||t[r++]!==e)throw new n("tlv.decode: wrong tlv");const o=t[r++];let i=0;if(!!(128&o)){const e=127&o;if(!e)throw new n("tlv.decode(long): indefinite length not supported");if(e>4)throw new n("tlv.decode(long): byte length is too big");const s=t.subarray(r,r+e);if(s.length!==e)throw new n("tlv.decode: length bytes not complete");if(0===s[0])throw new n("tlv.decode(long): zero leftmost byte");for(const t of s)i=i<<8|t;if(r+=e,i<128)throw new n("tlv.decode(long): not minimal encoding")}else i=o;const s=t.subarray(r,r+i);if(s.length!==i)throw new n("tlv.decode: wrong value length");return{v:s,l:t.subarray(r+i)}}},_int:{encode(e){const{Err:t}=qe;if(e<He)throw new t("integer: negative integers are not allowed");let n=M(e);if(8&Number.parseInt(n[0],16)&&(n="00"+n),1&n.length)throw new t("unexpected DER parsing assertion: unpadded hex");return n},decode(e){const{Err:t}=qe;if(128&e[0])throw new t("invalid signature integer: negative");if(0===e[0]&&!(128&e[1]))throw new t("invalid signature integer: unnecessary leading zero");return j(e)}},toSig(e){const{Err:t,_int:n,_tlv:r}=qe,o=W("signature",e),{v:i,l:s}=r.decode(48,o);if(s.length)throw new t("invalid signature: left bytes after parsing");const{v:a,l:c}=r.decode(2,i),{v:u,l:l}=r.decode(2,c);if(l.length)throw new t("invalid signature: left bytes after parsing");return{r:n.decode(a),s:n.decode(u)}},hexFromSig(e){const{_tlv:t,_int:n}=qe,r=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,r)}},He=BigInt(0),We=BigInt(1),Je=BigInt(2),Ke=BigInt(3),Xe=BigInt(4);function Ye(e,t){const{BYTES:n}=e;let r;if("bigint"==typeof t)r=t;else{let i=W("private key",t);try{r=e.fromBytes(i)}catch(o){throw new Error(`invalid private key: expected ui8a of size ${n}, got ${typeof t}`)}}if(!e.isValidNot0(r))throw new Error("invalid private key: out of range [1..N-1]");return r}function Qe(e,t={}){const n=function(e,t,n={},r){if(void 0===r&&(r="edwards"===e),!t||"object"!=typeof t)throw new Error(`expected valid ${e} CURVE object`);for(const a of["p","n","h"]){const e=t[a];if(!("bigint"==typeof e&&e>Ae))throw new Error(`CURVE.${a} must be positive bigint`)}const o=Ue(t.p,n.Fp,r),i=Ue(t.n,n.Fn,r),s=["Gx","Gy","a","weierstrass"===e?"b":"d"];for(const a of s)if(!o.isValid(t[a]))throw new Error(`CURVE.${a} must be valid field element of CURVE.Fp`);return{CURVE:t=Object.freeze(Object.assign({},t)),Fp:o,Fn:i}}("weierstrass",e,t),{Fp:r,Fn:o}=n;let i=n.CURVE;const{h:s,n:a}=i;Q(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:c}=t;if(c&&(!r.is0(i.a)||"bigint"!=typeof c.beta||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const u=tt(r,o);function l(){if(!r.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}const f=t.toBytes||function(e,t,n){const{x:o,y:i}=t.toAffine(),s=r.toBytes(o);if(G(n,"isCompressed"),n){l();return R(et(!r.isOdd(i)),s)}return R(Uint8Array.of(4),s,r.toBytes(i))},h=t.fromBytes||function(e){U(e,void 0,"Point");const{publicKey:t,publicKeyUncompressed:n}=u,o=e.length,i=e[0],s=e.subarray(1);if(o!==t||2!==i&&3!==i){if(o===n&&4===i){const e=r.BYTES,t=r.fromBytes(s.subarray(0,e)),n=r.fromBytes(s.subarray(e,2*e));if(!m(t,n))throw new Error("bad point: is not on curve");return{x:t,y:n}}throw new Error(`bad point: got length ${o}, expected compressed=${t} or uncompressed=${n}`)}{const e=r.fromBytes(s);if(!r.isValid(e))throw new Error("bad point: is not on curve, wrong x");const t=d(e);let n;try{n=r.sqrt(t)}catch(a){const e=a instanceof Error?": "+a.message:"";throw new Error("bad point: is not on curve, sqrt error"+e)}l();return!(1&~i)!==r.isOdd(n)&&(n=r.neg(n)),{x:e,y:n}}};function d(e){const t=r.sqr(e),n=r.mul(t,e);return r.add(r.add(n,r.mul(e,i.a)),i.b)}function m(e,t){const n=r.sqr(t),o=d(e);return r.eql(n,o)}if(!m(i.Gx,i.Gy))throw new Error("bad curve params: generator point");const g=r.mul(r.pow(i.a,Ke),Xe),y=r.mul(r.sqr(i.b),BigInt(27));if(r.is0(r.add(g,y)))throw new Error("bad curve params: a or b");function w(e,t,n=!1){if(!r.isValid(t)||n&&r.is0(t))throw new Error(`bad point coordinate ${e}`);return t}function b(e){if(!(e instanceof T))throw new Error("ProjectivePoint expected")}function v(e){if(!c||!c.basises)throw new Error("no endo");return function(e,t,n){const[[r,o],[i,s]]=t,a=Me(s*e,n),c=Me(-o*e,n);let u=e-a*r-c*i,l=-a*o-c*s;const f=u<He,h=l<He;f&&(u=-u),h&&(l=-l);const d=Y(Math.ceil(X(n)/2))+We;if(u<He||u>=d||l<He||l>=d)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:f,k1:u,k2neg:h,k2:l}}(e,c.basises,o.ORDER)}const B=ee(((e,t)=>{const{X:n,Y:o,Z:i}=e;if(r.eql(i,r.ONE))return{x:n,y:o};const s=e.is0();null==t&&(t=s?r.ONE:r.inv(i));const a=r.mul(n,t),c=r.mul(o,t),u=r.mul(i,t);if(s)return{x:r.ZERO,y:r.ZERO};if(!r.eql(u,r.ONE))throw new Error("invZ was invalid");return{x:a,y:c}})),E=ee((e=>{if(e.is0()){if(t.allowInfinityPoint&&!r.is0(e.Y))return;throw new Error("bad point: ZERO")}const{x:n,y:o}=e.toAffine();if(!r.isValid(n)||!r.isValid(o))throw new Error("bad point: x or y not field elements");if(!m(n,o))throw new Error("bad point: equation left != right");if(!e.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0}));function x(e,t,n,o,i){return n=new T(r.mul(n.X,e),n.Y,n.Z),t=Oe(o,t),n=Oe(i,n),t.add(n)}class T{constructor(e,t,n){this.X=w("x",e),this.Y=w("y",t,!0),this.Z=w("z",n),Object.freeze(this)}static CURVE(){return i}static fromAffine(e){const{x:t,y:n}=e||{};if(!e||!r.isValid(t)||!r.isValid(n))throw new Error("invalid affine point");if(e instanceof T)throw new Error("projective point not allowed");return r.is0(t)&&r.is0(n)?T.ZERO:new T(t,n,r.ONE)}static fromBytes(e){const t=T.fromAffine(h(U(e,void 0,"point")));return t.assertValidity(),t}static fromHex(e){return T.fromBytes(W("pointHex",e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=8,t=!0){return A.createCache(this,e),t||this.multiply(Ke),this}assertValidity(){E(this)}hasEvenY(){const{y:e}=this.toAffine();if(!r.isOdd)throw new Error("Field doesn't support isOdd");return!r.isOdd(e)}equals(e){b(e);const{X:t,Y:n,Z:o}=this,{X:i,Y:s,Z:a}=e,c=r.eql(r.mul(t,a),r.mul(i,o)),u=r.eql(r.mul(n,a),r.mul(s,o));return c&&u}negate(){return new T(this.X,r.neg(this.Y),this.Z)}double(){const{a:e,b:t}=i,n=r.mul(t,Ke),{X:o,Y:s,Z:a}=this;let c=r.ZERO,u=r.ZERO,l=r.ZERO,f=r.mul(o,o),h=r.mul(s,s),d=r.mul(a,a),p=r.mul(o,s);return p=r.add(p,p),l=r.mul(o,a),l=r.add(l,l),c=r.mul(e,l),u=r.mul(n,d),u=r.add(c,u),c=r.sub(h,u),u=r.add(h,u),u=r.mul(c,u),c=r.mul(p,c),l=r.mul(n,l),d=r.mul(e,d),p=r.sub(f,d),p=r.mul(e,p),p=r.add(p,l),l=r.add(f,f),f=r.add(l,f),f=r.add(f,d),f=r.mul(f,p),u=r.add(u,f),d=r.mul(s,a),d=r.add(d,d),f=r.mul(d,p),c=r.sub(c,f),l=r.mul(d,h),l=r.add(l,l),l=r.add(l,l),new T(c,u,l)}add(e){b(e);const{X:t,Y:n,Z:o}=this,{X:s,Y:a,Z:c}=e;let u=r.ZERO,l=r.ZERO,f=r.ZERO;const h=i.a,d=r.mul(i.b,Ke);let p=r.mul(t,s),m=r.mul(n,a),g=r.mul(o,c),y=r.add(t,n),w=r.add(s,a);y=r.mul(y,w),w=r.add(p,m),y=r.sub(y,w),w=r.add(t,o);let v=r.add(s,c);return w=r.mul(w,v),v=r.add(p,g),w=r.sub(w,v),v=r.add(n,o),u=r.add(a,c),v=r.mul(v,u),u=r.add(m,g),v=r.sub(v,u),f=r.mul(h,w),u=r.mul(d,g),f=r.add(u,f),u=r.sub(m,f),f=r.add(m,f),l=r.mul(u,f),m=r.add(p,p),m=r.add(m,p),g=r.mul(h,g),w=r.mul(d,w),m=r.add(m,g),g=r.sub(p,g),g=r.mul(h,g),w=r.add(w,g),p=r.mul(m,w),l=r.add(l,p),p=r.mul(v,w),u=r.mul(y,u),u=r.sub(u,p),p=r.mul(y,m),f=r.mul(v,f),f=r.add(f,p),new T(u,l,f)}subtract(e){return this.add(e.negate())}is0(){return this.equals(T.ZERO)}multiply(e){const{endo:n}=t;if(!o.isValidNot0(e))throw new Error("invalid scalar: out of range");let r,i;const s=e=>A.cached(this,e,(e=>Se(T,e)));if(n){const{k1neg:t,k1:o,k2neg:a,k2:c}=v(e),{p:u,f:l}=s(o),{p:f,f:h}=s(c);i=l.add(h),r=x(n.beta,u,f,t,a)}else{const{p:t,f:n}=s(e);r=t,i=n}return Se(T,[r,i])[0]}multiplyUnsafe(e){const{endo:n}=t,r=this;if(!o.isValid(e))throw new Error("invalid scalar: out of range");if(e===He||r.is0())return T.ZERO;if(e===We)return r;if(A.hasCache(this))return this.multiply(e);if(n){const{k1neg:t,k1:o,k2neg:i,k2:s}=v(e),{p1:a,p2:c}=function(e,t,n,r){let o=t,i=e.ZERO,s=e.ZERO;for(;n>Ae||r>Ae;)n&ke&&(i=i.add(o)),r&ke&&(s=s.add(o)),o=o.double(),n>>=ke,r>>=ke;return{p1:i,p2:s}}(T,r,o,s);return x(n.beta,a,c,t,i)}return A.unsafe(r,e)}multiplyAndAddUnsafe(e,t,n){const r=this.multiplyUnsafe(t).add(e.multiplyUnsafe(n));return r.is0()?void 0:r}toAffine(e){return B(this,e)}isTorsionFree(){const{isTorsionFree:e}=t;return s===We||(e?e(T,this):A.unsafe(this,a).is0())}clearCofactor(){const{clearCofactor:e}=t;return s===We?this:e?e(T,this):this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(e=!0){return G(e,"isCompressed"),this.assertValidity(),f(T,this,e)}toHex(e=!0){return p(this.toBytes(e))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(e=!0){return this.toBytes(e)}_setWindowSize(e){this.precompute(e)}static normalizeZ(e){return Se(T,e)}static msm(e,t){return function(e,t,n,r){Ve(n,e),De(r,t);const o=n.length,i=r.length;if(o!==i)throw new Error("arrays of points and scalars must have equal length");const s=e.ZERO,a=X(BigInt(o));let c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);const u=Y(c),l=new Array(Number(u)+1).fill(s);let f=s;for(let h=Math.floor((t.BITS-1)/c)*c;h>=0;h-=c){l.fill(s);for(let t=0;t<i;t++){const e=r[t],o=Number(e>>BigInt(h)&u);l[o]=l[o].add(n[t])}let e=s;for(let t=l.length-1,n=s;t>0;t--)n=n.add(l[t]),e=e.add(n);if(f=f.add(e),0!==h)for(let t=0;t<c;t++)f=f.double()}return f}(T,o,e,t)}static fromPrivateKey(e){return T.BASE.multiply(Ye(o,e))}}T.BASE=new T(i.Gx,i.Gy,r.ONE),T.ZERO=new T(r.ZERO,r.ONE,r.ZERO),T.Fp=r,T.Fn=o;const z=o.BITS,A=new Ge(T,t.endo?Math.ceil(z/2):z);return T.BASE.precompute(8),T}function et(e){return Uint8Array.of(e?2:3)}function tt(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function nt(e,t={}){const{Fn:n}=e,r=t.randomBytes||k,o=Object.assign(tt(e.Fp,n),{seed:ze(n.ORDER)});function i(e){try{return!!Ye(n,e)}catch(t){return!1}}function s(e=r(o.seed)){return function(e,t,n=!1){const r=e.length,o=Re(t),i=ze(t);if(r<16||r<i||r>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+r);const s=fe(n?Z(e):j(e),t-ne)+ne;return n?H(s,o):q(s,o)}(U(e,o.seed,"seed"),n.ORDER)}function a(t,r=!0){return e.BASE.multiply(Ye(n,t)).toBytes(r)}function c(t){if("bigint"==typeof t)return!1;if(t instanceof e)return!0;const{secretKey:r,publicKey:i,publicKeyUncompressed:s}=o;if(n.allowedLengths||r===i)return;const a=W("key",t).length;return a===i||a===s}const u={isValidSecretKey:i,isValidPublicKey:function(t,n){const{publicKey:r,publicKeyUncompressed:i}=o;try{const o=t.length;return(!0!==n||o===r)&&((!1!==n||o===i)&&!!e.fromBytes(t))}catch(s){return!1}},randomSecretKey:s,isValidPrivateKey:i,randomPrivateKey:s,normPrivateKeyToScalar:e=>Ye(n,e),precompute:(t=8,n=e.BASE)=>n.precompute(t,!1)};return Object.freeze({getPublicKey:a,getSharedSecret:function(t,r,o=!0){if(!0===c(t))throw new Error("first arg must be private key");if(!1===c(r))throw new Error("second arg must be public key");const i=Ye(n,t);return e.fromHex(r).multiply(i).toBytes(o)},keygen:function(e){const t=s(e);return{secretKey:t,publicKey:a(t)}},Point:e,utils:u,lengths:o})}function rt(e,t,n={}){a(t),Q(n,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const r=n.randomBytes||k,i=n.hmac||((e,...n)=>P(t,e,R(...n))),{Fp:s,Fn:c}=e,{ORDER:u,BITS:l}=c,{keygen:f,getPublicKey:h,getSharedSecret:d,utils:m,lengths:g}=nt(e,n),y={prehash:!1,lowS:"boolean"==typeof n.lowS&&n.lowS,format:void 0,extraEntropy:!1},w="compact";function b(e){return e>u>>We}function v(e,t){if(!c.isValidNot0(t))throw new Error(`invalid signature ${e}: out of range 1..Point.Fn.ORDER`);return t}class B{constructor(e,t,n){this.r=v("r",e),this.s=v("s",t),null!=n&&(this.recovery=n),Object.freeze(this)}static fromBytes(e,t=w){let n;if(function(e,t){Le(t);const n=g.signature;U(e,"compact"===t?n:"recovered"===t?n+1:void 0,`${t} signature`)}(e,t),"der"===t){const{r:t,s:n}=qe.toSig(U(e));return new B(t,n)}"recovered"===t&&(n=e[0],t="compact",e=e.subarray(1));const r=c.BYTES,o=e.subarray(0,r),i=e.subarray(r,2*r);return new B(c.fromBytes(o),c.fromBytes(i),n)}static fromHex(e,t){return this.fromBytes(E(e),t)}addRecoveryBit(e){return new B(this.r,this.s,e)}recoverPublicKey(t){const n=s.ORDER,{r:r,s:o,recovery:i}=this;if(null==i||![0,1,2,3].includes(i))throw new Error("recovery id invalid");if(u*Je<n&&i>1)throw new Error("recovery id is ambiguous for h>1 curve");const a=2===i||3===i?r+u:r;if(!s.isValid(a))throw new Error("recovery id 2 or 3 invalid");const l=s.toBytes(a),f=e.fromBytes(R(et(!(1&i)),l)),h=c.inv(a),d=T(W("msgHash",t)),p=c.create(-d*h),m=c.create(o*h),g=e.BASE.multiplyUnsafe(p).add(f.multiplyUnsafe(m));if(g.is0())throw new Error("point at infinify");return g.assertValidity(),g}hasHighS(){return b(this.s)}toBytes(e=w){if(Le(e),"der"===e)return E(qe.hexFromSig(this));const t=c.toBytes(this.r),n=c.toBytes(this.s);if("recovered"===e){if(null==this.recovery)throw new Error("recovery bit must be present");return R(Uint8Array.of(this.recovery),t,n)}return R(t,n)}toHex(e){return p(this.toBytes(e))}assertValidity(){}static fromCompact(e){return B.fromBytes(W("sig",e),"compact")}static fromDER(e){return B.fromBytes(W("sig",e),"der")}normalizeS(){return this.hasHighS()?new B(this.r,c.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return p(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return p(this.toBytes("compact"))}}const x=n.bits2int||function(e){if(e.length>8192)throw new Error("input is too large");const t=j(e),n=8*e.length-l;return n>0?t>>BigInt(n):t},T=n.bits2int_modN||function(e){return c.create(x(e))},z=Y(l);function A(e){return K("num < 2^"+l,e,He,z),c.toBytes(e)}function O(e,n){return U(e,void 0,"message"),n?U(t(e),void 0,"prehashed message"):e}return Object.freeze({keygen:f,getPublicKey:h,getSharedSecret:d,utils:m,lengths:g,Point:e,sign:function(n,o,s={}){n=W("message",n);const{seed:a,k2sig:u}=function(t,n,o){if(["recovered","canonical"].some((e=>e in o)))throw new Error("sign() legacy options not supported");const{lowS:i,prehash:s,extraEntropy:a}=je(o,y);t=O(t,s);const u=T(t),l=Ye(c,n),f=[A(l),A(u)];if(null!=a&&!1!==a){const e=!0===a?r(g.secretKey):a;f.push(W("extraEntropy",e))}const h=R(...f),d=u;return{seed:h,k2sig:function(t){const n=x(t);if(!c.isValidNot0(n))return;const r=c.inv(n),o=e.BASE.multiply(n).toAffine(),s=c.create(o.x);if(s===He)return;const a=c.create(r*c.create(d+s*l));if(a===He)return;let u=(o.x===s?0:2)|Number(o.y&We),f=a;return i&&b(a)&&(f=c.neg(a),u^=1),new B(s,f,u)}}}(n,o,s);return function(e,t,n){if("number"!=typeof e||e<2)throw new Error("hashLen must be a number");if("number"!=typeof t||t<2)throw new Error("qByteLen must be a number");if("function"!=typeof n)throw new Error("hmacFn must be a function");const r=e=>new Uint8Array(e),o=e=>Uint8Array.of(e);let i=r(e),s=r(e),a=0;const c=()=>{i.fill(1),s.fill(0),a=0},u=(...e)=>n(s,i,...e),l=(e=r(0))=>{s=u(o(0),e),i=u(),0!==e.length&&(s=u(o(1),e),i=u())},f=()=>{if(a++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const n=[];for(;e<t;){i=u();const t=i.slice();n.push(t),e+=i.length}return R(...n)};return(e,t)=>{let n;for(c(),l(e);!(n=t(f()));)l();return c(),n}}(t.outputLen,c.BYTES,i)(a,u)},verify:function(t,n,r,i={}){const{lowS:s,prehash:a,format:u}=je(i,y);if(r=W("publicKey",r),n=O(W("message",n),a),"strict"in i)throw new Error("options.strict was renamed to lowS");const l=void 0===u?function(e){let t;const n="string"==typeof e||o(e),r=!n&&null!==e&&"object"==typeof e&&"bigint"==typeof e.r&&"bigint"==typeof e.s;if(!n&&!r)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(r)t=new B(e.r,e.s);else if(n){try{t=B.fromBytes(W("sig",e),"der")}catch(i){if(!(i instanceof qe.Err))throw i}if(!t)try{t=B.fromBytes(W("sig",e),"compact")}catch(s){return!1}}return t||!1}(t):B.fromBytes(W("sig",t),u);if(!1===l)return!1;try{const t=e.fromBytes(r);if(s&&l.hasHighS())return!1;const{r:o,s:i}=l,a=T(n),u=c.inv(i),f=c.create(a*u),h=c.create(o*u),d=e.BASE.multiplyUnsafe(f).add(t.multiplyUnsafe(h));if(d.is0())return!1;return c.create(d.x)===o}catch(f){return!1}},recoverPublicKey:function(e,t,n={}){const{prehash:r}=je(n,y);return t=O(t,r),B.fromBytes(e,"recovered").recoverPublicKey(t).toBytes()},Signature:B,hash:t})}function ot(e){const t={a:e.a,b:e.b,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},n=e.Fp;let r=e.allowedPrivateKeyLengths?Array.from(new Set(e.allowedPrivateKeyLengths.map((e=>Math.ceil(e/2))))):void 0;return{CURVE:t,curveOpts:{Fp:n,Fn:Te(t.n,{BITS:e.nBitLength,allowedLengths:r,modFromBytes:e.wrapPrivateKey}),allowInfinityPoint:e.allowInfinityPoint,endo:e.endo,isTorsionFree:e.isTorsionFree,clearCofactor:e.clearCofactor,fromBytes:e.fromBytes,toBytes:e.toBytes}}}function it(e){const{CURVE:t,curveOpts:n,hash:r,ecdsaOpts:o}=function(e){const{CURVE:t,curveOpts:n}=ot(e),r={hmac:e.hmac,randomBytes:e.randomBytes,lowS:e.lowS,bits2int:e.bits2int,bits2int_modN:e.bits2int_modN};return{CURVE:t,curveOpts:n,hash:e.hash,ecdsaOpts:r}}(e);return function(e,t){const n=t.Point;return Object.assign({},t,{ProjectivePoint:n,CURVE:Object.assign({},e,xe(n.Fn.ORDER,n.Fn.BITS))})}(e,rt(Qe(t,n),r,o))}const st={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},at={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},ct=BigInt(2);const ut=Te(st.p,{sqrt:function(e){const t=st.p,n=BigInt(3),r=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),u=e*e*e%t,l=u*u*e%t,f=he(l,n,t)*l%t,h=he(f,n,t)*l%t,d=he(h,ct,t)*u%t,p=he(d,o,t)*d%t,m=he(p,i,t)*p%t,g=he(m,a,t)*m%t,y=he(g,c,t)*g%t,w=he(y,a,t)*m%t,b=he(w,n,t)*l%t,v=he(b,s,t)*p%t,B=he(v,r,t)*u%t,E=he(B,ct,t);if(!ut.eql(ut.sqr(E),e))throw new Error("Cannot find square root");return E}}),lt=function(e,t){const n=t=>it({...e,hash:t});return{...n(t),create:n}}({...st,Fp:ut,lowS:!0,endo:at},D);function ft(e,t){const n=[];for(let r=0;r<e.length;r+=t)n.push(e.subarray(r,r+t));return n}function ht(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function dt(e,t){const n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e[r]!==t[r])return e.subarray(0,r);return e.subarray(0,n)}function pt(e){return Array.from(e).map((e=>e.toString(16).padStart(2,"0"))).join("")}function mt(e,t){const n=new Uint8Array(32);let r=e;if("LE"===t){for(let e=0;e<32;e++)n[e]=Number(0xffn&r),r>>=8n;return n}for(let o=31;o>=0;o--)n[o]=Number(0xffn&r),r>>=8n;return n}function gt(e,t){let n=0n;if("LE"===t){for(let t=31;t>=0;t--)n=n<<8n|BigInt(e[t]);return n}for(let r=0;r<32;r++)n=n<<8n|BigInt(e[r]);return n}function yt(e){const t=e.startsWith("0x")||e.startsWith("0X")?e.slice(2):e,n=new Uint8Array(t.length/2);for(let r=0;r<n.length;r++)n[r]=parseInt(t.slice(2*r,2*r+2),16);return n}var wt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bt="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function vt(e,t){const n=t.length;let r=0,o=0;const i=[];for(let s=0;s<e.length;s++){const a=e.charAt(s);if("="===a)break;const c=t.indexOf(a);if(-1===c)throw new Error(`Invalid character: ${a}`);o=o<<Math.log2(n)|c,r+=Math.log2(n),r>=8&&(r-=8,i.push(o>>r&255))}return new Uint8Array(i)}function Bt(e,t){const n=t.length;let r=0,o=0,i="";for(const s of e)for(o=o<<8|s,r+=8;r>=Math.log2(n);)r-=Math.log2(n),i+=t.charAt(o>>r&n-1);return r>0&&(i+=t.charAt(o<<Math.log2(n)-r&n-1)),i.length%4!=0&&(i+="=".repeat(4-i.length%4)),i}function Et(e){return Bt(e,bt)}function xt(e){return new Uint8Array([e])}function Tt(e){return e[0]}function Rt(e,t){return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint16(0,"LE"===t)}function zt(e,t){const n=new ArrayBuffer(4);return new DataView(n).setUint32(0,e,"LE"===t),new Uint8Array(n)}function At(e,t){const n=new ArrayBuffer(8);return new DataView(n).setBigUint64(0,e,"LE"===t),new Uint8Array(n)}function kt(e,t){return new DataView(e.buffer,e.byteOffset,e.byteLength).getBigUint64(0,"LE"===t)}var Ot=[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 St(e){return t=function(e,t){for(const n of t){for(let t=0;t<34;t+=2)e[t]=e[t]^n[t+1],e[t+1]=e[t+1]^n[t];$t(e)}return e}(new Array(50).fill(0),function(e,t){if(!e.length){const e=new Uint8Array(136);return e[0]=t,e[135]=128,[It(e)]}const n=ft(e,136),r=n[n.length-1];if(r.length<136){const e=new Uint8Array(136);e.set(r),e[r.length]=t,e[135]=128|e[135],n[n.length-1]=e}if(136===r.length){const e=new Uint8Array(136);e[0]=t,e[135]=128,n.push(e)}return n.map(It)}(e,1)),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]);var t}function $t(e){for(let t=0;t<24;t++){const n=e[0]^e[10]^e[20]^e[30]^e[40],r=e[1]^e[11]^e[21]^e[31]^e[41],o=e[2]^e[12]^e[22]^e[32]^e[42],i=e[3]^e[13]^e[23]^e[33]^e[43],s=e[4]^e[14]^e[24]^e[34]^e[44],a=e[5]^e[15]^e[25]^e[35]^e[45],c=e[6]^e[16]^e[26]^e[36]^e[46],u=e[7]^e[17]^e[27]^e[37]^e[47],l=e[8]^e[18]^e[28]^e[38]^e[48],f=e[9]^e[19]^e[29]^e[39]^e[49],h=l^(o<<1|i>>>31),d=f^(i<<1|o>>>31),p=n^(s<<1|a>>>31),m=r^(a<<1|s>>>31),g=o^(c<<1|u>>>31),y=i^(u<<1|c>>>31),w=s^(l<<1|f>>>31),b=a^(f<<1|l>>>31),v=c^(n<<1|r>>>31),B=u^(r<<1|n>>>31);e[0]^=h,e[1]^=d,e[2]^=p,e[3]^=m,e[4]^=g,e[5]^=y,e[6]^=w,e[7]^=b,e[8]^=v,e[9]^=B,e[10]^=h,e[11]^=d,e[12]^=p,e[13]^=m,e[14]^=g,e[15]^=y,e[16]^=w,e[17]^=b,e[18]^=v,e[19]^=B,e[20]^=h,e[21]^=d,e[22]^=p,e[23]^=m,e[24]^=g,e[25]^=y,e[26]^=w,e[27]^=b,e[28]^=v,e[29]^=B,e[30]^=h,e[31]^=d,e[32]^=p,e[33]^=m,e[34]^=g,e[35]^=y,e[36]^=w,e[37]^=b,e[38]^=v,e[39]^=B,e[40]^=h,e[41]^=d,e[42]^=p,e[43]^=m,e[44]^=g,e[45]^=y,e[46]^=w,e[47]^=b,e[48]^=v,e[49]^=B;const E=e[0],x=e[1],T=e[2]<<1|e[3]>>>31,R=e[3]<<1|e[2]>>>31,z=e[5]<<30|e[4]>>>2,A=e[4]<<30|e[5]>>>2,k=e[6]<<28|e[7]>>>4,O=e[7]<<28|e[6]>>>4,S=e[8]<<27|e[9]>>>5,$=e[9]<<27|e[8]>>>5,I=e[11]<<4|e[10]>>>28,_=e[10]<<4|e[11]>>>28,V=e[13]<<12|e[12]>>>20,D=e[12]<<12|e[13]>>>20,N=e[14]<<6|e[15]>>>26,P=e[15]<<6|e[14]>>>26,C=e[17]<<23|e[16]>>>9,F=e[16]<<23|e[17]>>>9,G=e[18]<<20|e[19]>>>12,U=e[19]<<20|e[18]>>>12,M=e[20]<<3|e[21]>>>29,L=e[21]<<3|e[20]>>>29,j=e[22]<<10|e[23]>>>22,Z=e[23]<<10|e[22]>>>22,q=e[25]<<11|e[24]>>>21,H=e[24]<<11|e[25]>>>21,W=e[26]<<25|e[27]>>>7,J=e[27]<<25|e[26]>>>7,K=e[29]<<7|e[28]>>>25,X=e[28]<<7|e[29]>>>25,Y=e[31]<<9|e[30]>>>23,Q=e[30]<<9|e[31]>>>23,ee=e[33]<<13|e[32]>>>19,te=e[32]<<13|e[33]>>>19,ne=e[34]<<15|e[35]>>>17,re=e[35]<<15|e[34]>>>17,oe=e[36]<<21|e[37]>>>11,ie=e[37]<<21|e[36]>>>11,se=e[38]<<8|e[39]>>>24,ae=e[39]<<8|e[38]>>>24,ce=e[40]<<18|e[41]>>>14,ue=e[41]<<18|e[40]>>>14,le=e[42]<<2|e[43]>>>30,fe=e[43]<<2|e[42]>>>30,he=e[45]<<29|e[44]>>>3,de=e[44]<<29|e[45]>>>3,pe=e[47]<<24|e[46]>>>8,me=e[46]<<24|e[47]>>>8,ge=e[48]<<14|e[49]>>>18,ye=e[49]<<14|e[48]>>>18;e[0]=E^~V&q,e[1]=x^~D&H,e[2]=V^~q&oe,e[3]=D^~H&ie,e[4]=q^~oe&ge,e[5]=H^~ie&ye,e[6]=oe^~ge&E,e[7]=ie^~ye&x,e[8]=ge^~E&V,e[9]=ye^~x&D,e[10]=k^~G&M,e[11]=O^~U&L,e[12]=G^~M&ee,e[13]=U^~L&te,e[14]=M^~ee&he,e[15]=L^~te&de,e[16]=ee^~he&k,e[17]=te^~de&O,e[18]=he^~k&G,e[19]=de^~O&U,e[20]=T^~N&W,e[21]=R^~P&J,e[22]=N^~W&se,e[23]=P^~J&ae,e[24]=W^~se&ce,e[25]=J^~ae&ue,e[26]=se^~ce&T,e[27]=ae^~ue&R,e[28]=ce^~T&N,e[29]=ue^~R&P,e[30]=S^~I&j,e[31]=$^~_&Z,e[32]=I^~j&ne,e[33]=_^~Z&re,e[34]=j^~ne&pe,e[35]=Z^~re&me,e[36]=ne^~pe&S,e[37]=re^~me&$,e[38]=pe^~S&I,e[39]=me^~$&_,e[40]=z^~C&K,e[41]=A^~F&X,e[42]=C^~K&Y,e[43]=F^~X&Q,e[44]=K^~Y&le,e[45]=X^~Q&fe,e[46]=Y^~le&z,e[47]=Q^~fe&A,e[48]=le^~z&C,e[49]=fe^~A&F,e[0]^=Ot[2*t],e[1]^=Ot[2*t+1]}}function It(e){const t=[];for(let n=0;n<e.length;n+=4)t.push(e[n]|e[n+1]<<8|e[n+2]<<16|e[n+3]<<24);return t}var _t=new TextDecoder,Vt=new TextEncoder,Dt=/^(0x)?[0-9a-fA-F]*$/i;var Nt=class e{bytes;length;constructor(t,n){if(!t)throw new Error(`Bytes#constructor: constructor parameter is falsy: ${t}`);if(t instanceof e)this.bytes=t.bytes;else if("string"==typeof t){if(!Dt.test(t)||t.replace(/^0x/i,"").length%2!=0)throw new Error(`Bytes#constructor: invalid hex string: ${t}`);this.bytes=yt(t)}else if(t instanceof ArrayBuffer)this.bytes=new Uint8Array(t);else if(t instanceof Uint8Array)this.bytes=t;else{const e=t;if("object"!=typeof(r=e)||null===r||"function"!=typeof r.toHex)throw new Error("Bytes#constructor: unsupported type: "+typeof t);this.bytes=yt(e.toHex())}var r;if(this.length=this.bytes.length,void 0!==n)if(Array.isArray(n)){if(!n.includes(this.length))throw new Error(`Bytes#checkByteLength: bytes length is ${this.length} but expected ${n.join(" or ")}`)}else if(this.length!==n)throw new Error(`Bytes#checkByteLength: bytes length is ${this.length} but expected ${n}`)}static keccak256(t){return new e(St(new e(t).toUint8Array()))}static concat(...t){const n=t.map((t=>t instanceof e?t.toUint8Array():t)),r=n.reduce(((e,t)=>e+t.length),0),o=new Uint8Array(r);let i=0;for(const e of n)o.set(e,i),i+=e.length;return o}static fromUtf8(t){return new e(Vt.encode(t))}static fromSlice(t,n,r){return new e(void 0===r?t.slice(n):t.slice(n,n+r))}offset(e){return new Uint8Array(this.bytes.slice(e))}toUint8Array(){return new Uint8Array(this.bytes)}toHex(){return pt(this.bytes)}toBase64(){return Bt(this.bytes,wt)}toBase32(){return Et(this.bytes)}toString(){return this.toHex()}toUtf8(){return _t.decode(this.bytes)}toJSON(){return JSON.parse(this.toUtf8())}equals(t){return this.toHex()===new e(t).toHex()}represent(){return this.toHex()}},Pt=class extends Nt{static LENGTH=32;constructor(e){super(e,32)}},Ct=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n;function Ft(e){if(e<=0n||e>=Ct)throw new Error("Invalid private key");const t=lt.Point.BASE.multiply(e);return[t.x,t.y]}function Gt(e){const t=new Uint8Array(20),n=St(Nt.concat(mt(e[0],"BE"),mt(e[1],"BE")));return t.set(n.subarray(12)),t}var Ut=class extends Nt{static LENGTH=20;constructor(e){super(e,20)}toChecksum(){return function(e){const t=pt(e),n=pt(St(Uint8Array.from(t,(e=>e.charCodeAt(0)))));let r="0x";for(let o=0;o<t.length;o++)r+=parseInt(n.charAt(o),16)>7?t.charAt(o).toUpperCase():t.charAt(o);return r}(this.bytes)}},Mt=new Uint8Array(8).fill(255,0,8),Lt=class e extends Nt{static LENGTH=8;static MINUS_ONE=new e(Mt);constructor(e){super(e,8)}static fromBigInt(t){return new e(At(t,"BE"))}toBigInt(){return kt(this.bytes,"BE")}next(){return pt(this.bytes)===pt(Mt)?e.fromBigInt(0n):e.fromBigInt(this.toBigInt()+1n)}},jt=new TextEncoder,Zt=class e extends Nt{static LENGTH=32;constructor(e){super(e,32)}static fromString(t){return new e(St(jt.encode(t)))}},qt=class extends Nt{static LENGTH=32;constructor(e){super(e,32)}};function Ht(e,t){const n=lt.sign(St(e),t,{prehash:!1}),r=0===n.recovery?27n:28n;return[n.r,n.s,r]}function Wt(e,t,n,r){const o=27n===r?0:1,i=new lt.Signature(t,n,o).recoverPublicKey(St(e));return[i.x,i.y]}var Jt=class extends Nt{static LENGTH=64;constructor(e){const t=new Nt(e);if(33===t.length){const[e,n]=function(e){if(33!==e.length||2!==e[0]&&3!==e[0])throw new Error("Invalid compressed public key");const t=lt.Point.fromBytes(e);return[t.x,t.y]}(t.toUint8Array());super(Nt.concat(mt(e,"BE"),mt(n,"BE")),64)}else super(e,64)}address(){const e=gt(this.bytes.slice(0,32),"BE"),t=gt(this.bytes.slice(32,64),"BE");return new Ut(Gt([e,t]))}toCompressedUint8Array(){const e=gt(this.bytes.slice(0,32),"BE"),t=gt(this.bytes.slice(32,64),"BE");return n=[e,t],lt.Point.fromAffine({x:n[0],y:n[1]}).toBytes(!0);var n}toCompressedHex(){return pt(this.toCompressedUint8Array())}},Kt=new TextEncoder,Xt=Kt.encode("Ethereum Signed Message:\n32");function Yt(e){const t=e instanceof Uint8Array?e:Kt.encode(e);return Nt.concat(Xt,St(t))}var Qt=class e extends Nt{static LENGTH=65;constructor(e){super(e,65)}static fromSlice(t,n){return new e(t.slice(n,n+e.LENGTH))}recoverPublicKey(e){const t=gt(this.bytes.slice(0,32),"BE"),n=gt(this.bytes.slice(32,64),"BE"),r=BigInt(this.bytes[64]),[o,i]=Wt(Yt(e),t,n,r);return new Jt(Nt.concat(mt(o,"BE"),mt(i,"BE")))}isValid(e,t){return this.recoverPublicKey(e).address().equals(t)}},en=class extends Nt{static LENGTH=32;constructor(e){super(e,32)}publicKey(){const[e,t]=Ft(this.toBigInt());return new Jt(Nt.concat(mt(e,"BE"),mt(t,"BE")))}sign(e){const[t,n,r]=Ht(Yt(e),this.toBigInt());return new Qt(Nt.concat(mt(t,"BE"),mt(n,"BE"),new Uint8Array([Number(r)])))}toBigInt(){return gt(this.bytes,"BE")}};function tn(e){const t=vt(e.toUpperCase().slice(1),bt);const n=t[1];if(250!==n&&251!==n)throw new Error("Unknown codec");return t.slice(-32)}var nn=class e extends Nt{static LENGTH=32;constructor(e){"string"==typeof e&&e.startsWith("bah5")?super(tn(e),32):super(e,[32,64])}toCid(e){return`b${Et(Nt.concat(new Uint8Array([1]),new Uint8Array(["feed"===e?251:250]),new Uint8Array([1]),new Uint8Array([27]),new Uint8Array([32]))).replace(/=+$/,"")}${this.toBase32().replace(/=+$/,"")}`.toLowerCase()}static isValid(t){try{return new e(t),!0}catch{return!1}}},rn=class e extends Nt{static LENGTH=8;constructor(e){super(e,8)}static fromBigInt(t){return new e(At(t,"LE"))}toBigInt(){return kt(this.bytes,"LE")}static fromSlice(t,n){return new e(t.slice(n,n+e.LENGTH))}},on=new TextEncoder,sn=class e extends Nt{static LENGTH=32;constructor(e){super(e,32)}static fromString(t){return new e(St(on.encode(t)))}},an=class extends Nt{static LENGTH=32;constructor(e){super(e,32)}},cn=class{cursor=0;buffer;constructor(e){this.buffer=e}read(e){const t=this.buffer.subarray(this.cursor,this.cursor+e);return this.cursor+=e,t}max(){return this.buffer.length-this.cursor}},un=class{cursor=0;buffer;constructor(e){this.buffer=e}write(e){const t=Math.min(this.max(),e.max());return this.buffer.set(e.read(t),this.cursor),this.cursor+=t,t}max(){return this.buffer.length-this.cursor}};function ln(e,t,n){const r=new Uint8Array(n.length),o=new Uint8Array(36);o.set(e);for(let i=0,s=0;s<n.length;i++,s+=32){const e=t+i>>>0;o[32]=255&e,o[33]=e>>>8&255,o[34]=e>>>16&255,o[35]=e>>>24&255;const a=St(St(o)),c=Math.min(s+32,n.length);for(let t=s;t<c;t++)r[t]=n[t]^a[t-s]}return r}function fn(e,t){return ln(e,128,t)}function hn(e,t){return ln(e,0,t)}var dn=4096;function pn(e){const t=e.subarray(0,8),n=function(e){if(e.length>dn)throw new Error(`payload size ${e.length} exceeds maximum chunk payload size 4096`);const t=new Uint8Array(dn);t.set(e);let n=ft(t,32);for(;n.length>1;){const e=[];for(let t=0;t<n.length;t+=2)e.push(St(Nt.concat(n[t],n[t+1])));n=e}return n[0]}(e.subarray(8));return new nn(St(Nt.concat(t,n)))}yt("dc5b20847f43d67928f49cd4f85d696b5a7617b5");var mn=Zt.LENGTH,gn=Zt.LENGTH+65,yn=gn+rn.LENGTH,wn=(new TextEncoder).encode("Ethereum Signed Message:\n32");function bn(e,t){const n=St(Nt.concat(e,t));return Nt.concat(wn,n)}function vn(e,t,n){const[r,o,i]=Ht(bn(e,t),n);return Nt.concat(mt(r,"BE"),mt(o,"BE"),new Uint8Array([Number(i)]))}function Bn(e,t){const n=new Zt(e),r=new Ut(t);return new nn(St(Nt.concat(n.toUint8Array(),r.toUint8Array())))}function En(e,t,n){const r=new Zt(t),o=vn(r.toUint8Array(),e.address.toUint8Array(),n),i=new Ut(Gt(Ft(n))),s=Bn(r,i);return{data:Nt.concat(r.toUint8Array(),o,e.data),identifier:r,signature:new Qt(o),span:e.span,payload:e.payload,address:s,owner:i}}function xn(e,t){const n=e instanceof Nt?e.toUint8Array():e,r=new nn(t),o=new Zt(Nt.fromSlice(n,0,Zt.LENGTH)),i=n.slice(mn,mn+65),s=pn(n.slice(gn)),a=new Ut(function(e,t,n){const r=gt(n.subarray(0,32),"BE"),o=gt(n.subarray(32,64),"BE"),i=BigInt(n[64]);return Gt(Wt(bn(e,t),r,o,i))}(o.toUint8Array(),s.toUint8Array(),i)),c=Bn(o,a);if(!c.equals(r))throw new Error("SOC data does not match given address");const u=rn.fromSlice(n,gn),l=Nt.fromSlice(n,yn);return{data:n,identifier:o,signature:new Qt(i),span:u,payload:l,address:c,owner:a}}function Tn(e,t){if("string"==typeof e&&(e=Nt.fromUtf8(e)),e.length<1||e.length>4096)throw new RangeError(`payload size ${e.length} exceeds limits [1, 4096]`);const n=t?"bigint"==typeof t?rn.fromBigInt(t):t:rn.fromBigInt(BigInt(e.length)),r=new Nt(e),o=Nt.concat(n.toUint8Array(),r.toUint8Array()),i={data:o,span:n,payload:r,address:pn(o),toSingleOwnerChunk:(e,t)=>En(i,e,new en(t).toBigInt())};return i}function Rn(e){const t=new Nt(e);return Tn(t.toUint8Array().slice(rn.LENGTH),rn.fromSlice(t.toUint8Array(),0))}var zn=class{span;writer;constructor(e=0n){this.span=e,this.writer=new un(new Uint8Array(4096))}build(){return Nt.concat(At(this.span,"LE"),this.writer.buffer)}hash(){return pn(this.build())}encryptedHash(e){e||(e=new Uint8Array(32),crypto.getRandomValues(e));const t=fn(e,At(this.span,"LE")),n=hn(e,this.writer.buffer);return{address:pn(Nt.concat(t,n)),key:e}}},An=class e{static NOOP=async e=>[];refSize;encrypted;maxShards;chunks;counters=[1];pending=[[]];onBatch;onIntermediateChunk;hasParity=[!1];pendingEntries=[];constructor(e,t,n=!1,r){this.encrypted=n,this.refSize=n?64:32,this.maxShards=t??4096/this.refSize,this.chunks=[new zn],this.onBatch=e,this.onIntermediateChunk=r}static async root(t){const n=new e(e.NOOP);return await n.append(t),n.finalize()}static async encryptedRoot(t){const n=new e(e.NOOP,void 0,!0);await n.append(t);return(await n.finalize()).encryptedHash()}async append(e,t=0,n=0n){const r=new cn(e);for(;r.max()>0;){(0===this.chunks[t].writer.max()||n&&this.chunks[t].writer.max()<e.length)&&await this.elevate(t);const o=this.chunks[t].writer.write(r);n?this.chunks[t].span+=n:this.chunks[0].span+=BigInt(o)}}async elevate(e){this.counters[e]=(this.counters[e]+1)%(4096/this.refSize),this.pending[e]||(this.pending[e]=[]),await this.sealParities(e);const t=this.chunks[e].span;if(e>=1&&this.onIntermediateChunk&&(this.onIntermediateChunk(this.chunks[e],this.hasParity[e]??!1),this.hasParity[e]=!1),this.encrypted){const{address:n,key:r}=this.chunks[e].encryptedHash(),o=new Uint8Array(64);o.set(n.toUint8Array()),o.set(r,32),this.pending[e].push({entry:{chunk:this.chunks[e],key:r},ref:o,span:t})}else this.pending[e].push({entry:{chunk:this.chunks[e]},ref:this.chunks[e].hash().toUint8Array(),span:t});this.chunks[e]=new zn,this.pending[e].length>=this.maxShards&&await this.flushBatch(e)}async sealParities(e){const t=this.pendingEntries[e];if(!t?.length)return;this.pendingEntries[e]=[];const n=await this.onBatch(t);if(n.length>0){this.hasParity[e]=!0;for(const{chunk:t}of n)this.chunks[e].writer.write(new cn(t.hash().toUint8Array()))}}async flushBatch(e){this.chunks[e+1]||(this.chunks.push(new zn),this.counters.push(1),this.pending.push([]),this.hasParity.push(!1));const t=this.pending[e];this.pending[e]=[];for(const{ref:n,span:r}of t)await this.append(n,e+1,r);this.pendingEntries[e+1]||(this.pendingEntries[e+1]=[]),this.pendingEntries[e+1].push(...t.map((e=>e.entry))),t.length>=this.maxShards&&await this.sealParities(e+1)}async finalize(e=0){return this.pending[e]?.length&&await this.flushBatch(e),this.chunks[e+1]?1===this.counters[e]?(await this.elevate(e+1),await this.flushBatch(e+1),this.chunks[e+1]=this.chunks[e],this.finalize(e+1)):(await this.elevate(e),await this.flushBatch(e),this.finalize(e+1)):(await this.sealParities(e),e>=1&&this.onIntermediateChunk&&this.onIntermediateChunk(this.chunks[e],this.hasParity[e]??!1),this.chunks[e])}},kn=[[[],[]],[[95,69,47,29,15,6,2,1],[9,8,7,6,5,4,3,2]],[[105,96,87,78,70,62,54,47,40,33,27,21,16,11,7,4,2,1],[21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4]],[[93,88,83,78,74,69,64,60,55,51,46,42,38,34,30,27,23,20,17,14,11,9,6,4,3,2,1],[31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5]],[[37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1],[89,87,86,84,83,81,80,78,76,75,73,71,70,68,66,65,63,61,59,58,56,54,52,50,48,47,45,43,40,38,36,34,31,29,26,23,19]]],On=[[[],[]],[[47,34,23,14,7,3,1],[9,8,7,6,5,4,3]],[[52,48,43,39,35,31,27,23,20,16,13,10,8,5,3,2,1],[21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5]],[[46,44,41,39,37,34,32,30,27,25,23,21,19,17,15,13,11,10,8,7,5,4,3,2,1],[31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,6]],[[18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1],[87,84,81,78,75,71,68,65,61,58,54,50,47,43,38,34,29,23]]];function Sn(e,t,n){return e<=0||e>4?0:function(e,t){const[n,r]=e;for(let o=0;o<n.length;o++)if(t>=n[o])return r[o];return 0}(n?On[e]:kn[e],t)}function $n(e,t,n){return t<=0||e<=0?0:Sn(t,e,n)/e}var In={label:"medium",value:1,errorTolerance:.01},_n={label:"strong",value:2,errorTolerance:.05},Vn={label:"insane",value:3,errorTolerance:.1},Dn={label:"paranoid",value:4,errorTolerance:.5};function Nn(){return{medium:In,strong:_n,insane:Vn,paranoid:Dn}}function Pn(e){if("string"==typeof e)switch(e.toLowerCase()){case"medium":return In;case"strong":return _n;case"insane":return Vn;case"paranoid":return Dn;default:throw new Error(`Unknown redundancy level '${e}'`)}switch(e){case 1:return In;case 2:return _n;case 3:return Vn;case 4:return Dn;default:throw new Error(`Unknown redundancy level '${e}'`)}}function Cn(e,t){const n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e[r]^t[r%t.length];return n}new Uint8Array([0,0,1,25,2,50,26,198,3,223,51,238,27,104,199,75,4,100,224,14,52,141,239,129,28,193,105,248,200,8,76,113,5,138,101,47,225,36,15,33,53,147,142,218,240,18,130,69,29,181,194,125,106,39,249,185,201,154,9,120,77,228,114,166,6,191,139,98,102,221,48,253,226,152,37,179,16,145,34,136,54,208,148,206,143,150,219,189,241,210,19,92,131,56,70,64,30,66,182,163,195,72,126,110,107,58,40,84,250,133,186,61,202,94,155,159,10,21,121,43,78,212,229,172,115,243,167,87,7,112,192,247,140,128,99,13,103,74,222,237,49,197,254,24,227,165,153,119,38,184,180,124,17,68,146,217,35,32,137,46,55,63,209,91,149,188,207,205,144,135,151,178,220,252,190,97,242,86,211,171,20,42,93,158,132,60,57,83,71,109,65,162,31,45,67,216,183,123,164,118,196,23,73,236,127,12,111,246,108,161,59,82,41,157,85,170,251,96,134,177,187,204,62,90,203,89,95,176,156,169,160,81,11,245,22,235,122,117,44,215,79,174,213,233,230,231,173,232,116,214,244,234,168,80,88,175]),new Uint8Array([1,2,4,8,16,32,64,128,29,58,116,232,205,135,19,38,76,152,45,90,180,117,234,201,143,3,6,12,24,48,96,192,157,39,78,156,37,74,148,53,106,212,181,119,238,193,159,35,70,140,5,10,20,40,80,160,93,186,105,210,185,111,222,161,95,190,97,194,153,47,94,188,101,202,137,15,30,60,120,240,253,231,211,187,107,214,177,127,254,225,223,163,91,182,113,226,217,175,67,134,17,34,68,136,13,26,52,104,208,189,103,206,129,31,62,124,248,237,199,147,59,118,236,197,151,51,102,204,133,23,46,92,184,109,218,169,79,158,33,66,132,21,42,84,168,77,154,41,82,164,85,170,73,146,57,114,228,213,183,115,230,209,191,99,198,145,63,126,252,229,215,179,123,246,241,255,227,219,171,75,150,49,98,196,149,55,110,220,165,87,174,65,130,25,50,100,200,141,7,14,28,56,112,224,221,167,83,166,81,162,89,178,121,242,249,239,195,155,43,86,172,69,138,9,18,36,72,144,61,122,244,245,247,243,251,235,203,139,11,22,44,88,176,125,250,233,207,131,27,54,108,216,173,71,142]);var Fn=new TextEncoder,Gn=new TextDecoder,Un=new Uint8Array([47]),Mn=yt("5768b3b6a7db56d21d1abff40d41cebfc83448fed8d7e9b06ec0d3b073f28f7b");function Ln(e,t){const n=Math.floor(t/8),r=t%8;e[n]=e[n]|1<<r}function jn(e,t){const n=t%8;return 1==(e[Math.floor(t/8)]>>n&1)}var Zn=class e{obfuscationKey=new Uint8Array(32);selfAddress=null;targetAddress=new Uint8Array(32);metadata=null;path=new Uint8Array(0);forks=new Map;parent=null;type=null;encrypt=!1;constructor(e){e?.encrypt&&(this.encrypt=!0),e?.targetAddress?this.targetAddress=e.targetAddress:this.encrypt&&(this.targetAddress=new Uint8Array(64)),e?.selfAddress&&(this.selfAddress=e.selfAddress),e?.metadata&&(this.metadata=e.metadata),e?.obfuscationKey&&(this.obfuscationKey=e.obfuscationKey),e?.path&&(this.path=e.path),e?.parent&&(this.parent=e.parent),this.type=e?.type??null}get fullPath(){return Nt.concat(this.parent?.fullPath??new Uint8Array(0),this.path)}get fullPathString(){return Gn.decode(this.fullPath)}async marshal(){for(const a of this.forks.values())a.node.selfAddress||(a.node.selfAddress=(await a.node.calculateSelfAddress()).toUint8Array());this.encrypt&&ht(this.obfuscationKey,new Uint8Array(32))&&(this.obfuscationKey=new Uint8Array(32),crypto.getRandomValues(this.obfuscationKey));const e=!ht(this.targetAddress,new Uint8Array(this.targetAddress.length));let t=0;if(e)t=this.targetAddress.length;else for(const a of this.forks.values())if(a.node.selfAddress&&a.node.selfAddress.length>0){t=a.node.selfAddress.length;break}const n=new Uint8Array(32);n.set(Mn,0),n.set(xt(t),31);const r=e?this.targetAddress:new Uint8Array(t),o=new Uint8Array(32);for(const a of this.forks.keys())Ln(o,a);const i=[];for(let a=0;a<256;a++)jn(o,a)&&i.push(this.forks.get(a).marshal());const s=Cn(Nt.concat(n,r,o,...i),this.obfuscationKey);return Nt.concat(this.obfuscationKey,s)}static unmarshalFromData(t,n){if(t.length<64)throw new Error("MantarayNode#unmarshalFromData data too short");const r=t.subarray(0,32),o=Cn(t.subarray(32),r),i=new cn(o);if(!ht(i.read(31),Mn.slice(0,31)))throw new Error("MantarayNode#unmarshalFromData invalid version hash");const s=Tt(i.read(1)),a=i.read(s),c=new e({selfAddress:n,targetAddress:a,obfuscationKey:r}),u=i.read(32),l=0===s?32:s;for(let e=0;e<256;e++)if(jn(u,e)){const t=Wn.unmarshal(i,l);c.forks.set(e,t),t.node.parent=c}return c}addFork(t,n,r){this.selfAddress=null,this.type=null,t=t instanceof Uint8Array?t:Fn.encode(t);let o=this;for(;t.length;){const i=t.slice(0,30),s=0===(t=t.slice(30)).length,[a,c]=o.findClosest(i),u=i.slice(c.length);if(c.length&&(o=a),!u.length)continue;const l=new Wn(u,new e({targetAddress:s?new nn(n).toUint8Array():void 0,metadata:s?r:void 0,path:u,encrypt:this.encrypt})),f=a.forks.get(u[0]);if(f){const e=Wn.split(l,f);o.forks.set(u[0],e),e.node.parent=o}else o.forks.set(u[0],l),l.node.parent=o;o.selfAddress=null,o.type=null,o=l.node}}removeFork(e){if(this.selfAddress=null,this.type=null,0===(e=e instanceof Uint8Array?e:Fn.encode(e)).length)throw new Error("MantarayNode#removeFork path cannot be empty");const t=this.find(e);if(!t)throw new Error("MantarayNode#removeFork fork not found");const[n,r]=this.findClosest(e.slice(0,e.length-1));n.forks.delete(e.slice(r.length)[0]);for(const o of t.forks.values())n.addFork(Nt.concat(t.path,o.prefix),o.node.targetAddress,o.node.metadata)}async calculateSelfAddress(){if(this.selfAddress)return new nn(this.selfAddress);if(this.encrypt)throw new Error("MantarayNode#calculateSelfAddress is not supported for encrypted nodes - use saveRecursively");return(await An.root(await this.marshal())).hash()}async saveRecursively(e){for(const r of this.forks.values())await r.node.saveRecursively(e);const t=new An((async t=>{for(const{chunk:n,key:r}of t)await e(n,r);return[]}),void 0,this.encrypt);await t.append(await this.marshal());const n=await t.finalize();if(this.encrypt){const{address:t,key:r}=n.encryptedHash();return await e(n,r),this.selfAddress=Nt.concat(t.toUint8Array(),r),{reference:this.selfAddress,rootChunk:n,encryptionKey:r}}return await e(n),this.selfAddress=n.hash().toUint8Array(),{reference:this.selfAddress,rootChunk:n}}find(e){const t=e instanceof Uint8Array?e:Fn.encode(e),[n,r]=this.findClosest(t);return r.length===t.length?n:null}findClosest(e,t=new Uint8Array){if(0===(e=e instanceof Uint8Array?e:Fn.encode(e)).length)return[this,t];const n=this.forks.get(e[0]);return n&&dt(n.prefix,e).length===n.prefix.length?n.node.findClosest(e.slice(n.prefix.length),Nt.concat(t,n.prefix)):[this,t]}collect(e=[]){for(const t of this.forks.values())ht(t.node.targetAddress,new Uint8Array(t.node.targetAddress.length))||e.push(t.node),t.node.collect(e);return e}collectAndMap(){const e={};for(const t of this.collect())e[t.fullPathString]=new nn(t.targetAddress).toHex();return e}determineType(){let e=0;const t=new Uint8Array(this.targetAddress.length);return ht(this.targetAddress,t)&&0!==this.forks.size||(e|=2),this.forks.size>0&&(e|=4),function(e,t,n=0){for(let r=n;r<e.length;r++)for(let n=0;n<t.length&&e[r+n]===t[n];n++)if(n===t.length-1)return r;return-1}(this.path,Un)>0&&(e|=8),this.metadata&&(e|=16),e}},qn=new TextEncoder,Hn=new TextDecoder;var Wn=class e{prefix;node;constructor(e,t){this.prefix=e,this.node=t}static split(t,n){const r=dt(t.prefix,n.prefix);if(r.length===t.prefix.length){const e=n.prefix.slice(r.length);return n.node.path=n.prefix.slice(r.length),n.prefix=n.prefix.slice(r.length),n.node.parent=t.node,t.node.forks.set(e[0],n),t}if(r.length===n.prefix.length){const e=t.prefix.slice(r.length);return t.node.path=t.prefix.slice(r.length),t.prefix=t.prefix.slice(r.length),t.node.parent=n.node,n.node.forks.set(e[0],t),n}const o=new Zn({path:r,encrypt:t.node.encrypt}),i=new e(t.prefix.slice(r.length),t.node),s=new e(n.prefix.slice(r.length),n.node);return t.node.path=t.prefix.slice(r.length),n.node.path=n.prefix.slice(r.length),t.prefix=t.prefix.slice(r.length),n.prefix=n.prefix.slice(r.length),o.forks.set(i.prefix[0],i),o.forks.set(s.prefix[0],s),i.node.parent=o,s.node.parent=o,new e(r,o)}marshal(){if(!this.node.selfAddress)throw new Error("Fork#marshal node.selfAddress is not set");const e=[];if(e.push(new Uint8Array([this.node.type??this.node.determineType()])),e.push(xt(this.prefix.length)),e.push(this.prefix),this.prefix.length<30&&e.push(new Uint8Array(30-this.prefix.length)),e.push(this.node.selfAddress),this.node.metadata){const t=function(e,t,n){const r=e.length%t;if(0===r)return e;const o=new Uint8Array(e.length+t-r).fill(n);return o.set(e,0),o}(Nt.concat(new Uint8Array([0,0]),qn.encode(JSON.stringify(this.node.metadata))),32,10);t.set(function(e,t){const n=new ArrayBuffer(2);return new DataView(n).setUint16(0,e,"LE"===t),new Uint8Array(n)}(t.length-2,"BE"),0),e.push(t)}return Nt.concat(...e)}static unmarshal(t,n){const r=Tt(t.read(1)),o=Tt(t.read(1)),i=t.read(o);o<30&&t.read(30-o);const s=t.read(n);let a;if(function(e,t){return(e&t)===t}(r,16)){const e=Rt(t.read(2),"BE");if(e>t.max())throw new Error("Fork#unmarshal not enough bytes for metadata");a=JSON.parse(Hn.decode(t.read(e)))}return new e(i,new Zn({selfAddress:s,metadata:a,path:i,type:r}))}};function Jn(e,t,n){return e/Math.pow(2,t-n)}function Kn(e){return 4096*2**e}var Xn=.9;function Yn(e){const t=e.match(/^([\d.]+)\s*(B|kB|MB|GB|TB|PB)$/);if(!t)throw new Error(`Invalid size format: ${e}`);return Math.ceil(parseFloat(t[1])*{B:1,kB:1e3,MB:1e6,GB:1e3**3,TB:1e3**4,PB:1e3**5}[t[2]])}var Qn=[[17,"0.00004089 GB"],[18,"0.00609 GB"],[19,"0.10249 GB"],[20,"0.62891 GB"],[21,"2.38 GB"],[22,"7.07 GB"],[23,"18.24 GB"],[24,"43.04 GB"],[25,"96.5 GB"],[26,"208.52 GB"],[27,"435.98 GB"],[28,"908.81 GB"],[29,"1870 GB"],[30,"3810 GB"],[31,"7730 GB"],[32,"15610 GB"],[33,"31430 GB"],[34,"63150 GB"]],er=[[[17,"44.70 kB"],[18,"6.66 MB"],[19,"112.06 MB"],[20,"687.62 MB"],[21,"2.60 GB"],[22,"7.73 GB"],[23,"19.94 GB"],[24,"47.06 GB"],[25,"105.51 GB"],[26,"227.98 GB"],[27,"476.68 GB"],[28,"993.65 GB"],[29,"2.04 TB"],[30,"4.17 TB"],[31,"8.45 TB"],[32,"17.07 TB"],[33,"34.36 TB"],[34,"69.04 TB"],[35,"138.54 TB"],[36,"277.72 TB"],[37,"556.35 TB"],[38,"1.11 PB"],[39,"2.23 PB"],[40,"4.46 PB"],[41,"8.93 PB"]],[[17,"41.56 kB"],[18,"6.19 MB"],[19,"104.18 MB"],[20,"639.27 MB"],[21,"2.41 GB"],[22,"7.18 GB"],[23,"18.54 GB"],[24,"43.75 GB"],[25,"98.09 GB"],[26,"211.95 GB"],[27,"443.16 GB"],[28,"923.78 GB"],[29,"1.90 TB"],[30,"3.88 TB"],[31,"7.86 TB"],[32,"15.87 TB"],[33,"31.94 TB"],[34,"64.19 TB"],[35,"128.80 TB"],[36,"258.19 TB"],[37,"517.23 TB"],[38,"1.04 PB"],[39,"2.07 PB"],[40,"4.15 PB"],[41,"8.30 PB"]],[[17,"37.37 kB"],[18,"5.57 MB"],[19,"93.68 MB"],[20,"574.81 MB"],[21,"2.17 GB"],[22,"6.46 GB"],[23,"16.67 GB"],[24,"39.34 GB"],[25,"88.20 GB"],[26,"190.58 GB"],[27,"398.47 GB"],[28,"830.63 GB"],[29,"1.71 TB"],[30,"3.49 TB"],[31,"7.07 TB"],[32,"14.27 TB"],[33,"28.72 TB"],[34,"57.71 TB"],[35,"115.81 TB"],[36,"232.16 TB"],[37,"465.07 TB"],[38,"931.23 TB"],[39,"1.86 PB"],[40,"3.73 PB"],[41,"7.46 PB"]],[[17,"33.88 kB"],[18,"5.05 MB"],[19,"84.92 MB"],[20,"521.09 MB"],[21,"1.97 GB"],[22,"5.86 GB"],[23,"15.11 GB"],[24,"35.66 GB"],[25,"79.96 GB"],[26,"172.77 GB"],[27,"361.23 GB"],[28,"753.00 GB"],[29,"1.55 TB"],[30,"3.16 TB"],[31,"6.41 TB"],[32,"12.93 TB"],[33,"26.04 TB"],[34,"52.32 TB"],[35,"104.99 TB"],[36,"210.46 TB"],[37,"421.61 TB"],[38,"844.20 TB"],[39,"1.69 PB"],[40,"3.38 PB"],[41,"6.77 PB"]],[[17,"13.27 kB"],[18,"1.98 MB"],[19,"33.27 MB"],[20,"204.14 MB"],[21,"771.13 MB"],[22,"2.29 GB"],[23,"5.92 GB"],[24,"13.97 GB"],[25,"31.32 GB"],[26,"67.68 GB"],[27,"141.51 GB"],[28,"294.99 GB"],[29,"606.90 GB"],[30,"1.24 TB"],[31,"2.51 TB"],[32,"5.07 TB"],[33,"10.20 TB"],[34,"20.50 TB"],[35,"41.13 TB"],[36,"82.45 TB"],[37,"165.17 TB"],[38,"330.72 TB"],[39,"661.97 TB"],[40,"1.32 PB"],[41,"2.65 PB"]]],tr=[[[17,"44.35 kB"],[18,"6.61 MB"],[19,"111.18 MB"],[20,"682.21 MB"],[21,"2.58 GB"],[22,"7.67 GB"],[23,"19.78 GB"],[24,"46.69 GB"],[25,"104.68 GB"],[26,"226.19 GB"],[27,"472.93 GB"],[28,"985.83 GB"],[29,"2.03 TB"],[30,"4.14 TB"],[31,"8.39 TB"],[32,"16.93 TB"],[33,"34.09 TB"],[34,"68.50 TB"],[35,"137.45 TB"],[36,"275.53 TB"],[37,"551.97 TB"],[38,"1.11 PB"],[39,"2.21 PB"],[40,"4.43 PB"],[41,"8.86 PB"]],[[17,"40.89 kB"],[18,"6.09 MB"],[19,"102.49 MB"],[20,"628.91 MB"],[21,"2.38 GB"],[22,"7.07 GB"],[23,"18.24 GB"],[24,"43.04 GB"],[25,"96.50 GB"],[26,"208.52 GB"],[27,"435.98 GB"],[28,"908.81 GB"],[29,"1.87 TB"],[30,"3.81 TB"],[31,"7.73 TB"],[32,"15.61 TB"],[33,"31.43 TB"],[34,"63.15 TB"],[35,"126.71 TB"],[36,"254.01 TB"],[37,"508.85 TB"],[38,"1.02 PB"],[39,"2.04 PB"],[40,"4.08 PB"],[41,"8.17 PB"]],[[17,"36.73 kB"],[18,"5.47 MB"],[19,"92.07 MB"],[20,"564.95 MB"],[21,"2.13 GB"],[22,"6.35 GB"],[23,"16.38 GB"],[24,"38.66 GB"],[25,"86.69 GB"],[26,"187.31 GB"],[27,"391.64 GB"],[28,"816.39 GB"],[29,"1.68 TB"],[30,"3.43 TB"],[31,"6.94 TB"],[32,"14.02 TB"],[33,"28.23 TB"],[34,"56.72 TB"],[35,"113.82 TB"],[36,"228.18 TB"],[37,"457.10 TB"],[38,"915.26 TB"],[39,"1.83 PB"],[40,"3.67 PB"],[41,"7.34 PB"]],[[17,"33.26 kB"],[18,"4.96 MB"],[19,"83.38 MB"],[20,"511.65 MB"],[21,"1.93 GB"],[22,"5.75 GB"],[23,"14.84 GB"],[24,"35.02 GB"],[25,"78.51 GB"],[26,"169.64 GB"],[27,"354.69 GB"],[28,"739.37 GB"],[29,"1.52 TB"],[30,"3.10 TB"],[31,"6.29 TB"],[32,"12.70 TB"],[33,"25.57 TB"],[34,"51.37 TB"],[35,"103.08 TB"],[36,"206.65 TB"],[37,"413.98 TB"],[38,"828.91 TB"],[39,"1.66 PB"],[40,"3.32 PB"],[41,"6.64 PB"]],[[17,"13.17 kB"],[18,"1.96 MB"],[19,"33.01 MB"],[20,"202.53 MB"],[21,"765.05 MB"],[22,"2.28 GB"],[23,"5.87 GB"],[24,"13.86 GB"],[25,"31.08 GB"],[26,"67.15 GB"],[27,"140.40 GB"],[28,"292.67 GB"],[29,"602.12 GB"],[30,"1.23 TB"],[31,"2.49 TB"],[32,"5.03 TB"],[33,"10.12 TB"],[34,"20.34 TB"],[35,"40.80 TB"],[36,"81.80 TB"],[37,"163.87 TB"],[38,"328.11 TB"],[39,"656.76 TB"],[40,"1.31 PB"],[41,"2.63 PB"]]];function nr(e,t,n){if(e<17)return 0;if(void 0!==t&&void 0!==n){const r=(t?tr:er)[n],o=r?.find((([t])=>t===e));if(o)return Yn(o[1])}else{const t=Qn.find((([t])=>t===e));if(t)return Yn(t[1])}return Math.ceil(Kn(e)*Xn)}function rr(e,t){const n=new Map;for(let r=17;r<35;r++)n.set(r,nr(r,e,t));return n}function or(e){return function(e,t,n,r){if(65!==e.length)throw new Error("invalid signature length");if(32!==t.length)throw new Error("invalid batch ID length");if(8!==n.length)throw new Error("invalid timestamp length");if(8!==r.length)throw new Error("invalid index length");return new Nt(Nt.concat(t,r,n,e))}(e.signature.toUint8Array(),e.batchId.toUint8Array(),e.timestamp,e.index)}var ir,sr=class e{signer;batchId;buckets;depth;maxSlot;constructor(e,t,n,r){this.signer=e,this.batchId=t,this.buckets=n,this.depth=r,this.maxSlot=2**(r-16)}static fromBlank(t,n,r){return new e(new en(t),new Pt(n),new Uint32Array(65536),r)}static fromState(t,n,r,o){return new e(new en(t),new Pt(n),r,o)}stamp(e,t){const n=Rt(e,"BE"),r=this.buckets[n];if(r>=this.maxSlot)throw new Error("Stamper#stamp bucket is full");return this.buckets[n]=r+1,function(e,t,n,r,o=Date.now()){const i=new en(e),s=new Pt(t),a=Rt(n,"BE"),c=Nt.concat(zt(a,"BE"),zt(r,"BE")),u=At(1000000n*BigInt(o),"BE"),l=i.sign(Nt.concat(n,s.toUint8Array(),c,u));return{batchId:s,index:c,issuer:i.publicKey().address(),signature:l,timestamp:u}}(this.signer,this.batchId,e,r,t)}getState(){return this.buckets}},ar=n(20);function cr(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:s,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);const o=s.prototype,i=Object.keys(o);for(let e=0;e<i.length;e++){const t=i[e];t in n||(n[t]=o[t].bind(n))}}const o=n?.Parent??Object;class i extends o{}function s(e){var t;const o=n?.Parent?new i:this;r(o,e),(t=o._zod).deferred??(t.deferred=[]);for(const n of o._zod.deferred)n();return o}return Object.defineProperty(i,"name",{value:e}),Object.defineProperty(s,"init",{value:r}),Object.defineProperty(s,Symbol.hasInstance,{value:t=>!!(n?.Parent&&t instanceof n.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}Symbol("zod_brand");class ur extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class lr extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}(ir=globalThis).__zod_globalConfig??(ir.__zod_globalConfig={});const fr=globalThis.__zod_globalConfig;function hr(e){return e&&Object.assign(fr,e),fr}const dr=/^[cC][0-9a-z]{6,}$/,pr=/^[0-9a-z]+$/,mr=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,gr=/^[0-9a-vA-V]{20}$/,yr=/^[A-Za-z0-9]{27}$/,wr=/^[a-zA-Z0-9_-]{21}$/,br=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,vr=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Br=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Er=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;const xr=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Tr=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Rr=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,zr=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Ar=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,kr=/^[A-Za-z0-9_-]*$/,Or=/^https?$/,Sr=/^\+[1-9]\d{6,14}$/,$r="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Ir=new RegExp(`^${$r}$`);function _r(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof e.precision?-1===e.precision?`${t}`:0===e.precision?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}const Vr=/^-?\d+n?$/,Dr=/^-?\d+$/,Nr=/^-?\d+(?:\.\d+)?$/,Pr=/^(?:true|false)$/i,Cr=/^[^A-Z]*$/,Fr=/^[^a-z]*$/;function Gr(e){const t=Object.values(e).filter((e=>"number"==typeof e));return Object.entries(e).filter((([e,n])=>-1===t.indexOf(+e))).map((([e,t])=>t))}function Ur(e,t){return"bigint"==typeof t?t.toString():t}function Mr(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Lr(e){return null==e}function jr(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}const Zr=Symbol("evaluating");function qr(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Zr)return void 0===r&&(r=Zr,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Hr(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Wr(...e){const t={};for(const n of e){const e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Jr(e){return JSON.stringify(e)}const Kr="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Xr(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}const Yr=Mr((()=>{if(fr.jitless)return!1;if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}}));function Qr(e){if(!1===Xr(e))return!1;const t=e.constructor;if(void 0===t)return!0;if("function"!=typeof t)return!0;const n=t.prototype;return!1!==Xr(n)&&!1!==Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")}function eo(e){return Qr(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const to=new Set(["string","number","symbol"]);function no(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ro(e,t,n){const r=new e._zod.constr(t??e._zod.def);return t&&!n?.parent||(r._zod.parent=e),r}function oo(e){const t=e;if(!t)return{};if("string"==typeof t)return{error:()=>t};if(void 0!==t?.message){if(void 0!==t?.error)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,"string"==typeof t.error?{...t,error:()=>t.error}:t}const io={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function so(e,t=0){if(!0===e.aborted)return!0;for(let n=t;n<e.issues.length;n++)if(!0!==e.issues[n]?.continue)return!0;return!1}function ao(e,t=0){if(!0===e.aborted)return!0;for(let n=t;n<e.issues.length;n++)if(!1===e.issues[n]?.continue)return!0;return!1}function co(e,t){return t.map((t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t}))}function uo(e){return"string"==typeof e?e:e?.message}function lo(e,t,n){const r=e.message?e.message:uo(e.inst?._zod.def?.error?.(e))??uo(t?.error?.(e))??uo(n.customError?.(e))??uo(n.localeError?.(e))??"Invalid input",{inst:o,continue:i,input:s,...a}=e;return a.path??(a.path=[]),a.message=r,t?.reportInput&&(a.input=s),a}function fo(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function ho(...e){const[t,n,r]=e;return"string"==typeof t?{message:t,code:"custom",input:n,inst:r}:{...t}}const po=cr("$ZodCheck",((e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])})),mo={number:"number",bigint:"bigint",object:"date"},go=cr("$ZodCheckLessThan",((e,t)=>{po.init(e,t);const n=mo[typeof t.value];e._zod.onattach.push((e=>{const n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)})),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:"object"==typeof t.value?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}})),yo=cr("$ZodCheckGreaterThan",((e,t)=>{po.init(e,t);const n=mo[typeof t.value];e._zod.onattach.push((e=>{const n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)})),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:"object"==typeof t.value?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}})),wo=cr("$ZodCheckMultipleOf",((e,t)=>{po.init(e,t),e._zod.onattach.push((e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)})),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof n.value?n.value%t.value===BigInt(0):0===function(e,t){const n=e/t,r=Math.round(n),o=Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<o?0:n-r}(n.value,t.value))||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}})),bo=cr("$ZodCheckNumberFormat",((e,t)=>{po.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,i]=io[t.format];e._zod.onattach.push((e=>{const r=e._zod.bag;r.format=t.format,r.minimum=o,r.maximum=i,n&&(r.pattern=Dr)})),e._zod.check=s=>{const a=s.value;if(n){if(!Number.isInteger(a))return void s.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});if(!Number.isSafeInteger(a))return void(a>0?s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}))}a<o&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>i&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}})),vo=cr("$ZodCheckMaxLength",((e,t)=>{var n;po.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!Lr(t)&&void 0!==t.length}),e._zod.onattach.push((e=>{const n=e._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<n&&(e._zod.bag.maximum=t.maximum)})),e._zod.check=n=>{const r=n.value;if(r.length<=t.maximum)return;const o=fo(r);n.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}})),Bo=cr("$ZodCheckMinLength",((e,t)=>{var n;po.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!Lr(t)&&void 0!==t.length}),e._zod.onattach.push((e=>{const n=e._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>n&&(e._zod.bag.minimum=t.minimum)})),e._zod.check=n=>{const r=n.value;if(r.length>=t.minimum)return;const o=fo(r);n.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}})),Eo=cr("$ZodCheckLengthEquals",((e,t)=>{var n;po.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!Lr(t)&&void 0!==t.length}),e._zod.onattach.push((e=>{const n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length})),e._zod.check=n=>{const r=n.value,o=r.length;if(o===t.length)return;const i=fo(r),s=o>t.length;n.issues.push({origin:i,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}})),xo=cr("$ZodCheckStringFormat",((e,t)=>{var n,r;po.init(e,t),e._zod.onattach.push((e=>{const n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??(n.patterns=new Set),n.patterns.add(t.pattern))})),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})})),To=cr("$ZodCheckRegex",((e,t)=>{xo.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}})),Ro=cr("$ZodCheckLowerCase",((e,t)=>{t.pattern??(t.pattern=Cr),xo.init(e,t)})),zo=cr("$ZodCheckUpperCase",((e,t)=>{t.pattern??(t.pattern=Fr),xo.init(e,t)})),Ao=cr("$ZodCheckIncludes",((e,t)=>{po.init(e,t);const n=no(t.includes),r=new RegExp("number"==typeof t.position?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push((e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(r)})),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}})),ko=cr("$ZodCheckStartsWith",((e,t)=>{po.init(e,t);const n=new RegExp(`^${no(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push((e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(n)})),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}})),Oo=cr("$ZodCheckEndsWith",((e,t)=>{po.init(e,t);const n=new RegExp(`.*${no(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push((e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(n)})),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}));const So=cr("$ZodCheckOverwrite",((e,t)=>{po.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}));class $o{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if("function"==typeof e)return e(this,{execution:"sync"}),void e(this,{execution:"async"});const t=e.split("\n").filter((e=>e)),n=Math.min(...t.map((e=>e.length-e.trimStart().length))),r=t.map((e=>e.slice(n))).map((e=>" ".repeat(2*this.indent)+e));for(const o of r)this.content.push(o)}compile(){const e=Function,t=this?.args;return new e(...t,[...(this?.content??[""]).map((e=>` ${e}`))].join("\n"))}}const Io=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Ur,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},_o=cr("$ZodError",Io),Vo=cr("$ZodError",Io,{Parent:Error});const Do=e=>(t,n,r,o)=>{const i=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw new ur;if(s.issues.length){const t=new(o?.Err??e)(s.issues.map((e=>lo(e,i,hr()))));throw Kr(t,o?.callee),t}return s.value},No=Do(Vo),Po=e=>async(t,n,r,o)=>{const i=r?{...r,async:!0}:{async:!0};let s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise&&(s=await s),s.issues.length){const t=new(o?.Err??e)(s.issues.map((e=>lo(e,i,hr()))));throw Kr(t,o?.callee),t}return s.value},Co=Po(Vo),Fo=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new ur;return i.issues.length?{success:!1,error:new(e??_o)(i.issues.map((e=>lo(e,o,hr()))))}:{success:!0,data:i.value}},Go=Fo(Vo),Uo=e=>async(t,n,r)=>{const o=r?{...r,async:!0}:{async:!0};let i=t._zod.run({value:n,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map((e=>lo(e,o,hr()))))}:{success:!0,data:i.value}},Mo=Uo(Vo),Lo=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Do(e)(t,n,o)},jo=e=>(t,n,r)=>Do(e)(t,n,r),Zo=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Po(e)(t,n,o)},qo=e=>async(t,n,r)=>Po(e)(t,n,r),Ho=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Fo(e)(t,n,o)},Wo=e=>(t,n,r)=>Fo(e)(t,n,r),Jo=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Uo(e)(t,n,o)},Ko=e=>async(t,n,r)=>Uo(e)(t,n,r),Xo={major:4,minor:4,patch:3};const Yo=cr("$ZodType",((e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Xo;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const o of r)for(const t of o._zod.onattach)t(e);if(0===r.length)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push((()=>{e._zod.run=e._zod.parse}));else{const t=(e,t,n)=>{let r,o=so(e);for(const i of t){if(i._zod.def.when){if(ao(e))continue;if(!i._zod.def.when(e))continue}else if(o)continue;const t=e.issues.length,s=i._zod.check(e);if(s instanceof Promise&&!1===n?.async)throw new ur;if(r||s instanceof Promise)r=(r??Promise.resolve()).then((async()=>{await s;e.issues.length!==t&&(o||(o=so(e,t)))}));else{if(e.issues.length===t)continue;o||(o=so(e,t))}}return r?r.then((()=>e)):e},n=(n,o,i)=>{if(so(n))return n.aborted=!0,n;const s=t(o,r,i);if(s instanceof Promise){if(!1===i.async)throw new ur;return s.then((t=>e._zod.parse(t,i)))}return e._zod.parse(s,i)};e._zod.run=(o,i)=>{if(i.skipChecks)return e._zod.parse(o,i);if("backward"===i.direction){const t=e._zod.parse({value:o.value,issues:[]},{...i,skipChecks:!0});return t instanceof Promise?t.then((e=>n(e,o,i))):n(t,o,i)}const s=e._zod.parse(o,i);if(s instanceof Promise){if(!1===i.async)throw new ur;return s.then((e=>t(e,r,i)))}return t(s,r,i)}}qr(e,"~standard",(()=>({validate:t=>{try{const n=Go(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch(n){return Mo(e,t).then((e=>e.success?{value:e.data}:{issues:e.error?.issues}))}},vendor:"zod",version:1})))})),Qo=cr("$ZodString",((e,t)=>{var n;Yo.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??(n=e._zod.bag,new RegExp(`^${n?`[\\s\\S]{${n?.minimum??0},${n?.maximum??""}}`:"[\\s\\S]*"}$`)),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch(r){}return"string"==typeof n.value||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}})),ei=cr("$ZodStringFormat",((e,t)=>{xo.init(e,t),Qo.init(e,t)})),ti=cr("$ZodGUID",((e,t)=>{t.pattern??(t.pattern=vr),ei.init(e,t)})),ni=cr("$ZodUUID",((e,t)=>{if(t.version){const e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(void 0===e)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Br(e))}else t.pattern??(t.pattern=Br());ei.init(e,t)})),ri=cr("$ZodEmail",((e,t)=>{t.pattern??(t.pattern=Er),ei.init(e,t)})),oi=cr("$ZodURL",((e,t)=>{ei.init(e,t),e._zod.check=n=>{try{const r=n.value.trim();if(!t.normalize&&t.protocol?.source===Or.source&&!/^https?:\/\//i.test(r))return void n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});const o=new URL(r);return t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),void(t.normalize?n.value=o.href:n.value=r)}catch(r){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}})),ii=cr("$ZodEmoji",((e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),ei.init(e,t)})),si=cr("$ZodNanoID",((e,t)=>{t.pattern??(t.pattern=wr),ei.init(e,t)})),ai=cr("$ZodCUID",((e,t)=>{t.pattern??(t.pattern=dr),ei.init(e,t)})),ci=cr("$ZodCUID2",((e,t)=>{t.pattern??(t.pattern=pr),ei.init(e,t)})),ui=cr("$ZodULID",((e,t)=>{t.pattern??(t.pattern=mr),ei.init(e,t)})),li=cr("$ZodXID",((e,t)=>{t.pattern??(t.pattern=gr),ei.init(e,t)})),fi=cr("$ZodKSUID",((e,t)=>{t.pattern??(t.pattern=yr),ei.init(e,t)})),hi=cr("$ZodISODateTime",((e,t)=>{t.pattern??(t.pattern=function(e){const t=_r({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${$r}T(?:${r})$`)}(t)),ei.init(e,t)})),di=cr("$ZodISODate",((e,t)=>{t.pattern??(t.pattern=Ir),ei.init(e,t)})),pi=cr("$ZodISOTime",((e,t)=>{t.pattern??(t.pattern=new RegExp(`^${_r(t)}$`)),ei.init(e,t)})),mi=cr("$ZodISODuration",((e,t)=>{t.pattern??(t.pattern=br),ei.init(e,t)})),gi=cr("$ZodIPv4",((e,t)=>{t.pattern??(t.pattern=xr),ei.init(e,t),e._zod.bag.format="ipv4"})),yi=cr("$ZodIPv6",((e,t)=>{t.pattern??(t.pattern=Tr),ei.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}})),wi=cr("$ZodCIDRv4",((e,t)=>{t.pattern??(t.pattern=Rr),ei.init(e,t)})),bi=cr("$ZodCIDRv6",((e,t)=>{t.pattern??(t.pattern=zr),ei.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(2!==r.length)throw new Error;const[e,t]=r;if(!t)throw new Error;const n=Number(t);if(`${n}`!==t)throw new Error;if(n<0||n>128)throw new Error;new URL(`http://[${e}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}}));function vi(e){if(""===e)return!0;if(/\s/.test(e))return!1;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const Bi=cr("$ZodBase64",((e,t)=>{t.pattern??(t.pattern=Ar),ei.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{vi(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}));const Ei=cr("$ZodBase64URL",((e,t)=>{t.pattern??(t.pattern=kr),ei.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{(function(e){if(!kr.test(e))return!1;const t=e.replace(/[-_]/g,(e=>"-"===e?"+":"/"));return vi(t.padEnd(4*Math.ceil(t.length/4),"="))})(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}})),xi=cr("$ZodE164",((e,t)=>{t.pattern??(t.pattern=Sr),ei.init(e,t)}));const Ti=cr("$ZodJWT",((e,t)=>{ei.init(e,t),e._zod.check=n=>{(function(e,t=null){try{const n=e.split(".");if(3!==n.length)return!1;const[r]=n;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&"JWT"!==o?.typ||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}})(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}})),Ri=cr("$ZodNumber",((e,t)=>{Yo.init(e,t),e._zod.pattern=e._zod.bag.pattern??Nr,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch(s){}const o=n.value;if("number"==typeof o&&!Number.isNaN(o)&&Number.isFinite(o))return n;const i="number"==typeof o?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),n}})),zi=cr("$ZodNumberFormat",((e,t)=>{bo.init(e,t),Ri.init(e,t)})),Ai=cr("$ZodBoolean",((e,t)=>{Yo.init(e,t),e._zod.pattern=Pr,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(i){}const o=n.value;return"boolean"==typeof o||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}})),ki=cr("$ZodBigInt",((e,t)=>{Yo.init(e,t),e._zod.pattern=Vr,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=BigInt(n.value)}catch(o){}return"bigint"==typeof n.value||n.issues.push({expected:"bigint",code:"invalid_type",input:n.value,inst:e}),n}})),Oi=cr("$ZodAny",((e,t)=>{Yo.init(e,t),e._zod.parse=e=>e})),Si=cr("$ZodUnknown",((e,t)=>{Yo.init(e,t),e._zod.parse=e=>e})),$i=cr("$ZodNever",((e,t)=>{Yo.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)}));function Ii(e,t,n){e.issues.length&&t.issues.push(...co(n,e.issues)),t.value[n]=e.value}const _i=cr("$ZodArray",((e,t)=>{Yo.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.value=Array(o.length);const i=[];for(let e=0;e<o.length;e++){const s=o[e],a=t.element._zod.run({value:s,issues:[]},r);a instanceof Promise?i.push(a.then((t=>Ii(t,n,e)))):Ii(a,n,e)}return i.length?Promise.all(i).then((()=>n)):n}}));function Vi(e,t,n,r,o,i){const s=n in r;if(e.issues.length){if(o&&i&&!s)return;t.issues.push(...co(n,e.issues))}s||o?void 0===e.value?s&&(t.value[n]=void 0):t.value[n]=e.value:e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]})}function Di(e){const t=Object.keys(e.shape);for(const o of t)if(!e.shape?.[o]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${o}": expected a Zod schema`);const n=(r=e.shape,Object.keys(r).filter((e=>"optional"===r[e]._zod.optin&&"optional"===r[e]._zod.optout)));var r;return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Ni(e,t,n,r,o,i){const s=[],a=o.keySet,c=o.catchall._zod,u=c.def.type,l="optional"===c.optin,f="optional"===c.optout;for(const h in t){if("__proto__"===h)continue;if(a.has(h))continue;if("never"===u){s.push(h);continue}const o=c.run({value:t[h],issues:[]},r);o instanceof Promise?e.push(o.then((e=>Vi(e,n,h,t,l,f)))):Vi(o,n,h,t,l,f)}return s.length&&n.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i}),e.length?Promise.all(e).then((()=>n)):n}const Pi=cr("$ZodObject",((e,t)=>{Yo.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!n?.get){const e=t.shape;Object.defineProperty(t,"shape",{get:()=>{const n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}const r=Mr((()=>Di(t)));qr(e._zod,"propValues",(()=>{const e=t.shape,n={};for(const t in e){const r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(const e of r.values)n[t].add(e)}}return n}));const o=Xr,i=t.catchall;let s;e._zod.parse=(t,n)=>{s??(s=r.value);const a=t.value;if(!o(a))return t.issues.push({expected:"object",code:"invalid_type",input:a,inst:e}),t;t.value={};const c=[],u=s.shape;for(const e of s.keys){const r=u[e],o="optional"===r._zod.optin,i="optional"===r._zod.optout,s=r._zod.run({value:a[e],issues:[]},n);s instanceof Promise?c.push(s.then((n=>Vi(n,t,e,a,o,i)))):Vi(s,t,e,a,o,i)}return i?Ni(c,a,t,n,r.value,e):c.length?Promise.all(c).then((()=>t)):t}})),Ci=cr("$ZodObjectJIT",((e,t)=>{Pi.init(e,t);const n=e._zod.parse,r=Mr((()=>Di(t)));let o;const i=Xr,s=!fr.jitless,a=s&&Yr.value,c=t.catchall;let u;e._zod.parse=(l,f)=>{u??(u=r.value);const h=l.value;return i(h)?s&&a&&!1===f?.async&&!0!==f.jitless?(o||(o=(e=>{const t=new $o(["shape","payload","ctx"]),n=r.value,o=e=>{const t=Jr(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");const i=Object.create(null);let s=0;for(const r of n.keys)i[r]="key_"+s++;t.write("const newResult = {};");for(const r of n.keys){const n=i[r],s=Jr(r),a=e[r],c="optional"===a?._zod?.optin,u="optional"===a?._zod?.optout;t.write(`const ${n} = ${o(r)};`),c&&u?t.write(`\n if (${n}.issues.length) {\n if (${s} in input) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${s}, ...iss.path] : [${s}]\n })));\n }\n }\n \n if (${n}.value === undefined) {\n if (${s} in input) {\n newResult[${s}] = undefined;\n }\n } else {\n newResult[${s}] = ${n}.value;\n }\n \n `):c?t.write(`\n if (${n}.issues.length) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${s}, ...iss.path] : [${s}]\n })));\n }\n \n if (${n}.value === undefined) {\n if (${s} in input) {\n newResult[${s}] = undefined;\n }\n } else {\n newResult[${s}] = ${n}.value;\n }\n \n `):t.write(`\n const ${n}_present = ${s} in input;\n if (${n}.issues.length) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${s}, ...iss.path] : [${s}]\n })));\n }\n if (!${n}_present && !${n}.issues.length) {\n payload.issues.push({\n code: "invalid_type",\n expected: "nonoptional",\n input: undefined,\n path: [${s}]\n });\n }\n\n if (${n}_present) {\n if (${n}.value === undefined) {\n newResult[${s}] = undefined;\n } else {\n newResult[${s}] = ${n}.value;\n }\n }\n\n `)}t.write("payload.value = newResult;"),t.write("return payload;");const a=t.compile();return(t,n)=>a(e,t,n)})(t.shape)),l=o(l,f),c?Ni([],h,l,f,u,e):l):n(l,f):(l.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),l)}}));function Fi(e,t,n,r){for(const i of e)if(0===i.issues.length)return t.value=i.value,t;const o=e.filter((e=>!so(e)));return 1===o.length?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map((e=>e.issues.map((e=>lo(e,r,hr())))))}),t)}const Gi=cr("$ZodUnion",((e,t)=>{Yo.init(e,t),qr(e._zod,"optin",(()=>t.options.some((e=>"optional"===e._zod.optin))?"optional":void 0)),qr(e._zod,"optout",(()=>t.options.some((e=>"optional"===e._zod.optout))?"optional":void 0)),qr(e._zod,"values",(()=>{if(t.options.every((e=>e._zod.values)))return new Set(t.options.flatMap((e=>Array.from(e._zod.values))))})),qr(e._zod,"pattern",(()=>{if(t.options.every((e=>e._zod.pattern))){const e=t.options.map((e=>e._zod.pattern));return new RegExp(`^(${e.map((e=>jr(e.source))).join("|")})$`)}}));const n=1===t.options.length?t.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(n)return n(r,o);let i=!1;const s=[];for(const e of t.options){const t=e._zod.run({value:r.value,issues:[]},o);if(t instanceof Promise)s.push(t),i=!0;else{if(0===t.issues.length)return t;s.push(t)}}return i?Promise.all(s).then((t=>Fi(t,r,e,o))):Fi(s,r,e,o)}}));const Ui=cr("$ZodIntersection",((e,t)=>{Yo.init(e,t),e._zod.parse=(e,n)=>{const r=e.value,o=t.left._zod.run({value:r,issues:[]},n),i=t.right._zod.run({value:r,issues:[]},n);return o instanceof Promise||i instanceof Promise?Promise.all([o,i]).then((([t,n])=>Li(e,t,n))):Li(e,o,i)}}));function Mi(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Qr(e)&&Qr(t)){const n=Object.keys(t),r=Object.keys(e).filter((e=>-1!==n.indexOf(e))),o={...e,...t};for(const i of r){const n=Mi(e[i],t[i]);if(!n.valid)return{valid:!1,mergeErrorPath:[i,...n.mergeErrorPath]};o[i]=n.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=Mi(e[r],t[r]);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Li(e,t,n){const r=new Map;let o;for(const a of t.issues)if("unrecognized_keys"===a.code){o??(o=a);for(const e of a.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(a);for(const a of n.issues)if("unrecognized_keys"===a.code)for(const e of a.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(a);const i=[...r].filter((([,e])=>e.l&&e.r)).map((([e])=>e));if(i.length&&o&&e.issues.push({...o,keys:i}),so(e))return e;const s=Mi(t.value,n.value);if(!s.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return e.value=s.data,e}const ji=cr("$ZodTuple",((e,t)=>{Yo.init(e,t);const n=t.items;e._zod.parse=(r,o)=>{const i=r.value;if(!Array.isArray(i))return r.issues.push({input:i,inst:e,expected:"tuple",code:"invalid_type"}),r;r.value=[];const s=[],a=Zi(n,"optin"),c=Zi(n,"optout");if(!t.rest){if(i.length<a)return r.issues.push({code:"too_small",minimum:a,inclusive:!0,input:i,inst:e,origin:"array"}),r;i.length>n.length&&r.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:i,inst:e,origin:"array"})}const u=new Array(n.length);for(let e=0;e<n.length;e++){const t=n[e]._zod.run({value:i[e],issues:[]},o);t instanceof Promise?s.push(t.then((t=>{u[e]=t}))):u[e]=t}if(t.rest){let e=n.length-1;const a=i.slice(n.length);for(const n of a){e++;const i=t.rest._zod.run({value:n,issues:[]},o);i instanceof Promise?s.push(i.then((t=>qi(t,r,e)))):qi(i,r,e)}}return s.length?Promise.all(s).then((()=>Hi(u,r,n,i,c))):Hi(u,r,n,i,c)}}));function Zi(e,t){for(let n=e.length-1;n>=0;n--)if("optional"!==e[n]._zod[t])return n+1;return 0}function qi(e,t,n){e.issues.length&&t.issues.push(...co(n,e.issues)),t.value[n]=e.value}function Hi(e,t,n,r,o){for(let i=0;i<n.length;i++){const n=e[i],s=i<r.length;if(n.issues.length){if(!s&&i>=o){t.value.length=i;break}t.issues.push(...co(i,n.issues))}t.value[i]=n.value}for(let i=t.value.length-1;i>=r.length&&("optional"===n[i]._zod.optout&&void 0===t.value[i]);i--)t.value.length=i;return t}const Wi=cr("$ZodRecord",((e,t)=>{Yo.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!Qr(o))return n.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),n;const i=[],s=t.keyType._zod.values;if(s){n.value={};const a=new Set;for(const u of s)if("string"==typeof u||"number"==typeof u||"symbol"==typeof u){a.add("number"==typeof u?u.toString():u);const s=t.keyType._zod.run({value:u,issues:[]},r);if(s instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(s.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:s.issues.map((e=>lo(e,r,hr()))),input:u,path:[u],inst:e});continue}const c=s.value,l=t.valueType._zod.run({value:o[u],issues:[]},r);l instanceof Promise?i.push(l.then((e=>{e.issues.length&&n.issues.push(...co(u,e.issues)),n.value[c]=e.value}))):(l.issues.length&&n.issues.push(...co(u,l.issues)),n.value[c]=l.value)}let c;for(const e in o)a.has(e)||(c=c??[],c.push(e));c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:c})}else{n.value={};for(const s of Reflect.ownKeys(o)){if("__proto__"===s)continue;if(!Object.prototype.propertyIsEnumerable.call(o,s))continue;let a=t.keyType._zod.run({value:s,issues:[]},r);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if("string"==typeof s&&Nr.test(s)&&a.issues.length){const e=t.keyType._zod.run({value:Number(s),issues:[]},r);if(e instanceof Promise)throw new Error("Async schemas not supported in object keys currently");0===e.issues.length&&(a=e)}if(a.issues.length){"loose"===t.mode?n.value[s]=o[s]:n.issues.push({code:"invalid_key",origin:"record",issues:a.issues.map((e=>lo(e,r,hr()))),input:s,path:[s],inst:e});continue}const c=t.valueType._zod.run({value:o[s],issues:[]},r);c instanceof Promise?i.push(c.then((e=>{e.issues.length&&n.issues.push(...co(s,e.issues)),n.value[a.value]=e.value}))):(c.issues.length&&n.issues.push(...co(s,c.issues)),n.value[a.value]=c.value)}}return i.length?Promise.all(i).then((()=>n)):n}}));const Ji=cr("$ZodEnum",((e,t)=>{Yo.init(e,t);const n=Gr(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter((e=>to.has(typeof e))).map((e=>"string"==typeof e?no(e):e.toString())).join("|")})$`),e._zod.parse=(t,o)=>{const i=t.value;return r.has(i)||t.issues.push({code:"invalid_value",values:n,input:i,inst:e}),t}})),Ki=cr("$ZodLiteral",((e,t)=>{if(Yo.init(e,t),0===t.values.length)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map((e=>"string"==typeof e?no(e):e?no(e.toString()):String(e))).join("|")})$`),e._zod.parse=(r,o)=>{const i=r.value;return n.has(i)||r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}})),Xi=cr("$ZodTransform",((e,t)=>{Yo.init(e,t),e._zod.optin="optional",e._zod.parse=(n,r)=>{if("backward"===r.direction)throw new lr(e.constructor.name);const o=t.transform(n.value,n);if(r.async){return(o instanceof Promise?o:Promise.resolve(o)).then((e=>(n.value=e,n.fallback=!0,n)))}if(o instanceof Promise)throw new ur;return n.value=o,n.fallback=!0,n}}));function Yi(e,t){return void 0===t&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}const Qi=cr("$ZodOptional",((e,t)=>{Yo.init(e,t),e._zod.optin="optional",e._zod.optout="optional",qr(e._zod,"values",(()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0)),qr(e._zod,"pattern",(()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${jr(e.source)})?$`):void 0})),e._zod.parse=(e,n)=>{if("optional"===t.innerType._zod.optin){const r=e.value,o=t.innerType._zod.run(e,n);return o instanceof Promise?o.then((e=>Yi(e,r))):Yi(o,r)}return void 0===e.value?e:t.innerType._zod.run(e,n)}})),es=cr("$ZodExactOptional",((e,t)=>{Qi.init(e,t),qr(e._zod,"values",(()=>t.innerType._zod.values)),qr(e._zod,"pattern",(()=>t.innerType._zod.pattern)),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)})),ts=cr("$ZodNullable",((e,t)=>{Yo.init(e,t),qr(e._zod,"optin",(()=>t.innerType._zod.optin)),qr(e._zod,"optout",(()=>t.innerType._zod.optout)),qr(e._zod,"pattern",(()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${jr(e.source)}|null)$`):void 0})),qr(e._zod,"values",(()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0)),e._zod.parse=(e,n)=>null===e.value?e:t.innerType._zod.run(e,n)})),ns=cr("$ZodDefault",((e,t)=>{Yo.init(e,t),e._zod.optin="optional",qr(e._zod,"values",(()=>t.innerType._zod.values)),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);if(void 0===e.value)return e.value=t.defaultValue,e;const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then((e=>rs(e,t))):rs(r,t)}}));function rs(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}const os=cr("$ZodPrefault",((e,t)=>{Yo.init(e,t),e._zod.optin="optional",qr(e._zod,"values",(()=>t.innerType._zod.values)),e._zod.parse=(e,n)=>("backward"===n.direction||void 0===e.value&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))})),is=cr("$ZodNonOptional",((e,t)=>{Yo.init(e,t),qr(e._zod,"values",(()=>{const e=t.innerType._zod.values;return e?new Set([...e].filter((e=>void 0!==e))):void 0})),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then((t=>ss(t,e))):ss(o,e)}}));function ss(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const as=cr("$ZodCatch",((e,t)=>{Yo.init(e,t),e._zod.optin="optional",qr(e._zod,"optout",(()=>t.innerType._zod.optout)),qr(e._zod,"values",(()=>t.innerType._zod.values)),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then((r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map((e=>lo(e,n,hr())))},input:e.value}),e.issues=[],e.fallback=!0),e))):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map((e=>lo(e,n,hr())))},input:e.value}),e.issues=[],e.fallback=!0),e)}})),cs=cr("$ZodPipe",((e,t)=>{Yo.init(e,t),qr(e._zod,"values",(()=>t.in._zod.values)),qr(e._zod,"optin",(()=>t.in._zod.optin)),qr(e._zod,"optout",(()=>t.out._zod.optout)),qr(e._zod,"propValues",(()=>t.in._zod.propValues)),e._zod.parse=(e,n)=>{if("backward"===n.direction){const r=t.out._zod.run(e,n);return r instanceof Promise?r.then((e=>us(e,t.in,n))):us(r,t.in,n)}const r=t.in._zod.run(e,n);return r instanceof Promise?r.then((e=>us(e,t.out,n))):us(r,t.out,n)}}));function us(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}const ls=cr("$ZodReadonly",((e,t)=>{Yo.init(e,t),qr(e._zod,"propValues",(()=>t.innerType._zod.propValues)),qr(e._zod,"values",(()=>t.innerType._zod.values)),qr(e._zod,"optin",(()=>t.innerType?._zod?.optin)),qr(e._zod,"optout",(()=>t.innerType?._zod?.optout)),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(fs):fs(r)}}));function fs(e){return e.value=Object.freeze(e.value),e}const hs=cr("$ZodFunction",((e,t)=>(Yo.init(e,t),e._def=t,e._zod.def=t,e.implement=t=>{if("function"!=typeof t)throw new Error("implement() must be called with a function");return function(...n){const r=e._def.input?No(e._def.input,n):n,o=Reflect.apply(t,this,r);return e._def.output?No(e._def.output,o):o}},e.implementAsync=t=>{if("function"!=typeof t)throw new Error("implementAsync() must be called with a function");return async function(...n){const r=e._def.input?await Co(e._def.input,n):n,o=await Reflect.apply(t,this,r);return e._def.output?await Co(e._def.output,o):o}},e._zod.parse=(t,n)=>{if("function"!=typeof t.value)return t.issues.push({code:"invalid_type",expected:"function",input:t.value,inst:e}),t;const r=e._def.output&&"promise"===e._def.output._zod.def.type;return t.value=r?e.implementAsync(t.value):e.implement(t.value),t},e.input=(...t)=>{const n=e.constructor;return Array.isArray(t[0])?new n({type:"function",input:new ji({type:"tuple",items:t[0],rest:t[1]}),output:e._def.output}):new n({type:"function",input:t[0],output:e._def.output})},e.output=t=>new(0,e.constructor)({type:"function",input:e._def.input,output:t}),e))),ds=cr("$ZodCustom",((e,t)=>{po.init(e,t),Yo.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then((t=>ps(t,n,r,e)));ps(o,n,r,e)}}));function ps(e,t,n,r){if(!e){const e={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(ho(e))}}var ms;Symbol("ZodOutput"),Symbol("ZodInput");class gs{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const n=t[0];return this._map.set(e,n),n&&"object"==typeof n&&"id"in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&"object"==typeof t&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const n={...this.get(t)??{}};delete n.id;const r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}(ms=globalThis).__zod_globalRegistry??(ms.__zod_globalRegistry=new gs);const ys=globalThis.__zod_globalRegistry;function ws(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...oo(t)})}function bs(e,t){return new go({check:"less_than",...oo(t),value:e,inclusive:!1})}function vs(e,t){return new go({check:"less_than",...oo(t),value:e,inclusive:!0})}function Bs(e,t){return new yo({check:"greater_than",...oo(t),value:e,inclusive:!1})}function Es(e,t){return new yo({check:"greater_than",...oo(t),value:e,inclusive:!0})}function xs(e,t){return new wo({check:"multiple_of",...oo(t),value:e})}function Ts(e,t){return new vo({check:"max_length",...oo(t),maximum:e})}function Rs(e,t){return new Bo({check:"min_length",...oo(t),minimum:e})}function zs(e,t){return new Eo({check:"length_equals",...oo(t),length:e})}function As(e){return new So({check:"overwrite",tx:e})}function ks(e,t){const n=function(e,t){const n=new po({check:"custom",...oo(t)});return n._zod.check=e,n}((t=>(t.addIssue=e=>{if("string"==typeof e)t.issues.push(ho(e,t.value,n._zod.def));else{const r=e;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),r.input??(r.input=t.value),r.inst??(r.inst=n),r.continue??(r.continue=!n._zod.def.abort),t.issues.push(ho(r))}},e(t.value,t))),t);return n}function Os(e){let t=e?.target??"draft-2020-12";return"draft-4"===t&&(t="draft-04"),"draft-7"===t&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??ys,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function Ss(e,t,n={path:[],schemaPath:[]}){var r;const o=e._zod.def,i=t.seen.get(e);if(i){i.count++;return n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema}const s={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,s);const a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{const r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,r);else{const n=s.schema,i=t.processors[o.type];if(!i)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);i(e,t,n,r)}const i=e._zod.parent;i&&(s.ref||(s.ref=i),Ss(i,t,r),t.seen.get(i).isParent=!0)}const c=t.metadataRegistry.get(e);c&&Object.assign(s.schema,c),"input"===t.io&&_s(e)&&(delete s.schema.examples,delete s.schema.default),"input"===t.io&&"_prefault"in s.schema&&((r=s.schema).default??(r.default=s.schema._prefault)),delete s.schema._prefault;return t.seen.get(e).schema}function $s(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const i of e.seen.entries()){const t=e.metadataRegistry.get(i[0])?.id;if(t){const e=r.get(t);if(e&&e!==i[0])throw new Error(`Duplicate schema id "${t}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(t,i[0])}}const o=t=>{if(t[1].schema.$ref)return;const r=t[1],{ref:o,defId:i}=(t=>{const r="draft-2020-12"===e.target?"$defs":"definitions";if(e.external){const n=e.external.registry.get(t[0])?.id,o=e.external.uri??(e=>e);if(n)return{ref:o(n)};const i=t[1].defId??t[1].schema.id??"schema"+e.counter++;return t[1].defId=i,{defId:i,ref:`${o("__shared")}#/${r}/${i}`}}if(t[1]===n)return{ref:"#"};const o=`#/${r}/`,i=t[1].schema.id??"__schema"+e.counter++;return{defId:i,ref:o+i}})(t);r.def={...r.schema},i&&(r.defId=i);const s=r.schema;for(const e in s)delete s[e];s.$ref=o};if("throw"===e.cycles)for(const i of e.seen.entries()){const e=i[1];if(e.cycle)throw new Error(`Cycle detected: #/${e.cycle?.join("/")}/<root>\n\nSet the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const i of e.seen.entries()){const n=i[1];if(t===i[0]){o(i);continue}if(e.external){const n=e.external.registry.get(i[0])?.id;if(t!==i[0]&&n){o(i);continue}}const r=e.metadataRegistry.get(i[0])?.id;r?o(i):(n.cycle||n.count>1&&"ref"===e.reused)&&o(i)}}function Is(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=t=>{const n=e.seen.get(t);if(null===n.ref)return;const o=n.def??n.schema,i={...o},s=n.ref;if(n.ref=null,s){r(s);const n=e.seen.get(s),a=n.schema;!a.$ref||"draft-07"!==e.target&&"draft-04"!==e.target&&"openapi-3.0"!==e.target?Object.assign(o,a):(o.allOf=o.allOf??[],o.allOf.push(a)),Object.assign(o,i);if(t._zod.parent===s)for(const e in o)"$ref"!==e&&"allOf"!==e&&(e in i||delete o[e]);if(a.$ref&&n.def)for(const e in o)"$ref"!==e&&"allOf"!==e&&e in n.def&&JSON.stringify(o[e])===JSON.stringify(n.def[e])&&delete o[e]}const a=t._zod.parent;if(a&&a!==s){r(a);const t=e.seen.get(a);if(t?.schema.$ref&&(o.$ref=t.schema.$ref,t.def))for(const e in o)"$ref"!==e&&"allOf"!==e&&e in t.def&&JSON.stringify(o[e])===JSON.stringify(t.def[e])&&delete o[e]}e.override({zodSchema:t,jsonSchema:o,path:n.path??[]})};for(const c of[...e.seen.entries()].reverse())r(c[0]);const o={};if("draft-2020-12"===e.target?o.$schema="https://json-schema.org/draft/2020-12/schema":"draft-07"===e.target?o.$schema="http://json-schema.org/draft-07/schema#":"draft-04"===e.target?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const n=e.external.registry.get(t)?.id;if(!n)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(n)}Object.assign(o,n.def??n.schema);const i=e.metadataRegistry.get(t)?.id;void 0!==i&&o.id===i&&delete o.id;const s=e.external?.defs??{};for(const c of e.seen.entries()){const e=c[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,s[e.defId]=e.def)}e.external||Object.keys(s).length>0&&("draft-2020-12"===e.target?o.$defs=s:o.definitions=s);try{const n=JSON.parse(JSON.stringify(o));return Object.defineProperty(n,"~standard",{value:{...t["~standard"],jsonSchema:{input:Vs(t,"input",e.processors),output:Vs(t,"output",e.processors)}},enumerable:!1,writable:!1}),n}catch(a){throw new Error("Error converting schema to JSON.")}}function _s(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if("transform"===r.type)return!0;if("array"===r.type)return _s(r.element,n);if("set"===r.type)return _s(r.valueType,n);if("lazy"===r.type)return _s(r.getter(),n);if("promise"===r.type||"optional"===r.type||"nonoptional"===r.type||"nullable"===r.type||"readonly"===r.type||"default"===r.type||"prefault"===r.type)return _s(r.innerType,n);if("intersection"===r.type)return _s(r.left,n)||_s(r.right,n);if("record"===r.type||"map"===r.type)return _s(r.keyType,n)||_s(r.valueType,n);if("pipe"===r.type)return!!e._zod.traits.has("$ZodCodec")||(_s(r.in,n)||_s(r.out,n));if("object"===r.type){for(const e in r.shape)if(_s(r.shape[e],n))return!0;return!1}if("union"===r.type){for(const e of r.options)if(_s(e,n))return!0;return!1}if("tuple"===r.type){for(const e of r.items)if(_s(e,n))return!0;return!(!r.rest||!_s(r.rest,n))}return!1}const Vs=(e,t,n={})=>r=>{const{libraryOptions:o,target:i}=r??{},s=Os({...o??{},target:i,io:t,processors:n});return Ss(e,s),$s(s,e),Is(s,e)};const Ds={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Ns=(e,t,n,r)=>{const o=n;o.type="string";const{minimum:i,maximum:s,format:a,patterns:c,contentEncoding:u}=e._zod.bag;if("number"==typeof i&&(o.minLength=i),"number"==typeof s&&(o.maxLength=s),a&&(o.format=Ds[a]??a,""===o.format&&delete o.format,"time"===a&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){const e=[...c];1===e.length?o.pattern=e[0].source:e.length>1&&(o.allOf=[...e.map((e=>({..."draft-07"===t.target||"draft-04"===t.target||"openapi-3.0"===t.target?{type:"string"}:{},pattern:e.source})))])}},Ps=(e,t,n,r)=>{const o=n,{minimum:i,maximum:s,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:l}=e._zod.bag;"string"==typeof a&&a.includes("int")?o.type="integer":o.type="number";const f="number"==typeof l&&l>=(i??Number.NEGATIVE_INFINITY),h="number"==typeof u&&u<=(s??Number.POSITIVE_INFINITY),d="draft-04"===t.target||"openapi-3.0"===t.target;f?d?(o.minimum=l,o.exclusiveMinimum=!0):o.exclusiveMinimum=l:"number"==typeof i&&(o.minimum=i),h?d?(o.maximum=u,o.exclusiveMaximum=!0):o.exclusiveMaximum=u:"number"==typeof s&&(o.maximum=s),"number"==typeof c&&(o.multipleOf=c)},Cs=(e,t,n,r)=>{n.type="boolean"},Fs=(e,t,n,r)=>{if("throw"===t.unrepresentable)throw new Error("BigInt cannot be represented in JSON Schema")},Gs=(e,t,n,r)=>{n.not={}},Us=(e,t,n,r)=>{const o=Gr(e._zod.def.entries);o.every((e=>"number"==typeof e))&&(n.type="number"),o.every((e=>"string"==typeof e))&&(n.type="string"),n.enum=o},Ms=(e,t,n,r)=>{const o=e._zod.def,i=[];for(const s of o.values)if(void 0===s){if("throw"===t.unrepresentable)throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if("bigint"==typeof s){if("throw"===t.unrepresentable)throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(s))}else i.push(s);if(0===i.length);else if(1===i.length){const e=i[0];n.type=null===e?"null":typeof e,"draft-04"===t.target||"openapi-3.0"===t.target?n.enum=[e]:n.const=e}else i.every((e=>"number"==typeof e))&&(n.type="number"),i.every((e=>"string"==typeof e))&&(n.type="string"),i.every((e=>"boolean"==typeof e))&&(n.type="boolean"),i.every((e=>null===e))&&(n.type="null"),n.enum=i},Ls=(e,t,n,r)=>{if("throw"===t.unrepresentable)throw new Error("Custom types cannot be represented in JSON Schema")},js=(e,t,n,r)=>{if("throw"===t.unrepresentable)throw new Error("Function types cannot be represented in JSON Schema")},Zs=(e,t,n,r)=>{if("throw"===t.unrepresentable)throw new Error("Transforms cannot be represented in JSON Schema")},qs=(e,t,n,r)=>{const o=n,i=e._zod.def,{minimum:s,maximum:a}=e._zod.bag;"number"==typeof s&&(o.minItems=s),"number"==typeof a&&(o.maxItems=a),o.type="array",o.items=Ss(i.element,t,{...r,path:[...r.path,"items"]})},Hs=(e,t,n,r)=>{const o=n,i=e._zod.def;o.type="object",o.properties={};const s=i.shape;for(const u in s)o.properties[u]=Ss(s[u],t,{...r,path:[...r.path,"properties",u]});const a=new Set(Object.keys(s)),c=new Set([...a].filter((e=>{const n=i.shape[e]._zod;return"input"===t.io?void 0===n.optin:void 0===n.optout})));c.size>0&&(o.required=Array.from(c)),"never"===i.catchall?._zod.def.type?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=Ss(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):"output"===t.io&&(o.additionalProperties=!1)},Ws=(e,t,n,r)=>{const o=e._zod.def,i=!1===o.inclusive,s=o.options.map(((e,n)=>Ss(e,t,{...r,path:[...r.path,i?"oneOf":"anyOf",n]})));i?n.oneOf=s:n.anyOf=s},Js=(e,t,n,r)=>{const o=e._zod.def,i=Ss(o.left,t,{...r,path:[...r.path,"allOf",0]}),s=Ss(o.right,t,{...r,path:[...r.path,"allOf",1]}),a=e=>"allOf"in e&&1===Object.keys(e).length,c=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]];n.allOf=c},Ks=(e,t,n,r)=>{const o=n,i=e._zod.def;o.type="array";const s="draft-2020-12"===t.target?"prefixItems":"items",a="draft-2020-12"===t.target||"openapi-3.0"===t.target?"items":"additionalItems",c=i.items.map(((e,n)=>Ss(e,t,{...r,path:[...r.path,s,n]}))),u=i.rest?Ss(i.rest,t,{...r,path:[...r.path,a,..."openapi-3.0"===t.target?[i.items.length]:[]]}):null;"draft-2020-12"===t.target?(o.prefixItems=c,u&&(o.items=u)):"openapi-3.0"===t.target?(o.items={anyOf:c},u&&o.items.anyOf.push(u),o.minItems=c.length,u||(o.maxItems=c.length)):(o.items=c,u&&(o.additionalItems=u));const{minimum:l,maximum:f}=e._zod.bag;"number"==typeof l&&(o.minItems=l),"number"==typeof f&&(o.maxItems=f)},Xs=(e,t,n,r)=>{const o=n,i=e._zod.def;o.type="object";const s=i.keyType,a=s._zod.bag,c=a?.patterns;if("loose"===i.mode&&c&&c.size>0){const e=Ss(i.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});o.patternProperties={};for(const t of c)o.patternProperties[t.source]=e}else"draft-07"!==t.target&&"draft-2020-12"!==t.target||(o.propertyNames=Ss(i.keyType,t,{...r,path:[...r.path,"propertyNames"]})),o.additionalProperties=Ss(i.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const u=s._zod.values;if(u){const e=[...u].filter((e=>"string"==typeof e||"number"==typeof e));e.length>0&&(o.required=e)}},Ys=(e,t,n,r)=>{const o=e._zod.def,i=Ss(o.innerType,t,r),s=t.seen.get(e);"openapi-3.0"===t.target?(s.ref=o.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},Qs=(e,t,n,r)=>{const o=e._zod.def;Ss(o.innerType,t,r);t.seen.get(e).ref=o.innerType},ea=(e,t,n,r)=>{const o=e._zod.def;Ss(o.innerType,t,r);t.seen.get(e).ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))},ta=(e,t,n,r)=>{const o=e._zod.def;Ss(o.innerType,t,r);t.seen.get(e).ref=o.innerType,"input"===t.io&&(n._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},na=(e,t,n,r)=>{const o=e._zod.def;Ss(o.innerType,t,r);let i;t.seen.get(e).ref=o.innerType;try{i=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=i},ra=(e,t,n,r)=>{const o=e._zod.def,i=o.in._zod.traits.has("$ZodTransform"),s="input"===t.io?i?o.out:o.in:o.out;Ss(s,t,r);t.seen.get(e).ref=s},oa=(e,t,n,r)=>{const o=e._zod.def;Ss(o.innerType,t,r);t.seen.get(e).ref=o.innerType,n.readOnly=!0},ia=(e,t,n,r)=>{const o=e._zod.def;Ss(o.innerType,t,r);t.seen.get(e).ref=o.innerType};const sa=cr("ZodISODateTime",((e,t)=>{hi.init(e,t),Va.init(e,t)}));function aa(e){return function(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...oo(t)})}(sa,e)}const ca=cr("ZodISODate",((e,t)=>{di.init(e,t),Va.init(e,t)}));function ua(e){return function(e,t){return new e({type:"string",format:"date",check:"string_format",...oo(t)})}(ca,e)}const la=cr("ZodISOTime",((e,t)=>{pi.init(e,t),Va.init(e,t)}));function fa(e){return function(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...oo(t)})}(la,e)}const ha=cr("ZodISODuration",((e,t)=>{mi.init(e,t),Va.init(e,t)}));function da(e){return function(e,t){return new e({type:"string",format:"duration",check:"string_format",...oo(t)})}(ha,e)}const pa=(e,t)=>{_o.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>function(e,t=e=>e.message){const n={_errors:[]},r=(e,o=[])=>{for(const i of e.issues)if("invalid_union"===i.code&&i.errors.length)i.errors.map((e=>r({issues:e},[...o,...i.path])));else if("invalid_key"===i.code)r({issues:i.issues},[...o,...i.path]);else if("invalid_element"===i.code)r({issues:i.issues},[...o,...i.path]);else{const e=[...o,...i.path];if(0===e.length)n._errors.push(t(i));else{let r=n,o=0;for(;o<e.length;){const n=e[o];o===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(i))):r[n]=r[n]||{_errors:[]},r=r[n],o++}}}};return r(e),n}(e,t)},flatten:{value:t=>function(e,t=e=>e.message){const n={},r=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Ur,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Ur,2)}},isEmpty:{get:()=>0===e.issues.length}})},ma=cr("ZodError",pa,{Parent:Error}),ga=Do(ma),ya=Po(ma),wa=Fo(ma),ba=Uo(ma),va=Lo(ma),Ba=jo(ma),Ea=Zo(ma),xa=qo(ma),Ta=Ho(ma),Ra=Wo(ma),za=Jo(ma),Aa=Ko(ma);const ka=new WeakMap;function Oa(e,t,n){const r=Object.getPrototypeOf(e);let o=ka.get(r);if(o||(o=new Set,ka.set(r,o)),!o.has(t)){o.add(t);for(const e in n){const t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){const n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}const Sa=cr("ZodType",((e,t)=>(Yo.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Vs(e,"input"),output:Vs(e,"output")}}),e.toJSONSchema=((e,t={})=>n=>{const r=Os({...n,processors:t});return Ss(e,r),$s(r,e),Is(r,e)})(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>ga(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>wa(e,t,n),e.parseAsync=async(t,n)=>ya(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>ba(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>va(e,t,n),e.decode=(t,n)=>Ba(e,t,n),e.encodeAsync=async(t,n)=>Ea(e,t,n),e.decodeAsync=async(t,n)=>xa(e,t,n),e.safeEncode=(t,n)=>Ta(e,t,n),e.safeDecode=(t,n)=>Ra(e,t,n),e.safeEncodeAsync=async(t,n)=>za(e,t,n),e.safeDecodeAsync=async(t,n)=>Aa(e,t,n),Oa(e,"ZodType",{check(...e){const t=this.def;return this.clone(Wr(t,{checks:[...t.checks??[],...e.map((e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e))]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return ro(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(function(e,t={}){return function(e,t,n){return new e({type:"custom",check:"custom",fn:t,...oo(n)})}(Lc,e,t)}(e,t))},superRefine(e,t){return this.check(function(e,t){return ks(e,t)}(e,t))},overwrite(e){return this.check(As(e))},optional(){return $c(this)},exactOptional(){return new Ic({type:"optional",innerType:this})},nullable(){return Vc(this)},nullish(){return $c(Vc(this))},nonoptional(e){return function(e,t){return new Pc({type:"nonoptional",innerType:e,...oo(t)})}(this,e)},array(){return mc(this)},or(e){return bc([this,e])},and(e){return new vc({type:"intersection",left:this,right:e})},transform(e){return Gc(this,Oc(e))},default(e){return t=e,new Dc({type:"default",innerType:this,get defaultValue(){return"function"==typeof t?t():eo(t)}});var t},prefault(e){return t=e,new Nc({type:"prefault",innerType:this,get defaultValue(){return"function"==typeof t?t():eo(t)}});var t},catch(e){return new Cc({type:"catch",innerType:this,catchValue:"function"==typeof(t=e)?t:()=>t});var t},pipe(e){return Gc(this,e)},readonly(){return new Uc({type:"readonly",innerType:this})},describe(e){const t=this.clone();return ys.add(t,{description:e}),t},meta(...e){if(0===e.length)return ys.get(this);const t=this.clone();return ys.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get:()=>ys.get(e)?.description,configurable:!0}),e))),$a=cr("_ZodString",((e,t)=>{Qo.init(e,t),Sa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ns(e,t,n);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Oa(e,"_ZodString",{regex(...e){return this.check(function(e,t){return new To({check:"string_format",format:"regex",...oo(t),pattern:e})}(...e))},includes(...e){return this.check(function(e,t){return new Ao({check:"string_format",format:"includes",...oo(t),includes:e})}(...e))},startsWith(...e){return this.check(function(e,t){return new ko({check:"string_format",format:"starts_with",...oo(t),prefix:e})}(...e))},endsWith(...e){return this.check(function(e,t){return new Oo({check:"string_format",format:"ends_with",...oo(t),suffix:e})}(...e))},min(...e){return this.check(Rs(...e))},max(...e){return this.check(Ts(...e))},length(...e){return this.check(zs(...e))},nonempty(...e){return this.check(Rs(1,...e))},lowercase(e){return this.check(function(e){return new Ro({check:"string_format",format:"lowercase",...oo(e)})}(e))},uppercase(e){return this.check(function(e){return new zo({check:"string_format",format:"uppercase",...oo(e)})}(e))},trim(){return this.check(As((e=>e.trim())))},normalize(...e){return this.check(function(e){return As((t=>t.normalize(e)))}(...e))},toLowerCase(){return this.check(As((e=>e.toLowerCase())))},toUpperCase(){return this.check(As((e=>e.toUpperCase())))},slugify(){return this.check(As((e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}(e))))}})})),Ia=cr("ZodString",((e,t)=>{Qo.init(e,t),$a.init(e,t),e.email=t=>e.check(function(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...oo(t)})}(Da,t)),e.url=t=>e.check(function(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...oo(t)})}(Ca,t)),e.jwt=t=>e.check(function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...oo(t)})}(Qa,t)),e.emoji=t=>e.check(function(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...oo(t)})}(Fa,t)),e.guid=t=>e.check(ws(Na,t)),e.uuid=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...oo(t)})}(Pa,t)),e.uuidv4=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...oo(t)})}(Pa,t)),e.uuidv6=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...oo(t)})}(Pa,t)),e.uuidv7=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...oo(t)})}(Pa,t)),e.nanoid=t=>e.check(function(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...oo(t)})}(Ga,t)),e.guid=t=>e.check(ws(Na,t)),e.cuid=t=>e.check(function(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...oo(t)})}(Ua,t)),e.cuid2=t=>e.check(function(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...oo(t)})}(Ma,t)),e.ulid=t=>e.check(function(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...oo(t)})}(La,t)),e.base64=t=>e.check(function(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...oo(t)})}(Ka,t)),e.base64url=t=>e.check(function(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...oo(t)})}(Xa,t)),e.xid=t=>e.check(function(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...oo(t)})}(ja,t)),e.ksuid=t=>e.check(function(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...oo(t)})}(Za,t)),e.ipv4=t=>e.check(function(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...oo(t)})}(qa,t)),e.ipv6=t=>e.check(function(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...oo(t)})}(Ha,t)),e.cidrv4=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...oo(t)})}(Wa,t)),e.cidrv6=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...oo(t)})}(Ja,t)),e.e164=t=>e.check(function(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...oo(t)})}(Ya,t)),e.datetime=t=>e.check(aa(t)),e.date=t=>e.check(ua(t)),e.time=t=>e.check(fa(t)),e.duration=t=>e.check(da(t))}));function _a(e){return function(e,t){return new e({type:"string",...oo(t)})}(Ia,e)}const Va=cr("ZodStringFormat",((e,t)=>{ei.init(e,t),$a.init(e,t)})),Da=cr("ZodEmail",((e,t)=>{ri.init(e,t),Va.init(e,t)}));const Na=cr("ZodGUID",((e,t)=>{ti.init(e,t),Va.init(e,t)}));const Pa=cr("ZodUUID",((e,t)=>{ni.init(e,t),Va.init(e,t)}));const Ca=cr("ZodURL",((e,t)=>{oi.init(e,t),Va.init(e,t)}));const Fa=cr("ZodEmoji",((e,t)=>{ii.init(e,t),Va.init(e,t)}));const Ga=cr("ZodNanoID",((e,t)=>{si.init(e,t),Va.init(e,t)}));const Ua=cr("ZodCUID",((e,t)=>{ai.init(e,t),Va.init(e,t)}));const Ma=cr("ZodCUID2",((e,t)=>{ci.init(e,t),Va.init(e,t)}));const La=cr("ZodULID",((e,t)=>{ui.init(e,t),Va.init(e,t)}));const ja=cr("ZodXID",((e,t)=>{li.init(e,t),Va.init(e,t)}));const Za=cr("ZodKSUID",((e,t)=>{fi.init(e,t),Va.init(e,t)}));const qa=cr("ZodIPv4",((e,t)=>{gi.init(e,t),Va.init(e,t)}));const Ha=cr("ZodIPv6",((e,t)=>{yi.init(e,t),Va.init(e,t)}));const Wa=cr("ZodCIDRv4",((e,t)=>{wi.init(e,t),Va.init(e,t)}));const Ja=cr("ZodCIDRv6",((e,t)=>{bi.init(e,t),Va.init(e,t)}));const Ka=cr("ZodBase64",((e,t)=>{Bi.init(e,t),Va.init(e,t)}));const Xa=cr("ZodBase64URL",((e,t)=>{Ei.init(e,t),Va.init(e,t)}));const Ya=cr("ZodE164",((e,t)=>{xi.init(e,t),Va.init(e,t)}));const Qa=cr("ZodJWT",((e,t)=>{Ti.init(e,t),Va.init(e,t)}));const ec=cr("ZodNumber",((e,t)=>{Ri.init(e,t),Sa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ps(e,t,n),Oa(e,"ZodNumber",{gt(e,t){return this.check(Bs(e,t))},gte(e,t){return this.check(Es(e,t))},min(e,t){return this.check(Es(e,t))},lt(e,t){return this.check(bs(e,t))},lte(e,t){return this.check(vs(e,t))},max(e,t){return this.check(vs(e,t))},int(e){return this.check(rc(e))},safe(e){return this.check(rc(e))},positive(e){return this.check(Bs(0,e))},nonnegative(e){return this.check(Es(0,e))},negative(e){return this.check(bs(0,e))},nonpositive(e){return this.check(vs(0,e))},multipleOf(e,t){return this.check(xs(e,t))},step(e,t){return this.check(xs(e,t))},finite(){return this}});const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null}));function tc(e){return function(e,t){return new e({type:"number",checks:[],...oo(t)})}(ec,e)}const nc=cr("ZodNumberFormat",((e,t)=>{zi.init(e,t),ec.init(e,t)}));function rc(e){return function(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...oo(t)})}(nc,e)}const oc=cr("ZodBoolean",((e,t)=>{Ai.init(e,t),Sa.init(e,t),e._zod.processJSONSchema=(e,t,n)=>Cs(0,0,t)}));function ic(e){return function(e,t){return new e({type:"boolean",...oo(t)})}(oc,e)}const sc=cr("ZodBigInt",((e,t)=>{ki.init(e,t),Sa.init(e,t),e._zod.processJSONSchema=(e,t,n)=>Fs(0,e),e.gte=(t,n)=>e.check(Es(t,n)),e.min=(t,n)=>e.check(Es(t,n)),e.gt=(t,n)=>e.check(Bs(t,n)),e.gte=(t,n)=>e.check(Es(t,n)),e.min=(t,n)=>e.check(Es(t,n)),e.lt=(t,n)=>e.check(bs(t,n)),e.lte=(t,n)=>e.check(vs(t,n)),e.max=(t,n)=>e.check(vs(t,n)),e.positive=t=>e.check(Bs(BigInt(0),t)),e.negative=t=>e.check(bs(BigInt(0),t)),e.nonpositive=t=>e.check(vs(BigInt(0),t)),e.nonnegative=t=>e.check(Es(BigInt(0),t)),e.multipleOf=(t,n)=>e.check(xs(t,n));const n=e._zod.bag;e.minValue=n.minimum??null,e.maxValue=n.maximum??null,e.format=n.format??null}));function ac(e){return function(e,t){return new e({type:"bigint",...oo(t)})}(sc,e)}const cc=cr("ZodAny",((e,t)=>{Oi.init(e,t),Sa.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}}));function uc(){return function(e){return new e({type:"any"})}(cc)}const lc=cr("ZodUnknown",((e,t)=>{Si.init(e,t),Sa.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}}));function fc(){return function(e){return new e({type:"unknown"})}(lc)}const hc=cr("ZodNever",((e,t)=>{$i.init(e,t),Sa.init(e,t),e._zod.processJSONSchema=(e,t,n)=>Gs(0,0,t)}));function dc(e){return function(e,t){return new e({type:"never",...oo(t)})}(hc,e)}const pc=cr("ZodArray",((e,t)=>{_i.init(e,t),Sa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qs(e,t,n,r),e.element=t.element,Oa(e,"ZodArray",{min(e,t){return this.check(Rs(e,t))},nonempty(e){return this.check(Rs(1,e))},max(e,t){return this.check(Ts(e,t))},length(e,t){return this.check(zs(e,t))},unwrap(){return this.element}})}));function mc(e,t){return function(e,t,n){return new e({type:"array",element:t,...oo(n)})}(pc,e,t)}const gc=cr("ZodObject",((e,t)=>{Ci.init(e,t),Sa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hs(e,t,n,r),qr(e,"shape",(()=>t.shape)),Oa(e,"ZodObject",{keyof(){return zc(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:fc()})},loose(){return this.clone({...this._zod.def,catchall:fc()})},strict(){return this.clone({...this._zod.def,catchall:dc()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return function(e,t){if(!Qr(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const n=e._zod.def.shape;for(const e in t)if(void 0!==Object.getOwnPropertyDescriptor(n,e))throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const r=Wr(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return Hr(this,"shape",n),n}});return ro(e,r)}(this,e)},safeExtend(e){return function(e,t){if(!Qr(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=Wr(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return Hr(this,"shape",n),n}});return ro(e,n)}(this,e)},merge(e){return function(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n=Wr(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return Hr(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ro(e,n)}(this,e)},pick(e){return function(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");return ro(e,Wr(e._zod.def,{get shape(){const e={};for(const r in t){if(!(r in n.shape))throw new Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return Hr(this,"shape",e),e},checks:[]}))}(this,e)},omit(e){return function(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const o=Wr(e._zod.def,{get shape(){const r={...e._zod.def.shape};for(const e in t){if(!(e in n.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return Hr(this,"shape",r),r},checks:[]});return ro(e,o)}(this,e)},partial(...e){return function(e,t,n){const r=t._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const o=Wr(t._zod.def,{get shape(){const r=t._zod.def.shape,o={...r};if(n)for(const t in n){if(!(t in r))throw new Error(`Unrecognized key: "${t}"`);n[t]&&(o[t]=e?new e({type:"optional",innerType:r[t]}):r[t])}else for(const t in r)o[t]=e?new e({type:"optional",innerType:r[t]}):r[t];return Hr(this,"shape",o),o},checks:[]});return ro(t,o)}(Sc,this,e[0])},required(...e){return function(e,t,n){const r=Wr(t._zod.def,{get shape(){const r=t._zod.def.shape,o={...r};if(n)for(const t in n){if(!(t in o))throw new Error(`Unrecognized key: "${t}"`);n[t]&&(o[t]=new e({type:"nonoptional",innerType:r[t]}))}else for(const t in r)o[t]=new e({type:"nonoptional",innerType:r[t]});return Hr(this,"shape",o),o}});return ro(t,r)}(Pc,this,e[0])}})}));function yc(e,t){const n={type:"object",shape:e??{},...oo(t)};return new gc(n)}const wc=cr("ZodUnion",((e,t)=>{Gi.init(e,t),Sa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ws(e,t,n,r),e.options=t.options}));function bc(e,t){return new wc({type:"union",options:e,...oo(t)})}const vc=cr("ZodIntersection",((e,t)=>{Ui.init(e,t),Sa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Js(e,t,n,r)}));const Bc=cr("ZodTuple",((e,t)=>{ji.init(e,t),Sa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ks(e,t,n,r),e.rest=t=>e.clone({...e._zod.def,rest:t})}));function Ec(e,t,n){const r=t instanceof Yo;return new Bc({type:"tuple",items:e,rest:r?t:null,...oo(r?n:t)})}const xc=cr("ZodRecord",((e,t)=>{Wi.init(e,t),Sa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xs(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType}));function Tc(e,t,n){return t&&t._zod?new xc({type:"record",keyType:e,valueType:t,...oo(n)}):new xc({type:"record",keyType:_a(),valueType:e,...oo(t)})}const Rc=cr("ZodEnum",((e,t)=>{Ji.init(e,t),Sa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Us(e,0,n),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{const o={};for(const i of e){if(!n.has(i))throw new Error(`Key ${i} not found in enum`);o[i]=t.entries[i]}return new Rc({...t,checks:[],...oo(r),entries:o})},e.exclude=(e,r)=>{const o={...t.entries};for(const t of e){if(!n.has(t))throw new Error(`Key ${t} not found in enum`);delete o[t]}return new Rc({...t,checks:[],...oo(r),entries:o})}}));function zc(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map((e=>[e,e]))):e;return new Rc({type:"enum",entries:n,...oo(t)})}const Ac=cr("ZodLiteral",((e,t)=>{Ki.init(e,t),Sa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ms(e,t,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})}));const kc=cr("ZodTransform",((e,t)=>{Xi.init(e,t),Sa.init(e,t),e._zod.processJSONSchema=(e,t,n)=>Zs(0,e),e._zod.parse=(n,r)=>{if("backward"===r.direction)throw new lr(e.constructor.name);n.addIssue=r=>{if("string"==typeof r)n.issues.push(ho(r,n.value,t));else{const t=r;t.fatal&&(t.continue=!1),t.code??(t.code="custom"),t.input??(t.input=n.value),t.inst??(t.inst=e),n.issues.push(ho(t))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then((e=>(n.value=e,n.fallback=!0,n))):(n.value=o,n.fallback=!0,n)}}));function Oc(e){return new kc({type:"transform",transform:e})}const Sc=cr("ZodOptional",((e,t)=>{Qi.init(e,t),Sa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ia(e,t,0,r),e.unwrap=()=>e._zod.def.innerType}));function $c(e){return new Sc({type:"optional",innerType:e})}const Ic=cr("ZodExactOptional",((e,t)=>{es.init(e,t),Sa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ia(e,t,0,r),e.unwrap=()=>e._zod.def.innerType}));const _c=cr("ZodNullable",((e,t)=>{ts.init(e,t),Sa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ys(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}));function Vc(e){return new _c({type:"nullable",innerType:e})}const Dc=cr("ZodDefault",((e,t)=>{ns.init(e,t),Sa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ea(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap}));const Nc=cr("ZodPrefault",((e,t)=>{os.init(e,t),Sa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ta(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}));const Pc=cr("ZodNonOptional",((e,t)=>{is.init(e,t),Sa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qs(e,t,0,r),e.unwrap=()=>e._zod.def.innerType}));const Cc=cr("ZodCatch",((e,t)=>{as.init(e,t),Sa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>na(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap}));const Fc=cr("ZodPipe",((e,t)=>{cs.init(e,t),Sa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ra(e,t,0,r),e.in=t.in,e.out=t.out}));function Gc(e,t){return new Fc({type:"pipe",in:e,out:t})}const Uc=cr("ZodReadonly",((e,t)=>{ls.init(e,t),Sa.init(e,t),e._zod.processJSONSchema=(t,n,r)=>oa(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}));const Mc=cr("ZodFunction",((e,t)=>{hs.init(e,t),Sa.init(e,t),e._zod.processJSONSchema=(e,t,n)=>js(0,e)}));const Lc=cr("ZodCustom",((e,t)=>{ds.init(e,t),Sa.init(e,t),e._zod.processJSONSchema=(e,t,n)=>Ls(0,e)}));const jc=yc({issuer:_a().transform((e=>yt(e))),index:_a().transform((e=>yt(e))),timestamp:_a().transform((e=>yt(e))),signature:_a().transform((e=>yt(e)))});var Zc=n(878);const qc=n.n(Zc)()("bee-js:http"),Hc={headers:{accept:"application/json, text/plain, */*"}};async function Wc(e,t){const n=t.data,r=ar.Rb.deepMerge3(Hc,{...t,data:void 0},e);if(r.data=n,e.signal&&(r.signal=e.signal),function(e){if(void 0===e.data)return;const t=e.data;if(null!==t&&"object"==typeof t&&t.constructor===Object||Array.isArray(t))e.body=JSON.stringify(t),e.headers={"content-type":"application/json",...e.headers};else{e.body=t,e.duplex="half";const n=t instanceof Blob&&t.type?t.type:"application/octet-stream";e.headers={"content-type":n,...e.headers}}}(r),r.params)for(const c of Object.keys(r.params))void 0===r.params[c]&&delete r.params[c];const o=function(e){let t=ar.DH.joinUrl([e.baseURL??"",e.url??""]);if(e.params){const n=new URLSearchParams(Object.entries(e.params).filter((([,e])=>void 0!==e)).map((([e,t])=>[e,String(t)]))).toString();n&&(t+=`?${n}`)}return t}(r),i=(r.method||"GET").toUpperCase();r.method=i,e.onRequest?.({method:i,url:ar.DH.joinUrl([r.baseURL??"",r.url??""]),headers:{...r.headers},params:r.params});let s=0;for(;s<1e5;)try{qc(`${i} ${o}`,{headers:r.headers,params:r.params});const e=await fetch(o,r);return e.ok||await Jc(i,o,e,r.responseType),Xc(e,r.responseType)}catch(a){if(a instanceof nu)throw a;const t=a;if("TimeoutError"!==t.name||!e.endlesslyRetry)throw Kc(t,i,o);s++,await ar.iQ.sleepMillis(s<300?200:1e3)}throw Error("Max number of failed attempts reached")}async function Jc(e,t,n,r){const o=await Xc(n,r).catch((()=>({data:void 0}))),i="string"==typeof o.data?o.data:JSON.stringify(o.data),s=i&&"undefined"!==i?`${n.statusText}: ${i}`:n.statusText;throw new nu(e,t,s,o.data,n.status,n.statusText)}function Kc(e,t,n){if("AbortError"===e.name)return new nu(t,n,"Request aborted",void 0,void 0,"ERR_CANCELED");const r=e.cause,o=r?.message?`${e.message}: ${r.message}`:e.message;return new nu(t,n,o)}async function Xc(e,t="json"){let n;switch(t){case"arraybuffer":n=await e.arrayBuffer();break;case"text":n=await e.text();break;case"blob":n=await e.blob();break;case"stream":n=e.body;break;default:{const t=await e.text();n=t?JSON.parse(t):null}}return{data:n,status:e.status,statusText:e.statusText,headers:Object.fromEntries(e.headers.entries()),raw:e}}const Yc=yc({durationSeconds:tc()});const Qc=yc({reference:_a().transform((e=>new nn(e)))});class eu extends Error{constructor(e){super(e)}}class tu extends eu{constructor(e,t){super(e),this.value=t}}class nu extends eu{constructor(e,t,n,r,o,i){super(n),this.method=e,this.url=t,this.responseBody=r,this.status=o,this.statusText=i,this.response={status:o,data:r,statusText:i}}}class ru{static ZERO=new ru(0);constructor(e){this.seconds=Math.ceil(e),e<0&&(this.seconds=0)}static fromMilliseconds(e){return new ru(e/1e3)}static fromSeconds(e){return new ru(e)}static fromHours(e){return new ru(60*e*60)}static fromDays(e){return new ru(24*e*60*60)}static fromWeeks(e){return new ru(7*e*24*60*60)}static fromYears(e){return new ru(365*e*24*60*60)}static fromEndDate(e,t){return new ru((e.getTime()-(t??new Date).getTime())/1e3)}static parseFromString(e){return ru.fromSeconds(ar.AO.make(e)/1e3)}toSeconds(){return this.seconds}toHours(){return this.seconds/60/60}toDays(){return this.seconds/24/60/60}toWeeks(){return this.seconds/7/24/60/60}toYears(){return this.seconds/365/24/60/60}toEndDate(e){return new Date((e??new Date).getTime()+1e3*this.seconds)}represent(){return ar.AO.secondsToHumanTime(this.seconds)}isZero(){return 0===this.seconds}}class ou{constructor(e){if(this.bytes=Math.ceil(e),e<0)throw Error("Size must be at least 0")}static fromBytes(e){return new ou(e)}static fromKilobytes(e){return new ou(1e3*e)}static fromMegabytes(e){return new ou(1e3*e*1e3)}static fromGigabytes(e){return new ou(1e3*e*1e3*1e3)}static parseFromString(e){return ou.fromBytes(ar.FQ.makeStorage(e,1e3))}toBytes(){return this.bytes}toGigabytes(){return this.bytes/1e3/1e3/1e3}toFormattedString(){return ar.FQ.convertBytes(this.bytes,1e3)}represent(){return this.toFormattedString()}}class iu{static DIGITS=16;constructor(e){this.state=e}static fromDecimalString(e){return new iu(ar.ie.fromDecimalString(e,iu.DIGITS))}static fromPLUR(e){return new iu(new ar.ie(e,iu.DIGITS))}static fromFloat(e){return new iu(ar.ie.fromFloat(e,iu.DIGITS))}toPLURString(){return this.state.toString()}toPLURBigInt(){return this.state.value}toDecimalString(){return this.state.toDecimalString()}toFloat(){return this.state.toFloat()}toSignificantDigits(e){return this.toDecimalString().slice(0,this.toDecimalString().indexOf(".")+e+1)}plus(e){return new iu(this.state.add(e instanceof iu?e.state:new ar.ie(e,iu.DIGITS)))}minus(e){return new iu(this.state.subtract(e instanceof iu?e.state:new ar.ie(e,iu.DIGITS)))}divide(e){return new iu(this.state.divmod(e)[0])}gt(e){return 1===this.state.compare(e.state)}gte(e){return-1!==this.state.compare(e.state)}lt(e){return-1===this.state.compare(e.state)}lte(e){return 1!==this.state.compare(e.state)}eq(e){return 0===this.state.compare(e.state)}exchangeToDAI(e){return su.fromWei(this.state.exchange("*",new ar.ie(e.toWeiBigInt(),su.DIGITS),su.DIGITS).value)}}class su{static DIGITS=18;constructor(e){this.state=e}static fromDecimalString(e){return new su(ar.ie.fromDecimalString(e,su.DIGITS))}static fromWei(e){return new su(new ar.ie(e,su.DIGITS))}static fromFloat(e){return new su(ar.ie.fromFloat(e,su.DIGITS))}toWeiString(){return this.state.toString()}toWeiBigInt(){return this.state.value}toDecimalString(){return this.state.toDecimalString()}toSignificantDigits(e){return this.toDecimalString().slice(0,this.toDecimalString().indexOf(".")+e+1)}toFloat(){return this.state.toFloat()}plus(e){return new su(this.state.add(e instanceof su?e.state:new ar.ie(e,su.DIGITS)))}minus(e){return new su(this.state.subtract(e instanceof su?e.state:new ar.ie(e,su.DIGITS)))}divide(e){return new su(this.state.divmod(e)[0])}gt(e){return 1===this.state.compare(e.state)}gte(e){return-1!==this.state.compare(e.state)}lt(e){return-1===this.state.compare(e.state)}lte(e){return 1!==this.state.compare(e.state)}eq(e){return 0===this.state.compare(e.state)}exchangeToBZZ(e){return iu.fromPLUR(this.state.exchange("/",new ar.ie(e.toWeiBigInt(),su.DIGITS),iu.DIGITS).value)}}var au=n(320);function cu(e){if("function"==typeof File&&e instanceof File)return!0;const t=e;return"object"==typeof t&&"string"==typeof t.name&&("function"==typeof t.stream||"function"==typeof t.arrayBuffer)}function uu(e){return function(e,t){return new e({type:"number",coerce:!0,checks:[],...oo(t)})}(ec,e)}let lu=function(e){return e.FULL="full",e.LIGHT="light",e.ULTRA_LIGHT="ultra-light",e.DEV="dev",e}({});function fu(e){switch(e){case"full":return lu.FULL;case"light":return lu.LIGHT;case"ultra-light":return lu.ULTRA_LIGHT;case"dev":return lu.DEV;default:throw new Error(`Unknown Bee mode: ${e}`)}}const hu=32,du=128,pu=hu*du,mu=4,gu=17,yu=255,wu=1,bu=1e3;let vu=function(e){return e[e.OFF=0]="OFF",e[e.MEDIUM=1]="MEDIUM",e[e.STRONG=2]="STRONG",e[e.INSANE=3]="INSANE",e[e.PARANOID=4]="PARANOID",e}({}),Bu=function(e){return e[e.NONE=0]="NONE",e[e.DATA=1]="DATA",e[e.PROX=2]="PROX",e[e.RACE=3]="RACE",e}({});const Eu={ENCRYPTION_OFF:{[vu.OFF]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"44.70 kB",batchDepth:17,utilizationRate:"0.01%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"6.66 MB",batchDepth:18,utilizationRate:"0.61%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"112.06 MB",batchDepth:19,utilizationRate:"5.09%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"687.62 MB",batchDepth:20,utilizationRate:"15.65%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"2.60 GB",batchDepth:21,utilizationRate:"30.27%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"7.73 GB",batchDepth:22,utilizationRate:"44.99%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"19.94 GB",batchDepth:23,utilizationRate:"58.03%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"47.06 GB",batchDepth:24,utilizationRate:"68.48%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"105.51 GB",batchDepth:25,utilizationRate:"76.77%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"227.98 GB",batchDepth:26,utilizationRate:"82.94%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"476.68 GB",batchDepth:27,utilizationRate:"86.71%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"993.65 GB",batchDepth:28,utilizationRate:"88.37%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"2.04 TB",batchDepth:29,utilizationRate:"92.88%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"4.17 TB",batchDepth:30,utilizationRate:"94.81%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"8.45 TB",batchDepth:31,utilizationRate:"96.06%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"17.07 TB",batchDepth:32,utilizationRate:"97.01%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"34.36 TB",batchDepth:33,utilizationRate:"97.65%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"69.04 TB",batchDepth:34,utilizationRate:"98.11%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"138.54 TB",batchDepth:35,utilizationRate:"98.44%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"277.72 TB",batchDepth:36,utilizationRate:"98.67%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"556.35 TB",batchDepth:37,utilizationRate:"98.83%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"1.11 PB",batchDepth:38,utilizationRate:"98.91%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"2.23 PB",batchDepth:39,utilizationRate:"98.96%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"4.46 PB",batchDepth:40,utilizationRate:"98.98%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"8.93 PB",batchDepth:41,utilizationRate:"99.11%"}],[vu.MEDIUM]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"41.56 kB",batchDepth:17,utilizationRate:"0.01%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"6.19 MB",batchDepth:18,utilizationRate:"0.57%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"104.18 MB",batchDepth:19,utilizationRate:"4.73%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"639.27 MB",batchDepth:20,utilizationRate:"14.54%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"2.41 GB",batchDepth:21,utilizationRate:"28.11%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"7.18 GB",batchDepth:22,utilizationRate:"41.79%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"18.54 GB",batchDepth:23,utilizationRate:"53.95%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"43.75 GB",batchDepth:24,utilizationRate:"63.66%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"98.09 GB",batchDepth:25,utilizationRate:"71.37%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"211.95 GB",batchDepth:26,utilizationRate:"77.11%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"443.16 GB",batchDepth:27,utilizationRate:"80.61%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"923.78 GB",batchDepth:28,utilizationRate:"82.16%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"1.90 TB",batchDepth:29,utilizationRate:"86.30%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"3.88 TB",batchDepth:30,utilizationRate:"88.14%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"7.86 TB",batchDepth:31,utilizationRate:"89.26%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"15.87 TB",batchDepth:32,utilizationRate:"90.21%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"31.94 TB",batchDepth:33,utilizationRate:"90.77%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"64.19 TB",batchDepth:34,utilizationRate:"91.22%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"128.80 TB",batchDepth:35,utilizationRate:"91.52%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"258.19 TB",batchDepth:36,utilizationRate:"91.73%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"517.23 TB",batchDepth:37,utilizationRate:"91.88%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"1.04 PB",batchDepth:38,utilizationRate:"91.95%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"2.07 PB",batchDepth:39,utilizationRate:"92.00%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"4.15 PB",batchDepth:40,utilizationRate:"92.15%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"8.30 PB",batchDepth:41,utilizationRate:"92.14%"}],[vu.STRONG]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"37.37 kB",batchDepth:17,utilizationRate:"0.01%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"5.57 MB",batchDepth:18,utilizationRate:"0.51%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"93.68 MB",batchDepth:19,utilizationRate:"4.25%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"574.81 MB",batchDepth:20,utilizationRate:"13.07%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"2.17 GB",batchDepth:21,utilizationRate:"25.26%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"6.46 GB",batchDepth:22,utilizationRate:"37.58%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"16.67 GB",batchDepth:23,utilizationRate:"48.50%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"39.34 GB",batchDepth:24,utilizationRate:"57.24%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"88.20 GB",batchDepth:25,utilizationRate:"64.17%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"190.58 GB",batchDepth:26,utilizationRate:"69.33%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"398.47 GB",batchDepth:27,utilizationRate:"72.48%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"830.63 GB",batchDepth:28,utilizationRate:"73.85%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"1.71 TB",batchDepth:29,utilizationRate:"77.59%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"3.49 TB",batchDepth:30,utilizationRate:"79.27%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"7.07 TB",batchDepth:31,utilizationRate:"80.34%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"14.27 TB",batchDepth:32,utilizationRate:"81.12%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"28.72 TB",batchDepth:33,utilizationRate:"81.63%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"57.71 TB",batchDepth:34,utilizationRate:"82.01%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"115.81 TB",batchDepth:35,utilizationRate:"82.29%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"232.16 TB",batchDepth:36,utilizationRate:"82.48%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"465.07 TB",batchDepth:37,utilizationRate:"82.61%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"931.23 TB",batchDepth:38,utilizationRate:"82.67%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"1.86 PB",batchDepth:39,utilizationRate:"82.71%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"3.73 PB",batchDepth:40,utilizationRate:"82.78%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"7.46 PB",batchDepth:41,utilizationRate:"82.79%"}],[vu.INSANE]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"33.88 kB",batchDepth:17,utilizationRate:"0.01%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"5.05 MB",batchDepth:18,utilizationRate:"0.46%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"84.92 MB",batchDepth:19,utilizationRate:"3.86%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"521.09 MB",batchDepth:20,utilizationRate:"11.85%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"1.97 GB",batchDepth:21,utilizationRate:"22.90%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"5.86 GB",batchDepth:22,utilizationRate:"34.09%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"15.11 GB",batchDepth:23,utilizationRate:"43.97%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"35.66 GB",batchDepth:24,utilizationRate:"51.90%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"79.96 GB",batchDepth:25,utilizationRate:"58.18%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"172.77 GB",batchDepth:26,utilizationRate:"62.85%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"361.23 GB",batchDepth:27,utilizationRate:"65.70%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"753.00 GB",batchDepth:28,utilizationRate:"66.95%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"1.55 TB",batchDepth:29,utilizationRate:"70.38%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"3.16 TB",batchDepth:30,utilizationRate:"71.92%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"6.41 TB",batchDepth:31,utilizationRate:"72.85%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"12.93 TB",batchDepth:32,utilizationRate:"73.53%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"26.04 TB",batchDepth:33,utilizationRate:"74.01%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"52.32 TB",batchDepth:34,utilizationRate:"74.35%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"104.99 TB",batchDepth:35,utilizationRate:"74.60%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"210.46 TB",batchDepth:36,utilizationRate:"74.77%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"421.61 TB",batchDepth:37,utilizationRate:"74.89%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"844.20 TB",batchDepth:38,utilizationRate:"74.94%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"1.69 PB",batchDepth:39,utilizationRate:"74.98%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"3.38 PB",batchDepth:40,utilizationRate:"75.03%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"6.77 PB",batchDepth:41,utilizationRate:"75.10%"}],[vu.PARANOID]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"13.27 kB",batchDepth:17,utilizationRate:"0.00%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"1.98 MB",batchDepth:18,utilizationRate:"0.18%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"33.27 MB",batchDepth:19,utilizationRate:"1.51%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"204.14 MB",batchDepth:20,utilizationRate:"4.64%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"771.13 MB",batchDepth:21,utilizationRate:"8.75%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"2.29 GB",batchDepth:22,utilizationRate:"13.34%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"5.92 GB",batchDepth:23,utilizationRate:"17.22%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"13.97 GB",batchDepth:24,utilizationRate:"20.33%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"31.32 GB",batchDepth:25,utilizationRate:"22.79%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"67.68 GB",batchDepth:26,utilizationRate:"24.62%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"141.51 GB",batchDepth:27,utilizationRate:"25.74%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"294.99 GB",batchDepth:28,utilizationRate:"26.23%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"606.90 GB",batchDepth:29,utilizationRate:"27.56%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"1.24 TB",batchDepth:30,utilizationRate:"28.15%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"2.51 TB",batchDepth:31,utilizationRate:"28.54%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"5.07 TB",batchDepth:32,utilizationRate:"28.82%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"10.20 TB",batchDepth:33,utilizationRate:"28.99%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"20.50 TB",batchDepth:34,utilizationRate:"29.13%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"41.13 TB",batchDepth:35,utilizationRate:"29.22%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"82.45 TB",batchDepth:36,utilizationRate:"29.29%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"165.17 TB",batchDepth:37,utilizationRate:"29.34%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"330.72 TB",batchDepth:38,utilizationRate:"29.37%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"661.97 TB",batchDepth:39,utilizationRate:"29.39%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"1.32 PB",batchDepth:40,utilizationRate:"29.41%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"2.65 PB",batchDepth:41,utilizationRate:"29.43%"}]},ENCRYPTION_ON:{[vu.OFF]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"44.35 kB",batchDepth:17,utilizationRate:"0.01%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"6.61 MB",batchDepth:18,utilizationRate:"0.60%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"111.18 MB",batchDepth:19,utilizationRate:"5.05%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"682.21 MB",batchDepth:20,utilizationRate:"15.52%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"2.58 GB",batchDepth:21,utilizationRate:"30.04%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"7.67 GB",batchDepth:22,utilizationRate:"44.62%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"19.78 GB",batchDepth:23,utilizationRate:"57.56%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"46.69 GB",batchDepth:24,utilizationRate:"67.93%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"104.68 GB",batchDepth:25,utilizationRate:"76.16%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"226.19 GB",batchDepth:26,utilizationRate:"82.29%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"472.93 GB",batchDepth:27,utilizationRate:"86.02%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"985.83 GB",batchDepth:28,utilizationRate:"87.66%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"2.03 TB",batchDepth:29,utilizationRate:"92.25%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"4.14 TB",batchDepth:30,utilizationRate:"94.21%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"8.39 TB",batchDepth:31,utilizationRate:"95.37%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"16.93 TB",batchDepth:32,utilizationRate:"96.22%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"34.09 TB",batchDepth:33,utilizationRate:"96.88%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"68.50 TB",batchDepth:34,utilizationRate:"97.34%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"137.45 TB",batchDepth:35,utilizationRate:"97.67%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"275.53 TB",batchDepth:36,utilizationRate:"97.89%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"551.97 TB",batchDepth:37,utilizationRate:"98.05%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"1.11 PB",batchDepth:38,utilizationRate:"98.13%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"2.21 PB",batchDepth:39,utilizationRate:"98.18%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"4.43 PB",batchDepth:40,utilizationRate:"98.36%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"8.86 PB",batchDepth:41,utilizationRate:"98.37%"}],[vu.MEDIUM]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"40.89 kB",batchDepth:17,utilizationRate:"0.01%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"6.09 MB",batchDepth:18,utilizationRate:"0.56%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"102.49 MB",batchDepth:19,utilizationRate:"4.65%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"628.91 MB",batchDepth:20,utilizationRate:"14.30%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"2.38 GB",batchDepth:21,utilizationRate:"27.68%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"7.07 GB",batchDepth:22,utilizationRate:"41.15%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"18.24 GB",batchDepth:23,utilizationRate:"53.09%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"43.04 GB",batchDepth:24,utilizationRate:"62.63%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"96.50 GB",batchDepth:25,utilizationRate:"70.21%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"208.52 GB",batchDepth:26,utilizationRate:"75.86%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"435.98 GB",batchDepth:27,utilizationRate:"79.30%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"908.81 GB",batchDepth:28,utilizationRate:"80.82%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"1.87 TB",batchDepth:29,utilizationRate:"84.98%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"3.81 TB",batchDepth:30,utilizationRate:"86.67%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"7.73 TB",batchDepth:31,utilizationRate:"87.84%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"15.61 TB",batchDepth:32,utilizationRate:"88.74%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"31.43 TB",batchDepth:33,utilizationRate:"89.34%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"63.15 TB",batchDepth:34,utilizationRate:"89.74%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"126.71 TB",batchDepth:35,utilizationRate:"90.03%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"254.01 TB",batchDepth:36,utilizationRate:"90.24%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"508.85 TB",batchDepth:37,utilizationRate:"90.39%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"1.02 PB",batchDepth:38,utilizationRate:"90.47%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"2.04 PB",batchDepth:39,utilizationRate:"90.51%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"4.08 PB",batchDepth:40,utilizationRate:"90.64%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"8.17 PB",batchDepth:41,utilizationRate:"90.65%"}],[vu.STRONG]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"36.73 kB",batchDepth:17,utilizationRate:"0.01%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"5.47 MB",batchDepth:18,utilizationRate:"0.50%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"92.07 MB",batchDepth:19,utilizationRate:"4.18%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"564.95 MB",batchDepth:20,utilizationRate:"12.85%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"2.13 GB",batchDepth:21,utilizationRate:"24.86%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"6.35 GB",batchDepth:22,utilizationRate:"36.97%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"16.38 GB",batchDepth:23,utilizationRate:"47.67%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"38.66 GB",batchDepth:24,utilizationRate:"56.26%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"86.69 GB",batchDepth:25,utilizationRate:"63.07%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"187.31 GB",batchDepth:26,utilizationRate:"68.14%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"391.64 GB",batchDepth:27,utilizationRate:"71.24%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"816.39 GB",batchDepth:28,utilizationRate:"72.59%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"1.68 TB",batchDepth:29,utilizationRate:"76.34%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"3.43 TB",batchDepth:30,utilizationRate:"77.89%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"6.94 TB",batchDepth:31,utilizationRate:"78.86%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"14.02 TB",batchDepth:32,utilizationRate:"79.71%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"28.23 TB",batchDepth:33,utilizationRate:"80.23%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"56.72 TB",batchDepth:34,utilizationRate:"80.60%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"113.82 TB",batchDepth:35,utilizationRate:"80.88%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"228.18 TB",batchDepth:36,utilizationRate:"81.06%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"457.10 TB",batchDepth:37,utilizationRate:"81.20%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"915.26 TB",batchDepth:38,utilizationRate:"81.26%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"1.83 PB",batchDepth:39,utilizationRate:"81.30%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"3.67 PB",batchDepth:40,utilizationRate:"81.43%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"7.34 PB",batchDepth:41,utilizationRate:"81.45%"}],[vu.INSANE]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"33.26 kB",batchDepth:17,utilizationRate:"0.01%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"4.96 MB",batchDepth:18,utilizationRate:"0.45%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"83.38 MB",batchDepth:19,utilizationRate:"3.79%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"511.65 MB",batchDepth:20,utilizationRate:"11.64%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"1.93 GB",batchDepth:21,utilizationRate:"22.52%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"5.75 GB",batchDepth:22,utilizationRate:"33.50%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"14.84 GB",batchDepth:23,utilizationRate:"43.19%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"35.02 GB",batchDepth:24,utilizationRate:"50.96%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"78.51 GB",batchDepth:25,utilizationRate:"57.12%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"169.64 GB",batchDepth:26,utilizationRate:"61.71%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"354.69 GB",batchDepth:27,utilizationRate:"64.52%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"739.37 GB",batchDepth:28,utilizationRate:"65.74%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"1.52 TB",batchDepth:29,utilizationRate:"69.15%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"3.10 TB",batchDepth:30,utilizationRate:"70.56%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"6.29 TB",batchDepth:31,utilizationRate:"71.48%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"12.70 TB",batchDepth:32,utilizationRate:"72.18%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"25.57 TB",batchDepth:33,utilizationRate:"72.67%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"51.37 TB",batchDepth:34,utilizationRate:"73.00%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"103.08 TB",batchDepth:35,utilizationRate:"73.24%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"206.65 TB",batchDepth:36,utilizationRate:"73.42%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"413.98 TB",batchDepth:37,utilizationRate:"73.54%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"828.91 TB",batchDepth:38,utilizationRate:"73.59%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"1.66 PB",batchDepth:39,utilizationRate:"73.62%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"3.32 PB",batchDepth:40,utilizationRate:"73.72%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"6.64 PB",batchDepth:41,utilizationRate:"73.74%"}],[vu.PARANOID]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"13.17 kB",batchDepth:17,utilizationRate:"0.00%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"1.96 MB",batchDepth:18,utilizationRate:"0.18%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"33.01 MB",batchDepth:19,utilizationRate:"1.50%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"202.53 MB",batchDepth:20,utilizationRate:"4.61%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"765.05 MB",batchDepth:21,utilizationRate:"8.68%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"2.28 GB",batchDepth:22,utilizationRate:"13.27%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"5.87 GB",batchDepth:23,utilizationRate:"17.08%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"13.86 GB",batchDepth:24,utilizationRate:"20.17%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"31.08 GB",batchDepth:25,utilizationRate:"22.61%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"67.15 GB",batchDepth:26,utilizationRate:"24.43%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"140.40 GB",batchDepth:27,utilizationRate:"25.54%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"292.67 GB",batchDepth:28,utilizationRate:"26.03%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"602.12 GB",batchDepth:29,utilizationRate:"27.35%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"1.23 TB",batchDepth:30,utilizationRate:"27.94%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"2.49 TB",batchDepth:31,utilizationRate:"28.32%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"5.03 TB",batchDepth:32,utilizationRate:"28.60%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"10.12 TB",batchDepth:33,utilizationRate:"28.77%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"20.34 TB",batchDepth:34,utilizationRate:"28.91%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"40.80 TB",batchDepth:35,utilizationRate:"29.00%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"81.80 TB",batchDepth:36,utilizationRate:"29.06%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"163.87 TB",batchDepth:37,utilizationRate:"29.11%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"328.11 TB",batchDepth:38,utilizationRate:"29.14%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"656.76 TB",batchDepth:39,utilizationRate:"29.16%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"1.31 PB",batchDepth:40,utilizationRate:"29.18%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"2.63 PB",batchDepth:41,utilizationRate:"29.19%"}]}},xu=(_a().regex(/^(?:0x)?[0-9a-fA-F]*$/i,"expected hex string").refine((e=>e.replace(/^0x/i,"").length%2==0),"expected even-length hex string"),uc().refine((e=>{return new Mc({type:"function",input:Array.isArray(t?.input)?Ec(t?.input):t?.input??mc(fc()),output:t?.output??fc()}).safeParse(e).success;var t}),"expected a function")),Tu=uc().transform((e=>(ac().safeParse(e).success&&(e=String(e)),_a().regex(/^-?\d+$/,"expected integer string").parse(e)))),Ru=uc().transform((e=>(ac().safeParse(e).success&&(e=String(e)),_a().regex(/^\d+$/,"expected non-negative integer string").parse(e)))),zu=yc({baseURL:_a().optional(),timeout:tc().int().min(0).optional(),headers:Tc(_a(),_a()).optional(),onRequest:xu.optional(),httpAgent:fc().optional(),httpsAgent:fc().optional(),endlesslyRetry:ic().optional(),signal:uc().optional()}),Au=yc({redundancyStrategy:tc().int().optional(),fallback:ic().optional(),timeoutMs:tc().int().min(0).optional(),actPublisher:$c(uc().transform((e=>new Jt(e)))),actHistoryAddress:$c(uc().transform((e=>new nn(e)))),actTimestamp:uu().optional()}),ku=yc({act:ic().optional(),actHistoryAddress:$c(uc().transform((e=>new nn(e)))),deferred:ic().optional(),encrypt:ic().optional(),pin:ic().optional(),tag:tc().int().min(0).optional()}),Ou=ku.extend({redundancyLevel:tc().int().min(0).optional()}),Su=ku.extend({size:tc().int().min(0).optional(),contentType:_a().optional(),redundancyLevel:tc().int().min(0).optional()}),$u=ku.extend({errorDocument:_a().optional(),indexDocument:_a().optional(),redundancyLevel:tc().int().min(0).optional()}),Iu=yc({uid:tc().int()}),_u=uu().min(0),Vu=yc({onMessage:xu,onError:xu,onClose:xu}),Du=yc({onMessage:xu,onError:xu,onClose:xu}),Nu=yc({gasPrice:Tu.optional(),immutableFlag:ic().optional(),label:_a().optional(),waitForUsable:ic().optional(),waitForUsableTimeout:tc().int().min(0).optional()}),Pu=yc({gasLimit:Ru.optional(),gasPrice:Ru.optional()}),Cu=yc({limit:tc().int().min(wu).max(bu).optional(),offset:tc().int().min(0).optional()});function Fu(e){return void 0!==au.Readable&&e instanceof au.Readable}function Gu(e,t){if("bigint"==typeof e&&(e=e.toString()),"string"!=typeof e||!/^-?\d+$/.test(e))throw new TypeError(`${t?.name??"value"} is not a valid integer string, got: ${e}`);if(void 0!==t?.min&&BigInt(e)<t.min)throw new RangeError(`${t?.name??"value"} must be >= ${t.min}, got: ${e}`);if(void 0!==t?.max&&BigInt(e)>t.max)throw new RangeError(`${t?.name??"value"} must be <= ${t.max}, got: ${e}`);return e}function Uu(e){if(!("string"==typeof e||e instanceof Uint8Array||e instanceof Blob||Fu(e)))throw new TypeError("Data must be either string, Uint8Array, Blob or Readable!")}function Mu(e){if(null==e)throw new TypeError(`Expected number | Tag | string from tagUid, got: ${e}`);if(t=e,Iu.safeParse(t).success)return e.uid;if("number"==typeof e||"string"==typeof e)return _u.parse(e);var t;throw new TypeError(`Expected number | Tag | string from tagUid, got: ${e}`)}function Lu(e,t){return iu.fromPLUR(2n**BigInt(e)*BigInt(t))}function ju(e,t,n){const r=BigInt(Gu(e));return ru.fromSeconds(Number(r*BigInt(n)/BigInt(t)))}function Zu(e,t,n){return BigInt(e.toSeconds())/BigInt(n)*BigInt(t)+1n}function qu(e,t,n){return function(e,t,n){if(void 0!==t&&void 0!==n){const r=(t?tr:er)[n],o=r?.find((([,t])=>e<=Yn(t)));if(o)return o[0]}else for(const[r,o]of Qn)if(e<=Yn(o))return r;return 35}(e.toBytes(),t,n)}function Hu(e){return or(e)}function Wu(e,t,n){const r=function(e){return Number.isInteger(e)?e<1?1:e>3155695200?3155695200:e:1}(e.batchTTL),o=ru.fromSeconds(r),i=nr(e.depth,t,n),s=e.utilizationRatio??Jn(e.utilization,e.depth,e.bucketDepth);return{batchID:new Pt(e.batchID),utilization:e.utilization,usable:e.usable,label:e.label,depth:e.depth,amount:Gu(e.amount),bucketDepth:e.bucketDepth,blockNumber:e.blockNumber,immutableFlag:e.immutableFlag,usage:s,usageText:`${Math.round(100*s)}%`,size:ou.fromBytes(i),remainingSize:ou.fromBytes(Math.ceil(i*(1-s))),theoreticalSize:ou.fromBytes(Kn(e.depth)),duration:o,calculateSize(t,n){const r=nr(e.depth,t,n);return ou.fromBytes(r)},calculateRemainingSize(t,n){const r=nr(e.depth,t,n);return ou.fromBytes(Math.ceil(r*(1-this.usage)))}}}function Ju(e){return{batchID:e.batchID.toHex(),utilization:e.utilization,utilizationRatio:e.usage,usable:e.usable,label:e.label,depth:e.depth,amount:e.amount,bucketDepth:e.bucketDepth,blockNumber:e.blockNumber,immutableFlag:e.immutableFlag,batchTTL:e.duration.toSeconds()}}function Ku(e){return{name:function(e){if(!e)throw new eu("missing content-disposition header");const t=e.match(/filename\*?=['"]?(?:UTF-\d['"]*)?([^;\r\n"']*)['"]?;?/i);if(t&&t.length>0)return t[1];throw new eu("invalid content-disposition header")}(e["content-disposition"]),tagUid:function(e){if(!e)return;return parseInt(e,10)}(e["swarm-tag-uid"]),contentType:e["content-type"]||void 0}}function Xu(e,t){const n={};if(!function(e){if(!yc({}).safeParse(e).success)return!1;const t=e;return void 0!==t.issuer&&void 0!==t.index&&void 0!==t.signature&&void 0!==t.timestamp&&void 0!==t.batchId}(e)?e&&(e=new Pt(e),n["swarm-postage-batch-id"]=e.toHex()):n["swarm-postage-stamp"]=Hu(e).toHex(),!t)return n;const r=t;r.size&&(n["content-length"]=String(r.size)),r.contentType&&(n["content-type"]=String(r.contentType)),r.redundancyLevel&&(n["swarm-redundancy-level"]=String(r.redundancyLevel));const o=ic().safeParse(r.act);o.success&&(n["swarm-act"]=String(o.data));const i=ic().safeParse(r.pin);i.success&&(n["swarm-pin"]=String(i.data));const s=ic().safeParse(r.encrypt);s.success&&(n["swarm-encrypt"]=String(s.data)),r.tag&&(n["swarm-tag"]=String(r.tag));const a=ic().safeParse(r.deferred);a.success&&(n["swarm-deferred-upload"]=String(a.data)),r.redundancyStrategy&&(n["swarm-redundancy-strategy"]=String(r.redundancyStrategy));const c=ic().safeParse(r.fallback);return c.success&&(n["swarm-redundancy-fallback-mode"]=String(c.data)),r.timeoutMs&&(n["swarm-chunk-retrieval-timeout"]=String(r.timeoutMs)),r.indexDocument&&(n["swarm-index-document"]=String(r.indexDocument)),r.errorDocument&&(n["swarm-error-document"]=String(r.errorDocument)),r.actPublisher&&(n["swarm-act-publisher"]=new Jt(r.actPublisher).toCompressedHex()),r.actHistoryAddress&&(n["swarm-act-history-address"]=new nn(r.actHistoryAddress).toHex()),r.actTimestamp&&(n["swarm-act-timestamp"]=String(r.actTimestamp)),(r.actPublisher||r.actHistoryAddress||r.actTimestamp)&&(n["swarm-act"]="true"),r.gasPrice&&(n["gas-price"]=String(r.gasPrice)),r.gasLimit&&(n["gas-limit"]=String(r.gasLimit)),n}const Yu="chunks";async function Qu(e,t,n){t=new nn(t);const r=await Wc(e,{responseType:"arraybuffer",url:`${Yu}/${t}`,headers:Xu(null,n)});return new Uint8Array(r.data)}function el(e,t){try{return xn(e,t)}catch(n){throw new eu(n.message)}}async function tl(e,t,n,r){const o=Nt.concat(t.span.toUint8Array(),t.payload.toUint8Array());return async function(e,t,n,r,o,i,s){const a=await Wc(e,{method:"post",url:`soc/${t}/${n}`,data:o,headers:{"content-type":"application/octet-stream",...Xu(i,s)},responseType:"json",params:{sig:r.toHex()}});return{reference:Qc.parse(a.data).reference,tagUid:a.headers["swarm-tag"]?Mu(a.headers["swarm-tag"]):void 0,historyAddress:a.headers["swarm-act-history-address"]?ar.Xx.of(new nn(a.headers["swarm-act-history-address"])):ar.Xx.empty()}}(e,t.owner,t.identifier,t.signature,o,n,r)}async function nl(e,t,n,r,o,i){t=new en(t),r=new Zt(r);return tl(e,Tn(o).toSingleOwnerChunk(r,t),n,i)}async function rl(e,t,n,r,o,i){t=new en(t),r=new Zt(r);return tl(e,o.toSingleOwnerChunk(r,t),n,i)}async function ol(e,t,n){const r=Bn(n=new Zt(n),t=new Ut(t));return el(await Qu(e,r.toHex()),r)}const il=yc({peer:_a(),balance:_a().transform((e=>iu.fromPLUR(Gu(e,{name:"balance"}))))}),sl=yc({balances:mc(il)}),al=il,cl="balances";const ul="consumed";class ll{constructor(e){this.context=e}async getAll(e){return async function(e){const t=await Wc(e,{url:cl,responseType:"json"});return sl.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getPeer(e,t){const n=new qt(e);return async function(e,t){const n=await Wc(e,{url:`${cl}/${t}`,responseType:"json"});return al.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async getAllPastDueConsumption(e){return async function(e){const t=await Wc(e,{url:ul,responseType:"json"});return sl.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getAllPastDueConsumptionForPeer(e,t){const n=new qt(e);return async function(e,t){const n=await Wc(e,{url:`${ul}/${t}`,responseType:"json"});return al.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}}const fl=yc({beneficiary:_a().transform((e=>new Ut(e))),chequebook:_a().transform((e=>new Ut(e))),payout:_a().transform((e=>iu.fromPLUR(Gu(e,{name:"payout"}))))}),hl=yc({recipient:_a(),lastPayout:_a().transform((e=>iu.fromPLUR(Gu(e,{name:"lastPayout"})))),bounced:ic()}),dl=yc({chequebookAddress:_a().transform((e=>new Ut(e)))}),pl=yc({availableBalance:_a().transform((e=>iu.fromPLUR(Gu(e,{name:"availableBalance"})))),totalBalance:_a().transform((e=>iu.fromPLUR(Gu(e,{name:"totalBalance"}))))}),ml=yc({peer:_a(),uncashedAmount:_a().transform((e=>iu.fromPLUR(Gu(e,{name:"uncashedAmount"})))),transactionHash:_a().nullish().transform((e=>e??null)),lastCashedCheque:fl.nullish().transform((e=>e??null)),result:hl.nullish().transform((e=>e??null))}),gl=yc({peer:_a(),lastreceived:fl.nullish().transform((e=>e??null)),lastsent:fl.nullish().transform((e=>e??null))}),yl=yc({lastcheques:mc(yc({peer:_a(),lastreceived:fl.nullish().transform((e=>e??null)),lastsent:fl.nullish().transform((e=>e??null))}))}),wl=yc({transactionHash:_a().transform((e=>new an(e)))}),bl="chequebook";class vl{constructor(e){this.context=e}async getAllLatest(e){return async function(e){const t=await Wc(e,{url:`${bl}/cheque`,responseType:"json"});return yl.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getAllLatestForPeer(e,t){const n=new qt(e);return async function(e,t){const n=await Wc(e,{url:`${bl}/cheque/${t}`,responseType:"json"});return gl.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async getLastCashoutAction(e,t){const n=new qt(e);return async function(e,t){const n=await Wc(e,{url:`${bl}/cashout/${t}`,responseType:"json"});return ml.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async cashoutLast(e,t,n){const r=new qt(e);return t&&(t=Pu.parse(t)),async function(e,t,n){const r=await Wc(e,{method:"post",url:`${bl}/cashout/${t}`,responseType:"json",headers:Xu(null,n)});return wl.parse(r.data).transactionHash}(this.context.getRequestOptionsForCall(n),r,t)}}class Bl{constructor(e){this.context=e}async getAddress(e){return async function(e){const t=await Wc(e,{url:`${bl}/address`,responseType:"json"});return dl.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getBalance(e){return async function(e){const t=await Wc(e,{url:`${bl}/balance`,responseType:"json"});return pl.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async deposit(e,t,n){const r=e instanceof iu?e.toPLURString():Gu(e,{min:1n,name:"amount"}),o=t?Gu(e,{min:0n,name:"gasPrice"}):void 0;return async function(e,t,n){const r={};n&&(r["gas-price"]=n);const o=await Wc(e,{method:"post",url:`${bl}/deposit`,responseType:"json",params:{amount:t},headers:r});return wl.parse(o.data).transactionHash}(this.context.getRequestOptionsForCall(n),r,o)}async withdraw(e,t,n){const r=e instanceof iu?e.toPLURString():Gu(e,{min:1n,name:"amount"}),o=t?Gu(e,{min:0n,name:"gasPrice"}):void 0;return async function(e,t,n){const r={};n&&(r["gas-price"]=n);const o=await Wc(e,{method:"post",url:`${bl}/withdraw`,responseType:"json",params:{amount:t},headers:r});return wl.parse(o.data).transactionHash}(this.context.getRequestOptionsForCall(n),r,o)}}class El{constructor(e){this.context=e}async upload(e,t,n,r){const o="identifier"in t&&"signature"in t&&"owner"in t;if(t=t instanceof Uint8Array?t:t.data,n&&(n=ku.parse(n)),t.length<rn.LENGTH)throw new tu(`Chunk has to have size of at least ${rn.LENGTH}.`,t);if(!o&&t.length>pu+rn.LENGTH)throw new tu(`Content Addressed Chunk must not exceed ${pu+rn.LENGTH} bytes.`,t);if(o&&t.length>pu+rn.LENGTH+Qt.LENGTH+Zt.LENGTH)throw new tu(`Single Owner Chunk must not exceed ${pu+rn.LENGTH+Qt.LENGTH+Zt.LENGTH} bytes.`,t);return async function(e,t,n,r){const o=await Wc(e,{method:"post",url:`${Yu}`,data:t,headers:{"content-type":"application/octet-stream",...Xu(n,r)},responseType:"json"});return{reference:Qc.parse(o.data).reference,tagUid:o.headers["swarm-tag"]?Mu(o.headers["swarm-tag"]):void 0,historyAddress:o.headers["swarm-act-history-address"]?ar.Xx.of(new nn(o.headers["swarm-act-history-address"])):ar.Xx.empty()}}(this.context.getRequestOptionsForCall(r),t,e,n)}async download(e,t,n){const r=new nn(e);return t&&(t=Au.parse(t)),Qu(this.context.getRequestOptionsForCall(n),r,t)}}var xl=n(497),Tl=n.n(xl);async function Rl(e,t,n,r,o){for(const s of e.forks.values()){const e=await Rl(s.node,t,n,r,o);if(r?.act){let t;e.historyAddress.ifPresent((e=>t=e)),t&&(s.node.metadata||(s.node.metadata={}),s.node.metadata["swarm-act-history-address"]=t.toHex())}}const i=await t.data.upload(n,await e.marshal(),r,o);return e.selfAddress=i.reference.toUint8Array(),i}async function zl(e,t,n,r){for(const o of e.forks.values()){if(!o.node.selfAddress)throw Error("MantarayNode#loadRecursively fork.node.selfAddress is not set");let i=n;o.node.metadata&&o.node.metadata["swarm-act-history-address"]&&(i={...n,actHistoryAddress:o.node.metadata["swarm-act-history-address"]});const s=(await t.data.download(o.node.selfAddress,i,r)).toUint8Array(),a=Zn.unmarshalFromData(s,o.node.selfAddress);o.node.targetAddress=a.targetAddress,o.node.forks=a.forks,o.node.path=o.prefix,o.node.parent=e,await zl(o.node,t,n,r)}}class Al{constructor(e=new Zn){this.core=e}get obfuscationKey(){return this.core.obfuscationKey}get selfAddress(){return this.core.selfAddress}get targetAddress(){return this.core.targetAddress}get metadata(){return this.core.metadata}get path(){return this.core.path}get forks(){return this.core.forks}get parent(){return this.core.parent}get type(){return this.core.type}get fullPath(){return this.core.fullPath}get fullPathString(){return this.core.fullPathString}getRootMetadata(){const e=this.core.find("/");return e&&e.metadata?ar.Xx.of(e.metadata):ar.Xx.empty()}getDocsMetadata(){const e=this.core.find("/");return e&&e.metadata?{indexDocument:e.metadata["website-index-document"]??null,errorDocument:e.metadata["website-error-document"]??null}:{indexDocument:null,errorDocument:null}}async resolveFeed(e,t){const n=this.core.find("/");if(!n||!n.metadata)return ar.Xx.empty();const r=n.metadata["swarm-feed-owner"],o=n.metadata["swarm-feed-topic"];return r&&o?ar.Xx.of(await e.feed.fetchLatestUpdate(o,r,t)):ar.Xx.empty()}async marshal(){return this.core.marshal()}static async unmarshal(e,t,n,r){t=new nn(t);const o=(await e.data.download(t,n,r)).toUint8Array();return this.unmarshalFromData(o,t.toUint8Array())}static unmarshalFromData(e,t){return new Al(Zn.unmarshalFromData(e,t))}addFork(e,t,n){this.core.addFork(e,t instanceof Nt?t.toUint8Array():t,n)}removeFork(e){this.core.removeFork(e)}async calculateSelfAddress(){return this.core.calculateSelfAddress()}async saveRecursively(e,t,n,r){return Rl(this.core,e,t,n,r)}async loadRecursively(e,t,n){return zl(this.core,e,t,n)}find(e){return this.core.find(e)}findClosest(e,t){return this.core.findClosest(e,t)}collect(e=[]){return this.core.collect(e)}collectAndMap(){return this.core.collectAndMap()}determineType(){return this.core.determineType()}}var kl=n(61),Ol=n.n(kl);async function Sl(e){if("string"!=typeof e)throw new TypeError("dir has to be string!");if(""===e)throw new TypeError("dir must not be empty string!");return $l(e,"")}async function $l(e,t){const n=Ol().join(e,t),r=await Tl().promises.opendir(n);let o=[];for await(const i of r){const n=Ol().join(e,t,i.name),r=Ol().join(t,i.name);i.isFile()?o.push({path:r,size:(await Tl().promises.stat(n)).size,fsPath:n}):i.isDirectory()&&(o=[...await $l(e,r),...o])}return o}async function Il(e){if("string"!=typeof e)throw new TypeError("dir has to be string!");if(""===e)throw new TypeError("dir must not be empty string!");const t=await Tl().promises.opendir(e);let n=0;for await(const r of t)if(r.isFile()){n+=(await Tl().promises.stat(Ol().join(e,r.name))).size}else r.isDirectory()&&(n+=await Il(Ol().join(e,r.name)));return n}const _l={aac:"audio/aac",abw:"application/x-abiword",ai:"application/postscript",arc:"application/octet-stream",avi:"video/x-msvideo",azw:"application/vnd.amazon.ebook",bin:"application/octet-stream",bz:"application/x-bzip",bz2:"application/x-bzip2",csh:"application/x-csh",css:"text/css",csv:"text/csv",doc:"application/msword",dll:"application/octet-stream",dmg:"application/x-apple-diskimage",eot:"application/vnd.ms-fontobject",epub:"application/epub+zip",gif:"image/gif",htm:"text/html",html:"text/html",ico:"image/x-icon",ics:"text/calendar",jar:"application/java-archive",jpeg:"image/jpeg",jpg:"image/jpeg",js:"application/javascript",json:"application/json",mid:"audio/midi",midi:"audio/midi",mp2:"audio/mpeg",mp3:"audio/mpeg",mp4:"video/mp4",mpa:"video/mpeg",mpe:"video/mpeg",mpeg:"video/mpeg",mpkg:"application/vnd.apple.installer+xml",odp:"application/vnd.oasis.opendocument.presentation",ods:"application/vnd.oasis.opendocument.spreadsheet",odt:"application/vnd.oasis.opendocument.text",oga:"audio/ogg",ogv:"video/ogg",ogx:"application/ogg",otf:"font/otf",png:"image/png",pdf:"application/pdf",ppt:"application/vnd.ms-powerpoint",rar:"application/x-rar-compressed",rtf:"application/rtf",sh:"application/x-sh",svg:"image/svg+xml",swf:"application/x-shockwave-flash",tar:"application/x-tar",tif:"image/tiff",tiff:"image/tiff",ts:"application/typescript",ttf:"font/ttf",txt:"text/plain",vsd:"application/vnd.visio",wav:"audio/x-wav",weba:"audio/webm",webm:"video/webm",webp:"image/webp",woff:"font/woff",woff2:"font/woff2",xhtml:"application/xhtml+xml",xls:"application/vnd.ms-excel",xlsx:"application/vnd.ms-excel",xml:"application/xml",xul:"application/vnd.mozilla.xul+xml",zip:"application/zip","3gp":"video/3gpp","3gp2":"video/3gpp2","7z":"application/x-7z-compressed"};function Vl(e){return["text/html","text/css"].includes(e)?`${e}; charset=utf-8`:e}function Dl(e){if(!function(e){return!!Array.isArray(e)&&e.every((e=>"object"==typeof e&&e.path&&void 0!==e.size))}(e))throw new tu("invalid collection",e)}function Nl(e){if(e.webkitRelativePath&&""!==e.webkitRelativePath)return e.webkitRelativePath.replace(/.*?\//i,"");if(e.name)return e.name;throw new TypeError("file is not valid File object")}function Pl(e){return Array.from(e).map((e=>({path:Nl(e),size:e.size,file:e})))}function Cl(e){return Array.from(e).reduce(((e,t)=>e+t.size),0)}class Fl{output=new au.PassThrough;currentFileSize=0;beginFile(e,t){const{name:n,prefix:r,longLink:o}=function(e){if(e.length<=100)return{name:e,prefix:"",longLink:!1};for(let r=e.length-1;r>=0;r--)if("/"===e[r]){const t=e.substring(r+1),n=e.substring(0,r);if(t.length<=100&&n.length<=155)return{name:t,prefix:n,longLink:!1}}const t=e.lastIndexOf("/"),n=(t>=0?e.substring(t+1):e).slice(0,100);return{name:n,prefix:"",longLink:!0}}(e);if(o){const t=Buffer.from(e+"\0");this.output.write(function(e){const t=Buffer.alloc(512,0);t.write("././@LongLink",0,100),t.write("0000644\0",100,8),t.write("0000000\0",108,8),t.write("0000000\0",116,8),t.write(e.toString(8).padStart(11,"0")+"\0",124,12),t.write("00000000000\0",136,12),t.write(" ",148,8),t.write("L",156,1),t.write("ustar\0\0",257,8);let n=0;for(let r=0;r<512;r++)n+=t[r];return t.write(n.toString(8).padStart(6,"0")+"\0 ",148,8),t}(t.length)),this.output.write(t);const n=t.length%512==0?0:512-t.length%512;n>0&&this.output.write(Buffer.alloc(n,0))}const i=function(e,t,n){const r=Buffer.alloc(512,0);r.write(e.slice(0,100).padEnd(100,"\0"),0,100),r.write("0000777\0",100,8),r.write("0001750\0",108,8),r.write("0001750\0",116,8),r.write(n.toString(8).padStart(11,"0")+"\0",124,12);const o=Math.floor((new Date).getTime()/1e3);r.write(o.toString(8).padStart(11,"0")+"\0",136,12),r.write(" ",148,8),r.write("0",156,1),r.write("ustar\0\0",257,8),t&&r.write(t.slice(0,155).padEnd(155,"\0"),345,155);let i=0;for(let s=0;s<512;s++)i+=r[s];return r.write(i.toString(8).padStart(6,"0")+"\0 ",148,8),r}(n,r,t);this.output.write(i),this.currentFileSize=0}async appendFile(e){return new Promise((t=>{this.output.write(e)?t():this.output.once("drain",(()=>{t()})),this.currentFileSize+=e.length}))}async endFile(){const e=this.currentFileSize%512==0?0:512-this.currentFileSize%512;e>0&&this.output.write(Buffer.alloc(e,0))}async end(){return new Promise((e=>{this.output.write(Buffer.alloc(1024,0)),this.output.end((()=>{e()}))}))}}async function Gl(e,t,n,r){const o=new Fl,i=Wc(e,{method:"post",url:"bzz",data:o.output,responseType:"json",headers:{"content-type":"application/x-tar","swarm-collection":"true",...Xu(n,r)}});await async function(e,t){for(const n of e)if(t.beginFile(n.path,n.size),n.fsPath){const e=(0,xl.createReadStream)(n.fsPath);for await(const n of e)await t.appendFile(n);await t.endFile(),e.close()}else{if(!n.file)throw new Error("Invalid collection item");await t.appendFile(new Uint8Array(await n.file.arrayBuffer())),await t.endFile()}}(t,o),await o.end();return await i}const Ul="bzz";async function Ml(e,t,n,r,o){Fu(t)&&!o?.contentType&&(o||(o={}),o.contentType="application/octet-stream");const i=await Wc(e,{method:"post",url:Ul,data:t,headers:Xu(n,o),params:{name:r},responseType:"json"});return{reference:Qc.parse(i.data).reference,tagUid:i.headers["swarm-tag"]?Mu(i.headers["swarm-tag"]):void 0,historyAddress:i.headers["swarm-act-history-address"]?ar.Xx.of(new nn(i.headers["swarm-act-history-address"])):ar.Xx.empty()}}async function Ll(e,t,n,r){Dl(t);const o=await Gl(e,t,n,r);return{reference:Qc.parse(o.data).reference,tagUid:o.headers["swarm-tag"]?Mu(o.headers["swarm-tag"]):void 0,historyAddress:o.headers["swarm-act-history-address"]?ar.Xx.of(new nn(o.headers["swarm-act-history-address"])):ar.Xx.empty()}}class jl{constructor(e){this.context=e}async upload(e,t,n,r){const o=new Pt(e);return Dl(t),n&&(n=$u.parse(n)),Ll(this.context.getRequestOptionsForCall(r),t,o,n)}async uploadFromFileList(e,t,n,r){const o=new Pt(e);n&&(n=$u.parse(n));const i=Pl(t);return Ll(this.context.getRequestOptionsForCall(r),i,o,n)}async uploadFromDirectory(e,t,n,r){const o=new Pt(e);n&&(n=$u.parse(n));const i=await Sl(t);return Ll(this.context.getRequestOptionsForCall(r),i,o,n)}async stream(e,t,n,r,o){new Pt(e);return async function(){throw new Error("Streaming files is not supported in Node.js")}(this.context.bee,0,0,0,0,this.context.getRequestOptionsForCall(o))}async streamFromDirectory(e,t,n,r,o){const i=new Pt(e);return async function(e,t,n,r,o,i){const s=new ar.O3(64,64);let a=0,c=0;n=new Pt(n);const u=await Sl(t);for(const m of u)a+=(l=m.size,function e(t){return t<=1?t:t+e(Math.ceil(t/128))}(Math.ceil(l/4096)));var l;let f=!1;async function h(t){await e.chunk.upload(n,t.build(),o,i),r?.({total:a,processed:++c})}async function d(e){for(const{chunk:t}of e)await s.enqueue((async()=>h(t)));return[]}const p=new Al;for(const m of u){if(!m.fsPath)throw Error("File does not have fsPath, which should never happen in node. Please report this issue.");const e=(0,xl.createReadStream)(m.fsPath),t=new An(d);for await(const i of e)await t.append(i);const n=await t.finalize();await s.enqueue((async()=>h(n))),await s.drain();const{filename:r,extension:o}=ar.DH.parseFilename(m.path);p.addFork(m.path,n.hash(),{"Content-Type":Vl(_l[o.toLowerCase()]||"application/octet-stream"),Filename:r}),"index.html"===m.path&&(f=!0)}if(f||o?.indexDocument||o?.errorDocument){const e={};o?.indexDocument?e["website-index-document"]=o.indexDocument:f&&(e["website-index-document"]="index.html"),o?.errorDocument&&(e["website-error-document"]=o.errorDocument),p.addFork("/",Zh,e)}return p.saveRecursively(e,n,o,i)}(this.context.bee,t,i,n,r,this.context.getRequestOptionsForCall(o))}async hashDirectory(e){return async function(e){const t=await Sl(e),n=new Al;for(const r of t){const e=new An(An.NOOP);if(!r.fsPath)throw Error("File does not have fsPath, which should never happen in node. Please report this issue.");const t=(0,xl.createReadStream)(r.fsPath);for await(const n of t)await e.append(n);const o=await e.finalize(),{filename:i,extension:s}=ar.DH.parseFilename(r.path);n.addFork(r.path,o.hash(),{"Content-Type":Vl(_l[s.toLowerCase()]||"application/octet-stream"),Filename:i})}return n.calculateSelfAddress()}(e)}}const Zl=yc({address:_a(),fullNode:ic()}),ql=yc({population:tc(),connected:tc(),connectedPeers:mc(yc({address:_a()})).nullish().transform((e=>e??[])),disconnectedPeers:mc(yc({address:_a()})).nullish().transform((e=>e??[]))}),Hl=Tc(_a(),ql),Wl=yc({overlay:_a().transform((e=>new qt(e))),underlay:mc(_a()),ethereum:_a().transform((e=>new Ut(e))),publicKey:_a().transform((e=>new Jt(e))),pssPublicKey:_a().transform((e=>new Jt(e)))}),Jl=yc({peers:mc(Zl)}),Kl=yc({peers:mc(Zl)}),Xl=yc({baseAddr:_a(),population:tc(),connected:tc(),timestamp:_a(),nnLowWatermark:tc(),depth:tc(),reachability:_a(),networkAvailability:_a(),bins:Hl}),Yl=yc({overlay:_a(),proximity:tc(),beeMode:_a().transform(fu),reserveSize:tc(),reserveSizeWithinRadius:tc(),pullsyncRate:tc(),storageRadius:tc(),connectedPeers:tc(),neighborhoodSize:tc(),batchCommitment:tc(),isReachable:ic(),lastSyncedBlock:tc(),committedDepth:tc(),isWarmingUp:ic()}),Ql=yc({apiVersion:_a(),version:_a(),status:(ef="ok",new Ac({type:"literal",values:Array.isArray(ef)?ef:[ef],...oo(tf)}))});var ef,tf;const nf=yc({apiVersion:_a(),version:_a(),status:zc(["ready","notReady"])}),rf=yc({beeMode:_a().transform(fu),chequebookEnabled:ic(),swapEnabled:ic()}),of=yc({gateway:ic()}),sf="peers";class af{constructor(e){this.context=e}async checkConnection(e){return async function(e){await Wc(e,{url:"",responseType:"text"})}(this.context.getRequestOptionsForCall(e))}async isConnected(e){try{await this.checkConnection(e)}catch{return!1}return!0}async isGateway(e){try{return await async function(e){const t=await Wc(e,{url:"/gateway"});return of.parse(t.data).gateway}(this.context.getRequestOptionsForCall(e))}catch{return!1}}async getNodeAddresses(e){return async function(e){const t=await Wc(e,{url:"addresses",responseType:"json"});return Wl.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getBlocklist(e){return async function(e){const t=await Wc(e,{url:"blocklist",responseType:"json"});return Kl.parse(t.data).peers}(this.context.getRequestOptionsForCall(e))}async getPeers(e){return async function(e){const t=await Wc(e,{url:sf,responseType:"json"});return Jl.parse(t.data).peers}(this.context.getRequestOptionsForCall(e))}async removePeer(e,t){const n=new qt(e);return async function(e,t){return(await Wc(e,{url:`${sf}/${t}`,responseType:"json",method:"DELETE"})).data}(this.context.getRequestOptionsForCall(t),n)}async getTopology(e){return async function(e){const t=await Wc(e,{url:"topology",responseType:"json"});return Xl.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async ping(e,t){const n=new qt(e);return async function(e,t){return(await Wc(e,{url:`pingpong/${t}`,responseType:"json",method:"POST"})).data}(this.context.getRequestOptionsForCall(t),n)}}const cf="bytes";async function uf(e,t,n,r){const o=await Wc(e,{url:cf,method:"post",responseType:"json",data:t,headers:{"content-type":"application/octet-stream",...Xu(n,r)}});return{reference:Qc.parse(o.data).reference,tagUid:o.headers["swarm-tag"]?Mu(o.headers["swarm-tag"]):void 0,historyAddress:o.headers["swarm-act-history-address"]?ar.Xx.of(new nn(o.headers["swarm-act-history-address"])):ar.Xx.empty()}}async function lf(e,t,n){n&&(n=Au.parse(n));const r=await Wc(e,{responseType:"arraybuffer",url:`${cf}/${t}`,headers:Xu(null,n)});return new Nt(r.data)}const ff=yc({isRetrievable:ic()}),hf="stewardship";class df{constructor(e){this.raw=e}toString(){const e=_a().safeParse(this.raw);return e.success&&e.data.includes(".eth")?e.data:new nn(this.raw).toHex()}}class pf{constructor(e){this.context=e}async upload(e,t,n,r){const o=new Pt(e);return Uu(t),n&&(n=Ou.parse(n)),uf(this.context.getRequestOptionsForCall(r),t,o,n)}async download(e,t,n){return t&&(t=Au.parse(t)),lf(this.context.getRequestOptionsForCall(n),new df(e),t)}async downloadReadable(e,t,n){return t&&(t=Au.parse(t)),async function(e,t,n){return n&&(n=Au.parse(n)),(await Wc(e,{responseType:"stream",url:`${cf}/${t}`,headers:Xu(null,n)})).data}(this.context.getRequestOptionsForCall(n),new df(e),t)}async probe(e,t){const n=new nn(e);return async function(e,t){const n=await Wc(e,{url:`${cf}/${t}`,method:"head",responseType:"json"});return{contentLength:parseInt(n.headers["content-length"])}}(this.context.getRequestOptionsForCall(t),n)}async isRetrievable(e,t){const n=new nn(e);return async function(e,t){const n=await Wc(e,{method:"get",responseType:"json",url:`${hf}/${t}`});return ff.parse(n.data).isRetrievable}(this.context.getRequestOptionsForCall(t),n)}}const mf="feeds";function gf(e){const t=e["swarm-feed-index"],n=e["swarm-feed-index-next"];if(!t)throw new eu("Response did not contain expected swarm-feed-index!");if(!n)throw new eu("Response did not contain expected swarm-feed-index-next!");return{feedIndex:new Lt(t),feedIndexNext:new Lt(n)}}async function yf(e,t,n,r){const o=await Wc(e,{responseType:"arraybuffer",url:`${mf}/${t}/${n}`,params:{...r}});return{payload:new Nt(o.data),...gf(o.headers)}}async function wf(e,t,n){return gf((await Wc(e,{responseType:"arraybuffer",url:`${mf}/${t}/${n}`,params:{"Swarm-Only-Root-Chunk":!0}})).headers)}function bf(e,t){return t="number"==typeof t?Lt.fromBigInt(BigInt(t)):t,new Zt(St(Nt.concat(e.toUint8Array(),t.toUint8Array())))}async function vf(e,t,n){try{const r=await yf(e,t,n);if(!r.feedIndexNext)throw Error("Feed index next is not defined. This should happen when fetching an exact index.");return r.feedIndexNext}catch(r){if(r instanceof nu)return Lt.fromBigInt(0n);throw r}}async function Bf(e,t,n,r,o,i){r=new nn(r);const s=bf(n,i?.index??await vf(e,t.publicKey().address(),n)),a=i?.at??Date.now()/1e3,c=At(BigInt(Math.floor(a)),"BE");return nl(e,t,o,s,Nt.concat(c,r.toUint8Array()),i)}async function Ef(e,t,n,r,o,i){const s=bf(n,i?.index??await vf(e,t.publicKey().address(),n));if(r.length>4096){const n=await uf(e,r,o,i);return rl(e,t,o,s,Rn(await Qu(e,n.reference)),i)}const a=_a().safeParse(r);return nl(e,t,o,s,a.success?Nt.fromUtf8(a.data).toUint8Array():r,i)}function xf(e,t,n){const r=bf(t,n);return new nn(St(Nt.concat(r.toUint8Array(),e.toUint8Array())))}async function Tf(e,t,n,r,o=!1){const i=xf(t,n,r="number"==typeof r?Lt.fromBigInt(BigInt(r)):r),s=el(await Qu(e,i.toHex()),i);let a=ar.Xx.empty();if(o){const e=Nt.fromSlice(s.payload.toUint8Array(),0,8);a=ar.Xx.of(Number(kt(e.toUint8Array(),"BE")))}return{timestamp:a,payload:new Nt(s.payload.offset(o?8:0))}}async function Rf(e,t,n,r){const o=xf(t,n,r="number"==typeof r?Lt.fromBigInt(BigInt(r)):r),i=el(await Qu(e,o),o);return Tn(i.payload,i.span)}function zf(e,t,n){const r=async r=>{if(void 0===r?.index)return yf(e,n,t);const o=await Tf(e,n,t,r.index,r.hasTimestamp??!0),i="number"==typeof r.index?Lt.fromBigInt(BigInt(r.index)):r.index;return{payload:o.payload,feedIndex:i,feedIndexNext:i.next()}};return{download:r,downloadPayload:async r=>{if(void 0===r?.index)return yf(e,n,t);const o=await Rf(e,n,t,r.index),i=o.span.toBigInt()<=4096n?o.payload:await lf(e,new df(o.address)),s="number"==typeof r.index?Lt.fromBigInt(BigInt(r.index)):r.index;return{payload:i,feedIndex:s,feedIndexNext:s.next()}},downloadReference:async o=>{let i=o?.index;void 0===i&&(i=(await wf(e,n,t)).feedIndex);const s=await r({...o,index:i});return{reference:new nn(s.payload.toUint8Array()),feedIndex:s.feedIndex,feedIndexNext:s.feedIndexNext??s.feedIndex.next()}},owner:n,topic:t}}async function Af(e,t,n,r,o,i){const s=function(e,t,n){const r=n.toBigInt(),o=[];for(let i=0n;i<=r;i++)o.push(xf(e,t,Lt.fromBigInt(i)));return o}(t,n,r).map((async t=>async function(e,t,n,r){try{return await e.chunk.download(t,n,r),!0}catch(o){const e=ar.Rb.getDeep(o,"status");if(404===e||500===e)return!1;throw o}}(e,t,o,i)));return(await Promise.all(s)).every((e=>e))}class kf{constructor(e){this.context=e}makeReader(e,t,n){return zf(this.context.getRequestOptionsForCall(n),new sn(e),new Ut(t))}makeWriter(e,t,n){const r=t?new en(t):this.context.signer;if(!r)throw Error("No signer provided");return function(e,t,n){const r=async(r,o,i)=>Bf(e,n,t,o,r,i);return{...zf(e,t,n.publicKey().address()),upload:r,uploadReference:r,uploadPayload:async(r,o,i)=>Ef(e,n,t,o,r,i)}}(this.context.getRequestOptionsForCall(n),new sn(e),r)}async createManifest(e,t,n,r,o){const i=new Pt(e),s=new sn(t),a=new Ut(n);return r&&(r=ku.parse(r)),async function(e,t,n,r,o){const i=await Wc(e,{method:"post",responseType:"json",url:`${mf}/${t}/${n}`,headers:Xu(r,o)});return Qc.parse(i.data).reference}(this.context.getRequestOptionsForCall(o),a,s,i,r)}async fetchLatestUpdate(e,t,n){return yf(this.context.getRequestOptionsForCall(n),new Ut(t),new sn(e))}async isRetrievable(e,t,n,r,o){const i=new Ut(e),s=new sn(t);if(r&&(r=Au.parse(r)),!n)try{return await this.makeReader(s,i,o).download(),!0}catch(a){const e=ar.Rb.getDeep(a,"status");if(404===e||500===e)return!1;throw a}return Af(this.context.bee,i,s,n,r,this.context.getRequestOptionsForCall(o))}}class Of{constructor(e){this.context=e}async upload(e,t,n,r,o){const i=new Pt(e);if(function(e){if(!("string"==typeof e||e instanceof Uint8Array||cu(e)||Fu(e)))throw new TypeError("Data must be either string, Readable, Uint8Array or File!")}(t),r&&(r=Su.parse(r)),n&&"string"!=typeof n)throw new TypeError("name has to be string or undefined!");if(cu(t)){const e=await async function(e){return e.arrayBuffer?e.arrayBuffer():new Promise((t=>{const n=new FileReader;n.onload=()=>t(n.result),n.readAsArrayBuffer(e)}))}(t),s=n??t.name,a=t.type,c={...r,contentType:a};return Ml(this.context.getRequestOptionsForCall(o),e,i,s,c)}return Ml(this.context.getRequestOptionsForCall(o),t,i,n,r)}async download(e,t="",n,r){return n&&(n=Au.parse(n)),async function(e,t,n="",r){const o=await Wc(e,{method:"GET",responseType:"arraybuffer",url:`${Ul}/${t}/${n}`,headers:Xu(null,r)});return{...Ku(o.headers),data:new Nt(o.data)}}(this.context.getRequestOptionsForCall(r),new df(e),t,n)}async downloadReadable(e,t="",n,r){const o=new nn(e);return n&&(n=Au.parse(n)),async function(e,t,n="",r){t=new nn(t);const o=await Wc(e,{method:"GET",responseType:"stream",url:`${Ul}/${t}/${n}`,headers:Xu(null,r)});return{...Ku(o.headers),data:o.data}}(this.context.getRequestOptionsForCall(r),o,t,n)}}const Sf=mc(_a().transform((e=>new Jt(e)))),$f=yc({ref:_a().transform((e=>new nn(e))),historyref:_a().transform((e=>new nn(e)))}),If="grantee";class _f{constructor(e){this.context=e}async create(e,t,n){const r=new Pt(e),o=t.map((e=>new Jt(e)));return async function(e,t,n){const r=await Wc(e,{method:"post",url:If,data:{grantees:n.map((e=>e.toCompressedHex()))},headers:Xu(t),responseType:"json"}),o=$f.parse(r.data);return{status:r.status,statusText:r.statusText,ref:o.ref,historyref:o.historyref}}(this.context.getRequestOptionsForCall(n),r,o)}async get(e,t){const n=new nn(e);return async function(e,t){const n=await Wc(e,{method:"get",url:`${If}/${t}`,responseType:"json"});return{status:n.status,statusText:n.statusText,grantees:Sf.parse(n.data)}}(this.context.getRequestOptionsForCall(t),n)}async patch(e,t,n,r,o){const i=new Pt(e),s=new nn(t),a=new nn(n),c={add:r.add?.map((e=>new Jt(e)))??[],revoke:r.revoke?.map((e=>new Jt(e)))??[]};return async function(e,t,n,r,o){const i=await Wc(e,{method:"patch",url:`${If}/${n}`,data:{add:o.add.map((e=>e.toCompressedHex())),revoke:o.revoke.map((e=>e.toCompressedHex()))},headers:{...Xu(t),"swarm-act-history-address":r.toHex()},responseType:"json"}),s=$f.parse(i.data);return{status:i.status,statusText:i.statusText,ref:s.ref,historyref:s.historyref}}(this.context.getRequestOptionsForCall(o),i,s,a,c)}}var Vf=null;"undefined"!=typeof WebSocket?Vf=WebSocket:"undefined"!=typeof MozWebSocket?Vf=MozWebSocket:void 0!==n.g?Vf=n.g.WebSocket||n.g.MozWebSocket:"undefined"!=typeof window?Vf=window.WebSocket||window.MozWebSocket:"undefined"!=typeof self&&(Vf=self.WebSocket||self.MozWebSocket);const Df=Vf;async function Nf(e){if("string"==typeof e)return(new TextEncoder).encode(e);if(e instanceof Buffer)return new Uint8Array(e);if(e instanceof ArrayBuffer)return new Uint8Array(e);if(t=e,Array.isArray(t)&&t.length>0&&t.every((e=>e instanceof Buffer)))return new Uint8Array(Buffer.concat(e));var t;throw new TypeError("unknown websocket data type")}class Pf{constructor(e){this.context=e}async pssSend(e,t,n,r,o,i){const s=new Pt(e);Uu(r);const a=o?new Jt(o):void 0;await async function(e,t,n,r,o,i){await Wc(e,{method:"post",url:`pss/send/${n}/${r}`,data:o,responseType:"json",params:{recipient:i},headers:Xu(t)})}(this.context.getRequestOptionsForCall(i),s,t,n,r,a)}pssSubscribe(e,t){t=Vu.parse(t);const n=this.openWebSocket(`pss/subscribe/${e.toHex()}`),r={topic:e,cancel:this.makeCancel(n)};return n.onmessage=async e=>{const n=await Nf(e.data);n.length&&t.onMessage(new Nt(n),r)},n.onerror=e=>{this.isCancelled(n)||t.onError(new eu(e.message),r)},n.onclose=()=>{t.onClose(r)},r}async pssReceive(e,t=0){if("number"!=typeof t)throw new TypeError("timeoutMsc parameter has to be a number!");return new Promise(((n,r)=>{let o;const i=this.pssSubscribe(e,{onError:e=>{clearTimeout(o),i.cancel(),r(e.message)},onMessage:e=>{clearTimeout(o),i.cancel(),n(e)},onClose:()=>{clearTimeout(o),i.cancel()}});t>0&&(o=setTimeout((()=>{i.cancel(),r(new eu("pssReceive timeout"))}),t))}))}gsocMine(e,t,n=12){const r=new qt(e),o=new Zt(t);for(let i=0n;i<0xffffn;i++){const e=new en(mt(2867n+i,"BE")),t=Bn(o,e.publicKey().address());if(256-ar.yI.proximity(t.toUint8Array(),r.toUint8Array())<=256-n)return e}throw Error("Could not mine a valid signer")}async gsocSend(e,t,n,r,o,i){const s=new Pt(e),a=new en(t),c=new Zt(n),u=Tn(r).toSingleOwnerChunk(c,a);return tl(this.context.getRequestOptionsForCall(i),u,s,o)}gsocSubscribe(e,t,n){const r=new Ut(e),o=new Zt(t);n=Du.parse(n);const i=Bn(o,r),s=this.openWebSocket(`gsoc/subscribe/${i.toHex()}`),a={address:r,cancel:this.makeCancel(s)};return s.onmessage=async e=>{const t=await Nf(e.data);t.length&&n.onMessage(new Nt(t),a)},s.onerror=e=>{this.isCancelled(s)||n.onError(new eu(e.message),a)},s.onclose=()=>{n.onClose(a)},a}openWebSocket(e){const t=this.context.url.replace(/^http/i,"ws");return"browser"===ar.iQ.whereAmI()?new Df(`${t}/${e}`):new Df(`${t}/${e}`,{headers:this.context.getRequestOptionsForCall().headers})}cancelled=new WeakSet;makeCancel(e){return()=>{this.cancelled.has(e)||(this.cancelled.add(e),e.terminate?e.terminate():e.close())}}isCancelled(e){return this.cancelled.has(e)}}const Cf=yc({references:mc(_a()).nullable()}),Ff="pins";class Gf{constructor(e){this.context=e}async add(e,t){const n=new nn(e);await async function(e,t){await Wc(e,{method:"post",responseType:"json",url:`${Ff}/${t}`})}(this.context.getRequestOptionsForCall(t),n)}async remove(e,t){const n=new nn(e);await async function(e,t){await Wc(e,{method:"delete",responseType:"json",url:`${Ff}/${t}`})}(this.context.getRequestOptionsForCall(t),n)}async getAll(e){return async function(e){const t=await Wc(e,{method:"get",responseType:"json",url:Ff}),{references:n}=Cf.parse(t.data);return(n??[]).map((e=>new nn(e)))}(this.context.getRequestOptionsForCall(e))}async get(e,t){const n=new nn(e);return async function(e,t){const n=await Wc(e,{method:"get",responseType:"json",url:`${Ff}/${t}`});return Qc.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async reuploadData(e,t,n){const r=new Pt(e),o=new nn(t);await async function(e,t,n){await Wc(e,{method:"put",url:`${hf}/${n}`,headers:{"swarm-postage-batch-id":t.toHex()}})}(this.context.getRequestOptionsForCall(n),r,o)}}function Uf(e,t){if(t<=0)throw new eu("Period length must be greater than zero!");return Math.floor(e/t)}function Mf(e,t){const n=e.toUint8Array();return new sn(St(Nt.concat(n,At(BigInt(t),"BE"))))}async function Lf(e,t,n){try{return await wf(e,t,n),!0}catch(r){if(r instanceof nu)return!1;throw r}}async function jf(e,t,n){const{feedIndex:r}=await wf(e,t,n),o=await Tf(e,t,n,r,!0);return{reference:new nn(o.payload.toUint8Array()),feedIndex:r,feedIndexNext:r.next()}}class Zf{constructor(e){this.context=e}makeWriter(e,t,n){return new qf(this.context,e,t,n)}makeReader(e,t,n){return new Hf(this.context,e,t,n)}}class qf{constructor(e,t,n,r){this.context=e,this.baseTopic=t,this.signer=n,this.periodLength=r}async uploadPayload(e,t,n){const r=this.context.getRequestOptionsForCall(),o=new Pt(e),{currentTopic:i,nextTopic:s,mirrorOptions:a}=this.currentAndNextTopics(n),[c]=await Promise.all([Ef(r,this.signer,i,t,o,n),Ef(r,this.signer,s,t,o,a)]);return c}async uploadReference(e,t,n){const r=this.context.getRequestOptionsForCall(),o=new Pt(e),{currentTopic:i,nextTopic:s,mirrorOptions:a}=this.currentAndNextTopics(n),[c]=await Promise.all([Bf(r,this.signer,i,t,o,n),Bf(r,this.signer,s,t,o,a)]);return c}async isCaughtUp(e){const t=this.context.getRequestOptionsForCall(),n=e??Uf(Date.now()/1e3,this.periodLength);return Lf(t,this.signer.publicKey().address(),Mf(this.baseTopic,n))}async catchUp(e,t,n=1){const r=this.context.getRequestOptionsForCall(),o=new Pt(e),i=this.signer.publicKey().address(),s=t??Uf(Date.now()/1e3,this.periodLength),a=Math.max(0,s-1-n);let c=s-1;for(;c>=a&&!await Lf(r,i,Mf(this.baseTopic,c));)c--;if(c<a)throw new eu(`No populated period found within ${n} periods to catch up from!`);if(c===s-1)return;const u=Mf(this.baseTopic,c),{feedIndex:l}=await wf(r,i,u),f=await Rf(r,i,u,l),h=Array.from({length:s-1-c},((e,t)=>c+1+t));await Promise.all(h.map((async e=>{const t=bf(Mf(this.baseTopic,e),0);return rl(r,this.signer,o,t,f)})))}currentAndNextTopics(e){const t=Uf(Date.now()/1e3,this.periodLength);return{currentTopic:Mf(this.baseTopic,t),nextTopic:Mf(this.baseTopic,t+1),mirrorOptions:{...e,index:void 0}}}}class Hf{constructor(e,t,n,r){this.context=e,this.baseTopic=t,this.owner=n,this.periodLength=r}async downloadPayload(e){const t=this.context.getRequestOptionsForCall(),n=Uf(Date.now()/1e3,this.periodLength);try{return await yf(t,this.owner,Mf(this.baseTopic,n),e)}catch(r){if(!(r instanceof nu))throw r;return yf(t,this.owner,Mf(this.baseTopic,n-1),e)}}async downloadReference(){const e=this.context.getRequestOptionsForCall(),t=Uf(Date.now()/1e3,this.periodLength);try{return await jf(e,this.owner,Mf(this.baseTopic,t))}catch(n){if(!(n instanceof nu))throw n;return jf(e,this.owner,Mf(this.baseTopic,t-1))}}}const Wf=yc({peer:_a(),sent:_a().transform((e=>iu.fromPLUR(Gu(e,{name:"sent"})))),received:_a().transform((e=>iu.fromPLUR(Gu(e,{name:"received"}))))}),Jf=Wf,Kf=yc({totalSent:_a().transform((e=>iu.fromPLUR(Gu(e,{name:"totalSent"})))),totalReceived:_a().transform((e=>iu.fromPLUR(Gu(e,{name:"totalReceived"})))),settlements:mc(Wf)}),Xf="settlements";class Yf{constructor(e){this.context=e}async get(e,t){const n=new qt(e);return async function(e,t){const n=await Wc(e,{url:`${Xf}/${t}`,responseType:"json"});return Jf.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async getAll(e){return async function(e){const t=await Wc(e,{url:Xf,responseType:"json"});return Kf.parse(t.data)}(this.context.getRequestOptionsForCall(e))}}class Qf{constructor(e){this.context=e}makeReader(e,t){const n=new Ut(e);return{owner:n,download:ol.bind(null,this.context.getRequestOptionsForCall(t),n)}}makeWriter(e,t){const n=e?new en(e):this.context.signer;if(!n)throw Error("No signer provided");return{...this.makeReader(n.publicKey().address(),t),upload:nl.bind(null,this.context.getRequestOptionsForCall(t),n)}}}const eh=yc({stakedAmount:_a().transform((e=>iu.fromPLUR(Gu(e,{name:"stakedAmount"}))))}),th=yc({withdrawableAmount:_a().transform((e=>iu.fromPLUR(Gu(e,{name:"withdrawableAmount"}))))}),nh=yc({txHash:_a().transform((e=>new an(e)))}),rh=yc({minimumGasFunds:_a().transform((e=>su.fromWei(Gu(e,{name:"minimumGasFunds"})))),hasSufficientFunds:ic(),isFrozen:ic(),isFullySynced:ic(),phase:_a(),round:tc(),lastWonRound:tc(),lastPlayedRound:tc(),lastFrozenRound:tc(),lastSelectedRound:tc(),lastSampleDurationSeconds:tc(),block:tc(),reward:_a().transform((e=>iu.fromPLUR(Gu(e,{name:"reward"})))),fees:_a().transform((e=>su.fromWei(Gu(e,{name:"fees"})))),isHealthy:ic()}),oh="stake";class ih{constructor(e){this.context=e}async get(e){return async function(e){const t=await Wc(e,{method:"get",responseType:"json",url:oh});return eh.parse(t.data).stakedAmount}(this.context.getRequestOptionsForCall(e))}async getWithdrawable(e){return async function(e){const t=await Wc(e,{method:"get",responseType:"json",url:`${oh}/withdrawable`});return th.parse(t.data).withdrawableAmount}(this.context.getRequestOptionsForCall(e))}async deposit(e,t,n){const r=e instanceof iu?e.toPLURString():Gu(e,{min:1n,name:"amount"});return t&&(t=Pu.parse(t)),async function(e,t,n){const r=await Wc(e,{method:"post",responseType:"json",url:`${oh}/${t}`,headers:Xu(null,n)});return nh.parse(r.data).txHash}(this.context.getRequestOptionsForCall(n),r,t)}async withdrawSurplus(e){return async function(e){const t=await Wc(e,{method:"delete",responseType:"json",url:`${oh}/withdrawable`});return nh.parse(t.data).txHash}(this.context.getRequestOptionsForCall(e))}async migrate(e){return async function(e){const t=await Wc(e,{method:"delete",responseType:"json",url:oh});return nh.parse(t.data).txHash}(this.context.getRequestOptionsForCall(e))}async getRedistributionState(e){return async function(e){const t=await Wc(e,{method:"get",responseType:"json",url:"redistributionstate"});return rh.parse(t.data)}(this.context.getRequestOptionsForCall(e))}}const sh=yc({batchID:_a(),utilization:tc(),utilizationRatio:tc().optional(),usable:ic(),label:_a(),depth:tc(),amount:_a(),bucketDepth:tc(),blockNumber:tc(),immutableFlag:ic(),batchTTL:tc()}),ah=yc({batchID:_a().transform((e=>new Pt(e))),batchTTL:tc(),bucketDepth:tc(),depth:tc(),immutable:ic(),owner:_a().transform((e=>new Ut(e))),start:tc(),value:_a().transform((e=>Gu(e,{name:"value"})))}),ch=yc({batches:mc(ah)}),uh=yc({stamps:mc(sh)}),lh=sh,fh=yc({depth:tc(),bucketDepth:tc(),bucketUpperBound:tc(),buckets:mc(yc({bucketID:tc(),collisions:tc()}))}),hh=yc({batchID:_a().transform((e=>new Pt(e)))}),dh="stamps";const ph="batches";class mh{constructor(e){this.context=e}async create(e,t,n,r){const o=Gu(e,{min:0n,name:"amount"});if(n&&(n=Nu.parse(n)),t<gu||t>yu)throw new tu(`Depth has to be between ${gu}..${yu}`,t);const i=await this.context.bee.status.getChainState(),s=17280n*BigInt(i.currentPrice)+1n;if(BigInt(o)<s)throw new tu(`Amount has to be at least ${s} (1 day at current price ${i.currentPrice})`,o);const a=await async function(e,t,n,r,o,i){const s={};o&&(s["gas-price"]=o),void 0!==i&&(s.immutable=String(i));const a=await Wc(e,{method:"post",url:`${dh}/${t}/${n}`,responseType:"json",params:{label:r},headers:s});return hh.parse(a.data).batchID}(this.context.getRequestOptionsForCall(r),o,t,n?.label,n?.gasPrice?.toString(),n?.immutableFlag);return!1!==n?.waitForUsable&&await this.waitForUsable(a,n?.waitForUsableTimeout),a}async updateLabel(e,t,n){const r=new Pt(e);await async function(e,t,n){await Wc(e,{method:"patch",url:`${dh}/${t}`,responseType:"json",data:{label:n}})}(this.context.getRequestOptionsForCall(n),r,t)}async calculateTopUpForBZZ(e,t,n){const r=await this.context.bee.status.getChainState(n),o="gnosis"===this.context.network?5:15,i=t.toPLURBigInt()/2n**BigInt(e);return{amount:i,duration:ju(i,r.currentPrice,o)}}async topUp(e,t,n){const r=new Pt(e),o=Gu(t,{min:1n,name:"amount"});return async function(e,t,n){const r=await Wc(e,{method:"patch",url:`${dh}/topup/${t}/${n}`,responseType:"json"});return hh.parse(r.data).batchID}(this.context.getRequestOptionsForCall(n),r,o)}async dilute(e,t,n){const r=new Pt(e),o=tc().int().min(18).max(255).parse(t);return async function(e,t,n){const r=await Wc(e,{method:"patch",url:`${dh}/dilute/${t}/${n}`,responseType:"json"});return hh.parse(r.data).batchID}(this.context.getRequestOptionsForCall(n),r,o)}async get(e,t,n,r){const o=new Pt(e);return async function(e,t,n,r){const o=await Wc(e,{method:"get",url:`${dh}/${t}`,responseType:"json"});return Wu(lh.parse(o.data),n,r)}(this.context.getRequestOptionsForCall(t),o,n,r)}async getGlobal(e,t){const n=new Pt(e);return async function(e,t){const n=await Wc(e,{method:"get",url:`${ph}/${t}`,responseType:"json"});return ah.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async getBuckets(e,t){const n=new Pt(e);return async function(e,t){const n=await Wc(e,{method:"get",url:`${dh}/${t}/buckets`,responseType:"json"});return fh.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async getAll(e){return async function(e){const t=await Wc(e,{method:"get",url:dh,responseType:"json"});return uh.parse(t.data).stamps.map((e=>Wu(e)))}(this.context.getRequestOptionsForCall(e))}async getAllGlobal(e){return async function(e){const t=await Wc(e,{method:"get",url:ph,responseType:"json"});return ch.parse(t.data).batches}(this.context.getRequestOptionsForCall(e))}async waitForUsable(e,t=24e4){for(let n=0;n<t;n+=3e3){try{if((await this.get(e)).usable)return}catch{}await ar.iQ.sleepMillis(3e3)}throw new eu("Timeout on waiting for postage stamp to become usable")}}var gh=n(359),yh=n.n(gh);const wh="2.8.1-7cf53193",bh=wh.split("-")[0],vh="8.1.0",Bh=yc({commitment:tc(),radius:tc(),storageRadius:tc(),reserveCapacityDoubling:tc()}),Eh=yc({block:tc(),chainTip:tc(),totalAmount:_a().transform((e=>Gu(e,{name:"totalAmount"}))),currentPrice:_a().transform(Number).transform((e=>{return t=e,Number.isInteger(t)?t<24e3?24e3:t:24e3;var t})),minimumValidityBlocks:tc().optional()}),xh=yc({bzzBalance:_a().transform((e=>iu.fromPLUR(Gu(e,{name:"bzzBalance"})))),nativeTokenBalance:_a().transform((e=>su.fromWei(Gu(e,{name:"nativeTokenBalance"})))),chainID:tc(),chequebookContractAddress:_a(),walletAddress:_a()}),Th=yc({transactionHash:_a().transform((e=>new an(e)))});class Rh{constructor(e){this.context=e}async get(e){return async function(e){const t=await Wc(e,{method:"get",url:"status",responseType:"json"});return Yl.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getHealth(e){return async function(e){const t=await Wc(e,{method:"get",url:"health",responseType:"json"});return Ql.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getReadiness(e){return async function(e){const t=await Wc(e,{method:"get",url:"readiness"});return nf.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getNodeInfo(e){return async function(e){const t=await Wc(e,{method:"get",url:"node",responseType:"json"});return rf.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async isSupportedExactVersion(e){const{version:t}=await this.getHealth(e);return t===wh}async isSupportedApiVersion(e){const{apiVersion:t}=await this.getHealth(e);return yh()(t)===yh()(vh)}async getVersions(e){const{version:t,apiVersion:n}=await this.getHealth(e);return{supportedBeeVersion:wh,supportedBeeApiVersion:vh,beeVersion:t,beeApiVersion:n}}async getReserveState(e){return async function(e){const t=await Wc(e,{method:"get",url:"reservestate",responseType:"json"});return Bh.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getChainState(e){return async function(e){const t=await Wc(e,{method:"get",url:"chainstate",responseType:"json"});return Eh.parse(t.data)}(this.context.getRequestOptionsForCall(e))}}class zh{constructor(e){this.context=e}get blockTime(){return"gnosis"===this.context.network?5:15}async buy(e,t,n,r,o,i){const s=Zu(t,(await this.context.bee.status.getChainState(r)).currentPrice,this.blockTime),a=qu(e,o,i);return n&&(n=Nu.parse(n)),this.context.bee.stamp.create(s,a,n,r)}async getCost(e,t,n,r,o){const i=Zu(t,(await this.context.bee.status.getChainState(n)).currentPrice,this.blockTime);return Lu(qu(e,r,o),i)}async extend(e,t,n,r,o,i){const s=await this.context.bee.stamp.get(e,r),a=qu(t,o,i),c=await this.context.bee.status.getChainState(r),u=a-s.depth,l=u<=0?1n:2n**BigInt(u),f=Zu(n,c.currentPrice,this.blockTime),h=Zu(s.duration,c.currentPrice,this.blockTime),d=(n.isZero()?h*l:(h+f)*l)-h;let p;if(d>0n&&(p=await this.context.bee.stamp.topUp(s.batchID,d,r)),u>0)return this.context.bee.stamp.dilute(s.batchID,a,r);if(!p)throw new Error("Nothing to extend, both size and duration are already sufficient");return p}async extendSize(e,t,n,r,o){const i=await this.context.bee.status.getChainState(n),s=await this.context.bee.stamp.get(e,n),a=qu(t,r,o),c=a-s.depth;if(c<=0)throw new tu("New depth has to be greater than the original depth",a);const u=Zu(s.duration,i.currentPrice,this.blockTime);return await this.context.bee.stamp.topUp(s.batchID,u*(2n**BigInt(c)-1n)+1n,n),this.context.bee.stamp.dilute(s.batchID,a,n)}async extendDuration(e,t,n){const r=await this.context.bee.stamp.get(e,n),o=Zu(t,(await this.context.bee.status.getChainState(n)).currentPrice,this.blockTime);return this.context.bee.stamp.topUp(r.batchID,o,n)}async getExtensionCost(e,t,n,r,o,i){const s=await this.context.bee.stamp.get(e,r),a=await this.context.bee.status.getChainState(r),c=n.isZero()?0n:Zu(n,a.currentPrice,this.blockTime),u=qu(t,o,i),l=Zu(s.duration,a.currentPrice,this.blockTime),f=Lu(s.depth,l);return Lu(Math.max(s.depth,u),l+c).minus(f)}async getSizeExtensionCost(e,t,n,r,o){const i=await this.context.bee.stamp.get(e,n),s=await this.context.bee.status.getChainState(n),a=qu(t,r,o);if(a-i.depth<=0)throw new tu("New depth has to be greater than the original depth",a);const c=Zu(i.duration,s.currentPrice,this.blockTime),u=Lu(i.depth,c);return Lu(a,c).minus(u)}async getDurationExtensionCost(e,t,n){const r=await this.context.bee.stamp.get(e,n),o=Zu(t,(await this.context.bee.status.getChainState(n)).currentPrice,this.blockTime);return Lu(r.depth,o)}async rename(e,t,n){return this.context.bee.stamp.updateLabel(e,t,n)}}const Ah=yc({address:_a().nullish().transform((e=>e??"")),seen:tc(),sent:tc(),split:tc(),startedAt:_a(),stored:tc(),synced:tc(),uid:tc()}),kh=yc({tags:mc(Ah)}),Oh="tags";class Sh{constructor(e){this.context=e}async create(e){return async function(e){const t=await Wc(e,{method:"post",url:Oh,responseType:"json"});return Ah.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getAll(e,t){return e&&(e=Cu.parse(e)),async function(e,t){const n=await Wc(e,{url:Oh,params:{offset:t?.offset,limit:t?.limit},responseType:"json"});return kh.parse(n.data).tags}(this.context.getRequestOptionsForCall(t),e)}async get(e,t){const n=Mu(e);return async function(e,t){const n=await Wc(e,{url:`${Oh}/${t}`,responseType:"json"});return Ah.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async delete(e,t){const n=Mu(e);await async function(e,t){await Wc(e,{method:"delete",url:`${Oh}/${t}`})}(this.context.getRequestOptionsForCall(t),n)}async update(e,t,n){const r=new nn(t),o=Mu(e);await async function(e,t,n){await Wc(e,{method:"patch",url:`${Oh}/${t}`,data:{reference:n}})}(this.context.getRequestOptionsForCall(n),o,r)}}const $h=yc({transactionHash:_a().transform((e=>new an(e))),to:_a(),nonce:tc(),gasPrice:_a().transform((e=>Gu(e,{name:"gasPrice"}))),gasLimit:tc(),data:_a(),created:_a(),description:_a(),value:_a().transform((e=>Gu(e,{name:"value"})))}),Ih=yc({pendingTransactions:mc($h)}),_h=$h,Vh=yc({transactionHash:_a().transform((e=>new an(e)))}),Dh="transactions";class Nh{constructor(e){this.context=e}async getAll(e){return async function(e){const t=await Wc(e,{url:Dh,responseType:"json"});return Ih.parse(t.data).pendingTransactions}(this.context.getRequestOptionsForCall(e))}async get(e,t){const n=new an(e);return async function(e,t){const n=await Wc(e,{url:`${Dh}/${t}`,responseType:"json"});return _h.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async rebroadcast(e,t){const n=new an(e);return async function(e,t){const n=await Wc(e,{method:"post",url:`${Dh}/${t}`,responseType:"json"});return Vh.parse(n.data).transactionHash}(this.context.getRequestOptionsForCall(t),n)}async cancel(e,t,n){const r=new an(e),o=t?Gu(t,{min:0n,name:"gasPrice"}):void 0;return async function(e,t,n){const r={};n&&(r["gas-price"]=n);const o=await Wc(e,{method:"delete",headers:r,url:`${Dh}/${t}`,responseType:"json"});return Vh.parse(o.data).transactionHash}(this.context.getRequestOptionsForCall(n),r,o)}}const Ph="wallet";class Ch{constructor(e){this.context=e}async getBalance(e){return async function(e){const t=await Wc(e,{method:"get",url:Ph,responseType:"json"});return xh.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async withdrawBZZ(e,t,n){const r=e instanceof iu?e:iu.fromPLUR(e),o=new Ut(t);return async function(e,t,n){const r=await Wc(e,{method:"post",url:`${Ph}/withdraw/bzz`,responseType:"json",params:{amount:t.toPLURString(),address:n.toHex()}});return Th.parse(r.data).transactionHash}(this.context.getRequestOptionsForCall(n),r,o)}async withdrawDAI(e,t,n){const r=e instanceof su?e:su.fromWei(e),o=new Ut(t);return async function(e,t,n){const r=await Wc(e,{method:"post",url:`${Ph}/withdraw/nativetoken`,responseType:"json",params:{amount:t.toWeiString(),address:n.toHex()}});return Th.parse(r.data).transactionHash}(this.context.getRequestOptionsForCall(n),r,o)}}const Fh=["1","7","9","11","13","15","17","19","20","21","22","23","25","37","42","43","53","69","77","79","87","95","101","102","103","104","109","110","111","113","115","117","119","123","135","137","139","143","161","179","389","427","465","512","513","514","515","526","530","531","532","540","548","554","556","563","587","601","636","989","990","993","995","1719","1720","1723","2049","3659","4045","4190","5060","5061","6000","6566","6665","6666","6667","6668","6669","6679","6697","10080"];function Gh(e){if(!function(e){try{if("string"!=typeof e)return!1;const t=new URL(e);return"http:"===t.protocol||"https:"===t.protocol}catch(t){return!1}}(e))throw new tu("URL is not valid!",e);const t=new URL(e).port;if(t&&!function(e){if("string"!=typeof e)return!1;if(Fh.includes(e))return!1;const t=parseInt(e,10);return t>0&&t<65536&&!isNaN(t)}(t))throw new tu("Port in URL is considered bad port and cannot be used!",t)}class Uh{constructor(e,t){Gh(e),this.url=function(e){return e.endsWith("/")?e.slice(0,-1):e}(e),t?.signer&&(this.signer=new en(t.signer)),this.network=t?.network??"gnosis",this.requestOptions={baseURL:this.url,timeout:t?.timeout??0,headers:t?.headers,onRequest:t?.onRequest,httpAgent:t?.httpAgent,httpsAgent:t?.httpsAgent};const n={getRequestOptionsForCall:e=>this.getRequestOptionsForCall(e),url:this.url,signer:this.signer,network:this.network,bee:this};this.balance=new ll(n),this.settlement=new Yf(n),this.transaction=new Nh(n),this.stake=new ih(n),this.connectivity=new af(n),this.status=new Rh(n),this.wallet=new Ch(n),this.stamp=new mh(n),this.storage=new zh(n),this.chequebook=new Bl(n),this.cheque=new vl(n),this.tag=new Sh(n),this.pin=new Gf(n),this.grantee=new _f(n),this.messaging=new Pf(n),this.feed=new kf(n),this.soc=new Qf(n),this.data=new pf(n),this.chunk=new El(n),this.file=new Of(n),this.collection=new jl(n),this.rollingFeed=new Zf(n)}makeContentAddressedChunk(e,t){return Tn(e,t)}unmarshalContentAddressedChunk(e){return Rn(e)}makeSingleOwnerChunk(e,t,n,r,o){return function(e,t,n,r,o){return r=new Zt(r),o=new en(o),En({data:Nt.concat(t.toUint8Array(),n.toUint8Array()),span:t,payload:n,address:e},r,o.toBigInt())}(e,t,n,r,o)}calculateSingleOwnerChunkAddress(e,t){return Bn(e,t)}unmarshalSingleOwnerChunk(e,t){return el(e,t)}async createEnvelope(e,t,n){return e=new Pt(e),t=new nn(t),async function(e,t,n){const r=await Wc(e,{method:"post",responseType:"json",url:`envelope/${n}`,headers:{"swarm-postage-batch-id":t.toHex()}}),o=jc.parse(r.data);return{issuer:new Ut(o.issuer),index:o.index,timestamp:o.timestamp,signature:new Qt(o.signature),batchId:t}}(this.getRequestOptionsForCall(n),e,t)}async rchash(e,t,n,r){return async function(e,t,n,r){const o=await Wc(e,{responseType:"json",url:`rchash/${t}/${n}/${r}`});return Yc.parse(o.data).durationSeconds}(this.getRequestOptionsForCall(r),e,t,n)}getRequestOptionsForCall(e){return e&&(e=zu.parse(e)),e?ar.Rb.deepMerge2(this.requestOptions,e):this.requestOptions}}const Mh="https://api.gateway.ethswarm.org",Lh=new Pt("0000000000000000000000000000000000000000000000000000000000000000"),jh=new sn("0000000000000000000000000000000000000000000000000000000000000000"),Zh=new Uint8Array(32),qh=new Uint8Array(32),Hh=new Uint8Array(20);function Wh(e){return(e=new qt(e)).toHex().slice(0,mu)}})(),r})()));
2
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.BeeJs=t():e.BeeJs=t()}(this,(()=>(()=>{var e={20(e,t){"use strict";var n;async function r(e){return new Promise(((t,n)=>e.then(n,t)))}async function o(e){return new Promise((t=>setTimeout((()=>{t(!0)}),e)))}function i(e,t=Math.random){for(let n=e.length-1;n>0;n--){const r=Math.floor(t()*(n+1)),o=e[n];e[n]=e[r],e[r]=o}return e}function s(e,t,n=Math.random){return i(H(0,e.length-1),n).slice(0,t)}function a(e,t,n=Math.random){return Math.floor(n()*(t-e+1))+e}function c(e,t,n){return t>=e.x&&t<e.x+e.width&&n>=e.y&&n<e.y+e.height}function u(e,t=Math.random){return t()<e}function l(e,t=Math.random){return e[Math.floor(e.length*t())]}function f(e){if(!e.length)throw Error("Received empty array");return e[e.length-1]}function h(e,t,n){return n(t.reduce(((e,t)=>t(e)),e))}function d(e,t){if(null==e)return null;const n=t.split(".");let r=e;for(const o of n){if(null===r[o]||void 0===r[o])return null;r=r[o]}return r}function p(e,t,n){const r=t.split(/\.|\[/);let o=e;for(let i=0;i<r.length;i++){const e=r[i],t=i<r.length-1&&r[i+1].includes("]"),s=e.includes("]")?e.replace(/\[|\]/g,""):e;if(i===r.length-1)return o[s]=n,n;g(o[s])||(o[s]=t?[]:{}),o=o[s]}return n}function m(e,t){return Math.round(e/t)*t}function g(e,t=!0){return!(!e||t&&!b(e._readableState)||t&&e.constructor&&(e.constructor.isBuffer||"AbortController"==e.constructor.name||"AbortSignal"==e.constructor.name||"Uint8Array"==e.constructor.name||"ArrayBuffer"===e.constructor.name||"ReadableStream"===e.constructor.name))&&"object"==typeof e}function y(e){return g(e)&&!Array.isArray(e)}function w(e){return Array.isArray(e)&&0===e.length}function b(e){return void 0===e}function v(e){return"[object Function]"===Object.prototype.toString.call(e)||"[object AsyncFunction]"===Object.prototype.toString.call(e)}function B(e){return"[object String]"===Object.prototype.toString.call(e)}function E(e){return"number"==typeof e&&isFinite(e)}function x(e){return!0===e||!1===e}function T(e){return"[object Date]"===Object.prototype.toString.call(e)}function R(e){return!B(e)||0===e.trim().length}function z(e){return E(e)&&Number.isInteger(e)&&e>=1}function A(e){return B(e)&&null!==e.match(/^-?\d+$/)}function k(e){return B(e)&&null!==e.match(/^(0x)?[0-9a-f]+$/i)}t.DH=t.Or=t.Rb=t.AO=t.FQ=t.iQ=t.DO=t.o8=t.yI=t.O3=t.ie=t.Xx=void 0;const S="!@#$%^&*()_+-=[]{}|;:<>?,./".split(""),O="abcdefghijklmnopqrstuvwxyz",$=O+"ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890",I=$+"!@#$%^&*()_+-=[]{}|;:<>?,./",_=["—","\\","東","京","都","𝖆","𝖇","𝖈","👾","🙇","💁","🙅","ᚠ","ᛇ","ᚻ","ᛦ"],V="0123456789abcdef";function D(e,t){if(R(e))throw new TypeError(`Expected string${t?.name?` for ${t.name}`:""}, got: `+e);if(t&&(void 0!==t.min&&e.length<t.min||void 0!==t.max&&e.length>t.max))throw RangeError(`Expected string${t?.name?` for ${t.name}`:""} length in range: ${t.min??"-inf"}..${t.max??"inf"}; got: ${e.length}`);return e}function N(e,t){if(void 0!==t.min&&e<t.min||void 0!==t.max&&e>t.max)throw RangeError(`Expected value${t?.name?` for ${t.name}`:""} in range: ${t.min??"-inf"}..${t.max??"inf"}; got: ${e}`)}function P(e,t){if(E(e))return t&&N(e,t),e;if(!B(e)||!e.match(/^-?\d+(\.\d+)?$/))throw new TypeError(`Expected number${t?.name?` for ${t.name}`:""}, got: `+e);const n=parseFloat(e);return t&&N(n,t),n}function C(e,t){return Math.trunc(P(e,t))}function F(e,t){if(!y(e))throw new TypeError(`Expected object${t?.name?` for ${t.name}`:""}, got: `+e);return e}function G(e){return B(e)&&null!==e.match(/^https?:\/\/.+/)}function M(e){return"bigint"==typeof e}function U(e,t){if(!M(e))throw new TypeError(`Expected bigint${t?.name?` for ${t.name}`:""}, got: `+e);if(void 0!==t?.min&&e<t?.min||void 0!==t?.max&&e>t?.max)throw RangeError(`Expected value${t?.name?` for ${t.name}`:""} in range: ${t.min??"-inf"}..${t.max??"inf"}; got: ${e}`);return e}function L(e,t){for(const[n,r]of Object.entries(t))if(!r(e[n]))throw TypeError(`${n} in value does not exist or match shape`);for(const n of Object.keys(e))if(!t[n])throw TypeError(`${n} exists in value but not in shape`);return!0}function j(e,t){if(y(e)&&y(t))for(const n in t)y(t[n])?(e[n]||(e[n]={}),j(e[n],t[n])):Array.isArray(t[n])?e[n]=[...t[n]]:(null!==t[n]&&void 0!==t[n]||null===e[n]||void 0===e[n])&&(e[n]=t[n]);return e}function Z(e,t){const n={};for(const r of e)for(const e of Object.keys(r))n[e]?n[e]=t(n[e],r[e]):n[e]=r[e];return n}function q(e,t){Array.prototype.push.apply(e,t)}function H(e,t){const n=[];for(let r=e;r<=t;r++)n.push(r);return n}function W(e,t=()=>!1){return e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").split("").map((e=>/[a-z0-9]/.test(e)||t(e)?e:"-")).join("").replace(/-+/g,"-").replace(/^-|-$/g,"")}function J(e,t){if(0===t.length)return 0;const n=e.toLowerCase(),r=t.toLowerCase();return e===t?1e4:n.startsWith(r)?1e4-e.length:n.includes(r)?5e3-e.length:new RegExp(".*"+r.split("").join(".*")+".*").test(n)?1e3-e.length:0}const K={"&amp;":"&","&quot;":'"',"&apos;":"'","&gt;":">","&lt;":"<"};function X(e,t){const n=e.indexOf(t);return-1===n?null:e.slice(0,n)}function Y(e,t){const n=e.indexOf(t);return-1===n?null:e.slice(n+t.length)}function Q(e,t){const n=e.lastIndexOf(t);return-1===n?null:e.slice(0,n)}function ee(e,t){const n=e.lastIndexOf(t);return-1===n?null:e.slice(n+t.length)}function te(e,t,n=!1){const r=n?e.lastIndexOf(t):e.indexOf(t);return-1===r?n?[null,e]:[e,null]:[e.slice(0,r),e.slice(r+t.length)]}function ne(e,t){let n=[e];for(const r of t)n=n.flatMap((e=>e.split(r)));return n.filter((e=>e))}function re(e){const t=f(e.split(/\\|\//g)),n=t.lastIndexOf(".",t.length-1);return n<=0?"":t.slice(n+1)}function oe(e){const t=f(e.split(/\\|\//g)),n=t.lastIndexOf(".",t.length-1);return n<=0?t:t.slice(0,n)}function ie(e){return e.split("\n").map((e=>e.trim().replace(/\s+/g," "))).filter((e=>e.length>0)).join("\n")}function se(e){return e.charAt(0).toUpperCase()+e.slice(1)}function ae(e){return e.charAt(0).toLowerCase()+e.slice(1)}function ce(e){if(!e)return!1;const t=e.charCodeAt(0);return t>=65&&t<=90||t>=97&&t<=122}function ue(e){if(!e)return!1;const t=e.charCodeAt(0);return t>=48&&t<=57}function le(e){return ce(e)||ue(e)}const fe=" \n\t\r.,?!:;\"'`(){}[]~@#$%^&*-+=|<>/\\".split("");function he(e){return fe.includes(e)}function de(e,t,n=0){const r=t.exec(e.slice(n));return r?{index:r.index,match:r[0]}:null}function pe(e,t,n=!0){if(!n)return t.every((t=>t instanceof RegExp?t.test(e):-1!==e.indexOf(t,0)));let r=0;for(const o of t)if(o instanceof RegExp){const t=de(e,o,r);if(!t)return!1;r=t.index+t.match.length}else{const t=e.indexOf(o,r);if(-1===t)return!1;r=t+o.length}return!0}function me(e,t,n=0){const r=[];let o=e.indexOf(t,n);for(;-1!==o;)r.push(o),o=e.indexOf(t,o+t.length);return r}function ge(e,t,n=0){let r=-1;for(const o of t){const t=e.indexOf(o,n);-1!==t&&(-1===r||t<r)&&(r=t)}return r}function ye(e,t=0){for(let n=t;n<e.length;n++)if(he(e[n]))return n;return-1}function we(e,t=0){for(let n=t;n<e.length;n++)if("#"===e[n]&&le(e[n+1]))return n;return-1}function be(e,t,n=0){return e.slice(0,n).lastIndexOf(t)}function ve(e,t=0,n="{",r="}"){let o=1;for(let i=t;i<e.length;i++)if(e.slice(i,i+r.length)===r){if(0==--o)return i}else e.slice(i,i+n.length)===n&&o++;return-1}function Be(e,t){const n=t.wordBoundary?ge(e,[`${t.opening} `,`${t.opening}\n`],t.start||0):e.indexOf(t.opening,t.start||0);if(-1===n)return null;const r=ve(e,n+t.opening.length,t.opening,t.closing);return-1===r?null:t.exclusive?e.slice(n+t.opening.length,r):e.slice(n,r+t.closing.length)}const Ee="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",xe="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function Te(e,t){const n=t.length;let r=0,o=0;const i=[];for(let s=0;s<e.length;s++){const a=e[s];if("="===a)break;const c=t.indexOf(a);if(-1===c)throw new Error(`Invalid character: ${a}`);o=o<<Math.log2(n)|c,r+=Math.log2(n),r>=8&&(r-=8,i.push(o>>r&255))}return new Uint8Array(i)}function Re(e,t){const n=t.length;let r=0,o=0,i="";for(let s=0;s<e.length;s++)for(o=o<<8|e[s],r+=8;r>=Math.log2(n);)r-=Math.log2(n),i+=t[o>>r&n-1];return r>0&&(i+=t[o<<Math.log2(n)-r&n-1]),i.length%4!=0&&(i+="=".repeat(4-i.length%4)),i}function ze(e,t,n){const r=[];for(const o of n)o!==t&&r.push(e.replace(t,o));return r}function Ae(e){const t=e.lastIndexOf(" ");if(-1===t)return{line:e,rest:""};return{line:e.slice(0,t),rest:e.slice(t+1)}}function ke(e){const t=e.reduce(((e,t)=>e.length<t.length?e:t));let n="";for(let r=0;r<t.length;r++){const o=t[r];if(!e.every((e=>e[r]===o)))break;n+=o}return n}function Se(e,t){return new RegExp(`\\b${t}\\b`).test(e)}function Oe(e,t,n=[]){let r="";for(;t<e.length&&(le(e[t])||n.includes(e[t]));)r+=e[t++];return r}function $e(e,t,n,r="$",o=":"){if(""===n)return e;let i=e.indexOf(`${r}${t}`);for(;-1!==i;){if(e[i+t.length+1]===o)if(e[i+t.length+2]===o)e=e.replace(`${r}${t}${o}${o}`,n);else{const s=Oe(e,i+t.length+2,["_"]);e=e.replace(`${r}${t}${o}${s}`,n)}else e=e.replace(`${r}${t}`,n);i=e.indexOf(`${r}${t}`,i+n.length)}return e}function Ie(e,t="$",n=":"){let r=e.indexOf(t);for(;-1!==r;){const o=Oe(e,r+1);if(e[r+o.length+1]===n)if(e[r+o.length+2]===n)e=e.replace(`${t}${o}${n}${n}`,"");else{const i=Oe(e,r+o.length+2);e=e.replace(`${t}${o}${n}${i}`,i)}r=e.indexOf(t,r+1)}return e}function _e(e,t=!0){const n=Object.entries(e).filter((([e,t])=>null!=t)).map((([e,t])=>`${e}=${encodeURIComponent(t)}`)).join("&");return n?(t?"?":"")+n:""}function Ve(e){return String(Math.floor(e)).padStart(2,"0")}function De(e){const t=Math.floor(e/36e5);e%=36e5;const n=Math.floor(e/6e4);e%=6e4;const r=Math.floor(e/1e3);return t?`${Ve(t)}:${Ve(n)}:${Ve(r)}`:`${Ve(n)}:${Ve(r)}`}function Ne(e){return Math.floor((T(e)?e.getTime():e)/864e5)}const Pe={today:(e,t)=>Ve(e)+":"+Ve(t),yesterday:()=>"Yesterday",monday:()=>"Mon",tuesday:()=>"Tue",wednesday:()=>"Wed",thursday:()=>"Thu",friday:()=>"Fri",saturday:()=>"Sat",sunday:()=>"Sun",weeks:e=>`${e}w`};const Ce={now:()=>"A few seconds",seconds:e=>`${e} seconds`,minutes:e=>`${e} minutes`,hours:e=>`${e} hours`,days:e=>`${e} days`,weeks:e=>`${e} weeks`};function Fe(e,n){const r=n?.now??Date.now(),o=n?.labels||Ce;let i=(r-(t.Or.isDate(e)?e.getTime():e))/1e3;return i<10?o.now():i<120?o.seconds(Math.floor(i)):(i/=60,i<120?o.minutes(Math.floor(i)):(i/=60,i<48?o.hours(Math.floor(i)):(i/=24,i<14?o.days(Math.floor(i)):(i/=7,o.weeks(Math.floor(i))))))}const Ge={};const Me={s:1e3,m:6e4,h:36e5,d:864e5};const Ue={0:"sunday",1:"monday",2:"tuesday",3:"wednesday",4:"thursday",5:"friday",6:"saturday"};function Le(e){return{zeroBasedIndex:e,day:Ue[e]}}function je(e){return Le(e.getDay())}const Ze={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};const qe={b:0,byte:0,bytes:0,kb:1,kilobyte:1,kilobytes:1,mb:2,megabyte:2,megabytes:2,gb:3,gigabyte:3,gigabytes:3,tb:4,terabyte:4,terabytes:4};const He=new Map;function We(e,t=!1){e=e.filter((e=>e)),t&&B(e[1])&&(e[1]="../"+e[1]);let n="";B(e[0])&&e[0].includes("://")&&(n=X(e[0],"://")??"",e[0]=Y(e[0],"://")??"");const r=e.map((e=>String(e))).flatMap((e=>e.split("/"))),o=[];for(let i=0;i<r.length;i++)"."!==r[i]&&(".."===r[i]?(!n||o.length>1)&&o.pop():o.push(r[i]));return(n?n+"://":"")+o.join("/").replaceAll(/\/{2,}/g,"/")}function Je(e){const t=Object.keys(e).sort(((e,t)=>e.localeCompare(t))),n={};for(const r of t)n[r]=Xe(e[r]);return n}function Ke(e){const t=[];return e.sort(((e,t)=>JSON.stringify(Xe(e)).localeCompare(JSON.stringify(Xe(t))))).forEach((e=>t.push(Xe(e)))),t}function Xe(e){return Array.isArray(e)?Ke(e):g(e)?Je(e):e}function Ye(e,t){return JSON.stringify(Xe(e))===JSON.stringify(Xe(t))}function Qe(e){const t=Object.keys(e);return t[Math.floor(Math.random()*t.length)]}const et=[1e3,1e6,1e9,1e12,1e15,1e18,1e21,1e24,1e27,1e30,1e9,1e16,1e18,1e18,1e18,1e33],tt=["thousand","million","billion","trillion","quadrillion","quintillion","sextillion","septillion","octillion","nonillion","gwei","bzz","btc","eth","dai","decillion"],nt=["K","M","B","T","Qa","Qi","Sx","Sp","O","N","gwei","bzz","eth","btc","dai","D"];function rt(e){const t=parseFloat(e);if(isNaN(t))throw Error("makeNumber got NaN for input");const n=e.replace(/^-?[0-9.]+/,"").trim(),r=nt.findIndex((e=>e.toLowerCase()===n.toLowerCase()));return-1===r?t:t*et[r]}function ot(e,t,n){return e<t?t:e>n?n:e}function it(e,t,n){return e+(n?"["+t+"]":(e.length?".":"")+t)}function st(e,t,n,r,o){if(!g(t))return t;for(const[i,s]of Object.entries(t)){const t=it(n,i,r);Array.isArray(s)?o?st(e,s,t,!0,o):e[t]=s.map((e=>st(Array.isArray(e)?[]:{},e,"",!1,o))):g(s)?st(e,s,t,!1,o):e[t]=s}return e}function at(e,t){const n={};for(const r of e){n[t(r)]=r}return n}function ct(e,t){const n=Math.ceil(e.length/t),r=[];for(let o=0;o<e.length;o+=n)r.push(e.slice(o,o+n));return r}function ut(e,t){const n=[],r=Math.ceil(e.length/t);for(let o=0;o<r;o++)n.push(e.slice(o*t,o*t+t));return n}function lt(e,t){return Object.fromEntries(Object.entries(e).sort(t))}function ft(e,t){const n=[];let r=[];return e.forEach(((o,i)=>{(0===i||!t(o,e[i-1]))&&(r=[],n.push(r)),r.push(o)})),n}function ht(e,t,n,r=100){if(e.map.has(t)){const n=e.keys.indexOf(t);e.keys.splice(n,1)}if(e.map.set(t,n),e.keys.push(t),e.keys.length>r){const t=e.keys.shift();t&&e.map.delete(t)}}class dt{constructor(e){this.value=e}static of(e){return new dt(e)}static empty(){return new dt(null)}map(e){return new dt(null!==this.value&&void 0!==this.value?e(this.value):null)}mapAsync(e){return null!==this.value&&void 0!==this.value?e(this.value).then((e=>dt.of(e))):Promise.resolve(dt.empty())}ifPresent(e){return null!==this.value&&void 0!==this.value&&e(this.value),this}ifPresentAsync(e){return null!==this.value&&void 0!==this.value?e(this.value).then((()=>this)):Promise.resolve(this)}ifAbsent(e){return(null===this.value||void 0===this.value)&&e(),this}ifAbsentAsync(e){return null===this.value||void 0===this.value?e().then((()=>this)):Promise.resolve(this)}getOrFallback(e){return this.value??e()}getOrFallbackAsync(e){return null!==this.value&&void 0!==this.value?Promise.resolve(this.value):e()}getOrThrow(){if(null===this.value||void 0===this.value)throw Error("Optional.value is empty");return this.value}}t.Xx=dt;class pt{constructor(e){this.value=e,this.children=[]}}function mt(e,t){if(Math.log2(e.length)%1!=0)throw new Error("Array length must be a power of 2");let n=[...e];for(;n.length>1;){const e=[];for(let r=0;r<n.length;r+=2){const o=n[r+1];e.push(t(n[r],o))}n=e}return n[0]}function gt(...e){const t=e.reduce(((e,t)=>e+t.length),0),n=new Uint8Array(t);let r=0;return e.forEach((e=>{n.set(e,r),r+=e.length})),n}function yt(e){return 137===e[0]&&80===e[1]&&78===e[2]&&71===e[3]}function wt(e){return 255===e[0]&&216===e[1]}function bt(e){return 87===e[8]&&69===e[9]&&66===e[10]&&80===e[11]}function vt(e,t){const n=new ArrayBuffer(8);return new DataView(n).setBigUint64(0,BigInt(e),"LE"===t),new Uint8Array(n)}function Bt(e,t){const n=new Uint8Array(32);let r=e;if("LE"===t){for(let e=0;e<32;e++)n[e]=Number(0xffn&r),r>>=8n;return n}for(let o=31;o>=0;o--)n[o]=Number(0xffn&r),r>>=8n;return n}function Et(e,t){let n=0n;if("LE"===t){for(let t=31;t>=0;t--)n=n<<8n|BigInt(e[t]);return n}for(let r=0;r<32;r++)n=n<<8n|BigInt(e[r]);return n}function xt(e,t){const n=[];for(let r=0;r<e.length;r+=t)n.push(e.subarray(r,r+t));return n}const Tt=[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 Rt(e){for(let t=0;t<24;t++){const n=e[0]^e[10]^e[20]^e[30]^e[40],r=e[1]^e[11]^e[21]^e[31]^e[41],o=e[2]^e[12]^e[22]^e[32]^e[42],i=e[3]^e[13]^e[23]^e[33]^e[43],s=e[4]^e[14]^e[24]^e[34]^e[44],a=e[5]^e[15]^e[25]^e[35]^e[45],c=e[6]^e[16]^e[26]^e[36]^e[46],u=e[7]^e[17]^e[27]^e[37]^e[47],l=e[8]^e[18]^e[28]^e[38]^e[48],f=e[9]^e[19]^e[29]^e[39]^e[49],h=l^(o<<1|i>>>31),d=f^(i<<1|o>>>31),p=n^(s<<1|a>>>31),m=r^(a<<1|s>>>31),g=o^(c<<1|u>>>31),y=i^(u<<1|c>>>31),w=s^(l<<1|f>>>31),b=a^(f<<1|l>>>31),v=c^(n<<1|r>>>31),B=u^(r<<1|n>>>31);e[0]^=h,e[1]^=d,e[2]^=p,e[3]^=m,e[4]^=g,e[5]^=y,e[6]^=w,e[7]^=b,e[8]^=v,e[9]^=B,e[10]^=h,e[11]^=d,e[12]^=p,e[13]^=m,e[14]^=g,e[15]^=y,e[16]^=w,e[17]^=b,e[18]^=v,e[19]^=B,e[20]^=h,e[21]^=d,e[22]^=p,e[23]^=m,e[24]^=g,e[25]^=y,e[26]^=w,e[27]^=b,e[28]^=v,e[29]^=B,e[30]^=h,e[31]^=d,e[32]^=p,e[33]^=m,e[34]^=g,e[35]^=y,e[36]^=w,e[37]^=b,e[38]^=v,e[39]^=B,e[40]^=h,e[41]^=d,e[42]^=p,e[43]^=m,e[44]^=g,e[45]^=y,e[46]^=w,e[47]^=b,e[48]^=v,e[49]^=B;const E=e[0],x=e[1],T=e[2]<<1|e[3]>>>31,R=e[3]<<1|e[2]>>>31,z=e[5]<<30|e[4]>>>2,A=e[4]<<30|e[5]>>>2,k=e[6]<<28|e[7]>>>4,S=e[7]<<28|e[6]>>>4,O=e[8]<<27|e[9]>>>5,$=e[9]<<27|e[8]>>>5,I=e[11]<<4|e[10]>>>28,_=e[10]<<4|e[11]>>>28,V=e[13]<<12|e[12]>>>20,D=e[12]<<12|e[13]>>>20,N=e[14]<<6|e[15]>>>26,P=e[15]<<6|e[14]>>>26,C=e[17]<<23|e[16]>>>9,F=e[16]<<23|e[17]>>>9,G=e[18]<<20|e[19]>>>12,M=e[19]<<20|e[18]>>>12,U=e[20]<<3|e[21]>>>29,L=e[21]<<3|e[20]>>>29,j=e[22]<<10|e[23]>>>22,Z=e[23]<<10|e[22]>>>22,q=e[25]<<11|e[24]>>>21,H=e[24]<<11|e[25]>>>21,W=e[26]<<25|e[27]>>>7,J=e[27]<<25|e[26]>>>7,K=e[29]<<7|e[28]>>>25,X=e[28]<<7|e[29]>>>25,Y=e[31]<<9|e[30]>>>23,Q=e[30]<<9|e[31]>>>23,ee=e[33]<<13|e[32]>>>19,te=e[32]<<13|e[33]>>>19,ne=e[34]<<15|e[35]>>>17,re=e[35]<<15|e[34]>>>17,oe=e[36]<<21|e[37]>>>11,ie=e[37]<<21|e[36]>>>11,se=e[38]<<8|e[39]>>>24,ae=e[39]<<8|e[38]>>>24,ce=e[40]<<18|e[41]>>>14,ue=e[41]<<18|e[40]>>>14,le=e[42]<<2|e[43]>>>30,fe=e[43]<<2|e[42]>>>30,he=e[45]<<29|e[44]>>>3,de=e[44]<<29|e[45]>>>3,pe=e[47]<<24|e[46]>>>8,me=e[46]<<24|e[47]>>>8,ge=e[48]<<14|e[49]>>>18,ye=e[49]<<14|e[48]>>>18;e[0]=E^~V&q,e[1]=x^~D&H,e[2]=V^~q&oe,e[3]=D^~H&ie,e[4]=q^~oe&ge,e[5]=H^~ie&ye,e[6]=oe^~ge&E,e[7]=ie^~ye&x,e[8]=ge^~E&V,e[9]=ye^~x&D,e[10]=k^~G&U,e[11]=S^~M&L,e[12]=G^~U&ee,e[13]=M^~L&te,e[14]=U^~ee&he,e[15]=L^~te&de,e[16]=ee^~he&k,e[17]=te^~de&S,e[18]=he^~k&G,e[19]=de^~S&M,e[20]=T^~N&W,e[21]=R^~P&J,e[22]=N^~W&se,e[23]=P^~J&ae,e[24]=W^~se&ce,e[25]=J^~ae&ue,e[26]=se^~ce&T,e[27]=ae^~ue&R,e[28]=ce^~T&N,e[29]=ue^~R&P,e[30]=O^~I&j,e[31]=$^~_&Z,e[32]=I^~j&ne,e[33]=_^~Z&re,e[34]=j^~ne&pe,e[35]=Z^~re&me,e[36]=ne^~pe&O,e[37]=re^~me&$,e[38]=pe^~O&I,e[39]=me^~$&_,e[40]=z^~C&K,e[41]=A^~F&X,e[42]=C^~K&Y,e[43]=F^~X&Q,e[44]=K^~Y&le,e[45]=X^~Q&fe,e[46]=Y^~le&z,e[47]=Q^~fe&A,e[48]=le^~z&C,e[49]=fe^~A&F,e[0]^=Tt[2*t],e[1]^=Tt[2*t+1]}}function zt(e){const t=[];for(let n=0;n<e.length;n+=4)t.push(e[n]|e[n+1]<<8|e[n+2]<<16|e[n+3]<<24);return t}function At(e,t){if(!e.length){const e=new Uint8Array(136);return e[0]=t,e[135]=128,[zt(e)]}const n=xt(e,136),r=n[n.length-1];if(r.length<136){const e=new Uint8Array(136);e.set(r),e[r.length]=t,e[135]|=128,n[n.length-1]=e}if(136===r.length){const e=new Uint8Array(136);e[0]=t,e[135]=128,n.push(e)}return n.map(zt)}function kt(e,t){for(const n of t){for(let t=0;t<34;t+=2)e[t]^=n[t+1],e[t+1]^=n[t];Rt(e)}return e}function St(e){return new Uint8Array([e[1],e[1]>>-24,e[1]>>-16,e[1]>>-8,e[0],e[0]>>8,e[0]>>16,e[0]>>24,e[3],e[3]>>-24,e[3]>>-16,e[3]>>-8,e[2],e[2]>>8,e[2]>>16,e[2]>>24,e[5],e[5]>>-24,e[5]>>-16,e[5]>>-8,e[4],e[4]>>8,e[4]>>16,e[4]>>24,e[7],e[7]>>-24,e[7]>>-16,e[7]>>-8,e[6],e[6]>>8,e[6]>>16,e[6]>>24])}function Ot(e){return St(kt(new Array(50).fill(0),At(e,1)))}function $t(e,t,n=0){if(e.length>=t)return e;const r=new Uint8Array(t);return r.fill(n),r.set(e,t-e.length),r}function It(e,t,n=0){if(e.length>=t)return e;const r=new Uint8Array(t);return r.fill(n),r.set(e,0),r}function _t(e,t){return(e%t+t)%t}function Vt(e,t){_t(e,t);let[n,r]=[0n,1n],[o,i]=[t,e];for(;0n!==i;){const e=o/i;[n,r]=[r,n-e*r],[o,i]=[i,o-e*i]}if(o>1n)throw new Error("a is not invertible");return n<0n&&t,n}function Dt(e,t){return 0n===_t(e,t)?0n:t%4n===3n?function(e,t,n){let r=1n;for(_t(e,n);t>0;)t%2n===1n&&_t(r*e,n),_t(e*e,n);return r}(e,(t+1n)/4n,t):null}const Nt=0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,Pt=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n,Ct=0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,Ft=0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n;function Gt(e,t,n){if(0n===t)return[0n,0n];const r=_t(3n*e*e*Vt(2n*t,n),n),o=_t(r*r-2n*e,n);return[o,_t(r*(e-o)-t,n)]}function Mt(e,t,n,r,o){if(0n===e&&0n===t)return[n,r];if(0n===n&&0n===r)return[e,t];if(e===n&&t===_t(-r,o))return[0n,0n];if(e===n&&t===r)return Gt(e,t,o);const i=_t((r-t)*Vt(n-e,o),o),s=_t(i*i-e-n,o);return[s,_t(i*(e-s)-t,o)]}function Ut(e,t,n,r){let o=[0n,0n],i=[e,t];const s=n.toString(2);for(const a of s)"0"===a?(Mt(o[0],o[1],i[0],i[1],r),Gt(o[0],o[1],r)):(Mt(o[0],o[1],i[0],i[1],r),Gt(i[0],i[1],r));return o}function Lt(e,t,n){if(t<=0n||t>=Pt)throw new Error("Invalid private key");if(n||_t(Et(Ot(gt(Ot(Bt(t,"BE")),Bt(e,"BE"))),"BE"),Pt),n<=0n||n>=Pt)throw new Error("Invalid nonce");const r=_t(e,Pt),o=Ut(Ct,Ft,n,Nt),i=_t(o[0],Pt);let s=_t((r+_t(i,Pt)*t)*Vt(n,Pt),Pt);if(0n===i||0n===s)throw new Error("Invalid r or s value");let a=o[1]%2n===0n?27n:28n;return s>Pt/2n&&(27n===a?28n:27n),[i,s,a]}class jt{constructor(e){this.cursor=0,this.buffer=e}read(e){const t=this.buffer.subarray(this.cursor,this.cursor+e);return this.cursor+=e,t}max(){return this.buffer.length-this.cursor}}class Zt{constructor(e){this.buffer=e,this.cursor=0}write(e){const t=Math.min(this.max(),e.max());return this.buffer.set(e.read(t),this.cursor),this.cursor+=t,t}max(){return this.buffer.length-this.cursor}}class qt{constructor(e,t=0n){this.span=t,this.writer=new Zt(new Uint8Array(e))}build(){return gt(vt(this.span,"LE"),this.writer.buffer)}hash(){const e=mt(xt(this.writer.buffer,32),((e,t)=>qt.hashFunction(gt(e,t))));return qt.hashFunction(gt(vt(this.span,"LE"),e))}}qt.hashFunction=Ot;class Ht{constructor(e,t=4096){this.counters=[1],this.capacity=t,this.chunks=[new qt(t)],this.onChunk=e}static async root(e,t=4096){const r=new n(n.NOOP,t);return await r.append(e),r.finalize()}async append(e,t=0,n=0n){const r=new jt(e);for(;r.max()>0;){0===this.chunks[t].writer.max()&&await this.elevate(t);const e=this.chunks[t].writer.write(r);n?this.chunks[t].span+=n:this.chunks[0].span+=BigInt(e)}}async elevate(e){this.counters[e]=++this.counters[e]%(this.capacity/32),this.chunks[e+1]||(this.chunks.push(new qt(this.capacity)),this.counters.push(1)),await this.append(this.chunks[e].hash(),e+1,this.chunks[e].span),await this.onChunk(this.chunks[e]),this.chunks[e]=new qt(this.capacity)}async finalize(e=0){return this.chunks[e+1]?1===this.counters[e]?(await this.elevate(e+1),this.chunks[e+1]=this.chunks[e],this.finalize(e+1)):(await this.elevate(e),this.finalize(e+1)):(await this.onChunk(this.chunks[e]),this.chunks[e])}}n=Ht,Ht.NOOP=async e=>{};class Wt{constructor(e,t){if(t<0)throw Error("Scale must be non-negative");this.value=BigInt(e),this.scale=t}static cast(e){if(!e)throw Error("Cannot cast falsy value to FixedPointNumber");if(e instanceof Wt)return e;const t=U(e.value),n=P(e.scale);return new Wt(t,n)}static fromDecimalString(e,t){/e\-\d+$/i.test(e)&&(e=parseFloat(e).toFixed(t));let[n,r]=e.split(".");return r=(r||"").padEnd(t,"0").slice(0,t),new Wt(BigInt(n+r),t)}static fromFloat(e,t){return Wt.fromDecimalString(e.toString(),t)}add(e){return this.assertSameScale(e),new Wt(this.value+e.value,this.scale)}subtract(e){return this.assertSameScale(e),new Wt(this.value-e.value,this.scale)}multiply(e){return new Wt(this.value*e,this.scale)}divmod(e){if(0n===e)throw new Error("Division by zero is not allowed");const t=this.value/e,n=this.value%e;return[new Wt(t,this.scale),new Wt(n,this.scale)]}exchange(e,t,n){if("*"===e){const e=this.value*t.value/10n**BigInt(this.scale);return new Wt(e,n)}this.assertSameScale(t);const r=this.value*10n**BigInt(n)/t.value;return new Wt(r,n)}compare(e){return this.assertSameScale(e),this.value>e.value?1:this.value<e.value?-1:0}toDecimalString(){if(0===this.scale)return this.value.toString();const e=this.value.toString();return`${e.slice(0,-this.scale)||"0"}.${e.slice(-this.scale).padStart(this.scale,"0")}`}toString(){return this.value.toString()}toJSON(){return this.toString()}toFloat(){return parseFloat(this.toDecimalString())}assertSameScale(e){if(this.scale!==e.scale)throw new Error(`Scale mismatch: expected ${this.scale}, but got ${e.scale}`)}}function Jt(e,t,n,r){const o=e.findIndex((e=>e===`--${t}`||e.startsWith(`--${t}=`))),i=e[o];if(!i)return(n||{})[r||t||""]||null;if(i.includes("="))return i.split("=")[1];const s=e[o+1];return s&&!s.startsWith("-")?s:(n||{})[r||t||""]||null}function Kt(e,t,n,r){const o=Jt(e,t,n,r);if(!o)throw new Error(`Missing argument ${t}`);return o}function Xt(e,t){const n=e[t];e.splice(t,1),e.unshift(n)}function Yt(e,t){return{x:e.x+t.x,y:e.y+t.y}}function Qt(e,t){return{x:e.x*t,y:e.y*t}}function en(e,t,n){return{x:e.x+Math.cos(t)*n,y:e.y+Math.sin(t)*n}}function tn(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function nn(e,t,n="row-first"){const r=[];if("column-first"===n)for(let o=0;o<e.length;o++)for(let n=0;n<e[0].length;n++)t(o,n)&&r.push({x:o,y:n});else for(let o=0;o<e[0].length;o++)for(let n=0;n<e.length;n++)t(n,o)&&r.push({x:n,y:o});return r}function rn(e,t,n){return!e[t-1]?.[n]}function on(e,t,n){return!e[t+1]?.[n]}function sn(e,t,n){return!e[t][n-1]}function an(e,t,n){return!e[t][n+1]}function cn(e,t,n){const r=[];return e[t][n]?function(e,t,n){return e[t+1]?.[n]&&e[t-1]?.[n]&&!e[t][n-1]&&!e[t][n+1]}(e,t,n)||function(e,t,n){return e[t][n+1]&&e[t][n-1]&&!e[t-1]?.[n]&&!e[t+1]?.[n]}(e,t,n)?[]:(!e[t-1]?.[n-1]&&rn(e,t,n)&&sn(e,t,n)&&r.push({x:t,y:n}),!e[t+1]?.[n-1]&&on(e,t,n)&&sn(e,t,n)&&r.push({x:t+1,y:n}),!e[t-1]?.[n+1]&&rn(e,t,n)&&an(e,t,n)&&r.push({x:t,y:n+1}),!e[t+1]?.[n+1]&&on(e,t,n)&&an(e,t,n)&&r.push({x:t+1,y:n+1}),r):(e[t-1]?.[n]&&e[t][n-1]&&r.push({x:t,y:n}),e[t+1]?.[n]&&e[t][n-1]&&r.push({x:t+1,y:n}),e[t-1]?.[n]&&e[t][n+1]&&r.push({x:t,y:n+1}),e[t+1]?.[n]&&e[t][n+1]&&r.push({x:t+1,y:n+1}),r)}function un(e,t){return t.map((t=>function(e,t){return Math.atan2(t.y-e.y,t.x-e.x)}(e,t))).sort(((e,t)=>e-t))}function ln(e,t,n,r){const o=(r.y-n.y)*(t.x-e.x)-(r.x-n.x)*(t.y-e.y);if(0===o)return null;let i=e.y-n.y,s=e.x-n.x;const a=(r.x-n.x)*i-(r.y-n.y)*s,c=(t.x-e.x)*i-(t.y-e.y)*s;return i>0&&i<1&&s>0&&s<1?{x:e.x+i*(t.x-e.x),y:e.y+i*(t.y-e.y)}:null}function fn(e,t,n){const r=[],o=en(e,n,1e4);for(const i of t){const t=ln(e,o,i.start,i.end);t&&r.push(t)}return r.length?r.reduce(((t,n)=>tn(e,n)<tn(e,t)?n:t)):null}t.ie=Wt;class hn{constructor(){this.subscribers=[]}subscribe(e){return this.subscribers.push(e),()=>{this.subscribers=this.subscribers.filter((t=>t!==e))}}publish(e){this.subscribers.forEach((t=>t(e)))}clear(){this.subscribers=[]}getSubscriberCount(){return this.subscribers.length}}t.O3=class{constructor(e,t){this.queue=[],this.running=0,this.onProcessed=new hn,this.onDrained=new hn,this.concurrency=e,this.capacity=t}process(){if(this.running>=this.concurrency)return;const e=this.queue.shift();e&&(this.running++,e().finally((()=>{this.running--,this.process(),this.onProcessed.publish(),0===this.running&&this.onDrained.publish()})))}enqueue(e){if(this.queue.length<this.capacity)return this.queue.push(e),this.process(),Promise.resolve();if(this.onProcessed.getSubscriberCount())throw Error("Queue capacity is full");return new Promise((t=>{this.onProcessed.subscribe((()=>{this.queue.length<this.capacity&&(this.queue.push(e),this.process(),this.onProcessed.clear(),t())}))}))}drain(){if(0===this.running)return Promise.resolve();if(this.onDrained.getSubscriberCount())throw Error("Already draining");return new Promise((e=>{this.onDrained.subscribe((()=>{this.onDrained.clear(),e()}))}))}};class dn{constructor(){this.forks=new Map}insert(e,t){if(0===e.length)return void(this.handler=t);const n=e[0];let r,o=n;if(n.startsWith(":")&&n.slice(1),!this.forks.has(o)){const e=new dn;r&&(e.variableName=r),this.forks.set(o,e)}this.forks.get(o).insert(e.slice(1),t)}async handle(e,t,n,r){if(0===e.length)return!!this.handler&&(await this.handler(t,n,r),!0);const o=e[0],i=this.forks.get(o);if(i)return i.handle(e.slice(1),t,n,r);const s=this.forks.get(":");if(s)return s.variableName&&r.set(s.variableName,decodeURIComponent(o)),s.handle(e.slice(1),t,n,r);const a=this.forks.get("*");return!!a&&(r.set("wildcard",e.join("/")),!!a.handler&&(await a.handler(t,n,r),!0))}}t.yI={hexToUint8Array:function(e){(e.startsWith("0x")||e.startsWith("0X"))&&(e=e.slice(2));const t=e.length/2,n=new Uint8Array(t);for(let r=0;r<t;r++){const t=parseInt(e.slice(2*r,2*r+2),16);n[r]=t}return n},uint8ArrayToHex:function(e){return Array.from(e).map((e=>e.toString(16).padStart(2,"0"))).join("")},binaryToUint8Array:function(e){const t=Math.ceil(e.length/8),n=new Uint8Array(t);for(let r=0;r<t;r++){const t=parseInt(e.slice(8*r,8*r+8),2);n[r]=t}return n},uint8ArrayToBinary:function(e){return Array.from(e).map((e=>e.toString(2).padStart(8,"0"))).join("")},base64ToUint8Array:function(e){return Te(e,Ee)},uint8ArrayToBase64:function(e){return Re(e,Ee)},base32ToUint8Array:function(e){return Te(e,xe)},uint8ArrayToBase32:function(e){return Re(e,xe)},log2Reduce:mt,partition:xt,concatBytes:gt,numberToUint8:function(e){return new Uint8Array([e])},uint8ToNumber:function(e){return e[0]},numberToUint16:function(e,t){const n=new ArrayBuffer(2);return new DataView(n).setUint16(0,e,"LE"===t),new Uint8Array(n)},uint16ToNumber:function(e,t){return new DataView(e.buffer).getUint16(e.byteOffset,"LE"===t)},numberToUint32:function(e,t){const n=new ArrayBuffer(4);return new DataView(n).setUint32(0,e,"LE"===t),new Uint8Array(n)},uint32ToNumber:function(e,t){return new DataView(e.buffer).getUint32(e.byteOffset,"LE"===t)},numberToUint64:vt,uint64ToNumber:function(e,t){return new DataView(e.buffer).getBigUint64(e.byteOffset,"LE"===t)},numberToUint256:Bt,uint256ToNumber:Et,sliceBytes:function(e,t){const n=[];let r=0;for(const o of t)n.push(e.subarray(r,r+o)),r+=o;return n},keccak256:Ot,sha3_256:function(e){return St(kt(new Array(50).fill(0),At(e,6)))},proximity:function(e,t){const n=Math.min(e.length,t.length);for(let r=0;r<n;r++){const n=e[r]^t[r];for(let e=0;e<8;e++)if(n>>7-e&1)return 8*r+e}return 8*Math.min(e.length,t.length)},commonPrefix:function(e,t){const n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e[r]!==t[r])return e.subarray(0,r);return e.subarray(0,n)},setBit:function(e,t,n,r){const o=Math.floor(t/8),i=t%8;1===n?e[o]|=1<<("BE"===r?7-i:i):e[o]&=~(1<<("BE"===r?7-i:i))},getBit:function(e,t,n){const r=t%8;return e[Math.floor(t/8)]>>("BE"===n?7-r:r)&1},indexOf:function(e,t,n=0){for(let r=n;r<e.length;r++)for(let n=0;n<t.length&&e[r+n]===t[n];n++)if(n===t.length-1)return r;return-1},equals:function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0},padStart:$t,padStartToMultiple:function(e,t,n=0){const r=e.length%t;return 0===r?e:$t(e,e.length+t-r,n)},padEnd:It,padEndToMultiple:function(e,t,n=0){const r=e.length%t;return 0===r?e:It(e,e.length+t-r,n)},xorCypher:function(e,t){const n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e[r]^t[r%t.length];return n},isUtf8:function(e){for(let t=0;t<e.length;t++){const n=e[t];if(!(n<128))if(192==(224&n)){if(t+1>=e.length||128!=(192&e[t+1]))return!1;t+=1}else if(224==(240&n)){if(t+2>=e.length||128!=(192&e[t+1])||128!=(192&e[t+2]))return!1;t+=2}else{if(240!=(248&n))return!1;if(t+3>=e.length||128!=(192&e[t+1])||128!=(192&e[t+2])||128!=(192&e[t+3]))return!1;t+=3}}return!0}},t.o8={intBetween:a,floatBetween:function(e,t,n=Math.random){return n()*(t-e)+e},chance:u,signed:function(){return 2*Math.random()-1},makeSeededRng:function(e){let t=e,n=3405648695,r=3735928559;return function(){return t+=n,n^=t<<7,t*=r,r^=t<<13,t^=n^r,(t>>>0)/4294967296}},point:function(e,t,n,r=Math.random){let o,i;do{o=a(0,e-1,r),i=a(0,t-1,r)}while(n&&c(n,o,i));return[o,i]},procs:function(e,t=Math.random){const n=Math.floor(e);return u(e-n,t)?n+1:n}},t.DO={countUnique:function(e,t,n,r,o){const i=t?e.map(t):e,s={};for(const c of i)s[c]=(s[c]||0)+1;const a=r?lt(s,o?(e,t)=>e[1]-t[1]:(e,t)=>t[1]-e[1]):s;return n?Object.keys(a):a},makeUnique:function(e,t){return Object.values(at(e,t))},splitBySize:function(e,t){const n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n},splitByCount:ct,index:at,indexCollection:function(e,t){const n={};for(const r of e){const e=t(r);n[e]||(n[e]=[]),n[e].push(r)}return n},onlyOrThrow:function(e){if(1===e.length)return e[0];throw Error(`Expected exactly one element, actual: ${e.length}`)},onlyOrNull:function(e){return 1===e.length?e[0]:null},firstOrThrow:function(e){if(!e.length)throw Error("Received empty array");return e[0]},firstOrNull:function(e){return e.length>0?e[0]:null},shuffle:i,initialize:function(e,t){const n=[];for(let r=0;r<e;r++)n.push(t(r));return n},initialize2D:function(e,t,n){const r=[];for(let o=0;o<e;o++){r.push([]);for(let e=0;e<t;e++)r[o].push(n)}return r},rotate2D:function(e){const t=[];for(let n=0;n<e[0].length;n++){t.push([]);for(let r=0;r<e.length;r++)t[n].push(e[r][n])}return t},containsShape:function(e,t,n,r){if(n<0||r<0||r+t[0].length>e[0].length||n+t.length>e.length)return!1;for(let o=0;o<t.length;o++)for(let i=0;i<t[o].length;i++)if(void 0!==t[o][i]&&e[n+o][r+i]!==t[o][i])return!1;return!0},glue:function(e,t){const n=[];for(let r=0;r<e.length;r++)n.push(e[r]),r<e.length-1&&(v(t)?n.push(t()):n.push(t));return n},pluck:function(e,t){return e.map((e=>e[t]))},pick:l,pickMany:function(e,t,n=Math.random){if(t>e.length)throw new Error(`Count (${t}) is greater than array length (${e.length})`);return s(e,t,n).map((t=>e[t]))},pickManyUnique:function(e,t,n,r=Math.random){if(t>e.length)throw new Error(`Count (${t}) is greater than array length (${e.length})`);const o=[];for(;o.length<t;){const t=l(e,r);o.some((e=>n(e,t)))||o.push(t)}return o},pickWeighted:function(e,t,n){if(void 0===n&&(n=Math.random()),e.length!==t.length)throw new Error("Array length mismatch");let r=t.reduce(((e,t)=>e+t),0);const o=n*r;for(let i=0;i<e.length-1;i++)if(r-=t[i],o>=r)return e[i];return f(e)},pickRandomIndices:s,pickGuaranteed:function(e,n,r,o,s,a=Math.random){const c=e.filter((e=>e!==n&&e!==r)),u=[];for(null!==n&&u.push(n);c.length&&u.length<o;){const e=t.o8.intBetween(0,c.length-1,a);s(c[e],u)&&u.push(c[e]),c.splice(e,1)}return i(u,a),{values:u,indexOfGuaranteed:null!==n?u.indexOf(n):-1}},last:f,pipe:h,makePipe:function(e,t){return n=>h(n,e,t)},sortWeighted:function(e,t,n=Math.random){const r=t.map((e=>n()*e)),o=[];for(let i=0;i<e.length;i++)o.push([e[i],r[i]]);return o.sort(((e,t)=>t[1]-e[1])).map((e=>e[0]))},pushAll:q,unshiftAll:function(e,t){Array.prototype.unshift.apply(e,t)},filterAndRemove:function(e,t){const n=[];for(let r=e.length-1;r>=0;r--)t(e[r])&&n.push(e.splice(r,1)[0]);return n},merge:function(e,t){const n=Object.keys(t);for(const r of n)Array.isArray(t[r])&&Array.isArray(e[r])&&q(e[r],t[r])},empty:function(e){return e.splice(0,e.length),e},pushToBucket:function(e,t,n){e[t]||(e[t]=[]),e[t].push(n)},unshiftAndLimit:function(e,t,n){for(e.unshift(t);e.length>n;)e.pop()},atRolling:function(e,t){let n=t%e.length;return n<0&&(n+=e.length),e[n]},group:ft,createOscillator:function(e){let t=0;return{next:()=>e[t++%e.length]}},organiseWithLimits:function(e,t,n,r,o){const i={};for(const s of Object.keys(t))i[s]=[];i[r]=[],o&&(e=e.sort(o));for(const s of e){const e=s[n],o=t[e]?e:r;i[o].length>=t[o]?i[r].push(s):i[o].push(s)}return i},tickPlaybook:function(e){if(0===e.length)return null;const t=e[0];return t.ttlMax?--t.ttl<=0&&e.shift():t.ttlMax=t.ttl,{progress:(t.ttlMax-t.ttl)/t.ttlMax,data:t.data}},getArgument:Jt,getBooleanArgument:function(e,t,n,r){const o=e.some((e=>e.endsWith("-"+t))),i=Jt(e,t,n,r);if(!i&&o)return!0;if(!i&&!o)return null;if(["true","1","yes","y","on"].includes(i.toLowerCase()))return!0;if(["false","0","no","n","off"].includes(i.toLowerCase()))return!1;throw Error(`Invalid boolean argument ${t}: ${i}`)},getNumberArgument:function(e,t,n,r){const o=Jt(e,t,n,r);if(!o)return null;try{return rt(o)}catch{throw new Error(`Invalid number argument ${t}: ${o}`)}},requireStringArgument:Kt,requireNumberArgument:function(e,t,n,r){const o=Kt(e,t,n,r);try{return rt(o)}catch{throw new Error(`Invalid argument ${t}: ${o}`)}},bringToFront:function(e,t){const n=[...e];return Xt(n,t),n},bringToFrontInPlace:Xt,findInstance:function(e,t){const n=e.find((e=>e instanceof t));return dt.of(n)},filterInstances:function(e,t){return e.filter((e=>e instanceof t))},interleave:function(e,t){const n=[],r=Math.max(e.length,t.length);for(let o=0;o<r;o++)e[o]&&n.push(e[o]),t[o]&&n.push(t[o]);return n},toggle:function(e,t){return e.includes(t)?e.filter((e=>e!==t)):[...e,t]},createHierarchy:function(e,t,n,r,o=!1){const i=new Map,s=[];e.forEach((e=>{const n=new pt(e);i.set(e[t],n)})),e.forEach((e=>{const r=i.get(e[t]);if(!r)return;const o=e[n];if(o){const e=i.get(o);e&&e.children.push(r)}else s.push(r)}));const a=e=>{e.children.sort(((e,t)=>{const n=e.value[r],i=t.value[r];return o?i-n:n-i})),e.children.forEach(a)};return s.forEach(a),s},multicall:function(e){return()=>e.forEach((e=>e()))},maxBy:function(e,t){return e.reduce(((e,n)=>t(e)>t(n)?e:n))},minBy:function(e,t){return e.reduce(((e,n)=>t(e)<t(n)?e:n))},allIndexOf:function(e,t){const n=[];return e.forEach(((e,r)=>{t(e)&&n.push(r)})),n}},t.iQ={sleepMillis:o,forever:async function(e,t,n){for(;;){try{await e()}catch(r){n&&n("Error in forever",r)}await o(t)}},scheduleMany:function(e,t){for(let n=0;n<e.length;n++){const r=e[n],o=t[n],i=Math.max(0,o.getTime()-Date.now());setTimeout(r,i)}},waitFor:async function(e,t){let n=t.requiredConsecutivePasses||1,r=0;for(let i=0;i<t.attempts;i++){try{if(await e()){if(r++,r>=n)return}else r=0}catch{r=0}i<t.attempts-1&&await o(t.waitMillis)}throw Error("Timed out waiting for predicate")},expandError:function(e,t){if(B(e))return e;const n=Object.keys(e);e.message&&!n.includes("message")&&n.push("message");const r=n.map((t=>`${t}: ${e[t]}`)).join("; ");return t&&e.stack?r+"\n"+e.stack:r},runAndSetInterval:function(e,t){e();const n=setInterval((()=>{e()}),t);return()=>clearInterval(n)},whereAmI:function(){const e=globalThis.process;return e?!0===e.browser?"browser":"node":"browser"},withRetries:async function(e,t,n,r,i,s){let a=null;for(let u=0;u<=t;u++)try{return await e()}catch(c){if(a=c,u===t)break;const e=n+u/(t-1)*(r-n);i&&i("Error in withRetries, retrying",{attempt:u+1,allowedFailures:t,delayMillis:e,error:c}),s&&s(),await o(e)}throw a}},t.FQ={make:rt,sum:function(e){return e.reduce(((e,t)=>e+t),0)},average:function(e){return e.reduce(((e,t)=>e+t),0)/e.length},median:function(e){const t=[...e].sort(((e,t)=>e-t)),n=Math.floor(t.length/2);return t.length%2==0?(t[n]+t[n-1])/2:t[n]},getDistanceFromMidpoint:function(e,t){return e-(t-1)/2},clamp:ot,range:H,interpolate:function(e,t,n){return e+(t-e)*n},createSequence:function(){let e=0;return{next:()=>e++}},increment:function(e,t,n){const r=e+t;return r>n?n:r},decrement:function(e,t,n){const r=e-t;return r<n?n:r},format:function(e,t){const n=t?.longForm??!1,r=t?.unit?` ${t.unit}`:"",o=n?tt:nt,i=t?.precision??1;if(e<et[0])return`${e}${r}`;for(let s=0;s<et.length-1;s++)if(e<et[s+1])return`${(e/et[s]).toFixed(i)}${n?" ":""}${o[s]}${r}`;return`${(e/et[et.length-1]).toFixed(i)}${n?" ":""}${o[et.length-1]}${r}`},fromDecimals:function(e,t,n){let r=e.length-t;if(r<=0)return"0."+"0".repeat(-r)+e+(n?" "+n:"");let o=e.substring(0,r);return""===o&&(o="0"),o+"."+e.substring(r)+(n?" "+n:"")},makeStorage:function(e,t=1024){const n=parseFloat(e);if(isNaN(n))throw Error("makeStorage got NaN for input");const r=e.replace(/^-?[0-9.]+/,"").trim().toLowerCase(),o=""===r?0:qe[r];if(null==o)throw Error(`Unknown unit: "${r}"`);return Math.ceil(n*t**o)},asMegabytes:function(e){return e/1024/1024},convertBytes:function(e,t=1024){return e>=t*t*t*t?(e/t/t/t/t).toFixed(3)+" TB":e>=t*t*t?(e/t/t/t).toFixed(3)+" GB":e>=t*t?(e/t/t).toFixed(3)+" MB":e>=t?(e/t).toFixed(3)+" KB":e+" B"},hexToRgb:function(e){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e.toLowerCase());if(!t)throw new Error("Invalid hex color: "+e);return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)]},rgbToHex:function(e){return"#"+e.map((e=>e.toString(16).padStart(2,"0"))).join("")},haversineDistanceToMeters:function(e,t,n,r){const o=e*Math.PI/180,i=n*Math.PI/180,s=(n-e)*Math.PI/180,a=(r-t)*Math.PI/180,c=Math.sin(s/2)*Math.sin(s/2)+Math.cos(o)*Math.cos(i)*Math.sin(a/2)*Math.sin(a/2);return 2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c))*6371e3},roundToNearest:m,formatDistance:function(e){return e>1e3?(e/1e3).toFixed(0)+" km":e>=500?m(e,100)+" m":e>=100?m(e,50)+" m":m(e,10)+" m"},triangularNumber:function(e){return e*(e+1)/2},searchFloat:function(e){const t=e.match(/-?\d+(\.\d+)?/);if(!t)throw Error("No float found in "+e);return parseFloat(t[0])},binomialSample:function(e,t,n=Math.random){const r=e*t,o=Math.sqrt(e*t*(1-t)),i=(n()+n()+n()+n()+n()+n()-3)*Math.SQRT2,s=Math.round(r+o*i);return Math.max(0,Math.min(e,s))},toSignificantDigits:function(e,t){if(!e.includes("."))return e;if(0===parseFloat(e))return"0";const[n,r]=e.split("."),o=n.replace("-",""),i=o.length;if(i>=t)return n;if("0"!==o){const e=t-i,o=r.slice(0,e);return/[1-9]/.test(o)?`${n}.${o.replace(/0+$/,"")}`:n}const s=t+(r.match(/^0*/)?.[0].length??0);return`${n}.${r.slice(0,s)}`}},t.AO={getTimestamp:function(e,t){const n=new Date(t?.now||Date.now()),r=t?.labels||Pe,o=T(e)?e:new Date(e);if(Ne(n)===Ne(o))return r.today(o.getUTCHours(),o.getUTCMinutes(),o.getUTCHours()>12);if(Ne(n)-Ne(o)==1)return r.yesterday();const i=je(o);return Ne(n)-Ne(o)<7?r[i.day]():r.weeks(Math.round((n.getTime()-o.getTime())/6048e5))},getTimeDelta:Fe,secondsToHumanTime:function(e,t=Ce){return Fe(0,{now:1e3*e,labels:t})},countCycles:function(e,t,n){const r=(n?.now??Date.now())-e;return{cycles:Math.floor(r/t),remaining:t/(n?.precision??1)-Math.ceil(r%t/(n?.precision??1))}},isoDate:function(e){return(e||new Date).toISOString().slice(0,10)},throttle:function(e,t){return(!Ge[e]||Date.now()>Ge[e])&&(Ge[e]=Date.now()+t,!0)},timeSince:function(e,t,n){return t=T(t)?t.getTime():t,((n=n?T(n)?n.getTime():n:Date.now())-t)/Me[e]},dateTimeSlug:function(e){return(e||new Date).toISOString().slice(0,19).replace(/T|:/g,"-")},unixTimestamp:function(e){return Math.ceil((e||Date.now())/1e3)},fromUtcString:function(e){const t=new Date(e);return new Date(t.getTime()-6e4*t.getTimezoneOffset())},fromMillis:function(e){return new Date(e)},getProgress:function(e,t,n,r){r||(r=Date.now());const o=r-e,i=o/t,s=i*n;return{deltaMs:o,progress:t/n,baseTimeMs:i,totalTimeMs:s,remainingTimeMs:s-o}},humanizeTime:De,humanizeProgress:function(e){return`[${Math.floor(100*e.progress)}%] ${De(e.deltaMs)} out of ${De(e.totalTimeMs)} (${De(e.remainingTimeMs)} left) [${Math.round(e.baseTimeMs)} ms each]`},createTimeDigits:Ve,mapDayNumber:Le,getDayInfoFromDate:je,getDayInfoFromDateTimeString:function(e){return je(new Date(e))},seconds:function(e){return 1e3*e},minutes:function(e){return 6e4*e},hours:function(e){return 36e5*e},days:function(e){return 864e5*e},make:function(e){const t=parseFloat(e);if(isNaN(t))throw Error("makeDate got NaN for input");const n=e.replace(/^-?[0-9.]+/,"").trim().toLowerCase(),r=""===n?1:Ze[n];if(!r)throw Error(`Unknown unit: "${n}"`);return Math.ceil(t*r)},normalizeTime:function(e){let[t,n]=e.split(":");E(parseInt(t,10))||(t="0"),E(parseInt(n,10))||(n="0");let r=ot(C(t),0,23),o=ot(C(n),0,59);return`${Ve(r)}:${Ve(o)}`},absoluteDays:Ne},t.Rb={safeParse:function(e){try{return JSON.parse(e)}catch{return null}},deleteDeep:function(e,t){const n=Q(t,"."),r=ee(t,".");if(!n||!r)return;const o=d(e,n);o&&delete o[r]},getDeep:d,setDeep:p,incrementDeep:function(e,t,n=1){const r=d(e,t)||0;return p(e,t,r+n),r},ensureDeep:function(e,t,n){return d(e,t)||p(e,t,n)},replaceDeep:function(e,t,n){const r=d(e,t);if(!r)throw new Error("Key '"+t+"' does not exist.");return p(e,t,n),r},getFirstDeep:function(e,t,n){for(const r of t){const t=d(e,r);if(t)return t}if(n){const t=Object.values(e);if(t.length)return t[0]}return null},deepMergeInPlace:j,deepMerge2:function(e,t){const n={};return j(n,e),j(n,t),n},deepMerge3:function(e,t,n){const r={};return j(r,e),j(r,t),j(r,n),r},mapAllAsync:async function(e,t){const n=[];for(const r of e)n.push(await t(r));return n},cloneWithJson:function(e){return JSON.parse(JSON.stringify(e))},sortObject:Je,sortArray:Ke,sortAny:Xe,deepEquals:Ye,deepEqualsEvery:function(...e){for(let t=1;t<e.length;t++)if(!Ye(e[t-1],e[t]))return!1;return!0},runOn:function(e,t){return t(e),e},ifPresent:function(e,t){e&&t(e)},zip:Z,zipSum:function(e){return Z(e,((e,t)=>e+t))},removeEmptyArrays:function(e){for(const t of Object.keys(e))(w(e[t])||Array.isArray(e[t])&&e[t].every((e=>null==e)))&&delete e[t];return e},removeEmptyValues:function(e){for(const t of Object.entries(e))(null===t[1]||void 0===t[1]||B(t[1])&&R(t[1]))&&delete e[t[0]];return e},flatten:function(e,t=!1,n){return st({},e,n||"",!1,t)},unflatten:function e(t){if(!g(t))return t;const n=Array.isArray(t)?[]:{};for(const[r,o]of Object.entries(t))Array.isArray(o)?p(n,r,o.map((t=>e(t)))):p(n,r,o);return n},match:function(e,t,n){return t[e]?t[e]:n},sort:lt,map:function(e,t){const n={};for(const r of Object.entries(e))n[r[0]]=t(r[1]);return n},mapIterable:function(e,t){const n=[];let r=0;for(const o of e)n.push(t(o,r++));return n},filterKeys:function(e,t){const n={};for(const[r,o]of Object.entries(e))t(r)&&(n[r]=o);return n},filterValues:function(e,t){const n={};for(const[r,o]of Object.entries(e))t(o)&&(n[r]=o);return n},rethrow:async function(e,t){try{return await e()}catch{throw t}},setSomeOnObject:function(e,t,n){null!=n&&(e[t]=n)},setSomeDeep:function(e,t,n,r){const o=d(n,r);null!=o&&p(e,t,o)},flip:function(e){const t={};for(const[n,r]of Object.entries(e))t[r]=n;return t},getAllPermutations:function(e){const t=Object.keys(e),n=t.map((t=>e[t].length)),r=n.reduce(((e,t)=>e*t));let o=1;const i=[1];for(let a=0;a<n.length-1;a++)o*=n[a],i.push(o);const s=[];for(let a=0;a<r;a++){const n={};for(let r=0;r<t.length;r++){const o=e[t[r]],s=Math.floor(a/i[r])%o.length;n[t[r]]=o[s]}s.push(n)}return s},countTruthyValues:function(e){return Object.values(e).filter((e=>e)).length},transformToArray:function(e){const t=[],n=Object.keys(e),r=e[n[0]].length;for(let o=0;o<r;o++){const r={};for(const t of n)r[t]=e[t][o];t.push(r)}return t},setMulti:function(e,t,n){for(const r of e)r[t]=n},incrementMulti:function(e,t,n=1){for(const r of e)r[t]+=n},createBidirectionalMap:function(){return{map:new Map,keys:[]}},createTemporalBidirectionalMap:function(){return{map:new Map,keys:[]}},pushToBidirectionalMap:ht,unshiftToBidirectionalMap:function(e,t,n,r=100){if(e.map.has(t)){const n=e.keys.indexOf(t);e.keys.splice(n,1)}if(e.map.set(t,n),e.keys.unshift(t),e.keys.length>r){const t=e.keys.shift();t&&e.map.delete(t)}},addToTemporalBidirectionalMap:function(e,t,n,r,o=100){ht(e,t,{validUntil:Date.now()+r,data:n},o)},getFromTemporalBidirectionalMap:function(e,t){const n=e.map.get(t);return n&&n.validUntil>Date.now()?n.data:null},createStatefulToggle:function(e){let t;return n=>{const r=n===e&&t!==e;return t=n,r}},diffKeys:function(e,t){const n=Object.keys(e),r=Object.keys(t);return{uniqueToA:n.filter((e=>!r.includes(e))),uniqueToB:r.filter((e=>!n.includes(e)))}},pickRandomKey:Qe,mapRandomKey:function(e,t){const n=Qe(e);return e[n]=t(e[n]),n},fromObjectString:function(e){return e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=e.replace(/\r\n/g,"\n")).replace(/(\w+)\((.+)\)/g,((e,t,n)=>`${t}(${n.replaceAll(",","&comma;")})`))).replace(/(,)(\s+})/g,"$2")).replace(/\.\.\..+?,/g,"")).replace(/({\s+)([a-zA-Z]\w+),/g,"$1$2: '$2',")).replace(/(,\s+)([a-zA-Z]\w+),/g,"$1$2: '$2',")).replace(/:(.+)\?(.+):/g,((e,t,n)=>`: (${t.trim()} && ${n.trim()}) ||`))).replace(/([a-zA-Z0-9]+)( ?: ?{)/g,'"$1"$2')).replace(/([a-zA-Z0-9]+) ?: ?(.+?)(,|\n|})/g,((e,t,n,r)=>`"${t}":"${n.trim()}"${r}`))).replace(/("'|'")/g,'"')).replaceAll("&comma;",","),JSON.parse(e)},toQueryString:_e,parseQueryString:function(e){const t={},n=e.split("&");for(const r of n){const[e,n]=r.split("=");e&&n&&(t[e]=decodeURIComponent(n))}return t},hasKey:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},selectMax:function(e,t){let n=null,r=-1/0;for(const[o,i]of Object.entries(e)){const e=t(i);e>r&&(r=e,n=o)}return n?[n,e[n]]:null},reposition:function(e,t,n,r){const o=e.find((e=>e[t]===n)),i=e.find((e=>e[t]===n+r));o&&i?(o[t]=n+r,i[t]=n):o&&(o[t]=n+r),e.sort(((e,n)=>P(e[t])-P(n[t]))),e.forEach(((e,n)=>e[t]=n+1))},unwrapSingleKey:function(e){const t=Object.keys(e);if(1===t.length)return e[t[0]];throw new Error("Expected object to have a single key")},parseKeyValues:function(e,t=":"){return Object.fromEntries(e.map((e=>te(e,t))).map((e=>e[0]&&e[1]?[ie(e[0]),ie(e[1])]:null)).filter((e=>e)))},errorMatches:function(e,t){if(!e)return!1;const n=e.message;return"string"==typeof n&&n.includes(t)}},t.Or={isFunction:v,isObject:g,isStrictlyObject:y,isEmptyArray:w,isEmptyObject:function(e){return y(e)&&0===Object.keys(e).length},isUndefined:b,isString:B,isNumber:E,isBoolean:x,isDate:T,isBlank:R,isId:z,isIntegerString:A,isHexString:k,isUrl:G,isBigint:M,isNullable:function(e,t){return null==t||e(t)},asString:D,asHexString:function(e,t){if(!k(e))throw new TypeError(`Expected hex string${t?.name?` for ${t.name}`:""}, got: `+e);if(t?.strictPrefix&&!e.startsWith("0x")&&!e.startsWith("0X"))throw new TypeError(`Expected hex string with 0x prefix${t?.name?` for ${t.name}`:""}, got: `+e);const n=e.replace(/^0x/i,"");if(n.length%2!=0&&!t?.uneven)throw RangeError(`Expected even number of hex digits${t?.name?` for ${t.name}`:""}; got: `+e);if(t&&t.byteLength&&n.length!==2*t.byteLength)throw RangeError(`Expected hex string${t?.name?` for ${t.name}`:""} of byte length ${t.byteLength}; got: `+n);return`0x${n}`},asSafeString:function(e,t){if(!D(e,t).split("").every((e=>"_"===e||le(e))))throw new TypeError(`Expected safe string${t?.name?` for ${t.name}`:""}, got: `+e);return e},asIntegerString:function(e,t){if(!A(e))throw new TypeError(`Expected integer string${t?.name?` for ${t.name}`:""}, got: `+e);const n=BigInt(e);if(t&&(t.min&&n<t.min||t.max&&n>t.max))throw RangeError(`Expected integer string${t?.name?` for ${t.name}`:""} in range: ${t.min??"-inf"}..${t.max??"inf"}; got: `+n);return e},asNumber:P,asFunction:function(e,t){if(!v(e))throw new TypeError(`Expected function${t?.name?` for ${t.name}`:""}, got: `+e);return e},asInteger:C,asBoolean:function(e,t){if("true"===e)return!0;if("false"===e)return!1;if(!x(e))throw new TypeError(`Expected boolean${t?.name?` for ${t.name}`:""}, got: `+e);return e},asDate:function(e,t){if(!T(e))throw new TypeError(`Expected date${t?.name?` for ${t.name}`:""}, got: `+e);return e},asNullableString:function(e){return R(e)?null:e},asEmptiableString:function(e,t){if(!B(e))throw new TypeError(`Expected string${t?.name?` for ${t.name}`:""}, got: `+e);return e},asId:function(e,t){if(z(e))return e;const n=parseInt(e,10);if(!z(n))throw new TypeError(`Expected id${t?.name?` for ${t.name}`:""}, got: `+e);return n},asTime:function(e,t){if(!B(e))throw new TypeError(`Expected time${t?.name?` for ${t.name}`:""}, got: `+e);const n=e.split(":");if(2!==n.length)throw new TypeError(`Expected time${t?.name?` for ${t.name}`:""}, got: `+e);const r=parseInt(n[0],10),o=parseInt(n[1],10);if(!E(r)||!E(o)||r<0||r>23||o<0||o>59)throw new TypeError(`Expected time, got${t?.name?` for ${t.name}`:""}: `+e);return`${String(r).padStart(2,"0")}:${String(o).padStart(2,"0")}`},asArray:function(e,t){if(!Array.isArray(e))throw new TypeError(`Expected array${t?.name?` for ${t.name}`:""}, got: `+e);return e},asObject:F,asNullableObject:function(e,t){return null===e?null:F(e,t)},asStringMap:function(e,t){const n=F(e,t);for(const r of Object.keys(n))if(!B(n[r]))throw new TypeError(`Expected string map${t?.name?` for ${t.name}`:""}, got: `+e);return n},asNumericDictionary:function(e,t){const n=F(e),r=Object.keys(n),o=Object.values(n);if(!r.every(B)||!o.every(E))throw new TypeError(`Expected numeric dictionary${t?.name?` for ${t.name}`:""}, got: `+e);return n},asUrl:function(e,t){if(!G(e))throw new TypeError(`Expected url${t?.name?` for ${t.name}`:""}, got: `+e);return e},asBigint:U,asEmptiable:function(e,t){return""===t?void 0:e(t)},asNullable:function(e,t){return null==t?null:e(t)},asOptional:function(e,t){return null==t?void 0:e(t)},enforceObjectShape:L,enforceArrayShape:function(e,t){return e.every((e=>L(e,t)))},isPng:yt,isJpg:wt,isWebp:bt,isImage:function(e){return yt(e)||wt(e)||bt(e)}},t.DH={tokenizeByCount:function(e,t){return ut(e,Math.ceil(e.length/t))},tokenizeByLength:ut,searchHex:function(e,t){const n=new RegExp(`[0-9a-f]{${t}}`,"i"),r=e.match(n);return r?r[0]:null},searchSubstring:function(e,t,n=S){const r=ne(e,n);for(const o of r)if(t(o))return o;return null},randomHex:function(e,t=Math.random){let n="";for(let r=0;r<e;r++)n+=V[Math.floor(16*t())];return n},randomLetter:function(e,t=Math.random){let n="";for(let r=0;r<e;r++)n+=O[Math.floor(26*t())];return n},randomAlphanumeric:function(e,t=Math.random){let n="";for(let r=0;r<e;r++)n+=$[Math.floor(62*t())];return n},randomRichAscii:function(e,t=Math.random){let n="";for(let r=0;r<e;r++)n+=I[Math.floor(89*t())];return n},randomUnicode:function(e,t=Math.random){let n="";for(let r=0;r<e;r++)n+=_[Math.floor(t()*_.length)];return n},includesAny:function(e,t){return t.some((t=>e.includes(t)))},slugify:W,normalForm:function(e){return W(e).replaceAll("-","")},enumify:function(e){return W(e).replace(/-/g,"_").toUpperCase()},escapeHtml:function(e){return e.replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")},decodeHtmlEntities:function(e){let t=e.replace(/&#(\d+);/g,((e,t)=>String.fromCharCode(t))).replace(/&#x(\d+);/g,((e,t)=>String.fromCharCode(parseInt(t,16))));for(const[n,r]of Object.entries(K))t=t.replaceAll(n,r);return t},after:Y,afterLast:ee,before:X,beforeLast:Q,betweenWide:function(e,t,n){const r=Q(e,n);return r?Y(r,t):null},betweenNarrow:function(e,t,n){const r=Y(e,t);return r?X(r,n):null},getPreLine:function(e){return e.replace(/ +/g," ").replace(/^ /gm,"")},containsWord:Se,containsWords:function(e,t,n){return"any"===n?t.some((t=>Se(e,t))):t.every((t=>Se(e,t)))},joinUrl:We,getFuzzyMatchScore:J,sortByFuzzyScore:function(e,t){return e.filter((e=>J(e,t))).sort(((e,n)=>J(n,t)-J(e,t)))},splitOnce:te,splitAll:ne,randomize:function(e,t=Math.random){return e.replace(/\{(.+?)\}/g,((e,n)=>l(n.split("|"),t)))},expand:function e(t){const n=t.match(/\{(.+?)\}/);if(!n||!n.index)return[t];const r=n[1].split(","),o=t.slice(0,n.index),i=t.slice(n.index+n[0].length);let s=[];for(const a of r){const t=e(o+a+i);s=s.concat(t)}return s},shrinkTrim:ie,capitalize:se,decapitalize:ae,csvEscape:function(e){return e.match(/"|,/)?`"${e.replace(/"/g,'""')}"`:e},parseCsv:function(e,t=",",n='"'){const r=[];let o="",i=!1;const s=e.split("");for(const a of s)a!==t||i?a!==n||(o||i)&&!i?o+=a:i=!i:(r.push(o),o="");return r.push(o),r},surroundInOut:function(e,t){return t+e.split("").join(t)+t},getExtension:re,getBasename:oe,normalizeEmail:function(e){let[t,n]=e.split("@");t=ie(t.replaceAll(".","").toLowerCase()).replaceAll(" ","");const[r]=t.split("+");if(!r||!n||-1===n.indexOf(".")||n.indexOf(".")===n.length-1)throw new Error("Invalid email");return n=ie(n.toLowerCase()).replaceAll(" ",""),`${r}@${n}`},normalizeFilename:function(e){const t=oe(e),n=re(e);return n?`${t}.${n}`:t},parseFilename:function(e){const t=oe(e),n=re(e);return{basename:t,extension:n,filename:n?`${t}.${n}`:t}},camelToTitle:function(e){return se(e.replace(/([A-Z])/g," $1"))},slugToTitle:function(e){return e.split("-").map(se).join(" ")},slugToCamel:function(e){return ae(e.split("-").map(se).join(""))},joinHumanly:function(e,t=", ",n=" and "){return e&&e.length?1===e.length?e[0]:2===e.length?`${e[0]}${n}${e[1]}`:`${e.slice(0,e.length-1).join(t)}${n}${e[e.length-1]}`:""},findWeightedPair:ve,extractBlock:Be,extractAllBlocks:function(e,t){const n=[];let r=t.wordBoundary?ge(e,[`${t.opening} `,`${t.opening}\n`],t.start||0):e.indexOf(t.opening,t.start||0);for(;;){if(-1===r)return n;const o=Be(e,{...t,start:r});if(!o)return n;n.push(o),r=t.wordBoundary?ge(e,[`${t.opening} `,`${t.opening}\n`],r+o.length):e.indexOf(t.opening,r+o.length)}},replaceBlocks:function(e,n,r){let o=0;for(;;){const i=t.DH.extractBlock(e,{...r,start:o});if(!i)return e;const s=n(i);o=e.indexOf(i,o)+s.length,e=e.replace(i,s)}},indexOfEarliest:ge,lastIndexOfBefore:be,parseHtmlAttributes:function(e){const t={},n=e.match(/([a-z\-]+)="([^"]+)"/g);if(n)for(const r of n){const[e,n]=te(r,"=");t[e]=n.slice(1,n.length-1)}return t},readNextWord:Oe,readWordsAfterAll:function(e,t,n=[]){const r=me(e,t),o=[];for(const i of r)o.push(Oe(e,i+t.length,n));return o},resolveVariables:function(e,t,n="$",r=":"){for(const o in t)e=$e(e,o,t[o],n,r);return e=Ie(e)},resolveVariableWithDefaultSyntax:$e,resolveRemainingVariablesWithDefaults:Ie,isLetter:ce,isDigit:ue,isLetterOrDigit:le,isValidObjectPathCharacter:function(e){return le(e)||"."===e||"["===e||"]"===e||"_"===e},insert:function(e,t,n,r,o){return e.slice(0,t)+r+e.slice(t,t+n)+o+e.slice(t+n)},indexOfRegex:de,allIndexOf:me,lineMatches:pe,linesMatchInOrder:function(e,t,n=!0){let r=0;for(const o of t){let t=!1;for(;!t&&r<e.length;)pe(e[r],o,n)&&(t=!0),r++;if(!t)return!1}return!0},represent:function e(t,n="json",r=0){if(t&&v(t.represent)){const e=t.represent();if(B(e))return"json"===n&&0===r?JSON.stringify(e):e}if(g(t,!1)){if(r>1)return"[object Object]";if("json"===n){if(Array.isArray(t)){const n=t.map((t=>e(t,"json",r+1)));return 0===r?JSON.stringify(n):n}const n={};t.message&&(n.message=e(t.message,"json",r+1));for(const[o,i]of Object.entries(t))n[o]=e(i,"json",r+1);return 0===r?JSON.stringify(n):n}if("key-value"===n){const n=Object.keys(t);return t.message&&!n.includes("message")&&n.unshift("message"),n.map((n=>`${n}=${JSON.stringify(e(t[n],"json",r+1))}`)).join(" ")}}return b(t)&&(t="undefined"),0===r?JSON.stringify(t):t},resolveMarkdownLinks:function(e,t){let n=e.indexOf("](");for(;-1!==n;){const r=be(e,"[",n),o=e.indexOf(")",n);if(-1!==r&&-1!==o){const[n,i]=e.slice(r+1,o).split("]("),s=t(n,i);e=e.slice(0,r)+s+e.slice(o+1)}n=e.indexOf("](",n+1)}return e},buildUrl:function(e,t,n){return We([e,t])+_e(n||{})},isChinese:function(e){return/^[\u4E00-\u9FA5]+$/.test(e)},replaceBetweenStrings:function(e,t,n,r,o=!0){const i=e.indexOf(t),s=e.indexOf(n,i+t.length);if(-1===i||-1===s)throw Error("Start or end not found");return o?e.substring(0,i+t.length)+r+e.substring(s):e.substring(0,i)+r+e.substring(s+n.length)},describeMarkdown:function(e){let t="p";return e.startsWith("#")?(t="h1",e=e.slice(1).trim()):e.startsWith("-")&&(t="li",e=e.slice(1).trim()),{type:t,isCapitalized:e[0]===e[0].toUpperCase(),hasPunctuation:/[.?!]$/.test(e),endsWithColon:/:$/.test(e)}},isBalanced:function(e,t="(",n=")"){let r=0,o=0;for(;o<e.length;)if(e.startsWith(t,o)?(r++,o+=t.length):e.startsWith(n,o)?(r--,o+=n.length):o++,r<0)return!1;return t===n?r%2==0:0===r},textToFormat:function(e){let t=(e=e.normalize("NFD").replace(/[\u0300-\u036f]/g,"")).length;for(;(e=e.replace(/(\w+)[\s,']+\w+/g,"$1")).length!==t;)t=e.length;return e=(e=(e=e.replaceAll(/[A-Z][a-zA-Z0-9]*/g,"A")).replaceAll(/[a-z][a-zA-Z0-9]*/g,"a")).replaceAll(/[\u4E00-\u9FA5]+/g,"Z")},splitFormatting:function(e,t){const n=[];let r=0;for(;r<e.length;){const o=e.indexOf(t,r);if(-1===o){n.push({string:e.slice(r),symbol:null});break}const i=e.indexOf(t,o+t.length);if(o>r&&-1!==i&&n.push({string:e.slice(r,o),symbol:null}),-1===i){n.push({string:e.slice(r),symbol:null});break}n.push({string:e.slice(o+t.length,i),symbol:t}),r=i+t.length}return n},splitHashtags:function(e){const t=[];let n=0;for(;n<e.length;){const r=we(e,n);if(-1===r){t.push({string:e.slice(n),symbol:null});break}const o=ye(e,r+1);if(-1===o){t.push({string:e.slice(n,r),symbol:null}),t.push({string:e.slice(r+1),symbol:"#"});break}r>n&&t.push({string:e.slice(n,r),symbol:null}),t.push({string:e.slice(r+1,o),symbol:"#"}),n=o}return t},splitUrls:function(e){const t=[];let n=0;for(;n<e.length;){const r=ge(e,["http://","https://"],n);if(-1===r){t.push({string:e.slice(n),symbol:null});break}const o=ge(e,[" ","\n"],r);if(-1===o){r>n&&t.push({string:e.slice(n,r),symbol:null}),t.push({string:e.slice(r),symbol:"http"});break}r>n&&t.push({string:e.slice(n,r),symbol:null}),t.push({string:e.slice(r,o),symbol:"http"}),n=o}return t},route:function(e,t){const n=e.split("/").filter((e=>e)),r=t.split("/").filter((e=>e));if(n.length!==r.length)return null;const o={};for(let i=0;i<n.length;i++){const e=n[i];if(e.startsWith(":"))o[e.slice(1)]=r[i];else if(e!==r[i])return null}return o},explodeReplace:ze,generateVariants:function(e,n,r,o=Math.random){const i=t.DO.shuffle(n.map((e=>({variants:t.DO.shuffle(e.variants.map((e=>e)),o),avoid:e.avoid}))),o),s=[];for(const t of i){const n=t.variants.filter((e=>e!==t.avoid)),o=n.find((t=>e.includes(t)));if(o&&(q(s,ze(e,o,n)),s.length>=r))break}if(s.length<r)for(const t of i){const n=t.variants.find((t=>e.includes(t)));if(n&&(q(s,ze(e,n,t.variants)),s.length>=r))break}return s.slice(0,r)},replaceWord:function(e,t,n,r=!1){const o=new RegExp(r?`(?<=\\s|^)${t}(?=\\s|$)`:`\\b${t}\\b`,"g");return e.replace(o,n)},replacePascalCaseWords:function(e,t){return e.replace(/\b[A-Z][a-zA-Z0-9]*\b/g,(e=>e.toUpperCase()===e?e:t(e)))},stripHtml:function(e){return e.replace(/<[^>]*>/g,"")},breakLine:Ae,measureTextWidth:function(e,t={}){return[...e].reduce(((e,n)=>e+(t[n]||1)),0)},toLines:function(e,t,n={}){const r=[];let o="",i=0;for(let s=0;s<e.length;s++){const a=e[s];if(o+=a,i+=n[a]||1,i>t){const{line:e,rest:t}=Ae(o);r.push(e),o=t,i=t.split("").map((e=>n[e]||1)).reduce(((e,t)=>e+t),0)}}return o&&r.push(o),r},levenshteinDistance:function(e,t){const n=[];for(let r=0;r<=e.length;r++)n[r]=[r];for(let r=0;r<=t.length;r++)n[0][r]=r;for(let r=1;r<=e.length;r++)for(let o=1;o<=t.length;o++){const i=e[r-1]===t[o-1]?0:1;n[r][o]=Math.min(n[r-1][o]+1,n[r][o-1]+1,n[r-1][o-1]+i)}return n[e.length][t.length]},findCommonPrefix:ke,findCommonDirectory:function(e){const t=ke(e),n=t.lastIndexOf("/");return-1===n?"":t.slice(0,n+1)}}},878(e,t,n){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0,o=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(r++,"%c"===e&&(o=r))})),t.splice(o,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(n){}},t.load=function(){let e;try{e=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch(n){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=n(945)(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}},945(e,t,n){e.exports=function(e){function t(e){let n,o,i,s=null;function a(...e){if(!a.enabled)return;const r=a,o=Number(new Date),i=o-(n||o);r.diff=i,r.prev=n,r.curr=o,n=o,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,o)=>{if("%%"===n)return"%";s++;const i=t.formatters[o];if("function"==typeof i){const t=e[s];n=i.call(r,t),e.splice(s,1),s--}return n})),t.formatArgs.call(r,e);(r.log||t.log).apply(r,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=r,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(o!==t.namespaces&&(o=t.namespaces,i=t.enabled(e)),i),set:e=>{s=e}}),"function"==typeof t.init&&t.init(a),a}function r(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function o(e,t){let n=0,r=0,o=-1,i=0;for(;n<e.length;)if(r<t.length&&(t[r]===e[n]||"*"===t[r]))"*"===t[r]?(o=r,i=n,r++):(n++,r++);else{if(-1===o)return!1;r=o+1,i++,n=i}for(;r<t.length&&"*"===t[r];)r++;return r===t.length}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names,...t.skips.map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const r of n)"-"===r[0]?t.skips.push(r.slice(1)):t.names.push(r)},t.enabled=function(e){for(const n of t.skips)if(o(e,n))return!1;for(const n of t.names)if(o(e,n))return!0;return!1},t.humanize=n(192),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((n=>{t[n]=e[n]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return t.colors[Math.abs(n)%t.colors.length]},t.enable(t.load()),t}},192(e){var t=1e3,n=60*t,r=60*n,o=24*r,i=7*o,s=365.25*o;function a(e,t,n,r){var o=t>=1.5*n;return Math.round(e/n)+" "+r+(o?"s":"")}e.exports=function(e,c){c=c||{};var u=typeof e;if("string"===u&&e.length>0)return function(e){if((e=String(e)).length>100)return;var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!a)return;var c=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*s;case"weeks":case"week":case"w":return c*i;case"days":case"day":case"d":return c*o;case"hours":case"hour":case"hrs":case"hr":case"h":return c*r;case"minutes":case"minute":case"mins":case"min":case"m":return c*n;case"seconds":case"second":case"secs":case"sec":case"s":return c*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(e);if("number"===u&&isFinite(e))return c.long?function(e){var i=Math.abs(e);if(i>=o)return a(e,i,o,"day");if(i>=r)return a(e,i,r,"hour");if(i>=n)return a(e,i,n,"minute");if(i>=t)return a(e,i,t,"second");return e+" ms"}(e):function(e){var i=Math.abs(e);if(i>=o)return Math.round(e/o)+"d";if(i>=r)return Math.round(e/r)+"h";if(i>=n)return Math.round(e/n)+"m";if(i>=t)return Math.round(e/t)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},963(e,t,n){"use strict";const r=n(527),{MAX_LENGTH:o,MAX_SAFE_INTEGER:i}=n(197),{safeRe:s,t:a}=n(423),c=n(676),{compareIdentifiers:u}=n(956);class l{constructor(e,t){if(t=c(t),e instanceof l){if(e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease)return e;e=e.version}else if("string"!=typeof e)throw new TypeError(`Invalid version. Must be a string. Got type "${typeof e}".`);if(e.length>o)throw new TypeError(`version is longer than ${o} characters`);r("SemVer",e,t),this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease;const n=e.trim().match(t.loose?s[a.LOOSE]:s[a.FULL]);if(!n)throw new TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+n[1],this.minor=+n[2],this.patch=+n[3],this.major>i||this.major<0)throw new TypeError("Invalid major version");if(this.minor>i||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>i||this.patch<0)throw new TypeError("Invalid patch version");n[4]?this.prerelease=n[4].split(".").map((e=>{if(/^[0-9]+$/.test(e)){const t=+e;if(t>=0&&t<i)return t}return e})):this.prerelease=[],this.build=n[5]?n[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(e){if(r("SemVer.compare",this.version,this.options,e),!(e instanceof l)){if("string"==typeof e&&e===this.version)return 0;e=new l(e,this.options)}return e.version===this.version?0:this.compareMain(e)||this.comparePre(e)}compareMain(e){return e instanceof l||(e=new l(e,this.options)),this.major<e.major?-1:this.major>e.major?1:this.minor<e.minor?-1:this.minor>e.minor?1:this.patch<e.patch?-1:this.patch>e.patch?1:0}comparePre(e){if(e instanceof l||(e=new l(e,this.options)),this.prerelease.length&&!e.prerelease.length)return-1;if(!this.prerelease.length&&e.prerelease.length)return 1;if(!this.prerelease.length&&!e.prerelease.length)return 0;let t=0;do{const n=this.prerelease[t],o=e.prerelease[t];if(r("prerelease compare",t,n,o),void 0===n&&void 0===o)return 0;if(void 0===o)return 1;if(void 0===n)return-1;if(n!==o)return u(n,o)}while(++t)}compareBuild(e){e instanceof l||(e=new l(e,this.options));let t=0;do{const n=this.build[t],o=e.build[t];if(r("build compare",t,n,o),void 0===n&&void 0===o)return 0;if(void 0===o)return 1;if(void 0===n)return-1;if(n!==o)return u(n,o)}while(++t)}inc(e,t,n){if(e.startsWith("pre")){if(!t&&!1===n)throw new Error("invalid increment argument: identifier is empty");if(t){const e=`-${t}`.match(this.options.loose?s[a.PRERELEASELOOSE]:s[a.PRERELEASE]);if(!e||e[1]!==t)throw new Error(`invalid identifier: ${t}`)}}switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",t,n);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",t,n);break;case"prepatch":this.prerelease.length=0,this.inc("patch",t,n),this.inc("pre",t,n);break;case"prerelease":0===this.prerelease.length&&this.inc("patch",t,n),this.inc("pre",t,n);break;case"release":if(0===this.prerelease.length)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":0===this.minor&&0===this.patch&&0!==this.prerelease.length||this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":0===this.patch&&0!==this.prerelease.length||this.minor++,this.patch=0,this.prerelease=[];break;case"patch":0===this.prerelease.length&&this.patch++,this.prerelease=[];break;case"pre":{const e=Number(n)?1:0;if(0===this.prerelease.length)this.prerelease=[e];else{let r=this.prerelease.length;for(;--r>=0;)"number"==typeof this.prerelease[r]&&(this.prerelease[r]++,r=-2);if(-1===r){if(t===this.prerelease.join(".")&&!1===n)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(e)}}if(t){let r=[t,e];if(!1===n&&(r=[t]),((e,t)=>{const n=t.split(".");if(n.length>e.length)return!1;for(let r=0;r<n.length;r++)if(0!==u(e[r],n[r]))return!1;return!0})(this.prerelease,t)){const e=this.prerelease[t.split(".").length];isNaN(e)&&(this.prerelease=r)}else this.prerelease=r}break}default:throw new Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}}e.exports=l},359(e,t,n){"use strict";const r=n(963);e.exports=(e,t)=>new r(e,t).major},197(e){"use strict";const t=Number.MAX_SAFE_INTEGER||9007199254740991;e.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:t,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:"2.0.0",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}},527(e){"use strict";const t="object"==typeof process&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};e.exports=t},956(e){"use strict";const t=/^[0-9]+$/,n=(e,n)=>{if("number"==typeof e&&"number"==typeof n)return e===n?0:e<n?-1:1;const r=t.test(e),o=t.test(n);return r&&o&&(e=+e,n=+n),e===n?0:r&&!o?-1:o&&!r?1:e<n?-1:1};e.exports={compareIdentifiers:n,rcompareIdentifiers:(e,t)=>n(t,e)}},676(e){"use strict";const t=Object.freeze({loose:!0}),n=Object.freeze({});e.exports=e=>e?"object"!=typeof e?t:e:n},423(e,t,n){"use strict";const{MAX_SAFE_COMPONENT_LENGTH:r,MAX_SAFE_BUILD_LENGTH:o,MAX_LENGTH:i}=n(197),s=n(527),a=(t=e.exports={}).re=[],c=t.safeRe=[],u=t.src=[],l=t.safeSrc=[],f=t.t={};let h=0;const d="[a-zA-Z0-9-]",p=[["\\s",1],["\\d",i],[d,o]],m=(e,t,n)=>{const r=(e=>{for(const[t,n]of p)e=e.split(`${t}*`).join(`${t}{0,${n}}`).split(`${t}+`).join(`${t}{1,${n}}`);return e})(t),o=h++;s(e,o,t),f[e]=o,u[o]=t,l[o]=r,a[o]=new RegExp(t,n?"g":void 0),c[o]=new RegExp(r,n?"g":void 0)};m("NUMERICIDENTIFIER","0|[1-9]\\d*"),m("NUMERICIDENTIFIERLOOSE","\\d+"),m("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${d}*`),m("MAINVERSION",`(${u[f.NUMERICIDENTIFIER]})\\.(${u[f.NUMERICIDENTIFIER]})\\.(${u[f.NUMERICIDENTIFIER]})`),m("MAINVERSIONLOOSE",`(${u[f.NUMERICIDENTIFIERLOOSE]})\\.(${u[f.NUMERICIDENTIFIERLOOSE]})\\.(${u[f.NUMERICIDENTIFIERLOOSE]})`),m("PRERELEASEIDENTIFIER",`(?:${u[f.NONNUMERICIDENTIFIER]}|${u[f.NUMERICIDENTIFIER]})`),m("PRERELEASEIDENTIFIERLOOSE",`(?:${u[f.NONNUMERICIDENTIFIER]}|${u[f.NUMERICIDENTIFIERLOOSE]})`),m("PRERELEASE",`(?:-(${u[f.PRERELEASEIDENTIFIER]}(?:\\.${u[f.PRERELEASEIDENTIFIER]})*))`),m("PRERELEASELOOSE",`(?:-?(${u[f.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${u[f.PRERELEASEIDENTIFIERLOOSE]})*))`),m("BUILDIDENTIFIER",`${d}+`),m("BUILD",`(?:\\+(${u[f.BUILDIDENTIFIER]}(?:\\.${u[f.BUILDIDENTIFIER]})*))`),m("FULLPLAIN",`v?${u[f.MAINVERSION]}${u[f.PRERELEASE]}?${u[f.BUILD]}?`),m("FULL",`^${u[f.FULLPLAIN]}$`),m("LOOSEPLAIN",`[v=\\s]*${u[f.MAINVERSIONLOOSE]}${u[f.PRERELEASELOOSE]}?${u[f.BUILD]}?`),m("LOOSE",`^${u[f.LOOSEPLAIN]}$`),m("GTLT","((?:<|>)?=?)"),m("XRANGEIDENTIFIERLOOSE",`${u[f.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),m("XRANGEIDENTIFIER",`${u[f.NUMERICIDENTIFIER]}|x|X|\\*`),m("XRANGEPLAIN",`[v=\\s]*(${u[f.XRANGEIDENTIFIER]})(?:\\.(${u[f.XRANGEIDENTIFIER]})(?:\\.(${u[f.XRANGEIDENTIFIER]})(?:${u[f.PRERELEASE]})?${u[f.BUILD]}?)?)?`),m("XRANGEPLAINLOOSE",`[v=\\s]*(${u[f.XRANGEIDENTIFIERLOOSE]})(?:\\.(${u[f.XRANGEIDENTIFIERLOOSE]})(?:\\.(${u[f.XRANGEIDENTIFIERLOOSE]})(?:${u[f.PRERELEASELOOSE]})?${u[f.BUILD]}?)?)?`),m("XRANGE",`^${u[f.GTLT]}\\s*${u[f.XRANGEPLAIN]}$`),m("XRANGELOOSE",`^${u[f.GTLT]}\\s*${u[f.XRANGEPLAINLOOSE]}$`),m("COERCEPLAIN",`(^|[^\\d])(\\d{1,${r}})(?:\\.(\\d{1,${r}}))?(?:\\.(\\d{1,${r}}))?`),m("COERCE",`${u[f.COERCEPLAIN]}(?:$|[^\\d])`),m("COERCEFULL",u[f.COERCEPLAIN]+`(?:${u[f.PRERELEASE]})?`+`(?:${u[f.BUILD]})?(?:$|[^\\d])`),m("COERCERTL",u[f.COERCE],!0),m("COERCERTLFULL",u[f.COERCEFULL],!0),m("LONETILDE","(?:~>?)"),m("TILDETRIM",`(\\s*)${u[f.LONETILDE]}\\s+`,!0),t.tildeTrimReplace="$1~",m("TILDE",`^${u[f.LONETILDE]}${u[f.XRANGEPLAIN]}$`),m("TILDELOOSE",`^${u[f.LONETILDE]}${u[f.XRANGEPLAINLOOSE]}$`),m("LONECARET","(?:\\^)"),m("CARETTRIM",`(\\s*)${u[f.LONECARET]}\\s+`,!0),t.caretTrimReplace="$1^",m("CARET",`^${u[f.LONECARET]}${u[f.XRANGEPLAIN]}$`),m("CARETLOOSE",`^${u[f.LONECARET]}${u[f.XRANGEPLAINLOOSE]}$`),m("COMPARATORLOOSE",`^${u[f.GTLT]}\\s*(${u[f.LOOSEPLAIN]})$|^$`),m("COMPARATOR",`^${u[f.GTLT]}\\s*(${u[f.FULLPLAIN]})$|^$`),m("COMPARATORTRIM",`(\\s*)${u[f.GTLT]}\\s*(${u[f.LOOSEPLAIN]}|${u[f.XRANGEPLAIN]})`,!0),t.comparatorTrimReplace="$1$2$3",m("HYPHENRANGE",`^\\s*(${u[f.XRANGEPLAIN]})\\s+-\\s+(${u[f.XRANGEPLAIN]})\\s*$`),m("HYPHENRANGELOOSE",`^\\s*(${u[f.XRANGEPLAINLOOSE]})\\s+-\\s+(${u[f.XRANGEPLAINLOOSE]})\\s*$`),m("STAR","(<|>)?=?\\s*\\*"),m("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),m("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")},497(){},61(){},320(){}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{"use strict";n.r(r),n.d(r,{BRANCHES:()=>pu,BZZ:()=>su,BatchId:()=>Pt,Bee:()=>Uh,BeeArgumentError:()=>nu,BeeError:()=>tu,BeeModes:()=>fu,BeeResponseError:()=>ru,Bytes:()=>Nt,CHUNK_SIZE:()=>mu,ChunkBuilder:()=>zn,ChunkSplitter:()=>An,DAI:()=>au,Duration:()=>ou,EthAddress:()=>Mt,FeedIndex:()=>Lt,Identifier:()=>Zt,MantarayNode:()=>kl,NULL_ADDRESS:()=>qh,NULL_IDENTIFIER:()=>Hh,NULL_OWNER:()=>Wh,NULL_STAMP:()=>jh,NULL_TOPIC:()=>Zh,PSS_TARGET_HEX_LENGTH_MAX:()=>gu,PeerAddress:()=>qt,PrivateKey:()=>en,PublicKey:()=>Jt,RedundancyLevel:()=>Bu,RedundancyStrategy:()=>Eu,Reference:()=>nn,RollingFeedReader:()=>Wf,RollingFeedWriter:()=>Hf,SECTION_SIZE:()=>du,STAMPS_DEPTH_MAX:()=>wu,STAMPS_DEPTH_MIN:()=>yu,SUPPORTED_BEE_VERSION:()=>vh,SUPPORTED_BEE_VERSION_EXACT:()=>bh,SWARM_GATEWAY_URL:()=>Lh,Signature:()=>Qt,Size:()=>iu,Span:()=>rn,Stamper:()=>ar,TAGS_LIMIT_MAX:()=>vu,TAGS_LIMIT_MIN:()=>bu,Topic:()=>sn,TransactionId:()=>an,Utils:()=>e,capacityBreakpoints:()=>xu,toBeeMode:()=>hu});var e={};n.r(e),n.d(e,{approximateOverheadForRedundancyLevel:()=>$n,convertEnvelopeToMarshaledStamp:()=>Wu,getAmountForDuration:()=>qu,getCollectionSize:()=>Fl,getDepthForSize:()=>Hu,getFolderSize:()=>_l,getRedundancyStat:()=>Pn,getRedundancyStats:()=>Nn,getStampCost:()=>ju,getStampDuration:()=>Zu,getStampEffectiveBytes:()=>rr,getStampEffectiveBytesBreakpoints:()=>or,getStampTheoreticalBytes:()=>Xn,getStampUsage:()=>Kn,makeCollectionFromFileList:()=>Cl,makeMaxTarget:()=>Jh,mapPostageBatch:()=>Ju,unmapPostageBatch:()=>Ku});const t="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function o(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function i(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function s(e,...t){if(!o(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function a(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.createHasher");i(e.outputLen),i(e.blockLen)}function c(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function u(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function l(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function f(e,t){return e<<32-t|e>>>t}const h=(()=>"function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex)(),d=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function p(e){if(s(e),h)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=d[e[n]];return t}const m=48,g=57,y=65,w=70,b=97,v=102;function B(e){return e>=m&&e<=g?e-m:e>=y&&e<=w?e-(y-10):e>=b&&e<=v?e-(b-10):void 0}function E(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(h)return Uint8Array.fromHex(e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let o=0,i=0;o<n;o++,i+=2){const t=B(e.charCodeAt(i)),n=B(e.charCodeAt(i+1));if(void 0===t||void 0===n){const t=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+i)}r[o]=16*t+n}return r}function x(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}function T(e){return"string"==typeof e&&(e=x(e)),s(e),e}function R(...e){let t=0;for(let r=0;r<e.length;r++){const n=e[r];s(n),t+=n.length}const n=new Uint8Array(t);for(let r=0,o=0;r<e.length;r++){const t=e[r];n.set(t,o),o+=t.length}return n}class z{}function A(e){const t=t=>e().update(T(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function k(e=32){if(t&&"function"==typeof t.getRandomValues)return t.getRandomValues(new Uint8Array(e));if(t&&"function"==typeof t.randomBytes)return Uint8Array.from(t.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}function S(e,t,n){return e&t^e&n^t&n}class O extends z{constructor(e,t,n,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=l(this.buffer)}update(e){c(this),s(e=T(e));const{view:t,buffer:n,blockLen:r}=this,o=e.length;for(let i=0;i<o;){const s=Math.min(r-this.pos,o-i);if(s!==r)n.set(e.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===r&&(this.process(t,0),this.pos=0);else{const t=l(e);for(;r<=o-i;i+=r)this.process(t,i)}}return this.length+=e.length,this.roundClean(),this}digestInto(e){c(this),function(e,t){s(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:o}=this;let{pos:i}=this;t[i++]=128,u(this.buffer.subarray(i)),this.padOffset>r-i&&(this.process(n,0),i=0);for(let s=i;s<r;s++)t[s]=0;!function(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const o=BigInt(32),i=BigInt(4294967295),s=Number(n>>o&i),a=Number(n&i),c=r?4:0,u=r?0:4;e.setUint32(t+c,s,r),e.setUint32(t+u,a,r)}(n,r-8,BigInt(8*this.length),o),this.process(n,0);const a=l(e),f=this.outputLen;if(f%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const h=f/4,d=this.get();if(h>d.length)throw new Error("_sha2: outputLen bigger than state");for(let s=0;s<h;s++)a.setUint32(4*s,d[s],o)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:r,finished:o,destroyed:i,pos:s}=this;return e.destroyed=i,e.finished=o,e.length=r,e.pos=s,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}}const $=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);const I=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),_=new Uint32Array(64);class V extends O{constructor(e=32){super(64,e,8,!1),this.A=0|$[0],this.B=0|$[1],this.C=0|$[2],this.D=0|$[3],this.E=0|$[4],this.F=0|$[5],this.G=0|$[6],this.H=0|$[7]}get(){const{A:e,B:t,C:n,D:r,E:o,F:i,G:s,H:a}=this;return[e,t,n,r,o,i,s,a]}set(e,t,n,r,o,i,s,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|o,this.F=0|i,this.G=0|s,this.H=0|a}process(e,t){for(let f=0;f<16;f++,t+=4)_[f]=e.getUint32(t,!1);for(let h=16;h<64;h++){const e=_[h-15],t=_[h-2],n=f(e,7)^f(e,18)^e>>>3,r=f(t,17)^f(t,19)^t>>>10;_[h]=r+_[h-7]+n+_[h-16]|0}let{A:n,B:r,C:o,D:i,E:s,F:a,G:c,H:u}=this;for(let h=0;h<64;h++){const e=u+(f(s,6)^f(s,11)^f(s,25))+((l=s)&a^~l&c)+I[h]+_[h]|0,t=(f(n,2)^f(n,13)^f(n,22))+S(n,r,o)|0;u=c,c=a,a=s,s=i+e|0,i=o,o=r,r=n,n=e+t|0}var l;n=n+this.A|0,r=r+this.B|0,o=o+this.C|0,i=i+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(n,r,o,i,s,a,c,u)}roundClean(){u(_)}destroy(){this.set(0,0,0,0,0,0,0,0),u(this.buffer)}}const D=A((()=>new V));class N extends z{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,a(e);const n=T(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,o=new Uint8Array(r);o.set(n.length>r?e.create().update(n).digest():n);for(let i=0;i<o.length;i++)o[i]^=54;this.iHash.update(o),this.oHash=e.create();for(let i=0;i<o.length;i++)o[i]^=106;this.oHash.update(o),u(o)}update(e){return c(this),this.iHash.update(e),this}digestInto(e){c(this),s(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:r,destroyed:o,blockLen:i,outputLen:s}=this;return e.finished=r,e.destroyed=o,e.blockLen=i,e.outputLen=s,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const P=(e,t,n)=>new N(e,t).update(n).digest();P.create=(e,t)=>new N(e,t);const C=BigInt(0),F=BigInt(1);function G(e,t=""){if("boolean"!=typeof e){throw new Error((t&&`"${t}"`)+"expected boolean, got type="+typeof e)}return e}function M(e,t,n=""){const r=o(e),i=e?.length,s=void 0!==t;if(!r||s&&i!==t){throw new Error((n&&`"${n}" `)+"expected Uint8Array"+(s?` of length ${t}`:"")+", got "+(r?`length=${i}`:"type="+typeof e))}return e}function U(e){const t=e.toString(16);return 1&t.length?"0"+t:t}function L(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return""===e?C:BigInt("0x"+e)}function j(e){return L(p(e))}function Z(e){return s(e),L(p(Uint8Array.from(e).reverse()))}function q(e,t){return E(e.toString(16).padStart(2*t,"0"))}function H(e,t){return q(e,t).reverse()}function W(e,t,n){let r;if("string"==typeof t)try{r=E(t)}catch(s){throw new Error(e+" must be hex string or Uint8Array, cause: "+s)}else{if(!o(t))throw new Error(e+" must be hex string or Uint8Array");r=Uint8Array.from(t)}const i=r.length;if("number"==typeof n&&i!==n)throw new Error(e+" of length "+n+" expected, got "+i);return r}const J=e=>"bigint"==typeof e&&C<=e;function K(e,t,n,r){if(!function(e,t,n){return J(e)&&J(t)&&J(n)&&t<=e&&e<n}(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)}function X(e){let t;for(t=0;e>C;e>>=F,t+=1);return t}const Y=e=>(F<<BigInt(e))-F;function Q(e,t,n={}){if(!e||"object"!=typeof e)throw new Error("expected valid options object");function r(t,n,r){const o=e[t];if(r&&void 0===o)return;const i=typeof o;if(i!==n||null===o)throw new Error(`param "${t}" is invalid: expected ${n}, got ${i}`)}Object.entries(t).forEach((([e,t])=>r(e,t,!1))),Object.entries(n).forEach((([e,t])=>r(e,t,!0)))}function ee(e){const t=new WeakMap;return(n,...r)=>{const o=t.get(n);if(void 0!==o)return o;const i=e(n,...r);return t.set(n,i),i}}const te=BigInt(0),ne=BigInt(1),re=BigInt(2),oe=BigInt(3),ie=BigInt(4),se=BigInt(5),ae=BigInt(7),ce=BigInt(8),ue=BigInt(9),le=BigInt(16);function fe(e,t){const n=e%t;return n>=te?n:t+n}function he(e,t,n){let r=e;for(;t-- >te;)r*=r,r%=n;return r}function de(e,t){if(e===te)throw new Error("invert: expected non-zero number");if(t<=te)throw new Error("invert: expected positive modulus, got "+t);let n=fe(e,t),r=t,o=te,i=ne,s=ne,a=te;for(;n!==te;){const e=r/n,t=r%n,c=o-s*e,u=i-a*e;r=n,n=t,o=s,i=a,s=c,a=u}if(r!==ne)throw new Error("invert: does not exist");return fe(o,t)}function pe(e,t,n){if(!e.eql(e.sqr(t),n))throw new Error("Cannot find square root")}function me(e,t){const n=(e.ORDER+ne)/ie,r=e.pow(t,n);return pe(e,r,t),r}function ge(e,t){const n=(e.ORDER-se)/ce,r=e.mul(t,re),o=e.pow(r,n),i=e.mul(t,o),s=e.mul(e.mul(i,re),o),a=e.mul(i,e.sub(s,e.ONE));return pe(e,a,t),a}function ye(e){if(e<oe)throw new Error("sqrt is not defined for small field");let t=e-ne,n=0;for(;t%re===te;)t/=re,n++;let r=re;const o=Te(e);for(;1===Ee(o,r);)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===n)return me;let i=o.pow(r,t);const s=(t+ne)/re;return function(e,r){if(e.is0(r))return r;if(1!==Ee(e,r))throw new Error("Cannot find square root");let o=n,a=e.mul(e.ONE,i),c=e.pow(r,t),u=e.pow(r,s);for(;!e.eql(c,e.ONE);){if(e.is0(c))return e.ZERO;let t=1,n=e.sqr(c);for(;!e.eql(n,e.ONE);)if(t++,n=e.sqr(n),t===o)throw new Error("Cannot find square root");const r=ne<<BigInt(o-t-1),i=e.pow(a,r);o=t,a=e.sqr(i),c=e.mul(c,a),u=e.mul(u,i)}return u}}function we(e){return e%ie===oe?me:e%ce===se?ge:e%le===ue?function(e){const t=Te(e),n=ye(e),r=n(t,t.neg(t.ONE)),o=n(t,r),i=n(t,t.neg(r)),s=(e+ae)/le;return(e,t)=>{let n=e.pow(t,s),a=e.mul(n,r);const c=e.mul(n,o),u=e.mul(n,i),l=e.eql(e.sqr(a),t),f=e.eql(e.sqr(c),t);n=e.cmov(n,a,l),a=e.cmov(u,c,f);const h=e.eql(e.sqr(a),t),d=e.cmov(n,a,h);return pe(e,d,t),d}}(e):ye(e)}const be=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function ve(e,t,n){if(n<te)throw new Error("invalid exponent, negatives unsupported");if(n===te)return e.ONE;if(n===ne)return t;let r=e.ONE,o=t;for(;n>te;)n&ne&&(r=e.mul(r,o)),o=e.sqr(o),n>>=ne;return r}function Be(e,t,n=!1){const r=new Array(t.length).fill(n?e.ZERO:void 0),o=t.reduce(((t,n,o)=>e.is0(n)?t:(r[o]=t,e.mul(t,n))),e.ONE),i=e.inv(o);return t.reduceRight(((t,n,o)=>e.is0(n)?t:(r[o]=e.mul(t,r[o]),e.mul(t,n))),i),r}function Ee(e,t){const n=(e.ORDER-ne)/re,r=e.pow(t,n),o=e.eql(r,e.ONE),i=e.eql(r,e.ZERO),s=e.eql(r,e.neg(e.ONE));if(!o&&!i&&!s)throw new Error("invalid Legendre symbol result");return o?1:i?0:-1}function xe(e,t){void 0!==t&&i(t);const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function Te(e,t,n=!1,r={}){if(e<=te)throw new Error("invalid field: expected ORDER > 0, got "+e);let o,i,s,a=!1;if("object"==typeof t&&null!=t){if(r.sqrt||n)throw new Error("cannot specify opts in two arguments");const e=t;e.BITS&&(o=e.BITS),e.sqrt&&(i=e.sqrt),"boolean"==typeof e.isLE&&(n=e.isLE),"boolean"==typeof e.modFromBytes&&(a=e.modFromBytes),s=e.allowedLengths}else"number"==typeof t&&(o=t),r.sqrt&&(i=r.sqrt);const{nBitLength:c,nByteLength:u}=xe(e,o);if(u>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let l;const f=Object.freeze({ORDER:e,isLE:n,BITS:c,BYTES:u,MASK:Y(c),ZERO:te,ONE:ne,allowedLengths:s,create:t=>fe(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("invalid field element: expected bigint, got "+typeof t);return te<=t&&t<e},is0:e=>e===te,isValidNot0:e=>!f.is0(e)&&f.isValid(e),isOdd:e=>(e&ne)===ne,neg:t=>fe(-t,e),eql:(e,t)=>e===t,sqr:t=>fe(t*t,e),add:(t,n)=>fe(t+n,e),sub:(t,n)=>fe(t-n,e),mul:(t,n)=>fe(t*n,e),pow:(e,t)=>ve(f,e,t),div:(t,n)=>fe(t*de(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>de(t,e),sqrt:i||(t=>(l||(l=we(e)),l(f,t))),toBytes:e=>n?H(e,u):q(e,u),fromBytes:(t,r=!0)=>{if(s){if(!s.includes(t.length)||t.length>u)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+t.length);const e=new Uint8Array(u);e.set(t,n?0:e.length-t.length),t=e}if(t.length!==u)throw new Error("Field.fromBytes: expected "+u+" bytes, got "+t.length);let o=n?Z(t):j(t);if(a&&(o=fe(o,e)),!r&&!f.isValid(o))throw new Error("invalid field element: outside of range 0..ORDER");return o},invertBatch:e=>Be(f,e),cmov:(e,t,n)=>n?t:e});return Object.freeze(f)}function Re(e){if("bigint"!=typeof e)throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function ze(e){const t=Re(e);return t+Math.ceil(t/2)}const Ae=BigInt(0),ke=BigInt(1);function Se(e,t){const n=t.negate();return e?n:t}function Oe(e,t){const n=Be(e.Fp,t.map((e=>e.Z)));return t.map(((t,r)=>e.fromAffine(t.toAffine(n[r]))))}function $e(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function Ie(e,t){$e(e,t);const n=2**e;return{windows:Math.ceil(t/e)+1,windowSize:2**(e-1),mask:Y(e),maxNumber:n,shiftBy:BigInt(e)}}function _e(e,t,n){const{windowSize:r,mask:o,maxNumber:i,shiftBy:s}=n;let a=Number(e&o),c=e>>s;a>r&&(a-=i,c+=ke);const u=t*r;return{nextN:c,offset:u+Math.abs(a)-1,isZero:0===a,isNeg:a<0,isNegF:t%2!=0,offsetF:u}}function Ve(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach(((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)}))}function De(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach(((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)}))}const Ne=new WeakMap,Pe=new WeakMap;function Ce(e){return Pe.get(e)||1}function Fe(e){if(e!==Ae)throw new Error("invalid wNAF")}class Ge{constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,n=this.ZERO){let r=e;for(;t>Ae;)t&ke&&(n=n.add(r)),r=r.double(),t>>=ke;return n}precomputeWindow(e,t){const{windows:n,windowSize:r}=Ie(t,this.bits),o=[];let i=e,s=i;for(let a=0;a<n;a++){s=i,o.push(s);for(let e=1;e<r;e++)s=s.add(i),o.push(s);i=s.double()}return o}wNAF(e,t,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let r=this.ZERO,o=this.BASE;const i=Ie(e,this.bits);for(let s=0;s<i.windows;s++){const{nextN:e,offset:a,isZero:c,isNeg:u,isNegF:l,offsetF:f}=_e(n,s,i);n=e,c?o=o.add(Se(l,t[f])):r=r.add(Se(u,t[a]))}return Fe(n),{p:r,f:o}}wNAFUnsafe(e,t,n,r=this.ZERO){const o=Ie(e,this.bits);for(let i=0;i<o.windows&&n!==Ae;i++){const{nextN:e,offset:s,isZero:a,isNeg:c}=_e(n,i,o);if(n=e,!a){const e=t[s];r=r.add(c?e.negate():e)}}return Fe(n),r}getPrecomputes(e,t,n){let r=Ne.get(t);return r||(r=this.precomputeWindow(t,e),1!==e&&("function"==typeof n&&(r=n(r)),Ne.set(t,r))),r}cached(e,t,n){const r=Ce(e);return this.wNAF(r,this.getPrecomputes(r,e,n),t)}unsafe(e,t,n,r){const o=Ce(e);return 1===o?this._unsafeLadder(e,t,r):this.wNAFUnsafe(o,this.getPrecomputes(o,e,n),t,r)}createCache(e,t){$e(t,this.bits),Pe.set(e,t),Ne.delete(e)}hasCache(e){return 1!==Ce(e)}}function Me(e,t,n){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return function(e){const t=be.reduce(((e,t)=>(e[t]="function",e)),{ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"});Q(e,t)}(t),t}return Te(e,{isLE:n})}const Ue=(e,t)=>(e+(e>=0?t:-t)/Je)/t;function Le(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function je(e,t){const n={};for(let r of Object.keys(t))n[r]=void 0===e[r]?t[r]:e[r];return G(n.lowS,"lowS"),G(n.prehash,"prehash"),void 0!==n.format&&Le(n.format),n}class Ze extends Error{constructor(e=""){super(e)}}const qe={Err:Ze,_tlv:{encode:(e,t)=>{const{Err:n}=qe;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(1&t.length)throw new n("tlv.encode: unpadded data");const r=t.length/2,o=U(r);if(o.length/2&128)throw new n("tlv.encode: long form length too big");const i=r>127?U(o.length/2|128):"";return U(e)+i+o+t},decode(e,t){const{Err:n}=qe;let r=0;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length<2||t[r++]!==e)throw new n("tlv.decode: wrong tlv");const o=t[r++];let i=0;if(!!(128&o)){const e=127&o;if(!e)throw new n("tlv.decode(long): indefinite length not supported");if(e>4)throw new n("tlv.decode(long): byte length is too big");const s=t.subarray(r,r+e);if(s.length!==e)throw new n("tlv.decode: length bytes not complete");if(0===s[0])throw new n("tlv.decode(long): zero leftmost byte");for(const t of s)i=i<<8|t;if(r+=e,i<128)throw new n("tlv.decode(long): not minimal encoding")}else i=o;const s=t.subarray(r,r+i);if(s.length!==i)throw new n("tlv.decode: wrong value length");return{v:s,l:t.subarray(r+i)}}},_int:{encode(e){const{Err:t}=qe;if(e<He)throw new t("integer: negative integers are not allowed");let n=U(e);if(8&Number.parseInt(n[0],16)&&(n="00"+n),1&n.length)throw new t("unexpected DER parsing assertion: unpadded hex");return n},decode(e){const{Err:t}=qe;if(128&e[0])throw new t("invalid signature integer: negative");if(0===e[0]&&!(128&e[1]))throw new t("invalid signature integer: unnecessary leading zero");return j(e)}},toSig(e){const{Err:t,_int:n,_tlv:r}=qe,o=W("signature",e),{v:i,l:s}=r.decode(48,o);if(s.length)throw new t("invalid signature: left bytes after parsing");const{v:a,l:c}=r.decode(2,i),{v:u,l:l}=r.decode(2,c);if(l.length)throw new t("invalid signature: left bytes after parsing");return{r:n.decode(a),s:n.decode(u)}},hexFromSig(e){const{_tlv:t,_int:n}=qe,r=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,r)}},He=BigInt(0),We=BigInt(1),Je=BigInt(2),Ke=BigInt(3),Xe=BigInt(4);function Ye(e,t){const{BYTES:n}=e;let r;if("bigint"==typeof t)r=t;else{let i=W("private key",t);try{r=e.fromBytes(i)}catch(o){throw new Error(`invalid private key: expected ui8a of size ${n}, got ${typeof t}`)}}if(!e.isValidNot0(r))throw new Error("invalid private key: out of range [1..N-1]");return r}function Qe(e,t={}){const n=function(e,t,n={},r){if(void 0===r&&(r="edwards"===e),!t||"object"!=typeof t)throw new Error(`expected valid ${e} CURVE object`);for(const a of["p","n","h"]){const e=t[a];if(!("bigint"==typeof e&&e>Ae))throw new Error(`CURVE.${a} must be positive bigint`)}const o=Me(t.p,n.Fp,r),i=Me(t.n,n.Fn,r),s=["Gx","Gy","a","weierstrass"===e?"b":"d"];for(const a of s)if(!o.isValid(t[a]))throw new Error(`CURVE.${a} must be valid field element of CURVE.Fp`);return{CURVE:t=Object.freeze(Object.assign({},t)),Fp:o,Fn:i}}("weierstrass",e,t),{Fp:r,Fn:o}=n;let i=n.CURVE;const{h:s,n:a}=i;Q(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:c}=t;if(c&&(!r.is0(i.a)||"bigint"!=typeof c.beta||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const u=tt(r,o);function l(){if(!r.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}const f=t.toBytes||function(e,t,n){const{x:o,y:i}=t.toAffine(),s=r.toBytes(o);if(G(n,"isCompressed"),n){l();return R(et(!r.isOdd(i)),s)}return R(Uint8Array.of(4),s,r.toBytes(i))},h=t.fromBytes||function(e){M(e,void 0,"Point");const{publicKey:t,publicKeyUncompressed:n}=u,o=e.length,i=e[0],s=e.subarray(1);if(o!==t||2!==i&&3!==i){if(o===n&&4===i){const e=r.BYTES,t=r.fromBytes(s.subarray(0,e)),n=r.fromBytes(s.subarray(e,2*e));if(!m(t,n))throw new Error("bad point: is not on curve");return{x:t,y:n}}throw new Error(`bad point: got length ${o}, expected compressed=${t} or uncompressed=${n}`)}{const e=r.fromBytes(s);if(!r.isValid(e))throw new Error("bad point: is not on curve, wrong x");const t=d(e);let n;try{n=r.sqrt(t)}catch(a){const e=a instanceof Error?": "+a.message:"";throw new Error("bad point: is not on curve, sqrt error"+e)}l();return!(1&~i)!==r.isOdd(n)&&(n=r.neg(n)),{x:e,y:n}}};function d(e){const t=r.sqr(e),n=r.mul(t,e);return r.add(r.add(n,r.mul(e,i.a)),i.b)}function m(e,t){const n=r.sqr(t),o=d(e);return r.eql(n,o)}if(!m(i.Gx,i.Gy))throw new Error("bad curve params: generator point");const g=r.mul(r.pow(i.a,Ke),Xe),y=r.mul(r.sqr(i.b),BigInt(27));if(r.is0(r.add(g,y)))throw new Error("bad curve params: a or b");function w(e,t,n=!1){if(!r.isValid(t)||n&&r.is0(t))throw new Error(`bad point coordinate ${e}`);return t}function b(e){if(!(e instanceof T))throw new Error("ProjectivePoint expected")}function v(e){if(!c||!c.basises)throw new Error("no endo");return function(e,t,n){const[[r,o],[i,s]]=t,a=Ue(s*e,n),c=Ue(-o*e,n);let u=e-a*r-c*i,l=-a*o-c*s;const f=u<He,h=l<He;f&&(u=-u),h&&(l=-l);const d=Y(Math.ceil(X(n)/2))+We;if(u<He||u>=d||l<He||l>=d)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:f,k1:u,k2neg:h,k2:l}}(e,c.basises,o.ORDER)}const B=ee(((e,t)=>{const{X:n,Y:o,Z:i}=e;if(r.eql(i,r.ONE))return{x:n,y:o};const s=e.is0();null==t&&(t=s?r.ONE:r.inv(i));const a=r.mul(n,t),c=r.mul(o,t),u=r.mul(i,t);if(s)return{x:r.ZERO,y:r.ZERO};if(!r.eql(u,r.ONE))throw new Error("invZ was invalid");return{x:a,y:c}})),E=ee((e=>{if(e.is0()){if(t.allowInfinityPoint&&!r.is0(e.Y))return;throw new Error("bad point: ZERO")}const{x:n,y:o}=e.toAffine();if(!r.isValid(n)||!r.isValid(o))throw new Error("bad point: x or y not field elements");if(!m(n,o))throw new Error("bad point: equation left != right");if(!e.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0}));function x(e,t,n,o,i){return n=new T(r.mul(n.X,e),n.Y,n.Z),t=Se(o,t),n=Se(i,n),t.add(n)}class T{constructor(e,t,n){this.X=w("x",e),this.Y=w("y",t,!0),this.Z=w("z",n),Object.freeze(this)}static CURVE(){return i}static fromAffine(e){const{x:t,y:n}=e||{};if(!e||!r.isValid(t)||!r.isValid(n))throw new Error("invalid affine point");if(e instanceof T)throw new Error("projective point not allowed");return r.is0(t)&&r.is0(n)?T.ZERO:new T(t,n,r.ONE)}static fromBytes(e){const t=T.fromAffine(h(M(e,void 0,"point")));return t.assertValidity(),t}static fromHex(e){return T.fromBytes(W("pointHex",e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=8,t=!0){return A.createCache(this,e),t||this.multiply(Ke),this}assertValidity(){E(this)}hasEvenY(){const{y:e}=this.toAffine();if(!r.isOdd)throw new Error("Field doesn't support isOdd");return!r.isOdd(e)}equals(e){b(e);const{X:t,Y:n,Z:o}=this,{X:i,Y:s,Z:a}=e,c=r.eql(r.mul(t,a),r.mul(i,o)),u=r.eql(r.mul(n,a),r.mul(s,o));return c&&u}negate(){return new T(this.X,r.neg(this.Y),this.Z)}double(){const{a:e,b:t}=i,n=r.mul(t,Ke),{X:o,Y:s,Z:a}=this;let c=r.ZERO,u=r.ZERO,l=r.ZERO,f=r.mul(o,o),h=r.mul(s,s),d=r.mul(a,a),p=r.mul(o,s);return p=r.add(p,p),l=r.mul(o,a),l=r.add(l,l),c=r.mul(e,l),u=r.mul(n,d),u=r.add(c,u),c=r.sub(h,u),u=r.add(h,u),u=r.mul(c,u),c=r.mul(p,c),l=r.mul(n,l),d=r.mul(e,d),p=r.sub(f,d),p=r.mul(e,p),p=r.add(p,l),l=r.add(f,f),f=r.add(l,f),f=r.add(f,d),f=r.mul(f,p),u=r.add(u,f),d=r.mul(s,a),d=r.add(d,d),f=r.mul(d,p),c=r.sub(c,f),l=r.mul(d,h),l=r.add(l,l),l=r.add(l,l),new T(c,u,l)}add(e){b(e);const{X:t,Y:n,Z:o}=this,{X:s,Y:a,Z:c}=e;let u=r.ZERO,l=r.ZERO,f=r.ZERO;const h=i.a,d=r.mul(i.b,Ke);let p=r.mul(t,s),m=r.mul(n,a),g=r.mul(o,c),y=r.add(t,n),w=r.add(s,a);y=r.mul(y,w),w=r.add(p,m),y=r.sub(y,w),w=r.add(t,o);let v=r.add(s,c);return w=r.mul(w,v),v=r.add(p,g),w=r.sub(w,v),v=r.add(n,o),u=r.add(a,c),v=r.mul(v,u),u=r.add(m,g),v=r.sub(v,u),f=r.mul(h,w),u=r.mul(d,g),f=r.add(u,f),u=r.sub(m,f),f=r.add(m,f),l=r.mul(u,f),m=r.add(p,p),m=r.add(m,p),g=r.mul(h,g),w=r.mul(d,w),m=r.add(m,g),g=r.sub(p,g),g=r.mul(h,g),w=r.add(w,g),p=r.mul(m,w),l=r.add(l,p),p=r.mul(v,w),u=r.mul(y,u),u=r.sub(u,p),p=r.mul(y,m),f=r.mul(v,f),f=r.add(f,p),new T(u,l,f)}subtract(e){return this.add(e.negate())}is0(){return this.equals(T.ZERO)}multiply(e){const{endo:n}=t;if(!o.isValidNot0(e))throw new Error("invalid scalar: out of range");let r,i;const s=e=>A.cached(this,e,(e=>Oe(T,e)));if(n){const{k1neg:t,k1:o,k2neg:a,k2:c}=v(e),{p:u,f:l}=s(o),{p:f,f:h}=s(c);i=l.add(h),r=x(n.beta,u,f,t,a)}else{const{p:t,f:n}=s(e);r=t,i=n}return Oe(T,[r,i])[0]}multiplyUnsafe(e){const{endo:n}=t,r=this;if(!o.isValid(e))throw new Error("invalid scalar: out of range");if(e===He||r.is0())return T.ZERO;if(e===We)return r;if(A.hasCache(this))return this.multiply(e);if(n){const{k1neg:t,k1:o,k2neg:i,k2:s}=v(e),{p1:a,p2:c}=function(e,t,n,r){let o=t,i=e.ZERO,s=e.ZERO;for(;n>Ae||r>Ae;)n&ke&&(i=i.add(o)),r&ke&&(s=s.add(o)),o=o.double(),n>>=ke,r>>=ke;return{p1:i,p2:s}}(T,r,o,s);return x(n.beta,a,c,t,i)}return A.unsafe(r,e)}multiplyAndAddUnsafe(e,t,n){const r=this.multiplyUnsafe(t).add(e.multiplyUnsafe(n));return r.is0()?void 0:r}toAffine(e){return B(this,e)}isTorsionFree(){const{isTorsionFree:e}=t;return s===We||(e?e(T,this):A.unsafe(this,a).is0())}clearCofactor(){const{clearCofactor:e}=t;return s===We?this:e?e(T,this):this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(e=!0){return G(e,"isCompressed"),this.assertValidity(),f(T,this,e)}toHex(e=!0){return p(this.toBytes(e))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(e=!0){return this.toBytes(e)}_setWindowSize(e){this.precompute(e)}static normalizeZ(e){return Oe(T,e)}static msm(e,t){return function(e,t,n,r){Ve(n,e),De(r,t);const o=n.length,i=r.length;if(o!==i)throw new Error("arrays of points and scalars must have equal length");const s=e.ZERO,a=X(BigInt(o));let c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);const u=Y(c),l=new Array(Number(u)+1).fill(s);let f=s;for(let h=Math.floor((t.BITS-1)/c)*c;h>=0;h-=c){l.fill(s);for(let t=0;t<i;t++){const e=r[t],o=Number(e>>BigInt(h)&u);l[o]=l[o].add(n[t])}let e=s;for(let t=l.length-1,n=s;t>0;t--)n=n.add(l[t]),e=e.add(n);if(f=f.add(e),0!==h)for(let t=0;t<c;t++)f=f.double()}return f}(T,o,e,t)}static fromPrivateKey(e){return T.BASE.multiply(Ye(o,e))}}T.BASE=new T(i.Gx,i.Gy,r.ONE),T.ZERO=new T(r.ZERO,r.ONE,r.ZERO),T.Fp=r,T.Fn=o;const z=o.BITS,A=new Ge(T,t.endo?Math.ceil(z/2):z);return T.BASE.precompute(8),T}function et(e){return Uint8Array.of(e?2:3)}function tt(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function nt(e,t={}){const{Fn:n}=e,r=t.randomBytes||k,o=Object.assign(tt(e.Fp,n),{seed:ze(n.ORDER)});function i(e){try{return!!Ye(n,e)}catch(t){return!1}}function s(e=r(o.seed)){return function(e,t,n=!1){const r=e.length,o=Re(t),i=ze(t);if(r<16||r<i||r>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+r);const s=fe(n?Z(e):j(e),t-ne)+ne;return n?H(s,o):q(s,o)}(M(e,o.seed,"seed"),n.ORDER)}function a(t,r=!0){return e.BASE.multiply(Ye(n,t)).toBytes(r)}function c(t){if("bigint"==typeof t)return!1;if(t instanceof e)return!0;const{secretKey:r,publicKey:i,publicKeyUncompressed:s}=o;if(n.allowedLengths||r===i)return;const a=W("key",t).length;return a===i||a===s}const u={isValidSecretKey:i,isValidPublicKey:function(t,n){const{publicKey:r,publicKeyUncompressed:i}=o;try{const o=t.length;return(!0!==n||o===r)&&((!1!==n||o===i)&&!!e.fromBytes(t))}catch(s){return!1}},randomSecretKey:s,isValidPrivateKey:i,randomPrivateKey:s,normPrivateKeyToScalar:e=>Ye(n,e),precompute:(t=8,n=e.BASE)=>n.precompute(t,!1)};return Object.freeze({getPublicKey:a,getSharedSecret:function(t,r,o=!0){if(!0===c(t))throw new Error("first arg must be private key");if(!1===c(r))throw new Error("second arg must be public key");const i=Ye(n,t);return e.fromHex(r).multiply(i).toBytes(o)},keygen:function(e){const t=s(e);return{secretKey:t,publicKey:a(t)}},Point:e,utils:u,lengths:o})}function rt(e,t,n={}){a(t),Q(n,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const r=n.randomBytes||k,i=n.hmac||((e,...n)=>P(t,e,R(...n))),{Fp:s,Fn:c}=e,{ORDER:u,BITS:l}=c,{keygen:f,getPublicKey:h,getSharedSecret:d,utils:m,lengths:g}=nt(e,n),y={prehash:!1,lowS:"boolean"==typeof n.lowS&&n.lowS,format:void 0,extraEntropy:!1},w="compact";function b(e){return e>u>>We}function v(e,t){if(!c.isValidNot0(t))throw new Error(`invalid signature ${e}: out of range 1..Point.Fn.ORDER`);return t}class B{constructor(e,t,n){this.r=v("r",e),this.s=v("s",t),null!=n&&(this.recovery=n),Object.freeze(this)}static fromBytes(e,t=w){let n;if(function(e,t){Le(t);const n=g.signature;M(e,"compact"===t?n:"recovered"===t?n+1:void 0,`${t} signature`)}(e,t),"der"===t){const{r:t,s:n}=qe.toSig(M(e));return new B(t,n)}"recovered"===t&&(n=e[0],t="compact",e=e.subarray(1));const r=c.BYTES,o=e.subarray(0,r),i=e.subarray(r,2*r);return new B(c.fromBytes(o),c.fromBytes(i),n)}static fromHex(e,t){return this.fromBytes(E(e),t)}addRecoveryBit(e){return new B(this.r,this.s,e)}recoverPublicKey(t){const n=s.ORDER,{r:r,s:o,recovery:i}=this;if(null==i||![0,1,2,3].includes(i))throw new Error("recovery id invalid");if(u*Je<n&&i>1)throw new Error("recovery id is ambiguous for h>1 curve");const a=2===i||3===i?r+u:r;if(!s.isValid(a))throw new Error("recovery id 2 or 3 invalid");const l=s.toBytes(a),f=e.fromBytes(R(et(!(1&i)),l)),h=c.inv(a),d=T(W("msgHash",t)),p=c.create(-d*h),m=c.create(o*h),g=e.BASE.multiplyUnsafe(p).add(f.multiplyUnsafe(m));if(g.is0())throw new Error("point at infinify");return g.assertValidity(),g}hasHighS(){return b(this.s)}toBytes(e=w){if(Le(e),"der"===e)return E(qe.hexFromSig(this));const t=c.toBytes(this.r),n=c.toBytes(this.s);if("recovered"===e){if(null==this.recovery)throw new Error("recovery bit must be present");return R(Uint8Array.of(this.recovery),t,n)}return R(t,n)}toHex(e){return p(this.toBytes(e))}assertValidity(){}static fromCompact(e){return B.fromBytes(W("sig",e),"compact")}static fromDER(e){return B.fromBytes(W("sig",e),"der")}normalizeS(){return this.hasHighS()?new B(this.r,c.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return p(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return p(this.toBytes("compact"))}}const x=n.bits2int||function(e){if(e.length>8192)throw new Error("input is too large");const t=j(e),n=8*e.length-l;return n>0?t>>BigInt(n):t},T=n.bits2int_modN||function(e){return c.create(x(e))},z=Y(l);function A(e){return K("num < 2^"+l,e,He,z),c.toBytes(e)}function S(e,n){return M(e,void 0,"message"),n?M(t(e),void 0,"prehashed message"):e}return Object.freeze({keygen:f,getPublicKey:h,getSharedSecret:d,utils:m,lengths:g,Point:e,sign:function(n,o,s={}){n=W("message",n);const{seed:a,k2sig:u}=function(t,n,o){if(["recovered","canonical"].some((e=>e in o)))throw new Error("sign() legacy options not supported");const{lowS:i,prehash:s,extraEntropy:a}=je(o,y);t=S(t,s);const u=T(t),l=Ye(c,n),f=[A(l),A(u)];if(null!=a&&!1!==a){const e=!0===a?r(g.secretKey):a;f.push(W("extraEntropy",e))}const h=R(...f),d=u;return{seed:h,k2sig:function(t){const n=x(t);if(!c.isValidNot0(n))return;const r=c.inv(n),o=e.BASE.multiply(n).toAffine(),s=c.create(o.x);if(s===He)return;const a=c.create(r*c.create(d+s*l));if(a===He)return;let u=(o.x===s?0:2)|Number(o.y&We),f=a;return i&&b(a)&&(f=c.neg(a),u^=1),new B(s,f,u)}}}(n,o,s);return function(e,t,n){if("number"!=typeof e||e<2)throw new Error("hashLen must be a number");if("number"!=typeof t||t<2)throw new Error("qByteLen must be a number");if("function"!=typeof n)throw new Error("hmacFn must be a function");const r=e=>new Uint8Array(e),o=e=>Uint8Array.of(e);let i=r(e),s=r(e),a=0;const c=()=>{i.fill(1),s.fill(0),a=0},u=(...e)=>n(s,i,...e),l=(e=r(0))=>{s=u(o(0),e),i=u(),0!==e.length&&(s=u(o(1),e),i=u())},f=()=>{if(a++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const n=[];for(;e<t;){i=u();const t=i.slice();n.push(t),e+=i.length}return R(...n)};return(e,t)=>{let n;for(c(),l(e);!(n=t(f()));)l();return c(),n}}(t.outputLen,c.BYTES,i)(a,u)},verify:function(t,n,r,i={}){const{lowS:s,prehash:a,format:u}=je(i,y);if(r=W("publicKey",r),n=S(W("message",n),a),"strict"in i)throw new Error("options.strict was renamed to lowS");const l=void 0===u?function(e){let t;const n="string"==typeof e||o(e),r=!n&&null!==e&&"object"==typeof e&&"bigint"==typeof e.r&&"bigint"==typeof e.s;if(!n&&!r)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(r)t=new B(e.r,e.s);else if(n){try{t=B.fromBytes(W("sig",e),"der")}catch(i){if(!(i instanceof qe.Err))throw i}if(!t)try{t=B.fromBytes(W("sig",e),"compact")}catch(s){return!1}}return t||!1}(t):B.fromBytes(W("sig",t),u);if(!1===l)return!1;try{const t=e.fromBytes(r);if(s&&l.hasHighS())return!1;const{r:o,s:i}=l,a=T(n),u=c.inv(i),f=c.create(a*u),h=c.create(o*u),d=e.BASE.multiplyUnsafe(f).add(t.multiplyUnsafe(h));if(d.is0())return!1;return c.create(d.x)===o}catch(f){return!1}},recoverPublicKey:function(e,t,n={}){const{prehash:r}=je(n,y);return t=S(t,r),B.fromBytes(e,"recovered").recoverPublicKey(t).toBytes()},Signature:B,hash:t})}function ot(e){const t={a:e.a,b:e.b,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},n=e.Fp;let r=e.allowedPrivateKeyLengths?Array.from(new Set(e.allowedPrivateKeyLengths.map((e=>Math.ceil(e/2))))):void 0;return{CURVE:t,curveOpts:{Fp:n,Fn:Te(t.n,{BITS:e.nBitLength,allowedLengths:r,modFromBytes:e.wrapPrivateKey}),allowInfinityPoint:e.allowInfinityPoint,endo:e.endo,isTorsionFree:e.isTorsionFree,clearCofactor:e.clearCofactor,fromBytes:e.fromBytes,toBytes:e.toBytes}}}function it(e){const{CURVE:t,curveOpts:n,hash:r,ecdsaOpts:o}=function(e){const{CURVE:t,curveOpts:n}=ot(e),r={hmac:e.hmac,randomBytes:e.randomBytes,lowS:e.lowS,bits2int:e.bits2int,bits2int_modN:e.bits2int_modN};return{CURVE:t,curveOpts:n,hash:e.hash,ecdsaOpts:r}}(e);return function(e,t){const n=t.Point;return Object.assign({},t,{ProjectivePoint:n,CURVE:Object.assign({},e,xe(n.Fn.ORDER,n.Fn.BITS))})}(e,rt(Qe(t,n),r,o))}const st={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},at={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},ct=BigInt(2);const ut=Te(st.p,{sqrt:function(e){const t=st.p,n=BigInt(3),r=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),u=e*e*e%t,l=u*u*e%t,f=he(l,n,t)*l%t,h=he(f,n,t)*l%t,d=he(h,ct,t)*u%t,p=he(d,o,t)*d%t,m=he(p,i,t)*p%t,g=he(m,a,t)*m%t,y=he(g,c,t)*g%t,w=he(y,a,t)*m%t,b=he(w,n,t)*l%t,v=he(b,s,t)*p%t,B=he(v,r,t)*u%t,E=he(B,ct,t);if(!ut.eql(ut.sqr(E),e))throw new Error("Cannot find square root");return E}}),lt=function(e,t){const n=t=>it({...e,hash:t});return{...n(t),create:n}}({...st,Fp:ut,lowS:!0,endo:at},D);function ft(e,t){const n=[];for(let r=0;r<e.length;r+=t)n.push(e.subarray(r,r+t));return n}function ht(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function dt(e,t){const n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e[r]!==t[r])return e.subarray(0,r);return e.subarray(0,n)}function pt(e){return Array.from(e).map((e=>e.toString(16).padStart(2,"0"))).join("")}function mt(e,t){const n=new Uint8Array(32);let r=e;if("LE"===t){for(let e=0;e<32;e++)n[e]=Number(0xffn&r),r>>=8n;return n}for(let o=31;o>=0;o--)n[o]=Number(0xffn&r),r>>=8n;return n}function gt(e,t){let n=0n;if("LE"===t){for(let t=31;t>=0;t--)n=n<<8n|BigInt(e[t]);return n}for(let r=0;r<32;r++)n=n<<8n|BigInt(e[r]);return n}function yt(e){const t=e.startsWith("0x")||e.startsWith("0X")?e.slice(2):e;if(t.length%2!=0||!/^[0-9a-fA-F]*$/.test(t))throw new Error(`hexToUint8Array: invalid hex string: ${e}`);const n=new Uint8Array(t.length/2);for(let r=0;r<n.length;r++)n[r]=parseInt(t.slice(2*r,2*r+2),16);return n}var wt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bt="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function vt(e,t){const n=t.length;let r=0,o=0;const i=[];for(let s=0;s<e.length;s++){const a=e.charAt(s);if("="===a)break;const c=t.indexOf(a);if(-1===c)throw new Error(`Invalid character: ${a}`);o=o<<Math.log2(n)|c,r+=Math.log2(n),r>=8&&(r-=8,i.push(o>>r&255))}return new Uint8Array(i)}function Bt(e,t,n){const r=t.length;let o=0,i=0,s="";for(const a of e)for(i=i<<8|a,o+=8;o>=Math.log2(r);)o-=Math.log2(r),s+=t.charAt(i>>o&r-1);return o>0&&(s+=t.charAt(i<<Math.log2(r)-o&r-1)),s.length%n!=0&&(s+="=".repeat(n-s.length%n)),s}function Et(e){return Bt(e,bt,8)}function xt(e){return new Uint8Array([e])}function Tt(e){return e[0]}function Rt(e,t){return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint16(0,"LE"===t)}function zt(e,t){const n=new ArrayBuffer(4);return new DataView(n).setUint32(0,e,"LE"===t),new Uint8Array(n)}function At(e,t){const n=new ArrayBuffer(8);return new DataView(n).setBigUint64(0,e,"LE"===t),new Uint8Array(n)}function kt(e,t){return new DataView(e.buffer,e.byteOffset,e.byteLength).getBigUint64(0,"LE"===t)}var St=[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 Ot(e){return t=function(e,t){for(const n of t){for(let t=0;t<34;t+=2)e[t]=e[t]^n[t+1],e[t+1]=e[t+1]^n[t];$t(e)}return e}(new Array(50).fill(0),function(e,t){if(!e.length){const e=new Uint8Array(136);return e[0]=t,e[135]=128,[It(e)]}const n=ft(e,136),r=n[n.length-1];if(r.length<136){const e=new Uint8Array(136);e.set(r),e[r.length]=t,e[135]=128|e[135],n[n.length-1]=e}if(136===r.length){const e=new Uint8Array(136);e[0]=t,e[135]=128,n.push(e)}return n.map(It)}(e,1)),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]);var t}function $t(e){for(let t=0;t<24;t++){const n=e[0]^e[10]^e[20]^e[30]^e[40],r=e[1]^e[11]^e[21]^e[31]^e[41],o=e[2]^e[12]^e[22]^e[32]^e[42],i=e[3]^e[13]^e[23]^e[33]^e[43],s=e[4]^e[14]^e[24]^e[34]^e[44],a=e[5]^e[15]^e[25]^e[35]^e[45],c=e[6]^e[16]^e[26]^e[36]^e[46],u=e[7]^e[17]^e[27]^e[37]^e[47],l=e[8]^e[18]^e[28]^e[38]^e[48],f=e[9]^e[19]^e[29]^e[39]^e[49],h=l^(o<<1|i>>>31),d=f^(i<<1|o>>>31),p=n^(s<<1|a>>>31),m=r^(a<<1|s>>>31),g=o^(c<<1|u>>>31),y=i^(u<<1|c>>>31),w=s^(l<<1|f>>>31),b=a^(f<<1|l>>>31),v=c^(n<<1|r>>>31),B=u^(r<<1|n>>>31);e[0]^=h,e[1]^=d,e[2]^=p,e[3]^=m,e[4]^=g,e[5]^=y,e[6]^=w,e[7]^=b,e[8]^=v,e[9]^=B,e[10]^=h,e[11]^=d,e[12]^=p,e[13]^=m,e[14]^=g,e[15]^=y,e[16]^=w,e[17]^=b,e[18]^=v,e[19]^=B,e[20]^=h,e[21]^=d,e[22]^=p,e[23]^=m,e[24]^=g,e[25]^=y,e[26]^=w,e[27]^=b,e[28]^=v,e[29]^=B,e[30]^=h,e[31]^=d,e[32]^=p,e[33]^=m,e[34]^=g,e[35]^=y,e[36]^=w,e[37]^=b,e[38]^=v,e[39]^=B,e[40]^=h,e[41]^=d,e[42]^=p,e[43]^=m,e[44]^=g,e[45]^=y,e[46]^=w,e[47]^=b,e[48]^=v,e[49]^=B;const E=e[0],x=e[1],T=e[2]<<1|e[3]>>>31,R=e[3]<<1|e[2]>>>31,z=e[5]<<30|e[4]>>>2,A=e[4]<<30|e[5]>>>2,k=e[6]<<28|e[7]>>>4,S=e[7]<<28|e[6]>>>4,O=e[8]<<27|e[9]>>>5,$=e[9]<<27|e[8]>>>5,I=e[11]<<4|e[10]>>>28,_=e[10]<<4|e[11]>>>28,V=e[13]<<12|e[12]>>>20,D=e[12]<<12|e[13]>>>20,N=e[14]<<6|e[15]>>>26,P=e[15]<<6|e[14]>>>26,C=e[17]<<23|e[16]>>>9,F=e[16]<<23|e[17]>>>9,G=e[18]<<20|e[19]>>>12,M=e[19]<<20|e[18]>>>12,U=e[20]<<3|e[21]>>>29,L=e[21]<<3|e[20]>>>29,j=e[22]<<10|e[23]>>>22,Z=e[23]<<10|e[22]>>>22,q=e[25]<<11|e[24]>>>21,H=e[24]<<11|e[25]>>>21,W=e[26]<<25|e[27]>>>7,J=e[27]<<25|e[26]>>>7,K=e[29]<<7|e[28]>>>25,X=e[28]<<7|e[29]>>>25,Y=e[31]<<9|e[30]>>>23,Q=e[30]<<9|e[31]>>>23,ee=e[33]<<13|e[32]>>>19,te=e[32]<<13|e[33]>>>19,ne=e[34]<<15|e[35]>>>17,re=e[35]<<15|e[34]>>>17,oe=e[36]<<21|e[37]>>>11,ie=e[37]<<21|e[36]>>>11,se=e[38]<<8|e[39]>>>24,ae=e[39]<<8|e[38]>>>24,ce=e[40]<<18|e[41]>>>14,ue=e[41]<<18|e[40]>>>14,le=e[42]<<2|e[43]>>>30,fe=e[43]<<2|e[42]>>>30,he=e[45]<<29|e[44]>>>3,de=e[44]<<29|e[45]>>>3,pe=e[47]<<24|e[46]>>>8,me=e[46]<<24|e[47]>>>8,ge=e[48]<<14|e[49]>>>18,ye=e[49]<<14|e[48]>>>18;e[0]=E^~V&q,e[1]=x^~D&H,e[2]=V^~q&oe,e[3]=D^~H&ie,e[4]=q^~oe&ge,e[5]=H^~ie&ye,e[6]=oe^~ge&E,e[7]=ie^~ye&x,e[8]=ge^~E&V,e[9]=ye^~x&D,e[10]=k^~G&U,e[11]=S^~M&L,e[12]=G^~U&ee,e[13]=M^~L&te,e[14]=U^~ee&he,e[15]=L^~te&de,e[16]=ee^~he&k,e[17]=te^~de&S,e[18]=he^~k&G,e[19]=de^~S&M,e[20]=T^~N&W,e[21]=R^~P&J,e[22]=N^~W&se,e[23]=P^~J&ae,e[24]=W^~se&ce,e[25]=J^~ae&ue,e[26]=se^~ce&T,e[27]=ae^~ue&R,e[28]=ce^~T&N,e[29]=ue^~R&P,e[30]=O^~I&j,e[31]=$^~_&Z,e[32]=I^~j&ne,e[33]=_^~Z&re,e[34]=j^~ne&pe,e[35]=Z^~re&me,e[36]=ne^~pe&O,e[37]=re^~me&$,e[38]=pe^~O&I,e[39]=me^~$&_,e[40]=z^~C&K,e[41]=A^~F&X,e[42]=C^~K&Y,e[43]=F^~X&Q,e[44]=K^~Y&le,e[45]=X^~Q&fe,e[46]=Y^~le&z,e[47]=Q^~fe&A,e[48]=le^~z&C,e[49]=fe^~A&F,e[0]^=St[2*t],e[1]^=St[2*t+1]}}function It(e){const t=[];for(let n=0;n<e.length;n+=4)t.push(e[n]|e[n+1]<<8|e[n+2]<<16|e[n+3]<<24);return t}var _t=new TextDecoder,Vt=new TextEncoder,Dt=/^(0x)?[0-9a-fA-F]*$/i;var Nt=class e{bytes;length;constructor(t,n){if(!t)throw new Error(`Bytes#constructor: constructor parameter is falsy: ${t}`);if(t instanceof e)this.bytes=t.bytes;else if("string"==typeof t){if(!Dt.test(t)||t.replace(/^0x/i,"").length%2!=0)throw new Error(`Bytes#constructor: invalid hex string: ${t}`);this.bytes=yt(t)}else if(t instanceof ArrayBuffer)this.bytes=new Uint8Array(t.slice(0));else if(t instanceof Uint8Array)this.bytes=t.slice();else{const e=t;if("object"!=typeof(r=e)||null===r||"function"!=typeof r.toHex)throw new Error("Bytes#constructor: unsupported type: "+typeof t);this.bytes=yt(e.toHex())}var r;if(this.length=this.bytes.length,void 0!==n)if(Array.isArray(n)){if(!n.includes(this.length))throw new Error(`Bytes#checkByteLength: bytes length is ${this.length} but expected ${n.join(" or ")}`)}else if(this.length!==n)throw new Error(`Bytes#checkByteLength: bytes length is ${this.length} but expected ${n}`)}static keccak256(t){return new e(Ot(new e(t).toUint8Array()))}static concat(...t){const n=t.map((t=>t instanceof e?t.toUint8Array():t)),r=n.reduce(((e,t)=>e+t.length),0),o=new Uint8Array(r);let i=0;for(const e of n)o.set(e,i),i+=e.length;return o}static fromUtf8(t){return new e(Vt.encode(t))}static fromSlice(t,n,r){return new e(void 0===r?t.slice(n):t.slice(n,n+r))}offset(e){return new Uint8Array(this.bytes.slice(e))}toUint8Array(){return new Uint8Array(this.bytes)}toHex(){return pt(this.bytes)}toBase64(){return Bt(this.bytes,wt,4)}toBase32(){return Et(this.bytes)}toString(){return this.toHex()}toUtf8(){return _t.decode(this.bytes)}parsePayloadAsJson(){return JSON.parse(this.toUtf8())}toJSON(){return this.toHex()}equals(t){return this.toHex()===new e(t).toHex()}represent(){return this.toHex()}[Symbol.for("nodejs.util.inspect.custom")](){return this.represent()}},Pt=class extends Nt{static LENGTH=32;constructor(e){super(e,32)}},Ct=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n;function Ft(e){if(e<=0n||e>=Ct)throw new Error("Invalid private key");const t=lt.Point.BASE.multiply(e);return[t.x,t.y]}function Gt(e){const t=new Uint8Array(20),n=Ot(Nt.concat(mt(e[0],"BE"),mt(e[1],"BE")));return t.set(n.subarray(12)),t}var Mt=class extends Nt{static LENGTH=20;constructor(e){super(e,20)}toChecksum(){return function(e){const t=pt(e),n=pt(Ot(Uint8Array.from(t,(e=>e.charCodeAt(0)))));let r="0x";for(let o=0;o<t.length;o++)r+=parseInt(n.charAt(o),16)>7?t.charAt(o).toUpperCase():t.charAt(o);return r}(this.bytes)}},Ut=new Uint8Array(8).fill(255,0,8),Lt=class e extends Nt{static LENGTH=8;static MINUS_ONE=new e(Ut);constructor(e){super(e,8)}static fromBigInt(t){return new e(At(t,"BE"))}toBigInt(){return kt(this.bytes,"BE")}next(){return pt(this.bytes)===pt(Ut)?e.fromBigInt(0n):e.fromBigInt(this.toBigInt()+1n)}},jt=new TextEncoder,Zt=class e extends Nt{static LENGTH=32;constructor(e){super(e,32)}static fromString(t){return new e(Ot(jt.encode(t)))}},qt=class extends Nt{static LENGTH=32;constructor(e){super(e,32)}};function Ht(e,t){const n=lt.sign(Ot(e),t,{prehash:!1}),r=0===n.recovery?27n:28n;return[n.r,n.s,r]}function Wt(e,t,n,r){const o=27n===r?0:1,i=new lt.Signature(t,n,o).recoverPublicKey(Ot(e));return[i.x,i.y]}var Jt=class extends Nt{static LENGTH=64;constructor(e){const t=new Nt(e);if(33===t.length){const[e,n]=function(e){if(33!==e.length||2!==e[0]&&3!==e[0])throw new Error("Invalid compressed public key");const t=lt.Point.fromBytes(e);return[t.x,t.y]}(t.toUint8Array());super(Nt.concat(mt(e,"BE"),mt(n,"BE")),64)}else super(e,64)}address(){const e=gt(this.bytes.slice(0,32),"BE"),t=gt(this.bytes.slice(32,64),"BE");return new Mt(Gt([e,t]))}toCompressedUint8Array(){const e=gt(this.bytes.slice(0,32),"BE"),t=gt(this.bytes.slice(32,64),"BE");return n=[e,t],lt.Point.fromAffine({x:n[0],y:n[1]}).toBytes(!0);var n}toCompressedHex(){return pt(this.toCompressedUint8Array())}},Kt=new TextEncoder,Xt=Kt.encode("Ethereum Signed Message:\n32");function Yt(e){const t=e instanceof Uint8Array?e:Kt.encode(e);return Nt.concat(Xt,Ot(t))}var Qt=class e extends Nt{static LENGTH=65;constructor(e){super(e,65)}static fromSlice(t,n){return new e(t.slice(n,n+e.LENGTH))}recoverPublicKey(e){const t=gt(this.bytes.slice(0,32),"BE"),n=gt(this.bytes.slice(32,64),"BE"),r=BigInt(this.bytes[64]),[o,i]=Wt(Yt(e),t,n,r);return new Jt(Nt.concat(mt(o,"BE"),mt(i,"BE")))}isValid(e,t){return this.recoverPublicKey(e).address().equals(t)}},en=class extends Nt{static LENGTH=32;constructor(e){super(e,32)}publicKey(){const[e,t]=Ft(this.toBigInt());return new Jt(Nt.concat(mt(e,"BE"),mt(t,"BE")))}sign(e){const[t,n,r]=Ht(Yt(e),this.toBigInt());return new Qt(Nt.concat(mt(t,"BE"),mt(n,"BE"),new Uint8Array([Number(r)])))}toBigInt(){return gt(this.bytes,"BE")}};function tn(e){const t=vt(e.toUpperCase().slice(1),bt);const n=t[1];if(250!==n&&251!==n)throw new Error("Unknown codec");return t.slice(-32)}var nn=class e extends Nt{static LENGTH=32;constructor(e){"string"==typeof e&&e.startsWith("bah5")?super(tn(e),32):super(e,[32,64])}toCid(t){if(this.length!==e.LENGTH)throw new Error(`Reference#toCid: only 32-byte references can be encoded as a CID, got ${this.length} bytes`);return`b${Et(Nt.concat(new Uint8Array([1]),new Uint8Array(["feed"===t?251:250]),new Uint8Array([1]),new Uint8Array([27]),new Uint8Array([32]))).replace(/=+$/,"")}${this.toBase32().replace(/=+$/,"")}`.toLowerCase()}static isValid(t){try{return new e(t),!0}catch{return!1}}},rn=class e extends Nt{static LENGTH=8;constructor(e){super(e,8)}static fromBigInt(t){return new e(At(t,"LE"))}toBigInt(){return kt(this.bytes,"LE")}static fromSlice(t,n){return new e(t.slice(n,n+e.LENGTH))}},on=new TextEncoder,sn=class e extends Nt{static LENGTH=32;constructor(e){super(e,32)}static fromString(t){return new e(Ot(on.encode(t)))}},an=class extends Nt{static LENGTH=32;constructor(e){super(e,32)}},cn=class{cursor=0;buffer;constructor(e){this.buffer=e}read(e){const t=this.buffer.subarray(this.cursor,this.cursor+e);return this.cursor+=e,t}max(){return this.buffer.length-this.cursor}},un=class{cursor=0;buffer;constructor(e){this.buffer=e}write(e){const t=Math.min(this.max(),e.max());return this.buffer.set(e.read(t),this.cursor),this.cursor+=t,t}max(){return this.buffer.length-this.cursor}};function ln(e,t,n){const r=new Uint8Array(n.length),o=new Uint8Array(36);o.set(e);for(let i=0,s=0;s<n.length;i++,s+=32){const e=t+i>>>0;o[32]=255&e,o[33]=e>>>8&255,o[34]=e>>>16&255,o[35]=e>>>24&255;const a=Ot(Ot(o)),c=Math.min(s+32,n.length);for(let t=s;t<c;t++)r[t]=n[t]^a[t-s]}return r}function fn(e,t){return ln(e,128,t)}function hn(e,t){return ln(e,0,t)}var dn=4096;function pn(e){const t=e.subarray(0,8),n=function(e){if(e.length>dn)throw new Error(`payload size ${e.length} exceeds maximum chunk payload size 4096`);const t=new Uint8Array(dn);t.set(e);let n=ft(t,32);for(;n.length>1;){const e=[];for(let t=0;t<n.length;t+=2)e.push(Ot(Nt.concat(n[t],n[t+1])));n=e}return n[0]}(e.subarray(8));return new nn(Ot(Nt.concat(t,n)))}yt("dc5b20847f43d67928f49cd4f85d696b5a7617b5");var mn=Zt.LENGTH,gn=Zt.LENGTH+65,yn=gn+rn.LENGTH,wn=(new TextEncoder).encode("Ethereum Signed Message:\n32");function bn(e,t){const n=Ot(Nt.concat(e,t));return Nt.concat(wn,n)}function vn(e,t,n){const[r,o,i]=Ht(bn(e,t),n);return Nt.concat(mt(r,"BE"),mt(o,"BE"),new Uint8Array([Number(i)]))}function Bn(e,t){const n=new Zt(e),r=new Mt(t);return new nn(Ot(Nt.concat(n.toUint8Array(),r.toUint8Array())))}function En(e,t,n){const r=new Zt(t),o=vn(r.toUint8Array(),e.address.toUint8Array(),n),i=new Mt(Gt(Ft(n))),s=Bn(r,i);return{data:Nt.concat(r.toUint8Array(),o,e.data),identifier:r,signature:new Qt(o),span:e.span,payload:e.payload,address:s,owner:i}}function xn(e,t){const n=e instanceof Nt?e.toUint8Array():e,r=new nn(t),o=new Zt(Nt.fromSlice(n,0,Zt.LENGTH)),i=n.slice(mn,mn+65),s=pn(n.slice(gn)),a=new Mt(function(e,t,n){const r=gt(n.subarray(0,32),"BE"),o=gt(n.subarray(32,64),"BE"),i=BigInt(n[64]);return Gt(Wt(bn(e,t),r,o,i))}(o.toUint8Array(),s.toUint8Array(),i)),c=Bn(o,a);if(!c.equals(r))throw new Error("SOC data does not match given address");const u=rn.fromSlice(n,gn),l=Nt.fromSlice(n,yn);return{data:n,identifier:o,signature:new Qt(i),span:u,payload:l,address:c,owner:a}}function Tn(e,t){if("string"==typeof e&&(e=Nt.fromUtf8(e)),e.length<1||e.length>4096)throw new RangeError(`payload size ${e.length} exceeds limits [1, 4096]`);const n=t?"bigint"==typeof t?rn.fromBigInt(t):t:rn.fromBigInt(BigInt(e.length)),r=new Nt(e),o=Nt.concat(n.toUint8Array(),r.toUint8Array()),i={data:o,span:n,payload:r,address:pn(o),toSingleOwnerChunk:(e,t)=>En(i,e,new en(t).toBigInt())};return i}function Rn(e){const t=new Nt(e);return Tn(t.toUint8Array().slice(rn.LENGTH),rn.fromSlice(t.toUint8Array(),0))}var zn=class{span;writer;constructor(e=0n){this.span=e,this.writer=new un(new Uint8Array(4096))}build(){return Nt.concat(At(this.span,"LE"),this.writer.buffer)}hash(){return pn(this.build())}encryptedHash(e){e||(e=new Uint8Array(32),crypto.getRandomValues(e));const t=fn(e,At(this.span,"LE")),n=hn(e,this.writer.buffer);return{address:pn(Nt.concat(t,n)),key:e}}},An=class e{static NOOP=async e=>[];refSize;encrypted;maxShards;chunks;pending=[[]];onBatch;onIntermediateChunk;hasParity=[!1];promotedLeaf=[!1];pendingEntries=[];constructor(e,t,n=!1,r){this.encrypted=n,this.refSize=n?64:32,this.maxShards=t??4096/this.refSize,this.chunks=[new zn],this.onBatch=e,this.onIntermediateChunk=r}static async root(t){const n=new e(e.NOOP);return await n.append(t),n.finalize()}static async encryptedRoot(t){const n=new e(e.NOOP,void 0,!0);await n.append(t);return(await n.finalize()).encryptedHash()}async append(e,t=0,n=0n){const r=new cn(e);for(;r.max()>0;){(0===this.chunks[t].writer.max()||n&&this.chunks[t].writer.max()<e.length)&&await this.elevate(t);const o=this.chunks[t].writer.write(r);n?this.chunks[t].span+=n:this.chunks[0].span+=BigInt(o)}}async elevate(e){this.pending[e]||(this.pending[e]=[]),await this.sealParities(e);const t=this.chunks[e].span;if(e>=1&&this.onIntermediateChunk&&!this.promotedLeaf[e]&&this.onIntermediateChunk(this.chunks[e],this.hasParity[e]??!1),this.hasParity[e]=!1,this.encrypted){const{address:n,key:r}=this.chunks[e].encryptedHash(),o=new Uint8Array(64);o.set(n.toUint8Array()),o.set(r,32),this.pending[e].push({entry:{chunk:this.chunks[e],key:r},ref:o,span:t})}else this.pending[e].push({entry:{chunk:this.chunks[e]},ref:this.chunks[e].hash().toUint8Array(),span:t});this.chunks[e]=new zn,this.promotedLeaf[e]=!1,this.pending[e].length>=this.maxShards&&await this.flushBatch(e)}async sealParities(e){const t=this.pendingEntries[e];if(!t?.length)return;this.pendingEntries[e]=[];const n=await this.onBatch(t);if(n.length>0){this.hasParity[e]=!0;for(const{chunk:t}of n)this.chunks[e].writer.write(new cn(t.hash().toUint8Array()))}}async flushBatch(e){this.chunks[e+1]||(this.chunks.push(new zn),this.pending.push([]),this.hasParity.push(!1),this.promotedLeaf.push(!1));const t=this.pending[e];this.pending[e]=[];for(const{ref:n,span:r}of t)await this.append(n,e+1,r);this.pendingEntries[e+1]||(this.pendingEntries[e+1]=[]),this.pendingEntries[e+1].push(...t.map((e=>e.entry))),t.length>=this.maxShards&&await this.sealParities(e+1)}async finalize(e=0){if(this.pending[e]?.length&&await this.flushBatch(e),!this.chunks[e+1])return await this.sealParities(e),e>=1&&this.onIntermediateChunk&&!this.promotedLeaf[e]&&this.onIntermediateChunk(this.chunks[e],this.hasParity[e]??!1),this.chunks[e];const t=this.chunks[e+1].writer;return 0===t.cursor||t.max()<this.refSize?(await this.elevate(e+1),await this.flushBatch(e+1),await this.sealParities(e),this.chunks[e+1]=this.chunks[e],this.hasParity[e+1]=this.hasParity[e]??!1,this.hasParity[e]=!1,this.promotedLeaf[e+1]=0===e||(this.promotedLeaf[e]??!1),this.finalize(e+1)):(await this.elevate(e),await this.flushBatch(e),this.finalize(e+1))}},kn=[[[],[]],[[95,69,47,29,15,6,2,1],[9,8,7,6,5,4,3,2]],[[105,96,87,78,70,62,54,47,40,33,27,21,16,11,7,4,2,1],[21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4]],[[93,88,83,78,74,69,64,60,55,51,46,42,38,34,30,27,23,20,17,14,11,9,6,4,3,2,1],[31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5]],[[37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1],[89,87,86,84,83,81,80,78,76,75,73,71,70,68,66,65,63,61,59,58,56,54,52,50,48,47,45,43,40,38,36,34,31,29,26,23,19]]],Sn=[[[],[]],[[47,34,23,14,7,3,1],[9,8,7,6,5,4,3]],[[52,48,43,39,35,31,27,23,20,16,13,10,8,5,3,2,1],[21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5]],[[46,44,41,39,37,34,32,30,27,25,23,21,19,17,15,13,11,10,8,7,5,4,3,2,1],[31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,6]],[[18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1],[87,84,81,78,75,71,68,65,61,58,54,50,47,43,38,34,29,23]]];function On(e,t,n){return e<=0||e>4?0:function(e,t){const[n,r]=e;for(let o=0;o<n.length;o++)if(t>=n[o])return r[o];return 0}(n?Sn[e]:kn[e],t)}function $n(e,t,n){return t<=0||e<=0?0:On(t,e,n)/e}var In={label:"medium",value:1,errorTolerance:.01},_n={label:"strong",value:2,errorTolerance:.05},Vn={label:"insane",value:3,errorTolerance:.1},Dn={label:"paranoid",value:4,errorTolerance:.5};function Nn(){return{medium:In,strong:_n,insane:Vn,paranoid:Dn}}function Pn(e){if("string"==typeof e)switch(e.toLowerCase()){case"medium":return In;case"strong":return _n;case"insane":return Vn;case"paranoid":return Dn;default:throw new Error(`Unknown redundancy level '${e}'`)}switch(e){case 1:return In;case 2:return _n;case 3:return Vn;case 4:return Dn;default:throw new Error(`Unknown redundancy level '${e}'`)}}function Cn(e,t){if(0===t.length)throw new Error("xorCypher: key must not be empty");const n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e[r]^t[r%t.length];return n}new Uint8Array([0,0,1,25,2,50,26,198,3,223,51,238,27,104,199,75,4,100,224,14,52,141,239,129,28,193,105,248,200,8,76,113,5,138,101,47,225,36,15,33,53,147,142,218,240,18,130,69,29,181,194,125,106,39,249,185,201,154,9,120,77,228,114,166,6,191,139,98,102,221,48,253,226,152,37,179,16,145,34,136,54,208,148,206,143,150,219,189,241,210,19,92,131,56,70,64,30,66,182,163,195,72,126,110,107,58,40,84,250,133,186,61,202,94,155,159,10,21,121,43,78,212,229,172,115,243,167,87,7,112,192,247,140,128,99,13,103,74,222,237,49,197,254,24,227,165,153,119,38,184,180,124,17,68,146,217,35,32,137,46,55,63,209,91,149,188,207,205,144,135,151,178,220,252,190,97,242,86,211,171,20,42,93,158,132,60,57,83,71,109,65,162,31,45,67,216,183,123,164,118,196,23,73,236,127,12,111,246,108,161,59,82,41,157,85,170,251,96,134,177,187,204,62,90,203,89,95,176,156,169,160,81,11,245,22,235,122,117,44,215,79,174,213,233,230,231,173,232,116,214,244,234,168,80,88,175]),new Uint8Array([1,2,4,8,16,32,64,128,29,58,116,232,205,135,19,38,76,152,45,90,180,117,234,201,143,3,6,12,24,48,96,192,157,39,78,156,37,74,148,53,106,212,181,119,238,193,159,35,70,140,5,10,20,40,80,160,93,186,105,210,185,111,222,161,95,190,97,194,153,47,94,188,101,202,137,15,30,60,120,240,253,231,211,187,107,214,177,127,254,225,223,163,91,182,113,226,217,175,67,134,17,34,68,136,13,26,52,104,208,189,103,206,129,31,62,124,248,237,199,147,59,118,236,197,151,51,102,204,133,23,46,92,184,109,218,169,79,158,33,66,132,21,42,84,168,77,154,41,82,164,85,170,73,146,57,114,228,213,183,115,230,209,191,99,198,145,63,126,252,229,215,179,123,246,241,255,227,219,171,75,150,49,98,196,149,55,110,220,165,87,174,65,130,25,50,100,200,141,7,14,28,56,112,224,221,167,83,166,81,162,89,178,121,242,249,239,195,155,43,86,172,69,138,9,18,36,72,144,61,122,244,245,247,243,251,235,203,139,11,22,44,88,176,125,250,233,207,131,27,54,108,216,173,71,142]);var Fn=new TextEncoder,Gn=new TextDecoder,Mn=new Uint8Array([47]),Un=yt("5768b3b6a7db56d21d1abff40d41cebfc83448fed8d7e9b06ec0d3b073f28f7b");function Ln(e){return function(e,t,n=0){if(0===t.length)return Math.min(n,e.length);for(let r=n;r<e.length;r++)for(let n=0;n<t.length&&e[r+n]===t[n];n++)if(n===t.length-1)return r;return-1}(e,Mn)>0}function jn(e,t){const n=Math.floor(t/8),r=t%8;e[n]=e[n]|1<<r}function Zn(e,t){const n=t%8;return 1==(e[Math.floor(t/8)]>>n&1)}var qn=class e{obfuscationKey;persisted=!1;loaded=!0;selfAddress=null;targetAddress=new Uint8Array(32);metadata=null;path=new Uint8Array(0);forks=new Map;parent=null;type=null;encrypt=!1;constructor(e){e?.encrypt&&(this.encrypt=!0),e?.targetAddress?this.targetAddress=e.targetAddress:this.encrypt&&(this.targetAddress=new Uint8Array(64)),e?.selfAddress&&(this.selfAddress=e.selfAddress),e?.metadata&&(this.metadata=e.metadata),this.obfuscationKey=e?.obfuscationKey??function(){const e=new Uint8Array(32);return crypto.getRandomValues(e),e}(),e?.path&&(this.path=e.path),e?.parent&&(this.parent=e.parent),this.type=e?.type??null}get fullPath(){return Nt.concat(this.parent?.fullPath??new Uint8Array(0),this.path)}get fullPathString(){return Gn.decode(this.fullPath)}async marshal(){for(const a of this.forks.values())a.node.selfAddress||(a.node.selfAddress=(await a.node.calculateSelfAddress()).toUint8Array());const e=!ht(this.targetAddress,new Uint8Array(this.targetAddress.length));let t=0;if(e)t=this.targetAddress.length;else for(const a of this.forks.values())if(a.node.selfAddress&&a.node.selfAddress.length>0){t=a.node.selfAddress.length;break}const n=new Uint8Array(32);n.set(Un,0),n.set(xt(t),31);const r=e?this.targetAddress:new Uint8Array(t),o=new Uint8Array(32);for(const a of this.forks.keys())jn(o,a);const i=[];for(let a=0;a<256;a++)Zn(o,a)&&i.push(this.forks.get(a).marshal());const s=Cn(Nt.concat(n,r,o,...i),this.obfuscationKey);return Nt.concat(this.obfuscationKey,s)}static unmarshalFromData(t,n){if(t.length<64)throw new Error("MantarayNode#unmarshalFromData data too short");const r=t.subarray(0,32),o=Cn(t.subarray(32),r),i=new cn(o);if(!ht(i.read(31),Un.slice(0,31)))throw new Error("MantarayNode#unmarshalFromData invalid version hash");const s=Tt(i.read(1)),a=i.read(s),c=new e({selfAddress:n,targetAddress:a,obfuscationKey:r,encrypt:64===s||64===n?.length});c.persisted=!0;const u=i.read(32),l=0===s?32:s;for(let e=0;e<256;e++)if(Zn(u,e)){const t=Jn.unmarshal(i,l);c.forks.set(e,t),t.node.parent=c,t.node.persisted=!0,t.node.loaded=!1}return c}addFork(t,n,r){this.selfAddress=null,this.type=null,t=t instanceof Uint8Array?t:Fn.encode(t);let o=this;for(;t.length;){const i=t.slice(0,30),s=0===(t=t.slice(30)).length,[a,c]=o.findClosest(i),u=i.slice(c.length);if(c.length&&(o=a),!u.length){s&&(o.assertSubtreeLoaded(),o.targetAddress=new nn(n).toUint8Array(),o.metadata=r??null,o.invalidate());continue}const l=new Jn(u,new e({targetAddress:s?new nn(n).toUint8Array():void 0,metadata:s?r:void 0,path:u,encrypt:this.encrypt}));o.assertSubtreeLoaded();const f=a.forks.get(u[0]);if(f){const e=Jn.split(l,f);o.forks.set(u[0],e),e.node.parent=o}else o.forks.set(u[0],l),l.node.parent=o;o.invalidate(),o=l.node}}relocate(e){this.path=e,this.loaded?this.type=null:null!==this.type&&(this.type=-9&this.type|(Ln(e)?8:0))}assertSubtreeLoaded(){if(!this.loaded)throw new Error(`MantarayNode: forks of "${this.fullPathString}" are not loaded - load the subtree before editing it`)}invalidate(){let e=this;for(;e;)e.selfAddress=null,e.type=null,e.persisted=!1,e=e.parent}removeFork(e){if(this.selfAddress=null,this.type=null,0===(e=e instanceof Uint8Array?e:Fn.encode(e)).length)throw new Error("MantarayNode#removeFork path cannot be empty");const t=this.find(e);if(!t)throw new Error("MantarayNode#removeFork fork not found");t.assertSubtreeLoaded();const[n,r]=this.findClosest(e.slice(0,e.length-1)),o=e.slice(r.length)[0],i=t.onlyChildFittingOneFork();i?(n.forks.delete(o),n.adopt(i,Nt.concat(t.path,i.prefix))):0===t.forks.size?n.forks.delete(o):t.clearEntry(),t.invalidate(),n.invalidate()}onlyChildFittingOneFork(){if(1!==this.forks.size)return;const e=[...this.forks.values()][0];return Nt.concat(this.path,e.prefix).length<=30?e:void 0}adopt(e,t){e.prefix=t,e.node.relocate(t),e.node.parent=this,this.forks.set(t[0],e)}clearEntry(){this.targetAddress=new Uint8Array(this.targetAddress.length),this.metadata=null}async calculateSelfAddress(){if(this.selfAddress)return new nn(this.selfAddress);if(this.encrypt)throw new Error("MantarayNode#calculateSelfAddress is not supported for encrypted nodes - use saveRecursively");return(await An.root(await this.marshal())).hash()}async saveRecursively(e){for(const r of this.forks.values())r.node.persisted||await r.node.saveRecursively(e);const t=new An((async t=>{for(const{chunk:n,key:r}of t)await e(n,r);return[]}),void 0,this.encrypt);await t.append(await this.marshal());const n=await t.finalize();if(this.encrypt){const{address:t,key:r}=n.encryptedHash();return await e(n,r),this.selfAddress=Nt.concat(t.toUint8Array(),r),this.persisted=!0,{reference:this.selfAddress,rootChunk:n,encryptionKey:r}}return await e(n),this.selfAddress=n.hash().toUint8Array(),this.persisted=!0,{reference:this.selfAddress,rootChunk:n}}find(e){const t=e instanceof Uint8Array?e:Fn.encode(e),[n,r]=this.findClosest(t);return r.length===t.length?n:null}findClosest(e,t=new Uint8Array){if(0===(e=e instanceof Uint8Array?e:Fn.encode(e)).length)return[this,t];const n=this.forks.get(e[0]);return n&&dt(n.prefix,e).length===n.prefix.length?n.node.findClosest(e.slice(n.prefix.length),Nt.concat(t,n.prefix)):[this,t]}collect(e=[]){for(const t of this.forks.values())ht(t.node.targetAddress,new Uint8Array(t.node.targetAddress.length))||e.push(t.node),t.node.collect(e);return e}collectAndMap(){const e={};for(const t of this.collect())e[t.fullPathString]=new nn(t.targetAddress).toHex();return e}determineType(){let e=0;const t=new Uint8Array(this.targetAddress.length);return ht(this.targetAddress,t)&&0!==this.forks.size||(e|=2),this.forks.size>0&&(e|=4),Ln(this.path)&&(e|=8),this.metadata&&(e|=16),e}},Hn=new TextEncoder,Wn=new TextDecoder;var Jn=class e{prefix;node;constructor(e,t){this.prefix=e,this.node=t}static split(t,n){const r=dt(t.prefix,n.prefix);if(r.length===t.prefix.length){const e=n.prefix.slice(r.length);return n.node.relocate(n.prefix.slice(r.length)),n.prefix=n.prefix.slice(r.length),n.node.parent=t.node,t.node.forks.set(e[0],n),t}if(r.length===n.prefix.length){const e=t.prefix.slice(r.length);return t.node.relocate(t.prefix.slice(r.length)),t.prefix=t.prefix.slice(r.length),t.node.parent=n.node,n.node.forks.set(e[0],t),n}const o=new qn({path:r,encrypt:t.node.encrypt}),i=new e(t.prefix.slice(r.length),t.node),s=new e(n.prefix.slice(r.length),n.node);return t.node.relocate(t.prefix.slice(r.length)),n.node.relocate(n.prefix.slice(r.length)),t.prefix=t.prefix.slice(r.length),n.prefix=n.prefix.slice(r.length),o.forks.set(i.prefix[0],i),o.forks.set(s.prefix[0],s),i.node.parent=o,s.node.parent=o,new e(r,o)}marshal(){if(!this.node.selfAddress)throw new Error("Fork#marshal node.selfAddress is not set");const e=[];if(e.push(new Uint8Array([this.node.type??this.node.determineType()])),e.push(xt(this.prefix.length)),e.push(this.prefix),this.prefix.length<30&&e.push(new Uint8Array(30-this.prefix.length)),e.push(this.node.selfAddress),this.node.metadata){const t=function(e,t,n){const r=e.length%t;if(0===r)return e;const o=new Uint8Array(e.length+t-r).fill(n);return o.set(e,0),o}(Nt.concat(new Uint8Array([0,0]),Hn.encode(JSON.stringify(this.node.metadata))),32,10);t.set(function(e,t){const n=new ArrayBuffer(2);return new DataView(n).setUint16(0,e,"LE"===t),new Uint8Array(n)}(t.length-2,"BE"),0),e.push(t)}return Nt.concat(...e)}static unmarshal(t,n){const r=Tt(t.read(1)),o=Tt(t.read(1)),i=t.read(o);o<30&&t.read(30-o);const s=t.read(n);let a;if(function(e,t){return(e&t)===t}(r,16)){const e=Rt(t.read(2),"BE");if(e>t.max())throw new Error("Fork#unmarshal not enough bytes for metadata");a=JSON.parse(Wn.decode(t.read(e)))}return new e(i,new qn({selfAddress:s,metadata:a,path:i,type:r,encrypt:64===n}))}};function Kn(e,t,n){return e/Math.pow(2,t-n)}function Xn(e){return 4096*2**e}var Yn=.9;function Qn(e){const t=e.match(/^([\d.]+)\s*(B|kB|MB|GB|TB|PB)$/);if(!t)throw new Error(`Invalid size format: ${e}`);return Math.ceil(parseFloat(t[1])*{B:1,kB:1e3,MB:1e6,GB:1e3**3,TB:1e3**4,PB:1e3**5}[t[2]])}var er=[[17,"0.00004089 GB"],[18,"0.00609 GB"],[19,"0.10249 GB"],[20,"0.62891 GB"],[21,"2.38 GB"],[22,"7.07 GB"],[23,"18.24 GB"],[24,"43.04 GB"],[25,"96.5 GB"],[26,"208.52 GB"],[27,"435.98 GB"],[28,"908.81 GB"],[29,"1870 GB"],[30,"3810 GB"],[31,"7730 GB"],[32,"15610 GB"],[33,"31430 GB"],[34,"63150 GB"]],tr=[[[17,"44.70 kB"],[18,"6.66 MB"],[19,"112.06 MB"],[20,"687.62 MB"],[21,"2.60 GB"],[22,"7.73 GB"],[23,"19.94 GB"],[24,"47.06 GB"],[25,"105.51 GB"],[26,"227.98 GB"],[27,"476.68 GB"],[28,"993.65 GB"],[29,"2.04 TB"],[30,"4.17 TB"],[31,"8.45 TB"],[32,"17.07 TB"],[33,"34.36 TB"],[34,"69.04 TB"],[35,"138.54 TB"],[36,"277.72 TB"],[37,"556.35 TB"],[38,"1.11 PB"],[39,"2.23 PB"],[40,"4.46 PB"],[41,"8.93 PB"]],[[17,"41.56 kB"],[18,"6.19 MB"],[19,"104.18 MB"],[20,"639.27 MB"],[21,"2.41 GB"],[22,"7.18 GB"],[23,"18.54 GB"],[24,"43.75 GB"],[25,"98.09 GB"],[26,"211.95 GB"],[27,"443.16 GB"],[28,"923.78 GB"],[29,"1.90 TB"],[30,"3.88 TB"],[31,"7.86 TB"],[32,"15.87 TB"],[33,"31.94 TB"],[34,"64.19 TB"],[35,"128.80 TB"],[36,"258.19 TB"],[37,"517.23 TB"],[38,"1.04 PB"],[39,"2.07 PB"],[40,"4.15 PB"],[41,"8.30 PB"]],[[17,"37.37 kB"],[18,"5.57 MB"],[19,"93.68 MB"],[20,"574.81 MB"],[21,"2.17 GB"],[22,"6.46 GB"],[23,"16.67 GB"],[24,"39.34 GB"],[25,"88.20 GB"],[26,"190.58 GB"],[27,"398.47 GB"],[28,"830.63 GB"],[29,"1.71 TB"],[30,"3.49 TB"],[31,"7.07 TB"],[32,"14.27 TB"],[33,"28.72 TB"],[34,"57.71 TB"],[35,"115.81 TB"],[36,"232.16 TB"],[37,"465.07 TB"],[38,"931.23 TB"],[39,"1.86 PB"],[40,"3.73 PB"],[41,"7.46 PB"]],[[17,"33.88 kB"],[18,"5.05 MB"],[19,"84.92 MB"],[20,"521.09 MB"],[21,"1.97 GB"],[22,"5.86 GB"],[23,"15.11 GB"],[24,"35.66 GB"],[25,"79.96 GB"],[26,"172.77 GB"],[27,"361.23 GB"],[28,"753.00 GB"],[29,"1.55 TB"],[30,"3.16 TB"],[31,"6.41 TB"],[32,"12.93 TB"],[33,"26.04 TB"],[34,"52.32 TB"],[35,"104.99 TB"],[36,"210.46 TB"],[37,"421.61 TB"],[38,"844.20 TB"],[39,"1.69 PB"],[40,"3.38 PB"],[41,"6.77 PB"]],[[17,"13.27 kB"],[18,"1.98 MB"],[19,"33.27 MB"],[20,"204.14 MB"],[21,"771.13 MB"],[22,"2.29 GB"],[23,"5.92 GB"],[24,"13.97 GB"],[25,"31.32 GB"],[26,"67.68 GB"],[27,"141.51 GB"],[28,"294.99 GB"],[29,"606.90 GB"],[30,"1.24 TB"],[31,"2.51 TB"],[32,"5.07 TB"],[33,"10.20 TB"],[34,"20.50 TB"],[35,"41.13 TB"],[36,"82.45 TB"],[37,"165.17 TB"],[38,"330.72 TB"],[39,"661.97 TB"],[40,"1.32 PB"],[41,"2.65 PB"]]],nr=[[[17,"44.35 kB"],[18,"6.61 MB"],[19,"111.18 MB"],[20,"682.21 MB"],[21,"2.58 GB"],[22,"7.67 GB"],[23,"19.78 GB"],[24,"46.69 GB"],[25,"104.68 GB"],[26,"226.19 GB"],[27,"472.93 GB"],[28,"985.83 GB"],[29,"2.03 TB"],[30,"4.14 TB"],[31,"8.39 TB"],[32,"16.93 TB"],[33,"34.09 TB"],[34,"68.50 TB"],[35,"137.45 TB"],[36,"275.53 TB"],[37,"551.97 TB"],[38,"1.11 PB"],[39,"2.21 PB"],[40,"4.43 PB"],[41,"8.86 PB"]],[[17,"40.89 kB"],[18,"6.09 MB"],[19,"102.49 MB"],[20,"628.91 MB"],[21,"2.38 GB"],[22,"7.07 GB"],[23,"18.24 GB"],[24,"43.04 GB"],[25,"96.50 GB"],[26,"208.52 GB"],[27,"435.98 GB"],[28,"908.81 GB"],[29,"1.87 TB"],[30,"3.81 TB"],[31,"7.73 TB"],[32,"15.61 TB"],[33,"31.43 TB"],[34,"63.15 TB"],[35,"126.71 TB"],[36,"254.01 TB"],[37,"508.85 TB"],[38,"1.02 PB"],[39,"2.04 PB"],[40,"4.08 PB"],[41,"8.17 PB"]],[[17,"36.73 kB"],[18,"5.47 MB"],[19,"92.07 MB"],[20,"564.95 MB"],[21,"2.13 GB"],[22,"6.35 GB"],[23,"16.38 GB"],[24,"38.66 GB"],[25,"86.69 GB"],[26,"187.31 GB"],[27,"391.64 GB"],[28,"816.39 GB"],[29,"1.68 TB"],[30,"3.43 TB"],[31,"6.94 TB"],[32,"14.02 TB"],[33,"28.23 TB"],[34,"56.72 TB"],[35,"113.82 TB"],[36,"228.18 TB"],[37,"457.10 TB"],[38,"915.26 TB"],[39,"1.83 PB"],[40,"3.67 PB"],[41,"7.34 PB"]],[[17,"33.26 kB"],[18,"4.96 MB"],[19,"83.38 MB"],[20,"511.65 MB"],[21,"1.93 GB"],[22,"5.75 GB"],[23,"14.84 GB"],[24,"35.02 GB"],[25,"78.51 GB"],[26,"169.64 GB"],[27,"354.69 GB"],[28,"739.37 GB"],[29,"1.52 TB"],[30,"3.10 TB"],[31,"6.29 TB"],[32,"12.70 TB"],[33,"25.57 TB"],[34,"51.37 TB"],[35,"103.08 TB"],[36,"206.65 TB"],[37,"413.98 TB"],[38,"828.91 TB"],[39,"1.66 PB"],[40,"3.32 PB"],[41,"6.64 PB"]],[[17,"13.17 kB"],[18,"1.96 MB"],[19,"33.01 MB"],[20,"202.53 MB"],[21,"765.05 MB"],[22,"2.28 GB"],[23,"5.87 GB"],[24,"13.86 GB"],[25,"31.08 GB"],[26,"67.15 GB"],[27,"140.40 GB"],[28,"292.67 GB"],[29,"602.12 GB"],[30,"1.23 TB"],[31,"2.49 TB"],[32,"5.03 TB"],[33,"10.12 TB"],[34,"20.34 TB"],[35,"40.80 TB"],[36,"81.80 TB"],[37,"163.87 TB"],[38,"328.11 TB"],[39,"656.76 TB"],[40,"1.31 PB"],[41,"2.63 PB"]]];function rr(e,t,n){if(e<17)return 0;if(void 0!==t&&void 0!==n){const r=(t?nr:tr)[n],o=r?.find((([t])=>t===e));if(o)return Qn(o[1])}else{const t=er.find((([t])=>t===e));if(t)return Qn(t[1])}return Math.ceil(Xn(e)*Yn)}function or(e,t){const n=new Map;for(let r=17;r<35;r++)n.set(r,rr(r,e,t));return n}function ir(e){return function(e,t,n,r){if(65!==e.length)throw new Error("invalid signature length");if(32!==t.length)throw new Error("invalid batch ID length");if(8!==n.length)throw new Error("invalid timestamp length");if(8!==r.length)throw new Error("invalid index length");return new Nt(Nt.concat(t,r,n,e))}(e.signature.toUint8Array(),e.batchId.toUint8Array(),e.timestamp,e.index)}var sr,ar=class e{signer;batchId;buckets;depth;maxSlot;constructor(e,t,n,r){if(!Number.isInteger(r)||r<=16)throw new Error(`Stamper#constructor depth must be an integer above 16, got ${r}`);this.signer=e,this.batchId=t,this.buckets=n,this.depth=r,this.maxSlot=2**(r-16)}static fromBlank(t,n,r){return new e(new en(t),new Pt(n),new Uint32Array(65536),r)}static fromState(t,n,r,o){return new e(new en(t),new Pt(n),r,o)}stamp(e,t){const n=Rt(e,"BE"),r=this.buckets[n];if(r>=this.maxSlot)throw new Error("Stamper#stamp bucket is full");return this.buckets[n]=r+1,function(e,t,n,r,o=Date.now()){const i=new en(e),s=new Pt(t),a=Rt(n,"BE"),c=Nt.concat(zt(a,"BE"),zt(r,"BE")),u=At(1000000n*BigInt(o),"BE"),l=i.sign(Nt.concat(n,s.toUint8Array(),c,u));return{batchId:s,index:c,issuer:i.publicKey().address(),signature:l,timestamp:u}}(this.signer,this.batchId,e,r,t)}getState(){return this.buckets}},cr=n(20);function ur(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:s,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);const o=s.prototype,i=Object.keys(o);for(let e=0;e<i.length;e++){const t=i[e];t in n||(n[t]=o[t].bind(n))}}const o=n?.Parent??Object;class i extends o{}function s(e){var t;const o=n?.Parent?new i:this;r(o,e),(t=o._zod).deferred??(t.deferred=[]);for(const n of o._zod.deferred)n();return o}return Object.defineProperty(i,"name",{value:e}),Object.defineProperty(s,"init",{value:r}),Object.defineProperty(s,Symbol.hasInstance,{value:t=>!!(n?.Parent&&t instanceof n.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}Symbol("zod_brand");class lr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class fr extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}(sr=globalThis).__zod_globalConfig??(sr.__zod_globalConfig={});const hr=globalThis.__zod_globalConfig;function dr(e){return e&&Object.assign(hr,e),hr}const pr=/^[cC][0-9a-z]{6,}$/,mr=/^[0-9a-z]+$/,gr=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,yr=/^[0-9a-vA-V]{20}$/,wr=/^[A-Za-z0-9]{27}$/,br=/^[a-zA-Z0-9_-]{21}$/,vr=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Br=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Er=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,xr=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;const Tr=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Rr=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,zr=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Ar=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,kr=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Sr=/^[A-Za-z0-9_-]*$/,Or=/^https?$/,$r=/^\+[1-9]\d{6,14}$/,Ir="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",_r=new RegExp(`^${Ir}$`);function Vr(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof e.precision?-1===e.precision?`${t}`:0===e.precision?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}const Dr=/^-?\d+n?$/,Nr=/^-?\d+$/,Pr=/^-?\d+(?:\.\d+)?$/,Cr=/^(?:true|false)$/i,Fr=/^[^A-Z]*$/,Gr=/^[^a-z]*$/;function Mr(e){const t=Object.values(e).filter((e=>"number"==typeof e));return Object.entries(e).filter((([e,n])=>-1===t.indexOf(+e))).map((([e,t])=>t))}function Ur(e,t){return"bigint"==typeof t?t.toString():t}function Lr(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function jr(e){return null==e}function Zr(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}const qr=Symbol("evaluating");function Hr(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==qr)return void 0===r&&(r=qr,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Wr(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Jr(...e){const t={};for(const n of e){const e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Kr(e){return JSON.stringify(e)}const Xr="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Yr(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}const Qr=Lr((()=>{if(hr.jitless)return!1;if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}}));function eo(e){if(!1===Yr(e))return!1;const t=e.constructor;if(void 0===t)return!0;if("function"!=typeof t)return!0;const n=t.prototype;return!1!==Yr(n)&&!1!==Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")}function to(e){return eo(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const no=new Set(["string","number","symbol"]);function ro(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function oo(e,t,n){const r=new e._zod.constr(t??e._zod.def);return t&&!n?.parent||(r._zod.parent=e),r}function io(e){const t=e;if(!t)return{};if("string"==typeof t)return{error:()=>t};if(void 0!==t?.message){if(void 0!==t?.error)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,"string"==typeof t.error?{...t,error:()=>t.error}:t}const so={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function ao(e,t=0){if(!0===e.aborted)return!0;for(let n=t;n<e.issues.length;n++)if(!0!==e.issues[n]?.continue)return!0;return!1}function co(e,t=0){if(!0===e.aborted)return!0;for(let n=t;n<e.issues.length;n++)if(!1===e.issues[n]?.continue)return!0;return!1}function uo(e,t){return t.map((t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t}))}function lo(e){return"string"==typeof e?e:e?.message}function fo(e,t,n){const r=e.message?e.message:lo(e.inst?._zod.def?.error?.(e))??lo(t?.error?.(e))??lo(n.customError?.(e))??lo(n.localeError?.(e))??"Invalid input",{inst:o,continue:i,input:s,...a}=e;return a.path??(a.path=[]),a.message=r,t?.reportInput&&(a.input=s),a}function ho(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function po(...e){const[t,n,r]=e;return"string"==typeof t?{message:t,code:"custom",input:n,inst:r}:{...t}}const mo=ur("$ZodCheck",((e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])})),go={number:"number",bigint:"bigint",object:"date"},yo=ur("$ZodCheckLessThan",((e,t)=>{mo.init(e,t);const n=go[typeof t.value];e._zod.onattach.push((e=>{const n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)})),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:"object"==typeof t.value?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}})),wo=ur("$ZodCheckGreaterThan",((e,t)=>{mo.init(e,t);const n=go[typeof t.value];e._zod.onattach.push((e=>{const n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)})),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:"object"==typeof t.value?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}})),bo=ur("$ZodCheckMultipleOf",((e,t)=>{mo.init(e,t),e._zod.onattach.push((e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)})),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof n.value?n.value%t.value===BigInt(0):0===function(e,t){const n=e/t,r=Math.round(n),o=Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<o?0:n-r}(n.value,t.value))||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}})),vo=ur("$ZodCheckNumberFormat",((e,t)=>{mo.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,i]=so[t.format];e._zod.onattach.push((e=>{const r=e._zod.bag;r.format=t.format,r.minimum=o,r.maximum=i,n&&(r.pattern=Nr)})),e._zod.check=s=>{const a=s.value;if(n){if(!Number.isInteger(a))return void s.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});if(!Number.isSafeInteger(a))return void(a>0?s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}))}a<o&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>i&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}})),Bo=ur("$ZodCheckMaxLength",((e,t)=>{var n;mo.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!jr(t)&&void 0!==t.length}),e._zod.onattach.push((e=>{const n=e._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<n&&(e._zod.bag.maximum=t.maximum)})),e._zod.check=n=>{const r=n.value;if(r.length<=t.maximum)return;const o=ho(r);n.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}})),Eo=ur("$ZodCheckMinLength",((e,t)=>{var n;mo.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!jr(t)&&void 0!==t.length}),e._zod.onattach.push((e=>{const n=e._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>n&&(e._zod.bag.minimum=t.minimum)})),e._zod.check=n=>{const r=n.value;if(r.length>=t.minimum)return;const o=ho(r);n.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}})),xo=ur("$ZodCheckLengthEquals",((e,t)=>{var n;mo.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!jr(t)&&void 0!==t.length}),e._zod.onattach.push((e=>{const n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length})),e._zod.check=n=>{const r=n.value,o=r.length;if(o===t.length)return;const i=ho(r),s=o>t.length;n.issues.push({origin:i,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}})),To=ur("$ZodCheckStringFormat",((e,t)=>{var n,r;mo.init(e,t),e._zod.onattach.push((e=>{const n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??(n.patterns=new Set),n.patterns.add(t.pattern))})),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})})),Ro=ur("$ZodCheckRegex",((e,t)=>{To.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}})),zo=ur("$ZodCheckLowerCase",((e,t)=>{t.pattern??(t.pattern=Fr),To.init(e,t)})),Ao=ur("$ZodCheckUpperCase",((e,t)=>{t.pattern??(t.pattern=Gr),To.init(e,t)})),ko=ur("$ZodCheckIncludes",((e,t)=>{mo.init(e,t);const n=ro(t.includes),r=new RegExp("number"==typeof t.position?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push((e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(r)})),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}})),So=ur("$ZodCheckStartsWith",((e,t)=>{mo.init(e,t);const n=new RegExp(`^${ro(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push((e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(n)})),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}})),Oo=ur("$ZodCheckEndsWith",((e,t)=>{mo.init(e,t);const n=new RegExp(`.*${ro(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push((e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(n)})),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}));const $o=ur("$ZodCheckOverwrite",((e,t)=>{mo.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}));class Io{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if("function"==typeof e)return e(this,{execution:"sync"}),void e(this,{execution:"async"});const t=e.split("\n").filter((e=>e)),n=Math.min(...t.map((e=>e.length-e.trimStart().length))),r=t.map((e=>e.slice(n))).map((e=>" ".repeat(2*this.indent)+e));for(const o of r)this.content.push(o)}compile(){const e=Function,t=this?.args;return new e(...t,[...(this?.content??[""]).map((e=>` ${e}`))].join("\n"))}}const _o=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Ur,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Vo=ur("$ZodError",_o),Do=ur("$ZodError",_o,{Parent:Error});const No=e=>(t,n,r,o)=>{const i=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw new lr;if(s.issues.length){const t=new(o?.Err??e)(s.issues.map((e=>fo(e,i,dr()))));throw Xr(t,o?.callee),t}return s.value},Po=No(Do),Co=e=>async(t,n,r,o)=>{const i=r?{...r,async:!0}:{async:!0};let s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise&&(s=await s),s.issues.length){const t=new(o?.Err??e)(s.issues.map((e=>fo(e,i,dr()))));throw Xr(t,o?.callee),t}return s.value},Fo=Co(Do),Go=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new lr;return i.issues.length?{success:!1,error:new(e??Vo)(i.issues.map((e=>fo(e,o,dr()))))}:{success:!0,data:i.value}},Mo=Go(Do),Uo=e=>async(t,n,r)=>{const o=r?{...r,async:!0}:{async:!0};let i=t._zod.run({value:n,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map((e=>fo(e,o,dr()))))}:{success:!0,data:i.value}},Lo=Uo(Do),jo=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return No(e)(t,n,o)},Zo=e=>(t,n,r)=>No(e)(t,n,r),qo=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Co(e)(t,n,o)},Ho=e=>async(t,n,r)=>Co(e)(t,n,r),Wo=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Go(e)(t,n,o)},Jo=e=>(t,n,r)=>Go(e)(t,n,r),Ko=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Uo(e)(t,n,o)},Xo=e=>async(t,n,r)=>Uo(e)(t,n,r),Yo={major:4,minor:4,patch:3};const Qo=ur("$ZodType",((e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Yo;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const o of r)for(const t of o._zod.onattach)t(e);if(0===r.length)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push((()=>{e._zod.run=e._zod.parse}));else{const t=(e,t,n)=>{let r,o=ao(e);for(const i of t){if(i._zod.def.when){if(co(e))continue;if(!i._zod.def.when(e))continue}else if(o)continue;const t=e.issues.length,s=i._zod.check(e);if(s instanceof Promise&&!1===n?.async)throw new lr;if(r||s instanceof Promise)r=(r??Promise.resolve()).then((async()=>{await s;e.issues.length!==t&&(o||(o=ao(e,t)))}));else{if(e.issues.length===t)continue;o||(o=ao(e,t))}}return r?r.then((()=>e)):e},n=(n,o,i)=>{if(ao(n))return n.aborted=!0,n;const s=t(o,r,i);if(s instanceof Promise){if(!1===i.async)throw new lr;return s.then((t=>e._zod.parse(t,i)))}return e._zod.parse(s,i)};e._zod.run=(o,i)=>{if(i.skipChecks)return e._zod.parse(o,i);if("backward"===i.direction){const t=e._zod.parse({value:o.value,issues:[]},{...i,skipChecks:!0});return t instanceof Promise?t.then((e=>n(e,o,i))):n(t,o,i)}const s=e._zod.parse(o,i);if(s instanceof Promise){if(!1===i.async)throw new lr;return s.then((e=>t(e,r,i)))}return t(s,r,i)}}Hr(e,"~standard",(()=>({validate:t=>{try{const n=Mo(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch(n){return Lo(e,t).then((e=>e.success?{value:e.data}:{issues:e.error?.issues}))}},vendor:"zod",version:1})))})),ei=ur("$ZodString",((e,t)=>{var n;Qo.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??(n=e._zod.bag,new RegExp(`^${n?`[\\s\\S]{${n?.minimum??0},${n?.maximum??""}}`:"[\\s\\S]*"}$`)),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch(r){}return"string"==typeof n.value||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}})),ti=ur("$ZodStringFormat",((e,t)=>{To.init(e,t),ei.init(e,t)})),ni=ur("$ZodGUID",((e,t)=>{t.pattern??(t.pattern=Br),ti.init(e,t)})),ri=ur("$ZodUUID",((e,t)=>{if(t.version){const e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(void 0===e)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Er(e))}else t.pattern??(t.pattern=Er());ti.init(e,t)})),oi=ur("$ZodEmail",((e,t)=>{t.pattern??(t.pattern=xr),ti.init(e,t)})),ii=ur("$ZodURL",((e,t)=>{ti.init(e,t),e._zod.check=n=>{try{const r=n.value.trim();if(!t.normalize&&t.protocol?.source===Or.source&&!/^https?:\/\//i.test(r))return void n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});const o=new URL(r);return t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),void(t.normalize?n.value=o.href:n.value=r)}catch(r){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}})),si=ur("$ZodEmoji",((e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),ti.init(e,t)})),ai=ur("$ZodNanoID",((e,t)=>{t.pattern??(t.pattern=br),ti.init(e,t)})),ci=ur("$ZodCUID",((e,t)=>{t.pattern??(t.pattern=pr),ti.init(e,t)})),ui=ur("$ZodCUID2",((e,t)=>{t.pattern??(t.pattern=mr),ti.init(e,t)})),li=ur("$ZodULID",((e,t)=>{t.pattern??(t.pattern=gr),ti.init(e,t)})),fi=ur("$ZodXID",((e,t)=>{t.pattern??(t.pattern=yr),ti.init(e,t)})),hi=ur("$ZodKSUID",((e,t)=>{t.pattern??(t.pattern=wr),ti.init(e,t)})),di=ur("$ZodISODateTime",((e,t)=>{t.pattern??(t.pattern=function(e){const t=Vr({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${Ir}T(?:${r})$`)}(t)),ti.init(e,t)})),pi=ur("$ZodISODate",((e,t)=>{t.pattern??(t.pattern=_r),ti.init(e,t)})),mi=ur("$ZodISOTime",((e,t)=>{t.pattern??(t.pattern=new RegExp(`^${Vr(t)}$`)),ti.init(e,t)})),gi=ur("$ZodISODuration",((e,t)=>{t.pattern??(t.pattern=vr),ti.init(e,t)})),yi=ur("$ZodIPv4",((e,t)=>{t.pattern??(t.pattern=Tr),ti.init(e,t),e._zod.bag.format="ipv4"})),wi=ur("$ZodIPv6",((e,t)=>{t.pattern??(t.pattern=Rr),ti.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}})),bi=ur("$ZodCIDRv4",((e,t)=>{t.pattern??(t.pattern=zr),ti.init(e,t)})),vi=ur("$ZodCIDRv6",((e,t)=>{t.pattern??(t.pattern=Ar),ti.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(2!==r.length)throw new Error;const[e,t]=r;if(!t)throw new Error;const n=Number(t);if(`${n}`!==t)throw new Error;if(n<0||n>128)throw new Error;new URL(`http://[${e}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}}));function Bi(e){if(""===e)return!0;if(/\s/.test(e))return!1;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const Ei=ur("$ZodBase64",((e,t)=>{t.pattern??(t.pattern=kr),ti.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Bi(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}));const xi=ur("$ZodBase64URL",((e,t)=>{t.pattern??(t.pattern=Sr),ti.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{(function(e){if(!Sr.test(e))return!1;const t=e.replace(/[-_]/g,(e=>"-"===e?"+":"/"));return Bi(t.padEnd(4*Math.ceil(t.length/4),"="))})(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}})),Ti=ur("$ZodE164",((e,t)=>{t.pattern??(t.pattern=$r),ti.init(e,t)}));const Ri=ur("$ZodJWT",((e,t)=>{ti.init(e,t),e._zod.check=n=>{(function(e,t=null){try{const n=e.split(".");if(3!==n.length)return!1;const[r]=n;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&"JWT"!==o?.typ||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}})(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}})),zi=ur("$ZodNumber",((e,t)=>{Qo.init(e,t),e._zod.pattern=e._zod.bag.pattern??Pr,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch(s){}const o=n.value;if("number"==typeof o&&!Number.isNaN(o)&&Number.isFinite(o))return n;const i="number"==typeof o?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),n}})),Ai=ur("$ZodNumberFormat",((e,t)=>{vo.init(e,t),zi.init(e,t)})),ki=ur("$ZodBoolean",((e,t)=>{Qo.init(e,t),e._zod.pattern=Cr,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(i){}const o=n.value;return"boolean"==typeof o||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}})),Si=ur("$ZodBigInt",((e,t)=>{Qo.init(e,t),e._zod.pattern=Dr,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=BigInt(n.value)}catch(o){}return"bigint"==typeof n.value||n.issues.push({expected:"bigint",code:"invalid_type",input:n.value,inst:e}),n}})),Oi=ur("$ZodAny",((e,t)=>{Qo.init(e,t),e._zod.parse=e=>e})),$i=ur("$ZodUnknown",((e,t)=>{Qo.init(e,t),e._zod.parse=e=>e})),Ii=ur("$ZodNever",((e,t)=>{Qo.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)}));function _i(e,t,n){e.issues.length&&t.issues.push(...uo(n,e.issues)),t.value[n]=e.value}const Vi=ur("$ZodArray",((e,t)=>{Qo.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.value=Array(o.length);const i=[];for(let e=0;e<o.length;e++){const s=o[e],a=t.element._zod.run({value:s,issues:[]},r);a instanceof Promise?i.push(a.then((t=>_i(t,n,e)))):_i(a,n,e)}return i.length?Promise.all(i).then((()=>n)):n}}));function Di(e,t,n,r,o,i){const s=n in r;if(e.issues.length){if(o&&i&&!s)return;t.issues.push(...uo(n,e.issues))}s||o?void 0===e.value?s&&(t.value[n]=void 0):t.value[n]=e.value:e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]})}function Ni(e){const t=Object.keys(e.shape);for(const o of t)if(!e.shape?.[o]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${o}": expected a Zod schema`);const n=(r=e.shape,Object.keys(r).filter((e=>"optional"===r[e]._zod.optin&&"optional"===r[e]._zod.optout)));var r;return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Pi(e,t,n,r,o,i){const s=[],a=o.keySet,c=o.catchall._zod,u=c.def.type,l="optional"===c.optin,f="optional"===c.optout;for(const h in t){if("__proto__"===h)continue;if(a.has(h))continue;if("never"===u){s.push(h);continue}const o=c.run({value:t[h],issues:[]},r);o instanceof Promise?e.push(o.then((e=>Di(e,n,h,t,l,f)))):Di(o,n,h,t,l,f)}return s.length&&n.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i}),e.length?Promise.all(e).then((()=>n)):n}const Ci=ur("$ZodObject",((e,t)=>{Qo.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!n?.get){const e=t.shape;Object.defineProperty(t,"shape",{get:()=>{const n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}const r=Lr((()=>Ni(t)));Hr(e._zod,"propValues",(()=>{const e=t.shape,n={};for(const t in e){const r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(const e of r.values)n[t].add(e)}}return n}));const o=Yr,i=t.catchall;let s;e._zod.parse=(t,n)=>{s??(s=r.value);const a=t.value;if(!o(a))return t.issues.push({expected:"object",code:"invalid_type",input:a,inst:e}),t;t.value={};const c=[],u=s.shape;for(const e of s.keys){const r=u[e],o="optional"===r._zod.optin,i="optional"===r._zod.optout,s=r._zod.run({value:a[e],issues:[]},n);s instanceof Promise?c.push(s.then((n=>Di(n,t,e,a,o,i)))):Di(s,t,e,a,o,i)}return i?Pi(c,a,t,n,r.value,e):c.length?Promise.all(c).then((()=>t)):t}})),Fi=ur("$ZodObjectJIT",((e,t)=>{Ci.init(e,t);const n=e._zod.parse,r=Lr((()=>Ni(t)));let o;const i=Yr,s=!hr.jitless,a=s&&Qr.value,c=t.catchall;let u;e._zod.parse=(l,f)=>{u??(u=r.value);const h=l.value;return i(h)?s&&a&&!1===f?.async&&!0!==f.jitless?(o||(o=(e=>{const t=new Io(["shape","payload","ctx"]),n=r.value,o=e=>{const t=Kr(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");const i=Object.create(null);let s=0;for(const r of n.keys)i[r]="key_"+s++;t.write("const newResult = {};");for(const r of n.keys){const n=i[r],s=Kr(r),a=e[r],c="optional"===a?._zod?.optin,u="optional"===a?._zod?.optout;t.write(`const ${n} = ${o(r)};`),c&&u?t.write(`\n if (${n}.issues.length) {\n if (${s} in input) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${s}, ...iss.path] : [${s}]\n })));\n }\n }\n \n if (${n}.value === undefined) {\n if (${s} in input) {\n newResult[${s}] = undefined;\n }\n } else {\n newResult[${s}] = ${n}.value;\n }\n \n `):c?t.write(`\n if (${n}.issues.length) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${s}, ...iss.path] : [${s}]\n })));\n }\n \n if (${n}.value === undefined) {\n if (${s} in input) {\n newResult[${s}] = undefined;\n }\n } else {\n newResult[${s}] = ${n}.value;\n }\n \n `):t.write(`\n const ${n}_present = ${s} in input;\n if (${n}.issues.length) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${s}, ...iss.path] : [${s}]\n })));\n }\n if (!${n}_present && !${n}.issues.length) {\n payload.issues.push({\n code: "invalid_type",\n expected: "nonoptional",\n input: undefined,\n path: [${s}]\n });\n }\n\n if (${n}_present) {\n if (${n}.value === undefined) {\n newResult[${s}] = undefined;\n } else {\n newResult[${s}] = ${n}.value;\n }\n }\n\n `)}t.write("payload.value = newResult;"),t.write("return payload;");const a=t.compile();return(t,n)=>a(e,t,n)})(t.shape)),l=o(l,f),c?Pi([],h,l,f,u,e):l):n(l,f):(l.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),l)}}));function Gi(e,t,n,r){for(const i of e)if(0===i.issues.length)return t.value=i.value,t;const o=e.filter((e=>!ao(e)));return 1===o.length?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map((e=>e.issues.map((e=>fo(e,r,dr())))))}),t)}const Mi=ur("$ZodUnion",((e,t)=>{Qo.init(e,t),Hr(e._zod,"optin",(()=>t.options.some((e=>"optional"===e._zod.optin))?"optional":void 0)),Hr(e._zod,"optout",(()=>t.options.some((e=>"optional"===e._zod.optout))?"optional":void 0)),Hr(e._zod,"values",(()=>{if(t.options.every((e=>e._zod.values)))return new Set(t.options.flatMap((e=>Array.from(e._zod.values))))})),Hr(e._zod,"pattern",(()=>{if(t.options.every((e=>e._zod.pattern))){const e=t.options.map((e=>e._zod.pattern));return new RegExp(`^(${e.map((e=>Zr(e.source))).join("|")})$`)}}));const n=1===t.options.length?t.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(n)return n(r,o);let i=!1;const s=[];for(const e of t.options){const t=e._zod.run({value:r.value,issues:[]},o);if(t instanceof Promise)s.push(t),i=!0;else{if(0===t.issues.length)return t;s.push(t)}}return i?Promise.all(s).then((t=>Gi(t,r,e,o))):Gi(s,r,e,o)}}));const Ui=ur("$ZodIntersection",((e,t)=>{Qo.init(e,t),e._zod.parse=(e,n)=>{const r=e.value,o=t.left._zod.run({value:r,issues:[]},n),i=t.right._zod.run({value:r,issues:[]},n);return o instanceof Promise||i instanceof Promise?Promise.all([o,i]).then((([t,n])=>ji(e,t,n))):ji(e,o,i)}}));function Li(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(eo(e)&&eo(t)){const n=Object.keys(t),r=Object.keys(e).filter((e=>-1!==n.indexOf(e))),o={...e,...t};for(const i of r){const n=Li(e[i],t[i]);if(!n.valid)return{valid:!1,mergeErrorPath:[i,...n.mergeErrorPath]};o[i]=n.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=Li(e[r],t[r]);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function ji(e,t,n){const r=new Map;let o;for(const a of t.issues)if("unrecognized_keys"===a.code){o??(o=a);for(const e of a.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(a);for(const a of n.issues)if("unrecognized_keys"===a.code)for(const e of a.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(a);const i=[...r].filter((([,e])=>e.l&&e.r)).map((([e])=>e));if(i.length&&o&&e.issues.push({...o,keys:i}),ao(e))return e;const s=Li(t.value,n.value);if(!s.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return e.value=s.data,e}const Zi=ur("$ZodTuple",((e,t)=>{Qo.init(e,t);const n=t.items;e._zod.parse=(r,o)=>{const i=r.value;if(!Array.isArray(i))return r.issues.push({input:i,inst:e,expected:"tuple",code:"invalid_type"}),r;r.value=[];const s=[],a=qi(n,"optin"),c=qi(n,"optout");if(!t.rest){if(i.length<a)return r.issues.push({code:"too_small",minimum:a,inclusive:!0,input:i,inst:e,origin:"array"}),r;i.length>n.length&&r.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:i,inst:e,origin:"array"})}const u=new Array(n.length);for(let e=0;e<n.length;e++){const t=n[e]._zod.run({value:i[e],issues:[]},o);t instanceof Promise?s.push(t.then((t=>{u[e]=t}))):u[e]=t}if(t.rest){let e=n.length-1;const a=i.slice(n.length);for(const n of a){e++;const i=t.rest._zod.run({value:n,issues:[]},o);i instanceof Promise?s.push(i.then((t=>Hi(t,r,e)))):Hi(i,r,e)}}return s.length?Promise.all(s).then((()=>Wi(u,r,n,i,c))):Wi(u,r,n,i,c)}}));function qi(e,t){for(let n=e.length-1;n>=0;n--)if("optional"!==e[n]._zod[t])return n+1;return 0}function Hi(e,t,n){e.issues.length&&t.issues.push(...uo(n,e.issues)),t.value[n]=e.value}function Wi(e,t,n,r,o){for(let i=0;i<n.length;i++){const n=e[i],s=i<r.length;if(n.issues.length){if(!s&&i>=o){t.value.length=i;break}t.issues.push(...uo(i,n.issues))}t.value[i]=n.value}for(let i=t.value.length-1;i>=r.length&&("optional"===n[i]._zod.optout&&void 0===t.value[i]);i--)t.value.length=i;return t}const Ji=ur("$ZodRecord",((e,t)=>{Qo.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!eo(o))return n.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),n;const i=[],s=t.keyType._zod.values;if(s){n.value={};const a=new Set;for(const u of s)if("string"==typeof u||"number"==typeof u||"symbol"==typeof u){a.add("number"==typeof u?u.toString():u);const s=t.keyType._zod.run({value:u,issues:[]},r);if(s instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(s.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:s.issues.map((e=>fo(e,r,dr()))),input:u,path:[u],inst:e});continue}const c=s.value,l=t.valueType._zod.run({value:o[u],issues:[]},r);l instanceof Promise?i.push(l.then((e=>{e.issues.length&&n.issues.push(...uo(u,e.issues)),n.value[c]=e.value}))):(l.issues.length&&n.issues.push(...uo(u,l.issues)),n.value[c]=l.value)}let c;for(const e in o)a.has(e)||(c=c??[],c.push(e));c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:c})}else{n.value={};for(const s of Reflect.ownKeys(o)){if("__proto__"===s)continue;if(!Object.prototype.propertyIsEnumerable.call(o,s))continue;let a=t.keyType._zod.run({value:s,issues:[]},r);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if("string"==typeof s&&Pr.test(s)&&a.issues.length){const e=t.keyType._zod.run({value:Number(s),issues:[]},r);if(e instanceof Promise)throw new Error("Async schemas not supported in object keys currently");0===e.issues.length&&(a=e)}if(a.issues.length){"loose"===t.mode?n.value[s]=o[s]:n.issues.push({code:"invalid_key",origin:"record",issues:a.issues.map((e=>fo(e,r,dr()))),input:s,path:[s],inst:e});continue}const c=t.valueType._zod.run({value:o[s],issues:[]},r);c instanceof Promise?i.push(c.then((e=>{e.issues.length&&n.issues.push(...uo(s,e.issues)),n.value[a.value]=e.value}))):(c.issues.length&&n.issues.push(...uo(s,c.issues)),n.value[a.value]=c.value)}}return i.length?Promise.all(i).then((()=>n)):n}}));const Ki=ur("$ZodEnum",((e,t)=>{Qo.init(e,t);const n=Mr(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter((e=>no.has(typeof e))).map((e=>"string"==typeof e?ro(e):e.toString())).join("|")})$`),e._zod.parse=(t,o)=>{const i=t.value;return r.has(i)||t.issues.push({code:"invalid_value",values:n,input:i,inst:e}),t}})),Xi=ur("$ZodLiteral",((e,t)=>{if(Qo.init(e,t),0===t.values.length)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map((e=>"string"==typeof e?ro(e):e?ro(e.toString()):String(e))).join("|")})$`),e._zod.parse=(r,o)=>{const i=r.value;return n.has(i)||r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}})),Yi=ur("$ZodTransform",((e,t)=>{Qo.init(e,t),e._zod.optin="optional",e._zod.parse=(n,r)=>{if("backward"===r.direction)throw new fr(e.constructor.name);const o=t.transform(n.value,n);if(r.async){return(o instanceof Promise?o:Promise.resolve(o)).then((e=>(n.value=e,n.fallback=!0,n)))}if(o instanceof Promise)throw new lr;return n.value=o,n.fallback=!0,n}}));function Qi(e,t){return void 0===t&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}const es=ur("$ZodOptional",((e,t)=>{Qo.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Hr(e._zod,"values",(()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0)),Hr(e._zod,"pattern",(()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${Zr(e.source)})?$`):void 0})),e._zod.parse=(e,n)=>{if("optional"===t.innerType._zod.optin){const r=e.value,o=t.innerType._zod.run(e,n);return o instanceof Promise?o.then((e=>Qi(e,r))):Qi(o,r)}return void 0===e.value?e:t.innerType._zod.run(e,n)}})),ts=ur("$ZodExactOptional",((e,t)=>{es.init(e,t),Hr(e._zod,"values",(()=>t.innerType._zod.values)),Hr(e._zod,"pattern",(()=>t.innerType._zod.pattern)),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)})),ns=ur("$ZodNullable",((e,t)=>{Qo.init(e,t),Hr(e._zod,"optin",(()=>t.innerType._zod.optin)),Hr(e._zod,"optout",(()=>t.innerType._zod.optout)),Hr(e._zod,"pattern",(()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${Zr(e.source)}|null)$`):void 0})),Hr(e._zod,"values",(()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0)),e._zod.parse=(e,n)=>null===e.value?e:t.innerType._zod.run(e,n)})),rs=ur("$ZodDefault",((e,t)=>{Qo.init(e,t),e._zod.optin="optional",Hr(e._zod,"values",(()=>t.innerType._zod.values)),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);if(void 0===e.value)return e.value=t.defaultValue,e;const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then((e=>os(e,t))):os(r,t)}}));function os(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}const is=ur("$ZodPrefault",((e,t)=>{Qo.init(e,t),e._zod.optin="optional",Hr(e._zod,"values",(()=>t.innerType._zod.values)),e._zod.parse=(e,n)=>("backward"===n.direction||void 0===e.value&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))})),ss=ur("$ZodNonOptional",((e,t)=>{Qo.init(e,t),Hr(e._zod,"values",(()=>{const e=t.innerType._zod.values;return e?new Set([...e].filter((e=>void 0!==e))):void 0})),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then((t=>as(t,e))):as(o,e)}}));function as(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const cs=ur("$ZodCatch",((e,t)=>{Qo.init(e,t),e._zod.optin="optional",Hr(e._zod,"optout",(()=>t.innerType._zod.optout)),Hr(e._zod,"values",(()=>t.innerType._zod.values)),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then((r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map((e=>fo(e,n,dr())))},input:e.value}),e.issues=[],e.fallback=!0),e))):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map((e=>fo(e,n,dr())))},input:e.value}),e.issues=[],e.fallback=!0),e)}})),us=ur("$ZodPipe",((e,t)=>{Qo.init(e,t),Hr(e._zod,"values",(()=>t.in._zod.values)),Hr(e._zod,"optin",(()=>t.in._zod.optin)),Hr(e._zod,"optout",(()=>t.out._zod.optout)),Hr(e._zod,"propValues",(()=>t.in._zod.propValues)),e._zod.parse=(e,n)=>{if("backward"===n.direction){const r=t.out._zod.run(e,n);return r instanceof Promise?r.then((e=>ls(e,t.in,n))):ls(r,t.in,n)}const r=t.in._zod.run(e,n);return r instanceof Promise?r.then((e=>ls(e,t.out,n))):ls(r,t.out,n)}}));function ls(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}const fs=ur("$ZodReadonly",((e,t)=>{Qo.init(e,t),Hr(e._zod,"propValues",(()=>t.innerType._zod.propValues)),Hr(e._zod,"values",(()=>t.innerType._zod.values)),Hr(e._zod,"optin",(()=>t.innerType?._zod?.optin)),Hr(e._zod,"optout",(()=>t.innerType?._zod?.optout)),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(hs):hs(r)}}));function hs(e){return e.value=Object.freeze(e.value),e}const ds=ur("$ZodFunction",((e,t)=>(Qo.init(e,t),e._def=t,e._zod.def=t,e.implement=t=>{if("function"!=typeof t)throw new Error("implement() must be called with a function");return function(...n){const r=e._def.input?Po(e._def.input,n):n,o=Reflect.apply(t,this,r);return e._def.output?Po(e._def.output,o):o}},e.implementAsync=t=>{if("function"!=typeof t)throw new Error("implementAsync() must be called with a function");return async function(...n){const r=e._def.input?await Fo(e._def.input,n):n,o=await Reflect.apply(t,this,r);return e._def.output?await Fo(e._def.output,o):o}},e._zod.parse=(t,n)=>{if("function"!=typeof t.value)return t.issues.push({code:"invalid_type",expected:"function",input:t.value,inst:e}),t;const r=e._def.output&&"promise"===e._def.output._zod.def.type;return t.value=r?e.implementAsync(t.value):e.implement(t.value),t},e.input=(...t)=>{const n=e.constructor;return Array.isArray(t[0])?new n({type:"function",input:new Zi({type:"tuple",items:t[0],rest:t[1]}),output:e._def.output}):new n({type:"function",input:t[0],output:e._def.output})},e.output=t=>new(0,e.constructor)({type:"function",input:e._def.input,output:t}),e))),ps=ur("$ZodCustom",((e,t)=>{mo.init(e,t),Qo.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then((t=>ms(t,n,r,e)));ms(o,n,r,e)}}));function ms(e,t,n,r){if(!e){const e={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(po(e))}}var gs;Symbol("ZodOutput"),Symbol("ZodInput");class ys{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const n=t[0];return this._map.set(e,n),n&&"object"==typeof n&&"id"in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&"object"==typeof t&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const n={...this.get(t)??{}};delete n.id;const r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}(gs=globalThis).__zod_globalRegistry??(gs.__zod_globalRegistry=new ys);const ws=globalThis.__zod_globalRegistry;function bs(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...io(t)})}function vs(e,t){return new yo({check:"less_than",...io(t),value:e,inclusive:!1})}function Bs(e,t){return new yo({check:"less_than",...io(t),value:e,inclusive:!0})}function Es(e,t){return new wo({check:"greater_than",...io(t),value:e,inclusive:!1})}function xs(e,t){return new wo({check:"greater_than",...io(t),value:e,inclusive:!0})}function Ts(e,t){return new bo({check:"multiple_of",...io(t),value:e})}function Rs(e,t){return new Bo({check:"max_length",...io(t),maximum:e})}function zs(e,t){return new Eo({check:"min_length",...io(t),minimum:e})}function As(e,t){return new xo({check:"length_equals",...io(t),length:e})}function ks(e){return new $o({check:"overwrite",tx:e})}function Ss(e,t){const n=function(e,t){const n=new mo({check:"custom",...io(t)});return n._zod.check=e,n}((t=>(t.addIssue=e=>{if("string"==typeof e)t.issues.push(po(e,t.value,n._zod.def));else{const r=e;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),r.input??(r.input=t.value),r.inst??(r.inst=n),r.continue??(r.continue=!n._zod.def.abort),t.issues.push(po(r))}},e(t.value,t))),t);return n}function Os(e){let t=e?.target??"draft-2020-12";return"draft-4"===t&&(t="draft-04"),"draft-7"===t&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??ws,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function $s(e,t,n={path:[],schemaPath:[]}){var r;const o=e._zod.def,i=t.seen.get(e);if(i){i.count++;return n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema}const s={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,s);const a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{const r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,r);else{const n=s.schema,i=t.processors[o.type];if(!i)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);i(e,t,n,r)}const i=e._zod.parent;i&&(s.ref||(s.ref=i),$s(i,t,r),t.seen.get(i).isParent=!0)}const c=t.metadataRegistry.get(e);c&&Object.assign(s.schema,c),"input"===t.io&&Vs(e)&&(delete s.schema.examples,delete s.schema.default),"input"===t.io&&"_prefault"in s.schema&&((r=s.schema).default??(r.default=s.schema._prefault)),delete s.schema._prefault;return t.seen.get(e).schema}function Is(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const i of e.seen.entries()){const t=e.metadataRegistry.get(i[0])?.id;if(t){const e=r.get(t);if(e&&e!==i[0])throw new Error(`Duplicate schema id "${t}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(t,i[0])}}const o=t=>{if(t[1].schema.$ref)return;const r=t[1],{ref:o,defId:i}=(t=>{const r="draft-2020-12"===e.target?"$defs":"definitions";if(e.external){const n=e.external.registry.get(t[0])?.id,o=e.external.uri??(e=>e);if(n)return{ref:o(n)};const i=t[1].defId??t[1].schema.id??"schema"+e.counter++;return t[1].defId=i,{defId:i,ref:`${o("__shared")}#/${r}/${i}`}}if(t[1]===n)return{ref:"#"};const o=`#/${r}/`,i=t[1].schema.id??"__schema"+e.counter++;return{defId:i,ref:o+i}})(t);r.def={...r.schema},i&&(r.defId=i);const s=r.schema;for(const e in s)delete s[e];s.$ref=o};if("throw"===e.cycles)for(const i of e.seen.entries()){const e=i[1];if(e.cycle)throw new Error(`Cycle detected: #/${e.cycle?.join("/")}/<root>\n\nSet the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const i of e.seen.entries()){const n=i[1];if(t===i[0]){o(i);continue}if(e.external){const n=e.external.registry.get(i[0])?.id;if(t!==i[0]&&n){o(i);continue}}const r=e.metadataRegistry.get(i[0])?.id;r?o(i):(n.cycle||n.count>1&&"ref"===e.reused)&&o(i)}}function _s(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=t=>{const n=e.seen.get(t);if(null===n.ref)return;const o=n.def??n.schema,i={...o},s=n.ref;if(n.ref=null,s){r(s);const n=e.seen.get(s),a=n.schema;!a.$ref||"draft-07"!==e.target&&"draft-04"!==e.target&&"openapi-3.0"!==e.target?Object.assign(o,a):(o.allOf=o.allOf??[],o.allOf.push(a)),Object.assign(o,i);if(t._zod.parent===s)for(const e in o)"$ref"!==e&&"allOf"!==e&&(e in i||delete o[e]);if(a.$ref&&n.def)for(const e in o)"$ref"!==e&&"allOf"!==e&&e in n.def&&JSON.stringify(o[e])===JSON.stringify(n.def[e])&&delete o[e]}const a=t._zod.parent;if(a&&a!==s){r(a);const t=e.seen.get(a);if(t?.schema.$ref&&(o.$ref=t.schema.$ref,t.def))for(const e in o)"$ref"!==e&&"allOf"!==e&&e in t.def&&JSON.stringify(o[e])===JSON.stringify(t.def[e])&&delete o[e]}e.override({zodSchema:t,jsonSchema:o,path:n.path??[]})};for(const c of[...e.seen.entries()].reverse())r(c[0]);const o={};if("draft-2020-12"===e.target?o.$schema="https://json-schema.org/draft/2020-12/schema":"draft-07"===e.target?o.$schema="http://json-schema.org/draft-07/schema#":"draft-04"===e.target?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const n=e.external.registry.get(t)?.id;if(!n)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(n)}Object.assign(o,n.def??n.schema);const i=e.metadataRegistry.get(t)?.id;void 0!==i&&o.id===i&&delete o.id;const s=e.external?.defs??{};for(const c of e.seen.entries()){const e=c[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,s[e.defId]=e.def)}e.external||Object.keys(s).length>0&&("draft-2020-12"===e.target?o.$defs=s:o.definitions=s);try{const n=JSON.parse(JSON.stringify(o));return Object.defineProperty(n,"~standard",{value:{...t["~standard"],jsonSchema:{input:Ds(t,"input",e.processors),output:Ds(t,"output",e.processors)}},enumerable:!1,writable:!1}),n}catch(a){throw new Error("Error converting schema to JSON.")}}function Vs(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if("transform"===r.type)return!0;if("array"===r.type)return Vs(r.element,n);if("set"===r.type)return Vs(r.valueType,n);if("lazy"===r.type)return Vs(r.getter(),n);if("promise"===r.type||"optional"===r.type||"nonoptional"===r.type||"nullable"===r.type||"readonly"===r.type||"default"===r.type||"prefault"===r.type)return Vs(r.innerType,n);if("intersection"===r.type)return Vs(r.left,n)||Vs(r.right,n);if("record"===r.type||"map"===r.type)return Vs(r.keyType,n)||Vs(r.valueType,n);if("pipe"===r.type)return!!e._zod.traits.has("$ZodCodec")||(Vs(r.in,n)||Vs(r.out,n));if("object"===r.type){for(const e in r.shape)if(Vs(r.shape[e],n))return!0;return!1}if("union"===r.type){for(const e of r.options)if(Vs(e,n))return!0;return!1}if("tuple"===r.type){for(const e of r.items)if(Vs(e,n))return!0;return!(!r.rest||!Vs(r.rest,n))}return!1}const Ds=(e,t,n={})=>r=>{const{libraryOptions:o,target:i}=r??{},s=Os({...o??{},target:i,io:t,processors:n});return $s(e,s),Is(s,e),_s(s,e)};const Ns={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Ps=(e,t,n,r)=>{const o=n;o.type="string";const{minimum:i,maximum:s,format:a,patterns:c,contentEncoding:u}=e._zod.bag;if("number"==typeof i&&(o.minLength=i),"number"==typeof s&&(o.maxLength=s),a&&(o.format=Ns[a]??a,""===o.format&&delete o.format,"time"===a&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){const e=[...c];1===e.length?o.pattern=e[0].source:e.length>1&&(o.allOf=[...e.map((e=>({..."draft-07"===t.target||"draft-04"===t.target||"openapi-3.0"===t.target?{type:"string"}:{},pattern:e.source})))])}},Cs=(e,t,n,r)=>{const o=n,{minimum:i,maximum:s,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:l}=e._zod.bag;"string"==typeof a&&a.includes("int")?o.type="integer":o.type="number";const f="number"==typeof l&&l>=(i??Number.NEGATIVE_INFINITY),h="number"==typeof u&&u<=(s??Number.POSITIVE_INFINITY),d="draft-04"===t.target||"openapi-3.0"===t.target;f?d?(o.minimum=l,o.exclusiveMinimum=!0):o.exclusiveMinimum=l:"number"==typeof i&&(o.minimum=i),h?d?(o.maximum=u,o.exclusiveMaximum=!0):o.exclusiveMaximum=u:"number"==typeof s&&(o.maximum=s),"number"==typeof c&&(o.multipleOf=c)},Fs=(e,t,n,r)=>{n.type="boolean"},Gs=(e,t,n,r)=>{if("throw"===t.unrepresentable)throw new Error("BigInt cannot be represented in JSON Schema")},Ms=(e,t,n,r)=>{n.not={}},Us=(e,t,n,r)=>{const o=Mr(e._zod.def.entries);o.every((e=>"number"==typeof e))&&(n.type="number"),o.every((e=>"string"==typeof e))&&(n.type="string"),n.enum=o},Ls=(e,t,n,r)=>{const o=e._zod.def,i=[];for(const s of o.values)if(void 0===s){if("throw"===t.unrepresentable)throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if("bigint"==typeof s){if("throw"===t.unrepresentable)throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(s))}else i.push(s);if(0===i.length);else if(1===i.length){const e=i[0];n.type=null===e?"null":typeof e,"draft-04"===t.target||"openapi-3.0"===t.target?n.enum=[e]:n.const=e}else i.every((e=>"number"==typeof e))&&(n.type="number"),i.every((e=>"string"==typeof e))&&(n.type="string"),i.every((e=>"boolean"==typeof e))&&(n.type="boolean"),i.every((e=>null===e))&&(n.type="null"),n.enum=i},js=(e,t,n,r)=>{if("throw"===t.unrepresentable)throw new Error("Custom types cannot be represented in JSON Schema")},Zs=(e,t,n,r)=>{if("throw"===t.unrepresentable)throw new Error("Function types cannot be represented in JSON Schema")},qs=(e,t,n,r)=>{if("throw"===t.unrepresentable)throw new Error("Transforms cannot be represented in JSON Schema")},Hs=(e,t,n,r)=>{const o=n,i=e._zod.def,{minimum:s,maximum:a}=e._zod.bag;"number"==typeof s&&(o.minItems=s),"number"==typeof a&&(o.maxItems=a),o.type="array",o.items=$s(i.element,t,{...r,path:[...r.path,"items"]})},Ws=(e,t,n,r)=>{const o=n,i=e._zod.def;o.type="object",o.properties={};const s=i.shape;for(const u in s)o.properties[u]=$s(s[u],t,{...r,path:[...r.path,"properties",u]});const a=new Set(Object.keys(s)),c=new Set([...a].filter((e=>{const n=i.shape[e]._zod;return"input"===t.io?void 0===n.optin:void 0===n.optout})));c.size>0&&(o.required=Array.from(c)),"never"===i.catchall?._zod.def.type?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=$s(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):"output"===t.io&&(o.additionalProperties=!1)},Js=(e,t,n,r)=>{const o=e._zod.def,i=!1===o.inclusive,s=o.options.map(((e,n)=>$s(e,t,{...r,path:[...r.path,i?"oneOf":"anyOf",n]})));i?n.oneOf=s:n.anyOf=s},Ks=(e,t,n,r)=>{const o=e._zod.def,i=$s(o.left,t,{...r,path:[...r.path,"allOf",0]}),s=$s(o.right,t,{...r,path:[...r.path,"allOf",1]}),a=e=>"allOf"in e&&1===Object.keys(e).length,c=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]];n.allOf=c},Xs=(e,t,n,r)=>{const o=n,i=e._zod.def;o.type="array";const s="draft-2020-12"===t.target?"prefixItems":"items",a="draft-2020-12"===t.target||"openapi-3.0"===t.target?"items":"additionalItems",c=i.items.map(((e,n)=>$s(e,t,{...r,path:[...r.path,s,n]}))),u=i.rest?$s(i.rest,t,{...r,path:[...r.path,a,..."openapi-3.0"===t.target?[i.items.length]:[]]}):null;"draft-2020-12"===t.target?(o.prefixItems=c,u&&(o.items=u)):"openapi-3.0"===t.target?(o.items={anyOf:c},u&&o.items.anyOf.push(u),o.minItems=c.length,u||(o.maxItems=c.length)):(o.items=c,u&&(o.additionalItems=u));const{minimum:l,maximum:f}=e._zod.bag;"number"==typeof l&&(o.minItems=l),"number"==typeof f&&(o.maxItems=f)},Ys=(e,t,n,r)=>{const o=n,i=e._zod.def;o.type="object";const s=i.keyType,a=s._zod.bag,c=a?.patterns;if("loose"===i.mode&&c&&c.size>0){const e=$s(i.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});o.patternProperties={};for(const t of c)o.patternProperties[t.source]=e}else"draft-07"!==t.target&&"draft-2020-12"!==t.target||(o.propertyNames=$s(i.keyType,t,{...r,path:[...r.path,"propertyNames"]})),o.additionalProperties=$s(i.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const u=s._zod.values;if(u){const e=[...u].filter((e=>"string"==typeof e||"number"==typeof e));e.length>0&&(o.required=e)}},Qs=(e,t,n,r)=>{const o=e._zod.def,i=$s(o.innerType,t,r),s=t.seen.get(e);"openapi-3.0"===t.target?(s.ref=o.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},ea=(e,t,n,r)=>{const o=e._zod.def;$s(o.innerType,t,r);t.seen.get(e).ref=o.innerType},ta=(e,t,n,r)=>{const o=e._zod.def;$s(o.innerType,t,r);t.seen.get(e).ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))},na=(e,t,n,r)=>{const o=e._zod.def;$s(o.innerType,t,r);t.seen.get(e).ref=o.innerType,"input"===t.io&&(n._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},ra=(e,t,n,r)=>{const o=e._zod.def;$s(o.innerType,t,r);let i;t.seen.get(e).ref=o.innerType;try{i=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=i},oa=(e,t,n,r)=>{const o=e._zod.def,i=o.in._zod.traits.has("$ZodTransform"),s="input"===t.io?i?o.out:o.in:o.out;$s(s,t,r);t.seen.get(e).ref=s},ia=(e,t,n,r)=>{const o=e._zod.def;$s(o.innerType,t,r);t.seen.get(e).ref=o.innerType,n.readOnly=!0},sa=(e,t,n,r)=>{const o=e._zod.def;$s(o.innerType,t,r);t.seen.get(e).ref=o.innerType};const aa=ur("ZodISODateTime",((e,t)=>{di.init(e,t),Da.init(e,t)}));function ca(e){return function(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...io(t)})}(aa,e)}const ua=ur("ZodISODate",((e,t)=>{pi.init(e,t),Da.init(e,t)}));function la(e){return function(e,t){return new e({type:"string",format:"date",check:"string_format",...io(t)})}(ua,e)}const fa=ur("ZodISOTime",((e,t)=>{mi.init(e,t),Da.init(e,t)}));function ha(e){return function(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...io(t)})}(fa,e)}const da=ur("ZodISODuration",((e,t)=>{gi.init(e,t),Da.init(e,t)}));function pa(e){return function(e,t){return new e({type:"string",format:"duration",check:"string_format",...io(t)})}(da,e)}const ma=(e,t)=>{Vo.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>function(e,t=e=>e.message){const n={_errors:[]},r=(e,o=[])=>{for(const i of e.issues)if("invalid_union"===i.code&&i.errors.length)i.errors.map((e=>r({issues:e},[...o,...i.path])));else if("invalid_key"===i.code)r({issues:i.issues},[...o,...i.path]);else if("invalid_element"===i.code)r({issues:i.issues},[...o,...i.path]);else{const e=[...o,...i.path];if(0===e.length)n._errors.push(t(i));else{let r=n,o=0;for(;o<e.length;){const n=e[o];o===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(i))):r[n]=r[n]||{_errors:[]},r=r[n],o++}}}};return r(e),n}(e,t)},flatten:{value:t=>function(e,t=e=>e.message){const n={},r=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Ur,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Ur,2)}},isEmpty:{get:()=>0===e.issues.length}})},ga=ur("ZodError",ma,{Parent:Error}),ya=No(ga),wa=Co(ga),ba=Go(ga),va=Uo(ga),Ba=jo(ga),Ea=Zo(ga),xa=qo(ga),Ta=Ho(ga),Ra=Wo(ga),za=Jo(ga),Aa=Ko(ga),ka=Xo(ga);const Sa=new WeakMap;function Oa(e,t,n){const r=Object.getPrototypeOf(e);let o=Sa.get(r);if(o||(o=new Set,Sa.set(r,o)),!o.has(t)){o.add(t);for(const e in n){const t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){const n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}const $a=ur("ZodType",((e,t)=>(Qo.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Ds(e,"input"),output:Ds(e,"output")}}),e.toJSONSchema=((e,t={})=>n=>{const r=Os({...n,processors:t});return $s(e,r),Is(r,e),_s(r,e)})(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>ya(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>ba(e,t,n),e.parseAsync=async(t,n)=>wa(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>va(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Ba(e,t,n),e.decode=(t,n)=>Ea(e,t,n),e.encodeAsync=async(t,n)=>xa(e,t,n),e.decodeAsync=async(t,n)=>Ta(e,t,n),e.safeEncode=(t,n)=>Ra(e,t,n),e.safeDecode=(t,n)=>za(e,t,n),e.safeEncodeAsync=async(t,n)=>Aa(e,t,n),e.safeDecodeAsync=async(t,n)=>ka(e,t,n),Oa(e,"ZodType",{check(...e){const t=this.def;return this.clone(Jr(t,{checks:[...t.checks??[],...e.map((e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e))]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return oo(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(function(e,t={}){return function(e,t,n){return new e({type:"custom",check:"custom",fn:t,...io(n)})}(jc,e,t)}(e,t))},superRefine(e,t){return this.check(function(e,t){return Ss(e,t)}(e,t))},overwrite(e){return this.check(ks(e))},optional(){return Ic(this)},exactOptional(){return new _c({type:"optional",innerType:this})},nullable(){return Dc(this)},nullish(){return Ic(Dc(this))},nonoptional(e){return function(e,t){return new Cc({type:"nonoptional",innerType:e,...io(t)})}(this,e)},array(){return gc(this)},or(e){return vc([this,e])},and(e){return new Bc({type:"intersection",left:this,right:e})},transform(e){return Mc(this,Oc(e))},default(e){return t=e,new Nc({type:"default",innerType:this,get defaultValue(){return"function"==typeof t?t():to(t)}});var t},prefault(e){return t=e,new Pc({type:"prefault",innerType:this,get defaultValue(){return"function"==typeof t?t():to(t)}});var t},catch(e){return new Fc({type:"catch",innerType:this,catchValue:"function"==typeof(t=e)?t:()=>t});var t},pipe(e){return Mc(this,e)},readonly(){return new Uc({type:"readonly",innerType:this})},describe(e){const t=this.clone();return ws.add(t,{description:e}),t},meta(...e){if(0===e.length)return ws.get(this);const t=this.clone();return ws.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get:()=>ws.get(e)?.description,configurable:!0}),e))),Ia=ur("_ZodString",((e,t)=>{ei.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ps(e,t,n);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Oa(e,"_ZodString",{regex(...e){return this.check(function(e,t){return new Ro({check:"string_format",format:"regex",...io(t),pattern:e})}(...e))},includes(...e){return this.check(function(e,t){return new ko({check:"string_format",format:"includes",...io(t),includes:e})}(...e))},startsWith(...e){return this.check(function(e,t){return new So({check:"string_format",format:"starts_with",...io(t),prefix:e})}(...e))},endsWith(...e){return this.check(function(e,t){return new Oo({check:"string_format",format:"ends_with",...io(t),suffix:e})}(...e))},min(...e){return this.check(zs(...e))},max(...e){return this.check(Rs(...e))},length(...e){return this.check(As(...e))},nonempty(...e){return this.check(zs(1,...e))},lowercase(e){return this.check(function(e){return new zo({check:"string_format",format:"lowercase",...io(e)})}(e))},uppercase(e){return this.check(function(e){return new Ao({check:"string_format",format:"uppercase",...io(e)})}(e))},trim(){return this.check(ks((e=>e.trim())))},normalize(...e){return this.check(function(e){return ks((t=>t.normalize(e)))}(...e))},toLowerCase(){return this.check(ks((e=>e.toLowerCase())))},toUpperCase(){return this.check(ks((e=>e.toUpperCase())))},slugify(){return this.check(ks((e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}(e))))}})})),_a=ur("ZodString",((e,t)=>{ei.init(e,t),Ia.init(e,t),e.email=t=>e.check(function(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...io(t)})}(Na,t)),e.url=t=>e.check(function(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...io(t)})}(Fa,t)),e.jwt=t=>e.check(function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...io(t)})}(ec,t)),e.emoji=t=>e.check(function(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...io(t)})}(Ga,t)),e.guid=t=>e.check(bs(Pa,t)),e.uuid=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...io(t)})}(Ca,t)),e.uuidv4=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...io(t)})}(Ca,t)),e.uuidv6=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...io(t)})}(Ca,t)),e.uuidv7=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...io(t)})}(Ca,t)),e.nanoid=t=>e.check(function(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...io(t)})}(Ma,t)),e.guid=t=>e.check(bs(Pa,t)),e.cuid=t=>e.check(function(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...io(t)})}(Ua,t)),e.cuid2=t=>e.check(function(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...io(t)})}(La,t)),e.ulid=t=>e.check(function(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...io(t)})}(ja,t)),e.base64=t=>e.check(function(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...io(t)})}(Xa,t)),e.base64url=t=>e.check(function(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...io(t)})}(Ya,t)),e.xid=t=>e.check(function(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...io(t)})}(Za,t)),e.ksuid=t=>e.check(function(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...io(t)})}(qa,t)),e.ipv4=t=>e.check(function(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...io(t)})}(Ha,t)),e.ipv6=t=>e.check(function(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...io(t)})}(Wa,t)),e.cidrv4=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...io(t)})}(Ja,t)),e.cidrv6=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...io(t)})}(Ka,t)),e.e164=t=>e.check(function(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...io(t)})}(Qa,t)),e.datetime=t=>e.check(ca(t)),e.date=t=>e.check(la(t)),e.time=t=>e.check(ha(t)),e.duration=t=>e.check(pa(t))}));function Va(e){return function(e,t){return new e({type:"string",...io(t)})}(_a,e)}const Da=ur("ZodStringFormat",((e,t)=>{ti.init(e,t),Ia.init(e,t)})),Na=ur("ZodEmail",((e,t)=>{oi.init(e,t),Da.init(e,t)}));const Pa=ur("ZodGUID",((e,t)=>{ni.init(e,t),Da.init(e,t)}));const Ca=ur("ZodUUID",((e,t)=>{ri.init(e,t),Da.init(e,t)}));const Fa=ur("ZodURL",((e,t)=>{ii.init(e,t),Da.init(e,t)}));const Ga=ur("ZodEmoji",((e,t)=>{si.init(e,t),Da.init(e,t)}));const Ma=ur("ZodNanoID",((e,t)=>{ai.init(e,t),Da.init(e,t)}));const Ua=ur("ZodCUID",((e,t)=>{ci.init(e,t),Da.init(e,t)}));const La=ur("ZodCUID2",((e,t)=>{ui.init(e,t),Da.init(e,t)}));const ja=ur("ZodULID",((e,t)=>{li.init(e,t),Da.init(e,t)}));const Za=ur("ZodXID",((e,t)=>{fi.init(e,t),Da.init(e,t)}));const qa=ur("ZodKSUID",((e,t)=>{hi.init(e,t),Da.init(e,t)}));const Ha=ur("ZodIPv4",((e,t)=>{yi.init(e,t),Da.init(e,t)}));const Wa=ur("ZodIPv6",((e,t)=>{wi.init(e,t),Da.init(e,t)}));const Ja=ur("ZodCIDRv4",((e,t)=>{bi.init(e,t),Da.init(e,t)}));const Ka=ur("ZodCIDRv6",((e,t)=>{vi.init(e,t),Da.init(e,t)}));const Xa=ur("ZodBase64",((e,t)=>{Ei.init(e,t),Da.init(e,t)}));const Ya=ur("ZodBase64URL",((e,t)=>{xi.init(e,t),Da.init(e,t)}));const Qa=ur("ZodE164",((e,t)=>{Ti.init(e,t),Da.init(e,t)}));const ec=ur("ZodJWT",((e,t)=>{Ri.init(e,t),Da.init(e,t)}));const tc=ur("ZodNumber",((e,t)=>{zi.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Cs(e,t,n),Oa(e,"ZodNumber",{gt(e,t){return this.check(Es(e,t))},gte(e,t){return this.check(xs(e,t))},min(e,t){return this.check(xs(e,t))},lt(e,t){return this.check(vs(e,t))},lte(e,t){return this.check(Bs(e,t))},max(e,t){return this.check(Bs(e,t))},int(e){return this.check(oc(e))},safe(e){return this.check(oc(e))},positive(e){return this.check(Es(0,e))},nonnegative(e){return this.check(xs(0,e))},negative(e){return this.check(vs(0,e))},nonpositive(e){return this.check(Bs(0,e))},multipleOf(e,t){return this.check(Ts(e,t))},step(e,t){return this.check(Ts(e,t))},finite(){return this}});const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null}));function nc(e){return function(e,t){return new e({type:"number",checks:[],...io(t)})}(tc,e)}const rc=ur("ZodNumberFormat",((e,t)=>{Ai.init(e,t),tc.init(e,t)}));function oc(e){return function(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...io(t)})}(rc,e)}const ic=ur("ZodBoolean",((e,t)=>{ki.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(e,t,n)=>Fs(0,0,t)}));function sc(e){return function(e,t){return new e({type:"boolean",...io(t)})}(ic,e)}const ac=ur("ZodBigInt",((e,t)=>{Si.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(e,t,n)=>Gs(0,e),e.gte=(t,n)=>e.check(xs(t,n)),e.min=(t,n)=>e.check(xs(t,n)),e.gt=(t,n)=>e.check(Es(t,n)),e.gte=(t,n)=>e.check(xs(t,n)),e.min=(t,n)=>e.check(xs(t,n)),e.lt=(t,n)=>e.check(vs(t,n)),e.lte=(t,n)=>e.check(Bs(t,n)),e.max=(t,n)=>e.check(Bs(t,n)),e.positive=t=>e.check(Es(BigInt(0),t)),e.negative=t=>e.check(vs(BigInt(0),t)),e.nonpositive=t=>e.check(Bs(BigInt(0),t)),e.nonnegative=t=>e.check(xs(BigInt(0),t)),e.multipleOf=(t,n)=>e.check(Ts(t,n));const n=e._zod.bag;e.minValue=n.minimum??null,e.maxValue=n.maximum??null,e.format=n.format??null}));function cc(e){return function(e,t){return new e({type:"bigint",...io(t)})}(ac,e)}const uc=ur("ZodAny",((e,t)=>{Oi.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}}));function lc(){return function(e){return new e({type:"any"})}(uc)}const fc=ur("ZodUnknown",((e,t)=>{$i.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}}));function hc(){return function(e){return new e({type:"unknown"})}(fc)}const dc=ur("ZodNever",((e,t)=>{Ii.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(e,t,n)=>Ms(0,0,t)}));function pc(e){return function(e,t){return new e({type:"never",...io(t)})}(dc,e)}const mc=ur("ZodArray",((e,t)=>{Vi.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hs(e,t,n,r),e.element=t.element,Oa(e,"ZodArray",{min(e,t){return this.check(zs(e,t))},nonempty(e){return this.check(zs(1,e))},max(e,t){return this.check(Rs(e,t))},length(e,t){return this.check(As(e,t))},unwrap(){return this.element}})}));function gc(e,t){return function(e,t,n){return new e({type:"array",element:t,...io(n)})}(mc,e,t)}const yc=ur("ZodObject",((e,t)=>{Fi.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ws(e,t,n,r),Hr(e,"shape",(()=>t.shape)),Oa(e,"ZodObject",{keyof(){return Ac(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:hc()})},loose(){return this.clone({...this._zod.def,catchall:hc()})},strict(){return this.clone({...this._zod.def,catchall:pc()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return function(e,t){if(!eo(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const n=e._zod.def.shape;for(const e in t)if(void 0!==Object.getOwnPropertyDescriptor(n,e))throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const r=Jr(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return Wr(this,"shape",n),n}});return oo(e,r)}(this,e)},safeExtend(e){return function(e,t){if(!eo(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=Jr(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return Wr(this,"shape",n),n}});return oo(e,n)}(this,e)},merge(e){return function(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n=Jr(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return Wr(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return oo(e,n)}(this,e)},pick(e){return function(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");return oo(e,Jr(e._zod.def,{get shape(){const e={};for(const r in t){if(!(r in n.shape))throw new Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return Wr(this,"shape",e),e},checks:[]}))}(this,e)},omit(e){return function(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const o=Jr(e._zod.def,{get shape(){const r={...e._zod.def.shape};for(const e in t){if(!(e in n.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return Wr(this,"shape",r),r},checks:[]});return oo(e,o)}(this,e)},partial(...e){return function(e,t,n){const r=t._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const o=Jr(t._zod.def,{get shape(){const r=t._zod.def.shape,o={...r};if(n)for(const t in n){if(!(t in r))throw new Error(`Unrecognized key: "${t}"`);n[t]&&(o[t]=e?new e({type:"optional",innerType:r[t]}):r[t])}else for(const t in r)o[t]=e?new e({type:"optional",innerType:r[t]}):r[t];return Wr(this,"shape",o),o},checks:[]});return oo(t,o)}($c,this,e[0])},required(...e){return function(e,t,n){const r=Jr(t._zod.def,{get shape(){const r=t._zod.def.shape,o={...r};if(n)for(const t in n){if(!(t in o))throw new Error(`Unrecognized key: "${t}"`);n[t]&&(o[t]=new e({type:"nonoptional",innerType:r[t]}))}else for(const t in r)o[t]=new e({type:"nonoptional",innerType:r[t]});return Wr(this,"shape",o),o}});return oo(t,r)}(Cc,this,e[0])}})}));function wc(e,t){const n={type:"object",shape:e??{},...io(t)};return new yc(n)}const bc=ur("ZodUnion",((e,t)=>{Mi.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Js(e,t,n,r),e.options=t.options}));function vc(e,t){return new bc({type:"union",options:e,...io(t)})}const Bc=ur("ZodIntersection",((e,t)=>{Ui.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ks(e,t,n,r)}));const Ec=ur("ZodTuple",((e,t)=>{Zi.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xs(e,t,n,r),e.rest=t=>e.clone({...e._zod.def,rest:t})}));function xc(e,t,n){const r=t instanceof Qo;return new Ec({type:"tuple",items:e,rest:r?t:null,...io(r?n:t)})}const Tc=ur("ZodRecord",((e,t)=>{Ji.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ys(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType}));function Rc(e,t,n){return t&&t._zod?new Tc({type:"record",keyType:e,valueType:t,...io(n)}):new Tc({type:"record",keyType:Va(),valueType:e,...io(t)})}const zc=ur("ZodEnum",((e,t)=>{Ki.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Us(e,0,n),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{const o={};for(const i of e){if(!n.has(i))throw new Error(`Key ${i} not found in enum`);o[i]=t.entries[i]}return new zc({...t,checks:[],...io(r),entries:o})},e.exclude=(e,r)=>{const o={...t.entries};for(const t of e){if(!n.has(t))throw new Error(`Key ${t} not found in enum`);delete o[t]}return new zc({...t,checks:[],...io(r),entries:o})}}));function Ac(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map((e=>[e,e]))):e;return new zc({type:"enum",entries:n,...io(t)})}const kc=ur("ZodLiteral",((e,t)=>{Xi.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ls(e,t,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})}));const Sc=ur("ZodTransform",((e,t)=>{Yi.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(e,t,n)=>qs(0,e),e._zod.parse=(n,r)=>{if("backward"===r.direction)throw new fr(e.constructor.name);n.addIssue=r=>{if("string"==typeof r)n.issues.push(po(r,n.value,t));else{const t=r;t.fatal&&(t.continue=!1),t.code??(t.code="custom"),t.input??(t.input=n.value),t.inst??(t.inst=e),n.issues.push(po(t))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then((e=>(n.value=e,n.fallback=!0,n))):(n.value=o,n.fallback=!0,n)}}));function Oc(e){return new Sc({type:"transform",transform:e})}const $c=ur("ZodOptional",((e,t)=>{es.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sa(e,t,0,r),e.unwrap=()=>e._zod.def.innerType}));function Ic(e){return new $c({type:"optional",innerType:e})}const _c=ur("ZodExactOptional",((e,t)=>{ts.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sa(e,t,0,r),e.unwrap=()=>e._zod.def.innerType}));const Vc=ur("ZodNullable",((e,t)=>{ns.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}));function Dc(e){return new Vc({type:"nullable",innerType:e})}const Nc=ur("ZodDefault",((e,t)=>{rs.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ta(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap}));const Pc=ur("ZodPrefault",((e,t)=>{is.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(t,n,r)=>na(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}));const Cc=ur("ZodNonOptional",((e,t)=>{ss.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ea(e,t,0,r),e.unwrap=()=>e._zod.def.innerType}));const Fc=ur("ZodCatch",((e,t)=>{cs.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ra(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap}));const Gc=ur("ZodPipe",((e,t)=>{us.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(t,n,r)=>oa(e,t,0,r),e.in=t.in,e.out=t.out}));function Mc(e,t){return new Gc({type:"pipe",in:e,out:t})}const Uc=ur("ZodReadonly",((e,t)=>{fs.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ia(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}));const Lc=ur("ZodFunction",((e,t)=>{ds.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(e,t,n)=>Zs(0,e)}));const jc=ur("ZodCustom",((e,t)=>{ps.init(e,t),$a.init(e,t),e._zod.processJSONSchema=(e,t,n)=>js(0,e)}));const Zc=wc({issuer:Va().transform((e=>yt(e))),index:Va().transform((e=>yt(e))),timestamp:Va().transform((e=>yt(e))),signature:Va().transform((e=>yt(e)))});var qc=n(878);const Hc=n.n(qc)()("bee-js:http"),Wc={headers:{accept:"application/json, text/plain, */*"}};async function Jc(e,t){const n=t.data,r=cr.Rb.deepMerge3(Wc,{...t,data:void 0},e);if(r.data=n,e.signal&&(r.signal=e.signal),function(e){if(void 0===e.data)return;const t=e.data;if(null!==t&&"object"==typeof t&&t.constructor===Object||Array.isArray(t))e.body=JSON.stringify(t),e.headers={"content-type":"application/json",...e.headers};else{e.body=t,e.duplex="half";const n=t instanceof Blob&&t.type?t.type:"application/octet-stream";e.headers={"content-type":n,...e.headers}}}(r),r.params)for(const c of Object.keys(r.params))void 0===r.params[c]&&delete r.params[c];const o=function(e){let t=cr.DH.joinUrl([e.baseURL??"",e.url??""]);if(e.params){const n=new URLSearchParams(Object.entries(e.params).filter((([,e])=>void 0!==e)).map((([e,t])=>[e,String(t)]))).toString();n&&(t+=`?${n}`)}return t}(r),i=(r.method||"GET").toUpperCase();r.method=i,e.onRequest?.({method:i,url:cr.DH.joinUrl([r.baseURL??"",r.url??""]),headers:{...r.headers},params:r.params});let s=0;for(;s<1e5;)try{Hc(`${i} ${o}`,{headers:r.headers,params:r.params});const e=await fetch(o,r);return e.ok||await Kc(i,o,e,r.responseType),Yc(e,r.responseType)}catch(a){if(a instanceof ru)throw a;const t=a;if("TimeoutError"!==t.name||!e.endlesslyRetry)throw Xc(t,i,o);s++,await cr.iQ.sleepMillis(s<300?200:1e3)}throw Error("Max number of failed attempts reached")}async function Kc(e,t,n,r){const o=await Yc(n,r).catch((()=>({data:void 0}))),i="string"==typeof o.data?o.data:JSON.stringify(o.data),s=i&&"undefined"!==i?`${n.statusText}: ${i}`:n.statusText;throw new ru(e,t,s,o.data,n.status,n.statusText)}function Xc(e,t,n){if("AbortError"===e.name)return new ru(t,n,"Request aborted",void 0,void 0,"ERR_CANCELED");const r=e.cause,o=r?.message?`${e.message}: ${r.message}`:e.message;return new ru(t,n,o)}async function Yc(e,t="json"){let n;switch(t){case"arraybuffer":n=await e.arrayBuffer();break;case"text":n=await e.text();break;case"blob":n=await e.blob();break;case"stream":n=e.body;break;default:{const t=await e.text();n=t?JSON.parse(t):null}}return{data:n,status:e.status,statusText:e.statusText,headers:Object.fromEntries(e.headers.entries()),raw:e}}const Qc=wc({durationSeconds:nc()});const eu=wc({reference:Va().transform((e=>new nn(e)))});class tu extends Error{constructor(e){super(e)}}class nu extends tu{constructor(e,t){super(e),this.value=t}}class ru extends tu{constructor(e,t,n,r,o,i){super(n),this.method=e,this.url=t,this.responseBody=r,this.status=o,this.statusText=i,this.response={status:o,data:r,statusText:i}}}class ou{static ZERO=new ou(0);constructor(e){this.seconds=Math.ceil(e),e<0&&(this.seconds=0)}static fromMilliseconds(e){return new ou(e/1e3)}static fromSeconds(e){return new ou(e)}static fromHours(e){return new ou(60*e*60)}static fromDays(e){return new ou(24*e*60*60)}static fromWeeks(e){return new ou(7*e*24*60*60)}static fromYears(e){return new ou(365*e*24*60*60)}static fromEndDate(e,t){return new ou((e.getTime()-(t??new Date).getTime())/1e3)}static parseFromString(e){return ou.fromSeconds(cr.AO.make(e)/1e3)}toSeconds(){return this.seconds}toHours(){return this.seconds/60/60}toDays(){return this.seconds/24/60/60}toWeeks(){return this.seconds/7/24/60/60}toYears(){return this.seconds/365/24/60/60}toEndDate(e){return new Date((e??new Date).getTime()+1e3*this.seconds)}represent(){return cr.AO.secondsToHumanTime(this.seconds)}isZero(){return 0===this.seconds}}class iu{constructor(e){if(this.bytes=Math.ceil(e),e<0)throw Error("Size must be at least 0")}static fromBytes(e){return new iu(e)}static fromKilobytes(e){return new iu(1e3*e)}static fromMegabytes(e){return new iu(1e3*e*1e3)}static fromGigabytes(e){return new iu(1e3*e*1e3*1e3)}static parseFromString(e){return iu.fromBytes(cr.FQ.makeStorage(e,1e3))}toBytes(){return this.bytes}toGigabytes(){return this.bytes/1e3/1e3/1e3}toFormattedString(){return cr.FQ.convertBytes(this.bytes,1e3)}represent(){return this.toFormattedString()}}class su{static DIGITS=16;constructor(e){this.state=e}static fromDecimalString(e){return new su(cr.ie.fromDecimalString(e,su.DIGITS))}static fromPLUR(e){return new su(new cr.ie(e,su.DIGITS))}static fromFloat(e){return new su(cr.ie.fromFloat(e,su.DIGITS))}toPLURString(){return this.state.toString()}toPLURBigInt(){return this.state.value}toDecimalString(){return this.state.toDecimalString()}toFloat(){return this.state.toFloat()}toSignificantDigits(e){return this.toDecimalString().slice(0,this.toDecimalString().indexOf(".")+e+1)}plus(e){return new su(this.state.add(e instanceof su?e.state:new cr.ie(e,su.DIGITS)))}minus(e){return new su(this.state.subtract(e instanceof su?e.state:new cr.ie(e,su.DIGITS)))}divide(e){return new su(this.state.divmod(e)[0])}gt(e){return 1===this.state.compare(e.state)}gte(e){return-1!==this.state.compare(e.state)}lt(e){return-1===this.state.compare(e.state)}lte(e){return 1!==this.state.compare(e.state)}eq(e){return 0===this.state.compare(e.state)}exchangeToDAI(e){return au.fromWei(this.state.exchange("*",new cr.ie(e.toWeiBigInt(),au.DIGITS),au.DIGITS).value)}}class au{static DIGITS=18;constructor(e){this.state=e}static fromDecimalString(e){return new au(cr.ie.fromDecimalString(e,au.DIGITS))}static fromWei(e){return new au(new cr.ie(e,au.DIGITS))}static fromFloat(e){return new au(cr.ie.fromFloat(e,au.DIGITS))}toWeiString(){return this.state.toString()}toWeiBigInt(){return this.state.value}toDecimalString(){return this.state.toDecimalString()}toSignificantDigits(e){return this.toDecimalString().slice(0,this.toDecimalString().indexOf(".")+e+1)}toFloat(){return this.state.toFloat()}plus(e){return new au(this.state.add(e instanceof au?e.state:new cr.ie(e,au.DIGITS)))}minus(e){return new au(this.state.subtract(e instanceof au?e.state:new cr.ie(e,au.DIGITS)))}divide(e){return new au(this.state.divmod(e)[0])}gt(e){return 1===this.state.compare(e.state)}gte(e){return-1!==this.state.compare(e.state)}lt(e){return-1===this.state.compare(e.state)}lte(e){return 1!==this.state.compare(e.state)}eq(e){return 0===this.state.compare(e.state)}exchangeToBZZ(e){return su.fromPLUR(this.state.exchange("/",new cr.ie(e.toWeiBigInt(),au.DIGITS),su.DIGITS).value)}}var cu=n(320);function uu(e){if("function"==typeof File&&e instanceof File)return!0;const t=e;return"object"==typeof t&&"string"==typeof t.name&&("function"==typeof t.stream||"function"==typeof t.arrayBuffer)}function lu(e){return function(e,t){return new e({type:"number",coerce:!0,checks:[],...io(t)})}(tc,e)}let fu=function(e){return e.FULL="full",e.LIGHT="light",e.ULTRA_LIGHT="ultra-light",e.DEV="dev",e}({});function hu(e){switch(e){case"full":return fu.FULL;case"light":return fu.LIGHT;case"ultra-light":return fu.ULTRA_LIGHT;case"dev":return fu.DEV;default:throw new Error(`Unknown Bee mode: ${e}`)}}const du=32,pu=128,mu=du*pu,gu=4,yu=17,wu=255,bu=1,vu=1e3;let Bu=function(e){return e[e.OFF=0]="OFF",e[e.MEDIUM=1]="MEDIUM",e[e.STRONG=2]="STRONG",e[e.INSANE=3]="INSANE",e[e.PARANOID=4]="PARANOID",e}({}),Eu=function(e){return e[e.NONE=0]="NONE",e[e.DATA=1]="DATA",e[e.PROX=2]="PROX",e[e.RACE=3]="RACE",e}({});const xu={ENCRYPTION_OFF:{[Bu.OFF]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"44.70 kB",batchDepth:17,utilizationRate:"0.01%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"6.66 MB",batchDepth:18,utilizationRate:"0.61%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"112.06 MB",batchDepth:19,utilizationRate:"5.09%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"687.62 MB",batchDepth:20,utilizationRate:"15.65%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"2.60 GB",batchDepth:21,utilizationRate:"30.27%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"7.73 GB",batchDepth:22,utilizationRate:"44.99%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"19.94 GB",batchDepth:23,utilizationRate:"58.03%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"47.06 GB",batchDepth:24,utilizationRate:"68.48%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"105.51 GB",batchDepth:25,utilizationRate:"76.77%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"227.98 GB",batchDepth:26,utilizationRate:"82.94%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"476.68 GB",batchDepth:27,utilizationRate:"86.71%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"993.65 GB",batchDepth:28,utilizationRate:"88.37%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"2.04 TB",batchDepth:29,utilizationRate:"92.88%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"4.17 TB",batchDepth:30,utilizationRate:"94.81%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"8.45 TB",batchDepth:31,utilizationRate:"96.06%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"17.07 TB",batchDepth:32,utilizationRate:"97.01%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"34.36 TB",batchDepth:33,utilizationRate:"97.65%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"69.04 TB",batchDepth:34,utilizationRate:"98.11%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"138.54 TB",batchDepth:35,utilizationRate:"98.44%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"277.72 TB",batchDepth:36,utilizationRate:"98.67%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"556.35 TB",batchDepth:37,utilizationRate:"98.83%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"1.11 PB",batchDepth:38,utilizationRate:"98.91%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"2.23 PB",batchDepth:39,utilizationRate:"98.96%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"4.46 PB",batchDepth:40,utilizationRate:"98.98%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"8.93 PB",batchDepth:41,utilizationRate:"99.11%"}],[Bu.MEDIUM]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"41.56 kB",batchDepth:17,utilizationRate:"0.01%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"6.19 MB",batchDepth:18,utilizationRate:"0.57%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"104.18 MB",batchDepth:19,utilizationRate:"4.73%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"639.27 MB",batchDepth:20,utilizationRate:"14.54%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"2.41 GB",batchDepth:21,utilizationRate:"28.11%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"7.18 GB",batchDepth:22,utilizationRate:"41.79%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"18.54 GB",batchDepth:23,utilizationRate:"53.95%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"43.75 GB",batchDepth:24,utilizationRate:"63.66%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"98.09 GB",batchDepth:25,utilizationRate:"71.37%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"211.95 GB",batchDepth:26,utilizationRate:"77.11%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"443.16 GB",batchDepth:27,utilizationRate:"80.61%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"923.78 GB",batchDepth:28,utilizationRate:"82.16%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"1.90 TB",batchDepth:29,utilizationRate:"86.30%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"3.88 TB",batchDepth:30,utilizationRate:"88.14%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"7.86 TB",batchDepth:31,utilizationRate:"89.26%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"15.87 TB",batchDepth:32,utilizationRate:"90.21%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"31.94 TB",batchDepth:33,utilizationRate:"90.77%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"64.19 TB",batchDepth:34,utilizationRate:"91.22%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"128.80 TB",batchDepth:35,utilizationRate:"91.52%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"258.19 TB",batchDepth:36,utilizationRate:"91.73%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"517.23 TB",batchDepth:37,utilizationRate:"91.88%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"1.04 PB",batchDepth:38,utilizationRate:"91.95%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"2.07 PB",batchDepth:39,utilizationRate:"92.00%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"4.15 PB",batchDepth:40,utilizationRate:"92.15%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"8.30 PB",batchDepth:41,utilizationRate:"92.14%"}],[Bu.STRONG]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"37.37 kB",batchDepth:17,utilizationRate:"0.01%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"5.57 MB",batchDepth:18,utilizationRate:"0.51%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"93.68 MB",batchDepth:19,utilizationRate:"4.25%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"574.81 MB",batchDepth:20,utilizationRate:"13.07%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"2.17 GB",batchDepth:21,utilizationRate:"25.26%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"6.46 GB",batchDepth:22,utilizationRate:"37.58%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"16.67 GB",batchDepth:23,utilizationRate:"48.50%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"39.34 GB",batchDepth:24,utilizationRate:"57.24%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"88.20 GB",batchDepth:25,utilizationRate:"64.17%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"190.58 GB",batchDepth:26,utilizationRate:"69.33%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"398.47 GB",batchDepth:27,utilizationRate:"72.48%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"830.63 GB",batchDepth:28,utilizationRate:"73.85%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"1.71 TB",batchDepth:29,utilizationRate:"77.59%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"3.49 TB",batchDepth:30,utilizationRate:"79.27%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"7.07 TB",batchDepth:31,utilizationRate:"80.34%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"14.27 TB",batchDepth:32,utilizationRate:"81.12%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"28.72 TB",batchDepth:33,utilizationRate:"81.63%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"57.71 TB",batchDepth:34,utilizationRate:"82.01%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"115.81 TB",batchDepth:35,utilizationRate:"82.29%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"232.16 TB",batchDepth:36,utilizationRate:"82.48%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"465.07 TB",batchDepth:37,utilizationRate:"82.61%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"931.23 TB",batchDepth:38,utilizationRate:"82.67%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"1.86 PB",batchDepth:39,utilizationRate:"82.71%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"3.73 PB",batchDepth:40,utilizationRate:"82.78%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"7.46 PB",batchDepth:41,utilizationRate:"82.79%"}],[Bu.INSANE]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"33.88 kB",batchDepth:17,utilizationRate:"0.01%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"5.05 MB",batchDepth:18,utilizationRate:"0.46%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"84.92 MB",batchDepth:19,utilizationRate:"3.86%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"521.09 MB",batchDepth:20,utilizationRate:"11.85%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"1.97 GB",batchDepth:21,utilizationRate:"22.90%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"5.86 GB",batchDepth:22,utilizationRate:"34.09%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"15.11 GB",batchDepth:23,utilizationRate:"43.97%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"35.66 GB",batchDepth:24,utilizationRate:"51.90%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"79.96 GB",batchDepth:25,utilizationRate:"58.18%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"172.77 GB",batchDepth:26,utilizationRate:"62.85%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"361.23 GB",batchDepth:27,utilizationRate:"65.70%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"753.00 GB",batchDepth:28,utilizationRate:"66.95%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"1.55 TB",batchDepth:29,utilizationRate:"70.38%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"3.16 TB",batchDepth:30,utilizationRate:"71.92%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"6.41 TB",batchDepth:31,utilizationRate:"72.85%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"12.93 TB",batchDepth:32,utilizationRate:"73.53%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"26.04 TB",batchDepth:33,utilizationRate:"74.01%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"52.32 TB",batchDepth:34,utilizationRate:"74.35%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"104.99 TB",batchDepth:35,utilizationRate:"74.60%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"210.46 TB",batchDepth:36,utilizationRate:"74.77%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"421.61 TB",batchDepth:37,utilizationRate:"74.89%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"844.20 TB",batchDepth:38,utilizationRate:"74.94%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"1.69 PB",batchDepth:39,utilizationRate:"74.98%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"3.38 PB",batchDepth:40,utilizationRate:"75.03%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"6.77 PB",batchDepth:41,utilizationRate:"75.10%"}],[Bu.PARANOID]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"13.27 kB",batchDepth:17,utilizationRate:"0.00%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"1.98 MB",batchDepth:18,utilizationRate:"0.18%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"33.27 MB",batchDepth:19,utilizationRate:"1.51%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"204.14 MB",batchDepth:20,utilizationRate:"4.64%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"771.13 MB",batchDepth:21,utilizationRate:"8.75%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"2.29 GB",batchDepth:22,utilizationRate:"13.34%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"5.92 GB",batchDepth:23,utilizationRate:"17.22%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"13.97 GB",batchDepth:24,utilizationRate:"20.33%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"31.32 GB",batchDepth:25,utilizationRate:"22.79%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"67.68 GB",batchDepth:26,utilizationRate:"24.62%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"141.51 GB",batchDepth:27,utilizationRate:"25.74%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"294.99 GB",batchDepth:28,utilizationRate:"26.23%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"606.90 GB",batchDepth:29,utilizationRate:"27.56%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"1.24 TB",batchDepth:30,utilizationRate:"28.15%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"2.51 TB",batchDepth:31,utilizationRate:"28.54%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"5.07 TB",batchDepth:32,utilizationRate:"28.82%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"10.20 TB",batchDepth:33,utilizationRate:"28.99%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"20.50 TB",batchDepth:34,utilizationRate:"29.13%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"41.13 TB",batchDepth:35,utilizationRate:"29.22%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"82.45 TB",batchDepth:36,utilizationRate:"29.29%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"165.17 TB",batchDepth:37,utilizationRate:"29.34%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"330.72 TB",batchDepth:38,utilizationRate:"29.37%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"661.97 TB",batchDepth:39,utilizationRate:"29.39%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"1.32 PB",batchDepth:40,utilizationRate:"29.41%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"2.65 PB",batchDepth:41,utilizationRate:"29.43%"}]},ENCRYPTION_ON:{[Bu.OFF]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"44.35 kB",batchDepth:17,utilizationRate:"0.01%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"6.61 MB",batchDepth:18,utilizationRate:"0.60%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"111.18 MB",batchDepth:19,utilizationRate:"5.05%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"682.21 MB",batchDepth:20,utilizationRate:"15.52%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"2.58 GB",batchDepth:21,utilizationRate:"30.04%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"7.67 GB",batchDepth:22,utilizationRate:"44.62%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"19.78 GB",batchDepth:23,utilizationRate:"57.56%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"46.69 GB",batchDepth:24,utilizationRate:"67.93%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"104.68 GB",batchDepth:25,utilizationRate:"76.16%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"226.19 GB",batchDepth:26,utilizationRate:"82.29%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"472.93 GB",batchDepth:27,utilizationRate:"86.02%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"985.83 GB",batchDepth:28,utilizationRate:"87.66%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"2.03 TB",batchDepth:29,utilizationRate:"92.25%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"4.14 TB",batchDepth:30,utilizationRate:"94.21%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"8.39 TB",batchDepth:31,utilizationRate:"95.37%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"16.93 TB",batchDepth:32,utilizationRate:"96.22%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"34.09 TB",batchDepth:33,utilizationRate:"96.88%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"68.50 TB",batchDepth:34,utilizationRate:"97.34%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"137.45 TB",batchDepth:35,utilizationRate:"97.67%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"275.53 TB",batchDepth:36,utilizationRate:"97.89%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"551.97 TB",batchDepth:37,utilizationRate:"98.05%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"1.11 PB",batchDepth:38,utilizationRate:"98.13%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"2.21 PB",batchDepth:39,utilizationRate:"98.18%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"4.43 PB",batchDepth:40,utilizationRate:"98.36%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"8.86 PB",batchDepth:41,utilizationRate:"98.37%"}],[Bu.MEDIUM]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"40.89 kB",batchDepth:17,utilizationRate:"0.01%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"6.09 MB",batchDepth:18,utilizationRate:"0.56%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"102.49 MB",batchDepth:19,utilizationRate:"4.65%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"628.91 MB",batchDepth:20,utilizationRate:"14.30%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"2.38 GB",batchDepth:21,utilizationRate:"27.68%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"7.07 GB",batchDepth:22,utilizationRate:"41.15%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"18.24 GB",batchDepth:23,utilizationRate:"53.09%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"43.04 GB",batchDepth:24,utilizationRate:"62.63%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"96.50 GB",batchDepth:25,utilizationRate:"70.21%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"208.52 GB",batchDepth:26,utilizationRate:"75.86%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"435.98 GB",batchDepth:27,utilizationRate:"79.30%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"908.81 GB",batchDepth:28,utilizationRate:"80.82%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"1.87 TB",batchDepth:29,utilizationRate:"84.98%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"3.81 TB",batchDepth:30,utilizationRate:"86.67%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"7.73 TB",batchDepth:31,utilizationRate:"87.84%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"15.61 TB",batchDepth:32,utilizationRate:"88.74%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"31.43 TB",batchDepth:33,utilizationRate:"89.34%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"63.15 TB",batchDepth:34,utilizationRate:"89.74%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"126.71 TB",batchDepth:35,utilizationRate:"90.03%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"254.01 TB",batchDepth:36,utilizationRate:"90.24%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"508.85 TB",batchDepth:37,utilizationRate:"90.39%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"1.02 PB",batchDepth:38,utilizationRate:"90.47%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"2.04 PB",batchDepth:39,utilizationRate:"90.51%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"4.08 PB",batchDepth:40,utilizationRate:"90.64%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"8.17 PB",batchDepth:41,utilizationRate:"90.65%"}],[Bu.STRONG]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"36.73 kB",batchDepth:17,utilizationRate:"0.01%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"5.47 MB",batchDepth:18,utilizationRate:"0.50%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"92.07 MB",batchDepth:19,utilizationRate:"4.18%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"564.95 MB",batchDepth:20,utilizationRate:"12.85%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"2.13 GB",batchDepth:21,utilizationRate:"24.86%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"6.35 GB",batchDepth:22,utilizationRate:"36.97%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"16.38 GB",batchDepth:23,utilizationRate:"47.67%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"38.66 GB",batchDepth:24,utilizationRate:"56.26%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"86.69 GB",batchDepth:25,utilizationRate:"63.07%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"187.31 GB",batchDepth:26,utilizationRate:"68.14%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"391.64 GB",batchDepth:27,utilizationRate:"71.24%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"816.39 GB",batchDepth:28,utilizationRate:"72.59%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"1.68 TB",batchDepth:29,utilizationRate:"76.34%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"3.43 TB",batchDepth:30,utilizationRate:"77.89%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"6.94 TB",batchDepth:31,utilizationRate:"78.86%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"14.02 TB",batchDepth:32,utilizationRate:"79.71%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"28.23 TB",batchDepth:33,utilizationRate:"80.23%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"56.72 TB",batchDepth:34,utilizationRate:"80.60%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"113.82 TB",batchDepth:35,utilizationRate:"80.88%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"228.18 TB",batchDepth:36,utilizationRate:"81.06%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"457.10 TB",batchDepth:37,utilizationRate:"81.20%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"915.26 TB",batchDepth:38,utilizationRate:"81.26%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"1.83 PB",batchDepth:39,utilizationRate:"81.30%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"3.67 PB",batchDepth:40,utilizationRate:"81.43%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"7.34 PB",batchDepth:41,utilizationRate:"81.45%"}],[Bu.INSANE]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"33.26 kB",batchDepth:17,utilizationRate:"0.01%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"4.96 MB",batchDepth:18,utilizationRate:"0.45%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"83.38 MB",batchDepth:19,utilizationRate:"3.79%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"511.65 MB",batchDepth:20,utilizationRate:"11.64%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"1.93 GB",batchDepth:21,utilizationRate:"22.52%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"5.75 GB",batchDepth:22,utilizationRate:"33.50%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"14.84 GB",batchDepth:23,utilizationRate:"43.19%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"35.02 GB",batchDepth:24,utilizationRate:"50.96%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"78.51 GB",batchDepth:25,utilizationRate:"57.12%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"169.64 GB",batchDepth:26,utilizationRate:"61.71%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"354.69 GB",batchDepth:27,utilizationRate:"64.52%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"739.37 GB",batchDepth:28,utilizationRate:"65.74%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"1.52 TB",batchDepth:29,utilizationRate:"69.15%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"3.10 TB",batchDepth:30,utilizationRate:"70.56%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"6.29 TB",batchDepth:31,utilizationRate:"71.48%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"12.70 TB",batchDepth:32,utilizationRate:"72.18%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"25.57 TB",batchDepth:33,utilizationRate:"72.67%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"51.37 TB",batchDepth:34,utilizationRate:"73.00%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"103.08 TB",batchDepth:35,utilizationRate:"73.24%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"206.65 TB",batchDepth:36,utilizationRate:"73.42%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"413.98 TB",batchDepth:37,utilizationRate:"73.54%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"828.91 TB",batchDepth:38,utilizationRate:"73.59%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"1.66 PB",batchDepth:39,utilizationRate:"73.62%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"3.32 PB",batchDepth:40,utilizationRate:"73.72%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"6.64 PB",batchDepth:41,utilizationRate:"73.74%"}],[Bu.PARANOID]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"13.17 kB",batchDepth:17,utilizationRate:"0.00%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"1.96 MB",batchDepth:18,utilizationRate:"0.18%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"33.01 MB",batchDepth:19,utilizationRate:"1.50%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"202.53 MB",batchDepth:20,utilizationRate:"4.61%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"765.05 MB",batchDepth:21,utilizationRate:"8.68%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"2.28 GB",batchDepth:22,utilizationRate:"13.27%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"5.87 GB",batchDepth:23,utilizationRate:"17.08%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"13.86 GB",batchDepth:24,utilizationRate:"20.17%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"31.08 GB",batchDepth:25,utilizationRate:"22.61%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"67.15 GB",batchDepth:26,utilizationRate:"24.43%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"140.40 GB",batchDepth:27,utilizationRate:"25.54%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"292.67 GB",batchDepth:28,utilizationRate:"26.03%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"602.12 GB",batchDepth:29,utilizationRate:"27.35%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"1.23 TB",batchDepth:30,utilizationRate:"27.94%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"2.49 TB",batchDepth:31,utilizationRate:"28.32%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"5.03 TB",batchDepth:32,utilizationRate:"28.60%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"10.12 TB",batchDepth:33,utilizationRate:"28.77%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"20.34 TB",batchDepth:34,utilizationRate:"28.91%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"40.80 TB",batchDepth:35,utilizationRate:"29.00%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"81.80 TB",batchDepth:36,utilizationRate:"29.06%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"163.87 TB",batchDepth:37,utilizationRate:"29.11%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"328.11 TB",batchDepth:38,utilizationRate:"29.14%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"656.76 TB",batchDepth:39,utilizationRate:"29.16%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"1.31 PB",batchDepth:40,utilizationRate:"29.18%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"2.63 PB",batchDepth:41,utilizationRate:"29.19%"}]}},Tu=(Va().regex(/^(?:0x)?[0-9a-fA-F]*$/i,"expected hex string").refine((e=>e.replace(/^0x/i,"").length%2==0),"expected even-length hex string"),lc().refine((e=>{return new Lc({type:"function",input:Array.isArray(t?.input)?xc(t?.input):t?.input??gc(hc()),output:t?.output??hc()}).safeParse(e).success;var t}),"expected a function")),Ru=lc().transform((e=>(cc().safeParse(e).success&&(e=String(e)),Va().regex(/^-?\d+$/,"expected integer string").parse(e)))),zu=lc().transform((e=>(cc().safeParse(e).success&&(e=String(e)),Va().regex(/^\d+$/,"expected non-negative integer string").parse(e)))),Au=wc({baseURL:Va().optional(),timeout:nc().int().min(0).optional(),headers:Rc(Va(),Va()).optional(),onRequest:Tu.optional(),httpAgent:hc().optional(),httpsAgent:hc().optional(),endlesslyRetry:sc().optional(),signal:lc().optional()}),ku=wc({redundancyStrategy:nc().int().optional(),fallback:sc().optional(),timeoutMs:nc().int().min(0).optional(),actPublisher:Ic(lc().transform((e=>new Jt(e)))),actHistoryAddress:Ic(lc().transform((e=>new nn(e)))),actTimestamp:lu().optional()}),Su=wc({act:sc().optional(),actHistoryAddress:Ic(lc().transform((e=>new nn(e)))),deferred:sc().optional(),encrypt:sc().optional(),pin:sc().optional(),tag:nc().int().min(0).optional()}),Ou=Su.extend({redundancyLevel:nc().int().min(0).optional()}),$u=Su.extend({size:nc().int().min(0).optional(),contentType:Va().optional(),redundancyLevel:nc().int().min(0).optional()}),Iu=Su.extend({errorDocument:Va().optional(),indexDocument:Va().optional(),redundancyLevel:nc().int().min(0).optional()}),_u=wc({uid:nc().int()}),Vu=lu().min(0),Du=wc({onMessage:Tu,onError:Tu,onClose:Tu}),Nu=wc({onMessage:Tu,onError:Tu,onClose:Tu}),Pu=wc({gasPrice:Ru.optional(),immutableFlag:sc().optional(),label:Va().optional(),waitForUsable:sc().optional(),waitForUsableTimeout:nc().int().min(0).optional()}),Cu=wc({gasLimit:zu.optional(),gasPrice:zu.optional()}),Fu=wc({limit:nc().int().min(bu).max(vu).optional(),offset:nc().int().min(0).optional()});function Gu(e){return void 0!==cu.Readable&&e instanceof cu.Readable}function Mu(e,t){if("bigint"==typeof e&&(e=e.toString()),"string"!=typeof e||!/^-?\d+$/.test(e))throw new TypeError(`${t?.name??"value"} is not a valid integer string, got: ${e}`);if(void 0!==t?.min&&BigInt(e)<t.min)throw new RangeError(`${t?.name??"value"} must be >= ${t.min}, got: ${e}`);if(void 0!==t?.max&&BigInt(e)>t.max)throw new RangeError(`${t?.name??"value"} must be <= ${t.max}, got: ${e}`);return e}function Uu(e){if(!("string"==typeof e||e instanceof Uint8Array||e instanceof Blob||Gu(e)))throw new TypeError("Data must be either string, Uint8Array, Blob or Readable!")}function Lu(e){if(null==e)throw new TypeError(`Expected number | Tag | string from tagUid, got: ${e}`);if(t=e,_u.safeParse(t).success)return e.uid;if("number"==typeof e||"string"==typeof e)return Vu.parse(e);var t;throw new TypeError(`Expected number | Tag | string from tagUid, got: ${e}`)}function ju(e,t){return su.fromPLUR(2n**BigInt(e)*BigInt(t))}function Zu(e,t,n){const r=BigInt(Mu(e));return ou.fromSeconds(Number(r*BigInt(n)/BigInt(t)))}function qu(e,t,n){return BigInt(e.toSeconds())/BigInt(n)*BigInt(t)+1n}function Hu(e,t,n){return function(e,t,n){if(void 0!==t&&void 0!==n){const r=(t?nr:tr)[n],o=r?.find((([,t])=>e<=Qn(t)));if(o)return o[0]}else for(const[r,o]of er)if(e<=Qn(o))return r;return 35}(e.toBytes(),t,n)}function Wu(e){return ir(e)}function Ju(e,t,n){const r=function(e){return Number.isInteger(e)?e<1?1:e>3155695200?3155695200:e:1}(e.batchTTL),o=ou.fromSeconds(r),i=rr(e.depth,t,n),s=e.utilizationRatio??Kn(e.utilization,e.depth,e.bucketDepth);return{batchID:new Pt(e.batchID),utilization:e.utilization,usable:e.usable,label:e.label,depth:e.depth,amount:Mu(e.amount),bucketDepth:e.bucketDepth,blockNumber:e.blockNumber,immutableFlag:e.immutableFlag,usage:s,usageText:`${Math.round(100*s)}%`,size:iu.fromBytes(i),remainingSize:iu.fromBytes(Math.ceil(i*(1-s))),theoreticalSize:iu.fromBytes(Xn(e.depth)),duration:o,calculateSize(t,n){const r=rr(e.depth,t,n);return iu.fromBytes(r)},calculateRemainingSize(t,n){const r=rr(e.depth,t,n);return iu.fromBytes(Math.ceil(r*(1-this.usage)))}}}function Ku(e){return{batchID:e.batchID.toHex(),utilization:e.utilization,utilizationRatio:e.usage,usable:e.usable,label:e.label,depth:e.depth,amount:e.amount,bucketDepth:e.bucketDepth,blockNumber:e.blockNumber,immutableFlag:e.immutableFlag,batchTTL:e.duration.toSeconds()}}function Xu(e){return{name:function(e){if(!e)throw new tu("missing content-disposition header");const t=e.match(/filename\*?=['"]?(?:UTF-\d['"]*)?([^;\r\n"']*)['"]?;?/i);if(t&&t.length>0)return t[1];throw new tu("invalid content-disposition header")}(e["content-disposition"]),tagUid:function(e){if(!e)return;return parseInt(e,10)}(e["swarm-tag-uid"]),contentType:e["content-type"]||void 0}}function Yu(e,t){const n={};if(!function(e){if(!wc({}).safeParse(e).success)return!1;const t=e;return void 0!==t.issuer&&void 0!==t.index&&void 0!==t.signature&&void 0!==t.timestamp&&void 0!==t.batchId}(e)?e&&(e=new Pt(e),n["swarm-postage-batch-id"]=e.toHex()):n["swarm-postage-stamp"]=Wu(e).toHex(),!t)return n;const r=t;r.size&&(n["content-length"]=String(r.size)),r.contentType&&(n["content-type"]=String(r.contentType)),r.redundancyLevel&&(n["swarm-redundancy-level"]=String(r.redundancyLevel));const o=sc().safeParse(r.act);o.success&&(n["swarm-act"]=String(o.data));const i=sc().safeParse(r.pin);i.success&&(n["swarm-pin"]=String(i.data));const s=sc().safeParse(r.encrypt);s.success&&(n["swarm-encrypt"]=String(s.data)),r.tag&&(n["swarm-tag"]=String(r.tag));const a=sc().safeParse(r.deferred);a.success&&(n["swarm-deferred-upload"]=String(a.data)),r.redundancyStrategy&&(n["swarm-redundancy-strategy"]=String(r.redundancyStrategy));const c=sc().safeParse(r.fallback);return c.success&&(n["swarm-redundancy-fallback-mode"]=String(c.data)),r.timeoutMs&&(n["swarm-chunk-retrieval-timeout"]=String(r.timeoutMs)),r.indexDocument&&(n["swarm-index-document"]=String(r.indexDocument)),r.errorDocument&&(n["swarm-error-document"]=String(r.errorDocument)),r.actPublisher&&(n["swarm-act-publisher"]=new Jt(r.actPublisher).toCompressedHex()),r.actHistoryAddress&&(n["swarm-act-history-address"]=new nn(r.actHistoryAddress).toHex()),r.actTimestamp&&(n["swarm-act-timestamp"]=String(r.actTimestamp)),(r.actPublisher||r.actHistoryAddress||r.actTimestamp)&&(n["swarm-act"]="true"),r.gasPrice&&(n["gas-price"]=String(r.gasPrice)),r.gasLimit&&(n["gas-limit"]=String(r.gasLimit)),n}const Qu="chunks";async function el(e,t,n){t=new nn(t);const r=await Jc(e,{responseType:"arraybuffer",url:`${Qu}/${t}`,headers:Yu(null,n)});return new Uint8Array(r.data)}function tl(e,t){try{return xn(e,t)}catch(n){throw new tu(n.message)}}async function nl(e,t,n,r){const o=Nt.concat(t.span.toUint8Array(),t.payload.toUint8Array());return async function(e,t,n,r,o,i,s){const a=await Jc(e,{method:"post",url:`soc/${t}/${n}`,data:o,headers:{"content-type":"application/octet-stream",...Yu(i,s)},responseType:"json",params:{sig:r.toHex()}});return{reference:eu.parse(a.data).reference,tagUid:a.headers["swarm-tag"]?Lu(a.headers["swarm-tag"]):void 0,historyAddress:a.headers["swarm-act-history-address"]?cr.Xx.of(new nn(a.headers["swarm-act-history-address"])):cr.Xx.empty()}}(e,t.owner,t.identifier,t.signature,o,n,r)}async function rl(e,t,n,r,o,i){t=new en(t),r=new Zt(r);return nl(e,Tn(o).toSingleOwnerChunk(r,t),n,i)}async function ol(e,t,n,r,o,i){t=new en(t),r=new Zt(r);return nl(e,o.toSingleOwnerChunk(r,t),n,i)}async function il(e,t,n){const r=Bn(n=new Zt(n),t=new Mt(t));return tl(await el(e,r.toHex()),r)}const sl=wc({peer:Va(),balance:Va().transform((e=>su.fromPLUR(Mu(e,{name:"balance"}))))}),al=wc({balances:gc(sl)}),cl=sl,ul="balances";const ll="consumed";class fl{constructor(e){this.context=e}async getAll(e){return async function(e){const t=await Jc(e,{url:ul,responseType:"json"});return al.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getPeer(e,t){const n=new qt(e);return async function(e,t){const n=await Jc(e,{url:`${ul}/${t}`,responseType:"json"});return cl.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async getAllPastDueConsumption(e){return async function(e){const t=await Jc(e,{url:ll,responseType:"json"});return al.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getAllPastDueConsumptionForPeer(e,t){const n=new qt(e);return async function(e,t){const n=await Jc(e,{url:`${ll}/${t}`,responseType:"json"});return cl.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}}const hl=wc({beneficiary:Va().transform((e=>new Mt(e))),chequebook:Va().transform((e=>new Mt(e))),payout:Va().transform((e=>su.fromPLUR(Mu(e,{name:"payout"}))))}),dl=wc({recipient:Va(),lastPayout:Va().transform((e=>su.fromPLUR(Mu(e,{name:"lastPayout"})))),bounced:sc()}),pl=wc({chequebookAddress:Va().transform((e=>new Mt(e)))}),ml=wc({availableBalance:Va().transform((e=>su.fromPLUR(Mu(e,{name:"availableBalance"})))),totalBalance:Va().transform((e=>su.fromPLUR(Mu(e,{name:"totalBalance"}))))}),gl=wc({peer:Va(),uncashedAmount:Va().transform((e=>su.fromPLUR(Mu(e,{name:"uncashedAmount"})))),transactionHash:Va().nullish().transform((e=>e??null)),lastCashedCheque:hl.nullish().transform((e=>e??null)),result:dl.nullish().transform((e=>e??null))}),yl=wc({peer:Va(),lastreceived:hl.nullish().transform((e=>e??null)),lastsent:hl.nullish().transform((e=>e??null))}),wl=wc({lastcheques:gc(wc({peer:Va(),lastreceived:hl.nullish().transform((e=>e??null)),lastsent:hl.nullish().transform((e=>e??null))}))}),bl=wc({transactionHash:Va().transform((e=>new an(e)))}),vl="chequebook";class Bl{constructor(e){this.context=e}async getAllLatest(e){return async function(e){const t=await Jc(e,{url:`${vl}/cheque`,responseType:"json"});return wl.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getAllLatestForPeer(e,t){const n=new qt(e);return async function(e,t){const n=await Jc(e,{url:`${vl}/cheque/${t}`,responseType:"json"});return yl.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async getLastCashoutAction(e,t){const n=new qt(e);return async function(e,t){const n=await Jc(e,{url:`${vl}/cashout/${t}`,responseType:"json"});return gl.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async cashoutLast(e,t,n){const r=new qt(e);return t&&(t=Cu.parse(t)),async function(e,t,n){const r=await Jc(e,{method:"post",url:`${vl}/cashout/${t}`,responseType:"json",headers:Yu(null,n)});return bl.parse(r.data).transactionHash}(this.context.getRequestOptionsForCall(n),r,t)}}class El{constructor(e){this.context=e}async getAddress(e){return async function(e){const t=await Jc(e,{url:`${vl}/address`,responseType:"json"});return pl.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getBalance(e){return async function(e){const t=await Jc(e,{url:`${vl}/balance`,responseType:"json"});return ml.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async deposit(e,t,n){const r=e instanceof su?e.toPLURString():Mu(e,{min:1n,name:"amount"}),o=t?Mu(e,{min:0n,name:"gasPrice"}):void 0;return async function(e,t,n){const r={};n&&(r["gas-price"]=n);const o=await Jc(e,{method:"post",url:`${vl}/deposit`,responseType:"json",params:{amount:t},headers:r});return bl.parse(o.data).transactionHash}(this.context.getRequestOptionsForCall(n),r,o)}async withdraw(e,t,n){const r=e instanceof su?e.toPLURString():Mu(e,{min:1n,name:"amount"}),o=t?Mu(e,{min:0n,name:"gasPrice"}):void 0;return async function(e,t,n){const r={};n&&(r["gas-price"]=n);const o=await Jc(e,{method:"post",url:`${vl}/withdraw`,responseType:"json",params:{amount:t},headers:r});return bl.parse(o.data).transactionHash}(this.context.getRequestOptionsForCall(n),r,o)}}class xl{constructor(e){this.context=e}async upload(e,t,n,r){const o="identifier"in t&&"signature"in t&&"owner"in t;if(t=t instanceof Uint8Array?t:t.data,n&&(n=Su.parse(n)),t.length<rn.LENGTH)throw new nu(`Chunk has to have size of at least ${rn.LENGTH}.`,t);if(!o&&t.length>mu+rn.LENGTH)throw new nu(`Content Addressed Chunk must not exceed ${mu+rn.LENGTH} bytes.`,t);if(o&&t.length>mu+rn.LENGTH+Qt.LENGTH+Zt.LENGTH)throw new nu(`Single Owner Chunk must not exceed ${mu+rn.LENGTH+Qt.LENGTH+Zt.LENGTH} bytes.`,t);return async function(e,t,n,r){const o=await Jc(e,{method:"post",url:`${Qu}`,data:t,headers:{"content-type":"application/octet-stream",...Yu(n,r)},responseType:"json"});return{reference:eu.parse(o.data).reference,tagUid:o.headers["swarm-tag"]?Lu(o.headers["swarm-tag"]):void 0,historyAddress:o.headers["swarm-act-history-address"]?cr.Xx.of(new nn(o.headers["swarm-act-history-address"])):cr.Xx.empty()}}(this.context.getRequestOptionsForCall(r),t,e,n)}async download(e,t,n){const r=new nn(e);return t&&(t=ku.parse(t)),el(this.context.getRequestOptionsForCall(n),r,t)}}var Tl=n(497),Rl=n.n(Tl);async function zl(e,t,n,r,o){for(const s of e.forks.values()){const e=await zl(s.node,t,n,r,o);if(r?.act){let t;e.historyAddress.ifPresent((e=>t=e)),t&&(s.node.metadata||(s.node.metadata={}),s.node.metadata["swarm-act-history-address"]=t.toHex())}}const i=await t.data.upload(n,await e.marshal(),r,o);return e.selfAddress=i.reference.toUint8Array(),i}async function Al(e,t,n,r){for(const o of e.forks.values()){if(!o.node.selfAddress)throw Error("MantarayNode#loadRecursively fork.node.selfAddress is not set");let i=n;o.node.metadata&&o.node.metadata["swarm-act-history-address"]&&(i={...n,actHistoryAddress:o.node.metadata["swarm-act-history-address"]});const s=(await t.data.download(o.node.selfAddress,i,r)).toUint8Array(),a=qn.unmarshalFromData(s,o.node.selfAddress);o.node.targetAddress=a.targetAddress,o.node.forks=a.forks,o.node.obfuscationKey=a.obfuscationKey,o.node.path=o.prefix,o.node.parent=e,await Al(o.node,t,n,r)}}class kl{constructor(e=new qn){this.core=e}get obfuscationKey(){return this.core.obfuscationKey}get selfAddress(){return this.core.selfAddress}get targetAddress(){return this.core.targetAddress}get metadata(){return this.core.metadata}get path(){return this.core.path}get forks(){return this.core.forks}get parent(){return this.core.parent}get type(){return this.core.type}get fullPath(){return this.core.fullPath}get fullPathString(){return this.core.fullPathString}getRootMetadata(){const e=this.core.find("/");return e&&e.metadata?cr.Xx.of(e.metadata):cr.Xx.empty()}getDocsMetadata(){const e=this.core.find("/");return e&&e.metadata?{indexDocument:e.metadata["website-index-document"]??null,errorDocument:e.metadata["website-error-document"]??null}:{indexDocument:null,errorDocument:null}}async resolveFeed(e,t){const n=this.core.find("/");if(!n||!n.metadata)return cr.Xx.empty();const r=n.metadata["swarm-feed-owner"],o=n.metadata["swarm-feed-topic"];return r&&o?cr.Xx.of(await e.feed.fetchLatestUpdate(o,r,t)):cr.Xx.empty()}async marshal(){return this.core.marshal()}static async unmarshal(e,t,n,r){t=new nn(t);const o=(await e.data.download(t,n,r)).toUint8Array();return this.unmarshalFromData(o,t.toUint8Array())}static unmarshalFromData(e,t){return new kl(qn.unmarshalFromData(e,t))}addFork(e,t,n){this.core.addFork(e,t instanceof Nt?t.toUint8Array():t,n)}removeFork(e){this.core.removeFork(e)}async calculateSelfAddress(){return this.core.calculateSelfAddress()}async saveRecursively(e,t,n,r){return zl(this.core,e,t,n,r)}async loadRecursively(e,t,n){return Al(this.core,e,t,n)}find(e){return this.core.find(e)}findClosest(e,t){return this.core.findClosest(e,t)}collect(e=[]){return this.core.collect(e)}collectAndMap(){return this.core.collectAndMap()}determineType(){return this.core.determineType()}}var Sl=n(61),Ol=n.n(Sl);async function $l(e){if("string"!=typeof e)throw new TypeError("dir has to be string!");if(""===e)throw new TypeError("dir must not be empty string!");return Il(e,"")}async function Il(e,t){const n=Ol().join(e,t),r=await Rl().promises.opendir(n);let o=[];for await(const i of r){const n=Ol().join(e,t,i.name),r=Ol().join(t,i.name);i.isFile()?o.push({path:r,size:(await Rl().promises.stat(n)).size,fsPath:n}):i.isDirectory()&&(o=[...await Il(e,r),...o])}return o}async function _l(e){if("string"!=typeof e)throw new TypeError("dir has to be string!");if(""===e)throw new TypeError("dir must not be empty string!");const t=await Rl().promises.opendir(e);let n=0;for await(const r of t)if(r.isFile()){n+=(await Rl().promises.stat(Ol().join(e,r.name))).size}else r.isDirectory()&&(n+=await _l(Ol().join(e,r.name)));return n}const Vl={aac:"audio/aac",abw:"application/x-abiword",ai:"application/postscript",arc:"application/octet-stream",avi:"video/x-msvideo",azw:"application/vnd.amazon.ebook",bin:"application/octet-stream",bz:"application/x-bzip",bz2:"application/x-bzip2",csh:"application/x-csh",css:"text/css",csv:"text/csv",doc:"application/msword",dll:"application/octet-stream",dmg:"application/x-apple-diskimage",eot:"application/vnd.ms-fontobject",epub:"application/epub+zip",gif:"image/gif",htm:"text/html",html:"text/html",ico:"image/x-icon",ics:"text/calendar",jar:"application/java-archive",jpeg:"image/jpeg",jpg:"image/jpeg",js:"application/javascript",json:"application/json",mid:"audio/midi",midi:"audio/midi",mp2:"audio/mpeg",mp3:"audio/mpeg",mp4:"video/mp4",mpa:"video/mpeg",mpe:"video/mpeg",mpeg:"video/mpeg",mpkg:"application/vnd.apple.installer+xml",odp:"application/vnd.oasis.opendocument.presentation",ods:"application/vnd.oasis.opendocument.spreadsheet",odt:"application/vnd.oasis.opendocument.text",oga:"audio/ogg",ogv:"video/ogg",ogx:"application/ogg",otf:"font/otf",png:"image/png",pdf:"application/pdf",ppt:"application/vnd.ms-powerpoint",rar:"application/x-rar-compressed",rtf:"application/rtf",sh:"application/x-sh",svg:"image/svg+xml",swf:"application/x-shockwave-flash",tar:"application/x-tar",tif:"image/tiff",tiff:"image/tiff",ts:"application/typescript",ttf:"font/ttf",txt:"text/plain",vsd:"application/vnd.visio",wav:"audio/x-wav",weba:"audio/webm",webm:"video/webm",webp:"image/webp",woff:"font/woff",woff2:"font/woff2",xhtml:"application/xhtml+xml",xls:"application/vnd.ms-excel",xlsx:"application/vnd.ms-excel",xml:"application/xml",xul:"application/vnd.mozilla.xul+xml",zip:"application/zip","3gp":"video/3gpp","3gp2":"video/3gpp2","7z":"application/x-7z-compressed"};function Dl(e){return["text/html","text/css"].includes(e)?`${e}; charset=utf-8`:e}function Nl(e){if(!function(e){return!!Array.isArray(e)&&e.every((e=>"object"==typeof e&&e.path&&void 0!==e.size))}(e))throw new nu("invalid collection",e)}function Pl(e){if(e.webkitRelativePath&&""!==e.webkitRelativePath)return e.webkitRelativePath.replace(/.*?\//i,"");if(e.name)return e.name;throw new TypeError("file is not valid File object")}function Cl(e){return Array.from(e).map((e=>({path:Pl(e),size:e.size,file:e})))}function Fl(e){return Array.from(e).reduce(((e,t)=>e+t.size),0)}class Gl{output=new cu.PassThrough;currentFileSize=0;beginFile(e,t){const{name:n,prefix:r,longLink:o}=function(e){if(e.length<=100)return{name:e,prefix:"",longLink:!1};for(let r=e.length-1;r>=0;r--)if("/"===e[r]){const t=e.substring(r+1),n=e.substring(0,r);if(t.length<=100&&n.length<=155)return{name:t,prefix:n,longLink:!1}}const t=e.lastIndexOf("/"),n=(t>=0?e.substring(t+1):e).slice(0,100);return{name:n,prefix:"",longLink:!0}}(e);if(o){const t=Buffer.from(e+"\0");this.output.write(function(e){const t=Buffer.alloc(512,0);t.write("././@LongLink",0,100),t.write("0000644\0",100,8),t.write("0000000\0",108,8),t.write("0000000\0",116,8),t.write(e.toString(8).padStart(11,"0")+"\0",124,12),t.write("00000000000\0",136,12),t.write(" ",148,8),t.write("L",156,1),t.write("ustar\0\0",257,8);let n=0;for(let r=0;r<512;r++)n+=t[r];return t.write(n.toString(8).padStart(6,"0")+"\0 ",148,8),t}(t.length)),this.output.write(t);const n=t.length%512==0?0:512-t.length%512;n>0&&this.output.write(Buffer.alloc(n,0))}const i=function(e,t,n){const r=Buffer.alloc(512,0);r.write(e.slice(0,100).padEnd(100,"\0"),0,100),r.write("0000777\0",100,8),r.write("0001750\0",108,8),r.write("0001750\0",116,8),r.write(n.toString(8).padStart(11,"0")+"\0",124,12);const o=Math.floor((new Date).getTime()/1e3);r.write(o.toString(8).padStart(11,"0")+"\0",136,12),r.write(" ",148,8),r.write("0",156,1),r.write("ustar\0\0",257,8),t&&r.write(t.slice(0,155).padEnd(155,"\0"),345,155);let i=0;for(let s=0;s<512;s++)i+=r[s];return r.write(i.toString(8).padStart(6,"0")+"\0 ",148,8),r}(n,r,t);this.output.write(i),this.currentFileSize=0}async appendFile(e){return new Promise((t=>{this.output.write(e)?t():this.output.once("drain",(()=>{t()})),this.currentFileSize+=e.length}))}async endFile(){const e=this.currentFileSize%512==0?0:512-this.currentFileSize%512;e>0&&this.output.write(Buffer.alloc(e,0))}async end(){return new Promise((e=>{this.output.write(Buffer.alloc(1024,0)),this.output.end((()=>{e()}))}))}}async function Ml(e,t,n,r){const o=new Gl,i=Jc(e,{method:"post",url:"bzz",data:o.output,responseType:"json",headers:{"content-type":"application/x-tar","swarm-collection":"true",...Yu(n,r)}});await async function(e,t){for(const n of e)if(t.beginFile(n.path,n.size),n.fsPath){const e=(0,Tl.createReadStream)(n.fsPath);for await(const n of e)await t.appendFile(n);await t.endFile(),e.close()}else{if(!n.file)throw new Error("Invalid collection item");await t.appendFile(new Uint8Array(await n.file.arrayBuffer())),await t.endFile()}}(t,o),await o.end();return await i}const Ul="bzz";async function Ll(e,t,n,r,o){Gu(t)&&!o?.contentType&&(o||(o={}),o.contentType="application/octet-stream");const i=await Jc(e,{method:"post",url:Ul,data:t,headers:Yu(n,o),params:{name:r},responseType:"json"});return{reference:eu.parse(i.data).reference,tagUid:i.headers["swarm-tag"]?Lu(i.headers["swarm-tag"]):void 0,historyAddress:i.headers["swarm-act-history-address"]?cr.Xx.of(new nn(i.headers["swarm-act-history-address"])):cr.Xx.empty()}}async function jl(e,t,n,r){Nl(t);const o=await Ml(e,t,n,r);return{reference:eu.parse(o.data).reference,tagUid:o.headers["swarm-tag"]?Lu(o.headers["swarm-tag"]):void 0,historyAddress:o.headers["swarm-act-history-address"]?cr.Xx.of(new nn(o.headers["swarm-act-history-address"])):cr.Xx.empty()}}class Zl{constructor(e){this.context=e}async upload(e,t,n,r){const o=new Pt(e);return Nl(t),n&&(n=Iu.parse(n)),jl(this.context.getRequestOptionsForCall(r),t,o,n)}async uploadFromFileList(e,t,n,r){const o=new Pt(e);n&&(n=Iu.parse(n));const i=Cl(t);return jl(this.context.getRequestOptionsForCall(r),i,o,n)}async uploadFromDirectory(e,t,n,r){const o=new Pt(e);n&&(n=Iu.parse(n));const i=await $l(t);return jl(this.context.getRequestOptionsForCall(r),i,o,n)}async stream(e,t,n,r,o){new Pt(e);return async function(){throw new Error("Streaming files is not supported in Node.js")}(this.context.bee,0,0,0,0,this.context.getRequestOptionsForCall(o))}async streamFromDirectory(e,t,n,r,o){const i=new Pt(e);return async function(e,t,n,r,o,i){const s=new cr.O3(64,64);let a=0,c=0;n=new Pt(n);const u=await $l(t);for(const m of u)a+=(l=m.size,function e(t){return t<=1?t:t+e(Math.ceil(t/128))}(Math.ceil(l/4096)));var l;let f=!1;async function h(t){await e.chunk.upload(n,t.build(),o,i),r?.({total:a,processed:++c})}async function d(e){for(const{chunk:t}of e)await s.enqueue((async()=>h(t)));return[]}const p=new kl;for(const m of u){if(!m.fsPath)throw Error("File does not have fsPath, which should never happen in node. Please report this issue.");const e=(0,Tl.createReadStream)(m.fsPath),t=new An(d);for await(const i of e)await t.append(i);const n=await t.finalize();await s.enqueue((async()=>h(n))),await s.drain();const{filename:r,extension:o}=cr.DH.parseFilename(m.path);p.addFork(m.path,n.hash(),{"Content-Type":Dl(Vl[o.toLowerCase()]||"application/octet-stream"),Filename:r}),"index.html"===m.path&&(f=!0)}if(f||o?.indexDocument||o?.errorDocument){const e={};o?.indexDocument?e["website-index-document"]=o.indexDocument:f&&(e["website-index-document"]="index.html"),o?.errorDocument&&(e["website-error-document"]=o.errorDocument),p.addFork("/",qh,e)}return p.saveRecursively(e,n,o,i)}(this.context.bee,t,i,n,r,this.context.getRequestOptionsForCall(o))}async hashDirectory(e){return async function(e){const t=await $l(e),n=new kl;for(const r of t){const e=new An(An.NOOP);if(!r.fsPath)throw Error("File does not have fsPath, which should never happen in node. Please report this issue.");const t=(0,Tl.createReadStream)(r.fsPath);for await(const n of t)await e.append(n);const o=await e.finalize(),{filename:i,extension:s}=cr.DH.parseFilename(r.path);n.addFork(r.path,o.hash(),{"Content-Type":Dl(Vl[s.toLowerCase()]||"application/octet-stream"),Filename:i})}return n.calculateSelfAddress()}(e)}}const ql=wc({address:Va(),fullNode:sc()}),Hl=wc({population:nc(),connected:nc(),connectedPeers:gc(wc({address:Va()})).nullish().transform((e=>e??[])),disconnectedPeers:gc(wc({address:Va()})).nullish().transform((e=>e??[]))}),Wl=Rc(Va(),Hl),Jl=wc({overlay:Va().transform((e=>new qt(e))),underlay:gc(Va()),ethereum:Va().transform((e=>new Mt(e))),publicKey:Va().transform((e=>new Jt(e))),pssPublicKey:Va().transform((e=>new Jt(e)))}),Kl=wc({peers:gc(ql)}),Xl=wc({peers:gc(ql)}),Yl=wc({baseAddr:Va(),population:nc(),connected:nc(),timestamp:Va(),nnLowWatermark:nc(),depth:nc(),reachability:Va(),networkAvailability:Va(),bins:Wl}),Ql=wc({overlay:Va(),proximity:nc(),beeMode:Va().transform(hu),reserveSize:nc(),reserveSizeWithinRadius:nc(),pullsyncRate:nc(),storageRadius:nc(),connectedPeers:nc(),neighborhoodSize:nc(),batchCommitment:nc(),isReachable:sc(),lastSyncedBlock:nc(),committedDepth:nc(),isWarmingUp:sc()}),ef=wc({apiVersion:Va(),version:Va(),status:(tf="ok",new kc({type:"literal",values:Array.isArray(tf)?tf:[tf],...io(nf)}))});var tf,nf;const rf=wc({apiVersion:Va(),version:Va(),status:Ac(["ready","notReady"])}),of=wc({beeMode:Va().transform(hu),chequebookEnabled:sc(),swapEnabled:sc()}),sf=wc({gateway:sc()}),af="peers";class cf{constructor(e){this.context=e}async checkConnection(e){return async function(e){await Jc(e,{url:"",responseType:"text"})}(this.context.getRequestOptionsForCall(e))}async isConnected(e){try{await this.checkConnection(e)}catch{return!1}return!0}async isGateway(e){try{return await async function(e){const t=await Jc(e,{url:"/gateway"});return sf.parse(t.data).gateway}(this.context.getRequestOptionsForCall(e))}catch{return!1}}async getNodeAddresses(e){return async function(e){const t=await Jc(e,{url:"addresses",responseType:"json"});return Jl.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getBlocklist(e){return async function(e){const t=await Jc(e,{url:"blocklist",responseType:"json"});return Xl.parse(t.data).peers}(this.context.getRequestOptionsForCall(e))}async getPeers(e){return async function(e){const t=await Jc(e,{url:af,responseType:"json"});return Kl.parse(t.data).peers}(this.context.getRequestOptionsForCall(e))}async removePeer(e,t){const n=new qt(e);return async function(e,t){return(await Jc(e,{url:`${af}/${t}`,responseType:"json",method:"DELETE"})).data}(this.context.getRequestOptionsForCall(t),n)}async getTopology(e){return async function(e){const t=await Jc(e,{url:"topology",responseType:"json"});return Yl.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async ping(e,t){const n=new qt(e);return async function(e,t){return(await Jc(e,{url:`pingpong/${t}`,responseType:"json",method:"POST"})).data}(this.context.getRequestOptionsForCall(t),n)}}const uf="bytes";async function lf(e,t,n,r){const o=await Jc(e,{url:uf,method:"post",responseType:"json",data:t,headers:{"content-type":"application/octet-stream",...Yu(n,r)}});return{reference:eu.parse(o.data).reference,tagUid:o.headers["swarm-tag"]?Lu(o.headers["swarm-tag"]):void 0,historyAddress:o.headers["swarm-act-history-address"]?cr.Xx.of(new nn(o.headers["swarm-act-history-address"])):cr.Xx.empty()}}async function ff(e,t,n){n&&(n=ku.parse(n));const r=await Jc(e,{responseType:"arraybuffer",url:`${uf}/${t}`,headers:Yu(null,n)});return new Nt(r.data)}const hf=wc({isRetrievable:sc()}),df="stewardship";class pf{constructor(e){this.raw=e}toString(){const e=Va().safeParse(this.raw);return e.success&&e.data.includes(".eth")?e.data:new nn(this.raw).toHex()}}class mf{constructor(e){this.context=e}async upload(e,t,n,r){const o=new Pt(e);return Uu(t),n&&(n=Ou.parse(n)),lf(this.context.getRequestOptionsForCall(r),t,o,n)}async download(e,t,n){return t&&(t=ku.parse(t)),ff(this.context.getRequestOptionsForCall(n),new pf(e),t)}async downloadReadable(e,t,n){return t&&(t=ku.parse(t)),async function(e,t,n){return n&&(n=ku.parse(n)),(await Jc(e,{responseType:"stream",url:`${uf}/${t}`,headers:Yu(null,n)})).data}(this.context.getRequestOptionsForCall(n),new pf(e),t)}async probe(e,t){const n=new nn(e);return async function(e,t){const n=await Jc(e,{url:`${uf}/${t}`,method:"head",responseType:"json"});return{contentLength:parseInt(n.headers["content-length"])}}(this.context.getRequestOptionsForCall(t),n)}async isRetrievable(e,t){const n=new nn(e);return async function(e,t){const n=await Jc(e,{method:"get",responseType:"json",url:`${df}/${t}`});return hf.parse(n.data).isRetrievable}(this.context.getRequestOptionsForCall(t),n)}}const gf="feeds";function yf(e){const t=e["swarm-feed-index"],n=e["swarm-feed-index-next"];if(!t)throw new tu("Response did not contain expected swarm-feed-index!");if(!n)throw new tu("Response did not contain expected swarm-feed-index-next!");return{feedIndex:new Lt(t),feedIndexNext:new Lt(n)}}async function wf(e,t,n,r){const o=await Jc(e,{responseType:"arraybuffer",url:`${gf}/${t}/${n}`,params:{...r}});return{payload:new Nt(o.data),...yf(o.headers)}}async function bf(e,t,n){return yf((await Jc(e,{responseType:"arraybuffer",url:`${gf}/${t}/${n}`,params:{"Swarm-Only-Root-Chunk":!0}})).headers)}function vf(e,t){return t="number"==typeof t?Lt.fromBigInt(BigInt(t)):t,new Zt(Ot(Nt.concat(e.toUint8Array(),t.toUint8Array())))}async function Bf(e,t,n){try{const r=await wf(e,t,n);if(!r.feedIndexNext)throw Error("Feed index next is not defined. This should happen when fetching an exact index.");return r.feedIndexNext}catch(r){if(r instanceof ru)return Lt.fromBigInt(0n);throw r}}async function Ef(e,t,n,r,o,i){r=new nn(r);const s=vf(n,i?.index??await Bf(e,t.publicKey().address(),n)),a=i?.at??Date.now()/1e3,c=At(BigInt(Math.floor(a)),"BE");return rl(e,t,o,s,Nt.concat(c,r.toUint8Array()),i)}async function xf(e,t,n,r,o,i){const s=vf(n,i?.index??await Bf(e,t.publicKey().address(),n));if(r.length>4096){const n=await lf(e,r,o,i);return ol(e,t,o,s,Rn(await el(e,n.reference)),i)}const a=Va().safeParse(r);return rl(e,t,o,s,a.success?Nt.fromUtf8(a.data).toUint8Array():r,i)}function Tf(e,t,n){const r=vf(t,n);return new nn(Ot(Nt.concat(r.toUint8Array(),e.toUint8Array())))}async function Rf(e,t,n,r,o=!1){const i=Tf(t,n,r="number"==typeof r?Lt.fromBigInt(BigInt(r)):r),s=tl(await el(e,i.toHex()),i);let a=cr.Xx.empty();if(o){const e=Nt.fromSlice(s.payload.toUint8Array(),0,8);a=cr.Xx.of(Number(kt(e.toUint8Array(),"BE")))}return{timestamp:a,payload:new Nt(s.payload.offset(o?8:0))}}async function zf(e,t,n,r){const o=Tf(t,n,r="number"==typeof r?Lt.fromBigInt(BigInt(r)):r),i=tl(await el(e,o),o);return Tn(i.payload,i.span)}function Af(e,t,n){const r=async r=>{if(void 0===r?.index)return wf(e,n,t);const o=await Rf(e,n,t,r.index,r.hasTimestamp??!0),i="number"==typeof r.index?Lt.fromBigInt(BigInt(r.index)):r.index;return{payload:o.payload,feedIndex:i,feedIndexNext:i.next()}};return{download:r,downloadPayload:async r=>{if(void 0===r?.index)return wf(e,n,t);const o=await zf(e,n,t,r.index),i=o.span.toBigInt()<=4096n?o.payload:await ff(e,new pf(o.address)),s="number"==typeof r.index?Lt.fromBigInt(BigInt(r.index)):r.index;return{payload:i,feedIndex:s,feedIndexNext:s.next()}},downloadReference:async o=>{let i=o?.index;void 0===i&&(i=(await bf(e,n,t)).feedIndex);const s=await r({...o,index:i});return{reference:new nn(s.payload.toUint8Array()),feedIndex:s.feedIndex,feedIndexNext:s.feedIndexNext??s.feedIndex.next()}},owner:n,topic:t}}async function kf(e,t,n,r,o,i){const s=function(e,t,n){const r=n.toBigInt(),o=[];for(let i=0n;i<=r;i++)o.push(Tf(e,t,Lt.fromBigInt(i)));return o}(t,n,r).map((async t=>async function(e,t,n,r){try{return await e.chunk.download(t,n,r),!0}catch(o){const e=cr.Rb.getDeep(o,"status");if(404===e||500===e)return!1;throw o}}(e,t,o,i)));return(await Promise.all(s)).every((e=>e))}class Sf{constructor(e){this.context=e}makeReader(e,t,n){return Af(this.context.getRequestOptionsForCall(n),new sn(e),new Mt(t))}makeWriter(e,t,n){const r=t?new en(t):this.context.signer;if(!r)throw Error("No signer provided");return function(e,t,n){const r=async(r,o,i)=>Ef(e,n,t,o,r,i);return{...Af(e,t,n.publicKey().address()),upload:r,uploadReference:r,uploadPayload:async(r,o,i)=>xf(e,n,t,o,r,i)}}(this.context.getRequestOptionsForCall(n),new sn(e),r)}async createManifest(e,t,n,r,o){const i=new Pt(e),s=new sn(t),a=new Mt(n);return r&&(r=Su.parse(r)),async function(e,t,n,r,o){const i=await Jc(e,{method:"post",responseType:"json",url:`${gf}/${t}/${n}`,headers:Yu(r,o)});return eu.parse(i.data).reference}(this.context.getRequestOptionsForCall(o),a,s,i,r)}async fetchLatestUpdate(e,t,n){return wf(this.context.getRequestOptionsForCall(n),new Mt(t),new sn(e))}async isRetrievable(e,t,n,r,o){const i=new Mt(e),s=new sn(t);if(r&&(r=ku.parse(r)),!n)try{return await this.makeReader(s,i,o).download(),!0}catch(a){const e=cr.Rb.getDeep(a,"status");if(404===e||500===e)return!1;throw a}return kf(this.context.bee,i,s,n,r,this.context.getRequestOptionsForCall(o))}}class Of{constructor(e){this.context=e}async upload(e,t,n,r,o){const i=new Pt(e);if(function(e){if(!("string"==typeof e||e instanceof Uint8Array||uu(e)||Gu(e)))throw new TypeError("Data must be either string, Readable, Uint8Array or File!")}(t),r&&(r=$u.parse(r)),n&&"string"!=typeof n)throw new TypeError("name has to be string or undefined!");if(uu(t)){const e=await async function(e){return e.arrayBuffer?e.arrayBuffer():new Promise((t=>{const n=new FileReader;n.onload=()=>t(n.result),n.readAsArrayBuffer(e)}))}(t),s=n??t.name,a=t.type,c={...r,contentType:a};return Ll(this.context.getRequestOptionsForCall(o),e,i,s,c)}return Ll(this.context.getRequestOptionsForCall(o),t,i,n,r)}async download(e,t="",n,r){return n&&(n=ku.parse(n)),async function(e,t,n="",r){const o=await Jc(e,{method:"GET",responseType:"arraybuffer",url:`${Ul}/${t}/${n}`,headers:Yu(null,r)});return{...Xu(o.headers),data:new Nt(o.data)}}(this.context.getRequestOptionsForCall(r),new pf(e),t,n)}async downloadReadable(e,t="",n,r){const o=new nn(e);return n&&(n=ku.parse(n)),async function(e,t,n="",r){t=new nn(t);const o=await Jc(e,{method:"GET",responseType:"stream",url:`${Ul}/${t}/${n}`,headers:Yu(null,r)});return{...Xu(o.headers),data:o.data}}(this.context.getRequestOptionsForCall(r),o,t,n)}}const $f=gc(Va().transform((e=>new Jt(e)))),If=wc({ref:Va().transform((e=>new nn(e))),historyref:Va().transform((e=>new nn(e)))}),_f="grantee";class Vf{constructor(e){this.context=e}async create(e,t,n){const r=new Pt(e),o=t.map((e=>new Jt(e)));return async function(e,t,n){const r=await Jc(e,{method:"post",url:_f,data:{grantees:n.map((e=>e.toCompressedHex()))},headers:Yu(t),responseType:"json"}),o=If.parse(r.data);return{status:r.status,statusText:r.statusText,ref:o.ref,historyref:o.historyref}}(this.context.getRequestOptionsForCall(n),r,o)}async get(e,t){const n=new nn(e);return async function(e,t){const n=await Jc(e,{method:"get",url:`${_f}/${t}`,responseType:"json"});return{status:n.status,statusText:n.statusText,grantees:$f.parse(n.data)}}(this.context.getRequestOptionsForCall(t),n)}async patch(e,t,n,r,o){const i=new Pt(e),s=new nn(t),a=new nn(n),c={add:r.add?.map((e=>new Jt(e)))??[],revoke:r.revoke?.map((e=>new Jt(e)))??[]};return async function(e,t,n,r,o){const i=await Jc(e,{method:"patch",url:`${_f}/${n}`,data:{add:o.add.map((e=>e.toCompressedHex())),revoke:o.revoke.map((e=>e.toCompressedHex()))},headers:{...Yu(t),"swarm-act-history-address":r.toHex()},responseType:"json"}),s=If.parse(i.data);return{status:i.status,statusText:i.statusText,ref:s.ref,historyref:s.historyref}}(this.context.getRequestOptionsForCall(o),i,s,a,c)}}var Df=null;"undefined"!=typeof WebSocket?Df=WebSocket:"undefined"!=typeof MozWebSocket?Df=MozWebSocket:void 0!==n.g?Df=n.g.WebSocket||n.g.MozWebSocket:"undefined"!=typeof window?Df=window.WebSocket||window.MozWebSocket:"undefined"!=typeof self&&(Df=self.WebSocket||self.MozWebSocket);const Nf=Df;async function Pf(e){if("string"==typeof e)return(new TextEncoder).encode(e);if(e instanceof Buffer)return new Uint8Array(e);if(e instanceof ArrayBuffer)return new Uint8Array(e);if(t=e,Array.isArray(t)&&t.length>0&&t.every((e=>e instanceof Buffer)))return new Uint8Array(Buffer.concat(e));var t;throw new TypeError("unknown websocket data type")}class Cf{constructor(e){this.context=e}async pssSend(e,t,n,r,o,i){const s=new Pt(e);Uu(r);const a=o?new Jt(o):void 0;await async function(e,t,n,r,o,i){await Jc(e,{method:"post",url:`pss/send/${n}/${r}`,data:o,responseType:"json",params:{recipient:i},headers:Yu(t)})}(this.context.getRequestOptionsForCall(i),s,t,n,r,a)}pssSubscribe(e,t){t=Du.parse(t);const n=this.openWebSocket(`pss/subscribe/${e.toHex()}`),r={topic:e,cancel:this.makeCancel(n)};return n.onmessage=async e=>{const n=await Pf(e.data);n.length&&t.onMessage(new Nt(n),r)},n.onerror=e=>{this.isCancelled(n)||t.onError(new tu(e.message),r)},n.onclose=()=>{t.onClose(r)},r}async pssReceive(e,t=0){if("number"!=typeof t)throw new TypeError("timeoutMsc parameter has to be a number!");return new Promise(((n,r)=>{let o;const i=this.pssSubscribe(e,{onError:e=>{clearTimeout(o),i.cancel(),r(e.message)},onMessage:e=>{clearTimeout(o),i.cancel(),n(e)},onClose:()=>{clearTimeout(o),i.cancel()}});t>0&&(o=setTimeout((()=>{i.cancel(),r(new tu("pssReceive timeout"))}),t))}))}gsocMine(e,t,n=12){const r=new qt(e),o=new Zt(t);for(let i=0n;i<0xffffn;i++){const e=new en(mt(2867n+i,"BE")),t=Bn(o,e.publicKey().address());if(256-cr.yI.proximity(t.toUint8Array(),r.toUint8Array())<=256-n)return e}throw Error("Could not mine a valid signer")}async gsocSend(e,t,n,r,o,i){const s=new Pt(e),a=new en(t),c=new Zt(n),u=Tn(r).toSingleOwnerChunk(c,a);return nl(this.context.getRequestOptionsForCall(i),u,s,o)}gsocSubscribe(e,t,n){const r=new Mt(e),o=new Zt(t);n=Nu.parse(n);const i=Bn(o,r),s=this.openWebSocket(`gsoc/subscribe/${i.toHex()}`),a={address:r,cancel:this.makeCancel(s)};return s.onmessage=async e=>{const t=await Pf(e.data);t.length&&n.onMessage(new Nt(t),a)},s.onerror=e=>{this.isCancelled(s)||n.onError(new tu(e.message),a)},s.onclose=()=>{n.onClose(a)},a}openWebSocket(e){const t=this.context.url.replace(/^http/i,"ws");return"browser"===cr.iQ.whereAmI()?new Nf(`${t}/${e}`):new Nf(`${t}/${e}`,{headers:this.context.getRequestOptionsForCall().headers})}cancelled=new WeakSet;makeCancel(e){return()=>{this.cancelled.has(e)||(this.cancelled.add(e),e.terminate?e.terminate():e.close())}}isCancelled(e){return this.cancelled.has(e)}}const Ff=wc({references:gc(Va()).nullable()}),Gf="pins";class Mf{constructor(e){this.context=e}async add(e,t){const n=new nn(e);await async function(e,t){await Jc(e,{method:"post",responseType:"json",url:`${Gf}/${t}`})}(this.context.getRequestOptionsForCall(t),n)}async remove(e,t){const n=new nn(e);await async function(e,t){await Jc(e,{method:"delete",responseType:"json",url:`${Gf}/${t}`})}(this.context.getRequestOptionsForCall(t),n)}async getAll(e){return async function(e){const t=await Jc(e,{method:"get",responseType:"json",url:Gf}),{references:n}=Ff.parse(t.data);return(n??[]).map((e=>new nn(e)))}(this.context.getRequestOptionsForCall(e))}async get(e,t){const n=new nn(e);return async function(e,t){const n=await Jc(e,{method:"get",responseType:"json",url:`${Gf}/${t}`});return eu.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async reuploadData(e,t,n){const r=new Pt(e),o=new nn(t);await async function(e,t,n){await Jc(e,{method:"put",url:`${df}/${n}`,headers:{"swarm-postage-batch-id":t.toHex()}})}(this.context.getRequestOptionsForCall(n),r,o)}}function Uf(e,t){if(t<=0)throw new tu("Period length must be greater than zero!");return Math.floor(e/t)}function Lf(e,t){const n=e.toUint8Array();return new sn(Ot(Nt.concat(n,At(BigInt(t),"BE"))))}async function jf(e,t,n){try{return await bf(e,t,n),!0}catch(r){if(r instanceof ru)return!1;throw r}}async function Zf(e,t,n){const{feedIndex:r}=await bf(e,t,n),o=await Rf(e,t,n,r,!0);return{reference:new nn(o.payload.toUint8Array()),feedIndex:r,feedIndexNext:r.next()}}class qf{constructor(e){this.context=e}makeWriter(e,t,n){return new Hf(this.context,e,t,n)}makeReader(e,t,n){return new Wf(this.context,e,t,n)}}class Hf{constructor(e,t,n,r){this.context=e,this.baseTopic=t,this.signer=n,this.periodLength=r}async uploadPayload(e,t,n){const r=this.context.getRequestOptionsForCall(),o=new Pt(e),{currentTopic:i,nextTopic:s,mirrorOptions:a}=this.currentAndNextTopics(n),[c]=await Promise.all([xf(r,this.signer,i,t,o,n),xf(r,this.signer,s,t,o,a)]);return c}async uploadReference(e,t,n){const r=this.context.getRequestOptionsForCall(),o=new Pt(e),{currentTopic:i,nextTopic:s,mirrorOptions:a}=this.currentAndNextTopics(n),[c]=await Promise.all([Ef(r,this.signer,i,t,o,n),Ef(r,this.signer,s,t,o,a)]);return c}async isCaughtUp(e){const t=this.context.getRequestOptionsForCall(),n=e??Uf(Date.now()/1e3,this.periodLength);return jf(t,this.signer.publicKey().address(),Lf(this.baseTopic,n))}async catchUp(e,t,n=1){const r=this.context.getRequestOptionsForCall(),o=new Pt(e),i=this.signer.publicKey().address(),s=t??Uf(Date.now()/1e3,this.periodLength),a=Math.max(0,s-1-n);let c=s-1;for(;c>=a&&!await jf(r,i,Lf(this.baseTopic,c));)c--;if(c<a)throw new tu(`No populated period found within ${n} periods to catch up from!`);if(c===s-1)return;const u=Lf(this.baseTopic,c),{feedIndex:l}=await bf(r,i,u),f=await zf(r,i,u,l),h=Array.from({length:s-1-c},((e,t)=>c+1+t));await Promise.all(h.map((async e=>{const t=vf(Lf(this.baseTopic,e),0);return ol(r,this.signer,o,t,f)})))}currentAndNextTopics(e){const t=Uf(Date.now()/1e3,this.periodLength);return{currentTopic:Lf(this.baseTopic,t),nextTopic:Lf(this.baseTopic,t+1),mirrorOptions:{...e,index:void 0}}}}class Wf{constructor(e,t,n,r){this.context=e,this.baseTopic=t,this.owner=n,this.periodLength=r}async downloadPayload(e){const t=this.context.getRequestOptionsForCall(),n=Uf(Date.now()/1e3,this.periodLength);try{return await wf(t,this.owner,Lf(this.baseTopic,n),e)}catch(r){if(!(r instanceof ru))throw r;return wf(t,this.owner,Lf(this.baseTopic,n-1),e)}}async downloadReference(){const e=this.context.getRequestOptionsForCall(),t=Uf(Date.now()/1e3,this.periodLength);try{return await Zf(e,this.owner,Lf(this.baseTopic,t))}catch(n){if(!(n instanceof ru))throw n;return Zf(e,this.owner,Lf(this.baseTopic,t-1))}}}const Jf=wc({peer:Va(),sent:Va().transform((e=>su.fromPLUR(Mu(e,{name:"sent"})))),received:Va().transform((e=>su.fromPLUR(Mu(e,{name:"received"}))))}),Kf=Jf,Xf=wc({totalSent:Va().transform((e=>su.fromPLUR(Mu(e,{name:"totalSent"})))),totalReceived:Va().transform((e=>su.fromPLUR(Mu(e,{name:"totalReceived"})))),settlements:gc(Jf)}),Yf="settlements";class Qf{constructor(e){this.context=e}async get(e,t){const n=new qt(e);return async function(e,t){const n=await Jc(e,{url:`${Yf}/${t}`,responseType:"json"});return Kf.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async getAll(e){return async function(e){const t=await Jc(e,{url:Yf,responseType:"json"});return Xf.parse(t.data)}(this.context.getRequestOptionsForCall(e))}}class eh{constructor(e){this.context=e}makeReader(e,t){const n=new Mt(e);return{owner:n,download:il.bind(null,this.context.getRequestOptionsForCall(t),n)}}makeWriter(e,t){const n=e?new en(e):this.context.signer;if(!n)throw Error("No signer provided");return{...this.makeReader(n.publicKey().address(),t),upload:rl.bind(null,this.context.getRequestOptionsForCall(t),n)}}}const th=wc({stakedAmount:Va().transform((e=>su.fromPLUR(Mu(e,{name:"stakedAmount"}))))}),nh=wc({withdrawableAmount:Va().transform((e=>su.fromPLUR(Mu(e,{name:"withdrawableAmount"}))))}),rh=wc({txHash:Va().transform((e=>new an(e)))}),oh=wc({minimumGasFunds:Va().transform((e=>au.fromWei(Mu(e,{name:"minimumGasFunds"})))),hasSufficientFunds:sc(),isFrozen:sc(),isFullySynced:sc(),phase:Va(),round:nc(),lastWonRound:nc(),lastPlayedRound:nc(),lastFrozenRound:nc(),lastSelectedRound:nc(),lastSampleDurationSeconds:nc(),block:nc(),reward:Va().transform((e=>su.fromPLUR(Mu(e,{name:"reward"})))),fees:Va().transform((e=>au.fromWei(Mu(e,{name:"fees"})))),isHealthy:sc()}),ih="stake";class sh{constructor(e){this.context=e}async get(e){return async function(e){const t=await Jc(e,{method:"get",responseType:"json",url:ih});return th.parse(t.data).stakedAmount}(this.context.getRequestOptionsForCall(e))}async getWithdrawable(e){return async function(e){const t=await Jc(e,{method:"get",responseType:"json",url:`${ih}/withdrawable`});return nh.parse(t.data).withdrawableAmount}(this.context.getRequestOptionsForCall(e))}async deposit(e,t,n){const r=e instanceof su?e.toPLURString():Mu(e,{min:1n,name:"amount"});return t&&(t=Cu.parse(t)),async function(e,t,n){const r=await Jc(e,{method:"post",responseType:"json",url:`${ih}/${t}`,headers:Yu(null,n)});return rh.parse(r.data).txHash}(this.context.getRequestOptionsForCall(n),r,t)}async withdrawSurplus(e){return async function(e){const t=await Jc(e,{method:"delete",responseType:"json",url:`${ih}/withdrawable`});return rh.parse(t.data).txHash}(this.context.getRequestOptionsForCall(e))}async migrate(e){return async function(e){const t=await Jc(e,{method:"delete",responseType:"json",url:ih});return rh.parse(t.data).txHash}(this.context.getRequestOptionsForCall(e))}async getRedistributionState(e){return async function(e){const t=await Jc(e,{method:"get",responseType:"json",url:"redistributionstate"});return oh.parse(t.data)}(this.context.getRequestOptionsForCall(e))}}const ah=wc({batchID:Va(),utilization:nc(),utilizationRatio:nc().optional(),usable:sc(),label:Va(),depth:nc(),amount:Va(),bucketDepth:nc(),blockNumber:nc(),immutableFlag:sc(),batchTTL:nc()}),ch=wc({batchID:Va().transform((e=>new Pt(e))),batchTTL:nc(),bucketDepth:nc(),depth:nc(),immutable:sc(),owner:Va().transform((e=>new Mt(e))),start:nc(),value:Va().transform((e=>Mu(e,{name:"value"})))}),uh=wc({batches:gc(ch)}),lh=wc({stamps:gc(ah)}),fh=ah,hh=wc({depth:nc(),bucketDepth:nc(),bucketUpperBound:nc(),buckets:gc(wc({bucketID:nc(),collisions:nc()}))}),dh=wc({batchID:Va().transform((e=>new Pt(e)))}),ph="stamps";const mh="batches";class gh{constructor(e){this.context=e}async create(e,t,n,r){const o=Mu(e,{min:0n,name:"amount"});if(n&&(n=Pu.parse(n)),t<yu||t>wu)throw new nu(`Depth has to be between ${yu}..${wu}`,t);const i=await this.context.bee.status.getChainState(),s=17280n*BigInt(i.currentPrice)+1n;if(BigInt(o)<s)throw new nu(`Amount has to be at least ${s} (1 day at current price ${i.currentPrice})`,o);const a=await async function(e,t,n,r,o,i){const s={};o&&(s["gas-price"]=o),void 0!==i&&(s.immutable=String(i));const a=await Jc(e,{method:"post",url:`${ph}/${t}/${n}`,responseType:"json",params:{label:r},headers:s});return dh.parse(a.data).batchID}(this.context.getRequestOptionsForCall(r),o,t,n?.label,n?.gasPrice?.toString(),n?.immutableFlag);return!1!==n?.waitForUsable&&await this.waitForUsable(a,n?.waitForUsableTimeout),a}async updateLabel(e,t,n){const r=new Pt(e);await async function(e,t,n){await Jc(e,{method:"patch",url:`${ph}/${t}`,responseType:"json",data:{label:n}})}(this.context.getRequestOptionsForCall(n),r,t)}async calculateTopUpForBZZ(e,t,n){const r=await this.context.bee.status.getChainState(n),o="gnosis"===this.context.network?5:15,i=t.toPLURBigInt()/2n**BigInt(e);return{amount:i,duration:Zu(i,r.currentPrice,o)}}async topUp(e,t,n){const r=new Pt(e),o=Mu(t,{min:1n,name:"amount"});return async function(e,t,n){const r=await Jc(e,{method:"patch",url:`${ph}/topup/${t}/${n}`,responseType:"json"});return dh.parse(r.data).batchID}(this.context.getRequestOptionsForCall(n),r,o)}async dilute(e,t,n){const r=new Pt(e),o=nc().int().min(18).max(255).parse(t);return async function(e,t,n){const r=await Jc(e,{method:"patch",url:`${ph}/dilute/${t}/${n}`,responseType:"json"});return dh.parse(r.data).batchID}(this.context.getRequestOptionsForCall(n),r,o)}async get(e,t,n,r){const o=new Pt(e);return async function(e,t,n,r){const o=await Jc(e,{method:"get",url:`${ph}/${t}`,responseType:"json"});return Ju(fh.parse(o.data),n,r)}(this.context.getRequestOptionsForCall(t),o,n,r)}async getGlobal(e,t){const n=new Pt(e);return async function(e,t){const n=await Jc(e,{method:"get",url:`${mh}/${t}`,responseType:"json"});return ch.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async getBuckets(e,t){const n=new Pt(e);return async function(e,t){const n=await Jc(e,{method:"get",url:`${ph}/${t}/buckets`,responseType:"json"});return hh.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async getAll(e){return async function(e){const t=await Jc(e,{method:"get",url:ph,responseType:"json"});return lh.parse(t.data).stamps.map((e=>Ju(e)))}(this.context.getRequestOptionsForCall(e))}async getAllGlobal(e){return async function(e){const t=await Jc(e,{method:"get",url:mh,responseType:"json"});return uh.parse(t.data).batches}(this.context.getRequestOptionsForCall(e))}async waitForUsable(e,t=24e4){for(let n=0;n<t;n+=3e3){try{if((await this.get(e)).usable)return}catch{}await cr.iQ.sleepMillis(3e3)}throw new tu("Timeout on waiting for postage stamp to become usable")}}var yh=n(359),wh=n.n(yh);const bh="2.8.1-7cf53193",vh=bh.split("-")[0],Bh="8.1.0",Eh=wc({commitment:nc(),radius:nc(),storageRadius:nc(),reserveCapacityDoubling:nc()}),xh=wc({block:nc(),chainTip:nc(),totalAmount:Va().transform((e=>Mu(e,{name:"totalAmount"}))),currentPrice:Va().transform(Number).transform((e=>{return t=e,Number.isInteger(t)?t<24e3?24e3:t:24e3;var t})),minimumValidityBlocks:nc().optional()}),Th=wc({bzzBalance:Va().transform((e=>su.fromPLUR(Mu(e,{name:"bzzBalance"})))),nativeTokenBalance:Va().transform((e=>au.fromWei(Mu(e,{name:"nativeTokenBalance"})))),chainID:nc(),chequebookContractAddress:Va(),walletAddress:Va()}),Rh=wc({transactionHash:Va().transform((e=>new an(e)))});class zh{constructor(e){this.context=e}async get(e){return async function(e){const t=await Jc(e,{method:"get",url:"status",responseType:"json"});return Ql.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getHealth(e){return async function(e){const t=await Jc(e,{method:"get",url:"health",responseType:"json"});return ef.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getReadiness(e){return async function(e){const t=await Jc(e,{method:"get",url:"readiness"});return rf.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getNodeInfo(e){return async function(e){const t=await Jc(e,{method:"get",url:"node",responseType:"json"});return of.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async isSupportedExactVersion(e){const{version:t}=await this.getHealth(e);return t===bh}async isSupportedApiVersion(e){const{apiVersion:t}=await this.getHealth(e);return wh()(t)===wh()(Bh)}async getVersions(e){const{version:t,apiVersion:n}=await this.getHealth(e);return{supportedBeeVersion:bh,supportedBeeApiVersion:Bh,beeVersion:t,beeApiVersion:n}}async getReserveState(e){return async function(e){const t=await Jc(e,{method:"get",url:"reservestate",responseType:"json"});return Eh.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getChainState(e){return async function(e){const t=await Jc(e,{method:"get",url:"chainstate",responseType:"json"});return xh.parse(t.data)}(this.context.getRequestOptionsForCall(e))}}class Ah{constructor(e){this.context=e}get blockTime(){return"gnosis"===this.context.network?5:15}async buy(e,t,n,r,o,i){const s=qu(t,(await this.context.bee.status.getChainState(r)).currentPrice,this.blockTime),a=Hu(e,o,i);return n&&(n=Pu.parse(n)),this.context.bee.stamp.create(s,a,n,r)}async getCost(e,t,n,r,o){const i=qu(t,(await this.context.bee.status.getChainState(n)).currentPrice,this.blockTime);return ju(Hu(e,r,o),i)}async extend(e,t,n,r,o,i){const s=await this.context.bee.stamp.get(e,r),a=Hu(t,o,i),c=await this.context.bee.status.getChainState(r),u=a-s.depth,l=u<=0?1n:2n**BigInt(u),f=qu(n,c.currentPrice,this.blockTime),h=qu(s.duration,c.currentPrice,this.blockTime),d=(n.isZero()?h*l:(h+f)*l)-h;let p;if(d>0n&&(p=await this.context.bee.stamp.topUp(s.batchID,d,r)),u>0)return this.context.bee.stamp.dilute(s.batchID,a,r);if(!p)throw new Error("Nothing to extend, both size and duration are already sufficient");return p}async extendSize(e,t,n,r,o){const i=await this.context.bee.status.getChainState(n),s=await this.context.bee.stamp.get(e,n),a=Hu(t,r,o),c=a-s.depth;if(c<=0)throw new nu("New depth has to be greater than the original depth",a);const u=qu(s.duration,i.currentPrice,this.blockTime);return await this.context.bee.stamp.topUp(s.batchID,u*(2n**BigInt(c)-1n)+1n,n),this.context.bee.stamp.dilute(s.batchID,a,n)}async extendDuration(e,t,n){const r=await this.context.bee.stamp.get(e,n),o=qu(t,(await this.context.bee.status.getChainState(n)).currentPrice,this.blockTime);return this.context.bee.stamp.topUp(r.batchID,o,n)}async getExtensionCost(e,t,n,r,o,i){const s=await this.context.bee.stamp.get(e,r),a=await this.context.bee.status.getChainState(r),c=n.isZero()?0n:qu(n,a.currentPrice,this.blockTime),u=Hu(t,o,i),l=qu(s.duration,a.currentPrice,this.blockTime),f=ju(s.depth,l);return ju(Math.max(s.depth,u),l+c).minus(f)}async getSizeExtensionCost(e,t,n,r,o){const i=await this.context.bee.stamp.get(e,n),s=await this.context.bee.status.getChainState(n),a=Hu(t,r,o);if(a-i.depth<=0)throw new nu("New depth has to be greater than the original depth",a);const c=qu(i.duration,s.currentPrice,this.blockTime),u=ju(i.depth,c);return ju(a,c).minus(u)}async getDurationExtensionCost(e,t,n){const r=await this.context.bee.stamp.get(e,n),o=qu(t,(await this.context.bee.status.getChainState(n)).currentPrice,this.blockTime);return ju(r.depth,o)}async rename(e,t,n){return this.context.bee.stamp.updateLabel(e,t,n)}}const kh=wc({address:Va().nullish().transform((e=>e??"")),seen:nc(),sent:nc(),split:nc(),startedAt:Va(),stored:nc(),synced:nc(),uid:nc()}),Sh=wc({tags:gc(kh)}),Oh="tags";class $h{constructor(e){this.context=e}async create(e){return async function(e){const t=await Jc(e,{method:"post",url:Oh,responseType:"json"});return kh.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async getAll(e,t){return e&&(e=Fu.parse(e)),async function(e,t){const n=await Jc(e,{url:Oh,params:{offset:t?.offset,limit:t?.limit},responseType:"json"});return Sh.parse(n.data).tags}(this.context.getRequestOptionsForCall(t),e)}async get(e,t){const n=Lu(e);return async function(e,t){const n=await Jc(e,{url:`${Oh}/${t}`,responseType:"json"});return kh.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async delete(e,t){const n=Lu(e);await async function(e,t){await Jc(e,{method:"delete",url:`${Oh}/${t}`})}(this.context.getRequestOptionsForCall(t),n)}async update(e,t,n){const r=new nn(t),o=Lu(e);await async function(e,t,n){await Jc(e,{method:"patch",url:`${Oh}/${t}`,data:{reference:n}})}(this.context.getRequestOptionsForCall(n),o,r)}}const Ih=wc({transactionHash:Va().transform((e=>new an(e))),to:Va(),nonce:nc(),gasPrice:Va().transform((e=>Mu(e,{name:"gasPrice"}))),gasLimit:nc(),data:Va(),created:Va(),description:Va(),value:Va().transform((e=>Mu(e,{name:"value"})))}),_h=wc({pendingTransactions:gc(Ih)}),Vh=Ih,Dh=wc({transactionHash:Va().transform((e=>new an(e)))}),Nh="transactions";class Ph{constructor(e){this.context=e}async getAll(e){return async function(e){const t=await Jc(e,{url:Nh,responseType:"json"});return _h.parse(t.data).pendingTransactions}(this.context.getRequestOptionsForCall(e))}async get(e,t){const n=new an(e);return async function(e,t){const n=await Jc(e,{url:`${Nh}/${t}`,responseType:"json"});return Vh.parse(n.data)}(this.context.getRequestOptionsForCall(t),n)}async rebroadcast(e,t){const n=new an(e);return async function(e,t){const n=await Jc(e,{method:"post",url:`${Nh}/${t}`,responseType:"json"});return Dh.parse(n.data).transactionHash}(this.context.getRequestOptionsForCall(t),n)}async cancel(e,t,n){const r=new an(e),o=t?Mu(t,{min:0n,name:"gasPrice"}):void 0;return async function(e,t,n){const r={};n&&(r["gas-price"]=n);const o=await Jc(e,{method:"delete",headers:r,url:`${Nh}/${t}`,responseType:"json"});return Dh.parse(o.data).transactionHash}(this.context.getRequestOptionsForCall(n),r,o)}}const Ch="wallet";class Fh{constructor(e){this.context=e}async getBalance(e){return async function(e){const t=await Jc(e,{method:"get",url:Ch,responseType:"json"});return Th.parse(t.data)}(this.context.getRequestOptionsForCall(e))}async withdrawBZZ(e,t,n){const r=e instanceof su?e:su.fromPLUR(e),o=new Mt(t);return async function(e,t,n){const r=await Jc(e,{method:"post",url:`${Ch}/withdraw/bzz`,responseType:"json",params:{amount:t.toPLURString(),address:n.toHex()}});return Rh.parse(r.data).transactionHash}(this.context.getRequestOptionsForCall(n),r,o)}async withdrawDAI(e,t,n){const r=e instanceof au?e:au.fromWei(e),o=new Mt(t);return async function(e,t,n){const r=await Jc(e,{method:"post",url:`${Ch}/withdraw/nativetoken`,responseType:"json",params:{amount:t.toWeiString(),address:n.toHex()}});return Rh.parse(r.data).transactionHash}(this.context.getRequestOptionsForCall(n),r,o)}}const Gh=["1","7","9","11","13","15","17","19","20","21","22","23","25","37","42","43","53","69","77","79","87","95","101","102","103","104","109","110","111","113","115","117","119","123","135","137","139","143","161","179","389","427","465","512","513","514","515","526","530","531","532","540","548","554","556","563","587","601","636","989","990","993","995","1719","1720","1723","2049","3659","4045","4190","5060","5061","6000","6566","6665","6666","6667","6668","6669","6679","6697","10080"];function Mh(e){if(!function(e){try{if("string"!=typeof e)return!1;const t=new URL(e);return"http:"===t.protocol||"https:"===t.protocol}catch(t){return!1}}(e))throw new nu("URL is not valid!",e);const t=new URL(e).port;if(t&&!function(e){if("string"!=typeof e)return!1;if(Gh.includes(e))return!1;const t=parseInt(e,10);return t>0&&t<65536&&!isNaN(t)}(t))throw new nu("Port in URL is considered bad port and cannot be used!",t)}class Uh{constructor(e,t){Mh(e),this.url=function(e){return e.endsWith("/")?e.slice(0,-1):e}(e),t?.signer&&(this.signer=new en(t.signer)),this.network=t?.network??"gnosis",this.requestOptions={baseURL:this.url,timeout:t?.timeout??0,headers:t?.headers,onRequest:t?.onRequest,httpAgent:t?.httpAgent,httpsAgent:t?.httpsAgent};const n={getRequestOptionsForCall:e=>this.getRequestOptionsForCall(e),url:this.url,signer:this.signer,network:this.network,bee:this};this.balance=new fl(n),this.settlement=new Qf(n),this.transaction=new Ph(n),this.stake=new sh(n),this.connectivity=new cf(n),this.status=new zh(n),this.wallet=new Fh(n),this.stamp=new gh(n),this.storage=new Ah(n),this.chequebook=new El(n),this.cheque=new Bl(n),this.tag=new $h(n),this.pin=new Mf(n),this.grantee=new Vf(n),this.messaging=new Cf(n),this.feed=new Sf(n),this.soc=new eh(n),this.data=new mf(n),this.chunk=new xl(n),this.file=new Of(n),this.collection=new Zl(n),this.rollingFeed=new qf(n)}makeContentAddressedChunk(e,t){return Tn(e,t)}unmarshalContentAddressedChunk(e){return Rn(e)}makeSingleOwnerChunk(e,t,n,r,o){return function(e,t,n,r,o){return r=new Zt(r),o=new en(o),En({data:Nt.concat(t.toUint8Array(),n.toUint8Array()),span:t,payload:n,address:e},r,o.toBigInt())}(e,t,n,r,o)}calculateSingleOwnerChunkAddress(e,t){return Bn(e,t)}unmarshalSingleOwnerChunk(e,t){return tl(e,t)}async createEnvelope(e,t,n){return e=new Pt(e),t=new nn(t),async function(e,t,n){const r=await Jc(e,{method:"post",responseType:"json",url:`envelope/${n}`,headers:{"swarm-postage-batch-id":t.toHex()}}),o=Zc.parse(r.data);return{issuer:new Mt(o.issuer),index:o.index,timestamp:o.timestamp,signature:new Qt(o.signature),batchId:t}}(this.getRequestOptionsForCall(n),e,t)}async rchash(e,t,n,r){return async function(e,t,n,r){const o=await Jc(e,{responseType:"json",url:`rchash/${t}/${n}/${r}`});return Qc.parse(o.data).durationSeconds}(this.getRequestOptionsForCall(r),e,t,n)}getRequestOptionsForCall(e){return e&&(e=Au.parse(e)),e?cr.Rb.deepMerge2(this.requestOptions,e):this.requestOptions}}const Lh="https://api.gateway.ethswarm.org",jh=new Pt("0000000000000000000000000000000000000000000000000000000000000000"),Zh=new sn("0000000000000000000000000000000000000000000000000000000000000000"),qh=new Uint8Array(32),Hh=new Uint8Array(32),Wh=new Uint8Array(20);function Jh(e){return(e=new qt(e)).toHex().slice(0,gu)}})(),r})()));
3
3
  //# sourceMappingURL=index.browser.min.js.map