(function(re,V){typeof exports=="object"&&typeof module<"u"?V(exports):typeof define=="function"&&define.amd?define(["exports"],V):(re=typeof globalThis<"u"?globalThis:re||self,V(re["@digasystems/ipp-browser"]={}))})(this,function(re){"use strict";var Nt=Object.defineProperty;var Pt=(re,V,pe)=>V in re?Nt(re,V,{enumerable:!0,configurable:!0,writable:!0,value:pe}):re[V]=pe;var Be=(re,V,pe)=>(Pt(re,typeof V!="symbol"?V+"":V,pe),pe);var V={},pe={};pe.byteLength=ut,pe.toByteArray=pt,pe.fromByteArray=mt;for(var le=[],oe=[],at=typeof Uint8Array<"u"?Uint8Array:Array,Ce="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",_e=0,st=Ce.length;_e0)throw new Error("Invalid string. Length must be a multiple of 4");var h=c.indexOf("=");h===-1&&(h=m);var x=h===m?0:4-h%4;return[h,x]}function ut(c){var m=Ge(c),h=m[0],x=m[1];return(h+x)*3/4-x}function ct(c,m,h){return(m+h)*3/4-h}function pt(c){var m,h=Ge(c),x=h[0],w=h[1],j=new at(ct(c,x,w)),_=0,u=w>0?x-4:x,C;for(C=0;C>16&255,j[_++]=m>>8&255,j[_++]=m&255;return w===2&&(m=oe[c.charCodeAt(C)]<<2|oe[c.charCodeAt(C+1)]>>4,j[_++]=m&255),w===1&&(m=oe[c.charCodeAt(C)]<<10|oe[c.charCodeAt(C+1)]<<4|oe[c.charCodeAt(C+2)]>>2,j[_++]=m>>8&255,j[_++]=m&255),j}function lt(c){return le[c>>18&63]+le[c>>12&63]+le[c>>6&63]+le[c&63]}function dt(c,m,h){for(var x,w=[],j=m;ju?u:_+j));return x===1?(m=c[h-1],w.push(le[m>>2]+le[m<<4&63]+"==")):x===2&&(m=(c[h-2]<<8)+c[h-1],w.push(le[m>>10]+le[m>>4&63]+le[m<<2&63]+"=")),w.join("")}var Re={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */Re.read=function(c,m,h,x,w){var j,_,u=w*8-x-1,C=(1<>1,G=-7,M=h?w-1:0,ie=h?-1:1,W=c[m+M];for(M+=ie,j=W&(1<<-G)-1,W>>=-G,G+=u;G>0;j=j*256+c[m+M],M+=ie,G-=8);for(_=j&(1<<-G)-1,j>>=-G,G+=x;G>0;_=_*256+c[m+M],M+=ie,G-=8);if(j===0)j=1-Q;else{if(j===C)return _?NaN:(W?-1:1)*(1/0);_=_+Math.pow(2,x),j=j-Q}return(W?-1:1)*_*Math.pow(2,j-x)},Re.write=function(c,m,h,x,w,j){var _,u,C,Q=j*8-w-1,G=(1<>1,ie=w===23?Math.pow(2,-24)-Math.pow(2,-77):0,W=x?0:j-1,fe=x?1:-1,ce=m<0||m===0&&1/m<0?1:0;for(m=Math.abs(m),isNaN(m)||m===1/0?(u=isNaN(m)?1:0,_=G):(_=Math.floor(Math.log(m)/Math.LN2),m*(C=Math.pow(2,-_))<1&&(_--,C*=2),_+M>=1?m+=ie/C:m+=ie*Math.pow(2,1-M),m*C>=2&&(_++,C/=2),_+M>=G?(u=0,_=G):_+M>=1?(u=(m*C-1)*Math.pow(2,w),_=_+M):(u=m*Math.pow(2,M-1)*Math.pow(2,w),_=0));w>=8;c[h+W]=u&255,W+=fe,u/=256,w-=8);for(_=_<0;c[h+W]=_&255,W+=fe,_/=256,Q-=8);c[h+W-fe]|=ce*128};/*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh * @license MIT */(function(c){const m=pe,h=Re,x=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;c.Buffer=u,c.SlowBuffer=y,c.INSPECT_MAX_BYTES=50;const w=2147483647;c.kMaxLength=w,u.TYPED_ARRAY_SUPPORT=j(),!u.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function j(){try{const r=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(r,e),r.foo()===42}catch{return!1}}Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}});function _(r){if(r>w)throw new RangeError('The value "'+r+'" is invalid for option "size"');const e=new Uint8Array(r);return Object.setPrototypeOf(e,u.prototype),e}function u(r,e,t){if(typeof r=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return M(r)}return C(r,e,t)}u.poolSize=8192;function C(r,e,t){if(typeof r=="string")return ie(r,e);if(ArrayBuffer.isView(r))return fe(r);if(r==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(be(r,ArrayBuffer)||r&&be(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(be(r,SharedArrayBuffer)||r&&be(r.buffer,SharedArrayBuffer)))return ce(r,e,t);if(typeof r=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const i=r.valueOf&&r.valueOf();if(i!=null&&i!==r)return u.from(i,e,t);const s=he(r);if(s)return s;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return u.from(r[Symbol.toPrimitive]("string"),e,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}u.from=function(r,e,t){return C(r,e,t)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array);function Q(r){if(typeof r!="number")throw new TypeError('"size" argument must be of type number');if(r<0)throw new RangeError('The value "'+r+'" is invalid for option "size"')}function G(r,e,t){return Q(r),r<=0?_(r):e!==void 0?typeof t=="string"?_(r).fill(e,t):_(r).fill(e):_(r)}u.alloc=function(r,e,t){return G(r,e,t)};function M(r){return Q(r),_(r<0?0:F(r)|0)}u.allocUnsafe=function(r){return M(r)},u.allocUnsafeSlow=function(r){return M(r)};function ie(r,e){if((typeof e!="string"||e==="")&&(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const t=k(r,e)|0;let i=_(t);const s=i.write(r,e);return s!==t&&(i=i.slice(0,s)),i}function W(r){const e=r.length<0?0:F(r.length)|0,t=_(e);for(let i=0;i=w)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+w.toString(16)+" bytes");return r|0}function y(r){return+r!=r&&(r=0),u.alloc(+r)}u.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==u.prototype},u.compare=function(e,t){if(be(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),be(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(e)||!u.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let i=e.length,s=t.length;for(let l=0,f=Math.min(i,s);ls.length?(u.isBuffer(f)||(f=u.from(f)),f.copy(s,l)):Uint8Array.prototype.set.call(s,f,l);else if(u.isBuffer(f))f.copy(s,l);else throw new TypeError('"list" argument must be an Array of Buffers');l+=f.length}return s};function k(r,e){if(u.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||be(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof r);const t=r.length,i=arguments.length>2&&arguments[2]===!0;if(!i&&t===0)return 0;let s=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return ze(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return nt(r).length;default:if(s)return i?-1:ze(r).length;e=(""+e).toLowerCase(),s=!0}}u.byteLength=k;function T(r,e,t){let i=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,e>>>=0,t<=e))return"";for(r||(r="utf8");;)switch(r){case"hex":return Ut(this,e,t);case"utf8":case"utf-8":return Xe(this,e,t);case"ascii":return At(this,e,t);case"latin1":case"binary":return Ft(this,e,t);case"base64":return It(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return St(this,e,t);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),i=!0}}u.prototype._isBuffer=!0;function q(r,e,t){const i=r[e];r[e]=r[t],r[t]=i}u.prototype.swap16=function(){const e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;tt&&(e+=" ... "),""},x&&(u.prototype[x]=u.prototype.inspect),u.prototype.compare=function(e,t,i,s,l){if(be(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),!u.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(t===void 0&&(t=0),i===void 0&&(i=e?e.length:0),s===void 0&&(s=0),l===void 0&&(l=this.length),t<0||i>e.length||s<0||l>this.length)throw new RangeError("out of range index");if(s>=l&&t>=i)return 0;if(s>=l)return-1;if(t>=i)return 1;if(t>>>=0,i>>>=0,s>>>=0,l>>>=0,this===e)return 0;let f=l-s,S=i-t;const z=Math.min(f,S),N=this.slice(s,l),$=e.slice(t,i);for(let L=0;L2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,$e(t)&&(t=s?0:r.length-1),t<0&&(t=r.length+t),t>=r.length){if(s)return-1;t=r.length-1}else if(t<0)if(s)t=0;else return-1;if(typeof e=="string"&&(e=u.from(e,i)),u.isBuffer(e))return e.length===0?-1:ee(r,e,t,i,s);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?s?Uint8Array.prototype.indexOf.call(r,e,t):Uint8Array.prototype.lastIndexOf.call(r,e,t):ee(r,[e],t,i,s);throw new TypeError("val must be string, number or Buffer")}function ee(r,e,t,i,s){let l=1,f=r.length,S=e.length;if(i!==void 0&&(i=String(i).toLowerCase(),i==="ucs2"||i==="ucs-2"||i==="utf16le"||i==="utf-16le")){if(r.length<2||e.length<2)return-1;l=2,f/=2,S/=2,t/=2}function z($,L){return l===1?$[L]:$.readUInt16BE(L*l)}let N;if(s){let $=-1;for(N=t;Nf&&(t=f-S),N=t;N>=0;N--){let $=!0;for(let L=0;Ls&&(i=s)):i=s;const l=e.length;i>l/2&&(i=l/2);let f;for(f=0;f>>0,isFinite(i)?(i=i>>>0,s===void 0&&(s="utf8")):(s=i,i=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const l=this.length-t;if((i===void 0||i>l)&&(i=l),e.length>0&&(i<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");s||(s="utf8");let f=!1;for(;;)switch(s){case"hex":return ge(this,e,t,i);case"utf8":case"utf-8":return Pe(this,e,t,i);case"ascii":case"latin1":case"binary":return Se(this,e,t,i);case"base64":return Ie(this,e,t,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Et(this,e,t,i);default:if(f)throw new TypeError("Unknown encoding: "+s);s=(""+s).toLowerCase(),f=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function It(r,e,t){return e===0&&t===r.length?m.fromByteArray(r):m.fromByteArray(r.slice(e,t))}function Xe(r,e,t){t=Math.min(r.length,t);const i=[];let s=e;for(;s239?4:l>223?3:l>191?2:1;if(s+S<=t){let z,N,$,L;switch(S){case 1:l<128&&(f=l);break;case 2:z=r[s+1],(z&192)===128&&(L=(l&31)<<6|z&63,L>127&&(f=L));break;case 3:z=r[s+1],N=r[s+2],(z&192)===128&&(N&192)===128&&(L=(l&15)<<12|(z&63)<<6|N&63,L>2047&&(L<55296||L>57343)&&(f=L));break;case 4:z=r[s+1],N=r[s+2],$=r[s+3],(z&192)===128&&(N&192)===128&&($&192)===128&&(L=(l&15)<<18|(z&63)<<12|(N&63)<<6|$&63,L>65535&&L<1114112&&(f=L))}}f===null?(f=65533,S=1):f>65535&&(f-=65536,i.push(f>>>10&1023|55296),f=56320|f&1023),i.push(f),s+=S}return Tt(i)}const Ke=4096;function Tt(r){const e=r.length;if(e<=Ke)return String.fromCharCode.apply(String,r);let t="",i=0;for(;ii)&&(t=i);let s="";for(let l=e;li&&(e=i),t<0?(t+=i,t<0&&(t=0)):t>i&&(t=i),tt)throw new RangeError("Trying to access beyond buffer length")}u.prototype.readUintLE=u.prototype.readUIntLE=function(e,t,i){e=e>>>0,t=t>>>0,i||X(e,t,this.length);let s=this[e],l=1,f=0;for(;++f>>0,t=t>>>0,i||X(e,t,this.length);let s=this[e+--t],l=1;for(;t>0&&(l*=256);)s+=this[e+--t]*l;return s},u.prototype.readUint8=u.prototype.readUInt8=function(e,t){return e=e>>>0,t||X(e,1,this.length),this[e]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(e,t){return e=e>>>0,t||X(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(e,t){return e=e>>>0,t||X(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(e,t){return e=e>>>0,t||X(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(e,t){return e=e>>>0,t||X(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readBigUInt64LE=xe(function(e){e=e>>>0,ke(e,"offset");const t=this[e],i=this[e+7];(t===void 0||i===void 0)&&Te(e,this.length-8);const s=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,l=this[++e]+this[++e]*2**8+this[++e]*2**16+i*2**24;return BigInt(s)+(BigInt(l)<>>0,ke(e,"offset");const t=this[e],i=this[e+7];(t===void 0||i===void 0)&&Te(e,this.length-8);const s=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],l=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+i;return(BigInt(s)<>>0,t=t>>>0,i||X(e,t,this.length);let s=this[e],l=1,f=0;for(;++f=l&&(s-=Math.pow(2,8*t)),s},u.prototype.readIntBE=function(e,t,i){e=e>>>0,t=t>>>0,i||X(e,t,this.length);let s=t,l=1,f=this[e+--s];for(;s>0&&(l*=256);)f+=this[e+--s]*l;return l*=128,f>=l&&(f-=Math.pow(2,8*t)),f},u.prototype.readInt8=function(e,t){return e=e>>>0,t||X(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]},u.prototype.readInt16LE=function(e,t){e=e>>>0,t||X(e,2,this.length);const i=this[e]|this[e+1]<<8;return i&32768?i|4294901760:i},u.prototype.readInt16BE=function(e,t){e=e>>>0,t||X(e,2,this.length);const i=this[e+1]|this[e]<<8;return i&32768?i|4294901760:i},u.prototype.readInt32LE=function(e,t){return e=e>>>0,t||X(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},u.prototype.readInt32BE=function(e,t){return e=e>>>0,t||X(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readBigInt64LE=xe(function(e){e=e>>>0,ke(e,"offset");const t=this[e],i=this[e+7];(t===void 0||i===void 0)&&Te(e,this.length-8);const s=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(i<<24);return(BigInt(s)<>>0,ke(e,"offset");const t=this[e],i=this[e+7];(t===void 0||i===void 0)&&Te(e,this.length-8);const s=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(s)<>>0,t||X(e,4,this.length),h.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return e=e>>>0,t||X(e,4,this.length),h.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return e=e>>>0,t||X(e,8,this.length),h.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return e=e>>>0,t||X(e,8,this.length),h.read(this,e,!1,52,8)};function te(r,e,t,i,s,l){if(!u.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>s||er.length)throw new RangeError("Index out of range")}u.prototype.writeUintLE=u.prototype.writeUIntLE=function(e,t,i,s){if(e=+e,t=t>>>0,i=i>>>0,!s){const S=Math.pow(2,8*i)-1;te(this,e,t,i,S,0)}let l=1,f=0;for(this[t]=e&255;++f>>0,i=i>>>0,!s){const S=Math.pow(2,8*i)-1;te(this,e,t,i,S,0)}let l=i-1,f=1;for(this[t+l]=e&255;--l>=0&&(f*=256);)this[t+l]=e/f&255;return t+i},u.prototype.writeUint8=u.prototype.writeUInt8=function(e,t,i){return e=+e,t=t>>>0,i||te(this,e,t,1,255,0),this[t]=e&255,t+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(e,t,i){return e=+e,t=t>>>0,i||te(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(e,t,i){return e=+e,t=t>>>0,i||te(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(e,t,i){return e=+e,t=t>>>0,i||te(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(e,t,i){return e=+e,t=t>>>0,i||te(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function Ze(r,e,t,i,s){ot(e,i,s,r,t,7);let l=Number(e&BigInt(4294967295));r[t++]=l,l=l>>8,r[t++]=l,l=l>>8,r[t++]=l,l=l>>8,r[t++]=l;let f=Number(e>>BigInt(32)&BigInt(4294967295));return r[t++]=f,f=f>>8,r[t++]=f,f=f>>8,r[t++]=f,f=f>>8,r[t++]=f,t}function Qe(r,e,t,i,s){ot(e,i,s,r,t,7);let l=Number(e&BigInt(4294967295));r[t+7]=l,l=l>>8,r[t+6]=l,l=l>>8,r[t+5]=l,l=l>>8,r[t+4]=l;let f=Number(e>>BigInt(32)&BigInt(4294967295));return r[t+3]=f,f=f>>8,r[t+2]=f,f=f>>8,r[t+1]=f,f=f>>8,r[t]=f,t+8}u.prototype.writeBigUInt64LE=xe(function(e,t=0){return Ze(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeBigUInt64BE=xe(function(e,t=0){return Qe(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeIntLE=function(e,t,i,s){if(e=+e,t=t>>>0,!s){const z=Math.pow(2,8*i-1);te(this,e,t,i,z-1,-z)}let l=0,f=1,S=0;for(this[t]=e&255;++l>0)-S&255;return t+i},u.prototype.writeIntBE=function(e,t,i,s){if(e=+e,t=t>>>0,!s){const z=Math.pow(2,8*i-1);te(this,e,t,i,z-1,-z)}let l=i-1,f=1,S=0;for(this[t+l]=e&255;--l>=0&&(f*=256);)e<0&&S===0&&this[t+l+1]!==0&&(S=1),this[t+l]=(e/f>>0)-S&255;return t+i},u.prototype.writeInt8=function(e,t,i){return e=+e,t=t>>>0,i||te(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1},u.prototype.writeInt16LE=function(e,t,i){return e=+e,t=t>>>0,i||te(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2},u.prototype.writeInt16BE=function(e,t,i){return e=+e,t=t>>>0,i||te(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2},u.prototype.writeInt32LE=function(e,t,i){return e=+e,t=t>>>0,i||te(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},u.prototype.writeInt32BE=function(e,t,i){return e=+e,t=t>>>0,i||te(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4},u.prototype.writeBigInt64LE=xe(function(e,t=0){return Ze(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeBigInt64BE=xe(function(e,t=0){return Qe(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function et(r,e,t,i,s,l){if(t+i>r.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function tt(r,e,t,i,s){return e=+e,t=t>>>0,s||et(r,e,t,4),h.write(r,e,t,i,23,4),t+4}u.prototype.writeFloatLE=function(e,t,i){return tt(this,e,t,!0,i)},u.prototype.writeFloatBE=function(e,t,i){return tt(this,e,t,!1,i)};function rt(r,e,t,i,s){return e=+e,t=t>>>0,s||et(r,e,t,8),h.write(r,e,t,i,52,8),t+8}u.prototype.writeDoubleLE=function(e,t,i){return rt(this,e,t,!0,i)},u.prototype.writeDoubleBE=function(e,t,i){return rt(this,e,t,!1,i)},u.prototype.copy=function(e,t,i,s){if(!u.isBuffer(e))throw new TypeError("argument should be a Buffer");if(i||(i=0),!s&&s!==0&&(s=this.length),t>=e.length&&(t=e.length),t||(t=0),s>0&&s=this.length)throw new RangeError("Index out of range");if(s<0)throw new RangeError("sourceEnd out of bounds");s>this.length&&(s=this.length),e.length-t>>0,i=i===void 0?this.length:i>>>0,e||(e=0);let l;if(typeof e=="number")for(l=t;l2**32?s=it(String(t)):typeof t=="bigint"&&(s=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(s=it(s)),s+="n"),i+=` It must be ${e}. Received ${s}`,i},RangeError);function it(r){let e="",t=r.length;const i=r[0]==="-"?1:0;for(;t>=i+4;t-=3)e=`_${r.slice(t-3,t)}${e}`;return`${r.slice(0,t)}${e}`}function Jt(r,e,t){ke(e,"offset"),(r[e]===void 0||r[e+t]===void 0)&&Te(e,r.length-(t+1))}function ot(r,e,t,i,s,l){if(r>t||r3?e===0||e===BigInt(0)?S=`>= 0${f} and < 2${f} ** ${(l+1)*8}${f}`:S=`>= -(2${f} ** ${(l+1)*8-1}${f}) and < 2 ** ${(l+1)*8-1}${f}`:S=`>= ${e}${f} and <= ${t}${f}`,new je.ERR_OUT_OF_RANGE("value",S,r)}Jt(i,s,l)}function ke(r,e){if(typeof r!="number")throw new je.ERR_INVALID_ARG_TYPE(e,"number",r)}function Te(r,e,t){throw Math.floor(r)!==r?(ke(r,t),new je.ERR_OUT_OF_RANGE(t||"offset","an integer",r)):e<0?new je.ERR_BUFFER_OUT_OF_BOUNDS:new je.ERR_OUT_OF_RANGE(t||"offset",`>= ${t?1:0} and <= ${e}`,r)}const Ct=/[^+/0-9A-Za-z-_]/g;function Rt(r){if(r=r.split("=")[0],r=r.trim().replace(Ct,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function ze(r,e){e=e||1/0;let t;const i=r.length;let s=null;const l=[];for(let f=0;f55295&&t<57344){if(!s){if(t>56319){(e-=3)>-1&&l.push(239,191,189);continue}else if(f+1===i){(e-=3)>-1&&l.push(239,191,189);continue}s=t;continue}if(t<56320){(e-=3)>-1&&l.push(239,191,189),s=t;continue}t=(s-55296<<10|t-56320)+65536}else s&&(e-=3)>-1&&l.push(239,191,189);if(s=null,t<128){if((e-=1)<0)break;l.push(t)}else if(t<2048){if((e-=2)<0)break;l.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;l.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;l.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return l}function qt(r){const e=[];for(let t=0;t>8,s=t%256,l.push(s),l.push(i);return l}function nt(r){return m.toByteArray(Rt(r))}function Je(r,e,t,i){let s;for(s=0;s=e.length||s>=r.length);++s)e[s+t]=r[s];return s}function be(r,e){return r instanceof e||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===e.name}function $e(r){return r!==r}const Lt=function(){const r="0123456789abcdef",e=new Array(256);for(let t=0;t<16;++t){const i=t*16;for(let s=0;s<16;++s)e[i+s]=r[t]+r[s]}return e}();function xe(r){return typeof BigInt>"u"?Mt:r}function Mt(){throw new Error("BigInt not supported")}})(V);function ae(c){let m={};return c.forEach(function(h,x){m[h]=x}),m.lookup=c,m}function We(c,m){for(let h in m)m[h]&&m[h].constructor===Object?(c[h]=c[h]||{},We(c[h],m[h])):c[h]=m[h];return c}let P={"document-state":ae([,,,"pending",,"processing",,"canceled","aborted","completed"]),finishings:ae([,,,"none","staple","punch","cover","bind","saddle-stitch","edge-stitch","fold","trim","bale","booklet-maker","jog-offset",,,,,,"staple-top-left","staple-bottom-left","staple-top-right","staple-bottom-right","edge-stitch-left","edge-stitch-top","edge-stitch-right","edge-stitch-bottom","staple-dual-left","staple-dual-top","staple-dual-right","staple-dual-bottom",,,,,,,,,,,,,,,,,,,"bind-left","bind-top","bind-right","bind-bottom",,,,,,,"trim-after-pages","trim-after-documents","trim-after-copies","trim-after-job"]),"operations-supported":ae([,,"Print-Job","Print-URI","Validate-Job","Create-Job","Send-Document","Send-URI","Cancel-Job","Get-Job-Attributes","Get-Jobs","Get-Printer-Attributes","Hold-Job","Release-Job","Restart-Job",,"Pause-Printer","Resume-Printer","Purge-Jobs","Set-Printer-Attributes","Set-Job-Attributes","Get-Printer-Supported-Values","Create-Printer-Subscriptions","Create-Job-Subscription","Get-Subscription-Attributes","Get-Subscriptions","Renew-Subscription","Cancel-Subscription","Get-Notifications","ipp-indp-method","Get-Resource-Attributes","Get-Resource-Data","Get-Resources","ipp-install","Enable-Printer","Disable-Printer","Pause-Printer-After-Current-Job","Hold-New-Jobs","Release-Held-New-Jobs","Deactivate-Printer","Activate-Printer","Restart-Printer","Shutdown-Printer","Startup-Printer","Reprocess-Job","Cancel-Current-Job","Suspend-Current-Job","Resume-Job","Promote-Job","Schedule-Job-After",,"Cancel-Document","Get-Document-Attributes","Get-Documents","Delete-Document","Set-Document-Attributes","Cancel-Jobs","Cancel-My-Jobs","Resubmit-Job","Close-Job","Identify-Printer","Validate-Document"]),"job-collation-type":ae(["other","unknown","uncollated-documents","collated-documents","uncollated-documents"]),"job-state":ae([,,,"pending","pending-held","processing","processing-stopped","canceled","aborted","completed"]),"orientation-requested":ae([,,,"portrait","landscape","reverse-landscape","reverse-portrait","none"]),"print-quality":ae([,,,"draft","normal","high"]),"printer-state":ae([,,,"idle","processing","stopped"])};P["finishings-default"]=P.finishings,P["finishings-ready"]=P.finishings,P["finishings-supported"]=P.finishings,P["media-source-feed-orientation"]=P["orientation-requested"],P["orientation-requested-default"]=P["orientation-requested"],P["orientation-requested-supported"]=P["orientation-requested"],P["print-quality-default"]=P["print-quality"],P["print-quality-supported"]=P["print-quality"];let E=[];E[0]="successful-ok",E[1]="successful-ok-ignored-or-substituted-attributes",E[2]="successful-ok-conflicting-attributes",E[3]="successful-ok-ignored-subscriptions",E[4]="successful-ok-ignored-notifications",E[5]="successful-ok-too-many-events",E[6]="successful-ok-but-cancel-subscription",E[7]="successful-ok-events-complete",E[1024]="client-error-bad-request",E[1025]="client-error-forbidden",E[1026]="client-error-not-authenticated",E[1027]="client-error-not-authorized",E[1028]="client-error-not-possible",E[1029]="client-error-timeout",E[1030]="client-error-not-found",E[1031]="client-error-gone",E[1032]="client-error-request-entity-too-large",E[1033]="client-error-request-value-too-long",E[1034]="client-error-document-format-not-supported",E[1035]="client-error-attributes-or-values-not-supported",E[1036]="client-error-uri-scheme-not-supported",E[1037]="client-error-charset-not-supported",E[1038]="client-error-conflicting-attributes",E[1039]="client-error-compression-not-supported",E[1040]="client-error-compression-error",E[1041]="client-error-document-format-error",E[1042]="client-error-document-access-error",E[1043]="client-error-attributes-not-settable",E[1044]="client-error-ignored-all-subscriptions",E[1045]="client-error-too-many-subscriptions",E[1046]="client-error-ignored-all-notifications",E[1047]="client-error-client-print-support-file-not-found",E[1048]="client-error-document-password-error",E[1049]="client-error-document-permission-error",E[1050]="client-error-document-security-error",E[1051]="client-error-document-unprintable-error",E[1280]="server-error-internal-error",E[1281]="server-error-operation-not-supported",E[1282]="server-error-service-unavailable",E[1283]="server-error-version-not-supported",E[1284]="server-error-device-error",E[1285]="server-error-temporary-error",E[1286]="server-error-not-accepting-jobs",E[1287]="server-error-busy",E[1288]="server-error-job-canceled",E[1289]="server-error-multiple-document-jobs-not-supported",E[1290]="server-error-printer-is-deactivated",E[1291]="server-error-too-many-jobs",E[1292]="server-error-too-many-documents";const Ve=ae(E);let He=[,"operation-attributes-tag","job-attributes-tag","end-of-attributes-tag","printer-attributes-tag","unsupported-attributes-tag","subscription-attributes-tag","event-notification-attributes-tag","resource-attributes-tag","document-attributes-tag",,,,,,,"unsupported","default","unknown","no-value",,"not-settable","delete-attribute","admin-define",,,,,,,,,,"integer","boolean","enum",,,,,,,,,,,,,"octetString","dateTime","resolution","rangeOfInteger","begCollection","textWithLanguage","nameWithLanguage","endCollection",,,,,,,,,,"textWithoutLanguage","nameWithoutLanguage",,"keyword","uri","uriScheme","charset","naturalLanguage","mimeMediaType","memberAttrName"];He[127]="extension";const v=ae(He);let ft=P["operations-supported"],ht="";function bt(c){let m={},h=0,x="utf8";function w(){return c[h++]}function j(){let F=c.readInt16BE(h,!0);return h+=2,F}function _(){let F=c.readInt32BE(h,!0);return h+=4,F}function u(F,y){return F==0?"":c.toString(y||x,h,h+=F)}function C(){let F;for(;h=15;)G(F)}function G(F){let y=w();y===127&&(y=_());let k=u(j());F[k]=ie(y,k)}function M(){let F=c[h];return F!==74&&F!==55&&F!==3&&c[h+1]===0&&c[h+2]===0}function ie(F,y){let k=W(F,y);if(M()){k=[k];do F=w(),j(),k.push(W(F,y));while(M())}return k}function W(F,y){let k=j();switch(F){case v.enum:let T=_();return P[y]&&P[y].lookup[T]||T;case v.integer:return _();case v.boolean:return!!w();case v.rangeOfInteger:return[_(),_()];case v.resolution:return[_(),_(),w()===3?"dpi":"dpcm"];case v.dateTime:let q=new Date(j(),w(),w(),w(),w(),w(),w());return new Date(q.toISOString().substr(0,23).replace("T",",")+","+String.fromCharCode(u(1))+u(1)+":"+u(1));case v.textWithLanguage:case v.nameWithLanguage:let H=u(j()),ee=u(j());return H+ht+ee;case v.nameWithoutLanguage:case v.textWithoutLanguage:case v.octetString:case v.memberAttrName:return u(k);case v.keyword:case v.uri:case v.uriScheme:case v.charset:case v.naturalLanguage:case v.mimeMediaType:return u(k,"ascii");case v.begCollection:return u(k),fe();case v["no-value"]:}}function fe(){let F,y={};for(;(F=w())!==55;){if(F!==74){console.log("unexpected:",v.lookup[F]);return}u(j());let k=W(74),T=ce();y[k]=T}return u(j()),u(j()),y}function ce(F){let y=w();return y===127&&(y=_()),u(j()),ie(y,F)}m.version=w()+"."+w();let he=j();return(he>=2||he<=61)&&(m.operation=ft.lookup[he]),(he<=7||he>=1024)&&(m.statusCode=Ve.lookup[he]),m.id=_(),C(),hm.length&&(m=V.Buffer.concat([m],2*m.length))}let Q={"attributes-charset":1,"attributes-natural-language":2},G={"job-attributes-tag":["Job Template","Job Description"],"operation-attributes-tag":"Operation","printer-attributes-tag":"Printer Description","unsupported-attributes-tag":"","subscription-attributes-tag":"Subscription Description","event-notification-attributes-tag":"Event Notifications","resource-attributes-tag":"","document-attributes-tag":"Document Description"};function M(y){let k=c[y];if(!k)return;let T=Object.keys(k);y==v["operation-attributes-tag"]&&(T=T.sort(function(H,ee){return(Q[H]||3)-(Q[ee]||3)}));let q=G[y];x(v[y]),T.forEach(function(H){ie(q,H,k)})}function ie(y,k,T){let q=Array.isArray(y)?y.find(function(ge){return K[ge][k]}):y;if(!q)throw"Unknown attribute: "+k;let H=K[q][k],ee=T[k];Array.isArray(ee)||(ee=[ee]),ee.forEach(function(ge,Pe){let Se=Array.isArray(H)?fe(H,k,ge):H,Ie=W(Se,k,ge);Ie===v.enum&&(ge=P[k][ge]),x(Ie),Pe==0?u(k):w(0),ce(Ie,ge,Se.members)})}function W(y,k,T){let q=y.tag;if(!q){let H=!!~T.indexOf(_t);q=v[y.type+(H?"With":"Without")+"Language"]}return q}function fe(y,k,T){switch(y.alts){case"keyword,name":case"keyword,name,novalue":return T===null&&y.lookup.novalue?y.lookup.novalue:~a[k].indexOf(T)?y.lookup.keyword:y.lookup.name;case"integer,rangeOfInteger":return Array.isArray(T)?y.lookup.rangeOfInteger:y.lookup.integer;case"dateTime,novalue":return isNaN(Date.parse(T))?y.lookup.novalue:y.lookup.dateTime;case"integer,novalue":return isNaN(T)?y.lookup.novalue:y.lookup.integer;case"name,novalue":return T!==null?y.lookup.name:y.lookup.novalue;case"novalue,uri":return T!==null?y.lookup.uri:y.lookup.novalue;case"enumeration,unknown":return P[k][T]?y.lookup.enumeration:y.lookup.unknown;case"enumeration,novalue":return T!==null?y.lookup.enumeration:y.lookup.novalue;case"collection,novalue":return T!==null?y.lookup.enumeration:y.lookup.novalue}}function ce(y,k,T){switch(y){case v.enum:return w(4),j(k);case v.integer:return w(4),j(k);case v.boolean:return w(1),x(Number(k));case v.rangeOfInteger:w(8),j(k.min),j(k.max);return;case v.resolution:w(9),j(k[0]),j(k[1]),x(k[2]==="dpi"?3:4);return;case v.dateTime:w(11),w(k.getFullYear()),x(k.getMonth()+1),x(k.getDate()),x(k.getHours()),x(k.getMinutes()),x(k.getSeconds()),x(Math.floor(k.getMilliseconds()/100));let q=Bt(k);_(q[0]),x(q[1]),x(q[2]);return;case v.nameWithoutLanguage:case v.textWithoutLanguage:case v.octetString:case v.memberAttrName:return u(k);case v.keyword:case v.uri:case v.uriScheme:case v.charset:case v.naturalLanguage:case v.mimeMediaType:return u(k,"ascii");case v.begCollection:return w(0),he(k,T);case v["no-value"]:return w(0);default:return w(0)}}function he(y,k){Object.keys(y).forEach(function(T){let q=y[T],H=k[T];Array.isArray(H)&&(H=fe(H,T,q));let ee=W(H,T,q);ee===v.enum&&(q=P[T][q]),x(v.memberAttrName),w(0),ce(v.memberAttrName,T),x(ee),w(0),ce(ee,q,H.members)}),x(v.endCollection),w(0),w(0)}if(w(wt[c.version||"2.0"]),w(c.operation?vt[c.operation]:Ve[c.statusCode]),j(c.id||jt()),M("operation-attributes-tag"),M("job-attributes-tag"),M("printer-attributes-tag"),M("document-attributes-tag"),x(3),!c.data)return m.slice(0,h);if(!V.Buffer.isBuffer(c.data))throw"data must be a Buffer";let F=V.Buffer.alloc(h+c.data.length);return m.copy(F,0,0,h),c.data.copy(F,h,0),F}function Bt(c){let m=c.getTimezoneOffset();return[m>0?"-":"+",~~(Math.abs(m)/60),Math.abs(m)%60]}class Ue{constructor(m,h){Be(this,"url");Be(this,"version");Be(this,"uri");Be(this,"charset");Be(this,"language");if(!(this instanceof Ue))return new Ue(m,h);h=h||{},this.url=typeof m=="string"?new URL(m):m,this.version=h.version||"2.0",this.uri=h.uri||"ipp://"+this.url.host+this.url.pathname,this.charset=h.charset||"utf-8",this.language=h.language||"en-us"}_message(m,h){typeof m>"u"&&(m="Get-Printer-Attributes");const x={version:this.version,operation:m,id:null,"operation-attributes-tag":{"attributes-charset":this.charset,"attributes-natural-language":this.language,"printer-uri":this.uri}};return h&&h["operation-attributes-tag"]["job-id"]?x["operation-attributes-tag"]["job-id"]=h["operation-attributes-tag"]["job-id"]:h&&h["operation-attributes-tag"]["job-uri"]&&(x["operation-attributes-tag"]["job-uri"]=h["operation-attributes-tag"]["job-uri"]),h=We(x,h),h["operation-attributes-tag"]["job-uri"]&&delete h["operation-attributes-tag"]["printer-uri"],h}getHeaders(m){return{...m,"Content-Type":"application/ipp"}}encodeMsg(m,h){h=this._message(m,h);const x=kt(h);return console.log(x),x}}re.decodeResponse=gt,re.default=Ue,Object.defineProperties(re,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});