@moonpay/cli 0.11.1 → 0.12.0

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.
@@ -0,0 +1,50 @@
1
+ process.noDeprecation = true; import { createRequire as __createRequire } from "module"; const require = __createRequire(import.meta.url);
2
+ import{a as Fs,b as Bn,k as Q,l as Y,m as _T,n as Km}from"./chunk-RGIDTLVF.js";import{a as ST}from"./chunk-X4FGWJTX.js";import{fb as De}from"./chunk-OYYN2ANR.js";import{a as E,c as a,f as X}from"./chunk-LMDE72OE.js";var Gs=a((Vce,zm)=>{"use strict";var Vs=Object.defineProperty,DT=Object.getOwnPropertyDescriptor,OT=Object.getOwnPropertyNames,ET=Object.prototype.hasOwnProperty,CT=(t,e)=>{for(var r in e)Vs(t,r,{get:e[r],enumerable:!0})},AT=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of OT(e))!ET.call(t,n)&&n!==r&&Vs(t,n,{get:()=>e[n],enumerable:!(i=DT(e,n))||i.enumerable});return t},wT=t=>AT(Vs({},"__esModule",{value:!0}),t),$m={};CT($m,{Apdu:()=>ks});zm.exports=wT($m);var ks=class{cla;ins;p1;p2;data;constructor(e,r,i,n,o){this.cla=e,this.ins=r,this.p1=i,this.p2=n,this.data=o??new Uint8Array}getRawApdu(){let e=Uint8Array.from([this.cla,this.ins,this.p1,this.p2,this.data.length]),r=new Uint8Array(e.length+this.data.length);return r.set(e,0),this.data.length>0&&r.set(this.data,e.length),r}}});var jt=a((Gce,Xm)=>{"use strict";var Hs=Object.defineProperty,IT=Object.getOwnPropertyDescriptor,PT=Object.getOwnPropertyNames,xT=Object.prototype.hasOwnProperty,MT=(t,e)=>{for(var r in e)Hs(t,r,{get:e[r],enumerable:!0})},TT=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of PT(e))!xT.call(t,n)&&n!==r&&Hs(t,n,{get:()=>e[n],enumerable:!(i=IT(e,n))||i.enumerable});return t},jT=t=>TT(Hs({},"__esModule",{value:!0}),t),Jm={};MT(Jm,{bufferToHexaString:()=>NT,hexaStringToBuffer:()=>RT,isHexaString:()=>qT});Xm.exports=jT(Jm);function qT(t){return typeof t=="string"&&/^0x[0-9a-fA-F]*$/.test(t)}function RT(t){if(t.startsWith("0x")&&(t=t.slice(2)),t.length===0)return new Uint8Array;if(t.length%2!==0&&(t="0"+t),/^[0-9a-fA-F]*$/.test(t)===!1)return null;let e=t.match(/.{1,2}/g)?.map(r=>parseInt(r,16));return!e||e.some(isNaN)?null:new Uint8Array(e)}function NT(t,e=!0){return`${e?"0x":""}${Array.from(t,r=>r.toString(16).padStart(2,"0")).join("")}`}});var Js=a((Hce,Ym)=>{"use strict";var zs=Object.defineProperty,UT=Object.getOwnPropertyDescriptor,BT=Object.getOwnPropertyNames,LT=Object.prototype.hasOwnProperty,FT=(t,e)=>{for(var r in e)zs(t,r,{get:e[r],enumerable:!0})},kT=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of BT(e))!LT.call(t,n)&&n!==r&&zs(t,n,{get:()=>e[n],enumerable:!(i=UT(e,n))||i.enumerable});return t},VT=t=>kT(zs({},"__esModule",{value:!0}),t),Qm={};FT(Qm,{DataOverflowError:()=>Ks,HexaStringEncodeError:()=>$s,ValueOverflowError:()=>Ws});Ym.exports=VT(Qm);var GT=Oe(),Ws=class{_tag="ValueOverflow";originalError;message;constructor(e,r=GT.APDU_MAX_PAYLOAD){this.message=`Value overflow for ${e}, max is ${r}`}},Ks=class{_tag="DataOverflow";message;originalError;constructor(e,r=0){this.message=r===0?`this.data is already full (value: ${e})`:`this.data will overflow with "${e}", remaining bytes: ${r}`}},$s=class{_tag="HexaString";message;originalError;constructor(e){this.message=`Invalid encoded hexa string or length is null: ${e}`}}});var Ys=a((Wce,ty)=>{"use strict";var Qs=Object.defineProperty,HT=Object.getOwnPropertyDescriptor,WT=Object.getOwnPropertyNames,KT=Object.prototype.hasOwnProperty,$T=(t,e)=>{for(var r in e)Qs(t,r,{get:e[r],enumerable:!0})},zT=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of WT(e))!KT.call(t,n)&&n!==r&&Qs(t,n,{get:()=>e[n],enumerable:!(i=HT(e,n))||i.enumerable});return t},JT=t=>zT(Qs({},"__esModule",{value:!0}),t),ey={};$T(ey,{ByteArrayBuilder:()=>Xs});ty.exports=JT(ey);var Zm=jt(),ze=Js(),XT=4294967295,Xs=class{constructor(e=XT){this.maxPayloadSize=e}data=new Uint8Array;errors=[];build=()=>this.data;tryBuild=()=>this.hasErrors()?void 0:this.data;add8BitUIntToData=e=>this.addNumberToData(e,8n,!1,!1);add16BitUIntToData=(e,r=!0)=>this.addNumberToData(e,16n,!1,r);add32BitUIntToData=(e,r=!0)=>this.addNumberToData(e,32n,!1,r);add64BitUIntToData=(e,r=!0)=>this.addNumberToData(e,64n,!1,r);add128BitUIntToData=(e,r=!0)=>this.addNumberToData(e,128n,!1,r);add256BitUIntToData=(e,r=!0)=>this.addNumberToData(e,256n,!1,r);add16BitIntToData=(e,r=!0)=>this.addNumberToData(e,16n,!0,r);add32BitIntToData=(e,r=!0)=>this.addNumberToData(e,32n,!0,r);add64BitIntToData=(e,r=!0)=>this.addNumberToData(e,64n,!0,r);add128BitIntToData=(e,r=!0)=>this.addNumberToData(e,128n,!0,r);add256BitIntToData=(e,r=!0)=>this.addNumberToData(e,256n,!0,r);addBufferToData=e=>this.hasEnoughLengthRemaining(e)?(this.data=Uint8Array.from([...this.data,...e]),this):(this.errors.push(new ze.DataOverflowError(e.toString())),this);addHexaStringToData=e=>{let r=(0,Zm.hexaStringToBuffer)(e);return r===null||r.length===0?(this.errors.push(new ze.HexaStringEncodeError(e)),this):(this.addBufferToData(r),this)};addAsciiStringToData=e=>{let r=new TextEncoder().encode(e);return this.addBufferToData(r),this};encodeInLVFromHexa=e=>{let r=(0,Zm.hexaStringToBuffer)(e);return r===null||r.length===0?(this.errors.push(new ze.HexaStringEncodeError(e)),this):this.hasEnoughLengthRemaining(r,!0)?(this.add8BitUIntToData(r.length),this.addBufferToData(r),this):(this.errors.push(new ze.DataOverflowError(e)),this)};encodeInLVFromBuffer=e=>this.hasEnoughLengthRemaining(e,!0)?(this.add8BitUIntToData(e.length),this.addBufferToData(e),this):(this.errors.push(new ze.DataOverflowError(e.toString())),this);encodeInLVFromAscii=e=>this.hasEnoughLengthRemaining(e,!0)?(this.add8BitUIntToData(e.length),this.addAsciiStringToData(e),this):(this.errors.push(new ze.DataOverflowError(e)),this);encodeInTLVFromAscii=(e,r)=>(this.add8BitUIntToData(e),this.encodeInLVFromAscii(r));encodeInTLVFromHexa=(e,r)=>(this.add8BitUIntToData(e),this.encodeInLVFromHexa(r));encodeInTLVFromBuffer=(e,r)=>(this.add8BitUIntToData(e),this.encodeInLVFromBuffer(r));encodeInTLVFromUInt8=(e,r)=>(this.add8BitUIntToData(e),this.add8BitUIntToData(1),this.add8BitUIntToData(r));encodeInTLVFromUInt16=(e,r,i=!0)=>(this.add8BitUIntToData(e),this.add8BitUIntToData(2),this.add16BitUIntToData(r,i));encodeInTLVFromUInt32=(e,r,i=!0)=>(this.add8BitUIntToData(e),this.add8BitUIntToData(4),this.add32BitUIntToData(r,i));encodeInTLVFromUInt64=(e,r,i=!0)=>(this.add8BitUIntToData(e),this.add8BitUIntToData(8),this.add64BitUIntToData(r,i));getAvailablePayloadLength=()=>this.maxPayloadSize-this.data.length;getErrors=()=>this.errors;hasErrors=()=>this.errors.length!==0;hasEnoughLengthRemaining=(e,r=!1)=>this.data.length+e.length+(r?1:0)<=this.maxPayloadSize;addNumberToData(e,r,i,n){let o=this.checkBoundsAndConvert(e,r,i);if(o===void 0)return this;let s=Number(r)/8,l=new Uint8Array(s);if(n)for(let u=s-1;u>=0;u--)l[u]=Number(o&0xffn),o>>=8n;else for(let u=0;u<s;u++)l[u]=Number(o&0xffn),o>>=8n;return this.addBufferToData(l)}checkBoundsAndConvert(e,r,i){if(typeof e=="number"){if(!Number.isInteger(e)||e>Number.MAX_SAFE_INTEGER){this.errors.push(new ze.ValueOverflowError(e.toString()));return}e=BigInt(e)}if(i){let n=1n<<r-1n;if(e>=n||e<-n){this.errors.push(new ze.ValueOverflowError(e.toString(),n-1n));return}if(e<0n){let o=(1n<<r)-1n;e=-e,e=(~e&o)+1n}}else{let n=1n<<r;if(e<0||e>=n){this.errors.push(new ze.ValueOverflowError(e.toString(),n-1n));return}}return e}}});var Oe=a((Kce,ny)=>{"use strict";var ea=Object.defineProperty,QT=Object.getOwnPropertyDescriptor,YT=Object.getOwnPropertyNames,ZT=Object.prototype.hasOwnProperty,ej=(t,e)=>{for(var r in e)ea(t,r,{get:e[r],enumerable:!0})},tj=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of YT(e))!ZT.call(t,n)&&n!==r&&ea(t,n,{get:()=>e[n],enumerable:!(i=QT(e,n))||i.enumerable});return t},rj=t=>tj(ea({},"__esModule",{value:!0}),t),ry={};ej(ry,{APDU_MAX_PAYLOAD:()=>ta,APDU_MAX_SIZE:()=>sj,ApduBuilder:()=>Zs,HEADER_LENGTH:()=>oj});ny.exports=rj(ry);var nj=Gs(),ij=Ys(),oj=5,ta=255,sj=ta+5,Zs=class{_ins;_cla;_p1;p2;data=new ij.ByteArrayBuilder(ta);constructor({ins:e,cla:r,p1:i,p2:n}){this._cla=r&255,this._ins=e&255,this._p1=i&255,this.p2=n&255}build=()=>new nj.Apdu(this._cla,this._ins,this._p1,this.p2,this.data.build());add8BitUIntToData=e=>(this.data.add8BitUIntToData(e),this);add16BitUIntToData=e=>(this.data.add16BitUIntToData(e),this);add32BitUIntToData=e=>(this.data.add32BitUIntToData(e),this);addBufferToData=e=>(this.data.addBufferToData(e),this);addHexaStringToData=e=>(this.data.addHexaStringToData(e),this);addAsciiStringToData=e=>(this.data.addAsciiStringToData(e),this);encodeInLVFromHexa=e=>(this.data.encodeInLVFromHexa(e),this);encodeInLVFromBuffer=e=>(this.data.encodeInLVFromBuffer(e),this);encodeInLVFromAscii=e=>(this.data.encodeInLVFromAscii(e),this);getAvailablePayloadLength=()=>this.data.getAvailablePayloadLength();getErrors=()=>this.data.getErrors()}});var ia=a(($ce,oy)=>{"use strict";var na=Object.defineProperty,aj=Object.getOwnPropertyDescriptor,cj=Object.getOwnPropertyNames,uj=Object.prototype.hasOwnProperty,dj=(t,e)=>{for(var r in e)na(t,r,{get:e[r],enumerable:!0})},lj=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of cj(e))!uj.call(t,n)&&n!==r&&na(t,n,{get:()=>e[n],enumerable:!(i=aj(e,n))||i.enumerable});return t},pj=t=>lj(na({},"__esModule",{value:!0}),t),iy={};dj(iy,{ByteArrayParser:()=>ra});oy.exports=pj(iy);var fj=jt(),ra=class{constructor(e){this.buffer=e}index=0;testMinimalLength(e){return e<=this.buffer.length-this.index}extract8BitUInt(){if(!this.outOfRange(1))return this.buffer[this.index++]}extract16BitUInt(e=!0){let r=this.extractNumber(16n,!1,e);return r===void 0?void 0:Number(r)}extract16BitInt(e=!0){let r=this.extractNumber(16n,!0,e);return r===void 0?void 0:Number(r)}extract32BitUInt(e=!0){let r=this.extractNumber(32n,!1,e);return r===void 0?void 0:Number(r)}extract32BitInt(e=!0){let r=this.extractNumber(32n,!0,e);return r===void 0?void 0:Number(r)}extract64BitUInt(e=!0){return this.extractNumber(64n,!1,e)}extract64BitInt(e=!0){return this.extractNumber(64n,!0,e)}extract128BitUInt(e=!0){return this.extractNumber(128n,!1,e)}extract128BitInt(e=!0){return this.extractNumber(128n,!0,e)}extract256BitUInt(e=!0){return this.extractNumber(256n,!1,e)}extract256BitInt(e=!0){return this.extractNumber(256n,!0,e)}extractFieldByLength(e){if(this.outOfRange(e))return;if(e===0)return new Uint8Array;let r=this.buffer.slice(this.index,this.index+e);return this.index+=e,r}extractFieldLVEncoded(){let e=this.extract8BitUInt();if(e===void 0)return;if(e===0)return new Uint8Array;let r=this.extractFieldByLength(e);return r===void 0&&this.index--,r}extractFieldTLVEncoded(){if(this.outOfRange(2))return;let e=this.index,r=this.extract8BitUInt(),i=this.extractFieldLVEncoded();if(r===void 0||i===void 0){this.index--;return}let n=this.index;return{tag:r,value:i,tlv:this.buffer.slice(e,n)}}encodeToHexaString(e,r=!1){if(e===void 0||e.length===0)return"";let i=(0,fj.bufferToHexaString)(e);return r?i:i.slice(2)}encodeToString(e){let r="",i=0;if(!e)return r;for(;i<=e.length;){let n=e[i];n&&(r+=String.fromCharCode(n)),i++}return r}getCurrentIndex(){return this.index}resetIndex(){this.index=0}getUnparsedRemainingLength(){return this.buffer.length-this.index}outOfRange(e){return this.index+e>this.buffer.length}extractNumber(e,r,i){let n=Number(e)/8;if(this.outOfRange(n))return;let o=0n;if(i)for(let s=0;s<n;s++)o=o<<8n|BigInt(this.buffer[s+this.index]);else for(let s=n-1;s>=0;s--)o=o<<8n|BigInt(this.buffer[s+this.index]);if(r){let s=1n<<e-1n;o&s&&(o-=s<<1n)}return this.index+=n,o}}});var Ee=a((zce,ay)=>{"use strict";var sa=Object.defineProperty,vj=Object.getOwnPropertyDescriptor,gj=Object.getOwnPropertyNames,hj=Object.prototype.hasOwnProperty,mj=(t,e)=>{for(var r in e)sa(t,r,{get:e[r],enumerable:!0})},yj=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of gj(e))!hj.call(t,n)&&n!==r&&sa(t,n,{get:()=>e[n],enumerable:!(i=vj(e,n))||i.enumerable});return t},bj=t=>yj(sa({},"__esModule",{value:!0}),t),sy={};mj(sy,{ApduParser:()=>oa});ay.exports=bj(sy);var _j=ia(),oa=class{parser;constructor(e){this.parser=new _j.ByteArrayParser(e.data)}testMinimalLength=e=>this.parser.testMinimalLength(e);extract8BitUInt=()=>this.parser.extract8BitUInt();extract16BitUInt=()=>this.parser.extract16BitUInt();extract32BitUInt=()=>this.parser.extract32BitUInt();extractFieldByLength=e=>this.parser.extractFieldByLength(e);extractFieldLVEncoded=()=>this.parser.extractFieldLVEncoded();extractFieldTLVEncoded=()=>this.parser.extractFieldTLVEncoded();encodeToHexaString(e,r=!1){return r?this.parser.encodeToHexaString(e,!0):this.parser.encodeToHexaString(e,!1)}encodeToString=e=>this.parser.encodeToString(e);getUnparsedRemainingLength=()=>this.parser.getUnparsedRemainingLength()}});var Je=a((Jce,uy)=>{"use strict";var fa=Object.defineProperty,Sj=Object.getOwnPropertyDescriptor,Dj=Object.getOwnPropertyNames,Oj=Object.prototype.hasOwnProperty,Ej=(t,e)=>{for(var r in e)fa(t,r,{get:e[r],enumerable:!0})},Cj=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Dj(e))!Oj.call(t,n)&&n!==r&&fa(t,n,{get:()=>e[n],enumerable:!(i=Sj(e,n))||i.enumerable});return t},Aj=t=>Cj(fa({},"__esModule",{value:!0}),t),cy={};Ej(cy,{InvalidBatteryDataError:()=>ua,InvalidBatteryFlagsError:()=>da,InvalidBatteryStatusTypeError:()=>ca,InvalidGetFirmwareMetadataResponseError:()=>pa,InvalidResponseFormatError:()=>la,InvalidStatusWordError:()=>aa});uy.exports=Aj(cy);var aa=class{_tag="InvalidStatusWordError";originalError;constructor(e){this.originalError=new Error(e??"Invalid status word.")}},ca=class{_tag="InvalidBatteryStatusTypeError";originalError;constructor(e){this.originalError=new Error(e??"Invalid battery status type.")}},ua=class{_tag="InvalidBatteryDataError";originalError;constructor(e){this.originalError=new Error(e??"Invalid battery data.")}},da=class{_tag="InvalidBatteryFlagsError";originalError;constructor(e){this.originalError=new Error(e??"Invalid battery flags.")}},la=class{_tag="InvalidResponseFormatError";originalError;constructor(e){this.originalError=new Error(e??"Invalid response format.")}},pa=class{_tag="InvalidGetFirmwareMetadataResponseError";originalError;constructor(e){this.originalError=new Error(e??"Invalid Firmware Metadata response error.")}}});var w=a((Xce,py)=>{"use strict";var va=Object.defineProperty,wj=Object.getOwnPropertyDescriptor,Ij=Object.getOwnPropertyNames,Pj=Object.prototype.hasOwnProperty,xj=(t,e)=>{for(var r in e)va(t,r,{get:e[r],enumerable:!0})},Mj=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ij(e))!Pj.call(t,n)&&n!==r&&va(t,n,{get:()=>e[n],enumerable:!(i=wj(e,n))||i.enumerable});return t},Tj=t=>Mj(va({},"__esModule",{value:!0}),t),dy={};xj(dy,{CommandResultFactory:()=>jj,CommandResultStatus:()=>ly,isSuccessCommandResult:()=>qj});py.exports=Tj(dy);var ly=(t=>(t.Error="ERROR",t.Success="SUCCESS",t))(ly||{});function jj({data:t,error:e}){return e?{status:"ERROR",error:e}:{status:"SUCCESS",data:t}}function qj(t){return t.status==="SUCCESS"}});var ye=a((Qce,vy)=>{"use strict";var ha=Object.defineProperty,Rj=Object.getOwnPropertyDescriptor,Nj=Object.getOwnPropertyNames,Uj=Object.prototype.hasOwnProperty,Bj=(t,e)=>{for(var r in e)ha(t,r,{get:e[r],enumerable:!0})},Lj=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Nj(e))!Uj.call(t,n)&&n!==r&&ha(t,n,{get:()=>e[n],enumerable:!(i=Rj(e,n))||i.enumerable});return t},Fj=t=>Lj(ha({},"__esModule",{value:!0}),t),fy={};Bj(fy,{CommandUtils:()=>ga});vy.exports=Fj(fy);var ga=class t{static isValidStatusCode(e){return e.length===2}static isSuccessResponse({statusCode:e}){return t.isValidStatusCode(e)?e[0]===144&&e[1]===0:!1}static isLockedDeviceResponse({statusCode:e}){return t.isValidStatusCode(e)?e[0]===85&&e[1]===21||e[0]===105&&e[1]===130||e[0]===83&&e[1]===3:!1}static isRefusedByUser({statusCode:e}){return t.isValidStatusCode(e)?e[0]===85&&e[1]===1||e[0]===105&&e[1]===133:!1}static isAppAlreadyInstalled({statusCode:e}){return t.isValidStatusCode(e)?e[0]===106&&e[1]===128||e[0]===106&&e[1]===129||e[0]===106&&e[1]===142||e[0]===106&&e[1]===143:!1}static isOutOfMemory({statusCode:e}){return t.isValidStatusCode(e)?e[0]===106&&e[1]===132||e[0]===106&&e[1]===133||e[0]===81&&e[1]===2||e[0]===81&&e[1]===3:!1}static isApduThatTriggersDisconnection(e){let r=new Map;return r.set("openApp",new Uint8Array([224,216,0,0])),r.set("closeApp",new Uint8Array([176,167,0,0])),Array.from(r.values()).some(i=>{for(let n=0;n<4;n++)if(i[n]!==e[n])return!1;return!0})}}});var Xe=a((Yce,hy)=>{"use strict";var _a=Object.defineProperty,kj=Object.getOwnPropertyDescriptor,Vj=Object.getOwnPropertyNames,Gj=Object.prototype.hasOwnProperty,Hj=(t,e)=>{for(var r in e)_a(t,r,{get:e[r],enumerable:!0})},Wj=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Vj(e))!Gj.call(t,n)&&n!==r&&_a(t,n,{get:()=>e[n],enumerable:!(i=kj(e,n))||i.enumerable});return t},Kj=t=>Wj(_a({},"__esModule",{value:!0}),t),gy={};Hj(gy,{DeviceBusyError:()=>ba,DeviceExchangeError:()=>ma,UnknownDeviceExchangeError:()=>ya});hy.exports=Kj(gy);var ma=class{_tag;originalError;errorCode;message;constructor({tag:e,errorCode:r,originalError:i,message:n}){this._tag=e,this.originalError=i,this.errorCode=r,this.message=n??"An error occured during device exchange."}},ya=class{_tag="UnknownDeviceExchangeError";originalError;message;constructor(e){this.originalError=e,this.message="Unexpected device exchange error happened."}},ba=class{_tag="DeviceBusyError";originalError;constructor(e){this.originalError=e??new Error("Device is busy, please try again later")}}});var ft=a((Zce,yy)=>{"use strict";var Sa=Object.defineProperty,$j=Object.getOwnPropertyDescriptor,zj=Object.getOwnPropertyNames,Jj=Object.prototype.hasOwnProperty,Xj=(t,e)=>{for(var r in e)Sa(t,r,{get:e[r],enumerable:!0})},Qj=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of zj(e))!Jj.call(t,n)&&n!==r&&Sa(t,n,{get:()=>e[n],enumerable:!(i=$j(e,n))||i.enumerable});return t},Yj=t=>Qj(Sa({},"__esModule",{value:!0}),t),my={};Xj(my,{isCommandErrorCode:()=>Zj});yy.exports=Yj(my);var Zj=(t,e)=>Object.keys(e).includes(t)});var Be=a((eue,Sy)=>{"use strict";var Ea=Object.defineProperty,eq=Object.getOwnPropertyDescriptor,tq=Object.getOwnPropertyNames,rq=Object.prototype.hasOwnProperty,nq=(t,e)=>{for(var r in e)Ea(t,r,{get:e[r],enumerable:!0})},iq=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of tq(e))!rq.call(t,n)&&n!==r&&Ea(t,n,{get:()=>e[n],enumerable:!(i=eq(e,n))||i.enumerable});return t},oq=t=>iq(Ea({},"__esModule",{value:!0}),t),by={};nq(by,{GLOBAL_ERRORS:()=>Da,GlobalCommandError:()=>Ln,GlobalCommandErrorHandler:()=>Oa});Sy.exports=oq(by);var sq=Ee(),_y=Xe(),aq=ft(),Ln=class extends _y.DeviceExchangeError{constructor(e){super({tag:"GlobalCommandError",...e})}},Da={5515:{message:"Device is locked.",tag:"DeviceLockedError"},5501:{message:"Action refused on device.",tag:"ActionRefusedError"},5502:{message:"Pin is not set",tag:"PinNotSetError"},5223:{message:"Device internal error",tag:"DeviceInternalError"},"6e00":{message:"CLA not supported",tag:"DeviceInternalError"},"6d00":{message:"INS not supported",tag:"DeviceInternalError"}},Oa=class{static handle(e){let r=new sq.ApduParser(e).encodeToHexaString(e.statusCode);return(0,aq.isCommandErrorCode)(r,Da)?new Ln({...Da[r],errorCode:r}):new _y.UnknownDeviceExchangeError({message:"UnknownError",errorCode:r})}}});var Fn=a((tue,Ey)=>{"use strict";var Aa=Object.defineProperty,cq=Object.getOwnPropertyDescriptor,uq=Object.getOwnPropertyNames,dq=Object.prototype.hasOwnProperty,lq=(t,e)=>{for(var r in e)Aa(t,r,{get:e[r],enumerable:!0})},pq=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of uq(e))!dq.call(t,n)&&n!==r&&Aa(t,n,{get:()=>e[n],enumerable:!(i=cq(e,n))||i.enumerable});return t},fq=t=>pq(Aa({},"__esModule",{value:!0}),t),Oy={};lq(Oy,{CloseAppCommand:()=>Ca});Ey.exports=fq(Oy);var vq=Oe(),Dy=w(),gq=ye(),hq=Be(),Ca=class{name="closeApp";args=void 0;triggersDisconnection=!0;getApdu(){let e={cla:176,ins:167,p1:0,p2:0};return new vq.ApduBuilder(e).build()}parseResponse(e){return gq.CommandUtils.isSuccessResponse(e)?(0,Dy.CommandResultFactory)({data:void 0}):(0,Dy.CommandResultFactory)({error:hq.GlobalCommandErrorHandler.handle(e)})}}});var jr=a((rue,Ay)=>{"use strict";var Ia=Object.defineProperty,mq=Object.getOwnPropertyDescriptor,yq=Object.getOwnPropertyNames,bq=Object.prototype.hasOwnProperty,_q=(t,e)=>{for(var r in e)Ia(t,r,{get:e[r],enumerable:!0})},Sq=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of yq(e))!bq.call(t,n)&&n!==r&&Ia(t,n,{get:()=>e[n],enumerable:!(i=mq(e,n))||i.enumerable});return t},Dq=t=>Sq(Ia({},"__esModule",{value:!0}),t),Cy={};_q(Cy,{GetAppAndVersionCommand:()=>wa});Ay.exports=Dq(Cy);var Oq=Oe(),Eq=Ee(),Cq=Je(),kn=w(),Aq=ye(),wq=Be(),wa=class{name="getAppAndVersion";args=void 0;getApdu(){let e={cla:176,ins:1,p1:0,p2:0};return new Oq.ApduBuilder(e).build()}parseResponse(e){if(!Aq.CommandUtils.isSuccessResponse(e))return(0,kn.CommandResultFactory)({error:wq.GlobalCommandErrorHandler.handle(e)});let r=new Eq.ApduParser(e);if(r.extract8BitUInt()!==1)return(0,kn.CommandResultFactory)({error:new Cq.InvalidResponseFormatError("getAppAndVersion: format not supported")});let i=r.encodeToString(r.extractFieldLVEncoded()),n=r.encodeToString(r.extractFieldLVEncoded());if(r.getUnparsedRemainingLength()===0)return(0,kn.CommandResultFactory)({data:{name:i,version:n}});let o=r.extractFieldLVEncoded();return(0,kn.CommandResultFactory)({data:{name:i,version:n,flags:o}})}}});var Ma=a((nue,Py)=>{"use strict";var xa=Object.defineProperty,Iq=Object.getOwnPropertyDescriptor,Pq=Object.getOwnPropertyNames,xq=Object.prototype.hasOwnProperty,Mq=(t,e)=>{for(var r in e)xa(t,r,{get:e[r],enumerable:!0})},Tq=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Pq(e))!xq.call(t,n)&&n!==r&&xa(t,n,{get:()=>e[n],enumerable:!(i=Iq(e,n))||i.enumerable});return t},jq=t=>Tq(xa({},"__esModule",{value:!0}),t),Iy={};Mq(Iy,{GetBackgroundImageSizeCommand:()=>Pa,GetBackgroundImageSizeCommandError:()=>Gn});Py.exports=jq(Iy);var qq=Oe(),Rq=Ee(),Nq=Je(),Vn=w(),Uq=ft(),Bq=ye(),Lq=Be(),Fq=Xe(),wy={"662e":{message:"Invalid state, no background image loaded."},"662f":{message:"Invalid state, device is in recovery mode."}},Gn=class extends Fq.DeviceExchangeError{constructor({message:e,errorCode:r}){super({message:e,errorCode:r,tag:"GetBackgroundImageSizeCommandError"})}},Pa=class{name="getBackgroundImageSize";getApdu(){let e={cla:224,ins:100,p1:0,p2:0};return new qq.ApduBuilder(e).build()}parseResponse(e){let r=new Rq.ApduParser(e);if(!Bq.CommandUtils.isSuccessResponse(e)){let n=r.encodeToHexaString(e.statusCode);return(0,Uq.isCommandErrorCode)(n,wy)?(0,Vn.CommandResultFactory)({error:new Gn({...wy[n],errorCode:n})}):(0,Vn.CommandResultFactory)({error:Lq.GlobalCommandErrorHandler.handle(e)})}let i=r.extract32BitUInt();return i===void 0?(0,Vn.CommandResultFactory)({error:new Nq.InvalidStatusWordError("Didn't receive any size")}):(0,Vn.CommandResultFactory)({data:i})}}});var qy=a((iue,jy)=>{"use strict";var ja=Object.defineProperty,kq=Object.getOwnPropertyDescriptor,Vq=Object.getOwnPropertyNames,Gq=Object.prototype.hasOwnProperty,Hq=(t,e)=>{for(var r in e)ja(t,r,{get:e[r],enumerable:!0})},Wq=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Vq(e))!Gq.call(t,n)&&n!==r&&ja(t,n,{get:()=>e[n],enumerable:!(i=kq(e,n))||i.enumerable});return t},Kq=t=>Wq(ja({},"__esModule",{value:!0}),t),xy={};Hq(xy,{BatteryStatusType:()=>My,ChargingMode:()=>Ty,GetBatteryStatusCommand:()=>Ta});jy.exports=Kq(xy);var $q=Oe(),zq=Ee(),qr=Je(),Qe=w(),My=(t=>(t[t.BATTERY_PERCENTAGE=0]="BATTERY_PERCENTAGE",t[t.BATTERY_VOLTAGE=1]="BATTERY_VOLTAGE",t[t.BATTERY_TEMPERATURE=2]="BATTERY_TEMPERATURE",t[t.BATTERY_CURRENT=3]="BATTERY_CURRENT",t[t.BATTERY_FLAGS=4]="BATTERY_FLAGS",t))(My||{}),Ty=(t=>(t[t.NONE=0]="NONE",t[t.USB=1]="USB",t[t.QI=2]="QI",t))(Ty||{}),Ta=class{name="getBatteryStatus";args;constructor(e){this.args=e}getApdu(){let e={cla:224,ins:16,p1:0,p2:this.args.statusType};return new $q.ApduBuilder(e).build()}parseResponse(e){let r=new zq.ApduParser(e);switch(this.args.statusType){case 0:{let i=r.extract8BitUInt();return i===void 0?(0,Qe.CommandResultFactory)({error:new qr.InvalidBatteryDataError("Cannot parse APDU response")}):(0,Qe.CommandResultFactory)({data:i>100?-1:i})}case 1:{let i=r.extract16BitUInt();return i===void 0?(0,Qe.CommandResultFactory)({error:new qr.InvalidBatteryDataError("Cannot parse APDU response")}):(0,Qe.CommandResultFactory)({data:i})}case 2:case 3:{let i=r.extract8BitUInt();return i===void 0?(0,Qe.CommandResultFactory)({error:new qr.InvalidBatteryDataError("Cannot parse APDU response")}):(0,Qe.CommandResultFactory)({data:i<<24>>24})}case 4:{let i=r.extract32BitUInt();if(i===void 0)return(0,Qe.CommandResultFactory)({error:new qr.InvalidBatteryDataError("Cannot parse APDU response")});let n=!!(i&8),o=!n&&!!(i&1);return(0,Qe.CommandResultFactory)({data:{charging:o?2:n?1:0,issueCharging:!!(i&16),issueTemperature:!!(i&32),issueBattery:!!(i&128)}})}default:return(0,Qe.CommandResultFactory)({error:new qr.InvalidBatteryStatusTypeError("One or some case(s) not covered")})}}}});var Ye=a((oue,Uy)=>{"use strict";var Ra=Object.defineProperty,Jq=Object.getOwnPropertyDescriptor,Xq=Object.getOwnPropertyNames,Qq=Object.prototype.hasOwnProperty,Yq=(t,e)=>{for(var r in e)Ra(t,r,{get:e[r],enumerable:!0})},Zq=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Xq(e))!Qq.call(t,n)&&n!==r&&Ra(t,n,{get:()=>e[n],enumerable:!(i=Jq(e,n))||i.enumerable});return t},eR=t=>Zq(Ra({},"__esModule",{value:!0}),t),Ry={};Yq(Ry,{DeviceModel:()=>qa,DeviceModelId:()=>Ny,LEDGER_VENDOR_ID:()=>tR});Uy.exports=eR(Ry);var Ny=(t=>(t.NANO_S="nanoS",t.NANO_SP="nanoSP",t.NANO_X="nanoX",t.STAX="stax",t.FLEX="flex",t.APEX="apexp",t))(Ny||{}),qa=class{id;model;name;constructor({id:e,model:r,name:i}){this.id=e,this.model=r,this.name=i}},tR=11415});var Fy=a((sue,Ly)=>{"use strict";var Ua=Object.defineProperty,rR=Object.getOwnPropertyDescriptor,nR=Object.getOwnPropertyNames,iR=Object.prototype.hasOwnProperty,oR=(t,e)=>{for(var r in e)Ua(t,r,{get:e[r],enumerable:!0})},sR=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of nR(e))!iR.call(t,n)&&n!==r&&Ua(t,n,{get:()=>e[n],enumerable:!(i=rR(e,n))||i.enumerable});return t},aR=t=>sR(Ua({},"__esModule",{value:!0}),t),By={};oR(By,{SecureElementFlagsParser:()=>Na});Ly.exports=aR(By);var Na=class{constructor(e){if(this.seFlags=e,this.seFlags.length!==4)throw new Error("Invalid secure element flags length")}generalDeviceState(){let e=this.seFlags[0]??0;return{isPinValidated:this._checkNthBitInByte(e,1),hasMcuSerialNumber:this._checkNthBitInByte(e,2),hasValidCertificate:this._checkNthBitInByte(e,3),isCustomAuthorityConnectionAllowed:this._checkNthBitInByte(e,4),isSecureConnectionAllowed:this._checkNthBitInByte(e,5),isOnboarded:this._checkNthBitInByte(e,6),isMcuCodeSigned:this._checkNthBitInByte(e,7),isInRecoveryMode:this._checkNthBitInByte(e,8)}}endorsementInformation(){throw new Error("Not implemented")}wordsInformation(){throw new Error("Not implemented")}onboardingStatus(){throw new Error("Not implemented")}_checkNthBitInByte(e,r){return(e>>8-r&1)===1}}});var qt=a((aue,Vy)=>{"use strict";var Fa=Object.defineProperty,cR=Object.getOwnPropertyDescriptor,uR=Object.getOwnPropertyNames,dR=Object.prototype.hasOwnProperty,lR=(t,e)=>{for(var r in e)Fa(t,r,{get:e[r],enumerable:!0})},pR=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of uR(e))!dR.call(t,n)&&n!==r&&Fa(t,n,{get:()=>e[n],enumerable:!(i=cR(e,n))||i.enumerable});return t},fR=t=>pR(Fa({},"__esModule",{value:!0}),t),ky={};lR(ky,{GetOsVersionCommand:()=>La});Vy.exports=fR(ky);var Ce=Bn(),vR=Oe(),gR=Ee(),hR=Je(),Ba=w(),mR=ye(),yR=Be(),je=Ye(),bR=Fy(),La=class{name="getOsVersion";args=void 0;getApdu(){let e={cla:224,ins:1,p1:0,p2:0};return new vR.ApduBuilder(e).build()}parseResponse(e,r){if(!mR.CommandUtils.isSuccessResponse(e))return(0,Ba.CommandResultFactory)({error:yR.GlobalCommandErrorHandler.handle(e)});let i=new gR.ApduParser(e),n=i.extract32BitUInt();if(n===void 0)return(0,Ba.CommandResultFactory)({error:new hR.InvalidStatusWordError("Missing target ID in OS version")});let o=i.encodeToString(i.extractFieldLVEncoded()),s=i.extractFieldLVEncoded()??new Uint8Array(0),l={...new bR.SecureElementFlagsParser(s).generalDeviceState()};o||(o="0.0.0",s=new Uint8Array);let u=(n&4026531840)!==805306368,d=o.includes("-osu"),c="",p="",v="",y="",oe,Se,pt,Tt;if(u){v=o,oe=n;let se=i.extractFieldLVEncoded();se&&(se.length>=5?(c=i.encodeToString(se),Se=parseInt(i.encodeToHexaString(i.extractFieldLVEncoded()),16)):Se=parseInt(i.encodeToHexaString(se),16))}else{if(c=o,Se=n,p=i.encodeToString(i.extractFieldLVEncoded()),this.isBootloaderVersionSupported(c,r)&&(v=i.encodeToString(i.extractFieldLVEncoded())),this.isHardwareVersionSupported(c,r)?y=i.encodeToHexaString(i.extractFieldLVEncoded()):y="00",this.isLocalizationSupported(c,r)){let se=i.extractFieldLVEncoded();se!==void 0&&(pt=parseInt(i.encodeToHexaString(se),16))}if(this.isRecoverSupported(c,r)){let se=i.extractFieldLVEncoded();se!==void 0&&(Tt=parseInt(i.encodeToHexaString(se),16))}}return(0,Ba.CommandResultFactory)({data:{isBootloader:u,isOsu:d,targetId:n,seTargetId:Se,mcuTargetId:oe,seVersion:c,seFlags:s,mcuSephVersion:p,mcuBootloaderVersion:v,hwVersion:y,langId:pt,recoverState:Tt,secureElementFlags:l}})}isBootloaderVersionSupported(e,r){let i=(0,Ce.coerce)(e)??"";switch(r){case je.DeviceModelId.NANO_S:case je.DeviceModelId.NANO_X:return(0,Ce.gte)(i,"2.0.0");default:return!0}}isHardwareVersionSupported(e,r){let i=(0,Ce.coerce)(e)??"";switch(r){case je.DeviceModelId.NANO_X:return(0,Ce.gte)(i,"2.0.0");default:return!1}}isLocalizationSupported(e,r){let i=(0,Ce.coerce)(e)??"";switch(r){case je.DeviceModelId.NANO_S:return!1;case je.DeviceModelId.NANO_SP:return(0,Ce.gte)(i,"1.1.0");case je.DeviceModelId.NANO_X:return(0,Ce.gte)(i,"2.1.0");default:return!0}}isRecoverSupported(e,r){let i=(0,Ce.coerce)(e)??"";switch(r){case je.DeviceModelId.NANO_S:return!1;case je.DeviceModelId.NANO_SP:return(0,Ce.gte)(i,"1.1.2");case je.DeviceModelId.NANO_X:return(0,Ce.gte)(i,"2.2.3");case je.DeviceModelId.STAX:return(0,Ce.gte)(i,"1.4.0");case je.DeviceModelId.FLEX:return(0,Ce.gte)(i,"1.0.1");default:return!0}}}});var Ga=a((cue,Wy)=>{"use strict";var Va=Object.defineProperty,_R=Object.getOwnPropertyDescriptor,SR=Object.getOwnPropertyNames,DR=Object.prototype.hasOwnProperty,OR=(t,e)=>{for(var r in e)Va(t,r,{get:e[r],enumerable:!0})},ER=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of SR(e))!DR.call(t,n)&&n!==r&&Va(t,n,{get:()=>e[n],enumerable:!(i=_R(e,n))||i.enumerable});return t},CR=t=>ER(Va({},"__esModule",{value:!0}),t),Hy={};OR(Hy,{ListAppsCommand:()=>ka,ListAppsCommandError:()=>Wn});Wy.exports=CR(Hy);var AR=Oe(),wR=Ee(),Hn=w(),IR=ft(),PR=ye(),xR=Be(),MR=Xe(),Gy={6624:{message:"Invalid state (List applications command must be sent)"}},Wn=class extends MR.DeviceExchangeError{constructor({message:e,errorCode:r}){super({message:e,errorCode:r,tag:"ListAppsCommandError"})}},ka=class{name="listApps";args;constructor(e={isContinue:!1}){this.args=e}getApdu(){let e={cla:224,ins:this.args.isContinue?223:222,p1:0,p2:0};return new AR.ApduBuilder(e).build()}parseResponse(e){let r=[],i=new wR.ApduParser(e);if(!PR.CommandUtils.isSuccessResponse(e)){let n=i.encodeToHexaString(e.statusCode);return(0,IR.isCommandErrorCode)(n,Gy)?(0,Hn.CommandResultFactory)({error:new Wn({...Gy[n],errorCode:n})}):(0,Hn.CommandResultFactory)({error:xR.GlobalCommandErrorHandler.handle(e)})}if(e.data.length<=0)return(0,Hn.CommandResultFactory)({data:[]});for(i.extract8BitUInt();i.getUnparsedRemainingLength()>0;){let n=i.extract8BitUInt(),o=i.extract16BitUInt();i.extract16BitUInt();let s=i.encodeToHexaString(i.extractFieldByLength(32)),l=i.encodeToHexaString(i.extractFieldByLength(32)),u=i.encodeToString(i.extractFieldLVEncoded());r.push({appEntryLength:n,appSizeInBlocks:o,appCodeHash:s,appFullHash:l,appName:u})}return(0,Hn.CommandResultFactory)({data:r})}}});var Jy=a((uue,zy)=>{"use strict";var Ka=Object.defineProperty,TR=Object.getOwnPropertyDescriptor,jR=Object.getOwnPropertyNames,qR=Object.prototype.hasOwnProperty,RR=(t,e)=>{for(var r in e)Ka(t,r,{get:e[r],enumerable:!0})},NR=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of jR(e))!qR.call(t,n)&&n!==r&&Ka(t,n,{get:()=>e[n],enumerable:!(i=TR(e,n))||i.enumerable});return t},UR=t=>NR(Ka({},"__esModule",{value:!0}),t),$y={};RR($y,{LoadCertificateCommand:()=>Wa,LoadCertificateCommandError:()=>Kn});zy.exports=UR($y);var BR=Oe(),LR=Ee(),Ha=w(),FR=ft(),kR=ye(),VR=Be(),GR=Xe(),Ky={"422f":{message:"Incorrect structure type"},4230:{message:"Incorrect certificate version"},4231:{message:"Incorrect certificate validity"},4232:{message:"Incorrect certificate validity index"},4233:{message:"Unknown signer key ID"},4234:{message:"Unknown signature algorithm"},4235:{message:"Unknown public key ID"},4236:{message:"Unknown public key usage"},4237:{message:"Incorrect elliptic curve ID"},4238:{message:"Incorrect signature algorithm associated to the public key"},4239:{message:"Unknown target device"},"422d":{message:"Unknown certificate tag"},3301:{message:"Failed to hash data"},"422e":{message:"expected_key_usage doesn't match certificate key usage"},5720:{message:"Failed to verify signature"},4118:{message:"trusted_name buffer is too small to contain the trusted name"},ffff:{message:"Cryptography-related error"}},Kn=class extends GR.DeviceExchangeError{constructor({message:e,errorCode:r}){super({tag:"ProvidePkiCertificateCommandError",message:e,errorCode:r})}},Wa=class{name="loadCertificate";args;triggersDisconnection=!1;constructor(e){this.args=e}getApdu(){let e={cla:176,ins:6,p1:this.args.keyUsage,p2:0};return new BR.ApduBuilder(e).addBufferToData(this.args.certificate).build()}parseResponse(e){if(kR.CommandUtils.isSuccessResponse(e))return(0,Ha.CommandResultFactory)({data:void 0});let r=new LR.ApduParser(e).encodeToHexaString(e.statusCode);return(0,FR.isCommandErrorCode)(r,Ky)?(0,Ha.CommandResultFactory)({error:new Kn({...Ky[r],errorCode:r})}):(0,Ha.CommandResultFactory)({error:VR.GlobalCommandErrorHandler.handle(e)})}}});var Xa=a((due,Yy)=>{"use strict";var Ja=Object.defineProperty,HR=Object.getOwnPropertyDescriptor,WR=Object.getOwnPropertyNames,KR=Object.prototype.hasOwnProperty,$R=(t,e)=>{for(var r in e)Ja(t,r,{get:e[r],enumerable:!0})},zR=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of WR(e))!KR.call(t,n)&&n!==r&&Ja(t,n,{get:()=>e[n],enumerable:!(i=HR(e,n))||i.enumerable});return t},JR=t=>zR(Ja({},"__esModule",{value:!0}),t),Qy={};$R(Qy,{OpenAppCommand:()=>za,OpenAppCommandError:()=>$n});Yy.exports=JR(Qy);var XR=Oe(),QR=Ee(),$a=w(),YR=ft(),ZR=ye(),eN=Be(),tN=Xe(),Xy={"670a":{message:"No app name provided"},6807:{message:"Unknown application name"}},$n=class extends tN.DeviceExchangeError{constructor({message:e,errorCode:r}){super({tag:"OpenAppCommandError",message:e,errorCode:r})}},za=class{name="openApp";args;triggersDisconnection=!0;constructor(e){this.args=e}getApdu(){let e={cla:224,ins:216,p1:0,p2:0};return new XR.ApduBuilder(e).addAsciiStringToData(this.args.appName).build()}parseResponse(e){if(ZR.CommandUtils.isSuccessResponse(e))return(0,$a.CommandResultFactory)({data:void 0});let r=new QR.ApduParser(e).encodeToHexaString(e.statusCode);return(0,YR.isCommandErrorCode)(r,Xy)?(0,$a.CommandResultFactory)({error:new $n({...Xy[r],errorCode:r})}):(0,$a.CommandResultFactory)({error:eN.GlobalCommandErrorHandler.handle(e)})}}});var zn=a((lue,tb)=>{"use strict";var Qa=Object.defineProperty,rN=Object.getOwnPropertyDescriptor,nN=Object.getOwnPropertyNames,iN=Object.prototype.hasOwnProperty,oN=(t,e)=>{for(var r in e)Qa(t,r,{get:e[r],enumerable:!0})},sN=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of nN(e))!iN.call(t,n)&&n!==r&&Qa(t,n,{get:()=>e[n],enumerable:!(i=rN(e,n))||i.enumerable});return t},aN=t=>sN(Qa({},"__esModule",{value:!0}),t),Zy={};oN(Zy,{DeviceStatus:()=>eb});tb.exports=aN(Zy);var eb=(t=>(t.LOCKED="LOCKED",t.BUSY="BUSY",t.CONNECTED="CONNECTED",t.NOT_CONNECTED="NOT CONNECTED",t))(eb||{})});var Za=a((pue,ib)=>{"use strict";var Ya=Object.defineProperty,cN=Object.getOwnPropertyDescriptor,uN=Object.getOwnPropertyNames,dN=Object.prototype.hasOwnProperty,lN=(t,e)=>{for(var r in e)Ya(t,r,{get:e[r],enumerable:!0})},pN=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of uN(e))!dN.call(t,n)&&n!==r&&Ya(t,n,{get:()=>e[n],enumerable:!(i=cN(e,n))||i.enumerable});return t},fN=t=>pN(Ya({},"__esModule",{value:!0}),t),rb={};lN(rb,{DeviceActionStatus:()=>nb});ib.exports=fN(rb);var nb=(t=>(t.NotStarted="not-started",t.Pending="pending",t.Stopped="stopped",t.Completed="completed",t.Error="error",t))(nb||{})});var Z=a((fue,ab)=>{"use strict";var ec=Object.defineProperty,vN=Object.getOwnPropertyDescriptor,gN=Object.getOwnPropertyNames,hN=Object.prototype.hasOwnProperty,mN=(t,e)=>{for(var r in e)ec(t,r,{get:e[r],enumerable:!0})},yN=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of gN(e))!hN.call(t,n)&&n!==r&&ec(t,n,{get:()=>e[n],enumerable:!(i=vN(e,n))||i.enumerable});return t},bN=t=>yN(ec({},"__esModule",{value:!0}),t),ob={};mN(ob,{UserInteractionRequired:()=>sb});ab.exports=bN(ob);var sb=(t=>(t.None="none",t.UnlockDevice="unlock-device",t.AllowSecureConnection="allow-secure-connection",t.ConfirmOpenApp="confirm-open-app",t.SignTransaction="sign-transaction",t.SignTypedData="sign-typed-data",t.AllowListApps="allow-list-apps",t.VerifyAddress="verify-address",t.SignPersonalMessage="sign-personal-message",t.SignDelegationAuthorization="sign-delegation-authorization",t.Web3ChecksOptIn="web3-checks-opt-in",t.VerifySafeAddress="verify-safe-address",t.RegisterWallet="register-wallet",t.ConfirmLoadImage="confirm-load-image",t.ConfirmCommitImage="confirm-commit-image",t.ConfirmRemoveImage="confirm-remove-image",t))(sb||{})});var Rt=a(ae=>{"use strict";Object.defineProperty(ae,"__esModule",{value:!0});ae.Nothing=ae.Just=ae.Maybe=void 0;var cb=Ur();ae.Maybe={of(t){return Le(t)},empty(){return k},zero(){return k},fromNullable(t){return t==null?k:Le(t)},fromFalsy(t){return t?Le(t):k},fromPredicate(t,e){switch(arguments.length){case 1:return r=>ae.Maybe.fromPredicate(t,r);default:return t(e)?Le(e):k}},mapMaybe(t,e){switch(arguments.length){case 1:return r=>ae.Maybe.mapMaybe(t,r);default:return ae.Maybe.catMaybes(e.map(t))}},catMaybes(t){let e=[];for(let r of t)r.isJust()&&e.push(r.extract());return e},encase(t){try{return Le(t())}catch{return k}},isMaybe(t){return t instanceof Rr||t instanceof Nr},sequence(t){let e=[];for(let r of t)if(r.isJust())e.push(r.extract());else return k;return Le(e)},"fantasy-land/of"(t){return this.of(t)},"fantasy-land/empty"(){return this.empty()},"fantasy-land/zero"(){return this.zero()}};var Rr=class{constructor(e){this.__value=e,this["fantasy-land/equals"]=this.equals,this["fantasy-land/map"]=this.map,this["fantasy-land/ap"]=this.ap,this["fantasy-land/alt"]=this.alt,this["fantasy-land/chain"]=this.chain,this["fantasy-land/reduce"]=this.reduce,this["fantasy-land/extend"]=this.extend,this["fantasy-land/filter"]=this.filter}isJust(){return!0}isNothing(){return!1}inspect(){return`Just(${this.__value})`}toString(){return this.inspect()}toJSON(){let e=this.__value;return e instanceof Date?e.toJSON():e}equals(e){return this.extract()===e.extract()}map(e){return Le(e(this.__value))}ap(e){return e.isJust()?this.map(e.extract()):k}alt(e){return this}altLazy(e){return this}chain(e){return e(this.__value)}chainNullable(e){return ae.Maybe.fromNullable(e(this.__value))}join(){return this.__value}reduce(e,r){return e(r,this.__value)}extend(e){return Le(e(this))}unsafeCoerce(){return this.__value}caseOf(e){return"_"in e?e._():e.Just(this.__value)}orDefault(e){return this.__value}orDefaultLazy(e){return this.__value}toList(){return[this.__value]}mapOrDefault(e,r){return e(this.__value)}extract(){return this.__value}extractNullable(){return this.__value}toEither(e){return(0,cb.Right)(this.__value)}ifJust(e){return e(this.__value),this}ifNothing(e){return this}filter(e){return e(this.__value)?Le(this.__value):k}};Rr.prototype.constructor=ae.Maybe;var Nr=class{constructor(){this["fantasy-land/equals"]=this.equals,this["fantasy-land/map"]=this.map,this["fantasy-land/ap"]=this.ap,this["fantasy-land/alt"]=this.alt,this["fantasy-land/chain"]=this.chain,this["fantasy-land/reduce"]=this.reduce,this["fantasy-land/extend"]=this.extend,this["fantasy-land/filter"]=this.filter}isJust(){return!1}isNothing(){return!0}inspect(){return"Nothing"}toString(){return this.inspect()}toJSON(){return this.__value}equals(e){return this.extract()===e.extract()}map(e){return k}ap(e){return k}alt(e){return e}altLazy(e){return e()}chain(e){return k}chainNullable(e){return k}join(){return k}reduce(e,r){return r}extend(e){return k}unsafeCoerce(){throw new Error("Maybe#unsafeCoerce was ran on a Nothing")}caseOf(e){return"_"in e?e._():e.Nothing()}orDefault(e){return e}orDefaultLazy(e){return e()}toList(){return[]}mapOrDefault(e,r){return r}extract(){}extractNullable(){return null}toEither(e){return(0,cb.Left)(e)}ifJust(e){return this}ifNothing(e){return e(),this}filter(e){return k}};Nr.prototype.constructor=ae.Maybe;var Le=t=>new Rr(t);ae.Just=Le;var k=new Nr;ae.Nothing=k});var Ur=a(qe=>{"use strict";Object.defineProperty(qe,"__esModule",{value:!0});qe.Right=qe.Left=qe.Either=void 0;var Jn=Rt();qe.Either={of(t){return vt(t)},lefts(t){let e=[];for(let r of t)r.isLeft()&&e.push(r.extract());return e},rights(t){let e=[];for(let r of t)r.isRight()&&e.push(r.extract());return e},encase(t){try{return vt(t())}catch(e){return Fr(e)}},sequence(t){let e=[];for(let r of t){if(r.isLeft())return r;e.push(r.extract())}return vt(e)},isEither(t){return t instanceof Lr||t instanceof Br},"fantasy-land/of"(t){return qe.Either.of(t)}};var Br=class{constructor(e){this.__value=e,this._="R",this["fantasy-land/bimap"]=this.bimap,this["fantasy-land/map"]=this.map,this["fantasy-land/ap"]=this.ap,this["fantasy-land/equals"]=this.equals,this["fantasy-land/chain"]=this.chain,this["fantasy-land/alt"]=this.alt,this["fantasy-land/reduce"]=this.reduce,this["fantasy-land/extend"]=this.extend}isLeft(){return!1}isRight(){return!0}toJSON(){return this.__value}inspect(){return`Right(${this.__value})`}toString(){return this.inspect()}bimap(e,r){return vt(r(this.__value))}map(e){return vt(e(this.__value))}mapLeft(e){return this}ap(e){return e.isRight()?this.map(e.extract()):e}equals(e){return e.isRight()?this.__value===e.extract():!1}chain(e){return e(this.__value)}chainLeft(e){return this}join(){return this.__value}alt(e){return this}altLazy(e){return this}reduce(e,r){return e(r,this.__value)}extend(e){return vt(e(this))}unsafeCoerce(){return this.__value}caseOf(e){return"_"in e?e._():e.Right(this.__value)}leftOrDefault(e){return e}orDefault(e){return this.__value}orDefaultLazy(e){return this.__value}leftOrDefaultLazy(e){return e()}ifLeft(e){return this}ifRight(e){return e(this.__value),this}toMaybe(){return(0,Jn.Just)(this.__value)}leftToMaybe(){return Jn.Nothing}extract(){return this.__value}swap(){return Fr(this.__value)}};Br.prototype.constructor=qe.Either;var Lr=class{constructor(e){this.__value=e,this._="L",this["fantasy-land/bimap"]=this.bimap,this["fantasy-land/map"]=this.map,this["fantasy-land/ap"]=this.ap,this["fantasy-land/equals"]=this.equals,this["fantasy-land/chain"]=this.chain,this["fantasy-land/alt"]=this.alt,this["fantasy-land/reduce"]=this.reduce,this["fantasy-land/extend"]=this.extend}isLeft(){return!0}isRight(){return!1}toJSON(){return this.__value}inspect(){return`Left(${JSON.stringify(this.__value)})`}toString(){return this.inspect()}bimap(e,r){return Fr(e(this.__value))}map(e){return this}mapLeft(e){return Fr(e(this.__value))}ap(e){return e.isLeft()?e:this}equals(e){return e.isLeft()?e.extract()===this.__value:!1}chain(e){return this}chainLeft(e){return e(this.__value)}join(){return this}alt(e){return e}altLazy(e){return e()}reduce(e,r){return r}extend(e){return this}unsafeCoerce(){throw this.__value instanceof Error?this.__value:new Error("Either#unsafeCoerce was ran on a Left")}caseOf(e){return"_"in e?e._():e.Left(this.__value)}leftOrDefault(e){return this.__value}orDefault(e){return e}orDefaultLazy(e){return e()}leftOrDefaultLazy(e){return this.__value}ifLeft(e){return e(this.__value),this}ifRight(e){return this}toMaybe(){return Jn.Nothing}leftToMaybe(){return(0,Jn.Just)(this.__value)}extract(){return this.__value}swap(){return vt(this.__value)}};Lr.prototype.constructor=qe.Either;var Fr=t=>new Lr(t);qe.Left=Fr;var vt=t=>new Br(t);qe.Right=vt});var Xn=a(U=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0});U.curry=U.orderToNumber=U.compare=U.Order=U.always=U.identity=void 0;var _N=t=>t;U.identity=_N;var SN=t=>()=>t;U.always=SN;U.Order={LT:"LT",EQ:"EQ",GT:"GT"};var DN=(t,e)=>t>e?U.Order.GT:t<e?U.Order.LT:U.Order.EQ;U.compare=DN;var ON=t=>{switch(t){case U.Order.LT:return-1;case U.Order.EQ:return 0;case U.Order.GT:return 1}};U.orderToNumber=ON;var EN=t=>function e(...r){return r.length>=t.length?t.apply(void 0,r):e.bind(void 0,...r)};U.curry=EN});var tc=a(Nt=>{"use strict";Object.defineProperty(Nt,"__esModule",{value:!0});Nt.NonEmptyList=void 0;var ub=Rt(),CN=t=>t;Nt.NonEmptyList=Object.assign(CN,{fromArray:t=>Nt.NonEmptyList.isNonEmpty(t)?(0,ub.Just)(t):ub.Nothing,unsafeCoerce:t=>{if(Nt.NonEmptyList.isNonEmpty(t))return t;throw new Error("NonEmptyList#unsafeCoerce was ran on an empty array")},fromTuple:t=>(0,Nt.NonEmptyList)(t.toArray()),head:t=>t[0],last:t=>t[t.length-1],isNonEmpty:t=>t.length>0,tail:t=>t.slice(1)})});var mb=a(f=>{"use strict";Object.defineProperty(f,"__esModule",{value:!0});f.parseError=f.map=f.intersect=f.date=f.tuple=f.nonEmptyList=f.maybe=f.lazy=f.exactly=f.record=f.array=f.oneOf=f.enumeration=f.unknown=f.boolean=f.nullable=f.optional=f.nullType=f.number=f.string=f.Codec=void 0;var m=Ur(),Ze=Xn(),rc=Rt(),AN=tc(),Qn=(t,e)=>typeof e=="bigint"?e.toString():e,wN=t=>Object.keys(t).length===0,ur=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),Ae=(t,e)=>{let r="";switch(typeof e){case"undefined":r="undefined";break;case"object":r=e===null?"null":Array.isArray(e)?"an array with value "+JSON.stringify(e,Qn):"an object with value "+JSON.stringify(e,Qn);break;case"boolean":r="a boolean";break;case"symbol":r="a symbol";break;case"function":r="a function";break;case"bigint":r=`a bigint with value ${e.toString()}`}return r=r||`a ${typeof e} with value ${JSON.stringify(e,Qn)}`,`Expected ${t}, but received ${r}`},IN=t=>{var e;return Object.keys(t).length===1&&((e=t.oneOf)===null||e===void 0?void 0:e.length)===1&&typeof t.oneOf[0]=="object"&&(Object.assign(t,t.oneOf[0]),delete t.oneOf),t},PN=t=>{if(Array.isArray(t.oneOf))for(let e=0;e<t.oneOf.length;e++){let r=t.oneOf[e];if(typeof r=="object"&&r.oneOf)return t.oneOf.splice(e,1),t.oneOf.push(...r.oneOf),hb(t)}return t},hb=t=>(PN(t),IN(t),t);f.Codec={interface(t){let e=Object.keys(t),r=n=>{if(!ur(n))return(0,m.Left)(Ae("an object",n));let o={};for(let s of e){if(!n.hasOwnProperty(s)&&!t[s]._isOptional)return(0,m.Left)(`Problem with property "${s}": it does not exist in received object ${JSON.stringify(n,Qn)}`);let l=t[s].decode(n[s]);if(l.isLeft())return(0,m.Left)(`Problem with the value of property "${s}": ${l.extract()}`);let u=l.extract();u!==void 0&&(o[s]=u)}return(0,m.Right)(o)};return{decode:r,encode:n=>{let o={};for(let s of e)o[s]=t[s].encode(n[s]);return o},unsafeDecode:n=>r(n).mapLeft(Error).unsafeCoerce(),schema:()=>e.reduce((n,o)=>(t[o]._isOptional||n.required.push(o),n.properties[o]=hb(t[o].schema()),n),{type:"object",properties:{},required:[]})}},custom({decode:t,encode:e,schema:r}){return{decode:t,encode:e,unsafeDecode:i=>t(i).mapLeft(Error).unsafeCoerce(),schema:r??(()=>({}))}}};f.string=f.Codec.custom({decode:t=>typeof t=="string"?(0,m.Right)(t):(0,m.Left)(Ae("a string",t)),encode:Ze.identity,schema:()=>({type:"string"})});f.number=f.Codec.custom({decode:t=>typeof t=="number"?(0,m.Right)(t):(0,m.Left)(Ae("a number",t)),encode:Ze.identity,schema:()=>({type:"number"})});f.nullType=f.Codec.custom({decode:t=>t===null?(0,m.Right)(t):(0,m.Left)(Ae("a null",t)),encode:Ze.identity,schema:()=>({type:"null"})});var xN=f.Codec.custom({decode:t=>t===void 0?(0,m.Right)(t):(0,m.Left)(Ae("an undefined",t)),encode:Ze.identity}),MN=t=>Object.assign(Object.assign({},(0,f.oneOf)([t,xN])),{schema:t.schema,_isOptional:!0});f.optional=MN;var TN=t=>(0,f.oneOf)([t,f.nullType]);f.nullable=TN;f.boolean=f.Codec.custom({decode:t=>typeof t=="boolean"?(0,m.Right)(t):(0,m.Left)(Ae("a boolean",t)),encode:Ze.identity,schema:()=>({type:"boolean"})});f.unknown=f.Codec.custom({decode:m.Right,encode:Ze.identity,schema:()=>({})});var jN=t=>{let e=Object.values(t);return f.Codec.custom({decode:r=>(0,f.oneOf)([f.string,f.number]).decode(r).chain(i=>{let n=e.indexOf(i);return n!==-1?(0,m.Right)(e[n]):(0,m.Left)(Ae("an enum member",r))}),encode:Ze.identity,schema:()=>({enum:e})})};f.enumeration=jN;var qN=t=>f.Codec.custom({decode:e=>{let r=[];for(let i of t){let n=i.decode(e);if(n.isRight())return n;r.push(n.extract())}return(0,m.Left)(`One of the following problems occured: ${r.map((i,n)=>`(${n}) ${i}`).join(", ")}`)},encode:e=>{for(let r of t)if(m.Either.encase(()=>r.encode(e)).mapLeft(n=>"").chain(r.decode).isRight())return r.encode(e);return e},schema:()=>({oneOf:t.map(e=>e.schema())})});f.oneOf=qN;var RN=t=>f.Codec.custom({decode:e=>{if(Array.isArray(e)){let r=[];for(let i=0;i<e.length;i++){let n=t.decode(e[i]);if(n.isRight())r.push(n.extract());else return(0,m.Left)(`Problem with the value at index ${i}: ${n.extract()}`)}return(0,m.Right)(r)}else return(0,m.Left)(Ae("an array",e))},encode:e=>e.map(t.encode),schema:()=>({type:"array",items:t.schema()})});f.array=RN;var NN=f.Codec.custom({decode:t=>f.string.decode(t).chain(e=>isFinite(+e)?(0,m.Right)(e):(0,m.Left)(Ae("a number",t))),encode:Ze.identity,schema:f.number.schema}),UN=(t,e)=>f.Codec.custom({decode:r=>{let i={},n=t===f.number?NN:t;if(!ur(r))return(0,m.Left)(Ae("an object",r));for(let o of Object.keys(r))if(r.hasOwnProperty(o)){let s=n.decode(o),l=e.decode(r[o]);if(s.isRight()&&l.isRight())i[s.extract()]=l.extract();else{if(s.isLeft())return(0,m.Left)(`Problem with key type of property "${o}": ${s.extract()}`);if(l.isLeft())return(0,m.Left)(`Problem with the value of property "${o}": ${l.extract()}`)}}return(0,m.Right)(i)},encode:r=>{let i={};for(let n in r)r.hasOwnProperty(n)&&(i[t.encode(n)]=e.encode(r[n]));return i},schema:()=>({type:"object",additionalProperties:e.schema()})});f.record=UN;var BN=(...t)=>f.Codec.custom({decode:e=>t.includes(e)?(0,m.Right)(e):(0,m.Left)(Ae(t.map(r=>JSON.stringify(r)).join(", "),e)),encode:Ze.identity,schema:()=>({oneOf:t.map(e=>({type:typeof e,enum:[e]}))})});f.exactly=BN;var LN=t=>f.Codec.custom({decode:e=>t().decode(e),encode:e=>t().encode(e),schema:()=>({$comment:"Lazy codecs are not supported when generating a JSON schema"})});f.lazy=LN;var FN=t=>{let e=f.Codec.custom({decode:r=>rc.Maybe.fromNullable(r).caseOf({Just:i=>t.decode(i).map(rc.Just),Nothing:()=>(0,m.Right)(rc.Nothing)}),encode:r=>r.map(t.encode).orDefault(void 0),schema:()=>wN(t.schema())?{}:{oneOf:[t.schema(),{type:"null"}]}});return Object.assign(Object.assign({},e),{_isOptional:!0})};f.maybe=FN;var kN=t=>{let e=(0,f.array)(t);return f.Codec.custom({decode:r=>e.decode(r).chain(i=>AN.NonEmptyList.fromArray(i).toEither("Expected an array with one or more elements, but received an empty array")),encode:e.encode,schema:()=>Object.assign(Object.assign({},e.schema()),{minItems:1})})};f.nonEmptyList=kN;var VN=t=>f.Codec.custom({decode:e=>{if(Array.isArray(e)){if(t.length!==e.length)return(0,m.Left)(`Expected an array of length ${t.length}, but received an array with length of ${e.length}`);{let r=[];for(let i=0;i<t.length;i++){let n=t[i].decode(e[i]);if(n.isRight())r.push(n.extract());else return(0,m.Left)(`Problem with the value at index ${i}: ${n.extract()}`)}return(0,m.Right)(r)}}else return(0,m.Left)(Ae("an array",e))},encode:e=>e.map((r,i)=>t[i].encode(r)),schema:()=>({type:"array",items:t.map(e=>e.schema()),additionalItems:!1,minItems:t.length,maxItems:t.length})});f.tuple=VN;f.date=f.Codec.custom({decode:t=>f.string.decode(t).mapLeft(e=>`Problem with date string: ${e}`).chain(e=>Number.isNaN(Date.parse(e))?(0,m.Left)("Expected a valid date string, but received a string that cannot be parsed"):(0,m.Right)(new Date(e))),encode:t=>t.toISOString(),schema:()=>({type:"string",format:"date-time"})});var GN=(t,e)=>f.Codec.custom({decode:r=>{let i=t.decode(r);if(i.isLeft())return i;let n=e.decode(r);if(n.isLeft())return n;let o=i.extract(),s=n.extract();return ur(o)&&ur(s)?(0,m.Right)(Object.assign(o,s)):(0,m.Right)(s)},encode:r=>{let i=t.encode(r),n=e.encode(r);return ur(i)&&ur(n)?Object.assign(i,n):n},schema:()=>({allOf:[t,e].map(r=>r.schema())})});f.intersect=GN;var HN=(t,e)=>f.Codec.custom({decode:r=>(0,f.array)((0,f.tuple)([t,e])).decode(r).map(i=>new Map(i)),encode:r=>Array.from(r.entries()).map(([i,n])=>[t.encode(i),e.encode(n)]),schema:()=>({type:"array",items:{type:"array",items:[t.schema(),e.schema()],additionalItems:!1,minItems:2,maxItems:2}})});f.map=HN;var WN=/^(One of the following problems occured:)\s/,KN=/\(\d\)\s/,$N=/\, (?=\()/g,zN=/^(Expected ).+(, but received )/,db=" with value",lb='Problem with property "',pb='Problem with the value of property "',fb='Problem with key type of property "',vb="Problem with date string: ",gb="Problem with the value at index ",JN={"an object":"object","a number":"number","a string":"string","an undefined":"undefined","a boolean":"boolean","an array":"array","a null":"null","an enum member":"enum"},XN={"a string":"string","a number":"number",null:"null",undefined:"undefined","a boolean":"boolean","an array":"array","an object":"object","a symbol":"symbol","a function":"function","a bigint":"bigint"},QN=["null","undefined","boolean","symbol","function","bigint"],YN=t=>{let e=t.match(WN);if(e)return{type:"oneOf",errors:t.replace(e[0],"").split($N).map(n=>(0,f.parseError)(n.replace(n.match(KN)[0],"")))};let r=t.match(zN);if(r){let i=t.split(r[2]).pop(),n=XN[i.split(db)[0]];if(n){let o=t.replace(r[1],"").split(r[2])[0];return{type:"failure",expectedType:JN[o],receivedType:n,receivedValue:QN.includes(n)?void 0:JSON.parse(i.split(db).pop())}}}if(t.startsWith(lb))return{type:"property",property:t.replace(lb,"").split('": ')[0],error:{type:"failure",receivedType:"undefined"}};if(t.startsWith(pb)||t.startsWith(fb)){let[i,...n]=t.replace(pb,"").replace(fb,"").split(/": (.+)/);return{type:"property",property:i,error:(0,f.parseError)(n.join(""))}}if(t.startsWith(vb))return(0,f.parseError)(t.replace(vb,""));if(t.startsWith(gb)){let[i,...n]=t.replace(gb,"").split(/: (.+)/);return{type:"index",index:Number(i),error:(0,f.parseError)(n.join(""))}}return{type:"custom",message:t}};f.parseError=YN});var nc=a(ce=>{"use strict";Object.defineProperty(ce,"__esModule",{value:!0});ce.Tuple=void 0;var Yn=class{constructor(e,r){this.first=e,this.second=r,this.length=2,this["fantasy-land/equals"]=this.equals,this["fantasy-land/bimap"]=this.bimap,this["fantasy-land/map"]=this.map,this["fantasy-land/reduce"]=this.reduce,this["fantasy-land/ap"]=this.ap,this[0]=e,this[1]=r}*[Symbol.iterator](){yield this.first,yield this.second}toJSON(){return this.toArray()}inspect(){return`Tuple(${JSON.stringify(this.first)}, ${JSON.stringify(this.second)})`}toString(){return this.inspect()}fst(){return this.first}snd(){return this.second}equals(e){return this.first===e.fst()&&this.second===e.snd()}bimap(e,r){return(0,ce.Tuple)(e(this.first),r(this.second))}mapFirst(e){return(0,ce.Tuple)(e(this.first),this.second)}map(e){return(0,ce.Tuple)(this.first,e(this.second))}reduce(e,r){return e(r,this.second)}toArray(){return[this.first,this.second]}swap(){return(0,ce.Tuple)(this.second,this.first)}ap(e){return(0,ce.Tuple)(this.first,e.snd()(this.second))}every(e){return e(this.first)&&e(this.second)}some(e){return e(this.first)||e(this.second)}};ce.Tuple=Object.assign((t,e)=>new Yn(t,e),{fromArray:([t,e])=>(0,ce.Tuple)(t,e),fanout:(...t)=>{let[e,r,i]=t;switch(t.length){case 3:return(0,ce.Tuple)(e(i),r(i));case 2:return n=>ce.Tuple.fanout(e,r,n);default:return n=>o=>ce.Tuple.fanout(e,n,o)}}});Yn.prototype.constructor=ce.Tuple});var Db=a(Zn=>{"use strict";Object.defineProperty(Zn,"__esModule",{value:!0});Zn.List=void 0;var ZN=nc(),ue=Rt(),eU=Xn(),tU=t=>t.length>0?(0,ue.Just)(t[0]):ue.Nothing,rU=t=>t.length>0?(0,ue.Just)(t[t.length-1]):ue.Nothing,nU=t=>t.length>0?(0,ue.Just)(t.slice(1)):ue.Nothing,iU=t=>t.length>0?(0,ue.Just)(t.slice(0,-1)):ue.Nothing,oU=t=>t.length>0?(0,ue.Just)((0,ZN.Tuple)(t[0],t.slice(1))):ue.Nothing,sU=t=>t.reduce((e,r)=>e+r,0);function yb(t,e){switch(arguments.length){case 1:return r=>yb(t,r);default:return ue.Maybe.fromNullable(e.find(t))}}function bb(t,e){switch(arguments.length){case 1:return r=>bb(t,r);default:return ue.Maybe.fromPredicate(r=>r!==-1,e.findIndex(t))}}function _b(t,e){switch(arguments.length){case 1:return r=>_b(t,r);default:return e[t]===void 0?ue.Nothing:(0,ue.Just)(e[t])}}function Sb(t,e){switch(arguments.length){case 1:return r=>Sb(t,r);default:return[...e].sort((r,i)=>(0,eU.orderToNumber)(t(r,i)))}}Zn.List={init:iU,uncons:oU,at:_b,head:tU,last:rU,tail:nU,find:yb,findIndex:bb,sum:sU,sort:Sb}});var ic=a(C=>{"use strict";var re=C&&C.__awaiter||function(t,e,r,i){function n(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function l(c){try{d(i.next(c))}catch(p){s(p)}}function u(c){try{d(i.throw(c))}catch(p){s(p)}}function d(c){c.done?o(c.value):n(c.value).then(l,u)}d((i=i.apply(t,e||[])).next())})},aU=C&&C.__asyncValues||function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof __values=="function"?__values(t):t[Symbol.iterator](),r={},i("next"),i("throw"),i("return"),r[Symbol.asyncIterator]=function(){return this},r);function i(o){r[o]=t[o]&&function(s){return new Promise(function(l,u){s=t[o](s),n(l,u,s.done,s.value)})}}function n(o,s,l,u){Promise.resolve(u).then(function(d){o({value:d,done:l})},s)}},Ob;Object.defineProperty(C,"__esModule",{value:!0});C.EitherAsync=void 0;var gt=Ur(),cU=oc(),Eb={liftEither(t){if(t.isRight())return Promise.resolve(t.extract());throw t.extract()},fromPromise(t){return t.then(Eb.liftEither)},throwE(t){throw t}},ei=class{constructor(e){this.runPromise=e,this[Ob]="EitherAsync",this["fantasy-land/chain"]=this.chain,this["fantasy-land/alt"]=this.alt,this.then=(r,i)=>this.run().then(r,i)}leftOrDefault(e){return this.run().then(r=>r.leftOrDefault(e))}orDefault(e){return this.run().then(r=>r.orDefault(e))}join(){return(0,C.EitherAsync)(e=>re(this,void 0,void 0,function*(){let r=yield this;if(r.isRight()){let i=yield r.extract();return e.liftEither(i)}return e.liftEither(r)}))}ap(e){return(0,C.EitherAsync)(r=>re(this,void 0,void 0,function*(){let i=yield e;if(i.isRight()){let n=yield this.run();return n.isRight()?i.extract()(n.extract()):r.liftEither(n)}return r.liftEither(i)}))}alt(e){return(0,C.EitherAsync)(r=>re(this,void 0,void 0,function*(){let i=yield this.run();if(i.isRight())return i.extract();{let n=yield e;return r.liftEither(n)}}))}extend(e){return(0,C.EitherAsync)(r=>re(this,void 0,void 0,function*(){let i=yield this.run();if(i.isRight()){let n=C.EitherAsync.liftEither(i);return r.liftEither((0,gt.Right)(e(n)))}return r.liftEither(i)}))}run(){return re(this,void 0,void 0,function*(){try{return(0,gt.Right)(yield this.runPromise(Eb))}catch(e){return(0,gt.Left)(e)}})}bimap(e,r){return(0,C.EitherAsync)(i=>re(this,void 0,void 0,function*(){let n=yield this.run();try{return yield i.liftEither(n.bimap(e,r))}catch(o){throw yield o}}))}map(e){return(0,C.EitherAsync)(r=>this.runPromise(r).then(e))}mapLeft(e){return(0,C.EitherAsync)(r=>re(this,void 0,void 0,function*(){try{return yield this.runPromise(r)}catch(i){throw yield e(i)}}))}chain(e){return(0,C.EitherAsync)(r=>re(this,void 0,void 0,function*(){let i=yield this.runPromise(r);return r.fromPromise(e(i))}))}chainLeft(e){return(0,C.EitherAsync)(r=>re(this,void 0,void 0,function*(){try{return yield this.runPromise(r)}catch(i){return r.fromPromise(e(i))}}))}toMaybeAsync(){return(0,cU.MaybeAsync)(e=>re(this,[e],void 0,function*({liftMaybe:r}){let i=yield this.run();return r(i.toMaybe())}))}swap(){return(0,C.EitherAsync)(e=>re(this,void 0,void 0,function*(){let r=yield this.run();return r.isRight()&&e.throwE(r.extract()),e.liftEither((0,gt.Right)(r.extract()))}))}ifLeft(e){return(0,C.EitherAsync)(r=>re(this,void 0,void 0,function*(){let i=yield this.run();return i.ifLeft(e),r.liftEither(i)}))}ifRight(e){return(0,C.EitherAsync)(r=>re(this,void 0,void 0,function*(){let i=yield this.run();return i.ifRight(e),r.liftEither(i)}))}void(){return this.map(e=>{})}caseOf(e){return this.run().then(r=>r.caseOf(e))}finally(e){return(0,C.EitherAsync)(({fromPromise:r})=>r(this.run().finally(e)))}};Ob=Symbol.toStringTag;C.EitherAsync=Object.assign(t=>new ei(t),{fromPromise:t=>(0,C.EitherAsync)(({fromPromise:e})=>e(t())),liftEither:t=>(0,C.EitherAsync)(({liftEither:e})=>e(t)),lefts:t=>Promise.all(t.map(e=>e.run())).then(gt.Either.lefts),rights:t=>Promise.all(t.map(e=>e.run())).then(gt.Either.rights),sequence:t=>(0,C.EitherAsync)(e=>re(void 0,void 0,void 0,function*(){var r,i,n,o;let s=[];try{for(var l=!0,u=aU(t),d;d=yield u.next(),r=d.done,!r;l=!0){o=d.value,l=!1;let c=o;if(c.isLeft())return e.liftEither(c);s.push(c.extract())}}catch(c){i={error:c}}finally{try{!l&&!r&&(n=u.return)&&(yield n.call(u))}finally{if(i)throw i.error}}return e.liftEither((0,gt.Right)(s))})),all:t=>C.EitherAsync.fromPromise(()=>re(void 0,void 0,void 0,function*(){return Promise.all(t).then(gt.Either.sequence)}))});ei.prototype.constructor=C.EitherAsync});var oc=a(B=>{"use strict";var Fe=B&&B.__awaiter||function(t,e,r,i){function n(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function l(c){try{d(i.next(c))}catch(p){s(p)}}function u(c){try{d(i.throw(c))}catch(p){s(p)}}function d(c){c.done?o(c.value):n(c.value).then(l,u)}d((i=i.apply(t,e||[])).next())})},Cb;Object.defineProperty(B,"__esModule",{value:!0});B.MaybeAsync=void 0;var et=Rt(),uU=ic(),Ab={liftMaybe(t){if(t.isJust())return Promise.resolve(t.extract());throw et.Nothing},fromPromise(t){return t.then(Ab.liftMaybe)}},ti=class{constructor(e){this.runPromise=e,this[Cb]="MaybeAsync",this["fantasy-land/chain"]=this.chain,this["fantasy-land/filter"]=this.filter,this["fantasy-land/alt"]=this.alt}orDefault(e){return this.run().then(r=>r.orDefault(e))}join(){return(0,B.MaybeAsync)(e=>Fe(this,void 0,void 0,function*(){let r=yield this.run();if(r.isJust()){let i=yield r.extract();return e.liftMaybe(i)}return e.liftMaybe(et.Nothing)}))}ap(e){return(0,B.MaybeAsync)(r=>Fe(this,void 0,void 0,function*(){let i=yield e;if(i.isJust()){let n=yield this.run();return n.isJust()?i.extract()(n.extract()):r.liftMaybe(et.Nothing)}return r.liftMaybe(et.Nothing)}))}alt(e){return(0,B.MaybeAsync)(r=>Fe(this,void 0,void 0,function*(){let i=yield this.run();if(i.isJust())return i.extract();{let n=yield e;return r.liftMaybe(n)}}))}extend(e){return(0,B.MaybeAsync)(r=>Fe(this,void 0,void 0,function*(){let i=yield this.run();if(i.isJust()){let n=B.MaybeAsync.liftMaybe(i);return r.liftMaybe((0,et.Just)(e(n)))}return r.liftMaybe(et.Nothing)}))}filter(e){return(0,B.MaybeAsync)(r=>Fe(this,void 0,void 0,function*(){let i=yield this.run();return r.liftMaybe(i.filter(e))}))}run(){return Fe(this,void 0,void 0,function*(){try{return(0,et.Just)(yield this.runPromise(Ab))}catch{return et.Nothing}})}map(e){return(0,B.MaybeAsync)(r=>this.runPromise(r).then(e))}chain(e){return(0,B.MaybeAsync)(r=>Fe(this,void 0,void 0,function*(){let i=yield this.runPromise(r);return r.fromPromise(e(i))}))}toEitherAsync(e){return(0,uU.EitherAsync)(r=>Fe(this,[r],void 0,function*({liftEither:i}){let n=yield this.run();return i(n.toEither(e))}))}ifJust(e){return(0,B.MaybeAsync)(r=>Fe(this,void 0,void 0,function*(){let i=yield this.run();return i.ifJust(e),r.liftMaybe(i)}))}ifNothing(e){return(0,B.MaybeAsync)(r=>Fe(this,void 0,void 0,function*(){let i=yield this.run();return i.ifNothing(e),r.liftMaybe(i)}))}void(){return this.map(e=>{})}caseOf(e){return this.run().then(r=>r.caseOf(e))}finally(e){return(0,B.MaybeAsync)(({fromPromise:r})=>r(this.run().finally(e)))}then(e,r){return this.run().then(e,r)}};Cb=Symbol.toStringTag;B.MaybeAsync=Object.assign(t=>new ti(t),{catMaybes:t=>Promise.all(t).then(et.Maybe.catMaybes),fromPromise:t=>(0,B.MaybeAsync)(({fromPromise:e})=>e(t())),liftMaybe:t=>(0,B.MaybeAsync)(({liftMaybe:e})=>e(t))});ti.prototype.constructor=B.MaybeAsync});var b=a(V=>{"use strict";var dU=V&&V.__createBinding||(Object.create?(function(t,e,r,i){i===void 0&&(i=r);var n=Object.getOwnPropertyDescriptor(e,r);(!n||("get"in n?!e.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,i,n)}):(function(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]})),Ut=V&&V.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&dU(e,t,r)};Object.defineProperty(V,"__esModule",{value:!0});V.EitherAsync=V.MaybeAsync=void 0;Ut(mb(),V);Ut(Ur(),V);Ut(Xn(),V);Ut(Db(),V);Ut(Rt(),V);var lU=oc();Object.defineProperty(V,"MaybeAsync",{enumerable:!0,get:function(){return lU.MaybeAsync}});var pU=ic();Object.defineProperty(V,"EitherAsync",{enumerable:!0,get:function(){return pU.EitherAsync}});Ut(tc(),V);Ut(nc(),V)});var de=a((Eue,Ib)=>{"use strict";var vc=Object.defineProperty,fU=Object.getOwnPropertyDescriptor,vU=Object.getOwnPropertyNames,gU=Object.prototype.hasOwnProperty,hU=(t,e)=>{for(var r in e)vc(t,r,{get:e[r],enumerable:!0})},mU=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of vU(e))!gU.call(t,n)&&n!==r&&vc(t,n,{get:()=>e[n],enumerable:!(i=fU(e,n))||i.enumerable});return t},yU=t=>mU(vc({},"__esModule",{value:!0}),t),wb={};hU(wb,{AppAlreadyInstalledDAError:()=>dc,DeviceLockedError:()=>ac,DeviceNotOnboardedError:()=>sc,OutOfMemoryDAError:()=>lc,RefusedByUserDAError:()=>uc,UnknownDAError:()=>pc,UnsupportedApplicationDAError:()=>fc,UnsupportedFirmwareDAError:()=>cc});Ib.exports=yU(wb);var sc=class{_tag="DeviceNotOnboardedError";originalError;constructor(e){this.originalError=new Error(e??"Device not onboarded.")}},ac=class{_tag="DeviceLockedError";originalError;constructor(e){this.originalError=new Error(e??"Device locked.")}},cc=class{_tag="UnsupportedFirmwareDAError";originalError;constructor(e){this.originalError=new Error(e??"Unknown error.")}},uc=class{_tag="RefusedByUserDAError";originalError;constructor(e){this.originalError=new Error(e??"Unknown error.")}},dc=class{_tag="AppAlreadyInstalledDAError";originalError;constructor(e){this.originalError=new Error(e??"Unknown error.")}},lc=class{_tag="OutOfMemoryDAError";originalError;constructor(e){this.originalError=new Error(e??"Unknown error.")}},pc=class{_tag="UnknownDAError";originalError;constructor(e){this.originalError=new Error(e??"Unknown error.")}},fc=class{_tag="UnsupportedApplicationDAError";originalError;constructor(e){this.originalError=new Error(e??"Application currently not supported.")}}});var le=a((Cue,xb)=>{"use strict";var gc=Object.defineProperty,bU=Object.getOwnPropertyDescriptor,_U=Object.getOwnPropertyNames,SU=Object.prototype.hasOwnProperty,DU=(t,e)=>{for(var r in e)gc(t,r,{get:e[r],enumerable:!0})},OU=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of _U(e))!SU.call(t,n)&&n!==r&&gc(t,n,{get:()=>e[n],enumerable:!(i=bU(e,n))||i.enumerable});return t},EU=t=>OU(gc({},"__esModule",{value:!0}),t),Pb={};DU(Pb,{DEFAULT_UNLOCK_TIMEOUT_MS:()=>CU});xb.exports=EU(Pb);var CU=6e4});var mc=a((Aue,jb)=>{"use strict";var hc=Object.defineProperty,AU=Object.getOwnPropertyDescriptor,wU=Object.getOwnPropertyNames,IU=Object.prototype.hasOwnProperty,PU=(t,e)=>{for(var r in e)hc(t,r,{get:e[r],enumerable:!0})},xU=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of wU(e))!IU.call(t,n)&&n!==r&&hc(t,n,{get:()=>e[n],enumerable:!(i=AU(e,n))||i.enumerable});return t},MU=t=>xU(hc({},"__esModule",{value:!0}),t),Mb={};PU(Mb,{noopLogger:()=>Tb,noopLoggerFactory:()=>TU});jb.exports=MU(Mb);var Tb={subscribers:[],error:()=>{},warn:()=>{},info:()=>{},debug:()=>{}},TU=t=>Tb});var ee=a((wue,Rb)=>{"use strict";var _c=Object.defineProperty,jU=Object.getOwnPropertyDescriptor,qU=Object.getOwnPropertyNames,RU=Object.prototype.hasOwnProperty,NU=(t,e)=>{for(var r in e)_c(t,r,{get:e[r],enumerable:!0})},UU=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of qU(e))!RU.call(t,n)&&n!==r&&_c(t,n,{get:()=>e[n],enumerable:!(i=jU(e,n))||i.enumerable});return t},BU=t=>UU(_c({},"__esModule",{value:!0}),t),qb={};NU(qb,{XStateDeviceAction:()=>bc});Rb.exports=BU(qb);var yc=De(),LU=(Y(),X(Q)),ri=Za(),FU=mc(),bc=class{input;inspect=!1;logger;loggerFactory;constructor(e){this.input=e.input,this.inspect=!!e.inspect,this.logger=e.logger,this.loggerFactory=e.loggerFactory}getLoggerFactory(e){return this.loggerFactory??e.loggerFactory??FU.noopLoggerFactory}_execute(e){let r=this.makeStateMachine(e);return!this.logger&&r.id&&(this.logger=this.getLoggerFactory(e)(r.id)),this._subscribeToStateMachine(r)}_subscribeToStateMachine(e){let r=(0,LU.createActor)(e,{input:this.input}),i=new yc.ReplaySubject,n=!1,o=u=>{let{context:d,status:c,output:p,error:v}=u;if(this.logger&&!n&&(n=!0,this.logger.debug("[XStateDeviceAction] Input",{data:{input:d.input}})),this.logger&&c==="active"){let y=typeof u.value=="string"?u.value:JSON.stringify(u.value);this.logger.debug(`[XStateDeviceAction] State: ${y}`,{data:{internalState:d._internalState}})}switch(c){case"active":i.next({status:ri.DeviceActionStatus.Pending,intermediateValue:d.intermediateValue});break;case"done":p.caseOf({Left:y=>{i.next({status:ri.DeviceActionStatus.Error,error:y})},Right:y=>{i.next({status:ri.DeviceActionStatus.Completed,output:y})}}),i.complete();break;case"error":i.error(v),i.complete();break;case"stopped":i.next({status:ri.DeviceActionStatus.Stopped}),i.complete();break;default:this._exhaustiveMatchingGuard(c)}},s=new yc.Observable(u=>{let d=i.subscribe(u);return()=>{l.unsubscribe(),d.unsubscribe(),r.stop()}}),l=r.subscribe(o);return r.start(),{observable:s.pipe((0,yc.share)()),cancel:()=>{r.stop(),l.unsubscribe(),o(r.getSnapshot())}}}_exhaustiveMatchingGuard(e){throw console.log("_exhaustiveMatchingGuard status",e),new Error(`Unhandled status: ${e}`)}}});var ne=a((Iue,Bb)=>{"use strict";var Sc=Object.defineProperty,kU=Object.getOwnPropertyDescriptor,VU=Object.getOwnPropertyNames,GU=Object.prototype.hasOwnProperty,HU=(t,e)=>{for(var r in e)Sc(t,r,{get:e[r],enumerable:!0})},WU=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of VU(e))!GU.call(t,n)&&n!==r&&Sc(t,n,{get:()=>e[n],enumerable:!(i=kU(e,n))||i.enumerable});return t},KU=t=>WU(Sc({},"__esModule",{value:!0}),t),Nb={};HU(Nb,{DeviceSessionStateType:()=>Ub});Bb.exports=KU(Nb);var Ub=(t=>(t[t.Connected=0]="Connected",t[t.ReadyWithoutSecureChannel=1]="ReadyWithoutSecureChannel",t[t.ReadyWithSecureChannel=2]="ReadyWithSecureChannel",t))(Ub||{})});var ii=a((Pue,Hb)=>{"use strict";var Ec=Object.defineProperty,$U=Object.getOwnPropertyDescriptor,zU=Object.getOwnPropertyNames,JU=Object.prototype.hasOwnProperty,XU=(t,e)=>{for(var r in e)Ec(t,r,{get:e[r],enumerable:!0})},QU=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of zU(e))!JU.call(t,n)&&n!==r&&Ec(t,n,{get:()=>e[n],enumerable:!(i=$U(e,n))||i.enumerable});return t},YU=t=>QU(Ec({},"__esModule",{value:!0}),t),Gb={};XU(Gb,{GetDeviceStatusDeviceAction:()=>Oc});Hb.exports=YU(Gb);var Lb=b(),Bt=De(),ZU=_T(),Re=(Y(),X(Q)),Fb=w(),kb=jr(),e1=zn(),ni=Z(),t1=le(),Vb=de(),r1=ee(),Dc=ne(),Oc=class extends r1.XStateDeviceAction{makeStateMachine(e){let{getAppAndVersion:r,getDeviceSessionState:i,setDeviceSessionState:n,waitForDeviceUnlock:o,isDeviceOnboarded:s}=this.extractDependencies(e),l=this.input.unlockTimeout??t1.DEFAULT_UNLOCK_TIMEOUT_MS;return(0,Re.setup)({types:{input:{unlockTimeout:l},context:{},output:{}},actors:{getAppAndVersion:(0,Re.fromPromise)(r),waitForDeviceUnlock:(0,Re.fromObservable)(o)},guards:{isDeviceOnboarded:()=>s(),isDeviceLocked:({context:u})=>u._internalState.locked,hasError:({context:u})=>u._internalState.error!==null},actions:{assignErrorDeviceNotOnboarded:(0,Re.assign)({_internalState:u=>({...u.context._internalState,error:new Vb.DeviceNotOnboardedError})}),assignErrorDeviceLocked:(0,Re.assign)({_internalState:u=>({...u.context._internalState,error:new Vb.DeviceLockedError}),intermediateValue:{requiredUserInteraction:ni.UserInteractionRequired.UnlockDevice}}),assignErrorFromEvent:(0,Re.assign)({_internalState:u=>({...u.context._internalState,error:u.event.error})}),assignNoUserActionNeeded:(0,Re.assign)({intermediateValue:u=>({...u.context.intermediateValue,requiredUserInteraction:ni.UserInteractionRequired.None})}),assignUserActionUnlockNeeded:(0,Re.assign)({intermediateValue:u=>({...u.context.intermediateValue,requiredUserInteraction:ni.UserInteractionRequired.UnlockDevice})})}}).createMachine({id:"GetDeviceStatusDeviceAction",initial:"DeviceReady",context:u=>{let d=i(),{sessionStateType:c}=d;return{input:{unlockTimeout:u.input.unlockTimeout},intermediateValue:{requiredUserInteraction:ni.UserInteractionRequired.None},_internalState:{onboarded:!1,locked:!1,currentApp:c===Dc.DeviceSessionStateType.ReadyWithoutSecureChannel?d.currentApp.name:null,currentAppVersion:null,error:null}}},states:{DeviceReady:{always:{target:"OnboardingCheck"}},OnboardingCheck:{always:[{guard:{type:"isDeviceOnboarded"},target:"AppAndVersionCheck",actions:(0,Re.assign)({_internalState:u=>({...u.context._internalState,onboarded:!0})})},{target:"Error",actions:"assignErrorDeviceNotOnboarded"}]},UserActionUnlockDevice:{entry:"assignUserActionUnlockNeeded",exit:"assignNoUserActionNeeded",invoke:{id:"UserActionUnlockDevice",src:"waitForDeviceUnlock",input:u=>({unlockTimeout:l}),onDone:{target:"AppAndVersionCheck",actions:(0,Re.assign)({_internalState:u=>({...u.context._internalState,locked:!1})})},onError:{target:"Error",actions:"assignErrorDeviceLocked"}}},AppAndVersionCheck:{invoke:{src:"getAppAndVersion",onDone:{target:"ApplicationAvailableResultCheck",actions:(0,Re.assign)({_internalState:u=>{if((0,Fb.isSuccessCommandResult)(u.event.output)){let d=i();return d.sessionStateType!==Dc.DeviceSessionStateType.Connected?n({...d,currentApp:u.event.output.data}):n({deviceModelId:d.deviceModelId,sessionStateType:Dc.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:e1.DeviceStatus.CONNECTED,currentApp:u.event.output.data,installedApps:[],isSecureConnectionAllowed:!1}),{...u.context._internalState,locked:!1,currentApp:u.event.output.data.name,currentAppVersion:u.event.output.data.version}}if("errorCode"in u.event.output.error){if(u.event.output.error.errorCode==="5515")return{...u.context._internalState,locked:!0};if(u.event.output.error.errorCode==="6e00")return{...u.context._internalState,locked:!1,currentApp:"BOLOS",currentAppVersion:"0.0.0"}}return{...u.context._internalState,error:u.event.output.error}}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},ApplicationAvailableResultCheck:{always:[{guard:"hasError",target:"Error"},{target:"UserActionUnlockDevice",guard:"isDeviceLocked"},{target:"Success"}]},Success:{type:"final"},Error:{type:"final"}},output:u=>{let{context:d}=u,{error:c,currentApp:p,currentAppVersion:v}=d._internalState;return c?(0,Lb.Left)(c):(0,Lb.Right)({currentApp:p,currentAppVersion:v})}})}extractDependencies(e){return{getAppAndVersion:()=>e.sendCommand(new kb.GetAppAndVersionCommand),waitForDeviceUnlock:({input:r})=>(0,Bt.interval)(1e3).pipe((0,Bt.switchMap)(()=>(0,Bt.from)(e.sendCommand(new kb.GetAppAndVersionCommand))),(0,Bt.mergeMap)(i=>!(0,Fb.isSuccessCommandResult)(i)&&"errorCode"in i.error&&i.error.errorCode==="5515"?Bt.EMPTY:(0,Bt.of)(void 0)),(0,Bt.take)(1),(0,ZU.timeout)(r.unlockTimeout)),getDeviceSessionState:()=>e.getDeviceSessionState(),setDeviceSessionState:r=>e.setDeviceSessionState(r),isDeviceOnboarded:()=>!0}}}});var tt=a((xue,Kb)=>{"use strict";var Hc=Object.defineProperty,n1=Object.getOwnPropertyDescriptor,i1=Object.getOwnPropertyNames,o1=Object.prototype.hasOwnProperty,s1=(t,e)=>{for(var r in e)Hc(t,r,{get:e[r],enumerable:!0})},a1=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of i1(e))!o1.call(t,n)&&n!==r&&Hc(t,n,{get:()=>e[n],enumerable:!(i=n1(e,n))||i.enumerable});return t},c1=t=>a1(Hc({},"__esModule",{value:!0}),t),Wb={};s1(Wb,{AlreadySendingApduError:()=>kc,DeviceAlreadyConnectedError:()=>Cc,DeviceDisconnectedBeforeSendingApdu:()=>Vc,DeviceDisconnectedWhileSendingError:()=>Fc,DeviceNotInitializedError:()=>Uc,DeviceNotRecognizedError:()=>Ac,DisconnectError:()=>Rc,GeneralDmkError:()=>M,NoAccessibleDeviceError:()=>wc,NoTransportProvidedError:()=>Gc,NoTransportsProvidedError:()=>Bc,OpeningConnectionError:()=>Ic,ReconnectionFailedError:()=>Nc,SendApduConcurrencyError:()=>Mc,SendApduEmptyResponseError:()=>qc,SendApduTimeoutError:()=>Tc,SendCommandTimeoutError:()=>jc,TransportAlreadyExistsError:()=>Lc,TransportNotSupportedError:()=>xc,UnknownDeviceError:()=>Pc});Kb.exports=c1(Wb);var M=class{_tag="GeneralDmkError";originalError;constructor(e){e instanceof Error?this.originalError=e:e!==void 0&&(this.originalError=new Error(String(e)))}},Cc=class extends M{constructor(e){super(e),this.err=e}_tag="DeviceAlreadyDiscoveredError"},Ac=class extends M{constructor(e){super(e),this.err=e}_tag="DeviceNotRecognizedError"},wc=class extends M{constructor(e){super(e),this.err=e}_tag="NoAccessibleDeviceError"},Ic=class extends M{_tag="ConnectionOpeningError";constructor(e){super(e)}},Pc=class extends M{constructor(e){super(e),this.err=e}_tag="UnknownDeviceError"},xc=class extends M{constructor(e){super(e),this.err=e}_tag="TransportNotSupportedError"},Mc=class extends M{constructor(e){super(e),this.err=e}_tag="SendApduConcurrencyError"},Tc=class extends M{constructor(e){super(e),this.err=e}_tag="SendApduTimeoutError"},jc=class extends M{constructor(e){super(e),this.err=e}_tag="SendCommandTimeoutError"},qc=class extends M{constructor(e){super(e),this.err=e}_tag="SendApduEmptyResponseError"},Rc=class extends M{constructor(e){super(e),this.err=e}_tag="DisconnectError"},Nc=class extends M{constructor(e){super(e),this.err=e}_tag="ReconnectionFailedError"},Uc=class extends M{constructor(e){super(e),this.err=e}_tag="DeviceNotInitializedError"},Bc=class extends M{constructor(e){super(e),this.err=e}_tag="NoTransportsProvidedError"},Lc=class extends M{constructor(e){super(e),this.err=e}_tag="TransportAlreadyExistsError"},Fc=class extends M{constructor(e){super(e),this.err=e}_tag="DeviceDisconnectedWhileSendingError"},kc=class extends M{constructor(e){super(e),this.err=e}_tag="AlreadySendingApduError"},Vc=class extends M{constructor(e){super(e),this.err=e}_tag="DeviceDisconnectedBeforeSendingApdu"},Gc=class extends M{constructor(e){super(e),this.err=e}_tag="NoTransportProvidedError"}});var Kc=a((Mue,zb)=>{"use strict";var Wc=Object.defineProperty,u1=Object.getOwnPropertyDescriptor,d1=Object.getOwnPropertyNames,l1=Object.prototype.hasOwnProperty,p1=(t,e)=>{for(var r in e)Wc(t,r,{get:e[r],enumerable:!0})},f1=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of d1(e))!l1.call(t,n)&&n!==r&&Wc(t,n,{get:()=>e[n],enumerable:!(i=u1(e,n))||i.enumerable});return t},v1=t=>f1(Wc({},"__esModule",{value:!0}),t),$b={};p1($b,{isDashboardName:()=>h1});zb.exports=v1($b);var g1=["BOLOS","OLOS","OLOS\0"],h1=t=>g1.includes(t)});var kr=a((Tue,Zb)=>{"use strict";var Jc=Object.defineProperty,m1=Object.getOwnPropertyDescriptor,y1=Object.getOwnPropertyNames,b1=Object.prototype.hasOwnProperty,_1=(t,e)=>{for(var r in e)Jc(t,r,{get:e[r],enumerable:!0})},S1=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of y1(e))!b1.call(t,n)&&n!==r&&Jc(t,n,{get:()=>e[n],enumerable:!(i=m1(e,n))||i.enumerable});return t},D1=t=>S1(Jc({},"__esModule",{value:!0}),t),Yb={};_1(Yb,{OpenAppDeviceAction:()=>zc});Zb.exports=D1(Yb);var Jb=b(),be=(Y(),X(Q)),Xb=w(),O1=Fn(),E1=Xa(),$c=Z(),C1=le(),A1=de(),w1=ii(),I1=ee(),Qb=ne(),P1=tt(),x1=Kc(),zc=class extends I1.XStateDeviceAction{makeStateMachine(e){let{closeApp:r,openApp:i,getDeviceSessionState:n,isDeviceOnboarded:o,setDeviceSessionState:s}=this.extractDependencies(e),l=this.input.unlockTimeout??C1.DEFAULT_UNLOCK_TIMEOUT_MS,u=new w1.GetDeviceStatusDeviceAction({input:{unlockTimeout:l}}).makeStateMachine(e);return(0,be.setup)({types:{input:{},context:{},output:{}},actors:{closeApp:(0,be.fromPromise)(r),openApp:(0,be.fromPromise)(i),getDeviceStatus:u},guards:{isDeviceOnboarded:()=>o(),isRequestedAppOpen:({context:d})=>d._internalState.currentlyRunningApp===null?!1:d._internalState.currentlyRunningApp===d.input.appName,isDashboardOpen:({context:d})=>{if(d._internalState.currentlyRunningApp===null)throw new Error("context.currentlyRunningApp === null");return(0,x1.isDashboardName)(d._internalState.currentlyRunningApp)},hasDisconnectedWhileSending:({context:d})=>d._internalState.error!==null&&d._internalState.error instanceof P1.DeviceDisconnectedWhileSendingError,hasError:({context:d})=>d._internalState.error!==null},actions:{assignErrorDeviceNotOnboarded:(0,be.assign)({_internalState:d=>({...d.context._internalState,error:new A1.DeviceNotOnboardedError})}),assignUserActionNeededOpenApp:(0,be.assign)({intermediateValue:d=>({...d.context.intermediateValue,requiredUserInteraction:$c.UserInteractionRequired.ConfirmOpenApp})}),assignNoUserActionNeeded:(0,be.assign)({intermediateValue:d=>({...d.context.intermediateValue,requiredUserInteraction:$c.UserInteractionRequired.None})}),assignErrorFromEvent:(0,be.assign)({_internalState:d=>({...d.context._internalState,error:d.event.error})}),assignNoError:(0,be.assign)({_internalState:d=>({...d.context._internalState,error:null})})}}).createMachine({id:"OpenAppDeviceAction",initial:"DeviceReady",context:({input:d})=>{let c=n(),{sessionStateType:p}=c;return{input:d,intermediateValue:{requiredUserInteraction:$c.UserInteractionRequired.None},_internalState:{error:null,currentlyRunningApp:p===Qb.DeviceSessionStateType.ReadyWithoutSecureChannel?c.currentApp.name:null}}},states:{DeviceReady:{always:{target:"OnboardingCheck"}},OnboardingCheck:{always:[{target:"GetDeviceStatus",guard:{type:"isDeviceOnboarded"}},{target:"Error",actions:"assignErrorDeviceNotOnboarded"}]},GetDeviceStatus:{invoke:{id:"deviceStatus",src:"getDeviceStatus",input:d=>({unlockTimeout:d.context.input.unlockTimeout}),onSnapshot:{actions:(0,be.assign)({intermediateValue:d=>d.event.snapshot.context.intermediateValue})},onDone:{target:"CheckDeviceStatus",actions:(0,be.assign)({_internalState:d=>d.event.output.caseOf({Right:c=>{let p=n();return p.sessionStateType!==Qb.DeviceSessionStateType.Connected&&s({...p,currentApp:{name:c.currentApp,version:c.currentAppVersion}}),{...d.context._internalState,currentlyRunningApp:c.currentApp}},Left:c=>({...d.context._internalState,currentlyRunningApp:null,error:c})})})},onError:{target:"Error",actions:[(0,be.assign)({_internalState:d=>({...d.context._internalState,currentlyRunningApp:null})}),"assignErrorFromEvent"]}}},CheckDeviceStatus:{always:[{target:"ApplicationReady",guard:"isRequestedAppOpen",actions:"assignNoError"},{target:"Error",guard:"hasError"},{target:"DashboardCheck"}]},DashboardCheck:{always:[{target:"OpenApplication",guard:"isDashboardOpen"},"CloseApplication"]},OpenApplication:{entry:"assignUserActionNeededOpenApp",exit:"assignNoUserActionNeeded",invoke:{src:"openApp",input:({context:d})=>({appName:d.input.appName}),onDone:{target:"OpenApplicationResultCheck",actions:(0,be.assign)({_internalState:d=>(0,Xb.isSuccessCommandResult)(d.event.output)?{...d.context._internalState,currentlyRunningApp:d.context.input.appName}:{...d.context._internalState,error:d.event.output.error}})},onError:{target:"OpenApplicationResultCheck",actions:"assignErrorFromEvent"}}},OpenApplicationResultCheck:{always:[{target:"GetDeviceStatus",guard:"hasDisconnectedWhileSending"},{target:"Error",guard:"hasError"},{target:"GetDeviceStatus"}]},CloseApplication:{invoke:{src:"closeApp",onDone:{target:"CloseApplicationResultCheck",actions:(0,be.assign)({_internalState:d=>(0,Xb.isSuccessCommandResult)(d.event.output)?{...d.context._internalState,currentlyRunningApp:"BOLOS"}:{...d.context._internalState,error:d.event.output.error}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},CloseApplicationResultCheck:{always:[{target:"Error",guard:"hasError"},{target:"OpenApplication"}]},ApplicationReady:{always:"Success"},Success:{type:"final",actions:"assignNoError"},Error:{type:"final"}},output:({context:d})=>d._internalState.error?(0,Jb.Left)(d._internalState.error):(0,Jb.Right)(void 0)})}extractDependencies(e){return{closeApp:async()=>e.sendCommand(new O1.CloseAppCommand),openApp:async r=>e.sendCommand(new E1.OpenAppCommand({appName:r.input.appName})),getDeviceSessionState:()=>e.getDeviceSessionState(),setDeviceSessionState:r=>e.setDeviceSessionState(r),isDeviceOnboarded:()=>!0}}}});var i_=a((jue,n_)=>{"use strict";var Qc=Object.defineProperty,M1=Object.getOwnPropertyDescriptor,T1=Object.getOwnPropertyNames,j1=Object.prototype.hasOwnProperty,q1=(t,e)=>{for(var r in e)Qc(t,r,{get:e[r],enumerable:!0})},R1=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of T1(e))!j1.call(t,n)&&n!==r&&Qc(t,n,{get:()=>e[n],enumerable:!(i=M1(e,n))||i.enumerable});return t},N1=t=>R1(Qc({},"__esModule",{value:!0}),t),r_={};q1(r_,{CallTaskInAppDeviceAction:()=>Xc});n_.exports=N1(r_);var e_=b(),ht=(Y(),X(Q)),U1=w(),t_=Z(),B1=de(),L1=kr(),F1=ee(),Xc=class extends F1.XStateDeviceAction{makeStateMachine(e){let{callTask:r}=this.extractDependencies(e);return(0,ht.setup)({types:{input:{},context:{},output:{}},actors:{callTask:(0,ht.fromPromise)(r),openAppStateMachine:new L1.OpenAppDeviceAction({input:{appName:this.input.appName}}).makeStateMachine(e)},guards:{skipOpenApp:()=>this.input.skipOpenApp,noInternalError:({context:i})=>i._internalState.error===null},actions:{assignErrorFromEvent:(0,ht.assign)({_internalState:i=>({...i.context._internalState,error:i.event.error})})}}).createMachine({id:"CallTaskInAppDeviceAction",initial:"InitialState",context:({input:i})=>({input:i,intermediateValue:{requiredUserInteraction:t_.UserInteractionRequired.None},_internalState:{taskResponse:null,error:null}}),states:{InitialState:{always:[{target:"CallTask",guard:"skipOpenApp"},"OpenAppDeviceAction"]},OpenAppDeviceAction:{invoke:{id:"openAppStateMachine",input:{appName:this.input.appName},src:"openAppStateMachine",onSnapshot:{actions:(0,ht.assign)({intermediateValue:i=>i.event.snapshot.context.intermediateValue})},onDone:{actions:(0,ht.assign)({_internalState:i=>i.event.output.caseOf({Right:()=>i.context._internalState,Left:n=>({...i.context._internalState,error:n})})}),target:"CheckOpenAppDeviceActionResult"}}},CheckOpenAppDeviceActionResult:{always:[{target:"CallTask",guard:"noInternalError"},"Error"]},CallTask:{entry:(0,ht.assign)({intermediateValue:{requiredUserInteraction:this.input.requiredUserInteraction}}),exit:(0,ht.assign)({intermediateValue:{requiredUserInteraction:t_.UserInteractionRequired.None}}),invoke:{id:"callTask",src:"callTask",input:i=>i.context.input.task,onDone:{target:"CallTaskResultCheck",actions:[(0,ht.assign)({_internalState:({event:i,context:n})=>(0,U1.isSuccessCommandResult)(i.output)?{...n._internalState,taskResponse:i.output.data}:{...n._internalState,error:i.output.error}})]},onError:{target:"Error",actions:"assignErrorFromEvent"}}},CallTaskResultCheck:{always:[{target:"Success",guard:"noInternalError"},"Error"]},Success:{type:"final"},Error:{type:"final"}},output:({context:i})=>i._internalState.taskResponse?(0,e_.Right)(i._internalState.taskResponse):(0,e_.Left)(i._internalState.error||new B1.UnknownDAError("No error in final state"))})}extractDependencies(e){return{callTask:r=>r.input(e)}}}});var nt=a((que,c_)=>{"use strict";var Zc=Object.defineProperty,k1=Object.getOwnPropertyDescriptor,V1=Object.getOwnPropertyNames,G1=Object.prototype.hasOwnProperty,H1=(t,e)=>{for(var r in e)Zc(t,r,{get:e[r],enumerable:!0})},W1=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of V1(e))!G1.call(t,n)&&n!==r&&Zc(t,n,{get:()=>e[n],enumerable:!(i=k1(e,n))||i.enumerable});return t},K1=t=>W1(Zc({},"__esModule",{value:!0}),t),a_={};H1(a_,{GoToDashboardDeviceAction:()=>Yc});c_.exports=K1(a_);var o_=b(),rt=(Y(),X(Q)),s_=w(),$1=Fn(),z1=jr(),J1=Z(),X1=le(),Q1=de(),Y1=ii(),Z1=ee(),eB=ne(),tB=Kc(),Yc=class extends Z1.XStateDeviceAction{makeStateMachine(e){let{getDeviceSessionState:r,setDeviceSessionState:i,closeApp:n,getAppAndVersion:o}=this.extractDependencies(e),s=this.input.unlockTimeout??X1.DEFAULT_UNLOCK_TIMEOUT_MS,l=new Y1.GetDeviceStatusDeviceAction({input:{unlockTimeout:s}}).makeStateMachine(e);return(0,rt.setup)({types:{input:{unlockTimeout:s},context:{},output:{}},actors:{getAppAndVersion:(0,rt.fromPromise)(o),closeApp:(0,rt.fromPromise)(n),getDeviceStatus:l},guards:{hasError:({context:u})=>u._internalState.error!==null,isDashboardOpen:({context:u})=>u._internalState.currentApp!==null&&(0,tB.isDashboardName)(u._internalState.currentApp)},actions:{assignErrorFromEvent:(0,rt.assign)({_internalState:u=>({...u.context._internalState,error:u.event.error})})}}).createMachine({id:"GoToDashboardDeviceAction",initial:"DeviceReady",context:u=>{let d=r();return{input:{unlockTimeout:u.input.unlockTimeout},intermediateValue:{requiredUserInteraction:J1.UserInteractionRequired.None},_internalState:{currentApp:"currentApp"in d?d.currentApp.name:null,error:null}}},states:{DeviceReady:{always:{target:"GetDeviceStatus"}},GetDeviceStatus:{invoke:{id:"deviceStatus",src:"getDeviceStatus",input:u=>({unlockTimeout:u.context.input.unlockTimeout}),onSnapshot:{actions:(0,rt.assign)({intermediateValue:u=>u.event.snapshot.context.intermediateValue})},onDone:{target:"CheckDeviceStatus",actions:(0,rt.assign)({_internalState:u=>u.event.output.caseOf({Right:d=>({...u.context._internalState,currentApp:d.currentApp}),Left:d=>({...u.context._internalState,error:d})})})}}},CheckDeviceStatus:{always:[{target:"Error",guard:"hasError"},{target:"DashboardCheck"}]},DashboardCheck:{always:[{target:"Success",guard:"isDashboardOpen"},{target:"Error",guard:"hasError"},{target:"Error",guard:u=>u.context._internalState.currentApp===null,actions:(0,rt.assign)({_internalState:u=>({...u.context._internalState,error:new Q1.UnknownDAError("currentApp === null")})})},{target:"CloseApp"}]},CloseApp:{invoke:{src:"closeApp",onDone:{target:"CloseAppCheck",actions:(0,rt.assign)({_internalState:u=>(0,s_.isSuccessCommandResult)(u.event.output)?u.context._internalState:{...u.context._internalState,error:u.event.output.error}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},CloseAppCheck:{always:[{target:"Error",guard:"hasError"},{target:"GetAppAndVersion",reenter:!0}]},GetAppAndVersion:{invoke:{src:"getAppAndVersion",onDone:{target:"DashboardCheck",actions:(0,rt.assign)({_internalState:u=>{if((0,s_.isSuccessCommandResult)(u.event.output)){let d=r();return d.sessionStateType!==eB.DeviceSessionStateType.Connected&&i({...d,currentApp:u.event.output.data}),{...u.context._internalState,currentApp:u.event.output.data.name}}return{...u.context._internalState,error:u.event.output.error}}})}}},Success:{type:"final"},Error:{type:"final"}},output:u=>u.context._internalState.error?(0,o_.Left)(u.context._internalState.error):(0,o_.Right)(void 0)})}extractDependencies(e){return{closeApp:async()=>e.sendCommand(new $1.CloseAppCommand),getAppAndVersion:async()=>e.sendCommand(new z1.GetAppAndVersionCommand),getDeviceSessionState:()=>e.getDeviceSessionState(),setDeviceSessionState:r=>e.setDeviceSessionState(r)}}}});var oi=a((Rue,p_)=>{"use strict";var ru=Object.defineProperty,rB=Object.getOwnPropertyDescriptor,nB=Object.getOwnPropertyNames,iB=Object.prototype.hasOwnProperty,oB=(t,e)=>{for(var r in e)ru(t,r,{get:e[r],enumerable:!0})},sB=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of nB(e))!iB.call(t,n)&&n!==r&&ru(t,n,{get:()=>e[n],enumerable:!(i=rB(e,n))||i.enumerable});return t},aB=t=>sB(ru({},"__esModule",{value:!0}),t),l_={};oB(l_,{ListAppsDeviceAction:()=>tu});p_.exports=aB(l_);var u_=b(),mt=(Y(),X(Q)),d_=w(),cB=Ga(),eu=Z(),uB=le(),dB=nt(),lB=ee(),tu=class extends lB.XStateDeviceAction{makeStateMachine(e){let{listApps:r}=this.extractDependencies(e),i=this.input.unlockTimeout??uB.DEFAULT_UNLOCK_TIMEOUT_MS,n=new dB.GoToDashboardDeviceAction({input:{unlockTimeout:i}}).makeStateMachine(e);return(0,mt.setup)({types:{input:{unlockTimeout:i},context:{},output:{}},actors:{listApps:(0,mt.fromPromise)(r),goToDashboard:n},guards:{hasError:({context:o})=>o._internalState.error!==null,hasMoreApps:o=>o.context._internalState.shouldContinue},actions:{assignAllowListApps:(0,mt.assign)({intermediateValue:o=>({requiredUserInteraction:eu.UserInteractionRequired.AllowListApps})}),assignErrorFromEvent:(0,mt.assign)({_internalState:o=>({...o.context._internalState,error:o.event.error})})}}).createMachine({id:"ListAppsDeviceAction",initial:"DeviceReady",context:o=>({input:{unlockTimeout:o.input.unlockTimeout},intermediateValue:{requiredUserInteraction:eu.UserInteractionRequired.None},_internalState:{error:null,apps:[],shouldContinue:!1}}),states:{DeviceReady:{always:{target:"GoToDashboard"}},GoToDashboard:{invoke:{id:"dashboard",src:"goToDashboard",input:o=>({unlockTimeout:o.context.input.unlockTimeout}),onSnapshot:{actions:(0,mt.assign)({intermediateValue:o=>o.event.snapshot.context.intermediateValue})},onDone:{target:"GoToDashboardCheck",actions:(0,mt.assign)({_internalState:o=>o.event.output.caseOf({Right:()=>o.context._internalState,Left:s=>({...o.context._internalState,error:s})})})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GoToDashboardCheck:{always:[{target:"Error",guard:"hasError"},{target:"ListApps"}]},ListApps:{entry:"assignAllowListApps",invoke:{src:"listApps",input:o=>!1,onDone:{target:"Continue",actions:(0,mt.assign)({_internalState:o=>(0,d_.isSuccessCommandResult)(o.event.output)?{...o.context._internalState,apps:o.context._internalState.apps.concat(o.event.output.data),shouldContinue:o.event.output.data.length>=2}:{...o.context._internalState,error:o.event.output.error},intermediateValue:o=>({...o.context.intermediateValue,requiredUserInteraction:eu.UserInteractionRequired.None})})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},ListAppsCheck:{always:[{target:"Error",guard:"hasError"},"ListAppsContinue"]},ListAppsContinue:{invoke:{src:"listApps",input:o=>!0,onDone:{target:"Continue",actions:(0,mt.assign)({_internalState:o=>(0,d_.isSuccessCommandResult)(o.event.output)?{...o.context._internalState,apps:o.context._internalState.apps.concat(o.event.output.data),shouldContinue:o.event.output.data.length>=2}:{...o.context._internalState,error:o.event.output.error}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},Continue:{always:[{target:"ListAppsContinue",guard:"hasMoreApps"},{target:"Success"}]},Success:{type:"final"},Error:{type:"final"}},output:o=>o.context._internalState.error?(0,u_.Left)(o.context._internalState.error):(0,u_.Right)(o.context._internalState.apps)})}extractDependencies(e){return{listApps:async({input:r})=>{let i=new cB.ListAppsCommand({isContinue:r});return e.sendCommand(i)}}}}});var y_=a((Nue,m_)=>{"use strict";var iu=Object.defineProperty,pB=Object.getOwnPropertyDescriptor,fB=Object.getOwnPropertyNames,vB=Object.prototype.hasOwnProperty,gB=(t,e)=>{for(var r in e)iu(t,r,{get:e[r],enumerable:!0})},hB=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of fB(e))!vB.call(t,n)&&n!==r&&iu(t,n,{get:()=>e[n],enumerable:!(i=pB(e,n))||i.enumerable});return t},mB=t=>hB(iu({},"__esModule",{value:!0}),t),h_={};gB(h_,{ListLanguagePackCommand:()=>nu,ListLanguagePackCommandError:()=>si});m_.exports=mB(h_);var yB=Oe(),bB=Ee(),f_=Je(),dr=w(),_B=ft(),SB=ye(),DB=Be(),OB=Xe(),v_=jt(),g_={"662d":{message:"Invalid LIST_ARG, first command must be sent with P1_LIST_LANGUAGE_PACKS_FIRST."}},si=class extends OB.DeviceExchangeError{constructor({message:e,errorCode:r}){super({message:e,errorCode:r,tag:"ListLanguagePackCommandError"})}},nu=class{constructor(e){this.args=e}name="listLanguagePack";getApdu(){let e={cla:224,ins:52,p1:this.args.firstChunk?0:1,p2:0};return new yB.ApduBuilder(e).build()}parseResponse(e){let r=new bB.ApduParser(e);if(!SB.CommandUtils.isSuccessResponse(e)){let l=r.encodeToHexaString(e.statusCode);return(0,_B.isCommandErrorCode)(l,g_)?(0,dr.CommandResultFactory)({error:new si({...g_[l],errorCode:l})}):(0,dr.CommandResultFactory)({error:DB.GlobalCommandErrorHandler.handle(e)})}if(r.extract8BitUInt()===void 0)return(0,dr.CommandResultFactory)({data:void 0});r.extract8BitUInt();let i=r.extractFieldLVEncoded();if(i===void 0)return(0,dr.CommandResultFactory)({error:new f_.InvalidStatusWordError("Failed to get language pack id")});let n=r.extractFieldLVEncoded();if(n===void 0)return(0,dr.CommandResultFactory)({error:new f_.InvalidStatusWordError("Failed to get language pack size")});let o=parseInt((0,v_.bufferToHexaString)(i),16),s=parseInt((0,v_.bufferToHexaString)(n),16);return(0,dr.CommandResultFactory)({data:{id:o,size:s}})}}});var D_=a((Uue,S_)=>{"use strict";var su=Object.defineProperty,EB=Object.getOwnPropertyDescriptor,CB=Object.getOwnPropertyNames,AB=Object.prototype.hasOwnProperty,wB=(t,e)=>{for(var r in e)su(t,r,{get:e[r],enumerable:!0})},IB=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of CB(e))!AB.call(t,n)&&n!==r&&su(t,n,{get:()=>e[n],enumerable:!(i=EB(e,n))||i.enumerable});return t},PB=t=>IB(su({},"__esModule",{value:!0}),t),__={};wB(__,{GetApplicationsMetadataTask:()=>ou});S_.exports=PB(__);var xB=Bn(),b_=Je(),ai=w(),MB=y_(),TB="0000000000000000000000000000000000000000000000000000000000000000",ou=class{constructor(e,r){this.api=e,this.args=r}async run(){let e=this.args.installedApps.filter(p=>this.isApplication(p)),r=this.api.getManagerApiService(),i=e.map(p=>p.hash),n=await r.getAppsByHash(i).chain(p=>r.getAppList(this.args.firmwareVersion.metadata).map(v=>({applications:p,catalog:v})));if(n.isLeft())return(0,ai.CommandResultFactory)({error:new b_.InvalidStatusWordError("Cannot get the application catalog")});let{applications:o,catalog:s}=n.unsafeCoerce(),l=o.reduce((p,v,y)=>{if(v!==null)return[...p,v];let oe=e[y],Se=s.find(pt=>pt.versionName===oe.name);return Se?[...p,Se]:p},[]),u=o.filter(p=>p!==null).reduce((p,v)=>{let y=s.find(oe=>oe.versionName===v.versionName);return y&&(0,xB.gt)(y.version,v.version)?[...p,y]:p},[]),d=[];for(let p=0;;p++){let v=await this.api.sendCommand(new MB.ListLanguagePackCommand({firstChunk:p===0}));if(!(0,ai.isSuccessCommandResult)(v)||v.data===void 0)break;d=[...d,v.data]}let c=await r.getLanguagePackages(this.args.deviceVersion,this.args.firmware);return c.isRight()?(0,ai.CommandResultFactory)({data:{applications:l,applicationsUpdates:u,installedLanguages:d,catalog:{applications:s,languagePackages:c.extract()}}}):(0,ai.CommandResultFactory)({error:new b_.InvalidStatusWordError("Cannot get the languages catalog")})}isApplication(e){return e.hashCode!==TB}}});var C_=a((Bue,E_)=>{"use strict";var cu=Object.defineProperty,jB=Object.getOwnPropertyDescriptor,qB=Object.getOwnPropertyNames,RB=Object.prototype.hasOwnProperty,NB=(t,e)=>{for(var r in e)cu(t,r,{get:e[r],enumerable:!0})},UB=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of qB(e))!RB.call(t,n)&&n!==r&&cu(t,n,{get:()=>e[n],enumerable:!(i=jB(e,n))||i.enumerable});return t},BB=t=>UB(cu({},"__esModule",{value:!0}),t),O_={};NB(O_,{GetFirmwareMetadataTask:()=>au});E_.exports=BB(O_);var LB=Je(),ci=w(),FB=Ma(),kB=qt(),au=class{constructor(e){this.api=e}async run(){let e=await this.api.sendCommand(new kB.GetOsVersionCommand);if(!(0,ci.isSuccessCommandResult)(e))return e;let r={mcu:e.data.mcuSephVersion,bootloader:e.data.mcuBootloaderVersion,os:e.data.seVersion,metadata:e.data},i=this.api.getManagerApiService(),n=await i.getDeviceVersion(e.data).chain(p=>i.getFirmwareVersion(e.data,p).map(v=>({deviceVersion:p,currentFirmware:v})));if(n.isLeft())return(0,ci.CommandResultFactory)({error:new LB.InvalidGetFirmwareMetadataResponseError});let{deviceVersion:o,currentFirmware:s}=n.unsafeCoerce(),l=(await i.getLatestFirmwareVersion(s,o).chain(p=>i.getNextFirmwareVersion(p).chain(v=>i.getMcuList().map(y=>y.find(oe=>oe.name===r.mcu)).map(y=>y===void 0||!v.mcuVersions.includes(y.id)).map(y=>({osuFirmware:p,finalFirmware:v,mcuUpdateRequired:y}))))).caseOf({Right:p=>p,Left:p=>{}}),u={currentFirmware:s,availableUpdate:l},d={},c=await this.api.sendCommand(new FB.GetBackgroundImageSizeCommand);return(0,ci.isSuccessCommandResult)(c)&&(d={size:c.data}),(0,ci.CommandResultFactory)({data:{deviceVersion:o,firmware:s,firmwareVersion:r,firmwareUpdateContext:u,customImage:d}})}}});var du=a((Lue,w_)=>{"use strict";var uu=Object.defineProperty,VB=Object.getOwnPropertyDescriptor,GB=Object.getOwnPropertyNames,HB=Object.prototype.hasOwnProperty,WB=(t,e)=>{for(var r in e)uu(t,r,{get:e[r],enumerable:!0})},KB=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of GB(e))!HB.call(t,n)&&n!==r&&uu(t,n,{get:()=>e[n],enumerable:!(i=VB(e,n))||i.enumerable});return t},$B=t=>KB(uu({},"__esModule",{value:!0}),t),A_={};WB(A_,{installedAppResultGuard:()=>zB});w_.exports=$B(A_);function zB(t){return Array.isArray(t)&&t.every(e=>typeof e=="object"&&e!==null&&"flags"in e&&"hash"in e&&"hash_code_data"in e&&"name"in e&&typeof e.flags=="number"&&typeof e.hash=="string"&&typeof e.hash_code_data=="string"&&typeof e.name=="string")}});var yt=a((Fue,j_)=>{"use strict";var lu=Object.defineProperty,JB=Object.getOwnPropertyDescriptor,XB=Object.getOwnPropertyNames,QB=Object.prototype.hasOwnProperty,YB=(t,e)=>{for(var r in e)lu(t,r,{get:e[r],enumerable:!0})},ZB=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of XB(e))!QB.call(t,n)&&n!==r&&lu(t,n,{get:()=>e[n],enumerable:!(i=JB(e,n))||i.enumerable});return t},eL=t=>ZB(lu({},"__esModule",{value:!0}),t),I_={};YB(I_,{InMessageQueryEnum:()=>x_,OutMessageResponseEnum:()=>M_,SecureChannelEventType:()=>T_,SecureChannelOperationEnum:()=>P_});j_.exports=eL(I_);var P_=(t=>(t.GenuineCheck="GenuineCheck",t.ListInstalledApps="ListInstalledApps",t.UpdateMcu="UpdateMcu",t.UpdateFirmware="UpdateFirmware",t.InstallApp="InstallApp",t.UninstallApp="UninstallApp",t))(P_||{}),x_=(t=>(t.EXCHANGE="exchange",t.BULK="bulk",t.ERROR="error",t.WARNING="warning",t.SUCCESS="success",t))(x_||{}),M_=(t=>(t.SUCCESS="success",t.ERROR="error",t))(M_||{}),T_=(t=>(t.Opened="opened",t.Closed="closed",t.PermissionRequested="permission-requested",t.PermissionGranted="permission-granted",t.PreExchange="pre-exchange",t.Exchange="exchange",t.DeviceId="device-id",t.Progress="progress",t.Warning="warning",t.Error="error",t.Result="result",t))(T_||{})});var N_=a((kue,R_)=>{"use strict";var pu=Object.defineProperty,tL=Object.getOwnPropertyDescriptor,rL=Object.getOwnPropertyNames,nL=Object.prototype.hasOwnProperty,iL=(t,e)=>{for(var r in e)pu(t,r,{get:e[r],enumerable:!0})},oL=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of rL(e))!nL.call(t,n)&&n!==r&&pu(t,n,{get:()=>e[n],enumerable:!(i=tL(e,n))||i.enumerable});return t},sL=t=>oL(pu({},"__esModule",{value:!0}),t),q_={};iL(q_,{GENUINE_DEVICE_RESULT:()=>aL});R_.exports=sL(q_);var aL="0000"});var vu=a((Vue,B_)=>{"use strict";var fu=Object.defineProperty,cL=Object.getOwnPropertyDescriptor,uL=Object.getOwnPropertyNames,dL=Object.prototype.hasOwnProperty,lL=(t,e)=>{for(var r in e)fu(t,r,{get:e[r],enumerable:!0})},pL=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of uL(e))!dL.call(t,n)&&n!==r&&fu(t,n,{get:()=>e[n],enumerable:!(i=cL(e,n))||i.enumerable});return t},fL=t=>pL(fu({},"__esModule",{value:!0}),t),U_={};lL(U_,{extractPublicKey:()=>yL,isDeviceGenuine:()=>bL,isGetCertificateApdu:()=>mL,willRequestPermission:()=>hL});B_.exports=fL(U_);var vL=Ee(),gL=N_();function hL(t){return t[0]===224&&t[1]===81}function mL(t){return t[0]===224&&t[1]===82}function yL(t){try{let e=new vL.ApduParser(t);return e.extractFieldLVEncoded()?e.extractFieldLVEncoded()??null:null}catch{return null}}function bL(t){return t===gL.GENUINE_DEVICE_RESULT}});var k_=a((Gue,F_)=>{"use strict";var hu=Object.defineProperty,_L=Object.getOwnPropertyDescriptor,SL=Object.getOwnPropertyNames,DL=Object.prototype.hasOwnProperty,OL=(t,e)=>{for(var r in e)hu(t,r,{get:e[r],enumerable:!0})},EL=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of SL(e))!DL.call(t,n)&&n!==r&&hu(t,n,{get:()=>e[n],enumerable:!(i=_L(e,n))||i.enumerable});return t},CL=t=>EL(hu({},"__esModule",{value:!0}),t),L_={};OL(L_,{NobleCryptoService:()=>gu});F_.exports=CL(L_);var AL=E("@noble/hashes/sha3"),gu=class{sha3_256(e){return(0,AL.sha3_256)(e)}}});var ui=a((Hue,H_)=>{"use strict";var bu=Object.defineProperty,wL=Object.getOwnPropertyDescriptor,IL=Object.getOwnPropertyNames,PL=Object.prototype.hasOwnProperty,xL=(t,e)=>{for(var r in e)bu(t,r,{get:e[r],enumerable:!0})},ML=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of IL(e))!PL.call(t,n)&&n!==r&&bu(t,n,{get:()=>e[n],enumerable:!(i=wL(e,n))||i.enumerable});return t},TL=t=>ML(bu({},"__esModule",{value:!0}),t),V_={};xL(V_,{SecureChannelError:()=>yu,SecureChannelErrorType:()=>G_,WebSocketConnectionError:()=>mu});H_.exports=TL(V_);var lr=de(),G_=(t=>(t[t.AppAlreadyInstalled=0]="AppAlreadyInstalled",t[t.DeviceLocked=1]="DeviceLocked",t[t.OutOfMemory=2]="OutOfMemory",t[t.RefusedByUser=3]="RefusedByUser",t[t.Unknown=4]="Unknown",t))(G_||{}),mu=class{constructor(e){this.error=e,this.originalError=e}_tag="WebSocketConnectionError";originalError},yu=class{constructor(e,r=4){this.error=e,this.errorType=r,this.originalError=e}_tag="SecureChannelError";originalError;mapDAErrors(){switch(this.errorType){case 1:return new lr.DeviceLockedError;case 3:return new lr.RefusedByUserDAError;default:return this}}mapInstallDAErrors(){switch(this.errorType){case 1:return new lr.DeviceLockedError;case 3:return new lr.RefusedByUserDAError;case 0:return new lr.AppAlreadyInstalledDAError;case 2:return new lr.OutOfMemoryDAError;default:return this}}}});var Lt=a((Wue,$_)=>{"use strict";var jL=Object.create,li=Object.defineProperty,qL=Object.getOwnPropertyDescriptor,RL=Object.getOwnPropertyNames,NL=Object.getPrototypeOf,UL=Object.prototype.hasOwnProperty,BL=(t,e)=>{for(var r in e)li(t,r,{get:e[r],enumerable:!0})},W_=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of RL(e))!UL.call(t,n)&&n!==r&&li(t,n,{get:()=>e[n],enumerable:!(i=qL(e,n))||i.enumerable});return t},LL=(t,e,r)=>(r=t!=null?jL(NL(t)):{},W_(e||!t||!t.__esModule?li(r,"default",{value:t,enumerable:!0}):r,t)),FL=t=>W_(li({},"__esModule",{value:!0}),t),K_={};BL(K_,{ConnectToSecureChannelTask:()=>Su});$_.exports=FL(K_);var kL=LL(Km()),VL=De(),Vr=ye(),T=yt(),_u=vu(),di=jt(),GL=k_(),L=ui(),Su=class{constructor(e,r){if(this._api=e,this._args=r,this._args.connection.isRight())this._connection=this._args.connection.extract();else throw new L.SecureChannelError(`Invalid WebSocket connection: ${String(this._args.connection.extract())}`);this._cryptoService=this._args.cryptoService??new GL.NobleCryptoService}_connection;_cryptoService;_deviceIdCaptured=!1;run(){return new VL.Observable(e=>{let r=!1,i=!1,n=!1,o=s=>{e.next({type:T.SecureChannelEventType.Error,error:s}),e.complete(),i=!0};return this._connection.onopen=()=>{e.next({type:T.SecureChannelEventType.Opened})},this._connection.onerror=s=>{i||(e.next({type:T.SecureChannelEventType.Error,error:new L.SecureChannelError({url:this._connection.url,errorMessage:s.message})}),e.complete())},this._connection.onclose=()=>{i||(n?e.next({type:T.SecureChannelEventType.Closed}):e.next({type:T.SecureChannelEventType.Error,error:new L.SecureChannelError({url:this._connection.url,errorMessage:"Connection closed unexpectedly"})}),e.complete())},this._connection.onmessage=async s=>{if(r)return;let l;try{let u=JSON.parse(String(s.data));if(this.isInMessageType(u))l=u;else throw new Error("Data does not match InMessageType")}catch{o(new L.SecureChannelError({url:this._connection.url,errorMessage:`Invalid message received: ${String(s.data)}`}));return}switch(l.query){case T.InMessageQueryEnum.EXCHANGE:{let{nonce:u,data:d}=l;if(typeof d!="string"){o(new L.SecureChannelError(`${T.InMessageQueryEnum.EXCHANGE} data type should be an APDU`));return}let c=(0,di.hexaStringToBuffer)(d);if(c===null||c.length<5){o(new L.SecureChannelError(`Received invalid APDU data: ${d}`));return}e.next({type:T.SecureChannelEventType.PreExchange,payload:{nonce:u,apdu:c}});let p=!1;(0,_u.willRequestPermission)(c)&&!this.isSecureConnectionAllowed()&&(p=!0,e.next({type:T.SecureChannelEventType.PermissionRequested}));let v=await this._api.sendApdu(c);if(r)return;v.caseOf({Left:y=>{o(new L.SecureChannelError(y))},Right:y=>{let oe,Se=this.mapDeviceError(y);if(Se===null){if(oe=T.OutMessageResponseEnum.SUCCESS,!this._deviceIdCaptured&&(0,_u.isGetCertificateApdu)(c)){this._deviceIdCaptured=!0;let Tt=(0,_u.extractPublicKey)(y);if(Tt){let se=this._cryptoService.sha3_256(Tt);e.next({type:T.SecureChannelEventType.DeviceId,payload:{deviceId:se}})}}e.next({type:T.SecureChannelEventType.Exchange,payload:{nonce:u,apdu:c,data:y.data,status:y.statusCode}}),p&&e.next({type:T.SecureChannelEventType.PermissionGranted})}else oe=T.OutMessageResponseEnum.ERROR,o(Se);let pt={nonce:u,response:oe,data:(0,di.bufferToHexaString)(y.data,!1)};this._connection.send(JSON.stringify(pt))}});break}case T.InMessageQueryEnum.BULK:{if(i=!0,this._connection.close(),!Array.isArray(l.data)||l.data.length===0||!l.data.every(u=>typeof u=="string")){o(new L.SecureChannelError("Invalid bulk data received"));return}for(let u=0,d=l.data.length;u<d;u++){let c=(0,di.hexaStringToBuffer)(l.data[u]);if(c===null||c.length<5){o(new L.SecureChannelError(`Received invalid APDU bulk data: ${l.data[u]}`));return}let p=await this._api.sendApdu(c);if(r)return;if(p.isLeft()){o(new L.SecureChannelError(p.extract()));return}else if(p.isRight()){let v=this.mapDeviceError(p.extract());if(v===null)e.next({type:T.SecureChannelEventType.Progress,payload:{progress:+Number((u+1)/d).toFixed(2),index:u,total:d}});else{o(v);return}}}n=!0,e.complete();break}case T.InMessageQueryEnum.SUCCESS:{if(i)break;let u=l.result??l.data;u&&e.next({type:T.SecureChannelEventType.Result,payload:u??""}),n=!0,e.complete();break}case T.InMessageQueryEnum.WARNING:{if(i)break;e.next({type:T.SecureChannelEventType.Warning,payload:{message:String(l.data)}});break}case T.InMessageQueryEnum.ERROR:{if(i)break;o(new L.SecureChannelError({url:this._connection.url,errorMessage:String(l.data)}))}}},()=>{r=!0,this._connection.readyState===kL.default.OPEN&&this._connection.close()}})}isSecureConnectionAllowed(){let e=this._api.getDeviceSessionState();return"isSecureConnectionAllowed"in e&&e.isSecureConnectionAllowed}isInMessageType(e){if(typeof e!="object"||!e)return!1;let r=e;return typeof r.uuid=="string"&&typeof r.session=="string"&&typeof r.query=="string"&&Object.values(T.InMessageQueryEnum).includes(r.query)&&typeof r.nonce=="number"}mapDeviceError(e){return Vr.CommandUtils.isSuccessResponse(e)?null:Vr.CommandUtils.isLockedDeviceResponse(e)?new L.SecureChannelError({url:this._connection.url,errorMessage:"Device is locked"},L.SecureChannelErrorType.DeviceLocked):Vr.CommandUtils.isRefusedByUser(e)?new L.SecureChannelError({url:this._connection.url,errorMessage:"User refused on the device"},L.SecureChannelErrorType.RefusedByUser):Vr.CommandUtils.isAppAlreadyInstalled(e)?new L.SecureChannelError({url:this._connection.url,errorMessage:"App already installed"},L.SecureChannelErrorType.AppAlreadyInstalled):Vr.CommandUtils.isOutOfMemory(e)?new L.SecureChannelError({url:this._connection.url,errorMessage:"Out of memory"},L.SecureChannelErrorType.OutOfMemory):new L.SecureChannelError({url:this._connection.url,errorMessage:`Invalid status code: ${(0,di.bufferToHexaString)(e.statusCode)}`})}}});var fi=a((Kue,Q_)=>{"use strict";var Ou=Object.defineProperty,HL=Object.getOwnPropertyDescriptor,WL=Object.getOwnPropertyNames,KL=Object.prototype.hasOwnProperty,$L=(t,e)=>{for(var r in e)Ou(t,r,{get:e[r],enumerable:!0})},zL=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of WL(e))!KL.call(t,n)&&n!==r&&Ou(t,n,{get:()=>e[n],enumerable:!(i=HL(e,n))||i.enumerable});return t},JL=t=>zL(Ou({},"__esModule",{value:!0}),t),X_={};$L(X_,{GetDeviceMetadataDeviceAction:()=>Du});Q_.exports=JL(X_);var z_=b(),G=(Y(),X(Q)),J_=w(),pr=Z(),XL=le(),QL=nt(),YL=oi(),ZL=D_(),eF=C_(),tF=ee(),pi=ne(),rF=du(),nF=Lt(),Gr=yt(),Du=class extends tF.XStateDeviceAction{makeStateMachine(e){let{getDeviceMetadata:r,getFirmwareMetadata:i,getApplicationsMetadata:n,listAppsSecureChannel:o}=this.extractDependencies(e),s=this.input.unlockTimeout??XL.DEFAULT_UNLOCK_TIMEOUT_MS,l=new QL.GoToDashboardDeviceAction({input:{unlockTimeout:s}}).makeStateMachine(e),u=new YL.ListAppsDeviceAction({input:{unlockTimeout:s}}).makeStateMachine(e);return(0,G.setup)({types:{input:{unlockTimeout:s},context:{},output:{}},actors:{goToDashboard:l,getDeviceMetadata:(0,G.fromPromise)(r),getFirmwareMetadata:(0,G.fromPromise)(i),getApplicationsMetadata:(0,G.fromPromise)(n),listApps:u,listAppsSecureChannel:(0,G.fromObservable)(o)},guards:{hasError:({context:d})=>d._internalState.error!==null,hasMetadata:({context:d})=>d._internalState.firmwareVersion!==null&&d._internalState.firmwareUpdateContext!==null&&d._internalState.customImage!==null&&d._internalState.applications!==null&&d._internalState.applicationsUpdates!==null&&d._internalState.installedLanguages!==null&&d._internalState.catalog!==null,forceUpdate:({context:d})=>!!d.input.forceUpdate,useSecureChannel:({context:d})=>!!d.input.useSecureChannel},actions:{assignErrorFromEvent:(0,G.assign)({_internalState:d=>({...d.context._internalState,error:d.event.error})})}}).createMachine({id:"GetDeviceMetadataDeviceAction",initial:"DeviceReady",context:d=>({input:{useSecureChannel:d.input.useSecureChannel,forceUpdate:d.input.forceUpdate,unlockTimeout:d.input.unlockTimeout},intermediateValue:{requiredUserInteraction:pr.UserInteractionRequired.None},_internalState:{error:null,deviceVersion:null,firmware:null,firmwareVersion:null,firmwareUpdateContext:null,customImage:null,installedApps:null,applications:null,applicationsUpdates:null,installedLanguages:null,catalog:null}}),states:{DeviceReady:{always:[{target:"GoToDashboard",guard:"forceUpdate"},{target:"GetDeviceMetadataFromContext"}]},GetDeviceMetadataFromContext:{invoke:{src:"getDeviceMetadata",onDone:{target:"GetDeviceMetadataFromContextResultCheck",actions:(0,G.assign)({_internalState:d=>d.event.output===null?d.context._internalState:{...d.context._internalState,firmwareVersion:d.event.output.firmwareVersion,firmwareUpdateContext:d.event.output.firmwareUpdateContext,customImage:d.event.output.customImage,applications:d.event.output.applications,applicationsUpdates:d.event.output.applicationsUpdates,installedLanguages:d.event.output.installedLanguages,catalog:d.event.output.catalog}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GetDeviceMetadataFromContextResultCheck:{always:[{target:"Success",guard:"hasMetadata"},{target:"GoToDashboard"}]},GoToDashboard:{exit:(0,G.assign)({intermediateValue:{requiredUserInteraction:pr.UserInteractionRequired.None}}),invoke:{id:"dashboard",src:"goToDashboard",input:d=>({unlockTimeout:d.context.input.unlockTimeout}),onSnapshot:{actions:(0,G.assign)({intermediateValue:d=>d.event.snapshot.context.intermediateValue})},onDone:{target:"GoToDashboardCheck",actions:(0,G.assign)({_internalState:d=>d.event.output.caseOf({Right:()=>d.context._internalState,Left:c=>({...d.context._internalState,error:c})})})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GoToDashboardCheck:{always:[{target:"Error",guard:"hasError"},{target:"GetFirmwareMetadata"}]},GetFirmwareMetadata:{invoke:{src:"getFirmwareMetadata",onDone:{target:"GetFirmwareMetadataResultCheck",actions:(0,G.assign)({_internalState:d=>{if((0,J_.isSuccessCommandResult)(d.event.output)){let c=e.getDeviceSessionState();return c.sessionStateType!==pi.DeviceSessionStateType.Connected&&e.setDeviceSessionState({...c,firmwareVersion:d.event.output.data.firmwareVersion,firmwareUpdateContext:d.event.output.data.firmwareUpdateContext,customImage:d.event.output.data.customImage}),{...d.context._internalState,deviceVersion:d.event.output.data.deviceVersion,firmware:d.event.output.data.firmware,firmwareVersion:d.event.output.data.firmwareVersion,firmwareUpdateContext:d.event.output.data.firmwareUpdateContext,customImage:d.event.output.data.customImage}}return{...d.context._internalState,error:d.event.output.error}}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GetFirmwareMetadataResultCheck:{always:[{guard:"hasError",target:"Error"},{guard:"useSecureChannel",target:"ListAppsSecureChannel"},{target:"ListApps"}]},ListAppsSecureChannel:{exit:(0,G.assign)({intermediateValue:{requiredUserInteraction:pr.UserInteractionRequired.None}}),invoke:{id:"listAppsSecureChannel",src:"listAppsSecureChannel",input:d=>({firmware:d.context._internalState.firmware,firmwareVersion:d.context._internalState.firmwareVersion}),onSnapshot:{actions:(0,G.assign)({intermediateValue:d=>{switch(d.event.snapshot.context?.type){case Gr.SecureChannelEventType.DeviceId:return{...d.context.intermediateValue,deviceId:d.event.snapshot.context.payload.deviceId};case Gr.SecureChannelEventType.PermissionRequested:return{...d.context.intermediateValue,requiredUserInteraction:pr.UserInteractionRequired.AllowSecureConnection};case Gr.SecureChannelEventType.PermissionGranted:{let c=e.getDeviceSessionState();return c.sessionStateType!==pi.DeviceSessionStateType.Connected&&e.setDeviceSessionState({...c,isSecureConnectionAllowed:!0}),{...d.context.intermediateValue,requiredUserInteraction:pr.UserInteractionRequired.None}}default:return{...d.context.intermediateValue}}},_internalState:d=>{if(d.event.snapshot.context?.type===Gr.SecureChannelEventType.Error)return{...d.context._internalState,error:d.event.snapshot.context.error.mapDAErrors()};if(d.event.snapshot.context?.type===Gr.SecureChannelEventType.Result){if((0,rF.installedAppResultGuard)(d.event.snapshot.context.payload))return{...d.context._internalState,installedApps:d.event.snapshot.context.payload.map(c=>({name:c.name,hash:c.hash,hashCode:c.hash_code_data}))};throw new Error(`Invalid result ${JSON.stringify(d.event.snapshot.context.payload)}`)}return{...d.context._internalState}}})},onDone:{target:"ListAppsCheck"},onError:{target:"Error",actions:"assignErrorFromEvent"}}},ListApps:{exit:(0,G.assign)({intermediateValue:{requiredUserInteraction:pr.UserInteractionRequired.None}}),invoke:{id:"listApps",src:"listApps",input:d=>({unlockTimeout:d.context.input.unlockTimeout}),onSnapshot:{actions:(0,G.assign)({intermediateValue:d=>d.event.snapshot.context.intermediateValue})},onDone:{target:"ListAppsCheck",actions:(0,G.assign)({_internalState:d=>d.event.output.isLeft()?{...d.context._internalState,error:d.event.output.extract()}:{...d.context._internalState,installedApps:d.event.output.unsafeCoerce().map(c=>({name:c.appName,hash:c.appFullHash,hashCode:c.appCodeHash}))}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},ListAppsCheck:{always:[{target:"Error",guard:"hasError"},{target:"GetApplicationsMetadata"}]},GetApplicationsMetadata:{invoke:{src:"getApplicationsMetadata",input:d=>({deviceVersion:d.context._internalState.deviceVersion,firmware:d.context._internalState.firmware,firmwareVersion:d.context._internalState.firmwareVersion,installedApps:d.context._internalState.installedApps}),onDone:{target:"GetApplicationsMetadataResultCheck",actions:(0,G.assign)({_internalState:d=>{if((0,J_.isSuccessCommandResult)(d.event.output)){let c=e.getDeviceSessionState();return c.sessionStateType!==pi.DeviceSessionStateType.Connected&&e.setDeviceSessionState({...c,installedApps:d.event.output.data.applications,appsUpdates:d.event.output.data.applicationsUpdates,installedLanguages:d.event.output.data.installedLanguages,catalog:d.event.output.data.catalog}),{...d.context._internalState,applications:d.event.output.data.applications,applicationsUpdates:d.event.output.data.applicationsUpdates,installedLanguages:d.event.output.data.installedLanguages,catalog:d.event.output.data.catalog}}return{...d.context._internalState,error:d.event.output.error}}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GetApplicationsMetadataResultCheck:{always:[{guard:"hasError",target:"Error"},{target:"Success"}]},Success:{type:"final"},Error:{type:"final"}},output:d=>{let{context:c}=d,{error:p,firmwareVersion:v,firmwareUpdateContext:y,customImage:oe,applications:Se,applicationsUpdates:pt,installedLanguages:Tt,catalog:se}=c._internalState;return p?(0,z_.Left)(p):(0,z_.Right)({firmwareVersion:v,firmwareUpdateContext:y,customImage:oe,applications:Se,applicationsUpdates:pt,installedLanguages:Tt,catalog:se})}})}extractDependencies(e){return{getDeviceMetadata:()=>{let r=e.getDeviceSessionState();return r.sessionStateType===pi.DeviceSessionStateType.Connected||r.firmwareVersion?.metadata===void 0||r.firmwareUpdateContext===void 0||r.customImage===void 0||r.installedApps.length===0||r.appsUpdates===void 0||r.installedLanguages===void 0||r.catalog===void 0?Promise.resolve(null):Promise.resolve({firmwareVersion:r.firmwareVersion,firmwareUpdateContext:r.firmwareUpdateContext,customImage:r.customImage,applications:r.installedApps,applicationsUpdates:r.appsUpdates,installedLanguages:r.installedLanguages,catalog:r.catalog})},getFirmwareMetadata:async()=>new eF.GetFirmwareMetadataTask(e).run(),getApplicationsMetadata:async r=>new ZL.GetApplicationsMetadataTask(e,{deviceVersion:r.input.deviceVersion,firmware:r.input.firmware,firmwareVersion:r.input.firmwareVersion,installedApps:r.input.installedApps}).run(),listAppsSecureChannel:r=>{let{firmware:i,firmwareVersion:n}=r.input,o=e.getSecureChannelService().listInstalledApps(n.metadata,i);return new nF.ConnectToSecureChannelTask(e,{connection:o}).run()}}}}});var tS=a(($ue,eS)=>{"use strict";var Cu=Object.defineProperty,iF=Object.getOwnPropertyDescriptor,oF=Object.getOwnPropertyNames,sF=Object.prototype.hasOwnProperty,aF=(t,e)=>{for(var r in e)Cu(t,r,{get:e[r],enumerable:!0})},cF=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of oF(e))!sF.call(t,n)&&n!==r&&Cu(t,n,{get:()=>e[n],enumerable:!(i=iF(e,n))||i.enumerable});return t},uF=t=>cF(Cu({},"__esModule",{value:!0}),t),Z_={};aF(Z_,{BuildAppsInstallPlanTask:()=>Eu});eS.exports=uF(Z_);var Y_=Bn(),Hr=de(),dF=ne(),Eu=class{constructor(e,r){this.api=e,this.args=r;let i=e.getDeviceModel();this.deviceModelId=i.id}deviceModelId;run(){let e=this.api.getDeviceSessionState();if(e.sessionStateType===dF.DeviceSessionStateType.Connected)return{error:new Hr.UnknownDAError("Invalid device state")};if(e.catalog===void 0)return{error:new Hr.UnknownDAError("Device apps metadata not fetched")};let r=[],i=[],n=[];for(let o of this.args.applications){let s=e.catalog.applications.find(u=>u.versionName===o.name),l=e.installedApps.find(u=>u.versionName===o.name);if(l!==void 0&&this.validateConstraint(l,s,o.constraints)){i=[...i,o.name];continue}if(s!==void 0&&this.validateConstraint(s,void 0,o.constraints))r=[...r,s];else if(this.args.allowMissingApplication)n=[...n,o.name];else return e.firmwareUpdateContext?.availableUpdate!==void 0&&s!==void 0?{error:new Hr.UnsupportedFirmwareDAError(`Application ${o.name} needs latest firmware`)}:e.firmwareUpdateContext?.availableUpdate!==void 0?{error:new Hr.UnsupportedFirmwareDAError(`Application ${o.name} needs latest firmware`)}:{error:new Hr.UnsupportedApplicationDAError(`Application ${o.name} not supported for this device`)}}return r=[...r.reduce((o,s)=>{let l=s.parentName;if(l){let u=e.catalog.applications.find(c=>c.versionName===l),d=e.installedApps.find(c=>c.versionName===l);if(u&&!d)return[...o,u]}return o},[]),...r],{installPlan:r.filter((o,s)=>r.findIndex(l=>l.versionName===o.versionName)===s),missingApplications:n,alreadyInstalled:i}}validateConstraint(e,r,i){if(i===void 0)return!0;for(let n of i)if(!(n.exemptModels!==void 0&&n.exemptModels.includes(this.deviceModelId))&&!(n.applicableModels!==void 0&&!n.applicableModels.includes(this.deviceModelId)))return n.minVersion==="latest"?!r||(0,Y_.gte)(e.version,r.version):(0,Y_.gte)(e.version,n.minVersion);return!0}}});var oS=a((zue,iS)=>{"use strict";var wu=Object.defineProperty,lF=Object.getOwnPropertyDescriptor,pF=Object.getOwnPropertyNames,fF=Object.prototype.hasOwnProperty,vF=(t,e)=>{for(var r in e)wu(t,r,{get:e[r],enumerable:!0})},gF=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of pF(e))!fF.call(t,n)&&n!==r&&wu(t,n,{get:()=>e[n],enumerable:!(i=lF(e,n))||i.enumerable});return t},hF=t=>gF(wu({},"__esModule",{value:!0}),t),nS={};vF(nS,{PredictOutOfMemoryTask:()=>Au});iS.exports=hF(nS);var rS=de(),mF=ne(),Au=class{constructor(e,r){this.api=e,this.args=r,this.deviceModel=e.getDeviceModel()}deviceModel;run(){let e=this.api.getDeviceSessionState();if(e.sessionStateType===mF.DeviceSessionStateType.Connected)return{error:new rS.UnknownDAError("Invalid device state")};let{firmwareUpdateContext:r,customImage:i,firmwareVersion:n,installedLanguages:o,installedApps:s}=e;if(r===void 0||i===void 0||n===void 0||o===void 0)return{error:new rS.UnknownDAError("Device metadata not fetched")};let{blockSize:l,totalMemoryBlocks:u}=this.getMemoryConstants(n),d=this.getCurrentMemoryBlocksUsage({firmwareUpdateContext:r,customImage:i,installedApps:s,installedLanguages:o,blockSize:l}),c=this.getInstallPlanMemoryBlocksUsage(this.args.installPlan,l);return{outOfMemory:d+c>u}}getMemoryConstants(e){let r=this.deviceModel.getBlockSize({firmwareVersion:e.os}),i=Math.floor(this.deviceModel.memorySize/r);return{blockSize:r,totalMemoryBlocks:i}}getCurrentMemoryBlocksUsage({firmwareUpdateContext:e,customImage:r,installedApps:i,installedLanguages:n,blockSize:o}){let s=p=>Math.ceil(p/o),l=s(e.currentFirmware.bytes||0),u=s(r.size||0),d=i.reduce((p,v)=>p+s(v.bytes||0),0),c=n.reduce((p,v)=>p+s(v.size),0);return l+u+d+c}getInstallPlanMemoryBlocksUsage(e,r){let i=n=>Math.ceil(n/r);return e.reduce((n,o)=>n+i(o.bytes||0),0)}}});var xu=a((Jue,uS)=>{"use strict";var Pu=Object.defineProperty,yF=Object.getOwnPropertyDescriptor,bF=Object.getOwnPropertyNames,_F=Object.prototype.hasOwnProperty,SF=(t,e)=>{for(var r in e)Pu(t,r,{get:e[r],enumerable:!0})},DF=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of bF(e))!_F.call(t,n)&&n!==r&&Pu(t,n,{get:()=>e[n],enumerable:!(i=yF(e,n))||i.enumerable});return t},OF=t=>DF(Pu({},"__esModule",{value:!0}),t),cS={};SF(cS,{InstallOrUpdateAppsDeviceAction:()=>Iu});uS.exports=OF(cS);var sS=b(),ie=(Y(),X(Q)),Wr=Z(),EF=le(),CF=de(),AF=fi(),wF=nt(),IF=tS(),PF=oS(),xF=ee(),aS=ne(),MF=Lt(),Kr=yt(),Iu=class extends xF.XStateDeviceAction{makeStateMachine(e){let{buildInstallPlan:r,predictOutOfMemory:i,installApp:n}=this.extractDependencies(e),o=this.input.unlockTimeout??EF.DEFAULT_UNLOCK_TIMEOUT_MS,s=new AF.GetDeviceMetadataDeviceAction({input:{unlockTimeout:o,useSecureChannel:!0,forceUpdate:!1}}).makeStateMachine(e),l=new wF.GoToDashboardDeviceAction({input:{unlockTimeout:o}}).makeStateMachine(e);return(0,ie.setup)({types:{input:{unlockTimeout:o},context:{},output:{}},actors:{updateMetadata:s,buildInstallPlan:(0,ie.fromPromise)(r),predictOutOfMemory:(0,ie.fromPromise)(i),goToDashboard:l,installApp:(0,ie.fromObservable)(n)},guards:{hasError:({context:u})=>u._internalState.error!==null,hasInstallPlan:u=>u.context.intermediateValue.installPlan!==null,hasMoreApps:u=>u.context._internalState.currentIndex<u.context.intermediateValue.installPlan.installPlan.length},actions:{assignErrorFromEvent:(0,ie.assign)({_internalState:u=>({...u.context._internalState,error:u.event.error})}),nextAppIndex:(0,ie.assign)({_internalState:u=>({...u.context._internalState,currentIndex:u.context._internalState.currentIndex+1})}),cleanupDeviceState:()=>{let u=e.getDeviceSessionState();u.sessionStateType!==aS.DeviceSessionStateType.Connected&&e.setDeviceSessionState({...u,installedApps:[],appsUpdates:void 0})}}}).createMachine({id:"InstallOrUpdateAppsDeviceAction",initial:"DeviceReady",context:u=>({input:{applications:u.input.applications,allowMissingApplication:u.input.allowMissingApplication,unlockTimeout:u.input.unlockTimeout},intermediateValue:{requiredUserInteraction:Wr.UserInteractionRequired.None,installPlan:null},_internalState:{error:null,osVersion:null,currentIndex:0}}),states:{DeviceReady:{always:[{target:"UpdateDeviceMetadata"}]},UpdateDeviceMetadata:{exit:(0,ie.assign)({intermediateValue:u=>({...u.context.intermediateValue,requiredUserInteraction:Wr.UserInteractionRequired.None})}),invoke:{id:"updateMetadata",src:"updateMetadata",input:u=>({unlockTimeout:u.context.input.unlockTimeout,useSecureChannel:!0,forceUpdate:!1}),onSnapshot:{actions:(0,ie.assign)({intermediateValue:u=>({...u.context.intermediateValue,requiredUserInteraction:u.event.snapshot.context.intermediateValue.requiredUserInteraction,deviceId:u.event.snapshot.context.intermediateValue.deviceId??u.context.intermediateValue.deviceId})})},onDone:{target:"UpdateDeviceMetadataCheck",actions:(0,ie.assign)({_internalState:u=>u.event.output.caseOf({Right:d=>({...u.context._internalState,osVersion:d.firmwareVersion.metadata}),Left:d=>({...u.context._internalState,error:d})})})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},UpdateDeviceMetadataCheck:{always:[{target:"Error",guard:"hasError"},{target:"Success",guard:"hasInstallPlan"},{target:"BuildInstallPlan"}]},BuildInstallPlan:{invoke:{src:"buildInstallPlan",input:u=>({applications:u.context.input.applications,allowMissingApplication:u.context.input.allowMissingApplication}),onDone:{target:"BuildInstallPlanCheck",actions:(0,ie.assign)({_internalState:u=>"error"in u.event.output?{...u.context._internalState,error:u.event.output.error}:u.context._internalState,intermediateValue:u=>"error"in u.event.output?u.context.intermediateValue:{...u.context.intermediateValue,installPlan:{installPlan:u.event.output.installPlan,alreadyInstalled:u.event.output.alreadyInstalled,missingApplications:u.event.output.missingApplications,currentIndex:0,currentProgress:0}}})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},BuildInstallPlanCheck:{always:[{guard:"hasError",target:"Error"},{target:"PredictOutOfMemory",guard:"hasMoreApps"},{target:"Success"}]},PredictOutOfMemory:{invoke:{src:"predictOutOfMemory",input:u=>({installPlan:u.context.intermediateValue.installPlan.installPlan}),onDone:{target:"PredictOutOfMemoryCheck",actions:(0,ie.assign)({_internalState:u=>"error"in u.event.output?{...u.context._internalState,error:u.event.output.error}:u.event.output.outOfMemory?{...u.context._internalState,error:new CF.OutOfMemoryDAError("Not enough memory for those applications")}:u.context._internalState})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},PredictOutOfMemoryCheck:{always:[{guard:"hasError",target:"Error"},{target:"GoToDashboard"}]},GoToDashboard:{invoke:{id:"goToDashboard",src:"goToDashboard",input:u=>({unlockTimeout:u.context.input.unlockTimeout}),onSnapshot:{actions:(0,ie.assign)({intermediateValue:u=>({...u.context.intermediateValue,requiredUserInteraction:u.event.snapshot.context.intermediateValue.requiredUserInteraction})})},onDone:{target:"GoToDashboardCheck",actions:(0,ie.assign)({_internalState:u=>u.event.output.caseOf({Right:()=>u.context._internalState,Left:d=>({...u.context._internalState,error:d})})})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GoToDashboardCheck:{always:[{target:"Error",guard:"hasError"},{target:"InstallApp",actions:"cleanupDeviceState"}]},InstallApp:{exit:(0,ie.assign)({intermediateValue:u=>({...u.context.intermediateValue,requiredUserInteraction:Wr.UserInteractionRequired.None})}),invoke:{id:"installApp",src:"installApp",input:u=>({osVersion:u.context._internalState.osVersion,application:u.context.intermediateValue.installPlan.installPlan[u.context._internalState.currentIndex]}),onSnapshot:{actions:(0,ie.assign)({intermediateValue:u=>{switch(u.event.snapshot.context?.type){case Kr.SecureChannelEventType.DeviceId:return{...u.context.intermediateValue,deviceId:u.event.snapshot.context.payload.deviceId};case Kr.SecureChannelEventType.PermissionRequested:return{...u.context.intermediateValue,requiredUserInteraction:Wr.UserInteractionRequired.AllowSecureConnection};case Kr.SecureChannelEventType.PermissionGranted:{let d=e.getDeviceSessionState();return d.sessionStateType!==aS.DeviceSessionStateType.Connected&&e.setDeviceSessionState({...d,isSecureConnectionAllowed:!0}),{...u.context.intermediateValue,requiredUserInteraction:Wr.UserInteractionRequired.None}}case Kr.SecureChannelEventType.Progress:return{...u.context.intermediateValue,installPlan:{...u.context.intermediateValue.installPlan,currentIndex:u.context._internalState.currentIndex,currentProgress:u.event.snapshot.context.payload.progress}};default:return u.context.intermediateValue}},_internalState:u=>u.event.snapshot.context?.type===Kr.SecureChannelEventType.Error?{...u.context._internalState,error:u.event.snapshot.context.error.mapInstallDAErrors()}:u.context._internalState})},onDone:{target:"InstallAppCheck",actions:"nextAppIndex"},onError:{target:"Error",actions:"assignErrorFromEvent"}}},InstallAppCheck:{always:[{target:"Error",guard:"hasError"},{target:"InstallApp",guard:"hasMoreApps"},{target:"UpdateDeviceMetadata"}]},Success:{type:"final"},Error:{type:"final"}},output:u=>{let{context:d}=u,{error:c}=d._internalState,{installPlan:p}=d.intermediateValue;return c?(0,sS.Left)(c):(0,sS.Right)({successfullyInstalled:p.installPlan,alreadyInstalled:p.alreadyInstalled,missingApplications:p.missingApplications})}})}extractDependencies(e){return{buildInstallPlan:r=>Promise.resolve(new IF.BuildAppsInstallPlanTask(e,{applications:r.input.applications,allowMissingApplication:r.input.allowMissingApplication}).run()),predictOutOfMemory:r=>Promise.resolve(new PF.PredictOutOfMemoryTask(e,{installPlan:r.input.installPlan}).run()),installApp:r=>{let{osVersion:i,application:n}=r.input,o=e.getSecureChannelService().installApp(i,n);return new MF.ConnectToSecureChannelTask(e,{connection:o}).run()}}}}});var vS=a((Xue,fS)=>{"use strict";var Tu=Object.defineProperty,TF=Object.getOwnPropertyDescriptor,jF=Object.getOwnPropertyNames,qF=Object.prototype.hasOwnProperty,RF=(t,e)=>{for(var r in e)Tu(t,r,{get:e[r],enumerable:!0})},NF=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of jF(e))!qF.call(t,n)&&n!==r&&Tu(t,n,{get:()=>e[n],enumerable:!(i=TF(e,n))||i.enumerable});return t},UF=t=>NF(Tu({},"__esModule",{value:!0}),t),pS={};RF(pS,{ListAppsWithMetadataDeviceAction:()=>Mu});fS.exports=UF(pS);var dS=b(),bt=(Y(),X(Q)),lS=Z(),BF=le(),LF=oi(),FF=ee(),Mu=class extends FF.XStateDeviceAction{makeStateMachine(e){let{getAppsByHash:r,setDeviceSessionState:i,getDeviceSessionState:n}=this.extractDependencies(e),o=this.input.unlockTimeout??BF.DEFAULT_UNLOCK_TIMEOUT_MS,s=new LF.ListAppsDeviceAction({input:{unlockTimeout:o}}).makeStateMachine(e);return(0,bt.setup)({types:{input:{unlockTimeout:o},context:{},output:{}},actors:{listApps:s,getAppsByHash:(0,bt.fromPromise)(r),updateDeviceSessionState:(0,bt.fromCallback)(({input:l,sendBack:u})=>{let{appsWithMetadata:d}=l,c=d.filter(v=>v!==null),p={...n(),installedApps:c};try{i(p),u({type:"done"})}catch(v){u({type:"error",error:v})}})},guards:{hasError:({context:l})=>l._internalState.error!==null,hasNoAppsInstalled:({context:l})=>l._internalState.apps.length===0},actions:{assignErrorFromEvent:(0,bt.assign)({_internalState:l=>({...l.context._internalState,error:l.event.error})})}}).createMachine({id:"ListAppsWithMetadataDeviceAction",initial:"DeviceReady",context:l=>({input:l.input,_internalState:{error:null,apps:[],appsWithMetadata:[]},intermediateValue:{requiredUserInteraction:lS.UserInteractionRequired.None}}),states:{DeviceReady:{always:{target:"ListApps"}},ListApps:{invoke:{id:"listApps",src:"listApps",input:l=>({unlockTimeout:l.context.input.unlockTimeout}),onSnapshot:{actions:(0,bt.assign)({intermediateValue:l=>l.event.snapshot.context.intermediateValue})},onDone:{target:"ListAppsCheck",actions:(0,bt.assign)({intermediateValue:l=>({requiredUserInteraction:lS.UserInteractionRequired.None}),_internalState:l=>l.event.output.caseOf({Right:u=>({...l.context._internalState,apps:u}),Left:u=>({...l.context._internalState,error:u})})})}}},ListAppsCheck:{always:[{target:"Error",guard:"hasError"},{target:"Success",guard:"hasNoAppsInstalled",actions:(0,bt.assign)({_internalState:l=>({...l.context._internalState,appsWithMetadata:[]})})},{target:"FetchMetadata"}]},FetchMetadata:{invoke:{id:"getAppsByHash",src:"getAppsByHash",input:l=>l.context._internalState.apps,onDone:{target:"FetchMetadataCheck",actions:(0,bt.assign)({_internalState:l=>l.event.output.caseOf({Right:u=>({...l.context._internalState,appsWithMetadata:u}),Left:u=>({...l.context._internalState,error:u})})})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},FetchMetadataCheck:{always:[{target:"Error",guard:"hasError"},{target:"SaveSession"}]},SaveSession:{invoke:{src:"updateDeviceSessionState",input:l=>({appsWithMetadata:l.context._internalState.appsWithMetadata})},on:{done:{target:"Success"},error:{target:"Error",actions:"assignErrorFromEvent"}}},Success:{type:"final"},Error:{type:"final"}},output:l=>l.context._internalState.error?(0,dS.Left)(l.context._internalState.error):(0,dS.Right)(l.context._internalState.appsWithMetadata)})}extractDependencies(e){return{getAppsByHash:({input:r})=>{let i=r.reduce((n,o)=>o.appFullHash?n.concat(o.appFullHash):n,[]);return e.getManagerApiService().getAppsByHash(i)},getDeviceSessionState:()=>e.getDeviceSessionState(),setDeviceSessionState:r=>e.setDeviceSessionState(r)}}}});var yS=a((Que,mS)=>{"use strict";var qu=Object.defineProperty,kF=Object.getOwnPropertyDescriptor,VF=Object.getOwnPropertyNames,GF=Object.prototype.hasOwnProperty,HF=(t,e)=>{for(var r in e)qu(t,r,{get:e[r],enumerable:!0})},WF=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of VF(e))!GF.call(t,n)&&n!==r&&qu(t,n,{get:()=>e[n],enumerable:!(i=kF(e,n))||i.enumerable});return t},KF=t=>WF(qu({},"__esModule",{value:!0}),t),hS={};HF(hS,{OpenAppWithDependenciesDeviceAction:()=>ju});mS.exports=KF(hS);var gS=b(),Ne=(Y(),X(Q)),gi=Z(),$F=le(),zF=de(),JF=fi(),XF=xu(),QF=kr(),YF=ee(),ju=class extends YF.XStateDeviceAction{makeStateMachine(e){let r=this.input.unlockTimeout??$F.DEFAULT_UNLOCK_TIMEOUT_MS,i=new JF.GetDeviceMetadataDeviceAction({input:{unlockTimeout:r,useSecureChannel:!0,forceUpdate:!1}}).makeStateMachine(e),n=new XF.InstallOrUpdateAppsDeviceAction({input:{unlockTimeout:r,applications:[...this.input.dependencies,this.input.application],allowMissingApplication:!1}}).makeStateMachine(e),o=new QF.OpenAppDeviceAction({input:{unlockTimeout:r,appName:this.input.application.name}}).makeStateMachine(e);return(0,Ne.setup)({types:{input:{unlockTimeout:r},context:{},output:{}},actors:{getMetadata:i,installApps:n,openApp:o},guards:{hasError:({context:s})=>s._internalState.error!==null},actions:{assignErrorFromEvent:(0,Ne.assign)({_internalState:s=>({...s.context._internalState,error:s.event.error})})}}).createMachine({id:"OpenAppWithDependenciesDeviceAction",initial:"DeviceReady",context:s=>({input:{application:s.input.application,dependencies:s.input.dependencies,requireLatestFirmware:s.input.requireLatestFirmware,unlockTimeout:s.input.unlockTimeout},intermediateValue:{requiredUserInteraction:gi.UserInteractionRequired.None,installPlan:null},_internalState:{error:null,deviceMetadata:null,installResult:null}}),states:{DeviceReady:{always:[{target:"GetDeviceMetadata"}]},GetDeviceMetadata:{exit:(0,Ne.assign)({intermediateValue:s=>({...s.context.intermediateValue,requiredUserInteraction:gi.UserInteractionRequired.None})}),invoke:{id:"getMetadata",src:"getMetadata",input:s=>({unlockTimeout:s.context.input.unlockTimeout,useSecureChannel:!0,forceUpdate:!1}),onSnapshot:{actions:(0,Ne.assign)({intermediateValue:s=>({...s.context.intermediateValue,requiredUserInteraction:s.event.snapshot.context.intermediateValue.requiredUserInteraction,deviceId:s.event.snapshot.context.intermediateValue.deviceId??s.context.intermediateValue.deviceId})})},onDone:{target:"GetDeviceMetadataCheck",actions:(0,Ne.assign)({_internalState:s=>s.event.output.caseOf({Right:l=>s.context.input.requireLatestFirmware&&l.firmwareUpdateContext.availableUpdate!==void 0?{...s.context._internalState,error:new zF.UnsupportedFirmwareDAError("Firmware is not the latest version")}:{...s.context._internalState,deviceMetadata:l},Left:l=>({...s.context._internalState,error:l})})})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GetDeviceMetadataCheck:{always:[{target:"Error",guard:"hasError"},{target:"InstallDependencies"}]},InstallDependencies:{exit:(0,Ne.assign)({intermediateValue:s=>({...s.context.intermediateValue,requiredUserInteraction:gi.UserInteractionRequired.None})}),invoke:{src:"installApps",input:s=>({unlockTimeout:s.context.input.unlockTimeout,applications:[...s.context.input.dependencies,s.context.input.application],allowMissingApplication:!1}),onSnapshot:{actions:(0,Ne.assign)({intermediateValue:s=>({...s.context.intermediateValue,requiredUserInteraction:s.event.snapshot.context.intermediateValue.requiredUserInteraction,installPlan:s.event.snapshot.context.intermediateValue.installPlan,deviceId:s.event.snapshot.context.intermediateValue.deviceId??s.context.intermediateValue.deviceId})})},onDone:{target:"InstallDependenciesCheck",actions:(0,Ne.assign)({_internalState:s=>s.event.output.caseOf({Right:l=>({...s.context._internalState,installResult:l}),Left:l=>({...s.context._internalState,error:l})})})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},InstallDependenciesCheck:{always:[{guard:"hasError",target:"Error"},{target:"OpenApp"}]},OpenApp:{exit:(0,Ne.assign)({intermediateValue:s=>({...s.context.intermediateValue,requiredUserInteraction:gi.UserInteractionRequired.None})}),invoke:{src:"openApp",input:s=>({unlockTimeout:s.context.input.unlockTimeout,appName:s.context.input.application.name}),onSnapshot:{actions:(0,Ne.assign)({intermediateValue:s=>({...s.context.intermediateValue,requiredUserInteraction:s.event.snapshot.context.intermediateValue.requiredUserInteraction,installPlan:null})})},onDone:{target:"OpenAppCheck",actions:(0,Ne.assign)({_internalState:s=>s.event.output.caseOf({Right:()=>s.context._internalState,Left:l=>({...s.context._internalState,error:l})})})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},OpenAppCheck:{always:[{guard:"hasError",target:"Error"},{target:"Success"}]},Success:{type:"final"},Error:{type:"final"}},output:s=>{let{context:l}=s,{error:u,deviceMetadata:d,installResult:c}=l._internalState;return u?(0,gS.Left)(u):(0,gS.Right)({deviceMetadata:d,installResult:c})}})}}});var OS=a((Yue,DS)=>{"use strict";var Nu=Object.defineProperty,ZF=Object.getOwnPropertyDescriptor,ek=Object.getOwnPropertyNames,tk=Object.prototype.hasOwnProperty,rk=(t,e)=>{for(var r in e)Nu(t,r,{get:e[r],enumerable:!0})},nk=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of ek(e))!tk.call(t,n)&&n!==r&&Nu(t,n,{get:()=>e[n],enumerable:!(i=ZF(e,n))||i.enumerable});return t},ik=t=>nk(Nu({},"__esModule",{value:!0}),t),SS={};rk(SS,{SendCommandInAppDeviceAction:()=>Ru});DS.exports=ik(SS);var bS=b(),_t=(Y(),X(Q)),ok=w(),_S=Z(),sk=de(),ak=kr(),ck=ee(),Ru=class extends ck.XStateDeviceAction{makeStateMachine(e){let{sendCommand:r}=this.extractDependencies(e);return(0,_t.setup)({types:{input:{},context:{},output:{}},actors:{sendCommand:(0,_t.fromPromise)(r),openAppStateMachine:new ak.OpenAppDeviceAction({input:{appName:this.input.appName}}).makeStateMachine(e)},guards:{skipOpenApp:()=>this.input.skipOpenApp,noInternalError:({context:i})=>i._internalState.error===null},actions:{assignErrorFromEvent:(0,_t.assign)({_internalState:i=>({...i.context._internalState,error:i.event.error})})}}).createMachine({id:"SendCommandInAppDeviceAction",initial:"InitialState",context:({input:i})=>({input:i,intermediateValue:{requiredUserInteraction:_S.UserInteractionRequired.None},_internalState:{commandResponse:null,error:null}}),states:{InitialState:{always:[{target:"SendCommand",guard:"skipOpenApp"},"OpenAppDeviceAction"]},OpenAppDeviceAction:{invoke:{id:"openAppStateMachine",input:{appName:this.input.appName},src:"openAppStateMachine",onSnapshot:{actions:(0,_t.assign)({intermediateValue:i=>i.event.snapshot.context.intermediateValue})},onDone:{actions:(0,_t.assign)({_internalState:i=>i.event.output.caseOf({Right:()=>i.context._internalState,Left:n=>({...i.context._internalState,error:n})})}),target:"CheckOpenAppDeviceActionResult"}}},CheckOpenAppDeviceActionResult:{always:[{target:"SendCommand",guard:"noInternalError"},"Error"]},SendCommand:{entry:(0,_t.assign)({intermediateValue:{requiredUserInteraction:this.input.requiredUserInteraction}}),exit:(0,_t.assign)({intermediateValue:{requiredUserInteraction:_S.UserInteractionRequired.None}}),invoke:{id:"sendCommand",src:"sendCommand",input:({context:i})=>i.input.command,onDone:{target:"SendCommandResultCheck",actions:[(0,_t.assign)({_internalState:({event:i,context:n})=>(0,ok.isSuccessCommandResult)(i.output)?{...n._internalState,commandResponse:i.output.data}:{...n._internalState,error:i.output.error}})]},onError:{target:"Error",actions:"assignErrorFromEvent"}}},SendCommandResultCheck:{always:[{target:"Success",guard:"noInternalError"},"Error"]},Success:{type:"final"},Error:{type:"final"}},output:({context:i})=>i._internalState.commandResponse?(0,bS.Right)(i._internalState.commandResponse):(0,bS.Left)(i._internalState.error||new sk.UnknownDAError("No error in final state"))})}extractDependencies(e){return{sendCommand:r=>e.sendCommand(r.input)}}}});var ES=a(Uu=>{"use strict";Object.defineProperty(Uu,"__esModule",{value:!0});Uu.isPromise=uk;function uk(t){return(typeof t=="object"&&t!==null||typeof t=="function")&&typeof t.then=="function"}});var CS=a(Bu=>{"use strict";Object.defineProperty(Bu,"__esModule",{value:!0});Bu.stringifyServiceIdentifier=dk;function dk(t){switch(typeof t){case"string":case"symbol":return t.toString();case"function":return t.name;default:throw new Error(`Unexpected ${typeof t} service id type`)}}});var AS=a(it=>{"use strict";Object.defineProperty(it,"__esModule",{value:!0});it.LazyServiceIdentifier=it.islazyServiceIdentifierSymbol=void 0;it.islazyServiceIdentifierSymbol=Symbol.for("@inversifyjs/common/islazyServiceIdentifier");var Lu=class{[it.islazyServiceIdentifierSymbol];#e;constructor(e){this.#e=e,this[it.islazyServiceIdentifierSymbol]=!0}static is(e){return typeof e=="object"&&e!==null&&e[it.islazyServiceIdentifierSymbol]===!0}unwrap(){return this.#e()}};it.LazyServiceIdentifier=Lu});var j=a(St=>{"use strict";Object.defineProperty(St,"__esModule",{value:!0});St.stringifyServiceIdentifier=St.LazyServiceIdentifier=St.isPromise=void 0;var lk=ES();Object.defineProperty(St,"isPromise",{enumerable:!0,get:function(){return lk.isPromise}});var pk=CS();Object.defineProperty(St,"stringifyServiceIdentifier",{enumerable:!0,get:function(){return pk.stringifyServiceIdentifier}});var fk=AS();Object.defineProperty(St,"LazyServiceIdentifier",{enumerable:!0,get:function(){return fk.LazyServiceIdentifier}})});var ku=a(Fu=>{"use strict";Object.defineProperty(Fu,"__esModule",{value:!0});Fu.getOwnReflectMetadata=vk;function vk(t,e){return Reflect.getOwnMetadata(e,t)}});var Gu=a(Vu=>{"use strict";Object.defineProperty(Vu,"__esModule",{value:!0});Vu.getReflectMetadata=gk;function gk(t,e){return Reflect.getMetadata(e,t)}});var wS=a(Hu=>{"use strict";Object.defineProperty(Hu,"__esModule",{value:!0});Hu.setReflectMetadata=hk;function hk(t,e,r){Reflect.defineMetadata(e,r,t)}});var IS=a(Wu=>{"use strict";Object.defineProperty(Wu,"__esModule",{value:!0});Wu.updateOwnReflectMetadata=yk;var mk=ku();function yk(t,e,r,i){let n=(0,mk.getOwnReflectMetadata)(t,e)??r(),o=i(n);Reflect.defineMetadata(e,o,t)}});var PS=a(Ku=>{"use strict";Object.defineProperty(Ku,"__esModule",{value:!0});Ku.updateReflectMetadata=_k;var bk=Gu();function _k(t,e,r,i){let n=(0,bk.getReflectMetadata)(t,e)??r(),o=i(n);Reflect.defineMetadata(e,o,t)}});var pe=a(we=>{"use strict";Object.defineProperty(we,"__esModule",{value:!0});we.updateReflectMetadata=we.updateOwnReflectMetadata=we.setReflectMetadata=we.getOwnReflectMetadata=we.getReflectMetadata=void 0;var Sk=ku();Object.defineProperty(we,"getOwnReflectMetadata",{enumerable:!0,get:function(){return Sk.getOwnReflectMetadata}});var Dk=Gu();Object.defineProperty(we,"getReflectMetadata",{enumerable:!0,get:function(){return Dk.getReflectMetadata}});var Ok=wS();Object.defineProperty(we,"setReflectMetadata",{enumerable:!0,get:function(){return Ok.setReflectMetadata}});var Ek=IS();Object.defineProperty(we,"updateOwnReflectMetadata",{enumerable:!0,get:function(){return Ek.updateOwnReflectMetadata}});var Ck=PS();Object.defineProperty(we,"updateReflectMetadata",{enumerable:!0,get:function(){return Ck.updateReflectMetadata}})});var xS=a(Ju=>{"use strict";Object.defineProperty(Ju,"__esModule",{value:!0});Ju.getContainerModuleId=Ak;var $u=pe(),zu="@inversifyjs/container/bindingId";function Ak(){let t=(0,$u.getOwnReflectMetadata)(Object,zu)??0;return t===Number.MAX_SAFE_INTEGER?(0,$u.setReflectMetadata)(Object,zu,Number.MIN_SAFE_INTEGER):(0,$u.updateOwnReflectMetadata)(Object,zu,()=>t,e=>e+1),t}});var MS=a(hi=>{"use strict";Object.defineProperty(hi,"__esModule",{value:!0});hi.ContainerModule=void 0;var wk=xS(),Xu=class{#e;#t;constructor(e){this.#e=(0,wk.getContainerModuleId)(),this.#t=e}get id(){return this.#e}load(e){return this.#t(e)}};hi.ContainerModule=Xu});var ed=a(Zu=>{"use strict";Object.defineProperty(Zu,"__esModule",{value:!0});Zu.getBindingId=Ik;var Qu=pe(),Yu="@inversifyjs/container/bindingId";function Ik(){let t=(0,Qu.getOwnReflectMetadata)(Object,Yu)??0;return t===Number.MAX_SAFE_INTEGER?(0,Qu.setReflectMetadata)(Object,Yu,Number.MIN_SAFE_INTEGER):(0,Qu.updateOwnReflectMetadata)(Object,Yu,()=>t,e=>e+1),t}});var yi=a(mi=>{"use strict";Object.defineProperty(mi,"__esModule",{value:!0});mi.bindingScopeValues=void 0;mi.bindingScopeValues={Request:"Request",Singleton:"Singleton",Transient:"Transient"}});var Dt=a(bi=>{"use strict";Object.defineProperty(bi,"__esModule",{value:!0});bi.bindingTypeValues=void 0;bi.bindingTypeValues={ConstantValue:"ConstantValue",DynamicValue:"DynamicValue",Factory:"Factory",Instance:"Instance",Provider:"Provider",ResolvedValue:"ResolvedValue",ServiceRedirection:"ServiceRedirection"}});var _i=a(td=>{"use strict";Object.defineProperty(td,"__esModule",{value:!0});td.chain=Pk;function*Pk(...t){for(let e of t)yield*e}});var Di=a(Si=>{"use strict";Object.defineProperty(Si,"__esModule",{value:!0});Si.OneToManyMapStar=void 0;var xk=-1,rd=class t{#e;#t;#i;constructor(e){this.#e=new Map,this.#t={};for(let r of Reflect.ownKeys(e))this.#t[r]=new Map;this.#i=e}add(e,r){this.#r(e).push(r);for(let i of Reflect.ownKeys(r))this.#s(i,r[i]).push(e)}clone(){let e=Reflect.ownKeys(this.#i),r=new t(this.#i);this.#a(this.#e,r.#e);for(let i of e)this.#a(this.#t[i],r.#t[i]);return r}get(e,r){return this.#t[e].get(r)}getAllKeys(e){return this.#t[e].keys()}removeByRelation(e,r){let i=this.get(e,r);if(i===void 0)return;let n=new Set(i);for(let o of n){let s=this.#e.get(o);if(s===void 0)throw new Error("Expecting model relation, none found");for(let l of s)l[e]===r&&this.#o(o,l);this.#e.delete(o)}}#r(e){let r=this.#e.get(e);return r===void 0&&(r=[],this.#e.set(e,r)),r}#s(e,r){let i=this.#t[e].get(r);return i===void 0&&(i=[],this.#t[e].set(r,i)),i}#a(e,r){for(let[i,n]of e)r.set(i,[...n])}#o(e,r){for(let i of Reflect.ownKeys(r))this.#n(e,i,r[i])}#n(e,r,i){let n=this.#t[r].get(i);if(n!==void 0){let o=n.indexOf(e);o!==xk&&n.splice(o,1),n.length===0&&this.#t[r].delete(i)}}};Si.OneToManyMapStar=rd});var TS=a(Oi=>{"use strict";Object.defineProperty(Oi,"__esModule",{value:!0});Oi.ActivationsService=void 0;var Mk=_i(),Tk=Di(),$r;(function(t){t.moduleId="moduleId",t.serviceId="serviceId"})($r||($r={}));var nd=class t{#e;#t;constructor(e,r){this.#e=r??new Tk.OneToManyMapStar({moduleId:{isOptional:!0},serviceId:{isOptional:!1}}),this.#t=e}static build(e){return new t(e)}add(e,r){this.#e.add(e,r)}clone(){return new t(this.#t,this.#e.clone())}get(e){let r=[],i=this.#e.get($r.serviceId,e);i!==void 0&&r.push(i);let n=this.#t?.get(e);if(n!==void 0&&r.push(n),r.length!==0)return(0,Mk.chain)(...r)}removeAllByModuleId(e){this.#e.removeByRelation($r.moduleId,e)}removeAllByServiceId(e){this.#e.removeByRelation($r.serviceId,e)}};Oi.ActivationsService=nd});var jS=a(Ei=>{"use strict";Object.defineProperty(Ei,"__esModule",{value:!0});Ei.BindingService=void 0;var jk=Di(),Ie;(function(t){t.id="id",t.moduleId="moduleId",t.serviceId="serviceId"})(Ie||(Ie={}));var id=class t{#e;#t;constructor(e,r){this.#e=r??new jk.OneToManyMapStar({id:{isOptional:!1},moduleId:{isOptional:!0},serviceId:{isOptional:!1}}),this.#t=e}static build(e){return new t(e)}clone(){return new t(this.#t,this.#e.clone())}get(e){return this.getNonParentBindings(e)??this.#t?.get(e)}getById(e){return this.#e.get(Ie.id,e)??this.#t?.getById(e)}getByModuleId(e){return this.#e.get(Ie.moduleId,e)??this.#t?.getByModuleId(e)}getNonParentBindings(e){return this.#e.get(Ie.serviceId,e)}getNonParentBoundServices(){return this.#e.getAllKeys(Ie.serviceId)}removeById(e){this.#e.removeByRelation(Ie.id,e)}removeAllByModuleId(e){this.#e.removeByRelation(Ie.moduleId,e)}removeAllByServiceId(e){this.#e.removeByRelation(Ie.serviceId,e)}set(e){let r={[Ie.id]:e.id,[Ie.serviceId]:e.serviceIdentifier};e.moduleId!==void 0&&(r[Ie.moduleId]=e.moduleId),this.#e.add(e,r)}};Ei.BindingService=id});var qS=a(Ci=>{"use strict";Object.defineProperty(Ci,"__esModule",{value:!0});Ci.DeactivationsService=void 0;var qk=_i(),Rk=Di(),zr;(function(t){t.moduleId="moduleId",t.serviceId="serviceId"})(zr||(zr={}));var od=class t{#e;#t;constructor(e,r){this.#e=r??new Rk.OneToManyMapStar({moduleId:{isOptional:!0},serviceId:{isOptional:!1}}),this.#t=e}static build(e){return new t(e)}add(e,r){this.#e.add(e,r)}clone(){return new t(this.#t,this.#e.clone())}get(e){let r=[],i=this.#e.get(zr.serviceId,e);i!==void 0&&r.push(i);let n=this.#t?.get(e);if(n!==void 0&&r.push(n),r.length!==0)return(0,qk.chain)(...r)}removeAllByModuleId(e){this.#e.removeByRelation(zr.moduleId,e)}removeAllByServiceId(e){this.#e.removeByRelation(zr.serviceId,e)}};Ci.DeactivationsService=od});var RS=a(sd=>{"use strict";Object.defineProperty(sd,"__esModule",{value:!0});sd.decorate=Nk;function Nk(t,e,r){let i=Array.isArray(t)?t:[t];if(r===void 0){Reflect.decorate(i,e);return}if(typeof r=="number"){for(let n of i)n(e,void 0,r);return}Reflect.decorate(i,e.prototype,r)}});var Ot=a(Ai=>{"use strict";Object.defineProperty(Ai,"__esModule",{value:!0});Ai.classMetadataReflectKey=void 0;Ai.classMetadataReflectKey="@inversifyjs/core/classMetadataReflectKey"});var Et=a(ad=>{"use strict";Object.defineProperty(ad,"__esModule",{value:!0});ad.getDefaultClassMetadata=Uk;function Uk(){return{constructorArguments:[],lifecycle:{postConstructMethodName:void 0,preDestroyMethodName:void 0},properties:new Map,scope:void 0}}});var Ii=a(wi=>{"use strict";Object.defineProperty(wi,"__esModule",{value:!0});wi.pendingClassMetadataCountReflectKey=void 0;wi.pendingClassMetadataCountReflectKey="@inversifyjs/core/pendingClassMetadataCountReflectKey"});var NS=a(cd=>{"use strict";Object.defineProperty(cd,"__esModule",{value:!0});cd.isPendingClassMetadata=Fk;var Bk=pe(),Lk=Ii();function Fk(t){let e=(0,Bk.getOwnReflectMetadata)(t,Lk.pendingClassMetadataCountReflectKey);return e!==void 0&&e!==0}});var q=a(Pi=>{"use strict";Object.defineProperty(Pi,"__esModule",{value:!0});Pi.InversifyCoreError=void 0;var ud=Symbol.for("@inversifyjs/core/InversifyCoreError"),dd=class t extends Error{[ud];kind;constructor(e,r,i){super(r,i),this[ud]=!0,this.kind=e}static is(e){return typeof e=="object"&&e!==null&&e[ud]===!0}static isErrorOfKind(e,r){return t.is(e)&&e.kind===r}};Pi.InversifyCoreError=dd});var R=a(xi=>{"use strict";Object.defineProperty(xi,"__esModule",{value:!0});xi.InversifyCoreErrorKind=void 0;var US;(function(t){t[t.injectionDecoratorConflict=0]="injectionDecoratorConflict",t[t.missingInjectionDecorator=1]="missingInjectionDecorator",t[t.planning=2]="planning",t[t.resolution=3]="resolution",t[t.unknown=4]="unknown"})(US||(xi.InversifyCoreErrorKind=US={}))});var Jr=a(Mi=>{"use strict";Object.defineProperty(Mi,"__esModule",{value:!0});Mi.MaybeClassElementMetadataKind=void 0;var BS;(function(t){t[t.unknown=32]="unknown"})(BS||(Mi.MaybeClassElementMetadataKind=BS={}))});var VS=a(ld=>{"use strict";Object.defineProperty(ld,"__esModule",{value:!0});ld.throwAtInvalidClassMetadata=kk;var LS=q(),FS=R(),kS=Jr();function kk(t,e){let r=[];for(let i=0;i<e.constructorArguments.length;++i){let n=e.constructorArguments[i];(n===void 0||n.kind===kS.MaybeClassElementMetadataKind.unknown)&&r.push(` - Missing or incomplete metadata for type "${t.name}" at constructor argument with index ${i.toString()}.
3
+ Every constructor parameter must be decorated either with @inject, @multiInject or @unmanaged decorator.`)}for(let[i,n]of e.properties)n.kind===kS.MaybeClassElementMetadataKind.unknown&&r.push(` - Missing or incomplete metadata for type "${t.name}" at property "${i.toString()}".
4
+ This property must be decorated either with @inject or @multiInject decorator.`);throw r.length===0?new LS.InversifyCoreError(FS.InversifyCoreErrorKind.unknown,`Unexpected class metadata for type "${t.name}" with uncompletion traces.
5
+ This might be caused by one of the following reasons:
6
+
7
+ 1. A third party library is targeting inversify reflection metadata.
8
+ 2. A bug is causing the issue. Consider submiting an issue to fix it.`):new LS.InversifyCoreError(FS.InversifyCoreErrorKind.missingInjectionDecorator,`Invalid class metadata at type ${t.name}:
9
+
10
+ ${r.join(`
11
+
12
+ `)}`)}});var WS=a(pd=>{"use strict";Object.defineProperty(pd,"__esModule",{value:!0});pd.validateConstructorMetadataArray=Vk;var GS=q(),HS=R();function Vk(t,e){let r=[];if(e.length<t.length)throw new GS.InversifyCoreError(HS.InversifyCoreErrorKind.missingInjectionDecorator,`Found unexpected missing metadata on type "${t.name}". "${t.name}" constructor requires at least ${t.length.toString()} arguments, found ${e.length.toString()} instead.
13
+ Are you using @inject, @multiInject or @unmanaged decorators in every non optional constructor argument?
14
+
15
+ If you're using typescript and want to rely on auto injection, set "emitDecoratorMetadata" compiler option to true`);for(let i=0;i<e.length;++i)e[i]===void 0&&r.push(i);if(r.length>0)throw new GS.InversifyCoreError(HS.InversifyCoreErrorKind.missingInjectionDecorator,`Found unexpected missing metadata on type "${t.name}" at constructor indexes "${r.join('", "')}".
16
+
17
+ Are you using @inject, @multiInject or @unmanaged decorators at those indexes?
18
+
19
+ If you're using typescript and want to rely on auto injection, set "emitDecoratorMetadata" compiler option to true`)}});var Ti=a(fd=>{"use strict";Object.defineProperty(fd,"__esModule",{value:!0});fd.getClassMetadata=Jk;var Gk=pe(),Hk=Ot(),Wk=Et(),Kk=NS(),$k=VS(),zk=WS();function Jk(t){let e=(0,Gk.getOwnReflectMetadata)(t,Hk.classMetadataReflectKey)??(0,Wk.getDefaultClassMetadata)();if((0,Kk.isPendingClassMetadata)(t))(0,$k.throwAtInvalidClassMetadata)(t,e);else return(0,zk.validateConstructorMetadataArray)(t,e.constructorArguments),e}});var gd=a(vd=>{"use strict";Object.defineProperty(vd,"__esModule",{value:!0});vd.getDefaultPendingClassMetadataCount=Xk;function Xk(){return 0}});var ji=a(hd=>{"use strict";Object.defineProperty(hd,"__esModule",{value:!0});hd.decrementPendingClassMetadataCount=tV;var Qk=pe(),Yk=Ii(),Zk=gd(),eV=Jr();function tV(t){return e=>{e!==void 0&&e.kind===eV.MaybeClassElementMetadataKind.unknown&&(0,Qk.updateOwnReflectMetadata)(t,Yk.pendingClassMetadataCountReflectKey,Zk.getDefaultPendingClassMetadataCount,r=>r-1)}}});var ke=a(qi=>{"use strict";Object.defineProperty(qi,"__esModule",{value:!0});qi.ClassElementMetadataKind=void 0;var KS;(function(t){t[t.multipleInjection=0]="multipleInjection",t[t.singleInjection=1]="singleInjection",t[t.unmanaged=2]="unmanaged"})(KS||(qi.ClassElementMetadataKind=KS={}))});var yd=a(md=>{"use strict";Object.defineProperty(md,"__esModule",{value:!0});md.buildClassElementMetadataFromMaybeClassElementMetadata=oV;var rV=q(),nV=R(),iV=ke();function oV(t,e){return(...r)=>i=>{if(i===void 0)return t(...r);if(i.kind===iV.ClassElementMetadataKind.unmanaged)throw new rV.InversifyCoreError(nV.InversifyCoreErrorKind.injectionDecoratorConflict,"Unexpected injection found. Multiple @inject, @multiInject or @unmanaged decorators found");return e(i,...r)}}});var $S=a(bd=>{"use strict";Object.defineProperty(bd,"__esModule",{value:!0});bd.buildDefaultManagedMetadata=sV;function sV(t,e){return{kind:t,name:void 0,optional:!1,tags:new Map,value:e}}});var Sd=a(_d=>{"use strict";Object.defineProperty(_d,"__esModule",{value:!0});_d.assertMetadataFromTypescriptIfManaged=dV;var aV=q(),cV=R(),uV=Jr();function dV(t){if(t.kind!==uV.MaybeClassElementMetadataKind.unknown&&t.isFromTypescriptParamType!==!0)throw new aV.InversifyCoreError(cV.InversifyCoreErrorKind.injectionDecoratorConflict,"Unexpected injection found. Multiple @inject, @multiInject or @unmanaged decorators found")}});var zS=a(Dd=>{"use strict";Object.defineProperty(Dd,"__esModule",{value:!0});Dd.buildManagedMetadataFromMaybeManagedMetadata=pV;var lV=Sd();function pV(t,e,r){return(0,lV.assertMetadataFromTypescriptIfManaged)(t),{...t,kind:e,value:r}}});var Od=a(Ri=>{"use strict";Object.defineProperty(Ri,"__esModule",{value:!0});Ri.buildManagedMetadataFromMaybeClassElementMetadata=void 0;var fV=yd(),vV=$S(),gV=zS();Ri.buildManagedMetadataFromMaybeClassElementMetadata=(0,fV.buildClassElementMetadataFromMaybeClassElementMetadata)(vV.buildDefaultManagedMetadata,gV.buildManagedMetadataFromMaybeManagedMetadata)});var JS=a(Ed=>{"use strict";Object.defineProperty(Ed,"__esModule",{value:!0});Ed.updateMaybeClassMetadataConstructorArgument=hV;function hV(t,e){return r=>{let i=r.constructorArguments[e];return r.constructorArguments[e]=t(i),r}}});var XS=a(Cd=>{"use strict";Object.defineProperty(Cd,"__esModule",{value:!0});Cd.updateMaybeClassMetadataProperty=mV;function mV(t,e){return r=>{let i=r.properties.get(e);return r.properties.set(e,t(i)),r}}});var Ad=a(Ni=>{"use strict";Object.defineProperty(Ni,"__esModule",{value:!0});Ni.DecoratorInfoKind=void 0;var QS;(function(t){t[t.method=0]="method",t[t.parameter=1]="parameter",t[t.property=2]="property"})(QS||(Ni.DecoratorInfoKind=QS={}))});var YS=a(Id=>{"use strict";Object.defineProperty(Id,"__esModule",{value:!0});Id.getDecoratorInfo=_V;var yV=q(),bV=R(),wd=Ad();function _V(t,e,r){if(r===void 0){if(e===void 0)throw new yV.InversifyCoreError(bV.InversifyCoreErrorKind.unknown,"Unexpected undefined property and index values");return{kind:wd.DecoratorInfoKind.property,property:e,targetClass:t.constructor}}return typeof r=="number"?{index:r,kind:wd.DecoratorInfoKind.parameter,targetClass:t}:{kind:wd.DecoratorInfoKind.method,method:e,targetClass:t}}});var ZS=a(xd=>{"use strict";Object.defineProperty(xd,"__esModule",{value:!0});xd.stringifyDecoratorInfo=SV;var Pd=Ad();function SV(t){switch(t.kind){case Pd.DecoratorInfoKind.method:return`[class: "${t.targetClass.name}", method: "${t.method.toString()}"]`;case Pd.DecoratorInfoKind.parameter:return`[class: "${t.targetClass.name}", index: "${t.index.toString()}"]`;case Pd.DecoratorInfoKind.property:return`[class: "${t.targetClass.name}", property: "${t.property.toString()}"]`}}});var Ui=a(Md=>{"use strict";Object.defineProperty(Md,"__esModule",{value:!0});Md.handleInjectionError=EV;var DV=YS(),OV=ZS(),e0=q(),t0=R();function EV(t,e,r,i){if(e0.InversifyCoreError.isErrorOfKind(i,t0.InversifyCoreErrorKind.injectionDecoratorConflict)){let n=(0,DV.getDecoratorInfo)(t,e,r);throw new e0.InversifyCoreError(t0.InversifyCoreErrorKind.injectionDecoratorConflict,`Unexpected injection error.
20
+
21
+ Cause:
22
+
23
+ ${i.message}
24
+
25
+ Details
26
+
27
+ ${(0,OV.stringifyDecoratorInfo)(n)}`,{cause:i})}throw i}});var Ft=a(Nd=>{"use strict";Object.defineProperty(Nd,"__esModule",{value:!0});Nd.injectBase=wV;var Td=pe(),r0=q(),n0=R(),jd=Ot(),CV=JS(),i0=XS(),qd=Et(),AV=Ui();function wV(t,e){return(i,n,o)=>{try{o===void 0?xV(t,e)(i,n):typeof o=="number"?PV(t,e)(i,n,o):IV(t,e)(i,n,o)}catch(s){(0,AV.handleInjectionError)(i,n,o,s)}}}function Rd(t,e){return r=>{let i=e(r);return n=>(i(n),t(n))}}function IV(t,e){let r=Rd(t,e);return(i,n,o)=>{if(TV(o))(0,Td.updateOwnReflectMetadata)(i.constructor,jd.classMetadataReflectKey,qd.getDefaultClassMetadata,(0,i0.updateMaybeClassMetadataProperty)(r(i),n));else throw new r0.InversifyCoreError(n0.InversifyCoreErrorKind.injectionDecoratorConflict,`Found an @inject decorator in a non setter property method.
28
+ Found @inject decorator at method "${n.toString()}" at class "${i.constructor.name}"`)}}function PV(t,e){let r=Rd(t,e);return(i,n,o)=>{if(MV(i,n))(0,Td.updateOwnReflectMetadata)(i,jd.classMetadataReflectKey,qd.getDefaultClassMetadata,(0,CV.updateMaybeClassMetadataConstructorArgument)(r(i),o));else throw new r0.InversifyCoreError(n0.InversifyCoreErrorKind.injectionDecoratorConflict,`Found an @inject decorator in a non constructor parameter.
29
+ Found @inject decorator at method "${n?.toString()??""}" at class "${i.constructor.name}"`)}}function xV(t,e){let r=Rd(t,e);return(i,n)=>{(0,Td.updateOwnReflectMetadata)(i.constructor,jd.classMetadataReflectKey,qd.getDefaultClassMetadata,(0,i0.updateMaybeClassMetadataProperty)(r(i),n))}}function MV(t,e){return typeof t=="function"&&e===void 0}function TV(t){return t.set!==void 0}});var o0=a(Ud=>{"use strict";Object.defineProperty(Ud,"__esModule",{value:!0});Ud.inject=UV;var jV=ji(),qV=Od(),RV=ke(),NV=Ft();function UV(t){let e=(0,qV.buildManagedMetadataFromMaybeClassElementMetadata)(RV.ClassElementMetadataKind.singleInjection,t);return(0,NV.injectBase)(e,jV.decrementPendingClassMetadataCount)}});var s0=a(Bi=>{"use strict";Object.defineProperty(Bi,"__esModule",{value:!0});Bi.classIsInjectableFlagReflectKey=void 0;Bi.classIsInjectableFlagReflectKey="@inversifyjs/core/classIsInjectableFlagReflectKey"});var u0=a(Bd=>{"use strict";Object.defineProperty(Bd,"__esModule",{value:!0});Bd.setIsInjectableFlag=FV;var a0=pe(),BV=q(),LV=R(),c0=s0();function FV(t){if((0,a0.getOwnReflectMetadata)(t,c0.classIsInjectableFlagReflectKey)!==void 0)throw new BV.InversifyCoreError(LV.InversifyCoreErrorKind.injectionDecoratorConflict,`Cannot apply @injectable decorator multiple times at class "${t.name}"`);(0,a0.setReflectMetadata)(t,c0.classIsInjectableFlagReflectKey,!0)}});var d0=a(Li=>{"use strict";Object.defineProperty(Li,"__esModule",{value:!0});Li.typescriptParameterTypesReflectKey=void 0;Li.typescriptParameterTypesReflectKey="design:paramtypes"});var l0=a(Ld=>{"use strict";Object.defineProperty(Ld,"__esModule",{value:!0});Ld.buildClassElementMetadataFromTypescriptParameterType=VV;var kV=ke();function VV(t){return{isFromTypescriptParamType:!0,kind:kV.ClassElementMetadataKind.singleInjection,name:void 0,optional:!1,tags:new Map,value:t}}});var p0=a(Fd=>{"use strict";Object.defineProperty(Fd,"__esModule",{value:!0});Fd.isUserlandEmittedType=HV;var GV=[Array,BigInt,Boolean,Function,Number,Object,String];function HV(t){return!GV.includes(t)}});var v0=a(kd=>{"use strict";Object.defineProperty(kd,"__esModule",{value:!0});kd.updateClassMetadataWithTypescriptParameterTypes=XV;var f0=pe(),WV=Ot(),KV=d0(),$V=l0(),zV=Et(),JV=p0();function XV(t){let e=(0,f0.getOwnReflectMetadata)(t,KV.typescriptParameterTypesReflectKey);e!==void 0&&(0,f0.updateOwnReflectMetadata)(t,WV.classMetadataReflectKey,zV.getDefaultClassMetadata,QV(e))}function QV(t){return e=>(t.forEach((r,i)=>{e.constructorArguments[i]===void 0&&(0,JV.isUserlandEmittedType)(r)&&(e.constructorArguments[i]=(0,$V.buildClassElementMetadataFromTypescriptParameterType)(r))}),e)}});var g0=a(Vd=>{"use strict";Object.defineProperty(Vd,"__esModule",{value:!0});Vd.injectable=nG;var YV=pe(),ZV=Ot(),eG=u0(),tG=v0(),rG=Et();function nG(t){return e=>{(0,eG.setIsInjectableFlag)(e),(0,tG.updateClassMetadataWithTypescriptParameterTypes)(e),t!==void 0&&(0,YV.updateOwnReflectMetadata)(e,ZV.classMetadataReflectKey,rG.getDefaultClassMetadata,r=>({...r,scope:t}))}}});var h0=a(Gd=>{"use strict";Object.defineProperty(Gd,"__esModule",{value:!0});Gd.getBaseType=iG;function iG(t){return Object.getPrototypeOf(t.prototype)?.constructor}});var m0=a(Fi=>{"use strict";Object.defineProperty(Fi,"__esModule",{value:!0});Fi.getBaseType=void 0;var oG=h0();Object.defineProperty(Fi,"getBaseType",{enumerable:!0,get:function(){return oG.getBaseType}})});var y0=a(Hd=>{"use strict";Object.defineProperty(Hd,"__esModule",{value:!0});Hd.getExtendedConstructorArguments=sG;function sG(t,e,r){let i=t.extendConstructorArguments??!0,n;return i?(n=[...e.constructorArguments],r.constructorArguments.map((o,s)=>{n[s]=o})):n=r.constructorArguments,n}});var b0=a(Wd=>{"use strict";Object.defineProperty(Wd,"__esModule",{value:!0});Wd.getExtendedProperties=cG;var aG=_i();function cG(t,e,r){let i=t.extendProperties??!0,n;return i?n=new Map((0,aG.chain)(e.properties,r.properties)):n=r.properties,n}});var _0=a(Kd=>{"use strict";Object.defineProperty(Kd,"__esModule",{value:!0});Kd.injectFrom=gG;var uG=pe(),dG=Ot(),lG=Ti(),pG=Et(),fG=y0(),vG=b0();function gG(t){return r=>{let i=(0,lG.getClassMetadata)(t.type);(0,uG.updateOwnReflectMetadata)(r,dG.classMetadataReflectKey,pG.getDefaultClassMetadata,hG(t,i))}}function hG(t,e){return i=>({constructorArguments:(0,fG.getExtendedConstructorArguments)(t,e,i),lifecycle:i.lifecycle,properties:(0,vG.getExtendedProperties)(t,e,i),scope:i.scope})}});var S0=a($d=>{"use strict";Object.defineProperty($d,"__esModule",{value:!0});$d.injectFromBase=SG;var mG=m0(),yG=q(),bG=R(),_G=_0();function SG(t){return e=>{let r=(0,mG.getBaseType)(e);if(r===void 0)throw new yG.InversifyCoreError(bG.InversifyCoreErrorKind.injectionDecoratorConflict,`Expected base type for type "${e.name}", none found.`);(0,_G.injectFrom)({...t,type:r})(e)}}});var D0=a(zd=>{"use strict";Object.defineProperty(zd,"__esModule",{value:!0});zd.multiInject=AG;var DG=ji(),OG=Od(),EG=ke(),CG=Ft();function AG(t){let e=(0,OG.buildManagedMetadataFromMaybeClassElementMetadata)(EG.ClassElementMetadataKind.multipleInjection,t);return(0,CG.injectBase)(e,DG.decrementPendingClassMetadataCount)}});var ki=a(Jd=>{"use strict";Object.defineProperty(Jd,"__esModule",{value:!0});Jd.incrementPendingClassMetadataCount=xG;var wG=pe(),IG=Ii(),PG=gd();function xG(t){return e=>{e===void 0&&(0,wG.updateOwnReflectMetadata)(t,IG.pendingClassMetadataCountReflectKey,PG.getDefaultPendingClassMetadataCount,r=>r+1)}}});var O0=a(Xd=>{"use strict";Object.defineProperty(Xd,"__esModule",{value:!0});Xd.updateMetadataName=jG;var MG=q(),TG=R();function jG(t){return e=>{if(e.name!==void 0)throw new MG.InversifyCoreError(TG.InversifyCoreErrorKind.injectionDecoratorConflict,"Unexpected duplicated named decorator");return e.name=t,e}}});var E0=a(Qd=>{"use strict";Object.defineProperty(Qd,"__esModule",{value:!0});Qd.buildDefaultMaybeClassElementMetadata=RG;var qG=Jr();function RG(){return{kind:qG.MaybeClassElementMetadataKind.unknown,name:void 0,optional:!1,tags:new Map}}});var Vi=a(Yd=>{"use strict";Object.defineProperty(Yd,"__esModule",{value:!0});Yd.buildMaybeClassElementMetadataFromMaybeClassElementMetadata=FG;var NG=q(),UG=R(),BG=ke(),LG=E0();function FG(t){return e=>{let r=e??(0,LG.buildDefaultMaybeClassElementMetadata)();switch(r.kind){case BG.ClassElementMetadataKind.unmanaged:throw new NG.InversifyCoreError(UG.InversifyCoreErrorKind.injectionDecoratorConflict,"Unexpected injection found. Found @unmanaged injection with additional @named, @optional, @tagged or @targetName injections");default:return t(r)}}}});var C0=a(Zd=>{"use strict";Object.defineProperty(Zd,"__esModule",{value:!0});Zd.named=WG;var kG=ki(),VG=O0(),GG=Vi(),HG=Ft();function WG(t){let e=(0,GG.buildMaybeClassElementMetadataFromMaybeClassElementMetadata)((0,VG.updateMetadataName)(t));return(0,HG.injectBase)(e,kG.incrementPendingClassMetadataCount)}});var A0=a(el=>{"use strict";Object.defineProperty(el,"__esModule",{value:!0});el.updateMetadataOptional=zG;var KG=q(),$G=R();function zG(t){if(t.optional)throw new KG.InversifyCoreError($G.InversifyCoreErrorKind.injectionDecoratorConflict,"Unexpected duplicated optional decorator");return t.optional=!0,t}});var w0=a(tl=>{"use strict";Object.defineProperty(tl,"__esModule",{value:!0});tl.optional=ZG;var JG=ki(),XG=A0(),QG=Vi(),YG=Ft();function ZG(){let t=(0,QG.buildMaybeClassElementMetadataFromMaybeClassElementMetadata)(XG.updateMetadataOptional);return(0,YG.injectBase)(t,JG.incrementPendingClassMetadataCount)}});var I0=a(rl=>{"use strict";Object.defineProperty(rl,"__esModule",{value:!0});rl.updateMaybeClassMetadataPostConstructor=r2;var e2=q(),t2=R();function r2(t){return e=>{if(e.lifecycle.postConstructMethodName!==void 0)throw new e2.InversifyCoreError(t2.InversifyCoreErrorKind.injectionDecoratorConflict,"Unexpected duplicated postConstruct decorator");return e.lifecycle.postConstructMethodName=t,e}}});var P0=a(nl=>{"use strict";Object.defineProperty(nl,"__esModule",{value:!0});nl.postConstruct=c2;var n2=pe(),i2=Ot(),o2=I0(),s2=Et(),a2=Ui();function c2(){return(t,e,r)=>{try{(0,n2.updateOwnReflectMetadata)(t.constructor,i2.classMetadataReflectKey,s2.getDefaultClassMetadata,(0,o2.updateMaybeClassMetadataPostConstructor)(e))}catch(i){(0,a2.handleInjectionError)(t,e,void 0,i)}}}});var x0=a(il=>{"use strict";Object.defineProperty(il,"__esModule",{value:!0});il.updateMaybeClassMetadataPreDestroy=l2;var u2=q(),d2=R();function l2(t){return e=>{if(e.lifecycle.preDestroyMethodName!==void 0)throw new u2.InversifyCoreError(d2.InversifyCoreErrorKind.injectionDecoratorConflict,"Unexpected duplicated preDestroy decorator");return e.lifecycle.preDestroyMethodName=t,e}}});var M0=a(ol=>{"use strict";Object.defineProperty(ol,"__esModule",{value:!0});ol.preDestroy=m2;var p2=pe(),f2=Ot(),v2=x0(),g2=Et(),h2=Ui();function m2(){return(t,e,r)=>{try{(0,p2.updateOwnReflectMetadata)(t.constructor,f2.classMetadataReflectKey,g2.getDefaultClassMetadata,(0,v2.updateMaybeClassMetadataPreDestroy)(e))}catch(i){(0,h2.handleInjectionError)(t,e,void 0,i)}}}});var T0=a(sl=>{"use strict";Object.defineProperty(sl,"__esModule",{value:!0});sl.updateMetadataTag=_2;var y2=q(),b2=R();function _2(t,e){return r=>{if(r.tags.has(t))throw new y2.InversifyCoreError(b2.InversifyCoreErrorKind.injectionDecoratorConflict,"Unexpected duplicated tag decorator with existing tag");return r.tags.set(t,e),r}}});var j0=a(al=>{"use strict";Object.defineProperty(al,"__esModule",{value:!0});al.tagged=C2;var S2=ki(),D2=T0(),O2=Vi(),E2=Ft();function C2(t,e){let r=(0,O2.buildMaybeClassElementMetadataFromMaybeClassElementMetadata)((0,D2.updateMetadataTag)(t,e));return(0,E2.injectBase)(r,S2.incrementPendingClassMetadataCount)}});var ul=a(cl=>{"use strict";Object.defineProperty(cl,"__esModule",{value:!0});cl.buildDefaultUnmanagedMetadata=w2;var A2=ke();function w2(){return{kind:A2.ClassElementMetadataKind.unmanaged}}});var q0=a(dl=>{"use strict";Object.defineProperty(dl,"__esModule",{value:!0});dl.buildUnmanagedMetadataFromMaybeManagedMetadata=T2;var I2=q(),P2=R(),x2=Sd(),M2=ul();function T2(t){if((0,x2.assertMetadataFromTypescriptIfManaged)(t),j2(t))throw new I2.InversifyCoreError(P2.InversifyCoreErrorKind.injectionDecoratorConflict,"Unexpected injection found. Found @unmanaged injection with additional @named, @optional, @tagged or @targetName injections");return(0,M2.buildDefaultUnmanagedMetadata)()}function j2(t){return t.name!==void 0||t.optional||t.tags.size>0}});var R0=a(Gi=>{"use strict";Object.defineProperty(Gi,"__esModule",{value:!0});Gi.buildUnmanagedMetadataFromMaybeClassElementMetadata=void 0;var q2=yd(),R2=ul(),N2=q0();Gi.buildUnmanagedMetadataFromMaybeClassElementMetadata=(0,q2.buildClassElementMetadataFromMaybeClassElementMetadata)(R2.buildDefaultUnmanagedMetadata,N2.buildUnmanagedMetadataFromMaybeManagedMetadata)});var N0=a(ll=>{"use strict";Object.defineProperty(ll,"__esModule",{value:!0});ll.unmanaged=F2;var U2=ji(),B2=R0(),L2=Ft();function F2(){let t=(0,B2.buildUnmanagedMetadataFromMaybeClassElementMetadata)();return(0,L2.injectBase)(t,U2.decrementPendingClassMetadataCount)}});var pl=a(Hi=>{"use strict";Object.defineProperty(Hi,"__esModule",{value:!0});Hi.ResolvedValueElementMetadataKind=void 0;var U0;(function(t){t[t.multipleInjection=0]="multipleInjection",t[t.singleInjection=1]="singleInjection"})(U0||(Hi.ResolvedValueElementMetadataKind=U0={}))});var B0=a(Wi=>{"use strict";Object.defineProperty(Wi,"__esModule",{value:!0});Wi.BindingConstraintsImplementation=void 0;var fl=class t{#e;constructor(e){this.#e=e}get name(){return this.#e.elem.name}get serviceIdentifier(){return this.#e.elem.serviceIdentifier}get tags(){return this.#e.elem.tags}getAncestor(){if(this.#e.previous!==void 0)return new t(this.#e.previous)}};Wi.BindingConstraintsImplementation=fl});var L0=a(Ki=>{"use strict";Object.defineProperty(Ki,"__esModule",{value:!0});Ki.SingleInmutableLinkedList=void 0;var vl=class t{last;constructor(e){this.last=e}concat(e){return new t({elem:e,previous:this.last})}[Symbol.iterator](){let e=this.last;return{next:()=>{if(e===void 0)return{done:!0,value:void 0};let r=e.elem;return e=e.previous,{done:!1,value:r}}}}};Ki.SingleInmutableLinkedList=vl});var F0=a(gl=>{"use strict";Object.defineProperty(gl,"__esModule",{value:!0});gl.buildFilteredServiceBindings=H2;var k2=ed(),V2=Dt(),G2=Ti();function H2(t,e,r){let i=r?.customServiceIdentifier??e.serviceIdentifier,o=[...t.getBindings(i)??[]].filter(s=>s.isSatisfiedBy(e));if(o.length===0&&t.autobindOptions!==void 0&&typeof i=="function"){let s=W2(t.autobindOptions,i);t.setBinding(s),o.push(s)}return o}function W2(t,e){let i=(0,G2.getClassMetadata)(e).scope??t.scope;return{cache:{isRight:!1,value:void 0},id:(0,k2.getBindingId)(),implementationType:e,isSatisfiedBy:()=>!0,moduleId:void 0,onActivation:void 0,onDeactivation:void 0,scope:i,serviceIdentifier:e,type:V2.bindingTypeValues.Instance}}});var kt=a(hl=>{"use strict";Object.defineProperty(hl,"__esModule",{value:!0});hl.isPlanServiceRedirectionBindingNode=K2;function K2(t){return t.redirections!==void 0}});var V0=a(ml=>{"use strict";Object.defineProperty(ml,"__esModule",{value:!0});ml.stringifyBinding=$2;var $i=j(),k0=Dt();function $2(t){switch(t.type){case k0.bindingTypeValues.Instance:return`[ type: "${t.type}", serviceIdentifier: "${(0,$i.stringifyServiceIdentifier)(t.serviceIdentifier)}", scope: "${t.scope}", implementationType: "${t.implementationType.name}" ]`;case k0.bindingTypeValues.ServiceRedirection:return`[ type: "${t.type}", serviceIdentifier: "${(0,$i.stringifyServiceIdentifier)(t.serviceIdentifier)}", redirection: "${(0,$i.stringifyServiceIdentifier)(t.targetServiceIdentifier)}" ]`;default:return`[ type: "${t.type}", serviceIdentifier: "${(0,$i.stringifyServiceIdentifier)(t.serviceIdentifier)}", scope: "${t.scope}" ]`}}});var bl=a(yl=>{"use strict";Object.defineProperty(yl,"__esModule",{value:!0});yl.throwErrorWhenUnexpectedBindingsAmountFound=X2;var Xr=j(),z2=V0(),G0=q(),H0=R(),J2=kt();function X2(t,e,r,i){let n,o;(0,J2.isPlanServiceRedirectionBindingNode)(r)?(n=r.binding.targetServiceIdentifier,o=r.binding.serviceIdentifier):(n=r.serviceIdentifier,o=r.parent?.binding.serviceIdentifier),Array.isArray(t)?Q2(t,e,n,o,i):Y2(t,e,n,o,i)}function W0(t,e,r){let i=`No bindings found for service: "${(0,Xr.stringifyServiceIdentifier)(t)}".
30
+
31
+ Trying to resolve bindings for "${K0(t,e)}".
32
+
33
+ ${$0(r)}`;throw new G0.InversifyCoreError(H0.InversifyCoreErrorKind.planning,i)}function Q2(t,e,r,i,n){if(t.length===0)e||W0(r,i,n);else{let o=`Ambiguous bindings found for service: "${(0,Xr.stringifyServiceIdentifier)(r)}".
34
+
35
+ Registered bindings:
36
+
37
+ ${t.map(s=>(0,z2.stringifyBinding)(s.binding)).join(`
38
+ `)}
39
+
40
+ Trying to resolve bindings for "${K0(r,i)}".
41
+
42
+ ${$0(n)}`;throw new G0.InversifyCoreError(H0.InversifyCoreErrorKind.planning,o)}}function Y2(t,e,r,i,n){if(t===void 0&&!e)W0(r,i,n);else return}function K0(t,e){return e===void 0?`${(0,Xr.stringifyServiceIdentifier)(t)} (Root service)`:(0,Xr.stringifyServiceIdentifier)(e)}function $0(t){let e=t.tags.size===0?"":`
43
+ - tags:
44
+ - ${[...t.tags.keys()].map(r=>r.toString()).join(`
45
+ - `)}`;return`Binding constraints:
46
+ - service identifier: ${(0,Xr.stringifyServiceIdentifier)(t.serviceIdentifier)}
47
+ - name: ${t.name?.toString()??"-"}${e}`}});var J0=a(_l=>{"use strict";Object.defineProperty(_l,"__esModule",{value:!0});_l.checkPlanServiceRedirectionBindingNodeSingleInjectionBindings=z0;var Z2=kt(),e6=bl(),t6=1;function z0(t,e,r){if(t.redirections.length===t6){let[i]=t.redirections;(0,Z2.isPlanServiceRedirectionBindingNode)(i)&&z0(i,e,r);return}(0,e6.throwErrorWhenUnexpectedBindingsAmountFound)(t.redirections,e,t,r)}});var X0=a(Sl=>{"use strict";Object.defineProperty(Sl,"__esModule",{value:!0});Sl.checkServiceNodeSingleInjectionBindings=s6;var r6=J0(),n6=kt(),i6=bl(),o6=1;function s6(t,e,r){if(Array.isArray(t.bindings)&&t.bindings.length===o6){let[i]=t.bindings;(0,n6.isPlanServiceRedirectionBindingNode)(i)&&(0,r6.checkPlanServiceRedirectionBindingNodeSingleInjectionBindings)(i,e,r);return}(0,i6.throwErrorWhenUnexpectedBindingsAmountFound)(t.bindings,e,t,r)}});var Q0=a(Dl=>{"use strict";Object.defineProperty(Dl,"__esModule",{value:!0});Dl.isStackOverflowError=a6;function a6(t){if(!(t instanceof Error))return!1;let e=/stack space|call stack|too much recursion/i;return t instanceof RangeError&&e.test(t.message)||t.name==="InternalError"&&/too much recursion/.test(t.message)}});var Y0=a(Ol=>{"use strict";Object.defineProperty(Ol,"__esModule",{value:!0});Ol.handlePlanError=f6;var c6=j(),u6=Q0(),d6=q(),l6=R();function p6(t){let e=new Set;for(let r of t.servicesBranch){if(e.has(r))return[...e,r];e.add(r)}return[...e]}function f6(t,e){if((0,u6.isStackOverflowError)(e)){let r=v6(p6(t));throw new d6.InversifyCoreError(l6.InversifyCoreErrorKind.planning,`Circular dependency found: ${r}`,{cause:e})}throw e}function v6(t){let e=[...t];return e.length===0?"(No dependency trace)":e.map(c6.stringifyServiceIdentifier).join(" -> ")}});var Z0=a(El=>{"use strict";Object.defineProperty(El,"__esModule",{value:!0});El.isInstanceBindingNode=h6;var g6=Dt();function h6(t){return t.binding.type===g6.bindingTypeValues.Instance}});var iD=a(wl=>{"use strict";Object.defineProperty(wl,"__esModule",{value:!0});wl.plan=D6;var rD=j(),zi=B0(),Cl=Dt(),m6=L0(),eD=ke(),y6=pl(),Ji=F0(),Al=X0(),b6=Y0(),_6=Z0(),S6=kt();function D6(t){try{let e=new Map;t.rootConstraints.tag!==void 0&&e.set(t.rootConstraints.tag.key,t.rootConstraints.tag.value);let r=new m6.SingleInmutableLinkedList({elem:{name:t.rootConstraints.name,serviceIdentifier:t.rootConstraints.serviceIdentifier,tags:e},previous:void 0}),i=new zi.BindingConstraintsImplementation(r.last),n=(0,Ji.buildFilteredServiceBindings)(t,i),o=[],s={bindings:o,parent:void 0,serviceIdentifier:t.rootConstraints.serviceIdentifier};if(o.push(...Xi(t,r,n,s)),!t.rootConstraints.isMultiple){(0,Al.checkServiceNodeSingleInjectionBindings)(s,t.rootConstraints.isOptional??!1,i);let[l]=o;s.bindings=l}return{tree:{root:s}}}catch(e){(0,b6.handlePlanError)(t,e)}}function O6(t,e,r,i){let n=t.getClassMetadata(e.implementationType),o={binding:e,classMetadata:n,constructorParams:[],parent:i,propertyParams:new Map},s={autobindOptions:t.autobindOptions,getBindings:t.getBindings,getClassMetadata:t.getClassMetadata,node:o,servicesBranch:t.servicesBranch,setBinding:t.setBinding};return nD(s,r)}function tD(t,e,r){if(r.kind===eD.ClassElementMetadataKind.unmanaged)return;let i=rD.LazyServiceIdentifier.is(r.value)?r.value.unwrap():r.value,n=e.concat({name:r.name,serviceIdentifier:i,tags:r.tags}),o=new zi.BindingConstraintsImplementation(n.last),s=(0,Ji.buildFilteredServiceBindings)(t,o),l=[],u={bindings:l,parent:t.node,serviceIdentifier:i};if(l.push(...Xi(t,n,s,u)),r.kind===eD.ClassElementMetadataKind.singleInjection){(0,Al.checkServiceNodeSingleInjectionBindings)(u,r.optional,o);let[d]=l;u.bindings=d}return u}function E6(t,e,r){let i=rD.LazyServiceIdentifier.is(r.value)?r.value.unwrap():r.value,n=e.concat({name:r.name,serviceIdentifier:i,tags:r.tags}),o=new zi.BindingConstraintsImplementation(n.last),s=(0,Ji.buildFilteredServiceBindings)(t,o),l=[],u={bindings:l,parent:t.node,serviceIdentifier:i};if(l.push(...Xi(t,n,s,u)),r.kind===y6.ResolvedValueElementMetadataKind.singleInjection){(0,Al.checkServiceNodeSingleInjectionBindings)(u,r.optional,o);let[d]=l;u.bindings=d}return u}function C6(t,e,r,i){let n={binding:e,params:[],parent:i},o={autobindOptions:t.autobindOptions,getBindings:t.getBindings,getClassMetadata:t.getClassMetadata,node:n,servicesBranch:t.servicesBranch,setBinding:t.setBinding};return nD(o,r)}function Xi(t,e,r,i){let n=(0,S6.isPlanServiceRedirectionBindingNode)(i)?i.binding.targetServiceIdentifier:i.serviceIdentifier;t.servicesBranch.push(n);let o=[];for(let s of r)switch(s.type){case Cl.bindingTypeValues.Instance:{o.push(O6(t,s,e,i));break}case Cl.bindingTypeValues.ResolvedValue:{o.push(C6(t,s,e,i));break}case Cl.bindingTypeValues.ServiceRedirection:{let l=A6(t,e,s,i);o.push(l);break}default:o.push({binding:s,parent:i})}return t.servicesBranch.pop(),o}function A6(t,e,r,i){let n={binding:r,parent:i,redirections:[]},o=new zi.BindingConstraintsImplementation(e.last),s=(0,Ji.buildFilteredServiceBindings)(t,o,{customServiceIdentifier:r.targetServiceIdentifier});return n.redirections.push(...Xi(t,e,s,n)),n}function nD(t,e){return(0,_6.isInstanceBindingNode)(t.node)?w6(t,t.node,e):I6(t,t.node,e)}function w6(t,e,r){let i=e.classMetadata;for(let[n,o]of i.constructorArguments.entries())e.constructorParams[n]=tD(t,r,o);for(let[n,o]of i.properties){let s=tD(t,r,o);s!==void 0&&e.propertyParams.set(n,s)}return t.node}function I6(t,e,r){let i=e.binding.metadata;for(let[n,o]of i.arguments.entries())e.params[n]=E6(t,r,o);return t.node}});var oD=a(Qi=>{"use strict";Object.defineProperty(Qi,"__esModule",{value:!0});Qi.PlanResultCacheService=void 0;var Vt;(function(t){t[t.singleMandatory=0]="singleMandatory",t[t.singleOptional=1]="singleOptional",t[t.multipleMandatory=2]="multipleMandatory",t[t.multipleOptional=3]="multipleOptional",t[t.length=4]="length"})(Vt||(Vt={}));var Il=class{#e;#t;#i;#r;#s;constructor(){this.#e=this.#a(),this.#t=this.#a(),this.#r=this.#a(),this.#i=this.#a(),this.#s=[]}clearCache(){for(let e of this.#c())e.clear();for(let e of this.#s)e.clearCache()}get(e){return e.name===void 0?e.tag===void 0?this.#n(this.#e,e).get(e.serviceIdentifier):this.#n(this.#i,e).get(e.serviceIdentifier)?.get(e.tag.key)?.get(e.tag.value):e.tag===void 0?this.#n(this.#t,e).get(e.serviceIdentifier)?.get(e.name):this.#n(this.#r,e).get(e.serviceIdentifier)?.get(e.name)?.get(e.tag.key)?.get(e.tag.value)}set(e,r){e.name===void 0?e.tag===void 0?this.#n(this.#e,e).set(e.serviceIdentifier,r):this.#o(this.#o(this.#n(this.#i,e),e.serviceIdentifier),e.tag.key).set(e.tag.value,r):e.tag===void 0?this.#o(this.#n(this.#t,e),e.serviceIdentifier).set(e.name,r):this.#o(this.#o(this.#o(this.#n(this.#r,e),e.serviceIdentifier),e.name),e.tag.key).set(e.tag.value,r)}subscribe(e){this.#s.push(e)}#a(){let e=new Array(Vt.length);for(let r=0;r<e.length;++r)e[r]=new Map;return e}#o(e,r){let i=e.get(r);return i===void 0&&(i=new Map,e.set(r,i)),i}#n(e,r){return e[this.#u(r)]}#c(){return[...this.#e,...this.#t,...this.#r,...this.#i]}#u(e){return e.isMultiple?e.optional===!0?Vt.multipleOptional:Vt.multipleMandatory:e.optional===!0?Vt.singleOptional:Vt.singleMandatory}};Qi.PlanResultCacheService=Il});var sD=a(Pl=>{"use strict";Object.defineProperty(Pl,"__esModule",{value:!0});Pl.resolveConstantValueBindingCallback=P6;function P6(t,e){return e.value}});var Ml=a(xl=>{"use strict";Object.defineProperty(xl,"__esModule",{value:!0});xl.cacheResolvedValue=M6;var x6=j();function M6(t,e){return(0,x6.isPromise)(e)?(t.cache={isRight:!0,value:e},e.then(r=>aD(t,r))):aD(t,e)}function aD(t,e){return t.cache={isRight:!0,value:e},e}});var dD=a(Tl=>{"use strict";Object.defineProperty(Tl,"__esModule",{value:!0});Tl.resolveBindingServiceActivations=T6;var cD=j();function T6(t,e,r){let i=t.getActivations(e);return i===void 0?r:(0,cD.isPromise)(r)?uD(t,r,i[Symbol.iterator]()):j6(t,r,i[Symbol.iterator]())}function j6(t,e,r){let i=e,n=r.next();for(;n.done!==!0;){let o=n.value(t.context,i);if((0,cD.isPromise)(o))return uD(t,o,r);i=o,n=r.next()}return i}async function uD(t,e,r){let i=await e,n=r.next();for(;n.done!==!0;)i=await n.value(t.context,i),n=r.next();return i}});var ql=a(jl=>{"use strict";Object.defineProperty(jl,"__esModule",{value:!0});jl.resolveBindingActivations=N6;var q6=j(),R6=dD();function N6(t,e,r){let i=r;if(e.onActivation!==void 0){let n=e.onActivation;(0,q6.isPromise)(i)?i=i.then(o=>n(t.context,o)):i=n(t.context,i)}return(0,R6.resolveBindingServiceActivations)(t,e.serviceIdentifier,i)}});var Yi=a(Rl=>{"use strict";Object.defineProperty(Rl,"__esModule",{value:!0});Rl.resolveSingletonScopedBinding=L6;var U6=Ml(),B6=ql();function L6(t){return(e,r)=>{if(r.cache.isRight)return r.cache.value;let i=(0,B6.resolveBindingActivations)(e,r,t(e,r));return(0,U6.cacheResolvedValue)(r,i)}}});var lD=a(Zi=>{"use strict";Object.defineProperty(Zi,"__esModule",{value:!0});Zi.resolveConstantValueBinding=void 0;var F6=sD(),k6=Yi();Zi.resolveConstantValueBinding=(0,k6.resolveSingletonScopedBinding)(F6.resolveConstantValueBindingCallback)});var pD=a(Nl=>{"use strict";Object.defineProperty(Nl,"__esModule",{value:!0});Nl.resolveDynamicValueBindingCallback=V6;function V6(t,e){return e.value(t.context)}});var fD=a(Ul=>{"use strict";Object.defineProperty(Ul,"__esModule",{value:!0});Ul.getSelf=G6;function G6(t){return t}});var eo=a(Fl=>{"use strict";Object.defineProperty(Fl,"__esModule",{value:!0});Fl.resolveScoped=W6;var Bl=yi(),H6=Ml(),Ll=ql();function W6(t,e){return(r,i)=>{let n=t(i);switch(n.scope){case Bl.bindingScopeValues.Singleton:{if(n.cache.isRight)return n.cache.value;let o=(0,Ll.resolveBindingActivations)(r,n,e(r,i));return(0,H6.cacheResolvedValue)(n,o)}case Bl.bindingScopeValues.Request:{if(r.requestScopeCache.has(n.id))return r.requestScopeCache.get(n.id);let o=(0,Ll.resolveBindingActivations)(r,n,e(r,i));return r.requestScopeCache.set(n.id,o),o}case Bl.bindingScopeValues.Transient:return(0,Ll.resolveBindingActivations)(r,n,e(r,i))}}}});var vD=a(to=>{"use strict";Object.defineProperty(to,"__esModule",{value:!0});to.resolveScopedBinding=void 0;var K6=fD(),$6=eo(),z6=t=>(0,$6.resolveScoped)(K6.getSelf,t);to.resolveScopedBinding=z6});var gD=a(ro=>{"use strict";Object.defineProperty(ro,"__esModule",{value:!0});ro.resolveDynamicValueBinding=void 0;var J6=pD(),X6=vD();ro.resolveDynamicValueBinding=(0,X6.resolveScopedBinding)(J6.resolveDynamicValueBindingCallback)});var hD=a(kl=>{"use strict";Object.defineProperty(kl,"__esModule",{value:!0});kl.resolveFactoryBindingCallback=Q6;function Q6(t,e){return e.factory(t.context)}});var mD=a(no=>{"use strict";Object.defineProperty(no,"__esModule",{value:!0});no.resolveFactoryBinding=void 0;var Y6=hD(),Z6=Yi();no.resolveFactoryBinding=(0,Z6.resolveSingletonScopedBinding)(Y6.resolveFactoryBindingCallback)});var yD=a(Vl=>{"use strict";Object.defineProperty(Vl,"__esModule",{value:!0});Vl.resolveInstanceBindingConstructorParams=t4;var e4=j();function t4(t){return(e,r)=>{let i=[];for(let n of r.constructorParams)n===void 0?i.push(void 0):i.push(t(e,n));return i.some(e4.isPromise)?Promise.all(i):i}}});var bD=a(Gl=>{"use strict";Object.defineProperty(Gl,"__esModule",{value:!0});Gl.resolveInstanceBindingNode=n4;var r4=j();function n4(t,e,r){return(i,n)=>{let o=t(i,n);return(0,r4.isPromise)(o)?e(o,i,n):r(o,i,n)}}});var _D=a(Hl=>{"use strict";Object.defineProperty(Hl,"__esModule",{value:!0});Hl.resolveInstanceBindingNodeAsyncFromConstructorParams=i4;function i4(t){return async(e,r,i)=>{let n=await e;return t(n,r,i)}}});var DD=a(Wl=>{"use strict";Object.defineProperty(Wl,"__esModule",{value:!0});Wl.resolvePostConstruct=o4;var SD=j(),io=q(),oo=R();function o4(t,e,r){let i=s4(t,e,r);return(0,SD.isPromise)(i)?i.then(()=>t):t}function s4(t,e,r){if(r!==void 0)if(r in t)if(typeof t[r]=="function"){let i;try{i=t[r]()}catch(n){throw new io.InversifyCoreError(oo.InversifyCoreErrorKind.resolution,`Unexpected error found when calling "${r.toString()}" @postConstruct decorated method on class "${e.implementationType.name}"`,{cause:n})}if((0,SD.isPromise)(i))return a4(e,r,i)}else throw new io.InversifyCoreError(oo.InversifyCoreErrorKind.resolution,`Expecting a "${r.toString()}" method when resolving "${e.implementationType.name}" class @postConstruct decorated method, a non function property was found instead.`);else throw new io.InversifyCoreError(oo.InversifyCoreErrorKind.resolution,`Expecting a "${r.toString()}" property when resolving "${e.implementationType.name}" class @postConstruct decorated method, none found.`)}async function a4(t,e,r){try{await r}catch(i){throw new io.InversifyCoreError(oo.InversifyCoreErrorKind.resolution,`Unexpected error found when calling "${e.toString()}" @postConstruct decorated method on class "${t.implementationType.name}"`,{cause:i})}}});var ED=a(Kl=>{"use strict";Object.defineProperty(Kl,"__esModule",{value:!0});Kl.resolveInstanceBindingNodeFromConstructorParams=u4;var c4=j(),OD=DD();function u4(t){return(e,r,i)=>{let n=new i.binding.implementationType(...e),o=t(r,n,i);return(0,c4.isPromise)(o)?o.then(()=>(0,OD.resolvePostConstruct)(n,i.binding,i.classMetadata.lifecycle.postConstructMethodName)):(0,OD.resolvePostConstruct)(n,i.binding,i.classMetadata.lifecycle.postConstructMethodName)}}});var CD=a($l=>{"use strict";Object.defineProperty($l,"__esModule",{value:!0});$l.resolveProviderBindingCallback=d4;function d4(t,e){return e.provider(t.context)}});var AD=a(so=>{"use strict";Object.defineProperty(so,"__esModule",{value:!0});so.resolveProviderBinding=void 0;var l4=CD(),p4=Yi();so.resolveProviderBinding=(0,p4.resolveSingletonScopedBinding)(l4.resolveProviderBindingCallback)});var wD=a(zl=>{"use strict";Object.defineProperty(zl,"__esModule",{value:!0});zl.resolveResolvedValueBindingNode=v4;var f4=j();function v4(t){return(e,r)=>{let i=t(e,r);return(0,f4.isPromise)(i)?i.then(n=>r.binding.factory(...n)):r.binding.factory(...i)}}});var ID=a(Jl=>{"use strict";Object.defineProperty(Jl,"__esModule",{value:!0});Jl.resolveResolvedValueBindingParams=h4;var g4=j();function h4(t){return(e,r)=>{let i=[];for(let n of r.params)i.push(t(e,n));return i.some(g4.isPromise)?Promise.all(i):i}}});var PD=a(Xl=>{"use strict";Object.defineProperty(Xl,"__esModule",{value:!0});Xl.getInstanceNodeBinding=m4;function m4(t){return t.binding}});var xD=a(ao=>{"use strict";Object.defineProperty(ao,"__esModule",{value:!0});ao.resolveScopedInstanceBindingNode=void 0;var y4=PD(),b4=eo(),_4=t=>(0,b4.resolveScoped)(y4.getInstanceNodeBinding,t);ao.resolveScopedInstanceBindingNode=_4});var MD=a(Ql=>{"use strict";Object.defineProperty(Ql,"__esModule",{value:!0});Ql.getResolvedValueNodeBinding=S4;function S4(t){return t.binding}});var TD=a(co=>{"use strict";Object.defineProperty(co,"__esModule",{value:!0});co.resolveScopedResolvedValueBindingNode=void 0;var D4=MD(),O4=eo(),E4=t=>(0,O4.resolveScoped)(D4.getResolvedValueNodeBinding,t);co.resolveScopedResolvedValueBindingNode=E4});var jD=a(Yl=>{"use strict";Object.defineProperty(Yl,"__esModule",{value:!0});Yl.resolveServiceRedirectionBindingNode=A4;var C4=kt();function A4(t){function e(r,i){let n=[];for(let o of i.redirections)(0,C4.isPlanServiceRedirectionBindingNode)(o)?n.push(...e(r,o)):n.push(t(r,o));return n}return e}});var qD=a(Zl=>{"use strict";Object.defineProperty(Zl,"__esModule",{value:!0});Zl.setInstanceProperties=M4;var w4=j(),I4=q(),P4=R(),x4=ke();function M4(t){return(e,r,i)=>{let n=[];for(let[o,s]of i.propertyParams){let l=i.classMetadata.properties.get(o);if(l===void 0)throw new I4.InversifyCoreError(P4.InversifyCoreErrorKind.resolution,`Expecting metadata at property "${o.toString()}", none found`);l.kind!==x4.ClassElementMetadataKind.unmanaged&&s.bindings!==void 0&&(r[o]=t(e,s),(0,w4.isPromise)(r[o])&&n.push((async()=>{r[o]=await r[o]})()))}if(n.length>0)return Promise.all(n).then(()=>{})}}});var LD=a(tp=>{"use strict";Object.defineProperty(tp,"__esModule",{value:!0});tp.resolve=Y4;var T4=j(),fr=Dt(),j4=q(),q4=R(),UD=kt(),R4=lD(),N4=gD(),U4=mD(),B4=yD(),L4=bD(),F4=_D(),RD=ED(),k4=AD(),V4=wD(),G4=ID(),H4=xD(),W4=TD(),K4=jD(),$4=qD(),ND=(0,$4.setInstanceProperties)(uo),BD=(0,K4.resolveServiceRedirectionBindingNode)(ep),z4=(0,L4.resolveInstanceBindingNode)((0,B4.resolveInstanceBindingConstructorParams)(uo),(0,F4.resolveInstanceBindingNodeAsyncFromConstructorParams)((0,RD.resolveInstanceBindingNodeFromConstructorParams)(ND)),(0,RD.resolveInstanceBindingNodeFromConstructorParams)(ND)),J4=(0,V4.resolveResolvedValueBindingNode)((0,G4.resolveResolvedValueBindingParams)(uo)),X4=(0,H4.resolveScopedInstanceBindingNode)(z4),Q4=(0,W4.resolveScopedResolvedValueBindingNode)(J4);function Y4(t){let e=t.planResult.tree.root;return uo(t,e)}function ep(t,e){switch(e.binding.type){case fr.bindingTypeValues.ConstantValue:return(0,R4.resolveConstantValueBinding)(t,e.binding);case fr.bindingTypeValues.DynamicValue:return(0,N4.resolveDynamicValueBinding)(t,e.binding);case fr.bindingTypeValues.Factory:return(0,U4.resolveFactoryBinding)(t,e.binding);case fr.bindingTypeValues.Instance:return X4(t,e);case fr.bindingTypeValues.Provider:return(0,k4.resolveProviderBinding)(t,e.binding);case fr.bindingTypeValues.ResolvedValue:return Q4(t,e)}}function uo(t,e){if(e.bindings!==void 0)return Array.isArray(e.bindings)?Z4(t,e.bindings):eH(t,e.bindings)}function Z4(t,e){let r=[];for(let i of e)(0,UD.isPlanServiceRedirectionBindingNode)(i)?r.push(...BD(t,i)):r.push(ep(t,i));return r.some(T4.isPromise)?Promise.all(r):r}function eH(t,e){if((0,UD.isPlanServiceRedirectionBindingNode)(e)){let r=BD(t,e);if(r.length===1)return r[0];throw new j4.InversifyCoreError(q4.InversifyCoreErrorKind.resolution,"Unexpected multiple resolved values on single injection")}else return ep(t,e)}});var FD=a(rp=>{"use strict";Object.defineProperty(rp,"__esModule",{value:!0});rp.isScopedBinding=tH;function tH(t){return t.scope!==void 0}});var VD=a(np=>{"use strict";Object.defineProperty(np,"__esModule",{value:!0});np.resolveBindingPreDestroy=iH;var rH=j(),nH=Dt();function iH(t,e){if(e.type===nH.bindingTypeValues.Instance){let r=t.getClassMetadata(e.implementationType),i=e.cache.value;return(0,rH.isPromise)(i)?i.then(n=>kD(r,n)):kD(r,i)}}function kD(t,e){if(t.lifecycle.preDestroyMethodName!==void 0&&typeof e[t.lifecycle.preDestroyMethodName]=="function")return e[t.lifecycle.preDestroyMethodName]()}});var WD=a(ip=>{"use strict";Object.defineProperty(ip,"__esModule",{value:!0});ip.resolveBindingServiceDeactivations=oH;var GD=j();function oH(t,e,r){let i=t.getDeactivations(e);if(i!==void 0)return(0,GD.isPromise)(r)?HD(r,i[Symbol.iterator]()):sH(r,i[Symbol.iterator]())}function sH(t,e){let r=e.next();for(;r.done!==!0;){let i=r.value(t);if((0,GD.isPromise)(i))return HD(t,e);r=e.next()}}async function HD(t,e){let r=await t,i=e.next();for(;i.done!==!0;)await i.value(r),i=e.next()}});var JD=a(op=>{"use strict";Object.defineProperty(op,"__esModule",{value:!0});op.resolveBindingDeactivations=uH;var aH=j(),cH=VD(),KD=WD();function uH(t,e){let r=(0,cH.resolveBindingPreDestroy)(t,e);return r===void 0?$D(t,e):r.then(()=>$D(t,e))}function $D(t,e){let r=e.cache;return(0,aH.isPromise)(r.value)?r.value.then(i=>zD(t,e,i)):zD(t,e,r.value)}function zD(t,e,r){let i;if(e.onDeactivation!==void 0){let n=e.onDeactivation;i=n(r)}return i===void 0?(0,KD.resolveBindingServiceDeactivations)(t,e.serviceIdentifier,r):i.then(()=>(0,KD.resolveBindingServiceDeactivations)(t,e.serviceIdentifier,r))}});var lo=a(sp=>{"use strict";Object.defineProperty(sp,"__esModule",{value:!0});sp.resolveBindingsDeactivations=fH;var dH=FD(),lH=yi(),pH=JD();function fH(t,e){if(e===void 0)return;let r=vH(e),i=[];for(let n of r){let o=(0,pH.resolveBindingDeactivations)(t,n);o!==void 0&&i.push(o)}if(i.length>0)return Promise.all(i).then(()=>{})}function vH(t){let e=[];for(let r of t)(0,dH.isScopedBinding)(r)&&r.scope===lH.bindingScopeValues.Singleton&&r.cache.isRight&&e.push(r);return e}});var XD=a(ap=>{"use strict";Object.defineProperty(ap,"__esModule",{value:!0});ap.resolveModuleDeactivations=hH;var gH=lo();function hH(t,e){let r=t.getBindingsFromModule(e);return(0,gH.resolveBindingsDeactivations)(t,r)}});var QD=a(cp=>{"use strict";Object.defineProperty(cp,"__esModule",{value:!0});cp.resolveServiceDeactivations=yH;var mH=lo();function yH(t,e){let r=t.getBindings(e);return(0,mH.resolveBindingsDeactivations)(t,r)}});var Qr=a(g=>{"use strict";Object.defineProperty(g,"__esModule",{value:!0});g.unmanaged=g.tagged=g.resolveServiceDeactivations=g.resolveModuleDeactivations=g.ResolvedValueElementMetadataKind=g.resolveBindingsDeactivations=g.resolve=g.preDestroy=g.postConstruct=g.PlanResultCacheService=g.plan=g.optional=g.named=g.multiInject=g.injectFromBase=g.injectable=g.inject=g.getClassMetadata=g.getBindingId=g.decorate=g.DeactivationsService=g.ClassElementMetadataKind=g.bindingTypeValues=g.BindingService=g.bindingScopeValues=g.ActivationsService=void 0;var bH=ed();Object.defineProperty(g,"getBindingId",{enumerable:!0,get:function(){return bH.getBindingId}});var _H=yi();Object.defineProperty(g,"bindingScopeValues",{enumerable:!0,get:function(){return _H.bindingScopeValues}});var SH=Dt();Object.defineProperty(g,"bindingTypeValues",{enumerable:!0,get:function(){return SH.bindingTypeValues}});var DH=TS();Object.defineProperty(g,"ActivationsService",{enumerable:!0,get:function(){return DH.ActivationsService}});var OH=jS();Object.defineProperty(g,"BindingService",{enumerable:!0,get:function(){return OH.BindingService}});var EH=qS();Object.defineProperty(g,"DeactivationsService",{enumerable:!0,get:function(){return EH.DeactivationsService}});var CH=RS();Object.defineProperty(g,"decorate",{enumerable:!0,get:function(){return CH.decorate}});var AH=Ti();Object.defineProperty(g,"getClassMetadata",{enumerable:!0,get:function(){return AH.getClassMetadata}});var wH=o0();Object.defineProperty(g,"inject",{enumerable:!0,get:function(){return wH.inject}});var IH=g0();Object.defineProperty(g,"injectable",{enumerable:!0,get:function(){return IH.injectable}});var PH=S0();Object.defineProperty(g,"injectFromBase",{enumerable:!0,get:function(){return PH.injectFromBase}});var xH=D0();Object.defineProperty(g,"multiInject",{enumerable:!0,get:function(){return xH.multiInject}});var MH=C0();Object.defineProperty(g,"named",{enumerable:!0,get:function(){return MH.named}});var TH=w0();Object.defineProperty(g,"optional",{enumerable:!0,get:function(){return TH.optional}});var jH=P0();Object.defineProperty(g,"postConstruct",{enumerable:!0,get:function(){return jH.postConstruct}});var qH=M0();Object.defineProperty(g,"preDestroy",{enumerable:!0,get:function(){return qH.preDestroy}});var RH=j0();Object.defineProperty(g,"tagged",{enumerable:!0,get:function(){return RH.tagged}});var NH=N0();Object.defineProperty(g,"unmanaged",{enumerable:!0,get:function(){return NH.unmanaged}});var UH=ke();Object.defineProperty(g,"ClassElementMetadataKind",{enumerable:!0,get:function(){return UH.ClassElementMetadataKind}});var BH=pl();Object.defineProperty(g,"ResolvedValueElementMetadataKind",{enumerable:!0,get:function(){return BH.ResolvedValueElementMetadataKind}});var LH=iD();Object.defineProperty(g,"plan",{enumerable:!0,get:function(){return LH.plan}});var FH=oD();Object.defineProperty(g,"PlanResultCacheService",{enumerable:!0,get:function(){return FH.PlanResultCacheService}});var kH=LD();Object.defineProperty(g,"resolve",{enumerable:!0,get:function(){return kH.resolve}});var VH=lo();Object.defineProperty(g,"resolveBindingsDeactivations",{enumerable:!0,get:function(){return VH.resolveBindingsDeactivations}});var GH=XD();Object.defineProperty(g,"resolveModuleDeactivations",{enumerable:!0,get:function(){return GH.resolveModuleDeactivations}});var HH=QD();Object.defineProperty(g,"resolveServiceDeactivations",{enumerable:!0,get:function(){return HH.resolveServiceDeactivations}})});var up=a(po=>{"use strict";Object.defineProperty(po,"__esModule",{value:!0});po.bindingIdentifierSymbol=void 0;po.bindingIdentifierSymbol=Symbol.for("@inversifyjs/container/bindingIdentifier")});var YD=a(dp=>{"use strict";Object.defineProperty(dp,"__esModule",{value:!0});dp.isBindingIdentifier=KH;var WH=up();function KH(t){return typeof t=="object"&&t!==null&&t[WH.bindingIdentifierSymbol]===!0}});var ZD=a(fo=>{"use strict";Object.defineProperty(fo,"__esModule",{value:!0});fo.BindingConstraintUtils=void 0;var lp=class{static always=e=>!0};fo.BindingConstraintUtils=lp});var eO=a(pp=>{"use strict";Object.defineProperty(pp,"__esModule",{value:!0});pp.buildBindingIdentifier=zH;var $H=up();function zH(t){return{[$H.bindingIdentifierSymbol]:!0,id:t.id}}});var vr=a(fp=>{"use strict";Object.defineProperty(fp,"__esModule",{value:!0});fp.isAnyAncestorBindingConstraints=JH;function JH(t){return e=>{for(let r=e.getAncestor();r!==void 0;r=r.getAncestor())if(t(r))return!0;return!1}}});var gr=a(vp=>{"use strict";Object.defineProperty(vp,"__esModule",{value:!0});vp.isBindingConstraintsWithName=XH;function XH(t){return e=>e.name===t}});var tO=a(gp=>{"use strict";Object.defineProperty(gp,"__esModule",{value:!0});gp.isAnyAncestorBindingConstraintsWithName=ZH;var QH=vr(),YH=gr();function ZH(t){return(0,QH.isAnyAncestorBindingConstraints)((0,YH.isBindingConstraintsWithName)(t))}});var Yr=a(hp=>{"use strict";Object.defineProperty(hp,"__esModule",{value:!0});hp.isBindingConstraintsWithServiceId=eW;function eW(t){return e=>e.serviceIdentifier===t}});var rO=a(mp=>{"use strict";Object.defineProperty(mp,"__esModule",{value:!0});mp.isAnyAncestorBindingConstraintsWithServiceId=nW;var tW=vr(),rW=Yr();function nW(t){return(0,tW.isAnyAncestorBindingConstraints)((0,rW.isBindingConstraintsWithServiceId)(t))}});var hr=a(yp=>{"use strict";Object.defineProperty(yp,"__esModule",{value:!0});yp.isBindingConstraintsWithTag=iW;function iW(t,e){return r=>r.tags.has(t)&&r.tags.get(t)===e}});var nO=a(bp=>{"use strict";Object.defineProperty(bp,"__esModule",{value:!0});bp.isAnyAncestorBindingConstraintsWithTag=aW;var oW=vr(),sW=hr();function aW(t,e){return(0,oW.isAnyAncestorBindingConstraints)((0,sW.isBindingConstraintsWithTag)(t,e))}});var iO=a(_p=>{"use strict";Object.defineProperty(_p,"__esModule",{value:!0});_p.isBindingConstraintsWithNoNameNorTags=cW;function cW(t){return t.name===void 0&&t.tags.size===0}});var Zr=a(Sp=>{"use strict";Object.defineProperty(Sp,"__esModule",{value:!0});Sp.isNoAncestorBindingConstraints=dW;var uW=vr();function dW(t){let e=(0,uW.isAnyAncestorBindingConstraints)(t);return r=>!e(r)}});var oO=a(Dp=>{"use strict";Object.defineProperty(Dp,"__esModule",{value:!0});Dp.isNoAncestorBindingConstraintsWithName=fW;var lW=gr(),pW=Zr();function fW(t){return(0,pW.isNoAncestorBindingConstraints)((0,lW.isBindingConstraintsWithName)(t))}});var sO=a(Op=>{"use strict";Object.defineProperty(Op,"__esModule",{value:!0});Op.isNoAncestorBindingConstraintsWithServiceId=hW;var vW=Yr(),gW=Zr();function hW(t){return(0,gW.isNoAncestorBindingConstraints)((0,vW.isBindingConstraintsWithServiceId)(t))}});var aO=a(Ep=>{"use strict";Object.defineProperty(Ep,"__esModule",{value:!0});Ep.isNoAncestorBindingConstraintsWithTag=bW;var mW=hr(),yW=Zr();function bW(t,e){return(0,yW.isNoAncestorBindingConstraints)((0,mW.isBindingConstraintsWithTag)(t,e))}});var en=a(Cp=>{"use strict";Object.defineProperty(Cp,"__esModule",{value:!0});Cp.isNotParentBindingConstraints=_W;function _W(t){return e=>{let r=e.getAncestor();return r===void 0||!t(r)}}});var cO=a(Ap=>{"use strict";Object.defineProperty(Ap,"__esModule",{value:!0});Ap.isNotParentBindingConstraintsWithName=OW;var SW=gr(),DW=en();function OW(t){return(0,DW.isNotParentBindingConstraints)((0,SW.isBindingConstraintsWithName)(t))}});var uO=a(wp=>{"use strict";Object.defineProperty(wp,"__esModule",{value:!0});wp.isNotParentBindingConstraintsWithServiceId=AW;var EW=Yr(),CW=en();function AW(t){return(0,CW.isNotParentBindingConstraints)((0,EW.isBindingConstraintsWithServiceId)(t))}});var dO=a(Ip=>{"use strict";Object.defineProperty(Ip,"__esModule",{value:!0});Ip.isNotParentBindingConstraintsWithTag=PW;var wW=hr(),IW=en();function PW(t,e){return(0,IW.isNotParentBindingConstraints)((0,wW.isBindingConstraintsWithTag)(t,e))}});var tn=a(Pp=>{"use strict";Object.defineProperty(Pp,"__esModule",{value:!0});Pp.isParentBindingConstraints=xW;function xW(t){return e=>{let r=e.getAncestor();return r!==void 0&&t(r)}}});var lO=a(xp=>{"use strict";Object.defineProperty(xp,"__esModule",{value:!0});xp.isParentBindingConstraintsWithName=jW;var MW=gr(),TW=tn();function jW(t){return(0,TW.isParentBindingConstraints)((0,MW.isBindingConstraintsWithName)(t))}});var pO=a(Mp=>{"use strict";Object.defineProperty(Mp,"__esModule",{value:!0});Mp.isParentBindingConstraintsWithServiceId=NW;var qW=Yr(),RW=tn();function NW(t){return(0,RW.isParentBindingConstraints)((0,qW.isBindingConstraintsWithServiceId)(t))}});var fO=a(Tp=>{"use strict";Object.defineProperty(Tp,"__esModule",{value:!0});Tp.isParentBindingConstraintsWithTag=LW;var UW=hr(),BW=tn();function LW(t,e){return(0,BW.isParentBindingConstraints)((0,UW.isBindingConstraintsWithTag)(t,e))}});var vO=a(jp=>{"use strict";Object.defineProperty(jp,"__esModule",{value:!0});jp.isResolvedValueMetadataInjectOptions=kW;var FW=j();function kW(t){return typeof t=="object"&&!FW.LazyServiceIdentifier.is(t)}});var gO=a(fe=>{"use strict";Object.defineProperty(fe,"__esModule",{value:!0});fe.BindInWhenOnFluentSyntaxImplementation=fe.BindWhenOnFluentSyntaxImplementation=fe.BindWhenFluentSyntaxImplementation=fe.BindOnFluentSyntaxImplementation=fe.BindToFluentSyntaxImplementation=fe.BindInFluentSyntaxImplementation=void 0;var H=Qr(),Gt=Qr(),Ht=ZD(),Rp=eO(),VW=vr(),GW=tO(),HW=rO(),WW=nO(),KW=gr(),$W=iO(),zW=hr(),JW=Zr(),XW=oO(),QW=sO(),YW=aO(),ZW=en(),e8=cO(),t8=uO(),r8=dO(),n8=tn(),i8=lO(),o8=pO(),s8=fO(),a8=vO(),vo=class{#e;constructor(e){this.#e=e}getIdentifier(){return(0,Rp.buildBindingIdentifier)(this.#e)}inRequestScope(){return this.#e.scope=H.bindingScopeValues.Request,new Ve(this.#e)}inSingletonScope(){return this.#e.scope=H.bindingScopeValues.Singleton,new Ve(this.#e)}inTransientScope(){return this.#e.scope=H.bindingScopeValues.Transient,new Ve(this.#e)}};fe.BindInFluentSyntaxImplementation=vo;var qp=class{#e;#t;#i;#r;constructor(e,r,i,n){this.#e=e,this.#t=r,this.#i=i,this.#r=n}to(e){let r=(0,H.getClassMetadata)(e),i={cache:{isRight:!1,value:void 0},id:(0,Gt.getBindingId)(),implementationType:e,isSatisfiedBy:Ht.BindingConstraintUtils.always,moduleId:this.#t,onActivation:void 0,onDeactivation:void 0,scope:r.scope??this.#i,serviceIdentifier:this.#r,type:H.bindingTypeValues.Instance};return this.#e(i),new mr(i)}toSelf(){if(typeof this.#r!="function")throw new Error('"toSelf" function can only be applied when a newable function is used as service identifier');return this.to(this.#r)}toConstantValue(e){let r={cache:{isRight:!1,value:void 0},id:(0,Gt.getBindingId)(),isSatisfiedBy:Ht.BindingConstraintUtils.always,moduleId:this.#t,onActivation:void 0,onDeactivation:void 0,scope:H.bindingScopeValues.Singleton,serviceIdentifier:this.#r,type:H.bindingTypeValues.ConstantValue,value:e};return this.#e(r),new Ve(r)}toDynamicValue(e){let r={cache:{isRight:!1,value:void 0},id:(0,Gt.getBindingId)(),isSatisfiedBy:Ht.BindingConstraintUtils.always,moduleId:this.#t,onActivation:void 0,onDeactivation:void 0,scope:this.#i,serviceIdentifier:this.#r,type:H.bindingTypeValues.DynamicValue,value:e};return this.#e(r),new mr(r)}toResolvedValue(e,r){let i={cache:{isRight:!1,value:void 0},factory:e,id:(0,Gt.getBindingId)(),isSatisfiedBy:Ht.BindingConstraintUtils.always,metadata:this.#s(r),moduleId:this.#t,onActivation:void 0,onDeactivation:void 0,scope:this.#i,serviceIdentifier:this.#r,type:H.bindingTypeValues.ResolvedValue};return this.#e(i),new mr(i)}toFactory(e){let r={cache:{isRight:!1,value:void 0},factory:e,id:(0,Gt.getBindingId)(),isSatisfiedBy:Ht.BindingConstraintUtils.always,moduleId:this.#t,onActivation:void 0,onDeactivation:void 0,scope:H.bindingScopeValues.Singleton,serviceIdentifier:this.#r,type:H.bindingTypeValues.Factory};return this.#e(r),new Ve(r)}toProvider(e){let r={cache:{isRight:!1,value:void 0},id:(0,Gt.getBindingId)(),isSatisfiedBy:Ht.BindingConstraintUtils.always,moduleId:this.#t,onActivation:void 0,onDeactivation:void 0,provider:e,scope:H.bindingScopeValues.Singleton,serviceIdentifier:this.#r,type:H.bindingTypeValues.Provider};return this.#e(r),new Ve(r)}toService(e){let r={id:(0,Gt.getBindingId)(),isSatisfiedBy:Ht.BindingConstraintUtils.always,moduleId:this.#t,serviceIdentifier:this.#r,targetServiceIdentifier:e,type:H.bindingTypeValues.ServiceRedirection};this.#e(r)}#s(e){return{arguments:(e??[]).map(i=>(0,a8.isResolvedValueMetadataInjectOptions)(i)?{kind:i.isMultiple===!0?H.ResolvedValueElementMetadataKind.multipleInjection:H.ResolvedValueElementMetadataKind.singleInjection,name:i.name,optional:i.optional??!1,tags:new Map((i.tags??[]).map(n=>[n.key,n.value])),value:i.serviceIdentifier}:{kind:H.ResolvedValueElementMetadataKind.singleInjection,name:void 0,optional:!1,tags:new Map,value:i})}}};fe.BindToFluentSyntaxImplementation=qp;var rn=class{#e;constructor(e){this.#e=e}getIdentifier(){return(0,Rp.buildBindingIdentifier)(this.#e)}onActivation(e){return this.#e.onActivation=e,new yr(this.#e)}onDeactivation(e){return this.#e.onDeactivation=e,new yr(this.#e)}};fe.BindOnFluentSyntaxImplementation=rn;var yr=class{#e;constructor(e){this.#e=e}getIdentifier(){return(0,Rp.buildBindingIdentifier)(this.#e)}when(e){return this.#e.isSatisfiedBy=e,new rn(this.#e)}whenAnyAncestor(e){return this.when((0,VW.isAnyAncestorBindingConstraints)(e))}whenAnyAncestorIs(e){return this.when((0,HW.isAnyAncestorBindingConstraintsWithServiceId)(e))}whenAnyAncestorNamed(e){return this.when((0,GW.isAnyAncestorBindingConstraintsWithName)(e))}whenAnyAncestorTagged(e,r){return this.when((0,WW.isAnyAncestorBindingConstraintsWithTag)(e,r))}whenDefault(){return this.when($W.isBindingConstraintsWithNoNameNorTags)}whenNamed(e){return this.when((0,KW.isBindingConstraintsWithName)(e))}whenNoParent(e){return this.when((0,ZW.isNotParentBindingConstraints)(e))}whenNoParentIs(e){return this.when((0,t8.isNotParentBindingConstraintsWithServiceId)(e))}whenNoParentNamed(e){return this.when((0,e8.isNotParentBindingConstraintsWithName)(e))}whenNoParentTagged(e,r){return this.when((0,r8.isNotParentBindingConstraintsWithTag)(e,r))}whenParent(e){return this.when((0,n8.isParentBindingConstraints)(e))}whenParentIs(e){return this.when((0,o8.isParentBindingConstraintsWithServiceId)(e))}whenParentNamed(e){return this.when((0,i8.isParentBindingConstraintsWithName)(e))}whenParentTagged(e,r){return this.when((0,s8.isParentBindingConstraintsWithTag)(e,r))}whenTagged(e,r){return this.when((0,zW.isBindingConstraintsWithTag)(e,r))}whenNoAncestor(e){return this.when((0,JW.isNoAncestorBindingConstraints)(e))}whenNoAncestorIs(e){return this.when((0,QW.isNoAncestorBindingConstraintsWithServiceId)(e))}whenNoAncestorNamed(e){return this.when((0,XW.isNoAncestorBindingConstraintsWithName)(e))}whenNoAncestorTagged(e,r){return this.when((0,YW.isNoAncestorBindingConstraintsWithTag)(e,r))}};fe.BindWhenFluentSyntaxImplementation=yr;var Ve=class extends yr{#e;constructor(e){super(e),this.#e=new rn(e)}onActivation(e){return this.#e.onActivation(e)}onDeactivation(e){return this.#e.onDeactivation(e)}};fe.BindWhenOnFluentSyntaxImplementation=Ve;var mr=class extends Ve{#e;constructor(e){super(e),this.#e=new vo(e)}inRequestScope(){return this.#e.inRequestScope()}inSingletonScope(){return this.#e.inSingletonScope()}inTransientScope(){return this.#e.inTransientScope()}};fe.BindInWhenOnFluentSyntaxImplementation=mr});var hO=a(Np=>{"use strict";Object.defineProperty(Np,"__esModule",{value:!0});Np.getFirstIteratorResult=c8;function c8(t){if(t===void 0)return;let e=t.next();if(e.done!==!0)return e.value}});var mO=a(Up=>{"use strict";Object.defineProperty(Up,"__esModule",{value:!0});Up.getFirstIterableResult=d8;var u8=hO();function d8(t){return(0,u8.getFirstIteratorResult)(t?.[Symbol.iterator]())}});var Fp=a(go=>{"use strict";Object.defineProperty(go,"__esModule",{value:!0});go.InversifyContainerError=void 0;var Bp=Symbol.for("@inversifyjs/container/InversifyContainerError"),Lp=class t extends Error{[Bp];kind;constructor(e,r,i){super(r,i),this[Bp]=!0,this.kind=e}static is(e){return typeof e=="object"&&e!==null&&e[Bp]===!0}static isErrorOfKind(e,r){return t.is(e)&&e.kind===r}};go.InversifyContainerError=Lp});var kp=a(ho=>{"use strict";Object.defineProperty(ho,"__esModule",{value:!0});ho.InversifyContainerErrorKind=void 0;var yO;(function(t){t[t.invalidOperation=0]="invalidOperation"})(yO||(ho.InversifyContainerErrorKind=yO={}))});var SO=a(mo=>{"use strict";Object.defineProperty(mo,"__esModule",{value:!0});mo.Container=void 0;var br=j(),te=Qr(),bO=YD(),_O=gO(),l8=mO(),_r=Fp(),Sr=kp(),p8=te.bindingScopeValues.Transient,Vp=class{#e;#t;#i;#r;#s;#a;#o;#n;#c;#u;#f;constructor(e){this.#i=this.#O(),this.#s=r=>this.#e.get(r),this.#n=new te.PlanResultCacheService,this.#c=this.#v(),e?.parent===void 0?(this.#e=te.ActivationsService.build(void 0),this.#t=te.BindingService.build(void 0),this.#r=te.DeactivationsService.build(void 0)):(this.#e=te.ActivationsService.build(e.parent.#e),this.#t=te.BindingService.build(e.parent.#t),this.#r=te.DeactivationsService.build(e.parent.#r),e.parent.#n.subscribe(this.#n)),this.#a=this.#t.get.bind(this.#t),this.#u=this.#p.bind(this),this.#o={autobind:e?.autobind??!1,defaultScope:e?.defaultScope??p8},this.#f=[]}bind(e){return new _O.BindToFluentSyntaxImplementation(r=>{this.#p(r)},void 0,this.#o.defaultScope,e)}get(e,r){let i=this.#d(!1,e,r),n=this.#l(i);if((0,br.isPromise)(n))throw new _r.InversifyContainerError(Sr.InversifyContainerErrorKind.invalidOperation,`Unexpected asyncronous service when resolving service "${(0,br.stringifyServiceIdentifier)(e)}"`);return n}getAll(e,r){let i=this.#d(!0,e,r),n=this.#l(i);if((0,br.isPromise)(n))throw new _r.InversifyContainerError(Sr.InversifyContainerErrorKind.invalidOperation,`Unexpected asyncronous service when resolving service "${(0,br.stringifyServiceIdentifier)(e)}"`);return n}async getAllAsync(e,r){let i=this.#d(!0,e,r);return this.#l(i)}async getAsync(e,r){let i=this.#d(!1,e,r);return this.#l(i)}isBound(e,r){let i=this.#t.get(e);return this.#g(e,i,r)}isCurrentBound(e,r){let i=this.#t.getNonParentBindings(e);return this.#g(e,i,r)}async load(...e){await Promise.all(this.#h(...e))}loadSync(...e){let r=this.#h(...e);for(let i of r)if(i!==void 0)throw new _r.InversifyContainerError(Sr.InversifyContainerErrorKind.invalidOperation,"Unexpected asyncronous module load. Consider using Container.load() instead.")}onActivation(e,r){this.#e.add(r,{serviceId:e})}onDeactivation(e,r){this.#r.add(r,{serviceId:e})}restore(){let e=this.#f.pop();if(e===void 0)throw new _r.InversifyContainerError(Sr.InversifyContainerErrorKind.invalidOperation,"No snapshot available to restore");this.#e=e.activationService,this.#t=e.bindingService,this.#r=e.deactivationService,this.#w()}async rebind(e){return await this.unbind(e),this.bind(e)}rebindSync(e){return this.unbindSync(e),this.bind(e)}snapshot(){this.#f.push({activationService:this.#e.clone(),bindingService:this.#t.clone(),deactivationService:this.#r.clone()})}async unbind(e){await this.#y(e)}async unbindAll(){let e=[...this.#t.getNonParentBoundServices()];await Promise.all(e.map(async r=>(0,te.resolveServiceDeactivations)(this.#i,r)));for(let r of e)this.#e.removeAllByServiceId(r),this.#t.removeAllByServiceId(r),this.#r.removeAllByServiceId(r);this.#n.clearCache()}unbindSync(e){this.#y(e)!==void 0&&this.#I(e)}async unload(...e){await Promise.all(this.#m(...e)),this.#_(e)}unloadSync(...e){let r=this.#m(...e);for(let i of r)if(i!==void 0)throw new _r.InversifyContainerError(Sr.InversifyContainerErrorKind.invalidOperation,"Unexpected asyncronous module unload. Consider using Container.unload() instead.");this.#_(e)}#D(e){return{bind:r=>new _O.BindToFluentSyntaxImplementation(i=>{this.#p(i)},e,this.#o.defaultScope,r),isBound:this.isBound.bind(this),onActivation:(r,i)=>{this.#e.add(i,{moduleId:e,serviceId:r})},onDeactivation:(r,i)=>{this.#r.add(i,{moduleId:e,serviceId:r})},rebind:this.rebind.bind(this),rebindSync:this.rebindSync.bind(this),unbind:this.unbind.bind(this),unbindSync:this.unbindSync.bind(this)}}#O(){return{getBindings:e=>this.#t.get(e),getBindingsFromModule:e=>this.#t.getByModuleId(e),getClassMetadata:te.getClassMetadata,getDeactivations:e=>this.#r.get(e)}}#E(e,r,i){return{isMultiple:e,name:i?.name,optional:i?.optional,serviceIdentifier:r,tag:i?.tag}}#C(e,r,i){let n={autobindOptions:i?.autobind??this.#o.autobind?{scope:this.#o.defaultScope}:void 0,getBindings:this.#a,getClassMetadata:te.getClassMetadata,rootConstraints:{isMultiple:r,serviceIdentifier:e},servicesBranch:[],setBinding:this.#u};return this.#A(n,i),n}#d(e,r,i){let n=this.#E(e,r,i),o=this.#n.get(n);if(o!==void 0)return o;let s=(0,te.plan)(this.#C(r,e,i));return this.#n.set(n,s),s}#v(){return{get:this.get.bind(this),getAll:this.getAll.bind(this),getAllAsync:this.getAllAsync.bind(this),getAsync:this.getAsync.bind(this)}}#l(e){return(0,te.resolve)({context:this.#c,getActivations:this.#s,planResult:e,requestScopeCache:new Map})}#A(e,r){r!==void 0&&(r.name!==void 0&&(e.rootConstraints.name=r.name),r.optional===!0&&(e.rootConstraints.isOptional=!0),r.tag!==void 0&&(e.rootConstraints.tag={key:r.tag.key,value:r.tag.value}))}#g(e,r,i){if(r===void 0)return!1;let n={getAncestor:()=>{},name:i?.name,serviceIdentifier:e,tags:new Map};i?.tag!==void 0&&n.tags.set(i.tag.key,i.tag.value);for(let o of r)if(o.isSatisfiedBy(n))return!0;return!1}#h(...e){return e.map(r=>r.load(this.#D(r.id)))}#m(...e){return e.map(r=>(0,te.resolveModuleDeactivations)(this.#i,r.id))}#w(){this.#n.clearCache(),this.#s=e=>this.#e.get(e),this.#a=this.#t.get.bind(this.#t),this.#c=this.#v(),this.#u=this.#p.bind(this)}#p(e){this.#t.set(e),this.#n.clearCache()}#I(e){let r;if((0,bO.isBindingIdentifier)(e)){let i=this.#t.getById(e.id),n=(0,l8.getFirstIterableResult)(i)?.serviceIdentifier;n===void 0?r="Unexpected asyncronous deactivation when unbinding binding identifier. Consider using Container.unbind() instead.":r=`Unexpected asyncronous deactivation when unbinding "${(0,br.stringifyServiceIdentifier)(n)}" binding. Consider using Container.unbind() instead.`}else r=`Unexpected asyncronous deactivation when unbinding "${(0,br.stringifyServiceIdentifier)(e)}" service. Consider using Container.unbind() instead.`;throw new _r.InversifyContainerError(Sr.InversifyContainerErrorKind.invalidOperation,r)}#y(e){return(0,bO.isBindingIdentifier)(e)?this.#P(e):this.#x(e)}#P(e){let r=this.#t.getById(e.id),i=(0,te.resolveBindingsDeactivations)(this.#i,r);if(i===void 0)this.#b(e);else return i.then(()=>{this.#b(e)})}#b(e){this.#t.removeById(e.id),this.#n.clearCache()}#_(e){for(let r of e)this.#e.removeAllByModuleId(r.id),this.#t.removeAllByModuleId(r.id),this.#r.removeAllByModuleId(r.id);this.#n.clearCache()}#x(e){let r=(0,te.resolveServiceDeactivations)(this.#i,e);if(r===void 0)this.#S(e);else return r.then(()=>{this.#S(e)})}#S(e){this.#e.removeAllByServiceId(e),this.#t.removeAllByServiceId(e),this.#r.removeAllByServiceId(e),this.#n.clearCache()}};mo.Container=Vp});var DO=a(Ge=>{"use strict";Object.defineProperty(Ge,"__esModule",{value:!0});Ge.InversifyContainerErrorKind=Ge.InversifyContainerError=Ge.ContainerModule=Ge.Container=void 0;Fs();var f8=MS();Object.defineProperty(Ge,"ContainerModule",{enumerable:!0,get:function(){return f8.ContainerModule}});var v8=SO();Object.defineProperty(Ge,"Container",{enumerable:!0,get:function(){return v8.Container}});var g8=Fp();Object.defineProperty(Ge,"InversifyContainerError",{enumerable:!0,get:function(){return g8.InversifyContainerError}});var h8=kp();Object.defineProperty(Ge,"InversifyContainerErrorKind",{enumerable:!0,get:function(){return h8.InversifyContainerErrorKind}})});var h=a(_=>{"use strict";Object.defineProperty(_,"__esModule",{value:!0});_.preDestroy=_.postConstruct=_.tagged=_.unmanaged=_.optional=_.named=_.multiInject=_.injectable=_.injectFromBase=_.inject=_.decorate=_.bindingTypeValues=_.bindingScopeValues=_.ContainerModule=_.Container=_.LazyServiceIdentifier=void 0;Fs();var m8=j();Object.defineProperty(_,"LazyServiceIdentifier",{enumerable:!0,get:function(){return m8.LazyServiceIdentifier}});var OO=DO();Object.defineProperty(_,"Container",{enumerable:!0,get:function(){return OO.Container}});Object.defineProperty(_,"ContainerModule",{enumerable:!0,get:function(){return OO.ContainerModule}});var _e=Qr();Object.defineProperty(_,"bindingScopeValues",{enumerable:!0,get:function(){return _e.bindingScopeValues}});Object.defineProperty(_,"bindingTypeValues",{enumerable:!0,get:function(){return _e.bindingTypeValues}});Object.defineProperty(_,"decorate",{enumerable:!0,get:function(){return _e.decorate}});Object.defineProperty(_,"inject",{enumerable:!0,get:function(){return _e.inject}});Object.defineProperty(_,"injectFromBase",{enumerable:!0,get:function(){return _e.injectFromBase}});Object.defineProperty(_,"injectable",{enumerable:!0,get:function(){return _e.injectable}});Object.defineProperty(_,"multiInject",{enumerable:!0,get:function(){return _e.multiInject}});Object.defineProperty(_,"named",{enumerable:!0,get:function(){return _e.named}});Object.defineProperty(_,"optional",{enumerable:!0,get:function(){return _e.optional}});Object.defineProperty(_,"unmanaged",{enumerable:!0,get:function(){return _e.unmanaged}});Object.defineProperty(_,"tagged",{enumerable:!0,get:function(){return _e.tagged}});Object.defineProperty(_,"postConstruct",{enumerable:!0,get:function(){return _e.postConstruct}});Object.defineProperty(_,"preDestroy",{enumerable:!0,get:function(){return _e.preDestroy}})});var Wp=a((Zpe,CO)=>{"use strict";var Hp=Object.defineProperty,y8=Object.getOwnPropertyDescriptor,b8=Object.getOwnPropertyNames,_8=Object.prototype.hasOwnProperty,S8=(t,e)=>{for(var r in e)Hp(t,r,{get:e[r],enumerable:!0})},D8=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of b8(e))!_8.call(t,n)&&n!==r&&Hp(t,n,{get:()=>e[n],enumerable:!(i=y8(e,n))||i.enumerable});return t},O8=t=>D8(Hp({},"__esModule",{value:!0}),t),EO={};S8(EO,{BleDeviceInfos:()=>Gp});CO.exports=O8(EO);var Gp=class{constructor(e,r,i,n,o){this.deviceModel=e,this.serviceUuid=r,this.writeUuid=i,this.writeCmdUuid=n,this.notifyUuid=o}}});var zp=a((efe,wO)=>{"use strict";var $p=Object.defineProperty,E8=Object.getOwnPropertyDescriptor,C8=Object.getOwnPropertyNames,A8=Object.prototype.hasOwnProperty,w8=(t,e)=>{for(var r in e)$p(t,r,{get:e[r],enumerable:!0})},I8=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of C8(e))!A8.call(t,n)&&n!==r&&$p(t,n,{get:()=>e[n],enumerable:!(i=E8(e,n))||i.enumerable});return t},P8=t=>I8($p({},"__esModule",{value:!0}),t),AO={};w8(AO,{TransportDeviceModel:()=>Kp});wO.exports=P8(AO);var Kp=class{id;productName;usbProductId;bootloaderUsbProductId;usbOnly;memorySize;getBlockSize;masks;bluetoothSpec;constructor(e){this.id=e.id,this.productName=e.productName,this.usbProductId=e.usbProductId,this.bootloaderUsbProductId=e.bootloaderUsbProductId,this.usbOnly=e.usbOnly,this.memorySize=e.memorySize,this.getBlockSize=e.getBlockSize,this.masks=e.masks,this.bluetoothSpec=e.bluetoothSpec}}});var Jp=a((tfe,TO)=>{"use strict";var x8=Object.create,Or=Object.defineProperty,PO=Object.getOwnPropertyDescriptor,M8=Object.getOwnPropertyNames,T8=Object.getPrototypeOf,j8=Object.prototype.hasOwnProperty,q8=(t,e,r)=>e in t?Or(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,R8=(t,e)=>{for(var r in e)Or(t,r,{get:e[r],enumerable:!0})},xO=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of M8(e))!j8.call(t,n)&&n!==r&&Or(t,n,{get:()=>e[n],enumerable:!(i=PO(e,n))||i.enumerable});return t},N8=(t,e,r)=>(r=t!=null?x8(T8(t)):{},xO(e||!t||!t.__esModule?Or(r,"default",{value:t,enumerable:!0}):r,t)),U8=t=>xO(Or({},"__esModule",{value:!0}),t),B8=(t,e,r,i)=>{for(var n=i>1?void 0:i?PO(e,r):e,o=t.length-1,s;o>=0;o--)(s=t[o])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&Or(e,r,n),n},L8=(t,e,r)=>q8(t,typeof e!="symbol"?e+"":e,r),MO={};R8(MO,{StaticDeviceModelDataSource:()=>Ct});TO.exports=U8(MO);var F8=h(),IO=N8(Bn()),Pe=Ye(),k8=Wp(),Dr=zp(),Ct=class{getAllDeviceModels(){return Object.values(Ct.deviceModelByIds)}getDeviceModel(t){return Ct.deviceModelByIds[t.id]}filterDeviceModels(t){return this.getAllDeviceModels().filter(e=>Object.entries(t).every(([r,i])=>e[r]===i))}getBluetoothServicesInfos(){return Object.values(Ct.deviceModelByIds).reduce((t,e)=>{let{bluetoothSpec:r}=e;return r?{...t,...r.reduce((i,n)=>({...i,[n.serviceUuid]:new k8.BleDeviceInfos(e,n.serviceUuid,n.writeUuid,n.writeCmdUuid,n.notifyUuid)}),{})}:t},{})}getBluetoothServices(){return Object.values(Ct.deviceModelByIds).map(t=>(t.bluetoothSpec||[]).map(e=>e.serviceUuid)).flat().filter(t=>!!t)}};L8(Ct,"deviceModelByIds",{[Pe.DeviceModelId.NANO_S]:new Dr.TransportDeviceModel({id:Pe.DeviceModelId.NANO_S,productName:"Ledger Nano S",usbProductId:16,bootloaderUsbProductId:1,usbOnly:!0,memorySize:320*1024,getBlockSize:t=>IO.default.lt(IO.default.coerce(t.firmwareVersion)??"","2.0.0")?4*1024:2*1024,masks:[823132160]}),[Pe.DeviceModelId.NANO_SP]:new Dr.TransportDeviceModel({id:Pe.DeviceModelId.NANO_SP,productName:"Ledger Nano S Plus",usbProductId:80,bootloaderUsbProductId:5,usbOnly:!0,memorySize:1533*1024,getBlockSize:()=>32,masks:[856686592]}),[Pe.DeviceModelId.NANO_X]:new Dr.TransportDeviceModel({id:Pe.DeviceModelId.NANO_X,productName:"Ledger Nano X",usbProductId:64,bootloaderUsbProductId:4,usbOnly:!1,memorySize:2*1024*1024,getBlockSize:()=>4*1024,masks:[855638016],bluetoothSpec:[{serviceUuid:"13d63400-2c97-0004-0000-4c6564676572",notifyUuid:"13d63400-2c97-0004-0001-4c6564676572",writeUuid:"13d63400-2c97-0004-0002-4c6564676572",writeCmdUuid:"13d63400-2c97-0004-0003-4c6564676572"}]}),[Pe.DeviceModelId.STAX]:new Dr.TransportDeviceModel({id:Pe.DeviceModelId.STAX,productName:"Ledger Stax",usbProductId:96,bootloaderUsbProductId:6,usbOnly:!1,memorySize:1533*1024,getBlockSize:()=>32,masks:[857735168],bluetoothSpec:[{serviceUuid:"13d63400-2c97-6004-0000-4c6564676572",notifyUuid:"13d63400-2c97-6004-0001-4c6564676572",writeUuid:"13d63400-2c97-6004-0002-4c6564676572",writeCmdUuid:"13d63400-2c97-6004-0003-4c6564676572"}]}),[Pe.DeviceModelId.FLEX]:new Dr.TransportDeviceModel({id:Pe.DeviceModelId.FLEX,productName:"Ledger Flex",usbProductId:112,bootloaderUsbProductId:7,usbOnly:!1,memorySize:1533*1024,getBlockSize:()=>32,masks:[858783744],bluetoothSpec:[{serviceUuid:"13d63400-2c97-3004-0000-4c6564676572",notifyUuid:"13d63400-2c97-3004-0001-4c6564676572",writeUuid:"13d63400-2c97-3004-0002-4c6564676572",writeCmdUuid:"13d63400-2c97-3004-0003-4c6564676572"}]}),[Pe.DeviceModelId.APEX]:new Dr.TransportDeviceModel({id:Pe.DeviceModelId.APEX,productName:"Ledger\xA0Nano\xA0Gen5",usbProductId:128,bootloaderUsbProductId:8,usbOnly:!1,memorySize:1533*1024,getBlockSize:()=>32,masks:[859832320],bluetoothSpec:[{serviceUuid:"13d63400-2c97-8004-0000-4c6564676572",notifyUuid:"13d63400-2c97-8004-0001-4c6564676572",writeUuid:"13d63400-2c97-8004-0002-4c6564676572",writeCmdUuid:"13d63400-2c97-8004-0003-4c6564676572"},{serviceUuid:"13d63400-2c97-9004-0000-4c6564676572",notifyUuid:"13d63400-2c97-9004-0001-4c6564676572",writeUuid:"13d63400-2c97-9004-0002-4c6564676572",writeCmdUuid:"13d63400-2c97-9004-0003-4c6564676572"}]})}),Ct=B8([(0,F8.injectable)()],Ct)});var yo=a((nfe,qO)=>{"use strict";var Qp=Object.defineProperty,V8=Object.getOwnPropertyDescriptor,G8=Object.getOwnPropertyNames,H8=Object.prototype.hasOwnProperty,W8=(t,e)=>{for(var r in e)Qp(t,r,{get:e[r],enumerable:!0})},K8=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of G8(e))!H8.call(t,n)&&n!==r&&Qp(t,n,{get:()=>e[n],enumerable:!(i=V8(e,n))||i.enumerable});return t},$8=t=>K8(Qp({},"__esModule",{value:!0}),t),jO={};W8(jO,{ApduResponse:()=>Xp});qO.exports=$8(jO);var Xp=class{statusCode;data;constructor({statusCode:e,data:r}){this.statusCode=e,this.data=r}}});var bo=a((ife,NO)=>{"use strict";var Yp=Object.defineProperty,z8=Object.getOwnPropertyDescriptor,J8=Object.getOwnPropertyNames,X8=Object.prototype.hasOwnProperty,Q8=(t,e)=>{for(var r in e)Yp(t,r,{get:e[r],enumerable:!0})},Y8=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of J8(e))!X8.call(t,n)&&n!==r&&Yp(t,n,{get:()=>e[n],enumerable:!(i=z8(e,n))||i.enumerable});return t},Z8=t=>Y8(Yp({},"__esModule",{value:!0}),t),RO={};Q8(RO,{APDU_DATA_LENGTH_LENGTH:()=>iK,CHANNEL_LENGTH:()=>rK,HEAD_TAG:()=>eK,HEAD_TAG_LENGTH:()=>tK,INDEX_LENGTH:()=>nK});NO.exports=Z8(RO);var eK=5,tK=1,rK=2,nK=2,iK=2});var FO=a((ofe,LO)=>{"use strict";var tf=Object.defineProperty,oK=Object.getOwnPropertyDescriptor,sK=Object.getOwnPropertyNames,aK=Object.prototype.hasOwnProperty,cK=(t,e)=>{for(var r in e)tf(t,r,{get:e[r],enumerable:!0})},uK=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of sK(e))!aK.call(t,n)&&n!==r&&tf(t,n,{get:()=>e[n],enumerable:!(i=oK(e,n))||i.enumerable});return t},dK=t=>uK(tf({},"__esModule",{value:!0}),t),BO={};cK(BO,{GenuineCheckDeviceAction:()=>ef});LO.exports=dK(BO);var UO=b(),xe=(Y(),X(Q)),lK=w(),pK=qt(),Zp=Z(),fK=le(),vK=nt(),gK=ee(),hK=ne(),mK=Lt(),nn=yt(),yK=vu(),ef=class extends gK.XStateDeviceAction{makeStateMachine(e){let{getOsVersion:r,getDeviceVersion:i,getFirmwareVersion:n,genuineCheck:o,getDeviceSessionState:s,setDeviceSessionState:l}=this.extractDependencies(e),u=this.input.unlockTimeout??fK.DEFAULT_UNLOCK_TIMEOUT_MS,d=new vK.GoToDashboardDeviceAction({input:{unlockTimeout:u}}).makeStateMachine(e);return(0,xe.setup)({types:{input:{},context:{},output:{}},actors:{goToDashboard:d,getOsVersion:(0,xe.fromPromise)(r),getDeviceVersion:(0,xe.fromPromise)(i),getFirmwareVersion:(0,xe.fromPromise)(n),genuineCheck:(0,xe.fromObservable)(o)},guards:{hasError:c=>c.context._internalState.error!==null},actions:{assignErrorFromEvent:(0,xe.assign)({_internalState:c=>({...c.context._internalState,error:c.event.error})})}}).createMachine({id:"GenuineCheckDeviceAction",initial:"DeviceReady",context:c=>({input:{unlockTimeout:c.input.unlockTimeout},intermediateValue:{requiredUserInteraction:Zp.UserInteractionRequired.None},_internalState:{error:null,result:{isGenuine:!1},getOsVersionResponse:null,deviceVersion:null,firmwareVersion:null}}),states:{DeviceReady:{always:{target:"GoToDashboard"}},GoToDashboard:{invoke:{id:"goToDashboard",src:"goToDashboard",input:c=>({unlockTimeout:c.context.input.unlockTimeout}),onSnapshot:{actions:(0,xe.assign)({intermediateValue:c=>({...c.context.intermediateValue,requiredUserInteraction:c.event.snapshot.context.intermediateValue.requiredUserInteraction})})},onDone:{target:"GoToDashboardCheck",actions:(0,xe.assign)({_internalState:c=>c.event.output.caseOf({Right:()=>c.context._internalState,Left:p=>({...c.context._internalState,error:p})})})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GoToDashboardCheck:{always:[{target:"Error",guard:"hasError"},{target:"GetOsVersion"}]},GetOsVersion:{invoke:{id:"getOsVersion",src:"getOsVersion",input:c=>{},onDone:{target:"GetOsVersionCheck",actions:(0,xe.assign)({_internalState:c=>{if((0,lK.isSuccessCommandResult)(c.event.output)){let p=s(),v=c.event.output.data.secureElementFlags.isSecureConnectionAllowed;return p.sessionStateType!==hK.DeviceSessionStateType.Connected&&l({...p,isSecureConnectionAllowed:v}),{...c.context._internalState,getOsVersionResponse:c.event.output.data}}return{...c.context._internalState,error:c.event.output.error}}})}}},GetOsVersionCheck:{always:[{target:"Error",guard:"hasError"},{target:"GetDeviceVersion"}]},GetDeviceVersion:{invoke:{id:"getDeviceVersion",src:"getDeviceVersion",input:c=>({deviceInfo:c.context._internalState.getOsVersionResponse}),onDone:{target:"GetDeviceVersionCheck",actions:(0,xe.assign)({_internalState:c=>c.event.output.caseOf({Right:p=>({...c.context._internalState,deviceVersion:p}),Left:p=>({...c.context._internalState,error:p})})})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GetDeviceVersionCheck:{always:[{target:"Error",guard:"hasError"},{target:"GetFirmwareVersion"}]},GetFirmwareVersion:{invoke:{id:"getFirmwareVersion",src:"getFirmwareVersion",input:c=>({deviceInfo:c.context._internalState.getOsVersionResponse,deviceVersion:c.context._internalState.deviceVersion}),onDone:{target:"GetFirmwareVersionCheck",actions:(0,xe.assign)({_internalState:c=>c.event.output.caseOf({Right:p=>({...c.context._internalState,firmwareVersion:p}),Left:p=>({...c.context._internalState,error:p})})})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GetFirmwareVersionCheck:{always:[{target:"Error",guard:"hasError"},{target:"GenuineCheck"}]},GenuineCheck:{invoke:{id:"genuineCheck",src:"genuineCheck",input:c=>({deviceInfo:c.context._internalState.getOsVersionResponse,finalFirmware:c.context._internalState.firmwareVersion}),onSnapshot:{actions:(0,xe.assign)({intermediateValue:c=>{switch(c.event.snapshot.context?.type){case nn.SecureChannelEventType.DeviceId:return{...c.context.intermediateValue,deviceId:c.event.snapshot.context.payload.deviceId};case nn.SecureChannelEventType.PermissionRequested:return{...c.context.intermediateValue,requiredUserInteraction:Zp.UserInteractionRequired.AllowSecureConnection};case nn.SecureChannelEventType.PermissionGranted:return{...c.context.intermediateValue,requiredUserInteraction:Zp.UserInteractionRequired.None};default:return{...c.context.intermediateValue}}},_internalState:c=>c.event.snapshot.context?.type===nn.SecureChannelEventType.Error?{...c.context._internalState,error:c.event.snapshot.context.error.mapDAErrors()}:c.event.snapshot.context?.type===nn.SecureChannelEventType.Result?{...c.context._internalState,result:{isGenuine:(0,yK.isDeviceGenuine)(c.event.snapshot.context.payload)}}:c.context._internalState})},onDone:{target:"GenuineCheckCheck"},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GenuineCheckCheck:{always:[{target:"Error",guard:"hasError"},{target:"Success"}]},Success:{type:"final"},Error:{type:"final"}},output:c=>c.context._internalState.error?(0,UO.Left)(c.context._internalState.error):(0,UO.Right)(c.context._internalState.result)})}extractDependencies(e){return{getOsVersion:()=>e.sendCommand(new pK.GetOsVersionCommand),getDeviceVersion:({input:r})=>{let{deviceInfo:i}=r;return e.getManagerApiService().getDeviceVersion(i)},getFirmwareVersion:({input:r})=>{let{deviceInfo:i,deviceVersion:n}=r;return e.getManagerApiService().getFirmwareVersion(i,n)},genuineCheck:({input:r})=>{let{deviceInfo:i,finalFirmware:n}=r,o=e.getSecureChannelService().genuineCheck(i,n);return new mK.ConnectToSecureChannelTask(e,{connection:o}).run()},getDeviceSessionState:()=>e.getDeviceSessionState(),setDeviceSessionState:r=>e.setDeviceSessionState(r)}}}});var _o=a((sfe,GO)=>{"use strict";var of=Object.defineProperty,bK=Object.getOwnPropertyDescriptor,_K=Object.getOwnPropertyNames,SK=Object.prototype.hasOwnProperty,DK=(t,e)=>{for(var r in e)of(t,r,{get:e[r],enumerable:!0})},OK=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of _K(e))!SK.call(t,n)&&n!==r&&of(t,n,{get:()=>e[n],enumerable:!(i=bK(e,n))||i.enumerable});return t},EK=t=>OK(of({},"__esModule",{value:!0}),t),VO={};DK(VO,{ListInstalledAppsDeviceAction:()=>nf});GO.exports=EK(VO);var kO=b(),Me=(Y(),X(Q)),CK=w(),AK=qt(),rf=Z(),wK=le(),IK=nt(),PK=ee(),xK=ne(),MK=Lt(),on=yt(),TK=du(),nf=class extends PK.XStateDeviceAction{makeStateMachine(e){let{getOsVersion:r,getDeviceVersion:i,getFirmwareVersion:n,listInstalledApps:o,getDeviceSessionState:s,setDeviceSessionState:l}=this.extractDependencies(e),u=this.input.unlockTimeout??wK.DEFAULT_UNLOCK_TIMEOUT_MS,d=new IK.GoToDashboardDeviceAction({input:{unlockTimeout:u}}).makeStateMachine(e);return(0,Me.setup)({types:{input:{},context:{},output:{}},actors:{goToDashboard:d,getOsVersion:(0,Me.fromPromise)(r),getDeviceVersion:(0,Me.fromPromise)(i),getFirmwareVersion:(0,Me.fromPromise)(n),listInstalledApps:(0,Me.fromObservable)(o)},guards:{hasError:c=>c.context._internalState.error!==null},actions:{assignErrorFromEvent:(0,Me.assign)({_internalState:c=>({...c.context._internalState,error:c.event.error})})}}).createMachine({id:"ListInstalledAppsDeviceAction",initial:"DeviceReady",context:c=>({input:{unlockTimeout:c.input.unlockTimeout},intermediateValue:{requiredUserInteraction:rf.UserInteractionRequired.None},_internalState:{error:null,getOsVersionResponse:null,deviceVersion:null,firmwareVersion:null,result:{installedApps:[]}}}),states:{DeviceReady:{always:{target:"GoToDashboard"}},GoToDashboard:{invoke:{id:"goToDashboard",src:"goToDashboard",input:c=>({unlockTimeout:c.context.input.unlockTimeout}),onSnapshot:{actions:(0,Me.assign)({intermediateValue:c=>({...c.context.intermediateValue,requiredUserInteraction:c.event.snapshot.context.intermediateValue.requiredUserInteraction})})},onDone:{target:"GoToDashboardCheck",actions:(0,Me.assign)({_internalState:c=>c.event.output.caseOf({Right:()=>c.context._internalState,Left:p=>({...c.context._internalState,error:p})})})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GoToDashboardCheck:{always:[{target:"Error",guard:"hasError"},{target:"GetOsVersion"}]},GetOsVersion:{invoke:{id:"getOsVersion",src:"getOsVersion",input:c=>{},onDone:{target:"GetOsVersionCheck",actions:(0,Me.assign)({_internalState:c=>{if((0,CK.isSuccessCommandResult)(c.event.output)){let p=s(),v=c.event.output.data.secureElementFlags.isSecureConnectionAllowed;return p.sessionStateType!==xK.DeviceSessionStateType.Connected&&l({...p,isSecureConnectionAllowed:v}),{...c.context._internalState,getOsVersionResponse:c.event.output.data}}return{...c.context._internalState,error:c.event.output.error}}})}}},GetOsVersionCheck:{always:[{target:"Error",guard:"hasError"},{target:"GetDeviceVersion"}]},GetDeviceVersion:{invoke:{id:"getDeviceVersion",src:"getDeviceVersion",input:c=>({deviceInfo:c.context._internalState.getOsVersionResponse}),onDone:{target:"GetDeviceVersionCheck",actions:(0,Me.assign)({_internalState:c=>c.event.output.caseOf({Right:p=>({...c.context._internalState,deviceVersion:p}),Left:p=>({...c.context._internalState,error:p})})})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GetDeviceVersionCheck:{always:[{target:"Error",guard:"hasError"},{target:"GetFirmwareVersion"}]},GetFirmwareVersion:{invoke:{id:"getFirmwareVersion",src:"getFirmwareVersion",input:c=>({deviceInfo:c.context._internalState.getOsVersionResponse,deviceVersion:c.context._internalState.deviceVersion}),onDone:{target:"GetFirmwareVersionCheck",actions:(0,Me.assign)({_internalState:c=>c.event.output.caseOf({Right:p=>({...c.context._internalState,firmwareVersion:p}),Left:p=>({...c.context._internalState,error:p})})})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GetFirmwareVersionCheck:{always:[{target:"Error",guard:"hasError"},{target:"ListInstalledApps"}]},ListInstalledApps:{invoke:{id:"listInstalledApps",src:"listInstalledApps",input:c=>({deviceInfo:c.context._internalState.getOsVersionResponse,finalFirmware:c.context._internalState.firmwareVersion}),onSnapshot:{actions:(0,Me.assign)({intermediateValue:c=>{switch(c.event.snapshot.context?.type){case on.SecureChannelEventType.DeviceId:return{...c.context.intermediateValue,deviceId:c.event.snapshot.context.payload.deviceId};case on.SecureChannelEventType.PermissionRequested:return{...c.context.intermediateValue,requiredUserInteraction:rf.UserInteractionRequired.AllowSecureConnection};case on.SecureChannelEventType.PermissionGranted:return{...c.context.intermediateValue,requiredUserInteraction:rf.UserInteractionRequired.None};default:return{...c.context.intermediateValue}}},_internalState:c=>{if(c.event.snapshot.context?.type===on.SecureChannelEventType.Error)return{...c.context._internalState,error:c.event.snapshot.context.error.mapDAErrors()};if(c.event.snapshot.context?.type===on.SecureChannelEventType.Result){if((0,TK.installedAppResultGuard)(c.event.snapshot.context.payload))return{...c.context._internalState,result:{installedApps:c.event.snapshot.context.payload}};throw new Error(`Invalid result ${JSON.stringify(c.event.snapshot.context.payload)}`)}return{...c.context._internalState}}})},onDone:{target:"Success"},onError:{target:"Error",actions:"assignErrorFromEvent"}}},ListInstalledAppsCheck:{always:[{target:"Error",guard:"hasError"},{target:"Success"}]},Success:{type:"final"},Error:{type:"final"}},output:c=>c.context._internalState.error?(0,kO.Left)(c.context._internalState.error):(0,kO.Right)(c.context._internalState.result)})}extractDependencies(e){return{getOsVersion:()=>e.sendCommand(new AK.GetOsVersionCommand),getDeviceVersion:({input:r})=>{let{deviceInfo:i}=r;return e.getManagerApiService().getDeviceVersion(i)},getFirmwareVersion:({input:r})=>{let{deviceInfo:i,deviceVersion:n}=r;return e.getManagerApiService().getFirmwareVersion(i,n)},listInstalledApps:({input:r})=>{let{deviceInfo:i,finalFirmware:n}=r,o=e.getSecureChannelService().listInstalledApps(i,n);return new MK.ConnectToSecureChannelTask(e,{connection:o}).run()},getDeviceSessionState:()=>e.getDeviceSessionState(),setDeviceSessionState:r=>e.setDeviceSessionState(r)}}}});var JO=a((afe,zO)=>{"use strict";var cf=Object.defineProperty,jK=Object.getOwnPropertyDescriptor,qK=Object.getOwnPropertyNames,RK=Object.prototype.hasOwnProperty,NK=(t,e)=>{for(var r in e)cf(t,r,{get:e[r],enumerable:!0})},UK=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of qK(e))!RK.call(t,n)&&n!==r&&cf(t,n,{get:()=>e[n],enumerable:!(i=jK(e,n))||i.enumerable});return t},BK=t=>UK(cf({},"__esModule",{value:!0}),t),$O={};NK($O,{InstallAppDeviceAction:()=>af});zO.exports=BK($O);var HO=b(),ve=(Y(),X(Q)),LK=w(),FK=qt(),kK=Z(),VK=le(),WO=de(),GK=nt(),HK=ee(),KO=ne(),WK=_o(),KK=Lt(),sf=yt(),af=class extends HK.XStateDeviceAction{makeStateMachine(e){let{getOsVersion:r,getAppList:i,installApp:n,getDeviceSessionState:o,setDeviceSessionState:s}=this.extractDependencies(e),l=this.input.unlockTimeout??VK.DEFAULT_UNLOCK_TIMEOUT_MS,u=new WK.ListInstalledAppsDeviceAction({input:{unlockTimeout:l}}).makeStateMachine(e),d=new GK.GoToDashboardDeviceAction({input:{unlockTimeout:l}}).makeStateMachine(e);return(0,ve.setup)({types:{input:{},context:{},output:{}},actors:{listInstalledApps:u,goToDashboard:d,getOsVersion:(0,ve.fromPromise)(r),getAppList:(0,ve.fromPromise)(i),installApp:(0,ve.fromObservable)(n)},guards:{hasError:c=>c.context._internalState.error!==null,appInstalled:c=>c.context._internalState.installedApps.some(p=>p.name===c.context.input.appName),appNotFound:c=>c.context._internalState.appList.findIndex(({versionName:p})=>p===c.context.input.appName)===-1,depAppNotInstalled:c=>{let p=c.context._internalState.appList.find(({versionName:v})=>v===c.context.input.appName);return p?.parentName?c.context._internalState.installedApps.findIndex(({name:v})=>v===p.parentName)===-1:!1}},actions:{assignErrorFromEvent:(0,ve.assign)({_internalState:c=>({...c.context._internalState,error:c.event.error})}),assignAppNotFound:(0,ve.assign)({_internalState:c=>({...c.context._internalState,error:new WO.UnknownDAError("App to install not found in manager API")})}),assignDepAppNotInstalled:(0,ve.assign)({_internalState:c=>({...c.context._internalState,error:new WO.UnknownDAError("Dep app is not installed on the device")})}),cleanupDeviceState:()=>{let c=o();c.sessionStateType!==KO.DeviceSessionStateType.Connected&&s({...c,installedApps:[],appsUpdates:void 0})}}}).createMachine({id:"InstallAppDeviceAction",initial:"DeviceReady",context:c=>({input:{unlockTimeout:c.input.unlockTimeout,appName:c.input.appName},intermediateValue:{requiredUserInteraction:kK.UserInteractionRequired.None,progress:0},_internalState:{error:null,installedApps:[],getOsVersionResponse:null,appList:[]}}),states:{DeviceReady:{always:{target:"ListInstalledApps"}},ListInstalledApps:{value:"ListInstalledApps",invoke:{id:"listInstalledApps",src:"listInstalledApps",input:c=>({unlockTimeout:c.context.input.unlockTimeout}),onSnapshot:{actions:(0,ve.assign)({intermediateValue:c=>({...c.context.intermediateValue,requiredUserInteraction:c.event.snapshot.context.intermediateValue.requiredUserInteraction})})},onDone:{target:"ListInstalledAppsCheck",actions:(0,ve.assign)({_internalState:c=>c.event.output.caseOf({Right:({installedApps:p})=>({...c.context._internalState,installedApps:p}),Left:p=>({...c.context._internalState,error:p})})})}}},ListInstalledAppsCheck:{always:[{target:"Error",guard:"hasError"},{target:"Success",guard:"appInstalled"},{target:"GoToDashboard"}]},GoToDashboard:{invoke:{id:"goToDashboard",src:"goToDashboard",input:c=>({unlockTimeout:c.context.input.unlockTimeout}),onSnapshot:{actions:(0,ve.assign)({intermediateValue:c=>({...c.context.intermediateValue,requiredUserInteraction:c.event.snapshot.context.intermediateValue.requiredUserInteraction})})},onDone:{target:"GoToDashboardCheck",actions:(0,ve.assign)({_internalState:c=>c.event.output.caseOf({Right:()=>c.context._internalState,Left:p=>({...c.context._internalState,error:p})})})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GoToDashboardCheck:{always:[{target:"Error",guard:"hasError"},{target:"GetOsVersion"}]},GetOsVersion:{invoke:{id:"getOsVersion",src:"getOsVersion",input:c=>{},onDone:{target:"GetOsVersionCheck",actions:(0,ve.assign)({_internalState:c=>{if((0,LK.isSuccessCommandResult)(c.event.output)){let p=o(),v=c.event.output.data.secureElementFlags.isSecureConnectionAllowed;return p.sessionStateType!==KO.DeviceSessionStateType.Connected&&s({...p,isSecureConnectionAllowed:v}),{...c.context._internalState,getOsVersionResponse:c.event.output.data}}return{...c.context._internalState,error:c.event.output.error}}})}}},GetOsVersionCheck:{always:[{target:"Error",guard:"hasError"},{target:"GetAppList"}]},GetAppList:{invoke:{id:"getAppList",src:"getAppList",input:c=>({deviceInfo:c.context._internalState.getOsVersionResponse}),onDone:{target:"GetAppListCheck",actions:(0,ve.assign)({_internalState:c=>c.event.output.caseOf({Right:p=>({...c.context._internalState,appList:p}),Left:p=>({...c.context._internalState,error:p})})})}}},GetAppListCheck:{always:[{target:"Error",guard:"hasError"},{target:"Error",guard:"appNotFound",actions:"assignAppNotFound"},{target:"Error",guard:"depAppNotInstalled",actions:"assignDepAppNotInstalled"},{target:"InstallApp"}]},InstallApp:{invoke:{id:"installApp",src:"installApp",input:c=>({deviceInfo:c.context._internalState.getOsVersionResponse,app:c.context._internalState.appList.find(({versionName:p})=>p===c.context.input.appName)}),onSnapshot:{actions:(0,ve.assign)({intermediateValue:c=>c.event.snapshot.context?.type===sf.SecureChannelEventType.DeviceId?{...c.context.intermediateValue,deviceId:c.event.snapshot.context.payload.deviceId}:c.event.snapshot.context?.type===sf.SecureChannelEventType.Progress?{...c.context.intermediateValue,progress:c.event.snapshot.context.payload.progress}:{...c.context.intermediateValue},_internalState:c=>c.event.snapshot.context?.type===sf.SecureChannelEventType.Error?{...c.context._internalState,error:c.event.snapshot.context.error.mapInstallDAErrors()}:c.context._internalState})},onDone:{target:"ListInstalledApps",actions:"cleanupDeviceState"},onError:{target:"Error",actions:"assignErrorFromEvent"}}},Success:{type:"final",description:"App installed successfully"},Error:{type:"final"}},output:({context:c})=>c._internalState.error?(0,HO.Left)(c._internalState.error):(0,HO.Right)(void 0)})}extractDependencies(e){return{getOsVersion:()=>e.sendCommand(new FK.GetOsVersionCommand),getAppList:({input:r})=>{let{deviceInfo:i}=r;return e.getManagerApiService().getAppList(i)},installApp:({input:r})=>{let{deviceInfo:i,app:n}=r,o=e.getSecureChannelService().installApp(i,n);return new KK.ConnectToSecureChannelTask(e,{connection:o}).run()},getDeviceSessionState:()=>e.getDeviceSessionState(),setDeviceSessionState:r=>e.setDeviceSessionState(r)}}}});var tE=a((cfe,eE)=>{"use strict";var lf=Object.defineProperty,$K=Object.getOwnPropertyDescriptor,zK=Object.getOwnPropertyNames,JK=Object.prototype.hasOwnProperty,XK=(t,e)=>{for(var r in e)lf(t,r,{get:e[r],enumerable:!0})},QK=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of zK(e))!JK.call(t,n)&&n!==r&&lf(t,n,{get:()=>e[n],enumerable:!(i=$K(e,n))||i.enumerable});return t},YK=t=>QK(lf({},"__esModule",{value:!0}),t),ZO={};XK(ZO,{UninstallAppDeviceAction:()=>df});eE.exports=YK(ZO);var XO=b(),ge=(Y(),X(Q)),ZK=w(),e3=qt(),uf=Z(),t3=le(),QO=de(),r3=nt(),n3=ee(),YO=ne(),i3=_o(),o3=Lt(),So=yt(),df=class extends n3.XStateDeviceAction{makeStateMachine(e){let{getOsVersion:r,getAppsByHash:i,uninstallApp:n,getDeviceSessionState:o,setDeviceSessionState:s}=this.extractDependencies(e),l=this.input.unlockTimeout??t3.DEFAULT_UNLOCK_TIMEOUT_MS,u=new r3.GoToDashboardDeviceAction({input:{unlockTimeout:l}}).makeStateMachine(e),d=new i3.ListInstalledAppsDeviceAction({input:{unlockTimeout:l}}).makeStateMachine(e);return(0,ge.setup)({types:{input:{},context:{},output:{}},actors:{listInstalledApps:d,goToDashboard:u,getOsVersion:(0,ge.fromPromise)(r),getAppsByHash:(0,ge.fromPromise)(i),uninstallApp:(0,ge.fromObservable)(n)},guards:{hasError:c=>c.context._internalState.error!==null,appNotInstalled:c=>!c.context._internalState.installedApps.some(p=>p.name===c.context.input.appName),appNotFound:c=>c.context._internalState.appList.findIndex(p=>p?.versionName===c.context.input.appName)===-1,isDepAppOfOther:c=>c.context._internalState.appList.some(p=>p?.parentName===c.context.input.appName)},actions:{assignErrorFromEvent:(0,ge.assign)({_internalState:c=>({...c.context._internalState,error:c.event.error})}),assignAppNotFound:(0,ge.assign)({_internalState:c=>({...c.context._internalState,error:new QO.UnknownDAError("App to uninstall not found in manager API")})}),assignIsDepAppOfOther:(0,ge.assign)({_internalState:c=>({...c.context._internalState,error:new QO.UnknownDAError("App to uninstall is a dependency of another installed app")})}),cleanupDeviceState:()=>{let c=o();c.sessionStateType!==YO.DeviceSessionStateType.Connected&&s({...c,installedApps:[],appsUpdates:void 0})}}}).createMachine({id:"UninstallAppDeviceAction",initial:"DeviceReady",context:c=>({input:{unlockTimeout:c.input.unlockTimeout,appName:c.input.appName},intermediateValue:{requiredUserInteraction:uf.UserInteractionRequired.None},_internalState:{error:null,installedApps:[],appList:[],getOsVersionResponse:null}}),states:{DeviceReady:{always:{target:"ListInstalledApps"}},ListInstalledApps:{invoke:{id:"listInstalledApps",src:"listInstalledApps",input:c=>({unlockTimeout:c.context.input.unlockTimeout}),onSnapshot:{actions:(0,ge.assign)({intermediateValue:c=>({...c.context.intermediateValue,requiredUserInteraction:c.event.snapshot.context.intermediateValue.requiredUserInteraction})})},onDone:{target:"ListInstalledAppsCheck",actions:(0,ge.assign)({_internalState:c=>c.event.output.caseOf({Right:({installedApps:p})=>({...c.context._internalState,installedApps:p,hasCheckedInstalledApps:!0}),Left:p=>({...c.context._internalState,error:p})})})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},ListInstalledAppsCheck:{always:[{target:"Error",guard:"hasError"},{target:"Success",guard:"appNotInstalled"},{target:"GetAppsByHash"}]},GetAppsByHash:{invoke:{id:"getAppsByHash",src:"getAppsByHash",input:c=>c.context._internalState.installedApps,onDone:{target:"GetAppsByHashCheck",actions:(0,ge.assign)({_internalState:c=>c.event.output.caseOf({Right:p=>({...c.context._internalState,appList:p}),Left:p=>({...c.context._internalState,error:p})})})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GetAppsByHashCheck:{always:[{target:"Error",guard:"hasError"},{target:"Error",guard:"appNotFound",actions:"assignAppNotFound"},{target:"Error",guard:"isDepAppOfOther",actions:"assignIsDepAppOfOther"},{target:"GoToDashboard"}]},GoToDashboard:{invoke:{id:"goToDashboard",src:"goToDashboard",input:c=>({unlockTimeout:c.context.input.unlockTimeout}),onSnapshot:{actions:(0,ge.assign)({intermediateValue:c=>({...c.context.intermediateValue,requiredUserInteraction:c.event.snapshot.context.intermediateValue.requiredUserInteraction})})},onDone:{target:"GoToDashboardCheck",actions:(0,ge.assign)({_internalState:c=>c.event.output.caseOf({Right:()=>c.context._internalState,Left:p=>({...c.context._internalState,error:p})})})},onError:{target:"Error",actions:"assignErrorFromEvent"}}},GoToDashboardCheck:{always:[{target:"Error",guard:"hasError"},{target:"GetOsVersion"}]},GetOsVersion:{invoke:{id:"getOsVersion",src:"getOsVersion",input:c=>{},onDone:{target:"GetOsVersionCheck",actions:(0,ge.assign)({_internalState:c=>{if((0,ZK.isSuccessCommandResult)(c.event.output)){let p=o(),v=c.event.output.data.secureElementFlags.isSecureConnectionAllowed;return p.sessionStateType!==YO.DeviceSessionStateType.Connected&&s({...p,isSecureConnectionAllowed:v}),{...c.context._internalState,getOsVersionResponse:c.event.output.data}}return{...c.context._internalState,error:c.event.output.error}}})}}},GetOsVersionCheck:{always:[{target:"Error",guard:"hasError"},{target:"UninstallApp"}]},UninstallApp:{invoke:{id:"uninstallApp",src:"uninstallApp",input:c=>({deviceInfo:c.context._internalState.getOsVersionResponse,app:c.context._internalState.appList.find(p=>p?.versionName===c.context.input.appName)}),onSnapshot:{actions:(0,ge.assign)({intermediateValue:c=>{switch(c.event.snapshot.context?.type){case So.SecureChannelEventType.DeviceId:return{...c.context.intermediateValue,deviceId:c.event.snapshot.context.payload.deviceId};case So.SecureChannelEventType.PermissionRequested:return{...c.context.intermediateValue,requiredUserInteraction:uf.UserInteractionRequired.AllowSecureConnection};case So.SecureChannelEventType.PermissionGranted:return{...c.context.intermediateValue,requiredUserInteraction:uf.UserInteractionRequired.None};default:return{...c.context.intermediateValue}}},_internalState:c=>c.event.snapshot.context?.type===So.SecureChannelEventType.Error?{...c.context._internalState,error:c.event.snapshot.context.error.mapDAErrors()}:c.context._internalState})},onDone:{target:"ListInstalledApps",actions:"cleanupDeviceState"},onError:{target:"Error",actions:"assignErrorFromEvent"}}},Success:{type:"final",description:"App uninstalled successfully"},Error:{type:"final"}},output:({context:c})=>c._internalState.error?(0,XO.Left)(c._internalState.error):(0,XO.Right)(void 0)})}extractDependencies(e){return{getOsVersion:()=>e.sendCommand(new e3.GetOsVersionCommand),getAppsByHash:({input:r})=>{let i=r.map(n=>n.hash);return e.getManagerApiService().getAppsByHash(i)},uninstallApp:({input:r})=>{let{deviceInfo:i,app:n}=r,o=e.getSecureChannelService().uninstallApp(i,n);return new o3.ConnectToSecureChannelTask(e,{connection:o}).run()},getDeviceSessionState:()=>e.getDeviceSessionState(),setDeviceSessionState:r=>e.setDeviceSessionState(r)}}}});var rE=a(pf=>{"use strict";Object.defineProperty(pf,"__esModule",{value:!0});pf.default="ffffffff-ffff-ffff-ffff-ffffffffffff"});var nE=a(ff=>{"use strict";Object.defineProperty(ff,"__esModule",{value:!0});ff.default="00000000-0000-0000-0000-000000000000"});var iE=a(vf=>{"use strict";Object.defineProperty(vf,"__esModule",{value:!0});vf.default=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i});var sn=a(gf=>{"use strict";Object.defineProperty(gf,"__esModule",{value:!0});var s3=iE();function a3(t){return typeof t=="string"&&s3.default.test(t)}gf.default=a3});var an=a(hf=>{"use strict";Object.defineProperty(hf,"__esModule",{value:!0});var c3=sn();function u3(t){if(!(0,c3.default)(t))throw TypeError("Invalid UUID");let e;return Uint8Array.of((e=parseInt(t.slice(0,8),16))>>>24,e>>>16&255,e>>>8&255,e&255,(e=parseInt(t.slice(9,13),16))>>>8,e&255,(e=parseInt(t.slice(14,18),16))>>>8,e&255,(e=parseInt(t.slice(19,23),16))>>>8,e&255,(e=parseInt(t.slice(24,36),16))/1099511627776&255,e/4294967296&255,e>>>24&255,e>>>16&255,e>>>8&255,e&255)}hf.default=u3});var ot=a(Do=>{"use strict";Object.defineProperty(Do,"__esModule",{value:!0});Do.unsafeStringify=oE;var d3=sn(),W=[];for(let t=0;t<256;++t)W.push((t+256).toString(16).slice(1));function oE(t,e=0){return(W[t[e+0]]+W[t[e+1]]+W[t[e+2]]+W[t[e+3]]+"-"+W[t[e+4]]+W[t[e+5]]+"-"+W[t[e+6]]+W[t[e+7]]+"-"+W[t[e+8]]+W[t[e+9]]+"-"+W[t[e+10]]+W[t[e+11]]+W[t[e+12]]+W[t[e+13]]+W[t[e+14]]+W[t[e+15]]).toLowerCase()}function l3(t,e=0){let r=oE(t,e);if(!(0,d3.default)(r))throw TypeError("Stringified UUID is invalid");return r}Do.default=l3});var Co=a(mf=>{"use strict";Object.defineProperty(mf,"__esModule",{value:!0});mf.default=f3;var p3=E("crypto"),Eo=new Uint8Array(256),Oo=Eo.length;function f3(){return Oo>Eo.length-16&&((0,p3.randomFillSync)(Eo),Oo=0),Eo.slice(Oo,Oo+=16)}});var yf=a(Ao=>{"use strict";Object.defineProperty(Ao,"__esModule",{value:!0});Ao.updateV1State=cE;var sE=Co(),v3=ot(),cn={};function g3(t,e,r){let i,n=t?._v6??!1;if(t){let o=Object.keys(t);o.length===1&&o[0]==="_v6"&&(t=void 0)}if(t)i=aE(t.random??t.rng?.()??(0,sE.default)(),t.msecs,t.nsecs,t.clockseq,t.node,e,r);else{let o=Date.now(),s=(0,sE.default)();cE(cn,o,s),i=aE(s,cn.msecs,cn.nsecs,n?void 0:cn.clockseq,n?void 0:cn.node,e,r)}return e?i:(0,v3.unsafeStringify)(i)}function cE(t,e,r){return t.msecs??=-1/0,t.nsecs??=0,e===t.msecs?(t.nsecs++,t.nsecs>=1e4&&(t.node=void 0,t.nsecs=0)):e>t.msecs?t.nsecs=0:e<t.msecs&&(t.node=void 0),t.node||(t.node=r.slice(10,16),t.node[0]|=1,t.clockseq=(r[8]<<8|r[9])&16383),t.msecs=e,t}function aE(t,e,r,i,n,o,s=0){o||(o=new Uint8Array(16),s=0),e??=Date.now(),r??=0,i??=(t[8]<<8|t[9])&16383,n??=t.slice(10,16),e+=122192928e5;let l=((e&268435455)*1e4+r)%4294967296;o[s++]=l>>>24&255,o[s++]=l>>>16&255,o[s++]=l>>>8&255,o[s++]=l&255;let u=e/4294967296*1e4&268435455;o[s++]=u>>>8&255,o[s++]=u&255,o[s++]=u>>>24&15|16,o[s++]=u>>>16&255,o[s++]=i>>>8|128,o[s++]=i&255;for(let d=0;d<6;++d)o[s++]=n[d];return o}Ao.default=g3});var _f=a(bf=>{"use strict";Object.defineProperty(bf,"__esModule",{value:!0});bf.default=y3;var h3=an(),m3=ot();function y3(t){let e=typeof t=="string"?(0,h3.default)(t):t,r=b3(e);return typeof t=="string"?(0,m3.unsafeStringify)(r):r}function b3(t){return Uint8Array.of((t[6]&15)<<4|t[7]>>4&15,(t[7]&15)<<4|(t[4]&240)>>4,(t[4]&15)<<4|(t[5]&240)>>4,(t[5]&15)<<4|(t[0]&240)>>4,(t[0]&15)<<4|(t[1]&240)>>4,(t[1]&15)<<4|(t[2]&240)>>4,96|t[2]&15,t[3],t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15])}});var uE=a(Sf=>{"use strict";Object.defineProperty(Sf,"__esModule",{value:!0});var _3=E("crypto");function S3(t){return Array.isArray(t)?t=Buffer.from(t):typeof t=="string"&&(t=Buffer.from(t,"utf8")),(0,_3.createHash)("md5").update(t).digest()}Sf.default=S3});var un=a(At=>{"use strict";Object.defineProperty(At,"__esModule",{value:!0});At.URL=At.DNS=void 0;At.stringToBytes=lE;At.default=O3;var dE=an(),D3=ot();function lE(t){t=unescape(encodeURIComponent(t));let e=new Uint8Array(t.length);for(let r=0;r<t.length;++r)e[r]=t.charCodeAt(r);return e}At.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8";At.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function O3(t,e,r,i,n,o){let s=typeof r=="string"?lE(r):r,l=typeof i=="string"?(0,dE.default)(i):i;if(typeof i=="string"&&(i=(0,dE.default)(i)),i?.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let u=new Uint8Array(16+s.length);if(u.set(l),u.set(s,l.length),u=e(u),u[6]=u[6]&15|t,u[8]=u[8]&63|128,n){o=o||0;for(let d=0;d<16;++d)n[o+d]=u[d];return n}return(0,D3.unsafeStringify)(u)}});var fE=a(Wt=>{"use strict";Object.defineProperty(Wt,"__esModule",{value:!0});Wt.URL=Wt.DNS=void 0;var E3=uE(),Df=un(),pE=un();Object.defineProperty(Wt,"DNS",{enumerable:!0,get:function(){return pE.DNS}});Object.defineProperty(Wt,"URL",{enumerable:!0,get:function(){return pE.URL}});function Of(t,e,r,i){return(0,Df.default)(48,E3.default,t,e,r,i)}Of.DNS=Df.DNS;Of.URL=Df.URL;Wt.default=Of});var vE=a(Ef=>{"use strict";Object.defineProperty(Ef,"__esModule",{value:!0});var C3=E("crypto");Ef.default={randomUUID:C3.randomUUID}});var hE=a(Cf=>{"use strict";Object.defineProperty(Cf,"__esModule",{value:!0});var gE=vE(),A3=Co(),w3=ot();function I3(t,e,r){if(gE.default.randomUUID&&!e&&!t)return gE.default.randomUUID();t=t||{};let i=t.random||(t.rng||A3.default)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,e){r=r||0;for(let n=0;n<16;++n)e[r+n]=i[n];return e}return(0,w3.unsafeStringify)(i)}Cf.default=I3});var mE=a(Af=>{"use strict";Object.defineProperty(Af,"__esModule",{value:!0});var P3=E("crypto");function x3(t){return Array.isArray(t)?t=Buffer.from(t):typeof t=="string"&&(t=Buffer.from(t,"utf8")),(0,P3.createHash)("sha1").update(t).digest()}Af.default=x3});var bE=a(Kt=>{"use strict";Object.defineProperty(Kt,"__esModule",{value:!0});Kt.URL=Kt.DNS=void 0;var M3=mE(),wf=un(),yE=un();Object.defineProperty(Kt,"DNS",{enumerable:!0,get:function(){return yE.DNS}});Object.defineProperty(Kt,"URL",{enumerable:!0,get:function(){return yE.URL}});function If(t,e,r,i){return(0,wf.default)(80,M3.default,t,e,r,i)}If.DNS=wf.DNS;If.URL=wf.URL;Kt.default=If});var _E=a(Pf=>{"use strict";Object.defineProperty(Pf,"__esModule",{value:!0});var T3=ot(),j3=yf(),q3=_f();function R3(t,e,r){t??={},r??=0;let i=(0,j3.default)({...t,_v6:!0},new Uint8Array(16));if(i=(0,q3.default)(i),e){for(let n=0;n<16;n++)e[r+n]=i[n];return e}return(0,T3.unsafeStringify)(i)}Pf.default=R3});var SE=a(xf=>{"use strict";Object.defineProperty(xf,"__esModule",{value:!0});xf.default=B3;var N3=an(),U3=ot();function B3(t){let e=typeof t=="string"?(0,N3.default)(t):t,r=L3(e);return typeof t=="string"?(0,U3.unsafeStringify)(r):r}function L3(t){return Uint8Array.of((t[3]&15)<<4|t[4]>>4&15,(t[4]&15)<<4|(t[5]&240)>>4,(t[5]&15)<<4|t[6]&15,t[7],(t[1]&15)<<4|(t[2]&240)>>4,(t[2]&15)<<4|(t[3]&240)>>4,16|(t[0]&240)>>4,(t[0]&15)<<4|(t[1]&240)>>4,t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15])}});var CE=a(wo=>{"use strict";Object.defineProperty(wo,"__esModule",{value:!0});wo.updateV7State=EE;var DE=Co(),F3=ot(),Mf={};function k3(t,e,r){let i;if(t)i=OE(t.random??t.rng?.()??(0,DE.default)(),t.msecs,t.seq,e,r);else{let n=Date.now(),o=(0,DE.default)();EE(Mf,n,o),i=OE(o,Mf.msecs,Mf.seq,e,r)}return e?i:(0,F3.unsafeStringify)(i)}function EE(t,e,r){return t.msecs??=-1/0,t.seq??=0,e>t.msecs?(t.seq=r[6]<<23|r[7]<<16|r[8]<<8|r[9],t.msecs=e):(t.seq=t.seq+1|0,t.seq===0&&t.msecs++),t}function OE(t,e,r,i,n=0){return i||(i=new Uint8Array(16),n=0),e??=Date.now(),r??=t[6]*127<<24|t[7]<<16|t[8]<<8|t[9],i[n++]=e/1099511627776&255,i[n++]=e/4294967296&255,i[n++]=e/16777216&255,i[n++]=e/65536&255,i[n++]=e/256&255,i[n++]=e&255,i[n++]=112|r>>>28&15,i[n++]=r>>>20&255,i[n++]=128|r>>>14&63,i[n++]=r>>>6&255,i[n++]=r<<2&255|t[10]&3,i[n++]=t[11],i[n++]=t[12],i[n++]=t[13],i[n++]=t[14],i[n++]=t[15],i}wo.default=k3});var AE=a(Tf=>{"use strict";Object.defineProperty(Tf,"__esModule",{value:!0});var V3=sn();function G3(t){if(!(0,V3.default)(t))throw TypeError("Invalid UUID");return parseInt(t.slice(14,15),16)}Tf.default=G3});var dn=a(S=>{"use strict";Object.defineProperty(S,"__esModule",{value:!0});S.version=S.validate=S.v7=S.v6ToV1=S.v6=S.v5=S.v4=S.v3=S.v1ToV6=S.v1=S.stringify=S.parse=S.NIL=S.MAX=void 0;var H3=rE();Object.defineProperty(S,"MAX",{enumerable:!0,get:function(){return H3.default}});var W3=nE();Object.defineProperty(S,"NIL",{enumerable:!0,get:function(){return W3.default}});var K3=an();Object.defineProperty(S,"parse",{enumerable:!0,get:function(){return K3.default}});var $3=ot();Object.defineProperty(S,"stringify",{enumerable:!0,get:function(){return $3.default}});var z3=yf();Object.defineProperty(S,"v1",{enumerable:!0,get:function(){return z3.default}});var J3=_f();Object.defineProperty(S,"v1ToV6",{enumerable:!0,get:function(){return J3.default}});var X3=fE();Object.defineProperty(S,"v3",{enumerable:!0,get:function(){return X3.default}});var Q3=hE();Object.defineProperty(S,"v4",{enumerable:!0,get:function(){return Q3.default}});var Y3=bE();Object.defineProperty(S,"v5",{enumerable:!0,get:function(){return Y3.default}});var Z3=_E();Object.defineProperty(S,"v6",{enumerable:!0,get:function(){return Z3.default}});var e$=SE();Object.defineProperty(S,"v6ToV1",{enumerable:!0,get:function(){return e$.default}});var t$=CE();Object.defineProperty(S,"v7",{enumerable:!0,get:function(){return t$.default}});var r$=sn();Object.defineProperty(S,"validate",{enumerable:!0,get:function(){return r$.default}});var n$=AE();Object.defineProperty(S,"version",{enumerable:!0,get:function(){return n$.default}})});var ln=a((xfe,IE)=>{"use strict";var jf=Object.defineProperty,i$=Object.getOwnPropertyDescriptor,o$=Object.getOwnPropertyNames,s$=Object.prototype.hasOwnProperty,a$=(t,e)=>{for(var r in e)jf(t,r,{get:e[r],enumerable:!0})},c$=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of o$(e))!s$.call(t,n)&&n!==r&&jf(t,n,{get:()=>e[n],enumerable:!(i=i$(e,n))||i.enumerable});return t},u$=t=>c$(jf({},"__esModule",{value:!0}),t),wE={};a$(wE,{FramerUtils:()=>d$});IE.exports=u$(wE);var d$={getLastBytesFrom(t,e){return t.slice(-e)},getFirstBytesFrom(t,e){return t.slice(0,e)},bytesToNumber(t){return t.reduce((e,r,i)=>e+r*Math.pow(256,t.length-1-i),0)},numberToByteArray(t,e){return new Uint8Array(e).map((r,i)=>t>>8*(e-1-i)&255)}}});var Rf=a((Mfe,xE)=>{"use strict";var qf=Object.defineProperty,l$=Object.getOwnPropertyDescriptor,p$=Object.getOwnPropertyNames,f$=Object.prototype.hasOwnProperty,v$=(t,e)=>{for(var r in e)qf(t,r,{get:e[r],enumerable:!0})},g$=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of p$(e))!f$.call(t,n)&&n!==r&&qf(t,n,{get:()=>e[n],enumerable:!(i=l$(e,n))||i.enumerable});return t},h$=t=>g$(qf({},"__esModule",{value:!0}),t),PE={};v$(PE,{APDU_RESPONSE_STATUS_CODE_LENGTH:()=>m$,PINGER_TIMEOUT:()=>y$});xE.exports=h$(PE);var m$=2,y$=800});var Io=a((Tfe,TE)=>{"use strict";var kf=Object.defineProperty,b$=Object.getOwnPropertyDescriptor,_$=Object.getOwnPropertyNames,S$=Object.prototype.hasOwnProperty,D$=(t,e)=>{for(var r in e)kf(t,r,{get:e[r],enumerable:!0})},O$=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of _$(e))!S$.call(t,n)&&n!==r&&kf(t,n,{get:()=>e[n],enumerable:!(i=b$(e,n))||i.enumerable});return t},E$=t=>O$(kf({},"__esModule",{value:!0}),t),ME={};D$(ME,{DeviceSessionNotFound:()=>Lf,DeviceSessionRefresherError:()=>Ff,FramerApduError:()=>Uf,FramerOverflowError:()=>Nf,ReceiverApduError:()=>Bf});TE.exports=E$(ME);var Nf=class{_tag="FramerOverflowError";originalError;constructor(){this.originalError=new Error("Frame header length is greater than frame size")}},Uf=class{_tag="FramerApduError";originalError;constructor(){this.originalError=new Error("Frame offset is greater than apdu length")}},Bf=class{_tag="ReceiverApduError";originalError;constructor(e){this.originalError=new Error(e??"Unable to parse apdu")}},Lf=class{_tag="DeviceSessionNotFound";originalError;constructor(e){this.originalError=e??new Error("Device session not found")}},Ff=class{_tag="DeviceSessionRefresherError";originalError;constructor(e){this.originalError=e??new Error("Device session refresher error")}}});var Hf=a((jfe,qE)=>{"use strict";var Gf=Object.defineProperty,C$=Object.getOwnPropertyDescriptor,A$=Object.getOwnPropertyNames,w$=Object.prototype.hasOwnProperty,I$=(t,e)=>{for(var r in e)Gf(t,r,{get:e[r],enumerable:!0})},P$=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of A$(e))!w$.call(t,n)&&n!==r&&Gf(t,n,{get:()=>e[n],enumerable:!(i=C$(e,n))||i.enumerable});return t},x$=t=>P$(Gf({},"__esModule",{value:!0}),t),jE={};I$(jE,{Frame:()=>Vf});qE.exports=x$(jE);var M$=pn(),Vf=class{_header;_data;constructor({header:e,data:r}){this._header=e,this._data=r}toString(){return JSON.stringify({header:this._header.toString(),data:(0,M$.bufferToHexaString)(this._data)},null,2)}getRawData(){let e=this._header.getRawData(),r=new Uint8Array(e.length+this._data.length);return r.set(e,0),r.set(this._data,e.length),r}getHeader(){return this._header}getData(){return this._data}}});var $f=a((qfe,NE)=>{"use strict";var Kf=Object.defineProperty,T$=Object.getOwnPropertyDescriptor,j$=Object.getOwnPropertyNames,q$=Object.prototype.hasOwnProperty,R$=(t,e)=>{for(var r in e)Kf(t,r,{get:e[r],enumerable:!0})},N$=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of j$(e))!q$.call(t,n)&&n!==r&&Kf(t,n,{get:()=>e[n],enumerable:!(i=T$(e,n))||i.enumerable});return t},U$=t=>N$(Kf({},"__esModule",{value:!0}),t),RE={};R$(RE,{FrameHeader:()=>Wf});NE.exports=U$(RE);var B$=ln(),Wf=class{_uuid;_channel;_headTag;_index;_length;_dataLength;constructor({uuid:e,dataSize:r,index:i,headTag:n,length:o,channel:s}){this._uuid=e,this._dataLength=r,this._index=i,this._headTag=n,this._length=o,this._channel=s}getDataLength(){return this._dataLength.map(e=>B$.FramerUtils.bytesToNumber(e))}setDataSize(e){return this._dataLength=e,this}getLength(){return this._length}toString(){return JSON.stringify({uuid:this._uuid.toString(),dataSize:this._dataLength.extract()?.toString(),index:this._index.toString(),headTag:this._headTag.toString(),length:this._length.toString(),channel:this._channel.extract()?.toString()})}getRawData(){return new Uint8Array([...this._channel.caseOf({Just:e=>[...e],Nothing:()=>[]}),...this._headTag,...this._index,...this._dataLength.caseOf({Just:e=>[...e],Nothing:()=>[]})])}}});var P=a((Rfe,BE)=>{"use strict";var zf=Object.defineProperty,L$=Object.getOwnPropertyDescriptor,F$=Object.getOwnPropertyNames,k$=Object.prototype.hasOwnProperty,V$=(t,e)=>{for(var r in e)zf(t,r,{get:e[r],enumerable:!0})},G$=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of F$(e))!k$.call(t,n)&&n!==r&&zf(t,n,{get:()=>e[n],enumerable:!(i=L$(e,n))||i.enumerable});return t},H$=t=>G$(zf({},"__esModule",{value:!0}),t),UE={};V$(UE,{loggerTypes:()=>W$});BE.exports=H$(UE);var W$={LoggerPublisherServiceFactory:Symbol.for("LoggerPublisherServiceFactory")}});var Qf=a((Nfe,HE)=>{"use strict";var Po=Object.defineProperty,VE=Object.getOwnPropertyDescriptor,K$=Object.getOwnPropertyNames,$$=Object.prototype.hasOwnProperty,z$=(t,e)=>{for(var r in e)Po(t,r,{get:e[r],enumerable:!0})},J$=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of K$(e))!$$.call(t,n)&&n!==r&&Po(t,n,{get:()=>e[n],enumerable:!(i=VE(e,n))||i.enumerable});return t},X$=t=>J$(Po({},"__esModule",{value:!0}),t),Q$=(t,e,r,i)=>{for(var n=i>1?void 0:i?VE(e,r):e,o=t.length-1,s;o>=0;o--)(s=t[o])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&Po(e,r,n),n},Y$=(t,e)=>(r,i)=>e(r,i,t),GE={};z$(GE,{DefaultApduReceiverService:()=>Xf});HE.exports=X$(GE);var LE=h(),st=b(),Z$=dn(),e5=yo(),Te=bo(),Jf=ln(),FE=Rf(),kE=Io(),t5=Hf(),r5=$f(),n5=P(),Xf=class{_channel;_logger;_pendingFrames;constructor({channel:t=st.Maybe.zero()},e){this._channel=t,this._logger=e("ApduReceiverService"),this._pendingFrames=[]}handleFrame(t){return this.getFrameFromBytes(t).map(e=>{if(this._pendingFrames.push(e),!this._pendingFrames[0])return st.Nothing;let r=this._pendingFrames[0].getHeader().getDataLength();return this.getCompleteFrame(r)})}getCompleteFrame(t){return t.chain(e=>{if(!this.isComplete(e))return this._logger.debug("frame is not complete, waiting for more"),st.Nothing;let r=Jf.FramerUtils.getFirstBytesFrom(this.concatFrames(this._pendingFrames),e),i=Jf.FramerUtils.getFirstBytesFrom(r,r.length-FE.APDU_RESPONSE_STATUS_CODE_LENGTH),n=Jf.FramerUtils.getLastBytesFrom(r,FE.APDU_RESPONSE_STATUS_CODE_LENGTH);return this._pendingFrames=[],(0,st.Just)(new e5.ApduResponse({data:i,statusCode:n}))})}getFrameFromBytes(t){let e=this._channel.caseOf({Just:()=>Te.CHANNEL_LENGTH,Nothing:()=>0}),r=t.slice(e,e+Te.HEAD_TAG_LENGTH),i=t.slice(e+Te.HEAD_TAG_LENGTH,e+Te.HEAD_TAG_LENGTH+Te.INDEX_LENGTH),n=i.reduce((p,v)=>p+v,0)===0;if(!n&&this._pendingFrames.length===0)return(0,st.Left)(new kE.ReceiverApduError);let o=e+Te.HEAD_TAG_LENGTH+Te.INDEX_LENGTH,s=n?Te.APDU_DATA_LENGTH_LENGTH:0;if(t.length<e+Te.HEAD_TAG_LENGTH+Te.INDEX_LENGTH+s)return(0,st.Left)(new kE.ReceiverApduError("Unable to parse header from apdu"));let l=n?(0,st.Just)(t.slice(o,o+s)):st.Nothing,u=o+s,d=t.slice(u),c=new t5.Frame({header:new r5.FrameHeader({uuid:(0,Z$.v4)(),channel:this._channel,dataSize:l,headTag:r,index:i,length:e+Te.HEAD_TAG_LENGTH+Te.INDEX_LENGTH+s}),data:d});return(0,st.Right)(c)}isComplete(t){return this._pendingFrames.reduce((e,r)=>e+r.getData().length,0)>=t}concatFrames(t){return t.reduce((e,r)=>Uint8Array.from([...e,...r.getData()]),new Uint8Array(0))}};Xf=Q$([(0,LE.injectable)(),Y$(1,(0,LE.inject)(n5.loggerTypes.LoggerPublisherServiceFactory))],Xf)});var $E=a((Bfe,KE)=>{"use strict";var Yf=Object.defineProperty,i5=Object.getOwnPropertyDescriptor,o5=Object.getOwnPropertyNames,s5=Object.prototype.hasOwnProperty,a5=(t,e)=>{for(var r in e)Yf(t,r,{get:e[r],enumerable:!0})},c5=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of o5(e))!s5.call(t,n)&&n!==r&&Yf(t,n,{get:()=>e[n],enumerable:!(i=i5(e,n))||i.enumerable});return t},u5=t=>c5(Yf({},"__esModule",{value:!0}),t),WE={};a5(WE,{defaultApduReceiverServiceStubBuilder:()=>p5});KE.exports=u5(WE);var d5=b(),l5=Qf(),p5=(t={},e)=>new l5.DefaultApduReceiverService({channel:d5.Maybe.of(new Uint8Array([18,52])),...t},e)});var rv=a((Lfe,QE)=>{"use strict";var xo=Object.defineProperty,JE=Object.getOwnPropertyDescriptor,f5=Object.getOwnPropertyNames,v5=Object.prototype.hasOwnProperty,g5=(t,e)=>{for(var r in e)xo(t,r,{get:e[r],enumerable:!0})},h5=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of f5(e))!v5.call(t,n)&&n!==r&&xo(t,n,{get:()=>e[n],enumerable:!(i=JE(e,n))||i.enumerable});return t},m5=t=>h5(xo({},"__esModule",{value:!0}),t),y5=(t,e,r,i)=>{for(var n=i>1?void 0:i?JE(e,r):e,o=t.length-1,s;o>=0;o--)(s=t[o])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&xo(e,r,n),n},b5=(t,e)=>(r,i)=>e(r,i,t),XE={};g5(XE,{DefaultApduSenderService:()=>tv});QE.exports=m5(XE);var zE=h(),Er=b(),_5=dn(),wt=bo(),Zf=ln(),ev=Io(),S5=Hf(),D5=$f(),O5=P(),tv=class{_frameSize;_channel;_padding;_logger;constructor({frameSize:t,channel:e=Er.Maybe.zero(),padding:r=!1},i){this._frameSize=t,this._channel=e,this._padding=r,this._logger=i("DefaultApduSenderService")}getFrames(t){let e=[],r=0,i=this.getFrameAtIndex(t,r);for(;i.isRight();)e.push(i.extract()),r+=1,i=this.getFrameAtIndex(t,r).mapLeft(n=>(n instanceof ev.FramerOverflowError||this._logger.error("Error while parsing frame",{data:{error:n}}),n));return e}getFrameAtIndex(t,e){let r=this.getFrameHeaderFrom(e,t.length),i=e===0?0:e*this._frameSize-this.getHeaderSizeSumFrom(e);if(i>=t.length)return(0,Er.Left)(new ev.FramerOverflowError);if(r.getLength()>this._frameSize)return(0,Er.Left)(new ev.FramerApduError);let n=this._frameSize-r.getLength(),o=t.slice(i,i+this._frameSize-r.getLength()),s=this._padding?new Uint8Array(n).fill(0):new Uint8Array(o.length<n?o.length:n);s.set(o,0);let l=new S5.Frame({header:r,data:s});return(0,Er.Right)(l)}getFrameHeaderFrom(t,e){let r=new D5.FrameHeader({uuid:(0,_5.v4)(),channel:this._channel.map(i=>Zf.FramerUtils.getLastBytesFrom(i,wt.CHANNEL_LENGTH)),headTag:new Uint8Array([wt.HEAD_TAG]),index:Zf.FramerUtils.numberToByteArray(t,wt.INDEX_LENGTH),length:this.getFrameHeaderSizeFromIndex(t),dataSize:Er.Maybe.zero()});return t===0&&r.setDataSize(Er.Maybe.of(Zf.FramerUtils.numberToByteArray(e,wt.APDU_DATA_LENGTH_LENGTH))),r}getHeaderSizeSumFrom(t){let e=this.getFrameHeaderSizeFromIndex(0),r=1;for(;r<t;)e+=this.getFrameHeaderSizeFromIndex(r),r+=1;return e}getFrameHeaderSizeFromIndex(t){return this._channel.caseOf({Just:()=>wt.CHANNEL_LENGTH,Nothing:()=>0})+wt.INDEX_LENGTH+wt.HEAD_TAG_LENGTH+(t===0?wt.APDU_DATA_LENGTH_LENGTH:0)}};tv=y5([(0,zE.injectable)(),b5(1,(0,zE.inject)(O5.loggerTypes.LoggerPublisherServiceFactory))],tv)});var eC=a((kfe,ZE)=>{"use strict";var nv=Object.defineProperty,E5=Object.getOwnPropertyDescriptor,C5=Object.getOwnPropertyNames,A5=Object.prototype.hasOwnProperty,w5=(t,e)=>{for(var r in e)nv(t,r,{get:e[r],enumerable:!0})},I5=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of C5(e))!A5.call(t,n)&&n!==r&&nv(t,n,{get:()=>e[n],enumerable:!(i=E5(e,n))||i.enumerable});return t},P5=t=>I5(nv({},"__esModule",{value:!0}),t),YE={};w5(YE,{defaultApduSenderServiceStubBuilder:()=>T5});ZE.exports=P5(YE);var x5=b(),M5=rv(),T5=(t={},e)=>new M5.DefaultApduSenderService({frameSize:64,channel:x5.Maybe.of(new Uint8Array([18,52])),padding:!0,...t},e)});var ov=a((Vfe,rC)=>{"use strict";var iv=Object.defineProperty,j5=Object.getOwnPropertyDescriptor,q5=Object.getOwnPropertyNames,R5=Object.prototype.hasOwnProperty,N5=(t,e)=>{for(var r in e)iv(t,r,{get:e[r],enumerable:!0})},U5=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of q5(e))!R5.call(t,n)&&n!==r&&iv(t,n,{get:()=>e[n],enumerable:!(i=j5(e,n))||i.enumerable});return t},B5=t=>U5(iv({},"__esModule",{value:!0}),t),tC={};N5(tC,{commandTypes:()=>L5});rC.exports=B5(tC);var L5={SendCommandUseCase:Symbol.for("SendCommandUseCase")}});var fn=a((Gfe,iC)=>{"use strict";var sv=Object.defineProperty,F5=Object.getOwnPropertyDescriptor,k5=Object.getOwnPropertyNames,V5=Object.prototype.hasOwnProperty,G5=(t,e)=>{for(var r in e)sv(t,r,{get:e[r],enumerable:!0})},H5=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of k5(e))!V5.call(t,n)&&n!==r&&sv(t,n,{get:()=>e[n],enumerable:!(i=F5(e,n))||i.enumerable});return t},W5=t=>H5(sv({},"__esModule",{value:!0}),t),nC={};G5(nC,{configTypes:()=>K5});iC.exports=W5(nC);var K5={LocalConfigDataSource:Symbol.for("LocalConfigDataSource"),RemoteConfigDataSource:Symbol.for("RemoteConfigDataSource"),ConfigService:Symbol.for("ConfigService"),GetDmkVersionUseCase:Symbol.for("GetDmkVersionUseCase")}});var K=a((Hfe,sC)=>{"use strict";var av=Object.defineProperty,$5=Object.getOwnPropertyDescriptor,z5=Object.getOwnPropertyNames,J5=Object.prototype.hasOwnProperty,X5=(t,e)=>{for(var r in e)av(t,r,{get:e[r],enumerable:!0})},Q5=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of z5(e))!J5.call(t,n)&&n!==r&&av(t,n,{get:()=>e[n],enumerable:!(i=$5(e,n))||i.enumerable});return t},Y5=t=>Q5(av({},"__esModule",{value:!0}),t),oC={};X5(oC,{deviceSessionTypes:()=>Z5});sC.exports=Y5(oC);var Z5={ApduSenderServiceFactory:Symbol.for("ApduSenderServiceFactory"),ApduReceiverServiceFactory:Symbol.for("ApduReceiverServiceFactory"),DeviceSessionService:Symbol.for("DeviceSessionService"),GetDeviceSessionStateUseCase:Symbol.for("GetDeviceSessionStateUseCase"),DisableDeviceSessionRefresherUseCase:Symbol.for("DisableDeviceSessionRefresherUseCase"),CloseSessionsUseCase:Symbol.for("CloseSessionsUseCase"),UnsafeBypassIntentQueueUseCase:Symbol.for("UnsafeBypassIntentQueueUseCase")}});var Mo=a((Wfe,cC)=>{"use strict";var cv=Object.defineProperty,ez=Object.getOwnPropertyDescriptor,tz=Object.getOwnPropertyNames,rz=Object.prototype.hasOwnProperty,nz=(t,e)=>{for(var r in e)cv(t,r,{get:e[r],enumerable:!0})},iz=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of tz(e))!rz.call(t,n)&&n!==r&&cv(t,n,{get:()=>e[n],enumerable:!(i=ez(e,n))||i.enumerable});return t},oz=t=>iz(cv({},"__esModule",{value:!0}),t),aC={};nz(aC,{discoveryTypes:()=>sz});cC.exports=oz(aC);var sz={StartDiscoveringUseCase:Symbol.for("StartDiscoveringUseCase"),StopDiscoveringUseCase:Symbol.for("StopDiscoveringUseCase"),ConnectUseCase:Symbol.for("ConnectUseCase"),DisconnectUseCase:Symbol.for("DisconnectUseCase"),GetConnectedDeviceUseCase:Symbol.for("GetConnectedDeviceUseCase"),ListenToAvailableDevicesUseCase:Symbol.for("ListenToAvailableDevicesUseCase"),ListenToConnectedDeviceUseCase:Symbol.for("ListenToConnectedDeviceUseCase"),ListConnectedDevicesUseCase:Symbol.for("ListConnectedDevicesUseCase"),ReconnectUseCase:Symbol.for("ReconnectUseCase")}});var $t=a((Kfe,dC)=>{"use strict";var uv=Object.defineProperty,az=Object.getOwnPropertyDescriptor,cz=Object.getOwnPropertyNames,uz=Object.prototype.hasOwnProperty,dz=(t,e)=>{for(var r in e)uv(t,r,{get:e[r],enumerable:!0})},lz=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of cz(e))!uz.call(t,n)&&n!==r&&uv(t,n,{get:()=>e[n],enumerable:!(i=az(e,n))||i.enumerable});return t},pz=t=>lz(uv({},"__esModule",{value:!0}),t),uC={};dz(uC,{managerApiTypes:()=>fz});dC.exports=pz(uC);var fz={ManagerApiService:Symbol.for("ManagerApiService"),ManagerApiDataSource:Symbol.for("ManagerApiDataSource"),DmkConfig:Symbol.for("ManagerApiDmkConfig"),SetProviderUseCase:Symbol.for("SetProviderUseCase")}});var lv=a(($fe,pC)=>{"use strict";var dv=Object.defineProperty,vz=Object.getOwnPropertyDescriptor,gz=Object.getOwnPropertyNames,hz=Object.prototype.hasOwnProperty,mz=(t,e)=>{for(var r in e)dv(t,r,{get:e[r],enumerable:!0})},yz=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of gz(e))!hz.call(t,n)&&n!==r&&dv(t,n,{get:()=>e[n],enumerable:!(i=vz(e,n))||i.enumerable});return t},bz=t=>yz(dv({},"__esModule",{value:!0}),t),lC={};mz(lC,{sendTypes:()=>_z});pC.exports=bz(lC);var _z={SendApduUseCase:Symbol.for("SendApduUseCase")}});var He=a((zfe,vC)=>{"use strict";var pv=Object.defineProperty,Sz=Object.getOwnPropertyDescriptor,Dz=Object.getOwnPropertyNames,Oz=Object.prototype.hasOwnProperty,Ez=(t,e)=>{for(var r in e)pv(t,r,{get:e[r],enumerable:!0})},Cz=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Dz(e))!Oz.call(t,n)&&n!==r&&pv(t,n,{get:()=>e[n],enumerable:!(i=Sz(e,n))||i.enumerable});return t},Az=t=>Cz(pv({},"__esModule",{value:!0}),t),fC={};Ez(fC,{transportDiTypes:()=>wz});vC.exports=Az(fC);var wz={DmkConfig:Symbol.for("TransportDmkConfig"),TransportService:Symbol.for("TransportService"),TransportsInput:Symbol.for("TransportsInput")}});var bC=a((Jfe,yC)=>{"use strict";var To=Object.defineProperty,hC=Object.getOwnPropertyDescriptor,Iz=Object.getOwnPropertyNames,Pz=Object.prototype.hasOwnProperty,xz=(t,e)=>{for(var r in e)To(t,r,{get:e[r],enumerable:!0})},Mz=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Iz(e))!Pz.call(t,n)&&n!==r&&To(t,n,{get:()=>e[n],enumerable:!(i=hC(e,n))||i.enumerable});return t},Tz=t=>Mz(To({},"__esModule",{value:!0}),t),jz=(t,e,r,i)=>{for(var n=i>1?void 0:i?hC(e,r):e,o=t.length-1,s;o>=0;o--)(s=t[o])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&To(e,r,n),n},gC=(t,e)=>(r,i)=>e(r,i,t),mC={};xz(mC,{SendCommandUseCase:()=>vv});yC.exports=Tz(mC);var fv=h(),qz=K(),Rz=P(),vv=class{_sessionService;_logger;constructor(t,e){this._sessionService=t,this._logger=e("SendCommandUseCase")}async execute({sessionId:t,command:e,abortTimeout:r}){return this._sessionService.getDeviceSessionById(t).caseOf({Right:async i=>await i.sendCommand(e,r),Left:i=>{throw this._logger.error("Error getting session",{data:{error:i}}),i}})}};vv=jz([(0,fv.injectable)(),gC(0,(0,fv.inject)(qz.deviceSessionTypes.DeviceSessionService)),gC(1,(0,fv.inject)(Rz.loggerTypes.LoggerPublisherServiceFactory))],vv)});var zt=a((Qfe,DC)=>{"use strict";var jo=Object.defineProperty,_C=Object.getOwnPropertyDescriptor,Nz=Object.getOwnPropertyNames,Uz=Object.prototype.hasOwnProperty,Bz=(t,e)=>{for(var r in e)jo(t,r,{get:e[r],enumerable:!0})},Lz=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Nz(e))!Uz.call(t,n)&&n!==r&&jo(t,n,{get:()=>e[n],enumerable:!(i=_C(e,n))||i.enumerable});return t},Fz=t=>Lz(jo({},"__esModule",{value:!0}),t),kz=(t,e,r,i)=>{for(var n=i>1?void 0:i?_C(e,r):e,o=t.length-1,s;o>=0;o--)(s=t[o])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&jo(e,r,n),n},SC={};Bz(SC,{StubUseCase:()=>gv});DC.exports=Fz(SC);var Vz=h(),gv=class{execute=vi.fn(()=>"stub")};gv=kz([(0,Vz.injectable)()],gv)});var AC=a((Zfe,CC)=>{"use strict";var hv=Object.defineProperty,Gz=Object.getOwnPropertyDescriptor,Hz=Object.getOwnPropertyNames,Wz=Object.prototype.hasOwnProperty,Kz=(t,e)=>{for(var r in e)hv(t,r,{get:e[r],enumerable:!0})},$z=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Hz(e))!Wz.call(t,n)&&n!==r&&hv(t,n,{get:()=>e[n],enumerable:!(i=Gz(e,n))||i.enumerable});return t},zz=t=>$z(hv({},"__esModule",{value:!0}),t),EC={};Kz(EC,{commandModuleFactory:()=>Yz});CC.exports=zz(EC);var Jz=h(),Xz=bC(),Qz=zt(),OC=ov(),Yz=({stub:t=!1}={})=>new Jz.ContainerModule(({bind:e,rebindSync:r})=>{e(OC.commandTypes.SendCommandUseCase).to(Xz.SendCommandUseCase),t&&r(OC.commandTypes.SendCommandUseCase).to(Qz.StubUseCase)})});var MC=a((eve,xC)=>{"use strict";var qo=Object.defineProperty,IC=Object.getOwnPropertyDescriptor,Zz=Object.getOwnPropertyNames,e7=Object.prototype.hasOwnProperty,t7=(t,e)=>{for(var r in e)qo(t,r,{get:e[r],enumerable:!0})},r7=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Zz(e))!e7.call(t,n)&&n!==r&&qo(t,n,{get:()=>e[n],enumerable:!(i=IC(e,n))||i.enumerable});return t},n7=t=>r7(qo({},"__esModule",{value:!0}),t),i7=(t,e,r,i)=>{for(var n=i>1?void 0:i?IC(e,r):e,o=t.length-1,s;o>=0;o--)(s=t[o])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&qo(e,r,n),n},wC=(t,e)=>(r,i)=>e(r,i,t),PC={};t7(PC,{ExecuteDeviceActionUseCase:()=>yv});xC.exports=n7(PC);var mv=h(),o7=K(),s7=P(),yv=class{_sessionService;_logger;constructor(t,e){this._sessionService=t,this._logger=e("ExecuteDeviceActionUseCase")}execute({sessionId:t,deviceAction:e}){return this._sessionService.getDeviceSessionById(t).caseOf({Right:r=>r.executeDeviceAction(e),Left:r=>{throw this._logger.error("Error getting session",{data:{error:r}}),r}})}};yv=i7([(0,mv.injectable)(),wC(0,(0,mv.inject)(o7.deviceSessionTypes.DeviceSessionService)),wC(1,(0,mv.inject)(s7.loggerTypes.LoggerPublisherServiceFactory))],yv)});var _v=a((rve,jC)=>{"use strict";var bv=Object.defineProperty,a7=Object.getOwnPropertyDescriptor,c7=Object.getOwnPropertyNames,u7=Object.prototype.hasOwnProperty,d7=(t,e)=>{for(var r in e)bv(t,r,{get:e[r],enumerable:!0})},l7=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of c7(e))!u7.call(t,n)&&n!==r&&bv(t,n,{get:()=>e[n],enumerable:!(i=a7(e,n))||i.enumerable});return t},p7=t=>l7(bv({},"__esModule",{value:!0}),t),TC={};d7(TC,{deviceActionTypes:()=>f7});jC.exports=p7(TC);var f7={ExecuteDeviceActionUseCase:Symbol.for("ExecuteDeviceActionUseCase")}});var UC=a((nve,NC)=>{"use strict";var Sv=Object.defineProperty,v7=Object.getOwnPropertyDescriptor,g7=Object.getOwnPropertyNames,h7=Object.prototype.hasOwnProperty,m7=(t,e)=>{for(var r in e)Sv(t,r,{get:e[r],enumerable:!0})},y7=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of g7(e))!h7.call(t,n)&&n!==r&&Sv(t,n,{get:()=>e[n],enumerable:!(i=v7(e,n))||i.enumerable});return t},b7=t=>y7(Sv({},"__esModule",{value:!0}),t),RC={};m7(RC,{deviceActionModuleFactory:()=>O7});NC.exports=b7(RC);var _7=h(),S7=MC(),D7=zt(),qC=_v(),O7=({stub:t=!1}={})=>new _7.ContainerModule(({bind:e,rebindSync:r})=>{e(qC.deviceActionTypes.ExecuteDeviceActionUseCase).to(S7.ExecuteDeviceActionUseCase),t&&r(qC.deviceActionTypes.ExecuteDeviceActionUseCase).to(D7.StubUseCase)})});var FC=a((ive,LC)=>{"use strict";var Dv=Object.defineProperty,E7=Object.getOwnPropertyDescriptor,C7=Object.getOwnPropertyNames,A7=Object.prototype.hasOwnProperty,w7=(t,e)=>{for(var r in e)Dv(t,r,{get:e[r],enumerable:!0})},I7=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of C7(e))!A7.call(t,n)&&n!==r&&Dv(t,n,{get:()=>e[n],enumerable:!(i=E7(e,n))||i.enumerable});return t},P7=t=>I7(Dv({},"__esModule",{value:!0}),t),BC={};w7(BC,{isConfig:()=>x7});LC.exports=P7(BC);function x7(t){return typeof t=="object"&&t!==null&&"version"in t&&"name"in t&&typeof t.version=="string"&&typeof t.name=="string"}});var Iv=a((ove,VC)=>{"use strict";var wv=Object.defineProperty,M7=Object.getOwnPropertyDescriptor,T7=Object.getOwnPropertyNames,j7=Object.prototype.hasOwnProperty,q7=(t,e)=>{for(var r in e)wv(t,r,{get:e[r],enumerable:!0})},R7=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of T7(e))!j7.call(t,n)&&n!==r&&wv(t,n,{get:()=>e[n],enumerable:!(i=M7(e,n))||i.enumerable});return t},N7=t=>R7(wv({},"__esModule",{value:!0}),t),kC={};q7(kC,{ApiCallError:()=>Ov,JSONParseError:()=>Cv,ParseResponseError:()=>Ev,ReadFileError:()=>Av});VC.exports=N7(kC);var Ov=class{constructor(e){this.err=e,this.originalError=e}_tag="ApiCallError";originalError},Ev=class{constructor(e){this.err=e,this.originalError=e}_tag="ParseResponseError";originalError},Cv=class{constructor(e){this.err=e,this.originalError=e}_tag="JSONParseError";originalError},Av=class{constructor(e){this.err=e,this.originalError=e}_tag="ReadFileError";originalError}});var GC=a((sve,U7)=>{U7.exports={dependencies:{"@noble/hashes":"^1.8.0","@sentry/minimal":"catalog:",axios:"catalog:",inversify:"catalog:","isomorphic-ws":"catalog:","purify-ts":"catalog:","reflect-metadata":"catalog:",semver:"catalog:",url:"catalog:",uuid:"catalog:",ws:"catalog:",xstate:"catalog:"},devDependencies:{"@ledgerhq/eslint-config-dsdk":"workspace:^","@ledgerhq/ldmk-tool":"workspace:^","@ledgerhq/prettier-config-dsdk":"workspace:^","@ledgerhq/tsconfig-dsdk":"workspace:^","@ledgerhq/vitest-config-dmk":"workspace:^","@statelyai/inspect":"catalog:","@types/semver":"catalog:","@types/uuid":"catalog:","@types/ws":"catalog:",rxjs:"catalog:","ts-node":"catalog:"},exports:{".":{import:"./lib/esm/index.js",require:"./lib/cjs/index.js",types:"./lib/types/index.d.ts"}},files:["./lib","package.json"],license:"Apache-2.0",name:"@ledgerhq/device-management-kit",peerDependencies:{rxjs:"catalog:"},private:!1,repository:{type:"git",url:"https://github.com/LedgerHQ/device-sdk-ts.git"},scripts:{build:"pnpm ldmk-tool build --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json",dev:'concurrently "pnpm watch:builds" "pnpm watch:types"',lint:"eslint","lint:fix":"pnpm lint --fix","module:create":"pnpm hygen core-module with-prompt",postpack:"find . -name '*.tgz' -exec cp {} ../../dist/ \\; ",prebuild:"rimraf lib",prettier:"prettier . --check","prettier:fix":"prettier . --write",test:"vitest run","test:coverage":"vitest run --coverage","test:watch":"vitest",typecheck:"tsc --noEmit","watch:builds":"pnpm ldmk-tool watch --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json","watch:types":'concurrently "tsc --watch -p tsconfig.prod.json" "tsc-alias --watch -p tsconfig.prod.json"'},version:"1.1.0"}});var YC=a((ave,QC)=>{"use strict";var B7=Object.create,vn=Object.defineProperty,$C=Object.getOwnPropertyDescriptor,L7=Object.getOwnPropertyNames,F7=Object.getPrototypeOf,k7=Object.prototype.hasOwnProperty,V7=(t,e)=>{for(var r in e)vn(t,r,{get:e[r],enumerable:!0})},zC=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of L7(e))!k7.call(t,n)&&n!==r&&vn(t,n,{get:()=>e[n],enumerable:!(i=$C(e,n))||i.enumerable});return t},G7=(t,e,r)=>(r=t!=null?B7(F7(t)):{},zC(e||!t||!t.__esModule?vn(r,"default",{value:t,enumerable:!0}):r,t)),H7=t=>zC(vn({},"__esModule",{value:!0}),t),W7=(t,e,r,i)=>{for(var n=i>1?void 0:i?$C(e,r):e,o=t.length-1,s;o>=0;o--)(s=t[o])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&vn(e,r,n),n},JC={};V7(JC,{FileLocalConfigDataSource:()=>Pv,stubFsReadFile:()=>XC});QC.exports=H7(JC);var K7=h(),HC=b(),$7=FC(),WC=Iv(),KC=G7(GC()),z7={name:KC.default.name,version:KC.default.version},XC=()=>JSON.stringify(z7),Pv=class{getConfig(){return HC.Either.encase(()=>XC()).mapLeft(t=>new WC.ReadFileError(t)).chain(t=>HC.Either.encase(()=>{let e=JSON.parse(t);if((0,$7.isConfig)(e))return e;throw new Error("Invalid config file")}).mapLeft(e=>new WC.JSONParseError(e)))}};Pv=W7([(0,K7.injectable)()],Pv)});var rA=a((uve,tA)=>{"use strict";var Ro=Object.defineProperty,ZC=Object.getOwnPropertyDescriptor,J7=Object.getOwnPropertyNames,X7=Object.prototype.hasOwnProperty,Q7=(t,e)=>{for(var r in e)Ro(t,r,{get:e[r],enumerable:!0})},Y7=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of J7(e))!X7.call(t,n)&&n!==r&&Ro(t,n,{get:()=>e[n],enumerable:!(i=ZC(e,n))||i.enumerable});return t},Z7=t=>Y7(Ro({},"__esModule",{value:!0}),t),eJ=(t,e,r,i)=>{for(var n=i>1?void 0:i?ZC(e,r):e,o=t.length-1,s;o>=0;o--)(s=t[o])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&Ro(e,r,n),n},eA={};Q7(eA,{StubLocalConfigDataSource:()=>xv});tA.exports=Z7(eA);var tJ=h(),rJ=b(),xv=class{getConfig(){return rJ.Either.of({name:"DeviceSDK",version:"0.0.0-stub.1"})}};xv=eJ([(0,tJ.injectable)()],xv)});var sA=a((lve,oA)=>{"use strict";var Uo=Object.defineProperty,nA=Object.getOwnPropertyDescriptor,nJ=Object.getOwnPropertyNames,iJ=Object.prototype.hasOwnProperty,oJ=(t,e)=>{for(var r in e)Uo(t,r,{get:e[r],enumerable:!0})},sJ=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of nJ(e))!iJ.call(t,n)&&n!==r&&Uo(t,n,{get:()=>e[n],enumerable:!(i=nA(e,n))||i.enumerable});return t},aJ=t=>sJ(Uo({},"__esModule",{value:!0}),t),cJ=(t,e,r,i)=>{for(var n=i>1?void 0:i?nA(e,r):e,o=t.length-1,s;o>=0;o--)(s=t[o])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&Uo(e,r,n),n},iA={};oJ(iA,{RestRemoteConfigDataSource:()=>Mv});oA.exports=aJ(iA);var uJ=h(),Jt=b(),No=Iv(),Mv=class{async getConfig(){let t=await this._callApi();if(t.isLeft())return(0,Jt.Left)(new No.ApiCallError(t.extract()));if(!t.extract().ok)return(0,Jt.Left)(new No.ApiCallError(new Error("response not ok")));let e=await t.extract().json();return e.isLeft()?(0,Jt.Left)(new No.JSONParseError):e.chain(r=>this._parseResponse(r)).map(r=>r)}_parseResponse(t){let{name:e,version:r}=t;return!e||!r?(0,Jt.Left)(new No.ParseResponseError):Jt.Either.of({name:e,version:r})}_callApi(){return new Promise(t=>{t(Jt.Either.of({ok:!0,json:async()=>new Promise(e=>{e(Jt.Either.of({name:"DeviceSDK",version:"0.0.0-fake.1",yolo:"yolo"}))})}))})}};Mv=cJ([(0,uJ.injectable)()],Mv)});var dA=a((fve,uA)=>{"use strict";var Bo=Object.defineProperty,aA=Object.getOwnPropertyDescriptor,dJ=Object.getOwnPropertyNames,lJ=Object.prototype.hasOwnProperty,pJ=(t,e)=>{for(var r in e)Bo(t,r,{get:e[r],enumerable:!0})},fJ=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of dJ(e))!lJ.call(t,n)&&n!==r&&Bo(t,n,{get:()=>e[n],enumerable:!(i=aA(e,n))||i.enumerable});return t},vJ=t=>fJ(Bo({},"__esModule",{value:!0}),t),gJ=(t,e,r,i)=>{for(var n=i>1?void 0:i?aA(e,r):e,o=t.length-1,s;o>=0;o--)(s=t[o])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&Bo(e,r,n),n},cA={};pJ(cA,{StubRemoteConfigDataSource:()=>Tv});uA.exports=vJ(cA);var hJ=h(),mJ=b(),Tv=class{async getConfig(){return new Promise(t=>t(mJ.Either.of({name:"DeviceSDK",version:"0.0.0-fake.2"})))}};Tv=gJ([(0,hJ.injectable)()],Tv)});var gA=a((gve,vA)=>{"use strict";var Fo=Object.defineProperty,pA=Object.getOwnPropertyDescriptor,yJ=Object.getOwnPropertyNames,bJ=Object.prototype.hasOwnProperty,_J=(t,e)=>{for(var r in e)Fo(t,r,{get:e[r],enumerable:!0})},SJ=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of yJ(e))!bJ.call(t,n)&&n!==r&&Fo(t,n,{get:()=>e[n],enumerable:!(i=pA(e,n))||i.enumerable});return t},DJ=t=>SJ(Fo({},"__esModule",{value:!0}),t),OJ=(t,e,r,i)=>{for(var n=i>1?void 0:i?pA(e,r):e,o=t.length-1,s;o>=0;o--)(s=t[o])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&Fo(e,r,n),n},jv=(t,e)=>(r,i)=>e(r,i,t),fA={};_J(fA,{DefaultConfigService:()=>qv});vA.exports=DJ(fA);var Lo=h(),lA=fn(),EJ=P(),qv=class{_local;_remote;_logger;constructor(t,e,r){this._local=t,this._remote=e,this._logger=r("config")}async getDmkConfig(){let t=this._local.getConfig().ifLeft(e=>{this._logger.error("Local config not available",{data:{error:e}})});if(t.isRight()){let e=t.extract();return this._logger.info("Local config available",{data:{config:e}}),e}return this._remote.getConfig().then(e=>e.mapLeft(r=>(this._logger.error("Local config available",{data:{error:r}}),{name:"DeadDmk",version:"0.0.0-dead.1"})).extract())}};qv=OJ([(0,Lo.injectable)(),jv(0,(0,Lo.inject)(lA.configTypes.LocalConfigDataSource)),jv(1,(0,Lo.inject)(lA.configTypes.RemoteConfigDataSource)),jv(2,(0,Lo.inject)(EJ.loggerTypes.LoggerPublisherServiceFactory))],qv)});var _A=a((mve,bA)=>{"use strict";var ko=Object.defineProperty,mA=Object.getOwnPropertyDescriptor,CJ=Object.getOwnPropertyNames,AJ=Object.prototype.hasOwnProperty,wJ=(t,e)=>{for(var r in e)ko(t,r,{get:e[r],enumerable:!0})},IJ=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of CJ(e))!AJ.call(t,n)&&n!==r&&ko(t,n,{get:()=>e[n],enumerable:!(i=mA(e,n))||i.enumerable});return t},PJ=t=>IJ(ko({},"__esModule",{value:!0}),t),xJ=(t,e,r,i)=>{for(var n=i>1?void 0:i?mA(e,r):e,o=t.length-1,s;o>=0;o--)(s=t[o])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&ko(e,r,n),n},MJ=(t,e)=>(r,i)=>e(r,i,t),yA={};wJ(yA,{GetDmkVersionUseCase:()=>Rv});bA.exports=PJ(yA);var hA=h(),TJ=fn(),Rv=class{_configService;constructor(t){this._configService=t}async getDmkVersion(){return(await this._configService.getDmkConfig()).version}};Rv=xJ([(0,hA.injectable)(),MJ(0,(0,hA.inject)(TJ.configTypes.ConfigService))],Rv)});var OA=a((bve,DA)=>{"use strict";var Nv=Object.defineProperty,jJ=Object.getOwnPropertyDescriptor,qJ=Object.getOwnPropertyNames,RJ=Object.prototype.hasOwnProperty,NJ=(t,e)=>{for(var r in e)Nv(t,r,{get:e[r],enumerable:!0})},UJ=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of qJ(e))!RJ.call(t,n)&&n!==r&&Nv(t,n,{get:()=>e[n],enumerable:!(i=jJ(e,n))||i.enumerable});return t},BJ=t=>UJ(Nv({},"__esModule",{value:!0}),t),SA={};NJ(SA,{configModuleFactory:()=>KJ});DA.exports=BJ(SA);var LJ=h(),FJ=YC(),kJ=rA(),VJ=sA(),GJ=dA(),HJ=gA(),WJ=_A(),Cr=fn(),KJ=({stub:t})=>new LJ.ContainerModule(({bind:e,rebindSync:r})=>{e(Cr.configTypes.LocalConfigDataSource).to(FJ.FileLocalConfigDataSource),e(Cr.configTypes.RemoteConfigDataSource).to(VJ.RestRemoteConfigDataSource),e(Cr.configTypes.GetDmkVersionUseCase).to(WJ.GetDmkVersionUseCase),e(Cr.configTypes.ConfigService).to(HJ.DefaultConfigService),t&&(r(Cr.configTypes.LocalConfigDataSource).to(kJ.StubLocalConfigDataSource),r(Cr.configTypes.RemoteConfigDataSource).to(GJ.StubRemoteConfigDataSource))})});var Bv=a((_ve,CA)=>{"use strict";var Uv=Object.defineProperty,$J=Object.getOwnPropertyDescriptor,zJ=Object.getOwnPropertyNames,JJ=Object.prototype.hasOwnProperty,XJ=(t,e)=>{for(var r in e)Uv(t,r,{get:e[r],enumerable:!0})},QJ=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of zJ(e))!JJ.call(t,n)&&n!==r&&Uv(t,n,{get:()=>e[n],enumerable:!(i=$J(e,n))||i.enumerable});return t},YJ=t=>QJ(Uv({},"__esModule",{value:!0}),t),EA={};XJ(EA,{deviceModelTypes:()=>ZJ});CA.exports=YJ(EA);var ZJ={DeviceModelDataSource:Symbol.for("DeviceModelDataSource")}});var IA=a((Sve,wA)=>{"use strict";var Lv=Object.defineProperty,e9=Object.getOwnPropertyDescriptor,t9=Object.getOwnPropertyNames,r9=Object.prototype.hasOwnProperty,n9=(t,e)=>{for(var r in e)Lv(t,r,{get:e[r],enumerable:!0})},i9=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of t9(e))!r9.call(t,n)&&n!==r&&Lv(t,n,{get:()=>e[n],enumerable:!(i=e9(e,n))||i.enumerable});return t},o9=t=>i9(Lv({},"__esModule",{value:!0}),t),AA={};n9(AA,{deviceModelModuleFactory:()=>u9});wA.exports=o9(AA);var s9=h(),a9=Jp(),c9=Bv(),u9=({stub:t})=>new s9.ContainerModule(({bind:e})=>{e(c9.deviceModelTypes.DeviceModelDataSource).to(a9.StaticDeviceModelDataSource)})});var jA=a((Dve,TA)=>{"use strict";var Vo=Object.defineProperty,xA=Object.getOwnPropertyDescriptor,d9=Object.getOwnPropertyNames,l9=Object.prototype.hasOwnProperty,p9=(t,e)=>{for(var r in e)Vo(t,r,{get:e[r],enumerable:!0})},f9=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of d9(e))!l9.call(t,n)&&n!==r&&Vo(t,n,{get:()=>e[n],enumerable:!(i=xA(e,n))||i.enumerable});return t},v9=t=>f9(Vo({},"__esModule",{value:!0}),t),g9=(t,e,r,i)=>{for(var n=i>1?void 0:i?xA(e,r):e,o=t.length-1,s;o>=0;o--)(s=t[o])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&Vo(e,r,n),n},PA=(t,e)=>(r,i)=>e(r,i,t),MA={};p9(MA,{DisableDeviceSessionRefresherUseCase:()=>kv});TA.exports=v9(MA);var Fv=h(),h9=K(),m9=P(),kv=class{constructor(t,e){this._sessionService=t,this._logger=e("DisableDeviceSessionRefresherUseCase")}_logger;execute({sessionId:t,blockerId:e}){return this._sessionService.getDeviceSessionById(t).caseOf({Left:r=>{throw this._logger.error("Error getting device session",{data:{error:r}}),r},Right:r=>r.disableRefresher(e)})}};kv=g9([(0,Fv.injectable)(),PA(0,(0,Fv.inject)(h9.deviceSessionTypes.DeviceSessionService)),PA(1,(0,Fv.inject)(m9.loggerTypes.LoggerPublisherServiceFactory))],kv)});var FA=a((Eve,LA)=>{"use strict";var Go=Object.defineProperty,UA=Object.getOwnPropertyDescriptor,y9=Object.getOwnPropertyNames,b9=Object.prototype.hasOwnProperty,_9=(t,e)=>{for(var r in e)Go(t,r,{get:e[r],enumerable:!0})},S9=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of y9(e))!b9.call(t,n)&&n!==r&&Go(t,n,{get:()=>e[n],enumerable:!(i=UA(e,n))||i.enumerable});return t},D9=t=>S9(Go({},"__esModule",{value:!0}),t),O9=(t,e,r,i)=>{for(var n=i>1?void 0:i?UA(e,r):e,o=t.length-1,s;o>=0;o--)(s=t[o])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&Go(e,r,n),n},E9=(t,e)=>(r,i)=>e(r,i,t),BA={};_9(BA,{DefaultDeviceSessionService:()=>Vv});LA.exports=D9(BA);var qA=h(),RA=b(),C9=De(),NA=Io(),A9=P(),Vv=class{_sessions;_sessionsSubject;_logger;constructor(t){this._sessions=[],this._sessionsSubject=new C9.ReplaySubject,this._logger=t("DeviceSessionService")}get sessionsObs(){return this._sessionsSubject.asObservable()}addDeviceSession(t){return this._sessions.find(e=>e.id===t.id)?(this._logger.warn("DeviceSession already exists",{data:{deviceSession:t}}),this):(this._sessions.push(t),this._sessionsSubject.next(t),this._logger.info("DeviceSession added",{data:{sessionId:t.id}}),this)}removeDeviceSession(t){let e=this._sessions.find(r=>r.id===t);return e?(e.close(),this._sessions=this._sessions.filter(r=>r.id!==t),this._logger.info("DeviceSession removed",{data:{sessionId:t}}),this):(this._logger.warn("DeviceSession not found",{data:{sessionId:t}}),this)}getDeviceSessionById(t){return RA.Maybe.fromNullable(this._sessions.find(e=>e.id===t)).toEither(new NA.DeviceSessionNotFound)}getDeviceSessionsByDeviceId(t){return RA.Maybe.fromPredicate(({length:e})=>e>0,this._sessions.filter(e=>e.connectedDevice.id===t)).toEither(new NA.DeviceSessionNotFound)}getDeviceSessions(){return this._sessions}};Vv=O9([(0,qA.injectable)(),E9(0,(0,qA.inject)(A9.loggerTypes.LoggerPublisherServiceFactory))],Vv)});var WA=a((Ave,HA)=>{"use strict";var Ho=Object.defineProperty,VA=Object.getOwnPropertyDescriptor,w9=Object.getOwnPropertyNames,I9=Object.prototype.hasOwnProperty,P9=(t,e)=>{for(var r in e)Ho(t,r,{get:e[r],enumerable:!0})},x9=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of w9(e))!I9.call(t,n)&&n!==r&&Ho(t,n,{get:()=>e[n],enumerable:!(i=VA(e,n))||i.enumerable});return t},M9=t=>x9(Ho({},"__esModule",{value:!0}),t),T9=(t,e,r,i)=>{for(var n=i>1?void 0:i?VA(e,r):e,o=t.length-1,s;o>=0;o--)(s=t[o])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&Ho(e,r,n),n},kA=(t,e)=>(r,i)=>e(r,i,t),GA={};P9(GA,{CloseSessionsUseCase:()=>Hv});HA.exports=M9(GA);var Gv=h(),j9=K(),q9=He(),Hv=class{_sessionService;_transportService;constructor(t,e){this._sessionService=t,this._transportService=e}execute(){let t=this._sessionService.getDeviceSessions();for(let e of t)this._transportService.closeConnection(e.connectedDevice),this._sessionService.removeDeviceSession(e.id)}};Hv=T9([(0,Gv.injectable)(),kA(0,(0,Gv.inject)(j9.deviceSessionTypes.DeviceSessionService)),kA(1,(0,Gv.inject)(q9.transportDiTypes.TransportService))],Hv)});var XA=a((Ive,JA)=>{"use strict";var Wo=Object.defineProperty,$A=Object.getOwnPropertyDescriptor,R9=Object.getOwnPropertyNames,N9=Object.prototype.hasOwnProperty,U9=(t,e)=>{for(var r in e)Wo(t,r,{get:e[r],enumerable:!0})},B9=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of R9(e))!N9.call(t,n)&&n!==r&&Wo(t,n,{get:()=>e[n],enumerable:!(i=$A(e,n))||i.enumerable});return t},L9=t=>B9(Wo({},"__esModule",{value:!0}),t),F9=(t,e,r,i)=>{for(var n=i>1?void 0:i?$A(e,r):e,o=t.length-1,s;o>=0;o--)(s=t[o])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&Wo(e,r,n),n},KA=(t,e)=>(r,i)=>e(r,i,t),zA={};U9(zA,{GetDeviceSessionStateUseCase:()=>Kv});JA.exports=L9(zA);var Wv=h(),k9=K(),V9=P(),Kv=class{_sessionService;_logger;constructor(t,e){this._sessionService=t,this._logger=e("GetDeviceSessionStateUseCase")}execute({sessionId:t}){return this._sessionService.getDeviceSessionById(t).caseOf({Left:e=>{throw this._logger.error("Error getting session device",{data:{error:e}}),e},Right:e=>e.state})}};Kv=F9([(0,Wv.injectable)(),KA(0,(0,Wv.inject)(k9.deviceSessionTypes.DeviceSessionService)),KA(1,(0,Wv.inject)(V9.loggerTypes.LoggerPublisherServiceFactory))],Kv)});var tw=a((xve,ew)=>{"use strict";var Ko=Object.defineProperty,YA=Object.getOwnPropertyDescriptor,G9=Object.getOwnPropertyNames,H9=Object.prototype.hasOwnProperty,W9=(t,e)=>{for(var r in e)Ko(t,r,{get:e[r],enumerable:!0})},K9=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of G9(e))!H9.call(t,n)&&n!==r&&Ko(t,n,{get:()=>e[n],enumerable:!(i=YA(e,n))||i.enumerable});return t},$9=t=>K9(Ko({},"__esModule",{value:!0}),t),z9=(t,e,r,i)=>{for(var n=i>1?void 0:i?YA(e,r):e,o=t.length-1,s;o>=0;o--)(s=t[o])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&Ko(e,r,n),n},QA=(t,e)=>(r,i)=>e(r,i,t),ZA={};W9(ZA,{UnsafeBypassIntentQueueUseCase:()=>zv});ew.exports=$9(ZA);var $v=h(),J9=K(),X9=P(),zv=class{_sessionService;_logger;constructor(t,e){this._sessionService=t,this._logger=e("UnsafeBypassIntentQueueUseCase")}execute({sessionId:t,bypass:e}){this._sessionService.getDeviceSessionById(t).caseOf({Left:r=>{throw this._logger.error("Error getting session",{data:{error:r}}),r},Right:r=>{this._logger.warn(`UNSAFE: ${e?"Enabling":"Disabling"} intent queue bypass for session ${t}`),r._unsafeBypassIntentQueue(e)}})}};zv=z9([(0,$v.injectable)(),QA(0,(0,$v.inject)(J9.deviceSessionTypes.DeviceSessionService)),QA(1,(0,$v.inject)(X9.loggerTypes.LoggerPublisherServiceFactory))],zv)});var ow=a((Tve,iw)=>{"use strict";var Xv=Object.defineProperty,Q9=Object.getOwnPropertyDescriptor,Y9=Object.getOwnPropertyNames,Z9=Object.prototype.hasOwnProperty,eX=(t,e)=>{for(var r in e)Xv(t,r,{get:e[r],enumerable:!0})},tX=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Y9(e))!Z9.call(t,n)&&n!==r&&Xv(t,n,{get:()=>e[n],enumerable:!(i=Q9(e,n))||i.enumerable});return t},rX=t=>tX(Xv({},"__esModule",{value:!0}),t),nw={};eX(nw,{deviceSessionModuleFactory:()=>lX});iw.exports=rX(nw);var nX=h(),iX=jA(),oX=Qf(),sX=rv(),aX=FA(),cX=WA(),uX=XA(),dX=tw(),rw=P(),Jv=zt(),We=K(),lX=({stub:t}={stub:!1})=>new nX.ContainerModule(({bind:e,rebindSync:r})=>{e(We.deviceSessionTypes.ApduSenderServiceFactory).toFactory(i=>{let n=i.get(rw.loggerTypes.LoggerPublisherServiceFactory);return o=>new sX.DefaultApduSenderService(o,n)}),e(We.deviceSessionTypes.ApduReceiverServiceFactory).toFactory(i=>{let n=i.get(rw.loggerTypes.LoggerPublisherServiceFactory);return(o={})=>new oX.DefaultApduReceiverService(o,n)}),e(We.deviceSessionTypes.DeviceSessionService).to(aX.DefaultDeviceSessionService).inSingletonScope(),e(We.deviceSessionTypes.GetDeviceSessionStateUseCase).to(uX.GetDeviceSessionStateUseCase),e(We.deviceSessionTypes.CloseSessionsUseCase).to(cX.CloseSessionsUseCase),e(We.deviceSessionTypes.DisableDeviceSessionRefresherUseCase).to(iX.DisableDeviceSessionRefresherUseCase),e(We.deviceSessionTypes.UnsafeBypassIntentQueueUseCase).to(dX.UnsafeBypassIntentQueueUseCase),t&&(r(We.deviceSessionTypes.GetDeviceSessionStateUseCase).to(Jv.StubUseCase),r(We.deviceSessionTypes.DisableDeviceSessionRefresherUseCase).to(Jv.StubUseCase),r(We.deviceSessionTypes.UnsafeBypassIntentQueueUseCase).to(Jv.StubUseCase))})});var Yv=a((jve,aw)=>{"use strict";var Qv=Object.defineProperty,pX=Object.getOwnPropertyDescriptor,fX=Object.getOwnPropertyNames,vX=Object.prototype.hasOwnProperty,gX=(t,e)=>{for(var r in e)Qv(t,r,{get:e[r],enumerable:!0})},hX=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of fX(e))!vX.call(t,n)&&n!==r&&Qv(t,n,{get:()=>e[n],enumerable:!(i=pX(e,n))||i.enumerable});return t},mX=t=>hX(Qv({},"__esModule",{value:!0}),t),sw={};gX(sw,{formatApduReceivedLog:()=>_X,formatApduSendingLog:()=>yX,formatApduSentLog:()=>bX});aw.exports=mX(sw);var $o=jt();function yX(t){return`[will send APDU] ~...> ${(0,$o.bufferToHexaString)(t,!1)}`}function bX(t){return`[exchange] => ${(0,$o.bufferToHexaString)(t,!1)}`}function _X(t){return`[exchange] <= ${(0,$o.bufferToHexaString)(t.data,!1)}${(0,$o.bufferToHexaString)(t.statusCode,!1)}`}});var zo=a((qve,uw)=>{"use strict";var Zv=Object.defineProperty,SX=Object.getOwnPropertyDescriptor,DX=Object.getOwnPropertyNames,OX=Object.prototype.hasOwnProperty,EX=(t,e)=>{for(var r in e)Zv(t,r,{get:e[r],enumerable:!0})},CX=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of DX(e))!OX.call(t,n)&&n!==r&&Zv(t,n,{get:()=>e[n],enumerable:!(i=SX(e,n))||i.enumerable});return t},AX=t=>CX(Zv({},"__esModule",{value:!0}),t),cw={};EX(cw,{DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS:()=>PX,DEVICE_SESSION_REFRESHER_MINIMUM_POLLING_INTERVAL:()=>IX,DEVICE_SESSION_REFRESHER_POLLING_INTERVAL:()=>wX});uw.exports=AX(cw);var wX=1e3,IX=1e3,PX={isRefresherDisabled:!1,pollingInterval:1e3}});var Ar=a((Rve,pw)=>{"use strict";var tg=Object.defineProperty,xX=Object.getOwnPropertyDescriptor,MX=Object.getOwnPropertyNames,TX=Object.prototype.hasOwnProperty,jX=(t,e)=>{for(var r in e)tg(t,r,{get:e[r],enumerable:!0})},qX=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of MX(e))!TX.call(t,n)&&n!==r&&tg(t,n,{get:()=>e[n],enumerable:!(i=xX(e,n))||i.enumerable});return t},RX=t=>qX(tg({},"__esModule",{value:!0}),t),dw={};jX(dw,{DeviceSessionEventDispatcher:()=>eg,SessionEvents:()=>lw});pw.exports=RX(dw);var NX=De(),lw=(t=>(t.NEW_STATE="NEW_STATE",t.REFRESH_NEEDED="REFRESH_NEEDED",t.COMMAND_SUCCEEDED="COMMAND_SUCCEEDED",t.DEVICE_STATE_UPDATE_BUSY="DEVICE_STATE_UPDATE_BUSY",t.DEVICE_STATE_UPDATE_LOCKED="DEVICE_STATE_UPDATE_LOCKED",t.DEVICE_STATE_UPDATE_CONNECTED="DEVICE_STATE_UPDATE_CONNECTED",t.DEVICE_STATE_UPDATE_UNKNOWN="DEVICE_STATE_UPDATE_UNKNOWN",t))(lw||{}),eg=class{_eventEmitter=new NX.Subject;listen(){return this._eventEmitter.asObservable()}dispatch(e){this._eventEmitter.next(e)}}});var mw=a((Nve,hw)=>{"use strict";var ng=Object.defineProperty,UX=Object.getOwnPropertyDescriptor,BX=Object.getOwnPropertyNames,LX=Object.prototype.hasOwnProperty,FX=(t,e)=>{for(var r in e)ng(t,r,{get:e[r],enumerable:!0})},kX=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of BX(e))!LX.call(t,n)&&n!==r&&ng(t,n,{get:()=>e[n],enumerable:!(i=UX(e,n))||i.enumerable});return t},VX=t=>kX(ng({},"__esModule",{value:!0}),t),gw={};FX(gw,{IntentQueueService:()=>rg});hw.exports=VX(gw);var fw=De(),vw=Ar(),rg=class{constructor(e,r){this.loggerModuleFactory=e,this.sessionEventDispatcher=r,this._logger=this.loggerModuleFactory("IntentQueueService")}_logger;_queue=[];_isProcessing=!1;_currentSubscription=null;enqueue(e){this._logger.debug("Enqueueing intent",{data:{type:e.type}});let r=new fw.Subject,i={intent:e,subject:r,isCancelled:!1};this._queue.push(i);let n=()=>{this._logger.debug("Cancelling intent",{data:{type:e.type}}),i.isCancelled=!0,this._queue[0]===i&&this._currentSubscription?(this._currentSubscription.unsubscribe(),this._currentSubscription=null,r.complete(),this._queue.shift(),this._isProcessing=!1,this._processQueue()):(!this._isProcessing||this._queue[0]!==i)&&r.complete()};return this._isProcessing||this._processQueue(),{observable:r.asObservable().pipe((0,fw.finalize)(()=>{this._logger.debug("Intent observable finalized",{data:{type:e.type}})})),cancel:n}}_processQueue(){if(this._isProcessing)return;if(this._queue.length===0){this.sessionEventDispatcher.dispatch({eventName:vw.SessionEvents.NEW_STATE});return}this.sessionEventDispatcher.dispatch({eventName:vw.SessionEvents.DEVICE_STATE_UPDATE_BUSY}),this._isProcessing=!0;let e=this._queue[0];if(e.isCancelled){this._logger.debug("Skipping cancelled intent",{data:{type:e.intent.type}}),e.subject.complete(),this._queue.shift(),this._isProcessing=!1,this._processQueue();return}this._logger.debug("Processing intent",{data:{type:e.intent.type}}),this._currentSubscription=e.intent.execute().subscribe({next:r=>{e.isCancelled||e.subject.next(r)},error:r=>{e.isCancelled||e.subject.error(r),this._onIntentComplete()},complete:()=>{e.isCancelled||e.subject.complete(),this._onIntentComplete()}})}_onIntentComplete(){this._logger.debug("Intent completed"),this._currentSubscription=null,this._queue.shift(),this._isProcessing=!1,this._processQueue()}}});var _w=a((Uve,bw)=>{"use strict";var og=Object.defineProperty,GX=Object.getOwnPropertyDescriptor,HX=Object.getOwnPropertyNames,WX=Object.prototype.hasOwnProperty,KX=(t,e)=>{for(var r in e)og(t,r,{get:e[r],enumerable:!0})},$X=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of HX(e))!WX.call(t,n)&&n!==r&&og(t,n,{get:()=>e[n],enumerable:!(i=GX(e,n))||i.enumerable});return t},zX=t=>$X(og({},"__esModule",{value:!0}),t),yw={};KX(yw,{RefresherService:()=>ig});bw.exports=zX(yw);var JX=dn(),ig=class{constructor(e,r){this._refresher=r,this._logger=e("refresher-service")}_refresherBlockers=new Set;_logger;disableRefresher(e){let r=`${e}-${(0,JX.v4)()}`;this.addRefresherBlocker(r),this._logger.debug("Refresher disabled",{data:{blockerId:r,blockers:Array.from(this._refresherBlockers)}});let i=!1;return()=>{i||(i=!0,this.removeRefresherBlocker(r),this._logger.debug("Refresher re-enabled",{data:{blockerId:r,blockers:Array.from(this._refresherBlockers)}}))}}addRefresherBlocker(e){let r=this._refresherBlockers.size;this._refresherBlockers.add(e),r===0&&this._refresher.stop()}removeRefresherBlocker(e){let r=this._refresherBlockers.size;this._refresherBlockers.delete(e),r>0&&this._refresherBlockers.size===0&&this._refresher.start()}}});var Ow=a((Bve,Dw)=>{"use strict";var ug=Object.defineProperty,XX=Object.getOwnPropertyDescriptor,QX=Object.getOwnPropertyNames,YX=Object.prototype.hasOwnProperty,ZX=(t,e)=>{for(var r in e)ug(t,r,{get:e[r],enumerable:!0})},eQ=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of QX(e))!YX.call(t,n)&&n!==r&&ug(t,n,{get:()=>e[n],enumerable:!(i=XX(e,n))||i.enumerable});return t},tQ=t=>eQ(ug({},"__esModule",{value:!0}),t),Sw={};ZX(Sw,{DevicePinger:()=>cg});Dw.exports=tQ(Sw);var rQ=Ye(),sg=pn(),ag=Rf(),nQ=zo(),Jo=Ar(),cg=class{constructor(e,r,i,n){this.connectedDevice=r,this._sessionEventDispatcher=i,this._sendCommandFunction=n,this._logger=e("device-pinger"),this._subscription=this._sessionEventDispatcher.listen().subscribe(async o=>await this.mapEventAction(o))}_sendCommandFunction;_subscription;_logger;async ping(){try{return await this.mapDevicePingAction(this.connectedDevice.deviceModel.id)}catch(e){return this._logger.error("Error while pinging device",{data:{error:e}}),null}}mapEventAction=async e=>{switch(e.eventName){case Jo.SessionEvents.REFRESH_NEEDED:return await this.ping();default:return null}};async mapDevicePingAction(e){switch(e){case rQ.DeviceModelId.NANO_S:{let r=async()=>{let o=await this._sendCommandFunction(new sg.GetAppAndVersionCommand,ag.PINGER_TIMEOUT);return this._sendCommandFunction(new sg.GetOsVersionCommand,ag.PINGER_TIMEOUT),o},i=new Promise(o=>{setTimeout(()=>o(null),nQ.DEVICE_SESSION_REFRESHER_POLLING_INTERVAL*2+100)}),n=await Promise.race([r(),i]);return n?this._sessionEventDispatcher.dispatch({eventName:Jo.SessionEvents.COMMAND_SUCCEEDED,eventData:n}):this._sessionEventDispatcher.dispatch({eventName:Jo.SessionEvents.DEVICE_STATE_UPDATE_LOCKED}),n}default:{let r=await this._sendCommandFunction(new sg.GetAppAndVersionCommand,ag.PINGER_TIMEOUT);return this._sessionEventDispatcher.dispatch({eventName:Jo.SessionEvents.COMMAND_SUCCEEDED,eventData:r}),r}}}unsubscribe(){this._subscription.unsubscribe()}}});var Aw=a((Lve,Cw)=>{"use strict";var lg=Object.defineProperty,iQ=Object.getOwnPropertyDescriptor,oQ=Object.getOwnPropertyNames,sQ=Object.prototype.hasOwnProperty,aQ=(t,e)=>{for(var r in e)lg(t,r,{get:e[r],enumerable:!0})},cQ=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of oQ(e))!sQ.call(t,n)&&n!==r&&lg(t,n,{get:()=>e[n],enumerable:!(i=iQ(e,n))||i.enumerable});return t},uQ=t=>cQ(lg({},"__esModule",{value:!0}),t),Ew={};aQ(Ew,{DeviceSessionRefresher:()=>dg});Cw.exports=uQ(Ew);var at=De(),dQ=Ye(),gn=zo(),Xo=Ar(),dg=class{constructor(e,r,i,n){this._sessionEventDispatcher=i,this._refresherOptions=r,this._logger=e("device-session-refresher"),this._connectedDeviceID=n.deviceModel.id}_refresherSubscription;_refresherOptions;_logger;_connectedDeviceID;startRefresher(){if(this._refresherOptions.isRefresherDisabled||this._refresherSubscription)return;let e=this.getValidPollingInterval(this._refresherOptions,this._logger)*2,r=this._sessionEventDispatcher.listen().pipe((0,at.filter)(i=>i.eventName===Xo.SessionEvents.DEVICE_STATE_UPDATE_BUSY||i.eventName===Xo.SessionEvents.NEW_STATE),(0,at.map)(i=>i.eventName===Xo.SessionEvents.DEVICE_STATE_UPDATE_BUSY),(0,at.startWith)(!1),(0,at.distinctUntilChanged)());this._refresherSubscription=(0,at.timer)(0,e).pipe((0,at.withLatestFrom)(r),(0,at.tap)(([i,n])=>{n&&this._logger.debug("Refresh skipped: device is busy")}),(0,at.filter)(([i,n])=>!n),(0,at.tap)(()=>this._sessionEventDispatcher.dispatch({eventName:Xo.SessionEvents.REFRESH_NEEDED}))).subscribe(),this._logger.info("Refresher started.")}stopRefresher(){this._refresherSubscription&&(this._refresherSubscription.unsubscribe(),this._refresherSubscription=void 0,this._logger.info("Refresher stopped."))}restartRefresher(){this.stopRefresher(),this.startRefresher(),this._logger.info("Refresher restarted.")}getValidPollingInterval=(e,r)=>{let{pollingInterval:i}=e;switch(this._connectedDeviceID){case dQ.DeviceModelId.NANO_S:{let n=gn.DEVICE_SESSION_REFRESHER_POLLING_INTERVAL*2;return i!==void 0&&i<n?(r.warn(`Polling interval of ${i} is too low, setting to minimum as ${n}`),n):i??n}default:return i!==void 0&&i<gn.DEVICE_SESSION_REFRESHER_MINIMUM_POLLING_INTERVAL?(r.warn(`Polling interval of ${i} is too low, setting to minimum as ${gn.DEVICE_SESSION_REFRESHER_MINIMUM_POLLING_INTERVAL}`),gn.DEVICE_SESSION_REFRESHER_MINIMUM_POLLING_INTERVAL):i??gn.DEVICE_SESSION_REFRESHER_POLLING_INTERVAL}}}});var Pw=a((Fve,Iw)=>{"use strict";var fg=Object.defineProperty,lQ=Object.getOwnPropertyDescriptor,pQ=Object.getOwnPropertyNames,fQ=Object.prototype.hasOwnProperty,vQ=(t,e)=>{for(var r in e)fg(t,r,{get:e[r],enumerable:!0})},gQ=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of pQ(e))!fQ.call(t,n)&&n!==r&&fg(t,n,{get:()=>e[n],enumerable:!(i=lQ(e,n))||i.enumerable});return t},hQ=t=>gQ(fg({},"__esModule",{value:!0}),t),ww={};vQ(ww,{DeviceSessionStateHandler:()=>pg});Iw.exports=hQ(ww);var Ke=pn(),Xt=Ar(),pg=class{constructor(e,r,i,n,o){this._sessionEventDispatcher=r,this._connectedDevice=i,this._deviceState=n,this.setDeviceSessionState=o,this._subscription=this._sessionEventDispatcher.listen().subscribe(s=>this.mapEventAction(s)),this._logger=e("device-session-state-handler")}_subscription;_logger;_pendingDeviceStatus=Ke.DeviceStatus.BUSY;_updateDeviceState(e){let r=this._parseDeviceStatus(e);if(r){let{sessionStateType:i,deviceStatus:n,currentApp:o}=r,s=this._deviceState.getValue();s.sessionStateType===Ke.DeviceSessionStateType.Connected?this.setDeviceSessionState({sessionStateType:i,deviceStatus:n,deviceModelId:this._connectedDevice.deviceModel.id,currentApp:o,installedApps:[],isSecureConnectionAllowed:!1}):this.setDeviceSessionState({...s,sessionStateType:i,deviceStatus:n,deviceModelId:this._connectedDevice.deviceModel.id,currentApp:o})}}mapEventAction=e=>{let{eventName:r}=e;switch(r){case Xt.SessionEvents.COMMAND_SUCCEEDED:return this._updateDeviceState(e.eventData);case Xt.SessionEvents.DEVICE_STATE_UPDATE_BUSY:return this.setDeviceSessionState({...this._deviceState.getValue(),deviceStatus:Ke.DeviceStatus.BUSY});case Xt.SessionEvents.DEVICE_STATE_UPDATE_LOCKED:this._pendingDeviceStatus=Ke.DeviceStatus.LOCKED;return;case Xt.SessionEvents.DEVICE_STATE_UPDATE_CONNECTED:this._pendingDeviceStatus=Ke.DeviceStatus.CONNECTED;return;case Xt.SessionEvents.NEW_STATE:{let i=this._pendingDeviceStatus;return this._pendingDeviceStatus=Ke.DeviceStatus.BUSY,this.setDeviceSessionState({...this._deviceState.getValue(),deviceStatus:i})}case Xt.SessionEvents.DEVICE_STATE_UPDATE_UNKNOWN:return this.setDeviceSessionState({...this._deviceState.getValue(),deviceStatus:Ke.DeviceStatus.BUSY});case Xt.SessionEvents.REFRESH_NEEDED:return;default:{let i=r;throw new Error(`Unhandled context type ${i}`)}}};_parseDeviceStatus(e){return(0,Ke.isSuccessCommandResult)(e)?{sessionStateType:Ke.DeviceSessionStateType.ReadyWithoutSecureChannel,deviceStatus:Ke.DeviceStatus.CONNECTED,currentApp:{name:e.data.name,version:e.data.version}}:(this._logger.debug("Error while parsing APDU response",{data:{parsedResponse:e}}),null)}unsubscribe(){this._subscription.unsubscribe()}}});var hg=a((kve,qw)=>{"use strict";var gg=Object.defineProperty,mQ=Object.getOwnPropertyDescriptor,yQ=Object.getOwnPropertyNames,bQ=Object.prototype.hasOwnProperty,_Q=(t,e)=>{for(var r in e)gg(t,r,{get:e[r],enumerable:!0})},SQ=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of yQ(e))!bQ.call(t,n)&&n!==r&&gg(t,n,{get:()=>e[n],enumerable:!(i=mQ(e,n))||i.enumerable});return t},DQ=t=>SQ(gg({},"__esModule",{value:!0}),t),jw={};_Q(jw,{DeviceSession:()=>vg});qw.exports=DQ(jw);var Qt=De(),OQ=dn(),EQ=ye(),xw=zn(),CQ=ne(),Mw=tt(),Tw=Yv(),AQ=zo(),wQ=mw(),IQ=_w(),PQ=Ow(),Qo=Ar(),xQ=Aw(),MQ=Pw(),vg=class{_id;_connectedDevice;_deviceState;_managerApiService;_secureChannelService;_logger;_loggerModuleFactory;_refresherOptions;_pinger;_deviceSessionRefresher;_refresherService;_intentQueueService;_sessionEventDispatcher=new Qo.DeviceSessionEventDispatcher;_bypassIntentQueue=!1;constructor({connectedDevice:e,id:r=(0,OQ.v4)()},i,n,o,s,l=u=>new wQ.IntentQueueService(i,u)){this._id=r,this._connectedDevice=e,this._loggerModuleFactory=i,this._logger=i("device-session"),this._managerApiService=n,this._intentQueueService=l(this._sessionEventDispatcher),this._secureChannelService=o,this._refresherOptions={...AQ.DEVICE_SESSION_REFRESHER_DEFAULT_OPTIONS,...s},this._deviceState=new Qt.BehaviorSubject({sessionStateType:CQ.DeviceSessionStateType.Connected,deviceStatus:xw.DeviceStatus.CONNECTED,deviceModelId:this._connectedDevice.deviceModel.id}),this._pinger=new PQ.DevicePinger(i,e,this._sessionEventDispatcher,(u,d)=>this.sendCommand(u,d)),this._deviceSessionRefresher=new xQ.DeviceSessionRefresher(i,this._refresherOptions,this._sessionEventDispatcher,this._connectedDevice),new MQ.DeviceSessionStateHandler(i,this._sessionEventDispatcher,this._connectedDevice,this._deviceState,u=>this.setDeviceSessionState(u)),this._refresherService=new IQ.RefresherService(i,{start:()=>this._deviceSessionRefresher.restartRefresher(),stop:()=>this._deviceSessionRefresher.stopRefresher()})}async initialiseSession(){try{this._refresherOptions.isRefresherDisabled?await this._pinger.ping():this._deviceSessionRefresher.startRefresher()}catch(e){throw this._logger.error("Error while initialising session",{data:{error:e}}),e}}get id(){return this._id}get connectedDevice(){return this._connectedDevice}get state(){return this._deviceState.asObservable()}getDeviceSessionState(){return this._deviceState.getValue()}setDeviceSessionState(e){this._deviceState.next(e)}sendApdu(e,r={isPolling:!1,triggersDisconnection:!1,abortTimeout:void 0}){return this._bypassIntentQueue?this._unsafeInternalSendApdu(e,r):this._internalSendApdu(e,r)}_internalSendApdu(e,r){let i=r.abortTimeout,n=Date.now(),{observable:o,cancel:s}=this._intentQueueService.enqueue({type:"send-apdu",execute:()=>(0,Qt.from)((async()=>{let u=Date.now()-n;return await this._unsafeInternalSendApdu(e,{isPolling:r.isPolling,triggersDisconnection:r.triggersDisconnection,abortTimeout:i?i-u:void 0})})())}),l=i?o.pipe((0,Qt.timeout)({each:i,with:()=>{throw s(),new Mw.SendApduTimeoutError}})):o;return(0,Qt.lastValueFrom)(l)}async _unsafeInternalSendApdu(e,r={isPolling:!1,triggersDisconnection:!1,abortTimeout:void 0}){return this._logger.debug((0,Tw.formatApduSendingLog)(e)),(await this._connectedDevice.sendApdu(e,r.triggersDisconnection,r.abortTimeout)).ifRight(i=>{this._logger.debug((0,Tw.formatApduReceivedLog)(i)),EQ.CommandUtils.isLockedDeviceResponse(i)?this._sessionEventDispatcher.dispatch({eventName:Qo.SessionEvents.DEVICE_STATE_UPDATE_LOCKED}):this._sessionEventDispatcher.dispatch({eventName:Qo.SessionEvents.DEVICE_STATE_UPDATE_CONNECTED})}).ifLeft(()=>{this._sessionEventDispatcher.dispatch({eventName:Qo.SessionEvents.DEVICE_STATE_UPDATE_UNKNOWN})})}sendCommand(e,r){return this._logger.debug(`[sendCommand] ${e.name}`),this._bypassIntentQueue?this._unsafeInternalSendCommand(e,r):this._internalSendCommand(e,r)}_internalSendCommand(e,r){let i=Date.now(),{observable:n,cancel:o}=this._intentQueueService.enqueue({type:"send-command",execute:()=>(0,Qt.from)((async()=>{let l=Date.now()-i;return await this._unsafeInternalSendCommand(e,r?r-l:void 0)})())}),s=r?n.pipe((0,Qt.timeout)({each:r,with:()=>{throw o(),new Mw.SendCommandTimeoutError}})):n;return(0,Qt.lastValueFrom)(s)}async _unsafeInternalSendCommand(e,r){let i=e.getApdu();return(await this._unsafeInternalSendApdu(i.getRawApdu(),{isPolling:!1,triggersDisconnection:e.triggersDisconnection??!1,abortTimeout:r})).caseOf({Left:n=>{throw this._logger.error("[sendCommand] error",{data:{err:n}}),n},Right:n=>{let o=e.parseResponse(n,this._connectedDevice.deviceModel.id);return this._logger.debug("[sendCommand] result",{data:{result:o}}),o}})}executeDeviceAction(e){return this._bypassIntentQueue?this._unsafeInternalExecuteDeviceAction(e):this._internalExecuteDeviceAction(e)}_internalExecuteDeviceAction(e){let r,{observable:i,cancel:n}=this._intentQueueService.enqueue({type:"device-action",execute:()=>{let{observable:o,cancel:s}=this._unsafeInternalExecuteDeviceAction(e);return r=s,o}});return{observable:i,cancel:()=>{r?.(),n()}}}_unsafeInternalExecuteDeviceAction(e){let{observable:r,cancel:i}=e._execute({sendApdu:async n=>this._unsafeInternalSendApdu(n),sendCommand:async n=>this._unsafeInternalSendCommand(n),getDeviceModel:()=>this._connectedDevice.deviceModel,getDeviceSessionState:()=>this._deviceState.getValue(),getDeviceSessionStateObservable:()=>this.state,setDeviceSessionState:n=>(this.setDeviceSessionState(n),this._deviceState.getValue()),getManagerApiService:()=>this._managerApiService,getSecureChannelService:()=>this._secureChannelService,loggerFactory:this._loggerModuleFactory});return{observable:r,cancel:i}}close(){this._updateDeviceStatus(xw.DeviceStatus.NOT_CONNECTED),this._deviceState.complete(),this._deviceSessionRefresher.stopRefresher(),this._pinger.unsubscribe()}disableRefresher(e){return this._refresherService.disableRefresher(e)}_unsafeBypassIntentQueue(e){this._bypassIntentQueue=e}_updateDeviceStatus(e){let r=this._deviceState.getValue();this._deviceState.next({...r,deviceStatus:e})}}});var hn=a((Vve,Nw)=>{"use strict";var mg=Object.defineProperty,TQ=Object.getOwnPropertyDescriptor,jQ=Object.getOwnPropertyNames,qQ=Object.prototype.hasOwnProperty,RQ=(t,e)=>{for(var r in e)mg(t,r,{get:e[r],enumerable:!0})},NQ=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of jQ(e))!qQ.call(t,n)&&n!==r&&mg(t,n,{get:()=>e[n],enumerable:!(i=TQ(e,n))||i.enumerable});return t},UQ=t=>NQ(mg({},"__esModule",{value:!0}),t),Rw={};RQ(Rw,{secureChannelTypes:()=>BQ});Nw.exports=UQ(Rw);var BQ={SecureChannelService:Symbol.for("SecureChannelService"),SecureChannelDataSource:Symbol.for("SecureChannelDataSource"),DmkConfig:Symbol.for("SecureChannelDmkConfig")}});var Fw=a((Gve,Lw)=>{"use strict";var Yo=Object.defineProperty,Uw=Object.getOwnPropertyDescriptor,LQ=Object.getOwnPropertyNames,FQ=Object.prototype.hasOwnProperty,kQ=(t,e)=>{for(var r in e)Yo(t,r,{get:e[r],enumerable:!0})},VQ=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of LQ(e))!FQ.call(t,n)&&n!==r&&Yo(t,n,{get:()=>e[n],enumerable:!(i=Uw(e,n))||i.enumerable});return t},GQ=t=>VQ(Yo({},"__esModule",{value:!0}),t),HQ=(t,e,r,i)=>{for(var n=i>1?void 0:i?Uw(e,r):e,o=t.length-1,s;o>=0;o--)(s=t[o])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&Yo(e,r,n),n},mn=(t,e)=>(r,i)=>e(r,i,t),Bw={};kQ(Bw,{ConnectUseCase:()=>yg});Lw.exports=GQ(Bw);var wr=h(),WQ=b(),KQ=tt(),$Q=K(),zQ=hg(),JQ=P(),XQ=$t(),QQ=hn(),YQ=He(),yg=class{_transportService;_sessionService;_loggerFactory;_managerApi;_secureChannel;_logger;constructor(t,e,r,i,n){this._sessionService=e,this._transportService=t,this._loggerFactory=r,this._logger=r("ConnectUseCase"),this._managerApi=i,this._secureChannel=n}handleDeviceDisconnect(t){this._sessionService.getDeviceSessionsByDeviceId(t).ifRight(e=>{e.forEach(r=>{this._sessionService.removeDeviceSession(r.id),this._logger.info("Session removed",{data:{deviceId:t,sessionId:r.id}})})})}async execute({device:t,sessionRefresherOptions:e}){let r=this._transportService.getTransport(t.transport),i="sessionId"in t?t.sessionId:void 0;return WQ.EitherAsync.liftEither(r.toEither(new KQ.TransportNotSupportedError(new Error("Unknown transport")))).chain(async n=>n.connect({deviceId:t.id,onDisconnect:o=>this.handleDeviceDisconnect(o)})).ifLeft(n=>{this._logger.error("Error connecting to device")}).map(async n=>{let o=new zQ.DeviceSession({connectedDevice:n,id:i},this._loggerFactory,this._managerApi,this._secureChannel,e);return this._sessionService.addDeviceSession(o),await o.initialiseSession(),o.id}).caseOf({Left:n=>{throw n},Right:n=>n})}};yg=HQ([(0,wr.injectable)(),mn(0,(0,wr.inject)(YQ.transportDiTypes.TransportService)),mn(1,(0,wr.inject)($Q.deviceSessionTypes.DeviceSessionService)),mn(2,(0,wr.inject)(JQ.loggerTypes.LoggerPublisherServiceFactory)),mn(3,(0,wr.inject)(XQ.managerApiTypes.ManagerApiService)),mn(4,(0,wr.inject)(QQ.secureChannelTypes.SecureChannelService))],yg)});var Hw=a((Wve,Gw)=>{"use strict";var es=Object.defineProperty,kw=Object.getOwnPropertyDescriptor,ZQ=Object.getOwnPropertyNames,eY=Object.prototype.hasOwnProperty,tY=(t,e)=>{for(var r in e)es(t,r,{get:e[r],enumerable:!0})},rY=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of ZQ(e))!eY.call(t,n)&&n!==r&&es(t,n,{get:()=>e[n],enumerable:!(i=kw(e,n))||i.enumerable});return t},nY=t=>rY(es({},"__esModule",{value:!0}),t),iY=(t,e,r,i)=>{for(var n=i>1?void 0:i?kw(e,r):e,o=t.length-1,s;o>=0;o--)(s=t[o])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&es(e,r,n),n},bg=(t,e)=>(r,i)=>e(r,i,t),Vw={};tY(Vw,{DisconnectUseCase:()=>_g});Gw.exports=nY(Vw);var Zo=h(),oY=b(),sY=tt(),aY=K(),cY=P(),uY=He(),_g=class{_transportService;_sessionService;_logger;constructor(t,e,r){this._sessionService=e,this._transportService=t,this._logger=r("DisconnectUseCase")}async execute({sessionId:t}){return this._logger.debug("Disconnecting from device",{data:{test:this._sessionService.getDeviceSessions().map(e=>e.id)}}),(0,oY.EitherAsync)(async({liftEither:e})=>{let r=await e(this._sessionService.getDeviceSessionById(t).ifLeft(o=>{this._logger.error("Device session not found",{data:{sessionId:t,error:o}})})),i=r.connectedDevice.transport,n=await e(this._transportService.getTransport(i).toEither(new sY.TransportNotSupportedError(new Error("Unknown transport"))));r.close(),this._sessionService.removeDeviceSession(t),await n.disconnect({connectedDevice:r.connectedDevice})}).caseOf({Left:e=>{throw this._logger.error("Error disconnecting from device",{data:{error:e}}),e},Right:()=>{}})}};_g=iY([(0,Zo.injectable)(),bg(0,(0,Zo.inject)(uY.transportDiTypes.TransportService)),bg(1,(0,Zo.inject)(aY.deviceSessionTypes.DeviceSessionService)),bg(2,(0,Zo.inject)(cY.loggerTypes.LoggerPublisherServiceFactory))],_g)});var yn=a(($ve,Kw)=>{"use strict";var Dg=Object.defineProperty,dY=Object.getOwnPropertyDescriptor,lY=Object.getOwnPropertyNames,pY=Object.prototype.hasOwnProperty,fY=(t,e)=>{for(var r in e)Dg(t,r,{get:e[r],enumerable:!0})},vY=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of lY(e))!pY.call(t,n)&&n!==r&&Dg(t,n,{get:()=>e[n],enumerable:!(i=dY(e,n))||i.enumerable});return t},gY=t=>vY(Dg({},"__esModule",{value:!0}),t),Ww={};fY(Ww,{ConnectedDevice:()=>Sg});Kw.exports=gY(Ww);var Sg=class{id;sessionId;modelId;name;type;transport;constructor({transportConnectedDevice:{id:e,deviceModel:{id:r,productName:i},type:n,transport:o,name:s},sessionId:l}){this.id=e,this.sessionId=l,this.modelId=r,this.name=s??i,this.type=n,this.transport=o}}});var Qw=a((zve,Xw)=>{"use strict";var ts=Object.defineProperty,zw=Object.getOwnPropertyDescriptor,hY=Object.getOwnPropertyNames,mY=Object.prototype.hasOwnProperty,yY=(t,e)=>{for(var r in e)ts(t,r,{get:e[r],enumerable:!0})},bY=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of hY(e))!mY.call(t,n)&&n!==r&&ts(t,n,{get:()=>e[n],enumerable:!(i=zw(e,n))||i.enumerable});return t},_Y=t=>bY(ts({},"__esModule",{value:!0}),t),SY=(t,e,r,i)=>{for(var n=i>1?void 0:i?zw(e,r):e,o=t.length-1,s;o>=0;o--)(s=t[o])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&ts(e,r,n),n},$w=(t,e)=>(r,i)=>e(r,i,t),Jw={};yY(Jw,{GetConnectedDeviceUseCase:()=>Eg});Xw.exports=_Y(Jw);var Og=h(),DY=yn(),OY=K(),EY=P(),Eg=class{_sessionService;_logger;constructor(t,e){this._sessionService=t,this._logger=e("GetConnectedDeviceUseCase")}execute({sessionId:t}){return this._sessionService.getDeviceSessionById(t).caseOf({Right:e=>new DY.ConnectedDevice({sessionId:e.id,transportConnectedDevice:e.connectedDevice}),Left:e=>{throw this._logger.error("Error getting session",{data:{error:e}}),e}})}};Eg=SY([(0,Og.injectable)(),$w(0,(0,Og.inject)(OY.deviceSessionTypes.DeviceSessionService)),$w(1,(0,Og.inject)(EY.loggerTypes.LoggerPublisherServiceFactory))],Eg)});var rI=a((Xve,tI)=>{"use strict";var rs=Object.defineProperty,Zw=Object.getOwnPropertyDescriptor,CY=Object.getOwnPropertyNames,AY=Object.prototype.hasOwnProperty,wY=(t,e)=>{for(var r in e)rs(t,r,{get:e[r],enumerable:!0})},IY=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of CY(e))!AY.call(t,n)&&n!==r&&rs(t,n,{get:()=>e[n],enumerable:!(i=Zw(e,n))||i.enumerable});return t},PY=t=>IY(rs({},"__esModule",{value:!0}),t),xY=(t,e,r,i)=>{for(var n=i>1?void 0:i?Zw(e,r):e,o=t.length-1,s;o>=0;o--)(s=t[o])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&rs(e,r,n),n},Yw=(t,e)=>(r,i)=>e(r,i,t),eI={};wY(eI,{ListConnectedDevicesUseCase:()=>Ag});tI.exports=PY(eI);var Cg=h(),MY=yn(),TY=K(),jY=P(),Ag=class{_sessionService;_logger;constructor(t,e){this._sessionService=t,this._logger=e("ListConnectedDeviceUseCase")}execute(){return this._logger.info("Listing connected devices"),this._sessionService.getDeviceSessions().map(t=>new MY.ConnectedDevice({transportConnectedDevice:t.connectedDevice,sessionId:t.id}))}};Ag=xY([(0,Cg.injectable)(),Yw(0,(0,Cg.inject)(TY.deviceSessionTypes.DeviceSessionService)),Yw(1,(0,Cg.inject)(jY.loggerTypes.LoggerPublisherServiceFactory))],Ag)});var aI=a((Yve,sI)=>{"use strict";var ns=Object.defineProperty,iI=Object.getOwnPropertyDescriptor,qY=Object.getOwnPropertyNames,RY=Object.prototype.hasOwnProperty,NY=(t,e)=>{for(var r in e)ns(t,r,{get:e[r],enumerable:!0})},UY=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of qY(e))!RY.call(t,n)&&n!==r&&ns(t,n,{get:()=>e[n],enumerable:!(i=iI(e,n))||i.enumerable});return t},BY=t=>UY(ns({},"__esModule",{value:!0}),t),LY=(t,e,r,i)=>{for(var n=i>1?void 0:i?iI(e,r):e,o=t.length-1,s;o>=0;o--)(s=t[o])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&ns(e,r,n),n},nI=(t,e)=>(r,i)=>e(r,i,t),oI={};NY(oI,{ListenToAvailableDevicesUseCase:()=>Ig});sI.exports=BY(oI);var wg=h(),Yt=De(),FY=Ye(),kY=P(),VY=He(),Ig=class{_transports;_transportService;_logger;constructor(t,e){this._transports=t.getAllTransports(),this._transportService=t,this._logger=e("ListenToAvailableDevicesUseCase")}mapTransportDiscoveredDeviceToDiscoveredDevice(t){let e=new FY.DeviceModel({id:t.id,model:t.deviceModel.id,name:t.deviceModel.productName});return{id:t.id,deviceModel:e,transport:t.transport,name:t.name||e.name,rssi:t.rssi}}execute({transport:t}={}){if(this._logger.info("Listening to available devices"),this._transports.length===0)return this._logger.warn("No transports available"),(0,Yt.from)([[]]);if(!t){this._logger.info("Discovering all available transports");let e=this._transports.map((r,i)=>r.listenToAvailableDevices().pipe((0,Yt.map)(n=>({index:i,arr:n}))));return(0,Yt.merge)(...e).pipe((0,Yt.scan)((r,{index:i,arr:n})=>(r[i]=n,r),{}),(0,Yt.map)(r=>Object.values(r).flat().map(this.mapTransportDiscoveredDeviceToDiscoveredDevice)))}return this._logger.info(`Discovering devices on transport ${t}`),this._transportService.getTransport(t).caseOf({Nothing:()=>(this._logger.error(`Transport ${t} not found`),(0,Yt.of)([])),Just:e=>e.listenToAvailableDevices().pipe((0,Yt.map)(r=>r.map(this.mapTransportDiscoveredDeviceToDiscoveredDevice)))})}};Ig=LY([(0,wg.injectable)(),nI(0,(0,wg.inject)(VY.transportDiTypes.TransportService)),nI(1,(0,wg.inject)(kY.loggerTypes.LoggerPublisherServiceFactory))],Ig)});var pI=a((ege,lI)=>{"use strict";var is=Object.defineProperty,uI=Object.getOwnPropertyDescriptor,GY=Object.getOwnPropertyNames,HY=Object.prototype.hasOwnProperty,WY=(t,e)=>{for(var r in e)is(t,r,{get:e[r],enumerable:!0})},KY=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of GY(e))!HY.call(t,n)&&n!==r&&is(t,n,{get:()=>e[n],enumerable:!(i=uI(e,n))||i.enumerable});return t},$Y=t=>KY(is({},"__esModule",{value:!0}),t),zY=(t,e,r,i)=>{for(var n=i>1?void 0:i?uI(e,r):e,o=t.length-1,s;o>=0;o--)(s=t[o])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&is(e,r,n),n},cI=(t,e)=>(r,i)=>e(r,i,t),dI={};WY(dI,{ListenToConnectedDeviceUseCase:()=>xg});lI.exports=$Y(dI);var Pg=h(),JY=De(),XY=yn(),QY=K(),YY=P(),xg=class{constructor(t,e){this._sessionService=t,this._logger=e("ListenToConnectedDeviceUseCase")}_logger;execute(){return this._logger.info("Observe connected devices"),this._sessionService.sessionsObs.pipe((0,JY.map)(t=>new XY.ConnectedDevice({transportConnectedDevice:t.connectedDevice,sessionId:t.id})))}};xg=zY([(0,Pg.injectable)(),cI(0,(0,Pg.inject)(QY.deviceSessionTypes.DeviceSessionService)),cI(1,(0,Pg.inject)(YY.loggerTypes.LoggerPublisherServiceFactory))],xg)});var mI=a((rge,hI)=>{"use strict";var ss=Object.defineProperty,vI=Object.getOwnPropertyDescriptor,ZY=Object.getOwnPropertyNames,eZ=Object.prototype.hasOwnProperty,tZ=(t,e)=>{for(var r in e)ss(t,r,{get:e[r],enumerable:!0})},rZ=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of ZY(e))!eZ.call(t,n)&&n!==r&&ss(t,n,{get:()=>e[n],enumerable:!(i=vI(e,n))||i.enumerable});return t},nZ=t=>rZ(ss({},"__esModule",{value:!0}),t),iZ=(t,e,r,i)=>{for(var n=i>1?void 0:i?vI(e,r):e,o=t.length-1,s;o>=0;o--)(s=t[o])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&ss(e,r,n),n},Mg=(t,e)=>(r,i)=>e(r,i,t),gI={};tZ(gI,{ReconnectUseCase:()=>Tg});hI.exports=nZ(gI);var os=h(),fI=Mo(),oZ=P(),Tg=class{constructor(t,e,r){this.connectUseCase=t,this.disconnectUseCase=e,this._logger=r("ReconnectUseCase")}_logger;async execute({device:t,sessionRefresherOptions:e}){return this._logger.debug("Reconnecting device session",{data:{deviceId:t.id,transport:t.transport}}),await this.disconnectUseCase.execute({sessionId:t.sessionId}),this.connectUseCase.execute({device:t,sessionRefresherOptions:e})}};Tg=iZ([(0,os.injectable)(),Mg(0,(0,os.inject)(fI.discoveryTypes.ConnectUseCase)),Mg(1,(0,os.inject)(fI.discoveryTypes.DisconnectUseCase)),Mg(2,(0,os.inject)(oZ.loggerTypes.LoggerPublisherServiceFactory))],Tg)});var DI=a((ige,SI)=>{"use strict";var cs=Object.defineProperty,bI=Object.getOwnPropertyDescriptor,sZ=Object.getOwnPropertyNames,aZ=Object.prototype.hasOwnProperty,cZ=(t,e)=>{for(var r in e)cs(t,r,{get:e[r],enumerable:!0})},uZ=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of sZ(e))!aZ.call(t,n)&&n!==r&&cs(t,n,{get:()=>e[n],enumerable:!(i=bI(e,n))||i.enumerable});return t},dZ=t=>uZ(cs({},"__esModule",{value:!0}),t),lZ=(t,e,r,i)=>{for(var n=i>1?void 0:i?bI(e,r):e,o=t.length-1,s;o>=0;o--)(s=t[o])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&cs(e,r,n),n},pZ=(t,e)=>(r,i)=>e(r,i,t),_I={};cZ(_I,{StartDiscoveringUseCase:()=>jg});SI.exports=dZ(_I);var yI=h(),as=De(),fZ=Ye(),vZ=tt(),gZ=He(),jg=class{constructor(t){this._transportService=t}mapDiscoveredDevice(t){let e=new fZ.DeviceModel({id:t.id,model:t.deviceModel.id,name:t.deviceModel.productName});return{id:t.id,deviceModel:e,transport:t.transport,name:t.name||e.name,rssi:t.rssi}}execute({transport:t}={}){if(!t){let e=this._transportService.getAllTransports();return(0,as.of)(...e).pipe((0,as.mergeMap)(r=>r.startDiscovering().pipe((0,as.map)(i=>this.mapDiscoveredDevice(i)))))}return this._transportService.getTransport(t).caseOf({Just:e=>e.startDiscovering().pipe((0,as.map)(r=>this.mapDiscoveredDevice(r))),Nothing:()=>{throw new vZ.TransportNotSupportedError(new Error("Unknown transport"))}})}};jg=lZ([(0,yI.injectable)(),pZ(0,(0,yI.inject)(gZ.transportDiTypes.TransportService))],jg)});var wI=a((sge,AI)=>{"use strict";var us=Object.defineProperty,EI=Object.getOwnPropertyDescriptor,hZ=Object.getOwnPropertyNames,mZ=Object.prototype.hasOwnProperty,yZ=(t,e)=>{for(var r in e)us(t,r,{get:e[r],enumerable:!0})},bZ=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of hZ(e))!mZ.call(t,n)&&n!==r&&us(t,n,{get:()=>e[n],enumerable:!(i=EI(e,n))||i.enumerable});return t},_Z=t=>bZ(us({},"__esModule",{value:!0}),t),SZ=(t,e,r,i)=>{for(var n=i>1?void 0:i?EI(e,r):e,o=t.length-1,s;o>=0;o--)(s=t[o])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&us(e,r,n),n},OI=(t,e)=>(r,i)=>e(r,i,t),CI={};yZ(CI,{StopDiscoveringUseCase:()=>Rg});AI.exports=_Z(CI);var qg=h(),DZ=P(),OZ=He(),Rg=class{constructor(t,e){this.transportService=t,this._logger=e("StopDiscoveringUseCase")}_logger;async execute(){this._logger.debug("Stopping discovering devices");for(let t of this.transportService.getAllTransports())await t.stopDiscovering()}};Rg=SZ([(0,qg.injectable)(),OI(0,(0,qg.inject)(OZ.transportDiTypes.TransportService)),OI(1,(0,qg.inject)(DZ.loggerTypes.LoggerPublisherServiceFactory))],Rg)});var xI=a((cge,PI)=>{"use strict";var Ng=Object.defineProperty,EZ=Object.getOwnPropertyDescriptor,CZ=Object.getOwnPropertyNames,AZ=Object.prototype.hasOwnProperty,wZ=(t,e)=>{for(var r in e)Ng(t,r,{get:e[r],enumerable:!0})},IZ=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of CZ(e))!AZ.call(t,n)&&n!==r&&Ng(t,n,{get:()=>e[n],enumerable:!(i=EZ(e,n))||i.enumerable});return t},PZ=t=>IZ(Ng({},"__esModule",{value:!0}),t),II={};wZ(II,{discoveryModuleFactory:()=>FZ});PI.exports=PZ(II);var xZ=h(),MZ=Fw(),TZ=Hw(),jZ=Qw(),qZ=rI(),RZ=aI(),NZ=pI(),UZ=mI(),BZ=DI(),LZ=wI(),It=zt(),$=Mo(),FZ=({stub:t=!1})=>new xZ.ContainerModule(({bind:e,rebindSync:r})=>{e($.discoveryTypes.ConnectUseCase).to(MZ.ConnectUseCase),e($.discoveryTypes.DisconnectUseCase).to(TZ.DisconnectUseCase),e($.discoveryTypes.ReconnectUseCase).to(UZ.ReconnectUseCase),e($.discoveryTypes.StartDiscoveringUseCase).to(BZ.StartDiscoveringUseCase),e($.discoveryTypes.StopDiscoveringUseCase).to(LZ.StopDiscoveringUseCase),e($.discoveryTypes.GetConnectedDeviceUseCase).to(jZ.GetConnectedDeviceUseCase),e($.discoveryTypes.ListenToAvailableDevicesUseCase).to(RZ.ListenToAvailableDevicesUseCase),e($.discoveryTypes.ListenToConnectedDeviceUseCase).to(NZ.ListenToConnectedDeviceUseCase),e($.discoveryTypes.ListConnectedDevicesUseCase).to(qZ.ListConnectedDevicesUseCase),t&&(r($.discoveryTypes.ConnectUseCase).to(It.StubUseCase),r($.discoveryTypes.DisconnectUseCase).to(It.StubUseCase),r($.discoveryTypes.StartDiscoveringUseCase).to(It.StubUseCase),r($.discoveryTypes.StopDiscoveringUseCase).to(It.StubUseCase),r($.discoveryTypes.GetConnectedDeviceUseCase).to(It.StubUseCase),r($.discoveryTypes.ListenToAvailableDevicesUseCase).to(It.StubUseCase),r($.discoveryTypes.ListenToConnectedDeviceUseCase).to(It.StubUseCase),r($.discoveryTypes.ListConnectedDevicesUseCase).to(It.StubUseCase))})});var bn=a((uge,jI)=>{"use strict";var Ug=Object.defineProperty,kZ=Object.getOwnPropertyDescriptor,VZ=Object.getOwnPropertyNames,GZ=Object.prototype.hasOwnProperty,HZ=(t,e)=>{for(var r in e)Ug(t,r,{get:e[r],enumerable:!0})},WZ=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of VZ(e))!GZ.call(t,n)&&n!==r&&Ug(t,n,{get:()=>e[n],enumerable:!(i=kZ(e,n))||i.enumerable});return t},KZ=t=>WZ(Ug({},"__esModule",{value:!0}),t),MI={};HZ(MI,{LogLevel:()=>TI});jI.exports=KZ(MI);var TI=(t=>(t[t.Fatal=0]="Fatal",t[t.Error=1]="Error",t[t.Warning=2]="Warning",t[t.Info=3]="Info",t[t.Debug=4]="Debug",t))(TI||{})});var Fg=a((dge,RI)=>{"use strict";var Lg=Object.defineProperty,$Z=Object.getOwnPropertyDescriptor,zZ=Object.getOwnPropertyNames,JZ=Object.prototype.hasOwnProperty,XZ=(t,e)=>{for(var r in e)Lg(t,r,{get:e[r],enumerable:!0})},QZ=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of zZ(e))!JZ.call(t,n)&&n!==r&&Lg(t,n,{get:()=>e[n],enumerable:!(i=$Z(e,n))||i.enumerable});return t},YZ=t=>QZ(Lg({},"__esModule",{value:!0}),t),qI={};XZ(qI,{DefaultLogTagFormatter:()=>Bg});RI.exports=YZ(qI);var Bg=class{format(e){return Array.isArray(e)?e.map(r=>`[${r}]`).join(" "):`[${e}]`}}});var BI=a((lge,UI)=>{"use strict";var Vg=Object.defineProperty,ZZ=Object.getOwnPropertyDescriptor,eee=Object.getOwnPropertyNames,tee=Object.prototype.hasOwnProperty,ree=(t,e)=>{for(var r in e)Vg(t,r,{get:e[r],enumerable:!0})},nee=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of eee(e))!tee.call(t,n)&&n!==r&&Vg(t,n,{get:()=>e[n],enumerable:!(i=ZZ(e,n))||i.enumerable});return t},iee=t=>nee(Vg({},"__esModule",{value:!0}),t),NI={};ree(NI,{sanitiseData:()=>oee});UI.exports=iee(NI);function kg(t,e){if(typeof t=="bigint")return t.toString();if(Array.isArray(t))return e.has(t)?"[Circular]":(e.add(t),t.map(r=>kg(r,e)));if(t!==null&&typeof t=="object"){if(e.has(t))return"[Circular]";e.add(t);let r={};for(let[i,n]of Object.entries(t))r[i]=kg(n,e);return r}return t}function oee(t){let e=new WeakSet;e.add(t);let r={};for(let[i,n]of Object.entries(t))r[i]=kg(n,e);return r}});var VI=a((pge,kI)=>{"use strict";var ls=Object.defineProperty,LI=Object.getOwnPropertyDescriptor,see=Object.getOwnPropertyNames,aee=Object.prototype.hasOwnProperty,cee=(t,e)=>{for(var r in e)ls(t,r,{get:e[r],enumerable:!0})},uee=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of see(e))!aee.call(t,n)&&n!==r&&ls(t,n,{get:()=>e[n],enumerable:!(i=LI(e,n))||i.enumerable});return t},dee=t=>uee(ls({},"__esModule",{value:!0}),t),lee=(t,e,r,i)=>{for(var n=i>1?void 0:i?LI(e,r):e,o=t.length-1,s;o>=0;o--)(s=t[o])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&ls(e,r,n),n},FI={};cee(FI,{DefaultLoggerPublisherService:()=>Gg});kI.exports=dee(FI);var pee=h(),ds=bn(),fee=Fg(),vee=BI(),Gg=class{subscribers;tag;tagFormatter;constructor(t,e,r=new fee.DefaultLogTagFormatter){this.subscribers=t,this.tag=e,this.tagFormatter=r}_log(t,e,r){let i=r?.data?(0,vee.sanitiseData)(r.data):void 0,n=r?.tag??this.tag,o=this.tagFormatter.format(n);this.subscribers.forEach(s=>{let l={timestamp:r?.timestamp??Date.now(),tag:o,data:i};s.log(t,e,l)})}info(t,e){this._log(ds.LogLevel.Info,t,e)}warn(t,e){this._log(ds.LogLevel.Warning,t,e)}debug(t,e){this._log(ds.LogLevel.Debug,t,e)}error(t,e){this._log(ds.LogLevel.Error,t,e)}};Gg=lee([(0,pee.injectable)()],Gg)});var WI=a((vge,HI)=>{"use strict";var Hg=Object.defineProperty,gee=Object.getOwnPropertyDescriptor,hee=Object.getOwnPropertyNames,mee=Object.prototype.hasOwnProperty,yee=(t,e)=>{for(var r in e)Hg(t,r,{get:e[r],enumerable:!0})},bee=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of hee(e))!mee.call(t,n)&&n!==r&&Hg(t,n,{get:()=>e[n],enumerable:!(i=gee(e,n))||i.enumerable});return t},_ee=t=>bee(Hg({},"__esModule",{value:!0}),t),GI={};yee(GI,{loggerModuleFactory:()=>Eee});HI.exports=_ee(GI);var See=h(),Dee=VI(),Oee=P(),Eee=({subscribers:t}={subscribers:[]})=>new See.ContainerModule(({bind:e})=>{e(Oee.loggerTypes.LoggerPublisherServiceFactory).toFactory(r=>i=>new Dee.DefaultLoggerPublisherService(t,i))})});var JI=a((gge,zI)=>{"use strict";var Wg=Object.defineProperty,Cee=Object.getOwnPropertyDescriptor,Aee=Object.getOwnPropertyNames,wee=Object.prototype.hasOwnProperty,Iee=(t,e)=>{for(var r in e)Wg(t,r,{get:e[r],enumerable:!0})},Pee=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Aee(e))!wee.call(t,n)&&n!==r&&Wg(t,n,{get:()=>e[n],enumerable:!(i=Cee(e,n))||i.enumerable});return t},xee=t=>Pee(Wg({},"__esModule",{value:!0}),t),KI={};Iee(KI,{AppType:()=>$I});zI.exports=xee(KI);var $I=(t=>(t.currency="currency",t.plugin="plugin",t.tool="tool",t.swap="swap",t))($I||{})});var _n=a((hge,QI)=>{"use strict";var Kg=Object.defineProperty,Mee=Object.getOwnPropertyDescriptor,Tee=Object.getOwnPropertyNames,jee=Object.prototype.hasOwnProperty,qee=(t,e)=>{for(var r in e)Kg(t,r,{get:e[r],enumerable:!0})},Ree=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Tee(e))!jee.call(t,n)&&n!==r&&Kg(t,n,{get:()=>e[n],enumerable:!(i=Mee(e,n))||i.enumerable});return t},Nee=t=>Ree(Kg({},"__esModule",{value:!0}),t),XI={};qee(XI,{DEFAULT_FIRMWARE_DISTRIBUTION_SALT:()=>Fee,DEFAULT_MANAGER_API_BASE_URL:()=>Uee,DEFAULT_MOCK_SERVER_BASE_URL:()=>Bee,DEFAULT_PROVIDER:()=>Lee});QI.exports=Nee(XI);var Uee="https://manager.api.live.ledger.com/api",Bee="http://localhost:8080",Lee=1,Fee="0"});var Jg=a((mge,ZI)=>{"use strict";var zg=Object.defineProperty,kee=Object.getOwnPropertyDescriptor,Vee=Object.getOwnPropertyNames,Gee=Object.prototype.hasOwnProperty,Hee=(t,e)=>{for(var r in e)zg(t,r,{get:e[r],enumerable:!0})},Wee=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Vee(e))!Gee.call(t,n)&&n!==r&&zg(t,n,{get:()=>e[n],enumerable:!(i=kee(e,n))||i.enumerable});return t},Kee=t=>Wee(zg({},"__esModule",{value:!0}),t),YI={};Hee(YI,{HttpFetchApiError:()=>$g});ZI.exports=Kee(YI);var $g=class{constructor(e){this.error=e,this.originalError=e}_tag="FetchError";originalError}});var nP=a((yge,rP)=>{"use strict";var Xg=Object.defineProperty,$ee=Object.getOwnPropertyDescriptor,zee=Object.getOwnPropertyNames,Jee=Object.prototype.hasOwnProperty,Xee=(t,e)=>{for(var r in e)Xg(t,r,{get:e[r],enumerable:!0})},Qee=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of zee(e))!Jee.call(t,n)&&n!==r&&Xg(t,n,{get:()=>e[n],enumerable:!(i=$ee(e,n))||i.enumerable});return t},Yee=t=>Qee(Xg({},"__esModule",{value:!0}),t),eP={};Xee(eP,{AppTypeDto:()=>tP});rP.exports=Yee(eP);var tP=(t=>(t.currency="currency",t.plugin="plugin",t.tool="tool",t.swap="swap",t))(tP||{})});var uP=a((bge,cP)=>{"use strict";var Zee=Object.create,Sn=Object.defineProperty,oP=Object.getOwnPropertyDescriptor,ete=Object.getOwnPropertyNames,tte=Object.getPrototypeOf,rte=Object.prototype.hasOwnProperty,nte=(t,e)=>{for(var r in e)Sn(t,r,{get:e[r],enumerable:!0})},sP=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of ete(e))!rte.call(t,n)&&n!==r&&Sn(t,n,{get:()=>e[n],enumerable:!(i=oP(e,n))||i.enumerable});return t},ite=(t,e,r)=>(r=t!=null?Zee(tte(t)):{},sP(e||!t||!t.__esModule?Sn(r,"default",{value:t,enumerable:!0}):r,t)),ote=t=>sP(Sn({},"__esModule",{value:!0}),t),ste=(t,e,r,i)=>{for(var n=i>1?void 0:i?oP(e,r):e,o=t.length-1,s;o>=0;o--)(s=t[o])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&Sn(e,r,n),n},ate=(t,e)=>(r,i)=>e(r,i,t),aP={};nte(aP,{AxiosManagerApiDataSource:()=>Qg});cP.exports=ote(aP);var ct=ite(E("axios")),iP=h(),z=b(),cte=$t(),ps=JI(),ute=_n(),dte=_n(),ut=Jg(),fs=nP(),Qg=class{_managerApiBaseUrl;_provider=ute.DEFAULT_PROVIDER;_firmwareDistributionSalt=dte.DEFAULT_FIRMWARE_DISTRIBUTION_SALT;constructor({managerApiUrl:t,provider:e,firmwareDistributionSalt:r}){this._managerApiBaseUrl=t,this._provider=e,this._firmwareDistributionSalt=r}setProvider(t){this._provider===t||t<1||(this._provider=t)}getProvider(){return this._provider}getAppList(t){let{targetId:e,firmwareVersionName:r}=t;return(0,z.EitherAsync)(()=>ct.default.get(`${this._managerApiBaseUrl}/v2/apps/by-target`,{params:{target_id:e,provider:this._provider,firmware_version_name:r}})).map(i=>i.data).chain(i=>this.mapApplicationDtoToApplication(i)).mapLeft(i=>new ut.HttpFetchApiError(i))}getMcuList(){return(0,z.EitherAsync)(()=>ct.default.get(`${this._managerApiBaseUrl}/mcu_versions`,{})).map(t=>t.data).chain(t=>this.mapMcuDtoToMcu(t)).mapLeft(t=>new ut.HttpFetchApiError(t))}getDeviceVersion(t){let{targetId:e}=t;return(0,z.EitherAsync)(()=>ct.default.get(`${this._managerApiBaseUrl}/get_device_version`,{params:{target_id:e,provider:this._provider}})).map(r=>r.data).chain(r=>this.mapDeviceVersionDto(r)).mapLeft(r=>new ut.HttpFetchApiError(r))}getFirmwareVersion(t){let{deviceId:e,version:r}=t;return(0,z.EitherAsync)(()=>ct.default.get(`${this._managerApiBaseUrl}/get_firmware_version`,{params:{device_version:e,version_name:r,provider:this._provider}})).map(i=>i.data).chain(i=>this.mapFinalFirmwareDto(i)).mapLeft(i=>new ut.HttpFetchApiError(i))}getFirmwareVersionById(t){return(0,z.EitherAsync)(()=>ct.default.get(`${this._managerApiBaseUrl}/firmware_final_versions/${t}`,{})).map(e=>e.data).chain(e=>this.mapFinalFirmwareDto(e)).mapLeft(e=>new ut.HttpFetchApiError(e))}getOsuFirmwareVersion(t){let{deviceId:e,version:r}=t;return(0,z.EitherAsync)(()=>ct.default.get(`${this._managerApiBaseUrl}/get_osu_version`,{params:{device_version:e,version_name:r,provider:this._provider}})).map(i=>i.data).chain(i=>this.mapOsuFirmwareDto(i)).mapLeft(i=>new ut.HttpFetchApiError(i))}getLatestFirmwareVersion(t){let e="34.27.0",{currentFinalFirmwareId:r,deviceId:i}=t;return(0,z.EitherAsync)(()=>ct.default.get(`${this._managerApiBaseUrl}/get_latest_firmware`,{params:{current_se_firmware_final_version:r,device_version:i,provider:this._provider,salt:this._firmwareDistributionSalt,livecommonversion:e}})).map(n=>n.data).chain(n=>this.mapLatestFirmwareDto(n)).mapLeft(n=>new ut.HttpFetchApiError(n))}getAppsByHash(t){let{hashes:e}=t;return(0,z.EitherAsync)(()=>ct.default.post(`${this._managerApiBaseUrl}/v2/apps/hash`,e)).map(r=>r.data).chain(r=>this.mapNullableApplicationDtoToApplication(r)).mapLeft(r=>new ut.HttpFetchApiError(r))}getLanguagePackages(t){let{deviceId:e,currentFinalFirmwareId:r}=t;return(0,z.EitherAsync)(()=>ct.default.get(`${this._managerApiBaseUrl}/language-packages`,{params:{device_version:e,current_se_firmware_final_version:r}})).map(i=>i.data).chain(i=>this.mapLanguagesDtoToLanguages(i)).mapLeft(i=>new ut.HttpFetchApiError(i))}mapAppTypeDtoToAppType(t){if(t===null)return null;switch(t){case fs.AppTypeDto.currency:return ps.AppType.currency;case fs.AppTypeDto.plugin:return ps.AppType.plugin;case fs.AppTypeDto.tool:return ps.AppType.tool;case fs.AppTypeDto.swap:return ps.AppType.swap}}mapApplicationDtoToApplication(t){return(0,z.EitherAsync)(()=>Promise.resolve(t.map(e=>this.mapApplicationDto(e))))}mapNullableApplicationDtoToApplication(t){return(0,z.EitherAsync)(()=>Promise.resolve(t.map(e=>e===null?null:this.mapApplicationDto(e))))}mapApplicationDto(t){if(typeof t!="object"||typeof t.versionId!="number"||typeof t.versionName!="string"||t.versionDisplayName!==null&&typeof t.versionDisplayName!="string"||typeof t.version!="string"||t.currencyId!==null&&typeof t.currencyId!="string"||t.description!==null&&typeof t.description!="string"||t.applicationType!==null&&typeof t.applicationType!="string"||typeof t.dateModified!="string"||t.icon!==null&&typeof t.icon!="string"||t.authorName!==null&&typeof t.authorName!="string"||t.supportURL!==null&&typeof t.supportURL!="string"||t.contactURL!==null&&typeof t.contactURL!="string"||t.sourceURL!==null&&typeof t.sourceURL!="string"||t.compatibleWallets!==null&&typeof t.compatibleWallets!="string"||typeof t.hash!="string"||typeof t.perso!="string"||typeof t.firmware!="string"||typeof t.firmwareKey!="string"||typeof t.delete!="string"||typeof t.deleteKey!="string"||t.bytes!==null&&typeof t.bytes!="number"||t.warning!==null&&typeof t.warning!="string"||typeof t.isDevTools!="boolean"||t.category!==null&&typeof t.category!="number"||t.parent!==null&&typeof t.parent!="number"||t.parentName!==null&&typeof t.parentName!="string")throw new Error(`Incomplete application: ${JSON.stringify(t)}`);let{applicationType:e,hash:r,perso:i,firmware:n,firmwareKey:o,delete:s,deleteKey:l,...u}=t;return{...u,hash:r,perso:i,firmware:n,firmwareKey:o,delete:s,deleteKey:l,applicationType:this.mapAppTypeDtoToAppType(e)}}mapMcuDtoToMcu(t){return(0,z.EitherAsync)(()=>Promise.resolve(t.map(e=>{if(typeof e!="object"||typeof e.id!="number"||typeof e.name!="string")throw new Error(`Incomplete MCU version: ${JSON.stringify(e)}`);return{id:e.id,name:e.name}})))}mapDeviceVersionDto(t){return(0,z.EitherAsync)(()=>{if(typeof t!="object"||typeof t.id!="number")throw new Error(`Incomplete device version: ${JSON.stringify(t)}`);let e={id:t.id};return Promise.resolve(e)})}mapFinalFirmwareDto(t){return(0,z.EitherAsync)(()=>{if(typeof t!="object"||typeof t.id!="number"||typeof t.version!="string"||typeof t.perso!="string"||t.firmware!==null&&typeof t.firmware!="string"||t.firmware_key!==null&&typeof t.firmware_key!="string"||t.hash!==null&&typeof t.hash!="string"||t.bytes!==null&&typeof t.bytes!="number"||!Array.isArray(t.mcu_versions))throw new Error(`Incomplete final firmware: ${JSON.stringify(t)}`);let e={id:t.id,version:t.version,perso:t.perso,firmware:t.firmware,firmwareKey:t.firmware_key,hash:t.hash,bytes:t.bytes,mcuVersions:t.mcu_versions};return Promise.resolve(e)})}mapLatestFirmwareDto(t){return(0,z.EitherAsync)(()=>{if(t.result!=="success"||!t.se_firmware_osu_version)throw new Error(`Latest firmware could not be retrieved: ${t.result}`);let e=t.se_firmware_osu_version;return Promise.resolve(e)}).chain(e=>this.mapOsuFirmwareDto(e))}mapOsuFirmwareDto(t){return(0,z.EitherAsync)(()=>{if(typeof t!="object"||typeof t.id!="number"||typeof t.perso!="string"||typeof t.firmware!="string"||typeof t.firmware_key!="string"||t.hash!==null&&typeof t.hash!="string"||typeof t.next_se_firmware_final_version!="number")throw new Error(`Incomplete latest firmware: ${JSON.stringify(t)}`);let e={id:t.id,perso:t.perso,firmware:t.firmware,firmwareKey:t.firmware_key,hash:t.hash,nextFinalFirmware:t.next_se_firmware_final_version};return Promise.resolve(e)})}mapLanguagesDtoToLanguages(t){return(0,z.EitherAsync)(()=>Promise.resolve(t.map(e=>this.mapLanguageDto(e))))}mapLanguageDto(t){if(typeof t!="object"||typeof t.language!="string"||typeof t.languagePackageVersionId!="number"||typeof t.version!="string"||typeof t.language_package_id!="number"||typeof t.apdu_install_url!="string"||typeof t.apdu_uninstall_url!="string"||typeof t.bytes!="number"||typeof t.date_creation!="string"||typeof t.date_last_modified!="string")throw new Error(`Incomplete language version: ${JSON.stringify(t)}`);return{language:t.language,languagePackageVersionId:t.languagePackageVersionId,version:t.version,languagePackageId:t.language_package_id,apduInstallUrl:t.apdu_install_url,apduUninstallUrl:t.apdu_uninstall_url,bytes:t.bytes,dateCreation:t.date_creation,dateLastModified:t.date_last_modified}}};Qg=ste([(0,iP.injectable)(),ate(0,(0,iP.inject)(cte.managerApiTypes.DmkConfig))],Qg)});var gP=a((Sge,vP)=>{"use strict";var vs=Object.defineProperty,pP=Object.getOwnPropertyDescriptor,lte=Object.getOwnPropertyNames,pte=Object.prototype.hasOwnProperty,fte=(t,e)=>{for(var r in e)vs(t,r,{get:e[r],enumerable:!0})},vte=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of lte(e))!pte.call(t,n)&&n!==r&&vs(t,n,{get:()=>e[n],enumerable:!(i=pP(e,n))||i.enumerable});return t},gte=t=>vte(vs({},"__esModule",{value:!0}),t),hte=(t,e,r,i)=>{for(var n=i>1?void 0:i?pP(e,r):e,o=t.length-1,s;o>=0;o--)(s=t[o])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&vs(e,r,n),n},mte=(t,e)=>(r,i)=>e(r,i,t),fP={};fte(fP,{DefaultManagerApiService:()=>Yg});vP.exports=gte(fP);var dP=h(),yte=b(),bte=$t(),lP=Jg(),Yg=class{constructor(t){this.dataSource=t}getAppList(t){let e={targetId:t.targetId.toString(),firmwareVersionName:t.seVersion};return this.dataSource.getAppList(e)}getDeviceVersion(t){let e={targetId:t.targetId.toString()};return this.dataSource.getDeviceVersion(e)}getFirmwareVersion(t,e){let r={version:t.seVersion,deviceId:e.id};return this.dataSource.getFirmwareVersion(r)}getOsuFirmwareVersion(t,e){let r={version:t.seVersion,deviceId:e.id};return this.dataSource.getOsuFirmwareVersion(r)}getLatestFirmwareVersion(t,e){let r={currentFinalFirmwareId:t.id,deviceId:e.id};return this.dataSource.getLatestFirmwareVersion(r)}getNextFirmwareVersion(t){return this.dataSource.getFirmwareVersionById(t.nextFinalFirmware)}getLanguagePackages(t,e){let r={deviceId:t.id,currentFinalFirmwareId:e.id};return this.dataSource.getLanguagePackages(r)}getMcuList(){return this.dataSource.getMcuList()}getAppsByHash(t){let e={hashes:t};return(0,yte.EitherAsync)(async({fromPromise:r,throwE:i})=>{if(e.hashes.length===0)return[];try{return await r(this.dataSource.getAppsByHash(e))}catch(n){return n instanceof lP.HttpFetchApiError?i(n):i(new lP.HttpFetchApiError(n))}})}};Yg=hte([(0,dP.injectable)(),mte(0,(0,dP.inject)(bte.managerApiTypes.ManagerApiDataSource))],Yg)});var _P=a((Oge,bP)=>{"use strict";var gs=Object.defineProperty,mP=Object.getOwnPropertyDescriptor,_te=Object.getOwnPropertyNames,Ste=Object.prototype.hasOwnProperty,Dte=(t,e)=>{for(var r in e)gs(t,r,{get:e[r],enumerable:!0})},Ote=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of _te(e))!Ste.call(t,n)&&n!==r&&gs(t,n,{get:()=>e[n],enumerable:!(i=mP(e,n))||i.enumerable});return t},Ete=t=>Ote(gs({},"__esModule",{value:!0}),t),Cte=(t,e,r,i)=>{for(var n=i>1?void 0:i?mP(e,r):e,o=t.length-1,s;o>=0;o--)(s=t[o])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&gs(e,r,n),n},hP=(t,e)=>(r,i)=>e(r,i,t),yP={};Dte(yP,{SetProviderUseCase:()=>eh});bP.exports=Ete(yP);var Zg=h(),Ate=ne(),wte=K(),Ite=$t(),eh=class{constructor(t,e){this.sessionService=t,this.managerApiDataSource=e}execute(t){for(let e of this.sessionService.getDeviceSessions()){let r=e.getDeviceSessionState();r.sessionStateType!==Ate.DeviceSessionStateType.Connected&&e.setDeviceSessionState({...r,firmwareUpdateContext:void 0,installedApps:[],appsUpdates:void 0,catalog:void 0})}this.managerApiDataSource.setProvider(t)}};eh=Cte([(0,Zg.injectable)(),hP(0,(0,Zg.inject)(wte.deviceSessionTypes.DeviceSessionService)),hP(1,(0,Zg.inject)(Ite.managerApiTypes.ManagerApiDataSource))],eh)});var OP=a((Cge,DP)=>{"use strict";var rh=Object.defineProperty,Pte=Object.getOwnPropertyDescriptor,xte=Object.getOwnPropertyNames,Mte=Object.prototype.hasOwnProperty,Tte=(t,e)=>{for(var r in e)rh(t,r,{get:e[r],enumerable:!0})},jte=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of xte(e))!Mte.call(t,n)&&n!==r&&rh(t,n,{get:()=>e[n],enumerable:!(i=Pte(e,n))||i.enumerable});return t},qte=t=>jte(rh({},"__esModule",{value:!0}),t),SP={};Tte(SP,{managerApiModuleFactory:()=>Lte});DP.exports=qte(SP);var Rte=h(),Nte=uP(),Ute=gP(),Bte=_P(),th=zt(),Zt=$t(),Lte=({stub:t,config:e})=>new Rte.ContainerModule(({bind:r,rebindSync:i})=>{r(Zt.managerApiTypes.DmkConfig).toConstantValue(e),r(Zt.managerApiTypes.ManagerApiDataSource).to(Nte.AxiosManagerApiDataSource).inSingletonScope(),r(Zt.managerApiTypes.ManagerApiService).to(Ute.DefaultManagerApiService).inSingletonScope(),r(Zt.managerApiTypes.SetProviderUseCase).to(Bte.SetProviderUseCase),t&&(i(Zt.managerApiTypes.ManagerApiDataSource).to(th.StubUseCase),i(Zt.managerApiTypes.ManagerApiService).to(th.StubUseCase),i(Zt.managerApiTypes.SetProviderUseCase).to(th.StubUseCase))})});var MP=a((Age,xP)=>{"use strict";var Fte=Object.create,Dn=Object.defineProperty,AP=Object.getOwnPropertyDescriptor,kte=Object.getOwnPropertyNames,Vte=Object.getPrototypeOf,Gte=Object.prototype.hasOwnProperty,Hte=(t,e)=>{for(var r in e)Dn(t,r,{get:e[r],enumerable:!0})},wP=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of kte(e))!Gte.call(t,n)&&n!==r&&Dn(t,n,{get:()=>e[n],enumerable:!(i=AP(e,n))||i.enumerable});return t},IP=(t,e,r)=>(r=t!=null?Fte(Vte(t)):{},wP(e||!t||!t.__esModule?Dn(r,"default",{value:t,enumerable:!0}):r,t)),Wte=t=>wP(Dn({},"__esModule",{value:!0}),t),Kte=(t,e,r,i)=>{for(var n=i>1?void 0:i?AP(e,r):e,o=t.length-1,s;o>=0;o--)(s=t[o])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&Dn(e,r,n),n},$te=(t,e)=>(r,i)=>e(r,i,t),PP={};Hte(PP,{DefaultSecureChannelDataSource:()=>nh});xP.exports=Wte(PP);var EP=h(),zte=IP(Km()),CP=b(),Ir=IP(E("url")),Jte=hn(),Xte=ui(),nh=class{webSocketBaseUrl;constructor({webSocketUrl:t}){this.webSocketBaseUrl=t}genuineCheck(t){let e=Ir.default.format({pathname:`${this.webSocketBaseUrl}/genuine`,query:t});return this._connectWebSocket(e)}installApp(t){let e=Ir.default.format({pathname:`${this.webSocketBaseUrl}/install`,query:t});return this._connectWebSocket(e)}listInstalledApps(t){let e=Ir.default.format({pathname:`${this.webSocketBaseUrl}/apps/list`,query:t});return this._connectWebSocket(e)}uninstallApp(t){let e=Ir.default.format({pathname:`${this.webSocketBaseUrl}/install`,query:t});return this._connectWebSocket(e)}updateFirmware(t){let e=Ir.default.format({pathname:`${this.webSocketBaseUrl}/install`,query:t});return this._connectWebSocket(e)}updateMcu(t){let e=Ir.default.format({pathname:`${this.webSocketBaseUrl}/mcu`,query:t});return this._connectWebSocket(e)}_connectWebSocket(t){try{return(0,CP.Right)(new zte.default(t))}catch(e){return(0,CP.Left)(new Xte.WebSocketConnectionError(e))}}};nh=Kte([(0,EP.injectable)(),$te(0,(0,EP.inject)(Jte.secureChannelTypes.DmkConfig))],nh)});var NP=a((Ige,RP)=>{"use strict";var hs=Object.defineProperty,jP=Object.getOwnPropertyDescriptor,Qte=Object.getOwnPropertyNames,Yte=Object.prototype.hasOwnProperty,Zte=(t,e)=>{for(var r in e)hs(t,r,{get:e[r],enumerable:!0})},ere=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Qte(e))!Yte.call(t,n)&&n!==r&&hs(t,n,{get:()=>e[n],enumerable:!(i=jP(e,n))||i.enumerable});return t},tre=t=>ere(hs({},"__esModule",{value:!0}),t),rre=(t,e,r,i)=>{for(var n=i>1?void 0:i?jP(e,r):e,o=t.length-1,s;o>=0;o--)(s=t[o])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&hs(e,r,n),n},nre=(t,e)=>(r,i)=>e(r,i,t),qP={};Zte(qP,{DefaultSecureChannelService:()=>ih});RP.exports=tre(qP);var TP=h(),ire=hn(),ih=class{constructor(t){this.dataSource=t}genuineCheck(t,e){let r={targetId:t.targetId.toString(),perso:e.perso};return this.dataSource.genuineCheck(r)}installApp(t,e){let{perso:r,firmware:i,firmwareKey:n,hash:o}=e,s={targetId:t.targetId.toString(),perso:r,firmware:i,firmwareKey:n,hash:o};return this.dataSource.installApp(s)}listInstalledApps(t,e){let r={targetId:t.targetId.toString(),perso:e.perso};return this.dataSource.listInstalledApps(r)}uninstallApp(t,e){let{perso:r,delete:i,deleteKey:n,hash:o}=e,s={targetId:t.targetId.toString(),perso:r,firmware:i,firmwareKey:n,hash:o};return this.dataSource.uninstallApp(s)}updateFirmware(t,e){let r={targetId:t.targetId.toString(),perso:e.perso,firmware:e.firmware,firmwareKey:e.firmwareKey};return this.dataSource.updateFirmware(r)}updateMcu(t,e){let r={targetId:t.targetId.toString(),version:e.version};return this.dataSource.updateMcu(r)}};ih=rre([(0,TP.injectable)(),nre(0,(0,TP.inject)(ire.secureChannelTypes.SecureChannelDataSource))],ih)});var LP=a((xge,BP)=>{"use strict";var sh=Object.defineProperty,ore=Object.getOwnPropertyDescriptor,sre=Object.getOwnPropertyNames,are=Object.prototype.hasOwnProperty,cre=(t,e)=>{for(var r in e)sh(t,r,{get:e[r],enumerable:!0})},ure=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of sre(e))!are.call(t,n)&&n!==r&&sh(t,n,{get:()=>e[n],enumerable:!(i=ore(e,n))||i.enumerable});return t},dre=t=>ure(sh({},"__esModule",{value:!0}),t),UP={};cre(UP,{secureChannelModuleFactory:()=>vre});BP.exports=dre(UP);var lre=h(),pre=MP(),fre=NP(),oh=hn(),vre=({stub:t,config:e})=>new lre.ContainerModule(({bind:r})=>{r(oh.secureChannelTypes.DmkConfig).toConstantValue(e),r(oh.secureChannelTypes.SecureChannelDataSource).to(pre.DefaultSecureChannelDataSource),r(oh.secureChannelTypes.SecureChannelService).to(fre.DefaultSecureChannelService)})});var ch=a((Mge,kP)=>{"use strict";var ah=Object.defineProperty,gre=Object.getOwnPropertyDescriptor,hre=Object.getOwnPropertyNames,mre=Object.prototype.hasOwnProperty,yre=(t,e)=>{for(var r in e)ah(t,r,{get:e[r],enumerable:!0})},bre=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of hre(e))!mre.call(t,n)&&n!==r&&ah(t,n,{get:()=>e[n],enumerable:!(i=gre(e,n))||i.enumerable});return t},_re=t=>bre(ah({},"__esModule",{value:!0}),t),FP={};yre(FP,{DEFAULT_WEB_SOCKET_BASE_URL:()=>Sre});kP.exports=_re(FP);var Sre="wss://scriptrunner.api.live.ledger.com/update"});var KP=a((Tge,WP)=>{"use strict";var ms=Object.defineProperty,GP=Object.getOwnPropertyDescriptor,Dre=Object.getOwnPropertyNames,Ore=Object.prototype.hasOwnProperty,Ere=(t,e)=>{for(var r in e)ms(t,r,{get:e[r],enumerable:!0})},Cre=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Dre(e))!Ore.call(t,n)&&n!==r&&ms(t,n,{get:()=>e[n],enumerable:!(i=GP(e,n))||i.enumerable});return t},Are=t=>Cre(ms({},"__esModule",{value:!0}),t),wre=(t,e,r,i)=>{for(var n=i>1?void 0:i?GP(e,r):e,o=t.length-1,s;o>=0;o--)(s=t[o])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&ms(e,r,n),n},VP=(t,e)=>(r,i)=>e(r,i,t),HP={};Ere(HP,{SendApduUseCase:()=>dh});WP.exports=Are(HP);var uh=h(),Ire=K(),Pre=P(),dh=class{_sessionService;_logger;constructor(t,e){this._sessionService=t,this._logger=e("SendApduUseCase")}async execute({sessionId:t,apdu:e,abortTimeout:r,triggersDisconnection:i}){return this._sessionService.getDeviceSessionById(t).caseOf({Right:async n=>(await n.sendApdu(e,{abortTimeout:r,triggersDisconnection:i})).caseOf({Right:o=>o,Left:o=>{throw this._logger.error("Error sending APDU",{data:{sessionId:t,apdu:e,error:o}}),o}}),Left:n=>{throw this._logger.error("Error getting deviceSession",{data:{error:n}}),n}})}};dh=wre([(0,uh.injectable)(),VP(0,(0,uh.inject)(Ire.deviceSessionTypes.DeviceSessionService)),VP(1,(0,uh.inject)(Pre.loggerTypes.LoggerPublisherServiceFactory))],dh)});var XP=a((qge,JP)=>{"use strict";var lh=Object.defineProperty,xre=Object.getOwnPropertyDescriptor,Mre=Object.getOwnPropertyNames,Tre=Object.prototype.hasOwnProperty,jre=(t,e)=>{for(var r in e)lh(t,r,{get:e[r],enumerable:!0})},qre=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Mre(e))!Tre.call(t,n)&&n!==r&&lh(t,n,{get:()=>e[n],enumerable:!(i=xre(e,n))||i.enumerable});return t},Rre=t=>qre(lh({},"__esModule",{value:!0}),t),zP={};jre(zP,{sendModuleFactory:()=>Lre});JP.exports=Rre(zP);var Nre=h(),Ure=KP(),Bre=zt(),$P=lv(),Lre=({stub:t=!1})=>new Nre.ContainerModule(({bind:e,rebindSync:r})=>{e($P.sendTypes.SendApduUseCase).to(Ure.SendApduUseCase),t&&r($P.sendTypes.SendApduUseCase).to(Bre.StubUseCase)})});var nx=a((Rge,rx)=>{"use strict";var ys=Object.defineProperty,ex=Object.getOwnPropertyDescriptor,Fre=Object.getOwnPropertyNames,kre=Object.prototype.hasOwnProperty,Vre=(t,e)=>{for(var r in e)ys(t,r,{get:e[r],enumerable:!0})},Gre=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Fre(e))!kre.call(t,n)&&n!==r&&ys(t,n,{get:()=>e[n],enumerable:!(i=ex(e,n))||i.enumerable});return t},Hre=t=>Gre(ys({},"__esModule",{value:!0}),t),Wre=(t,e,r,i)=>{for(var n=i>1?void 0:i?ex(e,r):e,o=t.length-1,s;o>=0;o--)(s=t[o])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&ys(e,r,n),n},Pr=(t,e)=>(r,i)=>e(r,i,t),tx={};Vre(tx,{DefaultTransportService:()=>fh});rx.exports=Hre(tx);var er=h(),ph=b(),QP=tt(),Kre=Bv(),YP=K(),$re=P(),ZP=He(),fh=class{constructor(t,e,r,i,n,o){if(this._config=e,this._loggerModuleFactory=r,this._deviceModelDataSource=i,this._apduSenderServiceFactory=n,this._apduReceiverServiceFactory=o,this._logger=r("TransportService"),t.length===0)throw this._logger.warn("No transports provided, please check your configuration"),new QP.NoTransportProvidedError("No transports provided, please check your configuration");for(let s of t){let l=this.addTransport(s);if(l.isLeft())throw l.extract()}}_transports=new Map;_logger;addTransport(t){let e=t({deviceModelDataSource:this._deviceModelDataSource,loggerServiceFactory:this._loggerModuleFactory,config:this._config,apduSenderServiceFactory:this._apduSenderServiceFactory,apduReceiverServiceFactory:this._apduReceiverServiceFactory});return this.addTransportInternal(e)}addTransportInternal(t){return this.getTransport(t.getIdentifier()).isJust()?(this._logger.warn(`Transport ${t.getIdentifier()} already exists, please check your configuration`),(0,ph.Left)(new QP.TransportAlreadyExistsError(`Transport ${t.getIdentifier()} already exists, please check your configuration`))):(this._transports.set(t.getIdentifier(),t),(0,ph.Right)(void 0))}getTransport(t){return ph.Maybe.fromNullable(this._transports.get(t))}getAllTransports(){return Array.from(this._transports.values())}closeConnection(t){this.getTransport(t.transport).map(e=>e.disconnect({connectedDevice:t}))}};fh=Wre([(0,er.injectable)(),Pr(0,(0,er.inject)(ZP.transportDiTypes.TransportsInput)),Pr(1,(0,er.inject)(ZP.transportDiTypes.DmkConfig)),Pr(2,(0,er.inject)($re.loggerTypes.LoggerPublisherServiceFactory)),Pr(3,(0,er.inject)(Kre.deviceModelTypes.DeviceModelDataSource)),Pr(4,(0,er.inject)(YP.deviceSessionTypes.ApduSenderServiceFactory)),Pr(5,(0,er.inject)(YP.deviceSessionTypes.ApduReceiverServiceFactory))],fh)});var sx=a((Uge,ox)=>{"use strict";var gh=Object.defineProperty,zre=Object.getOwnPropertyDescriptor,Jre=Object.getOwnPropertyNames,Xre=Object.prototype.hasOwnProperty,Qre=(t,e)=>{for(var r in e)gh(t,r,{get:e[r],enumerable:!0})},Yre=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Jre(e))!Xre.call(t,n)&&n!==r&&gh(t,n,{get:()=>e[n],enumerable:!(i=zre(e,n))||i.enumerable});return t},Zre=t=>Yre(gh({},"__esModule",{value:!0}),t),ix={};Qre(ix,{transportModuleFactory:()=>rne});ox.exports=Zre(ix);var ene=h(),tne=nx(),vh=He(),rne=({stub:t=!1,transports:e=[],config:r}={})=>new ene.ContainerModule(({bind:i})=>{i(vh.transportDiTypes.TransportsInput).toConstantValue(e),i(vh.transportDiTypes.TransportService).to(tne.DefaultTransportService).inSingletonScope(),i(vh.transportDiTypes.DmkConfig).toConstantValue(r)})});var ux=a((Bge,cx)=>{"use strict";var hh=Object.defineProperty,nne=Object.getOwnPropertyDescriptor,ine=Object.getOwnPropertyNames,one=Object.prototype.hasOwnProperty,sne=(t,e)=>{for(var r in e)hh(t,r,{get:e[r],enumerable:!0})},ane=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of ine(e))!one.call(t,n)&&n!==r&&hh(t,n,{get:()=>e[n],enumerable:!(i=nne(e,n))||i.enumerable});return t},cne=t=>ane(hh({},"__esModule",{value:!0}),t),ax={};sne(ax,{makeContainer:()=>Dne});cx.exports=cne(ax);var une=h(),dne=AC(),lne=UC(),pne=OA(),fne=IA(),vne=ow(),gne=xI(),hne=WI(),mne=OP(),bs=_n(),yne=LP(),bne=ch(),_ne=XP(),Sne=sx(),Dne=({stub:t=!1,transports:e=[],loggers:r=[],config:i={mockUrl:bs.DEFAULT_MOCK_SERVER_BASE_URL,managerApiUrl:bs.DEFAULT_MANAGER_API_BASE_URL,webSocketUrl:bne.DEFAULT_WEB_SOCKET_BASE_URL,provider:bs.DEFAULT_PROVIDER,firmwareDistributionSalt:bs.DEFAULT_FIRMWARE_DISTRIBUTION_SALT}})=>{let n=new une.Container;return n.loadSync((0,pne.configModuleFactory)({stub:t}),(0,fne.deviceModelModuleFactory)({stub:t}),(0,Sne.transportModuleFactory)({stub:t,transports:e,config:i}),(0,mne.managerApiModuleFactory)({stub:t,config:i}),(0,yne.secureChannelModuleFactory)({stub:t,config:i}),(0,gne.discoveryModuleFactory)({stub:t}),(0,hne.loggerModuleFactory)({subscribers:r}),(0,vne.deviceSessionModuleFactory)({stub:t}),(0,_ne.sendModuleFactory)({stub:t}),(0,dne.commandModuleFactory)({stub:t}),(0,lne.deviceActionModuleFactory)({stub:t})),n}});var bh=a((Lge,px)=>{"use strict";var yh=Object.defineProperty,One=Object.getOwnPropertyDescriptor,Ene=Object.getOwnPropertyNames,Cne=Object.prototype.hasOwnProperty,Ane=(t,e)=>{for(var r in e)yh(t,r,{get:e[r],enumerable:!0})},wne=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ene(e))!Cne.call(t,n)&&n!==r&&yh(t,n,{get:()=>e[n],enumerable:!(i=One(e,n))||i.enumerable});return t},Ine=t=>wne(yh({},"__esModule",{value:!0}),t),lx={};Ane(lx,{DeviceManagementKit:()=>mh});px.exports=Ine(lx);var Pne=ov(),xne=fn(),_s=K(),dt=Mo(),Mne=P(),dx=$t(),Tne=lv(),jne=He(),qne=ux(),Rne=_v(),mh=class{container;constructor({stub:e,transports:r,loggers:i,config:n}={}){this.container=(0,qne.makeContainer)({stub:e,transports:r,loggers:i,config:n})}getVersion(){return this.container.get(xne.configTypes.GetDmkVersionUseCase).getDmkVersion()}startDiscovering(e){return this.container.get(dt.discoveryTypes.StartDiscoveringUseCase).execute(e)}stopDiscovering(){return this.container.get(dt.discoveryTypes.StopDiscoveringUseCase).execute()}listenToAvailableDevices(e){return this.container.get(dt.discoveryTypes.ListenToAvailableDevicesUseCase).execute(e)}async reconnect(e){return this.container.get(dt.discoveryTypes.ReconnectUseCase).execute(e)}connect(e){return this.container.get(dt.discoveryTypes.ConnectUseCase).execute(e)}disconnect(e){return this.container.get(dt.discoveryTypes.DisconnectUseCase).execute(e)}sendApdu(e){return this.container.get(Tne.sendTypes.SendApduUseCase).execute(e)}sendCommand(e){return this.container.get(Pne.commandTypes.SendCommandUseCase).execute(e)}executeDeviceAction(e){return this.container.get(Rne.deviceActionTypes.ExecuteDeviceActionUseCase).execute(e)}getConnectedDevice(e){return this.container.get(dt.discoveryTypes.GetConnectedDeviceUseCase).execute(e)}getDeviceSessionState(e){return this.container.get(_s.deviceSessionTypes.GetDeviceSessionStateUseCase).execute(e)}close(){return this.container.get(_s.deviceSessionTypes.CloseSessionsUseCase).execute()}listConnectedDevices(){return this.container.get(dt.discoveryTypes.ListConnectedDevicesUseCase).execute()}listenToConnectedDevice(){return this.container.get(dt.discoveryTypes.ListenToConnectedDeviceUseCase).execute()}disableDeviceSessionRefresher(e){return this.container.get(_s.deviceSessionTypes.DisableDeviceSessionRefresherUseCase).execute(e)}_unsafeBypassIntentQueue(e){return this.container.get(_s.deviceSessionTypes.UnsafeBypassIntentQueueUseCase).execute(e)}setProvider(e){return this.container.get(dx.managerApiTypes.SetProviderUseCase).execute(e)}getProvider(){return this.container.get(dx.managerApiTypes.ManagerApiDataSource).getProvider()}isEnvironmentSupported(){return this.container.get(jne.transportDiTypes.TransportService).getAllTransports().some(e=>e.isSupported())}getLoggerFactory(){return this.container.get(Mne.loggerTypes.LoggerPublisherServiceFactory)}}});var gx=a((Fge,vx)=>{"use strict";var Sh=Object.defineProperty,Nne=Object.getOwnPropertyDescriptor,Une=Object.getOwnPropertyNames,Bne=Object.prototype.hasOwnProperty,Lne=(t,e)=>{for(var r in e)Sh(t,r,{get:e[r],enumerable:!0})},Fne=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Une(e))!Bne.call(t,n)&&n!==r&&Sh(t,n,{get:()=>e[n],enumerable:!(i=Nne(e,n))||i.enumerable});return t},kne=t=>Fne(Sh({},"__esModule",{value:!0}),t),fx={};Lne(fx,{DeviceManagementKitBuilder:()=>_h});vx.exports=kne(fx);var Ss=_n(),Vne=ch(),Gne=bh(),_h=class{stub=!1;loggers=[];transports=[];config={managerApiUrl:Ss.DEFAULT_MANAGER_API_BASE_URL,mockUrl:Ss.DEFAULT_MOCK_SERVER_BASE_URL,webSocketUrl:Vne.DEFAULT_WEB_SOCKET_BASE_URL,provider:Ss.DEFAULT_PROVIDER,firmwareDistributionSalt:Ss.DEFAULT_FIRMWARE_DISTRIBUTION_SALT};build(){return new Gne.DeviceManagementKit({stub:this.stub,transports:this.transports,loggers:this.loggers,config:this.config})}setStub(e){return this.stub=e,this}addTransport(e){return this.transports.push(e),this}addLogger(e){return this.loggers.push(e),this}addConfig(e){return this.config={...this.config,...e},this}}});var yx=a((kge,mx)=>{"use strict";var Oh=Object.defineProperty,Hne=Object.getOwnPropertyDescriptor,Wne=Object.getOwnPropertyNames,Kne=Object.prototype.hasOwnProperty,$ne=(t,e)=>{for(var r in e)Oh(t,r,{get:e[r],enumerable:!0})},zne=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Wne(e))!Kne.call(t,n)&&n!==r&&Oh(t,n,{get:()=>e[n],enumerable:!(i=Hne(e,n))||i.enumerable});return t},Jne=t=>zne(Oh({},"__esModule",{value:!0}),t),hx={};$ne(hx,{ConsoleLogger:()=>Dh});mx.exports=Jne(hx);var Ue=bn(),Dh=class{maxLevel;constructor(e=Ue.LogLevel.Debug){this.maxLevel=e}log(e,r,i){let n=i.tag;switch(e){case Ue.LogLevel.Info:{this.maxLevel>=Ue.LogLevel.Info&&this.logWithData(n,console.info,r,i);break}case Ue.LogLevel.Warning:{this.maxLevel>=Ue.LogLevel.Warning&&this.logWithData(n,console.warn,r,i);break}case Ue.LogLevel.Debug:{this.maxLevel>=Ue.LogLevel.Debug&&this.logWithData(n,console.debug,r,i);break}case Ue.LogLevel.Error:{this.maxLevel>=Ue.LogLevel.Error&&this.logWithData(n,console.error,r,i);break}case Ue.LogLevel.Fatal:{this.maxLevel>=Ue.LogLevel.Fatal&&this.logWithData(n,console.error,r,i);break}default:this.logWithData(n,console.log,r,i)}}logWithData(e,r,i,n){n.data?r(e,i,n.data):r(e,i)}}});var Dx=a((Vge,Sx)=>{"use strict";var Ch=Object.defineProperty,Xne=Object.getOwnPropertyDescriptor,Qne=Object.getOwnPropertyNames,Yne=Object.prototype.hasOwnProperty,Zne=(t,e)=>{for(var r in e)Ch(t,r,{get:e[r],enumerable:!0})},eie=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Qne(e))!Yne.call(t,n)&&n!==r&&Ch(t,n,{get:()=>e[n],enumerable:!(i=Xne(e,n))||i.enumerable});return t},tie=t=>eie(Ch({},"__esModule",{value:!0}),t),bx={};Zne(bx,{WebLogsExporterLogger:()=>Eh,getJSONStringifyReplacer:()=>_x});Sx.exports=tie(bx);var rie=bn(),nie=hg();function _x(){let t=[];return function(e,r){if(r instanceof Uint8Array){let i=Array.from(r).map(n=>n.toString(16).padStart(2,"0"));return{hex:"0x"+i.join(""),readableHex:i.join(" "),value:r.toString()}}if(r instanceof nie.DeviceSession){let{connectedDevice:{deviceModel:i,type:n,id:o}}=r;return{id:r.id,connectedDevice:{deviceModel:i,type:n,id:o}}}if(typeof r!="object"||r===null)return r;for(;t.length>0&&t.at(-1)!==this;)t.pop();return t.includes(r)?"[Circular]":(t.push(r),r)}}var Eh=class{logs=[];log(e,r,i){this.logs.push([e,r,i])}formatLogsToJSON(){let e=this.logs.map(([r,i,n])=>{let{timestamp:o,...s}=n;return{level:rie.LogLevel[r],message:i,options:{...s,date:new Date(n.timestamp)}}});return JSON.stringify(e,_x(),2)}exportLogsToJSON(){let e=this.formatLogsToJSON(),r=new Blob([e],{type:"application/json"}),i=URL.createObjectURL(r),n=document.createElement("a");n.href=i,n.download=`ledger-device-management-kit-logs-${new Date().toISOString()}.json`,n.click()}}});var wx=a((Gge,Ax)=>{"use strict";var wh=Object.defineProperty,iie=Object.getOwnPropertyDescriptor,oie=Object.getOwnPropertyNames,sie=Object.prototype.hasOwnProperty,aie=(t,e)=>{for(var r in e)wh(t,r,{get:e[r],enumerable:!0})},cie=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of oie(e))!sie.call(t,n)&&n!==r&&wh(t,n,{get:()=>e[n],enumerable:!(i=iie(e,n))||i.enumerable});return t},uie=t=>cie(wh({},"__esModule",{value:!0}),t),Ex={};aie(Ex,{DeviceConnectionStateMachine:()=>Ah});Ax.exports=uie(Ex);var F=b(),Pt=(Y(),X(Q)),die=jr(),Ox=ye(),Cx=Xe(),tr=tt(),lie=1e4,Ah=class{deviceId;deviceAdpuSender;machineActor;timeoutDuration;timeout=null;previousSendApduPromise=null;startReconnectionTimeout(){this.timeout=setTimeout(()=>{this.machineActor.send({type:"ReconnectionTimedOut"})},this.timeoutDuration)}constructor(e){this.deviceId=e.deviceId,this.deviceAdpuSender=e.deviceApduSender,this.timeoutDuration=e.timeoutDuration,this.machineActor=(0,Pt.createActor)(pie({sendApduFn:(r,i,n)=>this.sendApduToDeviceConnection(r,i,n),startReconnectionTimeout:()=>this.startReconnectionTimeout(),cancelReconnectionTimeout:()=>{this.timeout&&(clearTimeout(this.timeout),this.timeout=null)},tryToReconnect:()=>{e.tryToReconnect(this.timeoutDuration)},onTerminated:e.onTerminated,closeConnection:()=>{this.deviceAdpuSender.closeConnection()}})),this.machineActor.start()}sendApduToDeviceConnection(e,r,i){this.deviceAdpuSender.sendApdu(e,r,i).then(n=>{n.caseOf({Left:o=>{this.machineActor.send({type:"ApduSendingError",error:o})},Right:o=>{this.machineActor.send({type:"ApduResponseReceived",apduResponse:o})}})}).catch(n=>{this.machineActor.send({type:"ApduSendingError",error:new Cx.UnknownDeviceExchangeError(n)})})}getDependencies(){return this.deviceAdpuSender.getDependencies()}setDependencies(e){this.deviceAdpuSender.setDependencies(e)}getDeviceId(){return this.deviceId}async sendApdu(e,r,i){this.machineActor.getSnapshot().context.apduInProgress.isJust()&&await Promise.race([new Promise(o=>setTimeout(o,lie)),this.previousSendApduPromise]);let n=new Promise(o=>{this.machineActor.send({type:"SendApduCalled",apdu:e,triggersDisconnection:!!r,abortTimeout:i,responseCallback:o})});return this.previousSendApduPromise=n,n.finally(()=>{this.previousSendApduPromise===n&&(this.previousSendApduPromise=null)}),n}async setupConnection(){await this.deviceAdpuSender.setupConnection()}eventDeviceConnected(){this.machineActor.send({type:"DeviceConnected"})}eventDeviceDisconnected(){this.machineActor.send({type:"DeviceDisconnected"})}closeConnection(){this.machineActor.send({type:"CloseConnectionCalled"})}};function pie({sendApduFn:t,startReconnectionTimeout:e,cancelReconnectionTimeout:r,tryToReconnect:i,onTerminated:n,closeConnection:o}){return(0,Pt.setup)({types:{},actions:{startTimer:()=>{e()},cancelTimer:()=>{r()},reconnectionTimeoutEvent:(0,Pt.emit)({type:"ReconnectionTimedOut"}),sendApdu:({context:s})=>{s.apduInProgress.map(({apdu:l,abortTimeout:u})=>{t(l,!1,u)})},sendApduResponse:({context:s},l)=>{s.apduInProgress.map(({responseCallback:u})=>u(l.response))},sendGetAppAndVersion:()=>{t(new die.GetAppAndVersionCommand().getApdu().getRawApdu(),!1)},tryToReconnect:()=>{i()},clearApduInProgress:(0,Pt.assign)({apduInProgress:F.Nothing}),clearApduResponse:(0,Pt.assign)({apduResponse:F.Nothing}),signalTermination:()=>{n()},closeConnection:()=>{o()}},guards:{isApduThatTriggersDisconnection:({context:s,event:l})=>l.type!=="ApduResponseReceived"?!1:s.apduInProgress.caseOf({Just:({triggersDisconnection:u,apdu:d})=>(u||Ox.CommandUtils.isApduThatTriggersDisconnection(d))&&Ox.CommandUtils.isSuccessResponse(l.apduResponse),Nothing:()=>!1}),isSendApduBusyError:({event:s})=>s.type!=="ApduResponseReceived"?!1:s.apduResponse.statusCode[0]===102&&s.apduResponse.statusCode[1]===1}}).createMachine({id:"deviceConnection",initial:"Connected",context:{apduInProgress:F.Nothing,apduResponse:F.Nothing},states:{Connected:{on:{DeviceDisconnected:{target:"WaitingForReconnection"},SendApduCalled:{target:"SendingApdu",actions:(0,Pt.assign)({apduInProgress:({event:s})=>F.Maybe.of({apdu:s.apdu,triggersDisconnection:s.triggersDisconnection,abortTimeout:s.abortTimeout,responseCallback:s.responseCallback})})},CloseConnectionCalled:{target:"Terminated"}}},SendingApdu:{entry:"sendApdu",on:{ApduResponseReceived:[{guard:"isApduThatTriggersDisconnection",target:"WaitingForDisconnection",actions:[(0,Pt.assign)({apduResponse:({event:s})=>F.Maybe.of(s.apduResponse)})]},{target:"Connected",actions:[{type:"sendApduResponse",params:({event:s})=>({response:(0,F.Right)(s.apduResponse)})},{type:"clearApduInProgress"}]}],ApduSendingError:{target:"Connected",actions:[{type:"sendApduResponse",params:({event:s})=>({response:(0,F.Left)(s.error)})},"clearApduInProgress"]},DeviceDisconnected:{target:"WaitingForReconnection",actions:[{type:"sendApduResponse",params:{response:(0,F.Left)(new tr.DeviceDisconnectedWhileSendingError)}},"clearApduInProgress"]},CloseConnectionCalled:{target:"Terminated",actions:[{type:"sendApduResponse",params:{response:(0,F.Left)(new tr.DeviceDisconnectedWhileSendingError)}},"clearApduInProgress"]},SendApduCalled:{actions:({event:s})=>{s.responseCallback((0,F.Left)(new tr.AlreadySendingApduError))}}}},WaitingForDisconnection:{entry:["sendGetAppAndVersion"],exit:[{type:"sendApduResponse",params:({context:s})=>({response:s.apduResponse.caseOf({Just:l=>(0,F.Right)(l),Nothing:()=>(0,F.Left)(new Cx.UnknownDeviceExchangeError)})})},{type:"clearApduInProgress"},{type:"clearApduResponse"}],on:{ApduResponseReceived:[{guard:"isSendApduBusyError",actions:["sendGetAppAndVersion"],target:"WaitingForDisconnection"},{target:"Connected"}],ApduSendingError:[{target:"WaitingForReconnection"}],SendApduCalled:{actions:({event:s})=>{s.responseCallback((0,F.Left)(new tr.AlreadySendingApduError))}},DeviceDisconnected:{target:"WaitingForReconnection"},CloseConnectionCalled:{target:"Terminated"}}},WaitingForReconnection:{entry:["startTimer","tryToReconnect"],on:{DeviceConnected:{target:"Connected",actions:"cancelTimer"},SendApduCalled:{target:"WaitingForReconnectionWithQueuedSendApdu",actions:(0,Pt.assign)({apduInProgress:({event:s})=>F.Maybe.of({apdu:s.apdu,triggersDisconnection:s.triggersDisconnection,abortTimeout:s.abortTimeout,responseCallback:s.responseCallback})})},ReconnectionTimedOut:{target:"Terminated"},CloseConnectionCalled:{target:"Terminated"}}},WaitingForReconnectionWithQueuedSendApdu:{on:{DeviceConnected:{target:"SendingApdu",actions:"cancelTimer"},ReconnectionTimedOut:{target:"Terminated",actions:[{type:"sendApduResponse",params:{response:(0,F.Left)(new tr.DeviceDisconnectedBeforeSendingApdu)}},{type:"clearApduInProgress"}]},CloseConnectionCalled:{target:"Terminated",actions:[{type:"sendApduResponse",params:{response:(0,F.Left)(new tr.DeviceDisconnectedWhileSendingError)}},"clearApduInProgress"]},SendApduCalled:{actions:({event:s})=>{s.responseCallback((0,F.Left)(new tr.AlreadySendingApduError))}}}},Terminated:{entry:["signalTermination","closeConnection"],type:"final"}}})}});var xh=a((Hge,Px)=>{"use strict";var Ph=Object.defineProperty,fie=Object.getOwnPropertyDescriptor,vie=Object.getOwnPropertyNames,gie=Object.prototype.hasOwnProperty,hie=(t,e)=>{for(var r in e)Ph(t,r,{get:e[r],enumerable:!0})},mie=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of vie(e))!gie.call(t,n)&&n!==r&&Ph(t,n,{get:()=>e[n],enumerable:!(i=fie(e,n))||i.enumerable});return t},yie=t=>mie(Ph({},"__esModule",{value:!0}),t),Ix={};hie(Ix,{TransportConnectedDevice:()=>Ih});Px.exports=yie(Ix);var Ih=class{id;deviceModel;sendApdu;type;transport;name;constructor({id:e,deviceModel:r,type:i,transport:n,sendApdu:o,name:s}){this.id=e,this.deviceModel=r,this.sendApdu=o,this.type=i,this.transport=n,this.name=s}}});var Tx=a((Wge,Mx)=>{"use strict";var Mh=Object.defineProperty,bie=Object.getOwnPropertyDescriptor,_ie=Object.getOwnPropertyNames,Sie=Object.prototype.hasOwnProperty,Die=(t,e)=>{for(var r in e)Mh(t,r,{get:e[r],enumerable:!0})},Oie=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of _ie(e))!Sie.call(t,n)&&n!==r&&Mh(t,n,{get:()=>e[n],enumerable:!(i=bie(e,n))||i.enumerable});return t},Eie=t=>Oie(Mh({},"__esModule",{value:!0}),t),xx={};Die(xx,{deviceModelStubBuilder:()=>Aie});Mx.exports=Eie(xx);var Cie=Ye();function Aie(t={}){return{id:Cie.DeviceModelId.NANO_X,productName:"Ledger Nano X",usbProductId:64,bootloaderUsbProductId:4,usbOnly:!1,memorySize:2*1024*1024,getBlockSize:()=>4*1024,masks:[855638016],bluetoothSpec:[{serviceUuid:"13d63400-2c97-0004-0000-4c6564676572",notifyUuid:"13d63400-2c97-0004-0001-4c6564676572",writeUuid:"13d63400-2c97-0004-0002-4c6564676572",writeCmdUuid:"13d63400-2c97-0004-0003-4c6564676572"}],...t}}});var Rx=a((Kge,qx)=>{"use strict";var Th=Object.defineProperty,wie=Object.getOwnPropertyDescriptor,Iie=Object.getOwnPropertyNames,Pie=Object.prototype.hasOwnProperty,xie=(t,e)=>{for(var r in e)Th(t,r,{get:e[r],enumerable:!0})},Mie=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Iie(e))!Pie.call(t,n)&&n!==r&&Th(t,n,{get:()=>e[n],enumerable:!(i=wie(e,n))||i.enumerable});return t},Tie=t=>Mie(Th({},"__esModule",{value:!0}),t),jx={};xie(jx,{defaultApduResponseStubBuilder:()=>qie});qx.exports=Tie(jx);var jie=yo(),qie=({statusCode:t=Uint8Array.from([144,0]),data:e=Uint8Array.from([])}={})=>new jie.ApduResponse({statusCode:t,data:e})});var Bx=a(($ge,Ux)=>{"use strict";var jh=Object.defineProperty,Rie=Object.getOwnPropertyDescriptor,Nie=Object.getOwnPropertyNames,Uie=Object.prototype.hasOwnProperty,Bie=(t,e)=>{for(var r in e)jh(t,r,{get:e[r],enumerable:!0})},Lie=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Nie(e))!Uie.call(t,n)&&n!==r&&jh(t,n,{get:()=>e[n],enumerable:!(i=Rie(e,n))||i.enumerable});return t},Fie=t=>Lie(jh({},"__esModule",{value:!0}),t),Nx={};Bie(Nx,{connectedDeviceStubBuilder:()=>Wie});Ux.exports=Fie(Nx);var kie=b(),Vie=Tx(),Gie=Rx(),Hie=xh();function Wie(t={}){let e=(0,Vie.deviceModelStubBuilder)();return new Hie.TransportConnectedDevice({deviceModel:e,id:"42",type:"MOCK",transport:"USB",sendApdu:vi.fn(async()=>Promise.resolve((0,kie.Right)((0,Gie.defaultApduResponseStubBuilder)()))),...t})}});var kx=a((zge,Fx)=>{"use strict";var Lx=Object.defineProperty,Kie=Object.getOwnPropertyDescriptor,$ie=Object.getOwnPropertyNames,zie=Object.prototype.hasOwnProperty,Jie=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of $ie(e))!zie.call(t,n)&&n!==r&&Lx(t,n,{get:()=>e[n],enumerable:!(i=Kie(e,n))||i.enumerable});return t},Xie=t=>Jie(Lx({},"__esModule",{value:!0}),t),Qie={};Fx.exports=Xie(Qie)});var Wx=a((Jge,Hx)=>{"use strict";var qh=Object.defineProperty,Yie=Object.getOwnPropertyDescriptor,Zie=Object.getOwnPropertyNames,eoe=Object.prototype.hasOwnProperty,toe=(t,e)=>{for(var r in e)qh(t,r,{get:e[r],enumerable:!0})},roe=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Zie(e))!eoe.call(t,n)&&n!==r&&qh(t,n,{get:()=>e[n],enumerable:!(i=Yie(e,n))||i.enumerable});return t},noe=t=>roe(qh({},"__esModule",{value:!0}),t),Vx={};toe(Vx,{base64StringToBuffer:()=>ioe,isBase64String:()=>Gx});Hx.exports=noe(Vx);function Gx(t){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t)}function ioe(t){if(t.length===0)return new Uint8Array;if(!Gx(t))return null;try{let e=atob(t),r=new Uint8Array(e.length);for(let i=0;i<e.length;i++)r[i]=e.charCodeAt(i);return r}catch{return Uint8Array.from(Buffer.from(t,"base64"))}}});var pn=a((Xge,ir)=>{"use strict";var Fh=Object.defineProperty,ooe=Object.getOwnPropertyDescriptor,soe=Object.getOwnPropertyNames,aoe=Object.prototype.hasOwnProperty,coe=(t,e)=>{for(var r in e)Fh(t,r,{get:e[r],enumerable:!0})},Lh=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of soe(e))!aoe.call(t,n)&&n!==r&&Fh(t,n,{get:()=>e[n],enumerable:!(i=ooe(e,n))||i.enumerable});return t},On=(t,e,r)=>(Lh(t,e,"default"),r&&Lh(r,e,"default")),uoe=t=>Lh(Fh({},"__esModule",{value:!0}),t),nr={};coe(nr,{APDU_MAX_PAYLOAD:()=>Kx.APDU_MAX_PAYLOAD,Apdu:()=>doe.Apdu,ApduBuilder:()=>Kx.ApduBuilder,ApduParser:()=>loe.ApduParser,ApduResponse:()=>Foe.ApduResponse,AppAlreadyInstalledDAError:()=>rr.AppAlreadyInstalledDAError,BatteryStatusType:()=>Jx.BatteryStatusType,BleDeviceInfos:()=>Boe.BleDeviceInfos,ByteArrayBuilder:()=>poe.ByteArrayBuilder,ByteArrayParser:()=>foe.ByteArrayParser,CallTaskInAppDeviceAction:()=>Coe.CallTaskInAppDeviceAction,CloseAppCommand:()=>voe.CloseAppCommand,CommandResultFactory:()=>Rh.CommandResultFactory,CommandResultStatus:()=>Rh.CommandResultStatus,CommandUtils:()=>Soe.CommandUtils,ConnectedDevice:()=>rse.ConnectedDevice,ConsoleLogger:()=>Zoe.ConsoleLogger,DEFAULT_UNLOCK_TIMEOUT_MS:()=>Aoe.DEFAULT_UNLOCK_TIMEOUT_MS,DefaultLogTagFormatter:()=>ese.DefaultLogTagFormatter,DeviceActionStatus:()=>Ooe.DeviceActionStatus,DeviceConnectionStateMachine:()=>nse.DeviceConnectionStateMachine,DeviceLockedError:()=>rr.DeviceLockedError,DeviceManagementKit:()=>Xoe.DeviceManagementKit,DeviceManagementKitBuilder:()=>Qoe.DeviceManagementKitBuilder,DeviceModel:()=>Uh.DeviceModel,DeviceModelId:()=>Uh.DeviceModelId,DeviceNotOnboardedError:()=>rr.DeviceNotOnboardedError,DeviceSessionStateType:()=>koe.DeviceSessionStateType,DeviceStatus:()=>Doe.DeviceStatus,FramerUtils:()=>Joe.FramerUtils,GLOBAL_ERRORS:()=>Nh.GLOBAL_ERRORS,GenuineCheckDeviceAction:()=>Voe.GenuineCheckDeviceAction,GetAppAndVersionCommand:()=>goe.GetAppAndVersionCommand,GetBackgroundImageSizeCommand:()=>zx.GetBackgroundImageSizeCommand,GetBackgroundImageSizeCommandError:()=>zx.GetBackgroundImageSizeCommandError,GetBatteryStatusCommand:()=>Jx.GetBatteryStatusCommand,GetDeviceMetadataDeviceAction:()=>woe.GetDeviceMetadataDeviceAction,GetDeviceStatusDeviceAction:()=>Ioe.GetDeviceStatusDeviceAction,GetOsVersionCommand:()=>hoe.GetOsVersionCommand,GlobalCommandError:()=>Nh.GlobalCommandError,GlobalCommandErrorHandler:()=>Nh.GlobalCommandErrorHandler,GoToDashboardDeviceAction:()=>Poe.GoToDashboardDeviceAction,InstallAppDeviceAction:()=>Goe.InstallAppDeviceAction,InstallOrUpdateAppsDeviceAction:()=>xoe.InstallOrUpdateAppsDeviceAction,InvalidGetFirmwareMetadataResponseError:()=>$x.InvalidGetFirmwareMetadataResponseError,InvalidStatusWordError:()=>$x.InvalidStatusWordError,LEDGER_VENDOR_ID:()=>Uh.LEDGER_VENDOR_ID,ListAppsCommand:()=>moe.ListAppsCommand,ListAppsDeviceAction:()=>Moe.ListAppsDeviceAction,ListAppsWithMetadataDeviceAction:()=>Toe.ListAppsWithMetadataDeviceAction,ListInstalledAppsDeviceAction:()=>Hoe.ListInstalledAppsDeviceAction,LoadCertificateCommand:()=>yoe.LoadCertificateCommand,LogLevel:()=>Yoe.LogLevel,OpenAppCommand:()=>boe.OpenAppCommand,OpenAppDeviceAction:()=>joe.OpenAppDeviceAction,OpenAppWithDependenciesDeviceAction:()=>qoe.OpenAppWithDependenciesDeviceAction,OutOfMemoryDAError:()=>rr.OutOfMemoryDAError,RefusedByUserDAError:()=>rr.RefusedByUserDAError,SecureChannelError:()=>Koe.SecureChannelError,SendCommandInAppDeviceAction:()=>Roe.SendCommandInAppDeviceAction,StaticDeviceModelDataSource:()=>Uoe.StaticDeviceModelDataSource,TransportConnectedDevice:()=>ise.TransportConnectedDevice,TransportDeviceModel:()=>Loe.TransportDeviceModel,UninstallAppDeviceAction:()=>Woe.UninstallAppDeviceAction,UnknownDAError:()=>rr.UnknownDAError,UnsupportedFirmwareDAError:()=>rr.UnsupportedFirmwareDAError,UserInteractionRequired:()=>Eoe.UserInteractionRequired,WebLogsExporterLogger:()=>tse.WebLogsExporterLogger,XStateDeviceAction:()=>Noe.XStateDeviceAction,base64StringToBuffer:()=>Yx.base64StringToBuffer,bufferToHexaString:()=>Bh.bufferToHexaString,connectedDeviceStubBuilder:()=>ose.connectedDeviceStubBuilder,defaultApduReceiverServiceStubBuilder:()=>$oe.defaultApduReceiverServiceStubBuilder,defaultApduSenderServiceStubBuilder:()=>zoe.defaultApduSenderServiceStubBuilder,formatApduReceivedLog:()=>Qx.formatApduReceivedLog,formatApduSentLog:()=>Qx.formatApduSentLog,hexaStringToBuffer:()=>Bh.hexaStringToBuffer,isBase64String:()=>Yx.isBase64String,isCommandErrorCode:()=>_oe.isCommandErrorCode,isHexaString:()=>Bh.isHexaString,isSuccessCommandResult:()=>Rh.isSuccessCommandResult,noopLogger:()=>Xx.noopLogger,noopLoggerFactory:()=>Xx.noopLoggerFactory});ir.exports=uoe(nr);var doe=Gs(),Kx=Oe(),loe=Ee();On(nr,Js(),ir.exports);var poe=Ys(),foe=ia(),$x=Je(),Rh=w(),voe=Fn(),goe=jr(),zx=Ma(),Jx=qy(),hoe=qt(),moe=Ga(),yoe=Jy(),boe=Xa(),_oe=ft(),Soe=ye(),Nh=Be(),Uh=Ye(),Doe=zn(),Ooe=Za(),Eoe=Z(),Coe=i_(),Aoe=le(),rr=de(),woe=fi(),Ioe=ii(),Poe=nt(),xoe=xu(),Moe=oi(),Toe=vS(),joe=kr(),qoe=yS(),Roe=OS(),Noe=ee(),Uoe=Jp(),Boe=Wp(),Loe=zp(),Foe=yo();On(nr,bo(),ir.exports);var koe=ne(),Voe=FO(),Goe=JO(),Hoe=_o(),Woe=tE(),Koe=ui(),$oe=$E(),zoe=eC(),Joe=ln(),Xoe=bh(),Qoe=gx();On(nr,Xe(),ir.exports);var Xx=mc(),Yoe=bn(),Zoe=yx(),ese=Fg(),tse=Dx(),rse=yn(),nse=wx();On(nr,tt(),ir.exports);var ise=xh(),ose=Bx();On(nr,kx(),ir.exports);var Qx=Yv(),Yx=Wx(),Bh=jt()});var tM=a((Yge,Vh)=>{"use strict";var Zx=Object.defineProperty,sse=Object.getOwnPropertyDescriptor,ase=Object.getOwnPropertyNames,cse=Object.prototype.hasOwnProperty,kh=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of ase(e))!cse.call(t,n)&&n!==r&&Zx(t,n,{get:()=>e[n],enumerable:!(i=sse(e,n))||i.enumerable});return t},use=(t,e,r)=>(kh(t,e,"default"),r&&kh(r,e,"default")),dse=t=>kh(Zx({},"__esModule",{value:!0}),t),eM={};Vh.exports=dse(eM);var Qge=Fs();use(eM,pn(),Vh.exports)});var Ds=a((Zge,Hh)=>{"use strict";var rM=Object.defineProperty,lse=Object.getOwnPropertyDescriptor,pse=Object.getOwnPropertyNames,fse=Object.prototype.hasOwnProperty,Gh=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of pse(e))!fse.call(t,n)&&n!==r&&rM(t,n,{get:()=>e[n],enumerable:!(i=lse(e,n))||i.enumerable});return t},vse=(t,e,r)=>(Gh(t,e,"default"),r&&Gh(r,e,"default")),gse=t=>Gh(rM({},"__esModule",{value:!0}),t),nM={};Hh.exports=gse(nM);vse(nM,tM(),Hh.exports)});var Os=a((ehe,sM)=>{"use strict";var $h=Object.defineProperty,hse=Object.getOwnPropertyDescriptor,mse=Object.getOwnPropertyNames,yse=Object.prototype.hasOwnProperty,bse=(t,e)=>{for(var r in e)$h(t,r,{get:e[r],enumerable:!0})},_se=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of mse(e))!yse.call(t,n)&&n!==r&&$h(t,n,{get:()=>e[n],enumerable:!(i=hse(e,n))||i.enumerable});return t},Sse=t=>_se($h({},"__esModule",{value:!0}),t),iM={};bse(iM,{NodeHidSendReportError:()=>Kh,NodeHidTransportNotSupportedError:()=>Wh});sM.exports=Sse(iM);var oM=Ds(),Wh=class extends oM.GeneralDmkError{constructor(e){super(e),this.err=e}_tag="NodeHidTransportNotSupportedError"},Kh=class extends oM.GeneralDmkError{constructor(e){super(e),this.err=e}_tag="NodeHidSendReportError"}});var cM=a((the,aM)=>{"use strict";aM.exports={name:"HID",napi_versions:[4]}});var dM=a((rhe,uM)=>{"use strict";var Dse=E("fs");function Ose(t){if(!t.napi_version)throw new Error("NAN not implemented");return`${[t.name,t.platform,t.arch,t.libc&&t.platform==="linux"?t.libc:null].filter(r=>!!r).join("-")}/${t.runtime}-napi-v${t.napi_version}.node`}function Ese(){return!!(process.versions&&process.versions.nw)}function Cse(){return process.versions&&process.versions.electron||process.env.ELECTRON_RUN_AS_NODE?!0:typeof window<"u"&&window.process&&window.process.type==="renderer"}function Ase(t){return t==="linux"&&Dse.existsSync("/etc/alpine-release")}uM.exports={getPrebuildName:Ose,isNwjs:Ese,isElectron:Cse,isAlpine:Ase}});var hM=a((nhe,gM)=>{"use strict";var zh=E("path"),lM=E("os"),{getPrebuildName:wse,isNwjs:Ise,isElectron:Pse,isAlpine:xse}=dM(),pM=typeof jest<"u"?jest.requireActual("fs"):E("fs"),Mse=typeof __webpack_require__=="function"?__non_webpack_require__:E;function fM(t,e,r,i){if(typeof t!="string"||!t)throw new Error("Invalid basePath to pkg-prebuilds");if(typeof e!="object"||!e)throw new Error("Invalid options to pkg-prebuilds");if(typeof e.name!="string"||!e.name)throw new Error("Invalid name to pkg-prebuilds");let n=!1;e.napi_versions&&Array.isArray(e.napi_versions)&&(n=!0);let o=r&&process.env.npm_config_arch||lM.arch(),s=r&&process.env.npm_config_platform||lM.platform(),l="node";n||(r&&process.env.npm_config_runtime?l=process.env.npm_config_runtime:Pse()?l="electron":Ise()&&(l="node-webkit"));let u=[];r||u.push(zh.join(t,"build","Debug",`${e.name}.node`),zh.join(t,"build","Release",`${e.name}.node`));let d;if(xse(s)&&(d="musl"),n)for(let p of e.napi_versions){let v=wse({name:e.name,platform:s,arch:o,libc:d,napi_version:p,runtime:l});u.push(zh.join(t,"prebuilds",v))}else throw new Error("Not implemented for NAN!");let c=null;for(let p of u)if(pM.existsSync(p)&&pM.statSync(p).isFile()){c=p;break}if(!c&&i){let p=u.map(v=>` - ${v}`).join(`
48
+ `);throw new Error(`Failed to find binding for ${e.name}
49
+ Tried paths:
50
+ ${p}`)}return c}function vM(t,e){let r=fM(t,e,!1,!0);if(!r)throw new Error(`Failed to find binding for ${e.name}`);return Mse(r)}vM.resolve=fM;gM.exports=vM});var Yh=a(sr=>{"use strict";var Qh=E("events").EventEmitter,Tse=E("util"),Jh=null;function jse(t){Jh=t}var $e=null;function En(){if(!$e){let t=cM();process.platform==="linux"&&(!Jh||Jh==="hidraw")&&(t.name="HID_hidraw"),$e=hM()(__dirname,t)}}function or(){if(!new.target)throw new Error("HID() must be called with 'new' operator");Qh.call(this),En();var t=new Array(arguments.length+1);t[0]=null;for(var e=0;e<arguments.length;e++)t[e+1]=arguments[e];this._raw=new(Function.prototype.bind.apply($e.HID,t));for(var e in $e.HID.prototype)this[e]=$e.HID.prototype[e].bind(this._raw);this._paused=!0;var r=this;r.on("newListener",function(i,n){i=="data"&&process.nextTick(r.resume.bind(r))})}Tse.inherits(or,Qh);or.prototype.close=function(){this._closing=!0,this.removeAllListeners(),this._paused?(this._raw.close(),this._closed=!0):this._raw.readInterrupt()};or.prototype.pause=function(){this._paused=!0,this._raw.readInterrupt()};or.prototype.read=function(e){if(this._closed)throw new Error("Unable to read from a closed HID device");return this._raw.read(e)};or.prototype.resume=function(){var e=this;e._paused&&e.listeners("data").length>0&&(e._paused=!1,e.read(function r(i,n){try{if(e._closing){e._paused=!0,e._raw.close(),e._closed=!0;return}i?(e._paused=!0,e._closing||e.emit("error",i)):(e.listeners("data").length<=0&&(e._paused=!0),e._paused||e.read(r),e.emit("data",n))}catch(o){setImmediate(()=>{e._closing||e.emit("error",o)})}}))};var Xh=class t extends Qh{constructor(e){if(super(),!(e instanceof $e.HIDAsync))throw new Error("HIDAsync cannot be constructed directly. Use HIDAsync.open() instead");this._raw=e;for(let r in this._raw)this[r]=async(...i)=>this._raw[r](...i);this.on("newListener",(r,i)=>{r=="data"&&process.nextTick(this.resume.bind(this))}),this.on("removeListener",(r,i)=>{r=="data"&&this.listenerCount("data")==0&&process.nextTick(this.pause.bind(this))})}static async open(...e){En();let r=await $e.openAsyncHIDDevice(...e);return new t(r)}async close(){this._closing=!0,await this._raw.close(),this.removeAllListeners(),this._closed=!0}pause(){this._raw.readStop()}resume(){this.listenerCount("data")>0&&this._raw.readStart((e,r)=>{try{e?this._closing||this.emit("error",e):this.emit("data",r)}catch(i){setImmediate(()=>{this._closing||this.emit("error",i)})}})}};function qse(){return En(),$e.devices.apply(or,arguments)}function Rse(...t){return En(),$e.devicesAsync(...t)}function Nse(){return En(),$e.hidapiVersion}sr.HID=or;sr.HIDAsync=Xh;sr.devices=qse;sr.devicesAsync=Rse;sr.setDriverType=jse;sr.getHidapiVersion=Nse});var Cn=a((mM,yM)=>{"use strict";Object.defineProperty(mM,"__esModule",{value:!0});var Use=E("path"),Bse=ST()(process.env.NODE_USB_PATH||(0,Use.join)(__dirname,"..",".."));yM.exports=Bse});var rm=a(xt=>{"use strict";Object.defineProperty(xt,"__esModule",{value:!0});xt.OutEndpoint=xt.InEndpoint=xt.Endpoint=void 0;var Lse=E("events"),Zh=Cn(),bM=E("util"),Fse=t=>t&&t instanceof Buffer,An=class extends Lse.EventEmitter{constructor(e,r){super(),this.device=e,this.timeout=0,this.descriptor=r,this.address=r.bEndpointAddress,this.transferType=r.bmAttributes&3}clearHalt(e){return this.device.__clearHalt(this.address,e)}makeTransfer(e,r){return new Zh.Transfer(this.device,this.address,this.transferType,e,r)}};xt.Endpoint=An;var em=class extends An{constructor(e,r){super(e,r),this.direction="in",this.pollTransfers=[],this.pollTransferSize=0,this.pollPending=0,this.pollActive=!1,this.transferAsync=(0,bM.promisify)(this.transfer).bind(this)}transfer(e,r){let i=Buffer.alloc(e),n=(o,s,l)=>{r.call(this,o,i.slice(0,l))};try{this.makeTransfer(this.timeout,n).submit(i)}catch(o){process.nextTick(()=>r.call(this,o))}return this}startPoll(e,r,i){let n=(s,l,u,d)=>{if(s?s.errno!==Zh.LIBUSB_TRANSFER_CANCELLED&&this.pollActive&&(this.emit("error",s),this.stopPoll()):this.emit("data",u.slice(0,d)),this.pollActive)o(l);else if(this.pollPending--,this.pollPending===0&&(this.pollTransfers=[],this.pollActive=!1,this.emit("end"),i)){let c=s?.errno===Zh.LIBUSB_TRANSFER_CANCELLED;i(c?void 0:s,u,d,c)}},o=s=>{try{s.submit(Buffer.alloc(this.pollTransferSize),(l,u,d)=>{n(l,s,u,d)})}catch(l){this.emit("error",l),this.stopPoll()}};return this.pollTransfers=this.startPollTransfers(e,r,function(s,l,u){n(s,this,l,u)}),this.pollTransfers.forEach(o),this.pollPending=this.pollTransfers.length,this.pollTransfers}startPollTransfers(e=3,r=this.descriptor.wMaxPacketSize,i){if(this.pollActive)throw new Error("Polling already active");this.pollTransferSize=r,this.pollActive=!0,this.pollPending=0;let n=[];for(let o=0;o<e;o++){let s=this.makeTransfer(0,i);n[o]=s}return n}stopPoll(e){if(!this.pollActive)throw new Error("Polling is not active.");for(let r=0;r<this.pollTransfers.length;r++)try{this.pollTransfers[r].cancel()}catch(i){this.emit("error",i)}this.pollActive=!1,e&&this.once("end",e)}};xt.InEndpoint=em;var tm=class extends An{constructor(e,r){super(e,r),this.direction="out",this.transferAsync=(0,bM.promisify)(this.transfer).bind(this)}transfer(e,r){e?Fse(e)||(e=Buffer.from(e)):e=Buffer.alloc(0);let i=(n,o,s)=>{r&&r.call(this,n,s||0)};try{this.makeTransfer(this.timeout,i).submit(e)}catch(n){process.nextTick(()=>i(n))}return this}transferWithZLP(e,r){e.length%this.descriptor.wMaxPacketSize===0?(this.transfer(e),this.transfer(Buffer.alloc(0),r)):this.transfer(e,r)}};xt.OutEndpoint=tm});var im=a(Es=>{"use strict";Object.defineProperty(Es,"__esModule",{value:!0});Es.Interface=void 0;var kse=Cn(),_M=rm(),SM=E("util"),nm=class{constructor(e,r){this.device=e,this.id=r,this.altSetting=0,this.refresh(),this.releaseAsync=(0,SM.promisify)(this.release).bind(this),this.setAltSettingAsync=(0,SM.promisify)(this.setAltSetting).bind(this)}refresh(){if(!this.device.configDescriptor)return;this.descriptor=this.device.configDescriptor.interfaces[this.id][this.altSetting],this.interfaceNumber=this.descriptor.bInterfaceNumber,this.endpoints=[];let e=this.descriptor.endpoints.length;for(let r=0;r<e;r++){let i=this.descriptor.endpoints[r],n=i.bEndpointAddress&kse.LIBUSB_ENDPOINT_IN?_M.InEndpoint:_M.OutEndpoint;this.endpoints[r]=new n(this.device,i)}}claim(){this.device.__claimInterface(this.id)}release(e,r){let i=!1;typeof e=="boolean"?i=e:r=e;let n=()=>{this.device.__releaseInterface(this.id,o=>{o||(this.altSetting=0,this.refresh()),r&&r.call(this,o)})};if(!i||this.endpoints.length===0)n();else{let o=this.endpoints.length;this.endpoints.forEach(s=>{s.direction==="in"&&s.pollActive?(s.once("end",()=>{--o===0&&n()}),s.stopPoll()):--o===0&&n()})}}isKernelDriverActive(){return this.device.__isKernelDriverActive(this.id)}detachKernelDriver(){return this.device.__detachKernelDriver(this.id)}attachKernelDriver(){return this.device.__attachKernelDriver(this.id)}setAltSetting(e,r){this.device.__setInterface(this.id,e,i=>{i||(this.altSetting=e,this.refresh()),r&&r.call(this,i)})}endpoint(e){return this.endpoints.find(r=>r.address===e)}};Es.Interface=nm});var sm=a(Cs=>{"use strict";Object.defineProperty(Cs,"__esModule",{value:!0});Cs.Capability=void 0;var om=class{constructor(e,r){if(this.device=e,this.id=r,!e._bosDescriptor)throw new Error("bosDescriptor not found");this.descriptor=e._bosDescriptor.capabilities[this.id],this.type=this.descriptor.bDevCapabilityType,this.data=this.descriptor.dev_capability_data}};Cs.Capability=om});var EM=a(ws=>{"use strict";Object.defineProperty(ws,"__esModule",{value:!0});ws.ExtendedDevice=void 0;var I=Cn(),DM=im(),Vse=sm(),As=t=>!!t&&t instanceof Uint8Array,OM=1e3,am=class{constructor(){this._timeout=OM}get timeout(){return this._timeout||OM}set timeout(e){this._timeout=e}get configDescriptor(){try{return this.__getConfigDescriptor()}catch(e){let r=e.errno;if(r===I.LIBUSB_ERROR_NOT_FOUND||r===I.LIBUSB_ERROR_NO_DEVICE)return;throw e}}get allConfigDescriptors(){try{return this.__getAllConfigDescriptors()}catch(e){let r=e.errno;if(r===I.LIBUSB_ERROR_NOT_FOUND||r===I.LIBUSB_ERROR_NO_DEVICE)return[];throw e}}get parent(){return this.__getParent()}open(e=!0){if(this.__open(),this.interfaces=[],e===!1)return;let r=this.configDescriptor?this.configDescriptor.interfaces.length:0;for(let i=0;i<r;i++)this.interfaces[i]=new DM.Interface(this,i)}close(){this.__close(),this.interfaces=void 0}setConfiguration(e,r){this.__setConfiguration(e,i=>{if(!i){this.interfaces=[];let n=this.configDescriptor?this.configDescriptor.interfaces.length:0;for(let o=0;o<n;o++)this.interfaces[o]=new DM.Interface(this,o)}r&&r.call(this,i)})}setAutoDetachKernelDriver(e){return this.__setAutoDetachKernelDriver(e?1:0)}controlTransfer(e,r,i,n,o,s){let l=!!(e&I.LIBUSB_ENDPOINT_IN),u=l?o:o.length;if(l){if(u<0)throw new TypeError("Expected size number for IN transfer (based on bmRequestType)")}else if(!As(o))throw new TypeError("Expected buffer for OUT transfer (based on bmRequestType)");let d=Buffer.alloc(u+I.LIBUSB_CONTROL_SETUP_SIZE);d.writeUInt8(e,0),d.writeUInt8(r,1),d.writeUInt16LE(i,2),d.writeUInt16LE(n,4),d.writeUInt16LE(u,6),l||d.set(o,I.LIBUSB_CONTROL_SETUP_SIZE);let c=new I.Transfer(this,0,I.LIBUSB_TRANSFER_TYPE_CONTROL,this.timeout,(p,v,y)=>{s&&(l?s.call(this,p,v.slice(I.LIBUSB_CONTROL_SETUP_SIZE,I.LIBUSB_CONTROL_SETUP_SIZE+y)):s.call(this,p,y))});try{c.submit(d)}catch(p){s&&process.nextTick(()=>s.call(this,p,void 0))}return this}interface(e){if(!this.interfaces)throw new Error("Device must be open before searching for interfaces");e=e||0;for(let r=0;r<this.interfaces.length;r++)if(this.interfaces[r].interfaceNumber===e)return this.interfaces[r];throw new Error(`Interface not found for address: ${e}`)}getStringDescriptor(e,r){if(e===0){r();return}this.controlTransfer(I.LIBUSB_ENDPOINT_IN,I.LIBUSB_REQUEST_GET_DESCRIPTOR,I.LIBUSB_DT_STRING<<8|e,1033,255,(o,s)=>{if(o)return r(o);r(void 0,As(s)?s.toString("utf16le",2):void 0)})}getBosDescriptor(e){if(this._bosDescriptor)return e(void 0,this._bosDescriptor);if(this.deviceDescriptor.bcdUSB<513)return e(void 0,void 0);this.controlTransfer(I.LIBUSB_ENDPOINT_IN,I.LIBUSB_REQUEST_GET_DESCRIPTOR,I.LIBUSB_DT_BOS<<8,0,I.LIBUSB_DT_BOS_SIZE,(r,i)=>{if(r)return r.errno===I.LIBUSB_TRANSFER_STALL?e(void 0,void 0):e(r,void 0);if(!As(i))return e(void 0,void 0);let n=i.readUInt16LE(2);this.controlTransfer(I.LIBUSB_ENDPOINT_IN,I.LIBUSB_REQUEST_GET_DESCRIPTOR,I.LIBUSB_DT_BOS<<8,0,n,(o,s)=>{if(o)return o.errno===I.LIBUSB_TRANSFER_STALL?e(void 0,void 0):e(o,void 0);if(!As(s))return e(void 0,void 0);let l={bLength:s.readUInt8(0),bDescriptorType:s.readUInt8(1),wTotalLength:s.readUInt16LE(2),bNumDeviceCaps:s.readUInt8(4),capabilities:[]},u=I.LIBUSB_DT_BOS_SIZE;for(;u<l.wTotalLength;){let d={bLength:s.readUInt8(u+0),bDescriptorType:s.readUInt8(u+1),bDevCapabilityType:s.readUInt8(u+2),dev_capability_data:s.slice(u+3,u+s.readUInt8(u+0))};l.capabilities.push(d),u+=d.bLength}this._bosDescriptor=l,e(void 0,this._bosDescriptor)})})}getCapabilities(e){let r=[];this.getBosDescriptor((i,n)=>{if(i)return e(i,void 0);let o=n?n.capabilities.length:0;for(let s=0;s<o;s++)r.push(new Vse.Capability(this,s));e(void 0,r)})}};ws.ExtendedDevice=am});var wn=a((dhe,IM)=>{"use strict";var Gse=E("events"),CM=EM(),A=Cn();A.INIT_ERROR&&console.warn("Failed to initialize libusb.");Object.setPrototypeOf(A,Gse.EventEmitter.prototype);Object.defineProperty(A,"pollHotplug",{value:!1,writable:!0});Object.defineProperty(A,"pollHotplugDelay",{value:500,writable:!0});A.Device&&Object.getOwnPropertyNames(CM.ExtendedDevice.prototype).forEach(t=>{Object.defineProperty(A.Device.prototype,t,Object.getOwnPropertyDescriptor(CM.ExtendedDevice.prototype,t)||Object.create(null))});var Is=new Set,AM=()=>{let t=new Set(A.getDeviceList());for(let e of t)Is.has(e)||A.emit("attach",e);for(let e of Is)t.has(e)||A.emit("detach",e);Is=t},cm=!1,wM=(t=!1)=>{if(t)cm=!0;else if(cm)AM();else return;setTimeout(()=>wM(),A.pollHotplugDelay)},Ps=()=>setTimeout(()=>AM(),A.pollHotplugDelay),xr=0,Hse=()=>{xr=A.pollHotplug?0:A._supportedHotplugEvents(),xr!==1&&(Is=new Set(A.getDeviceList())),xr?(A._enableHotplugEvents(),xr===2&&(A.on("attachIds",Ps),A.on("detachIds",Ps))):wM(!0)},Wse=()=>{xr?(A._disableHotplugEvents(),xr===2&&(A.off("attachIds",Ps),A.off("detachIds",Ps))):cm=!1};A.on("newListener",t=>{if(t!=="attach"&&t!=="detach")return;A.listenerCount("attach")+A.listenerCount("detach")===0&&Hse()});A.on("removeListener",t=>{if(t!=="attach"&&t!=="detach")return;A.listenerCount("attach")+A.listenerCount("detach")===0&&Wse()});IM.exports=A});var dm=a(Ms=>{"use strict";Object.defineProperty(Ms,"__esModule",{value:!0});Ms.WebUSBDevice=void 0;var x=wn(),xs=E("util"),PM=E("os"),xM=3,Kse=127,$se=1,zse=0,um=class t{static async createInstance(e,r=!0){let i=new t(e,r);return await i.initialize(),i}constructor(e,r){this.device=e,this.autoDetachKernelDriver=r,this.manufacturerName=null,this.productName=null,this.serialNumber=null,this.configurations=[];let i=this.decodeVersion(e.deviceDescriptor.bcdUSB);this.usbVersionMajor=i.major,this.usbVersionMinor=i.minor,this.usbVersionSubminor=i.sub,this.deviceClass=e.deviceDescriptor.bDeviceClass,this.deviceSubclass=e.deviceDescriptor.bDeviceSubClass,this.deviceProtocol=e.deviceDescriptor.bDeviceProtocol,this.vendorId=e.deviceDescriptor.idVendor,this.productId=e.deviceDescriptor.idProduct;let n=this.decodeVersion(e.deviceDescriptor.bcdDevice);this.deviceVersionMajor=n.major,this.deviceVersionMinor=n.minor,this.deviceVersionSubminor=n.sub,this.controlTransferAsync=(0,xs.promisify)(this.device.controlTransfer).bind(this.device),this.setConfigurationAsync=(0,xs.promisify)(this.device.setConfiguration).bind(this.device),this.resetAsync=(0,xs.promisify)(this.device.reset).bind(this.device),this.getStringDescriptorAsync=(0,xs.promisify)(this.device.getStringDescriptor).bind(this.device)}get configuration(){if(!this.device.configDescriptor)return null;let e=this.device.configDescriptor.bConfigurationValue;return this.configurations.find(r=>r.configurationValue===e)||null}get opened(){return!!this.device.interfaces}async open(){try{if(this.opened)return;this.device.open(),(0,PM.platform)()!=="win32"&&this.device.setAutoDetachKernelDriver(this.autoDetachKernelDriver)}catch(e){throw new Error(`open error: ${e}`)}}async close(){try{if(!this.opened)return;try{if(this.configuration)for(let e of this.configuration.interfaces)await this._releaseInterface(e.interfaceNumber),this.configuration.interfaces[this.configuration.interfaces.indexOf(e)]={interfaceNumber:e.interfaceNumber,alternate:e.alternate,alternates:e.alternates,claimed:!1}}catch{}this.device.close()}catch(e){throw new Error(`close error: ${e}`)}}async selectConfiguration(e){if(!this.opened||!this.device.configDescriptor)throw new Error("selectConfiguration error: invalid state");if(this.device.configDescriptor.bConfigurationValue===e)return;if(!this.configurations.find(i=>i.configurationValue===e))throw new Error("selectConfiguration error: configuration not found");try{await this.setConfigurationAsync(e)}catch(i){throw new Error(`selectConfiguration error: ${i}`)}}async claimInterface(e){if(!this.opened)throw new Error("claimInterface error: invalid state");if(!this.configuration)throw new Error("claimInterface error: interface not found");let r=this.configuration.interfaces.find(i=>i.interfaceNumber===e);if(!r)throw new Error("claimInterface error: interface not found");if(!r.claimed)try{this.device.interface(e).claim(),this.configuration.interfaces[this.configuration.interfaces.indexOf(r)]={interfaceNumber:e,alternate:r.alternate,alternates:r.alternates,claimed:!0}}catch(i){throw new Error(`claimInterface error: ${i}`)}}async releaseInterface(e){if(await this._releaseInterface(e),this.configuration){let r=this.configuration.interfaces.find(i=>i.interfaceNumber===e);r&&(this.configuration.interfaces[this.configuration.interfaces.indexOf(r)]={interfaceNumber:e,alternate:r.alternate,alternates:r.alternates,claimed:!1})}}async selectAlternateInterface(e,r){if(!this.opened)throw new Error("selectAlternateInterface error: invalid state");if(!this.configuration)throw new Error("selectAlternateInterface error: interface not found");let i=this.configuration.interfaces.find(n=>n.interfaceNumber===e);if(!i)throw new Error("selectAlternateInterface error: interface not found");if(!i.claimed)throw new Error("selectAlternateInterface error: invalid state");try{await this.device.interface(e).setAltSettingAsync(r)}catch(n){throw new Error(`selectAlternateInterface error: ${n}`)}}async controlTransferIn(e,r){try{this.checkDeviceOpen();let i=this.controlTransferParamsToType(e,x.LIBUSB_ENDPOINT_IN),n=await this.controlTransferAsync(i,e.request,e.value,e.index,r);return{data:n?new DataView(new Uint8Array(n).buffer):void 0,status:"ok"}}catch(i){if(i.errno===x.LIBUSB_TRANSFER_STALL)return{status:"stall"};if(i.errno===x.LIBUSB_TRANSFER_OVERFLOW)return{status:"babble"};throw new Error(`controlTransferIn error: ${i}`)}}async controlTransferOut(e,r){try{this.checkDeviceOpen();let i=this.controlTransferParamsToType(e,x.LIBUSB_ENDPOINT_OUT),n=r?Buffer.from(r):Buffer.alloc(0);return{bytesWritten:await this.controlTransferAsync(i,e.request,e.value,e.index,n),status:"ok"}}catch(i){if(i.errno===x.LIBUSB_TRANSFER_STALL)return{bytesWritten:0,status:"stall"};throw new Error(`controlTransferOut error: ${i}`)}}async clearHalt(e,r){try{let i=r|(e==="in"?x.LIBUSB_ENDPOINT_IN:x.LIBUSB_ENDPOINT_OUT);await this.controlTransferAsync(x.LIBUSB_RECIPIENT_ENDPOINT,$se,zse,i,Buffer.from(new Uint8Array))}catch(i){throw new Error(`clearHalt error: ${i}`)}}async transferIn(e,r){try{this.checkDeviceOpen();let n=await this.getEndpoint(e|x.LIBUSB_ENDPOINT_IN).transferAsync(r);return{data:n?new DataView(new Uint8Array(n).buffer):void 0,status:"ok"}}catch(i){if(i.errno===x.LIBUSB_TRANSFER_STALL)return{status:"stall"};if(i.errno===x.LIBUSB_TRANSFER_OVERFLOW)return{status:"babble"};throw new Error(`transferIn error: ${i}`)}}async transferOut(e,r){try{this.checkDeviceOpen();let i=this.getEndpoint(e|x.LIBUSB_ENDPOINT_OUT),n=Buffer.from(r);return{bytesWritten:await i.transferAsync(n),status:"ok"}}catch(i){if(i.errno===x.LIBUSB_TRANSFER_STALL)return{bytesWritten:0,status:"stall"};throw new Error(`transferOut error: ${i}`)}}async reset(){try{await this.resetAsync()}catch(e){throw new Error(`reset error: ${e}`)}}async isochronousTransferIn(e,r){throw new Error("isochronousTransferIn error: method not implemented")}async isochronousTransferOut(e,r,i){throw new Error("isochronousTransferOut error: method not implemented")}async forget(){throw new Error("forget error: method not implemented")}async initialize(){try{this.opened||(this.device.open(),this.deviceClass===255&&(0,PM.platform)()==="darwin"&&await this.setConfigurationAsync(1)),this.manufacturerName=await this.getStringDescriptor(this.device.deviceDescriptor.iManufacturer),this.productName=await this.getStringDescriptor(this.device.deviceDescriptor.iProduct),this.serialNumber=await this.getStringDescriptor(this.device.deviceDescriptor.iSerialNumber),this.configurations=await this.getConfigurations()}catch(e){throw new Error(`initialize error: ${e}`)}finally{this.opened&&this.device.close()}}decodeVersion(e){let r=`0000${e.toString(16)}`.slice(-4);return{major:parseInt(r.substr(0,2),void 0),minor:parseInt(r.substr(2,1),void 0),sub:parseInt(r.substr(3,1),void 0)}}async getStringDescriptor(e){try{let r=await this.getStringDescriptorAsync(e);return r?r.toString():""}catch{return""}}async getConfigurations(){let e=[];for(let r of this.device.allConfigDescriptors){let i=[];for(let n of r.interfaces){let o=[];for(let u of n){let d=[];for(let c of u.endpoints)d.push({endpointNumber:c.bEndpointAddress&Kse,direction:c.bEndpointAddress&x.LIBUSB_ENDPOINT_IN?"in":"out",type:(c.bmAttributes&xM)===x.LIBUSB_TRANSFER_TYPE_BULK?"bulk":(c.bmAttributes&xM)===x.LIBUSB_TRANSFER_TYPE_INTERRUPT?"interrupt":"isochronous",packetSize:c.wMaxPacketSize});o.push({alternateSetting:u.bAlternateSetting,interfaceClass:u.bInterfaceClass,interfaceSubclass:u.bInterfaceSubClass,interfaceProtocol:u.bInterfaceProtocol,interfaceName:await this.getStringDescriptor(u.iInterface),endpoints:d})}let s=n[0].bInterfaceNumber,l=o.find(u=>u.alternateSetting===this.device.interface(s).altSetting);l&&i.push({interfaceNumber:s,alternate:l,alternates:o,claimed:!1})}e.push({configurationValue:r.bConfigurationValue,configurationName:await this.getStringDescriptor(r.iConfiguration),interfaces:i})}return e}getEndpoint(e){if(this.device.interfaces)for(let r of this.device.interfaces){let i=r.endpoint(e);if(i)return i}}controlTransferParamsToType(e,r){let i=e.recipient==="device"?x.LIBUSB_RECIPIENT_DEVICE:e.recipient==="interface"?x.LIBUSB_RECIPIENT_INTERFACE:e.recipient==="endpoint"?x.LIBUSB_RECIPIENT_ENDPOINT:x.LIBUSB_RECIPIENT_OTHER,n=e.requestType==="standard"?x.LIBUSB_REQUEST_TYPE_STANDARD:e.requestType==="class"?x.LIBUSB_REQUEST_TYPE_CLASS:x.LIBUSB_REQUEST_TYPE_VENDOR;return i|n|r}async _releaseInterface(e){if(!this.opened)throw new Error("releaseInterface error: invalid state");if(!this.configuration)throw new Error("releaseInterface error: interface not found");let r=this.configuration.interfaces.find(i=>i.interfaceNumber===e);if(!r)throw new Error("releaseInterface error: interface not found");if(r.claimed)try{await this.device.interface(e).releaseAsync()}catch(i){throw new Error(`releaseInterface error: ${i}`)}}checkDeviceOpen(){if(!this.opened)throw new Error("The device must be opened first")}};Ms.WebUSBDevice=um});var lm=a(Mr=>{"use strict";Object.defineProperty(Mr,"__esModule",{value:!0});Mr.WebUSB=Mr.getWebUsb=void 0;var In=wn(),Jse=E("events"),Xse=dm(),Qse=()=>navigator&&navigator.usb?navigator.usb:new Ts;Mr.getWebUsb=Qse;var Pn=class extends Error{constructor(e,r){super(e),this.name=r}},Ts=class{constructor(e={}){this.options=e,this.emitter=new Jse.EventEmitter,this.knownDevices=new Map,this.authorisedDevices=new Set;let r=async n=>{let o=await this.getWebDevice(n);if(o&&this.isAuthorisedDevice(o)){let s={type:"connect",device:o};this.emitter.emit("connect",s)}},i=async n=>{if(this.knownDevices.has(n)){let o=this.knownDevices.get(n);if(o&&this.isAuthorisedDevice(o)){let s={type:"disconnect",device:o};this.emitter.emit("disconnect",s)}}};this.emitter.on("newListener",n=>{this.emitter.listenerCount(n)===0&&(n==="connect"?In.addListener("attach",r):n==="disconnect"&&In.addListener("detach",i))}),this.emitter.on("removeListener",n=>{this.emitter.listenerCount(n)===0&&(n==="connect"?In.removeListener("attach",r):n==="disconnect"&&In.removeListener("detach",i))})}set onconnect(e){this._onconnect&&(this.removeEventListener("connect",this._onconnect),this._onconnect=void 0),e&&(this._onconnect=e,this.addEventListener("connect",this._onconnect))}set ondisconnect(e){this._ondisconnect&&(this.removeEventListener("disconnect",this._ondisconnect),this._ondisconnect=void 0),e&&(this._ondisconnect=e,this.addEventListener("disconnect",this._ondisconnect))}addEventListener(e,r){this.emitter.addListener(e,r)}removeEventListener(e,r){this.emitter.removeListener(e,r)}dispatchEvent(e){return!1}async requestDevice(e){if(!e)throw new TypeError("requestDevice error: 1 argument required, but only 0 present");if(e.constructor!=={}.constructor)throw new TypeError("requestDevice error: parameter 1 (options) is not an object");if(!e.filters)throw new TypeError("requestDevice error: required member filters is undefined");if(e.filters.constructor!==[].constructor)throw new TypeError("requestDevice error: the provided value cannot be converted to a sequence");e.filters.forEach(i=>{if(i.protocolCode&&!i.subclassCode)throw new TypeError("requestDevice error: subclass code is required");if(i.subclassCode&&!i.classCode)throw new TypeError("requestDevice error: class code is required")});let r=await this.loadDevices(e.filters);if(r=r.filter(i=>this.filterDevice(i,e.filters)),r.length===0)throw new Pn("Failed to execute 'requestDevice' on 'USB': No device selected.","NotFoundError");try{let i=this.options.devicesFound?await this.options.devicesFound(r):r[0];if(!i)throw new Pn("Failed to execute 'requestDevice' on 'USB': No device selected.","NotFoundError");return this.authorisedDevices.add({vendorId:i.vendorId,productId:i.productId,classCode:i.deviceClass,subclassCode:i.deviceSubclass,protocolCode:i.deviceProtocol,serialNumber:i.serialNumber||void 0}),i}catch{throw new Pn("Failed to execute 'requestDevice' on 'USB': No device selected.","NotFoundError")}}async getDevices(){let e=this.options.allowAllDevices?void 0:this.options.allowedDevices;return(await this.loadDevices(e)).filter(i=>this.isAuthorisedDevice(i))}async loadDevices(e){let r=In.getDeviceList();r=this.quickFilter(r,e);let i=new Map;for(let n of r){let o=await this.getWebDevice(n);o&&i.set(n,o)}return this.knownDevices=i,[...this.knownDevices.values()]}async getWebDevice(e){if(!this.knownDevices.has(e)){this.options.deviceTimeout&&(e.timeout=this.options.deviceTimeout);try{let r=await Xse.WebUSBDevice.createInstance(e,this.options.autoDetachKernelDriver);this.knownDevices.set(e,r)}catch{}}return this.knownDevices.get(e)}quickFilter(e,r){return!r||!r.length?e:e.filter(i=>r.some(n=>!(n.vendorId&&n.vendorId!==i.deviceDescriptor.idVendor||n.productId&&n.productId!==i.deviceDescriptor.idProduct)))}filterDevice(e,r){return!r||!r.length?!0:r.some(i=>{if(i.vendorId&&i.vendorId!==e.vendorId||i.productId&&i.productId!==e.productId)return!1;if(i.classCode){if(!e.configuration)return!1;if(e.configuration.interfaces.some(o=>!(i.classCode&&i.classCode!==o.alternate.interfaceClass||i.subclassCode&&i.subclassCode!==o.alternate.interfaceSubclass||i.protocolCode&&i.protocolCode!==o.alternate.interfaceProtocol)))return!0}return!(i.classCode&&i.classCode!==e.deviceClass||i.subclassCode&&i.subclassCode!==e.deviceSubclass||i.protocolCode&&i.protocolCode!==e.deviceProtocol||i.serialNumber&&i.serialNumber!==e.serialNumber)})}isAuthorisedDevice(e){return this.options.allowAllDevices||this.options.allowedDevices&&this.filterDevice(e,this.options.allowedDevices)?!0:[...this.authorisedDevices.values()].some(r=>r.vendorId===e.vendorId&&r.productId===e.productId&&r.classCode===e.deviceClass&&r.subclassCode===e.deviceSubclass&&r.protocolCode===e.deviceProtocol&&r.serialNumber===e.serialNumber)}};Mr.WebUSB=Ts});var TM=a(MM=>{"use strict";Object.defineProperty(MM,"__esModule",{value:!0})});var jM=a(D=>{"use strict";var Yse=D&&D.__createBinding||(Object.create?(function(t,e,r,i){i===void 0&&(i=r);var n=Object.getOwnPropertyDescriptor(e,r);(!n||("get"in n?!e.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,i,n)}):(function(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]})),Tr=D&&D.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&Yse(e,t,r)};Object.defineProperty(D,"__esModule",{value:!0});D.LibUSBException=D.useUsbDkBackend=D.getDeviceList=D.Transfer=D.Device=D.webusb=D.findBySerialNumber=D.findByIds=D.usb=void 0;var Zse=E("util"),eae=lm(),pm=wn();D.usb=pm;var tae=(t,e)=>pm.getDeviceList().find(i=>i.deviceDescriptor.idVendor===t&&i.deviceDescriptor.idProduct===e);D.findByIds=tae;var rae=async t=>{let e=pm.getDeviceList(),r=i=>!!i.interfaces;for(let i of e)try{r(i)||i.open();let o=await(0,Zse.promisify)(i.getStringDescriptor).bind(i)(i.deviceDescriptor.iSerialNumber);if(o&&o.toString()===t)return i}catch{}finally{try{r(i)&&i.close()}catch{}}};D.findBySerialNumber=rae;var nae=new eae.WebUSB;D.webusb=nae;var xn=wn();Object.defineProperty(D,"Device",{enumerable:!0,get:function(){return xn.Device}});Object.defineProperty(D,"Transfer",{enumerable:!0,get:function(){return xn.Transfer}});Object.defineProperty(D,"getDeviceList",{enumerable:!0,get:function(){return xn.getDeviceList}});Object.defineProperty(D,"useUsbDkBackend",{enumerable:!0,get:function(){return xn.useUsbDkBackend}});Object.defineProperty(D,"LibUSBException",{enumerable:!0,get:function(){return xn.LibUSBException}});Tr(sm(),D);Tr(TM(),D);Tr(rm(),D);Tr(im(),D);Tr(lm(),D);Tr(dm(),D)});var qM=a(fm=>{"use strict";Object.defineProperty(fm,"__esModule",{value:!0});fm.default="ffffffff-ffff-ffff-ffff-ffffffffffff"});var RM=a(vm=>{"use strict";Object.defineProperty(vm,"__esModule",{value:!0});vm.default="00000000-0000-0000-0000-000000000000"});var NM=a(gm=>{"use strict";Object.defineProperty(gm,"__esModule",{value:!0});gm.default=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i});var Mn=a(hm=>{"use strict";Object.defineProperty(hm,"__esModule",{value:!0});var iae=NM();function oae(t){return typeof t=="string"&&iae.default.test(t)}hm.default=oae});var Tn=a(mm=>{"use strict";Object.defineProperty(mm,"__esModule",{value:!0});var sae=Mn();function aae(t){if(!(0,sae.default)(t))throw TypeError("Invalid UUID");let e;return Uint8Array.of((e=parseInt(t.slice(0,8),16))>>>24,e>>>16&255,e>>>8&255,e&255,(e=parseInt(t.slice(9,13),16))>>>8,e&255,(e=parseInt(t.slice(14,18),16))>>>8,e&255,(e=parseInt(t.slice(19,23),16))>>>8,e&255,(e=parseInt(t.slice(24,36),16))/1099511627776&255,e/4294967296&255,e>>>24&255,e>>>16&255,e>>>8&255,e&255)}mm.default=aae});var lt=a(js=>{"use strict";Object.defineProperty(js,"__esModule",{value:!0});js.unsafeStringify=UM;var cae=Mn(),J=[];for(let t=0;t<256;++t)J.push((t+256).toString(16).slice(1));function UM(t,e=0){return(J[t[e+0]]+J[t[e+1]]+J[t[e+2]]+J[t[e+3]]+"-"+J[t[e+4]]+J[t[e+5]]+"-"+J[t[e+6]]+J[t[e+7]]+"-"+J[t[e+8]]+J[t[e+9]]+"-"+J[t[e+10]]+J[t[e+11]]+J[t[e+12]]+J[t[e+13]]+J[t[e+14]]+J[t[e+15]]).toLowerCase()}function uae(t,e=0){let r=UM(t,e);if(!(0,cae.default)(r))throw TypeError("Stringified UUID is invalid");return r}js.default=uae});var Ns=a(ym=>{"use strict";Object.defineProperty(ym,"__esModule",{value:!0});ym.default=lae;var dae=E("crypto"),Rs=new Uint8Array(256),qs=Rs.length;function lae(){return qs>Rs.length-16&&((0,dae.randomFillSync)(Rs),qs=0),Rs.slice(qs,qs+=16)}});var bm=a(Us=>{"use strict";Object.defineProperty(Us,"__esModule",{value:!0});Us.updateV1State=FM;var BM=Ns(),pae=lt(),jn={};function fae(t,e,r){let i,n=t?._v6??!1;if(t){let o=Object.keys(t);o.length===1&&o[0]==="_v6"&&(t=void 0)}if(t)i=LM(t.random??t.rng?.()??(0,BM.default)(),t.msecs,t.nsecs,t.clockseq,t.node,e,r);else{let o=Date.now(),s=(0,BM.default)();FM(jn,o,s),i=LM(s,jn.msecs,jn.nsecs,n?void 0:jn.clockseq,n?void 0:jn.node,e,r)}return e?i:(0,pae.unsafeStringify)(i)}function FM(t,e,r){return t.msecs??=-1/0,t.nsecs??=0,e===t.msecs?(t.nsecs++,t.nsecs>=1e4&&(t.node=void 0,t.nsecs=0)):e>t.msecs?t.nsecs=0:e<t.msecs&&(t.node=void 0),t.node||(t.node=r.slice(10,16),t.node[0]|=1,t.clockseq=(r[8]<<8|r[9])&16383),t.msecs=e,t}function LM(t,e,r,i,n,o,s=0){o||(o=new Uint8Array(16),s=0),e??=Date.now(),r??=0,i??=(t[8]<<8|t[9])&16383,n??=t.slice(10,16),e+=122192928e5;let l=((e&268435455)*1e4+r)%4294967296;o[s++]=l>>>24&255,o[s++]=l>>>16&255,o[s++]=l>>>8&255,o[s++]=l&255;let u=e/4294967296*1e4&268435455;o[s++]=u>>>8&255,o[s++]=u&255,o[s++]=u>>>24&15|16,o[s++]=u>>>16&255,o[s++]=i>>>8|128,o[s++]=i&255;for(let d=0;d<6;++d)o[s++]=n[d];return o}Us.default=fae});var Sm=a(_m=>{"use strict";Object.defineProperty(_m,"__esModule",{value:!0});_m.default=hae;var vae=Tn(),gae=lt();function hae(t){let e=typeof t=="string"?(0,vae.default)(t):t,r=mae(e);return typeof t=="string"?(0,gae.unsafeStringify)(r):r}function mae(t){return Uint8Array.of((t[6]&15)<<4|t[7]>>4&15,(t[7]&15)<<4|(t[4]&240)>>4,(t[4]&15)<<4|(t[5]&240)>>4,(t[5]&15)<<4|(t[0]&240)>>4,(t[0]&15)<<4|(t[1]&240)>>4,(t[1]&15)<<4|(t[2]&240)>>4,96|t[2]&15,t[3],t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15])}});var kM=a(Dm=>{"use strict";Object.defineProperty(Dm,"__esModule",{value:!0});var yae=E("crypto");function bae(t){return Array.isArray(t)?t=Buffer.from(t):typeof t=="string"&&(t=Buffer.from(t,"utf8")),(0,yae.createHash)("md5").update(t).digest()}Dm.default=bae});var qn=a(Mt=>{"use strict";Object.defineProperty(Mt,"__esModule",{value:!0});Mt.URL=Mt.DNS=void 0;Mt.stringToBytes=GM;Mt.default=Sae;var VM=Tn(),_ae=lt();function GM(t){t=unescape(encodeURIComponent(t));let e=new Uint8Array(t.length);for(let r=0;r<t.length;++r)e[r]=t.charCodeAt(r);return e}Mt.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8";Mt.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function Sae(t,e,r,i,n,o){let s=typeof r=="string"?GM(r):r,l=typeof i=="string"?(0,VM.default)(i):i;if(typeof i=="string"&&(i=(0,VM.default)(i)),i?.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let u=new Uint8Array(16+s.length);if(u.set(l),u.set(s,l.length),u=e(u),u[6]=u[6]&15|t,u[8]=u[8]&63|128,n){o=o||0;for(let d=0;d<16;++d)n[o+d]=u[d];return n}return(0,_ae.unsafeStringify)(u)}});var WM=a(ar=>{"use strict";Object.defineProperty(ar,"__esModule",{value:!0});ar.URL=ar.DNS=void 0;var Dae=kM(),Om=qn(),HM=qn();Object.defineProperty(ar,"DNS",{enumerable:!0,get:function(){return HM.DNS}});Object.defineProperty(ar,"URL",{enumerable:!0,get:function(){return HM.URL}});function Em(t,e,r,i){return(0,Om.default)(48,Dae.default,t,e,r,i)}Em.DNS=Om.DNS;Em.URL=Om.URL;ar.default=Em});var KM=a(Cm=>{"use strict";Object.defineProperty(Cm,"__esModule",{value:!0});var Oae=E("crypto");Cm.default={randomUUID:Oae.randomUUID}});var zM=a(Am=>{"use strict";Object.defineProperty(Am,"__esModule",{value:!0});var $M=KM(),Eae=Ns(),Cae=lt();function Aae(t,e,r){if($M.default.randomUUID&&!e&&!t)return $M.default.randomUUID();t=t||{};let i=t.random||(t.rng||Eae.default)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,e){r=r||0;for(let n=0;n<16;++n)e[r+n]=i[n];return e}return(0,Cae.unsafeStringify)(i)}Am.default=Aae});var JM=a(wm=>{"use strict";Object.defineProperty(wm,"__esModule",{value:!0});var wae=E("crypto");function Iae(t){return Array.isArray(t)?t=Buffer.from(t):typeof t=="string"&&(t=Buffer.from(t,"utf8")),(0,wae.createHash)("sha1").update(t).digest()}wm.default=Iae});var QM=a(cr=>{"use strict";Object.defineProperty(cr,"__esModule",{value:!0});cr.URL=cr.DNS=void 0;var Pae=JM(),Im=qn(),XM=qn();Object.defineProperty(cr,"DNS",{enumerable:!0,get:function(){return XM.DNS}});Object.defineProperty(cr,"URL",{enumerable:!0,get:function(){return XM.URL}});function Pm(t,e,r,i){return(0,Im.default)(80,Pae.default,t,e,r,i)}Pm.DNS=Im.DNS;Pm.URL=Im.URL;cr.default=Pm});var YM=a(xm=>{"use strict";Object.defineProperty(xm,"__esModule",{value:!0});var xae=lt(),Mae=bm(),Tae=Sm();function jae(t,e,r){t??={},r??=0;let i=(0,Mae.default)({...t,_v6:!0},new Uint8Array(16));if(i=(0,Tae.default)(i),e){for(let n=0;n<16;n++)e[r+n]=i[n];return e}return(0,xae.unsafeStringify)(i)}xm.default=jae});var ZM=a(Mm=>{"use strict";Object.defineProperty(Mm,"__esModule",{value:!0});Mm.default=Nae;var qae=Tn(),Rae=lt();function Nae(t){let e=typeof t=="string"?(0,qae.default)(t):t,r=Uae(e);return typeof t=="string"?(0,Rae.unsafeStringify)(r):r}function Uae(t){return Uint8Array.of((t[3]&15)<<4|t[4]>>4&15,(t[4]&15)<<4|(t[5]&240)>>4,(t[5]&15)<<4|t[6]&15,t[7],(t[1]&15)<<4|(t[2]&240)>>4,(t[2]&15)<<4|(t[3]&240)>>4,16|(t[0]&240)>>4,(t[0]&15)<<4|(t[1]&240)>>4,t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15])}});var nT=a(Bs=>{"use strict";Object.defineProperty(Bs,"__esModule",{value:!0});Bs.updateV7State=rT;var eT=Ns(),Bae=lt(),Tm={};function Lae(t,e,r){let i;if(t)i=tT(t.random??t.rng?.()??(0,eT.default)(),t.msecs,t.seq,e,r);else{let n=Date.now(),o=(0,eT.default)();rT(Tm,n,o),i=tT(o,Tm.msecs,Tm.seq,e,r)}return e?i:(0,Bae.unsafeStringify)(i)}function rT(t,e,r){return t.msecs??=-1/0,t.seq??=0,e>t.msecs?(t.seq=r[6]<<23|r[7]<<16|r[8]<<8|r[9],t.msecs=e):(t.seq=t.seq+1|0,t.seq===0&&t.msecs++),t}function tT(t,e,r,i,n=0){return i||(i=new Uint8Array(16),n=0),e??=Date.now(),r??=t[6]*127<<24|t[7]<<16|t[8]<<8|t[9],i[n++]=e/1099511627776&255,i[n++]=e/4294967296&255,i[n++]=e/16777216&255,i[n++]=e/65536&255,i[n++]=e/256&255,i[n++]=e&255,i[n++]=112|r>>>28&15,i[n++]=r>>>20&255,i[n++]=128|r>>>14&63,i[n++]=r>>>6&255,i[n++]=r<<2&255|t[10]&3,i[n++]=t[11],i[n++]=t[12],i[n++]=t[13],i[n++]=t[14],i[n++]=t[15],i}Bs.default=Lae});var iT=a(jm=>{"use strict";Object.defineProperty(jm,"__esModule",{value:!0});var Fae=Mn();function kae(t){if(!(0,Fae.default)(t))throw TypeError("Invalid UUID");return parseInt(t.slice(14,15),16)}jm.default=kae});var oT=a(O=>{"use strict";Object.defineProperty(O,"__esModule",{value:!0});O.version=O.validate=O.v7=O.v6ToV1=O.v6=O.v5=O.v4=O.v3=O.v1ToV6=O.v1=O.stringify=O.parse=O.NIL=O.MAX=void 0;var Vae=qM();Object.defineProperty(O,"MAX",{enumerable:!0,get:function(){return Vae.default}});var Gae=RM();Object.defineProperty(O,"NIL",{enumerable:!0,get:function(){return Gae.default}});var Hae=Tn();Object.defineProperty(O,"parse",{enumerable:!0,get:function(){return Hae.default}});var Wae=lt();Object.defineProperty(O,"stringify",{enumerable:!0,get:function(){return Wae.default}});var Kae=bm();Object.defineProperty(O,"v1",{enumerable:!0,get:function(){return Kae.default}});var $ae=Sm();Object.defineProperty(O,"v1ToV6",{enumerable:!0,get:function(){return $ae.default}});var zae=WM();Object.defineProperty(O,"v3",{enumerable:!0,get:function(){return zae.default}});var Jae=zM();Object.defineProperty(O,"v4",{enumerable:!0,get:function(){return Jae.default}});var Xae=QM();Object.defineProperty(O,"v5",{enumerable:!0,get:function(){return Xae.default}});var Qae=YM();Object.defineProperty(O,"v6",{enumerable:!0,get:function(){return Qae.default}});var Yae=ZM();Object.defineProperty(O,"v6ToV1",{enumerable:!0,get:function(){return Yae.default}});var Zae=nT();Object.defineProperty(O,"v7",{enumerable:!0,get:function(){return Zae.default}});var ece=Mn();Object.defineProperty(O,"validate",{enumerable:!0,get:function(){return ece.default}});var tce=iT();Object.defineProperty(O,"version",{enumerable:!0,get:function(){return tce.default}})});var Rm=a((Nhe,aT)=>{"use strict";var qm=Object.defineProperty,rce=Object.getOwnPropertyDescriptor,nce=Object.getOwnPropertyNames,ice=Object.prototype.hasOwnProperty,oce=(t,e)=>{for(var r in e)qm(t,r,{get:e[r],enumerable:!0})},sce=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of nce(e))!ice.call(t,n)&&n!==r&&qm(t,n,{get:()=>e[n],enumerable:!(i=rce(e,n))||i.enumerable});return t},ace=t=>sce(qm({},"__esModule",{value:!0}),t),sT={};oce(sT,{FRAME_SIZE:()=>cce,RECONNECT_DEVICE_TIMEOUT:()=>uce});aT.exports=ace(sT);var cce=64,uce=6e3});var lT=a((Uhe,dT)=>{"use strict";var Um=Object.defineProperty,dce=Object.getOwnPropertyDescriptor,lce=Object.getOwnPropertyNames,pce=Object.prototype.hasOwnProperty,fce=(t,e)=>{for(var r in e)Um(t,r,{get:e[r],enumerable:!0})},vce=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of lce(e))!pce.call(t,n)&&n!==r&&Um(t,n,{get:()=>e[n],enumerable:!(i=dce(e,n))||i.enumerable});return t},gce=t=>vce(Um({},"__esModule",{value:!0}),t),uT={};fce(uT,{NodeHidApduSender:()=>Nm});dT.exports=gce(uT);var Rn=Ds(),hce=Yh(),N=b(),mce=Rm(),cT=Os(),Nm=class{dependencies;apduSenderFactory;apduSender;apduReceiverFactory;apduReceiver;logger;hidAsync;sendApduPromiseResolver;abortTimeout;constructor({dependencies:e,apduSenderFactory:r,apduReceiverFactory:i,loggerFactory:n}){let o=N.Maybe.of(Rn.FramerUtils.numberToByteArray(Math.floor(Math.random()*65535),2));this.dependencies=e,this.apduSenderFactory=r,this.apduSender=this.apduSenderFactory({frameSize:mce.FRAME_SIZE,channel:o,padding:!0}),this.apduReceiverFactory=i,this.apduReceiver=this.apduReceiverFactory({channel:o}),this.logger=n("NodeHidApduSender"),this.hidAsync=N.Nothing,this.sendApduPromiseResolver=N.Nothing,this.abortTimeout=N.Nothing}async sendApdu(e,r,i){return this.hidAsync.caseOf({Just:async n=>{let o=new Promise(s=>{this.sendApduPromiseResolver=(0,N.Just)(s)});for(let s of this.apduSender.getFrames(e))try{let l=Buffer.from([0].concat([...s.getRawData()]));await n.write(l)}catch(l){return this.logger.info("Error sending frame",{data:{error:l}}),Promise.resolve((0,N.Left)(new cT.NodeHidSendReportError(l)))}return this.logger.debug((0,Rn.formatApduSentLog)(e)),i&&(this.abortTimeout=(0,N.Just)(setTimeout(()=>{this.logger.debug("[sendApdu] Abort timeout",{data:{abortTimeout:i}}),this.resolvePendingApdu((0,N.Left)(new Rn.SendApduTimeoutError("Abort timeout")))},i))),o},Nothing:()=>Promise.resolve((0,N.Left)(new Rn.OpeningConnectionError("Device not connected")))})}getDependencies(){return this.dependencies}setDependencies(e){this.dependencies=e}async setupConnection(){if(await this.hidAsync.caseOf({Just:async e=>{try{await e.close(),this.hidAsync=N.Nothing,this.sendApduPromiseResolver=N.Nothing,this.abortTimeout=N.Nothing}catch(r){throw this.logger.error("Error while closing device",{data:{device:this.dependencies.device,error:r}}),r}},Nothing:()=>Promise.resolve()}),this.dependencies.device.path===void 0)throw new Error("Missing device path");return await new Promise(e=>setTimeout(e,300)),this.hidAsync=N.Maybe.of(await hce.HIDAsync.open(this.dependencies.device.path,{nonExclusive:!0})),this.hidAsync.caseOf({Just:e=>{e.on("data",r=>this.receiveHidInputReport(r)),e.on("error",r=>{this.logger.error("Error while receiving data",{data:{error:r}}),this.resolvePendingApdu((0,N.Left)(new cT.NodeHidSendReportError(r)))}),this.logger.info("\u{1F50C} Connected to device")},Nothing:()=>{let e=new Error("Error while opening device");throw this.logger.error("Error while opening device",{data:{error:e}}),e}})}async closeConnection(){return this.hidAsync.caseOf({Just:async e=>{try{await e.close(),this.hidAsync=N.Nothing,this.sendApduPromiseResolver=N.Nothing,this.abortTimeout=N.Nothing,this.logger.info("\u{1F51A} Disconnect")}catch(r){throw this.logger.error("Error while closing device",{data:{device:this.dependencies.device,error:r}}),r}},Nothing:()=>{}})}receiveHidInputReport(e){let r=new Uint8Array(e);this.apduReceiver.handleFrame(r).map(i=>{i.map(n=>{this.logger.debug((0,Rn.formatApduReceivedLog)(n)),this.resolvePendingApdu((0,N.Right)(n))})}).mapLeft(i=>{this.resolvePendingApdu((0,N.Left)(i))})}resolvePendingApdu(e){this.abortTimeout.map(r=>{this.abortTimeout=N.Nothing,clearTimeout(r)}),this.sendApduPromiseResolver.map(r=>{this.sendApduPromiseResolver=N.Nothing,r(e)})}}});var hT=a((Bhe,gT)=>{"use strict";var Bm=Object.defineProperty,yce=Object.getOwnPropertyDescriptor,bce=Object.getOwnPropertyNames,_ce=Object.prototype.hasOwnProperty,Sce=(t,e)=>{for(var r in e)Bm(t,r,{get:e[r],enumerable:!0})},Dce=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of bce(e))!_ce.call(t,n)&&n!==r&&Bm(t,n,{get:()=>e[n],enumerable:!(i=yce(e,n))||i.enumerable});return t},Oce=t=>Dce(Bm({},"__esModule",{value:!0}),t),fT={};Sce(fT,{NodeHidTransport:()=>Ls,nodeHidIdentifier:()=>vT,nodeHidTransportFactory:()=>Pce});gT.exports=Oce(fT);var he=Ds(),pT=Yh(),me=b(),Nn=De(),Un=jM(),Ece=oT(),Cce=Rm(),Ace=Os(),wce=lT(),Ice={devicesAsync:pT.devicesAsync,HIDAsync:pT.HIDAsync},vT="NODE-HID",Ls=class{constructor(e,r,i,n,o=l=>new he.DeviceConnectionStateMachine(l),s=l=>new wce.NodeHidApduSender(l)){this._deviceModelDataSource=e,this._loggerServiceFactory=r,this._apduSenderFactory=i,this._apduReceiverFactory=n,this._deviceConnectionStateMachineFactory=o,this._deviceApduSenderFactory=s,this._logger=r("NodeHidTransport"),this.startListeningToConnectionEvents()}_transportDiscoveredDevices=new Nn.BehaviorSubject([]);_deviceConnectionsByHidDevice=new Map;_deviceConnectionsPendingReconnection=new Set;_connectionListenersAbortController=new AbortController;_logger;connectionType="USB";identifier=vT;get hidApi(){return this.isSupported()?(0,me.Right)(Ice):(0,me.Left)(new Ace.NodeHidTransportNotSupportedError("NodeHID not supported"))}isSupported(){try{return this._logger.debug("isSupported: true"),!0}catch(e){return this._logger.error("isSupported: error",{data:{error:e}}),!1}}getIdentifier(){return this.identifier}async getDevices(){return me.EitherAsync.liftEither(this.hidApi).map(async e=>{try{let r=(await e.devicesAsync()).filter(i=>i.vendorId===he.LEDGER_VENDOR_ID);return Array.from(new Map(r.map(i=>[`${i.vendorId}:${i.productId}`,i])).values())}catch(r){let i=new he.NoAccessibleDeviceError(r);throw this._logger.error("getDevices: error getting devices",{data:{error:r}}),i}})}mapHIDDeviceToTransportDiscoveredDevice(e){let r=this._transportDiscoveredDevices.getValue().find(n=>n.hidDevice.vendorId===e.vendorId&&n.hidDevice.productId===e.productId);if(r)return r;let i=this._deviceConnectionsByHidDevice.get(e);return this.getDeviceModel(e).caseOf({Just:n=>{let o=i?.getDeviceId()??(0,Ece.v4)(),s={id:o,deviceModel:n,hidDevice:e,transport:this.identifier};return this._logger.debug(`Discovered device ${o} ${s.deviceModel.productName}`),s},Nothing:()=>{throw this._logger.warn(`Device not recognized: hidDevice.productId: 0x${e.productId.toString(16)}`),new he.DeviceNotRecognizedError(`Device not recognized: hidDevice.productId: 0x${e.productId.toString(16)}`)}})}listenToAvailableDevices(){return this.updateTransportDiscoveredDevices(),this._transportDiscoveredDevices.pipe((0,Nn.map)(e=>e.map(({hidDevice:r,...i})=>i)))}async updateTransportDiscoveredDevices(){(await this.getDevices()).caseOf({Left:e=>{this._logger.error("Error while getting accessible device",{data:{error:e}})},Right:e=>{this._transportDiscoveredDevices.next(e.map(r=>this.mapHIDDeviceToTransportDiscoveredDevice(r)))}})}async promptDeviceAccess(){return me.EitherAsync.liftEither(this.hidApi).map(async e=>{let r=[];try{r=(await e.devicesAsync()).filter(n=>n.vendorId===he.LEDGER_VENDOR_ID),await this.updateTransportDiscoveredDevices()}catch(n){let o=new he.NoAccessibleDeviceError(n);throw this._logger.error("promptDeviceAccess: error requesting device",{data:{error:n}}),o}if(this._logger.debug(`promptDeviceAccess: hidDevices len ${r.length}`),r.length===0)throw this._logger.warn("No device was selected"),new he.NoAccessibleDeviceError("No selected device");let i=[];for(let n of r)i.push(n),this._logger.debug("promptDeviceAccess: selected device",{data:{hidDevice:n}});return i}).run()}startDiscovering(){return this._logger.debug("startDiscovering"),(0,Nn.from)(this.promptDeviceAccess()).pipe((0,Nn.switchMap)(e=>e.caseOf({Left:r=>{throw this._logger.error("Error while getting accessible device",{data:{error:r}}),r},Right:r=>{this._logger.info(`Got access to ${r.length} HID devices`);let i=r.map(n=>this.mapHIDDeviceToTransportDiscoveredDevice(n));return(0,Nn.from)(i)}})))}stopDiscovering(){}startListeningToConnectionEvents(){this._logger.debug("startListeningToConnectionEvents"),Un.usb.on("attach",e=>{this.handleDeviceConnection(e)}),Un.usb.on("detach",e=>{this.handleDeviceDisconnection(e)}),process.on("exit",()=>{Un.usb.unrefHotplugEvents(),Un.usb.removeAllListeners()})}stopListeningToConnectionEvents(){this._logger.debug("stopListeningToConnectionEvents"),this._connectionListenersAbortController.abort(),Un.usb.removeAllListeners()}async connect({deviceId:e,onDisconnect:r}){this._logger.debug("connect",{data:{deviceId:e}});let i=this._transportDiscoveredDevices.getValue().find(u=>u.id===e);if(!i)return this._logger.error(`Unknown device ${e}`),(0,me.Left)(new he.UnknownDeviceError(`Unknown device ${e}`));let n=this._deviceConnectionsByHidDevice.get(i.hidDevice);if(n)return(0,me.Right)(new he.TransportConnectedDevice({id:e,deviceModel:i.deviceModel,type:this.connectionType,sendApdu:(...u)=>n.sendApdu(...u),transport:this.identifier}));let o=this._deviceApduSenderFactory({dependencies:{device:i.hidDevice},apduSenderFactory:this._apduSenderFactory,apduReceiverFactory:this._apduReceiverFactory,loggerFactory:this._loggerServiceFactory}),s=this._deviceConnectionStateMachineFactory({deviceId:e,deviceApduSender:o,timeoutDuration:Cce.RECONNECT_DEVICE_TIMEOUT,tryToReconnect:()=>{this._deviceConnectionsByHidDevice.forEach((u,d)=>{u.getDeviceId()===e&&(this._deviceConnectionsPendingReconnection.add(u),this._deviceConnectionsByHidDevice.delete(d))})},onTerminated:()=>{this._deviceConnectionsPendingReconnection.forEach(u=>{u.getDeviceId()===e&&(this._deviceConnectionsPendingReconnection.delete(u),r(u.getDeviceId()))}),this._deviceConnectionsByHidDevice.forEach((u,d)=>{u.getDeviceId()===e&&(this._deviceConnectionsByHidDevice.delete(d),r(u.getDeviceId()))})}});try{await s.setupConnection()}catch(u){return this._logger.error("Error while setting up device connection",{data:{error:u}}),(0,me.Left)(new he.OpeningConnectionError(u))}this._deviceConnectionsByHidDevice.set(i.hidDevice,s);let l=new he.TransportConnectedDevice({sendApdu:(...u)=>s.sendApdu(...u),deviceModel:i.deviceModel,id:e,type:this.connectionType,transport:this.identifier});return(0,me.Right)(l)}getDeviceModel(e){let{productId:r}=e,i=this._deviceModelDataSource.getAllDeviceModels().find(n=>n.usbProductId===r>>8||n.bootloaderUsbProductId===r);return i?me.Maybe.of(i):me.Maybe.zero()}getHidUsbProductId(e){return this.getDeviceModel(e).caseOf({Just:r=>r.usbProductId,Nothing:()=>e.productId>>8})}async disconnect(e){this._logger.debug("disconnect",{data:{connectedDevice:e}});let r=Array.from(this._deviceConnectionsByHidDevice.values()).find(i=>i.getDeviceId()===e.connectedDevice.id);return r?(r.closeConnection(),Promise.resolve((0,me.Right)(void 0))):(this._logger.error("No matching device connection found",{data:{connectedDevice:e}}),Promise.resolve((0,me.Left)(new he.UnknownDeviceError(`Unknown device ${e.connectedDevice.id}`))))}async handleDeviceDisconnection(e){let{idVendor:r,idProduct:i}=e.deviceDescriptor;r===he.LEDGER_VENDOR_ID&&(this._logger.info("[handleDeviceDisconnectionEvent] Device disconnected",{data:{vendorId:r,productId:i}}),this.updateTransportDiscoveredDevices(),(()=>{for(let[n,o]of this._deviceConnectionsByHidDevice.entries())if(n.vendorId===r&&(n.productId>>8===i||n.productId===i))return(0,me.Just)(o);return me.Nothing})().caseOf({Just:n=>{try{n.eventDeviceDisconnected()}catch(o){this._logger.error("Error while handling device disconnection",{data:{error:o}})}},Nothing:()=>{this._logger.error("No matching device connection found",{data:{vendorId:r,productId:i}})}}))}async handleDeviceReconnection(e,r){try{this._deviceConnectionsPendingReconnection.delete(e),e.setDependencies({device:r}),await e.setupConnection(),this._deviceConnectionsByHidDevice.set(r,e),e.eventDeviceConnected()}catch(i){this._logger.error("Error while reconnecting to device",{data:{error:i}}),e.closeConnection()}}async handleDeviceConnection(e){let{idVendor:r,idProduct:i}=e.deviceDescriptor;r===he.LEDGER_VENDOR_ID&&(this._logger.info("[handleDeviceConnection] New device connected",{data:{vendorId:r,productId:i}}),(await this.getDevices()).caseOf({Left:n=>{this._logger.error("Error while getting HID devices for reconnection",{data:{error:n}})},Right:async n=>{let o=n.find(l=>l.vendorId===r&&(l.productId>>8===i||l.productId===i));if(!o){this._logger.debug("[handleDeviceConnection] No matching HID device found",{data:{vendorId:r,productId:i}});return}let s=Array.from(this._deviceConnectionsPendingReconnection).find(l=>this.getHidUsbProductId(l.getDependencies().device)===this.getHidUsbProductId(o));s&&await this.handleDeviceReconnection(s,o),await this.updateTransportDiscoveredDevices()}}))}destroy(){this.stopListeningToConnectionEvents(),this._deviceConnectionsByHidDevice.forEach(e=>{e.closeConnection()}),this._deviceConnectionsPendingReconnection.clear()}},Pce=({deviceModelDataSource:t,loggerServiceFactory:e,apduSenderServiceFactory:r,apduReceiverServiceFactory:i})=>new Ls(t,e,r,i)});var mT=a((Lhe,Gm)=>{"use strict";var km=Object.defineProperty,xce=Object.getOwnPropertyDescriptor,Mce=Object.getOwnPropertyNames,Tce=Object.prototype.hasOwnProperty,jce=(t,e)=>{for(var r in e)km(t,r,{get:e[r],enumerable:!0})},Fm=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Mce(e))!Tce.call(t,n)&&n!==r&&km(t,n,{get:()=>e[n],enumerable:!(i=xce(e,n))||i.enumerable});return t},qce=(t,e,r)=>(Fm(t,e,"default"),r&&Fm(r,e,"default")),Rce=t=>Fm(km({},"__esModule",{value:!0}),t),Vm={};jce(Vm,{NodeHidTransport:()=>Lm.NodeHidTransport,nodeHidIdentifier:()=>Lm.nodeHidIdentifier,nodeHidTransportFactory:()=>Lm.nodeHidTransportFactory});Gm.exports=Rce(Vm);qce(Vm,Os(),Gm.exports);var Lm=hT()});var kce=a((Fhe,Wm)=>{var yT=Object.defineProperty,Nce=Object.getOwnPropertyDescriptor,Uce=Object.getOwnPropertyNames,Bce=Object.prototype.hasOwnProperty,Hm=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Uce(e))!Bce.call(t,n)&&n!==r&&yT(t,n,{get:()=>e[n],enumerable:!(i=Nce(e,n))||i.enumerable});return t},Lce=(t,e,r)=>(Hm(t,e,"default"),r&&Hm(r,e,"default")),Fce=t=>Hm(yT({},"__esModule",{value:!0}),t),bT={};Wm.exports=Fce(bT);Lce(bT,mT(),Wm.exports)});export default kce();