/* esm.sh - simple-cbor@0.4.1 */
var L=Object.create;var U=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var v=Object.getPrototypeOf,J=Object.prototype.hasOwnProperty;var p=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var T=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let f of q(e))!J.call(r,f)&&f!==t&&U(r,f,{get:()=>e[f],enumerable:!(n=D(e,f))||n.enumerable});return r};var W=(r,e,t)=>(t=r!=null?L(v(r)):{},T(e||!r||!r.__esModule?U(t,"default",{value:r,enumerable:!0}):t,r));var A=p(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0});var X=9007199254740992;function s(r,...e){let t=new Uint8Array(r.byteLength+e.reduce((f,u)=>f+u.byteLength,0));t.set(new Uint8Array(r),0);let n=r.byteLength;for(let f of e)t.set(new Uint8Array(f),n),n+=f.byteLength;return t.buffer}function a(r,e,t){t=t.replace(/[^0-9a-fA-F]/g,"");let n=2**(e-24);t=t.slice(-n*2).padStart(n*2,"0");let f=[(r<<5)+e].concat(t.match(/../g).map(u=>parseInt(u,16)));return new Uint8Array(f).buffer}function w(r,e){if(e<24)return new Uint8Array([(r<<5)+e]).buffer;{let t=e<=255?24:e<=65535?25:e<=4294967295?26:27;return a(r,t,e.toString(16))}}function I(r){let e=[];for(let t=0;t<r.length;t++){let n=r.charCodeAt(t);n<128?e.push(n):n<2048?e.push(192|n>>6,128|n&63):n<55296||n>=57344?e.push(224|n>>12,128|n>>6&63,128|n&63):(t++,n=(n&1023)<<10|r.charCodeAt(t)&1023,e.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|n&63))}return s(new Uint8Array(w(3,r.length)),new Uint8Array(e))}function G(r,e){if(r==14277111)return s(new Uint8Array([217,217,247]),e);if(r<24)return s(new Uint8Array([192+r]),e);{let t=r<=255?24:r<=65535?25:r<=4294967295?26:27,n=2**(t-24),f=r.toString(16).slice(-n*2).padStart(n*2,"0"),u=[192+t].concat(f.match(/../g).map(d=>parseInt(d,16)));return new Uint8Array(u).buffer}}i.tagged=G;function h(r){return new Uint8Array(r).buffer}i.raw=h;function g(r){if(isNaN(r))throw new RangeError("Invalid number.");r=Math.min(Math.max(0,r),23);let e=[0+r];return new Uint8Array(e).buffer}i.uSmall=g;function S(r,e){if(r=parseInt(""+r,e),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,r),255),r=r.toString(16),a(0,24,r)}i.u8=S;function E(r,e){if(r=parseInt(""+r,e),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,r),65535),r=r.toString(16),a(0,25,r)}i.u16=E;function N(r,e){if(r=parseInt(""+r,e),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,r),4294967295),r=r.toString(16),a(0,26,r)}i.u32=N;function _(r,e){if(typeof r=="string"&&e==16){if(r.match(/[^0-9a-fA-F]/))throw new RangeError("Invalid number.");return a(0,27,r)}if(r=parseInt(""+r,e),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,r),X),r=r.toString(16),a(0,27,r)}i.u64=_;function z(r){if(isNaN(r))throw new RangeError("Invalid number.");if(r===0)return g(0);r=Math.min(Math.max(0,-r),24)-1;let e=[32+r];return new Uint8Array(e).buffer}i.iSmall=z;function O(r,e){if(r=parseInt(""+r,e),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,-r-1),255),r=r.toString(16),a(1,24,r)}i.i8=O;function R(r,e){if(r=parseInt(""+r,e),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,-r-1),65535),r=r.toString(16),a(1,25,r)}i.i16=R;function F(r,e){if(r=parseInt(""+r,e),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,-r-1),4294967295),r=r.toString(16),a(1,26,r)}i.i32=F;function j(r,e){if(typeof r=="string"&&e==16){if(r.startsWith("-")?r=r.slice(1):r="0",r.match(/[^0-9a-fA-F]/)||r.length>16)throw new RangeError("Invalid number.");let t=!1,n=r.split("").reduceRight((f,u)=>{if(t)return u+f;let d=parseInt(u,16)-1;return d>=0?(t=!0,d.toString(16)+f):"f"+f},"");return t?a(1,27,n):_(0)}if(r=parseInt(""+r,e),isNaN(r))throw new RangeError("Invalid number.");return r=Math.min(Math.max(0,-r-1),9007199254740992),r=r.toString(16),a(1,27,r)}i.i64=j;function H(r){return r>=0?r<24?g(r):r<=255?S(r):r<=65535?E(r):r<=4294967295?N(r):_(r):r>=-24?z(r):r>=-255?O(r):r>=-65535?R(r):r>=-4294967295?F(r):j(r)}i.number=H;function K(r){return s(w(2,r.byteLength),r)}i.bytes=K;function Q(r){return I(r)}i.string=Q;function Y(r){return s(w(4,r.length),...r)}i.array=Y;function Z(r,e=!1){r instanceof Map||(r=new Map(Object.entries(r)));let t=Array.from(r.entries());return e&&(t=t.sort(([n],[f])=>n.localeCompare(f))),s(w(5,r.size),...t.map(([n,f])=>s(I(n),f)))}i.map=Z;function $(r){let e=new Float32Array([r]);return s(new Uint8Array([250]),new Uint8Array(e.buffer))}i.singleFloat=$;function k(r){let e=new Float64Array([r]);return s(new Uint8Array([251]),new Uint8Array(e.buffer))}i.doubleFloat=k;function rr(r){return r?C():P()}i.bool=rr;function C(){return h(new Uint8Array([245]))}i.true_=C;function P(){return h(new Uint8Array([244]))}i.false_=P;function er(){return h(new Uint8Array([246]))}i.null_=er;function tr(){return h(new Uint8Array([247]))}i.undefined_=tr});var V=p(l=>{"use strict";var nr=l&&l.__importStar||function(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t in r)Object.hasOwnProperty.call(r,t)&&(e[t]=r[t]);return e.default=r,e};Object.defineProperty(l,"__esModule",{value:!0});var o=nr(A()),fr=[ArrayBuffer,Uint8Array,Uint16Array,Uint32Array,Int8Array,Int16Array,Int32Array,Float32Array,Float64Array],y=class{constructor(e,t=!1){this._serializer=e,this._stable=t,this.name="jsonDefault",this.priority=-100}match(e){return["undefined","boolean","number","string","object"].indexOf(typeof e)!=-1}encode(e){switch(typeof e){case"undefined":return o.undefined_();case"boolean":return o.bool(e);case"number":return Math.floor(e)===e?o.number(e):o.doubleFloat(e);case"string":return o.string(e);case"object":if(e===null)return o.null_();if(Array.isArray(e))return o.array(e.map(t=>this._serializer.serializeValue(t)));if(fr.find(t=>e instanceof t))return o.bytes(e.buffer);if(Object.getOwnPropertyNames(e).indexOf("toJSON")!==-1)return this.encode(e.toJSON());if(e instanceof Map){let t=new Map;for(let[n,f]of e.entries())t.set(n,this._serializer.serializeValue(f));return o.map(t,this._stable)}else{let t=new Map;for(let[n,f]of Object.entries(e))t.set(n,this._serializer.serializeValue(f));return o.map(t,this._stable)}default:throw new Error("Invalid value.")}}};l.JsonDefaultCborEncoder=y;var b=class{constructor(){this.name="cborEncoder",this.priority=-90}match(e){return typeof e=="object"&&typeof e.toCBOR=="function"}encode(e){return e.toCBOR()}};l.ToCborEncoder=b;var x=class{constructor(){this._encoders=new Set}static withDefaultEncoders(e=!1){let t=new this;return t.addEncoder(new y(t,e)),t.addEncoder(new b),t}removeEncoder(e){for(let t of this._encoders.values())t.name==e&&this._encoders.delete(t)}addEncoder(e){this._encoders.add(e)}getEncoderFor(e){let t=null;for(let n of this._encoders)(!t||n.priority>t.priority)&&n.match(e)&&(t=n);if(t===null)throw new Error("Could not find an encoder for value.");return t}serializeValue(e){return this.getEncoderFor(e).encode(e)}serialize(e){return this.serializeValue(e)}};l.CborSerializer=x;var M=class extends x{serialize(e){return o.raw(new Uint8Array([...new Uint8Array([217,217,247]),...new Uint8Array(super.serializeValue(e))]))}};l.SelfDescribeCborSerializer=M});var B=p(c=>{"use strict";function ir(r){for(var e in r)c.hasOwnProperty(e)||(c[e]=r[e])}var ar=c&&c.__importStar||function(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t in r)Object.hasOwnProperty.call(r,t)&&(e[t]=r[t]);return e.default=r,e};Object.defineProperty(c,"__esModule",{value:!0});ir(V());var or=ar(A());c.value=or});var m=W(B()),{__esModule:hr,value:dr,JsonDefaultCborEncoder:wr,ToCborEncoder:yr,CborSerializer:br,SelfDescribeCborSerializer:xr}=m,mr=m.default??m;export{br as CborSerializer,wr as JsonDefaultCborEncoder,xr as SelfDescribeCborSerializer,yr as ToCborEncoder,hr as __esModule,mr as default,dr as value};
//# sourceMappingURL=simple-cbor.mjs.map