/* esm.sh - simple-cbor@0.5.0 */
var K=Object.create;var F=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var Y=Object.getOwnPropertyNames;var Z=Object.getPrototypeOf,$=Object.prototype.hasOwnProperty;var m=(r,e)=>()=>{try{return e||r((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}};var k=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let f of Y(e))!$.call(r,f)&&f!==t&&F(r,f,{get:()=>e[f],enumerable:!(n=Q(e,f))||n.enumerable});return r};var v=(r,e,t)=>(t=r!=null?K(Z(r)):{},k(e||!r||!r.__esModule?F(t,"default",{value:r,enumerable:!0}):t,r));var E=m(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0});var A=9007199254740992;function l(r,...e){let t=new Uint8Array(r.byteLength+e.reduce((f,o)=>f+o.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 u(r,e){let t=typeof r=="number"?Math.trunc(r):parseInt(r,e);if(!isFinite(t))throw new RangeError("Invalid number.");return t}function rr(r){return Object.prototype.toString.call(r)==="[object ArrayBuffer]"}function j(r,e){let t=new Uint8Array(r),n=new Uint8Array(e);for(let f=0;f<Math.min(t.length,n.length);f++)if(t[f]!==n[f])return t[f]-n[f];return t.length-n.length}var d=new Float32Array(1),er=new Uint32Array(d.buffer);function tr(r){if(d[0]=r,d[0]!==r)return null;let e=er[0],t=e>>>16&32768,n=e>>>23&255,f=e&8388607;if(n==255)return t|31744;if(n==0)return f==0?t:null;let o=n-127+15;if(o>=31)return null;if(o<=0){let y=14-o;if(y>24)return null;let z=f|8388608;return z&(1<<y)-1?null:t|z>>>y}return f&8191?null:t|o<<10|f>>>13}function s(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(o=>parseInt(o,16)));return new Uint8Array(f).buffer}function b(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 s(r,t,e.toString(16))}}function B(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 l(new Uint8Array(b(3,r.length)),new Uint8Array(e))}function nr(r,e){return r==14277111?l(new Uint8Array([217,217,247]),e):l(b(6,r),e)}i.tagged=nr;function x(r){return new Uint8Array(r).buffer}i.raw=x;function U(r){r=u(r),r=Math.min(Math.max(0,r),23);let e=[0+r];return new Uint8Array(e).buffer}i.uSmall=U;function C(r,e){return r=u(r,e),r=Math.min(Math.max(0,r),255),r=r.toString(16),s(0,24,r)}i.u8=C;function V(r,e){return r=u(r,e),r=Math.min(Math.max(0,r),65535),r=r.toString(16),s(0,25,r)}i.u16=V;function N(r,e){return r=u(r,e),r=Math.min(Math.max(0,r),4294967295),r=r.toString(16),s(0,26,r)}i.u32=N;function S(r,e){if(typeof r=="string"&&e==16){if(r.match(/[^0-9a-fA-F]/))throw new RangeError("Invalid number.");return s(0,27,r)}return r=u(r,e),r=Math.min(Math.max(0,r),A),r=r.toString(16),s(0,27,r)}i.u64=S;function D(r){if(r=u(r),r===0)return U(0);r=Math.min(Math.max(0,-r),24)-1;let e=[32+r];return new Uint8Array(e).buffer}i.iSmall=D;function P(r,e){return r=u(r,e),r=Math.min(Math.max(0,-r-1),255),r=r.toString(16),s(1,24,r)}i.i8=P;function R(r,e){return r=u(r,e),r=Math.min(Math.max(0,-r-1),65535),r=r.toString(16),s(1,25,r)}i.i16=R;function L(r,e){return r=u(r,e),r=Math.min(Math.max(0,-r-1),4294967295),r=r.toString(16),s(1,26,r)}i.i32=L;function q(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,o)=>{if(t)return o+f;let y=parseInt(o,16)-1;return y>=0?(t=!0,y.toString(16)+f):"f"+f},"");return t?s(1,27,n):S(0)}return r=u(r,e),r=Math.min(Math.max(0,-r-1),9007199254740992),r=r.toString(16),s(1,27,r)}i.i64=q;function fr(r){return!Number.isInteger(r)||Object.is(r,-0)||r>A||r<-A?M(r):r>=0?r<24?U(r):r<=255?C(r):r<=65535?V(r):r<=4294967295?N(r):S(r):r>=-24?D(r):r>=-255?P(r):r>=-65535?R(r):r>=-4294967295?L(r):q(r)}i.number=fr;function ir(r){return l(b(2,r.byteLength),r)}i.bytes=ir;function or(r){return B(r)}i.string=or;function sr(r){return l(b(4,r.length),...r)}i.array=sr;function ar(r,e=!1){let n=(r instanceof Map?Array.from(r.entries()):Array.isArray(r)?r:Object.entries(r)).map(([f,o])=>{if(typeof f=="string")return[B(f),o];if(rr(f))return[f,o];throw new TypeError("Invalid map key.")});if(e){n.sort(([f],[o])=>j(f,o));for(let f=1;f<n.length;f++)if(j(n[f-1][0],n[f][0])==0)throw new TypeError("Duplicate map key.")}return l(b(5,n.length),...n.map(([f,o])=>l(f,o)))}i.map=ar;function I(r){return new Uint8Array([249,r>>>8&255,r&255]).buffer}function J(r){let e=new ArrayBuffer(5),t=new DataView(e);return t.setUint8(0,250),t.setFloat32(1,r),e}i.singleFloat=J;function T(r){let e=new ArrayBuffer(9),t=new DataView(e);return t.setUint8(0,251),t.setFloat64(1,r),e}i.doubleFloat=T;function M(r){if(isNaN(r))return I(32256);let e=tr(r);return e!==null?I(e):(d[0]=r,d[0]===r?J(r):T(r))}i.float=M;function ur(r){return r?H():W()}i.bool=ur;function H(){return x(new Uint8Array([245]))}i.true_=H;function W(){return x(new Uint8Array([244]))}i.false_=W;function cr(){return x(new Uint8Array([246]))}i.null_=cr;function lr(){return x(new Uint8Array([247]))}i.undefined_=lr});var X=m(c=>{"use strict";var hr=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});var a=hr(E()),yr=[ArrayBuffer,Uint8Array,Uint16Array,Uint32Array,Int8Array,Int16Array,Int32Array,Float32Array,Float64Array],w=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 a.undefined_();case"boolean":return a.bool(e);case"number":return this._stable||Number.isInteger(e)?a.number(e):a.doubleFloat(e);case"string":return a.string(e);case"object":if(e===null)return a.null_();if(Array.isArray(e))return a.array(e.map(t=>this._serializer.serializeValue(t)));if(yr.find(t=>e instanceof t))return a.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(typeof n=="string"?n:this._serializer.serializeValue(n),this._serializer.serializeValue(f));return a.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 a.map(t,this._stable)}default:throw new Error("Invalid value.")}}};c.JsonDefaultCborEncoder=w;var _=class{constructor(){this.name="cborEncoder",this.priority=-90}match(e){return typeof e=="object"&&typeof e.toCBOR=="function"}encode(e){return e.toCBOR()}};c.ToCborEncoder=_;var p=class{constructor(){this._encoders=new Set}static withDefaultEncoders(e=!1){let t=new this;return t.addEncoder(new w(t,e)),t.addEncoder(new _),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)}};c.CborSerializer=p;var O=class extends p{serialize(e){return a.raw(new Uint8Array([...new Uint8Array([217,217,247]),...new Uint8Array(super.serializeValue(e))]))}};c.SelfDescribeCborSerializer=O});var G=m(h=>{"use strict";function dr(r){for(var e in r)h.hasOwnProperty(e)||(h[e]=r[e])}var br=h&&h.__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(h,"__esModule",{value:!0});dr(X());var xr=br(E());h.value=xr});var g=v(G()),{__esModule:mr,value:Ar,JsonDefaultCborEncoder:Mr,ToCborEncoder:Ur,CborSerializer:Sr,SelfDescribeCborSerializer:Er}=g,Or=g.default??g;export{Sr as CborSerializer,Mr as JsonDefaultCborEncoder,Er as SelfDescribeCborSerializer,Ur as ToCborEncoder,mr as __esModule,Or as default,Ar as value};
//# sourceMappingURL=simple-cbor.mjs.map