@graffiti-garden/implementation-decentralized 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/1-services/3-storage-buckets.d.ts +5 -0
- package/dist/1-services/3-storage-buckets.d.ts.map +1 -1
- package/dist/browser/index.js +7 -7
- package/dist/browser/index.js.map +3 -3
- package/dist/cjs/1-services/3-storage-buckets-tests.js +179 -0
- package/dist/cjs/1-services/3-storage-buckets-tests.js.map +3 -3
- package/dist/cjs/1-services/3-storage-buckets.js +91 -0
- package/dist/cjs/1-services/3-storage-buckets.js.map +3 -3
- package/dist/cjs/1-services/4-inboxes-tests.js +20 -0
- package/dist/cjs/1-services/4-inboxes-tests.js.map +3 -3
- package/dist/esm/1-services/3-storage-buckets-tests.js +180 -1
- package/dist/esm/1-services/3-storage-buckets-tests.js.map +2 -2
- package/dist/esm/1-services/3-storage-buckets.js +92 -1
- package/dist/esm/1-services/3-storage-buckets.js.map +2 -2
- package/dist/esm/1-services/4-inboxes-tests.js +20 -0
- package/dist/esm/1-services/4-inboxes-tests.js.map +2 -2
- package/package.json +1 -1
- package/src/1-services/3-storage-buckets-tests.ts +199 -1
- package/src/1-services/3-storage-buckets.ts +129 -1
- package/src/1-services/4-inboxes-tests.ts +25 -0
package/dist/browser/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import{a as
|
|
2
|
-
`)===0?M.substr(1,M.length):M}).forEach(function(M){var L=M.split(":"),B=L.shift().trim();if(B){var je=L.join(":").trim();try{v.append(B,je)}catch(Rt){console.warn("Response "+Rt.message)}}}),v}_.call(A.prototype);function U(g,v){if(!(this instanceof U))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(v||(v={}),this.type="default",this.status=v.status===void 0?200:v.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=v.statusText===void 0?"":""+v.statusText,this.headers=new d(v.headers),this.url=v.url||"",this._initBody(g)}_.call(U.prototype),U.prototype.clone=function(){return new U(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new d(this.headers),url:this.url})},U.error=function(){var g=new U(null,{status:200,statusText:""});return g.ok=!1,g.status=0,g.type="error",g};var V=[301,302,303,307,308];U.redirect=function(g,v){if(V.indexOf(v)===-1)throw new RangeError("Invalid status code");return new U(null,{status:v,headers:{location:g}})},n.DOMException=r.DOMException;try{new n.DOMException}catch{n.DOMException=function(v,D){this.message=v,this.name=D;var M=Error(v);this.stack=M.stack},n.DOMException.prototype=Object.create(Error.prototype),n.DOMException.prototype.constructor=n.DOMException}function G(g,v){return new Promise(function(D,M){var L=new A(g,v);if(L.signal&&L.signal.aborted)return M(new n.DOMException("Aborted","AbortError"));var B=new XMLHttpRequest;function je(){B.abort()}B.onload=function(){var ee={statusText:B.statusText,headers:I(B.getAllResponseHeaders()||"")};L.url.indexOf("file://")===0&&(B.status<200||B.status>599)?ee.status=200:ee.status=B.status,ee.url="responseURL"in B?B.responseURL:ee.headers.get("X-Request-URL");var le="response"in B?B.response:B.responseText;setTimeout(function(){D(new U(le,ee))},0)},B.onerror=function(){setTimeout(function(){M(new TypeError("Network request failed"))},0)},B.ontimeout=function(){setTimeout(function(){M(new TypeError("Network request timed out"))},0)},B.onabort=function(){setTimeout(function(){M(new n.DOMException("Aborted","AbortError"))},0)};function Rt(ee){try{return ee===""&&r.location.href?r.location.href:ee}catch{return ee}}if(B.open(L.method,Rt(L.url),!0),L.credentials==="include"?B.withCredentials=!0:L.credentials==="omit"&&(B.withCredentials=!1),"responseType"in B&&(o.blob?B.responseType="blob":o.arrayBuffer&&(B.responseType="arraybuffer")),v&&typeof v.headers=="object"&&!(v.headers instanceof d||r.Headers&&v.headers instanceof r.Headers)){var qr=[];Object.getOwnPropertyNames(v.headers).forEach(function(ee){qr.push(c(ee)),B.setRequestHeader(ee,u(v.headers[ee]))}),L.headers.forEach(function(ee,le){qr.indexOf(le)===-1&&B.setRequestHeader(le,ee)})}else L.headers.forEach(function(ee,le){B.setRequestHeader(le,ee)});L.signal&&(L.signal.addEventListener("abort",je),B.onreadystatechange=function(){B.readyState===4&&L.signal.removeEventListener("abort",je)}),B.send(typeof L._bodyInit>"u"?null:L._bodyInit)})}return G.polyfill=!0,r.fetch||(r.fetch=G,r.Headers=d,r.Request=A,r.Response=U),n.Headers=d,n.Request=A,n.Response=U,n.fetch=G,n})({})})(jo);jo.fetch.ponyfill=!0;delete jo.fetch.polyfill;var On=Bo.fetch?Bo:jo;Et=On.fetch;Et.default=On.fetch;Et.fetch=On.fetch;Et.Headers=On.Headers;Et.Request=On.Request;Et.Response=On.Response;Gd.exports=Et});function oc(e){let t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function ic(e,t){return typeof t=="bigint"?t.toString():t}function sc(e){return{get value(){{let n=e();return Object.defineProperty(this,"value",{value:n}),n}throw new Error("cached value already set")}}}function Vr(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Ui(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function bp(...e){let t={};for(let n of e){let r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}var Mi="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Kr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Hn(e){if(Kr(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let n=t.prototype;return!(Kr(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}var ac=new Set(["string","number","symbol"]);function Li(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Gn(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function te(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function cc(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var uc={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 lc(e,t){if(!Hn(t))throw new Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let i=e._zod.def.shape;for(let s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(i,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let o=bp(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t};return Ui(this,"shape",i),i}});return Gn(e,o)}function kt(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function dc(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Ze(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function Fn(e){return typeof e=="string"?e:e?.message}function Ni(e,t,n){var r;for(let o=t;o<e.length;o++)(r=e[o]).schema??(r.schema=n)}function rt(e,t,n){var r;let o=e.inst?._zod?.traits;o?.has("$ZodType")&&(o.has("$ZodCheck")?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let i=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,s=e.message?e.message:Fn(e.inst?._zod.def?.error?.(e))??Fn(i?.(e))??Fn(t?.error?.(e))??Fn(n.customError?.(e))??Fn(n.localeError?.(e))??"Invalid input",{inst:a,schema:c,continue:u,input:l,...d}=e;return d.path??(d.path=[]),d.message=s,t?.reportInput&&(d.input=l),d}function Bi(...e){let[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}function fc(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):xp(e,n,r.value)}}function Ot(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function pc(e,t,n){return Ot(e,t,n,!1)}function xp(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Ot(this,t,n.bind(this))},set(r){Ot(this,t,r)}})}function Ep(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var Di,pt=!1,vp={configurable:!0,get(){pt=!0}};function _e(e,t,n){let r=Object.getPrototypeOf(e._zod);if(t in r&&Di!==e._zod){Di=void 0;return}Di=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,vp);let o=pt;pt=!1;try{let i=n(this);return pt?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i}),pt=pt||o,i}catch(i){throw delete this[t],pt=pt||o,i}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function hc(e,t,n,r){let o=Ep(e,t);o&&Object.defineProperty(o,t,{configurable:!0,get(){let i={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,i),i.value=n(this),Object.defineProperty(this,t,i),i.value},set(i){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:i})}})}var mc;var ji={value:void 0,enumerable:!1},gc="captureStackTrace"in Error?Error:null;function Sp(e){let t=gc;if(t){let n=t.stackTraceLimit;if(typeof n=="number"){try{t.stackTraceLimit=0}catch{return gc=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function $(e,t,n,r){let o={};function i(f){this.def=f,this.constr=d,this.traits=new Set}i.prototype=o;let s=n,a=s&&new WeakSet;function c(f,m){if(!f._zod){ji.value=new i(m);try{Object.defineProperty(f,"_zod",ji)}finally{ji.value=void 0}}if(f._zod.traits.has(e))return;if(f._zod.traits.add(e),t(f,m),a){let b=Object.getPrototypeOf(f),S=f._zod.constr.prototype,h=b;for(;h&&h!==S;)h=Object.getPrototypeOf(h);let _=h??b;a.has(_)||(a.add(_),fc(_,s))}let w=d.prototype;for(let b in w)Object.prototype.hasOwnProperty.call(w,b)&&(b in f||(f[b]=w[b].bind(f)))}let u=r?.Parent??Object;class l extends u{}Object.defineProperty(l,"name",{value:e});function d(f){let m=r?.Parent?Sp(l):this;c(m,f);let w=m._zod.deferred;if(w){for(let S of w)S();m._zod.deferred=void 0}let b=globalThis.__zod_globalConfig?.postProcessor;return b&&b(m),m}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:f=>r?.Parent&&f instanceof r.Parent?!0:f?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var ot=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};(mc=globalThis).__zod_globalConfig??(mc.__zod_globalConfig={});var zt=globalThis.__zod_globalConfig;function it(e){return e&&Object.assign(zt,e),zt}function Ap(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,ic,2)),e.message}function Rp(e){this._zod.message=e}var Pp={get:Ap,set:Rp,enumerable:!0,configurable:!0},Fi={value:void 0,enumerable:!1},Hi={value:void 0,enumerable:!1},yc=new WeakSet([Object.prototype,Error.prototype]),wc=(e,t)=>{e.name="$ZodError",Fi.value=e._zod,Object.defineProperty(e,"_zod",Fi),Hi.value=t,Object.defineProperty(e,"issues",Hi),Fi.value=void 0,Hi.value=void 0,Object.defineProperty(e,"message",Pp);let n=Object.getPrototypeOf(e);yc.has(n)||(yc.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let r=()=>this.message;return Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0})}}))},_c=$("$ZodError",wc),qn=$("$ZodError",wc,void 0,{Parent:Error});var Op=e=>{let t=(n,r,o,i)=>{let s=o?{...o,async:!1}:{async:!1},a=n._zod.run({value:r,issues:[]},s);if(a instanceof Promise)throw new ot;if(a.issues.length){let c=new(i?.Err??e)(a.issues.map(u=>rt(u,s,it())));throw Mi(c,i?.callee??t),c}return a.value};return t},Wr=Op(qn),kp=e=>{let t=async(n,r,o,i)=>{let s=o?{...o,async:!0}:{async:!0},a=n._zod.run({value:r,issues:[]},s);if(a instanceof Promise&&(a=await a),a.issues.length){let c=new(i?.Err??e)(a.issues.map(u=>rt(u,s,it())));throw Mi(c,i?.callee??t),c}return a.value};return t},Xr=kp(qn),Ip=e=>(t,n,r)=>{let o=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new ot;return i.issues.length?{success:!1,error:new(e??_c)(i.issues.map(s=>rt(s,o,it())))}:{success:!0,data:i.value}},Jn=Ip(qn),zp=e=>async(t,n,r)=>{let o=r?{...r,async:!0}:{async:!0},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(s=>rt(s,o,it())))}:{success:!0,data:i.value}},Kn=zp(qn);var bc=/^https?$/;var xc=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var Ec=/^-?\d+$/,Gi=/^-?\d+(?:\.\d+)?$/,vc=/^(?:true|false)$/i;var Sc=/^undefined$/i;var $t=$("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])});var Ac={number:"number",bigint:"bigint",object:"date"};var Rc=$("$ZodCheckGreaterThan",(e,t)=>{$t.init(e,t);let n=Ac[typeof t.value];e._zod.onattach.push(r=>{let o=r._zod.bag,i=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:Ac[typeof r.value]??n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}});var Pc=$("$ZodCheckNumberFormat",(e,t)=>{$t.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),r=n?"int":"number",[o,i]=uc[t.format];e._zod.onattach.push(s=>{let a=s._zod.bag;a.format=t.format,a.minimum=o,a.maximum=i,n&&(a.pattern=Ec)}),e._zod.check=s=>{let a=s.value;if(n){if(!Number.isInteger(a)){s.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){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});return}}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})}});var Tc=$("$ZodCheckStringFormat",(e,t)=>{var n,r;$t.init(e,t),e._zod.onattach.push(o=>{let i=o._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})});var kc={major:4,minor:5,patch:4};var oe=$("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=kc;let r=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...r??[]]:r?.length?[...r]:[];for(let i of o)for(let s of i._zod.onattach)s(e);if(o.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let i=(a,c,u)=>{if(a.memo)return a;let l=kt(a),d;for(let f of c){if(f._zod.def.when){if(dc(a)||!f._zod.def.when(a))continue}else if(l)continue;let m=a.issues.length,w=f._zod.check(a);if(w instanceof Promise&&u?.async===!1)throw new ot;if(d||w instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await w,a.issues.length!==m&&(Ni(a.issues,m,e),l||(l=kt(a,m)))});else{if(a.issues.length===m)continue;Ni(a.issues,m,e),l||(l=kt(a,m))}}return d?d.then(()=>a):a},s=(a,c,u)=>{if(kt(a))return a.aborted=!0,a;let l=i(c,o,u);if(l instanceof Promise){if(u.async===!1)throw new ot;return l.then(d=>e._zod.parse(d,u))}return e._zod.parse(l,u)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let l=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return l instanceof Promise?l.then(d=>s(d,a,c)):s(l,a,c)}let u=e._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new ot;return u.then(l=>i(l,o,c))}return i(u,o,c)}}},{get"~standard"(){return pc(this,"~standard",$p(this))},set"~standard"(e){Ot(this,"~standard",e)}}),Ic=e=>e.success?{value:e.data}:{issues:e.error?.issues};function $p(e){return{validate:t=>{try{return Ic(Jn(e,t))}catch{return Kn(e,t).then(Ic)}},vendor:"zod",version:1}}var Ki=$("$ZodString",(e,t)=>{oe.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??xc(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),Vi=$("$ZodStringFormat",(e,t)=>{Tc.init(e,t),Ki.init(e,t)});var jc=1,Zc=2;function Cp(e,t){if(!t.normalize&&t.protocol?.source===bc.source&&!/^https?:\/\//i.test(e))return jc;try{return new URL(e)}catch{return Zc}}var Dp=/[\t\n\r]/g;function Up(e){return e.replace(Dp,"")}function Mp(e,t){return t.lastIndex=0,t.test(e.hostname)}function Lp(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var Fc=$("$ZodURL",(e,t)=>{Vi.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),o=Cp(r,t);if(o===jc){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(o===Zc){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}t.hostname&&!Mp(o,t.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&&!Lp(o,t.protocol)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?o.href:Up(r);return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}});var Wi=$("$ZodNumber",(e,t)=>{oe.init(e,t),e._zod.pattern=e._zod.bag.pattern??Gi,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let o=n.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;let i=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:String(o):void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),n}}),Hc=$("$ZodNumberFormat",(e,t)=>{Pc.init(e,t),Wi.init(e,t)}),Gc=$("$ZodBoolean",(e,t)=>{oe.init(e,t),e._zod.pattern=vc,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let o=n.value;return typeof o=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}});var qc=$("$ZodUndefined",(e,t)=>{oe.init(e,t),e._zod.pattern=Sc,e._zod.values=new Set([void 0]),e._zod.parse=(n,r)=>{let o=n.value;return typeof o>"u"||n.issues.push({expected:"undefined",code:"invalid_type",input:o,inst:e}),n}});var Jc=$("$ZodUnknown",(e,t)=>{oe.init(e,t),e._zod.parse=n=>n}),Kc=$("$ZodNever",(e,t)=>{oe.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function zc(e,t,n){e.issues.length&&t.issues.push(...Ze(n,e.issues)),t.value[n]=e.value}var Vc=$("$ZodArray",(e,t)=>{oe.init(e,t);let n=zt.memoizer;n?.attach(e),e._zod.parse=(r,o)=>{let i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),r;r.value=n?n.alloc(e,r,Array(i.length),o):Array(i.length);let s=[];for(let a=0;a<i.length;a++){let c=i[a],u=t.element._zod.run({value:c,issues:[]},o);u instanceof Promise?s.push(u.then(l=>zc(l,r,a))):zc(u,r,a)}return s.length?Promise.all(s).then(()=>r):r}});function Yr(e,t,n,r,o,i){let s=n in r,a=i==="optional";if(!(!s&&a&&o==="optional")){if(e.issues.length){if(o!==void 0&&a&&!s)return;t.issues.push(...Ze(n,e.issues))}if(!s&&o===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?s&&(t.value[n]=void 0):t.value[n]=e.value}}var Np=[];function Bp(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:Np,o=r.length?[...t,...r]:t;for(let s of o)if(!e.shape?.[s]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(s)}": expected a Zod schema`);let i=cc(e.shape);return{...e,allKeys:o,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(i)}}function jp(e,t,n,r,o,i){let s=[],a=o.keySet,c=o.catchall._zod,u=c.def.type,l=c.optin,d=c.optout;for(let f in t){if(a.has(f))continue;if(f==="__proto__"){u==="never"&&s.push(f);continue}if(u==="never"){s.push(f);continue}let m=c.run({value:t[f],issues:[]},r);m instanceof Promise?e.push(m.then(w=>Yr(w,n,f,t,l,d))):Yr(m,n,f,t,l,d)}return s.length&&n.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i,continue:!0}),e.length?Promise.all(e).then(()=>n):n}var $c=new WeakMap,Wc=$("$ZodObject",(e,t)=>{if(oe.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let c=t.shape;$c.set(t,c),Object.defineProperty(t,"shape",{get:()=>{let u={...c};return Object.defineProperty(t,"shape",{value:u}),$c.set(t,u),u}})}let r=sc(()=>Bp(t));_e(e,"propValues",c=>{let u=c.def.shape,l={};for(let d in u){let f=u[d]._zod;if(f.values){Object.prototype.hasOwnProperty.call(l,d)||Ui(l,d,new Set);for(let m of f.values)l[d].add(m);f.optin!==void 0&&l[d].add(void 0)}}return l});let o=Kr,i=t.catchall,s,a=zt.memoizer;a?.attach(e),e._zod.parse=(c,u)=>{s??(s=r.value);let l=c.value;if(!o(l))return c.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),c;c.value=a?a.alloc(e,c,{},u):{};let d=[],f=s.shape;for(let m of s.allKeys){if(m==="__proto__")continue;let w=f[m],b=w._zod.optin,S=w._zod.optout,h=w._zod.run({value:l[m],issues:[]},u);h instanceof Promise?d.push(h.then(_=>Yr(_,c,m,l,b,S))):Yr(h,c,m,l,b,S)}return i?jp(d,l,c,u,r.value,e):d.length?Promise.all(d).then(()=>c):c}});function Cc(e,t,n,r){for(let i of e)if(i.issues.length===0)return t.value=i.value,t;let o=e.filter(i=>!kt(i));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(s=>rt(s,r,it())))}),t)}var Xc=$("$ZodUnion",(e,t)=>{oe.init(e,t),_e(e,"optin",r=>r.def.options.some(o=>o._zod.optin==="defaulted")?"defaulted":r.def.options.some(o=>o._zod.optin!==void 0)?"optional":void 0),_e(e,"optout",r=>r.def.options.some(o=>o._zod.optout==="optional")?"optional":void 0),_e(e,"values",r=>{if(r.def.options.every(o=>o._zod.values))return new Set(r.def.options.flatMap(o=>Array.from(o._zod.values)))}),_e(e,"pattern",r=>{if(r.def.options.every(o=>o._zod.pattern)){let o=r.def.options.map(i=>i._zod.pattern);return new RegExp(`^(${o.map(i=>Vr(i.source)).join("|")})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(n)return n(r,o);let i=!1,s=[];for(let a of t.options){let c=a._zod.run({value:r.value,issues:[]},o);if(c instanceof Promise)s.push(c),i=!0;else{if(c.issues.length===0)return c;s.push(c)}}return i?Promise.all(s).then(a=>Cc(a,r,e,o)):Cc(s,r,e,o)}});var Yc=$("$ZodIntersection",(e,t)=>{oe.init(e,t),e._zod.parse=(n,r)=>{let o=n.value,i=t.left._zod.run({value:o,issues:[]},r),s=t.right._zod.run({value:o,issues:[]},r);return i instanceof Promise||s instanceof Promise?Promise.all([i,s]).then(([c,u])=>Dc(n,c,u)):Dc(n,i,s)}});function Ji(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(Hn(e)&&Hn(t)){let n=Object.keys(t),r=Object.keys(e).filter(i=>n.indexOf(i)!==-1),o={...e,...t};Object.prototype.hasOwnProperty.call(o,"__proto__")&&delete o.__proto__;for(let i of r){if(i==="__proto__")continue;let s=Ji(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};o[i]=s.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let o=e[r],i=t[r],s=Ji(o,i);if(!s.valid)return{valid:!1,mergeErrorPath:[r,...s.mergeErrorPath]};n.push(s.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Dc(e,t,n){let r=new Map,o,i=new Map,s=(u,l)=>{let d;if(u.code==="unrecognized_keys"&&!u.path?.length)o??(o=u),d=u.keys;else if(u.code==="invalid_key"&&u.origin==="record"&&u.path?.length===1){let f=String(u.path[0]);i.has(f)||i.set(f,u),d=[f]}else return!1;for(let f of d)r.has(f)||r.set(f,{}),r.get(f)[l]=!0;return!0};for(let u of t.issues)s(u,"l")||e.issues.push(u);for(let u of n.issues)s(u,"r")||e.issues.push(u);let a=[...r].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(a.length){let u=o?a.filter(l=>o.keys.includes(l)):[];u.length&&e.issues.push({...o,keys:u});for(let l of a)!u.includes(l)&&i.has(l)&&e.issues.push(i.get(l))}let c=Ji(t.value,n.value);if(!c.valid){if(kt(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Qc=$("$ZodTuple",(e,t)=>{oe.init(e,t);let n=t.items,r=zt.memoizer;r?.attach(e),e._zod.parse=(o,i)=>{let s=o.value;if(!Array.isArray(s))return o.issues.push({input:s,inst:e,expected:"tuple",code:"invalid_type"}),o;o.value=r?r.alloc(e,o,[],i):[];let a=[],c=Uc(n,"optin"),u=Uc(n,"optout");if(!t.rest){if(s.length<c)return o.issues.push({code:"too_small",minimum:c,inclusive:!0,input:s,inst:e,origin:"array"}),o;s.length>n.length&&o.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:s,inst:e,origin:"array"})}let l=new Array(n.length);for(let d=0;d<n.length;d++){let f=n[d]._zod.run({value:s[d],issues:[]},i);f instanceof Promise?a.push(f.then(m=>{l[d]=m})):l[d]=f}if(t.rest){let d=n.length-1,f=s.slice(n.length);for(let m of f){d++;let w=t.rest._zod.run({value:m,issues:[]},i);w instanceof Promise?a.push(w.then(b=>Mc(b,o,d))):Mc(w,o,d)}}return a.length?Promise.all(a).then(()=>Lc(l,o,n,s,u)):Lc(l,o,n,s,u)}});function Uc(e,t){for(let n=e.length-1;n>=0;n--)if(!(t==="optin"?e[n]._zod.optin!==void 0:e[n]._zod.optout==="optional"))return n+1;return 0}function Mc(e,t,n){e.issues.length&&t.issues.push(...Ze(n,e.issues)),t.value[n]=e.value}function Lc(e,t,n,r,o){for(let i=0;i<n.length;i++){let s=e[i],a=i<r.length;if(!a&&i>=o&&n[i]._zod.optin==="optional"){t.value.length=i;break}if(s.issues.length){if(!a&&i>=o){t.value.length=i;break}t.issues.push(...Ze(i,s.issues))}t.value[i]=s.value}for(let i=t.value.length-1;i>=r.length&&(n[i]._zod.optout==="optional"&&t.value[i]===void 0);i--)t.value.length=i;return t}var eu=$("$ZodRecord",(e,t)=>{oe.init(e,t);let n=zt.memoizer;n?.attach(e),e._zod.parse=(r,o)=>{let i=r.value;if(!Hn(i))return r.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),r;let s=[],a=t.keyType._zod.values;if(a&&!t.partial){r.value=n?n.alloc(e,r,{},o):{};let c=new Set;for(let l of a)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){if(c.add(typeof l=="number"?l.toString():l),l==="__proto__")continue;let d=t.keyType._zod.run({value:l,issues:[]},o);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(d.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(w=>rt(w,o,it())),input:l,path:[l],inst:e});continue}let f=d.value;if(f==="__proto__")continue;let m=t.valueType._zod.run({value:i[l],issues:[]},o);m instanceof Promise?s.push(m.then(w=>{w.issues.length&&r.issues.push(...Ze(l,w.issues)),r.value[f]=w.value})):(m.issues.length&&r.issues.push(...Ze(l,m.issues)),r.value[f]=m.value)}let u;for(let l in i)if(!c.has(l))if(t.mode==="loose"){if(l==="__proto__")continue;r.value[l]=i[l]}else u=u??[],u.push(l);u&&u.length>0&&r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:u,continue:!0})}else{r.value=n?n.alloc(e,r,{},o):{};let c;for(let u of Reflect.ownKeys(i)){if(u==="__proto__"||!Object.prototype.propertyIsEnumerable.call(i,u))continue;let l=t.keyType._zod.run({value:u,issues:[]},o);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof u=="string"&&Gi.test(u)&&l.issues.length){let w=t.keyType._zod.run({value:Number(u),issues:[]},o);if(w instanceof Promise)throw new Error("Async schemas not supported in object keys currently");w.issues.length===0&&(l=w)}if(l.issues.length){t.mode==="loose"?r.value[u]=i[u]:a?(c=c??[],c.push(u)):r.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(w=>rt(w,o,it())),input:u,path:[u],inst:e});continue}let f=l.value;if(f==="__proto__")continue;let m=t.valueType._zod.run({value:i[u],issues:[]},o);m instanceof Promise?s.push(m.then(w=>{w.issues.length&&r.issues.push(...Ze(u,w.issues)),r.value[f]=w.value})):(m.issues.length&&r.issues.push(...Ze(u,m.issues)),r.value[f]=m.value)}c&&c.length>0&&r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:c,continue:!0})}return s.length?Promise.all(s).then(()=>r):r}});var tu=$("$ZodEnum",(e,t)=>{oe.init(e,t);let n=oc(t.entries),r=new Set(n);e._zod.values=r;let o=n.filter(i=>ac.has(typeof i));e._zod.pattern=new RegExp(o.length?`^(${o.map(i=>Li(i.toString())).join("|")})$`:"^[^\\s\\S]$"),e._zod.parse=(i,s)=>{let a=i.value;return r.has(a)||i.issues.push({code:"invalid_value",values:n,input:a,inst:e}),i}});function Nc(e,t){return e.value=t.issues.length?void 0:t.value,e}var nu=$("$ZodOptional",(e,t)=>{oe.init(e,t),_e(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",_e(e,"values",n=>{let r=n.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),_e(e,"pattern",n=>{let r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${Vr(r.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;let o=t.innerType._zod.run({value:n.value,issues:[]},r);return o instanceof Promise?o.then(i=>Nc(n,i)):Nc(n,o)}return t.innerType._zod.run(n,r)}});var ru=$("$ZodNullable",(e,t)=>{oe.init(e,t),_e(e,"optin",n=>n.def.innerType._zod.optin),_e(e,"optout",n=>n.def.innerType._zod.optout),_e(e,"pattern",n=>{let r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${Vr(r.source)}|null)$`):void 0}),_e(e,"values",n=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)});var ou=$("$ZodCustom",(e,t)=>{$t.init(e,t),oe.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{let r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(i=>Bc(i,n,r,e));Bc(o,n,r,e)}});function Bc(e,t,n,r){if(!e){let o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(Bi(o))}}function iu(e,t){return new e({type:"string",...te(t)})}function su(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...te(t)})}function au(e,t){return new e({type:"number",checks:[],...te(t)})}function cu(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...te(t)})}function uu(e,t){return new e({type:"boolean",...te(t)})}function lu(e,t){return new e({type:"undefined",...te(t)})}function du(e){return new e({type:"unknown"})}function fu(e,t){return new e({type:"never",...te(t)})}function Xi(e,t){return new Rc({check:"greater_than",...te(t),value:e,inclusive:!0})}function Ct(e){return Xi(0,e)}function pu(e,t,n){let r=te(n);return r.abort??(r.abort=!0),new e({type:"custom",check:"custom",fn:t,...r})}var fe=$("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");oe.init(e,t),e.def=t,e.type=t.type},{get with(){return this.check},set with(e){Ot(this,"with",e)},parse(e,t){return Wr(this,e,t,{callee:this.parse})},parseAsync(e,t){return Xr(this,e,t,{callee:this.parseAsync})},safeParse(e,t){return Jn(this,e,t)},safeParseAsync(e,t){return Kn(this,e,t)},check(...e){let t=this.def;return this.clone({...t,checks:[...t.checks??[],...e.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]},{parent:!0})},clone(e,t){return Gn(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},apply(e,...t){return t.length===0?e(this):e(this,...t)}}),mu=$("ZodMiniString",(e,t)=>{Ki.init(e,t),fe.init(e,t)});function j(e){return iu(mu,e)}var Hp=$("ZodMiniStringFormat",(e,t)=>{Vi.init(e,t),mu.init(e,t)});var Gp=$("ZodMiniURL",(e,t)=>{Fc.init(e,t),Hp.init(e,t)});function F(e){return su(Gp,e)}var gu=$("ZodMiniNumber",(e,t)=>{Wi.init(e,t),fe.init(e,t)});function yu(e){return au(gu,e)}var qp=$("ZodMiniNumberFormat",(e,t)=>{Hc.init(e,t),gu.init(e,t)});function tn(e){return cu(qp,e)}var Jp=$("ZodMiniBoolean",(e,t)=>{Gc.init(e,t),fe.init(e,t)});function Vn(e){return uu(Jp,e)}var Kp=$("ZodMiniUndefined",(e,t)=>{qc.init(e,t),fe.init(e,t)});function wu(e){return lu(Kp,e)}var Vp=$("ZodMiniUnknown",(e,t)=>{Jc.init(e,t),fe.init(e,t)});function Wp(){return du(Vp)}var Xp=$("ZodMiniNever",(e,t)=>{Kc.init(e,t),fe.init(e,t)});function Yp(e){return fu(Xp,e)}var Qp=$("ZodMiniArray",(e,t)=>{Vc.init(e,t),fe.init(e,t)});function J(e,t){return new Qp({type:"array",element:e,...te(t)})}var Yi=$("ZodMiniObject",(e,t)=>{Wc.init(e,t),fe.init(e,t),hc(e,"shape",n=>n._zod.def.shape,!1)});function be(e,t){let n={type:"object",shape:e??{},...te(t)};return new Yi(n)}function xe(e,t){return new Yi({type:"object",shape:e,catchall:Yp(),...te(t)})}function Ee(e,t){return new Yi({type:"object",shape:e,catchall:Wp(),...te(t)})}function st(e,t){return lc(e,t)}var eh=$("ZodMiniUnion",(e,t)=>{Xc.init(e,t),fe.init(e,t)});function at(e,t){return new eh({type:"union",options:e,...te(t)})}var th=$("ZodMiniIntersection",(e,t)=>{Yc.init(e,t),fe.init(e,t)});function _u(e,t){return new th({type:"intersection",left:e,right:t})}var nh=$("ZodMiniTuple",(e,t)=>{Qc.init(e,t),fe.init(e,t)});function he(e,t,n){let r=t instanceof oe,o=r?n:t,i=r?t:null;return new nh({type:"tuple",items:e,rest:i,...te(o)})}var hu=$("ZodMiniRecord",(e,t)=>{eu.init(e,t),fe.init(e,t)});function bu(e,t,n){return!t||!t._zod?new hu({type:"record",keyType:j(),valueType:e,...te(t)}):new hu({type:"record",keyType:e,valueType:t,...te(n)})}var rh=$("ZodMiniEnum",(e,t)=>{tu.init(e,t),fe.init(e,t),e.options=Object.values(t.entries)});function xu(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new rh({type:"enum",entries:n,...te(t)})}var oh=$("ZodMiniOptional",(e,t)=>{nu.init(e,t),fe.init(e,t)});function Y(e){return new oh({type:"optional",innerType:e})}var ih=$("ZodMiniNullable",(e,t)=>{ru.init(e,t),fe.init(e,t)});function Ue(e){return new ih({type:"nullable",innerType:e})}var sh=$("ZodMiniCustom",(e,t)=>{ou.init(e,t),fe.init(e,t)});function Dt(e,t){return pu(sh,e??(()=>!0),t)}function nn(e,t={}){let n=Dt(r=>r instanceof e,t);return n._zod.bag.Class=e,n._zod.check=r=>{r.value instanceof e||r.issues.push({code:"invalid_type",expected:e.name,input:r.value,inst:n,path:[...n._zod.def.path??[]]})},n}var Su=Ee({value:Ee({}),channels:J(j()),allowed:Y(Ue(J(F())))}),bv=st(Su,{url:F(),actor:F()}),Eu=at([Ee({url:F()}),F()]),rn=Ee({actor:F()}),Qr=Y(Ue(rn)),vu=at([Vn(),Ee({})]),Au=Ee({data:nn(Blob),allowed:Y(Ue(J(F())))}),xv=st(Au,{actor:F()}),ch=Ee({types:Y(J(j())),maxBytes:Y(tn().check(Ct()))}),eo=class{constructor(t){this.graffiti=t,this.sessionEvents=this.graffiti.sessionEvents}graffiti;sessionEvents;login=(...t)=>{let n=he([Y(Ue(F()))]).parse(t);return this.graffiti.login(...n)};logout=(...t)=>{let n=he([rn]).parse(t);return this.graffiti.logout(...n)};handleToActor=(...t)=>{let n=he([j()]).parse(t);return this.graffiti.handleToActor(...n)};actorToHandle=(...t)=>{let n=he([F()]).parse(t);return this.graffiti.actorToHandle(...n)};post=(...t)=>{let n=he([Su,rn]).parse(t);return this.graffiti.post(...n)};get=(...t)=>{let n=he([Eu,vu,Qr]).parse(t);return this.graffiti.get(n[0],n[1],n[2])};delete=(...t)=>{let n=he([Eu,rn]).parse(t);return this.graffiti.delete(...n)};postMedia=(...t)=>{let n=he([Au,rn]).parse(t);return this.graffiti.postMedia(...n)};getMedia=(...t)=>{let n=he([F(),ch,Qr]).parse(t);return this.graffiti.getMedia(...n)};deleteMedia=(...t)=>{let n=he([F(),rn]).parse(t);return this.graffiti.deleteMedia(...n)};discover=(...t)=>{let n=he([J(j()),vu,Qr]).parse(t);return this.graffiti.discover(n[0],n[1],n[2])};continueDiscover=(...t)=>{let n=he([j(),Qr]).parse(t);return this.graffiti.continueDiscover(...n)}};var uh={type:"object",properties:{value:{type:"object"},channels:{type:"array",items:{type:"string"}},allowed:{type:"array",items:{type:"string"},nullable:!0},url:{type:"string"},actor:{type:"string"}},additionalProperties:!1,required:["value","channels","actor","url"]},Sv={...uh,required:["value","channels"]};var ht=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorForbidden",Object.setPrototypeOf(this,e.prototype)}},ne=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorNotFound",Object.setPrototypeOf(this,e.prototype)}},on=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorInvalidSchema",Object.setPrototypeOf(this,e.prototype)}},to=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorSchemaMismatch",Object.setPrototypeOf(this,e.prototype)}},sn=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorTooLarge",Object.setPrototypeOf(this,e.prototype)}},no=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorNotAcceptable",Object.setPrototypeOf(this,e.prototype)}},Me=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorCursorExpired",Object.setPrototypeOf(this,e.prototype)}};function es(e){return typeof e=="string"?e:e.url}function ts(e,t,n){if(n===e.actor)return e;let r=e.allowed&&n?[n]:void 0,o=e.channels.filter(i=>t.includes(i));return{...e,...r?{allowed:r}:{},channels:o}}function Ru(e,t){let[n,r]=e.toLowerCase().split(";")[0].split("/");return!n||!r?!1:t.some(o=>{let[i,s]=o.toLowerCase().split(";")[0].split("/");return!i||!s?!1:(i===n||i==="*")&&(s===r||s==="*")})}var Qi;async function ro(e){if(!Qi){let{default:t}=await import("./ajv-X6C4R6QN.js");Qi=new t({strict:!1})}try{return Qi.compile(e)}catch(t){throw new on(t instanceof Error?t.message:String(t))}}function Pu(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}var ns=e=>e?`"${e}" `:"";function Wn(e,t=""){if(typeof e!="number")throw new TypeError(ns(t)+"expected number, got "+typeof e);if(!Number.isSafeInteger(e)||e<0)throw new RangeError(ns(t)+"expected integer >= 0, got "+e);return e}function Xn(e,t,n=""){if(Pu(e)&&(t===void 0||e.length===t))return e;t!==void 0&&Wn(t,"length");let r=Pu(e),o=t!==void 0?` of length ${t}`:"",i=r?`length=${e.length}`:`type=${typeof e}`,s=ns(n)+"expected Uint8Array"+o+", got "+i;throw r?new RangeError(s):new TypeError(s)}function Tu(e){return Uint8Array.from(Xn(e))}function Ou(e){if(typeof e!="function"||typeof e.create!="function")throw new TypeError("expected hash wrapped by utils.createHasher");if(Wn(e.outputLen),Wn(e.blockLen),e.outputLen<1||e.blockLen<1)throw new Error("hash blockLen / outputLen must be >= 1")}function ku(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Ut(e=32){Wn(e,"bytesLength");let t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(e>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}var lh=["Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array","Tagged"];function rs(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(t==="string"||t==="number"||t==="bigint"||t==="symbol")return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(e instanceof Uint8Array)return"Uint8Array";if(e.constructor===Object)return"Object";let n=dh(e);return n||"Object"}function dh(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(lh.includes(t))return t}var y=class{constructor(t,n,r){this.major=t,this.majorEncoded=t<<5,this.name=n,this.terminal=r}toString(){return`Type[${this.major}].${this.name}`}compare(t){return this.major<t.major?-1:this.major>t.major?1:0}static equals(t,n){return t===n||t.major===n.major&&t.name===n.name}};y.uint=new y(0,"uint",!0);y.negint=new y(1,"negint",!0);y.bytes=new y(2,"bytes",!0);y.string=new y(3,"string",!0);y.array=new y(4,"array",!1);y.map=new y(5,"map",!1);y.tag=new y(6,"tag",!1);y.float=new y(7,"float",!0);y.false=new y(7,"false",!0);y.true=new y(7,"true",!0);y.null=new y(7,"null",!0);y.undefined=new y(7,"undefined",!0);y.break=new y(7,"break",!0);var T=class{constructor(t,n,r){this.type=t,this.value=n,this.encodedLength=r,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var Yn=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",fh=new TextEncoder;function oo(e){return Yn&&globalThis.Buffer.isBuffer(e)}function Qn(e){return e instanceof Uint8Array?oo(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var ph=24,hh=200,io=Yn?e=>e.length>=ph?globalThis.Buffer.from(e):Iu(e):e=>e.length>=hh?fh.encode(e):Iu(e),Fe=e=>Uint8Array.from(e),zu=Yn?(e,t,n)=>oo(e)?new Uint8Array(e.subarray(t,n)):e.slice(t,n):(e,t,n)=>e.slice(t,n),$u=Yn?(e,t)=>(e=e.map(n=>n instanceof Uint8Array?n:globalThis.Buffer.from(n)),Qn(globalThis.Buffer.concat(e,t))):(e,t)=>{let n=new Uint8Array(t),r=0;for(let o of e)r+o.length>n.length&&(o=o.subarray(0,n.length-r)),n.set(o,r),r+=o.length;return n},os=Yn?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function an(e,t){if(oo(e)&&oo(t))return e.compare(t);for(let n=0;n<e.length;n++)if(e[n]!==t[n])return e[n]<t[n]?-1:1;return 0}function Iu(e){let t=[],n=0;for(let r=0;r<e.length;r++){let o=e.charCodeAt(r);o<128?t[n++]=o:o<2048?(t[n++]=o>>6|192,t[n++]=o&63|128):(o&64512)===55296&&r+1<e.length&&(e.charCodeAt(r+1)&64512)===56320?(o=65536+((o&1023)<<10)+(e.charCodeAt(++r)&1023),t[n++]=o>>18|240,t[n++]=o>>12&63|128,t[n++]=o>>6&63|128,t[n++]=o&63|128):(o>=55296&&o<=57343&&(o=65533),t[n++]=o>>12|224,t[n++]=o>>6&63|128,t[n++]=o&63|128)}return t}var mh=256,er=class{constructor(t=mh){this.chunkSize=t,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}pushByte(t){let n=this.chunks[this.chunks.length-1];this.cursor>this.maxCursor&&(n=os(this.chunkSize),this.chunks.push(n),this.maxCursor+=n.length,this._initReuseChunk===null&&(this._initReuseChunk=n));let r=n.length-(this.maxCursor-this.cursor)-1;n[r]=t,this.cursor++}push(t){let n=this.chunks[this.chunks.length-1];if(this.cursor+t.length<=this.maxCursor+1){let o=n.length-(this.maxCursor-this.cursor)-1;n.set(t,o)}else{if(n){let o=n.length-(this.maxCursor-this.cursor)-1;o<n.length&&(this.chunks[this.chunks.length-1]=n.subarray(0,o),this.maxCursor=this.cursor-1)}t.length<64&&t.length<this.chunkSize?(n=os(this.chunkSize),this.chunks.push(n),this.maxCursor+=n.length,this._initReuseChunk===null&&(this._initReuseChunk=n),n.set(t,0)):(this.chunks.push(t),this.maxCursor+=t.length)}this.cursor+=t.length}toBytes(t=!1){let n;if(this.chunks.length===1){let r=this.chunks[0];t&&this.cursor>r.length/2?(n=this.cursor===r.length?r:r.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):n=zu(r,0,this.cursor)}else n=$u(this.chunks,this.cursor);return t&&this.reset(),n}},so=class{constructor(t){this.dest=t,this.cursor=0,this.chunks=[t]}reset(){this.cursor=0}pushByte(t){if(this.cursor>=this.dest.length)throw new Error("write out of bounds, destination buffer is too small");this.dest[this.cursor++]=t}push(t){if(this.cursor+t.length>this.dest.length)throw new Error("write out of bounds, destination buffer is too small");this.dest.set(t,this.cursor),this.cursor+=t.length}toBytes(t=!1){let n=this.dest.subarray(0,this.cursor);return t&&this.reset(),n}};var z="CBOR decode error:",ao="CBOR encode error:",tr=[];tr[23]=1;tr[24]=2;tr[25]=3;tr[26]=5;tr[27]=9;function ct(e,t,n){if(e.length-t<n)throw new Error(`${z} not enough data for type`)}var ae=[24,256,65536,4294967296,BigInt("18446744073709551616")];function ve(e,t,n){ct(e,t,1);let r=e[t];if(n.strict===!0&&r<ae[0])throw new Error(`${z} integer encoded in more bytes than necessary (strict decode)`);return r}function Se(e,t,n){ct(e,t,2);let r=e[t]<<8|e[t+1];if(n.strict===!0&&r<ae[1])throw new Error(`${z} integer encoded in more bytes than necessary (strict decode)`);return r}function Ae(e,t,n){ct(e,t,4);let r=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(n.strict===!0&&r<ae[2])throw new Error(`${z} integer encoded in more bytes than necessary (strict decode)`);return r}function Re(e,t,n){ct(e,t,8);let r=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],o=e[t+4]*16777216+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],i=(BigInt(r)<<BigInt(32))+BigInt(o);if(n.strict===!0&&i<ae[3])throw new Error(`${z} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(n.allowBigInt===!0)return i;throw new Error(`${z} integers outside of the safe integer range are not supported`)}function Cu(e,t,n,r){return new T(y.uint,ve(e,t+1,r),2)}function Du(e,t,n,r){return new T(y.uint,Se(e,t+1,r),3)}function Uu(e,t,n,r){return new T(y.uint,Ae(e,t+1,r),5)}function Mu(e,t,n,r){return new T(y.uint,Re(e,t+1,r),9)}function He(e,t){return ie(e,0,t.value)}function ie(e,t,n){if(n<ae[0]){let r=Number(n);e.pushByte(t|r)}else if(n<ae[1]){let r=Number(n);e.push([t|24,r])}else if(n<ae[2]){let r=Number(n);e.push([t|25,r>>>8,r&255])}else if(n<ae[3]){let r=Number(n);e.push([t|26,r>>>24&255,r>>>16&255,r>>>8&255,r&255])}else{let r=BigInt(n);if(r<ae[4]){let o=[t|27,0,0,0,0,0,0,0],i=Number(r&BigInt(4294967295)),s=Number(r>>BigInt(32)&BigInt(4294967295));o[8]=i&255,i=i>>8,o[7]=i&255,i=i>>8,o[6]=i&255,i=i>>8,o[5]=i&255,o[4]=s&255,s=s>>8,o[3]=s&255,s=s>>8,o[2]=s&255,s=s>>8,o[1]=s&255,e.push(o)}else throw new Error(`${z} encountered BigInt larger than allowable range`)}}He.encodedSize=function(t){return ie.encodedSize(t.value)};ie.encodedSize=function(t){return t<ae[0]?1:t<ae[1]?2:t<ae[2]?3:t<ae[3]?5:9};He.compareTokens=function(t,n){return t.value<n.value?-1:t.value>n.value?1:0};function Lu(e,t,n,r){return new T(y.negint,-1-ve(e,t+1,r),2)}function Nu(e,t,n,r){return new T(y.negint,-1-Se(e,t+1,r),3)}function Bu(e,t,n,r){return new T(y.negint,-1-Ae(e,t+1,r),5)}var is=BigInt(-1),ju=BigInt(1);function Zu(e,t,n,r){let o=Re(e,t+1,r);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new T(y.negint,i,9)}if(r.allowBigInt!==!0)throw new Error(`${z} integers outside of the safe integer range are not supported`);return new T(y.negint,is-BigInt(o),9)}function co(e,t){let n=t.value,r=typeof n=="bigint"?n*is-ju:n*-1-1;ie(e,t.type.majorEncoded,r)}co.encodedSize=function(t){let n=t.value,r=typeof n=="bigint"?n*is-ju:n*-1-1;return r<ae[0]?1:r<ae[1]?2:r<ae[2]?3:r<ae[3]?5:9};co.compareTokens=function(t,n){return t.value<n.value?1:t.value>n.value?-1:0};function nr(e,t,n,r){ct(e,t,n+r);let o=e.slice(t+n,t+n+r);return new T(y.bytes,o,n+r)}function Fu(e,t,n,r){return nr(e,t,1,n)}function Hu(e,t,n,r){return nr(e,t,2,ve(e,t+1,r))}function Gu(e,t,n,r){return nr(e,t,3,Se(e,t+1,r))}function qu(e,t,n,r){return nr(e,t,5,Ae(e,t+1,r))}function Ju(e,t,n,r){let o=Re(e,t+1,r);if(typeof o=="bigint")throw new Error(`${z} 64-bit integer bytes lengths not supported`);return nr(e,t,9,o)}function uo(e){return e.encodedBytes===void 0&&(e.encodedBytes=y.equals(e.type,y.string)?io(e.value):e.value),e.encodedBytes}function cn(e,t){let n=uo(t);ie(e,t.type.majorEncoded,n.length),e.push(n)}cn.encodedSize=function(t){let n=uo(t);return ie.encodedSize(n.length)+n.length};cn.compareTokens=function(t,n){return yh(uo(t),uo(n))};function yh(e,t){return e.length<t.length?-1:e.length>t.length?1:an(e,t)}var Ku=new TextDecoder,_h=32;function bh(e,t,n){if(n-t<_h){let o="";for(let i=t;i<n;i++){let s=e[i];if(s&128)return Ku.decode(e.subarray(t,n));o+=String.fromCharCode(s)}return o}return Ku.decode(e.subarray(t,n))}function rr(e,t,n,r,o){let i=n+r;ct(e,t,i);let s=new T(y.string,bh(e,t+n,t+i),i);return o.retainStringBytes===!0&&(s.byteValue=e.slice(t+n,t+i)),s}function Vu(e,t,n,r){return rr(e,t,1,n,r)}function Wu(e,t,n,r){return rr(e,t,2,ve(e,t+1,r),r)}function Xu(e,t,n,r){return rr(e,t,3,Se(e,t+1,r),r)}function Yu(e,t,n,r){return rr(e,t,5,Ae(e,t+1,r),r)}function Qu(e,t,n,r){let o=Re(e,t+1,r);if(typeof o=="bigint")throw new Error(`${z} 64-bit integer string lengths not supported`);return rr(e,t,9,o,r)}var el=cn;function un(e,t,n,r){return new T(y.array,r,n)}function tl(e,t,n,r){return un(e,t,1,n)}function nl(e,t,n,r){return un(e,t,2,ve(e,t+1,r))}function rl(e,t,n,r){return un(e,t,3,Se(e,t+1,r))}function ol(e,t,n,r){return un(e,t,5,Ae(e,t+1,r))}function il(e,t,n,r){let o=Re(e,t+1,r);if(typeof o=="bigint")throw new Error(`${z} 64-bit integer array lengths not supported`);return un(e,t,9,o)}function sl(e,t,n,r){if(r.allowIndefinite===!1)throw new Error(`${z} indefinite length items not allowed`);return un(e,t,1,1/0)}function lo(e,t){ie(e,y.array.majorEncoded,t.value)}lo.compareTokens=He.compareTokens;lo.encodedSize=function(t){return ie.encodedSize(t.value)};function ln(e,t,n,r){return new T(y.map,r,n)}function al(e,t,n,r){return ln(e,t,1,n)}function cl(e,t,n,r){return ln(e,t,2,ve(e,t+1,r))}function ul(e,t,n,r){return ln(e,t,3,Se(e,t+1,r))}function ll(e,t,n,r){return ln(e,t,5,Ae(e,t+1,r))}function dl(e,t,n,r){let o=Re(e,t+1,r);if(typeof o=="bigint")throw new Error(`${z} 64-bit integer map lengths not supported`);return ln(e,t,9,o)}function fl(e,t,n,r){if(r.allowIndefinite===!1)throw new Error(`${z} indefinite length items not allowed`);return ln(e,t,1,1/0)}function fo(e,t){ie(e,y.map.majorEncoded,t.value)}fo.compareTokens=He.compareTokens;fo.encodedSize=function(t){return ie.encodedSize(t.value)};function pl(e,t,n,r){return new T(y.tag,n,1)}function hl(e,t,n,r){return new T(y.tag,ve(e,t+1,r),2)}function ml(e,t,n,r){return new T(y.tag,Se(e,t+1,r),3)}function gl(e,t,n,r){return new T(y.tag,Ae(e,t+1,r),5)}function yl(e,t,n,r){return new T(y.tag,Re(e,t+1,r),9)}function po(e,t){ie(e,y.tag.majorEncoded,t.value)}po.compareTokens=He.compareTokens;po.encodedSize=function(t){return ie.encodedSize(t.value)};var ho=20,mo=21,go=22,yo=23;function _l(e,t,n,r){if(r.allowUndefined===!1)throw new Error(`${z} undefined values are not supported`);return r.coerceUndefinedToNull===!0?new T(y.null,null,1):new T(y.undefined,void 0,1)}function bl(e,t,n,r){if(r.allowIndefinite===!1)throw new Error(`${z} indefinite length items not allowed`);return new T(y.break,void 0,1)}function ss(e,t,n){if(n){if(n.allowNaN===!1&&Number.isNaN(e))throw new Error(`${z} NaN values are not supported`);if(n.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${z} Infinity values are not supported`)}return new T(y.float,e,t)}function xl(e,t,n,r){return ss(wo(e,t+1),3,r)}function El(e,t,n,r){return ss(_o(e,t+1),5,r)}function vl(e,t,n,r){return ss(Rl(e,t+1),9,r)}function or(e,t,n){let r=t.value;if(r===!1)e.pushByte(y.float.majorEncoded|ho);else if(r===!0)e.pushByte(y.float.majorEncoded|mo);else if(r===null)e.pushByte(y.float.majorEncoded|go);else if(r===void 0)e.pushByte(y.float.majorEncoded|yo);else{let o,i=!1;(!n||n.float64!==!0)&&(as(r),o=wo(se,1),r===o||Number.isNaN(r)?(se[0]=249,e.push(se.slice(0,3)),i=!0):(cs(r),o=_o(se,1),r===o&&(se[0]=250,e.push(se.slice(0,5)),i=!0))),i||(Al(r),o=Rl(se,1),se[0]=251,e.push(se.slice(0,9)))}}or.encodedSize=function(t,n){let r=t.value;if(r===!1||r===!0||r===null||r===void 0)return 1;if(!n||n.float64!==!0){as(r);let o=wo(se,1);if(r===o||Number.isNaN(r))return 3;if(cs(r),o=_o(se,1),r===o)return 5}return 9};var Sl=new ArrayBuffer(9),Ie=new DataView(Sl,1),se=new Uint8Array(Sl,0);function as(e){if(e===1/0)Ie.setUint16(0,31744,!1);else if(e===-1/0)Ie.setUint16(0,64512,!1);else if(Number.isNaN(e))Ie.setUint16(0,32256,!1);else{Ie.setFloat32(0,e);let t=Ie.getUint32(0),n=(t&2139095040)>>23,r=t&8388607;if(n===255)Ie.setUint16(0,31744,!1);else if(n===0)Ie.setUint16(0,(t&2147483648)>>16|r>>13,!1);else{let o=n-127;o<-24?Ie.setUint16(0,0):o<-14?Ie.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):Ie.setUint16(0,(t&2147483648)>>16|o+15<<10|r>>13,!1)}}}function wo(e,t){if(e.length-t<2)throw new Error(`${z} not enough data for float16`);let n=(e[t]<<8)+e[t+1];if(n===31744)return 1/0;if(n===64512)return-1/0;if(n===32256)return NaN;let r=n>>10&31,o=n&1023,i;return r===0?i=o*2**-24:r!==31?i=(o+1024)*2**(r-25):i=o===0?1/0:NaN,n&32768?-i:i}function cs(e){Ie.setFloat32(0,e,!1)}function _o(e,t){if(e.length-t<4)throw new Error(`${z} not enough data for float32`);let n=(e.byteOffset||0)+t;return new DataView(e.buffer,n,4).getFloat32(0,!1)}function Al(e){Ie.setFloat64(0,e,!1)}function Rl(e,t){if(e.length-t<8)throw new Error(`${z} not enough data for float64`);let n=(e.byteOffset||0)+t;return new DataView(e.buffer,n,8).getFloat64(0,!1)}function Ah(e,t){let n=e.value;if(n===!1)return Uint8Array.of(y.float.majorEncoded|ho);if(n===!0)return Uint8Array.of(y.float.majorEncoded|mo);if(n===null)return Uint8Array.of(y.float.majorEncoded|go);if(n===void 0)return Uint8Array.of(y.float.majorEncoded|yo);if(!t){if(as(n),n===wo(se,1)||Number.isNaN(n))return se[0]=249,se.slice(0,3);if(cs(n),n===_o(se,1))return se[0]=250,se.slice(0,5)}return Al(n),se[0]=251,se.slice(0,9)}function wl(e,t){let n=e,r=t?.float64===!0,o=r?n._keyBytesFloat64:n._keyBytes;if(o!==void 0)return o;let i=Ah(e,r);return r?n._keyBytesFloat64=i:n._keyBytes=i,i}or.compareTokens=function(t,n,r){let o=wl(t,r),i=wl(n,r);return o.length!==i.length?o.length<i.length?-1:1:an(o,i)};function Z(e,t,n){throw new Error(`${z} encountered invalid minor (${n}) for major ${e[t]>>>5}`)}function bo(e){return()=>{throw new Error(`${z} ${e}`)}}var R=[];for(let e=0;e<=23;e++)R[e]=Z;R[24]=Cu;R[25]=Du;R[26]=Uu;R[27]=Mu;R[28]=Z;R[29]=Z;R[30]=Z;R[31]=Z;for(let e=32;e<=55;e++)R[e]=Z;R[56]=Lu;R[57]=Nu;R[58]=Bu;R[59]=Zu;R[60]=Z;R[61]=Z;R[62]=Z;R[63]=Z;for(let e=64;e<=87;e++)R[e]=Fu;R[88]=Hu;R[89]=Gu;R[90]=qu;R[91]=Ju;R[92]=Z;R[93]=Z;R[94]=Z;R[95]=bo("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)R[e]=Vu;R[120]=Wu;R[121]=Xu;R[122]=Yu;R[123]=Qu;R[124]=Z;R[125]=Z;R[126]=Z;R[127]=bo("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)R[e]=tl;R[152]=nl;R[153]=rl;R[154]=ol;R[155]=il;R[156]=Z;R[157]=Z;R[158]=Z;R[159]=sl;for(let e=160;e<=183;e++)R[e]=al;R[184]=cl;R[185]=ul;R[186]=ll;R[187]=dl;R[188]=Z;R[189]=Z;R[190]=Z;R[191]=fl;for(let e=192;e<=215;e++)R[e]=pl;R[216]=hl;R[217]=ml;R[218]=gl;R[219]=yl;R[220]=Z;R[221]=Z;R[222]=Z;R[223]=Z;for(let e=224;e<=243;e++)R[e]=bo("simple values are not supported");R[244]=Z;R[245]=Z;R[246]=Z;R[247]=_l;R[248]=bo("simple values are not supported");R[249]=xl;R[250]=El;R[251]=vl;R[252]=Z;R[253]=Z;R[254]=Z;R[255]=bl;var Le=[];for(let e=0;e<24;e++)Le[e]=new T(y.uint,e,1);for(let e=-1;e>=-24;e--)Le[31-e]=new T(y.negint,e,1);Le[64]=new T(y.bytes,new Uint8Array(0),1);Le[96]=new T(y.string,"",1);Le[128]=new T(y.array,0,1);Le[160]=new T(y.map,0,1);Le[244]=new T(y.false,!1,1);Le[245]=new T(y.true,!0,1);Le[246]=new T(y.null,null,1);function us(e){switch(e.type){case y.false:return Fe([244]);case y.true:return Fe([245]);case y.null:return Fe([246]);case y.bytes:return e.value.length?void 0:Fe([64]);case y.string:return e.value===""?Fe([96]):void 0;case y.array:return e.value===0?Fe([128]):void 0;case y.map:return e.value===0?Fe([160]):void 0;case y.uint:return e.value<24?Fe([Number(e.value)]):void 0;case y.negint:if(e.value>=-24)return Fe([31-Number(e.value)])}}var Ph={float64:!1,mapSorter:ds,quickEncodeToken:us},Il=Object.freeze({mapSorter:kh,quickEncodeToken:us});function Th(){let e=[];return e[y.uint.major]=He,e[y.negint.major]=co,e[y.bytes.major]=cn,e[y.string.major]=el,e[y.array.major]=lo,e[y.map.major]=fo,e[y.tag.major]=po,e[y.float.major]=or,e}var Nt=Th(),xo=new er,fn=class e{constructor(t,n){this.obj=t,this.parent=n}includes(t){let n=this;do if(n.obj===t)return!0;while(n=n.parent);return!1}static createCheck(t,n){if(t&&t.includes(n))throw new Error(`${ao} object contains circular references`);return new e(n,t)}},mt={null:new T(y.null,null),undefined:new T(y.undefined,void 0),true:new T(y.true,!0),false:new T(y.false,!1),emptyArray:new T(y.array,0),emptyMap:new T(y.map,0)},Ge={number(e,t,n,r){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new T(y.float,e):e>=0?new T(y.uint,e):new T(y.negint,e)},bigint(e,t,n,r){return e>=BigInt(0)?new T(y.uint,e):new T(y.negint,e)},Uint8Array(e,t,n,r){return new T(y.bytes,e)},string(e,t,n,r){return new T(y.string,e)},boolean(e,t,n,r){return e?mt.true:mt.false},null(e,t,n,r){return mt.null},undefined(e,t,n,r){return mt.undefined},ArrayBuffer(e,t,n,r){return new T(y.bytes,new Uint8Array(e))},DataView(e,t,n,r){return new T(y.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,n,r){if(!e.length)return n.addBreakTokens===!0?[mt.emptyArray,new T(y.break)]:mt.emptyArray;r=fn.createCheck(r,e);let o=[],i=0;for(let s of e)o[i++]=Lt(s,n,r);return n.addBreakTokens?[new T(y.array,e.length),o,new T(y.break)]:[new T(y.array,e.length),o]},Object(e,t,n,r){let o=t!=="Object",i=o?e.keys():Object.keys(e),s=o?e.size:i.length,a;if(s){a=new Array(s),r=fn.createCheck(r,e);let c=!o&&n.ignoreUndefinedProperties,u=0;for(let l of i){let d=o?e.get(l):e[l];c&&d===void 0||(a[u++]=[Lt(l,n,r),Lt(d,n,r)])}u<s&&(a.length=u)}return a?.length?(Oh(a,n),n.addBreakTokens?[new T(y.map,a.length),a,new T(y.break)]:[new T(y.map,a.length),a]):n.addBreakTokens===!0?[mt.emptyMap,new T(y.break)]:mt.emptyMap},Tagged(e,t,n,r){return[new T(y.tag,e.tag),Lt(e.value,n,r)]}};Ge.Map=Ge.Object;Ge.Buffer=Ge.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Ge[`${e}Array`]=Ge.DataView;function Lt(e,t={},n){let r=rs(e),o=t&&t.typeEncoders&&t.typeEncoders[r]||Ge[r];if(typeof o=="function"){let s=o(e,r,t,n);if(s!=null)return s}let i=Ge[r];if(!i)throw new Error(`${ao} unsupported type: ${r}`);return i(e,r,t,n)}function Oh(e,t){let n=t.mapSorter;n&&e.sort((r,o)=>n(r,o,t))}function ds(e,t,n){let r=Array.isArray(e[0])?e[0][0]:e[0],o=Array.isArray(t[0])?t[0][0]:t[0];if(r.type.major!==o.type.major)return r.type.compare(o.type);let i=r.type.major,s=Nt[i].compareTokens(r,o,n);return s===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),s}function kh(e,t){if(e[0]instanceof T&&t[0]instanceof T){let n=e[0],r=t[0];return n._keyBytes||(n._keyBytes=Pl(n.value)),r._keyBytes||(r._keyBytes=Pl(r.value)),an(n._keyBytes,r._keyBytes)}throw new Error("rfc8949MapSorter: complex key types are not supported yet")}function Pl(e){return zl(e,Nt,Il)}function dn(e,t,n,r){if(Array.isArray(t))for(let o of t)dn(e,o,n,r);else n[t.type.major](e,t,r)}var Tl=y.uint.majorEncoded,Ol=y.negint.majorEncoded,Ih=y.bytes.majorEncoded,zh=y.string.majorEncoded,kl=y.array.majorEncoded,ls=y.map.majorEncoded,$h=y.float.majorEncoded|ho,Ch=y.float.majorEncoded|mo,Dh=y.float.majorEncoded|go,Uh=y.float.majorEncoded|yo,Mh=BigInt(-1),Lh=BigInt(1);function gt(e,t,n){n<24?e.pushByte(t|Number(n)):ie(e,t,n)}function Nh(e){return e.addBreakTokens!==!0}function Bh(e,t,n,r,o){let i=n==="Map",s=i?t.keys():Object.keys(t),a=i?t.size:s.length;if(!a){e.pushByte(ls);return}o=fn.createCheck(o,t);let c=!i&&r.ignoreUndefinedProperties,u=new Array(a),l=0;for(let d of s){let f=i?t.get(d):t[d];c&&f===void 0||(u[l++]=[Lt(d,r,o),f])}if(l===0){e.pushByte(ls);return}l<a&&(u.length=l),u.sort((d,f)=>ds(d,f,r)),gt(e,ls,l);for(let[d,f]of u)dn(e,d,Nt,r),fs(e,f,r,o)}function fs(e,t,n,r){let o=rs(t),i=n.typeEncoders&&n.typeEncoders[o];if(i){let s=i(t,o,n,r);if(s!=null){dn(e,s,Nt,n);return}}switch(o){case"null":e.pushByte(Dh);return;case"undefined":e.pushByte(Uh);return;case"boolean":e.pushByte(t?Ch:$h);return;case"number":!Number.isInteger(t)||!Number.isSafeInteger(t)?or(e,new T(y.float,t),n):t>=0?gt(e,Tl,t):gt(e,Ol,t*-1-1);return;case"bigint":t>=BigInt(0)?gt(e,Tl,t):gt(e,Ol,t*Mh-Lh);return;case"string":{let s=io(t);gt(e,zh,s.length),e.push(s);return}case"Uint8Array":gt(e,Ih,t.length),e.push(t);return;case"Array":if(!t.length){e.pushByte(kl);return}r=fn.createCheck(r,t),gt(e,kl,t.length);for(let s of t)fs(e,s,n,r);return;case"Object":case"Map":if(n.mapSorter===ds)Bh(e,t,o,n,r);else{let s=Ge.Object(t,o,n,r);dn(e,s,Nt,n)}return;default:{let s=Ge[o];if(!s)throw new Error(`${ao} unsupported type: ${o}`);let a=s(t,o,n,r);dn(e,a,Nt,n)}}}function zl(e,t,n,r){let o=r instanceof Uint8Array,i=o?new so(r):xo,s=Lt(e,n);if(!Array.isArray(s)&&n.quickEncodeToken){let a=n.quickEncodeToken(s);if(a)return o?(i.push(a),i.toBytes()):a;let c=t[s.type.major];if(c.encodedSize){let u=c.encodedSize(s,n);if(o||(i=new er(u)),c(i,s,n),i.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${s} was wrong`);return o?i.toBytes():Qn(i.chunks[0])}}return i.reset(),dn(i,s,t,n),i.toBytes(!0)}function ps(e,t){return t=Object.assign({},Ph,t),Nh(t)?(xo.reset(),fs(xo,e,t,void 0),xo.toBytes(!0)):zl(e,Nt,t)}var jh={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Eo=class{constructor(t,n={}){this._pos=0,this.data=t,this.options=n}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let t=this.data[this._pos],n=Le[t];if(n===void 0){let r=R[t];if(!r)throw new Error(`${z} no decoder for major type ${t>>>5} (byte 0x${t.toString(16).padStart(2,"0")})`);let o=t&31;n=r(this.data,this._pos,o,this.options)}return this._pos+=n.encodedLength,n}},yt=Symbol.for("DONE"),pn=Symbol.for("BREAK");function Zh(e,t,n){let r=[];for(let o=0;o<e.value;o++){let i=wt(t,n);if(i===pn){if(e.value===1/0)break;throw new Error(`${z} got unexpected break to lengthed array`)}if(i===yt)throw new Error(`${z} found array but not enough entries (got ${o}, expected ${e.value})`);r[o]=i}return r}function Fh(e,t,n){let r=n.useMaps===!0,o=n.rejectDuplicateMapKeys===!0,i=r?void 0:{},s=r?new Map:void 0;for(let a=0;a<e.value;a++){let c=wt(t,n);if(c===pn){if(e.value===1/0)break;throw new Error(`${z} got unexpected break to lengthed map`)}if(c===yt)throw new Error(`${z} found map but not enough entries (got ${a} [no key], expected ${e.value})`);if(!r&&typeof c!="string")throw new Error(`${z} non-string keys not supported (got ${typeof c})`);if(o&&(r&&s.has(c)||!r&&Object.hasOwn(i,c)))throw new Error(`${z} found repeat map key "${c}"`);let u=wt(t,n);if(u===yt)throw new Error(`${z} found map but not enough entries (got ${a} [no value], expected ${e.value})`);r?s.set(c,u):i[c]=u}return r?s:i}function*Hh(e,t,n){for(let r=0;r<e.value;r++){let o=wt(t,n);if(o===pn){if(e.value===1/0)break;throw new Error(`${z} got unexpected break to lengthed map`)}if(o===yt)throw new Error(`${z} found map but not enough entries (got ${r} [no key], expected ${e.value})`);let i=wt(t,n);if(i===yt)throw new Error(`${z} found map but not enough entries (got ${r} [no value], expected ${e.value})`);yield[o,i]}}function Gh(e,t){let n=function(){if(n._called)throw new Error(`${z} tag decode() may only be called once`);n._called=!0;let r=wt(e,t);if(r===yt)throw new Error(`${z} tag content missing`);if(r===pn)throw new Error(`${z} got unexpected break in tag content`);return r};return n.entries=function(){if(n._called)throw new Error(`${z} tag decode() may only be called once`);n._called=!0;let r=e.next();if(!y.equals(r.type,y.map))throw new Error(`${z} entries() requires map content, got ${r.type.name}`);let o=[];for(let i of Hh(r,e,t))o.push(i);return o},n._called=!1,n}function wt(e,t){if(e.done())return yt;let n=e.next();if(y.equals(n.type,y.break))return pn;if(n.type.terminal)return n.value;if(y.equals(n.type,y.array))return Zh(n,e,t);if(y.equals(n.type,y.map))return Fh(n,e,t);if(y.equals(n.type,y.tag)){if(t.tags&&typeof t.tags[n.value]=="function"){let r=Gh(e,t),o=t.tags[n.value](r);if(!r._called)throw new Error(`${z} tag decoder must call decode() or entries()`);return o}throw new Error(`${z} tag not supported (${n.value})`)}throw new Error("unsupported")}function $l(e,t){if(!(e instanceof Uint8Array))throw new Error(`${z} data to decode must be a Uint8Array`);t=Object.assign({},jh,t);let n=Qn(e),r=t.tokenizer||new Eo(n,t),o=wt(r,t);if(o===yt)throw new Error(`${z} did not find any content to decode`);if(o===pn)throw new Error(`${z} got unexpected break`);return[o,e.subarray(r.pos())]}function hs(e,t){let[n,r]=$l(e,t);if(r.length>0)throw new Error(`${z} too many terminals, data makes no sense`);return n}var vo=class e{constructor(t,n){if(typeof t!="number"||!Number.isInteger(t)||t<0)throw new TypeError("Tagged: tag must be a non-negative integer");this.tag=t,this.value=n}static decoder(t){return n=>new e(t,n())}static preserve(...t){let n={};for(let r of t)n[r]=e.decoder(r);return n}};Object.defineProperty(vo.prototype,Symbol.toStringTag,{value:"Tagged"});var DS=new Uint8Array(0);function Cl(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.byteLength;n++)if(e[n]!==t[n])return!1;return!0}function hn(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return Bt(e);if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return Bt(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));throw new Error("Unknown type, must be binary type")}function Jh(e){return e?.buffer instanceof ArrayBuffer}function Bt(e){return Jh(e)?e:e.slice()}function Kh(e,t,n){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),o=0;o<r.length;o++)r[o]=255;for(var i=0;i<e.length;i++){var s=e.charAt(i),a=s.charCodeAt(0);if(r[a]!==255)throw new TypeError(s+" is ambiguous");if(r[a]=i,n){var c=s.toLowerCase().charCodeAt(0),u=s.toUpperCase().charCodeAt(0);c!==a&&(r[c]=i),u!==a&&(r[u]=i)}}var l=e.length,d=e.charAt(0),f=Math.log(l)/Math.log(256),m=Math.log(256)/Math.log(l);function w(h){if(h instanceof Uint8Array||(ArrayBuffer.isView(h)?h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):Array.isArray(h)&&(h=Uint8Array.from(h))),!(h instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(h.length===0)return"";for(var _=0,x=0,E=0,A=h.length;E!==A&&h[E]===0;)E++,_++;for(var k=(A-E)*m+1>>>0,I=new Uint8Array(k);E!==A;){for(var U=h[E],V=0,G=k-1;(U!==0||V<x)&&G!==-1;G--,V++)U+=256*I[G]>>>0,I[G]=U%l>>>0,U=U/l>>>0;if(U!==0)throw new Error("Non-zero carry");x=V,E++}for(var g=k-x;g!==k&&I[g]===0;)g++;for(var v=d.repeat(_);g<k;++g)v+=e.charAt(I[g]);return v}function b(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;var _=0;if(h[_]!==" "){for(var x=0,E=0;h[_]===d;)x++,_++;for(var A=(h.length-_)*f+1>>>0,k=new Uint8Array(A);h[_];){var I=r[h.charCodeAt(_)];if(I===255)return;for(var U=0,V=A-1;(I!==0||U<E)&&V!==-1;V--,U++)I+=l*k[V]>>>0,k[V]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");E=U,_++}if(h[_]!==" "){for(var G=A-E;G!==A&&k[G]===0;)G++;for(var g=new Uint8Array(x+(A-G)),v=x;G!==A;)g[v++]=k[G++];return g}}}function S(h){var _=b(h);if(_)return _;throw new Error(`Non-${t} character`)}return{encode:w,decodeUnsafe:b,decode:S}}var Vh=Kh,Wh=Vh,Dl=Wh;var ms=class{name;prefix;baseEncode;constructor(t,n,r){this.name=t,this.prefix=n,this.baseEncode=r}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},gs=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,n,r){this.name=t,this.prefix=n;let o=n.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=r}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Ul(this,t)}},ys=class{decoders;constructor(t){this.decoders=t}or(t){return Ul(this,t)}decode(t){let n=t[0],r=this.decoders[n];if(r!=null)return r.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Ul(e,t){return new ys({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var ws=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,n,r,o){this.name=t,this.prefix=n,this.baseEncode=r,this.baseDecode=o,this.encoder=new ms(t,n,r),this.decoder=new gs(t,n,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Ml({name:e,prefix:t,encode:n,decode:r}){return new ws(e,t,n,r)}function mn({name:e,prefix:t,alphabet:n,caseInsensitive:r=!1}){let{encode:o,decode:i}=Dl(n,e,r);return Ml({prefix:t,name:e,encode:o,decode:s=>hn(i(s))})}function Xh(e,t,n,r){let o=e.length;for(;e[o-1]==="=";)--o;let i=new Uint8Array(o*n/8|0),s=0,a=0,c=0;for(let u=0;u<o;++u){let l=t[e[u]];if(l===void 0)throw new SyntaxError(`Non-${r} character`);a=a<<n|l,s+=n,s>=8&&(s-=8,i[c++]=255&a>>s)}if(s>=n||(255&a<<8-s)!==0)throw new SyntaxError("Unexpected end of data");return i}function Yh(e,t,n){let r=t[t.length-1]==="=",o=(1<<n)-1,i="",s=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>n;)s-=n,i+=t[o&a>>s];if(s!==0&&(i+=t[o&a<<n-s]),r)for(;(i.length*n&7)!==0;)i+="=";return i}function Qh(e,t){let n={};for(let r=0;r<e.length;++r)if(n[e[r]]=r,t){let o=e[r].toLowerCase(),i=e[r].toUpperCase();o!==e[r]&&(n[o]=r),i!==e[r]&&(n[i]=r)}return n}function qe({name:e,prefix:t,bitsPerChar:n,alphabet:r,caseInsensitive:o=!1}){let i=Qh(r,o);return Ml({prefix:t,name:e,encode(s){return Yh(s,r,n)},decode(s){return Xh(s,i,n,e)}})}var ir=qe({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5,caseInsensitive:!0}),ZS=qe({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5,caseInsensitive:!0}),FS=qe({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5,caseInsensitive:!0}),HS=qe({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5,caseInsensitive:!0}),GS=qe({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5,caseInsensitive:!0}),qS=qe({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5,caseInsensitive:!0}),JS=qe({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5,caseInsensitive:!0}),KS=qe({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5,caseInsensitive:!0}),VS=qe({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var So=mn({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz",caseInsensitive:!0}),YS=mn({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",caseInsensitive:!0});var ut=mn({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),tA=mn({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var em=Bl,Ll=128,tm=127,nm=~tm,rm=Math.pow(2,31);function Bl(e,t,n){t=t||[],n=n||0;for(var r=n;e>=rm;)t[n++]=e&255|Ll,e/=128;for(;e&nm;)t[n++]=e&255|Ll,e>>>=7;return t[n]=e|0,Bl.bytes=n-r+1,t}var om=_s,im=128,Nl=127;function _s(e,r){var n=0,r=r||0,o=0,i=r,s,a=e.length;do{if(i>=a)throw _s.bytes=0,new RangeError("Could not decode varint");s=e[i++],n+=o<28?(s&Nl)<<o:(s&Nl)*Math.pow(2,o),o+=7}while(s>=im);return _s.bytes=i-r,n}var sm=Math.pow(2,7),am=Math.pow(2,14),cm=Math.pow(2,21),um=Math.pow(2,28),lm=Math.pow(2,35),dm=Math.pow(2,42),fm=Math.pow(2,49),pm=Math.pow(2,56),hm=Math.pow(2,63),mm=function(e){return e<sm?1:e<am?2:e<cm?3:e<um?4:e<lm?5:e<dm?6:e<fm?7:e<pm?8:e<hm?9:10},gm={encode:em,decode:om,encodingLength:mm},ym=gm,sr=ym;function ar(e,t=0){let n=sr.decode(e,t),r=sr.decode.bytes;if(r>9)throw new RangeError("Invalid varint: too long");if(r>1&&e[t+r-1]===0)throw new RangeError("Invalid varint: not minimally encoded");return[n,r]}function gn(e,t,n=0){return sr.encode(e,t,n),t}function yn(e){return sr.encodingLength(e)}function Zl(e,t){let n=t.byteLength,r=yn(e),o=r+yn(n),i=new Uint8Array(o+n);return gn(e,i,0),gn(n,i,r),i.set(t,o),new wn(e,n,t,i)}function Fl(e){let t=hn(e),[n,r]=ar(t),[o,i]=ar(t.subarray(r)),s=t.subarray(r+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new wn(n,o,s,t)}function Hl(e,t){if(e===t)return!0;{let n=t;return e.code===n.code&&e.size===n.size&&n.bytes instanceof Uint8Array&&Cl(e.bytes,n.bytes)}}var wn=class{code;size;digest;bytes;constructor(t,n,r,o){this.code=t,this.size=n,this.digest=Bt(r),this.bytes=Bt(o)}};function Gl(e,t){let{bytes:n,version:r}=e;return r===0?bm(n,bs(e),t??ut.encoder):xm(n,bs(e),t??ir.encoder)}var ql=new WeakMap;function bs(e){let t=ql.get(e);if(t==null){let n=new Map;return ql.set(e,n),n}return t}var ur=class e{code;version;multihash;bytes;"/";constructor(t,n,r,o){this.code=n,this.version=t,this.multihash=r,this.bytes=Bt(o),this["/"]=this.bytes}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:n}=this;if(t!==cr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(n.code!==Em)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.createV0(n)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:n}=this.multihash,r=Zl(t,n);return e.createV1(this.code,r)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return e.equals(this,t)}static equals(t,n){let r=n;return r!=null&&t.code===r.code&&t.version===r.version&&Hl(t.multihash,r.multihash)}toString(t){return Gl(this,t)}toJSON(){return{"/":Gl(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let n=t;if(n instanceof e)return n;if(n["/"]!=null&&n["/"]===n.bytes||n.asCID===n){let{version:r,code:o,multihash:i,bytes:s}=n;return new e(r,o,i,s??Jl(r,o,i.bytes))}else if(n[vm]===!0){let{version:r,multihash:o,code:i}=n,s=Fl(o);return e.create(r,i,s)}else return null}static create(t,n,r){if(typeof n!="number")throw new Error("String codecs are no longer supported");if(!(r.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(n!==cr)throw new Error(`Version 0 CID must use dag-pb (code: ${cr}) block encoding`);return new e(t,n,r,r.bytes)}case 1:{let o=Jl(t,n,r.bytes);return new e(t,n,r,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,cr,t)}static createV1(t,n){return e.create(1,t,n)}static decode(t){let[n,r]=e.decodeFirst(t);if(r.length!==0)throw new Error("Incorrect length");return n}static decodeFirst(t){let n=e.inspectBytes(t),r=n.size-n.multihashSize,o=hn(t.subarray(r,r+n.multihashSize));if(o.byteLength!==n.multihashSize)throw new Error("Incorrect length");let i=o.subarray(n.multihashSize-n.digestSize),s=new wn(n.multihashCode,n.digestSize,i,o);return[n.version===0?e.createV0(s):e.createV1(n.codec,s),t.subarray(n.size)]}static inspectBytes(t){let n=0,r=()=>{let[d,f]=ar(t.subarray(n));return n+=f,d},o=r(),i=cr;if(o===18?(o=0,n=0):i=r(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=n,a=r(),c=r(),u=n+c,l=u-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:l,size:u}}static parse(t,n){let[r,o]=_m(t,n),i=e.decode(o);if(i.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return bs(i).set(r,t),i}};function _m(e,t){switch(e[0]){case"Q":{let n=t??ut;return[ut.prefix,n.decode(`${ut.prefix}${e}`)]}case ut.prefix:{let n=t??ut;return[ut.prefix,n.decode(e)]}case ir.prefix:{let n=t??ir;return[ir.prefix,n.decode(e)]}case So.prefix:{let n=t??So;return[So.prefix,n.decode(e)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function bm(e,t,n){let{prefix:r}=n;if(r!==ut.prefix)throw Error(`Cannot string encode V0 in ${n.name} encoding`);let o=t.get(r);if(o==null){let i=n.encode(e).slice(1);return t.set(r,i),i}else return o}function xm(e,t,n){let{prefix:r}=n,o=t.get(r);if(o==null){let i=n.encode(e);return t.set(r,i),i}else return o}var cr=112,Em=18;function Jl(e,t,n){let r=yn(e),o=r+yn(t),i=new Uint8Array(o+n.byteLength);return gn(e,i,0),gn(t,i,r),i.set(n,o),i}var vm=Symbol.for("@ipld/js-cid/CID");var Kl=42;function Sm(e){return e instanceof ArrayBuffer?new Uint8Array(e,0,e.byteLength):e}function Am(e){if(e.asCID!==e&&e["/"]!==e.bytes)return null;let t=ur.asCID(e);if(!t)return null;let n=new Uint8Array(t.bytes.byteLength+1);return n.set(t.bytes,1),[new T(y.tag,Kl),new T(y.bytes,n)]}function Rm(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function Pm(e){if(Number.isNaN(e))throw new Error("`NaN` is not supported by the IPLD Data Model and cannot be encoded");if(e===1/0||e===-1/0)throw new Error("`Infinity` and `-Infinity` is not supported by the IPLD Data Model and cannot be encoded");return null}function Tm(e){for(let t of e.keys())if(typeof t!="string"||t.length===0)throw new Error("Non-string Map keys are not supported by the IPLD Data Model and cannot be encoded");return null}var xs={float64:!0,typeEncoders:{Map:Tm,Object:Am,undefined:Rm,number:Pm}},pA={...xs,typeEncoders:{...xs.typeEncoders}};function Om(e){let t=e();if(t[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return ur.decode(t.subarray(1))}var Es={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:{[Kl]:Om}},hA={...Es,tags:{...Es.tags}};var Pe=e=>ps(e,xs),Je=e=>hs(Sm(e),Es);function km(){let e=new Map;return async(t,n)=>{if(t.params&&t.params["no-cache"]==="true")return await n();let r=e.get(t.didUrl);if(r!==void 0)return r;let o=await n();return o.didResolutionMetadata?.error!=="notFound"&&e.set(t.didUrl,o),o}}function Im(e,t){return t()}var zm="(?:%[0-9a-fA-F]{2})",Vl=`(?:[a-zA-Z0-9._-]|${zm})`,$m="([a-z0-9]+)",Cm=`((?:${Vl}*:)*(${Vl}+))`,Wl="[a-zA-Z0-9_.:%-]",Dm=`;${Wl}+=${Wl}*`,Um=`((${Dm})*)`,Mm="(/[^#?]*)?",Lm="([?][^#]*)?",Nm="(#.*)?",Bm=new RegExp(`^did:${$m}:${Cm}${Um}${Mm}${Lm}${Nm}$`);function jm(e){if(e===""||!e)return null;let t=e.match(Bm);if(t){let n={did:`did:${t[1]}:${t[2]}`,method:t[1],id:t[2],didUrl:e};if(t[4]){let r=t[4].slice(1).split(";");n.params={};for(let o of r){let i=o.split("=");n.params[i[0]]=i[1]}}return t[6]&&(n.path=t[6]),t[7]&&(n.query=t[7].slice(1)),t[8]&&(n.fragment=t[8].slice(1)),n}return null}var Ao={didResolutionMetadata:{},didDocument:null,didDocumentMetadata:{}};function Zm(e){return async(t,n,r)=>{try{let o=await e(t,n,r);return{...Ao,didResolutionMetadata:{contentType:"application/did+ld+json"},didDocument:o}}catch(o){return{...Ao,didResolutionMetadata:{error:"notFound",message:o.toString()}}}}}var Ro=class{constructor(t={},n={}){this.registry=t,this.cache=n.cache===!0?km():n.cache||Im,n.legacyResolvers&&Object.keys(n.legacyResolvers).map(r=>{this.registry[r]||(this.registry[r]=Zm(n.legacyResolvers[r]))})}async resolve(t,n={}){let r=jm(t);if(r===null)return{...Ao,didResolutionMetadata:{error:"invalidDid"}};let o=this.registry[r.method];return o?this.cache(r,()=>o(r.did,r,this,n)):{...Ao,didResolutionMetadata:{error:"unsupportedDidMethod"}}}};function lr(e,t){return function(){return e.apply(t,arguments)}}var{toString:Fm}=Object.prototype,{getPrototypeOf:_t}=Object,{iterator:pr,toStringTag:Ql}=Symbol,dr=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),ed=e=>typeof e=="string"&&(e==="__proto__"||e==="constructor"||e==="prototype"),td=(e,t,n)=>e===Object.prototype||!n&&t===null,Hm=e=>{if(!Object.isExtensible(e))return!1;let t=Object.getOwnPropertyNames(e);return Object.getOwnPropertySymbols&&t.push(...Object.getOwnPropertySymbols(e)),t.every(n=>{if(ed(n))return!1;let r=Object.getOwnPropertyDescriptor(e,n);return!!r&&r.configurable&&r.writable===!0})},fr=(e,t)=>{let n=e,r=[];for(;n!=null;){if(r.indexOf(n)!==-1)return!1;r.push(n);let o=_t(n);if(td(n,o,n===e))return!1;if(dr(n,t))return!0;n=o}return!1},Gm=(e,t)=>e!=null&&fr(e,t)?e[t]:void 0,qm=e=>{if(e==null||typeof e!="object"&&typeof e!="function")return e;let t=_t(e);if(t===null&&Hm(e))return e;let n=Object.create(null),r=Object.create(null),o=[],i=e;for(;i!=null&&o.indexOf(i)===-1;){o.push(i);let s=i===e?t:_t(i);if(td(i,s,i===e))break;let a=Object.getOwnPropertyNames(i);Object.getOwnPropertySymbols&&a.push(...Object.getOwnPropertySymbols(i));for(let c of a)ed(c)||dr(r,c)||(n[c]=e[c],r[c]=!0);i=s}return n},Ss=(e=>t=>{let n=Fm.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),ze=e=>(e=e.toLowerCase(),t=>Ss(t)===e),To=e=>t=>typeof t===e,{isArray:Zt}=Array,Ft=To("undefined");function _n(e){return e!==null&&!Ft(e)&&e.constructor!==null&&!Ft(e.constructor)&&ge(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var nd=ze("ArrayBuffer");function Jm(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&nd(e.buffer),t}var Km=To("string"),ge=To("function"),rd=To("number"),bn=e=>e!==null&&typeof e=="object",Vm=e=>e===!0||e===!1,Po=e=>{if(!bn(e))return!1;let t=_t(e);return(t===null||t===Object.prototype||_t(t)===null)&&!fr(e,Ql)&&!fr(e,pr)},Wm=e=>{if(!bn(e)||_n(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Xm=ze("Date"),Ym=ze("File"),Qm=e=>!!(e&&typeof e.uri<"u"),eg=e=>e&&typeof e.getParts<"u",tg=ze("Blob"),ng=ze("FileList"),rg=ze("Set"),og=e=>bn(e)&&ge(e.pipe);function ig(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}var Xl=ig(),Yl=typeof Xl.FormData<"u"?Xl.FormData:void 0,sg=e=>{if(!e)return!1;if(Yl&&e instanceof Yl)return!0;let t=_t(e);if(!t||t===Object.prototype||!ge(e.append))return!1;let n=Ss(e);return n==="formdata"||n==="object"&&ge(e.toString)&&e.toString()==="[object FormData]"},ag=ze("URLSearchParams"),[cg,ug,lg,dg]=["ReadableStream","Request","Response","Headers"].map(ze),fg=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function hr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),Zt(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(_n(e))return;let i=n?Object.getOwnPropertyNames(e):Object.keys(e),s=i.length,a;for(r=0;r<s;r++)a=i[r],t.call(null,e[a],a,e)}}function od(e,t){if(_n(e))return null;t=t.toLowerCase();let n=Object.keys(e),r=n.length,o;for(;r-- >0;)if(o=n[r],t===o.toLowerCase())return o;return null}var jt=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,id=e=>!Ft(e)&&e!==jt;function vs(...e){let{caseless:t,skipUndefined:n}=id(this)&&this||{},r={},o=(i,s)=>{if(s==="__proto__"||s==="constructor"||s==="prototype")return;let a=t&&typeof s=="string"&&od(r,s)||s,c=dr(r,a)?r[a]:void 0;Po(c)&&Po(i)?r[a]=vs(c,i):Po(i)?r[a]=vs({},i):Zt(i)?r[a]=i.slice():(!n||!Ft(i))&&(r[a]=i)};for(let i=0,s=e.length;i<s;i++){let a=e[i];if(!a||_n(a)||(hr(a,o),typeof a!="object"||Zt(a)))continue;let c=Object.getOwnPropertySymbols(a);for(let u=0;u<c.length;u++){let l=c[u];Sg.call(a,l)&&o(a[l],l)}}return r}var pg=(e,t,n,{allOwnKeys:r}={})=>(hr(t,(o,i)=>{n&&ge(o)?Object.defineProperty(e,i,{__proto__:null,value:lr(o,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,i,{__proto__:null,value:o,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),e),hg=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),mg=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),Object.defineProperty(e.prototype,"constructor",{__proto__:null,value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,"super",{__proto__:null,value:t.prototype}),n&&Object.assign(e.prototype,n)},gg=(e,t,n,r)=>{let o,i,s,a={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),i=o.length;i-- >0;)s=o[i],(!r||r(s,e,t))&&!a[s]&&(t[s]=e[s],a[s]=!0);e=n!==!1&&_t(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},yg=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;let r=e.indexOf(t,n);return r!==-1&&r===n},wg=e=>{if(!e)return null;if(Zt(e))return e;let t=e.length;if(!rd(t))return null;let n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},_g=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&_t(Uint8Array)),bg=(e,t)=>{let r=(e&&e[pr]).call(e),o;for(;(o=r.next())&&!o.done;){let i=o.value;t.call(e,i[0],i[1])}},xg=(e,t)=>{let n,r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Eg=ze("HTMLFormElement"),vg=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),{propertyIsEnumerable:Sg}=Object.prototype,Ag=ze("RegExp"),sd=(e,t)=>{let n=Object.getOwnPropertyDescriptors(e),r={};hr(n,(o,i)=>{let s;(s=t(o,i,e))!==!1&&(r[i]=s||o)}),Object.defineProperties(e,r)},Rg=e=>{sd(e,(t,n)=>{if(ge(e)&&["arguments","caller","callee"].includes(n))return!1;let r=e[n];if(ge(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},Pg=(e,t)=>{let n={},r=o=>{o.forEach(i=>{n[i]=!0})};return Zt(e)?r(e):r(String(e).split(t)),n},Tg=()=>{},Og=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function kg(e){return!!(e&&ge(e.append)&&e[Ql]==="FormData"&&e[pr])}var Ig=e=>{let t=new WeakSet,n=r=>{if(bn(r)){if(t.has(r))return;if(_n(r))return r;if(!("toJSON"in r)){t.add(r);let o;if(rg(r)){o=[];for(let i of r){let s=n(i);!Ft(s)&&o.push(s)}}else o=Zt(r)?[]:{},hr(r,(i,s)=>{let a=n(i);!Ft(a)&&(o[s]=a)});return t.delete(r),o}}return r};return n(e)},zg=ze("AsyncFunction"),$g=e=>e&&(bn(e)||ge(e))&&ge(e.then)&&ge(e.catch),ad=((e,t)=>e?setImmediate:t?((n,r)=>(jt.addEventListener("message",({source:o,data:i})=>{o===jt&&i===n&&r.length&&r.shift()()},!1),o=>{r.push(o),jt.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",ge(jt.postMessage)),Cg=typeof queueMicrotask<"u"?queueMicrotask.bind(jt):typeof process<"u"&&process.nextTick||ad,cd=e=>e!=null&&ge(e[pr]),Dg=e=>e!=null&&fr(e,pr)&&cd(e),p={isArray:Zt,isArrayBuffer:nd,isBuffer:_n,isFormData:sg,isArrayBufferView:Jm,isString:Km,isNumber:rd,isBoolean:Vm,isObject:bn,isPlainObject:Po,isEmptyObject:Wm,isReadableStream:cg,isRequest:ug,isResponse:lg,isHeaders:dg,isUndefined:Ft,isDate:Xm,isFile:Ym,isReactNativeBlob:Qm,isReactNative:eg,isBlob:tg,isRegExp:Ag,isFunction:ge,isStream:og,isURLSearchParams:ag,isTypedArray:_g,isFileList:ng,forEach:hr,merge:vs,extend:pg,trim:fg,stripBOM:hg,inherits:mg,toFlatObject:gg,kindOf:Ss,kindOfTest:ze,endsWith:yg,toArray:wg,forEachEntry:bg,matchAll:xg,isHTMLForm:Eg,hasOwnProperty:dr,hasOwnProp:dr,hasOwnInPrototypeChain:fr,getSafeProp:Gm,toSafeFlatObject:qm,reduceDescriptors:sd,freezeMethods:Rg,toObjectSet:Pg,toCamelCase:vg,noop:Tg,toFiniteNumber:Og,findKey:od,global:jt,isContextDefined:id,isSpecCompliantForm:kg,toJSONObject:Ig,isAsyncFn:zg,isThenable:$g,setImmediate:ad,asap:Cg,isIterable:cd,isSafeIterable:Dg};var Ug=p.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),ud=e=>{let t={},n,r,o;return e&&e.split(`
|
|
3
|
-
`).forEach(function(s){o=s.indexOf(":"),n=s.substring(0,o).trim().toLowerCase(),r=s.substring(o+1).trim();let a=p.hasOwnProp(t,n);!n||a&&p.hasOwnProp(
|
|
4
|
-
`)}getSetCookie(){let t=this.get("set-cookie");return p.isArray(t)?t:t==null||t===!1?[]:[t]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static parseParameters(t){return Hg(t)}static concat(t,...n){let r=new this(t);return n.forEach(o=>r.set(o)),r}static accessor(t){let r=(this[dd]=this[dd]={accessors:{}}).accessors,o=this.prototype;function i(s){let a=mr(s);r[a]||(Jg(o,s),r[a]=!0)}return p.isArray(t)?t.forEach(i):i(t),this}};xn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);p.reduceDescriptors(xn.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}});p.freezeMethods(xn);var Q=xn;var gr="[REDACTED ****]";function Kg(e){if(p.hasOwnProp(e,"toJSON"))return!0;let t=Object.getPrototypeOf(e);for(;t&&t!==Object.prototype;){if(p.hasOwnProp(t,"toJSON"))return!0;t=Object.getPrototypeOf(t)}return!1}function Vg(e,t){let n=new Set(t.map(i=>String(i).toLowerCase())),r=[],o=i=>{if(i===null||typeof i!="object"||p.isBuffer(i))return i;if(r.indexOf(i)!==-1)return;i instanceof Q&&(i=i.toJSON()),r.push(i);let s;if(p.isArray(i))s=[],i.forEach((a,c)=>{let u=o(a);p.isUndefined(u)||(s[c]=u)});else{if(!p.isPlainObject(i)&&Kg(i))return r.pop(),i;s=Object.create(null);for(let[a,c]of Object.entries(i)){let u=n.has(a.toLowerCase())?gr:o(c);p.isUndefined(u)||(s[a]=u)}}return r.pop(),s};return o(e)}function fd(e){try{return String(e)}catch{return""}}function Wg(e){return e.errors.map(n=>{try{return n&&n.message?fd(n.message):fd(n)}catch{return""}}).filter(Boolean).join("; ")||e.name||"AggregateError"}var ue=class e extends Error{static from(t,n,r,o,i,s){let a=t.message;!a&&p.isArray(t.errors)&&t.errors.length&&(a=Wg(t));let c=new e(a,n||t.code,r,o,i);return Object.defineProperty(c,"cause",{__proto__:null,value:t,writable:!0,enumerable:!1,configurable:!0}),c.name=t.name,t.status!=null&&c.status==null&&(c.status=t.status),s&&Object.assign(c,s),c}constructor(t,n,r,o,i){super(t),Object.defineProperty(this,"message",{__proto__:null,value:t,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,n&&(this.code=n),r&&(this.config=r),o&&(this.request=o),i&&(this.response=i,this.status=i.status)}toJSON(){let t=this.config,n=t&&p.hasOwnProp(t,"redact")?t.redact:void 0,r=p.isArray(n)&&n.length>0?Vg(t,n):p.toJSONObject(t);return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:r,code:this.code,status:this.status}}};ue.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";ue.ERR_BAD_OPTION="ERR_BAD_OPTION";ue.ECONNABORTED="ECONNABORTED";ue.ETIMEDOUT="ETIMEDOUT";ue.ECONNREFUSED="ECONNREFUSED";ue.ERR_NETWORK="ERR_NETWORK";ue.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";ue.ERR_DEPRECATED="ERR_DEPRECATED";ue.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";ue.ERR_BAD_REQUEST="ERR_BAD_REQUEST";ue.ERR_CANCELED="ERR_CANCELED";ue.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";ue.ERR_INVALID_URL="ERR_INVALID_URL";ue.ERR_FORM_DATA_DEPTH_EXCEEDED="ERR_FORM_DATA_DEPTH_EXCEEDED";var P=ue;var bt=null;var ks=100;function Os(e){return p.isPlainObject(e)||p.isArray(e)}function pd(e){return p.endsWith(e,"[]")?e.slice(0,-2):e}function Ts(e,t,n){return e?e.concat(t).map(function(o,i){return o=pd(o),!n&&i?"["+o+"]":o}).join(n?".":""):t}function Xg(e){return p.isArray(e)&&!e.some(Os)}var Yg=p.toFlatObject(p,{},null,function(t){return/^is[A-Z]/.test(t)});function Qg(e,t,n){if(!p.isObject(e))throw new TypeError("target must be an object");t=t||new(bt||FormData);let r=(_,x)=>{let E=p.getSafeProp(n,_);return p.isUndefined(E)?x:E},o=r("metaTokens",!0),i=r("visitor")||b,s=r("dots",!1),a=r("indexes",!1),c=r("Blob")||typeof Blob<"u"&&Blob,u=r("maxDepth",ks),l=c&&p.isSpecCompliantForm(t),d=[];if(!p.isFunction(i))throw new TypeError("visitor must be a function");function f(_){if(_===null)return"";if(p.isDate(_))return _.toISOString();if(p.isBoolean(_))return _.toString();if(!l&&p.isBlob(_))throw new P("Blob is not supported. Use a Buffer instead.");if(p.isArrayBuffer(_)||p.isTypedArray(_)){if(l&&typeof c=="function")return new c([_]);if(bt&&bt.isBufferAvailable())return bt.from(_);throw new P("Blob is not supported. Use a Buffer instead.",P.ERR_NOT_SUPPORT)}return _}function m(_){if(_>u)throw new P("Object is too deeply nested ("+_+" levels). Max depth: "+u,P.ERR_FORM_DATA_DEPTH_EXCEEDED)}function w(_,x){if(u===1/0)return JSON.stringify(_);let E=[];return JSON.stringify(_,function(k,I){if(!p.isObject(I))return I;for(;E.length&&E[E.length-1]!==this;)E.pop();return E.push(I),m(x+E.length-1),I})}function b(_,x,E){let A=_;if(p.isReactNative(t)&&p.isReactNativeBlob(_))return t.append(Ts(E,x,s),f(_)),!1;if(_&&!E&&typeof _=="object"){if(p.endsWith(x,"{}"))x=o?x:x.slice(0,-2),_=w(_,1);else if(p.isArray(_)&&Xg(_)||(p.isFileList(_)||p.endsWith(x,"[]"))&&(A=p.toArray(_)))return x=pd(x),A.forEach(function(I,U){!(p.isUndefined(I)||I===null)&&t.append(a===!0?Ts([x],U,s):a===null?x:x+"[]",f(I))}),!1}return Os(_)?!0:(t.append(Ts(E,x,s),f(_)),!1)}let S=Object.assign(Yg,{defaultVisitor:b,convertValue:f,isVisitable:Os});function h(_,x,E=0){if(!p.isUndefined(_)){if(m(E),d.indexOf(_)!==-1)throw new Error("Circular reference detected in "+x.join("."));d.push(_),p.forEach(_,function(k,I){(!(p.isUndefined(k)||k===null)&&i.call(t,k,p.isString(I)?I.trim():I,x,S))===!0&&h(k,x?x.concat(I):[I],E+1)}),d.pop()}}if(!p.isObject(e))throw new TypeError("data must be an object");return h(e),t}var xt=Qg;function hd(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"};return encodeURIComponent(e).replace(/[!'()~]|%20/g,function(r){return t[r]})}function md(e,t){this._pairs=[],e&&xt(e,this,t)}var gd=md.prototype;gd.append=function(t,n){this._pairs.push([t,n])};gd.toString=function(t){let n=t?r=>t.call(this,r,hd):hd;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};var Io=md;function ey(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function yr(e,t,n){if(!t)return e;e=e||"";let r=p.isFunction(n)?{serialize:n}:n,o=p.getSafeProp(r,"encode")||ey,i=p.getSafeProp(r,"serialize"),s;if(i?s=i(t,r):s=p.isURLSearchParams(t)?t.toString():new Io(t,r).toString(o),s){let a=e.indexOf("#");a!==-1&&(e=e.slice(0,a)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}var wr=Symbol("internals");function wd(e){return e?e.length:0}function yd(e){if(e)for(;e.length&&e[e.length-1]===null;)e.pop()}function _r(e,t){let n=e.handlers,r=wd(n);n!==t.handlersRef?(t.handlersRef=n,t.handlerEntries.clear()):r!==t.handlersLength&&(r?t.handlerEntries.forEach(function(i,s){n[i.index]!==i.handler&&t.handlerEntries.delete(s)}):t.handlerEntries.clear()),t.handlersLength=r}var Is=class{constructor(){this.handlers=[],this[wr]={handlersRef:this.handlers,handlersLength:this.handlers.length,handlerEntries:new Map,iterationDepth:0,nextId:0}}use(t,n,r){let o={fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null},i=this[wr];this.handlers==null&&(this.handlers=[]),_r(this,i);let s=i.nextId++;return this.handlers.push(o),i.handlerEntries.set(s,{handler:o,index:this.handlers.length-1}),i.handlersLength=this.handlers.length,s}eject(t){let n=this[wr];_r(this,n);let r=n.handlerEntries.get(t);if(r){if(n.handlerEntries.delete(t),this.handlers[r.index]!==r.handler)return;this.handlers[r.index]=null,n.iterationDepth||(yd(this.handlers),n.handlersLength=this.handlers.length)}}clear(){this.handlers&&(this.handlers=[],_r(this,this[wr]))}forEach(t){let n=this[wr];_r(this,n),n.iterationDepth++;try{p.forEach(this.handlers,function(o){o!==null&&t(o)})}finally{--n.iterationDepth||(_r(this,n),yd(this.handlers),n.handlersLength=wd(this.handlers))}}},zs=Is;var En={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0,advertiseZstdAcceptEncoding:!1,validateStatusUndefinedResolves:!0};var _d=typeof URLSearchParams<"u"?URLSearchParams:Io;var bd=typeof FormData<"u"?FormData:null;var xd=typeof Blob<"u"?Blob:null;var Ed={isBrowser:!0,classes:{URLSearchParams:_d,FormData:bd,Blob:xd},protocols:["http","https","file","blob","url","data"]};var Ds={};wp(Ds,{hasBrowserEnv:()=>Cs,hasStandardBrowserEnv:()=>ty,hasStandardBrowserWebWorkerEnv:()=>ny,navigator:()=>$s,origin:()=>ry});var Cs=typeof window<"u"&&typeof document<"u",$s=typeof navigator=="object"&&navigator||void 0,ty=Cs&&(!$s||["ReactNative","NativeScript","NS"].indexOf($s.product)<0),ny=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",ry=Cs&&window.location.href||"http://localhost";var W={...Ds,...Ed};function Us(e,t){return xt(e,new W.classes.URLSearchParams,{visitor:function(n,r,o,i){return W.isNode&&p.isBuffer(n)?(this.append(r,n.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)},...t})}var vd=ks;function Sd(e){if(e>vd)throw new P("FormData field is too deeply nested ("+e+" levels). Max depth: "+vd,P.ERR_FORM_DATA_DEPTH_EXCEEDED)}function oy(e){let t=[],n=/[^.[\]]+|\[([^.[\]]*)]/g,r;for(;(r=n.exec(e))!==null;)Sd(t.length),t.push(r[0]==="[]"?"":r[1]||r[0]);return t}function iy(e){let t={},n=Object.keys(e),r,o=n.length,i;for(r=0;r<o;r++)i=n[r],t[i]=e[i];return t}function sy(e){function t(n,r,o,i){Sd(i);let s=n[i++];if(s==="__proto__")return!0;let a=Number.isFinite(+s),c=i>=n.length;return s=!s&&p.isArray(o)?o.length:s,c?(p.hasOwnProp(o,s)?o[s]=p.isArray(o[s])?o[s].concat(r):[o[s],r]:o[s]=r,!a):((!p.hasOwnProp(o,s)||!p.isObject(o[s]))&&(o[s]=[]),t(n,r,o[s],i)&&p.isArray(o[s])&&(o[s]=iy(o[s])),!a)}if(p.isFormData(e)&&p.isFunction(e.entries)){let n={};return p.forEachEntry(e,(r,o)=>{t(oy(r),o,n,0)}),n}return null}var zo=sy;var ay=Object.freeze(["get","delete","head","options","post","put","patch","purge","link","unlink","query"]),$o=ay;var vn=(e,t)=>e!=null&&p.hasOwnProp(e,t)?e[t]:void 0;function cy(e,t,n){if(p.isString(e))try{return(t||JSON.parse)(e),p.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}var Ms={transitional:En,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){let r=n.getContentType()||"",o=r.indexOf("application/json")>-1,i=p.isObject(t);if(i&&p.isHTMLForm(t)&&(t=new FormData(t)),p.isFormData(t))return o?JSON.stringify(zo(t)):t;if(p.isArrayBuffer(t)||p.isBuffer(t)||p.isStream(t)||p.isFile(t)||p.isBlob(t)||p.isReadableStream(t))return t;if(p.isArrayBufferView(t))return t.buffer;if(p.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let a;if(i){let c=vn(this,"formSerializer");if(r.indexOf("application/x-www-form-urlencoded")>-1)return Us(t,c).toString();if((a=p.isFileList(t))||r.indexOf("multipart/form-data")>-1){let u=vn(this,"env"),l=u&&u.FormData;return xt(a?{"files[]":t}:t,l&&new l,c)}}return i||o?(n.setContentType("application/json",!1),cy(t)):t}],transformResponse:[function(t){let n=vn(this,"transitional")||Ms.transitional,r=n&&n.forcedJSONParsing,o=vn(this,"responseType"),i=o==="json";if(p.isResponse(t)||p.isReadableStream(t))return t;if(t&&p.isString(t)&&(r&&!o||i)){let a=!(n&&n.silentJSONParsing)&&i;try{return JSON.parse(t,vn(this,"parseReviver"))}catch(c){if(a)throw c.name==="SyntaxError"?P.from(c,P.ERR_BAD_RESPONSE,this,null,vn(this,"response")):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:W.classes.FormData,Blob:W.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};p.forEach($o,e=>{Ms.headers[e]={}});var Sn=Ms;function br(e,t){let n=this||Sn,r=t||n,o=Q.from(r.headers),i=r.data;return p.forEach(e,function(a){i=a.call(n,i,o.normalize(),t?t.status:void 0)}),o.normalize(),i}function xr(e){return!!(e&&e.__CANCEL__)}var Ls=class extends P{constructor(t,n,r){super(t??"canceled",P.ERR_CANCELED,n,r),this.name="CanceledError",this.__CANCEL__=!0}},Ke=Ls;function Er(e,t,n){let r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new P("Request failed with status code "+n.status,n.status>=400&&n.status<500?P.ERR_BAD_REQUEST:P.ERR_BAD_RESPONSE,n.config,n.request,n))}var uy=/[\t\n\r]/g;function vr(e){if(typeof e!="string")return e;let t=0;for(;t<e.length&&e.charCodeAt(t)<=32;)t++;return e.slice(t).replace(uy,"")}function Sr(e){let t=/^([-+\w]{1,25}):(?:\/\/)?/.exec(e);return t&&t[1]||""}function ly(e,t){e=e||10;let n=new Array(e),r=new Array(e),o=0,i=0,s;return t=t!==void 0?t:1e3,function(c){let u=Date.now(),l=r[i];s||(s=u),n[o]=c,r[o]=u;let d=i,f=0;for(;d!==o;)f+=n[d++],d=d%e;if(o=(o+1)%e,o===i&&(i=(i+1)%e),u-s<t)return;let m=l&&u-l;return m?Math.round(f*1e3/m):void 0}}var Ad=ly;function dy(e,t){let n=0,r=1e3/t,o,i,s=(l,d=Date.now())=>{n=d,o=null,i&&(clearTimeout(i),i=null),e(...l)};return[(...l)=>{let d=Date.now(),f=d-n;f>=r?s(l,d):(o=l,i||(i=setTimeout(()=>{i=null,s(o)},r-f)))},()=>o&&s(o),(...l)=>s(l)]}var Rd=dy;var An=(e,t,n=3)=>{let r=0,o=Ad(50,250);return Rd(i=>{if(!i||!p.isNumber(i.loaded))return;let s=i.loaded,a=i.lengthComputable?i.total:void 0,c=Math.max(0,a!=null?Math.min(s,a):s),u=Math.max(0,c-r),l=o(u);r=Math.max(r,c);let d={loaded:c,total:a,progress:a?c/a:void 0,bytes:u,rate:l||void 0,estimated:l&&a?(a-c)/l:void 0,event:i,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(d)},n)},Ns=(e,t)=>{let n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Bs=(e,t=p.asap)=>(...n)=>t(()=>e(...n));var Pd=W.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,W.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(W.origin),W.navigator&&/(msie|trident)/i.test(W.navigator.userAgent)):()=>!0;var Td=W.hasStandardBrowserEnv?{write(e,t,n,r,o,i,s){if(typeof document>"u")return;let a=[`${e}=${encodeURIComponent(t)}`];p.isNumber(n)&&a.push(`expires=${new Date(n).toUTCString()}`),p.isString(r)&&a.push(`path=${r}`),p.isString(o)&&a.push(`domain=${o}`),i===!0&&a.push("secure"),p.isString(s)&&a.push(`SameSite=${s}`),document.cookie=a.join("; ")},read(e){if(typeof document>"u")return null;let t=document.cookie.split(";");for(let n=0;n<t.length;n++){let r=t[n].replace(/^\s+/,""),o=r.indexOf("=");if(o!==-1&&r.slice(0,o)===e)try{return decodeURIComponent(r.slice(o+1))}catch{return r.slice(o+1)}}return null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function js(e){return typeof e!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Zs(e,t){if(!t)return e;let n=e.length;for(;n>0&&e.charCodeAt(n-1)===47;)n--;return e.slice(0,n)+"/"+t.replace(/^\/+/,"")}var fy=/^https?:(?!\/\/)/i;function py(e){return e&&e.replace(/(^|&)([^=&]*=)?[^&]+/g,(t,n,r="")=>`${n}${r}${gr}`)}function hy(e){let t=e.replace(/^(https?:\/{0,2})[^/?#]*@/i,`$1${gr}@`),n=t.indexOf("#"),o=(n===-1?t:t.slice(0,n)).replace(/([?&][^=&#]*=)[^&#]*/g,`$1${gr}`);return n===-1?o:`${o}#${py(t.slice(n+1))}`}function Od(e,t){if(typeof e=="string"){let n=vr(e);if(fy.test(n))throw new P(`Invalid URL ${JSON.stringify(hy(n))}: missing "//" after protocol`,P.ERR_INVALID_URL,t)}}function Ar(e,t,n,r){Od(t,r);let o=!js(t);return e&&(o||n===!1)?(Od(e,r),Zs(e,t)):t}var kd=e=>e instanceof Q?{...e}:e,my=e=>Object.getOwnPropertySymbols&&Object.getOwnPropertyDescriptor?Object.keys(e).concat(Object.getOwnPropertySymbols(e).filter(t=>Object.getOwnPropertyDescriptor(e,t).enumerable)):Object.keys(e);function Ne(e,t){e=e||{},t=t||{};let n=Object.create(null);Object.defineProperty(n,"hasOwnProperty",{__proto__:null,value:Object.prototype.hasOwnProperty,enumerable:!1,writable:!0,configurable:!0});function r(l,d,f,m){return p.isPlainObject(l)&&p.isPlainObject(d)?p.merge.call({caseless:m},l,d):p.isPlainObject(d)?p.merge({},d):p.isArray(d)?d.slice():d}function o(l,d,f,m){if(p.isUndefined(d)){if(!p.isUndefined(l))return r(void 0,l,f,m)}else return r(l,d,f,m)}function i(l,d){if(!p.isUndefined(d))return r(void 0,d)}function s(l,d){if(p.isUndefined(d)){if(!p.isUndefined(l))return r(void 0,l)}else return r(void 0,d)}function a(l){let d=p.hasOwnProp(t,"transitional")?t.transitional:void 0;if(!p.isUndefined(d))if(p.isPlainObject(d)){if(p.hasOwnProp(d,l))return d[l]}else return;let f=p.hasOwnProp(e,"transitional")?e.transitional:void 0;if(p.isPlainObject(f)&&p.hasOwnProp(f,l))return f[l]}function c(l,d,f){if(p.hasOwnProp(t,f))return r(l,d);if(p.hasOwnProp(e,f))return r(void 0,l)}let u={url:i,method:i,data:i,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutErrorMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,allowedSocketPaths:s,responseEncoding:s,validateStatus:c,headers:(l,d,f)=>o(kd(l),kd(d),f,!0)};return p.forEach(my({...e,...t}),function(d){if(d==="__proto__"||d==="constructor"||d==="prototype")return;let f=p.hasOwnProp(u,d)?u[d]:o,m=p.hasOwnProp(e,d)?e[d]:void 0,w=p.hasOwnProp(t,d)?t[d]:void 0,b=f(m,w,d);p.isUndefined(b)&&f!==c||(n[d]=b)}),p.hasOwnProp(t,"validateStatus")&&p.isUndefined(t.validateStatus)&&a("validateStatusUndefinedResolves")===!1&&(p.hasOwnProp(e,"validateStatus")?n.validateStatus=r(void 0,e.validateStatus):delete n.validateStatus),n}var gy=["content-type","content-length"];function Fs(e,t,n){if(n!=="content-only"){e.set(t);return}Object.entries(t||{}).forEach(([r,o])=>{gy.includes(r.toLowerCase())&&e.set(r,o)})}var yy=e=>encodeURIComponent(e).replace(/%([0-9A-F]{2})/gi,(t,n)=>String.fromCharCode(parseInt(n,16)));function wy(e){let t=Ne({},e),n=f=>p.hasOwnProp(t,f)?t[f]:void 0,r=n("data"),o=n("withXSRFToken"),i=n("xsrfHeaderName"),s=n("xsrfCookieName"),a=n("headers"),c=n("auth"),u=n("baseURL"),l=n("allowAbsoluteUrls"),d=n("url");if(t.headers=a=Q.from(a),t.url=yr(Ar(u,d,l,t),n("params"),n("paramsSerializer")),c){let f=p.getSafeProp(c,"username")||"",m=p.getSafeProp(c,"password")||"";try{a.set("Authorization","Basic "+btoa(f+":"+(m?yy(m):"")))}catch(w){throw P.from(w,P.ERR_BAD_OPTION_VALUE,e)}}if(p.isFormData(r)){let f=p.getSafeProp(r,"getHeaders");W.hasStandardBrowserEnv||W.hasStandardBrowserWebWorkerEnv||p.isReactNative(r)?a.setContentType(void 0):p.isFunction(f)&&Fs(a,f.call(r),n("formDataHeaderPolicy"))}if(W.hasStandardBrowserEnv&&(p.isFunction(o)&&(o=o(t)),o===!0||o==null&&Pd(t.url))){let m=i&&s&&Td.read(s);m&&a.set(i,m)}return t}var Co=wy;var _y=typeof XMLHttpRequest<"u",Id=_y&&function(e){return new Promise(function(n,r){let o=Co(e),i=o.data,s=Q.from(o.headers).normalize(),{responseType:a,onUploadProgress:c,onDownloadProgress:u}=o,l,d,f,m,w,b;function S(){m&&m(),w&&w(),o.cancelToken&&o.cancelToken.unsubscribe(l),o.signal&&o.signal.removeEventListener("abort",l)}let h=new XMLHttpRequest;h.open(o.method.toUpperCase(),o.url,!0),h.timeout=o.timeout;function _(E){if(!h)return;if(h.status===0&&(Sr(vr(o.url))||Sr(W.origin))!=="file"&&!(h.responseURL&&h.responseURL.startsWith("file:"))){r(new P("Request aborted",P.ECONNABORTED,e,h)),S(),h=null;return}try{E?b&&b(E):w&&w()}catch(U){setTimeout(()=>{throw U})}if(!h)return;let A=Q.from("getAllResponseHeaders"in h&&h.getAllResponseHeaders()),I={data:!a||a==="text"||a==="json"?h.responseText:h.response,status:h.status,statusText:h.statusText,headers:A,config:e,request:h};Er(function(V){n(V),S()},function(V){r(V),S()},I),h=null}"onloadend"in h?h.onloadend=_:h.onreadystatechange=function(){!h||h.readyState!==4||h.status===0&&!(h.responseURL&&h.responseURL.startsWith("file:"))||setTimeout(_)},h.onabort=function(){h&&(r(new P("Request aborted",P.ECONNABORTED,e,h)),S(),h=null)},h.onerror=function(A){let k=A&&A.message?A.message:"Network Error",I=new P(k,P.ERR_NETWORK,e,h);I.event=A||null,r(I),S(),h=null},h.ontimeout=function(){let A=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded",k=o.transitional||En;o.timeoutErrorMessage&&(A=o.timeoutErrorMessage),r(new P(A,k.clarifyTimeoutError?P.ETIMEDOUT:P.ECONNABORTED,e,h)),S(),h=null},i===void 0&&s.setContentType(null),"setRequestHeader"in h&&p.forEach(Oo(s),function(A,k){h.setRequestHeader(k,A)}),p.isUndefined(o.withCredentials)||(h.withCredentials=!!o.withCredentials),a&&a!=="json"&&(h.responseType=o.responseType),u&&([f,w,b]=An(u,!0),h.addEventListener("progress",f)),c&&h.upload&&([d,m]=An(c),h.upload.addEventListener("progress",d),h.upload.addEventListener("loadend",m)),(o.cancelToken||o.signal)&&(l=E=>{h&&(r(!E||E.type?new Ke(null,e,h):E),h.abort(),S(),h=null)},o.cancelToken&&o.cancelToken.subscribe(l),o.signal&&(o.signal.aborted?l():o.signal.addEventListener("abort",l)));let x=Sr(o.url);if(x&&!W.protocols.includes(x)){r(new P("Unsupported protocol "+x+":",P.ERR_BAD_REQUEST,e)),S();return}h.send(i||null)})};var by=(e,t)=>{if(e=e?e.filter(Boolean):[],!t&&!e.length)return;let n=new AbortController,r=!1,o=function(c){if(!r){r=!0,s();let u=c instanceof Error?c:this.reason;n.abort(u instanceof P?u:new Ke(u instanceof Error?u.message:u))}},i=t&&setTimeout(()=>{i=null,o(new P(`timeout of ${t}ms exceeded`,P.ETIMEDOUT))},t),s=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(c=>{c.unsubscribe?c.unsubscribe(o):c.removeEventListener("abort",o)}),e=null)};e.forEach(c=>{if(!r){if(c.aborted){o.call(c);return}c.addEventListener("abort",o,{once:!0})}});let{signal:a}=n;return a.unsubscribe=()=>p.asap(s),a},zd=by;var xy=function*(e,t){let n=e.byteLength;if(!t||n<t){yield e;return}let r=0,o;for(;r<n;)o=r+t,yield e.slice(r,o),r=o},Ey=async function*(e,t){for await(let n of vy(e))yield*xy(n,t)},vy=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}let t=e.getReader();try{for(;;){let{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},Hs=(e,t,n,r)=>{let o=Ey(e,t),i=0,s,a=c=>{s||(s=!0,r&&r(c))};return new ReadableStream({async pull(c){try{let{done:u,value:l}=await o.next();if(u){a(),c.close();return}let d=l.byteLength;if(n){let f=i+=d;n(f)}c.enqueue(new Uint8Array(l))}catch(u){throw a(u),u}},cancel(c){return a(c),o.return()}},{highWaterMark:2})};var $d=e=>e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102,Dd=(e,t,n)=>t+2<n&&$d(e.charCodeAt(t+1))&&$d(e.charCodeAt(t+2)),Cd=e=>e<=57?e-48:(e&223)-55,Sy=e=>e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===43||e===47||e===45||e===95,Ay=e=>e===9||e===10||e===12||e===13||e===32,Ry=e=>{let t=Math.floor(e/4),n=e%4;return t*3+(n===2?1:n===3?2:0)},Py=e=>{let t=e.length,n=0;return t>0&&e.charCodeAt(t-1)===61&&(n++,t>1&&e.charCodeAt(t-2)===61&&n++),Math.floor((t-n)*3/4)},Ty=e=>{let t=e.length,n=0,r=0,o=!1;for(let i=0;i<t;i++){let s=e.charCodeAt(i);if(s===37&&Dd(e,i,t)&&(s=Cd(e.charCodeAt(i+1))*16+Cd(e.charCodeAt(i+2)),i+=2),!Ay(s)){if(s===61){r++;continue}if(!Sy(s)||r>0){o=!0;continue}n++}}return o||r>2||r>0&&(n+r)%4!==0||n%4===1?Py(e):Ry(n)},Oy=(e,t)=>{if(!e||typeof e!="string"||!e.startsWith("data:"))return 0;let n=e.indexOf(",");if(n<0)return 0;let r=e.slice(5,n),o=e.slice(n+1);if(/;base64/i.test(r))return t(o);let s=0;for(let a=0,c=o.length;a<c;a++){let u=o.charCodeAt(a);if(u===37&&Dd(o,a,c))s+=1,a+=2;else if(u<128)s+=1;else if(u<2048)s+=2;else if(u>=55296&&u<=56319&&a+1<c){let l=o.charCodeAt(a+1);l>=56320&&l<=57343?(s+=4,a++):s+=3}else s+=3}return s};function Gs(e){let t=typeof e=="string"?e.indexOf("#"):-1;return Oy(t===-1?e:e.slice(0,t),Ty)}var Rn="1.20.0";var Ud=64*1024,ky={cache:"default",redirect:"follow",referrer:"about:client",referrerPolicy:"",mode:"cors",integrity:"",keepalive:!1,priority:"auto",window:null},{isFunction:Do}=p,Iy=e=>encodeURIComponent(e).replace(/%([0-9A-F]{2})/gi,(t,n)=>String.fromCharCode(parseInt(n,16))),Md=e=>{if(!p.isString(e))return e;try{return decodeURIComponent(e)}catch{return e}},Ld=(e,...t)=>{try{return!!e(...t)}catch{return!1}},zy=e=>{let t=e.indexOf("://"),n=e;return t!==-1&&(n=n.slice(t+3)),n.includes("@")||n.includes(":")},$y=e=>{let t=p.global!==void 0&&p.global!==null?p.global:globalThis,{ReadableStream:n,TextEncoder:r}=t;e=p.merge.call({skipUndefined:!0},{Request:t.Request,Response:t.Response},e);let{fetch:o,Request:i,Response:s}=e,a=o?Do(o):typeof fetch=="function",c=Do(i),u=Do(s);if(!a)return!1;let l=a&&Do(n),d=a&&(typeof r=="function"?(h=>_=>h.encode(_))(new r):async h=>new Uint8Array(await new i(h).arrayBuffer())),f=c&&l&&Ld(()=>{let h=!1,_=new i(W.origin,{body:new n,method:"POST",get duplex(){return h=!0,"half"}}),x=_.headers.has("Content-Type");return _.body!=null&&_.body.cancel(),h&&!x}),m=u&&l&&Ld(()=>p.isReadableStream(new s("").body)),w={stream:m&&(h=>h.body)};a&&["text","arrayBuffer","blob","formData","stream"].forEach(h=>{!w[h]&&(w[h]=(_,x)=>{let E=_&&_[h];if(E)return E.call(_);throw new P(`Response type '${h}' is not supported`,P.ERR_NOT_SUPPORT,x)})});let b=async h=>{if(h==null)return 0;if(p.isBlob(h))return h.size;if(p.isSpecCompliantForm(h))return(await new i(W.origin,{method:"POST",body:h}).arrayBuffer()).byteLength;if(p.isArrayBufferView(h)||p.isArrayBuffer(h))return h.byteLength;if(p.isURLSearchParams(h)&&(h=h+""),p.isString(h))return(await d(h)).byteLength},S=async(h,_)=>{let x=p.toFiniteNumber(h.getContentLength());return x??b(_)};return async h=>{let{url:_,method:x,data:E,signal:A,cancelToken:k,timeout:I,onDownloadProgress:U,onUploadProgress:V,responseType:G,headers:g,withCredentials:v="same-origin",fetchOptions:D,maxContentLength:M,maxBodyLength:L,maxRedirects:B}=Co(h),je=p.isNumber(M)&&M>-1,Rt=p.isNumber(L)&&L>-1,qr=q=>p.hasOwnProp(h,q)?h[q]:void 0,ee=o||fetch;G=G?(G+"").toLowerCase():"text";let le=zd([A,k&&k.toAbortSignal()],I),ce=null,Pt=le&&le.unsubscribe&&(()=>{le.unsubscribe()}),en,jn=null,ec=()=>new P("Request body larger than maxBodyLength limit",P.ERR_BAD_REQUEST,h,ce);try{let q,ke=qr("auth");if(ke){let N=p.getSafeProp(ke,"username")||"",de=p.getSafeProp(ke,"password")||"";q={username:N,password:de}}if(zy(_)){let N=new URL(_,W.origin);if(!q&&(N.username||N.password)){let de=Md(N.username),ft=Md(N.password);q={username:de,password:ft}}(N.username||N.password)&&(N.username="",N.password="",_=N.href)}if(q&&(g.delete("authorization"),g.set("Authorization","Basic "+btoa(Iy((q.username||"")+":"+(q.password||""))))),je&&typeof _=="string"&&_.startsWith("data:")&&Gs(_)>M)throw new P("maxContentLength size of "+M+" exceeded",P.ERR_BAD_RESPONSE,h,ce);if(Rt&&x!=="get"&&x!=="head"){let N=await b(E);if(typeof N=="number"&&isFinite(N)&&(en=N,N>L))throw ec()}let Jr=Rt&&(p.isReadableStream(E)||p.isStream(E)),tc=(N,de,ft)=>Hs(N,Ud,Tt=>{if(Rt&&Tt>L)throw jn=ec();de&&de(Tt)},ft);if(f&&x!=="get"&&x!=="head"&&(V||Jr)){if(en=en??await S(g,E),en!==0||Jr){let N=new i(_,{method:"POST",body:E,duplex:"half"}),de;if(p.isFormData(E)&&(de=N.headers.get("content-type"))&&g.setContentType(de),N.body){let[ft,Tt]=V&&Ns(en,An(Bs(V)))||[];E=tc(N.body,ft,Tt)}}}else if(Jr&&!c&&l&&x!=="get"&&x!=="head")E=tc(E);else if(Jr&&c&&!f&&x!=="get"&&x!=="head")throw new P("Stream request bodies are not supported by the current fetch implementation",P.ERR_NOT_SUPPORT,h,ce);p.isString(v)||(v=v?"include":"omit");let mp=c&&"credentials"in i.prototype;if(p.isFormData(E)){let N=g.getContentType();N&&/^multipart\/form-data/i.test(N)&&!/boundary=/i.test(N)&&g.delete("content-type")}g.set("User-Agent","axios/"+Rn,!1);let De=D==null?D:Object.assign(Object.create(null),D);De&&(delete De.body,delete De.headers,delete De.method,delete De.signal,delete De.duplex,delete De.credentials);let et=Object.assign(Object.create(null),De,{signal:le,method:x.toUpperCase(),headers:Oo(g.normalize()),body:E,duplex:"half",credentials:mp?v:void 0});c&&(p.forEach(ky,(N,de)=>{et[de]===void 0&&(et[de]=N)}),et.signal===void 0&&(et.signal=null),et.body===void 0&&(et.body=null)),B===0&&(et.redirect="manual",De&&(De.redirect="manual")),ce=c&&new i(_,et);let tt=await(c?ee(ce,De):ee(_,et)),nc=Q.from(tt.headers);if(je){let N=p.toFiniteNumber(nc.getContentLength());if(N!=null&&N>M)throw new P("maxContentLength size of "+M+" exceeded",P.ERR_BAD_RESPONSE,h,ce)}let Ci=m&&(G==="stream"||G==="response");if(m&&tt.body&&(U||je||Ci&&Pt)){let N={};["status","statusText","headers"].forEach(Zn=>{N[Zn]=tt[Zn]});let de=p.toFiniteNumber(nc.getContentLength()),[ft,Tt]=U&&Ns(de,An(Bs(U),!0))||[],rc=0,gp=Zn=>{if(je&&(rc=Zn,rc>M))throw new P("maxContentLength size of "+M+" exceeded",P.ERR_BAD_RESPONSE,h,ce);ft&&ft(Zn)};tt=new s(Hs(tt.body,Ud,gp,()=>{Tt&&Tt(),Pt&&Pt()}),N)}G=G||"text";let nt=await w[p.findKey(w,G)||"text"](tt,h);if(je&&!m&&!Ci){let N;if(nt!=null&&(typeof nt.byteLength=="number"?N=nt.byteLength:typeof nt.size=="number"?N=nt.size:typeof nt=="string"&&(N=typeof r=="function"?new r().encode(nt).byteLength:nt.length)),typeof N=="number"&&N>M)throw new P("maxContentLength size of "+M+" exceeded",P.ERR_BAD_RESPONSE,h,ce)}return!Ci&&Pt&&Pt(),await new Promise((N,de)=>{Er(N,de,{data:nt,headers:Q.from(tt.headers),status:tt.status,statusText:tt.statusText,config:h,request:ce})})}catch(q){if(Pt&&Pt(),le&&le.aborted&&le.reason instanceof P){let ke=le.reason;throw ke.config=h,ce&&(ke.request=ce),q!==ke&&Object.defineProperty(ke,"cause",{__proto__:null,value:q,writable:!0,enumerable:!1,configurable:!0}),ke}if(jn)throw ce&&!jn.request&&(jn.request=ce),jn;if(q instanceof P)throw ce&&!q.request&&(q.request=ce),q;if(q&&q.name==="TypeError"&&/Load failed|fetch/i.test(q.message)){let ke=new P("Network Error",P.ERR_NETWORK,h,ce,q&&q.response);throw Object.defineProperty(ke,"cause",{__proto__:null,value:q.cause||q,writable:!0,enumerable:!1,configurable:!0}),ke}throw P.from(q,q&&q.code,h,ce,q&&q.response)}}},Cy=new Map,qs=e=>{let t=e&&e.env||{},{fetch:n,Request:r,Response:o}=t,i=[r,o,n],s=i.length,a=s,c,u,l=Cy;for(;a--;)c=i[a],u=l.get(c),u===void 0&&l.set(c,u=a?new Map:$y(t)),l=u;return u},jR=qs();var Js={http:bt,xhr:Id,fetch:{get:qs}};p.forEach(Js,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{__proto__:null,value:t})}catch{}Object.defineProperty(e,"adapterName",{__proto__:null,value:t})}});var Nd=e=>`- ${e}`,Uy=e=>p.isFunction(e)||e===null||e===!1;function My(e,t){e=p.isArray(e)?e:[e];let{length:n}=e,r,o,i={};for(let s=0;s<n;s++){r=e[s];let a;if(o=r,!Uy(r)&&(o=Js[(a=String(r)).toLowerCase()],o===void 0))throw new P(`Unknown adapter '${a}'`);if(o&&(p.isFunction(o)||(o=o.get(t))))break;i[a||"#"+s]=o}if(!o){let s=Object.entries(i).map(([c,u])=>`adapter ${c} `+(u===!1?"is not supported by the environment":"is not available in the build")),a=n?s.length>1?`since :
|
|
5
|
-
`+s.map(
|
|
6
|
-
`):" "+
|
|
1
|
+
import{a as wp,b as _p,c as bp}from"./chunk-O4MIY67H.js";var Jf=wp((vt,qf)=>{var Bo=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof global<"u"&&global,jo=(function(){function e(){this.fetch=!1,this.DOMException=Bo.DOMException}return e.prototype=Bo,new e})();(function(e){var t=(function(n){var r=typeof e<"u"&&e||typeof self<"u"&&self||typeof global<"u"&&global||{},o={searchParams:"URLSearchParams"in r,iterable:"Symbol"in r&&"iterator"in Symbol,blob:"FileReader"in r&&"Blob"in r&&(function(){try{return new Blob,!0}catch{return!1}})(),formData:"FormData"in r,arrayBuffer:"ArrayBuffer"in r};function i(g){return g&&DataView.prototype.isPrototypeOf(g)}if(o.arrayBuffer)var s=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],a=ArrayBuffer.isView||function(g){return g&&s.indexOf(Object.prototype.toString.call(g))>-1};function c(g){if(typeof g!="string"&&(g=String(g)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(g)||g==="")throw new TypeError('Invalid character in header field name: "'+g+'"');return g.toLowerCase()}function u(g){return typeof g!="string"&&(g=String(g)),g}function l(g){var v={next:function(){var D=g.shift();return{done:D===void 0,value:D}}};return o.iterable&&(v[Symbol.iterator]=function(){return v}),v}function f(g){this.map={},g instanceof f?g.forEach(function(v,D){this.append(D,v)},this):Array.isArray(g)?g.forEach(function(v){if(v.length!=2)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+v.length);this.append(v[0],v[1])},this):g&&Object.getOwnPropertyNames(g).forEach(function(v){this.append(v,g[v])},this)}f.prototype.append=function(g,v){g=c(g),v=u(v);var D=this.map[g];this.map[g]=D?D+", "+v:v},f.prototype.delete=function(g){delete this.map[c(g)]},f.prototype.get=function(g){return g=c(g),this.has(g)?this.map[g]:null},f.prototype.has=function(g){return this.map.hasOwnProperty(c(g))},f.prototype.set=function(g,v){this.map[c(g)]=u(v)},f.prototype.forEach=function(g,v){for(var D in this.map)this.map.hasOwnProperty(D)&&g.call(v,this.map[D],D,this)},f.prototype.keys=function(){var g=[];return this.forEach(function(v,D){g.push(D)}),l(g)},f.prototype.values=function(){var g=[];return this.forEach(function(v){g.push(v)}),l(g)},f.prototype.entries=function(){var g=[];return this.forEach(function(v,D){g.push([D,v])}),l(g)},o.iterable&&(f.prototype[Symbol.iterator]=f.prototype.entries);function d(g){if(!g._noBody){if(g.bodyUsed)return Promise.reject(new TypeError("Already read"));g.bodyUsed=!0}}function m(g){return new Promise(function(v,D){g.onload=function(){v(g.result)},g.onerror=function(){D(g.error)}})}function w(g){var v=new FileReader,D=m(v);return v.readAsArrayBuffer(g),D}function b(g){var v=new FileReader,D=m(v),M=/charset=([A-Za-z0-9_-]+)/.exec(g.type),L=M?M[1]:"utf-8";return v.readAsText(g,L),D}function S(g){for(var v=new Uint8Array(g),D=new Array(v.length),M=0;M<v.length;M++)D[M]=String.fromCharCode(v[M]);return D.join("")}function h(g){if(g.slice)return g.slice(0);var v=new Uint8Array(g.byteLength);return v.set(new Uint8Array(g)),v.buffer}function _(){return this.bodyUsed=!1,this._initBody=function(g){this.bodyUsed=this.bodyUsed,this._bodyInit=g,g?typeof g=="string"?this._bodyText=g:o.blob&&Blob.prototype.isPrototypeOf(g)?this._bodyBlob=g:o.formData&&FormData.prototype.isPrototypeOf(g)?this._bodyFormData=g:o.searchParams&&URLSearchParams.prototype.isPrototypeOf(g)?this._bodyText=g.toString():o.arrayBuffer&&o.blob&&i(g)?(this._bodyArrayBuffer=h(g.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):o.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(g)||a(g))?this._bodyArrayBuffer=h(g):this._bodyText=g=Object.prototype.toString.call(g):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||(typeof g=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):o.searchParams&&URLSearchParams.prototype.isPrototypeOf(g)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},o.blob&&(this.blob=function(){var g=d(this);if(g)return g;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer){var g=d(this);return g||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}else{if(o.blob)return this.blob().then(w);throw new Error("could not read as ArrayBuffer")}},this.text=function(){var g=d(this);if(g)return g;if(this._bodyBlob)return b(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(S(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},o.formData&&(this.formData=function(){return this.text().then(k)}),this.json=function(){return this.text().then(JSON.parse)},this}var x=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function E(g){var v=g.toUpperCase();return x.indexOf(v)>-1?v:g}function A(g,v){if(!(this instanceof A))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');v=v||{};var D=v.body;if(g instanceof A){if(g.bodyUsed)throw new TypeError("Already read");this.url=g.url,this.credentials=g.credentials,v.headers||(this.headers=new f(g.headers)),this.method=g.method,this.mode=g.mode,this.signal=g.signal,!D&&g._bodyInit!=null&&(D=g._bodyInit,g.bodyUsed=!0)}else this.url=String(g);if(this.credentials=v.credentials||this.credentials||"same-origin",(v.headers||!this.headers)&&(this.headers=new f(v.headers)),this.method=E(v.method||this.method||"GET"),this.mode=v.mode||this.mode||null,this.signal=v.signal||this.signal||(function(){if("AbortController"in r){var B=new AbortController;return B.signal}})(),this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&D)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(D),(this.method==="GET"||this.method==="HEAD")&&(v.cache==="no-store"||v.cache==="no-cache")){var M=/([?&])_=[^&]*/;if(M.test(this.url))this.url=this.url.replace(M,"$1_="+new Date().getTime());else{var L=/\?/;this.url+=(L.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}A.prototype.clone=function(){return new A(this,{body:this._bodyInit})};function k(g){var v=new FormData;return g.trim().split("&").forEach(function(D){if(D){var M=D.split("="),L=M.shift().replace(/\+/g," "),B=M.join("=").replace(/\+/g," ");v.append(decodeURIComponent(L),decodeURIComponent(B))}}),v}function I(g){var v=new f,D=g.replace(/\r?\n[\t ]+/g," ");return D.split("\r").map(function(M){return M.indexOf(`
|
|
2
|
+
`)===0?M.substr(1,M.length):M}).forEach(function(M){var L=M.split(":"),B=L.shift().trim();if(B){var Ze=L.join(":").trim();try{v.append(B,Ze)}catch(Tt){console.warn("Response "+Tt.message)}}}),v}_.call(A.prototype);function U(g,v){if(!(this instanceof U))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(v||(v={}),this.type="default",this.status=v.status===void 0?200:v.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=v.statusText===void 0?"":""+v.statusText,this.headers=new f(v.headers),this.url=v.url||"",this._initBody(g)}_.call(U.prototype),U.prototype.clone=function(){return new U(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},U.error=function(){var g=new U(null,{status:200,statusText:""});return g.ok=!1,g.status=0,g.type="error",g};var V=[301,302,303,307,308];U.redirect=function(g,v){if(V.indexOf(v)===-1)throw new RangeError("Invalid status code");return new U(null,{status:v,headers:{location:g}})},n.DOMException=r.DOMException;try{new n.DOMException}catch{n.DOMException=function(v,D){this.message=v,this.name=D;var M=Error(v);this.stack=M.stack},n.DOMException.prototype=Object.create(Error.prototype),n.DOMException.prototype.constructor=n.DOMException}function G(g,v){return new Promise(function(D,M){var L=new A(g,v);if(L.signal&&L.signal.aborted)return M(new n.DOMException("Aborted","AbortError"));var B=new XMLHttpRequest;function Ze(){B.abort()}B.onload=function(){var te={statusText:B.statusText,headers:I(B.getAllResponseHeaders()||"")};L.url.indexOf("file://")===0&&(B.status<200||B.status>599)?te.status=200:te.status=B.status,te.url="responseURL"in B?B.responseURL:te.headers.get("X-Request-URL");var le="response"in B?B.response:B.responseText;setTimeout(function(){D(new U(le,te))},0)},B.onerror=function(){setTimeout(function(){M(new TypeError("Network request failed"))},0)},B.ontimeout=function(){setTimeout(function(){M(new TypeError("Network request timed out"))},0)},B.onabort=function(){setTimeout(function(){M(new n.DOMException("Aborted","AbortError"))},0)};function Tt(te){try{return te===""&&r.location.href?r.location.href:te}catch{return te}}if(B.open(L.method,Tt(L.url),!0),L.credentials==="include"?B.withCredentials=!0:L.credentials==="omit"&&(B.withCredentials=!1),"responseType"in B&&(o.blob?B.responseType="blob":o.arrayBuffer&&(B.responseType="arraybuffer")),v&&typeof v.headers=="object"&&!(v.headers instanceof f||r.Headers&&v.headers instanceof r.Headers)){var qr=[];Object.getOwnPropertyNames(v.headers).forEach(function(te){qr.push(c(te)),B.setRequestHeader(te,u(v.headers[te]))}),L.headers.forEach(function(te,le){qr.indexOf(le)===-1&&B.setRequestHeader(le,te)})}else L.headers.forEach(function(te,le){B.setRequestHeader(le,te)});L.signal&&(L.signal.addEventListener("abort",Ze),B.onreadystatechange=function(){B.readyState===4&&L.signal.removeEventListener("abort",Ze)}),B.send(typeof L._bodyInit>"u"?null:L._bodyInit)})}return G.polyfill=!0,r.fetch||(r.fetch=G,r.Headers=f,r.Request=A,r.Response=U),n.Headers=f,n.Request=A,n.Response=U,n.fetch=G,n})({})})(jo);jo.fetch.ponyfill=!0;delete jo.fetch.polyfill;var On=Bo.fetch?Bo:jo;vt=On.fetch;vt.default=On.fetch;vt.fetch=On.fetch;vt.Headers=On.Headers;vt.Request=On.Request;vt.Response=On.Response;qf.exports=vt});function oc(e){let t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function ic(e,t){return typeof t=="bigint"?t.toString():t}function sc(e){return{get value(){{let n=e();return Object.defineProperty(this,"value",{value:n}),n}throw new Error("cached value already set")}}}function Vr(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Ui(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function xp(...e){let t={};for(let n of e){let r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}var Mi="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Kr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Hn(e){if(Kr(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let n=t.prototype;return!(Kr(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}var ac=new Set(["string","number","symbol"]);function Li(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Gn(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function ne(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function cc(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var uc={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 lc(e,t){if(!Hn(t))throw new Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let i=e._zod.def.shape;for(let s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(i,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let o=xp(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t};return Ui(this,"shape",i),i}});return Gn(e,o)}function It(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function fc(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Fe(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function Fn(e){return typeof e=="string"?e:e?.message}function Ni(e,t,n){var r;for(let o=t;o<e.length;o++)(r=e[o]).schema??(r.schema=n)}function rt(e,t,n){var r;let o=e.inst?._zod?.traits;o?.has("$ZodType")&&(o.has("$ZodCheck")?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let i=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,s=e.message?e.message:Fn(e.inst?._zod.def?.error?.(e))??Fn(i?.(e))??Fn(t?.error?.(e))??Fn(n.customError?.(e))??Fn(n.localeError?.(e))??"Invalid input",{inst:a,schema:c,continue:u,input:l,...f}=e;return f.path??(f.path=[]),f.message=s,t?.reportInput&&(f.input=l),f}function Bi(...e){let[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}function dc(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):Ep(e,n,r.value)}}function kt(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function pc(e,t,n){return kt(e,t,n,!1)}function Ep(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:kt(this,t,n.bind(this))},set(r){kt(this,t,r)}})}function vp(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var Di,pt=!1,Sp={configurable:!0,get(){pt=!0}};function be(e,t,n){let r=Object.getPrototypeOf(e._zod);if(t in r&&Di!==e._zod){Di=void 0;return}Di=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,Sp);let o=pt;pt=!1;try{let i=n(this);return pt?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i}),pt=pt||o,i}catch(i){throw delete this[t],pt=pt||o,i}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function hc(e,t,n,r){let o=vp(e,t);o&&Object.defineProperty(o,t,{configurable:!0,get(){let i={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,i),i.value=n(this),Object.defineProperty(this,t,i),i.value},set(i){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:i})}})}var mc;var ji={value:void 0,enumerable:!1},gc="captureStackTrace"in Error?Error:null;function Ap(e){let t=gc;if(t){let n=t.stackTraceLimit;if(typeof n=="number"){try{t.stackTraceLimit=0}catch{return gc=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function C(e,t,n,r){let o={};function i(d){this.def=d,this.constr=f,this.traits=new Set}i.prototype=o;let s=n,a=s&&new WeakSet;function c(d,m){if(!d._zod){ji.value=new i(m);try{Object.defineProperty(d,"_zod",ji)}finally{ji.value=void 0}}if(d._zod.traits.has(e))return;if(d._zod.traits.add(e),t(d,m),a){let b=Object.getPrototypeOf(d),S=d._zod.constr.prototype,h=b;for(;h&&h!==S;)h=Object.getPrototypeOf(h);let _=h??b;a.has(_)||(a.add(_),dc(_,s))}let w=f.prototype;for(let b in w)Object.prototype.hasOwnProperty.call(w,b)&&(b in d||(d[b]=w[b].bind(d)))}let u=r?.Parent??Object;class l extends u{}Object.defineProperty(l,"name",{value:e});function f(d){let m=r?.Parent?Ap(l):this;c(m,d);let w=m._zod.deferred;if(w){for(let S of w)S();m._zod.deferred=void 0}let b=globalThis.__zod_globalConfig?.postProcessor;return b&&b(m),m}return Object.defineProperty(f,"init",{value:c}),Object.defineProperty(f,Symbol.hasInstance,{value:d=>r?.Parent&&d instanceof r.Parent?!0:d?._zod?.traits?.has(e)}),Object.defineProperty(f,"name",{value:e}),f}var ot=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};(mc=globalThis).__zod_globalConfig??(mc.__zod_globalConfig={});var Ct=globalThis.__zod_globalConfig;function it(e){return e&&Object.assign(Ct,e),Ct}function Rp(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,ic,2)),e.message}function Tp(e){this._zod.message=e}var Pp={get:Rp,set:Tp,enumerable:!0,configurable:!0},Fi={value:void 0,enumerable:!1},Hi={value:void 0,enumerable:!1},yc=new WeakSet([Object.prototype,Error.prototype]),wc=(e,t)=>{e.name="$ZodError",Fi.value=e._zod,Object.defineProperty(e,"_zod",Fi),Hi.value=t,Object.defineProperty(e,"issues",Hi),Fi.value=void 0,Hi.value=void 0,Object.defineProperty(e,"message",Pp);let n=Object.getPrototypeOf(e);yc.has(n)||(yc.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let r=()=>this.message;return Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0})}}))},_c=C("$ZodError",wc),qn=C("$ZodError",wc,void 0,{Parent:Error});var kp=e=>{let t=(n,r,o,i)=>{let s=o?{...o,async:!1}:{async:!1},a=n._zod.run({value:r,issues:[]},s);if(a instanceof Promise)throw new ot;if(a.issues.length){let c=new(i?.Err??e)(a.issues.map(u=>rt(u,s,it())));throw Mi(c,i?.callee??t),c}return a.value};return t},Wr=kp(qn),Ip=e=>{let t=async(n,r,o,i)=>{let s=o?{...o,async:!0}:{async:!0},a=n._zod.run({value:r,issues:[]},s);if(a instanceof Promise&&(a=await a),a.issues.length){let c=new(i?.Err??e)(a.issues.map(u=>rt(u,s,it())));throw Mi(c,i?.callee??t),c}return a.value};return t},Xr=Ip(qn),zp=e=>(t,n,r)=>{let o=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new ot;return i.issues.length?{success:!1,error:new(e??_c)(i.issues.map(s=>rt(s,o,it())))}:{success:!0,data:i.value}},Jn=zp(qn),Cp=e=>async(t,n,r)=>{let o=r?{...r,async:!0}:{async:!0},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(s=>rt(s,o,it())))}:{success:!0,data:i.value}},Kn=Cp(qn);var bc=/^https?$/;var xc=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var Ec=/^-?\d+$/,Gi=/^-?\d+(?:\.\d+)?$/,vc=/^(?:true|false)$/i;var Sc=/^undefined$/i;var $t=C("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])});var Ac={number:"number",bigint:"bigint",object:"date"};var Rc=C("$ZodCheckGreaterThan",(e,t)=>{$t.init(e,t);let n=Ac[typeof t.value];e._zod.onattach.push(r=>{let o=r._zod.bag,i=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:Ac[typeof r.value]??n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}});var Tc=C("$ZodCheckNumberFormat",(e,t)=>{$t.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),r=n?"int":"number",[o,i]=uc[t.format];e._zod.onattach.push(s=>{let a=s._zod.bag;a.format=t.format,a.minimum=o,a.maximum=i,n&&(a.pattern=Ec)}),e._zod.check=s=>{let a=s.value;if(n){if(!Number.isInteger(a)){s.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){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});return}}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})}});var Pc=C("$ZodCheckStringFormat",(e,t)=>{var n,r;$t.init(e,t),e._zod.onattach.push(o=>{let i=o._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})});var kc={major:4,minor:5,patch:4};var oe=C("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=kc;let r=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...r??[]]:r?.length?[...r]:[];for(let i of o)for(let s of i._zod.onattach)s(e);if(o.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let i=(a,c,u)=>{if(a.memo)return a;let l=It(a),f;for(let d of c){if(d._zod.def.when){if(fc(a)||!d._zod.def.when(a))continue}else if(l)continue;let m=a.issues.length,w=d._zod.check(a);if(w instanceof Promise&&u?.async===!1)throw new ot;if(f||w instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await w,a.issues.length!==m&&(Ni(a.issues,m,e),l||(l=It(a,m)))});else{if(a.issues.length===m)continue;Ni(a.issues,m,e),l||(l=It(a,m))}}return f?f.then(()=>a):a},s=(a,c,u)=>{if(It(a))return a.aborted=!0,a;let l=i(c,o,u);if(l instanceof Promise){if(u.async===!1)throw new ot;return l.then(f=>e._zod.parse(f,u))}return e._zod.parse(l,u)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let l=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return l instanceof Promise?l.then(f=>s(f,a,c)):s(l,a,c)}let u=e._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new ot;return u.then(l=>i(l,o,c))}return i(u,o,c)}}},{get"~standard"(){return pc(this,"~standard",$p(this))},set"~standard"(e){kt(this,"~standard",e)}}),Ic=e=>e.success?{value:e.data}:{issues:e.error?.issues};function $p(e){return{validate:t=>{try{return Ic(Jn(e,t))}catch{return Kn(e,t).then(Ic)}},vendor:"zod",version:1}}var Ki=C("$ZodString",(e,t)=>{oe.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??xc(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),Vi=C("$ZodStringFormat",(e,t)=>{Pc.init(e,t),Ki.init(e,t)});var jc=1,Zc=2;function Dp(e,t){if(!t.normalize&&t.protocol?.source===bc.source&&!/^https?:\/\//i.test(e))return jc;try{return new URL(e)}catch{return Zc}}var Up=/[\t\n\r]/g;function Mp(e){return e.replace(Up,"")}function Lp(e,t){return t.lastIndex=0,t.test(e.hostname)}function Np(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var Fc=C("$ZodURL",(e,t)=>{Vi.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),o=Dp(r,t);if(o===jc){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(o===Zc){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}t.hostname&&!Lp(o,t.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&&!Np(o,t.protocol)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?o.href:Mp(r);return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}});var Wi=C("$ZodNumber",(e,t)=>{oe.init(e,t),e._zod.pattern=e._zod.bag.pattern??Gi,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let o=n.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;let i=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:String(o):void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),n}}),Hc=C("$ZodNumberFormat",(e,t)=>{Tc.init(e,t),Wi.init(e,t)}),Gc=C("$ZodBoolean",(e,t)=>{oe.init(e,t),e._zod.pattern=vc,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let o=n.value;return typeof o=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}});var qc=C("$ZodUndefined",(e,t)=>{oe.init(e,t),e._zod.pattern=Sc,e._zod.values=new Set([void 0]),e._zod.parse=(n,r)=>{let o=n.value;return typeof o>"u"||n.issues.push({expected:"undefined",code:"invalid_type",input:o,inst:e}),n}});var Jc=C("$ZodUnknown",(e,t)=>{oe.init(e,t),e._zod.parse=n=>n}),Kc=C("$ZodNever",(e,t)=>{oe.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function zc(e,t,n){e.issues.length&&t.issues.push(...Fe(n,e.issues)),t.value[n]=e.value}var Vc=C("$ZodArray",(e,t)=>{oe.init(e,t);let n=Ct.memoizer;n?.attach(e),e._zod.parse=(r,o)=>{let i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),r;r.value=n?n.alloc(e,r,Array(i.length),o):Array(i.length);let s=[];for(let a=0;a<i.length;a++){let c=i[a],u=t.element._zod.run({value:c,issues:[]},o);u instanceof Promise?s.push(u.then(l=>zc(l,r,a))):zc(u,r,a)}return s.length?Promise.all(s).then(()=>r):r}});function Yr(e,t,n,r,o,i){let s=n in r,a=i==="optional";if(!(!s&&a&&o==="optional")){if(e.issues.length){if(o!==void 0&&a&&!s)return;t.issues.push(...Fe(n,e.issues))}if(!s&&o===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?s&&(t.value[n]=void 0):t.value[n]=e.value}}var Bp=[];function jp(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:Bp,o=r.length?[...t,...r]:t;for(let s of o)if(!e.shape?.[s]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(s)}": expected a Zod schema`);let i=cc(e.shape);return{...e,allKeys:o,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(i)}}function Zp(e,t,n,r,o,i){let s=[],a=o.keySet,c=o.catchall._zod,u=c.def.type,l=c.optin,f=c.optout;for(let d in t){if(a.has(d))continue;if(d==="__proto__"){u==="never"&&s.push(d);continue}if(u==="never"){s.push(d);continue}let m=c.run({value:t[d],issues:[]},r);m instanceof Promise?e.push(m.then(w=>Yr(w,n,d,t,l,f))):Yr(m,n,d,t,l,f)}return s.length&&n.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i,continue:!0}),e.length?Promise.all(e).then(()=>n):n}var Cc=new WeakMap,Wc=C("$ZodObject",(e,t)=>{if(oe.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let c=t.shape;Cc.set(t,c),Object.defineProperty(t,"shape",{get:()=>{let u={...c};return Object.defineProperty(t,"shape",{value:u}),Cc.set(t,u),u}})}let r=sc(()=>jp(t));be(e,"propValues",c=>{let u=c.def.shape,l={};for(let f in u){let d=u[f]._zod;if(d.values){Object.prototype.hasOwnProperty.call(l,f)||Ui(l,f,new Set);for(let m of d.values)l[f].add(m);d.optin!==void 0&&l[f].add(void 0)}}return l});let o=Kr,i=t.catchall,s,a=Ct.memoizer;a?.attach(e),e._zod.parse=(c,u)=>{s??(s=r.value);let l=c.value;if(!o(l))return c.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),c;c.value=a?a.alloc(e,c,{},u):{};let f=[],d=s.shape;for(let m of s.allKeys){if(m==="__proto__")continue;let w=d[m],b=w._zod.optin,S=w._zod.optout,h=w._zod.run({value:l[m],issues:[]},u);h instanceof Promise?f.push(h.then(_=>Yr(_,c,m,l,b,S))):Yr(h,c,m,l,b,S)}return i?Zp(f,l,c,u,r.value,e):f.length?Promise.all(f).then(()=>c):c}});function $c(e,t,n,r){for(let i of e)if(i.issues.length===0)return t.value=i.value,t;let o=e.filter(i=>!It(i));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(s=>rt(s,r,it())))}),t)}var Xc=C("$ZodUnion",(e,t)=>{oe.init(e,t),be(e,"optin",r=>r.def.options.some(o=>o._zod.optin==="defaulted")?"defaulted":r.def.options.some(o=>o._zod.optin!==void 0)?"optional":void 0),be(e,"optout",r=>r.def.options.some(o=>o._zod.optout==="optional")?"optional":void 0),be(e,"values",r=>{if(r.def.options.every(o=>o._zod.values))return new Set(r.def.options.flatMap(o=>Array.from(o._zod.values)))}),be(e,"pattern",r=>{if(r.def.options.every(o=>o._zod.pattern)){let o=r.def.options.map(i=>i._zod.pattern);return new RegExp(`^(${o.map(i=>Vr(i.source)).join("|")})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(n)return n(r,o);let i=!1,s=[];for(let a of t.options){let c=a._zod.run({value:r.value,issues:[]},o);if(c instanceof Promise)s.push(c),i=!0;else{if(c.issues.length===0)return c;s.push(c)}}return i?Promise.all(s).then(a=>$c(a,r,e,o)):$c(s,r,e,o)}});var Yc=C("$ZodIntersection",(e,t)=>{oe.init(e,t),e._zod.parse=(n,r)=>{let o=n.value,i=t.left._zod.run({value:o,issues:[]},r),s=t.right._zod.run({value:o,issues:[]},r);return i instanceof Promise||s instanceof Promise?Promise.all([i,s]).then(([c,u])=>Dc(n,c,u)):Dc(n,i,s)}});function Ji(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(Hn(e)&&Hn(t)){let n=Object.keys(t),r=Object.keys(e).filter(i=>n.indexOf(i)!==-1),o={...e,...t};Object.prototype.hasOwnProperty.call(o,"__proto__")&&delete o.__proto__;for(let i of r){if(i==="__proto__")continue;let s=Ji(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};o[i]=s.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let o=e[r],i=t[r],s=Ji(o,i);if(!s.valid)return{valid:!1,mergeErrorPath:[r,...s.mergeErrorPath]};n.push(s.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Dc(e,t,n){let r=new Map,o,i=new Map,s=(u,l)=>{let f;if(u.code==="unrecognized_keys"&&!u.path?.length)o??(o=u),f=u.keys;else if(u.code==="invalid_key"&&u.origin==="record"&&u.path?.length===1){let d=String(u.path[0]);i.has(d)||i.set(d,u),f=[d]}else return!1;for(let d of f)r.has(d)||r.set(d,{}),r.get(d)[l]=!0;return!0};for(let u of t.issues)s(u,"l")||e.issues.push(u);for(let u of n.issues)s(u,"r")||e.issues.push(u);let a=[...r].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(a.length){let u=o?a.filter(l=>o.keys.includes(l)):[];u.length&&e.issues.push({...o,keys:u});for(let l of a)!u.includes(l)&&i.has(l)&&e.issues.push(i.get(l))}let c=Ji(t.value,n.value);if(!c.valid){if(It(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Qc=C("$ZodTuple",(e,t)=>{oe.init(e,t);let n=t.items,r=Ct.memoizer;r?.attach(e),e._zod.parse=(o,i)=>{let s=o.value;if(!Array.isArray(s))return o.issues.push({input:s,inst:e,expected:"tuple",code:"invalid_type"}),o;o.value=r?r.alloc(e,o,[],i):[];let a=[],c=Uc(n,"optin"),u=Uc(n,"optout");if(!t.rest){if(s.length<c)return o.issues.push({code:"too_small",minimum:c,inclusive:!0,input:s,inst:e,origin:"array"}),o;s.length>n.length&&o.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:s,inst:e,origin:"array"})}let l=new Array(n.length);for(let f=0;f<n.length;f++){let d=n[f]._zod.run({value:s[f],issues:[]},i);d instanceof Promise?a.push(d.then(m=>{l[f]=m})):l[f]=d}if(t.rest){let f=n.length-1,d=s.slice(n.length);for(let m of d){f++;let w=t.rest._zod.run({value:m,issues:[]},i);w instanceof Promise?a.push(w.then(b=>Mc(b,o,f))):Mc(w,o,f)}}return a.length?Promise.all(a).then(()=>Lc(l,o,n,s,u)):Lc(l,o,n,s,u)}});function Uc(e,t){for(let n=e.length-1;n>=0;n--)if(!(t==="optin"?e[n]._zod.optin!==void 0:e[n]._zod.optout==="optional"))return n+1;return 0}function Mc(e,t,n){e.issues.length&&t.issues.push(...Fe(n,e.issues)),t.value[n]=e.value}function Lc(e,t,n,r,o){for(let i=0;i<n.length;i++){let s=e[i],a=i<r.length;if(!a&&i>=o&&n[i]._zod.optin==="optional"){t.value.length=i;break}if(s.issues.length){if(!a&&i>=o){t.value.length=i;break}t.issues.push(...Fe(i,s.issues))}t.value[i]=s.value}for(let i=t.value.length-1;i>=r.length&&(n[i]._zod.optout==="optional"&&t.value[i]===void 0);i--)t.value.length=i;return t}var eu=C("$ZodRecord",(e,t)=>{oe.init(e,t);let n=Ct.memoizer;n?.attach(e),e._zod.parse=(r,o)=>{let i=r.value;if(!Hn(i))return r.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),r;let s=[],a=t.keyType._zod.values;if(a&&!t.partial){r.value=n?n.alloc(e,r,{},o):{};let c=new Set;for(let l of a)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){if(c.add(typeof l=="number"?l.toString():l),l==="__proto__")continue;let f=t.keyType._zod.run({value:l,issues:[]},o);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(f.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:f.issues.map(w=>rt(w,o,it())),input:l,path:[l],inst:e});continue}let d=f.value;if(d==="__proto__")continue;let m=t.valueType._zod.run({value:i[l],issues:[]},o);m instanceof Promise?s.push(m.then(w=>{w.issues.length&&r.issues.push(...Fe(l,w.issues)),r.value[d]=w.value})):(m.issues.length&&r.issues.push(...Fe(l,m.issues)),r.value[d]=m.value)}let u;for(let l in i)if(!c.has(l))if(t.mode==="loose"){if(l==="__proto__")continue;r.value[l]=i[l]}else u=u??[],u.push(l);u&&u.length>0&&r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:u,continue:!0})}else{r.value=n?n.alloc(e,r,{},o):{};let c;for(let u of Reflect.ownKeys(i)){if(u==="__proto__"||!Object.prototype.propertyIsEnumerable.call(i,u))continue;let l=t.keyType._zod.run({value:u,issues:[]},o);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof u=="string"&&Gi.test(u)&&l.issues.length){let w=t.keyType._zod.run({value:Number(u),issues:[]},o);if(w instanceof Promise)throw new Error("Async schemas not supported in object keys currently");w.issues.length===0&&(l=w)}if(l.issues.length){t.mode==="loose"?r.value[u]=i[u]:a?(c=c??[],c.push(u)):r.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(w=>rt(w,o,it())),input:u,path:[u],inst:e});continue}let d=l.value;if(d==="__proto__")continue;let m=t.valueType._zod.run({value:i[u],issues:[]},o);m instanceof Promise?s.push(m.then(w=>{w.issues.length&&r.issues.push(...Fe(u,w.issues)),r.value[d]=w.value})):(m.issues.length&&r.issues.push(...Fe(u,m.issues)),r.value[d]=m.value)}c&&c.length>0&&r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:c,continue:!0})}return s.length?Promise.all(s).then(()=>r):r}});var tu=C("$ZodEnum",(e,t)=>{oe.init(e,t);let n=oc(t.entries),r=new Set(n);e._zod.values=r;let o=n.filter(i=>ac.has(typeof i));e._zod.pattern=new RegExp(o.length?`^(${o.map(i=>Li(i.toString())).join("|")})$`:"^[^\\s\\S]$"),e._zod.parse=(i,s)=>{let a=i.value;return r.has(a)||i.issues.push({code:"invalid_value",values:n,input:a,inst:e}),i}});function Nc(e,t){return e.value=t.issues.length?void 0:t.value,e}var nu=C("$ZodOptional",(e,t)=>{oe.init(e,t),be(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",be(e,"values",n=>{let r=n.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),be(e,"pattern",n=>{let r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${Vr(r.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;let o=t.innerType._zod.run({value:n.value,issues:[]},r);return o instanceof Promise?o.then(i=>Nc(n,i)):Nc(n,o)}return t.innerType._zod.run(n,r)}});var ru=C("$ZodNullable",(e,t)=>{oe.init(e,t),be(e,"optin",n=>n.def.innerType._zod.optin),be(e,"optout",n=>n.def.innerType._zod.optout),be(e,"pattern",n=>{let r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${Vr(r.source)}|null)$`):void 0}),be(e,"values",n=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)});var ou=C("$ZodCustom",(e,t)=>{$t.init(e,t),oe.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{let r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(i=>Bc(i,n,r,e));Bc(o,n,r,e)}});function Bc(e,t,n,r){if(!e){let o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(Bi(o))}}function iu(e,t){return new e({type:"string",...ne(t)})}function su(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...ne(t)})}function au(e,t){return new e({type:"number",checks:[],...ne(t)})}function cu(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...ne(t)})}function uu(e,t){return new e({type:"boolean",...ne(t)})}function lu(e,t){return new e({type:"undefined",...ne(t)})}function fu(e){return new e({type:"unknown"})}function du(e,t){return new e({type:"never",...ne(t)})}function Xi(e,t){return new Rc({check:"greater_than",...ne(t),value:e,inclusive:!0})}function Dt(e){return Xi(0,e)}function pu(e,t,n){let r=ne(n);return r.abort??(r.abort=!0),new e({type:"custom",check:"custom",fn:t,...r})}var de=C("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");oe.init(e,t),e.def=t,e.type=t.type},{get with(){return this.check},set with(e){kt(this,"with",e)},parse(e,t){return Wr(this,e,t,{callee:this.parse})},parseAsync(e,t){return Xr(this,e,t,{callee:this.parseAsync})},safeParse(e,t){return Jn(this,e,t)},safeParseAsync(e,t){return Kn(this,e,t)},check(...e){let t=this.def;return this.clone({...t,checks:[...t.checks??[],...e.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]},{parent:!0})},clone(e,t){return Gn(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},apply(e,...t){return t.length===0?e(this):e(this,...t)}}),mu=C("ZodMiniString",(e,t)=>{Ki.init(e,t),de.init(e,t)});function j(e){return iu(mu,e)}var Gp=C("ZodMiniStringFormat",(e,t)=>{Vi.init(e,t),mu.init(e,t)});var qp=C("ZodMiniURL",(e,t)=>{Fc.init(e,t),Gp.init(e,t)});function F(e){return su(qp,e)}var gu=C("ZodMiniNumber",(e,t)=>{Wi.init(e,t),de.init(e,t)});function yu(e){return au(gu,e)}var Jp=C("ZodMiniNumberFormat",(e,t)=>{Hc.init(e,t),gu.init(e,t)});function nn(e){return cu(Jp,e)}var Kp=C("ZodMiniBoolean",(e,t)=>{Gc.init(e,t),de.init(e,t)});function Vn(e){return uu(Kp,e)}var Vp=C("ZodMiniUndefined",(e,t)=>{qc.init(e,t),de.init(e,t)});function wu(e){return lu(Vp,e)}var Wp=C("ZodMiniUnknown",(e,t)=>{Jc.init(e,t),de.init(e,t)});function Xp(){return fu(Wp)}var Yp=C("ZodMiniNever",(e,t)=>{Kc.init(e,t),de.init(e,t)});function Qp(e){return du(Yp,e)}var eh=C("ZodMiniArray",(e,t)=>{Vc.init(e,t),de.init(e,t)});function J(e,t){return new eh({type:"array",element:e,...ne(t)})}var Yi=C("ZodMiniObject",(e,t)=>{Wc.init(e,t),de.init(e,t),hc(e,"shape",n=>n._zod.def.shape,!1)});function xe(e,t){let n={type:"object",shape:e??{},...ne(t)};return new Yi(n)}function Ee(e,t){return new Yi({type:"object",shape:e,catchall:Qp(),...ne(t)})}function ve(e,t){return new Yi({type:"object",shape:e,catchall:Xp(),...ne(t)})}function st(e,t){return lc(e,t)}var th=C("ZodMiniUnion",(e,t)=>{Xc.init(e,t),de.init(e,t)});function at(e,t){return new th({type:"union",options:e,...ne(t)})}var nh=C("ZodMiniIntersection",(e,t)=>{Yc.init(e,t),de.init(e,t)});function _u(e,t){return new nh({type:"intersection",left:e,right:t})}var rh=C("ZodMiniTuple",(e,t)=>{Qc.init(e,t),de.init(e,t)});function he(e,t,n){let r=t instanceof oe,o=r?n:t,i=r?t:null;return new rh({type:"tuple",items:e,rest:i,...ne(o)})}var hu=C("ZodMiniRecord",(e,t)=>{eu.init(e,t),de.init(e,t)});function bu(e,t,n){return!t||!t._zod?new hu({type:"record",keyType:j(),valueType:e,...ne(t)}):new hu({type:"record",keyType:e,valueType:t,...ne(n)})}var oh=C("ZodMiniEnum",(e,t)=>{tu.init(e,t),de.init(e,t),e.options=Object.values(t.entries)});function xu(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new oh({type:"enum",entries:n,...ne(t)})}var ih=C("ZodMiniOptional",(e,t)=>{nu.init(e,t),de.init(e,t)});function Y(e){return new ih({type:"optional",innerType:e})}var sh=C("ZodMiniNullable",(e,t)=>{ru.init(e,t),de.init(e,t)});function Ue(e){return new sh({type:"nullable",innerType:e})}var ah=C("ZodMiniCustom",(e,t)=>{ou.init(e,t),de.init(e,t)});function Ut(e,t){return pu(ah,e??(()=>!0),t)}function rn(e,t={}){let n=Ut(r=>r instanceof e,t);return n._zod.bag.Class=e,n._zod.check=r=>{r.value instanceof e||r.issues.push({code:"invalid_type",expected:e.name,input:r.value,inst:n,path:[...n._zod.def.path??[]]})},n}var Su=ve({value:ve({}),channels:J(j()),allowed:Y(Ue(J(F())))}),Sv=st(Su,{url:F(),actor:F()}),Eu=at([ve({url:F()}),F()]),on=ve({actor:F()}),Qr=Y(Ue(on)),vu=at([Vn(),ve({})]),Au=ve({data:rn(Blob),allowed:Y(Ue(J(F())))}),Av=st(Au,{actor:F()}),uh=ve({types:Y(J(j())),maxBytes:Y(nn().check(Dt()))}),eo=class{constructor(t){this.graffiti=t,this.sessionEvents=this.graffiti.sessionEvents}graffiti;sessionEvents;login=(...t)=>{let n=he([Y(Ue(F()))]).parse(t);return this.graffiti.login(...n)};logout=(...t)=>{let n=he([on]).parse(t);return this.graffiti.logout(...n)};handleToActor=(...t)=>{let n=he([j()]).parse(t);return this.graffiti.handleToActor(...n)};actorToHandle=(...t)=>{let n=he([F()]).parse(t);return this.graffiti.actorToHandle(...n)};post=(...t)=>{let n=he([Su,on]).parse(t);return this.graffiti.post(...n)};get=(...t)=>{let n=he([Eu,vu,Qr]).parse(t);return this.graffiti.get(n[0],n[1],n[2])};delete=(...t)=>{let n=he([Eu,on]).parse(t);return this.graffiti.delete(...n)};postMedia=(...t)=>{let n=he([Au,on]).parse(t);return this.graffiti.postMedia(...n)};getMedia=(...t)=>{let n=he([F(),uh,Qr]).parse(t);return this.graffiti.getMedia(...n)};deleteMedia=(...t)=>{let n=he([F(),on]).parse(t);return this.graffiti.deleteMedia(...n)};discover=(...t)=>{let n=he([J(j()),vu,Qr]).parse(t);return this.graffiti.discover(n[0],n[1],n[2])};continueDiscover=(...t)=>{let n=he([j(),Qr]).parse(t);return this.graffiti.continueDiscover(...n)}};var lh={type:"object",properties:{value:{type:"object"},channels:{type:"array",items:{type:"string"}},allowed:{type:"array",items:{type:"string"},nullable:!0},url:{type:"string"},actor:{type:"string"}},additionalProperties:!1,required:["value","channels","actor","url"]},Pv={...lh,required:["value","channels"]};var ht=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorForbidden",Object.setPrototypeOf(this,e.prototype)}},Q=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorNotFound",Object.setPrototypeOf(this,e.prototype)}},sn=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorInvalidSchema",Object.setPrototypeOf(this,e.prototype)}},to=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorSchemaMismatch",Object.setPrototypeOf(this,e.prototype)}},mt=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorTooLarge",Object.setPrototypeOf(this,e.prototype)}},no=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorNotAcceptable",Object.setPrototypeOf(this,e.prototype)}},Me=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorCursorExpired",Object.setPrototypeOf(this,e.prototype)}};function es(e){return typeof e=="string"?e:e.url}function ts(e,t,n){if(n===e.actor)return e;let r=e.allowed&&n?[n]:void 0,o=e.channels.filter(i=>t.includes(i));return{...e,...r?{allowed:r}:{},channels:o}}function Ru(e,t){let[n,r]=e.toLowerCase().split(";")[0].split("/");return!n||!r?!1:t.some(o=>{let[i,s]=o.toLowerCase().split(";")[0].split("/");return!i||!s?!1:(i===n||i==="*")&&(s===r||s==="*")})}var Qi;async function ro(e){if(!Qi){let{default:t}=await import("./ajv-X6C4R6QN.js");Qi=new t({strict:!1})}try{return Qi.compile(e)}catch(t){throw new sn(t instanceof Error?t.message:String(t))}}function Tu(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}var ns=e=>e?`"${e}" `:"";function Wn(e,t=""){if(typeof e!="number")throw new TypeError(ns(t)+"expected number, got "+typeof e);if(!Number.isSafeInteger(e)||e<0)throw new RangeError(ns(t)+"expected integer >= 0, got "+e);return e}function Xn(e,t,n=""){if(Tu(e)&&(t===void 0||e.length===t))return e;t!==void 0&&Wn(t,"length");let r=Tu(e),o=t!==void 0?` of length ${t}`:"",i=r?`length=${e.length}`:`type=${typeof e}`,s=ns(n)+"expected Uint8Array"+o+", got "+i;throw r?new RangeError(s):new TypeError(s)}function Pu(e){return Uint8Array.from(Xn(e))}function Ou(e){if(typeof e!="function"||typeof e.create!="function")throw new TypeError("expected hash wrapped by utils.createHasher");if(Wn(e.outputLen),Wn(e.blockLen),e.outputLen<1||e.blockLen<1)throw new Error("hash blockLen / outputLen must be >= 1")}function ku(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Mt(e=32){Wn(e,"bytesLength");let t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(e>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}var fh=["Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array","Tagged"];function rs(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(t==="string"||t==="number"||t==="bigint"||t==="symbol")return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(e instanceof Uint8Array)return"Uint8Array";if(e.constructor===Object)return"Object";let n=dh(e);return n||"Object"}function dh(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(fh.includes(t))return t}var y=class{constructor(t,n,r){this.major=t,this.majorEncoded=t<<5,this.name=n,this.terminal=r}toString(){return`Type[${this.major}].${this.name}`}compare(t){return this.major<t.major?-1:this.major>t.major?1:0}static equals(t,n){return t===n||t.major===n.major&&t.name===n.name}};y.uint=new y(0,"uint",!0);y.negint=new y(1,"negint",!0);y.bytes=new y(2,"bytes",!0);y.string=new y(3,"string",!0);y.array=new y(4,"array",!1);y.map=new y(5,"map",!1);y.tag=new y(6,"tag",!1);y.float=new y(7,"float",!0);y.false=new y(7,"false",!0);y.true=new y(7,"true",!0);y.null=new y(7,"null",!0);y.undefined=new y(7,"undefined",!0);y.break=new y(7,"break",!0);var P=class{constructor(t,n,r){this.type=t,this.value=n,this.encodedLength=r,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var Yn=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",ph=new TextEncoder;function oo(e){return Yn&&globalThis.Buffer.isBuffer(e)}function Qn(e){return e instanceof Uint8Array?oo(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var hh=24,mh=200,io=Yn?e=>e.length>=hh?globalThis.Buffer.from(e):Iu(e):e=>e.length>=mh?ph.encode(e):Iu(e),He=e=>Uint8Array.from(e),zu=Yn?(e,t,n)=>oo(e)?new Uint8Array(e.subarray(t,n)):e.slice(t,n):(e,t,n)=>e.slice(t,n),Cu=Yn?(e,t)=>(e=e.map(n=>n instanceof Uint8Array?n:globalThis.Buffer.from(n)),Qn(globalThis.Buffer.concat(e,t))):(e,t)=>{let n=new Uint8Array(t),r=0;for(let o of e)r+o.length>n.length&&(o=o.subarray(0,n.length-r)),n.set(o,r),r+=o.length;return n},os=Yn?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function an(e,t){if(oo(e)&&oo(t))return e.compare(t);for(let n=0;n<e.length;n++)if(e[n]!==t[n])return e[n]<t[n]?-1:1;return 0}function Iu(e){let t=[],n=0;for(let r=0;r<e.length;r++){let o=e.charCodeAt(r);o<128?t[n++]=o:o<2048?(t[n++]=o>>6|192,t[n++]=o&63|128):(o&64512)===55296&&r+1<e.length&&(e.charCodeAt(r+1)&64512)===56320?(o=65536+((o&1023)<<10)+(e.charCodeAt(++r)&1023),t[n++]=o>>18|240,t[n++]=o>>12&63|128,t[n++]=o>>6&63|128,t[n++]=o&63|128):(o>=55296&&o<=57343&&(o=65533),t[n++]=o>>12|224,t[n++]=o>>6&63|128,t[n++]=o&63|128)}return t}var gh=256,er=class{constructor(t=gh){this.chunkSize=t,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}pushByte(t){let n=this.chunks[this.chunks.length-1];this.cursor>this.maxCursor&&(n=os(this.chunkSize),this.chunks.push(n),this.maxCursor+=n.length,this._initReuseChunk===null&&(this._initReuseChunk=n));let r=n.length-(this.maxCursor-this.cursor)-1;n[r]=t,this.cursor++}push(t){let n=this.chunks[this.chunks.length-1];if(this.cursor+t.length<=this.maxCursor+1){let o=n.length-(this.maxCursor-this.cursor)-1;n.set(t,o)}else{if(n){let o=n.length-(this.maxCursor-this.cursor)-1;o<n.length&&(this.chunks[this.chunks.length-1]=n.subarray(0,o),this.maxCursor=this.cursor-1)}t.length<64&&t.length<this.chunkSize?(n=os(this.chunkSize),this.chunks.push(n),this.maxCursor+=n.length,this._initReuseChunk===null&&(this._initReuseChunk=n),n.set(t,0)):(this.chunks.push(t),this.maxCursor+=t.length)}this.cursor+=t.length}toBytes(t=!1){let n;if(this.chunks.length===1){let r=this.chunks[0];t&&this.cursor>r.length/2?(n=this.cursor===r.length?r:r.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):n=zu(r,0,this.cursor)}else n=Cu(this.chunks,this.cursor);return t&&this.reset(),n}},so=class{constructor(t){this.dest=t,this.cursor=0,this.chunks=[t]}reset(){this.cursor=0}pushByte(t){if(this.cursor>=this.dest.length)throw new Error("write out of bounds, destination buffer is too small");this.dest[this.cursor++]=t}push(t){if(this.cursor+t.length>this.dest.length)throw new Error("write out of bounds, destination buffer is too small");this.dest.set(t,this.cursor),this.cursor+=t.length}toBytes(t=!1){let n=this.dest.subarray(0,this.cursor);return t&&this.reset(),n}};var z="CBOR decode error:",ao="CBOR encode error:",tr=[];tr[23]=1;tr[24]=2;tr[25]=3;tr[26]=5;tr[27]=9;function ct(e,t,n){if(e.length-t<n)throw new Error(`${z} not enough data for type`)}var ae=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Se(e,t,n){ct(e,t,1);let r=e[t];if(n.strict===!0&&r<ae[0])throw new Error(`${z} integer encoded in more bytes than necessary (strict decode)`);return r}function Ae(e,t,n){ct(e,t,2);let r=e[t]<<8|e[t+1];if(n.strict===!0&&r<ae[1])throw new Error(`${z} integer encoded in more bytes than necessary (strict decode)`);return r}function Re(e,t,n){ct(e,t,4);let r=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(n.strict===!0&&r<ae[2])throw new Error(`${z} integer encoded in more bytes than necessary (strict decode)`);return r}function Te(e,t,n){ct(e,t,8);let r=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],o=e[t+4]*16777216+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],i=(BigInt(r)<<BigInt(32))+BigInt(o);if(n.strict===!0&&i<ae[3])throw new Error(`${z} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(n.allowBigInt===!0)return i;throw new Error(`${z} integers outside of the safe integer range are not supported`)}function $u(e,t,n,r){return new P(y.uint,Se(e,t+1,r),2)}function Du(e,t,n,r){return new P(y.uint,Ae(e,t+1,r),3)}function Uu(e,t,n,r){return new P(y.uint,Re(e,t+1,r),5)}function Mu(e,t,n,r){return new P(y.uint,Te(e,t+1,r),9)}function Ge(e,t){return ie(e,0,t.value)}function ie(e,t,n){if(n<ae[0]){let r=Number(n);e.pushByte(t|r)}else if(n<ae[1]){let r=Number(n);e.push([t|24,r])}else if(n<ae[2]){let r=Number(n);e.push([t|25,r>>>8,r&255])}else if(n<ae[3]){let r=Number(n);e.push([t|26,r>>>24&255,r>>>16&255,r>>>8&255,r&255])}else{let r=BigInt(n);if(r<ae[4]){let o=[t|27,0,0,0,0,0,0,0],i=Number(r&BigInt(4294967295)),s=Number(r>>BigInt(32)&BigInt(4294967295));o[8]=i&255,i=i>>8,o[7]=i&255,i=i>>8,o[6]=i&255,i=i>>8,o[5]=i&255,o[4]=s&255,s=s>>8,o[3]=s&255,s=s>>8,o[2]=s&255,s=s>>8,o[1]=s&255,e.push(o)}else throw new Error(`${z} encountered BigInt larger than allowable range`)}}Ge.encodedSize=function(t){return ie.encodedSize(t.value)};ie.encodedSize=function(t){return t<ae[0]?1:t<ae[1]?2:t<ae[2]?3:t<ae[3]?5:9};Ge.compareTokens=function(t,n){return t.value<n.value?-1:t.value>n.value?1:0};function Lu(e,t,n,r){return new P(y.negint,-1-Se(e,t+1,r),2)}function Nu(e,t,n,r){return new P(y.negint,-1-Ae(e,t+1,r),3)}function Bu(e,t,n,r){return new P(y.negint,-1-Re(e,t+1,r),5)}var is=BigInt(-1),ju=BigInt(1);function Zu(e,t,n,r){let o=Te(e,t+1,r);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new P(y.negint,i,9)}if(r.allowBigInt!==!0)throw new Error(`${z} integers outside of the safe integer range are not supported`);return new P(y.negint,is-BigInt(o),9)}function co(e,t){let n=t.value,r=typeof n=="bigint"?n*is-ju:n*-1-1;ie(e,t.type.majorEncoded,r)}co.encodedSize=function(t){let n=t.value,r=typeof n=="bigint"?n*is-ju:n*-1-1;return r<ae[0]?1:r<ae[1]?2:r<ae[2]?3:r<ae[3]?5:9};co.compareTokens=function(t,n){return t.value<n.value?1:t.value>n.value?-1:0};function nr(e,t,n,r){ct(e,t,n+r);let o=e.slice(t+n,t+n+r);return new P(y.bytes,o,n+r)}function Fu(e,t,n,r){return nr(e,t,1,n)}function Hu(e,t,n,r){return nr(e,t,2,Se(e,t+1,r))}function Gu(e,t,n,r){return nr(e,t,3,Ae(e,t+1,r))}function qu(e,t,n,r){return nr(e,t,5,Re(e,t+1,r))}function Ju(e,t,n,r){let o=Te(e,t+1,r);if(typeof o=="bigint")throw new Error(`${z} 64-bit integer bytes lengths not supported`);return nr(e,t,9,o)}function uo(e){return e.encodedBytes===void 0&&(e.encodedBytes=y.equals(e.type,y.string)?io(e.value):e.value),e.encodedBytes}function cn(e,t){let n=uo(t);ie(e,t.type.majorEncoded,n.length),e.push(n)}cn.encodedSize=function(t){let n=uo(t);return ie.encodedSize(n.length)+n.length};cn.compareTokens=function(t,n){return wh(uo(t),uo(n))};function wh(e,t){return e.length<t.length?-1:e.length>t.length?1:an(e,t)}var Ku=new TextDecoder,bh=32;function xh(e,t,n){if(n-t<bh){let o="";for(let i=t;i<n;i++){let s=e[i];if(s&128)return Ku.decode(e.subarray(t,n));o+=String.fromCharCode(s)}return o}return Ku.decode(e.subarray(t,n))}function rr(e,t,n,r,o){let i=n+r;ct(e,t,i);let s=new P(y.string,xh(e,t+n,t+i),i);return o.retainStringBytes===!0&&(s.byteValue=e.slice(t+n,t+i)),s}function Vu(e,t,n,r){return rr(e,t,1,n,r)}function Wu(e,t,n,r){return rr(e,t,2,Se(e,t+1,r),r)}function Xu(e,t,n,r){return rr(e,t,3,Ae(e,t+1,r),r)}function Yu(e,t,n,r){return rr(e,t,5,Re(e,t+1,r),r)}function Qu(e,t,n,r){let o=Te(e,t+1,r);if(typeof o=="bigint")throw new Error(`${z} 64-bit integer string lengths not supported`);return rr(e,t,9,o,r)}var el=cn;function un(e,t,n,r){return new P(y.array,r,n)}function tl(e,t,n,r){return un(e,t,1,n)}function nl(e,t,n,r){return un(e,t,2,Se(e,t+1,r))}function rl(e,t,n,r){return un(e,t,3,Ae(e,t+1,r))}function ol(e,t,n,r){return un(e,t,5,Re(e,t+1,r))}function il(e,t,n,r){let o=Te(e,t+1,r);if(typeof o=="bigint")throw new Error(`${z} 64-bit integer array lengths not supported`);return un(e,t,9,o)}function sl(e,t,n,r){if(r.allowIndefinite===!1)throw new Error(`${z} indefinite length items not allowed`);return un(e,t,1,1/0)}function lo(e,t){ie(e,y.array.majorEncoded,t.value)}lo.compareTokens=Ge.compareTokens;lo.encodedSize=function(t){return ie.encodedSize(t.value)};function ln(e,t,n,r){return new P(y.map,r,n)}function al(e,t,n,r){return ln(e,t,1,n)}function cl(e,t,n,r){return ln(e,t,2,Se(e,t+1,r))}function ul(e,t,n,r){return ln(e,t,3,Ae(e,t+1,r))}function ll(e,t,n,r){return ln(e,t,5,Re(e,t+1,r))}function fl(e,t,n,r){let o=Te(e,t+1,r);if(typeof o=="bigint")throw new Error(`${z} 64-bit integer map lengths not supported`);return ln(e,t,9,o)}function dl(e,t,n,r){if(r.allowIndefinite===!1)throw new Error(`${z} indefinite length items not allowed`);return ln(e,t,1,1/0)}function fo(e,t){ie(e,y.map.majorEncoded,t.value)}fo.compareTokens=Ge.compareTokens;fo.encodedSize=function(t){return ie.encodedSize(t.value)};function pl(e,t,n,r){return new P(y.tag,n,1)}function hl(e,t,n,r){return new P(y.tag,Se(e,t+1,r),2)}function ml(e,t,n,r){return new P(y.tag,Ae(e,t+1,r),3)}function gl(e,t,n,r){return new P(y.tag,Re(e,t+1,r),5)}function yl(e,t,n,r){return new P(y.tag,Te(e,t+1,r),9)}function po(e,t){ie(e,y.tag.majorEncoded,t.value)}po.compareTokens=Ge.compareTokens;po.encodedSize=function(t){return ie.encodedSize(t.value)};var ho=20,mo=21,go=22,yo=23;function _l(e,t,n,r){if(r.allowUndefined===!1)throw new Error(`${z} undefined values are not supported`);return r.coerceUndefinedToNull===!0?new P(y.null,null,1):new P(y.undefined,void 0,1)}function bl(e,t,n,r){if(r.allowIndefinite===!1)throw new Error(`${z} indefinite length items not allowed`);return new P(y.break,void 0,1)}function ss(e,t,n){if(n){if(n.allowNaN===!1&&Number.isNaN(e))throw new Error(`${z} NaN values are not supported`);if(n.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${z} Infinity values are not supported`)}return new P(y.float,e,t)}function xl(e,t,n,r){return ss(wo(e,t+1),3,r)}function El(e,t,n,r){return ss(_o(e,t+1),5,r)}function vl(e,t,n,r){return ss(Rl(e,t+1),9,r)}function or(e,t,n){let r=t.value;if(r===!1)e.pushByte(y.float.majorEncoded|ho);else if(r===!0)e.pushByte(y.float.majorEncoded|mo);else if(r===null)e.pushByte(y.float.majorEncoded|go);else if(r===void 0)e.pushByte(y.float.majorEncoded|yo);else{let o,i=!1;(!n||n.float64!==!0)&&(as(r),o=wo(se,1),r===o||Number.isNaN(r)?(se[0]=249,e.push(se.slice(0,3)),i=!0):(cs(r),o=_o(se,1),r===o&&(se[0]=250,e.push(se.slice(0,5)),i=!0))),i||(Al(r),o=Rl(se,1),se[0]=251,e.push(se.slice(0,9)))}}or.encodedSize=function(t,n){let r=t.value;if(r===!1||r===!0||r===null||r===void 0)return 1;if(!n||n.float64!==!0){as(r);let o=wo(se,1);if(r===o||Number.isNaN(r))return 3;if(cs(r),o=_o(se,1),r===o)return 5}return 9};var Sl=new ArrayBuffer(9),Ie=new DataView(Sl,1),se=new Uint8Array(Sl,0);function as(e){if(e===1/0)Ie.setUint16(0,31744,!1);else if(e===-1/0)Ie.setUint16(0,64512,!1);else if(Number.isNaN(e))Ie.setUint16(0,32256,!1);else{Ie.setFloat32(0,e);let t=Ie.getUint32(0),n=(t&2139095040)>>23,r=t&8388607;if(n===255)Ie.setUint16(0,31744,!1);else if(n===0)Ie.setUint16(0,(t&2147483648)>>16|r>>13,!1);else{let o=n-127;o<-24?Ie.setUint16(0,0):o<-14?Ie.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):Ie.setUint16(0,(t&2147483648)>>16|o+15<<10|r>>13,!1)}}}function wo(e,t){if(e.length-t<2)throw new Error(`${z} not enough data for float16`);let n=(e[t]<<8)+e[t+1];if(n===31744)return 1/0;if(n===64512)return-1/0;if(n===32256)return NaN;let r=n>>10&31,o=n&1023,i;return r===0?i=o*2**-24:r!==31?i=(o+1024)*2**(r-25):i=o===0?1/0:NaN,n&32768?-i:i}function cs(e){Ie.setFloat32(0,e,!1)}function _o(e,t){if(e.length-t<4)throw new Error(`${z} not enough data for float32`);let n=(e.byteOffset||0)+t;return new DataView(e.buffer,n,4).getFloat32(0,!1)}function Al(e){Ie.setFloat64(0,e,!1)}function Rl(e,t){if(e.length-t<8)throw new Error(`${z} not enough data for float64`);let n=(e.byteOffset||0)+t;return new DataView(e.buffer,n,8).getFloat64(0,!1)}function Rh(e,t){let n=e.value;if(n===!1)return Uint8Array.of(y.float.majorEncoded|ho);if(n===!0)return Uint8Array.of(y.float.majorEncoded|mo);if(n===null)return Uint8Array.of(y.float.majorEncoded|go);if(n===void 0)return Uint8Array.of(y.float.majorEncoded|yo);if(!t){if(as(n),n===wo(se,1)||Number.isNaN(n))return se[0]=249,se.slice(0,3);if(cs(n),n===_o(se,1))return se[0]=250,se.slice(0,5)}return Al(n),se[0]=251,se.slice(0,9)}function wl(e,t){let n=e,r=t?.float64===!0,o=r?n._keyBytesFloat64:n._keyBytes;if(o!==void 0)return o;let i=Rh(e,r);return r?n._keyBytesFloat64=i:n._keyBytes=i,i}or.compareTokens=function(t,n,r){let o=wl(t,r),i=wl(n,r);return o.length!==i.length?o.length<i.length?-1:1:an(o,i)};function Z(e,t,n){throw new Error(`${z} encountered invalid minor (${n}) for major ${e[t]>>>5}`)}function bo(e){return()=>{throw new Error(`${z} ${e}`)}}var R=[];for(let e=0;e<=23;e++)R[e]=Z;R[24]=$u;R[25]=Du;R[26]=Uu;R[27]=Mu;R[28]=Z;R[29]=Z;R[30]=Z;R[31]=Z;for(let e=32;e<=55;e++)R[e]=Z;R[56]=Lu;R[57]=Nu;R[58]=Bu;R[59]=Zu;R[60]=Z;R[61]=Z;R[62]=Z;R[63]=Z;for(let e=64;e<=87;e++)R[e]=Fu;R[88]=Hu;R[89]=Gu;R[90]=qu;R[91]=Ju;R[92]=Z;R[93]=Z;R[94]=Z;R[95]=bo("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)R[e]=Vu;R[120]=Wu;R[121]=Xu;R[122]=Yu;R[123]=Qu;R[124]=Z;R[125]=Z;R[126]=Z;R[127]=bo("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)R[e]=tl;R[152]=nl;R[153]=rl;R[154]=ol;R[155]=il;R[156]=Z;R[157]=Z;R[158]=Z;R[159]=sl;for(let e=160;e<=183;e++)R[e]=al;R[184]=cl;R[185]=ul;R[186]=ll;R[187]=fl;R[188]=Z;R[189]=Z;R[190]=Z;R[191]=dl;for(let e=192;e<=215;e++)R[e]=pl;R[216]=hl;R[217]=ml;R[218]=gl;R[219]=yl;R[220]=Z;R[221]=Z;R[222]=Z;R[223]=Z;for(let e=224;e<=243;e++)R[e]=bo("simple values are not supported");R[244]=Z;R[245]=Z;R[246]=Z;R[247]=_l;R[248]=bo("simple values are not supported");R[249]=xl;R[250]=El;R[251]=vl;R[252]=Z;R[253]=Z;R[254]=Z;R[255]=bl;var Le=[];for(let e=0;e<24;e++)Le[e]=new P(y.uint,e,1);for(let e=-1;e>=-24;e--)Le[31-e]=new P(y.negint,e,1);Le[64]=new P(y.bytes,new Uint8Array(0),1);Le[96]=new P(y.string,"",1);Le[128]=new P(y.array,0,1);Le[160]=new P(y.map,0,1);Le[244]=new P(y.false,!1,1);Le[245]=new P(y.true,!0,1);Le[246]=new P(y.null,null,1);function us(e){switch(e.type){case y.false:return He([244]);case y.true:return He([245]);case y.null:return He([246]);case y.bytes:return e.value.length?void 0:He([64]);case y.string:return e.value===""?He([96]):void 0;case y.array:return e.value===0?He([128]):void 0;case y.map:return e.value===0?He([160]):void 0;case y.uint:return e.value<24?He([Number(e.value)]):void 0;case y.negint:if(e.value>=-24)return He([31-Number(e.value)])}}var Ph={float64:!1,mapSorter:fs,quickEncodeToken:us},Il=Object.freeze({mapSorter:Ih,quickEncodeToken:us});function Oh(){let e=[];return e[y.uint.major]=Ge,e[y.negint.major]=co,e[y.bytes.major]=cn,e[y.string.major]=el,e[y.array.major]=lo,e[y.map.major]=fo,e[y.tag.major]=po,e[y.float.major]=or,e}var Bt=Oh(),xo=new er,dn=class e{constructor(t,n){this.obj=t,this.parent=n}includes(t){let n=this;do if(n.obj===t)return!0;while(n=n.parent);return!1}static createCheck(t,n){if(t&&t.includes(n))throw new Error(`${ao} object contains circular references`);return new e(n,t)}},gt={null:new P(y.null,null),undefined:new P(y.undefined,void 0),true:new P(y.true,!0),false:new P(y.false,!1),emptyArray:new P(y.array,0),emptyMap:new P(y.map,0)},qe={number(e,t,n,r){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new P(y.float,e):e>=0?new P(y.uint,e):new P(y.negint,e)},bigint(e,t,n,r){return e>=BigInt(0)?new P(y.uint,e):new P(y.negint,e)},Uint8Array(e,t,n,r){return new P(y.bytes,e)},string(e,t,n,r){return new P(y.string,e)},boolean(e,t,n,r){return e?gt.true:gt.false},null(e,t,n,r){return gt.null},undefined(e,t,n,r){return gt.undefined},ArrayBuffer(e,t,n,r){return new P(y.bytes,new Uint8Array(e))},DataView(e,t,n,r){return new P(y.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,n,r){if(!e.length)return n.addBreakTokens===!0?[gt.emptyArray,new P(y.break)]:gt.emptyArray;r=dn.createCheck(r,e);let o=[],i=0;for(let s of e)o[i++]=Nt(s,n,r);return n.addBreakTokens?[new P(y.array,e.length),o,new P(y.break)]:[new P(y.array,e.length),o]},Object(e,t,n,r){let o=t!=="Object",i=o?e.keys():Object.keys(e),s=o?e.size:i.length,a;if(s){a=new Array(s),r=dn.createCheck(r,e);let c=!o&&n.ignoreUndefinedProperties,u=0;for(let l of i){let f=o?e.get(l):e[l];c&&f===void 0||(a[u++]=[Nt(l,n,r),Nt(f,n,r)])}u<s&&(a.length=u)}return a?.length?(kh(a,n),n.addBreakTokens?[new P(y.map,a.length),a,new P(y.break)]:[new P(y.map,a.length),a]):n.addBreakTokens===!0?[gt.emptyMap,new P(y.break)]:gt.emptyMap},Tagged(e,t,n,r){return[new P(y.tag,e.tag),Nt(e.value,n,r)]}};qe.Map=qe.Object;qe.Buffer=qe.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))qe[`${e}Array`]=qe.DataView;function Nt(e,t={},n){let r=rs(e),o=t&&t.typeEncoders&&t.typeEncoders[r]||qe[r];if(typeof o=="function"){let s=o(e,r,t,n);if(s!=null)return s}let i=qe[r];if(!i)throw new Error(`${ao} unsupported type: ${r}`);return i(e,r,t,n)}function kh(e,t){let n=t.mapSorter;n&&e.sort((r,o)=>n(r,o,t))}function fs(e,t,n){let r=Array.isArray(e[0])?e[0][0]:e[0],o=Array.isArray(t[0])?t[0][0]:t[0];if(r.type.major!==o.type.major)return r.type.compare(o.type);let i=r.type.major,s=Bt[i].compareTokens(r,o,n);return s===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),s}function Ih(e,t){if(e[0]instanceof P&&t[0]instanceof P){let n=e[0],r=t[0];return n._keyBytes||(n._keyBytes=Tl(n.value)),r._keyBytes||(r._keyBytes=Tl(r.value)),an(n._keyBytes,r._keyBytes)}throw new Error("rfc8949MapSorter: complex key types are not supported yet")}function Tl(e){return zl(e,Bt,Il)}function fn(e,t,n,r){if(Array.isArray(t))for(let o of t)fn(e,o,n,r);else n[t.type.major](e,t,r)}var Pl=y.uint.majorEncoded,Ol=y.negint.majorEncoded,zh=y.bytes.majorEncoded,Ch=y.string.majorEncoded,kl=y.array.majorEncoded,ls=y.map.majorEncoded,$h=y.float.majorEncoded|ho,Dh=y.float.majorEncoded|mo,Uh=y.float.majorEncoded|go,Mh=y.float.majorEncoded|yo,Lh=BigInt(-1),Nh=BigInt(1);function yt(e,t,n){n<24?e.pushByte(t|Number(n)):ie(e,t,n)}function Bh(e){return e.addBreakTokens!==!0}function jh(e,t,n,r,o){let i=n==="Map",s=i?t.keys():Object.keys(t),a=i?t.size:s.length;if(!a){e.pushByte(ls);return}o=dn.createCheck(o,t);let c=!i&&r.ignoreUndefinedProperties,u=new Array(a),l=0;for(let f of s){let d=i?t.get(f):t[f];c&&d===void 0||(u[l++]=[Nt(f,r,o),d])}if(l===0){e.pushByte(ls);return}l<a&&(u.length=l),u.sort((f,d)=>fs(f,d,r)),yt(e,ls,l);for(let[f,d]of u)fn(e,f,Bt,r),ds(e,d,r,o)}function ds(e,t,n,r){let o=rs(t),i=n.typeEncoders&&n.typeEncoders[o];if(i){let s=i(t,o,n,r);if(s!=null){fn(e,s,Bt,n);return}}switch(o){case"null":e.pushByte(Uh);return;case"undefined":e.pushByte(Mh);return;case"boolean":e.pushByte(t?Dh:$h);return;case"number":!Number.isInteger(t)||!Number.isSafeInteger(t)?or(e,new P(y.float,t),n):t>=0?yt(e,Pl,t):yt(e,Ol,t*-1-1);return;case"bigint":t>=BigInt(0)?yt(e,Pl,t):yt(e,Ol,t*Lh-Nh);return;case"string":{let s=io(t);yt(e,Ch,s.length),e.push(s);return}case"Uint8Array":yt(e,zh,t.length),e.push(t);return;case"Array":if(!t.length){e.pushByte(kl);return}r=dn.createCheck(r,t),yt(e,kl,t.length);for(let s of t)ds(e,s,n,r);return;case"Object":case"Map":if(n.mapSorter===fs)jh(e,t,o,n,r);else{let s=qe.Object(t,o,n,r);fn(e,s,Bt,n)}return;default:{let s=qe[o];if(!s)throw new Error(`${ao} unsupported type: ${o}`);let a=s(t,o,n,r);fn(e,a,Bt,n)}}}function zl(e,t,n,r){let o=r instanceof Uint8Array,i=o?new so(r):xo,s=Nt(e,n);if(!Array.isArray(s)&&n.quickEncodeToken){let a=n.quickEncodeToken(s);if(a)return o?(i.push(a),i.toBytes()):a;let c=t[s.type.major];if(c.encodedSize){let u=c.encodedSize(s,n);if(o||(i=new er(u)),c(i,s,n),i.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${s} was wrong`);return o?i.toBytes():Qn(i.chunks[0])}}return i.reset(),fn(i,s,t,n),i.toBytes(!0)}function ps(e,t){return t=Object.assign({},Ph,t),Bh(t)?(xo.reset(),ds(xo,e,t,void 0),xo.toBytes(!0)):zl(e,Bt,t)}var Zh={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Eo=class{constructor(t,n={}){this._pos=0,this.data=t,this.options=n}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let t=this.data[this._pos],n=Le[t];if(n===void 0){let r=R[t];if(!r)throw new Error(`${z} no decoder for major type ${t>>>5} (byte 0x${t.toString(16).padStart(2,"0")})`);let o=t&31;n=r(this.data,this._pos,o,this.options)}return this._pos+=n.encodedLength,n}},wt=Symbol.for("DONE"),pn=Symbol.for("BREAK");function Fh(e,t,n){let r=[];for(let o=0;o<e.value;o++){let i=_t(t,n);if(i===pn){if(e.value===1/0)break;throw new Error(`${z} got unexpected break to lengthed array`)}if(i===wt)throw new Error(`${z} found array but not enough entries (got ${o}, expected ${e.value})`);r[o]=i}return r}function Hh(e,t,n){let r=n.useMaps===!0,o=n.rejectDuplicateMapKeys===!0,i=r?void 0:{},s=r?new Map:void 0;for(let a=0;a<e.value;a++){let c=_t(t,n);if(c===pn){if(e.value===1/0)break;throw new Error(`${z} got unexpected break to lengthed map`)}if(c===wt)throw new Error(`${z} found map but not enough entries (got ${a} [no key], expected ${e.value})`);if(!r&&typeof c!="string")throw new Error(`${z} non-string keys not supported (got ${typeof c})`);if(o&&(r&&s.has(c)||!r&&Object.hasOwn(i,c)))throw new Error(`${z} found repeat map key "${c}"`);let u=_t(t,n);if(u===wt)throw new Error(`${z} found map but not enough entries (got ${a} [no value], expected ${e.value})`);r?s.set(c,u):i[c]=u}return r?s:i}function*Gh(e,t,n){for(let r=0;r<e.value;r++){let o=_t(t,n);if(o===pn){if(e.value===1/0)break;throw new Error(`${z} got unexpected break to lengthed map`)}if(o===wt)throw new Error(`${z} found map but not enough entries (got ${r} [no key], expected ${e.value})`);let i=_t(t,n);if(i===wt)throw new Error(`${z} found map but not enough entries (got ${r} [no value], expected ${e.value})`);yield[o,i]}}function qh(e,t){let n=function(){if(n._called)throw new Error(`${z} tag decode() may only be called once`);n._called=!0;let r=_t(e,t);if(r===wt)throw new Error(`${z} tag content missing`);if(r===pn)throw new Error(`${z} got unexpected break in tag content`);return r};return n.entries=function(){if(n._called)throw new Error(`${z} tag decode() may only be called once`);n._called=!0;let r=e.next();if(!y.equals(r.type,y.map))throw new Error(`${z} entries() requires map content, got ${r.type.name}`);let o=[];for(let i of Gh(r,e,t))o.push(i);return o},n._called=!1,n}function _t(e,t){if(e.done())return wt;let n=e.next();if(y.equals(n.type,y.break))return pn;if(n.type.terminal)return n.value;if(y.equals(n.type,y.array))return Fh(n,e,t);if(y.equals(n.type,y.map))return Hh(n,e,t);if(y.equals(n.type,y.tag)){if(t.tags&&typeof t.tags[n.value]=="function"){let r=qh(e,t),o=t.tags[n.value](r);if(!r._called)throw new Error(`${z} tag decoder must call decode() or entries()`);return o}throw new Error(`${z} tag not supported (${n.value})`)}throw new Error("unsupported")}function Cl(e,t){if(!(e instanceof Uint8Array))throw new Error(`${z} data to decode must be a Uint8Array`);t=Object.assign({},Zh,t);let n=Qn(e),r=t.tokenizer||new Eo(n,t),o=_t(r,t);if(o===wt)throw new Error(`${z} did not find any content to decode`);if(o===pn)throw new Error(`${z} got unexpected break`);return[o,e.subarray(r.pos())]}function hs(e,t){let[n,r]=Cl(e,t);if(r.length>0)throw new Error(`${z} too many terminals, data makes no sense`);return n}var vo=class e{constructor(t,n){if(typeof t!="number"||!Number.isInteger(t)||t<0)throw new TypeError("Tagged: tag must be a non-negative integer");this.tag=t,this.value=n}static decoder(t){return n=>new e(t,n())}static preserve(...t){let n={};for(let r of t)n[r]=e.decoder(r);return n}};Object.defineProperty(vo.prototype,Symbol.toStringTag,{value:"Tagged"});var NS=new Uint8Array(0);function $l(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.byteLength;n++)if(e[n]!==t[n])return!1;return!0}function hn(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return jt(e);if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return jt(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));throw new Error("Unknown type, must be binary type")}function Kh(e){return e?.buffer instanceof ArrayBuffer}function jt(e){return Kh(e)?e:e.slice()}function Vh(e,t,n){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),o=0;o<r.length;o++)r[o]=255;for(var i=0;i<e.length;i++){var s=e.charAt(i),a=s.charCodeAt(0);if(r[a]!==255)throw new TypeError(s+" is ambiguous");if(r[a]=i,n){var c=s.toLowerCase().charCodeAt(0),u=s.toUpperCase().charCodeAt(0);c!==a&&(r[c]=i),u!==a&&(r[u]=i)}}var l=e.length,f=e.charAt(0),d=Math.log(l)/Math.log(256),m=Math.log(256)/Math.log(l);function w(h){if(h instanceof Uint8Array||(ArrayBuffer.isView(h)?h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):Array.isArray(h)&&(h=Uint8Array.from(h))),!(h instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(h.length===0)return"";for(var _=0,x=0,E=0,A=h.length;E!==A&&h[E]===0;)E++,_++;for(var k=(A-E)*m+1>>>0,I=new Uint8Array(k);E!==A;){for(var U=h[E],V=0,G=k-1;(U!==0||V<x)&&G!==-1;G--,V++)U+=256*I[G]>>>0,I[G]=U%l>>>0,U=U/l>>>0;if(U!==0)throw new Error("Non-zero carry");x=V,E++}for(var g=k-x;g!==k&&I[g]===0;)g++;for(var v=f.repeat(_);g<k;++g)v+=e.charAt(I[g]);return v}function b(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;var _=0;if(h[_]!==" "){for(var x=0,E=0;h[_]===f;)x++,_++;for(var A=(h.length-_)*d+1>>>0,k=new Uint8Array(A);h[_];){var I=r[h.charCodeAt(_)];if(I===255)return;for(var U=0,V=A-1;(I!==0||U<E)&&V!==-1;V--,U++)I+=l*k[V]>>>0,k[V]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");E=U,_++}if(h[_]!==" "){for(var G=A-E;G!==A&&k[G]===0;)G++;for(var g=new Uint8Array(x+(A-G)),v=x;G!==A;)g[v++]=k[G++];return g}}}function S(h){var _=b(h);if(_)return _;throw new Error(`Non-${t} character`)}return{encode:w,decodeUnsafe:b,decode:S}}var Wh=Vh,Xh=Wh,Dl=Xh;var ms=class{name;prefix;baseEncode;constructor(t,n,r){this.name=t,this.prefix=n,this.baseEncode=r}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},gs=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,n,r){this.name=t,this.prefix=n;let o=n.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=r}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Ul(this,t)}},ys=class{decoders;constructor(t){this.decoders=t}or(t){return Ul(this,t)}decode(t){let n=t[0],r=this.decoders[n];if(r!=null)return r.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Ul(e,t){return new ys({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var ws=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,n,r,o){this.name=t,this.prefix=n,this.baseEncode=r,this.baseDecode=o,this.encoder=new ms(t,n,r),this.decoder=new gs(t,n,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Ml({name:e,prefix:t,encode:n,decode:r}){return new ws(e,t,n,r)}function mn({name:e,prefix:t,alphabet:n,caseInsensitive:r=!1}){let{encode:o,decode:i}=Dl(n,e,r);return Ml({prefix:t,name:e,encode:o,decode:s=>hn(i(s))})}function Yh(e,t,n,r){let o=e.length;for(;e[o-1]==="=";)--o;let i=new Uint8Array(o*n/8|0),s=0,a=0,c=0;for(let u=0;u<o;++u){let l=t[e[u]];if(l===void 0)throw new SyntaxError(`Non-${r} character`);a=a<<n|l,s+=n,s>=8&&(s-=8,i[c++]=255&a>>s)}if(s>=n||(255&a<<8-s)!==0)throw new SyntaxError("Unexpected end of data");return i}function Qh(e,t,n){let r=t[t.length-1]==="=",o=(1<<n)-1,i="",s=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>n;)s-=n,i+=t[o&a>>s];if(s!==0&&(i+=t[o&a<<n-s]),r)for(;(i.length*n&7)!==0;)i+="=";return i}function em(e,t){let n={};for(let r=0;r<e.length;++r)if(n[e[r]]=r,t){let o=e[r].toLowerCase(),i=e[r].toUpperCase();o!==e[r]&&(n[o]=r),i!==e[r]&&(n[i]=r)}return n}function Je({name:e,prefix:t,bitsPerChar:n,alphabet:r,caseInsensitive:o=!1}){let i=em(r,o);return Ml({prefix:t,name:e,encode(s){return Qh(s,r,n)},decode(s){return Yh(s,i,n,e)}})}var ir=Je({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5,caseInsensitive:!0}),qS=Je({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5,caseInsensitive:!0}),JS=Je({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5,caseInsensitive:!0}),KS=Je({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5,caseInsensitive:!0}),VS=Je({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5,caseInsensitive:!0}),WS=Je({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5,caseInsensitive:!0}),XS=Je({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5,caseInsensitive:!0}),YS=Je({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5,caseInsensitive:!0}),QS=Je({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var So=mn({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz",caseInsensitive:!0}),nA=mn({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",caseInsensitive:!0});var ut=mn({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),iA=mn({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var tm=Bl,Ll=128,nm=127,rm=~nm,om=Math.pow(2,31);function Bl(e,t,n){t=t||[],n=n||0;for(var r=n;e>=om;)t[n++]=e&255|Ll,e/=128;for(;e&rm;)t[n++]=e&255|Ll,e>>>=7;return t[n]=e|0,Bl.bytes=n-r+1,t}var im=_s,sm=128,Nl=127;function _s(e,r){var n=0,r=r||0,o=0,i=r,s,a=e.length;do{if(i>=a)throw _s.bytes=0,new RangeError("Could not decode varint");s=e[i++],n+=o<28?(s&Nl)<<o:(s&Nl)*Math.pow(2,o),o+=7}while(s>=sm);return _s.bytes=i-r,n}var am=Math.pow(2,7),cm=Math.pow(2,14),um=Math.pow(2,21),lm=Math.pow(2,28),fm=Math.pow(2,35),dm=Math.pow(2,42),pm=Math.pow(2,49),hm=Math.pow(2,56),mm=Math.pow(2,63),gm=function(e){return e<am?1:e<cm?2:e<um?3:e<lm?4:e<fm?5:e<dm?6:e<pm?7:e<hm?8:e<mm?9:10},ym={encode:tm,decode:im,encodingLength:gm},wm=ym,sr=wm;function ar(e,t=0){let n=sr.decode(e,t),r=sr.decode.bytes;if(r>9)throw new RangeError("Invalid varint: too long");if(r>1&&e[t+r-1]===0)throw new RangeError("Invalid varint: not minimally encoded");return[n,r]}function gn(e,t,n=0){return sr.encode(e,t,n),t}function yn(e){return sr.encodingLength(e)}function Zl(e,t){let n=t.byteLength,r=yn(e),o=r+yn(n),i=new Uint8Array(o+n);return gn(e,i,0),gn(n,i,r),i.set(t,o),new wn(e,n,t,i)}function Fl(e){let t=hn(e),[n,r]=ar(t),[o,i]=ar(t.subarray(r)),s=t.subarray(r+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new wn(n,o,s,t)}function Hl(e,t){if(e===t)return!0;{let n=t;return e.code===n.code&&e.size===n.size&&n.bytes instanceof Uint8Array&&$l(e.bytes,n.bytes)}}var wn=class{code;size;digest;bytes;constructor(t,n,r,o){this.code=t,this.size=n,this.digest=jt(r),this.bytes=jt(o)}};function Gl(e,t){let{bytes:n,version:r}=e;return r===0?xm(n,bs(e),t??ut.encoder):Em(n,bs(e),t??ir.encoder)}var ql=new WeakMap;function bs(e){let t=ql.get(e);if(t==null){let n=new Map;return ql.set(e,n),n}return t}var ur=class e{code;version;multihash;bytes;"/";constructor(t,n,r,o){this.code=n,this.version=t,this.multihash=r,this.bytes=jt(o),this["/"]=this.bytes}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:n}=this;if(t!==cr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(n.code!==vm)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.createV0(n)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:n}=this.multihash,r=Zl(t,n);return e.createV1(this.code,r)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return e.equals(this,t)}static equals(t,n){let r=n;return r!=null&&t.code===r.code&&t.version===r.version&&Hl(t.multihash,r.multihash)}toString(t){return Gl(this,t)}toJSON(){return{"/":Gl(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let n=t;if(n instanceof e)return n;if(n["/"]!=null&&n["/"]===n.bytes||n.asCID===n){let{version:r,code:o,multihash:i,bytes:s}=n;return new e(r,o,i,s??Jl(r,o,i.bytes))}else if(n[Sm]===!0){let{version:r,multihash:o,code:i}=n,s=Fl(o);return e.create(r,i,s)}else return null}static create(t,n,r){if(typeof n!="number")throw new Error("String codecs are no longer supported");if(!(r.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(n!==cr)throw new Error(`Version 0 CID must use dag-pb (code: ${cr}) block encoding`);return new e(t,n,r,r.bytes)}case 1:{let o=Jl(t,n,r.bytes);return new e(t,n,r,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,cr,t)}static createV1(t,n){return e.create(1,t,n)}static decode(t){let[n,r]=e.decodeFirst(t);if(r.length!==0)throw new Error("Incorrect length");return n}static decodeFirst(t){let n=e.inspectBytes(t),r=n.size-n.multihashSize,o=hn(t.subarray(r,r+n.multihashSize));if(o.byteLength!==n.multihashSize)throw new Error("Incorrect length");let i=o.subarray(n.multihashSize-n.digestSize),s=new wn(n.multihashCode,n.digestSize,i,o);return[n.version===0?e.createV0(s):e.createV1(n.codec,s),t.subarray(n.size)]}static inspectBytes(t){let n=0,r=()=>{let[f,d]=ar(t.subarray(n));return n+=d,f},o=r(),i=cr;if(o===18?(o=0,n=0):i=r(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=n,a=r(),c=r(),u=n+c,l=u-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:l,size:u}}static parse(t,n){let[r,o]=bm(t,n),i=e.decode(o);if(i.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return bs(i).set(r,t),i}};function bm(e,t){switch(e[0]){case"Q":{let n=t??ut;return[ut.prefix,n.decode(`${ut.prefix}${e}`)]}case ut.prefix:{let n=t??ut;return[ut.prefix,n.decode(e)]}case ir.prefix:{let n=t??ir;return[ir.prefix,n.decode(e)]}case So.prefix:{let n=t??So;return[So.prefix,n.decode(e)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function xm(e,t,n){let{prefix:r}=n;if(r!==ut.prefix)throw Error(`Cannot string encode V0 in ${n.name} encoding`);let o=t.get(r);if(o==null){let i=n.encode(e).slice(1);return t.set(r,i),i}else return o}function Em(e,t,n){let{prefix:r}=n,o=t.get(r);if(o==null){let i=n.encode(e);return t.set(r,i),i}else return o}var cr=112,vm=18;function Jl(e,t,n){let r=yn(e),o=r+yn(t),i=new Uint8Array(o+n.byteLength);return gn(e,i,0),gn(t,i,r),i.set(n,o),i}var Sm=Symbol.for("@ipld/js-cid/CID");var Kl=42;function Am(e){return e instanceof ArrayBuffer?new Uint8Array(e,0,e.byteLength):e}function Rm(e){if(e.asCID!==e&&e["/"]!==e.bytes)return null;let t=ur.asCID(e);if(!t)return null;let n=new Uint8Array(t.bytes.byteLength+1);return n.set(t.bytes,1),[new P(y.tag,Kl),new P(y.bytes,n)]}function Tm(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function Pm(e){if(Number.isNaN(e))throw new Error("`NaN` is not supported by the IPLD Data Model and cannot be encoded");if(e===1/0||e===-1/0)throw new Error("`Infinity` and `-Infinity` is not supported by the IPLD Data Model and cannot be encoded");return null}function Om(e){for(let t of e.keys())if(typeof t!="string"||t.length===0)throw new Error("Non-string Map keys are not supported by the IPLD Data Model and cannot be encoded");return null}var xs={float64:!0,typeEncoders:{Map:Om,Object:Rm,undefined:Tm,number:Pm}},yA={...xs,typeEncoders:{...xs.typeEncoders}};function km(e){let t=e();if(t[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return ur.decode(t.subarray(1))}var Es={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:{[Kl]:km}},wA={...Es,tags:{...Es.tags}};var me=e=>ps(e,xs),Ne=e=>hs(Am(e),Es);function Im(){let e=new Map;return async(t,n)=>{if(t.params&&t.params["no-cache"]==="true")return await n();let r=e.get(t.didUrl);if(r!==void 0)return r;let o=await n();return o.didResolutionMetadata?.error!=="notFound"&&e.set(t.didUrl,o),o}}function zm(e,t){return t()}var Cm="(?:%[0-9a-fA-F]{2})",Vl=`(?:[a-zA-Z0-9._-]|${Cm})`,$m="([a-z0-9]+)",Dm=`((?:${Vl}*:)*(${Vl}+))`,Wl="[a-zA-Z0-9_.:%-]",Um=`;${Wl}+=${Wl}*`,Mm=`((${Um})*)`,Lm="(/[^#?]*)?",Nm="([?][^#]*)?",Bm="(#.*)?",jm=new RegExp(`^did:${$m}:${Dm}${Mm}${Lm}${Nm}${Bm}$`);function Zm(e){if(e===""||!e)return null;let t=e.match(jm);if(t){let n={did:`did:${t[1]}:${t[2]}`,method:t[1],id:t[2],didUrl:e};if(t[4]){let r=t[4].slice(1).split(";");n.params={};for(let o of r){let i=o.split("=");n.params[i[0]]=i[1]}}return t[6]&&(n.path=t[6]),t[7]&&(n.query=t[7].slice(1)),t[8]&&(n.fragment=t[8].slice(1)),n}return null}var Ao={didResolutionMetadata:{},didDocument:null,didDocumentMetadata:{}};function Fm(e){return async(t,n,r)=>{try{let o=await e(t,n,r);return{...Ao,didResolutionMetadata:{contentType:"application/did+ld+json"},didDocument:o}}catch(o){return{...Ao,didResolutionMetadata:{error:"notFound",message:o.toString()}}}}}var Ro=class{constructor(t={},n={}){this.registry=t,this.cache=n.cache===!0?Im():n.cache||zm,n.legacyResolvers&&Object.keys(n.legacyResolvers).map(r=>{this.registry[r]||(this.registry[r]=Fm(n.legacyResolvers[r]))})}async resolve(t,n={}){let r=Zm(t);if(r===null)return{...Ao,didResolutionMetadata:{error:"invalidDid"}};let o=this.registry[r.method];return o?this.cache(r,()=>o(r.did,r,this,n)):{...Ao,didResolutionMetadata:{error:"unsupportedDidMethod"}}}};function lr(e,t){return function(){return e.apply(t,arguments)}}var{toString:Hm}=Object.prototype,{getPrototypeOf:bt}=Object,{iterator:pr,toStringTag:Ql}=Symbol,fr=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),ef=e=>typeof e=="string"&&(e==="__proto__"||e==="constructor"||e==="prototype"),tf=(e,t,n)=>e===Object.prototype||!n&&t===null,Gm=e=>{if(!Object.isExtensible(e))return!1;let t=Object.getOwnPropertyNames(e);return Object.getOwnPropertySymbols&&t.push(...Object.getOwnPropertySymbols(e)),t.every(n=>{if(ef(n))return!1;let r=Object.getOwnPropertyDescriptor(e,n);return!!r&&r.configurable&&r.writable===!0})},dr=(e,t)=>{let n=e,r=[];for(;n!=null;){if(r.indexOf(n)!==-1)return!1;r.push(n);let o=bt(n);if(tf(n,o,n===e))return!1;if(fr(n,t))return!0;n=o}return!1},qm=(e,t)=>e!=null&&dr(e,t)?e[t]:void 0,Jm=e=>{if(e==null||typeof e!="object"&&typeof e!="function")return e;let t=bt(e);if(t===null&&Gm(e))return e;let n=Object.create(null),r=Object.create(null),o=[],i=e;for(;i!=null&&o.indexOf(i)===-1;){o.push(i);let s=i===e?t:bt(i);if(tf(i,s,i===e))break;let a=Object.getOwnPropertyNames(i);Object.getOwnPropertySymbols&&a.push(...Object.getOwnPropertySymbols(i));for(let c of a)ef(c)||fr(r,c)||(n[c]=e[c],r[c]=!0);i=s}return n},Ss=(e=>t=>{let n=Hm.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),ze=e=>(e=e.toLowerCase(),t=>Ss(t)===e),Po=e=>t=>typeof t===e,{isArray:Ft}=Array,Ht=Po("undefined");function _n(e){return e!==null&&!Ht(e)&&e.constructor!==null&&!Ht(e.constructor)&&ye(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var nf=ze("ArrayBuffer");function Km(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&nf(e.buffer),t}var Vm=Po("string"),ye=Po("function"),rf=Po("number"),bn=e=>e!==null&&typeof e=="object",Wm=e=>e===!0||e===!1,To=e=>{if(!bn(e))return!1;let t=bt(e);return(t===null||t===Object.prototype||bt(t)===null)&&!dr(e,Ql)&&!dr(e,pr)},Xm=e=>{if(!bn(e)||_n(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},Ym=ze("Date"),Qm=ze("File"),eg=e=>!!(e&&typeof e.uri<"u"),tg=e=>e&&typeof e.getParts<"u",ng=ze("Blob"),rg=ze("FileList"),og=ze("Set"),ig=e=>bn(e)&&ye(e.pipe);function sg(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}var Xl=sg(),Yl=typeof Xl.FormData<"u"?Xl.FormData:void 0,ag=e=>{if(!e)return!1;if(Yl&&e instanceof Yl)return!0;let t=bt(e);if(!t||t===Object.prototype||!ye(e.append))return!1;let n=Ss(e);return n==="formdata"||n==="object"&&ye(e.toString)&&e.toString()==="[object FormData]"},cg=ze("URLSearchParams"),[ug,lg,fg,dg]=["ReadableStream","Request","Response","Headers"].map(ze),pg=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function hr(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),Ft(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(_n(e))return;let i=n?Object.getOwnPropertyNames(e):Object.keys(e),s=i.length,a;for(r=0;r<s;r++)a=i[r],t.call(null,e[a],a,e)}}function of(e,t){if(_n(e))return null;t=t.toLowerCase();let n=Object.keys(e),r=n.length,o;for(;r-- >0;)if(o=n[r],t===o.toLowerCase())return o;return null}var Zt=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,sf=e=>!Ht(e)&&e!==Zt;function vs(...e){let{caseless:t,skipUndefined:n}=sf(this)&&this||{},r={},o=(i,s)=>{if(s==="__proto__"||s==="constructor"||s==="prototype")return;let a=t&&typeof s=="string"&&of(r,s)||s,c=fr(r,a)?r[a]:void 0;To(c)&&To(i)?r[a]=vs(c,i):To(i)?r[a]=vs({},i):Ft(i)?r[a]=i.slice():(!n||!Ht(i))&&(r[a]=i)};for(let i=0,s=e.length;i<s;i++){let a=e[i];if(!a||_n(a)||(hr(a,o),typeof a!="object"||Ft(a)))continue;let c=Object.getOwnPropertySymbols(a);for(let u=0;u<c.length;u++){let l=c[u];Ag.call(a,l)&&o(a[l],l)}}return r}var hg=(e,t,n,{allOwnKeys:r}={})=>(hr(t,(o,i)=>{n&&ye(o)?Object.defineProperty(e,i,{__proto__:null,value:lr(o,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,i,{__proto__:null,value:o,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),e),mg=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),gg=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),Object.defineProperty(e.prototype,"constructor",{__proto__:null,value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,"super",{__proto__:null,value:t.prototype}),n&&Object.assign(e.prototype,n)},yg=(e,t,n,r)=>{let o,i,s,a={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),i=o.length;i-- >0;)s=o[i],(!r||r(s,e,t))&&!a[s]&&(t[s]=e[s],a[s]=!0);e=n!==!1&&bt(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},wg=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;let r=e.indexOf(t,n);return r!==-1&&r===n},_g=e=>{if(!e)return null;if(Ft(e))return e;let t=e.length;if(!rf(t))return null;let n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},bg=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&bt(Uint8Array)),xg=(e,t)=>{let r=(e&&e[pr]).call(e),o;for(;(o=r.next())&&!o.done;){let i=o.value;t.call(e,i[0],i[1])}},Eg=(e,t)=>{let n,r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},vg=ze("HTMLFormElement"),Sg=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),{propertyIsEnumerable:Ag}=Object.prototype,Rg=ze("RegExp"),af=(e,t)=>{let n=Object.getOwnPropertyDescriptors(e),r={};hr(n,(o,i)=>{let s;(s=t(o,i,e))!==!1&&(r[i]=s||o)}),Object.defineProperties(e,r)},Tg=e=>{af(e,(t,n)=>{if(ye(e)&&["arguments","caller","callee"].includes(n))return!1;let r=e[n];if(ye(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},Pg=(e,t)=>{let n={},r=o=>{o.forEach(i=>{n[i]=!0})};return Ft(e)?r(e):r(String(e).split(t)),n},Og=()=>{},kg=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Ig(e){return!!(e&&ye(e.append)&&e[Ql]==="FormData"&&e[pr])}var zg=e=>{let t=new WeakSet,n=r=>{if(bn(r)){if(t.has(r))return;if(_n(r))return r;if(!("toJSON"in r)){t.add(r);let o;if(og(r)){o=[];for(let i of r){let s=n(i);!Ht(s)&&o.push(s)}}else o=Ft(r)?[]:{},hr(r,(i,s)=>{let a=n(i);!Ht(a)&&(o[s]=a)});return t.delete(r),o}}return r};return n(e)},Cg=ze("AsyncFunction"),$g=e=>e&&(bn(e)||ye(e))&&ye(e.then)&&ye(e.catch),cf=((e,t)=>e?setImmediate:t?((n,r)=>(Zt.addEventListener("message",({source:o,data:i})=>{o===Zt&&i===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Zt.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",ye(Zt.postMessage)),Dg=typeof queueMicrotask<"u"?queueMicrotask.bind(Zt):typeof process<"u"&&process.nextTick||cf,uf=e=>e!=null&&ye(e[pr]),Ug=e=>e!=null&&dr(e,pr)&&uf(e),p={isArray:Ft,isArrayBuffer:nf,isBuffer:_n,isFormData:ag,isArrayBufferView:Km,isString:Vm,isNumber:rf,isBoolean:Wm,isObject:bn,isPlainObject:To,isEmptyObject:Xm,isReadableStream:ug,isRequest:lg,isResponse:fg,isHeaders:dg,isUndefined:Ht,isDate:Ym,isFile:Qm,isReactNativeBlob:eg,isReactNative:tg,isBlob:ng,isRegExp:Rg,isFunction:ye,isStream:ig,isURLSearchParams:cg,isTypedArray:bg,isFileList:rg,forEach:hr,merge:vs,extend:hg,trim:pg,stripBOM:mg,inherits:gg,toFlatObject:yg,kindOf:Ss,kindOfTest:ze,endsWith:wg,toArray:_g,forEachEntry:xg,matchAll:Eg,isHTMLForm:vg,hasOwnProperty:fr,hasOwnProp:fr,hasOwnInPrototypeChain:dr,getSafeProp:qm,toSafeFlatObject:Jm,reduceDescriptors:af,freezeMethods:Tg,toObjectSet:Pg,toCamelCase:Sg,noop:Og,toFiniteNumber:kg,findKey:of,global:Zt,isContextDefined:sf,isSpecCompliantForm:Ig,toJSONObject:zg,isAsyncFn:Cg,isThenable:$g,setImmediate:cf,asap:Dg,isIterable:uf,isSafeIterable:Ug};var Mg=p.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),lf=e=>{let t={},n,r,o;return e&&e.split(`
|
|
3
|
+
`).forEach(function(s){o=s.indexOf(":"),n=s.substring(0,o).trim().toLowerCase(),r=s.substring(o+1).trim();let a=p.hasOwnProp(t,n);!n||a&&p.hasOwnProp(Mg,n)||(n==="set-cookie"?a?t[n].push(r):t[n]=[r]:t[n]=a?t[n]+", "+r:r)}),t};function Lg(e){let t=0,n=e.length;for(;t<n;){let r=e.charCodeAt(t);if(r!==9&&r!==32)break;t+=1}for(;n>t;){let r=e.charCodeAt(n-1);if(r!==9&&r!==32)break;n-=1}return t===0&&n===e.length?e:e.slice(t,n)}var Ng=new RegExp("[\\u0000-\\u0008\\u000a-\\u001f\\u007f]+","g"),Bg=new RegExp("[^\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+","g");function As(e,t){return p.isArray(e)?e.map(n=>As(n,t)):Lg(String(e).replace(t,""))}var ff=e=>As(e,Ng),jg=e=>As(e,Bg);function Oo(e){let t=Object.create(null);return p.forEach(e.toJSON(),(n,r)=>{t[r]=jg(n)}),t}var df=Symbol("internals");function mr(e){return e&&String(e).trim().toLowerCase()}function ko(e){return e===!1||e==null?e:p.isArray(e)?e.map(ko):ff(String(e))}function Zg(e){let t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}var Fg=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;function Rs(e){let t=0,n=e.length;for(;t<n;){let r=e.charCodeAt(t);if(r!==9&&r!==32)break;t+=1}for(;n>t;){let r=e.charCodeAt(n-1);if(r!==9&&r!==32)break;n-=1}return t===0&&n===e.length?e:e.slice(t,n)}function Hg(e){let t=e.length-1;if(t<1||e.charCodeAt(0)!==34||e.charCodeAt(t)!==34)return e;let n="";for(let r=1;r<t;r++){let o=e.charCodeAt(r);if(o===34||o===92&&(r+=1,r>=t))return e;n+=e[r]}return n}function Gg(e){let t=Object.create(null),n=String(e),r=0,o=!1,i=!1;function s(a){let c=Rs(n.slice(r,a)),u=c.indexOf("=");if(u<1)return;let l=Rs(c.slice(0,u));if(!Fg.test(l))return;let f=l.toLowerCase();if(f==="__proto__"||f==="constructor"||f==="prototype")return;let d=Rs(c.slice(u+1));t[f]=Hg(d)}for(let a=0;a<n.length;a++){let c=n.charCodeAt(a);o?i?i=!1:c===92?i=!0:c===34&&(o=!1):c===34?o=!0:(c===44||c===59)&&(s(a),r=a+1)}return s(n.length),t}var qg=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Ts(e,t,n,r,o){if(p.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!p.isString(t)){if(p.isString(r))return t.indexOf(r)!==-1;if(p.isRegExp(r))return r.test(t)}}function Jg(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Kg(e,t){let n=p.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{__proto__:null,value:function(o,i,s){return this[r].call(this,t,o,i,s)},configurable:!0})})}var xn=class{constructor(t){t&&this.set(t)}set(t,n,r){let o=this;function i(a,c,u){let l=mr(c);if(!l)return;let f=p.findKey(o,l);(!f||o[f]===void 0||u===!0||u===void 0&&o[f]!==!1)&&(o[f||c]=ko(a))}let s=(a,c)=>p.forEach(a,(u,l)=>i(u,l,c));if(p.isPlainObject(t)||t instanceof this.constructor)s(t,n);else if(p.isString(t)&&(t=t.trim())&&!qg(t))s(lf(t),n);else if(p.isObject(t)&&p.isSafeIterable(t)){let a=Object.create(null),c,u;for(let l of t){if(!p.isArray(l))throw new TypeError("Object iterator must return a key-value pair");u=l[0],p.hasOwnProp(a,u)?(c=a[u],a[u]=p.isArray(c)?[...c,l[1]]:[c,l[1]]):a[u]=l[1]}s(a,n)}else t!=null&&i(n,t,r);return this}get(t,n){if(t=mr(t),t){let r=p.findKey(this,t);if(r){let o=this[r];if(!n)return o;if(n===!0)return Zg(o);if(p.isFunction(n))return n.call(this,o,r);if(p.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=mr(t),t){let r=p.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||Ts(this,this[r],r,n)))}return!1}delete(t,n){let r=this,o=!1;function i(s){if(s=mr(s),s){let a=p.findKey(r,s);a&&(!n||Ts(r,r[a],a,n))&&(delete r[a],o=!0)}}return p.isArray(t)?t.forEach(i):i(t),o}clear(t){let n=Object.keys(this),r=n.length,o=!1;for(;r--;){let i=n[r];(!t||Ts(this,this[i],i,t,!0))&&(delete this[i],o=!0)}return o}normalize(t){let n=this,r={};return p.forEach(this,(o,i)=>{let s=p.findKey(r,i);if(s){n[s]=ko(o),delete n[i];return}let a=t?Jg(i):String(i).trim();a!==i&&delete n[i],n[a]=ko(o),r[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){let n=Object.create(null);return p.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&p.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(`
|
|
4
|
+
`)}getSetCookie(){let t=this.get("set-cookie");return p.isArray(t)?t:t==null||t===!1?[]:[t]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static parseParameters(t){return Gg(t)}static concat(t,...n){let r=new this(t);return n.forEach(o=>r.set(o)),r}static accessor(t){let r=(this[df]=this[df]={accessors:{}}).accessors,o=this.prototype;function i(s){let a=mr(s);r[a]||(Kg(o,s),r[a]=!0)}return p.isArray(t)?t.forEach(i):i(t),this}};xn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);p.reduceDescriptors(xn.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}});p.freezeMethods(xn);var ee=xn;var gr="[REDACTED ****]";function Vg(e){if(p.hasOwnProp(e,"toJSON"))return!0;let t=Object.getPrototypeOf(e);for(;t&&t!==Object.prototype;){if(p.hasOwnProp(t,"toJSON"))return!0;t=Object.getPrototypeOf(t)}return!1}function Wg(e,t){let n=new Set(t.map(i=>String(i).toLowerCase())),r=[],o=i=>{if(i===null||typeof i!="object"||p.isBuffer(i))return i;if(r.indexOf(i)!==-1)return;i instanceof ee&&(i=i.toJSON()),r.push(i);let s;if(p.isArray(i))s=[],i.forEach((a,c)=>{let u=o(a);p.isUndefined(u)||(s[c]=u)});else{if(!p.isPlainObject(i)&&Vg(i))return r.pop(),i;s=Object.create(null);for(let[a,c]of Object.entries(i)){let u=n.has(a.toLowerCase())?gr:o(c);p.isUndefined(u)||(s[a]=u)}}return r.pop(),s};return o(e)}function pf(e){try{return String(e)}catch{return""}}function Xg(e){return e.errors.map(n=>{try{return n&&n.message?pf(n.message):pf(n)}catch{return""}}).filter(Boolean).join("; ")||e.name||"AggregateError"}var ue=class e extends Error{static from(t,n,r,o,i,s){let a=t.message;!a&&p.isArray(t.errors)&&t.errors.length&&(a=Xg(t));let c=new e(a,n||t.code,r,o,i);return Object.defineProperty(c,"cause",{__proto__:null,value:t,writable:!0,enumerable:!1,configurable:!0}),c.name=t.name,t.status!=null&&c.status==null&&(c.status=t.status),s&&Object.assign(c,s),c}constructor(t,n,r,o,i){super(t),Object.defineProperty(this,"message",{__proto__:null,value:t,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,n&&(this.code=n),r&&(this.config=r),o&&(this.request=o),i&&(this.response=i,this.status=i.status)}toJSON(){let t=this.config,n=t&&p.hasOwnProp(t,"redact")?t.redact:void 0,r=p.isArray(n)&&n.length>0?Wg(t,n):p.toJSONObject(t);return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:r,code:this.code,status:this.status}}};ue.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";ue.ERR_BAD_OPTION="ERR_BAD_OPTION";ue.ECONNABORTED="ECONNABORTED";ue.ETIMEDOUT="ETIMEDOUT";ue.ECONNREFUSED="ECONNREFUSED";ue.ERR_NETWORK="ERR_NETWORK";ue.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";ue.ERR_DEPRECATED="ERR_DEPRECATED";ue.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";ue.ERR_BAD_REQUEST="ERR_BAD_REQUEST";ue.ERR_CANCELED="ERR_CANCELED";ue.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";ue.ERR_INVALID_URL="ERR_INVALID_URL";ue.ERR_FORM_DATA_DEPTH_EXCEEDED="ERR_FORM_DATA_DEPTH_EXCEEDED";var T=ue;var xt=null;var ks=100;function Os(e){return p.isPlainObject(e)||p.isArray(e)}function hf(e){return p.endsWith(e,"[]")?e.slice(0,-2):e}function Ps(e,t,n){return e?e.concat(t).map(function(o,i){return o=hf(o),!n&&i?"["+o+"]":o}).join(n?".":""):t}function Yg(e){return p.isArray(e)&&!e.some(Os)}var Qg=p.toFlatObject(p,{},null,function(t){return/^is[A-Z]/.test(t)});function ey(e,t,n){if(!p.isObject(e))throw new TypeError("target must be an object");t=t||new(xt||FormData);let r=(_,x)=>{let E=p.getSafeProp(n,_);return p.isUndefined(E)?x:E},o=r("metaTokens",!0),i=r("visitor")||b,s=r("dots",!1),a=r("indexes",!1),c=r("Blob")||typeof Blob<"u"&&Blob,u=r("maxDepth",ks),l=c&&p.isSpecCompliantForm(t),f=[];if(!p.isFunction(i))throw new TypeError("visitor must be a function");function d(_){if(_===null)return"";if(p.isDate(_))return _.toISOString();if(p.isBoolean(_))return _.toString();if(!l&&p.isBlob(_))throw new T("Blob is not supported. Use a Buffer instead.");if(p.isArrayBuffer(_)||p.isTypedArray(_)){if(l&&typeof c=="function")return new c([_]);if(xt&&xt.isBufferAvailable())return xt.from(_);throw new T("Blob is not supported. Use a Buffer instead.",T.ERR_NOT_SUPPORT)}return _}function m(_){if(_>u)throw new T("Object is too deeply nested ("+_+" levels). Max depth: "+u,T.ERR_FORM_DATA_DEPTH_EXCEEDED)}function w(_,x){if(u===1/0)return JSON.stringify(_);let E=[];return JSON.stringify(_,function(k,I){if(!p.isObject(I))return I;for(;E.length&&E[E.length-1]!==this;)E.pop();return E.push(I),m(x+E.length-1),I})}function b(_,x,E){let A=_;if(p.isReactNative(t)&&p.isReactNativeBlob(_))return t.append(Ps(E,x,s),d(_)),!1;if(_&&!E&&typeof _=="object"){if(p.endsWith(x,"{}"))x=o?x:x.slice(0,-2),_=w(_,1);else if(p.isArray(_)&&Yg(_)||(p.isFileList(_)||p.endsWith(x,"[]"))&&(A=p.toArray(_)))return x=hf(x),A.forEach(function(I,U){!(p.isUndefined(I)||I===null)&&t.append(a===!0?Ps([x],U,s):a===null?x:x+"[]",d(I))}),!1}return Os(_)?!0:(t.append(Ps(E,x,s),d(_)),!1)}let S=Object.assign(Qg,{defaultVisitor:b,convertValue:d,isVisitable:Os});function h(_,x,E=0){if(!p.isUndefined(_)){if(m(E),f.indexOf(_)!==-1)throw new Error("Circular reference detected in "+x.join("."));f.push(_),p.forEach(_,function(k,I){(!(p.isUndefined(k)||k===null)&&i.call(t,k,p.isString(I)?I.trim():I,x,S))===!0&&h(k,x?x.concat(I):[I],E+1)}),f.pop()}}if(!p.isObject(e))throw new TypeError("data must be an object");return h(e),t}var Et=ey;function mf(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"};return encodeURIComponent(e).replace(/[!'()~]|%20/g,function(r){return t[r]})}function gf(e,t){this._pairs=[],e&&Et(e,this,t)}var yf=gf.prototype;yf.append=function(t,n){this._pairs.push([t,n])};yf.toString=function(t){let n=t?r=>t.call(this,r,mf):mf;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};var Io=gf;function ty(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function yr(e,t,n){if(!t)return e;e=e||"";let r=p.isFunction(n)?{serialize:n}:n,o=p.getSafeProp(r,"encode")||ty,i=p.getSafeProp(r,"serialize"),s;if(i?s=i(t,r):s=p.isURLSearchParams(t)?t.toString():new Io(t,r).toString(o),s){let a=e.indexOf("#");a!==-1&&(e=e.slice(0,a)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}var wr=Symbol("internals");function _f(e){return e?e.length:0}function wf(e){if(e)for(;e.length&&e[e.length-1]===null;)e.pop()}function _r(e,t){let n=e.handlers,r=_f(n);n!==t.handlersRef?(t.handlersRef=n,t.handlerEntries.clear()):r!==t.handlersLength&&(r?t.handlerEntries.forEach(function(i,s){n[i.index]!==i.handler&&t.handlerEntries.delete(s)}):t.handlerEntries.clear()),t.handlersLength=r}var Is=class{constructor(){this.handlers=[],this[wr]={handlersRef:this.handlers,handlersLength:this.handlers.length,handlerEntries:new Map,iterationDepth:0,nextId:0}}use(t,n,r){let o={fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null},i=this[wr];this.handlers==null&&(this.handlers=[]),_r(this,i);let s=i.nextId++;return this.handlers.push(o),i.handlerEntries.set(s,{handler:o,index:this.handlers.length-1}),i.handlersLength=this.handlers.length,s}eject(t){let n=this[wr];_r(this,n);let r=n.handlerEntries.get(t);if(r){if(n.handlerEntries.delete(t),this.handlers[r.index]!==r.handler)return;this.handlers[r.index]=null,n.iterationDepth||(wf(this.handlers),n.handlersLength=this.handlers.length)}}clear(){this.handlers&&(this.handlers=[],_r(this,this[wr]))}forEach(t){let n=this[wr];_r(this,n),n.iterationDepth++;try{p.forEach(this.handlers,function(o){o!==null&&t(o)})}finally{--n.iterationDepth||(_r(this,n),wf(this.handlers),n.handlersLength=_f(this.handlers))}}},zs=Is;var En={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0,advertiseZstdAcceptEncoding:!1,validateStatusUndefinedResolves:!0};var bf=typeof URLSearchParams<"u"?URLSearchParams:Io;var xf=typeof FormData<"u"?FormData:null;var Ef=typeof Blob<"u"?Blob:null;var vf={isBrowser:!0,classes:{URLSearchParams:bf,FormData:xf,Blob:Ef},protocols:["http","https","file","blob","url","data"]};var Ds={};_p(Ds,{hasBrowserEnv:()=>$s,hasStandardBrowserEnv:()=>ny,hasStandardBrowserWebWorkerEnv:()=>ry,navigator:()=>Cs,origin:()=>oy});var $s=typeof window<"u"&&typeof document<"u",Cs=typeof navigator=="object"&&navigator||void 0,ny=$s&&(!Cs||["ReactNative","NativeScript","NS"].indexOf(Cs.product)<0),ry=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",oy=$s&&window.location.href||"http://localhost";var W={...Ds,...vf};function Us(e,t){return Et(e,new W.classes.URLSearchParams,{visitor:function(n,r,o,i){return W.isNode&&p.isBuffer(n)?(this.append(r,n.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)},...t})}var Sf=ks;function Af(e){if(e>Sf)throw new T("FormData field is too deeply nested ("+e+" levels). Max depth: "+Sf,T.ERR_FORM_DATA_DEPTH_EXCEEDED)}function iy(e){let t=[],n=/[^.[\]]+|\[([^.[\]]*)]/g,r;for(;(r=n.exec(e))!==null;)Af(t.length),t.push(r[0]==="[]"?"":r[1]||r[0]);return t}function sy(e){let t={},n=Object.keys(e),r,o=n.length,i;for(r=0;r<o;r++)i=n[r],t[i]=e[i];return t}function ay(e){function t(n,r,o,i){Af(i);let s=n[i++];if(s==="__proto__")return!0;let a=Number.isFinite(+s),c=i>=n.length;return s=!s&&p.isArray(o)?o.length:s,c?(p.hasOwnProp(o,s)?o[s]=p.isArray(o[s])?o[s].concat(r):[o[s],r]:o[s]=r,!a):((!p.hasOwnProp(o,s)||!p.isObject(o[s]))&&(o[s]=[]),t(n,r,o[s],i)&&p.isArray(o[s])&&(o[s]=sy(o[s])),!a)}if(p.isFormData(e)&&p.isFunction(e.entries)){let n={};return p.forEachEntry(e,(r,o)=>{t(iy(r),o,n,0)}),n}return null}var zo=ay;var cy=Object.freeze(["get","delete","head","options","post","put","patch","purge","link","unlink","query"]),Co=cy;var vn=(e,t)=>e!=null&&p.hasOwnProp(e,t)?e[t]:void 0;function uy(e,t,n){if(p.isString(e))try{return(t||JSON.parse)(e),p.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}var Ms={transitional:En,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){let r=n.getContentType()||"",o=r.indexOf("application/json")>-1,i=p.isObject(t);if(i&&p.isHTMLForm(t)&&(t=new FormData(t)),p.isFormData(t))return o?JSON.stringify(zo(t)):t;if(p.isArrayBuffer(t)||p.isBuffer(t)||p.isStream(t)||p.isFile(t)||p.isBlob(t)||p.isReadableStream(t))return t;if(p.isArrayBufferView(t))return t.buffer;if(p.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let a;if(i){let c=vn(this,"formSerializer");if(r.indexOf("application/x-www-form-urlencoded")>-1)return Us(t,c).toString();if((a=p.isFileList(t))||r.indexOf("multipart/form-data")>-1){let u=vn(this,"env"),l=u&&u.FormData;return Et(a?{"files[]":t}:t,l&&new l,c)}}return i||o?(n.setContentType("application/json",!1),uy(t)):t}],transformResponse:[function(t){let n=vn(this,"transitional")||Ms.transitional,r=n&&n.forcedJSONParsing,o=vn(this,"responseType"),i=o==="json";if(p.isResponse(t)||p.isReadableStream(t))return t;if(t&&p.isString(t)&&(r&&!o||i)){let a=!(n&&n.silentJSONParsing)&&i;try{return JSON.parse(t,vn(this,"parseReviver"))}catch(c){if(a)throw c.name==="SyntaxError"?T.from(c,T.ERR_BAD_RESPONSE,this,null,vn(this,"response")):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:W.classes.FormData,Blob:W.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};p.forEach(Co,e=>{Ms.headers[e]={}});var Sn=Ms;function br(e,t){let n=this||Sn,r=t||n,o=ee.from(r.headers),i=r.data;return p.forEach(e,function(a){i=a.call(n,i,o.normalize(),t?t.status:void 0)}),o.normalize(),i}function xr(e){return!!(e&&e.__CANCEL__)}var Ls=class extends T{constructor(t,n,r){super(t??"canceled",T.ERR_CANCELED,n,r),this.name="CanceledError",this.__CANCEL__=!0}},Ke=Ls;function Er(e,t,n){let r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new T("Request failed with status code "+n.status,n.status>=400&&n.status<500?T.ERR_BAD_REQUEST:T.ERR_BAD_RESPONSE,n.config,n.request,n))}var ly=/[\t\n\r]/g;function vr(e){if(typeof e!="string")return e;let t=0;for(;t<e.length&&e.charCodeAt(t)<=32;)t++;return e.slice(t).replace(ly,"")}function Sr(e){let t=/^([-+\w]{1,25}):(?:\/\/)?/.exec(e);return t&&t[1]||""}function fy(e,t){e=e||10;let n=new Array(e),r=new Array(e),o=0,i=0,s;return t=t!==void 0?t:1e3,function(c){let u=Date.now(),l=r[i];s||(s=u),n[o]=c,r[o]=u;let f=i,d=0;for(;f!==o;)d+=n[f++],f=f%e;if(o=(o+1)%e,o===i&&(i=(i+1)%e),u-s<t)return;let m=l&&u-l;return m?Math.round(d*1e3/m):void 0}}var Rf=fy;function dy(e,t){let n=0,r=1e3/t,o,i,s=(l,f=Date.now())=>{n=f,o=null,i&&(clearTimeout(i),i=null),e(...l)};return[(...l)=>{let f=Date.now(),d=f-n;d>=r?s(l,f):(o=l,i||(i=setTimeout(()=>{i=null,s(o)},r-d)))},()=>o&&s(o),(...l)=>s(l)]}var Tf=dy;var An=(e,t,n=3)=>{let r=0,o=Rf(50,250);return Tf(i=>{if(!i||!p.isNumber(i.loaded))return;let s=i.loaded,a=i.lengthComputable?i.total:void 0,c=Math.max(0,a!=null?Math.min(s,a):s),u=Math.max(0,c-r),l=o(u);r=Math.max(r,c);let f={loaded:c,total:a,progress:a?c/a:void 0,bytes:u,rate:l||void 0,estimated:l&&a?(a-c)/l:void 0,event:i,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(f)},n)},Ns=(e,t)=>{let n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Bs=(e,t=p.asap)=>(...n)=>t(()=>e(...n));var Pf=W.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,W.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(W.origin),W.navigator&&/(msie|trident)/i.test(W.navigator.userAgent)):()=>!0;var Of=W.hasStandardBrowserEnv?{write(e,t,n,r,o,i,s){if(typeof document>"u")return;let a=[`${e}=${encodeURIComponent(t)}`];p.isNumber(n)&&a.push(`expires=${new Date(n).toUTCString()}`),p.isString(r)&&a.push(`path=${r}`),p.isString(o)&&a.push(`domain=${o}`),i===!0&&a.push("secure"),p.isString(s)&&a.push(`SameSite=${s}`),document.cookie=a.join("; ")},read(e){if(typeof document>"u")return null;let t=document.cookie.split(";");for(let n=0;n<t.length;n++){let r=t[n].replace(/^\s+/,""),o=r.indexOf("=");if(o!==-1&&r.slice(0,o)===e)try{return decodeURIComponent(r.slice(o+1))}catch{return r.slice(o+1)}}return null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function js(e){return typeof e!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Zs(e,t){if(!t)return e;let n=e.length;for(;n>0&&e.charCodeAt(n-1)===47;)n--;return e.slice(0,n)+"/"+t.replace(/^\/+/,"")}var py=/^https?:(?!\/\/)/i;function hy(e){return e&&e.replace(/(^|&)([^=&]*=)?[^&]+/g,(t,n,r="")=>`${n}${r}${gr}`)}function my(e){let t=e.replace(/^(https?:\/{0,2})[^/?#]*@/i,`$1${gr}@`),n=t.indexOf("#"),o=(n===-1?t:t.slice(0,n)).replace(/([?&][^=&#]*=)[^&#]*/g,`$1${gr}`);return n===-1?o:`${o}#${hy(t.slice(n+1))}`}function kf(e,t){if(typeof e=="string"){let n=vr(e);if(py.test(n))throw new T(`Invalid URL ${JSON.stringify(my(n))}: missing "//" after protocol`,T.ERR_INVALID_URL,t)}}function Ar(e,t,n,r){kf(t,r);let o=!js(t);return e&&(o||n===!1)?(kf(e,r),Zs(e,t)):t}var If=e=>e instanceof ee?{...e}:e,gy=e=>Object.getOwnPropertySymbols&&Object.getOwnPropertyDescriptor?Object.keys(e).concat(Object.getOwnPropertySymbols(e).filter(t=>Object.getOwnPropertyDescriptor(e,t).enumerable)):Object.keys(e);function Be(e,t){e=e||{},t=t||{};let n=Object.create(null);Object.defineProperty(n,"hasOwnProperty",{__proto__:null,value:Object.prototype.hasOwnProperty,enumerable:!1,writable:!0,configurable:!0});function r(l,f,d,m){return p.isPlainObject(l)&&p.isPlainObject(f)?p.merge.call({caseless:m},l,f):p.isPlainObject(f)?p.merge({},f):p.isArray(f)?f.slice():f}function o(l,f,d,m){if(p.isUndefined(f)){if(!p.isUndefined(l))return r(void 0,l,d,m)}else return r(l,f,d,m)}function i(l,f){if(!p.isUndefined(f))return r(void 0,f)}function s(l,f){if(p.isUndefined(f)){if(!p.isUndefined(l))return r(void 0,l)}else return r(void 0,f)}function a(l){let f=p.hasOwnProp(t,"transitional")?t.transitional:void 0;if(!p.isUndefined(f))if(p.isPlainObject(f)){if(p.hasOwnProp(f,l))return f[l]}else return;let d=p.hasOwnProp(e,"transitional")?e.transitional:void 0;if(p.isPlainObject(d)&&p.hasOwnProp(d,l))return d[l]}function c(l,f,d){if(p.hasOwnProp(t,d))return r(l,f);if(p.hasOwnProp(e,d))return r(void 0,l)}let u={url:i,method:i,data:i,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutErrorMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,allowedSocketPaths:s,responseEncoding:s,validateStatus:c,headers:(l,f,d)=>o(If(l),If(f),d,!0)};return p.forEach(gy({...e,...t}),function(f){if(f==="__proto__"||f==="constructor"||f==="prototype")return;let d=p.hasOwnProp(u,f)?u[f]:o,m=p.hasOwnProp(e,f)?e[f]:void 0,w=p.hasOwnProp(t,f)?t[f]:void 0,b=d(m,w,f);p.isUndefined(b)&&d!==c||(n[f]=b)}),p.hasOwnProp(t,"validateStatus")&&p.isUndefined(t.validateStatus)&&a("validateStatusUndefinedResolves")===!1&&(p.hasOwnProp(e,"validateStatus")?n.validateStatus=r(void 0,e.validateStatus):delete n.validateStatus),n}var yy=["content-type","content-length"];function Fs(e,t,n){if(n!=="content-only"){e.set(t);return}Object.entries(t||{}).forEach(([r,o])=>{yy.includes(r.toLowerCase())&&e.set(r,o)})}var wy=e=>encodeURIComponent(e).replace(/%([0-9A-F]{2})/gi,(t,n)=>String.fromCharCode(parseInt(n,16)));function _y(e){let t=Be({},e),n=d=>p.hasOwnProp(t,d)?t[d]:void 0,r=n("data"),o=n("withXSRFToken"),i=n("xsrfHeaderName"),s=n("xsrfCookieName"),a=n("headers"),c=n("auth"),u=n("baseURL"),l=n("allowAbsoluteUrls"),f=n("url");if(t.headers=a=ee.from(a),t.url=yr(Ar(u,f,l,t),n("params"),n("paramsSerializer")),c){let d=p.getSafeProp(c,"username")||"",m=p.getSafeProp(c,"password")||"";try{a.set("Authorization","Basic "+btoa(d+":"+(m?wy(m):"")))}catch(w){throw T.from(w,T.ERR_BAD_OPTION_VALUE,e)}}if(p.isFormData(r)){let d=p.getSafeProp(r,"getHeaders");W.hasStandardBrowserEnv||W.hasStandardBrowserWebWorkerEnv||p.isReactNative(r)?a.setContentType(void 0):p.isFunction(d)&&Fs(a,d.call(r),n("formDataHeaderPolicy"))}if(W.hasStandardBrowserEnv&&(p.isFunction(o)&&(o=o(t)),o===!0||o==null&&Pf(t.url))){let m=i&&s&&Of.read(s);m&&a.set(i,m)}return t}var $o=_y;var by=typeof XMLHttpRequest<"u",zf=by&&function(e){return new Promise(function(n,r){let o=$o(e),i=o.data,s=ee.from(o.headers).normalize(),{responseType:a,onUploadProgress:c,onDownloadProgress:u}=o,l,f,d,m,w,b;function S(){m&&m(),w&&w(),o.cancelToken&&o.cancelToken.unsubscribe(l),o.signal&&o.signal.removeEventListener("abort",l)}let h=new XMLHttpRequest;h.open(o.method.toUpperCase(),o.url,!0),h.timeout=o.timeout;function _(E){if(!h)return;if(h.status===0&&(Sr(vr(o.url))||Sr(W.origin))!=="file"&&!(h.responseURL&&h.responseURL.startsWith("file:"))){r(new T("Request aborted",T.ECONNABORTED,e,h)),S(),h=null;return}try{E?b&&b(E):w&&w()}catch(U){setTimeout(()=>{throw U})}if(!h)return;let A=ee.from("getAllResponseHeaders"in h&&h.getAllResponseHeaders()),I={data:!a||a==="text"||a==="json"?h.responseText:h.response,status:h.status,statusText:h.statusText,headers:A,config:e,request:h};Er(function(V){n(V),S()},function(V){r(V),S()},I),h=null}"onloadend"in h?h.onloadend=_:h.onreadystatechange=function(){!h||h.readyState!==4||h.status===0&&!(h.responseURL&&h.responseURL.startsWith("file:"))||setTimeout(_)},h.onabort=function(){h&&(r(new T("Request aborted",T.ECONNABORTED,e,h)),S(),h=null)},h.onerror=function(A){let k=A&&A.message?A.message:"Network Error",I=new T(k,T.ERR_NETWORK,e,h);I.event=A||null,r(I),S(),h=null},h.ontimeout=function(){let A=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded",k=o.transitional||En;o.timeoutErrorMessage&&(A=o.timeoutErrorMessage),r(new T(A,k.clarifyTimeoutError?T.ETIMEDOUT:T.ECONNABORTED,e,h)),S(),h=null},i===void 0&&s.setContentType(null),"setRequestHeader"in h&&p.forEach(Oo(s),function(A,k){h.setRequestHeader(k,A)}),p.isUndefined(o.withCredentials)||(h.withCredentials=!!o.withCredentials),a&&a!=="json"&&(h.responseType=o.responseType),u&&([d,w,b]=An(u,!0),h.addEventListener("progress",d)),c&&h.upload&&([f,m]=An(c),h.upload.addEventListener("progress",f),h.upload.addEventListener("loadend",m)),(o.cancelToken||o.signal)&&(l=E=>{h&&(r(!E||E.type?new Ke(null,e,h):E),h.abort(),S(),h=null)},o.cancelToken&&o.cancelToken.subscribe(l),o.signal&&(o.signal.aborted?l():o.signal.addEventListener("abort",l)));let x=Sr(o.url);if(x&&!W.protocols.includes(x)){r(new T("Unsupported protocol "+x+":",T.ERR_BAD_REQUEST,e)),S();return}h.send(i||null)})};var xy=(e,t)=>{if(e=e?e.filter(Boolean):[],!t&&!e.length)return;let n=new AbortController,r=!1,o=function(c){if(!r){r=!0,s();let u=c instanceof Error?c:this.reason;n.abort(u instanceof T?u:new Ke(u instanceof Error?u.message:u))}},i=t&&setTimeout(()=>{i=null,o(new T(`timeout of ${t}ms exceeded`,T.ETIMEDOUT))},t),s=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(c=>{c.unsubscribe?c.unsubscribe(o):c.removeEventListener("abort",o)}),e=null)};e.forEach(c=>{if(!r){if(c.aborted){o.call(c);return}c.addEventListener("abort",o,{once:!0})}});let{signal:a}=n;return a.unsubscribe=()=>p.asap(s),a},Cf=xy;var Ey=function*(e,t){let n=e.byteLength;if(!t||n<t){yield e;return}let r=0,o;for(;r<n;)o=r+t,yield e.slice(r,o),r=o},vy=async function*(e,t){for await(let n of Sy(e))yield*Ey(n,t)},Sy=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}let t=e.getReader();try{for(;;){let{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},Hs=(e,t,n,r)=>{let o=vy(e,t),i=0,s,a=c=>{s||(s=!0,r&&r(c))};return new ReadableStream({async pull(c){try{let{done:u,value:l}=await o.next();if(u){a(),c.close();return}let f=l.byteLength;if(n){let d=i+=f;n(d)}c.enqueue(new Uint8Array(l))}catch(u){throw a(u),u}},cancel(c){return a(c),o.return()}},{highWaterMark:2})};var $f=e=>e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102,Uf=(e,t,n)=>t+2<n&&$f(e.charCodeAt(t+1))&&$f(e.charCodeAt(t+2)),Df=e=>e<=57?e-48:(e&223)-55,Ay=e=>e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===43||e===47||e===45||e===95,Ry=e=>e===9||e===10||e===12||e===13||e===32,Ty=e=>{let t=Math.floor(e/4),n=e%4;return t*3+(n===2?1:n===3?2:0)},Py=e=>{let t=e.length,n=0;return t>0&&e.charCodeAt(t-1)===61&&(n++,t>1&&e.charCodeAt(t-2)===61&&n++),Math.floor((t-n)*3/4)},Oy=e=>{let t=e.length,n=0,r=0,o=!1;for(let i=0;i<t;i++){let s=e.charCodeAt(i);if(s===37&&Uf(e,i,t)&&(s=Df(e.charCodeAt(i+1))*16+Df(e.charCodeAt(i+2)),i+=2),!Ry(s)){if(s===61){r++;continue}if(!Ay(s)||r>0){o=!0;continue}n++}}return o||r>2||r>0&&(n+r)%4!==0||n%4===1?Py(e):Ty(n)},ky=(e,t)=>{if(!e||typeof e!="string"||!e.startsWith("data:"))return 0;let n=e.indexOf(",");if(n<0)return 0;let r=e.slice(5,n),o=e.slice(n+1);if(/;base64/i.test(r))return t(o);let s=0;for(let a=0,c=o.length;a<c;a++){let u=o.charCodeAt(a);if(u===37&&Uf(o,a,c))s+=1,a+=2;else if(u<128)s+=1;else if(u<2048)s+=2;else if(u>=55296&&u<=56319&&a+1<c){let l=o.charCodeAt(a+1);l>=56320&&l<=57343?(s+=4,a++):s+=3}else s+=3}return s};function Gs(e){let t=typeof e=="string"?e.indexOf("#"):-1;return ky(t===-1?e:e.slice(0,t),Oy)}var Rn="1.20.0";var Mf=64*1024,Iy={cache:"default",redirect:"follow",referrer:"about:client",referrerPolicy:"",mode:"cors",integrity:"",keepalive:!1,priority:"auto",window:null},{isFunction:Do}=p,zy=e=>encodeURIComponent(e).replace(/%([0-9A-F]{2})/gi,(t,n)=>String.fromCharCode(parseInt(n,16))),Lf=e=>{if(!p.isString(e))return e;try{return decodeURIComponent(e)}catch{return e}},Nf=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Cy=e=>{let t=e.indexOf("://"),n=e;return t!==-1&&(n=n.slice(t+3)),n.includes("@")||n.includes(":")},$y=e=>{let t=p.global!==void 0&&p.global!==null?p.global:globalThis,{ReadableStream:n,TextEncoder:r}=t;e=p.merge.call({skipUndefined:!0},{Request:t.Request,Response:t.Response},e);let{fetch:o,Request:i,Response:s}=e,a=o?Do(o):typeof fetch=="function",c=Do(i),u=Do(s);if(!a)return!1;let l=a&&Do(n),f=a&&(typeof r=="function"?(h=>_=>h.encode(_))(new r):async h=>new Uint8Array(await new i(h).arrayBuffer())),d=c&&l&&Nf(()=>{let h=!1,_=new i(W.origin,{body:new n,method:"POST",get duplex(){return h=!0,"half"}}),x=_.headers.has("Content-Type");return _.body!=null&&_.body.cancel(),h&&!x}),m=u&&l&&Nf(()=>p.isReadableStream(new s("").body)),w={stream:m&&(h=>h.body)};a&&["text","arrayBuffer","blob","formData","stream"].forEach(h=>{!w[h]&&(w[h]=(_,x)=>{let E=_&&_[h];if(E)return E.call(_);throw new T(`Response type '${h}' is not supported`,T.ERR_NOT_SUPPORT,x)})});let b=async h=>{if(h==null)return 0;if(p.isBlob(h))return h.size;if(p.isSpecCompliantForm(h))return(await new i(W.origin,{method:"POST",body:h}).arrayBuffer()).byteLength;if(p.isArrayBufferView(h)||p.isArrayBuffer(h))return h.byteLength;if(p.isURLSearchParams(h)&&(h=h+""),p.isString(h))return(await f(h)).byteLength},S=async(h,_)=>{let x=p.toFiniteNumber(h.getContentLength());return x??b(_)};return async h=>{let{url:_,method:x,data:E,signal:A,cancelToken:k,timeout:I,onDownloadProgress:U,onUploadProgress:V,responseType:G,headers:g,withCredentials:v="same-origin",fetchOptions:D,maxContentLength:M,maxBodyLength:L,maxRedirects:B}=$o(h),Ze=p.isNumber(M)&&M>-1,Tt=p.isNumber(L)&&L>-1,qr=q=>p.hasOwnProp(h,q)?h[q]:void 0,te=o||fetch;G=G?(G+"").toLowerCase():"text";let le=Cf([A,k&&k.toAbortSignal()],I),ce=null,Pt=le&&le.unsubscribe&&(()=>{le.unsubscribe()}),tn,jn=null,ec=()=>new T("Request body larger than maxBodyLength limit",T.ERR_BAD_REQUEST,h,ce);try{let q,ke=qr("auth");if(ke){let N=p.getSafeProp(ke,"username")||"",fe=p.getSafeProp(ke,"password")||"";q={username:N,password:fe}}if(Cy(_)){let N=new URL(_,W.origin);if(!q&&(N.username||N.password)){let fe=Lf(N.username),dt=Lf(N.password);q={username:fe,password:dt}}(N.username||N.password)&&(N.username="",N.password="",_=N.href)}if(q&&(g.delete("authorization"),g.set("Authorization","Basic "+btoa(zy((q.username||"")+":"+(q.password||""))))),Ze&&typeof _=="string"&&_.startsWith("data:")&&Gs(_)>M)throw new T("maxContentLength size of "+M+" exceeded",T.ERR_BAD_RESPONSE,h,ce);if(Tt&&x!=="get"&&x!=="head"){let N=await b(E);if(typeof N=="number"&&isFinite(N)&&(tn=N,N>L))throw ec()}let Jr=Tt&&(p.isReadableStream(E)||p.isStream(E)),tc=(N,fe,dt)=>Hs(N,Mf,Ot=>{if(Tt&&Ot>L)throw jn=ec();fe&&fe(Ot)},dt);if(d&&x!=="get"&&x!=="head"&&(V||Jr)){if(tn=tn??await S(g,E),tn!==0||Jr){let N=new i(_,{method:"POST",body:E,duplex:"half"}),fe;if(p.isFormData(E)&&(fe=N.headers.get("content-type"))&&g.setContentType(fe),N.body){let[dt,Ot]=V&&Ns(tn,An(Bs(V)))||[];E=tc(N.body,dt,Ot)}}}else if(Jr&&!c&&l&&x!=="get"&&x!=="head")E=tc(E);else if(Jr&&c&&!d&&x!=="get"&&x!=="head")throw new T("Stream request bodies are not supported by the current fetch implementation",T.ERR_NOT_SUPPORT,h,ce);p.isString(v)||(v=v?"include":"omit");let gp=c&&"credentials"in i.prototype;if(p.isFormData(E)){let N=g.getContentType();N&&/^multipart\/form-data/i.test(N)&&!/boundary=/i.test(N)&&g.delete("content-type")}g.set("User-Agent","axios/"+Rn,!1);let De=D==null?D:Object.assign(Object.create(null),D);De&&(delete De.body,delete De.headers,delete De.method,delete De.signal,delete De.duplex,delete De.credentials);let et=Object.assign(Object.create(null),De,{signal:le,method:x.toUpperCase(),headers:Oo(g.normalize()),body:E,duplex:"half",credentials:gp?v:void 0});c&&(p.forEach(Iy,(N,fe)=>{et[fe]===void 0&&(et[fe]=N)}),et.signal===void 0&&(et.signal=null),et.body===void 0&&(et.body=null)),B===0&&(et.redirect="manual",De&&(De.redirect="manual")),ce=c&&new i(_,et);let tt=await(c?te(ce,De):te(_,et)),nc=ee.from(tt.headers);if(Ze){let N=p.toFiniteNumber(nc.getContentLength());if(N!=null&&N>M)throw new T("maxContentLength size of "+M+" exceeded",T.ERR_BAD_RESPONSE,h,ce)}let $i=m&&(G==="stream"||G==="response");if(m&&tt.body&&(U||Ze||$i&&Pt)){let N={};["status","statusText","headers"].forEach(Zn=>{N[Zn]=tt[Zn]});let fe=p.toFiniteNumber(nc.getContentLength()),[dt,Ot]=U&&Ns(fe,An(Bs(U),!0))||[],rc=0,yp=Zn=>{if(Ze&&(rc=Zn,rc>M))throw new T("maxContentLength size of "+M+" exceeded",T.ERR_BAD_RESPONSE,h,ce);dt&&dt(Zn)};tt=new s(Hs(tt.body,Mf,yp,()=>{Ot&&Ot(),Pt&&Pt()}),N)}G=G||"text";let nt=await w[p.findKey(w,G)||"text"](tt,h);if(Ze&&!m&&!$i){let N;if(nt!=null&&(typeof nt.byteLength=="number"?N=nt.byteLength:typeof nt.size=="number"?N=nt.size:typeof nt=="string"&&(N=typeof r=="function"?new r().encode(nt).byteLength:nt.length)),typeof N=="number"&&N>M)throw new T("maxContentLength size of "+M+" exceeded",T.ERR_BAD_RESPONSE,h,ce)}return!$i&&Pt&&Pt(),await new Promise((N,fe)=>{Er(N,fe,{data:nt,headers:ee.from(tt.headers),status:tt.status,statusText:tt.statusText,config:h,request:ce})})}catch(q){if(Pt&&Pt(),le&&le.aborted&&le.reason instanceof T){let ke=le.reason;throw ke.config=h,ce&&(ke.request=ce),q!==ke&&Object.defineProperty(ke,"cause",{__proto__:null,value:q,writable:!0,enumerable:!1,configurable:!0}),ke}if(jn)throw ce&&!jn.request&&(jn.request=ce),jn;if(q instanceof T)throw ce&&!q.request&&(q.request=ce),q;if(q&&q.name==="TypeError"&&/Load failed|fetch/i.test(q.message)){let ke=new T("Network Error",T.ERR_NETWORK,h,ce,q&&q.response);throw Object.defineProperty(ke,"cause",{__proto__:null,value:q.cause||q,writable:!0,enumerable:!1,configurable:!0}),ke}throw T.from(q,q&&q.code,h,ce,q&&q.response)}}},Dy=new Map,qs=e=>{let t=e&&e.env||{},{fetch:n,Request:r,Response:o}=t,i=[r,o,n],s=i.length,a=s,c,u,l=Dy;for(;a--;)c=i[a],u=l.get(c),u===void 0&&l.set(c,u=a?new Map:$y(t)),l=u;return u},GR=qs();var Js={http:xt,xhr:zf,fetch:{get:qs}};p.forEach(Js,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{__proto__:null,value:t})}catch{}Object.defineProperty(e,"adapterName",{__proto__:null,value:t})}});var Bf=e=>`- ${e}`,My=e=>p.isFunction(e)||e===null||e===!1;function Ly(e,t){e=p.isArray(e)?e:[e];let{length:n}=e,r,o,i={};for(let s=0;s<n;s++){r=e[s];let a;if(o=r,!My(r)&&(o=Js[(a=String(r)).toLowerCase()],o===void 0))throw new T(`Unknown adapter '${a}'`);if(o&&(p.isFunction(o)||(o=o.get(t))))break;i[a||"#"+s]=o}if(!o){let s=Object.entries(i).map(([c,u])=>`adapter ${c} `+(u===!1?"is not supported by the environment":"is not available in the build")),a=n?s.length>1?`since :
|
|
5
|
+
`+s.map(Bf).join(`
|
|
6
|
+
`):" "+Bf(s[0]):"as no adapter specified";throw new T("There is no suitable adapter to dispatch the request "+a,T.ERR_NOT_SUPPORT)}return o}var Uo={getAdapter:Ly,adapters:Js};function Ks(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Ke(null,e)}function Rr(e){let t=p.toSafeFlatObject(e);return Ks(t),t.headers=ee.from(p.getSafeProp(t,"headers")),t.data=br.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),Uo.getAdapter(t.adapter||Sn.adapter,t)(t).then(function(o){Ks(t),t.response=o;try{o.data=br.call(t,t.transformResponse,o)}finally{delete t.response}return o.headers=ee.from(o.headers),o},function(o){if(!xr(o)&&(Ks(t),o&&o.response)){t.response=o.response;try{o.response.data=br.call(t,t.transformResponse,o.response)}finally{delete t.response}o.response.headers=ee.from(o.response.headers)}return Promise.reject(o)})}var Mo={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Mo[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});var jf={};Mo.transitional=function(t,n,r){function o(i,s){return"[Axios v"+Rn+"] Transitional option '"+i+"'"+s+(r?". "+r:"")}return(i,s,a)=>{if(t===!1)throw new T(o(s," has been removed"+(n?" in "+n:"")),T.ERR_DEPRECATED);return n&&!jf[s]&&(jf[s]=!0,console.warn(o(s," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(i,s,a):!0}};Mo.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Ny(e,t,n){if(typeof e!="object"||e===null)throw new T("options must be an object",T.ERR_BAD_OPTION_VALUE);let r=Object.keys(e),o=r.length;for(;o-- >0;){let i=r[o],s=Object.prototype.hasOwnProperty.call(t,i)?t[i]:void 0;if(s){let a=e[i],c=a===void 0||s(a,i,e);if(c!==!0)throw new T("option "+i+" must be "+c,T.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new T("Unknown option "+i,T.ERR_BAD_OPTION)}}var Tr={assertOptions:Ny,validators:Mo};var pe=Tr.validators,Tn=class{constructor(t){this.defaults=t||{},this.interceptors={request:new zs,response:new zs}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error)try{let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;let i=o.stack,s="";if(typeof i=="string"){let a=i.indexOf(`
|
|
7
7
|
`);s=a===-1?"":i.slice(a+1)}if(!r.stack)r.stack=s;else if(s){let a=s.indexOf(`
|
|
8
8
|
`),c=a===-1?-1:s.indexOf(`
|
|
9
9
|
`,a+1),u=c===-1?"":s.slice(c+1);String(r.stack).endsWith(u)||(r.stack+=`
|
|
10
|
-
`+s)}}catch{}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Ne(this.defaults,n);let{transitional:r,paramsSerializer:o,headers:i}=n;r!==void 0&&Pr.assertOptions(r,{silentJSONParsing:pe.transitional(pe.boolean),forcedJSONParsing:pe.transitional(pe.boolean),clarifyTimeoutError:pe.transitional(pe.boolean),legacyInterceptorReqResOrdering:pe.transitional(pe.boolean),advertiseZstdAcceptEncoding:pe.transitional(pe.boolean),validateStatusUndefinedResolves:pe.transitional(pe.boolean)},!1),o!=null&&(p.isFunction(o)?n.paramsSerializer={serialize:o}:Pr.assertOptions(o,{encode:pe.function,serialize:pe.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Pr.assertOptions(n,{baseUrl:pe.spelling("baseURL"),withXsrfToken:pe.spelling("withXSRFToken")},!0),n.method=(p.getSafeProp(n,"method")||p.getSafeProp(this.defaults,"method")||"get").toLowerCase();let s=i&&p.merge(i.common,i[n.method]);i&&p.forEach($o.concat("common"),w=>{delete i[w]}),n.headers=Q.concat(s,i);let a=[],c=!0;this.interceptors.request.forEach(function(b){if(typeof b.runWhen=="function"&&b.runWhen(n)===!1)return;c=c&&b.synchronous;let S=n.transitional||En;S&&S.legacyInterceptorReqResOrdering?a.unshift(b.fulfilled,b.rejected):a.push(b.fulfilled,b.rejected)});let u=[];this.interceptors.response.forEach(function(b){u.push(b.fulfilled,b.rejected)});let l,d=0,f;if(!c){let w=[Rr.bind(this),void 0];for(w.unshift(...a),w.push(...u),f=w.length,l=Promise.resolve(n);d<f;)l=l.then(w[d++],w[d++]);return l}f=a.length;let m=n;for(;d<f;){let w=a[d++],b=a[d++];try{m=w?w(m):m}catch(S){if(!b){l=Promise.reject(S);break}try{let h=b.call(this,S);p.isThenable(h)&&(l=Promise.resolve(h).then(()=>Rr.call(this,m)))}catch(h){l=Promise.reject(h)}break}}if(!l)try{l=Rr.call(this,m)}catch(w){l=Promise.reject(w)}for(d=0,f=u.length;d<f;)l=l.then(u[d++],u[d++]);return l}getUri(t){t=Ne(this.defaults,t);let n=Ar(t.baseURL,t.url,t.allowAbsoluteUrls,t);return yr(n,t.params,t.paramsSerializer)}};p.forEach(["delete","get","head","options"],function(t){Pn.prototype[t]=function(n,r){return this.request(Ne(r||{},{method:t,url:n,data:r&&p.hasOwnProp(r,"data")?r.data:void 0}))}});p.forEach(["post","put","patch","query"],function(t){function n(r){return function(i,s,a){return this.request(Ne(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:i,data:s}))}}Pn.prototype[t]=n(),t!=="query"&&(Pn.prototype[t+"Form"]=n(!0))});var Tr=Pn;var Vs=class e{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(i){n=i});let r=this;this.promise.then(o=>{if(!r._listeners)return;let i=r._listeners.length;for(;i-- >0;)r._listeners[i](o);r._listeners=null}),this.promise.then=o=>{let i,s=new Promise(a=>{r.subscribe(a),i=a}).then(o);return s.cancel=function(){r.unsubscribe(i)},s},t(function(i,s,a){r.reason||(r.reason=new Ke(i,s,a),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;let n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){let t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new e(function(o){t=o}),cancel:t}}},jd=Vs;function Ws(e){return function(n){return e.apply(null,n)}}function Xs(e){return p.isObject(e)&&e.isAxiosError===!0}var Lo={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,ContentTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,UnprocessableContent:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerReturnsAnUnknownError:520,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Lo).forEach(([e,t])=>{Lo[t]===void 0&&(Lo[t]=e)});var Zd=Lo;function Fd(e){let t=new Tr(e),n=lr(Tr.prototype.request,t);return p.extend(n,Tr.prototype,t,{allOwnKeys:!0}),p.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Fd(Ne(e,o))},n}var re=Fd(Sn);re.Axios=Tr;re.CanceledError=Ke;re.CancelToken=jd;re.isCancel=xr;re.VERSION=Rn;re.toFormData=xt;re.AxiosError=P;re.Cancel=re.CanceledError;re.all=function(t){return Promise.all(t)};re.spread=Ws;re.isAxiosError=Xs;re.mergeConfig=Ne;re.AxiosHeaders=Q;re.formToJSON=e=>zo(p.isHTMLForm(e)?new FormData(e):e);re.getAdapter=Uo.getAdapter;re.HttpStatusCode=Zd;re.default=re;var No=re;var{Axios:BP,AxiosError:jP,CanceledError:ZP,isCancel:FP,CancelToken:HP,VERSION:GP,all:qP,Cancel:JP,isAxiosError:KP,spread:VP,toFormData:WP,AxiosHeaders:XP,HttpStatusCode:YP,formToJSON:QP,getAdapter:eT,mergeConfig:tT,create:nT}=No;function Ny(e,t){try{var n=e()}catch(r){return t(r)}return n&&n.then?n.then(void 0,t):n}function Te(e,t,n){if(!e.s){if(n instanceof Ys)if(n.s)t&1&&(t=n.s),n=n.v;else{n.o=Te.bind(null,e,t);return}if(n&&n.then){n.then(Te.bind(null,e,t),Te.bind(null,e,2));return}e.s=t,e.v=n;let r=e.o;r&&r(e)}}var Ys=(function(){function e(){}return e.prototype.then=function(t,n){let r=new e,o=this.s;if(o){let i=o&1?t:n;if(i){try{Te(r,1,i(this.v))}catch(s){Te(r,2,s)}return r}else return this}return this.o=function(i){try{let s=i.v;i.s&1?Te(r,1,t?t(s):s):n?Te(r,1,n(s)):Te(r,2,s)}catch(s){Te(r,2,s)}},r},e})();function Tn(e){return e instanceof Ys&&e.s&1}function By(e,t){var n;do{var r=e();if(r&&r.then)if(Tn(r))r=r.v;else{n=!0;break}var o=t();if(Tn(o)&&(o=o.v),!o)return r}while(!o.then);let i=new Ys,s=Te.bind(null,i,2);return(n?r.then(a):o.then(c)).then(void 0,s),i;function a(u){for(r=u;o=t(),Tn(o)&&(o=o.v),!!o;){if(o.then){o.then(c).then(void 0,s);return}if(r=e(),r&&r.then)if(Tn(r))r=r.v;else{r.then(a).then(void 0,s);return}}Te(i,1,r)}function c(u){if(u){do{if(r=e(),r&&r.then)if(Tn(r))r=r.v;else{r.then(a).then(void 0,s);return}if(u=t(),Tn(u)&&(u=u.v),!u){Te(i,1,r);return}}while(!u.then);u.then(c).then(void 0,s)}else Te(i,1,r)}}function Hd(){return{plc:function(t,n){try{let o=function(){let l=typeof c?.["@context"]<"u"?"application/did+ld+json":"application/did+json";return i?{didDocument:c,didDocumentMetadata:a,didResolutionMetadata:{error:"notFound",message:i}}:{didDocument:c,didDocumentMetadata:a,didResolutionMetadata:{contentType:l}}},r,i=null,s=`https://plc.directory/${encodeURIComponent(t)}`,a={},c=null,u=By(function(){function l(){r||c?.id===t||(i="resolver_error: DID document id does not match requested did")}let d=Ny(function(){return Promise.resolve(No.get(s)).then(function(f){c=f.data})},function(f){i=`resolver_error: '"https://plc.directory/" + DID' must resolve to a valid https URL containing a JSON document: ${f}`,r=1});return d&&d.then?d.then(l):l(d)},function(){return!r&&!1});return Promise.resolve(u&&u.then?u.then(o):o(u))}catch(r){return Promise.reject(r)}}}}var Jd=_p(qd(),1);function jy(e,t){try{var n=e()}catch(r){return t(r)}return n&&n.then?n.then(void 0,t):n}var Zy=function(e){try{return Promise.resolve((0,Jd.default)(e,{mode:"cors"})).then(function(t){if(t.status>=400)throw new Error(`Bad response ${t.statusText}`);return t.json()})}catch(t){return Promise.reject(t)}};function Oe(e,t,n){if(!e.s){if(n instanceof Qs)if(n.s)t&1&&(t=n.s),n=n.v;else{n.o=Oe.bind(null,e,t);return}if(n&&n.then){n.then(Oe.bind(null,e,t),Oe.bind(null,e,2));return}e.s=t,e.v=n;let r=e.o;r&&r(e)}}var Fy="/.well-known/did.json",Qs=(function(){function e(){}return e.prototype.then=function(t,n){let r=new e,o=this.s;if(o){let i=o&1?t:n;if(i){try{Oe(r,1,i(this.v))}catch(s){Oe(r,2,s)}return r}else return this}return this.o=function(i){try{let s=i.v;i.s&1?Oe(r,1,t?t(s):s):n?Oe(r,1,n(s)):Oe(r,2,s)}catch(s){Oe(r,2,s)}},r},e})();function kn(e){return e instanceof Qs&&e.s&1}function Hy(e,t){var n;do{var r=e();if(r&&r.then)if(kn(r))r=r.v;else{n=!0;break}var o=t();if(kn(o)&&(o=o.v),!o)return r}while(!o.then);let i=new Qs,s=Oe.bind(null,i,2);return(n?r.then(a):o.then(c)).then(void 0,s),i;function a(u){for(r=u;o=t(),kn(o)&&(o=o.v),!!o;){if(o.then){o.then(c).then(void 0,s);return}if(r=e(),r&&r.then)if(kn(r))r=r.v;else{r.then(a).then(void 0,s);return}}Oe(i,1,r)}function c(u){if(u){do{if(r=e(),r&&r.then)if(kn(r))r=r.v;else{r.then(a).then(void 0,s);return}if(u=t(),kn(u)&&(u=u.v),!u){Oe(i,1,r);return}}while(!u.then);u.then(c).then(void 0,s)}else Oe(i,1,r)}}function Kd(){return{web:function(t,n){try{let o=function(){let f=typeof l?.["@context"]<"u"?"application/did+ld+json":"application/did+json";return i?{didDocument:l,didDocumentMetadata:u,didResolutionMetadata:{error:"notFound",message:i}}:{didDocument:l,didDocumentMetadata:u,didResolutionMetadata:{contentType:f}}},r,i=null,s=decodeURIComponent(n.id)+Fy,a=n.id.split(":");a.length>1&&(s=a.map(decodeURIComponent).join("/")+"/did.json");let c=`https://${s}`,u={},l=null,d=Hy(function(){function f(){r||l?.id===t||(i="resolver_error: DID document id does not match requested did")}let m=jy(function(){return Promise.resolve(Zy(c)).then(function(w){l=w})},function(w){i=`resolver_error: DID must resolve to a valid https URL containing a JSON document: ${w}`,r=1});return m&&m.then?m.then(f):f(m)},function(){return!r&&!1});return Promise.resolve(d&&d.then?d.then(o):o(d))}catch(r){return Promise.reject(r)}}}}var Zo=class{methods={...Hd(),...Kd()};resolver=new Ro(this.methods,{cache:!0});inFlight=new Map;async resolve(t){if(!Object.keys(this.methods).some(o=>t.startsWith(`did:${o}:`)))throw new Error(`Unrecognized DID method: ${t}`);let n=this.inFlight.get(t);if(n)return n;let r=this.resolver.resolve(t).then(({didDocument:o})=>{if(!o)throw new ne(`DID not found: ${t}`);return o});this.inFlight.set(t,r);try{return await r}finally{this.inFlight.delete(t)}}};var na;(typeof navigator>"u"||!navigator.userAgent?.startsWith?.("Mozilla/5.0 "))&&(na="oauth4webapi/v3.8.7");function $r(e,t){if(e==null)return!1;try{return e instanceof t||Object.getPrototypeOf(e)[Symbol.toStringTag]===t.prototype[Symbol.toStringTag]}catch{return!1}}var we="ERR_INVALID_ARG_VALUE",$e="ERR_INVALID_ARG_TYPE";function K(e,t,n){let r=new TypeError(e,{cause:n});return Object.assign(r,{code:t}),r}var Gt=Symbol(),Jo=Symbol(),Ko=Symbol(),qt=Symbol();var Fo=Symbol();var Gy=new TextEncoder,qy=new TextDecoder;function Vd(e){return typeof e=="string"?Gy.encode(e):qy.decode(e)}var ra;Uint8Array.prototype.toBase64?ra=e=>(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),e.toBase64({alphabet:"base64url",omitPadding:!0})):ra=t=>{t instanceof ArrayBuffer&&(t=new Uint8Array(t));let n=[];for(let r=0;r<t.byteLength;r+=32768)n.push(String.fromCharCode.apply(null,t.subarray(r,r+32768)));return btoa(n.join("")).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")};var oa;Uint8Array.fromBase64?oa=e=>{try{return Uint8Array.fromBase64(e,{alphabet:"base64url"})}catch(t){throw K("The input to be decoded is not correctly encoded.",we,t)}}:oa=e=>{try{let t=atob(e.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"")),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}catch(t){throw K("The input to be decoded is not correctly encoded.",we,t)}};function ia(e){return typeof e=="string"?oa(e):ra(e)}var vt=class extends Error{code;constructor(t,n){super(t,n),this.name=this.constructor.name,this.code=ei,Error.captureStackTrace?.(this,this.constructor)}},kr=class extends Error{code;constructor(t,n){super(t,n),this.name=this.constructor.name,n?.code&&(this.code=n?.code),Error.captureStackTrace?.(this,this.constructor)}};function C(e,t,n){return new kr(e,{code:t,cause:n})}function Ho(e){return!(e===null||typeof e!="object"||Array.isArray(e))}function sa(e){$r(e,Headers)&&(e=Object.fromEntries(e.entries()));let t=new Headers(e??{});if(na&&!t.has("user-agent")&&t.set("user-agent",na),t.has("authorization"))throw K('"options.headers" must not include the "authorization" header name',we);return t}function Xd(e,t){if(t!==void 0){if(typeof t=="function"&&(t=t(e.href)),!(t instanceof AbortSignal))throw K('"options.signal" must return or be an instance of AbortSignal',$e);return t}}function Yd(e){return e.includes("//")?e.replace("//","/"):e}function Jy(e,t,n=!1){return e.pathname==="/"?e.pathname=t:e.pathname=Yd(`${t}/${n?e.pathname:e.pathname.replace(/(\/)$/,"")}`),e}function Ky(e,t){return e.pathname=Yd(`${e.pathname}/${t}`),e}async function Vy(e,t,n,r){if(!(e instanceof URL))throw K(`"${t}" must be an instance of URL`,$e);Xo(e,r?.[Gt]!==!0);let o=n(new URL(e.href)),i=sa(r?.headers);return i.set("accept","application/json"),(r?.[qt]||fetch)(o.href,{body:void 0,headers:Object.fromEntries(i.entries()),method:"GET",redirect:"manual",signal:Xd(o,r?.signal)})}async function Qd(e,t){return Vy(e,"issuerIdentifier",n=>{switch(t?.algorithm){case void 0:case"oidc":Ky(n,".well-known/openid-configuration");break;case"oauth2":Jy(n,".well-known/oauth-authorization-server");break;default:throw K('"options.algorithm" must be "oidc" (default), or "oauth2"',we)}return n},t)}function Or(e,t,n,r,o){try{if(typeof e!="number"||!Number.isFinite(e))throw K(`${n} must be a number`,$e,o);if(e>0)return;if(t){if(e!==0)throw K(`${n} must be a non-negative number`,we,o);return}throw K(`${n} must be a positive number`,we,o)}catch(i){throw r?C(i.message,r,o):i}}function ye(e,t,n,r){try{if(typeof e!="string")throw K(`${t} must be a string`,$e,r);if(e.length===0)throw K(`${t} must not be empty`,we,r)}catch(o){throw n?C(o.message,n,r):o}}async function ef(e,t){let n=e;if(!(n instanceof URL)&&n!==qo)throw K('"expectedIssuerIdentifier" must be an instance of URL',$e);if(!$r(t,Response))throw K('"response" must be an instance of Response',$e);if(t.status!==200)throw C('"response" is not a conform Authorization Server Metadata response (unexpected HTTP status code)',ti,t);ya(t);let r=await yf(t);if(ye(r.issuer,'"response" body "issuer" property',H,{body:r}),n!==qo&&new URL(r.issuer).href!==n.href)throw C('"response" body "issuer" property does not match the expected value',ni,{expected:n.href,body:r,attribute:"issuer"});return r}function tf(e){Xy(e,"application/json")}function Wy(e,...t){let n='"response" content-type must be ';if(t.length>2){let r=t.pop();n+=`${t.join(", ")}, or ${r}`}else t.length===2?n+=`${t[0]} or ${t[1]}`:n+=t[0];return C(n,ha,e)}function Xy(e,t){if(da(e)!==t)throw Wy(e,t)}function Yy(){return ia(crypto.getRandomValues(new Uint8Array(32)))}function nf(){return Yy()}function aa(e){let t=e?.[Jo];return typeof t=="number"&&Number.isFinite(t)?t:0}function ca(e){let t=e?.[Ko];return typeof t=="number"&&Number.isFinite(t)&&Math.sign(t)!==-1?t:30}function ua(){return Math.floor(Date.now()/1e3)}function Vo(e){if(typeof e!="object"||e===null)throw K('"as" must be an object',$e);ye(e.issuer,'"as.issuer"')}function Wo(e){if(typeof e!="object"||e===null)throw K('"client" must be an object',$e);ye(e.client_id,'"client.client_id"')}function la(e){return ye(e,'"clientSecret"'),(t,n,r,o)=>{r.set("client_id",n.client_id),r.set("client_secret",e)}}function rf(){return(e,t,n,r)=>{n.set("client_id",t.client_id)}}var Qy=URL.parse?(e,t)=>URL.parse(e,t):(e,t)=>{try{return new URL(e,t)}catch{return null}};function Xo(e,t){if(t&&e.protocol!=="https:")throw C("only requests to HTTPS are allowed",ma,e);if(e.protocol!=="https:"&&e.protocol!=="http:")throw C("only HTTP and HTTPS requests are allowed",ga,e)}function Wd(e,t,n,r){let o;if(typeof e!="string"||!(o=Qy(e)))throw C(`authorization server metadata does not contain a valid ${n?`"as.mtls_endpoint_aliases.${t}"`:`"as.${t}"`}`,e===void 0?Sw:Aw,{attribute:n?`mtls_endpoint_aliases.${t}`:t});return Xo(o,r),o}function Yo(e,t,n,r){return n&&e.mtls_endpoint_aliases&&t in e.mtls_endpoint_aliases?Wd(e.mtls_endpoint_aliases[t],t,n,r):Wd(e[t],t,n,r)}function of(e){if(e instanceof zn){let{0:t,length:n}=e.cause;return n===1&&t.scheme==="dpop"&&t.parameters.error==="use_dpop_nonce"}return e instanceof In?e.error==="use_dpop_nonce":!1}var In=class extends Error{cause;code;error;status;error_description;response;constructor(t,n){super(t,n),this.name=this.constructor.name,this.code=Ew,this.cause=n.cause,this.error=n.cause.error,this.status=n.response.status,this.error_description=n.cause.error_description,Object.defineProperty(this,"response",{enumerable:!1,value:n.response}),Error.captureStackTrace?.(this,this.constructor)}},Ir=class extends Error{cause;code;error;error_description;constructor(t,n){super(t,n),this.name=this.constructor.name,this.code=vw,this.cause=n.cause,this.error=n.cause.get("error"),this.error_description=n.cause.get("error_description")??void 0,Error.captureStackTrace?.(this,this.constructor)}},zn=class extends Error{cause;code;response;status;constructor(t,n){super(t,n),this.name=this.constructor.name,this.code=xw,this.cause=n.cause,this.status=n.response.status,this.response=n.response,Object.defineProperty(this,"response",{enumerable:!1}),Error.captureStackTrace?.(this,this.constructor)}},Go="[a-zA-Z0-9!#$%&\\'\\*\\+\\-\\.\\^_`\\|~]+",ew="[a-zA-Z0-9\\-\\._\\~\\+\\/]+={0,2}",tw='"((?:[^"\\\\]|\\\\[\\s\\S])*)"',nw="("+Go+")\\s*=\\s*"+tw,rw="("+Go+")\\s*=\\s*("+Go+")",ow=new RegExp("^[,\\s]*("+Go+")"),iw=new RegExp("^[,\\s]*"+nw+"[,\\s]*(.*)"),sw=new RegExp("^[,\\s]*"+rw+"[,\\s]*(.*)"),aw=new RegExp("^("+ew+")(?:$|[,\\s])(.*)");function cw(e){if(!$r(e,Response))throw K('"response" must be an instance of Response',$e);let t=e.headers.get("www-authenticate");if(t===null)return;let n=[],r=t;for(;r;){let o=r.match(ow),i=o?.[1].toLowerCase();if(!i)return;let s=r.substring(o[0].length);if(s&&!s.match(/^[\s,]/))return;let a=s.match(/^\s+(.*)$/),c=!!a;r=a?a[1]:void 0;let u={},l;if(c)for(;r;){let f,m;if(o=r.match(iw)){if([,f,m,r]=o,m.includes("\\"))try{m=JSON.parse(`"${m}"`)}catch{}u[f.toLowerCase()]=m;continue}if(o=r.match(sw)){[,f,m,r]=o,u[f.toLowerCase()]=m;continue}if(o=r.match(aw)){if(Object.keys(u).length)break;[,l,r]=o;break}return}else r=s||void 0;let d={scheme:i,parameters:u};l&&(d.token68=l),n.push(d)}if(n.length)return n}async function uw(e){if(e.status>399&&e.status<500){ya(e),tf(e);try{let t=await e.clone().json();if(Ho(t)&&typeof t.error=="string"&&t.error.length)return t}catch{}}}async function sf(e,t,n){if(e.status!==t){pw(e);let r;throw(r=await uw(e))?(await e.body?.cancel(),new In("server responded with an error in the response body",{cause:r,response:e})):C(`"response" is not a conform ${n} response (unexpected HTTP status code)`,ti,e)}}function lw(e){if(!fa.has(e))throw K('"options.DPoP" is not a valid DPoPHandle',we)}function da(e){return e.headers.get("content-type")?.split(";")[0]}async function af(e,t,n,r,o,i,s){return await n(e,t,o,i),i.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"),(s?.[qt]||fetch)(r.href,{body:o,headers:Object.fromEntries(i.entries()),method:"POST",redirect:"manual",signal:Xd(r,s?.signal)})}async function dw(e,t,n,r,o,i){let s=Yo(e,"token_endpoint",t.use_mtls_endpoint_aliases,i?.[Gt]!==!0);o.set("grant_type",r);let a=sa(i?.headers);a.set("accept","application/json"),i?.DPoP!==void 0&&(lw(i.DPoP),await i.DPoP.addProof(s,a,"POST"));let c=await af(e,t,n,s,o,a,i);return i?.DPoP?.cacheNonce(c,s),c}var cf=new WeakMap,fw=new WeakMap;function Qo(e){if(!e.id_token)return;let t=cf.get(e);if(!t)throw K('"ref" was already garbage collected or did not resolve from the proper sources',we);return t}async function uf(e,t,n,r,o,i){if(Vo(e),Wo(t),!$r(n,Response))throw K('"response" must be an instance of Response',$e);await sf(n,200,"Token Endpoint"),ya(n);let s=await yf(n);if(ye(s.access_token,'"response" body "access_token" property',H,{body:s}),ye(s.token_type,'"response" body "token_type" property',H,{body:s}),s.token_type=s.token_type.toLowerCase(),s.expires_in!==void 0){let a=typeof s.expires_in!="number"?parseFloat(s.expires_in):s.expires_in;Or(a,!0,'"response" body "expires_in" property',H,{body:s}),s.expires_in=a}if(s.refresh_token!==void 0&&ye(s.refresh_token,'"response" body "refresh_token" property',H,{body:s}),s.scope!==void 0&&typeof s.scope!="string")throw C('"response" body "scope" property must be a string',H,{body:s});if(s.id_token!==void 0){ye(s.id_token,'"response" body "id_token" property',H,{body:s});let a=["aud","exp","iat","iss","sub"];t.require_auth_time===!0&&a.push("auth_time"),t.default_max_age!==void 0&&(Or(t.default_max_age,!0,'"client.default_max_age"'),a.push("auth_time")),r?.length&&a.push(...r);let{claims:c,jwt:u}=await Rw(s.id_token,Tw.bind(void 0,t.id_token_signed_response_alg,e.id_token_signing_alg_values_supported,"RS256"),aa(t),ca(t),o).then(ww.bind(void 0,a)).then(mw.bind(void 0,e)).then(hw.bind(void 0,t.client_id));if(Array.isArray(c.aud)&&c.aud.length!==1){if(c.azp===void 0)throw C('ID Token "aud" (audience) claim includes additional untrusted audiences',Ve,{claims:c,claim:"aud"});if(c.azp!==t.client_id)throw C('unexpected ID Token "azp" (authorized party) claim value',Ve,{expected:t.client_id,claims:c,claim:"azp"})}c.auth_time!==void 0&&Or(c.auth_time,!0,'ID Token "auth_time" (authentication time)',H,{claims:c}),fw.set(n,u),cf.set(s,c)}if(i?.[s.token_type]!==void 0)i[s.token_type](n,s);else if(s.token_type!=="dpop"&&s.token_type!=="bearer")throw new vt("unsupported `token_type` value",{cause:{body:s}});return s}function pw(e){let t;if(t=cw(e))throw new zn("server responded with a challenge in the WWW-Authenticate HTTP Header",{cause:t,response:e})}function hw(e,t){if(Array.isArray(t.claims.aud)){if(!t.claims.aud.includes(e))throw C('unexpected JWT "aud" (audience) claim value',Ve,{expected:e,claims:t.claims,claim:"aud"})}else if(t.claims.aud!==e)throw C('unexpected JWT "aud" (audience) claim value',Ve,{expected:e,claims:t.claims,claim:"aud"});return t}function mw(e,t){let n=e[wa]?.(t)??e.issuer;if(t.claims.iss!==n)throw C('unexpected JWT "iss" (issuer) claim value',Ve,{expected:n,claims:t.claims,claim:"iss"});return t}var fa=new WeakSet;function gw(e){return fa.add(e),e}var pa=Symbol();async function lf(e,t,n,r,o,i,s){if(Vo(e),Wo(t),!fa.has(r))throw K('"callbackParameters" must be an instance of URLSearchParams obtained from "validateAuthResponse()", or "validateJwtAuthResponse()',we);ye(o,'"redirectUri"');let a=Ht(r,"code");if(!a)throw C('no authorization code in "callbackParameters"',H);let c=new URLSearchParams(s?.additionalParameters);return c.set("redirect_uri",o),c.set("code",a),i!==pa&&(ye(i,'"codeVerifier"'),c.set("code_verifier",i)),dw(e,t,n,"authorization_code",c,s)}var yw={aud:"audience",c_hash:"code hash",client_id:"client id",exp:"expiration time",iat:"issued at",iss:"issuer",jti:"jwt id",nonce:"nonce",s_hash:"state hash",sub:"subject",ath:"access token hash",htm:"http method",htu:"http uri",cnf:"confirmation",auth_time:"authentication time"};function ww(e,t){for(let n of e)if(t.claims[n]===void 0)throw C(`JWT "${n}" (${yw[n]}) claim missing`,H,{claims:t.claims});return t}var ea=Symbol(),ta=Symbol();async function df(e,t,n,r){return typeof r?.expectedNonce=="string"||typeof r?.maxAge=="number"||r?.requireIdToken?_w(e,t,n,r.expectedNonce,r.maxAge,r[Fo],r.recognizedTokenTypes):bw(e,t,n,r?.[Fo],r?.recognizedTokenTypes)}async function _w(e,t,n,r,o,i,s){let a=[];switch(r){case void 0:r=ea;break;case ea:break;default:ye(r,'"expectedNonce" argument'),a.push("nonce")}switch(o??=t.default_max_age,o){case void 0:o=ta;break;case ta:break;default:Or(o,!0,'"maxAge" argument'),a.push("auth_time")}let c=await uf(e,t,n,a,i,s);ye(c.id_token,'"response" body "id_token" property',H,{body:c});let u=Qo(c);if(o!==ta){let l=ua()+aa(t),d=ca(t);if(u.auth_time+o<l-d)throw C("too much time has elapsed since the last End-User authentication",$n,{claims:u,now:l,tolerance:d,claim:"auth_time"})}if(r===ea){if(u.nonce!==void 0)throw C('unexpected ID Token "nonce" claim value',Ve,{expected:void 0,claims:u,claim:"nonce"})}else if(u.nonce!==r)throw C('unexpected ID Token "nonce" claim value',Ve,{expected:r,claims:u,claim:"nonce"});return c}async function bw(e,t,n,r,o){let i=await uf(e,t,n,void 0,r,o),s=Qo(i);if(s){if(t.default_max_age!==void 0){Or(t.default_max_age,!0,'"client.default_max_age"');let a=ua()+aa(t),c=ca(t);if(s.auth_time+t.default_max_age<a-c)throw C("too much time has elapsed since the last End-User authentication",$n,{claims:s,now:a,tolerance:c,claim:"auth_time"})}if(s.nonce!==void 0)throw C('unexpected ID Token "nonce" claim value',Ve,{expected:void 0,claims:s,claim:"nonce"})}return i}var xw="OAUTH_WWW_AUTHENTICATE_CHALLENGE",Ew="OAUTH_RESPONSE_BODY_ERROR",ei="OAUTH_UNSUPPORTED_OPERATION",vw="OAUTH_AUTHORIZATION_RESPONSE_ERROR";var zr="OAUTH_PARSE_ERROR",H="OAUTH_INVALID_RESPONSE";var ha="OAUTH_RESPONSE_IS_NOT_JSON",ti="OAUTH_RESPONSE_IS_NOT_CONFORM",ma="OAUTH_HTTP_REQUEST_FORBIDDEN",ga="OAUTH_REQUEST_PROTOCOL_FORBIDDEN",$n="OAUTH_JWT_TIMESTAMP_CHECK_FAILED",Ve="OAUTH_JWT_CLAIM_COMPARISON_FAILED",ni="OAUTH_JSON_ATTRIBUTE_COMPARISON_FAILED";var Sw="OAUTH_MISSING_SERVER_METADATA",Aw="OAUTH_INVALID_SERVER_METADATA";async function ff(e,t,n,r,o){Vo(e),Wo(t),ye(r,'"token"');let i=Yo(e,"revocation_endpoint",t.use_mtls_endpoint_aliases,o?.[Gt]!==!0),s=new URLSearchParams(o?.additionalParameters);s.set("token",r);let a=sa(o?.headers);return a.delete("accept"),af(e,t,n,i,s,a,o)}async function pf(e){if(!$r(e,Response))throw K('"response" must be an instance of Response',$e);await sf(e,200,"Revocation Endpoint")}function ya(e){if(e.bodyUsed)throw K('"response" body has been used already',we)}async function Rw(e,t,n,r,o){let{0:i,1:s,length:a}=e.split(".");if(a===5)if(o!==void 0)e=await o(e),{0:i,1:s,length:a}=e.split(".");else throw new vt("JWE decryption is not configured",{cause:e});if(a!==3)throw C("Invalid JWT",H,e);let c;try{c=JSON.parse(Vd(ia(i)))}catch(d){throw C("failed to parse JWT Header body as base64url encoded JSON",zr,d)}if(!Ho(c))throw C("JWT Header must be a top level object",H,e);if(t(c),c.crit!==void 0)throw new vt('no JWT "crit" header parameter extensions are supported',{cause:{header:c}});let u;try{u=JSON.parse(Vd(ia(s)))}catch(d){throw C("failed to parse JWT Payload body as base64url encoded JSON",zr,d)}if(!Ho(u))throw C("JWT Payload must be a top level object",H,e);let l=ua()+n;if(u.exp!==void 0){if(typeof u.exp!="number")throw C('unexpected JWT "exp" (expiration time) claim type',H,{claims:u});if(u.exp<=l-r)throw C('unexpected JWT "exp" (expiration time) claim value, expiration is past current timestamp',$n,{claims:u,now:l,tolerance:r,claim:"exp"})}if(u.iat!==void 0&&typeof u.iat!="number")throw C('unexpected JWT "iat" (issued at) claim type',H,{claims:u});if(u.iss!==void 0&&typeof u.iss!="string")throw C('unexpected JWT "iss" (issuer) claim type',H,{claims:u});if(u.nbf!==void 0){if(typeof u.nbf!="number")throw C('unexpected JWT "nbf" (not before) claim type',H,{claims:u});if(u.nbf>l+r)throw C('unexpected JWT "nbf" (not before) claim value',$n,{claims:u,now:l,tolerance:r,claim:"nbf"})}if(u.aud!==void 0&&typeof u.aud!="string"&&!Array.isArray(u.aud))throw C('unexpected JWT "aud" (audience) claim type',H,{claims:u});return{header:c,claims:u,jwt:e}}async function Pw(e){if(e.bodyUsed)throw K("form_post Request instances must contain a readable body",we,{cause:e});return e.text()}async function hf(e){if(e.method!=="POST")throw K("form_post responses are expected to use the POST method",we,{cause:e});if(da(e)!=="application/x-www-form-urlencoded")throw K("form_post responses are expected to use the application/x-www-form-urlencoded content-type",we,{cause:e});return Pw(e)}function Tw(e,t,n,r){if(e!==void 0){if(typeof e=="string"?r.alg!==e:!e.includes(r.alg))throw C('unexpected JWT "alg" header parameter',H,{header:r,expected:e,reason:"client configuration"});return}if(Array.isArray(t)){if(!t.includes(r.alg))throw C('unexpected JWT "alg" header parameter',H,{header:r,expected:t,reason:"authorization server metadata"});return}if(n!==void 0){if(typeof n=="string"?r.alg!==n:typeof n=="function"?!n(r.alg):!n.includes(r.alg))throw C('unexpected JWT "alg" header parameter',H,{header:r,expected:n,reason:"default value"});return}throw C('missing client or server configuration to verify used JWT "alg" header parameter',void 0,{client:e,issuer:t,fallback:n})}function Ht(e,t){let{0:n,length:r}=e.getAll(t);if(r>1)throw C(`"${t}" parameter must be provided only once`,H);return n}var mf=Symbol(),Ow=Symbol();function gf(e,t,n,r){if(Vo(e),Wo(t),n instanceof URL&&(n=n.searchParams),!(n instanceof URLSearchParams))throw K('"parameters" must be an instance of URLSearchParams, or URL',$e);if(Ht(n,"response"))throw C('"parameters" contains a JARM response, use validateJwtAuthResponse() instead of validateAuthResponse()',H,{parameters:n});let o=Ht(n,"iss"),i=Ht(n,"state");if(!o&&e.authorization_response_iss_parameter_supported)throw C('response parameter "iss" (issuer) missing',H,{parameters:n});if(o&&o!==e.issuer)throw C('unexpected "iss" (issuer) response parameter value',H,{expected:e.issuer,parameters:n});switch(r){case void 0:case Ow:if(i!==void 0)throw C('unexpected "state" response parameter encountered',H,{expected:void 0,parameters:n});break;case mf:break;default:if(ye(r,'"expectedState" argument'),i!==r)throw C(i===void 0?'response parameter "state" missing':'unexpected "state" response parameter value',H,{expected:r,parameters:n})}if(Ht(n,"error"))throw new Ir("authorization response from the server is an error",{cause:n});let a=Ht(n,"id_token"),c=Ht(n,"token");if(a!==void 0||c!==void 0)throw new vt("implicit and hybrid flows are not supported");return gw(new URLSearchParams(n))}async function yf(e,t=tf){let n;try{n=await e.json()}catch(r){throw t(e),C('failed to parse "response" body as JSON',zr,r)}if(!Ho(n))throw C('"response" body must be a top level object',H,{body:n});return n}var qo=Symbol(),wa=Symbol();var Dr,wf;(typeof navigator>"u"||!navigator.userAgent?.startsWith?.("Mozilla/5.0 "))&&(wf="openid-client/v6.8.7",Dr={"user-agent":wf});var Be=e=>ba.get(e),ba,_a;function Iw(e){return e!==void 0?la(e):(_a||=new WeakMap,(t,n,r,o)=>{let i;return(i=_a.get(n))||(zw(n.client_secret,'"metadata.client_secret"'),i=la(n.client_secret),_a.set(n,i)),i(t,n,r,o)})}function zw(e,t){if(typeof e!="string")throw We(`${t} must be a string`,Mr);if(e.length===0)throw We(`${t} must not be empty`,Ur)}function $w(){return rf()}var Cn=qt;var Ur="ERR_INVALID_ARG_VALUE",Mr="ERR_INVALID_ARG_TYPE";function We(e,t,n){let r=new TypeError(e,{cause:n});return Object.assign(r,{code:t}),r}function bf(){return nf()}var Dn=class extends Error{code;constructor(t,n){super(t,n),this.name=this.constructor.name,this.code=n?.code,Error.captureStackTrace?.(this,this.constructor)}},YT=new TextDecoder;function me(e,t,n){return new Dn(e,{cause:t,code:n})}function Cr(e){if(e instanceof TypeError||e instanceof Dn||e instanceof In||e instanceof Ir||e instanceof zn)throw e;if(e instanceof kr)switch(e.code){case ma:throw me("only requests to HTTPS are allowed",e,e.code);case ga:throw me("only requests to HTTP or HTTPS are allowed",e,e.code);case ti:throw me("unexpected HTTP response status code",e.cause,e.code);case ha:throw me("unexpected response content-type",e.cause,e.code);case zr:throw me("parsing error occured",e,e.code);case H:throw me("invalid response encountered",e,e.code);case Ve:throw me("unexpected JWT claim value encountered",e,e.code);case ni:throw me("unexpected JSON attribute value encountered",e,e.code);case $n:throw me("JWT timestamp claim value failed validation",e,e.code);default:throw me(e.message,e,e.code)}if(e instanceof vt)throw me("unsupported operation",e,e.code);if(e instanceof DOMException)switch(e.name){case"OperationError":throw me("runtime operation error",e,ei);case"NotSupportedError":throw me("runtime unsupported operation",e,ei);case"TimeoutError":throw me("operation timed out",e,"OAUTH_TIMEOUT");case"AbortError":throw me("operation aborted",e,"OAUTH_ABORT")}throw new Dn("something went wrong",{cause:e})}function Cw(e,t,n){return e.origin==="https://login.microsoftonline.com"&&(!n?.algorithm||n.algorithm==="oidc")?(t[Ef]=!0,!0):!1}function Dw(e,t){return!!(e.hostname.endsWith(".b2clogin.com")&&(!t?.algorithm||t.algorithm==="oidc"))}async function xf(e,t,n,r,o){let i=await Uw(e,o),s=new Un(i,t,n,r),a=Be(s);if(o?.[Cn]&&(a.fetch=o[Cn]),o?.timeout&&(a.timeout=o.timeout),o?.execute)for(let c of o.execute)c(s);return s}async function Uw(e,t){if(!(e instanceof URL))throw We('"server" must be an instance of URL',Mr);let n=!e.href.includes("/.well-known/"),r=t?.timeout??30,o=AbortSignal.timeout(r*1e3),i=await(n?Qd(e,{algorithm:t?.algorithm,[qt]:t?.[Cn],[Gt]:t?.execute?.includes(_f),signal:o,headers:new Headers(Dr)}):(t?.[Cn]||fetch)((Xo(e,!t?.execute?.includes(_f)),e.href),{headers:Object.fromEntries(new Headers({accept:"application/json",...Dr}).entries()),body:void 0,method:"GET",redirect:"manual",signal:o})).then(s=>ef(qo,s)).catch(Cr);return n&&new URL(i.issuer).href!==e.href&&(Cw(e,i,t)||Dw(e,t)||(()=>{throw new Dn("discovered metadata issuer does not match the expected issuer",{code:ni,cause:{expected:e.href,body:i,attribute:"issuer"}})})()),i}function Mw(e){return{supportsPKCE:{__proto__:null,value(t="S256"){return e.code_challenge_methods_supported?.includes(t)===!0}}}}function Lw(e){Object.defineProperties(e,Mw(e))}var Ef=Symbol(),Un=class{constructor(t,n,r,o){if(typeof n!="string"||!n.length)throw We('"clientId" must be a non-empty string',Mr);if(typeof r=="string"&&(r={client_secret:r}),r?.client_id!==void 0&&n!==r.client_id)throw We('"clientId" and "metadata.client_id" must be the same',Ur);let i={...structuredClone(r),client_id:n};i[Jo]=r?.[Jo]??0,i[Ko]=r?.[Ko]??30;let s;o?s=o:typeof i.client_secret=="string"&&i.client_secret.length?s=Iw(i.client_secret):s=$w();let a=Object.freeze(i),c=structuredClone(t);Ef in t&&(c[wa]=({claims:{tid:l}})=>t.issuer.replace("{tenantid}",l));let u=Object.freeze(c);ba||=new WeakMap,ba.set(this,{__proto__:null,as:u,c:a,auth:s,tlsOnly:!0,jwksCache:{}})}serverMetadata(){let t=structuredClone(Be(this).as);return Lw(t),t}clientMetadata(){return structuredClone(Be(this).c)}get timeout(){return Be(this).timeout}set timeout(t){Be(this).timeout=t}get[Cn](){return Be(this).fetch}set[Cn](t){Be(this).fetch=t}};Object.freeze(Un.prototype);function Nw(e){let t;if(e.expires_in!==void 0){let n=new Date;n.setSeconds(n.getSeconds()+e.expires_in),t=n.getTime()}return{expiresIn:{__proto__:null,value(){if(t){let n=Date.now();return t>n?Math.floor((t-n)/1e3):0}}},claims:{__proto__:null,value(){return Qo(e)}}}}function Bw(e){Object.defineProperties(e,Nw(e))}function _f(e){Be(e).tlsOnly=!1}function jw(e){return e=new URL(e),e.search="",e.hash="",e.href}function Zw(e,t){try{return Object.getPrototypeOf(e)[Symbol.toStringTag]===t}catch{return!1}}async function xa(e,t,n,r,o){if(Ea(e),o?.flag!==ri&&!(t instanceof URL)&&!Zw(t,"Request"))throw We('"currentUrl" must be an instance of URL, or Request',Mr);let i,s,{as:a,c,auth:u,fetch:l,tlsOnly:d,jarm:f,hybrid:m,nonRepudiation:w,timeout:b,decrypt:S,implicit:h}=Be(e);if(o?.flag===ri)i=o.authResponse,s=o.redirectUri;else{if(!(t instanceof URL)){let A=t;switch(t=new URL(t.url),A.method){case"GET":break;case"POST":let k=new URLSearchParams(await hf(A));if(m)t.hash=k.toString();else for(let[I,U]of k.entries())t.searchParams.append(I,U);break;default:throw We("unexpected Request HTTP method",Ur)}}switch(s=jw(t),!0){case!!f:i=await f(t,n?.expectedState);break;case!!m:i=await m(t,n?.expectedNonce,n?.expectedState,n?.maxAge);break;case!!h:throw new TypeError("authorizationCodeGrant() cannot be used by response_type=id_token clients");default:try{i=gf(a,c,t.searchParams,n?.expectedState)}catch(A){Cr(A)}}}let _=await lf(a,c,u,i,s,n?.pkceCodeVerifier||pa,{additionalParameters:r,[qt]:l,[Gt]:!d,DPoP:o?.DPoP,headers:new Headers(Dr),signal:Sf(b)}).catch(Cr);(typeof n?.expectedNonce=="string"||typeof n?.maxAge=="number")&&(n.idTokenExpected=!0);let x=df(a,c,_,{expectedNonce:n?.expectedNonce,maxAge:n?.maxAge,requireIdToken:n?.idTokenExpected,[Fo]:S}),E;try{E=await x}catch(A){if(Fw(A,o))return xa(e,void 0,n,r,{...o,flag:ri,authResponse:i,redirectUri:s});Cr(A)}return E.id_token&&await w?.(_),Bw(E),E}function vf(e,t){Ea(e);let{as:n,c:r,tlsOnly:o,hybrid:i,jarm:s,implicit:a}=Be(e),c=Yo(n,"authorization_endpoint",!1,o);if(t=new URLSearchParams(t),t.has("client_id")||t.set("client_id",r.client_id),!t.has("request_uri")&&!t.has("request")){if(t.has("response_type")||t.set("response_type",i?"code id_token":a?"id_token":"code"),a&&!t.has("nonce"))throw We("response_type=id_token clients must provide a nonce parameter in their authorization request parameters",Ur);s&&t.set("response_mode","jwt")}for(let[u,l]of t.entries())c.searchParams.append(u,l);return c}function Ea(e){if(!(e instanceof Un))throw We('"config" must be an instance of Configuration',Mr);if(Object.getPrototypeOf(e)!==Un.prototype)throw We("subclassing Configuration is not allowed",Ur)}function Sf(e){return e?AbortSignal.timeout(e*1e3):void 0}function Fw(e,t){return t?.DPoP&&t.flag!==ri?of(e):!1}var ri=Symbol();async function Af(e,t,n){Ea(e);let{as:r,c:o,auth:i,fetch:s,tlsOnly:a,timeout:c}=Be(e);return ff(r,o,i,t,{[qt]:s,[Gt]:!a,additionalParameters:new URLSearchParams(n),headers:new Headers(Dr),signal:Sf(c)}).then(pf).catch(Cr)}var Rf="oauth2:",Lr="graffiti-auth-oauth2-data",oi=class{eventTarget=new EventTarget;constructor(){let t=this.completeOauth();(async()=>{await new Promise(r=>setTimeout(r,0)),await t;let n=new CustomEvent("initialized");this.eventTarget.dispatchEvent(n)})()}async login(...t){try{await this.login_(...t)}catch(n){let r=n instanceof Error?n:new Error("Unknown error"),o={loginId:t[1],error:r};this.eventTarget.dispatchEvent(new CustomEvent("login",{detail:o}))}}async login_(t,n,r){let o=await this.getAuthorizationConfiguration(t),i=r.map(encodeURIComponent).join(" "),s=bf(),a,c;if(typeof window<"u"){a=window.location.href;let d={loginId:n,redirectUri:a,authorizationEndpoint:t,state:s,serviceEndpoints:r};window.localStorage.setItem(Lr,JSON.stringify(d))}else{let f=(await import("node:http").catch(w=>{throw new Error("Unrecognized environment: cannot find window or node:http")})).createServer();try{await new Promise((w,b)=>{f.once("error",b),f.listen(0,"::1",w)})}catch{try{f.close()}catch{}throw new Error("Failed to start local oauth callback server.")}let m=f.address();if(!m){try{f.close()}catch{}throw new Error("Failed to get local oauth callback server address.")}a=typeof m=="string"?`http://${m}`:`http://${m.family==="IPv6"?`[${m.address}]`:m.address}:${m.port}`,c=new Promise((w,b)=>{let S=setTimeout(()=>{try{f.close()}catch{}b("Oauth callback timed out.")},3e5),h=new Set;f.on("connection",x=>{h.add(x),x.on("close",()=>{h.delete(x)})});let _=async(x,E)=>{try{let A=new URL(x.url??"/",a);await this.onCallbackUrl({loginId:n,callbackUrl:A,configuration:o,expectedState:s,serviceEndpoints:r}),E.statusCode=200,E.setHeader("Content-Type","text/plain"),E.end("You may now close this window.")}catch(A){throw E.statusCode=500,E.setHeader("Content-Type","text/plain"),E.end("Error processing OAuth callback."),A}finally{clearTimeout(S),f.off("request",_);for(let A of h)A.destroy();f.close(()=>w())}};f.on("request",_)})}let u=new URL(a);u.hash="",u.search="";let l=vf(o,{scope:i,redirect_uri:u.toString(),state:s});typeof window<"u"?window.location.href=l.toString():(console.log("Please open the following URL in your browser:"),console.log(l.toString()),await c)}completeOauth(){if(typeof window>"u")return;let t=window.localStorage.getItem(Lr);if(!t)return;let n;try{n=JSON.parse(t)}catch{console.error("Invalid OAuth2 login data in local storage."),window.localStorage.removeItem(Lr);return}let r=Hw.safeParse(n);if(!r.success){console.error("Invalid OAuth2 login data structure in local storage.",r.error),window.localStorage.removeItem(Lr);return}let{loginId:o,redirectUri:i,authorizationEndpoint:s,state:a,serviceEndpoints:c}=r.data;try{let u=new URL(i),l=new URL(window.location.href);if(u.pathname!==l.pathname)return;let d=l.searchParams;return!d.has("code")&&!d.has("error")?void 0:(window.history.replaceState({},document.title,u.toString()),window.localStorage.removeItem(Lr),new Promise(f=>setTimeout(f,0)).then(()=>this.getAuthorizationConfiguration(s)).then(f=>this.onCallbackUrl({loginId:o,callbackUrl:l,configuration:f,expectedState:a,serviceEndpoints:c})).catch(f=>{let m=f instanceof Error?f:new Error("Unknown error"),w={loginId:o,error:m};this.eventTarget.dispatchEvent(new CustomEvent("login",{detail:w}))}))}catch(u){console.error(u)}}async onCallbackUrl(t){let{loginId:n,callbackUrl:r,configuration:o,expectedState:i,serviceEndpoints:s}=t,a=await xa(o,r,{expectedState:i}),c=a.access_token,l=a.scope?.split(" ").map(decodeURIComponent)||s;if(!s.every(f=>l.includes(f)))throw new Error("Not all requested service endpoints were granted.");let d=new CustomEvent("login",{detail:{loginId:n,token:c}});this.eventTarget.dispatchEvent(d)}async logout(t,n,r){try{await this.logout_(t,n,r)}catch(o){let i=o instanceof Error?o:new Error("Unknown error"),s={logoutId:n,error:i};this.eventTarget.dispatchEvent(new CustomEvent("logout",{detail:s}))}}async logout_(t,n,r){let o=await this.getAuthorizationConfiguration(t);await Af(o,r);let i={logoutId:n};this.eventTarget.dispatchEvent(new CustomEvent("logout",{detail:i}))}async getAuthorizationConfiguration(t){if(!t.startsWith(Rf))throw new Error(`Unrecognized authorization endpoint method: ${t}`);let n=t.slice(Rf.length),r;try{r=new URL(n)}catch{throw new Error("Invalid issuer URL.")}return await xf(r,"graffiti-client")}},Pf=_u(be({loginId:j()}),at([be({token:j(),error:Y(wu())}),be({error:nn(Error)})])),Tf=be({logoutId:j(),error:Y(nn(Error))}),Of=Y(Ue(be({error:Y(nn(Error))}))),Hw=be({loginId:j(),redirectUri:F(),authorizationEndpoint:F(),state:j(),serviceEndpoints:J(F())});var Gw="https://";function Ce(e){if(!e.startsWith(Gw))throw new Error("Unrecognized storage bucket endpoint type")}async function ii(e){Ce(e);let t=`${e}/auth`,n=await fetch(t);if(!n.ok)throw new Error("Failed to get storage bucket authorization endpoint");return await n.text()}var Jt=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorUnauthorized",Object.setPrototypeOf(this,e.prototype)}};async function Xe(...e){let t=await fetch(...e);if(!t.ok){let n;try{n=await t.text()}catch{n=t.statusText}throw t.status===401?new Jt(n):t.status===403?new ht(n):t.status===404?new ne(n):t.status===410?new Me(n):t.status===413?new sn(n):new Error(n)}return t}var si=class{getAuthorizationEndpoint=ii;async put(t,n,r,o){Ce(t);let i=`${t}/value/${encodeURIComponent(n)}`;await Xe(i,{method:"PUT",headers:{"Content-Type":"application/octet-stream",Authorization:`Bearer ${o}`},body:r.slice()})}async delete(t,n,r){Ce(t);let o=`${t}/value/${encodeURIComponent(n)}`;await Xe(o,{method:"DELETE",headers:{Authorization:`Bearer ${r}`}})}async get(t,n,r){Ce(t);let o=`${t}/value/${encodeURIComponent(n)}`,i=await Xe(o),s=i.body?.getReader();if(!s)throw new Error("Failed to read value from storage bucket");let a=i.headers.get("Content-Length"),c=a?Number(a):void 0;if(!!c&&!!Number.isFinite(c)&&c>=0){let w=c;if(r!==void 0&&w>r)throw new Error("Value exceeds maximum byte limit");let b=new Uint8Array(w),S=0,h=!1;try{for(;S<=b.length;){let{done:_,value:x}=await s.read();if(_){h=!0;break}if(!x||x.length===0)continue;let E=S+x.length;if(E>b.length)throw new Error("Received more data than expected");b.set(x,S),S=E}}finally{s.releaseLock()}if(!h)throw new Error("Failed to read complete value from storage bucket");return S===w?b:b.slice(0,S)}let l=[],d=0;try{for(;;){let{done:w,value:b}=await s.read();if(w)break;if(!(!b||b.length===0)){if(d+=b.length,r!==void 0&&d>r)throw new Error("Value exceeds maximum byte limit");l.push(b.slice())}}}finally{s.releaseLock()}let f=new Uint8Array(d),m=0;for(let w of l)f.set(w,m),m+=w.length;return f}async*export(t,n){Ce(t);let r=`${t}/export`,o;for(;;){let s=await(await Xe(o?`${r}?cursor=${encodeURIComponent(o)}`:r,{headers:{Authorization:`Bearer ${n}`}})).blob(),a=Je(await s.arrayBuffer()),c=qw.parse(a);for(let u of c.keys)yield{key:u};if(c.cursor)o=c.cursor;else break}}},qw=be({keys:J(j()),cursor:Y(Ue(j()))});var ci=class{getAuthorizationEndpoint=ii;cache_=null;get cache(){return this.cache_||(this.cache_=Qw()),this.cache_}async send(t,n){Ce(t);let r=`${t}/send`,i=await(await Xe(r,{method:"PUT",headers:{"Content-Type":"application/cbor"},body:new Uint8Array(Pe({m:n}))})).blob(),s=Je(await i.arrayBuffer());return Ww.parse(s).id}async get(t,n,r){let o=ai(t,n),i=await this.cache,s=await i.messages.get(o);if(s!==void 0)return s;let a=`${t}/message/${n}`,c=null;try{c=await Xe(a,{method:"GET",headers:{...r?{Authorization:`Bearer ${r}`}:{}}})}catch(f){if(f instanceof ne)return await i.messages.set(o,null),null;throw f}let u=await c.blob(),l=Je(await u.arrayBuffer()),d=Cf.parse(l);return await i.messages.set(o,d),d}async label(t,n,r,o){if(Ce(t),o){let c=`${t}/label/${n}`;await Xe(c,{method:"PUT",headers:{"Content-Type":"application/cbor",Authorization:`Bearer ${o}`},body:new Uint8Array(Pe({l:r}))})}let i=await this.cache,s=ai(t,n),a=await i.messages.get(s);a&&await i.messages.set(s,{...a,l:r})}async fetchMessageBatch(t,n,r,o,i,s){let a=await Xe(`${t}/${n}${i?`?cursor=${encodeURIComponent(i)}`:""}`,{method:"POST",headers:{"Content-Type":"application/cbor",...o?{Authorization:`Bearer ${o}`}:{}},body:r,signal:s}),c=a.headers.get("Retry-After"),u=c?parseInt(c):void 0,l=u&&Number.isFinite(u)?Date.now()+u*1e3:void 0;return{response:a,waitTil:l}}async*yieldFromCache(t,n,r,o,i=0){let s=o.messageIds.slice(i);yield*await Promise.all(s.map(async c=>{let u=await t.messages.get(ai(n,c));if(!u){try{await t.messageIds.del(r)}catch{}throw new Error("Cache out of sync - perhaps clear browser storage")}return u}))}async*lockedMessageStreamer(...t){if(typeof window>"u"||!await Df()){let w=this.messageStreamer(...t);for(;;){let b=await w.next();if(b.done)return b.value;yield b.value}}let n=await t[0],r=`graffiti:inbox:${n}`,o=()=>{},i=!1;if(await new Promise(w=>{window.navigator.locks.request(r,{mode:"exclusive",ifAvailable:!0},async b=>{i=!!b,w(),await new Promise(S=>o=S)})}),i)try{let w=this.messageStreamer(...t);for(;;){let b=await w.next();if(b.done)return b.value;yield b.value}}finally{o()}o(),await window.navigator.locks.request(r,()=>{});let s=t[1],a=t[5]??{},c=t[6],u=t[7],l=await this.cache,d=await l.messageIds.get(n);if(!d)throw new Error("Cache not found");if(c!==void 0&&c!==d.version)throw new Me("Cursor is stale");let f=this.yieldFromCache(l,s,n,d,u);for await(let w of f)yield w;let m={numSeen:d.messageIds.length,version:d.version,messageIdsCacheKey:n,objectSchema:a};return JSON.stringify(m)}async*messageStreamer(t,n,r,o,i,s={},a,c=0){let u=await ro(s),l=await t,d=await this.cache,f=await d.messageIds.get(l);if(a!==void 0&&a!==f?.version)throw new Me("Cursor is stale");let m=f?.waitTil;await zf(m);let w=f?.cursor,b;try{let A=await this.fetchMessageBatch(n,r,o,i,w);b=A.response,m=A.waitTil}catch(A){if(!(A instanceof Me&&w))throw console.error("Unexpected error in stream, waiting 5 seconds before continuing..."),await new Promise(k=>setTimeout(k,5e3)),A;if(await d.messageIds.del(l),a===void 0)f=void 0;else throw A}if(b!==void 0&&f){let A=this.yieldFromCache(d,n,l,f,c);for await(let k of A)yield k}if(b===void 0){let A=await this.fetchMessageBatch(n,r,o,i);b=A.response,m=A.waitTil}let S=b,h,_=f?.version??crypto.randomUUID(),x=f?.messageIds??[];for(;;){let A=await S.blob(),k=Je(await A.arrayBuffer()),{results:I,hasMore:U,cursor:V}=Xw.parse(k);h=V;let G=I.map(L=>{let B=L[Kt][lt];if(!u(B))throw new Error("Server returned data that does not match schema");return{...L,[Kt]:{...L[Kt],[lt]:B}}});await d.messages.setMany(G.map(L=>[ai(n,L[va]),L])),x=[...x,...G.map(L=>L[va])],await d.messageIds.set(l,{cursor:h,version:_,messageIds:x,waitTil:m}),c+=G.length;let g=new AbortController,v=U?zf(m).then(()=>this.fetchMessageBatch(n,r,void 0,i,h,g.signal)).then(L=>({value:L}),L=>({error:L})):null,D=!1;try{for(let L of G)yield L;D=!0}finally{D||g.abort()}if(!U)break;let M=await v;if("error"in M)throw M.error;S=M.value.response,m=M.value.waitTil}return JSON.stringify({numSeen:c,version:_,messageIdsCacheKey:l,objectSchema:s})}query(t,n,r,o){Ce(t);let i=Pe({tags:n,schema:r}),s=kf(t,"query",i);return this.lockedMessageStreamer(s,t,"query",new Uint8Array(i),o,r)}continueQuery(t,n,r){Ce(t);let o=JSON.parse(n),{messageIdsCacheKey:i,numSeen:s,objectSchema:a,version:c}=Yw.parse(o);return this.lockedMessageStreamer(Promise.resolve(i),t,"query",void 0,r,a,c,s)}export(t,n){Ce(t);let r=kf(t,"export");return this.lockedMessageStreamer(r,t,"export",void 0,n)}},Jw=xe({value:Ee({}),channels:J(j()),allowed:Y(Ue(J(F()))),url:F(),actor:F()}),$f=Dt(e=>e instanceof Uint8Array),Kw=J($f),Nr="t",lt="o",Br="m",Vw=xe({[Nr]:Kw,[lt]:Jw,[Br]:$f}),va="id",Kt="m",ui="l",Cf=xe({[va]:j(),[Kt]:Vw,[ui]:yu()}),Ww=xe({id:j()}),Xw=xe({results:J(Cf),hasMore:Vn(),cursor:j()}),Yw=xe({messageIdsCacheKey:j(),version:j(),numSeen:tn().check(Ct()),objectSchema:at([Ee({}),Vn()])});async function Df(){try{return globalThis.indexedDB?(await new Promise((e,t)=>{let n=indexedDB.open("__idb_probe__",1);n.onupgradeneeded=()=>n.result.createObjectStore("k"),n.onsuccess=()=>{n.result.close(),e()},n.onerror=()=>t(n.error)}),!0):!1}catch{return!1}}function ai(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}async function kf(e,t,n){let r=Pe({inboxUrl:e,type:t,body:n??null});return crypto.subtle.digest("SHA-256",new Uint8Array(r)).then(o=>Array.from(new Uint8Array(o)).map(i=>i.toString(16).padStart(2,"0")).join(""))}async function If(){await new Promise(e=>{let t=indexedDB.deleteDatabase("graffiti-inbox-cache");t.onsuccess=()=>e(),t.onerror=()=>e(),t.onblocked=()=>e()})}async function Qw(){if(await Df()){let{openDB:n}=await import("./build-KAK33G4E.js"),r=await n("graffiti-inbox-cache",1,{upgrade(o){o.objectStoreNames.contains("m")||o.createObjectStore("m"),o.objectStoreNames.contains("q")||o.createObjectStore("q")}});return{messages:{get:async o=>{try{return r.get("m",o)}catch(i){console.error("Error getting message from cache:",i),console.error("resetting cache..."),await If();return}},set:async(o,i)=>{await r.put("m",i,o)},setMany:async o=>{if(o.length===0)return;let i=r.transaction("m","readwrite");await Promise.all([...o.map(([s,a])=>i.store.put(a,s)),i.done])},del:o=>r.delete("m",o)},messageIds:{get:async o=>{try{return await r.get("q",o)}catch(i){console.error("Error getting message IDs from cache:",i),console.error("resetting cache..."),await If();return}},set:async(o,i)=>{await r.put("q",i,o)},del:o=>r.delete("q",o)}}}let e=new Map,t=new Map;return{messages:{get:async n=>e.get(n),set:async(n,r)=>{e.set(n,r)},setMany:async n=>{for(let[r,o]of n)e.set(r,o)},del:async n=>{e.delete(n)}},messageIds:{get:async n=>t.get(n),set:async(n,r)=>{t.set(n,r)},del:async n=>{t.delete(n)}}}}async function zf(e){if(e!==void 0){let t=e-Date.now();t>0&&await new Promise(n=>setTimeout(n,t))}}var Mn="base64url";var li=class{async encode(t,n){if(t!==Mn)throw new Error(`Unsupported string encoding method: ${t}`);return"u"+btoa(String.fromCodePoint(...n)).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=+$/,"")}async decode(t){if(!t.startsWith("u"))throw new Error(`Unsupported string encoding prefix: ${t[0]}`);t=t.slice(1);let n=t.replace(/-/g,"+").replace(/_/g,"/");for(;n.length%4!==0;)n+="=";return Uint8Array.from(atob(n),r=>r.charCodeAt(0))}};function Uf(){let t=(typeof globalThis=="object"?globalThis.crypto:null)?.subtle;if(typeof t=="object"&&t!=null)return t;throw new Error("crypto.subtle must be defined")}function Mf(e,t,n){let r=async o=>{Xn(o);let i=Uf();return new Uint8Array(await i.digest(e,o))};return r.webCryptoName=e,r.outputLen=n,r.blockLen=t,r.create=()=>{throw new Error("not implemented")},Object.freeze(r)}function e_(e){Ou(e);let t=e.webCryptoName;if(typeof t!="string")throw new Error("non-web hash");return t}var Vt=Mf("SHA-256",64,32);var Lf=Mf("SHA-512",128,64),Sa=(()=>{let e=async(t,n,r)=>{let o=Uf();Xn(n,void 0,"key"),Xn(r,void 0,"message");let i=e_(t),s=Tu(r);try{let a=await o.importKey("raw",n,{name:"HMAC",hash:i},!1,["sign"]);return new Uint8Array(await o.sign("HMAC",a,s))}finally{ku(s)}};return e.create=(t,n)=>{throw new Error("not implemented")},e})();var di="sha2-256",jr=18,Ln=32,fi=class{async register(t,n){if(t!==di)throw new Error(`Unsupported content address method: ${t}`);let r=await Vt(n),o=new Uint8Array(2+r.length);return o[0]=jr,o[1]=Ln,o.set(r,2),o}async getMethod(t){if(t[0]===jr&&t[1]===Ln&&t.length===2+Ln)return di;throw new Error("Unrecognized content address format.")}};var Hf=Object.freeze,Nn=0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,mi=0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,pi=0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Ra=0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Pa=0x6666666666666666666666666666666666666666666666666666666666666658n,hi=Nn-1n,t_=Hf({p:Nn,n:mi,h:8n,a:hi,d:pi,Gx:Ra,Gy:Pa}),Zr=32,Nf=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&e.BYTES_PER_ELEMENT===1,Qe=(e,t,n="")=>{if(Nf(e)&&(t===void 0||e.length===t))return e;let r=Nf(e),o=t!==void 0?` of length ${t}`:"",i=r?`length=${e.length}`:`type=${typeof e}`,s=(n?`"${n}" `:"")+"expected Uint8Array"+o+", got "+i;throw r?new RangeError(s):new TypeError(s)},Ta=(e,t="",n)=>Uint8Array.from(Qe(e,n,t)),Gf=(e,t)=>e.toString(16).padStart(t,"0"),qf=e=>{let t="";for(let n of Qe(e))t+=Gf(n,2);return t},Jf=e=>{let t="hex invalid";if(typeof e!="string")throw new TypeError(t);if(e.length%2||!/^[\da-f]*$/i.test(e))throw new RangeError(t);let n=new Uint8Array(e.length/2);for(let r=0,o=0;r<n.length;r++,o+=2){let i=e.charCodeAt(o),s=e.charCodeAt(o+1);n[r]=((i&15)+(i>>6)*9)*16+(s&15)+(s>>6)*9}return n},Fr=(...e)=>{let t=0;for(let o of e)t+=Qe(o).length;let n=new Uint8Array(t),r=0;for(let o of e)n.set(o,r),r+=o.length;return n};var Wt=(e,t,n,r="bad number: out of range")=>{if(typeof e!="bigint")throw new TypeError(r);if(t<=e&&e<n)return e;throw new RangeError(r)},X=(e,t=Nn)=>(e%=t)>=0n?e:t+e,Bf=(1n<<255n)-1n,O=e=>{if(e<0n)throw new RangeError("negative coordinate");let t=(e>>255n)*19n+(e&Bf);return t=(t>>255n)*19n+(t&Bf),t%Nn},Kf=e=>X(e,mi),n_=(e,t)=>{if(e===0n)throw new Error("invert: expected non-zero number");if(t<=1n)throw new Error("invert: expected modulus > 1, got "+t);let n=X(e,t),r=t,o=0n,i=1n;for(;n!==0n;){let a=r/n,c=r-n*a,u=o-i*a;r=n,n=c,o=i,i=u}if(r!==1n)throw new Error("invert: does not exist");return X(o,t)},r_=e=>{let t=Ia[e];if(typeof t!="function")throw new Error("hashes."+e+" not set");return t};var Oa=async(e,...t)=>Qe(await r_(e)(Fr(...t)),64,"digest");var Aa=e=>{if(e instanceof dt)return e;throw new TypeError("Point expected")},Vf=2n**256n,dt=class e{static BASE;static ZERO;X;Y;Z;T;constructor(t,n,r,o){let i=Vf;this.X=Wt(t,0n,i),this.Y=Wt(n,0n,i),this.Z=Wt(r,1n,i),this.T=Wt(o,0n,i),Hf(this)}static CURVE(){return t_}static fromAffine(t){return new e(t.x,t.y,1n,O(t.x*t.y))}static fromBytes(t,n=!1){let r=Ta(t,"point",Zr),o=r[31];r[31]=o&-129;let i=ka(r);n||Wt(i,0n,Nn);let s=O(i*i),a=X(s-1n),c=O(pi*s+1n),{isValid:u,value:l}=i_(a,c);if(!u)throw new Error("bad point: y not sqrt");let d=!!(o&128);if(!n&&l===0n&&d)throw new Error("bad point: x==0, isLastByteOdd");return d!==!!(l&1n)&&(l=X(-l)),new e(l,i,1n,O(l*i))}static fromHex(t,n){return e.fromBytes(Jf(t),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){let t=hi,n=pi,r=this;if(r.is0())throw new Error("bad point: ZERO");let{X:o,Y:i,Z:s,T:a}=r,c=O(o*o),u=O(i*i),l=O(s*s),d=O(l*l),f=O(c*t),m=O(l*(f+u)),w=X(d+O(n*O(c*u)));if(m!==w)throw new Error("bad point: equation left != right (1)");let b=O(o*i),S=O(s*a);if(b!==S)throw new Error("bad point: equation left != right (2)");return this}equals(t){let{X:n,Y:r,Z:o}=this,{X:i,Y:s,Z:a}=Aa(t);return O(n*a)===O(i*o)&&O(r*a)===O(s*o)}is0(){return this.equals(Xt)}negate(){return new e(X(-this.X),this.Y,this.Z,X(-this.T))}double(){let{X:t,Y:n,Z:r}=this,o=hi,i=O(t*t),s=O(n*n),a=O(2n*r*r),c=O(o*i),u=X(t+n),l=X(O(u*u)-i-s),d=X(c+s),f=X(d-a),m=X(c-s),w=O(l*f),b=O(d*m),S=O(l*m),h=O(f*d);return new e(w,b,h,S)}add(t){let{X:n,Y:r,Z:o,T:i}=this,{X:s,Y:a,Z:c,T:u}=Aa(t),l=hi,d=pi,f=O(n*s),m=O(r*a),w=O(O(i*d)*u),b=O(o*c),S=X(O(X(n+r)*X(s+a))-f-m),h=X(b-w),_=X(b+w),x=X(m-O(l*f)),E=O(S*h),A=O(_*x),k=O(S*x),I=O(h*_);return new e(E,A,I,k)}subtract(t){return this.add(Aa(t).negate())}multiply(t,n=!0){if(!n&&t===0n||(Wt(t,1n,mi),!n&&this.is0()))return Xt;if(t===1n)return this;if(this.equals(St))return d_(t).p;let r=Xt,o=St,i=this;for(let s=0;n?s<256:t>0n;s++)t&1n?r=r.add(i):n&&(o=o.add(i)),i=i.double(),t>>=1n;return r}multiplyUnsafe(t){return this.multiply(t,!1)}toAffine(){let{X:t,Y:n,Z:r}=this;if(this.equals(Xt))return{x:0n,y:1n};let o=n_(r,Nn);if(O(r*o)!==1n)throw new Error("invalid inverse");return{x:O(t*o),y:O(n*o)}}toBytes(){let{x:t,y:n}=this.toAffine(),r=Wf(n);return r[31]|=t&1n?128:0,r}toHex(){return qf(this.toBytes())}clearCofactor(){return this.multiply(8n,!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return this.multiply(mi/2n,!1).double().add(this).is0()}},St=new dt(Ra,Pa,1n,X(Ra*Pa)),Xt=new dt(0n,1n,1n,0n);dt.BASE=St;dt.ZERO=Xt;var Wf=e=>Jf(Gf(Wt(e,0n,Vf),64)).reverse(),ka=e=>BigInt("0x"+qf(Uint8Array.from(Qe(e)).reverse())),Ye=(e,t)=>{let n=e;for(;t-- >0;)n=O(n*n);return n},o_=e=>{let t=O(e*e),n=O(t*e),r=O(Ye(n,2)*n),o=O(Ye(r,1)*e),i=O(Ye(o,5)*o),s=O(Ye(i,10)*i),a=O(Ye(s,20)*s),c=O(Ye(a,40)*a),u=O(Ye(c,80)*c),l=O(Ye(u,80)*c),d=O(Ye(l,10)*i);return O(Ye(d,2)*e)},jf=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,i_=(e,t)=>{let n=O(t*O(t*t)),r=O(O(n*n)*t),o=o_(O(e*r)),i=O(e*O(n*o)),s=O(t*O(i*i)),a=i,c=O(i*jf),u=s===e,l=s===X(-e),d=s===X(-e*jf);return u&&(i=a),(l||d)&&(i=c),(X(i)&1n)===1n&&(i=X(-i)),{isValid:u||l,value:i}},gi=e=>Kf(ka(e)),s_=e=>{let t=Ta(e),n=t.slice(0,32);n[0]&=248,n[31]&=127,n[31]|=64;let r=t.slice(32),o=gi(n),i=St.multiply(o),s=i.toBytes();return{head:n,prefix:r,scalar:o,point:i,pointBytes:s}},Xf=e=>Oa("sha512Async",Qe(e,Zr,"secretKey")).then(s_);var Yf=e=>Xf(e).then(t=>t.pointBytes);var Qf=async e=>e[1](await Oa("sha512Async",e[0]));var a_=(e,t,n)=>{let{pointBytes:r,scalar:o}=e,i=gi(t),s=St.multiply(i).toBytes();return[Fr(s,r,n),u=>{let l=Kf(i+gi(u)*o);return Qe(Fr(s,Wf(l)),64)}]},ep=async(e,t)=>{let n=Ta(e,"message"),r=await Xf(t);return Qf(a_(r,await Oa("sha512Async",r.prefix,n),n))};var c_=e=>{if(e===null||typeof e!="object")throw new TypeError("expected valid options object");return e.zip215??!0},u_=(e,t,n,r)=>{e=Qe(e,64,"signature"),t=Qe(t,void 0,"message"),n=Qe(n,Zr,"publicKey");let o=c_(r),i=e.subarray(0,Zr),s=ka(e.subarray(Zr,64)),a,c,u,l=Uint8Array.of(),d=!1;try{a=dt.fromBytes(n,o),c=dt.fromBytes(i,o),u=St.multiply(s,!1),l=Fr(i,n,t),d=!0}catch{}return[l,m=>{if(!d||!o&&a.isSmallOrder())return!1;let w=gi(m);return c.add(a.multiply(w,!1)).subtract(u).clearCofactor().is0()}]},tp=async(e,t,n,r={})=>Qf(u_(e,t,n,r));var Ia={sha512Async:async e=>{let t=globalThis?.crypto?.subtle;if(!t)throw new Error("crypto.subtle must be defined, consider polyfill");return new Uint8Array(await t.digest("SHA-512",Fr(e)))},sha512:void 0};var l_=()=>{let e=[],t=St,n;for(let r=0;r<33;r++){n=t,e.push(n);for(let o=1;o<128;o++)n=n.add(t),e.push(n);t=n.double()}return e},Zf,Ff=(e,t)=>{let n=t.negate();return e?n:t},d_=e=>{let t=Zf||(Zf=l_()),n=Xt,r=St;for(let o=0;o<33;o++){let i=Number(e&255n);e>>=8n,i>128&&(i-=256,e+=1n);let s=o*128,a=s+Math.abs(i)-1,c=o%2!==0,u=i<0;i===0?r=r.add(Ff(c,t[s])):n=n.add(Ff(u,t[a]))}if(e!==0n)throw new Error("invalid wnaf");return{p:n,f:r}};Ia.sha512Async=Lf;var Yt="pk:sha2-256+ed25519",za=0,yi=class{async register(t,n){if(t!==Yt)throw new Error(`Unsupported channel attestation method: ${t}`);let r=await this.channelToPrivateKey(n);return await this.channelPublicIdFromPrivateKey(r)}async getMethod(t){if(t[0]===za)return Yt;throw new Error("Unrecognized channel attestation method.")}async channelToPrivateKey(t){let n=new TextEncoder().encode(t);return await Vt(n)}async channelPublicIdFromPrivateKey(t){let n=await Yf(t),r=new Uint8Array(n.length+1);return r[0]=za,r.set(n,1),r}async attest(t,n,r){if(t!==Yt)throw new Error(`Unsupported channel attestation method: ${t}`);let o=await this.channelToPrivateKey(r),i=await this.channelPublicIdFromPrivateKey(o),s=new TextEncoder().encode(n);return{attestation:await ep(s,o),channelPublicId:i}}async validate(t,n,r){let o=r[0];if(o!==za)throw new Error(`Unrecognized channel attestation method prefix: ${o}`);return await tp(t,new TextEncoder().encode(n),r.slice(1))}};var $a="hmac:sha2-256",np=0,wi=class{async attest(t,n){if(t!==$a)throw new Error(`Unsupported allowed attestation method: ${t}`);let r=Ut(),o=await Sa(Vt,r,new TextEncoder().encode(n)),i=new Uint8Array(r.length+3);return i[0]=np,i[1]=jr,i[2]=Ln,i.set(r,3),{attestation:o,ticket:i}}async validate(t,n,r){let o=r[0],i=r[1],s=r[2];if(o!==np||i!==jr||s!==Ln)throw new Error("Unrecognized allowed ticket format");let a=await Sa(Vt,r.slice(3),new TextEncoder().encode(n));return t.length!==a.length?!1:a.every((c,u)=>t[u]===c)}};var Ca="did:web:",_i=class{constructor(t){this.services=t}services;actorToHandle=async t=>{let r=(await this.services.dids.resolve(t)).alsoKnownAs?.at(0);if(!r)throw new ne(`Handle for actor DID ${t} not found`);if(!r.startsWith(Ca))throw new Error(`Handle DID ${r} is not a valid handle`);let o=r.slice(Ca.length),i=await this.services.dids.resolve(r);if(!i.alsoKnownAs||!i.alsoKnownAs.includes(t))throw new Error(`Handle ${o} does not match actor ${t}`);return o};handleToActor=async t=>{let n=`${Ca}${t}`,o=(await this.services.dids.resolve(n)).alsoKnownAs?.at(0);if(!o)throw new ne(`Actor for handle DID ${n} not found`);let i=await this.services.dids.resolve(o);if(!i.alsoKnownAs||!i.alsoKnownAs.includes(n))throw new Error(`Actor ${o} does not match handle ${t}`);return o}};function bi(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)r!=="__proto__"&&(e[r]=n[r])}return e}var f_={read:function(e){return e[0]==='"'&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};function Da(e,t){function n(o,i,s){if(!(typeof document>"u")){s=bi({},t,s),typeof s.expires=="number"&&(s.expires=new Date(Date.now()+s.expires*864e5)),s.expires&&(s.expires=s.expires.toUTCString()),o=encodeURIComponent(o).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var a="";for(var c in s)s[c]&&(a+="; "+c,s[c]!==!0&&(a+="="+s[c].split(";")[0]));return document.cookie=o+"="+e.write(i,o)+a}}function r(o){if(!(typeof document>"u"||arguments.length&&!o)){for(var i=document.cookie?document.cookie.split("; "):[],s={},a=0;a<i.length;a++){var c=i[a].split("="),u=c.slice(1).join("=");try{var l=decodeURIComponent(c[0]);if(l in s||(s[l]=e.read(u,l)),o===l)break}catch{}}return o?s[o]:s}}return Object.create({set:n,get:r,remove:function(o,i){n(o,"",bi({},i,{expires:-1}))},withAttributes:function(o){return Da(this.converter,bi({},this.attributes,o))},withConverter:function(o){return Da(bi({},this.converter,o),this.attributes)}},{attributes:{value:Object.freeze(t)},converter:{value:Object.freeze(e)}})}var xi=Da(f_,{path:"/"});var p_=365;function rp(e,t){xi.set(e,t,ip())}function op(e){return xi.get(e)}function Ua(e){xi.remove(e,ip())}function ip(){let e={expires:p_,path:"/",sameSite:"lax"};return typeof window<"u"&&window.location.protocol==="https:"&&(e.sameSite="none",e.secure=!0),e}var Ai="GraffitiInbox",Pi="GraffitiStorageBucket",Ba="#graffitiPersonalInbox",Ti="#graffitiStorageBucket",h_="#graffitiSharedInbox_",Ri=class{constructor(t){this.services=t;let n=new Promise(o=>{this.services.authorization.eventTarget.addEventListener("initialized",i=>{if(!(i instanceof CustomEvent))return;let s=Of.safeParse(i.detail);if(!s.success)return;let a=s.data?.error;a&&console.error(a),o()})});this.services.authorization.eventTarget.addEventListener("login",this.onLogin.bind(this)),this.services.authorization.eventTarget.addEventListener("logout",this.onLogout.bind(this));let r;if(typeof window<"u"){let o=new URLSearchParams(window.location.search).get("actor");if(o)try{let i=decodeURIComponent(o),s=new URL(window.location.toString());s.searchParams.delete("actor"),window.history.replaceState({},"",s.toString()),r=this.login(i)}catch(i){console.error("Error decoding actor:",i)}}(async()=>{await new Promise(i=>setTimeout(i,0)),await r;for(let i of this.loggedInSessions){let s=new CustomEvent("login",{detail:{session:{actor:i.actor}}});this.sessionEvents.dispatchEvent(s)}await n;let o=new CustomEvent("initialized");this.sessionEvents.dispatchEvent(o)})()}services;sessionEvents=new EventTarget;inProgressLogin=void 0;inProgressLogout=void 0;async login(t){try{await this.login_(t)}catch(n){let r=new CustomEvent("login",{detail:{error:n instanceof Error?n:new Error(String(n)),session:{actor:t}}});this.sessionEvents.dispatchEvent(r)}}async login_(t){if(this.loggedInSessions.find(x=>x.actor===t)){this.sessionEvents.dispatchEvent(new CustomEvent("login",{detail:{session:{actor:t}}}));return}let o=(await this.services.dids.resolve(t)).service;if(!o)throw new Error(`No services found in actor document for ${t}`);let i=o.find(x=>x.id===Ti&&x.type===Pi),s=o.find(x=>x.id===Ba&&x.type===Ai),a=o.filter(x=>x.id.match(new RegExp(`^${h_}\\d+$`))&&x.type===Ai);if(!s||!i||a.length===0)throw new Error(`Required services not found in actor document for ${t}`);let c=La(i),u=La(s),l=a.map(La),d=[{endpoint:c,type:"bucket"},{endpoint:u,type:"personal-inbox"},...l.map(x=>({endpoint:x,type:"shared-inbox"}))],f=await Promise.all(d.map(async({endpoint:x,type:E})=>{let A=await(E==="bucket"?this.services.storageBuckets.getAuthorizationEndpoint(x):this.services.inboxes.getAuthorizationEndpoint(x));return{endpoint:x,authorizationEndpoint:A,type:E}})),m=new Map;f.forEach(({authorizationEndpoint:x,endpoint:E,type:A})=>{m.has(x)||m.set(x,[]),m.get(x).push({endpoint:E,type:A})});let w=[...m.entries()],S={...{actor:t},tokens:[],servicesByAuthorization:w};typeof window<"u"?window.localStorage.setItem(Ei,JSON.stringify(S)):this.inProgressLogin=S;let[h,_]=w[0];await this.services.authorization.login(h,t,_.map(x=>x.endpoint))}async onLogin(t){if(!(t instanceof CustomEvent))return;let n=Pf.safeParse(t.detail);if(!n.success)return;let r=n.data.loginId;try{await this.onLogin_(n.data)}catch(o){let i=new CustomEvent("login",{detail:{error:o instanceof Error?o:new Error(String(o)),session:{actor:r}}});this.sessionEvents.dispatchEvent(i)}}async onLogin_(t){if(t.error)throw t.error;let n=t.token,r=t.loginId,o;if(typeof window<"u"){let i=window.localStorage.getItem(Ei);if(!i)throw new Error("No in-progress login found");let s=JSON.parse(i);o=Na.parse(s)}else{if(!this.inProgressLogin)throw new Error("No in-progress login found");o=this.inProgressLogin}if(o.actor!==r)throw new Error("Actor mismatch in login response - concurrent logins?");if(o.tokens.push(n),o.tokens.length===o.servicesByAuthorization.length){typeof window>"u"?this.inProgressLogin=void 0:window.localStorage.removeItem(Ei);let i=o.servicesByAuthorization.flatMap(([u,l],d)=>l.map(f=>({token:o.tokens[d],serviceEndpoint:f.endpoint,authorizationEndpoint:u,type:f.type}))),s={...o,storageBucket:i.find(u=>u.type==="bucket"),personalInbox:i.find(u=>u.type==="personal-inbox"),sharedInboxes:i.filter(u=>u.type==="shared-inbox")},a=this.loggedInSessions;a.push(s),this.loggedInSessions=a;let c=new CustomEvent("login",{detail:{session:{actor:r}}});this.sessionEvents.dispatchEvent(c)}else{typeof window<"u"?window.localStorage.setItem(Ei,JSON.stringify(o)):this.inProgressLogin=o;let[i,s]=o.servicesByAuthorization[o.tokens.length];await this.services.authorization.login(i,r,s.map(a=>a.endpoint))}}async logout(t){try{await this.logout_(t)}catch(n){let r=new CustomEvent("logout",{detail:{error:n instanceof Jt?void 0:n instanceof Error?n:new Error(String(n)),actor:t}});this.sessionEvents.dispatchEvent(r)}}async logout_(t){let n=this.loggedInSessions.find(s=>s.actor===t);if(!n)throw new Error(`No session found for actor ${t}`);this.loggedInSessions=this.loggedInSessions.filter(s=>s.actor!==t);let r=n.tokens.pop();if(!r)throw new Error("No tokens found in session");typeof window<"u"?window.localStorage.setItem(vi,JSON.stringify(n)):this.inProgressLogout=n;let[o,i]=n.servicesByAuthorization[n.tokens.length];await this.services.authorization.logout(o,t,r)}async onLogout(t){if(!(t instanceof CustomEvent))return;let n=Tf.safeParse(t.detail);if(!n.success)return;let r=n.data.logoutId;try{await this.onLogout_(n.data)}catch(o){let i=new CustomEvent("logout",{detail:{error:o instanceof Error?o:new Error(String(o)),actor:r}});this.sessionEvents.dispatchEvent(i)}}async onLogout_(t){if(t.error)throw t.error;let n=t.logoutId,r;if(typeof window<"u"){let i=window.localStorage.getItem(vi);if(!i)throw new Error("No in-progress logout found");let s=JSON.parse(i);r=Na.parse(s)}else{if(!this.inProgressLogout)throw new Error("No in-progress logout found");r=this.inProgressLogout}if(r.actor!==n)throw new Error("Actor mismatch in logout response - concurrent logouts?");let o=r.tokens.pop();if(o){typeof window<"u"?window.localStorage.setItem(vi,JSON.stringify(r)):this.inProgressLogout=r;let[i,s]=r.servicesByAuthorization[r.tokens.length];await this.services.authorization.logout(i,n,o)}else{typeof window>"u"?this.inProgressLogout=void 0:window.localStorage.removeItem(vi);let i=new CustomEvent("logout",{detail:{actor:n}});this.sessionEvents.dispatchEvent(i)}}get loggedInSessions(){if(typeof window>"u")return sp;let t=op(Si);if(!t)return[];let n;try{n=JSON.parse(t)}catch{return console.error("Error parsing stored session data"),Ua(Si),[]}let r=J(y_).safeParse(n);return r.success?r.data:(console.error("Stored session data is invalid"),Ua(Si),[])}set loggedInSessions(t){if(typeof window>"u"){sp=t;return}rp(Si,JSON.stringify(t))}resolveSession(t){let n=this.loggedInSessions.find(r=>r.actor===t.actor);if(!n){let r=new CustomEvent("logout",{detail:{actor:t.actor}});throw this.sessionEvents.dispatchEvent(r),new Error("Not logged in")}return n}},sp=[],Ei="graffiti-login-in-progress",vi="graffiti-logout-in-progress",Si="graffiti-sessions-logged-in",m_=be({actor:F()}),Ma=be({token:j(),serviceEndpoint:F(),authorizationEndpoint:F()}),g_=J(he([F(),J(be({endpoint:F(),type:xu(["bucket","personal-inbox","shared-inbox"])}))])),Na=st(m_,{tokens:J(j()),servicesByAuthorization:g_}),y_=st(Na,{storageBucket:Ma,personalInbox:Ma,sharedInboxes:J(Ma)});function La(e){if(typeof e.serviceEndpoint=="string")return e.serviceEndpoint;throw new Error(`Service endpoint for ${e.id} is not a string`)}var Oi=32*1024,ki=class{constructor(t){this.primitives=t}primitives;async encode(t,n){t=qa(t);let r=[...new Set(t.channels)],o=await Promise.all(r.map(b=>this.primitives.channelAttestations.attest(Yt,n,b))),i=o.map(b=>b.attestation),s=o.map(b=>b.channelPublicId),a={[Za]:t.value,[Fa]:i,[up]:Ut(32)},c;if(Array.isArray(t.allowed)){let b=await Promise.all(t.allowed.map(async S=>this.primitives.allowedAttestations.attest($a,S)));a[Ha]=b.map(S=>S.attestation),c=b.map(S=>S.ticket)}let u=Pe(a);if(u.byteLength>Oi)throw new Error("The object is too large");let l=await this.primitives.contentAddresses.register(di,u),d=await this.primitives.stringEncoder.encode(Mn,l),f=__(n,d),m=[new TextEncoder().encode(f),...s];return{object:{value:t.value,channels:r,url:f,actor:n,...t.allowed?{allowed:t.allowed}:{}},tags:m,objectBytes:u,allowedTickets:c}}async validate(t,n,r,o){if(r.byteLength>Oi)throw new Error("Object is too big");let{actor:i,contentAddress:s}=Ja(t.url);if(i!==t.actor)throw new Error("Object actor does not match URL actor");let a=n.at(0);if(!a)throw new Error("No object URL tag");if(new TextDecoder().decode(a)!==t.url)throw new Error("Object URL tag does not match object URL");let c=n.slice(1),u=await this.primitives.stringEncoder.decode(s),l=await this.primitives.contentAddresses.getMethod(u),d=await this.primitives.contentAddresses.register(l,r);if(d.length!==u.length||!d.every((x,E)=>x===u[E]))throw new Error("Content address is invalid");let f=Je(r),m=w_.parse(f),w=m[Za],b=m[Fa],S=m[Ha],h=Pe(w),_=Pe(t.value);if(h.length!==_.length||!h.every((x,E)=>x===_[E]))throw new Error("Object value does not match storage value");if(b.length!==c.length)throw new Error("Not as many channel attestations and public ids");for(let[x,E]of b.entries()){let A=c[x];if(!await this.primitives.channelAttestations.validate(E,i,A))throw new Error("Invalid channel attestation")}if(t.channels.length){if(t.channels.length!==c.length)throw new Error("Number of claimed channels does not match attestations/public IDs");let x=await this.primitives.channelAttestations.getMethod(c[0]),E=await Promise.all(t.channels.map(A=>this.primitives.channelAttestations.register(x,A)));for(let[A,k]of E.entries()){let I=c[A];if(k.length!==I.length||!k.every((U,V)=>U===I[V]))throw new Error("Channel public id does not match expected")}}if(o){if(!S)throw new Error("Object is public but thought to be private");let x,E,A;if("recipient"in o?(x=[o.recipient],E=[o.allowedTicket],A=S.filter((k,I)=>I===o.allowedIndex)):(x=[...t.allowed??[]],E=o.allowedTickets,A=S),x.length!==t.allowed?.length)throw new Error("Recipient count does not match object allowed list");if(!x.every(k=>t.allowed?.includes(k)))throw new Error("Recipient not in object allowed list");for(let[k,I]of x.entries()){let U=E.at(k),V=A.at(k);if(!U)throw new Error("Missing allowed ticket for recipient");if(!V)throw new Error("Missing allowed attestation for recipient");if(!await this.primitives.allowedAttestations.validate(V,I,U))throw new Error("Invalid allowed attestation for recipient")}}else if(S)throw new Error("Object is private but no recipient info provided")}},Za="v",Fa="c",Ha="a",up="n",ja=Dt(e=>e instanceof Uint8Array),w_=xe({[Za]:Ee({}),[Fa]:J(ja),[Ha]:Y(J(ja)),[up]:ja}),Ga="graffiti:";function ap(e){let t=e.replace(/:/g,"!").replace(/\//g,"~");return encodeURIComponent(t)}function cp(e){return decodeURIComponent(e).replace(/!/g,":").replace(/~/g,"/")}function __(e,t){return`${Ga}${ap(e)}:${ap(t)}`}function Ja(e){if(!e.startsWith(Ga))throw new Error("Invalid object URL");let n=e.slice(Ga.length).split(":");if(n.length!==2)throw new Error("Invalid object URL format");let[r,o]=n;return{actor:cp(r),contentAddress:cp(o)}}function qa(e){return e===void 0?null:Array.isArray(e)?e.map(qa):typeof e=="object"?Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0).map(([t,n])=>[t,qa(n)])):e}var lp=class{dialog=document.createElement("dialog");shadow;main_;useTemplateHTML;templates_;onManualClose;displayTemplateSeq=0;constructor(e){this.useTemplateHTML=e.useTemplateHTML,this.onManualClose=e.onManualClose,this.dialog.className="graffiti-modal",this.dialog.addEventListener("click",n=>{if("pointerType"in n&&!n.pointerType)return;let r=this.dialog.getBoundingClientRect();(r.top>n.clientY||r.left>n.clientX||n.clientY>r.top+r.height||n.clientX>r.left+r.width)&&(this.close(),this.onManualClose?.())});let t=document.createElement("div");this.shadow=t.attachShadow({mode:"closed"}),this.shadow.appendChild(this.dialog),document.body.append(t)}get templates(){return this.templates_||(this.main_,this.templates_=new Promise(async e=>e(await this.useTemplateHTML())).then(e=>{let t=new DOMParser().parseFromString(e,"text/html"),n=new Map;return t.querySelectorAll("template").forEach(r=>{let o=r.id;o&&n.set(o,r)}),n})),this.templates_}get main(){return this.main_||(this.templates_,this.main_=Promise.all([import("./style-BOBMBTYJ-2YZTO5FX.js"),import("./graffiti-KV3G3O72-QD3APAKT.js"),import("./rock-salt-LI7DAH66-M6W5PPFD.js")]).then(async([{default:e},{default:t},{default:n}])=>{let r=document.createElement("header"),o=document.createElement("button");o.className="secondary",o.textContent="Close",o?.addEventListener("click",()=>{this.close(),this.onManualClose?.()}),r.appendChild(o);let i=document.createElement("main");this.dialog.appendChild(r),this.dialog.appendChild(i);let s=new FontFace("Rock Salt",`url(${n})`,{style:"normal",weight:"400"});document.fonts.add(s),await s.load(),e=e.replace("url(graffiti.jpg)",`url(${t})`);let a=new CSSStyleSheet;return a.replace(e).then(()=>{this.shadow.adoptedStyleSheets=[a]}),i})),this.main_}async open(){await this.main,this.dialog.showModal(),this.dialog.focus()}close(){this.dialog.close()}async displayTemplate(e){let t=++this.displayTemplateSeq,n=()=>{if(t!==this.displayTemplateSeq)throw new Error(`displayTemplate(${e}) overridden by concurrent call`)},r=await this.main;n();let o=(await this.templates).get(e);if(n(),!o)throw new Error(`Template not found: ${e}`);let i=o.content.cloneNode(!0);return r.replaceChildren(i),r}};var pp=Dt(e=>e instanceof Uint8Array),Wa="k",Bn="t",Qa=xe({[Wa]:j(),[Bn]:Y(j())}),Qt="id",Xa="e",Hr="a",b_=J(xe({[Qt]:j(),[Xa]:Y(F()),[Hr]:Y(F())})),Ii="s",zi="n",x_=st(Qa,{[Ii]:Y(J(pp)),[zi]:b_}),Gr="a",Ya="i",E_=st(Qa,{[Gr]:pp,[Ya]:tn().check(Ct())}),v_=at([Qa,x_,E_]),S_=0,Ka=1,At=2,Va=3,A_=128,dp="graffiti-login-remembered-handle",$i=class{dids=new Zo;authorization=new oi;storageBuckets=new si;inboxes=new ci;stringEncoder=new li;contentAddresses=new fi;channelAttestations=new yi;allowedAttestations=new wi;sessions=new Ri({dids:this.dids,authorization:this.authorization,storageBuckets:this.storageBuckets,inboxes:this.inboxes});handles=new _i({dids:this.dids});objectEncoding=new ki({stringEncoder:this.stringEncoder,contentAddresses:this.contentAddresses,channelAttestations:this.channelAttestations,allowedAttestations:this.allowedAttestations});modal=typeof window>"u"?void 0:new lp({useTemplateHTML:()=>import("./login-dialog.html-E6VRKMXH.js").then(({template:t})=>t),onManualClose:()=>{let t=new CustomEvent("login",{detail:{error:new Error("User cancelled login"),manual:!0}});this.sessionEvents.dispatchEvent(t)}});defaultInboxEndpoints;identityCreatorEndpoint;constructor(t){this.defaultInboxEndpoints=t?.defaultInboxEndpoints??["https://graffiti.actor/i/shared"],this.identityCreatorEndpoint=t?.identityCreatorEndpoint??"https://graffiti.actor/create",this.sessionEvents.addEventListener("login",async n=>{if(!(n instanceof CustomEvent))return;let r=n.detail;if(r.error!==void 0){if("manual"in r&&r.manual)return;alert("Login failed: "+r.error.message);let s=r.session?.actor,a;if(s)try{a=await this.actorToHandle(s)}catch(c){console.error("Failed to handle actor:",c)}this.login_(a);return}let o=r.session.actor,i;try{i=await this.actorToHandle(o)}catch(s){console.error("Failed to load handle from actor:",s)}i&&await this.rememberHandleInPasswordManager(i,o)});for(let n of["post","get","delete","postMedia","getMedia","deleteMedia"]){let r=this[n];this[n]=async(...o)=>{try{return await r(...o)}catch(i){let s=o[o.length-1];throw await this.tryLogoutIfUnauthorized(i,s),i}}}}actorToHandle=this.handles.actorToHandle.bind(this.handles);handleToActor=this.handles.handleToActor.bind(this.handles);sessionEvents=this.sessions.sessionEvents;login=async t=>{try{let n;try{n=t?await this.actorToHandle(t):void 0}catch(r){console.error("Error fetching handle for actor:",r)}await this.login_(n)}catch(n){let r=new CustomEvent("login",{detail:{error:n instanceof Error?n:new Error(String(n))}});this.sessionEvents.dispatchEvent(r)}};async login_(t){if(typeof window<"u"){let n;if(t!==void 0){n=await this.modal?.displayTemplate("graffiti-login-handle");let o=n?.querySelector("#username"),i=t||await this.getRememberedHandleFromPasswordManager();o&&(o.value=i??""),o?.addEventListener("focus",()=>o?.select()),setTimeout(()=>o?.focus(),0),n?.querySelector("#graffiti-login-handle-form")?.addEventListener("submit",async s=>{s.preventDefault(),o?.setAttribute("disabled","true");let a=n?.querySelector("#graffiti-login-handle-submit");if(a?.setAttribute("disabled","true"),a&&(a.innerHTML="Logging in..."),!o?.value){alert("No handle provided"),this.login_("");return}let c=o.value;if(!c.includes(".")&&!c.startsWith("localhost")){let l=new URL(this.identityCreatorEndpoint).host;c=`${c}.${l}`}let u;try{u=await this.handleToActor(c)}catch{alert("Could not find an identity associated with that handle."),this.login_(c);return}try{await this.sessions.login(u)}catch(l){alert("Error logging in."),console.error(l),this.login_(c)}})}else n=await this.modal?.displayTemplate("graffiti-login-welcome"),n?.querySelector("#graffiti-login-existing")?.addEventListener("click",o=>{o.preventDefault(),this.login_("")}),setTimeout(()=>n?.querySelector("#graffiti-login-new")?.focus(),0);let r=new URL(this.identityCreatorEndpoint);r.searchParams.set("redirect_uri",encodeURIComponent(window.location.toString())),n?.querySelector("#graffiti-login-new")?.setAttribute("href",r.toString()),await this.modal?.open()}else{let n=await import("readline").catch(s=>{throw new Error("Unrecognized environment: neither window nor readline")});console.log("If you do not already have a Graffiti handle, you can create one here:"),console.log(this.identityCreatorEndpoint);let r=n.createInterface({input:process.stdin,output:process.stdout}),o=await new Promise(s=>{r.question(`Please enter your handle${t?` (default: ${t})`:""}: `,a=>{r.close(),s(a||t)})});if(!o)throw new Error("No handle provided");let i=await this.handleToActor(o);await this.sessions.login(i)}}async rememberHandleInPasswordManager(t,n){if(typeof window>"u")return;let r=window.navigator.credentials,o=window.PasswordCredential;if(!r?.store||!o){this.rememberHandleInBrowserStorage(t);return}try{let i=new o({id:t,password:"no-password",name:t});await r.store(i)}catch(i){console.error("Failed to remember handle in password manager:",i),this.rememberHandleInBrowserStorage(t)}}async getRememberedHandleFromPasswordManager(){if(typeof window>"u")return;let t=window.navigator.credentials,n=window.PasswordCredential;if(!t?.get||!n)return this.getRememberedHandleFromBrowserStorage();try{let r=await t.get({password:!0,mediation:"optional"});if(r&&"id"in r&&typeof r.id=="string")return r.id}catch(r){return console.error("Failed to load handle from password manager:",r),this.getRememberedHandleFromBrowserStorage()}}rememberHandleInBrowserStorage(t){if(!(typeof window>"u"))try{window.localStorage.setItem(dp,t)}catch(n){console.error("Failed to remember handle in browser storage:",n)}}getRememberedHandleFromBrowserStorage(){if(!(typeof window>"u"))try{return window.localStorage.getItem(dp)??void 0}catch(t){console.error("Failed to load handle from browser storage:",t);return}}logout=async t=>{await this.sessions.logout(t.actor)};post=async(...t)=>{let[n,r]=t,o=this.sessions.resolveSession(r),{object:i,tags:s,objectBytes:a,allowedTickets:c}=await this.objectEncoding.encode(n,r.actor),u=Ut(),l=await this.stringEncoder.encode(Mn,u);return await this.storageBuckets.put(o.storageBucket.serviceEndpoint,l,a,o.storageBucket.token),await this.announceObject(i,s,c,l,r),i};get=async(...t)=>{let[n,r,o]=t,i,s=await ro(r);if(o){let u=this.sessions.resolveSession(o);i=[u.personalInbox,...u.sharedInboxes]}else i=this.defaultInboxEndpoints.map(u=>({serviceEndpoint:u}));let a=es(n),c=[new TextEncoder().encode(a)];for(let u of i){let l,d=this.querySingleEndpoint(u.serviceEndpoint,{tags:c,objectSchema:{}},u.token,o?.actor);for await(let f of d)f.object.url===a&&(f.tombstone?l=void 0:l=f.object);if(l){if(!s(l))throw new to("Object exists but does not match the supplied schema");return l}}throw new ne("Object not found")};delete=async(t,n)=>{let r=this.sessions.resolveSession(n),o=es(t),{actor:i}=Ja(o);if(i!==n.actor)throw new ht("Cannot delete someone else's actor");let s=this.querySingleEndpoint(r.personalInbox.serviceEndpoint,{tags:[new TextEncoder().encode(o)],objectSchema:{}},r.personalInbox.token),a;for await(let w of s)w.object.url===o&&(w.tombstone?a=void 0:a=w);if(!a)throw new ne(`Object ${o} not found`);let{object:c,storageBucketKey:u,tags:l,allowedTickets:d,announcements:f,messageId:m}=a;return await this.storageBuckets.delete(r.storageBucket.serviceEndpoint,u,r.storageBucket.token),await this.announceObject(c,l,d,u,n,[...f??[],{[Hr]:n.actor,[Qt]:m}]),c};postMedia=async(...t)=>{let[n,r]=t,o=n.data.type,i=this.sessions.resolveSession(r),s=Ut(),a=await this.stringEncoder.encode(Mn,s);await this.storageBuckets.put(i.storageBucket.serviceEndpoint,a,new Uint8Array(await n.data.arrayBuffer()),i.storageBucket.token);let{url:c}=await this.post({value:{key:a,type:o,size:n.data.size},channels:[],allowed:n.allowed},r);return c};getMedia=async(...t)=>{let[n,r,o]=t;if(r?.maxBytes!==void 0&&(!Number.isSafeInteger(r.maxBytes)||r.maxBytes<0))throw new TypeError("maxBytes must be a nonnegative safe integer");let i=await this.get(n,R_,o),{key:s,type:a,size:c}=i.value;if(r?.maxBytes!==void 0&&c>r.maxBytes)throw new sn("File size exceeds limit");if(r?.types&&!Ru(a,r.types))throw new no(`Unacceptable media type, ${a}`);let l=(await this.dids.resolve(i.actor))?.service?.find(w=>w.id===Ti&&w.type===Pi);if(!l)throw new ne(`Actor ${i.actor} has no storage bucket service`);if(typeof l.serviceEndpoint!="string")throw new ne(`Actor ${i.actor} does not have a valid storage bucket endpoint`);let d=l.serviceEndpoint,f=await this.storageBuckets.get(d,s,c);return{data:new Blob([f.slice()],{type:a}),actor:i.actor,allowed:i.allowed}};deleteMedia=async(...t)=>{let[n,r]=t,o=this.sessions.resolveSession(r),i=await this.delete(n,r);if(!("key"in i.value&&typeof i.value.key=="string"))throw new Error("Deleted object was not media: "+JSON.stringify(i,null,2));await this.storageBuckets.delete(o.storageBucket.serviceEndpoint,i.value.key,o.storageBucket.token)};async*discoverMeta(t,n,r,o){let i=new Map,s;if(o){let d=this.sessions.resolveSession(o);s=[d.personalInbox,...d.sharedInboxes]}else s=this.defaultInboxEndpoints.map(d=>({serviceEndpoint:d}));for(let d in r)if(!s.some(f=>f.serviceEndpoint===d))throw new ht("Cursor does not match actor's inboxes");let a=await Promise.all(t.map(d=>this.channelAttestations.register(Yt,d))),c=s.map(d=>{let f=r[d.serviceEndpoint];return this.querySingleEndpoint(d.serviceEndpoint,f?{cursor:f}:{tags:a,objectSchema:n},d.token,o?.actor)}),u=c.map(async(d,f)=>fp(d,f)),l=u.length;try{for(;l>0;){let d=await Promise.race(u);if(d.error!==void 0)u[d.index]=new Promise(()=>{}),l--,yield{error:d.error,origin:s[d.index].serviceEndpoint},this.tryLogoutIfUnauthorized(d.error,o);else if(d.result.done){let f=s[d.index];r[f.serviceEndpoint]=d.result.value,u[d.index]=new Promise(()=>{}),l--}else{u[d.index]=fp(c[d.index],d.index);let{object:f,tombstone:m,tags:w}=d.result.value;if(m){if(i.get(f.url)===!0)continue;i.set(f.url,!0),yield{tombstone:m,object:{url:f.url}}}else{if(i.get(f.url)===!1)continue;let S=a.reduce((h,_,x)=>{for(let E of w)if(_.length===E.length&&_.every((A,k)=>E[k]===A)){h.push(x);break}return h},[]).map(h=>t[h]);S.length===0&&(yield{error:new Error("Inbox returned object without matching channels"),origin:s[d.index].serviceEndpoint}),i.set(f.url,!1),yield{object:{...f,channels:S}}}}}}catch(d){throw this.tryLogoutIfUnauthorized(d,o),d}finally{await Promise.all(c.map(async d=>{await d.return("")}))}return{cursor:JSON.stringify({channels:t,cursors:r})}}discover=(...t)=>{let[n,r,o]=t;return this.discoverMeta(n,r,{},o)};continueDiscover=(...t)=>{let[n,r]=t,o,i;try{let s=JSON.parse(n),a=P_.parse(s);o=a.channels,i=a.cursors}catch{return(async function*(){throw new Me("Invalid cursor")})()}return this.discoverMeta(o,{},i,r)};async tryLogoutIfUnauthorized(t,n){t instanceof Jt&&n&&await this.sessions.logout(n.actor)}async announceObject(t,n,r,o,i,s){let a=this.sessions.resolveSession(i),c={[Wa]:o},u=[],l=t.allowed;if(Array.isArray(l)){if(!r||r.length!==l.length)throw new Error("If allowed actors are specified, there must be a corresponding ticket for each allowed actor");let m=await Promise.allSettled(l.map(async(w,b)=>{let S=JSON.parse(JSON.stringify(t)),h=ts(S,[],w),x=(await this.dids.resolve(w)).service?.find(I=>I.type===Ai&&I.id===Ba);if(!x)throw new Error(`Recipient ${w} does not have a personal inbox`);if(typeof x.serviceEndpoint!="string")throw new Error(`Recipient ${w} does not have a valid personal inbox endpoint`);let E=s?s.find(I=>I[Hr]===w)?.[Qt]:void 0,A={...c,...E?{[Bn]:E}:{},[Gr]:r[b],[Ya]:b},k=await this.inboxes.send(x.serviceEndpoint,{[Nr]:n,[lt]:h,[Br]:Pe(A)});u.push({[Qt]:k,[Hr]:w})}));for(let[w,b]of m.entries())if(b.status==="rejected"){let S=l[w];console.error("Error sending to recipient:",S),console.error(b.reason)}}else{let m=JSON.parse(JSON.stringify(t)),w=ts(m,[]),b=a.sharedInboxes,S=await Promise.allSettled(b.map(async h=>{let _=s?s.find(A=>A[Xa]===h.serviceEndpoint)?.[Qt]:void 0,x={...c,..._?{[Bn]:_}:{}},E=await this.inboxes.send(h.serviceEndpoint,{..._?{[Bn]:_}:{},[Nr]:n,[lt]:w,[Br]:Pe(x)});u.push({[Qt]:E,[Xa]:h.serviceEndpoint})}));for(let[h,_]of S.entries())if(_.status==="rejected"){let x=b[h];console.error("Error sending to inbox:",x),console.error(_.reason)}}let d=s?s.find(m=>m[Hr]===i.actor)?.[Qt]:void 0,f={...c,...r?{[Ii]:r}:{},...d?{[Bn]:d}:{},[zi]:u};await this.inboxes.send(a.personalInbox.serviceEndpoint,{[Nr]:n,[lt]:t,[Br]:Pe(f)})}async*querySingleEndpoint(t,n,r,o){let i="tags"in n?this.inboxes.query(t,n.tags,n.objectSchema,r):this.inboxes.continueQuery(t,n.cursor,r),s=[],a=null;try{for(;;){for(;a===null&&s.length<A_;){let l=await i.next();if(l.done){a=l.value;break}let d=this.processOneLabeledMessage(t,l.value,r,o).catch(f=>{throw f});s.push(d)}let c=s.shift();if(!c){if(a!==null)return a;throw new Error("Process queue empty but no return value")}let u=await c;u&&(yield u)}}finally{await i.return("")}}async processOneLabeledMessage(t,n,r,o){let i=n.l;if(i!==Ka&&i!==S_&&i!==At)return;let s=n.id,{o:a,m:c,t:u}=n.m,l;try{let S=Je(c);l=v_.parse(S)}catch{this.inboxes.label(t,s,Va,r);return}let{[Wa]:d,[Bn]:f}=l,m=Ii in l?l[Ii]:void 0,w=zi in l?l[zi]:void 0;if(i===Ka)return{messageId:s,object:a,storageBucketKey:d,allowedTickets:m,tags:u,announcements:w};if(i===At){if(!f)return;let S=await this.inboxes.get(t,f,r);return!S||S[Kt][lt].url!==a.url?void 0:(S[ui]!==At&&this.inboxes.label(t,f,At,r),{messageId:s,tombstone:!0,object:a,storageBucketKey:d,allowedTickets:m,tags:u,announcements:w})}let b;try{let S=a.actor,_=(await this.dids.resolve(S))?.service?.find(k=>k.id===Ti&&k.type===Pi);if(!_)throw new ne(`Actor ${S} has no storage bucket service`);if(typeof _.serviceEndpoint!="string")throw new ne(`Actor ${S} does not have a valid storage bucket endpoint`);let x=_.serviceEndpoint,E=await this.storageBuckets.get(x,d,Oi);if(Gr in l&&!o)throw new ht("Recipient is required when allowed ticket is present");let A=m?{allowedTickets:m}:Gr in l?{recipient:o??"null",allowedTicket:l[Gr],allowedIndex:l[Ya]}:void 0;await this.objectEncoding.validate(a,u,E,A)}catch(S){b=S}if(f){if(b instanceof ne)return this.inboxes.get(t,f,r).then(S=>{S&&S[Kt][lt].url===a.url&&S[ui]!==At&&this.inboxes.label(t,f,At,r),this.inboxes.label(t,s,At,r)}),{messageId:s,tombstone:!0,object:a,storageBucketKey:d,allowedTickets:m,tags:u,announcements:w};console.error("Recieved an incorrect tombstone object"),console.error(b),this.inboxes.label(t,s,Va,r)}else{if(b===void 0)return this.inboxes.label(t,s,Ka,r),{messageId:s,object:a,storageBucketKey:d,tags:u,allowedTickets:m,announcements:w};b instanceof ne?this.inboxes.label(t,s,At,r):(console.error("Recieved an incorrect object"),console.error(b),this.inboxes.label(t,s,Va,r))}}},R_={properties:{value:{properties:{type:{type:"string"},size:{type:"number"},key:{type:"string"}},required:["type","size","key"]}}},P_=xe({cursors:bu(F(),j()),channels:J(j())});async function fp(e,t){try{return{index:t,result:await e.next()}}catch(n){if(n instanceof Me||n instanceof on)throw n;return{index:t,error:n instanceof Error?n:new Error(String(n))}}}var hp=class extends eo{constructor(t){let n=new $i(t);super(n)}};export{hp as GraffitiDecentralized};
|
|
10
|
+
`+s)}}catch{}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Be(this.defaults,n);let{transitional:r,paramsSerializer:o,headers:i}=n;r!==void 0&&Tr.assertOptions(r,{silentJSONParsing:pe.transitional(pe.boolean),forcedJSONParsing:pe.transitional(pe.boolean),clarifyTimeoutError:pe.transitional(pe.boolean),legacyInterceptorReqResOrdering:pe.transitional(pe.boolean),advertiseZstdAcceptEncoding:pe.transitional(pe.boolean),validateStatusUndefinedResolves:pe.transitional(pe.boolean)},!1),o!=null&&(p.isFunction(o)?n.paramsSerializer={serialize:o}:Tr.assertOptions(o,{encode:pe.function,serialize:pe.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Tr.assertOptions(n,{baseUrl:pe.spelling("baseURL"),withXsrfToken:pe.spelling("withXSRFToken")},!0),n.method=(p.getSafeProp(n,"method")||p.getSafeProp(this.defaults,"method")||"get").toLowerCase();let s=i&&p.merge(i.common,i[n.method]);i&&p.forEach(Co.concat("common"),w=>{delete i[w]}),n.headers=ee.concat(s,i);let a=[],c=!0;this.interceptors.request.forEach(function(b){if(typeof b.runWhen=="function"&&b.runWhen(n)===!1)return;c=c&&b.synchronous;let S=n.transitional||En;S&&S.legacyInterceptorReqResOrdering?a.unshift(b.fulfilled,b.rejected):a.push(b.fulfilled,b.rejected)});let u=[];this.interceptors.response.forEach(function(b){u.push(b.fulfilled,b.rejected)});let l,f=0,d;if(!c){let w=[Rr.bind(this),void 0];for(w.unshift(...a),w.push(...u),d=w.length,l=Promise.resolve(n);f<d;)l=l.then(w[f++],w[f++]);return l}d=a.length;let m=n;for(;f<d;){let w=a[f++],b=a[f++];try{m=w?w(m):m}catch(S){if(!b){l=Promise.reject(S);break}try{let h=b.call(this,S);p.isThenable(h)&&(l=Promise.resolve(h).then(()=>Rr.call(this,m)))}catch(h){l=Promise.reject(h)}break}}if(!l)try{l=Rr.call(this,m)}catch(w){l=Promise.reject(w)}for(f=0,d=u.length;f<d;)l=l.then(u[f++],u[f++]);return l}getUri(t){t=Be(this.defaults,t);let n=Ar(t.baseURL,t.url,t.allowAbsoluteUrls,t);return yr(n,t.params,t.paramsSerializer)}};p.forEach(["delete","get","head","options"],function(t){Tn.prototype[t]=function(n,r){return this.request(Be(r||{},{method:t,url:n,data:r&&p.hasOwnProp(r,"data")?r.data:void 0}))}});p.forEach(["post","put","patch","query"],function(t){function n(r){return function(i,s,a){return this.request(Be(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:i,data:s}))}}Tn.prototype[t]=n(),t!=="query"&&(Tn.prototype[t+"Form"]=n(!0))});var Pr=Tn;var Vs=class e{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(i){n=i});let r=this;this.promise.then(o=>{if(!r._listeners)return;let i=r._listeners.length;for(;i-- >0;)r._listeners[i](o);r._listeners=null}),this.promise.then=o=>{let i,s=new Promise(a=>{r.subscribe(a),i=a}).then(o);return s.cancel=function(){r.unsubscribe(i)},s},t(function(i,s,a){r.reason||(r.reason=new Ke(i,s,a),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;let n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){let t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new e(function(o){t=o}),cancel:t}}},Zf=Vs;function Ws(e){return function(n){return e.apply(null,n)}}function Xs(e){return p.isObject(e)&&e.isAxiosError===!0}var Lo={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,ContentTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,UnprocessableContent:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerReturnsAnUnknownError:520,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Lo).forEach(([e,t])=>{Lo[t]===void 0&&(Lo[t]=e)});var Ff=Lo;function Hf(e){let t=new Pr(e),n=lr(Pr.prototype.request,t);return p.extend(n,Pr.prototype,t,{allOwnKeys:!0}),p.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Hf(Be(e,o))},n}var re=Hf(Sn);re.Axios=Pr;re.CanceledError=Ke;re.CancelToken=Zf;re.isCancel=xr;re.VERSION=Rn;re.toFormData=Et;re.AxiosError=T;re.Cancel=re.CanceledError;re.all=function(t){return Promise.all(t)};re.spread=Ws;re.isAxiosError=Xs;re.mergeConfig=Be;re.AxiosHeaders=ee;re.formToJSON=e=>zo(p.isHTMLForm(e)?new FormData(e):e);re.getAdapter=Uo.getAdapter;re.HttpStatusCode=Ff;re.default=re;var No=re;var{Axios:HT,AxiosError:GT,CanceledError:qT,isCancel:JT,CancelToken:KT,VERSION:VT,all:WT,Cancel:XT,isAxiosError:YT,spread:QT,toFormData:eP,AxiosHeaders:tP,HttpStatusCode:nP,formToJSON:rP,getAdapter:oP,mergeConfig:iP,create:sP}=No;function By(e,t){try{var n=e()}catch(r){return t(r)}return n&&n.then?n.then(void 0,t):n}function Pe(e,t,n){if(!e.s){if(n instanceof Ys)if(n.s)t&1&&(t=n.s),n=n.v;else{n.o=Pe.bind(null,e,t);return}if(n&&n.then){n.then(Pe.bind(null,e,t),Pe.bind(null,e,2));return}e.s=t,e.v=n;let r=e.o;r&&r(e)}}var Ys=(function(){function e(){}return e.prototype.then=function(t,n){let r=new e,o=this.s;if(o){let i=o&1?t:n;if(i){try{Pe(r,1,i(this.v))}catch(s){Pe(r,2,s)}return r}else return this}return this.o=function(i){try{let s=i.v;i.s&1?Pe(r,1,t?t(s):s):n?Pe(r,1,n(s)):Pe(r,2,s)}catch(s){Pe(r,2,s)}},r},e})();function Pn(e){return e instanceof Ys&&e.s&1}function jy(e,t){var n;do{var r=e();if(r&&r.then)if(Pn(r))r=r.v;else{n=!0;break}var o=t();if(Pn(o)&&(o=o.v),!o)return r}while(!o.then);let i=new Ys,s=Pe.bind(null,i,2);return(n?r.then(a):o.then(c)).then(void 0,s),i;function a(u){for(r=u;o=t(),Pn(o)&&(o=o.v),!!o;){if(o.then){o.then(c).then(void 0,s);return}if(r=e(),r&&r.then)if(Pn(r))r=r.v;else{r.then(a).then(void 0,s);return}}Pe(i,1,r)}function c(u){if(u){do{if(r=e(),r&&r.then)if(Pn(r))r=r.v;else{r.then(a).then(void 0,s);return}if(u=t(),Pn(u)&&(u=u.v),!u){Pe(i,1,r);return}}while(!u.then);u.then(c).then(void 0,s)}else Pe(i,1,r)}}function Gf(){return{plc:function(t,n){try{let o=function(){let l=typeof c?.["@context"]<"u"?"application/did+ld+json":"application/did+json";return i?{didDocument:c,didDocumentMetadata:a,didResolutionMetadata:{error:"notFound",message:i}}:{didDocument:c,didDocumentMetadata:a,didResolutionMetadata:{contentType:l}}},r,i=null,s=`https://plc.directory/${encodeURIComponent(t)}`,a={},c=null,u=jy(function(){function l(){r||c?.id===t||(i="resolver_error: DID document id does not match requested did")}let f=By(function(){return Promise.resolve(No.get(s)).then(function(d){c=d.data})},function(d){i=`resolver_error: '"https://plc.directory/" + DID' must resolve to a valid https URL containing a JSON document: ${d}`,r=1});return f&&f.then?f.then(l):l(f)},function(){return!r&&!1});return Promise.resolve(u&&u.then?u.then(o):o(u))}catch(r){return Promise.reject(r)}}}}var Kf=bp(Jf(),1);function Zy(e,t){try{var n=e()}catch(r){return t(r)}return n&&n.then?n.then(void 0,t):n}var Fy=function(e){try{return Promise.resolve((0,Kf.default)(e,{mode:"cors"})).then(function(t){if(t.status>=400)throw new Error(`Bad response ${t.statusText}`);return t.json()})}catch(t){return Promise.reject(t)}};function Oe(e,t,n){if(!e.s){if(n instanceof Qs)if(n.s)t&1&&(t=n.s),n=n.v;else{n.o=Oe.bind(null,e,t);return}if(n&&n.then){n.then(Oe.bind(null,e,t),Oe.bind(null,e,2));return}e.s=t,e.v=n;let r=e.o;r&&r(e)}}var Hy="/.well-known/did.json",Qs=(function(){function e(){}return e.prototype.then=function(t,n){let r=new e,o=this.s;if(o){let i=o&1?t:n;if(i){try{Oe(r,1,i(this.v))}catch(s){Oe(r,2,s)}return r}else return this}return this.o=function(i){try{let s=i.v;i.s&1?Oe(r,1,t?t(s):s):n?Oe(r,1,n(s)):Oe(r,2,s)}catch(s){Oe(r,2,s)}},r},e})();function kn(e){return e instanceof Qs&&e.s&1}function Gy(e,t){var n;do{var r=e();if(r&&r.then)if(kn(r))r=r.v;else{n=!0;break}var o=t();if(kn(o)&&(o=o.v),!o)return r}while(!o.then);let i=new Qs,s=Oe.bind(null,i,2);return(n?r.then(a):o.then(c)).then(void 0,s),i;function a(u){for(r=u;o=t(),kn(o)&&(o=o.v),!!o;){if(o.then){o.then(c).then(void 0,s);return}if(r=e(),r&&r.then)if(kn(r))r=r.v;else{r.then(a).then(void 0,s);return}}Oe(i,1,r)}function c(u){if(u){do{if(r=e(),r&&r.then)if(kn(r))r=r.v;else{r.then(a).then(void 0,s);return}if(u=t(),kn(u)&&(u=u.v),!u){Oe(i,1,r);return}}while(!u.then);u.then(c).then(void 0,s)}else Oe(i,1,r)}}function Vf(){return{web:function(t,n){try{let o=function(){let d=typeof l?.["@context"]<"u"?"application/did+ld+json":"application/did+json";return i?{didDocument:l,didDocumentMetadata:u,didResolutionMetadata:{error:"notFound",message:i}}:{didDocument:l,didDocumentMetadata:u,didResolutionMetadata:{contentType:d}}},r,i=null,s=decodeURIComponent(n.id)+Hy,a=n.id.split(":");a.length>1&&(s=a.map(decodeURIComponent).join("/")+"/did.json");let c=`https://${s}`,u={},l=null,f=Gy(function(){function d(){r||l?.id===t||(i="resolver_error: DID document id does not match requested did")}let m=Zy(function(){return Promise.resolve(Fy(c)).then(function(w){l=w})},function(w){i=`resolver_error: DID must resolve to a valid https URL containing a JSON document: ${w}`,r=1});return m&&m.then?m.then(d):d(m)},function(){return!r&&!1});return Promise.resolve(f&&f.then?f.then(o):o(f))}catch(r){return Promise.reject(r)}}}}var Zo=class{methods={...Gf(),...Vf()};resolver=new Ro(this.methods,{cache:!0});inFlight=new Map;async resolve(t){if(!Object.keys(this.methods).some(o=>t.startsWith(`did:${o}:`)))throw new Error(`Unrecognized DID method: ${t}`);let n=this.inFlight.get(t);if(n)return n;let r=this.resolver.resolve(t).then(({didDocument:o})=>{if(!o)throw new Q(`DID not found: ${t}`);return o});this.inFlight.set(t,r);try{return await r}finally{this.inFlight.delete(t)}}};var na;(typeof navigator>"u"||!navigator.userAgent?.startsWith?.("Mozilla/5.0 "))&&(na="oauth4webapi/v3.8.7");function Cr(e,t){if(e==null)return!1;try{return e instanceof t||Object.getPrototypeOf(e)[Symbol.toStringTag]===t.prototype[Symbol.toStringTag]}catch{return!1}}var _e="ERR_INVALID_ARG_VALUE",Ce="ERR_INVALID_ARG_TYPE";function K(e,t,n){let r=new TypeError(e,{cause:n});return Object.assign(r,{code:t}),r}var qt=Symbol(),Jo=Symbol(),Ko=Symbol(),Jt=Symbol();var Fo=Symbol();var qy=new TextEncoder,Jy=new TextDecoder;function Wf(e){return typeof e=="string"?qy.encode(e):Jy.decode(e)}var ra;Uint8Array.prototype.toBase64?ra=e=>(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),e.toBase64({alphabet:"base64url",omitPadding:!0})):ra=t=>{t instanceof ArrayBuffer&&(t=new Uint8Array(t));let n=[];for(let r=0;r<t.byteLength;r+=32768)n.push(String.fromCharCode.apply(null,t.subarray(r,r+32768)));return btoa(n.join("")).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")};var oa;Uint8Array.fromBase64?oa=e=>{try{return Uint8Array.fromBase64(e,{alphabet:"base64url"})}catch(t){throw K("The input to be decoded is not correctly encoded.",_e,t)}}:oa=e=>{try{let t=atob(e.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"")),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}catch(t){throw K("The input to be decoded is not correctly encoded.",_e,t)}};function ia(e){return typeof e=="string"?oa(e):ra(e)}var St=class extends Error{code;constructor(t,n){super(t,n),this.name=this.constructor.name,this.code=ei,Error.captureStackTrace?.(this,this.constructor)}},kr=class extends Error{code;constructor(t,n){super(t,n),this.name=this.constructor.name,n?.code&&(this.code=n?.code),Error.captureStackTrace?.(this,this.constructor)}};function $(e,t,n){return new kr(e,{code:t,cause:n})}function Ho(e){return!(e===null||typeof e!="object"||Array.isArray(e))}function sa(e){Cr(e,Headers)&&(e=Object.fromEntries(e.entries()));let t=new Headers(e??{});if(na&&!t.has("user-agent")&&t.set("user-agent",na),t.has("authorization"))throw K('"options.headers" must not include the "authorization" header name',_e);return t}function Yf(e,t){if(t!==void 0){if(typeof t=="function"&&(t=t(e.href)),!(t instanceof AbortSignal))throw K('"options.signal" must return or be an instance of AbortSignal',Ce);return t}}function Qf(e){return e.includes("//")?e.replace("//","/"):e}function Ky(e,t,n=!1){return e.pathname==="/"?e.pathname=t:e.pathname=Qf(`${t}/${n?e.pathname:e.pathname.replace(/(\/)$/,"")}`),e}function Vy(e,t){return e.pathname=Qf(`${e.pathname}/${t}`),e}async function Wy(e,t,n,r){if(!(e instanceof URL))throw K(`"${t}" must be an instance of URL`,Ce);Xo(e,r?.[qt]!==!0);let o=n(new URL(e.href)),i=sa(r?.headers);return i.set("accept","application/json"),(r?.[Jt]||fetch)(o.href,{body:void 0,headers:Object.fromEntries(i.entries()),method:"GET",redirect:"manual",signal:Yf(o,r?.signal)})}async function ed(e,t){return Wy(e,"issuerIdentifier",n=>{switch(t?.algorithm){case void 0:case"oidc":Vy(n,".well-known/openid-configuration");break;case"oauth2":Ky(n,".well-known/oauth-authorization-server");break;default:throw K('"options.algorithm" must be "oidc" (default), or "oauth2"',_e)}return n},t)}function Or(e,t,n,r,o){try{if(typeof e!="number"||!Number.isFinite(e))throw K(`${n} must be a number`,Ce,o);if(e>0)return;if(t){if(e!==0)throw K(`${n} must be a non-negative number`,_e,o);return}throw K(`${n} must be a positive number`,_e,o)}catch(i){throw r?$(i.message,r,o):i}}function we(e,t,n,r){try{if(typeof e!="string")throw K(`${t} must be a string`,Ce,r);if(e.length===0)throw K(`${t} must not be empty`,_e,r)}catch(o){throw n?$(o.message,n,r):o}}async function td(e,t){let n=e;if(!(n instanceof URL)&&n!==qo)throw K('"expectedIssuerIdentifier" must be an instance of URL',Ce);if(!Cr(t,Response))throw K('"response" must be an instance of Response',Ce);if(t.status!==200)throw $('"response" is not a conform Authorization Server Metadata response (unexpected HTTP status code)',ti,t);ya(t);let r=await yd(t);if(we(r.issuer,'"response" body "issuer" property',H,{body:r}),n!==qo&&new URL(r.issuer).href!==n.href)throw $('"response" body "issuer" property does not match the expected value',ni,{expected:n.href,body:r,attribute:"issuer"});return r}function nd(e){Yy(e,"application/json")}function Xy(e,...t){let n='"response" content-type must be ';if(t.length>2){let r=t.pop();n+=`${t.join(", ")}, or ${r}`}else t.length===2?n+=`${t[0]} or ${t[1]}`:n+=t[0];return $(n,ha,e)}function Yy(e,t){if(fa(e)!==t)throw Xy(e,t)}function Qy(){return ia(crypto.getRandomValues(new Uint8Array(32)))}function rd(){return Qy()}function aa(e){let t=e?.[Jo];return typeof t=="number"&&Number.isFinite(t)?t:0}function ca(e){let t=e?.[Ko];return typeof t=="number"&&Number.isFinite(t)&&Math.sign(t)!==-1?t:30}function ua(){return Math.floor(Date.now()/1e3)}function Vo(e){if(typeof e!="object"||e===null)throw K('"as" must be an object',Ce);we(e.issuer,'"as.issuer"')}function Wo(e){if(typeof e!="object"||e===null)throw K('"client" must be an object',Ce);we(e.client_id,'"client.client_id"')}function la(e){return we(e,'"clientSecret"'),(t,n,r,o)=>{r.set("client_id",n.client_id),r.set("client_secret",e)}}function od(){return(e,t,n,r)=>{n.set("client_id",t.client_id)}}var ew=URL.parse?(e,t)=>URL.parse(e,t):(e,t)=>{try{return new URL(e,t)}catch{return null}};function Xo(e,t){if(t&&e.protocol!=="https:")throw $("only requests to HTTPS are allowed",ma,e);if(e.protocol!=="https:"&&e.protocol!=="http:")throw $("only HTTP and HTTPS requests are allowed",ga,e)}function Xf(e,t,n,r){let o;if(typeof e!="string"||!(o=ew(e)))throw $(`authorization server metadata does not contain a valid ${n?`"as.mtls_endpoint_aliases.${t}"`:`"as.${t}"`}`,e===void 0?Aw:Rw,{attribute:n?`mtls_endpoint_aliases.${t}`:t});return Xo(o,r),o}function Yo(e,t,n,r){return n&&e.mtls_endpoint_aliases&&t in e.mtls_endpoint_aliases?Xf(e.mtls_endpoint_aliases[t],t,n,r):Xf(e[t],t,n,r)}function id(e){if(e instanceof zn){let{0:t,length:n}=e.cause;return n===1&&t.scheme==="dpop"&&t.parameters.error==="use_dpop_nonce"}return e instanceof In?e.error==="use_dpop_nonce":!1}var In=class extends Error{cause;code;error;status;error_description;response;constructor(t,n){super(t,n),this.name=this.constructor.name,this.code=vw,this.cause=n.cause,this.error=n.cause.error,this.status=n.response.status,this.error_description=n.cause.error_description,Object.defineProperty(this,"response",{enumerable:!1,value:n.response}),Error.captureStackTrace?.(this,this.constructor)}},Ir=class extends Error{cause;code;error;error_description;constructor(t,n){super(t,n),this.name=this.constructor.name,this.code=Sw,this.cause=n.cause,this.error=n.cause.get("error"),this.error_description=n.cause.get("error_description")??void 0,Error.captureStackTrace?.(this,this.constructor)}},zn=class extends Error{cause;code;response;status;constructor(t,n){super(t,n),this.name=this.constructor.name,this.code=Ew,this.cause=n.cause,this.status=n.response.status,this.response=n.response,Object.defineProperty(this,"response",{enumerable:!1}),Error.captureStackTrace?.(this,this.constructor)}},Go="[a-zA-Z0-9!#$%&\\'\\*\\+\\-\\.\\^_`\\|~]+",tw="[a-zA-Z0-9\\-\\._\\~\\+\\/]+={0,2}",nw='"((?:[^"\\\\]|\\\\[\\s\\S])*)"',rw="("+Go+")\\s*=\\s*"+nw,ow="("+Go+")\\s*=\\s*("+Go+")",iw=new RegExp("^[,\\s]*("+Go+")"),sw=new RegExp("^[,\\s]*"+rw+"[,\\s]*(.*)"),aw=new RegExp("^[,\\s]*"+ow+"[,\\s]*(.*)"),cw=new RegExp("^("+tw+")(?:$|[,\\s])(.*)");function uw(e){if(!Cr(e,Response))throw K('"response" must be an instance of Response',Ce);let t=e.headers.get("www-authenticate");if(t===null)return;let n=[],r=t;for(;r;){let o=r.match(iw),i=o?.[1].toLowerCase();if(!i)return;let s=r.substring(o[0].length);if(s&&!s.match(/^[\s,]/))return;let a=s.match(/^\s+(.*)$/),c=!!a;r=a?a[1]:void 0;let u={},l;if(c)for(;r;){let d,m;if(o=r.match(sw)){if([,d,m,r]=o,m.includes("\\"))try{m=JSON.parse(`"${m}"`)}catch{}u[d.toLowerCase()]=m;continue}if(o=r.match(aw)){[,d,m,r]=o,u[d.toLowerCase()]=m;continue}if(o=r.match(cw)){if(Object.keys(u).length)break;[,l,r]=o;break}return}else r=s||void 0;let f={scheme:i,parameters:u};l&&(f.token68=l),n.push(f)}if(n.length)return n}async function lw(e){if(e.status>399&&e.status<500){ya(e),nd(e);try{let t=await e.clone().json();if(Ho(t)&&typeof t.error=="string"&&t.error.length)return t}catch{}}}async function sd(e,t,n){if(e.status!==t){hw(e);let r;throw(r=await lw(e))?(await e.body?.cancel(),new In("server responded with an error in the response body",{cause:r,response:e})):$(`"response" is not a conform ${n} response (unexpected HTTP status code)`,ti,e)}}function fw(e){if(!da.has(e))throw K('"options.DPoP" is not a valid DPoPHandle',_e)}function fa(e){return e.headers.get("content-type")?.split(";")[0]}async function ad(e,t,n,r,o,i,s){return await n(e,t,o,i),i.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"),(s?.[Jt]||fetch)(r.href,{body:o,headers:Object.fromEntries(i.entries()),method:"POST",redirect:"manual",signal:Yf(r,s?.signal)})}async function dw(e,t,n,r,o,i){let s=Yo(e,"token_endpoint",t.use_mtls_endpoint_aliases,i?.[qt]!==!0);o.set("grant_type",r);let a=sa(i?.headers);a.set("accept","application/json"),i?.DPoP!==void 0&&(fw(i.DPoP),await i.DPoP.addProof(s,a,"POST"));let c=await ad(e,t,n,s,o,a,i);return i?.DPoP?.cacheNonce(c,s),c}var cd=new WeakMap,pw=new WeakMap;function Qo(e){if(!e.id_token)return;let t=cd.get(e);if(!t)throw K('"ref" was already garbage collected or did not resolve from the proper sources',_e);return t}async function ud(e,t,n,r,o,i){if(Vo(e),Wo(t),!Cr(n,Response))throw K('"response" must be an instance of Response',Ce);await sd(n,200,"Token Endpoint"),ya(n);let s=await yd(n);if(we(s.access_token,'"response" body "access_token" property',H,{body:s}),we(s.token_type,'"response" body "token_type" property',H,{body:s}),s.token_type=s.token_type.toLowerCase(),s.expires_in!==void 0){let a=typeof s.expires_in!="number"?parseFloat(s.expires_in):s.expires_in;Or(a,!0,'"response" body "expires_in" property',H,{body:s}),s.expires_in=a}if(s.refresh_token!==void 0&&we(s.refresh_token,'"response" body "refresh_token" property',H,{body:s}),s.scope!==void 0&&typeof s.scope!="string")throw $('"response" body "scope" property must be a string',H,{body:s});if(s.id_token!==void 0){we(s.id_token,'"response" body "id_token" property',H,{body:s});let a=["aud","exp","iat","iss","sub"];t.require_auth_time===!0&&a.push("auth_time"),t.default_max_age!==void 0&&(Or(t.default_max_age,!0,'"client.default_max_age"'),a.push("auth_time")),r?.length&&a.push(...r);let{claims:c,jwt:u}=await Tw(s.id_token,Ow.bind(void 0,t.id_token_signed_response_alg,e.id_token_signing_alg_values_supported,"RS256"),aa(t),ca(t),o).then(_w.bind(void 0,a)).then(gw.bind(void 0,e)).then(mw.bind(void 0,t.client_id));if(Array.isArray(c.aud)&&c.aud.length!==1){if(c.azp===void 0)throw $('ID Token "aud" (audience) claim includes additional untrusted audiences',Ve,{claims:c,claim:"aud"});if(c.azp!==t.client_id)throw $('unexpected ID Token "azp" (authorized party) claim value',Ve,{expected:t.client_id,claims:c,claim:"azp"})}c.auth_time!==void 0&&Or(c.auth_time,!0,'ID Token "auth_time" (authentication time)',H,{claims:c}),pw.set(n,u),cd.set(s,c)}if(i?.[s.token_type]!==void 0)i[s.token_type](n,s);else if(s.token_type!=="dpop"&&s.token_type!=="bearer")throw new St("unsupported `token_type` value",{cause:{body:s}});return s}function hw(e){let t;if(t=uw(e))throw new zn("server responded with a challenge in the WWW-Authenticate HTTP Header",{cause:t,response:e})}function mw(e,t){if(Array.isArray(t.claims.aud)){if(!t.claims.aud.includes(e))throw $('unexpected JWT "aud" (audience) claim value',Ve,{expected:e,claims:t.claims,claim:"aud"})}else if(t.claims.aud!==e)throw $('unexpected JWT "aud" (audience) claim value',Ve,{expected:e,claims:t.claims,claim:"aud"});return t}function gw(e,t){let n=e[wa]?.(t)??e.issuer;if(t.claims.iss!==n)throw $('unexpected JWT "iss" (issuer) claim value',Ve,{expected:n,claims:t.claims,claim:"iss"});return t}var da=new WeakSet;function yw(e){return da.add(e),e}var pa=Symbol();async function ld(e,t,n,r,o,i,s){if(Vo(e),Wo(t),!da.has(r))throw K('"callbackParameters" must be an instance of URLSearchParams obtained from "validateAuthResponse()", or "validateJwtAuthResponse()',_e);we(o,'"redirectUri"');let a=Gt(r,"code");if(!a)throw $('no authorization code in "callbackParameters"',H);let c=new URLSearchParams(s?.additionalParameters);return c.set("redirect_uri",o),c.set("code",a),i!==pa&&(we(i,'"codeVerifier"'),c.set("code_verifier",i)),dw(e,t,n,"authorization_code",c,s)}var ww={aud:"audience",c_hash:"code hash",client_id:"client id",exp:"expiration time",iat:"issued at",iss:"issuer",jti:"jwt id",nonce:"nonce",s_hash:"state hash",sub:"subject",ath:"access token hash",htm:"http method",htu:"http uri",cnf:"confirmation",auth_time:"authentication time"};function _w(e,t){for(let n of e)if(t.claims[n]===void 0)throw $(`JWT "${n}" (${ww[n]}) claim missing`,H,{claims:t.claims});return t}var ea=Symbol(),ta=Symbol();async function fd(e,t,n,r){return typeof r?.expectedNonce=="string"||typeof r?.maxAge=="number"||r?.requireIdToken?bw(e,t,n,r.expectedNonce,r.maxAge,r[Fo],r.recognizedTokenTypes):xw(e,t,n,r?.[Fo],r?.recognizedTokenTypes)}async function bw(e,t,n,r,o,i,s){let a=[];switch(r){case void 0:r=ea;break;case ea:break;default:we(r,'"expectedNonce" argument'),a.push("nonce")}switch(o??=t.default_max_age,o){case void 0:o=ta;break;case ta:break;default:Or(o,!0,'"maxAge" argument'),a.push("auth_time")}let c=await ud(e,t,n,a,i,s);we(c.id_token,'"response" body "id_token" property',H,{body:c});let u=Qo(c);if(o!==ta){let l=ua()+aa(t),f=ca(t);if(u.auth_time+o<l-f)throw $("too much time has elapsed since the last End-User authentication",Cn,{claims:u,now:l,tolerance:f,claim:"auth_time"})}if(r===ea){if(u.nonce!==void 0)throw $('unexpected ID Token "nonce" claim value',Ve,{expected:void 0,claims:u,claim:"nonce"})}else if(u.nonce!==r)throw $('unexpected ID Token "nonce" claim value',Ve,{expected:r,claims:u,claim:"nonce"});return c}async function xw(e,t,n,r,o){let i=await ud(e,t,n,void 0,r,o),s=Qo(i);if(s){if(t.default_max_age!==void 0){Or(t.default_max_age,!0,'"client.default_max_age"');let a=ua()+aa(t),c=ca(t);if(s.auth_time+t.default_max_age<a-c)throw $("too much time has elapsed since the last End-User authentication",Cn,{claims:s,now:a,tolerance:c,claim:"auth_time"})}if(s.nonce!==void 0)throw $('unexpected ID Token "nonce" claim value',Ve,{expected:void 0,claims:s,claim:"nonce"})}return i}var Ew="OAUTH_WWW_AUTHENTICATE_CHALLENGE",vw="OAUTH_RESPONSE_BODY_ERROR",ei="OAUTH_UNSUPPORTED_OPERATION",Sw="OAUTH_AUTHORIZATION_RESPONSE_ERROR";var zr="OAUTH_PARSE_ERROR",H="OAUTH_INVALID_RESPONSE";var ha="OAUTH_RESPONSE_IS_NOT_JSON",ti="OAUTH_RESPONSE_IS_NOT_CONFORM",ma="OAUTH_HTTP_REQUEST_FORBIDDEN",ga="OAUTH_REQUEST_PROTOCOL_FORBIDDEN",Cn="OAUTH_JWT_TIMESTAMP_CHECK_FAILED",Ve="OAUTH_JWT_CLAIM_COMPARISON_FAILED",ni="OAUTH_JSON_ATTRIBUTE_COMPARISON_FAILED";var Aw="OAUTH_MISSING_SERVER_METADATA",Rw="OAUTH_INVALID_SERVER_METADATA";async function dd(e,t,n,r,o){Vo(e),Wo(t),we(r,'"token"');let i=Yo(e,"revocation_endpoint",t.use_mtls_endpoint_aliases,o?.[qt]!==!0),s=new URLSearchParams(o?.additionalParameters);s.set("token",r);let a=sa(o?.headers);return a.delete("accept"),ad(e,t,n,i,s,a,o)}async function pd(e){if(!Cr(e,Response))throw K('"response" must be an instance of Response',Ce);await sd(e,200,"Revocation Endpoint")}function ya(e){if(e.bodyUsed)throw K('"response" body has been used already',_e)}async function Tw(e,t,n,r,o){let{0:i,1:s,length:a}=e.split(".");if(a===5)if(o!==void 0)e=await o(e),{0:i,1:s,length:a}=e.split(".");else throw new St("JWE decryption is not configured",{cause:e});if(a!==3)throw $("Invalid JWT",H,e);let c;try{c=JSON.parse(Wf(ia(i)))}catch(f){throw $("failed to parse JWT Header body as base64url encoded JSON",zr,f)}if(!Ho(c))throw $("JWT Header must be a top level object",H,e);if(t(c),c.crit!==void 0)throw new St('no JWT "crit" header parameter extensions are supported',{cause:{header:c}});let u;try{u=JSON.parse(Wf(ia(s)))}catch(f){throw $("failed to parse JWT Payload body as base64url encoded JSON",zr,f)}if(!Ho(u))throw $("JWT Payload must be a top level object",H,e);let l=ua()+n;if(u.exp!==void 0){if(typeof u.exp!="number")throw $('unexpected JWT "exp" (expiration time) claim type',H,{claims:u});if(u.exp<=l-r)throw $('unexpected JWT "exp" (expiration time) claim value, expiration is past current timestamp',Cn,{claims:u,now:l,tolerance:r,claim:"exp"})}if(u.iat!==void 0&&typeof u.iat!="number")throw $('unexpected JWT "iat" (issued at) claim type',H,{claims:u});if(u.iss!==void 0&&typeof u.iss!="string")throw $('unexpected JWT "iss" (issuer) claim type',H,{claims:u});if(u.nbf!==void 0){if(typeof u.nbf!="number")throw $('unexpected JWT "nbf" (not before) claim type',H,{claims:u});if(u.nbf>l+r)throw $('unexpected JWT "nbf" (not before) claim value',Cn,{claims:u,now:l,tolerance:r,claim:"nbf"})}if(u.aud!==void 0&&typeof u.aud!="string"&&!Array.isArray(u.aud))throw $('unexpected JWT "aud" (audience) claim type',H,{claims:u});return{header:c,claims:u,jwt:e}}async function Pw(e){if(e.bodyUsed)throw K("form_post Request instances must contain a readable body",_e,{cause:e});return e.text()}async function hd(e){if(e.method!=="POST")throw K("form_post responses are expected to use the POST method",_e,{cause:e});if(fa(e)!=="application/x-www-form-urlencoded")throw K("form_post responses are expected to use the application/x-www-form-urlencoded content-type",_e,{cause:e});return Pw(e)}function Ow(e,t,n,r){if(e!==void 0){if(typeof e=="string"?r.alg!==e:!e.includes(r.alg))throw $('unexpected JWT "alg" header parameter',H,{header:r,expected:e,reason:"client configuration"});return}if(Array.isArray(t)){if(!t.includes(r.alg))throw $('unexpected JWT "alg" header parameter',H,{header:r,expected:t,reason:"authorization server metadata"});return}if(n!==void 0){if(typeof n=="string"?r.alg!==n:typeof n=="function"?!n(r.alg):!n.includes(r.alg))throw $('unexpected JWT "alg" header parameter',H,{header:r,expected:n,reason:"default value"});return}throw $('missing client or server configuration to verify used JWT "alg" header parameter',void 0,{client:e,issuer:t,fallback:n})}function Gt(e,t){let{0:n,length:r}=e.getAll(t);if(r>1)throw $(`"${t}" parameter must be provided only once`,H);return n}var md=Symbol(),kw=Symbol();function gd(e,t,n,r){if(Vo(e),Wo(t),n instanceof URL&&(n=n.searchParams),!(n instanceof URLSearchParams))throw K('"parameters" must be an instance of URLSearchParams, or URL',Ce);if(Gt(n,"response"))throw $('"parameters" contains a JARM response, use validateJwtAuthResponse() instead of validateAuthResponse()',H,{parameters:n});let o=Gt(n,"iss"),i=Gt(n,"state");if(!o&&e.authorization_response_iss_parameter_supported)throw $('response parameter "iss" (issuer) missing',H,{parameters:n});if(o&&o!==e.issuer)throw $('unexpected "iss" (issuer) response parameter value',H,{expected:e.issuer,parameters:n});switch(r){case void 0:case kw:if(i!==void 0)throw $('unexpected "state" response parameter encountered',H,{expected:void 0,parameters:n});break;case md:break;default:if(we(r,'"expectedState" argument'),i!==r)throw $(i===void 0?'response parameter "state" missing':'unexpected "state" response parameter value',H,{expected:r,parameters:n})}if(Gt(n,"error"))throw new Ir("authorization response from the server is an error",{cause:n});let a=Gt(n,"id_token"),c=Gt(n,"token");if(a!==void 0||c!==void 0)throw new St("implicit and hybrid flows are not supported");return yw(new URLSearchParams(n))}async function yd(e,t=nd){let n;try{n=await e.json()}catch(r){throw t(e),$('failed to parse "response" body as JSON',zr,r)}if(!Ho(n))throw $('"response" body must be a top level object',H,{body:n});return n}var qo=Symbol(),wa=Symbol();var Dr,wd;(typeof navigator>"u"||!navigator.userAgent?.startsWith?.("Mozilla/5.0 "))&&(wd="openid-client/v6.8.7",Dr={"user-agent":wd});var je=e=>ba.get(e),ba,_a;function zw(e){return e!==void 0?la(e):(_a||=new WeakMap,(t,n,r,o)=>{let i;return(i=_a.get(n))||(Cw(n.client_secret,'"metadata.client_secret"'),i=la(n.client_secret),_a.set(n,i)),i(t,n,r,o)})}function Cw(e,t){if(typeof e!="string")throw We(`${t} must be a string`,Mr);if(e.length===0)throw We(`${t} must not be empty`,Ur)}function $w(){return od()}var $n=Jt;var Ur="ERR_INVALID_ARG_VALUE",Mr="ERR_INVALID_ARG_TYPE";function We(e,t,n){let r=new TypeError(e,{cause:n});return Object.assign(r,{code:t}),r}function bd(){return rd()}var Dn=class extends Error{code;constructor(t,n){super(t,n),this.name=this.constructor.name,this.code=n?.code,Error.captureStackTrace?.(this,this.constructor)}},nO=new TextDecoder;function ge(e,t,n){return new Dn(e,{cause:t,code:n})}function $r(e){if(e instanceof TypeError||e instanceof Dn||e instanceof In||e instanceof Ir||e instanceof zn)throw e;if(e instanceof kr)switch(e.code){case ma:throw ge("only requests to HTTPS are allowed",e,e.code);case ga:throw ge("only requests to HTTP or HTTPS are allowed",e,e.code);case ti:throw ge("unexpected HTTP response status code",e.cause,e.code);case ha:throw ge("unexpected response content-type",e.cause,e.code);case zr:throw ge("parsing error occured",e,e.code);case H:throw ge("invalid response encountered",e,e.code);case Ve:throw ge("unexpected JWT claim value encountered",e,e.code);case ni:throw ge("unexpected JSON attribute value encountered",e,e.code);case Cn:throw ge("JWT timestamp claim value failed validation",e,e.code);default:throw ge(e.message,e,e.code)}if(e instanceof St)throw ge("unsupported operation",e,e.code);if(e instanceof DOMException)switch(e.name){case"OperationError":throw ge("runtime operation error",e,ei);case"NotSupportedError":throw ge("runtime unsupported operation",e,ei);case"TimeoutError":throw ge("operation timed out",e,"OAUTH_TIMEOUT");case"AbortError":throw ge("operation aborted",e,"OAUTH_ABORT")}throw new Dn("something went wrong",{cause:e})}function Dw(e,t,n){return e.origin==="https://login.microsoftonline.com"&&(!n?.algorithm||n.algorithm==="oidc")?(t[Ed]=!0,!0):!1}function Uw(e,t){return!!(e.hostname.endsWith(".b2clogin.com")&&(!t?.algorithm||t.algorithm==="oidc"))}async function xd(e,t,n,r,o){let i=await Mw(e,o),s=new Un(i,t,n,r),a=je(s);if(o?.[$n]&&(a.fetch=o[$n]),o?.timeout&&(a.timeout=o.timeout),o?.execute)for(let c of o.execute)c(s);return s}async function Mw(e,t){if(!(e instanceof URL))throw We('"server" must be an instance of URL',Mr);let n=!e.href.includes("/.well-known/"),r=t?.timeout??30,o=AbortSignal.timeout(r*1e3),i=await(n?ed(e,{algorithm:t?.algorithm,[Jt]:t?.[$n],[qt]:t?.execute?.includes(_d),signal:o,headers:new Headers(Dr)}):(t?.[$n]||fetch)((Xo(e,!t?.execute?.includes(_d)),e.href),{headers:Object.fromEntries(new Headers({accept:"application/json",...Dr}).entries()),body:void 0,method:"GET",redirect:"manual",signal:o})).then(s=>td(qo,s)).catch($r);return n&&new URL(i.issuer).href!==e.href&&(Dw(e,i,t)||Uw(e,t)||(()=>{throw new Dn("discovered metadata issuer does not match the expected issuer",{code:ni,cause:{expected:e.href,body:i,attribute:"issuer"}})})()),i}function Lw(e){return{supportsPKCE:{__proto__:null,value(t="S256"){return e.code_challenge_methods_supported?.includes(t)===!0}}}}function Nw(e){Object.defineProperties(e,Lw(e))}var Ed=Symbol(),Un=class{constructor(t,n,r,o){if(typeof n!="string"||!n.length)throw We('"clientId" must be a non-empty string',Mr);if(typeof r=="string"&&(r={client_secret:r}),r?.client_id!==void 0&&n!==r.client_id)throw We('"clientId" and "metadata.client_id" must be the same',Ur);let i={...structuredClone(r),client_id:n};i[Jo]=r?.[Jo]??0,i[Ko]=r?.[Ko]??30;let s;o?s=o:typeof i.client_secret=="string"&&i.client_secret.length?s=zw(i.client_secret):s=$w();let a=Object.freeze(i),c=structuredClone(t);Ed in t&&(c[wa]=({claims:{tid:l}})=>t.issuer.replace("{tenantid}",l));let u=Object.freeze(c);ba||=new WeakMap,ba.set(this,{__proto__:null,as:u,c:a,auth:s,tlsOnly:!0,jwksCache:{}})}serverMetadata(){let t=structuredClone(je(this).as);return Nw(t),t}clientMetadata(){return structuredClone(je(this).c)}get timeout(){return je(this).timeout}set timeout(t){je(this).timeout=t}get[$n](){return je(this).fetch}set[$n](t){je(this).fetch=t}};Object.freeze(Un.prototype);function Bw(e){let t;if(e.expires_in!==void 0){let n=new Date;n.setSeconds(n.getSeconds()+e.expires_in),t=n.getTime()}return{expiresIn:{__proto__:null,value(){if(t){let n=Date.now();return t>n?Math.floor((t-n)/1e3):0}}},claims:{__proto__:null,value(){return Qo(e)}}}}function jw(e){Object.defineProperties(e,Bw(e))}function _d(e){je(e).tlsOnly=!1}function Zw(e){return e=new URL(e),e.search="",e.hash="",e.href}function Fw(e,t){try{return Object.getPrototypeOf(e)[Symbol.toStringTag]===t}catch{return!1}}async function xa(e,t,n,r,o){if(Ea(e),o?.flag!==ri&&!(t instanceof URL)&&!Fw(t,"Request"))throw We('"currentUrl" must be an instance of URL, or Request',Mr);let i,s,{as:a,c,auth:u,fetch:l,tlsOnly:f,jarm:d,hybrid:m,nonRepudiation:w,timeout:b,decrypt:S,implicit:h}=je(e);if(o?.flag===ri)i=o.authResponse,s=o.redirectUri;else{if(!(t instanceof URL)){let A=t;switch(t=new URL(t.url),A.method){case"GET":break;case"POST":let k=new URLSearchParams(await hd(A));if(m)t.hash=k.toString();else for(let[I,U]of k.entries())t.searchParams.append(I,U);break;default:throw We("unexpected Request HTTP method",Ur)}}switch(s=Zw(t),!0){case!!d:i=await d(t,n?.expectedState);break;case!!m:i=await m(t,n?.expectedNonce,n?.expectedState,n?.maxAge);break;case!!h:throw new TypeError("authorizationCodeGrant() cannot be used by response_type=id_token clients");default:try{i=gd(a,c,t.searchParams,n?.expectedState)}catch(A){$r(A)}}}let _=await ld(a,c,u,i,s,n?.pkceCodeVerifier||pa,{additionalParameters:r,[Jt]:l,[qt]:!f,DPoP:o?.DPoP,headers:new Headers(Dr),signal:Sd(b)}).catch($r);(typeof n?.expectedNonce=="string"||typeof n?.maxAge=="number")&&(n.idTokenExpected=!0);let x=fd(a,c,_,{expectedNonce:n?.expectedNonce,maxAge:n?.maxAge,requireIdToken:n?.idTokenExpected,[Fo]:S}),E;try{E=await x}catch(A){if(Hw(A,o))return xa(e,void 0,n,r,{...o,flag:ri,authResponse:i,redirectUri:s});$r(A)}return E.id_token&&await w?.(_),jw(E),E}function vd(e,t){Ea(e);let{as:n,c:r,tlsOnly:o,hybrid:i,jarm:s,implicit:a}=je(e),c=Yo(n,"authorization_endpoint",!1,o);if(t=new URLSearchParams(t),t.has("client_id")||t.set("client_id",r.client_id),!t.has("request_uri")&&!t.has("request")){if(t.has("response_type")||t.set("response_type",i?"code id_token":a?"id_token":"code"),a&&!t.has("nonce"))throw We("response_type=id_token clients must provide a nonce parameter in their authorization request parameters",Ur);s&&t.set("response_mode","jwt")}for(let[u,l]of t.entries())c.searchParams.append(u,l);return c}function Ea(e){if(!(e instanceof Un))throw We('"config" must be an instance of Configuration',Mr);if(Object.getPrototypeOf(e)!==Un.prototype)throw We("subclassing Configuration is not allowed",Ur)}function Sd(e){return e?AbortSignal.timeout(e*1e3):void 0}function Hw(e,t){return t?.DPoP&&t.flag!==ri?id(e):!1}var ri=Symbol();async function Ad(e,t,n){Ea(e);let{as:r,c:o,auth:i,fetch:s,tlsOnly:a,timeout:c}=je(e);return dd(r,o,i,t,{[Jt]:s,[qt]:!a,additionalParameters:new URLSearchParams(n),headers:new Headers(Dr),signal:Sd(c)}).then(pd).catch($r)}var Rd="oauth2:",Lr="graffiti-auth-oauth2-data",oi=class{eventTarget=new EventTarget;constructor(){let t=this.completeOauth();(async()=>{await new Promise(r=>setTimeout(r,0)),await t;let n=new CustomEvent("initialized");this.eventTarget.dispatchEvent(n)})()}async login(...t){try{await this.login_(...t)}catch(n){let r=n instanceof Error?n:new Error("Unknown error"),o={loginId:t[1],error:r};this.eventTarget.dispatchEvent(new CustomEvent("login",{detail:o}))}}async login_(t,n,r){let o=await this.getAuthorizationConfiguration(t),i=r.map(encodeURIComponent).join(" "),s=bd(),a,c;if(typeof window<"u"){a=window.location.href;let f={loginId:n,redirectUri:a,authorizationEndpoint:t,state:s,serviceEndpoints:r};window.localStorage.setItem(Lr,JSON.stringify(f))}else{let d=(await import("node:http").catch(w=>{throw new Error("Unrecognized environment: cannot find window or node:http")})).createServer();try{await new Promise((w,b)=>{d.once("error",b),d.listen(0,"::1",w)})}catch{try{d.close()}catch{}throw new Error("Failed to start local oauth callback server.")}let m=d.address();if(!m){try{d.close()}catch{}throw new Error("Failed to get local oauth callback server address.")}a=typeof m=="string"?`http://${m}`:`http://${m.family==="IPv6"?`[${m.address}]`:m.address}:${m.port}`,c=new Promise((w,b)=>{let S=setTimeout(()=>{try{d.close()}catch{}b("Oauth callback timed out.")},3e5),h=new Set;d.on("connection",x=>{h.add(x),x.on("close",()=>{h.delete(x)})});let _=async(x,E)=>{try{let A=new URL(x.url??"/",a);await this.onCallbackUrl({loginId:n,callbackUrl:A,configuration:o,expectedState:s,serviceEndpoints:r}),E.statusCode=200,E.setHeader("Content-Type","text/plain"),E.end("You may now close this window.")}catch(A){throw E.statusCode=500,E.setHeader("Content-Type","text/plain"),E.end("Error processing OAuth callback."),A}finally{clearTimeout(S),d.off("request",_);for(let A of h)A.destroy();d.close(()=>w())}};d.on("request",_)})}let u=new URL(a);u.hash="",u.search="";let l=vd(o,{scope:i,redirect_uri:u.toString(),state:s});typeof window<"u"?window.location.href=l.toString():(console.log("Please open the following URL in your browser:"),console.log(l.toString()),await c)}completeOauth(){if(typeof window>"u")return;let t=window.localStorage.getItem(Lr);if(!t)return;let n;try{n=JSON.parse(t)}catch{console.error("Invalid OAuth2 login data in local storage."),window.localStorage.removeItem(Lr);return}let r=Gw.safeParse(n);if(!r.success){console.error("Invalid OAuth2 login data structure in local storage.",r.error),window.localStorage.removeItem(Lr);return}let{loginId:o,redirectUri:i,authorizationEndpoint:s,state:a,serviceEndpoints:c}=r.data;try{let u=new URL(i),l=new URL(window.location.href);if(u.pathname!==l.pathname)return;let f=l.searchParams;return!f.has("code")&&!f.has("error")?void 0:(window.history.replaceState({},document.title,u.toString()),window.localStorage.removeItem(Lr),new Promise(d=>setTimeout(d,0)).then(()=>this.getAuthorizationConfiguration(s)).then(d=>this.onCallbackUrl({loginId:o,callbackUrl:l,configuration:d,expectedState:a,serviceEndpoints:c})).catch(d=>{let m=d instanceof Error?d:new Error("Unknown error"),w={loginId:o,error:m};this.eventTarget.dispatchEvent(new CustomEvent("login",{detail:w}))}))}catch(u){console.error(u)}}async onCallbackUrl(t){let{loginId:n,callbackUrl:r,configuration:o,expectedState:i,serviceEndpoints:s}=t,a=await xa(o,r,{expectedState:i}),c=a.access_token,l=a.scope?.split(" ").map(decodeURIComponent)||s;if(!s.every(d=>l.includes(d)))throw new Error("Not all requested service endpoints were granted.");let f=new CustomEvent("login",{detail:{loginId:n,token:c}});this.eventTarget.dispatchEvent(f)}async logout(t,n,r){try{await this.logout_(t,n,r)}catch(o){let i=o instanceof Error?o:new Error("Unknown error"),s={logoutId:n,error:i};this.eventTarget.dispatchEvent(new CustomEvent("logout",{detail:s}))}}async logout_(t,n,r){let o=await this.getAuthorizationConfiguration(t);await Ad(o,r);let i={logoutId:n};this.eventTarget.dispatchEvent(new CustomEvent("logout",{detail:i}))}async getAuthorizationConfiguration(t){if(!t.startsWith(Rd))throw new Error(`Unrecognized authorization endpoint method: ${t}`);let n=t.slice(Rd.length),r;try{r=new URL(n)}catch{throw new Error("Invalid issuer URL.")}return await xd(r,"graffiti-client")}},Td=_u(xe({loginId:j()}),at([xe({token:j(),error:Y(wu())}),xe({error:rn(Error)})])),Pd=xe({logoutId:j(),error:Y(rn(Error))}),Od=Y(Ue(xe({error:Y(rn(Error))}))),Gw=xe({loginId:j(),redirectUri:F(),authorizationEndpoint:F(),state:j(),serviceEndpoints:J(F())});var qw="https://";function $e(e){if(!e.startsWith(qw))throw new Error("Unrecognized storage bucket endpoint type")}async function ii(e){$e(e);let t=`${e}/auth`,n=await fetch(t);if(!n.ok)throw new Error("Failed to get storage bucket authorization endpoint");return await n.text()}var Kt=class e extends Error{constructor(t){super(t),this.name="GraffitiErrorUnauthorized",Object.setPrototypeOf(this,e.prototype)}};async function Xe(...e){let t=await fetch(...e);if(!t.ok){let n;try{n=await t.text()}catch{n=t.statusText}throw t.status===401?new Kt(n):t.status===403?new ht(n):t.status===404?new Q(n):t.status===410?new Me(n):t.status===413?new mt(n):new Error(n)}return t}var Jw=32,Kw=1024*1024,Vw=2;function kd(e){return Math.min(Jw,Math.floor(Kw/e))}var si=class{getAuthorizationEndpoint=ii;queues=new Map;unsupportedBatchEndpoints=new Set;async put(t,n,r,o){$e(t);let i=`${t}/value/${encodeURIComponent(n)}`;await Xe(i,{method:"PUT",headers:{"Content-Type":"application/octet-stream",Authorization:`Bearer ${o}`},body:r.slice()})}async delete(t,n,r){$e(t);let o=`${t}/value/${encodeURIComponent(n)}`;await Xe(o,{method:"DELETE",headers:{Authorization:`Bearer ${r}`}})}async get(t,n,r){return $e(t),r!==void 0&&Number.isSafeInteger(r)&&r>0&&kd(r)>=2&&!this.unsupportedBatchEndpoints.has(t)?new Promise((o,i)=>{let s=this.queues.get(t);s||(s=new Map,this.queues.set(t,s));let a=s.get(r);a||(a={requests:[]},s.set(r,a)),a.requests.push({key:n,resolve:o,reject:i}),a.requests.length===kd(r)?this.flush(t,r,a):a.timer===void 0&&(a.timer=setTimeout(()=>this.flush(t,r,a),Vw))}):this.getOne(t,n,r)}flush(t,n,r){r.timer!==void 0&&clearTimeout(r.timer);let o=r.requests,i=this.queues.get(t);i.delete(n),i.size===0&&this.queues.delete(t),o.length===1||this.unsupportedBatchEndpoints.has(t)?o.forEach(({key:s,resolve:a,reject:c})=>{this.getOne(t,s,n).then(a,c)}):this.getBatch(t,n,o)}async getBatch(t,n,r){try{let o=await fetch(`${t}/values`,{method:"POST",headers:{"Content-Type":"application/cbor",Accept:"application/cbor"},body:me({keys:r.map(({key:s})=>s),maxValueBytes:n}).slice()});if(o.status===404){this.unsupportedBatchEndpoints.add(t),await Promise.all(r.map(async({key:s,resolve:a,reject:c})=>{try{a(await this.getOne(t,s,n))}catch(u){c(u)}}));return}if(!o.ok)throw new Error(await o.text());let i=Ne(await o.arrayBuffer());if(!i||typeof i!="object"||!("results"in i)||!Array.isArray(i.results)||i.results.length!==r.length)throw new Error("Invalid storage batch response");i.results.forEach((s,a)=>{let{resolve:c,reject:u}=r[a];!s||typeof s!="object"||!("status"in s)?u(new Error("Invalid storage batch result")):s.status===200&&"value"in s&&s.value instanceof Uint8Array&&s.value.byteLength<=n?c(s.value):s.status===404?u(new Q("Value not found")):s.status===413?u(new mt("Value exceeds maximum byte limit")):u(new Error("Invalid storage batch result"))})}catch(o){r.forEach(({reject:i})=>i(o))}}async getOne(t,n,r){let o=`${t}/value/${encodeURIComponent(n)}`,i=await Xe(o),s=i.body?.getReader();if(!s)throw new Error("Failed to read value from storage bucket");let a=i.headers.get("Content-Length"),c=a?Number(a):void 0;if(!!c&&!!Number.isFinite(c)&&c>=0){let w=c;if(r!==void 0&&w>r)throw new Error("Value exceeds maximum byte limit");let b=new Uint8Array(w),S=0,h=!1;try{for(;S<=b.length;){let{done:_,value:x}=await s.read();if(_){h=!0;break}if(!x||x.length===0)continue;let E=S+x.length;if(E>b.length)throw new Error("Received more data than expected");b.set(x,S),S=E}}finally{s.releaseLock()}if(!h)throw new Error("Failed to read complete value from storage bucket");return S===w?b:b.slice(0,S)}let l=[],f=0;try{for(;;){let{done:w,value:b}=await s.read();if(w)break;if(!(!b||b.length===0)){if(f+=b.length,r!==void 0&&f>r)throw new Error("Value exceeds maximum byte limit");l.push(b.slice())}}}finally{s.releaseLock()}let d=new Uint8Array(f),m=0;for(let w of l)d.set(w,m),m+=w.length;return d}async*export(t,n){$e(t);let r=`${t}/export`,o;for(;;){let s=await(await Xe(o?`${r}?cursor=${encodeURIComponent(o)}`:r,{headers:{Authorization:`Bearer ${n}`}})).blob(),a=Ne(await s.arrayBuffer()),c=Ww.parse(a);for(let u of c.keys)yield{key:u};if(c.cursor)o=c.cursor;else break}}},Ww=xe({keys:J(j()),cursor:Y(Ue(j()))});var ci=class{getAuthorizationEndpoint=ii;cache_=null;get cache(){return this.cache_||(this.cache_=r_()),this.cache_}async send(t,n){$e(t);let r=`${t}/send`,i=await(await Xe(r,{method:"PUT",headers:{"Content-Type":"application/cbor"},body:new Uint8Array(me({m:n}))})).blob(),s=Ne(await i.arrayBuffer());return e_.parse(s).id}async get(t,n,r){let o=ai(t,n),i=await this.cache,s=await i.messages.get(o);if(s!==void 0)return s;let a=`${t}/message/${n}`,c=null;try{c=await Xe(a,{method:"GET",headers:{...r?{Authorization:`Bearer ${r}`}:{}}})}catch(d){if(d instanceof Q)return await i.messages.set(o,null),null;throw d}let u=await c.blob(),l=Ne(await u.arrayBuffer()),f=Dd.parse(l);return await i.messages.set(o,f),f}async label(t,n,r,o){if($e(t),o){let c=`${t}/label/${n}`;await Xe(c,{method:"PUT",headers:{"Content-Type":"application/cbor",Authorization:`Bearer ${o}`},body:new Uint8Array(me({l:r}))})}let i=await this.cache,s=ai(t,n),a=await i.messages.get(s);a&&await i.messages.set(s,{...a,l:r})}async fetchMessageBatch(t,n,r,o,i,s){let a=await Xe(`${t}/${n}${i?`?cursor=${encodeURIComponent(i)}`:""}`,{method:"POST",headers:{"Content-Type":"application/cbor",...o?{Authorization:`Bearer ${o}`}:{}},body:r,signal:s}),c=a.headers.get("Retry-After"),u=c?parseInt(c):void 0,l=u&&Number.isFinite(u)?Date.now()+u*1e3:void 0;return{response:a,waitTil:l}}async*yieldFromCache(t,n,r,o,i=0){let s=o.messageIds.slice(i);yield*await Promise.all(s.map(async c=>{let u=await t.messages.get(ai(n,c));if(!u){try{await t.messageIds.del(r)}catch{}throw new Error("Cache out of sync - perhaps clear browser storage")}return u}))}async*lockedMessageStreamer(...t){if(typeof window>"u"||!await Ud()){let w=this.messageStreamer(...t);for(;;){let b=await w.next();if(b.done)return b.value;yield b.value}}let n=await t[0],r=`graffiti:inbox:${n}`,o=()=>{},i=!1;if(await new Promise(w=>{window.navigator.locks.request(r,{mode:"exclusive",ifAvailable:!0},async b=>{i=!!b,w(),await new Promise(S=>o=S)})}),i)try{let w=this.messageStreamer(...t);for(;;){let b=await w.next();if(b.done)return b.value;yield b.value}}finally{o()}o(),await window.navigator.locks.request(r,()=>{});let s=t[1],a=t[5]??{},c=t[6],u=t[7],l=await this.cache,f=await l.messageIds.get(n);if(!f)throw new Error("Cache not found");if(c!==void 0&&c!==f.version)throw new Me("Cursor is stale");let d=this.yieldFromCache(l,s,n,f,u);for await(let w of d)yield w;let m={numSeen:f.messageIds.length,version:f.version,messageIdsCacheKey:n,objectSchema:a};return JSON.stringify(m)}async*messageStreamer(t,n,r,o,i,s={},a,c=0){let u=await ro(s),l=await t,f=await this.cache,d=await f.messageIds.get(l);if(a!==void 0&&a!==d?.version)throw new Me("Cursor is stale");let m=d?.waitTil;await Cd(m);let w=d?.cursor,b;try{let A=await this.fetchMessageBatch(n,r,o,i,w);b=A.response,m=A.waitTil}catch(A){if(!(A instanceof Me&&w))throw console.error("Unexpected error in stream, waiting 5 seconds before continuing..."),await new Promise(k=>setTimeout(k,5e3)),A;if(await f.messageIds.del(l),a===void 0)d=void 0;else throw A}if(b!==void 0&&d){let A=this.yieldFromCache(f,n,l,d,c);for await(let k of A)yield k}if(b===void 0){let A=await this.fetchMessageBatch(n,r,o,i);b=A.response,m=A.waitTil}let S=b,h,_=d?.version??crypto.randomUUID(),x=d?.messageIds??[];for(;;){let A=await S.blob(),k=Ne(await A.arrayBuffer()),{results:I,hasMore:U,cursor:V}=t_.parse(k);h=V;let G=I.map(L=>{let B=L[Vt][lt];if(!u(B))throw new Error("Server returned data that does not match schema");return{...L,[Vt]:{...L[Vt],[lt]:B}}});await f.messages.setMany(G.map(L=>[ai(n,L[va]),L])),x=[...x,...G.map(L=>L[va])],await f.messageIds.set(l,{cursor:h,version:_,messageIds:x,waitTil:m}),c+=G.length;let g=new AbortController,v=U?Cd(m).then(()=>this.fetchMessageBatch(n,r,void 0,i,h,g.signal)).then(L=>({value:L}),L=>({error:L})):null,D=!1;try{for(let L of G)yield L;D=!0}finally{D||g.abort()}if(!U)break;let M=await v;if("error"in M)throw M.error;S=M.value.response,m=M.value.waitTil}return JSON.stringify({numSeen:c,version:_,messageIdsCacheKey:l,objectSchema:s})}query(t,n,r,o){$e(t);let i=me({tags:n,schema:r}),s=Id(t,"query",i);return this.lockedMessageStreamer(s,t,"query",new Uint8Array(i),o,r)}continueQuery(t,n,r){$e(t);let o=JSON.parse(n),{messageIdsCacheKey:i,numSeen:s,objectSchema:a,version:c}=n_.parse(o);return this.lockedMessageStreamer(Promise.resolve(i),t,"query",void 0,r,a,c,s)}export(t,n){$e(t);let r=Id(t,"export");return this.lockedMessageStreamer(r,t,"export",void 0,n)}},Xw=Ee({value:ve({}),channels:J(j()),allowed:Y(Ue(J(F()))),url:F(),actor:F()}),$d=Ut(e=>e instanceof Uint8Array),Yw=J($d),Nr="t",lt="o",Br="m",Qw=Ee({[Nr]:Yw,[lt]:Xw,[Br]:$d}),va="id",Vt="m",ui="l",Dd=Ee({[va]:j(),[Vt]:Qw,[ui]:yu()}),e_=Ee({id:j()}),t_=Ee({results:J(Dd),hasMore:Vn(),cursor:j()}),n_=Ee({messageIdsCacheKey:j(),version:j(),numSeen:nn().check(Dt()),objectSchema:at([ve({}),Vn()])});async function Ud(){try{return globalThis.indexedDB?(await new Promise((e,t)=>{let n=indexedDB.open("__idb_probe__",1);n.onupgradeneeded=()=>n.result.createObjectStore("k"),n.onsuccess=()=>{n.result.close(),e()},n.onerror=()=>t(n.error)}),!0):!1}catch{return!1}}function ai(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}async function Id(e,t,n){let r=me({inboxUrl:e,type:t,body:n??null});return crypto.subtle.digest("SHA-256",new Uint8Array(r)).then(o=>Array.from(new Uint8Array(o)).map(i=>i.toString(16).padStart(2,"0")).join(""))}async function zd(){await new Promise(e=>{let t=indexedDB.deleteDatabase("graffiti-inbox-cache");t.onsuccess=()=>e(),t.onerror=()=>e(),t.onblocked=()=>e()})}async function r_(){if(await Ud()){let{openDB:n}=await import("./build-KAK33G4E.js"),r=await n("graffiti-inbox-cache",1,{upgrade(o){o.objectStoreNames.contains("m")||o.createObjectStore("m"),o.objectStoreNames.contains("q")||o.createObjectStore("q")}});return{messages:{get:async o=>{try{return r.get("m",o)}catch(i){console.error("Error getting message from cache:",i),console.error("resetting cache..."),await zd();return}},set:async(o,i)=>{await r.put("m",i,o)},setMany:async o=>{if(o.length===0)return;let i=r.transaction("m","readwrite");await Promise.all([...o.map(([s,a])=>i.store.put(a,s)),i.done])},del:o=>r.delete("m",o)},messageIds:{get:async o=>{try{return await r.get("q",o)}catch(i){console.error("Error getting message IDs from cache:",i),console.error("resetting cache..."),await zd();return}},set:async(o,i)=>{await r.put("q",i,o)},del:o=>r.delete("q",o)}}}let e=new Map,t=new Map;return{messages:{get:async n=>e.get(n),set:async(n,r)=>{e.set(n,r)},setMany:async n=>{for(let[r,o]of n)e.set(r,o)},del:async n=>{e.delete(n)}},messageIds:{get:async n=>t.get(n),set:async(n,r)=>{t.set(n,r)},del:async n=>{t.delete(n)}}}}async function Cd(e){if(e!==void 0){let t=e-Date.now();t>0&&await new Promise(n=>setTimeout(n,t))}}var Mn="base64url";var li=class{async encode(t,n){if(t!==Mn)throw new Error(`Unsupported string encoding method: ${t}`);return"u"+btoa(String.fromCodePoint(...n)).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=+$/,"")}async decode(t){if(!t.startsWith("u"))throw new Error(`Unsupported string encoding prefix: ${t[0]}`);t=t.slice(1);let n=t.replace(/-/g,"+").replace(/_/g,"/");for(;n.length%4!==0;)n+="=";return Uint8Array.from(atob(n),r=>r.charCodeAt(0))}};function Md(){let t=(typeof globalThis=="object"?globalThis.crypto:null)?.subtle;if(typeof t=="object"&&t!=null)return t;throw new Error("crypto.subtle must be defined")}function Ld(e,t,n){let r=async o=>{Xn(o);let i=Md();return new Uint8Array(await i.digest(e,o))};return r.webCryptoName=e,r.outputLen=n,r.blockLen=t,r.create=()=>{throw new Error("not implemented")},Object.freeze(r)}function o_(e){Ou(e);let t=e.webCryptoName;if(typeof t!="string")throw new Error("non-web hash");return t}var Wt=Ld("SHA-256",64,32);var Nd=Ld("SHA-512",128,64),Sa=(()=>{let e=async(t,n,r)=>{let o=Md();Xn(n,void 0,"key"),Xn(r,void 0,"message");let i=o_(t),s=Pu(r);try{let a=await o.importKey("raw",n,{name:"HMAC",hash:i},!1,["sign"]);return new Uint8Array(await o.sign("HMAC",a,s))}finally{ku(s)}};return e.create=(t,n)=>{throw new Error("not implemented")},e})();var fi="sha2-256",jr=18,Ln=32,di=class{async register(t,n){if(t!==fi)throw new Error(`Unsupported content address method: ${t}`);let r=await Wt(n),o=new Uint8Array(2+r.length);return o[0]=jr,o[1]=Ln,o.set(r,2),o}async getMethod(t){if(t[0]===jr&&t[1]===Ln&&t.length===2+Ln)return fi;throw new Error("Unrecognized content address format.")}};var Gd=Object.freeze,Nn=0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,mi=0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,pi=0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Ra=0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Ta=0x6666666666666666666666666666666666666666666666666666666666666658n,hi=Nn-1n,i_=Gd({p:Nn,n:mi,h:8n,a:hi,d:pi,Gx:Ra,Gy:Ta}),Zr=32,Bd=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&e.BYTES_PER_ELEMENT===1,Qe=(e,t,n="")=>{if(Bd(e)&&(t===void 0||e.length===t))return e;let r=Bd(e),o=t!==void 0?` of length ${t}`:"",i=r?`length=${e.length}`:`type=${typeof e}`,s=(n?`"${n}" `:"")+"expected Uint8Array"+o+", got "+i;throw r?new RangeError(s):new TypeError(s)},Pa=(e,t="",n)=>Uint8Array.from(Qe(e,n,t)),qd=(e,t)=>e.toString(16).padStart(t,"0"),Jd=e=>{let t="";for(let n of Qe(e))t+=qd(n,2);return t},Kd=e=>{let t="hex invalid";if(typeof e!="string")throw new TypeError(t);if(e.length%2||!/^[\da-f]*$/i.test(e))throw new RangeError(t);let n=new Uint8Array(e.length/2);for(let r=0,o=0;r<n.length;r++,o+=2){let i=e.charCodeAt(o),s=e.charCodeAt(o+1);n[r]=((i&15)+(i>>6)*9)*16+(s&15)+(s>>6)*9}return n},Fr=(...e)=>{let t=0;for(let o of e)t+=Qe(o).length;let n=new Uint8Array(t),r=0;for(let o of e)n.set(o,r),r+=o.length;return n};var Xt=(e,t,n,r="bad number: out of range")=>{if(typeof e!="bigint")throw new TypeError(r);if(t<=e&&e<n)return e;throw new RangeError(r)},X=(e,t=Nn)=>(e%=t)>=0n?e:t+e,jd=(1n<<255n)-1n,O=e=>{if(e<0n)throw new RangeError("negative coordinate");let t=(e>>255n)*19n+(e&jd);return t=(t>>255n)*19n+(t&jd),t%Nn},Vd=e=>X(e,mi),s_=(e,t)=>{if(e===0n)throw new Error("invert: expected non-zero number");if(t<=1n)throw new Error("invert: expected modulus > 1, got "+t);let n=X(e,t),r=t,o=0n,i=1n;for(;n!==0n;){let a=r/n,c=r-n*a,u=o-i*a;r=n,n=c,o=i,i=u}if(r!==1n)throw new Error("invert: does not exist");return X(o,t)},a_=e=>{let t=Ia[e];if(typeof t!="function")throw new Error("hashes."+e+" not set");return t};var Oa=async(e,...t)=>Qe(await a_(e)(Fr(...t)),64,"digest");var Aa=e=>{if(e instanceof ft)return e;throw new TypeError("Point expected")},Wd=2n**256n,ft=class e{static BASE;static ZERO;X;Y;Z;T;constructor(t,n,r,o){let i=Wd;this.X=Xt(t,0n,i),this.Y=Xt(n,0n,i),this.Z=Xt(r,1n,i),this.T=Xt(o,0n,i),Gd(this)}static CURVE(){return i_}static fromAffine(t){return new e(t.x,t.y,1n,O(t.x*t.y))}static fromBytes(t,n=!1){let r=Pa(t,"point",Zr),o=r[31];r[31]=o&-129;let i=ka(r);n||Xt(i,0n,Nn);let s=O(i*i),a=X(s-1n),c=O(pi*s+1n),{isValid:u,value:l}=u_(a,c);if(!u)throw new Error("bad point: y not sqrt");let f=!!(o&128);if(!n&&l===0n&&f)throw new Error("bad point: x==0, isLastByteOdd");return f!==!!(l&1n)&&(l=X(-l)),new e(l,i,1n,O(l*i))}static fromHex(t,n){return e.fromBytes(Kd(t),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){let t=hi,n=pi,r=this;if(r.is0())throw new Error("bad point: ZERO");let{X:o,Y:i,Z:s,T:a}=r,c=O(o*o),u=O(i*i),l=O(s*s),f=O(l*l),d=O(c*t),m=O(l*(d+u)),w=X(f+O(n*O(c*u)));if(m!==w)throw new Error("bad point: equation left != right (1)");let b=O(o*i),S=O(s*a);if(b!==S)throw new Error("bad point: equation left != right (2)");return this}equals(t){let{X:n,Y:r,Z:o}=this,{X:i,Y:s,Z:a}=Aa(t);return O(n*a)===O(i*o)&&O(r*a)===O(s*o)}is0(){return this.equals(Yt)}negate(){return new e(X(-this.X),this.Y,this.Z,X(-this.T))}double(){let{X:t,Y:n,Z:r}=this,o=hi,i=O(t*t),s=O(n*n),a=O(2n*r*r),c=O(o*i),u=X(t+n),l=X(O(u*u)-i-s),f=X(c+s),d=X(f-a),m=X(c-s),w=O(l*d),b=O(f*m),S=O(l*m),h=O(d*f);return new e(w,b,h,S)}add(t){let{X:n,Y:r,Z:o,T:i}=this,{X:s,Y:a,Z:c,T:u}=Aa(t),l=hi,f=pi,d=O(n*s),m=O(r*a),w=O(O(i*f)*u),b=O(o*c),S=X(O(X(n+r)*X(s+a))-d-m),h=X(b-w),_=X(b+w),x=X(m-O(l*d)),E=O(S*h),A=O(_*x),k=O(S*x),I=O(h*_);return new e(E,A,I,k)}subtract(t){return this.add(Aa(t).negate())}multiply(t,n=!0){if(!n&&t===0n||(Xt(t,1n,mi),!n&&this.is0()))return Yt;if(t===1n)return this;if(this.equals(At))return m_(t).p;let r=Yt,o=At,i=this;for(let s=0;n?s<256:t>0n;s++)t&1n?r=r.add(i):n&&(o=o.add(i)),i=i.double(),t>>=1n;return r}multiplyUnsafe(t){return this.multiply(t,!1)}toAffine(){let{X:t,Y:n,Z:r}=this;if(this.equals(Yt))return{x:0n,y:1n};let o=s_(r,Nn);if(O(r*o)!==1n)throw new Error("invalid inverse");return{x:O(t*o),y:O(n*o)}}toBytes(){let{x:t,y:n}=this.toAffine(),r=Xd(n);return r[31]|=t&1n?128:0,r}toHex(){return Jd(this.toBytes())}clearCofactor(){return this.multiply(8n,!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return this.multiply(mi/2n,!1).double().add(this).is0()}},At=new ft(Ra,Ta,1n,X(Ra*Ta)),Yt=new ft(0n,1n,1n,0n);ft.BASE=At;ft.ZERO=Yt;var Xd=e=>Kd(qd(Xt(e,0n,Wd),64)).reverse(),ka=e=>BigInt("0x"+Jd(Uint8Array.from(Qe(e)).reverse())),Ye=(e,t)=>{let n=e;for(;t-- >0;)n=O(n*n);return n},c_=e=>{let t=O(e*e),n=O(t*e),r=O(Ye(n,2)*n),o=O(Ye(r,1)*e),i=O(Ye(o,5)*o),s=O(Ye(i,10)*i),a=O(Ye(s,20)*s),c=O(Ye(a,40)*a),u=O(Ye(c,80)*c),l=O(Ye(u,80)*c),f=O(Ye(l,10)*i);return O(Ye(f,2)*e)},Zd=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,u_=(e,t)=>{let n=O(t*O(t*t)),r=O(O(n*n)*t),o=c_(O(e*r)),i=O(e*O(n*o)),s=O(t*O(i*i)),a=i,c=O(i*Zd),u=s===e,l=s===X(-e),f=s===X(-e*Zd);return u&&(i=a),(l||f)&&(i=c),(X(i)&1n)===1n&&(i=X(-i)),{isValid:u||l,value:i}},gi=e=>Vd(ka(e)),l_=e=>{let t=Pa(e),n=t.slice(0,32);n[0]&=248,n[31]&=127,n[31]|=64;let r=t.slice(32),o=gi(n),i=At.multiply(o),s=i.toBytes();return{head:n,prefix:r,scalar:o,point:i,pointBytes:s}},Yd=e=>Oa("sha512Async",Qe(e,Zr,"secretKey")).then(l_);var Qd=e=>Yd(e).then(t=>t.pointBytes);var ep=async e=>e[1](await Oa("sha512Async",e[0]));var f_=(e,t,n)=>{let{pointBytes:r,scalar:o}=e,i=gi(t),s=At.multiply(i).toBytes();return[Fr(s,r,n),u=>{let l=Vd(i+gi(u)*o);return Qe(Fr(s,Xd(l)),64)}]},tp=async(e,t)=>{let n=Pa(e,"message"),r=await Yd(t);return ep(f_(r,await Oa("sha512Async",r.prefix,n),n))};var d_=e=>{if(e===null||typeof e!="object")throw new TypeError("expected valid options object");return e.zip215??!0},p_=(e,t,n,r)=>{e=Qe(e,64,"signature"),t=Qe(t,void 0,"message"),n=Qe(n,Zr,"publicKey");let o=d_(r),i=e.subarray(0,Zr),s=ka(e.subarray(Zr,64)),a,c,u,l=Uint8Array.of(),f=!1;try{a=ft.fromBytes(n,o),c=ft.fromBytes(i,o),u=At.multiply(s,!1),l=Fr(i,n,t),f=!0}catch{}return[l,m=>{if(!f||!o&&a.isSmallOrder())return!1;let w=gi(m);return c.add(a.multiply(w,!1)).subtract(u).clearCofactor().is0()}]},np=async(e,t,n,r={})=>ep(p_(e,t,n,r));var Ia={sha512Async:async e=>{let t=globalThis?.crypto?.subtle;if(!t)throw new Error("crypto.subtle must be defined, consider polyfill");return new Uint8Array(await t.digest("SHA-512",Fr(e)))},sha512:void 0};var h_=()=>{let e=[],t=At,n;for(let r=0;r<33;r++){n=t,e.push(n);for(let o=1;o<128;o++)n=n.add(t),e.push(n);t=n.double()}return e},Fd,Hd=(e,t)=>{let n=t.negate();return e?n:t},m_=e=>{let t=Fd||(Fd=h_()),n=Yt,r=At;for(let o=0;o<33;o++){let i=Number(e&255n);e>>=8n,i>128&&(i-=256,e+=1n);let s=o*128,a=s+Math.abs(i)-1,c=o%2!==0,u=i<0;i===0?r=r.add(Hd(c,t[s])):n=n.add(Hd(u,t[a]))}if(e!==0n)throw new Error("invalid wnaf");return{p:n,f:r}};Ia.sha512Async=Nd;var Qt="pk:sha2-256+ed25519",za=0,yi=class{async register(t,n){if(t!==Qt)throw new Error(`Unsupported channel attestation method: ${t}`);let r=await this.channelToPrivateKey(n);return await this.channelPublicIdFromPrivateKey(r)}async getMethod(t){if(t[0]===za)return Qt;throw new Error("Unrecognized channel attestation method.")}async channelToPrivateKey(t){let n=new TextEncoder().encode(t);return await Wt(n)}async channelPublicIdFromPrivateKey(t){let n=await Qd(t),r=new Uint8Array(n.length+1);return r[0]=za,r.set(n,1),r}async attest(t,n,r){if(t!==Qt)throw new Error(`Unsupported channel attestation method: ${t}`);let o=await this.channelToPrivateKey(r),i=await this.channelPublicIdFromPrivateKey(o),s=new TextEncoder().encode(n);return{attestation:await tp(s,o),channelPublicId:i}}async validate(t,n,r){let o=r[0];if(o!==za)throw new Error(`Unrecognized channel attestation method prefix: ${o}`);return await np(t,new TextEncoder().encode(n),r.slice(1))}};var Ca="hmac:sha2-256",rp=0,wi=class{async attest(t,n){if(t!==Ca)throw new Error(`Unsupported allowed attestation method: ${t}`);let r=Mt(),o=await Sa(Wt,r,new TextEncoder().encode(n)),i=new Uint8Array(r.length+3);return i[0]=rp,i[1]=jr,i[2]=Ln,i.set(r,3),{attestation:o,ticket:i}}async validate(t,n,r){let o=r[0],i=r[1],s=r[2];if(o!==rp||i!==jr||s!==Ln)throw new Error("Unrecognized allowed ticket format");let a=await Sa(Wt,r.slice(3),new TextEncoder().encode(n));return t.length!==a.length?!1:a.every((c,u)=>t[u]===c)}};var $a="did:web:",_i=class{constructor(t){this.services=t}services;actorToHandle=async t=>{let r=(await this.services.dids.resolve(t)).alsoKnownAs?.at(0);if(!r)throw new Q(`Handle for actor DID ${t} not found`);if(!r.startsWith($a))throw new Error(`Handle DID ${r} is not a valid handle`);let o=r.slice($a.length),i=await this.services.dids.resolve(r);if(!i.alsoKnownAs||!i.alsoKnownAs.includes(t))throw new Error(`Handle ${o} does not match actor ${t}`);return o};handleToActor=async t=>{let n=`${$a}${t}`,o=(await this.services.dids.resolve(n)).alsoKnownAs?.at(0);if(!o)throw new Q(`Actor for handle DID ${n} not found`);let i=await this.services.dids.resolve(o);if(!i.alsoKnownAs||!i.alsoKnownAs.includes(n))throw new Error(`Actor ${o} does not match handle ${t}`);return o}};function bi(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)r!=="__proto__"&&(e[r]=n[r])}return e}var g_={read:function(e){return e[0]==='"'&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};function Da(e,t){function n(o,i,s){if(!(typeof document>"u")){s=bi({},t,s),typeof s.expires=="number"&&(s.expires=new Date(Date.now()+s.expires*864e5)),s.expires&&(s.expires=s.expires.toUTCString()),o=encodeURIComponent(o).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var a="";for(var c in s)s[c]&&(a+="; "+c,s[c]!==!0&&(a+="="+s[c].split(";")[0]));return document.cookie=o+"="+e.write(i,o)+a}}function r(o){if(!(typeof document>"u"||arguments.length&&!o)){for(var i=document.cookie?document.cookie.split("; "):[],s={},a=0;a<i.length;a++){var c=i[a].split("="),u=c.slice(1).join("=");try{var l=decodeURIComponent(c[0]);if(l in s||(s[l]=e.read(u,l)),o===l)break}catch{}}return o?s[o]:s}}return Object.create({set:n,get:r,remove:function(o,i){n(o,"",bi({},i,{expires:-1}))},withAttributes:function(o){return Da(this.converter,bi({},this.attributes,o))},withConverter:function(o){return Da(bi({},this.converter,o),this.attributes)}},{attributes:{value:Object.freeze(t)},converter:{value:Object.freeze(e)}})}var xi=Da(g_,{path:"/"});var y_=365;function op(e,t){xi.set(e,t,sp())}function ip(e){return xi.get(e)}function Ua(e){xi.remove(e,sp())}function sp(){let e={expires:y_,path:"/",sameSite:"lax"};return typeof window<"u"&&window.location.protocol==="https:"&&(e.sameSite="none",e.secure=!0),e}var Ai="GraffitiInbox",Ti="GraffitiStorageBucket",Ba="#graffitiPersonalInbox",Pi="#graffitiStorageBucket",w_="#graffitiSharedInbox_",Ri=class{constructor(t){this.services=t;let n=new Promise(o=>{this.services.authorization.eventTarget.addEventListener("initialized",i=>{if(!(i instanceof CustomEvent))return;let s=Od.safeParse(i.detail);if(!s.success)return;let a=s.data?.error;a&&console.error(a),o()})});this.services.authorization.eventTarget.addEventListener("login",this.onLogin.bind(this)),this.services.authorization.eventTarget.addEventListener("logout",this.onLogout.bind(this));let r;if(typeof window<"u"){let o=new URLSearchParams(window.location.search).get("actor");if(o)try{let i=decodeURIComponent(o),s=new URL(window.location.toString());s.searchParams.delete("actor"),window.history.replaceState({},"",s.toString()),r=this.login(i)}catch(i){console.error("Error decoding actor:",i)}}(async()=>{await new Promise(i=>setTimeout(i,0)),await r;for(let i of this.loggedInSessions){let s=new CustomEvent("login",{detail:{session:{actor:i.actor}}});this.sessionEvents.dispatchEvent(s)}await n;let o=new CustomEvent("initialized");this.sessionEvents.dispatchEvent(o)})()}services;sessionEvents=new EventTarget;inProgressLogin=void 0;inProgressLogout=void 0;async login(t){try{await this.login_(t)}catch(n){let r=new CustomEvent("login",{detail:{error:n instanceof Error?n:new Error(String(n)),session:{actor:t}}});this.sessionEvents.dispatchEvent(r)}}async login_(t){if(this.loggedInSessions.find(x=>x.actor===t)){this.sessionEvents.dispatchEvent(new CustomEvent("login",{detail:{session:{actor:t}}}));return}let o=(await this.services.dids.resolve(t)).service;if(!o)throw new Error(`No services found in actor document for ${t}`);let i=o.find(x=>x.id===Pi&&x.type===Ti),s=o.find(x=>x.id===Ba&&x.type===Ai),a=o.filter(x=>x.id.match(new RegExp(`^${w_}\\d+$`))&&x.type===Ai);if(!s||!i||a.length===0)throw new Error(`Required services not found in actor document for ${t}`);let c=La(i),u=La(s),l=a.map(La),f=[{endpoint:c,type:"bucket"},{endpoint:u,type:"personal-inbox"},...l.map(x=>({endpoint:x,type:"shared-inbox"}))],d=await Promise.all(f.map(async({endpoint:x,type:E})=>{let A=await(E==="bucket"?this.services.storageBuckets.getAuthorizationEndpoint(x):this.services.inboxes.getAuthorizationEndpoint(x));return{endpoint:x,authorizationEndpoint:A,type:E}})),m=new Map;d.forEach(({authorizationEndpoint:x,endpoint:E,type:A})=>{m.has(x)||m.set(x,[]),m.get(x).push({endpoint:E,type:A})});let w=[...m.entries()],S={...{actor:t},tokens:[],servicesByAuthorization:w};typeof window<"u"?window.localStorage.setItem(Ei,JSON.stringify(S)):this.inProgressLogin=S;let[h,_]=w[0];await this.services.authorization.login(h,t,_.map(x=>x.endpoint))}async onLogin(t){if(!(t instanceof CustomEvent))return;let n=Td.safeParse(t.detail);if(!n.success)return;let r=n.data.loginId;try{await this.onLogin_(n.data)}catch(o){let i=new CustomEvent("login",{detail:{error:o instanceof Error?o:new Error(String(o)),session:{actor:r}}});this.sessionEvents.dispatchEvent(i)}}async onLogin_(t){if(t.error)throw t.error;let n=t.token,r=t.loginId,o;if(typeof window<"u"){let i=window.localStorage.getItem(Ei);if(!i)throw new Error("No in-progress login found");let s=JSON.parse(i);o=Na.parse(s)}else{if(!this.inProgressLogin)throw new Error("No in-progress login found");o=this.inProgressLogin}if(o.actor!==r)throw new Error("Actor mismatch in login response - concurrent logins?");if(o.tokens.push(n),o.tokens.length===o.servicesByAuthorization.length){typeof window>"u"?this.inProgressLogin=void 0:window.localStorage.removeItem(Ei);let i=o.servicesByAuthorization.flatMap(([u,l],f)=>l.map(d=>({token:o.tokens[f],serviceEndpoint:d.endpoint,authorizationEndpoint:u,type:d.type}))),s={...o,storageBucket:i.find(u=>u.type==="bucket"),personalInbox:i.find(u=>u.type==="personal-inbox"),sharedInboxes:i.filter(u=>u.type==="shared-inbox")},a=this.loggedInSessions;a.push(s),this.loggedInSessions=a;let c=new CustomEvent("login",{detail:{session:{actor:r}}});this.sessionEvents.dispatchEvent(c)}else{typeof window<"u"?window.localStorage.setItem(Ei,JSON.stringify(o)):this.inProgressLogin=o;let[i,s]=o.servicesByAuthorization[o.tokens.length];await this.services.authorization.login(i,r,s.map(a=>a.endpoint))}}async logout(t){try{await this.logout_(t)}catch(n){let r=new CustomEvent("logout",{detail:{error:n instanceof Kt?void 0:n instanceof Error?n:new Error(String(n)),actor:t}});this.sessionEvents.dispatchEvent(r)}}async logout_(t){let n=this.loggedInSessions.find(s=>s.actor===t);if(!n)throw new Error(`No session found for actor ${t}`);this.loggedInSessions=this.loggedInSessions.filter(s=>s.actor!==t);let r=n.tokens.pop();if(!r)throw new Error("No tokens found in session");typeof window<"u"?window.localStorage.setItem(vi,JSON.stringify(n)):this.inProgressLogout=n;let[o,i]=n.servicesByAuthorization[n.tokens.length];await this.services.authorization.logout(o,t,r)}async onLogout(t){if(!(t instanceof CustomEvent))return;let n=Pd.safeParse(t.detail);if(!n.success)return;let r=n.data.logoutId;try{await this.onLogout_(n.data)}catch(o){let i=new CustomEvent("logout",{detail:{error:o instanceof Error?o:new Error(String(o)),actor:r}});this.sessionEvents.dispatchEvent(i)}}async onLogout_(t){if(t.error)throw t.error;let n=t.logoutId,r;if(typeof window<"u"){let i=window.localStorage.getItem(vi);if(!i)throw new Error("No in-progress logout found");let s=JSON.parse(i);r=Na.parse(s)}else{if(!this.inProgressLogout)throw new Error("No in-progress logout found");r=this.inProgressLogout}if(r.actor!==n)throw new Error("Actor mismatch in logout response - concurrent logouts?");let o=r.tokens.pop();if(o){typeof window<"u"?window.localStorage.setItem(vi,JSON.stringify(r)):this.inProgressLogout=r;let[i,s]=r.servicesByAuthorization[r.tokens.length];await this.services.authorization.logout(i,n,o)}else{typeof window>"u"?this.inProgressLogout=void 0:window.localStorage.removeItem(vi);let i=new CustomEvent("logout",{detail:{actor:n}});this.sessionEvents.dispatchEvent(i)}}get loggedInSessions(){if(typeof window>"u")return ap;let t=ip(Si);if(!t)return[];let n;try{n=JSON.parse(t)}catch{return console.error("Error parsing stored session data"),Ua(Si),[]}let r=J(x_).safeParse(n);return r.success?r.data:(console.error("Stored session data is invalid"),Ua(Si),[])}set loggedInSessions(t){if(typeof window>"u"){ap=t;return}op(Si,JSON.stringify(t))}resolveSession(t){let n=this.loggedInSessions.find(r=>r.actor===t.actor);if(!n){let r=new CustomEvent("logout",{detail:{actor:t.actor}});throw this.sessionEvents.dispatchEvent(r),new Error("Not logged in")}return n}},ap=[],Ei="graffiti-login-in-progress",vi="graffiti-logout-in-progress",Si="graffiti-sessions-logged-in",__=xe({actor:F()}),Ma=xe({token:j(),serviceEndpoint:F(),authorizationEndpoint:F()}),b_=J(he([F(),J(xe({endpoint:F(),type:xu(["bucket","personal-inbox","shared-inbox"])}))])),Na=st(__,{tokens:J(j()),servicesByAuthorization:b_}),x_=st(Na,{storageBucket:Ma,personalInbox:Ma,sharedInboxes:J(Ma)});function La(e){if(typeof e.serviceEndpoint=="string")return e.serviceEndpoint;throw new Error(`Service endpoint for ${e.id} is not a string`)}var Oi=32*1024,ki=class{constructor(t){this.primitives=t}primitives;async encode(t,n){t=qa(t);let r=[...new Set(t.channels)],o=await Promise.all(r.map(b=>this.primitives.channelAttestations.attest(Qt,n,b))),i=o.map(b=>b.attestation),s=o.map(b=>b.channelPublicId),a={[Za]:t.value,[Fa]:i,[lp]:Mt(32)},c;if(Array.isArray(t.allowed)){let b=await Promise.all(t.allowed.map(async S=>this.primitives.allowedAttestations.attest(Ca,S)));a[Ha]=b.map(S=>S.attestation),c=b.map(S=>S.ticket)}let u=me(a);if(u.byteLength>Oi)throw new Error("The object is too large");let l=await this.primitives.contentAddresses.register(fi,u),f=await this.primitives.stringEncoder.encode(Mn,l),d=v_(n,f),m=[new TextEncoder().encode(d),...s];return{object:{value:t.value,channels:r,url:d,actor:n,...t.allowed?{allowed:t.allowed}:{}},tags:m,objectBytes:u,allowedTickets:c}}async validate(t,n,r,o){if(r.byteLength>Oi)throw new Error("Object is too big");let{actor:i,contentAddress:s}=Ja(t.url);if(i!==t.actor)throw new Error("Object actor does not match URL actor");let a=n.at(0);if(!a)throw new Error("No object URL tag");if(new TextDecoder().decode(a)!==t.url)throw new Error("Object URL tag does not match object URL");let c=n.slice(1),u=await this.primitives.stringEncoder.decode(s),l=await this.primitives.contentAddresses.getMethod(u),f=await this.primitives.contentAddresses.register(l,r);if(f.length!==u.length||!f.every((x,E)=>x===u[E]))throw new Error("Content address is invalid");let d=Ne(r),m=E_.parse(d),w=m[Za],b=m[Fa],S=m[Ha],h=me(w),_=me(t.value);if(h.length!==_.length||!h.every((x,E)=>x===_[E]))throw new Error("Object value does not match storage value");if(b.length!==c.length)throw new Error("Not as many channel attestations and public ids");for(let[x,E]of b.entries()){let A=c[x];if(!await this.primitives.channelAttestations.validate(E,i,A))throw new Error("Invalid channel attestation")}if(t.channels.length){if(t.channels.length!==c.length)throw new Error("Number of claimed channels does not match attestations/public IDs");let x=await this.primitives.channelAttestations.getMethod(c[0]),E=await Promise.all(t.channels.map(A=>this.primitives.channelAttestations.register(x,A)));for(let[A,k]of E.entries()){let I=c[A];if(k.length!==I.length||!k.every((U,V)=>U===I[V]))throw new Error("Channel public id does not match expected")}}if(o){if(!S)throw new Error("Object is public but thought to be private");let x,E,A;if("recipient"in o?(x=[o.recipient],E=[o.allowedTicket],A=S.filter((k,I)=>I===o.allowedIndex)):(x=[...t.allowed??[]],E=o.allowedTickets,A=S),x.length!==t.allowed?.length)throw new Error("Recipient count does not match object allowed list");if(!x.every(k=>t.allowed?.includes(k)))throw new Error("Recipient not in object allowed list");for(let[k,I]of x.entries()){let U=E.at(k),V=A.at(k);if(!U)throw new Error("Missing allowed ticket for recipient");if(!V)throw new Error("Missing allowed attestation for recipient");if(!await this.primitives.allowedAttestations.validate(V,I,U))throw new Error("Invalid allowed attestation for recipient")}}else if(S)throw new Error("Object is private but no recipient info provided")}},Za="v",Fa="c",Ha="a",lp="n",ja=Ut(e=>e instanceof Uint8Array),E_=Ee({[Za]:ve({}),[Fa]:J(ja),[Ha]:Y(J(ja)),[lp]:ja}),Ga="graffiti:";function cp(e){let t=e.replace(/:/g,"!").replace(/\//g,"~");return encodeURIComponent(t)}function up(e){return decodeURIComponent(e).replace(/!/g,":").replace(/~/g,"/")}function v_(e,t){return`${Ga}${cp(e)}:${cp(t)}`}function Ja(e){if(!e.startsWith(Ga))throw new Error("Invalid object URL");let n=e.slice(Ga.length).split(":");if(n.length!==2)throw new Error("Invalid object URL format");let[r,o]=n;return{actor:up(r),contentAddress:up(o)}}function qa(e){return e===void 0?null:Array.isArray(e)?e.map(qa):typeof e=="object"?Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0).map(([t,n])=>[t,qa(n)])):e}var fp=class{dialog=document.createElement("dialog");shadow;main_;useTemplateHTML;templates_;onManualClose;displayTemplateSeq=0;constructor(e){this.useTemplateHTML=e.useTemplateHTML,this.onManualClose=e.onManualClose,this.dialog.className="graffiti-modal",this.dialog.addEventListener("click",n=>{if("pointerType"in n&&!n.pointerType)return;let r=this.dialog.getBoundingClientRect();(r.top>n.clientY||r.left>n.clientX||n.clientY>r.top+r.height||n.clientX>r.left+r.width)&&(this.close(),this.onManualClose?.())});let t=document.createElement("div");this.shadow=t.attachShadow({mode:"closed"}),this.shadow.appendChild(this.dialog),document.body.append(t)}get templates(){return this.templates_||(this.main_,this.templates_=new Promise(async e=>e(await this.useTemplateHTML())).then(e=>{let t=new DOMParser().parseFromString(e,"text/html"),n=new Map;return t.querySelectorAll("template").forEach(r=>{let o=r.id;o&&n.set(o,r)}),n})),this.templates_}get main(){return this.main_||(this.templates_,this.main_=Promise.all([import("./style-BOBMBTYJ-2YZTO5FX.js"),import("./graffiti-KV3G3O72-QD3APAKT.js"),import("./rock-salt-LI7DAH66-M6W5PPFD.js")]).then(async([{default:e},{default:t},{default:n}])=>{let r=document.createElement("header"),o=document.createElement("button");o.className="secondary",o.textContent="Close",o?.addEventListener("click",()=>{this.close(),this.onManualClose?.()}),r.appendChild(o);let i=document.createElement("main");this.dialog.appendChild(r),this.dialog.appendChild(i);let s=new FontFace("Rock Salt",`url(${n})`,{style:"normal",weight:"400"});document.fonts.add(s),await s.load(),e=e.replace("url(graffiti.jpg)",`url(${t})`);let a=new CSSStyleSheet;return a.replace(e).then(()=>{this.shadow.adoptedStyleSheets=[a]}),i})),this.main_}async open(){await this.main,this.dialog.showModal(),this.dialog.focus()}close(){this.dialog.close()}async displayTemplate(e){let t=++this.displayTemplateSeq,n=()=>{if(t!==this.displayTemplateSeq)throw new Error(`displayTemplate(${e}) overridden by concurrent call`)},r=await this.main;n();let o=(await this.templates).get(e);if(n(),!o)throw new Error(`Template not found: ${e}`);let i=o.content.cloneNode(!0);return r.replaceChildren(i),r}};var hp=Ut(e=>e instanceof Uint8Array),Wa="k",Bn="t",Qa=Ee({[Wa]:j(),[Bn]:Y(j())}),en="id",Xa="e",Hr="a",S_=J(Ee({[en]:j(),[Xa]:Y(F()),[Hr]:Y(F())})),Ii="s",zi="n",A_=st(Qa,{[Ii]:Y(J(hp)),[zi]:S_}),Gr="a",Ya="i",R_=st(Qa,{[Gr]:hp,[Ya]:nn().check(Dt())}),T_=at([Qa,A_,R_]),P_=0,Ka=1,Rt=2,Va=3,O_=128,dp="graffiti-login-remembered-handle",Ci=class{dids=new Zo;authorization=new oi;storageBuckets=new si;inboxes=new ci;stringEncoder=new li;contentAddresses=new di;channelAttestations=new yi;allowedAttestations=new wi;sessions=new Ri({dids:this.dids,authorization:this.authorization,storageBuckets:this.storageBuckets,inboxes:this.inboxes});handles=new _i({dids:this.dids});objectEncoding=new ki({stringEncoder:this.stringEncoder,contentAddresses:this.contentAddresses,channelAttestations:this.channelAttestations,allowedAttestations:this.allowedAttestations});modal=typeof window>"u"?void 0:new fp({useTemplateHTML:()=>import("./login-dialog.html-E6VRKMXH.js").then(({template:t})=>t),onManualClose:()=>{let t=new CustomEvent("login",{detail:{error:new Error("User cancelled login"),manual:!0}});this.sessionEvents.dispatchEvent(t)}});defaultInboxEndpoints;identityCreatorEndpoint;constructor(t){this.defaultInboxEndpoints=t?.defaultInboxEndpoints??["https://graffiti.actor/i/shared"],this.identityCreatorEndpoint=t?.identityCreatorEndpoint??"https://graffiti.actor/create",this.sessionEvents.addEventListener("login",async n=>{if(!(n instanceof CustomEvent))return;let r=n.detail;if(r.error!==void 0){if("manual"in r&&r.manual)return;alert("Login failed: "+r.error.message);let s=r.session?.actor,a;if(s)try{a=await this.actorToHandle(s)}catch(c){console.error("Failed to handle actor:",c)}this.login_(a);return}let o=r.session.actor,i;try{i=await this.actorToHandle(o)}catch(s){console.error("Failed to load handle from actor:",s)}i&&await this.rememberHandleInPasswordManager(i,o)});for(let n of["post","get","delete","postMedia","getMedia","deleteMedia"]){let r=this[n];this[n]=async(...o)=>{try{return await r(...o)}catch(i){let s=o[o.length-1];throw await this.tryLogoutIfUnauthorized(i,s),i}}}}actorToHandle=this.handles.actorToHandle.bind(this.handles);handleToActor=this.handles.handleToActor.bind(this.handles);sessionEvents=this.sessions.sessionEvents;login=async t=>{try{let n;try{n=t?await this.actorToHandle(t):void 0}catch(r){console.error("Error fetching handle for actor:",r)}await this.login_(n)}catch(n){let r=new CustomEvent("login",{detail:{error:n instanceof Error?n:new Error(String(n))}});this.sessionEvents.dispatchEvent(r)}};async login_(t){if(typeof window<"u"){let n;if(t!==void 0){n=await this.modal?.displayTemplate("graffiti-login-handle");let o=n?.querySelector("#username"),i=t||await this.getRememberedHandleFromPasswordManager();o&&(o.value=i??""),o?.addEventListener("focus",()=>o?.select()),setTimeout(()=>o?.focus(),0),n?.querySelector("#graffiti-login-handle-form")?.addEventListener("submit",async s=>{s.preventDefault(),o?.setAttribute("disabled","true");let a=n?.querySelector("#graffiti-login-handle-submit");if(a?.setAttribute("disabled","true"),a&&(a.innerHTML="Logging in..."),!o?.value){alert("No handle provided"),this.login_("");return}let c=o.value;if(!c.includes(".")&&!c.startsWith("localhost")){let l=new URL(this.identityCreatorEndpoint).host;c=`${c}.${l}`}let u;try{u=await this.handleToActor(c)}catch{alert("Could not find an identity associated with that handle."),this.login_(c);return}try{await this.sessions.login(u)}catch(l){alert("Error logging in."),console.error(l),this.login_(c)}})}else n=await this.modal?.displayTemplate("graffiti-login-welcome"),n?.querySelector("#graffiti-login-existing")?.addEventListener("click",o=>{o.preventDefault(),this.login_("")}),setTimeout(()=>n?.querySelector("#graffiti-login-new")?.focus(),0);let r=new URL(this.identityCreatorEndpoint);r.searchParams.set("redirect_uri",encodeURIComponent(window.location.toString())),n?.querySelector("#graffiti-login-new")?.setAttribute("href",r.toString()),await this.modal?.open()}else{let n=await import("readline").catch(s=>{throw new Error("Unrecognized environment: neither window nor readline")});console.log("If you do not already have a Graffiti handle, you can create one here:"),console.log(this.identityCreatorEndpoint);let r=n.createInterface({input:process.stdin,output:process.stdout}),o=await new Promise(s=>{r.question(`Please enter your handle${t?` (default: ${t})`:""}: `,a=>{r.close(),s(a||t)})});if(!o)throw new Error("No handle provided");let i=await this.handleToActor(o);await this.sessions.login(i)}}async rememberHandleInPasswordManager(t,n){if(typeof window>"u")return;let r=window.navigator.credentials,o=window.PasswordCredential;if(!r?.store||!o){this.rememberHandleInBrowserStorage(t);return}try{let i=new o({id:t,password:"no-password",name:t});await r.store(i)}catch(i){console.error("Failed to remember handle in password manager:",i),this.rememberHandleInBrowserStorage(t)}}async getRememberedHandleFromPasswordManager(){if(typeof window>"u")return;let t=window.navigator.credentials,n=window.PasswordCredential;if(!t?.get||!n)return this.getRememberedHandleFromBrowserStorage();try{let r=await t.get({password:!0,mediation:"optional"});if(r&&"id"in r&&typeof r.id=="string")return r.id}catch(r){return console.error("Failed to load handle from password manager:",r),this.getRememberedHandleFromBrowserStorage()}}rememberHandleInBrowserStorage(t){if(!(typeof window>"u"))try{window.localStorage.setItem(dp,t)}catch(n){console.error("Failed to remember handle in browser storage:",n)}}getRememberedHandleFromBrowserStorage(){if(!(typeof window>"u"))try{return window.localStorage.getItem(dp)??void 0}catch(t){console.error("Failed to load handle from browser storage:",t);return}}logout=async t=>{await this.sessions.logout(t.actor)};post=async(...t)=>{let[n,r]=t,o=this.sessions.resolveSession(r),{object:i,tags:s,objectBytes:a,allowedTickets:c}=await this.objectEncoding.encode(n,r.actor),u=Mt(),l=await this.stringEncoder.encode(Mn,u);return await this.storageBuckets.put(o.storageBucket.serviceEndpoint,l,a,o.storageBucket.token),await this.announceObject(i,s,c,l,r),i};get=async(...t)=>{let[n,r,o]=t,i,s=await ro(r);if(o){let u=this.sessions.resolveSession(o);i=[u.personalInbox,...u.sharedInboxes]}else i=this.defaultInboxEndpoints.map(u=>({serviceEndpoint:u}));let a=es(n),c=[new TextEncoder().encode(a)];for(let u of i){let l,f=this.querySingleEndpoint(u.serviceEndpoint,{tags:c,objectSchema:{}},u.token,o?.actor);for await(let d of f)d.object.url===a&&(d.tombstone?l=void 0:l=d.object);if(l){if(!s(l))throw new to("Object exists but does not match the supplied schema");return l}}throw new Q("Object not found")};delete=async(t,n)=>{let r=this.sessions.resolveSession(n),o=es(t),{actor:i}=Ja(o);if(i!==n.actor)throw new ht("Cannot delete someone else's actor");let s=this.querySingleEndpoint(r.personalInbox.serviceEndpoint,{tags:[new TextEncoder().encode(o)],objectSchema:{}},r.personalInbox.token),a;for await(let w of s)w.object.url===o&&(w.tombstone?a=void 0:a=w);if(!a)throw new Q(`Object ${o} not found`);let{object:c,storageBucketKey:u,tags:l,allowedTickets:f,announcements:d,messageId:m}=a;return await this.storageBuckets.delete(r.storageBucket.serviceEndpoint,u,r.storageBucket.token),await this.announceObject(c,l,f,u,n,[...d??[],{[Hr]:n.actor,[en]:m}]),c};postMedia=async(...t)=>{let[n,r]=t,o=n.data.type,i=this.sessions.resolveSession(r),s=Mt(),a=await this.stringEncoder.encode(Mn,s);await this.storageBuckets.put(i.storageBucket.serviceEndpoint,a,new Uint8Array(await n.data.arrayBuffer()),i.storageBucket.token);let{url:c}=await this.post({value:{key:a,type:o,size:n.data.size},channels:[],allowed:n.allowed},r);return c};getMedia=async(...t)=>{let[n,r,o]=t;if(r?.maxBytes!==void 0&&(!Number.isSafeInteger(r.maxBytes)||r.maxBytes<0))throw new TypeError("maxBytes must be a nonnegative safe integer");let i=await this.get(n,k_,o),{key:s,type:a,size:c}=i.value;if(r?.maxBytes!==void 0&&c>r.maxBytes)throw new mt("File size exceeds limit");if(r?.types&&!Ru(a,r.types))throw new no(`Unacceptable media type, ${a}`);let l=(await this.dids.resolve(i.actor))?.service?.find(w=>w.id===Pi&&w.type===Ti);if(!l)throw new Q(`Actor ${i.actor} has no storage bucket service`);if(typeof l.serviceEndpoint!="string")throw new Q(`Actor ${i.actor} does not have a valid storage bucket endpoint`);let f=l.serviceEndpoint,d=await this.storageBuckets.get(f,s,c);return{data:new Blob([d.slice()],{type:a}),actor:i.actor,allowed:i.allowed}};deleteMedia=async(...t)=>{let[n,r]=t,o=this.sessions.resolveSession(r),i=await this.delete(n,r);if(!("key"in i.value&&typeof i.value.key=="string"))throw new Error("Deleted object was not media: "+JSON.stringify(i,null,2));await this.storageBuckets.delete(o.storageBucket.serviceEndpoint,i.value.key,o.storageBucket.token)};async*discoverMeta(t,n,r,o){let i=new Map,s;if(o){let f=this.sessions.resolveSession(o);s=[f.personalInbox,...f.sharedInboxes]}else s=this.defaultInboxEndpoints.map(f=>({serviceEndpoint:f}));for(let f in r)if(!s.some(d=>d.serviceEndpoint===f))throw new ht("Cursor does not match actor's inboxes");let a=await Promise.all(t.map(f=>this.channelAttestations.register(Qt,f))),c=s.map(f=>{let d=r[f.serviceEndpoint];return this.querySingleEndpoint(f.serviceEndpoint,d?{cursor:d}:{tags:a,objectSchema:n},f.token,o?.actor)}),u=c.map(async(f,d)=>pp(f,d)),l=u.length;try{for(;l>0;){let f=await Promise.race(u);if(f.error!==void 0)u[f.index]=new Promise(()=>{}),l--,yield{error:f.error,origin:s[f.index].serviceEndpoint},this.tryLogoutIfUnauthorized(f.error,o);else if(f.result.done){let d=s[f.index];r[d.serviceEndpoint]=f.result.value,u[f.index]=new Promise(()=>{}),l--}else{u[f.index]=pp(c[f.index],f.index);let{object:d,tombstone:m,tags:w}=f.result.value;if(m){if(i.get(d.url)===!0)continue;i.set(d.url,!0),yield{tombstone:m,object:{url:d.url}}}else{if(i.get(d.url)===!1)continue;let S=a.reduce((h,_,x)=>{for(let E of w)if(_.length===E.length&&_.every((A,k)=>E[k]===A)){h.push(x);break}return h},[]).map(h=>t[h]);S.length===0&&(yield{error:new Error("Inbox returned object without matching channels"),origin:s[f.index].serviceEndpoint}),i.set(d.url,!1),yield{object:{...d,channels:S}}}}}}catch(f){throw this.tryLogoutIfUnauthorized(f,o),f}finally{await Promise.all(c.map(async f=>{await f.return("")}))}return{cursor:JSON.stringify({channels:t,cursors:r})}}discover=(...t)=>{let[n,r,o]=t;return this.discoverMeta(n,r,{},o)};continueDiscover=(...t)=>{let[n,r]=t,o,i;try{let s=JSON.parse(n),a=I_.parse(s);o=a.channels,i=a.cursors}catch{return(async function*(){throw new Me("Invalid cursor")})()}return this.discoverMeta(o,{},i,r)};async tryLogoutIfUnauthorized(t,n){t instanceof Kt&&n&&await this.sessions.logout(n.actor)}async announceObject(t,n,r,o,i,s){let a=this.sessions.resolveSession(i),c={[Wa]:o},u=[],l=t.allowed;if(Array.isArray(l)){if(!r||r.length!==l.length)throw new Error("If allowed actors are specified, there must be a corresponding ticket for each allowed actor");let m=await Promise.allSettled(l.map(async(w,b)=>{let S=JSON.parse(JSON.stringify(t)),h=ts(S,[],w),x=(await this.dids.resolve(w)).service?.find(I=>I.type===Ai&&I.id===Ba);if(!x)throw new Error(`Recipient ${w} does not have a personal inbox`);if(typeof x.serviceEndpoint!="string")throw new Error(`Recipient ${w} does not have a valid personal inbox endpoint`);let E=s?s.find(I=>I[Hr]===w)?.[en]:void 0,A={...c,...E?{[Bn]:E}:{},[Gr]:r[b],[Ya]:b},k=await this.inboxes.send(x.serviceEndpoint,{[Nr]:n,[lt]:h,[Br]:me(A)});u.push({[en]:k,[Hr]:w})}));for(let[w,b]of m.entries())if(b.status==="rejected"){let S=l[w];console.error("Error sending to recipient:",S),console.error(b.reason)}}else{let m=JSON.parse(JSON.stringify(t)),w=ts(m,[]),b=a.sharedInboxes,S=await Promise.allSettled(b.map(async h=>{let _=s?s.find(A=>A[Xa]===h.serviceEndpoint)?.[en]:void 0,x={...c,..._?{[Bn]:_}:{}},E=await this.inboxes.send(h.serviceEndpoint,{..._?{[Bn]:_}:{},[Nr]:n,[lt]:w,[Br]:me(x)});u.push({[en]:E,[Xa]:h.serviceEndpoint})}));for(let[h,_]of S.entries())if(_.status==="rejected"){let x=b[h];console.error("Error sending to inbox:",x),console.error(_.reason)}}let f=s?s.find(m=>m[Hr]===i.actor)?.[en]:void 0,d={...c,...r?{[Ii]:r}:{},...f?{[Bn]:f}:{},[zi]:u};await this.inboxes.send(a.personalInbox.serviceEndpoint,{[Nr]:n,[lt]:t,[Br]:me(d)})}async*querySingleEndpoint(t,n,r,o){let i="tags"in n?this.inboxes.query(t,n.tags,n.objectSchema,r):this.inboxes.continueQuery(t,n.cursor,r),s=[],a=null;try{for(;;){for(;a===null&&s.length<O_;){let l=await i.next();if(l.done){a=l.value;break}let f=this.processOneLabeledMessage(t,l.value,r,o).catch(d=>{throw d});s.push(f)}let c=s.shift();if(!c){if(a!==null)return a;throw new Error("Process queue empty but no return value")}let u=await c;u&&(yield u)}}finally{await i.return("")}}async processOneLabeledMessage(t,n,r,o){let i=n.l;if(i!==Ka&&i!==P_&&i!==Rt)return;let s=n.id,{o:a,m:c,t:u}=n.m,l;try{let S=Ne(c);l=T_.parse(S)}catch{this.inboxes.label(t,s,Va,r);return}let{[Wa]:f,[Bn]:d}=l,m=Ii in l?l[Ii]:void 0,w=zi in l?l[zi]:void 0;if(i===Ka)return{messageId:s,object:a,storageBucketKey:f,allowedTickets:m,tags:u,announcements:w};if(i===Rt){if(!d)return;let S=await this.inboxes.get(t,d,r);return!S||S[Vt][lt].url!==a.url?void 0:(S[ui]!==Rt&&this.inboxes.label(t,d,Rt,r),{messageId:s,tombstone:!0,object:a,storageBucketKey:f,allowedTickets:m,tags:u,announcements:w})}let b;try{let S=a.actor,_=(await this.dids.resolve(S))?.service?.find(k=>k.id===Pi&&k.type===Ti);if(!_)throw new Q(`Actor ${S} has no storage bucket service`);if(typeof _.serviceEndpoint!="string")throw new Q(`Actor ${S} does not have a valid storage bucket endpoint`);let x=_.serviceEndpoint,E=await this.storageBuckets.get(x,f,Oi);if(Gr in l&&!o)throw new ht("Recipient is required when allowed ticket is present");let A=m?{allowedTickets:m}:Gr in l?{recipient:o??"null",allowedTicket:l[Gr],allowedIndex:l[Ya]}:void 0;await this.objectEncoding.validate(a,u,E,A)}catch(S){b=S}if(d){if(b instanceof Q)return this.inboxes.get(t,d,r).then(S=>{S&&S[Vt][lt].url===a.url&&S[ui]!==Rt&&this.inboxes.label(t,d,Rt,r),this.inboxes.label(t,s,Rt,r)}),{messageId:s,tombstone:!0,object:a,storageBucketKey:f,allowedTickets:m,tags:u,announcements:w};console.error("Recieved an incorrect tombstone object"),console.error(b),this.inboxes.label(t,s,Va,r)}else{if(b===void 0)return this.inboxes.label(t,s,Ka,r),{messageId:s,object:a,storageBucketKey:f,tags:u,allowedTickets:m,announcements:w};b instanceof Q?this.inboxes.label(t,s,Rt,r):(console.error("Recieved an incorrect object"),console.error(b),this.inboxes.label(t,s,Va,r))}}},k_={properties:{value:{properties:{type:{type:"string"},size:{type:"number"},key:{type:"string"}},required:["type","size","key"]}}},I_=Ee({cursors:bu(F(),j()),channels:J(j())});async function pp(e,t){try{return{index:t,result:await e.next()}}catch(n){if(n instanceof Me||n instanceof sn)throw n;return{index:t,error:n instanceof Error?n:new Error(String(n))}}}var mp=class extends eo{constructor(t){let n=new Ci(t);super(n)}};export{mp as GraffitiDecentralized};
|
|
11
11
|
/*! Bundled license information:
|
|
12
12
|
|
|
13
13
|
@noble/ed25519/index.js:
|